summaryrefslogtreecommitdiff
path: root/spec/ruby/core/kernel/instance_of_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/kernel/instance_of_spec.rb')
-rw-r--r--spec/ruby/core/kernel/instance_of_spec.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/spec/ruby/core/kernel/instance_of_spec.rb b/spec/ruby/core/kernel/instance_of_spec.rb
index d1170d5047..8d19974aa3 100644
--- a/spec/ruby/core/kernel/instance_of_spec.rb
+++ b/spec/ruby/core/kernel/instance_of_spec.rb
@@ -33,8 +33,8 @@ describe "Kernel#instance_of?" do
end
it "raises a TypeError if given an object that is not a Class nor a Module" do
- -> { @o.instance_of?(Object.new) }.should raise_error(TypeError)
- -> { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError)
- -> { @o.instance_of?(1) }.should raise_error(TypeError)
+ -> { @o.instance_of?(Object.new) }.should.raise(TypeError)
+ -> { @o.instance_of?('KernelSpecs::InstanceClass') }.should.raise(TypeError)
+ -> { @o.instance_of?(1) }.should.raise(TypeError)
end
end
ass='graph'>
-rw-r--r--README.EXT79
-rw-r--r--README.EXT.ja104
-rw-r--r--README.ja8
-rw-r--r--ToDo14
-rw-r--r--array.c1935
-rw-r--r--bcc32/Makefile.sub167
-rw-r--r--bcc32/README.bcc3225
-rwxr-xr-xbcc32/configure.bat13
-rwxr-xr-xbcc32/mkexports.rb39
-rw-r--r--bcc32/setup.mak6
-rw-r--r--benchmark/bm_app_answer.rb15
-rw-r--r--benchmark/bm_app_erb.rb26
-rw-r--r--benchmark/bm_app_factorial.rb11
-rw-r--r--benchmark/bm_app_fib.rb10
-rw-r--r--benchmark/bm_app_mandelbrot.rb23
-rw-r--r--benchmark/bm_app_pentomino.rb259
-rw-r--r--benchmark/bm_app_raise.rb8
-rw-r--r--benchmark/bm_app_strconcat.rb5
-rw-r--r--benchmark/bm_app_tak.rb13
-rw-r--r--benchmark/bm_app_tarai.rb10
-rw-r--r--benchmark/bm_app_uri.rb8
-rw-r--r--benchmark/bm_io_file_create.rb13
-rw-r--r--benchmark/bm_io_file_read.rb15
-rw-r--r--benchmark/bm_io_file_write.rb14
-rw-r--r--benchmark/bm_loop_generator.rb14
-rw-r--r--benchmark/bm_loop_times.rb1
-rw-r--r--benchmark/bm_loop_whileloop.rb4
-rw-r--r--benchmark/bm_loop_whileloop2.rb4
-rw-r--r--benchmark/bm_so_ackermann.rb19
-rw-r--r--benchmark/bm_so_array.rb23
-rw-r--r--benchmark/bm_so_binary_trees.rb57
-rw-r--r--benchmark/bm_so_concatenate.rb18
-rw-r--r--benchmark/bm_so_count_words.rb19
-rw-r--r--benchmark/bm_so_exception.rb61
-rw-r--r--benchmark/bm_so_fannkuch.rb45
-rw-r--r--benchmark/bm_so_fasta.rb81
-rw-r--r--benchmark/bm_so_k_nucleotide.rb48
-rw-r--r--benchmark/bm_so_lists.rb47
-rw-r--r--benchmark/bm_so_mandelbrot.rb57
-rw-r--r--benchmark/bm_so_matrix.rb48
-rw-r--r--benchmark/bm_so_meteor_contest.rb564
-rw-r--r--benchmark/bm_so_nbody.rb148
-rw-r--r--benchmark/bm_so_nested_loop.rb24
-rw-r--r--benchmark/bm_so_nsieve.rb35
-rw-r--r--benchmark/bm_so_nsieve_bits.rb42
-rw-r--r--benchmark/bm_so_object.rb56
-rw-r--r--benchmark/bm_so_partial_sums.rb31
-rw-r--r--benchmark/bm_so_pidigits.rb92
-rw-r--r--benchmark/bm_so_random.rb20
-rw-r--r--benchmark/bm_so_reverse_complement.rb30
-rw-r--r--benchmark/bm_so_sieve.rb24
-rw-r--r--benchmark/bm_so_spectralnorm.rb50
-rw-r--r--benchmark/bm_vm1_block.rb10
-rw-r--r--benchmark/bm_vm1_const.rb8
-rw-r--r--benchmark/bm_vm1_ensure.rb11
-rw-r--r--benchmark/bm_vm1_ivar.rb8
-rw-r--r--benchmark/bm_vm1_ivar_set.rb6
-rw-r--r--benchmark/bm_vm1_length.rb9
-rw-r--r--benchmark/bm_vm1_neq.rb8
-rw-r--r--benchmark/bm_vm1_not.rb7
-rw-r--r--benchmark/bm_vm1_rescue.rb7
-rw-r--r--benchmark/bm_vm1_simplereturn.rb9
-rw-r--r--benchmark/bm_vm1_swap.rb8
-rw-r--r--benchmark/bm_vm2_array.rb5
-rw-r--r--benchmark/bm_vm2_case.rb14
-rw-r--r--benchmark/bm_vm2_eval.rb6
-rw-r--r--benchmark/bm_vm2_method.rb9
-rw-r--r--benchmark/bm_vm2_mutex.rb9
-rw-r--r--benchmark/bm_vm2_poly_method.rb20
-rw-r--r--benchmark/bm_vm2_poly_method_ov.rb20
-rw-r--r--benchmark/bm_vm2_proc.rb14
-rw-r--r--benchmark/bm_vm2_regexp.rb6
-rw-r--r--benchmark/bm_vm2_send.rb12
-rw-r--r--benchmark/bm_vm2_super.rb20
-rw-r--r--benchmark/bm_vm2_unif1.rb8
-rw-r--r--benchmark/bm_vm2_zsuper.rb20
-rw-r--r--benchmark/bm_vm3_thread_create_join.rb6
-rw-r--r--benchmark/bm_vm3_thread_mutex.rb18
-rw-r--r--benchmark/driver.rb253
-rw-r--r--benchmark/make_fasta_output.rb19
-rw-r--r--benchmark/other-lang/ack.pl11
-rw-r--r--benchmark/other-lang/ack.py16
-rw-r--r--benchmark/other-lang/ack.rb12
-rw-r--r--benchmark/other-lang/ack.scm7
-rw-r--r--benchmark/other-lang/eval.rb66
-rw-r--r--benchmark/other-lang/fact.pl13
-rw-r--r--benchmark/other-lang/fact.py18
-rw-r--r--benchmark/other-lang/fact.rb13
-rw-r--r--benchmark/other-lang/fact.scm8
-rw-r--r--benchmark/other-lang/fib.pl11
-rw-r--r--benchmark/other-lang/fib.py7
-rw-r--r--benchmark/other-lang/fib.rb9
-rw-r--r--benchmark/other-lang/fib.scm7
-rw-r--r--benchmark/other-lang/loop.pl3
-rw-r--r--benchmark/other-lang/loop.py2
-rw-r--r--benchmark/other-lang/loop.rb4
-rw-r--r--benchmark/other-lang/loop.scm1
-rw-r--r--benchmark/other-lang/loop2.rb1
-rw-r--r--benchmark/other-lang/tak.pl11
-rw-r--r--benchmark/other-lang/tak.py8
-rw-r--r--benchmark/other-lang/tak.rb13
-rw-r--r--benchmark/other-lang/tak.scm10
-rw-r--r--benchmark/prepare_so_count_words.rb15
-rw-r--r--benchmark/prepare_so_k_nucleotide.rb2
-rw-r--r--benchmark/prepare_so_reverse_complement.rb2
-rw-r--r--benchmark/report.rb81
-rw-r--r--benchmark/run.rb127
-rw-r--r--benchmark/runc.rb29
-rw-r--r--benchmark/wc.input.base25
-rw-r--r--bignum.c1330
-rwxr-xr-xbin/gem23
-rw-r--r--bin/irb2
-rwxr-xr-xbin/rake31
-rw-r--r--bin/rdoc2
-rwxr-xr-xbin/ri2
-rw-r--r--blockinlining.c458
-rw-r--r--bootstraptest/pending.rb25
-rw-r--r--bootstraptest/runner.rb318
-rw-r--r--bootstraptest/test_block.rb549
-rw-r--r--bootstraptest/test_class.rb217
-rw-r--r--bootstraptest/test_eval.rb200
-rw-r--r--bootstraptest/test_exception.rb404
-rw-r--r--bootstraptest/test_flip.rb1
-rw-r--r--bootstraptest/test_flow.rb491
-rw-r--r--bootstraptest/test_fork.rb10
-rw-r--r--bootstraptest/test_io.rb38
-rw-r--r--bootstraptest/test_jump.rb250
-rw-r--r--bootstraptest/test_knownbug.rb4
-rw-r--r--bootstraptest/test_literal.rb178
-rw-r--r--bootstraptest/test_load.rb15
-rw-r--r--bootstraptest/test_m17n.rb200
-rw-r--r--bootstraptest/test_marshal.rb5
-rw-r--r--bootstraptest/test_massign.rb176
-rw-r--r--bootstraptest/test_method.rb1028
-rw-r--r--bootstraptest/test_objectspace.rb33
-rw-r--r--bootstraptest/test_proc.rb255
-rw-r--r--bootstraptest/test_syntax.rb748
-rw-r--r--bootstraptest/test_thread.rb195
-rw-r--r--class.c471
-rw-r--r--common.mk516
-rw-r--r--compar.c48
-rw-r--r--compile.c4913
-rw-r--r--compile.h222
-rw-r--r--config.sub6
-rw-r--r--configure.in645
-rw-r--r--cont.c782
-rw-r--r--cygwin/GNUmakefile.in12
-rw-r--r--debug.c155
-rw-r--r--debug.h33
-rw-r--r--defines.h273
-rw-r--r--dir.c332
-rw-r--r--djgpp/config.hin8
-rw-r--r--dln.c242
-rw-r--r--dln.h8
-rw-r--r--dmyext.c2
-rw-r--r--doc/ChangeLog-YARV6917
-rw-r--r--doc/NEWS207
-rw-r--r--doc/NEWS-1.8.0837
-rw-r--r--enc/Makefile.in46
-rw-r--r--enc/ascii.c49
-rw-r--r--enc/depend63
-rw-r--r--enc/euc_jp.c362
-rw-r--r--enc/iso_8859_1.c274
-rw-r--r--enc/iso_8859_10.c244
-rw-r--r--enc/iso_8859_11.c96
-rw-r--r--enc/iso_8859_13.c233
-rw-r--r--enc/iso_8859_14.c245
-rw-r--r--enc/iso_8859_15.c239
-rw-r--r--enc/iso_8859_16.c242
-rw-r--r--enc/iso_8859_2.c239
-rw-r--r--enc/iso_8859_3.c239
-rw-r--r--enc/iso_8859_4.c241
-rw-r--r--enc/iso_8859_5.c229
-rw-r--r--enc/iso_8859_6.c96
-rw-r--r--enc/iso_8859_7.c226
-rw-r--r--enc/iso_8859_8.c96
-rw-r--r--enc/iso_8859_9.c233
-rw-r--r--enc/make_encmake.rb29
-rw-r--r--enc/sjis.c372
-rw-r--r--enc/trans/japanese.c23868
-rw-r--r--enc/trans/single_byte.c3020
-rw-r--r--enc/unicode.c11345
-rw-r--r--enc/us_ascii.c28
-rw-r--r--enc/utf8.c506
-rw-r--r--encoding.c1001
-rw-r--r--enum.c1090
-rw-r--r--enumerator.c242
-rw-r--r--env.h60
-rw-r--r--error.c536
-rw-r--r--eval.c12989
-rw-r--r--eval_error.c291
-rw-r--r--eval_intern.h246
-rw-r--r--eval_jump.c305
-rw-r--r--eval_method.c649
-rw-r--r--eval_safe.c111
-rw-r--r--ext/.document6
-rw-r--r--ext/Setup6
-rw-r--r--ext/Setup.atheos5
-rw-r--r--ext/Setup.dj5
-rw-r--r--ext/Setup.emx5
-rw-r--r--ext/Setup.nt5
-rw-r--r--ext/Setup.x685
-rw-r--r--ext/Win32API/.cvsignore3
-rw-r--r--ext/Win32API/Win32API.c215
-rw-r--r--ext/Win32API/depend1
-rw-r--r--ext/Win32API/extconf.rb6
-rw-r--r--ext/Win32API/getch.rb5
-rw-r--r--ext/Win32API/lib/win32/registry.rb831
-rw-r--r--ext/Win32API/lib/win32/resolv.rb366
-rw-r--r--ext/Win32API/point.rb18
-rw-r--r--ext/bigdecimal/.cvsignore1
-rw-r--r--ext/bigdecimal/bigdecimal.c72
-rw-r--r--ext/bigdecimal/extconf.rb8
-rw-r--r--ext/continuation/continuation.c8
-rw-r--r--ext/continuation/extconf.rb3
-rw-r--r--ext/curses/.cvsignore1
-rw-r--r--ext/curses/curses.c226
-rw-r--r--ext/curses/extconf.rb1
-rw-r--r--ext/dbm/.cvsignore1
-rw-r--r--ext/dbm/dbm.c256
-rw-r--r--ext/dbm/extconf.rb2
-rw-r--r--ext/digest/.cvsignore1
-rw-r--r--ext/digest/bubblebabble/.cvsignore1
-rw-r--r--ext/digest/digest.c2
-rw-r--r--ext/digest/extconf.rb2
-rw-r--r--ext/digest/lib/digest/hmac.rb274
-rw-r--r--ext/digest/lib/md5.rb23
-rw-r--r--ext/digest/lib/sha1.rb23
-rw-r--r--ext/digest/md5/.cvsignore1
-rw-r--r--ext/digest/rmd160/.cvsignore1
-rw-r--r--ext/digest/sha1/.cvsignore1
-rw-r--r--ext/digest/sha2/.cvsignore1
-rw-r--r--ext/dl/.cvsignore2
-rw-r--r--ext/dl/cfunc.c515
-rw-r--r--ext/dl/cptr.c478
-rw-r--r--ext/dl/depend49
-rw-r--r--ext/dl/dl.c790
-rw-r--r--ext/dl/dl.def59
-rw-r--r--ext/dl/dl.h361
-rw-r--r--ext/dl/doc/dl.txt266
-rw-r--r--ext/dl/extconf.rb198
-rw-r--r--ext/dl/h2rb500
-rw-r--r--ext/dl/handle.c178
-rw-r--r--ext/dl/install.rb49
-rw-r--r--ext/dl/lib/dl/callback.rb69
-rw-r--r--ext/dl/lib/dl/cparser.rb109
-rw-r--r--ext/dl/lib/dl/func.rb141
-rw-r--r--ext/dl/lib/dl/import.rb414
-rw-r--r--ext/dl/lib/dl/pack.rb173
-rw-r--r--ext/dl/lib/dl/stack.rb140
-rw-r--r--ext/dl/lib/dl/struct.rb346
-rw-r--r--ext/dl/lib/dl/types.rb273
-rw-r--r--ext/dl/lib/dl/value.rb108
-rw-r--r--ext/dl/lib/dl/win32.rb25
-rw-r--r--ext/dl/mkcall.rb62
-rw-r--r--ext/dl/mkcallback.rb227
-rw-r--r--ext/dl/mkcbtable.rb18
-rw-r--r--ext/dl/ptr.c1058
-rw-r--r--ext/dl/sample/c++sample.C35
-rw-r--r--ext/dl/sample/c++sample.rb60
-rw-r--r--ext/dl/sample/drives.rb70
-rw-r--r--ext/dl/sample/getch.rb5
-rw-r--r--ext/dl/sample/libc.rb69
-rw-r--r--ext/dl/sample/msgbox.rb19
-rw-r--r--ext/dl/sample/msgbox2.rb18
-rw-r--r--ext/dl/sample/stream.rb87
-rw-r--r--ext/dl/sym.c993
-rw-r--r--ext/dl/test/libtest.def28
-rw-r--r--ext/dl/test/test.c247
-rw-r--r--ext/dl/test/test.rb306
-rw-r--r--ext/dl/test/test_all.rb11
-rw-r--r--ext/dl/test/test_base.rb52
-rw-r--r--ext/dl/test/test_dl2.rb111
-rw-r--r--ext/dl/test/test_func.rb62
-rw-r--r--ext/dl/test/test_import.rb154
-rw-r--r--ext/dl/test/test_win32.rb53
-rw-r--r--ext/dl/type.rb115
-rw-r--r--ext/dl/win32/extconf.rb3
-rw-r--r--ext/dl/win32/lib/Win32API.rb28
-rw-r--r--ext/dl/win32/lib/win32/registry.rb831
-rw-r--r--ext/dl/win32/lib/win32/resolv.rb366
-rw-r--r--ext/dl/win32/lib/win32/sspi.rb330
-rw-r--r--ext/etc/etc.c92
-rw-r--r--ext/etc/extconf.rb15
-rw-r--r--ext/extmk.rb72
-rw-r--r--ext/fcntl/.cvsignore1
-rw-r--r--ext/fiber/extconf.rb3
-rw-r--r--ext/fiber/fiber.c8
-rw-r--r--ext/gdbm/.cvsignore1
-rw-r--r--ext/gdbm/gdbm.c410
-rw-r--r--ext/iconv/.cvsignore1
-rw-r--r--ext/iconv/charset_alias.rb4
-rw-r--r--ext/iconv/depend2
-rw-r--r--ext/iconv/extconf.rb2
-rw-r--r--ext/iconv/iconv.c694
-rw-r--r--ext/iconv/mkwrapper.rb53
-rw-r--r--ext/io/wait/.cvsignore1
-rw-r--r--ext/io/wait/wait.c97
-rw-r--r--ext/json/ext/generator/extconf.rb10
-rw-r--r--ext/json/ext/generator/generator.c876
-rw-r--r--ext/json/ext/generator/unicode.c184
-rw-r--r--ext/json/ext/generator/unicode.h53
-rw-r--r--ext/json/ext/parser/extconf.rb10
-rw-r--r--ext/json/ext/parser/parser.c1752
-rw-r--r--ext/json/ext/parser/parser.rl639
-rw-r--r--ext/json/ext/parser/unicode.c156
-rw-r--r--ext/json/ext/parser/unicode.h58
-rw-r--r--ext/json/extconf.rb3
-rw-r--r--ext/json/lib/json.rb235
-rw-r--r--ext/json/lib/json/Array.xpm21
-rw-r--r--ext/json/lib/json/FalseClass.xpm21
-rw-r--r--ext/json/lib/json/Hash.xpm21
-rw-r--r--ext/json/lib/json/Key.xpm73
-rw-r--r--ext/json/lib/json/NilClass.xpm21
-rw-r--r--ext/json/lib/json/Numeric.xpm28
-rw-r--r--ext/json/lib/json/String.xpm96
-rw-r--r--ext/json/lib/json/TrueClass.xpm21
-rw-r--r--ext/json/lib/json/add/core.rb120
-rw-r--r--ext/json/lib/json/add/rails.rb58
-rw-r--r--ext/json/lib/json/common.rb354
-rw-r--r--ext/json/lib/json/editor.rb1363
-rw-r--r--ext/json/lib/json/ext.rb13
-rw-r--r--ext/json/lib/json/json.xpm1499
-rw-r--r--ext/json/lib/json/pure.rb75
-rw-r--r--ext/json/lib/json/pure/generator.rb394
-rw-r--r--ext/json/lib/json/pure/parser.rb259
-rw-r--r--ext/json/lib/json/version.rb9
-rw-r--r--ext/nkf/.cvsignore1
-rw-r--r--ext/nkf/lib/kconv.rb148
-rw-r--r--ext/nkf/nkf-utf8/config.h7
-rw-r--r--ext/nkf/nkf-utf8/nkf.c2259
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.c247
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.h3
-rw-r--r--ext/nkf/nkf.c374
-rw-r--r--ext/openssl/extconf.rb2
-rw-r--r--ext/openssl/lib/net/ftptls.rb53
-rw-r--r--ext/openssl/lib/net/telnets.rb251
-rw-r--r--ext/openssl/lib/openssl.rb1
-rw-r--r--ext/openssl/lib/openssl/buffering.rb13
-rw-r--r--ext/openssl/lib/openssl/digest.rb9
-rw-r--r--ext/openssl/lib/openssl/pkcs7.rb25
-rw-r--r--ext/openssl/lib/openssl/ssl.rb1
-rw-r--r--ext/openssl/openssl_missing.c12
-rw-r--r--ext/openssl/openssl_missing.h60
-rw-r--r--ext/openssl/ossl.h6
-rw-r--r--ext/openssl/ossl_bn.c6
-rw-r--r--ext/openssl/ossl_digest.c158
-rw-r--r--ext/openssl/ossl_hmac.c8
-rw-r--r--ext/openssl/ossl_pkcs5.c2
-rw-r--r--ext/openssl/ossl_pkey_dh.c8
-rw-r--r--ext/openssl/ossl_pkey_dsa.c6
-rw-r--r--ext/openssl/ossl_pkey_ec.c3
-rw-r--r--ext/openssl/ossl_pkey_rsa.c2
-rw-r--r--ext/openssl/ossl_rand.c16
-rw-r--r--ext/openssl/ossl_ssl.c39
-rw-r--r--ext/openssl/ossl_ssl_session.c8
-rw-r--r--ext/openssl/ossl_x509store.c2
-rw-r--r--ext/pty/.cvsignore1
-rw-r--r--ext/pty/extconf.rb2
-rw-r--r--ext/pty/lib/expect.rb2
-rw-r--r--ext/pty/pty.c94
-rw-r--r--ext/purelib.rb9
-rw-r--r--ext/racc/cparse/.cvsignore1
-rw-r--r--ext/racc/cparse/README10
-rw-r--r--ext/racc/cparse/cparse.c70
-rw-r--r--ext/racc/cparse/extconf.rb1
-rw-r--r--ext/readline/.cvsignore1
-rw-r--r--ext/readline/readline.c253
-rw-r--r--ext/ripper/.cvsignore8
-rw-r--r--ext/ripper/README30
-rw-r--r--ext/ripper/depend34
-rw-r--r--ext/ripper/eventids2.c277
-rw-r--r--ext/ripper/extconf.rb22
-rw-r--r--ext/ripper/lib/ripper.rb4
-rw-r--r--ext/ripper/lib/ripper/core.rb70
-rw-r--r--ext/ripper/lib/ripper/filter.rb70
-rw-r--r--ext/ripper/lib/ripper/lexer.rb179
-rw-r--r--ext/ripper/lib/ripper/sexp.rb99
-rwxr-xr-xext/ripper/tools/generate-param-macros.rb14
-rwxr-xr-xext/ripper/tools/generate.rb152
-rwxr-xr-xext/ripper/tools/preproc.rb91
-rwxr-xr-xext/ripper/tools/strip.rb12
-rw-r--r--ext/sdbm/.cvsignore1
-rw-r--r--ext/sdbm/_sdbm.c99
-rw-r--r--ext/sdbm/init.c287
-rw-r--r--ext/socket/.cvsignore2
-rw-r--r--ext/socket/addrinfo.h5
-rw-r--r--ext/socket/depend12
-rw-r--r--ext/socket/extconf.rb27
-rw-r--r--ext/socket/getaddrinfo.c45
-rw-r--r--ext/socket/getnameinfo.c17
-rw-r--r--ext/socket/mkconstants.rb262
-rw-r--r--ext/socket/socket.c1762
-rw-r--r--ext/stringio/.cvsignore1
-rw-r--r--ext/stringio/depend5
-rw-r--r--ext/stringio/stringio.c548
-rw-r--r--ext/strscan/.cvsignore1
-rw-r--r--ext/strscan/depend3
-rw-r--r--ext/strscan/strscan.c105
-rw-r--r--ext/syck/.cvsignore1
-rw-r--r--ext/syck/bytecode.c2
-rw-r--r--ext/syck/emitter.c20
-rw-r--r--ext/syck/handler.c4
-rw-r--r--ext/syck/implicit.c4
-rw-r--r--ext/syck/node.c12
-rw-r--r--ext/syck/rubyext.c291
-rw-r--r--ext/syck/syck.c6
-rw-r--r--ext/syck/syck.h26
-rw-r--r--ext/syck/token.c2
-rw-r--r--ext/syck/yaml2byte.c4
-rw-r--r--ext/syslog/.cvsignore1
-rw-r--r--ext/syslog/syslog.c11
-rw-r--r--ext/syslog/syslog.txt5
-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/.cvsignore2
-rw-r--r--ext/tk/ChangeLog.tkextlib6
-rw-r--r--ext/tk/MANUAL_tcltklib.eng7
-rw-r--r--ext/tk/MANUAL_tcltklib.eucj6
-rw-r--r--ext/tk/README.tcltklib20
-rw-r--r--ext/tk/extconf.rb172
-rw-r--r--ext/tk/lib/multi-tk.rb165
-rw-r--r--ext/tk/lib/tk.rb1186
-rw-r--r--ext/tk/lib/tk/autoload.rb398
-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.rb51
-rw-r--r--ext/tk/lib/tk/canvastag.rb117
-rw-r--r--ext/tk/lib/tk/checkbutton.rb8
-rw-r--r--ext/tk/lib/tk/composite.rb65
-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.rb732
-rw-r--r--ext/tk/lib/tk/frame.rb3
-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.rb164
-rw-r--r--ext/tk/lib/tk/itemfont.rb33
-rw-r--r--ext/tk/lib/tk/label.rb3
-rw-r--r--ext/tk/lib/tk/labelframe.rb9
-rw-r--r--ext/tk/lib/tk/listbox.rb3
-rw-r--r--ext/tk/lib/tk/macpkg.rb3
-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/palette.rb2
-rw-r--r--ext/tk/lib/tk/panedwindow.rb29
-rw-r--r--ext/tk/lib/tk/radiobutton.rb8
-rw-r--r--ext/tk/lib/tk/root.rb33
-rw-r--r--ext/tk/lib/tk/scale.rb31
-rw-r--r--ext/tk/lib/tk/scrollbar.rb61
-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.rb172
-rw-r--r--ext/tk/lib/tk/textimage.rb12
-rw-r--r--ext/tk/lib/tk/textmark.rb97
-rw-r--r--ext/tk/lib/tk/texttag.rb110
-rw-r--r--ext/tk/lib/tk/textwindow.rb11
-rw-r--r--ext/tk/lib/tk/timer.rb55
-rw-r--r--ext/tk/lib/tk/toplevel.rb5
-rw-r--r--ext/tk/lib/tk/ttk_selector.rb117
-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.rb6
-rw-r--r--ext/tk/lib/tk/wm.rb476
-rw-r--r--ext/tk/lib/tkextlib/SUPPORT_STATUS2
-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/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.rb17
-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.rb2
-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.rb2
-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.rb37
-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.rb21
-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.rb27
-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_core.rb16
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tkpiechart.rb14
-rw-r--r--ext/tk/lib/tkextlib/tile.rb186
-rw-r--r--ext/tk/lib/tkextlib/tile/dialog.rb14
-rw-r--r--ext/tk/lib/tkextlib/tile/sizegrip.rb4
-rw-r--r--ext/tk/lib/tkextlib/tile/style.rb210
-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.rb3
-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.rb31
-rw-r--r--ext/tk/lib/tkextlib/tile/tpaned.rb47
-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.rb193
-rw-r--r--ext/tk/lib/tkextlib/tile/tscale.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tscrollbar.rb9
-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.rb2
-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.rb27
-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.rb48
-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.rb10
-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.rb10
-rw-r--r--ext/tk/sample/demos-jp/aniwave.rb9
-rw-r--r--ext/tk/sample/demos-jp/arrow.rb26
-rw-r--r--ext/tk/sample/demos-jp/bind.rb27
-rw-r--r--ext/tk/sample/demos-jp/bitmap.rb10
-rw-r--r--ext/tk/sample/demos-jp/button.rb3
-rw-r--r--ext/tk/sample/demos-jp/check.rb14
-rw-r--r--ext/tk/sample/demos-jp/check2.rb14
-rw-r--r--ext/tk/sample/demos-jp/clrpick.rb20
-rw-r--r--ext/tk/sample/demos-jp/colors.rb18
-rw-r--r--ext/tk/sample/demos-jp/combo.rb98
-rw-r--r--ext/tk/sample/demos-jp/cscroll.rb14
-rw-r--r--ext/tk/sample/demos-jp/ctext.rb53
-rw-r--r--ext/tk/sample/demos-jp/entry1.rb12
-rw-r--r--ext/tk/sample/demos-jp/entry2.rb8
-rw-r--r--ext/tk/sample/demos-jp/entry3.rb48
-rw-r--r--ext/tk/sample/demos-jp/filebox.rb17
-rw-r--r--ext/tk/sample/demos-jp/floor.rb14
-rw-r--r--ext/tk/sample/demos-jp/floor2.rb14
-rw-r--r--ext/tk/sample/demos-jp/form.rb8
-rw-r--r--ext/tk/sample/demos-jp/goldberg.rb23
-rw-r--r--ext/tk/sample/demos-jp/hscale.rb28
-rw-r--r--ext/tk/sample/demos-jp/icon.rb20
-rw-r--r--ext/tk/sample/demos-jp/image1.rb13
-rw-r--r--ext/tk/sample/demos-jp/image2.rb23
-rw-r--r--ext/tk/sample/demos-jp/image3.rb17
-rw-r--r--ext/tk/sample/demos-jp/items.rb17
-rw-r--r--ext/tk/sample/demos-jp/knightstour.rb273
-rw-r--r--ext/tk/sample/demos-jp/label.rb13
-rw-r--r--ext/tk/sample/demos-jp/labelframe.rb8
-rw-r--r--ext/tk/sample/demos-jp/mclist.rb121
-rw-r--r--ext/tk/sample/demos-jp/menu.rb14
-rw-r--r--ext/tk/sample/demos-jp/menu84.rb8
-rw-r--r--ext/tk/sample/demos-jp/menu8x.rb12
-rw-r--r--ext/tk/sample/demos-jp/menubu.rb10
-rw-r--r--ext/tk/sample/demos-jp/msgbox.rb14
-rw-r--r--ext/tk/sample/demos-jp/msgbox2.rb90
-rw-r--r--ext/tk/sample/demos-jp/paned1.rb14
-rw-r--r--ext/tk/sample/demos-jp/paned2.rb8
-rw-r--r--ext/tk/sample/demos-jp/pendulum.rb10
-rw-r--r--ext/tk/sample/demos-jp/plot.rb14
-rw-r--r--ext/tk/sample/demos-jp/puzzle.rb32
-rw-r--r--ext/tk/sample/demos-jp/radio.rb12
-rw-r--r--ext/tk/sample/demos-jp/radio2.rb17
-rw-r--r--ext/tk/sample/demos-jp/radio3.rb19
-rw-r--r--ext/tk/sample/demos-jp/ruler.rb8
-rw-r--r--ext/tk/sample/demos-jp/sayings.rb8
-rw-r--r--ext/tk/sample/demos-jp/search.rb19
-rw-r--r--ext/tk/sample/demos-jp/spin.rb14
-rw-r--r--ext/tk/sample/demos-jp/states.rb8
-rw-r--r--ext/tk/sample/demos-jp/style.rb41
-rw-r--r--ext/tk/sample/demos-jp/text.rb8
-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.rb12
-rw-r--r--ext/tk/sample/demos-jp/twind2.rb6
-rw-r--r--ext/tk/sample/demos-jp/unicodeout.rb14
-rw-r--r--ext/tk/sample/demos-jp/vscale.rb29
-rw-r--r--ext/tk/sample/demos-jp/widget273
-rw-r--r--ext/tk/sample/encstr_usage.rb5
-rw-r--r--ext/tk/sample/figmemo_sample.rb456
-rw-r--r--ext/tk/sample/irbtkw.rbw24
-rw-r--r--ext/tk/sample/tkextlib/tile/demo.rb39
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl2
-rw-r--r--ext/tk/sample/tkextlib/tile/themes/kroc.rb30
-rw-r--r--ext/tk/sample/tkextlib/treectrl/demo.rb7
-rw-r--r--ext/tk/sample/tkrttimer.rb13
-rw-r--r--ext/tk/sample/tksleep_sample.rb29
-rw-r--r--ext/tk/sample/tktextio.rb12
-rw-r--r--ext/tk/sample/ttk_wrapper.rb154
-rw-r--r--ext/tk/stubs.c64
-rw-r--r--ext/tk/tcltklib.c2412
-rw-r--r--ext/tk/tkutil/extconf.rb1
-rw-r--r--ext/tk/tkutil/tkutil.c508
-rw-r--r--ext/win32ole/doc/win32ole.rd294
-rw-r--r--ext/win32ole/extconf.rb1
-rw-r--r--ext/win32ole/sample/excel1.rb15
-rw-r--r--ext/win32ole/sample/excel2.rb10
-rw-r--r--ext/win32ole/tests/oleserver.rb10
-rw-r--r--ext/win32ole/tests/testNIL2VTEMPTY.rb28
-rw-r--r--ext/win32ole/tests/testOLEMETHOD.rb92
-rw-r--r--ext/win32ole/tests/testOLEPARAM.rb65
-rw-r--r--ext/win32ole/tests/testOLETYPE.rb96
-rw-r--r--ext/win32ole/tests/testOLEVARIABLE.rb49
-rw-r--r--ext/win32ole/tests/testVARIANT.rb32
-rw-r--r--ext/win32ole/tests/testWIN32OLE.rb373
-rw-r--r--ext/win32ole/tests/test_ole_methods.rb (renamed from test/win32ole/test_ole_methods.rb)0
-rw-r--r--ext/win32ole/tests/test_propertyputref.rb19
-rw-r--r--ext/win32ole/tests/test_win32ole_event.rb133
-rw-r--r--ext/win32ole/tests/test_word.rb37
-rw-r--r--ext/win32ole/tests/testall.rb16
-rw-r--r--ext/win32ole/win32ole.c4222
-rw-r--r--ext/zlib/.cvsignore1
-rw-r--r--ext/zlib/extconf.rb4
-rw-r--r--ext/zlib/zlib.c815
-rw-r--r--file.c1672
-rw-r--r--gc.c1230
-rw-r--r--gc.h61
-rw-r--r--gem_prelude.rb201
-rw-r--r--golf_prelude.rb11
-rw-r--r--goruby.c3
-rw-r--r--hash.c1223
-rw-r--r--ia64.s9
-rw-r--r--id.c67
-rw-r--r--id.h52
-rw-r--r--include/ruby.h1
-rw-r--r--include/ruby/defines.h278
-rw-r--r--include/ruby/encoding.h131
-rw-r--r--include/ruby/intern.h638
-rw-r--r--include/ruby/io.h133
-rw-r--r--include/ruby/missing.h169
-rw-r--r--include/ruby/node.h509
-rw-r--r--include/ruby/oniguruma.h846
-rw-r--r--include/ruby/re.h53
-rw-r--r--include/ruby/regex.h43
-rw-r--r--include/ruby/ruby.h985
-rw-r--r--include/ruby/signal.h93
-rw-r--r--include/ruby/st.h98
-rw-r--r--include/ruby/util.h81
-rw-r--r--include/ruby/win32.h565
-rw-r--r--include/rubyio.h1
-rw-r--r--include/rubysig.h1
-rw-r--r--inits.c93
-rw-r--r--insnhelper.h149
-rw-r--r--insns.def2086
-rwxr-xr-xinstruby.rb172
-rw-r--r--intern.h530
-rw-r--r--io.c4729
-rw-r--r--iseq.c1298
-rw-r--r--keywords91
-rw-r--r--lex.c136
-rw-r--r--lex.c.blt214
-rw-r--r--lex.c.src51
-rw-r--r--lib/.document5
-rw-r--r--lib/Env.rb18
-rw-r--r--lib/README19
-rw-r--r--lib/base64.rb133
-rw-r--r--lib/benchmark.rb7
-rw-r--r--lib/cgi-lib.rb272
-rw-r--r--lib/cgi.rb173
-rw-r--r--lib/cgi/.document3
-rw-r--r--lib/cgi/session.rb45
-rw-r--r--lib/cgi/session/pstore.rb4
-rw-r--r--lib/complex.rb52
-rw-r--r--lib/csv.rb2654
-rw-r--r--lib/date.rb1077
-rw-r--r--lib/date/format.rb447
-rw-r--r--lib/date2.rb5
-rw-r--r--lib/debug.rb106
-rw-r--r--lib/delegate.rb222
-rw-r--r--lib/drb/extserv.rb19
-rw-r--r--lib/drb/invokemethod.rb2
-rw-r--r--lib/e2mmap.rb31
-rw-r--r--lib/erb.rb306
-rw-r--r--lib/eregex.rb37
-rw-r--r--lib/fileutils.rb45
-rw-r--r--lib/finalize.rb193
-rw-r--r--lib/find.rb4
-rw-r--r--lib/forwardable.rb140
-rw-r--r--lib/ftools.rb261
-rw-r--r--lib/generator.rb131
-rw-r--r--lib/getoptlong.rb29
-rw-r--r--lib/getopts.rb127
-rw-r--r--lib/importenv.rb33
-rw-r--r--lib/ipaddr.rb8
-rw-r--r--lib/irb.rb20
-rw-r--r--lib/irb/completion.rb39
-rw-r--r--lib/irb/extend-command.rb2
-rw-r--r--lib/irb/help.rb2
-rw-r--r--lib/irb/init.rb8
-rw-r--r--lib/irb/input-method.rb4
-rw-r--r--lib/irb/notifier.rb2
-rw-r--r--lib/irb/output-method.rb25
-rw-r--r--lib/irb/ruby-lex.rb10
-rw-r--r--lib/irb/ruby-token.rb6
-rw-r--r--lib/irb/slex.rb4
-rw-r--r--lib/jcode.rb220
-rw-r--r--lib/logger.rb41
-rw-r--r--lib/mailread.rb62
-rw-r--r--lib/mathn.rb84
-rw-r--r--lib/matrix.rb164
-rw-r--r--lib/mkmf.rb461
-rw-r--r--lib/monitor.rb153
-rw-r--r--lib/mutex_m.rb78
-rw-r--r--lib/net/.document8
-rw-r--r--lib/net/ftp.rb214
-rw-r--r--lib/net/http.rb206
-rw-r--r--lib/net/https.rb61
-rw-r--r--lib/net/imap.rb404
-rw-r--r--lib/net/pop.rb4
-rw-r--r--lib/net/protocol.rb18
-rw-r--r--lib/net/smtp.rb4
-rw-r--r--lib/net/telnet.rb23
-rw-r--r--lib/observer.rb19
-rw-r--r--lib/open-uri.rb150
-rw-r--r--lib/optparse.rb49
-rw-r--r--lib/ostruct.rb7
-rw-r--r--lib/parsearg.rb87
-rw-r--r--lib/parsedate.rb53
-rw-r--r--lib/ping.rb64
-rw-r--r--lib/pp.rb82
-rw-r--r--lib/profile.rb4
-rw-r--r--lib/profiler.rb2
-rw-r--r--lib/pstore.rb4
-rwxr-xr-xlib/rake.rb2240
-rw-r--r--lib/rake/classic_namespace.rb8
-rw-r--r--lib/rake/clean.rb33
-rw-r--r--lib/rake/gempackagetask.rb103
-rw-r--r--lib/rake/loaders/makefile.rb40
-rw-r--r--lib/rake/packagetask.rb184
-rw-r--r--lib/rake/rake_test_loader.rb5
-rw-r--r--lib/rake/rdoctask.rb147
-rwxr-xr-xlib/rake/ruby182_test_unit_fix.rb23
-rw-r--r--lib/rake/runtest.rb23
-rw-r--r--lib/rake/tasklib.rb18
-rw-r--r--lib/rake/testtask.rb161
-rw-r--r--lib/rational.rb89
-rw-r--r--lib/rbconfig/datadir.rb24
-rw-r--r--lib/rdoc/code_objects.rb15
-rw-r--r--lib/rdoc/diagram.rb6
-rw-r--r--lib/rdoc/generators/html_generator.rb9
-rw-r--r--lib/rdoc/generators/ri_generator.rb2
-rw-r--r--lib/rdoc/generators/xml_generator.rb2
-rw-r--r--lib/rdoc/markup/simple_markup/inline.rb12
-rw-r--r--lib/rdoc/options.rb13
-rw-r--r--lib/rdoc/parsers/parse_c.rb18
-rw-r--r--lib/rdoc/parsers/parse_f95.rb8
-rw-r--r--lib/rdoc/parsers/parse_rb.rb74
-rw-r--r--lib/rdoc/rdoc.rb9
-rw-r--r--lib/rdoc/ri/ri_display.rb1
-rw-r--r--lib/rdoc/ri/ri_paths.rb42
-rw-r--r--lib/rdoc/ri/ri_writer.rb2
-rw-r--r--lib/readbytes.rb41
-rw-r--r--lib/resolv-replace.rb3
-rw-r--r--lib/resolv.rb319
-rw-r--r--lib/rexml/attlistdecl.rb2
-rw-r--r--lib/rexml/document.rb4
-rw-r--r--lib/rexml/element.rb8
-rw-r--r--lib/rexml/formatters/pretty.rb2
-rw-r--r--lib/rexml/functions.rb2
-rw-r--r--lib/rexml/rexml.rb5
-rw-r--r--lib/rexml/source.rb13
-rw-r--r--lib/rexml/text.rb2
-rw-r--r--lib/rexml/xpath.rb2
-rw-r--r--lib/rinda/.document3
-rw-r--r--lib/rinda/ring.rb6
-rw-r--r--lib/rinda/tuplespace.rb111
-rw-r--r--lib/rss/atom.rb1
-rw-r--r--lib/rss/maker.rb8
-rw-r--r--lib/rss/maker/0.9.rb22
-rw-r--r--lib/rss/maker/1.0.rb8
-rw-r--r--lib/rss/maker/2.0.rb15
-rw-r--r--lib/rss/maker/base.rb4
-rw-r--r--lib/rss/maker/entry.rb8
-rw-r--r--lib/rss/maker/feed.rb12
-rw-r--r--lib/rss/parser.rb68
-rw-r--r--lib/rss/rss.rb5
-rw-r--r--lib/rss/utils.rb5
-rw-r--r--lib/rubygems.rb567
-rw-r--r--lib/rubygems/builder.rb81
-rw-r--r--lib/rubygems/command.rb406
-rw-r--r--lib/rubygems/command_manager.rb144
-rw-r--r--lib/rubygems/commands/build_command.rb53
-rw-r--r--lib/rubygems/commands/cert_command.rb86
-rw-r--r--lib/rubygems/commands/check_command.rb74
-rw-r--r--lib/rubygems/commands/cleanup_command.rb93
-rw-r--r--lib/rubygems/commands/contents_command.rb74
-rw-r--r--lib/rubygems/commands/dependency_command.rb150
-rw-r--r--lib/rubygems/commands/environment_command.rb80
-rw-r--r--lib/rubygems/commands/fetch_command.rb62
-rw-r--r--lib/rubygems/commands/generate_index_command.rb57
-rw-r--r--lib/rubygems/commands/help_command.rb172
-rw-r--r--lib/rubygems/commands/install_command.rb127
-rw-r--r--lib/rubygems/commands/list_command.rb35
-rw-r--r--lib/rubygems/commands/lock_command.rb101
-rw-r--r--lib/rubygems/commands/mirror_command.rb111
-rw-r--r--lib/rubygems/commands/outdated_command.rb30
-rw-r--r--lib/rubygems/commands/pristine_command.rb133
-rw-r--r--lib/rubygems/commands/query_command.rb120
-rw-r--r--lib/rubygems/commands/rdoc_command.rb78
-rw-r--r--lib/rubygems/commands/search_command.rb37
-rw-r--r--lib/rubygems/commands/server_command.rb48
-rw-r--r--lib/rubygems/commands/sources_command.rb115
-rw-r--r--lib/rubygems/commands/specification_command.rb72
-rw-r--r--lib/rubygems/commands/uninstall_command.rb56
-rw-r--r--lib/rubygems/commands/unpack_command.rb83
-rw-r--r--lib/rubygems/commands/update_command.rb155
-rw-r--r--lib/rubygems/commands/which_command.rb86
-rw-r--r--lib/rubygems/config_file.rb224
-rwxr-xr-xlib/rubygems/custom_require.rb38
-rw-r--r--lib/rubygems/defaults.rb46
-rw-r--r--lib/rubygems/dependency.rb65
-rw-r--r--lib/rubygems/dependency_installer.rb243
-rw-r--r--lib/rubygems/dependency_list.rb165
-rwxr-xr-xlib/rubygems/digest/digest_adapter.rb40
-rwxr-xr-xlib/rubygems/digest/md5.rb23
-rwxr-xr-xlib/rubygems/digest/sha1.rb17
-rwxr-xr-xlib/rubygems/digest/sha2.rb17
-rw-r--r--lib/rubygems/doc_manager.rb161
-rw-r--r--lib/rubygems/exceptions.rb63
-rw-r--r--lib/rubygems/ext.rb18
-rw-r--r--lib/rubygems/ext/builder.rb56
-rw-r--r--lib/rubygems/ext/configure_builder.rb24
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb23
-rw-r--r--lib/rubygems/ext/rake_builder.rb27
-rw-r--r--lib/rubygems/format.rb81
-rw-r--r--lib/rubygems/gem_open_uri.rb7
-rw-r--r--lib/rubygems/gem_openssl.rb83
-rw-r--r--lib/rubygems/gem_path_searcher.rb84
-rw-r--r--lib/rubygems/gem_runner.rb58
-rw-r--r--lib/rubygems/indexer.rb163
-rw-r--r--lib/rubygems/indexer/abstract_index_builder.rb80
-rw-r--r--lib/rubygems/indexer/marshal_index_builder.rb17
-rw-r--r--lib/rubygems/indexer/master_index_builder.rb53
-rw-r--r--lib/rubygems/indexer/quick_index_builder.rb48
-rw-r--r--lib/rubygems/install_update_options.rb94
-rw-r--r--lib/rubygems/installer.rb476
-rw-r--r--lib/rubygems/local_remote_options.rb106
-rw-r--r--lib/rubygems/old_format.rb148
-rw-r--r--lib/rubygems/open-uri.rb773
-rw-r--r--lib/rubygems/package.rb852
-rw-r--r--lib/rubygems/platform.rb181
-rw-r--r--lib/rubygems/remote_fetcher.rb168
-rw-r--r--lib/rubygems/require_paths_builder.rb15
-rw-r--r--lib/rubygems/requirement.rb157
-rw-r--r--lib/rubygems/rubygems_version.rb6
-rw-r--r--lib/rubygems/security.rb785
-rw-r--r--lib/rubygems/server.rb519
-rw-r--r--lib/rubygems/source_index.rb443
-rw-r--r--lib/rubygems/source_info_cache.rb232
-rw-r--r--lib/rubygems/source_info_cache_entry.rb46
-rw-r--r--lib/rubygems/specification.rb973
-rwxr-xr-xlib/rubygems/timer.rb25
-rw-r--r--lib/rubygems/uninstaller.rb183
-rw-r--r--lib/rubygems/user_interaction.rb291
-rwxr-xr-xlib/rubygems/validator.rb186
-rw-r--r--lib/rubygems/version.rb165
-rw-r--r--lib/rubygems/version_option.rb49
-rw-r--r--lib/rubyunit.rb6
-rw-r--r--lib/runit/assert.rb73
-rw-r--r--lib/runit/cui/testrunner.rb51
-rw-r--r--lib/runit/error.rb9
-rw-r--r--lib/runit/testcase.rb45
-rw-r--r--lib/runit/testresult.rb44
-rw-r--r--lib/runit/testsuite.rb26
-rw-r--r--lib/runit/topublic.rb8
-rw-r--r--lib/scanf.rb8
-rw-r--r--lib/securerandom.rb4
-rw-r--r--lib/set.rb93
-rw-r--r--lib/shell.rb126
-rw-r--r--lib/shell/builtin-command.rb31
-rw-r--r--lib/shell/command-processor.rb108
-rw-r--r--lib/shell/error.rb4
-rw-r--r--lib/shell/filter.rb4
-rw-r--r--lib/shell/process-controller.rb158
-rw-r--r--lib/shell/system-command.rb60
-rw-r--r--lib/shell/version.rb8
-rw-r--r--lib/shellwords.rb37
-rw-r--r--lib/singleton.rb166
-rw-r--r--lib/soap/attachment.rb107
-rw-r--r--lib/soap/baseData.rb942
-rw-r--r--lib/soap/element.rb258
-rw-r--r--lib/soap/encodingstyle/aspDotNetHandler.rb213
-rw-r--r--lib/soap/encodingstyle/handler.rb100
-rw-r--r--lib/soap/encodingstyle/literalHandler.rb226
-rw-r--r--lib/soap/encodingstyle/soapHandler.rb582
-rw-r--r--lib/soap/generator.rb268
-rw-r--r--lib/soap/header/handler.rb57
-rw-r--r--lib/soap/header/handlerset.rb70
-rw-r--r--lib/soap/header/simplehandler.rb44
-rw-r--r--lib/soap/httpconfigloader.rb119
-rw-r--r--lib/soap/mapping.rb10
-rw-r--r--lib/soap/mapping/factory.rb355
-rw-r--r--lib/soap/mapping/mapping.rb381
-rw-r--r--lib/soap/mapping/registry.rb541
-rw-r--r--lib/soap/mapping/rubytypeFactory.rb475
-rw-r--r--lib/soap/mapping/typeMap.rb50
-rw-r--r--lib/soap/mapping/wsdlencodedregistry.rb280
-rw-r--r--lib/soap/mapping/wsdlliteralregistry.rb418
-rw-r--r--lib/soap/marshal.rb59
-rw-r--r--lib/soap/mimemessage.rb240
-rw-r--r--lib/soap/netHttpClient.rb190
-rw-r--r--lib/soap/parser.rb251
-rw-r--r--lib/soap/processor.rb66
-rw-r--r--lib/soap/property.rb333
-rw-r--r--lib/soap/rpc/cgistub.rb206
-rw-r--r--lib/soap/rpc/driver.rb254
-rw-r--r--lib/soap/rpc/element.rb325
-rw-r--r--lib/soap/rpc/httpserver.rb129
-rw-r--r--lib/soap/rpc/proxy.rb497
-rw-r--r--lib/soap/rpc/router.rb594
-rw-r--r--lib/soap/rpc/rpc.rb25
-rw-r--r--lib/soap/rpc/soaplet.rb162
-rw-r--r--lib/soap/rpc/standaloneServer.rb43
-rw-r--r--lib/soap/soap.rb140
-rw-r--r--lib/soap/streamHandler.rb229
-rw-r--r--lib/soap/wsdlDriver.rb575
-rw-r--r--lib/sync.rb187
-rw-r--r--lib/tempfile.rb42
-rw-r--r--lib/test/unit/assertions.rb8
-rw-r--r--lib/test/unit/autorunner.rb2
-rw-r--r--lib/test/unit/collector/dir.rb2
-rw-r--r--lib/test/unit/collector/objectspace.rb2
-rw-r--r--lib/test/unit/testcase.rb14
-rw-r--r--lib/test/unit/testresult.rb1
-rw-r--r--lib/test/unit/ui/console/testrunner.rb14
-rw-r--r--lib/test/unit/ui/fox/testrunner.rb50
-rw-r--r--lib/test/unit/ui/gtk/testrunner.rb84
-rw-r--r--lib/test/unit/ui/gtk2/testrunner.rb84
-rw-r--r--lib/test/unit/ui/testrunnermediator.rb2
-rw-r--r--lib/test/unit/ui/tk/testrunner.rb30
-rw-r--r--lib/test/unit/util/observable.rb4
-rw-r--r--lib/test/unit/util/procwrapper.rb6
-rw-r--r--lib/thread.rb267
-rw-r--r--lib/time.rb63
-rw-r--r--lib/timeout.rb85
-rw-r--r--lib/tmpdir.rb19
-rw-r--r--lib/tracer.rb10
-rw-r--r--lib/ubygems.rb10
-rw-r--r--lib/uri/.document7
-rw-r--r--lib/uri/common.rb35
-rw-r--r--lib/uri/ftp.rb2
-rw-r--r--lib/uri/generic.rb3
-rw-r--r--lib/uri/mailto.rb2
-rw-r--r--lib/weakref.rb70
-rw-r--r--lib/webrick/cgi.rb23
-rw-r--r--lib/webrick/config.rb7
-rw-r--r--lib/webrick/httpauth/authenticator.rb2
-rw-r--r--lib/webrick/httpauth/basicauth.rb2
-rw-r--r--lib/webrick/httpauth/digestauth.rb1
-rw-r--r--lib/webrick/httpauth/htpasswd.rb2
-rw-r--r--lib/webrick/httpproxy.rb12
-rw-r--r--lib/webrick/httprequest.rb31
-rw-r--r--lib/webrick/httpresponse.rb15
-rw-r--r--lib/webrick/httpserver.rb15
-rw-r--r--lib/webrick/httpservlet/abstract.rb2
-rw-r--r--lib/webrick/httpservlet/cgi_runner.rb4
-rw-r--r--lib/webrick/httpservlet/cgihandler.rb16
-rw-r--r--lib/webrick/httpservlet/erbhandler.rb2
-rw-r--r--lib/webrick/httpservlet/filehandler.rb73
-rw-r--r--lib/webrick/httpstatus.rb80
-rw-r--r--lib/webrick/httputils.rb27
-rw-r--r--lib/webrick/server.rb13
-rw-r--r--lib/webrick/utils.rb75
-rw-r--r--lib/wsdl/binding.rb65
-rw-r--r--lib/wsdl/data.rb64
-rw-r--r--lib/wsdl/definitions.rb250
-rw-r--r--lib/wsdl/documentation.rb32
-rw-r--r--lib/wsdl/import.rb80
-rw-r--r--lib/wsdl/importer.rb38
-rw-r--r--lib/wsdl/info.rb39
-rw-r--r--lib/wsdl/message.rb54
-rw-r--r--lib/wsdl/operation.rb130
-rw-r--r--lib/wsdl/operationBinding.rb108
-rw-r--r--lib/wsdl/param.rb85
-rw-r--r--lib/wsdl/parser.rb163
-rw-r--r--lib/wsdl/part.rb52
-rw-r--r--lib/wsdl/port.rb84
-rw-r--r--lib/wsdl/portType.rb73
-rw-r--r--lib/wsdl/service.rb61
-rw-r--r--lib/wsdl/soap/address.rb40
-rw-r--r--lib/wsdl/soap/binding.rb49
-rw-r--r--lib/wsdl/soap/body.rb56
-rw-r--r--lib/wsdl/soap/cgiStubCreator.rb76
-rw-r--r--lib/wsdl/soap/classDefCreator.rb314
-rw-r--r--lib/wsdl/soap/classDefCreatorSupport.rb126
-rw-r--r--lib/wsdl/soap/clientSkeltonCreator.rb78
-rw-r--r--lib/wsdl/soap/complexType.rb161
-rw-r--r--lib/wsdl/soap/data.rb42
-rw-r--r--lib/wsdl/soap/definitions.rb149
-rw-r--r--lib/wsdl/soap/driverCreator.rb95
-rw-r--r--lib/wsdl/soap/element.rb28
-rw-r--r--lib/wsdl/soap/fault.rb56
-rw-r--r--lib/wsdl/soap/header.rb86
-rw-r--r--lib/wsdl/soap/headerfault.rb56
-rw-r--r--lib/wsdl/soap/mappingRegistryCreator.rb92
-rw-r--r--lib/wsdl/soap/methodDefCreator.rb228
-rw-r--r--lib/wsdl/soap/operation.rb122
-rw-r--r--lib/wsdl/soap/servantSkeltonCreator.rb67
-rw-r--r--lib/wsdl/soap/standaloneServerStubCreator.rb85
-rw-r--r--lib/wsdl/soap/wsdl2ruby.rb176
-rw-r--r--lib/wsdl/types.rb43
-rw-r--r--lib/wsdl/wsdl.rb23
-rw-r--r--lib/wsdl/xmlSchema/all.rb69
-rw-r--r--lib/wsdl/xmlSchema/annotation.rb34
-rw-r--r--lib/wsdl/xmlSchema/any.rb56
-rw-r--r--lib/wsdl/xmlSchema/attribute.rb127
-rw-r--r--lib/wsdl/xmlSchema/choice.rb69
-rw-r--r--lib/wsdl/xmlSchema/complexContent.rb92
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb139
-rw-r--r--lib/wsdl/xmlSchema/content.rb96
-rw-r--r--lib/wsdl/xmlSchema/data.rb80
-rw-r--r--lib/wsdl/xmlSchema/element.rb154
-rw-r--r--lib/wsdl/xmlSchema/enumeration.rb36
-rw-r--r--lib/wsdl/xmlSchema/import.rb65
-rw-r--r--lib/wsdl/xmlSchema/importer.rb87
-rw-r--r--lib/wsdl/xmlSchema/include.rb54
-rw-r--r--lib/wsdl/xmlSchema/length.rb35
-rw-r--r--lib/wsdl/xmlSchema/parser.rb166
-rw-r--r--lib/wsdl/xmlSchema/pattern.rb36
-rw-r--r--lib/wsdl/xmlSchema/schema.rb143
-rw-r--r--lib/wsdl/xmlSchema/sequence.rb69
-rw-r--r--lib/wsdl/xmlSchema/simpleContent.rb65
-rw-r--r--lib/wsdl/xmlSchema/simpleExtension.rb54
-rw-r--r--lib/wsdl/xmlSchema/simpleRestriction.rb73
-rw-r--r--lib/wsdl/xmlSchema/simpleType.rb73
-rw-r--r--lib/wsdl/xmlSchema/unique.rb34
-rw-r--r--lib/wsdl/xmlSchema/xsd2ruby.rb107
-rw-r--r--lib/xmlrpc/README.rdoc300
-rw-r--r--lib/xmlrpc/client.rb10
-rw-r--r--lib/xmlrpc/create.rb6
-rw-r--r--lib/xmlrpc/datetime.rb2
-rw-r--r--lib/xsd/charset.rb187
-rw-r--r--lib/xsd/codegen.rb12
-rw-r--r--lib/xsd/codegen/classdef.rb203
-rw-r--r--lib/xsd/codegen/commentdef.rb34
-rw-r--r--lib/xsd/codegen/gensupport.rb166
-rw-r--r--lib/xsd/codegen/methoddef.rb63
-rw-r--r--lib/xsd/codegen/moduledef.rb191
-rw-r--r--lib/xsd/datatypes.rb1269
-rw-r--r--lib/xsd/datatypes1999.rb20
-rw-r--r--lib/xsd/iconvcharset.rb33
-rw-r--r--lib/xsd/mapping.rb42
-rw-r--r--lib/xsd/namedelements.rb95
-rw-r--r--lib/xsd/ns.rb140
-rw-r--r--lib/xsd/qname.rb78
-rw-r--r--lib/xsd/xmlparser.rb61
-rw-r--r--lib/xsd/xmlparser/parser.rb96
-rw-r--r--lib/xsd/xmlparser/rexmlparser.rb54
-rw-r--r--lib/xsd/xmlparser/xmlparser.rb50
-rw-r--r--lib/xsd/xmlparser/xmlscanner.rb147
-rw-r--r--lib/yaml/baseemitter.rb2
-rw-r--r--lib/yaml/encoding.rb6
-rw-r--r--lib/yaml/store.rb20
-rw-r--r--load.c681
-rw-r--r--main.c48
-rw-r--r--marshal.c674
-rw-r--r--math.c200
-rw-r--r--misc/README3
-rw-r--r--misc/rdebug.el136
-rw-r--r--misc/ruby-mode.el48
-rw-r--r--misc/ruby-style.el7
-rw-r--r--missing.h142
-rw-r--r--missing/acosh.c9
-rw-r--r--missing/alloca.c2
-rw-r--r--missing/crypt.c34
-rw-r--r--missing/dup2.c5
-rw-r--r--missing/erf.c12
-rw-r--r--missing/finite.c3
-rw-r--r--missing/flock.c14
-rw-r--r--missing/hypot.c3
-rw-r--r--missing/isinf.c17
-rw-r--r--missing/isnan.c8
-rw-r--r--missing/memcmp.c9
-rw-r--r--missing/memmove.c17
-rw-r--r--missing/os2.c25
-rw-r--r--missing/strcasecmp.c3
-rw-r--r--missing/strchr.c18
-rw-r--r--missing/strerror.c3
-rw-r--r--missing/strftime.c2
-rw-r--r--missing/strlcat.c73
-rw-r--r--missing/strlcpy.c69
-rw-r--r--missing/strncasecmp.c6
-rw-r--r--missing/strstr.c11
-rw-r--r--missing/strtod.c271
-rw-r--r--missing/strtol.c9
-rw-r--r--missing/strtoul.c14
-rw-r--r--missing/vsnprintf.c151
-rw-r--r--missing/x68.c2
-rwxr-xr-xmkconfig.rb16
-rw-r--r--node.h488
-rw-r--r--numeric.c1102
-rw-r--r--object.c1078
-rw-r--r--opt_insn_unif.def29
-rw-r--r--opt_operand.def59
-rw-r--r--pack.c360
-rw-r--r--parse.y7340
-rw-r--r--prec.c23
-rw-r--r--prelude.rb25
-rw-r--r--proc.c1686
-rw-r--r--process.c1553
-rw-r--r--random.c115
-rw-r--r--range.c564
-rw-r--r--re.c2668
-rw-r--r--re.h42
-rw-r--r--regcomp.c6311
-rw-r--r--regenc.c913
-rw-r--r--regenc.h198
-rw-r--r--regerror.c371
-rw-r--r--regex.c4693
-rw-r--r--regex.h221
-rw-r--r--regexec.c3802
-rw-r--r--regint.h836
-rw-r--r--regparse.c5345
-rw-r--r--regparse.h350
-rw-r--r--regsyntax.c315
-rw-r--r--ruby.c1006
-rw-r--r--ruby.h776
-rw-r--r--rubyio.h91
-rw-r--r--rubysig.h105
-rwxr-xr-xrubytest.rb12
-rw-r--r--sample/README7
-rw-r--r--sample/biorhythm.rb115
-rw-r--r--sample/cal.rb52
-rw-r--r--sample/dbmtest.rb14
-rw-r--r--sample/drb/darrayc.rb12
-rw-r--r--sample/erb/erb4html.rb60
-rw-r--r--sample/from.rb161
-rw-r--r--sample/getopts.test36
-rw-r--r--sample/goodfriday.rb48
-rw-r--r--sample/mrshtest.rb13
-rw-r--r--sample/occur.rb4
-rw-r--r--sample/openssl/cert_store_view.rb911
-rw-r--r--sample/openssl/cipher.rb73
-rw-r--r--sample/openssl/echo_cli.rb21
-rw-r--r--sample/openssl/echo_svr.rb15
-rw-r--r--sample/openssl/gen_csr.rb13
-rw-r--r--sample/openssl/smime_read.rb10
-rw-r--r--sample/openssl/smime_write.rb10
-rw-r--r--sample/openssl/wget.rb17
-rw-r--r--sample/optparse/opttest.rb28
-rw-r--r--sample/regx.rb23
-rw-r--r--sample/ripper/ruby2html.rb112
-rw-r--r--sample/ripper/strip-comment.rb19
-rw-r--r--sample/test.rb670
-rw-r--r--sample/time.rb16
-rw-r--r--signal.c713
-rw-r--r--sprintf.c371
-rw-r--r--st.c686
-rw-r--r--st.h72
-rw-r--r--string.c3938
-rw-r--r--struct.c398
-rw-r--r--template/insns.inc.tmpl21
-rw-r--r--template/insns_info.inc.tmpl83
-rw-r--r--template/minsns.inc.tmpl14
-rw-r--r--template/opt_sc.inc.tmpl32
-rw-r--r--template/optinsn.inc.tmpl30
-rw-r--r--template/optunifs.inc.tmpl35
-rw-r--r--template/vm.inc.tmpl28
-rw-r--r--template/vmtc.inc.tmpl18
-rw-r--r--template/yarvarch.en7
-rw-r--r--template/yarvarch.ja454
-rw-r--r--template/yasmdata.rb.tmpl20
-rw-r--r--test/csv/line_endings.gzbin59 -> 0 bytes-rw-r--r--test/csv/tc_csv_parsing.rb164
-rw-r--r--test/csv/tc_csv_writing.rb96
-rw-r--r--test/csv/tc_data_converters.rb260
-rw-r--r--test/csv/tc_features.rb177
-rw-r--r--test/csv/tc_headers.rb261
-rw-r--r--test/csv/tc_interface.rb235
-rw-r--r--test/csv/tc_row.rb289
-rw-r--r--test/csv/tc_serialization.rb155
-rw-r--r--test/csv/tc_table.rb392
-rw-r--r--test/csv/test_csv.rb1753
-rw-r--r--test/csv/ts_all.rb19
-rw-r--r--test/dbm/test_dbm.rb75
-rw-r--r--test/digest/test_digest_hmac.rb3
-rw-r--r--test/drb/drbtest.rb29
-rw-r--r--test/drb/test_drb.rb6
-rw-r--r--test/erb/hello.erb4
-rw-r--r--test/erb/test_erb.rb394
-rw-r--r--test/fileutils/fileasserts.rb35
-rw-r--r--test/fileutils/test_fileutils.rb12
-rw-r--r--test/gdbm/test_gdbm.rb111
-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/inlinetest.rb55
-rw-r--r--test/io/nonblock/test_flush.rb6
-rw-r--r--test/json/fixtures/fail1.json1
-rw-r--r--test/json/fixtures/fail10.json1
-rw-r--r--test/json/fixtures/fail11.json1
-rw-r--r--test/json/fixtures/fail12.json1
-rw-r--r--test/json/fixtures/fail13.json1
-rw-r--r--test/json/fixtures/fail14.json1
-rw-r--r--test/json/fixtures/fail18.json1
-rw-r--r--test/json/fixtures/fail19.json1
-rw-r--r--test/json/fixtures/fail2.json1
-rw-r--r--test/json/fixtures/fail20.json1
-rw-r--r--test/json/fixtures/fail21.json1
-rw-r--r--test/json/fixtures/fail22.json1
-rw-r--r--test/json/fixtures/fail23.json1
-rw-r--r--test/json/fixtures/fail24.json1
-rw-r--r--test/json/fixtures/fail25.json1
-rw-r--r--test/json/fixtures/fail27.json2
-rw-r--r--test/json/fixtures/fail28.json2
-rw-r--r--test/json/fixtures/fail3.json1
-rw-r--r--test/json/fixtures/fail4.json1
-rw-r--r--test/json/fixtures/fail5.json1
-rw-r--r--test/json/fixtures/fail6.json1
-rw-r--r--test/json/fixtures/fail7.json1
-rw-r--r--test/json/fixtures/fail8.json1
-rw-r--r--test/json/fixtures/fail9.json1
-rw-r--r--test/json/fixtures/pass1.json56
-rw-r--r--test/json/fixtures/pass15.json1
-rw-r--r--test/json/fixtures/pass16.json1
-rw-r--r--test/json/fixtures/pass17.json1
-rw-r--r--test/json/fixtures/pass2.json1
-rw-r--r--test/json/fixtures/pass26.json1
-rw-r--r--test/json/fixtures/pass3.json6
-rwxr-xr-xtest/json/runner.rb26
-rwxr-xr-xtest/json/test_json.rb254
-rwxr-xr-xtest/json/test_json_addition.rb143
-rwxr-xr-xtest/json/test_json_fixtures.rb29
-rw-r--r--test/json/test_json_generate.rb80
-rw-r--r--test/json/test_json_rails.rb113
-rwxr-xr-xtest/json/test_json_unicode.rb60
-rw-r--r--test/logger/test_logger.rb2
-rw-r--r--test/monitor/test_monitor.rb2
-rw-r--r--test/net/http/test_http.rb319
-rw-r--r--test/net/http/test_https.rb97
-rw-r--r--test/net/http/utils.rb95
-rw-r--r--test/net/imap/cacert.pem62
-rw-r--r--test/net/imap/server.crt12
-rw-r--r--test/net/imap/server.key15
-rw-r--r--test/net/imap/test_imap.rb142
-rw-r--r--test/nkf/test_kconv.rb97
-rw-r--r--test/openssl/test_asn1.rb2
-rw-r--r--test/openssl/test_pair.rb5
-rw-r--r--test/openssl/test_pkcs7.rb10
-rw-r--r--test/openssl/test_ssl.rb233
-rw-r--r--test/pathname/test_pathname.rb28
-rw-r--r--test/readline/test_readline.rb2
-rw-r--r--test/rinda/test_rinda.rb124
-rw-r--r--test/rinda/test_tuplebag.rb172
-rw-r--r--test/ripper/dummyparser.rb571
-rw-r--r--test/ripper/test_files.rb25
-rw-r--r--test/ripper/test_parser_events.rb498
-rw-r--r--test/ripper/test_scanner_events.rb807
-rw-r--r--test/rss/dot.pngbin0 -> 111 bytes-rw-r--r--test/rss/rss-assertions.rb16
-rw-r--r--test/rss/test_atom.rb17
-rw-r--r--test/rss/test_maker_0.9.rb2
-rw-r--r--test/rss/test_maker_2.0.rb29
-rw-r--r--test/rss/test_maker_dc.rb5
-rw-r--r--test/rss/test_parser.rb12
-rw-r--r--test/rss/test_parser_1.0.rb1
-rw-r--r--test/rss/test_version.rb2
-rw-r--r--test/ruby/beginmainend.rb2
-rw-r--r--test/ruby/endblockwarn.rb (renamed from test/ruby/endblockwarn_rb)0
-rw-r--r--test/ruby/envutil.rb7
-rw-r--r--test/ruby/marshaltestlib.rb6
-rw-r--r--test/ruby/sentence.rb668
-rw-r--r--test/ruby/suicide.rb2
-rw-r--r--test/ruby/test_alias.rb56
-rw-r--r--test/ruby/test_array.rb56
-rw-r--r--test/ruby/test_assignment.rb702
-rw-r--r--test/ruby/test_basicinstructions.rb628
-rw-r--r--test/ruby/test_beginendblock.rb37
-rw-r--r--test/ruby/test_bignum.rb22
-rw-r--r--test/ruby/test_class.rb80
-rw-r--r--test/ruby/test_const.rb27
-rw-r--r--test/ruby/test_continuation.rb54
-rw-r--r--test/ruby/test_defined.rb42
-rw-r--r--test/ruby/test_dir.rb30
-rw-r--r--test/ruby/test_encoding.rb28
-rw-r--r--test/ruby/test_enum.rb258
-rw-r--r--test/ruby/test_enumerator.rb62
-rw-r--r--test/ruby/test_env.rb24
-rw-r--r--test/ruby/test_eval.rb276
-rw-r--r--test/ruby/test_fiber.rb164
-rw-r--r--test/ruby/test_file.rb74
-rw-r--r--test/ruby/test_fixnum.rb95
-rw-r--r--test/ruby/test_float.rb37
-rw-r--r--test/ruby/test_fnmatch.rb104
-rw-r--r--test/ruby/test_gc.rb5
-rw-r--r--test/ruby/test_hash.rb24
-rw-r--r--test/ruby/test_integer.rb27
-rw-r--r--test/ruby/test_io.rb47
-rw-r--r--test/ruby/test_io_m17n.rb388
-rw-r--r--test/ruby/test_iterator.rb94
-rw-r--r--test/ruby/test_lambda.rb68
-rw-r--r--test/ruby/test_literal.rb184
-rw-r--r--test/ruby/test_m17n.rb1913
-rw-r--r--test/ruby/test_marshal.rb43
-rw-r--r--test/ruby/test_method.rb20
-rw-r--r--test/ruby/test_mixed_unicode_escapes.rb25
-rw-r--r--test/ruby/test_module.rb316
-rw-r--r--test/ruby/test_optimization.rb140
-rw-r--r--test/ruby/test_path.rb10
-rw-r--r--test/ruby/test_pipe.rb2
-rw-r--r--test/ruby/test_primitive.rb397
-rw-r--r--test/ruby/test_proc.rb66
-rw-r--r--test/ruby/test_process.rb2
-rw-r--r--test/ruby/test_range.rb57
-rw-r--r--test/ruby/test_readpartial.rb4
-rw-r--r--test/ruby/test_regexp.rb118
-rw-r--r--test/ruby/test_settracefunc.rb284
-rw-r--r--test/ruby/test_signal.rb37
-rw-r--r--test/ruby/test_sleep.rb10
-rw-r--r--test/ruby/test_sprintf.rb182
-rw-r--r--test/ruby/test_string.rb1342
-rw-r--r--test/ruby/test_stringchar.rb8
-rw-r--r--test/ruby/test_struct.rb28
-rw-r--r--test/ruby/test_super.rb6
-rw-r--r--test/ruby/test_symbol.rb11
-rw-r--r--test/ruby/test_system.rb75
-rw-r--r--test/ruby/test_thread.rb24
-rw-r--r--test/ruby/test_time.rb83
-rw-r--r--test/ruby/test_transcode.rb124
-rw-r--r--test/ruby/test_unicode_escape.rb267
-rw-r--r--test/ruby/test_variable.rb8
-rw-r--r--test/ruby/test_whileuntil.rb111
-rw-r--r--test/ruby/test_yield.rb355
-rw-r--r--test/ruby/ut_eof.rb12
-rw-r--r--test/rubygems/bogussources.rb8
-rw-r--r--test/rubygems/data/gem-private_key.pem27
-rw-r--r--test/rubygems/data/gem-public_cert.pem20
-rw-r--r--test/rubygems/fake_certlib/openssl.rb7
-rw-r--r--test/rubygems/functional.rb95
-rw-r--r--test/rubygems/gemutilities.rb315
-rw-r--r--test/rubygems/insure_session.rb51
-rw-r--r--test/rubygems/mockgemui.rb51
-rw-r--r--test/rubygems/simple_gem.rb72
-rw-r--r--test/rubygems/test_config.rb26
-rw-r--r--test/rubygems/test_gem.rb348
-rw-r--r--test/rubygems/test_gem_builder.rb34
-rw-r--r--test/rubygems/test_gem_command.rb196
-rw-r--r--test/rubygems/test_gem_command_manager.rb211
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb75
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb122
-rw-r--r--test/rubygems/test_gem_commands_check_command.rb25
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb92
-rw-r--r--test/rubygems/test_gem_commands_dependency_command.rb108
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb117
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb34
-rw-r--r--test/rubygems/test_gem_commands_generate_index_command.rb32
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb160
-rw-r--r--test/rubygems/test_gem_commands_mirror_command.rb61
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb100
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb86
-rw-r--r--test/rubygems/test_gem_commands_server_command.rb27
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb147
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb93
-rw-r--r--test/rubygems/test_gem_commands_unpack_command.rb73
-rw-r--r--test/rubygems/test_gem_config_file.rb210
-rw-r--r--test/rubygems/test_gem_dependency.rb89
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb542
-rw-r--r--test/rubygems/test_gem_dependency_list.rb212
-rwxr-xr-xtest/rubygems/test_gem_digest.rb44
-rw-r--r--test/rubygems/test_gem_doc_manager.rb32
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb84
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb122
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb73
-rw-r--r--test/rubygems/test_gem_format.rb69
-rw-r--r--test/rubygems/test_gem_gem_path_searcher.rb57
-rw-r--r--test/rubygems/test_gem_gem_runner.rb35
-rw-r--r--test/rubygems/test_gem_indexer.rb119
-rw-r--r--test/rubygems/test_gem_install_update_options.rb40
-rw-r--r--test/rubygems/test_gem_installer.rb885
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb84
-rw-r--r--test/rubygems/test_gem_outdated_command.rb40
-rw-r--r--test/rubygems/test_gem_platform.rb259
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb434
-rw-r--r--test/rubygems/test_gem_requirement.rb223
-rw-r--r--test/rubygems/test_gem_server.rb114
-rw-r--r--test/rubygems/test_gem_source_index.rb429
-rw-r--r--test/rubygems/test_gem_source_info_cache.rb299
-rw-r--r--test/rubygems/test_gem_source_info_cache_entry.rb46
-rw-r--r--test/rubygems/test_gem_specification.rb870
-rw-r--r--test/rubygems/test_gem_stream_ui.rb117
-rw-r--r--test/rubygems/test_gem_validator.rb70
-rw-r--r--test/rubygems/test_gem_version.rb206
-rw-r--r--test/rubygems/test_gem_version_option.rb77
-rw-r--r--test/rubygems/test_kernel.rb64
-rw-r--r--test/rubygems/test_open_uri.rb13
-rw-r--r--test/rubygems/test_package.rb610
-rw-r--r--test/runner.rb2
-rw-r--r--test/scanf/data.txt6
-rw-r--r--test/scanf/test_scanf.rb313
-rw-r--r--test/scanf/test_scanfblocks.rb81
-rw-r--r--test/scanf/test_scanfio.rb19
-rw-r--r--test/sdbm/test_sdbm.rb51
-rw-r--r--test/soap/asp.net/hello.wsdl96
-rw-r--r--test/soap/asp.net/test_aspdotnet.rb111
-rw-r--r--test/soap/calc/calc.rb17
-rw-r--r--test/soap/calc/calc2.rb29
-rw-r--r--test/soap/calc/server.cgi13
-rw-r--r--test/soap/calc/server.rb17
-rw-r--r--test/soap/calc/server2.rb20
-rw-r--r--test/soap/calc/test_calc.rb49
-rw-r--r--test/soap/calc/test_calc2.rb53
-rw-r--r--test/soap/calc/test_calc_cgi.rb69
-rw-r--r--test/soap/fault/test_customfault.rb58
-rw-r--r--test/soap/header/server.cgi119
-rw-r--r--test/soap/header/test_authheader.rb240
-rw-r--r--test/soap/header/test_authheader_cgi.rb121
-rw-r--r--test/soap/header/test_simplehandler.rb116
-rw-r--r--test/soap/helloworld/hw_s.rb16
-rw-r--r--test/soap/helloworld/test_helloworld.rb40
-rw-r--r--test/soap/marshal/test_digraph.rb56
-rw-r--r--test/soap/marshal/test_marshal.rb26
-rw-r--r--test/soap/marshal/test_struct.rb47
-rw-r--r--test/soap/ssl/README1
-rw-r--r--test/soap/ssl/ca.cert23
-rw-r--r--test/soap/ssl/client.cert19
-rw-r--r--test/soap/ssl/client.key15
-rw-r--r--test/soap/ssl/server.cert19
-rw-r--r--test/soap/ssl/server.key15
-rw-r--r--test/soap/ssl/sslsvr.rb57
-rw-r--r--test/soap/ssl/subca.cert21
-rw-r--r--test/soap/ssl/test_ssl.rb204
-rw-r--r--test/soap/struct/test_struct.rb77
-rw-r--r--test/soap/swa/test_file.rb73
-rw-r--r--test/soap/test_basetype.rb970
-rw-r--r--test/soap/test_envelopenamespace.rb92
-rw-r--r--test/soap/test_httpconfigloader.rb39
-rw-r--r--test/soap/test_mapping.rb59
-rw-r--r--test/soap/test_no_indent.rb86
-rw-r--r--test/soap/test_property.rb424
-rw-r--r--test/soap/test_soapelement.rb122
-rw-r--r--test/soap/test_streamhandler.rb209
-rw-r--r--test/soap/test_styleuse.rb333
-rw-r--r--test/soap/wsdlDriver/README.txt2
-rw-r--r--test/soap/wsdlDriver/calc.wsdl126
-rw-r--r--test/soap/wsdlDriver/document.wsdl54
-rw-r--r--test/soap/wsdlDriver/echo_version.rb20
-rw-r--r--test/soap/wsdlDriver/simpletype.wsdl63
-rw-r--r--test/soap/wsdlDriver/test_calc.rb100
-rw-r--r--test/soap/wsdlDriver/test_document.rb78
-rw-r--r--test/soap/wsdlDriver/test_simpletype.rb87
-rw-r--r--test/socket/test_socket.rb37
-rw-r--r--test/socket/test_tcp.rb29
-rw-r--r--test/socket/test_udp.rb32
-rw-r--r--test/socket/test_unix.rb1
-rw-r--r--test/stringio/test_stringio.rb12
-rw-r--r--test/strscan/test_stringscanner.rb52
-rw-r--r--test/test_generator.rb4
-rw-r--r--test/test_ipaddr.rb4
-rw-r--r--test/test_pp.rb4
-rw-r--r--test/test_prettyprint.rb4
-rw-r--r--test/test_set.rb4
-rw-r--r--test/test_shellwords.rb39
-rw-r--r--test/test_time.rb4
-rw-r--r--test/test_tsort.rb4
-rw-r--r--test/testunit/collector/test_dir.rb31
-rw-r--r--test/testunit/collector/test_objectspace.rb16
-rw-r--r--test/testunit/runit/test_assert.rb402
-rw-r--r--test/testunit/runit/test_testcase.rb91
-rw-r--r--test/testunit/runit/test_testresult.rb144
-rw-r--r--test/testunit/runit/test_testsuite.rb49
-rw-r--r--test/testunit/test_assertions.rb1
-rwxr-xr-xtest/thread/lbtest.rb51
-rw-r--r--test/thread/test_thread.rb81
-rw-r--r--test/uri/test_ftp.rb8
-rw-r--r--test/uri/test_generic.rb105
-rw-r--r--test/webrick/.htaccess1
-rw-r--r--test/webrick/test_cgi.rb18
-rw-r--r--test/webrick/test_cookie.rb2
-rw-r--r--test/webrick/test_filehandler.rb141
-rw-r--r--test/webrick/test_httprequest.rb10
-rw-r--r--test/webrick/test_utils.rb64
-rw-r--r--test/webrick/utils.rb14
-rw-r--r--test/webrick/webrick_long_filename.cgi36
-rw-r--r--test/win32ole/test_folderitem2_invokeverb.rb83
-rw-r--r--test/win32ole/test_nil2vtempty.rb36
-rw-r--r--test/win32ole/test_propertyputref.rb30
-rw-r--r--test/win32ole/test_win32ole.rb408
-rw-r--r--test/win32ole/test_win32ole_event.rb131
-rw-r--r--test/win32ole/test_win32ole_method.rb135
-rw-r--r--test/win32ole/test_win32ole_param.rb84
-rw-r--r--test/win32ole/test_win32ole_type.rb177
-rw-r--r--test/win32ole/test_win32ole_typelib.rb105
-rw-r--r--test/win32ole/test_win32ole_variable.rb61
-rw-r--r--test/win32ole/test_win32ole_variant.rb592
-rw-r--r--test/win32ole/test_win32ole_variant_m.rb35
-rw-r--r--test/win32ole/test_win32ole_variant_with_ie.rb53
-rw-r--r--test/win32ole/test_word.rb45
-rw-r--r--test/wsdl/any/any.wsdl50
-rw-r--r--test/wsdl/any/expectedDriver.rb54
-rw-r--r--test/wsdl/any/expectedEcho.rb14
-rw-r--r--test/wsdl/any/expectedService.rb52
-rw-r--r--test/wsdl/any/test_any.rb58
-rw-r--r--test/wsdl/axisArray/axisArray.wsdl60
-rw-r--r--test/wsdl/axisArray/itemList.rb27
-rw-r--r--test/wsdl/axisArray/test_axisarray.rb69
-rw-r--r--test/wsdl/datetime/DatetimeService.rb44
-rw-r--r--test/wsdl/datetime/datetime.rb (renamed from benchmark/bmx_temp.rb)0
-rw-r--r--test/wsdl/datetime/datetime.wsdl45
-rw-r--r--test/wsdl/datetime/datetimeServant.rb21
-rw-r--r--test/wsdl/datetime/test_datetime.rb82
-rw-r--r--test/wsdl/document/document.wsdl74
-rw-r--r--test/wsdl/document/echo.rb92
-rw-r--r--test/wsdl/document/number.wsdl54
-rw-r--r--test/wsdl/document/ping_nosoapaction.wsdl66
-rw-r--r--test/wsdl/document/test_nosoapaction.rb109
-rw-r--r--test/wsdl/document/test_number.rb99
-rw-r--r--test/wsdl/document/test_rpc.rb177
-rw-r--r--test/wsdl/emptycomplextype.wsdl31
-rw-r--r--test/wsdl/map/map.wsdl92
-rw-r--r--test/wsdl/map/map.xml43
-rw-r--r--test/wsdl/map/test_map.rb99
-rw-r--r--test/wsdl/marshal/person.wsdl21
-rw-r--r--test/wsdl/marshal/person_org.rb22
-rw-r--r--test/wsdl/marshal/test_wsdlmarshal.rb80
-rw-r--r--test/wsdl/multiplefault.wsdl68
-rw-r--r--test/wsdl/qualified/lp.rb0
-rw-r--r--test/wsdl/qualified/lp.wsdl47
-rw-r--r--test/wsdl/qualified/lp.xsd26
-rw-r--r--test/wsdl/qualified/np.wsdl50
-rw-r--r--test/wsdl/qualified/test_qualified.rb154
-rw-r--r--test/wsdl/qualified/test_unqualified.rb143
-rw-r--r--test/wsdl/raa/RAA.rb243
-rw-r--r--test/wsdl/raa/RAAServant.rb99
-rw-r--r--test/wsdl/raa/RAAService.rb100
-rw-r--r--test/wsdl/raa/README.txt8
-rw-r--r--test/wsdl/raa/raa.wsdl264
-rw-r--r--test/wsdl/raa/server.rb103
-rw-r--r--test/wsdl/raa/test_raa.rb71
-rw-r--r--test/wsdl/ref/expectedProduct.rb90
-rw-r--r--test/wsdl/ref/product.wsdl86
-rw-r--r--test/wsdl/ref/test_ref.rb54
-rw-r--r--test/wsdl/rpc/echoDriver.rb55
-rw-r--r--test/wsdl/rpc/echo_serviceClient.rb23
-rw-r--r--test/wsdl/rpc/rpc.wsdl75
-rw-r--r--test/wsdl/rpc/test-rpc-lit.wsdl364
-rw-r--r--test/wsdl/rpc/test-rpc-lit12.wsdl455
-rw-r--r--test/wsdl/rpc/test_rpc.rb118
-rw-r--r--test/wsdl/rpc/test_rpc_lit.rb399
-rw-r--r--test/wsdl/simpletype/rpc/expectedClient.rb34
-rw-r--r--test/wsdl/simpletype/rpc/expectedDriver.rb62
-rw-r--r--test/wsdl/simpletype/rpc/expectedEchoVersion.rb23
-rw-r--r--test/wsdl/simpletype/rpc/expectedServant.rb32
-rw-r--r--test/wsdl/simpletype/rpc/expectedService.rb60
-rw-r--r--test/wsdl/simpletype/rpc/rpc.wsdl80
-rw-r--r--test/wsdl/simpletype/rpc/test_rpc.rb62
-rw-r--r--test/wsdl/simpletype/simpletype.wsdl95
-rw-r--r--test/wsdl/simpletype/test_simpletype.rb99
-rw-r--r--test/wsdl/soap/soapbodyparts.wsdl103
-rw-r--r--test/wsdl/soap/test_soapbodyparts.rb79
-rw-r--r--test/wsdl/test_emptycomplextype.rb21
-rw-r--r--test/wsdl/test_fault.rb51
-rw-r--r--test/wsdl/test_multiplefault.rb39
-rw-r--r--test/xmlrpc/test_cookie.rb96
-rw-r--r--test/xmlrpc/webrick_testing.rb7
-rw-r--r--test/xsd/codegen/test_classdef.rb214
-rw-r--r--test/xsd/noencoding.xml4
-rw-r--r--test/xsd/test_noencoding.rb32
-rw-r--r--test/xsd/test_xmlschemaparser.rb22
-rw-r--r--test/xsd/test_xsd.rb1511
-rw-r--r--test/xsd/xmlschema.xml12
-rw-r--r--test/yaml/test_yaml.rb34
-rw-r--r--test/yaml/test_yamlstore.rb74
-rw-r--r--test/zlib/test_zlib.rb18
-rw-r--r--thread.c3115
-rw-r--r--thread_pthread.c600
-rw-r--r--thread_pthread.h25
-rw-r--r--thread_win32.c528
-rw-r--r--thread_win32.h34
-rw-r--r--time.c1543
-rw-r--r--tool/asm_parse.rb51
-rw-r--r--tool/compile_prelude.rb96
-rw-r--r--tool/eval.rb161
-rwxr-xr-xtool/insns2vm.rb15
-rw-r--r--tool/instruction.rb1381
-rwxr-xr-xtool/make-snapshot38
-rwxr-xr-xtool/node_name.rb4
-rw-r--r--tool/parse.rb13
-rw-r--r--tool/vtlh.rb15
-rwxr-xr-xtool/ytab.sed30
-rw-r--r--transcode.c433
-rw-r--r--transcode_data.h78
-rw-r--r--util.c125
-rw-r--r--util.h67
-rw-r--r--variable.c970
-rw-r--r--version.c48
-rw-r--r--version.h54
-rw-r--r--vm.c1895
-rw-r--r--vm.h281
-rw-r--r--vm_core.h681
-rw-r--r--vm_dump.c598
-rw-r--r--vm_evalbody.c143
-rw-r--r--vm_insnhelper.c1455
-rw-r--r--vm_opts.h52
-rw-r--r--vms/config.h193
-rw-r--r--vms/vms.h9
-rw-r--r--win32/Makefile.sub341
-rw-r--r--win32/README.win3251
-rwxr-xr-xwin32/configure.bat65
-rw-r--r--win32/dir.h11
-rw-r--r--win32/enc-setup.mak6
-rwxr-xr-xwin32/mkexports.rb153
-rwxr-xr-xwin32/resource.rb6
-rw-r--r--win32/setup.mak93
-rw-r--r--win32/win32.c1365
-rw-r--r--win32/win32.h556
-rw-r--r--wince/Makefile.sub539
-rw-r--r--wince/README.wince19
-rwxr-xr-xwince/configure.bat9
-rw-r--r--wince/setup.mak9
-rw-r--r--yarvtest/runner.rb9
-rw-r--r--yarvtest/test_block.rb429
-rw-r--r--yarvtest/test_eval.rb221
-rw-r--r--yarvtest/test_exception.rb408
-rw-r--r--yarvtest/test_flow.rb591
-rw-r--r--yarvtest/test_jump.rb296
-rw-r--r--yarvtest/test_proc.rb293
-rw-r--r--yarvtest/test_syntax.rb594
-rw-r--r--yarvtest/test_test.rb8
-rw-r--r--yarvtest/test_thread.rb209
-rw-r--r--yarvtest/yarvtest.rb112
1766 files changed, 123999 insertions, 237121 deletions
diff --git a/.cvsignore b/.cvsignore
index 76c9bc0b78..a72211d03f 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -14,7 +14,6 @@
COPYING.LIB
ChangeLog.pre-alpha
ChangeLog.pre1_1
-ChangeLog-1.8.0
Makefile
README.fat-patch
README.v6
@@ -35,12 +34,9 @@ newdate.rb
newver.rb
parse.c
patches
-patches-master
-pitest.rb
ppack
preview
rbconfig.rb
-rename2.h
repack
riscos
rubicon
diff --git a/.gdbinit b/.gdbinit
deleted file mode 100644
index dee9fd87e8..0000000000
--- a/.gdbinit
+++ /dev/null
@@ -1,522 +0,0 @@
-define rp
- if (VALUE)$arg0 & RUBY_FIXNUM_FLAG
- printf "FIXNUM: %d\n", $arg0 >> 1
- else
- if ((VALUE)$arg0 & ~(~(VALUE)0<<RUBY_SPECIAL_SHIFT)) == RUBY_SYMBOL_FLAG
- printf "SYMBOL(%d)\n", $arg0 >> RUBY_SPECIAL_SHIFT
- else
- if $arg0 == RUBY_Qfalse
- echo false\n
- else
- if $arg0 == RUBY_Qtrue
- echo true\n
- else
- if $arg0 == RUBY_Qnil
- echo nil\n
- else
- if $arg0 == RUBY_Qundef
- echo undef\n
- else
- if (VALUE)$arg0 & RUBY_IMMEDIATE_MASK
- echo immediate\n
- else
- set $flags = ((struct RBasic*)$arg0)->flags
- if ($flags & RUBY_T_MASK) == RUBY_T_NONE
- printf "T_NONE: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_NIL
- printf "T_NIL: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_OBJECT
- printf "T_OBJECT: "
- print (struct RObject *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_CLASS
- printf "T_CLASS: "
- print (struct RClass *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_ICLASS
- printf "T_ICLASS: "
- print (struct RClass *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_MODULE
- printf "T_MODULE: "
- print (struct RClass *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_FLOAT
- printf "T_FLOAT: %.16g ", (((struct RFloat*)$arg0)->value)
- print (struct RFloat *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_STRING
- printf "T_STRING: "
- set print address off
- output (char *)(($flags & RUBY_FL_USER1) ? \
- ((struct RString*)$arg0)->as.heap.ptr : \
- ((struct RString*)$arg0)->as.ary)
- set print address on
- printf " bytesize:%d ", ($flags & RUBY_FL_USER1) ? \
- ((struct RString*)$arg0)->as.heap.len : \
- (($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
- if !($flags & RUBY_FL_USER1)
- printf "(embed) "
- else
- if ($flags & RUBY_FL_USER2)
- printf "(shared) "
- end
- if ($flags & RUBY_FL_USER3)
- printf "(assoc) "
- end
- end
- printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
- if ($flags & RUBY_ENC_CODERANGE_MASK) == 0
- printf "coderange:unknown "
- else
- if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_7BIT
- printf "coderange:7bit "
- else
- if ($flags & RUBY_ENC_CODERANGE_MASK) == RUBY_ENC_CODERANGE_VALID
- printf "coderange:valid "
- else
- printf "coderange:broken "
- end
- end
- end
- print (struct RString *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_REGEXP
- printf "T_REGEXP: "
- set print address off
- output ((struct RRegexp*)$arg0)->str
- set print address on
- printf " len:%d ", ((struct RRegexp*)$arg0)->len
- if $flags & RUBY_FL_USER6
- printf "(none) "
- end
- if $flags & RUBY_FL_USER5
- printf "(literal) "
- end
- if $flags & RUBY_FL_USER4
- printf "(fixed) "
- end
- printf "encoding:%d ", ($flags & RUBY_ENCODING_MASK) >> RUBY_ENCODING_SHIFT
- print (struct RRegexp *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_ARRAY
- printf "T_ARRAY: len=%d ", ((struct RArray*)$arg0)->len
- print (struct RArray *)$arg0
- x/xw ((struct RArray*)$arg0)->ptr
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_FIXNUM
- printf "T_FIXNUM: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_HASH
- printf "T_HASH: ",
- if ((struct RHash *)$arg0)->ntbl
- printf "len=%d ", ((struct RHash *)$arg0)->ntbl->num_entries
- end
- print (struct RHash *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_STRUCT
- printf "T_STRUCT: len=%d ", \
- (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
- ($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) >> (RUBY_FL_USHIFT+1) : \
- ((struct RStruct *)$arg0)->as.heap.len)
- print (struct RStruct *)$arg0
- x/xw (($flags & (RUBY_FL_USER1|RUBY_FL_USER2)) ? \
- ((struct RStruct *)$arg0)->as.ary : \
- ((struct RStruct *)$arg0)->as.heap.len)
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_BIGNUM
- printf "T_BIGNUM: sign=%d len=%d ", \
- (($flags & RUBY_FL_USER1) != 0), \
- (($flags & RUBY_FL_USER2) ? \
- ($flags & (RUBY_FL_USER5|RUBY_FL_USER4|RUBY_FL_USER3)) >> (RUBY_FL_USHIFT+3) : \
- ((struct RBignum*)$arg0)->as.heap.len)
- if $flags & RUBY_FL_USER2
- printf "(embed) "
- end
- print (struct RBignum *)$arg0
- x/xw (($flags & RUBY_FL_USER2) ? \
- ((struct RBignum*)$arg0)->as.ary : \
- ((struct RBignum*)$arg0)->as.heap.digits)
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_FILE
- printf "T_FILE: "
- print (struct RFile *)$arg0
- output *((struct RFile *)$arg0)->fptr
- printf "\n"
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_TRUE
- printf "T_TRUE: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_FALSE
- printf "T_FALSE: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_DATA
- printf "T_DATA: "
- print (struct RData *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_MATCH
- printf "T_MATCH: "
- print (struct RMatch *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_SYMBOL
- printf "T_SYMBOL: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_VALUES
- printf "T_VALUES: "
- print (struct RValues *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_BLOCK
- printf "T_BLOCK: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_UNDEF
- printf "T_UNDEF: "
- print (struct RBasic *)$arg0
- else
- if ($flags & RUBY_T_MASK) == RUBY_T_NODE
- printf "T_NODE("
- output (enum node_type)(($flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
- printf "): "
- print *(NODE *)$arg0
- else
- printf "unknown: "
- print (struct RBasic *)$arg0
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
-end
-document rp
- Print a Ruby's VALUE.
-end
-
-define nd_type
- print (enum node_type)((((NODE*)$arg0)->flags&RUBY_NODE_TYPEMASK)>>RUBY_NODE_TYPESHIFT)
-end
-document nd_type
- Print a Ruby' node type.
-end
-
-define nd_file
- print ((NODE*)$arg0)->nd_file
-end
-document nd_file
- Print the source file name of a node.
-end
-
-define nd_line
- print ((unsigned int)((((NODE*)$arg0)->flags>>RUBY_NODE_LSHIFT)&RUBY_NODE_LMASK))
-end
-document nd_line
- Print the source line number of a node.
-end
-
-# Print members of ruby node.
-
-define nd_head
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_alen
- printf "u2.argc: "
- p $arg0.u2.argc
-end
-
-define nd_next
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_cond
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_body
- printf "u2.node: "
- rp $arg0.u2.node
-end
-
-define nd_else
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_orig
- printf "u3.value: "
- rp $arg0.u3.value
-end
-
-
-define nd_resq
- printf "u2.node: "
- rp $arg0.u2.node
-end
-
-define nd_ensr
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_1st
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_2nd
- printf "u2.node: "
- rp $arg0.u2.node
-end
-
-
-define nd_stts
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-
-define nd_entry
- printf "u3.entry: "
- p $arg0.u3.entry
-end
-
-define nd_vid
- printf "u1.id: "
- p $arg0.u1.id
-end
-
-define nd_cflag
- printf "u2.id: "
- p $arg0.u2.id
-end
-
-define nd_cval
- printf "u3.value: "
- rp $arg0.u3.value
-end
-
-
-define nd_cnt
- printf "u3.cnt: "
- p $arg0.u3.cnt
-end
-
-define nd_tbl
- printf "u1.tbl: "
- p $arg0.u1.tbl
-end
-
-
-define nd_var
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_ibdy
- printf "u2.node: "
- rp $arg0.u2.node
-end
-
-define nd_iter
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_value
- printf "u2.node: "
- rp $arg0.u2.node
-end
-
-define nd_aid
- printf "u3.id: "
- p $arg0.u3.id
-end
-
-
-define nd_lit
- printf "u1.value: "
- rp $arg0.u1.value
-end
-
-
-define nd_frml
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_rest
- printf "u2.argc: "
- p $arg0.u2.argc
-end
-
-define nd_opt
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-
-define nd_recv
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_mid
- printf "u2.id: "
- p $arg0.u2.id
-end
-
-define nd_args
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_noex
- printf "u1.id: "
- p $arg0.u1.id
-end
-
-define nd_defn
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_old
- printf "u1.id: "
- p $arg0.u1.id
-end
-
-define nd_new
- printf "u2.id: "
- p $arg0.u2.id
-end
-
-
-define nd_cfnc
- printf "u1.cfunc: "
- p $arg0.u1.cfunc
-end
-
-define nd_argc
- printf "u2.argc: "
- p $arg0.u2.argc
-end
-
-
-define nd_cname
- printf "u1.id: "
- p $arg0.u1.id
-end
-
-define nd_super
- printf "u3.node: "
- rp $arg0.u3.node
-end
-
-
-define nd_modl
- printf "u1.id: "
- p $arg0.u1.id
-end
-
-define nd_clss
- printf "u1.value: "
- rp $arg0.u1.value
-end
-
-
-define nd_beg
- printf "u1.node: "
- rp $arg0.u1.node
-end
-
-define nd_end
- printf "u2.node: "
- rp $arg0.u2.node
-end
-
-define nd_state
- printf "u3.state: "
- p $arg0.u3.state
-end
-
-define nd_rval
- printf "u2.value: "
- rp $arg0.u2.value
-end
-
-
-define nd_nth
- printf "u2.argc: "
- p $arg0.u2.argc
-end
-
-
-define nd_tag
- printf "u1.id: "
- p $arg0.u1.id
-end
-
-define nd_tval
- printf "u2.value: "
- rp $arg0.u2.value
-end
-
-define rb_p
- call rb_p($arg0)
-end
-
-define rb_id2name
- call rb_id2name($arg0)
-end
-
-define rb_classname
- call classname($arg0)
- rb_p $
- print *(struct RClass*)$arg0
-end
-
-define rb_backtrace
- call rb_backtrace()
-end
diff --git a/COPYING.ja b/COPYING.ja
index aa2a163848..933cc7cb9a 100644
--- a/COPYING.ja
+++ b/COPYING.ja
@@ -1,6 +1,6 @@
-$BK\%W%m%0%i%`$O%U%j!<%=%U%H%&%'%"$G$9!%(BGPL (the GNU General
-Public License)$B%P!<%8%g%s(B2$B$^$?$O0J2<$K<($9>r7o$GK\%W%m%0%i%`(B
-$B$r:FG[I[$G$-$^$9!%(BGPL$B$K$D$$$F$O(BGPL$B%U%!%$%k$r;2>H$7$F2<$5$$!%(B
+$BK\%W%m%0%i%`$O%U%j!<%=%U%H%&%'%"$G$9!%(BGPL(the GNU General
+Public License)$B$^$?$O0J2<$K<($9>r7o$GK\%W%m%0%i%`$r:FG[I[$G(B
+$B$-$^$9!%(BGPL$B$K$D$$$F$O(BGPL$B%U%!%$%k$r;2>H$7$F2<$5$$!%(B
1. $BJ#@=$O@)8B$J$/<+M3$G$9!%(B
diff --git a/ChangeLog b/ChangeLog
index b77d871a4b..6432869b78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,2860 +1,2768 @@
-Tue Dec 25 23:33:55 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Jan 9 19:25:25 2009 Shugo Maeda <shugo@ruby-lang.org>
- * development version 1.9.0 released.
+ * lib/net/imap.rb (disconnect): do not refer SSL::SSLSocket for
+ environments without OpenSSL. backported from trunk.
+ fixed [ruby-dev:35755].
-Tue Dec 25 23:25:29 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jan 8 13:24:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.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].
-
-Tue Dec 25 23:16:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (proc_options): encoding option in shbang and RUBYOPT did not
- work, do not store alloca()ed string in a parent scope struct.
-
-Tue Dec 25 22:56:52 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/Makefile.sub (config.status): keep this file.
-
-Tue Dec 25 22:55:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (TIMEZONE_VOID): typo.
-
-Tue Dec 25 22:45:10 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns2vm.rb: add encoding option to shbang.
-
-Tue Dec 25 22:13:51 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/pending.rb: add pending issue.
-
-Tue Dec 25 22:12:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c: remove Thread.critical(=).
-
-Tue Dec 25 21:44:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * tool/make-snapshot: add version number.
-
-Tue Dec 25 21:32:54 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix stack consistency error
- (break is compiled to throw instead of jump insn).
- these problems are reported by Yusuke ENDOH <mame AT tsg.ne.jp>
-
- * bootstraptest/test_knownbug.rb, test_syntax.rb: move fixed test.
-
-Tue Dec 25 21:32:44 2007 Tanaka Akira <akr@fsij.org>
-
- * parse.y (struct parser_params): make parser_ruby_sourcefile common
- field. it is used by node_newnode.
- new field parser_ruby_sourcefile_string for ripper.
- (parser_initialize): initialize parser_ruby_sourcefile in ripper.
- (ripper_initialize): initialize parser_ruby_sourcefile_string.
-
-Tue Dec 25 21:26:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (parse.c): depends on tool/ytab.sed.
-
- * tool/ytab.sed: hack for bison 2.1.
-
-Tue Dec 25 20:24:58 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().
-
-Tue Dec 25 20:24:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * tool/make-snapshot: argument check, and cleanup exported directory.
-
-Tue Dec 25 20:07:13 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * tool/make-snapshot: more portable.
-
-Tue Dec 25 19:01:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.h (rb_enc_mbc_to_codepoint): wrapper for
- ONIGENC_MBC_TO_CODE().
+ * 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]
- * string.c (rb_str_succ): deal with invalid sequence as binary.
+Wed Jan 7 10:09:46 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 18:40:46 2007 Koichi Sasada <ko1@atdot.net>
+ * eval.c (timeofday): use monotonic clock. based on a patch
+ from zimbatm <zimbatm@oree.ch> in [ruby-core:16627].
- * iseq.c: all methods need $SAFE < 1.
+Tue Jan 6 09:03:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
- vm.c: comment out debug functions.
+ * parse.y (yylex): 8 and 9 in octal integer should cause compile
+ error. [ruby-dev:35729]
-Tue Dec 25 18:37:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Jan 5 11:14:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (appendline): move RS comparison to rb_io_getline_1().
+ * eval.c (rb_thread_schedule): runs deferred finalizers.
-Tue Dec 25 18:27:51 2007 Tanaka Akira <akr@fsij.org>
+ * gc.c (gc_sweep): sets rb_thread_pending to run deferred finalizers.
- * string.c (rb_str_each_line): don't call rb_enc_codepoint with empty
- string.
-
-Tue Dec 25 18:06:04 2007 Tanaka Akira <akr@fsij.org>
-
- * string.c (rb_str_inspect): don't call rb_enc_codepoint with empty
- string. fix '#'.inspect.
+ * rubysig.h (CHECK_INTS): now checks rb_thread_pending even on
+ platforms where setitimer is not available. [ruby-core:18045]
- * encoding.c (rb_enc_codepoint): raise on empty string.
+Mon Jan 5 11:14:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 17:48:28 2007 Shugo Maeda <shugo@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]
- * vm.c (rb_frame_method_id_and_class): new function to get the
- method id and class of the current frame.
+Sun Jan 4 04:49:01 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 17:32:04 2007 Akinori MUSHA <knu@iDaemons.org>
+ * win32/win32.c (rb_w32_telldir): just returns loc.
- * 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.
+ * win32/win32.c (rb_w32_rewinddir): needs to intialize loc.
+ [ruby-core:18041]
-Tue Dec 25 16:51:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jan 4 04:45:26 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enc/trans/japanese.c (rb_{from,to}_{SHIFT_JIS,EUC_JP}): inversed
- from_encoding and to_encoding.
+ * win32/win32.c (rb_w32_select): recalc the rest of timeout for each
+ iterations. [ruby-core:18015]
-Tue Dec 25 16:41:57 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Jan 2 03:08:47 2009 Kouhei Sutou <kou@cozmixng.org>
- * golf_prelude.rb (h): add new method for all golfers.
+ * test/rss/: use PNG instead of zlib as binary data. [ruby-dev:35666]
-Tue Dec 25 16:37:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Nov 11 01:07:32 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * enc/trans/japanese.c (rb_to_EUC_JP): fixed typo.
+ * 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].
-Tue Dec 25 16:34:58 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Aug 11 09:37:17 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/dl/depend: add dependencies. [ruby-dev:32760]
+ * ext/dl/dl.c (rb_str_to_ptr): should propagate taint to dlptr.
-Tue Dec 25 16:26:48 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/dl/dl.c (rb_ary_to_ptr): ditto.
- * include/ruby/ruby.h, thread.c: rename is_ruby_native_thread() to
- ruby_native_thread_p().
+ * ext/dl/sym.c (rb_dlsym_call): should check taint of DLPtrData as
+ well.
- * ext/tk/tcltklib.c: apply it.
+Fri Aug 8 10:53:52 2008 Tanaka Akira <akr@fsij.org>
-Tue Dec 25 16:15:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/resolv.rb: randomize source port and transaction id.
+ CVE-2008-1447.
- * common.mk (clean-enc): clean encoding objects.
+ * lib/resolv-replace.rb (UDPSocket#bind): don't resolv host if host is
+ "".
-Tue Dec 25 16:04:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Aug 4 14:49:35 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
- * trunk/common.mk, goruby.c, golf_prelude.rb: for golfers.
+ * lib/net/smtp.rb (Net::SMTP::rcptto): fix a typo. a patch from
+ Masao Takaku <masao at nii.ac.jp>
+ fix [ruby-dev:35489].
- * trunk/main.c (main): hook for embedding applications.
+Mon Aug 4 14:13:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * trunk/tool/compile_prelude.rb: can change initialize function name.
+ * regex.c (xmalloc, xrealloc, xfree): not to use ruby managed memory.
-Tue Dec 25 15:59:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * regex.c (DOUBLE_STACK, re_compile_fastmap0, re_adjust_startpos),
+ (re_search, re_match_exec): check if failed to allocate memory.
- * encoding.c (rb_enc_register): do not use based_encoding to check if
- dummy encoding.
+Mon Aug 4 13:53:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 15:55:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * bignum.c (rb_big2str0, bigsqr): made interruptible. [ruby-Bugs-20622]
- * string.c (rb_str_succ): fix for string with non-alphanumeric chars.
+Mon Aug 4 13:31:41 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Dec 25 15:42:49 2007 Yukihiro Matsumoto <matz@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>
- * io.c (rb_io_external_encoding): should return nil for
- pass-through write IO. [ruby-dev:32740]
+ * numeric.c (check_uint, rb_num2uint, rb_fix2uint): strict check.
+ fixed [ruby-dev:33683]
-Tue Dec 25 15:24:57 2007 Tanaka Akira <akr@fsij.org>
+Thu Jul 17 21:42:07 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
- * io.c (appendline): initialize rslen to 1 if rsptr is 0.
- rslen is the length of the delimiter.
- if only delim is given, it should be 1.
- [ruby-dev:32746]
+ * lib/net/smtp.rb (Net::SMTP::start): revert to avoid RFC2821
+ violation. [ruby-dev:35487]
-Tue Dec 25 15:21:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Jul 17 21:32:49 2008 Tanaka Akira <akr@fsij.org>
- * transcode.c (transcode_dispatch): fix for multistep transcode.
+ * string.c (rb_str_format_m): make tmp volatile to avoid possible GC
+ problem.
-Tue Dec 25 15:07:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jul 17 21:30:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enc/trans/single_byte.c (Init_single_byte): renamed.
+ * lib/optparse.rb (OptionParser#environment): requires shellwords.
+ [ruby-dev:35466]
-Tue Dec 25 15:00:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jul 17 02:05:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enum.c (enum_yield): when multiple values yielded from #each
- pack them into an array. [ruby-dev:32708]
+ * lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): requires
+ webrick/cookie. [ ruby-Bugs-21139 ]
- * enum.c: all method but all?, any?, one? and none? passed packed
- multiple values to the block.
+Thu Jul 17 01:38:31 2008 Yusuke Endoh <mame@tsg.ne.jp>
- * enum.c (collect_all): should pack all values. [ruby-core:14410]
+ * ext/zlib/zlib.c (rb_gzfile_set_mtime): fix typo. [ruby-core:17713]
-Tue Dec 25 14:57:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jul 13 00:08:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * common.mk (COMMONOBJS): transcode_data_*.c moved under enc/trans.
+ * 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].
- * transcode_data.h (rb_transcoding, rb_transcoder): prefixed.
+Sun Jul 13 00:04:38 2008 Tanaka Akira <akr@fsij.org>
- * transcode.c (rb_register_transcoder, rb_declare_transcoder): split
- declaration and registration. [ruby-dev:32704]
+ * 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
- * transcode.c (transcode_dispatch): autoload pre-declared transcoder.
+Thu Jul 10 18:50:48 2008 Tanaka Akira <akr@fsij.org>
- * transcode.c (str_transcode): use rb_define_dummy_encoding().
+ * common.mk (SPEC_GIT_BASE): update RubySpec GIT URL.
- * transcode.c (Init_transcode): initialize transcoder tables.
+Thu Jul 10 18:46:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enc/trans/single_byte.c, enc/trans/japanese.c: moved from top.
+ * file.c (rb_file_s_extname): fix for file name with spaces.
+ [ruby-talk:307404]
-Tue Dec 25 14:20:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jul 10 18:42:37 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/mkmf.rb (map_dir): should generate path including $top_srcdir.
+ * lib/erb.rb (PercentScanner#scan): fix %% line bug. [ruby-core:17491]
-Tue Dec 25 14:09:16 2007 James Edward Gray II <jeg2@ruby-lang.org>
+ * test/erb/test_erb.rb (test_percent): ditto.
- * lib/csv.rb: Fixed test failures caused by changes to Ruby.
-
- * test/csv/tc_serialization, test/csv/tc_csv_parsing, test/csv/tc_features:
- Fixed test failures caused by changes to Ruby.
+Thu Jul 10 18:40:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 14:11:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/net/ftp.rb (Net::FTP#sendport): use divmod. [ruby-core:17557]
- * io.c (io_encoding_set): missing return type.
+Thu Jul 10 18:36:53 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Tue Dec 25 14:03:48 2007 NARUSE, Yui <naruse@ruby-lang.org>
+ * ruby.c: Mac OS X needs origargc times of '\0' in
+ origargv. [ruby-dev:35308]
- * test/rinda/test_rinda.rb (MockClock#{_forward, forwrd, sleep}):
- Change default value of n as @reso from nil. If default value is
- nil, n.+ is not defined.
+Thu Jul 10 13:53:08 2008 Tanaka Akira <akr@fsij.org>
-Tue Dec 25 13:54:01 2007 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.
- * test/ruby/test_io_m17n.rb (test_pipe): fixed.
- [ruby-dev:32743]
+Mon Jul 7 16:21:38 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Dec 25 13:44:51 2007 Koichi Sasada <ko1@atdot.net>
+ * lib/net/smtp.rb (Net::SMTP::start): use 'localhost' instead of
+ 'localhost.localdomain'. [ruby-dev:35333]
- * thread.c (rb_thread_wait_fd_rw): should check EBADF on select().
+ * lib/net/smtp.rb (Net::SMTP::SMTP.start): ditto.
-Tue Dec 25 13:30:03 2007 Koichi Sasada <ko1@atdot.net>
+Mon Jul 7 15:02:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * thread_pthread.c, thread_pthread.h, thread_win32.c,
- thread_win32.c: make some functions static functions.
- a patch from Tadashi Saito <shiba AT mail2.accsnet.ne.jp>
- in [ruby-core:14407]
+ * eval.c (rb_longjmp): duplicate the thrown exception to set backtrace
+ if it was frozen. clear all raised flags.
-Tue Dec 25 13:23:13 2007 Tanaka Akira <akr@fsij.org>
+ * eval.c (stack_check): leave clearing flag to rb_longjmp.
- * test/ruby/test_io_m17n.rb (test_write_noenc): don't mix text and
- binary mode. [ruby-dev:32743]
+ * eval.c (rb_thread_set_raised, rb_thread_reset_raised): use generic
+ flags.
-Tue Dec 25 13:13:09 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (Init_Proc), gc.c (Init_GC): freeze preallocated special exceptions.
- * README.EXT.ja, dir.c, eval.c, eval_intern.h, lex.c.src,
- lex.c.blt, keywords, load.c, thread.c: more ANSI'ize.
- a patch from Tadashi Saito <shiba AT mail2.accsnet.ne.jp>
- in [ruby-dev:32725]
+ * 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]
-Tue Dec 25 13:07:56 2007 Koichi Sasada <ko1@atdot.net>
+ * 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.
- * vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
- RUBY_VM_SET_TIMER_INTERRUPT(), RUBY_VM_INTERRUPTED().
+Mon Jul 7 12:23:05 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * thread.c, thread_pthread.c, thread_win32.c: fix to ignore time slice
- event until sleep.
+ * ext/win32ole/win32ole.c: avoid creating Ruby object during
+ GC. thanks to arton <artonx AT yahoo.co.jp>. [ruby-dev:35313]
- * bootstraptest/test_thread.rb: add a test for time limited join test.
+ * ext/win32ole/tests: add test_win32ole_event.rb, remove
+ testOLEEVENT.rb
-Tue Dec 25 12:42:59 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/win32ole/tests/testWIN32OLE.rb(test_convert_bignum):
+ fix test.
- * vm.c (Init_VM): remove unused code.
- [ruby-dev:32732]
+Mon Jul 7 12:23:05 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Tue Dec 25 12:32:32 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * gc.c: add rb_during_gc(). based on a patch from arton <artonx AT
+ yahoo.co.jp> at [ruby-dev:35313].
- * transcode.c: Moving a static counter from inside register_transcoder()
- and register_functional_transcoder() to outside the functions, renaming
- from n to next_transcoder_position. Fixes 3) in [ruby-dev:32715].
+ * intern.h: ditto.
-Tue Dec 25 12:22:17 2007 NARUSE, Yui <naruse@ruby-lang.org>
+Thu Jul 3 20:13:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * sample/from.rb: follow Ruby 1.9 libraries.
+ * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
+ public methods only. [ruby-core:17283]
-Tue Dec 25 12:21:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * object.c (convert_type): ditto.
- * proc.c (method_inspect): preserve encoding of the method name.
+ * lib/singleton.rb (Singleton#_dump): conversion method should be
+ public.
-Tue Dec 25 12:07:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jul 2 19:06:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in (BASERUBY): delayed error until BASERUBY is used.
+ * lib/cgi.rb (CGI::QueryExtension.read_multipart): blanks inside
+ double quotes are allowed. [ruby-list:45140]
-Tue Dec 25 11:48:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Jul 2 19:03:37 2008 Tanaka Akira <akr@fsij.org>
- * sample/README: removed obsoleted files: dbmtest.rb,
- getopts.test, mrshtest.rb, regx.rb.
+ * numeric.c (num_coerce): call rb_Float(x) first. don't depend on
+ evaluation order of function arguments.
-Tue Dec 25 11:45:34 2007 James Edward Gray II <jeg2@ruby-lang.org>
+Wed Jul 2 18:57:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/csv.rb: Import the FasterCSV source as the new CSV class.
-
- * test/csv/*: Added all applicable tests from FasterCSV.
+ * 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>.
-Tue Dec 25 11:33:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/syslog/syslog.c (mSyslog_close): ditto.
- * error.c (report_bug): uses ruby_description.
+ * ext/syslog/syslog.c (mSyslog_set_mask): ditto.
-Tue Dec 25 11:20:38 2007 Koichi Sasada <ko1@atdot.net>
+Wed Jul 2 18:26:20 2008 Tanaka Akira <akr@fsij.org>
- * compile.c (iseq_compile_each): fix stack consistency error.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp> [ruby-dev:32720]
+ * math.c (domain_check): fix preprocess condition.
- * bootstraptest/test_syntax.rb: add 2 tests for above.
+Wed Jul 2 18:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 11:14:20 2007 Koichi Sasada <ko1@atdot.net>
+ * 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]
- * iseq.c, vm_core.h: comment out unused fields.
+Wed Jul 2 18:16:19 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Tue Dec 25 11:02:10 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/win32ole/win32ole.c (date2time_str): fix the overflow in
+ some situation. [ruby-bugs-20793]
- * vm.c: check frame is FINAL when creating env.
- [ruby-core:14395]
+Tue Jul 1 15:11:14 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bootstraptest/test_block.rb: add a test for above.
+ * array.c (rb_ary_fill): check if beg is too big.
-Tue Dec 25 09:12:13 2007 Eric Hodel <drbrain@segment7.net>
+Mon Jun 30 20:35:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rdoc/: Enable RDoc debugging only with $DEBUG_RDOC.
+ * string.c (str_buf_cat): check for self concatenation.
-Tue Dec 25 08:37:43 2007 James Edward Gray II <jeg2@ruby-lang.org>
+Sun Jun 29 21:39:54 2008 Tanaka Akira <akr@fsij.org>
- * lib/csv.rb, test/csv/test_csv.rb: Removed in preparation for
- FasterCSV code import.
+ * eval.c (rb_obj_respond_to): use RTEST to test the result of
+ respond_to? method.
-Tue Dec 25 08:27:43 2007 Eric Hodel <drbrain@segment7.net>
+Sun Jun 29 21:20:17 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
- * lib/rubygems.rb: Fix test failures.
+ * array.c (rb_ary_fill): (compatibility) do not raise
+ ArgumentError on negative length. This behaviour shall change
+ in a future release.
- * test/rubygems/test_gem.rb: Fix test failure.
+Sun Jun 29 20:08:11 2008 Tanaka Akira <akr@fsij.org>
-Tue Dec 25 06:23:40 2007 Koichi Sasada <ko1@atdot.net>
+ * time.c (time_timeval): fix rounding negative float.
- * bootstraptest/test_knownbug.rb, test_literal.rb: move fixed test.
+Sun Jun 29 19:19:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 06:19:04 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * test/inlinetest.rb (InlineTest.in_progname): workaround for frozen
+ $0. [ruby-dev:35261]
- * sample/biorhythm.rb: follow Ruby 1.9 libraries.
+ * lib/test/unit/ui/console/testrunner.rb (TestRunner#finished): ditto.
-Tue Dec 25 06:15:01 2007 Koichi Sasada <ko1@atdot.net>
+Sun Jun 29 19:19:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * vm.c: add dummy toplevel frame.
+ * ruby.c (set_arg0, ruby_prog_init): freeze $0. a patch from Keita
+ Yamaguchi <keita.yamaguchi at gmail.com>.
-Tue Dec 25 05:44:56 2007 Eric Hodel <drbrain@segment7.net>
+Sun Jun 29 18:33:33 2008 Tanaka Akira <akr@fsij.org>
- * lib/net/http.rb: Fix uninitialized variable warning.
- [ruby-talk:284582]
+ * process.c: include sys/resource.h if HAVE_SYS_RESOURCE_H is defined.
+ pointed by TOYOFUKU Chikanobu. [ruby-dev:35258]
- * lib/irb/output-method.rb: Remove unused #foo method.
- [ruby-talk:284582]
+Sun Jun 29 18:26:01 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Dec 25 05:24:12 2007 Koichi Sasada <ko1@atdot.net>
+ * variable.c (rb_f_trace_var): should not be allowed at safe level 4.
+ a patch from Keita Yamaguchi <keita.yamaguchi at gmail.com>.
- * compile.c (iseq_compile): clear local table if node == 0.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp> [ruby-dev:32530]
+ * eval.c (rb_call0): wrong condition to check insecure method.
+ a patch from Keita Yamaguchi <keita.yamaguchi at gmail.com>.
- * vm.c: clear VM stack.
+Sun Jun 29 18:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 04:23:32 2007 Tanaka Akira <akr@fsij.org>
+ * array.c (rb_ary_fill): not depend on unspecified behavior at integer
+ overflow. reported by Vincenzo Iozzo <snagg AT openssl.it>.
- * parse.y (rb_id2str): fill klass of returned string as rb_cString.
- some strings are allocated before rb_cString is created.
- This prevents a "called on terminated object" error by
- ObjectSpace.each_object(Module) {|m| p m.name }.
+Sun Jun 29 18:22:06 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Tue Dec 25 03:51:55 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/win32ole/win32ole.c(ole_invoke): fix memory leak.
+ [ruby-bugs-20792]
- * compile.c (iseq_compile_each): fix stack consistency bug.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp>
+Sun Jun 29 18:19:11 2008 Akinori MUSHA <knu@iDaemons.org>
-Tue Dec 25 03:19:47 2007 WATANABE Hirofumi <eban@ruby-lang.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.
- * tool/make-snapshot: must create configure and lex.c.
+Sun Jun 29 17:24:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 03:16:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rdoc/parsers/parse_rb.rb (RDoc#collect_first_comment): skip
+ magic comment.
- * io.c (rb_io_s_pipe): now takes up to two arguments. allow its
- external/internal encoding by Encoding objects.
+Sun Jun 29 17:22:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_set_encoding): new method to set encoding of the IO.
+ * ext/stringio/stringio.c (strio_each, strio_readlines): IO#each and
+ IO#readlines do not affect $_. [ruby-core:17277]
- * io.c (argf_set_encoding): ditto.
+Sun Jun 29 17:19:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 03:08:53 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/stringio/stringio.c (strio_readline, strio_each)
+ (strio_readlines): set lastline. [ruby-core:17257]
- * pack.c (pack_pack): use NUM2LONG instead of NUM2INT.
+Sun Jun 29 17:15:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * numeric.c (fix_lshift, fix_aref): use SIZEOF_LONG instead of
- SIZEOF_VALUE.
+ * 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]
- * bignum.c (big2ulong, rb_big_aref): ditto.
+Sun Jun 29 17:09:48 2008 wanabe <s.wanabe@gmail.com>
-Tue Dec 25 02:55:26 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * util.c (ruby_strtod): ruby_strtod don't allow a trailing
+ decimal point like "7.". [ruby-dev:34835] [ruby-dev:35009]
- * lib/rexml/element.rb (REXML::Elements#each): yield in each
- should be called with one parameter. [ruby-dev:32708]
+Sat Jun 28 19:23:40 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-Tue Dec 25 02:15:39 2007 Koichi Sasada <ko1@atdot.net>
+ * class.c (clone_method): use rb_copy_node_scope.
+ fixed [ruby-list:45102]
+ fixed [ruby-core:17393]
- * compile.c (iseq_compile_each): add a "pop" insn after break
- to fix stack consistency error. [ruby-core:14385]
+Sat Jun 28 18:49:50 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
- * bootstraptest/test_syntax.rb: add tests for above.
+ * class.c: revert to r15855.
- * bootstraptest/test_knownbug.rb: remove fixed bug.
+Fri Jun 20 18:25:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 25 01:54:36 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * string.c (rb_str_buf_append): should infect.
- * id.c (Init_id): remove several unused symbols. [ruby-core:14362]
+Fri Jun 20 16:33:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * compile.c (iseq_specialized_instruction): do not use
- VM_CALL_SEND_BANG flag any longer.
+ * array.c (rb_ary_store, rb_ary_splice): not depend on unspecified
+ behavior at integer overflow.
-Tue Dec 25 01:42:41 2007 Tanaka Akira <akr@fsij.org>
+ * string.c (str_buf_cat): ditto.
- * lib/rdoc/rdoc.rb (parse_files): interpret coding cookie.
+Wed Jun 18 22:24:46 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-Tue Dec 25 01:38:04 2007 Yukihiro Matsumoto <matz@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
- * proc.c (method_name): preserve Symbol's encoding.
+ * 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
- * numeric.c (fix_id2name): ditto.
+ * sprintf.c (rb_str_format): backported from trunk.
-Tue Dec 25 01:19:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * intern.h: ditto.
- * include/ruby/encoding.h (rb_enc_left_char_head): new utility macro.
+Tue Jun 17 15:09:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * include/ruby/encoding.h (rb_enc_right_char_head): ditto.
+ * file.c (file_expand_path): no need to expand root path which has no
+ short file name. [ruby-dev:35095]
- * io.c (appendline): does multibyte RS search in the function.
+Sun Jun 15 19:27:40 2008 Akinori MUSHA <knu@iDaemons.org>
- * io.c (prepare_getline_args): RS may be nil.
+ * configure.in: Fix $LOAD_PATH. Properly expand vendor_ruby
+ directories; submitted by Takahiro Kambe <taca at
+ back-street.net> in [ruby-dev:35099].
- * io.c (rb_io_getc): should process character based on external
- encoding, when transcoding required.
+Mon Jun 9 17:56:30 2008 Akinori MUSHA <knu@iDaemons.org>
-Tue Dec 25 01:07:57 2007 Tanaka Akira <akr@fsij.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.
- * lib/irb/output-method.rb: translate a comment to English to
- avoid mix of EUC-JP comment and UTF-8 Date keyword.
- svn substitute Date keyword with UTF-8 weekday on UTF-8 locale.
+Mon Jun 9 03:28:05 2008 Akinori MUSHA <knu@iDaemons.org>
-Tue Dec 25 00:27:28 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * ext/zlib/zlib.c (rb_deflate_initialize, Init_zlib): Fix up
+ initialize_copy; [ruby-list:45016], [ruby-list:45018].
- * lib/webrick/httpservley/cgihandler.rb
- (WEBrick::HTTPServlet::CGIHandler#do_GET): m17nized.
+Mon Jun 9 03:26:03 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Mon Dec 24 23:55:29 2007 Tanaka Akira <akr@fsij.org>
+ * NEWS: Mention new constants.
- * lib/cgi.rb (CGI::escape): m17nized.
- (CGI::unescape): ditto.
- (CGI::escapeHTML): ditto.
- (CGI::unescapeHTML): ditto.
+Mon Jun 9 03:24:18 2008 Tanaka Akira <akr@fsij.org>
-Mon Dec 24 23:32:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * hash.c (hash_i): make Hash#hash order insensitive.
- * transcode_data_japanese.c (select_iso_2022_mode): '\e' is not valid.
+Mon Jun 9 03:22:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 24 23:13:09 2007 GOTOU Yuuzou <gotoyuzo@notwork.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].
- * lib/rdoc/diagram.rb (RDoc::Diagram#initialize): use fileuitls
- instead of ftools.
+Mon Jun 9 03:21:20 2008 Tanaka Akira <akr@fsij.org>
-Mon Dec 24 23:04:57 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+ * gc.c (os_obj_of): assure to not free the scanning heap.
- * lib/ftools.rb: removed obsoleted lib. use fileutils instead (by eban).
+Mon Jun 9 03:20:12 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/rdoc/rdoc.rb, lib/rdoc/generators/*, lib/rake.rb: let it use
- fileutils instead of ftools.
+ * io.c (rb_open_file, rb_io_s_sysopen): fmode should be unsigned int.
+ fixed [ruby-dev:34979]
- * lib/shell/command-processor.rb: removed unused references to ftools.
+Fri Jun 6 21:16:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/parsedate.rb: removed. see [ruby-core:12535], [ruby-dev:31969].
+ * win32/Makefile.sub (COMMON_HEADERS): include ws2tcpip.h.
- * lib/README: updated.
+ * ext/socket/addrinfo.h (addrinfo, getaddrinfo, getnameinfo,
+ freehostent, freeaddrinfo): undef before define because these are
+ macros in some versions of Windows SDK.
-Mon Dec 24 23:01:04 2007 Tanaka Akira <akr@fsij.org>
+ * win32/setup.mak: maybe commit miss.
- * lib/open-uri.rb (OpenURI::Buffer): use Meta ===. [ruby-core:14295]
+Fri Jun 6 19:34:22 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 22:46:42 2007 NARUSE, Yui <naruse@ruby-lang.org>
+ * mkconfig.rb: hide build path from rbconfig.rb.
- * transocode.c: register_functional_transcoder() added.
- (init_transcoder_table(: register ISO-2022-JP.
- (str_transcode): add preprocessor and postprocessor.
+ * util.c (ruby_strtod, dtoa): initialize more variables for error
+ handling.
- * transcode_data_japanese.c: add ISO-2022-JP support.
+ * io.c (rscheck), marshal.c (w_nbyte, w_bytes, w_unique),
+ (path2class, path2module): constified.
- * transcode_data.h: moved transcoder and transcoding difinition from
- transcode.c.
+ * pack.c (pack_unpack), process.c (rb_syswait): suppress warnings.
-Mon Dec 24 20:29:28 2007 Koichi Sasada <ko1@atdot.net>
+ * suppress warnings on cygwin, mingw and mswin.
- * test/io/nonblock/test_flush.rb: fix test for 1.9.
+Fri Jun 6 19:23:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 24 20:23:44 2007 Koichi Sasada <ko1@atdot.net>
+ * file.c (file_expand_path): fix for non-existent files and SFN of
+ symlinks. [ruby-talk:303736]
- * test/rinda/test_rinda.rb: revert last commit because this test seems
- to have timing problem to halt all tests.
+Fri Jun 6 18:25:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 24 20:18:52 2007 Koichi Sasada <ko1@atdot.net>
+ * test/iconv: Tests fixed.
- * test/rinda/test_rinda.rb: enable rinda test.
+Fri Jun 6 17:04:56 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 20:16:54 2007 Koichi Sasada <ko1@atdot.net>
+ * win32/win32.h: include ws2tcpip.h. fixed [ruby-Bugs-20528]
- * instruby.rb: fix rdoc install dir.
+ * 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
-Mon Dec 24 18:37:32 2007 Tanaka Akira <akr@fsij.org>
+ * object.c (rb_obj_alloc): RDoc updated. a patch from Gaston
+ Ramos <ramos.gaston at gmail.com> in [ruby-core:17073].
- * re.c (rb_reg_prepare_re): show regexp encoding in the error message.
+ * lib/rdoc.rb: massive spelling correction patch from Evan Farrar
+ <evanfarrar at gmail.com> in [ruby-doc:1382] applied.
-Mon Dec 24 18:23:32 2007 Tanaka Akira <akr@fsij.org>
+ * ext/openssl/ossl_ssl_session.c (ossl_ssl_session_initialize):
+ Add a null check for ssl; submitted by akira yamada
+ in [ruby-dev:34950].
- * eval.c (rb_exc_raise): ANSI style.
- (rb_exc_fatal): ditto.
- (rb_raise_jump): ditto.
- (rb_jump_tag): ditto.
- (rb_block_given_p): ditto.
+ * 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].
- * variable.c (original_module): ditto.
+ * 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].
-Mon Dec 24 18:05:09 2007 Koichi Sasada <ko1@atdot.net>
+Fri Jun 6 16:58:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * iseq.c (Init_ISeq): disable ISeq.load() because there is no verifier.
+ * ext/iconv/iconv.c (iconv_iconv): fix for length argument and now
+ allows range. [ruby-core:17092] [ruby-core:17115]
- * iseq.c, proc.c: add ISeq.disasm(method).
+Wed Jun 4 17:22:30 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 18:06:03 2007 Tanaka Akira <akr@fsij.org>
+ * NEWS: Fix typos and move misplaced entries.
+ NEWS: Somehow optflags and warnflags were not actually included
+ in this release.
- * eval_method.c (Init_eval_method): extracted from Init_eval
- for rdoc to find rb_mod_remove_method, rb_mod_undef_method and
- rb_mod_alias_method.
+Tue Jun 3 19:33:22 2008 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (Init_eval): call Init_eval_method.
+ * enumerator.c (enumerator_init_copy): Take care of
+ initialize_copy as well as initialize.
-Mon Dec 24 17:59:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * test/ruby/test_enumerator.rb: Pull in the test suite for
+ enumerator from trunk.
- * load.c (load_lock): reverted.
+Tue Jun 3 12:51:57 2008 Akinori MUSHA <knu@iDaemons.org>
- * thread.c (rb_barrier_wait): check for recursive wait.
+ * 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]
-Mon Dec 24 17:50:54 2007 Tanaka Akira <akr@fsij.org>
+Tue Jun 3 10:16:40 2008 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (function_call_may_return_twice_jmp_buf): removed.
- (function_call_may_return_twice_false): removed.
- [ruby-core:14335]
+ * 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].
-Mon Dec 24 17:40:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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.
- * common.mk (node_name.inc, miniprelude.c, prelude.c): nmake cannot
- handle target vpath in other than implicit rules.
+Mon Jun 2 19:47:16 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 17:20:34 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.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].
- * lib/{mailread.rb,getopts.rb,parsearg.rb}: removed.
- see [ruby-core:12535], [ruby-dev:31969].
+Sat May 31 23:53:35 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 17:12:57 2007 Tanaka Akira <akr@fsij.org>
+ * .: Release as Ruby 1.8.7.
- * include/ruby/intern.h, random.c, array.c:
- change exported name.
- genrand_int32 -> rb_genrand_int32.
- genrand_real -> rb_genrand_real.
- [ruby-core:14335]
+Sat May 31 23:33:34 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 17:06:37 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+ * README, README.ja: Add a note about default C flags.
- * {lib,test}/{soap,wsdl,xsd}: removed soap4r along to the discussion
- at ruby-core and ruby-dev. see [ruby-core:12535], [ruby-dev:31969].
+Sat May 31 22:11:15 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Mon Dec 24 17:06:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * version.c (ruby_description, ruby_copyright): backported from
+ 1.9. bug#19002, [ruby-dev:34883]
- * load.c (rb_feature_p): returns loading path name too.
+ * error.c (report_bug): uses ruby_description.
- * load.c (search_required): returns path too if feature is being
- loaded. [ruby-dev:32048] [TODO: refactoring]
+Sat May 31 20:56:04 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 16:29:12 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * array.c (rb_ary_delete_if): should return enumerator if no block
+ is given. [ruby-dev:34901]
- * sample/openssl: reviewed and remove dependency on getopts.rb.
+Sat May 31 18:28:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 24 16:18:57 2007 Koichi Sasada <ko1@atdot.net>
+ * suppress warnings with -Wwrite-string.
- * mkconfig.rb: add teeny to CONFIG['ruby_version'].
+Sat May 31 15:58:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 24 15:55:50 2007 Koichi Sasada <ko1@atdot.net>
+ * Makefile.in, configure.in (warnflags): defaulted to -Wall
+ -Wno-parentheses with gcc. [ruby-dev:34810]
- * tool/compile.rb, getrev.rb, runruby.rb: remove unused tools.
+Fri May 30 05:28:18 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-Mon Dec 24 15:42:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * enum.c (count_i, count_iter_i, count_all_i): add prototypes for VC.
- * configure.in, cygwin/GNUmakefile.in, */Makefile.sub,
- djgpp/config.hin.: version dependent directory names now contain
- teeny.
+Fri May 30 04:32:07 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 15:29:13 2007 Tanaka Akira <akr@fsij.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.
- * tool/serb.rb: removed.
+Fri May 30 03:12:18 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 13:55:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_bn.c (ossl_bn_s_rand, ossl_bn_s_pseudo_rand):
+ Int should be enough here.
- * proc.c (rb_proc_new), vm.c (invoke_block): removed u3.state magic.
- [ruby-core:14310]
+Fri May 30 02:35:00 2008 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_symbol.rb (test_to_proc): a test from Frederick
- Cheung <frederick.cheung AT gmail.com>.
+ * 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].
-Mon Dec 24 13:43:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu May 29 20:07:45 2008 Akinori MUSHA <knu@iDaemons.org>
- * thread.c (rb_thread_atfork): should not leave living_threads
- referring freed table while allocating new table.
+ * 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.
-Mon Dec 24 12:49:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu May 29 17:52:31 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * Makefile.in, configure.in, lib/mkmf.rb, */Makefile.sub: specify
- compiled output file name explicitly.
+ * ext/zlib/extconf.rb: search zlib1, and regard mswin32 later than VC6
+ as WIN32. [ruby-core:16984]
- * enc/Makefile.in, enc/depend: now makes compiler to put generated
- files under directories corresnponding to the each source.
- enc/trans supported.
+Wed May 28 17:54:29 2008 Akinori MUSHA <knu@iDaemons.org>
- * enc/make_encmake.rb: evaluates depend file before Makefile.in so
- that the former can influence to CONFIG.
+ * string.c (rb_str_start_with): Remove an unused variable.
+ (rb_str_upto_m): Fix a prototype.
-Mon Dec 24 12:35:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 28 17:48:28 2008 Akinori MUSHA <knu@iDaemons.org>
- * win{32,ce}/Makefile.sub (MFLAGS): defaulted to -l.
+ * 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.
-Mon Dec 24 12:08:10 2007 Eric Hodel <drbrain@segment7.net>
+ * string.c (rb_str_upto_m, Init_String): Add an optional second
+ argument to specify if the last value should be included.
- * /, ext/: Add svn:ignore for OS X Xcode 3's conftest.dSYM
- directories.
+Wed May 28 16:53:39 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 11:56:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * array.c (rb_ary_slice_bang): Call rb_ary_modify_check() at the
+ beginning. [rubyspec]
- * common.mk: should not pass MAKEFLAGS to recursive make.
- + normal make: MFLAGS are set and command line options and macros
- are all passed silently.
- + GNU make: ditto, and all options and macros in MAKEFLAGS are in
- effect.
- + nmake: MFLAGS is not set and MAKEFLAGS has only options without
- hyphen, no macros exist in any variables.
- + Borland make: ditto, and command line macros cannot override
- macros in makefile, so passing them is vain.
+Wed May 28 16:12:44 2008 Akinori MUSHA <knu@iDaemons.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.
+ * 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.
-Mon Dec 24 11:32:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed May 28 15:18:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_comparable): fixed to keep transitivity.
- [ruby-dev:32693]
+ * lib/singleton.rb (SingletonClassMethods): _load should be public.
-Mon Dec 24 11:20:31 2007 Eric Hodel <drbrain@segment7.net>
+Wed May 28 12:52:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rdoc/ri/ri_options.rb: Fix display of GEMDIRS, make command
- examples match ri's name.
+ * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
+ private methods too. [ruby-dev:34671]
- * lib/rdoc/ri/ri_paths.rb: Only allow latest ri dirs in ri output.
+ * object.c (convert_type): ditto.
-Mon Dec 24 10:49:04 2007 Eric Hodel <drbrain@segment7.net>
+Tue May 27 23:26:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/uri/mailto.rb, lib/uri/common.rb: Fix Regexp warnings. Patch
- #16524 from Kornelius Kalnbach, [ruby-core:14302].
+ * error.c (rb_bug): description from rb_bug() should include
+ patchlevel. [ruby-dev:34826]
-Mon Dec 24 10:37:38 2007 Eric Hodel <drbrain@segment7.net>
+Tue May 27 20:19:22 2008 Akinori MUSHA <knu@iDaemons.org>
- * gem_prelude.rb: Remove methods from Gem, not QuickLoader, to fix
- warnings.
+ * 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.
-Mon Dec 24 09:45:45 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+Tue May 27 19:45:20 2008 Akinori MUSHA <knu@iDaemons.org>
- * transcode.c, transcode_data_one_byte.c, transcode_data_japanese.c:
- added rb_ prefix to external data symbols.
+ * numeric.c (flo_divmod): Revert the behavior change; do not
+ suppress an exception when div is NaN or Inf. [ruby-dev:34857]
-Mon Dec 24 05:32:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue May 27 19:24:40 2008 Akinori MUSHA <knu@iDaemons.org>
- * enum.c (enum_inject): updated documentation. a patch from Keita
- Yamaguchi <keita.yamaguchi AT gmail.com> in [ruby-dev:32686].
+ * 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().
- * README.EXT: updated. a patch from Tadashi Saito
- <shiba AT mail2.accsnet.ne.jp> in [ruby-core:14328].
+Tue May 27 18:54:02 2008 Akinori MUSHA <knu@iDaemons.org>
- * array.c (rb_ary_at): updated documentation. a patch from Tadashi
- Saito <shiba AT mail2.accsnet.ne.jp> in [ruby-core:14330].
+ * ext/stringio/stringio.c (strio_each_char, Init_stringio): Add
+ StringIO#{each_char,chars}.
-Mon Dec 24 05:13:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue May 27 17:59:34 2008 Akinori MUSHA <knu@iDaemons.org>
- * string.c (tr_trans): should associate new encoding if modified.
+ * 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.
-Mon Dec 24 04:04:12 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * io.c (rb_io_each_byte): Fix rdoc. IO#each_byte returns self,
+ not nil.
- * test/net/http/test_https.rb: should rescue LoadError.
+Tue May 27 16:02:58 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 03:57:28 2007 Koichi Sasada <ko1@atdot.net>
+ * eval.c (rb_mod_module_exec, Init_eval): Add
+ Module#{module_exec,class_exec}.
- * cont.c, vm.h: fix to support sparc machine.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp>
+Tue May 27 15:36:37 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 03:35:19 2007 Koichi Sasada <ko1@atdot.net>
+ * io.c (rb_io_each_char, argf_each_char, Init_IO):
+ Add {IO#,ARGF.}{each_char,chars}.
- * common.mk: remove additional "-".
+Tue May 27 13:46:52 2008 Akinori MUSHA <knu@iDaemons.org>
-Mon Dec 24 02:59:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/stringio/stringio.c (Init_stringio): Define
+ StringIO#{getbyte,readbyte}.
- * io.c (rb_io_check_readable): should not fill fptr->enc always.
- read-write IO (e.g. socket) does not work. [ruby-dev:32685]
+Tue May 27 13:38:51 2008 Akinori MUSHA <knu@iDaemons.org>
- * io.c (io_read_encoding): retrieve reading encoding.
+ * io.c (Init_IO): Define {IO#,ARGF.}{getbyte,readbyte}.
- * io.c (prepare_getline_args): convert RS to external encoding.
+Tue May 27 13:26:15 2008 Akinori MUSHA <knu@iDaemons.org>
- * string.c (str_new_shared): was setting embedding flag of wrong
- string object. [ruby-dev:32685]
+ * ext/stringio/stringio.c (Init_stringio): Define #bytes and
+ #lines.
- * io.c (io_enc_str): should preserve default_external encoding.
+Tue May 27 13:20:35 2008 Akinori MUSHA <knu@iDaemons.org>
- * io.c (appendline): should do multibyte aware RS search.
+ * io.c: (rb_io_lines, rb_io_bytes, Init_IO): Define
+ IO#{lines,bytes} and ARGF.{lines,bytes}.
-Mon Dec 24 02:06:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue May 27 12:13:17 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * io.c (rb_f_open): documentation update.
+ * file.c (BUFCHECK): wrong condition. [ruby-core:16921]
- * io.c (rb_io_s_pipe): ditto.
+ * file.c (file_expand_buf): shouldn't use buflen for length of string.
- * io.c (io_fwrite): wrong encoding destination.
+Mon May 26 18:24:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_external_encoding): should return the encoding of
- the file reading.
+ * file.c (BUFCHECK): no resize if enough room.
- * io.c (rb_io_internal_encoding): should return the encoding of
- read string.
+ * file.c (file_expand_path): use BUFCHECK.
-Mon Dec 24 01:46:43 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon May 26 16:46:19 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * io.c (rb_io_s_pipe): allow specifying read-side encoding.
+ * file.c (ntfs_tail): filename which starts with '.' is valid.
- * io.c (io_enc_str): wrong encoding destination.
+ * file.c (file_expand_path): cygwin symlink support.
-Mon Dec 24 01:03:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon May 26 12:16:43 2008 Akinori MUSHA <knu@iDaemons.org>
- * string.c (rb_str_comparable): comparison including broken
- coderange strings do not consider encoding.
+ * .: Release as Ruby 1.8.7-preview4.
-Mon Dec 24 00:57:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon May 26 12:12:26 2008 Akinori MUSHA <knu@iDaemons.org>
- * io.c (open_key_args): IO direct methods (foreach, readlines,
- read) now takes keyword argument: encoding, mode, open_args.
+ * marshal.c (dump_ensure, load_ensure): should return values.
-Mon Dec 24 00:52:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * 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.
- * io.c (rb_io_s_read): encoding argument reverted.
+Mon May 26 11:53:21 2008 Akinori MUSHA <knu@iDaemons.org>
- * io.c (mode_enc): independent function to share code.
+ * 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.
- * io.c (rb_io_internal_encoding): new method.
+ * parse.y (block_par, block_var): ditto.
-Mon Dec 24 00:47:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon May 26 08:00:52 2008 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_beginendblock.rb (TestBeginEndBlock::test_endblockwarn):
- rename endblockwarn.rb to endblockwarn_rb to avoid unnecessary
- warning in make test.
+ * marshal.c (r_object0, Init_marshal): Fix the garbled s_call
+ definition; fixes [ruby-dev:34843].
-Sun Dec 23 23:03:13 2007 Tanaka Akira <akr@fsij.org>
+Mon May 26 03:16:20 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c (rb_enc_codepoint): implemented to raise invalid
- encoding.
+ * 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.
- * include/ruby/encoding.h (rb_enc_codepoint): macro is replaced as a
- declaration.
+Sun May 25 19:48:12 2008 Akinori MUSHA <knu@iDaemons.org>
-Sun Dec 23 19:45:22 2007 Tanaka Akira <akr@fsij.org>
+ * hash.c (env_delete_if): Return an enumerator if no block is
+ given.
+ (env_each_key): Delay a variable initialization after
+ RETURN_ENUMERATOR().
- * lib/time.rb (Time.httpdate): fix 2 digits year for 20xx.
- reported by Tadayoshi Funaba. [ruby-dev:32687]
+Sun May 25 05:07:19 2008 Akinori MUSHA <knu@iDaemons.org>
-Sun Dec 23 19:33:42 2007 Eric Hodel <drbrain@segment7.net>
+ * 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.
- * lib/open-uri.rb: Fix method redefined warning. [ruby-core:14304]
+ * enumerator.c (Init_Enumerator): Override
+ Enumerable::Enumerator#each_with_index with #with_index.
-Sun Dec 23 18:31:49 2007 NARUSE, Yui <naruse@ruby-lang.org>
+Sun May 25 03:13:09 2008 Akinori MUSHA <knu@iDaemons.org>
- * ext/nkf/nkf.c (rb_nkf_enc_get): use rb_define_dummy_encoding.
+ * eval.c (Init_Thread): Initialize recursive_key.
- * ext/nkf/nkf.c (Init_nkf): use rb_nkf_enc_get("ASCII").
+Sun May 25 02:45:49 2008 Akinori MUSHA <knu@iDaemons.org>
- * ext/nkf/nkf-utf8/nkf.c: Update 1.161.
+ * error.c (syserr_eqq): Use en.
- * ext/nkf/nkf-utf9/config.h: default output encoding is now UTF-8.
+Sat May 24 22:32:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/nkf/lib/kconv.rb (Kconv.kconv): replace Encoding#name by
- Encoding#to_s.
+ * object.c (rb_cstr_to_dbl): should clear errno before calling
+ strtod(3). [ruby-dev:34834]
-Sun Dec 23 18:02:52 2007 Eric Hodel <drbrain@segment7.net>
+Sat May 24 22:27:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/rubygems/gem_open_uri.rb: Fix version check.
+ * marshal.c (marshal_load): should initialize arg.data used for
+ reentrant check. [ruby-dev:34837]
-Sun Dec 23 17:24:48 2007 Tanaka Akira <akr@fsij.org>
+Sat May 24 00:34:59 2008 Tanaka Akira <akr@fsij.org>
- * encoding.c (rb_enc_init): add eucJP as an alias of EUC-JP.
+ * lib/rational.rb (Rational#to_i): fix rdoc. Rational(-7,4).to_i
+ should be -1.
-Sun Dec 23 17:00:23 2007 Tanaka Akira <akr@fsij.org>
+Fri May 23 20:22:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/time.rb (Time.httpdate): use Time.utc for
- "day-of-week, dd-mon-yy HH::MM:SS GMT" format.
+ * marshal.c (reentrant_check): check reentrance via callcc.
+ [ruby-dev:34802]
-Sun Dec 23 16:12:40 2007 Eric Hodel <drbrain@segment7.net>
+Fri May 23 16:46:28 2008 Akinori MUSHA <knu@iDaemons.org>
- * lib/rdoc: Fix 1.9 warnings.
+ * enumerator.c (proc_call): Remove an unused static function.
-Sun Dec 23 15:28:37 2007 Eric Hodel <drbrain@segment7.net>
+Fri May 23 13:46:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rubygems, test/rubygems: Fix new 1.9 warnings.
+ * configure.in (cflags): commit miss.
-Sun Dec 23 14:43:10 2007 Eric Hodel <drbrain@segment7.net>
+Fri May 23 09:52:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * gem_prelude.rb: Use require to load rubygems.rb so the correct path
- is in $LOADED_FEATURES on RubyGems upgrade.
+ * configure.in (MINIRUBY), common.mk (RUBYOPT): add purelib.rb.
+ [ruby-core:16642]
-Sun Dec 23 11:26:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/extmk.rb: load purelib.rb only when not cross compiling.
- * string.c (sym_call): use exact argument array interface.
- [ruby-core:14279]
+Fri May 23 08:47:02 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sun Dec 23 11:01:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * error.c (syserr_eqq): === should be able to handle delegated
+ objects as well.
- * io.c (rb_io_binmode_m): removed C99ism.
+Fri May 23 04:22:19 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sun Dec 23 10:23:23 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: fix memory leak.
- * transcode_data_one_byte.c: Better (and more honest) optimization.
+ * ext/tk/lib/tk.rb: avoid trouble when finalize TclTkIp.
- * transcode_data_japanese.c: First optimization step.
+ * ext/tk/lib/tk.rb, ext/tk/lib/tk/*: help to fix troubles when
+ use Ttk widgets on old Tk scripts.
-Sun Dec 23 09:07:02 2007 Tanaka Akira <akr@fsij.org>
+ * ext/tk/sample/*: update and add demo scripts. some of them are
+ introduction about new features of Tcl/Tk8.5.
- * include/ruby/encoding.h, encoding.c, re.c, io.c, parse.y, numeric.c,
- ruby.c, transcode.c, ext/nkf/nkf.c: rename rb_ascii_encoding. to
- rb_ascii8bit_encoding. rb_ascii_encoding is ambiguous with
- ASCII-8BIT and US-ASCII.
+Fri May 23 03:48:10 2008 Akinori MUSHA <knu@iDaemons.org>
-Sun Dec 23 03:35:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * class.c (clone_method): Just use ruby_cref as cref.
- * version.h: use patchlevel if revision is not set.
+Fri May 23 01:03:23 2008 Akinori MUSHA <knu@iDaemons.org>
- * {bcc32,win{32,ce}}/setup.mak (-version-): skip including revision.h.
+ * class.c (rb_singleton_class_clone): Pass Qnil, not 0.
- * common.mk (srcs): new target to generated sources.
+Fri May 23 00:51:48 2008 Akinori MUSHA <knu@iDaemons.org>
- * common.mk (encs, ext/ripper/ripper.c): MAKEFLAGS needs -.
+ * class.c (clone_method): Totally revamp the previous fix which
+ was incorrect.
+ (rb_mod_init_copy): Ditto.
+ (singleton_class_clone_int): Ditto.
- * enc/depend, enc/make_encmake.rb: use erb.
+Fri May 23 00:48:10 2008 Akinori MUSHA <knu@iDaemons.org>
-Sun Dec 23 01:56:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (rb_copy_node_scope), node.h: Rename from copy_node_scope
+ and export.
- * io.c (rb_io_mode_enc): do not set encoding unless explicitly
- specified.
+Thu May 22 21:24:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_io_check_readable): fill fptr->enc by default_external
- if it's empty.
+ * parse.y (top_local_setup): fixed memory leak bug based on a
+ patch from Roger Pack <rogerpack2005 at gmail.com> in
+ [ruby-core:16610].
- * io.c (io_enc_str): fptr->enc is always set for reading IO (by
- rb_io_check_readable(fptr)).
+Thu May 22 14:20:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Dec 23 01:18:06 2007 David Flanagan <david@davidflanagan.com>
+ * array.c (flatten): check if reentered. [ruby-dev:34798]
- * io.c, io.h: temporary patch to partially implement
- transcode-on-read and transcode-on-write
+Thu May 22 08:28:49 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sun Dec 23 00:48:05 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * array.c (flatten): free memo hash table before raising exception.
+ [ruby-dev:34789]
- * test/net/imap/test_imap.rb: added tests for SSL.
+Thu May 22 06:30:10 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Dec 22 21:10:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (flatten): fix memory leak.
- * ext/syck/rubyext.c (syck_genericresolver_node_import): should
- not set instance variable "@kind" before initializing it.
- [ruby-dev:32677]
+Thu May 22 05:45:30 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 22 19:52:23 2007 Koichi Sasada <ko1@atdot.net>
+ * proc.c (proc_dup): should copy safe_level from src proc
+ properly. a patch from Keita Yamaguchi
+ <keita.yamaguchi at gmail.com>
- * bootstraptest/test_objectspace.rb: fix condition.
+Wed May 21 23:31:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 22 19:17:10 2007 Koichi Sasada <ko1@atdot.net>
+ * 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.
- * ext/probeprofiler/: removed.
+ * 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.
-Sat Dec 22 19:14:38 2007 Koichi Sasada <ko1@atdot.net>
+Wed May 21 12:34:51 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * process.c (rb_f_fork): Unsupport Kernel.fork() on NetBSD.
+ * hash.c (rb_hash_delete): rdoc fix based on a patch from Gaston Ramos
+ <ramos.gaston AT gmail.com>. [ruby-core:16825]
-Sat Dec 22 15:54:54 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+Tue May 20 13:15:46 2008 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_transcode.rb: Added simple tests for
- EUC-JP and Shift_JIS and tests for ASCII-only range
+ * file.c (lchmod_internal): Remove a compiler warning.
-Sat Dec 22 18:20:13 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon May 19 18:22:35 2008 Akinori MUSHA <knu@iDaemons.org>
- * common.mk (version.o): add dependency. [ruby-dev:32680]
+ * 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].
-Sat Dec 22 17:45:11 2007 NARUSE, Yui <naruse@ruby-lang.org>
+Mon May 19 14:20:13 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/nkf/nkf.c (Init_nkf): use rb_ascii_encoding() for
- rb_nkf_enc_get("US-ASCII").
- * if use rb_nkf_enc_get("US-ASCII"), ruby will crash - this is bug?
+ * sprintf.c (rb_f_sprintf): fixed SEGV on win32 with "% 0e" % 1.0/0.0.
-Sat Dec 22 17:39:03 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon May 19 13:29:58 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/mkmf.rb ($extmk): fixed broken condition.
+ * 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>
-Sat Dec 22 17:35:59 2007 NARUSE, Yui <naruse@ruby-lang.org>
+Mon May 19 13:01:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/nkf/nkf-utf8.c: Update nkf.c rev:1.157.
+ * common.mk ({MSPEC,RUBYSPEC}_GIT_URL): moved from Makefine.in.
- * ext/nkf/nkf.c (rb_nkf_enc_get): replicate proper based encoding.
+ * {win32,bcc32}/Makefile.sub (update-rubyspec): added.
- * ext/nkf/kconv.c (Kconv#kconv, to*): use self.encoding as from_enc
- when from_enc isn't given.
+Mon May 19 11:53:45 2008 Akinori MUSHA <knu@iDaemons.org>
-Sat Dec 22 17:06:50 2007 GOTOU Yuuzou <gotoyuzo@notwork.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].
- * ext/openssl/lib/net/ssl.rb (OpenSSL::SSL::SSLContext.build): removed.
+Mon May 19 06:36:37 2008 Akinori MUSHA <knu@iDaemons.org>
- * ext/openssl/lib/net/ssl.rb (OpenSSL::SSL::SSLContext#set_params):
- new method to set suitable SSL parameters.
+ * .: Release as Ruby 1.8.7-preview3.
- * lib/net/pop.rb, lib/net/http.rb, lib/net/imap.rb,
- test/openssl/test_ssl.rb: follow above change.
+Sun May 18 22:26:51 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * test/net/http/test_https.rb: refine error case.
+ * 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.
-Sat Dec 22 16:58:49 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * lib/webrick/httpservlet/abstract.rb
+ (WEBrick::HTTPServlet::AbstracServlet#redirect_to_directory_uri):
+ should escape the value of Location: header.
- * lib/net/imap.rb (encode_utf7): accept UTF-8 strings.
+ * lib/webrick/httpservlet/cgi_runner.rb: accept interpreter
+ command line arguments.
- * lib/net/imap.rb (decode_utf7): return UTF-8 strings.
+Sat May 17 23:53:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 22 15:56:36 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * file.c (file_expand_path): fix for short file name on Cygwin.
- * transcode_data_japanese: typo.
+Sat May 17 11:29:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 22 15:54:54 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * file.c (rb_file_s_extname): first dot is not an extension name.
- * ChangeLog: Information for last patch got lost, fixed
+Sat May 17 10:18:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 22 15:45:45 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * re.c (rb_reg_search): need to free allocated buffer in re_register.
- * transcode_data_one_byte: slightly optimized
+Fri May 16 17:01:44 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * transcode_data_japanese: new data file for EUC-JP and SHIFT_JIS
- (not yet optimized; tests to follow; data from
- http://nkf.sourceforge.jp/ucm/{SJIS|eucJP}-nkf.ucm)
+ * win32/Makefile.sub (test-rubyspec): added.
- * common.mk, transcode.c: Adjusted for transcode_data_japanese
+Fri May 16 16:22:40 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Dec 22 15:30:13 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/tk/tcltklib.c: sometimes freeze when receive Interrupt signal.
- * */Makefile.sub (MFLAGS): define unless defined.
+Fri May 16 14:54:56 2008 Tanaka Akira <akr@fsij.org>
-Sat Dec 22 15:17:40 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * Makefile.in (update-rubyspec): move rubyspec to srcdir.
+ (test-rubyspec): ditto.
- * lib/mkmf.rb ($extmk): set true only when under ext/ or tool/.
+Fri May 16 14:25:22 2008 Tanaka Akira <akr@fsij.org>
-Sat Dec 22 15:14:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * Makefile.in (test-rubyspec): use RUNRUBY. suggested by nobu.
- * common.mk (encs, ext/ripper/ripper.c): needs MFLAGS.
+Fri May 16 13:01:43 2008 Tanaka Akira <akr@fsij.org>
- * configure.in (STRINGIZE): stringizing macro.
+ * Makefile.in (update-rubyspec): new target to download rubyspec.
+ (test-rubyspec): new target to run rubyspec. this doesn't work
+ before install.
- * include/ruby/defines.h (STRINGIZE): fallback.
+Fri May 16 08:15:52 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * tool/make-snapshot: new file.
+ * ext/tk/lib/tk.rb: fix memory (object) leak bug.
- * version.c (ruby_description, ruby_copyright): string constants for
- -v option.
+ * ext/tk/sample/demos-jp/aniwave.rb, ext/tk/sample/demos-en/aniwave.rb:
+ bug fix.
-Sat Dec 22 15:03:37 2007 Shugo Maeda <shugo@ruby-lang.org>
+Thu May 15 17:00:22 2008 Akinori MUSHA <knu@iDaemons.org>
- * lib/net/imap.rb (initialize): fixed documentation.
+ * string.c (Init_String): Define #bytesize as an alias for #size
+ for compatibility with 1.9.
-Sat Dec 22 15:01:16 2007 Shugo Maeda <shugo@ruby-lang.org>
+Thu May 15 15:33:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/pop.rb (enable_ssl): use OpenSSL::SSL::SSLContext.build
- instead of SSLContext.new (default verify mode is now
- OpenSSL::SSL::VERIFY_PEER).
+ * file.c (file_expand_path): support for alternative data stream
+ and ignored trailing garbages of NTFS.
-Sat Dec 22 14:45:21 2007 Tadayoshi Funaba <tadf@dotrb.org>
+ * file.c (rb_file_s_basename): ditto.
- * lib/date.rb: shouldn't freeze nil. [ruby-dev:32677]
+ * file.c (rb_file_s_extname): ditto.
-Sat Dec 22 14:27:27 2007 Tanaka Akira <akr@fsij.org>
+Wed May 14 19:24:59 2008 Akinori MUSHA <knu@iDaemons.org>
- * regenc.c (onigenc_ascii_is_code_ctype): moved from enc/ascii.c.
+ * array.c (rb_ary_count): Override Enumerable#count for better
+ performance.
+ (rb_ary_nitems): Undo the backport. Use #count {} instead.
- * regenc.h (onigenc_ascii_is_code_ctype): declared.
+ * enumerator.c (enumerator_iter_i): Remove an unused function.
+ (enumerator_with_index, enumerator_each): Remove unused
+ variables.
- * enc/ascii.c: use onigenc_ascii_is_code_ctype.
+Wed May 14 17:15:11 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * enc/us_ascii.c: new file for US-ASCII.
+ * ext/tk/tkutil/extronf.rb: check stdndup() because it's not standard
+ function of C.
-Sat Dec 22 14:30:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): use malloc() and
+ strncpy() instead of strndup() if not available.
- * parse.y (reg_named_capture_assign_iter): allows non-ascii names and
- get rid of reserved word IDs.
+Wed May 14 09:52:02 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Dec 22 14:18:45 2007 Koichi Sasada <ko1@atdot.net>
+ * 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).
- * test/ruby/test_float.rb, test_sprintf.rb: fix test place.
+ * 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.
-Sat Dec 22 14:17:02 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/tk/tkutil/tkutil.c: strings are available on subst_tables on
+ TkUtil::CallbackSubst class (it is useful on Ruby 1.9).
- * bootstraptest/test_objectspace.rb: skip flozen string.
+ * 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.
-Sat Dec 22 14:02:58 2007 Koichi Sasada <ko1@atdot.net>
+Tue May 13 15:10:50 2008 Akinori MUSHA <knu@iDaemons.org>
- * array.c (rb_ary_permutation): add volatile to avoid GC problem.
+ * 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.
-Sat Dec 22 11:47:42 2007 Koichi Sasada <ko1@atdot.net>
+ * NEWS: Intentionally omit enum_slice and enum_cons, which are
+ removed in 1.9.
- * eval.c (rb_obj_instance_eval): use class of immediate objects.
+Tue May 13 07:56:36 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * test/ruby/test_eval.rb: fix a test.
+ * string.c (rb_str_cat): fixed buffer overrun reported by
+ Christopher Thompson <cthompson at nexopia.com> in [ruby-core:16746]
-Sat Dec 22 11:37:06 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon May 12 13:57:19 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * encoding.c (rb_locale_charmap): win32 support.
+ * eval.c (is_defined): add NODE_OP_ASGN_{OR,AND}. "defined?(a||=1)"
+ should not operate assignment. [ruby-dev:34645]
-Sat Dec 22 11:31:14 2007 Eric Hodel <drbrain@segment7.net>
+Mon May 12 12:59:23 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * gem_prelude.rb: Place bin dir before lib dir so gem bin stubs work.
+ * ext/tk/lib/tk/wm.rb: Wm#overrideredirect overwrites arguemnt to
+ an invalid value.
-Sat Dec 22 11:05:44 2007 Jim Weirich <jim@tardis.local>
+ * ext/tk/sample/ttk_wrapper.rb: support "if __FILE__ == $0" idiom.
- * lib/rake.rb (Rake): Added Rake and related libraries to the
- source code base.
+Mon May 12 12:36:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-Sat Dec 22 10:30:45 2007 Koichi Sasada <ko1@atdot.net>
+ * win32/win32.c (rb_w32_select): backport from trunk.
+ [ruby-talk:300743]
- * tool/insns2vm.rb: moved from lib/vm/instruction.rb.
+Mon May 12 12:33:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 22 10:25:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * common.mk (RUBYLIB, RUBYOPT): clear.
- * parse.y (reg_named_capture_assign_iter): captured name should
- not be reserved word. a patch from Keita Yamaguchi
- <keita.yamaguchi AT gmail.com> in [ruby-dev:32675].
+Mon May 12 10:41:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (reg_named_capture_assign_iter): just ignore the
- captures that do not have valid local variable name.
+ * lib/delegate.rb (SimpleDelegator::dup): removed needless argument.
+ [ruby-list:44910]
-Sat Dec 22 10:19:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/delegate.rb (clone, dup): keep relationship with the target
+ object.
- * eval.c (rb_f_method_name): now __method__ and __callee__ are
- aliases. [ruby-core:14244]
+Sun May 11 23:19:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 22 08:29:56 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * enum.c (all_iter_i, any_iter_i): reduced duplicated code.
- * string.c (rb_str_buf_append): improvement for non-broken coded
- strings.
+Sun May 11 17:57:36 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 22 06:30:04 2007 Koichi Sasada <ko1@atdot.net>
+ * configure.in (MINIRUBY): should not include extension library path.
- * bootstraptest/test_fork.rb: skip if fork is not unsupported.
+Sun May 11 10:36:10 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * bootstraptest/test_io.rb: skip if require failed.
+ * eval.c (method_name, method_owner): New methods; backported
+ from 1.9. (UnboundMethod#name, UnboundMethod#owner)
-Sat Dec 22 06:09:12 2007 David Flanagan <david@davidflanagan.com>
+Sun May 11 02:48:13 2008 <nagai@orca16.orcabay.ddo.jp>
- * io.c: fix typo in rdoc comment
+ * ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: fail to do pack/grid
+ without options.
-Sat Dec 22 05:09:43 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/tk/lib/tk.rb: add TkWindow#grid_anchor, grid_column, grid_row.
- * parse.y (parser_str_new, rb_intern3): rb_default_encoding() renamed.
+Sat May 10 18:19:16 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/nkf/nkf.c (rb_nkf_putchar): ditto.
+ * string.c (rb_str_each_line): RDoc updated. [ruby-dev:34586]
-Sat Dec 22 03:54:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat May 10 13:17:56 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * encoding.c (rb_ascii_encoding): renamed from previous
- rb_default_encoding().
+ * ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: increase supported
+ parameter patterns of configure method.
-Sat Dec 22 02:49:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat May 10 09:16:13 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (command): block from cmd_brace_block was ignored.
- [ruby-dev:32644]
+ * 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]
- * re.c (rb_reg_prepare_re): stop ENCODING_NONE warning if the
- encoding of the str is ASCII-8BIT.
+Fri May 9 23:33:25 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Dec 22 01:52:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tk/wm.rb: methods of Tk::Wm_for_General module cannot
+ pass the given block to methods of Tk::Wm module.
- * io.c (io_ungetc): avoid buffer relocation, which might cause
- serious problem under concurrent situation.
+ * ext/tk/lib/tk/grid.rb: lack of module-method definitions.
-Sat Dec 22 01:35:41 2007 Tanaka Akira <akr@fsij.org>
+ * ext/tk/lib/tkextlib/tile.rb: lack of autoload definitions.
- * re.c (ARG_ENCODING_NONE): defined for /.../n option.
- (REG_ENCODING_NONE): ditto.
- (rb_char_to_option_kcode): return ARG_ENCODING_NONE for n.
- (rb_reg_prepare_re): warn /ascii/n =~ "non-ascii".
- (rb_reg_initialize): set REG_ENCODING_NONE from ARG_ENCODING_NONE.
+ * ext/tk/lib/tkextlib/tile/tnotebook.rb: cannot use kanji (not UTF-8)
+ characters for headings.
-Sat Dec 22 01:23:10 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * ext/tk/tcltklib.c: maybe a little more stable about @encoding value
+ of TclTkIp object.
- * test/json/test_json_addition.rb (test_core): do not use Time.now
- because JSON can't hold nsec.
+Wed May 7 08:46:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 22 01:10:30 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * struct.c (rb_struct_s_def): to_str should be called only once.
+ [ruby-core:16647]
- * ext/tk/sample/tkextlib/vu/canvSticker2.rb,
- ext/tk/sample/demos-{en,jp}/bind.rb: fix typo. [ruby-dev:32668]
+Wed May 7 00:54:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 22 00:56:43 2007 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].
- * sample/test.rb (valid_syntax): force_encoding input script.
+Sun May 4 09:35:51 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Fri Dec 21 23:48:38 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * sample/erb/erb4html.rb (ERB4Html) : add example of ERB#set_eoutvar.
+ ERB4Html is an auto-quote ERB.
- * lib/mkmf.rb (depend_rules): suffixes list broken. fixed.
+Sat May 3 22:52:48 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Fri Dec 21 20:18:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * 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).
- * bignum.c (rb_big_mul0): remove unused variable.
+Fri May 2 14:52:33 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (bigdivrem): ditto.
+ * misc/ruby-mode.el: move fontifying code from hook. a patch from
+ Phil Hagelberg <phil at hagelb.org> in [ruby-core:16636].
-Fri Dec 21 20:13:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri May 2 13:47:51 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * include/ruby/ruby.h (rb_catch_obj, rb_throw_obj): prototyped.
+ * 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]
- * include/ruby/intern.h (rb_fiber_alive_p): prototyped.
+Fri May 2 13:04:04 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Dec 21 20:09:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/dbm/dbm.c (Init_dbm): defines DBM::VERSION even when
+ DB_VERSION_STRING is not available. [ruby-dev:34569]
- * string.c (rb_str_succ): retry increasing until valid char is found.
+Thu May 1 23:57:06 2008 James Edward Gray II <jeg2@ruby-lang.org>
-Fri Dec 21 20:00:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ Merged 16257 from trunk.
- * encoding.c (rb_enc_replicate): now creates first class encoding.
+ * 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.
- * encoding.c (rb_define_dummy_encoding): always based on the default
- encoding.
+Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * encoding.c (rb_enc_dummy_p): check if dummy.
+ * range.c (range_step): check if step can be converted to an integer.
+ [ruby-dev:34558]
- * encoding.c (enc_inspect): shows if dummy.
+ * range.c (range_step): allow float step bigger than zero but less
+ than one. [ruby-dev:34557]
- * encoding.c (Init_Encoding): added dummy? method
+Wed Apr 30 20:22:40 2008 James Edward Gray II <jeg2@ruby-lang.org>
- * include/ruby/encoding.h (ENCODING_INLINE_MAX): increased.
+ Merged 16241 from trunk.
-Fri Dec 21 18:40:54 2007 Koichi Sasada <ko1@atdot.net>
+ * lib/net/telnet.rb: Fixing a bug where line endings would not be properly
+ escaped when the two character ending was broken up into separate TCP
+ packets. Issue reported and patched by Brian Candler.
- * io.c: write() should be in blocking region.
+Wed Apr 30 17:47:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bootstraptest/test_io.rb, test_knownbug.rb: move a fixed test.
+ * re.c (rb_reg_search): use local variable. a patch from wanabe
+ <s.wanabe AT gmail.com> in [ruby-dev:34537]. [ruby-dev:34492]
-Fri Dec 21 17:56:30 2007 <nagai@orca16.orcabay.ddo.jp>
+Sat Apr 26 19:40:34 2008 Guy Decoux <decoux@moulon.inra.fr>
- * ext/tk/tcltklib.c: provisional support on Ruby-VM.
+ * 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]
- * ext/tk/MANUAL_tcltklib.eng, ext/tk/MANUAL_tcltklib.eucj:
- modify document about new functions.
+ * eval.c (rb_block_dup, rb_method_dup), intern.h: Add duplicator
+ methods for use from class.c#clone_method().
- * ext/tk/lib/tk.rb, ext/tk/lib/tk/labelframe.rb,
- ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/toplevel.rb,
- ext/tk/lib/tk/scrollbar.rb, ext/tk/lib/tk/message.rb,
- ext/tk/lib/tk/listbox.rb, ext/tk/lib/tk/text.rb,
- ext/tk/lib/tk/scale.rb, ext/tk/lib/tk/entry.rb,
- ext/tk/lib/tk/ttk_selector.rb, ext/tk/lib/tk/menu.rb,
- ext/tk/lib/tk/label.rb, ext/tk/lib/tk/spinbox.rb,
- ext/tk/lib/tk/textmark.rb, ext/tk/lib/tk/winpkg.rb,
- ext/tk/lib/tk/checkbutton.rb, ext/tk/lib/tk/panedwindow.rb,
- ext/tk/lib/tk/texttag.rb, ext/tk/lib/tk/root.rb,
- ext/tk/lib/tk/textimage.rb, ext/tk/lib/tk/radiobutton.rb,
- ext/tk/lib/tk/package.rb, ext/tk/lib/tk/macpkg.rb,
- ext/tk/lib/tk/composite.rb, ext/tk/lib/tk/autoload.rb,
- ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/button.rb,
- ext/tk/lib/tk/textwindow.rb,
- ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb,
- ext/tk/lib/tkextlib/tile/style.rb,
- ext/tk/lib/tkextlib/tile/tscrollbar.rb,
- ext/tk/lib/tkextlib/tile/tpaned.rb, ext/tk/lib/tkextlib/tile.rb,
- ext/tk/extconf.rb: support Tcl/Tk8.5 (partial, not complete).
+Fri Apr 25 15:46:37 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/sample/demos-jp/widget,
- ext/tk/sample/demos-jp/pendulum.rb,
- ext/tk/sample/demos-jp/bind.rb,
- ext/tk/sample/tkextlib/vu/canvSticker2.rb,
- ext/tk/sample/demos-en/pendulum.rb,
- ext/tk/sample/demos-en/bind.rb: remove $KCODE and minor bug fix.
+ * 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.
-Fri Dec 21 17:49:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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'.
- * transcode.c (rb_str_transcode_bang): returns self if no conversion.
- [ruby-dev:32662]
+ * ext/tk/lib/tk/menuspec.rb: option check will fail when
+ TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ is true.
-Fri Dec 21 17:44:47 2007 Eric Hodel <drbrain@segment7.net>
+ * ext/tk/lib/tk/palette.rb: bug fix.
- * lib/rubygems*: Update to RubyGems 1.0.1, r1581
+Fri Apr 25 12:37:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Dec 21 17:32:49 2007 Koichi Sasada <ko1@atdot.net>
+ * array.c (flatten): returns an instance of same class.
+ [ruby-core:16554]
- * bootstraptest/pending.rb: renamed from featurebug.rb.
- This file contains bugs which is known but will not be
- fixed in days.
+Thu Apr 24 23:47:50 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Fri Dec 21 17:31:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/net/pop.rb: backported from 1.9. bug#19003
- * debug.c (dummy_gdb_enums.various): added ENCODING and CODERANGE
- constants.
+ * ext/openssl/lib/openssl/ssl.rb: set_params; backported from 1.9.
+ bug#19552, [ruby-dev:34402]
- * .gdbinit: use enum constants.
+ * ext/openssl/ossl_ssl.c: ditto.
-Fri Dec 21 17:28:17 2007 Koichi Sasada <ko1@atdot.net>
+ * test/openssl/test_ssl.rb: ditto.
- * bootstraptest/featurebug.rb: added.
+Thu Apr 24 17:06:34 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bootstraptest/test_knownbug.rb: move a feature bug.
+ * eval.c (THREAD_SAVE_CONTEXT): remove unnecessary
+ FLUSH_REGISTER_WINDOWS before calling setjmp(). [ruby-core:16285]
-Fri Dec 21 17:25:22 2007 Koichi Sasada <ko1@atdot.net>
+Thu Apr 24 14:15:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * thread.c (rb_thread_atfork): fix to mark thread object.
- [ruby-dev:32404]
+ * dln.c (dln_find_1): prior files with extensions to files sans
+ extensions. [ruby-core:16517]
- * bootstraptest/test_knownbug.rb, test_fork.rb: move a fixed test.
+Wed Apr 23 15:39:31 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 17:07:13 2007 Koichi Sasada <ko1@atdot.net>
+ * eval.c (bind_eval): Add Binding#eval, a shorthand method for
+ eval(str, binding, ..); backported from 1.9.
- * gc.h: extern variable should not be initialized.
+Wed Apr 23 15:28:52 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * thread_pthread.c: add a parameter.
+ * test/gdbm/test_gdbm.rb (TestGDBM#test_s_open_no_create): failed
+ notice moved from comment to assertion message. [ruby-dev:29127]
-Fri Dec 21 16:50:43 2007 Tanaka Akira <akr@fsij.org>
+Wed Apr 23 14:00:05 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c (Init_Encoding): use enc_name as to_s.
- (enc_inspect): renamed from enc_to_s. add "#" at beginning.
+ * 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.
-Fri Dec 21 16:37:43 2007 NARUSE, Yui <naruse@ruby-lang.org>
+Wed Apr 23 11:49:54 2008 Akinori MUSHA <knu@iDaemons.org>
- * ext/nkf/nkf-utf8/config.h (MIME_DECODE_DEFAULT, X0201_DEFAULT):
- defined as FALSE. nkf and kconv don't decode MIME encoded string
- and don't convert JIS X 0201 Katakana.
-
- * test/nkf/test_kconv.rb: fix tests.
+ * lib/set.rb (Set#each, SortedSet#each, TC_Set#test_each): Return
+ an enumerator if no block is given.
-Fri Dec 21 16:33:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Apr 23 00:42:49 2008 Tanaka Akira <akr@fsij.org>
- * enumerator.c (enumerator_iter_i): adjusted for rb_block_call_func.
+ * eval.c (error_print): show full stack grace except SystemStackError.
+ backport from 1.9. [ruby-dev:31014]
- * include/ruby/ruby.h (rb_block_call_func): function to be called back
- as block.
+Wed Apr 23 00:18:45 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Fri Dec 21 16:25:25 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * test/ruby/test_symbol.rb (TestSymbol#test_to_proc): Improve
+ tests of Symbol#to_proc.
- * common.mk, transcode_data_iso_8859.c: renamed to
- transcode_data_one_byte.c.
+Tue Apr 22 22:43:05 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 16:10:30 2007 Shigeo Kobayashi <shigeo@tinyforest.jp>
+ * 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.
- * ext/bigdecimal/bigdecimal.c (VpMidRound): Round method bug
- pointed by Ryan Platte fixed(Patch to the patch from "NATORI
- Shin"). [ruby-talk:273360]
+ * intern.h, object.c: Hide rb_proc_new() from intern.h. It should
+ not be considered an official API function yet.
-Fri Dec 21 16:06:13 2007 Tanaka Akira <akr@fsij.org>
+Tue Apr 22 21:24:32 2008 Akinori MUSHA <knu@iDaemons.org>
- * re.c (append_utf8): use rb_utf8_encoding() instead of
- rb_enc_find("utf-8").
+ * eval.c (rb_proc_new): Turn the BLOCK_LAMBDA flag on.
-Fri Dec 21 15:59:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * object.c (sym_to_proc), test/ruby/test_symbol.rb: Add back
+ Symbol#to_proc, now that it passes the tests.
- * encoding.c (rb_enc_init): use enc_register_at() directly.
+Tue Apr 22 19:35:03 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c (rb_utf8_encoding): returns utf-8 encoding.
+ * enumerator.c (enumerator_initialize): Remove an undocumented
+ feature (passing a block to the constructor) that's broken.
+ This is not what I intended.
- * include/ruby/encoding.h (rb_utf8_encoding): prototyped.
+Tue Apr 22 17:49:46 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (UTF8_ENC): uses rb_utf8_encoding().
+ * sprintf.c (rb_f_sprintf): should protect temporary string from
+ GC. [ruby-dev:34480]
-Fri Dec 21 15:31:59 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Apr 22 17:12:05 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_io_s_read): allow specifying encoding explicitly.
+ * regex.c (re_search): string might be NULL. [ruby-core:16478]
- * io.c (rb_io_binmode): specifies encoding to ASCII-8BIT (binary).
+Tue Apr 22 16:44:00 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * io.c (rb_io_s_read): IO should be in binary mode when offset is
- specified.
+ * object.c (rb_obj_tap): Correct documentation; pointed out by
+ okkez in [ruby-dev:34472].
- * encoding.c (rb_to_encoding): returns default encoding if no
- corresponding encoding found.
+Tue Apr 22 10:05:51 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Dec 21 15:24:22 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * file.c (eaccess): workaround for recent msvcrt's behavior.
+ [ruby-core:16460]
- * lib/net/imap.rb (initialize): accept service name. changed
- the defalut value of the old style +verify+ argument to true.
+Mon Apr 21 16:06:47 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Dec 21 15:15:44 2007 Tanaka Akira <akr@fsij.org>
+ * enumerator.c (enumerator_init): preserve the method name in ID.
- * gc.c (rb_garbage_collect): new function for debugging.
+ * enumerator.c (enumerator_each): need not to call rb_to_id().
-Fri Dec 21 15:16:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * enumerator.c (enumerator_with_index): ditto.
- * encoding.c (rb_to_encoding_index): should return error instead of
- exception even if type is incorrect.
+Mon Apr 21 17:19:52 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 14:58:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (rb_f_method_name): New gloval function: __method__;
+ backported from matzruby / 1.9.
- * enumerator.c (enumerator_init_copy): prohibit cloning of
- generators since Fibers cannot be copied.
+ * eval.c (rb_frame_this_func), intern.h: New internal function.
- * enumerator.c (enumerator_init_copy): typo fixed.
+ * intern.h (RETURN_ENUMERATOR): Use rb_frame_this_func() instead
+ of rb_frame_last_func(), to accommodate the behavior to that of
+ 1.9.
-Fri Dec 21 14:46:07 2007 Tanaka Akira <akr@fsij.org>
+Mon Apr 21 15:54:48 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (Init_IO): define IO::BINARY even if O_BINARY is not exist.
+ * lib/tempfile.rb (Tempfile::_close): check @data before modifying
+ it; backported from 1.9. [ruby-dev:34094]
-Fri Dec 21 14:01:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/tempfile.rb (Tempfile::close): clear @data and @tmpname.
- * test/ruby/test_system.rb (TestSystem::valid_syntax): apply
- ASCII-8BIT encoding explicitly.
+Mon Apr 21 10:17:17 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * re.c (rb_reg_prepare_re): add encoding name in the message.
+ * time.c: should include <errno.h> to refer errno.
-Fri Dec 21 13:54:05 2007 Tanaka Akira <akr@fsij.org>
+Mon Apr 21 10:02:43 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * re.c: change "character encodings differ" error messages.
+ * hash.c (recursive_hash): prototype.
-Fri Dec 21 13:46:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Apr 21 10:00:51 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * encoding.c (rb_enc_register): set encoding constant.
+ * time.c (rb_strftime): check errno to detect strftime(3)'s error.
+ this is workaround for recent version of MSVCRT.
+ [ruby-dev:34456]
- * encoding.c (rb_enc_find_index): replace non-alphanumeric chars with
- underscores, so that initialize function can be called.
+Sun Apr 20 21:10:04 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c (rb_enc_find_index): extension libraries have lower case
- names conventionally.
+ * .: Release as Ruby 1.8.7-preview2.
- * ruby.c (proc_options, process_options): finds encoding after
- load_path is initialized.
+Sun Apr 20 21:02:06 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 13:10:57 2007 Yukihiro Matsumoto <matz@ruby-lang.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]
- * io.c (rb_io_external_encoding): new method.
+Sun Apr 20 17:59:25 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c (rb_enc_from_encoding): returns Qnil for NULL
- encoding.
+ * object.c, NEWS, test/ruby/test_symbol.rb: Revert Symbol#to_proc
+ since it does not pass the tests.
- * io.c (rb_io_external_encoding): should fill delayed
- initialization for STDIN.
+Sun Apr 20 14:29:35 2008 Technorama Ltd. <oss-ruby@technorama.net>
-Fri Dec 21 13:09:11 2007 Tanaka Akira <akr@fsij.org>
+ * ext/openssl/ossl_ssl.c: initialize session class.
- * encoding.c (rb_locale_charmap): return nil if no locale information.
+Sat Apr 19 20:54:42 2008 akira yamada <akira@arika.org>
-Fri Dec 21 12:55:39 2007 Tanaka Akira <akr@fsij.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]
- * lib/runit, lib/rubyunit.rb, test/testunit/runit: removed.
+Sat Apr 19 20:35:02 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 12:45:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/yaml/baseemitter.rb, lib/yaml/encoding.rb: performance
+ tuning around String#gsub.
- * string.c (rb_str_chomp_bang): avoid unnecessary loop using
- ONIGENC_LEFT_ADJUST_CHAR_HEAD().
+ * lib/yaml/tag.rb: Replace nodoc with stopdoc so Module methods get
+ documented.
-Fri Dec 21 12:32:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/yaml/store.rb (YAML::load): modified to support empty
+ database.
- * file.c (Init_File): File.exists? revived.
+ * lib/yaml/store.rb (YAML::Store::marshal_dump_supports_canonical_option?):
+ add a method to support faster PStore.
- * dir.c (Init_Dir): Dir.exists? again.
+Sat Apr 19 20:16:52 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 12:26:36 2007 Koichi Sasada <ko1@atdot.net>
+ * lib/yaml/types.rb: Likewise, pass self to YAML::quick_emit;
+ merged from 1.9.
- * compile.c: remove "illegal".
+ * lib/yaml.rb (quick_emit): use combination of object_id and hash to
+ identify repeated object references, since GC will reuse memory of
+ objects during output of YAML. [ruby-Bugs-8548] [ruby-Bugs-3698];
+ merged from 1.9.
-Fri Dec 21 12:22:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Apr 19 20:05:39 2008 Akinori MUSHA <knu@iDaemons.org>
- * keywords, parse.y (__ENCODING__): represent script encoding.
+ * 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.
-Fri Dec 21 12:16:50 2007 Tanaka Akira <akr@fsij.org>
+ * hash.c (hash_equal, rb_hash_hash): Make Hash#eql?, #hash and #==
+ use rb_exec_recursive() and handle recursive data properly.
- * string.c (rb_str_is_ascii_only_p): new method ascii_only?.
+Sat Apr 19 19:26:09 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 12:11:57 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * intern.h, eval.c (rb_exec_recursive): New internal function to
+ help perform recursive operation; backported from 1.9.
- * io.c (rb_io_mode_enc): set default external encoding if no
- encoding specified explicitly.
+Sat Apr 19 18:42:04 2008 Akinori MUSHA <knu@iDaemons.org>
-Fri Dec 21 12:00:34 2007 Tanaka Akira <akr@fsij.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.
- * configure.in: check langinfo.h and locale.h.
+Fri Apr 18 18:56:57 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c: use langinfo.h only if available.
+ * ext/syck/rubyext.c (syck_genericresolver_node_import): should
+ not set instance variable "@kind" before initializing it.
+ [ruby-dev:32677]
- * main.c: use locale.h only if available.
+ * ext/syck/rubyext.c (syck_resolver_initialize,
+ syck_resolver_detect_implicit, syck_emitter_emit): remove unused
+ variables.
-Fri Dec 21 11:47:56 2007 Tanaka Akira <akr@fsij.org>
+Fri Apr 18 18:54:57 2008 Akinori MUSHA <knu@iDaemons.org>
- * encoding.c: include locale.h
- (rb_locale_charmap): new method Encoding.locale_charmap for
- nl_langinfo(CODESET).
+ * ext/syck/rubyext.c: Node#value defined twice.
- * include/ruby/encoding.h (rb_locale_charmap): declared.
+ * lib/yaml/: several method redefinitions causing warnings.
- * main.c (main): call setlocale with LC_CTYPE.
+Fri Apr 18 16:36:16 2008 Akinori MUSHA <knu@iDaemons.org>
- * ruby.c (locale_encoding): use rb_locale_charmap.
+ * 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 Dec 21 11:35:10 2007 Koichi Sasada <ko1@atdot.net>
+Fri Apr 18 16:01:37 2008 Akinori MUSHA <knu@iDaemons.org>
- * vm.c, vm_dump.c: fix typo. Reported by Yuki Mitsui.
+ * lib/rexml: Merge fixes since 1.8.6 made solely on the ruby_1_8_6
+ branch.
-Fri Dec 21 11:28:00 2007 Tanaka Akira <akr@fsij.org>
+Wed Apr 16 06:11:49 2008 Akinori MUSHA <knu@iDaemons.org>
- * regerror.c, string.c, io.c, lib/getoptlong.rb, lib/net/imap.rb,
- compile.c, sprintf.c, parse.y, ext/win32ole/win32ole.c,
- ext/tk/sample/demos-en/entry3.rb, ext/tk/lib/tcltk.rb,
- ext/openssl/ossl_bn.c, numeric.c, vm.c,
- benchmark/bm_so_meteor_contest.rb, bignum.c, ruby.c: don't "illegal"
- for non law violation context.
+ * test/ruby/test_settracefunc.rb (TestSetTraceFunc#test_event):
+ Fix tests to reflect the following changes: r15833, r15759.
-Fri Dec 21 11:23:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Apr 16 05:03:48 2008 Akinori MUSHA <knu@iDaemons.org>
- * common.mk (enc.mk): depends on $(RBCONFIG) instead of rbconfig.rb.
+ * .: Release as Ruby 1.8.7-preview1.
- * encoding.c (Init_Encoding): ISO-8859-1 is no longer a replica.
+Wed Apr 16 02:09:14 2008 Kouhei Sutou <kou@cozmixng.org>
- * regenc.h (OnigEncodingDefine): names of extension and encoding can
- differ.
+ * lib/xmlrpc/client.rb: fix cookie handling. [ruby-dev:34403]
- * enc/Makefile.in: always shared.
+ * test/xmlrpc/test_cookie.rb: add a test for the above fix.
- * enc/depend (deffile): should not upcase.
+Tue Apr 15 23:48:28 2008 Akinori MUSHA <knu@iDaemons.org>
- * enc/{ascii,euc_jp,sjis,utf8,iso_8859_{1..16}}.c: fix for Init.
+ * version.h: Branch off ruby_1_8_7 from ruby_1_8 in preparation
+ for the forthcoming 1.8.7 release.
-Fri Dec 21 09:26:48 2007 Tanaka Akira <akr@fsij.org>
+Tue Apr 15 23:40:39 2008 Akinori MUSHA <knu@iDaemons.org>
- * tool/compile_prelude.rb: use erb.
+ * ext/syck/rubyext.c (rb_syck_mktime): Avoid buffer overflow.
-Fri Dec 21 08:07:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Apr 15 20:32:03 2008 Tanaka Akira <akr@fsij.org>
- * enumerator.c (enumerator_next): should call next_init() if fiber
- is dead already. [ruby-dev:32459]
+ * re.c (match_inspect): backported from 1.9.
-Fri Dec 21 01:21:49 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Apr 15 19:03:28 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLContext.build):
- enable CRL checking by default.
+ * eval.c (method_receiver, method_name, method_owner): New
+ methods; backported from 1.9. bug#19007
-Fri Dec 21 01:20:56 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Apr 15 18:39:14 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * lib/net/http.rb (Net::HTTP#connect): use
- OpenSSL::SSL::SSLContext.build instead of SSLContext.new (default
- verify mode is now OpenSSL::SSL::VERIFY_PEER).
+ * lib/uri.rb, lib/uri/ldaps.rb: added LDAPS
+ scheme; backported from 1.9. bug#19015, [ruby-dev:31896]
- * lib/net/https.rb: SSL parameters are defined by attr_accessor.
+Tue Apr 15 17:45:43 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * test/net/http/test_https.rb: add test for HTTPS features.
+ * lib/net/smtp.rb: backported from 1.9. bug#19003
-Fri Dec 21 01:11:37 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Apr 15 17:06:12 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * io.c (select_internal): should return original value.
+ * test/ruby/test_symbol.rb (TestSymbol#test_to_proc): add tests.
-Fri Dec 21 00:26:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Apr 15 16:58:55 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * string.c (tr_trans): wrong encoding check for tree strings.
+ * ext/tk/lib/tk/menuspec.rb: option check will fail when
+ TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ is true.
- * test/ruby/test_m17n.rb (TestM17N::test_tr_s): "invalid mbstring
- sequence" is not an error to be tested.
+ * ext/tk/lib/tk/palette.rb: bug fix.
- * test/ruby/test_m17n.rb (TestM17N::test_tr): ditto.
+Tue Apr 15 16:47:48 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Thu Dec 20 19:29:07 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * 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
- * lib/net/imap.rb (initialize): the second argument is an option
- hash now. use SSLContext.build to specify SSL parameters.
+Tue Apr 15 12:35:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Dec 20 19:11:56 2007 Koichi Sasada <ko1@atdot.net>
+ * rubyio.h (rb_io_t): renamed from OpenFile.
- * thread_pthread.c (native_thread_apply_priority): check
- _POSIX_PRIORITY_SCHEDULING for OpenBSD.
+ * 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.
-Thu Dec 20 18:33:54 2007 Koichi Sasada <ko1@atdot.net>
+ * win32/win32.h: removed workaround for OpenFile.
- * configure.in: add libthr for FreeBSD.
+Tue Apr 15 00:15:29 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Thu Dec 20 18:17:14 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/tk/lib/tk/text.rb: typo. call a wrong method.
- * common.mk, *.ci: renamed to *.c.
+ * ext/tk/lib/tk/itemconfig.rb: ditto.
- * eval_laod.c: renamed to load.c.
+ * ext/tk/sample/ttk_wrapper.rb: bug fix.
-Thu Dec 20 17:36:01 2007 Eric Hodel <drbrain@segment7.net>
+ * ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode.
- * lib/rubygems*: Import RubyGems 1.0.0, r1575.
+ * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb:
+ support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options.
-Thu Dec 20 17:18:38 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb,
+ ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb,
+ ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix.
- * proc.c: support Proc#binding.
+ * ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add.
- * sample/test.rb: add a test.
+ * ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the
+ procedure which called at end of the timer.
-Thu Dec 20 17:15:15 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+Mon Apr 14 19:54:21 2008 Akinori MUSHA <knu@iDaemons.org>
- * pack.c: Slight change to documentation ('character' ->
- 'byte (C char)'). [ruby-core:13126], see also [ruby-core:13998].
+ * 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.
-Thu Dec 20 17:07:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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.
- * common.mk (enc.mk): depends on rbconfig.rb.
+Mon Apr 14 19:52:35 2008 Akinori MUSHA <knu@iDaemons.org>
- * regenc.h (OnigEncodingDefine): external encoding definition macro.
+ * ruby.h: New macro: RB_GC_GUARD().
- * enc/Makefile.in: fix for linking.
+Mon Apr 14 19:49:35 2008 Akinori MUSHA <knu@iDaemons.org>
- * enc/depend, enc/make_encmake.rb: fix for Windows.
+ * random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.
- * enc/{ascii,euc_jp,sjis,utf8,iso_8859_{1..16}}.c: renamed.
+ * string.c (rb_str_tmp_new), intern.h: New function.
-Thu Dec 20 16:42:55 2007 Koichi Sasada <ko1@atdot.net>
+Mon Apr 14 19:18:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * iseq.c (find_line_no): return 0 if not found.
+ * enum.c (inject_i, inject_op_i): prototype.
-Thu Dec 20 16:04:17 2007 Koichi Sasada <ko1@atdot.net>
+Mon Apr 14 19:10:47 2008 Akinori MUSHA <knu@iDaemons.org>
- * insnhelper.ci, vm.c, vm_core.h: change interface of
- vm_invoke_block() to specify block ptr. [ruby-talk:266422]
+ * enum.c New methods: Enumerable#take, #take_while, #drop and
+ #drop_while; backported from 1.9.
- * cont.c, eval_jump.ci, insns.def, proc.c, signal.c, thread.c:
- apply above change.
+Mon Apr 14 18:50:15 2008 Akinori MUSHA <knu@iDaemons.org>
- * bootstraptest/test_knownbug.rb: move fixed bug.
+ * enum.c: New methods: Enumerable#one?, #none?, #minmax, #min_by,
+ #max_by, #minmax_by and #cycle; backported from 1.9.
- * bootstraptest/test_block.rb: ditto. and add a test.
+ * enum.c (enum_find_index): Add support for find_index(obj);
+ [ruby-dev:34313]; backported from 1.9.
-Thu Dec 20 15:47:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * enum.c (enum_inject): Add support for Enumerable#inject(:binop);
+ backported from 1.9.
- * enc/iso_8859_{1..16}.c: renamed.
+ * enum.c: Alias Enumerable#reject to #inject; backported from 1.9.
-Thu Dec 20 09:59:27 2007 Koichi Sasada <ko1@atdot.net>
+Mon Apr 14 18:14:19 2008 Akinori MUSHA <knu@iDaemons.org>
- * insnhelper.ci (vm_expandarray): fix sp increase place.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-dev:32581].
+ * enum.c (enum_find, enum_reject): Return an enumerator if no
+ block is given; backported from 1.9.
- * bootstraptest/test_massign.rb: add a test for above.
+ * io.c (rb_io_each_line, rb_io_each_byte, rb_io_s_foreach,
+ argf_each_line, argf_each_byte): Ditto.
- * bootstraptest/test_syntax.rb: fix last committed test.
+ * string.c (str_gsub): Ditto.
-Thu Dec 20 09:47:58 2007 Koichi Sasada <ko1@atdot.net>
+Mon Apr 14 18:10:05 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * bootstraptest/test_syntax.rb: add a test.
+ * enum.c (find_index_i, find_index_iter_i): add prototype for VC.
-Thu Dec 20 09:40:51 2007 Koichi Sasada <ko1@atdot.net>
+Mon Apr 14 17:55:30 2008 Akinori MUSHA <knu@iDaemons.org>
- * compile.c (iseq_compile_each/NODE_RETURN): fix stack consistency.
+ * array.c (rb_ary_collect_bang, rb_ary_select): Return an
+ enumerator if no block is given; backported from 1.9.
-Thu Dec 20 09:42:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * dir.c (dir_each, dir_foreach): Ditto.
- * bignum.c (big2str_orig): access beyond memory region cause crash
- on interrupt. a patch from Yusuke ENDOH <mame AT tsg.ne.jp> in
- [ruby-dev:32651]. [ruby-dev:32641]
+ * enum.c (enum_partition, enum_sort_by): Ditto.
-Thu Dec 20 09:06:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * gc.c (os_each_obj): Ditto.
- * string.c (rb_str_index): wrong starting position.
+ * 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.
-Thu Dec 20 06:34:27 2007 Koichi Sasada <ko1@atdot.net>
+ * numeric.c (num_step, int_upto, int_downto, int_dotimes): Ditto.
- * compile.c (iseq_compile_each): add pop after throw as return.
+Mon Apr 14 16:42:53 2008 Akinori MUSHA <knu@iDaemons.org>
- * bootstraptest/test_knownbug.rb, test_syntax.rb: move resolved test.
+ * ruby.h (rb_block_call_func): Fix prototype.
- * vm_core.h, iseq.c, compile.h: add debug output code.
+ * enumerator.c (enumerator_iter_i, enumerator_each_i): Ditto.
-Thu Dec 20 04:57:18 2007 Koichi Sasada <ko1@atdot.net>
+Mon Apr 14 15:49:05 2008 Akinori MUSHA <knu@iDaemons.org>
- * compile.c (iseq_compile_each): remove unused retry entry.
+ * enum.c (enum_count, enum_find_index): New methods:
+ Enumerable#count and #find_index; backported from 1.9.
-Thu Dec 20 04:15:41 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Apr 14 14:16:08 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * */Makefile.sub (DEFS, RM): output to config.status.
+ * enumerator.c (enumerator_mark, enumerator_iter_i, enumerator_each_i,
+ enumerator_allocate): add prototype.
-Thu Dec 20 02:59:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * enumerator.c (enumerator_each_i): declare unused two arguments.
- * common.mk (encs): create encoding directory.
+Mon Apr 14 13:58:32 2008 Akinori MUSHA <knu@iDaemons.org>
-Thu Dec 20 02:50:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * string.c (rb_str_each_char): New methods: String#chars and
+ #each_char; backported from 1.9.
- * enc/iso8859_{1..16}.c: adjust for ruby.
+Mon Apr 14 13:42:20 2008 Akinori MUSHA <knu@iDaemons.org>
-Thu Dec 20 02:28:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.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.
- * enc/iso8859_{1..16}.c: imported from Onigiruma 5.9.0.
+Mon Apr 14 13:19:36 2008 Akinori MUSHA <knu@iDaemons.org>
-Thu Dec 20 02:23:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * range.c (range_each, range_step): Return an enumerator if no
+ block is given; backported from 1.9.
- * enc/Makefile.in (RM): added.
+ * struct.c (rb_struct_each, rb_struct_each_pair): Ditto.
- * enc/depend (encs): sort in alpha-numeric order.
+Mon Apr 14 13:07:59 2008 Akinori MUSHA <knu@iDaemons.org>
- * enc/depend (clean, distclean): added.
+ * 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?.
-Thu Dec 20 01:10:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Apr 13 15:55:52 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * compile.c (iseq_compile_each): should handle upper level eval iseq
- from break/next, and COMPILE_ERROR() breaks only one block.
- [ruby-dev:31372]
+ * object.c (sym_to_proc): new method Symbol#to_proc; backported
+ from 1.9. bug#19012
-Thu Dec 20 00:07:36 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Fri Apr 11 19:14:30 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * test/drb/drbtest.rb (test_07_public_private_protected_missing):
- followed current Ruby specification.
+ * object.c (rb_obj_tap): new method Object#tap; backported from
+ 1.9. bug#19008
-Wed Dec 19 23:57:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Apr 11 18:58:09 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * dir.c (dir_inspect, dir_path, dir_tell): check for frozen and closed
- is not needed. [ruby-dev:32640]
+ * process.c: new method Process.exec; backported from 1.9. bug#19006
-Wed Dec 19 22:59:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Apr 11 12:43:56 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * string.c (str_sublen): adjust position if position is not at the
- head of a character.
+ * 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.
- * string.c (rb_str_chomp_bang): check if match start at the head
- of a character.
+Fri Apr 11 10:22:54 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * string.c (rb_str_chomp_bang): wrong adjust condition.
+ * ext/tk/lib/tkextlib/tile.rb:
+ __define_LoadImages_proc_for_compatibility__! do nothing when the
+ Tcl command exists.
- * string.c (rb_str_rindex): comparison length should be based on
- bytes, not characters.
+ * ext/tk/lib/tkextlib/tile/style.rb:
+ __define_wrapper_proc_for_compatibility__! do nothing when the Tcl
+ command exists.
- * string.c (rb_str_rindex_m): too much adjustment.
+ * ext/tk/sample/tkextlib/tile/demo.rb: don't create 'step' theme if
+ it already exists.
- * re.c (reg_match_pos): pos adjustment should be based on
- characters.
+Fri Apr 11 08:05:12 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * test/ruby/test_m17n.rb (TestM17N::test_str_insert): test updated
- to check negative offset behavior.
+ * 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].
- * string.c (rb_str_each_line): should consider rslen.
+Thu Apr 10 20:29:13 2008 Akinori MUSHA <knu@iDaemons.org>
- * string.c (rb_str_buf_append): should propagate encoding.
+ * 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.
- * string.c (rb_str_each_line): ditto.
+Thu Apr 10 20:08:37 2008 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_m17n.rb (TestM17N::test_str_each_line): should
- check encoding as well.
+ * enum.c (enum_first, enum_group_by): New methods:
+ Enumerable#first and #group_by; backported from 1.9.
- * test/ruby/test_m17n.rb (TestM17N::test_str_each_line): empty
- array can not propagate encoding; should not check.
+Thu Apr 10 19:49:10 2008 Akinori MUSHA <knu@iDaemons.org>
-Wed Dec 19 21:42:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.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.
- * re.c (rb_reg_regsub): should set checked encoding.
+ * enumerator.c (enumerator_next, enumerator_rewind): Implement
+ #next and #rewind using the "generator" library.
- * string.c (rb_str_sub_bang): applied r14212 too.
+ * lib/generator.rb: Implement Enumerable::Enumerator#next and
+ #rewind.
-Wed Dec 19 20:40:01 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Apr 10 19:29:48 2008 Akinori MUSHA <knu@iDaemons.org>
- * bignum.c (bigmul1): C99ism.
+ * array.c (rb_ary_first, rb_ary_last): Return a shared array when
+ possible.
- * bignum.c (bigdivrem1): need dummy return value.
+ * 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.
-Wed Dec 19 19:18:06 2007 NARUSE, Yui <naruse@ruby-lang.org>
+Thu Apr 10 14:00:44 2008 Tanaka Akira <akr@fsij.org>
- * ext/nkf/nkf-utf8/nkf.c: Updated.
+ * lib/resolv.rb (Resolv::DNS#each_address): backport from 1.9 for
+ CNAME. [ruby-dev:34200]
- * ext/nkf/nkf.c (rb_nkf_enc_get): added.
- (find encoding or replicate default encoding)
+Thu Apr 10 01:42:25 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/nkf/nkf.c (NKF::<ENCODING>): redefine encoding constant.
+ * enum.c (iterate_method): add prototype to avoid warning on VC++.
- * ext/nkf/lib/kconv.rb (Kconv::<ENCODING>): redefined as Encoding.
+Wed Apr 9 23:12:41 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/nkf/lib/kconv.rb: refactoring.
+ * ext/tk/tcltklib.c: SEGV when tcltk-stubs is enabled.
-Wed Dec 19 19:11:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/tcltklib.c: avoid error on a shared object.
- * bignum.c (rb_big_mul0): blocking check for bigger numbers.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-dev:32632].
+ * ext/tk/extconf.rb: support --with-tcltkversion
- * bignum.c (bigdivrem): ditto.
+ * ext/tk/README.tcltklib: add document about --with-tcltkversion
-Wed Dec 19 17:34:50 2007 Koichi Sasada <ko1@atdot.net>
+ * 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.
- * compile.c (iseq_compile_each): remove "retry" in block.
- ("iter{retry}" cause syntax error)
- Currently, "begin; ...; rescue; iter{retry}; end" cause
- syntax error too.
+Wed Apr 9 21:54:45 2008 Akinori MUSHA <knu@iDaemons.org>
- * bootstraptest/test_jump.rb: ditto.
+ * array.c (rb_ary_pop): Do not reallocate too often; backported
+ from 1.9.
- * lib/drb/invokemethod.rb: ditto.
+Wed Apr 9 21:13:05 2008 Akinori MUSHA <knu@iDaemons.org>
- * sample/drb/darrayc.rb: ditto.
+ * 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.
- * sample/test.rb: ditto.
+Wed Apr 9 20:47:16 2008 Akinori MUSHA <knu@iDaemons.org>
- * test/drb/drbtest.rb: ditto.
+ * array.c (rb_ary_index, rb_ary_index): Array#index and #rindex
+ can take a block instead of an argument; backported from 1.9.
- * test/ruby/test_iterator.rb: ditto.
+Wed Apr 9 19:58:31 2008 Akinori MUSHA <knu@iDaemons.org>
- * sample/test.rb: add a 'test' directory on the SYSTEM test.
+ * enumerator.c, inits.c (rb_call_inits), ruby.h, intern.h,
+ ext/enumerator, common.mk (OBJS, enumerator.$(OBJEXT)): Make the
+ enumerator module built-in.
-Wed Dec 19 17:12:59 2007 Koichi Sasada <ko1@atdot.net>
+ * enumerator.c: New method: Enumerable::Enumerator#with_index.
- * bootstraptest/test_knownbug.rb, test_block.rb:
- move fixed bug.
+ * 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.
- * bootstraptest/test_m17n.rb: added.
+Wed Apr 9 19:43:51 2008 Akinori MUSHA <knu@iDaemons.org>
-Wed Dec 19 16:59:55 2007 Koichi Sasada <ko1@atdot.net>
+ * eval.c (rb_obj_method, rb_proc_call), intern.h: Export.
- * eval.c (errinfo_place): skip if error is Fixnum. [ruby-dev:32608]
+Tue Apr 8 11:11:28 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bootstraptest/test_exception.rb, test_known_bug.rb: move fixed bug.
+ * eval.c (EXEC_TAG): remove unnecessary FLUSH_REGISTER_WINDOWS for
+ better performance on SPARC. [ruby-core:16159]
-Wed Dec 19 16:31:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Apr 8 10:49:54 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (reg_named_capture_assign_iter): remove C99 dependency.
+ * re.c (rb_reg_quote): should always copy the quoting string.
+ [ruby-core:16235]
- * parse.y (reg_named_capture_assign_iter): get rid of creating
- unnecessary ID.
+Mon Apr 7 21:35:08 2008 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (rb_enc_symname2_p): check for non-nul-terminated string.
+ * array.c (rb_ary_nitems): Backport Array#nitems with a block;
+ suggested by Bertram Scharpf <lists@bertram-scharpf.de> in
+ [ruby-talk:134083].
-Wed Dec 19 15:37:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Apr 6 09:45:00 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * insnhelper.ci (vm_yield_with_cfunc): call cfunc with
- (argv[0], data, argc, argv) to pass all arguments.
+ * dir.c (dir_tell): check if closed. [ruby-core:16223]
- * enumerator.c (enumerator_each_i): adapted to new calling
- convention.
+Sat Apr 5 10:05:00 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Dec 19 15:13:20 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * object.c (rb_check_to_integer): backported for range_step.
- * string.c (rb_str_justify): should propagate encoding from pad
- string too.
+Fri Apr 4 05:57:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Dec 19 13:57:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/net/pop.rb (Net::POP3::do_finish): clear @n_mails and
+ @n_bytes as well. [ruby-core:16144]
- * configure.in (TIMEZONE_VOID): check whether timezone requires zero
- arguments. [ruby-dev:32631]
+Fri Apr 4 02:17:06 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Dec 19 13:22:14 2007 NARUSE, Yui <naruse@ruby-lang.org>
+ * range.c (range_step): should not round step into integer if
+ begin and end are numeric. [ruby-core:15990]
- * ext/nkf/nkf.c (NKF::_ENCODING): removed.
+Tue Apr 1 14:43:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/nkf/nkf.c (rb_nkf_kconv): renamed to rb_nkf_convert.
+ * configure.in: get rid of empty expansion.
- * ext/nkf/nkf.c (rb_nkf_convert): set encoding.
+ * {bcc,win}32/Makefile (config.h): need to define RUBY_SETJMP, etc.
- * ext/nkf/nkf.c (rb_nkf_guess1): removed.
+Tue Apr 1 11:36:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/nkf/nkf.c (rb_nkf_guess2): renamed to rb_nkf_guess.
+ * configure.in: _setjmp is available but _longjmp is not on mingw.
- * ext/nkf/nkf.c (rb_nkf_guess):
- guess method now returns encoding object.
+Tue Apr 1 03:20:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/nkf/nkf-utf8/nkf.c: Update to nkf 2.0.8 2007-12-19.
+ * configure.in (RUBY_SETJMP, RUBY_LONGJMP, RUBY_JMP_BUF): prefers
+ _setjmp over setjmp and sigsetjmp. [ruby-core:16023]
+ __builtin_setjmp cannot handle a variable.
-Wed Dec 19 10:52:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * configure.in (--with-setjmp-type): new option to override the
+ default rule in the above.
- * bignum.c (rb_cstr_to_inum): an underscore succeeding after octal
- prefix is allowed. [ruby-core:14139]
+ * 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.
-Wed Dec 19 00:09:19 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Apr 1 01:55:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bignum.c (rb_cstr_to_inum): wrong radix check. a patch from
- Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-dev:32628].
+ * lib/resolv.rb (Resolv::Config.default_config_hash): requires
+ win32/resolv to use Win32::Resolv. [ruby-dev:34138]
- * bignum.c (big2str_find_n1): ditto.
+Mon Mar 31 14:51:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Dec 18 23:53:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * bignum.c (rb_big_div): Bignum#div should return integer for
+ floating number operand.
- * compile.c (iseq_compile_each): fix for segfault. [ruby-dev:31372]
+Sun Mar 30 07:00:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 18 23:44:32 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * ext/tk/tcltklib.c: rb_hash_lookup has not been backported yet.
- * test/net/http/utils.rb: split TestNetHTTPUtils module from
- test/net/http/test_http.rb. and start HTTP server in each test case.
+Sat Mar 29 14:18:41 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Dec 18 23:27:51 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
- * lib/webrick/server.rb (WEBrick::GenericServer#accept_client):
- should rescue Errno::EINVAL from TCPServer#accept. this exception
- might occur if the server socket is not in ready to listen.
+ * 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'".
- * lib/webrick/server.rb (WEBrick::GenericServer#accept_client):
- don't call TCPServer#close if the :ShutdownSocketWithoutClose is set.
+ * 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".
- * lib/webrick/config.rb (WEBrick::Config::General): add new parameter
- :ShutdownSocketWithoutClose.
+ * 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.
-Tue Dec 18 22:51:47 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * 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/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#shutdown):
- new method which calls TCPSocket#shutdown of the underlying socket.
+ * 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.
-Tue Dec 18 22:11:50 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
+ method instead of instate/state method.
- * lib/rss/parser.rb, lib/rss/atom.rb, lib/rss/rss.rb,
- test/rss/rss-assertions.rb, test/rss/test_atom.rb: use
- pack/unpack("m") instead of base64 library.
+ * 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)".
- * lib/webrick/httpproxy.rb: use delete("\n") instead of chomp/chop
- because the result of pack("m") might be multi-line.
+ * ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
+ a character code on Ruby1.9).
-Tue Dec 18 22:12:35 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/tk/lib/tk/variable.rb: support new style of operation argument
+ on Tcl/Tk's 'trace' command for variables.
- * insnhelper.ci, vm.c: rewrite sp manipulation around method/block
- invocation. [ruby-dev:32547]
+ * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
-Tue Dec 18 22:11:23 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/tk/sammple/demos-jp/textpeer.rb,
+ ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
- * ext/dl/win32/lib/win32/sspi.rb: use pack/unpack("m") instead of
- base64 library which was already removed.
+ * ext/tk/tcltklib.c: decrase SEGV troubles (probably)
-Tue Dec 18 21:09:23 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
- * vm.c (invoke_block): merge 2 stack overflow checks.
+ * ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
-Tue Dec 18 20:58:35 2007 Koichi Sasada <ko1@atdot.net>
+ * 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__)
- * compile.c, insnhelper.ci, insns.def, object.c, vm.c, vm.h:
- optimize !@, != method invocation.
+ * 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.
- * id.c, id.h: ditto.
+ * ext/tk/lib/tkextlib/tile/style.rb: ditto.
+ (Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
- * bootstraptest/test_syntax.rb: add tests for above.
+ * 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.
-Tue Dec 18 18:10:05 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
- * bootstraptest/test_knownbug.rb: add issues.
+ * 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.
-Tue Dec 18 20:22:44 2007 Tanaka Akira <akr@fsij.org>
+ * ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
- * parse.y (arg tMATCH arg): call reg_named_capture_assign_gen if regexp
- literal is used.
- (reg_named_capture_assign_gen): assign the result of named capture
- into local variables.
- [ruby-dev:32588]
+Sat Mar 29 04:08:59 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * re.c: document the assignment by named captures.
+ * class.c (clone_method): should copy cref as well.
+ [ruby-core:15833]
-Tue Dec 18 18:09:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Mar 24 20:07:42 2008 Akinori MUSHA <knu@iDaemons.org>
- * string.c (rb_str_splice): propagate encoding.
+ * eval.c (rb_eval): Call trace hook for if expression after the
+ condition has been evaluated, not before; submitted by Rocky
+ Bernstein in #18722.
- * string.c (rb_str_subpat_set): ditto.
+Mon Mar 24 19:44:53 2008 Akinori MUSHA <knu@iDaemons.org>
-Tue Dec 18 17:27:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * parse.y (yycompile): Always prepare a new array for each file's
+ SCRIPT_LINES__ storage, instead of appending source lines every
+ time a file is re-loaded; submitted by Rocky Bernstein in
+ #18517.
- * object.c (rb_obj_freeze): preserve frozen state of immediate
- values in internal hash table, a la generic_ivar.
+Mon Mar 24 10:25:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * object.c (rb_obj_frozen_p): check immediate values too.
+ * configure.in: sitearch should use target_cpu. [ruby-core:15986]
- * variable.c (generic_ivar_set): add frozen check fro immediate
- values.
+Mon Mar 24 01:24:24 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Dec 18 17:04:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/erb.rb (result): use proc instead of Thread. [ruby-dev:33692]
- * transcode.c (rb_str_transcode_bang, rb_str_transcode): set new
- encoding even if no conversion is done because of 7bit only.
- [ruby-dev:32591]
+Fri Mar 21 21:26:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 18 15:43:59 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/resolv.rb (Resolv::Hosts): should not use win32/resolv on cygwin.
+ [ruby-dev:29945], [ruby-dev:34095]
- * common.mk (encs, ext/ripper/ripper.c): other options must come
- before MAKEFLAGS in GNU make.
+ * lib/win32/registry.rb (Win32::Registry.expand_environ): try upcased
+ name too for cygwin. [ruby-dev:29945]
-Tue Dec 18 15:19:55 2007 Eric Hodel <drbrain@segment7.net>
+ * lib/win32/resolv.rb (Win32::Resolv.get_hosts_path): use expand_path.
- * lib/rdoc/parsers/parse_rb.rb: Don't call private fail anymore.
+Fri Mar 21 21:10:00 2008 Akinori MUSHA <knu@iDaemons.org>
-Tue Dec 18 15:17:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/ipaddr.rb: Say that I am the current maintainer.
- * common.mk (encs, ext/ripper/ripper.c): pass MAKEFLAGS.
+ * lib/set.rb: Ditto.
-Tue Dec 18 14:45:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/shellwords.rb: Ditto.
- * parse.y (op_tbl): remove duplication to avoid symbol aliases.
+ * ext/syslog/syslog.txt: Ditto.
-Tue Dec 18 14:39:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Mar 21 09:24:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (str_nth): need not to raise out-of-range exception.
+ * instruby.rb (open_for_install): write block result and rewrite only
+ if changed from existing file.
- * test/ruby/test_m17n.rb (TestM17N::test_str_aref_len): removed
- debug print.
+Wed Mar 19 21:01:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 18 14:05:23 2007 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]
- * enc/depend: get rid of target expanded as empty for nmake.
+Wed Mar 19 20:25:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 18 07:56:57 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * dir.c (Init_Dir): define inspect method. [ruby-core:15960]
- * proc.c (rb_obj_public_method): Object#public_method to retrieve
- public method object.
+Wed Mar 19 14:59:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * proc.c (rb_mod_public_instance_method): Module#public_instance_method
- to retrieve public instance method from class / module.
-
- * proc.c (mnew): visibility check added.
+ * misc/ruby-style.el (ruby-style-{case,label}-indent): fix for labels
+ inside blocks in switch and function top level.
- * eval_error.ci (rb_print_undef): add rb_ prefix.
+Wed Mar 19 14:36:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval_error.ci (rb_print_undef): add visibility in the error
- message.
+ * bignum.c (rb_cstr_to_inum): treat successive underscores as
+ nondigit. [ruby-dev:34089]
-Tue Dec 18 05:54:26 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Mar 19 00:01:23 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/Env.rb, lib/base64.rb, lib/importenv.rb, lib/eregex.rb: removed.
+ * lib/erb.rb (ERB::Compiler): Make some minor code optimization.
- * lib/ping.rb, lib/readbytes.rb: removed
+Mon Mar 17 17:11:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 18 02:30:56 2007 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]
- * configure.in (BUILTIN_ENCS): removed.
+Mon Mar 17 16:41:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * common.mk (enc.mk): pass BUILTIN_ENCS from command line.
+ * configure.in: unset GREP_OPTIONS. [ruby-core:15918]
- * enc/depend: ditto.
+Fri Mar 14 16:59:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enc/make_encmake.rb: ditto.
+ * configure.in (RUBY_LIB_PREFIX): fix for prefix.
-Tue Dec 18 01:46:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Mar 14 16:35:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sprintf.c (rb_str_format): need to clear output buffer to avoid
- broken encoding compatibility check.
+ * lib/cgi.rb (CGI::Cookie::initialize): performance patch from
+ Makoto Kuwata <kwa@kuwata-lab.com> in [ruby-dev:34048].
-Tue Dec 18 01:40:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 14 15:49:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/mkmf.rb (depend_rules): inserts ruby to only headers.
+ * configure.in (RUBY_LIB_PREFIX): use libdir.
-Tue Dec 18 01:21:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Mar 14 10:12:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (parser_encode_length): chomp eol style modifiers.
+ * configure.in (RUBY_CHECK_VARTYPE): should not indent preprocessor
+ directives.
- * parse.y (parser_magic_comment): ditto.
+Thu Mar 13 00:37:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (set_file_encoding): ditto.
+ * eval.c (rb_call0): yields the last executed node line number at
+ return event. [ruby-core:15855]
-Tue Dec 18 01:15:44 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Mar 12 02:12:20 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * common.mk (encs): added dependencies.
+ * lib/delegate.rb: check $@ to avoid NoMethodError.
- * enc/Makefile.in, enc/depend, enc/make_encmake.rb: moved serb code.
+Tue Mar 11 19:48:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/mkmf.rb (depend_rules): now takes content string, not file name.
+ * numeric.c (fix_coerce): try conversion before type check.
+ [ruby-core:15838]
- * win32/enc-setup.mak: overrides default target.
+Tue Mar 11 17:03:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 18 00:26:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/delegate.rb (Delegator#initialize, DelegateClass): skip correct
+ backtrace. [ruby-dev:34019]
- * re.c (rb_reg_initialize): raise error if non-Unicode fixed
- encoding option is specified for regexp literals with \u{}
- escapes.
+Tue Mar 11 16:43:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_squeeze_bang): should squeeze multibyte
- characters as well.
+ * win32/win32.c (rb_w32_cmdvector): terminate shrunken command line.
-Mon Dec 17 21:41:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Mar 11 12:39:03 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/enc-setup.mak: extracts BUILTIN_ENCOBJS.
+ * common.mk (clean-local): removes MINOBJS.
- * tool/compile_prelude.rb: needs srcdir.
+Sat Mar 8 18:50:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 21:24:04 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * file.c (isdirsep): backslash is valid path separator on cygwin too.
- * common.mk (miniprelude.c): add -I$(srcdir).
+Fri Mar 7 19:56:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 20:53:27 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * lib/mkmf.rb: rdoc added. [ruby-Patches-9762]
- * ext/openssl/ossl_ssl.c (ossl_sslctx_set_ssl_version):
- new method OpenSSL::SSL::SSLContext#ssl_version to wrap
- SSL_CTX_set_ssl_version.
+Thu Mar 6 15:10:21 2008 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/openssl/ossl_ssl.c (ossl_ssl_get_verify_result):
- new method OpenSSL::SSL::SSLSocket#verify_result to wrap
- SSL_get_verrify_result.
+ * {bcc32,win32}/Makefile.sub (RUNRUBY): use $(PROGRAM) instead of
+ ruby$(EXEEXT).
+ suggested by KIMURA Koichi <kimura.koichi at canon.co.jp>.
+ [ruby-dev:34000]
- * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLContext.build):
- new method to build OpenSSL::SSL::SSLContext with Hash parameters.
- this method provides safety default parameters than SSLContext.new.
+Thu Mar 6 12:15:06 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL.verify_cetificate_identity):
- new module function: pull out identity verification process
- from OpenSSL::SSL::SSLSocket#post_connection_check.
+ * parse.y (opt_block_param): command can start just after block param
+ definition. [ruby-list:44479]
-Mon Dec 17 18:42:23 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Mar 6 00:34:11 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * string.c (scan_once): need no encoding compatibility check.
- it's done inside of re_reg_search().
+ * lib/erb.rb: update RDoc. Thanks Makoto Kuwata [ruby-dev:33702]
- * string.c (rb_str_split_m): ditto.
+Mon Mar 3 23:28:34 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * re.c (rb_reg_regsub): ditto.
+ * 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].
-Mon Dec 17 17:50:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/webrick/httpservlet/filehandler.rb: pathnames which have
+ not to be published should be checked case-insensitively.
- * string.c (rb_str_index): check if substring is broken.
+Mon Mar 3 16:14:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_rindex): ditto.
+ * hash.c (rb_any_hash): shrinks all results in Fixnum range.
+ [ruby-core:15713]
- * string.c (rb_str_succ): should carry over.
+Sat Mar 1 02:35:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 17:47:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * bignum.c (big2str_find_n1): check integer overflow.
- * common.mk (encs): new target to compile external encodings.
+Tue Feb 26 16:06:00 2008 Technorama Ltd. <oss-ruby@technorama.net>
- * enc/Makefile.in: became a serb template.
+ * ext/openssl/ossl_pkey_{ec,dh,dsa,rsa}.c: Remove useless warnings.
- * enc/make_encmake.rb: creates enc.mk from enc/Makefile.in using serb.
+ * ext/openssl/ossl_asn1.c: Simplify code.
- * lib/mkmf.rb (relative_from): moved from ext/extmk.rb.
+ * ext/openssl/ossl_ssl_session.c Fix compiler warnings.
+ Undefine #id if SSL_SESSION_get_id is not supported.
- * lib/mkmf.rb ($extmk): true if under to top source directory, not
- only ext.
+Tue Feb 26 15:43:42 2008 Tanaka Akira <akr@fsij.org>
- * lib/mkmf.rb (depend_rules): extracted from create_makefile.
+ * parse.y (tokadd_escape): refactored. [ruby-core:15657]
- * tool/serb.rb (serb): splitted from tool/compile_prelude.rb.
+Mon Feb 25 17:30:29 2008 Technorama Ltd. <oss-ruby@technorama.net>
-Mon Dec 17 17:32:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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.
- * configure.in (MAKEFILES): removed enc/Makefile.
+Mon Feb 25 13:40:03 2008 Tanaka Akira <akr@fsij.org>
- * configure.in (EXTERNAL_ENCOBJS, ENCSOS): removed.
+ * process.c (Init_process): share bignum objects for RLIM_INFINITY,
+ RLIM_SAVED_MAX and RLIM_SAVED_CUR if they are equal.
- * enc/Makefile.in (BUILTIN_ENCS): includes .c suffix.
+Sun Feb 24 23:29:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enc/depend: splitted from Makefile.in.
+ * common.mk, {bcc,win}32/Makefile.sub (clean-local): remove
+ intermediate files.
- * {bcc32,win32,wince}/setup.mak (-encs-): extracts BUILTIN_ENCOBJS.
+Sun Feb 24 03:52:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 17:07:53 2007 Tanaka Akira <akr@fsij.org>
+ * util.c (valid_filename): use O_EXCL to get rid of clobbering
+ existing files in race conditions.
- * string.c (rb_enc_str_asciionly_p): use rb_enc_str_coderange.
+Fri Feb 22 19:50:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 16:39:25 2007 Tanaka Akira <akr@fsij.org>
+ * bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
- * string.c (rb_enc_str_coderange): set ENC_CODERANGE_BROKEN using
- rb_enc_precise_mbclen.
- (rb_str_valid_encoding_p): just check coderange is
- ENC_CODERANGE_BROKEN or not.
+Fri Feb 22 16:09:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 16:04:16 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * bignum.c (rb_big_lshift, rb_big_rshift, rb_big_aref): removed excess
+ arguments.
- * ext/openssl/lib/openssl/buffering.rb (Buffering#gets): added second
- optional argument to specify maximum length limit.
+Thu Feb 21 00:01:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 16:02:30 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * configure.in (RPATHFLAG): -R option of HP-UX ld is not for runtime
+ load path. [ruby-list:44600]
- * lib/webrick/httprequest.rb, lib/webrick/cgi.rb: Request-Line or
- header fields shold be read with maximum length. [ruby-talk:231745]
+Wed Feb 20 23:55:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 17 14:03:39 2007 Tanaka Akira <akr@fsij.org>
+ * win32/win32.c (rb_w32_map_errno): exported.
- * include/ruby/encoding.h (ENC_CODERANGE_VALID): rename from
- ENC_CODERANGE_8BIT.
+Wed Feb 20 13:08:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_enc_str_coderange): follow the renaming.
+ * instruby.rb (parse_args): added --dir-mode, --script-mode and
+ --cmd-type options. [ruby-dev:33816]
-Mon Dec 17 13:56:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * instruby.rb (parse_args): added bin-arch and bin-comm to install
+ type, for compiled files and script files.
- * string.c (tr_find): wrong condition fixed.
+ * instruby.rb (parse_args): deal with make style command line macros,
+ and count as long syle options if prefixed with INSTALL_.
- * sprintf.c (rb_str_format): check encoding based on result, not
- the format string.
+ * instruby.rb (makedirs): use $dir_mode. [ruby-dev:33805]
- * string.c (rb_str_upto): add encoding check.
+ * instruby.rb (open_for_install): set file mode, which is now
+ permission mode instead of access mode.
-Mon Dec 17 12:21:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * instruby.rb (bin-comm): installs scripts with replacing shebang
+ lines.
- * Makefile.in (RUNRUBY): added RUNRUBYOPT.
+Tue Feb 19 18:34:32 2008 Tanaka Akira <akr@fsij.org>
-Mon Dec 17 11:38:59 2007 Tanaka Akira <akr@fsij.org>
+ * gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]
- * thread_win32.ci (native_thread_create): initialize
- th->machine_stack_maxsize as rb_gc_stack_maxsize.
+Tue Feb 19 14:27:32 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Dec 16 17:07:35 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * ext/readline/readline.c (readline_event): prevent polling. based on
+ a patch from error errorsson in [ruby-Bugs-17675].
- * transcode.c (transcode_loop): removed special case (-1)
- for undefined conversions.
+Tue Feb 19 12:08:29 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * transcode_data_iso_8859.c: Changed from character constants
- ('\xC2') to integer contants (0xC2) for shorter files and
- better readability; eliminated duplicated tables; changed
- from -1 offset to actual UNDEF entry (not yet distinguishing
- UNDEF and ILLEGAL correctly).
+ * parse.y (yycompile): clear ruby_eval_tree_begin if parse failed.
- * test/ruby/test_transcode.rb: added a test for UNDEF conversion.
+Mon Feb 18 16:23:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Dec 16 14:51:59 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * parse.y (yycompile): clear ruby_eval_tree_begin too before parse.
- * configure.in (MAKEFILES): should be enc/Makefile, not GNUmakefile.
- [ruby-dev:32609]
+Mon Feb 18 10:17:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in (BUILTIN_ENCS): removed escapes for OpenBSD.
+ * ext/pty/lib/expect.rb (IO#expect): check if peer is closed.
+ [ruby-Bugs-17940]
-Sat Dec 15 23:58:46 2007 Tanaka Akira <akr@fsij.org>
+Fri Feb 15 20:37:06 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * test/openssl/test_pair.rb (SSLPair#ssl_pair): join the thread, even
- on an error.
+ * lib/rational.rb (floor, ceil, truncate, round): do not use
+ definitions of Numeric.
-Sat Dec 15 23:50:31 2007 Tanaka Akira <akr@fsij.org>
+ * lib/rational.rb (to_i): should returns truncated self.
- * test/xmlrpc/webrick_testing.rb: join webrick server thread.
+ * lib/complex.rb (numerator): requires
+ Integer#{numerator,denominator}.
-Sat Dec 15 22:27:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/complex.rb (quo): do not use definition of Numeric.
- * configure.in (BUILTIN_ENCS): splitted command line instead of
- semicolons for Solaris.
+ * lib/complex.rb (div, divmod, floor, ceil, truncate, round):
+ undef'ed.
-Sat Dec 15 21:38:24 2007 Tanaka Akira <akr@fsij.org>
+Fri Feb 15 15:23:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/timeout.rb: join the background thread to make sure it is dead.
+ * ext/iconv/iconv.c (iconv_convert): check upper bound. a patch from
+ Daniel Luz at [ruby-Bugs-17910].
-Sat Dec 15 20:20:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Feb 15 02:42:25 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in (enc/Makefile): add external encoding objects list.
+ * configure.in (ftruncate): check if available.
- * common.mk (BUILTIN_ENCOBJS): renamed from ENCOBJS.
+ * file.c (rb_file_truncate): check if ftruncate instead of truncate.
- * configure.in (BUILTIN_ENCS): [] needs to be enclosed because of m4.
+Fri Feb 15 02:40:54 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * Makefile.in (BUILTIN_ENCOBJS): substitued by autoconf.
+ * configure.in (sigsetmask): check when signal semantics is not POSIX.
- * enc/Makefile.in: new file to compile external encoding sources.
+ * signal.c (USE_TRAP_MASK): set true if sigprocmask or sigsetmask is
+ available.
- * encoding.c (rb_enc_find_index): auto-load external encoding objects
- as "ext/ENCODING_NAME". [ruby-dev:32606]
+Thu Feb 14 17:44:32 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 15 13:04:30 2007 Tanaka Akira <akr@fsij.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].
- * vm_core.h (rb_thread_t): new member machine_stack_maxsize and
- machine_register_stack_maxsize.
+Thu Feb 14 16:02:51 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * gc.c (rb_gc_stack_maxsize): new global variable for the thread size
- of the main thread.
- (STACK_LEVEL_MAX): use machine_stack_maxsize of current thread.
- (ruby_stack_check): check IA64 register stack.
- (ruby_set_stack_size): set rb_gc_stack_maxsize.
- (Init_stack): set rb_gc_stack_maxsize.
+ * file.c (rb_file_s_utime): inhibits with secure level 2 or higher.
- * thread_pthread.ci (native_thread_create): initialize
- th->machine_stack_maxsize and th->machine_register_stack_maxsize.
+Thu Feb 14 01:43:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * vm.c (Init_BareVM): initialize th->machine_stack_maxsize and
- th->machine_register_stack_maxsize.
+ * lib/timeout.rb (Timeout::timeout): made sensitive to location on the
+ stack. [ruby-core:15458]
- * thread_win32.ci (native_thread_create): initialize
- th->machine_stack_maxsize. not tested. just a guess at all.
+Thu Feb 14 00:49:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- [ruby-dev:32604]
+ * common.mk (INSTRUBY_ARGS): pass mode to install. [ruby-dev:33766]
-Sat Dec 15 12:58:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * instruby.rb (parse_args): added --data-mode and --prog-mode options.
- * encoding.c (rb_enc_register, rb_enc_replicate, rb_enc_alias): check
- if already registered.
+Tue Feb 12 11:33:26 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Sat Dec 15 01:57:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * test/erb/test_erb.rb(TestERBCore): import from erb-2.0.4.
- * lib/rdoc/options.rb (Options::parse): do not access $KCODE any
- longer. [ruby-core:14079]
+ * test/erb/hello.erb: ditto
- * lib/irb/init.rb (IRB::IRB.parse_opts): ditto.
+Mon Feb 11 17:25:21 2008 Kouhei Sutou <kou@cozmixng.org>
- * lib/cgi.rb (CGI::CGI): ditto.
+ * lib/rss/rss.rb (RSS::VERSION), test/rss/test_version.rb, NEWS:
+ 0.2.3 -> 0.2.4.
-Fri Dec 14 18:18:31 2007 Tanaka Akira <akr@fsij.org>
+ * 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!!!
- * thread_pthread.ci (native_thread_create): twice the stack size.
- 512KB is not enough to complete test-all on Debian GNU/Linux on
- IA64.
-
-Fri Dec 14 16:10:50 2007 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.
- * io.c (rb_f_p): RDoc update. a patch from murphy <murphy AT rubychan.de>.
- [ruby-core:14010]
+Mon Feb 11 16:57:00 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Fri Dec 14 16:06:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ChangeLog: format-time-string under C locale. [ruby-dev:33261]
- * string.c (rb_str_cmp): encoding aware comparison.
+Mon Feb 11 16:31:47 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
- * string.c (rb_str_casecmp): ditto.
+ * gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
+ Submitted by Sylvain Joyeux [ruby-core:12099].
-Fri Dec 14 15:25:30 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
+ * ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
+ Slightly modified fix bassed on a patch by Sylvain Joyeux
+ [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
+ [ ruby-patches-13151 ].
- * transcode.c (encoding_equal): new function.
+Mon Feb 11 00:22:55 2008 NARUSE, Yui <naruse@ruby-lang.org>
- * transcode.c (str_transcode, transcode_dispatch): added two-step
- conversion logic via UTF-8.
+ * lib/benchmark.rb (Job::Benchmark#item): fix typo.
- * trancode.c: some minor formatting fixes
+Sat Feb 9 23:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * transcode_data.h, transcode_data_iso_8859.c: Shortened
- extremely frequently used macros to shorten file length.
+ * ext/bigdecimal/extconf.rb: simplified the condition.
- * test/ruby/test_transcode.rb: Fixed name of test class;
- added setup method to ensure all necessary encodings exist;
- split tests into more test methods; added tests; fixed ordering
- of arguments in assert_equal to have expected result first.
+Sat Feb 9 17:51:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Dec 14 13:47:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): use strtod() for more
+ precision. [ruby-talk:290296]
- * common.mk (ruby.imp): fix for circular dependency. a patch from
- Yutaka Kanemoto <kinpoco AT gmail.com> in [ruby-dev:32590].
+ * ext/bigdecimal/bigdecimal.c (BASE_FIG): made constant.
- * regint.h, st.c, ext/json/ext/generator/generator.c: suppress
- warnings on AIX.
+ * ext/bigdecimal/extconf.rb: ditto. [ruby-dev:33658]
-Fri Dec 14 12:36:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Feb 9 00:44:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in (RUBY_CHECK_VARTYPE): check if a variable is defined
- and its type.
+ * lib/irb.rb (IRB::Irb::eval_input): rescues Interrupt and other than
+ SystemExit and SignalException. [ruby-core:15359]
- * configure.in (timezone, altzone): check for recent cygwin.
+Fri Feb 8 15:09:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * missing/strftime.c (strftime): fix for timezone. [ruby-dev:32536]
+ * lib/mkmf.rb (xsystem): expand macros like as make.
- * lib/mkmf.rb (try_var): should fail for functions.
+Tue Feb 5 11:14:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/readline/extconf.rb: should use have_func for functions instead
- of have_var.
+ * lib/mkmf.rb (INSTALL_DIRS, install_dirs): added BINDIR.
-Fri Dec 14 10:25:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/mkmf.rb (install_files): rejects files matching to
+ $NONINSTALLFILES.
- * lib/e2mmap.rb (Exception2MessageMapper::E2MM.Raise): $! no
- longer modifiable in 1.9.
+ * lib/mkmf.rb (init_mkmf): defaults $NONINSTALLFILES to backup and
+ temporary filse.
-Fri Dec 14 08:17:24 2007 Tanaka Akira <akr@fsij.org>
+Mon Feb 4 16:44:24 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_protect): restore root_jmpbuf even if proc exits by
- break such as dbm.delete_if { break }.
+ * configure.in (darwin): NSIG is not defined if _XOPEN_SOURCE > 500L.
+ [ruby-dev:33584]
-Fri Dec 14 02:55:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Feb 2 20:06:42 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_nth): direct jump if string is 7bit only. great
- performance boost for worst case.
+ * lib/benchmark.rb (Benchmark::realtime): make Benchmark#realtime
+ a bit faster. a patch from Alexander Dymo <dymo AT ukrpost.ua> in
+ [ruby-core:15337].
- * string.c (str_strlen): direct size if string is 7bit only.
+Sat Feb 2 09:53:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Dec 14 02:29:32 2007 Yukihiro Matsumoto <matz@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.
- * encoding.c (rb_enc_compatible): 1st argument (typically the
- receiver) would have higher priority in encoding detection.
+Fri Feb 1 21:42:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Dec 14 02:05:42 2007 Yukihiro Matsumoto <matz@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]
- * io.c (rb_io_synchronized): should check if initialized.
- [ruby-dev:32585]
+ * configure.in (darwin): ucontext on PowerPC MacOS X 10.5 is broken.
-Fri Dec 14 00:54:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jan 31 08:31:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (rb_reg_initialize): embedded string may override encoding
- of the regular expression.
+ * common.mk (ext/extmk.rb, instruby.rb): inlined $(MAKE) so that can
+ be executed even with -n.
- * re.c (rb_reg_initialize): fix encoding of regular expression if
- embedded string has its own encoding specified.
+Thu Jan 31 07:00:19 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Thu Dec 13 22:16:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rinda/tuplespace.rb (bin_for_find): should find a symbol by
+ Symbol class.
- * encoding.c (rb_enc_compatible): encoding should never fall back
- to ASCII-8BIT unless both encodings are ASCII-8BIT.
+ * test/rinda/test_rinda.rb (test_symbol_tuple): ditto.
-Thu Dec 13 20:31:28 2007 Tanaka Akira <akr@fsij.org>
+Wed Jan 30 22:07:58 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * string.c (rb_str_shared_replace): make str noembed after free.
+ * lib/date.rb: refined deprecated methods.
-Thu Dec 13 20:09:09 2007 Tanaka Akira <akr@fsij.org>
+Wed Jan 30 22:06:54 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * eval.c (rb_protect): restore root_jmpbuf to avoid SEGV by
- 'IO.pipe; [].each.next' with gcc version 3.3.5 (Debian 1:3.3.5-13)
- on IA64.
+ * bignum.c (rb_cstr_to_inum): '0_2' is a valid representation.
-Thu Dec 13 17:51:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Jan 29 22:40:12 2008 Yusuke Endoh <mame@tsg.ne.jp>
- * string.c (rb_str_split_m): need not to check encoding if regexp
- is empty.
+ * range.c (step_i): rb_funcall receives VALUE as an argument.
- * string.c (rb_str_justify): associate encoding of original to the
- result.
+Tue Jan 29 11:53:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_chomp_bang): need to check encoding of record
- separator.
+ * configure.in: rm largefile.h.
- * string.c (str_gsub): should copy encoding to the result.
+Mon Jan 28 01:21:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sprintf.c (rb_str_format): ditto.
+ * io.c (rb_open_file): should check NUL in path.
+ <http://www.rubyist.net/~matz/20080125.html#c01>.
- * string.c (rb_str_succ): should not enter infinite loop for
- non-ASCII, non-alphanumeric character at the bottom.
+ * io.c (rb_io_s_popen): ditto.
-Thu Dec 13 17:03:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * io.c (rb_io_reopen): ditto.
- * encoding.c (rb_enc_compatible): should swap encoding indexes too.
+ * io.c (next_argv): ditto.
-Thu Dec 13 16:41:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (rb_io_s_foreach): ditto.
- * encoding.c (rb_enc_compatible): should not judge compatibility
- based on rb_enc_asciicompat().
+ * io.c (rb_io_s_readlines): ditto.
-Thu Dec 13 13:09:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (rb_io_s_read): ditto.
- * include/ruby/io.h (MakeOpenFile): fptr->enc should be
- intialized to zero. [ruby-dev:32569]
+Fri Jan 25 22:33:38 2008 Yusuke Endoh <mame@tsg.ne.jp>
-Thu Dec 13 08:56:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * math.c: fix comment. [ruby-dev:33276]
- * io.c (rb_io_getc): use default external encoding if fptr->enc is
- not set. [ruby-dev:32565]
+Fri Jan 25 10:31:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rubygems/package.rb (Gem::TarReader::Entry::rewind): typo fixed.
- [ruby-dev:32565]
+ * */*.bat: set svn:mime-type to text/batch.
-Thu Dec 13 08:24:16 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jan 24 19:36:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (read_all): should associate default external encoding.
+ * lib/uri/generic.rb (URI::Generic::inspect): use Kernel#to_s instead
+ object_id with printf. [ruby-dev:33347]
- * io.c (io_read): should NOT associate default external encoding.
+Tue Jan 22 11:22:47 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Dec 12 23:22:58 2007 Tanaka Akira <akr@fsij.org>
+ * win32/setup.mak ($(ARCH)): if a macro is appended by $(APPEND),
+ a space will be inserted on the top of the line.
- * re.c, regerror.c, string.c, parse.y, ruby.c, file.c:
- use capital letter for \xHH notation. [ruby-dev:32511]
+ * win32/Makefile.sub (MKFILES): stop make process if Makefile is
+ updated.
-Wed Dec 12 22:21:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Jan 21 17:34:41 2008 Akinori MUSHA <knu@iDaemons.org>
- * io.c (rb_io_mode_enc): allow specifying external encoding in
- open mode, e.g. open(path, "r:utf-8").
+ * io.c (rb_io_mode_flags, rb_io_mode_modenum): Ignore encoding
+ options for forward compatibility.
-Wed Dec 12 21:26:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Jan 21 12:50:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval_method.ci (rb_alias): no need to skip aliasing when new
- equals to old. [ruby-core:13990]
+ * eval.c, gc.c (setjmp): sigsetjmp is a macro on cygwin.
-Wed Dec 12 16:34:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Jan 19 11:21:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_check_readable): set default external encoding to
- STDIN.
+ * configure.in (sigsetjmp): check if available.
- * io.c (io_enc_str): associate encoding to output string.
+ * eval.c, gc.c (setjmp): do not use _setjmp if sigsetjmp is available.
-Wed Dec 12 12:44:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Jan 19 11:10:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (expr): 'not' and '!' should act as conditional
- expression. [ruby-dev:32548]
+ * configure.in: Remove wrong assumptions about Cygwin. a patch from
+ Corinna Vinschen in [ruby-Bugs-17018].
-Wed Dec 12 12:11:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Jan 17 21:06:01 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * re.c (rb_reg_regsub): should copy encoding.
+ * 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.
- * string.c (rb_str_sub_bang, str_gsub): should check and copy encoding
- to be replaced.
+ * lib/date.rb, lib/date/format.rb: some trivial changes.
-Tue Dec 11 23:04:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Jan 15 15:09:28 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * pack.c (pack_pack): RDoc update. a patch from Gary Wright
- <radar2002 AT gmail.com>. [ruby-core:13998]
+ * win32/setup.mak: strip out empty lines from CPP output.
- * pack.c (pack_unpack): ditto.
+Tue Jan 15 03:41:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 11 16:37:47 2007 Tanaka Akira <akr@fsij.org>
+ * eval.c (eval): check if backtrace is empty. [ruby-core:15040]
- * encoding.c (rb_enc_ascget): renamed from rb_enc_get_ascii.
+Tue Jan 15 01:28:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * include/ruby/encoding.h: follow the renaming.
+ * common.mk: simplified dummy objects dependencies.
- * re.c: ditto.
+Mon Jan 14 16:12:58 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Dec 11 16:19:26 2007 Nobuyoshi Nakada <nobu@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].
- * Makefile.in, */Makefile.sub (CP, MV): added.
+Mon Jan 14 09:32:40 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * common.mk (.y.c): not discard the old target until successfully
- created.
+ * lib/time.rb: do not reference Time directly from the inside of
+ definitions. [ruby-dev:33059]
-Tue Dec 11 15:20:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Jan 12 18:27:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * object.c (Init_Object): singleton_method_{added,removed,undefined}
- hooks should be defined for BasicObject. [ruby-dev:32531]
+ * eval.c (rb_define_alloc_func, rb_undef_alloc_func): should
+ define/undef on a signleton class. [ruby-core:09959]
- * eval.c (Init_eval): method_missing should be defined for all
- objects; moved to BasicObject.
+Sat Jan 12 12:04:14 2008 Tadayoshi Funaba <tadf@dotrb.org>
-Tue Dec 11 14:27:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/date.rb, lib/date/format.rb: tuning for performance.
- * transcode.c (transcode_loop): get rid of SEGV at sequence can not be
- converted.
+Fri Jan 11 12:35:56 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * transcode.c (rb_str_transcode_bang): copy encoding. [ruby-dev:32532]
+ * configure.in: moved broken syscall checks from process.c etc.
- * test/ruby/test_transcode.rb: added tests from Martin Duerst <duerst
- AT it.aoyama.ac.jp>. [ruby-dev:32532]
+ * defines.h (WORDS_BIGENDIAN): honor __BIG_ENDIAN__ than the result of
+ configure.
-Tue Dec 11 12:05:51 2007 Tanaka Akira <akr@fsij.org>
+ * dln.c: use dlopen on Mac OS X 10.3 or later. backport from trunk.
- * encoding.c (rb_enc_get_ascii): add an argument to provide the
- length of the returned character.
+ * lib/rdoc/options.rb (check_diagram): more precise check, darwin
+ is not Windows but minwg is on it.
- * include/ruby/encoding.h (rb_enc_get_ascii): add the argument.
+Thu Jan 10 10:53:50 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (rb_reg_expr_str): modify rb_enc_get_ascii call.
- (rb_reg_quote): ditto.
- (rb_reg_regsub): ditto.
+ * win32/win32.c (rb_w32_open_osfhandle): reverted to old definition.
+ [ ruby-Bugs-16948 ]
-Tue Dec 11 09:40:21 2007 Tanaka Akira <akr@fsij.org>
+Tue Jan 8 20:02:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * include/ruby/oniguruma.h (ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE):
- parenthesize an argument.
+ * win{32,ce}/Makefile.sub: merged.
-Tue Dec 11 02:23:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jan 6 09:39:02 2008 Tadayoshi Funaba <tadf@dotrb.org>
- * eval.c (rb_method_missing): RDoc update patch from Hugh Sasse
- <hgs AT dmu.ac.uk>. [ruby-core:12932]
+ * lib/date.rb, lib/date/format.rb: introduced some constants
+ (for internal use).
-Tue Dec 11 01:51:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * sample/cal.rb: trivial adjustments.
- * lib/net/http.rb (Net::HTTP::get): now supports gzip
- content-encoding. a patch from Hugh Sasse <hgs AT dmu.ac.uk>.
- [ruby-core:13451]
+Fri Jan 4 23:08:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 11 01:21:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * time.c (time_arg): use converted object. [ruby-core:14759]
- * parse.y (shadowing_lvar_gen): no duplicate error for "_".
+Fri Jan 4 01:20:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 10 22:08:47 2007 Akinori MUSHA <knu@iDaemons.org>
+ * win32.h: only VC6 needs extern "C++" for math.h. [ruby-talk:285660]
- * array.c (rb_ary_slice_bang): If an invalid range is given, do
- not raise an exception but return nil just like slice() does.
+Thu Jan 3 11:28:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 10 21:47:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * io.c (fptr_finalize): clear errno first. [ruby-talk:284492]
- * transcode.c (str_transcode): allow non-registered encodings.
- [ruby-dev:32520]
+Wed Jan 2 10:18:56 2008 Tadayoshi Funaba <tadf@dotrb.org>
-Mon Dec 10 21:00:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * sample/time.rb: use Process.times instead of Time.times.
- * 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]
+Wed Jan 2 09:18:11 2008 Tadayoshi Funaba <tadf@dotrb.org>
-Mon Dec 10 19:02:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * sample/goodfriday.rb: examples for date are enough. retired.
- * re.c (rb_reg_match): should calculate offset by converted
- operand. [ruby-cvs:21416]
+Wed Jan 2 09:06:55 2008 Tadayoshi Funaba <tadf@dotrb.org>
-Mon Dec 10 18:28:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * sample/cal.rb: just updated with the newest version.
- * 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]
+Mon Dec 31 06:50:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 10 17:46:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * trunk/common.mk: not use -I$(srcdir)/lib with $(MINIRUBY) for cross
+ compiling.
- * string.c (rb_str_tmp_new): creates hidden temporary buffer.
+ * configure.in, {win,bcc}32/Makefile.sub (MINIRUBY): -I$(srcdir)/lib
+ moved.
- * transcode.c (transcoding): added a pointer to function to flush.
+Sun Dec 30 22:48:37 2007 Tadayoshi Funaba <tadf@dotrb.org>
- * transcode.c (transcode_loop): do not use string internal.
- [ruby-dev:32512]
+ * lib/date.rb (_valid_time?): I'm not sure to recommend such an
+ expression. but anyway it is acceptable now. [ruby-core:14580]
- * transcode.c (str_transcode): allow Encoding objects.
+Fri Dec 28 16:36:33 2007 NARUSE, Yui <naruse@airemix.com>
- * transcode_data.h (BYTE_LOOKUP): use actual struct name.
+ * lib/resolv.rb (Resolv::DNS#each_address): now returns IPv6 address.
-Mon Dec 10 16:52:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Dec 28 13:21:32 2007 Kouhei Sutou <kou@cozmixng.org>
- * string.c (rb_str_insert): should not add length in bytes to index in
- chars.
+ * lib/rss/rss.rb, test/rss/test_version.rb, NEWS: 0.2.2 -> 0.2.3.
-Mon Dec 10 14:33:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/parser.rb, test/rss/test_parser.rb: supported "-" in tag name.
+ Reported by Ray Chen. Thanks.
- * eval.c (rb_f_public_send): rename invoke_method to public_send.
- it now invokes public method only no matter how it's called.
+Thu Dec 27 23:56:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 10 14:00:43 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * mkconfig.rb: should not use the libraries under the source directory
+ at cross compiling.
- * transcode.c: new file to provide encoding conversion features.
- code contributed by Martin Duerst.
+Thu Dec 27 11:02:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Dec 10 13:50:33 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]
- * re.c (rb_reg_search): return byte offset. [ruby-dev:32452]
+ * string.c (rb_str_lines, rb_str_bytes): ditto.
- * re.c (rb_reg_match, rb_reg_match2, rb_reg_match_m): convert byte
- offset to char index.
+Thu Dec 27 10:47:32 2007 Technorama Ltd. <oss-ruby@technorama.net>
- * string.c (rb_str_index): return byte offset. [ruby-dev:32472]
+ * ext/openssl/ossl_ssl.c: Only show a warning if the default
+ DH callback is actually used.
- * string.c (rb_str_split_m): calculate in byte offset.
+ * ext/openssl/ossl_rand.c: New method: random_add().
-Mon Dec 10 09:56:29 2007 Koichi Sasada <ko1@atdot.net>
+Wed Dec 26 22:27:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
- * benchmark/bm_vm1_neq.rb, bm_vm1_not.rb: added.
+ * lib/resolv.rb (Resolv::DNS::Name.==): fix for other is array of
+ Resolv::DNS::Label::Str.
-Mon Dec 10 07:48:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/resolv.rb (Resolv::DNS::MessageEncoder#put_label): String#string
+ is not defined, so replace to_s.
- * parse.y (parser_yylex): wrong token was generated. [ruby-dev:32498]
+ * lib/resolv.rb (Resolv::IPv6#to_name): ip6.int is obsoleted by
+ int.arpa.
- * object.c (rb_obj_not_match): wrong test.
+Mon Dec 24 16:18:57 2007 Eric Hodel <drbrain@segment7.net>
-Mon Dec 10 06:44:47 2007 Tanaka Akira <akr@fsij.org>
+ * lib/rdoc/ri/ri_options.rb: Fix ri --help listing of gem ri paths.
+ Merge of r14567 and r14569 from trunk.
- * re.c (rb_reg_expr_str): use \xHH instead of \OOO.
+ * lib/rdoc/ri/ri_paths.rb: Fix duplication of ri data for multiple
+ gems. Merge of r14567 from trunk
- * regerror.c (to_ascii): ditto.
- (onig_snprintf_with_pattern): ditto.
- (onig_snprintf_with_pattern): ditto.
+Mon Dec 24 12:35:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_inspect): ditto.
- (rb_str_dump): ditto.
+ * win{32,ce}/Makefile.sub (MFLAGS): defaulted to -l.
- * parse.y (parser_yylex): ditto.
+Mon Dec 24 11:56:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ruby.c (proc_options): ditto.
+ * {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.
- * file.c (rb_f_test): ditto.
+Sat Dec 22 14:49:46 2007 Tadayoshi Funaba <tadf@dotrb.org>
- [ruby-dev:32495]
+ * lib/date.rb: don't freeze nil even if 1.8 will not be aware of
+ the issue. [ruby-dev:32677]
-Mon Dec 10 06:41:00 2007 Tanaka Akira <akr@fsij.org>
+Wed Dec 19 13:57:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (rb_reg_names): new method Regexp#names.
- (rb_reg_named_captures): new method Regexp#named_captures
- (match_regexp): new method MatchData#regexp.
- (match_names): new method MatchData#names.
+ * configure.in (TIMEZONE_VOID): check whether timezone requires zero
+ arguments. [ruby-dev:32631]
- * lib/pp.rb (MatchData#pretty_print): show names of named captures.
+Wed Dec 19 12:01:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- [ruby-dev:32493]
+ * parse.y (f_rest_arg): check if duplicated. [ruby-core:14140]
-Mon Dec 10 01:35:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Dec 19 10:52:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (expr): redefinable not (!) operator.
+ * bignum.c (rb_cstr_to_inum): an underscore succeeding after octal
+ prefix is allowed. [ruby-core:14139]
- * parse.y (arg): ditto.
+Mon Dec 17 13:43:15 2007 Tanaka Akira <akr@fsij.org>
- * object.c (rb_obj_not): new method "!".
+ * 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.
- * object.c (rb_obj_not_equal): new method "!=".
+Mon Dec 17 12:21:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * object.c (rb_obj_not_match): new method "!~".
+ * Makefile.in (RUNRUBY): added RUNRUBYOPT.
-Sun Dec 9 22:31:36 2007 Tanaka Akira <akr@fsij.org>
+Fri Dec 14 12:36:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (rb_reg_s_last_match): accept named capture's name.
+ * configure.in (RUBY_CHECK_VARTYPE): check if a variable is defined
+ and its type.
-Sun Dec 9 15:57:53 2007 Tanaka Akira <akr@fsij.org>
+ * configure.in (timezone, altzone): check for recent cygwin.
- * re.c (match_backref_number): new function for converting a backref
- name/number to an integer.
- (match_offset): use match_backref_number.
- (match_begin): ditto.
- (match_end): ditto.
- (name_to_backref_number): raise IndexError instead of RuntimeError.
- (match_inspect): show capture index.
+ * missing/strftime.c (strftime): fix for timezone. [ruby-dev:32536]
-Sun Dec 9 14:59:15 2007 Koichi Sasada <ko1@atdot.net>
+ * lib/mkmf.rb (try_var): should fail for functions.
- * eval_intern.h (CHECK_STACK_OVERFLOW): reserve frame size.
- [ruby-dev:32485]
+ * ext/readline/extconf.rb: should use have_func for functions instead
+ of have_var.
-Sun Dec 9 14:38:25 2007 Koichi Sasada <ko1@atdot.net>
+Tue Dec 11 00:04:05 2007 Akinori MUSHA <knu@iDaemons.org>
- * vm.c (rb_thread_mark): use rb_gc_mark_maybe() for
- VM stack specified by mark_stack_len. [ruby-dev:32462]
+ * 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.
- * insnhelper.ci: clear vm stack extended by opt value.
+ * test/ruby/test_array.rb (TestArray::test_slice,
+ TestArray::test_slice!): Pull in test cases from trunk.
-Sun Dec 9 14:08:47 2007 Tanaka Akira <akr@fsij.org>
+Mon Dec 10 21:47:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * include/ruby/ruby.h (FilePathStringValue): defined. similar to
- FilePathValue but no taint check.
+ * transcode.c (str_transcode): allow non-registered encodings.
+ [ruby-dev:32520]
- * file.c (rb_get_path_no_checksafe): implementation of
- FilePathStringValue.
- (rb_file_s_basename): use FilePathStringValue.
- (rb_file_s_dirname): ditto.
- (rb_file_s_extname): ditto.
- (rb_file_s_split): ditto.
- (rb_file_join): ditto.
+Mon Dec 10 21:00:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * dir.c (file_s_fnmatch): ditto.
+ * 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]
-Sun Dec 9 12:49:34 2007 Tanaka Akira <akr@fsij.org>
+Mon Dec 10 18:28:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * re.c (append_utf8): check unicode range.
+ * 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>
* lib/cgi.rb (read_multipart): exclude blanks from header values.
[ruby-list:44327]
-Sun Dec 9 12:18:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_get_path): use the original object if to_path method is
- not defined. [ruby-dev:32473]
-
- * io.c (rb_f_open): call to_open on non-string objects, instead of
- to_str. [ruby-dev:32473]
-
-Sun Dec 9 12:12:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (tr_find): returns true if no characters to be removed is
- specified.
-
-Sun Dec 9 12:03:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_magic_comment): delimits with a semicolon.
-
-Sun Dec 9 11:29:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (tr_trans): get rid of segfaults when has mulitbytes but
- source sets have no mulitbytes.
-
-Sun Dec 9 04:01:28 2007 Tanaka Akira <akr@fsij.org>
-
- * encoding.c (rb_enc_mbclen): return 1 if underlying implementation
- returns a length longer than e-p.
- (rb_enc_precise_mbclen): return needmore if underlying
- implementation returns a length longer than e-p.
-
-Sat Dec 8 17:59:40 2007 Tanaka Akira <akr@fsij.org>
-
- * signal.c (posix_signal): return value.
-
-Sat Dec 8 17:22:16 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * test/openssl/test_pkcs7.rb: Remove redundant module namespace.
-
-Sat Dec 8 17:07:10 2007 Tanaka Akira <akr@fsij.org>
-
- * ruby.c (proc_options): make rb_raise format as a string literal to
- avoid warning.
-
-Sat Dec 8 16:18:16 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (rb_reg_check_preprocess): new function for validating regexp
- fragment.
-
- * parse.y (regexp): invoke reg_fragment_check.
- (reg_fragment_check): defined.
- (reg_fragment_check_gen): defined.
-
-Sat Dec 8 11:06:29 2007 Tanaka Akira <akr@fsij.org>
-
- * encoding.c (rb_enc_mbclen): make it never fail.
- (rb_enc_nth): don't check the return value of rb_enc_mbclen.
- (rb_enc_strlen): ditto.
- (rb_enc_precise_mbclen): return needmore(1) if e <= p.
- (rb_enc_get_ascii): new function for extracting ASCII character.
-
- * include/ruby/encoding.h (rb_enc_get_ascii): declared.
-
- * include/ruby/regex.h (ismbchar): removed.
-
- * re.c (rb_reg_expr_str): use rb_enc_get_ascii.
- (unescape_escaped_nonascii): use rb_enc_precise_mbclen to determine
- the termination of escaped non-ASCII character.
- (unescape_nonascii): use rb_enc_precise_mbclen.
- (rb_reg_quote): use rb_enc_get_ascii.
- (rb_reg_regsub): use rb_enc_get_ascii.
-
- * string.c (rb_str_reverse) don't check the return value of
- rb_enc_mbclen.
- (rb_str_split_m): don't call rb_enc_mbclen with e <= p.
-
- * parse.y (is_identchar): use ISASCII.
- (parser_ismbchar): removed.
- (parser_precise_mbclen): new macro.
- (parser_isascii): new macro.
- (parser_tokadd_mbchar): use parser_precise_mbclen to check invalid
- character precisely.
- (parser_tokadd_string): use parser_isascii.
- (parser_yylex): ditto.
- (is_special_global_name): don't call is_identchar with e <= p.
- (rb_enc_symname_p): ditto.
-
- [ruby-dev:32455]
-
- * ext/tk/sample/tkextlib/vu/canvSticker2.rb: remove coding cookie
- because the encoding is not UTF-8. [ruby-dev:32475]
-
-Fri Dec 7 20:21:35 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/lib/net/ftptls.rb, ext/openssl/lib/net/telnets.rb:
- half-finished libraries are discontinued.
-
-Fri Dec 7 15:44:40 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/pp.rb: use Hash for recursion check as inspect.
-
-Fri Dec 7 15:04:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (flatten): some performance improvements, based on a patch
- from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-core:13877].
- [ruby-core:13851]
-
- * thread.c (rb_exec_recursive): use Hash instead of Array for
- performance improvement. [ruby-core:13898]
-
- * thread.c (recursive_pop): use object ID.
-
-Thu Dec 6 19:52:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (arg): typo fixed ("!" -> "|") in the ripper code.
-
-Thu Dec 6 19:48:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (arg): tUPLUS no longer works as identity operation any
- more. inspired by [ruby-talk:265532].
-
-Thu Dec 6 18:22:11 2007 Tanaka Akira <akr@fsij.org>
-
- * encoding.c (rb_enc_precise_mbclen): new function for mbclen with
- validation.
-
- * include/ruby/encoding.h (rb_enc_precise_mbclen): declared.
- (MBCLEN_CHARFOUND): new macro.
- (MBCLEN_INVALID): new macro.
- (MBCLEN_NEEDMORE): new macro.
-
- * include/ruby/oniguruma.h (OnigEncodingTypeST): replace mbc_enc_len
- by precise_mbc_enc_len.
- (ONIGENC_PRECISE_MBC_ENC_LEN): new macro.
- (ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND): new macro.
- (ONIGENC_CONSTRUCT_MBCLEN_INVALID): new macro.
- (ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE): new macro.
- (ONIGENC_MBCLEN_CHARFOUND): new macro.
- (ONIGENC_MBCLEN_INVALID): new macro.
- (ONIGENC_MBCLEN_NEEDMORE): new macro.
- (ONIGENC_MBC_ENC_LEN): use ONIGENC_PRECISE_MBC_ENC_LEN.
-
- * enc/euc_jp.c: validation implemented.
-
- * enc/sjis.c: ditto.
-
- * enc/utf8.c: ditto.
-
- * string.c (rb_str_inspect): use rb_enc_precise_mbclen for invalid
- encoding.
- (rb_str_valid_encoding_p): new method String#valid_encoding?.
-
- * io.c (rb_io_getc): use rb_enc_precise_mbclen.
-
- [ruby-dev:32438]
-
-Thu Dec 6 01:37:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * regparse.c (i_apply_case_fold): fix for negative character class. a
- patch from Yusuke ENDOH <mame AT tsg.ne.jp> in [ruby-core:13884].
+Wed Dec 5 23:38:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Dec 6 01:00:38 2007 NARUSE, Yui <naruse@ruby-lang.org>
+ * range.c (range_each): followed step_i change.
- * ext/iconv/iconv.c (iconv_s_list): support NetBSD/Citrus iconv.
+Wed Dec 5 18:08:45 2007 Tanaka Akira <akr@fsij.org>
-Wed Dec 5 16:18:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * proc.c (rb_proc_s_new): call initialize. [ruby-core:13824]
-
- * proc.c (rb_proc_location): return file name and line number where
- the proc is defined.
-
- * thread.c (thread_s_new): call initialize. [ruby-core:13835]
-
- * thread.c (thread_initialize): split initialize method.
-
-Wed Dec 5 15:25:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_intern3): fix to changing encoding to default, and
- uncommented r13835, which is rare but not impossible.
+ * 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]
-Wed Dec 5 14:25:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix typo.
-
-Wed Dec 5 13:41:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (yycompile): get rid of tracing while parsing.
- [ruby-dev:31351]
-
- * thread.c (ruby_suppress_tracing): added a new parameter, which
- directs to call func always.
-
-Tue Dec 4 19:56:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_convert): should not set encoding unless
- the target encoding is supported. [ruby-dev:32451]
-
-Tue Dec 4 17:34:17 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/lib/kconv.rb (tojis, tosjis, toeuc, toutf8):
- set encoding. [ruby-dev:32447]
-
-Tue Dec 4 17:07:25 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/json.rb, lib/json/*: moved to ext/json/lib.
-
-Tue Dec 4 16:34:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_create): achieve target encoding.
-
- * ext/iconv/iconv.c (iconv_convert, iconv_finish, iconv_iconv,
- iconv_conv): set result string encoding. [ruby-dev:32446]
-
- * ext/iconv/iconv.c (iconv_initialize, iconv_s_open): set encoding to
- Iconv instance.
-
-Tue Dec 4 14:34:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (process_options): reverted c flag.
-
Tue Dec 4 11:23:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_cstr_to_inum): trailing spaces may exist at sqeezing
preceeding 0s. [ruby-core:13873]
-Mon Dec 3 11:51:53 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/Win32API/*: removed or moved to ext/dl/win32.
-
- * ext/dl/win32/*: new. [ruby-dev:32387]
-
-Sun Dec 2 22:08:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_tokadd_mbchar): fix for ASCII chars. [ruby-dev:32432]
+Sun Dec 2 22:43:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (parser_parse_string, parser_here_document): prevent false
- error messages.
+ * eval.c (error_print): put newline unless multiple line message ends
+ with a newline. [ruby-dev:32429]
-Sun Dec 2 20:43:22 2007 Tanaka Akira <akr@fsij.org>
+Sun Dec 2 15:49:20 2007 Kouhei Sutou <kou@cozmixng.org>
- * re.c (unescape_escaped_nonascii): fix mbclen argument.
-
-Sun Dec 2 15:47:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_tokadd_mbchar): check insufficient multibyte char.
- [ruby-dev:32429]
-
-Sun Dec 2 15:42:16 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, test/rss/test_version.rb: 0.2.1 -> 0.2.2.
+ * 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
@@ -2863,160 +2771,41 @@ Sun Dec 2 15:42:16 2007 Kouhei Sutou <kou@cozmixng.org>
* test/rss/test_maker_itunes.rb, test/rss/test_itunes.rb: removed
needless UTF-8 characters.
-Sun Dec 2 15:18:37 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_callee_setup_arg): fix error message.
- [ruby-dev:32430]
-
-Sun Dec 2 09:12:48 2007 Tanaka Akira <akr@fsij.org>
-
- * parse.y (regexp): fix /#{}\xa1\xa2/e to be EUC-JP.
- (reg_fragment_setenc_gen): extracted from reg_compile_gen.
-
-Sun Dec 2 01:39:51 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/intern.h (rb_uv_to_utf8): declared.
+Sun Dec 2 01:12:15 2007 James Edward Gray II <jeg2@ruby-lang.org>
- * re.c (rb_reg_preprocess): new function for dynamic regexp with
- \u{} such as Regexp.new("\\u{6666}").
- (rb_reg_prepare_re): preprocess regexp for recompiling.
- (read_escaped_byte): new function.
- (unescape_escaped_nonascii): new function.
- (append_utf8): new function.
- (unescape_unicode_list): new function.
- (unescape_unicode_bmp): new function.
- (unescape_nonascii): new function.
- (rb_reg_initialize): preprocess regexp.
-
- * pack.c (rb_uv_to_utf8): renamed from uv_to_utf8.
-
- * parse.y (STR_NEW3): take func instead of has8 and hasmb.
- (parser_str_new): use default coderange mechanism except for regexp.
- (parser_tokadd_utf8): copy regexp source as-is.
- (parser_read_escape): UTF-8 stuff removed.
- (parser_tokadd_escape): has8bit and hasmb removed.
- (parser_tokadd_string): fix 8-bit single byte character with \u.
- (parser_parse_string): has8bit and hasmb removed.
- (parser_here_document): has8bit and hasmb removed.
- (parser_yylex): call parser_tokadd_utf8 instead of read_escape for
- UTF-8 character.
-
-Wed Dec 2 01:00:07 2007 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 23:04:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * encoding.c: rename primary_encoding -> default_external (encoding).
-
-Sat Dec 1 19:52:57 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb (Time#to_datetime): use nsec instead of usec.
-
- * lib/date.rb (DateTime#to_time): second minute as an argument to
- Time::utc contains fractional part in rational; hence Time
- object may keep resolution at most nanosecond.
-
-Sat Dec 1 14:36:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_knownbug.rb: move fixed bugs.
-
- * test/ruby/test_sprintf.rb: ditto.
-
- * test/yaml/test_yaml.rb: ditto.
-
-Sat Dec 1 13:24:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_yield_with_cfunc): fix to passing argc on third
- parameter of IFUNC. [ruby-dev:32329]
-
- * enumerator.c: fix to pass exact number of argument.
-
- * eval.c (rb_yield_values2): added.
-
- * include/ruby/ruby.h: ditto.
-
- * bootstraptest/test_knownbug.rb: move a fixed test.
-
- * bootstraptest/test_block.rb: ditto.
+Sat Dec 1 15:13:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 1 10:45:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/resolv.rb: documentation update. backported from 1.9.
+ [ruby-core:13273]
- * io.c (rb_f_open): use to_open for every non-string object. path
- object may use method_missing.
+Sat Dec 1 03:30:47 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 1 09:44:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * parse.y (newline_node): set line from outermost node before removing
+ NODE_BEGIN. [ruby-dev:32406]
- * insns.def (concatarray, splatarray): use to_a instead of
- to_splat.
+Fri Nov 30 21:53:28 2007 Kouhei Sutou <kou@cozmixng.org>
- * insnhelper.ci (caller_setup_args): ditto.
-
-Sat Dec 1 03:34:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (newline_node): always remove NODE_BEGIN.
-
-Fri Nov 30 23:48:07 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * signal.c (ruby_signal): use SA_SIGINFO if available.
- [ ruby-Patches-6418 ]
-
-Fri Nov 30 22:52:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * signal.c (trap_signm): SIGVTALRM no longer used for green
- thread. [ruby-talk:281318]
-
- * signal.c (ruby_sig_finalize): do not install SIG_DFL handler if
- previous handler is sighandler().
-
-Fri Nov 30 21:02:15 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/json.rb, lib/json/add/{core.rb, rails.rb},
- test/json/test_json_rails.rb: additional files of JSON 1.1.2.
- [ruby-dev:32405]
-
-Fri Nov 30 19:33:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/syck/rubyext.c (rb_syck_mktime): avoid segmentation fault.
- [ruby-core:13735]
-
-Fri Nov 30 19:05:55 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_count): precise argument number check.
-
- * enum.c (enum_count): return Enumerator if no block given.
-
-Fri Nov 30 16:42:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/rss.rb, test/rss/test_version.rb: 0.2.0 -> 0.2.1.
- * enum.c (enum_take_while): returns Enumerator if no block given.
+ * 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.
- * enum.c (enum_drop_while): ditto.
+ * NEWS: added the above changes.
Thu Nov 29 16:59:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt): remove unnecessary NODE_BEGIN. [ruby-core:13814]
-Thu Nov 29 06:45:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_eql): recursive comparison should be based on
- eql? [ruby-core:13803]
-
-Wed Nov 28 18:08:00 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/json, lib/json, test/json: Update to JSON 1.1.2.
- (RubyForge#15447)
-
- * math.c: fix typo.
-
-Wed Nov 28 16:29:35 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_invoke_block): should splat args.
- [ruby-dev:32392]
-
- * test/ruby/test_yield.rb: add tests for above.
-
Wed Nov 28 14:43:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extract_makefile): use dldflags instead of DLDFLAGS to
@@ -3027,459 +2816,29 @@ Wed Nov 28 14:43:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_makefile): support for extensions which has no
shared object.
-Wed Nov 28 02:42:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Nov 28 09:51:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bignum.c (big2str_find_n1): removed extraneous element.
- [ruby-dev:32351], [ruby-dev:32365]
-
- * bignum.c (big2str_find_n1): returns necessary digits now.
+ * bignum.c (rb_big2str0): do not clobber space for sign.
* sprintf.c (remove_sign_bits): extends sign bit first.
-Tue Nov 27 15:53:43 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): "when *[],1" dumps core.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:32350]
-
- * bootstraptest/test_syntax.rb: add a test for above.
-
-Tue Nov 27 15:40:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): "a[*b] += 1" dumps core.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:32354]
-
- * bootstraptest/test_syntax.rb: add a test for above.
-
-Tue Nov 27 12:47:23 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def: change return value of "defined?"
- for $&, $1, ... . If such variables are defined,
- return "global-variable".
-
- * test/ruby/test_defined.rb: add tests.
-
- * bootstraptest/test_syntax.rb: fix a test.
-
-Tue Nov 27 11:54:46 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def: fix typo.
-
-Tue Nov 27 11:23:20 2007 Koichi Sasada <ko1@atdot.net>
-
- * test_beginendblock.rb: add loop to wait signal.
- [ruby-dev:32332]
-
-Tue Nov 27 11:14:57 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/encoding.h, encoding.c, re.c, string.c, parse.y:
- rename ENC_CODERANGE_SINGLE to ENC_CODERANGE_7BIT.
- rename ENC_CODERANGE_MULTI to ENC_CODERANGE_8BIT.
- Because single byte 8bit character, such as Shift_JIS 1byte katakana,
- is represented by ENC_CODERANGE_MULTI even if it is not multi byte.
-
-Tue Nov 27 10:45:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (rb_method_missing): fix stack trace.
-
- * bootstraptest/test_knownbug.rb: move solved tests.
-
- * bootstraptest/test_method.rb, test/ruby/test_regexp.rb: ditto.
-
-Tue Nov 27 09:57:42 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c: fix to allow dsym for alias/undef.
- [ruby-dev:32355]
-
- * bootstraptest/test_method.rb: add tests for above.
-
-Mon Nov 26 23:18:46 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/extserv.rb (initialize, stop_service): synchronize with
- ExtServManager.
-
- * test/drb/test_drb.rb (TestDRbEval): ignored.
-
-Mon Nov 26 17:32:16 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (Init_Regexp): new method Regexp#fixed_encoding?
- [ruby-dev:32361]
-
-Mon Nov 26 13:28:14 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/complex.rb: be able to create Complex(0, -0.0). [ruby-list:44268]
-
-Mon Nov 26 11:24:04 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (rb_reg_fixed_encoding_p): extracted from rb_reg_prepare_re and
- rb_reg_s_union.
- (rb_reg_s_union): refactored.
-
-Mon Nov 26 10:44:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_read_internal, rb_sysopen_internal): remove C99 dependency.
-
-Sun Nov 25 22:21:35 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/encoding.h (rb_enc_str_asciionly_p): declared.
- (rb_enc_str_asciicompat_p): defined.
-
- * re.c (rb_reg_initialize_str): use rb_enc_str_asciionly_p.
- (rb_reg_quote): return ascii-8bit string if the argument is
- ascii-only to generate encoding generic regexp if possible.
- (rb_reg_s_union): fix encoding handling. [ruby-dev:32094]
-
- * string.c (rb_enc_str_asciionly_p): defined.
-
-Sun Nov 25 12:12:03 2007 Eric Hodel <drbrain@segment7.net>
-
- * gem_prelude.rb: Import fast-loading gem_prelude.rb from RubyGems.
-
- * lib/rubygems*: Import RubyGems r1516.
-
-Sat Nov 24 23:25:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/ruby/test_eval.rb (TestEval::test_instance_eval_cvar):
- updated not to modify class variable of Object class.
-
-Fri Nov 23 17:34:24 2007 Koichi Sasada <ko1@atdot.net>
-
- * io.c: add rb_read_internal() as blocking function.
-
-Fri Nov 23 17:33:39 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c: fix comment.
-
-Fri Nov 23 17:26:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_knownbug.rb: move solved tests.
-
- * bootstraptest/test_io.rb, test_marshal.rb, test_objectspace.rb:
- ditto.
-
- * test/ruby/test_integer.rb, test_regexp.rb: ditto.
-
-Fri Nov 23 15:59:04 2007 Tanaka Akira <akr@fsij.org>
-
- * struct.c (rb_struct_alloc_noinit): new function.
- (rb_struct_define_without_accessor): add allocator to the arguments.
-
- * range.c (range_alloc): re-introduced using rb_struct_alloc_noinit.
-
-Fri Nov 23 15:27:43 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (REG_CASESTATE): unused macro removed.
- (rb_reg_prepare_re): check encoding difference.
- (rb_reg_initialize): check 8bit byte.
-
- * parse.y (parser_tokadd_escape): fix has8bit.
-
- [ruby-dev:32113]
-
-Fri Nov 23 15:16:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_f_global_variables): variable names should not
- duplicate. [ruby-dev:32344]
-
-Fri Nov 23 13:34:08 2007 Tanaka Akira <akr@fsij.org>
-
- * struct.c (rb_struct_define_without_accessor): new function.
-
- * range.c (range_alloc): removed.
- (Init_Range): use rb_struct_define_without_accessor.
-
- based on [ruby-dev:32327].
-
-Fri Nov 23 11:01:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (match_begin): should return offset by character.
- [ruby-dev:32331]
-
- * re.c (match_end): ditto.
-
- * re.c (rb_reg_search): ditto.
-
-Fri Nov 23 10:44:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * compile.c (defined_expr): defined(method(x)) dumped core. a
- patch from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:32335]
-
-Wed Nov 21 18:03:49 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c: fix to recycle thread data (VM stack).
-
- * thread.c: ditto.
-
- * benchmark/bm_vm3_thread_create_join.rb: add loop count.
-
-Wed Nov 21 18:02:10 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: add path to trunk/lib if driver runner is
- in build directory.
-
-Wed Nov 21 16:39:21 2007 Tanaka Akira <akr@fsij.org>
-
- * test/fileutils/fileasserts.rb (assert_equal_timestamp): new assert
- to test tv_sec only for filestamp resolution portability.
- (assert_same_entry): use assert_same_entry for mtime comparison.
-
-Wed Nov 21 14:55:13 2007 Koichi Sasada <ko1@atdot.net>
-
- * array.c (rb_ary_permutation): add gc guard codes.
-
-Wed Nov 21 11:16:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * insnhelper.ci (vm_search_normal_superclass): rename function.
-
- * insnhelper.ci (vm_search_superclass): ditto.
-
- * proc.c (struct METHOD): rename rklass -> rclass.
-
-Wed Nov 21 03:12:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * process.c (rb_f_system): returns nil on execution failure.
- [ruby-core:13715]
-
Wed Nov 21 01:04:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (nil_plus): remove unused function. [ruby-core:13737]
-Tue Nov 20 21:46:46 2007 Tanaka Akira <akr@fsij.org>
-
- * time.c (time_mload): ignore invalid digits in submicro.
-
-Tue Nov 20 20:33:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * include/ruby/ruby.h: rename RFloat#double_value -> float_value.
-
- * numeric.c, parse.y: ditto.
-
-Tue Nov 20 19:36:21 2007 Koichi Sasada <ko1@atdot.net>
-
- * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
- should be at vm_core.h.
-
- * include/ruby/ruby.h, intern.h: remove type rb_thread_t.
-
- * include/ruby/intern.h: change rb_unblock_function_t,
- rb_unblock_function_t.
-
- * file.c, process.c: apply above changes.
-
- * thread.c, thread_pthread.ci, thread_win32.ci: ditto.
-
- * io.c: support blocking open (2). [ruby-core:13614]
-
-Tue Nov 20 17:10:11 2007 Tanaka Akira <akr@fsij.org>
-
- * io.c (rb_io_close_on_exec_p): new method IO#close_on_exec?.
- (rb_io_set_close_on_exec): new method IO#close_on_exec=.
- [ruby-dev:32323]
-
-Tue Nov 20 16:24:31 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c (gc_mark_children): obj->as.file.fptr may be 0 for T_FILE.
-
-Tue Nov 20 15:09:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_read_escape): has8bit flag may be set with control
- escape. [ruby-core:13722]
-
- * parse.y (parser_prepare): set begging after BOM if exists.
- [ruby-core:13718]
-
-Tue Nov 20 14:55:37 2007 Eric Hodel <drbrain@segment7.net>
-
- * lib/rubygems*: Update to RubyGems 0.9.5.
-
-Tue Nov 20 13:00:44 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * include/ruby/win32.h win32/win32.c (rb_w32_pipe_exec): use dual fd
- instead of socketpair when mode is RDWR.
-
- * io.c (pipe_open): pass &write_fd to rb_w32_pipe_exec().
-
- * io.c (popen_redirect): define only when HAVE_FORK.
-
-Tue Nov 20 12:12:04 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/io.h (rb_io_t): add tied_io_for_writing member.
-
- * io.c: use tied_io_for_writing for duplex popen.
-
- * gc.c: mark tied_io_for_writing.
-
- * common.mk: gc.o depends io.h.
-
- [ruby-dev:32205]
-
-Tue Nov 20 11:59:33 2007 Tanaka Akira <akr@fsij.org>
-
- * test/drb/test_drb.rb: rename TestRubyYield to TestDRbRubyYield to
- avoid name crash with test/ruby/test_yield.rb.
- TestRuby18Yield is renamed to TestDRbRuby18Yield too.
-
-Tue Nov 20 03:24:42 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/extservm.rb: merged from ruby_1_8 branch.
-
- * lib/drb/acl.rb: ditto.
-
- * lib/drb/ssl.rb: ditto.
-
- * lib/drb/unix.rb: ditto.
-
- * lib/drb/drb.rb: ditto.
-
- * lib/drb/observer.rb: ditto.
-
- * lib/drb/invokemethod.rb: ditto.
-
- * test/drb/test_drbssl.rb: ditto.
-
- * test/drb/test_drb.rb: ditto.
-
- * test/drb/drbtest.rb: ditto.
-
- * test/drb/test_drbunix.rb: ditto.
-
-Tue Nov 20 00:52:46 2007 Tanaka Akira <akr@fsij.org>
-
- * test/fileutils/fileasserts.rb (assert_equal_time): show nsec if
- assertion fails but time.to_s equals.
- (assert_same_entry): use assert_equal_time.
-
- * test/fileutils/test_fileutils.rb (test_install): use
- assert_equal_time.
-
-Mon Nov 19 18:46:49 2007 Tanaka Akira <akr@fsij.org>
-
- * file.c (utime_internal): fallback utimensat to utimes.
-
-Mon Nov 19 17:51:27 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in: check struct timespec, clock_gettime, utimensat,
- struct stat.st_atim,
- struct stat.st_atimespec,
- struct stat.st_atimensec,
- struct stat.st_mtim,
- struct stat.st_mtimespec,
- struct stat.st_mtimensec,
- struct stat.st_ctim,
- struct stat.st_ctimespec,
- struct stat.st_ctimensec.
-
- * include/ruby/missing.h: provide struct timespec if not available.
-
- * time.c: support nanosecond-resolution using struct timespec.
- (time_nsec): new method: Time#nsec and Time#tv_nsec.
-
- * include/ruby/intern.h: provide rb_time_nano_new.
-
- * file.c (utime_internal): use utimensat if available.
- (rb_file_s_utime): refactored.
- (rb_f_test): use stat_atime, stat_mtime, stat_ctime.
- (rb_stat_cmp): check tv_nsec.
- (stat_atimespec): new function.
- (stat_atime): ditto.
- (stat_mtimespec): ditto.
- (stat_mtime): ditto.
- (stat_ctimespec): ditto.
- (stat_ctime): ditto.
- (rb_stat_atime): use stat_atime.
- (rb_file_s_atime): ditto.
- (rb_file_atime): ditto.
- (rb_stat_mtime): use stat_mtime.
- (rb_file_s_mtime): ditto.
- (rb_file_mtime): ditto.
- (rb_file_ctime): use stat_ctime.
- (rb_file_s_ctime): ditto.
- (rb_stat_ctime): ditto.
-
- * variable.c (rb_copy_generic_ivar): clear clone's instance variables
- if obj has no instance variable.
-
- * marshal.c (w_object): dump instance variables of generated string
- for TYPE_USERDEF, even if original object has instance variables.
-
- * lib/time.rb (Time#xmlschema): use nsec instead of usec.
-
- [ruby-dev:32306]
-
-Mon Nov 19 17:48:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_class_superclass): should not raise exception for
- BasicObject. [ruby-Bugs-15668]
-
-Mon Nov 19 16:04:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_permutation): gives all permutations of elements
- if no argument given. a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
- [ruby-dev:32309]
-
-Mon Nov 19 02:44:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (iseq_compile_each): alias and undef accept dsyms as well
- as literals. [ruby-dev:32308]
-
-Mon Nov 19 02:31:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_method.ci (rb_add_method): no redefinition warning for undef.
-
-Mon Nov 19 01:53:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_read_escape): disallow control and meta modifiers
- for non-ASCII characters. [ruby-core:13685]
-
-Sun Nov 18 20:47:41 2007 Tanaka Akira <akr@fsij.org>
-
- * marshal.c (mark_dump_arg): it may be called after dump_ensure.
-
-Sun Nov 18 18:27:47 2007 Tanaka Akira <akr@fsij.org>
-
- * time.c (time_minus): fix Time.at(2**60+1) - Time.at(2**60).
-
-Sun Nov 18 17:28:49 2007 Tanaka Akira <akr@fsij.org>
-
- * time.c (time_arg): show actual year in 2-3 digits year warning.
- (time_mdump): show actual year in "year too big to marshal" error.
-
Sun Nov 18 14:03:44 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval_method.ci (rb_alias): do not call hook functions until
- initialization finishes. [ruby-talk:279538]
+ * 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.
-Sun Nov 18 05:19:46 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/mkmf.rb (have_struct_member): define HAVE_type_member.
-
-Sat Nov 17 23:51:29 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sat Nov 17 13:58:11 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_invoke): bug fix. [ruby-talk:279100]
-Sat Nov 17 23:21:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): should clear parser->tokp as well.
- [ruby-dev:32250]
-
- * parse.y: remove NEED_ASSOC that break test_parser_events.
-
- * parse.y (parser_yylex): should not decrement line numbers at the
- end of file.
-
- * file.c (rb_find_file_ext): search .rb files first through in the
- loadpath.
-
-Fri Nov 16 23:31:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big_odd_p): new method added. a patch from Tadashi
- Saito <shiba AT mail2.accsnet.ne.jp>. [ruby-dev:32305]
-
- * bignum.c (rb_big_even_p): ditto.
-
Fri Nov 16 17:41:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (Document-class): moved the simplest example to
@@ -3491,135 +2850,25 @@ Fri Nov 16 17:41:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (iconv_iconv): also instance method needs to be
qualified.
-Fri Nov 16 16:26:57 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * include/ruby/ruby.h: added some declarations for event hooks.
-
- * lib/profile.rb: set VM::InstructionSequence.compile_option.
-
Fri Nov 16 11:16:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/yaml/rubytypes.rb (String#is_binary_data?): use Integer#fdiv.
-Fri Nov 16 03:36:01 2007 why the lucky stiff <why@ruby-lang.org>
-
- * ext/syck/rubyext.c: Node#value defined twice.
-
- * lib/yaml/: several method redefinitions causing warnings.
-
-Fri Nov 16 03:01:00 2007 why the lucky stiff <why@ruby-lang.org>
-
- * lib/yaml/types.rb: Likewise, pass self to YAML::quick_emit.
-
-Fri Nov 16 02:51:59 2007 why the lucky stiff <why@ruby-lang.org>
-
- * lib/yaml.rb (quick_emit): use combination of object_id and hash to
- identify repeated object references, since GC will reuse memory of
- objects during output of YAML. [ruby-Bugs-8548] [ruby-Bugs-3698]
-
-Thu Nov 15 19:49:03 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Nov 15 19:50:46 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/curses/extconf.rb: check macro if cannot find func.
[ruby-list:44224]
-Thu Nov 15 18:04:06 2007 Tanaka Akira <akr@fsij.org>
-
- * tool/compile_prelude.rb: fix TMP_RUBY_PREFIX for relative load path
- environment.
-
-Thu Nov 15 17:28:21 2007 Tanaka Akira <akr@fsij.org>
-
- * tool/compile_prelude.rb: absolute path may not start with a slash.
- pointed by usa.
-
-Thu Nov 15 17:07:54 2007 Tanaka Akira <akr@fsij.org>
-
- * tool/compile_prelude.rb: fix first substitution.
- use constant for prefix.
- pointed by Richard Kilmer.
-
-Thu Nov 15 14:29:56 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (prereq): added auto generated sources. [ruby-dev:32280]
-
-Thu Nov 15 12:31:13 2007 Tanaka Akira <akr@fsij.org>
-
- * tool/compile_prelude.rb: use constant for prefix.
-
-Thu Nov 15 12:24:39 2007 Tanaka Akira <akr@fsij.org>
-
- * tool/compile_prelude.rb: use simple template system for source
- code generation.
-
Thu Nov 15 12:19:14 2007 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]
-Thu Nov 15 12:14:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * tool/compile_prelude.rb (c_esc): need to escape closing brace.
-
-Thu Nov 15 11:52:16 2007 Tanaka Akira <akr@fsij.org>
-
- * tool/compile_prelude.rb: adjust RbConfig::CONFIG paths relative
- to the installation path.
-
-Thu Nov 15 11:25:20 2007 Tanaka Akira <akr@fsij.org>
-
- * ruby.c (usage): fix typo on --disable-gems option.
- pointed by Richard Kilmer.
-
-Wed Nov 14 16:16:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/net/http/test_https_proxy.rb
- (HTTPSProxyTest::test_https_proxy_authentication): initialize
- local variable 't' first. [ruby-dev:32253]
-
-Wed Nov 14 15:39:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/socket/test_socket.rb: update not to use 1.8 assignment to
- external local variable in the block parameters. [ruby-dev:32251]
-
- * test/strscan/test_stringscanner.rb: avoid $KCODE, and use
- String#force_encoding(). [ruby-dev:32251]
-
-Wed Nov 14 14:04:42 2007 Tanaka Akira <akr@fsij.org>
-
- * common.mk, Makefile.in: rename prelude.c to miniprelude.c.
- rename ext_prelude.c to prelude.c
-
- * win32/Makefile.sub: ditto.
-
- * bcc32/Makefile.sub: ditto.
-
-Wed Nov 14 07:09:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, compile.c, compile.h, debug.c, debug.h,
- id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
- thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
- vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
- copyright year.
-
-Wed Nov 14 07:07:51 2007 Koichi Sasada <ko1@atdot.net>
-
- * tool/makedocs.rb, template/insnstbl.html: removed.
-
-Wed Nov 14 02:50:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (parse.c): dependency also needs vpath.
-
- * common.mk (node_name.inc, prelude.c): VPATH in nmake does not
- work for targets of explicit rules.
-
-Wed Nov 14 02:11:38 2007 Tanaka Akira <akr@fsij.org>
+Wed Nov 14 01:52:59 2007 Tanaka Akira <akr@fsij.org>
* missing/isinf.c (isinf): don't define if the macro is defined.
- * configure.in: no need to set ac_cv_func_isinf=yes on non-gcc
- solaris.
-
Wed Nov 14 01:34:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (round): fallback definition.
@@ -3627,43 +2876,11 @@ Wed Nov 14 01:34:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_divmod, flo_round): use round() always.
[ruby-dev:32269]
-Wed Nov 14 00:33:49 2007 Koichi Sasada <ko1@atdot.net>
-
- * include/ruby/ruby.h: introduce 2 macros:
- RFLOAT_VALUE(v), DOUBLE2NUM(dbl).
- Rename RFloat#value -> RFloat#double_value.
- Do not touch RFloat#double_value directly.
-
- * bignum.c, insns.def, marshal.c, math.c, numeric.c, object.c,
- pack.c, parse.y, process.c, random.c, sprintf.c, string.c,
- time.c: apply above changes.
-
- * ext/dl/mkcallback.rb, ext/json/ext/generator/generator.c:
- ditto.
-
-Wed Nov 14 00:15:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * tool/ytab.sed: get rid of GNU sed feature. a patch from Laurent
- Sansonetti <laurent.sansonetti AT gmail.com> in [ruby-core:13470].
+Tue Nov 13 22:02:23 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Nov 13 21:41:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/drb/drb.rb: remove Thread.exclusive.
- * common.mk (parse.c), ext/ripper/depend (ripper.c): process after
- bison with sed. [ruby-dev:32204]
-
- * ruby.c (proc_options): use yydebug in cmdline_options.
-
- * ruby.c (process_options): set yydebug flag of parser.
-
- * parse.y (yydebug): moved into struct parser_params.
-
- * parse.y (rb_parser_get_yydebug, rb_parser_set_yydebug): parser
- generic methods.
-
- * */Makefile.sub (parse.c): moved to common.mk.
-
- * tool/ytab.sed: comment out yydebug definition, and substitute
- yyerror with parser_yyerror.
+ * lib/drb/extservm.rb: ditto.
Tue Nov 13 16:33:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -3672,367 +2889,39 @@ Tue Nov 13 16:33:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (flo_divmod): work around for platforms have no round().
[ruby-dev:32247]
-Tue Nov 13 15:26:33 2007 Tanaka Akira <akr@fsij.org>
-
- * lex.c.blt: moved from lex.c.
-
- * lex.c.src: copied from keywords. This is the source of lex.c.blt.
-
- * Makefile.in (lex.c): use lex.c.blt if keywords is same as lex.c.src.
+Tue Nov 13 13:58:51 2007 Tanaka Akira <akr@fsij.org>
- * win32/Makefile.sub (lex.c): re-introduce copy rule.
-
- * bcc32/Makefile.sub (lex.c): ditto.
-
- * wince/Makefile.sub (lex.c): ditto.
-
-Tue Nov 13 15:21:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_specialized_instruction): check argc.
-
-Tue Nov 13 14:44:32 2007 why the lucky stiff <why@ruby-lang.org>
-
- * test/yaml/test_yaml.rb: fixed the failing YAML Struct test
- at ko1's request.
+ * numeric.c (numeric.c): Integer#ord implemented. [ruby-dev:32206]
Tue Nov 13 02:57:04 2007 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
* numeric.c (flo_divmod): round to the nearest integer.
[ ruby-Bugs-14540 ]
-Tue Nov 13 00:36:16 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * test/ruby/test_settracefunc.rb: fixed tests for set_trace_func.
-
-Mon Nov 12 19:47:29 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * thread.c (call_trace_proc): should return value.
-
-Mon Nov 12 19:45:18 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * {bcc,win}32/Makefile.sub (miniruby): use $(COMMONOBJS) and $(DMYEXT)
- instead of $(LIBRUBY_A).
-
-Mon Nov 12 18:32:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * {bcc,win}32/Makefile.sub (MINIOBJS): added prelude.$(OBJEXT).
-
-Mon Nov 12 17:13:23 2007 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in, common.mk: add prelude.o to MINIOBJS.
-
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 16:48:09 2007 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in, common.mk: add ext_prelude.o to OBJS.
-
-Mon Nov 12 13:57:39 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in (MINIDLNOBJS): removed.
- (MINIOBJS): set to dln.o if dmydln.o is not used.
-
- * Makefile.in (miniruby): use MINIOBJS instead of MINIDLNOBJS.
-
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:17:59 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in (MINIDLNOBJS): defined.
-
- * Makefile.in (miniruby): use MINIDLNOBJS and COMMONOBJS instead of
- MINIOBJS and OBJS to avoid linking both dmydln.o and dln.o.
-
-Sun Nov 11 20:32:45 2007 Tanaka Akira <akr@fsij.org>
-
- * {win32,wince,bcc32}/Makefile.sub: delete lex.c rule.
-
-Sun Nov 11 19:40:52 2007 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in (lex.c): simplified.
-
-Sun Nov 11 18:31:48 2007 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in (lex.c): touch lex.c if gperf failed but lex.c exists.
- Although this may cause non-updated lex.c,
- svn co may generate keywords newer than lex.c especially on
- a file system which can record fractional mtime such as XFS.
-
-Sun Nov 11 17:32:46 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * insnhelper.ci (vm_call_method): pass mn->nd_clss to
- vm_call_cfunc() instead of klass.
-
- * vm.c (rb_thread_method_id_and_klass): traverse parent_iseq.
-
- * thread.c (call_trace_proc): use rb_thread_method_id_and_klass().
-
-Sun Nov 11 16:54:25 2007 Tanaka Akira <akr@fsij.org>
-
- * lex.c: renamed from lex.c.blt.
-
- * Makefile.in (lex.c): use find command to check mtime.
+Mon Nov 12 12:38:31 2007 Tanaka Akira <akr@fsij.org>
-Sun Nov 11 05:34:13 2007 Eric Hodel <drbrain@segment7.net>
-
- * bin/gem: Add forgotten gem command.
-
-Sat Nov 10 23:50:31 2007 Tanaka Akira <akr@fsij.org>
-
- * string.c (tr_trans): cast to unsigned char after dereference
- a pointer to a char to avoid SEGV with "\377".tr("a", "b").
- on FreeBSD/amd64.
-
-Sat Nov 10 23:08:53 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in, common.mk, Makefile.in: don't generate
- libminiruby-static.a.
-
-Sat Nov 10 19:46:54 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in, common.mk, Makefile.in: generate libminiruby-static.a
- which contains prelude.o for miniruby.
-
-Sat Nov 10 18:10:07 2007 Tanaka Akira <akr@fsij.org>
-
- * gem_prelude.rb: new file for gem libraries. currently empty.
-
- * common.mk: generate ext_prelude.c by prelude.rb and gem_prelude.rb.
- ruby (not miniruby) is linked with ext_prelude.o instead of
- prelude.o.
-
- * inits.c (rb_call_inits): don't call Init_prelude.
-
- * ruby.c: support --disable-gems option.
- (ruby_init_gems): new function to define Gem::Enable and
- invoke Init_prelude.
- (process_options): call ruby_init_gems just after
- ruby_init_loadpath.
-
- * tool/compile_prelude.rb: support multiple files.
-
-Sat Nov 10 17:27:55 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * thread.c (call_trace_proc): don't call ID2SYM() for ID_ALLOCATOR
- to avoid SEGV.
-
-Sat Nov 10 16:37:07 2007 Eric Hodel <drbrain@segment7.net>
-
- * lib/rubygems: Import RubyGems revision 1493.
-
- * lib/rubygems.rb: ditto.
-
- * lib/ubygems.rb: ditto.
-
- * lib/rbconfig/datadir.rb: ditto.
-
- * test/rubygems: ditto.
-
-Sat Nov 10 16:34:21 2007 Eric Hodel <drbrain@segment7.net>
-
- * lib/soap/property.rb: Don't override Enumerable#inject for 1.9.
-
-Sat Nov 10 14:43:30 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * parse.y: use ASCII encoding for string literals that are
- 7-bit clean, fixing regression from my previous patch
-
-Sat Nov 10 13:18:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * {bcc32,win32}/Makefile.sub: vendor_ruby support.
-
-Fri Nov 9 23:33:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_nextc): added single line read forward buffer.
-
- * parse.y (parser_yylex): adjust line number for fluent interface.
-
-Fri Nov 9 22:04:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * vm.h (FRAME_MAGIC_MASK_BITS): bits of FRAME_MAGIC_MASK.
-
- * insnhelper.ci (vm_call_cfunc, vm_cfunc_flags): use shift operations.
-
-Fri Nov 9 21:46:28 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (eval): should be volatile value for GC.
-
-Fri Nov 9 17:48:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (locale_encoding): guesstimate encoding from environment
- variables. [ruby-core:13315]
-
- * ruby.c (process_options): set primary encoding from environment.
-
-Fri Nov 9 16:51:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_each_byte): should update rbuf_off and rbuf_len for
- each iteration. [ruby-dev:31659][ruby-dev:32192]
-
- * variable.c (rb_cvar_set): cvar assignment obey same rule to cvar
- reference. [ruby-dev:32192]
-
-Fri Nov 9 15:52:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (enc_check_encoding, rb_set_primary_encoding): ENCODING
- is no longer in FL_USERS flags.
-
-Fri Nov 9 15:20:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_squeeze_bang): initialize squeezing table if no
- arguments given.
-
-Fri Nov 9 13:57:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (each_with_index_i): use rb_yield_values() for
- compatibility with Enumerator#with_index(). a patch from Yusuke
- ENDOH <mame AT tsg.ne.jp>. [ruby-dev:32195]
-
-Fri Nov 9 13:45:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/ruby/test_iterator.rb (TestIterator::IterTest::each):
- #each_pair is now alias to #each. [ruby-dev:32192]
-
- * test/ruby/test_iterator.rb (TestIterator::test_assoc_yield):
- ditto
-
-Fri Nov 9 12:56:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_load.c (loaded_feature_path): check with type of given feature.
-
-Fri Nov 9 12:43:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/ruby/test_basicinstructions.rb: updated for new class
- behavior. [ruby-dev:32192]
-
- * encoding.c (enc_name): Encoding should not rely on ENCODING in
- the FL_USERS flags.
-
- * encoding.c (rb_enc_from_encoding): do not call rb_enc_associate
- for encoding itself.
-
- * encoding.c (enc_register_at): ditto.
-
- * marshal.c (r_ivar): do not set real instance variable for
- encoding data associated.
-
-Fri Nov 9 10:43:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (send_internal): use self in the previous frame to check for
- protected methods. [ruby-core:13254]
-
- * insnhelper.ci (vm_call_method): send! method has gone.
-
-Fri Nov 9 10:38:13 2007 Koichi Sasada <ko1@atdot.net>
-
- * marshal.c (w_object): should be SPECIAL_CONST_P() instead of
- IMMEDIATE_P().
-
-Fri Nov 9 10:29:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_invoke_method): check if invoked in function style.
- [ruby-core:13245]
-
- * insnhelper.ci (vm_call_cfunc, vm_cfunc_flags): stores and returns VM
- calling flags.
-
- * vm.c (rb_vm_cfunc_funcall_p): returns if the current method is
- invoked in function style.
-
-Fri Nov 9 10:10:21 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: add rb_context_t#type.
-
-Fri Nov 9 10:05:54 2007 Koichi Sasada <ko1@atdot.net>
-
- * ruby.c (set_arg0): fix breaking environ bugs.
+ * 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].
-Thu Nov 8 17:09:55 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * object.c: improve docs for Object.tap
-
- * ChangeLog: fix bogus dates on my previous entries
-
-Thu Nov 8 15:13:56 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * parse.y: fix segfault with \x escapes in regexps
- delete unused #if 0 code regions from previous patch
-
-Thu Nov 8 12:12:10 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * parse.y (parser_read_escape): remove C99/gcc-ism.
-
-Thu Nov 8 07:54:22 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * parse.y: patch, based on Nobu's, work to support \u escapes
- also modifications for better coderange detection
-
- * test/ruby/test_unicode_escapes.rb: test cases
-
- * test/ruby/test_mixed_unicode_escapes.rb: mixed encoding test cases
-
-Thu Nov 8 07:14:37 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * parse.y (rb_intern3): commented out broken code that prevented
- correct interning of multi-byte symbols. Without this patch
- :x==:x is false when x is a multi-byte character.
-
-Thu Nov 8 07:04:31 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * string.c (tr_setup_table, tr_trans): fix test failures
- in test/ruby/test_string.rb
-
-Wed Nov 7 15:07:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enum.c (enum_each_with_index): make different arrays at each
- iteration. [ruby-dev:32181]
-
-Wed Nov 7 05:17:24 2007 David Flanagan <davidflanagan@ruby-lang.org>
-
- * eval.c: fix typo in invoke_method documentation
-
-Wed Nov 7 03:52:26 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_product): core dumped with non array arguments.
- a patch from Yusuke ENDOH <mame AT tsg.ne.jp>. [ruby-dev:32180]
-
Wed Nov 7 03:32:38 2007 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]
-Wed Nov 7 02:59:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_each_index): should return meaningful value.
-
-Tue Nov 6 16:37:47 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_load.c (loaded_feature_path): need to expand relative paths.
-
- * eval_load.c (rb_feature_p): check if the feature is loading with
- load path. [ruby-dev:31932]
-
- * eval_load.c (load_lock): check the result of barrier waiting.
-
- * thread.c (rb_barrier_wait): check if owned by the current thread.
-
- * thread.c (rb_barrier_release): ditto.
-
-Mon Nov 5 08:01:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (Init_eval): move #send to Kernel module from BasicObject.
-
Mon Nov 5 05:17:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser::Switch::summarize): fix for long form
@@ -4046,176 +2935,23 @@ Mon Nov 5 01:20:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
reimplement the parser that is simpler than the current one.
since we abandoned the plan, warning no longer required.
-Mon Nov 5 01:02:56 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (HTTPHeader#initialize): provide default
- User-Agent to fix 500 error on some corrupted HTTP servers.
- [ruby-core:13135]
-
-Mon Nov 5 00:32:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_send): allow send/__send__ to call methods of all
- visibility again. we no longer provide __send, __send!.
-
- * eval.c (rb_invoke_method): new method to honor private
- visibility. if it's invoked in a function call style, it calls
- private methods as well (previous 1.9 send behavior).
-
-Mon Nov 5 00:24:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/Makefile.sub: vendor_ruby support.
-
- * configure.in (RUBY_LIB): duplicated.
-
-Mon Nov 5 00:01:33 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (rb_reg_quote): quote \v as well.
-
-Sun Nov 4 23:51:59 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (rb_reg_initialize_m): use StringValuePtr instead of
- StringValueCStr because \0 exists when Regexp.new("\0").
-
-Sun Nov 4 08:11:19 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c (count_objects): count TOTAL.
-
-Sun Nov 4 03:58:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (tr_setup_table): use C array for characters that fit
- in a byte to gain performance.
-
- * string.c (rb_str_delete_bang): ditto.
-
- * string.c (rb_str_squeeze_bang): ditto.
-
- * string.c (rb_str_count): ditto.
-
- * string.c (tr_trans): ditto.
-
-Sun Nov 4 00:06:40 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c (count_objects): ObjectSpace.count_objects implemented.
- [ruby-core:12301]
-
-Sat Nov 3 22:49:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_each_pair): make Hash#each to be alias to
- Hash#each_pair for compatibility and clarity.
-
- * hash.c (env_each_pair): ditto.
-
-Sat Nov 3 22:41:05 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in: --with-vendor-hdrdir implemented.
-
- * lib/mkmf.rb: check --vendor argument.
-
- * README.EXT: explain --vendor option for extconf.rb
-
- * README.EXT.ja: ditto.
-
-Sat Nov 3 20:30:48 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in: --with-vendordir implemented.
-
- * mkconfig.rb: add config to vendorlibdir and vendorarchdir.
-
- * instruby.rb: make vendor library directories.
-
- * ruby.c: insert vendor library directories into load path.
-
-Fri Nov 2 20:55:49 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/content.rb, lib/rss/content/, lib/rss/maker/content.rb,
- test/rss/test_content.rb, test/rss/test_maker_content.rb,
- test/rss/rss-testcase.rb (RSS::TestCase): supported
- content:encoded with RSS 2.0.
- Suggested by Sam Lown. Thanks.
-
-Fri Nov 2 20:47:04 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, test/rss/test_version.rb: 0.2.0 -> 0.2.1.
-
-Thu Nov 1 21:56:45 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (Init_Exception): make NameError to be subclass of
- StandardError again.
-
- * error.c (Init_Exception): make SecurityError to be subclass of
- Exception, since it's too important to be handled implicitly.
-
-Thu Nov 1 14:51:39 2007 David Flanagan <davidflanagan@ruby-lang.org>
- * enum.c (take_while_i, drop_while_i) add RTEST to handle nil return
-
-Thu Nov 1 02:12:50 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * common.mk (prereq): update the path of prelude.c.
+Fri Nov 2 00:13:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * common.mk (prelude.c): rollback a part of r13675, because it is not
- documented and causes build error.
-
-Thu Nov 1 01:52:23 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * enum.c (enum_drop): fix typo.
-
-Thu Nov 1 01:51:01 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * vm_core.h (ruby_current_thread): RUBY_EXTERN'ed for probeprofiler.
-
-Thu Nov 1 00:46:30 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/configure.bat, setup.mak: now can recognize OS even if
- the ``--target'' option of configure is omitted.
-
- * win32/README.win32: update the descriptions about compiler.
-
-Wed Oct 31 03:13:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_take_while): separate with-block form.
-
- * enum.c (drop_while_i): ditto.
-
- * enum.c (enum_butfirst): abandon butfirst method. reverted.
-
-Tue Oct 30 10:03:43 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_butfirst): add a new method to iterates over
- elements but first n. RDoc need to be updated.
-
- * enumerator.c (Init_Enumerator): remove unnecessary symbol
- initialization.
-
-Mon Oct 29 18:42:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (bvar): block-local variable can shadow outer variable.
- [ruby-core:13036]
-
-Mon Oct 29 17:58:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_substr): performance improvement. [ruby-dev:31806]
-
-Mon Oct 29 17:20:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_replicate): new function to replicate encoding.
-
- * encoding.c (enc_based_encoding): Encoding#base_encoding returns
- based encoding of replica.
-
-Mon Oct 29 17:18:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * array.c (rb_ary_assoc): check and convert inner arrays (assocs)
+ using #to_ary.
- * encoding.c (rb_enc_compatible): ASCII encoding is compatible with
- ASCII-compatible encoding, even for non-string objects.
+ * hash.c (rb_hash_s_create): check and convert argument hash
+ using #to_hash.
-Sun Oct 28 21:50:02 2007 Tanaka Akira <akr@fsij.org>
+ * hash.c (rb_hash_s_create): Hash#[] now takes assocs as source of
+ hash conversion.
- * lib/open-uri.rb: :redirect option implemented to disable redirects.
- (OpenURI::HTTPRedirect): new exception class for redirection.
+Thu Nov 1 23:47:43 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Fri Oct 26 17:38:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/drb/drb.rb (DRbTCPSocket): Improving with multiple network
+ interface.
- * numeric.c (int_chr): take an optional encoding parameter.
- [ruby-core:12816]
+ * test/drb/drbtest.rb: ditto.
Fri Oct 26 17:14:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -4223,344 +2959,107 @@ Fri Oct 26 17:14:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
-Fri Oct 26 15:00:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-style.el (ruby-style-{case,label}-indent): adjust for
- labels inside switch block.
+Wed Oct 25 07:18:09 2007 James Edward Gray II <jeg2@ruby-lang.org>
-Fri Oct 26 05:48:57 2007 David Flanagan <davidflanagan@ruby-lang.org>
- * array.c: raise IndexError for negative length in rb_ary_fill
-
-Wed Oct 25 07:12:03 2007 James Edward Gray II <jeg2@ruby-lang.org>
+ Merged 13781 from trunk.
* lib/net/telnet.rb (Net::Telnet#login): Allowing "passphrase" in
addition to "password" for Telnet login prompts. [ruby-Bugs-10746]
-Wed Oct 25 06:34:11 2007 James Edward Gray II <jeg2@ruby-lang.org>
+Wed Oct 25 06:46:21 2007 James Edward Gray II <jeg2@ruby-lang.org>
+
+ Merged 13779 from trunk.
* lib/net/telnet.rb (Net::Telnet#login): Making the password prompt
pattern case insensitive. [ruby-Bugs-10746]
-Fri Oct 26 04:21:36 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/net/pop.rb (Net::POP3::do_start): type fixed. a patch from
- Dan Zwell <dzwell AT zwell.net> in [ruby-core:12941].
-
-Fri Oct 26 01:48:28 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 Oct 25 16:46:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): dot at the head of the line denote line
- continuation from previous one to support fluent interface.
- [experimental]
-
- * misc/ruby-mode.el (ruby-calculate-indent): support fluent dot.
-
Thu Oct 25 14:19:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_tell, rb_io_seek): check errno too. [ruby-dev:32093]
-Thu Oct 25 13:59:53 2007 David Flanagan <davidflanagan@ruby-lang.org>
+Wed Oct 25 08:03:53 2007 James Edward Gray II <jeg2@ruby-lang.org>
- * parse.y (parser_tokspace): increment tokidx
- fixes test failure at [test/ruby/test_stringchar.rb:72]
-
-Thu Oct 25 09:49:49 2007 akira yamada <akira@ruby-lang.org>
-
- * lib/uri.rb, lib/uri/ldaps.rb: added LDAPS
- scheme. [ruby-dev:31896]
-
-Wed Oct 25 06:23:14 2007 James Edward Gray II <jeg2@ruby-lang.org>
+ Merged 13767, 13768, 13769, and 13770 from trunk.
* lib/xmlrpc/parser.rb (XMLRPC::Convert::dateTime): Fixing a bug that
caused time zone conversion to fail for some ISO 8601 date formats.
[ruby-Bugs-12677]
-Wed Oct 25 04:59:28 2007 James Edward Gray II <jeg2@ruby-lang.org>
-
* lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): Explicitly start
the HTTP connection to support keepalive requests. [ruby-Bugs-9353]
-Wed Oct 25 04:46:53 2007 James Edward Gray II <jeg2@ruby-lang.org>
-
* lib/xmlrpc/client.rb (XMLRPC::Client#do_rpc): Improving the error
message for Content-Type check failures. [ruby-core:12163]
-Wed Oct 25 03:45:08 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]
-Wed Oct 24 17:09:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_tokspace): make space in token buffer.
-
- * parse.y (parser_yylex): fix encoding of single character literal.
-
-Tue Oct 23 13:44:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (call_args2): nd_head of NODE_BLOCK_PASS should be a list.
- [ruby-core:12850]
-
-Tue Oct 23 10:42:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (process_options): encoding set by command line option takes
- priority over the encoding in the source, as the primary encoding.
-
-Mon Oct 22 19:24:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.c (proc_options): allow space after -E (encoding) option.
-
-Mon Oct 22 11:03:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (enc_check_encoding): returns index now.
-
- * encoding.c (rb_enc_compatible): check if two objects have compatible
- encodings.
-
- * encoding.c (enc_compatible_p): added Encoding.compatible?.
-
- * include/ruby/encoding.h (rb_enc_compatible): prototype.
-
-Sun Oct 21 18:29:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_default, rb_enc_primary): return pointers to
- rb_encoding of default and primary respectively. [ruby-core:12795]
-
- * encoding.c (set_primary_encoding): removed primary_encoding setter.
-
-Sat Oct 20 13:17:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_cycle): hide temporary array from ObjectSpace.
- [ruby-core:12762]
-
-Sat Oct 20 11:49:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_get_path): returns frozen string.
-
- * file.c (rb_file_s_chown, rb_file_s_lchown): use uid_t and gid_t.
-
-Fri Oct 19 20:08:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_id_encoding): returns ID "encoding".
-
- * marshal.c (w_encoding): dump encoding name.
-
- * marshal.c (r_ivar): load encoding.
-
-Fri Oct 19 16:41:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_regx_options, reg_compile_gen): relaxened encoding
- matching rule.
-
- * re.c (rb_reg_initialize): always set encoding of Regexp.
-
- * re.c (rb_reg_initialize_str): fix encoding for non 7bit-clean
- strings.
-
- * re.c (rb_reg_initialize_m): use ascii encoding for 'n' option.
-
-Fri Oct 19 11:09:56 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (process_options): set primary encoding from the parser
- always. [ruby-core:12758]
-
- * ruby.c (load_file): should not discard the parser parameter.
-
-Fri Oct 19 10:55:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * range.c (range_last): removed unused variables.
-
-Thu Oct 18 17:08:57 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_find_index): update RDoc. a patch from David Flanagan
- <david AT davidflanagan.com> in [ruby-core:12710].
-
- * enum.c (enum_take, enum_drop): ditto.
-
- * enum.c (enum_cycle): should not cause infinite loop for empty
- arrays. [ruby-core:12710]
-
- * range.c (Init_Range): typo fixed.
-
-Thu Oct 18 16:39:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/rexml/source.rb (REXML::SourceFactory::SourceFactory): more
- duck typed. better performance on JRuby.
- http://headius.blogspot.com/2007/10/another-performance-discovery-rexml.html
-
-Thu Oct 18 09:33:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (range_first): takes first n element if argument is
- given. [ruby-core:12697]
-
- * range.c (range_last): returns last n elements if argument is
- given.
-
- * array.c (rb_ary_subseq, rb_ary_last): export.
-
-Wed Oct 17 17:39:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (proc_options): fixed reversed condition. [ruby-core:12722]
-
-Wed Oct 17 13:54:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_s_union): the last check was not complete.
-
-Wed Oct 17 11:30:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_from_encoding, rb_enc_register): associate index
- to self.
-
- * encoding.c (enc_capable): Encoding objects are encoding capable.
-
- * re.c (rb_reg_s_union): check if encoding matching by exact encoding
- objects.
-
-Wed Oct 17 06:18:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_alias, rb_enc_find_index): changed
- enc_table_alias to a name-to-index hash.
-
- * encoding.c (rb_enc_init): use upper case names for aliases to use as
- constant names.
-
- * encoding.c (enc_find): allow symbols.
-
- * encoding.c (Init_Encoding): define encoding constants.
-
- * st.c (strcasehash): fix wrong code range condition.
-
-Wed Oct 17 05:07:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_primary_encoding): added Encoding.primary_encoding.
-
- * parse.y (rb_parser_encoding): added.
-
- * ruby.c (proc_options): added -E and --encoding options.
-
- * ruby.c (process_options): set primary encoding from command line
- option if set, or source encoding.
-
- * include/ruby/encoding.h (rb_enc_from_encoding,
- rb_get_primary_encoding, rb_set_primary_encoding): prototypes.
-
- * include/ruby/node.h (rb_parser_encoding): prototype.
-
-Wed Oct 17 03:37:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * re.c (rb_reg_desc): set encoding.
-
- * re.c (rb_reg_s_union): check encodings.
-
- * enc/utf8.c (utf8_code_to_mbclen): 0xfe and 0xff are valid Unicode to
- be encoded to 2bytes in UTF-8. [ruby-core:12700]
-
-Wed Oct 17 02:50:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_ord): use encoding.
-
-Wed Oct 17 01:57:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * re.c (rb_reg_initialize_m): allow binary encoding option.
- [ruby-dev:32083]
-
-Tue Oct 16 19:48:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * re.c (rb_reg_s_union): check for encoding of original object.
-
-Tue Oct 16 18:28:51 2007 Tanaka Akira <akr@fsij.org>
-
- * debug.c: use enum for constants for gdb if possible.
-
-Tue Oct 16 18:20:10 2007 Tanaka Akira <akr@fsij.org>
-
- * ruby.c, debug.c: move debug enum and constants to debug.c.
-
-Tue Oct 16 18:16:15 2007 Tanaka Akira <akr@fsij.org>
-
- * ruby.c (RUBY_ENCODING_SHIFT): added as enum.
-
- * .gdbinit (rp): show encoding and coderange for strings.
-
-Tue Oct 16 14:48:38 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_regx_options): check if regexp encoding option
- matches to current encoding.
-
- * re.c (char_to_option, rb_char_to_option_kcode): 'n' is not kcode
- option now.
+Sun Oct 21 21:16:43 2007 Kouhei Sutou <kou@cozmixng.org>
- * re.c (rb_reg_to_s, rb_reg_error_desc): copy encoding rather than
- append as an option.
-
- * re.c (make_regexp, rb_reg_prepare_re): use encoding of Regexp and
- String instead of kcode.
+ * 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.
- * re.c (rb_reg_initialize): set fixed option if none is set.
+ * NEWS: added an entry for RSS Parser.
- * re.c (rb_reg_regcomp): ditto.
+Thu Oct 18 10:57:06 2007 Tanaka Akira <akr@fsij.org>
- * re.c (rb_reg_equal): check if encodings are equal.
+ * ruby.h (RCLASS_IV_TBL): defined.
+ (RCLASS_M_TBL): ditto.
+ (RCLASS_SUPER): ditto.
+ (RMODULE_IV_TBL): ditto.
+ (RMODULE_M_TBL): ditto.
+ (RMODULE_SUPER): ditto.
- * re.c (rb_reg_initialize_m): encoding option is obsolete.
+Mon Oct 15 22:08:55 2007 Akinori MUSHA <knu@iDaemons.org>
- * re.c (rb_kcode, rb_get_kcode, rb_set_kcode): removed.
+ * NEWS: Merge some of the sub-sections, as the differences were
+ unclear.
- * re.c (Init_Regexp): removed Regexp#kcode method.
+Mon Oct 15 21:57:07 2007 Akinori MUSHA <knu@iDaemons.org>
- * ruby.c (proc_options): allow long encoding name.
+ * NEWS: Mention ipaddr enhancements.
-Tue Oct 16 14:03:09 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/ipaddr.rb (in_addr, in6_addr, addr_mask): Make some minor
+ code optimization.
- * re.c (rb_reg_s_union): encoding of all regexp objects should
- match. [ruby-dev:32076]
+ * lib/ipaddr.rb (<=>): Implement IPAddr#<=> and make IPAddr
+ comparable.
-Tue Oct 16 13:49:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/ipaddr.rb (succ): Implement IPAddr#succ. You can now create
+ a range between two IPAddr's, which (Range) object is
+ enumerable.
- * encoding.c (enc_to_s): rename function.
+ * lib/ipaddr.rb (to_range): A new method to create a Range object
+ for the (network) address.
-Tue Oct 16 13:25:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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.
- * string.c (rb_str_new4): should copy encoding. a patch from NARUSE,
- Yui <naruse AT airemix.com>. [ruby-dev:32076]
+ * lib/ipaddr.rb (initialize): Give better error messages.
-Tue Oct 16 01:31:23 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/ipaddr.rb: Improve documentation.
- * enum.c (enum_inject): RDoc update. a patch from David Flanagan
- <david AT davidflanagan.com> in [ruby-core:12710].
+Mon Oct 15 21:24:25 2007 Akinori MUSHA <knu@iDaemons.org>
-Tue Oct 16 01:25:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * NEWS: Mention shellwords and tempfile enhancements.
- * encoding.c (Init_Encoding): define #to_s to show encoding name
- in to_s representation as well as #inspect.
+ * NEWS: Move the entry about Tk::X_Scrollable to a better section.
-Mon Oct 15 13:24:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Oct 15 17:28:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * numeric.c (flo_round): should be number but not rounding factor.
- [ruby-dev:32060]
+ * 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>
* marshal.c (r_bytes0): refined length check. [ruby-dev:32059]
-Mon Oct 15 10:24:19 2007 Tanaka Akira <akr@fsij.org>
-
- * process.c (pst_to_s): returns a string such as "pid 10220 exit 1"
- instead of "256". [ruby-dev:32053]
- (pst_inspect): change format
- "#<Process::Status: pid=10220,exited(1)>" to
- "#<Process::Status: pid 10220 exit 1>".
-
Mon Oct 15 09:58:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_bytes0): check if source has enough data.
@@ -4571,26 +3070,6 @@ Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@fsij.org>
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
nonblocking. [ruby-talk:274079]
-Sun Oct 14 17:31:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_obj_encoding): rdoc update. a patch from David
- Flanagan <david AT davidflanagan.com>. [ruby-core:12664]
-
- * encoding.c (enc_dump, enc_load): marshaling feature. a patch from
- David Flanagan. [ruby-core:12665]
-
- * encoding.c (Init_Encoding): undefine allocator of Encoding.
- [ruby-core:12665], [ruby-core:12666]
-
- * test/ruby/test_encoding.rb: tests for Encoding from David Flanagan
- [ruby-core:12665]
-
-Sun Oct 14 11:09:09 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/pp.rb (PP::PPMethods#pp_hash): don't sort keys because hash is
- ordered.
- (ENV.pretty_print): call pp_hash with sorted hash.
-
Sun Oct 14 04:08:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (AC_SYS_LARGEFILE): keep results also in command
@@ -4603,789 +3082,98 @@ Sun Oct 14 03:55:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/mkexports.rb: deal with __fastcall name decorations.
[ruby-list:44111]
-Sun Oct 14 02:20:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_cEncoding): new Encoding class.
-
- * encoding.c (rb_to_encoding, rb_to_encoding_index): helper functions.
-
- * encoding.c (rb_obj_encoding): return Encoding object now.
-
- * gc.c (garbage_collect): mark Encoding objects.
-
- * inits.c (rb_call_inits): call Init_Encoding.
-
- * string.c (rb_str_force_encoding): accept Encoding object as well as
- encoding name.
-
- * include/ruby/encoding.h (rb_to_encoding_index, rb_to_encoding):
- prototypes.
-
-Sun Oct 14 01:03:30 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/open-uri.rb (OpenURI.open_http): fix :ssl_ca_cert option.
-
-Sat Oct 13 21:23:21 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (foletype_s_ole_classes,
- foletype_s_typelibs): refactoring.
-
- * test/win32ole/test_win32ole_type.rb: add some test.
-
- * ext/win32ole/win32ole.c (Init_win32ole): change method name
- WIN32OLE_TYPELIB.ole_types from WIN32OLE_TYPELIB.ole_classes.
-
- * test/win32ole/test_win32ole_typelib.rb: ditto.
-
- * test/win32ole/test_folderitem2_invokeverb.rb: check create
- shortcut string more strictly (This test is invoked in Japanese
- Windows environment).
-
-Sat Oct 13 09:11:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (set_file_encoding): case-insensitive search, a patch from
- David Flanagan <david AT davidflanagan.com> [ruby-core:12629]
-
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:17:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/rexml/document.rb (REXML::Document::write): leaky
- modification trans -> transitive. [ruby-dev:32040]
-
-Sat Oct 13 00:00:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y: encoding specifier should work if the line matches
- /coding[:=] ?/, a la Python PEP-263, so that VIM comments like
- "# vim: set fileencoding=<encoding name>" should be recognized.
+Sat Oct 13 00:35:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Oct 12 15:04:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * trunk/parse.y (magic_comments): add "encoding" as same as "coding".
-
- * trunk/parse.y (set_file_encoding): special file encoding handling.
-
- * trunk/parse.y (parser_yylex): ditto.
-
-Fri Oct 12 12:44:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_combination): fixed memory corruption due to too
- small memory allocation
-
- * array.c (rb_ary_product): accessing out of memory bounds.
- condition fixed.
+ * 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 21:10:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * include/ruby/node.h (NOEX_LOCAL): remove unused local visibility.
-
- * class.c (ins_methods_push): ditto.
-
- * class.c (rb_class_local_methods): method removed.
-
-Thu Oct 11 14:29:31 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * */Makefile.sub (COMMON_MACROS): workaround for old SDK's bug.
- [ruby-core:12584]
-
-Thu Oct 11 06:35:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, */Makefile.sub (VPATH): add enc directory.
-
- * common.mk (ENCOBJS): encoding objects.
-
- * enc: directory for encodings.
-
-Thu Oct 11 00:04:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * include/ruby/oniguruma.h (OnigEncodingTypeST): add OnigEncoding
- parameter to every function members.
-
- * include/ruby/oniguruma.h (OnigEncodingTypeST): add auxiliary
- data member to provide user defined data for an encoding.
-
-Wed Oct 10 23:32:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_s_quote): no longer takes optional second argument
- that has never been documented.
-
-Wed Oct 10 15:39:04 2007 Tanaka Akira <akr@fsij.org>
-
- * encoding.c (rb_enc_init): don't alias iso-8859-1 to ascii.
-
- * ascii.c (OnigEncodingASCII): change the name US-ASCII to ASCII-8BIT.
-
-Wed Oct 10 14:31:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_enc_str_coderange): fixed checkfor non-ascii.
-
-Tue Oct 9 21:35:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ to adapt RDoc description. [ruby-core:12588]
- * array.c (rb_ary_permutation, rb_ary_combination): missing type
- names.
+Thu Oct 11 14:32:46 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * array.c (rb_ary_permutation): used buffer should be t1.
+ * {bcc32,win32}/Makefile.sub (COMMON_MACROS): workaround for old SDK's
+ bug. [ruby-core:12584]
- * array.c (rb_ary_permutation): use frozen shared hidden array.
- [ruby-dev:31985]
+Wed Oct 10 23:34:45 2007 Tanaka Akira <akr@fsij.org>
-Tue Oct 9 16:58:10 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/securerandom.rb: new file. [ruby-dev:31928]
- * array.c: remove to_a completely.
+ * lib/cgi/session.rb (create_new_id): use securerandom if available.
- * array.c (tmpbuf): keep DRY to clear klass of temporary objects.
+Tue Oct 9 01:01:55 2007 Tanaka Akira <akr@fsij.org>
-Tue Oct 9 16:33:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * re.c (rb_reg_s_union_m): Regexp.union accepts single
+ argument which is an array of patterns. [ruby-list:44084]
- * array.c (rb_ary_permutation, rb_ary_combination, rb_ary_product):
- hide internal buffer objects. [ruby-dev:31982]
+Mon Oct 8 20:06:23 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Tue Oct 9 16:00:32 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * lib/net/http.rb, lib/open-uri.rb: remove
+ Net::HTTP#enable_post_connection_check. [ruby-dev:31960]
- * parse.y (parser_read_escape, parser_tokadd_escape): check code range.
- [ruby-dev:31980]
-
-Tue Oct 9 15:40:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (STR_NEW3): check for if single byte sequence.
-
-Mon Oct 8 20:06:29 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/net/imap.rb, lib/net/smtp.rb, lib/net/pop.rb: hostname should
- be verified against server's identity as presented in the server's
- certificate. [ruby-dev:31960]
+ * lib/net/imap.rb: hostname should be verified against server's
+ indentity as persented in the server's certificate. [ruby-dev:31960]
* ext/openssl/lib/net/telnets.rb, ext/openssl/lib/net/ftptls.rb: ditto.
-Sun Oct 7 22:37:47 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/test_taxonomy.rb, test/rss/test_parser_1.0.rb,
- test/rss/test_image.rb, test/rss/rss-testcase.rb: ensured
- declaring XML namespaces.
-
-Sun Oct 7 22:00:01 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/node.h: make node flags as VALUE type.
- enum ruby_node_flags removed.
-
- * ruby.c: define RUBY_NODE_* as const for gdb.
-
-Sun Oct 7 18:57:12 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/ruby.h: enum ruby_value_flags removed. [ruby-dev:31959]
-
- * ruby.c: define RUBY_FL_* as const VALUE for gdb.
-
-Sun Oct 7 17:50:14 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/net/http.rb: remove enable_post_connection_check flag.
-
- * lib/open-uri.rb: ditto.
-
-Sun Oct 07 15:48:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (opt_eq): fix to use rb_str_equal().
-
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]
-Sat Oct 6 16:24:02 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (cont_free): check Fiber or Continuation.
-
- * bootstraptest/test_knownbug.rb: remove a fixed test.
-
-Sat Oct 6 14:56:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_register): returns new index or -1 if failed.
-
- * encoding.c (rb_enc_alias): check if original name is registered.
-
- * encoding.c (rb_enc_init): register in same order as kcode options in
- re.c. added new aliases.
-
- * string.c (rb_str_force_encoding): check if valid encoding name.
-
-Sat Oct 6 14:32:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insns.def (opt_eq): get rid of gcc bug.
-
-Sat Oct 6 02:34:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * include/ruby/defines.h: no longer provide DEFAULT_KCODE.
-
-Fri Oct 5 21:24:59 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]
-
-Fri Oct 5 16:42:27 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (assert_not_match): new method.
-
-Fri Oct 5 16:15:52 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * configure.in: Turn on --enable-pthread by default for FreeBSD
- 5.2.1-RELEASE and later, and remove pthread support for older
- versions which has never worked perfectly.
-
-Fri Oct 5 16:11:50 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * time.c (time_to_s): Fix documentation. Time format changed.
-
-Fri Oct 5 04:02:39 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/ipaddr.rb (in_addr, in6_addr, addr_mask): Make some minor
- code optimization.
-
-Fri Oct 5 03:25:51 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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.
-
-Fri Oct 5 03:14:45 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * 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.
-
-Thu Oct 4 20:45:53 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * process.c (Init_process): win32 has our own WNOHANG definition, so
- remove unnecessary #ifdef guard.
-
-Thu Oct 4 20:17:19 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * array.c (rb_ary_permutation, rb_ary_product): support non C99
- compilers.
-
-Thu Oct 4 17:33:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (kcode_setter): Perl-ish global variable `$=' no longer
- effective.
-
- * io.c (Init_IO): remove obsolete variables: $defout, $deferr.
-
- * re.c (Init_Regexp): remove obsolete const alias: MatchingData.
-
- * time.c (Init_Time): remove obsolete Time::times.
-
- * re.c (ignorecase_setter): change warning message.
-
- * re.c (ignorecase_getter): now gives warning.
-
- * string.c (rb_str_cmp_m): update RDoc document.
-
- * re.c (kcode_setter): restore erroneously removed setter.
-
-Thu Oct 4 16:28:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_obj_encoding): returns encoding of the given object.
-
- * parse.y (reg_compile_gen): copy encoding from source string if
- non-empty.
-
- * re.c (Init_Regexp): new method Regexp#encoding.
-
- * string.c (str_encoding): moved to encoding.c
-
-Thu Oct 4 15:49:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_permutation): remove C99 dependency.
- [ruby-dev:31934]
-
- * array.c (rb_ary_product): ditto.
-
-Wed Oct 3 23:37:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/nkf/nkf.c, bin/ri, bin/irb: fixed typos in doc and comments.
- a patch from Eugene Ossintsev <eugoss AT gmail.com>.
- [ruby-core:12375]
-
-Wed Oct 3 17:56:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: enable specify label to executable.
- (-e "ruby1::/path/to/ruby1; ruby2::/path/to/ruby2; ...")
-
-Wed Oct 3 16:58:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_str_new, parser_yylex, rb_intern3): set code-range
- bits.
-
- * parse.y (parser_tokadd_string): check code-range.
-
- * parse.y (parser_parse_string, parser_here_document): ditto.
-
- * parse.y (parser_set_encode): check if valid encoding.
-
-Wed Oct 3 15:43:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_cvar_set): check whether class variable is
- defined in superclasses. root classes have higher priority.
- removes lower class variable entry from IV_TBL (if it's defined
- in classes, not modules).
-
- * variable.c (rb_cvar_get): ditto.
-
-Wed Oct 3 10:06:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (ruby_process_options): push frame with program name.
- [ruby-core:12351]
-
-Tue Oct 2 20:16:55 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (init_env): refactoring. remove unused code.
-
-Tue Oct 2 12:30:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_product): generalized product, now takes
- arbitrary number of arrays. a patch from David Flanagan
- <david AT davidflanagan.com>. [ruby-core:12346]
-
-Tue Oct 2 08:25:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_permutation): implementation contributed from
- David Flanagan. [ruby-core:12344]
-
- * array.c (rb_ary_combination): RDoc update to clarify. a patch
- from David Flanagan. [ruby-core:12344]
-
- * array.c (rb_ary_permutation): small dirty hack by Matz to avoid
- arrays on stack.
-
-Tue Oct 2 07:01:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c (proc_dup): proc->block.proc should be self.
-
- * bootstraptest/test_knownbug.rb, test_method.rb:
- move a fixed test.
-
-Mon Oct 1 16:17:44 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/test_method.rb: use assert_normal_exit to test
- [ruby-dev:31818].
-
-Mon Oct 1 15:57:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (id2ref): skip ICLASS.
-
-Mon Oct 1 15:29:35 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (assert_normal_exit): use `` instead of
- system.
-
-Mon Oct 1 15:17:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (id2ref): T_VALUES is less than T_BLOCK. [ruby-dev:31911]
-
-Mon Oct 1 10:58:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (require_libraries): use require method instead of calling
- rb_require directly. [ruby-dev:31322]
-
-Mon Oct 1 10:52:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_options), ruby.c (proc_options, process_options): not
- call exit(2) directly. [ruby-dev:31912]
-
- * eval.c (ruby_run_node): deal with direct exit code.
-
-Sun Sep 30 17:12:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_append): always set encoding, and coderange
- cache bits.
-
- * include/ruby/encoding.h (ENC_CODERANGE_SET): fixed a bug not to
- set cache bits.
-
-Sun Sep 30 11:52:11 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (pretty): don't show beginning empty line.
-
-Sun Sep 30 11:32:34 2007 Tanaka Akira <akr@fsij.org>
-
- * numeric.c: use #ifdef for test LONG_LONG_VALUE.
-
-Sun Sep 30 04:30:55 2007 Tanaka Akira <akr@fsij.org>
-
- * bignum.c: use SIZEOF_LONG instead of SIZEOF_ULONG which is not
- defined.
-
-Sun Sep 30 04:03:43 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (Init_Regexp): test DEFAULT_KCODE in C code because
- KCODE_EUC, etc. are enum.
-
-Sun Sep 30 00:55:40 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * variable.c (obj_ivar_each): get rid of warning.
-
-Sat Sep 29 17:45:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * main.c (main): use platform-independent per-process initialization.
- [ruby-dev:31900]
-
- * ruby.c (ruby_sysinit): new function for per-process initialization.
-
- * include/ruby/ruby.h (RUBY_GLOBAL_SETUP): toplevel setup declaration.
-
- * include/ruby/win32.h, win32/mkexports.rb: alias NtInitialize
- ruby_sysinit.
-
- * win32/win32.c (rb_w32_sysinit): renamed from NtInitialize.
-
-Sat Sep 29 17:31:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_combination): new method to give all combination
- of elements from an array. [ruby-list:42671]
-
- * array.c (rb_ary_product): a new method to get all combinations
- of elements from two arrays. can be extended to combinations of
- n-arrays, e.g. a.product(b,c,d). anyone volunteer?
-
- * array.c (rb_ary_permutation): empty function body to calculate
- permutations of array elements. need volunteer.
-
-Sat Sep 29 17:14:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (r_leave): move proc invocation from r_entry() to
- avoid potential crash.
-
-Sat Sep 29 12:28:08 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (assert_normal_exit): new method.
-
- * bootstraptest/test_knownbug.rb: add test for Marshal.load.
-
-Sat Sep 29 10:12:20 2007 Tanaka Akira <akr@fsij.org>
-
- * variable.c (rb_ivar_set): fix class instance variable.
-
- * object.c (rb_class_real): cl argument may be 0.
-
-Sat Sep 29 09:12:02 2007 Tanaka Akira <akr@fsij.org>
-
- * object.c (rb_class_real): use BUILTIN_TYPE instead of TYPE.
- access flags directly instead of FL_TEST.
- they are enough because cl argument is a class.
-
-Sat Sep 29 08:57:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * include/ruby/win32.h (strcasecmp): needed for type_strcasehash.
-
-Sat Sep 29 06:47:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (struct cmdline_options): static variables packed.
-
-Sat Sep 29 05:29:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_fdopen): create IO object from fd.
-
- * parse.y (yycompile): use encoding of the source as default.
-
- * ruby.c (proc_options, load_file): ditto.
-
-Sat Sep 29 04:27:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_alias): allow encodings multiple aliases.
-
- * encoding.c (rb_enc_find_index): search the encoding which has the
- given name and return its index if found, or -1.
-
- * st.c (type_strcasehash): case-insensitive string hash type.
-
- * string.c (rb_str_force_encoding): force encoding of self. this name
- comes from [ruby-dev:31894] by Martin Duerst. [ruby-dev:31744]
-
- * include/ruby/encoding.h (rb_enc_find_index, rb_enc_associate_index):
- prototyped.
-
- * include/ruby/encoding.h (rb_enc_isctype): direct interface to ctype.
-
- * include/ruby/st.h (st_init_strcasetable): prototyped.
-
-Sat Sep 29 03:53:26 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: Thread local storage should be fiber local.
-
- * bootstraptest/test_knownbug.rb, test/ruby/test_fiber.rb:
- move a fixed test.
-
-Fri Sep 28 23:15:31 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * insnhelper.ci (vm_call_method): allow send! to call protected
- methods as well. [ruby-core:12280]
-
-Fri Sep 28 22:33:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_so_fasta.rb: added.
-
- * benchmark/bm_so_k_nucleotide.rb: added.
-
- * benchmark/bm_so_reverse_complement.rb: added.
-
- * benchmark/make_fasta_output.rb: added.
-
- * benchmark/prepare_so_k_nucleotide.rb: added.
-
- * benchmark/prepare_so_reverse_complement.rb: added.
-
-Fri Sep 28 19:14:51 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: fix notations.
-
- * benchmark/bm_loop_whileloop.rb: ditto.
-
- * benchmark/bm_loop_whileloop2.rb: ditto.
-
- * benchmark/bm_app_uri.rb: added.
-
- * benchmark/bm_vm1_ivar_set.rb: ditto.
-
- * benchmark/bm_so_binary_trees.rb: added from Computer Language
- Benchmarks Game (http://shootout.alioth.debian.org/).
-
- * benchmark/bm_so_fannkuch.rb: ditto.
-
- * benchmark/bm_so_mandelbrot.rb: ditto.
-
- * benchmark/bm_so_meteor_contest.rb: ditto.
-
- * benchmark/bm_so_nbody.rb: ditto.
-
- * benchmark/bm_so_nsieve.rb: ditto.
-
- * benchmark/bm_so_nsieve_bits.rb: ditto.
-
- * benchmark/bm_so_partial_sums.rb: ditto.
-
- * benchmark/bm_so_pidigits.rb: ditto.
-
- * benchmark/bm_so_spectralnorm.rb: ditto.
-
-Fri Sep 28 16:22:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * vm_core.h (rb_vm_struct): fix typo: bufferd -> buffered.
-
-Fri Sep 28 15:47:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: fix to output benchmark results
- to file "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}".
-
- * benchmark/bm_io_file_create.rb: remove useless codes.
-
- * benchmark/bm_vm2_eval.rb: added.
-
-Fri Sep 28 15:05:24 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/intern.h: export rb_ivar_foreach.
-
- * include/ruby/ruby.h: modify struct RObject and RClass for optimizing
- T_OBJECT space. [ruby-dev:31853]
- (ROBJECT_LEN, ROBJECT_PTR)
- (RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_SUPER, RCLASS_IV_INDEX_TBL)
- (RMODULE_IV_TBL, RMODULE_M_TBL, RMODULE_SUPER): abstract accessor
- defined.
-
- * variable.c: support the modified RObject and RClass.
-
- * object.c: ditto.
-
- * class.c: ditto.
-
- * gc.c: ditto.
-
- * marshal.c: ditto.
-
- * eval_method.ci: use the abstract accessor.
-
- * insns.def: ditto.
-
- * proc.c: ditto.
-
- * struct.c: ditto.
+Fri Oct 5 15:44:50 2007 Akinori MUSHA <knu@iDaemons.org>
- * eval.c: ditto.
-
- * error.c: ditto.
-
- * vm.c: ditto.
-
- * insnhelper.ci: ditto.
-
- * ext/digest/digest.c: ditto.
-
-Fri Sep 28 13:20:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_getline_fast, rb_io_getline_1): set encoding to the
- result string, as well as getc.
-
-Fri Sep 28 12:51:42 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_app_erb.rb: added.
-
- * benchmark/bm_io_file_(create|read|write).rb: added.
-
-Fri Sep 28 12:49:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: fix file selection algorithm.
-
-Fri Sep 28 02:05:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_comparable): need not to check asciicompat here.
-
- * encoding.c (rb_enc_check): ditto.
-
- * string.c (rb_enc_str_coderange): tuned a bit; no broken check.
-
- * encoding.c (rb_enc_check): new encoding comparison criteria.
-
-Thu Sep 27 17:36:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/REAMDE.win32: follow recent changes.
-
-Thu Sep 27 16:01:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: fix to output some helpful messages.
-
-Thu Sep 27 15:44:51 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/driver.rb: added.
-
- * common.mk: fix to use above driver.
-
- * benchmark/prepare_so_count_words.rb: added.
-
- * benchmark/bm_so_count_words.rb: fix benchmark process.
-
-Thu Sep 27 15:42:34 2007 Koichi Sasada <ko1@atdot.net>
-
- * ext/fiber/fiber.c: modify prototype declaration.
- [ruby-core:12247]
-
-Thu Sep 27 09:42:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (strings, xstring, regexp, dsym): empty strings have
- US-ASCII encoding.
-
-Thu Sep 27 07:39:13 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (assert_finish): new method.
-
- * bootstraptest/test_knownbug.rb: add test for [ruby-dev:31866] using
- assert_finish.
-
-Thu Sep 27 04:46:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_associate_index): deal with ASCII compatible
- flags.
-
- * encoding.c (rb_enc_check): allow ASCII compatible strings.
-
- * parse.y (rb_intern_str): use ASCII encoding for ASCII string.
-
- * string.c (rb_enc_str_coderange): check for code-range.
-
- * string.c (rb_str_modify): clear code-range flags.
-
- * string.c (rb_str_hash, rb_str_eql): ASCII compatible strings are
- comparable.
-
- * include/ruby/encoding.h: added code-range flags.
-
-Thu Sep 27 04:40:47 2007 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 and compat_tbl entries. [ruby-dev:31870]
-
-Thu Sep 27 03:17:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (rb_waitpid): no needs to poll. [ruby-dev:31871]
-
-Wed Sep 26 20:11:46 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_knownbug.rb: remove a fixed test.
-
-Wed Sep 26 20:00:12 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_knownbug.rb: move fixed tests.
-
- * bootstraptest/test_method.rb: ditto.
-
- * test/ruby/test_io.rb: ditto.
-
-Wed Sep 26 19:36:26 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (eval): fix to check stack overflow.
- [ruby-dev:31850]
-
- * eval_intern.h, vm.h: move CHECK_STACK_OVERFLOW() macro.
-
-Wed Sep 26 19:27:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_throw): fix to move increment point.
- [ruby-dev:31840]
-
-Wed Sep 26 19:23:56 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: Fiber as SemiCoroutine on default. [ruby-core:12146]
+ * lib/shellwords.rb: Add shellescape() and shelljoin().
- * ext/fiber/fiber.c: enable Fiber#transfer.
+ * lib/shellwords.rb: Rename shellwords() to shellsplit() and make
+ the former an alias to the latter.
-Wed Sep 26 18:38:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/shellwords.rb: Add escape(), split(), join() as class
+ methods, which are aliases to their respective long names
+ prefixed with `shell'.
- * encoding.c (rb_enc_check): check for ASCII-compatibilities.
+ * lib/shellwords.rb: Add String#shellescape(), String#shellsplit()
+ and Array#shelljoin() for convenience.
- * parse.y (parser_tokadd_string, parser_parse_string,
- parser_here_document, parser_yylex): set encoding to US-ASCII.
+Fri Oct 5 15:40:04 2007 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (rb_enc_symname_p): check if valid with encoding.
+ * lib/tempfile.rb (Tempfile::make_tmpname): Allow to specify a
+ suffix for a temporary file name.
- * parse.y (rb_intern3): let symbols have encoding.
+ * lib/tempfile.rb (Tempfile::make_tmpname): Make temporary file
+ names less predictable by including a random string.
+ [inspired by: akr]
- * string.c (rb_str_hash): add encoding index.
+Tue Oct 2 21:20:14 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * string.c (rb_str_comparable, rb_str_equal, rb_str_eql): check if
- compatible encoding.
+ * win32/win32.c (make_cmdvector): adjust escaped successive
+ double-quote handling. (merge from trunk)
- * string.c (sym_inspect): made encoding aware.
+Tue Oct 2 20:35:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * insns.def (opt_eq): compare with encoding.
+ * win32/win32.c (init_env): initialize HOME and USER environment
+ variables unless set. [ruby-core:12328] (merge from trunk)
- * include/ruby/encoding.h (rb_enc_asciicompat): check if ASCII
- compatible.
+ * win32/win32.c (NtInitialize, getlogin): ditto.
- * include/ruby/encoding.h (rb_enc_get_index): added prototype.
+ * configure.in, win32/Makefile.sub (LIBS): need to link shell32
+ library for SH* functions on mswin32 and mingw32.
- * include/ruby/intern.h (rb_str_comparable, rb_str_equal): ditto.
+Mon Oct 1 12:50:59 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Sep 26 15:01:16 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * gc.c (id2ref): valid id should not refer T_VALUE nor T_ICLASS.
+ [ruby-dev:31911]
- * eval_method.ci (rb_get_alloc_func): cast to suppress a warning.
+Wed Sep 26 23:54:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval_method.ci (remove_method): local variable to be initialized.
+ * 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>
@@ -5394,51 +3182,20 @@ Wed Sep 26 08:36:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
Wed Sep 26 05:12:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (parser_yyerror): limit error message length.
- [ruby-dev:31848]
-
-Tue Sep 25 15:11:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_ungetc): reallocate internal buffer if pushing data
- excess capacity. [ruby-dev:31650]
-
-Tue Sep 25 13:43:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval_method.ci (remove_method): should not remove undef place
- holder. [ruby-dev:31816], [ruby-dev:31817]
-
-Tue Sep 25 09:51:31 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_longjmp): source file information may be NULL.
- [ruby-dev:31849]
-
- * eval.c (ruby_finalize_0): clear trace_func before finalization.
-
-Mon Sep 24 22:36:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_equal): should handle recursive array.
-
- * hash.c (hash_equal): should handle recursive hash.
-
-Mon Sep 24 22:14:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/weakref.rb (WeakRef): remove debug print. [ruby-dev:31799]
+ * parse.y (yyerror): limit error message length. [ruby-dev:31848]
- * hash.c (hash_i): avoid too frequent hash conflict where key and
- value are same. a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
- [ruby-dev:31802]
+ * regex.c (re_mbc_startpos): separated from re_adjust_startpos.
-Mon Sep 24 17:56:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Sep 25 13:47:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/strscan/strscan.c (strscan_initialize, strscan_getch): use the
- encoding of the target string instead of setting to StringScanner
- instance. [ruby-dev:31831]
+ * 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>
* lib/net/http.rb: fix typo.
-Mon Sep 24 06:49:15 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sun Sep 23 21:57:25 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/net/http.rb: an SSL verification (the server hostname should
be matched with its certificate's commonName) is added.
@@ -5450,7 +3207,7 @@ Mon Sep 24 06:49:15 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
perform SSL post connection check.
* ext/openssl/lib/openssl/ssl.c
- (OpenSSL::SSL::SSLSocket#post_connection_check): refine error message.
+ (OpenSSL::SSL::SSLSocket#post_connection_check): refine error message.
Sun Sep 23 09:05:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -5459,16 +3216,11 @@ Sun Sep 23 09:05:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sun Sep 23 08:58:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval_method.ci (rb_attr): should not use alloca for unknown size
- input. [ruby-dev:31818]
+ * eval_method.ci (rb_attr): should not use alloca for unknowen size
+ input. [ruby-dev:31816]
* parse.y (rb_intern_str): prevent str from optimization.
-Sun Sep 23 06:16:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_method.ci (remove_method): check for undefined method.
- [ruby-dev:31816]
-
Sun Sep 23 05:42:35 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
* lib/rdoc/options.rb (Options::check_diagram): dot -V output
@@ -5484,305 +3236,60 @@ Sat Sep 22 05:19:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_init): separate from strio_initialize
to share with strio_reopen properly. [ruby-Bugs-13919]
-Fri Sep 21 14:51:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (gc_mark_rest): copy just used part.
-
- * gc.c (gc_mark_children): mark u1 and u2 of NODE_ARGSCAT.
-
- * gc.c (os_obj_of): hide T_VALUES too. [ruby-dev:31804]
-
- * gc.c (run_final): freeze temporary argument array.
-
-Fri Sep 21 04:58:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-style.el (ruby-style-label-indent): fix for function top
- level labels.
-
-Fri Sep 21 02:11:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_match_m): evaluate a block if match. it would make
- condition statement much shorter, if no else clause is needed.
-
- * string.c (rb_str_match_m): ditto.
-
-Fri Sep 21 02:02:34 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (hash_equal): should call rb_eql when argument eql is set.
-
-Thu Sep 20 17:28:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (popen_exec), process.c (rb_spawn): stop other threads before
- exec. [ruby-core:08262]
-
-Tue Sep 18 22:08:42 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/matrix.rb: fix a coerce bug of Vector. [ruby-core: 12190]
-
-Mon Sep 17 21:06:03 2007 Minero Aoki <aamine@loveruby.net>
+Fri Sep 21 15:46:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/http.rb (HTTP::GenericRequest#initialize): check path is
- not nil. [ruby-dev:31149]
+ * process.c (struct rb_exec_arg): proc should be a VALUE.
-Mon Sep 17 21:00:51 2007 Minero Aoki <aamine@loveruby.net>
+ * process.c (rb_f_exec): suppress a warning.
- * parse.y (ripper): rename event: arglist_* -> args_*.
+Fri Sep 21 03:05:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (ripper): rename event: restparam -> rest_param.
+ * eval.c, intern.h, ext/thread/thread.c: should not free queue while
+ any live threads are waiting. [ruby-dev:30653]
- * parse.y (ripper): rename event: constpath_* -> const_path_*.
+Thu Sep 20 17:24:59 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (ripper): rename event: topconst_* -> top_const_*.
+ * process.c (rb_detach_process): cast for the platforms where size of
+ pointer differs from size of int.
- * parse.y (ripper): rename event: iter_block -> method_add_block.
+ * process.c (rb_f_exec, rb_f_system): should not exceptions after
+ fork. [ruby-core:08262]
- * parse.y (ripper): support block local parameter declaration.
+Fri Sep 14 00:34:25 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * parse.y (ripper): introduce new macro params_new.
-
- * ext/ripper/lib/ripper/sexp.rb: should not dispose event
- arguments whose name ends with "_new" but arity != 0.
-
-Sat Sep 15 23:36:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (struct parser_params): common members in the parser and
- ripper must be placed at each same location.
-
-Sat Sep 15 18:25:15 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * string.c (rb_str_rstrip_bang): fixed too much rstrip. [ruby-dev:31786]
-
-Sat Sep 15 17:32:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_initialize): set default encoding. [ruby-dev:31787]
-
- * ruby.c (load_file): make new parse instance after processing shebang
- line options.
-
-Sat Sep 15 17:04:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * encoding.c (rb_enc_associate_index, rb_enc_get_index): check if
- object is encoding capable. [ruby-dev:31780]
-
- * string.c (rb_str_subpat_set): check for if the argument is a String.
-
-Sat Sep 15 13:31:21 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss.rb, lib/rss/, test/rss/:
- - 0.1.9 -> 0.2.0.
- - supported Slash module.
-
-Fri Sep 14 22:20:01 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (fev_unadvise): no needs to reset
- event handlers.
-
-Fri Sep 14 17:28:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_io.rb: tests which cause SEGV should not be
- added.
-
- * bootstraptest/test_knownbug.rb: add above test to known bug.
-
-Fri Sep 14 16:24:04 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_expandarray): assignment should be placed
- after creating new array.
-
-Fri Sep 14 16:17:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/runner.rb: add a stress test (-s).
-
-Fri Sep 14 16:14:28 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.h, eval_intern.h: move some macros to eval_intern.h.
-
- * eval_jump.ci (rb_f_throw): fix to use NEW_THROW_OBJECT().
-
- * eval.c (rb_f_loop): remove additional macro.
-
-Fri Sep 14 16:12:10 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_expandarray): should be volatile value for GC.
-
-Thu Sep 13 15:42:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (iseq_compile_each): inline cache entries are overwritten
- in iseq_build_body().
-
-Thu Sep 13 14:00:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (brace_block): should use compstmt. patch submitted by
- Kirill A. Shutemov <k.shutemov AT gmail.com> [ruby-core:12154].
-
-Thu Sep 13 13:47:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_id2str): fixed typo.
+ * lib/drb/extservm.rb (invoke_service): use Thread.exclusive instead of
+ Thread.critical
Wed Sep 12 23:12:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.c (proc_options): -W should be allowed in RUBYOPT
environment variable. [ruby-core:12118]
-Wed Sep 12 15:19:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_s_sysopen): should not use alloca for unknown size
- input. [ruby-dev:31775]
-
- * parse.y (rb_id2str): ditto.
-
- * marshal.c (w_float): use snprintf instead of sprintf.
-
-Tue Sep 11 17:28:00 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 Sep 11 17:25:59 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.
-
-Mon Sep 10 15:48:31 2007 Tanaka Akira <akr@fsij.org>
-
- * range.c: represent initialized state using EXCL instead of FL_USER3.
-
- * range.c (range_dumper): make uninitialized range dumpable.
- (range_loader): make uninitialized range loadable.
-
-Mon Sep 10 13:44:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_cycle): avoid infinite loop for empty array.
- based on a patch from David Flanagan. [ruby-core:12085]
-
-Mon Sep 10 01:21:23 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (r_object0): struct allocation first to check if a
- class is a struct. compatibility check should come next.
-
Mon Sep 10 01:05:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_step): fixed integer overflow. [ruby-dev:31763]
-Sun Sep 9 08:57:27 2007 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Sep 9 09:14:45 2007 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/format.rb (_strptime): now also attaches an element
which denotes leftover substring if exists.
-Sun Sep 9 01:59:08 2007 Tanaka Akira <akr@fsij.org>
-
- * marshal.c (r_object0): check T_STRUCT type for structs.
-
-Sun Sep 9 01:17:05 2007 Tanaka Akira <akr@fsij.org>
-
- * marshal.c (r_object0): don't call user-defined initialize for
- T_STRUCT objects.
-
- * include/ruby/intern.h (rb_struct_initialize): declared.
-
- * struct.c (rb_struct_initialize): export.
-
-Sat Sep 8 23:55:56 2007 Tanaka Akira <akr@fsij.org>
-
- * eval_method.ci (rb_get_alloc_func): new function to get allocation
- function.
-
- * include/ruby/intern.h (rb_alloc_func_t): declared.
- (rb_define_alloc_func): declared.
- (rb_marshal_define_compat): declared.
-
- * range.c: use T_STRUCT for Range.
-
- * inits.c: move Init_marshal() prior to Init_Range() because
- Init_Range calls rb_marshal_define_compat which needs
- marshal's compat_allocator_tbl initialized.
-
- * marshal.c: support marshal format compatibility layer designed for
- marshaling T_STRUCT Range using T_OBJECT format.
- (rb_marshal_define_compat): defined.
-
- [ruby-dev:31710]
-
-Sat Sep 8 10:05:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * struct.c (rb_struct_s_members): check if __members__ is an
- array to prevent segmentation fault. [ruby-dev:31759]
-
-Sat Sep 8 09:33:09 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (str[fp]time): now check specifications more
- strictly.
-
-Sat Sep 8 02:56:31 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/ruby/test_fiber.rb (TestFiber::test_throw): uncaught throw
- now raise ArgumentError exception.
-
-Sat Sep 8 02:45:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Sep 8 10:22:20 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* struct.c (rb_struct_s_members): should raise TypeError instead
of call rb_bug(). [ruby-dev:31709]
* marshal.c (r_object0): no nil check require any more.
-Sat Sep 8 01:46:36 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * regenc.c, regenc.h (onigenc_single_byte_mbc_enc_len): should take
- two arguments. [ruby-dev:31754]
-
-Fri Sep 7 00:58:16 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: fix typo.
+Sat Sep 8 09:38:19 2007 Tadayoshi Funaba <tadf@dotrb.org>
-Fri Sep 7 00:28:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_getc): forgot to commit rb_enc_mbclen() fix.
-
- * ext/stringio/stringio.c (strio_getc): rb_enc_mbclen() fix.
-
- * ext/stringio/stringio.c (strio_ungetc): ditto.
-
-Thu Sep 6 22:57:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/fileutils.rb (FileUtils::Entry_::copy): prevent self copy of
- directories.
-
- * lib/fileutils.rb (FileUtils::fu_each_src_dest0): use try_convert.
-
- * lib/fileutils.rb (FileUtils::fu_update_option): ditto.
-
-Thu Sep 6 21:36:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * include/ruby/oniguruma.h (OnigEncodingTypeST): add end parameter
- to mbc_enc_len.
-
- * euc_jp.c (mbc_enc_len), sjis.c (mbc_enc_len),
- utf8.c (utf8_mbc_enc_len): ditto.
-
- * encoding.c (rb_enc_mbclen): add end parameter.
-
-Thu Sep 6 21:31:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_cycle): typo in rdoc. a patch from Yugui
- <yugui@yugui.sakura.ne.jp>. [ruby-dev:31748]
+ * lib/date/format.rb (str[fp]time): now check specifications more
+ strictly.
-Thu Sep 6 12:42:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Sep 7 05:36:19 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * string.c (rb_str_succ, rb_str_chop_bang, rb_str_chop): m17n support.
- [ruby-dev:31734]
+ * test/rinda/test_rinda.rb (MockClock): correct synchronous problems
+ of the MultiThreading. [ruby-dev:31692]
Wed Sep 5 22:02:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -5796,983 +3303,93 @@ 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]
-Tue Sep 4 20:43:44 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_EVENT#unadvise.
-
- * test/win32ole/test_win32ole_event.rb: ditto.
-
-Mon Sep 3 15:37:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (vm.o): depends on st.h too.
-
-Sun Sep 2 23:38:29 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/st.h (struct st_table): make num_entries bitfield
- instead of num_bins for speed. num_entries has less access.
-
-Sun Sep 2 00:37:57 2007 Tadayoshi Funaba <tadf@dotrb.org>
+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 23:44:26 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval_jump.ci (rb_f_throw): wrap tag and TAG_THROW in a NODE_MEMO
- node to make throw instruction to work well.
-
-Sat Sep 1 20:56:07 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/ruby.h (struct RBignum): embed digits in RBignum for
- small bignums.
-
- * bignum.c: RBignum embedded digits implemented.
-
- * include/ruby/intern.h: declare rb_big_resize.
-
- * gc.c: don't free embedded digits.
-
- * numeric.c: replace direct bignum field accessor by abstract field
- accessor such as RBIGNUM(val)->sign to RBIGNUM_SIGN(val).
-
- * sprintf.c: ditto.
-
- * compar.c: ditto.
-
- * marshal.c: ditto.
-
- * random.c: ditto.
-
- * .gdbinit: support embedded small bignums.
-
- [ruby-dev:31689]
-
-Sat Sep 1 19:59:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_event_free): IConnectionPoint should be
- released.
-
- * ext/win32ole/win32ole.c (EVENTSINK_Destructor): ITypeInfo should be
- released.
-
- * ext/win32ole/win32ole.c (fev_initialize): refactoring.
-
-Sat Sep 1 16:26:09 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/socket/test_tcp.rb (test_recvfrom): same as mswin32 on mswin64.
-
-Sat Sep 1 14:24:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * st.c (st_numcmp, st_numhash): use st_data_t instead of long, because
- the former may be larger than the latter.
-
- * include/ruby/st.h (CHAR_BIT): get rid of magic number.
-
- * include/ruby/st.h (rb_index_t): use st_data_t for the platforms it
- is larger than int.
-
-Sat Sep 1 10:43:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval_jump.ci (rb_f_catch): generate new tag object if no argument is
- given. backported from MatzRuby. [ruby-dev:31609]
-
- * eval_jump.ci (rb_catch): call #catch without arguments if tag
- string is NULL.
-
- * eval_jump.ci (rb_f_throw): allow throwing non-symbol object.
-
- * eval_jump.ci (rb_catch_obj): new function to wait throw with arbitrary
- object.
-
- * eval_jump.ci (rb_throw_obj): new function to throw arbitrary object.
-
- * variable.c (check_autoload_table): prevent multiple calls from
- RSTRING_PTR().
-
-Fri Aug 31 07:12:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * numeric.c (SQRT_LONG_MAX): use SIZEOF_LONG instead of SIZEOF_VALUE
- because SIZEOF_VALUE > SIZEOF_LONG on some platforms.
+Sat Sep 1 08:13:36 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Fri Aug 31 04:18:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/win32ole/win32ole.c: add WIN32OLE#ole_activex_initialize.
- * parse.y (f_norm_arg, f_arg_item): not croak already erred names.
- [ruby-dev:31687]
-
- * parse.y (assignable_gen): ignore already erred names.
-
- * parse.y (shadowing_lvar_gen): always make new block local variable
- when shadowing outer local variable. [ruby-dev:31507]
-
-Thu Aug 30 19:40:33 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * regenc.h: check RUBY_EXTERN before including config.h and defines.h
-
- * common.mk: update header dependency.
-
-Thu Aug 30 14:06:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * proc.c (rb_obj_define_method): reverted. [ruby-talk:266637]
-
-Thu Aug 30 13:49:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb: initialize $top_srcdir always. [ruby-dev:31682]
+Thu Aug 30 13:13:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (try_const, have_const): check for a const is defined.
[ruby-core:04422]
-Thu Aug 30 08:00:12 2007 Tanaka Akira <akr@fsij.org>
-
- * include/ruby/intern.h: declare rb_hash_tbl.
-
- * include/ruby/ruby.h (RHash): delay st_table allocation.
- rename tbl field to ntbl to detect direct reference to the st_table
- as a compile error.
- (RHASH_TBL): abstract accessor defined.
- (RHASH_ITER_LEV): ditto.
- (RHASH_IFNONE): ditto.
- (RHASH_SIZE): ditto.
- (RHASH_EMPTY_P): ditto.
- (hash_alloc0, hash_alloc): unified because hash_alloc doesn't
- allocate st_table now.
-
- * hash.c: delay st_table allocation.
-
- * gc.c: replace tbl by ntbl.
-
- * array.c: replace direct field accessor by abstract field accessor
- such as RHASH(hash)->tbl to RHASH_TBL(hash).
-
- * marshal.c: ditto.
-
- * insns.def: ditto.
-
- * ext/iconv/iconv.c: ditto.
-
- * ext/json/ext/generator/generator.c: ditto.
+Thu Aug 30 13:10:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/json/ext/parser/parser.c: ditto.
-
- * ext/json/ext/parser/parser.rl: ditto.
-
- * ext/syck/rubyext.c: ditto.
-
- * ext/tk/tkutil/tkutil.c: ditto.
-
- [ruby-dev:31678]
-
-Wed Aug 29 18:36:06 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/open-uri.rb: add :ftp_active_mode option. [ruby-dev:31677]
-
-Wed Aug 29 14:55:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (str_gsub): should not use mbclen2() which has broken API.
-
- * re.c: remove rb_reg_mbclen2().
-
-Wed Aug 29 12:48:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * configure.in (group_member): check if presents.
- * parse.y (aref_args): args may not be a list. [ruby-dev:31592]
+ * configure.in (XCFLAGS): add _GNU_SOURCE on linux.
-Wed Aug 29 11:30:10 2007 Tanaka Akira <akr@fsij.org>
+ * file.c (group_member): use system routine if available.
- * include/ruby/st.h (struct st_table): add entries_packed 1-bit
- bitfield. decrease num_bins 1-bit.
+Thu Aug 30 08:24:18 2007 Tanaka Akira <akr@fsij.org>
- * st.c: pack numhash which have 5 or less entries in bins.
- (st_init_table_with_size): setup entries_packed flag.
- (st_clear): support packed mode.
- (st_lookup): ditto.
- (st_insert): ditto.
- (st_add_direct): ditto.
- (st_copy): ditto.
- (st_delete): ditto.
- (st_foreach): ditto.
- (st_reverse_foreach): ditto.
- (unpack_entries): new function for converting to unpacked mode.
+ * ruby.h (RHASH_TBL): defined for compatibility to 1.9.
+ * (RHASH_ITER_LEV): ditto.
+ * (RHASH_IFNONE): ditto.
+ * (RHASH_SIZE): ditto.
+ * (RHASH_EMPTY_P): ditto.
- [ruby-list:43954]
-
-Wed Aug 29 10:46:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Aug 29 13:05:59 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 19:16:00 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_type_progid): progid getted by
- ProgIDFromCLSID should be freed by CoTaskMemFree. Thanks, arton.
-
- * test/win32ole/test_win32ole.rb (test_raise_message): set negative
- compareMode value to raise WIN32OLERuntimeError.
-
- * test/win32ole/test_win32ole_type.rb (test_implemented_ole_types):
- support some environment which returns IShellDispatch5 instead
- of IShellDispatch.
+Tue Aug 28 23:26:12 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Tue Aug 28 15:42:09 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_subseq): retrieve substring based on byte offset.
-
- * string.c (rb_str_rindex_m): was confusing character offset and
- byte offset.
-
-Tue Aug 28 14:23:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_splice_0): should check to modify. [ruby-dev:31665]
-
-Tue Aug 28 14:21:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (parser_prepare): set parser encode too when BOM exists.
-
-Tue Aug 28 00:51:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c: fix Mutex to be interruptable lock.
-
- * thread_win32.ci, thread_win32.h, thread_pthread.ci, thread_pthread.h:
- prepare native_cond_*() which are based on pthread_cond_*() spec.
-
- * prelude.rb: fix Mutex#synchronize method.
-
- * vm_core.h, include/ruby/intern.h: change unblock function interface
- (to pass some user data).
-
- * file.c, process.c: ditto.
-
- * benchmark/bm_vm2_mutex.rb: add a benchmark for mutex.
-
- * benchmark/bm_vm3_thread_mutex.rb: add a benchmark for mutex
- with contention.
-
- * benchmark/run.rb: fix to remove ENV['RUBYLIB'] for matzruby.
-
- * test/ruby/test_thread.rb: add a test.
-
- * common.mk: fix benchmark options.
-
-Mon Aug 27 23:14:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_rstrip_bang): wrong strip point. [ruby-dev:31652]
-
- * string.c (rb_str_each_line): should swallow sequence of newlines
- if rs (optional argument) is an empty string. [ruby-dev:31652]
-
-Mon Aug 27 22:39:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * encoding.c (rb_enc_codelen): raises invalid sequence exception
- if ONIGENC_CODE_TO_MBCLEN() returns zero. [ruby-dev:31661]
-
- * encoding.c (rb_enc_mbclen): check invalid sequence.
-
-Mon Aug 27 20:27:59 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_type_progid): fix the bug.
+ * ext/win32ole/win32ole.c (ole_type_progid, reg_enum_key,
+ reg_get_val, ole_wc2mb): fix the bug. Thanks, arton.
[ruby-dev:31576]
- * test/win32ole/test_win32ole_type.rb (test_initialize):
- remove duplicate assertions.
-
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]
-Mon Aug 27 15:56:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (sym_encoding): return the encoding of a Symbol.
-
-Mon Aug 27 15:33:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * util.c (IEEE_BIG_ENDIAN): use configured value. [ruby-dev:31623]
-
- * util.c (Llong): set to LONG_LONG if available.
-
-Mon Aug 27 13:11:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (tr_trans): wrong condition for mbmaxlen==1 strings.
- [ruby-dev:31652]
-
-Mon Aug 27 00:41:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_each_byte): caused infinite loop. [ruby-dev:31652]
-
- * io.c (rb_io_getc): should return nil at EOF, not EOFError.
-
- * lib/delegate.rb (SimpleDelegator::__setobj__): use raise
- argument to specify backtrace.
-
- * test/ruby/test_fnmatch.rb (TestFnmatch::bracket_test):
- String#include? no longer works for Fixnum. use #chr.
- [ruby-dev:31652]
-
-Sun Aug 26 12:27:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: fix to remove Fiber.new until fiber.so is not loaded.
-
- * test/ruby/test_continuation.rb: fix to use resume.
-
-Sun Aug 26 06:51:46 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate
- buffer should be NULL terminated.
-
-Sun Aug 26 06:04:13 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_setup_method): reorder code for branch prediction.
-
-Sun Aug 26 05:54:49 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_call_method): fix to relaxant safe level check
- ($SAFE > 2). [ruby-core:11998]
-
- * bootstraptest/test_method.rb: add tests for above.
-
-Sun Aug 26 05:52:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_fiber.rb: fix to require 'continuation'.
-
-Sat Aug 25 23:52:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_next): message changed.
-
-Sat Aug 25 23:22:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * include/ruby/encoding.h: remove unused rb_enc_ismbchar().
-
-Sat Aug 25 22:50:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_event_free, EVENTSINK_Destructor,
- fev_initialize): remove the connection ole_event_free and
- EVENTSINK_Destructor.
-
-Sat Aug 25 17:52:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * string.c, include/ruby/intern.h: export rb_str_length().
-
- * insns.def: use rb_str_length() in opt_length.
-
-Sat Aug 25 17:48:51 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: rename FIBER_STACK_SIZE to FIBER_VM_STACK_SIZE.
-
-Sat Aug 25 17:05:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (swallow): removed condition using an unset variable.
-
- * parse.y, re.c: re-applied revision 13092.
-
- * string.c (rb_str_splice): return from void function.
-
- * include/ruby/encoding.h (rb_enc_str_new): prototype added.
-
-Sat Aug 25 11:45:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * encoding.c: provide basic features for M17N.
-
- * parse.y: encoding aware parsing.
-
- * parse.y (pragma_encoding): encoding specification pragma.
-
- * parse.y (rb_intern3): encoding specified symbols.
-
- * string.c (rb_str_length): length based on characters.
- for older behavior, bytesize method added.
-
- * string.c (rb_str_index_m): index based on characters. rindex as
- well.
-
- * string.c (succ_char): encoding aware succeeding string.
-
- * string.c (rb_str_reverse): reverse based on characters.
-
- * string.c (rb_str_inspect): encoding aware string description.
-
- * string.c (rb_str_upcase_bang): encoding aware case conversion.
- downcase, capitalize, swapcase as well.
-
- * string.c (rb_str_tr_bang): tr based on characters. delete,
- squeeze, tr_s, count as well.
-
- * string.c (rb_str_split_m): split based on characters.
-
- * string.c (rb_str_each_line): encoding aware each_line.
-
- * string.c (rb_str_each_char): added. iteration based on
- characters.
-
- * string.c (rb_str_strip_bang): encoding aware whitespace
- stripping. lstrip, rstrip as well.
-
- * string.c (rb_str_justify): encoding aware justifying (ljust,
- rjust, center).
-
- * string.c (str_encoding): get encoding attribute from a string.
-
- * re.c (rb_reg_initialize): encoding aware regular expression
-
- * sprintf.c (rb_str_format): formatting (i.e. length count) based
- on characters.
-
- * io.c (rb_io_getc): getc to return one-character string.
- for older behavior, getbyte method added.
-
- * ext/stringio/stringio.c (strio_getc): ditto.
-
- * io.c (rb_io_ungetc): allow pushing arbitrary string at the
- current reading point.
-
- * ext/stringio/stringio.c (strio_ungetc): ditto.
-
- * ext/strscan/strscan.c: encoding support.
-
-Sat Aug 25 10:59:19 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: separate Continuation and Fiber from core.
-
- * ext/continuation/*, ext/fiber/*: ditto.
-
- * include/ruby/ruby.h: remove rb_cFiber.
-
- * include/ruby/intern.h: add the rb_fiber_new() declaration.
-
- * enumerator.c (next_init): fix to use rb_fiber_new().
-
- * test/ruby/test_enumerator.rb: remove next? tests.
-
- * test/ruby/test_continuation.rb: add a require 'continuation'.
-
- * test/ruby/test_fiber.rb: add a require 'fiber'.
-
-Sat Aug 25 10:20:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (prelude.o): depends on vm_core.h now.
-
- * common.mk (prelude.c): depends on tool/compile_prelude.rb too.
-
- * common.mk (prereq): updates all auto-generated sources.
-
- * tool/compile_prelude.rb: separated dynamic and static portions.
-
-Sat Aug 25 10:05:17 2007 Koichi Sasada <ko1@atdot.net>
-
- * prelude.rb: add Thread.exclusive. This class method
- is different from 1.8's. Thread.exclusive only does
- synchronize with VM global mutex.
-
-Sat Aug 25 09:39:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_s_try_convert): more document description.
-
- * re.c (rb_reg_s_try_convert): typo fixed.
-
-Sat Aug 25 08:54:12 2007 Koichi Sasada <ko1@atdot.net>
-
- * id.h, id.c: remove idFuncall.
-
- * compile.c (iseq_specialized_instruction): ditto.
-
-Sat Aug 25 08:47:28 2007 Koichi Sasada <ko1@atdot.net>
-
- * tool/compile_prelude.rb: fix to include "vm_core.h".
-
-Sat Aug 25 03:49:14 2007 Tanaka Akira <akr@fsij.org>
-
- * test/ruby/sentence.rb (Sentence): include Enumerable.
- (Sentence#each): defined.
-
- * test/ruby/test_assignment.rb: use Sentence#expand.
-
-Sat Aug 25 03:08:57 2007 Koichi Sasada <ko1@atdot.net>
-
- * prelude.rb: fix Mutex#synchronize definition.
-
-Sat Aug 25 02:08:45 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_s_try_convert): a new class method to convert
- object or nil if it's not target-type. this mechanism is used
- to convert types in the C implemented methods.
-
- * hash.c (rb_hash_s_try_convert): ditto.
-
- * io.c (rb_io_s_try_convert): ditto.
-
- * re.c (rb_reg_s_try_convert): ditto.
-
- * string.c (rb_str_s_try_convert): ditto.
-
-Sat Aug 25 00:49:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_loop_generator.rb: added.
-
-Sat Aug 25 00:22:31 2007 Koichi Sasada <ko1@atdot.net>
-
- * prelude.rb: added. run this script on startup.
-
- * tool/compile_prelude.rb: compile prelude.rb to C string.
- (prelude.rb -> prelude.c)
-
- * common.mk: fix to build with prelude.c.
-
- * inits.c (rb_call_inits): ditto.
-
- * thread.c (Init_Thread): move definition of Mutex#synchronize
- to prelude.rb.
-
-Sat Aug 25 00:08:43 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (compile_massign_opt): fix to skip massign optimization
- with global variables.
-
- * bootstraptest/test_massign.rb: add some tests for above.
-
-Fri Aug 24 18:42:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/ruby/test_dir.rb (TestDir::setup): ?c now makes a string.
-
- * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::initialize):
- initialize @workdir to stop warning.
-
-Fri Aug 24 18:30:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/drb/drb.rb (DRb::DRbServer::InvokeMethod::perform_without_block):
- replace funcall by send!. other files in the distribution as well.
-
-Fri Aug 24 17:06:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_send_bang): abandon the name funcall for private
- aware method call.
-
-Fri Aug 24 15:27:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_next): stop pre-fetching.
-
- * enumerator.c (Init_Enumerator): remove next? method.
-
-Fri Aug 24 15:14:57 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_loop): now handles StopIteration exception.
-
-Thu Aug 23 20:31:31 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: optimize simple massign.
-
-Thu Aug 23 20:02:25 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (reg_get_value): use RegQueryValueEx instead
- of RegQueryValueEx.
-
- * ext/win32ole/win32ole.c (typelib_file_from_clsid): fix the bug
- that the function always returns Qnil.
-
- * test/win32ole/test_win32ole_type.rb (test_initialize): add some test.
-
-Thu Aug 23 17:25:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (group_member): check if presents.
-
- * configure.in (XCFLAGS): add _GNU_SOURCE on linux.
-
- * file.c (group_member): use system routine if available.
-
- * process.c: moved _GNU_SOURCE macro to Makefile.
-
-Thu Aug 23 16:59:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (compile_massign), insnhelper.ci (vm_throw): not use C99
- comment.
-
- * cont.c (rb_cont_call, fiber_switch, rb_fiber_resume, rb_fiber_yield):
- suppress warnings.
-
- * cont.c (rb_fiber_start): change on non-volatile variable between
- setjmp and longjmp may not has an effect.
-
- * enumerator.c (sym_call): initialize first.
-
- * enumerator.c (enum_iter): typedefed.
-
- * enumerator.c (next_i): suppress a warning.
-
-Thu Aug 23 16:04:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def, parse.y: fix massign order. This change
- causes performance problem. Try vm1_swap benchmark.
- [ruby-dev:31522]
-
- * insns.def, insnhelper.ci: move process body of expandarray insn to
- vm_expandarray().
-
- * bootstraptest/test_knownbug.rb, bootstraptest/test_massign.rb:
- move a solved test.
-
-Thu Aug 23 15:51:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (f_norm_arg): ripper has no shadowing check.
-
- * parse.y (f_block_arg): dispatch blkarg_mark.
-
-Thu Aug 23 15:48:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (make_masgn_lhs, iseq_compile_each): fixed indent.
-
- * compile.c (iseq_translate_threaded_code),
- vm_evalbody.ci (get_insns_address_table),
- template/vmtc.inc.tmpl (insns_address_table): constified.
-
- * vm_evalbody.ci (vm_eval),
- template/insns_info.inc.tmpl (insn_stack_increase, insn_ret_num):
- suppress warnings.
-
-Thu Aug 23 13:19:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (f_norm_arg): check also nested arguments. [ruby-dev:31502]
-
-Thu Aug 23 00:06:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * util.c: updated for ANSI C only. applied a patch from
- <snakagawa AT infoteria.co.jp>. [ruby-dev:31591]
-
-Thu Aug 23 00:04:45 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * missing/strtod.c: removed. [ruby-dev:31588]
-
- * LEGAL: updated.
-
-Wed Aug 22 15:59:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_knownbug.rb:
- fix typo of filename (test_knwonbug.rb).
-
-Wed Aug 22 14:04:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_knwonbug.rb: added. This file will contain
- test cases which point out known bug. If bug is fixed, tests
- should move to the suitable place.
-
- * bootstraptest/test_massign.rb: move a test which show known bug
- to test_knownbug.rb.
-
-Wed Aug 22 13:02:26 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (in_temporary_working_directory):
- don't remove the directory specified by --dir.
-
-Wed Aug 22 05:51:23 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * util.c (ruby_strtod): replaced by the implementation by David
- M. Gay inspired by William D. Clinger's paper "How to Read Floating
- Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
- a patch from Satoshi Nakagawa <snakagawa AT infoteria.co.jp>.
- [ruby-dev:31582]
-
- * test/ruby/test_float.rb (TestFloat::test_float): add test for
- precision.
-
-Wed Aug 22 03:51:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: add Fiber#resume and Fiber.yield.
- and Fiber::Core class to realize Coroutine.
-
- * include/ruby/intern.h: declare rb_fiber_yield(), rb_fiber_resume().
-
- * enumerator.c: use above api.
-
- * test/ruby/test_fiber.rb: fix and add tests for above changes.
-
Tue Aug 21 21:09:48 2007 Tanaka Akira <akr@fsij.org>
* lib/tmpdir.rb (Dir.mktmpdir): make directory suffix specifiable.
- suggested by knu. [ruby-dev:31568]
-
-Tue Aug 21 15:00:23 2007 Koichi Sasada <ko1@atdot.net>
-
- * st.c (st_clear): reset num_entries too.
Tue Aug 21 13:57:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* hash.c (st_foreach_func, rb_foreach_func): typedefed.
- * hash.c (rb_hash_clear): use st_clear() unless iterating.
-
- * st.c (struct st_table_entry): add new members, fore and back, to
- iterate in inserted order.
-
- * include/ruby/st.h (struct st_table): ditto.
-
-Tue Aug 21 04:09:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_vm2_case.rb: add a new benchmark.
- YARV optimize case/when syntax. If every conditions
- are literal (such as Symbol, Fixnum, String), dispatch
- calc order will be O(1).
-
-Tue Aug 21 04:08:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_enumerator.rb: fix last commit.
-
-Tue Aug 21 03:59:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * test_enumerator.rb (enum_test): fix to return sorted
- array (for Hash test).
+Mon Aug 20 17:25:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Aug 21 03:55:20 2007 Koichi Sasada <ko1@atdot.net>
+ * eval.c (mnew): should preserve noex as safe_level.
- * enumerator.c (next_i): fix to return with Fiber#yield at
- the end of each block. [ruby-dev:31470]
+ * eval.c (rb_call0): tighten security check condition..
- * enumerator.c (enumerator_next_p): call init_next if not
- initialized. [ruby-dev:31514]
+Sat Aug 18 21:32:20 2007 Tanaka Akira <akr@fsij.org>
- * test/ruby/test_enumerator.rb: add tests for Enumerator.
-
-Mon Aug 20 23:28:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (Init_String): remove Symbol.intern and Symbol#dump.
- [ruby-dev:31525]
-
- * dir.c (dir_foreach): return Enumerator if no block given.
- [ruby-dev:31525]
-
- * io.c (rb_io_s_foreach): argument count check before making
- Enumerator. [ruby-dev:31525]
-
-Mon Aug 20 23:17:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * vm_core.h (struct rb_thread_struct): removed first_func_arg and
- reuse first_args instead.
-
-Sun Aug 19 13:31:40 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c: use VALGRIND_MAKE_MEM_UNDEFINED to detect use of collected
- objects if valgrind is available. It cannot detect first 2 words
- because they are used as the free list.
-
-Sun Aug 19 13:13:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each/NODE_RESBODY): fix to add
- additional nop to prevent tailcall optimization.
-
- * vm_opts.h: clean up comments.
-
-Sun Aug 19 12:58:39 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_call_bmethod): fix to propagate information
- that this proc is "from Method". [ruby-dev:31490]
-
- * proc.c (method_proc, rb_mod_define_method): ditto.
-
- * vm.c (vm_invoke_proc_core): removed.
-
- * vm_core.h: ditto.
-
-Sun Aug 19 12:36:11 2007 Tanaka Akira <akr@fsij.org>
-
- * test/ruby/sentence.rb: new method Sentence().
-
-Sun Aug 19 12:32:39 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_callee_setup_arg): fix to mark enough VM stack.
- [ruby-dev:31492]
-
-Sat Aug 18 19:02:34 2007 Tanaka Akira <akr@fsij.org>
-
- * test/ruby/test_yield.rb (TestYieldGen): relax array size check
- in nested parameters.
- [ruby-dev:31485]
+ * 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 17:40:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
-
-Sat Aug 18 16:44:15 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_call_bmethod),
- vm.c (vm_invoke_proc_core): fix to do not restore
- $SAFE when proc invoked by bmethod.
-
- * vm_core.h: ditto.
-
-Sat Aug 18 16:44:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_error.ci (ruby_error_print): call error_print.
-
- * eval_jump.ci, process.c (rb_exit, rb_f_exit, rb_f_abort): moved.
-
Sat Aug 18 15:59:52 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 15:52:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insnhelper.ci (vm_send_optimize): use MEMMOVE to shift values inside
- an array.
-
-Sat Aug 18 15:45:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insnhelper.ci (vm_yield_setup_args): rsize and psize should not be
- negative.
-
-Sat Aug 18 14:35:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insnhelper.ci (vm_callee_setup_arg, vm_send_optimize,
- vm_yield_setup_args): bulk copy for arguments.
-
-Sat Aug 18 13:55:58 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix to allow self.x=
- if x= is private.
-
- * bootstraptest/test_method.rb: add a test for above.
-
-Sat Aug 18 14:05:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (reg_compile_gen): obtain error info from errinfo.
-
- * re.c (rb_reg_error_desc): make RegexpError for initialization error.
-
- * re.c (rb_reg_compile): return nil and set errinfo if error.
-
-Sat Aug 18 13:23:01 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c: $! should not be writable.
-
- * eval.c (rb_rubylevel_errinfo): added. rb_errinfo() returns
- rb_thread_t#errinfo. rb_rubylevel_errinfo() returns $! value.
-
-Sat Aug 18 13:14:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_callee_setup_arg): fix to check arguments
- correctly. [ruby-dev:31472]
-
-Sat Aug 18 13:13:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/test_exception.rb: add escape character ("\") for
- editors.
-
-Sat Aug 18 12:42:50 2007 Tanaka Akira <akr@fsij.org>
-
- * test/ruby/test_yield.rb (TestYieldGen): add test for yielding to
- lambda using lambda parameter passing emulator.
-
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.
-Sat Aug 18 11:44:59 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_set_arguments), insnhelper.ci
- (vm_callee_setup_arg, vm_yield_setup_args):
- fix to cause raise on "lambda{|a|}.call(1, 2)".
- [ruby-dev:31464]
-
- * bootstraptest/test_block.rb: add tests for above.
-
-Sat Aug 18 01:12:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (frame_func_id): return proper method ID.
-
-Fri Aug 17 22:43:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): massign should return rvalue(s).
-
-Fri Aug 17 22:10:19 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_basicinstructions.rb: fix old tests.
- class variables should be inherited.
-
-Fri Aug 17 21:20:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (rb_call), eval_method.ci (rb_add_method, rb_alias),
- insnhelper.ci (vm_call_method): fix to save safelevel for
- method node.
-
- * include/ruby/node.h: ditto.
-
- * bootstraptest/test_method.rb: add a test for above.
-
-Fri Aug 17 16:02:50 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (rb_thread_terminate_all): fix to ignore
- exceptions.
-
- * thread.c (thread_start_func_2): fix
- abort_on_exception process. [ruby-dev:31394]
-
-Fri Aug 17 14:38:36 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (in_temporary_working_directory): use
- Dir.mktmpdir to create and remove temporary directory.
- (Dir.mktmpdir): define if not available.
- [ruby-dev:31431]
-
-Fri Aug 17 03:07:37 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix throw insn option of next.
-
-Fri Aug 17 01:25:23 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_set_arguments), insnhelper.ci
- (vm_callee_setup_arg, vm_yield_setup_args): fix
- block parameter problems. [ruby-dev:31437], [ruby-dev:31440]
-
- * bootstraptest/test_block.rb: add a test of [ruby-dev:31440].
-
-Fri Aug 17 01:24:12 2007 Koichi Sasada <ko1@atdot.net>
-
- * iseq.c (ruby_iseq_disasm): fix to show arg_simple value.
-
-Fri Aug 17 01:21:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (throw): insert a RUBY_VM_CHECK_INTS(). [ruby-dev:31361]
-
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]
- * sprintf.c (rb_str_format): small float should not call
- rb_dbl2big().
-
-Thu Aug 16 22:10:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix next/redo stack consistency.
- [ruby-dev:31373]
-
- * bootstraptest/test_syntax.rb: add tests for above.
-
- * sample/test.rb: fix to use __FILE__ instead of $0 to know basedir.
-
-Thu Aug 16 21:14:06 2007 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in (BASERUBY): need AC_SUBST. [ruby-dev:31438]
-
-Thu Aug 16 19:18:26 2007 Tanaka Akira <akr@fsij.org>
-
- * test/ruby/sentence.rb: Sentence class implemented
- based on sentgen.rb
-
- * test/ruby/sentgen.rb: removed.
-
- * test/ruby/test_assignment.rb: use sentence.rb.
-
- * test/ruby/test_yield.rb: block parameter passing emulator
- implemented.
-
-Thu Aug 16 16:48:47 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (BASERUBY): check if base ruby is runnable first.
- [ruby-core:11900]
-
Thu Aug 16 16:46:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (aix): enable shared by default.
@@ -6790,49 +3407,10 @@ Thu Aug 16 13:06:08 2007 Tanaka Akira <akr@fsij.org>
(big_rshift): ditto.
[ruby-dev:31434]
-Thu Aug 16 06:29:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (argf_readpartial): argf_forward needs argc and argv.
-
-Thu Aug 16 02:47:39 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_fiber_m_yield): added. use this function
- for Fiber#yield instead of rb_fiber_yield.
-
-Thu Aug 16 00:36:52 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/tmpdir.rb (Dir.mktmpdir): new method. [ruby-dev:31416]
-
-Wed Aug 15 18:57:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * gc.c (os_live_obj): fix to skip T_VALUES.
-
- * sample/test.rb: add an ObjectSpace test.
-
-Wed Aug 15 16:49:04 2007 Koichi Sasada <ko1@atdot.net>
-
- * inits.c (rb_call_inits): change initializing order.
- [ruby-dev:31420]
-
-Wed Aug 15 16:44:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (ARGF_FORWARD): wrongly compares with current_file with
- rb_stdout. should be rb_stdin. [ruby-cvs:20177]
-
-Wed Aug 15 14:59:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_initialize, argf_each_line, argf_each_byte): suppress
- warnings.
+Thu Aug 16 04:09:19 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Wed Aug 15 14:22:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y: remove "//" type comment.
-
-Wed Aug 15 13:42:15 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y: fix rules around f_margs. "make test" passes all tests.
-
- * bootstraptest/test_block.rb: add some tests for above.
+ * lib/rinda/tuplespace.rb (Rinda::TupleSpace#start_keeper): improve
+ keeper thread.
Wed Aug 15 13:50:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -6843,212 +3421,18 @@ 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]
-Wed Aug 15 13:39:25 2007 Koichi Sasada <ko1@atdot.net>
-
- * process.c (proc_geteuid): fix strange conversion. [ruby-dev:31417]
-
-Wed Aug 15 01:05:55 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (assert_check): don't call newtest.
- (assert_equal): call newtest.
- (assert_match): ditto.
-
-Tue Aug 14 21:43:39 2007 Tanaka Akira <akr@fsij.org>
-
- * bootstraptest/runner.rb (assert_check): new method.
- (assert_match): new method.
- (assert_equal): use assert_check.
- (pretty): give failure description as an argument.
-
- * bootstraptest/test_exception.rb: use assert_match to describe the
- test for [ruby-dev:31407]. [ruby-dev:31412]
-
-Tue Aug 14 19:53:15 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c (Init_Proc), eval.c (Init_eval), eval_intern.h: move
- init place of exception_error.
-
- * inits.c: ditto.
-
- * eval.c (Init_eval): set exception_error#throwed_state as TAG_FATAL.
- [ruby-dev:31407]
-
- * bootstraptest/test_exception.rb: add a test for above.
-
-Tue Aug 14 19:51:20 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: change test order (test -> btest).
-
-Tue Aug 14 00:04:27 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: 0.1.8 -> 0.1.9.
-
- * test/rss/test_version.rb: followed the above change.
-
- * lib/rss/parser.rb: fixed a bug that handles unintended elements.
- Thanks to Takuo Yonezawa. [ruby-list:43841]
-
-Mon Aug 13 17:23:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_clear_trace_func, rb_thread_stop_timer_thread):
- declarations for forward references.
-
- * eval.c (rb_longjmp, eval): use local variable.
-
- * eval.c (rb_longjmp): string object not to be optimized.
-
-Mon Aug 13 13:21:58 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/open-uri.rb: make ftp passive mode to avoid NAT problem.
- [ruby-dev:31377]
-
-Mon Aug 13 09:18:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_getc): should returns
- one-character string.
-
- * ext/stringio/stringio.c: remove unnecessary prototypes.
-
- * ext/stringio/stringio.c (strio_getbyte): new method.
-
- * ext/stringio/stringio.c (strio_readbyte): new method.
-
- * ext/stringio/stringio.c (strio_ungetc): should take a string as
- an input.
-
-Mon Aug 13 08:19:43 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (argf_close): always close via method.
-
- * io.c (Init_IO): remove obsolete Kernel#getc.
+Sun Arg 12 03:56:30 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Mon Aug 13 05:03:53 2007 Koichi Sasada <ko1@atdot.net>
+ * lib/rinda/tuplespace.rb: fix Rinda::TupleSpace keeper thread bug.
+ the thread is started too early. [ruby-talk:264062]
- * thread.c (rb_thread_raise): check if target thread is
- thrown by another thread or not. [ruby-dev:31371]
-
- * bootstraptest/test_thread.rb: add a test for above.
-
-Mon Aug 13 04:35:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_peephole_optimize): fix peephole optimization
- bug. [ruby-dev:31360]
-
- * bootstraptest/test_syntax.rb: add a test for above.
-
-Mon Aug 13 04:02:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm_dump.c (debug_print_pre): fix to show control frame count.
-
- * insns.def (opt_call_c_function): fix operand type.
-
- * lib/vm/instruction.rb: ditto.
-
- * insnhelper.ci (vm_push_frame, vm_pop_frame): fix to show
- control stack status on if VMDEBUG == 2.
-
- * vm.h: add a comment about VMDEBUG.
-
- * iseq.c (find_prev_line_no): fix to skip bug report if
- line is not found.
-
- * lib/vm/instruction.rb: fix to use build_string() on
- source code generators.
-
-Mon Aug 13 03:57:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * template/yasmdata.rb.tmpl: fix type and name.
-
-Sat Aug 11 23:27:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (argf_each_line): should use #each_line, not #each.
-
- * io.c (argf_each_line): simplified.
-
- * io.c (argf_getline): should handle non T_FILE object in ARGV.
-
- * io.c (argf_each_byte): each_byte should yield bytes not
- one-character strings. [ruby-dev:31374]
+ * test/rinda/test_rinda.rb: ditto.
-Sat Aug 11 07:24:55 2007 Tadayoshi Funaba <tadf@dotrb.org>
+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).
-Sat Aug 11 00:01:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (thread_start_func_2): not re-raise to main thread if it is
- joining the current thread.
-
-Fri Aug 10 23:54:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (thread_create_core): inherit the priority of creating
- thread. submitted at [ruby-core:11873] by David Flanagan <david AT
- davidflanagan.com>. [ruby-core:11876]
-
-Fri Aug 10 05:12:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (thread_start_func_2): let abort_on_exception work.
- [ruby-core:11873]
-
-Fri Aug 10 04:47:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (internal_id_gen): internal ID must be bigger than
- tLAST_TOKEN.
-
-Thu Aug 9 16:04:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (stmt): check if rhs has value before assignment instead
- inside node_assign_gen(). [ruby-dev:31293]
-
- * parse.y (call_bin_op_gen, call_uni_op_gen): split call_op_gen.
-
-Thu Aug 9 14:01:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (f_marg_list): renamed from f_marg_head.
-
- * parse.y (f_margs): allow multiple mandatory arguments after a splat.
- [ruby-dev:31153]
-
-Thu Aug 9 02:02:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_cycle): typo fixed. a patch from Kazuhiro
- NISHIYAMA <zn AT mbf.nifty.com>. [ruby-dev:31362]
-
-Wed Aug 8 19:17:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dl/cptr.c (rb_dlptr_s_to_ptr): no longer check
- HAVE_RB_IO_STDIO_FILE.
-
-Wed Aug 8 15:52:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_next_p): should check correctly even when
- e.next has not been called before.
-
- * enumerator.c (enumerator_next): raise StopIteration (name taken
- from Python) instead of IndexError.
-
- * enum.c (enum_zip): catch StopIteration exception.
-
- * enumerator.c (enumerator_with_index): return Enumerator if no
- block is given.
-
- * test/ruby/test_iterator.rb (TestIterator::test_enumerator): add
- test for enumerators.
-
-Wed Aug 8 11:48:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_big2str0): should not use RTEST for non-VALUE.
-
-Wed Aug 8 11:25:25 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * bignum.c (rb_big2str0): should preserve sign mark.
-
-Wed Aug 8 11:02:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (btest-miniruby, test-sample): split the test target
- so that -k option works.
-
Tue Aug 7 14:58:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/pty.c (establishShell): handshaking before close slave
@@ -7060,130 +3444,15 @@ Tue Aug 7 14:58:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/expect_sample.rb: support for autologin.
-Tue Aug 7 13:58:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * include/ruby/ruby.h (ruby_special_consts): added RUBY_SPECIAL_SHIFT.
-
- * .gdbinit: some improvements.
-
-Tue Aug 7 13:28:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (node_name.inc): use $? instead of $< for nmake.
- [ruby-dev:31356]
-
Tue Aug 7 12:45:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (ac_cv_func_isinf): set yes also on OpenSolaris.
[ruby-Bugs-12859]
-Tue Aug 7 12:31:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (pipe_open): fix for win32 platforms.
-
-Tue Aug 7 02:58:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big2str0): make Bignum#to_s even faster. a patch
- from Kenta Murata <muraken AT gmail.com>. [ruby-dev:31354]
-
-Tue Aug 7 01:42:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_zip): zip no longer converts arguments into
- arrays, uses enumerators.
-
-Tue Aug 7 01:27:47 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * cont.c (rb_fiber_yield): change argument ordering. export.
-
- * cont.c (rb_fiber_current): export
-
- * include/ruby/intern.h: export several functions from cont.c.
-
- * enumerator.c (enumerator_next): new method to implement external
- iterator (generator) using fiber.
-
- * enumerator.c (enumerator_next_p): new method to check whether
- any element is left in the generator sequence.
-
- * enumerator.c (enumerator_rewind): a new method to rewind the
- generator sequence.
-
-Tue Aug 7 01:15:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_cycle): new method to cycle enumerable forever.
-
-Tue Aug 7 00:05:38 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * irb/ruby-lex.rb: support for '\c'. [ruby-talk:263508]
-
-Mon Aug 6 20:29:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci, insns.def: move some statements to functions.
-
- * vm.c, vm.h, vm_evalbody.ci: fix include/typedef places.
-
-Mon Aug 6 18:41:12 2007 Koichi Sasada <ko1@atdot.net>
-
- * lib/vm/instruction.rb (make_header_analysys): fix last commit.
-
-Mon Aug 6 18:33:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * lib/vm/instruction.rb (make_header_analysys): add to separate
- header addition process.
-
Mon Aug 6 17:36:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rexml/encodings/{ISO-8859-15,CP-1252}.rb: fixed invalid syntax.
-Mon Aug 6 16:57:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * sample/test.rb: fix to output file name if it contains
- invalid syntax.
-
-Mon Aug 6 16:41:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y (value_expr_gen): fix to cause "void value expression"
- when jump expression such as "next" are shown on value_expr().
- [ruby-dev:31119]
-
- * bootstraptest/test_syntax.rb: fix to above change.
-
-Mon Aug 6 14:36:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y: fix a f_marg rule. [ruby-dev:31160]
-
-Mon Aug 6 14:29:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/runner.rb (assert_equal): add additional
- message parameter.
-
-Mon Aug 6 13:34:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk (INSNS): not chdir to srcdir.
-
- * common.mk (node_name.inc): auto-generate node name list.
-
- * iseq.c (ruby_node_name): ditto.
-
- * iseq.c (iseq_s_compile_option_get, Init_ISeq): added a new
- method VM::InstructionSequence::compile_option.
-
- * lib/vm/instruction.rb (RubyVM::SourceCodeGenerator): --destdir
- option.
-
- * tool/node_name.rb: to auto-generate node name list.
-
-Sun Aug 5 11:51:39 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss, sample/rss, test/rss:
- - 0.1.7 -> 0.1.8.
- - supported <itunes:XXX>.
- - reverted backward incompatibility API changes introduced 0.1.7.
-
-Sun Aug 5 04:56:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (pipe_open_v, pipe_open_s): separate array and string
- cases. [ruby-dev:31344]
-
Fri Aug 3 11:05:54 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): save all CONFIG values.
@@ -7202,47 +3471,11 @@ Fri Aug 3 07:09:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (find_type): new method.
-Fri Aug 3 00:00:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (big2str_table): base cannot be 0 or 1.
-
-Thu Aug 2 23:42:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (reg_compile_gen): set error if failed to compile regexp
- literal. [ruby-dev:31336]
-
- * re.c (option_to_str, arg_kcode, opt_kcode): options conversion
- between int and string.
-
- * re.c (rb_reg_compile): should not use regexp which could not get
- initialized. [ruby-dev:31333]
- return error message to let the parser know it.
-
- * re.c (rb_reg_compile): append regexp options to error message.
- [ruby-dev:31334]
-
-Thu Aug 2 22:05:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big2str0): faster Bignum#to_s using Karatsuba
- algorithm. a patch from Yusuke ENDOH <mame AT tsg.ne.jp>
- in [ruby-dev:31312], slightly modified by Kenta Murata
- <muraken AT gmail.com> in [ruby-dev:31339].
-
Thu Aug 2 13:46:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_f_sprintf): should not check positional number as
width. [ruby-core:11838]
-Wed Aug 1 12:40:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * generic.rb (URI::Generic::merge_path): behave as RFC 3986.
- [ruby-talk:252052]
-
-Tue Jul 31 23:38:09 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (_parse): now interprets slashed numerical
- dates as a big endian (except dd/mm/yyyy). [experimental]
-
Mon Jul 30 11:16:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_aref): check for Bignum index range.
@@ -7253,11 +3486,6 @@ 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 20:40:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (range_eqq): call_super() in === does not work well
- since Enumerable#=== has different behavior. [ruby-dev:31296]
-
Thu Jul 26 13:57:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (load_1, dln_find_1): constified.
@@ -7274,37 +3502,12 @@ Thu Jul 26 13:57:45 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (ruby_init_loadpath): not convert built-in paths.
-Tue Jul 24 10:37:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_f_p): return nil if no argument. [ruby-dev:31285]
-
-Tue Jul 24 01:05:07 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * regint.h (USE_MATCH_RANGE_IS_COMPLETE_RANGE): undef to achieve old
- rindex behavior. [ruby-dev:31265]
-
-Mon Jul 23 18:37:14 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * include/ruby/oniguruma.h: upgrade to Oniguruma 5.9.0. fixes
- some memory violation. [ruby-dev:31070]
-
-Sun Jul 22 20:09:49 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb (Date._parse): now accepts some new
- hints. [experimental]
-
- * lib/parsedate.rb: followed the changes on
- lib/date/format.rb. [experimental]
-
-Sun Jul 22 16:06:56 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (is_ruby_native_thread): made an int function as
- well as version 1.8.
+Sun Jul 22 16:07:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * include/ruby/ruby.h (is_ruby_native_thread): moved prototype
- from intern.h as well as version 1.8.
+ * intern.h (is_ruby_native_thread): removed since declared as an int
+ function in ruby.h already.
-Sun Jul 22 14:33:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jul 22 14:33:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_rename): deleted code to get rid of a bug of
old Cygwin.
@@ -7312,7 +3515,7 @@ Sun Jul 22 14:33:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_truncate): added prototype of GetLastError()
on cygwin. [ruby-dev:31239]
- * include/ruby/intern.h (is_ruby_native_thread): prototype.
+ * intern.h (is_ruby_native_thread): prototype.
* missing/strftime.c (strftime): fix printf format and actual
arguments.
@@ -7321,35 +3524,21 @@ Sun Jul 22 14:33:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/tk/tcltklib.c (ip_finalize): ditto.
- * ext/win32ole/win32ole.c (lcid_installed): ditto.
+ * ext/dl/ptr.c (rb_dlptr_inspect): ditto. [ruby-dev:31268]
- * ext/socket/getnameinfo.c: include stdio.h always.
-
-Sat Jul 21 21:39:12 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb, lib/date/format.rb (Date._parse): now can take some
- hints (its aim must be mainly determination of endianness of
- date). [experimental]
+ * ext/dl/sym.c (rb_dlsym_inspect): ditto.
- * lib/date.rb, lib/date/format.rb (Date._parse): now completes
- truncated year as default action. [experimental]
+ * ext/socket/getnameinfo.c: include stdio.h always.
- * lib/date.rb, lib/date/format.rb: added ::iso8601, ::rfc3339,
- ::xmlschema, ::rfc2822, ::httpdate, ::jisx0301, #xmlschema,
- #httpdate. [experimental]
+ * ext/win32ole/win32ole.c (ole_hresult2msg, folevariable_name,
+ 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>
- * common.mk: inverted rules order.
-
- * thread_win32.ci (w32_create_thread): bcc does not have
- _beginthreadex().
-
* lib/mkmf.rb (create_makefile): make OBJS depend on RUBY_EXTCONF_H
only if extconf.h is created.
- * bcc32/Makefile.sub: headers have moved.
-
* bcc32/{Makefile.sub,configure.bat,setup.mak: configure_args
support.
@@ -7366,63 +3555,21 @@ Sat Jul 21 12:06:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (init_mkmf): should remove mkmf.log too.
-Sat Jul 21 01:45:03 2007 Tadayoshi Funaba <tadf@dotrb.org>
+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 16:30:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (iseq_set_sequence): raise SyntaxError instead of rb_bug
- since this function can be called from VM::InstructionSequence.load.
-
- * compile.c (insn_set_sc_state, iseq_set_sequence_stackcaching): ditto.
-
-Fri Jul 20 16:11:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c, compile.h (DECL_ANCHOR, INIT_ANCHOR): split not to
- initialize aggregations with dynamic values. [ruby-talk:259306]
-
- * eval.c (rb_protect): not to initialize aggregations with dynamic
- values. [ruby-talk:259306]
-
- * gc.c (mark_current_machine_context): ditto.
-
- * thread.c (thgroup_list, call_trace_func): ditto.
-
- * vm.c (vm_init_redefined_flag): ditto.
-
Fri Jul 20 15:22:51 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]
-Fri Jul 20 10:39:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (stmt, mlhs_node, lhs, arg, var_ref): return dummy
- NODE_BEGIN after errors. [ruby-dev:31100], [ruby-dev:31118]
-
- * parse.y (remove_begin): keep empty NODE_BEGIN, instead of null.
- [ruby-dev:31252], [ruby-dev:31263]
-
-Fri Jul 20 09:50:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bootstraptest/runner.rb (get_result_string): check $?.coredump?
- first.
-
- * bootstraptest/runner.rb (cleanup_coredump, check_coredump): see
- stackdump file too.
-
-Thu Jul 19 20:39:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (value_expr_gen): warn for empty expression ().
- [ruby-dev:31252]
-
Thu Jul 19 19:24:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval_error.ci (get_backtrace): check the result more.
+ * 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>
@@ -7437,40 +3584,29 @@ Wed Jul 18 16:57:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
-Wed Jul 18 09:19:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_parser_append_print, rb_parser_while_loop): moved check
- for node to the head.
-
- * ruby.c (proc_options): do nothing for -p/-n options if tree is null.
- submitted by Yusuke ENDOH <mame AT tsg.ne.jp> at [ruby-dev:31243].
-
Wed Jul 18 08:47:09 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>
+
+ * 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>
* lib/base64.rb (Base64::b64encode): should not specify /o option
for regular expression. [ruby-dev:31221]
-Mon Jul 16 22:57:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sprintf.c (rb_str_format): make %u behave like %d for negative
- values, since decimal format does not work with preceding dots.
- [ruby-core:11575]
-
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 07:17:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insns.def (getspecial): lfp_svar_get() requires int for special
- global variables.
-
Mon Jul 16 05:45:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_f_sprintf): more checks for format argument.
@@ -7481,9 +3617,11 @@ 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 22:24:37 2007 pegacorn <subscriber.jp AT gmail.com>
+Sun Jul 15 23:59:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/dl/cfunc.c (rb_dlcfunc_call): adjust format. [ruby-dev:31222]
+ * bignum.c (rb_big_neg): SIGNED_VALUE isn't in 1.8.
+
+Sun Jul 15 22:24:49 2007 pegacorn <subscriber.jp AT gmail.com>
* ext/digest/digest.c (rb_digest_instance_update,
rb_digest_instance_finish, rb_digest_instance_reset,
@@ -7507,8 +3645,7 @@ Sun Jul 15 22:24:37 2007 pegacorn <subscriber.jp AT gmail.com>
* win32/win32.c: include mbstring.h for _mbspbrk(). [ruby-dev:31232]
- * include/ruby/win32.h (rb_w32_getcwd): prototype added.
- [ruby-dev:31232]
+ * win32.h (rb_w32_getcwd): prototype added. [ruby-dev:31232]
Sun Jul 15 21:07:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -7523,67 +3660,33 @@ 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 22:49:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (fix_pow): integer power calculation: 0**n => 0,
- 1**n => 1, -1**n => 1 (n: even) / -1 (n: odd).
-
- * test/ruby/test_fixnum.rb (TestFixnum::test_pow): update test
- suite. pow(-3, 2^64) gives NaN when pow(3, 2^64) gives Inf.
-
-Sat Jul 14 18:46:35 2007 Tanaka Akira <akr@fsij.org>
-
- * configure.in: add --with-valgrind.
-
- * gc.h (SET_MACHINE_STACK_END): new macro to replace
- rb_gc_set_stack_end. it find out accurate stack boundary by
- asm using gcc on x86.
-
- * thread.c (rb_gc_set_stack_end): don't define if asm-version
- SET_MACHINE_STACK_END is available.
-
- * gc.c (mark_current_machine_context): extracted from garbage_collect.
- it use SET_MACHINE_STACK_END to not scan out of stack area.
- it notify conservative GC information to valgrind if
- --with-valgrind.
-
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 11:08:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/json/ext/generator/generator.c (check_max_nesting): wrong
- format specifier. a patch from pegacorn <subscriber.jp AT gmail.com>.
- [ruby-dev:31217]
+Sat Jul 14 12:44:14 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Sat Jul 14 02:27:43 2007 Yukihiro Matsumoto <matz@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.
- * numeric.c (int_pow): overflow detection using FIT_SQRT_LONG().
- [ruby-dev:31215]
+Sat Jul 14 12:16:17 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Sat Jul 14 02:05:53 2007 Yukihiro Matsumoto <matz@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.
- * insns.def (opt_div): LONG2FIX() may not work for corner cases,
- use LONG2NUM() instead. [ruby-dev:31210]
+Sat Jul 14 02:51:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Jul 14 00:34:01 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * numeric.c (fix_pow): 0**2 should not raise floating point
+ exception. [ruby-dev:31216]
- * numeric.c (int_round): should not return false, but self.
- [ruby-dev:31212]
+Sat Jul 14 02:25:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Jul 13 18:31:27 2007 Koichi Sasada <ko1@atdot.net>
+ * numeric.c (int_pow): wrong overflow detection. [ruby-dev:31213]
- * include/ruby/intern.h: remove unused function declarations.
-
- * include/ruby/ruby.h: ditto.
-
-Fri Jul 13 17:32:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * vm.c (vm_free): clear free'ed living_threads field.
- [ruby-dev:31163]
-
- * insns.def (opt_succ): use cast to shut a warning up.
+ * numeric.c (int_pow): wrong overflow detection. [ruby-dev:31215]
Fri Jul 13 16:10:00 2007 Tanaka Akira <akr@fsij.org>
@@ -7596,319 +3699,30 @@ Fri Jul 13 15:02:15 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 11:33:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * range.c (range_max, range_min): return nil for empty set as well as
- 1.8 and Enumerable. [ruby-dev:31198]
-
-Fri Jul 13 11:28:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (bvar): semicolon was lost for ripper description.
- [ruby-dev:31140]
-
-Fri Jul 13 11:25:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (program, stmt, primary): reduced duplicated code.
-
- * parse.y (dsym): convert also literals containing NUL to
- symbol.
-
- * parse.y (debug_lines): use rb_hash_lookup() to get rid of
- call of Hash#default.
-
- * parse.y (ripper_warningS): unused in ripper right now.
-
-Fri Jul 13 10:33:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_flatten_bang): check argument if valid
- integer. [ruby-dev:31197]
-
Fri Jul 13 10:10:46 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 21:38:02 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * insns.def (opt_succ): use LONG_MAX as maximum Fixnum VALUE.
- [ruby-dev:31199]
-
-Thu Jul 12 18:42:18 2007 Tanaka Akira <akr@fsij.org>
-
- * range.c (range_max): use FIX2LONG instead of FIX2INT to avoid
- RangeError by ((-0x80000001)...(-0x80000001)).max on LP64.
-
- * insns.def (opt_plus): use FIX2LONG instead of FIX2INT to avoid
- RangeError by 0x3fffffffffffffff+1 on LP64.
-
- * insns.def (opt_succ): don't use 0x80000000 which assumes 32bit VALUE.
- use FIX2LONG instead of FIX2INT.
- [ruby-dev:31190]
-
Thu Jul 12 17:03:15 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* struct.c (rb_struct_init_copy): disallow changing the size.
[ruby-dev:31168]
-Thu Jul 12 12:58:21 2007 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c: remove "yarv" prefix.
-
- * array.c, numeric.c: ditto.
-
- * insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
-
- * yarvcore.c: removed.
-
- * yarvcore.h: renamed to core.h.
-
- * cont.c, debug.c, error.c, process.c, signal.c : ditto.
-
- * ext/probeprofiler/probeprofiler.c: ditto.
-
- * id.c, id.h: added.
-
- * inits.c: ditto.
-
- * compile.c: rename internal functions.
-
- * compile.h: fix debug flag.
-
- * eval.c, object.c, vm.c: remove ruby_top_self.
- use rb_vm_top_self() instead.
-
- * eval_intern.h, eval_load: ditto.
-
- * gc.c: rename yarv_machine_stack_mark() to
- rb_gc_mark_machine_stack().
+Wed Jul 11 23:38:14 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * insnhelper.h: remove unused macros.
-
- * iseq.c: add iseq_compile() to create iseq object
- from source string.
-
- * proc.c: rename a internal function.
-
- * template/insns.inc.tmpl: remove YARV prefix.
-
- * thread.c: use rb_iseq_eval() and rb_str_new2().
-
- * vm.c (rb_iseq_eval): added.
-
- * vm.c: move some functions from yarvcore.c.
-
- * vm_dump.c: fix to remove compiler warning.
-
-Thu Jul 12 12:24:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insns.def (opt_succ): fixed typo. [ruby-dev:31189]
-
-Thu Jul 12 10:30:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (thread_start_func_2): moved prototye from thread_*.ci.
-
- * thread_pthread.ci (thread_start_func_2): not use a directive
- inside a macro argument. [ruby-talk:258763]
-
- * thread.c (thread_join): pthread_t may not be pointer.
-
- * thread_pthread.ci (ubf_select_each): ditto.
-
-Thu Jul 12 05:32:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * include/ruby/ruby.h (FIX2ULONG): drop sign bit for LLP64 platform.
-
-Tue Jul 10 19:34:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * hash.c (rb_hash_lookup): added. this function is similar to
- rb_hash_aref(), but doesn't call Hash#default when no entry
- exists.
-
- * include/ruby/intern.h: ditto.
-
- * insnhelper.ci (lfp_svar_get): use rb_hash_lookup().
-
-Tue Jul 10 19:16:28 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, insnhelper.ci, vm.c: change cref index (-1 -> 2).
-
-Tue Jul 10 18:49:56 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (exec_under): add proper casts.
-
-Tue Jul 10 16:58:16 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, insnhelper.ci: fix svar interface.
-
- * compile.c (iseq_compile_each), yarvcore.h: fix to use new
- svar interface for flip flop.
-
- * eval.c: ditto.
-
- * insns.def: ditto.
-
- * include/ruby/intern.h: remove "rb_svar()" declaration.
-
-Tue Jul 10 16:52:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (rb_iseq_compile): formatted if/else to switch statement.
-
-Tue Jul 10 15:57:53 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bootstraptest/test_flip.rb: new test for flip-flop operator.
+ * 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>
* bcc32/{Makefile.sub,setup.mak}: remove surplus slash from srcdir.
-Mon Jul 9 02:17:36 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * cont.c (cont_restore_1): workaround for x64-mswin64's SEH.
-
-Sun Jul 8 02:08:53 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/json.rb, lib/json/, ext/json/: import JSON 1.1.1
-
-Sat Jul 7 21:59:29 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/pp.rb (PP::PPMethods#pp_hash): sort condition changed:
- all keys have a same class which is kind of Comparable.
-
-Sat Jul 7 17:12:37 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: use rb_bug() instead of rb_compile_error().
-
-Sat Jul 7 16:12:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y: fix node construction (around f_margs).
- [ruby-dev:31143]
-
- * bootstraptest/test_block.rb: add a test for above.
-
- * insnhelper.ci: fix indent.
-
-Sat Jul 7 15:36:50 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/pp.rb (PP::PPMethods#pp_hash): sort if
- all keys are strings, symbols or integers.
-
-Sat Jul 7 15:30:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_yield_setup_args), vm.c, insns.def:
- fix to pass nil as block parameter to yielded block.
- [ruby-dev:31147]
-
- * bootstraptest/test_block.rb: add a test for above.
-
-Fri Jul 6 19:55:10 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/irb.rb: typo. Thanks, Giles Bowkett.
-
- * lib/irb/completion.rb: support Ruby1.9 changing return value
- String to Symbol for Object#methods, etc. [ruby-dev:31148].
-
-Fri Jul 6 18:20:50 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/runner.rb: fix load path.
-
- * common.mk: fix "test" rule to run with "btest".
-
- * rubytest.rb, sample/test.rb: fix to show tests progress.
-
-Fri Jul 6 15:37:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_iterator.rb: fix test to 1.9 spec.
-
-Fri Jul 6 15:21:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jul 6 15:22:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_interrupt): suppress a gcc's officious warning.
-Fri Jul 6 14:57:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (keyword_to_name): constified.
-
- * ext/ripper/eventids2.c (token_to_eventid): ditto.
-
-Fri Jul 6 14:50:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bootstraptest/runner.rb: added --quiet option.
-
-Fri Jul 6 14:35:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (f_marg): wrap f_norm_arg assignment node with NODE_LIST.
- [ruby-dev:31141]
-
-Fri Jul 6 12:15:01 2007 Tanaka Akira <akr@fsij.org>
-
- * test/ruby/sentgen.rb: new file.
-
- * test/ruby/test_assignment.rb: tests implemented using assignment
- generator and emulator.
-
-Fri Jul 6 03:06:58 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def: remove unused code.
-
- * compile.c (compile_massign): fix to invoke to_splat on
- splat rhs (example: *a = *nil). [ruby-dev:31136]
-
- * bootstraptest/test_massign.rb: add tests for above.
-
- * compile.c (iseq_compile_each): disable excess optimization.
- [ruby-dev:31126]
-
-Fri Jul 6 02:08:25 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def: fix to invoke nil.to_splat on NODE_ARGSCAT.
- [ruby-dev:31138].
-
- * bootstraptest/test_literal.rb: add tests for above.
-
-Thu Jul 5 19:45:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h: rename rb_control_frame_t#magic to flag.
-
- * vm.h: add VM_FRAME_TYPE() and VM_FRAME_FLAG().
-
- * cont.c, insnhelper.ci, insns.def, vm.c, vm_dump.c,
- vm_evalbody.ci, yarvcore.c: apply above changes.
-
-Thu Jul 5 19:16:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_basicinstructions.rb: remove an assertion using
- unsupported hash literal (such as {1, 2}).
-
- * test/ruby/test_hash.rb: ditto.
-
-Thu Jul 5 19:12:22 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ruby.c: Qfalse is VALUE, not pointer.
-
-Thu Jul 5 18:42:01 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): add break catch point.
-
- * insns.def (throw): support correct "break" and "return".
- this commit achieve that "make test" passes all tests.
-
- * vm.c: ditto.
-
-Thu Jul 5 18:44:12 2007 Tanaka Akira <akr@fsij.org>
-
- * parse.y (mlhs_basic): use mlhs_post after tSTAR.
- [ruby-dev:31109]
-
-Thu Jul 5 18:27:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
- eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
- yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
- ruby_nerrs): purge global variables.
-
- * ruby.c (proc_options): moved do_print and do_loop options
- handling from ruby_process_options().
-
-Thu Jul 5 16:37:34 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jul 5 16:44:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* numeric.c (int_pow): fix previous nubu's commit.
@@ -7918,684 +3732,41 @@ Thu Jul 5 15:56:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* numeric.c (int_pow): even number multiplication never be negative.
-Thu Jul 5 10:42:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * include/ruby/{node,ruby}.h, ruby.c: added enum constants for gdb
- support. [ruby-dev:31066]
-
- * .gdbinit: some improvements.
-
-Thu Jul 5 10:13:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (global_symbols.last_id): reduce unused ID numbers.
-
- * include/ruby/st.h, st.c (st_init_table, st_init_table_with_size):
- constified.
-
-Wed Jul 4 23:36:27 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/webrick/httpauth/authenticator.rb
- (WEBrick::HTTPAuth::Authenticator#check_scheme): auth-scheme must be
- treated as a case-insensitive token according to RFC 2617 section 1.2.
-
-Wed Jul 4 18:30:04 2007 Tanaka Akira <akr@fsij.org>
-
- * parse.y (mlhs_inner): new rule. [ruby-dev:31132]
-
-Wed Jul 4 05:11:57 2007 Koichi Sasada <ko1@atdot.net>
-
- * iseq.c (set_relation): added.
-
-Wed Jul 4 04:58:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (caller_setup_args): fix to show correct class
- on an error message (ex: m(&1)). [ruby-dev:31101]
-
-Wed Jul 4 04:30:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (compile_array, iseq_compile_each): fix about array
- generation in void context. [ruby-dev:31102]
-
- * bootstraptest/test_literal.rb: add a test for above.
-
-Wed Jul 4 04:07:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (compile_array): ignore NODE_ZARRAY.
- [ruby-dev:31110]
-
- * bootstraptest/test_method.rb: add a test for above.
-
-Wed Jul 4 04:04:02 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.h: fix debug print level.
-
-Wed Jul 4 03:52:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): support v[&b]= type method call.
- [ruby-dev:31094]
-
- * bootstraptest/test_method.rb: add a test for above.
-
-Wed Jul 4 03:43:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (compile_massign): fix massign compilation
- (example: a, *v, (*x) = ...). [ruby-dev:31107]
-
- * bootstraptest/test_massign.rb: add tests for above.
-
-Tue Jul 3 23:12:29 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * include/ruby/onigiruma.h (ONIG_EXTERN): use RUBY_EXTERN if defined.
-
- * regenc.h: include ruby/defines.h.
-
- * regint.h: x64-mswin64 support.
-
-Tue Jul 3 13:47:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (cont_save_machine_stack): clear saved_thread.machine_stack*.
-
-Mon Jul 2 21:45:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: rename iseq_translate_direct_threaded_code()
- to iseq_translate_threaded_code().
-
- * eval_intern.h, yarvcore.h: mv EXEC_EVENT_HOOK() and
- exec_event_hooks() to yarvcore.h.
-
- * insnhelper.ci, vm.c: mv yarv_finish_insn_seq to vm.c.
-
- * insns.def (opt_call_c_function): fix to use RESTORE_REGS().
-
- * iseq.c (rb_iseq_build_for_ruby2cext): fix to allocate iseq.
-
-Mon Jul 2 11:59:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insns.def (defineclass): suppress a warning.
-
- * insns.def (opt_call_c_function): should raise the thrown exception
- instead of returning it.
-
-Mon Jul 2 08:53:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_intern.h, yarvcore.h: move declaration of sysstack_error
- to yarvcore.h.
-
- * iseq.c: fix symbol name (:toplevel -> :top).
-
- * lib/vm/instruction.rb, template/vm.inc.tmpl: replacable
- current file name.
+Mon Jul 2 14:34:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Jul 2 05:29:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, iseq.c: fix iseq some of load/store process.
-
-Mon Jul 2 03:09:36 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, compile.c, insnhelper.ci, iseq.c, vm.c:
- rename structure names and field names.
-
- * insnhelper.h, insns.def: add GET_CONST_INLINE_CACHE().
-
- * iseq.c: add rb_iseq_build_for_ruby2cext().
-
- * yarvcore.h, vm.h: move declaration of rb_insn_func_t
- to yarvcore.h.
-
-Sun Jul 1 03:25:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.h, vm.h: some refactoring.
- remove useless comments, etc.
-
-Sun Jul 1 03:02:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h: some refactoring on rb_iseq_t.
- rename some variable names, add comments, etc.
-
- * compile.c, iseq.c, proc.c, vm.c: ditto.
-
-Sun Jul 1 02:57:57 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.h: rename insn_func_type to rb_insn_func_type.
+ * sprintf.c (rb_f_sprintf): sign bit extension should not be done
+ if FPLUS flag is specified. [ruby-list:39224]
- * vm_evalbody.ci: ditto.
+Sat Jun 30 16:05:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * insns.def: add opt_call_native_compiled instruction
- instead of opt_call_native_compiled.
+ * 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>
- * parse.y (parser_yylex): return non-valid token for an invalid
+ * parse.y (yylex): return non-valid token for an invalid
instance/class variable name. a patch from Yusuke ENDOH
<mame AT tsg.ne.jp>. [ruby-dev:31095]
-Fri Jun 29 23:38:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (stmts): fix for ripper.
-
-Fri Jun 29 21:55:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y: fix to show line number of blank block.
- [ruby-dev:31093]
-
-Fri Jun 29 20:51:04 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/cgi/session.rb (create_new_id): don't cut off md5.hexdigest to
- follow Ruby 1.8.
-
-Fri Jun 29 17:10:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * debug.h: constified.
-
- * debug.c (ruby_set_debug_option): separated from main.c.
-
- * gc.c (ruby_gc_stress), signal.c (ruby_enable_coredump): prefixed.
-
-Fri Jun 29 16:39:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c (proc_new): fix to return a proc object
- which block is contained ([ruby-dev:31056]).
-
-Fri Jun 29 15:43:59 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (fix_pow): get rid of division by zero. reported by
- Yusuke ENDOH <mame AT tsg.ne.jp> [ruby-dev:31040]
-
- * numeric.c (int_round): do nothing when rounding by zeroth digit.
- check underflow. [ruby-dev:31043]
-
-Fri Jun 29 15:32:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * configure.in: add fastcall attribute check.
-
-Fri Jun 29 14:51:24 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (assoc_list): remove expanded hash literal (no splat).
-
- * lib/webrick/httpstatus.rb (WEBrick::HTTPStatus::EOFError): adapt
- to new syntax.
-
-Fri Jun 29 14:48:18 2007 Koichi Sasada <ko1@atdot.net>
-
- * tool/insns2vm.rb, lib/vm/instruction.rb: move process body
- to lib/vm/instruction.rb.
-
- * common.mk: fix aotc rule.
- experimental. bin/ruby2cext is not added yet.
-
Fri Jun 29 11:23:09 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]
-Thu Jun 28 23:29:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (assoc_list): odd number check only for NODE_ARRAY.
- [ruby-dev:31082]
-
-Thu Jun 28 22:24:33 2007 Koichi Sasada <ko1@atdot.net>
-
- * win32/Makefile.sub: define FUNC_FASTCALL macro.
-
- * vm.h: fix to use FUNC_FASTCALL macro.
- TODO: add FUNC_FASTCALL macro by configure.
-
-Thu Jun 28 19:38:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: fix to remove -Wall warnings on gcc.
-
- * compile.c (make_name_with_str): removed. use rb_sprintf() instead.
-
-Thu Jun 28 18:53:01 2007 Tanaka Akira <akr@fsij.org>
-
- * bignum.c (rb_big_hash): fix hash area.
-
-Thu Jun 28 15:00:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_getline): local variable to be
- initialized. [ruby-dev:31077]
-
-Thu Jun 28 11:30:39 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * gc.c (rb_obj_id): use SIGNED_VALUE instead of long.
-
-Thu Jun 28 05:01:56 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk (run.gdb): fix to load $(srcdir)/.gdbinit
-
- * vm.c (rb_vm_set_finish_env): add a cast.
-
- * vm.h: support __fastcall for MSVC.
-
-Thu Jun 28 02:12:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/runner.rb: fix to untouch $:.
-
-Thu Jun 28 02:03:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (setup_args): change parameter type.
-
-Thu Jun 28 02:03:39 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * parse.y (rb_intern2): unconstify cast.
-
-Thu Jun 28 01:44:31 2007 Tanaka Akira <akr@fsij.org>
-
- * parse.y (rb_intern2): don't allocate a string object at first.
- [ruby-dev:31064]
-
-Thu Jun 28 01:24:02 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/runner.rb: fix to show file name.
-
- * bootstraptest/test_*.rb: add bootstrap tests.
-
-Thu Jun 28 01:22:15 2007 Koichi Sasada <ko1@atdot.net>
-
- * include/ruby/node.h, parse.y, gc.c, iseq.c: remove NODE_CREF.
-
-Thu Jun 28 01:19:43 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix popped backref and others.
- ([ruby-dev:31068]).
-
- * compile.c (iseq_compile_each): remove needless statements.
-
-Wed Jun 27 23:51:33 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c: remove unused functions.
-
-Wed Jun 27 20:46:05 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * include/ruby/win32.h, win32/Makefile.sub, win32/configure.bat,
- win32/mkexports.rb, win32/setup.mak, win32/win32.c: import
- x64-mswin64 port.
-
-Wed Jun 27 20:31:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_translate_direct_threaded_code): fix prototype
- function name.
-
- * vm.h: add correct cast.
-
-Wed Jun 27 17:08:42 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm_evalbody.ci: support OPT_CALL_THREADED_CODE.
-
- * insns.def, vm.c, vm.h: ditto.
-
- * vm.h: add VM_CFP_CNT() and VM_SP_CNT().
-
-Wed Jun 27 04:23:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix type error.
-
-Wed Jun 27 03:26:15 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (compile_massign), insns.def (expandarray): support
- postarg with massign (a, *b, c = ...).
-
- * bootstraptest/test_massign.rb: add tests for above.
-
- * compile.h: fix debug macro names.
-
-Wed Jun 27 00:18:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_clear): need to check STR_EMBED_P() before
- free()ing memory. a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
- [ruby-dev:31062]
-
-Tue Jun 26 16:39:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (proc_getgroups): use GIDT2NUM for rb_gid_t.
-
-Tue Jun 26 16:28:24 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (rb_thread_wait_fd_rw): terminate fdset.
-
-Tue Jun 26 16:26:58 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * regint.h: IL32LLP64 support.
-
-Tue Jun 26 16:22:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * iseq.c (ruby_node_name): update node names.
-
-Tue Jun 26 15:21:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * include/ruby/ruby.h: IL32LLP64 support.
-
- * bignum.c (bigfixize, rb_cstr_to_inum): ditto.
-
- * insns.def (opt_plus, opt_minus, opt_mult): ditto.
-
-Tue Jun 26 15:04:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_fiber_s_new): revert initializing VM stack.
-
- * yarvcore.c (th_init2): ditto.
-
- * vm.c, vm.h: fix to stop using Qundef on VM stack. According to
- this change, VM stack should not include Qundef value.
-
- * insns.def (putundef): removed.
-
- * compile.c (iseq_compile_each): ditto.
-
- * eval.c (eval): fix spacing.
-
-Tue Jun 26 04:03:50 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (vm_yield_with_cfunc), proc.c: fix Method#to_proc
- to return lambda Proc ([ruby-dev:31021], [ruby-dev:31037]).
-
-Tue Jun 26 03:46:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_fiber_s_new): fix to clear rb_thread_t#tag.
- [ruby-dev:30995]
-
-Tue Jun 26 03:38:31 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_fiber_s_new), yarvcore.c (th_init2): fix to clear
- VM stack ([ruby-dev:31046]).
-
-Tue Jun 26 03:15:27 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: rename setup_arg() to setup_args().
- fix to use setup_args() at processing NODE_YIELD.
-
-Tue Jun 26 02:50:24 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (setup_arg): support kind of "m(*ary, x)" method call.
- ([ruby-dev:31048]).
-
-Tue Jun 26 00:28:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci, vm.c: complete block parameter support.
- post arguments, optional arguments, block argument.
-
- * compile.c, parse.y: fix {|a|} parameter.
-
- * insnshelper.ci, insns.def: revert caller_setup_args() option
- (need_block_check) parameter.
-
-Mon Jun 25 20:18:44 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * gc.c (RVALUE): in RVALUE and RBasic, flags must be the same type.
-
-Mon Jun 25 18:02:55 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/pty/extconf.rb: skip wince and win64.
-
-Mon Jun 25 17:59:32 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * include/ruby/node.h (NODE_LMASK, nd_line): shouldn't use int and/or
- long carelessly.
-
-Mon Jun 25 11:36:35 2007 Koichi Sasada <ko1@atdot.net>
-
- * gc.h: add RUBY_ prefix to debug macros.
-
- * cont.c, proc.c, yarvcore.c,
-
- * gc.c: define ruby_gc_debug_indent variable to debug mark/free.
-
- * vm.c, insnhelper.ci: rename some functions to vm_* or rb_vm_*.
- move some functions, definitions, declarations to suitable files.
-
- * eval.c, yarvcore.h, eval_error.ci, insnhelper.ci: ditto.
-
-Mon Jun 25 09:45:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_error.ci, eval_jump.ci, eval_method.ci, eval_safe.ci: c-mode.
-
-Mon Jun 25 05:27:54 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c: remove ruby_current_node and change eval() prototype.
- fix to use rb_sourcefile/line() instead of ruby_sourcefile/line.
-
- * error.c, eval_error.ci, eval_load.c, eval_safe.ci, gc.c,
- include/ruby/intern.h, parse.y, process.c, ruby.c: ditto.
-
- * vm.c: fix spaces.
-
-Mon Jun 25 04:20:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_*.h: rename to eval_*.ci.
+Tue Jun 26 16:35:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * common.mk: ditto.
+ * process.c (ruby_setreuid, ruby_setregid): rename to get rid of name
+ clash.
- * eval_error.ci: remove ruby_set_current_source().
+ * process.c (proc_exec_v, rb_proc_exec): preserve errno.
- * error.c, eval.c, ruby.c: ditto.
+Sat Jun 23 00:37:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval_safe.c, proc.c: remove unused macros.
+ * 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]
-Mon Jun 25 03:37:20 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.ci (caller_setup_args): add need_block_check option.
-
- * insns.def: ditto.
-
- * yarvcore.h: add GetCoreDataFromValue().
-
-Mon Jun 25 02:14:30 2007 Koichi Sasada <ko1@atdot.net>
-
- * call_cfunc.ci: removed.
-
- * insnhelper.ci: added. this function includes all functions that
- vm insns need.
-
- * common.mk: ditto.
-
- * insnhelper.h, vm.h, vm.c: move some declaration.
-
- * gc.h: remove GC_CHECK() macro because GC.stress is more useful.
-
- * compile.c, iseq.c, vm_dump: ditto.
-
- * gc.h, thread.c: move a prototype declaration.
-
- * debug.c, debug.h: rename some functions.
-
- * compile.h: ditto.
-
-Mon Jun 25 00:45:02 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (invokesuper): fix error message.
-
-Mon Jun 25 00:14:13 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c: some refactoring.
- * rename th_* to vm_*.
- * remove unused variables functions.
- * add prototypes.
-
- * blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
- eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
- proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
- vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
-
-Sun Jun 24 22:32:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h (rb_add_method): fix to check 0.
-
-Sun Jun 24 22:00:17 2007 Koichi Sasada <ko1@atdot.net>
-
- * insn_send.ci: removed.
-
- * common.mk: ditto.
-
- * vm.c (vm_call_bmethod), isnsn.def: added. fix to use this
- function instead of using goto.
-
- * vm.c (vm_call_bmethod): renamed from th_invoke_bmethod().
-
- * vm.c (vm_method_missing): renamed from eval_method_missing().
-
- * vm_evalbody.ci: remove tmp_* variables.
-
- * insnhelper.h: add some macros.
-
- * insns.def: forbid zsuper from method defined by define_method().
-
- * test/ruby/test_super.rb: ditto.
-
-Sun Jun 24 20:01:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm_macro.def: removed.
-
- * insn_send.ci: added. this file includes send instruction body.
-
- * common.mk: ditto.
-
- * insns.def: ditto.
-
- * tool/insns2vm.rb: ditto.
-
- * vm.c: ditto.
-
-Sun Jun 24 19:30:37 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.h (RESTORE_REGS): add do/while(0) around macro.
-
- * vm.c, vm_macro.def: remove macro_eval_invoke_func() and
- add vm_setup_method(). use it instead.
-
-Sun Jun 24 19:02:33 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, vm_macro.def : remove macro_eval_invoke_cfunc() and
- add vm_call_cfunc().
-
-Sun Jun 24 17:54:13 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, vm.c: add/fix stack overflow check.
-
-Sun Jun 24 17:28:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.h: change CHECK_STACK_OVERFLOW() to throw exception.
-
- * vm.c (caller_setup_arg), vm_macro.def: remove
- macro_eval_setup_send_arguments and add caller_setup_arg().
-
- * insns.def: ditto.
-
- * bootstraptest/test_method.rb: add splat arg tests.
-
-Sun Jun 24 16:35:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * proc.c (proc_to_s): used a variable before initialized.
-
-Sun Jun 24 16:05:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (callee_setup_arg): added. support correct post arg.
-
- * vm_macro.def (macro_eval_invoke_func): fix to use
- callee_setup_arg.
-
- * compile.c (set_arguments): adjust for above changes.
-
- * compile.c (iseq_compile_each): ditto.
-
- * iseq.c (ruby_iseq_disasm): ditto.
-
- * yarvcore.h: add rb_iseq_t#post_arg_start and arg_size.
-
- * bootstraptest/test_method.rb: add post arg tests.
-
-Sun Jun 24 16:10:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * proc.c (proc_to_s): suppress warning, and reduced duplicated code.
-
-Sun Jun 24 15:33:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * bootstraptest/runner.rb: set default directory to
- '/tmp/bootstraptest.tmpwd' and add --dir option.
- fix to output driver and target information.
-
- * common.mk: fix to run btest on BASERUBY and
- add OPTS to pass option ("make btest OPTS=...").
-
-Sun Jun 24 03:05:00 2007 Tanaka Akira <akr@fsij.org>
-
- * enum.c (enum_minmax): fix SEGV by [].minmax.
-
-Sat Jun 23 17:18:19 2007 Tanaka Akira <akr@fsij.org>
-
- * re.c (match_inspect): MatchData#inspect implemented.
-
-Sat Jun 23 15:00:16 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_minmax): new method to get the minimum and maximum
- values from the enumerable at once.
-
- * enum.c (enum_minmax_by): ditto.
-
-Sat Jun 23 01:25:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_assoc): new method.
-
- * hash.c (rb_hash_rassoc): ditto.
-
- * hash.c (rb_hash_flatten): ditto.
-
-Fri Jun 22 23:55:59 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_upto): add optional argument to specify
- exclusiveness.
-
- * range.c (range_step): use String#upto with optional argument.
-
- * range.c (range_each): ditto.
-
-Fri Jun 22 19:55:51 2007 Tanaka Akira <akr@fsij.org>
-
- * proc.c (proc_to_s): revert the change from %p to %lx at YARV
- merge time.
-
-Fri Jun 22 19:33:49 2007 Tanaka Akira <akr@fsij.org>
-
- * proc.c (proc_to_s): show is_lambda.
-
-Thu Jun 21 20:36:12 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_sort): remove hash specific implementation.
-
-Thu Jun 21 20:28:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_select): returns new hash, not assoc array.
- [ruby-core:11504]
-
- * hash.c (env_select): ditto.
-
-Thu Jun 21 23:08:19 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (rb_intern2): ID_JUNK test based on len, not by NUL.
-
-Thu Jun 21 19:42:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * yarvcore.c (rb_thread_mark): mark also thrown_errinfo.
-
-Thu Jun 21 17:13:44 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_intern2): name may not be NUL-terminated.
-
-Wed Jun 20 08:27:57 2007 Tanaka Akira <akr@fsij.org>
-
- * eval_error.h (error_print): show full stacktrace on
- non-SystemStackError.
-
-Wed Jun 20 04:45:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_intern2): use rb_intern2 to intern without trailing
- equal sign.
-
- * parse.y (rb_intern2, ripper_id2sym): fixed indent.
-
-Tue Jun 19 10:55:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_load.c (load_ext, rb_require_safe): pass VALUE instead of
- pointer. [ruby-Bugs-11659]
+ * hash.c: ditto.
Mon Jun 18 08:47:54 2007 Technorama Ltd. <oss-ruby@technorama.net>
@@ -8609,46 +3780,11 @@ Mon Jun 18 08:47:54 2007 Technorama Ltd. <oss-ruby@technorama.net>
* ext/openssl/ossl_rand.c
New method Random.status?
- * test/openssl/test_ec.rb
- New tests.
-
-Mon Jun 18 17:04:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_load.c (rb_require_safe, ruby_init_ext): load with ruby level
- cfp. [ruby-core:10779]
-
- * eval_intern.h, vm.c (rb_vm_call_cfunc): new function to call a
- function with ruby level cfp.
-
-Mon Jun 18 16:57:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (yycompile): disable trace while creating ruby_debug_lines.
- [ruby-talk:253586]
-
- * thread.c (ruby_suppress_tracing): new function to call a function
- with suppressing trace.
-
- * lib/debug.rb, lib/tracer.rb: for YARV.
-
Mon Jun 18 13:54:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (ruby_cleanup): return EXIT_FAILURE if any exceptions occurred
+ * eval.c (ruby_cleanup): return EXIT_FAILURE if any exceptions occured
in at_exit blocks. [ruby-core:11263]
-Mon Jun 18 02:49:16 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (env_mark): fix to mark block.proc.
-
- * vm.c (th_make_proc_from_block): set created proc to block->proc.
-
-Mon Jun 18 02:48:12 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm_dump.c (vm_stack_dump_raw): hide VM stack trace.
-
-Mon Jun 18 02:43:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * signal.c (sigsegv): clear gc_stress flag on SEGV.
-
Mon Jun 18 01:14:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* variable.c (rb_path2class): get rid of dangling pointer caused by
@@ -8660,170 +3796,31 @@ Mon Jun 18 01:14:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
rb_free_generic_ivar, rb_copy_generic_ivar,
rb_obj_instance_variables): suppress warnings.
-Sun Jun 17 11:11:07 2007 Tanaka Akira <akr@fsij.org>
-
- * eval.c (rb_method_missing): avoid a warning "too many arguments
- for format string" on "./ruby -ve 'def m() super end; m'".
-
-Sat Jun 16 22:24:17 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c (garbage_collect): re-introduce ruby_current_node marking code.
- [ruby-dev:31005]
-
-Sat Jun 16 21:37:43 2007 Tanaka Akira <akr@fsij.org>
-
- * gc.c (gc_sweep): re-introduce heap extension strategy change.
- [ruby-dev:31005]
-
-Fri Jun 15 22:59:37 2007 Tanaka Akira <akr@fsij.org>
-
- * .gdbinit: new file to ease debugging using gdb.
-
-Fri Jun 15 22:33:55 2007 Tanaka Akira <akr@fsij.org>
-
- * signal.c (default_handler): func argument removed.
- (trap_handler): support SYSTEM_DEFAULT. call default_handler
- internally.
- (sig_trap): don't call default_handler.
- [ruby-dev:30999]
-
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 20:50:02 2007 Tanaka Akira <akr@fsij.org>
-
- * keywords: enclose C code in declaration section by %{ and %} to
- avoid extra semicolon after #ifdef RIPPER.
- pointed by eban.
-
-Fri Jun 15 18:56:52 2007 Tanaka Akira <akr@fsij.org>
-
- * signal.c (trap_handler): trap("SIGSEGV", "DEFAULT") may cause wrong
- trap error because SIG_DFL may be zero.
-
-Fri Jun 15 15:55:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (setconstant, toregexp): fix to mark object correctly.
-
-Fri Jun 15 13:24:18 2007 Koichi Sasada <ko1@atdot.net>
-
- * hash.c: exchange semantics of Hash#each and Hash#each_pair.
- pointed out by [ruby-dev:30997].
-
- * test/ruby/test_iterator.rb: ditto.
-
- * test/ruby/test_yield.rb: ditto.
-
-Fri Jun 15 12:38:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_iterator.rb: remove debug code (GC.stress=true).
-
-Fri Jun 15 12:25:33 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (th_yield_setup_args): |v| should work as |v,|.
- ex) def m;yield 1, 2; end; m{|v| p v} #=> 1
-
- * parse.y: apply above change for "for" statement.
-
- * test/ruby/test_assignment.rb: ditto
+Fri Jun 15 17:01:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
- * test/ruby/test_basicinstructions.rb: ditto.
-
- * test/ruby/test_iterator.rb: ditto.
-
- * test/ruby/test_yield.rb: ditto.
-
- * compile.c (iseq_compile_each): fix debug.
-
-Fri Jun 15 12:22:10 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (ruby_finalize_1): rb_thread_t#errinfo should be clear with
- Qnil.
-
-Fri Jun 15 12:20:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_cont_call): forbid cross fiber continuation call.
-
- * test/ruby/test_fiber.rb: ditto.
-
-Fri Jun 15 12:14:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * sample/test.rb: fix to show line information whether test succeeds.
-
-Thu Jun 14 17:16:05 2007 Tanaka Akira <akr@fsij.org>
-
- * eval_load.c (Init_load): delay allocating an array for rb_load_path
- to avoid GC problem in very early stage.
- (RUBY_GC_STRESS causes GC in such stage.)
-
- * variable.c (rb_gc_mark_global_tbl): rb_global_tbl may be 0 in
- very early stage.
-
- * thread.c (thread_cleanup_func) [IA64]: clear register stack position.
- (thread_start_func_2) [IA64]: record the beginning of register
- stack using extra argument.
- (rb_gc_save_machine_context) [IA64]: record the end of register
- stack.
-
- * gc.c [IA64] (SET_STACK_END): record the end of register stack.
- (garbage_collect) [IA64]: use recorded register stack area for
- GC marking.
- (yarv_machine_stack_mark) [IA64]: GC mark from the register stack
- area.
-
- * yarvcore.c [IA64] (rb_gc_register_stack_start): defined.
- (Init_VM): store th->self on stack to fix GC problem.
- (Init_yarv) [IA64]: initialize the beginning of register stack.
-
- * yarvcore.h (struct rb_thread_struct) [IA64]: new members for
- register stack area.
-
- * thread_pthread.ci (thread_start_func_1) [IA64]: call
- thread_start_func_2 with the end of register stack.
-
- * cont.c (struct rb_context_struct) [IA64]: new members for register
- stack area.
- (cont_mark) [IA64]: GC mark from register stack area.
- (cont_free) [IA64]: free saved register stack.
- (cont_save_machine_stack) [IA64]: record the position and contents
- of the register stack.
- (cont_capture): store cont->self on stack to fix GC problem.
- (cont_restore_1) [IA64]: restore the register stack.
- [IA64] (register_stack_extend): new function.
- (cont_restore_0) [IA64]: call register_stack_extend instead of
- cont_restore_1.
-
- [ruby-dev:30982]
+ * 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>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser): handle more
extensions. [ruby-dev:30972]
-Thu Jun 14 14:40:42 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/securerandom.rb: document updated.
- suggested by NaHi. [ruby-dev:30966]
-
-Wed Jun 13 22:42:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (garbage_collect): update IA64 register stack code.
- [ruby-dev:30971]
-
Wed Jun 13 06:05:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (darwin): prohibit loading extension libraries to
miniruby.
-Tue Jun 12 21:50:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (call_args): no allow splat after assocs. takes
- consistency over compatibility.
+Wed Jun 13 05:47:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (call_args2): ditto
+ * 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>
@@ -8832,408 +3829,66 @@ Tue Jun 12 14:53:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (find_header): use header names in the message.
-Sun Jun 10 18:37:13 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/probeprofiler/probeprofiler.c: clean warnings.
-
-Sun Jun 10 18:32:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * missing/isinf.c, missing/dup2.c, missing/strtod.c, missing/x68.c,
- missing/alloca.c: use "ruby/config.h".
-
-Sun Jun 10 17:49:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (install_recursive): should check parent directories of
- the destination. [ruby-dev:30947]
-
-Sun Jun 10 16:59:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (do_block, brace_block): fix line numbers. [ruby-dev:30831]
-
-Sun Jun 10 16:57:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (install_recursive): add :glob option rather than
- using FNM_DOTMACH.
-
- * instruby.rb (ext-comm): make header directory first.
-
-Sun Jun 10 16:10:58 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/ruby/test_beginendblock.rb: typo.
-
-Sun Jun 10 16:07:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (install_recursive): skip .svn directories.
-
-Sun Jun 10 15:44:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/Makefile.sub (config.status): rubyhdrdir was missing.
-
-Sun Jun 10 15:26:36 2007 Tanaka Akira <akr@fsij.org>
-
- * Makefile.in: use --output-file for gperf to not leave lex.c.tmp.
-
-Sun Jun 10 15:11:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, win32/Makefile.sub (XCFLAGS): -I. is needed for *.inc.
-
- * ext/extmk.rb: prepend also topdir to mflags at last.
-
Sun Jun 10 13:47:36 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
get rid of invoking shell. [ruby-dev:30942]
-Sun Jun 10 12:56:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * include/ruby: moved public headers.
-
- * instruby.rb (install_recursive): skip backup files.
-
- * instruby.rb (ext-comm): install only current platform headers.
-
-Sun Jun 10 10:42:04 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/securerandom.rb: renamed from lib/secrand.rb.
- suggested by NaHi. [ruby-dev:30934]
-
-Sat Jun 9 06:40:05 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/secrand.rb: rename SecRand() to SecRand.random_number.
- suggested by NaHi. [ruby-dev:30934]
-
-Fri Jun 8 16:34:20 2007 Tanaka Akira <akr@fsij.org>
-
- * ext/zlib/zlib.c (gzfile_s_open): use FilePathValue to support
- to_path.
-
-Fri Jun 8 16:11:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_jump.h: th->errinfo should clear with nil.
-
-Fri Jun 8 14:53:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (call_args): allow splat argument after unpacked
- assocs like 1.8 does.
-
- * parse.y (call_args): ditto.
-
-Fri Jun 8 14:26:18 2007 Tanaka Akira <akr@fsij.org>
-
- * lib/secrand.rb: new file for secure random interface.
-
- * lib/cgi/session.rb: use secrand for generating cookies.
-
-Fri Jun 8 12:44:37 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * {win32,wince}/Makefile.sub: add lex.c rule.
-
-Fri Jun 8 11:54:18 2007 Tanaka Akira <akr@fsij.org>
-
- * lex.c.blt: moved from lex.c.
-
- * Makefile.in: use lex.c.blt if gperf is not available.
- [ruby-list:8212], [ruby-list:8214], [ruby-list:24667],
- [ruby-talk:120857], [ruby-dev:28102]
-
-Thu Jun 7 21:38:39 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (rb_thread_execute_interrupts): invoke ensure when
- main thread exits.
-
Thu Jun 7 19:02:48 2007 Tanaka Akira <akr@fsij.org>
* lib/pp.rb: call original "method" method instead of redefined one.
-Thu Jun 7 17:20:57 2007 Koichi Sasada <ko1@atdot.net>
-
- * iseq.c (prepare_iseq_build): freeze filename and name string.
-
- * variable.c: freeze class name string.
-
-Thu Jun 7 12:48:33 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (cont_restore_1): fix to check root fiber [ruby-dev:30911].
-
- * test/ruby/test_fiber.rb: add a test.
-
-Thu Jun 07 07:24:36 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/json/common.rb: Ponder offering parse! method.
-
- * lib/json/editor.rb: be a bit more robust while loading data.
-
- * ext/json/ext/{generator,parser}/extconf.rb:
- add a have_header directive for st.h
-
- * test/json: fix some tests.
-
-Thu Jun 7 03:29:18 2007 Koichi Sasada <ko1@atdot.net>
-
- * test_fiber.rb: add a test (Continuation and Fiber).
-
-Thu Jun 7 03:17:24 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (cont_new): add debug message.
-
- * cont.c (cont_restore_1): copy stack information from fiber.
-
- * cont.c (rb_fiber_s_new): fix to mark created fiber.
-
- * test/ruby/test_fiber.rb: add some tests around Thread and Fiber.
-
- * yarvcore.c (thread_free): fix to skip freeing stack if root fiber
- is available.
-
-Thu Jun 7 01:03:20 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_intern.h, eval.c (ruby_init): remove POP_TAG_INIT().
-
- * cont.c (rb_fiber_start): remove zero-clearing tag.
-
-Wed Jun 6 20:23:46 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (invokeblock): fix of splat argument.
- (splat same as normal method dispatch)
-
-Wed Jun 6 16:27:25 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * insns.def: fixed indentation.
-
-Wed Jun 6 10:58:23 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (rb_yield): fix to check Qundef.
-
-Wed Jun 6 10:57:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_continuation.rb: add a test for last commit.
-
-Wed Jun 6 10:55:42 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_cont_call): forbid calling dead fiber with
- Continuation#call.
-
-Wed Jun 6 10:50:01 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix around yield arguments
- (with NODE_ARGSCAT).
-
-Wed Jun 6 02:50:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (rb_fiber_start): clear th->tag and check error to fix
- [ruby-dev:30888] and [ruby-dev:30889].
-
- * eval_intern.h: fix rb_fiber_start() prototype.
-
- * test/ruby/test_fiber.rb: add tests for above.
-
-Wed Jun 6 02:40:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * insnhelper.h, insns.def (DEC_SP): shouldn't use unary minus operator
- in pointer operation. some compilers (such as VC++8 x64) cannot deal
- it with expected way.
-
-Wed Jun 6 02:19:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y (new_yield), compile.c (iseq_compile_each): fix
- passing parameter.
-
- * eval.c, eval_jump.h: simplify rb_yield*.
-
- * proc.c (proc_mark): fix to mark proc->block.proc.
-
- * proc.c (Init_Proc): add Proc#lambda?
-
- * test/ruby/test_lambda.rb: add some tests.
-
- * vm.c (invoke_block): fix to check lambda block or not.
-
- * vm.c (th_yield_setup_args): fix to check arguments size
- when lambda block.
-
-Tue Jun 5 16:30:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_f_p): returns arguments to intervene. [ruby-dev:29736]
-
-Tue Jun 5 14:07:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (invokeblock): check block is created by lambda
- or Proc.new.
-
- * vm.c (block_proc_is_lambda): added.
-
-Tue Jun 5 14:47:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/pp.rb (PP::PPMethods::seplist): revert last change to work
- around wrapper bug. [ruby-dev:30840]
-
-Tue Jun 5 14:11:15 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/nkf.c (kanji_convert): Fix guess fallback.
-
-Tue Jun 5 13:32:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
- pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
- thread_pthread.ci, thread_win32.ci: fixed indentation.
-
- * call_cfunc.ci: protoized.
-
- * thread_win32.ci: fixed typo.
-
-Tue Jun 5 13:17:11 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * call_cfunc.ci, compile.c, dir.c, eval.c, eval_jump.h, numeric.c,
- pack.c, re.c, thread.c, thread_win32.ci, vm.c, vm_dump.c: fixed
- indentation.
-
-Mon Jun 4 21:15:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/json.rb, lib/json, ext/json, test/json:
- import JSON library.
-
- * ext/nkf: import nkf.c rev:1.124
- Support CP10001.
-
-Mon Jun 4 20:52:58 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (int_round): should not just truncate.
-
-Sat Jun 2 16:48:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (Fiber#pass): rename to Fiber#yield. Block parameter
- of fiber body receive first yield values.
- e.g.: Fiber.new{|x| p x}.yield(:ok) #=> :ok
-
- * cont.c: rename rb_context_t#retval to rb_context_t#value.
-
- * test/ruby/test_fiber.rb: ditto.
+Mon Jun 4 11:11:12 2007 Shugo Maeda <shugo@ruby-lang.org>
-Sat Jun 2 16:45:21 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c (Init_Proc): remove a line break.
-
-Sat Jun 2 01:27:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (int_round): small optimization to handle bignums.
-
-Fri Jun 1 13:02:35 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * insnhelper.h (INC_SP): shouldn't cast ``x'' to unsigned type because
- it might be a negative value.
-
- * insnhelper.h, insns.def: shouldn't use unary minus operator in index
- operator. some compilers (such as VC++8 x64) cannot deal it with
- expected way.
-
-Fri Jun 1 11:33:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (num_round): should convert self to Float.
- [ruby-dev:30860]
-
-Fri Jun 1 02:01:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (flo_round): now takes optional argument to specify
- number of digits, like round() in Python/PHP.
-
- * numeric.c (num_round): ditto.
-
-Fri Jun 1 01:58:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/net/imap.rb (ResponseParser#next_token): fixed
+ error message. (backported from HEAD)
- * enum.c (each_with_index_i): should work well with continuation.
- a patch from sheepman <sheepman AT sheepman.sakura.ne.jp>.
- [ruby-dev:30846]
+ * lib/net/imap.rb (ResponseParser#parse_error): fixed
+ 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]
-Wed May 30 14:43:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c (cont_capture): store all local variables in heap
- ([ruby-dev:30832]).
+Thu May 31 02:12:32 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * vm.c (th_stack_to_heap): added.
+ * lib/rinda/tuplespace.rb (Rinda::TupleBag): create index on tuple bag
+ by first column.
- * test/ruby/test_continuation.rb: add a test for above.
+Wed May 30 13:27:40 2007 Shugo Maeda <shugo@ruby-lang.org>
- * eval_intern.h (th_get_ruby_level_cfp): fix to clean code.
-
-Wed May 30 13:32:34 2007 Shugo Maeda <shugo@ruby-lang.org>
+ * lib/net/ftp.rb (Net::FTP#transfercmd): skip 2XX
+ responses for some FTP servers. (backported from HEAD)
- * lib/net/imap.rb (ResponseParser#next_token): fixed
- error message.
+Wed May 30 05:17:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/imap.rb (ResponseParser#parse_error): fixed
- the condition not to refer @token.symbol unexpectedly.
- Thanks, Dick Monahan.
+ * eval.c (rb_eval): get rid of SEGV at ZSUPER in a block
+ [ruby-dev:30836]
-Wed May 30 13:24:33 2007 Shugo Maeda <shugo@ruby-lang.org>
+Wed May 30 04:29:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/ftp.rb (Net::FTP#transfercmd): skip 2XX
- responses for some FTP servers.
+ * eval.c (thread_timer): timer thread should not receive any
+ signals. submitted by Sylvain Joyeux. [ruby-core:08546]
Wed May 30 04:18:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_eval_cmd): just return if no exceptions.
[ruby-dev:30820]
-Wed May 30 02:14:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * signal.c (interrupt_init): needs to pass nil for Interrupt.
- [ruby-core:11038]
-
- * signal.c (trap): fixed segfaults. [ruby-dev:30830]
-
-Wed May 30 00:50:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (rb_source_filename, obj_free): suppress warnings.
-
- * gc.c (garbage_collect, yarv_machine_stack_mark): fixed typo.
- http://bugs.debian.org/426267
+Tue May 29 11:01:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed May 30 00:24:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (open_args, arg_ambiguous, parser_warning): should not use
- rb_warning in the parser.
-
-Tue May 29 12:31:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (rb_w32_opendir): removed duplicated code.
-
-Tue May 29 10:55:24 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: fix bug around Continuation and Fiber.
-
- * test/ruby/test_continuation.rb: add tests for Continuation.
-
-Tue May 29 10:54:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * win32/win32.c (rb_w32_opendir): store attributes of the second
+ entries or later too.
* win32/win32.c (rb_w32_opendir, rb_w32_readdir): eliminate magic
numbers.
-Mon May 28 10:27:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * cont.c: fixed a function name.
-
-Mon May 28 03:56:44 2007 Koichi Sasada <ko1@atdot.net>
+Mon May 28 02:54:05 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * cont.c: support Fiber. Check test/ruby/test_fiber.rb for detail.
- Fiber is known as "Micro Thread", "Coroutine", and other terms.
- At this time, only Fiber#pass is supported to change context.
- I want to know more suitable method name/API for Fiber (... do you
- know more suitable class name instead of Fiber?) as "suspend/resume",
- "call", "yield", "start/kick/stop/restart", ....
-
- * eval.c, eval_intern.h, thread.c, yarvcore.c, yarvcore.h: ditto.
-
-Sat May 26 00:38:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_exec_internal): do nothing if no code.
-
- * compile.c (rb_iseq_compile): check node if NULL before check
- nd_type. [ruby-talk:252956]
+ * lib/rinda/tuplespace.rb (Rinda::TupleBag#delete): use rindex and
+ delete_at instead of delete for little improvement.
Sat May 26 00:05:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -9241,54 +3896,6 @@ Sat May 26 00:05:22 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
skip tests for exitstatus and termsig on the platforms where
signals not supported.
-Fri May 25 16:04:47 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * yarvcore.c (Init_VM): wrap already initialized structs to use
- it directly.
-
-Fri May 25 11:09:47 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * regint.h (include): on some platform, defines.h redefines
- SIZE_OF_LONG_LONG so shouldn't re-include config.h after included
- defines.h.
-
- * regint.h (vsnprintf): ruby on windows already have vsnprintf macro.
-
-Thu May 24 12:07:27 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: check across trap violation.
-
- * eval.c, yarvcore.h: ditto.
-
-Thu May 24 11:46:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * gc.c, yarvcore.c: fix to mark VM structure on startup.
-
- * yarvcore.h: disable USE_CACHED_VALUE.
-
-Thu May 24 01:54:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * cont.c: support callcc which everyone love.
- incomplete. please give me bug reports.
-
- * common.mk, inits.c, thread.c: ditto.
-
- * yarvcore.c: export thread_mark().
-
- * yarvcore.h: disable value cache option.
-
- * eval_intern.h: set th_get_ruby_level_cfp to inline.
-
-Wed May 23 15:39:02 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * common.mk: add a rule for regsyntax.c.
-
-Wed May 23 10:31:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * oniguruma.h: updated to Oniguruma 5.7.0.
-
- * regsyntax.c, unicode.c: new files along with Oniguruma 5.x.
-
Wed May 23 06:51:46 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
* lib/cgi.rb (CGI#[]): get rid of exceptions being raised.
@@ -9300,148 +3907,50 @@ Wed May 23 05:49:49 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
load path to get rid of load pre-installed extensions/libraries.
[ruby-core:11017]
-Tue May 22 16:37:36 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.c (set_arg0): support RSTRING_LEN on HP-UX. a patch from
- WATANABE Tetsuya <Tetsuya.WATANABE AT nifty.com>. [ruby-dev:30806]
-
-Mon May 21 13:40:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, vm_macro.def: support tail call optimization
- (on default, this feature is not enabled).
-
- * iseq.c, compile.c, vm_opts.h: add "tailcall_optimization"
- option.
-
- * sample/test.rb (test_ok): fix to adjust tailcall stack layout.
-
- * insns.def, vm.c, compile.c, yarvcore.c, yarvcore.h:
- add opt_gt, opt_le instructions.
-
-Mon May 21 03:34:06 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/smtp.rb: CRAM-MD5 authentication did not work.
- [ruby-dev:30770]
-
-Sat May 19 10:26:01 2007 Tadayoshi Funaba <tadf@dotrb.org>
+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).
-Sat May 19 03:08:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enum.c (enum_inject): minor improvement. [ruby-dev:30792]
+Fri May 18 23:07:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * enum.c (one_i): no needs to iterate once the result became false.
+ * array.c (rb_ary_first): call rb_ary_subseq() instead of pushing
+ values by itself. [ruby-talk:252062]
- * enum.c (enum_one): fix for an example.
+ * array.c (rb_ary_first): add negative length check.
- * enum.c (one_iter_i, none_iter_i): DRY.;
+Fri May 18 17:10:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat May 19 01:07:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * win32/win32.c (move_to_next_entry): loc also must move forward.
+ [ruby-talk:251987]
- * enum.c (enum_inject): it is now can work without block. you
- have to specify two argument method name as the first argument.
+Fri May 18 03:02:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enum.c (Init_Enumerable): reduce is new alias to inject.
-
-Sat May 19 01:05:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (Init_File): method definition mismatch.
-
-Fri May 18 16:44:04 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (Init_File): add to_path method to File objects.
-
-Fri May 18 11:12:39 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * win32/mkexports.rb: preserve prefixed underscores for WINAPI
+ symbols.
- * ruby.c (DllMain, ruby_init_loadpath): use DLL instance handle given
- to DllMain instead of VirtualQuery so that loadpath becomes relative
- from the DLL on WinCE too.
+ * 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.
-Thu May 17 13:30:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_arg): remove typo from ripper description.
-
-Thu May 17 13:23:38 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y, compile.c (set_arguments): fix to support in-paren
- parameter (ex: def foo((a, b))).
-
-Thu May 17 13:01:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * iseq.c (ruby_iseq_disasm): fix to show post arg info.
-
-Thu May 17 12:56:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * debug.c (ruby_debug_node): fix to show node line.
-
-Wed May 16 21:48:44 2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/logger.rb (Logger::Application): remove meaningless logdev
- attribute and added logger attribute instead. [ruby-core:11143]
- also added Logger#formatter rdoc comment.
-
-Tue May 15 16:40:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/ruby/test_beginendblock.rb (test_endblockwarn): now parser
- warnings emit source names and line numbers.
-
-Tue May 15 15:01:38 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue May 15 14:54:07 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 02:12:07 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon May 14 13:28:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (rb_ary_zip): a.zip(b,c) should return an array, not
- enumerator.
+ * ext/thread/thread.c (wait_list): supress a warning.
- * array.c (rb_ary_zip): a.zip(b,c) should return array with size
- truncated to the size of its shortest argument array.
- [incompatible]
-
-Mon May 14 01:54:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_choice): should return nil when the array is
- empty.
-
-Sat May 12 18:26:36 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (tokens): forgot to add strip. [ruby-core:11120]
-
- * test/net/http/test_http.rb: test Net::HTTP.post_form.
-
-Fri May 11 15:27:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * iseq.c (iseq_data_to_ary): internal IDs must not be exposed.
- [ruby-core:11073]
-
- * parse.y (internal_id_gen): now returns scope local ID instead of
- global one.
-
-Thu May 10 15:15:53 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/ruby/test_super.rb: add tests.
-
-Thu May 10 15:14:05 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+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 15:09:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (POINTER_P): pointer may be larger than long.
-
- * parse.y (vtable_size, vtable_included, vtable_tblcpy,
- vtable_to_tbl): constified.
-
-Thu May 10 10:13:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu May 10 10:14:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * thread.c (rb_thread_priority): rdoc fix; the initial value is
+ * 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>
@@ -9449,163 +3958,49 @@ 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]
-Tue May 8 23:39:09 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:23:07 2007 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date/format.rb: reverted.
-
-Tue May 8 19:32:18 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/rational.rb: fix high-precision Rationals cannot be
- converted to Floats. [ruby-Bugs:10502], [ruby-core:11069],
- [ruby-dev:30743]
-
-Mon May 7 10:59:55 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/image.rb, test/rss/test_image.rb: fixed Image module
- namespace URI. reported by Dmitry Borodaenko. Thanks.
-
-Sun May 6 18:44:11 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (Net::HTTP.post_form): allow an Array of String
- for pairs argument. [ruby-Bugs:10340]
-
- * lib/net/http.rb (Net::HTTP#set_form_data): ditto.
-
-Sun May 6 17:54:36 2007 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: Connection header field might include both of
- "keep-alive" token and "close" token. [ruby-core:10818]
-
-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 original argument. [ruby-core:11090]
-
-Thu May 3 22:20:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in, defines.h, eval_load.c (rb_feature_p, rb_provided,
- 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]
-
- * thread.c: added an internal class, Barrier.
-
- * thread.c: copied rdocs from fastthread.
-
- * yarvcore.h (struct rb_vm_struct): moved loading_table from global.
-
-Thu May 3 18:10:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * vm_evalbody.ci, insns.def, vm.c, tool/insns2vm.rb (rb_num_t):
- renamed to get rid of name clash. [ruby-dev:30504]
-
- * yarvcore.c (ruby_thread_init): ditto.
-
-Wed May 2 18:52:58 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, yarvcore.h, yarvcore.c, insns.def: fix to mark VM stack
- in correct range.
-
-Wed May 2 17:13:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+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 2 15:14:56 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h: add redefine checks ([ruby-dev:30751]).
-
-Wed May 2 11:22:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: use Qtrue instead of 2.
-
- * vm.c, insns.def: support "lambda" calling convention.
-
-Wed May 2 06:46:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 9 11:51:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * error.c, parse.y, ruby.h (rb_compile_warn, rb_compile_warning): warn
- for compilation. the parser should no longer use rb_warn() and
- rb_warning(). [ruby-dev:30121]
-
-Wed May 2 05:45:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (assoc): result of assoc_new needs to be an assoc.
+ * bignum.c (rb_big_pow): reduce multiplying for even number.
-Wed May 2 05:40:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * 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>
-Tue May 1 18:45:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * sample/test.rb: import matzruby's sample/test.rb.
-
-Tue May 1 17:46:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_choice): a new method to choose an element
- randomly from an array.
-
- * array.c (rb_ary_choice): fixed mistake from RDoc.
-
-Tue May 1 13:59:18 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c (proc_arity): fix an arity bug ([ruby-core:11060]).
-
-Tue May 1 13:12:49 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, compile.c (set_arguments): support post arguments.
-
- * test/ruby/test_method.rb: add tests for above.
-
- * test/ruby/test_proc.rb: ditto.
-
- * proc.c: fix an arity bug ([ruby-core:11029]).
-
- * vm.c, vm.h, insns.def, vm_dump.h: fix bmethod process.
-
- * vm.c: support block argument on block parameter.
-
-Fri Apr 27 17:05:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (int_pow): bugfix of overflow detection.
-
- * numeric.c (int_pow): rb_big_pow() may return other than Bignum.
-
-Fri Apr 27 01:51:50 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c: support multiple splat (e.g, [a, *b, *c, e, *f]).
+ * numeric.c (int_pow): calculate power in Fixnum as possible.
+ [ruby-dev:30726]
-Fri Apr 27 00:03:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue May 8 23:42:51 2007 Tadayoshi Funaba <tadf@dotrb.org>
- * bignum.c (rb_big_pow): truncate all zero BDIGITs. [ruby-dev:30733]
+ * lib/date/format.rb (Date._parse): revised treatment of
+ hyphened/separatorless dates.
-Thu Apr 26 17:31:00 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/date/format.rb: some trivial adjustments.
- * bignum.c (rb_big_pow): reduce multiplying for even number.
+Tue May 8 20:25:05 2007 Tadayoshi Funaba <tadf@dotrb.org>
- * numeric.c (int_pow): calculate power in Fixnum as possible.
- [ruby-dev:30726]
+ * lib/date/format.rb: reverted.
-Thu Apr 26 17:18:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat May 5 16:26:33 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y: fixes for ripper.
+ * lib/date/format.rb (Format::Bag#method_missing): get rid of
+ modifying orginal argument. [ruby-core:11090]
- * parse.y (primary): reduced duplicated code.
+Mon Apr 30 01:17:51 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * parse.y (f_arg_item): should not override by meaningless value.
+ * lib/rinda/tuplespace.rb (TupleSpace#create_entry, TupleBag#push,
+ delete): extract method, and rename parameter.
- * parse.y (f_arg, assocs): should not use $$ before assigned.
+Fri Apr 27 02:00:17 2007 Ryan Davis <ryand-ruby@zenspider.com>
- * parse.y (assoc_list): dispatch assoclist_from_args for assocs as
- well as args.
+ * signal.c: Fixed backwards compatibility for 'raise Interrupt'.
- * parse.y (assoc): return assoc if dispatched result is $1.
+ * 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>
@@ -9616,49 +4011,6 @@ 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.
-Wed Apr 25 15:23:29 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (NtInitialize, exit_handler): add initializing and
- cleanup of critical section object for select.
-
- * win32/win32.c (do_select): block reentrance.
-
- * win32/win32.c (rb_w32_select): 0 sec polling of socket. this is
- workaround because winsock cannot do select at same socket at the
- same time by two or more threads.
-
-Wed Apr 25 14:10:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * ext/probeprofiler/probeprofiler.c: fix function name and
- return value.
-
-Wed Apr 25 12:42:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h: remove rb_control_frame_t#callee_id.
-
- * vm_macro.def: ditto.
-
- * eval_intern.h (exec_event_hooks): fix to check event flags
-
- * eval_intern.h (EXEC_EVENT_HOOK): fix to re-check event flags.
-
- * ext/probeprofiler : added. this profiler is sampling based
- profiler.
-
- * vm.c: add rb_thread_current_status() API for probeprofiler.
-
- * thread.c (rb_thread_execute_interrupts): add comments.
-
-Wed Apr 25 10:36:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_intern.h (PUSH_TAG): no argument now.
-
- * eval.c, eval_error.h, eval_jump.h, eval_load.c, proc.c, thread.c:
- ditto.
-
- * thread.c (alloc_event_hook, rb_thread_remove_event_hook): should
- return value.
-
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.
@@ -9686,89 +4038,19 @@ 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:21:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_cleanup): fixed access to out of bound, and inverted
- the order of errinfos.
+Fri Apr 20 12:17:05 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Apr 20 10:33:23 2007 Koichi Sasada <ko1@atdot.net>
+ * eval.c (ruby_cleanup): inversed the order of errinfos.
- * eval_intern.h: add prototypes of rb_sourceline() and
- rb_sourcefile().
+Thu Apr 19 14:53:32 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Apr 20 02:37:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (ruby_cleanup): re-send signal. [ruby-dev:30516]
-
- * eval_error.h (error_handle): no message when exiting by signal.
-
- * 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_f_kill): use NUM2PIDT instead of NUM2INT.
-
- * signal.c (rb_signal_exec, trap): handle SIGTERM. [ruby-dev:30505]
-
- * thread.c (rb_thread_signal_raise): now takes signal number instead
- of signal name.
-
- * thread.c (rb_thread_signal_exit): since rb_make_exception() calls
- #exception method, rb_class_new_instance() is not needed here.
-
- * yarvcore.h (struct rb_vm_struct), eval_jump.h (terminate_process):
- exit_code is no longer stored in VM.
-
-Thu Apr 19 18:37:49 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h:
- support set_trace_func (incomplete. id and klass
- don't be passed). And support Thread#set_trace_func
- which hook only specified thread and Thread#add_trace_func
- which add new trace func instead of replace old one.
- C level API was modified. See thread.c (logic) and
- yarvcore.h (data structures).
-
- * vm.c, vm_macro.def: add hook points.
-
- * compile.c, insns.def: fix "trace" instruction.
-
- * iseq.c, vm_macro.h: add compile option "trace_instruction".
-
- * test/ruby/test_settracefunc.rb: hook "c-return" of set_trace_func.
-
-Thu Apr 19 20:57:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (symbol): symbols should be followed by EXPR_ENDARG.
-
- * parse.y (dsym): ditto.
-
- * parse.y (parser_yylex): strings should be followed by
- EXPR_ENDARG.
-
- * parse.y (parser_yylex): ditto for numbers.
-
- * parse.y (parser_yylex): EXPR_ENDARG after ']' and '}'.
-
-Thu Apr 19 17:46:36 2007 Koichi Sasada <ko1@atdot.net>
-
- * lib/optparse.rb: fix to override conv proc.
+ * 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>
* util.c (ruby_strtod): exponent is radix 10. [ruby-talk:248272]
-Wed Apr 18 02:50:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * yarvcore.c (th_init2): push initial blockptr value for
- rb_block_given_p() outside ruby_exec(). [ruby-core:10923]
-
Wed Apr 18 02:30:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (LDFLAGS): prepend -L. instead appending it to
@@ -9777,6 +4059,14 @@ Wed Apr 18 02:30:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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>
+
+ * eval.c (rb_yield_0): should not clear state on TAG_NEXT when
+ it's invoked from within lambda body. [ruby-talk:248136]
+
+ * 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
@@ -9804,124 +4094,23 @@ 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]
-Mon Apr 16 10:51:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_each_with_index): each_with_index to forward
- arguments to each. [ruby-core:10921]
-
-Mon Apr 16 10:43:10 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (time_arg): should allow to specify 24:00.
- [ruby-core:10915]
-
-Sun Apr 15 09:12:54 2007 Tadayoshi Funaba <tadf@dotrb.org>
+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).
-Thu Apr 12 17:13:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (mutex_try_lock): check and set owner thread.
-
- * thread_pthread.ci: fix to show error code in error message.
-
-Thu Apr 12 17:11:54 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (rb_rescue2): restore cfp ([ruby-dev:30582]).
-
-Thu Apr 12 16:06:48 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (rb_protect): restore cfp ([ruby-dev:30671]).
-
-Thu Apr 12 16:04:31 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): check node->nd_state == 1, not !0.
-
-Wed Apr 11 16:35:16 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.[ch] (rb_w32_enter_critical, rb_w32_leave_critical): no
- need to reject reentrance. removed.
-
- * rubysig.h (RUBY_CRITICAL): follow above changes.
-
- * rubysig.h (TRAP_BEG, TRAP_END): no need to save errno.
-
-Tue Apr 10 17:02:17 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Apr 10 17:37:36 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().
-Tue Apr 10 16:14:22 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * thread_win32.ci (w32_wait_events): check whether interrupt_event is
- valid handle or not.
-
- * thread_win32.ci (native_thread_destroy): clear interrupt_event when
- close it.
-
-Tue Apr 10 15:53:17 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * thread_pthread.ci (native_thread_create): initialize sleep_cond.
- fixed: [ruby-dev:30675]
-
-Mon Apr 9 18:48:57 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * thread.c (do_select): ubf_select() is not necessary. interrupt is
- checked in the loop.
-
-Mon Apr 9 18:27:26 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * thread.c (do_select): use ubf_select() as UBF on windows.
-
- * win32/win32.c (do_select): shouldn't call catch_interrupt() here.
- fixed: [ruby-dev:30674], reported by wanabe.
-
-Mon Apr 9 09:24:32 2007 Shugo Maeda <shugo@ruby-lang.org>
+Mon Apr 9 09:30:44 2007 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (disconnect): call shutdown for
SSLSocket. Thanks, Technorama Ltd.
-Sun Apr 8 13:28:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (defined_expr): test arguments of NODE_CALL and so
- on as well as NODE_ATTRASGN. [ruby-core:10886]
-
-Fri Apr 6 10:56:29 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/ossl_pkey_ec.c (ossl_ec_key_get_group): get rid of
- warning. we are aware of it.
-
-Fri Apr 6 04:00:24 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_{bn,x509{attr,cert,name,store}}.c:
- Add documentation.
-
-Thu Apr 5 17:59:19 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * compile.c (defined_expr): support for assignment.
- [ruby-core:10867]
-
- * compile.h (ADD_CATCH_ENTRY): removed temporary variable.
-
-Thu Apr 5 15:13:34 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/ossl_ssl_session.c (ossl_ssl_session_alloc): should
- return value.
-
-Thu Apr 5 14:58:49 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_pkcs5.c: New module.
-
- * ext/openssl/ossl_{cipher,digest,pkcs7,pkcs12}.c:
- Remove redundant module namespace.
-
- * ext/openssl/lib/openssl/{cipher,digest}.rb
- Add backwards compatible classes for rearranged classes.
-
- * ext/openssl/ossl_{pkcs7,pkcs12}.c: Add documentation.
-
Thu Apr 5 00:42:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (rb_notimplement), io.c (pipe_open): removed definite
@@ -9932,258 +4121,153 @@ 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 12:29:02 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * error.c (rb_notimplement): should show the name of this func,
- not callee.
-
Wed Apr 4 10:18:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (popen_exec): should not close close-on-exec FDs.
- [ruby-dev:30679]
-
* io.c (pipe_open): raise NotImplementedError for command "-" on
platforms where fork(2) is not available. [ruby-dev:30681]
-Tue Apr 4 04:17:18 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_ssl.c: Add documentation.
-
-Tue Apr 3 16:22:24 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/openssl/extconf.rb: check for functions added in 1.9.
-
- * ext/openssl/ruby_missing.h: check per features instead by
- checking version code. [ruby-core:10845]
-
-Tue Apr 3 16:02:44 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_bn.c: More documentation.
-
- * ext/openssl/lib/ossl_{pkey,pkey_ec}.[ch]: Add elliptic curves.
-
-Tue Apr 3 15:50:41 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Apr 3 15:45:41 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]
-Tue Apr 3 09:36:55 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/ruby_missing.h: need to include version.h to check
- RUBY_VERSION_CODE.
-
-Mon Apr 3 07:10:12 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/ossl_{ssl.[ch],ssl_session.c},
- ext/openssl/lib/openssl/lib/openssl/ssl.rb:
- New SSL::Session class. Add session cb's, getter/setters,
- config, and statistics methods.
-
-Mon Apr 3 04:00:23 2007 Technorama Ltd. <oss-ruby@technorama.net>
-
- * ext/openssl/{ossl.[ch],ossl_pkey.c} Add documentation.
-
- * ext/openssl/ossl_hmac.c Add reset method.
-
- * ext/openssl/ossl_cipher.c (Cipher#update) Take additional
- buffer argument.
-
- * ext/openssl/{ossl_bio.c,ossl_ssl.c,ruby_missing.h}
- compatibility with 1.8.
-
-Mon Apr 2 21:55:12 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * insns.def (throw), thread.c, yarvcore.h (throwed_errinfo): fixed
- typo.
-
-Fri Mar 30 11:46:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_cmdvector): fixed buffer size. reported by
- wanabe [ruby-dev:30672]
-
- * win32/win32.c (init_env, insert, rb_w32_get_environ): use strdup
- instead of malloc + strlcpy. suggested by nobu [ruby-dev:30673]
+Sat Mar 24 23:40:29 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Mar 30 02:29:04 2007 Technorama <oss-ruby@technorama.net>
+ * node.h (struct rb_thread.locals): explicit as struct.
+ [ruby-core:10585]
- * ext/openssl/ossl_{bn,cipher,digest,hmac,rand,pkey_{dh,dsa,rsa}}.c:
- Add Documentation for various methods.
+ * eval.c, node.h (enum rb_thread_status, struct rb_thread,
+ rb_curr_thread, rb_main_thread): prefixed. [ruby-core:10586]
- * ext/openssl/lib/openssl/cipher.rb: Ditto
+ * file.c (chompdirsep): made an unprefixed name static.
- * ext/openssl/ossl_bn.c: add lshift! and rshift! methods.
+ * io.c (io_fread): ditto.
- * ext/openssl/ossl_digest.c: GetDigestPtr() also accept a string.
+Sat Mar 24 01:54:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Mar 23 11:28:24 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * eval.c (ruby_cleanup): exit by SystemExit and SignalException in END
+ block. [ruby-core:10609]
- * win32/win32.c (init_env, insert, cmdglob, rb_w32_cmdvector,
- rb_w32_opendir, rb_w32_readdir, rb_w32_strerror, rb_w32_stati64,
- rb_w32_get_environ): use strlcpy() and strlcat().
+ * test/ruby/test_beginendblock.rb (test_should_propagate_exit_code):
+ test for exit in END block. [ruby-core:10760]
- * win32/win32.c (rb_w32_opendir): use realloc() instead of xrealloc().
-
- * win32/win32.c (rb_w32_closedir): check NULL before free pointers.
-
-Fri Mar 23 00:24:52 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/shell: commit miss(support for ruby 1.9(YARV) thread model).
+ * test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
+ test for signal in END block.
-Thu Mar 22 13:32:17 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Mar 22 23:13:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/Makefile.sub (LIBS): remove an unnecessary library.
+ * eval.c (rb_provided): check for extension library if SOEXT is
+ explicitly given. [ruby-dev:30657]
-Thu Mar 22 10:27:58 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+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 20:38:06 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * marshal.c (w_short, w_long, w_object): get rid of VC++ warnings.
-
-Wed Mar 21 20:05:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
- proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
- debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
- is to change node structure around NODE_SCOPE, NODE_ARGS. Every
- scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
- represents more details of arguments information. I'll write a
- document about detail of node structure.
-
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]
-Tue Mar 21 08:20:00 2007 Nathaniel Talbott <ntalbott@ruby-lang.org>
-
- * test/testunit/collector/test_dir.rb: Fixed test/unit tests that
- were breaking due to Module#public_instance_methods now
- returning a Symbol instead of a String.
+Wed Mar 21 07:21:24 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/testunit/collector/test_objectspace.rb: Ditto.
+ * 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 21:36:47 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/shell.rb, lib/shell: support for ruby 1.9(YARV) thread model.
-
-Tue Mar 20 16:36:08 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
+Tue Mar 20 15:37:24 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
* distruby.rb: Add zip generation.
-Tue Mar 20 16:20:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_callee_name): add __method__ and __callee__ again.
- __callee__ need to rework to adopt YARV. [ruby-core:10671]
-
-Tue Mar 20 11:09:00 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/set.rb: Revise rdoc.
-
- * lib/set.rb (Set#freeze, Set#taint, Set#untaint): Implement
- Set#freeze, Set#taint, and Set#untaint; requested by: Dan
- Hutchings <dan AT moltoagitato.com> in [ruby-bugs:PR#9359].
-
-Tue Mar 20 09:13:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (rb_fork): flush stdouts always before fork(2).
- fixed: [ruby-dev:30612]
-
-Tue Mar 20 01:38:48 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * thread.c (thread_start_func_2): store the result of first_func
- as well as first_proc.
-
- * thread.c (thread_create_core): block is not used if first_func
- is given.
-
-Mon Mar 19 16:58:52 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * missing/{strlcat,strlcpy}.c, missing.h: new functions.
-
- * LEGAL: add copyright notice about above files.
-
- * configure.in: check whether strlcat and strlcpy are exist or not.
-
- * {bcc32,win32,wince}/Makefile.sub: use above files.
-
-Mon Mar 19 14:12:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+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 12:13:36 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Mar 19 11:39:29 2007 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb (rbuf_read): extend buffer size for speed.
- * regparse.c, etc.: K&R to ANSI code cleanup patch from Stefan
- Huehner <stefan at huehner.org>. [ruby-core:10543]
+Sun Mar 18 04:23:52 2007 Akinori MUSHA <knu@iDaemons.org>
-Mon Mar 19 11:27:13 2007 Minero Aoki <aamine@loveruby.net>
+ * NEWS: Add a note about the new `date' library defining
+ Time#to_date and Time#to_datetime private methods.
- * lib/net/protocol.rb (rbuf_read): extend buffer size for speed.
+ * NEWS: Inform that the old `thread' library is considered to be
+ stable.
-Sun Mar 18 08:31:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * NEWS: Sort library entries in alphabetical order.
- * win32/dir.h, win32/win32.c (rb_w32_opendir, rb_w32_readdir,
- rb_w32_closedir): get rid of possible buffer-overflows.
+Fri Mar 16 21:48:11 2007 Akinori MUSHA <knu@iDaemons.org>
-Sat Mar 17 19:10:39 2007 Kouhei Sutou <kou@cozmixng.org>
+ * ext/dl/dl.c (rb_ary2cary): Fix a bug in type validation;
+ submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
+ in [ruby-dev:30554].
- * lib/rss, test/rss:
- - supported Atom.
- - bumped version 0.1.6 to 0.1.7.
- * sample/rss/convert.rb: added new sample.
+Fri Mar 16 18:28:06 2007 Akinori MUSHA <knu@iDaemons.org>
-Fri Mar 16 22:32:20 2007 Minero Aoki <aamine@loveruby.net>
+ * ext/etc/etc.c (etc_getgrgid): Fix a bug in Etc::getgrgid()
+ always returning the (real) group entry of the running process;
+ reported by: UEDA Hiroyuki <ueda AT netforest.ad.jp>
+ in [ruby-dev:30586].
- * lib/net/pop.rb: change default verification mode from
- VERIFY_PEER to VERIFY_NONE because most POPS server does not have
- true certification.
+Fri Mar 16 16:33:58 2007 Akinori MUSHA <knu@iDaemons.org>
-Fri Mar 16 22:19:24 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * 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].
- * ext/win32ole/win32ole.c: add WIN32OLE#ole_activex_initialize,
- a little bit supporting ActiveX control. [ruby-talk:241188]
+Fri Mar 16 16:21:35 2007 Akinori MUSHA <knu@iDaemons.org>
-Fri Mar 16 22:16:58 2007 Minero Aoki <aamine@loveruby.net>
+ * 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].
- * lib/net/http.rb: merge Ruby-SSPI patch contributed by Justin
- Bailey.
+Fri Mar 16 16:17:27 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/Win32API/lib/win32/sspi.rb: new file.
+ * 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 19:04:30 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/sync.rb: support for ruby 1.9(YARV) thread model.
-
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 07:23:20 2007 Shugo Maeda <shugo@ruby-lang.org>
+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>
- * lib/monitor.rb (mon_try_enter): call @mon_muetx.try_lock.
- Thanks, Keiju ISHITSUKA. [ruby-dev:30507]
+ * runruby.rb: added --pure (turned on by default) and --debugger
+ options.
-Tue Mar 13 02:42:58 2007 Akinori MUSHA <knu@iDaemons.org>
+Tue Mar 13 02:50:28 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 10:53:28 2007 Akinori MUSHA <knu@iDaemons.org>
+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
@@ -10209,105 +4293,101 @@ Mon Mar 12 10:53:28 2007 Akinori MUSHA <knu@iDaemons.org>
* ext/openssl/ossl_ssl.c (Init_ossl_ssl): Ditto.
-Sun Mar 11 18:42:01 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * misc/ruby-mode.el (ruby-block-end-re): Support for the
- experimental ';;' terminator had been dropped.
-
-Sun Mar 11 05:45:46 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * misc/README, misc/rdebug.el: Add rdebug.el, Emacs ruby-debug
- interface based on rubydb3x.el; submitted by Martin Nordholts
- <enselic AT gmail.com> in [ruby-bugs:PR#9023].
-
-Sat Mar 10 07:20:28 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Mon Mar 12 01:05:17 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/win32ole/win32ole.c: add WIN32OLE_TYPELIB#library_name,
- WIN32OLE_TYPELIB#visible?.
+ * 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].
- * test/win32ole/test_win32ole_typelib.rb: ditto.
+ * ext/dl/ptr.c (rb_dlptr_inspect): Ditto.
-Thu Mar 8 09:17:59 2007 Minero Aoki <aamine@loveruby.net>
+Mon Mar 12 00:59:19 2007 Akinori MUSHA <knu@iDaemons.org>
- * compile.c: iseq_compile -> rb_iseq_compile.
+ * 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].
- * iseq.c: ditto.
+Sun Mar 11 18:57:50 2007 Akinori MUSHA <knu@iDaemons.org>
- * intern.h: provide function prototype of Init_jump.
+ * misc/README: Add a note about ruby-electric.el.
- * eval_jump.h (Init_jump): declare function type.
+ * misc/ruby-mode.el (ruby-non-block-do-re): Fix
+ ruby-non-block-do-re. [ruby-core:03719]
- * thread.c: platform-dependent functions should be surrounded by #ifdef.
+ * misc/inf-ruby.el: Synchronize the comment section with trunk.
- * iseq.c (iseq_data_to_ary): remove unused variable.
-
- * compile.c (set_arguments): ditto.
-
- * thread.c (set_unblock_function): ditto.
-
- * thread_pthread.ci: reduce printf warning.
+ * misc/README, misc/rdebug.el: Add rdebug.el, Emacs ruby-debug
+ interface based on rubydb3x.el; submitted by Martin Nordholts
+ <enselic AT gmail.com> in [ruby-bugs:PR#9023].
- * vm_dump.c: ditto.
+Sun Mar 11 17:45:51 2007 Akinori MUSHA <knu@iDaemons.org>
-Tue Mar 6 16:35:04 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
+ * ext/dl/mkcallback.rb (mkfunc): Make sure that a callback
+ function is found in the function table before trying to call
+ it; submitted by sheepman <sheepman AT sheepman.sakura.ne.jp>
+ in [ruby-dev:30524].
- * lib/shell/process-controller.rb: fix thread synchronization problem for [ruby-dev:30477].
+Sun Mar 11 12:09:37 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Mar 6 11:53:25 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * eval.c (error_handle): no message when exiting by signal.
- * ext/tk/sample/irbtkw.rbw: fails to exit process.
+ * eval.c (ruby_cleanup): re-send signal. [ruby-dev:30516]
-Tue Mar 6 10:23:09 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_thread_interrupt): instantiate SignalException.
- * runruby.rb: added --pure (turned on by default) and --debugger
- options.
+ * eval.c (rb_thread_signal_raise): now takes signal number instead
+ of signal name.
-Mon Mar 5 09:19:33 2007 Minero Aoki <aamine@loveruby.net>
+ * intern.h (rb_thread_signal_raise, ruby_default_signal): prototypes.
- * lib/timeout.rb (Timeout.timeout): should return the block value
- always.
+ * signal.c (esignal_init): takes a signal number and an optional
+ signal name.
- * lib/timeout.rb (Timeout.timeout): should yield sec argument
- always.
+ * signal.c (interrupt_init): pass SIGINT always.
- * lib/timeout.rb (Timeout.timeout): fix document.
+ * signal.c (ruby_default_signal): invoke system default signal
+ handler.
-Mon Mar 5 09:16:40 2007 Minero Aoki <aamine@loveruby.net>
+ * signal.c (rb_signal_exec, trap): handle SIGTERM. [ruby-dev:30505]
- * lib/net/smtp.rb: support automatic STARTTLS.
+Tue Mar 6 19:08:46 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/net/smtp.rb: check server advertisement.
+ * ext/digest/lib/md5.rb (MD5::new, MD5::md5): Do not modify
+ Digest::MD5.
- * lib/net/smtp.rb: introduce new class SMTP::Response.
+ * ext/digest/lib/sha1.rb (SHA1::new, SHA1::sha1): Ditto.
- * lib/net/smtp.rb (getok): should not use sprintf.
+Tue Mar 6 18:58:37 2007 Keiju Ishitsuka <keiju@ruby-lang.org>
- * lib/net/smtp.rb (get_response): ditto.
+ * lib/shell/process-controller.rb: fix thread synchronization
+ problem for [ruby-dev:30477].
- * lib/net/protocol.rb: reduce syntax warning on 1.9.
+Tue Mar 6 18:44:26 2007 Akinori MUSHA <knu@iDaemons.org>
-Mon Mar 5 07:13:28 2007 Minero Aoki <aamine@loveruby.net>
+ * 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].
- * lib/net/smtp.rb: reconstruct SMTPS/STARTTLS interface. New
- interface is incompatible from current 1.9 interface at all.
+ * ext/digest/lib/sha1.rb (SHA1::new, SHA1::sha1): Ditto.
- * lib/net/smtp.rb: All SSL-related class methods are removed; use
- instance methods instead.
+Tue Mar 6 18:24:19 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/net/smtp.rb: rename methods: *ssl -> *tls (with alias
- "ssl").
+ * time.c (time_to_s): Back out the format changes; discussed
+ in [ruby-dev:30495].
- * lib/net/smtp.rb: rename methods: *tls -> *starttls.
+Tue Mar 6 11:53:25 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Mar 5 01:36:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/tk/sample/irbtkw.rbw: fails to exit process.
- * parse.y (parser_yylex), win32/win32.c (rb_w32_utime): fixed
- indentation broken at YARV merger.
+Mon Mar 5 20:14:49 2007 Akinori MUSHA <knu@iDaemons.org>
-Sun Mar 4 23:41:14 2007 Nobuyoshi Nakada <nobu@ruby-lang.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].
- * file.c (rb_stat_uid, rb_stat_gid, eaccess): use rb_uid_t and
- rb_gid_t instead of int.
+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.
@@ -10318,21 +4398,21 @@ 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:01:25 2007 Akinori MUSHA <knu@iDaemons.org>
+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 22:54:33 2007 Minero Aoki <aamine@loveruby.net>
+Sat Mar 3 23:01:07 2007 Minero Aoki <aamine@loveruby.net>
- * lib/fileutils.rb (touch): last #touch change causes error when
- :mtime option was not given.
+ * lib/fileutils.rb (mv): could not move a directory between
+ different filesystems. [ruby-dev:30411]
-Sat Mar 3 22:51:29 2007 Minero Aoki <aamine@loveruby.net>
+Sat Mar 3 22:57:11 2007 Minero Aoki <aamine@loveruby.net>
- * lib/fileutils.rb (mv): could not move directory between
- different file systems. [ruby-dev:30411]
+ * 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>
@@ -10341,26 +4421,39 @@ Sat Mar 3 22:37:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/fileutils.rb (touch): ditto, and added :mtime and :nocreate
options. fixed: [ruby-talk:219037]
-Sat Mar 3 15:52:26 2007 Akinori MUSHA <knu@iDaemons.org>
+Sat Mar 3 21:17:35 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>
- * object.c (instance_variable_get): Restore rdoc markups lost in
- the last commit.
+ * NEWS: Add a note for String#intern.
-Fri Mar 2 21:17:14 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sat Mar 3 16:23:13 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/win32ole/win32ole.c (get_ptr_of_variant, ole_set_safe_array,
- ole_val2ptr_variant, ole_val2olevariantdata, ole_variant2val,
- ): fix some bugs of WIN32OLE_VARIANT.new when variant type is
- VT_ARRAY|VT_BSTR or VT_BYREF.
+ * env.h (SCOPE_CLONE): Introduce a new scope flag to prevent a
+ local_tbl region from getting freed many times; submitted by
+ Chikanaga Tomoyuki <chikanag AT nippon-control-system.co.jp> in
+ [ruby-dev:30460].
- * ext/win32ole/win32ole.c (folevariant_s_array, folevariant_initialize):
- WIN32OLE_VARIANT#[], WIN32OLE_VARIANT#[]=, WIN32OLE_VARIANT#value=
- is defined as instance method of WIN32OLE_VARIANT.
+ * eval.c (proc_invoke): Ditto.
- * test/win32ole/test_win32ole_variant.rb: add some test for
- VT_ARRAY, VT_BYREF variant type.
+ * gc.c (obj_free): Ditto.
-Fri Mar 2 07:58:24 2007 Yukihiro Matsumoto <matz@ruby-lang.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>.
@@ -10371,7 +4464,14 @@ Thu Mar 1 21:38:07 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 02:55:25 2007 Akinori MUSHA <knu@iDaemons.org>
+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
@@ -10381,6 +4481,11 @@ 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.
@@ -10393,31 +4498,29 @@ Wed Feb 28 20:51:32 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
UTF-8 encoded BOMs; submitted by SOUMA Yutaka <holon@radastery.jp>
to fix [ruby-core:10437]
-Wed Feb 28 18:31:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+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:23:43 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+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 10:33:58 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, configure.in, */Makefile.sub (THREAD_MODEL): system
- specific thread model.
+Wed Feb 28 18:31:32 2007 Akinori MUSHA <knu@iDaemons.org>
- * compile.h, regint.h, vm.h, array.c: removed unnecessary #include.
+ * doc/NEWS-1.8.0: Rename NEWS to NEWS-1.8.0. This is way too old
+ NEWS.
-Wed Feb 28 04:03:03 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (take_i): small cosmetic / documentation patch from
- Tadashi Saito <shiba AT mail2.accsnet.ne.jp>. [ruby-dev:30446]
-
-Wed Feb 28 01:20:18 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+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]
@@ -10445,27 +4548,19 @@ 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 20:35:28 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * common.mk (error.c, process.c): depend on yarvcore.h and rubysig.h.
-
-Tue Feb 27 19:26:31 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/nkf/nkf.c (rb_str_resize, rb_nkf_kconv, rb_nkf_guess1,
- rb_nkf_guess2): Silence warnings regarding char * vs. unsigned
- char * mismatch; submitted by Lyle Johnson
- <lyle.johnson@gmail.com> in [ruby-core:10416].
-
-Tue Feb 27 19:15:01 2007 Akinori MUSHA <knu@iDaemons.org>
+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 18:59:42 2007 Akinori MUSHA <knu@iDaemons.org>
+Tue Feb 27 19:36:57 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/bigdecimal/bigdecimal.c (BigDecimal_load): Silence warnings
- regarding char * vs. unsigned char * mismatch; submitted by Lyle
- Johnson <lyle.johnson@gmail.com> in [ruby-core:10416].
+ * 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.
@@ -10474,321 +4569,65 @@ Tue Feb 27 18:59:42 2007 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/digest.c (rb_digest_base_finish,
rb_digest_base_update): Ditto.
-Tue Feb 27 18:12:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_take): new method. [ruby-dev:30407]
-
- * enum.c (enum_drop): ditto.
-
-Tue Feb 27 07:47:24 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, vm.h: rename th_invoke_yield() to th_yield().
-
- * blockinlining.c: ditto.
-
- * eval.c: ditto.
-
- * vm.c, insns.def: rename th_invoke_yield_cfunc()
- to th_yield_with_cfunc().
-
- * yarvcore.h, yarvcore.c: rename theYarvVM to ruby_current_vm and
- yarvCurrentThread to ruby_current_thread. remove yarvVMArray.
-
-Tue Feb 27 00:45:23 2007 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_optimization.rb: restore method before calling
- assert_equal.
-
-Mon Feb 26 00:58:39 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h: add rb_thread_t#top_wrapper, top_self.
-
- * eval_load.c (rb_load): support eval in wrapper module
- (load(file, true)).
-
- * eval.c: ditto.
-
- * eval_jump.h: ditto.
-
- * iseq.c: ditto.
-
- * vm.c: ditto.
-
- * yarvcore.c: ditto.
-
- * insns.def: add a empty line.
-
-Mon Feb 26 00:54:36 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: change "gdb" rule. You can debug miniruby with
- $(srcdir)/test.rb on gdb by this rule (type "make gdb").
- If you write break points to "breakpoints.gdb" on $srcdir,
- gdb runs with this file.
-
-Sun Feb 25 11:46:58 2007 Koichi Sasada <ko1@atdot.net>
-
- * win32/Makefile.sub: enable -Zi (debug) option.
-
-Sun Feb 25 11:38:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * ruby.h: define RUBY_VM macro and remove NATIVETHREAD* macros.
-
- * intern.h: ditto.
-
- * signal.c (posix_signal): remove unused function
- posix_nativethread_signal().
-
-Sun Feb 25 11:31:13 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (rb_thread_run): fix to ANSI style.
-
-Sun Feb 25 11:09:16 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest/runner.rb: show source code in error message.
-
-Sun Feb 25 09:39:50 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h:
- rename:
- rb_iseq_t#file_name -> filename
- rb_iseq_t#local_tbl -> local_table
- add:
- rb_iseq_t#local_table_size
-
- * compile.c: separate local_table_size and local_size
- (local variable size)
-
- * blockinlining.c: apply above rename.
-
- * compile.h: ditto.
-
- * eval.c: ditto.
-
- * iseq.c: ditto.
-
- * proc.c: ditto.
-
- * vm.c: ditto.
-
- * vm_dump.c: ditto.
-
-Sun Feb 25 10:27:17 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest/runner.rb: add lib/ to load path.
-
-Sat Feb 25 10:16:50 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * rubyio.h (HAVE_RB_IO_T): macro to tell if rb_io_t is defined.
-
-Sat Feb 24 19:39:16 2007 Minero Aoki <aamine@loveruby.net>
-
- * common.mk: new target "btest", to run bootstraptests.
-
-Sat Feb 24 19:30:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c, gc.c, io.c, ruby.h, rubyio.h, win32/win32.h (rb_io_t):
- renamed from OpenFile.
-
- * ext/dl/cptr.c, ext/io/wait/wait.c, ext/openssl/ossl.h,
- ext/openssl/ossl_bio.c, ext/openssl/ossl_ssl.c, ext/pty/pty.c,
- ext/readline/readline.c, ext/socket/socket.c: ditto.
-
-Sat Feb 24 19:28:23 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest/runner.rb: new option -v,--verbose.
-
-Sat Feb 24 18:55:50 2007 Minero Aoki <aamine@loveruby.net>
-
- * yarvtest/test_method.rb: removed (merged to bootstraptest).
-
- * yarvtest/test_class.rb: ditto.
-
-Sat Feb 24 18:44:39 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest/test_class.rb: new file.
-
- * bootstraptest/test_method.rb: add tests.
-
-Sat Feb 24 18:44:30 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h (rb_thread_blocking_region): add prototype.
-
- * file.c (rb_thread_flock, rb_file_flock): use UBF feature.
-
- * process.c (rb_waitpid_blocking, rb_waitpid): use UBF feature.
-
- * thread.c (rb_thread_debug): added runtime debugging flag.
-
- * thread.c (BLOCKING_REGION): restore previous UBF.
-
- * thread.c (rb_thread_blocking_region): default UBF to interrupt
- in system dependent way by RB_UBF_DFL.
- + ubf_select() on posix system
- + ubf_handle() on Win32
- + none on cygwin
-
- * thread_win32.ci (rb_w32_wait_events_blocking): blocking version.
-
- * win32/win32.c (waitpid): use rb_w32_wait_events_blocking().
-
-Sat Feb 24 17:45:48 2007 Minero Aoki <aamine@loveruby.net>
-
- * parse.y (f_arg, opt_f_block_arg): ripper should export VALUE.
-
-Sat Feb 24 16:52:55 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest/runner.rb: fix syntax error.
-
-Sat Feb 24 16:51:09 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest/runner.rb: new option --help.
-
-Sat Feb 24 16:47:33 2007 Minero Aoki <aamine@loveruby.net>
-
- * bootstraptest: new test suite.
-
- * bootstraptest/runner.rb: new file.
-
- * bootstraptest/test_literal.rb: new file.
-
- * bootstraptest/test_method.rb: new file.
-
-Sat Feb 24 16:29:15 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (StartSocket): remove unnecessary code.
-
-Sat Feb 24 16:04:30 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (struct local_vars): remove unused nofree member from
- struct.
-
- * parse.y (parser_free): ditto.
-
-Sat Feb 24 15:57:19 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/thread.rb (ConditionVariable#broadcast): use Mutex
- instead of Thread.exclusive.
-
- * lib/monitor.rb (MonitorMixin#mon_exit): unset @mon_owner
- before calling Mutex#unlock.
-
-Sat Feb 24 15:51:45 2007 Minero Aoki <aamine@loveruby.net>
-
- * parse.y (program): remove useless assignment to reduce warning.
-
-Sat Feb 24 15:41:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (lambda): remove unused clause from the rule to stop
- warning.
-
-Sat Feb 24 15:41:22 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/thread.rb: do not redefine Mutex#synchronize.
-
-Sat Feb 24 15:14:02 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/monitor.rb: rewritten using Mutex/ConditionVariable.
-
-Sat Feb 24 13:25:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * lib/soap/mapping/factory.rb: catch up with spec changes (return
- Symbols instead of Strings).
-
- * lib/soap/mapping/mapping.rb: ditto.
-
-Sat Feb 24 10:49:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * parse.y, node.h, compile.c: change node tree structure. a purpose
- of this change is to unify argument structure of method and block.
- this change prohibits duplicate block parameter name.
- new argument infromation:
- NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
- NODE_ARGS_AUX [r: ID, b: ID, ->]
- NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
- optarg information:
- NODE_OPT_ARGS [idx, expr, ->]
+ * ext/nkf/nkf.c (rb_str_resize, rb_nkf_kconv, rb_nkf_guess1,
+ rb_nkf_guess2): Ditto.
- * vm_macro.def: ditto.
+Tue Feb 27 03:40:09 2007 Akinori MUSHA <knu@iDaemons.org>
- * gc.c: ditto.
+ * 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].
- * iseq.c: ditto.
+ * ext/thread/thread.c (set_critical): Merge in
+ thread_exclusive_ensure().
- * compile.h: fix debug function name.
+ * ext/thread/thread.c: Consistently use 0 and 1 for
+ rb_thread_critical values.
- * test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
+Mon Feb 26 15:18:23 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_lambda.rb: disalbe test temporarily.
+ * ext/thread/thread.c: Use xmalloc()/xfree() instead of
+ malloc()/free(); pointed out by shugo in [ruby-dev:30412].
-Sat Feb 24 10:46:28 2007 Koichi Sasada <ko1@atdot.net>
+Sun Feb 25 23:02:55 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/testunit/test_testcase.rb: catch up with current instance
- variable spec.
+ * 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].
-Sat Feb 24 10:32:59 2007 Koichi Sasada <ko1@atdot.net>
+Sun Feb 25 02:47:43 2007 Akinori MUSHA <knu@iDaemons.org>
- * common.mk: change vm_macro.def rule.
+ * 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:38:05 2007 Minero Aoki <aamine@loveruby.net>
+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]
-Sat Feb 24 07:31:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_VARIANT.array,
- WIN32OLE_VARIANT#value=, refactoring.
-
- * test/win32ole/test_win32ole_variant.rb: add some test for
- WIN32OLE_VARIANT.array, WIN32OLE_VARIANT#value=.
+Fri Feb 23 15:10:46 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Feb 23 18:37:55 2007 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_yield.rb: new test.
-
- * yarvtest/test_yield.rb: removed (moved to test_yield.rb).
-
-Fri Feb 23 18:27:17 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * thread.c (rb_thread_polling): check interrupts here.
-
- * thread_win32.ci (w32_wait_events): rename from w32_wait_event(), and
- now receive multiple event handles.
-
- * win32/win32.c (wait_events, rb_w32_main_context): removed.
-
- * thread_win32.ci (rb_w32_wait_events): new function.
-
- * thread_win32.ci, win32/win32.c (rb_w32_sleep, rb_w32_Sleep): move
- from win32/win32.c to thread_win32.ci, and use w32_wait_events().
-
-Fri Feb 23 18:13:22 2007 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_optimization.rb: new test (merges test_opts.rb).
-
- * yarvtest/test_opts.rb: removed.
-
-Fri Feb 23 16:59:39 2007 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_assignment.rb: merge yarvtest/test_massign.
-
- * yarvtest/test_massign.rb: removed (merged to
- test_assignment.rb).
+ * win32/win32.c (set_pioinfo_extra): new function for VC++8 SP1
+ workaround. [ruby-core:10259]
-Fri Feb 23 15:58:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+ * win32/win32.c (NtInitialize): call above function.
- * signal.c (sighandler): need to re-install sighandler on some
- platforms.
+Fri Feb 23 14:19:40 2007 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Feb 23 15:05:57 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.c (set_pioinfo_extra): simplified.
+ * win32/win32.[ch] (rb_win32_interrupted): new function to listen
+ interrupt.
-Fri Feb 23 14:23:20 2007 Minero Aoki <aamine@loveruby.net>
+Fri Feb 23 13:02:17 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_literal.rb: new test.
+ * 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:40:12 2007 James Edward Gray II <james@grayproductions.net>
+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
@@ -10798,85 +4637,12 @@ Fri Feb 23 12:40:12 2007 James Edward Gray II <james@grayproductions.net>
* lib/xmlrpc/create.rb (XMLRPC::Create::conv2value): Add DateTime
support to xmlrpc; approved by the maintainer.
-Fri Feb 23 12:24:46 2007 Minero Aoki <aamine@loveruby.net>
-
- * parse.y (lambda): add ripper event. This fixes bus error on
- "make test-all".
-
- * ext/ripper/extconf.rb: do not stop build.
-
-Fri Feb 23 12:16:05 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y: remove dyna_check_gen() prototype.
-
-Fri Feb 23 11:41:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
- object.c, string.c, variable.c, vm_macro.def: revert private
- instance variable feature, which is postponed until next major
- release.
-
- * marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
- 8th version.
-
-Fri Feb 23 10:53:21 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * thread_pthread.ci (native_mutex_lock): do not call
- pthread_mutex_trylock().
-
-Fri Feb 23 10:31:16 2007 Minero Aoki <aamine@loveruby.net>
-
- * dln.c: use dlopen on Mac OS X 10.3 or later.
-
-Fri Feb 23 10:03:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_ord): need not to check string length; ord
- returns a codepoint for the first character in the string.
-
-Wed Feb 21 22:29:45 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * numeric.c (fix_equal): A bit more optimization.
-
-Wed Feb 21 17:40:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (fix_equal): remove FIX2LONG() to optimize. suggested
- in http://t-a-w.blogspot.com/2007/02/making-ruby-faster.html.
- [ruby-talk:240223]
+Mon Feb 19 18:22:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * numeric.c (fix_cmp): ditto.
-
-Wed Feb 21 09:14:04 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval_load.c (rb_require_safe): should restore safe level.
-
-Tue Feb 20 21:19:29 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (installed_code_page_proc,
- ole_variant2val): small refactoring.
-
-Tue Feb 20 15:11:42 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, vm.c, yarvcore.h: move definition of rb_call_super() to
- vm.c from eval.c. change th_call_super() to static function.
-
-Tue Feb 20 15:08:25 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/io/nonblock/test_flush.rb: YARV doesn't raise any errors if
- another thread close IO object which current thread is blocking with.
-
-Tue Feb 20 15:03:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (do_select, rb_thread_wait_fd_rw): raise sys error if
- errno is not 0 and EBADF.
-
-Mon Feb 19 22:15:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_REPLACE_TYPE): cache convertible type info.
-
- * intern.h (rb_detach_process): use rb_pid_t instead of pid_t.
-
- * ruby.h (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM, NUM2GIDT):
- defaulted to conversion using long.
+ * 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>
@@ -10884,154 +4650,46 @@ Mon Feb 19 17:14:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
message for #peeraddr. a patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:10366]
-Sun Feb 18 22:56:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/etc/etc.c (etc_getgrgid): missed to replace a macro.
-
-Sun Feb 18 19:33:00 2007 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Feb 18 19:35:21 2007 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/format.rb: updated based on date2 4.0.3.
-Sun Feb 18 13:11:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (pid_t, uid_t, gid_t): check if defined.
-
- * intern.h, process.c, rubyio.h, ext/etc/etc.c, ext/pty/pty.c: use
- rb_{pid,uid,gid}_t instead of plain int. [ruby-dev:30376]
-
- * ext/etc/extconf.rb (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM,
- NUM2GIDT): moved to configure.in.
-
-Fri Feb 16 21:34:33 2007 Koichi Sasada <ko1@atdot.net>
-
- * object.c (rb_obj_ivar_set/get/defined): fix to check :@_v/C id.
-
- * test/testunit/test_testcase.rb: fix to use instance_variable_get()
- to access @_result.
-
-Fri Feb 16 20:59:10 2007 Koichi Sasada <ko1@atdot.net>
-
- * intern.h: add a prototype of rb_sym_to_s().
-
-Fri Feb 16 19:24:22 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * math.c (math_log): update document to mention second optional
- argument for logarithm base.
-
-Fri Feb 16 19:19:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (mrhs): need to append by arg_append().
- [ruby-talk:239385]
-
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]
+ <hgs at dmu.ac.uk> from [ruby-core:10135]
* lib/prettyprint.rb: Suppress RDoc for PrettyPrint test suite.
-Thu Feb 15 20:48:36 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Feb 15 20:26:30 2007 Akinori MUSHA <knu@iDaemons.org>
- * win32/win32.c (set_pioinfo_extra): new function for VC++8 SP1
- workaround. [ruby-core:10259]
+ * lib/uri/ftp.rb: Revert the previous change pending discussion.
- * win32/win32.c (NtInitialize): call above function.
+Thu Feb 15 18:08:17 2007 Akinori MUSHA <knu@iDaemons.org>
+
+ * dir.c (glob_helper): Fix the function declaration.
-Thu Feb 15 16:25:54 2007 Akinori MUSHA <knu@iDaemons.org>
+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 01:52:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.(c|h), yarvcore.(c|h) (yarvGlobalStateVersion): rename to
- ruby_vm_global_state_version.
-
-Thu Feb 15 01:50:26 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/fileutils/test_fileutils.rb (check_singleton): fix to use
- symbole instead of string.
-
- * test/io/nonblock/test_flush.rb: enable tests.
-
- * test/xmlrpc/test_webrick_server.rb: ditto.
-
-Thu Feb 15 01:43:45 2007 Koichi Sasada <ko1@atdot.net>
-
- * lib/delegate.rb: catch up with class local variable (@_v) spec.
-
- * lib/singleton.rb: ditto.
-
-Wed Feb 14 22:52:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_variant2val): VC++6 does not
- support VT_I8, VT_UI8.
-
-Wed Feb 14 22:10:21 2007 Koichi Sasada <ko1@atdot.net>
-
- * configure.in: change stack limit to 2MB from 32MB.
-
- * win32/Makefile.sub: ditto.
-
-Wed Feb 14 21:39:36 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.
-
-Wed Feb 14 21:19:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.ci (native_thread_create): adjust 4KB (page size)
- alignment.
-
-Wed Feb 14 21:12:36 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.ci (CHECK_ERR): call rb_bug()
- instead of printf() and exit().
-
-Wed Feb 14 16:48:56 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/date/format.rb (Date::Format::Bag::method_missing): need not
- to use instance variables corresponding each method; use Hash
- instead.
-
-Wed Feb 14 13:12:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (reg_operand): allow symbols to be operands for regular
- expression matches.
-
- * string.c (Init_String): allow Symbol#===.
-
- * lib/date/format.rb (Date::Format::Bag::to_hash): string
- added prefixes.
-
-Wed Feb 14 12:58:38 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (do_select): fix to iterate select().
- on cygwin/mswin32, iterate in unblocking region.
-
- * thread.c (rb_thread_select): don't iterate on this function.
- (iterate in do_select).
-
-Wed Feb 14 11:39:18 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (set_unblock_function): fix function interface.
+Thu Feb 15 11:46:05 2007 KIMURA Koichi <hogemuta@gmail.com>
-Wed Feb 14 11:12:02 2007 Koichi Sasada <ko1@atdot.net>
+ * 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.
- * eval_load.c, yarvcore.h: use rb_vm_t#loaded_features instead of
- rb_features (global variable).
-
- * yarvcore.c: mark rb_vm_t#loaded_features.
-
-Wed Feb 14 08:46:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * compile.c (defined_expr): no longer distinguish ordinary local
- variables and in-block local variables in defined? value.
-
-Wed Feb 14 03:14:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+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]
@@ -11039,317 +4697,110 @@ Wed Feb 14 03:14:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/uri/generic.rb (URI::Generic::set_password): password can be
cleared by nil. [ruby-core:10290]
-Wed Feb 14 03:10:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/uri/common.rb (escape): regard second string argument as a
+ character set properly. [ruby-dev:27692]
- * parse.y (struct local_vars): no need to warn out-of-scope
- variables; remove dnames member from struct.
+ * lib/uri/ftp.rb: Attempt to conform to RFC 1738 with regard to
+ relative/absolute paths.
-Wed Feb 14 03:04:10 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/uri: Lovely RDOC patches from mathew (metaATpoboxDOTcom).
- * parse.y: RVarmap no longer used as yytype; removed.
+Thu Feb 15 10:57:38 2007 Tietew <tietew@tietew.net>>
- * parse.y (dyna_push_gen): no longer need return value.
+ * 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]
- * parse.y (dyna_pop_gen): no longer need argument.
+Thu Feb 15 10:48:40 2007 MenTaLguY <mental@rydia.net>
- * parse.y (local_push_gen): initialize nofree.
+ * ext/thread/thread.c: Handle interrupted waits correctly.
+ [ruby-bugs:PR#8663]
-Wed Feb 14 00:30:07 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Feb 14 19:22:15 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/socket/socket.c (init_unixsock): path may contain NUL for
- abstract unix sockets. [ruby-core:10288]
+ * 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.
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]
-Mon Feb 12 13:57:30 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_variant2val): support VT_I8, VT_UI8.
-
-Mon Feb 12 11:48:52 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/dublincore.rb, lib/rss/maker/dublincore.rb: dc_rightses
- -> dc_rights_list. dc_rightses still exists for backward
- compatibility. [ruby-core:8350]
+Sun Feb 11 07:46:45 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/rss/test_maker_dc.rb: added tests for dc_rights_list.
+ * lib/cgi.rb (CGI::QueryExtension::read_multipart): Properly parse
+ a quoted-string in a Content-Disposition value.
-Sun Feb 11 22:40:17 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sun Feb 11 06:27:54 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/win32ole/win32ole.c (ole_ptrtype2val): ole_type, ole_type_detail
- should not return "VARIANT,VARIANT".
+ * 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 22:11:05 2007 Kouhei Sutou <kou@cozmixng.org>
+Sun Feb 11 06:22:20 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#initialize):
- kept backward compatibility.
+ * ext/Setup: Add thread except for platforms without threads
+ support.
-Sun Feb 11 22:10:08 2007 Kouhei Sutou <kou@cozmixng.org>
+Sun Feb 11 06:15:16 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/rss/parser.rb (RSS::ListenerMixin#start_else_element): used
- const_defined? instead of constants.include?.
+ * ext/thread/lib/thread.rb: Add a replacement of thread.rb that
+ loads this extension.
-Sun Feb 11 18:47:14 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_val2olevariantdata):
- WIN32OLE_VARIANT#new accepts nil when variant type is VT_ARRAY.
+ * lib/thread.rb: Remove an ineffective part of the code.
- * test/win32ole/test_win32ole_variant.rb: ditto.
+Sun Feb 11 05:32:54 2007 Akinori MUSHA <knu@iDaemons.org>
- * ext/win32ole/win32ole.c: small refactoring.
+ * ext/thread/thread.c (rb_thread_exclusive): Implement
+ Thread.exclusive.
-Sun Feb 11 07:42:25 2007 Akinori MUSHA <knu@iDaemons.org>
+Sun Feb 11 05:26:51 2007 Akinori MUSHA <knu@iDaemons.org>
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): Properly parse
- a quoted-string in a Content-Disposition value.
+ * ext/thread/thread.c: Get rid of use of a dummy function.
-Sat Feb 10 20:21:29 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sun Feb 11 01:45:31 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/win32ole/win32ole.c: add WIN32OLE#ole_query_interface.
- thanks to Mikael Pahmp.
+ * ext/thread/thread.c (Init_thread): Define missing aliases:
+ Queue#enq and SizedQueue#enq.
- * test/win32ole/test_win32ole.rb: ditto.
+Sat Feb 10 09:27:35 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Sat Feb 10 17:46:52 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/win32ole/win32ole.c (ole_variant2val): fix compile error
+ on VC++.
- * common.mk: targets which depend on yarvcore.h now depend on
- rubysig.h too.
+Sat Feb 10 07:41:52 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * yarvcore.h (rb_vm_t): use rb_atomic_t instead of int.
+ * 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 12:33:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread_win32.ci (w32_show_error_message): renamed to w32_error.
- this function do rb_bug().
-
- * thread_win32.ci (w32_set_event, w32_reset_event, w32_close_handle,
- w32_resume_thread): added. fix to use these functions instead calling
- win32api directly.
-
- * thread_win32.ci (w32_create_thread): create suspend thread
- (caller must call w32_resume_thread()).
-
-Fri Feb 9 11:03:40 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_readpartial.rb: tests are working on mswin32/cygwin.
-
-Fri Feb 9 05:08:17 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
- move cleanup function to thread_start_func_2().
-
- * thread.c, thread_pthread.ci, thread_win32.ci:
- add more destruct functions.
- (native_thread_destroy() and native_mutex_destroy())
-
- * thread_pthread.ci, thread_pthread.h: make native_mutex_* functions
- (check error, etc), it's not macro any more.
-
- * thread_win32.ci (thread_start_func_1): store some values before
- running thread (to release these after running thread).
-
- * thread_win32.ci (native_thread_create): fix spaces.
-
-Thu Feb 8 22:44:04 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_set_safe_array, ole_variant2val,
- ole_val_ary2variant_ary): fix WIN32OLE_VARIANT.new bug when
- 1st argument is empty array, and when 2nd argument is
- VT_ARRAY|VT_BYREF.
-
- * test/win32ole/test_win32ole_variant.rb: ditto.
-
-Thu Feb 8 22:39:09 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvtest/yarvtest.rb: check target command names.
-
-Thu Feb 8 22:31:45 2007 Koichi Sasada <ko1@atdot.net>
+Fri Feb 9 20:44:53 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_clone.rb: fix to current spec
- (Module should not be occur many times in ancestors).
+ * ext/thread: Make style fixes (mostly de-K&R'ism) to match the
+ rest of the source code.
-Thu Feb 8 22:26:14 2007 Koichi Sasada <ko1@atdot.net>
+ * ext/thread: Make USE_MEM_POOLS an extconf option.
- * test/ruby/test_string.rb: ("foo" == :foo) and ("foo" === :foo)
- should be false.
+Fri Feb 9 20:43:01 2007 Akinori MUSHA <knu@iDaemons.org>
- * ChangeLog: fix last messages.
+ * 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.
-Thu Feb 8 22:24:06 2007 Koichi Sasada <ko1@atdot.net>
+Fri Feb 9 15:46:09 2007 Akinori MUSHA <knu@iDaemons.org>
- * test/ruby/test_module.rb: fix to use Symbol instead of String.
-
- * test/ruby/test_module.rb: remove space before argument parentheses.
-
-Thu Feb 8 22:02:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/marshaltestlib.rb: eval(sym) -> eval(sym.to_s)
-
-Thu Feb 8 21:35:16 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * test/win32ole/test_propertyputref.rb (setup): fix typo.
-
- * test/win32ole/test_win32ole_event.rb: should not use
- InternetExplorer.gohome to test.
-
-Thu Feb 8 21:02:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (GVL_UNLOCK_RANGE): rename to BLOCKING_REGION().
-
- * thread.c (rb_thread_run_parallel): rename to
- rb_thread_blocking_region().
-
-Thu Feb 8 15:48:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, thread.c: fix to use pthread on cygwin.
-
- * yarvcore.h, thread.c: move GVL_UNLOCK_BEGIN() and GVL_UNLOCK_END()
- from yarvcore.h to thread.c.
-
- * thread.c: change GVL_UNLOCK_RANGE() arguments
- (adding ubf as 2nd argument).
-
- * thread.c: fix to use polling in select on cygwin and mswin32.
-
- * thread.c, thread_pthread.ci, thread_win32.ci, yarvcore.h:
- rename:
- * rb_thread_t#interrupt_function -> unblock_function
- * rb_interrupt_function_t -> rb_unblock_function
- * some interrupt function name -> ubf_*
- * yarv_* -> *
-
-Thu Feb 8 16:08:02 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: fix to use RUNRUBY instead of BASERUBY if possible.
-
- * common.mk ($(INSNS) rule): remove $(PROGRAM) first.
-
-Thu Feb 8 15:43:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * process.c: fix to use rb_status_line_set/get/clear().
-
- * eval_intern.h: fix line break.
-
-Thu Feb 8 15:00:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
- eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
- thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
- vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
- fix typo (rb_thead_t -> rb_thread_t).
-
- * eval_intern.h: remove unused definitions.
-
- * common.mk: fix around vm_opts.h path
- and remove harmful argument passed to insns2vm.rb.
-
-Thu Feb 8 03:11:47 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * 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]
-
-Wed Feb 7 23:25:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (specific_eval): suppress warning.
-
- * thread_win32.h: undefine _WIN32 on cygwin. [ruby-dev:30303]
-
-Wed Feb 7 22:41:34 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_intern.h: remove UNSUPPORTED() macro.
-
- * thread.c: fix to define Continuation methods
- (they only do rb_notimplement()).
-
-Wed Feb 7 22:33:58 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_intern.h, yarvcore.h: remove unused macro definition.
-
-Wed Feb 7 22:30:28 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval.c: fixed to use ANSI function style.
-
-Wed Feb 7 09:35:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * this commit is a result of refactoring. only renaming functions,
- moving definitions place, add/remove prototypes, deleting
- unused variables and removing yarv.h.
- This commit doesn't change any behavior of ruby/vm.
-
- * yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
-
- * error.c, eval_intern.h: include yarvcore.h instead yarv.h
-
- * rename some functions:
- * debug.[ch]: debug_*() -> ruby_debug_*()
- * iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
- * iseq.c: node_name() -> ruby_node_name()
- * vm.c: yarv_check_redefinition_opt_method() ->
- rb_vm_check_redefinition_opt_method()
-
- * some refactoring with checking -Wall.
-
- * array.c: remove rb_ary_ptr() (unused) and remove unused
- local variables.
-
- * object.c: add a prototype of rb_mod_module_exec().
-
- * eval_intern.h (ruby_cref): set it inline.
-
- * eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
-
- * parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
-
- * process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
-
- * thread.c: remove raw_gets() function (unused) and fix some format
- mismatch (format mismatchs have remained yet. this is todo).
-
- * thread.c (rb_thread_wait_fd_rw): fix typo on label name.
-
- * thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
-
- * vm.c (rb_svar, rb_backref_get, rb_backref_get,
- rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
-
- * vm.c (yarv_init_redefined_flag): add a prototype and rename
- yarv_opt_method_table to vm_opt_method_table.
-
- * vm.c (rb_thread_eval): moved from yarvcore.c.
-
- * yarvcore.c: remove unused global variables and fix to use nsdr().
-
-Wed Feb 7 03:39:32 2007 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, compile.c, compile.h, error.c, eval.c,
- eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
- eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
- process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
- vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
- yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
- * yarv_*_t -> rb_*_t
- * yarv_*_struct -> rb_*_struct
- * yarv_tag -> rb_vm_tag
- * YARV_* -> RUBY_VM_*
-
- * proc.c, vm.c: move functions about env object creation
- from proc.c to vm.c.
-
- * proc.c, yarvcore.c: fix rb_cVM initialization place.
-
- * inits.c: change Init_ISeq() order (after Init_VM).
-
- * ruby.h, proc.c: change declaration place of rb_cEnv
- from proc.c to ruby.c.
+ * 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>
@@ -11363,320 +4814,30 @@ Tue Feb 06 22:06:45 2007 NARUSE, Yui <naruse@ruby-lang.org>
* Support beyond BMP
[ruby-dev:29700] [ruby-dev:29922] [ruby-dev:30144]
-Tue Feb 6 20:36:19 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, lib/rss/parser.rb: followed current Ruby
- specification. [ruby-dev:30274]
-
-Tue Feb 6 20:29:44 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb, lib/rss/parser.rb: removed needless code for
- backward compatibility.
-
-Tue Feb 6 18:43:17 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/ftp.rb: moved fixes for EPIPE to the correct
- place. [ruby-core:10204]
-
-Tue Feb 6 16:38:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm_opts.h: set properties:
- svn:keywords: Author Date Id Revision
- svn:eol-style: native
-
-Tue Feb 6 15:55:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (ivar_i): need to support class local instance
- variables.
-
-Tue Feb 6 15:44:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each): fix setting is_local flag.
-
- * yarvtest/test_class.rb: add a test for class local isntance variable.
-
-Tue Feb 6 14:15:34 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def: remove (get|set)instancevariable2 and add a
- operand is_local to (get|set)instancevariable.
-
- * yarvtest/test_class.rb: add a test for class local instance variable.
-
- * parse.y (rb_decompose_ivar2): remove unused variable oid.
-
- * tool/insns2vm.rb: remove needless require.
-
-Tue Feb 6 11:18:41 2007 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/ftp.rb: check the control connection on EPIPE.
- Thanks, Simon Williams. [ruby-core:9547]
-
-Tue Feb 6 11:03:27 2007 Koichi Sasada <ko1@atdot.net>
-
- * complement last commit.
-
- * common.mk (*.inc): use VPATH.
-
- * vm_opts.h: renamed from vm_opts.h.base.
-
-Tue Feb 6 10:02:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * tool/insns2vm.rb: use vm_opts.h in VPATH.
-
-Tue Feb 6 03:47:58 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c: support Binding#eval.
-
- * yarvtest/test_eval.rb: add a test for above change.
-
-Tue Feb 6 03:13:33 2007 Koichi Sasada <ko1@atdot.net>
-
- * proc.c: refactoring (remove K&R style, move Binding stuffs from
- Init_Proc() to Init_Binding()).
-
-Tue Feb 6 01:07:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * intern.h: prepare rb_last_status_get() and rb_last_status_set().
- Use these functions instead of rb_last_status ([ruby-dev:30264]).
-
- * process.c: define above functions.
-
- * ext/pty/pty.c: use above functins.
-
- * io.c (pipe_finalize): ditto.
-
- * process.c: ditto.
-
-Mon Feb 5 21:26:56 2007 Koichi Sasada <ko1@atdot.net>
-
- * ruby.h: add a prototype of rb_id2str().
-
-Mon Feb 5 21:06:50 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_thread.c, common.mk: remove eval_thread.c.
-
- * yarvcore.c: rename cYarvThread to rb_cThread.
-
- * gc.c: remove YARV_* prefix.
-
- * gc.h: add an include guard and prototype of rb_gc_set_stack_end().
-
- * inits.c: fix to ANSI prototype style and reorder Init_*().
-
- * io.c (pipe_finalize): TODO: comment out last_status.
-
- * process.c, yarvcore.h: fix to use yarv_vm_t#last_status instead of
- rb_last_status and make last_status_get() to access $?.
-
- * yarvcore.c (vm_mark): mark yarv_vm_t#last_status.
-
- * ruby.h: add declarations of rb_cISeq and rb_cVM.
-
- * thread.c: move eval_thread.c codes to thread.c and remove yarv_*
- function prefix.
-
- * thread.c (thread_start_func_2): use yarv_thread_t#first_func if
- it is not null.
-
- * vm.c: fix copyright year.
-
- * yarvcore.c (Init_vm): rename to Init_VM().
-
-Mon Feb 5 04:09:48 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_frame_callee): check if prev_cfp can be accessible.
- a patch from Yoshinori Sano <yoshinori.sano at gmail.com> in
- [ruby-dev:30252]. solves [ruby-dev:30200] and [ruby-core:9856].
-
-Sun Feb 4 20:34:41 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/rss-assertions.rb: removed needless code for backward
- compatibility.
-
-Sun Feb 4 02:22:59 2007 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): Remove a debug
- print.
-
-Sat Feb 3 23:51:58 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (rb_compose_ivar2): function to create a new ivar2
- symbol from a symbol and a class. back-ported from matzruby.
-
- * parse.y (rb_decompose_ivar2): reverse function of
- rb_compose_ivar2().
-
- * marshal.c (w_symbol): support class local instance variables.
-
- * marshal.c (r_object0): ditto.
-
- * compile.c (defined_expr): ditto.
-
- * compile.c (iseq_compile_each): ditto.
-
- * insns.def: add two new instructions: getinstancevariable2 and
- setinstancevariable2.
-
-Sat Feb 3 23:21:13 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * insns.def (setclassvariable): remove unnecessary operand.
-
- * compile.c (iseq_compile_each): ditto.
-
- * common.mk (insns_info.inc): add dependency for insns_info.inc.
-
-Sat Feb 3 14:32:58 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_val2olevariantdata, ole_val2variant):
- fix the bug of WIN32OLE_VARIANT.new when variant type is
- VT_ARRAY.
-
- * ext/win32ole/sample/excel1.rb: rewrite using WIN32OLE_VARIANT.
-
- * test/win32ole/test_win32ole.rb: add some test.
-
- * test/win32ole/test_win32ole_variant.rb: ditto.
-
-Sat Feb 3 03:35:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, */Makefile.sub, common.mk (vmasm): generalized.
-
- * common.mk (runruby, benchmark, benchmark-each, tbench): use
- PROGRAM for the file to be built.
-
- * proc.c (yarv_proc_alloc): needs return.
-
- * call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
- eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
- insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
- range.c, ruby.h, signal.c, thread.c, thread_win32.ci, vm.c,
- vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
- fixed indents and non-C90 comments.
-
- * regenc.h: revert to before YARV.
-
- * lib/mkmf.rb (create_makefile): make object files depend on
- extconf.h even if depend file exists.
-
-Fri Feb 2 23:39:42 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * common.mk (bin): add more dependency. a patch from Tadashi
- Saito <shiba at mail2.accsnet.ne.jp>. [ruby-dev:30245]
-
-Fri Feb 2 18:44:31 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * insns.def (setclassvariable): remove warn argument.
-
-Fri Feb 2 18:36:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * common.mk (compile.$(OBJEXT)): add config.h to vm.c and
- compile.c.
-
-Fri Feb 2 18:27:54 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c: remove duplicated global variables rb_cProc and
- rb_cBinding. [ruby-dev:30242]
-
-Fri Feb 2 00:13:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h (SYMBOL_P): make Symbol immediate again for performance.
-
- * string.c: redesign symbol methods.
-
-Thu Feb 1 23:25:21 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_id2str): store Strings for operator symbols.
- [ruby-dev:30235]
-
-Thu Feb 1 21:04:39 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (assignable_gen): no need to generate NODE_CVDECL.
-
- * compile.c (iseq_compile_each): no NODE_CVDECL.
-
-Thu Feb 1 20:53:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * vm.c (eval_get_cvar_base): destination for class variable access
- is now strictly innermost surrounding class or module. warned
- if accessed from toplevel.
-
- * variable.c (rb_cvar_get): new class variable look-up scheme:
- 1) look up in the class. 2) if the class is singleton attached
- to a class (i.e. metaclass) then start look up in the attached
- class and its ancestors. 3) otherwise, look-up in ancestors of
- the class.
-
- * eval.c (cvar_cbase): destination for class variable access is
- the class/module that holds the method, or cbase outside of
- methods.
-
-Thu Feb 1 20:31:41 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_cvar_set): remove warn argument.
-
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 17:01:21 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jan 30 14:58:51 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 13:24:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (int_pred): add Integer#pred corresponding
- Integer#succ. [RCR#5]
-
Tue Jan 30 12:05:35 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
-Mon Jan 29 23:52:32 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * tool/compile.rb: replace YARVCore by VM class.
-
-Mon Jan 29 17:52:44 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/date/format.rb (Date::Format::Bag::method_missing): add
- prefix to avoid making t class-local instance variable.
+Sat Jan 27 15:20:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Jan 29 21:32:37 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * parse.y (dyna_var_lookup): should not alter dvar->val not to
+ destroy living value. [ruby-core:10076]
- * ext/win32ole/win32ole.c: add WIN32OLE.locale=, WIN32OLE.locale,
- WIN32OLE_VARIANT#vartype.
-
- * test/win32ole/test_win32ole.rb: add test for WIN32OLE.locale=,
- WIN32OLE.locale.
-
- * test/win32ole/test_win32ole_variant.rb: add test for
- WIN32OLE_VARIANT#vartype.
-
-Mon Jan 29 14:14:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * tool/parse.rb: replace YARVCore by VM class.
- http://d.hatena.ne.jp/ysano2005/20070128
-
-Sun Jan 28 08:41:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: refactoring.
-
-Sat Jan 27 18:36:33 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_val2olevariantdata): bug fix.
- WIN32OLE_VARIANT.new check that 1st argument should T_ARRAY
- when variant type is VT_ARRAY.
-
- * test/win32ole/test_win32ole_variant.rb: add some test.
-
-Fri Jan 26 23:55:56 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: bug fix of WIN32OLE_VARIANT when variant
- type is VT_BYREF|VT_VARIANT.
-
- * test/win32ole/test_win32ole_variant_with_ie.rb: ditto.
+ * parse.y (dyna_init): ditto.
Fri Jan 26 12:03:39 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -11693,196 +4854,63 @@ Fri Jan 26 12:03:39 2007 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/scrollable.rb: change primary name of modules
[ruby-dev:30080].
-Fri Jan 26 07:48:57 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_init_copy): need to copy internal
- structure on clone and dup. [ruby-dev:30192]
-
-Wed Jan 24 20:34:51 2007 Kouhei Sutou <kou@cozmixng.org>
-
- * test/ruby/test_iterator.rb: removed a needless workaround.
-
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]
-Tue Jan 23 15:39:25 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jan 23 10:48:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
- * Makefile.in, common.mk, configure.in, */{Makefile.sub, configure.bat,
- setup.mak}: add --with-baseruby configure option.
+ * 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 20 21:05:18 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (fole_s_set_code_page): WIN32OLE.codepage=
- accepts installed codepage.
-
- * test/win32ole/test_win32ole.rb (test_s_codepage_changed): ditto.
-
-Sat Jan 20 11:18:49 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_invoke, ole_invoke2, ole_propertyput):
- modify WIN32OLERuntimeError message.
-
- * test/win32ole/test_win32ole.rb: ditto.
-
-Sat Jan 20 06:45:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval_proc.c (method_receiver): add new method to get the bound
- receiver of the method object. [ruby-talk:234949]
-
- * eval_proc.c (method_name): new method to get the name of a
- method.
-
- * eval_proc.c (method_owner): a new method to get the class or
- module that defines the method.
-
-Fri Jan 19 17:12:23 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (Init_win32ole): add WIN32OLE_VARIANT::Empty,
- WIN32OLE_VARIANT::Null, WIN32OLE_VARIANT::Nothing.
-
- * test/win32ole/test_win32ole_variant.rb: ditto.
-
- * test/win32ole/test_nil2vtempty.rb(test_openSchema): ditto.
-
-Fri Jan 19 06:53:38 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (olevariant_free): fix memory leak.
-
- * ext/win32ole/win32ole.c (ole_val2olevariantdata):
- WIN32OLE_VARIANT.new accepts nil as first argument for some VARIANT
- TYPE.
-
- * test/win32ole/test_win32ole_variant.rb: ditto.
+Sat Jan 13 23:54:48 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net>
-
- * some refactoring around yarvcore and proc.
-
- * eval_proc.c: renamed to proc.c.
-
- * common.mk: ditto.
-
- * yarvcore.h, yarvcore.c: rename or remove some global variables
- removed: mYarvCore, mYarvInsns
- renamed: cYarvISeq -> rb_cISeq,
- cYarvProc -> rb_cProc, cYarvBinding -> rb_cBinding
- ::YarvCore module is removed and ::YarvCore::VM class becomes ::VM.
- And change/remove some functions which added with YARV.
-
- * compile.c: ditto.
-
- * eval.c: ditto.
-
- * iseq.c: ditto.
-
- * vm.c: ditto.
-
- * inits.c: rename Init_yarvcore to Init_vm.
-
- * yarvcore.c, proc.c: move some functions and initialization
- from yarvcore.c to proc.c.
-
- * intern.h, proc.c: add global function rb_binding_new(void).
-
-Tue Jan 16 17:49:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (eval_search_super_klass): rename to search_super_klass() and
- use it by th_call_super().
-
- * insns.def: ditto.
-
-Tue Jan 16 17:48:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: fix ruby script path.
-
-Tue Jan 16 17:39:44 2007 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (invoke_block): fix to specify self.
-
-Tue Jan 16 12:12:27 2007 Koichi Sasada <ko1@atdot.net>
-
- * env.h: removed
-
-Tue Jan 16 12:00:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_proc.c (rb_proc_new): added.
+ * ext/win32ole/win32ole.c (ole_free, ole_type_free,
+ olemethod_free, olevariable_free, oleparam_free,
+ ole_event_free): fix memory leak. [ruby-core:09846]
- * string.c (sym_to_proc): supported.
+Fri Jan 12 11:13:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * vm.c (invoke_block, th_invoke_yield, th_invoke_proc): fix to support
- rb_proc_new.
+ * ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly
+ convert uid/gid from VALUE. (backport of r11521)
- * yarvcore.c: add a test code.
+Wed Jan 10 18:57:57 2007 Minero Aoki <aamine@loveruby.net>
-Sat Jan 13 23:24:59 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * ext/strscan/strscan.c (strscan_do_scan): should set kcode option
+ before match. [ruby-dev:29914]
- * ext/win32ole/win32ole.c (ole_free, ole_type_free,
- olemethod_free, olevariable_free, oleparam_free,
- ole_event_free): fix memory leak. [ruby-core:09846]
+ * test/strscan/test_stringscanner.rb: test it.
-Wed Jan 10 00:10:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * re.c: export kcode_set_option and kcode_reset_option (with "rb_"
+ prefix).
- * array.c (rb_ary_replace): use ptr and len of orig instead of
- shared. fixed: [ruby-dev:30116]
+ * intern.h: ditto.
-Tue Jan 9 17:48:38 2007 NAKAMURA Usaku <usa@ruby-lang.org>
+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 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.
-
- * ext/etc/etc.c (etc_getpwuid): ditto.
-
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]
- * string.c (rb_str_upto): use RSTRING_LEN().
-
-Sun Jan 7 18:36:05 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread.c (rb_thread_stop_timer_thread(), rb_thread_reset_timer_thread(),
- rb_thread_start_timer_thread()): added.
-
- * thread_pthread.ci: add a native_thread_join() and move
- rb_thread_reset_timer_thread() definition to thread.c.
-
- * thread_win32.ci: ditto
-
- * process.c: fix before_exec(), after_exec() to stop timer thread
- (and restart timer thread if exec failed). and fix to reset
- timer thread information when forked child process starts
- (to fix [ruby-core:09822]).
-
-Sun Jan 7 18:28:17 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: add a "compare" rule and fix MATZRUBY variable
-
-Sun Jan 7 17:47:16 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * test/win32ole/test_win32ole.rb: add test for WIN32OLE#[],
- WIN32OLE#[]=.
-
- * ext/win32ole/win32ole.c: update comment for rdoc of
- WIN32OLE#[] and WIN32OLE#[]=.
-
Sun Jan 7 12:13:26 2007 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment):
@@ -11896,217 +4924,14 @@ Sun Jan 7 10:32:12 2007 Eric Hodel <drbrain@segment7.net>
* test/rdoc/parsers/test_parse_c.rb:
Test RDoc::C_Parser#do_classes and Rdoc::C_Parser#find_class_comment.
-Sun Jan 7 09:31:18 2007 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Jan 7 09:33:02 2007 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/format.rb: updated based on date2 4.0.1.
-Sat Jan 6 18:46:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_getline_fast, rb_io_getline): increase lineno
- when met the delimiter or EOF. fixed: [ruby-dev:30081]
-
- * io.c (prepare_getline_args, rb_io_getline_1): split
- preparation of arguments and reading. [ruby-dev:30085]
-
-Sat Jan 6 13:48:36 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (send): fix to optimize send() with Symbol.
-
- * yarvtest/test_method.rb: add another test.
-
-Sat Jan 6 13:43:55 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: add PHONY dependency to some rules
-
-Sat Jan 6 11:50:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (argf_read): fix wrong replacement. [ruby-dev:30070]
-
-Sat Jan 6 09:10:52 2007 Koichi Sasada <ko1@atdot.net>
-
- * insns.def: support direct method dispatch with "send" or "funcall".
- This means that "obj.send :m" skips "BasicObject#send" invocation
- (method frame creation, etc) and "obj.m" invokes directly.
- If you make backtrace, there are no enties of "send" method.
-
- * compile.c (iseq_specialized_instruction): fix to support above
-
- * eval.c: ditto (remove "static" from rb_f_send and rb_f_funcall
-
- * yarvcore.c: ditto (add a external IDs for compiler)
-
- * yarvcore.h: ditto (add a VM_CALL_SEND_BIT macro)
-
- * yarvtest/test_method.rb: add tests for above changes
-
- * eval.c: remove unused "Kernel#send" declaration
-
-Sat Jan 6 08:29:17 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (Init_win32ole): add
- WIN32OLE::VARIANT::VT_EMPTY, WIN32OLE::VARIANT::VT_NULL
-
- * test/win32ole/test_win32ole_variant_m.rb (test_variant): ditto.
-
-Sat Jan 6 03:49:22 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb: change option format
-
- * common.mk: ditto
-
-Fri Jan 5 22:21:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_app_pentomino.rb: use Array#dup instead of
- Array#clone
-
- * benchmark/bmx_temp.rb: removed
-
- * benchmark/run.rb: use run.rb instead of run_rite.rb
-
- * common.mk: ditto
-
- * benchmark/run_rite.rb: removed
-
- * common.mk: use $(srcdir)/test.rb to run a test program
- with "make run"
-
- * benchmark/bmx_temp.rb: removed and
- set svn:ignore (bmx_*.rb) to benchmark/
-
- * test.rb: set svn:ignore
-
-Fri Jan 5 21:03:08 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarvtest/yarvtest.rb: fix to compare results
-
-Fri Jan 5 20:52:56 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, compile.h: add ADD_CALL_RECEIVER() macro.
-
- * insns.def (send): use GET_SELF() direct if FCALL.
-
- * eval.c (rb_f_send): check method dispatch type to permit
- invoking private method when dispatch type is FCALL/VCALL
-
- * insns.def (opt_ltlt): remove useless statement.
-
- * vm.h: remove unused macros.
-
-Fri Jan 5 20:50:31 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run_rite.rb: fix to use readlines instead of
- read(...).lines (because 1.8 doesn't have String#lines).
-
-Fri Jan 5 20:28:19 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread_win32.ci (rb_thread_reset_timer_thread):
- added ([ruby-dev:30086]).
-
-Fri Jan 5 20:20:36 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: add .SUFFIXES rule
-
-Fri Jan 5 15:58:15 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h (rb_alias): fix to check search result
-
-Fri Jan 5 13:59:53 2007 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h (rb_add_method): fix to check old_node
-
-Fri Jan 5 12:03:07 2007 Koichi Sasada <ko1@atdot.net>
-
- * compile.c (iseq_compile_each, set_block_local_tbl):
- support NODE_LAMBDA (partly).
-
- * sample/test.rb: restore test of NODE_LAMBDA
-
- * test/ruby/test_lambda.rb: ditto
-
-Fri Jan 5 12:31:23 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * thread_pthread.ci (native_sleep): fix tv_nsec overflow.
-
-Thu Jan 4 20:01:29 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: rename yarv-test-[all/each] to compare-test[/-each].
- purpose of "compare-test" rule is to compare ruby (trunk) and
- matzruby (branches/matzruby) binary in miniruby level. MATZRUBY
- parameter means an path to miniruby of matzruby binary. to do this
- comparison test, you should build matzruby branch.
-
- * yarvtest/yarvtest.rb: fix to use command line option as
- command names to be compared.
-
- * yarvtest/runner.rb: remove a debug output.
-
-Thu Jan 4 19:12:27 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: fix to use test.rb script in build directory.
- ($(srcdir)/test.rb -> test.rb)
-
-Thu Jan 4 17:28:05 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler#initialize):
- Arrays could not be modified in its each block. [ruby-dev:30063]
-
-Thu Jan 4 16:57:14 2007 Koichi Sasada <ko1@atdot.net>
-
- * yarv_version.h: removed.
-
- * common.mk: remove yarv_version.h from rules
-
- * yarvcore.h (Init_yarvcore): remove useless constants
-
-Thu Jan 4 17:00:06 2007 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_asn1.c (Init_ossl_asn1):
- OpenSSL::ASN1::ASN1Data#value,#tag,#tag_class and
- OpenSSL::ASN1::BitString#unused_bits should be public.
-
-Thu Jan 04 13:45:10 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.ci: fix last changes around PTHREAD_STACK_MIN.
-
-Thu Jan 04 13:42:47 2007 Koichi Sasada <ko1@atdot.net>
-
- * common.mk: restore changes.
-
-Thu Jan 04 10:33:54 2007 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.ci: fix to skip using PTHREAD_STACK_MIN.
- [ruby-dev:30063]
-
-Thu Jan 04 10:30:11 2007 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run_rite.rb (bm): fix to use lines.
-
-Wed Jan 3 18:49:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_getline): lineno update condition was wrong.
- [ruby-dev:30065]
-
- * io.c (rb_io_getline_fast): ditto.
-
Wed Jan 3 11:36:51 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (ruby_dup): start GC on ENOMEM as well.
-Tue Jan 2 10:29:54 2007 Eric Hodel <drbrain@segment7.net>
-
- * ext/zlib/zlib.c: fix to compile on YARV
- ruby_errinfo -> rb_errinfo()
-
-Mon Jan 01 08:07:06 2007 Koichi Sasada <ko1@atdot.net>
-
- * ext/tk/tcltklib.c: fix to compile on YARV
- ruby_errinfo -> rb_errinfo(),
- ruby_safe_level -> rb_safe_level().
-
-Mon Jan 01 07:57:17 2007 Koichi Sasada <ko1@atdot.net>
-
- * test/drb/test_drbssl.rb: fix to skip drb tests.
-
Mon Jan 1 06:13:11 2007 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/parsers/c_parser.rb: Make Rdoc accessible. Update constant
@@ -12125,103 +4950,10 @@ Mon Jan 1 06:05:55 2007 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#handle_constansts): Fix
whitespace handling in constant comments.
-Mon Jan 01 00:00:00 2007 Koichi Sasada <ko1@atdot.net>
-
- * Merge YARV
-
-Sun Dec 31 16:22:48 2006 Eric Hodel <drbrain@segment7.net>
-
- * array.c: Fix Array#reject.
-
-Sun Dec 31 00:46:25 2006 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date2.rb: removed.
-
-Sun Dec 31 00:15:13 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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.
-Sat Dec 30 04:38:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_each_with_index): reuse array for yield parameters.
-
- * enum.c (enum_min, enum_max): ditto.
-
-Sat Dec 30 04:25:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_inject): reuse array for yield parameters.
-
-Sat Dec 30 02:54:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_gets): accepts limit argument.
-
- * ext/stringio/stringio.c (strio_readline, strio_each,
- strio_readlines): ditto.
-
-Sat Dec 30 02:22:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_getline): add limit capability.
-
- * io.c (rb_io_gets_m): accepts limit argument. [ruby-talk:231563]
-
- * io.c (rb_io_readline, rb_io_readlines, rb_io_each_line, argf_getline):
- ditto.
-
- * io.c (appendline): add limit capability.
-
- * io.c (rb_io_getline_fast, rb_io_getline): ditto.
-
- * io.c (rb_io_getline): small refactoring for DRY.
-
- * io.c (rb_io_s_foreach, rb_io_s_readlines): small refactoring.
-
-Thu Dec 28 15:27:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::Cookie::initialize): use Array() again.
- [ruby-core:09781]
-
-Wed Dec 27 20:52:32 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: remove WIN32OLE::PROPERTY class.
-
- * ext/win32ole/tests/testWIN32OLE.rb: ditto.
-
-Wed Dec 27 10:04:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_Array): returns 1-element array if the argument
- does not have to_ary nor to_a.
-
-Tue Dec 26 21:02:14 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * test/win32ole/test_folderitem2_invokeverb.rb: The argument
- of Shell.NameSpace should not be file path.
-
-Tue Dec 26 06:13:08 2006 Minero Aoki <aamine@loveruby.net>
-
- * ext/bigdecimal/bigdecimal.c: remove useless method
- BigDecimal#!=. [ruby-dev:30050]
-
-Thu Dec 21 15:37:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_slice_bang): rdoc description bug fixed.
- [ruby-core:09754]
-
-Wed Dec 20 12:54:31 2006 Koichi Sasada <ko1@atdot.net>
-
- * Convert CVS repository to Subversion repository.
-
-Mon Dec 18 08:36:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::Cookie::initialize): Array(string) no longer
- works. [ruby-core:09738]
-
-Fri Dec 15 00:19:53 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/Makefile.sub (COMPILE_RULES): latter rule has higher priority.
-
- * lib/mkmf.rb (create_makefile): remove static library before update,
- to get rid of sludge of Borland tlib.exe.
-
Thu Dec 14 18:29:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/readline/readline.c: NetBSD editline does not have
@@ -12234,11 +4966,7 @@ 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]
-Tue Dec 12 23:33:53 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (Switch#parse_arg, Switch#conv_arg): splat failures.
-
-Mon Dec 11 11:51:10 2006 Akinori MUSHA <knu@iDaemons.org>
+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/.
@@ -12263,128 +4991,79 @@ Sat Dec 9 11:22:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
instead of File.exists?. a patch from Yutaka Kanemoto
<kinpoco at gmail.com> in [ruby-dev:30000].
-Fri Dec 8 18:11:18 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/optparse.rb: cannot put :nodoc: before method definition.
- put after it.
-
-Fri Dec 8 17:00:13 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * bin/rdoc: ues File.exist? instead of File.exists?.
-
-Thu Dec 7 23:50:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (Init_Object): new method Dir.exist?(path).
- [ruby-core:09663]
-
- * file.c (Init_File): remove File.exists?; use File.exist?
- instead.
-
- * file.c: rename functions to test_* to rb_file_*_p.
-
Thu Dec 7 09:29:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/weakref.rb (WeakRef::__setobj__): should support
marshaling. [ruby-talk:228508]
-Wed Dec 6 23:58:36 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/delegate.rb (Delegator::marshal_load): need to call
+ __setobj__.
+
+Wed Dec 6 23:56:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, common.mk (NULLCMD): moved for platforms that empty
command does not run. fixed: [ruby-dev:29994]
- * win32/win32.c (init_stdhandle): redirect unopened IOs to NUL.
- [ruby-core:09572]
-
-Tue Dec 5 19:01:42 2006 WATANABE Hirofumi <eban@ruby-lang.org>
+Wed Dec 6 17:17:26 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 18:38:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/matrix.rb (Matrix::rank): use quo method to avoid integer
- division problem. [ruby-core:09644]
-
- * lib/matrix.rb (Matrix::rank_e): ditto.
-
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]
-Tue Dec 5 00:19:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h, object.c, variable.c (rb_mod_constants): added an optional
- flag to search ancestors, which is defaulted to true, as well as
- const_defined? and const_get. [ruby-dev:29989]
-
-Mon Dec 4 23:49:28 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (install_recursive): get rid of warning.
-
- * lib/optparse.rb (CompletingHash#match): get rid of splat failure.
-
-Mon Dec 4 19:16:39 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest/hmac.rb: Do alias << update.
-
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 08:32:25 2006 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/cgi.rb (CGI::QueryExtension::read_multipart): should quote
- boundary. JVN#84798830
+Mon Dec 4 10:43:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sun Dec 3 16:16:53 2006 Akinori MUSHA <knu@iDaemons.org>
+ * parse.y (dyna_init_gen): dvar initialization only if dvar is
+ assigned inner block. [ruby-talk:227402]
- * ext/digest/lib/digest/hmac.rb: Fix problems with update
- timing. [Reported by: oss-ruby@technorama.net]
+Mon Dec 4 08:32:49 2006 Shugo Maeda <shugo@ruby-lang.org>
-Sat Dec 2 07:33:53 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils::FormData::<<):
- HTTPUtils::parse_header() takes a string. [ruby-dev:29931]
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils::parse_header):
- String does no longer have each method.
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils::parse_form_data):
- ditto.
+ * 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]
-Tue Nov 28 17:25:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Nov 27 17:18:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * array.c (ary_iter_check): should check modification (size
- change) during iteration.
-
- * array.c (rb_ary_initialize, rb_ary_shift, rb_ary_unshift,
- rb_ary_splice, rb_ary_reverse, rb_ary_sort, rb_ary_delete,
- rb_ary_delete_at, rb_ary_reject_bang, rb_ary_replace,
- rb_ary_clear, rb_ary_fill, rb_ary_uniq_bang, rb_ary_compact,
- rb_ary_shuffle): add iteration check.
-
-Mon Nov 27 09:00:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_ord): typo fixed. reported from Kornelius
- Kalnbach <murphy@rubychan.de>. [ruby-core:09621]
+ * sprintf.c (rb_f_sprintf): need not to truncate string if no
+ width specifier given for %s. [ruby-dev:29952]
Sun Nov 26 16:36:46 2006 URABE Shyouhei <shyouhei@ruby-lang.org>
* version.h: addition of RUBY_PATCHLEVEL.
* version.c: ditto.
+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.
@@ -12395,57 +5074,28 @@ Wed Nov 22 16:00:49 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tkutil/extconf.rb: able to be called manually
[ruby-talk:225950].
-Sat Nov 18 23:39:20 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_obj_tap): a new method. [ruby-talk:224013]
-
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]
-Tue Nov 7 18:35:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (formal_assign): need to pack rest arg information in
- argc.
-
-Tue Nov 7 18:05:01 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/itemconfig.rb: minor bug fix.
-
-Tue Nov 7 17:52:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (rb_include_module): revert duplicate inclusion of
- modules. [ruby-dev:29793]
-
-Tue Nov 7 17:18:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (method_missing): update old argument adjustment.
-
-Tue Nov 7 16:41:21 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (when_check): need to splat for NODE_ARGSCAT as well.
- [ruby-dev:29860]
-
-Mon Nov 6 22:23:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (Init_String): remove duplicated definition of
- Symbol#to_s.
+Thu Nov 9 03:15:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Nov 6 18:54:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (BEGIN_CALLARGS): ruby_block may be NULL even when
+ ITER_PRE.
- * eval.c (svalue_to_avalue): need to splat but no error.
+Tue Nov 7 18:34:34 2006 Akinori MUSHA <knu@iDaemons.org>
- * eval.c: new macros - YIELD_CALL, YIELD_VALUES.
+ * 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.
- * eval.c (rb_yield_values): specify YIELD_VALUES.
+Tue Nov 7 18:05:01 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (rb_yield_0): use new macros.
+ * ext/tk/lib/tk/itemconfig.rb: minor bug fix.
- * eval.c (proc_invoke): slightly modified to separate YIELD_CALL
- and YIELD_VALUES from YIELD_ARY_ARGS.
+Mon Nov 6 20:11:20 2006 Kouhei Sutou <kou@cozmixng.org>
- * object.c (Init_Object): add nil.to_splat => [].
+ * lib/rss/0.9.rb (RSS::Rss): removed needless include.
Mon Nov 6 15:41:55 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -12453,9 +5103,9 @@ Mon Nov 6 15:41:55 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
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/tile/treeview.rb : support Tile 0.7.8.
- * ext/tk/lib/tkextlib/version.rb: [new] add Tk::Tkextlib_RELEASE_DATE
+ * 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
@@ -12472,17 +5122,14 @@ Mon Nov 6 15:41:55 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
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.
-Mon Nov 6 00:42:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (arg_dup_check): vid may be nameless internal id.
-
-Sun Nov 5 19:52:19 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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:09:31 2006 Shugo Maeda <shugo@ruby-lang.org>
+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>
@@ -12490,49 +5137,17 @@ Fri Nov 3 00:16:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
for AIX. a patch from Yutaka Kanemoto <kinpoco AT gmail.com>.
[ruby-dev:29744]
-Thu Nov 2 14:19:44 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/set.rb (Set#^): Fix XOR operation against a container that
- holds duplicate values. [ruby-core:9372]
-
-Thu Nov 2 10:00:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c: class Symbol is no longer subclass of String. also
- covers [ruby-core:09366]
-
-Thu Nov 2 08:21:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/xmlrpc/create.rb (XMLRPC::Create::conv2value): Symbol should
- come earlier than String.
-
- * lib/soap/mapping/rubytypeFactory.rb (RubytypeFactory::obj2soap):
- ditto.
-
- * lib/set.rb (TC_Set::test_s_new): strings are no longer
- Enumerable
-
- * lib/soap/property.rb (Property::load): ditto.
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils::parse_header): ditto.
-
- * lib/soap/mimemessage.rb (MIMEMessage::Headers::parse): ditto.
-
-Thu Nov 2 09:08:04 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c: revert lfree shift/unshift boost patch to avoid unknown
- memory error.
+Thu Nov 2 15:43:39 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Nov 1 23:24:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * parse.y (primary): should set NODE even when compstmt is NULL.
+ merge from trunk. fixed: [ruby-dev:29732]
- * ruby.h (struct RArray): revert embedding ptr in RVALUE.
+Thu Nov 2 14:48:30 2006 Akinori MUSHA <knu@iDaemons.org>
- * array.c: ditto.
-
-Wed Nov 1 23:01:55 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (hash): use Bob Jenkins' hash algorithm.
+ * lib/set.rb (Set#^): Fix XOR operation against a container that
+ holds duplicate values. [issue: #6444]
-Wed Nov 1 02:22:31 2006 Akinori MUSHA <knu@iDaemons.org>
+Wed Nov 1 02:41:38 2006 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor
optimization.
@@ -12545,6 +5160,8 @@ 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.
@@ -12553,11 +5170,6 @@ Tue Oct 31 17:03:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/time.rb (Time::make_time, Time::rfc2822, Time::httpdate):
should respect subclasses. [ruby-core:09357]
-Tue Oct 31 16:25:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (ary_shared_first): should address offset after
- ary_shared_array(). [ruby-core:09358]
-
Mon Oct 30 23:40:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in (miniruby): add XLDFLAGS.
@@ -12569,7 +5181,7 @@ Mon Oct 30 23:40:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (cmdglob, rb_w32_cmdvector, rb_w32_opendir,
rb_w32_get_environ): not to use GC before initialization.
-Mon Oct 30 19:28:02 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Oct 30 19:29:20 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* bignum.c (rb_big2str0): use better approximation.
@@ -12582,96 +5194,62 @@ 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]
-Sun Oct 29 19:51:31 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * regexec.c: invalid offset value was used in STATE_CHECK_BUFF_INIT().
-
-Sat Oct 28 20:13:18 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * oniguruma.h: Version 4.4.5
-
- * regint.h: ditto.
-
- * regerror.c: ditto.
-
- * regexec.c: ditto.
-
- * regcomp.c ditto.
-
- * regparse.c ditto.
-
-Sat Oct 28 07:56:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (r_object0): missing break. [ruby-core:09345]
-
-Fri Oct 27 17:30:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enum_each_cons): move RETURN_ENUMERATOR() after
- argument check.
-
-Thu Oct 26 21:05:48 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+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:23:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c: remove by_slice and by_cons.
-
-Thu Oct 26 15:12:12 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Oct 26 15:21:10 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/digest/digest.c (Init_digest): typo.
-Wed Oct 25 17:16:05 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * test/digest/test_digest_hmac.rb: added.
-
-Wed Oct 25 16:34:31 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/test.sh: make this script work again.
-
-Wed Oct 25 07:59:42 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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]
-Wed Oct 25 00:58:19 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/mkexports.rb, win32/resource.rb: use unique variable names.
-
-Tue Oct 24 19:18:53 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_by_slice): new method added.
-
- * enumerator.c (enumerator_by_cons): ditto.
-
-Tue Oct 24 18:56:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enum_each_slice, enum_each_cons): returns
- Enumerable::Enumerator if no block is given. [ruby-dev:29246]
-
- * enumerator.c: remove methods: enum_with_index, enum_slice,
- enum_cons. [ruby-dev:29246]
-
-Tue Oct 24 18:51:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_zip): add RETURN_ENUMERATOR() to zip method.
-
-Mon Oct 23 04:30:04 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (r_object0): use return value from proc given as the
- second argument to Marshal#load() to allow value replacement in
- the restoring data.
-
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.
@@ -12683,54 +5261,11 @@ Sun Oct 22 16:47:56 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_new4): keep shared string untainted when orignal
string is tainted. fixed: [ruby-dev:29672]
-Sun Oct 22 07:55:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_upcase, rb_str_downcase, rb_str_downcase,
- rb_str_upcase_bang, rb_str_downcase_bang, rb_str_swapcase_bang):
- add RDoc description that case conversion to be effective only
- in ASCII region.
-
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]
-Sat Oct 21 17:50:40 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest.rb: Follow the framework updates.
-
-Fri Oct 20 22:00:43 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest/hmac.rb: Complete half-boiled updates.
-
- * ext/digest/sha2/lib/digest/sha2.rb: Fix #initialize_clone().
-
-Fri Oct 20 20:28:37 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest: Prefix C constants with RUBY_ and C type names with
- rb_ to avoid name clash in writing extensions.
-
- * ext/digest: Introduce Digest::Class and Digest::Instance for
- ease of implementing subclasses and add-ons, inspried by
- gotoyuzo.
-
- * ext/digest: The Digest::Instance module now requires and assumes
- that any instance be resettable and clonable, and add some
- convenient instance methods such as "new()", for creating a new
- copy, parameter taking "digest()" and "hexdigest()", for instant
- calculation. These methods make digest instances work just like
- digest classes.
-
- * ext/digest/sha2/lib/digest/sha2.rb:
- 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.
-
- * ext/digest/lib/digest.rb: Adjust autoload entries for SHA2
- classes.
-
- * ext/digest/lib/digest/hmac.rb: Follow the framework updates.
-
Fri Oct 20 10:47:43 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/mkmf.rb: fixed the bug of handling COMMON_MACROS.
@@ -12757,39 +5292,10 @@ Wed Oct 18 23:02:40 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (rb_w32_utime): allow NULL to set the current time.
[ruby-talk:219248]
-Wed Oct 18 13:25:50 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_each_line): String#lines now works when a block
- is given. in other words, lines become an alias to each_line.
- [ruby-core:09218]
-
- * string.c (rb_str_each_byte): ditto for bytes in place of lines.
-
Wed Oct 18 00:55:33 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_yylex): use particular enums. [ruby-core:09221]
-Tue Oct 17 22:03:08 2006 Minero Aoki <aamine@loveruby.net>
-
- * lib/erb.rb: String#each was removed, use #each_line instead.
-
-Tue Oct 17 12:27:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (ary_shared_array): should set NOEMBED flag for a copied
- array.
-
-Tue Oct 17 08:04:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_lines): now takes optional argument for the
- line separator.
-
- * io.c (rb_io_lines, rb_io_bytes): new methods.
-
-Mon Oct 16 23:33:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_unshift_m): a bug in lfree shift length
- calculation.
-
Mon Oct 16 08:30:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* mkconfig.rb: *OBJS are not needed for extension libraries.
@@ -12797,11 +5303,6 @@ Mon Oct 16 08:30:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* {bcc32,wince,win32}/Makefile.sub (config.status): fixed typo,
missing comma.
-Mon Oct 16 00:44:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * pack.c (pack_unpack): execute block if given with unpacked value
- instead of creating an array. an idea from Tim Bray.
-
Sun Oct 15 01:03:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/collector/dir.rb (Collector::Dir#collect): append base
@@ -12821,49 +5322,16 @@ Sat Oct 14 23:25:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
contain format specifiers. a patch from Akinori MUSHA <knu at
iDaemons.org>. [ruby-dev:29657]
- * regparse.c (onig_rb_warning, onig_rb_warn): ditto.
-
* 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:15:42 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c, ext/digest/digest.h,
- ext/digest/md5/md5init.c, ext/digest/rmd160/rmd160init.c,
- ext/digest/sha1/sha1init.c, ext/digest/sha2/sha2init.c:
- Introduce API versioning.
+Sat Oct 14 08:24:45 2006 Akinori MUSHA <knu@iDaemons.org>
- * ext/digest/digest.c, ext/digest/digest.h,
- ext/digest/md5/md5init.c, ext/digest/rmd160/rmd160init.c,
- ext/digest/sha1/sha1init.c, ext/digest/sha2/sha2init.c: Remove
- the constants DIGEST_LENGTH and BLOCK_LENGTH and turn them into
- instance methods digest_length() and block_length(). Class
- methods with the same names are also provided, which take extra
- parameters for a digest method.
-
- * ext/digest/lib/digest/hmac.rb: Completely redesign the somewhat
- bizarre API, now that Digest classes can take hashing
- parameters.
-
-Sat Oct 14 05:54:05 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c: Improve RDoc documentation further more.
-
-Sat Oct 14 04:33:33 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c: Improve RDoc documentation.
-
- * ext/digest/digest.c (Init_digest, rb_digest_base_s_digest,
- rb_digest_base_s_hexdigest): Make Digest::Base::digest() and
- Digest::Base::hexdigest() take extra arguments, which are passed
- through to the constructor in an internal call.
-
- * ext/digest/bubblebabble/bubblebabble.c
- (rb_digest_base_s_bubblebabble): Ditto for
- Digest::Base::bubblebabble().
+ * 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>
@@ -12872,58 +5340,20 @@ Sat Oct 14 00:55:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bcc32/configure.bat: get rid of a quirk of Borland make, which
sets empty macro in command line to "1".
-Fri Oct 13 22:49:02 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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 21:00:01 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest.rb (Digest): Try to auto-load non-standard
- digest modules when a specified digest class is missing.
-
- * ext/digest/lib/digest.rb: Define Digest(name) for ease of
- dynamically selecting a hashing algorithm.
+Fri Oct 13 22:33:28 2006 Minero Aoki <aamine@loveruby.net>
-Fri Oct 13 20:53:37 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (Init_digest): Digest::Base.new() does no
- longer take an initial string to feed. This change allows
- subclasses to take hashing parameters. A statement such as
- ``md = Digest::MD5.new(s)'' can be easily rewritten as
- ``md = Digest::MD5.new << s'' or
- ``md = Digest::MD5.new.update(s)''.
-
-Fri Oct 13 20:51:55 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c, ext/digest/md5/md5init.c,
- ext/digest/rmd160/rmd160init.c, ext/digest/sha1/sha1init.c,
- ext/digest/sha2/sha2init.c: Add RDoc documentation.
-
- * ext/digest/digest.txt, ext/digest/digest.txt.ja: Removed in
- favor of embedded RDoc documentation.
-
-Fri Oct 13 20:38:12 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/bubblebabble, ext/digest/digest.c: Rip BubbleBabble
- support out of the base class and have a separate module named
- digest/bubblebabble.
-
-Fri Oct 13 19:53:59 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (rb_digest_base_equal): Again, should call
- digest() of a subclass instead of the one defined in the base
- class.
+ * 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:42:00 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (rb_digest_base_equal): Should call digest()
- of a subclass instead of the one defined in the base class.
-
Fri Oct 13 02:30:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/collector/dir.rb (Collector::Dir#collect): prepend
@@ -12940,13 +5370,6 @@ 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 01:05:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_partition): RDoc update. a patch from
- Mauricio Fernandez <mfp at acm.org>. [ruby-core:09160]
-
- * hash.c (rb_hash_compare_by_id): ditto.
-
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
@@ -12956,102 +5379,29 @@ Fri Oct 13 00:34:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_mod_cvar_set): ditto.
-Thu Oct 12 22:58:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_compare_by_id): somehow we lost renaming from
- Hash#identical. [ruby-core:09163]
-
-Thu Oct 12 18:25:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): need to handle new
- character literal (1 char string).
-
- * lib/mkmf.rb: shut up some warnings from tk's extconf.rb.
-
-Thu Oct 12 02:15:24 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest/hmac.rb: Make use of String#bytes.
-
-Thu Oct 12 02:12:31 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (get_digest_base_metadata): Use an instance
- variable of a class object instead of a class variable for
- metadata. This change is only crucial for ruby 1.8 because
- class variables are inherited to subclasses prior to 1.9, but
- applying it also to 1.9 will assure compatibilities.
-
- * ext/digest/md5/md5init.c (Init_md5): Ditto.
-
- * ext/digest/rmd160/rmd160init.c (Init_rmd160): Ditto.
-
- * ext/digest/sha1/sha1init.c (Init_sha1): Ditto.
-
- * ext/digest/sha2/sha2init.c (Init_sha2): Ditto.
-
-Wed Oct 11 21:36:47 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (rb_digest_base_alloc,
- rb_digest_base_equal): Simplify the equality check and just
- compare resulted digests since state-level equality should
- not be so significant.
+Wed Oct 11 22:21:41 2006 Akinori MUSHA <knu@iDaemons.org>
- * ext/digest/digest.h: Ditto.
+ * 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.
- * ext/digest/*/*.[ch]: Ditto.
+Tue Oct 10 17:24:12 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Oct 11 17:11:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_obj_define_method): add half boiled RDoc document.
-
-Wed Oct 11 16:57:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_replace): should shift lfree pointer before
- calling xfree.
-
-Wed Oct 11 15:07:42 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest/hmac.rb: Add digest/hmac, which implements
- HMAC keyed-hashing algorithm.
-
-Wed Oct 11 15:03:55 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (rb_digest_base_reset): Do not make
- recursive calls, but call initialize() when reset() is not
- defined in a subclass.
-
-Wed Oct 11 14:56:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/digest/sha1/sha1ossl.h: libssl 0.9.8c-3 defines no
- SHA_BLOCK_LENGTH.
-
-Wed Oct 11 14:03:31 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (rb_digest_base_reset, Init_digest): Add
- Digest::Base#reset.
-
- * ext/digest/digest.h: Update the header comment.
-
- * ext/digest/md5/md5ossl.h, ext/digest/md5/md5init.c (Init_md5):
- Define DIGEST_LENGTH and BLOCK_LENGTH.
-
- * ext/digest/rmd160/rmd160init.c (Init_rmd160): Ditto.
-
- * ext/digest/sha1/sha1init.c (Init_sha1): Ditto.
-
- * ext/digest/sha2/sha2init.c (Init_sha2): Ditto.
-
- * ext/digest/depend, ext/digest/extconf.rb: Use $INSTALLFILES
- rather than adding make targets. [Pointed out by: nobu]
+ * {bcc32,win32,wince}/Makefile.sub (config.status): shouldn't use
+ copy command instead of install. use -run install.
-Tue Oct 10 16:39:08 2006 Akinori MUSHA <knu@iDaemons.org>
+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.
-Tue Oct 10 13:21:21 2006 Akinori MUSHA <knu@iDaemons.org>
+ * ext/digest/digest.c: Use RSTRING_{PTR,LEN} macros.
+
+Tue Oct 10 13:49:53 2006 Akinori MUSHA <knu@iDaemons.org>
- * ext/digest/sha1/depend, ext/digest/sha2/depend: Remove obsolete
- dependencies.
+ * 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>
@@ -13060,11 +5410,6 @@ Mon Oct 9 23:46:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/open3.rb, lib/ping.rb: ditto.
-Mon Oct 9 23:40:58 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb, lib/fileutils.rb, lib/mkmf.rb, lib/optparse.rb,
- lib/shellwords.rb: get rid of shadowing outer local variable.
-
Mon Oct 9 22:56:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rexml/encoding.rb (REXML::Encoding::check_encoding): spaces
@@ -13072,11 +5417,6 @@ Mon Oct 9 22:56:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rexml/parsers/baseparser.rb (REXML::Parsers::BaseParser): ditto.
-Mon Oct 9 01:56:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_obj_define_method): add new method
- Kernel#define_singleton_method. [ruby-list:42851]
-
Sat Oct 7 23:53:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_scan): small documentation fix.
@@ -13087,95 +5427,15 @@ 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 23:33:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (formal_assign): packed post splat arguments may conflict
- with normal arguments. [ruby-core:09021]
-
- * eval.c (rb_call0): ditto.
-
-Sat Oct 7 11:53:04 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * object.c (rb_mod_initialize): since module_eval no longer passes
- self, use module_exec instead. fixed: [ruby-dev:29637]
-
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 15:19:59 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/depend: Fix header installation when the build
- directory is different from srcdir. [Pointed out by: eban]
-
-Fri Oct 6 09:56:31 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.
-
-Fri Oct 6 06:53:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_yield_0): small refactoring.
-
- * parse.y (bparam_item): fixed bugs in handling parenthesized LHS.
-
-Fri Oct 6 04:47:07 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/depend: Install digest.h.
-
-Fri Oct 6 04:27:40 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/md5.rb, ext/digest/lib/sha1.rb: Remove those
- compatibility stub libraries.
+Fri Oct 6 04:30:30 2006 Akinori MUSHA <knu@iDaemons.org>
* sample/openssl/c_rehash.rb: Use digest/md5 instead of obsolete md5.
-Fri Oct 6 04:09:51 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c: Make hexdigest() always call digest() internally.
-
- * ext/digest/digest.c: Add bubblebabble().
-
-Fri Oct 6 02:38:42 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c: Allow subclassing in Ruby.
-
-Fri Oct 6 02:06:10 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.c (hexdigest_str_new): Add a string size check.
-
-Thu Oct 5 19:28:35 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/digest.[ch]: Since the argument order of
- hash_final_func_t was inconsistent with others, change it and
- rename to hash_finish_func_t to avoid confusion.
-
- * ext/digest/digest.[ch]: Remove and eliminate the use of
- hash_end_func_t. Implement hexdigest conversion in the base
- class.
-
- * ext/digest/md5/md5.c, ext/digest/md5/md5.h,
- ext/digest/md5/md5init.c, ext/digest/md5/md5ossl.c,
- ext/digest/md5/md5ossl.h: Remove MD5_End() and change
- MD5_Final() to MD5_Finish().
-
- * ext/digest/rmd160/depend, ext/digest/rmd160/extconf.rb,
- ext/digest/rmd160/rmd160.c, ext/digest/rmd160/rmd160.h,
- ext/digest/rmd160/rmd160hl.c, ext/digest/rmd160/rmd160init.c,
- ext/digest/rmd160/rmd160ossl.c, ext/digest/rmd160/rmd160ossl.h:
- Remove unused functions RMD160_End(), RMD160_File(),
- RMD160_Data() and change RMD160_Final() to RMD160_Finish().
-
- * ext/digest/sha1/extconf.rb, ext/digest/sha1/sha1.c,
- ext/digest/sha1/sha1.h, ext/digest/sha1/sha1hl.c,
- ext/digest/sha1/sha1init.c, ext/digest/sha1/sha1ossl.c,
- ext/digest/sha1/sha1ossl.h: Likewise.
-
- * ext/digest/sha2/extconf.rb, ext/digest/sha2/sha2.c,
- ext/digest/sha2/sha2.h, ext/digest/sha2/sha2hl.c,
- ext/digest/sha2/sha2init.c: Likewise.
-
Wed Oct 4 18:47:25 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: bugfix and update
@@ -13186,45 +5446,15 @@ 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 15:46:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (block_param): should interpret single parenthesized
- left hand side expression.
-
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 21:04:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (dyna_in_block): inline using macro.
-
- * parse.y (mlhs): simplifies the rule a bit.
-
- * parse.y (block_param): restrict block parameters to be local
- variables only.
-
- * test/ruby/test_iterator.rb (TestIterator::test_nested_iterator):
- update test suite to conform the last change.
-
-Tue Oct 3 02:31:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (splat_value): use "to_splat" instead of "to_ary" to
- prepare splat values as an array.
+Tue Oct 3 23:32:27 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (Init_Array): define to_splat.
-
- * range.c (range_to_splat): new method.
-
- * enumerator.c (enumerator_to_splat): ditto.
-
-Tue Oct 3 01:36:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_lines): returns an Enumerator instead of an
- array of lines.
-
- * string.c (rb_str_bytes): a new method.
+ * 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>
@@ -13236,7 +5466,7 @@ Mon Oct 2 23:47:55 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir#collect_file):
load expanded path. fixed: [ruby-dev:29621]
-Mon Oct 2 15:47:55 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Oct 2 15:49:19 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* instruby.rb: batfile should be CRLF'ed.
@@ -13260,15 +5490,10 @@ 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:11:26 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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 13:18:24 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/lib/digest.rb (Digest): Require digest.so and fix the
- breakage. Point out by NAKAMURA Usaku in [ruby-dev:29619].
-
Fri Sep 29 12:11:04 2006 WATANABE Hirofumi <eban@ruby-lang.org>
* jcode.rb (succ!): call original succ! if $KCODE == 'n'.
@@ -13293,60 +5518,22 @@ Thu Sep 28 23:59:31 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
win32 regardless if it is implemented. Provisional fix for
[ruby-core:08917].
-Thu Sep 28 20:49:20 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+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 22:08:16 2006 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/digest/md5/md5init.c (Init_md5): Now that we have digest.rb,
- require "digest" rather than "digest.so".
-
- * ext/digest/rmd160/rmd160init.c (Init_rmd160): Ditto.
-
- * ext/digest/sha1/sha1init.c (Init_sha1): Ditto.
-
- * ext/digest/sha2/sha2init.c (Init_sha2): Ditto.
-
-Wed Sep 27 21:21:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_startwith): rename startwith? to start_with?,
- endwith? to endwith?, respectively. [ruby-talk:216685]
-
-Wed Sep 27 13:29:01 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::TagMaker::nOE_element_def): replace to_s by
- join. some other methods as well. [ruby-dev:29613]
-
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.
-Wed Sep 27 00:08:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_shift): shift/unshift performance boost patch,
- based on the patch from Eric Mahurin <eric_mahurin at yahoo.com>.
- [ruby-core:05861]
-
- * array.c (rb_ary_unshift_m): ditto.
-
- * array.c (ary_make_shared): ditto.
-
- * array.c (RESIZE_CAPA): ditto.
-
- * array.c (rb_ary_free): new function to free memory. code moved
- from gc.c.
-
- * string.c (rb_str_free): ditto.
-
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:29:55 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Sep 26 15:31:26 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* {win32,wince}/Makefile.sub (CPP): check predefined value.
@@ -13356,38 +5543,13 @@ Tue Sep 26 07:55:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
body is shared. a patch from Kent Sibilev <ksruby at gmail.com>.
[ruby-core:08922]
-Mon Sep 25 23:10:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (rb_push_glob): need not to check by FilePathValue().
- [ruby-dev:29599]
-
- * dir.c (dir_globs): ditto.
-
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 (rm_f): get rid of NUL.
-
* lib/mkmf.rb (init_mkmf): set default $LDFLAGS. Patch by Michal
Suchanek <hramrach at centrum.cz>. [ruby-talk:216256]
-Mon Sep 25 15:06:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sample/test.rb: "print nil" now prints empty string.
-
- * test/ruby/test_system.rb (TestSystem::test_system): ditto.
-
-Mon Sep 25 11:26:25 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (recursive_hash): remove unused local variable.
-
- * parse.y (parser_yylex): ditto.
-
- * parse.y (rb_gc_mark_symbols): fix unmatched prototype .
-
- * file.c (rb_get_path): check NUL byte in the path string.
-
Mon Sep 25 08:14:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_shift): should clear shifting top element.
@@ -13401,25 +5563,19 @@ 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 21:19:24 2006 Guy Decoux <ts@moulon.inra.fr>
-
- * gc.c (gc_mark_children): NODE_POSTEXE holds Ruby VALUE.
- [ruby-core:08912]
-
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 12:10:04 2006 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Sep 24 14:59:50 2006 Tanaka Akira <akr@fsij.org>
- * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.3.
+ * node.h (struct thread): ia64 support is broken by sandbox patch.
-Sun Sep 24 06:55:36 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Sep 24 12:11:16 2006 Tadayoshi Funaba <tadf@dotrb.org>
- * io.c (rb_io_print): no special handling for nil as well as puts.
- fixed: [ruby-dev:29586]
+ * lib/date.rb, lib/date/format.rb: updated based on date2 3.9.3.
-Sun Sep 24 06:25:53 2006 why the lucky stiff <why@ruby-lang.org>
+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.
@@ -13428,7 +5584,7 @@ Sun Sep 24 06:25:53 2006 why the lucky stiff <why@ruby-lang.org>
* eval.c (rb_thread_kill_bang): Thread#kill! uses the above flag
to circumvent ensure, in order to prevent endless loops.
- contributed by MenTaLguY. [ruby-core:08768]
+ [ruby-core:08768]
* eval.c (rb_thread_kill): fix Thread#kill docs, which returns
the thread object in all cases.
@@ -13443,40 +5599,14 @@ 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 20:54:28 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * oniguruma.h: Version 4.4.4
-
- * regexec.c: ditto.
-
- * regcomp.c ditto.
-
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:02:57 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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 18:07:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_partition): no need to call rb_call_super(),
- since String is no longer includes Enumerable.
-
-Fri Sep 22 17:33:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_eql): new method to be used by Hash.
-
- * hash.c (rb_hash_hash): ditto.
-
-Fri Sep 22 06:53:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big_hash): use rb_memhash().
-
- * numeric.c (flo_hash): simplified. klass need not to affect
- resulting hash value.
-
Fri Sep 22 02:06:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* .cvsignore: ignore timestamp files and installed list file.
@@ -13485,11 +5615,6 @@ Fri Sep 22 01:36:34 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* instruby.rb: include FileUtils unconditionally.
-Fri Sep 22 00:36:05 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (Init_Numeric): fix_odd_p and fix_even_p are for Fixnum.
- patch from Ondrej Bilka <neleai at seznam.cz>. [ruby-core:08904]
-
Thu Sep 21 22:56:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (no-install): not install rdoc actually.
@@ -13500,28 +5625,6 @@ Thu Sep 21 22:56:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: expand ruby executable names.
-Thu Sep 21 20:19:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (str_new3): embed shorter strings more eagerly.
-
-Thu Sep 21 17:44:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_startwith): a new method to check if a string
- starts with given prefix.
-
- * string.c (rb_str_endwith): the opposite of String#startwith?.
-
-Thu Sep 21 16:29:02 2006 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * rubytest.rb: use each_line instead of each.
-
-Thu Sep 21 15:06:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (int_odd_p): a new method to check even or odd.
- [RCR#337]
-
- * numeric.c (int_even_p): ditto.
-
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
@@ -13530,21 +5633,6 @@ Thu Sep 21 13:55:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/etc/etc.c (etc_getpwuid): uid_t may be bigger than plain
'int' type.
-Thu Sep 21 10:07:09 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_partition): RDoc typo fixed. [ruby-core:08898]
-
- * string.c (rb_str_rpartition): fixed separation seek bug.
-
-Thu Sep 21 09:38:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_lines): new method to split a string into lines.
-
- * string.c (Init_String): Strings are no longer Enumerable. use
- each_line or lines method explicitly.
-
- * string.c (Init_String): remove each method. use each_lines.
-
Wed Sep 20 23:17:41 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (pre-install-doc): create data directory before install.
@@ -13553,19 +5641,7 @@ Wed Sep 20 23:17:41 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (install_dirs): remove extra slash.
-Wed Sep 20 22:41:45 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (fix_mul): typo again. patch from Tadashi Saito
- <shiba at mail2.accsnet.ne.jp>. fixed: [ruby-core:08893]
-
-Wed Sep 20 19:32:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_partition): a new method to separate the string
- by a separator. taken from Python 2.5.
-
- * string.c (rb_str_rpartition): ditto.
-
-Wed Sep 20 09:49:40 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+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.
@@ -13573,7 +5649,7 @@ Wed Sep 20 09:49:40 2006 NAKAMURA Usaku <usa@ruby-lang.org>
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.
+ Thanks, Tom Soderlund. (backported from HEAD)
Wed Sep 20 09:25:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -13581,6 +5657,13 @@ Wed Sep 20 09:25:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
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,
@@ -13592,42 +5675,6 @@ Tue Sep 19 00:42:15 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
defined. fixed: [ruby-dev:29554]
-- This didn't fix anything.
-Tue Sep 19 00:07:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (sym_eql): fail early to gain performance.
-
- * string.c (sym_hash): cache hash value in aux.shared if possible.
-
- * gc.c (rb_obj_id): no need to treat symbols specially.
-
- * lib/fileutils.rb (FileUtils::FileUtils): singleton_methods() no
- longer return an array of strings, but of symbols.
-
- * lib/delegate.rb (DelegateClass): ditto.
-
-Mon Sep 18 15:29:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (dir_s_glob): restore GC protection volatile variable.
- [ruby-dev:29588]
-
- * re.c (rb_reg_regcomp): ditto.
-
-Mon Sep 18 12:16:48 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (fix_mul): get rid of shift overflow.
-
-Mon Sep 18 10:47:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (dir_s_glob): remove unused variable.
-
- * math.c (math_log): ditto.
-
- * re.c (rb_reg_regcomp): ditto.
-
- * eval.c (break_jump): ditto.
-
- * eval.c (rb_thread_yield_0): remove unused function.
-
Sun Sep 17 23:44:58 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/rdoc.rb (RDoc::RDoc#document): scan only files modified
@@ -13641,18 +5688,11 @@ Sun Sep 17 17:42:13 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/generators/ri_generator.rb: do not chdir twice.
-Sun Sep 17 10:42:10 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (fix_mul): fixed typo. fixed: [ruby-core:08885]
-
-Sat Sep 16 19:47:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Sep 16 23:14:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * README.EXT: should mention new macros: RSTRING_PTR, RSTRING_LEN,
- RARRAY_PTR, RARRAY_LEN.
+ * ext/pty/pty.c (establishShell): remove remaining unused line.
- * README.EXT.ja: ditto.
-
-Sat Sep 16 16:39:23 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+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.
@@ -13667,53 +5707,9 @@ Sat Sep 16 16:39:23 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/pty.c (freeDevice): not used.
- * lib/mkmf.rb (checking_for): improved the messages.
-
-Sat Sep 16 11:03:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (ary_shared_first): should create embedded copies
- instead of sharing memory region for smaller arrays.
-
-Sat Sep 16 09:37:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * struct.c (inspect_struct): do not display a class name for
- anonymous struct. The member fields are sufficient.
-
-Fri Sep 15 20:22:15 2006 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-8/nkf.c: imported nkf 2.0.8 rev.110.
- * Fix: check_bom cuts \xfe\xff\xXX\xXX of UTF-32LE.
- * Add support --ic=UTF-32.
- * Fix: can't guess UTF-16 and UTF-32.
- * Fix: can't decode beyond BMP of UTF-16LE.
-
- * ext/nkf/nkf.c (guess): Support UTF-32.
-
- * ext/nkf/lib/kconv.rb (kconv): Support UTF-32.
-
- * ext/nkf/lib/kconv.rb (to_utf32): new method.
-
-Fri Sep 15 05:23:24 2006 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-8/nkf.c: imported nkf 2.0.8 2006-09-15.
- Add support for U+10000 - U+10FFFF
- Add support UTF-32
-
-Fri Sep 15 00:03:07 2006 Tanaka Akira <akr@fsij.org>
-
- * ext/digest/lib/digest.rb (Digest::Base.file): open a file in binary
- mode. suggested by Kazuhiro NISHIYAMA. [ruby-dev:29579]
-
-Thu Sep 14 17:21:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (fix_mul): avoid bignum multiplication as far as
- possible. a patch from Ondrej Bilka <neleai at seznam.cz>.
- [ruby-core:08825]
-
-Thu Sep 14 16:34:55 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/pty/pty.c (get_device_once): removed garbage right brace.
- * string.c (rb_str_intern): allow zero length symbols.
- [ruby-core:08861]
+ * lib/mkmf.rb (checking_for): improved the messages.
Thu Sep 14 16:11:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -13723,27 +5719,7 @@ Thu Sep 14 16:11:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (rb_interned_p): new function to check if a string is
already interned.
- * string.c (str_to_id): use rb_str_intern().
-
-Thu Sep 14 14:37:45 2006 Tanaka Akira <akr@fsij.org>
-
- * ext/digest/lib/digest.rb (Digest::Base.file): new method.
- [ruby-dev:29572]
-
-Thu Sep 14 08:30:02 2006 Tanaka Akira <akr@fsij.org>
-
- * ext/digest/digest.c (rb_digest_base_inspect): new method.
- [ruby-dev:29573]
-
-Thu Sep 14 01:13:56 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * gc.c (ruby_init_stack): decrease "stack level too deep" in Windows.
- [ruby-dev:29569]
-
-Thu Sep 14 01:02:25 2006 Tanaka Akira <akr@fsij.org>
-
- * ext/digest/lib/digest.rb: new file.
- [ruby-dev:28689]
+ * object.c (str_to_id): use rb_str_intern().
Wed Sep 13 18:43:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -13760,74 +5736,28 @@ 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:02 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+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]
-Tue Sep 12 03:58:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_compare_by_identity): rename Hash#identical to
- Hash#compare_by_identity.
-
-Mon Sep 11 16:52:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_hash_identical): a new method to make a hash to
- compare keys by their identity.
-
- * hash.c (rb_hash_identical_p): new method to tell if a hash is
- identical or not.
-
- * st.c (st_numcmp, st_numhash): export hash type functions.
-
-Mon Sep 11 11:42:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/rexml/source.rb (REXML::Source::encoding): should not
- convert the body twice. [ruby-core:08828]
-
- * lib/rexml/encoding.rb (REXML::Encoding::encoding):
- Encoding#encoding= to return boolean value to tell if the body
- is really converted or not.
-
- * lib/rexml/encoding.rb (REXML::Encoding::encoding): Specific
- conversion library (e.g. rexml/encodings/UTF-16.rb) to have
- higher preceding.
-
- * lib/rexml/encodings/UTF-16.rb (REXML::Encoding::decode_utf16):
- UTF-16#decode_utf16 should work strings without BOM.
-
-Mon Sep 11 07:39:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (sym_equal): "sym == str" should compare them as
- strings. [ruby-dev:29554]
-
-Sun Sep 10 22:59:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (parse_args): remove splat.
-
-Sun Sep 10 20:25:30 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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.
-Sun Sep 10 09:41:29 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c: ISPRINT() needs ctype.h
-
-Sun Sep 10 09:19:47 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb: splat parsed arguments.
-
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:55:28 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Sep 9 23:50:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (rb_f_test): test(0) should not have any special
- meaning. [ruby-dev:29425]
+ * bignum.c (rb_big_mul0): bignum multiplication without
+ normalization.
- * file.c (rb_f_test): properer error message.
+ * bignum.c (rb_big_pow): use rb_big_mul0(). [ruby-dev:29547]
Sat Sep 9 14:08:38 2006 Eric Hodel <drbrain@segment7.net>
@@ -13839,29 +5769,18 @@ 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:47:45 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+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.
- * win32/resource.rb: only file which has more than one icon is DLL.
-
-Fri Sep 8 16:53:30 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/extmk.rb: Proc#call does not pass the block in 1.8.
- * string.c (str_alloc): should allocate a String object, even when
- asked to allocate a Symbol object. [ruby-dev:29529]
+ * win32/resource.rb: add more info.
-Fri Sep 8 16:36:27 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/extmk.rb (extmake): follow Array#to_s.
-
- * lib/mkmf.rb (create_makefile): ditto.
-
- * win32/resource.rb: ditto.
-
-Fri Sep 8 10:00:12 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+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.
@@ -13873,62 +5792,33 @@ 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 08:25:39 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb: suppress `assigning void value' warning.
-
-Fri Sep 8 01:16:34 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (Init_Array): #to_s to be an alias to #inspect.
- [ruby-dev:29520]
-
- * hash.c (Init_Hash): ditto.
+Fri Sep 8 01:33:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/mkmf.rb (create_makefile): replace "print array" by
- "print *array".
+ * ruby.h (RSTRING_PTR): add migration macro.
- * mkconfig.rb: ditto.
-
-Thu Sep 7 21:02:56 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (nil_to_s): returns the empty string again.
- [ruby-dev:29520]
+ * 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]
-Thu Sep 7 02:03:45 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (time_to_s): adopt new date format using digits
- e.g. "2006-09-07 02:03:45 +9000".
-
-Thu Sep 7 01:54:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (sym_equal): override. check equivalence.
-
-Wed Sep 6 13:25:04 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (symbols_i): need to initialize early-created symbols.
- [ruby-dev:29496]
-
Wed Sep 06 12:05:19 2006 NARUSE, Yui <naruse@ruby-lang.org>
- * ext/nkf/lib/kconv.rb (Kconv::toeuc): remove -m0 [ruby-dev:29505]
+ * ext/nkf/lib/kconv.rb (Kconv::RegexpEucjp): fix regexp for euc-jp
+ [ruby-dev:29344]
-Tue Sep 5 22:06:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/tk/tcltklib.c: use rb_ary_new3() since RARRAY_LEN() is not l-value.
-
- * ext/tk/tkutil/tkutil.c: use RARRAY_PTR() and RARRAY_LEN() and etc.
- fixed: [ruby-dev:29473]
+ * 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
@@ -13955,7 +5845,7 @@ 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:39:42 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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.
@@ -13963,37 +5853,21 @@ 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:39:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::out): specify -x option for nkf.
-
- * lib/cgi.rb (CGI::out): should not convert utf-8 implicitly using
- NKF. it is too Japanese centric.
-
-Mon Sep 4 14:23:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dbm/extconf.rb (db_check): remove debug print.
-
-Mon Sep 4 06:46:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (rb_id2sym): intern if id is attrset_id.
- [ruby-dev:29420] [ruby-dev:29447]
-
-Mon Sep 4 01:25:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_local_variables): list symbols.
+Mon Sep 4 16:29:33 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * struct.c (rb_struct_s_members_m): ditto.
+ * lib/cgi.rb (CGI::out): specify -m0 -x option for nkf.
+ [ruby-dev:29284]
- * variable.c (ivar_i): ditto.
+Mon Sep 4 16:13:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * variable.c (gvar_i): ditto.
+ * io.c (pipe_open): command name should not contain null bytes.
+ [ruby-dev:29421]
- * variable.c (cv_i): ditto.
+ * process.c (proc_spawn): ditto.
-Sun Sep 3 20:47:02 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * process.c (proc_spawn_n): ditto.
- * ruby.h (SYMBOL_P): Qnil and Qfalse are not Symbol.
+ * process.c (rb_f_system): ditto.
Sun Sep 3 15:32:44 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -14009,286 +5883,95 @@ Sun Sep 3 04:40:42 2006 Tanaka Akira <akr@fsij.org>
* ext/socket/socket.c: include arpa/inet.h if available.
-Sat Sep 2 23:59:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (Init_String): undef Symbol#new.
-
- * struct.c (rb_struct_s_def): wrong symbol detection.
-
-Sat Sep 2 23:59:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (str_to_id): a bug caused by premature optimization.
-
-Sat Sep 2 23:53:28 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (Init_Object): move symbol related code to string.c
-
- * string.c (Init_String): Symbol as subclass of String.
-
- * parse.y (rb_intern2): handle symbol as strings.
-
- * string.c (str_new): substring of symbols are mere strings, not
- symbols.
+Sun Sep 3 02:34:55 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Sat Sep 2 23:37:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/drb/unix.rb (DRbUNIXSocket#close): don't get path if client mode.
+ [ruby-dev:29417]
- * ruby.h (struct RArray): embed small arrays.
- (RARRAY_LEN): defined for accessing array members.
- (RARRAY_PTR): ditto.
+Sun Sep 3 01:45:17 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * array.c: use RARRAY_LEN and RARRAY_PTR.
+ * 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 12:06:35 2006 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/soap/generator.rb (SOAP::SOAPGenerator#encode_tag): do not dump
- XML attribute which value is nil. value "" and nil both were dumped
- as 'attr="value"'. [ruby-dev:29395]
-
-Sat Sep 2 11:47:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_eval): should handle when in else clause. a patch
- from Eric Hodel <drbrain at segment7.net>. [ruby-core:08662]
-
- * parse.y (primary): wrap with NODE_CASE. [ruby-core:08663]
-
-Sat Sep 2 12:00:32 2006 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/csv.rb (CSV::IOReader#initialize): use String#[](pos, len)
- instead of String#[](idx) to check utf BOM. follows String#[](idx)
- behavior change of 1.9.
-
-Sat Sep 2 11:47:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_eval): should handle when in else clause. a patch
- from Eric Hodel <drbrain at segment7.net>. [ruby-core:08662]
-
- * parse.y (primary): wrap with NODE_CASE. [ruby-core:08663]
-
-Fri Sep 1 22:07:04 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h (RSTRING_EMBED_LEN_MASK): uses 5 bits to support 64bit
- environment. [ruby-dev:29369]
-
-Fri Sep 1 22:02:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_resize): should copy embedded string to
- malloc'ed buffer. a patch from <nobu at ruby-lang.org> in
- [ruby-dev:29369]. fixed: [ruby-dev:29368]
-
- * string.c (rb_str_ord): use %ld specifier since STRING_LEN() is a
- long. [ruby-dev:29369]
-
-Fri Sep 1 21:41:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (socks_init): typo fixed. a patch from Sven
- Klemm <sven at c3d2.de>. [ruby-core:08770]
-
-Fri Sep 1 14:22:42 2006 WATANABE Hirofumi <eban@ruby-lang.org>
+Sat Sep 2 03:36:22 2006 Tanaka Akira <akr@fsij.org>
- * array.c (rb_ary_shuffle): RDoc fixed.
+ * 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.
-Fri Sep 1 09:32:55 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/irb/ruby-lex.rb (RubyLex::getc): should not push nil into
- reading buffer (@readed). reported in
- <http://jarp.does.notwork.org/diary/200608c.html#200608311>.
-
-Thu Aug 31 23:59:03 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (configuration): follow nil.to_s.
-
-Thu Aug 31 20:50:46 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/mkmf.rb (create_makefile): follow nil.to_s.
-
- * win32/resource.rb: ditto.
-
-Thu Aug 31 20:21:47 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * eval.c (search_required): use RSTRING_PTR and RSTRING_STR.
-
- * file.c (test_identical, rb_file_s_truncate): ditto.
-
- * io.c (pipe_open, rb_io_reopen): ditto.
-
- * object.c (nil_plus): ditto.
-
- * process.c (proc_spawn_n, rb_spawn): ditto.
-
- * util.c (ruby_add_suffix): ditto.
-
- * ext/Win32API/Win32API.c (Win32API_initialize): ditto.
-
- * ext/dl/cptr.c (rb_dlptr_s_to_ptr): ditto.
-
- * ext/openssl/ossl_x509ext.c (ossl_x509extfactory_create_ext): ditto.
-
- * ext/tk/stubs.c, ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: ditto.
-
- * ext/win32ole/win32ole.c (ole_val2olevariantdata): ditto.
-
-Thu Aug 31 18:23:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h (struct RString): embed small strings.
- (RSTRING_LEN): defined for accessing string members.
- (RSTRING_PTR): ditto.
-
- * string.c: use RSTRING_LEN and RSTRING_PTR.
-
-Thu Aug 31 17:16:19 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_shuffle_bang): new method.
-
- * array.c (rb_ary_shuffle): ditto.
-
- * random.c (genrand_real): ditto.
-
- * random.c (genrand_int32): export the function.
-
- * random.c (Init_Random): initialize random seed at the
- beginning.
-
-Thu Aug 31 13:12:06 2006 why the lucky stiff <why@ruby-lang.org>
+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.
-Wed Aug 30 12:01:57 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (flo_hash): improve collision.
-
- * string.c (rb_memhash): new generic function to calculate hash value
- for memory chunk.
-
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:29:46 2006 Eric Hodel <drbrain@segment7.net>
-
- * eval.c, parse.y: Revert.
- * ext/.document: Add digest.c.
- * ext/digest/digest.c: Make RDoc show up.
- * ext/io/wait.c: Fix call-seq in RDoc.
+Mon Aug 28 11:36:02 2006 Eric Hodel <drbrain@segment7.net>
-Mon Aug 28 08:03:20 2006 Eric Hodel <drbrain@segment7.net>
-
- * ext/.document: Add C files with RDoc.
- * ext/digest/digest.c: Convert to RDoc.
- * ext/io/wait.c: ditto.
* lib/rdoc/parsers/parse_rb.rb: Fix typo. Submitted by
<calamitas at gmail.com>. [ruby-core:08724]
-Mon Aug 28 07:21:47 2006 Eric Hodel <drbrain@segment7.net>
-
- * file.c (File#size?): Fix documentation submitted by Rick Ohnemus.
- ruby-Bugs-5529. [ruby-core:08725]
-
-Sun Aug 27 21:41:23 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * oniguruma.h: Version 4.4.0
-
- * regint.h: ditto.
+Mon Aug 28 07:53:44 2006 Eric Hodel <drbrain@segment7.net>
- * regparse.h: ditto.
-
- * regexec.c: ditto.
+ * lib/rdoc/ri/ri_formatter.rb: Don't unescape HTML in HtmlFormatter.
+ Submitted by Kent Sibilev <ksruby at gmail.com>. [ruby-core:08392].
- * regcomp.c ditto.
+Mon Aug 28 07:25:45 2006 Eric Hodel <drbrain@segment7.net>
- * regparse.c: ditto.
+ * file.c (File#size?): Fix documentation submitted by Rick Ohnemus.
+ ruby-Bugs-5529. [ruby-core:08725]
-Sat Aug 26 08:03:03 2006 Tadayoshi Funaba <tadf@dotrb.org>
+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 21:15:22 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
+Fri Aug 25 22:32:04 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * common.mk: add regint.h and oniguruma.h to dependence.
-
- * ext/strscan/depend: ditto.
-
-Fri Aug 25 20:35:57 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * lib/rexml/source.rb (REXML::IOSource#initialize): encoding have to
+ be set with the accessor. fixed: [ruby-list:42737]
- * test/wsdl/document/echo.rb: removed.
+Fri Aug 25 17:15:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * test/wsdl/document/test_rpc.rb: remove echo.rb after test.
- [ruby-dev:29337]
+ * stable version 1.8.5 released.
Fri Aug 25 17:02:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (gc_sweep): typo fixed.
-Fri Aug 25 16:05:50 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * object.c (sym_call): check if the receiver is given.
-
-Fri Aug 25 01:10:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_Integer): Integer(nil) should raise TypeError.
- [ruby-talk:210205]
-
- * object.c (nil_to_s): no longer returns empty string but "nil".
- [ruby-talk:210205]
-
- * lib/mkmf.rb: avoid COMMON_HEADERS being nil.
-
-Wed Aug 23 00:25:14 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]
-
-Tue Aug 22 19:21:00 2006 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/smtp.rb: parameter `to_addrs' might be an Array,
- .flatten is required. [ruby-dev:29316]
-
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].
-Tue Aug 22 12:35:57 2006 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/lib/kconv.rb (Kconv::RegexpEucjp): fix regexp for
- euc-jp [ruby-dev:29344]
-
-Sun Aug 20 11:46:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Aug 19 14:15:02 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * numeric.c (num_step): also return an enumerator object if no block
- is given.
-
-Sat Aug 19 16:47:51 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (hash2named_arg): accept hash argument
- of symbol key.
-
- * test/win32ole/test_win32ole.rb
- ditto.
+ * win32/Makefile.sub (config.status): include winsock2.h instead of
+ winsock.h when --with-winsock2 is specified.
+ fixed: [ruby-dev:29296]
Sat Aug 19 11:28:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_rename): use errno if set properly.
fixed: [ruby-dev:29293]
-Fri Aug 18 01:05:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Aug 19 11:09:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/cgi.rb (CGI::out): specify -m0 to disable MIME decode. a
- patch from Fujioka <fuj at rabbix.jp>. [ruby-dev:29284]
+ * parse.y (then): remove semicolon warning. [ruby-dev:29299]
Thu Aug 17 19:15:16 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -14299,98 +5982,30 @@ Thu Aug 17 14:47:06 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb: added rdoc by Daniel Berger. [ruby-core:08177]
-Wed Aug 16 17:46:59 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (r_byte): IO#getc returns one byte string now.
- fixed: [ruby-dev:29255]
+Thu Aug 17 00:39:05 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Wed Aug 16 17:22:44 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * common.mk (pre-install-local): remove unnecessary code.
- [ruby-dev:29249]
+ * lib/rinda/ring.rb (do_reply): Fix for RingServer fails to find a
+ TupleSpace when TupleSpace resides in the same ruby process with
+ RingServer. a patch from Kent Sibilev. [ruby-core:08453]
Wed Aug 16 11:45:36 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (proc_setuid, proc_setgid, proc_seteuid, proc_setegid):
get rid of bogus implementations on Mac OS X.
+Tue Aug 15 19:10:18 2006 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment): Fix
+ broken class-level documentation.
+
Wed Aug 16 11:09:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (set_arg0): fill argv other than the first with an empty
string instead of NULL.
-Tue Aug 15 11:21:08 2006 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/smtp.rb: support SMTP/SSL. Thanks Kazuhiro NISHIYAMA.
-
- * lib/net/smtp.rb: new method SMTP.use_ssl?
-
- * lib/net/smtp.rb: new method SMTP.enable_ssl.
-
- * lib/net/smtp.rb: new method SMTP.disable_ssl.
-
- * lib/net/smtp.rb: new method SMTP.default_ssl_port.
-
- * lib/net/smtp.rb: new method SMTP.default_tls_port.
-
- * lib/net/smtp.rb: now SMTP#enable_tls accepts a SSLContext
- object, instead of a verity and cert. [FEATURE CHANGE]
-
- * lib/net/smtp.rb: new method SMTP.ssl_context.
-
- * lib/net/smtp.rb: new method SMTP.default_ssl_context.
-
- * lib/net/smtp.rb: export SMTP.authenticate.
-
- * lib/net/smtp.rb: export SMTP.auth_plain.
-
- * lib/net/smtp.rb: export SMTP.auth_login.
-
- * lib/net/smtp.rb: export SMTP.auth_cram_md5.
-
- * lib/net/smtp.rb: export SMTP.starttls.
-
- * lib/net/smtp.rb: export SMTP.helo.
-
- * lib/net/smtp.rb: export SMTP.ehlo.
-
- * lib/net/smtp.rb: export SMTP.mailfrom.
-
- * lib/net/smtp.rb: export SMTP.rcptto.
+Wed Aug 16 11:08:00 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/smtp.rb: export SMTP.rcptto_list.
-
- * lib/net/smtp.rb: export SMTP.data.
-
- * lib/net/smtp.rb: export SMTP.quit.
-
-Sat Aug 12 22:33:06 2006 Eric Hodel <drbrain@segment7.net>
-
- * string.c (String#split): Describe grouping behavior. Patch by Jan
- Svitok <jan.svitok at gmail.com>. [ruby-core:08603]
-
-Sun Aug 13 12:08:02 2006 Tanaka Akira <akr@fsij.org>
-
- * ext/socket/socket.c: ANSIfied. [ruby-core:08601]
-
-Sat Aug 12 15:55:32 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in, bcc32/Makefile.sub, win32/Makefile.sub, win32/dir.h,
- win32/win32.c, win32/win32.h: large file support for win32.
-
-Fri Aug 11 15:39:25 2006 Eric Hodel <drbrain@segment7.net>
-
- * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_body): Make RDoc
- ignore C function prototypes. Patch by Tilman Sauerbeck
- <tilman at code-monkey.de>. [ruby-core:8574]
- * lib/yaml/tag.rb: Replace nodoc with stopdoc so Module methods get
- documented.
-
-Wed Aug 9 16:53:28 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/net/smtp.rb (Net::SMTP::auth_cram_md5): use ord to retrieve
- bytes from strings. a patch from WATANABE Tetsuya
- <Tetsuya.WATANABE at nifty.com>. [ruby-dev:29240]
+ * win32/win32.h: removed an excess macro. fixed: [ruby-dev:29258]
Tue Aug 8 23:49:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -14398,23 +6013,17 @@ Tue Aug 8 23:49:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
RDoc. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:08522]
-Tue Aug 8 19:26:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Aug 8 11:32:54 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder::get_string):
- affected by str[0] returns 1 char string. [ruby-dev:29223]
-
- * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder::get_labels):
- ditto.
-
-Tue Aug 8 12:28:43 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (arg): allow newlines before ternary colon. [ruby-dev:29189]
+ * Makefile.in, common.mk, configure.in: fix for platforms without
+ rm. patches from Yutaka kanemoto <kinpoco at gmail.com>.
+ [ruby-dev:29215]
Mon Aug 7 17:56:59 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c, ext/digest/rmd160/rmd160ossl.c,
ext/digest/sha1/sha1ossl.c, ext/readline/readline.c: move
- inclusion of config.h to pacify AIX. a patch from Yutaka
+ incluion of config.h to pacify AIX. a patch from Yutaka
Kanemoto <kinpoco at gmail.com>. [ruby-dev:29197]
Mon Aug 7 15:55:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -14431,58 +6040,33 @@ Mon Aug 7 14:37:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
Mon Aug 7 12:05:28 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * dln.c, eval.c, gc.c, ruby.h: shut up AIX alloca warning.
- a patch from Yutaka Kanemoto <kinpoco at gmail.com>.
+ * dln.c, eval.c, gc.c, regex.c, ruby.h: shut up AIX alloca
+ warning. a patch from Yutaka Kanemoto <kinpoco at gmail.com>.
[ruby-dev:29191]
-Sun Aug 6 20:34:24 2006 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Aug 6 20:40:41 2006 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/format.rb (str[fp]time): %[EO]U didn't denote %U.
-Sun Aug 6 17:12:12 2006 Tanaka Akira <akr@fsij.org>
-
- * io.c (io_reopen): STDERR.reopen(open("/dev/tty", "w")) should not
- clear FMODE_PREP in STDERR.
-
-Sat Aug 5 22:53:41 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * oniguruma.h: Version 4.2.2
-
- * regint.h: ditto.
-
- * regparse.h: ditto.
-
- * regexec.c: ditto.
-
- * regcomp.c ditto.
-
- * regerror.c: ditto.
-
- * regparse.c: ditto.
-
Sat Aug 5 17:07:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (top_local_setup): local_vars[-1] should point
ruby_scope itself to protect local_tbl from garbage collection.
[ruby-dev:29049]
-Sat Aug 5 13:49:43 2006 Tadayoshi Funaba <tadf@dotrb.org>
+Sat Aug 5 13:54:03 2006 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/format.rb (str[fp]time): "%\n" means "\n".
-Fri Aug 4 12:13:22 2006 Eric Hodel <drbrain@segment7.net>
+Fri Aug 4 15:21:00 2006 Eric Hodel <drbrain@segment7.net>
- * lib: Clean up files for RDoc.
- * lib/.document: Include most of the standard library in RDoc
- generation.
- * lib/rdoc/ri/ri_formatter.rb: Don't unescape HTML in HtmlFormatter.
- Submitted by <ksruby at gmail.com>. [ruby-core:08392].
+ * lib: Merge RDoc and .document from HEAD.
* lib/drb/ssl.rb: Close socket on SSLError [ruby-core:7197]
-Fri Aug 4 18:59:49 2006 Keiju Ishitsuka <keiju@ruby-lang.org>
+Fri Aug 4 19:13:41 2006 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/irb/{init.rb,ruby-lex.rb,slex.rb}: can't input '\c' for
- [ruby-core: 7122]. and support for ruby1.8.X
+ [ruby-core: 7122].
Fri Aug 4 14:02:14 2006 James Edward Gray II <james@grayproductions.net>
@@ -14495,22 +6079,15 @@ Fri Aug 4 13:56:51 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* pack.c (pack_pack): check argument overrun for 'P'. based on a
patch by rucila <rucila at yahoo.cojp>. fixed: [ruby-dev:29182]
-Fri Aug 4 02:42:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sprintf.c (rb_str_format): a bug in %c type check.
+Tue Aug 1 17:44:03 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Aug 4 01:28:19 2006 Tanaka Akira <akr@fsij.org>
-
- * io.c (io_reopen): STDERR.reopen(File.open("/dev/null", "w")) should
- not fclose stderr.
+ * win32/win32.c (init_stdhandle): assign standard file handles.
-Thu Aug 3 15:16:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Aug 1 12:24:58 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * range.c (range_include): should always call Enumerable#include?
- (not #===) for non numeric end points. [ruby-core:08477]
- [ruby-core:08496]
+ * eval.c (Init_Binding): fix old commit miss.
-Mon Jul 31 16:51:40 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Jul 31 17:08:20 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (exit_handler): new function; release winsock and
environment work area.
@@ -14521,7 +6098,7 @@ Mon Jul 31 16:51:40 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_getenv): use GetEnvironmentStrings() instead
of GetEnvironmentVariable(), because the latter cannot distinguish
- whether a null environment variable exists or not.
+ wheather a null environment variable exists or not.
fixed: [ruby-talk:205123]
Mon Jul 31 16:15:13 2006 Tanaka Akira <akr@fsij.org>
@@ -14530,18 +6107,18 @@ Mon Jul 31 16:15:13 2006 Tanaka Akira <akr@fsij.org>
setrlimit may fail with EINVAL.
reported by MIYAMUKO Katsuyuki. [ruby-dev:29174]
+Mon Jul 31 13:38:22 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/httprequest.rb (WEBrick::HTTPReuqest#parse_uri): improve
+ for the value of IPv6 address in the Host: header field.
+
Mon Jul 31 09:22:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.h: use ifdef (or defined) for macro constants that may or
may not be defined to shut up gcc's -Wundef warnings.
[ruby-core:08447]
-Mon Jul 31 13:38:13 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httprequest.rb (WEBrick::HTTPReuqest#parse_uri): improve
- for the value of IPv6 address in the Host: header field.
-
-Sun Jul 30 23:26:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jul 30 23:26:22 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_call0): trace call/return of method defined from block.
fixed: [ruby-core:08329]
@@ -14563,33 +6140,9 @@ Sat Jul 29 01:23:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
statement back before the comment block. a patch from Hugh
Sasse <hgs at dmu.ac.uk>. [ruby-core:08422]
-Fri Jul 28 17:18:03 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/curses/curses.c (NUM2CH, CH2FIX): use single char strings.
-
-Fri Jul 28 14:09:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_call): fixed typo in cache look-up. [ruby-dev:29167]
-
-Fri Jul 28 10:41:35 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_call): a bug in method cache look-up.
- http://www.rubyist.net/~matz/20060720.html#c04
-
-Fri Jul 28 10:19:28 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sprintf.c (rb_f_sprintf): documentation update patch from Jacob
- Fugal <lukfugl at gmail.com>. [ruby-core:08418]
-
-Fri Jul 28 09:41:45 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (time_to_s): fixed typo. [ruby-dev:29162]
-
-Fri Jul 28 00:26:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * math.c (domain_check): ANSI style function arguments
+Thu Jul 27 22:21:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * math.c (math_log): too few argument to domain_check().
+ * time.c (time_to_s): fixed format mismatch.
Thu Jul 27 21:19:54 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -14602,10 +6155,6 @@ Thu Jul 27 21:19:54 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* math.c (math_sqrt): fix documentation flaw.
-Thu Jul 27 22:21:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * time.c (time_to_s): fixed format mismatch.
-
Thu Jul 27 18:12:12 2006 WATANABE Hirofumi <eban@ruby-lang.org>
* time.c: need to declare time_utc_offset.
@@ -14615,19 +6164,23 @@ Thu Jul 27 17:01:01 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (io_close): always calls "close" method of the receiver.
[ruby-core:6911] [ruby-core:8112]
+Thu Jul 27 16:49:01 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_to_s): use +0900 style timezone string for local time.
+ [ruby-dev:29143]
+
Thu Jul 27 16:41:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/openssl/ossl.h: move <ruby.h> inclusion point to shut up
Solaris compiler. [ruby-core:08114]
- * time.c (time_to_s): use +0900 style timezone string for local time.
- [ruby-dev:29143]
-
Wed Jul 26 22:20:59 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in: add support for as and ASFLAGS. [ruby-dev:29138]
-Wed Jul 26 21:59:33 2006 Minero Aoki <aamine@loveruby.net>
+Wed Jul 26 22:13:45 2006 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: sync with HEAD (rev 1.132).
* lib/net/http.rb (Net::HTTP#post, request_post, request): should
set Content-Type: x-www-form-urlencoded by default.
@@ -14641,37 +6194,21 @@ Wed Jul 26 21:59:33 2006 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb (Net::HTTPHeader#type_params): wrongly failed
when there's no Content-Type.
-Wed Jul 26 18:38:13 2006 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c (strscan_do_scan): always return nil if
- p->curr exceeds string size.
-
-Wed Jul 26 18:33:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (Init_eval): rename #invoke_method and
- #invoke_functional_method to __send and __send! respectively.
+Wed Jul 26 18:35:38 2006 Minero Aoki <aamine@loveruby.net>
- * eval.c (remove_method): prohibit removing __send and __send!.
+ * ext/strscan/strscan.c: sync with HEAD (rev 1.25).
- * eval.c (rb_undef): prohibit undef'ing __send and __send!.
-
- * eval.c (rb_eval): prohibit redefining __send and __send!.
-
- * lib/delegate.rb (Delegator): preserve __send.
+ * ext/strscan/strscan.c (strscan_do_scan):
+ StringScanner.new("").scan(//) should return "". [ruby-Bugs:4361]
Wed Jul 26 18:14:19 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/pty.c (getDevice): retry once after GC on failure.
[ruby-core:08282]
-Wed Jul 26 17:43:20 2006 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c (strscan_do_scan):
- StringScanner.new("").scan(//) should return "". [ruby-Bugs:4361]
-
Wed Jul 26 17:28:16 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * sprintf.c (rb_str_format): prepend ".." to %u for negative bignum,
+ * sprintf.c (rb_f_sprintf): prepend ".." to %u for negative bignum,
but not "-". fixed: [ruby-core:08167]
Wed Jul 26 16:39:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -14689,7 +6226,11 @@ Wed Jul 26 01:02:59 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: suppress warnings by automake 1.8 or later.
-Tue Jul 25 14:46:14 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jul 25 00:30:06 2006 Eric Hodel <drbrain@segment7.net>
+
+ * lib/prettyprint.rb: RD to RDoc conversion by Hugh Sasse.
+
+Tue Jul 25 14:49:51 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/mkmf.rb (configuration): typo.
@@ -14702,6 +6243,13 @@ Mon Jul 24 22:03:40 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (backtrace): skip frames successive on node and method name.
+Mon Jul 24 17:55:55 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (rb_f_system): add security check. [ruby-talk:202947]
+
+ * process.c (rb_f_system): move signal right before fork to avoid
+ signal handler intervention.
+
Mon Jul 24 15:51:52 2006 Tanaka Akira <akr@fsij.org>
* ext/readline/readline.c (readline_readline): rl_deprep_term_function
@@ -14717,61 +6265,36 @@ Sun Jul 23 22:59:49 2006 Tanaka Akira <akr@fsij.org>
* test/socket/test_unix.rb: disabled on cygwin.
reported by Kouhei Yanagita. [ruby-dev:29080]
-Fri Jul 21 23:57:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ruby.c (proc_options): script is never used while recursing.
-
Fri Jul 21 21:21:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_call0): include funcalled methods in caller list.
fixed: [ruby-core:08290]
-Fri Jul 21 17:52:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_cstr_to_dbl): "9_e8" should consider "_e8" as
- trailing garbage so that it should return 9.0. [ruby-dev:29088]
-
Fri Jul 21 12:11:00 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb, lib/mkmf.rb (with_destdir): remove drive letter before
prepending destdir on DOSISH.
-Fri Jul 21 04:17:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_call): try local method look-up first for fcall, then
- normal method look-up. [ruby-talk:202564]
-
- * eval.c (rb_get_method_body): save local method cache separately.
-
- * eval.c (search_method): export info whether method is local or
- not.
-
-Thu Jul 20 20:27:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_mod_attr): make Module#attr to be an alias to
- attr_reader. [RCR#331]
-
Thu Jul 20 15:07:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.h: export classes/modules to implement sandbox.
[ruby-core:08283]
-Wed Jul 19 19:40:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jul 20 00:06:29 2006 Keiju Ishitsuka <keiju@ishitsuka.com>
- * eval.c (rb_yield_0): should check args_args before lambda
- argument check. [ruby-dev:29029]
+ * lib/irb/completion.rb: support for completion of numeric
+ number. [ruby-dev: 29038]
-Tue Jul 18 23:53:59 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Jul 19 23:53:05 2006 Kouhei Sutou <kou@cozmixng.org>
- * process.c (rb_f_system): shouldn't block SIGCHLD if it's not
- exist.
+ * lib/rss/parser.rb, lib/rss/utils.rb: added documents.
Tue Jul 18 22:10:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (rb_f_system): block SIGCHLD during the process
execution, like glibc system(3) does. [ruby-talk:202361]
-Tue Jul 18 23:10:43 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jul 18 23:12:14 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (open_ifs_socket): should not use plain malloc.
@@ -14782,11 +6305,6 @@ Tue Jul 18 18:05:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/ruby/test_float.rb (TestFloat::test_strtod): update test to
conform strtod change.
-Tue Jul 18 16:52:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (yield_under_i): argument should be passed in avalue
- form. [ruby-dev:29044]
-
Tue Jul 18 15:49:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_unpack): propagate association array to copied
@@ -14798,15 +6316,6 @@ Tue Jul 18 15:49:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): taint 'p' packed strings.
-Tue Jul 18 15:19:07 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * intern.h (st_foreach_safe): fix prototype.
-
- * node.h (NODE_LMASK): bigger than long on LLP64.
-
- * missing/vsnprintf.c (BSD__uqtoa): new function to support LLP64.
- all changes are derived from [ruby-dev:29045]
-
Tue Jul 18 14:03:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/webrick/httpserver.rb (WEBrick::HTTPServer::unmount): remove
@@ -14833,23 +6342,23 @@ Mon Jul 17 23:30:46 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (rb_cv_msvcrt): defaulted to msvcrt. Workaround for a
bug of cygwin 1.5.20.
-Mon Jul 17 22:55:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/io/wait/wait.c (io_ready_p): protoize.
-
Mon Jul 17 13:43:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (define_swapx): should not use plain malloc.
- * ext/curses/curses.c (curses_getmouse): ditto.
-
Mon Jul 17 12:58:41 2006 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in: should use ac_cv_lib_dl_dlopen=no on MinGW.
-Mon Jul 17 11:47:35 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Sat Jul 15 23:50:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * st.c: still need to include config.h on some platforms.
+ * eval.c (rb_require_safe): wait for another thread requiring the same
+ feature. fixed: [ruby-core:08229]
+
+Sat Jul 15 01:27:13 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * dir.c (has_magic): glob names contain alphabets to enable case fold
+ search also for directories. fixed: [ruby-talk:201917]
Sat Jul 15 01:09:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -14857,6 +6366,8 @@ Sat Jul 15 01:09:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
malloc/calloc, to detect memory allocation failure. see
<http://www.nongnu.org/failmalloc/>.
+ * gc.c (rb_memerror): should not raise empty nomem_error.
+
Fri Jul 14 13:08:13 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: add methods for new features of latest Tcl/Tk8.5.
@@ -14868,6 +6379,10 @@ Fri Jul 14 02:30:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/monitor.rb: document patch from Hugh Sasse <hgs at dmu.ac.uk>.
[ruby-core:08205]
+Fri Jul 14 01:09:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (then): error in warning action.
+
Fri Jul 14 00:10:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_pop): may cause realloc oscillation. a patch
@@ -14879,23 +6394,15 @@ Thu Jul 13 22:23:56 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/composite.rb: improve handling of the classname on the
option database for the widget class which includes TkComposite.
-Thu Jul 13 00:40:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h (FIX2LONG): returns integer of size of VALUE.
- [ruby-dev:29024]
-
- * ruby.h (FIX2ULONG): ditto.
-
-Wed Jul 12 20:05:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jul 13 20:32:19 2006 Kouhei Sutou <kou@cozmixng.org>
- * parse.y (f_args): allow post mandatory arguments after optional
- arguments. [ruby-dev:29014]
+ * lib/rss/parser.rb: updated documents by a patch from
+ Hugh Sasse <hgs at dmu.ac.uk>. [ruby-core:8194]
- * parse.y (new_args_gen): allow post_args without rest_args.
+Wed Jul 12 13:54:09 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (formal_assign): ditto.
-
- * parse.y (new_args_gen): check post argument duplication.
+ * parse.y (then): we'd like to reserve colon here for the future.
+ warning added.
Tue Jul 11 20:58:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -14910,42 +6417,10 @@ Tue Jul 11 18:00:57 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: security fix.
-Tue Jul 11 17:28:08 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jul 11 17:33:39 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* string.c (rb_str_dump): need to extend len for \b.
-Tue Jul 11 15:29:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_int2big): use SIGNED_VALUE. [ruby-dev:29019]
-
- * bignum.c (rb_int2inum, rb_uint2inum): use VALUE sized integer.
-
- * bignum.c (rb_big2long, rb_big2ulong): ditto.
-
- * numeric.c (rb_num2long, rb_num2ulong): ditto.
-
- * numeric.c (check_int, check_uint): ditto.
-
- * bignum.c (rb_quad_pack): typo fixed.
-
-Tue Jul 11 13:40:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (bignorm): sizeof(long) may be smaller than
- sizeof(VALUE). [ruby-dev:29013]
-
- * ruby.h (FIXNUM_MAX): fixnum may be bigger than long.
-
- * ruby.h (SIGNED_VALUE): signed integer of size of VALUE.
-
-Mon Jul 10 23:37:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/soap/rpc/proxy.rb (Proxy::Operation::response_doc): remove
- splat star from return statements.
-
- * lib/soap/rpc/proxy.rb (Proxy::Operation::response_obj): retrieve
- the first value from the result array if response has only one
- value.
-
Mon Jul 10 22:00:00 2006 Shigeo Kobayashi <shigek@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c: Allows '_' to appear within
@@ -14989,52 +6464,17 @@ Mon Jul 10 18:46:52 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/demos-jp/widget: ditto.
-Mon Jul 10 17:32:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sample/test.rb: update test suites.
-
- * test/ruby/test_assignment.rb (TestAssignment::test_yield): ditto.
+Mon Jul 10 13:58:40 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * test/ruby/test_iterator.rb (TestIterator::test_itertest): ditto.
+ * signal.c (ruby_nativethread_signal, posix_nativethread_signal,
+ sigsend_to_ruby_thread, install_nativethread_sighandler):
+ nativethread-support on signal handler. RE-backport from 1.9.
-Mon Jul 10 14:43:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ruby.h (HAVE_NATIVETHREAD_KILL): ditto.
- * eval.c (rb_call): remove erroneously restored prot_tag->blkid
- initialization. [ruby-dev:28997] [ruby-dev:29000]
-
-Mon Jul 10 13:58:08 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * signal.c (install_nativethread_sighandler): commented out.
-
-Mon Jul 10 09:29:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (ruby_native_thread_kill): ditto.
- * eval.c (rb_clear_cache_for_remove): clear entries for included
- module. fixed: [ruby-core:08180]
-
-Mon Jul 10 02:22:58 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): should not overwrite block information in
- current frame. [ruby-dev:28957]
-
- * eval.c (rb_yield_0): retrieve proper block object from the frame
- record.
-
- * eval.c (proc_alloc): return preserved block object if it's
- available.
-
-Mon Jul 10 01:48:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * st.h (st_data_t): use pointer sized integer for st_data_t.
- [ruby-dev:28988]
-
-Sun Jul 9 18:06:47 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (try_constant): fix for value 1 at cross compiling.
-
- * lib/mkmf.rb (create_makefile): prevent substitution of macro
- definition. fixed: http://www.yotabanana.com/lab/20060624.html#p02
-
-Sun Jul 9 07:58:48 2006 Ryan Davis <ryand@zenspider.com>
+Mon Jul 10 10:54:14 2006 Ryan Davis <ryand@zenspider.com>
* lib/rdoc/parsers/parse_f95.rb: massive overhaul from Yasuhiro
Morikawa including new file suffixes, function support, public
@@ -15054,33 +6494,44 @@ Sun Jul 9 07:58:48 2006 Ryan Davis <ryand@zenspider.com>
* lib/pp.rb: minor clarification on exception.
-Sun Jul 9 00:54:11 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jul 10 09:29:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (next_jump): deal with destination of next.
- fixed: [ruby-core:08169]
+ * eval.c (rb_clear_cache_for_undef): clear entries for included
+ module. fixed: [ruby-core:08180]
+
+Mon Jul 10 01:48:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * st.h (st_data_t): use pointer sized integer for st_data_t.
+ [ruby-dev:28988]
-Fri Jul 7 17:49:16 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jul 9 18:06:47 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_ord): extract lower byte. fixed: [ruby-dev:28980]
+ * lib/mkmf.rb (try_constant): fix for value 1 at cross compiling.
- * lib/jcode.rb (String#succ!): fix for 1.9. fixed: [ruby-dev:28979]
+ * lib/mkmf.rb (create_makefile): prevent substitution of macro
+ definition. fixed: http://www.yotabanana.com/lab/20060624.html#p02
-Fri Jul 7 14:05:03 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jul 9 00:54:34 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/Makefile.sub (config.h): define FUNC_STDCALL/FUNC_CDECL.
- from [ruby-dev:28970].
+ * eval.c (next_jump): deal with destination of next.
+ fixed: [ruby-core:08169]
Fri Jul 7 00:38:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (rb_hash_default): should not call default procedure if
no key is given. [ruby-list:42541]
-Thu Jul 6 23:30:04 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jul 7 00:29:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_mload): a patch from Daniel Berger
+ <Daniel.Berger at qwest.com>. [ruby-core:08128]
+
+Thu Jul 6 22:21:57 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (rb_proc_times): use sysconf(_SC_CLK_TCK) value prior to
HZ and CLK_TCK. fixed: [ruby-talk:200293]
-Thu Jul 6 21:50:06 2006 Minero Aoki <aamine@loveruby.net>
+Thu Jul 6 22:17:21 2006 Minero Aoki <aamine@loveruby.net>
* ext/racc/cparse/cparse.c: sync with original code, rev 1.8.
@@ -15090,30 +6541,6 @@ Thu Jul 6 21:50:06 2006 Minero Aoki <aamine@loveruby.net>
* lib/racc/parser.rb: update coding style.
-Wed Jul 5 05:28:45 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (block_param): should allow block argument after splat
- and post splat args.
-
-Wed Jul 5 01:12:19 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * test/ruby/test_lambda.rb (TestLambdaParameters::test_lambda_as_iterator):
- -> style block no longer available. [ruby-dev:28958]
-
-Tue Jul 4 21:48:56 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ruby.c (proc_options): supress warning on DOSISH.
-
-Tue Jul 4 15:12:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_call): should not set prot_tag->blkid since it would
- never catch breaks at this level. [ruby-dev:28922]
-
-Tue Jul 4 04:48:36 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c: ruby 1.9 HEAD 64 bit warnings clean up from
- <ville.mattila at stonesoft.com>. [ruby-core:08120]
-
Mon Jul 3 19:04:38 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tcltklib.c (ip_make_menu_embeddable): help to make a menu
@@ -15136,15 +6563,6 @@ Mon Jul 3 14:42:06 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
from int, and sys/types.h needs to be included before grp.h.
fixed: [ruby-dev:28938]
-Mon Jul 3 10:44:01 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (popen_exec): close file descriptors other than standard I/Os.
- fixed: [ruby-dev:28924]
-
-Mon Jul 3 05:15:29 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * test/openssl/test_asn1.c: String#[]= doesn't accept Integer.
-
Mon Jul 3 01:14:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_inspect): encode \b (\010) for escape.
@@ -15152,34 +6570,15 @@ Mon Jul 3 01:14:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_dump): ditto.
-Sun Jul 2 19:03:30 2006 Minero Aoki <aamine@loveruby.net>
-
- * ext/racc/cparse/cparse.c: sync with original code, rev 1.7.
-
- * ext/racc/cparse/cparse.c: must require version.h to get
- RUBY_VERSION_CODE.
-
-Sun Jul 2 18:42:27 2006 Minero Aoki <aamine@loveruby.net>
+Sun Jul 2 19:17:56 2006 Minero Aoki <aamine@loveruby.net>
- * ext/racc/cparse/cparse.c: sync with original source code, rev
- 1.6.
+ * ext/racc/cparse/cparse.c: sync with original code (rev 1.7).
- * ext/racc/cparse/cparse.c: do not use rb_iterate to give a block
- to the method, use rb_block_call instead. [ruby-dev:28445]
-
-Sun Jul 2 11:22:03 2006 Tanaka Akira <akr@m17n.org>
-
- * io.c (io_reopen): STDOUT.reopen(filename, "w+") didn't work.
- (rb_io_reopen): STDOUT.reopen(File.open(filename, "w+")) didn't work.
-
-Sat Jul 1 23:55:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (PUSH_FRAME): initialize frame->self. [ruby-dev:28911]
-
-Sat Jul 1 17:00:42 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * test/webrick/utils.rb: use Proc#yield instead of Proc#call.
- [ruby-dev:28914]
+ * ext/racc/cparse/cparse.c: use rb_catch instead of rb_iterate.
+ Giving a block to a Ruby-level method by rb_iterate is obsolete on
+ Ruby 1.9. Note that current cparse.c still includes one
+ rb_iterate call on Ruby 1.8, but it is not a problem (at least
+ just now).
Sat Jul 1 15:15:49 2006 Tanaka Akira <akr@m17n.org>
@@ -15195,34 +6594,6 @@ Fri Jun 30 23:46:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in: -shared patch from Andrew Morrow
<andrew.c.morrow at gmail.com>. [ruby-core:08100]
-Fri Jun 30 19:35:41 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils._escape): should
- use String#ord to get ascii code from the one-character string.
- [ruby-dev:28901]
-
-Thu Jun 29 23:56:01 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (gc_mark_children): a bug in NODE_BLOCK_PASS marking.
- [ruby-dev:28908]
-
-Thu Jun 29 23:04:36 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y: use ARGSPUSH instead of ARGSCAT to prevent too much
- splat expansion.
-
- * eval.c (when_check): need to handle ARGSPUSH as well.
-
- * eval.c (block_orphan): lambda and proc from method are always
- orphan.
-
- * gc.c (gc_mark_children): proper marking for NODE_LAMBDA.
-
-Thu Jun 29 22:47:30 2006 Tanaka Akira <akr@m17n.org>
-
- * eval.c (SETUP_ARGS0): avoid GC problem.
- [ruby-dev:28902]
-
Thu Jun 29 18:58:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c (BigDecimal_version): fix patch
@@ -15233,51 +6604,16 @@ Thu Jun 29 18:00:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/bigdecimal/bigdecimal.c: add RDoc document. a patch from
mathew <meta at pobox.com>. [ruby-core:07050]
-Wed Jun 28 14:53:09 2006 Eric Hodel <drbrain@segment7.net>
+Wed Jun 28 15:47:14 2006 Eric Hodel <drbrain@segment7.net>
* lib/optparse.rb: RDoc patch from Robin Stocker <robin@nibor.org>
[ruby-core:08087]
-Wed Jun 28 23:23:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_cstr_to_dbl): underscores should appear only
- between digits. [ruby-dev:28891]
-
Wed Jun 28 19:04:34 2006 Tanaka Akira <akr@m17n.org>
* test/socket/test_unix.rb: test_seqpacket_pair removed.
[ruby-dev:28846]
-Wed Jun 28 13:51:21 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (when_check): arbitrary values are allowed after splats.
- fixed: [ruby-dev:28879]
-
-Wed Jun 28 09:16:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (primary): remove meaningless else-only case statement
- syntax.
-
-Wed Jun 28 08:08:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_eval): problem to handle else part. [ruby-dev:28873]
-
-Wed Jun 28 01:48:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_eval): support splat in when expression list.
- [ruby-dev:28822]
-
- * eval.c (when_check): a new auxiliary function for case match.
-
- * eval.c (when_cond): ditto.
-
-Wed Jun 28 01:05:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_cstr_to_dbl): should not skip '_' at the beginning
- of a string. [ruby-dev:28830]
-
- * bignum.c (rb_cstr_to_inum): ditto.
-
Tue Jun 27 23:03:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c: RDoc update for =~ method. a patch from Alex Young
@@ -15290,17 +6626,6 @@ Tue Jun 27 22:47:18 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb (tk_tcl2ruby): [bug fix] sometimes fail to convert
a tcl string to a ruby object if the tcl string includes "\n".
-Tue Jun 27 20:05:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (pipe_open): backout unnecessary fix on 2006-06-26.
- [ruby-dev:28865]
-
- * eval.c (rb_yield_0): exact argument number check now done only
- for lambda Proc.
-
- * eval.c (rb_yield_0): add check for number of arguments, if
- there's one lambda block parameter.
-
Tue Jun 27 16:04:05 2006 WATANABE Hirofumi <eban@ruby-lang.org>
* win32/win32.h: define isascii on MinGW for msvcrt compatibility.
@@ -15313,246 +6638,297 @@ Tue Jun 27 11:36:02 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/etc/etc.c (setup_passwd, setup_group): allow bignum uid, gid and
so on. [ruby-talk:199102]
-Tue Jun 27 10:46:53 2006 Tanaka Akira <akr@m17n.org>
-
- * eval.c (rb_yield_0): avoid core dump. [ruby-dev:28840]
-
-Mon Jun 26 11:03:00 2006 Eric Hodel <drbrain@segment7.net>
-
- * lib/rdoc/ri: Add options to limit the ri search path.
-
-Tue Jun 27 01:31:59 2006 Tanaka Akira <akr@m17n.org>
-
- * ext/socket/socket.c (bsock_recv_nonblock): new method
- BasicSocket#recv_nonblock.
- (udp_recvfrom_nonblock): renamed from ip_recvfrom_nonblock.
- IPSocket#recvfrom_nonblock is moved to UDPSocket#recvfrom_nonblock.
- (unix_recvfrom_nonblock): removed.
- UNIXSocket#recvfrom_nonblock is removed.
-
-Tue Jun 27 00:52:40 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jun 26 13:37:27 2006 Eric Hodel <drbrain@segment7.net>
- * ext/ripper/eventids2.c (token_assoc): added tCHAR, which is not
- under 256 now. fixed: [ruby-dev:28832]
+ * lib/rdoc: Merge from HEAD.
+ Add options to limit the ri search path.
-Mon Jun 26 23:42:57 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Jun 27 00:54:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (call_trace_func): no check for argument number of the
- callback. fixed: [ruby-dev:28812]
+ * util.c (powersOf10): constified.
Mon Jun 26 18:37:44 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tcltklib.c (ip_delete): fix SEGV when a slave-ip is
deleted on callback.
-Mon Jun 26 15:40:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (sock_accept): revert to avoid ambiguity of
- argument evaluation order. [ruby-dev:28861]
-
- * ext/socket/socket.c (sock_accept_nonblock): ditto.
-
Mon Jun 26 10:47:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (pipe_open): avoid closing uninitialized file descriptors.
a patch from <tommy at tmtm.org> [ruby-dev:28600]
+Mon Jun 26 09:56:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.[ch] (rb_w32_send, rb_w32_sendto): constified.
+
Sun Jun 25 23:02:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, mkconfig.rb: catch-up for latest autoconf.
-Sun Jun 25 17:44:16 2006 Tanaka Akira <akr@m17n.org>
+Sat Jun 24 06:35:00 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (paren_args): wrap $2 by escape_Qundef because it may be
- Qundef. [ruby-dev:28843]
+ * signal.c: revert last change.
-Sun Jun 25 17:18:33 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * ruby.h: ditto.
- * ext/win32ole/win32ole.c(ole_invoke): support some kind of
- method of word. [ruby-Bugs#3237]
+ * eval.c: ditto.
- * test/win32ole/test_word.rb: ditto.
+Thu Jun 22 11:52:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Jun 24 23:48:08 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/net/http.rb (Net::HTTPResponse): duplicated error 501;
+ HTTPInternalServerError should be error 500. [ruby-core:08037]
- * parse.y: replace terminal token names with more descriptive
- name, i.e. kEND to keyword_end. [ruby-list:42477]
+Thu Jun 22 05:15:58 2006 Tanaka Akira <akr@m17n.org>
-Sat Jun 24 23:37:41 2006 Tanaka Akira <akr@m17n.org>
+ * ext/socket/socket.c (sock_s_socketpair): try GC only once.
+ [ruby-dev:28778]
- * eval.c (rb_eval): use rb_ary_new2 instead of rb_ary_new4 to avoid
- GC problem.
- (rb_yield_values): use rb_ary_new2 instead of rb_ary_new4.
+Wed Jun 21 21:28:32 2006 Tadayoshi Funaba <tadf@dotrb.org>
- * array.c (rb_ary_new4): don't set len as n if contents is not
- initialized. make it safe with GC.
+ * lib/date.rb (jd_to_commercial): now works fine even if in
+ mathn-ized context.
- [ruby-dev:28826]
+Wed Jun 21 17:32:31 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Fri Jun 23 23:35:32 2006 Tanaka Akira <akr@m17n.org>
+ * signal.c (ruby_nativethread_signal, posix_nativethread_signal,
+ sigsend_to_ruby_thread, install_nativethread_sighandler):
+ nativethread-support on signal handler (backport from 1.9).
- * ruby.h, lib/drb/drb.rb, lib/drb/invokemethod.rb: remove Values class.
- [ruby-dev:28805]
+ * ruby.h (HAVE_NATIVETHREAD_KILL): ditto.
-Fri Jun 23 17:27:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (ruby_native_thread_kill): ditto.
- * eval.c (rb_block_pass): removed.
+Wed Jun 21 08:39:54 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_thread_start_1): use rb_proc_yield() instead of
- rb_block_pass(). fixed: [ruby-dev:28794]
+ * lib/xmlrpc/create.rb (XMLRPC::Create::conv2value): merge Date
+ and Time processing. [ruby-core:08033]
-Thu Jun 22 11:52:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Jun 21 01:40:25 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/http.rb (Net::HTTPResponse): duplicated error 501;
- HTTPInternalServerError should be error 500. [ruby-core:08037]
+ * parse.y (yylex, reswords): modifier token is no longer returned in
+ fname state. [ruby-dev:28775]
-Thu Jun 22 11:47:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Jun 21 01:12:46 2006 Kouhei Sutou <kou@cozmixng.org>
- * variable.c (rb_mod_name): returns nil for anonymous modules.
- [ruby-talk:198440]
+ * lib/rss/rss.rb: RSS::Element.def_corresponded_attr_writer
+ supported date type.
-Thu Jun 22 10:31:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Jun 20 22:08:36 2006 Kouhei Sutou <kou@cozmixng.org>
- * string.c (rb_str_aref): "abc"[3] should not return an empty
- string but nil. [ruby-dev:28786]
+ * test/rss/test_parser.rb: split parser tests into ...
+ * test/rss/test_parser_1.0.rb: ... RSS 1.0 parsing tests and ...
+ * test/rss/test_parser_2.0.rb: ... RSS 2.0 parsing tests.
-Thu Jun 22 05:15:58 2006 Tanaka Akira <akr@m17n.org>
+Tue Jun 20 21:19:06 2006 Kouhei Sutou <kou@cozmixng.org>
- * ext/socket/socket.c (sock_s_socketpair): try GC only once.
- [ruby-dev:28778]
+ * lib/rss/rss.rb: provided default RSS::Element#children.
-Wed Jun 21 21:20:31 2006 Tadayoshi Funaba <tadf@dotrb.org>
+ * lib/rss/0.9.rb: used default RSS::Element#children.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
- * lib/date.rb (jd_to_commercial): now works fine even if in
- mathn-ized context.
+Tue Jun 20 21:04:33 2006 Kouhei Sutou <kou@cozmixng.org>
-Wed Jun 21 17:29:57 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * lib/rss/rss.rb: provided default RSS::Element#_tags.
- * ext/socket/getaddrinfo.c (freeaddrinfo, get_name): fixed typo.
+ * lib/rss/0.9.rb: used default RSS::Element#_tags.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
- * ext/tk/tcltklib.c (tcl_eval, tcl_global_eval): ditto.
+Tue Jun 20 20:47:07 2006 Kouhei Sutou <kou@cozmixng.org>
- * ext/zlib/zlib.c (rscheck): constified.
+ * lib/rss/rss.rb: hide RSS::Element.install_model.
+ (RSS::Element.install_have_child_element,
+ RSS::Element.install_have_children_element,
+ RSS::Element.install_text_element,
+ RSS::Element.install_date_element): call
+ RSS::Element.install_model internally.
-Wed Jun 21 17:18:55 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/0.9.rb: followed new API.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/content.rb: ditto.
+ * lib/rss/dublincore.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/syndication.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
- * lib/pp.rb (PP::PPMethods::seplist): should have preserved
- original reference to the array. [ruby-dev:28747]
+Tue Jun 20 20:18:05 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Wed Jun 21 14:35:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/openssl/extconf.rb: add check for OBJ_NAME_do_all_sorted.
- * parse.y (block_param): do not use multiple assignment for a sole
- block parameter. [ruby-dev:28710]
+ * ext/openssl/ossl_cipher.c (ossl_s_ciphers): new method
+ OpenSSL::Cipher.ciphers. it returns all the cipher names.
- * eval.c (rb_yield_0): pass a raw yielded value to a sole block
- parameter if a value is passed by yield.
+ * ext/openssl/lib/openssl/cipher.rb:
+ - add constants AES128, AES192, AES256. [ruby-dev:28610]
+ - reimplement without eval()
- * eval.c (proc_invoke): args may not be an array.
+ * ext/openssl/lib/openssl/digest.rb: reimplement without eval().
- * eval.c (rb_proc_yield): pass original value without wrapping
- it in an array.
+ * test/openssl/test_cipher.rb, test_digest: fix about reimplemented
+ features.
-Wed Jun 21 14:06:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * sample/openssl/cipher.rb: rewrite all.
- * parse.y (method_call): remove (fn)(args) style lambda
- invocation, add fn.(args) instead.
+Sat Jun 19 11:21:46 2006 Eric Hodel <drbrain@segment7.net>
-Wed Jun 21 08:39:54 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/test/unit/assertions.rb: Merge RDoc from HEAD.
- * lib/xmlrpc/create.rb (XMLRPC::Create::conv2value): merge Date
- and Time processing. [ruby-core:08033]
+Tue Jun 20 01:06:57 2006 Kouhei Sutou <kou@cozmixng.org>
-Wed Jun 21 03:01:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/rss.rb:
+ - cleanup validation mechanism. Now, #XXX_validation is
+ needless.
+ - changed internal variable name RSS::Element::MODEL to
+ RSS::Element::MODELS.
+ - RSS::Element.install_model requires uri.
- * eval.c, file.c, etc.: code-cleanup patch from Stefan Huehner
- <stefan at huehner.org>. [ruby-core:08029]
+ * lib/rss/0.9.rb: followed new validation API.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/content.rb: ditto.
+ * lib/rss/dublincore.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/syndication.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
-Wed Jun 21 01:40:25 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jun 19 23:40:59 2006 NARUSE, Yui <naruse@ruby-lang.org>
- * parse.y (reswords): modifier token is no longer returned in fname
- state. fixed: [ruby-dev:28775]
+ * ext/nkf/lib/kconv.rb: remove default -m0 and fix document.
-Tue Jun 20 23:28:34 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/nkf/nkf-8/{nkf.c, config.h, utf8tbl.c, utf8tbl.h}:
+ imported nkf 2.0.7.
- * ext/extmk.rb (parse_args): provisional catch-up for the recent changes.
+Mon Jun 19 22:31:59 2006 Kouhei Sutou <kou@cozmixng.org>
- * lib/optparse.rb (OptionParser::List#summarize, OptionParser#order!): ditto.
+ * lib/rss/rss.rb:
+ - provided default #to_s as RSS::Element#to_s.
+ - removed RSS::Element#other_element.
+ - RSS::Element#tag requires attributes as Hash instead of Array.
-Tue Jun 20 11:07:55 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/0.9.rb: removed #to_s to use RSS::Element#to_s.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
- * eval.c (proc_invoke): intercept break and return from lambda
- Proc objects. [ruby-dev:28742]
+ * lib/rss/2.0.rb: removed #other_element.
- * eval.c (proc_invoke): remove unnecessary YIELD_PROC_CALL flag.
+Mon Jun 19 22:09:16 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * eval.c (YIELD_EXACT_ARGS): renamed from YIELD_LAMBDA_CALL, which
- is no longer related to the behavior turned on by this flag.
+ * ext/win32ole/win32ole.c(ole_invoke): support some kind of
+ method of word. [ruby-Bugs#3237]
- * eval.c (return_jump): no need to care about PROT_YIELD.
+ * ext/win32ole/tests/test_word.rb: ditto.
- * eval.c (break_jump): no jump to toplevel PROT_THREAD tag.
+ * ext/win32ole/tests/testall.rb: ditto.
- * eval.c (rb_yield_0): fix confusion between lambda (which is a
- property of a proc) and pcall (which depends on whether it's
- called via yield or call).
+Mon Jun 19 00:02:17 2006 Kouhei Sutou <kou@cozmixng.org>
- * eval.c (rb_thread_yield): no need to specify YIELD_LAMBDA_CALL.
+ * lib/rss/rss.rb: automatically detected attributes.
- * eval.c (rb_block_pass): update blkid in prot_tag.
+ * lib/rss/0.9.rb: removed #_attrs.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
-Mon Jun 19 23:40:59 2006 NARUSE, Yui <naruse@ruby-lang.org>
+ * lib/rss/parser.rb: followed new internal API.
- * ext/nkf/lib/kconv.rb: remove default -m0 and fix document.
+Mon Jun 19 00:00:17 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/nkf/nkf-8/{nkf.c, config.h, utf8tbl.c, utf8tbl.h}:
- imported nkf 2.0.7.
+ * ext/tk/lib/multi-tk.rb: fix bug: initialize improper tables.
-Mon Jun 19 17:02:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 18 22:36:13 2006 Kouhei Sutou <kou@cozmixng.org>
- * sample/test.rb (proc_return3): return within non lambda block
- should terminate surrounding method. [ruby-dev:28741]
+ * lib/rss/rss.rb: RSS::Element#initialize accepts initial
+ attributes.
+ * lib/rss/0.9.rb: ditto.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/dublincore.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
-Mon Jun 19 13:22:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/utils.rb: added Utils.element_initialize_arguments? to
+ detect backward compatibility initial arguments.
- * ext/socket/socket.c (unix_sysaccept): typo fixed.
+ * lib/rss/parser.rb: user initial attributes to initialize
+ RSS::Element.
- * ext/socket/socket.c (sock_connect): remove an unused local
- variable tmpaddr.
+Sun Jun 18 18:24:42 2006 Kouhei Sutou <kou@cozmixng.org>
-Mon Jun 19 02:10:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/converter.rb: use NKF for Uconv fallback.
- * ext/socket/socket.c (tcp_accept_nonblock): forgot to remove
- abandoned hacks. [ruby-dev:28740]
+Sun Jun 18 18:22:04 2006 Kouhei Sutou <kou@cozmixng.org>
-Mon Jun 19 00:00:17 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * test/rss/test_image.rb: shared name space configuration.
- * ext/tk/lib/multi-tk.rb: fix bug: initialize improper tables.
+Sun Jun 18 18:13:25 2006 Kouhei Sutou <kou@cozmixng.org>
-Sun Jun 18 20:28:43 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * lib/rss/rss.rb: improved ignore_unknown_element
+ handling. RSS::NotExpectedTagError provides tag URI.
+ * lib/rss/parser.rb: ditto.
+ * lib/rss/0.9.rb: ditto.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/content.rb: ditto.
+ * lib/rss/dublincore.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/syndication.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
- * ext/win32ole/win32ole.c (fole_methods): The return value
- of WIN32OLE#ole_methods should include PROPERTYPUTREF methods.
+ * test/rss/rss-assertions.rb: checked URI of not expected tag too.
+ * test/rss/test_parser.rb: ditto.
- * ext/win32ole/win32ole.c (fole_put_methods): The return value
- of WIN32OLE#ole_put_methods should include PROPERTYPUTREF methods.
+Sun Jun 18 18:08:36 2006 Kouhei Sutou <kou@cozmixng.org>
- * test/win32ole/test_ole_methods.rb: ditto.
+ * lib/rss/rss.rb: changed empty namespace URI representation to ""
+ from nil.
+ * lib/rss/parser.rb: ditto.
+ * lib/rss/0.9.rb: ditto.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
- * ext/win32ole/win32ole.c (ole_propertyput): support
- PROPERTYPUTREF. [ruby-talk:183042]
+Sun Jun 18 18:03:50 2006 Kouhei Sutou <kou@cozmixng.org>
- * test/win32ole/test_propertyputref.rb: ditto.
+ * lib/rss/parser.rb: removed a guard for requiring open-uri.
-Sat Jun 17 23:42:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jun 18 18:01:26 2006 Kouhei Sutou <kou@cozmixng.org>
- * eval.c (Init_eval): add aliases invoke_method and
- invoke_functional_method corresponding send and funcall
- respectively. [ruby-talk:197512]
+ * lib/rss/rss.rb: fixed typo: except -> expect
+ * lib/rss/parser.rb: ditto.
+ * test/rss/rss-assertions.rb: ditto.
+ * test/rss/test_parser.rb: ditto.
- * parse.y (parser_yylex): returns the most typical keyword token
- on EXPR_FNAME. [ruby-core:7995]
+Sun Jun 18 17:52:39 2006 Kouhei Sutou <kou@cozmixng.org>
- * ext/socket/socket.c: protoize.
+ * lib/rss/rss.rb: RSS::Element#calc_indent became to be deprecated.
+ * lib/rss/0.9.rb: ditto.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/taxonomy.rb: ditto.
+ * lib/rss/trackback.rb: ditto.
+
+ * test/rss/test_1.0.rb: removed RSS::Element.indent_size tests.
+ * test/rss/test_2.0.rb: ditto.
+
+Sun Jun 18 00:49:11 2006 Tanaka Akira <akr@m17n.org>
+
+ * ext/socket/socket.c (bsock_recv_nonblock): new method
+ BasicSocket#recv_nonblock.
+ (udp_recvfrom_nonblock): renamed from ip_recvfrom_nonblock.
+ IPSocket#recvfrom_nonblock is moved to UDPSocket#recvfrom_nonblock.
+ (unix_recvfrom_nonblock): removed.
+ UNIXSocket#recvfrom_nonblock is removed.
Sat Jun 17 22:17:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -15561,147 +6937,227 @@ Sat Jun 17 22:17:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
Sat Jun 17 14:53:32 2006 Tanaka Akira <akr@m17n.org>
- * lib/pathname.rb (Kernel#Pathname): new method.
+ * lib/pathname.rb: backport from 1.9.
+ (Kernel#Pathname): new method.
-Sat Jun 17 02:01:00 2006 Tanaka Akira <akr@m17n.org>
+Sat Jun 17 10:30:41 2006 Kouhei Sutou <kou@cozmixng.org>
- * lib/pp.rb (Kernel#pretty_inspect): defined for pretty printed
- string.
+ * lib/rss/rss.rb (Hash#merge, Enumerable#sort_by): removed.
-Fri Jun 16 01:41:00 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/rss/rss.rb (RSS::RootElementMixin#to_xml): added.
+ [ruby-talk:197284]
- * eval.c (rb_proc_arity): get rid of segfault for mere splat.
+ We can convert RSS version easily like the following:
+ rss10 = RSS::Parser.parse(File.read("1.0.rdf"))
+ File.open("2.0.rss", "w") {|f| f.print(rss10.to_xml("2.0"))}
- * gc.c (gc_mark_children): NODE_BLOCK_PASS needs u3 to be marked.
+ * test/rss/test_1.0.rb: added #to_xml test.
+ * test/rss/test_2.0.rb: ditto.
-Thu Jun 15 22:06:56 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * test/rss/rss-testcase.rb: added some helper methods that
+ generates sample RSS 2.0.
- * parse.y (then): remove ':' from 'then' and 'do' rules.
+ * sample/rss/convert.rb: added a sample script to convert RSS format.
-Wed Jun 14 18:00:20 2006 Eric Hodel <drbrain@segment7.net>
+Sat Jun 17 10:23:22 2006 Kouhei Sutou <kou@cozmixng.org>
- * enum.c (enum_any): Documentation typo.
+ * lib/rss/rss.rb (Kernel#funcall): removed.
+ * lib/rss/parser.rb (Kernel.URI): removed.
-Wed Jun 14 15:01:09 2006 Eric Hodel <drbrain@segment7.net>
+ * lib/rss/maker/: supported
+ xxx.new_yyy do |yyy|
+ yyy.zzz = zzz
+ ...
+ end
+ style and this style became the style of the recommendation.
- * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser#warn): Don't print
- warnings when -q is set.
+ Old style
+ yyy = xxx.new_yyy
+ yyy.zzz = zzz
+ ...
+ is supported too but this style isn't recommended.
+ [ruby-talk:197284]
-Wed Jun 14 16:11:37 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * test/rss/test_*maker*.rb: used new recommended style.
- * eval.c (rb_f_method_name, rb_f_callee_name): document typo.
+Sat Jun 17 09:03:47 2006 Kouhei Sutou <kou@cozmixng.org>
-Wed Jun 14 15:19:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss, test/rss: backported from trunk. (2005-11-16 - now)
- * hash.c (env_aset): raise TypeError on nil with more descriptive
- message. [ruby-core:07990]
+ * lib/rss/rss.rb (RSS::VERSION): 0.1.5 -> 0.1.6.
+ * test/rss/test_version.rb (RSS::TestVersion#test_version): ditto.
-Tue Jun 13 17:22:19 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/trackback.rb: added TrackBack prefix.
+ * lib/rss/maker/trackback.rb: ditto.
- * ext/socket/socket.c (Init_socket): remove obsolete constants:
- IPsocket, TCPsocket, SOCKSsocket, TCPserver, UDPsocket,
- UNIXsocket, UNIXserver.
+ * lib/rss/rss.rb : removed needless argument 'prefix'.
+ * lib/rss/parser.rb: ditto.
-Tue Jun 13 09:07:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/1.0.rb: added rdf:Bag.
- * eval.c (formal_assign): post splat arguments should have had
- higher priority than optional arguments, since they are
- mandatory. [ruby-dev:28715]
+ * lib/rss/taxonomy.rb: implemented taxonomy module.
+ * test/rss/test_taxonomy.rb: added tests for taxonomy support.
- * eval.c (VIS_MASK): broken. should be 15. [ruby-dev:28715]
+ * lib/rss/1.0.rb: added convenience method 'resources'.
+ * lib/rss/taxonomy.rb: ditto.
+ * test/rss/rss-assertions.rb: added test for 'resources'.
+ * test/rss/test_taxonomy.rb: ditto.
- * io.c (argf_getc): should return one-character string.
- [ruby-dev:28715]
+ * lib/rss/rss.rb: fixed a indentation bug.
+ * lib/rss/taxonomy.rb: fixed <taxo:topic> #to_s bug.
+ * test/rss/test_taxonomy.rb: added a #to_s test.
- * io.c (rb_io_readchar): ditto.
+ * lib/rss/maker/taxonomy.rb: implemented taxonomy module for RSS
+ Maker.
+ * lib/rss/taxonomy.rb: supported RSS Maker.
+ * lib/rss/maker.rb: added taxonomy module support.
-Sun Jun 11 23:20:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/rss/rss.rb: adjusted to other element API.
+ * lib/rss/1.0.rb: adjusted to other element API but backward
+ compatibility is reserved.
+ * lib/rss/0.9.rb: ditto.
- * object.c (sym_call): disallow to call private methods.
+ * test/rss/test_maker_taxo.rb: added test case for taxonomy module
+ for RSS Maker.
+ * test/rss/test_setup_maker_1.0.rb: added tests for taxo:topic.
- * lib/optparse.rb (OptionParser::Arguable#getopts): pass self to the
- parser.
+ * test/rss/test_setup_maker_1.0.rb: added backward compatibility
+ test.
+ * test/rss/test_setup_maker_0.9.rb: ditto.
+ * test/rss/test_setup_maker_2.0.rb: ditto.
-Sun Jun 11 09:56:41 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * test/rss/rss-testcase.rb: added convenience method for setting
+ up taxo:topic.
+ * test/rss/rss-assertions.rb: added assertion for taxo:topic.
- * win32/win32.h (write): not need to define on bcc.
+ * sample/rss/blend.rb: followed new API.
-Sun Jun 11 08:30:33 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/rss/taxonomy.rb: changed class or module prefix to
+ Taxonomy from Taxo.
+ * lib/rss/maker/taxonomy.rb: ditto.
- * lib/optparse.rb (OptionParser#getopts): new methods.
+ * test/rss/test_taxonomy.rb: use #reject directory.
-Sun Jun 11 07:27:11 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * lib/rss/: use #__send__ instead of #send.
+ * test/rss/: ditto.
- * lib/rdoc/ri/ri_writer.rb: use String#ord.
+ * lib/rss/parser.rb: added entity handling type predicate.
+ * lib/rss/rexmlparser.rb: ditto.
+ * lib/rss/xmlparser.rb: ditto.
+ * lib/rss/xmlscanner.rb: ditto.
-Sun Jun 11 04:38:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/rss/xmlscanner.rb: more robust entity handling.
- * object.c (sym_to_proc): imported Symbol#to_proc from ActiveSupport.
+ * test/rss/test_parser.rb: added an entity handling test.
-Sat Jun 10 18:02:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * test/rss/test_2.0.rb: added RSS 2.0 tests.
+ * test/rss/rss-assertions.rb: extended XML stylesheet assertion.
+ * lib/rss/0.9.rb: added initialize method.
+ * test/rss/test_1.0.rb: cleanup.
- * ext/bigdecimal/lib/bigdecimal/newton.rb (Newton::nlsolve): typo
- fixed: raize -> raise. [ruby-talk:196608]
+ * lib/rss/image.rb: added Image prefix.
+ * lib/rss/maker/image.rb: ditto.
-Sat Jun 10 17:49:53 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/rss.rb: improved type conversion.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/0.9.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/syndication.rb: ditto.
- * string.c (rb_str_ord): new method.
+ * test/rss/test_2.0.rb: added type conversion tests.
+ * test/rss/test_accessor.rb: ditto.
+ * test/rss/test_to_s.rb: ditto.
+ * test/rss/test_syndication.rb: ditto.
+ * test/rss/test_setup_maker_2.0.rb: ditto.
+ * test/rss/test_setup_maker_1.0.rb: ditto.
+ * test/rss/test_setup_maker_0.9.rb: ditto.
+ * test/rss/test_maker_sy.rb: ditto.
+ * test/rss/test_maker_image.rb: ditto.
+ * test/rss/test_maker_2.0.rb: ditto.
+ * test/rss/test_maker_0.9.rb: ditto.
+ * test/rss/test_image.rb: ditto.
- * parse.y (rbracket): allow optional newline before closing
- brackets.
+ * test/rss/test_maker_1.0.rb: use assert instead of assert_equal.
-Sat Jun 10 15:12:29 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * test/rss/rss-assertions.rb: improved type conversion assertions.
- * eval.c (rb_f_method_name, rb_f_callee_name): new functions.
- new global method `__method__' and `__callee__'.
+ * lib/rss/rss.rb: added backward compatibility codes.
+ * lib/rss/parser.rb: ditto.
+ * test/rss/test_parser.rb: ditto.
+ * test/rss/test_2.0.rb: ditto.
-Sat Jun 10 10:13:13 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Sat Jun 17 02:01:00 2006 Tanaka Akira <akr@m17n.org>
- * lib/getoptlong.rb (GetoptLong#set_options): receive arguments
- as Array.
+ * lib/pp.rb (Kernel#pretty_inspect): defined for pretty printed
+ string.
- * lib/irb/slex.rb: use Proc#yield.
+Sat Jun 17 00:23:58 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rdoc/markup/simple_markup/inline.rb: follow the new behavior
- of String#[].
+ * parse.y (reswords): kDO_BLOCK was missing. fixed: [ruby-core:7995]
- * lib/rdoc/ri/ri_writer.rb: ditto.
+Sat Jun 17 00:02:15 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Sat Jun 10 08:17:23 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/win32ole/win32ole.c (ole_propertyput): support
+ PROPERTYPUTREF. [ruby-talk:183042]
- * math.c (log2): may be a macro.
+ * ext/win32ole/tests/test_propertyputref.rb: ditto.
- * parse.y (args, block_param, f_args): pass f_post_arg to #params.
+Thu Jun 15 23:02:47 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * util.c (powersOf10): constified.
+ * ext/win32ole/win32ole.c (fole_methods): The return value
+ of WIN32OLE#ole_methods should include PROPERTYPUTREF methods.
- * ext/readline/readline.c: include extconf.h first.
+ * ext/win32ole/win32ole.c (fole_put_methods): The return value
+ of WIN32OLE#ole_put_methods should include PROPERTYPUTREF methods.
+
+ * ext/win32ole/tests/test_ole_methods.rb: ditto.
+
+ * ext/win32ole/tests/testall.rb : ditto.
+
+Wed Jun 14 18:23:28 2006 Eric Hodel <drbrain@segment7.net>
+
+ * enum.c (enum_any): Documentation typo.
+
+Wed Jun 14 15:01:09 2006 Eric Hodel <drbrain@segment7.net>
- * ext/ripper/eventids2.c: removed tLAMBDA_ARG.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser#warn): Don't print
+ warnings when -q is set.
+
+Wed Jun 14 23:03:53 2006 Tanaka Akira <akr@m17n.org>
- * ext/tk/tcltklib.c (lib_fromUTF8_core): removed conflict.
+ * configure.in: check sizeof(rlim_t).
+ check setrlimit.
- * ext/tk/tkutil/tkutil.c (cbsubst_get_subst_arg): rb_id2name() is
- defined as const now.
+ * process.c (proc_getrlimit): new method Process.getrlimit.
+ (proc_setrlimit): new method Process.setrlimit.
+
+ * ruby.h (NUM2ULL): new macro.
+
+Mon Jun 12 22:25:09 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (rb_f_sprintf): adjust precision length to prevent
+ splitting multi-byte characters. [ruby-list:42389]
+
+Sun Jun 11 23:20:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/win32ole/win32ole.c (fole_missing): ditto.
+ * lib/optparse.rb (OptionParser::Arguable#getopts): pass self to the
+ parser.
- * lib/mkmf.rb (create_makefile): force to create extconf header.
+Sun Jun 11 10:00:57 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/optparse.rb (order!): use Proc#yield.
+ * win32/win32.h (write): not need to define on bcc.
-Sat Jun 10 06:53:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Jun 11 08:30:33 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (CALLARGS): remove last semicolon. C90 compiler doesn't
- allow any lines (even if they're empty) within variable
- declarations.
+ * lib/optparse.rb (OptionParser#getopts): new methods.
-Fri Jun 9 09:56:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Jun 10 18:02:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sprintf.c (rb_str_format): allow %c to print one character
- string (e.g. ?x).
+ * ext/bigdecimal/lib/bigdecimal/newton.rb (Newton::nlsolve): typo
+ fixed: raize -> raise. [ruby-talk:196608]
-Thu Jun 8 14:00:02 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jun 8 14:19:17 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.[ch] (rb_w32_read, rb_w32_write): new functions.
use recv() and send() when fd is socket. fixed: [ruby-dev:28694]
@@ -15711,25 +7167,43 @@ Wed Jun 7 16:22:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
-Wed Jun 7 16:16:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Jun 7 14:53:04 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (errmap): add some winsock errors.
- * parse.y (do_block): remove -> style block.
+Wed Jun 7 11:34:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * parse.y (parser_yylex): remove tLAMBDA_ARG.
+ * configure.in: add new configure option `--with-winsock2' for mingw.
-Wed Jun 7 14:51:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+ * win32/Makefile.sub (config.h): define USE_WINSOCK2 in config.h
+ instead of in CPPFLAGS.
- * win32/win32.c (errmap): add some winsock errors.
+ * ext/socket/extconf.rb: determine whether to use winsock2 or not
+ by using with_config.
+
+Wed Jun 7 10:45:10 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/{configure.bat, setup.mak, Makefile.sub, win32.h}: add
+ new configure option `--with-winsock2'.
+
+ * win32/win32.c (StartSockets): ditto.
+
+ * ext/socket/extconf.rb: ditto.
+
+ * win32/win32.c (open_ifs_socket): new function.
+
+ * win32/win32.c (StartSockets, rb_w32_socket): use open_ifs_socket()
+ instead of socket().
+ ifs socket support is backported from trunk.
Wed Jun 7 09:14:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
-Tue Jun 6 23:25:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): return behavior should depend whether it
- is surrounded by a lambda or a mere block.
+ * eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
+ event_hooks. no guarantee for arbitrary hook deletion.
+ [ruby-dev:28632]
Mon Jun 5 18:12:12 2006 Tanaka Akira <akr@m17n.org>
@@ -15743,21 +7217,12 @@ Sun Jun 4 20:40:19 2006 Tanaka Akira <akr@m17n.org>
* ext/socket/socket.c: fix sockaddr_un handling.
[ruby-dev:28677]
-Sat Jun 3 23:53:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (formal_assign): handles post splat arguments.
+Fri Jun 2 22:08:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_call0): ditto.
+ * lib/forwardable.rb: RDoc typo fix from Jan Svitok
+ <jan.svitok at gmail.com>. [ruby-core:07943]
-Sat Jun 3 13:10:41 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * st.c (strhash): use FNV-1a hash.
-
-Fri Jun 2 20:01:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): removed experimental ';;' terminator.
-
-Fri Jun 2 19:00:40 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Jun 2 19:02:09 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: use create_header.
@@ -15786,83 +7251,23 @@ Thu Jun 1 19:12:37 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (rb_w32_cmdvector): backslashes inside single-quotes
no longer has special meanings. fixed: [ruby-list:42311]
-Thu Jun 1 17:55:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_node_arity): should be aware of post splat arguments.
-
- * eval.c (rb_proc_arity): ditto.
-
-Thu Jun 1 16:17:26 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jun 1 16:14:41 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_getcwd): runtime's getcwd() will not success
if the length of the cwd is longer than MAX_PATH.
fixed [ruby-list:42335]
-Thu Jun 1 16:07:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_args): syntax rule enhanced to support arguments
- after the splat.
-
- * parse.y (mlhs_basic): ditto for multiple assignments
-
- * parse.y (block_param): ditto for block parameters.
-
- * parse.y (f_post_arg): mandatory formal arguments after the splat
- argument.
-
- * parse.y (new_args_gen): generate nodes for mandatory formal
- arguments after the splat argument.
-
- * eval.c (rb_eval): dispatch mandatory formal arguments after the
- splat argument.
-
-Thu Jun 1 11:33:32 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jun 1 11:29:14 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_getcwd): set errno if not set.
fixed [ruby-list:42346]
-Thu Jun 1 00:45:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (args): allow more than one splat in the argument list.
-
-Wed May 31 18:38:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (method_call): allow aref [] to accept all kind of
- method argument, including assocs, splat, and block argument.
-
- * eval.c (SETUP_ARGS0): prepare block argument as well.
-
-Tue May 30 18:13:53 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
-
-Mon May 29 22:40:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (error_line): print receivers true/false/nil specially.
-
- * eval.c (rb_proc_yield): handles parameters in yield semantics.
-
- * eval.c (nil_yield): gives LocalJumpError to denote no block
- error.
-
- * io.c (rb_io_getc): now takes one-character string.
-
-Sat May 27 22:46:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): save and restore block in the current frame.
- fixed: [ruby-core:07833], [ruby-talk:191639]
-
-Sat May 27 11:29:46 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat May 27 11:29:46 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): remove extinit files if no statically linked
extensions.
-Fri May 26 19:56:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
- hashing algorithm.
-
-Fri May 26 09:05:11 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri May 26 09:05:11 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* ruby.h, lib/mkmf.rb (create_header): clear command line options for
macros moved to extconf.h.
@@ -15877,7 +7282,7 @@ Fri May 26 09:05:11 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (configuration): add $defs unless extconf.h was created.
-Thu May 25 01:52:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu May 25 01:52:07 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (pkg_config): particular config commands support.
@@ -15891,27 +7296,23 @@ Thu May 25 01:52:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/setup.mak: suffix OS name by runtime version.
-Wed May 24 23:52:11 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 24 23:52:11 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* configure.in (ac_install_sh): ignore dummy install-sh.
[ruby-talk:193876]
-Wed May 24 17:55:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_aref): str[0] now returns 1 character string,
- instead of a fixnum. [Ruby2]
-
- * parse.y (parser_yylex): ?c now returns 1 character string,
- instead of a fixnum. [Ruby2]
-
- * string.c (rb_str_aset): no longer support fixnum insertion.
-
-Wed May 24 03:10:44 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Wed May 24 03:10:48 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/lib/openssl/ssl.rb
(OpenSSL::SSL::SocketForwarder#setsockopt,getsockopt): typo fixed.
-Mon May 22 16:32:03 2006 Tanaka Akira <akr@m17n.org>
+Mon May 22 17:54:12 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_recvfrom_nonblock): use rb_read_pending
+ instead of rb_io_read_pending.
+ [ruby-dev:28663]
+
+Mon May 22 17:30:04 2006 Tanaka Akira <akr@m17n.org>
* rubyio.h (rb_io_set_nonblock): declared.
@@ -15920,8 +7321,7 @@ Mon May 22 16:32:03 2006 Tanaka Akira <akr@m17n.org>
(io_read_nonblock): new method: IO#read_nonblock.
(io_write_nonblock): new method: IO#write_nonblock.
- * ext/socket/socket.c (s_accept): retry for EWOULDBLOCK.
- revert [ruby-talk:113807].
+ * ext/socket/socket.c
(sock_connect_nonblock): new method: Socket#connect_nonblock.
(sock_accept_nonblock): new method: Socket#accept_nonblock.
(sock_recvfrom_nonblock): new method: Socket#recvfrom_nonblock.
@@ -15938,33 +7338,6 @@ Mon May 22 13:38:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
-Sun May 21 09:50:31 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * regexec.c: add STK_NULL_CHECK_END to IS_TO_VOID_TARGET().
- [ruby-list:42234]
-
-Thu May 18 22:37:20 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/config.rb (WEBrick::Config::HTTP): add new parameters,
- :InputBufferSize and :OutputBufferSize.
-
- * lib/webrick/utils.rb (WEBrick::Utils.timeout): add new timeout
- method. this implementation is expected to be compatible with
- timeout.rb and faster than timeout.rb.
-
- * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#_read_data):
- Timeout.timeout is replaced by WEBrick::Utils.timeout.
-
- * lib/webrick/httprequest.rb: WEBrick::HTTPRequest::BUFSIZE is
- replaced by config[:InputBufferSize].
-
- * lib/webrick/httpresposne.rb: WEBrick::HTTPResponse::BUFSIZE is
- replaced by config[:OutputBufferSize].
-
- * lib/webrick/server.rb: get rid of unnecessary require.
-
- * test/webrick/test_utils.rb: test for WEBrick::Utils.timeout.
-
Thu May 18 17:51:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_timeval): should round for usec floating
@@ -15972,21 +7345,24 @@ Thu May 18 17:51:32 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_add): ditto.
-Thu May 18 00:42:12 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu May 18 17:11:45 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi.rb (CGI::out): support utf-8. a patch from Fujioka
+ <fuj at rabbix.jp>. [ruby-dev:28649]
+
+Thu May 18 00:42:12 2006 nobuyoshi nakada <nobu@ruby-lang.org>
* ext/extmk.rb, lib/mkmf.rb: use BUILD_FILE_SEPARATOR in Makefiles.
Wed May 17 17:55:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (sys_warning): should not call a vararg function
- rb_sys_warning() indirectly. [ruby-core:07886]
+ rb_sys_warning() indirectly. [ruby-core:07886]
-Tue May 16 17:23:19 2006 <sinara@blade.nagaokaut.ac.jp>
+Wed May 17 08:17:15 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * numeric.c (flo_divmod): the first element of Float#divmod should
- be an integer. [ruby-dev:28589]
-
- * test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
+ * util.c (ruby_strtod): try to reduce errors using powersOf10
+ table. [ruby-dev:28644]
Tue May 16 15:34:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -16004,10 +7380,6 @@ Tue May 16 09:20:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
-Mon May 15 21:37:12 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * re.c (rb_reg_prepare_re): don't use onig_recompile().
-
Mon May 15 17:42:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
@@ -16021,85 +7393,40 @@ Sat May 13 16:14:05 2006 Tanaka Akira <akr@m17n.org>
(Struct#pretty_print_cycle): ditto.
[ruby-core:7865]
-Fri May 12 15:54:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
- event_hooks. no guarantee for arbitrary hook deletion.
- [ruby-dev:28632]
-
Thu May 11 19:57:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
-Thu May 11 18:30:11 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Aug 11 15:39:25 2006 Eric Hodel <drbrain@segment7.net>
- * ext/openssl/ossl_cipher.c (add_cipher_name_to_ary): should return
- value. [ruby-dev:28627]
+ * lib/yaml/tag.rb: Replace nodoc with stopdoc so Module methods get
+ documented.
Thu May 11 18:10:43 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
-Wed May 10 23:40:21 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * oniguruma.h: Version 4.0.3
-
- * regexec.c: ditto.
-
-Mon May 8 09:10:31 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/extconf.rb: add check for OBJ_NAME_do_all_sorted.
-
- * ext/openssl/ossl_cipher.c (ossl_s_ciphers): new method
- OpenSSL::Cipher.ciphers. it returns all the cipher names.
-
- * ext/openssl/ossl_cipher.c (ossl_cipher_init): refine warning message.
-
- * ext/openssl/lib/openssl/cipher.rb: reimplement without eval() and
- add constants AES128, AES192, AES256. [ruby-dev:28610]
-
- * ext/openssl/lib/openssl/digest.rb: reimplement without eval().
-
- * test/openssl/test_cipher.rb, test_digest: fix about reimplemented
- features.
-
- * sample/openssl/cipher.rb: rewrite all.
-
Sun May 7 03:09:51 2006 Stephan Maka <stephan@spaceboyz.net>
* lib/resolv.rb (Resolv::DNS::Requester::ConnectedUDP#initialize):
Use AF_INET6 for nameservers containing colons.
-Sat May 6 23:40:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): should restore old ruby_frame->block.
- thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
- also fix [ruby-dev:28614] as well.
-
Sat May 6 00:38:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
-Thu May 4 22:13:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * math.c (math_log2): add new method inspired by
- [ruby-talk:191237].
-
- * math.c (math_log): add optional base argument to Math::log().
- [ruby-talk:191308]
-
Thu May 4 02:24:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
- uninitialized array element. a patch from Pat Eyler
+ uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
- patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
+ patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
@@ -16111,17 +7438,17 @@ Wed May 3 02:12:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
-Mon May 1 17:58:16 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Mon May 1 12:23:19 2006 <sinara@blade.nagaokaut.ac.jp>
- * ext/win32ole/win32ole.c (add_event_call_back): should not
- delete event handler when the event name is not entried.
+ * numeric.c (num_div): use floor rather than rb_Integer().
+ [ruby-dev:28589]
-Mon May 1 08:32:10 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * numeric.c (flo_divmod): the first element of Float#divmod should
+ be an integer. [ruby-dev:28589]
- * ext/win32ole/win32ole.c (ole_param_ole_type): should return
- "unknown type" string when ITypeInfo::GetFuncDesc failed.
+ * test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
-Sat Apr 29 22:43:37 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sat Apr 29 22:42:08 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1_decode0): should initialize
flag. [ruby-core:07785]
@@ -16131,6 +7458,8 @@ Fri Apr 28 10:53:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
+ * util.c (ruby_strtod): fixed wrong conversion.
+
Thu Apr 27 01:38:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_fill): internalize local variable "beg" to
@@ -16139,12 +7468,7 @@ Thu Apr 27 01:38:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
Wed Apr 26 16:59:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
- <tommy at tmtm.org>. [ruby-dev:28601]
-
-Wed Apr 26 16:55:19 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * applied code clean-up patch from Stefan Huehner
- <stefan at huehner.org>. [ruby-core:07764]
+ <tommy at tmtm.org>. [ruby-dev:28601]
Tue Apr 25 18:00:05 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -16157,6 +7481,12 @@ Tue Apr 25 07:55:31 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
+Tue Apr 25 00:08:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): should check if c is not a
+ multibyte character. a patch from KIMURA Koichi
+ <kimura.koichi at canon.co.jp>. [ruby-dev:28598]
+
Fri Apr 21 15:19:13 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tcltklib.c (lib_eventloop_ensure): refer freed pointer
@@ -16167,11 +7497,6 @@ Fri Apr 21 12:14:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
-Thu Apr 20 08:43:54 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/mathn.rb (Integer): need not to remove gcd2. a patch from
- NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
-
Wed Apr 19 13:55:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (arg): too much NEW_LIST()
@@ -16183,6 +7508,8 @@ Wed Apr 19 11:57:04 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
+ * parse.y (list_concat): revert last change.
+
* parse.y (arg): use NODE_ARGSCAT for placeholder.
Wed Apr 19 11:13:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -16195,6 +7522,11 @@ Wed Apr 19 10:13:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
+Wed Apr 19 09:49:36 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (list_concat): should not modify nodes other than
+ NODE_ARRAY. [ruby-dev:28583]
+
Tue Apr 18 17:40:37 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: add a binding to a container for a slave IP.
@@ -16205,6 +7537,19 @@ Tue Apr 18 17:40:37 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/stubs.c: fix potential bugs about handling rb_argv0.
+Tue Apr 18 00:11:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c: block_unique should be 1, not frame_unique.
+ [ruby-dev:28577]
+
+Fri Aug 11 15:39:25 2006 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_body): Make RDoc
+ ignore C function prototypes. Patch by Tilman Sauerbeck
+ <tilman at code-monkey.de>. [ruby-core:8574]
+ * lib/yaml/tag.rb: Replace nodoc with stopdoc so Module methods get
+ documented.
+
Mon Apr 10 01:03:10 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* prec.c (prec_prec_f): documentation patch from
@@ -16219,30 +7564,10 @@ Sat Apr 8 02:12:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* README.EXT: update symbol description. [ruby-talk:188104]
-Sat Apr 8 18:06:28 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_METHOD#inspect,
- WIN32OLE_PARAM#inspect.
-
- * test/win32ole/test_win32ole_method.rb: ditto.
-
- * add test/win32ole/test_win32ole_param.rb.
-
-Fri Apr 7 22:11:30 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c(foletypelib_initialize): WIN32OLE_TYPELIB.new
- accepts OLE file.
-
- * test/win32ole/test_win32ole_typelib.rb(test_initialize): ditto.
-
Thu Apr 6 23:28:47 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
-Thu Apr 6 16:43:06 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * intern.h (rb_obj_instance_exec, rb_mod_module_exec): add declaration.
-
Thu Apr 6 11:18:37 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/panedwindow.rb: lack of arguments. [ruby-core:7681]
@@ -16266,51 +7591,27 @@ Thu Apr 6 01:04:47 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/variable.rb: remove warning about unseting Tcl
variables.
-Wed Apr 5 00:22:54 2006 Tanaka Akira <akr@m17n.org>
-
- * lib/pathname.rb: use a subclass for instantiation except
- methods take pathname argument. suggested by Evan Phoenix.
- [ruby-core:7618]
-
-Tue Apr 4 22:15:41 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y: remove some obsolete syntax rules (unparenthesized
- method calls in argument list).
-
-Sat Apr 1 15:11:27 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_TYPE#inspect,
- WIN32OLE_VARIABLE#inspect
-
- * remove ext/win32ole/tests/testOLEVARIABLE.rb, testOLETYPE.rb
- testOLETYPELIB.rb.
+Wed Mar 29 20:54:44 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * testall.rb: ditto.
+ * ext/win32ole/win32ole.c (fole_getproperty): WIN32OLE#[] should accept
+ multi arguments.
- * add test/win32ole
+ * ext/win32ole/tests/testWIN32OLE.rb (test_setproperty_bracket): ditto.
-Fri Mar 31 14:24:55 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enumerator.c (enumerator_with_index): removed suspicious return
- statement.
-
-Wed Mar 29 23:06:48 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_invoke): change the behavior of
- WIN32OLE#[], WIN32OLE#[]=. These methods invoke DISPID_VALUE.
-
- * ext/win32ole/sample/excel2.rb: ditto.
-
- * ext/win32ole/tests/testWIN32OLE.rb: ditto.
-
-Wed Mar 29 10:11:31 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Mar 29 10:07:44 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c (nkf_each_char_to_hex, encode_fallback_subchar,
e2w_conv): support C90 compiler.
-Mon Mar 27 22:45:37 2006 NARUSE, Yui <naruse@ruby-lang.org>
+Wed Mar 29 06:48:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (backtrace): reports aliased method names in a generated
+ backtrace. a patch from "U.Nakamura" <usa at garbagecollect.jp>.
+ [ruby-dev:28471]
+
+Mon Mar 27 22:19:09 2006 NARUSE, Yui <naruse@ruby-lang.org>
- * ext/nkf/nkf-utf8/{nkf.c, utf8tbl.c}: imported nkf 2.0.6.
+ * ext/nkf/nkf-utf8/{nkf.c, utf8tbl.c, config.h}: imported nkf 2.0.6.
* Add --ic / --oc option and mapping tables.
* Add fallback option.
* Add --no-best-fit-chars option.
@@ -16321,12 +7622,6 @@ Mon Mar 27 22:45:37 2006 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/lib/kconv.rb (Kconv.to*): add -m0.
Note that Kconv.to* still imply -X.
- * ext/nkf/test.rb: Removed. Obsolete by test/nkf.
-
- * ext/.document: enabled documents in nkf and kconv
-
- * ext/nkf/nkf.c, ext/nkf/lib/kconv.rb: Add rdoc.
-
Mon Mar 27 03:17:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_call0): insecure calling should be checked for non
@@ -16335,125 +7630,53 @@ Mon Mar 27 03:17:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
-Sun Mar 26 22:02:51 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * re.c: refactoring for options.
-
- * parse.y: ditto.
-
-Fri Mar 24 21:11:02 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * re.c (match_aref): RDoc description updated.
-
- * string.c (rb_str_sub): ditto.
+Fri Mar 24 23:14:30 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (rb_str_gsub): ditto.
+ * eval.c (yield_under_i): pass self again for instance_eval().
+ [ruby-dev:28466]
Fri Mar 24 17:20:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * process.c (rb_f_sleep): remove RDoc description about SIGALRM
- which is not valid on the current implementation. [ruby-dev:28464]
-
-Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * re.c (rb_reg_regsub): prohibit \1, \2 ...\9 in replaced string
- for named regex pattern.
-
-Thu Mar 23 21:06:23 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * oniguruma.h: Version 4.0.2
-
- * regparse.c: ditto.
-
- * regcomp.c ditto.
-
- * regerror.c: ditto.
+ * process.c (rb_f_sleep): remove description about SIGALRM which
+ is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 10:47:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (method_missing): should support argument splat in
- super. a bug in combination of super, splat and
- method_missing. [ruby-talk:185438]
-
-Thu Mar 23 00:01:32 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * re.c (rb_reg_regsub): add back reference by name \k<name> in
- replace string.
-
- * re.h: add regexp argument to rb_reg_regsub().
-
- * string.c (rb_str_sub_bang): ditto.
-
- * string.c (str_gsub): ditto.
-
-Tue Mar 21 22:14:01 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * re.c (match_alloc): initialize member regexp.
-
- * re.c (match_aref): add String and Symbol argument. [ruby-dev:28448]
-
- * re.h: add member regexp to RMatch.
-
- * gc.c (gc_mark_children): add gc_mark() to regexp member.
+ super. [ruby-talk:185438]
Mon Mar 20 12:05:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
-Mon Mar 20 11:12:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/win32ole/win32ole.c (folevariant_value): could not compile
- with C90 compiler.
-
Mon Mar 20 09:40:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
-Sun Mar 19 09:46:30 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
- of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
- String object.
-
- * ext/win32ole/win32ole.c (folevariant_value): ditto.
+Fri Mar 17 19:08:49 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/win32ole/tests/testOLEVARIANT.rb: ditto.
+ * ext/openssl/ossl_ssl.c, ext/openssl/ossl_nsspki.c: fix typo.
+ [ruby-core:07571]
-Wed Mar 15 16:51:11 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Mar 15 16:54:21 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/mkmf.rb (create_makefile): support libraries without *.so.
-Wed Mar 15 16:39:29 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Wed Mar 15 16:35:43 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ssl.c, ext/openssl/ossl_nsspki.c: should use
"rb_str_new(0, 0)" to make empty string.
-Sun Mar 12 17:02:10 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c(ole_val2olevariantdata): support VT_ARRAY in
- WIN32OLE_VARIANT.new().
-
- * ext/win32ole/tests/testOLEVARIANT.rb: ditto.
-
- * ext/win32ole/tests/testOLEPARAM.rb: test method name should not be
- duplicated.
-
Sat Mar 11 14:24:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::wrap): removed
+ space before argument parenthesis. [ruby-talk:183630]
+
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
-Sun Mar 5 18:40:58 2006 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb: do not repeat command options.
-
-Sun Mar 5 18:35:03 2006 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (send_request_with_body): #content_type never
- return false, use #main_type instead. [ruby-core:07476]
-
Sat Mar 4 15:26:40 2006 Tanaka Akira <akr@m17n.org>
* gc.c (id2ref): fix symbol test.
@@ -16461,112 +7684,84 @@ Sat Mar 4 15:26:40 2006 Tanaka Akira <akr@m17n.org>
Sat Mar 4 01:08:07 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
- directories. a patch from Eric Hodel <drbrain at segment7.net>.
+ directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
-Fri Mar 3 17:59:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_clear_cache_by_class): clearing wrong cache.
-
-Fri Mar 3 21:22:42 2006 Tanaka Akira <akr@m17n.org>
-
- * lib/fileutils.rb (FileUtils.cp_r): implement :remove_destination
- option.
-
- * ext/extmk.rb: use :remove_destination to install extension libraries
- to avoid SEGV. [ruby-dev:28417]
-
-Fri Mar 3 14:41:04 2006 Minero Aoki <aamine@loveruby.net>
-
- * ext/dl/.cvsignore: ignore callback.h.
+Thu Mar 2 19:44:18 2006 Tanaka Akira <akr@m17n.org>
- * ext/ripper/.cvsignore: ignore eventids2table.c.
-
- * ext/socket/.cvsignore: ignore constants.h.
+ * gc.c: align VALUE with sizeof(RVALUE) globally.
+ (is_pointer_to_heap): check alignment out of loop.
+ (id2ref): avoid collision between symbols and objects.
+ (rb_obj_id): ditto. moved from object.c.
+ [ruby-talk:178364] [ruby-core:7305]
Thu Mar 2 18:58:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
-Thu Mar 2 09:12:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_flatten_bang): allow specifying recursion
- level. [ruby-talk:182170]
-
- * array.c (rb_ary_flatten): ditto.
-
-Thu Mar 2 08:02:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
- Weil <weil at mail.berlios.de>.
-
-Wed Mar 1 17:13:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_call): use separate cache for fcall/vcall
- invocation.
-
- * eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
- functions.
-
- * eval.c (rb_mod_local): a new method to specify newly added
- visibility "local".
-
- * eval.c (search_method): search for local methods which are
- visible only from the current class.
-
- * class.c (rb_class_local_methods): a method to list local methods.
-
-Thu Mar 2 17:54:45 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Mar 2 17:57:49 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* gc.c: commited magic for reducing RVALUE size on windows. (24->20byte)
[ruby-core:7474]
-Thu Mar 2 14:12:26 2006 Tanaka Akira <akr@m17n.org>
-
- * gc.c: align VALUE with sizeof(RVALUE) globally.
- (is_pointer_to_heap): check alignment out of loop.
- (id2ref): avoid collision between symbols and objects.
- (rb_obj_id): ditto. moved from object.c.
- [ruby-talk:178364] [ruby-core:7305]
-
-Thu Mar 2 12:55:16 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Mar 2 12:59:14 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (filetime_to_unixtime): should set tm_isdst to -1.
stat() didn't treat daylight saving time property on WinNT.
[ruby-talk:182100]
-Wed Mar 1 00:15:51 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Mar 2 08:02:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (add_heap): heap_slots may overflow. a patch from Stefan
+ Weil <weil at mail.berlios.de>.
+
+Wed Mar 1 00:24:31 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/parsers/parse_rb.rb (read_escape): could not handle /\^/.
merged Mr. Ishizuka's lib/irb/ruby-lex.rb 's patch rev 1.29.
[ruby-talk:181631] [ruby-dev:28404]
-Tue Feb 28 19:32:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Feb 28 09:32:17 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * object.c (Init_Object): add BasicObject class as a top level
- BlankSlate class.
+ * lib/drb/extservm.rb (invoke_service_command): cannot invoke command
+ if command name is quoted on mswin32. [ruby-dev:28400]
Mon Feb 27 00:19:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
-Fri Feb 24 20:21:38 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Fri Feb 24 20:07:23 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/drbtest.rb (add_service_command): quote pathnames in the
server's command line for space contained directory names.
Thanks, arton. [ruby-dev:28386]
-Fri Feb 24 12:10:07 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Feb 24 12:11:08 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* instruby.rb: install *.exe.manifest and *.dll.manifest if exist.
It's for VC++8.
-Fri Feb 24 11:17:45 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Feb 24 11:33:52 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * bcc32/Makefile.sub (HAVE_HYPOT): bcc32 has hypot().
+
+Fri Feb 24 11:19:58 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * time.c (time_new_internal): add prototype to tell the compiler
+ arugments types.
* win32/win32.c (NtInitialize): need to set a handler for VC++8.
+Fri Feb 24 08:19:16 2006 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * test.rb: Removed. Obsolete by test/nkf.
+
+ * ext/.document: enabled documents in nkf and kconv
+
+ * ext/nkf/nkf.c ext/nkf/lib/kconv.rb: Add rdoc.
+
Thu Feb 23 22:39:59 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bcc32/Makefile.sub: use borlndmm.dll if possible. bcc32's RTL internal
@@ -16574,84 +7769,30 @@ Thu Feb 23 22:39:59 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
ex: 10000.times { "" << "." * 529671; GC.start } # crash
[ruby-dev:28230]
-Thu Feb 23 13:23:03 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Feb 23 13:20:28 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* eval.c (SETUP_ARGS0): fixed memory corruption. [ruby-dev:28360]
-Wed Feb 22 21:16:55 2006 Tanaka Akira <akr@m17n.org>
-
- * lib/pathname.rb (Pathname#each_filename): use split_names properly.
-
-Wed Feb 22 16:24:05 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/webrick/test_cgi.rb: should support platforms which search
- library path from the interpreter's path.
- And, support test without install incidentally.
-
-Wed Feb 22 14:21:03 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (bignorm): x may not be a bignum. [ruby-dev:28367]
+Tue Feb 21 02:18:46 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Feb 22 09:22:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * configure.in (mingw): have link. [ruby-list:41838]
- * eval.c (proc_alloc): add proper check for creation of a lambda
- without a block.
+ * win32/Makefile.sub (config.h): ditto.
Tue Feb 21 02:07:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (f_arglist): should set command_start = Qtrue for
command body. [ruby-talk:180648]
-Mon Feb 20 22:30:17 2006 Tanaka Akira <akr@m17n.org>
+Mon Feb 20 17:37:26 2006 Tanaka Akira <akr@m17n.org>
- * mkconfig.rb: alias Config to RbConfig for compatibility.
-
-Mon Feb 20 18:21:41 2006 Tanaka Akira <akr@m17n.org>
-
- * io.c (rb_io_reopen): flush before reopening a file.
- reported by Mathieu Bouchard. [ruby-core:7396]
-
-Mon Feb 20 17:29:50 2006 Tanaka Akira <akr@m17n.org>
-
- * mkconfig.rb: generate RbConfig instead of Config.
-
- * instruby.rb, rubytest.rb, runruby.rb, bcc32/Makefile.sub,
- ext/extmk.rb, ext/dl/extconf.rb, ext/iconv/charset_alias.rb,
- lib/mkmf.rb, lib/rdoc/ri/ri_paths.rb,
- lib/webrick/httpservlet/cgihandler.rb,
- test/dbm/test_dbm.rb, test/gdbm/test_gdbm.rb,
- test/ruby/envutil.rb, test/soap/calc/test_calc_cgi.rb,
- test/soap/header/test_authheader_cgi.rb, test/soap/ssl/test_ssl.rb,
- win32/mkexports.rb, win32/resource.rb: Use RbConfig instead of
- Config.
-
-Mon Feb 20 13:46:19 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/find.rb: should raise ENOENT if root entry does not exist,
- without opening it. [ruby-dev:28345]
+ * mkconfig.rb: alias RbConfig for Config.
Mon Feb 20 12:27:53 2006 Kent Sibilev <ksruby@gmail.com>
* lib/rational.rb (Integer::gcd): small typo fix.
[ruby-core:07395]
-Mon Feb 20 10:03:59 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_const_get_0): Object should have been the lowest
- in const lookup precedence. [ruby-dev:28343]
-
-Mon Feb 20 09:17:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/delegate.rb (Delegator): should not delegate "funcall".
-
-Mon Feb 20 09:13:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/webrick/httpservlet/cgihandler.rb (WEBrick::HTTPServlet::CGIHandler):
- qualify the access for Config constant. [ruby-dev:28338]
-
- * lib/resolv.rb (Resolv::DNS::Resource::IN::A): qualify
- ClassValue. [ruby-dev:28338]
-
Mon Feb 20 01:05:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rational.rb (Integer::gcd): replaced by gcd4 in
@@ -16662,13 +7803,6 @@ Mon Feb 20 00:57:02 2006 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl.h (OSSL_Debug): should not use __func__.
[ruby-dev:28339]
-Mon Feb 20 00:13:49 2006 Tanaka Akira <akr@m17n.org>
-
- * lib/open-uri.rb: add :ssl_verify_mode option.
- suggested by Will Glynn.
-
- * lib/open-uri.rb: add :ssl_ca_cert option.
-
Sun Feb 19 04:46:29 2006 Guy Decoux <ts@moulon.inra.fr>
* eval.c: initial value for block_unique must be 1.
@@ -16684,44 +7818,17 @@ Sat Feb 18 23:58:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* sample/rtags.rb: ditto.
-Sat Feb 18 21:16:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_obj_instance_eval): RDoc description updated. a
- patch from Ozgur Murat Homurlu <ozgurmurath at gmail.com>.
- [ruby-core:07381]
+Sat Feb 18 12:18:26 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Feb 18 01:01:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_const_get_0): skip ruby_wrapper in const search
- to give it lower priority (just above Object). need not to
- change rb_const_defined_0() since it's only a precedence matter;
- they are defined anyway.
+ * lib/fileutils.rb (FileUtils::fu_world_writable): make it
+ private. [ruby-core:07383]
Sat Feb 18 00:22:39 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/tracer.rb: merged a minor clarification patch from Daniel
Berger <Daniel.Berger at qwest.com>. [ruby-core:07376]
-Fri Feb 17 17:30:20 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (ev_const_get): simplified using rb_const_get_fallback().
-
- * eval.c (ev_const_defined): adopt to ev_const_get() using
- rb_const_defined_fallback().
-
- * variable.c (rb_const_get_fallback): new function to implement
- constant search.
-
- * variable.c (rb_const_defined_fallback): new function to
- implement constant definition check.
-
- * variable.c (rb_const_get_0): adopt to new behavior. constants
- are looked up in the order of: current class, super classes (but
- Object), lexically external classes/modules, and Object.
-
- * variable.c (rb_const_defined_0): ditto.
-
-Fri Feb 17 11:20:53 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Feb 17 11:18:42 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* util.c (ruby_strtod): Float("1e") should fail. [ruby-core:7330]
@@ -16736,6 +7843,11 @@ Fri Feb 17 09:39:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_wait_for): sleep should always sleep for
specified amount of time. [ruby-talk:180067]
+Thu Feb 16 01:10:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (backtrace): frame->orig_func may not be initialized.
+ [ruby-core:07367]
+
Wed Feb 15 16:52:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): NODE_OP_ASGN1 should allow splat in its
@@ -16747,10 +7859,6 @@ Wed Feb 15 16:52:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): honor visibility on OP_ASGN1 and
OP_ASGN2. [ruby-core:07366]
-Wed Feb 15 15:20:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (error_line): remove void control path. [ruby-dev:28335]
-
Wed Feb 15 10:09:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (yield_under_i): should not pass self as an argument to
@@ -16761,32 +7869,17 @@ Wed Feb 15 09:20:35 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_obj_instance_eval): should be no singleton classes for
true, false, and nil. [ruby-dev:28186]
-Tue Feb 14 20:26:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enumerator.c (enumerator_each): return self if no block is
- given. [yarv-dev:882]
-
Tue Feb 14 18:48:33 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (DMETHOD_P): accessing wrong frame. [ruby-dev:28181]
* eval.c (proc_invoke): preserve FRAME_DMETH flag.
-Tue Feb 14 15:15:22 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Feb 14 15:13:51 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/zlib/zlib.c: supress warning on test/zlib. [ruby-dev:28323]
-Tue Feb 14 13:47:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_utime): drop read-only attribute before
- changing file time.
-
-Tue Feb 14 13:38:01 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/Makefile.sub (config.h): should define HAVE_LONG_LONG with
- VC++8.
-
-Tue Feb 14 11:42:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Feb 14 14:01:17 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* time.c (search_time_t): support non 32bit time_t environments.
@@ -16794,40 +7887,35 @@ Tue Feb 14 11:42:38 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub (config.h): VC++8's time_t is 64bit value.
-Mon Feb 13 18:01:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (copy_node_scope): remove duplicated semicolons at end.
- a patch from KIMURA Koichi <kimura.koichi at canon.co.jp>.
- [ruby-dev:28332]
-
- * eval.c (VIS_MODE): remove unnecessary argument.
- [ruby-dev:28332]
+ * win32/win32.c (rb_w32_utime): drop read-only attribute before
+ changing file time.
-Mon Feb 13 13:49:48 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+ all changes are backported from CVS HEAD.
- * parse.y (parser_parse_string): mention "regexp" in a error
- message. a patch from Mauricio Fernandez <mfp at acm.org>
- [ruby-core:07340]
+Tue Feb 14 11:21:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Feb 13 00:01:32 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
+ * io.c (argf_forward): should not use frame->argv.
+ [ruby-core:07358]
- * oniguruma.h: Version 4.0.1
+Mon Feb 13 18:08:12 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regparse.c (onig_free_shared_cclass_table): fix memory leaks.
+ * eval.c (rb_call0): argument update propagation. [ruby-dev:28044]
- * regcomp.c (optimize_node_left): change from IS_POSIXLINE() to IS_MULTILINE().
+ * env.h: remove argv member from struct FRAME.
- * regint.h: rename ANCHOR_ANYCHAR_STAR_PL to ANCHOR_ANYCHAR_STAR_ML.
+Mon Feb 13 13:27:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regparse.h: ditto.
+ * eval.c (eval): should push class from binding if supplied.
+ [ruby-core:07347]
- * regexec.c: ditto.
+Mon Feb 13 00:04:00 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Sat Feb 11 21:57:29 2006 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+ * lib/erb.rb (ERB::Compiler): add instance variable @insert_cmd to
+ change <%='s behavior. (backported 1.15 - 1.16)
- * ext/win32ole/win32ole.c: add WIN32OLE.create_guid.
+Sat Feb 11 02:04:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/win32ole/tests/testWIN32OLE.rb: ditto.
+ * eval.c (eval): no need to push ruby_class. [ruby-dev:28176]
Sat Feb 11 01:57:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -16835,76 +7923,39 @@ Sat Feb 11 01:57:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
instance_eval for objects cannot have singleton classes,
e.g. fixnums and symbols). [ruby-dev:28178]
-Fri Feb 10 12:31:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_eval): should support NODE_ZSUPER in NODE_ITER.
- [ruby-dev:28326]
-
- * eval.c (ZSUPER_ARGS): support macro.
-
-Wed Feb 8 10:26:06 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (rb_gc_call_finalizer_at_exit): turn on during_gc while
- invoking finalizers.
-
- * gc.c (rb_gc_finalize_deferred): ditto.
-
-Tue Feb 7 23:03:13 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Feb 7 23:03:24 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/zlib/zlib.c: should not access ruby objects in finalizer.
[ruby-dev:28286]
-Tue Feb 7 18:42:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_write_error2): use fwrite(3) if rb_stderr is not
- updated or is already freed. [ruby-dev:28313]
-
Mon Feb 6 16:02:51 2006 WATANABE Hirofumi <eban@ruby-lang.org>
* file.c (rb_thread_flock): ERROR_NOT_LOCKED is not an error on Cygwin.
In such situation, flock() should return 0.
-Mon Feb 6 14:36:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (error_line): include the class name of a surrounding
- method in error position description.
-
-Mon Feb 6 00:14:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_find_index): a new method Enumerable#find_index.
- [ruby-talk:178495]
+Mon Feb 6 00:41:08 2006 Tanaka Akira <akr@m17n.org>
-Sun Feb 5 23:29:31 2006 Tanaka Akira <akr@m17n.org>
+ * ruby.h (RSTRUCT_LEN, RSTRUCT_PTR): defined for source level
+ compatibility with ruby 1.9.
- * ruby.h (struct RStruct): embed 3 or less elements structs.
- (RSTRUCT_LEN): defined for accessing struct members.
- (RSTRUCT_PTR): ditto.
-
- * struct.c: use RSTRUCT_LEN and RSTRUCT_PTR.
- (struct_alloc): allocate small structs in embedded format.
- (rb_struct_init_copy): ditto.
-
- * gc.c (gc_mark_children): use RSTRUCT_LEN and RSTRUCT_PTR.
- (obj_free): ditto.
-
- * marshal.c (w_object): use RSTRUCT_LEN and RSTRUCT_PTR.
-
-Sun Feb 5 21:01:49 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sun Feb 5 21:05:34 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* numeric.c (fix_to_s): removed workaround for radix 2. Historically,
rb_fix2str could only handle radix 8, 10, 16. (Rev1.37) But for now,
it can handle radix 2..36. [ruby-Bugs#3438] [ruby-core:7300]
-Sun Feb 5 18:49:00 2006 Minero Aoki <aamine@loveruby.net>
+Sun Feb 5 18:55:08 2006 Minero Aoki <aamine@loveruby.net>
- * lib/net/http.rb (add_field, get_fields): keep 1.8.2
- compatibility. This patch is contributed by Rob Pitt.
+ * lib/net/http.rb: imported from trunk, rev 1.129
-Sun Feb 5 16:33:50 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * lib/net/http.rb (add_field, get_fields): keep 1.8.2 backward
+ compatibility.
- * lib/mkmf.rb (create_makefile): Kernel#sub! was removed on HEAD.
+ * lib/net/https.rb: imported from trunk, rev 1.3.
-Sun Feb 5 14:26:54 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * lib/net/https.rb: #use_ssl? definition moved from net/http.rb.
+
+Sun Feb 5 14:22:15 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/pstore.rb: should return default value if name is not found.
[ruby-core:7304]
@@ -16916,59 +7967,33 @@ Sat Feb 4 22:51:43 2006 Tanaka Akira <akr@m17n.org>
* eval.c: apply the FreeBSD getcontext/setcontext workaround
only before FreeBSD 7-CURRENT.
-Sat Feb 4 21:10:06 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Sat Feb 4 21:19:23 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (LK_ERR): ERROR_NOT_LOCKED is not an error.
In such situation, flock() should return 0.
-Sat Feb 4 15:52:56 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Feb 4 15:56:37 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* numeric.c (fix_to_s): (2**32).to_s(2) fails with exception where
sizeof(int) == 4 < sizeof(long). [ruby-core:7300]
-Sat Feb 4 15:02:05 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * oniguruma.h: merge Oniguruma 4.0.0 [ruby-dev:28290]
-
-Fri Feb 3 19:25:53 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ruby.h: fixed prototype.
-
- * ext/syck/rubyext.c: defined symbol ID as global variable as others.
-
-Fri Feb 3 17:57:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c: unify ruby_class (for method definition) and ruby_cbase
- (for constant reference).
-
-Fri Feb 3 15:02:10 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Feb 3 15:06:50 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/syck.c (syck_move_tokens): should reset p->cursor or etc
even if skip == 0. This causes buffer overrun.
(ex: YAML.load('--- "..' + '\x82\xA0' * 511 + '"'))
-Fri Feb 3 00:01:31 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Feb 2 23:51:18 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/emitter.c (syck_emitter_write): should not set '\0' on
- emitter's marker. if marker points to the end of buffer, this is
+ emitter's marker. if marker points to the end of buffer, this causes
buffer overrun. (ex: YAML.dump("." * 12288))
-Thu Feb 2 17:13:01 2006 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser#get_tk): added
- support of :'string' style Symbol.
-
Thu Feb 2 16:01:24 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_call0): use TMP_ALLOC() instead of allocating
- a temporary array object.
-
* eval.c (eval): need not to protect $SAFE value.
[ruby-core:07177]
- * error.c (Init_Exception): change NameError to direct subclass of
- Exception so that default rescue do not handle it silently.
-
Thu Feb 2 14:45:53 2006 Ville Mattila <ville.mattila@stonesoft.com>
* configure.in: The isinf is not regognized by autoconf
@@ -16995,36 +8020,17 @@ Tue Jan 31 11:58:51 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/namespace.rb: TkNamespace#eval was enbugged at the
last commit. Now it will return a proper object.
-Tue Jan 31 08:07:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (int_upto): return an enumerator if no block is
- attached to the method.
-
- * numeric.c (int_downto): ditto.
-
- * numeric.c (int_dotimes): ditto.
-
- * enum.c (enum_first): new method Enumerable#first to take first n
- elements from an enumerable.
-
- * enum.c (enum_group_by): new method Enumerable#group_by that
- groups enumerable values according to their block values.
-
-Tue Jan 31 00:08:22 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Jan 31 00:10:26 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/rubyext.c (syck_resolver_transfer): workaround for SEGV.
ex: ruby -ryaml -e 'YAML.load("!map:B {}")' [ruby-core:7217]
-Sat Jan 28 07:49:30 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Jan 28 07:56:57 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/usage.rb: support "a:0:33" style caller[-1]. In this case
file name is "a:0". I don't know this really happens though...
[ruby-Bugs:3344]
-Thu Jan 26 15:55:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c: turn on do_not_reverse_lookup by default.
-
Wed Jan 25 22:29:04 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in, dln.c, file.c, intern.h, missing.h (eaccess): use
@@ -17048,7 +8054,13 @@ Sun Jan 22 20:03:35 2006 Tanaka Akira <akr@m17n.org>
FreeBSD/i386 getcontext/setcontext bug.
[ruby-dev:28263]
-Thu Jan 19 22:19:18 2006 Minero Aoki <aamine@loveruby.net>
+Sat Jan 21 00:36:47 2006 Tanaka Akira <akr@m17n.org>
+
+ * eval.c (FUNCTION_CALL_MAY_RETURN_TWICE): use only on SPARC and IA64
+ before gcc 4.0.3.
+ [ruby-dev:28247]
+
+Thu Jan 19 22:21:23 2006 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (mv): should remove file after copying.
[ruby-dev:28223]
@@ -17062,34 +8074,32 @@ Wed Jan 18 23:37:06 2006 Tanaka Akira <akr@m17n.org>
reported by Pav Lucistnik and Marius Strobl.
http://lists.freebsd.org/pipermail/freebsd-sparc64/2006-January/003739.html
-Tue Jan 17 23:59:56 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * object.c (rb_mod_const_get, rb_mod_const_defined): added optional
- flag to search ancestors, which is defaulted to true.
- fixed: [ruby-talk:175899]
-
- * eval.c (rb_mod_method_defined): ditto.
-
-Tue Jan 17 11:31:47 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jan 17 11:32:46 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/setup.mak (MAKE): workaround for nmake 8.
-Tue Jan 17 11:06:19 2006 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jan 17 11:10:21 2006 NAKAMURA Usaku <usa@ruby-lang.org>
- * win32/Makefile.sub: invoke .bat via shell. workaround for nmake 8.
+ * win32/{Makefile.sub,setup.mak}: invoke .bat via shell. workaround
+ for nmake 8.
-Mon Jan 16 10:13:38 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Jan 16 10:26:23 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/emitter.c (syck_emit_seq, syck_emit_map, syck_emit_item):
should output complex key mark even if map's key is empty seq/map.
[ruby-core:7129]
-Sat Jan 14 03:38:54 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Jan 14 05:37:06 2006 Tanaka Akira <akr@m17n.org>
+
+ * io.c (READ_DATA_PENDING, READ_DATA_PENDING_COUNT): defined
+ for DragonFly BSD 1.4.0.
+
+Sat Jan 14 03:43:24 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* file.c (rb_file_s_chmod): avoid warning where sizeof(int) !=
sizeof(void*).
-Fri Jan 13 19:26:15 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Jan 13 19:14:56 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/diagram.rb:
- properly quote bare element attributes
@@ -17111,15 +8121,23 @@ Thu Jan 12 11:53:08 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
[new feature] support 'command' option which is called just before
popping up the balloon help.
-Wed Jan 11 00:12:29 2006 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Jan 11 15:00:00 2006 Ville Mattila <mulperi@iki.fi>
- * lib/erb.rb (ERB::Compiler): add instance variable @insert_cmd to
- change <%='s behavior.
+ * io.c (READ_PENDING*): Support solaris 64-bit environments.
+ Solaris defines a opaque FILE struct when compiling 64 bit
+ binaries. This means that we dont have access to _ptr etc.
+ members anymore. The solution by Steven Lumos is to define
+ FILE64 that has needed members available. I've modified
+ the origanal patch a bit so that it compiles both with gcc
+ and now free sun studio 11 compiler and both amd64 and sparc.
+ NOTE! We have to 64 bit solaris FILE structure time to time
+ otherwise we'll get breakage.
+ [ruby-core:7106]
Tue Jan 10 19:42:33 2006 Tanaka Akira <akr@m17n.org>
* gc.c (garbage_collect): mark ruby_current_node.
- if an exception is raised in a finalizer written in C called by
+ if an exception is raised in a finalizer called written in C by
rb_gc_call_finalizer_at_exit, ruby_set_current_source may use
collected ruby_current_node and mark_source_filename may corrupt
memory.
@@ -17142,68 +8160,37 @@ Tue Jan 10 12:00:48 2006 Aaron Schrab <aaron @nospam@ schrab.com>
* lib/yaml/rubytypes.rb (Symbol#yaml_new): YAML loading of quoted
Symbols broken. [ruby-Bugs:2535]
-Tue Jan 10 07:26:52 2006 Tanaka Akira <akr@m17n.org>
-
- * gc.c (gc_stress): renamed from always_gc and enabled by default.
- (gc_stress_get): new function for GC.stress.
- (gc_stress_set): new function for GC.stress=.
-
-Mon Jan 9 19:58:56 2006 arton <artonx@yahoo.co.jp>
+Mon Jan 9 19:54:35 2006 arton <artonx@yahoo.co.jp>
* ext/zlib/extconf.rb: zlib compiled DLL version 1.2.3 distributed by
http://www.zlib.net/ has zdll.lib. [ruby-dev:28209]
-Mon Jan 9 14:25:00 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Jan 9 14:17:12 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/Makefile.sub (OPTFLAGS): I have experienced trouble on y- flag,
(VisualC++6) so use -O2b2xg- if $(MSC_VER) < 1400. [ruby-core:7040]
-Mon Jan 9 14:25:00 2006 Kero van Gelder <rubyforge @nospam@ kero.tmfweb.nl>
+Mon Jan 9 14:17:12 2006 Kero van Gelder <rubyforge @nospam@ kero.tmfweb.nl>
* lib/webrick/httpservlet/filehandler.rb: fixed typo. [ruby-core:7075]
-Sun Jan 8 14:15:27 2006 Tanaka Akira <akr@m17n.org>
-
- * eval.c (GCC_VERSION_BEFORE): check __INTEL_COMPILER.
- Intel C++ Compiler defines __GNUC__.
- http://www.intel.com/software/products/compilers/clin/docs/ug_cpp/lin1077.htm
-
Sat Jan 7 15:40:07 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (singleton): get rid of segfault on syntax error.
fixed: [ruby-core:07070]
-Sat Jan 7 06:24:18 2006 Tanaka Akira <akr@m17n.org>
-
- * eval.c (rb_fd_isset): compare the result of FD_ISSET with 0 to
- avoid FreeBSD bug. FreeBSD defines FD_ISSET as just a bitmap of
- unsigned long. So returning the value from rb_fd_isset discards
- upper 32bits on LP64 environment.
- http://www.freebsd.org/cgi/query-pr.cgi?pr=ia64/91421
-
-Fri Jan 6 02:20:18 2006 Tanaka Akira <akr@m17n.org>
-
- * configure.in: don't force getcontext on IA64.
-
- * eval.c (ruby_setjmp): add an argument for just before getcontext.
- (THREAD_SAVE_CONTEXT): call rb_thread_save_context just
- before getcontext.
- [ruby-dev:28205]
+Fri Jan 6 10:16:20 2006 Steven Lumos <steven@lumos.us>
-Sun Jan 1 15:28:46 2006 Tanaka Akira <akr@m17n.org>
+ * io.c (READ_DATA_PENDING): defined for 64bit Solaris on SPARC.
+ [ruby-core:7057]
+ (READ_DATA_PENDING_COUNT): ditto.
+ (READ_DATA_PENDING_PTR): ditto.
- * missing.h (isinf): avoid macro expansion
- "extern int isinf(double);" to
- "extern int ((sizeof(double)==sizeof(float))?_Isinff(double):_Isinf(double));" on
- HP-UX.
-
-Sun Jan 1 14:42:54 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sun Jan 1 17:07:59 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_seekdir): should not segfault even if passed
- the location which rb_w32_telldir didn't return. (and should change
- `bits' position) [ruby-core:7035]
-
- * win32/dir.h: ditto. (stores `loc' instead of `bitpos')
+ the location which rb_w32_telldir didn't return. [ruby-core:7035]
+ (I think HEAD implementation is better. but binary compatibility)
* test/ruby/test_dir.rb: added.
@@ -17212,41 +8199,26 @@ Sat Dec 31 22:57:00 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_save_context): should not recycle scope object used
in a thread. fixed: [ruby-dev:28177]
-Sat Dec 31 19:50:38 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/syck/rubyext.c: attribute name was truncated with Rev1.64.
-
-Sat Dec 31 11:53:16 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * lib/generator.rb: (Generator#initialize): should kill @loop_thread
- before starting new thread. (occurs when called via Generator#rewind)
- [ruby-dev:28184]
-
Fri Dec 30 18:22:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * gc.c (garbage_collect): mark objects referred from aborting threads.
+ * gc.c (garbage_collect): mark objects refered from aborting threads.
[ruby-dev:28190]
* win32/Makefile.sub: VC++8 support.
-Fri Dec 30 15:17:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * lib/generator.rb (Generator#initialize): ensured to stop @loop_thread.
- Mr. Tanaka pointed out one Thread.pass is not enough. [ruby-dev:28185]
+Fri Dec 30 14:24:53 2005 WATANABE Hirofumi <eban@ruby-lang.org>
-Fri Dec 30 12:20:57 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * dir.c (glob_helper): do not use TRUE for djgpp.
- * lib/generator.rb (Generator#initialize): fixed dead lock. this occurred
- when end? was called before @loop_thread was stopped. [ruby-core:7029]
+Fri Dec 30 04:54:40 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Dec 30 01:04:52 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * file.c (eaccess): workaround for VC++8 runtime.
- * lib/generator.rb: should work with another thread. (more robust code)
- [ruby-dev:28177]
+ * win32/win32.c (ioinfo): VC++8 support.
Thu Dec 29 23:59:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_gc_mark_threads): keep unmarked threads which won't wake
+ * eval.c (rb_gc_mark_threads): leave unmarked threads which won't wake
up alone, and mark threads in the loading table. [ruby-dev:28154]
* eval.c (rb_gc_abort_threads), gc.c (gc_sweep): kill unmarked
@@ -17257,87 +8229,23 @@ Thu Dec 29 17:02:07 2005 Tanaka Akira <akr@m17n.org>
* test/ruby/envutil.rb (EnvUtil.rubybin): search "ruby" instead of
"miniruby". [ruby-dev:28140]
-Thu Dec 29 14:35:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_mod_define_method): should save safe_level in the
- proc object. [ruby-dev:28146]
-
-Thu Dec 29 11:22:34 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * lib/generator.rb: reimplemented Generator class with Thread instead of
- callcc, in order to fix memory leak. [ruby-dev:28142]
-
-Wed Dec 28 14:10:05 2005 Tanaka Akira <akr@m17n.org>
-
- * ia64.s: remove .pred.safe_across_calls directive.
- reported by WATANABE Tetsuya. [ruby-dev:28141]
-
-Wed Dec 28 01:32:39 2005 Tanaka Akira <akr@m17n.org>
-
- * eval.c (struct thread): add bstr_max.
- (rb_thread_save_context): use realloc instead of REALLOC_N
- to avoid GC.
-
-Tue Dec 27 23:59:53 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (CompletingHash#match): fix for 1.9.
-
Tue Dec 27 16:59:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/drb/drbtest.rb (DRbService::self.ext_service): increase
timeout limit. a patch from Kazuhiro NISHIYAMA
<zn at mbf.nifty.com>. [ruby-dev:28132]
-Tue Dec 27 14:17:55 2005 Tanaka Akira <akr@m17n.org>
-
- * configure.in: define IA64 for portability. (HP aC++/ANSI C doesn't
- define __ia64__.)
- don't check libunwind stuff.
- check __libc_ia64_register_backing_store_base.
-
- * defines.h: declare rb_ia64_bsp and rb_ia64_flushrs.
- (flush_register_windows): call rb_ia64_flushrs on IA64.
-
- * ia64.s: new file for IA64.
- it is separated from C program files because
- Intel C++ Compiler for IA64 doesn't support inline assembly.
+Tue Dec 27 08:29:18 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * common.mk (ia64.$(OBJEXT)): new target.
-
- * ruby.h (RUBY_INIT_STACK): defined.
- (ruby_init_stack): declared for RUBY_INIT_STACK.
-
- * main.c (main): precedes RUBY_INIT_STACK before ruby_init.
-
- * gc.c (rb_gc_register_stack_start): new global variable on IA64.
- (garbage_collect): simplify register stack marking code.
- don't use libunwind.
- (Init_stack): initialize rb_gc_register_stack_start.
- (ruby_init_stack): new function for RUBY_INIT_STACK.
-
- * eval.c (struct thread): add bstr_pos member for original position of
- register stack.
- (rb_thread_save_context): simplify register stack saving code.
- don't use libunwind.
- (rb_thread_restore_context_0): new function. moved from
- rb_thread_restore_context except the stack position checking code.
- don't use libunwind for IA64 register stack.
- (register_stack_extend): new function.
- (stack_extend): make it self-recursive with
- the stack position checking code in old rb_thread_restore_context.
- (rb_thread_restore_context): just call stack_extend.
- (flush_register_windows): removed.
-
- [ruby-dev:28127]
-
-Tue Dec 27 14:09:39 2005 Minero Aoki <aamine@loveruby.net>
-
- * process.c: new method Process.exec. [ruby-dev:28107]
+ * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLSocket#post_connection_chech):
+ treat wildcard character in commonName. [ruby-dev:28121]
-Tue Dec 27 08:22:15 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Dec 26 22:32:47 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLSocket#post_connection_check):
- treat wildcard character in commonName. [ruby-dev:28121]
+ * eval.c (rb_eval), gc.c (gc_mark_children), node.h (NEW_ALIAS,
+ NEW_VALIAS), parse.y (fitem): allow dynamic symbols to
+ NODE_UNDEF and NODE_ALIAS.
+ backported from trunk. fixed: [ruby-dev:28105]
Mon Dec 26 08:50:36 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -17350,20 +8258,23 @@ Mon Dec 26 08:50:36 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
Joel VanderWerf <vjoel at path.berkeley.edu>.
[ruby-talk:165285] [ruby-core:6995]
+Sat Dec 24 18:58:14 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * stable version 1.8.4 released.
+
Fri Dec 23 10:30:23 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/digest/sha2/sha2.c (ULL): support AIX C. a patch from
Kailden <kailden at gmail.com>. [ruby-core:06984]
-Wed Dec 21 16:47:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Dec 21 16:53:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* file.c (w32_io_info): should return handle because FileIndex is
valid only while file is open. [ruby-dev:28088]
-Wed Dec 21 12:12:21 2005 Tanaka Akira <akr@m17n.org>
+Wed Dec 21 14:53:26 2005 Tanaka Akira <akr@m17n.org>
- * test/pathname/test_pathname.rb (test_kernel_open): use
- File.identical?.
+ * lib/pathname.rb (test_kernel_open): use File.identical?.
[ruby-talk:171804]
Tue Dec 20 22:41:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -17371,102 +8282,36 @@ Tue Dec 20 22:41:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (eval_under_i): evaluate source in caller's frame.
[ruby-dev:28076]
-Tue Dec 20 12:53:23 2005 why the lucky stiff <why@ruby-lang.org>
-
- * ext/syck/rubyext.c (syck_emitter_reset): to ensure compatibility
- with previous Ruby versions, documents are no longer headless.
-
-Tue Dec 20 12:33:01 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/syck/rubyext.c (syck_node_transform): ruby object holding
- explicitly freed SyckNode caused SEGV. [ruby-dev:28067]
-
- ... I think syck GC problem was solved now!
-
-Tue Dec 20 01:46:48 2005 Tanaka Akira <akr@m17n.org>
-
- * io.c (rb_f_backquote): fix a GC problem on
- IA64 with gcc 4.0.3 20051216 (prerelease) -O3.
-
-Mon Dec 19 23:32:39 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_call_super): use original method name on exception.
+ [ruby-dev:28078]
- * Makefile.in (XCFLAGS): separated as well as win32/Makefile.sub.
+Tue Dec 20 13:11:59 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * main.c (always_gc): dllimport is required for VC to import a DLL
- symbol. fixed: [ruby-dev:28051]
+ * ext/syck/rubyext.c: fixed GC problem (backported HEAD 1.55 - 1.62)
+ [ruby-dev:27839]
- * parse.y (rb_symname_p): fixed wrong validation. [ruby-dev:28047]
-
-Mon Dec 19 23:09:24 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * ext/syck/syck.h (S_FREE): small hack. no need to check if pointer is
+ NULL or not before S_FREE.
* st.c: uses malloc instead of xmalloc to avoid GC. syck uses st_insert
in gram.c to insert node from rb_syck_bad_anchor_handler into
SyckParser's hash table. if GC occurs in st_insert, it's not under
SyckParser's mark system yet. so RString can be released wrongly.
+ [ruby-dev:28057]
- * ext/syck/syck.h (S_FREE): small hack. no need to check if pointer is
- NULL or not before S_FREE.
-
- * ext/syck/rubyext.c (syck_parser_assign_io): rb_check_string_type can
- return new RString. if so, it becomes unreachable from GC after
- returns syck_parser_assign_io, and can be freed by GC. (dangling
- in syck io system) so extends its life time till syck_parse is called.
-
- * ext/syck/rubyext.c (syck_parser_s_alloc): always allocates bonus,
- so no need to check if NULL, and "volatile VALUE hash"
- is not needed. (bonus->port was not protected in syck_emitter_reset)
-
- * ext/syck/rubyext.c (syck_mark_parser): ditto.
-
- * ext/syck/rubyext.c (syck_parser_load): ditto.
-
- * ext/syck/rubyext.c (syck_parser_load_documents): ditto.
-
- * ext/syck/rubyext.c (syck_emitter_s_alloc): ditto.
-
- * ext/syck/rubyext.c (syck_mark_emitter): ditto.
-
- * ext/syck/rubyext.c (syck_emitter_reset): ditto.
-
- * ext/syck/rubyext.c (syck_scalar_value_set): "should set newly
- allocated memory instead of RString's internal storage" stuff again.
- by this, should call syck_free_node instead of rb_syck_free_node.
-
- * ext/syck/rubyext.c (syck_node_type_id_set): ditto.
-
- ... I believe syck GC problem was solved by this.
-
-Mon Dec 19 12:20:59 2005 Tanaka Akira <akr@m17n.org>
-
- * eval.c (FUNCTION_CALL_MAY_RETURN_TWICE): activate only
- before gcc 4.0.3 on SPARC and IA64.
-
-Mon Dec 19 11:37:47 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/syck/rubyext.c: sorry, I reverted my "should set newly
- allocated memory instead of RString's internal storage" stuff.
- node allocated in rubyext.c seems to be freed by rb_syck_free_node
- not syck_free_node, and it won't free data.str->ptr and type_id.
-
- (I still think this is unsafe because RString(foo)->ptr becomes
- dangling pointer when RString is modified or freed, but anyway
- I misunderstood, so go back to original code for now)
-
-Sat Dec 17 21:50:41 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Dec 20 12:53:23 2005 why the lucky stiff <why@ruby-lang.org>
- * ext/syck/rubyext.c (syck_emitter_reset): should initialize
- emitter->bonus->oid. otherwise rb_gc_mark crashes.
+ * ext/syck/rubyext.c (syck_emitter_reset): to ensure compatibility
+ with previous Ruby versions, documents are no longer headless.
- * ext/syck/rubyext.c (syck_mark_parser): should mark anchor nodes
- because they hold ruby objects. (ie: rb_syck_bad_anchor_handler)
+Tue Dec 20 01:46:48 2005 Tanaka Akira <akr@m17n.org>
-Sat Dec 17 11:00:17 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (rb_f_backquote): fix a GC problem on
+ IA64 with gcc 4.0.3 20051216 (prerelease) -O3.
- * ext/syck/rubyext.c (rb_syck_compile): avoid potential memory
- leak.
+Mon Dec 19 23:32:39 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/syck/rubyext.c (syck_set_ivars): avoid potential memory
- leak by explicit symbol allocation.
+ * parse.y (rb_symname_p): fixed wrong validation. [ruby-dev:28047]
Sat Dec 17 03:57:01 2005 Tanaka Akira <akr@m17n.org>
@@ -17478,35 +8323,10 @@ Sat Dec 17 03:30:23 2005 Tanaka Akira <akr@m17n.org>
* eval.c (bmcall): fix a GC problem by tail call on
IA64 with gcc 4.0.3 20051216 (prerelease).
-Fri Dec 16 17:53:45 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/syck/rubyext.c (rb_syck_compile): fixed memory leak.
-
- * ext/syck/rubyext.c: should protect global variable from GC.
-
-Fri Dec 16 11:44:43 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Dec 16 00:54:06 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/syck/rubyext.c (syck_resolver_tagurize): fixed memory leak.
-
- * ext/syck/rubyext.c (syck_node_type_id_set): should set newly
- allocated memory instead of RString's internal storage.
-
- * ext/syck/rubyext.c (syck_scalar_value_set): ditto.
-
- ... these fixes won't fix [ruby-dev:27839]. more work is needed.
-
-Fri Dec 16 04:38:55 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/delegate.rb (Delegator::method_missing): should delegate
- block as well.
-
-Thu Dec 15 19:57:12 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb (CGI::QueryExtension::MorphingBody): fix criteria to
- use Tempfile. A fix from Zev Blut <rubyzbibd at ubit.com>.
- [ruby-core:06076]
-
- * string.c: remove global functions work on $_.
+ * signal.c (Init_signal): revert C++ style comment.
+ [ruby-dev:28041]
Thu Dec 15 12:35:14 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -17518,18 +8338,10 @@ Thu Dec 15 01:33:31 2005 Tanaka Akira <akr@m17n.org>
* ext/zlib/zlib.c (zstream_run): fix a GC problem by tail call on
x86_64 with gcc 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)
-Wed Dec 14 23:50:20 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/rdoc/parsers/parse_c.rb (find_class_comment): fix for class
- document with prototypes. [ruby-core:06863]
+Wed Dec 14 12:11:46 2005 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed Dec 14 23:39:53 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (has_magic): glob names contain alphabets to enable case fold
- search. [ruby-dev:27735]
-
- * dir.c (Init_Dir): FNM_SYSCASE which is default case fold flag.
- [ruby-dev:23296]
+ * test/gdbm/test_gdbm.rb: specify pid for the argument of
+ Process.wait. workaround for Cygwin.
Wed Dec 14 12:01:26 2005 Tanaka Akira <akr@m17n.org>
@@ -17553,18 +8365,11 @@ Tue Dec 13 00:08:09 2005 Tanaka Akira <akr@m17n.org>
* sprintf.c (rb_str_format): fix a GC problem.
[ruby-dev:28001]
-Mon Dec 12 15:51:22 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Dec 12 15:54:56 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_ssl.rb (test_parallel): call GC.start to close
unused files. [ruby-dev:27981]
-Mon Dec 12 09:58:09 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (range_cover): new method Range#cover? added. the
- method name might be changed. thanks to takano32 at
- http://www.rubyist.net/~matz/20051210.html#c08 for name
- suggestion. [ruby-talk:167182]
-
Mon Dec 12 00:33:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/digest/digest.c (rb_digest_base_s_digest): add volatile to
@@ -17574,38 +8379,11 @@ Mon Dec 12 00:33:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
be called before actual variable initialization.
[ruby-dev:27986]
-Sun Dec 11 23:54:07 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/*: update to support libraries in ActiveTcl8.4.12.0
- (see ext/tk/ChangeLog.tkextlib).
-
- * ext/tk/sample/scrollframe.rb: add a new sample.
-
-Sun Dec 11 22:07:58 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/rinda/test_rinda.rb (test_remote_array_and_hash): pseudo remote
- objects are protected against GC. [ruby-dev:27911]
-
-Sat Dec 10 01:06:06 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/matrix.rb: add Matrix#determinant_e, Matrix#rank_e.
- [ruby-dev:27820] and related thread.
-
-Sat Dec 10 00:31:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (calling_scope_t): gave names to magic numbers for rb_call().
- [ruby-dev:27978]
-
Fri Dec 9 23:31:02 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rexml/encoding.rb (encoding=): give priority to particular
conversion to iconv. [ruby-core:06520]
-Fri Dec 9 23:16:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * range.c (range_include): return false unless included in numeric
- range. fixed: [ruby-dev:27975]
-
Thu Dec 8 02:07:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (umethod_bind): adjust invoking class for module method.
@@ -17620,15 +8398,6 @@ Wed Dec 7 17:10:27 2005 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* sprintf.c (rb_f_sprintf): [ruby-dev:27967]
-Wed Dec 7 16:39:18 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (range_include): use discrete membership for non Numeric
- values, for example, String.
-
- * numeric.c (num_scalar_p): new method. [ruby-dev:27936]
-
- * lib/complex.rb (Complex#scalar?): ditto.
-
Wed Dec 7 15:31:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* sprintf.c (rb_str_format): integer overflow check added.
@@ -17656,22 +8425,11 @@ Wed Dec 7 01:02:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/demos-en/menu.rb: ditto.
-Tue Dec 6 16:48:40 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (ruby_xmalloc2): change check condition for integer
- overflow. [ruby-dev:27399]
-
- * gc.c (ruby_xrealloc2): ditto.
-
Tue Dec 6 16:37:57 2005 Yuya Nishida <yuya@j96.org>
* eval.c (exec_under): avoid accessing ruby_frame->prev.
[ruby-dev:27948]
-Fri Dec 2 19:06:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (Compare): should not fold double byte alphabet on win9x.
-
Thu Dec 1 00:50:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_funcall2): allow to call protected methods.
@@ -17679,9 +8437,6 @@ Thu Dec 1 00:50:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
Wed Nov 30 23:52:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (struct parser_params): fields common to ripper must be
- placed at each same offset.
-
* parse.y (NEWHEAP, ADD2HEAP): set count after pointer was set.
fixed: [ruby-dev:27896]
@@ -17690,53 +8445,23 @@ Wed Nov 30 13:43:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* misc/ruby-mode.el (ruby-expr-beg): support $! at the end of
expression. [ruby-dev:27868]
-Mon Nov 28 20:24:22 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/pp.rb (PP::PPMethods#object_address_group): mask an address with
- word size.
-
-Tue Nov 29 23:57:05 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (struct parser_params): heap must be placed at same offset
- also in ripper.y. fixed: [ruby-dev:27846]
-
- * parse.y (yycompile): prevent vparser from tail call optimization.
- fixed: [ruby-dev:27851]
-
- * parse.y (parser_mark): value needs to be marked.
- fixed: [ruby-dev:27845]
-
-Tue Nov 29 22:45:30 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/observer.rb (notify_observers): follow change of observer.rb.
- fixed: [ruby-core:6796]
-
-Mon Nov 28 20:24:22 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/pp.rb (PP::PPMethods#object_address_group): adjust address format.
-
-Mon Nov 28 18:55:22 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Nov 28 18:55:43 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/socket.c (init_inetsock_internal): remove setting
SO_REUSEADDR option on server socket on Cygwin.
fixed: [ruby-core:6765] ([ ruby-Bugs-2872 ])
-Mon Nov 28 13:11:45 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Nov 28 13:08:54 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_strerror): remove all CR and LF. (avoid broken
error message on bccwin32 + winsock)
-Mon Nov 28 09:15:50 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Nov 28 09:21:49 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/mkmf.rb (create_makefile): should not change sodir with
- dir.gsub!. (bccwin32 failed to install third party extensions)
+ dir.gsub!. (bccwin32 failed to install third party exntesions)
[ruby-dev:27834]
-Sun Nov 27 05:37:20 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/pathname.rb: use File.basename to decompose pathnames.
- experimental Windows support.
-
Sun Nov 27 00:56:13 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/wsdl/xmlSchema/complexContent.rb: missing
@@ -17746,103 +8471,23 @@ Sat Nov 26 19:57:45 2005 WATANABE Hirofumi <eban@ruby-lang.org>
* dln.c (conv_to_posix_path): should initialize posix.
-Fri Nov 25 20:34:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/xmlrpc/datetime.rb (DateTime::to_a): comparison with non
- array-convertible object must return false.
-
-Fri Nov 25 14:34:09 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (range_max): treat end exclusion without iteration if
- the end value is an integer. [ruby-talk:167433]
-
-Fri Nov 25 12:52:57 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: added backward compatibility codes.
- * lib/rss/parser.rb: ditto.
- * test/rss/test_parser.rb: ditto.
- * test/rss/test_2.0.rb: ditto.
-
- * test/rss/test_content.rb: use #__send__ instead of #funcall for
- no private method.
-
-Fri Nov 25 12:39:56 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: improved type conversion.
- * lib/rss/1.0.rb: ditto.
- * lib/rss/0.9.rb: ditto.
- * lib/rss/2.0.rb: ditto.
- * lib/rss/image.rb: ditto.
- * lib/rss/syndication.rb: ditto.
-
- * test/rss/test_2.0.rb: added type conversion tests.
- * test/rss/test_accessor.rb: ditto.
- * test/rss/test_to_s.rb: ditto.
- * test/rss/test_syndication.rb: ditto.
- * test/rss/test_setup_maker_2.0.rb: ditto.
- * test/rss/test_setup_maker_1.0.rb: ditto.
- * test/rss/test_setup_maker_0.9.rb: ditto.
- * test/rss/test_maker_sy.rb: ditto.
- * test/rss/test_maker_image.rb: ditto.
- * test/rss/test_maker_2.0.rb: ditto.
- * test/rss/test_maker_0.9.rb: ditto.
- * test/rss/test_image.rb: ditto.
-
- * test/rss/test_maker_1.0.rb: use assert instead of assert_equal.
-
- * test/rss/rss-assertions.rb: improved type conversion assertions.
-
-Fri Nov 25 10:38:20 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/image.rb: added Image prefix.
-
- * lib/rss/maker/image.rb: ditto.
-
-Fri Nov 25 10:33:02 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/test_2.0.rb: added RSS 2.0 tests.
-
- * test/rss/rss-assertions.rb: extended XML stylesheet assertion.
-
- * lib/rss/0.9.rb: added initialize method.
-
- * test/rss/test_1.0.rb: cleanup.
-
-Fri Nov 25 10:29:48 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Nov 24 21:05:58 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * range.c (range_min): use <=> comparison rather than iteration.
- [ruby-talk:167420]
+ * configure.in (AC_CHECK_FUNCS): need to check link().
+ fixed: [ruby-dev:27814]
- * range.c (range_max): ditto.
-
-Thu Nov 24 01:31:44 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Nov 24 01:22:25 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* file.c (w32_io_info): CreateFile failed on Win9x if file was already
opened. (FILE_SHARE_READ was needed, but actually I don't understand
the flags of CreateFile well...)
-Wed Nov 23 23:52:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (num_div): use floor rather than rb_Integer().
- [ruby-dev:27674]
-
-Wed Nov 23 22:34:15 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/parser.rb: added entity handling type predicate.
- * lib/rss/rexmlparser.rb: ditto.
- * lib/rss/xmlparser.rb: ditto.
- * lib/rss/xmlscanner.rb: ditto.
-
- * lib/rss/xmlscanner.rb: more robust entity handling.
-
- * test/rss/test_parser.rb: added an entity handling test.
-
Wed Nov 23 20:59:01 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: add Tk.pkgconfig_list and Tk.pkgconfig_get
[Tk8.5 feature].
- * ext/tk/lib/tk/text.rb: supports new indices modifiers on a Text
+ * ext/tk/lib/tk/text.rb: supports new indices modifires on a Text
widget [Tk8.5 feature].
* ext/tk/lib/tk/virtevent.rb: add TkNamedVirtualEvent.
@@ -17852,7 +8497,7 @@ Wed Nov 23 20:59:01 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/event.rb: add :data key for virtual events [Tk8.5
feature].
-Wed Nov 23 18:52:45 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Nov 23 18:55:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* file.c (w32_io_info): should not call GetFileInformationByHandle
for pipe.
@@ -17861,61 +8506,15 @@ Wed Nov 23 18:52:45 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* file.c (w32_io_info): now can identify directory on WinNT.
-Wed Nov 23 18:46:53 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/: use #__send__ instead of #send.
- * test/rss/: ditto.
-
-Wed Nov 23 18:32:56 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/test_taxonomy.rb: use #reject directory.
-
-Wed Nov 23 18:26:00 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/taxonomy.rb: changed class or module prefix to
- Taxonomy from Taxo.
- * lib/rss/maker/taxonomy.rb: ditto.
-
-Wed Nov 23 18:21:11 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/maker/taxonomy.rb: implemented taxonomy module for RSS
- Maker.
- * lib/rss/taxonomy.rb: supported RSS Maker.
- * lib/rss/maker.rb: added taxonomy module support.
-
- * lib/rss/rss.rb: adjusted to other element API.
- * lib/rss/1.0.rb: adjusted to other element API but backward
- compatibility is reserved.
- * lib/rss/0.9.rb: ditto.
-
- * test/rss/test_maker_taxo.rb: added test case for taxonomy module
- for RSS Maker.
- * test/rss/test_setup_maker_1.0.rb: added tests for taxo:topic.
-
- * test/rss/test_setup_maker_1.0.rb: added backward compatibility
- test.
- * test/rss/test_setup_maker_0.9.rb: ditto.
- * test/rss/test_setup_maker_2.0.rb: ditto.
-
- * test/rss/rss-testcase.rb: added convenience method for setting
- up taxo:topic.
- * test/rss/rss-assertions.rb: added assertion for taxo:topic.
-
- * sample/rss/blend.rb: followed new API.
-
-Wed Nov 23 17:42:24 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: fixed a indentation bug.
-
- * lib/rss/taxonomy.rb: fixed <taxo:topic> #to_s bug.
-
- * test/rss/test_taxonomy.rb: added a #to_s test.
-
Wed Nov 23 03:40:49 2005 Guy Decoux <ts@moulon.inra.fr>
* re.c (KR_REHASH): should cast to unsigned for 64bit CPU.
[ruby-core:06721]
+Wed Nov 23 11:01:33 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * intern.h, file.c: failed to compile on windows.
+
Wed Nov 23 07:26:44 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: check for X509V3_EXT_nconf_nid.
@@ -17947,14 +8546,14 @@ Tue Nov 22 18:36:11 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (winnt_stat): set mapped errno instead of ENOENT.
-Tue Nov 22 14:36:54 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Nov 22 14:46:57 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (rb_file_s_basename): skip slashes just after UNC top slashes.
* test/ruby/test_path.rb (test_dirname, test_basename): follow new
spec. and add new tests.
-Tue Nov 22 13:30:15 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Nov 22 13:18:32 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_stat): Dir.chdir('//server/shared');
p Dir.glob('*') should work on WinNT. (implemented our own
@@ -17983,11 +8582,6 @@ Mon Nov 21 16:03:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/setup.mk: findstr doesn't exist on win9x.
fixed: [ruby-dev:27756]
-Sun Nov 20 21:39:27 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * regparse.c (fetch_token_in_cc): tok->escaped should be
- initialized. [ruby-dev:27763]
-
Sun Nov 20 22:34:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (rb_symname_p): [ not followed by ] is not valid symbol.
@@ -17998,10 +8592,6 @@ Sat Nov 19 19:57:54 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/fileutils.rb (FileUtils::ln): ln documentation fix.
[ruby-core:06661]
-Sat Nov 19 08:19:38 2005 Zach Dennis <zdennis@mktec.com>
-
- * ext/socket/socket.c: Socket Documentation. [ruby-core:6552]
-
Sat Nov 19 07:34:32 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/font.rb: remove dependency on Ruby's version (1.8
@@ -18011,7 +8601,7 @@ Sat Nov 19 07:34:32 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/tkextlib/treectrl/demo.rb: ditto.
-Fri Nov 18 18:07:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Nov 18 17:57:08 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (rb_file_s_dirname): should use skipprefix for UNC path.
pointed out by nobu ([ruby-dev:27744]). fixed: [ruby-core:5076]
@@ -18032,7 +8622,7 @@ Fri Nov 18 17:35:09 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/namespace.rb: ditto.
-Fri Nov 18 16:47:33 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Nov 18 17:26:06 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (rb_file_s_dirname): added checks for some patterns with drive
letter. fixed: [ruby-dev:27738]
@@ -18040,37 +8630,11 @@ Fri Nov 18 16:47:33 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* test/ruby/test_path.rb (test_dirname): added tests for above
patterns.
-Fri Nov 18 12:19:16 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Nov 18 12:18:02 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.h (S_IFIFO): r,w = IO.pipe; r.stat.pipe? now
returns true on VisualC++6.
-Thu Nov 17 17:58:00 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/1.0.rb: added convenience method 'resources'.
-
- * lib/rss/taxonomy.rb: ditto.
-
- * test/rss/rss-assertions.rb: added test for 'resources'.
-
- * test/rss/test_taxonomy.rb: ditto.
-
-Thu Nov 17 17:53:30 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/taxonomy.rb: implemented taxonomy module.
-
- * test/rss/test_taxonomy.rb: added tests for taxonomy support.
-
-Thu Nov 17 17:40:19 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/1.0.rb: added rdf:Bag.
-
-Thu Nov 17 13:52:00 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: removed needless argument 'prefix'.
-
- * lib/rss/parser.rb: ditto.
-
Wed Nov 16 23:24:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (static-ruby): overridable.
@@ -18080,24 +8644,12 @@ Wed Nov 16 23:24:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (RUBY, RUBYW): overridable.
-Wed Nov 16 01:29:31 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/trackback.rb: added TrackBack prefix.
-
- * lib/rss/maker/trackback.rb: ditto.
-
-Wed Nov 16 01:26:13 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb (RSS::VERSION): 0.1.5 -> 0.1.6.
-
- * test/rss/test_version.rb (RSS::TestVersion#test_version): ditto.
+Tue Nov 15 23:46:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Nov 15 23:54:24 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/find.rb (Find::find): should not ignore symbolic links to
+ non-existing files. [ruby-talk:165866]
- * file.c (file_load_ok): eaccess() returns 0 on success.
- fixed: [ruby-dev:27713]
-
-Tue Nov 15 16:36:03 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Nov 15 16:23:26 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* array.c (rb_ary_fill): previous commit disabled this usage:
@@ -18105,17 +8657,9 @@ Tue Nov 15 16:36:03 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
a.fill {|i| a[i] * 10} #=> [nil, nil, ...., nil]
previous commit has the advantage of early garbage collection, but
- potentially this would break some script. so I reverted behavior.
-
-Tue Nov 15 16:15:23 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (file_load_ok): use eaccess() instead of actually opening
- the file. [ruby-talk:156378]
+ potensially this would break some script. so I reverted behavior.
- * lib/jcode.rb (String::reverse): add new methods.
- [ruby-list:41245]
-
-Tue Nov 15 15:49:34 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Nov 15 16:04:10 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* array.c (rb_ary_fill): tail elements were vanished when the middle
part of array was filled. (ie: [0,1,2,3,4].fill(-1,2,1) => [0,1,-1])
@@ -18137,71 +8681,33 @@ Mon Nov 14 17:36:22 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_first): RDoc update from Daniel Berger
<djberg96@yahoo.com>. [ruby-core:06577].
-Sun Nov 13 10:55:24 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/uri/common.rb (escape): regard second argument as a
- character set. [ruby-dev:27692]
-
-Sat Nov 12 08:36:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in, eval.c, intern.h: check fd_mask type.
-
- * configure.in (socketpair): need to be checked.
-
-Fri Nov 11 19:53:47 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Nov 11 10:31:44 2005 Zach Dennis <zdennis@mktec.com>
- * eval.c, intern.h: failed to compile where NFDBITS is defined but
- howmany() is not defined. [ruby-dev:27680]
-
- * io.c (is_socket): failed to compile where S_ISSOCK is not defined.
-
- * io.c (pipe_open): failed to compile where socketpair is not supported.
+ * ext/socket/socket.c: Socket Documentation. [ruby-core:6552]
Fri Nov 11 08:20:56 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in (OUTFLAG): keep trailing spaces. [ruby-dev:27666]
- * mkconfig.rb: substitution references added.
+ * mkconfig.rb: substitution refereces added.
-Fri Nov 11 07:39:49 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Nov 11 07:44:18 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* configure.in: undef HAVE_LINK on BeOS. (link(2) always returns
EINVAL, and this causes error in test/fileutils.)
- * file.c: override chown(2) and fchown(2) on BeOS. (these functions
+ * file.c: overwride chown(2) and fchown(2) on BeOS. (these functions
should not change user/group id if -1 is passed as corresponding
argument, and this causes error in test/fileutils too)
[ruby-dev:27672]
-Thu Nov 10 21:05:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/shellwords.rb: fix for blank but not empty string.
- fixed: [ruby-dev:27663]
-
-Wed Nov 9 08:39:38 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/shellwords.rb: refactored. [ruby-core:06581]
-
-Tue Nov 8 17:35:53 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * intern.h, eval.c (rb_thread_signal_raise): constified.
-
- * signal.c: cosmetic change.
+ * file.c (rb_file_s_link): checks HAVE_LINK.
Tue Nov 8 15:32:27 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/drb/ssl.rb (DRb::SSLConfig#accept): fixed typo.
[ruby-dev:27560] [ruby-core:4627]
-Mon Nov 7 20:54:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c: iconvctl() support. [EXPERIMENTAL]
-
-Mon Nov 7 16:23:23 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/ossl.h: need to include winsock2.h before including
- windows.h by some openssl headers.
-
Mon Nov 7 13:43:51 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/stubs.c (_nativethread_consistency_check): use simpler
@@ -18212,7 +8718,7 @@ Mon Nov 7 13:43:51 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tkutil/tkutil.c: ditto.
-Mon Nov 7 00:06:12 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Nov 7 00:06:58 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/yaml.rb: removed :nodoc: to generate Kernel doc. [ruby-core:6324]
@@ -18221,7 +8727,7 @@ Sun Nov 6 23:39:13 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (Iconv::BrokenLibrary): exception when detected a
bug of underlying library.
-Sun Nov 6 21:43:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sun Nov 6 21:46:59 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/tk/stubs.c (ruby_tcl_create_ip_and_stubs_init): should touch
interpreter after initialization is done. [ruby-dev:27638]
@@ -18231,33 +8737,21 @@ Sun Nov 6 20:13:27 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_readlink): readlink(2) on AIX fails with ERANGE if
buffer size is less than required. fixed: [ruby-dev:27634]
-Sat Nov 5 13:42:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in, cygwin/GNUmakefile.in (mingw): use def file to alias
- symbols. [ruby-dev:27532]
-
- * bcc32/mkexports.rb, win32/mkexports.rb: make aliases in DLL.
-
- * win32/win32.c, win32/win32.h: replace symbols only when RUBY_EXPORT
- is defined.
-
-Thu Nov 3 07:57:39 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/open-uri.rb (open_loop): find_proxy should return nil when
- proxy does not exist. [ruby-dev:27630]
-
Wed Nov 2 20:25:28 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/extconf.rb: ext/tk/extconf.rb: change the check parameter
for Win32.
+Wed Nov 2 20:14:53 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib: merge into ext/tk and remove.
+
Wed Nov 2 19:03:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c (ip_rbUpdateObjCmd, ip_rb_threadUpdateObjCmd):
- passed improper flags to DoOneEvent().
+ * ext/tcltklib/tcltklib.c (ip_rbUpdateObjCmd,
+ ip_rb_threadUpdateObjCmd): passed improper flags to DoOneEvent().
- * ext/tk/tkutil/tkutil.c: use rb_obj_respond_to() instead of
- rb_respond_to().
+ * ext/tk/tkutil.c: use rb_obj_respond_to() instead of rb_respond_to().
Tue Nov 1 14:20:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -18267,7 +8761,7 @@ Tue Nov 1 14:20:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (exec_under): frame during eval should preserve external
information.
-Tue Nov 1 10:48:49 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Nov 1 10:50:17 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: should check ERR_peek_last_error().
[ruby-dev:27597]
@@ -18279,14 +8773,19 @@ Mon Oct 31 17:34:46 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* configure.in: use proper option for Sun linker. A patch from
Shinya Kuwamura <kuwa at labs.fujitsu.com>. [ruby-dev:27603]
-Mon Oct 31 05:46:08 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Oct 31 11:27:22 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * test/gdbm/test_gdbm.rb, test/sdbm/test_sdbm.rb (test_s_open_error):
+ skip on Win32/DOS platforms.
+
+Mon Oct 31 05:49:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_cipher.c (ossl_cipher_update): input data must
not be empty. [ruby-talk:161220]
* test/openssl/test_cipher.rb: add test for Cipher#update("").
-Mon Oct 31 05:38:26 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Oct 31 05:37:20 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpservlet/cgihandler.rb
(WEBrick::HTTPServlet::CGIHandler#do_GET): the value of Set-Cookie:
@@ -18298,14 +8797,17 @@ Mon Oct 31 05:38:26 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/webrick/test_cookie.rb, test/webrick/test_cgi.rb,
test/webrick/webrick.cgi: add some test for cookie.
-Mon Oct 31 02:33:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Oct 31 03:19:36 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/readline/readline.c (readline_readline): type check.
+ [ruby-core:6089]
* numeric.c (fix_rshift): RDoc fix. [ruby-core:6351]
* util.h (strtod): add #undef for platforms defines strtod()
macro. [ruby-dev:27563]
-Mon Oct 31 02:31:41 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Oct 31 02:35:59 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* test/ruby/test_float.rb (test_precision): test by assert_in_delta.
[ruby-dev:27575]
@@ -18317,33 +8819,25 @@ Sat Oct 29 01:58:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/fcntl/fcntl.c: ditto.
-Sat Oct 29 16:56:03 2005 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: added seven predicates sunday? to saturday?.
-
- * lib/date.rb: added two methods {prev,next}_month,
- that are almost same as << and >>.
-
-Thu Oct 27 20:34:43 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enumerator.c (enumerator_allocate): allow subclassing.
-
Thu Oct 27 16:45:31 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (scan_once): wrong condition to use mbclen2().
[ruby-dev:27535]
-Thu Oct 27 11:53:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * missing.h, missing/memcmp.c, missing/memmove.c:
- ANSI compatible interface.
-
-Wed Oct 26 09:15:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Oct 26 09:27:27 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/implicit.c (syck_type_id_to_uri): should return
newly allocated memory. otherwise, type_id will be freed
twice. [ruby-dev:27384] [ruby-core:6385]
+Wed Oct 26 09:04:51 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * ruby.h (Qfalse, Qtrue, Qnil, Qundef): make sure these immediate
+ values have VALUE type. there is an environment where sizeof(VALUE)
+ != sizeof(int) like IA64. if 32bit integer (Qtrue) is passed to ANYARGS
+ and received by 64bit integer (VALUE), upper bits may have garbage value.
+ [ruby-dev:27513]
+
Wed Oct 26 01:58:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_EXTERN): macro to export symbols in shared
@@ -18354,14 +8848,6 @@ Wed Oct 26 01:58:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): RUBY_EXTERN for static linked extensions.
-Tue Oct 25 20:06:59 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ruby.h (Qfalse, Qtrue, Qnil, Qundef): make sure these immediate
- values have VALUE type. there is an environment where sizeof(VALUE)
- != sizeof(int) like IA64. if 32bit integer (Qtrue) is passed to ANYARGS
- and received by 64bit integer (VALUE), upper bits may have garbage value.
- [ruby-dev:27513]
-
Tue Oct 25 15:32:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/rational.rb: applied documentation patch from Gavin Sinclair
@@ -18370,22 +8856,12 @@ Tue Oct 25 15:32:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/irb.rb (IRB::Irb::eval_input): handle prompts with newlines
in irb auto-indentation mode. [ruby-core:06358]
-Tue Oct 25 14:21:46 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * gc.c (garbage_collect): sorry, previous commit was incorrect.
- [ruby-core:6386]
-
-Tue Oct 25 13:40:16 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * gc.c (garbage_collect): return now whether there're rooms for new
- objects, rather than whether GC run. fixed: [ruby-core:6376]
-
Tue Oct 25 02:12:08 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/markup/simple_markup.rb (SM::SimpleMarkup::LABEL_LIST_RE):
reduce redundant backtrack. [ruby-talk:161771]
-Tue Oct 25 00:35:33 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Oct 25 00:27:35 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/*: RDoc documentation from Eric Hodel
<drbrain@segment7.net> added.
@@ -18395,19 +8871,11 @@ Mon Oct 24 21:14:29 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in, io.c: use sys/syscall.h if syscall.h is not available.
[ruby-core:06247]
-Mon Oct 24 20:38:25 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Oct 24 20:49:45 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/Win32API/lib/win32/resolv.rb (get_info): support multiple DNS.
fixed: [ruby-list:40058], [ruby-dev:27479]
-Mon Oct 24 11:01:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/canvas.rb (TkCanvasItemConfig::__item_val2ruby_optkeys):
- typo fixed. [ruby-talk:162187]
-
- * ext/tk/lib/tk/menu.rb (TkMenuEntryConfig::__item_val2ruby_optkeys):
- ditto. [ruby-core:06359]
-
Mon Oct 24 07:57:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/tk/lib/tk/canvas.rb (TkCanvasItemConfig::__item_val2ruby_optkeys):
@@ -18416,18 +8884,15 @@ Mon Oct 24 07:57:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/tk/lib/tk/menu.rb (TkMenuEntryConfig::__item_val2ruby_optkeys):
ditto. [ruby-core:06359]
- * lib/matrix.rb (Matrix::initialize): use funcall instead of send
- to allow private methods to be called. A report from
- Jean-Claude Arbaut <jcarbaut@laposte.net>. [ruby-core:06359]
+Sun Oct 23 21:50:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Oct 24 00:41:18 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (time_sunday): added predicate methods for the days of the
- week. [ruby-list:41340]
+ * ext/enumerator/enumerator.c: applied documentation patch from
+ James Edward Gray II <james@grayproductions.net>.
+ [ruby-core:06348]
Sun Oct 23 07:11:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/extconf.rb: improve messages [ruby-core:06325].
+ * ext/tcltklib/extconf.rb: improve messages [ruby-core:06325].
* ext/tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb,
ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb,
@@ -18454,16 +8919,6 @@ Sat Oct 22 23:54:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb, lib/mkmf.rb (with_config): support --with-extension
options. [ruby-dev:27449]
-Sat Oct 22 14:25:43 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * util.[hc] (ruby_add_suffix): constified.
-
- * util.[hc] (ruby_scan_{oct,hex}): fixed typo. (renamed from
- scan_{oct,hex})
-
- * util.c: almostly ANSI styled. (except for functions depending on
- macro and K&R technique)
-
Sat Oct 22 13:26:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* object.c (sym_inspect), parse.y (parser_yylex, rb_symname_p): check
@@ -18474,20 +8929,7 @@ Sat Oct 22 13:26:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* time.c (rb_strftime): removed meaningless volatile modifiers, and
concatenate successive nul characters at once. [ruby-dev:27472]
- * ext/tk/lib/tk/font.rb, ext/tk/lib/tkextlib/ICONS/icons.rb,
- ext/tk/sample/tkextlib/treectrl/demo.rb, lib/net/imap.rb,
- lib/rss/parser.rb, test/rss/test_content.rb,
- test/rss/test_dublincore.rb, test/rss/test_syndication.rb,
- test/rss/test_trackback.rb, test/ruby/test_eval.rb,
- test/socket/test_socket.rb, test/socket/test_udp.rb:
- Object#fcall was renamed as Object#funcall.
-
-Sat Oct 22 10:08:28 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * missing.h, missing/*.c: SUSv3 compatible strcasecmp and strncasecmp,
- ANSI compatible strtol and strtoul, and ANSI styled other functions.
-
-Fri Oct 21 19:16:08 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Oct 21 19:21:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* rubysig.h (CHECK_INTS): fixed typo. (I believe bit-or is improper)
@@ -18495,27 +8937,7 @@ Fri Oct 21 17:49:32 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* bin/erb (ERB::Main::run): typo fixed. [ruby-core:06337]
-Fri Oct 21 15:42:28 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * intern.h, struct.c (rb_struct_iv_get): constified.
-
- * marshal.c: avoid one VC++6 warning for implicit conversion
- from int to char.
-
- * ruby.h: ANSI styled.
-
- * bcc32/Makefile.sub (HAVE_HYPOT): added.
-
- * ext/socket/extconf.rb: BeOS is only one platform should call
- closesocket, so check __BEOS__ macro directly. (I was worried
- accidently HAVE_CLOSESOCKET is defined on windows again because
- it has it)
-
- * ext/socket/{getaddrinfo.c,socket.c}: ditto.
-
- ... these are all cosmetic changes.
-
-Fri Oct 21 15:23:23 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Oct 21 15:27:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bignum.c (bignew_1): convertion from `int' to `char' discards
upper bits, (ie. (char)0xff00 -> 0) so it's better to test if
@@ -18525,26 +8947,7 @@ Fri Oct 21 15:23:23 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* time.c: should use LONG_LONG instead of `long long'.
-Thu Oct 20 22:22:49 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parser.y (struct parser_params): parser never modify input string.
-
- * ext/ripper/tools/preproc.rb (prelude): do not append surplus
- newlines to fix line numbers.
-
-Thu Oct 20 11:41:57 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * class.c, eval.c, hash.c, st.c, variable.c: changed /* ??? */ stuff
- protoize generated to ANYARGS.
-
-Thu Oct 20 11:18:11 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * eval.c, file.c, ruby.c: removed strchr, strrchr, strstr definition
- because they are defined in missing.h.
-
- * missing.h, missing/strchr.c, missing/strstr.c: ANSI styled.
-
-Thu Oct 20 09:36:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Oct 20 09:37:15 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/mkmf.rb (create_makefile): Borland make seems not to allow
empty dependency list. If this change is not good, please correct
@@ -18555,13 +8958,20 @@ Thu Oct 20 07:55:09 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_makefile): get rid of a restriction
of Borland make. fixed: [ruby-dev:27460]
- * ext/ripper/depend: ditto.
+Thu Oct 20 00:13:18 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * rubysig.h (CHECK_INTS): fix typo.
Wed Oct 19 23:58:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_makefile): do not create unnecessary empty
directories. fixed: [ruby-dev:27451]
+Wed Oct 19 19:26:15 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (rb_gc_mark_parser): get rid of segfault with old yacc.
+ fixed: [ruby-dev:27439]
+
Wed Oct 19 08:28:32 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_join): elements may contain null pointer strings.
@@ -18569,33 +8979,27 @@ Wed Oct 19 08:28:32 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
Wed Oct 19 02:34:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enumerator.c, eval.c, gc.c, parse.y, regparse.c, sjis.c, time.c:
- made internal symbols static. [ruby-dev:27435]
-
-Tue Oct 18 10:58:27 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/dl/depend, ext/dl/extconf.rb, ext/socket/depend,
- ext/socket/extconf.rb: shouldn't define DESTCLEANFILES in depend,
- use $distcleanfiles in extconf.rb.
+ * eval.c, gc.c, time.c: made internal symbols static. [ruby-dev:27435]
- * win32/Makefile.sub (distclean-local): should remove .config.h.time.
+Wed Oct 19 01:27:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Oct 17 09:42:50 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+ * regex.c (re_compile_pattern): numeric literal inside character class
+ disabled succeeding backtrack. fixed: [ruby-list:41328]
- * mkconfig.rb: fixup configure_args for mswin32 configure.
+Mon Oct 17 21:18:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/configure.bat (srcdir, target): ditto.
+ * parse.y (parser_heap): byacc never free parser stack.
+ fixed: [ruby-dev:27428]
-Mon Oct 17 05:01:50 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Oct 17 16:04:47 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * env.h: move struct METHOD and struct BLOCK from eval.c to
- support NodeWrap and ParseTree.
+ * file.c (chmod_internal, lchmod_internal): fixed type of 2nd argument.
Sun Oct 16 22:16:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: omit non-existing directories.
-Sun Oct 16 14:40:54 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Oct 16 14:30:05 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/rinda.rb (Rinda::Tuple#initialize): check remote hash
tuple. fixed: [ruby-list:41227]
@@ -18613,48 +9017,20 @@ Sun Oct 16 03:38:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_schedule): clear rb_thread_critical.
[ruby-core:04039]
-Sun Oct 16 00:13:14 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/configure.bat: remove unnecessary line which prevents
- creating Makefile.
-
-Sat Oct 15 23:52:07 2005 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/ftp.rb: (getbinaryfile): allow nil for localfile, and
- returns retrieved data if localfile is nil.
-
- * lib/net/ftp.rb: (gettextfile): ditto.
-
-Sat Oct 15 19:51:29 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Oct 15 19:56:38 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* bin/erb: typo fixed, again. thanks, Doug Kearns.
-Fri Oct 14 23:09:31 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/Makefile.sub (MKFILES): update MKFILES if configure files get
- changed.
-
- * win32/configure.bat, win32/setup.mak (configure_args): store
- arguments to configure files.
-
-Fri Oct 14 22:05:45 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Oct 14 22:08:26 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (ioctl): should set errno.
-Fri Oct 14 16:39:37 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Oct 14 16:57:32 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/config.rb (Config::FileHandler): :UserDir should be nil.
It is harmful to permit the access to ~/public_html by default.
suggested by Hiroyuki Iwatsuki.
-Fri Oct 14 04:58:38 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_obj_instance_exec): create instance_exec and
- module_exec which pass arguments to the block.
-
- * eval.c (rb_f_funcall): rename fcall to funcall to follow
- tradition.
-
Thu Oct 13 23:29:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (HEAPCNT): bison allocates indivisible size.
@@ -18663,7 +9039,7 @@ Thu Oct 13 23:29:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c, pack.c, ext/syck/rubyext.c, ext/syck/syck.h, missing/isinf.c:
get rid of warnings. fixed: [ruby-core:06247]
-Wed Oct 12 12:51:56 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Wed Oct 12 12:52:57 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl.c (Init_openssl): should call
OpenSSL_add_ssl_algorithms().
@@ -18674,15 +9050,6 @@ Wed Oct 12 11:08:54 2005 WATANABE Hirofumi <eban@ruby-lang.org>
Tue Oct 11 21:41:58 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in (RUBY_FUNC_ATTRIBUTE): check prefixed attribute form
- first. [ruby-dev:27398]
-
- * array.c, enum.c, eval.c, util.c: safer function pointer usage.
- fixed: [ruby-core:06143]
-
- * util.h (qsort): removed the definition incompatible to ANSI.
- fixed: [ruby-core:06147]
-
* eval.c (rb_obj_respond_to): check if obj responds to the given
method with the given visibility. [ruby-dev:27408]
@@ -18693,66 +9060,33 @@ Tue Oct 11 00:01:21 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* st.c (st_free_table): do not call free() but xfree().
[ruby-core:06205]
-Sat Oct 8 19:49:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Oct 8 20:04:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (Init_Binding): add Binding#dup method. [yarv-dev:666]
- * io.c (rb_io_init_copy): clear PREP flag for copied IO.
- fixed: [ruby-dev:27371]
-
* parse.y (rb_parser_malloc, rb_parser_free): manage parser stack on
heap. [ruby-list:41199]
- * parse.y (ripper_initialize): use rb_respond_to().
-
- * ext/ripper/depend (check): get rid of re-generating ripper.y always.
-
* ext/iconv/charset_alias.rb: parse config.charset_alias file directly.
- * ext/nkf/lib/kconv.rb (Kconv.conv): get rid of nil.to_a.
-
- * lib/scanf.rb (Scanf::FormatSpecifier#letter, #width): use matched
- substring directly.
-
- * test/ruby/test_assignment.rb, test/ruby/test_iterator.rb: followed
- change of sample/test.rb.
-
- * test/net/http/test_http.rb: removed superfluous splatting stars.
-
-Fri Oct 7 16:41:43 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (splat_value): call rb_Array() to convert svalue to
- values. [ruby-dev:27397]
-
Fri Oct 7 09:54:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi.rb (CGI::Cookie::parse): Cookies from Nokia devices may
not be parsed correctly. A patch from August Z. Flatby
(augustzf) in [ruby-Patches-2595]. [ruby-core:06183]
-Thu Oct 6 22:51:30 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_Array): Array() to raise error for objects without
- to_ary, nor to_a.
-
- * object.c (nil_to_a): revert NilClass#to_a.
-
-Thu Oct 6 20:10:38 2005 Minero Aoki <aamine@loveruby.net>
+Thu Oct 6 20:12:16 2005 Minero Aoki <aamine@loveruby.net>
* ext/strscan/strscan.c (strscan_free): remove useless code.
[ruby-dev:26368] [ruby-dev:27389]
-
-Thu Oct 6 01:02:19 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * range.c (rb_range_beg_len): should return Qfalse for non-range
- object.
+ (backported from trunk, rev 1.22)
Wed Oct 5 04:42:38 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/xmlrpc/server.rb (XMLRPC::Server#initialize): should mount the
servlet on "/".
-Wed Oct 5 04:06:49 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Wed Oct 5 03:59:09 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/xmlrpc/server.rb (XMLRPC::Server#serve): delete wrong call
of "join".
@@ -18761,31 +9095,14 @@ Mon Oct 3 00:04:00 2005 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* pack.c (EXTEND16): [ruby-dev:27383]
-Sat Oct 1 23:55:24 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (do_select, rb_w32_select): brush up.
-
-Sat Oct 1 12:57:02 2005 Tanaka Akira <akr@m17n.org>
-
- * bignum.c (rb_big_rand): removed. [ruby-dev:25405]
-
-Sat Oct 1 01:46:51 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/open-uri.rb (OpenURI.open_loop): prohibit multiple proxy
- options.
-
Thu Sep 29 10:26:18 2005 Tanaka Akira <akr@m17n.org>
- * ext/dl/cptr.c (rb_dlptr_s_to_ptr): abolish sizeof(FILE).
+ * ext/dl/dl.c (rb_io_to_ptr): abolish sizeof(FILE).
[ruby-dev:27317]
-Thu Sep 29 10:15:14 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/open-uri.rb (:proxy_http_basic_authentication): new option.
-
Thu Sep 29 07:22:05 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_f_send): underscores need to be escaped.
+ * evalc. (rb_f_send): underscores need to be escaped.
fixed by Doug Kearns. [ruby-core:06053]
Thu Sep 29 00:57:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -18796,11 +9113,23 @@ Thu Sep 29 00:57:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* variable.c (rb_autoload_load): now return true if autoload
succeeded. fixed: [ruby-dev:27331]
-Wed Sep 28 23:40:04 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Sep 28 23:42:15 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (apply2files): add prototype.
* file.c (rb_stat_inspect): constified.
-Wed Sep 28 15:12:28 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * class.c (rb_mod_init_copy, rb_class_init_copy), file.c (rb_stat_init_copy),
+ numeric.c (num_init_copy), object.c (rb_obj_init_copy, Init_Object),
+ re.c (match_init_copy, rb_reg_init_copy), time.c (time_init_copy):
+ undocumented.
+
+Wed Sep 28 23:09:23 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/delegate.rb: document update from James Edward Gray II
+ <james@grayproductions.net>. [ruby-core:06027]
+
+Wed Sep 28 15:14:19 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI#start): req.query_string should
refer the value of QUERY_STRING. [ruby-list:41186]
@@ -18810,7 +9139,12 @@ Wed Sep 28 15:12:28 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
Wed Sep 28 10:45:44 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c: cannot compile with Tcl/Tk8.0.x [ruby-dev:27335].
+ * ext/tcltklib/tcltklib.c: cannot compile with Tcl/Tk8.0.x
+ [ruby-dev:27335].
+
+Wed Sep 28 08:12:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (read_buffered_data): check if reached EOF. fixed: [ruby-dev:27334]
Wed Sep 28 07:56:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -18821,7 +9155,7 @@ Wed Sep 28 07:56:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/yaml/types.rb (YAML::PrivateType, YAML::DomainType): ditto.
-Wed Sep 28 03:16:41 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Sep 28 03:23:35 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* rubysig.h: fixed build problem with --enable-pthread on platforms
which don't have setitimer().
@@ -18831,38 +9165,15 @@ Mon Sep 26 22:32:13 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (set_trace_func): add rb_secure(4) to prevent adding
tracing function.
-Mon Sep 26 20:59:28 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * parse.y: changed to ANSI function style.
-
-Sun Sep 25 12:02:04 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Sep 25 12:05:10 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* bin/erb: typo fixed.
-Sun Sep 25 11:54:11 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/rinda/tuplespace.rb (Rinda::TemplateEntry::initialize): pull
- up method. Tabs converted to spaces.
-
-Sun Sep 25 09:34:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * parse.y: replaced `foo _((boo))' with `foo(boo)'.
-
-Sun Sep 25 08:19:53 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/rss/test_content.rb, test/rss/test_syndication.rb: use fcall
- instead of send in order to override visibility.
-
Sun Sep 25 01:46:43 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-mode.el (ruby-calculate-indent): arrange deep-indent
closing parenthesis at same column as the opening.
-Sun Sep 25 01:33:41 2005 Tanaka Akira <akr@m17n.org>
-
- * process.c (proc_setrlimit): make the third argument (rlim_max)
- optional.
-
Sun Sep 25 00:42:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-mode.el (ruby-expr-beg): deal with heredoc separately.
@@ -18872,37 +9183,20 @@ Sun Sep 25 00:42:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
level for continuous line inside parentheses.
http://nabeken.tdiary.net/20050915.html#p02
-Sat Sep 24 21:19:39 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c: document enhancement.
+Sun Sep 25 00:18:11 2005 Tanaka Akira <akr@m17n.org>
- * ext/strscan/strscan.c: update copyright year.
-
- * ext/strscan/strscan.c: update coding style.
-
-Sat Sep 24 20:20:05 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/net/http/test_http.rb (teardown): Net::HTTP.version_1_1 breaks
- many other tests; ensure that Net::HTTP is version 1.2 after test.
- [ruby-dev:27312]
-
-Sat Sep 24 11:44:28 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/net/http/test_http.rb: new file.
+ * eval.c (unknown_node): show more information. [ruby-dev:26196]
-Sat Sep 24 08:54:05 2005 Minero Aoki <aamine@loveruby.net>
+Sat Sep 24 08:56:01 2005 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (cd): no longer accept :noop option, related
- code is useless. [ruby-core:05858] [ruby-Bugs:2494]
-
-Sat Sep 24 08:30:00 2005 Tanaka Akira <akr@m17n.org>
+ code is useless (backported from trunk, rev 1.67).
+ [ruby-core:05858] [ruby-Bugs:2494]
- * lib/pathname.rb (Pathname#sub): new method.
-
-Sat Sep 24 08:29:36 2005 Minero Aoki <aamine@loveruby.net>
+Sat Sep 24 08:38:07 2005 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb: fix visibility of FileUtils::NoWrite, Verbose,
- DryRun. [ruby-core:05954]
+ DryRun (backported from trunk, rev 1.66). [ruby-core:05954]
* test/fileutils/test_nowrite.rb: test it.
@@ -18910,163 +9204,32 @@ Sat Sep 24 08:29:36 2005 Minero Aoki <aamine@loveruby.net>
* test/fileutils/test_verbose.rb: new file.
-Sat Sep 24 07:59:01 2005 Minero Aoki <aamine@loveruby.net>
-
- * sample/ripper/colorize.rb: removed (replaced by ruby2html.rb).
-
- * sample/ripper/ruby2html.rb: added.
-
-Sat Sep 24 06:35:15 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper: no longer generates .rb files.
-
- * parse.y (Init_ripper): ripper_init_eventids*() takes 1 argument,
- self (class Ripper).
-
- * ext/ripper/depend: target removed: `lib/ripper/core.rb'.
-
- * ext/ripper/depend: new target `eventids2table.c'.
-
- * ext/ripper/depend: new target `check'.
-
- * ext/ripper/eventids2.c: include eventids2table.c.
-
- * ext/ripper/eventids2.c: initialize SCANNER_EVENT_TABLE.
-
- * ext/ripper/extconf.rb: update $cleanfiles list.
-
- * ext/ripper/tools/generate.rb: no longer generate ripper/core.rb.
-
- * ext/ripper/tools/generate.rb: new mode `check'.
-
- * ext/ripper/tools/generate.rb: new mode `eventids2table'.
-
- * ext/ripper/lib/ripper/core.rb.in: removed.
-
- * ext/ripper/lib/ripper/core.rb: added.
-
- * ext/ripper/lib/ripper/filter.rb: update copyright year.
-
- * ext/ripper/lib/ripper/lexer.rb: ditto.
-
- * ext/ripper/lib/ripper/sexp.rb: ditto.
-
Sat Sep 24 02:40:20 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb: document update from James Edward Gray II
<james@grayproductions.net>. [ruby-core:05942]
-Sat Sep 24 02:05:51 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * process.c (proc_daemon): should restrict execution on levels
- higher than $SAFE=2. suggested by URABE Shyouhei
- <shyouhei@ice.uec.ac.jp>.
-
-Fri Sep 23 20:10:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/ripper/tools/generate.rb, ext/ripper/tools/preproc.rb: StringIO
- is not available for miniruby. fixed: [ruby-dev:27307]
-
-Fri Sep 23 17:36:48 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: avoid core dump with WIN32OLE_EVENT.
- [ruby-dev:27133]
-
-Fri Sep 23 16:27:39 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/forwardable.rb: replaced by new implementation from
- <Daniel.Berger@qwest.com>. [ruby-core:05899]
-
-Fri Sep 23 07:07:47 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/ripper/depend: use --output option instead of redirect;
- nmake does not remove a target when the target file is created by
- redirect. [ruby-dev:26466]
-
- * test/ripper/tools/preproc.rb: new option --output.
-
-Fri Sep 23 06:57:52 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/ripper/tools/generate.rb: check parser event arity.
-
- * test/ripper/tools/generate.rb: detect crash of parser-event-IDs
- and scanner-event-IDs.
-
-Fri Sep 23 06:01:30 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_file.rb: check File#chown(nil,nil).
- [ruby-dev:27140]
-
-Fri Sep 23 05:57:23 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper: refactoring code generation tools. [ruby-dev:27247]
- [ruby-dev:27273]
-
- * ext/ripper/depend: use generate.rb.
-
- * ext/ripper/lib/ripper/core.rb: removed.
-
- * ext/ripper/tools/generate-eventids1.rb: removed (code moved to
- generate.rb).
-
- * ext/ripper/tools/generate-ripper_rb.rb: removed (code moved to
- generate.rb).
-
- * ext/ripper/tools/list-parse-event-ids.rb: removed (code moved to
- generate.rb).
-
- * ext/ripper/tools/list-scan-event-ids.rb: removed (code moved to
- generate.rb).
-
- * ext/ripper/lib/ripper/core.rb: removed.
-
- * ext/ripper: refactoring tests. [ruby-dev:27273]
-
- * ext/ripper/test/check-event-arity.rb: removed (code moved to
- tools/generate.rb).
-
- * ext/ripper/test/check-event-coverage.rb: removed (code moved to
- test/ripper/test_parser_events.rb).
-
- * ext/ripper/test/check-scanner-event-coverage.rb: removed (code
- moved to test/ripper/test_scanner_events.rb).
-
- * ext/ripper/test/list-called-events.rb: removed.
-
- * ext/ripper/test/src_rb: removed.
-
- * ext/ripper/test/validate.rb: removed.
-
- * test/ripper/test_scanner_events.rb: check event coverage.
-
- * ext/ripper/lib/ripper/core.rb.in: update copyright year.
-
-Thu Sep 22 23:40:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Sep 22 23:36:24 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (find_executable0): default path if environment is not
set. [ruby-dev:27281]
- * ext/ripper/extconf.rb (have_command): replaced with find_executable.
-
-Thu Sep 22 17:31:48 2005 Shugo Maeda <shugo@ruby-lang.org>
+Thu Sep 22 16:33:12 2005 Shugo Maeda <shugo@ruby-lang.org>
* test/readline/test_readline.rb (TestReadline::replace_stdio):
merged the patch of [ruby-dev:25232] instead of [ruby-dev:25223].
- (merged from ruby_1_8 branch)
Wed Sep 21 23:30:44 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (configuration): generalized nmake dependent code.
-Wed Sep 21 14:16:30 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Sep 21 09:07:55 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/ripper/depend (SUFFIXES): no longer needed.
-
- * ext/ripper/depend (c): avoid nmake problem. fixed [ruby-dev:27191]
+ * stable version 1.8.3 released.
Wed Sep 21 08:52:25 2005 why the lucky stiff <why@ruby-lang.org>
- * ext/syck/token.c: correctly compute indentation of a block
+ * ext/syck/token.c: correctly compute identation of a block
scalar's parent node. [ruby-talk:150620]
Wed Sep 21 08:20:24 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -19083,18 +9246,19 @@ Wed Sep 21 02:44:09 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* file.c (path_check_0): disallow sticky world writable directory
in PATH (and $LOAD_PATH). [ruby-dev:27226]
-Wed Sep 21 00:32:22 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * file.c (fpath_check): typo fixed.
+
+Tue Sep 20 22:29:49 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * numeric.c (fix_idiv): 1.div(1.0) should return integer value.
- [ruby-dev:27235]
+ * test/wsdl/simpletype/rpc/test_rpc.rb, test/wsdl/ref/test_ref.rb,
+ test/wsdl/any/test_any.rb test/soap/wsdlDriver/test_calc.rb:
+ suppress deliberate warnings with $VERBOSE = nil.
-Tue Sep 20 22:25:43 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Sep 20 21:26:23 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/io/wait/lib/nonblock.rb: disable on platforms non-blocking flag
is not available. fixed: [ruby-dev:27187]
- * file.c (rb_stat_inspect): protoized function pointer.
-
Tue Sep 20 18:23:04 2005 Tanaka Akira <akr@m17n.org>
* eval.c (thread_mark): mark th->last_status. [ruby-dev:27179]
@@ -19114,23 +9278,28 @@ Tue Sep 20 17:48:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/xmlrpc/server.rb (WEBrickServlet::service): ditto.
-Tue Sep 20 17:26:42 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Sep 20 17:34:46 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* test/webrick/test_cgi.rb: set ENV["PATH"] to CGIEnvPath on
windows. bcc32's runtime is not installed into system directory,
so it cannot be found without this setting. [ruby-dev:27166]
-Tue Sep 20 17:14:10 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * io.c: PIPE_BUF is not defined on BeOS. use _POSIX_PIPE_BUF instead.
- [ruby-dev:27185]
-
Tue Sep 20 17:10:38 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/dbm/test_dbm.rb (TestDBM::test_s_open_error): remove
test_s_open_error test to detect duplicate open.
[ruby-dev:27202]
+Tue Sep 20 17:08:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * io.c: PIPE_BUF is not defined on BeOS. use _POSIX_PIPE_BUF instead.
+ [ruby-dev:27185]
+
+Tue Sep 20 16:53:53 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * test/readline/test_readline.rb (TestReadline::replace_stdio):
+ BSD seek support from [ruby-dev:25223]. fixed: [ruby-dev:27150]
+
Tue Sep 20 15:39:40 2005 why the lucky stiff <why@ruby-lang.org>
* ext/syck/emitter.c (syck_scan_scalar): prevent indicators from
@@ -19147,57 +9316,49 @@ Tue Sep 20 15:39:40 2005 why the lucky stiff <why@ruby-lang.org>
* ext/syck/rubyext.c: loading of binary-typed nodes. prevent
emission of plain strings that look like symbols, but which aren't.
-Tue Sep 20 05:48:26 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Sep 20 05:50:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* test/xmlrpc/test_webrick_server.rb (setup_http_server):
should not include 'webrick/https' unless 'use_ssl' because
it fails where openssl is not installed.
-Tue Sep 20 01:24:45 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (splat_value): use to_a to splat non Array object.
-
- * object.c (nil_to_a): remove nil.to_a. [experimental]
-
-Tue Sep 20 01:01:41 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/mathn.rb (Fixnum): remove debug print.
-
- * lib/rational.rb (Rational): ditto.
-
Tue Sep 20 00:34:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (io_close): call rb_io_close() directly if io is a T_FILE
object. [ruby-dev:27156]
-Mon Sep 19 18:58:10 2005 Minero Aoki <aamine@loveruby.net>
+Mon Sep 19 19:09:08 2005 Minero Aoki <aamine@loveruby.net>
* file.c (rb_file_chown): should accept nil. [ruby-dev:27171]
+ (backport from trunk, rev 1.208)
-Mon Sep 19 18:29:54 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Sep 19 18:35:13 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (file_expand_path): allow pathnames to expand.
- [ruby-dev:27152]
+ * ext/dl/dl.c (rb_io_to_ptr): fix DragonFlyBSD support.
+ [ruby-dev:27151]
-Mon Sep 19 15:12:15 2005 Minero Aoki <aamine@loveruby.net>
+Mon Sep 19 14:17:04 2005 Minero Aoki <aamine@loveruby.net>
- * ext/ripper/depend: do not make ripper/core.rb. [ruby-dev:26462]
+ * ext/syck/emitter.c (syck_emit): passing an int* value to the
+ long* parameter causes unaligned access on LP64 systems.
+ [ruby-dev:27161]
-Mon Sep 19 14:49:19 2005 Minero Aoki <aamine@loveruby.net>
+Mon Sep 19 13:44:03 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * ext/ripper/eventids2.c: add prefix `t' to tLAMBDA-related lexer
- events.
+ * ext/win32ole/win32ole.c: avoid core dump with WIN32OLE_EVENT.
+ [ruby-dev:27133]
- * ext/ripper/lib/ripper/core.rb: updated.
+Mon Sep 19 10:36:06 2005 Minero Aoki <aamine@loveruby.net>
-Mon Sep 19 14:39:46 2005 Minero Aoki <aamine@loveruby.net>
+ * lib/fileutils.rb (cp_r): default is :dereference_root=>true for
+ backward compatibility. [ruby-dev:27145]
- * parse.y (do_block): do_block event dispatches 2 args.
- [ruby-dev:26964]
+ * test/fileutils/test_fileutils.rb (test_cp_r): test it.
- * ext/ripper/lib/ripper/core.rb: updated.
+Mon Sep 19 09:57:39 2005 Minero Aoki <aamine@loveruby.net>
- * ext/ripper/tools/list-parser-event-ids.rb: check arity mismatch.
+ * test/fileutils/test_fileutils.rb: backported from trunk (1.36).
+ (again) [ruby-dev:27145]
Mon Sep 19 07:45:37 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
@@ -19209,23 +9370,43 @@ Mon Sep 19 07:45:37 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_engine.c: (ossl_engine_load_privkey): set private
key flag.
- * test/openssl/test_pkey_rsa.rb: add test about private detection.
+Mon Sep 19 06:41:32 2005 Minero Aoki <aamine@loveruby.net>
-Mon Sep 19 06:38:03 2005 Minero Aoki <aamine@loveruby.net>
+ * lib/fileutils.rb: backported from trunk (rev 1.65):
- * lib/fileutils.rb: method renaming: collect_methods ->
- collect_method.
+ * lib/fileutils.rb (rm_r): new option :secure.
-Mon Sep 19 05:58:59 2005 Minero Aoki <aamine@loveruby.net>
+ * lib/fileutils.rb (rm_rf): new option :secure.
- * lib/fileutils.rb: use module_function instead of single extend.
+ * lib/fileutils.rb: new method #remove_entry_secure.
+
+ * lib/fileutils.rb (cd): remove option :noop.
+
+ * lib/fileutils.rb (cp_r): new option :dereference_root.
+
+ * lib/fileutils.rb (cp_r): new option :dereference_root.
+
+ * lib/fileutils.rb: new method #remove_entry.
+
+ * lib/fileutils.rb: new method #chmod_R.
+
+ * lib/fileutils.rb: new method #chown.
+
+ * lib/fileutils.rb: new method #chown_R.
+
+ * lib/fileutils.rb: new method .commands.
- * test/fileutils/test_fileutils.rb: test existence of singleton
- methods.
+ * lib/fileutils.rb: new method .options.
-Mon Sep 19 05:32:41 2005 Minero Aoki <aamine@loveruby.net>
+ * lib/fileutils.rb: new method .have_option?.
- * lib/fileutils.rb (remove_entry_secure): does not use chdir(2).
+ * lib/fileutils.rb: new method .options_of.
+
+ * lib/fileutils.rb: new method .collect_method.
+
+ * lib/fileutils.rb: use module_function instead of single extend.
+
+ * test/fileutils/test_fileutils.rb: backported from trunk (1.36).
Mon Sep 19 03:17:48 2005 Tanaka Akira <akr@m17n.org>
@@ -19237,24 +9418,13 @@ Mon Sep 19 03:17:48 2005 Tanaka Akira <akr@m17n.org>
which is full. [ruby-dev:27132]
* io.c (rb_io_syswrite): wrap the write system call by
- TRAP_BEG/TRAP_END to run signal hander in syswrite method.
- [ruby-dev:27134]
-
-Mon Sep 19 01:07:38 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+ TRAP_BEG/TRAP_END to enable signals when writing to a pipe which is
+ full. [ruby-dev:27134]
- * numeric.c (Init_Numeric): should define Fixnum#div.
- [ruby-dev:27129]
+Mon Sep 19 03:02:08 2005 Tanaka Akira <akr@m17n.org>
- * file.c (rb_thread_flock): wrap flock(2) by TRAP_BEG and
- TRAP_END. [ruby-dev:27122]
-
- * file.c (rb_file_join): call FilePathValue() to all Pathnames to
- join. [ruby-dev:27127]
-
- * file.c (rb_get_path): call StringValueCStr() to ensure no nul
- bytes in path strings.
-
- * gc.c (garbage_collect): need value for return. [ruby-dev:27127]
+ * io.c (io_fwrite): wrap the write system call by TRAP_BEG/TRAP_END to
+ enable signals when writing to a pipe which is full.
Sun Sep 18 02:10:47 2005 why the lucky stiff <why@ruby-lang.org>
@@ -19272,10 +9442,6 @@ Sun Sep 18 02:10:47 2005 why the lucky stiff <why@ruby-lang.org>
* test/yaml/test_yaml.rb: remove outdated tests.
-Sun Sep 18 01:10:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (garbage_collect): return false if no GC run.
-
Sat Sep 17 23:25:04 2005 sheepman <sheepman@sheepman.sakura.ne.jp>
* lib/mathn.rb (Rational::inspect): should preserve original
@@ -19286,79 +9452,6 @@ Sat Sep 17 23:20:27 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi.rb (CGI::Cookie): should handle multiple values for a
cookie name. [ruby-talk:156140]
- * test/socket/test_tcp.rb (TestTCPSocket::test_recvfrom): typo
- fixed. [ruby-dev:27123]
-
-Sat Sep 17 20:58:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.c (rb_w32_select): fixed deadlock bug.
- because select(2) modifies its fd_set arguments, it must be
- restored sometimes.
-
- * win32/win32.c (rb_w32_select): performance improvement when
- 'always readable/writable handles' and sockets are passed.
- sockets should be polled every time.
-
- require "net/http"
-
- Thread.new {
- loop do
- STDOUT.write(".") # busy on console (this is worst case though)
- end
- }
-
- # socket operation took long time. (sometimes timed out)
- Net::HTTP.start("www.ruby-lang.org") do |http|
- http.get("/cgi-bin/cvsweb.cgi/ruby/array.c?rev=1.179")
- end
-
-Sat Sep 17 14:54:40 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * test/ruby/test_readpartial.rb (test_open_pipe, test_with_stdio):
- these tests are working now, so turned on. (windows)
-
-Sat Sep 17 14:18:15 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.c (rb_w32_select): I hope performance problem was
- solved.
-
-Sat Sep 17 13:45:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.c (rb_w32_select): console support is back.
- but still has performance problem because I loosely took 1 second
- for wait time. I'll fix it later. (The reason I drastically changed
- the code is that I wanted to implement the fileset management as
- single function, and I was worried that if pipe or console
- was always available, socket may not be processed any time)
-
-Sat Sep 17 11:24:16 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.c (rb_w32_select): select for socket didn't work.
- this caused deadlock in drb test. this happened because GetFileType
- for socket handle returns FILE_TYPE_PIPE. Of course, it's not a
- pipe. So socket handle didn't reach winsock's select function.
-
- * win32/win32.c (rb_w32_select): read for pipe was still blocked
- even if writer handle was closed.
-
- r,w = IO.pipe
-
- Thread.new {
- sleep 3; puts "------- 1"
- w.puts("foo")
- sleep 3; puts "------- 2"
- w.puts("boo")
- sleep 3; puts "------- 3"
- w.close
- }
-
- until r.eof? # should break by w.close but didn't.
- puts r.gets
- end
-
- * win32/win32.c (rb_w32_select): temporary reverted console support
- but it'll be back soon.
-
Sat Sep 17 10:42:13 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: MultiTkIp#eval_string and bg_eval_string
@@ -19382,14 +9475,14 @@ Sat Sep 17 08:35:39 2005 Kouhei Sutou <kou@cozmixng.org>
* test/rss/test_maker_1.0.rb (RSS::TestMaker10#test_items): ditto.
-Sat Sep 17 08:02:53 2005 Shugo Maeda <shugo@ruby-lang.org>
+Fri Sep 16 23:09:20 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * lib/net/imap.rb: supported DIGEST-MD5. Thanks, Mathieu Arnold.
+ * ext/win32ole/win32ole.c (ole_search_event_at): bug fix
+ in ext/win32ole/sample/ienavi.rb.
- * lib/net/imap.rb: use fcall instead of send. Thanks, Satoru
- Takabayashi.
+ * ext/win32ole/win32ole/tests/testOLEEVENT.rb: ditto.
-Fri Sep 16 22:45:49 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Sep 16 22:41:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_extname): empty string for path name ending with a
period. fixed: [ruby-core:05651]
@@ -19397,19 +9490,6 @@ Fri Sep 16 22:45:49 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_join): smarter behavior at edge cases.
fixed: [ruby-core:05706]
- * gc.c (rb_memerror, ruby_xmalloc, ruby_xrealloc, rb_newobj): just
- abondon if no memory available, when interpreter is not running.
- [ruby-dev:27104]
-
- * gc.c (garbage_collect): return whether GC could run.
-
- * dir.c (rb_push_glob): fix delimiter bug. fixed: [ruby-dev:27105]
-
- * dir.c (dir_s_aref, dir_s_glob): allow multiple patterns.
- [ruby-dev:27110]
-
- * win32/win32.c (cmdglob): enable brace expansion.
-
Fri Sep 16 18:34:01 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/syck/node.c (syck_replace_str): was using return from the
@@ -19425,12 +9505,12 @@ Fri Sep 16 12:02:12 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/syck/rubyext.c (syck_resolver_transfer): remove C++ style
comment (//). [ruby-core:05793]
-Fri Sep 16 00:17:03 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Fri Sep 16 00:14:14 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/logger/test_logger.rb: unintentionally overwritten changes by
Usa. reverted.
-Fri Sep 16 00:03:11 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Sep 16 00:06:18 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI::Socket#initialize): should set
$stdout.binmode.
@@ -19444,10 +9524,10 @@ Thu Sep 15 23:25:21 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* SOAP
* allow to configure an envelope namespace of SOAP request. (#124)
- TemporaryNamespace = 'http://www.w3.org/2003/05/soap-envelope'
- @client.options["soap.envelope.requestnamespace"] =
+ TemporaryNamespace = 'http://www.w3.org/2003/05/soap-envelope'
+ @client.options["soap.envelope.requestnamespace"] =
TemporaryNamespace
- @client.options["soap.envelope.responsenamespace"] =
+ @client.options["soap.envelope.responsenamespace"] =
TemporaryNamespace
@client.do_proc(...)
@@ -19519,62 +9599,45 @@ Thu Sep 15 23:25:21 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* updated deprecated method usage. (#138)
-Thu Sep 15 22:40:27 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Sep 15 23:02:57 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * test/ruby/test_signal.rb (test_exit_action): skip the test using
- fork on fork-less platforms.
+ * win32/win32.h (rb_w32_stat): added prototype.
-Thu Sep 15 13:54:33 2005 Tanaka Akira <akr@m17n.org>
+Thu Sep 15 22:35:55 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/open-uri.rb: add :read_timeout option.
- [ruby-core:4848]
+ * test/ruby/test_signal.rb (test_exit_action): skip the test using
+ fork on fork-less platforms.
Thu Sep 15 11:39:18 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/dialog.rb: If a dialog does not show up yet,
TkDialogObj#name raises an exception. [ruby-talk:156109]
-Thu Sep 15 11:01:58 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_pipe_exec): remove unnecessary CloseHandle().
-
- * win32/win32.c (extract_console_fd, peek_console): new functions.
+Thu Sep 15 01:39:19 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * win32/win32.c (rb_w32_select): check consoles by polling them.
+ * lib/rinda/tuplespace.rb (Rinda::TemplateEntry::initialize): pull
+ up method. Tabs converted to spaces.
Thu Sep 15 00:18:24 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/net/telnet.rb (Net::Telnet::waitfor): replace sysread with
readpartial. [ruby-talk:127641]
-Wed Sep 14 23:28:28 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (collect_file_fd): rename from extract_file_fd.
-
- * win32/win32.c (extract_pipe_fd, peek_pipe): new functions.
-
- * win32/win32.c (rb_w32_select): check pipes by polling them.
-
Wed Sep 14 22:40:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (ruby_glob): glob function not using ruby exception system.
-Wed Sep 14 17:24:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c: changed `foo (*bar)_((boo))' to `foo (*bar)(boo)`.
+Wed Sep 14 01:26:03 2005 Minero Aoki <aamine@loveruby.net>
- * enumerator.c, eval.c, gc.c, intern.h, io.c, process.c, ruby.c,
- ruby.h, signal.c: ditto.
+ * lib/net/https.rb: backported from trunk, rev 1.3.
+ [ruby-dev:25673] (again), [ruby-dev:26617] (again),
+ [ruby-dev:27062]
-Wed Sep 14 15:06:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * ext/openssl/lib/net/https.rb: removed.
- * bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
+ * ext/openssl/lib/net/protocols.rb: removed.
- * defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
- gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
- node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
- rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
- util.c, util.h, variable.c: ditto.
+ * lib/net/http.rb: #use_ssl?, #use_ssl are moved from net/https.
Tue Sep 13 22:09:40 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
@@ -19595,20 +9658,19 @@ Tue Sep 13 21:47:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (BEGIN_CALLARGS): pop halfly pushed status.
fixed: [ruby-dev:26881]
-Tue Sep 13 20:24:37 2005 Tanaka Akira <akr@m17n.org>
+Tue Sep 13 16:26:45 2005 Minero Aoki <aamine@loveruby.net>
- * ruby.h (PRINTF_ARGS): new macro for printf style argument checking.
+ * lib/net/http.rb: backported from trunk, rev 1.128.
+ [ruby-dev:25673] [ruby-dev:26617]
-Tue Sep 13 15:41:29 2005 Minero Aoki <aamine@loveruby.net>
+ * lib/net/protocol.rb: backported from trunk, rev 1.78.
- * lib/net/http.rb: wrote docuemntation of HTTPRequest/HTTPResponse
- classes.
+ * lib/net/protocol.rb: new method #old_open to support net/smtp
+ and net/pop.
-Tue Sep 13 14:27:47 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * lib/net/smtp.rb: use #old_open.
- * string.c, missing.h: failed to build on powerpc-apple-darwin7.9.0
- because of crypt argument's constness mismatch. (I hope this works)
- (http://mput.dip.jp/autobuild/ruby-trunk/log/20050913T110001.gz)
+ * lib/net/pop.rb: ditto.
Tue Sep 13 12:33:05 2005 why the lucky stiff <why@ruby-lang.org>
@@ -19624,12 +9686,12 @@ Tue Sep 13 12:33:05 2005 why the lucky stiff <why@ruby-lang.org>
continue support of Object#to_yaml_type.
* ext/syck/rubyext.c: new emitter code. yaml_new and yaml_initialize
- get called, should they be present. consolidated all the diaspora of internal node types into the family below YAML::Syck::Node -- Map,
+ get called, should they be present. consolidated all the diaspora of internal
+ node types into the family below YAML::Syck::Node -- Map,
Seq, Scalar -- all of whom are SyckNode structs pointing to
- Ruby data. moved Object#yaml_new into the node_import and made it
- the default behavior. the target_class is always called wih
- yaml_new, prepended a parameter, which is the klass. loaded nodes
- through GenericResolver show their style.
+ Ruby data. moved Object#yaml_new into the node_import and made it the
+ default behavior. the target_class is always called wih yaml_new, prepended
+ a parameter, which is the klass. loaded nodes through GenericResolver show their style.
new Resolver#tagurize converts type ids to taguris.
* ext/syck/implicit.re: were 'y' and 'n' seriously omitted??
@@ -19648,28 +9710,6 @@ Tue Sep 13 12:33:05 2005 why the lucky stiff <why@ruby-lang.org>
* ext/syck/syck.h: reflect block_styles and new node functions.
-Tue Sep 13 08:09:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/ostruct.rb (new_ostruct_member): Object#send no longer call
- private methods. [ruby-dev:27044]
-
- * test/rss/test_dublincore.rb, test/rss/test_trackback.rb,
- test/ruby/test_eval.rb, test/socket/test_socket.rb: ditto.
-
- * test/ruby/test_lambda (test_call_with_block): lambda makes new scope
- for formal block parameter.
-
-Tue Sep 13 01:17:45 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_save_safe_level): no need to restrict safe level
- memoize in $SAFE>=3. [ruby-dev:27050]
-
-Tue Sep 13 00:02:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (apply2files): stricter callback definition.
-
- * file.c (rb_path_check): constified.
-
Mon Sep 12 20:53:06 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_pkcs7.rb (test_enveloped): skip this test
@@ -19677,83 +9717,29 @@ Mon Sep 12 20:53:06 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
compiled with OpenSSL-0.9.7d or earlier versions).
http://www.mail-archive.com/openssl-dev@openssl.org/msg17376.html
-Mon Sep 12 20:32:00 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.[hc] (rb_w32_argv_size, ...): reverted my latest change
- to avoid incompatible pointer warning. (mingw32)
-
-Mon Sep 12 19:58:53 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dln.c: avoid warning of const to non-const convertion.
- [ruby-dev:27041]
-
- * eval.c, io.c, ruby.c: ditto.
-
-Mon Sep 12 19:26:29 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * array.c: moved to ANSI function style from K&R function style.
- (used protoize on windows, so still K&R remains on #ifdef part of
- other platforms. And `foo _((boo))' stuff is still there)
- [ruby-dev:26975]
-
- * bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
- enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
- io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
- prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
- regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
- sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
- version.c: ditto.
-
Mon Sep 12 14:03:33 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/dbm/test_dbm.rb: remove locking test, which may not be
supported on some platforms. [ruby-dev:27030]
-Sun Sep 11 23:23:02 2005 Shugo Maeda <shugo@ruby-lang.org>
+Mon Sep 12 10:45:58 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/imap.rb (starttls): supported the STARTTLS command.
+ * ext/dl/dl.c (rb_io_to_ptr): merged a patch for DragonFly BSD
+ from Takahiro Kambe <taca at back-street.net>. [ruby-dev:27023]
-Sun Sep 11 22:18:07 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Sep 11 22:05:51 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* bin/erb (ERB::Main#run): set ERB#filename so that it is used
when reporting syntax/runtime errors. Tabs converted to spaces.
-Sat Sep 10 22:34:19 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c, bignum.c: protoize.
-
-Sat Sep 10 00:23:01 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (splat_value): simpler and consistent array conversion
- for argument splat. [yarv-dev:599]
-
-Fri Sep 9 16:45:25 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_times): make empty strings to keep taintness,
- and a little improvement. [ruby-dev:26900]
-
- * ext/iconv/iconv.c (iconv_try), ext/iconv/extconf.rb: get rid of meta
- characters in command line option. fixed: [ruby-talk:155369]
-
- * ext/iconv/iconv.c: protoized.
-
-Thu Sep 8 14:58:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * merged a patch from Takahiro Kambe <taca at back-street.net> to
- support DragonFly BSD. [ruby-dev:26984]
-
-Thu Sep 8 13:14:57 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
-
- * missing/strchr.c (strrchr): fixed a bug in detecting NUL in a
- string. [ruby-dev:26985]
-
-Wed Sep 7 17:29:27 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sat Sep 10 10:17:03 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_engine.c (ossl_engine_s_by_id):
OpenSSL::Engine.by_id calls given block before calling
ENGINE_init (block parameter is the return value of this method
itself). this functionality is useful to load dynamic shared
- engines.
+ engines. the following code is a sample of loading a key using
+ OpenSC PKCS #11 module.
require "openssl"
pkcs11 = OpenSSL::Engine.by_id("dynamic"){|e|
@@ -19770,7 +9756,7 @@ Wed Sep 7 17:29:27 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_engine.c (ossl_engine_get_cmds): new method
OpenSSL::Engine#cmds. it returms engine command definitions.
-Wed Sep 7 15:48:37 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sat Sep 10 10:09:47 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (asn1str_to_str): new function.
@@ -19783,6 +9769,64 @@ Wed Sep 7 15:48:37 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_pkcs7.rb: new file.
+Sat Sep 10 10:05:51 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_ns_spki.c (ossl_spki_initialize): assume that
+ the argument is a DER string if Base64 decoding failed.
+
+ * ext/openssl/ossl_ns_pki.c (ossl_spki_to_der): new method.
+
+ * test/openssl/test_ns_spki.rb: add new file.
+
+Sat Sep 10 09:56:24 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/lib/digest.rb: added SHA224, SHA256, SHA384 and SHA512.
+ these features are enabled if this library is compiled with
+ OpenSSL 0.9.8 or later.
+
+ * test/openssl/test_digest.rb: add test for new digests.
+
+Sat Sep 10 09:51:30 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl.c (ossl_raise): should use ERR_peek_last_error
+ to get last error on the current thread. And should report
+ errors on the stack while OpenSSL.debug is true.
+
+ * ext/openssl/ossl.c (ossl_get_errors): new method for debugging
+ this library.
+
+ * ext/openssl/ossl_ssl.c (ossl_sslctx_set_ciphers): fix error message.
+
+ * ext/openssl/ossl_x509req.c (ossl_x509req_set_attributes): get rid
+ of unused variable.
+
+ * ext/openssl/ossl_x509store.c (ossl_x509store_initialize): should
+ set @time to avoid warning.
+
+ * ext/openssl/ossl_x509store.c (ossl_x509store_set_default_paths,
+ X509_STORE_add_cert, X509_STORE_add_crl): should raise error if
+ wrapped functions failed.
+
+ * test/openssl/test_x509store.rb: add test for errors.
+
+Fri Sep 9 22:13:19 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): prohibit calling tainted method (>2) when
+ $SAFE == 0.
+
+Fri Sep 9 16:45:25 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_times): make empty strings to keep taintness,
+ and a little improvement. [ruby-dev:26900]
+
+ * ext/iconv/iconv.c (iconv_try), ext/iconv/extconf.rb: get rid of meta
+ characters in command line option. fixed: [ruby-talk:155369]
+
+Thu Sep 8 14:58:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * merged a patch from Takahiro Kambe <taca at back-street.net> to
+ support DragonFly BSD. [ruby-dev:26984]
+
Wed Sep 7 12:55:08 2005 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb: abolish mod === tempfile to avoid a problem
@@ -19796,15 +9840,6 @@ Wed Sep 7 10:45:15 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_terminated): show backtrace before propagate
exceptions to main thread.
-Wed Sep 7 09:21:41 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.[hc] (rb_w32_utime): constified.
-
- * win32/win32.h (rb_w32_stat): added prototype.
-
- * win32/win32.[hc] (rb_w32_argv_size,rb_w32_join_argv,rb_w32_aspawn):
- changed `char *const *' to `const char *const *'. (constify string)
-
Wed Sep 7 08:35:04 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, configure.in (MINIOBJS): miniruby on HP-UX can not load
@@ -19823,62 +9858,37 @@ Wed Sep 7 08:35:04 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/etc/etc.c (setup_passwd), ext/etc/extconf.rb: pw_age might be
char*. fixed: [ruby-core:05470]
-Wed Sep 7 08:32:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_times): should taint empty strings as well.
+Wed Sep 7 08:32:47 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * object.c (Init_Object): make class_variable_{get,set} public.
- [ruby-dev:26965]
+ * object.c (rb_mod_cvar_get, rb_mod_cvar_set): document fix from
+ sheepman <sheepman@sheepman.sakura.ne.jp>; a bug in visibility
+ description. [ruby-dev:26965]
-Mon Sep 5 22:28:46 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (stmt, mlhs_node, lhs, arg, method_call): aref_args might be
- nothing. fixed: [ruby-dev:26952]
-
- * ext/ripper/eventids2.c: added new tokens. fixed: [ruby-dev:26952]
+ * sprintf.c (rb_f_sprintf): warn "too many argument" on verbose
+ mode (-v/-w); backported from 1.9. [ruby-dev:26963]
Mon Sep 5 17:03:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/find.rb: should raise ENOENT if root entry does not exist.
- [ruby-list:41054]
-
* lib/ostruct.rb: a patch from Florian Gross <florgro at gmail.com>
merged to allow recursive inspect (and to_s) for OpenStruct.
[ruby-core:05532]
-Mon Sep 5 08:20:19 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/observer.rb: a patch from nornagon <nornagon at gmail.com>
- merged to allow arbitrary names for update methods.
- [ruby-core:05416]
-
Mon Sep 5 07:01:12 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/openssl/lib/openssl/buffering.rb (Buffering#do_write):
should clear data from the buffer which already been output.
-Sun Sep 4 15:01:35 2005 Minero Aoki <aamine@loveruby.net>
-
- * parse.y (f_arg): Ripper should not do semantic check.
- [ruby-dev:26948]
-
-Sat Sep 3 23:52:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_fcall): new method to avoid inefficiency of
- obj.instance_eval{send(...)} tricks.
-
-Sat Sep 3 13:59:31 2005 Tanaka Akira <akr@m17n.org>
+Fri Sep 2 23:51:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/pathname.rb (Pathname#descend): Pathname.new("./a/b/c").descend
- didn't yield "."
- (Pathname#ascend): ditto.
+ * lib: do not use __send__ to access private methods. [ruby-dev:26935]
-Fri Sep 2 23:51:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Sep 2 03:29:00 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
- * parse.y (f_arg): f_norm_arg is a VALUE in ripper, not an ID.
- fixed: [ruby-dev:26942]
+ * lib/irb/init.rb: make IRB -I option that is same befavior for ruby.
+ [ruby-dev:26872], [ruby-dev: 26920]
- * lib: do not use __send__ to access private methods. [ruby-dev:26935]
+ * lib/irb/locale.rb: support to print help message when OS locale is
+ ja_JP.utf-8. [ruby-dev:26872]
Thu Sep 1 17:11:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -19893,31 +9903,20 @@ Thu Sep 1 14:12:45 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
to support '-namespace' option of 'interp invokehidden' command
on Tcl8.5.
-Wed Aug 31 14:41:30 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Aug 31 14:43:15 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub (OPTFLAGS): default global optimization to
disabled for all VC++ versions. fixed: [ruby-dev:26897]
-Wed Aug 31 10:36:09 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * process.c (proc_detach, proc_setmaxgroups): missing argument type
- declaration. (I recommend ANSI-style function)
-
-Wed Aug 31 06:59:01 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_scan): already String#scan behaves differently
- regarding if block is given.
-
-Tue Aug 30 23:49:34 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c, dir.c, enum.c, hash.c, io.c, range.c, string.c, struct.c:
- let enumerable methods return Enumerator. [ruby-dev:26924]
+Wed Aug 31 11:35:43 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * intern.h (RETURN_ENUMERATOR): utility macro for enumerable methods.
+ * test/gdbm/test_gdbm.rb (teardown): should remove GDBM temporary
+ file.
-Tue Aug 30 23:25:45 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Wed Aug 31 10:30:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/debug.rb: no need to restart at exit.
+ * process.c (proc_detach, proc_setmaxgroups): missing argument type
+ declaration. (I recommend ANSI-style function)
Tue Aug 30 23:20:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -19936,47 +9935,24 @@ Tue Aug 30 19:34:27 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
ext/digest/sha1/sha1ossl.h: include <stddef.h> to avoid
error in compilation with OpenSSL-0.9.8. [ruby-list:41068]
-Tue Aug 30 16:19:40 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/irb/init.rb: bug fix. [ruby-dev: 26920]
-
-Tue Aug 30 16:13:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_count): new method. [ruby-dev:26895]
-
-Tue Aug 30 12:45:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_send): do not call private methods if the receiver
- is specified. [ruby-talk:153672]
-
-Mon Aug 29 19:47:18 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Aug 29 19:54:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/usage.rb: improper exceptions. [ruby-dev:26870]
* lib/rdoc/usage.rb: support the case when non-ruby code exists before
shebang. (this is needed when ri.bat is executed on windows)
-Mon Aug 29 18:58:05 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
+Mon Aug 29 17:48:17 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/irb/init.rb: make IRB -I option that is same befavior for ruby.
- [ruby-dev:26872]
-
- * lib/irb/locale.rb: support to print help message when OS locale is
- ja_JP.utf-8. [ruby-dev:26872]
+ * eval.c (method_arity): should return proper arity value.
+ [ruby-dev:26390]
-Mon Aug 29 01:43:05 2005 Tanaka Akira <akr@m17n.org>
+Mon Aug 29 01:19:57 2005 Tanaka Akira <akr@m17n.org>
- * lib/pathname.rb (Pathname#descend): new method.
- (Pathname#ascend): ditto.
+ * lib/time.rb (Time.parse): extract fractional seconds using
+ Date._parse. [ruby-talk:153859]
-Mon Aug 29 00:35:09 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/time.rb: require 'date/format' instead of 'parsedate'.
- (Time.parse): extract fractional seconds using Date._parse.
- (Time.strptime): extract fractional seconds using Date._strptime.
- [ruby-talk:153859]
-
-Sat Aug 27 20:13:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Aug 27 20:20:01 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/curses/curses.c ({curses,window}_clrtoeol): added. suggested
by Reyn Vlietstra.
@@ -19986,77 +9962,18 @@ Sat Aug 27 20:13:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/curses/view.rb: String =~ String is deprecated.
-Thu Aug 25 15:48:58 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/win32ole/win32ole.c: supress warnings. (win32)
-
-Wed Aug 24 11:01:26 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Aug 24 10:53:28 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* test/logger/test_logger.rb (test_shifting_size): should close log
device before unlink, since some platform cannot unlink opened
file.
-Tue Aug 23 06:07:02 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/lib/digest.rb: added SHA224, SHA256, SHA384 and SHA512.
- these features are enabled if this library is compiled with
- OpenSSL 0.9.8 or later.
-
- * test/openssl/test_digest.rb: add test for new digests.
-
-Tue Aug 23 05:47:04 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_ns_spki.c (ossl_spki_initialize): try to decode
- the argument as a string.
-
- * ext/openssl/ossl_ns_pki.c (ossl_spki_to_der): new method.
-
- * ext/openssl/ossl_x509store.c (ossl_x509store_initialize): should
- set @time to avoid warning.
-
- * ext/openssl/ossl_x509store.c (ossl_x509store_set_default_paths,
- X509_STORE_add_cert, X509_STORE_add_crl): should raise error if
- wrapped functions fails.
-
- * ext/openssl/ossl_ssl.c (ossl_sslctx_set_ciphers): fix error message.
-
- * ext/openssl/ossl_x509req.c (ossl_x509req_set_attributes): get rid
- of unused variable.
-
- * test/openssl/test_ns_spki.rb: add new file.
-
- * test/openssl/test_x509store.rb: add test for error.
-
-Tue Aug 23 01:11:40 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * sprintf.c (ruby__sfvwrite): should move `buf' to the end of
- `result'. [ruby-dev:26859]
-
-Mon Aug 22 23:51:19 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y: ONIG_OPTION_CAPTURE_GROUP conflicts with
- RE_OPTION_ONCE. [ruby-dev:26852]
-
-Mon Aug 22 20:11:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * missing/vsnprintf.c (BSD__sprint): needs to call vwrite function
- pointer. fixed: [ruby-dev:26854]
-
-Sat Aug 20 23:55:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): update paren_nest for brackets [].
-
-Sun Aug 21 00:10:23 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Sun Aug 21 00:13:27 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/wsdl/xmlSchema/importer.rb (WSDL::XMLSchema::Importer#fetch): add
a workaround for importing an WSDL whose path begins with drive
letter. [ruby-dev:26242]
-Sat Aug 20 22:05:25 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * regexec.c (code_is_in_cclass_node): check code size.
- [ruby-dev:26840]
-
Sat Aug 20 22:37:13 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/logger.rb (write, shift_log?, shift_log): file shifting race
@@ -20069,25 +9986,23 @@ Fri Aug 19 18:13:39 2005 Tanaka Akira <akr@m17n.org>
* lib/time.rb (Time.apply_offset): fix a problem with last day of
month. reported by Lucas Nussbaum. [ruby-talk:152866]
-Thu Aug 18 11:05:36 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Aug 18 12:46:28 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * bcc32/Makefile.sub (COMMON_HEADERS): reverted 1.42.2.24.
+ I misunderstood, bccwin32 on ruby_1_8 uses winsock2 originally.
+ [ruby-dev:26806]
- * win32/win32.c (socketpair_internal): need to call open_ifs_socket()
- to create sockets instead of winsock's socket().
- fixed: [yarv-dev:581]
+ * win32/win32.h: include winsock2.h instead of winsock.h. (bcc32)
Wed Aug 17 23:58:05 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * object.c (rb_to_integer): argument constified.
+
* eval.c (terminate_process): take String message.
* eval.c (rb_thread_switch): propagate the exception caused thread
termination directly. fixed: [ruby-core:05552]
-Wed Aug 17 21:20:05 2005 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/lib/kconv.rb: ensure that symbol_to_option is private_class_method
- and all other methods are module_function
- fixed: [ruby-dev:26808]
-
Wed Aug 17 00:05:46 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_add_method): preserve safe level in the environment
@@ -20096,46 +10011,12 @@ Wed Aug 17 00:05:46 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_call0): restore preserved safe level in the method
execution.
- * parse.y (lambda): need separate block variable stack
- manipulation and lpar_beg maintenance. based on a patch found
- in [ruby-core:05551] from Mauricio Fernandez <mfp at acm.org>.
-
- * parse.y (parser_yylex): adjust lpar_beg after tLAMBEG and
- kDO_LAMBDA. [ruby-core:05551]
-
-Mon Aug 15 07:24:38 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h (rb_check_to_integer): add declaration.
-
- * object.c (rb_to_integer, rb_check_to_integer): argument constified.
-
Mon Aug 15 00:38:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_rescue2): reduce PUSH_TAG() as well as NODE_RESCUE.
[ruby-dev:26800]
- * range.c (range_check, range_init): reduce uselse exceptions.
-
-Mon Aug 15 00:34:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (yycompile): remove unreachable code. [yarv-dev:570]
-
-Sat Aug 13 22:16:12 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (remove_entry_secure): forgot final chdir.
-
-Sat Aug 13 22:07:49 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (remove_entry_secure): uses chdir(2) and check
- if current directory is correct. [ruby-dev:26100] [ruby-dev:26226]
-
-Sat Aug 13 21:11:05 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_VARIANT class.
-
- * ext/win32ole/tests/testall.rb: ditto.
-
- * ext/win32ole/tests/testOLEVARIANT.rb: ditto.
+ * range.c (range_check, range_init): reduce useless exceptions.
Sat Aug 13 18:51:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -20145,30 +10026,10 @@ Sat Aug 13 18:51:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_set_string): disallow nil.
http://www.rubyist.net/~nobu/t/20050811.html#c05
-Sat Aug 13 08:01:59 2005 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/lib/kconv.rb: Kconv.kconv is now alias of Kconv.conv
- * ext/nkf/lib/kconv.rb: remove nkf dependend symbols fomr SYMBOL_TO_OPTION
-
-Fri Aug 12 17:06:53 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_larglist): allow optional arguments even when
- parentheses are omitted. based on Nobu's patch from
- http://www.rubyist.net/~nobu/t/20050805.html
-
- * parse.y (parser_yylex): update & maintain lpar_beg for detect
- lambda parameters.
-
Thu Aug 11 23:29:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c: keep holding string after closed.
-Thu Aug 11 20:48:40 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
-
- * numeric.c (fix_equal, fix_cmp, fix_gt, fix_ge, fix_lt, fix_le):
- reduce coercing when a method knows about a operand type.
- [ruby-dev:26789]
-
Thu Aug 11 13:01:48 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss: fixed sort bug. [ruby-list:41018]
@@ -20193,33 +10054,6 @@ Thu Aug 11 13:01:48 2005 Kouhei Sutou <kou@cozmixng.org>
(RSS::TestSetupMaker10::test_setup_maker_items_sort): added some
tests for RSS::Maker::ItemsBase#do_sort.
-Wed Aug 10 12:01:20 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/delegate.rb: simplifies Delegator classes; SimpleDelegator
- now uses method_missing for all methods.
-
-Wed Aug 10 10:38:50 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big_mul0): multiply two numbers (x, y) without
- normalizing the result. x should be a big number.
- [ruby-dev:26778]
-
- * bignum.c (rb_big_pow): use rb_big_mul0() instead of
- rb_big_mul().
-
- * array.c (rb_ary_or, rb_ary_and, rb_ary_plus, rb_ary_diff):
- revert the change on 2005-08-03. Set operation on other item
- should have in separate methods.
-
- * parse.y (shadowing_lvar_gen): warn when arguments shadows
- external local variables.
-
- * parse.y (f_opt): optional arguments should not clobber external
- local variables.
-
- * parse.y (f_rest_arg): rest arguments should not clobber external
- local variables.
-
Wed Aug 10 10:29:40 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: fix bug on handling __ruby2val_optkeys().
@@ -20231,19 +10065,9 @@ Wed Aug 10 10:29:40 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/blt/component.rb: ditto.
-Tue Aug 9 21:53:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (formal_assign): let default values override
- arguments to zsuper. fixed: [ruby-dev:26743]
-
-Tue Aug 9 20:30:19 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
-
- * bignum.c (rb_big_coerce): allow bignum x bignum coercing.
- [ruby-dev:26778]
-
Tue Aug 9 15:12:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c: remove dangerous 'rb_jump_tag's.
+ * ext/tcltklib/tcltklib.c: remove dangerous 'rb_jump_tag's.
* ext/tk/lib/tk.rb: add __val2ruby_optkeys and __ruby2val_optkeys to
help to convert option values between ruby and tcl.
@@ -20266,56 +10090,28 @@ Tue Aug 9 15:12:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: support to treat tkvariable-type
configure options.
-Tue Aug 9 08:24:05 2005 Mauricio Fernandez <mfp@acm.org>
-
- * parse.y (f_block_arg), eval.c (rb_yield_0): deal with dynamic
- variable lambda arguments. [ruby-core:05540]
-
-Mon Aug 8 22:13:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (assign): deal with new block argument.
- fixed: [ruby-core:05536]
-
- * eval.c (rb_node_arity): follow change of NODE_ARGS.
- fixed: [ruby-dev:26761]
-
-Mon Aug 8 21:28:13 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Aug 9 20:30:19 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
- * test/ruby/test_fnmatch.rb: separated from test_file.rb.
+ * bignum.c (rb_big_coerce): allow bignum x bignum coercing.
+ [ruby-dev:26778]
-Mon Aug 8 20:40:35 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Mon Aug 8 20:43:02 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/ruby/test_method.rb: added. [ruby-dev:26761]
-Mon Aug 8 01:26:37 2005 Mauricio Fernandez <mfp@acm.org>
-
- * parse.y (f_larglist): mistake in syntax rule. [ruby-core:05535]
-
-Mon Aug 8 05:16:55 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl.c (ossl_raise): should use ERR_peek_last_error
- to get last error on the current thread. And should report
- if errors are on the stack while OpenSSL.debug is true.
-
- * ext/openssl/ossl.c (ossl_get_errors): new method for debugging
- this library.
+Sun Aug 7 23:50:14 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Mon Aug 8 05:15:19 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * test/ruby/test_super.rb: added from HEAD. [ruby-dev:26743]
- * lib/webrick/httpproxy.rb (HTTPProxyServer#intialize),
- lib/webrick/httpserver.rb (HTTPServer#intialize),
- lib/webrick/httpservlet/cgihandler.rb (CGIHandler#initialize),
- lib/webrick/httpservlet/erbhandler.rb (ERBHandler#initialize),
- lib/webrick/httpservlet/filehandler.rb(DefaultFileHandler#initialize):
- super (called with no arguments) takes default value of optional
- arguments. [ruby-dev:26743]
+Sun Aug 7 01:31:15 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * lib/webrick/httputils.rb: add a media-type "text/html" for .xhtml.
+ * ext/win32ole/win32ole.c (WIN32OLE_EVENT#on_event): should set
+ only one event handler.
-Sun Aug 7 23:52:39 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+ * ext/win32ole/tests/testOLEEVENT.rb: ditto.
- * test/ruby/test_super.rb: added optional arg tests. [ruby-dev:26743]
- the tests expects 1.8 behavior at this time.
+ * ext/win32ole/tests/testOLEPARAM.rb: remove re-defined
+ test_ole_type_detail method.
Sat Aug 6 12:35:24 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -20328,58 +10124,33 @@ Sat Aug 6 12:35:24 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/variable.rb: retains backward conpatibility.
-Fri Aug 5 12:48:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Aug 5 12:50:32 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c: fixed memory leak when tk_funcall raised
+ * ext/tcltklib/tcltklib.c: fixed memory leak when tk_funcall raised
exception. (copies argv into heap in tk_funcall instead of
caller)
-Fri Aug 5 12:36:40 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Aug 5 12:42:57 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/mkmf.rb (create_makefile): need to convert path separetor
before invoking install command.
-Fri Aug 5 08:08:05 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (return_jump): fix "can't across thread" error message
- when no thread associated.
- http://www.namikilab.tuat.ac.jp/~sasada/diary/200507.html#d31
-
-Fri Aug 5 00:25:12 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Aug 5 00:27:04 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c: refactoring - extract ruby string <->
+ * ext/tcltklib/tcltklib.c: refactoring - extract ruby string <->
tcl object conversion as get_str_from_obj and get_obj_from_str.
Fri Aug 5 00:19:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enumerator.c (Init_Enumerator): provided features should have
- extensions.
-
- * eval.c (rb_feature_p): returns type of the feature instead of
- extension.
-
- * eval.c (search_required): ruby library should be prior to statically
- linked extentions. fixed: [ruby-dev:26711]
-
- * eval.c (formal_assign): returns position of rest arguments variable.
-
- * parse.y (f_rest_arg): use anonymous variable for rest arguments.
- fixed: [ruby-dev:26647]
-
* extmk.rb (extmake): needs to be wrapped in an Array.
-Thu Aug 4 20:03:18 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
-
- * numeric.c (Init_Numeric): do not share implementation among
- Fixnum#/ and Fixnum#div. [ruby-core:05531]
-
Thu Aug 4 18:38:36 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c: cannot compile for Tcl7.6/Tk4.2.
+ * ext/tcltklib/tcltklib.c: cannot compile for Tcl7.6/Tk4.2.
- * ext/tk/tcltklib.c: add nativethread consistency check.
+ * ext/tcltklib/tcltklib.c: add nativethread consistency check.
- * ext/tk/stubs.c: ditto.
+ * ext/tcltklib/stubs.c: ditto.
* ext/tk/lib/tk.rb: forgot to define TclTkIp.encoding and encoding=
when Tcl is 7.6 or 8.0.
@@ -20393,11 +10164,6 @@ Thu Aug 4 18:38:36 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/SUPPRT_STATUS: update RELEASE_DATE
-Thu Aug 4 13:30:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (fix_div): should not convert the result into
- integer. [ruby-core:05524]
-
Thu Aug 4 08:03:39 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): should not modify $mflags for each
@@ -20412,84 +10178,47 @@ Thu Aug 4 00:25:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* {win32,wince}/Makefile.sub: separate config.h for compiler versions.
-Thu Aug 4 00:24:59 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * sprintf.c: replacing is no longer needed.
-
Wed Aug 3 21:59:16 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/variable.rb: TkVariable#trace didn't work on
TkVariable retrived from TkVariable.new_hash.ref. [ruby-dev:26721]
-Wed Aug 3 12:40:28 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
-
- * numeric.c (fix_plus): reduce coercing when a method knows about
- a operand type. [ruby-dev:26723]
-
- * numeric.c (fix_minus, fix_mul, fix_quo, fix_div, fix_mod,
- fix_divmod, fix_pow): ditto.
-
- * bignum.c (rb_big_div, rb_big_modulo): export to reduce
- coercing.
-
-Wed Aug 3 10:13:52 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * configure.in, {bcc32,win32,wince}/Makefile.sub (HAVE_SNPRINTF,
- HAVE_VSNPRINTF): use win32/win32.c's implementation instead of
- missing/vsnprintf.c's.
-
- * win32/win32.[ch] (rb_w32_snprintf, rb_w32_vsnprintf): reverted.
-
-Wed Aug 3 10:05:08 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: check vsnprintf() and snprintf().
-
- * sprintf.c, missing/vsnprintf.c: made vsnprintf() and snprintf()
- private. fixed: [ruby-dev:26651]
-
Wed Aug 3 08:22:13 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (ruby_connect): revert [ruby-talk:111654]
changes at 2004-09-07. [ruby-dev:26656]
-Wed Aug 3 06:53:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_or): wraps the operand in an array if it is not
- an array. [ruby-talk:150495] [EXPERIMENTAL]
-
- * array.c (rb_ary_and, rb_ary_plus, rb_ary_diff): ditto.
+Tue Aug 2 10:20:54 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Tue Aug 2 10:23:12 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/tk/tcltklib.c: use Tcl_[GS]etVar2Ex instead of
+ * ext/tcltklib/tcltklib.c: use Tcl_[GS]etVar2Ex instead of
Tcl_Obj[GS]etVar2. (avoid Tcl_NewStringObj on supported platforms)
- * ext/tk/tcltklib.c: use ip_{get,set,unset}_variable2_core from
+ * ext/tcltklib/tcltklib.c: use ip_{get,set,unset}_variable2_core from
ip_{get,set,unset}_variable.
- * ext/tk/tcltklib.c: replaced Tcl_Panic with rb_bug.
+ * ext/tcltklib/tcltklib.c: replaced Tcl_Panic with rb_bug.
-Tue Aug 2 01:40:38 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Aug 2 01:41:28 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/ping.rb (Ping.pingecho): should rescue StandardError.
[ruby-dev:26677]
-Mon Aug 1 19:02:23 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Aug 1 19:09:41 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c: refactoring - replaced rb_ivar_defined &
+ * ext/tcltklib/tcltklib.c: refactoring - replaced rb_ivar_defined &
rb_ivar_get with single rb_attr_get call.
-Mon Aug 1 18:44:08 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Aug 1 18:45:07 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c (Tcl_GetStringResult): refactoring - define
+ * ext/tcltklib/tcltklib.c (Tcl_GetStringResult): refactoring - define
alternative macro on Tcl7.x or earlier.
-Mon Aug 1 13:53:55 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Aug 1 13:57:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c (deleted_ip): refactoring - interpreter
+ * ext/tcltklib/tcltklib.c (deleted_ip): refactoring - interpreter
deletion check. [ruby-dev:26664]
-Mon Aug 1 01:08:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Mon Aug 1 01:17:40 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb (check_insecure_method): use private_methods and
protected_methods instead of respond_to? to check method visibility.
@@ -20499,205 +10228,86 @@ Mon Aug 1 01:08:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/ut_drb.rb: ditto.
-Sat Jul 30 18:49:44 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_TYPE#ole_typelib,
- WIN32OLE_TYPE#implemented_ole_types.
-
- * ext/win32ole/tests/testOLETYPE.rb: ditto.
+Mon Aug 1 00:07:32 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-Fri Jul 29 16:12:02 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/irb/context.rb: fix `irb --readline` option. [ruby-dev:40955]
+ * lib/irb/context.rb: fix `irb --readline` option. [ruby-list:40955]
Fri Jul 29 09:59:38 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_call0): fix calling zsuper from a method with anonymous
- rest argument. [ruby-dev:26639]
-
* eval.c (rb_yield_0): push yielded node instead of yielding.
fixed: [yarv-dev:549]
-Thu Jul 28 21:49:17 2005 IWATSUKI Hiroyuki <don@na.rim.or.jp>
-
- * parse.y (rb_parser_end_seen_p): exclude from ripper.
- <http://moonrock.jp/~don/d/200507.html#d28_t2>
-
- * sprintf.c (clearerr): remove standard macro before re-definition.
- <http://moonrock.jp/~don/d/200507.html#d28_t3>
-
Thu Jul 28 18:09:55 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/stubs.c: When --enable-tcltk-stubs, the initialize
+ * ext/tcltklib/stubs.c: When --enable-tcltk-stubs, the initialize
routine creates a Tcl/Tk interpreter and deletes it. However,
init cost of Tk's MainWindow is not so small. And that makes it
impossible to use libraries written with Tcl functions only on
an environment without a graphical display. This changes support
delaying initalization of Tk_Stubs until the script needs Tk.
- * ext/tk/stubs.h: New file. Define prototypes and return codes of
- functions on stubs.c.
+ * ext/tcltklib/stubs.h: New file. Define prototypes and return
+ codes of functions on stubs.c.
- * ext/tk/tcltklib.c: Support delaying initalization of Tk_Stubs
- until the script needs Tk.
+ * ext/tcltklib/tcltklib.c: Support delaying initalization of
+ Tk_Stubs until the script needs Tk.
- * ext/tk/tcltklib.c: Show friendly error messages for errors on
- initialization.
+ * ext/tcltklib/tcltklib.c: Show friendly error messages for errors
+ on initialization.
- * ext/tk/tcltklib.c: Avoid SEGV on ip_finalize() when ruby is
+ * ext/tcltklib/tcltklib.c: Avoid SEGV on ip_finalize() when ruby is
exiting and $DEBUG is true. (Not fix. If you know the reason of
why, please fix it.)
- * ext/tk/tkutil/tkutil.c (ary2list, ary2list2): bug fix on handling
- of encoding.
+ * ext/tk/tkutil.c (ary2list, ary2list2): bug fix on handling of
+ encoding.
* ext/tk/lib/multi-tk.rb: MultiTkIp#eval_string and bg_eval_string
don't work propery.
* ext/tk/lib/tk.rb: Forget extending Tk::Encoding module to Tk.
-
* ext/tk/lib/tk/variable.rb: TkVarAccess fails to initialize the
object for an element of a Tcl's array variable.
-Thu Jul 28 17:23:37 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_larglist): allow block argument in lambda parameter
- list without parenthesis.
-
-Thu Jul 28 17:14:01 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (each_i): typo fixed. [ruby-dev:26622]
-
-Thu Jul 28 15:04:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_arg): better argument name duplication check
-
- * parse.y (new_args_gen): factored out name duplication check for
- optional and rest arguments.
-
- * parse.y (new_bv_gen): allow shadowing outer local variables;
- warning remains.
-
-Thu Jul 28 13:46:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (ripper_warningS): the argument was omitted.
- [ruby-dev:26621]
-
-Thu Jul 28 11:30:57 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_larglist): allow bv_decl at the end of lambda
- argument list. [EXPERIMENTAL]
-
- * parse.y (new_bv_gen): allow local variable shadowing, with
- warning in verbose mode.
-
Wed Jul 27 23:23:54 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (obj_free): make message format consistent with one from
gc_mark(). [ruby-talk:149668]
- * sprintf.c (quad_t): prepare quad_t as well. [ruby-talk:149668]
-
Wed Jul 27 22:11:37 2005 Kouhei Sutou <kou@cozmixng.org>
* sample/rss/tdiary_plugin: removed. because the plugin
is imported in the tDiary plugin packages.
-Wed Jul 27 19:11:53 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (cd): follow :noop option change. (This patch
- is contributed by Doug Kearns)
-
-Wed Jul 27 16:25:59 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (lambda): Perl6 style -> lambda expression. [NEW]
- [VERY EXPERIMENTAL]
-
-Wed Jul 27 10:43:14 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (id2ref): must not assign pointers to long int. use
- LONG_LONG instead if SIZEOF_LONG < SIZEOF_VOIDP.
- [ruby-talk:149645]
-
- * ruby.h: use LONG_LONG to simplify the change.
- [ruby-talk:149645]
-
Wed Jul 27 10:59:02 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_each): rewinddir(3) before iteration.
[ruby-talk:149628]
-Wed Jul 27 02:34:58 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_f_throw): replace all '0x%lx' by '%p'.
- [ruby-talk:149553]
-
- * missing/vsnprintf.c (BSD_vfprintf): '%p' need to handle 64bit
- size pointer. [ruby-talk:149553]
-
-Tue Jul 26 22:41:28 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/sexp.rb: new method Ripper.sexp_raw.
-
- * ext/ripper/lib/ripper/sexp.rb (Ripper.sexp): returns more
- readable tree. This is suggested by Kirill A. Shutemov.
-
-Tue Jul 26 22:05:12 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: merge a patch contributed by Daniel Berger,
- with some modification. (RubyForge #2128)
-
-Tue Jul 26 18:11:33 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h: support LLP64 model. [ruby-talk:149524]
-
-Tue Jul 26 12:57:40 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Jul 26 12:57:49 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/openssl_missin.c: include <openssl/engine.h> before
<openssl/x509_vfy.h> to avoid compilation error of mswin32.
suggested by NAKAMURA Usaku.
-Mon Jul 25 23:48:55 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.[ch]: (rb_w32_vsnprintf, rb_w32_snprintf): removed.
-
Mon Jul 25 21:30:46 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * common.mk: Borland MAKE doesn't look for file names which have paths
- from VPATH. fixed: [ruby-dev:26604]
-
- * ruby.h (NORETURN, DEPRECATED): moved just after config.h.
-
- * {win32,wince}/Makefile.sub: vsnprintf() is in missing now.
-
* {bcc32,win32,wince}/Makefile.sub: moved CPPFLAGS only for ruby
source to XCFLAGS.
-Mon Jul 25 14:10:02 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/multi-tk.rb: fix en-bugged part in the last commit.
-
Mon Jul 25 13:45:18 2005 NAJIMA Hiroki <najima@mickey.ai.kyutech.ac.jp>
* io.c: check HAVE_SYS_IOCTL_H before including the header.
[ruby-dev:26610]
-Sat Jul 23 16:48:12 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_engine.c (ossl_engine_s_load): should check
- OPENSSL_NO_STATIC_ENGINE.
-
-Sat Jul 23 11:46:30 2005 Tanaka Akira <akr@m17n.org>
-
- * eval.c (rb_fd_select): the all three fd_sets must be long enough for
- select. fixed: [ruby-talk:149059]
+Mon Jul 25 14:10:02 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Jul 23 10:01:41 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/tk/lib/multi-tk.rb: fix en-bugged part in the last commit.
- * sprintf.c (rb_vsprintf, rb_sprintf): new functions return new String,
- using missing/vsnprintf.c. [ruby-dev:26580]
+Sat Jul 23 16:49:04 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * missing/vsnprintf.c: made the output changeable.
+ * ext/openssl/ossl_engine.c (ossl_engine_s_load): should check
+ OPENSSL_NO_STATIC_ENGINE.
Fri Jul 22 21:06:08 2005 Tadashi Saito <shiba@mail2.accsnet.ne.jp>
@@ -20731,12 +10341,12 @@ Fri Jul 22 14:37:43 2005 Kouhei Sutou <kou@cozmixng.org>
Fri Jul 22 07:01:42 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tkutil/tkutil.c (tk_conv_args): forget to revert
- thread_critical and gc_disable when raise ArgumentError.
+ * ext/tk/tkutil.c (tk_conv_args): forget to revert thread_critical
+ and gc_disable when raise ArgumentError.
* ext/tk/lib/remote-tk.rb: RemoteTkIp doesn't need to include TkUtil.
- * ext/tk/tcltklib.c: add TclTkIp#has_mainwindow? method.
+ * ext/tcltklib/tcltklib.c: add TclTkIp#has_mainwindow? method.
* ext/tk/lib/tk.rb: add Tk.has_mainwindow? method.
@@ -20768,17 +10378,11 @@ Fri Jul 22 07:01:42 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: fail to control a slave IP when Tk.mainloop
runs on the IP.
-Thu Jul 21 01:00:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/{nkf.c,utf8tbl.c,config.h}:
- import 1.76
- [ruby-dev:26592] nkf constification
-
-Wed Jul 20 19:18:52 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Jul 20 19:20:37 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* io.c (S_ISREG): need to define S_ISREG before it is used first.
-Wed Jul 20 18:33:15 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jul 20 18:40:50 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* io.c (wsplit_p): patch for the environment where
fcntl(F_GETFL, O_NONBLOCK) is not supported. in that case,
@@ -20794,7 +10398,7 @@ Wed Jul 20 10:04:51 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_class_path): need to adjust snprintf() len for
teminating NUL. [ruby-dev:26581]
-Wed Jul 20 03:58:52 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jul 20 04:01:55 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/socket/socket.c: sorry, BeOS also uses HAVE_CLOSESOCKET,
so reverted.
@@ -20802,7 +10406,7 @@ Wed Jul 20 03:58:52 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/socket/extconf.rb: should not define HAVE_CLOSESOCKET
on windows.
-Wed Jul 20 03:12:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jul 20 03:16:43 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/socket/socket.c: should not undef close() on win32.
it's defined to rb_w32_close(), otherwise handle leaks.
@@ -20818,22 +10422,19 @@ Tue Jul 19 22:47:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* error.c (syserr_initialize): add 1 byte for snprintf() size for
NUL at the end. [ruby-dev:26574]
-Tue Jul 19 17:16:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * signal.c (trap): remove sigexit(); handle "EXIT" via sig_exec().
- [ruby-dev:26440]
+Tue Jul 19 16:39:46 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_inspect): replace sprintf() with "%s" format all
over the place by snprintf() to avoid integer overflow.
-Tue Jul 19 14:10:50 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Jul 19 14:08:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c: rbtk_eventloop_depth is used as int.
+ * ext/tcltklib/tcltklib.c: rbtk_eventloop_depth is used as int.
- * ext/tk/tcltklib.c: rbtk_pending_exception is tested with
+ * ext/tcltklib/tcltklib.c: rbtk_pending_exception is tested with
NIL_P, so should assign Qnil instead of 0 (Qfalse).
- * ext/tk/tcltklib.c (ip_invoke_real): fixed memory leak when
+ * ext/tcltklib/tcltklib.c (ip_invoke_real): fixed memory leak when
ip is deleted.
Tue Jul 19 13:19:46 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -20842,50 +10443,33 @@ Tue Jul 19 13:19:46 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
returns a string even if the default value type of the TkVariable
object is not "string".
-Mon Jul 18 21:39:18 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Jul 18 21:40:20 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* eval.c (rb_call0): make the pointer to NODE volatile
instead of NODE itself.
Mon Jul 18 14:32:21 2005 Tanaka Akira <akr@m17n.org>
- * eval.c (rb_call0): make body volatile to avoid possible optimization
- problem.
+ * eval.c (rb_call0): make body volatile to avoid optimization problem.
[ruby-dev:26195]
Mon Jul 18 12:23:27 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/io/wait/wait.c: wrong backport from trunk, and compile error on
- platforms fd_set is not a bit set. fixed: [ruby-dev:26562]
+ * ext/io/wait/wait.c: wrong backport from trunk. fixed: [ruby-dev:26562]
Mon Jul 18 09:36:25 2005 Tanaka Akira <akr@m17n.org>
* rubyio.h (FMODE_WSPLIT, FMODE_WSPLIT_INITIALIZED): new constant.
* io.c (wsplit_p): new function.
- (io_fflush): split writing data by PIPE_BUF if wsplit_p is true in
+ (io_fwrite): split writing data by PIPE_BUF if wsplit_p is true in
multi-threaded mode.
- (io_fwrite): ditto.
[ruby-dev:26540]
-Mon Jul 18 05:00:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/nkf.c: import nkf.c 1.73
- fix: TestKconv 1F
-
Sun Jul 17 13:46:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/io/wait/extconf.rb, ext/io/wait/wait.c: Win32 platforms support.
-Sat Jul 16 23:43:16 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enumerator.c (Init_Enumerator): wrong argument specs.
- [ruby-core:05481]
-
-Sat Jul 16 15:52:50 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * win32/win32.[hc]: constified socket functions. [ruby-dev:26553]
-
Fri Jul 15 23:59:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/parsers/parse_c.rb (handle_class_module): handle a
@@ -20896,25 +10480,23 @@ Fri Jul 15 23:59:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/parsers/parse_c.rb (find_call_seq): allow :nodoc: modifier
in C. [ruby-core:04572]
-Fri Jul 15 23:20:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jul 15 18:00:01 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * enumerator.c (Init_Enumerator): use an internal directly.
+ * bcc32/Makefile.sub (COMMON_HEADERS): ruby_1_8 is using winsock.h.
+ failed to compile ext/socket on bcc5.6.4. [ruby-dev:26193]
-Fri Jul 15 07:58:10 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Jul 15 07:58:56 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/server.rb (WEBrick::GenericServer#accept_client):
sockets should be non-blocking mode. [ruby-dev:26405]
* lib/webrick/utils.rb (WEBrick::Utils.set_non_blocking): new method.
-Fri Jul 15 00:11:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * enum.c (enumeratorize): create new enumerator for current method if
- no block is given.
+ * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#read_chunked):
+ should call sock.read repeatedly until the preferred size data
+ is obtained.
- * enumerator.c: moved from ext/enumerator.
-
-Thu Jul 14 18:27:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Jul 14 18:27:16 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_strerror): should return correct message
for ENAMETOOLONG and ENOTEMPTY. (bcc32) [ruby-dev:26533]
@@ -20926,11 +10508,7 @@ Thu Jul 14 00:45:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* LEGAL (ext/nkf/nkf-utf8): updated from nkf1.7 to nkf-utf8.
-Wed Jul 13 22:44:00 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y: remove static variables. [ruby-dev:26530]
-
-Wed Jul 13 19:36:29 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jul 13 19:37:47 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_mkdir): should set EEXIST (not EACCES)
if file or directory already exists. (bcc32) [ruby-dev:26508]
@@ -20943,7 +10521,7 @@ Wed Jul 13 19:36:29 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
Wed Jul 13 12:40:00 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c: TclTkLib.do_one_event doesn't work.
+ * ext/tcltklib/tcltklib.c: TclTkLib.do_one_event doesn't work.
* ext/tk/lib/tk.rb: Tk.thread_update is available.
@@ -20951,30 +10529,16 @@ Tue Jul 12 23:32:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb: keep curdir unexpanded.
-Mon Jul 11 23:50:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c, intern.h (rb_proc_call, rb_obj_method, rb_method_call):
- export.
-
- * ext/enumerator/enumerator.c (enumerator_with_index): [EXPERIMENTAL]
- added a new method Enumerator#with_index. [ruby-talk:147728]
-
Mon Jul 11 08:31:29 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regparse.c (fetch_escaped_value): mask values following \c in
+ * regex.c (read_special): fix parsing backslashes following \c in
regexp. fixed: [ruby-dev:26500]
-Sun Jul 11 05:18:17 2005 Michael Neumann <mneumann@ruby-lang.org>
-
- * lib/xmlrpc/server.rb (XMLRPC::Server): Switch from GServer over to
- WEBrick. This makes file lib/xmlrpc/httpserver.rb obsolete (at least it is
- no further used by the XML-RPC library).
-
-Mon Jul 11 02:50:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Jul 11 02:53:00 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line):
- mistook to merge the patch of [ruby-dev:26235] at
- revision 1.11.
+ mistook in merging the patch of [ruby-dev:26235] at
+ revision 1.4.2.6.
Sun Jul 10 23:58:04 2005 Tanaka Akira <akr@m17n.org>
@@ -20982,12 +10546,18 @@ Sun Jul 10 23:58:04 2005 Tanaka Akira <akr@m17n.org>
avoid unlink a directory by root.
cf. [ruby-dev:26237]
+Sun Jul 11 05:18:17 2005 Michael Neumann <mneumann@ruby-lang.org>
+
+ * lib/xmlrpc/server.rb (XMLRPC::Server): Switch from GServer over to
+ WEBrick. This makes file lib/xmlrpc/httpserver.rb obsolete (at least it is
+ no further used by the XML-RPC library).
+
Sun Jul 10 12:47:01 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/debug.rb (debug_command): added a deficient format specifier.
fixed: [ruby-core:05419]
-Sat Jul 9 22:02:37 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sat Jul 9 21:28:46 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_method_dispid): convert dispid
in Ruby and C by INT2NUM and NUM2INT.
@@ -21012,36 +10582,6 @@ Fri Jul 8 15:45:04 2005 Kouhei Sutou <kou@cozmixng.org>
* test/rss/test_parser.rb (RSS::TestParser#test_category20):
adjusted test case.
-Wed Jul 6 18:45:53 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_obj_pattern_match): now returns nil.
- [ruby-core:05391]
-
-Mon Jul 4 14:35:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sample/svr.rb: service can be stopped by ill-behaved client; use
- tsvr.rb instead.
-
-Mon Jul 4 13:25:21 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * missing/erf.c: original erf.c by prof. Okumura is confirmed to
- be public domain. reverted BSD implementation.
-
-Wed Jul 6 11:15:21 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (open_ifs_socket): new function.
-
- * win32/win32.c (StartSockets, rb_w32_socket): use open_ifs_socket()
- instead of socket().
- all changes are derived from [ruby-core:5388].
-
-Wed Jul 6 00:15:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/{nkf.c,utf8tbl.c,config.h}:
- imported nkf.c 1.70 (support UTF-8-MAC)
-
- * ext/nkf/lib/kconv.rb: add :utf8mac and :internalunicode
-
Tue Jul 5 23:44:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* instruby.rb: expand source library path.
@@ -21058,19 +10598,19 @@ Tue Jul 5 15:15:10 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tkutil.c: fix typo.
-Tue Jul 5 14:52:56 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Tue Jul 5 14:51:35 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c: bug fix on treating Unicode strings.
+ * ext/tcltklib/tcltklib.c: bug fix on treating Unicode strings.
- * ext/tk/tcltklib.c: add methods to treat encoding mode.
+ * ext/tcltklib/tcltklib.c: add methods to treat encoding mode.
- * ext/tk/MANUAL_tcltklib.eng: add description of TclTkLib#encoding,
+ * ext/tcltklib/MANUAL.eng: add description of TclTkLib#encoding,
encoding_system, and so on.
- * ext/tk/MANUAL_tcltklib.eucj: ditto.
+ * ext/tcltklib/MANUAL.euc: ditto.
- * ext/tk/tkutil/tkutil.c: fail to create a Tcl's list string from
- an array including multiple kind of encoded strings.
+ * ext/tk/tkutil.c: fail to create a Tcl's list string from an
+ array including multiple kind of encoded strings.
* ext/tk/lib/tk.rb: ditto.
@@ -21096,11 +10636,17 @@ Tue Jul 5 14:52:56 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/namespace.rb: arguemnts for TclTkIp#_merge_tklist
should be UTF-8 strings.
-Mon Jul 4 19:29:32 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Jul 4 14:35:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sample/svr.rb: service can be stopped by ill-behaved client; use
+ tsvr.rb instead.
+
+Mon Jul 4 13:25:21 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/set.rb: test change to follow revision 1.28. (duck typing?)
+ * missing/erf.c: original erf.c by prof. Okumura is confirmed to
+ be public domain. reverted BSD implementation.
-Mon Jul 4 11:23:50 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Jul 4 11:15:37 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* test/{dbm,gdbm,sdbm}/test_{dbm,gdbm,sdbm}.rb: skip some tests
which using fork on fork-less platforms.
@@ -21123,18 +10669,11 @@ Sat Jul 2 17:06:23 2005 Tanaka Akira <akr@m17n.org>
* eval.c (flush_register_windows): new function.
- * ruby.h (NOINLINE): move up to be effective in defines.h.
-
-Sat Jul 2 15:19:41 2005 Tanaka Akira <akr@m17n.org>
-
- * configure.in: check select_large_fdset.
+Fri Jul 1 17:48:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c: use select_large_fdset to support large file descriptors
- on Solaris. [ruby-dev:26404]
-
-Fri Jul 1 17:55:08 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big_neg): may be accessing bogus pointer value.
+ * bignum.c (get2comp): revert all prior changes, and calculate
+ proper 2's complement for negative numbers. backported from
+ HEAD.
Fri Jul 1 15:50:12 2005 NAKAMURA Usaku <usa@ruby-lang.org>
@@ -21174,11 +10713,6 @@ Fri Jul 1 00:18:40 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (Delegator::respond_to): respond_to? must check
destination object. [ruby-talk:146894]
-Thu Jun 30 23:52:12 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * signal.c (trap): non-string trap hander was ignored.
- fixed: [ruby-dev:26417]
-
Thu Jun 30 19:00:21 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/irb/ruby-lex.rb (RubyLex::identify_number): alternative implements
@@ -21194,76 +10728,46 @@ Thu Jun 30 15:13:16 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): pre-evaluate argument for unambiguous
evaluation order. [ruby-dev:26383]
-Thu Jun 30 14:48:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/net/http.rb (Net::HTTP#connect, Net::HTTP#request): should
- not send proxy username and password to origin servers.
- [ruby-dev:25673]
-
- * lib/net/http.rb (Net::HTTP::ProxyDelta#edit_path): should not
- send HTTPS scheme URL to origine servers. [ruby-dev:25689]
-
Thu Jun 30 09:53:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (Delegator::method_missing): forward unknown
method to the destination. suggested by
<christophe.poucet@gmail.com>. [ruby-talk:146776]
-Wed Jun 29 00:03:20 2005 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * regparse.c (fetch_token): avoid warning of unused goto tag.
- [ruby-dev:26389]
-
Tue Jun 28 21:59:29 2005 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * dir.c, eval.c, parse.y, process.c, ruby.c: avoid warning "unused
+ * dir.c, eval.c, hash.c, process.c, ruby.c: avoid warning "unused
variable" [ruby-dev:26387]
- * dir.c (glob_helper): avoid warning "enumeration value `RECURSIVE'
- not handled in switch" [ruby-dev:26392]
-
-Tue Jun 28 01:52:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Sat Jun 25 17:15:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/nkf/lib/kconv.rb: add Kconv::VERSION
- * ext/nkf/lib/kconv.rb (conv): can process arrayed options
- * ext/nkf/nkf-utf8/nkf.c: imported Revision 1.69
- * ext/nkf/nkf-utf8/utf8tbl.c: imported Revision 1.9
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_query): should
+ discard if key=val pair is empty. patch from Gary Wright.
Sat Jun 25 23:30:51 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (detach_process_watcher): terminate process watcher
thread right after rb_waitpid() succeed. [ruby-talk:146430]
-Sat Jun 25 17:12:20 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_query): should
- discard if key=val pair is empty. patch from Gary Wright.
-
Sat Jun 25 15:49:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * enum.c (enum_min, enum_max, enum_min_by, enum_max_by): do not ignore
- nil as the first element.
+ * enum.c (enum_min, enum_max): do not ignore nil as the first element.
-Sat Jun 25 15:13:54 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Jun 25 14:40:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/set.rb (Set#==): [ruby-dev:25206] (ported from ruby_1_8 branch)
+ * ext/sdbm/init.c (fsdbm_select): SDBM#select had returned the array
+ which contained each elements twice. [ruby-dev:26358]
-Sat Jun 25 11:37:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Fri Jun 25 05:06:47 2005 Michael Neumann <mneumann@ruby-lang.org>
- * ext/nkf/lib/kconv.rb: remove constants
- Iconv_Shift_JIS, Uconv_EUC_JP, Iconv_UTF8
- * ext/nkf/lib/kconv.rb: add module functions to Kconv
- conv, {eucjp, shiftjis, utf8}?, guess_as_symbol
- * ext/nkf/lib/kconv.rb: add instance methods to String
- conv, {eucjp, shiftjis, utf8}?
- * ext/nkf/lib/kconv.rb: add aliases Kconv.to_* and String#to_*
+ * lib/xmlrpc/*, test/xmlrpc/*: backported changes from HEAD into 1.8
Fri Jun 24 17:00:00 2005 Shigeo Kobayashi <shigeo@tinyforest.jp>
* ext/bigdecimal/bigdecimal.c: patch from "NATORI Shin"
(u-tokyo.ac.jp) applied to fix rounding bug.
-Fri Jun 24 13:17:45 2005 akira yamada <akira@ruby-lang.org>
+Fri Jun 24 13:06:45 2005 akira yamada <akira@ruby-lang.org>
* lib/uri/common.rb, lib/uri/generic.rb: fixed typo in documents and
replaced some existent domain name with "example.com".
@@ -21300,7 +10804,7 @@ Mon Jun 20 18:44:04 2005 Tanaka Akira <akr@m17n.org>
because setjmp is not enough to fix getcontext and SPARC register
window problem.
-Mon Jun 20 17:15:51 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Jun 20 16:48:36 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/dbm/dbm.c (fdbm_closed): new method DBM#closed?
@@ -21313,7 +10817,7 @@ Mon Jun 20 17:15:51 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.{ch} (unlink): hook runtime function to change
file attribute before unlinking.
- merge from 1.8, see [ruby-dev:26360]
+ fixed: [ruby-dev:26360]
Mon Jun 20 02:15:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -21327,17 +10831,6 @@ Mon Jun 20 01:26:49 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
ext/openssl/ossl_pkcs12.h, ext/openssl/ossl_x509req.c: avoid
compiler warnings. suggested by Michal Rokos.
-Sun Jun 20 00:22:02 2005 Michael Neumann <mneumann@ruby-lang.org>
-
- * lib/xmlrpc/utils.rb: Patch by Nobuhiro IMAI fixes the following
- problem: Default value modification on
- Module#public_instance_methods (false -> true) breaks
- s.add_handler(XMLRPC::iPIMethods("sample"), MyHandler.new) style
- security protection.
-
- * lib/xmlrpc/client.rb: Aliased XMLRPC::Client#new2 as
- XMLRPC::Client#new_from_uri, and #new3 as #new_from_hash.
-
Sun Jun 19 14:09:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (run_final): reduce unnecessary object allocation during
@@ -21346,30 +10839,15 @@ Sun Jun 19 14:09:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (rb_gc_call_finalizer_at_exit): deferred finalizers list should
be cleared before calling them. fixed: [ruby-talk:145790]
-Sat Jun 18 01:15:36 2005 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/readline/readline.c (readline_readline): do not set
- rl_{in,out}stream.
-
- * ext/readline/readline.c (readline_s_set_input): new method.
-
- * ext/readline/readline.c (readline_s_set_output): new method.
-
- * lib/irb/input-method.rb: set Readline.input and Readline.output.
-
Fri Jun 17 13:01:40 2005 Tanaka Akira <akr@m17n.org>
* lib/time.rb (Time.parse): fix previous leap seconds support.
(Time.rfc2822): ditto.
(Time.xmlschema): ditto.
-Thu Jun 16 15:41:32 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ruby.c (load_file): '!' is already read. reported by gotoyuzo.
-
-Thu Jun 16 15:09:38 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Jun 16 15:06:55 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c (ip_rb_threadVwaitCommand): Tcl_Release
+ * ext/tcltklib/tcltklib.c (ip_rb_threadVwaitCommand): Tcl_Release
was missing.
Thu Jun 16 13:34:48 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -21385,14 +10863,10 @@ Thu Jun 16 12:53:24 2005 Tanaka Akira <akr@m17n.org>
(Time.rfc2822): ditto.
(Time.xmlschema): ditto.
-Thu Jun 16 00:13:41 2005 Tanaka Akira <akr@m17n.org>
+Thu Jun 16 08:29:22 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/resolv.rb (Resolv::DNS::Resource#ttl): new attribute.
- (Resolv::DNS::Resource#==): ignore @ttl.
- (Resolv::DNS::Resource#hash): ditto.
- (Resolv::DNS::Message::MessageDecoder#get_rr): save TTL in a
- Resource object.
- based on [ruby-core:5190] by Eric Hodel.
+ * ext/dl/sym.c (rb_dlsym_call): needs FREE_ARGS before return.
+ fixed memory leak. [ruby-Bugs-2034]
Wed Jun 15 18:26:39 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -21403,13 +10877,13 @@ Wed Jun 15 18:26:39 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Tue Jun 14 02:02:43 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tkutil/tkutil.c: add TkUtil::CallbackSubst.subst_arg(m, ...)
- & _define_attribute_aliases(hash) to get substitution-argument from
+ * ext/tk/tkutil.c: add TkUtil::CallbackSubst.subst_arg(m, ...) &
+ _define_attribute_aliases(hash) to get substitution-argument from
attributes (e.g. subst_arg(:x,:y,:num,:button) --> "%x %y %b %b ").
* ext/tk/lib/tk/event.rb: use _define_attribute_aliases().
-Mon Jun 13 13:03:08 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Jun 13 13:01:05 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* hash.c (ruby_setenv): fixed SEGV. [ruby-dev:26186]
@@ -21432,20 +10906,11 @@ Mon Jun 13 01:20:02 2005 Tanaka Akira <akr@m17n.org>
* eval.c (rb_gc_mark_threads): curr_thread may not be part of the
thread list. [ruby-dev:26312]
-Sat Jun 11 22:34:44 2005 Minero Aoki <aamine@loveruby.net>
-
- * parse.y: missing arg_paren event. This patch is contributed by
- Mitchell N Charity.
-
-Fri Jun 10 23:55:17 2005 Tanaka Akira <akr@m17n.org>
-
- * eval.c (unknown_node): show more information. [ruby-dev:26196]
-
Fri Jun 10 23:35:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* missing/mkdir.c: remove. [ruby-core:05177]
-Fri Jun 10 22:54:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jun 10 22:54:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* missing.h: fd_set stuffs need sys/types.h. fixed: [ruby-core:05179]
@@ -21469,47 +10934,20 @@ Thu Jun 9 19:55:41 2005 Tanaka Akira <akr@m17n.org>
* gc.c (Init_stack): remove IA64_MAGIC_STACK_LIMIT.
-Thu Jun 9 18:24:16 2005 Tanaka Akira <akr@m17n.org>
-
- * configure.in, eval.c, gc.c: use libunwind only on HP-UX.
- [ruby-dev:26297]
-
-Thu Jun 9 14:46:32 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (env_aset): do not treat nil as key-removing value.
- [ruby-list:40865]
-
- * parse.y (method_call): allow aref expression ([]) to take a
- block.
-
- * parse.y (block_dup_check): a function to check duplication of
- a block argument and an actual block.
-
Thu Jun 9 11:55:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (SimpleDelegator::__setobj__): need check for
recursive delegation. [ruby-core:04940]
-Thu Jun 9 11:50:43 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi.rb: add underscore aliases CGI::escape_html,
- CGI::unescape_html, CGI::escape_element, CGI::unescape_element.
- [ruby-core:05058]
-
Wed Jun 8 18:47:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* misc/ruby-mode.el (ruby-expr-beg): fix looking point drift.
-Wed Jun 8 12:25:59 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (rb_ary_nitems): add the block feature to Array#nitems.
- suggested by Bertram Scharpf <lists@bertram-scharpf.de> in
- [ruby-talk:134083].
-
Wed Jun 8 11:11:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (get2comp): revert all prior changes, and calculate
- proper 2's complement for negative numbers.
+ * bignum.c (get2comp): calculate proper 2's complement for
+ negative numbers. a bug in normalizing negative numbers
+ reported from Honda Hiroki <hhonda@ipflex.com>.
Wed Jun 8 08:33:10 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -21520,15 +10958,6 @@ Wed Jun 8 08:33:10 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (backtrace): skip successive frames sharing same node.
-Wed Jun 8 01:27:06 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (bignorm): fixed a bug in normalizing negative numbers
- reported from Honda Hiroki <hhonda@ipflex.com>. normalizing
- should not trim leading zeros from negative numbers.
-
- * bignum.c (rb_cstr_to_inum): must remove leading zeros for this
- case.
-
Wed Jun 8 00:15:08 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (ruby_getaddrinfo__aix): merged a patch from
@@ -21554,55 +10983,37 @@ Tue Jun 7 19:34:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
Tue Jun 7 18:39:31 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/thread.rb: RDoc documentation from Eric Hodel
- <drbrain@segment7.net> added. [ruby-core:05148]
+ <drbrain at segment7.net> added. [ruby-core:05148]
Tue Jun 7 18:30:04 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_makefile): add .SUFFIXES from depend file.
fixed: [ruby-dev:26294]
-Tue Jun 7 17:20:39 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): allow ';;' to be block terminator in
- place of 'end'. [highly experimental]
+Tue Jun 7 17:39:54 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * misc/ruby-mode.el (ruby-block-end-re): allow ';;' to be a
- negative indent trigger. [highly experimental]
+ * object.c (rb_mod_cvar_get): Module#class_variable_get(): back
+ ported from CVS HEAD. [ruby-talk:144741]
- * parse.y (parser_yylex): small error fixed.
-
-Tue Jun 7 16:45:49 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): "respond_to?:foo" should be interpreted
- as "respond_to? :foo" at the command level. [ruby-talk:144303]
+ * object.c (rb_mod_cvar_set): Module#class_variable_set().
+ [ruby-talk:144741]
Tue Jun 7 16:32:53 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* sprintf.c (rb_f_sprintf): raise exception on debug mode (-d),
not verbose mode (-v/-w). [ruby-core:05123]
- * sprintf.c (rb_f_sprintf): warn always on verbose mode.
-
Tue Jun 7 10:30:49 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: slave-ip fails to call procedures
delegated by master-ip.
-Mon Jun 6 16:35:18 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/ripper/depend: add .y to .SUFFIXES for nmake.
-
Sun Jun 5 23:00:35 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/console.rb: create console when required
* ext/tk/sample/tkextlib/tile/demo.rb: fix TypeError & create Console
-Sun Jun 5 10:23:52 2005 Tanaka Akira <akr@m17n.org>
-
- * signal.c (ruby_signal): don't set SA_RESTART.
- [ruby-dev:26276]
-
Sat Jun 4 14:55:18 2005 Tanaka Akira <akr@m17n.org>
* test/dbm/test_dbm.rb: merged from ext/dbm/testdbm.rb.
@@ -21612,61 +11023,15 @@ Sat Jun 4 14:55:18 2005 Tanaka Akira <akr@m17n.org>
* test/sdbm/test_sdbm.rb: renamed from ext/sdbm/testsdbm.rb with
modification to use test/unit.
-Fri Jun 3 23:23:02 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h (rb_fdset_t): deal with fd bit sets over FD_SETSIZE.
- fixed: [ruby-dev:26187]
-
- * eval.c (rb_fd_init, rb_fd_term, rb_fd_zero, rb_fd_set, rb_fd_clr,
- rb_fd_isset, rb_fd_copy): ditto.
-
- * io.c (rb_io_wait_readable, rb_io_wait_writable, rb_f_select): ditto.
-
- * ext/io/wait/wait.c (io_wait): ditto.
-
- * ext/socket/socket.c (wait_connectable, unix_recv_io): ditto.
-
Fri Jun 3 14:06:12 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: fix typo.
-Thu Jun 2 23:42:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y: pragma support on ripper. [ruby-dev:26266]
-
-Thu Jun 2 00:02:16 2005 Minero Aoki <aamine@loveruby.net>
-
- * struct.c: accessing >10 member caused segmentation fault.
- [ruby-dev:26247]
-
- * test/ruby/test_struct.rb: test it.
-
-Wed Jun 1 11:30:09 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jun 1 11:32:42 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bcc32/Makefile.sub: can use single quote character in DESTDIR.
[ruby-dev:26205]
- * bcc32/Makefile.sub: Dir.glob in 1.9 doesn't treat \ as path separator.
- [ruby-dev:26254]
-
-Wed Jun 1 00:11:06 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (method_call): new experiment: "(expr)(args...)" to
- invoke "expr.call(args...)". [EXPERIMENTAL]
-
-Tue May 31 23:43:41 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (command): revert implicit "call" for local variables.
-
-Tue May 31 15:52:45 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should
- break the loop if the socket reached to EOF. [ruby-talk:142285]
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): send response
- without reading the whole request body if keep-alive is diabled.
- [experimental]
-
Mon May 30 23:48:29 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/macpkg.rb: add PACKAGE_NAME information of Tcl/Tk
@@ -21678,12 +11043,12 @@ Mon May 30 23:48:29 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: ditto.
-Sat May 28 16:39:21 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sat May 28 16:40:15 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_x509store.rb: add test for expired CRL
and refine some assertions.
-Sat May 28 05:15:44 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Sat May 28 05:15:51 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509store.c (ossl_x509stctx_set_time): should
not set internal flag directry.
@@ -21699,41 +11064,22 @@ Fri May 27 16:32:04 2005 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/mkmf.rb: use the semicolon as the path separator
in the environment of MSYS. fixed: [ruby-dev:26232]
-Thu May 26 20:31:21 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (remove_entry_secure): add documentation.
-
- * lib/fileutils.rb (remove_entry_secure): should not invoke
- unlink(2) against a directory.
-
-Thu May 26 08:29:19 2005 Akiyoshi, Masamichi <akiyoshi@hp.com>
-
- * vms/vmsruby_private.c, vms/vmsruby_private.h: private routines
- for VMS port are added.
-
- * eval.c (ruby_init): change to call VMS private intialization routine.
-
-Thu May 26 07:39:07 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (rm_r): use lchown(2), not chown(2).
- [ruby-dev:26226]
-
- * lib/fileutils.rb (cd): remove :noop option. (feature change)
+Thu May 26 06:08:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/fileutils.rb (cp_r): should copy symlink as symlink, for
- also tree root. (feature change)
+ * ext/tk/lib/tk.rb: add shortcut-methods of tk_call + tk_split_list
- * lib/fileutils.rb (cp_r): new option :dereference_root.
+Wed May 25 22:52:42 2005 Shugo Maeda <shugo@ruby-lang.org>
- * lib/fileutils.rb: new method remove_entry.
+ * lib/irb/input-method.rb: do not use Readline::HISTORY.pop.
+ (backported from HEAD)
- * lib/fileutils.rb: new method remove_entry_secure.
+Wed May 25 21:55:40 2005 Shugo Maeda <shugo@ruby-lang.org>
- * lib/fileutils.rb: add documentation.
+ * ext/readline/readline.c: supported libedit. (backported from HEAD)
-Thu May 26 06:08:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * ext/readline/extconf.rb: ditto.
- * ext/tk/lib/tk.rb: add shortcut-methods of tk_call + tk_split_list
+ * test/readline/test_readline.rb: ditto.
Wed May 25 20:06:27 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -21775,10 +11121,6 @@ Wed May 25 20:06:27 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb: ditto.
-Wed May 25 19:48:12 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (rm_r): does chown(2). [ruby-dev:26199]
-
Wed May 25 12:59:48 2005 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb (OpenURI::Meta::RE_QUOTED_STRING): a content of
@@ -21794,17 +11136,17 @@ Tue May 24 16:57:24 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.c (require_libraries): caused SEGV when continuation jumped
in to the required library code.
-Tue May 24 17:45:59 2005 Shugo Maeda <shugo@ruby-lang.org>
+Tue May 24 11:56:25 2005 WATANABE Hirofumi <eban@ruby-lang.org>
- * test/readline/test_readline.rb: do not test libedit.
- fixed: [ruby-dev:26217]
+ * lib/getopts.rb: should warn only if verbose mode.
+ fixed: [ruby-dev:26201]
Tue May 24 06:45:31 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): string
literals to be matched non-greedy.
-Tue May 24 00:39:14 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Tue May 24 00:34:32 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/soap/calc: method name 'set' was able to crash with a class Set.
[ruby-dev:26210]
@@ -21812,16 +11154,11 @@ Tue May 24 00:39:14 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/wsdl/document/test_rpc.rb: dateTime comparison failed under
TZ=right/Asia/Tokyo (with leap second.) [ruby-dev:26208]
-Mon May 23 16:23:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/extconf.rb: Framework support on MacOS X Tiger.
-
- * ext/tk/README.tcltklib: add description of Framework support options.
+Mon May 23 16:24:05 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon May 23 15:07:34 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/tcltklib/extconf.rb: Framework support on MacOS X Tiger.
- * win32/Makefile.sub ($(PROGRAM)): add dependency on $(LIBRUBY_SO).
- [experimental]
+ * ext/tcltklib/README.1st: add description of Framework support options.
Mon May 23 12:21:37 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -21914,79 +11251,41 @@ Sun May 22 19:11:35 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ssl.c (ossl_sslctx_setup): add session id support.
-Sun May 22 12:30:58 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h, parse.y (ruby_pragma): removed. fixed: [ruby-dev:26198]
-
- * parse.y (parser_pragma): pragma name was ignored.
-
-Sun May 22 02:39:57 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (rm_r): new option :secure to avoid
- time-to-check-to-time-to-use security problem. [ruby-dev:26100]
-
- * lib/fileutils.rb (remove_file, remove_dir): try chmod(700) only
- on Windows.
-
- * lib/fileutils.rb: does not depend on find.rb.
-
- * lib/fileutils.rb: new method chmod_R.
-
- * lib/fileutils.rb (chown_R): did not work.
-
-Sat May 21 10:23:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat May 21 10:24:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bcc32/Makefile.sub: tds files were not deleted when DESTDIR
included '\' path delimiter. [ruby-dev:26193]
-Fri May 20 15:52:18 2005 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/readline/readline.c (readline_attempted_completion_function):
- return 2 items if completion_proc returns only 1 item (for libedit).
-
-Fri May 20 01:24:33 2005 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/readline/extconf.rb: check rl_vi_editing_mode() and
- rl_emacs_editing_mode().
-
-Thu May 19 23:33:09 2005 Shugo Maeda <shugo@ruby-lang.org>
+Thu May 19 19:04:29 2005 speakillof <speakillof@yahoo.co.jp>
- * ext/readline/readline.c: supported libedit. fixed: [ruby-core:4858]
-
- * ext/readline/extconf.rb: added new option --enable-libedit.
-
- * test/readline/test_readline.rb: added assertions for
- Readline::HISTORY.
-
- * lib/irb/input-method.rb: do not use Readline::HISTORY.pop.
+ * lib/rexml/encodings/SHIFT-JIS.rb: encoding and decoding were
+ swapped. [ruby-core:4772]
Wed May 18 23:42:25 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (exc_exception): reverted to call Exception#initialize
directly. fixed: [ruby-dev:26177]
-Wed May 18 17:38:51 2005 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * dir.c (glob_helper): check whether path is "" before calling
- do_opendir. [ruby-dev:26183]
-
-Wed May 18 13:40:48 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (NtInitialize): fix typo.
-
-Wed May 18 11:07:47 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed May 18 23:39:09 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (glob_helper): get rid of using String. [ruby-dev:26180]
+ * dir.c (push_braces): should skip balanced braces.
+
* eval.c (ruby_options), win32/win32.c (NtInitialize): move argument
intialization back. [ruby-dev:26180]
-Tue May 17 11:49:18 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue May 17 15:31:31 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should
+ break the loop if the socket reached to EOF. [ruby-talk:142285]
+
+Tue May 17 11:52:18 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (unixtime_to_filetime): use localtime() instead of
gmtime() when using FileLocalTimeToFileTime().
-Mon May 16 22:42:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon May 16 22:28:43 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.h, {bcc32,win32,wince}/Makefile.sub: moved rb_[ugp]id_t
to get rid of redefinition warnings on mingw.
@@ -21994,12 +11293,7 @@ Mon May 16 22:42:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* class.c (rb_class_init_copy): singleton class is disallowed to copy,
from its definition. fixed: [ruby-talk:142749]
- * parse.y (pragma_encoding): add prototype to suppress false warning
- by VC.
-
- * process.c (proc_spawn_v): use rb_w32_aspawn on Win32.
-
-Mon May 16 03:29:01 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon May 16 08:52:29 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.{h,c}: define rb_[pgu]id_t.
@@ -22009,7 +11303,7 @@ Mon May 16 00:21:02 2005 Tanaka Akira <akr@m17n.org>
Errno::EISDIR because EISDIR is not portable.
[ruby-core:5001]
-Sun May 15 22:28:10 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun May 15 22:11:33 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb (DRbObject#method_missing): use raise(exception).
[ruby-dev:26164]
@@ -22034,7 +11328,7 @@ Sat May 14 23:59:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (exc_exception, {exit,name_err,syserr}_initialize): call
Execption#initialize. fixed: [ruby-talk:142593]
-Sat May 14 23:56:41 2005 Erik Huelsmann <ehuels@gmail.com>
+Sat May 14 23:57:26 2005 Erik Huelsmann <ehuels@gmail.com>
* configure.in: Check for the availability of pid_t, gid_t and uid_t and
remove AC_TYPE_UID_T. fixed: [ruby-core:04745]
@@ -22059,16 +11353,6 @@ Sat May 14 23:56:41 2005 Erik Huelsmann <ehuels@gmail.com>
* wince/sys/types.h: Remove definitions of {p,g,u}id_t.
-Sat May 14 11:47:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * intern.h (ruby_pragma): prototype. [ruby-core:04881]
-
- * parse.y (parser_pragma): parse Emacsen hack.
-
- * parse.y (parser_prepare): deal with specific syntax at the top.
-
- * ruby.c (load_file): read the first line iff it started with shebang.
-
Fri May 13 23:44:22 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: keep srcdir unexpanded.
@@ -22080,45 +11364,87 @@ Fri May 13 23:44:22 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
also INSTALL_PROG and INSTALL_DATA system dependent.
fixed: [ruby-core:04931]
-Fri May 13 23:32:55 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (unknown_node): add volatile directive to prototype.
-
-Fri May 13 17:50:49 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri May 13 17:54:39 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* variable.c (generic_ivar_get): rb_attr_get should not warn.
[ruby-dev:26010]
-Thu May 12 17:41:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Fri May 13 12:28:43 2005 Daniel Berger <djberge@qwest.com>
- * ext/nkf/nkf-utf8/nkf.c: follow nkf 2.0.5
+ * array.c (rb_ary_select): can remove argc check. [ruby-core:4911]
+
+ * test/ruby/test_array.rb: add test for find_all.
-Thu May 12 16:50:40 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri May 13 11:29:00 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * eval.c (unknown_node): add volatile directive to prototype.
+
+Thu May 12 17:08:48 2005 Tanaka Akira <akr@m17n.org>
+
+ * io.c (rb_io_eof, remain_size, read_all, io_read, appendline)
+ (swallow, rb_io_each_byte, rb_io_getc): revert previous change.
+
+ * io.c (rb_io_eof, io_fread, appendline, swallow, rb_io_each_byte)
+ (rb_io_getc, rb_getc): call clearerr before getc to avoid
+ stdio incompatibility.
+
+Thu May 12 16:52:20 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/parsers/parse_c.rb: more readability for mixing
progress "c..." and warning message.
-Thu May 12 15:50:56 2005 Tilman Sauerbeck <tilman@code-monkey.de>
+Thu May 12 16:31:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/nkf/nkf-utf8/nkf.c: follow nkf 2.0.5
+
+Thu May 12 16:15:01 2005 Tanaka Akira <akr@m17n.org>
+
+ * io.c (rb_io_eof, remain_size, read_all, io_read, appendline)
+ (swallow, rb_io_each_byte, rb_io_getc): don't rely EOF flag.
+ [ruby-talk:141527]
+
+Thu May 12 15:56:20 2005 Tilman Sauerbeck <tilman@code-monkey.de>
* lib/rdoc/parsers/parse_c.rb: show parsing progress for C files.
[ruby-core:4341]
+Thu May 12 13:47:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * test/drb/test_drb{ssl,unix}.rb: can test drb
+ before install. (backported from HEAD) [ruby-dev:26146]
+
Thu May 12 09:53:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* version.c (ruby_show_version): flush for non-tty stdout.
+Thu May 12 09:07:07 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * test/ruby/envutil.rb, test/drb/drbtest.rb: can test drb
+ before install. (backported from HEAD) [ruby-Bugs-1672]
+
Thu May 12 01:23:55 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_eval), parse.y (arg): reduce fixnum range literal at
+ parser. fixed: [ruby-dev:26113]
+
* eval.c (unknown_node): ignore broken NODE to get rid of accessing
possibly inaccessible address. fixed: [ruby-dev:26122]
should emit more useful information like [ruby-dev:26126], though.
+Wed May 11 16:20:01 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/cgi.rb: new methods WEBrick::CGI#[], WEBrick::CGI#logger
+ and WEBrick::CGI#config. (backported from HEAD)
+
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.escape_path): should
+ not use String#split("/"). (backported from HEAD)
+
Wed May 11 15:58:39 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (break_jump): break should not cross functions.
[ruby-list:40818]
-Wed May 11 10:41:54 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed May 11 10:39:37 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/tempfile.rb (Tempfile#unlink): fixed typo.
@@ -22131,12 +11457,7 @@ Sun May 8 23:17:47 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/timer.rb: fix typo.
-Sun May 8 21:00:50 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * hash.c (Init_Hash): remove custom "hash" and "eql?".
- (ported from 1.8) [ruby-dev:26132]
-
-Sun May 8 16:50:25 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sun May 8 16:52:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/profiler.rb: fixed "undefined method `[]' for nil:NilClass"
[ruby-core:4775] [ruby-talk:140401] [ruby-dev:26118]
@@ -22145,54 +11466,11 @@ Sat May 7 22:58:00 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (have_var): no libs argument is given.
-Fri May 6 08:08:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * hash.c:rb_hash_hash_i() should be static. [ruby-core:04815]
-
- * re.c should include regint.h for declarations of oniguruma
- functions. [ruby-core:04815]
-
-Sun May 1 09:15:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun May 1 09:58:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (process_sflag): replace '-' in variable names with '_'.
[ruby-dev:26107]
- * eval.c (rb_eval), parse.y (arg): reduce fixnum range literal at
- parser. fixed: [ruby-dev:26113]
-
-Sat Apr 30 11:59:25 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_FUNC_ATTRIBUTE): check for function attribute.
- [ruby-dev:26109]
-
- * eval.c, gc.c: moved noinline to configure.in.
-
- * rubyio.h (DEPRECATED): moved to configure.in.
-
- * ruby.h (DEPRECATED, NOINLINE): default definition.
-
- * win{32,ce}/Makefile.sub (config.h): deprecated and noinline for
- __declspec() are available for VC++7 or later.
-
-Sat Apr 30 06:57:39 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/cgi.rb: new methods WEBrick::CGI#[], WEBrick::CGI#logger
- and WEBrick::CGI#config. these are necessary to use an instance of
- WEBrick::CGI as the first argument of HTTPServlet#get_instance.
- (suggested by Tatsuki Sugiura)
-
- * lib/webrick/cgi.rb
- (WEBrick::CGI#initalize): set a dummy to @config[:ServerSoftware]
- if SERVER_SOFTWARE environment variable is not given.
- (WEBrick::CGI#start): req.path_info must be a String.
- (WEBrick::CGI::Socket#request_line): treat REQUEST_METHOD, PATH_INFO
- and SCRIPT_NAME to run in console.
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils.escape_path): should
- not use String#split("/"). it removes trailing empty path component.
-
-Thu Apr 28 08:21:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
* ruby.c (set_arg0): use also environment variable space for setting
$0. [ruby-core:04774]
@@ -22203,46 +11481,23 @@ Wed Apr 27 23:42:22 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
Tue Apr 26 22:58:00 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c (ip_invoke_core): call Tcl's "::unknown"
+ * ext/tcltklib/tcltklib.c (ip_invoke_core): call Tcl's "::unknown"
command when can't get information of target command.
-Mon Apr 25 13:54:55 2005 speakillof <speakillof@yahoo.co.jp>
-
- * lib/rexml/encodings/SHIFT-JIS.rb: encoding and decoding were
- swapped. [ruby-core:4772]
-
Mon Apr 25 01:18:43 2005 Tanaka Akira <akr@m17n.org>
- * oniguruma.h (OnigWarnFunc): add a variadic argument.
- [ruby-core:4751]
+ * regex.c: declare rb_warn to have variadic argument. [ruby-core:4751]
-Sat Apr 23 19:49:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Apr 23 19:45:59 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tk/tcltklib.c (ip_RubyExitCommand): exit with status code
+ * ext/tcltklib/tcltklib.c (ip_RubyExitCommand): exit with status code
via TclTkIp#_eval didn't work. [ruby-talk:139390]
-Sat Apr 23 11:45:29 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_provided): should check also path name to be loaded.
- fixed: [ruby-dev:26093]
-
-Fri Apr 22 16:55:35 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/tk/tcltklib.c (ip_set_exc_message): fixed memory leak.
-
- * ext/tk/tcltklib.c: eTkCallbackReturn was not initialized.
-
-Thu Apr 21 06:45:28 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Apr 22 16:41:50 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ruby.c (ruby_incpush_expand, proc_options): expand relative path
- given with -I option. [ruby-dev:26090]
+ * ext/tcltklib/tcltklib.c (ip_set_exc_message): fixed memory leak.
- * configure.in, lib/mkmf.rb, {bcc32,win32,wince}/Makefile.sub: improve
- C++ support. [ruby-dev:26089]
-
-Thu Apr 21 01:53:09 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: add rdoc.
+ * ext/tcltklib/tcltklib.c: eTkCallbackReturn was not initialized.
Thu Apr 21 00:07:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -22256,7 +11511,7 @@ Thu Apr 21 00:07:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
Wed Apr 20 23:22:39 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * Makefile.in, common.mk: miniruby depends on MINIOBJS.
+ * Makefile.in, common.mk: miniruby depens on MINIOBJS.
* dmydln.c (dln_load): dummy function to raise LoadError.
@@ -22267,21 +11522,6 @@ Wed Apr 20 23:01:35 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/ifchange.bat: delete testing files.
-Wed Apr 20 22:54:54 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: new method Net::HTTP.post_form.
-
- * lib/net/http.rb: new method Net::HTTPHeader#set_form_data and
- its alias #form_data=.
-
- * lib/net/http.rb: Net::HTTPHeader#add_header -> add_field
- (adjustted to Ruby 1.8).
-
-Wed Apr 20 10:53:30 2005 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/rdoc/parsers/parse_rb.rb (lex_init): use IRB module.
- [ruby-core:04737]
-
Wed Apr 20 07:27:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* {bcc32,win32,wince}/configure.bat, {bcc32,win32,wince}/setup.mak:
@@ -22289,33 +11529,18 @@ Wed Apr 20 07:27:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bcc32/setup.mak: make configuration variables overridable.
-Tue Apr 19 23:37:09 2005 WATANABE Hirofumi <eban@ruby-lang.org>
+Wed Apr 20 04:15:27 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
- * lib/ftools.rb (File.safe_unlink): do not modify a symlinked file.
-
-Tue Apr 19 23:02:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (search_required): deal with features with path too.
+ * lib/irb.rb lib/irb/* doc/irb: IRB 0.9.5
- * intern.h (rb_file_expand_path): prototype. fixed: [ruby-dev:26082]
-
-Tue Apr 19 08:38:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Apr 19 23:37:09 2005 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (search_required, rb_require_safe): expand path in
- rb_features. [ruby-dev:26079]
+ * lib/ftools.rb (File.safe_unlink): do not modify a symlinked file.
- * file.c (rb_find_file_ext): return absolute path.
+Tue Apr 19 00:06:20 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: expand path for ext/**/extconf.rb.
- * eval.c (search_required): handle static linked extensions.
-
-Mon Apr 18 15:37:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_attr): attribute name check added.
-
- * numeric.c (flo_plus): small typo fix.
-
Mon Apr 18 11:25:14 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/zlib/zlib.c (zstream_run): fixed SEGV. [ruby-core:4712]
@@ -22342,7 +11567,7 @@ Sat Apr 16 15:27:03 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* mkconfig.rb: purge autoconf value variables.
-Sat Apr 16 10:33:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Apr 16 10:36:01 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bcc32/Makefile.sub: quick hack... prepend DESTDIR.
still have restriction on DESTDIR ("", "/", "e:")
@@ -22353,55 +11578,18 @@ Sat Apr 16 03:59:42 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/openssl_missing.h: ditto.
-Fri Apr 15 22:40:19 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/tests/testWIN32OLE.rb: add test for WIN32OLE.codepage=
-
- * ext/win32ole/tests/testOLETYPELIB.rb: correct expected message.
-
-Fri Apr 15 22:04:07 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c(ole_invoke): retry after converting Qnil
- to VT_EMPTY.
-
-Thu Apr 14 19:05:06 2005 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper] (regexp): dispatch regexp option.
- [ruby-Bugs:1688]
-
- * ext/ripper/lib/core.rb: regenerated (interface changed).
-
-Thu Apr 14 18:59:43 2005 Minero Aoki <aamine@loveruby.net>
+Thu Apr 14 19:18:30 2005 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (remove_file): ignore exceptions caused by
chmod.
* lib/fileutils.rb (remove_dir): try to get rights to rmdir.
- [ruby-Bugs:1502]
-
-Thu Apr 14 18:51:02 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/irb/ruby-lex.rb, lib/irb/slex.rb: bug fix of [ruby-Bugs-1745]
-
- * lib/irb/ext/loader.rb, lib/irb/ext/save-history.rb:
- fix location of @RCS_ID
-
- * lib/irb/cmd/help.rb: a lost of release IRB 0.9.5.
-
-Thu Apr 14 15:10:30 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * lib/irb/notifier.rb, lib/irb/output-method.rb, lib/irb/ext/history.rb
- fixed warning of 'ruby -w'
+ [ruby-Bugs:1502] (2 items backportted from HEAD, rev 1.53-54)
-Thu Apr 14 05:35:45 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
+Thu Apr 14 16:57:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * doc/irb/irb.rd.ja: a lost of release IRB 0.9.5.
-
- * lib/irb/slex.rb: bug fix by [ruby-core:04707].
-
-Thu Apr 14 00:20:31 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
-
- * bin/irb lib/irb.rb lib/irb/...: IRB 0.9.5.
+ * bcc32/Makefile.sub: failed to remove debug information files.
+ fixed: [ruby-dev:26034]
Wed Apr 13 23:40:21 2005 Kouhei Sutou <kou@cozmixng.org>
@@ -22410,44 +11598,33 @@ Wed Apr 13 23:40:21 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb (RSS::Element#converter): fixed converter
transmission bug.
-Wed Apr 13 22:12:16 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (OptionParser#order!): call handlers iff matches
- non-switch.
-
Wed Apr 13 21:20:35 2005 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (mingw32): extract msvcr*.dll from objdump result.
-Wed Apr 13 19:25:31 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Apr 13 20:24:30 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (mingw32): use actual runtime DLL name as ruby DLL
name and default load path.
* win32/Makefile.sub, win32/setup.mak: ditto.
-Tue Apr 12 19:30:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (OptionParser#make_switch, OptionParser#order!):
- added non-option and end-of-args handler. [ruby-talk:136878]
- [EXPERIMENTAL]
-
Tue Apr 12 15:33:09 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c (ip_finalize): better modification than the
+ * ext/tcltklib/tcltklib.c (ip_finalize): better modification than the
previous commit [ruby-dev:26029].
Tue Apr 12 12:38:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c (ip_finalize): fix SEGV when Tcl_GlobalEval()
+ * ext/tcltklib/tcltklib.c (ip_finalize): fix SEGV when Tcl_GlobalEval()
modifies the argument string to eval.
Tue Apr 12 02:21:55 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c (ip_finalize): add existence check of
+ * ext/tcltklib/tcltklib.c (ip_finalize): add existence check of
Tcl commands before calling Tcl_GlobalEval().
-Mon Apr 11 23:36:04 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Mon Apr 11 23:47:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: [druby-ja:123] fix: When reference of my object is
loaded, the object is tainted.
@@ -22460,13 +11637,28 @@ Mon Apr 11 22:18:23 2005 WATANABE Hirofumi <eban@ruby-lang.org>
Mon Apr 11 20:11:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c (ip_finalize): adhoc patch to avoid SEGV when exit
- on Tcl/Tk8.3.x.
+ * ext/tcltklib/tcltklib.c (ip_finalize): adhoc patch to avoid SEGV
+ when exit on Tcl/Tk8.3.x.
-Mon Apr 11 15:24:20 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Apr 11 15:26:25 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/mkmf.rb (configuration): shouldn't output hdrdir twice.
+Mon Apr 11 12:09:05 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * {bcc32,win32,wince}/Makefile.sub: ri data was not installed
+ into correct path. [ruby-dev:26011]
+
+ * bcc32/Makefile.sub: defaulted install-nodoc. [ruby-dev:26011]
+
+Sun Apr 10 10:12:42 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+
+ * ext/win32ole/win32ole.c(ole_invoke): retry after converting Qnil
+ to VT_EMPTY.
+
+ * ext/win32ole/win32ole/tests/testWIN32OLE.rb: correct error
+ message string "Unknown" => "unknown".
+
Sat Apr 9 18:20:31 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/image.rb: support to create TkImage object without
@@ -22486,41 +11678,68 @@ Sat Apr 9 14:42:29 2005 Kouhei Sutou <kou@cozmixng.org>
* sample/rss/tdiary_plugin/rss-recent.rb: supported configuration
via Web browser.
-Fri Apr 8 20:17:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Apr 9 11:59:57 2005 Kouhei Sutou <kou@cozmixng.org>
- * ext/extmk.rb (extmake): hdrdir needs to be defined also in
- Config::CONFIG.
+ * lib/rss: backoported from HEAD.
- * lib/mkmf.rb (configuration, create_makefile): get rid of recursive
- macro reference.
+ * lib/rss: refactored.
+ - gave a name to 'x'.
+ - undef_method -> remove_method for avoiding a warning in ruby 1.6.
-Fri Apr 8 01:55:20 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * lib/rss/parser.rb: @@setter -> @@setters.
- * ext/tk/sample/demos-{en,jp}/goldberg.rb: reduced window size.
- [ruby-dev:25992]
+ * lib/rss/parser.rb
+ (RSS::BaseListener.register_uri)
+ (RSS::BaseListener.uri_registered?)
+ (RSS::BaseListener.install_get_text_element):
+ swapped the first argument and the second argument.
-Thu Apr 7 23:58:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/rss/taxonomy.rb: swapped the first argument and the second
+ argument for RSS::BaseListener.install_get_text_element.
+ * lib/rss/image.rb: ditto.
+ * lib/rss/syndication.rb: ditto.
+ * lib/rss/dublincore.rb: ditto.
+ * lib/rss/parser.rb: ditto.
+ * lib/rss/1.0.rb: ditto.
+ * lib/rss/2.0.rb: ditto.
+ * lib/rss/0.9.rb: ditto.
+ * lib/rss/content.rb: ditto.
- * ext/extmk.rb (extmake): keep directory names in Makefile as macros.
+ * lib/rss/parser.rb
+ (RSS::BaseListener.install_setter)
+ (RSS::BaseListener.register_uri): changed fallback way.
- * lib/mkmf.rb (configuration, create_makefile): ditto.
+ * lib/rss/parser.rb: added class name registry for complex model
+ elements. (ex. have childlen elements, have some attributes and
+ a child element and so on.)
- * lib/mkmf.rb (CXX_EXT): separate C++ extensions.
+ * lib/rss/dublincore.rb: supported multiple Dublin Core items.
+ * lib/rss/maker/dublincore.rb: ditto.
-Thu Apr 7 17:24:17 2005 Shugo Maeda <shugo@ruby-lang.org>
+ * lib/rss/maker/image.rb: supproted new Dublin Core API.
- * eval.c (rb_call0): "return" event hook should be always executed
- if event_hooks is set.
+ * lib/rss/maker/base.rb: added default current_element implementation.
-Thu Apr 7 14:33:09 2005 Kouhei Sutou <kou@cozmixng.org>
+ * lib/rss/trackback.rb (RSS::TrackBackUtils.new_with_value_if_need):
+ moved to RSS::Utils.
- * test/rss/test_maker_dc.rb (test_date): added a test for #date=
- and #dc_date=.
+ * lib/rss/utils.rb (RSS::Utils.new_with_value_if_need):
+ moved from RSS::TrackBackUtils.
-Thu Apr 7 11:49:53 2005 Kouhei Sutou <kou@cozmixng.org>
+ * 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.
- * lib/rss/maker/dublincore.rb: _really_ supported multiple Dublin
- Core items.
+ * test/test_setup_maker_1.0.rb: fixed swapped actual and expected
+ values.
* test/rss/rss-assertions.rb (assert_multiple_dublin_core): added
an assertion for testing multiple Dublin Core items.
@@ -22528,18 +11747,8 @@ Thu Apr 7 11:49:53 2005 Kouhei Sutou <kou@cozmixng.org>
* test/rss/test_maker_dc.rb (test_rss10_multiple): added a test
for making multiple Dublin Core items.
-Wed Apr 6 16:06:30 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * test/ruby/test_env.rb (test_key): should test ENV.key instead of
- ENV.index. [ruby-dev:25994]
-
-Tue Apr 5 16:01:12 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/*: refactored.
- - gave a name to 'x'.
- - undef_method -> remove_method for avoiding a warning in ruby 1.6.
-
-Tue Apr 5 15:45:33 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']:
@@ -22548,46 +11757,54 @@ Tue Apr 5 15:45:33 2005 Kouhei Sutou <kou@cozmixng.org>
* sample/rss/tdiary_plugin/rss-recent.rb (RSS_RECENT_VERSION):
0.0.5 -> 0.0.6.
-Tue Apr 5 15:15:26 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/dublincore.rb: supported multiple Dublin Core items.
+Fri Apr 8 20:17:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rss/parser.rb: added class name registry for complex model
- elements. (ex. have childlen elements, have some attributes and
- a child element and so on.)
+ * ext/extmk.rb (extmake): hdrdir needs to be defined also in
+ Config::CONFIG.
- * lib/rss/maker/base.rb: added default current_element implementation.
+ * lib/mkmf.rb (configuration, create_makefile): get rid of recursive
+ macro reference.
- * lib/rss/maker/dublincore.rb: supported multiple Dublin Core
- items.
+Fri Apr 8 18:26:56 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * lib/rss/maker/image.rb: supproted new Dublin Core API.
+ * ext/openssl/ossl_ssl.c: add callbacks to OpenSSL::SSL::SSLContexts.
+ - SSLContext#client_cert_cb=(aProc). it is called when a client
+ certificate is requested by a server and no certificate was not
+ set for the SSLContext. it must return an Array which includes
+ OpenSSL::X509::Certificate and OpenSSL::PKey::RSA/DSA objects.
+ - SSLContext#tmp_dh_callback=(aProc). it is called in key
+ exchange with DH algorithm. it must return an OpenSSL::PKey::DH
+ object.
+ * ext/openssl/ossl_ssl.c (ossl_sslctx_set_ciphers): ignore the
+ argument if it's nil.
- * lib/rss/trackback.rb (RSS::TrackBackUtils.new_with_value_if_need):
- moved to RSS::Utils.
+ * ext/openssl/ossl_pkey.c
+ (GetPrivPKeyPtr, ossl_pkey_sign): should call rb_funcall first.
+ (DupPrivPKeyPtr): new function.
- * lib/rss/utils.rb (RSS::Utils.new_with_value_if_need):
- moved from RSS::TrackBackUtils.
+ * ext/openssl/ossl_pkey_dh.c: add default DH parameters.
+ * ext/openssl/ossl_pkey.h: ditto.
- * lib/rss/maker/image.rb: fixed invalid argument of
- add_need_initialize_variable bug.
+Fri Apr 8 01:55:20 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/rss/maker/trackback.rb: ditto.
+ * ext/tk/sample/demos-{en,jp}/goldberg.rb: reduced window size.
+ [ruby-dev:25992]
+Thu Apr 7 23:58:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/rss/rss.rb (Hash#merge): added for ruby 1.6.
+ * ext/extmk.rb (extmake): keep directory names in Makefile as macros.
- * lib/rss/rss.rb (RSS::BaseModel.date_writer): changed to accept nil
- for date value.
+ * lib/mkmf.rb (configuration, create_makefile): ditto.
+ * lib/mkmf.rb (CXX_EXT): separate C++ extensions.
- * test/test_dublincore.rb: added tests for plural accessor and
- multiple Dublin Core items.
+Thu Apr 7 17:43:25 2005 Shugo Maeda <shugo@ruby-lang.org>
- * test/test_setup_maker_1.0.rb: fixed swapped actual and expected
- values.
+ * eval.c (rb_call0): "return" event hook should be always executed
+ if event_hooks is set. fixed: [ruby-core:04662]
+ (backported from HEAD)
Mon Apr 4 23:17:52 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -22602,6 +11819,11 @@ Mon Apr 4 10:26:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/tk/lib/tk/dialog.rb: fixed typo.
+Sun Apr 3 17:16:33 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * win32/win32.{h,c} (rb_w32_fdopen): avoid warning on bcc32.
+ (backported from HEAD)
+
Sat Apr 2 23:38:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (CP, INSTALL): get rid of less portable options.
@@ -22609,8 +11831,8 @@ Sat Apr 2 23:38:54 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (configuration, create_makefile): correct configuration
variable.
- * wince/configure.bat, wince/setup.mak: add prefix, extstatic and
- rdoc options.
+ * {bcc32,win32,wince}/{Makefile.sub,setup.mak}: leave prefix empty in
+ config.status for backward compatibility. fixed: [ruby-core:04649]
* lib/mkmf.rb (create_makefile): ensure library directories get made
before copying libraries there.
@@ -22629,11 +11851,6 @@ Sat Apr 2 16:59:46 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/autoload.rb: add autoload entry 'TkDialogObj' and
'TkWarningObj'
-Sat Apr 2 13:23:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * hash.c (env_key): ENV.index is deprecated as well as Hash#index.
- use ENV.key instead. [ruby-dev:25974]
-
Sat Apr 2 02:19:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb (TkWindow.initialize): accept 'without_creating'
@@ -22650,39 +11867,12 @@ Thu Mar 31 22:23:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* README.EXT, README.EXT.ja (Appendix C): utility functions.
-Thu Mar 31 14:08:43 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Mar 31 14:15:44 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_engine.c (ossl_engine_s_load): should return
value. [ruby-dev:25971]
-Thu Mar 31 11:07:50 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/parser.rb: @@setter -> @@setters.
-
- * lib/rss/parser.rb
- (RSS::BaseListener.register_uri)
- (RSS::BaseListener.uri_registered?)
- (RSS::BaseListener.install_get_text_element):
- swapped the first argument and the second argument.
-
- * lib/rss/taxonomy.rb: swapped the first argument and the second
- argument for RSS::BaseListener.install_get_text_element.
- * lib/rss/image.rb: ditto.
- * lib/rss/syndication.rb: ditto.
- * lib/rss/dublincore.rb: ditto.
- * lib/rss/parser.rb: ditto.
- * lib/rss/1.0.rb: ditto.
- * lib/rss/2.0.rb: ditto.
- * lib/rss/0.9.rb: ditto.
- * lib/rss/content.rb: ditto.
-
-Thu Mar 31 11:00:36 2005 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/parser.rb
- (RSS::BaseListener.install_setter)
- (RSS::BaseListener.register_uri): changed fallback way.
-
-Thu Mar 31 08:25:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Mar 31 08:25:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (RUBYOPT): clear for the environment RubyGems installed.
@@ -22696,10 +11886,21 @@ Thu Mar 31 06:00:20 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
error even if the specified engine could not be loaded. (Dynamic
engines don't have fixed name to load.)
+Thu Mar 31 00:18:27 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * win32/ifchange.bat, win32/rm.bat: backported from HEAD.
+
+Wed Mar 30 23:44:50 2005 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * Makefile.in, */Makefile.sub, */configure.bat,
+ cygwin/GNUmakefile.in, common.mk, configure.in, ext/extmk.rb,
+ lib/mkmf.rb, instruby.rb, runruby.rb: backport extout.
+ [ruby-dev:25963]
+
Wed Mar 30 17:41:48 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tcltklib.c: add TclTkIp#_create_console() method to create
- a Tcl/Tk's console window.
+ * ext/tcltklib/tcltklib.c: add TclTkIp#_create_console() method to
+ create a Tcl/Tk's console window.
* ext/tk/lib/multi-tk.rb: support TclTkIp#_create_console() method.
@@ -22713,12 +11914,12 @@ Wed Mar 30 17:41:48 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/tkextlib/**: ditto.
-Tue Mar 29 22:20:49 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Mar 29 22:11:56 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/rinda/test_rinda.rb: use DRbObject.new_with instead of reinit.
[ruby-dev:25961]
-Tue Mar 29 00:04:57 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Mon Mar 28 23:40:40 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: move method DRbObject#reinit to DRbObject.new_with.
extract method DRbObject.prepare_backtrace. add DRb.regist_server,
@@ -22727,23 +11928,15 @@ Tue Mar 29 00:04:57 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/gw.rb: ditto.
-Mon Mar 28 20:53:44 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (extract_makefile): nothing to be removed when no file
- was deleted.
+Mon Mar 28 20:43:34 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/extmk.rb (extmake): restore srcdir.
+ * ext/syck/rubyext.c: get rid of warnings caused by a bug of VC.
Mon Mar 28 08:39:49 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (iconv_create): Iconv::Failure requires 3
arguments. (pointed out by NaHi)
-Sun Mar 27 00:56:58 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (remove_file): ignore Errno::E* if force option
- is set. [ruby-dev:25944]
-
Sat Mar 26 22:51:33 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb (_callback_entry_class?): add for checking whether
@@ -22799,26 +11992,31 @@ Thu Mar 24 23:10:44 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (check_sizeof): refine logging messages.
-Wed Mar 23 19:08:10 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Mar 24 03:57:48 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/utils.rb (WEBrick::Utils.create_listeners):
- should raise ArgumentError if no port is specified.
- even if the specified port is 0, all TCPServers should be
- initialized with the port given to the first one.
+ initialized with the port given to the first one.
* lib/webrick/server.rb (WEBrick::GenericServer#initialize): if :Port
parameter is 0, it should be updated with the port number which
- ectually listened.
-
-Wed Mar 23 16:12:40 2005 Shugo Maeda <shugo@ruby-lang.org>
+ actually listened.
- * parse.y (primary): fix lineno of rescue and ensure.
-
-Wed Mar 23 00:39:05 2005 Shugo Maeda <shugo@ruby-lang.org>
+Wed Mar 23 00:35:10 2005 Shugo Maeda <shugo@ruby-lang.org>
* test/ruby/test_settracefunc.rb (test_event): added tests for
"class" and "end" and "raise".
+Tue Mar 22 22:40:18 2005 Shugo Maeda <shugo@ruby-lang.org>
+
+ * eval.c (rb_call0): check event_hooks instead of trace_func.
+
+Tue Mar 22 17:30:44 2005 Shugo Maeda <shugo@ruby-lang.org>
+
+ * eval.c (rb_add_event_hook): new function to add a hook function for
+ interpreter events. (backported form HEAD)
+
Sun Mar 20 22:51:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (mkmf_failed): check if Makefile is created without
@@ -22844,42 +12042,28 @@ Thu Mar 17 17:42:13 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* struct.c (inspect_struct): ditto.
-Wed Mar 16 23:39:13 2005 Shugo Maeda <shugo@ruby-lang.org>
-
- * test/ruby/test_settracefunc.rb: added test for c-return.
-
-Wed Mar 16 22:57:43 2005 Shugo Maeda <shugo@ruby-lang.org>
+Wed Mar 16 23:36:02 2005 Shugo Maeda <shugo@ruby-lang.org>
* eval.c (rb_call0): call_cfunc() should be protected.
- * eval.c (rb_add_event_hook): use K&R style.
-
- * eval.c (rb_remove_event_hook): ditto.
+ * test/ruby/test_settracefunc.rb: added test for c-return.
-Wed Mar 16 22:03:15 2005 Shugo Maeda <shugo@ruby-lang.org>
+Wed Mar 16 22:20:25 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * eval.c (rb_add_event_hook): new function to add a hook function for
- interpreter events.
+ * object.c (str_to_id): fixed typo.
Wed Mar 16 18:08:32 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_call0): reorganize "return" event post.
- * eval.c (return_jump): no need to post "return" event here.
-
Tue Mar 15 23:49:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (Init_iconv): InvalidEncoding also should include
Iconv::Failure.
-Tue Mar 15 23:12:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (recursive_check, recursive_push): more restrictive check.
- fixed: [ruby-dev:25916]
+Tue Mar 15 16:38:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Mar 15 16:38:31 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tkutil/tkutil.c (ary2list): give wrong arguments to hash2kv()
+ * ext/tk/tkutil.c (ary2list): give wrong arguments to hash2kv()
Mon Mar 14 19:39:33 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -22895,8 +12079,7 @@ Mon Mar 14 12:21:03 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Mon Mar 14 08:14:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * object.c (str_to_id): raise ArgumentError for NUL containing
- strings.
+ * object.c (str_to_id): warn for NUL containing strings.
Mon Mar 14 00:13:49 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -22916,37 +12099,14 @@ Mon Mar 14 00:13:49 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/demos-jp/tcolor: ditto.
-Sun Mar 13 22:19:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (recursive_pop): raise TypeError instead of fatal error.
- fixed: [ruby-dev:25843]
-
-Sun Mar 13 10:09:17 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Mar 13 10:04:17 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/rinda/test_rinda.rb: remove test_gc. [ruby-dev:25871]
-Sun Mar 13 02:32:54 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Mar 10 19:12:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/openssl/ossl_ssl.c (ossl_tmp_dh_callback): should get DH
- parameter from the current SSL object.
-
-Sun Mar 13 02:09:03 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_pkey_dh.c (ossl_create_dh): fix typo.
- patch from IWATSUKI Hiroyuki. [ruby-dev:25867]
-
- * ext/openssl/ossl_ssl.c (ossl_tmp_dh_callback): ditto.
- (ossl_call_tmp_dh_callback): ditto
-
-Fri Mar 11 03:24:59 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (primary): wrong var node was set for NODE_LAMBDA.
- [ruby-core:04555]
-
-Thu Mar 10 19:10:29 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c (lib_eventloop_ensure): mis-delete a timer handler
- when exit from a recursive called eventloop
+ * ext/tcltklib/tcltklib.c (lib_eventloop_ensure): mis-delete a timer
+ handler when exit from a recursive called eventloop
* ext/tk/lib/tk/timer.rb: new TkRTTimer class, which can works for a
realtime operation
@@ -22967,48 +12127,18 @@ Thu Mar 10 08:10:11 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (make_regexp): need to free internal regexp structure when
compilation fails. [ruby-talk:133228]
-Thu Mar 10 01:08:20 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (bv_decl): remove initialize rule from block local
- variable declaration.
-
-Wed Mar 9 23:55:34 2005 Tanaka Akira <akr@m17n.org>
+Wed Mar 9 20:25:58 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * lib/pp.rb (PP::PPMethods#guard_inspect_key): support
- __recursive_key__. [ruby-dev:25821]
-
-Wed Mar 9 19:42:21 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_ssl.c: OpenSSL::SSL::SSLContexts suports callbacks:
- - SSLContext#client_cert_cb is a Proc. it is called when a client
- certificate is requested by a server and no certificate was yet
- set for the SSLContext. it must return an Array which includes
- OpenSSL::X509::Certificate and OpenSSL::PKey::RSA/DSA objects.
- - SSLContext#tmp_dh_callback is called in key exchange with DH
- algorithm. it must return an OpenSSL::PKey::DH object.
-
- * ext/openssl/ossl_ssl.c:
- (ossl_sslctx_set_ciphers): ignore the argument if it's nil.
- (ossl_start_ssl, ossl_ssl_write): call rb_sys_fail if errno isn't 0.
- [ruby-dev:25831]
-
- * ext/openssl/ossl_pkey.c
- (GetPrivPKeyPtr, ossl_pkey_sign): should call rb_funcall first.
- (DupPrivPKeyPtr): new function.
-
- * ext/openssl/ossl_pkey_dh.c: add default DH parameters.
-
- * ext/openssl/ossl_pkey.h: ditto.
+ * ext/openssl/ossl_ssl.c (ossl_start_ssl, ossl_ssl_write): call
+ rb_sys_fail if errno isn't 0. [ruby-dev:25831]
* ext/openssl/lib/openssl/cipher.rb: fix typo. [ruby-dev:24285]
-Wed Mar 9 18:09:51 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (gettable_gen): warns if VCALL name is used as
- out-of-scope block local variable. [EXPERIMENTAL]
+Wed Mar 9 15:46:35 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * parse.y (opt_bv_decl): add explicit block local variable
- declaration. raises error for name conflicts. [EXPERIMENTAL]
+ * lib/webrick/server.rb (WEBrick::GenericServer#start): should
+ restore @token if accept failure. suggested by Dominique Brezinski.
+ [ruby-core:04518]
Wed Mar 9 13:37:57 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -23021,10 +12151,9 @@ Tue Mar 8 18:16:55 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
sample supports to use a text widget as if it is a I/O stream (such
like as StringIO class).
-Tue Mar 8 13:39:25 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Mar 8 13:54:40 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/socket/mkconstants.rb: workaround for some of 4.4BSD-Lite
- derived OSs.
+ * ext/socket/socket.c: workaround for some of 4.4BSD-Lite derived OSs.
Tue Mar 8 12:36:17 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -23032,275 +12161,159 @@ Tue Mar 8 12:36:17 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
<sroberts@uniserve.com> for getsockopt and setsockopt is merged.
[ruby-doc:824]
-Tue Mar 8 10:48:53 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * eval.c (rb_exec_recursive): declaration should precede statements
- before C99.
-
-Tue Mar 8 10:05:40 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (errno_missing): Errno.const_missing to allow references
- to SyscallError exceptions not defined on the platform.
- [ruby-core:04522]
-
- * error.c (Init_syserr): Errno::NOERROR(0) for fallback exception.
-
-Tue Mar 8 01:19:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Tue Mar 8 01:27:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: follow nkf 1.66
fixed: [ruby-dev:25828]
-Mon Mar 7 21:29:40 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/server.rb (WEBrick::GenericServer#start): should
- restore @token if accept failure. suggested by Dominique Brezinski.
- [ruby-core:04518]
+Mon Mar 7 21:35:02 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* sample/webrick/httpsd.rb: fix typo in comment. suggested by
Kazuhiko Shiozaki.
-Mon Mar 7 21:01:37 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_require_safe): get actual path string under safe level
- when requested. fixed: [ruby-dev:25815]
-
-Mon Mar 7 16:46:02 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/openssl/ossl_ssl.c (ossl_start_ssl, ossl_ssl_read,
- ossl_ssl_write): need to set errno on Win32 platform.
-
Mon Mar 7 14:55:43 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (block_pass): should not push unique number if a block is
not an orphan. [ruby-dev:25808]
-Mon Mar 7 14:13:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/lib/openssl/buffering.rb (Buffering#initialize):
- should set @eof and @rbuffer.
-
-Mon Mar 7 10:28:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (inspect_obj): unintended space removal.
- [ruby-dev:25810]
-
- * eval.c (rb_exec_recursive): should not use NODE in disclosed
- context. [ruby-dev:25812]
-
- * io.c (rb_f_open): need not to check if to_open value is a
- T_FILE. [ruby-dev:25812]
-
-Mon Mar 7 01:21:01 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tkutil/tkutil.c: follow the change of st.c (committed
- at Fri, 4 Mar 2005 15:47:47 +0900 by matz)
-
-Mon Mar 7 00:01:55 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c: fail to call TclTkLib.mainloop when $SAFE==4
-
-Sun Mar 6 13:04:10 2005 Dee Zsombor <zsombor@ruby-lang.org>
-
- * misc/ruby-electric.el: added.
- * misc/Readme: updated.
-
-Sun Mar 6 11:47:10 2005 Sam Roberts <sroberts@uniserve.com>
-
- * lib/pp.rb: rdoced. [ruby-core:4490]
-
-Sun Mar 6 11:36:37 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/pp.rb (File::Stat#pretty_print): Etc.getpwuid and Etc.getgrgid
- may return nil. [ruby-talk:129826]
- reported by Daniel Berger.
-
-Sun Mar 6 06:34:31 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Wed Feb 16 02:55:21 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/openssl/ossl_ssl.c (ossl_start_ssl): should wait for that
- the underlying IO become readable or writable if the error was
- SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE. [ruby-dev:25795]
-
- * ext/openssl/ossl_ssl.c (ossl_ssl_read, ossl_ssl_write): ditto.
+ * ext/openssl/ossl_ssl.c (ossl_start_ssl, ossl_ssl_read,
+ ossl_ssl_write):
+ - need to set errno on Win32 platform.
+ - should call rb_sys_fail instead of rasing SSLError if
+ SSL_ERROR_SYSCALL occured.
+ - should wait for that the underlying IO become readable or
+ writable if the error was SSL_ERROR_WANT_READ or
+ SSL_ERROR_WANT_WRITE. [ruby-dev:25795]
* ext/openssl/lib/openssl/buffering.rb
+ (Buffering#initialize): should set @eof and @rbuffer.
+ (Buffering#fill_rbuff): should rescue Errno::EAGAIN.
(Buffering#consume_rbuf): pointless eof flag resetting is deleted.
(Buffering#read): should return an empty string if the specified
size is zero.
(Buffering#readpartial): new method.
(Buffering#readline): fix typo.
(Buffering#getc): return the first character of string correctly.
+ (Buffering#each): fix typo. suggested by Brian Ollenberger.
(Buffering#readchar): fix typo.
(Buffering#eof?): should read again it the input buffer is empty.
(Buffering#do_write): should rescue Errno::EAGAIN.
(Buffering#puts): use "\n" as the output field separator.
+ * ext/openssl/lib/openssl/ssl.rb: set non-blocking flag to the
+ underlying IO.
+
* ext/openssl/extconf.rb: get rid of GNUmakefile generation.
* text/openssl/test_pair.rb: test for IO like methods.
* test/ruby/ut_eof.rb: test about empty file.
-Sat Mar 5 17:48:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (rb_glob): fixed mismatch of argument.
-
- * dir.c (fnmatch): removed unnecessary code. (by string.c 1.219)
-
- * win32/win32.c (NtInitialize): ditto. (by numeric.c 1.117)
-
-Sat Mar 5 16:50:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Mon Mar 7 10:22:06 2005 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/nkf/nkf-utf8/nkf.c: follow nkf 1.65
+ * lib/un.rb: should use OptionParser. (backported form HEAD)
-Sat Mar 5 16:29:26 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Mon Mar 7 09:18:42 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/tk/lib/multi-tk.rb: freeze callback-entry objects
+ * string.c (rb_str_cmp_m): should not return false but nil.
+ fixed: [ruby-dev:25811]
- * ext/tk/lib/tkextlib/tile.rb: support tile-0.6
+Mon Mar 7 01:22:14 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Mar 5 12:52:08 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/tk/tkutil.c: remove the some codes which depend on the
+ difference between Ruby1.8 and 1.9, because st.c on Ruby1.9
+ was changed.
- * lib/mkmf.rb (create_makefile): allow putting spaces between target
- and colon in depend file.
+Mon Mar 7 00:01:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Mar 5 02:41:00 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/tcltklib/tcltklib.c: fail to call TclTkLib.mainloop when $SAFE==4
- * file.c (eaccess): workaround for VC++8 runtime.
+Sun Mar 6 16:41:33 2005 Minero Aoki <aamine@loveruby.net>
- * win32/win32.c (ioinfo): VC++8 support.
-
-Fri Mar 4 19:39:55 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#do_includes): replace
- also locally defined modules.
+ * lib/net/http.rb: HTTPHeader holds its header fields as an array
+ (backport from CVS HEAD rev 1.112-1.123). [ruby-list:40629]
- * ext/iconv/iconv.c: rdocified.
+ * test/net/http/test_httpheader.rb: new file.
- * ext/strscan/strscan.c: moved misplaced rdoc.
-
-Fri Mar 4 16:11:20 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * eval.c (rb_exec_recursive): matched the declaration to prototype.
-
- * ext/curses/curses.c: don't need to check HAVE_WCOLOR_SET excluding
- window_color_set().
+Sun Mar 6 11:47:10 2005 Sam Roberts <sroberts@uniserve.com>
- * ext/tk/tcltklib.c: fixed commit mistakes.
+ * lib/pp.rb: rdoced. [ruby-core:4490]
-Fri Mar 4 12:45:17 2005 Tilman Sauerbeck <tilman@code-monkey.de>
+Sun Mar 6 11:36:37 2005 Tanaka Akira <akr@m17n.org>
- * lib/rdoc/parsers/parse_c.rb: allow whitespace after function names.
- [ruby-core:4296]
+ * lib/pp.rb (File::Stat#pretty_print): Etc.getpwuid and Etc.getgrgid
+ may return nil. [ruby-talk:129826]
+ reported by Daniel Berger.
- * lib/rdoc/parsers/parse_simple.rb: adds support for private comments
- in the "simple" parser. [ruby-core:4301]
+Sat Mar 5 18:06:21 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Fri Mar 4 12:45:17 2005 Charles Mills <cmills@freeshell.org>
+ * dir.c (fnmatch): removed unnecessary code. (ruby_1_8 didn't have
+ String#clear, so [ruby-dev:24749] didn't affect it)
- * lib/rdoc/parsers/parse_c.rb: adds support for constants
- (rb_define_const), accessors (rb_define_attr), and makes a
- couple fixes. [ruby-core:4307]
+ * win32/win32.c (NtInitialize): ditto. (by numeric.c 1.101.2.14)
-Fri Mar 4 12:45:17 2005 Florian Gross <florgro@gmail.com>
+Sat Mar 5 16:29:26 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/rdoc/parsers/parse_rb.rb: Logic for def Builtin.method() end
- [ruby-core:4302]
+ * ext/tk/lib/multi-tk.rb: freeze callback-entry objects
-Fri Mar 4 12:45:17 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tkextlib/tile.rb: support tile-0.6
- * array.c: replace rb_protect_inspect() and rb_inspecting_p() by
- rb_exec_recursive() in eval.c.
+Fri Mar 4 19:39:28 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_exec_recursive): new function.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#do_includes): replace
+ also locally defined modules.
- * array.c (rb_ary_join): use rb_exec_recursive().
+ * ext/iconv/iconv.c: backport Iconv::InvalidEncoding from CVS HEAD.
- * array.c (rb_ary_inspect, rb_ary_hash): ditto.
+ * ext/strscan/strscan.c: moved misplaced rdoc.
- * file.c (rb_file_join): ditto.
+Fri Mar 4 15:58:12 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
+ * lib/cgi-lib.rb: add deprecation warning. [ruby-dev:25499]
+ getopts.rb, parsearg.rb, importenv.rb as well.
- * io.c (rb_io_puts): ditto.
+Fri Mar 4 11:17:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * object.c (rb_obj_inspect): ditto
+ * ext/tcltklib/tcltklib.c (ip_rbUpdateCommand): get rid of
+ warnings with Tcl/Tk 8.3 or former (backport from CVS_HEAD).
- * struct.c (rb_struct_inspect): ditto.
+ * ext/tcltklib/tcltklib.c (ip_rb_threadUpdateCommand): ditto.
Fri Mar 4 10:15:30 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
-Fri Mar 4 09:37:12 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * common.mk (install-nodoc, pre-install-doc, post-install-doc):
- fix some omissions.
-
-Fri Mar 4 08:09:12 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/time.rb (Time::strptime): add new function. inspired by
- [ruby-talk:132815].
-
- * lib/parsedate.rb (ParseDate::strptime): ditto.
-
Fri Mar 4 07:07:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: follow nkf 1.63
-Thu Mar 3 23:24:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Thu Mar 3 23:49:00 2005 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: follow nkf 1.62
-Thu Mar 3 18:47:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * {bcc32,win32,wince}/Makefile.sub (config.h): check if affected
- when makefiles are modified.
-
- * {bcc32,win32,wince}/Makefile.sub (config.status): add variables
- for tests.
-
- * win32/ifchange.bat: try to update a file only if modified.
-
- * win32/resource.rb: more descriptions.
-
- * common.mk: add {pre,post}-install targets.
-
- * instruby.rb (install?): install particular part.
-
- * bcc32/Makefile.sub (post-install-ext): remove debug information
- files after installation.
-
- * ext/tk/tcltklib.c (ip_rbUpdateCommand, ip_rb_threadUpdateCommand):
- get rid of warnings with Tcl/Tk 8.3 or former.
-
Thu Mar 3 11:49:51 2005 Kouhei Sutou <kou@cozmixng.org>
* sample/rss/tdiary_plugin/rss-recent.rb: added site information.
-Wed Mar 2 19:53:44 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (parse_args): return false if nothing matched.
-
-Wed Mar 2 17:15:08 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c (lib_eventloop_core): fix typo
+Wed Mar 2 19:53:07 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Mar 2 16:59:50 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * ext/extmk.rb (parse_args): add DESTDIR only when not directed
+ already. fixed: [ruby-dev:25781]
- * eval.c (ruby_native_thread_kill): call pthread_kill() to send a
- signal to ruby's native thread
+Wed Mar 2 17:14:18 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ruby.h: add definition of ruby_native_thread_kill()
+ * ext/tcltklib/tcltklib.c (lib_eventloop_core): fix typo
- * signal.c (sigsend_to_ruby_thread): send the signal to ruby's
- native thread ([ruby-dev:25744], [ruby-dev:25754]), and set
- signal mask to the current native thread
+Wed Mar 2 16:00:02 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Wed Mar 2 16:03:08 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c: enforce thread-check and exception-handling to
- avoid SEGV trouble.
+ * ext/tcltklib/tcltklib.c: enforce thread-check and exception-handling
+ to avoid SEGV trouble.
+ [KNOWN BUG] When supports pthread and running multiple Tk
+ interpreters, an interrupt signal causes SEGV frequently. That
+ may be a trouble of Ruby's signal handler.
* ext/tk/tkutil/tkutil.c; fix a bug on converting a SJIS string array
to a Tcl's list string.
@@ -23344,58 +12357,17 @@ Wed Mar 2 16:03:08 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/demos-*/widget: add entries of animation demos.
-Wed Mar 2 12:21:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_eval): [EXPERIMENTAL] NODE_LAMBDA implemented.
- [ruby-dev:25780]
-
- * node.h (NODE_LAMBDA): for literal Proc object.
-
- * parse.y (expr): interpret mere do...end block as proc object.
-
- * parse.y (primary): ditto, for brace block.
+Tue Mar 1 00:47:43 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Mar 1 21:16:54 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
+ * test/rinda/test_rinda.rb: backport from CVS_HEAD. use
+ MockClock.sleep instead of Kernel.sleep [ruby-dev:25387]
- * regcomp.c (optimize_node_left): uninitialized member
- (OptEnv.backrefed_status) was used. [ruby-dev:25778]
-
-Tue Mar 1 16:50:37 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * regparse.c: move st_*_strend() functions from st.c. fixed some
- potential memory leaks.
-
-Tue Mar 1 00:40:35 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Mar 1 00:34:24 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/tuplespace.rb (Rinda::TupleSpace): improved keeper thread.
* test/rinda/test_rinda.rb: ditto.
-Mon Feb 28 23:10:13 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/socket/socket.c (Init_socket): IPv6 is not supported although
- AF_INET6 is defined on bcc32. (rev1.108 again)
-
- * ext/socket/mkconstants.rb: ditto.
-
-Mon Feb 28 21:55:49 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * ext/strscan/strscan.c (strscan_s_allocate):
- use onig_region_init().
-
- * ext/strscan/strscan.c (adjust_registers_to_matched):
- use onig_region_set().
-
-Mon Feb 28 15:12:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/socket/socket.c (Init_socket): ported more Socket::Constants
- from ruby_1_8, and made it easy to add new constants.
- [ruby-dev:25771]
-
- * ext/socket/depend: ditto.
-
- * ext/socket/mkconstants.rb: ditto. (added)
-
Mon Feb 28 11:42:23 2005 Ian Macdonald <ian@caliban.org>
* exception error messages updated. [ruby-core:04497]
@@ -23406,27 +12378,6 @@ Mon Feb 28 09:03:09 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
-Sun Feb 27 05:55:38 2005 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: fix typo. [ruby-core:04494]
-
-Sat Feb 26 16:58:20 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * parse.y, re.c, regex.h, LEGAL, ext/strscan/strscan.c:
- remove oniggnu.h (GNU regex API).
-
-Wed Feb 23 22:08:16 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * st.c, st.h: imported additional file changes on
- Oniguruma 3.7.0.
-
-Wed Feb 23 21:45:29 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c,
- regenc.c, regenc.h, regerror.c, regexec.c, regint.h,
- regparse.c, regparse.h, sjis.c, utf8.c: imported Oni Guruma
- 3.7.0.
-
Wed Feb 23 15:04:32 2005 akira yamada <akira@ruby-lang.org>
* lib/uri/generic.rb (split_userinfo): should split ":pass" into ""
@@ -23439,53 +12390,27 @@ Wed Feb 23 08:00:18 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_unshift_m): ditto.
-Wed Feb 23 01:53:29 2005 Shugo Maeda <shugo@ruby-lang.org>
+Wed Feb 23 01:57:46 2005 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (initialize): handle certs correctly. Thanks,
- NABEYA Kenichi.
+ NABEYA Kenichi. (backported from CVS HEAD)
-Wed Feb 23 00:37:34 2005 Kouhei Sutou <kou@cozmixng.org>
+Tue Feb 22 07:25:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/mkmf.rb (mkmf_failed): fixed typo.
+ * parse.y (parser_yylex): identfier after dot must not be a variable.
-Tue Feb 22 23:52:45 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Feb 21 10:04:49 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * configure.in, lib/mkmf.rb: use simple commands if available.
-
- * mkconfig.rb: remove autoconf internal variables from rbconfig.rb.
-
- * lib/mkmf.rb (create_makefile): substitute implicit rules in depend
- file.
-
- * {bcc32,win32,wince}/Makefile.sub (COMPILE_RULES, RULE_SUBST):
- include $(topdir) and $(hdrdir) to search path.
-
-Tue Feb 22 23:51:45 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/syck/rubyext.c: get rid of warnings caused by a bug of VC.
-
-Tue Feb 22 23:50:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * signal.c (ruby_signal, ruby_nativethread_signal): must be valid as
- expressions, not only statements.
-
-Tue Feb 22 12:54:13 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_thread_start_0): update curr_thread before raising
- TAG_THREAD. [ruby-dev:25712]
-
-Tue Feb 22 07:24:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * {bcc32,win32,wince}/Makefile.sub (config.h): add fcntl.
- * parse.y (parser_yylex): identifier after dot must not be a variable.
+ * win32/win32.[ch] (fcntl): ditto.
-Mon Feb 21 18:31:12 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+ * win32/win32.c (rb_w32_connect): support nonblocking mode.
- * signal.c: Standard signal handlers ignore signals on non-Ruby native
- threads. When a handler is entried with ruby_signal() (like as the
- standard signal handlers), the handler for the signal is marked as
- it cannot accept non-Ruby native threads. If a handler can treat all
- signals on all native threads, please use ruby_nativethread_signal()
- to entry it.
+ * ext/socket/socket.c (wait_connectable, ruby_connect): support
+ nonblocking connect on various platforms.
+ all changes are backported from CVS HEAD. [ruby-core:3154],
+ [ruby-core:4364].
Sun Feb 20 00:48:48 2005 Tanaka Akira <akr@m17n.org>
@@ -23493,7 +12418,7 @@ Sun Feb 20 00:48:48 2005 Tanaka Akira <akr@m17n.org>
re-implemented according to RFC 1738.
reported by Guillaume Marcais. [ruby-talk:131650]
-Sat Feb 19 18:46:56 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Feb 19 18:11:47 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb (DRbObject#respond_to?): take two arguments.
[ruby-dev:25722]
@@ -23505,16 +12430,7 @@ Sat Feb 19 13:52:02 2005 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb: call OpenSSL::SSL::SSLSocket#post_connection_check
after connection is made.
-Sat Feb 19 13:31:28 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (extract_makefile): remove no longer existing installed
- files.
-
- * lib/mkmf.rb (install_dirs): return installation directory list.
-
- * lib/mkmf.rb (create_makefile): reverted wrongly removed lines.
-
-Sat Feb 19 01:28:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sat Feb 19 01:32:03 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/bigdecimal/lib/bigdecimal/newton.rb: resolved LoadError.
[ruby-dev:25685]
@@ -23531,42 +12447,16 @@ Fri Feb 18 17:14:00 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
-Fri Feb 18 04:06:41 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (fcall_gen): lvar(arg) will be evaluated as
- lvar.call(arg) when lvar is a defined local variable. [new]
-
-Thu Feb 17 22:15:34 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * ext/strscan/strscan.c: calls Oniguruma API directly.
-
-Thu Feb 17 21:53:12 2005 K.Kosako <sndgk393 AT ybb.ne.jp>
-
- * common.mk, LEGAL: remove reggnu.c.
-
-Thu Feb 17 21:53:12 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * gc.c, re.c: now ruby calls Oniguruma API directly, bypassing
- GNU compatible APIs.
-
-Thu Feb 17 20:09:23 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Feb 17 20:11:18 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/drb/drb.rb (DRbServer.default_safe_level): fix typo.
-Thu Feb 17 20:09:23 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Feb 17 20:11:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/digest/test_digest.rb: separate test case for each algorithms.
[ruby-dev:25412]
-Thu Feb 17 14:31:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_class_initialize): call inherited method before
- calling initializing block.
-
- * eval.c (rb_thread_start_1): initialize newly pushed frame.
- fixed: [ruby-dev:25707]
-
-Thu Feb 17 13:46:00 2005 Nathaniel Talbott <ntalbott@ruby-lang.org>
+Thu Feb 17 11:54:00 2005 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit/collector.rb (collect_file): now deletes paths added
to $LOAD_PATH instead of restoring it verbatim.
@@ -23584,43 +12474,38 @@ Thu Feb 17 04:21:47 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
-Thu Feb 17 00:31:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/drb/test_drb.rb, ut_safe1.rb: port from 1.8
+Thu Feb 17 00:09:45 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Thu Feb 17 00:02:27 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * test/drb/ignore_test_drb.rb: move TestDRbReusePort to new file
+ [ruby-dev:25238]
- * eval.c (is_defined): NODE_IASGN is an assignment.
+ * test/drb/test_drb.rb: add method DRbService.ext_service, move
+ TestDRbReusePort to new file [ruby-dev:25238]
-Wed Feb 16 23:54:14 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * test/drb/test_drb.rb: ditto.
- * eval.c (rb_thread_start_1): outer block variables wasn't linked to
- threads. fixed: [ruby-dev:25700]
+ * test/drb/test_drbssl.rb: ditto.
-Wed Feb 16 15:11:43 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * test/drb/test_drbunix.rb: ditto.
- * ext/openssl/lib/openssl/ssl.rb (OpenSSL::Nonblock#initialize):
- native win32 platform doesn't have F_GETFL.
+ * test/drb/ut_drb.rb: reduce sleep.
-Wed Feb 16 02:47:45 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Feb 17 00:02:27 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/openssl/ossl_ssl.c (ossl_ssl_read, ossl_ssl_write): should
- call rb_sys_fail instead of raising SSLError if SSL_ERROR_SYSCALL
- occurred.
+ * eval.c (is_defined): NODE_IASGN is an assignment.
- * ext/openssl/lib/openssl/buffering.rb (Buffering#fill_rbuff):
- should rescue Errno::EAGAIN.
+Wed Feb 16 23:34:30 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * ext/openssl/lib/openssl/buffering.rb (Buffering#each): fix typo.
- suggested by Brian Ollenberger.
+ * lib/drb/drb.rb: add lazy stop_service. ([druby-ja:109])
- * ext/openssl/lib/openssl/ssl.rb: set non-blocking flag to the
- underlying IO.
+ * lib/drb/extserv.rb: ditto.
-Tue Feb 15 22:14:34 2005 sheepman <sheepman@tcn.zaq.ne.jp>
+Wed Feb 16 17:07:57 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/readline/readline.c (Readline.readline): use rl_outstream
- and rl_instream. [ruby-dev:25699]
+ * ext/tk/tkutil.c: Follow the change of st.c (st_foreach)
+ [ruby-list:40623].
+ Sometimes mis-convert from a Ruby's Array of SJIS Strings, which
+ includes some kind of SJIS characters, to a Tcl's UTF8 list string.
Mon Feb 14 23:58:17 2005 Kouhei Sutou <kou@cozmixng.org>
@@ -23630,14 +12515,13 @@ Mon Feb 14 23:58:17 2005 Kouhei Sutou <kou@cozmixng.org>
Mon Feb 14 13:12:38 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/lib/openssl/ssl.rb
- (OpenSSL::SSL::SSLSocket#post_connection_check): new method.
+ (OpenSSL::SSL::SSLSocket#post_connection_check): new method.
-Mon Feb 14 00:10:17 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Mon Feb 14 00:40:49 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/drb/drb.rb (DRbServer): add default_safe_level, safe_level,
- config[:safe_level] ([druby-ja:120])
+ * lib/drb/drb.rb (InvokeMethod.perform): pass DRb info to sub thread.
- * test/drb/test_drb.rb, ut_eval.rb, ut_safe1.rb: ditto.
+ * test/drb/test_drb.rb (test_01_safe1_safe4_eval): fix test case.
Sun Feb 13 23:13:46 2005 Kouhei Sutou <kou@cozmixng.org>
@@ -23650,43 +12534,22 @@ Sun Feb 13 23:13:46 2005 Kouhei Sutou <kou@cozmixng.org>
* test/rss/: added tests for the convenient methods.
-Sun Feb 13 23:12:47 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Feb 13 22:43:03 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * eval.c (rb_thread_start_0): restore prot_tag before rewinding.
+ * lib/drb/drb.rb (DRbServer): add default_safe_level, safe_level,
+ config[:safe_level] ([druby-ja:120])
+
+ * test/drb/test_drb.rb, ut_eval.rb, ut_safe1.rb: ditto.
Sun Feb 13 16:56:52 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI.start): should set reason-phrase
to the value of status header field. ([ruby-dev:40617])
-Sun Feb 13 11:38:40 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * regparse.c (type_cclass_hash): (Thanks Nobu) fixed
- overrun. ([ruby-dev:25676]).
-
-Sun Feb 13 10:53:08 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * oniggnu.h, oniguruma.h, regcomp.c, st.c: imported
- Oni Guruma 3.6.0.
-
-Sun Feb 13 01:33:19 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Feb 13 00:52:33 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/erb.rb (ERB::Util.h, u): make it module_function.
-Sat Feb 12 22:17:11 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (TAG_THREAD): to start a new thread.
-
- * eval.c (ruby_init, ruby_options, ruby_cleanup, rb_protect,
- rb_load_protect, rb_thread_start_0): make thread anchor.
-
- * eval.c (proc_alloc): clone proc object if klass is not Proc or
- created in different thread.
-
- * eval.c (rb_block_pass): call a function with a block. [new]
-
- * eval.c (rb_f_throw): raise NameError in main thread.
-
Sat Feb 12 17:29:19 2005 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb (OpenURI.open_loop): send authentication only for
@@ -23696,10 +12559,6 @@ Sat Feb 12 15:07:23 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* random.c (rand_init): suppress warning.
-Sat Feb 12 14:10:24 2005 Tanaka Akira <akr@m17n.org>
-
- * lib/open-uri.rb (OpenURI.open_http): reject userinfo explicitly.
-
Sat Feb 12 13:54:03 2005 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb: support https if the platform provides CA
@@ -23707,10 +12566,10 @@ Sat Feb 12 13:54:03 2005 Tanaka Akira <akr@m17n.org>
Sat Feb 12 06:18:28 2005 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
- * ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
+ * ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check.
[ruby-dev:25675]
-Fri Feb 11 17:37:50 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Feb 11 17:40:42 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509store.c (ossl_x509store_set_default_paths):
new method OpenSSL::X509::Store#set_default_paths.
@@ -23732,108 +12591,68 @@ Fri Feb 11 04:54:13 2005 Tilman Sauerbeck <tilman@code-monkey.de>
* lib/rdoc/generators/ri_generator.rb: ditto.
-Thu Feb 10 13:52:42 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * configure.in, win32/Makefile.sub (LIBS, COMMON_HEADERS): use
- winsock2 on mswin32/mingw.
+Thu Feb 10 11:14:17 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/socket/extconf.rb: ditto.
-
- * win32/win32.c (StartSockets): ditto.
+ * win32/Makefile.sub (COMMON_HEADERS): shouldn't include winsock2.h.
- * win32/win32.h: ditto.
+ * ext/socket/extconf.rb (sockaddr_storage): remove workaround for
+ mswin32.
-Thu Feb 10 12:09:16 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Feb 10 10:29:16 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/extmk.rb (extract_makefile): default to true if not compiled
- previously.
-
- * ext/extmk.rb (extmake): create dummy makefile if extconf failed.
-
-Thu Feb 10 12:07:10 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (init_stdhandle): assign standard file handles.
-
- * bcc32/Makefile.sub (COMMON_LIBS): add libraries included in
- import32.lib.
-
- * lib/mkmf.rb (create_makefile): restrict prefixing with srcdir to
- rule lines, add search path to implicit rules, and set Borland make
- special macros for search path.
-
- * win32/win32.c, win32/win32.h (read): avoid a BCC runtime bug.
+ * ext/curses/curses.c: don't need to check HAVE_WCOLOR_SET excluding
+ window_color_set().
Thu Feb 10 00:47:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* struct.c (make_struct): fixed: [ruby-core:04402]
-Wed Feb 9 16:33:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/socket/socket.c (wait_connectable): fixed wrong condition.
-
-Wed Feb 9 14:42:28 2005 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
-
- * eval.c (scope_dup): add volatile not to optimize tbl.
-
-Wed Feb 9 10:02:02 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/tk/make-tkutil, ext/tk/tkutil/subconf.rb: no longer used.
-
- * ext/tk/tkutil/extconf.rb: need to compile tkutil. [ruby-dev:25607]
-
Wed Feb 9 08:07:08 2005 Paul Duncan <pabs@pablotron.org>
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
-Tue Feb 8 23:48:36 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Feb 8 23:51:47 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: reject :instance_eval, :class_eval, :module_eval
[druby-ja:117]
-Tue Feb 8 22:38:28 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * keywords, parse.y: separate EXPR_VALUE from EXPR_BEG.
- fixed: [ruby-core:04310], [ruby-core:04368]
-
Tue Feb 8 13:06:12 2005 Sam Roberts <sroberts@uniserve.com>
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
+Tue Feb 8 09:30:01 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi.rb (CGI::Cookie): [ruby-talk:130040]
+
Tue Feb 8 00:19:02 2005 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb (Resolv::DNS::Name#subdomain_of?): new method.
(Resolv::DNS::Name#inspect): ditto.
Suggested by Sam Roberts. [ruby-talk:129086]
-Mon Feb 7 23:14:11 2005 Tanaka Akira <akr@m17n.org>
-
- * io.c (io_getc): flush rb_stdout before read from stdin, which is
- connected to a tty. [ruby-core:4378]
-
- * rubyio.h (FMODE_TTY): renamed from FMODE_LINEBUF.
-
Mon Feb 7 10:06:30 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c: [ruby-doc:818]
-Mon Feb 7 02:13:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Feb 7 01:56:20 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * instruby.rb, rubytest.rb (srcdir): no longer embed srcdir into
+ rbconfig.rb. (backported from CVS HEAD)
* ext/socket/extconf.rb (sockaddr_storage): winsock2.h have the
definition of struct sockaddr_storage, but socket.c doesn't
include it because this version of ruby still has binary level
compatibility with winsock1.
-Mon Feb 7 01:22:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/mkmf.rb (create_makefile): should support header files in
+ depend file.
- * ext/extmk.rb (extract_makefile): extract previously collected
- informations from existing Makefile.
+Mon Feb 7 01:21:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/extconf.rb: check if getaddrinfo() works fine only when
wide-getaddrinfo option is not given. fixed: [ruby-dev:25422]
- * ext/tk/extconf.rb: separate tkutil configuration.
-
* lib/mkmf.rb ($extmk): check if under ext directory.
* lib/mkmf.rb (Logging.postpone): allow recursive operation.
@@ -23850,25 +12669,31 @@ Mon Feb 7 01:22:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (dir_config): accept arrays of directory names as
default values.
- * lib/mkmf.rb (with_cppflags, with_cflags, with_ldflags): keep flags
- modified if the block returned true.
+ * mkconfig.rb: no longer embed srcdir and compile_dir into
+ rbconfig.rb.
+
+ * lib/mkmf.rb (create_makefile): fix unbalanced parens.
-Sun Feb 6 19:20:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Feb 6 19:23:01 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* eval.c (stack_extend): add prototype because VC++8 doesn't
accept __declspec(noinline) with K&R style function definitions.
+ (backported from CVS HEAD)
-Sun Feb 6 13:56:19 2005 Tadayoshi Funaba <tadf@dotrb.org>
+Sun Feb 6 14:14:26 2005 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date.rb (new_with_hash): changed messages of exception.
* lib/date/format.rb (str[fp]time): undocumented conversion
specifications %[1-3] are now deprecated.
-Sun Feb 6 11:27:37 2005 Tanaka Akira <akr@m17n.org>
+Sun Feb 6 12:20:11 2005 Akinori MUSHA <knu@iDaemons.org>
- * ext/dl/dl.c (Init_dl): function declaration should precede
- statements before C99.
+ * bignum.c (rb_big2ulong_pack): One too many arguments are passed
+ to big2ulong().
+
+ * re.c (rb_reg_init_copy, rb_reg_initialize_m): One too many
+ arguments are passed to rb_reg_initialize().
Sun Feb 6 03:24:20 2005 Tanaka Akira <akr@m17n.org>
@@ -23880,28 +12705,7 @@ Sun Feb 6 03:24:20 2005 Tanaka Akira <akr@m17n.org>
(Resolv::DNS::Message::MessageDecoder#get_string_list): ditto.
based on [ruby-talk:129732] by Sam Roberts.
-Sat Feb 5 02:24:06 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/ripper/test_scanner_events.rb: fix test.
-
-Fri Feb 4 18:44:35 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/lexer.rb: last Lexer fix was incomplete;
- test all green.
-
-Fri Feb 4 15:57:06 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (open_args): fix too verbose warnings for the space
- before argument parentheses. [ruby-dev:25492]
-
- * parse.y (parser_yylex): ditto.
-
-Fri Feb 4 14:33:25 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/filter.rb: ripper/tokenizer ->
- ripper/lexer. [ruby-dev:25632]
-
-Fri Feb 4 00:24:15 2005 Kouhei Sutou <kou@cozmixng.org>
+Fri Feb 4 00:30:45 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss: supported Image module.
http://web.resource.org/rss/1.0/modules/image/
@@ -23914,19 +12718,6 @@ Thu Feb 3 23:42:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_extend, strio_putc): fill with zero
extended portion. [ruby-dev:25626]
-Thu Feb 3 16:12:57 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parser_yylex): the first expression in the parentheses
- should not be a command. [ruby-dev:25492]
-
-Thu Feb 3 03:31:20 2005 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/nkf.c: follow original v 1.57
-
- * ext/nkf/nkf-utf8/utf8tbl.c: follow original v 1.8
-
- * ext/nkf/nkf-utf8/config.h: follow original v 1.7
-
Wed Feb 2 23:52:53 2005 sheepman <sheepman@tcn.zaq.ne.jp>
* ext/stringio/stringio.c (strio_truncate): should MEMZERO an extended
@@ -23946,49 +12737,18 @@ Wed Feb 2 21:56:01 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/trackback.rb: ditto.
-Wed Feb 2 03:30:58 2005 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/tokenizer.rb -> lexer.rb.
-
- * ext/ripper/lib/ripper/lexer.rb: new method Ripper.slice.
- [experimental]
-
- * ext/ripper/lib/ripper/sexp.rb: new file. [experimental]
-
- * ext/ripper/lib/ripper.rb: require ripper/lexer and ripper/sexp.
-
-Tue Feb 1 21:49:24 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+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.
Tue Feb 1 00:20:23 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * Makefile.in, configure.in: made EXTOUT configurable.
-
- * ext/extmk.rb (extmake), lib/mkmf.rb: keep topdir as relative style.
-
- * lib/mkmf.rb: make extensions in depth order. [ruby-dev:25522]
-
* configure.in (aix): fix linker flags on AIX. [ruby-talk:125460]
-Mon Jan 31 13:16:39 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/extconf.rb: add tkutil configuration step (remove old schema)
-
- * ext/tk/depend: remove the information of tkutil
-
- * ext/tk/make-tkutil: sub-part of Makefile to compile tkutil
-
- * ext/tk/tkutil/tkutil.c: move tkutil.c to subdirectory
-
- * ext/tk/tkutil/subconf.rb: configuration file for tkutil.c
+Mon Jan 31 13:33:21 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tkutil/depend: ditto
-
-Mon Jan 31 13:13:35 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/tcltklib.c: add invalid namespace check
+ * ext/tcltklib/tcltklib.c: add invalid namespace check
* ext/tk/lib/multi-tk.rb: add invalid_namespace? method
@@ -23998,22 +12758,11 @@ Mon Jan 31 10:29:18 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
-Mon Jan 31 09:44:03 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (Init_Object): remove Object#type. [ruby-core:04335]
-
Sat Jan 29 09:42:12 2005 Sam Roberts <sroberts@uniserve.com>
* lib/resolv.rb (Resolv::DNS::Resource::IN::SRV): Added RFC2782 SRV
resource record for specifying location of services.
-Sat Jan 29 00:10:33 2005 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c,
- regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h,
- regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported
- Oni Guruma 3.5.4.
-
Fri Jan 28 17:16:55 2005 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb (Resolv::DNS::Config.parse_resolv_conf):
@@ -24023,60 +12772,33 @@ Fri Jan 28 17:16:55 2005 Tanaka Akira <akr@m17n.org>
(Resolv::DNS::Config#lazy_initialize): ditto.
Suggested by Sam Roberts.
-Thu Jan 27 17:15:03 2005 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/tk/extconf.rb: support new tk scheme on bccwin32.
- fixed: [ruby-dev:25546]
-
Thu Jan 27 13:18:03 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
-Thu Jan 27 00:12:19 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/fileutils/test_fileutils.rb (setup): support BSD style
- directory group inheritance (again).
+Thu Jan 27 00:15:29 2005 Minero Aoki <aamine@loveruby.net>
-Thu Jan 27 00:02:40 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/fileutils/test_fileutils.rb (setup): support BSD style
- directory group inheritance. [ruby-dev:25440]
+ * test/fileutils/test_fileutils.rb (setup): support BSD-style
+ directory group inheritance. (backport from HEAD, rev 1.32)
* test/fileutils/fileasserts.rb (assert_same_entry): show entry
- difference.
-
-Wed Jan 26 17:12:50 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y: forgot to initialize parser struct. [ruby-dev:25492]
-
- * parse.y (parser_yylex): no tLABEL on EXPR_BEG.
- [ruby-talk:127711]
-
-Wed Jan 26 14:12:58 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+ difference. (backport from HEAD, rev 1.4)
- * ext/Setup*: remove tcltklib.
+Wed Jan 26 23:09:11 2005 Minero Aoki <aamine@loveruby.net>
-Wed Jan 26 12:45:16 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+ * lib/net/protocol.rb (WriteAdapter#puts): should append \n, not
+ prepend. [ruby-talk:128302] (backport from HEAD, rev 1.75)
- * ext/tk/extconf.rb: support new tk scheme on mswin32.
- fixed: [ruby-dev:25535]
-
-Wed Jan 26 10:45:19 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Jan 26 10:51:50 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (flock_winnt, flock_win95): unlock file even if
- LOCK_NB is specified.
-
-Tue Jan 25 23:10:48 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk: merge tcltklib for Ruby/Tk installation control
-
- * ext/tcltklib: remove
+ LOCK_NB is specified. (backported from CVS HEAD)
-Tue Jan 25 17:05:15 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jan 25 17:11:51 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * ruby.c (proc_options): correct -T option in RUBYOPT.
- fixed: [ruby-dev:25512]
+ * ruby.c (proc_options): correct -T option in RUBYOPT. (backported
+ from CVS HEAD)
Tue Jan 25 14:05:52 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -24115,17 +12837,31 @@ Tue Jan 25 14:05:52 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/tkHTML/ss.rb: local variable scope bug fix
[ruby-dev:25479]
-Mon Jan 24 16:00:53 2005 NARUSE, Yui <naruse@ruby-lang.org>
+Mon Jan 24 15:44:25 2005 Tilman Sauerbeck <tilman@code-monkey.de>
- * ext/nkf/lib/kconv.rb (guess_old): not use NKF.guess_old
- but NKF.guess1. fixed: [ruby-dev:25491]
+ * lib/rdoc/parsers/parse_c.rb: allow whitespace after function names.
+ [ruby-core:4296]
+
+ * lib/rdoc/parsers/parse_simple.rb: adds support for private comments
+ in the "simple" parser. [ruby-core:4301]
+
+Mon Jan 24 15:44:25 2005 Charles Mills <cmills@freeshell.org>
+
+ * lib/rdoc/parsers/parse_c.rb: adds support for constants
+ (rb_define_const), accessors (rb_define_attr), and makes a
+ couple fixes. [ruby-core:4307]
+
+Mon Jan 24 15:44:25 2005 Florian Gro <florgro@gmail.com>
+
+ * lib/rdoc/parsers/parse_rb.rb: Logic for def Builtin.method() end
+ [ruby-core:4302]
Mon Jan 24 15:44:25 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
-Sun Jan 23 12:38:01 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Sun Jan 23 12:41:16 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/soap/wsdlDriver.rb: from 1.5.3-ruby1.8.2, operation which has
capitalized name (such as KeywordSearchRequest in AWS) is defined as
@@ -24141,62 +12877,65 @@ Sun Jan 23 05:24:42 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ocsp.c (ossl_ocspreq_to_der): should call
GetOCSPReq at first.
-Sat Jan 22 22:59:08 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Jan 22 23:09:47 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/ssl.rb (accept): rescue SSLError. [druby-ja:110]
-Sat Jan 22 22:27:28 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Jan 22 22:35:03 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/unix.rb: fail if UNIXFileOwner is set. [druby-ja:111]
+Fri Jan 21 23:58:42 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/stringio/stringio.c (strio_set_pos): clear EOF flag.
+ [ruby-talk:127511]
+
Fri Jan 21 20:07:02 2005 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb (Resolv::DNS::Config.resolv): don't raise ResolvError.
reported by Sam Roberts. [ruby-talk:127133]
-Fri Jan 21 17:09:44 2005 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb (decode_utf7): use pack("U*") to encode UTF-8.
-
- * lib/net/imap.rb (encode_utf7): use unpack("U*") to decode UTF-8.
-
- * test/net/imap/test_imap.rb: added tests for Net::IMAP.
-
Fri Jan 21 16:58:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (rb_push_glob): should work for NUL delimited patterns.
- * dir.c (rb_glob2): should aware of offset in the pattern.
-
Fri Jan 21 13:58:37 2005 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (u8tou16): fixed typo. fixed: [ruby-list:40546]
+ (backported from CVS HEAD)
+
+Fri Jan 21 09:30:16 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * rubyio.h (rb_eof_error): should mark as NORETURN. (backported
+ from CVS HEAD)
-Fri Jan 21 00:37:09 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Jan 21 00:31:36 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/syck/rubyext.c (syck_parser_bufsize_set): avoid VC++ warning
"local variable 'size' used without having been initialized".
+Thu Jan 20 19:03:24 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/extmk.rb (extmake): shouldn't set $extflags on mswin32.
+
+ * win32/Makefile.sub (LIBRUBY_SO): should use $DLDOBJS instead of
+ $EXTOBJS.
+ fixed: [ruby-core:04290] (backported from CVS HEAD)
+
Thu Jan 20 11:42:02 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_new4): should propagate taintedness.
- * env.h: rename member names in struct FRAME; last_func -> callee,
- orig_func -> this_func, last_class -> this_class.
-
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
-Thu Jan 20 02:01:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (Init_Object): remove rb_obj_id_obsolete()
-
-Wed Jan 19 18:02:19 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Jan 19 18:06:40 2005 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/ipaddr.rb (to_s, test_to_s): too many colons with some cases.
+ (backported from CVS HEAD)
Wed Jan 19 01:16:30 2005 Tanaka Akira <akr@m17n.org>
@@ -24204,6 +12943,32 @@ Wed Jan 19 01:16:30 2005 Tanaka Akira <akr@m17n.org>
domain and search directive without an argument.
reported by Sam Roberts. [ruby-talk:126781]
+Tue Jan 18 15:03:05 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/ssl.rb (WEBrick::Config::SSL): the default value
+ of :SSLEnable is false.
+
+ * lib/webrick/server.rb (WEBrick::Daemon.start): prepared stdio
+ don't allow changing its mode.
+
+ * lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_service):
+ should delete trailing LF from the result of pack("m*").
+
+ * lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect):
+ - should delete trailing LF from the result of pack("m*").
+ - clear Request-Line not to send the response by HTTPServer#run.
+
+ * lib/webrick/httputils (WEBrick::HTTPUtils.parse_qvalues):
+ refine regexp (and change the name of a local variable).
+
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils#escape_path): add
+ new method to escape URI path component.
+
+ * lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line): should
+ escape SCRIPT_NAME and PATH_INFO before being parsed as a URI.
+
+ * test/webrick/*, sample/webrick/httpproxy.rb: add new file.
+
Mon Jan 17 23:33:46 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (aix): fix typo. [ruby-talk:126401]
@@ -24232,63 +12997,48 @@ Sat Jan 15 14:57:22 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (proc_options): ignore trailing CRs at the end of short
options as well as long options. fixed: [ruby-core:04232]
-Sat Jan 15 13:44:22 2005 Kouhei Sutou <kou@cozmixng.org>
+Sat Jan 15 13:35:16 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb (RSS::VERSION): 0.1.2 -> 0.1.3.
* lib/rss/rss.rb: accept inheritance. [ruby-talk:126104]
-Wed Jan 12 12:29:28 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_mod_define_method): incomplete subclass check.
- [ruby-dev:25464]
+Thu Jan 13 04:48:53 2005 Tanaka Akira <akr@m17n.org>
- * class.c (rb_make_metaclass): class of metaclasses should be
- plain Class. [ruby-list:40524]
+ * io.c (io_fread): don't warn nonblocking behavior by default.
-Tue Jan 11 20:58:52 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 12 00:36:29 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (remain_size): use buffered data instead of unreading to avoid
- inconsistency of text mode. fixed: [ruby-dev:25446]
+ * object.c (rb_class_superclass): superclass of singleton class also
+ should be a singleton class. fixed: [ruby-list:40519]
-Tue Jan 11 09:37:53 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Jan 11 09:44:40 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* numeric.c (Init_Numeric): turn off floating point exceptions
on bcc32. "1e300".to_f had crashed by overflow.
-Mon Jan 10 15:28:51 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Jan 11 03:10:10 2005 Minero Aoki <aamine@loveruby.net>
- * lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line): should
- escape SCRIPT_NAME and PATH_INFO before being parsed as a URI.
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils#escape_path): add
- new method to escape URI path component.
+ * lib/fileutils.rb (copy_entry): could not copy symbolic link.
+ [ruby-talk:125733]
- * lib/webrick/ssl.rb (WEBrick::Config::SSL): the default value
- of :SSLEnable is false.
+ * lib/fileutils.rb (copy_stream): use read/write instead of
+ sysread/syswrite.
- * test/webrick/{test_cgi.rb,webrick.cgi}: new file.
+Mon Jan 10 23:08:15 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * test/webrick/utils.rb: require "webrick/https.h".
+ * variable.c (rb_autoload): hide internal data from ruby level.
+ fixed: [ruby-dev:25435], [ruby-list:40498]
Mon Jan 10 01:22:55 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
-Sun Jan 9 14:12:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_f_select): IO list could be altered. [ruby-dev:25312]
-
-Sun Jan 9 04:08:40 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * test/webrick/test_server.rb (test_daemon): delete an assertion
- which has possibility to fail by race condition.
+Sun Jan 9 03:12:58 2005 Tanaka Akira <akr@m17n.org>
-Sun Jan 9 03:22:46 2005 Minero Aoki <aamine@loveruby.net>
-
- * test/fileutils/test_fileutils.rb (test_copy_entry): copy_entry
- copies only file type, not mtime. [ruby-dev:25383]
+ * io.c (io_fread): warn nonblocking behavior.
+ (io_readpartial): new method IO#readpartial.
Sat Jan 8 04:38:47 2005 why the lucky stiff <why@ruby-lang.org>
@@ -24299,33 +13049,17 @@ Fri Jan 7 21:12:29 2005 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
* random.c (rand_init): use ALLOC_N instead of ALLOCA_N
[ruby-dev:25426]
-Fri Jan 7 20:01:31 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_service):
- should delete trailing LF from the result of pack("m*").
-
- * lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect):
- - should delete trailing LF from the result of pack("m*").
- - clear Request-Line not to send the response by HTTPServer#run.
-
- * lib/webrick/httputils (WEBrick::HTTPUtils.parse_qvalues):
- refine regexp (and change the name of a local variable).
-
- * lib/webrick/server.rb (WEBrick::Daemon.start): prepared stdio
- don't allow changing its mode.
-
- * test/webrick/*, sample/webrick/httpproxy.rb: add new files.
-
Fri Jan 7 18:03:35 2005 Tanaka Akira <akr@m17n.org>
* gc.c (mark_locations_array): avoid core dump with -O3.
[ruby-dev:25424]
-Thu Jan 6 20:29:18 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Jan 6 20:31:07 2005 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/zlib/zlib.c (zstream_end): should return value.
+ * ext/zlib/zlib.c (zstream_end): should return value. (backported
+ from CVS HEAD)
-Thu Jan 6 19:59:03 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Jan 6 19:55:13 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_close): didn't close socket handle.
[ruby-dev:25414]
@@ -24333,7 +13067,7 @@ Thu Jan 6 19:59:03 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.c (rb_w32_open_osfhandle): bcc32's _open_osfhandle
never set EMFILE.
-Thu Jan 6 17:22:41 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Jan 6 17:14:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* random.c (random_seed): O_NONBLOCK isn't defined on some
platforms. [ruby-dev:25417]
@@ -24347,11 +13081,6 @@ Thu Jan 6 07:58:28 2005 Dave Thomas <dave@pragprog.com>
* lib/rdoc/usage.rb (RDoc::RDoc.usage_no_exit): Allow for colons
in path names on DOS machines. (thanks to Johan Nilsson)
-Thu Jan 6 00:02:35 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/rinda/test_rinda.rb: use MockClock.sleep instead of Kernel.sleep
- [ruby-dev:25387]
-
Wed Jan 5 20:16:32 2005 Tanaka Akira <akr@m17n.org>
* random.c (limited_big_rand): didn't work if SIZEOF_BDIGITS == 2.
@@ -24359,20 +13088,22 @@ Wed Jan 5 20:16:32 2005 Tanaka Akira <akr@m17n.org>
* random.c (random_seed): refined.
-Wed Jan 5 16:39:54 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * parse.y (BITSTACK_POP): workaround for bcc32 compiler's bug.
- shift assignment operator '>>=' for __int64 in struct may
- generate collapsed code. [ruby-dev:25342]
-
- * win32/win32.[ch]: failed to compile on bcc32 (and probably wince)
- [ruby-dev:25306]
-
Wed Jan 5 12:49:39 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_initialize): Thread objects cannot be initialized
again. fixed: [ruby-core:04067]
+Wed Jan 5 10:48:16 2005 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * dir.c (dir_s_mkdir): win32 special processing doesn't need any
+ longer. (backported from CVS HEAD)
+
+ * win32/win32.[ch] (rb_w32_mkdir): new function. POSIX.1 compatible
+ interface. (backported from CVS HEAD)
+
+ * win32/win32.[ch] (rb_w32_rmdir): new function. (backported from CVS
+ HEAD)
+
Wed Jan 5 02:30:11 2005 Tanaka Akira <akr@m17n.org>
* random.c (init_by_array): imported from mt19937ar-cok.tgz.
@@ -24391,10 +13122,10 @@ Tue Jan 4 23:25:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
-Tue Jan 4 21:25:43 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Jan 4 11:15:29 2005 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
- * test/drb/{test_drbssl.rb,test_drbunix.rb,ut_drb.rb}: use
- DRbService.ext_service. reduce sleep.
+ * bignum.c (rb_big_rand): do not use rb_big_modulo to generate
+ random bignums. [ruby-dev:25396]
Mon Jan 3 14:01:54 2005 Tanaka Akira <akr@m17n.org>
@@ -24406,21 +13137,7 @@ Mon Jan 3 11:37:42 2005 Tanaka Akira <akr@m17n.org>
* random.c (random_seed): use /dev/urandom if available.
[ruby-dev:25392]
-Tue Jan 4 11:15:29 2005 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
-
- * bignum.c (rb_big_rand): do not use rb_big_modulo to generate
- random bignums. [ruby-dev:25396]
-
-Mon Jan 3 11:03:37 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/drb/test_drb.rb: move TestDRbReusePort to new file.
- [ruby-dev:25238]
-
- * test/drb/drbtest.rb: change timeout.
-
- * test/drb/ignore_test_drb.rb: new file.
-
-Mon Jan 3 07:27:46 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Jan 3 07:46:42 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpauth/htpasswd.rb (WEBrick::Htpasswd#reload):
raise NotImplementedError if password is encrypted by digest
@@ -24436,46 +13153,6 @@ Mon Jan 3 07:27:46 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/webrick/test_httpauth.rb: new file.
-Sun Jan 2 15:42:10 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb: add lazy stop_service.
-
- * lib/drb/extserv.rb: ditto.
-
-Sun Jan 2 01:17:17 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/drb/drbtest.rb: add method DRbService.ext_service.
-
- * test/drb/test_drb.rb: ditto.
-
- * test/drb/test_drbssl.rb: ditto.
-
-Sat Jan 1 20:23:02 2005 Tanaka Akira <akr@m17n.org>
-
- * io.c (argf_readpartial): new method ARGF.readpartial.
- (io_getpartial): extracted from io_readpartial.
- (io_readpartial): call io_getpartial.
-
-Sat Jan 1 17:44:54 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (each_capitalized): should join header field
- value. This patch is contributed sheepman [ruby-list:40478]
-
- * test/net/http/test_httpheader.rb: test it.
-
-Sat Jan 1 16:21:29 2005 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (copy_stream): use read/write instead of
- sysread/syswrite, which allows duck typing. [ruby-dev:25369]
-
- * lib/fileutils.rb (copy_stream): does NOT support nonblocking IO.
- [ruby-dev:25370]
-
- * lib/fileutils.rb (copy_entry): could not copy symlink.
-
- * test/fileutils/test_fileutils.rb: test copy_entry, copy_file,
- copy_stream.
-
Sat Jan 1 04:20:23 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ns_spki.c (ossl_spki_set_challenge): should call
@@ -24487,29 +13164,8 @@ Sat Jan 1 01:13:28 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
Fri Dec 31 14:10:43 2004 Dave Thomas <dave@pragprog.com>
- * lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::display_flow_item):
- Fix problem if heading contains formatting.
-
-Fri Dec 31 00:08:02 2004 Tanaka Akira <akr@m17n.org>
-
- * configure.in (HAVE_RLIM_T): removed because not used.
-
-Thu Dec 30 22:45:39 2004 Tanaka Akira <akr@m17n.org>
-
- * rubyio.h: don't deprecate rb_read_check.
-
- * io.c (STDIO_READ_DATA_PENDING): reverted from old READ_DATA_PENDING
- to check stdio read buffer.
- (rb_read_check): use STDIO_READ_DATA_PENDING.
- (rb_read_pending): ditto.
- (rb_getc): ditto.
-
-Thu Dec 30 05:39:35 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y: eliminate unused members in struct parser_params.
- [ruby-dev:25258] (again)
-
- * parse.y: make parser_new() static.
+ * lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::display_flow_item): Fix problem
+ if heading contains formatting.
Thu Dec 30 00:41:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -24527,11 +13183,6 @@ Tue Dec 28 22:31:46 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_justify): create buffer string after argument type
conversion. fixed: [ruby-dev:25341]
-Tue Dec 28 17:18:17 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/net/telnet.rb (preprocess): remove NULL unless binmode.
- fixed: [ruby-list:40320]
-
Tue Dec 28 15:41:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c (reinit): should initialize all static
@@ -24552,58 +13203,91 @@ Tue Dec 28 13:35:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/zlib/zlib.c (rb_deflate_init_copy): replace rb_deflate_clone.
+Tue Dec 28 12:26:45 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub, win32/setup.mak (RDOCTARGET, install,
+ install-nodoc, install-doc): rdoc support for mswin32.
+
+ * win32/configure.bat (--enable-install-doc, --disable-install-doc):
+ ditto.
+
Mon Dec 27 20:02:14 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: fix SEGV bug when deleting Tk interp
* ext/tk/lib/multi-tk.rb: ditto
-Mon Dec 27 16:54:05 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Dec 27 16:55:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509name.c (Init_ossl_x509name): should use
rb_hash_new to get exactly a Hash. fix [ruby-dev:25325].
-Mon Dec 27 15:29:12 2004 Minero Aoki <aamine@loveruby.net>
+Mon Dec 27 16:29:56 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_justify): [ruby-dev:25341]
- * test/fileutils/test_fileutils.rb (cp_r): tested wrong file name.
- [ruby-dev:25339]
+Mon Dec 27 15:47:48 2004 Minero Aoki <aamine@loveruby.net>
-Mon Dec 27 15:15:18 2004 Minero Aoki <aamine@loveruby.net>
+ * test/fileutils/fileasserts.rb: sync with HEAD.
+
+ * test/fileutils/test_fileutils.rb: ditto.
+
+ * test/fileutils/test_nowrite.rb: ditto.
+
+Mon Dec 27 15:21:07 2004 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (mv): should raise error when moving a
directory to the (empty) directory. [ruby-talk:124368]
+ (backport from HEAD 1.48)
* lib/fileutils.rb (mv): wrongly did not overwrite file on Win32
- platforms.
+ platforms. (backport from HEAD 1.48)
-Mon Dec 27 14:36:20 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Sat Dec 25 11:11:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * process.c (NUM2RLIM, RLIM2NUM): Without SIZEOF_RLIM_T is not error.
- fixed: [ruby-dev:25346]
+ * stable version 1.8.2 released.
-Sun Dec 26 16:21:39 2004 Shugo Maeda <shugo@ruby-lang.org>
+Sat Dec 25 04:23:49 2004 Minero Aoki <aamine@loveruby.net>
- * lib/net/imap.rb (Net::IMAP::PlainAuthenticator): added a new class
- to support the PLAIN authentication mechanism. Thanks, Benjamin
- Stiglitz.
+ * lib/fileutils.rb (mkdir, mkdir_p): should ensure directory
+ permission. (backportted from HEAD, 1.47)
+
+ * lib/fileutils.rb (traverse, remove_dir): untaint trasted
+ objects. (backportted from HEAD, 1.46)
Sat Dec 25 01:28:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_f_select): [ruby-dev:25312]
+ * io.c: cancel io_reopen() change on Dec. 24th.
+
+ * dln.c: use <dlfcn.h> for NetBSD. [ruby-dev:25313]
+
+ * io.c (rb_f_select): IO list could be altered. [ruby-dev:25312]
+
+Fri Dec 24 23:51:48 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * bcc32/Makefile.sub: bcc32 should use RTL dll (backport from HEAD)
+ [ruby-dev:25306]
+
+ * win32/win32.[ch]: ditto.
Fri Dec 24 23:27:18 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/image.rb: TkPhotoImage#cget bug fix
-Fri Dec 24 03:06:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Dec 24 18:39:25 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * win32/win32.[ch]: failed to compile on bcc32 (and probably wince)
+ [ruby-dev:25306]
+
+Fri Dec 24 02:52:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (io_reopen, rb_io_reopen): prohibit to change access mode for
special IO ports. [ruby-dev:25225]
- * io.c (next_argv): reduce use of stdio.
-
Fri Dec 24 02:22:53 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/syck/rubyext.c (rb_syck_io_str_read): [ruby-core:03973]
+
* ext/syck/rubyext.c (syck_loader_transfer): check type conversion.
* ext/syck/rubyext.c (syck_parser_assign_io, rb_new_syck_node): duck
@@ -24623,20 +13307,11 @@ Fri Dec 24 01:21:00 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/blt/tile/*.rb: ditto
-Thu Dec 23 23:43:24 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Dec 23 23:36:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * process.c (proc_setgroups): check if the argument length is
+ * process.c (proc_setgroups): check if the argument lenght is
modified. fixed: [ruby-dev:25285]
- * process.c (SIZEOF_RLIM_T): err if size of rlim_t is not set.
-
-Thu Dec 23 19:08:41 2004 Tanaka Akira <akr@m17n.org>
-
- * rubyio.h: rename FMODE_UNSEEKABLE to FMODE_DUPLEX.
-
- * io.c (io_check_tty): extracted function to set FMODE_LINEBUF and
- FMODE_DUPLEX.
-
Thu Dec 23 13:13:33 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: define TclTkLib::COMPILE_INFO and
@@ -24648,6 +13323,10 @@ Thu Dec 23 13:13:33 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: define Tk::RELEASE_DATE
+Thu Dec 23 09:38:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_reopen): restore exact mode. fixed: [ruby-core:04003]
+
Thu Dec 23 00:16:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (bsdi): use $(CC) for LDSHARED. fixed [ruby-dev:25270]
@@ -24662,49 +13341,41 @@ Wed Dec 22 08:34:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/dl/sym.c (rb_dlsym_initialize): extract internal pointers after
all argument conversion. fixed: [ruby-dev:25271]
-Tue Dec 21 16:15:21 2004 Michael Neumann <mneumann@ruby-lang.org>
-
- * lib/xmlrpc/client.rb: use "" instead of "." if prefix argument is
- nil in proxy methods. nil is default value.
-
- * test/xmlrpc/test_webrick_server.rb, test/xmlrpc/webrick_testing.rb:
- use threads instead of forking. this should fix issue #1208
- (http://rubyforge.org/tracker/?func=detail&atid=1698&aid=1208&group_id=426).
- removed testing of SSL enabled servlet as this hangs.
-
-Wed Dec 22 00:05:10 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Wed Dec 22 00:08:01 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/soap/*, test/soap/*, sample/soap/authheader/*: eval cleanup.
-Tue Dec 21 22:07:41 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_asn1.c (ossl_asn1_decode_all): use rb_str_new4
- to avoid SEGV.
+Tue Dec 21 22:07:33 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode,
ossl_asn1_decode_all): temporary value should be marked volatile.
-Tue Dec 21 12:42:34 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Dec 21 14:40:02 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode):
- use rb_str_new4 to avoid SEGV. fix [ruby-dev:25261]
+ * ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode,
+ ossl_asn1_decode_all): use rb_str_new4 to avoid SEGV.
+ fix [ruby-dev:25261]
* test/openssl/test_asn1.rb: add tests for OpenSSL::ASN1.
+Tue Dec 21 12:22:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_reopen): keep duplex pipe in correct mode for exception
+ safeness. fixed: [ruby-dev:25152]
+
Tue Dec 21 12:10:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/grid.rb: rescue bug of 'grid configure' on Tcl/Tk8.3-
-Mon Dec 20 22:52:29 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Tue Dec 21 00:53:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * added samples for the previous soap4r's commit.
+ * ext/openssl/ossl_asn1.c (ossl_asn1_traverse): [ruby-dev:25261]
-Mon Dec 20 22:56:39 2004 Tanaka Akira <akr@m17n.org>
+ * ext/openssl/ossl_asn1.c (ossl_asn1_decode): ditto.
- * gc.c (set_stack_end): gcc noinline attribute is available since
- gcc-3.1.
+ * ext/openssl/ossl_asn1.c (ossl_asn1_decode_all): ditto.
-Mon Dec 20 22:40:31 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Mon Dec 20 23:22:26 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* added files:
* lib/soap/mapping/wsdl*.rb
@@ -24718,6 +13389,8 @@ Mon Dec 20 22:40:31 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/soap/*
* test/wsdl/*
* test/xsd/*
+ * sample/soap/*
+ * sample/sdl/*
* summary
* imported from the soap4r repository. Version: 1.5.3-ruby1.8.2
@@ -24731,14 +13404,12 @@ Mon Dec 20 22:40:31 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* HTTP client/server gzipped content encoding support.
* improved WSDL schema definition support; still is far from
- complete, but is making step by step improvement.
-
-Mon Dec 20 14:45:19 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ complete, but is making step by step improovement.
- * lib/net/https.rb: delete descriptions about key_file and cert_file.
- fixed: [ruby-dev:25243]
+Mon Dec 20 22:56:39 2004 Tanaka Akira <akr@m17n.org>
- * ext/openssl/lib/net/telnets.rb: ditto.
+ * gc.c (stack_end_address): gcc noinline attribute is available since
+ gcc-3.1.
Mon Dec 20 14:07:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -24750,14 +13421,21 @@ Mon Dec 20 14:07:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/panedwindow.rb: ditto
-Mon Dec 20 13:51:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Dec 20 12:47:13 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/lib/net/https.rb,protocols.rb,telnets.rb: delete
+ doc and code about SSLContext#{key_file,cert_file}.
+ fixed: [ruby-dev:25243]
+
+Mon Dec 20 12:42:17 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
+ * io.c (io_fwrite): workaround for MSVCRT's bug.
+ fixed: [ruby-core:03982]
-Mon Dec 20 10:51:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Dec 20 11:21:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (special_local_set): prevent the parser object from GC.
- fixed: [ruby-dev:25252]
+ * io.c (rb_io_eof): check if closed before clearerr().
+ fixed: [ruby-dev:25251]
Mon Dec 20 03:30:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -24768,10 +13446,40 @@ Mon Dec 20 01:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* struct.c (make_struct): [ruby-dev:25249]
-Mon Dec 20 00:16:54 2004 Kouhei Sutou <kou@cozmixng.org>
+Mon Dec 20 00:28:20 2004 Kouhei Sutou <kou@cozmixng.org>
- * lib/rexml/encodings/SHIFT_JIS.rb: fixed LoadError bug.
- [ruby-core:3958]
+ * lib/rexml/encodings/SHIFT-JIS.rb: backported from CVS HEAD.
+
+ * lib/rexml/encodings/SHIFT_JIS.rb: ditto.
+
+Sun Dec 19 17:19:48 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_x509store.c
+ (ossl_x509store_set_time): add OpenSSL::X509::Store#time=.
+ (ossl_x509stctx_set_time): add OpenSSL::X509::StoreContext#time=.
+
+ * test/openssl/ossl_x509store.rb: test certificate validity times.
+
+ * ext/openssl/ossl_x509name.c (ossl_x509name_to_s): add optional
+ second argument to specify the output format (see also
+ X509_NAME_print_ex).
+
+ * ext/openssl/ossl_x509name.c (ossl_x509name_init): new constants:
+ OpenSSL::X509::Name::COMPAT, OpenSSL::X509::Name::RFC2253,
+ OpenSSL::X509::ONELINE, OpenSSL::X509::MULTILINE.
+
+ * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name::RFC2253DN):
+ new module to provide the parse for RFC2253 DN format.
+
+ * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name.parse_rfc2253):
+ new method to parse RFC2253 DN format.
+
+ * test/openssl/ossl_x509name.rb: add tests about RFC2253 DN.
+
+ * text/openssl/ssl_server.rb: try to listen ports from 20443 to 20542
+ while EADDRINUSE is raised.
+
+ * all changes in this entry are backport from 1.9.
Sun Dec 19 17:24:59 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -24793,7 +13501,7 @@ Sat Dec 18 16:36:23 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/zlib/zlib.c (rb_deflate_s_deflate, rb_inflate_s_inflate):
disallow interrupt by type conversion. fixed: [ruby-dev:25226]
-Sat Dec 18 15:09:02 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Sat Dec 18 15:16:41 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/webrick/httpauth.rb,
lib/webrick/httpauth/{basicauth.rb,digestauth.rb}: use
@@ -24804,12 +13512,10 @@ Sat Dec 18 10:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
- * io.c (rb_f_open): add type check for return value from to_open.
-
-Fri Dec 17 16:44:26 2004 Tanaka Akira <akr@m17n.org>
+Fri Dec 17 18:07:01 2004 Shugo Maeda <shugo@ruby-lang.org>
- * configure.in (ac_cv_sizeof_rlim_t): set 8 for BSD/OS.
- Reported by OHARA Shigeki. [ruby-dev:25236]
+ * test/readline/test_readline.rb: fix for BSD. Thanks, GOTOU Yuuzou.
+ fixed: [ruby-dev:25218]
Fri Dec 17 16:28:12 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -24847,27 +13553,45 @@ Fri Dec 17 16:28:12 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/textwindow.rb: wrong gravity of text mark for
embedded window
+Fri Dec 17 13:50:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
+
+ * vms/vmsruby_private.c, vms/vmsruby_private.h: private routines
+ for VMS port are added.
+
+ * eval.c (ruby_init): change to call VMS private intialization routine.
+
Fri Dec 17 13:33:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session#initialize): control adding
session_id hidden fields. fixed: [ruby-talk:123850]
-Fri Dec 17 00:01:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Dec 16 23:25:25 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * eval.c (rb_proc_arity, rb_node_arity, rb_mod_method_arity,
- rb_obj_method_arity): new functions to obtain method arity.
- [ruby-dev:25143]
+ * lib/drb/drb.rb, lib/drb/ssl.rb: backported from CVS HEAD.
+ [druby-ja:101]
-Thu Dec 16 23:31:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * test/drb/test_drb.rb: adjust and reduce sleep (backported from
+ CVS HEAD.)
- * lib/mkmf.rb (create_makefile): create RUBYARCHDIR also when no extension
- is installed. fixed: [ruby-dev:25215]
+Thu Dec 16 18:44:58 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Thu Dec 16 22:36:57 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should wait
+ for reading request till data arrive. [ruby-talk:121068]
+
+ * lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
+ should log about all accepted socket. [ruby-core:03962]
- * test/drb/test_drb.rb: adjust and reduce sleep.
+ * lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params):
+ "%%" and "%u" are supported. [webricken:135]
+
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::FileHandler#check_filename):
+ :NondisclosureName is acceptable if it is Enumerable.
+
+ * lib/webrick/config.rb (WEBrick::Config::FileHandler):
+ default value of :NondisclosureName is [".ht*", "*~"].
-Thu Dec 16 18:37:08 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Dec 16 18:36:52 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl.c (ossl_raise): refine message format.
@@ -24906,64 +13630,55 @@ Thu Dec 16 16:03:50 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: ditto
-Thu Dec 16 04:02:28 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/extconf.rb: bison is not needed if ripper.c exists.
- [ruby-dev:25191]
-
-Thu Dec 16 03:27:10 2004 Minero Aoki <aamine@loveruby.net>
+Thu Dec 16 03:14:28 2004 Minero Aoki <aamine@loveruby.net>
- * lib/net/http.rb: remove junk.
+ * lib/net/http.rb (basic_encode): return value of pack('m') may
+ include multiple CR/LFs. Backported from main trunk (rev 1.112).
+ [ruby-dev:25212]
-Thu Dec 16 00:57:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Dec 16 00:33:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/syck/rubyext.c (rb_syck_io_str_read): [ruby-core:03973]
+ * hash.c (Init_Hash): remove custom "hash" and "eql?".
-Thu Dec 16 00:43:29 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Dec 15 18:57:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/drb/drb.rb: changed default binded address family to use an
- available address family of host name. [druby-ja:101]
+ * lib/set.rb (Set::eql): wrong definition. [ruby-dev:25207]
- * lib/drb/ssl.rb: ditto
+Wed Dec 15 18:48:42 2004 Shugo Maeda <shugo@ruby-lang.org>
-Wed Dec 15 17:47:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * ext/curses/curses.c (window_subwin): call NUM2INT() before
+ GetWINDOW(). (backported from CVS HEAD)
- * lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
- should log about all accepted socket. [ruby-core:03962]
+Wed Dec 15 17:03:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params):
- "%%" and "%u" are supported. [webricken:135]
+ * win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
+ isatty because it never sets errno. (backported from CVS HEAD)
- * lib/webrick/httpservlet/filehandler.rb
- (WEBrick::HTTPServlet::FileHandler#check_filename):
- :NondisclosureName is acceptable if it is Enumerable.
+Wed Dec 15 15:39:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * lib/webrick/config.rb (WEBrick::Config::FileHandler):
- default value of :NondisclosureName is [".ht*", "*~"].
+ * ext/openssl/ossl_x509name.c (ossl_x509name_to_a): avoid SEGV
+ (rollback the previous commit).
Wed Dec 15 16:10:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_obj_id_obsolete): warn always.
+ * eval.c (rb_enable_super): ditto.
+
Wed Dec 15 15:31:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/set.rb (Set#==): [ruby-dev:25206]
-Wed Dec 15 14:32:18 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Dec 15 14:22:10 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_fdisset): check whether the handle is valid.
+ fixed: [ruby-core:03959]
Wed Dec 15 10:30:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/openssl/ossl_digest.c (ossl_digest_initialize): [ruby-dev:25198]
-Tue Dec 14 19:17:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * utf8.c (utf8_is_mbc_ambiguous): [ruby-talk:123561]
-
- * utf8.c (utf8_mbc_to_normalize): ditto.
-
-Tue Dec 14 17:08:15 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Dec 14 17:10:09 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_close): need to reset osfhnd().
@@ -24977,36 +13692,27 @@ Tue Dec 14 12:36:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::initialize): generate new
session if given session_id does not exist. [ruby-list:40368]
-Tue Dec 14 08:47:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (Init_eval): should mark ruby_eval_tree. [ruby-dev:25189]
-
Mon Dec 13 18:13:52 2004 Tanaka Akira <akr@m17n.org>
- * gc.c (set_stack_end): new function to obtain stack end address.
- set_stack_end obtains a stack end address by an address of local
- variable in the function.
- (SET_STACK_END, STACK_END): use set_stack_end. don't use alloca.
+ * gc.c (stack_end_address): new function to obtain stack end address.
+ stack_end_address calls __builtin_frame_address(0) to obtain the
+ frame pointer of a stack frame of stack_end_address. The address
+ is the stack pointer of the caller's stack frame.
+ (SET_STACK_END): use stack_end_address.
This makes the conservative garbage collector to scan a stack frame
of the garbage_collect function itself. This is required because
callee-save registers may be stored in the frame.
[ruby-dev:25158]
-Mon Dec 13 02:45:51 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/curses/curses.c (window_subwin): call NUM2INT() before
- GetWINDOW(). fixed: [ruby-dev:25161]
-
Mon Dec 13 00:58:02 2004 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb (cleanpath_aggressive): make it private.
(cleanpath_conservative): ditto.
Suggested by Daniel Berger. [ruby-core:3914]
-Sun Dec 12 21:32:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Dec 12 20:06:38 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * test/ruby/test_super.rb (TestSuper#test_define_method): now methods
- from procs can call super.
+ * lib/drb/drb.rb: backported from CVS HEAD.
Sun Dec 12 10:35:10 2004 Dave Thomas <dave@pragprog.com>
@@ -25018,7 +13724,14 @@ Sun Dec 12 10:14:03 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/rdoc.rb (RDoc::RDoc::parse_files): Never exclude files
explicitly given on the command line.
-Sat Dec 11 21:10:16 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Dec 11 23:54:07 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/*: update to support libraries in ActiveTcl8.4.12.0
+ (see ext/tk/ChangeLog.tkextlib).
+
+ * ext/tk/sample/scrollframe.rb: add a new sample.
+
+Sat Dec 11 20:12:21 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: add DRbRemoteError. [ruby-list:40348],
[ruby-list:40390]
@@ -25027,27 +13740,41 @@ Sat Dec 11 21:10:16 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/ut_drb.rb: ditto.
-Sat Dec 11 13:08:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Dec 11 15:38:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/jcode.rb (String::succ): [ruby-dev:25156]
+
+Sat Dec 11 12:41:55 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * eval.c (run_trap_eval): prototype; avoid VC++ warnings.
+
+ * ext/socket/getaddrinfo.c: fix typo. fixed: [ruby-core:03947]
- * sample/optparse/subcommand.rb: a sample for sub commands like
- cvs. contributed by Minero Aoki.
+ * win32/win32.c: need to include dln.h.
-Fri Dec 10 08:39:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Dec 11 00:10:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_reopen): [ruby-dev:25150]
+
+Fri Dec 10 08:39:27 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/socket.c (sock_listen): get OpenFile just before calling
- listen(2).
+ listen(2). fixed: [ruby-dev:25149]
-Thu Dec 9 16:28:35 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Dec 9 17:00:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
- * ext/sdbm/init.c (GetDBM): typo.
+ * ext/socket/socket.c, ext/socket/getaddrinfo.c: port to VMS
-Thu Dec 9 16:21:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Dec 9 16:31:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/webrick/cgi.rb (WEBrick::CGI#setup_header): avoid
- SecurityError. [ruby-dev:24970]
+ * ext/sdbm/init.c (GetDBM): typo.
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should wait
- for reading request till data arrive. [ruby-talk:121068]
+Thu Dec 9 16:05:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
+
+ * defines.h: change path of vms.h
+ * vms/vms.h: delete reference for snprintf()
+ * vms/config.h: new file
+ * vms/config.h_in: deleted
Thu Dec 9 14:38:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -25056,10 +13783,6 @@ Thu Dec 9 14:38:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_dump): not escape # which isn't a substitution.
-Thu Dec 9 12:31:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * io.c (pipe_open): should set prog if argc != 0.
-
Thu Dec 9 10:54:36 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/dbm/dbm.c (fdbm_select): [ruby-dev:25132]
@@ -25068,11 +13791,6 @@ Thu Dec 9 10:54:36 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/gdbm/gdbm.c: ditto.
-Thu Dec 9 10:19:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/socket/test_socket.rb (test_setsockopt): use SO_LINGER instead
- of SO_BINDTODEVICE. fixed: [ruby-dev:25133]
-
Thu Dec 9 03:08:36 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c (ip_init): set root-win title to "ruby" when
@@ -25127,174 +13845,44 @@ Wed Dec 8 23:54:29 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/template/html/html.rb (RDoc::Page): Typo
meant that h2 tag was invisible.
-Wed Dec 8 22:10:02 2004 Tanaka Akira <akr@m17n.org>
-
- * rubyio.h, io.c, ext/dl/dl.c, ext/pty/pty.c, ext/socket/socket.c:
- create FILE object only when required: popen(3) and DL's IO#to_ptr.
- [ruby-dev:25122]
-
- * io.c (rb_io_binmode): use setmode for Human68k. [ruby-dev:25121]
-
-Wed Dec 8 20:13:06 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * process.c (rb_spawn): support for DJGPP.
-
- * lib/mkmf.rb (VPATH): specify the implicit path separator for DJGPP.
-
-Wed Dec 8 17:48:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): merge Guy Decoux's argument preserve
- patch in [ruby-core:03874].
+Wed Dec 8 21:56:31 2004 Kouhei Sutou <kou@cozmixng.org>
-Wed Dec 8 17:37:33 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_pipe_exec): need to close original socket
- handle.
+ * lib/rss, test/rss, sample/rss: backported from CVS HEAD.
Wed Dec 8 14:31:36 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sprintf.c (rb_f_sprintf): [ruby-dev:25104]
-
-Wed Dec 8 13:49:46 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_pipe_exec): must close original handle
- before exec. fixed: [ruby-dev:25112]
-
-Wed Dec 8 11:46:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (string_content): get rid of segfault at empty evstr.
- fixed: [ruby-dev:25113]
-
-Wed Dec 8 03:26:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_bio.c (ossl_obj2bio): should not use fptr->f.
- [ruby-dev:25101]
-
-Wed Dec 8 03:26:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * runruby.rb: prepend LIBRUBY_SO to LD_PRELOAD as well as rubytest.rb.
-
-Wed Dec 8 01:35:44 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (is_socket): reorder of function definitions.
-
-Wed Dec 8 00:44:31 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (pipe_open): win32 bidirectional pipe support.
-
- * win32/win32.[ch] (rb_w32_pipe_exec): ditto.
-
- * win32/win32.[ch] (socketpair): new function. POSIX socketpair
- emulation.
-
- * win32/win32.c (socketpair_internal): ditto.
-
-Wed Dec 8 00:25:07 2004 Kouhei Sutou <kou@cozmixng.org>
+ * io.c (io_fwrite): change dereference for cosmetic reason.
- * test/rss/test_version.rb: added version check test.
- [ruby-dev:25053]
-
-Tue Dec 7 15:40:38 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c (io_fwrite): avoid context switch before writing to stderr.
- [ruby-dev:25080]
-
- * rubyio.h: refine deprecated declaration.
-
- * configure.in, file.c, io.c: remove useless check: fseeko, etc.
-
-Tue Dec 7 13:42:07 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * dir.c (dir_s_mkdir): win32 special processing doesn't need any
- longer.
+ * sprintf.c (rb_f_sprintf): [ruby-dev:25104]
- * win32/win32.[ch] (rb_w32_mkdir): new function. POSIX.1 compatible
- interface.
+Tue Dec 7 19:08:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
- * win32/win32.[ch] (rb_w32_rmdir): new function.
+ * io.c (io_fwrite): fix offset incrementation (for VMS and Human68k)
Tue Dec 7 00:27:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (proc_setgroups): [ruby-dev:25081]
-Mon Dec 6 23:07:57 2004 Tanaka Akira <akr@m17n.org>
-
- * configure.in: check -lsocket for socketpair and shutdown.
- reported by Ville Mattila. [ruby-core:03903]
-
-Mon Dec 6 23:00:45 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in (ac_cv_sizeof_rlim_t): setup for DJGPP.
-
- * io.c (is_socket, shutdown): define dummy macros for DJGPP.
-
- * process.c: use SIZEOF_RLIM_T instead of HAVE_RLIM_T for DJGPP.
-
-Mon Dec 6 21:19:40 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (is_socket): fix typos. [ruby-core:03900]
-
-Mon Dec 6 20:13:28 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (is_socket): new function.
-
- * io.c (rb_io_close_read, rb_io_close_write): use is_socket().
-
- * io.c (rb_io_fptr_finalize): need to check fptr->f before calling
- rb_io_fptr_cleanup().
-
- * io.c (pipe_open): win32 pipe support (experimental).
-
- * win32/win32.[ch] (rb_w32_pipe_exec): return file descriptors
- instead of FILE structure objects.
-
- * win32/win32.[ch] (rb_w32_is_socket): new function.
-
-Mon Dec 6 19:40:40 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * Makefile.in (.y.c): simplify the rule.
-
Mon Dec 6 18:08:10 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (rb_reg_eqq): document fix. [ruby-talk:122541]
-Mon Dec 6 17:49:30 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Dec 6 17:19:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (run_trap_eval): add prototype for Microsoft compiler.
+ * rubysig.h (TRAP_BEG, TRAP_END): safe errno around CHECK_INTS.
+ (backported from CVS HEAD) [ruby-dev:24993]
-Mon Dec 6 17:32:38 2004 Tanaka Akira <akr@m17n.org>
+Mon Dec 6 10:18:17 2004 Dave Thomas <dave@pragprog.com>
- * rubyio.h, intern.h, io.c, file.c, process.c, ext/socket/socket.c,
- ext/pty/pty.c, ext/io/wait/wait.c, ext/openssl/ossl_ssl.c:
- Use own buffering mechanism instead of stdio. [ruby-dev:25056]
-
- * io.c, ext/stringio/stringio.c, test/ruby/ut_eof.rb:
- EOF flag removed.
-
-Mon Dec 6 17:15:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/socket/test_socket.rb (TestBasicSocket#test_setsockopt):
- BasicSocket#setsockopt dumps core. [ruby-dev:25039]
-
- * test/socket/test_tcp.rb (TestTCPSocket#test_recvfrom):
- TCPSocket#recvfrom dumps core. [ruby-dev:24705]
-
- * test/socket/test_udp.rb (TestUDPSocket#test_connect):
- UDPSocket#connect dumps core. [ruby-dev:25045]
-
- * test/socket/test_udp.rb (TestUDPSocket#test_bind):
- UDPSocket#bind dumps core. [ruby-dev:25057]
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::look_for_directives_in):
+ Oops - 1.8 doesn't have String#clear
Mon Dec 6 09:59:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (io_fread): take VALUE argument.
-
* ext/socket/socket.c (sock_connect): use rb_str_new4().
[ruby-dev:25052]
- * eval.c (rb_yield_0): [ruby-dev:25051]
-
-Mon Dec 6 01:32:31 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Dec 6 01:42:08 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_pkey_rsa.c (ossl_rsa_public_encrypt,
ossl_rsa_public_decrypt, ossl_rsa_private_encrypt,
@@ -25315,11 +13903,6 @@ Sun Dec 5 19:39:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser#order!): ignore case only for long
option. [ruby-dev:25048]
-Sun Dec 5 00:54:32 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * mkconfig.rb: setup library paths before requiring library.
- [ruby-core:03892]
-
Sat Dec 4 22:54:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (io_write): remove rb_str_locktmp(). [ruby-dev:25050]
@@ -25343,29 +13926,10 @@ Sat Dec 4 22:54:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (rb_hash_hash): should provide "hash" method where "eql?"
is redefined. [ruby-talk:122482]
-Sat Dec 4 21:29:05 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb: (In previous commit) new method chown.
-
- * lib/fileutils.rb: (In previous commit) new method chown_R.
-
- * lib/fileutils.rb: (In previous commit) new method chmod_R
- wrongly added. Removed now.
-
-Sat Dec 4 20:45:52 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (mkdir, mkdir_p): should chmod explicitly.
- [ruby-core:03881]
-
-Sat Dec 4 18:54:09 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: removed empty lines from output.
-
-Sat Dec 4 18:49:09 2004 Kouhei Sutou <kou@cozmixng.org>
+Sat Dec 4 14:54:52 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * lib/rss/rss.rb (RSS::VERSION): 0.1.1 -> 0.1.2
-
- * lib/rss/rss.rb: #item=/#set_item and so on are obsolete.
+ * eval.c (proc_invoke): use volatile `tmp' rather than `args'.
+ [ruby-core:03882]
Sat Dec 4 14:28:56 2004 Dave Thomas <dave@pragprog.com>
@@ -25379,13 +13943,48 @@ Sat Dec 4 14:28:56 2004 Dave Thomas <dave@pragprog.com>
The lines before :section: are removed, and identical lines at the end are
also removed if present.
+Sat Dec 4 03:33:45 2004 Shugo Maeda <shugo@ruby-lang.org>
+
+ * ext/readline/readline.c: check $SAFE. (backported from CVS HEAD)
+
+ * test/readline/test_readline.rb: added tests for readline.
+ (backported from CVS HEAD)
+
+Sat Dec 4 02:24:00 2004 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/nkf/nkf.c: add constant NKF::VERSION
+
+ * ext/nkf/nkf.c(guess): this becomes an alias of guess2
+
+ * ext/nkf/test.rb(mime_out2): add --no-cp932
+
+ * ext/nkf/nkf-utf8/nkf.c: original nkf2 revision 1.47
+
Sat Dec 4 00:35:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039]
-Fri Dec 3 12:25:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Dec 3 18:57:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/ostruct.rb: 1.9 marshaling support back-ported.
+ [ruby-core:03871]
- * st.h: fix prototype for C++.
+Fri Dec 3 13:45:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_invoke): copy arguments to frame.argv.
+ [ruby-core:03861]
+
+Fri Dec 3 12:25:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * st.h: fix prototypes.
+
+Fri Dec 3 00:21:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (convert_type): use rb_respond_to() again.
+ [ruby-dev:25021]
+
+ * eval.c (rb_respond_to): funcall respond_to? if it's redefined.
+ [ruby-dev:25021]
Fri Dec 3 01:55:24 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -25405,25 +14004,6 @@ Fri Dec 3 01:55:24 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/demos-jp/widget: ditto.
-Fri Dec 3 00:21:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): prepare to pass a block from "call" method
- to a Proc generated by Method#to_proc. [ruby-dev:25031]
-
- * eval.c (rb_yield_0): actually passes a block given to "call".
-
- * object.c (convert_type): use rb_respond_to() again. this fix is
- based on [ruby-dev:25021]
-
- * eval.c (rb_respond_to): funcall respond_to? if it's redefined.
- [ruby-dev:25021]
-
-Thu Dec 2 15:13:53 2004 Michael Neumann <mneumann@ruby-lang.org>
-
- * test/xmlrpc/test_parser.rb, test/xmlrpc/data/*.expected: Expected
- values are now stored in YAML instead of using #inspect. This fixes
- false hash order.
-
Fri Dec 3 00:11:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_file_initialize): [ruby-dev:25032]
@@ -25436,16 +14016,12 @@ Thu Dec 2 16:41:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_callcc, rb_cont_call): prohibit calling from different
signal contexts. [ruby-dev:25022]
-Thu Dec 2 10:45:02 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * test/readline/test_readline.rb: fix for NetBSD.
-
Thu Dec 2 09:57:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/ostruct.rb (OpenStruct::Marshaler): OpenStruct can be
marshaled again. [ruby-core:03862]
-Thu Dec 2 09:30:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Dec 2 09:30:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (thread_mark): mark thread group. [ruby-dev:25020]
@@ -25455,56 +14031,35 @@ Thu Dec 2 07:57:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_ctl): [ruby-dev:25019]
-Wed Dec 1 06:13:00 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf.c: add constant NKF::VERSION
-
- * ext/nkf/nkf.c(guess): this becomes an alias of guess2
-
- * ext/nkf/test.rb: add --no-cp932
-
- * ext/nkf/nkf-utf8/nkf.c: original nkf2 revision 1.47
-
Wed Dec 1 02:21:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* signal.c (sighandler): call handler immediately only for default
handlers. [ruby-dev:25003]
-Tue Nov 30 23:49:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (pipe_open): errno should be preserved for rb_sys_fail() when
- fork failed.
-
-Tue Nov 30 16:18:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Nov 30 23:38:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (io_fread): need not to null terminate. [ruby-dev:24998]
- * eval.c (rb_eval): should check previous frame for ZSUPER.
-
* io.c (read_all): remove unnecessary rb_str_resize().
- [ruby-dev:24996]
+ [ruby-dev:24996] (backported from CVS HEAD)
* io.c (io_readpartial): ditto.
* io.c (io_read): ditto.
-Tue Nov 30 14:58:33 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+Tue Nov 30 16:18:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * instruby.rb (install): add arguments explicitly to "super".
+ * io.c (io_fread): need not to null terminate. [ruby-dev:24998]
-Tue Nov 30 00:49:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (read_all): remove unnecessary rb_str_resize().
+ [ruby-dev:24996]
- * eval.c (PUSH_FRAME): flags should have been initialized.
+ * io.c (io_read): ditto.
- * eval.c (rb_eval): [ruby-core:03856]
+Tue Nov 30 00:49:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]
-Tue Nov 30 00:12:57 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * regparse.c: now handles many alternatives (over 500000)
- in regexp. [ruby-dev:24773]
-
Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_write): insufficiently filled string
@@ -25522,19 +14077,10 @@ Mon Nov 29 15:22:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/io/nonblock/test_flush.rb: abandon tests when io/nonblock is
not supported.
-Mon Nov 29 13:37:54 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (fptr_finalize): must not use FILE after fclose().
- [ruby-dev:24985]
-
-Mon Nov 29 13:13:13 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (CreateChild): push back the last space before next
- loop because CharNext() eats it.
-
Mon Nov 29 03:08:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * object.c (convert_type): [ruby-core:03845]
+ * object.c (convert_type): direct call conversion methods for the
+ performance. [ruby-core:03845]
* eval.c (rb_funcall_rescue): new function.
@@ -25542,57 +14088,30 @@ Mon Nov 29 03:08:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_Integer): ditto.
- * eval.c (get_backtrace): no conversion for nil.
-
* parse.y (reduce_nodes): empty body should return nil.
-Mon Nov 29 01:18:18 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c (rb_io_check_writable): call io_seek regardless of
- NEED_IO_SEEK_BETWEEN_RW. [ruby-dev:24986]
-
-Sun Nov 28 15:57:58 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb (RSS::Element#tag): not use block_given? for
- working with ruby 1.6 again.
-
- * lib/rss/{0.9,2.0,trackback}.rb, lib/rss/maker/base.rb:
- undef -> remove_method for working with ruby 1.6 again.
-
-Sun Nov 28 15:51:40 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb (RSS::NotSetError): added.
-
- * lib/rss/maker/{1.0,0.9,2.0}.rb: changed RSS Maker to raise
- RSS::NotSetError if required values of maker.channel are not
- set. [ruby-talk:120061]
-
- * test/rss/test_maker_{1.0,0.9,2.0}.rb: changed tests to check RSS
- Maker raises or not.
-
-Sun Nov 28 12:14:47 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
+ * string.c (rb_str_aset): the original string should not be
+ affected by modifying duplicated string. [ruby-dev:24981]
- * regparse.c (fetch_token): fixed test failure on HP-UX ia64
- ([ruby-dev:24859]).
+Mon Nov 29 13:57:38 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Sun Nov 28 12:08:15 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * regparse.c, test/ruby/test_regexp.rb: fixed problem with UTF-8
- characters that have U+00FE or invalid characters.
+ * win32/win32.c (CreateChild): search executable file if no program
+ name given. (backported from CVS HEAD)
-Sun Nov 28 12:07:04 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
+Mon Nov 29 13:37:54 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regexec.c, test/ruby/test_regexp.rb: fixed segmentation fault
- ([ruby-dev:24887]).
+ * io.c (fptr_finalize): must not use FILE after fclose().
+ [ruby-dev:24985]
-Sun Nov 28 12:05:48 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
+Mon Nov 29 13:16:31 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * regcomp.c, regint.h: fixed PLATFORM_UNALIGNED_WORD_ACCESS
- problem ([ruby-dev:24802] and [ruby-core:3733])
+ * win32/win32.c (CreateChild): push back the last space before next
+ loop because CharNext() eats it.
-Sat Nov 27 23:43:39 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Nov 29 01:18:18 2004 Tanaka Akira <akr@m17n.org>
- * io.c (rb_io_initialize): [ruby-dev:24972]
+ * io.c (rb_io_check_writable): call io_seek regardless of
+ NEED_IO_SEEK_BETWEEN_RW. [ruby-dev:24986]
Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
@@ -25604,36 +14123,10 @@ Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
(rb_io_fwrite): wrapper for io_fwrite now.
(io_write): call io_fwrite instead of rb_io_fwrite.
-Sat Nov 27 17:43:21 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/{0.9,1.0,2.0,trackback,xml-stylesheet}.rb: added
- #setup_maker.
-
- * test/rss/test_setup_maker_*.rb: added tests for #setup_maker.
-
- * lib/rss/maker/base.rb(RSS::Maker::Items#max_size=): supported
- output item size limitation.
-
- * sample/rss/blend.rb: added sample for RSS Maker.
-
-Sat Nov 27 17:41:35 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/maker/0.9.rb: supported RSS::Maker.make("0.91"). Now,
- "0.9" is just alias of "0.91."
-
- * test/rss/test_maker_0.9.rb: make("0.9") -> maker("0.91").
-
- * test/rss/test_to_s.rb: ditto.
-
-Sat Nov 27 17:21:30 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * sample/rss/list_description.rb: untabified.
-
- * sample/rss/rss_recent.rb: ditto.
-
Sat Nov 27 14:44:15 2004 Kent Sibilev <ksibilev@bellsouth.net>
- * lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832]
+ * lib/cgi/session.rb (CGI::Session::initialize): create_new_id is
+ now a instance method. [ruby-core:03832]
Sat Nov 27 09:41:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -25651,18 +14144,8 @@ Fri Nov 26 18:02:44 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: some methods uses TkWindow#epath
-Fri Nov 26 14:29:39 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_initialize): uninitialized fd was checked to see open
- mode. [ruby-dev:24963]
-
- * io.c (rb_io_initialize): uninitialized fd was used. [ruby-dev:24962]
-
Fri Nov 26 13:49:06 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_io_initialize): should retrieve flags from copying file
- descriptor. [ruby-dev:24961]
-
* eval.c (method_missing): raise TypeError for classes do not
have allocators. [ruby-core:03752]
@@ -25684,17 +14167,12 @@ Thu Nov 25 20:14:57 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/thwait.rb (ThreadsWait#join_nowait): abnormally terminated
threads should be also processed. [ruby-talk:121320]
-Thu Nov 25 18:06:37 2004 Tanaka Akira <akr@m17n.org>
+Thu Nov 25 10:14:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in: AC_CHECK_SIZEOF(rlim_t) to include stdio.h to fix
- problem with autoconf 2.52 or earlier.
- revert AC_PREREQ to 2.50.
- [ruby-core:3809]
+ * dir.c (push_braces): do not reuse buffer strings. [ruby-core:03806]
Thu Nov 25 07:59:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * configure.in: AC_PREREQ(2.53) [ruby-core:03800]
-
* io.c (read_all): stringify non-nil buffer argument, and always
taint the result. [ruby-dev:24955]
@@ -25725,12 +14203,13 @@ Tue Nov 23 00:10:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_seek): use NUM2OFFT().
- * misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719]
+ * misc/ruby-mode.el (ruby-non-block-do-re): should not match words
+ start with block keyword and underscore. [ruby-core:03719]
Mon Nov 22 22:33:02 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Don't use names
- of variables or constants when parsing 'require'
+ of variables or constants when oarsing 'require'
Mon Nov 22 00:13:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -25740,7 +14219,7 @@ Mon Nov 22 00:13:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
Sat Nov 20 23:57:33 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/README (et al): Add a new directive, :section:, and
- change the output format to accommodate. :section: allows to to
+ change the output format to accomodate. :section: allows to to
group together methods, attributes, constants, etc under
headings in the output. If used, a table of contents is
generated.
@@ -25755,25 +14234,9 @@ Sat Nov 20 23:55:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_splice): should place index wrapping after
possible modification. [ruby-dev:24940]
-Sat Nov 20 23:25:12 2004 Minero Aoki <aamine@loveruby.net>
-
- * io.c (rb_io_getline): f.gets("") did not work. [ruby-core:03771]
-
- * test/ruby/test_io.rb (test_gets_rs): test it.
-
-Sat Nov 20 22:55:09 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * test/runner.rb (CROSS_COMPILING): need to require rbconfig.rb before
- using CROSS_COMPILNG.
-
-Sat Nov 20 20:42:42 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/depend: fix ripper.o dependency.
-
-Sat Nov 20 17:48:29 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+Sat Nov 20 13:26:03 2004 NARUSE, Yui <naruse@ruby-lang.org>
- * io.c (io_reopen): work around problem with Cygwin fseeko
- returning ESPIPE.
+ * ext/nkf/nkf-utf8/utf8tbl.c: original revision 1.7
Sat Nov 20 05:34:24 2004 NARUSE, Yui <naruse@ruby-lang.org>
@@ -25781,11 +14244,6 @@ Sat Nov 20 05:34:24 2004 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/test.rb: add test for mime encode/decode
-Sat Nov 20 01:45:04 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * test/xmlrpc/test_webrick_server.rb: move `requrie "webrick/https"'
- into #setup_http_server method to avoid soap test errors.
-
Sat Nov 20 01:37:34 2004 Johan Holmberg <holmberg@iar.se>
* eval.c (error_print): nicer traceback at interrupt.
@@ -25796,66 +14254,6 @@ Sat Nov 20 00:07:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object() by String#gsub. [ruby-dev:24931]
-Fri Nov 19 22:44:43 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/test/unit/collector/dir.rb: better support for -p/-x option.
-
-Fri Nov 19 17:46:56 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/maker/0.9.rb (RSS::Maker::RSS09::Image#have_required_values):
- changed /rss/channel/image to be optional. [ruby-Bugs:1047]
-
- * test/rss/test_maker_0.9.rb: added tests for the above.
-
-Fri Nov 19 17:18:17 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb (RSS::VERSION): 0.1.0 -> 0.1.1.
-
- * lib/rss: #to_s used #tag.
-
- * test/rss/test_to_s.rb: added.
-
- * lib/rss/maker.rb (RSS::Maker.make): changed API. It's not
- received modules which is used as the second argument.
-
- * lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#alternate):
- changed return value type which is not String but Boolean.
-
- * lib/rss/2.0.rb (RSS::Rss::Channel#ttl): changed return value
- type which is not String but Integer.
-
- * lib/rss/0.9.rb (RSS::Rss::Channel): <skipDays> has <day>s and
- <skipHours> has <hour>s.
-
- * lib/rss/maker/0.9.rb (RSS::Maker::RSS09::Channel): ditto.
-
- * lib/rss/0.9.rb (RSS::Rss::Channel::Item): <item> has <category>s.
-
- * lib/rss/maker/2.0.rb (RSS::Maker::Rss20::Channel::Item): ditto.
-
- * lib/rss/2.0.rb (RSS::Rss::Channel): <channel> has <category>s.
-
- * lib/rss/maker/2.0.rb (RSS::Maker::RSS20::Channel): ditto.
-
- * lib/rss/trackback.rb: parent element has <trackback:about>s.
-
- * lib/rss/maker/trackback.rb: ditto.
-
-Fri Nov 19 11:10:16 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/test/unit/collector/dir.rb: add support for directory name
- with -p/-x options.
-
- * test/testunit/collector/test_dir.rb: ditto.
-
- * lib/xmlrpc/datetime.rb (XMLRPC::DateTime#==): should use Array()
- instead of to_a.
-
-Fri Nov 19 10:32:36 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/readline/readline.c (readline_s_set_completion_append_character):
- accept nil. [ruby-core:03765]
-
Fri Nov 19 01:20:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
@@ -25867,37 +14265,12 @@ Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object(). [ruby-dev:24919]
-Thu Nov 18 23:42:36 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/depend: Never regenerate lib/ripper/core.rb
- automatically. [ruby-dev:24911]
-
-Thu Nov 18 20:47:24 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
- isatty because it never sets errno.
-
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().
-
-Thu Nov 18 17:05:01 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (f_rest_arg): store rest args into invisible local variable
- in order to get rid of SEGV at ZSUPER. [ruby-dev:24913]
-
-Thu Nov 18 15:39:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (rb_f_getenv): prohibit for $SAFE=4. [ruby-dev:24908]
-
-Thu Nov 18 14:58:42 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/readline/readline.c: check $SAFE.
-
- * test/readline/test_readline.rb: added tests for readline.
+ (rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -25918,15 +14291,10 @@ Thu Nov 18 10:10:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_initialize): allow Fixnum as mode as
well as IO.new does. [ruby-dev:24896]
-Wed Nov 17 23:47:30 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Wed Nov 17 23:42:40 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/ruby/test_settracefunc.rb: added. [ruby-dev:24884]
-Wed Nov 17 18:59:16 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * process.c (proc_getrlimit, proc_setrlimit): add rb_secure(2) to
- methods of Process.{getrlimit,setrlimit}
-
Wed Nov 17 13:56:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (newline_node): should not use FL_SET. [ruby-dev:24874]
@@ -25936,65 +14304,28 @@ Wed Nov 17 13:56:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* node.h (NODE_NEWLINE): remove unused bit to utilize flag field
in nodes.
-Wed Nov 17 13:05:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (rb_push_glob): fix overrun. [ruby-dev:24886]
+Wed Nov 17 13:09:40 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Nov 17 11:48:17 2004 Michael Neumann <mneumann@ruby-lang.org>
+ * {bcc32,win32,wince}/Makefile.sub (test): should build ruby.exe
+ before running test. [ruby-core:03756]
- * lib/xmlrpc/parser.rb, test/xmlrpc/test_features.rb: fixed "assigning
- to constants" warnings
+Wed Nov 17 04:33:01 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Wed Nov 17 09:38:18 2004 Johan Holmberg <holmberg@iar.se>
+ * pack.c: all features are backport from 1.9. [ruby-dev:24826]
- * re.c (rb_reg_initialize_m): should raise exception instead of
- compile error. [ruby-core:03755]
+ * bignum.c (rb_big2ulong_pack): new function to pack Bignums.
Wed Nov 17 03:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_splice): move rb_str_modify() after
StringValue(), which may alter the receiver. [ruby-dev:24878]
- * error.c (rb_error_frozen): now raise RuntimeError instead of
- TypeError.
-
-Tue Nov 16 21:22:47 2004 Michael Neumann <mneumann@ruby-lang.org>
-
- * lib/xmlrpc/server.rb (CGIServer): fixed bug when client sends
- "Content-typ: text/xml; ..."
-
Tue Nov 16 23:45:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (flo_divmod): protect float values from GC by
assignment to local variables. [ruby-dev:24873]
-Tue Nov 16 14:31:54 2004 Michael Neumann <mneumann@ruby-lang.org>
-
- * test/xmlrpc/*: imported and refactored original test cases.
-
- * test/xmlrpc/test_webrick_server.rb, test/xmlrpc/webrick_testing.rb:
- added test case that starts up a WEBrick XML-RPC server and performs
- some tests on it (both http and https servers are started).
-
- * lib/xmlrpc/create.rb (XMLWriter::each_installed_writer),
- lib/xmlrpc/parser.rb (XMLParser::each_installed_parser):
- added methods to simply original test cases
-
- * lib/xmlrpc/parser.rb, lib/xmlrpc/datetime.rb: applied patch by
- MoonWolf <moonwolf@moonwolf.com> to allow parsing datetime.iso8601
- (e.g. 20041105T01:15:23Z).
-
- * lib/xmlrpc/server.rb: fixed issue #998
- (http://rubyforge.org/tracker/?func=detail&atid=1700&aid=998&group_id=426)
-
- * lib/xmlrpc/create.rb, lib/xmlrpc/utils.rb: when marshalling/loading
- user-defined data structures, use Class#allocate instead of defining
- an empty #initialize method. module XMLRPC::Marshallable is now only
- used for tagging.
-
- * lib/xmlrpc/.document, lib/xmlrpc/README.rdoc: added howto
-
-Tue Nov 16 16:26:12 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Nov 16 16:30:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* {bcc32,win32,wince}/setup.mak (-epilogue-): remove config.h and
config.status to force updating them.
@@ -26004,15 +14335,6 @@ Tue Nov 16 16:20:45 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_read): position was ignored when a
buffer was passed. http://www.yo.rim.or.jp/~nov/d/?date=20041116#p03
-Tue Nov 16 13:35:54 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::options): add
- new option --exclude (-x) to skip some tests. [ruby-core:3363],
- [ruby-dev:24865]
-
- * lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir.exclude):
- ditto.
-
Tue Nov 16 11:19:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::options): use
@@ -26026,72 +14348,32 @@ Tue Nov 16 01:41:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_update): pedantic check to detect
rb_ary_to_ary() to modify the receiver. [ruby-dev:24861]
-Mon Nov 15 18:58:05 2004 Tanaka Akira <akr@m17n.org>
+Mon Nov 15 13:50:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * configure.in: check rlim_t more portably. [ruby-core:3735]
+ * string.c (rb_str_justify): typo fixed. [ruby-dev:24851]
Mon Nov 15 11:50:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-mode.el (ruby-special-char-p, ruby-parse-partial): handle
operator symbols. [ruby-talk:120177]
-Mon Nov 15 08:58:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (Init_Proc): make proc as an alias to Proc.new.
- [ruby-dev:24848]
-
-Mon Nov 15 00:46:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_yield_0): lambda{}.call(1) should raise exception.
- [ruby-talk:120253]
-
-Mon Nov 15 00:33:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_clear): avoid revealing NULL pointer.
- [ruby-dev:24766]
-
- * string.c (str_gsub): add paranoid check. [ruby-dev:24827]
-
- * string.c (str_mod_check): check frozen status as well.
- [ruby-dev:24801]
-
-Sun Nov 14 18:59:03 2004 Tanaka Akira <akr@m17n.org>
-
- * process.c (proc_getrlimit): new function for Process.getrlimit.
- (proc_setrlimit): new function for Process.setrlimit.
- [ruby-dev:24834]
-
- * configure.in: check rlim_t and its size. check setrlimit.
-
- * ruby.h (NUM2ULL): new macro.
-
Sun Nov 14 13:27:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/pp.rb (PP#object_address_group): remove odd number of 'f'
prefixed to negative address.
-Sun Nov 14 10:48:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/mathn.rb (Integer::gcd2): faster implementation by
- <erlercw@siu.edu>. [ruby-talk:120232]
-
-Sun Nov 14 08:46:33 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Sun Nov 14 08:51:04 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/logger/test_logger.rb: Logger just expects
Logger#datetime_format to be used for Time#strftime independently of
locale. [ruby-dev:24828]
-Fri Nov 12 17:32:07 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * bcc32/README.bcc32, win32/README.win32: need bison instead of
- byacc.
-
-Fri Nov 12 15:15:06 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Nov 12 15:03:26 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* eval.c (ruby_options): now we cannot call rb_glob() before
ruby_init(), so call rb_w32_cmdvector() at ruby_options().
- * win32/win32.{c,h} (rb_w32_cmdvector): rename make_cmdvector() and
+ * win32.{c,h} (rb_w32_cmdvector): rename make_cmdvector() and
export it.
Fri Nov 12 14:08:01 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -26105,15 +14387,21 @@ Fri Nov 12 00:31:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/gdbm/gdbm.c (fgdbm_store): StringValue() may alter string
pointer. [ruby-dev:24783]
-Thu Nov 11 17:58:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Nov 11 17:36:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * dir.c (rb_glob): should have called rb_glob_caller().
- [ruby-dev:24773]
+ * dir.c (rb_globi): also should call back via rb_glob_caller().
+ [ruby-dev:24775]
-Thu Nov 11 16:56:10 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Nov 11 16:47:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* test/ruby/test_file.rb (test_truncate_wbuf): we want to test
- only File#truncate, not behavior of seek(2).
+ only File#truncate, not behaviour of seek(2).
+
+Thu Nov 11 09:41:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (push_braces): was confusing VALUE and char*.
+
+ * dir.c (rb_push_glob): Dir.glob should have called its block.
Thu Nov 11 01:52:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -26127,10 +14415,6 @@ Wed Nov 10 22:49:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (DelegateClass::dup): ditto.
-Wed Nov 10 19:47:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (glob_helper): path is a string object now.
-
Wed Nov 10 12:31:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* README.EXT (Example): extconf.rb is indispensable now.
@@ -26142,22 +14426,10 @@ Wed Nov 10 03:33:36 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/tile/style.rb: bug fix
-Tue Nov 9 22:24:07 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf: original nkf.c rev:1.38
-
- * ext/nkf/nkf.c: fix bug: can't parse long-name options
-
- * ext/nkf/test.rb: fix bug: mime tests fail
-
Tue Nov 9 14:27:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser::Officious): moved from DefaultList.
-Tue Nov 9 00:50:06 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/rdoc.rb: Change version numbering of RDoc and ri
-
Tue Nov 9 01:05:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (rb_glob2): do not allocate buffer from heap to avoid
@@ -26171,7 +14443,15 @@ Tue Nov 9 01:05:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (fnmatch): p or s may be NULL. [ruby-dev:24749]
-Tue Nov 9 00:36:26 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Nov 9 00:53:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * regex.c (slow_match): avoid GCC 3.4.x warnings.
+
+Tue Nov 9 00:50:06 2004 Dave Thomas <dave@pragprog.com>
+
+ * lib/rdoc/rdoc.rb: Change version numbering of RDoc and ri
+
+Mon Nov 8 23:38:35 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/extservm.rb: add DRb::ExtServManager#uri=.
[ruby-dev:24743]
@@ -26202,14 +14482,13 @@ Sun Nov 7 23:49:26 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib: ditto.
-Sat Nov 6 20:40:16 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sat Nov 6 14:58:44 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/win32ole/win32ole.c: rename WIN32OLE#ole_obj_help to
- WIN32OLE#ole_type. alias ole_obj_help to ole_type.
+ * lib/webrick/server.rb (WEBrick::HTTPServer#start): remove
+ :DoNotReverseLookup option. (Socket#do_not_reverse_lookup is a
+ ruby 1.9 feature)
- * ext/win32ole/tests/testWIN32OLE.rb: ditto.
-
-Sat Nov 6 11:18:59 2004 Tadayoshi Funaba <tadf@dotrb.org>
+Sat Nov 6 11:31:04 2004 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date.rb (_parse): checks whether zone was given.
@@ -26218,10 +14497,6 @@ Sat Nov 6 00:46:27 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_locktmp): check STR_TMPLOCK flag before
locking. [ruby-dev:24727]
-Fri Nov 5 19:07:16 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf: follow CVS Head of original nkf.
-
Fri Nov 5 18:12:42 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
@@ -26248,43 +14523,23 @@ Fri Nov 5 08:52:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (gc_mark): stricter GC stack check.
+Fri Nov 5 08:52:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (gc_mark): stricter GC stack check.
+
Fri Nov 5 08:34:43 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): should have removed rb_str_unlocktmp(str).
[ruby-dev:24708]
- * ext/socket/socket.c (s_recvfrom): buffer modification check.
- [ruby-dev:24708]
-
-Thu Nov 4 23:54:21 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * regexec.c, regparse.c, regint.h: fixed conflicts between
- vendor branch.
-
-Thu Nov 4 23:41:55 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c,
- regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c,
- regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
- imported Oni Guruma 3.4.0.
-
- * parse.y, re.c: Now mbclen() takes unsigned char as
- its argument.
-
Thu Nov 4 21:25:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): string modify check no longer based on
tmplock. [ruby-dev:24706]
-Thu Nov 4 21:13:48 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c(typelib_file_from_typelib): search "win16"
- entry to get library path.
-
- * ext/win32ole/win32ole.c(oletypelib_path): ditto.
+Thu Nov 4 19:27:46 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/win32ole/win32ole.c(ole_typedesc2val): add VT_LPWSTR, VT_LPSTR,
- VT_ERROR case.
+ * io.c (rb_f_open): fix typo.
Thu Nov 4 15:02:14 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -26302,6 +14557,10 @@ Thu Nov 4 03:11:33 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (s_recvfrom): tmplock input buffer.
[ruby-dev:24705]
+Wed Nov 3 22:32:12 2004 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * process.c: On NetBSD don't use setruid() and setrgid().
+
Wed Nov 3 22:24:17 2004 Daigo Moriwaki <techml@sgtpepper.net>
* lib/webrick/httpauth/digestauth.rb: use Base64.encode64 to
@@ -26316,7 +14575,11 @@ Wed Nov 3 17:19:59 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_or): ditto.
-Wed Nov 3 17:02:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Wed Nov 3 17:13:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * io.c (pipe_open): fix compile error
+
+Wed Nov 3 16:58:07 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: support to use different Tcl commands between
configure and configinfo
@@ -26332,55 +14595,33 @@ Wed Nov 3 17:02:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib: some bug fixes (see ext/tk/ChangeLog.tkextlib)
-Wed Nov 3 15:38:28 2004 Kouhei Sutou <kou@cozmixng.org>
+Wed Nov 3 16:30:41 2004 NARUSE, Yui <naruse@ruby-lang.org>
- * test/rss/*.rb: removed tab width configuration headers.
+ * ext/nkf: follow nkf 2.0.4
- * test/rss/test_maker_{0.9,1.0}.rb: sort -> do_sort.
+Wed Nov 3 15:53:34 2004 Kouhei Sutou <kou@cozmixng.org>
- * lib/rss/maker/*.rb: changed API to RSS version independence.
-
- * lib/rss/maker/base.rb
- (RSS::Maker::XMLStyleSheets::XMLStyleSheet): checked required
- (pseudo) attributes.
+ * test/rss/test_maker_*.rb: added tests for RSS Maker.
- * lib/rss/maker/base.rb (RSS::Maker::Items): sort -> do_sort.
+ * lib/rss/maker.rb: added RSS Maker.
- * lib/rss/rss.rb (RSS::BaseModel.install_date_element): avoided
- warning.
-
- * lib/rss/0.9.rb (RSS::Rss#textinput): added convenience method.
+ * lib/rss/maker/*.rb: ditto.
Tue Nov 2 16:35:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/enumerator/enumerator.c (each_cons_i): pass copy of an
internal consequent array. [ruby-talk:118691]
-Tue Nov 2 14:54:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Nov 2 16:05:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (pipe_open): need to set cmd if argc == 0 (win32).
+ * process.c (rb_f_fork): need to flush stdout and stderr before
+ fork(2). [ruby-talk:117715]
Tue Nov 2 01:20:09 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (pipe_open): IO.popen should take array as 1st argument for
- a command line. [ruby-dev:24678]
-
* eval.c (proc_invoke): nail down dyna_var node when Proc object
or continuation is created. [ruby-dev:24671]
- * io.c (rb_io_s_popen): do not expand argv array. [ruby-dev:24670]
-
-Mon Nov 1 22:25:56 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/maker/base.rb: changed xml-stylesheet's API of RSS Maker
- like to item's one.
-
- * lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#guess_type): fixed
- regular expression bug.
-
- * test/rss/test_maker_xml-stylesheet.rb: updated tests for
- xml-stylesheet.
-
Mon Nov 1 13:59:28 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/extmk.rb (MANIFEST): do not use anymore, use extconf.rb instead.
@@ -26392,29 +14633,15 @@ Mon Nov 1 13:59:28 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* README.EXT, README.EXT.ja: remove MANIFEST stuff.
-Mon Nov 1 11:52:18 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (pipe_open): avoid conflict of variable name. [ruby-dev:24662]
-
-Mon Nov 1 11:46:19 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * process.c (rb_f_exec): should check whether prog is NULL.
-
-Mon Nov 1 09:37:19 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/maker.rb: added entry point of RSS Maker.
-
-Mon Nov 1 03:14:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Nov 1 01:14:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_get_method_body): store ICLASS in the cache.
- [ruby-core:03672]
+ * io.c (rb_f_open): create copy of popen specifier. [ruby-dev:24656]
- * eval.c (rb_provided): should return true for loading library
- too for autoloading. [ruby-core:03655]
+Mon Nov 1 00:36:48 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Mon Nov 1 01:14:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * main.c (_stklen): move to gc.c.
- * io.c (rb_f_open): create copy of popen specifier. [ruby-dev:24656]
+Sun Oct 31 00:22:28 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_locktmp): lock string temporarily.
@@ -26427,54 +14654,15 @@ Mon Nov 1 01:14:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (read_all): ditto.
-Sun Oct 31 23:37:00 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * process.c: on NetBSD don't use setruid() and setrgid().
-
-Sun Oct 31 23:12:10 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/maker/*.rb: added RSS Maker.
-
- * test/rss/test_maker_*.rb: added tests for RSS Maker.
-
-Sun Oct 31 16:58:12 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE.codepage, WIN32OLE.codepage=.
-
- * ext/win32ole/tests/testWIN32OLE.rb: ditto.
-
-Sun Oct 31 14:35:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/nkf.c: add "\075?UTF-8?Q?" for Gmail.
-
-Sun Oct 31 14:18:56 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: emit lexer-event values to the parser
- (still incomplete).
-
-Sat Oct 30 15:24:41 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-
- * ext/win32ole/win32ole.c: add WIN32OLE_TYPELIB class. add
- WIN32OLE#ole_typelib method.
-
- * ext/win32ole/tests/testOLETYPELIB.rb: add WIN32OLE_TYPELIB class.
-
Sat Oct 30 06:53:24 2004 Peter Vanbroekhoven <peter.vanbroekhoven@cs.kuleuven.ac.be>
* eval.c (rb_eval): NODE_XSTR should pass copy of literal string.
Sat Oct 30 00:19:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * array.c (rb_ary_update): a[n,m]=nil no longer works as element
- deletion.
-
* enum.c (enum_sort_by): protect continuation jump in.
[ruby-dev:24642]
- * eval.c (rb_eval), gc.c (gc_mark_children), node.h (NEW_ALIAS,
- NEW_VALIAS), parse.y (fitem): allow dynamic symbols to
- NODE_UNDEF and NODE_ALIAS.
-
Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_check_initialized): new function to check uninitialized
@@ -26482,26 +14670,6 @@ Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_path), io.c (rb_io_closed): check if initialized.
-Fri Oct 29 19:05:33 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf: follow nkf2.0.
-
-Fri Oct 29 17:18:22 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * parse.y (ripper_s_allocate): add prototype for Microsoft compiler.
-
- * range.c (range_step, range_each): need cast.
-
-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]
-
-Fri Oct 29 11:35:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rb_parser_append_print, rb_parser_while_loop): body node
- can be empty. [ruby-dev:24628]
-
Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_start_0): forget to free some memory chunks.
@@ -26516,20 +14684,32 @@ Thu Oct 28 08:42:02 2004 Tanaka Akira <akr@m17n.org>
(argf_read): call argf_forward with argv argument.
[ruby-dev:24624]
+Thu Oct 28 23:32:54 2004 akira yamada <akira@ruby-lang.org>
+
+ * ext/zlib/zlib.c (zstream_detach_input): resets klass of z->input if
+ z->input isn't nil.
+
+Thu Oct 28 23:19:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/extmk.rb: prefer relative path. [ruby-talk:93037]
+
+Wed Oct 27 18:49:11 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * gc.c: prototype; rb_io_fptr_finalize() doesn't return any value
+ at this version.
+
+Wed Oct 27 17:27:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (gc_sweep): recover ruby_in_compile variable.
+
Wed Oct 27 09:17:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_gsub): use a string object for exception safeness.
[ruby-dev:24601]
-Wed Oct 27 07:38:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Oct 26 23:52:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * node.h (NODE_TYPESHIFT): allow 4 more bits for line numbers.
- [ruby-talk:117841]
-
- * ruby.h (FL_ABLE): nodes are not subject for flag operations.
-
- * io.c (ARGF_FORWARD): should have specified argv explicitly,
- since we no longer have frame->argv saved. [ruby-dev:24602]
+ * io.c (rb_io_getline): rs modification check should not interfere in the loop.
Tue Oct 26 23:30:39 2004 Dave Thomas <dave@pragprog.com>
@@ -26551,6 +14731,16 @@ Tue Oct 26 10:56:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* sprintf.c (rb_f_sprintf): raise ArgumentError for extra
arguments, unless (digit)$ style used.
+Tue Oct 26 11:33:26 2004 David G. Andersen <dga@lcs.mit.edu>
+
+ * ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
+ performance. [ruby-talk:117701]
+
+Tue Oct 26 10:56:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (rb_f_sprintf): raise ArgumentError for extra
+ arguments, unless (digit)$ style used.
+
Mon Oct 25 18:35:39 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* win32/win32.c (isUNCRoot): should check NUL after '.'.
@@ -26562,16 +14752,11 @@ Mon Oct 25 08:03:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (get_backtrace): ignore illegal backtrace. [ruby-dev:24587]
-Sun Oct 24 00:40:50 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Oct 24 00:41:09 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_load, search_required, rb_require_safe, rb_require): use
frozen shared string to avoid outside modification. [ruby-dev:24580]
-Sat Oct 23 23:40:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_fptr_finalize): leave stdin/stdout/stderr open in
- interpreter termination. [ruby-dev:24579]
-
Sat Oct 23 22:18:32 2004 Guy Decoux <ts@moulon.inra.fr>
* eval.c (frame_free): Guy Decoux solved the leak problem.
@@ -26615,10 +14800,6 @@ Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
ensure to close @body. (http://bugs.debian.org/277520)
-Thu Oct 21 13:11:31 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * io.c (pipe_open): variable name "fpw" is conflicted.
-
Thu Oct 21 00:36:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_alias): should warn on method discarding.
@@ -26627,21 +14808,11 @@ Thu Oct 21 00:36:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/zlib/zlib.c (zstream_expand_buffer_into): hide internal
string buffer by clearing klass. [ruby-dev:24548]
- * parse.y (lex_getline): should not touch ruby_debug_lines if
- RIPPER is defined. [ruby-dev:24547]
-
Wed Oct 20 19:45:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): reentrant check. [ruby-dev:24432]
-Wed Oct 20 12:42:53 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_getline): rs modification check should not interfere
- in the loop.
-
-Wed Oct 20 10:31:33 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (lex_getline): should update ruby_debug_lines.
+ * backport all SEGV bug fixes from CVS HEAD. [ruby-dev:24536]
Wed Oct 20 04:17:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -26663,23 +14834,13 @@ Wed Oct 20 01:37:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ruby_exec): stack marking position may be higher than
expected. thanks to Guy Decoux. [ruby-core:03527]
-Wed Oct 20 00:25:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (search_required): required name must not be changed before
- loading. [ruby-dev:24492]
-
-Tue Oct 19 23:59:46 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_require_safe): provide the feature after loaded.
- [ruby-list:40085]
-
Tue Oct 19 22:43:12 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_attr): If
we come across 'attr' in a context where it isn't
followed by a symbol, just issue a warning.
-Tue Oct 19 20:32:50 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Tue Oct 19 20:41:37 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole.c(ole_invoke): retrieve the result value when
retrying the IDispatch::invoke.
@@ -26699,7 +14860,15 @@ Tue Oct 19 17:24:11 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/zlib/zlib.c (zstream_expand_buffer): hide internal string
buffer by clearing klass. [ruby-dev:24510]
-Tue Oct 19 08:47:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Oct 19 16:12:18 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/tkutil.c: backport from CVS HEAD
+
+Tue Oct 19 08:54:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * intern.h, object.c (rb_class_inherited_p): export.
+
+Tue Oct 19 08:46:57 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_upto): method result must be checked. [ruby-dev:24504]
@@ -26710,20 +14879,60 @@ Mon Oct 18 23:37:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_object0): check inheritance by the internal function.
[ruby-dev:24515]
-Mon Oct 18 11:29:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Oct 18 15:58:01 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * range.c (range_step, range_each): need cast.
+
+Fri Oct 29 16:34:19 2004 Daiki Ueno <ueno@unixuser.org>
- * io.c (rb_io_flags_mode, rb_io_mode_flags): distinguish whether file
- not existing is created. [ruby-dev:24505]
+ * misc/ruby-mode.el (ruby-parse-partial): Parse the rest of the
+ line after opening heredoc identifier. [ruby-dev:24635]
Mon Oct 18 07:26:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_truncate): discard read buffer before truncation.
[ruby-dev:24197]
-Mon Oct 18 01:56:03 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Oct 18 02:11:21 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/config.rb (WEBrick::Config::General): add default values:
+ - WEBrick::Config[:DoNotReverseLookup]
+ - WEBrick::Config[:RequestCallback] (it used as an alias of
+ :RequestHandler in WEBrick::HTTPServer#run)
+ - WEBrick::Config::FileHandler[:AcceptableLanguages]
+
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::FileHandler#set_filename): search files
+ having suffix of language-name which Accept-Language header field
+ includes if :AcceptableLanguages options is present.
+
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::FileHandler#get_servlet): new method to
+ search servlet correspond to the suffix of filename.
+
+ * lib/webrick/httprequest.rb: add attributes access methods: accept,
+ accept_charset, accept_encoding, accept_language, content_length
+ and content_type.
+
+ * lib/webrick/httpresponse.rb: add attribute access methods:
+ content_length, content_length=, content_type and content_type=.
+
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.mime_types):
+ use the second suffix to detect media type. (the first suffix
+ may be a language name.)
+
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_qvalues):
+ add method to parse Accept header field. it returns an Array of
+ values sorted by the qvalues.
+
+Mon Oct 18 02:04:11 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#initialize):
- initial value of accpet-* should be array.
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#virtual_host): new
+ method to register virtual hosting servers.
+
+ * lib/webrick/server.rb (WEBrick::GenericServer#accept): call
+ do_not_reverse_lookup for each socket if :DoNotReverseLookup
+ is set. [ruby-core:02357]
Mon Oct 18 00:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -26737,7 +14946,7 @@ Sun Oct 17 23:03:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/timer.rb: TkTimer#start and restart accept a block
-Sun Oct 17 12:53:46 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sun Oct 17 13:05:04 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (fole_func_methods): correct argument mismatch.
* ext/win32ole/win32ole.c (fole_get_methods): ditto.
@@ -26760,21 +14969,6 @@ Sat Oct 16 13:34:56 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss: supported prety print.
* test/rss/test_1.0.rb: added test for calculating default indent size.
-Sat Oct 16 10:56:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb (create_makefile): install-rb is needed for statically
- linked extensions. [ruby-dev:24491]
-
-Fri Oct 15 18:07:08 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_x509store.c
- (ossl_x509stctx_initialize): setup OpenSSL::X509::StoreContext with
- ossl_x509stctx_* functions instead of X509_STORE_CTX_*.
- (ossl_x509store_set_time): add OpenSSL::X509::Store#time=.
- (ossl_x509stctx_set_time): add OpenSSL::X509::StoreContext#time=.
-
- * test/openssl/ossl_x509store.rb: test certificate validity times.
-
Fri Oct 15 18:04:35 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/timer.rb: TkTimer.new(interval, loop){ ... } is
@@ -26785,60 +14979,13 @@ Fri Oct 15 12:43:09 2004 Tanaka Akira <akr@m17n.org>
* eval.c (Init_stack): make prototype declaration consistent with
the definition in gc.c.
-Thu Oct 14 13:33:59 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/rss.rb: added link to Tutorial.
-
-Tue Oct 12 21:22:50 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/config.rb:
- add WEBrick::Config::FileHandler[:AcceptableLanguages].
-
- * lib/webrick/httpservlet/filehandler.rb
- (WEBrick::HTTPServlet::FileHandler#set_filename): search files
- having suffix of language-name which Accept-Language header field
- includes if :AcceptableLanguages options is present.
-
- * lib/webrick/httpservlet/filehandler.rb
- (WEBrick::HTTPServlet::FileHandler#get_servlet): new method to
- search servlet correspond to the suffix of filename.
-
- * lib/webrick/httprequest.rb: add attributes access methods: accept,
- accept_charset, accept_encoding, accept_language, content_length
- and content_type.
-
- * lib/webrick/httpresponse.rb: add attribute access methods:
- content_length, content_length=, content_type and content_type=.
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils.mime_types):
- use the second suffix to detect media type. (the first suffix
- may be a language name.)
-
- * lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_qvalues):
- add method to parse Accept header field. it returns an Array of
- values sorted by the qvalues.
-
-Tue Oct 12 15:05:32 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+Thu Oct 14 14:34:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* io.c (MODE_BINMODE, MODE_BINARY): fixed reversed condition.
-Mon Oct 11 17:51:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
- avoid mode string modification. [ruby-dev:24454]
-
- * io.c (rb_io_getline_fast): should take delim as unsigned char to
- distinguish EOF and '\377'. [ruby-dev:24460]
-
- * io.c (rb_io_getline): add check for RS modification.
- [ruby-dev:24461]
-
- * enum.c (enum_sort_by): use qsort() directly instead using
- rb_iterate(). [ruby-dev:24462]
+Thu Oct 14 13:33:59 2004 Kouhei Sutou <kou@cozmixng.org>
- * enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
- prevent access to recycled object (via continuation for
- example). [ruby-dev:24463]
+ * lib/rss/rss.rb: added link to Tutorial.
Mon Oct 11 13:48:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -26849,16 +14996,6 @@ Sun Oct 10 12:32:08 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Allow 'require'
to be used as a variable name
-Sun Oct 10 02:49:14 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/filter.rb: require ripper/tokenizer.
-
- * ext/ripper/lib/ripper/filter.rb (parse): argument is optional.
-
-Sun Oct 10 02:43:13 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: \n between two comments disappeared.
-
Sat Oct 9 21:23:37 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/converter.rb: changed to try to use Iconv for default
@@ -26871,19 +15008,6 @@ Sat Oct 9 19:50:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_getline): should not treat char as negative value.
[ruby-dev:24460]
-Sat Oct 9 00:25:39 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c (rb_io_fread): rb_thread_wait_fd() was lost.
- [ruby-dev:24457]
-
-Fri Oct 8 21:36:56 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (fu_traverse): return value of Dir.entries is
- reliable. (pass $SAFE=1)
-
- * lib/fileutils.rb (remove_dir): return value of Dir.foreach is
- reliable. (pass $SAFE=1)
-
Fri Oct 8 09:49:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): pointer modification check before each
@@ -26943,19 +15067,7 @@ Wed Oct 6 09:21:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (member_i): use RANGE_EACH_BREAK. [ruby-talk:114959]
-Tue Oct 5 09:53:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_fopen): mode string copy at the lowest level.
-
- * io.c (rb_io_flags_mode): requires output buffer no more. no
- allocation needed.
-
- * array.c (rb_ary_index): takes a block to compare items in an
- array. [ruby-talk:113069] [Ruby2]
-
- * array.c (rb_ary_rindex): ditto.
-
-Mon Oct 4 14:03:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Oct 4 14:04:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_file_open_internal, rb_io_reopen): fname might be altered
while GC. [ruby-dev:24408]
@@ -26967,21 +15079,16 @@ Mon Oct 4 12:53:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/image.rb: bug fix
-Sun Oct 3 21:16:05 2004 Shugo Maeda <shugo@ruby-lang.org>
+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.
+ version of Microsoft Exchange Server. (backported from HEAD)
* lib/net/imap.rb (RTEXT_REGEXP): ditto.
* lib/net/imap.rb (CTEXT_REGEXP): ditto.
-Sat Oct 2 20:34:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (local_vars): moved to struct parser_params.
- [ruby-dev:24391]
-
- * parser.y (stmts): remove suspicious NODE_BEGIN. [ruby-dev:24390]
+Sat Oct 2 20:34:22 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* node.h (NEW_DVAR): extra semicolon.
@@ -27003,6 +15110,9 @@ Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (specific_eval): defer pointer retrieval to prevent
unsafe sourcefile string modification. [ruby-dev:24382]
+ * eval.c (specific_eval): defer pointer retrieval to prevent
+ unsafe sourcefile string modification. [ruby-dev:24382]
+
* string.c (rb_str_sum): wrong cast caused wrong result.
[ruby-dev:24385]
@@ -27014,6 +15124,24 @@ Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_sum): string may be altered. [ruby-dev:24381]
+Mon Oct 11 17:51:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
+ avoid mode string modification. [ruby-dev:24454]
+
+ * io.c (rb_io_getline_fast): should take delim as unsigned char to
+ distinguish EOF and '\377'. [ruby-dev:24460]
+
+ * io.c (rb_io_getline): add check for RS modification.
+ [ruby-dev:24461]
+
+ * enum.c (enum_sort_by): use qsort() directly instead using
+ rb_iterate(). [ruby-dev:24462]
+
+ * enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
+ prevent access to recycled object (via continuation for
+ example). [ruby-dev:24463]
+
Fri Oct 1 11:40:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_f_eval): defer pointer retrieval to prevent unsafe
@@ -27058,18 +15186,6 @@ Wed Sep 29 10:58:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (sort_by_i): internally used object must not be changed
outside. [ruby-dev:24368]
-Mon Sep 27 21:25:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_call0): invoke finalizers periodically.
-
- * gc.c (gc_sweep): defer running finalizers. [ruby-dev:24354]
-
- * gc.c (rb_gc_finalize_deferred): run deferred finalizers.
-
-Mon Sep 27 15:01:59 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: missing ';'.
-
Mon Sep 27 13:46:45 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* intern.h, struct.c (rb_struct_s_members, rb_struct_members): public
@@ -27079,34 +15195,9 @@ Mon Sep 27 13:46:45 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
Mon Sep 27 09:14:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * array.c (rb_ary_delete): comparison may change the capacity.
- [ruby-dev:24348]
-
- * array.c (rb_ary_fill): fill should honor length argument.
- [ruby-dev:24346]
-
- * array.c (rb_ary_replace): should not use ptr from shared array.
- [ruby-dev:24345]
-
* ext/socket/socket.c (s_accept): don't retry for EWOULDBLOCK.
[ruby-talk:113807]
-Sun Sep 26 08:05:10 2004 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: provides {Time,Date,DateTime}#to_{time,date,datetime}.
-
- * sample/cal.rb: uses getoptlong instead of getopts.
-
-Sat Sep 25 18:39:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * array.c (flatten): element size might change during comparison.
- [ruby-dev:24343]
-
-Sat Sep 25 01:52:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * struct.c (rb_struct_s_members): wrong call of struct_members.
- [ruby-dev:24333]
-
Fri Sep 24 16:09:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_invoke): propagate DVAR_DONT_RECYCLE on termination
@@ -27114,11 +15205,6 @@ Fri Sep 24 16:09:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
Fri Sep 24 08:29:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (rb_parser_append_print): should handle prelude.
- [llama@u01.gate0]
-
- * parse.y (rb_parser_while_loop): ditto.
-
* array.c (rb_ary_subseq): original object might be modified after
sharing data creation. [ruby-dev:24327]
@@ -27129,22 +15215,6 @@ Fri Sep 24 08:29:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* struct.c (struct_members): always check struct size and size of
members list in the class. [ruby-dev:24320]
-Thu Sep 23 19:48:14 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/Makefile.dev: removed.
-
- * ext/ripper/ripper.rb.in: moved to lib/ripper/core.rb.in.
-
- * ext/ripper/lib/ripper/core.rb: new file.
-
- * ext/ripper/lib/ripper/core.rb.in: new file.
-
- * ext/ripper/tools/generate-ripper_rb.rb: change comment.
-
- * test/ripper/*.rb: on__scan event removed.
-
- * test/ripper/*.rb: event name is changed: on__XXX -> on_XXX.
-
Thu Sep 23 09:29:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_sub_bang): check if string is not modified
@@ -27153,50 +15223,23 @@ Thu Sep 23 09:29:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (rb_hash_rehash): replace st_foreach() by its deep
checking counterpart. [ruby-dev:24310]
-Wed Sep 22 14:21:54 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: on__scan event removed.
-
- * parse.y [ripper]: event name is changed: on__XXX -> on_XXX.
-
- * ext/ripper/eventids2.c: ditto.
-
- * ext/ripper/ripper.rb.in: ditto.
-
- * ext/ripper/lib/ripper.rb: sync with ripper.rb.in.
-
- * ext/ripper/lib/ripper/tokenizer: ditto.
-
- * ext/ripper/lib/ripper/filter: new file.
-
- * sample/ripper/colorize.rb: new file.
-
- * sample/ripper/strip-comment.rb: new file.
-
-Wed Sep 22 13:50:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (hash_alloc): was using tbl pointer without
- initialization.
-
Wed Sep 22 13:38:12 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (rb_hash_rehash): add iteration check. [ruby-dev:24301]
* st.c (st_foreach): add deep check.
- * hash.c (rb_hash_fetch): returns KeyError instead of IndexError.
+Wed Sep 22 13:06:14 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * hash.c (env_fetch): ditto.
+ * win32/win32.c (rb_w32_call_handler): workaround for Ctrl-C.
+ merge from HEAD.
-Wed Sep 22 13:02:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Sep 22 00:11:12 2004 Dave Thomas <dave@pragprog.com>
- * win32/win32.c (rb_w32_call_handler): workaround for Ctrl-C.
+ * process.c: Add documentation for fork()
Wed Sep 22 09:04:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y: remove global variables ruby_eval_tree and
- ruby_eval_tree_begin.
-
* array.c (rb_ary_collect_bang): element size might change during
comparison. [ruby-dev:24300]
@@ -27204,116 +15247,13 @@ Wed Sep 22 09:04:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_eql): ditto. [ruby-dev:24300]
-Wed Sep 22 00:11:12 2004 Dave Thomas <dave@pragprog.com>
-
- * process.c: Add documentation for fork()
-
Tue Sep 21 18:29:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_equal): merge miss.
+
* array.c (rb_ary_uniq_bang): element size might change during
comparison. [ruby-dev:24298]
-Mon Sep 20 17:46:51 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/tokenizer.rb: fix typo.
-
-Mon Sep 20 17:38:43 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/ripper/test_scanner_events.rb: tokens must be reordered.
-
- * ext/ripper/lib/ripper/tokenizer.rb: ditto.
-
-Mon Sep 20 16:58:16 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: do not delay dispatching.
-
- * ext/ripper/lib/ripper/tokenizer.rb: sort tokens by right order.
-
-Mon Sep 20 15:17:47 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/lib/ripper/tokenizer.rb: new file.
-
-Mon Sep 20 15:13:52 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/ripper/test_scanner_events.rb: test #lineno and #column.
-
-Mon Sep 20 14:50:17 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: delayed heredocument events should be
- dispatched after EOF.
-
-Mon Sep 20 14:39:42 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: adjust lineno and columns for multi-line
- strings.
-
- * parse.y [ripper]: delay heredocument events until seeing
- end-of-line.
-
- * parse.y [ripper]: event on__heredoc_contentn ->
- on__tstring_content.
-
- * ext/ripper/eventids2.c: ditto.
-
- * ext/ripper/lib/ripper.rb: sync with eventids2.c.
-
- * test/ripper/test_scanner_events.rb: test it.
-
- * ext/ripper/tools/generate-ripper_rb.rb: show basename of input.
-
- * ext/ripper/Makefile.dev: support objdir build.
-
-Mon Sep 20 13:22:55 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: remove Ripper#pos.
-
- * parse.y [ripper]: Ripper#column should return the column of the
- current token.
-
-Mon Sep 20 12:02:41 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: unify old_lex_p and token_head.
-
- * test/ripper/test_scanner_events.rb: now \r\n is saved correctly.
-
- * parse.y: new macro lex_goto_eol() for next change.
-
-Mon Sep 20 11:01:55 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: adjust line number for heredoc. [ruby-dev:24272]
-
-Mon Sep 20 04:49:22 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/ripper.rb.in: new const Ripper::PARSER_EVENT_TABLE.
-
- * ext/ripper/ripper.rb.in: new const Ripper::SCANNER_EVENT_TABLE.
-
- * ext/ripper/lib/ripper.rb: sync with ripper.rb.in.
-
-Mon Sep 20 04:13:00 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/ripper/test_scanner_events.rb: test spaces before heredoc
- mark.
-
-Mon Sep 20 03:46:54 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: spaces before heredoc marker was lost.
- [ruby-dev:24272]
-
- * keywords: rb_reserved_word() should be defined only in ruby
- core. [ruby-dev:24272]
-
- * lex.c: sync with keywords.
-
- * ext/ripper/ripper.rb.in (parse): fix typo.
-
- * ext/ripper/lib/ripper.rb: sync with ripper.rb.in.
-
-Mon Sep 20 03:37:59 2004 Tanaka Akira <akr@m17n.org>
-
- * ext/zlib/zlib.c (gzfile_read_raw): call readpartial at first.
- (Zlib::GzipReader#readpartial): new method.
-
Mon Sep 20 00:24:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* enum.c (enum_sort_by): do not use qsort directly. use
@@ -27355,23 +15295,15 @@ Sat Sep 18 14:10:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
direcotry or within block. thanks to Johan Holmberg
<holmberg@iar.se> [ruby-core:03446]
-Fri Sep 17 20:29:33 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Fri Sep 17 20:20:27 2004 Minero Aoki <aamine@loveruby.net>
- * parse.y: add prototypes for Microsoft compiler.
-
- * ext/ripper/depend (parse.obj): lex.c exists at hdrdir.
-
- * {bcc32,win32,wince}/Makefile.sub (YACC, YFLAGS, parse.c):
- use bison.
+ * lib/fileutils.rb (mkdir_p): backport from CVS HEAD 1.45. [ruby-core:03420]
Fri Sep 17 17:11:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_delete): element comparison might change array
size. [ruby-dev:24273]
- * parse.y: make ruby parser reentrant. merge ripper parser to the
- real one. this change makes ruby require bison.
-
* file.c (rb_file_truncate): clear stdio buffer before truncating
the file. [ruby-dev:24191]
@@ -27399,7 +15331,7 @@ Fri Sep 17 15:01:57 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/tkoptdb-safeTk.rb: ditto
-Thu Sep 16 18:12:13 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Sep 16 18:12:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI#start): should set REMOTE_USER
to request.user attribute.
@@ -27428,44 +15360,6 @@ Tue Sep 14 23:45:44 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::TextFormatter.for):
Add Eric Hodel's simpleformatter.
-Tue Sep 14 22:11:08 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: Add rdoc.
-
-Tue Sep 14 20:24:49 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y [ripper]: space event is on__sp, not on__lwsp.
- [ruby-dev:24257]
-
- * ext/ripper/eventids2.c: ditto.
-
- * ext/ripper/lib/ripper.rb: ditto.
-
- * ext/ripper/depend (ripper.o): No action is needed.
- [ruby-dev:24260]
-
- * ext/ripper/depend: Borland make does not accept pipes in
- Makefile rules. [ruby-dev:24589]
-
- * ext/ripper/depend: separate rules for developpers.
-
- * ext/ripper/Makefile.dev: new file.
-
- * ext/ripper/MANIFEST: add Makefile.dev.
-
- * ext/ripper/tools/generate-eventids1.rb: read from file, not
- stdin.
-
- * ext/ripper/extconf.rb: clean ripper.E.
-
- * ext/ripper/tools/generate-ripper_rb.rb: #include ids1/ids2
- function was lost.
-
- * ext/ripper/tools/generate-ripper_rb.rb: SCANNER_EVENTS wrongly
- contained parser events.
-
- * ext/ripper/lib/ripper.rb: ditto.
-
Tue Sep 14 16:59:37 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: fix SEGV
@@ -27476,22 +15370,9 @@ Tue Sep 14 16:59:37 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/safe-tk.rb: new sample script
+Tue Sep 14 00:15:15 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Mon Sep 13 21:33:40 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_to_s): add optional
- second argument to specify the output format (see also
- X509_NAME_print_ex).
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_init): new constants:
- OpenSSL::X509::Name::COMPAT, OpenSSL::X509::Name::RFC2253,
- OpenSSL::X509::ONELINE, OpenSSL::X509::MULTILINE.
-
- * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name::RFC2253DN):
- new module to provide the parse for RFC2253 DN format.
-
- * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name.parse_rfc2253):
- new method to parse RFC2253 DN format.
+ * ext/zlib/zlib.c: backported from HEAD.
Mon Sep 13 19:16:33 2004 WATANABE Hirofumi <eban@ruby-lang.org>
@@ -27502,92 +15383,10 @@ Mon Sep 13 16:23:27 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: MultiTkIp.new_master and new_slave accept
safe-level value argument
-Mon Sep 13 10:48:37 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_getpid): don't need to use _getpid() on
- mswin32 and mingw32.
-
-Mon Sep 13 10:22:05 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Sep 13 10:20:45 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* object.c (nil_inspect): fix typo.
-Mon Sep 13 09:29:58 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/depend: (nmake hack) prepend "./" to ripper.c to
- avoid {$(srcdir)}.
-
-Mon Sep 13 06:43:42 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper/tools/list-parse-event-ids.rb: does not use getopts.
-
- * ext/ripper/tools/list-scan-event-ids.rb: ditto.
-
-Mon Sep 13 02:42:28 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/Setup: add ripper.
-
- * ext/Setup.atheos: ditto.
-
- * ext/Setup.dj: ditto.
-
- * ext/Setup.emx: ditto.
-
- * ext/Setup.nt: ditto.
-
- * ext/Setup.x68: ditto.
-
-Mon Sep 13 02:26:31 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/ripper: ripper extention added.
-
- * ext/ripper/MANIFEST: new file.
-
- * ext/ripper/README: new file.
-
- * ext/ripper/depend: new file.
-
- * ext/ripper/extconf.rb: new file.
-
- * ext/ripper/eventids2.c: new file.
-
- * ext/ripper/ripper.rb.in: new file.
-
- * ext/ripper/lib/ripper.rb: new file.
-
- * ext/ripper/test/check-event-arity.rb: new file.
-
- * ext/ripper/test/check-event-coverage.sh: new file.
-
- * ext/ripper/test/check-scanner-event-coverage.rb: new file.
-
- * ext/ripper/test/list-called-events.rb: new file.
-
- * ext/ripper/test/src_rb: new file.
-
- * ext/ripper/test/validate.rb: new file.
-
- * ext/ripper/tools/generate-eventids1.rb: new file.
-
- * ext/ripper/tools/generate-param-macros.rb: new file.
-
- * ext/ripper/tools/generate-ripper_rb.rb: new file.
-
- * ext/ripper/tools/list-parse-event-ids.rb: new file.
-
- * ext/ripper/tools/list-scan-event-ids.rb: new file.
-
- * ext/ripper/tools/preproc.rb: new file.
-
- * ext/ripper/tools/strip.rb: new file.
-
- * test/ripper: ripper tests added.
-
- * test/ripper/dummyparser.rb: new file.
-
- * test/ripper/test_parser_events.rb: new file.
-
- * test/ripper/test_scanner_events.rb: new file.
-
Mon Sep 13 01:03:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: improve control of preserv/release tcltkip
@@ -27596,19 +15395,7 @@ Mon Sep 13 01:03:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tkutil.c: fix(?) SEGV
-Mon Sep 13 00:22:53 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y: fix file header.
-
-Mon Sep 13 00:20:39 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y: ripper merged.
-
- * lex.c: ditto.
-
- * keywords: ditto.
-
-Sun Sep 12 23:53:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sun Sep 12 23:46:23 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* util.c (ruby_strdup): remove unnecessary code. (xmalloc never
returns NULL.)
@@ -27640,25 +15427,11 @@ Sat Sep 11 16:09:46 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb: Fix up cross-file class merging.
-Fri Sep 10 20:18:05 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Sep 10 20:20:53 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/tcltklib/tcltklib.c (lib_merge_tklist): fix suspicious
pointer conversion.
-Fri Sep 10 19:16:24 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * bcc32/Makefile.sub: bccwin32 port starts to use RTL dll.
- (need to rebuild all) [ruby-dev:24138]
-
- * win32/win32.{h,c}: ditto.
-
-Fri Sep 10 15:55:59 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (mkdir_p): should pass mode argument to
- Dir.mkdir. [ruby-dev:24242]
-
- * test/fileutils/test_fileutils.rb: test it.
-
Fri Sep 10 02:43:54 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/template/kilmer.rb: James Buck's
@@ -27700,16 +15473,9 @@ Tue Sep 7 15:17:49 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/socket/socket.c (ruby_connect): break immediately if a
socket is non-blocking. [ruby-talk:111654]
-Tue Sep 7 12:48:22 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Sep 6 11:08:50 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * {bcc32,win32,wince}/Makefile.sub (config.h): add fcntl.
-
- * win32/win32.[ch] (fcntl): ditto.
-
- * win32/win32.c (rb_w32_connect): support nonblocking mode.
-
- * ext/socket/socket.c (wait_connectable, ruby_connect): support
- nonblocking connect on various platforms.
+ * ext/tk/lib/tk/menu.rb(TkOptionMenubutton#insert): call correct method
Mon Sep 6 11:00:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -27717,10 +15483,6 @@ Mon Sep 6 11:00:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
exception occurred within a block. a patch was given from Johan
Holmberg <holmberg at iar.se>. [ruby-core:03292]
-Mon Sep 6 10:57:40 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ext/tk/lib/tk/menu.rb(TkOptionMenubutton#insert): call correct method
-
Mon Sep 6 07:51:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (cvar_cbase): singletons should refer outer cvar scope.
@@ -27754,20 +15516,18 @@ Fri Sep 3 02:12:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Fri Sep 3 01:54:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/extmk.rb (extmake): extact target prefix from Makefiles.
-
* ext/extmk.rb: already built-in libraries satisfy dependencies.
[ruby-dev:24028]
-Wed Sep 1 21:16:50 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Sep 2 11:36:20 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/tk/lib/tk/spinbox.rb: fix typo
+ * eval.c (rb_obj_instance_eval): backported from HEAD.
-Wed Sep 1 19:28:37 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Sep 1 21:18:25 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * process.c (rb_proc_exec): label cannot precede variable declarations.
+ * ext/tk/lib/tk/spinbox.rb: fix typo
-Tue Aug 31 18:20:49 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Aug 31 18:24:04 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/tk/tkutil.c (cbsubst_init): fix memory leak
@@ -27782,10 +15542,6 @@ Tue Aug 31 12:30:36 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c (del_root): fix SEGV
-Mon Aug 30 21:50:14 2004 Dave Thomas <dave@pragprog.com>
-
- * object.c: Add RDoc for Module.included.
-
Mon Aug 30 23:11:06 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_driver.rb (and others): ri now merges documentation
@@ -27795,10 +15551,19 @@ Mon Aug 30 22:40:30 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: 'restart' method accepts arguments
+Mon Aug 30 21:50:14 2004 Dave Thomas <dave@pragprog.com>
+
+ * object.c: Add RDoc for Module.included.
+
Mon Aug 30 15:10:46 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (GNU/k*BSD): fixed FTBFS on GNU/k*BSD. [ruby-dev:24051]
+Mon Aug 30 11:29:35 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (CreateChild): strip trailing spaces. [ruby-dev:24143]
+ merge from HEAD.
+
Sun Aug 29 14:08:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: compile error on bcc32 [ruby-dev:24081]
@@ -27810,49 +15575,27 @@ Sat Aug 28 23:04:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* bignum.c (rb_big_and): protect parameters from GC.
[ruby-talk:110664]
-Fri Aug 27 12:13:50 2004 Tanaka Akira <akr@m17n.org>
-
- * ext/stringio/stringio.c (Init_stringio): add StringIO#readpartial as
- an alias for StringIO#sysread.
-
-Fri Aug 27 10:14:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (rb_proc_exec): strip trailing spaces. [ruby-dev:24143]
-
- * win32/win32.c (CreateChild): ditto.
-
Thu Aug 26 04:38:29 2004 Dave Thomas <dave@pragprog.com>
* eval.c (return_jump): Minor typo in error message. Now reads
"return can't jump across threads".
-Wed Aug 25 15:18:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_longjmp): Exception#to_str is no longer defined.
-
-Wed Aug 25 11:39:10 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (exc_equal): exceptions are equal if they share same
- class, message and backtrace. [ruby-talk:110354]
-
- * error.c (name_err_mesg_equal): ditto.
-
-Tue Aug 24 16:41:48 2004 Shugo Maeda <shugo@ruby-lang.org>
+Tue Aug 24 17:30:00 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::FileStore#initialize): do not
- use a session id as a filename.
+ use a session id as a filename. (backported from HEAD)
* lib/cgi/session/pstore.rb (CGI::Session::PStore#initialize): ditto.
* lib/cgi/session/pstore.rb (CGI::Session::PStore#initialize): use
- Dir::tmpdir.
+ Dir::tmpdir. (backported from HEAD)
-Tue Aug 24 14:32:17 2004 Shugo Maeda <shugo@ruby-lang.org>
+Tue Aug 24 14:40:16 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::FileStore#initialize): untaint
- session id after check.
+ session id after check. (backported from HEAD)
-Tue Aug 24 08:57:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Aug 24 09:09:01 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509attr.c (ossl_x509attr_initialize): d2i
functions may replace the pointer indicated by the first argument.
@@ -27861,12 +15604,7 @@ Tue Aug 24 08:57:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509name.c (ossl_x509name_initialize): ditto.
-Mon Aug 23 12:43:32 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/resolv.rb (Config.default_config_hash): when multiple domains
- are set, Win32::Resolv.get_resolv_info returns Array.
-
-Sun Aug 22 16:27:38 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Aug 23 14:04:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ssl.c (ossl_ssl_read):
- should return an empty string if specified length to read is 0.
@@ -27882,7 +15620,12 @@ Sun Aug 22 16:27:38 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/lib/openssl/buffering.rb: should not use select.
-Sun Aug 22 01:10:36 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Aug 23 12:40:56 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/resolv.rb (Config.default_config_hash): when multiple domains
+ are set, Win32::Resolv.get_resolv_info returns Array.
+
+Sun Aug 22 01:15:31 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect):
should call :ProxyContentHandler before finishing CONNECT.
@@ -27894,15 +15637,6 @@ Sat Aug 21 06:41:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (arg_config, with_config): deal with '-' and '_'
uniformly. [ruby-dev:24118]
-Fri Aug 20 14:49:42 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (rb_io_check_writable): no need to check read buffer if
- already changed to write mode.
-
-Fri Aug 20 11:46:43 2004 UENO Katsuhiro <katsu@blue.sky.or.jp>
-
- * ext/zlib/zlib.c: GzipReader#ungetc caused crc error.
-
Thu Aug 19 16:29:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: Fail to treat a hash value of 'font' option.
@@ -27916,15 +15650,17 @@ Thu Aug 19 15:15:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (free_dir): fix memory leak. reported by yamamoto
madoka.
-Thu Aug 19 09:19:27 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Aug 19 11:00:00 2004 Akiyoshi, Masamichi <masamichi.akiyoshi@hp.com>
- * configure.in, win32/Makefile.sub (LIBS): need to link shell32
- library for SH* functions on mswin32 and mingw32.
+ * dln.c (dln_load): Modify to call lib$find_image_symbol for VMS.
+ * io.c (rb_io_fwrite): Use fputc() for VMS non-stream file.
- * wince/Makefile.sub (LIBS): need to link ceshell library for SH*
- functions on mswince.
+Thu Aug 19 06:07:45 2004 why the lucky stiff <why@ruby-lang.org>
-Thu Aug 19 03:07:00 2004 why the lucky stiff <why@ruby-lang.org>
+ * ext/syck/token.c: re2c no longer compiled with bit vectors. caused
+ problems for non-ascii characters. [ruby-core:03280]
+ * ext/syck/implicit.c: ditto.
+ * ext/syck/bytecode.c: ditto.
* lib/yaml/baseemitter.rb: folding now handles double-quoted strings,
fixed problem with extra line feeds at end of folding, whitespace
@@ -27933,9 +15669,9 @@ Thu Aug 19 03:07:00 2004 why the lucky stiff <why@ruby-lang.org>
* lib/yaml/rubytypes.rb: subtelties in handling strings with
non-printable characters and odd whitespace patterns.
-Wed Aug 18 23:44:20 2004 Minero Aoki <aamine@loveruby.net>
+Wed Aug 18 23:41:33 2004 Minero Aoki <aamine@loveruby.net>
- * lib/net/protocol.rb (rbuf_fill): OpenSSL::SSLSocket has its own
+ * lib/net/protocol.rb (rbuf_fill): OpenSSL::SSL::SSLSocket has its own
buffer, select(2) might not work. [ruby-dev:24072]
Wed Aug 18 17:10:12 2004 WATANABE Hirofumi <eban@ruby-lang.org>
@@ -27948,17 +15684,6 @@ Wed Aug 18 12:52:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_obj_instance_eval): evaluates under special singleton
classes as for special constants.
-Wed Aug 18 11:22:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (init_env): initialize HOME and USER environment
- variables unless set.
-
-Wed Aug 18 10:17:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (bind_eval): new method. [RCR 251]
-
- * string.c (rb_str_clear): new method. [ruby-dev:24104]
-
Tue Aug 17 17:20:59 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_reopen): should clear allocated OpenFile. pointed
@@ -27969,19 +15694,23 @@ Tue Aug 17 01:36:32 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/usage.rb: Remove extra indent. Tidy 'ri' option
parsing so RDoc::usage plays better with OptionParser.
+Sat Aug 14 13:09:10 2004 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: backport from CVS HEAD (rev1.44).
+
+ * lib/fileutils.rb: cp_r should copy symlink itself, except cp_r
+ root.
+
+ * lib/fileutils.rb: new option mv :force.
+
+ * lib/fileutils.rb: new module FileUtils::DryRun.
+
Sat Aug 14 02:48:16 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/usage.rb: Added. Allows command line programs
to report usage using their initial RDoc comment.
-Sat Aug 14 01:25:48 2004 why the lucky stiff <why@ruby-lang.org>
-
- * ext/syck/token.c: re2c no longer compiled with bit vectors. caused
- problems for non-ascii characters. [ruby-core:03280]
- * ext/syck/implicit.c: ditto.
- * ext/syck/bytecode.c: ditto.
-
-Fri Aug 13 12:55:20 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Fri Aug 13 13:23:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_range_header):
fix regex for range-spec.
@@ -27990,44 +15719,15 @@ Fri Aug 13 12:55:20 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
(WEBrick::HTTPServlet::DefaultFileHandler#make_partial_content):
multipart/byteranges response was broken.
- * lib/xmlrpc/server.rb: refine example code.
-
-Thu Aug 12 10:54:17 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * rubyio.h (rb_eof_error): should mark as NORETURN.
-
- * win32/win32.c (make_cmdvector): adjust escaped successive
- double-quote handling.
-
-Thu Aug 12 01:53:10 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c (read_buffered_data): extracted from rb_io_fread.
- (io_readpartial): new method IO#readpartial.
- [ruby-dev:24055]
-
-Wed Aug 11 17:17:50 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in (RPATHFLAG): stop setting RPATHFLAG on Interix.
-
-Mon Aug 9 15:03:20 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
* lib/webrick/httpservlet/erbhandler.rb
(WEBrick::HTTPServlet::ERBHandler#do_GET): should select media type
by suffix of script filename.
-Mon Aug 9 12:51:43 2004 Dave Thomas <dave@pragprog.com>
-
- * dir.c (dir_s_glob): Roll in Austin Ziegler's Dir.glob and
- fnmatch updates.
-
-Mon Aug 9 06:33:06 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (cp_r): copies symlink to symlink, except
- root entries of cp_r.
+ * lib/xmlrpc/server.rb: refine example code.
- * lib/fileutils.rb: new method FileUtils.copy_entry.
+Wed Aug 11 17:17:50 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * test/fileutils/test_fileutils.rb: more cp_r tests.
+ * configure.in (RPATHFLAG): stop setting RPATHFLAG on Interix.
Sun Aug 8 00:43:31 2004 why the lucky stiff <why@ruby-lang.org>
@@ -28039,38 +15739,21 @@ Sun Aug 8 00:43:31 2004 why the lucky stiff <why@ruby-lang.org>
collections. plain scalars are trimmed if indentation follows in
an ambiguous flow collection.
-Sat Aug 7 03:08:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * process.c (proc_daemon): new method. should be modified for
- platforms without /dev/null.
-
Sat Aug 7 00:50:01 2004 Tanaka Akira <akr@m17n.org>
* ext/zlib/zlib.c: Zlib::GzipReader#read(0) returns "" instead of nil.
-Wed Aug 4 13:26:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (r_bytes0): optimize out read(0). [ruby-talk:108276]
-
-Tue Aug 3 13:49:12 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Tue Aug 3 13:49:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/namespace.rb: bug fix
* ext/tk/lib/tkextlib/treectrl/tktreectrl.rb: add Tk::TreeCtrl.loupe
-Mon Aug 2 23:33:48 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * test/ruby/test_file.rb (test_fnmatch): added more tests.
-
Mon Aug 2 18:04:21 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/msgcat.rb (set_translation): bug fix (fail to set
trans_str to the same as src_str when trans_str is not given.)
-Mon Aug 2 17:40:44 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (blk_free): fixed serious memory leak. [ruby-dev:24013]
-
Mon Aug 2 11:53:06 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/code_objects.rb (RDoc::Context::find_symbol): Fix infinite recursion
@@ -28081,21 +15764,15 @@ Mon Aug 2 11:48:29 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods): Allow '.'s in
variable names to support SWIG generated files (Hans Fugal)
-Sat Jul 31 23:08:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (is_defined): stupid mistakes fixed. [ruby-dev:24006]
-
-Sat Jul 31 17:39:47 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jul 31 17:40:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-mode.el (ruby-expr-beg, ruby-parse-partial,
ruby-calculate-indent, ruby-move-to-block, ruby-forward-sexp,
ruby-backward-sexp): keywords must match word-wise.
-Sat Jul 31 13:37:51 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Jul 31 05:47:37 2004 why the lucky stiff <why@ruby-lang.org>
- * eval.c (is_defined): avoid unnecessary method invocations.
-
-Sat Jul 31 05:35:37 2004 why the lucky stiff <why@ruby-lang.org>
+ * lib/yaml.rb (YAML::load_file, YAML::parse_file): added.
* lib/yaml/rubytypes.rb: exceptions were using an older
YAML.object_maker. [ruby-core:03080]
@@ -28104,10 +15781,9 @@ Sat Jul 31 05:35:37 2004 why the lucky stiff <why@ruby-lang.org>
handline CR-LFs. "\000" was showing up on folded blocks which
stopped at EOF.
-Sat Jul 31 01:25:11 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (is_defined): call is_defined() before invoking
- rb_eval(). [ruby-talk:107867]
+ * ext/syck/token.c: re2c compiled with bit vectors now.
+ * ext/syck/implicit.c: ditto.
+ * ext/syck/bytecode.c: ditto.
Fri Jul 30 16:10:54 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -28125,26 +15801,8 @@ Wed Jul 28 18:59:17 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi.rb (CGI::initialize): remove at_exit code for CGI_PARAMS
and CGI_COOKIES. they will no longer be used.
-Wed Jul 28 15:44:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_call0): should call rb_call_super() directly for
- visibility overriding. [ruby-dev:23989]
-
Wed Jul 28 01:04:44 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * env.h: remove argv from ruby_frame.
-
- * eval.c (rb_eval): no more copy on write.
-
- * eval.c (assign): ditto.
-
- * eval.c (rb_call0): can receive *rest by specifying negative
- argc. (-1 means 0 arg and *rest, -2 means 1 arg and *rest...)
-
- * eval.c (rb_call0): properly set frame's argc counter.
-
- * gc.c (rb_gc_mark_frame): need not to mark frame's argv
-
* gc.c (run_final): wrong order of data. [ruby-dev:23984]
Tue Jul 27 07:05:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -28165,13 +15823,11 @@ Mon Jul 26 11:22:55 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httputils.rb (WEBrick::HTTPUtils.escape): should
escape space.
-Sun Jul 25 10:56:28 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Sun Jul 25 11:05:21 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* win32/win32.{h,c} (rb_w32_{f,fd,fs}open): workaround for bcc32's
{f,fd,fs}open bug. set errno EMFILE and EBADF. [ruby-dev:23963]
- * test/drb/drbtest.rb: fix method duplication.
-
Sat Jul 24 13:32:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (rb_range_beg_len): returns Qnil only when "beg" points
@@ -28182,24 +15838,37 @@ Fri Jul 23 16:40:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (define_final): should not disclose NODE* to Ruby world.
[ruby-dev:23957]
-Fri Jul 23 08:52:22 2004 Shugo Maeda <shugo@ruby-lang.org>
+Fri Jul 23 09:03:16 2004 Shugo Maeda <shugo@ruby-lang.org>
- * lib/net/imap.rb (disconnected?): new method.
+ * lib/net/imap.rb (disconnected?): new method. (backported from HEAD)
Thu Jul 22 16:41:54 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi/session.rb (CGI::Session::FileStore#update): sets the
- permission of the session data file to 0600.
+ permission of the session data file to 0600.
* lib/cgi/session/pstore.rb (CGI::Session::Pstore#initialize):
ditto.
-Mon Jul 19 00:53:46 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Jul 22 00:02:21 2004 Masahiro Kitajima <katonbo@katontech.com>
+
+ * process.c (rb_f_system): not need to call last_status_set() any
+ longer on _WIN32.
+
+Tue Jul 20 09:15:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * test/fileutils/test_fileutils.rb: File.link raises EINVAL on BeOS.
+
+Mon Jul 19 01:15:07 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpservlet/cgihandler.rb
(WEBrick::HTTPServlet::CGIhandler#do_GET): set SystemRoot environment
variable to CGI process on Windows native platforms. [ruby-dev:23936]
+ * lib/webrick/httpservlet/cgihandler.rb
+ (WEBrick::HTTPServlet::CGIhandler#do_GET): use $?.exitstatus and
+ refine log message.
+
Sun Jul 18 16:14:29 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/msgcat.rb (TkMsgCatalog.callback): bug fix
@@ -28209,19 +15878,18 @@ Sun Jul 18 08:13:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_f_sprintf): remove extra sign digit.
-Sun Jul 18 03:19:14 2004 Akinori MUSHA <knu@iDaemons.org>
+Sun Jul 18 03:21:42 2004 Akinori MUSHA <knu@iDaemons.org>
- * dir.c (bracket): use NULL instead of 0.
+ * dir.c (range): use NULL instead of 0.
-Sun Jul 18 02:35:30 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb (receive_responses): return if a LOGOUT response
- received.
+ * dir.c (range): get rid of a gcc 3.4 warning.
-Sat Jul 17 23:59:01 2004 Shugo Maeda <shugo@ruby-lang.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)
* lib/net/imap.rb (send_string_data): wait command continuation
- requests before sending octet data of literals.
+ requests before sending octet data of literals. (backported from HEAD)
Sat Jul 17 23:54:59 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -28235,14 +15903,6 @@ Sat Jul 17 18:29:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt): not to show same error messages twice.
-Sat Jul 17 14:18:11 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_match_m): String#match should also take
- optional argument. [ruby-core:03205]
-
- * re.c (rb_reg_match_m): add optional second argugment "pos" to
- specify match start point. [ruby-core:03203]
-
Sat Jul 17 13:13:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/irb/ruby-lex.rb (RubyLex::identify_string): %s string do not
@@ -28250,7 +15910,7 @@ Sat Jul 17 13:13:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
Sat Jul 17 05:26:27 2004 Dave Thomas <dave@pragprog.com>
- * lib/rdoc/diagram.rb: Incorporate Micheal Neumann's
+ * lib/rdoc/diagram.rb: Incorporate Micheal Neuman's
client-side imagemao patch
Sat Jul 17 01:57:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -28263,6 +15923,24 @@ Fri Jul 16 22:30:28 2004 Michael Neumann <mneumann@ntecs.de>
* file.c (rb_stat_dev_major): new methods File::Stat#dev_major and
#dev_minor. [ruby-core:03195]
+Fri Jul 16 15:23:53 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (return_jump, break_jump): raise unexpceted local jump
+ exception directly. [ruby-dev:23740]
+
+ * lib/base64.rb (Deprecated): super in bound method calls original
+ name method in stable version. [ruby-dev:23916]
+
+Fri Jul 16 11:31:49 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * lib/test/unit/ui/{fox,gtk,gtk2}/testrunner.rb: remove
+ garbage (patch from akira yamada) [ruby-dev:23911]
+
+Fri Jul 16 11:20:00 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * sprintf.c (rb_f_sprintf): fix output of NaN, Inf and -Inf with
+ "%f" or etc on MSVCRT platforms. (backported from HEAD)
+
Fri Jul 16 11:17:38 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (exit_initialize): use EXIT_SUCCESS instead of 0.
@@ -28282,19 +15960,13 @@ 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.
-
-Thu Jul 15 20:44:46 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * class.c: rdoc patch
+ termcap. (backported from HEAD)
-Thu Jul 15 14:12:34 2004 why the lucky stiff <why@ruby-lang.org>
+Thu Jul 15 20:29:15 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/yaml.rb (YAML::load_file, YAML::parse_file): added.
-
- * ext/syck/token.c: re2c compiled with bit vectors now.
- * ext/syck/implicit.c: ditto.
- * ext/syck/bytecode.c: ditto.
+ * class.c, error.c, eval.c, intern.h, object.c, variable.c:
+ do not set path if it is a singleton class. [ruby-dev:22588]
+ (backport from 1.9)
Thu Jul 15 10:15:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -28320,13 +15992,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 23:49:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * enum.c (enum_min_by): new method Enum#min_by. added Enum#max_by
- as well.
-
-Wed Jul 14 18:05:21 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Wed Jul 14 18:08:37 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1cons_to_der): fix type of
argument. [ruby-dev:23891]
@@ -28334,14 +16000,14 @@ Wed Jul 14 18:05:21 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_x509store.rb: prune tests for CRL checking
unless X509::V_FLAG_CRL_CHECK is defined.
-Wed Jul 14 12:20:05 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jul 14 12:29:07 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* util.c (ruby_strtod): should not convert string in the form of
"-I.FE-X" which both "I" and "F" are ommitted. [ruby-dev:23883]
* test/ruby/test_float.rb (test_strtod): add test for bug fix.
-Wed Jul 14 00:33:48 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jul 14 00:31:15 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* array.c: rdoc patch. merged patch from Johan Holmberg
<holmberg@iar.se> [ruby-core:3170]
@@ -28356,7 +16022,7 @@ Tue Jul 13 19:39:12 2004 akira yamada <akira@ruby-lang.org>
* test/uri/test_generic.rb (TestGeneric#test_merge): added tests.
-Tue Jul 13 15:48:56 2004 Akinori MUSHA <knu@iDaemons.org>
+Tue Jul 13 15:51:45 2004 Akinori MUSHA <knu@iDaemons.org>
* lib/mkmf.rb (init_mkmf): Do not add $(libdir) to $LIBPATH in
extmk mode.
@@ -28368,14 +16034,14 @@ Tue Jul 13 00:50:48 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb: Support call-seq: for Ruby files.
-Mon Jul 12 21:20:51 2004 Dave Thomas <dave@pragprog.com>
+Mon Jul 12 21:20:36 2004 Dave Thomas <dave@pragprog.com>
* html_generator.rb: Support hyperlinks of the form {any text}[xxx]
as well as stuff[xxx]
Sat Jul 10 09:30:24 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * test/soap/marshal/test_struct.rb: use qualified built-in class name
+ * test/soap/marshal/test_struct.rb: use qualified build-tin class name
(::Struct) to avoid name crash.
Sat Jul 10 04:21:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
@@ -28390,7 +16056,7 @@ Sat Jul 10 04:21:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
function of Tk::ValidateConfigure to define validatecommand
methods easier
-Fri Jul 9 22:18:59 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri Jul 9 22:36:36 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* array.c, enum.c, pack.c: rdoc patch from Johan Holmberg
<holmberg@iar.se> [ruby-core:3132] [ruby-core:3136]
@@ -28410,33 +16076,36 @@ Fri Jul 9 14:28:54 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
Fri Jul 9 01:47:08 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/lib: bug fix
- * ext/tk/lib/tkextlib/itcl: add [incr Tcl] support
- * ext/tk/lib/tkextlib/itk: add [incr Tk] support
- * ext/tk/lib/tkextlib/iwidgets: midway point of [incr Widgets] support
- * ext/tk/sample/tkextlib/iwidgets: very simple examples of
+ * ext/tk/lib : bug fix
+ * ext/tk/lib/tkextlib/itcl : add [incr Tcl] support
+ * ext/tk/lib/tkextlib/itk : add [incr Tk] support
+ * ext/tk/lib/tkextlib/iwidgets : midway point of [incr Widgets] support
+ * ext/tk/sample/tkextlib/iwidgets : very simple examples of
[incr Widgets]
-Thu Jul 8 19:27:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (rb_cv_stack_end_address): detect stack end address
- variable supplied by system. [ruby-core:03115]
+Thu Jul 8 22:52:19 2004 Kouhei Sutou <kou@cozmixng.org>
- * gc.c (Init_stack): use system provided address if possible.
+ * lib/rss/{rss,parser,0.9,1.0,2.0}.rb: supported RSS 0.9x/2.0
+ validation and validation which disregard order of elements.
+ * test/rss/test_parser.rb: added tests for RSS 0.9x/2.0
+ validation.
+ * test/rss/{test_trackback,rss-testcase}.rb: fixed no good method
+ name.
Thu Jul 8 00:05:23 2004 akira yamada <akira@ruby-lang.org>
* lib/tempfile.rb (Tempfile::initialize): got out code of
generating tmpname. [ruby-dev:23832][ruby-dev:23837]
-Wed Jul 7 02:31:41 2004 Kouhei Sutou <kou@cozmixng.org>
+Wed Jul 7 15:53:14 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/rss/{rss,parser,0.9,1.0,2.0}.rb: supported RSS 0.9x/2.0
- validation and validation which disregard order of elements.
- * test/rss/test_parser.rb: added tests for RSS 0.9x/2.0
- validation.
- * test/rss/{test_trackback,rss-testcase}.rb: fixed no good method
- name.
+ * string.c (rb_str_match): raise TypeError when both arguments are
+ strings. [ruby-dev:22869] (backported from HEAD)
+
+ * string.c (rb_str_match2): removed.
+
+ * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
+ wince/Makefile.sub (string.c): now not depend on version.h.
Wed Jul 7 00:48:34 2004 WATANABE Hirofumi <eban@ruby-lang.org>
@@ -28445,7 +16114,7 @@ Wed Jul 7 00:48:34 2004 WATANABE Hirofumi <eban@ruby-lang.org>
Tue Jul 6 18:38:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/lib: improve framework of developping Tcl/Tk extension
+ * ext/tk/lib : improve framework of developping Tcl/Tk extension
wrappers
Mon Jul 5 23:56:42 2004 Kouhei Sutou <kou@cozmixng.org>
@@ -28464,7 +16133,7 @@ Mon Jul 5 09:02:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_yield, rb_f_catch): 4th argument to rb_yield_0()
is a set of bit flags. [ruby-dev:23859]
-Mon Jul 5 01:20:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Jul 5 01:27:32 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/drb/drb.rb(DRbConn self.open): If socket pool is full, close
the socket whose last-access-time is oldest. (and add new one)
@@ -28474,10 +16143,12 @@ Sun Jul 4 12:24:50 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb: added copyright header.
-Sat Jul 3 22:25:27 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Sun Jul 4 00:24:40 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * added files:
- * lib/soap/header/*
+ * added files
+ * lib/soap/attachment.rb
+ * lib/soap/header
+ * lib/soap/mimemessage.rb
* lib/soap/rpc/httpserver.rb
* lib/wsdl/soap/cgiStubCreator.rb
* lib/wsdl/soap/classDefCreator.rb
@@ -28491,29 +16162,36 @@ Sat Jul 3 22:25:27 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/wsdl/xmlSchema/enumeration.rb
* lib/wsdl/xmlSchema/simpleRestriction.rb
* lib/wsdl/xmlSchema/simpleType.rb
- * lib/xsd/codegen/*
+ * lib/xsd/codegen
* lib/xsd/codegen.rb
- * sample/soap/authheader/*
- * sample/soap/raa2.4/*
- * sample/soap/ssl/*
- * sample/soap/swa/*
+ * sample/soap/authheader
+ * sample/soap/raa2.4
+ * sample/soap/ssl
+ * sample/soap/swa
* sample/soap/whois.rb
- * sample/wsdl/raa2.4/*
- * test/soap/header/*
- * test/soap/ssl/*
- * test/soap/struct/*
- * test/soap/swa/*
- * test/soap/wsdlDriver/*
+ * sample/soap/calc/samplehttpd.conf
+ * sample/soap/exchange/samplehttpd.conf
+ * sample/soap/sampleStruct/samplehttpd.conf
+ * sample/wsdl/raa2.4
+ * sample/wsdl/googleSearch/samplehttpd.conf
+ * test/openssl/_test_ssl.rb
+ * test/soap/header
+ * test/soap/ssl
+ * test/soap/struct
+ * test/soap/swa
+ * test/soap/wsdlDriver
* test/wsdl/multiplefault.wsdl
- * test/wsdl/simpletype/*
+ * test/wsdl/simpletype
* test/wsdl/test_multiplefault.rb
- * modified files:
+ * modified files
* lib/soap/baseData.rb
* lib/soap/element.rb
* lib/soap/generator.rb
+ * lib/soap/marshal.rb
* lib/soap/netHttpClient.rb
* lib/soap/parser.rb
+ * lib/soap/processor.rb
* lib/soap/property.rb
* lib/soap/soap.rb
* lib/soap/streamHandler.rb
@@ -28528,6 +16206,7 @@ Sat Jul 3 22:25:27 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/soap/mapping/wsdlRegistry.rb
* lib/soap/rpc/cgistub.rb
* lib/soap/rpc/driver.rb
+ * lib/soap/rpc/element.rb
* lib/soap/rpc/proxy.rb
* lib/soap/rpc/router.rb
* lib/soap/rpc/soaplet.rb
@@ -28544,12 +16223,26 @@ Sat Jul 3 22:25:27 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/wsdl/xmlSchema/schema.rb
* lib/xsd/datatypes.rb
* lib/xsd/qname.rb
+ * sample/soap/calc/httpd.rb
+ * sample/soap/exchange/httpd.rb
+ * sample/soap/sampleStruct/httpd.rb
* sample/soap/sampleStruct/server.rb
* sample/wsdl/amazon/AmazonSearch.rb
* sample/wsdl/amazon/AmazonSearchDriver.rb
+ * sample/wsdl/googleSearch/httpd.rb
+ * test/soap/test_basetype.rb
* test/soap/test_property.rb
+ * test/soap/test_streamhandler.rb
+ * test/soap/calc/test_calc.rb
+ * test/soap/calc/test_calc2.rb
* test/soap/calc/test_calc_cgi.rb
+ * test/soap/helloworld/test_helloworld.rb
* test/wsdl/test_emptycomplextype.rb
+ * test/wsdl/axisArray/test_axisarray.rb
+ * test/wsdl/datetime/test_datetime.rb
+ * test/wsdl/raa/test_raa.rb
+ * test/xsd/test_xmlschemaparser.rb
+ * test/xsd/test_xsd.rb
* summary
* add SOAP Header mustUnderstand support.
@@ -28564,33 +16257,34 @@ Sat Jul 3 22:25:27 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* add WSDL simpleType support to restrict lexical value space.
+ * add SOAP with Attachment support.
+
Sat Jul 3 17:19:44 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/tk/lib/tkextlib/tkDND.rb: fix syntax error.
-Thu Jul 1 18:36:08 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Thu Jul 1 23:15:29 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/tk/lib/tcltklib: bug fix
+ * lib/pstore.rb (transaction): safer backup scheme. [ruby-list:39102]
- * ext/tk/lib/tk: bug fix and add Tcl/Tk extension support libraries
+ * lib/pstore.rb (commit_new): use FileUtils.copy_stream for Cygwin.
+ [ruby-dev:23157]
-Thu Jul 1 18:31:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/pstore.rb (transaction): allow overriding dump and load.
+ [ruby-dev:23567]
* lib/pstore.rb (PStore#transaction): get rid of opening in write mode
when read only transaction. [ruby-dev:23842]
-Thu Jul 1 00:44:42 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * lib/yaml/store.rb: follow lib/pstore.rb's change.
- * ext/openssl/ossl_cipher.c (ossl_cipher_encrypt, ossl_cipher_decrypt):
- re-implemnt (the arguments for this method is ).
+Thu Jul 1 18:36:08 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/openssl/ossl_cipher.c (ossl_cipher_pkcs5_keyivgen): new method
- OpenSSL::Cipher::Cipher#pkcs5_keyivgen. it calls EVP_BytesToKey().
+ * ext/tk/lib/tcltklib : bug fix
- * ext/openssl/ossl_cipher.c (ossl_cipher_set_key_length): new method
- OpenSSL::Cipher::Cipher#key_len=.
+ * ext/tk/lib/tk : bug fix and add Tcl/Tk extension support libraries
-Wed Jun 30 19:48:09 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Jul 1 11:59:45 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: check for EVP_CIPHER_CTX_copy, ENGINE_add,
EVP_CIPHER_CTX_set_padding, EVP_CipherFinal_ex, EVP_CipherInit_ex,
@@ -28602,17 +16296,23 @@ Wed Jun 30 19:48:09 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
EVP_CipherInit_ex, EVP_CipherFinal_ex, HMAC_Init_ex): new macro for
OpenSSL 0.9.6.
+ * ext/openssl/ossl_cipher.c (ossl_cipher_encrypt, ossl_cipher_decrypt):
+ re-implemnt (the arguments for this method is ).
+
+ * ext/openssl/ossl_cipher.c (ossl_cipher_pkcs5_keyivgen): new method
+ OpenSSL::Cipher::Cipher#pkcs5_keyivgen. it calls EVP_BytesToKey().
+
* ext/openssl/ossl_cipher.c (ossl_cipher_alloc, ossl_cipher_initialize,
- ossl_cipher_copy, ossl_cipher_reset, ossl_cipher_encrypt,
- ossl_cipher_decrypt, ossl_cipher_final, ossl_cipher_set_key,
- ossl_cipher_set_iv): replace all EVP_CipherInit and
- EVP_CipherFinal into EVP_CipherInit_ex and EVP_CipherFinal_ex.
+ ossl_cipher_copy, ossl_cipher_reset ossl_cipher_final,
+ ossl_cipher_set_key, ossl_cipher_set_iv): replace all EVP_CipherInit
+ and EVP_CipherFinal into EVP_CipherInit_ex and EVP_CipherFinal_ex.
and EVP_CIPHER_CTX_init should only be called once.
- * ext/openssl/ossl_cipher.c (ossl_cipher_set_padding): check for
- EVP_CIPHER_CTX_set_padding.
+ * ext/openssl/ossl_cipher.c (ossl_cipher_set_key_length): new method
+ OpenSSL::Cipher::Cipher#key_len=.
- * ext/openssl/ossl_cipher.c (Init_ossl_cipher): Cipher#<< is deprecated.
+ * ext/openssl/ossl_cipher.c (ossl_cipher_init_deprecated): new
+ finction; print warning for Cipher#<<.
* ext/openssl/ossl_digest.c: replace all EVP_DigestInit and
EVP_DigestFinal into EVP_DigestInit_ex and EVP_DigestFinal_ex.
@@ -28630,16 +16330,50 @@ Wed Jun 30 19:48:09 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_cipher.rb, test/openssl/test_digest.rb,
test/openssl/test_hmac.rb: new file.
-Wed Jun 30 16:59:39 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Thu Jul 1 04:08:30 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_asn1.c (ossl_i2d_ASN1_TYPE, ossl_ASN1_TYPE_free):
+ workaround for the versions earlier than OpenSSL-0.9.7.
+
+Thu Jul 1 03:33:55 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_pkey_dh.c (ossl_dh_initialize): should create
+ empty pkey object if no argument is passed. [ruby-talk:103328]
- * test/ruby/test_file.rb (test_fnmatch): some tests for File.fnmatch
- are added.
+ * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize): ditto.
+
+ * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_initialize): ditto.
+
+ * ext/openssl/ossl_pkey_dh.c: add new methods: OpenSSL::PKey::DH#p,
+ OpenSSL::PKey::DH#p=, OpenSSL::PKey::DH#g, OpenSSL::PKey::DH#g=,
+ OpenSSL::PKey::DH#pub_key, OpenSSL::PKey::DH#pub_key=,
+ OpenSSL::PKey::DH#priv_key and OpenSSL::PKey::DH#priv_key=.
+
+ * ext/openssl/ossl_pkey_dsa.c: add new methods: OpenSSL::PKey::DSA#p,
+ OpenSSL::PKey::DSA#p=, OpenSSL::PKey::DSA#q, OpenSSL::PKey::DSA#q=,
+ OpenSSL::PKey::DSA#g, OpenSSL::PKey::DSA#g=,
+ OpenSSL::PKey::DSA#pub_key, OpenSSL::PKey::DSA#pub_key=,
+ OpenSSL::PKey::DSA#priv_key and OpenSSL::PKey::DSA#priv_key=.
+
+Thu Jul 1 03:16:09 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_ssl.c (ossl_ssl_read): take optional second argument
+ to specify a string to be written.
+
+ * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#read):
+ take optional second argument to specify a string to be written.
+
+ * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#gets):
+ refine regexp for end-of-line.
+
+ * ext/opnessl/lib/openssl/ssl.rb
+ (OpenSSL::SSL::SocketForwarder#listen): fix typo.
Wed Jun 30 11:38:51 2004 Mikael Brockman <phubuh@phubuh.org>
* parse.y (primary): should not be NULL. [ruby-core:03098]
-Wed Jun 30 02:41:10 2004 why the lucky stiff <why@ruby-lang.org>
+Wed Jun 30 02:53:24 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/rubyext.c (syck_emitter_new): set buffer after
Data_Wrap_Struct to avoid possible GC. [ruby-talk:104835]
@@ -28659,107 +16393,80 @@ Mon Jun 28 14:57:56 2004 Jeff Mitchell <quixoticsycophant@yahoo.com>
* configure.in, lib/mkmf.rb (LIBPATHFLAG): use double quotes due to
DOSISH compilers. [ruby-core:03107]
-Mon Jun 28 00:35:29 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Mon Jun 28 00:30:19 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* sample/drb/*.rb: using 'DRb.thread.join' instead of 'gets'
-Sun Jun 27 22:36:47 2004 Kouhei Sutou <kou@cozmixng.org>
+Sun Jun 27 22:39:51 2004 Kouhei Sutou <kou@cozmixng.org>
* sample/rss/tdiary_plugin/rss-recent.rb: supported Hiki.
-Sat Jun 26 15:17:11 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Jun 27 12:19:46 2004 Kouhei Sutou <kou@cozmixng.org>
- * variable.c (rb_mod_class_variables): class variables are no longer
- inherited. [ruby-dev:23808]
+ * {lib,sample,test}/rss: added RSS Parser. [ruby-dev:23780]
-Sat Jun 26 11:07:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jun 26 11:07:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (aix): -b must come at the start of the command line,
and -e must not appear while testing libraries. [ruby-talk:104501]
- * lib/mkmf.rb (find_header, dir_config): quote directory names if
- necessary. [ruby-talk:104505]
+ * lib/mkmf.rb (dir_config): quote directory names if necessary.
+ [ruby-talk:104505]
-Sat Jun 26 00:13:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jun 25 15:33:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_fopen, rb_fdopen, rb_io_reopen): setvbuf() may return
- positive value on failure. [ruby-dev:23792]
+ * ext/iconv/extconf.rb: check stricter. [ruby-talk:104501]
-Fri Jun 25 18:07:15 2004 Michal Rokos <michal@ruby-lang.org>
+ * ext/iconv/extconf.rb: include iconv.h for libiconv. [ruby-dev:22715]
- * gc.c: bring back _stklen for DJGPP [ruby-core:3084]
+Fri Jun 25 08:31:29 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Jun 25 15:33:01 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_thread_atfork): remove "fork terminates thread"
+ warning. [ruby-dev:23768]
- * ext/iconv/extconf.rb: check stricter. [ruby-talk:104501]
+ * object.c (rb_obj_clone): backport FL_FINALIZE patch from 1.9.
+ [ruby-core:02786][ruby-core:03067]
-Fri Jun 25 01:58:01 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+ * ext/socket/socket.c (sock_sockaddr): Socket#gethostbyname()
+ should give us packed address, not struct sockaddr.
+ [ruby-core:03053]
+
+Fri Jun 25 02:04:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* {bcc32,win32,wince}/setup.mak: remove RUBY_EXTERN lines when
- including version.h. [ruby-talk:104456]
+ including version.h. [ruby-talk:104456] (backported from HEAD)
Thu Jun 24 14:23:29 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (rb_io_fread): return already read data when system call is
interrupted. [ruby-talk:97206]
-Thu Jun 24 01:25:21 2004 Shugo Maeda <shugo@ruby-lang.org>
+Thu Jun 24 01:32:43 2004 Shugo Maeda <shugo@ruby-lang.org>
* version.h: added declarations of ruby_version,
ruby_release_date, ruby_platform.
+ (backported from HEAD)
-Thu Jun 24 01:07:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (sock_sockaddr): Socket#gethostbyname()
- should give us packed address, not struct sockaddr.
- [ruby-core:03053]
-
-Wed Jun 23 22:19:10 2004 Dave Thomas <dave@pragprog.com>
+Wed Jun 23 22:23:37 2004 Dave Thomas <dave@pragprog.com>
* ext/socket/socket.c (sock_s_gethostbyaddr): Work around problem
with OS X not returning 'from' parameter to recvfrom for
connection-oriented sockets.
-Wed Jun 23 22:16:16 2004 Michal Rokos <michal@ruby-lang.org>
-
- * io.c: io_seek()'s retval should be checked [ruby-core:03045]
-
-Wed Jun 23 21:48:27 2004 Michal Rokos <michal@ruby-lang.org>
-
- * time.c: Fix indentation.
-
- * main.c: Remove _stklen, and _CRT_glob. Move _stacksize for
- __human68k__ to gc.c where the others are.
-
- * gc.c: put _stacksize in place and clean the #ifdefs macros.
-
-Wed Jun 23 17:37:54 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb: added new option --ssl.
-
Wed Jun 23 01:45:27 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RubyLex::identify_quotation):
Fix problem with the 'r' being dropped from %r{xxx}
-Wed Jun 23 00:10:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Jun 23 00:20:20 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/win32ole/win32ole.c (ole_hresult2msg): remove trailing
CRs and LFs. (doesn't depend on CR+LF) [ruby-dev:23749]
Wed Jun 23 00:00:25 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (return_jump, break_jump): raise unexpected local jump
- exception directly. [ruby-dev:23740]
-
* io.c (rb_io_initialize): should check fcntl result. [ruby-dev:23742]
-Tue Jun 22 23:35:43 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * sprintf.c (rb_f_sprintf): support FZERO and FSPACE with NaN/Inf.
-
- * test/ruby/test_sprintf.rb (test_nan, test_inf): add tests.
-
Tue Jun 22 21:11:36 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (OLE_FREE): should not call CoFreeUnuse-
@@ -28770,56 +16477,21 @@ Tue Jun 22 21:11:36 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_hresult2msg): truncate error message
before CR.
-Tue Jun 22 19:24:59 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * sprintf.c (rb_f_sprintf): unify output of NaN, Inf and -Inf with
- "%f" or etc on all platform. [ruby-dev:23704], [ruby-dev:23747]
-
-Tue Jun 22 15:28:12 2004 Michal Rokos <michal@ruby-lang.org>
-
- * compar.c: Remove explicit NIL_P() checks since rb_cmpint() does it
- again in the exactly same manner.
-
-Tue Jun 22 01:32:40 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_pkey_dh.c (ossl_dh_initialize): should create
- empty pkey object if no argument is passed. [ruby-talk:103328]
-
- * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize): ditto.
-
- * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_initialize): ditto.
-
- * ext/openssl/ossl_pkey_dh.c: add new methods: OpenSSL::PKey::DH#p,
- OpenSSL::PKey::DH#p=, OpenSSL::PKey::DH#g, OpenSSL::PKey::DH#g=,
- OpenSSL::PKey::DH#pub_key, OpenSSL::PKey::DH#pub_key=,
- OpenSSL::PKey::DH#priv_key and OpenSSL::PKey::DH#priv_key=.
-
- * ext/openssl/ossl_pkey_dsa.c: add new methods: OpenSSL::PKey::DSA#p,
- OpenSSL::PKey::DSA#p=, OpenSSL::PKey::DSA#q, OpenSSL::PKey::DSA#q=,
- OpenSSL::PKey::DSA#g, OpenSSL::PKey::DSA#g=,
- OpenSSL::PKey::DSA#pub_key, OpenSSL::PKey::DSA#pub_key=,
- OpenSSL::PKey::DSA#priv_key and OpenSSL::PKey::DSA#priv_key=.
-
-Mon Jun 21 09:24:51 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jun 22 16:47:42 2004 Shugo Maeda <shugo@ruby-lang.org>
- * win32/win32.c (rb_w32_opendir): should set errno if error occurs
- when calling OS API.
+ * lib/net/ftp.rb (MDTM_REGEXP): fix for demon's ftp server.
+ Thanks, Rutger Nijlunsing.
-Sun Jun 20 21:12:54 2004 Shugo Maeda <shugo@ruby-lang.org>
+Mon Jun 21 10:19:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/net/ftp.rb (binary=): send TYPE commands only once.
+ * win32/win32.c (rb_w32_opendir): use FindFirstFile()/FindNextFile()/
+ FindClose() instead of _findfirst()/_findnext()/_findclose().
+ merge from HEAD.
-Sat Jun 19 13:27:01 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jun 19 13:24:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (method_call): allow changing $SAFE. [ruby-dev:23713]
- * eval.c (proc_set_safe_level, proc_invoke, rb_mod_define_method): not
- set $SAFE for methods defined from Proc. [ruby-dev:23697]
-
-Sat Jun 19 01:10:12 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * sample/rss/tdiary_plugin/rss-recent.rb: added more information.
-
Fri Jun 18 23:12:22 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (proc_save_safe_level, rb_set_safe_level, safe_setter): limit
@@ -28830,27 +16502,10 @@ Wed Jun 16 23:05:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_mod_freeze): prepare string representation before
freezing. [ruby-talk:103646]
-Wed Jun 16 19:57:24 2004 Michal Rokos <michal@ruby-lang.org>
-
- * test/ruby/test_array.rb: extend testcase to check #first, #last,
- #shift, #unshift, #pop, #push
-
-Wed Jun 16 16:05:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (ary_new): move alloc behind checks. [ruby-core:02982]
-
- * array.c (rb_ary_pop_m, rb_ary_shift_m): take arg to behave as push
- and unshift.
-
- * array.c (rb_ary_first, rb_ary_last): make shared array for result
- array, and correct doc for Array#first(n) and Array#last(n)
-
- * array.c (rb_ary_select): not accept any arg.
+Wed Jun 16 16:04:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jun 16 16:03:59 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * object.c (rb_class_inherited_p): singleton class inherits Class
- rather than its object's class. [ruby-dev:23690]
+ * object.c (rb_mod_le): singleton class inherits Class rather than its
+ object's class. [ruby-dev:23690]
Wed Jun 16 16:01:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -28885,36 +16540,31 @@ Sun Jun 13 00:23:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/menubar?.rb: [add] sample of menu_spec usage
-Sat Jun 12 14:15:20 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c: RDOC for File::FNM_CASEFOLD was missed.
-
Sat Jun 12 11:15:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (target_os): strip -gnu suffix on Linux.
-Fri Jun 11 22:08:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Jun 11 17:08:21 2004 Akinori MUSHA <knu@iDaemons.org>
- * array.c: remove #indexes, #indices.
+ * config.guess: Restore a wrongly removed hyphen.
- * hash.c: ditto.
+Fri Jun 11 14:30:08 2004 Akinori MUSHA <knu@iDaemons.org>
- * ext/dbm/dbm.c: remove #indexes, #indices, "values_at" warning
- from #select.
+ * config.guess: Attempt to avoid system name change on
+ Darwin platforms also.
- * ext/gdbm/gdbm.c: ditto.
+Fri Jun 11 14:22:45 2004 Akinori MUSHA <knu@iDaemons.org>
- * ext/sdbm/init.c: ditto.
-
- * ext/dbm/dbm.c (Init_dbm): set VERSION constant as "unknown" when
- DB_VERSION_STRING is not available.
+ * config.guess, config.sub: Attempt to avoid system name change on
+ Linux platforms. We have been using "linux" instead of
+ "linux-gnu" on this branch.
Thu Jun 10 19:19:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/sdbm/init.c (fsdbm_store): sdbm should use StringValue().
[ruby-talk:103062]
-Wed Jun 9 16:09:01 2004 akira yamada <akira@ruby-lang.org>
+Wed Jun 9 18:04:14 2004 akira yamada <akira@ruby-lang.org>
* lib/uri/generic.rb (URI::Generic::merge,
URI::Generic::route_from): accepts non-hierarchical URI.
@@ -28923,18 +16573,12 @@ Wed Jun 9 16:09:01 2004 akira yamada <akira@ruby-lang.org>
* test/uri/test_generic.rb (TestGeneric::test_route,
TestGeneric::test_merge): added tests for above changes.
-Wed Jun 9 15:39:55 2004 Akinori MUSHA <knu@iDaemons.org>
-
- * configure.in: Add support for DragonFly BSD.
-
-Wed Jun 9 15:07:06 2004 Akinori MUSHA <knu@iDaemons.org>
+Wed Jun 9 17:39:37 2004 Akinori MUSHA <knu@iDaemons.org>
* config.guess, config.sub: Update to a more recent version as of
2004-01-20.
-Wed Jun 9 11:20:05 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c: remove unused functions and variables.
+ * configure.in: Add support for DragonFly BSD.
Wed Jun 2 20:16:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -28952,43 +16596,82 @@ Fri May 28 11:20:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (eval): reverted wrongly removed condition. [ruby-dev:23638]
-Thu May 27 21:37:50 2004 Tanaka Akira <akr@m17n.org>
+Thu May 27 23:15:18 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * lib/pathname.rb (Pathname#initialize): fix pathname initialization
- by pathname.
-
-Thu May 27 20:02:09 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * lib/logger.rb: leading 0 padding of timestamp usec part.
- * io.c (rb_io_fwrite): check all case errno != 0 [ruby-dev:23648]
+ * lib/csv.rb (CSV.parse): [CAUTION] behavior changed. in the past,
+ CSV.parse accepts a filename to be read-opened (it was just a
+ shortcut of CSV.open(filename, 'r')). now CSV.parse accepts a
+ string or a stream to be parsed e.g.
+ CSV.parse("1,2\n3,r") #=> [['1', '2'], ['3', '4']]
-Thu May 27 15:54:02 2004 Shugo Maeda <shugo@ruby-lang.org>
+ * lib/csv.rb: CSV::Row and CSV::Cell are deprecated. these classes
+ are removed in the future. in the new csv.rb, row is represented
+ as just an Array. since CSV::Row was a subclass of Array, it won't
+ hurt almost all programs except one which depended CSV::Row#match.
+ and a cell is represented as just a String or nil(NULL). this
+ change will cause widespread destruction.
- * lib/net/ftp.rb (MDTM_REGEXP): fix for demon's ftp server.
- Thanks, Rutger Nijlunsing.
+ CSV.open("foo.csv", "r") do |row|
+ row.each do |cell|
+ if cell.is_null # using Cell#is_null
+ p "(NULL)"
+ else
+ p cell.data # using Cell#data
+ end
+ end
+ end
-Thu May 27 14:53:13 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+ must be just;
- * io.c (rb_io_fwrite): workaround for bcc32's fwrite bug.
- add errno checking. [ruby-dev:23627]
+ CSV.open("foo.csv", "r") do |row|
+ row.each do |cell|
+ if cell.nil?
+ p "(NULL)"
+ else
+ p cell
+ end
+ end
+ end
- * io.c (rb_io_fwrite): should check if errno == ENOENT, too.
+ * lib/csv.rb: [CAUTION] record separator(CR, LF, CR+LF) behavior
+ change. CSV.open, CSV.parse, and CSV,generate now do not force
+ opened file binmode. formerly it set binmode explicitly.
-Thu May 27 11:25:03 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+ with CSV.open, binmode of opened file depends the given mode
+ parameter "r", "w", "rb", and "wb". CSV.parse and CSV.generate open
+ file with "r" and "w".
- * test/csv/test_csv.rb: illegal require module name (../lib/csv.rb).
+ setting mode properly is user's responsibility now.
-Wed May 26 23:12:13 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+ * lib/csv.rb: accepts String as a fs (field separator/column separator)
+ and rs (record separator/row separator)
* lib/csv.rb (CSV.read, CSV.readlines): added. works as IO.read and
IO.readlines in CSV format.
- * lib/csv.rb (CSV.parse): [CAUTION] behavior changed. in the past,
- CSV.parse accepts a filename to be read-opened (it was just a
- shortcut of CSV.open(filename, 'r')). now CSV.parse accepts a
- string or a stream to be parsed e.g.
- CSV.parse("1,2\n3,r") #=> [['1', '2'], ['3', '4']]
+ * lib/csv.rb: added CSV.foreach(path, rs = nil, &block). CSV.foreach
+ now does not handle "| cmd" as a path different from IO.foreach.
+ needed?
+
+ * test/csv/test_csv.rb: updated.
- * test/csv/test_csv.rb: follow above changes.
+ * test/ruby/test_float.rb: added test_strtod to test Float("0").
+
+Thu May 27 21:37:50 2004 Tanaka Akira <akr@m17n.org>
+
+ * lib/pathname.rb (Pathname#initialize): refine pathname initialization
+ by pathname.
+
+Thu May 27 20:22:05 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * io.c (rb_io_fwrite): check all case errno != 0 [ruby-dev:23648]
+
+Thu May 27 14:53:13 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (rb_io_fwrite): workaround for bcc32's fwrite bug.
+ add errno checking. [ruby-dev:23627]
Wed May 26 14:19:42 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -29019,33 +16702,16 @@ Wed May 26 00:00:00 2004 why the lucky stiff <why@ruby-lang.org>
* lib/yaml/baseemitter.rb (indent_text): simpler flow block code.
-Tue May 25 11:54:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_yield_0, proc_invoke, proc_arity): allow passing a block
- to a Proc. [ruby-dev:23533]
-
- * parse.y (block_par, block_var): ditto.
-
-Tue May 25 01:50:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_asn1.c (ossl_i2d_ASN1_TYPE, ossl_ASN1_TYPE_free):
- workaround for the versions earlier than OpenSSL-0.9.7.
+ * lib/yaml.rb: added rdoc to beginning of lib.
Mon May 24 10:46:26 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* lib/rdoc/generators/template/html/html.rb: SYSTEM identifiers
must be absolute URIs
-Sun May 23 04:53:50 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * lib/pstore.rb (transaction): allow overriding dump and load.
- [ruby-dev:23567]
-
- * lib/yaml/store.rb: follow lib/pstore.rb's change.
-
-Sat May 22 11:54:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat May 22 12:00:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * MANIFEST: add test/openssl/test_x509store.rb.
+ * MANIFEST: add new encodings in rexml.
* ext/tk/MANIFEST: add recent files.
@@ -29059,12 +16725,6 @@ Fri May 21 09:22:05 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method_parameters):
Add ()'s around parameters that don't have them
-Fri May 21 02:21:11 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/csv.rb: fixed a few bugs around multi char record/field separator.
-
- * test/csv/test_csv.rb: added boundary test for above feature.
-
Thu May 20 17:02:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (check_sizeof): define result size. [ruby-core:02911]
@@ -29072,6 +16732,10 @@ Thu May 20 17:02:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_header): macro name should not include equal
sign.
+Thu May 20 15:59:50 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * ext/socket/socket.c: fix SEGV. [ruby-dev:23550]
+
Thu May 20 14:35:52 2004 Tanaka Akira <akr@m17n.org>
* ext/socket/socket.c: check SCM_RIGHTS macro addition to
@@ -29092,100 +16756,20 @@ Thu May 20 12:34:39 2004 Dave Thomas <dave@pragprog.com>
Thu May 20 12:22:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (have_type): do not check pointer to incomplete type,
- which always get compiled.
- [ruby-list:39683]
+ which always get compiled. [ruby-list:39683]
-Wed May 19 23:45:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/inlinetest.rb (InlineTest::loadtest): requiring library with
- replaced $0 can make $0 == __FILE__ block be evaluated twice.
-
- * test/ruby/envutil.rb (EnvUtil::rubybin): give priority to
- environment variable. [ruby-dev:23538]
-
-Wed May 19 11:08:10 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Wed May 19 11:09:00 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: change permition of TkObject#tk_send from
private to public
-Wed May 19 02:29:36 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: support TRACE.
-
-Wed May 19 02:21:53 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: do not use class variables.
-
-Tue May 18 21:21:43 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/csv.rb: writes lines with "\n" when row separator is not given.
- formerly it was "\r\n".
-
- * lib/csv.rb: [CAUTION] API change
-
- * CSV::Row removed. a row is represented as just an Array. since
- CSV::Row was a subclass of Array, it won't hurt almost all programs
- except one which depended CSV::Row#match.
-
- * CSV::Cell removed. a cell is represented as just a String or
- nil(NULL). this change will cause widespread destruction.
-
- CSV.open("foo.csv", "r") do |row|
- row.each do |cell|
- if cell.is_null # Cell#is_null
- p "(NULL)"
- else
- p cell.data # Cell#data
- end
- end
- end
-
- must be just;
-
- CSV.open("foo.csv", "r") do |row|
- row.each do |cell|
- if cell.nil?
- p "(NULL)"
- else
- p cell
- end
- end
- end
-
- * lib/csv.rb: [CAUTION] record separator(CR, LF, CR+LF) behavior
- change. CSV.open, CSV.parse, and CSV,generate now do not force
- opened file binmode. formerly it set binmode explicitly.
-
- with CSV.open, binmode of opened file depends the given mode
- parameter "r", "w", "rb", and "wb". CSV.parse and CSV.generate open
- file with "r" and "w".
-
- setting mode properly is user's responsibility now.
-
- * lib/csv.rb: accepts String as a fs (field separator/column separator)
- and rs (record separator/row separator)
-
- * lib/csv.rb: added CSV.foreach(path, rs = nil, &block). CSV.foreach
- now does not handle "| cmd" as a path different from IO.foreach.
- needed?
-
- * test/csv/test_csv.rb: updated.
-
-Tue May 18 14:24:20 2004 why the lucky stiff <why@ruby-lang.org>
-
- * lib/yaml.rb: added rdoc to beginning of lib.
-
Tue May 18 14:00:46 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* node.h (NEW_DSTR): adjust list length.
* parse.y (literal_concat): ditto.
-Tue May 18 09:30:25 2004 SASADA Koichi <ko1@atdot.net>
-
- * eval.c (rb_method_node): search cache entry first.
-
-Mon May 17 16:04:06 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon May 17 16:14:25 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* numeric.c (flo_to_s): it's preferable that "p 0.0" outputs "0.0"
instead of "0.0e+00". [ruby-dev:23480]
@@ -29202,43 +16786,13 @@ Mon May 17 10:13:33 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (sock_s_getnameinfo): ditto.
-Mon May 17 00:36:21 2004 why the lucky stiff <why@ruby-lang.org>
+Mon May 17 01:15:23 2004 why the lucky stiff <why@ruby-lang.org>
+
+ * lib/yaml.rb: removed fallback to pure Ruby parser.
* lib/yaml/baseemitter.rb (indent_text): was forcing a mod value
of zero at times, which kept some blocks from getting indentation.
-Mon May 17 00:07:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/drb/drb.rb: Cosmetic documentation changes.
-
-Sun May 16 20:55:49 2004 Tanaka Akira <akr@m17n.org>
-
- * ext/dbm/dbm.c (fdbm_initialize): accept optional 3rd argument to
- specify an open flag.
- (Init_dbm): define open flags: DBM::READER, DBM::WRITER, DBM::WRCREAT
- and DBM::NEWDB.
-
-Sat May 15 17:52:24 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * test/ruby/test_float.rb(test_strtod): Add test for signed 0.000...1
-
-Sat May 15 14:20:13 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/syck/depend: add ruby's headers.
-
-Sat May 15 13:38:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/syck/MANIFEST, ext/syck/depend: new file.
-
- * lib/yaml/rubytypes.rb: range of exponential floats. [ruby-core:02824]
-
- * test/yaml/test_yaml.rb: tests for strings start with colon and some
- round trip.
-
-Sat May 15 12:04:58 2004 why the lucky stiff <why@ruby-lang.org>
-
- * lib/yaml.rb: removed fallback to pure Ruby parser.
-
* lib/yaml/baseemitter.rb (node_text): rewriting folded scalars.
* ext/syck/syck.h: reports style of scalars now, be they plain, block
@@ -29255,9 +16809,33 @@ Sat May 15 12:04:58 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/rubyext.c (yaml_org_handler): symbols loaded only
if scalar style is plain.
+ * ext/syck/rubyext.c (yaml_org_handler): some empty strings were
+ loaded as symbols.
+
* test/yaml/test_yaml.rb (test_perl_regexp): updated test to
match new regexp serialization.
+Mon May 17 00:03:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+
+ * lib/drb/drb.rb: Cosmetic documentation changes.
+
+Sun May 16 22:36:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+
+ * lib/test/unit.rb: Removed :nodoc: directive (it prevented effective
+ RDoc operation), and added file-level comment.
+
+Sun May 16 20:55:49 2004 Tanaka Akira <akr@m17n.org>
+
+ * ext/dbm/dbm.c (fdbm_initialize): accept optional 3rd argument to
+ specify an open flag.
+ (Init_dbm): define open flags: DBM::READER, DBM::WRITER, DBM::WRCREAT
+ and DBM::NEWDB.
+
+Sun May 16 13:10:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+
+ * lib/test/unit/**/*.rb: Removed :nodoc: directives (many were
+ generating warnings, many were on private methods).
+
Sat May 15 01:41:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (eval): forgot to restore $SAFE value before evaluating
@@ -29273,27 +16851,18 @@ Fri May 14 22:08:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_new4): should not reuse frozen shared string if
the original is not an instance of String. [ruby-talk:100193]
-Fri May 14 21:29:26 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (time_mdump): preserve GMT bit in the marshal data.
- [ruby-talk:100213]
-
-Fri May 14 18:37:49 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Fri May 14 18:39:25 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/lib/tk/canvas.rb: improve coords support for canvas
- items. Now, supports all of the followings.
- TkcLine.new(c, 0, 0, 100, 100, :fill=>'red')
- TkcLine.new(c, [0, 0, 100, 100], :fill=>'red')
- TkcLine.new(c, [0, 0], [100, 100], :fill=>'red')
- TkcLine.new(c, [[0, 0], [100, 100]], :fill=>'red')
- TkcLine.new(c, :coords=>[0, 0, 100, 100], :fill=>'red')
- TkcLine.new(c, :coords=>[[0, 0], [100, 100]], :fill=>'red')
+ * ext/tk/lib/tk/canvas.rb: improve coords support for canvas items.
+ Now, supports all of the followings.
+ TkcLine.new(c, 0, 0, 100, 100, :fill=>'red')
+ TkcLine.new(c, [0, 0, 100, 100], :fill=>'red')
+ TkcLine.new(c, [0, 0], [100, 100], :fill=>'red')
+ TkcLine.new(c, [[0, 0], [100, 100]], :fill=>'red')
+ TkcLine.new(c, :coords=>[0, 0, 100, 100], :fill=>'red')
+ TkcLine.new(c, :coords=>[[0, 0], [100, 100]], :fill=>'red')
-Fri May 14 13:30:39 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * test/ruby/test_float.rb: Add test for util.c revision 1.42.
-
-Fri May 14 12:13:46 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri May 14 12:11:43 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* util.c (ruby_strtod): strtod("0", &end); => end should point '\0'.
[ruby-dev:23498]
@@ -29303,10 +16872,15 @@ Thu May 13 15:47:30 2004 akira yamada <akira@ruby-lang.org>
* lib/net/telnet.rb (Net::Telnet::login): "options" can specify
regexps for login prompt and/or password prompt.
-Thu May 13 14:17:57 2004 why the lucky stiff <why@ruby-lang.org>
+Thu May 13 14:23:45 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/syck/rubyext.c (yaml_org_handler): some empty strings were
- loaded as symbols.
+ * hash.c (delete_if_i): use st_delete_safe() (via
+ rb_hash_delete()) instead of returning ST_DELETE.
+ backport from HEAD. [ruby-dev:23487]
+
+Thu May 13 13:01:30 2004 akira yamada <akira@ruby-lang.org>
+
+ * lib/uri/mailto.rb (URI::MailTo::to_s): should include fragment.
Thu May 13 11:04:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -29338,15 +16912,6 @@ Wed May 12 11:51:08 2004 Dave Thomas <dave@pragprog.com>
* class.c (rb_obj_singleton_methods): fix rdoc
-Tue May 11 07:09:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (is_defined): do not protect exception during receiver
- evaluation.
-
-Mon May 10 22:28:14 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/protocol.rb (each_crlf_line): remove junk line.
-
Mon May 10 21:44:42 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/html_generator.rb: Change scheme for
@@ -29365,81 +16930,43 @@ Mon May 10 12:11:37 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/html_generator.rb: Hack to search parents
for unqualified constant names.
-Mon May 10 01:18:15 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/pop.rb (logging): append "\n".
-
-Sun May 9 23:38:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/net/ftp.rb: ported documentation improvement from 1.8 branch
-
- * lib/net/imap.rb: ditto
+Mon May 10 12:11:37 2004 Dave Thomas <dave@pragprog.com>
- * lib/net/pop.rb: ditto
+ * lib/rdoc/generators/html_generator.rb: Hack to search parents
+ for unqualified constant names.
- * lib/net/smtp.rb: ditto
+Sun May 9 22:37:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+ * lib/net/ftp.rb: improved documentation
+ * lib/net/imap.rb: ditto
+ * lib/net/pop.rb: ditto
+ * lib/net/smtp.rb: ditto
* lib/net/telnet.rb: ditto
-Sun May 9 23:34:51 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/ruby/test_float.rb: added test_strtod to test Float("0").
-
-Sun May 9 13:24:24 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/yaml/store.rb: use FileUtils::copy.
-
-Sun May 9 12:34:26 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * regex.c: removed unused file.
-
-Sat May 8 10:53:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_f_open): open should not ignore block when "to_open"
- method is used. [ruby-dev:23478]
-
-Fri May 7 22:07:39 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/fileutils.rb (mv): new option `force'. [ruby-talk:99457]
-
- * lib/fileutils.rb: new method for command option reflection:
- FileUtils.commands, .options, .have_option?, .options_of,
- .collect_methods.
-
- * lib/fileutils.rb: module Verbose, NoWrite, DryRun do not have
- option flags @fileutils_verbose and @fileutils_noop, they make no
- sense.
-
Fri May 7 21:50:21 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_include): Allow
multiple arguments to 'include'
-Fri May 7 21:03:51 2004 Minero Aoki <aamine@loveruby.net>
+Fri May 7 21:31:56 2004 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (fu_list): Array() breaks pathes including "\n".
[ruby-core:02843]
- * test/fileutils/test_fileutils.rb (mkdir): test "\n" in path.
-
-Fri May 7 20:53:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dbm/dbm.c (fdbm_modify): typo fixed. [ruby-dev:23473]
-
-Fri May 7 11:17:27 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Fri May 7 11:25:53 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* util.c (ruby_strtod): "0.0000000000000000001" should be converted
to 1.0e-19 instead of 0.0. (leading zeros aren't significant digits)
[ruby-talk:99318] [ruby-dev:23465]
-Thu May 6 22:27:32 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Fri May 7 10:00:05 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/socket/socket.c (ippaddr): use NUMERICHOST if can not resolve
- hostname.
+ * ext/tk/tkutil.c (get_eval_string_core): bug fix. [ruby-dev:23466]
-Thu May 6 22:09:29 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Thu May 6 22:13:17 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * ext/tk/tkutil.c (get_eval_string_core): bug fix. [ruby-dev:23466]
+ * ext/socket/socket.c (ippaddr): use NUMERICHOST if can not resolve
+ hostname.
Thu May 6 14:22:29 2004 why the lucky stiff <why@ruby-lang.org>
@@ -29454,15 +16981,6 @@ Thu May 6 14:22:29 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/gram.c: fixed transfer methods on structs, broke it
last commit.
-Thu May 6 14:38:02 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (rb_push_glob): simplified code (not change behavior)
-
-Thu May 6 13:32:44 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb: get rid of side effect of Config.expand, patched by
- <tttt01@infoseek.jp> (ruby-bugs:PR#597)
-
Thu May 6 11:40:28 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (string): accept NIL.
@@ -29475,13 +16993,16 @@ Thu May 6 01:59:04 2004 Dave Thomas <dave@pragprog.com>
Don't include the &block parameter if we have explicit
yield parameters.
-Wed May 5 03:52:31 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed May 5 03:40:29 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/ring.rb: use recv instead of recvfrom.
-Wed May 5 00:38:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Tue May 4 23:52:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/gserver.rb: documented
+
+Tue May 4 23:46:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+
* lib/xmlrpc/README.txt: introduced for documentation purposes
Mon May 3 09:47:24 2004 Dave Thomas <dave@pragprog.com>
@@ -29489,10 +17010,6 @@ Mon May 3 09:47:24 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method_or_yield_parameters):
Fix parsing bug if yield called within 1 line block
-Sun May 2 21:56:48 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/fileutils/test_fileutils.rb (rm_f, rm_r): test :force flag.
-
Sun May 2 01:04:38 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib, ext/tk: renewal Ruby/Tk
@@ -29501,26 +17018,11 @@ Fri Apr 30 20:08:41 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* time.c (SIZEOF_TIME_T): support SIZEOF_TIME_T == SIZEOF_INT.
-Wed Apr 28 01:26:11 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * oniguruma.h, regparse.c: imported Oni Guruma 2.2.8.
-
-Wed Apr 28 01:16:23 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * oniguruma.h, regparse.c: imported Oni Guruma 2.2.7.
+Tue Apr 27 13:12:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Apr 27 14:43:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_eval): too many line trace call. (ruby-bugs PR#1320)
- * common.mk: LIBURUBY_A is needed for extconf.rb even when
- cross-compiling.
-
-Tue Apr 27 13:33:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (string_content): turn off NODE_NEWLINE flag to avoid
- unnecessary line trace for inlined expression.
- (ruby-bugs PR#1320)
-
-Tue Apr 27 08:15:13 2004 why the lucky stiff <why@ruby-lang.org>
+Tue Apr 27 08:41:28 2004 why the lucky stiff <why@ruby-lang.org>
* lib/yaml/rubytypes.rb: passing Range tests.
@@ -29548,33 +17050,32 @@ Mon Apr 26 21:40:09 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/code_objects.rb (RDoc::Context::add_alias): Only alias
to instance methods.
-Sun Apr 25 18:26:23 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in (ac_cv_func_fork): set to no on DJGPP.
-
-Sat Apr 24 14:32:03 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * re.c: applied stack error handling patch. [ruby-dev:23431]
-
Sat Apr 24 10:38:31 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/markup/simple_markup.rb (SM::SimpleMarkup::group_lines):
Fix bug where consecutive headings are merged.
-Fri Apr 23 23:24:47 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Apr 23 23:26:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/mkmf.rb: $hdrdir should not contain macros, for backward
+ * lib/mkmf.rb: $hdrdir should not contain macros for backward
compatibility. [bruby-dev:28]
- * lib/mkmf.rb (create_makefile): in the case of extout, just copy
- script files, without comparison.
+ * version.c (ruby_show_copyright): obtain copyright year from
+ RUBY_RELEASE_YEAR.
+
+ * win32/resource.rb: ditto.
+
+ * win32/resource.rb: default rubyw icon to ruby.ico, and let DLL also
+ include them.
+
+ * win32/resource.rb: include winver.h for older WindowsCE.
Fri Apr 23 16:38:46 2004 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb: sync taint/freeze flag between
a pathname object and its internal string object.
-Fri Apr 23 14:52:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Apr 23 14:52:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt, arg, aref_args): should not make sole splat into
array, in aref_args other than aref with op_asgn.
@@ -29584,18 +17085,7 @@ Fri Apr 23 14:14:38 2004 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb: don't use Regexp#source to embed regexps.
[ruby-dev:23432]
-Thu Apr 22 18:25:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk, ext/extmk.rb: make ext and .ext get removed by distclean.
-
-Thu Apr 22 10:07:01 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * */Makefile.sub (distclean-local): should remove $(RBCONFIG).
-
-Thu Apr 22 04:17:57 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_mod_define_method): allow binding methods to modules.
- [ruby-dev:23410]
+Thu Apr 22 04:15:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (aref_args): should pass expanded list. [ruby-core:02793]
@@ -29607,7 +17097,7 @@ Thu Apr 22 01:12:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_index_m): use unsigned comparison for T_FIXNUM
search. [ruby-talk:97342]
-Wed Apr 21 23:04:42 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Apr 21 22:57:27 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/rinda.rb, test/rinda/test_rinda.rb: check Hash tuple size.
@@ -29616,44 +17106,6 @@ Wed Apr 21 20:05:00 2004 Tanaka Akira <akr@m17n.org>
* lib/open-uri.rb (URI::HTTP#proxy_open): set Host: field explicitly.
[ruby-list:39542]
-Wed Apr 21 18:39:46 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/smtp.rb: merge SMTP-TLS patch. This patch is
- contributed by Daniel Hob. [ruby-core:02789]
-
-Wed Apr 21 18:23:45 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/smtp.rb: change coding style: def m( a ) -> def m(a).
-
-Wed Apr 21 18:01:47 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/pop.rb: do not use class variables.
-
- * lib/net/pop.rb (do_start): ensure to clean up connection when
- authentication failed.
-
-Wed Apr 21 17:23:59 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (HTTP#connect): CONNECT must precede SSL connect.
- [ruby-dev:23379]
-
- * lib/net/http.rb (HTTP.new): class variables are not inherited
- now.
-
-Wed Apr 21 15:56:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/test/unit/ui/console/testrunner.rb (test_started): restore $0
- after changing process title. [ruby-talk:97426]
-
-Wed Apr 21 10:18:06 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * process.c(rb_spawn): fix SEGV at "p system('command line here')"
- (may happen only in bccwin32) [ruby-dev:23380]
-
-Mon Apr 19 20:58:44 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c: Updated RDocs.
-
Mon Apr 19 18:11:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (rb_hash_equal): returns true if two hashes have same set
@@ -29662,132 +17114,107 @@ Mon Apr 19 18:11:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (rb_hash_eql): returns true if two hashes are equal and
have same default values.
-Mon Apr 19 08:19:11 2004 Doug Kearns <djkea2@mugca.its.monash.edu.au>
+Mon Apr 19 08:19:58 2004 Doug Kearns <djkea2@mugca.its.monash.edu.au>
- * dln.c, io.c, pack.c, lib/benchmark.rb, lib/cgi.rb, lib/csv.rb,
- lib/date.rb, lib/ftools.rb, lib/getoptlong.rb, lib/logger.rb,
- lib/matrix.rb, lib/monitor.rb, lib/set.rb, lib/thwait.rb,
- lib/timeout.rb, lib/yaml.rb, lib/drb/drb.rb, lib/irb/workspace.rb,
- lib/net/ftp.rb, lib/net/http.rb, lib/net/imap.rb, lib/net/pop.rb,
- lib/net/telnet.rb, lib/racc/parser.rb, lib/rinda/rinda.rb,
- lib/rinda/tuplespace.rb, lib/shell/command-processor.rb,
- lib/soap/rpc/soaplet.rb, lib/test/unit/testcase.rb,
- lib/test/unit/testsuite.rb: typo fix.
+ * dln.c, io.c, lib/benchmark.rb, lib/cgi.rb, lib/csv.rb, lib/date.rb,
+ lib/ftools.rb, lib/getoptlong.rb, lib/logger.rb, lib/matrix.rb,
+ lib/monitor.rb, lib/set.rb, lib/thwait.rb, lib/timeout.rb,
+ lib/yaml.rb, lib/drb/drb.rb, lib/irb/workspace.rb, lib/net/ftp.rb,
+ lib/net/http.rb, lib/net/imap.rb, lib/net/telnet.rb,
+ lib/racc/parser.rb, lib/rinda/rinda.rb, lib/rinda/tuplespace.rb,
+ lib/shell/command-processor.rb, lib/soap/rpc/soaplet.rb,
+ lib/test/unit/testcase.rb, lib/test/unit/testsuite.rb: typo fix.
Mon Apr 19 08:14:18 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_body): Allow for
#ifdef HAVE_PROTOTYPES
+Fri Apr 16 22:33:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+
+ * ext/iconv/iconv.c: nearly finished RDoc comments.
+
Fri Apr 16 17:04:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_equal): always returns true or false, never
returns nil. [ruby-dev:23404]
-Fri Apr 16 12:38:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/drb/drb.rb (DRb::DRbUnknown::initialize): Exception#to_str is
- deprecated.
-
- * lib/drb/drb.rb (DRb::DRbServer::InvokeMethod::perform): multiple
- value class changed.
-
- * lib/drb/invokemethod.rb (DRb::DRbServer::InvokeMethod18Mixin::block_yield):
- ditto.
-
-Fri Apr 16 08:27:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Apr 16 08:27:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: skip linking when libraries to be preloaded not
compiled. [ruby-list:39561]
-Thu Apr 15 19:57:11 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Apr 15 23:21:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (pst_success_p): new method Process::Status#success?.
[ruby-dev:23385]
- * rubytest.rb: do nothing while cross-compiling, return status in
- system independent style.
-
-Thu Apr 15 19:26:54 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (rb_push_glob): Dir.glob() should return nil if block is given.
- (http://www.ruby-lang.org/ja/man/index.cgi?cmd=view;name=Dir)
-
- * dir.c (push_braces): Dir.glob() should handle '{ }' nested more than
- 3 times.
-
- * dir.c (push_braces, rb_push_glob): Dir.glob() should handle escaped
- '{' and '}' and ','.
-
- [ruby-dev:23376]
-
Thu Apr 15 17:12:13 2004 Tanaka Akira <akr@m17n.org>
* ext/gdbm/gdbm.c (Init_gdbm): define GDBM::READER, GDBM::WRITER,
GDBM::WRCREAT and GDBM::NEWDB.
(fgdbm_initialize): use specified read/write flag.
-Wed Apr 14 13:06:09 2004 Doug Kearns <djkea2@mugca.its.monash.edu.au>
-
- * array.c, enum.c, eval.c, file.c, io.c, numeric.c, object.c, prec.c,
- process.c, re.c, string.c: typos in RDoc comments. [ruby-core:02783]
-
Wed Apr 14 11:29:56 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* numeric.c (flo_eq): workaround for bcc32's bug.
(ruby-bugs-ja:PR#594)
+Wed Apr 14 13:06:35 2004 Doug Kearns <djkea2@mugca.its.monash.edu.au>
+
+ * array.c, enum.c, eval.c, file.c, io.c, numeric.c, object.c, prec.c,
+ process.c, re.c, string.c: typos in RDoc comments. [ruby-core:02783]
+
Wed Apr 14 11:06:38 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::scan): Changed
behavior of :enddoc: -- it now unconditionally terminates
processing of the current file.
-Wed Apr 14 10:57:40 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Wed Apr 14 11:03:22 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* defines.h: include <net/socket.h> to get fd_set definition in BeOS.
-Tue Apr 13 23:00:55 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Apr 13 23:06:30 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/rinda.rb: change pattern matching.
a === b -> a == b || a === b. [druby-ja:98]
* test/rinda/test_rinda.rb: ditto.
-Tue Apr 13 21:50:57 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Apr 13 19:54:29 2004 Minero Aoki <aamine@loveruby.net>
- * bcc32/Makefile.sub (PHONY): Borland make disallows empty command
- rules.
+ * lib/net/http.rb: should not overwrite HTTP request header.
+ [ruby-list:39543]
-Tue Apr 13 17:55:16 2004 Minero Aoki <aamine@loveruby.net>
+Tue Apr 13 01:30:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * lib/net/http.rb (begin_transport): should not overwrite HTTP
- request header. [ruby-list:39543]
+ * ext/iconv/iconv.c: RDoc documentation (from RD; nearly finished).
+ * ext/iconv/charset_alias.rb: Prevent from RDoc'ing.
-Tue Apr 13 16:48:00 2004 Minero Aoki <aamine@loveruby.net>
+Mon Apr 12 19:11:29 2004 Eric Hodel <drbrain@segment7.net>
- * lib/net/pop.rb: merge POP3S patch. This patch is contributed by
- Daniel Hobe.
+ * gc.c (rb_gc_copy_finalizer): typo. [ruby-core:02774]
-Tue Apr 13 02:56:29 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
+Mon Apr 12 18:52:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * common.mk: changed the order of ascii.c alphabetically.
+ * ext/openssl/ossl_x509name.c (ossl_x509name_init_i): should return
+ a value.
-Mon Apr 12 19:11:21 2004 Eric Hodel <drbrain@segment7.net>
+Mon Apr 12 10:43:47 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * gc.c (rb_gc_copy_finalizer): typo. [ruby-core:02774]
+ * dir.c (rb_glob2, rb_glob, rb_globi, push_globs, push_braces,
+ rb_push_glob): fix memory leak. (leaked when block was interrupted)
-Mon Apr 12 18:45:58 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Mon Apr 12 10:27:37 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/openssl/ossl_x509name.c (ossl_x509name_init_i): should return
- a value.
+ * bcc32/Makefile.sub: backport SIZEOF_TIME_T definition from 1.9.
-Mon Apr 12 10:39:50 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+ * win32/Makefile.sub: ditto.
- * dir.c (rb_glob2, rb_glob, push_globs, push_braces, rb_push_glob):
- fix memory leak. (leaked when block was interrupted)
+ * wince/Makefile.sub: ditto.
-Sun Apr 11 19:10:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sun Apr 11 19:12:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (require_libraries): restore source file/line after
statically linked extensions initialized. [ruby-dev:23357]
@@ -29808,73 +17235,7 @@ Sat Apr 10 00:00:19 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/markup/simple_markup/inline.rb: Fix problem
with \_cat_<b>dog</b>
-Fri Apr 9 17:05:21 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (has_magic, find_dirsep): incomplete '[' matches no character
- in Dir.glob. (follows File.fnmatch's behavior)
-
- * dir.c (fnmatch_helper): incomplete escape is ignored in File.fnmatch.
- (follows Dir.glob's behavior)
-
- * dir.c (find_dirsep): '/' between '[' and ']' is ignored in Dir.glob.
- (follows File.fnmatch with File::FNM_PATHNAME 's behavior)
-
- * dir.c (find_dirsep): escaped slash '\/' loses its meaning as
- directory separator in Dir.glob.
-
- [ruby-dev:23291]
-
-Thu Apr 8 20:25:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (extmake): skip uncompiled extensions.
-
- * lib/mkmf.rb (create_makefile): emit no rules for static library if
- $static is nil, e.g., outside of ext/.
-
- * lib/test/unit/ui/console/testrunner.rb (test_started): show test
- name via $0.
-
- * runruby.rb: set environments to use the compiled binary.
-
- * test/runner.rb: do nothing while cross-compiling.
-
- * test/drb/drbtest.rb, test/soap/calc/test_calc_cgi.rb: use envutil to
- know ruby binary, and restore $: after require.
-
- * test/ruby/envutil.rb: give priority to RUBY environment variable to
- use just compiled binary and libraries.
-
-Thu Apr 8 19:03:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_binmode): inverted condition. [ruby-dev:23349]
-
-Thu Apr 8 18:22:00 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_s_list): return encoding list if no block
- is given. [ruby-dev:23063]
-
-Wed Apr 7 15:29:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * pack.c (pack_pack): use NUM2INT() instead of num2i32().
-
-Wed Apr 7 12:32:02 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/parser.rb, lib/rss/1.0.rb: accepted rdf:resource or
- resource attribute in rdf:li.
- * test/rss/test_parser.rb: added test for above change.
-
- * lib/rss/dublincore.rb: reverted style.
-
- * lib/rss/xmlparser.rb: normalized XMLParser class hierarchy.
-
-Wed Apr 7 10:43:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, common.mk, */Makefile.sub (ext/extinit.o): OUTFLAG
- doesn't work for object files on VC.
-
- * */Makefile.sub (config.h): need SIZEOF_TIME_T now.
-
-Wed Apr 7 00:24:34 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Apr 7 00:19:50 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/rinda.rb: fix hash tuple bug.
@@ -29884,12 +17245,6 @@ Wed Apr 7 00:24:34 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
Tue Apr 6 18:24:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (rb_get_path): get path string via "to_path" method if
- path object is not a string. [Ruby2]
-
- * gc.c (rb_gc_call_finalizer_at_exit): do not free threads in the
- exit finalizers.
-
* io.c (rb_io_reopen): should use rb_io_check_io().
Tue Apr 6 16:46:09 2004 Tanaka Akira <akr@m17n.org>
@@ -29900,82 +17255,49 @@ Tue Apr 6 16:46:09 2004 Tanaka Akira <akr@m17n.org>
(time_plus): use time_add.
(time_minus): use time_add.
-Tue Apr 6 13:11:48 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/socket/socket.c (raise_socket_error): never return.
+Tue Apr 6 13:21:30 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/socket.c (make_hostent): must return value.
-Tue Apr 6 00:14:43 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (Init_Exception): remove Exception#to_str. [Ruby2]
-
- * eval.c (error_print): should no call "to_str" anymore use
- "message" method instead.
-
- * io.c (rb_f_open): Kernel#open() calls "to_open" if the first
- argument responds to it. [Ruby2]
-
-Tue Apr 6 00:13:43 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Tue Apr 6 00:05:30 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/rinda/rinda.rb: add require 'drb/drb'
-Mon Apr 5 22:25:32 2004 Tanaka Akira <akr@m17n.org>
-
- * test/zlib/test_zlib.rb: new file.
- (TestZlibGzipWriter#test_new_nil): test for [ruby-dev:23228].
-
-Mon Apr 5 22:16:23 2004 Minero Aoki <aamine@loveruby.net>
-
- * parse.y (assoc_list): {a: 1, b: 2} should be allowed.
- [ruby-dev:23328]
-
-Mon Apr 5 19:43:40 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * regexec.c: imported Oni Guruma 2.2.6.
-
-Mon Apr 5 19:39:10 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
+Mon Apr 5 08:18:23 2004 Dave Thomas <dave@pragprog.com>
- * regparse.c, oniguruma.h: imported Oni Guruma 2.2.6.
+ * lib/rdoc/rdoc.rb: Remove leading ./ from file names so that cross
+ references work properly.
-Mon Apr 5 12:12:09 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Sun Apr 4 20:33:42 2004 Minero Aoki <aamine@loveruby.net>
- * ext/socket/socket.c (raise_socket_error): some platforms don't have
- EAI_SYSTEM.
+ * eval.c (Init_load): make $LOADED_FEATURES built-in.
+ [ruby-dev:23299]
-Mon Apr 5 08:18:23 2004 Dave Thomas <dave@pragprog.com>
+ * ruby.c (ruby_prog_init): make $PROGRAM_NAME built-in.
- * lib/rdoc/rdoc.rb: Remove leading ./ from file names so that cross
- references work properly.
+ * lib/English.rb: remove $LOADED_FEATURES and $PROGRAM_NAME.
Sun Apr 4 14:01:20 2004 Dave Thomas <dave@pragprog.com>
- * lib/rdoc/options.rb (Options::parse): Allow multiple -x options to
- RDoc. Fix bug where files weren't being excluded properly
+ * lib/rdoc/options.rb (Options::parse): Allow multiple -x options to RDoc.
+ Fix bug where files weren't being excluded properly
-Sat Apr 3 09:36:38 2004 why the lucky stiff <why@ruby-lang.org>
+Sat Apr 3 17:11:05 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/syck.h: version 0.43.
-Sat Apr 3 08:28:47 2004 why the lucky stiff <why@ruby-lang.org>
-
* ext/syck/lib/gram.c: allow root-level inline collections.
- [ruby-talk:94922]
+ [ruby-talk:94922]
* lib/yaml/rubytypes.rb (Symbol#to_yaml): emit symbols as implicits.
- [ruby-talk:94930]
+ [ruby-talk:94930]
-Fri Apr 2 19:28:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bcc32/Makefile.sub (OUTFLAG): needed for static-linked-ext.
-
-Fri Apr 2 18:00:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/syck/bytecode.c: turn off default implicit typing.
- * ext/extmk.rb (extmake): extract necessary variables for static link
- from Makefile.
+ * ext/syck/implicit.c: detect base60 integers.
- * lib/mkmf.rb (create_makefile): save preload and libpath for next
- compile.
+ * ext/syck/rubyext.c: handle base60, as well as hex and octal
+ with commas. implicit typing of ruby symbols.
Fri Apr 2 17:27:17 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -29994,20 +17316,8 @@ Fri Apr 2 14:35:26 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (block_pass): should generate unique identifier of the
pushing block. [ruby-talk:96363]
-Fri Apr 2 11:36:20 2004 Minero Aoki <aamine@loveruby.net>
-
- * eval.c (Init_load): make $LOADED_FEATURES built-in.
- [ruby-dev:23299]
-
- * ruby.c (ruby_prog_init): make $PROGRAM_NAME built-in.
-
- * lib/English.rb: remove $LOADED_FEATURES and $PROGRAM_NAME.
-
Fri Apr 2 07:31:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/socket.c: mistakingly removed do_not_reverse_lookup.
- [ruby-list:39475]
-
* ext/socket/socket.c (make_hostent): fix memory leak, based on
the patch from HORIKAWA Hisashi <vzw00011@nifty.ne.jp>.
@@ -30032,6 +17342,14 @@ Thu Apr 1 19:58:37 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
be empty). Instance of URI have instance_variables but it must be
llowed whenever original mapping is allowed or not.
+ * lib/xsd/datatypes.rb: check the smallest positive non-zero
+ single-precision float exactly instead of packing with "f".
+ [ruby-talk:88822]
+
+ * lib/soap/mapping/rubytypeFactory.rb: should not dump singleton class.
+ [ruby-dev:22588]
+ c = class << Object.new; class C; self; end; end; SOAPMarshal.dump(c)
+
Wed Mar 31 19:06:23 2004 Tanaka Akira <akr@m17n.org>
* time.c (year_leap_p): new function.
@@ -30039,7 +17357,7 @@ Wed Mar 31 19:06:23 2004 Tanaka Akira <akr@m17n.org>
(search_time_t): use timegm_noleapsecond instead of
mktime for first guess.
-Wed Mar 31 12:05:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Mar 31 12:04:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/delegate.rb (DelegateClass): define internal methods of the
result class, but not metaclass of the caller. [ruby-talk:96156]
@@ -30048,44 +17366,12 @@ Wed Mar 31 12:05:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.h: missing.h is now prerequisite to intern.h.
-Wed Mar 31 11:17:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * pack.c (pack_pack): raises RangeError if uv is out of UTF8 value
- range. [ruby-dev:23281]
-
- * io.c (rb_io_binmode): stdio buffer should be empty when calling
- IO#binmode. [ruby-talk:96155]
-
Tue Mar 30 20:25:34 2004 Tanaka Akira <akr@m17n.org>
* time.c (search_time_t): limit guess range by mktime if it is
available. [ruby-dev:23274]
-Tue Mar 30 18:19:00 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_eval): fix SEGV at retry in iterator's receiver.
- [ruby-dev:23227]
-
-Mon Mar 29 20:17:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (rb_exec): follow older behavior if close-on-exec is not
- available.
-
- * process.c (rb_fork): protect from exceptions while waiting failed
- process, if status is given.
-
-Sun Mar 28 16:25:37 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * cygwin/GNUmakefile.in (clean-local, distclean-local): remove
- work files.
-
- * win32/Makefile.sub (clean-local): ditto.
-
-Sun Mar 28 14:23:02 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/pop.rb: def m( arg ) -> def m(arg).
-
-Sun Mar 28 14:09:13 2004 Minero Aoki <aamine@loveruby.net>
+Sun Mar 28 14:16:59 2004 Minero Aoki <aamine@loveruby.net>
* lib/net/pop.rb (auth): failed when account/password include "%".
[ruby-talk:95933]
@@ -30099,46 +17385,16 @@ Sat Mar 27 10:40:48 2004 Tanaka Akira <akr@m17n.org>
* (lib/pp.rb, lib/prettyprint.rb): define seplist in PP::PPMethods
instead of PrettyPrint.
-Sat Mar 27 01:47:09 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/logger.rb: trim tail space of each line. no user visible change.
-
- * lib/rss/dublincore.rb: fixed class definition mismatch.
+Thu Mar 25 23:28:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sample/openssl/gen_csr.rb: fixed wrong usage text.
+ * time.c (time_overflow_p): backport 1.9 usec overflow function.
+ (ruby-bugs PR#1307)
Thu Mar 25 23:15:24 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_options.rb (RI::Options::show_version):
Add --version option
-Thu Mar 25 21:45:00 2004 Shigeo Kobayashi <shigek@ruby-lang.org>
-
- * ext/bigdecimal/bigdecimal.c: Bug in + and - reported by Bret Jolly
- fixed.
-
-Thu Mar 25 21:01:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * version.c (ruby_show_copyright): obtain copyright year from
- RUBY_RELEASE_YEAR.
-
- * win32/resource.rb: ditto.
-
-Thu Mar 25 19:37:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/resource.rb: default rubyw icon to ruby.ico, and let DLL also
- include them.
-
- * win32/resource.rb: include winver.h for older WindowsCE.
-
-Thu Mar 25 14:01:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * common.mk, */Makefile.sub (lib, dll): phony targets.
-
- * configure.in (ruby, miniruby): ditto.
-
- * cygwin/GNUmakefile.in (rubyw): ditto.
-
Thu Mar 25 04:16:18 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_options.rb (RI::Options): Add the --list-names option,
@@ -30155,7 +17411,7 @@ Thu Mar 25 02:00:18 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/template/html/one_page_html.rb (Page):
Fix to work with C modules.
-Wed Mar 24 20:49:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Wed Mar 24 21:17:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/uri.rb: Documented (thanks Dmitry V. Sabanin).
* lib/uri/common.rb: Ditto.
@@ -30165,13 +17421,17 @@ Wed Mar 24 20:49:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/uri/https.rb: Ditto.
* lib/uri/ldap.rb: Ditto.
* lib/uri/mailto.rb: Ditto.
+ (All backported from 1.9)
-Wed Mar 24 18:48:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Mar 24 18:48:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb ($ruby, $topdir, $hdrdir): should not be affected by
DESTDIR after installed.
- * lib/mkmf.rb (dummy_makefile): default file lists to be cleaned.
+ * lib/mkmf.rb (RUBY): / is not recognized as path separator on
+ nmake/bmake. [ruby-list:39388]
+
+ * lib/mkmf.rb (init_mkmf): $INCFLAGS also should be lazy-evaluated.
Wed Mar 24 12:32:56 2004 Dave Thomas <dave@pragprog.com>
@@ -30188,86 +17448,18 @@ Wed Mar 24 11:11:26 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/html_generator.rb (Generators::HTMLGenerator::load_html_template):
Allow non-RDoc templates by putting a slash in the template name
-Wed Mar 24 10:05:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/tempfile.rb (Tempfile::_close): should not clear @tmpname
- until the file is really removed. [ruby-core:02684]
-
-Wed Mar 24 04:12:44 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_mod_cvar_get): new method Module#class_variable_get.
-
- * object.c (rb_mod_cvar_set): ditto (Module#class_variable_set).
-
-Tue Mar 23 17:45:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_thread_atfork): 1.9 warns no more for thread
- termination. [ruby-dev:23212]
+Mon Mar 22 16:19:57 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Mar 23 14:46:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, */Makefile.sub, common.mk (clean-local, distclean-local):
- separate files under directories due to directory separator.
-
- * */Makefile.sub (MKFILES): common.mk and */Makefile.sub should not be
- removed.
-
- * win32/Makefile.sub, wince/Makefile.sub: $* cannot appear in explicit
- rules.
-
- * cygwin/GNUmakefile.in: some mingw stuffs were missed.
-
- * lib/mkmf.rb (create_makefile): Borland make wrongly removes braces
- from command lines.
-
- * bcc32/Makefile.sub: needs bcc32/mkexports.rb.
-
-Mon Mar 22 08:21:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, */Makefile.sub, common.mk: extract common portions.
-
- * Makefile.in, cygwin/GNUmakefile.in, */Makefile.sub (RBCONFIG):
- separated time stamp file for rbconfig.rb.
-
- * configure.in: append common.mk to Makefile.
-
- * mkconfig.rb: keep mtime of rbconfig.rb if unchanged.
-
- * win32/rm.bat: remove multiple files.
-
- * wince/mkconfig_wce.rb: use fake.rb instead.
-
-Sun Mar 21 22:17:35 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#virtual_host):
- sort @virtual_hosts in address, port, host order.
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server):
- hostname should not be match if :ServerAlias is not given.
+ * ruby.1: add -width option to .Bl for old groff.
Sun Mar 21 21:11:16 2004 Keiju Ishitsuka <keiju@ishitsuka.com>
* lib/shell/*: bug fix for Shell#system(command_line_string).
-Sun Mar 21 21:04:42 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ruby.1: add -width option to .Bl for old groff.
-
-Sun Mar 21 18:57:37 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/*: Test::Unit::TestCase -> RSS::TestCase and
- Test::Unit::Assertions -> RSS::Assertions.
-
-Sun Mar 21 18:48:20 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/{rss,dublincore,syndication}.rb: handled W3CDTF correctly.
+Sat Mar 20 20:57:10 2004 David Black <dblack@wobblini.net>
-Sun Mar 21 18:15:29 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/test_xml-stylesheet.rb: added tests for xml-stylesheet.
-
- * lib/rss/xml-stylesheet.rb: added xml-stylesheet parsing
- function.
+ * lib/scanf.rb: Backported 1.9 branch
+ modifications/corrections to 1.8 branch
Sat Mar 20 23:51:03 2004 WATANABE Hirofumi <eban@ruby-lang.org>
@@ -30277,164 +17469,58 @@ Sat Mar 20 23:51:03 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* eval.c (rb_f_raise): should not clear backtrace information if
exception object already have one.
-Sat Mar 20 21:21:03 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/extmk.rb: rm -rf $extout, not extout.
-
Sat Mar 20 15:25:36 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/template/html/html.rb (RDoc::Page): Force
page background to white.
-Sat Mar 20 09:33:36 2004 Tadayoshi Funaba <tadf@dotrb.org>
+Sat Mar 20 09:52:33 2004 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date.rb, lib/date/format.rb: _parse() now accepts fractional
part of second minute that follows a comma or a full stop.
-Fri Mar 19 21:06:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (assoc_list): allow {sym: val} style Hash. [Ruby2]
- this change is done by Nobuyoshi Nakada <nobu@ruby-lang.org>.
-
-Fri Mar 19 15:15:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_cvar_set): class variables become private to the
- particular class/module. [Ruby2]
-
- * variable.c (rb_cvar_get): ditto.
-
- * variable.c (rb_cvar_defined): ditto.
-
-Fri Mar 19 11:31:32 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/mkmf.rb ($beos, $solaris): add OS flags.
-
- * lib/mkmf.rb (RUBY): / is not recognized as path separator on
- nmake/bmake. [ruby-list:39388]
-
- * lib/mkmf.rb (CLEANLIBS, CLEANOBJS): should remove *.exp with *.so.
-
Fri Mar 19 01:55:57 2004 Mauricio Fernandez <batsman.geo@yahoo.com>
* io.c (rb_io_sync): need not to check writable. [ruby-core:02674]
-Thu Mar 18 19:47:44 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * instruby.rb, rubytest.rb: do not depend on srcdir.
+Thu Mar 18 21:44:38 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Thu Mar 18 18:50:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/drb/drb.rb: backport drb.rb 1.16.
- * mkconfig.rb: no longer embed srcdir and compile_dir into
- rbconfig.rb.
+Fri Mar 18 17:49:51 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/extmk.rb, lib/mkmf.rb: obtain top_srcdir and topdir from library
- paths.
+ * struct.c (make_struct): allow const_id for accessor names.
+ [ruby-core:04585]
-Thu Mar 18 17:46:35 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb: do not undef :to_a.
+ * eval.c (rb_attr): check if attribute name is local_id or
+ const_id.
Thu Mar 18 16:22:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_eq): avoid false positive by using scope and
dyna_vars. no longer use frame.uniq.
- * eval.c (proc_arity): arity is now defined as number of
- parameters that would not be ignored. i.e. Proc.new{}.arity
- returns zero. update test suites too.
-
-Thu Mar 18 15:27:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c: remove specialized version of rb_Array(). use simple
- one defined in object.c.
-
- * object.c (Init_Object): remove Kernel#to_a.
-
- * enum.c (enum_zip): use "to_a" instead of "to_ary".
-
-Wed Mar 17 00:22:03 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * oniguruma.h: imported Oniguruma 2.2.5.
- * regparse.c: ditto.
-
-Tue Mar 16 11:14:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (fnmatch_helper): File.fnmatch('\.', '.') should return true.
- (Rev1.112 lost compatiblity)
-
- * dir.c (fnmatch_helper): File.fnmatch('\/', '/', File::FNM_PATHNAME)
- should return true. (Rev1.112 lost compatiblity)
-
- * dir.c (fnmatch): File.fnmatch('**/.boo', '.foo/.boo',
- File::FNM_PATHNAME) should return false because of leading period.
-
-Mon Mar 15 17:01:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (exc_initialize): calling 'to_str' each time just for
- type checking is too heavy. [ruby-core:02661]
+Wed Mar 17 14:44:43 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Mon Mar 15 10:14:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SocketForwarder):
- add do_not_reverse_lookup.
+ * dir.c (range): fix possible "\0" overrun. (in case of "\0-")
Mon Mar 15 07:39:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_yield_0): should not re-submit TAG_BREAK if this
yield is not break destination. [ruby-dev:23197]
-Sun Mar 14 22:07:38 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_thread_raise): err at unstarted thread. (PR#1302)
-
-Sat Mar 13 14:56:32 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * test/drb/ut_drb.rb: use 'druby://localhost:0'. [ruby-dev:23078]
-
- * test/drb/ut_eval.rb: ditto.
-
- * test/drb/ut_large.rb: ditto.
-
- * test/drb/ut_safe1.rb: ditto.
-
- * test/drb/ut_drb_drbssl.rb: use 'drbssl://localhost:0'.
-
-Fri Mar 12 23:52:56 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (fnmatch): directory recursion '**/' can be used with
- File::FNM_PATHNAME. [ruby-dev:22901]
-
- * dir.c (fnmatch, fnmatch_helper): only '/' is accepted as path
- separator even in DOSISH environment. [ruby-dev:22974]
- [ruby-list:39337]
-
- * dir.c (fnmatch_helper): faster '*' matching.
-
-Fri Mar 12 20:19:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Mar 13 14:28:16 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * configure.in (rb_cv_noreturn): default for platforms not support
- prototypes.
+ * test/drb/test_drbssl.rb: rescue LoadError. (Barkport from main
+ trunk)
- * ruby.c (ruby_init_loadpath): buffer for path name should have
- MAXPATHLEN.
-
- * lib/mkmf.rb (configuration): include topdir and hdrdir in VPATH.
-
- * lib/mkmf.rb (create_makefile): default dependency rule.
-
-Fri Mar 12 07:35:36 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/config.rb (WEBrick::Config::General): add
- :DoNotReverseLookup.
-
- * lib/webrick/server.rb (WEBrick::GenericServer#accept): call
- do_not_reverse_lookup for each socket if :DoNotReverseLookup
- is set. [ruby-code:02357]
+ * test/drb/test_drbunix.rb: ditto.
-Wed Mar 10 22:26:25 2004 Minero Aoki <aamine@loveruby.net>
+Wed Mar 10 22:28:09 2004 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb (remove_dir): should handle symlink correctly.
This patch is contributed by Christian Loew. [ruby-talk:94635]
+ (Backport from main trunk)
Wed Mar 10 16:28:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -30445,337 +17531,54 @@ Wed Mar 10 16:28:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_yield_0): set exit_value for block break.
-Wed Mar 10 16:00:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * struct.c (rb_struct_s_def): Struct::new executes block with
- generated struct class. [ruby-talk:02606]
-
Wed Mar 10 15:58:43 2004 Ryan Davis <ryand@zenspider.com>
* eval.c (eval): Only print backtrace if generating the backtrace
doesn't generate an exception. [ruby-core:02621]
-Wed Mar 10 10:15:16 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ruby.c (opt_W_getter): get rid of warning.
-
- * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub:
- fixed dependency.
-
Tue Mar 9 13:04:26 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_ungetc): raise IOError instead of calling
rb_sys_fail(). [ruby-talk:23181]
-Tue Mar 9 10:03:40 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub:
- replaced regex.c entry with Oniguruma files.
-
-Tue Mar 9 01:09:46 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
-
- * Makefile.in: replaced regex.c entry with Oniguruma files.
-
-Mon Mar 8 23:16:07 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: HTTPHeader did not initialized correctly.
-
- * lib/net/http.rb (connect): does same debug output.
-
-Mon Mar 8 21:38:18 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (add_header): remove warning. [ruby-dev:23170]
-
-Mon Mar 8 21:09:39 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (range): Cancel change for incomplete '['. More discussion
- is needed.
-
-Mon Mar 8 19:35:13 2004 akira yamada <akira@arika.org>
+Mon Mar 8 19:32:28 2004 akira yamada <akira@ruby-lang.org>
* lib/uri/common.rb (URI::REGEXP::PATTERN::HOSTPORT): (?:#{PORT})
-> (?::#{PORT}). [ruby-dev:23170]
-Mon Mar 8 15:03:24 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Mar 8 15:31:41 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* dir.c (range): treat incomplete '[' as ordinary character (like
- has_magic does). fix buffer overrun at incomplete escape like '[\'.
-
-Mon Mar 8 13:35:32 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+ has_magic does).
- * regparse.c (parse_exp): need to separate initialization for bcc32.
- [ruby-dev:23169]
+ * dir.c (range): Cancel above change. More discussion is needed.
- * oniguruma.h (ONIG_EXTERN): check __GNUC__ instead of __CYGWIN__.
+Sun Mar 7 22:37:46 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Mon Mar 8 01:05:55 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/config.rb (WEBrick::Config::HTTP): rename :RequestHander
- to :RequestCallback and add new option :ServerAlias.
+ * test/drb/ut_drb.rb: use 'druby://localhost:0'. [ruby-dev:23078]
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): use
- :RequestCallback and warn if :RequestHandler is in server's option.
+ * test/drb/ut_eval.rb: ditto.
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should print
- error message for WEBrick::HTTPSataus::Error.
+ * test/drb/ut_large.rb: ditto.
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server):
- lookup for hostname from :ServerAlias if the req.host is not match
- to :ServerName.
+ * test/drb/ut_safe1.rb: ditto.
- * lib/webrick/httpservlet.rb (WEBrick::HTTPServlet::CGIHandler#do_GET):
- use $?.exitstatus and refine log message.
+ * test/drb/ut_drb_drbssl.rb: use 'drbssl://localhost:0'.
Sun Mar 7 16:22:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* Makefile.in (lex.c): use $? instead of $<.
- * lib/pstore.rb (commit_new): use FileUtils.copy_stream for Cygwin.
- [ruby-dev:23157]
-
-Sun Mar 7 05:34:42 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: HTTPHeader keeps its header fields as an array.
-
- * lib/net/http.rb: new method HTTPHeader#add_header, get_fields.
-
- * lib/net/http.rb: new method HTTPHeader#content_length=.
-
- * lib/net/http.rb: new method HTTPHeader#content_type, main_type,
- sub_type, type_params, content_type=, set_content_type.
-
- * lib/net/http.rb (HTTPHeader#basic_encode): result of pack(m) may
- contain multiple LFs.
-
-Sun Mar 7 03:11:00 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: new method Net::HTTPRequest#body(=).
-
- * lib/net/http.rb: new method Net::HTTPRequest#body_stream(=).
-
-Sun Mar 7 02:06:07 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: spin off https code again.
-
- * lib/net/https.rb: new file.
-
- * ext/openssl/lib/net/https.rb: removed. moved to net/https with
- slight modifications.
-
- * ext/openssl/lib/net/protocols.rb: removed. merged with net/http.
-
- * lib/net/protocol.rb: new class BufferedIO.
-
- * lib/net/protocol.rb: InternetMessageIO < BufferedIO.
-
- * lib/net/protocol.rb: BufferedIO.new takes an IO.
-
- * lib/net/smtp.rb: follow InternetMessageIO's change.
-
- * lib/net/pop.rb: ditto.
-
-Sun Mar 7 00:55:03 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/protocol.rb: remove method: InternetMessageIO#address,
- port, ip_address, read_timeout(=), socket.
-
- * lib/net/protocol.rb: simplify code.
-
- * lib/net/protocol.rb: apply latest coding style.
-
-Sat Mar 6 15:15:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/strscan/depend: depends on re.h and regex.h.
-
- * ext/strscan/strscan.c: no version check needed.
-
- * ext/strscan/strscan.c (strscan_init_copy): struct re_registers must
- not be bitwise copied.
-
-Sat Mar 6 11:14:33 2004 David Black <dblack@wobblini.net>
-
- * lib/scanf.rb: refixed the previous fix in IO#block_scanf
-
-Sat Mar 6 10:49:40 2004 David Black <dblack@wobblini.net>
-
- * lib/scanf.rb: fixed a logic glitch in IO#block_scanf
-
-Sat Mar 6 02:00:19 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: net/https is merged.
-
- * ext/openssl/lib/net/https.rb: ditto.
-
-Sat Mar 6 00:39:21 2004 Kazuo Saito <ksaito@uranus.dti.ne.jp>
+Fri Mar 5 00:54:14 2004 Dave Thomas <dave@pragprog.com>
- * oniggnu.h: imported from Oniguruma library.
- * oniguruma.h: ditto.
- * regcomp.c: ditto.
- * regenc.c: ditto.
- * regenc.h: ditto.
- * regerror.c: ditto.
- * regex.c: ditto.
- * regexec.c: ditto.
- * reggnu.c: ditto.
- * regint.h: ditto.
- * regparse.c: ditto.
- * regparse.h: ditto.
- * ascii.c: ditto.
- * euc_jp.c: ditto.
- * sjis.c: ditto.
- * utf8.c: ditto.
-
- * MANIFEST: added Oniguruma files listed above.
-
- * LEGAL: added Oniguruma license.
-
- * regex.h: now includes oniggnu.h.
-
- * re.c: applied Oniguruma patch.
-
-Fri Mar 5 23:13:08 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: support WebDAV methods, PROPPATCH, LOCK,
- UNLOCK, OPTIONS, PROPFIND, DELETE, MOVE, COPY, MKCOL.
- This patch is contributed by Tatsuki Sugiura.
-
-Fri Mar 5 20:58:37 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb: Net::HTTPResponse#response is obsolete.
- [ruby-core:02592]
-
- * lib/net/http.rb: Net::HTTPResponse#header is obsolete.
-
- * lib/net/http.rb: Net::HTTPResponse#read_header is obsolete.
-
-Fri Mar 5 20:10:57 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c: new method StringScanner#initialize_copy
- to allow #dup and #clone.
-
- * test/strscan/test_strscan.rb: test StringScanner#dup.
-
-Fri Mar 5 19:42:09 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (HTTPResponse#to_ary): should return an object
- which does not respond to #to_ary. It causes infinite loop in
- puts. [ruby-core:02578]
-
-Fri Mar 5 00:51:35 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/test/unit.rb: Move RDoc documentation so that you can
+ * lib/test/unit.rb: MOve RDoc documentation so that you can
now say 'ri Test::Unit'
-Thu Mar 4 22:31:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in: miniruby is not needed for cross compile.
-
- * configure.in (PREP): miniruby for native compile.
-
-Thu Mar 4 11:46:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/drb/extservm.rb (DRb::ExtServManager#invoke_service_command):
- detach server processes to get rid of zombies.
-
-Thu Mar 4 10:41:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h (T_MASK): save 1 bit in flags bits by shifting T_xxx
- values.
-
-Thu Mar 4 08:08:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/syck/rubyext.c: get rid of warnings.
-
- * lib/rss/taxonomy.rb: ditto.
-
- * lib/rdoc/ri/ri_formatter.rb: ditto.
-
- * test/ruby/test_assignment.rb: ditto.
-
-Thu Mar 4 01:17:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/rdoc/ri/ri_display.rb (DefaultDisplay::page): wait until the
- pager terminates.
-
-Wed Mar 3 13:10:56 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (method_hash): new method. [ruby-talk:93968]
-
- * eval.c (proc_eq): do not compare dyna_vars.
-
- * eval.c (proc_hash): new method.
-
- * eval.c (rb_yield_0): protect break/return from within orphan (or
- lambda) Proc object.
-
-Wed Mar 3 09:52:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/mkmf.rb ($topdir): use compile_dir only when not installed yet.
- [ruby-talk:94098]
-
-Wed Mar 3 01:18:52 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/converter.rb: handled Uconv::Error.
-
- * lib/rss/dublincore.rb: DublincoreModel -> DublinCoreModel
-
-Wed Mar 3 00:59:30 2004 David Black <dblack@wobblini.net>
-
- * lib/scanf.rb: soak_up_spaces only ungetc's non-space last
- character
-
- * lib/scanf.rb: IO#block_scanf now returns partial last iteration
- array if format string matches partly
-
-Tue Mar 2 16:30:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (pipe_open): erred program name should be reported by
- exceptions, instead of the first argument.
-
- * process.c (rb_spawn): ditto.
-
- * process.c (proc_spawn_v): use first argument as program name.
-
- * win32/win32.c (rb_w32_aspawn): ditto.
-
- * win32/win32.c (CreateChild): search executable file if no program
- name given.
-
- * lib/drb/extservm.rb (invoke_service_command): use Process.spawn.
- [ruby-dev:23103]
-
- * lib/rdoc/ri/ri_display.rb (setup_pager): use IO.popen.
- [ruby-dev:23086], [ruby-dev:23103]
-
- * lib/rdoc/diagram.rb (convert_to_png): ditto.
-
- * lib/rdoc/generators/chm_generator.rb (compile_project): ditto.
-
-Tue Mar 2 12:24:03 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Mar 2 12:32:59 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub, wince/Makefile.sub (config.h): shouldn't check
defined? NORETURN. [ruby-dev:23100]
-Tue Mar 2 11:28:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/ruby/test_iterator.rb (test_ljump): cannot use
- assert_nothing_raised due to passing block.
-
-Tue Mar 2 06:23:14 2004 David Black <dblack@wobblini.net>
-
- * lib/scanf.rb: fixed Kernel#scanf to propagate code block
-
-Mon Mar 1 23:25:40 2004 David Black <dblack@wobblini.net>
-
- * lib/scanf.rb: Partial fix so STDIN#scanf works with new
- STDIN#pos behavior
-
-Mon Mar 1 19:42:05 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * bcc32/setup.mak: configure's default is "--enable-install-doc"
-
- * win32/setup.mak: ditto.
-
Mon Mar 1 12:24:10 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_alias):
@@ -30786,105 +17589,38 @@ Sun Feb 29 23:14:53 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_class):
Handle :nodoc: on singleton classes.
-Sat Feb 28 21:50:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bcc32/Makefile.sub, bcc32/README.bcc32, bcc32/configure.bat,
- bcc32/setup.mak: new configure scheme. use ``configure --prefix=dir''
- instead of ``make DESTDIR=dir install''.
- --with-static-linked-ext support on bccwin32. [ruby-dev:23034]
-
-Sat Feb 28 21:50:20 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * bcc32/setup.mak: "configure --disable-install-doc" is now working.
-
- * win32/setup.mak: ditto.
-
-Sat Feb 28 15:09:49 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * bcc32/configure.bat: append missing label ":exit".
-
- * bcc32/configure.bat: fix typo.
-
-Sat Feb 28 10:31:03 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Feb 28 10:58:49 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* MANIFEST: add test_erb.rb
* lib/erb.rb, test/erb/test_erb.rb: don't forget filename,
if both filename and safe_level given. [ruby-dev:23050]
-Sat Feb 28 01:08:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (yylex): should not allow symbol for invalid global
- variable (e.g. `:$-)`). [ruby-core:02518]
-
-Fri Feb 27 20:37:09 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): no orphan block check is needed when pcall
- is true.
-
- * eval.c (localjump_destination): update localjump condition.
-
-Fri Feb 27 02:10:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (localjump_destination): lambda should not interfere
- return from the yielded block.
-
-Fri Feb 27 00:53:49 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Fri Feb 27 01:00:09 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb, test/drb/drbtest.rb: require drb/eq.rb by default
-Thu Feb 26 12:15:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c (make_cmdvector): adjust successive double-quote
- handling.
-
-Thu Feb 26 09:42:56 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (delete_if_i): use st_delete_safe() (via
- rb_hash_delete()) instead of returning ST_DELETE.
-
-Thu Feb 26 02:35:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (rb_f_exec): get rid of SEGV when exec failed for command
- in single string.
-
-Wed Feb 25 21:17:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * gc.c (obj_free), io.c (rb_io_fptr_finalize), rubyio.h (OpenFile):
- sharing OpenFile.
-
- * io.c (rb_io_initialize): accept IO instance. [ruby-dev:22195]
-
-Wed Feb 25 21:16:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Feb 25 21:16:25 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* instruby.rb (with_destdir): should return the given argument if no
DESTDIR is given.
* instruby.rb: use path name expansion of cmd.exe.
-Wed Feb 25 20:44:45 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Feb 25 09:35:22 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/cgi-lib.rb, lib/getopts.rb, lib/importenv.rb, lib/parsearg.rb:
- warn with caller position.
+ * error.c (NameError::Message): new class for lazy evaluation of
+ message to ensure replaced before marshalling. merge from HEAD.
+ (ruby-bugs-ja:PR#588)
- * test/rss/test_content.rb, test/rss/test_dublincore.rb,
- test/rss/test_syndication.rb, test/rss/test_trackback.rb: use cgi
- instead of cgi-lib.
+ * eval.c (rb_method_missing): use NameError::Message. merge from
+ HEAD. (ruby-bugs-ja:PR#588)
-Tue Feb 24 18:42:03 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Tue Feb 24 18:59:37 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* dir.c (glob_helper): '**/' should not match leading period
unless File::FNM_DOTMATCH is set. (like '*/') [ruby-dev:23014]
-Tue Feb 24 18:03:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/ruby/test_file.rb (test_fnmatch): test for dir.c:1.108.
-
-Tue Feb 24 17:07:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (fnmatch): File.fnmatch with File::FNM_PATHNAME was broken
- for the pattern including '*' followed by '/'.
-
Tue Feb 24 13:22:21 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/rdoc.rb (RDoc::RDoc::normalized_file_list): Attempt to get better
@@ -30902,6 +17638,11 @@ Tue Feb 24 06:40:14 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RubyLex::identify_identifier): Handle
class variables in code listings
+Tue Feb 24 06:40:14 2004 Dave Thomas <dave@pragprog.com>
+
+ * lib/rdoc/parsers/parse_rb.rb (RubyLex::identify_identifier): Handle
+ class variables in code listings
+
Tue Feb 24 06:32:27 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_aliases): Handle
@@ -30930,164 +17671,88 @@ Tue Feb 24 03:45:06 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_config.c (Init_ossl_config): include Enumerable.
-Mon Feb 23 09:09:44 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * instruby.rb (parse_args): use optparse instead of getopts.
+Mon Feb 23 09:16:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* instruby.rb (DOSISH): embedded path in batch files should not be
prefixed by DESTDIR. [ruby-core:02186]
-Sun Feb 22 14:58:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb: $extstatic is Array or nil now. [ruby-talk:93383]
+Sun Feb 22 09:54:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub: terminate options.
-
- * lib/mkmf.rb (init_mkmf): $INCFLAGS also should be lazy-evaluated.
+ * re.c: corrected documentation format (again)
-Sun Feb 22 13:05:37 2004 akira yamada <akira@ruby-lang.org>
-
- * lib/uri/mailto.rb (URI::MailTo::to_s): should include fragment.
-
-Sun Feb 22 12:58:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb: use optparse instead of getopts.
-
- * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub: ditto.
-
-Sun Feb 22 09:51:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Sun Feb 22 09:43:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* re.c: corrected documentation format (rb_reg_initialize_m)
-Sat Feb 21 22:41:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Sat Feb 21 22:36:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* ext/zlib/zlib.c: documented, but needs more effort.
-Sat Feb 21 14:33:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb: prefer relative path. [ruby-talk:93037]
-
-Sat Feb 21 11:12:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Feb 21 11:12:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* missing/os2.c, missing/x68.c: typo fix. pointed out by greentea.
-Fri Feb 20 19:11:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/ostruct.rb (OpenStruct#initialize_copy): should not share
- members. [ruby-dev:22966]
-
Fri Feb 20 18:59:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/irb/init.rb (IRB::IRB.parse_opts): add -I option to
irb. [ruby-dev:39243]
-Fri Feb 20 12:55:27 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (pipe_open): fix typo.
-
- * win32/win32.c (CreateChild): first argument to CreateProcess() must
- have path, not just basename.
-
Thu Feb 19 23:24:16 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/html_generator.rb (Generators::HtmlClass::build_attribute_list):
Support visibility modifiers for attributes
-Thu Feb 19 22:39:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Thu Feb 19 23:24:16 2004 Dave Thomas <dave@pragprog.com>
- * lib/ostruct.rb: documented
+ * lib/rdoc/generators/html_generator.rb (Generators::HtmlClass::build_attribute_list):
+ Support visibility modifiers for attributes
Thu Feb 19 22:39:04 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/rinda/test_rinda.rb: DRb.start_service only once in testsuites.
DRb.start_service could handle this.
-Thu Feb 19 22:24:04 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+Thu Feb 19 22:19:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * lib/soap/mapping/rubytypeFactory.rb: should not dump singleton class.
- [ruby-dev:22588]
- c = class << Object.new; class C; self; end; end; SOAPMarshal.dump(c)
+ * lib/ostruct.rb: documented
-Thu Feb 19 18:08:18 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Thu Feb 19 21:28:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* ext/strscan/strscan.c: improved documentation
-Thu Feb 19 18:08:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * win32/win32.c, win32/win32.h: fixed prototypes.
-
- * win32/win32.c (wait): same as waitpid() with -1.
-
-Thu Feb 19 02:34:28 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/markup/simple_markup/preprocess.rb (SM::PreProcess::include_file):
- Only strip comment markers if all lines start with comments.
-
-Thu Feb 19 03:05:49 2004 Minero Aoki <aamine@loveruby.net>
+Thu Feb 19 03:10:52 2004 Minero Aoki <aamine@loveruby.net>
- * ext/strscan/strscan.c: StringScanner#restsize is obsolete;
- use #rest_size instead.
+ * ext/strscan/strscan.c: synchronized with main trunk (rev 1.11).
- * ext/strscan/strscan.c: StringScanner#matchedsize is obsolete;
- use #matched_size instead.
+Thu Feb 19 02:30:34 2004 Minero Aoki <aamine@loveruby.net>
-Thu Feb 19 02:42:19 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c: don't use rb_eval_string, it defines
- classes under the module when required in module clauses.
- [ruby-dev:22951]
-
-Thu Feb 19 02:37:28 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c: merge documentation from 1.8 branch.
- Thanks Gavin Sinclair.
-
-Thu Feb 19 00:20:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/cgi-lib.rb: deprecated after 1.8.1
-
- * lib/getopts.rb: ditto
-
- * lib/importenv.rb: ditto
-
- * lib/parsearg.rb: ditto
+ * ext/strscan/strscan.c: documentation checked.
Thu Feb 19 00:11:05 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/markup/simple_markup/preprocess.rb (SM::PreProcess::handle):
Strip extraneous space from filenames in :include:
-Wed Feb 18 22:53:41 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Feb 18 22:52:00 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/drb/unix.rb: remove O_NONBLOCk, thanks \ay
+ * lib/drb/unix.rb: remove O_NONBLOCK, thanks \ay
-Wed Feb 18 22:42:19 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Feb 18 22:47:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * test/rinda/test_rinda.rb: improt test_rinda.rb
+ * ext/strscan/strscan.c: documented
Wed Feb 18 22:03:11 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/*: should not depend on $KCODE.
-Wed Feb 18 18:07:09 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/ruby/test_sprintf.rb: added tests.
-
Wed Feb 18 17:18:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/win32ole/win32ole.c: need to include <olectl.h> on Cygwin.
Wed Feb 18 10:40:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sprintf.c (rb_f_sprintf): sign bit extension should not be done
- if FPLUS flag is specified. [ruby-list:39224]
-
* sprintf.c (rb_f_sprintf): do not prepend dots for negative
- numbers if FZERO is specified. [ruby-dev:39218]
-
-Wed Feb 18 10:23:34 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * sprintf.c (rb_f_sprintf): clean up.
+ numbers if FZERO is specified. [ruby-list:39218]
Tue Feb 17 23:40:34 2004 Guy Decoux <ts@moulon.inra.fr>
@@ -31096,11 +17761,6 @@ Tue Feb 17 23:40:34 2004 Guy Decoux <ts@moulon.inra.fr>
Tue Feb 17 23:28:45 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * test/soap/marshal/test_marshal.rb, test/ruby/test_marshal.rb: do $:
- trick to share the testcase test/ruby/marshaltestlib.rb.
-
-Tue Feb 17 23:13:23 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
* test/ruby/marshaltestlib.rb: common marshal testcase added.
* test/ruby/test_marshal.rb: use above testsuite.
@@ -31109,282 +17769,108 @@ Tue Feb 17 23:13:23 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/soap/marshal/cmarshal.rb: removed (not used).
-Tue Feb 17 19:34:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb (extmake): $extout_prefix doesn't vary for libraries.
-
- * ext/extmk.rb (extmake): remove compile directory if empty.
-
- * ext/extmk.rb (parse_args) lib/mkmf.rb (create_makefile): move
- initialization of $extout_prefix from lib/mkmf.rb. [ruby-dev:22928]
-
- * ext/extmk.rb: clear ext and extout directory when cleaning.
-
- * lib/mkmf.rb (CLEANLIBS): should be under $(arch) directory.
-
-Tue Feb 17 18:02:10 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/strscan/strscan.c: ScanError may be (wrongly) garbage
- collected. (thanks Gavin Sinclair)
-
- * ext/strscan/strscan.c: move ::ScanError to StringScanner::Error.
- ::ScanError is also defined for backward compatibility.
-
- * ext/strscan/strscan.c: #peep is obsolete, use #peek.
-
- * ext/strscan/strscan.c: #empty? is obsolete, use #eos?.
+Tue Feb 17 10:51:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/strscan/strscan.c: #clear is obsolete, use #terminate.
+ * ext/syck/rubyext.c (syck_emitter_end_object): takes only one arg.
- * ext/strscan/strscan.c: #getbyte is obsolete, use #get_byte.
+Tue Feb 17 01:35:28 2004 Tanaka Akira <akr@m17n.org>
-Tue Feb 17 12:12:47 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * eval.c (rb_eval): care that another thread replace NODE_DREGX_ONCE
+ to NODE_LIT. [ruby-dev:22920]
- * ext/extmk.rb (parse_args): delay expanding $(extout) until invoking
- make.
+Tue Feb 17 01:24:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/mkmf.rb (CLEANLIBS): should remove files have specific
- extensions.
-
-Tue Feb 17 11:33:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * bcc32/Makefile.sub, win32/Makefile.sub (config.h): define
+ STACK_GROW_DIRECTION. [ruby-dev:22910]
- * lib/rss/rexmlparser.rb: REXML version may be 4 digits.
+ * bcc32/Makefile.sub (config.h): add newer checks.
-Tue Feb 17 10:45:59 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+ * wince/Makefile.sub (config.h): define NEED_IO_SEEK_BETWEEN_RW.
- * ext/syck/rubyext.c (syck_emitter_end_object): takes only one arg.
+Tue Feb 17 00:38:10 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Feb 17 07:48:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * lib/rinda/tuplespace.rb: TupleSpace#initialize, stop doubling timeout
- * lib/rexml/encodings/SHIFT_JIS: wrong library name.
+Tue Feb 17 00:18:03 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Feb 17 01:35:28 2004 Tanaka Akira <akr@m17n.org>
+ * test/rinda/test_rinda.rb: import test_rinda.rb
- * eval.c (rb_eval): care that another thread replace NODE_DREGX_ONCE
- to NODE_LIT. [ruby-dev:22920]
+Tue Feb 17 00:14:30 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Tue Feb 17 01:20:57 2004 Minero Aoki <aamine@loveruby.net>
+ * bcc32/Makefile.sub: avoid warning "Redefinition of macro
+ 'HAVE_GETLOGIN'".
- * lib/fileutils.rb: new module FileUtils::DryRun.
+ * vms/config.h_in: ditto.
Mon Feb 16 23:28:14 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/csv.rb: document reduction. [ruby-core:02429]
- * test/yaml/test_yaml.rb: added 0..1 test with "0".."1" on display.
- it should be defined that the specification about what kind of Range
- is supported in ruby's custom type in YAML.
-
-Mon Feb 16 22:22:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Mon Feb 16 22:08:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/generator.rb: corrected doc format
-
* lib/rinda/rinda.rb: added documentation (from Hugh Sasse)
-
* lib/rinda/tuplespace.rb: ditto
- [Note: rinda files actually committed Wed Feb 18 07:27:00 2004]
-
-Mon Feb 16 20:28:52 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Feb 16 20:41:32 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bcc32/Makefile.sub: show more warnings. (refering to mingw)
* bcc32/setup.mak: ditto.
-Mon Feb 16 18:35:58 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Feb 16 13:39:44 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * win32/Makefile.sub (config.status): should create *.pdb on ext/,
- not .ext/.
+ * dir.c (rb_glob, rb_globi): add const.
- * win32/Makefile.sub (config.status): convert the name of import
- library.
+ * ruby.h: ditto.
- * lib/mkmf.rb (create_makefile): now don't need to remove
- $(TARGET).lib.
-
-Mon Feb 16 15:45:22 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: check functions, fork spawnv.
-
- * io.c (rb_io_s_popen): accept argv not only single command line.
-
- * process.c (rb_proc_exec_n): export.
-
- * process.c (rb_check_argv): check if arguments are safe to invoke.
-
- * process.c (rb_fork): retry to fork.
-
- * process.c (rb_spawn): spawn child process asynchronously.
-
- * process.c (rb_f_system): raise an exception if the command could not
- execute.
-
- * win32/win32.c (rb_w32_argv_size): count necessary size for joined
- arguments.
-
- * win32/win32.c (rb_w32_join_argv): join arguments with quoting.
-
- * win32/win32.c (rb_w32_pipe_exec, rb_w32_spawn, rb_w32_aspawn):
- accept program name adding to command line.
-
-Mon Feb 16 15:18:33 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/racc/parser.rb: add note for Racc full package.
-
-Mon Feb 16 15:13:01 2004 Minero Aoki <aamine@loveruby.net>
-
- * ext/racc/cparse/README: new file.
-
- * ext/racc/cparse/MANIFEST: add README.
-
-Mon Feb 16 12:29:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_s_list): new method Iconv.list
- (libiconv only).
-
-Mon Feb 16 10:29:52 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (CompareImpl): File.fnmatch and Dir.glob get better performance
- in Win32. This is achived by calling downcase() for single-byte
- characters. (CharLower() is slower than downcase())
-
-Mon Feb 16 02:14:29 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Feb 16 02:16:33 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* bcc32/Makefile.sub: should warn suspicious pointer conversion.
* bcc32/setup.mak: ditto.
-Sun Feb 15 20:56:22 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (push_braces): remove wrong const. [ruby-dev:22891]
-
-Sun Feb 15 20:41:15 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * sample/soap/calc/httpd.rb, sample/soap/exchange/httpd.rb,
- sample/soap/sampleStruct/httpd.rb, sample/wsdl/googleSearch/httpd.rb:
- use soap/property instead of getopts for configuring DocumentRoot
- and port# of httpd. see samplehttpd.conf below.
-
- * sample/soap/calc/samplehttpd.conf,
- sample/soap/exchange/samplehttpd.conf,
- sample/soap/sampleStruct/samplehttpd.conf,
- sample/wsdl/googleSearch/samplehttpd.conf: added.
-
-Sun Feb 15 19:13:33 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sun Feb 15 19:06:42 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/rinda/tuplespace.rb: read(tpl,0), raise RequestExpiredError
- if not found.
+ * lib/rinda/tuplespace.rb: TupleSpace#read(tpl, 0), raise
+ RequestExpiredError if not found.
-Sun Feb 15 15:48:57 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+Sun Feb 15 15:56:46 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c: add IDispatch wrapper in val2variant.
Thanks, arton.
-Sun Feb 15 15:23:29 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * ruby.h, dir.c (rb_glob): add const.
-
Sun Feb 15 01:46:05 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/mkmf.rb: absolute path of ruby is assigned to $(RUBY).
[ruby-dev:22870]
-Sat Feb 14 23:59:11 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * mkconfig.rb: use fileutils.rb instead of ftools.rb.
-
- * bcc32/Makefile.sub, win32/Makefile.sub (config.h): define
- STACK_GROW_DIRECTION.
-
- * bcc32/Makefile.sub (config.h): add newer checks.
-
- * wince/Makefile.sub (config.h): define NEED_IO_SEEK_BETWEEN_RW.
-
-Sat Feb 14 23:26:27 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/un.rb: use OptionParser instead of getopts.
-
-Sat Feb 14 11:28:14 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Feb 14 11:29:41 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* sample/drb/*: import lib/drb/sample
-Sat Feb 14 11:14:12 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Sat Feb 14 11:08:23 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: add pretty_print, thanks gotoken.
-Fri Feb 13 21:51:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/fileutils.rb: slighly improved documentation (sync with 1.8)
-
-Fri Feb 13 19:57:01 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * test/rss/test_trackback.rb: added tests for TrackBack with RSS
- 2.0.
-
- * test/rss/common.rb: added methods make RSS 2.0.
-
- * lib/rss/trackback.rb: TrackBack API is decided.
+Fri Feb 13 12:35:08 2004 Minero Aoki <aamine@loveruby.net>
- * lib/rss/rss.rb: RSS::VERSION 0.0.7 -> 0.0.8.
+ * test/fileutils/test_fileutils.rb: File.link may raise EINVAL and
+ EACCES on Windows.
- * lib/rss/parser.rb, lib/rss/rss.rb: replaced $DEBUG by RSS::DEBUG.
-
- * lib/rss/2.0.rb: removed RSS 2.0 URI. Because RSS 2.0 doesn't
- have URI.
-
-Fri Feb 13 14:41:00 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: en-bugged at last commit (Feb 11 23:24:22 2004)
-
-Fri Feb 13 12:26:37 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/fileutils/test_fileutils.rb: rescue SystemCallError instead
- of EINVAL. File.link may raise EACCES on network file systems.
-
-Fri Feb 13 05:18:58 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/fileutils/test_fileutils.rb: File.link raises EINVAL on
- Win9x. [ruby-dev:22713]
-
-Thu Feb 12 21:49:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Thu Feb 12 21:45:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
* lib/ftools.rb: documented
-Thu Feb 12 21:19:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/base64.rb: added and tidied documentation
+Thu Feb 12 21:25:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Thu Feb 12 20:45:01 2004 Minero Aoki <aamine@loveruby.net>
+ * lib/base64.rb: backported from HEAD (modularised and documented)
- * lib/net/protocol.rb (WriteAdapater#puts): must append "\n" to
- the string, don't prepend. (ruby-bugs:PR#1280)
-
-Thu Feb 12 20:31:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Feb 12 20:31:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (create_tmpsrc): cpp32 of Borland C++ ignores #error
directives in DOS line-ending files at all.
-Thu Feb 12 15:23:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (rparen): ignore preceding newlines to right parentheses.
- (ruby-bugs:PR#1221) [ruby-dev:22858]
-
-Thu Feb 12 14:17:43 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in: set ac_cv_func_link to yes to enable link() on MinGW.
- [ruby-dev:22241]
-
-Thu Feb 12 13:32:49 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (link): raise NotImplementedError on Win9X.
- contributed by Tietew. [ruby-dev:22713]
-
- * win32/win32.c, win32/win32.h (link): add const.
-
-Thu Feb 12 09:56:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/tk/lib/tk.rb (TkComm::tk_split_list): suppress a warning.
-
Thu Feb 12 02:23:56 2004 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb: use assert_raise instead of assert_raises.
@@ -31396,91 +17882,26 @@ Thu Feb 12 02:23:56 2004 Tanaka Akira <akr@m17n.org>
* lib/tsort.rb: ditto.
use TSortHash and TSortArray instead of Hash and Array in test.
-Wed Feb 11 23:24:22 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: properly treat a Tcl/Tk's string with escaping
- special characters.
-
-Tue Feb 10 20:49:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (method_proc): return bound Proc object. [ruby-dev:22854]
-
- * eval.c (rb_mod_define_method): bind method body itself for Method
- object.
-
- * node.h (NODE_DMETHOD): deprecated.
-
- * object.c (rb_class_inherited_p): export.
-
-Tue Feb 10 16:43:50 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (umethod_bind): purge unused check. [ruby-dev:22850]
-
-Tue Feb 10 14:33:08 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * string.c (rb_str_match): raise TypeError when both arguments are
- strings. [ruby-dev:22851]
-
- * string.c (rb_str_match2): removed.
-
- * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
- wince/Makefile.sub (string.c): now not depend on version.h.
-
-Mon Feb 9 17:46:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub, configure.in,
- runruby.rb: run rdoc, test and so on with compiled extension
- libraries. [ruby-dev:22688]
-
- * ext/extmk.rb, lib/mkmf.rb: make extension libraries in separated
- directory, similar to the actual directory structure.
-
- * lib/fileutils.rb (FileUtils.copy_file): use the mode of the original
- file to create new file.
-
- * lib/rdoc/ri/ri_paths.rb (RI::Paths::SYSDIR): get rid of unexpected
- influence by envirionment variable.
-
- * bcc32/configure.bat, win32/configure.bat: add install-doc options.
-
- * win32/win32.c, win32/win32.h (rb_w32_fstat): fix Borland C runtime
- bug which returns wrong mode. [ruby-dev:22846]
-
-Mon Feb 9 16:30:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * process.c (detach_process_watcher): return the last status.
- [ruby-dev:22841]
-
-Sun Feb 8 16:46:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/pp.rb (PP::PPMethods::object_address_group): suppress negative
- sign for higher heap areas.
-
-Sun Feb 8 16:18:27 2004 akira yamada <akira@ruby-lang.org>
-
- * test/yaml/test_yaml.rb (YAML_Unit_Tests::test_range_cycle):
- added tests.
-
-Sun Feb 8 15:51:57 2004 akira yamada <akira@ruby-lang.org>
+Wed Feb 11 20:01:12 2004 akira yamada <akira@ruby-lang.org>
* test/ruby/test_file.rb (TestFile::test_fnmatch): added tests for
File.fnmatch. [ruby-dev:22815][ruby-dev:22819]
-Sun Feb 8 15:41:45 2004 akira yamada <akira@ruby-lang.org>
+ * test/ruby/test_proc.rb (TestProc::test_eq): added a
+ test. [ruby-dev:22599]
- * test/yaml/test_yaml.rb (YAML_Unit_Tests::test_range_cycle):
- added tests. [ruby-core:02306] [ruby-core:02311]
+ * test/ruby/test_proc.rb (TestProc::test_eq): added tests for
+ Proc#==. [ruby-dev:22592], [ruby-dev:22601]
-Sun Feb 8 14:24:35 2004 Minero Aoki <aamine@loveruby.net>
+Tue Feb 10 16:43:56 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/http.rb (HTTP#request): should not overwrite Connection
- header. (ruby-bugs:PR#1274)
+ * eval.c (umethod_bind): purge unused check. [ruby-dev:22850]
-Sun Feb 8 10:11:21 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Feb 9 17:16:00 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * dir.c (glob_helper): Dir.glob('**/') did not work. [ruby-dev:22832]
+ * lib/rdoc/parsers/parse_c.rb: escape '{' and '}' to avoid warnings.
-Sun Feb 8 00:29:26 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+Mon Feb 9 13:00:55 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* dir.c (fnmatch): File.fnmatch('*?', 'a') should return true.
[ruby-dev:22815]
@@ -31488,14 +17909,10 @@ Sun Feb 8 00:29:26 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* dir.c (fnmatch): File.fnmatch('\[1\]' , '[1]') should return true.
[ruby-dev:22819]
- * dir.c: Did some styles (no change to behavior)
+Sun Feb 8 16:46:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Feb 7 19:56:11 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/irb/init.rb (IRB.rc_files): yield possible rc file names.
-
- * lib/irb/input-method.rb (IRB::ReadlineInputMethod::initialize):
- load and save history automatically. [ruby-core:02352]
+ * lib/pp.rb (PP::PPMethods::object_address_group): suppress negative
+ sign for higher heap areas.
Fri Feb 6 22:48:16 2004 Dave Thomas <dave@pragprog.com>
@@ -31512,27 +17929,6 @@ Fri Feb 6 22:22:50 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/pp.rb (PPInspectTest#test_to_s_with_iv): remove instance
variable which is defined in the test.
-Fri Feb 6 18:54:18 2004 akira yamada <akira@ruby-lang.org>
-
- * test/ruby/test_proc.rb (TestProc::test_eq): added a
- test. [ruby-dev:22599]
-
-Fri Feb 6 18:26:00 2004 akira yamada <akira@ruby-lang.org>
-
- * test/ruby/test_proc.rb (TestProc::test_eq): added tests for
- Proc#==. [ruby-dev:22592], [ruby-dev:22601]
-
-Fri Feb 6 10:12:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/socket/socket.c (bsock_do_not_reverse_lookup): control reverse
- lookup for every instance. [ruby-core:02346]
-
-Fri Feb 6 09:15:11 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/irb/extend-command.rb: add irb_help command. [ruby-talk:91610]
-
- * lib/irb/cmd/help.rb (IRB::ExtendCommand::Help): show RDoc.
-
Fri Feb 6 00:48:37 2004 Tanaka Akira <akr@m17n.org>
* lib/prettyprint.rb (PrettyPrint#first?): obsoleted.
@@ -31549,10 +17945,6 @@ Thu Feb 5 23:56:55 2004 Tanaka Akira <akr@m17n.org>
* lib/set.rb (Set#pretty_print): use seplist.
-Wed Feb 4 22:39:46 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (rb_stat_mode): should not sign-expand, so backout.
-
Wed Feb 4 02:12:06 2004 Tanaka Akira <akr@m17n.org>
* file.c (test_l): fix wrong method name in document.
@@ -31563,37 +17955,19 @@ Wed Feb 4 02:12:06 2004 Tanaka Akira <akr@m17n.org>
(test_sgid): ditto.
(test_sticky): ditto.
-Tue Feb 3 22:36:25 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/2.0.rb, lib/rss/content.rb, lib/rss/dublincore.rb,
- lib/rss/rss.rb, lib/rss/syndication.rb: removed warnings.
-
- * lib/rss/converter.rb: removed handling load error of nkf.
-
- * test/rss/test_syndication.rb, test/rss/test_trackback.rb,
- test/rss/test_dublincore.rb, test/rss/test_content.rb: replaced
- 'require "rss/parser"' by 'require "rss/1.0"'.
-
- * test/rss/test_parser.rb, test/rss/test_accessor.rb: removed
- 'require "rss/parser"'.
-
-Tue Feb 3 11:23:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (reduce_nodes): remove tail returns. [ruby-talk:90934]
-
Tue Feb 3 08:04:57 2004 Tanaka Akira <akr@m17n.org>
* lib/pp.rb (Struct#pretty_print_cycle): follow 1.8 style.
-Mon Feb 2 22:06:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Feb 2 19:33:49 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * parse.y (block_append, new_evstr, void_expr0): remove no longer used
- labels.
+ * configure.in: backport from 1.9 for Interix.
-Mon Feb 2 18:45:50 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+ * dln.c (dln_load): ditto.
- * dln.c (dln_load): don't specify RTLD_GLOBAL on Interix,
- because it caused SEGV when running runner.rb.
+Mon Feb 2 13:31:51 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/net/http.rb (canonical_each): fix merge miss.
Mon Feb 2 01:54:00 2004 Tanaka Akira <akr@m17n.org>
@@ -31615,14 +17989,12 @@ Mon Feb 2 01:54:00 2004 Tanaka Akira <akr@m17n.org>
(UDPSocket#send): recognize 3 arguments form. try all addresses on
4 arguments form.
-Sun Feb 1 23:00:00 2004 Shigeo Kobayashi <shigek@ruby-lang.org>
+Sun Feb 1 18:17:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * ext/bigdecimal.c: Bug in BigDecimal("1e#{n}").add BigDecimal('.5'),n)
- reported and fixed by Javier Goizueta.
+ * lib/net/http.rb: merged coding style changes from HEAD.
-Sun Feb 1 18:21:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
+Sun Feb 1 16:15:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- From ruby_1_8 branch:
* lib/test/unit.rb: rearranged documentation for RDoc's sake.
* lib/matrix.rb: improved documentation.
* lib/net/http.rb: slight documentation formatting improvement.
@@ -31633,32 +18005,27 @@ Sun Feb 1 05:30:06 2004 Tanaka Akira <akr@m17n.org>
raise an errror on non-http proxy URI.
(OpenURI::Buffer#<<): make a tempfile binmode. [ruby-talk:90793]
-Sun Feb 1 00:57:41 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss/parser.rb (RSS::Parser): added @@default_parser. Used
- XML parser became selectable.
- * test/rss/test_parser.rb: added tests for
- RSS::Parser.default_parser.
+Sat Jan 31 09:20:32 2004 NAKAMURA, Hiroshi <nakahiro@sairon.co.jp>
-Sat Jan 31 02:28:15 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+ * sample/openssl/gen_csr.rb: wrong usage string.
- * configure.in (RPATHFLAG): set to -Wl,-R like NetBSD on Interix.
+Sat Jan 31 01:00:32 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Sat Jan 31 01:09:41 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/logger.rb: leading 0 padding of timestamp usec part.
+ * lib/soap/wsdlDriver.rb, lib/wsdl/soap/operation.rb: add support of
+ "parts" attribute of soap:body element in WSDL.
-Fri Jan 30 18:53:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/wsdl/xmlSchema/schema.rb: friendly warning message for
+ simpleType element which is not supported for now.
- * re.c (KR_REHASH): wrong hash value on sizeof(long) > sizeof(int).
+ * lib/soap/mapping/factory.rb: deleted unused methods.
-Thu Jan 29 23:11:57 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+ * lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
+ string <-> Ruby class name matching.
- * configure.in (DLEXT2): removed. Ruby does not treat
- ".dll" as a extention library anymore.
+ * test/wsdl/soap/{soapbodyparts.wsdl,test_soapbodyparts.wsdl}: new
+ files.
- * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub (DLEXT2):
- ditto.
+Thu Jan 29 23:56:00 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* util.c (mblen): fix overrun. [ruby-dev:22672]
@@ -31667,83 +18034,36 @@ Thu Jan 29 22:41:53 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/generators/html_generator.rb: Allow 'link:' in Tidylinks.
THis means you can write "see f1[link:files/f1_rb.html]".
-Thu Jan 29 22:24:47 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * sample/openssl/gen_csr.rb: follow OpenSSL::X509::Name change.
- ASN.1 type of subject DN elements were wrong.
+Thu Jan 29 15:33:23 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Thu Jan 29 22:19:51 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/*: remove $: trick. [ruby-dev:22763] use test/runner.rb to
- run test.
-
-Thu Jan 29 19:28:16 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (Request#initialize): reject only when a path is
- empty. [ruby-dev:22771]
-
-Thu Jan 29 18:54:08 2004 H.Yamamoto <ocean@m2.ccsnet.ne.jp>
-
- * dir.c (glob_helper): infinite loop bug in win32 code.
- [ruby-dev:22770]
-
-Thu Jan 29 17:03:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c: merge tuning from H.Yamamoto <ocean@m2.ccsnet.ne.jp>.
- [ruby-dev:22761]
-
-Thu Jan 29 11:32:14 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/rss/test_*: do $: trick while searching a module in the current
- directory.
-
- * test/xsd/test_xmlschemaparser.rb, test/wsdl/test_emptycomplextype.rb,
- test/soap/helloworld/test_helloworld.rb,
- test/soap/calc/{test_calc.rb,test_calc2.rb}: do File.expand_path
- before using __FILE__.
-
- * test/yaml/test_yaml.rb: assert_equals -> assert_equal.
-
-Thu Jan 29 01:56:02 2004 why the lucky stiff <why@ruby-lang.org>
-
- * ext/syck/rubyext.c: usec round-tripping skew. [ruby-core:2305]
-
- * lib/yaml/rubytypes.rb: character Range now round-trips. [ruby-core:2306]
-
- * test/yaml/test_yaml.rb: add Time and Range tests.
-
-Thu Jan 29 00:00:46 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss: rss/parser.rb is always required.
-
-Wed Jan 28 15:09:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_x509hame.c (ossl_x509name_initialize): change
+ second argument. it expected to be a Hash not an Integer.
- * test/rss/*.rb: remove "test/" prefix.
+ * ext/openssl/ossl_x509name.c (ossl_x509name_add_entry): add new
+ function for OpenSSL::X509::Name#add_entry.
-Wed Jan 28 13:07:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+ * ext/openssl/ossl_x509name.c (ossl_x509name_to_a): append ASN.1
+ tag number to each element of return value.
- * ext/iconv/extconf.rb: include iconv.h for libiconv. [ruby-dev:22715]
+ * ext/openssl/ossl_x509name.c (Init_ossl_x509name): add constants
+ OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE and OBJECT_TYPE_TEMPLATE.
-Wed Jan 28 12:43:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name#initialize):
+ second argument takes OBJECT_TYPE_TEMPLATE by default.
- * lib/rss: rss library imported. [ruby-dev:22726]
+ * sample/openssl/gen_csr.rb: use OpenSSL::X509::Name.parse.
Wed Jan 28 04:29:41 2004 Eric Schwartz <emschwar@fc.hp.com>
* lib/cgi/session.rb: use LOCK_SH to read, and a few other
improvements. [ruby-core:02328]
-Tue Jan 27 15:00:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * misc/ruby-mode.el: better support for general delimited
- strings. [ruby-dev:22695]
-
-Tue Jan 27 11:04:40 2004 FUKUMOTO Atsushi <fukumoto@nospam.imasy.or.jp>
+Tue Jan 27 11:09:29 2004 FUKUMOTO Atsushi <fukumoto@nospam.imasy.or.jp>
* ext/socket/socket.c (s_recvfrom): sending length should be an
invariant while retrying on EAGAIN. [ruby-talk:89962]
-Tue Jan 27 10:31:28 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Tue Jan 27 10:35:18 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/win32ole/win32ole.c (set_argv): fix condition.
@@ -31752,14 +18072,19 @@ Tue Jan 27 02:26:31 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httputils.rb (WEBrick:HTTPUtils::parse_header):
refine regex for header-name.
+Tue Jan 27 00:30:11 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub: rollback.
+
Mon Jan 26 22:53:04 2004 Dave Thomas <dave@pragprog.com>
* io.c: Remove documentation references to $defout.
-Mon Jan 26 14:41:46 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Jan 26 15:11:47 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/weakref.rb (WeakRef::initialize): set up @__id before
- calling "super".
+ * sample/exyacc.rb: escape '}' to avoid warning.
+
+Mon Jan 26 14:41:46 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (Delegator::initialize): preserve
singleton_method_added method [ruby-dev:22685]
@@ -31767,11 +18092,11 @@ Mon Jan 26 14:41:46 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (Delegator::initialize): use Kernel::raise
instead of mere raise. [ruby-dev:22681]
-Mon Jan 26 12:45:23 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+Mon Jan 26 12:47:17 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c: define CONST84 when TCL_MAJOR_VERSION == 7
-Mon Jan 26 11:30:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jan 26 11:35:23 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb: Makefiles should depend on also rbconfig.rb.
(ruby-bugs:PR#1256)
@@ -31779,112 +18104,18 @@ Mon Jan 26 11:30:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/win32ole/win32ole.c (set_argv): set real arguments to
WIN32OLE::ARGV. [ruby-list:39073]
-Sun Jan 25 18:25:26 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_add_entry): third
- argument become optional.
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_initialize): ditto.
-
- * ext/openssl/ossl_x509name.c (Init_x509name): emailAddress and
- domainComponent should be IA5String.
-
-Sun Jan 25 01:45:38 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): support
- virtual host.
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#virtual_host): add
- new method to register virtual hosting server.
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#lookup_server): add
- new method to lookup virtual hosting server.
-
-Sat Jan 24 13:06:26 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_x509hame.c (ossl_x509name_initialize): change
- second argument. it expected to be a Hash not an Integer.
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_add_entry): add new
- function for OpenSSL::X509::Name#add_entry.
-
- * ext/openssl/ossl_x509name.c (Init_ossl_x509name): add constants
- OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE and OBJECT_TYPE_TEMPLATE.
-
- * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name#initialize):
- second argument takes OBJECT_TYPE_TEMPLATE by default.
-
-Fri Jan 23 02:26:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * pack.c (num2i32): pack should not raise RangeError.
- [ruby-dev:22654]
-
- * pack.c (pack_pack): do not auto convert nil to zero.
-
Thu Jan 22 22:54:53 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (BEG_REGEXP): allow 8-bit characters in quoted
strings for Novell GroupWise Internet Agent.
-
* lib/net/imap.rb (DATA_REGEXP): ditto.
-Thu Jan 22 18:35:49 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/e2mmap.rb (VERSION): remove unnecessary version checking.
-
-Thu Jan 22 16:21:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Thu Jan 22 16:21:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (string_content): reset lexical states at the beginning of
string contents. [ruby-list:39061]
-Thu Jan 22 08:08:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (opt_rescue): use NODE_ERRINFO() instead of
- NODE_GVAR("$!"), to avoid confusion from variable aliasing.
- [ruby-talk:90074]
-
- * version.c (Init_version): remove obsolete constants VERSION
- etc. [ruby-dev:22643]
-
-Thu Jan 22 01:46:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (newline_node): do not use NODE_NEWLINE node anymore,
- use NEWLINE flag instead.
-
-Thu Jan 22 01:12:12 2004 Siena. <siena@faculty.chiba-u.jp>
-
- * missing/os2.c (chdir, getcwd):
- use _chdir2 and _getcwd2 supporting multiple drives in OS/2 with EMX.
-
-Thu Jan 22 00:33:52 2004 Siena. <siena@faculty.chiba-u.jp>
-
- * configure.in: check availability of link(). [ruby-dev:22237]
- * file.c (rb_file_s_link): raise an exception when link() is unavailable.
- * missing/os2.c (link): removed. File#link isn't supported.
- * bcc32/Makefile.sub: define HAVE_LINK to enable link(). [ruby-dev:22241]
- * win32/Makefile.sub: ditto.
-
-Thu Jan 22 00:26:25 2004 Siena. <siena@faculty.chiba-u.jp>
-
- * ChangeLog: typo: RUBY_MBCHAR_MAX was RUBY_MBCHAR_MAXSIZE.
-
-Thu Jan 22 00:12:51 2004 Siena. <siena@faculty.chiba-u.jp>
-
- * defines.h: define RUBY_MBCHAR_MAX instead of MB_CUR_MAX.
- * dir.c (Next, emx_mblen): use RUBY_MBCHAR_MAX for mblen().
- * file.c (CharNext): ditto.
- * ruby.c (translate_char): ditto.
- * util.c (__crt0_glob_function): ditto.
-
-Thu Jan 22 00:10:01 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/base64.rb: :nodoc: the Deprecated module
-
-Wed Jan 21 23:52:39 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in: Interix(SFU) support.
-
-Wed Jan 21 23:03:45 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+Wed Jan 21 21:55:51 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/drb.rb: remove O_NONBLOCK, thanks \ay
* lib/drb/extserv.rb: typo
@@ -31897,28 +18128,21 @@ Wed Jan 21 17:57:56 2004 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (ensure_nz_number): show a detailed error
message.
-Wed Jan 21 16:44:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 21 16:44:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (merge_libs): squeeze successive same libraries.
[ruby-dev:22652]
-Wed Jan 21 16:10:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/base64.rb: enclosed in a module. [ruby-core:02285]
-
-Wed Jan 21 16:01:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 21 16:01:37 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/digest/rmd160/extconf.rb: have_library appends found library.
Wed Jan 21 11:36:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/socket.c (sock_gethostbyname): returns host if
- ai_canonname is NULL. (ruby-bugs PR#1243)
-
* parse.y (block_append): update nd_end for "real" head node.
[ruby-list:39058]
-Tue Jan 20 14:48:28 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Tue Jan 20 14:48:13 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: should check <openssl/conf_api.h> instead
of OPENSSL_VERSION_NUMBER. [ruby-list:39056]
@@ -31938,57 +18162,25 @@ Tue Jan 20 13:22:39 2004 Dave Thomas <dave@pragprog.com>
* lib/English.rb: Document English.rb.
-Tue Jan 20 04:41:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/ruby/test_marshal.rb (MarshalTestLib::test_exception): test
- for [ruby-dev:22604].
-
- * test/ruby/test_marshal.rb (MarshalTestLibtest_singleton): test
- for [ruby-dev:22588].
-
-Tue Jan 20 02:38:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (w_class): should not dump singleton class.
- [ruby-dev:22631]
-
Tue Jan 20 02:49:22 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: add check for OpenSSL version.
[ruby-list:39054]
-Mon Jan 19 23:56:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * error.c (name_err_mesg_to_str): inverted condition for result of
- inspection. [ruby-dev:22628]
-
-Mon Jan 19 22:24:28 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * sample/exyacc.rb: escape '}' to avoid warning.
-
- * lib/rdoc/parsers/parse_c.rb: escape '{' and '}' to avoid warnings.
-
-Mon Jan 19 21:28:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/digest/defs.h, win32/win3.c, win32/win32.h, file.c: remove
- useless casts for Borland C.
-
-Mon Jan 19 17:39:38 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * error.c (NameError::message): internal use only.
+Tue Jan 20 02:38:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_method_missing): use hidden constant.
+ * marshal.c (w_class): should not dump singleton class.
+ [ruby-dev:22631]
-Mon Jan 19 16:30:53 2004 akira yamada <akira@ruby-lang.org>
+Tue Jan 20 01:31:36 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * test/ruby/test_time.rb: added tests for [ruby-dev:22614] and
- [ruby-dev:22617].
+ * io.c (lineno): typo fix(FIX2INT -> INT2FIX).
-Mon Jan 19 13:09:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+Mon Jan 19 21:53:38 2004 akira yamada <akira@ruby-lang.org>
- * ext/extmk.rb, win32/Makefile.sub, win32/configure.bat,
- win32/setup.mak: --with-static-linked-ext support on mswin32.
+ * io.c, re.c, string.c, time.c: fixed up positions of RDocs.
-Mon Jan 19 06:49:07 2004 Tadayoshi Funaba <tadf@dotrb.org>
+Mon Jan 19 07:09:20 2004 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date.rb: zone was wrong when it was behind UTC.
Thanks Mark J. Reed.
@@ -31998,53 +18190,10 @@ Mon Jan 19 06:49:07 2004 Tadayoshi Funaba <tadf@dotrb.org>
* sample/cal.rb: added a class, anyway.
-Mon Jan 19 01:08:39 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c, error.c, eval.c, intern.h, object.c, variable.c:
- do not set path if it is a singleton class. [ruby-dev:22588]
-
- * lib/cgi.rb (CGI::QueryExtension): give extended string, not a
- delegater object.
-
-Sun Jan 18 23:59:44 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/charset_alias.rb: prefer us_EN locale encodings or
- former. [ruby-dev:22609]
-
- * ext/iconv/iconv.c (iconv_create): raise InvalidEncoding
- exception when EINVAL.
-
-Sun Jan 18 23:16:34 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * class.c, error.c, file.c, io.c, numeric.c, object.c, re.c, struct.c,
- time.c: marked init_copy functions nodoc.
-
Sun Jan 18 20:47:35 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* ruby.c: use translate_char() on Cygwin.
-Sun Jan 18 20:00:16 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/soap/wsdlDriver.rb, lib/wsdl/soap/operation.rb: add support of
- "parts" attribute of soap:body element in WSDL.
-
- * lib/wsdl/xmlSchema/schema.rb: friendly warning message for
- simpleType element which is not supported for now.
-
- * test/wsdl/soap/{soapbodyparts.wsdl,test_soapbodyparts.wsdl}: new
- files.
-
-Sun Jan 18 16:46:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * time.c (time_overflow_p): should return results. [ruby-dev:22614]
-
-Sun Jan 18 12:07:24 2004 Siena. <siena@faculty.chiba-u.jp>
-
- * test/ruby/test_time.rb: new test case to test Time#[+-].
-
- * time.c (time_plus, time_minus): fix RangeError for a negative
- argument in environments whose time_t is unsigned. [ruby-dev:22608]
-
Sun Jan 18 02:33:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* defines.h (_WIN32): undef _WIN32 on Cygwin before defining DOSISH.
@@ -32054,136 +18203,59 @@ Sun Jan 18 00:23:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (class2path): check anonymous class/module before
checking referable, and allow singleton classes.
-Sat Jan 17 23:58:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * error.c (NameError::Message): new class for lazy evaluation of
- message to ensure replaced before marshalling. [ruby-dev:22604]
-
- * eval.c (rb_method_missing): use NameError::Message.
-
-Sat Jan 17 21:49:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/time.rb (test_rfc2822, test_rfc3339, test_encode_xmlschema):
- should not expect that all platforms handle negative time_t value.
-
-Fri Jan 16 23:53:09 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (proc_eq): compare also arguments and environment
- (including local variables). [ruby-dev:22590]
-
Fri Jan 16 14:33:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (class2path): get class path and check referable.
[ruby-dev:22588]
-Thu Jan 15 12:58:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jan 16 09:52:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_eq): Proc with empty body may not be equal.
+ [ruby-dev:22590]
+
+Thu Jan 15 13:03:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (argf_read): do not append EOF. (ruby-bugs-ja:PR#585)
* io.c (rb_io_fwrite): ad-hockery hack to get rid of HP-UX stdio
weird behavior. [ruby-dev:22424]
-Wed Jan 14 21:13:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/inlinetest.rb (InlineTest::eval_part): eval under the top
- level environment.
-
-Wed Jan 14 17:54:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/inlinetest.rb (InlineTest::loadtest): require instead of
- load, to get rid of multiple loading.
-
-Wed Jan 14 13:30:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Jan 14 13:31:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/extconf.rb: wrapper iconv.rb is dependent on platform.
-Wed Jan 14 09:32:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * MANIFEST: add test/net/test_httpheader.rb. (commit miss?)
-
-Wed Jan 14 00:58:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (Init_Proc): move SystemStackError from under
- StandardError to Exception. [ruby-talk:89782]
-
-Tue Jan 13 18:03:02 2004 Ian Macdonald <ian@caliban.org>
-
- * file.c (rb_stat_wr, rb_stat_ww): New functions
- implementing new methods (File::Stat#world_readable?,
- File::Stat#world_writable?).
-
-Tue Jan 13 16:53:25 2004 why the lucky stiff <why@ruby-lang.org>
+Tue Jan 13 18:54:28 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * ext/syck/rubyext.c: omission of Date library code caused
- test suite failure. [ruby-core:2251]
-
-Tue Jan 13 16:50:03 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: use $0 as the default application class name.
-
-Tue Jan 13 14:48:00 2004 Ian Macdonald <ian@caliban.org>
-
- * lib/pathname.rb: New methods (Pathname#world_readable?,
- Pathname#world_writable?).
-
-Tue Jan 13 14:48:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (primary): allow no "when" case. [ruby-dev:22578]
+ * lib/logger.rb(Logger#msg2str): no special treatment for the object
+ which responds to :to_str. commited at 2004-01-11T21:46:27 by
+ gsinclair.
- * ruby.h (rb_class_of): reduce branch. [ruby-dev:22577]
+ * lib/logger.rb(LogDevice#initialize): remove type checking if the
+ given object is a String. Kernel.open handles it correctly.
+ commited at 2004-01-11T21:46:27 by gsinclair.
- * ruby.h (rb_type): ditto.
+ * test/logger/test_logger.rb: follow above change (ArgumentError ->
+ TypeError.) follow above commit.
-Tue Jan 13 14:26:59 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+Tue Jan 13 14:27:13 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* lib/test/unit/ui/testrunnerutilities.rb (TestRunnerUtilities):
moved run method which allows output level. [ruby-dev:22554]
-Tue Jan 13 13:04:24 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/test_*.rb: Pathname#parent -> Pathname#dirname.
-
-Tue Jan 13 11:38:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/yaml/test_yaml.rb (YAML_Unit_Tests::test_spec_type_{int,float}):
- fix syntax error.
-
-Tue Jan 13 07:52:40 2004 why the lucky stiff <why@ruby-lang.org>
-
- * ext/syck/bytecode.c: turn off default implicit typing.
-
- * ext/syck/implicit.c: detect base60 integers.
-
- * ext/syck/rubyext.c: handle base60, as well as hex and octal
- with commas. implicit typing of ruby symbols.
-
- * test/yaml/test_yaml.rb: add test.
-
Tue Jan 13 04:29:52 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_driver.rb (RiDriver::report_method_stuff):
Show fully-qualified class names in class list.
-Tue Jan 13 01:24:17 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (test_wr): Rdoc fix. [ruby-core:02225]
-
Tue Jan 13 01:04:37 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_paths.rb (RI::Paths): First attempt at
incorporating DESTDIR in the rdoc installation.
-Mon Jan 12 23:26:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Jan 12 23:27:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (primary): fix position after FCALL. [ruby-dev:22574]
-Mon Jan 12 18:00:11 2004 Ian Macdonald <ian@caliban.org>
-
- * file.c (test_wr, test_ww): New functions implementing new
- methods (File::world_readable?, File::world_writable?).
-
- * file.c (S_IRUGO, S_IGUGO): New macros.
-
Mon Jan 12 12:07:22 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods):
@@ -32201,22 +18273,29 @@ Mon Jan 12 12:07:22 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_formatter.rb (RI::HtmlFormatter::break_to_newline):
HTML formats need explicit line breaks.
+Mon Jan 12 11:46:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * configure.in (LIBPATHFLAG, RPATHFLAG): enclose paths with single
+ quotes. [ruby-dev:22564]
+
+ * lib/mkmf.rb (libpathflag): do not enclose with quotes always.
+
+ * {bcc32,win32,wince}/Makefile.sub (LIBPATHFLAG): quoted.
+
Mon Jan 12 02:24:07 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_formatter.rb (RI::HtmlFormatter): Add HTML
generation support to ri (Elliot Hughes)
-Sun Jan 11 23:54:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * env.h (ruby_frame, ruby_scope, ruby_in_eval, ruby_class,
- ruby_dyna_vars): export. [ruby-dev:22566]
+Mon Jan 12 02:24:07 2004 Dave Thomas <dave@pragprog.com>
-Sun Jan 11 02:35:53 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rdoc/ri/ri_formatter.rb (RI::HtmlFormatter): Add HTML
+ generation support to ri (Elliot Hughes)
- * ext/socket/socket.c (make_hostent): a bug in brace position.
+Sun Jan 11 02:07:47 2004 Dave Thomas <dave@pragprog.com>
- * configure.in: install rdoc by default. if you do not want to
- install rdoc, specify --disable-install-doc.
+ * lib/rdoc/ri/ri_options.rb (RI::Options::OptionList::OptionList):
+ Also accept command line options via the 'RI' environment variable.
Sun Jan 11 02:07:47 2004 Dave Thomas <dave@pragprog.com>
@@ -32237,49 +18316,7 @@ Sat Jan 10 01:54:50 2004 Eric Sunshine <sunshine@sunshineco.com>
correctly on Rhapsody when -arch compiler flag was used (via
configure's --enable-fat-binary option).
-Sat Jan 10 23:01:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (LIBPATHFLAG, RPATHFLAG): enclose paths with single
- quotes. [ruby-dev:22564]
-
- * lib/mkmf.rb (libpathflag): do not enclose with quotes always.
-
- * {bcc32,win32,wince}/Makefile.sub (LIBPATHFLAG): quoted.
-
-Sat Jan 10 22:46:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (dir_inspect): new method, Dir#inspect. [ruby-dev:22562]
-
-Fri Jan 9 17:36:51 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (make_hostent): getaddrinfo(3) on BSD do not
- fill ai_canonname if serv is not supplied. (ruby-bugs PR#1243)
-
-Fri Jan 9 13:14:59 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/test/unit/collector/dir.rb: do not ignore exceptions(LoadError
- and SystemExitError) while loading a testcase. smell of bug.
-
- * test/testunit/collector/test_dir.rb: add new test of the LoadError.
-
- * test/drb/{test_drbssl.rb,test_drbunix.rb}: do not define testcase if
- openssl is not installed.
-
- * test/testunit/collector/test_dir.rb: assert_raises -> assert_raise.
-
-Fri Jan 9 11:52:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * rubysig.h: <errno.h> is needed to use errno which may be a macro.
-
-Fri Jan 9 11:20:24 2004 Siena. <siena@faculty.chiba-u.jp>
-
- * ext/extmk.rb (extmake): should not reduce necessary libraries.
- [ruby-dev:22440]
-
- * lib/mkmf.rb (merge_libs): merge libraries according to
- dependency.
-
-Fri Jan 9 10:05:23 2004 Siena. <siena@faculty.chiba-u.jp>
+Fri Jan 9 10:05:14 2004 Siena. <siena@faculty.chiba-u.jp>
* lib/mkmf.rb (libpathflag): use single quotes. [ruby-dev:22440]
@@ -32289,7 +18326,7 @@ Thu Jan 8 23:49:21 2004 WATANABE Hirofumi <eban@ruby-lang.org>
rdoc documentation, you need to run configure with
--enable-install-doc.
-Thu Jan 8 21:17:43 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Jan 8 21:29:43 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_pkey.c (ossl_pkey_to_der): removed; it returns
public key only.
@@ -32303,10 +18340,6 @@ Thu Jan 8 21:17:43 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_pkey_rsa.c (ossl_rsa_to_der): new function for
OpenSSL::PKey::RSA#to_der.
-Thu Jan 8 18:25:29 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (glob_helper): should not recurse in exceptional status.
-
Thu Jan 8 16:51:04 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/wsdl/datetime/test_datetime.rb: fixed a stupid testcase which
@@ -32316,58 +18349,15 @@ Thu Jan 8 11:20:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* eval.c, object.c, process.c, re.c: don't use C++ style comments.
-Thu Jan 8 08:46:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/syck/rubyext.c (yaml_org_handler): lazy-load Date for
- static-ext.
-
-Thu Jan 8 07:06:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/extmk.rb: preserve order in Setup. [ruby-dev:22503]
-
- * ext/extmk.rb: move dependent libraries just after depended
- libraries.
-
- * ext/digest/*/extconf.rb: depend on digest.
-
-Thu Jan 8 04:36:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+Thu Jan 8 04:36:21 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI#initialize): should create
@config[:Logger] if it was not given.
-Wed Jan 7 22:28:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (glob_helper): fix memory leak.
-
-Wed Jan 7 21:15:07 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
* sample/webrick/*: new files.
* MANIFEST: add sample/webrick/*
-Wed Jan 7 20:51:51 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/net/test_httpheader.rb: new file.
-
- * MANIFEST: add test/net/test_httpheader.rb.
-
-Wed Jan 7 20:42:06 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (HTTPHeader#content_length): should return nil
- unless header exists. [ruby-dev:22519]
-
-Wed Jan 7 14:26:05 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb (TkPanedWindow): use epath for embedded windows.
-
- * ext/tk/lib/tktext.rb: use epath for embedded windows.
-
- * ext/tk/lib/tkcanvas.rb: use epath for window items.
-
-Wed Jan 7 14:24:04 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/soap/{attachment.rb,mimemessage.rb}: added from soap4r/1.5.2.
-
Wed Jan 7 13:00:18 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_driver.rb: Fix problem where ri was
@@ -32391,71 +18381,16 @@ Tue Jan 6 22:13:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_mod_modfunc): should break if m has no super class.
[ruby-dev:22498]
-Tue Jan 6 21:51:37 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Tue Jan 6 21:55:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (fptr_finalize): should save errno just after failure.
[ruby-dev:22492]
-Tue Jan 6 20:51:10 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * lib/logger.rb(Logger#msg2str): no special treatment for the object
- which responds to :to_str.
-
- * lib/logger.rb(LogDevice#initialize): remove type checking if the
- given object is a String. Kernel.open handles it correctly.
-
- * test/logger/test_logger.rb: follow above change (ArgumentError ->
- TypeError.)
-
Tue Jan 6 14:53:14 2004 Dave Thomas <dave@pragprog.com>
* bin/ri: split out the display side, making it pluggable. Added
new ri_driver and ri_display files in lib/rdoc/ri.
-Tue Jan 6 11:29:43 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * test/inlinetest.rb, test/{test_generator.rb,test_ipaddr.rb,
- test_pathname.rb,test_pp.rb,test_prettyprint.rb,test_set.rb,
- test_time.rb,test_tsort.rb: added.
-
-Tue Jan 6 09:38:27 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-
- * import soap4r/1.5.2;
-
- * lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}:
- introduce SOAPExternalReference class as a referenct to SOAPEnvelope
- external content.
-
- * lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages
- with Attachments) support code by Jamie Herre.
-
- * lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb,
- streamHandler.rb,wsdlDriver.rb}: SwA support.
-
- * lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb,
- soaplet.rb}: SwA support and refactoring.
-
- * lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow
- SOAPReference#initialize signature change.
-
- * lib/soap/mapping/factory.rb: deleted unused methods.
-
- * lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
- string <-> Ruby class name matching.
-
- * lib/xsd/datatypes.rb: check the smallest positive non-zero
- single-precision float exactly instead of packing with "f".
- [ruby-talk:88822]
-
- * test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not
- 1.4e-45. 1.4e-45 is smaller than 2 ** -149...
-
- * test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb,
- test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0".
-
- * test/soap/test_streamhandler.rb: revert to the previous test that
- warns "basic_auth unsupported under net/http".
-
Tue Jan 6 06:37:53 2004 Dave Thomas <dave@pragprog.com>
* bin/rdoc: Add --ri-system switch
@@ -32476,45 +18411,6 @@ Tue Jan 6 00:04:40 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method_or_yield_parameters):
fix parsing if there are braces in a method parameter list
-Tue Jan 6 01:01:04 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/dir.h, win32/win32.c: fix patch miss.
-
- * win32/Makefile.sub: fix file dependency.
-
-Mon Jan 5 20:32:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/logger.rb: enhanced documentation.
-
-Mon Jan 5 18:58:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c: merge tuning from H.Yamamoto <ocean@m2.ccsnet.ne.jp>.
- [ruby-dev:22486]
-
- * pack.c (pack_unpack): unpack requires big endian offet (OFF16B
- and OFF32B). The patch is from Minero Aoki in [ruby-dev:22489]
-
- * pack.c (OFF16B): add big-endian offset again.
-
-Mon Jan 5 03:00:53 2004 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_pack.rb: new test test_unpack_N.
-
-Mon Jan 5 01:47:53 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * lib/mkmf.rb (create_makefile): remove duplicated object files
- from $objs on DOSISH platforms.
-
-Sat Jan 3 02:44:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * rubysig.h (TRAP_END): preserve errno before switching context.
- [ruby-core:02137]
-
-Sat Jan 3 01:18:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c: merge tuning from H.Yamamoto <ocean@m2.ccsnet.ne.jp>.
- [ruby-dev:22476]
-
Fri Jan 2 14:54:11 2004 Dave Thomas <dave@pragprog.com>
* bin/ri: Add new --classes option, and arrange for
@@ -32533,23 +18429,10 @@ Fri Jan 2 01:50:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (argf_eof): ARGF.eof? should not have any side effect.
[ruby-dev:22469]
-Thu Jan 1 09:03:20 2004 Dave Thomas <dave@pragprog.com>
-
- * bin/ri (report_class_stuff): Fix problem with ambiguous nested
- classes not matching.
-
Wed Dec 31 17:25:17 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (argf_each_byte): should return self. [ruby-dev:22465]
-Wed Dec 31 15:05:00 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/pathname.rb: Corrected small coding error.
-
-Wed Dec 31 15:00:00 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/pathname.rb: Completed documentation.
-
Wed Dec 31 11:20:34 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods): Make
@@ -32588,20 +18471,16 @@ Tue Dec 30 12:30:30 2003 Dave Thomas <dave@pragprog.com>
Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method):
- Handle undoing nsting of yield parameters correctly for:
-
- def each_entry(&b) Dir.foreach(@path) {|f| yield P.new(f) } end
-
-Tue Dec 30 07:30:00 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
+ Handle undoing nesting of yield parameters correctly for:
- * lib/pathname.rb: Added documentation.
+ def each_entry(&b) Dir.foreach(@path) {|f| yield P.new(f) } end
-Mon Dec 29 20:08:17 2003 Minero Aoki <aamine@loveruby.net>
+Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
- * lib/net/http.rb (GenericRequest#initialize): check if path
- begins with '/'.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method):
+ Handle undoing nesting of yield parameters correctly for:
- * lib/net/http.rb: def m( arg ) -> def m(arg)
+ def each_entry(&block) Dir.foreach(@path) {|f| yield Pathname.new(f) } end
Mon Dec 29 12:51:02 2003 Dave Thomas <dave@pragprog.com>
@@ -32615,25 +18494,10 @@ Mon Dec 29 05:05:51 2003 Dave Thomas <dave@pragprog.com>
* struct.c, random: Add RDoc comments
-Mon Dec 29 02:25:00 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
-
- * lib/optparse.rb: Improved documentation.
-
Mon Dec 29 02:20:54 2003 Dave Thomas <dave@pragprog.com>
* eval.c: Add RDoc for class Proc, Method, UnboundMethod
-Mon Dec 29 02:20:26 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * instruby.rb: fix install directory if destdir and compile_dir are
- not in the same drive.
-
- * ext/extmk.rb: ditto. [ruby-list:39009]
-
- * win32/Makefile.sub, win32/README.win32, win32/configure.bat,
- win32/setup.mak: new configure scheme. use ``configure --prefix=dir''
- instead of ``nmake DESTDIR=dir install''.
-
Mon Dec 29 00:41:44 2003 Dave Thomas <dave@pragprog.com>
* math.c: Add RDoc comments
@@ -32667,7 +18531,7 @@ Sun Dec 28 03:50:05 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_override_comment):
Escape method names used in regexp
-Sun Dec 28 01:46:02 2003 Dave Thomas <dave@wireless_3.local.thomases.com>
+Sun Dec 28 01:46:02 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::display_flow_item):
Add support for rules in 'ri' output.
@@ -32685,27 +18549,27 @@ Sun Dec 28 01:05:31 2003 Dave Thomas <dave@pragprog.com>
* marshal.c, signal.c: RDoc collemts added by Elliott Hughes
-Sun Dec 28 00:46:25 2003 Dave Thomas <dave@pragprog.com>
+Sun Dec 28 00:48:47 2003 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_class_comment):
- Some Ruby source uses lower-case class names for the
- Init_Xxx C function name.
+ Some source files use lower case class or module names
+ when naming the Init_XXX function in C.
Sat Dec 27 23:41:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in: fix "test: too many arguments" error.
-Sat Dec 27 15:32:40 2003 Dave Thomas <dave@wireless_3.local.thomases.com>
+Sat Dec 27 15:32:19 2003 Dave Thomas <dave@wireless_3.local.thomases.com>
- * time.c: Add RDoc comments for Time class.
+ * time.c: RDoc comments added
-Sat Dec 27 15:07:26 2003 Dave Thomas <dave@pragprog.com>
+Sat Dec 27 15:07:57 2003 Dave Thomas <dave@pragprog.com>
* object.c: Add RDoc comments for Symbol class.
-Sat Dec 27 14:39:53 2003 Dave Thomas <dave@pragprog.com>
+Sat Dec 27 14:42:30 2003 Dave Thomas <dave@pragprog.com>
- * numeric.c (Init_Numeric): Add RDoc comments.
+ * numeric.c: Add RDoc comments.
Sat Dec 27 00:44:00 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -32723,7 +18587,7 @@ Fri Dec 26 23:02:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_getline): should return nil when read_all gives
empty string, even when nil rs is specified. [ruby-core:02077]
-Fri Dec 26 18:33:54 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Dec 26 18:50:59 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: check if getcontext and setcontext are available.
@@ -32733,26 +18597,14 @@ Fri Dec 26 16:40:53 2003 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb (PathnameTest#test_plus): add 2 assertions.
-Fri Dec 26 14:05:13 2003 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_pack.rb: new test test_pack_N.
-
-Fri Dec 26 12:53:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Dec 26 09:26:58 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): add sign check for 'i', and 'l'.
[ruby-dev:22427]
* bignum.c (rb_quad_pack): add range check for 'quad int'.
-Fri Dec 26 10:58:58 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * MANIFEST: add vms/config.h and remove vms/config.h_in.
-
-Fri Dec 26 10:42:00 2003 AKIYOSHI, Masamichi <masamichi.akiyoshi@hp.com>
-
- * io.c: [VMS] "rfm=stmlf" is specified for open() and fopen().
-
-Thu Dec 25 22:29:53 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+Thu Dec 25 22:39:59 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* string.c (rb_str_update): don't return any value.
@@ -34602,10 +20454,10 @@ Wed Nov 5 22:55:16 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/README.1st: add the description of '--with-pthread-ext'
- * ext/tk/lib/tktext.rb: add TkText#text_copy, text_cut, text_paste
+ * ext/tk/lib/tktext.rb : add TkText#text_copy, text_cut, text_paste
to support Tcl/Tk8.4's tk_textCopy, tk_textCut, tk_textPaste
- * ext/tk/lib/tk.rb: add TkMenu#set_focus support Tcl/Tk's
+ * ext/tk/lib/tk.rb : add TkMenu#set_focus support Tcl/Tk's
tk_menuSetFocus
Wed Nov 5 17:33:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -35017,6 +20869,11 @@ Mon Oct 20 09:45:12 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/debug.rb (debug_command): remove debug print.
+Wed Oct 20 00:25:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (search_required): required name must not be changed before
+ loading. [ruby-dev:24492]
+
Sun Oct 19 13:12:30 2003 Tanaka Akira <akr@m17n.org>
* lib/pathname.rb (foreachline, dir_foreach): add obsolete warning.
@@ -35174,10 +21031,10 @@ Wed Oct 15 05:05:53 2003 Akinori MUSHA <knu@iDaemons.org>
Wed Oct 15 04:31:51 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/sample/demos-en/entry3.rb, ext/tk/sample/demos-jp/entry3.rb:
+ * ext/tk/sample/demos-en/entry3.rb, ext/tk/sample/demos-jp/entry3.rb :
new demo-scripts
- * ext/tk/sample/demos-en/widget, ext/tk/sample/demos-jp/widget:
+ * ext/tk/sample/demos-en/widget, ext/tk/sample/demos-jp/widget :
add entries for 'entry3.rb'
Wed Oct 15 04:31:47 2003 Akinori MUSHA <knu@iDaemons.org>
@@ -36000,6 +21857,35 @@ Thu Oct 2 00:21:11 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/soap/calc/*: give httpd config param "CGIInterpreter".
"/usr/bin/env ruby" thing does not work under non-Unix boxes.
+Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (r_byte): retrieve pointer from string value for each
+ time. [ruby-dev:24404]
+
+ * marshal.c (r_bytes0): ditto.
+
+ * enum.c (sort_by_i): re-entrance check added. [ruby-dev:24399]
+
+ * io.c (io_read): should freeze all reading buffer.
+ [ruby-dev:24400]
+
+ * string.c (rb_str_sum): should use bignums when bits is greater
+ than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]
+
+ * eval.c (specific_eval): defer pointer retrieval to prevent
+ unsafe sourcefile string modification. [ruby-dev:24382]
+
+ * string.c (rb_str_sum): wrong cast caused wrong result.
+ [ruby-dev:24385]
+
+ * enum.c (enum_sort_by): hide temporary array from
+ ObjectSpace.each_object. [ruby-dev:24386]
+
+ * string.c (rb_str_sum): check was done with false pointer.
+ [ruby-dev:24383]
+
+ * string.c (rb_str_sum): string may be altered. [ruby-dev:24381]
+
Thu Oct 2 00:25:21 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* signal.c (ruby_signal_name): adjust to the prototype.
@@ -36163,6 +22049,20 @@ Sat Sep 27 09:44:18 2003 Minero Aoki <aamine@loveruby.net>
* test/fileutils/test_nowrite.rb: ditto.
+Mon Sep 27 09:14:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_delete): comparison may change the capacity.
+ [ruby-dev:24348]
+
+ * array.c (rb_ary_fill): fill should honor length argument.
+ [ruby-dev:24346]
+
+ * array.c (rb_ary_replace): should not use ptr from shared array.
+ [ruby-dev:24345]
+
+ * ext/socket/socket.c (s_accept): don't retry for EWOULDBLOCK.
+ [ruby-talk:113807]
+
Sat Sep 27 04:57:07 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/ruby/test_file.rb: new file. only asserts unlink-before-close
@@ -36566,7 +22466,7 @@ Sun Sep 7 16:08:28 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c (lib_mainloop_core): fixed signal-trap bug
- * ext/tk/lib/*.rb: Ruby/Tk works at $SAFE == 4
+ * ext/tk/lib/*.rb : Ruby/Tk works at $SAFE == 4
Sat Sep 6 02:26:34 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
@@ -36785,7 +22685,7 @@ Tue Sep 2 14:02:19 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tcltklib/tcltklib.c (ip_invoke): fixed bug on passing a exception
- * ext/tk/lib/{tk.rb, tkcanvas.rb, tkfont.rb, tktext.rb}:
+ * ext/tk/lib/{tk.rb, tkcanvas.rb, tkfont.rb, tktext.rb} :
bug fix and improvement of font control
Tue Sep 2 09:51:36 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
@@ -36886,17 +22786,17 @@ Fri Aug 29 17:30:15 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* process.c: deny handling IDs during evaluating the block given to
the Process::{UID,GID}.switch method
- * ext/tcltklib/tcltklib.c: some methods have no effect if on slave-IP
+ * ext/tcltklib/tcltklib.c : some methods have no effect if on slave-IP
- * ext/tcltklib/tcltklib.c: can create a interpreter without Tk
+ * ext/tcltklib/tcltklib.c : can create a interpreter without Tk
- * ext/tcltklib/tcltklib.c: bug fix on handling exceptions
+ * ext/tcltklib/tcltklib.c : bug fix on handling exceptions
- * ext/tcltklib/MANUAL.euc: modify
+ * ext/tcltklib/MANUAL.euc : modify
- * ext/tk/lib/tk.rb: freeze some core modules
+ * ext/tk/lib/tk.rb : freeze some core modules
- * ext/tk/lib/multi-tk.rb: more secure
+ * ext/tk/lib/multi-tk.rb : more secure
* ext/tk/lib/tk.rb: TkVariable.new(array) --> treat the array as the
Tk's list
@@ -36904,9 +22804,9 @@ Fri Aug 29 17:30:15 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: improve accessibility of TkVariable object
* ext/tk/lib/tk.rb, ext/tk/lib/tkfont.rb, ext/tk/lib/tkcanvas.rb,
- ext/tk/lib/tktext.rb: fix bug of font handling
+ ext/tk/lib/tktext.rb : fix bug of font handling
- * ext/tk/lib/tkfont.rb: TkFont.new() accepts compound fonts
+ * ext/tk/lib/tkfont.rb TkFont.new() accepts compound fonts
Thu Aug 28 22:07:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -37519,9 +23419,10 @@ 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/LEGAL b/LEGAL
index 00db893d8d..908eb270f5 100644
--- a/LEGAL
+++ b/LEGAL
@@ -5,27 +5,34 @@ All the files in this distribution are covered under either the Ruby's
license (see the file COPYING) or public-domain except some files
mentioned below.
-oniguruma.h:
-regcomp.c:
-regenc.[ch]:
-regerror.c:
-regex.c:
-regexec.c:
-regint.h:
-regparse.[ch]:
-ascii.c:
-euc_jp.c:
-sjis.c:
-utf8.c:
-
-Oniguruma ---- (C) K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
-
-http://www.geocities.jp/kosako3/oniguruma/
-http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/oniguruma/
-http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/oniguruma/
-
- When this software is partly used or it is distributed with Ruby,
- this of Ruby follows the license of Ruby.
+regex.[ch]:
+
+ These files are under LGPL. Treat them as LGPL says. (See the file
+ LGPL for details)
+
+ Extended regular expression matching and search library.
+ Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file LGPL. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto)
+ Last change: May 21, 1993 by t^2
+ removed gapped buffer support, multiple syntax support by matz <matz@nts.co.jp>
+ Perl5 extension added by matz <matz@caelum.co.jp>
+ UTF-8 extension added Jan 16 1999 by Yoshida Masato <yoshidam@tau.bekkoame.ne.jp>
configure:
@@ -66,21 +73,6 @@ parse.c:
the same distribution terms that you use for the rest of that program.
util.c (partly):
-
- Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
-
- Permission to use, copy, modify, and distribute this software for any
- purpose without fee is hereby granted, provided that this entire notice
- is included in all copies of any software which is or includes a copy
- or modification of this software and in all copies of the supporting
- documentation for such software.
-
- THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
- REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
-
-util.c (partly):
win32/win32.[ch]:
You can apply the Artistic License to these files. (or GPL,
@@ -159,6 +151,23 @@ ext/digest/sha1/sha1.[ch]:
These files are all under public domain.
+missing/strtod.c:
+
+ This file will not be used on most platforms depending on how the
+ configure script results. In any case you must not receive any fee
+ with the file itself.
+
+ Copyright (c) 1988-1993 The Regents of the University of California.
+ Copyright (c) 1994 Sun Microsystems, Inc.
+
+ Permission to use, copy, modify, and distribute this
+ software and its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright
+ notice appear in all copies. The University of California
+ makes no representations about the suitability of this
+ software for any purpose. It is provided "as is" without
+ express or implied warranty.
+
missing/strtoul.c:
This file will not be used on most platforms depending on how the
@@ -217,36 +226,6 @@ missing/vsnprintf.c:
From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
paragraph 3 above is now null and void.
-missing/strlcat.c
-missing/strlcpy.c
-
- These files are under the new-style BSD license.
-
- Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
ext/digest/md5/md5.[ch]:
These files are under the following license. Ruby uses modified
diff --git a/Makefile.in b/Makefile.in
index d4da5d62bd..a37bcf65fb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,15 +4,14 @@ NULLCMD = :
#### Start of system configuration section. ####
srcdir = @srcdir@
-hdrdir = $(srcdir)/include
+VPATH = $(srcdir):$(srcdir)/missing
CC = @CC@
-YACC = bison
+YACC = @YACC@
PURIFY =
AUTOCONF = autoconf
@SET_MAKE@
MKFILES = @MAKEFILES@
-BASERUBY = @BASERUBY@
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -32,15 +31,14 @@ RDOCTARGET = @RDOCTARGET@
EXTOUT = @EXTOUT@
RIDATADIR = $(DESTDIR)$(datadir)/ri/$(MAJOR).$(MINOR)/system
-arch_hdrdir = $(EXTOUT)/include/$(arch)
-VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir):$(srcdir)/enc:$(srcdir)/missing
empty =
OUTFLAG = @OUTFLAG@$(empty)
-COUTFLAG = @COUTFLAG@$(empty)
-CFLAGS = @CFLAGS@ @ARCH_FLAG@
-XCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) @XCFLAGS@
-CPPFLAGS = @CPPFLAGS@
+CFLAGS = @CFLAGS@ @XCFLAGS@ @ARCH_FLAG@
+cflags = @cflags@
+optflags = @optflags@
+debugflags = @debugflags@
+CPPFLAGS = -I. -I$(srcdir) @CPPFLAGS@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXTLDFLAGS =
XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
@@ -51,8 +49,7 @@ LDSHARED = @LIBRUBY_LDSHARED@
DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
SOLIBS = @SOLIBS@
MAINLIBS = @MAINLIBS@
-MINIOBJS = @MINIOBJS@ miniprelude.$(OBJEXT)
-BUILTIN_ENCOBJS = @BUILTIN_ENCOBJS@
+MINIOBJS = @MINIOBJS@
RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
RUBY_SO_NAME=@RUBY_SO_NAME@
@@ -76,15 +73,11 @@ LIBRUBYARG = @LIBRUBYARG@
LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@
LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
-THREAD_MODEL = @THREAD_MODEL@
-
PREP = @PREP@
ARCHFILE = @ARCHFILE@
SETUP =
EXTSTATIC = @EXTSTATIC@
-CP = cp
-MV = mv
RM = rm -f
NM = @NM@
AR = @AR@
@@ -94,8 +87,6 @@ AS = @AS@
ASFLAGS = @ASFLAGS@
OBJEXT = @OBJEXT@
-ASMEXT = S
-DLEXT = @DLEXT@
MANTYPE = @MANTYPE@
INSTALLED_LIST= .installed.list
@@ -110,7 +101,7 @@ all:
miniruby$(EXEEXT):
@$(RM) $@
- $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE) $(LIBS) $(OUTFLAG)$@
+ $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@
$(PROGRAM):
@$(RM) $@
@@ -166,31 +157,25 @@ config.status: $(srcdir)/configure
$(srcdir)/configure: $(srcdir)/configure.in
cd $(srcdir) && $(AUTOCONF)
-# Things which should be considered:
-# * with gperf v.s. without gperf
-# * ./configure v.s. ../ruby/configure
-# * GNU make v.s. HP-UX make # HP-UX make invokes the action if lex.c and keywords has same mtime.
-# * svn checkout generate a file with mtime as current time
-# * XFS has a mtime with fractional part
lex.c: keywords
- if cmp -s $(srcdir)/lex.c.src $?; then \
- cp $(srcdir)/lex.c.blt $@; \
+ ( 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 \
- gperf -C -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? > $@.tmp && \
- mv $@.tmp $@ && \
- cp $? $(srcdir)/lex.c.src && \
- cp $@ $(srcdir)/lex.c.blt; \
+ cp $(srcdir)/lex.c $@ && echo $@ copied.; \
fi
+.y.c:
+ $(YACC) $<
+ sed '/^#/s|y\.tab\.c|$@|' y.tab.c > $@
+ rm -f y.tab.c
+
.c.@OBJEXT@:
- $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
.s.@OBJEXT@:
$(AS) $(ASFLAGS) -o $@ $<
-.c.S:
- $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -S $<
-
clean-local::
@$(RM) ext/extinit.c ext/extinit.$(OBJEXT)
@@ -198,4 +183,20 @@ distclean-local::
@$(RM) ext/config.cache $(RBCONFIG)
ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
- $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c
+ $(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
new file mode 100644
index 0000000000..61373187e5
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,629 @@
+= 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.
+
+== 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 938c846e3f..1b79781367 100644
--- a/README
+++ b/README
@@ -26,6 +26,11 @@ The Ruby distribution files can be found in the following FTP site:
ftp://ftp.ruby-lang.org/pub/ruby/
+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/
+
The trunk of the Ruby source tree can be checked out with the
following command:
@@ -65,6 +70,10 @@ 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 f93f82997e..637b19d25b 100644
--- a/README.EXT
+++ b/README.EXT
@@ -78,8 +78,7 @@ There is the data-type check function
void Check_Type(VALUE value, int type)
-which raises an exception if the VALUE does not have the type
-specified.
+which raises an exception if the VALUE does not have the type specified.
There are also faster check macros for fixnums and nil.
@@ -94,36 +93,36 @@ 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
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.
+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.
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
+representation of var. These macros will skip the replacement if var is
+a String. Notice that the macros take only the lvalue as their
argument, to change the value of var in place.
In version 1.6 or earlier, STR2CSTR() was used to do 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() implicit conversion.
+of a dangling pointer problem in the to_str() impliclit conversion.
Other data types have corresponding C structures, e.g. struct RArray
-for T_ARRAY etc. The VALUE of the type which has the corresponding
-structure can be cast to retrieve the pointer to the struct. The
-casting macro will be of the form RXXXX for each data type; for
-instance, RARRAY(obj). See "ruby.h".
+for T_ARRAY etc. The VALUE of the type which has the corresponding structure
+can be cast to retrieve the pointer to the struct. The casting macro
+will be of the form RXXXX for each data type; for instance, RARRAY(obj).
+See "ruby.h".
-There are some accessing macros for structure members, for example
-`RSTRING_LEN(s)' to to get the size of the Ruby String object. The
-allocated region can be accessed by `RSTRING_PTR(str). For arrays, use
-`RARRAY_LEN(ary) and `RARRAY_PTR(ary) respectively.
+For example, `RSTRING(str)->len' is the way to get the size of the
+Ruby String object. The allocated region can be accessed by
+`RSTRING(str)->ptr'. For arrays, use `RARRAY(ary)->len' and
+`RARRAY(ary)->ptr' respectively.
Notice: Do not change the value of the structure directly, unless you
-are responsible for the result. This ends up being the cause of
-interesting bugs.
+are responsible for the result. This ends up being the cause of interesting
+bugs.
1.4 Convert C data into VALUE
@@ -153,10 +152,9 @@ range, but is a bit slower.
1.5 Manipulating Ruby data
-As I already mentioned, it is not recommended to modify an object's
-internal structure. To manipulate objects, use the functions supplied
-by the Ruby interpreter. Some (not all) of the useful functions are
-listed below:
+As I already mentioned, it is not recommended to modify an object's internal
+structure. To manipulate objects, use the functions supplied by the Ruby
+interpreter. Some (not all) of the useful functions are listed below:
String functions
@@ -211,7 +209,7 @@ listed below:
2. Extending Ruby with C
-2.1 Adding new features to Ruby
+2.1 Addding new features to Ruby
You can add new features (classes, methods, etc.) to the Ruby
interpreter. Ruby provides APIs for defining the following things:
@@ -332,11 +330,10 @@ of the innermost method (which is defined by Ruby) can be accessed.
2.2.2 ID or Symbol
-You can invoke methods directly, without parsing the string. First I
-need to explain about ID. ID is the integer number to represent
-Ruby's identifiers such as variable names. The Ruby data type
-corresponding to ID is Symbol. It can be accessed from Ruby in the
-form:
+You can invoke methods directly, without parsing the string. First I need
+to explain about ID. ID is the integer number to represent Ruby's
+identifiers such as variable names. The Ruby data type corresponding to ID
+is Symbol. It can be accessed from Ruby in the form:
:Identifier
@@ -369,8 +366,8 @@ specified by the symbol mid.
2.2.4 Accessing the variables and constants
You can access class variables and instance variables using access
-functions. Also, global variables can be shared between both
-environments. There's no way to access Ruby's local variables.
+functions. Also, global variables can be shared between both environments.
+There's no way to access Ruby's local variables.
The functions to access/modify instance variables are below:
@@ -504,8 +501,7 @@ the library.
Here's the example of an initializing function.
--
-void
-Init_dbm(void)
+Init_dbm()
{
/* define DBM class */
cDBM = rb_define_class("DBM", rb_cObject);
@@ -539,8 +535,8 @@ struct dbmdata {
obj = Data_Make_Struct(klass, struct dbmdata, 0, free_dbm, dbmp);
--
-This code wraps the dbmdata structure into a Ruby object. We avoid
-wrapping DBM* directly, because we want to cache size information.
+This code wraps the dbmdata structure into a Ruby object. We avoid wrapping
+DBM* directly, because we want to cache size information.
To retrieve the dbmdata structure from a Ruby object, we define the
following macro:
@@ -560,7 +556,8 @@ methods with a fixed number of arguments receive arguments like this:
--
static VALUE
-fdbm_delete(VALUE obj, VALUE keystr)
+fdbm_delete(obj, keystr)
+ VALUE obj, keystr;
{
:
}
@@ -574,7 +571,10 @@ arguments like this:
--
static VALUE
-fdbm_s_open(int argc, VALUE *argv, VALUE klass)
+fdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
:
if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
@@ -597,7 +597,8 @@ by Ruby's array, like this:
--
static VALUE
-fdbm_indexes(VALUE obj, VALUE args)
+fdbm_indexes(obj, args)
+ VALUE obj, args;
{
:
}
@@ -1124,7 +1125,7 @@ this method, the compilation will not be done.
find_executable(bin, path)
Finds command in path, which is File::PATH_SEPARATOR-separated list of
-directories. If path is nil or omitted, environment variable PATH
+directories. If path is nil or omitted, environment varialbe PATH
will be used. Returns the path name of the command if it is found,
otherwise nil.
@@ -1153,7 +1154,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
-command name can be overridden by --with-pkg-config command line
+command name can be overriden by --with-pkg-config command line
option.
/*
diff --git a/README.EXT.ja b/README.EXT.ja
index 09555ee13f..73425c2cdb 100644
--- a/README.EXT.ja
+++ b/README.EXT.ja
@@ -107,16 +107,16 @@ FIXNUM¤ÈNIL¤Ë´Ø¤·¤Æ¤Ï¤è¤ê¹â®¤ÊȽÊÌ¥Þ¥¯¥í¤¬ÍѰդµ¤ì¤Æ¤¤¤Þ¤¹¡¥
ȯÀ¸¤¹¤ë)¡¥Æ±Íͤ˥Á¥§¥Ã¥¯Ìµ¤·¤Ç»È¤¨¤ëÊÑ´¹¥Þ¥¯¥í¤Ïdouble¤ò
¼è¤ê½Ð¤¹¡ÖNUM2DBL()¡×¤¬¤¢¤ê¤Þ¤¹¡£
-char* ¤ò¼è¤ê½Ð¤¹¾ì¹ç¡¢version 1.6 °ÊÁ°¤Ç¤Ï¡ÖSTR2CSTR()¡×¤È¤¤
-¤¦¥Þ¥¯¥í¤ò»È¤Ã¤Æ¤¤¤Þ¤·¤¿¤¬¡¢¤³¤ì¤Ï to_str() ¤Ë¤è¤ë°ÅÌۤη¿ÊÑ
-´¹·ë²Ì¤¬ GC ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¡¢version 1.7 °Ê¹ß¤Ç¤Ï
-obsolete ¤È¤Ê¤ê¡¢Âå¤ï¤ê¤Ë StringValue() ¤È StringValuePtr()
-¤ò»È¤¦»ö¤ò¿ä¾©¤·¤Æ¤¤¤Þ¤¹¡£StringValue(var) ¤Ï var ¤¬ String
-¤Ç¤¢¤ì¤Ð²¿¤â¤»¤º¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð var ¤ò var.to_str() ¤Î·ë²Ì
-¤ËÃÖ¤­´¹¤¨¤ë¥Þ¥¯¥í¡¢StringValuePtr(var) ¤ÏƱÍÍ¤Ë var ¤òÃÖ¤­
-´¹¤¨¤Æ¤«¤é var ¤Îʸ»úÎóɽ¸½¤ËÂФ¹¤ë char* ¤òÊÖ¤¹¥Þ¥¯¥í¤Ç¤¹¡£
-var ¤ÎÆâÍÆ¤òľÀÜÃÖ¤­´¹¤¨¤ë½èÍý¤¬Æþ¤ë¤Î¤Ç¡¢var ¤Ï lvalue ¤Ç¤¢
-¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
+char* ¤ò¼è¤ê½Ð¤¹¾ì¹ç¡¢version 1.6 °ÊÁ°¤Ç¤Ï¡ÖSTR2CSTR()¡×¤È
+¤¤¤¦¥Þ¥¯¥í¤ò»È¤Ã¤Æ¤¤¤Þ¤·¤¿¤¬¡¢¤³¤ì¤Ï to_str() ¤Ë¤è¤ë°ÅÌÛ¤Î
+·¿ÊÑ´¹·ë²Ì¤¬ GC ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¡¢version 1.7 °Ê¹ß¤Ç¤Ï
+obsolete ¤È¤Ê¤ê¡¢Âå¤ï¤ê¤Ë StringValue() ¤È StringValuePtr()
+¤ò»È¤¦»ö¤ò¿ä¾©¤·¤Æ¤¤¤Þ¤¹¡£StringValue(var) ¤Ï var ¤¬ String
+ ¤Ç¤¢¤ì¤Ð²¿¤â¤»¤º¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð var ¤ò var.to_str() ¤Î·ë²Ì¤Ë
+ÃÖ¤­´¹¤¨¤ë¥Þ¥¯¥í¡¢StringValuePtr(var) ¤ÏƱÍÍ¤Ë var ¤òÃÖ¤­´¹¤¨
+¤Æ¤«¤é var ¤Îʸ»úÎóɽ¸½¤ËÂФ¹¤ë char* ¤òÊÖ¤¹¥Þ¥¯¥í¤Ç¤¹¡£var ¤Î
+ÆâÍÆ¤òľÀÜÃÖ¤­´¹¤¨¤ë½èÍý¤¬Æþ¤ë¤Î¤Ç¡¢var ¤Ï lvalue ¤Ç¤¢¤ëɬÍפ¬
+¤¢¤ê¤Þ¤¹¡£
¤½¤ì°Ê³°¤Î¥Ç¡¼¥¿¥¿¥¤¥×¤ÏÂбþ¤¹¤ëC¤Î¹½Â¤ÂΤ¬¤¢¤ê¤Þ¤¹¡¥Âбþ¤¹
¤ë¹½Â¤ÂΤΤ¢¤ëVALUE¤Ï¤½¤Î¤Þ¤Þ¥­¥ã¥¹¥È(·¿ÊÑ´¹)¤¹¤ì¤Ð¹½Â¤ÂΤÎ
@@ -129,11 +129,10 @@ var ¤ÎÆâÍÆ¤òľÀÜÃÖ¤­´¹¤¨¤ë½èÍý¤¬Æþ¤ë¤Î¤Ç¡¢var ¤Ï lvalue ¤Ç¤¢
ruby.h¤Ç¤Ï¹½Â¤ÂΤإ­¥ã¥¹¥È¤¹¤ë¥Þ¥¯¥í¤â¡ÖRXXXXX()¡×(Á´ÉôÂçʸ
»ú¤Ë¤·¤¿¤â¤Î)¤È¤¤¤¦Ì¾Á°¤ÇÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹(Îã: RSTRING())¡¥
-¹½Â¤ÂΤ«¤é¥Ç¡¼¥¿¤ò¼è¤ê½Ð¤¹¥Þ¥¯¥í¤¬Ä󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£Ê¸»úÎó
-str¤ÎŤµ¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¡ÖRSTRING_LEN(str)¡×¤È¤·¡¤Ê¸»úÎóstr¤ò
-char*¤È¤·¤ÆÆÀ¤ë¤¿¤á¤Ë¤Ï¡ÖRSTRING_PTR(str)¡×¤È¤·¤Þ¤¹¡¥ÇÛÎó¤Î
-¾ì¹ç¤Ë¤Ï¡¤¤½¤ì¤¾¤ì¡ÖRARRAY_LEN(ary)¡×¡¤¡ÖRARRAY_PTR(ary)¡×¤È
-¤Ê¤ê¤Þ¤¹¡¥
+Î㤨¤Ð¡¤Ê¸»úÎóstr¤ÎŤµ¤òÆÀ¤ë¤¿¤á¤Ë¤Ï¡ÖRSTRING(str)->len¡×¤È
+¤·¡¤Ê¸»úÎóstr¤òchar*¤È¤·¤ÆÆÀ¤ë¤¿¤á¤Ë¤Ï¡ÖRSTRING(str)->ptr¡×
+¤È¤·¤Þ¤¹¡¥ÇÛÎó¤Î¾ì¹ç¤Ë¤Ï¡¤¤½¤ì¤¾¤ì¡ÖRARRAY(ary)->len¡×¡¤
+¡ÖRARRAY(ary)->ptr¡×¤È¤Ê¤ê¤Þ¤¹¡¥
Ruby¤Î¹½Â¤ÂΤòľÀÜ¥¢¥¯¥»¥¹¤¹¤ë»þ¤Ëµ¤¤ò¤Ä¤±¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³
¤È¤Ï¡¤ÇÛÎó¤äʸ»úÎó¤Î¹½Â¤ÂΤÎÃæ¿È¤Ï»²¾È¤¹¤ë¤À¤±¤Ç¡¤Ä¾ÀÜÊѹ¹¤·
@@ -381,7 +380,8 @@ C¤«¤éʸ»úÎó¤ò·Ðͳ¤»¤º¤ËRuby¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤â¤Ç¤­¤Þ
¤¹¡¥¤½¤ÎÁ°¤Ë¡¤Ruby¥¤¥ó¥¿¥×¥ê¥¿Æâ¤Ç¥á¥½¥Ã¥É¤äÊÑ¿ô̾¤ò»ØÄꤹ¤ë
»þ¤Ë»È¤ï¤ì¤Æ¤¤¤ëID¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡¥
-ID¤È¤ÏÊÑ¿ô̾¡¤¥á¥½¥Ã¥É̾¤òɽ¤¹À°¿ô¤Ç¤¹¡¥Ruby¤ÎÃæ¤Ç¤Ï
+ID¤È¤ÏÊÑ¿ô̾¡¤¥á¥½¥Ã¥É̾¤òɽ¤¹À°¿ô¤Ç¤¹¡¥Ruby¤Ç¤ÏID¤ËÂбþ¤¹¤ë
+¥ª¥Ö¥¸¥§¥¯¥È¤È¤·¤Æ¥·¥ó¥Ü¥ë(Symbol)¤¬¤¢¤ê¡¤
:¼±ÊÌ»Ò
@@ -394,6 +394,14 @@ ID¤È¤ÏÊÑ¿ô̾¡¤¥á¥½¥Ã¥É̾¤òɽ¤¹À°¿ô¤Ç¤¹¡¥Ruby¤ÎÃæ¤Ç¤Ï
rb_to_id(VALUE symbol)
+ID¤«¤é¥·¥ó¥Ü¥ë¤òÆÀ¤ë¤¿¤á¤Ë¤Ï°Ê²¼¤Î¥Þ¥¯¥í¤ò»È¤¤¤Þ¤¹¡¥
+
+ VALUE ID2SYM(ID id)
+
+¥·¥ó¥Ü¥ë¤«¤éID¤òÆÀ¤ë¤¿¤á¤Ë¤Ï°Ê²¼¤Î¥Þ¥¯¥í¤ò»È¤¤¤Þ¤¹¡¥
+
+ ID SYM2ID(VALUE symbol)
+
2.2.3 C¤«¤éRuby¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹
C¤«¤éʸ»úÎó¤ò·Ðͳ¤»¤º¤ËRuby¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤¿¤á¤Ë¤Ï°Ê²¼
@@ -576,8 +584,7 @@ Ruby¤Ï³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤ò¥í¡¼¥É¤¹¤ë»þ¤Ë¡ÖInit_¥é¥¤¥Ö¥é¥ê̾¡×¤È
ÄêµÁ¤ò¹Ô¤¤¤Þ¤¹¡¥dbm.c¤«¤é°ìÉô°úÍѤ·¤Þ¤¹¡¥
--
-void
-Init_dbm(void)
+Init_dbm()
{
/* DBM¥¯¥é¥¹¤òÄêµÁ¤¹¤ë */
cDBM = rb_define_class("DBM", rb_cObject);
@@ -639,7 +646,8 @@ fdbm_delete()¤Ï¤³¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
--
static VALUE
-fdbm_delete(VALUE obj, VALUE keystr)
+fdbm_delete(obj, keystr)
+ VALUE obj, keystr;
{
:
}
@@ -655,7 +663,10 @@ fdbm_delete(VALUE obj, VALUE keystr)
--
static VALUE
-fdbm_s_open(int argc, VALUE *argv, VALUE klass)
+fdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
:
if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
@@ -684,7 +695,8 @@ Ruby¤ÎÇÛÎó¤Ç°ú¿ô¤ò¼õ¤±¼è¤ë¤â¤Î¤Ïindexes¤¬¤¢¤ê¤Þ¤¹¡¥¼ÂÁõ¤Ï¤³
--
static VALUE
-fdbm_indexes(VALUE obj, VALUE args)
+fdbm_indexes(obj, args)
+ VALUE obj, args;
{
:
}
@@ -1045,8 +1057,8 @@ char *rb_id2name(ID id)
char *rb_class2name(VALUE klass)
- ¥¯¥é¥¹¤Î̾Á°¤òÊÖ¤¹(¥Ç¥Ð¥Ã¥°ÍÑ)¡¥¥¯¥é¥¹¤¬Ì¾Á°¤ò»ý¤¿¤Ê¤¤»þ¤Ë
- ¤Ï, ÁÄÀè¤òÁ̤äÆÌ¾Á°¤ò»ý¤Ä¥¯¥é¥¹¤Î̾Á°¤òÊÖ¤¹¡¥
+ ¥¯¥é¥¹¤Î̾Á°¤òÊÖ¤¹(¥Ç¥Ð¥Ã¥°ÍÑ)¡¥¥¯¥é¥¹¤¬Ì¾Á°¤ò»ý¤¿¤Ê¤¤»þ¤Ë¤Ï,
+ ÁÄÀè¤òÁ̤äÆÌ¾Á°¤ò»ý¤Ä¥¯¥é¥¹¤Î̾Á°¤òÊÖ¤¹¡¥
int rb_respond_to(VALUE obj, ID id)
@@ -1139,32 +1151,6 @@ void ruby_script(char *name)
Ruby¤Î¥¹¥¯¥ê¥×¥È̾($0)¤òÀßÄꤹ¤ë¡¥
-** ¥¤¥ó¥¿¥×¥ê¥¿¤Î¥¤¥Ù¥ó¥È¤Î¥Õ¥Ã¥¯
-
- void rb_add_event_hook(rb_event_hook_func_t func, rb_event_t events)
-
-»ØÄꤵ¤ì¤¿¥¤¥ó¥¿¥×¥ê¥¿¤Î¥¤¥Ù¥ó¥È¤ËÂФ¹¤ë¥Õ¥Ã¥¯´Ø¿ô¤òÄɲä·¤Þ¤¹¡¥
-events¤Ï°Ê²¼¤ÎÃͤÎor¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó:
-
- 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
-
-rb_event_hook_func_t¤ÎÄêµÁ¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹:
-
- 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)
-
-»ØÄꤵ¤ì¤¿¥Õ¥Ã¥¯´Ø¿ô¤òºï½ü¤·¤Þ¤¹¡¥
-
Appendix C. extconf.rb¤Ç»È¤¨¤ë´Ø¿ô¤¿¤Á
@@ -1189,10 +1175,10 @@ find_library(lib, func, path...)
have_func(func, header)
- ¥Ø¥Ã¥À¥Õ¥¡¥¤¥ëheader¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Æ´Ø¿ôfunc¤Î¸ºß¤ò¥Á¥§
- ¥Ã¥¯¤¹¤ë¡¥func¤¬É¸½à¤Ç¤Ï¥ê¥ó¥¯¤µ¤ì¤Ê¤¤¥é¥¤¥Ö¥é¥êÆâ¤Î¤â¤Î¤Ç
- ¤¢¤ë»þ¤Ë¤ÏÀè¤Ëhave_library¤Ç¤½¤Î¥é¥¤¥Ö¥é¥ê¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤ª
- ¤¯»ö¡¥´Ø¿ô¤¬Â¸ºß¤¹¤ë»þtrue¤òÊÖ¤¹¡¥
+ ¥Ø¥Ã¥À¥Õ¥¡¥¤¥ëheader¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Æ´Ø¿ôfunc¤Î¸ºß¤ò¥Á¥§¥Ã
+ ¥¯¤¹¤ë¡¥func¤¬É¸½à¤Ç¤Ï¥ê¥ó¥¯¤µ¤ì¤Ê¤¤¥é¥¤¥Ö¥é¥êÆâ¤Î¤â¤Î¤Ç¤¢
+ ¤ë»þ¤Ë¤ÏÀè¤Ëhave_library¤Ç¤½¤Î¥é¥¤¥Ö¥é¥ê¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤ª¤¯
+ »ö¡¥´Ø¿ô¤¬Â¸ºß¤¹¤ë»þtrue¤òÊÖ¤¹¡¥
have_var(var, header)
@@ -1243,8 +1229,7 @@ find_executable(command, path)
with_config(withval[, default=nil])
- ¥³¥Þ¥ó¥É¥é¥¤¥ó¾å¤Î--with-<withval>¤Ç»ØÄꤵ¤ì¤¿¥ª¥×¥·¥ç¥óÃÍ
- ¤òÆÀ¤ë¡¥
+ ¥³¥Þ¥ó¥É¥é¥¤¥ó¾å¤Î--with-<withval>¤Ç»ØÄꤵ¤ì¤¿¥ª¥×¥·¥ç¥óÃͤòÆÀ¤ë¡¥
enable_config(config, *defaults)
disable_config(config, *defaults)
@@ -1253,9 +1238,8 @@ disable_config(config, *defaults)
--disable-<config>¤Ç»ØÄꤵ¤ì¤¿¿¿µ¶ÃͤòÆÀ¤ë¡¥
--enable-<config>¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ïtrue¡¤
--disable-<config>¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ïfalse¤òÊÖ¤¹¡¥
- ¤É¤Á¤é¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¤¥Ö¥í¥Ã¥¯¤Ä¤­¤Ç¸Æ¤Ó½Ð¤µ¤ì¤Æ
- ¤¤¤ë¾ì¹ç¤Ï*defaults¤òyield¤·¤¿·ë²Ì¡¤¥Ö¥í¥Ã¥¯¤Ê¤·¤Ê¤é
- *defaults¤òÊÖ¤¹¡¥
+ ¤É¤Á¤é¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¤¥Ö¥í¥Ã¥¯¤Ä¤­¤Ç¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï
+ *defaults¤òyield¤·¤¿·ë²Ì¡¤¥Ö¥í¥Ã¥¯¤Ê¤·¤Ê¤é*defaults¤òÊÖ¤¹¡¥
dir_config(target[, default_dir])
dir_config(target[, default_include, default_lib])
@@ -1264,8 +1248,8 @@ dir_config(target[, default_include, default_lib])
--with-<target>-lib¤Î¤¤¤º¤ì¤«¤Ç»ØÄꤵ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ò
$CFLAGS ¤ä $LDFLAGS ¤ËÄɲ乤롥--with-<target>-dir=/path¤Ï
--with-<target>-include=/path/include --with-<target>-lib=/path/lib
- ¤ÈÅù²Á¤Ç¤¢¤ë¡¥Äɲ䵤줿 include ¥Ç¥£¥ì¥¯¥È¥ê¤È lib ¥Ç¥£¥ì
- ¥¯¥È¥ê¤ÎÇÛÎó¤òÊÖ¤¹¡¥ ([include_dir, lib_dir])
+ ¤ÈÅù²Á¤Ç¤¢¤ë¡¥Äɲ䵤줿 include ¥Ç¥£¥ì¥¯¥È¥ê¤È lib ¥Ç¥£¥ì¥¯¥È¥ê¤Î
+ ÇÛÎó¤òÊÖ¤¹¡¥ ([include_dir, lib_dir])
pkg_config(pkg)
diff --git a/README.ja b/README.ja
index ee1e0d4951..71ce4ee12c 100644
--- a/README.ja
+++ b/README.ja
@@ -34,6 +34,10 @@ Ruby¤Ï¥Æ¥­¥¹¥È½èÍý´Ø·¸¤ÎǽÎϤʤɤËÍ¥¤ì¡¤Perl¤ÈƱ¤¸¤¯¤é¤¤¶¯ÎÏ
** Subversion¤Ç
+ËÜ¥Ö¥é¥ó¥Á¤ÎRuby¤ÎºÇ¿·¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï¼¡¤Î¥³¥Þ¥ó¥É¤Ç¼èÆÀ¤Ç¤­¤Þ¤¹¡¥
+
+ $ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/
+
³«È¯Àèü¤Î¥½¡¼¥¹¥³¡¼¥É¤Ï¼¡¤Î¥³¥Þ¥ó¥É¤Ç¼èÆÀ¤Ç¤­¤Þ¤¹¡¥
$ svn co http://svn.ruby-lang.org/repos/ruby/trunk/ ruby
@@ -88,6 +92,10 @@ Ruby³ÈÄ¥¥â¥¸¥å¡¼¥ë¤Ë¤Ä¤¤¤ÆÏ䷹礦ruby-ext¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤È
2. configure¤ò¼Â¹Ô¤·¤ÆMakefile¤Ê¤É¤òÀ¸À®¤¹¤ë
+ ´Ä¶­¤Ë¤è¤Ã¤Æ¤Ï¥Ç¥Õ¥©¥ë¥È¤ÎC¥³¥ó¥Ñ¥¤¥éÍÑ¥ª¥×¥·¥ç¥ó¤¬ÉÕ¤­
+ ¤Þ¤¹¡¥configure¥ª¥×¥·¥ç¥ó¤Ç optflags=.. warnflags=.. Åù
+ ¤Ç¾å½ñ¤­¤Ç¤­¤Þ¤¹¡¥
+
3. (ɬÍפʤé¤Ð)defines.h¤òÊÔ½¸¤¹¤ë
¿ʬ¡¤É¬Í×̵¤¤¤È»×¤¤¤Þ¤¹¡¥
diff --git a/ToDo b/ToDo
index 7e5ef523a8..b55e399edf 100644
--- a/ToDo
+++ b/ToDo
@@ -2,10 +2,6 @@ Language Spec.
- Class#allocate - basicNew
- class Foo::Bar<Baz .. end, module Boo::Bar .. end
-- raise exception by `` error
-- a +1 to be a+1, not a(+1).
-- clarify evaluation order of operator argument (=~, .., ...)
-- :symbol => value hash in the form of {symbol: value, ...} ??
* operator !! for rescue. ???
* objectify characters
* ../... outside condition invokes operator method too.
@@ -18,6 +14,7 @@ Language Spec.
* def Class#method .. end ??
* def Foo::Bar::baz() .. end ??
* I18N (or M17N) script/string/regexp
+* Fixnum 0 as false ????
* discourage use of symbol variables (e.g. $/, etc.) in manual
* discourage use of Perlish features by giving warnings.
* non confusing in-block local variable (is it possible?)
@@ -25,9 +22,12 @@ Language Spec.
+ variables appears within block may have independent values.
* Regexp: make /o thread safe.
* decide whether begin with rescue or ensure make do..while loop.
+* a +1 to be a+1, not a(+1).
* unify == and eql? again
* to_i returns nil if str contains no digit.
+* raise exception by `` error
* jar like combined library package. -> RubyGems?
+* resumable Exception via Exception#resume.
* method combination, e.g. before, after, around, etc.
* .. or something like defadvice in Emacs.
* property - for methods, or for objects in general.
@@ -35,6 +35,8 @@ Language Spec.
* selector namespace - something like generic-flet in CLOS, to help RubyBehavior
* private instance variable (as in Python?) @_foo in class Foo => @_Foo_foo
* warn/error "bare word" method, like "foo", you should type "foo()"
+* clarify evaluation order of operator argument (=~, .., ...)
+* :symbol => value hash in the form of {symbol: value, ...} ??
Hacking Interpreter
@@ -81,7 +83,7 @@ Standard Libraries
- use Mersenne Twister RNG for random.
- deprecate Array#indexes, and Array#indices.
- remove dependency on MAXPATHLEN.
-- String#scanf(?)
+* String#scanf(?)
* Object#fmt(?)
* Time::strptime
* Integer[num], Float[num]; Fixnum[num]?
@@ -115,7 +117,7 @@ Extension Libraries
Ruby Libraries
-- urllib.rb, nttplib.rb, etc.
+* urllib.rb, nttplib.rb, etc.
* format like perl's
Tools
diff --git a/array.c b/array.c
index 0a3fb64b24..7e8c12b683 100644
--- a/array.c
+++ b/array.c
@@ -6,24 +6,26 @@
$Date$
created at: Fri Aug 6 09:46:12 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/util.h"
-#include "ruby/st.h"
+#include "ruby.h"
+#include "util.h"
+#include "st.h"
VALUE rb_cArray;
-
static ID id_cmp;
#define ARY_DEFAULT_SIZE 16
+#define ARY_MAX_SIZE (LONG_MAX / sizeof(VALUE))
void
-rb_mem_clear(register VALUE *mem, register long size)
+rb_mem_clear(mem, size)
+ register VALUE *mem;
+ register long size;
{
while (size--) {
*mem++ = Qnil;
@@ -31,66 +33,48 @@ rb_mem_clear(register VALUE *mem, register long size)
}
static inline void
-memfill(register VALUE *mem, register long size, register VALUE val)
+memfill(mem, size, val)
+ register VALUE *mem;
+ register long size;
+ register VALUE val;
{
while (size--) {
*mem++ = val;
}
}
-#define ARY_ITERLOCK FL_USER1
-static void
-ary_iter_check(VALUE ary)
-{
- if (FL_TEST(ary, ARY_ITERLOCK)) {
- rb_raise(rb_eRuntimeError, "can't modify array during iteration");
- }
-}
-#define ARY_SORTLOCK FL_USER3
-#define ARY_SHARED_P(a) FL_TEST(a, ELTS_SHARED)
-
-#define ARY_SET_LEN(ary, n) do { \
- RARRAY(ary)->len = (n);\
-} while (0)
-
-#define ARY_CAPA(ary) RARRAY(ary)->aux.capa
-#define RESIZE_CAPA(ary,capacity) do {\
- REALLOC_N(RARRAY(ary)->ptr, VALUE, (capacity));\
- RARRAY(ary)->aux.capa = (capacity);\
-} while (0)
-
-#define ITERATE(func, ary) do { \
- FL_SET(ary, ARY_ITERLOCK); \
- return rb_ensure(func, (ary), each_unlock, (ary));\
-} while (0)
+#define ARY_TMPLOCK FL_USER1
static inline void
-rb_ary_modify_check(VALUE ary)
+rb_ary_modify_check(ary)
+ VALUE ary;
{
if (OBJ_FROZEN(ary)) rb_error_frozen("array");
- if (FL_TEST(ary, ARY_SORTLOCK))
- rb_raise(rb_eRuntimeError, "can't modify array during sort");
+ if (FL_TEST(ary, ARY_TMPLOCK))
+ rb_raise(rb_eRuntimeError, "can't modify array during iteration");
if (!OBJ_TAINTED(ary) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify array");
}
static void
-rb_ary_modify(VALUE ary)
+rb_ary_modify(ary)
+ VALUE ary;
{
VALUE *ptr;
rb_ary_modify_check(ary);
- if (ARY_SHARED_P(ary)) {
- ptr = ALLOC_N(VALUE, RARRAY_LEN(ary));
+ if (FL_TEST(ary, ELTS_SHARED)) {
+ ptr = ALLOC_N(VALUE, RARRAY(ary)->len);
FL_UNSET(ary, ELTS_SHARED);
- RARRAY(ary)->aux.capa = RARRAY_LEN(ary);
- MEMCPY(ptr, RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
+ RARRAY(ary)->aux.capa = RARRAY(ary)->len;
+ MEMCPY(ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
RARRAY(ary)->ptr = ptr;
}
}
VALUE
-rb_ary_freeze(VALUE ary)
+rb_ary_freeze(ary)
+ VALUE ary;
{
return rb_obj_freeze(ary);
}
@@ -104,15 +88,18 @@ rb_ary_freeze(VALUE ary)
*/
static VALUE
-rb_ary_frozen_p(VALUE ary)
+rb_ary_frozen_p(ary)
+ VALUE ary;
{
if (OBJ_FROZEN(ary)) return Qtrue;
- if (FL_TEST(ary, ARY_SORTLOCK)) return Qtrue;
+ if (FL_TEST(ary, ARY_TMPLOCK)) return Qtrue;
return Qfalse;
}
+static VALUE ary_alloc _((VALUE));
static VALUE
-ary_alloc(VALUE klass)
+ary_alloc(klass)
+ VALUE klass;
{
NEWOBJ(ary, struct RArray);
OBJSETUP(ary, klass, T_ARRAY);
@@ -125,17 +112,18 @@ ary_alloc(VALUE klass)
}
static VALUE
-ary_new(VALUE klass, long len)
+ary_new(klass, len)
+ VALUE klass;
+ long len;
{
- VALUE ary;
+ VALUE ary = ary_alloc(klass);
if (len < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
}
- if (len > 0 && len * sizeof(VALUE) <= len) {
+ if (len > ARY_MAX_SIZE) {
rb_raise(rb_eArgError, "array size too big");
}
- ary = ary_alloc(klass);
if (len == 0) len++;
RARRAY(ary)->ptr = ALLOC_N(VALUE, len);
RARRAY(ary)->aux.capa = len;
@@ -144,22 +132,35 @@ ary_new(VALUE klass, long len)
}
VALUE
-rb_ary_new2(long len)
+rb_ary_new2(len)
+ long len;
{
return ary_new(rb_cArray, len);
}
VALUE
-rb_ary_new(void)
+rb_ary_new()
{
return rb_ary_new2(ARY_DEFAULT_SIZE);
}
+#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
rb_ary_new3(long n, ...)
+#else
+rb_ary_new3(n, va_alist)
+ long n;
+ va_dcl
+#endif
{
va_list ar;
VALUE ary;
@@ -167,9 +168,9 @@ rb_ary_new3(long n, ...)
ary = rb_ary_new2(n);
- va_start(ar, n);
+ va_init_list(ar, n);
for (i=0; i<n; i++) {
- RARRAY_PTR(ary)[i] = va_arg(ar, VALUE);
+ RARRAY(ary)->ptr[i] = va_arg(ar, VALUE);
}
va_end(ar);
@@ -178,36 +179,30 @@ rb_ary_new3(long n, ...)
}
VALUE
-rb_ary_new4(long n, const VALUE *elts)
+rb_ary_new4(n, elts)
+ long n;
+ const VALUE *elts;
{
VALUE ary;
ary = rb_ary_new2(n);
if (n > 0 && elts) {
- MEMCPY(RARRAY_PTR(ary), elts, VALUE, n);
- RARRAY(ary)->len = n;
+ MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
}
- return ary;
-}
+ /* This assignment to len will be moved to the above "if" block in Ruby 1.9 */
+ RARRAY(ary)->len = n;
-void
-rb_ary_free(VALUE ary)
-{
- if (!ARY_SHARED_P(ary)) {
- xfree(RARRAY(ary)->ptr);
- }
+ return ary;
}
static VALUE
-ary_make_shared(VALUE ary)
+ary_make_shared(ary)
+ VALUE ary;
{
- if (ARY_SHARED_P(ary)) {
- return RARRAY(ary)->aux.shared;
- }
- else {
+ if (!FL_TEST(ary, ELTS_SHARED)) {
NEWOBJ(shared, struct RArray);
- OBJSETUP(shared, 0, T_ARRAY);
+ OBJSETUP(shared, rb_cArray, T_ARRAY);
shared->len = RARRAY(ary)->len;
shared->ptr = RARRAY(ary)->ptr;
@@ -217,51 +212,40 @@ ary_make_shared(VALUE ary)
OBJ_FREEZE(shared);
return (VALUE)shared;
}
+ else {
+ return RARRAY(ary)->aux.shared;
+ }
}
VALUE
-rb_assoc_new(VALUE car, VALUE cdr)
+rb_assoc_new(car, cdr)
+ VALUE car, cdr;
{
- return rb_ary_new3(2, car, cdr);
+ VALUE ary;
+
+ ary = rb_ary_new2(2);
+ RARRAY(ary)->ptr[0] = car;
+ RARRAY(ary)->ptr[1] = cdr;
+ RARRAY(ary)->len = 2;
+
+ return ary;
}
static VALUE
-to_ary(VALUE ary)
+to_ary(ary)
+ VALUE ary;
{
return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
}
VALUE
-rb_check_array_type(VALUE ary)
+rb_check_array_type(ary)
+ VALUE ary;
{
return rb_check_convert_type(ary, T_ARRAY, "Array", "to_ary");
}
-/*
- * call-seq:
- * Array.try_convert(obj) -> array or nil
- *
- * Try to convert <i>obj</i> into an array, using to_ary method.
- * Returns converted array or nil if <i>obj</i> cannot be converted
- * for any reason. This method is to check if an argument is an
- * array.
- *
- * Array.try_convert([1]) # => [1]
- * Array.try_convert("1") # => nil
- *
- * if tmp = Array.try_convert(arg)
- * # the argument is an array
- * elsif tmp = String.try_convert(arg)
- * # the argument is a string
- * end
- *
- */
-
-static VALUE
-rb_ary_s_try_convert(VALUE dummy, VALUE ary)
-{
- return rb_check_array_type(ary);
-}
+static VALUE rb_ary_replace _((VALUE, VALUE));
/*
* call-seq:
@@ -302,17 +286,16 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary)
*/
static VALUE
-rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
+rb_ary_initialize(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
long len;
VALUE size, val;
rb_ary_modify(ary);
- ary_iter_check(ary);
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
- if (RARRAY_PTR(ary) && !ARY_SHARED_P(ary)) {
- free(RARRAY(ary)->ptr);
- }
RARRAY(ary)->len = 0;
if (rb_block_given_p()) {
rb_warning("given block not used");
@@ -332,11 +315,13 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size");
}
- if (len > 0 && len * (long)sizeof(VALUE) <= len) {
+ if (len > ARY_MAX_SIZE) {
rb_raise(rb_eArgError, "array size too big");
}
- rb_ary_modify(ary);
- RESIZE_CAPA(ary, len);
+ if (len > RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
+ RARRAY(ary)->aux.capa = len;
+ }
if (rb_block_given_p()) {
long i;
@@ -349,9 +334,10 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
}
}
else {
- memfill(RARRAY_PTR(ary), len, val);
+ memfill(RARRAY(ary)->ptr, len, val);
RARRAY(ary)->len = len;
}
+
return ary;
}
@@ -365,61 +351,68 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
*/
static VALUE
-rb_ary_s_create(int argc, VALUE *argv, VALUE klass)
+rb_ary_s_create(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE ary = ary_alloc(klass);
- if (argc < 0) {
- rb_raise(rb_eArgError, "negative array size");
+ if (argc > 0) {
+ RARRAY(ary)->ptr = ALLOC_N(VALUE, argc);
+ MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
}
- RARRAY(ary)->ptr = ALLOC_N(VALUE, argc);
- RARRAY(ary)->aux.capa = argc;
- MEMCPY(RARRAY_PTR(ary), argv, VALUE, argc);
- RARRAY(ary)->len = argc;
+ RARRAY(ary)->len = RARRAY(ary)->aux.capa = argc;
return ary;
}
void
-rb_ary_store(VALUE ary, long idx, VALUE val)
+rb_ary_store(ary, idx, val)
+ VALUE ary;
+ long idx;
+ VALUE val;
{
if (idx < 0) {
- idx += RARRAY_LEN(ary);
+ idx += RARRAY(ary)->len;
if (idx < 0) {
rb_raise(rb_eIndexError, "index %ld out of array",
- idx - RARRAY_LEN(ary));
+ 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 >= ARY_CAPA(ary)) {
- long new_capa = ARY_CAPA(ary) / 2;
+ if (idx >= RARRAY(ary)->aux.capa) {
+ long new_capa = RARRAY(ary)->aux.capa / 2;
if (new_capa < ARY_DEFAULT_SIZE) {
new_capa = ARY_DEFAULT_SIZE;
}
- if (new_capa + idx < new_capa) {
- rb_raise(rb_eArgError, "index too big");
+ 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");
- }
- RESIZE_CAPA(ary, new_capa);
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, new_capa);
+ RARRAY(ary)->aux.capa = new_capa;
}
- if (idx > RARRAY_LEN(ary)) {
- rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary),
- idx-RARRAY_LEN(ary) + 1);
+ if (idx > RARRAY(ary)->len) {
+ rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len,
+ idx-RARRAY(ary)->len + 1);
}
- if (idx >= RARRAY_LEN(ary)) {
+ if (idx >= RARRAY(ary)->len) {
RARRAY(ary)->len = idx + 1;
}
- RARRAY_PTR(ary)[idx] = val;
+ RARRAY(ary)->ptr[idx] = val;
}
static VALUE
-ary_shared_array(VALUE klass, VALUE ary)
+ary_shared_array(klass, ary)
+ VALUE klass;
+ VALUE ary;
{
VALUE val = ary_alloc(klass);
@@ -432,7 +425,11 @@ ary_shared_array(VALUE klass, VALUE ary)
}
static VALUE
-ary_shared_first(int argc, VALUE *argv, VALUE ary, int last)
+ary_shared_first(argc, argv, ary, last)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+ int last;
{
VALUE nv, result;
long n;
@@ -440,14 +437,14 @@ ary_shared_first(int argc, VALUE *argv, VALUE ary, int last)
rb_scan_args(argc, argv, "1", &nv);
n = NUM2LONG(nv);
- if (n > RARRAY_LEN(ary)) {
- n = RARRAY_LEN(ary);
+ if (n > RARRAY(ary)->len) {
+ n = RARRAY(ary)->len;
}
else if (n < 0) {
rb_raise(rb_eArgError, "negative array size");
}
if (last) {
- offset = RARRAY_LEN(ary) - n;
+ offset = RARRAY(ary)->len - n;
}
result = ary_shared_array(rb_cArray, ary);
RARRAY(result)->ptr += offset;
@@ -470,9 +467,11 @@ ary_shared_first(int argc, VALUE *argv, VALUE ary, int last)
*/
VALUE
-rb_ary_push(VALUE ary, VALUE item)
+rb_ary_push(ary, item)
+ VALUE ary;
+ VALUE item;
{
- rb_ary_store(ary, RARRAY_LEN(ary), item);
+ rb_ary_store(ary, RARRAY(ary)->len, item);
return ary;
}
@@ -490,7 +489,10 @@ rb_ary_push(VALUE ary, VALUE item)
*/
static VALUE
-rb_ary_push_m(int argc, VALUE *argv, VALUE ary)
+rb_ary_push_m(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
while (argc--) {
rb_ary_push(ary, *argv++);
@@ -499,28 +501,30 @@ rb_ary_push_m(int argc, VALUE *argv, VALUE ary)
}
VALUE
-rb_ary_pop(VALUE ary)
+rb_ary_pop(ary)
+ VALUE ary;
{
- long n;
rb_ary_modify_check(ary);
- if (RARRAY_LEN(ary) == 0) return Qnil;
- if (!ARY_SHARED_P(ary) &&
- RARRAY_LEN(ary) * 3 < ARY_CAPA(ary) &&
- ARY_CAPA(ary) > ARY_DEFAULT_SIZE)
- {
- RESIZE_CAPA(ary, RARRAY_LEN(ary) * 2);
- }
- n = RARRAY_LEN(ary)-1;
- RARRAY(ary)->len = n;
- return RARRAY_PTR(ary)[n];
+ if (RARRAY(ary)->len == 0) return Qnil;
+ if (!FL_TEST(ary, ELTS_SHARED) &&
+ RARRAY(ary)->len * 3 < RARRAY(ary)->aux.capa &&
+ RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
+ RARRAY(ary)->aux.capa = RARRAY(ary)->len * 2;
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);
+ }
+ return RARRAY(ary)->ptr[--RARRAY(ary)->len];
}
/*
* call-seq:
- * array.pop -> obj or nil
+ * 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"
@@ -529,7 +533,10 @@ rb_ary_pop(VALUE ary)
*/
static VALUE
-rb_ary_pop_m(int argc, VALUE *argv, VALUE ary)
+rb_ary_pop_m(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE result;
@@ -539,26 +546,26 @@ rb_ary_pop_m(int argc, VALUE *argv, VALUE ary)
rb_ary_modify_check(ary);
result = ary_shared_first(argc, argv, ary, Qtrue);
- RARRAY(ary)->len -= RARRAY_LEN(result);
+ RARRAY(ary)->len -= RARRAY(result)->len;
return result;
}
VALUE
-rb_ary_shift(VALUE ary)
+rb_ary_shift(ary)
+ VALUE ary;
{
VALUE top;
rb_ary_modify_check(ary);
- ary_iter_check(ary);
- if (RARRAY_LEN(ary) == 0) return Qnil;
- top = RARRAY_PTR(ary)[0];
- if (!ARY_SHARED_P(ary)) {
- if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
- MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)-1);
+ 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_PTR(ary)[0] = Qnil;
+ return top;
+ }
+ RARRAY(ary)->ptr[0] = Qnil;
ary_make_shared(ary);
}
RARRAY(ary)->ptr++; /* shift ptr */
@@ -569,11 +576,15 @@ rb_ary_shift(VALUE ary)
/*
* call-seq:
- * array.shift -> obj or nil
+ * array.shift -> obj or nil
+ * array.shift(n) -> array
*
* 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"
@@ -585,7 +596,10 @@ rb_ary_shift(VALUE ary)
*/
static VALUE
-rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
+rb_ary_shift_m(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE result;
long n;
@@ -595,21 +609,43 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
}
rb_ary_modify_check(ary);
- ary_iter_check(ary);
result = ary_shared_first(argc, argv, ary, Qfalse);
- n = RARRAY_LEN(result);
- if (ARY_SHARED_P(ary)) {
+ n = RARRAY(result)->len;
+ if (FL_TEST(ary, ELTS_SHARED)) {
RARRAY(ary)->ptr += n;
RARRAY(ary)->len -= n;
}
else {
- MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+n, VALUE, RARRAY_LEN(ary)-n);
+ MEMMOVE(RARRAY(ary)->ptr, RARRAY(ary)->ptr+n, VALUE, RARRAY(ary)->len-n);
RARRAY(ary)->len -= n;
}
return result;
}
+VALUE
+rb_ary_unshift(ary, item)
+ VALUE ary, item;
+{
+ rb_ary_modify(ary);
+ if (RARRAY(ary)->len == RARRAY(ary)->aux.capa) {
+ long capa_inc = RARRAY(ary)->aux.capa / 2;
+ if (capa_inc < ARY_DEFAULT_SIZE) {
+ capa_inc = ARY_DEFAULT_SIZE;
+ }
+ RARRAY(ary)->aux.capa += capa_inc;
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);
+ }
+
+ /* sliding items */
+ MEMMOVE(RARRAY(ary)->ptr + 1, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
+
+ RARRAY(ary)->len++;
+ RARRAY(ary)->ptr[0] = item;
+
+ return ary;
+}
+
/*
* call-seq:
* array.unshift(obj, ...) -> array
@@ -623,68 +659,70 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
*/
static VALUE
-rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
+rb_ary_unshift_m(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
long len = RARRAY(ary)->len;
if (argc == 0) return ary;
- rb_ary_modify(ary);
- ary_iter_check(ary);
- if (RARRAY(ary)->aux.capa <= RARRAY_LEN(ary)+argc) {
- RESIZE_CAPA(ary, RARRAY(ary)->aux.capa + ARY_DEFAULT_SIZE);
- }
+
+ /* make rooms by setting the last item */
+ rb_ary_store(ary, len + argc - 1, Qnil);
/* sliding items */
MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len);
MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
- RARRAY(ary)->len += argc;
return ary;
}
-VALUE
-rb_ary_unshift(VALUE ary, VALUE item)
-{
- return rb_ary_unshift_m(1,&item,ary);
-}
-
/* faster version - use this if you don't need to treat negative offset */
static inline VALUE
-rb_ary_elt(VALUE ary, long offset)
+rb_ary_elt(ary, offset)
+ VALUE ary;
+ long offset;
{
- if (RARRAY_LEN(ary) == 0) return Qnil;
- if (offset < 0 || RARRAY_LEN(ary) <= offset) {
+ if (RARRAY(ary)->len == 0) return Qnil;
+ if (offset < 0 || RARRAY(ary)->len <= offset) {
return Qnil;
}
- return RARRAY_PTR(ary)[offset];
+ return RARRAY(ary)->ptr[offset];
}
VALUE
-rb_ary_entry(VALUE ary, long offset)
+rb_ary_entry(ary, offset)
+ VALUE ary;
+ long offset;
{
if (offset < 0) {
- offset += RARRAY_LEN(ary);
+ offset += RARRAY(ary)->len;
}
return rb_ary_elt(ary, offset);
}
-VALUE
-rb_ary_subseq(VALUE ary, long beg, long len)
+static VALUE
+rb_ary_subseq(ary, beg, len)
+ VALUE ary;
+ long beg, len;
{
VALUE klass, ary2, shared;
VALUE *ptr;
- if (beg > RARRAY_LEN(ary)) return Qnil;
+ if (beg > RARRAY(ary)->len) return Qnil;
if (beg < 0 || len < 0) return Qnil;
- if (RARRAY_LEN(ary) < len || RARRAY_LEN(ary) < beg + len) {
- len = RARRAY_LEN(ary) - beg;
+ if (RARRAY(ary)->len < len || RARRAY(ary)->len < beg + len) {
+ len = RARRAY(ary)->len - beg;
+ if (len < 0)
+ len = 0;
}
klass = rb_obj_class(ary);
if (len == 0) return ary_new(klass, 0);
shared = ary_make_shared(ary);
- ptr = RARRAY_PTR(ary);
+ ptr = RARRAY(ary)->ptr;
ary2 = ary_alloc(klass);
RARRAY(ary2)->ptr = ptr + beg;
RARRAY(ary2)->len = len;
@@ -727,16 +765,22 @@ rb_ary_subseq(VALUE ary, long beg, long len)
*/
VALUE
-rb_ary_aref(int argc, VALUE *argv, VALUE ary)
+rb_ary_aref(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE arg;
long beg, len;
if (argc == 2) {
+ if (SYMBOL_P(argv[0])) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
beg = NUM2LONG(argv[0]);
len = NUM2LONG(argv[1]);
if (beg < 0) {
- beg += RARRAY_LEN(ary);
+ beg += RARRAY(ary)->len;
}
return rb_ary_subseq(ary, beg, len);
}
@@ -748,8 +792,11 @@ rb_ary_aref(int argc, VALUE *argv, VALUE ary)
if (FIXNUM_P(arg)) {
return rb_ary_entry(ary, FIX2LONG(arg));
}
+ if (SYMBOL_P(arg)) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
/* check if idx is Range */
- switch (rb_range_beg_len(arg, &beg, &len, RARRAY_LEN(ary), 0)) {
+ switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) {
case Qfalse:
break;
case Qnil:
@@ -767,6 +814,8 @@ rb_ary_aref(int argc, VALUE *argv, VALUE ary)
* Returns the element at _index_. A
* negative index counts from the end of _self_. Returns +nil+
* if the index is out of range. See also <code>Array#[]</code>.
+ * (<code>Array#at</code> is slightly faster than <code>Array#[]</code>,
+ * as it does not accept ranges and so on.)
*
* a = [ "a", "b", "c", "d", "e" ]
* a.at(0) #=> "a"
@@ -774,31 +823,36 @@ rb_ary_aref(int argc, VALUE *argv, VALUE ary)
*/
static VALUE
-rb_ary_at(VALUE ary, VALUE pos)
+rb_ary_at(ary, pos)
+ VALUE ary, pos;
{
return rb_ary_entry(ary, NUM2LONG(pos));
}
/*
* call-seq:
- * array.first -> obj or nil
- * array.first(n) -> an_array
- *
+ * array.first -> obj or nil
+ * array.first(n) -> an_array
+ *
* Returns the first element, or the first +n+ elements, of the array.
* If the array is empty, the first form returns <code>nil</code>, and the
* second form returns an empty array.
- *
+ *
* a = [ "q", "r", "s", "t" ]
- * a.first #=> "q"
- * a.first(2) #=> ["q", "r"]
+ * a.first #=> "q"
+ * a.first(1) #=> ["q"]
+ * a.first(3) #=> ["q", "r", "s"]
*/
static VALUE
-rb_ary_first(int argc, VALUE *argv, VALUE ary)
+rb_ary_first(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
if (argc == 0) {
- if (RARRAY_LEN(ary) == 0) return Qnil;
- return RARRAY_PTR(ary)[0];
+ if (RARRAY(ary)->len == 0) return Qnil;
+ return RARRAY(ary)->ptr[0];
}
else {
return ary_shared_first(argc, argv, ary, Qfalse);
@@ -813,17 +867,18 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary)
* Returns the last element(s) of <i>self</i>. If the array is empty,
* the first form returns <code>nil</code>.
*
- * a = [ "w", "x", "y", "z" ]
- * a.last #=> "z"
- * a.last(2) #=> ["y", "z"]
+ * [ "w", "x", "y", "z" ].last #=> "z"
*/
-VALUE
-rb_ary_last(int argc, VALUE *argv, VALUE ary)
+static VALUE
+rb_ary_last(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
if (argc == 0) {
- if (RARRAY_LEN(ary) == 0) return Qnil;
- return RARRAY_PTR(ary)[RARRAY_LEN(ary)-1];
+ if (RARRAY(ary)->len == 0) return Qnil;
+ return RARRAY(ary)->ptr[RARRAY(ary)->len-1];
}
else {
return ary_shared_first(argc, argv, ary, Qtrue);
@@ -851,7 +906,10 @@ rb_ary_last(int argc, VALUE *argv, VALUE ary)
*/
static VALUE
-rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
+rb_ary_fetch(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE pos, ifnone;
long block_given;
@@ -865,16 +923,16 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
idx = NUM2LONG(pos);
if (idx < 0) {
- idx += RARRAY_LEN(ary);
+ idx += RARRAY(ary)->len;
}
- if (idx < 0 || RARRAY_LEN(ary) <= idx) {
+ if (idx < 0 || RARRAY(ary)->len <= idx) {
if (block_given) return rb_yield(pos);
if (argc == 1) {
rb_raise(rb_eIndexError, "index %ld out of array", idx);
}
return ifnone;
}
- return RARRAY_PTR(ary)[idx];
+ return RARRAY(ary)->ptr[idx];
}
/*
@@ -891,27 +949,32 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
* a.index("b") #=> 1
* a.index("z") #=> nil
* a.index{|x|x=="b"} #=> 1
+ *
+ * This is an alias of <code>#find_index</code>.
*/
static VALUE
-rb_ary_index(int argc, VALUE *argv, VALUE ary)
+rb_ary_index(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE val;
long i;
- if (rb_scan_args(argc, argv, "01", &val) == 0) {
+ if (argc == 0) {
RETURN_ENUMERATOR(ary, 0, 0);
- for (i=0; i<RARRAY_LEN(ary); i++) {
- if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ if (RTEST(rb_yield(RARRAY(ary)->ptr[i]))) {
return LONG2NUM(i);
}
}
+ return Qnil;
}
- else {
- for (i=0; i<RARRAY_LEN(ary); i++) {
- if (rb_equal(RARRAY_PTR(ary)[i], val))
- return LONG2NUM(i);
- }
+ 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);
}
return Qnil;
}
@@ -932,101 +995,139 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
*/
static VALUE
-rb_ary_rindex(int argc, VALUE *argv, VALUE ary)
+rb_ary_rindex(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE val;
- long i = RARRAY_LEN(ary);
+ long i = RARRAY(ary)->len;
- if (rb_scan_args(argc, argv, "01", &val) == 0) {
+ if (argc == 0) {
RETURN_ENUMERATOR(ary, 0, 0);
while (i--) {
- if (RTEST(rb_yield(RARRAY_PTR(ary)[i])))
+ if (RTEST(rb_yield(RARRAY(ary)->ptr[i])))
return LONG2NUM(i);
- if (i > RARRAY_LEN(ary)) {
- i = RARRAY_LEN(ary);
+ if (i > RARRAY(ary)->len) {
+ i = RARRAY(ary)->len;
}
}
+ return Qnil;
}
- else {
- while (i--) {
- if (rb_equal(RARRAY_PTR(ary)[i], val))
- return LONG2NUM(i);
- if (i > RARRAY_LEN(ary)) {
- i = RARRAY_LEN(ary);
- }
+ 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;
}
}
return Qnil;
}
+/*
+ * call-seq:
+ * array.indexes( i1, i2, ... iN ) -> an_array
+ * array.indices( i1, i2, ... iN ) -> an_array
+ *
+ * Deprecated; use <code>Array#values_at</code>.
+ */
+
+static VALUE
+rb_ary_indexes(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ VALUE new_ary;
+ long i;
+
+ rb_warn("Array#%s is deprecated; use Array#values_at", rb_id2name(rb_frame_last_func()));
+ new_ary = rb_ary_new2(argc);
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new_ary, rb_ary_aref(1, argv+i, ary));
+ }
+
+ return new_ary;
+}
+
VALUE
-rb_ary_to_ary(VALUE obj)
+rb_ary_to_ary(obj)
+ VALUE obj;
{
if (TYPE(obj) == T_ARRAY) {
return obj;
}
if (rb_respond_to(obj, rb_intern("to_ary"))) {
- return to_ary(obj);
+ return rb_convert_type(obj, T_ARRAY, "Array", "to_ary");
}
return rb_ary_new3(1, obj);
}
static void
-rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
+rb_ary_splice(ary, beg, len, rpl)
+ VALUE ary;
+ long beg, len;
+ VALUE rpl;
{
long rlen;
if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
if (beg < 0) {
- beg += RARRAY_LEN(ary);
+ beg += RARRAY(ary)->len;
if (beg < 0) {
- beg -= RARRAY_LEN(ary);
+ beg -= RARRAY(ary)->len;
rb_raise(rb_eIndexError, "index %ld out of array", beg);
}
}
- if (RARRAY_LEN(ary) < len || RARRAY_LEN(ary) < beg + len) {
- len = RARRAY_LEN(ary) - beg;
+ if (RARRAY(ary)->len < len || RARRAY(ary)->len < beg + len) {
+ len = RARRAY(ary)->len - beg;
}
- if (rpl == Qundef) {
+ if (NIL_P(rpl)) {
rlen = 0;
}
else {
rpl = rb_ary_to_ary(rpl);
- rlen = RARRAY_LEN(rpl);
+ rlen = RARRAY(rpl)->len;
}
rb_ary_modify(ary);
- ary_iter_check(ary);
- if (beg >= RARRAY_LEN(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 >= ARY_CAPA(ary)) {
- RESIZE_CAPA(ary, len);
+ if (len >= RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
+ RARRAY(ary)->aux.capa = len;
}
- rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), beg - RARRAY_LEN(ary));
+ rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len, beg - RARRAY(ary)->len);
if (rlen > 0) {
- MEMCPY(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen);
+ MEMCPY(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
}
RARRAY(ary)->len = len;
}
else {
long alen;
- if (beg + len > RARRAY_LEN(ary)) {
- len = RARRAY_LEN(ary) - beg;
+ if (beg + len > RARRAY(ary)->len) {
+ len = RARRAY(ary)->len - beg;
}
- alen = RARRAY_LEN(ary) + rlen - len;
- if (alen >= ARY_CAPA(ary)) {
- RESIZE_CAPA(ary, alen);
+ alen = RARRAY(ary)->len + rlen - len;
+ if (alen >= RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, alen);
+ RARRAY(ary)->aux.capa = alen;
}
if (len != rlen) {
- MEMMOVE(RARRAY_PTR(ary) + beg + rlen, RARRAY_PTR(ary) + beg + len,
- VALUE, RARRAY_LEN(ary) - (beg + len));
+ MEMMOVE(RARRAY(ary)->ptr + beg + rlen, RARRAY(ary)->ptr + beg + len,
+ VALUE, RARRAY(ary)->len - (beg + len));
RARRAY(ary)->len = alen;
}
if (rlen > 0) {
- MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen);
+ MEMMOVE(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
}
}
}
@@ -1044,8 +1145,9 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
* the current capacity of the array, the array grows
* automatically. A negative indices will count backward
* from the end of the array. Inserts elements if _length_ is
- * zero. An +IndexError+ is raised if a negative index points
- * past the beginning of the array. See also
+ * zero. If +nil+ is used in the second and third form,
+ * deletes elements from _self_. An +IndexError+ is raised if a
+ * negative index points past the beginning of the array. See also
* <code>Array#push</code>, and <code>Array#unshift</code>.
*
* a = Array.new
@@ -1055,16 +1157,24 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
* a[0, 2] = "?" #=> ["?", 2, nil, "4"]
* a[0..2] = "A" #=> ["A", "4"]
* a[-1] = "Z" #=> ["A", "Z"]
- * a[1..-1] = nil #=> ["A", nil]
- * a[1..-1] = [] #=> ["A"]
+ * a[1..-1] = nil #=> ["A"]
*/
static VALUE
-rb_ary_aset(int argc, VALUE *argv, VALUE ary)
+rb_ary_aset(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
long offset, beg, len;
if (argc == 3) {
+ if (SYMBOL_P(argv[0])) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
+ if (SYMBOL_P(argv[1])) {
+ rb_raise(rb_eTypeError, "Symbol as subarray length");
+ }
rb_ary_splice(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
return argv[2];
}
@@ -1075,7 +1185,10 @@ rb_ary_aset(int argc, VALUE *argv, VALUE ary)
offset = FIX2LONG(argv[0]);
goto fixnum;
}
- if (rb_range_beg_len(argv[0], &beg, &len, RARRAY_LEN(ary), 1)) {
+ if (SYMBOL_P(argv[0])) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
+ if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
/* check if idx is Range */
rb_ary_splice(ary, beg, len, argv[1]);
return argv[1];
@@ -1100,7 +1213,10 @@ fixnum:
*/
static VALUE
-rb_ary_insert(int argc, VALUE *argv, VALUE ary)
+rb_ary_insert(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
long pos;
@@ -1110,7 +1226,7 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary)
}
pos = NUM2LONG(argv[0]);
if (pos == -1) {
- pos = RARRAY_LEN(ary);
+ pos = RARRAY(ary)->len;
}
if (pos < 0) {
pos++;
@@ -1119,24 +1235,6 @@ rb_ary_insert(int argc, VALUE *argv, VALUE ary)
return ary;
}
-static VALUE
-each_unlock(VALUE ary)
-{
- FL_UNSET(ary, ARY_ITERLOCK);
- return ary;
-}
-
-static VALUE
-each_i(VALUE ary)
-{
- long i;
-
- for (i=0; i<RARRAY_LEN(ary); i++) {
- rb_yield(RARRAY_PTR(ary)[i]);
- }
- return ary;
-}
-
/*
* call-seq:
* array.each {|item| block } -> array
@@ -1153,20 +1251,14 @@ each_i(VALUE ary)
*/
VALUE
-rb_ary_each(VALUE ary)
-{
- RETURN_ENUMERATOR(ary, 0, 0);
- ITERATE(each_i, ary);
- return ary;
-}
-
-static VALUE
-each_index_i(VALUE ary)
+rb_ary_each(ary)
+ VALUE ary;
{
long i;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- rb_yield(LONG2NUM(i));
+ RETURN_ENUMERATOR(ary, 0, 0);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ rb_yield(RARRAY(ary)->ptr[i]);
}
return ary;
}
@@ -1187,23 +1279,14 @@ each_index_i(VALUE ary)
*/
static VALUE
-rb_ary_each_index(VALUE ary)
-{
- RETURN_ENUMERATOR(ary, 0, 0);
- ITERATE(each_index_i, ary);
- return ary;
-}
-
-static VALUE
-reverse_each_i(VALUE ary)
+rb_ary_each_index(ary)
+ VALUE ary;
{
- long len = RARRAY_LEN(ary);
+ long i;
- while (len--) {
- rb_yield(RARRAY_PTR(ary)[len]);
- if (RARRAY_LEN(ary) < len) {
- len = RARRAY_LEN(ary);
- }
+ RETURN_ENUMERATOR(ary, 0, 0);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ rb_yield(LONG2NUM(i));
}
return ary;
}
@@ -1224,10 +1307,20 @@ reverse_each_i(VALUE ary)
*/
static VALUE
-rb_ary_reverse_each(VALUE ary)
+rb_ary_reverse_each(ary)
+ VALUE ary;
{
+ long len;
+
RETURN_ENUMERATOR(ary, 0, 0);
- ITERATE(reverse_each_i, ary);
+ len = RARRAY(ary)->len;
+ while (len--) {
+ rb_yield(RARRAY(ary)->ptr[len]);
+ if (RARRAY(ary)->len < len) {
+ len = RARRAY(ary)->len;
+ }
+ }
+ return ary;
}
/*
@@ -1240,10 +1333,10 @@ rb_ary_reverse_each(VALUE ary)
*/
static VALUE
-rb_ary_length(VALUE ary)
+rb_ary_length(ary)
+ VALUE ary;
{
- long len = RARRAY_LEN(ary);
- return LONG2NUM(len);
+ return LONG2NUM(RARRAY(ary)->len);
}
/*
@@ -1256,68 +1349,71 @@ rb_ary_length(VALUE ary)
*/
static VALUE
-rb_ary_empty_p(VALUE ary)
+rb_ary_empty_p(ary)
+ VALUE ary;
{
- if (RARRAY_LEN(ary) == 0)
+ if (RARRAY(ary)->len == 0)
return Qtrue;
return Qfalse;
}
VALUE
-rb_ary_dup(VALUE ary)
+rb_ary_dup(ary)
+ VALUE ary;
{
- VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
-
- MEMCPY(RARRAY_PTR(dup), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
- RARRAY(dup)->len = RARRAY_LEN(ary);
- OBJ_INFECT(dup, ary);
+ VALUE dup = rb_ary_new2(RARRAY(ary)->len);
+ DUPSETUP(dup, ary);
+ MEMCPY(RARRAY(dup)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
+ RARRAY(dup)->len = RARRAY(ary)->len;
return dup;
}
extern VALUE rb_output_fs;
static VALUE
-recursive_join(VALUE ary, VALUE argp, int recur)
+inspect_join(ary, arg)
+ VALUE ary;
+ VALUE *arg;
{
- VALUE *arg = (VALUE *)argp;
- if (recur) {
- return rb_str_new2("[...]");
- }
return rb_ary_join(arg[0], arg[1]);
}
VALUE
-rb_ary_join(VALUE ary, VALUE sep)
+rb_ary_join(ary, sep)
+ VALUE ary, sep;
{
long len = 1, i;
int taint = Qfalse;
VALUE result, tmp;
- if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
+ if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- tmp = rb_check_string_type(RARRAY_PTR(ary)[i]);
- len += NIL_P(tmp) ? 10 : RSTRING_LEN(tmp);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ tmp = rb_check_string_type(RARRAY(ary)->ptr[i]);
+ len += NIL_P(tmp) ? 10 : RSTRING(tmp)->len;
}
if (!NIL_P(sep)) {
StringValue(sep);
- len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
+ len += RSTRING(sep)->len * (RARRAY(ary)->len - 1);
}
result = rb_str_buf_new(len);
- for (i=0; i<RARRAY_LEN(ary); i++) {
- tmp = RARRAY_PTR(ary)[i];
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ tmp = RARRAY(ary)->ptr[i];
switch (TYPE(tmp)) {
case T_STRING:
break;
case T_ARRAY:
- {
+ if (rb_inspecting_p(tmp)) {
+ tmp = rb_str_new2("[...]");
+ }
+ else {
VALUE args[2];
args[0] = tmp;
args[1] = sep;
- tmp = rb_exec_recursive(recursive_join, ary, (VALUE)args);
+ tmp = rb_protect_inspect(inspect_join, ary, (VALUE)args);
}
break;
default:
@@ -1345,7 +1441,10 @@ rb_ary_join(VALUE ary, VALUE sep)
*/
static VALUE
-rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
+rb_ary_join_m(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE sep;
@@ -1355,17 +1454,118 @@ rb_ary_join_m(int argc, VALUE *argv, VALUE ary)
return rb_ary_join(ary, sep);
}
+/*
+ * call-seq:
+ * array.to_s -> string
+ *
+ * Returns _self_<code>.join</code>.
+ *
+ * [ "a", "e", "i", "o" ].to_s #=> "aeio"
+ *
+ */
+
+VALUE
+rb_ary_to_s(ary)
+ VALUE ary;
+{
+ if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
+
+ return rb_ary_join(ary, rb_output_fs);
+}
+
+static ID inspect_key;
+
+struct inspect_arg {
+ VALUE (*func)();
+ VALUE arg1, arg2;
+};
+
+static VALUE
+inspect_call(arg)
+ struct inspect_arg *arg;
+{
+ return (*arg->func)(arg->arg1, arg->arg2);
+}
+
+static VALUE
+get_inspect_tbl(create)
+ int create;
+{
+ VALUE inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
+
+ if (NIL_P(inspect_tbl)) {
+ if (create) {
+ tbl_init:
+ inspect_tbl = rb_ary_new();
+ rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl);
+ }
+ }
+ else if (TYPE(inspect_tbl) != T_ARRAY) {
+ rb_warn("invalid inspect_tbl value");
+ if (create) goto tbl_init;
+ rb_thread_local_aset(rb_thread_current(), inspect_key, Qnil);
+ return Qnil;
+ }
+ return inspect_tbl;
+}
+
+static VALUE
+inspect_ensure(obj)
+ VALUE obj;
+{
+ VALUE inspect_tbl;
+
+ inspect_tbl = get_inspect_tbl(Qfalse);
+ if (!NIL_P(inspect_tbl)) {
+ rb_ary_pop(inspect_tbl);
+ }
+ return 0;
+}
+
+VALUE
+rb_protect_inspect(func, obj, arg)
+ VALUE (*func)(ANYARGS);
+ VALUE obj, arg;
+{
+ struct inspect_arg iarg;
+ VALUE inspect_tbl;
+ VALUE id;
+
+ inspect_tbl = get_inspect_tbl(Qtrue);
+ id = rb_obj_id(obj);
+ if (rb_ary_includes(inspect_tbl, id)) {
+ return (*func)(obj, arg);
+ }
+ rb_ary_push(inspect_tbl, id);
+ iarg.func = func;
+ iarg.arg1 = obj;
+ iarg.arg2 = arg;
+
+ return rb_ensure(inspect_call, (VALUE)&iarg, inspect_ensure, obj);
+}
+
+VALUE
+rb_inspecting_p(obj)
+ VALUE obj;
+{
+ VALUE inspect_tbl;
+
+ inspect_tbl = get_inspect_tbl(Qfalse);
+ if (NIL_P(inspect_tbl)) return Qfalse;
+ return rb_ary_includes(inspect_tbl, rb_obj_id(obj));
+}
+
static VALUE
-inspect_ary(VALUE ary, VALUE dummy, int recur)
+inspect_ary(ary)
+ VALUE ary;
{
int tainted = OBJ_TAINTED(ary);
long i;
VALUE s, str;
- if (recur) return rb_tainted_str_new2("[...]");
str = rb_str_buf_new2("[");
- for (i=0; i<RARRAY_LEN(ary); i++) {
- s = rb_inspect(RARRAY_PTR(ary)[i]);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ s = rb_inspect(RARRAY(ary)->ptr[i]);
if (OBJ_TAINTED(s)) tainted = Qtrue;
if (i > 0) rb_str_buf_cat2(str, ", ");
rb_str_buf_append(str, s);
@@ -1377,23 +1577,18 @@ inspect_ary(VALUE ary, VALUE dummy, int recur)
/*
* call-seq:
- * array.to_s -> string
* array.inspect -> string
*
* Create a printable version of <i>array</i>.
*/
static VALUE
-rb_ary_inspect(VALUE ary)
-{
- if (RARRAY_LEN(ary) == 0) return rb_str_new2("[]");
- return rb_exec_recursive(inspect_ary, ary, 0);
-}
-
-VALUE
-rb_ary_to_s(VALUE ary)
+rb_ary_inspect(ary)
+ VALUE ary;
{
- return rb_ary_inspect(ary);
+ if (RARRAY(ary)->len == 0) return rb_str_new2("[]");
+ if (rb_inspecting_p(ary)) return rb_str_new2("[...]");
+ return rb_protect_inspect(inspect_ary, ary, 0);
}
/*
@@ -1405,10 +1600,11 @@ rb_ary_to_s(VALUE ary)
*/
static VALUE
-rb_ary_to_a(VALUE ary)
+rb_ary_to_a(ary)
+ VALUE ary;
{
if (rb_obj_class(ary) != rb_cArray) {
- VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
+ VALUE dup = rb_ary_new2(RARRAY(ary)->len);
rb_ary_replace(dup, ary);
return dup;
}
@@ -1423,22 +1619,23 @@ rb_ary_to_a(VALUE ary)
*/
static VALUE
-rb_ary_to_ary_m(VALUE ary)
+rb_ary_to_ary_m(ary)
+ VALUE ary;
{
return ary;
}
VALUE
-rb_ary_reverse(VALUE ary)
+rb_ary_reverse(ary)
+ VALUE ary;
{
VALUE *p1, *p2;
VALUE tmp;
rb_ary_modify(ary);
- ary_iter_check(ary);
- if (RARRAY_LEN(ary) > 1) {
- p1 = RARRAY_PTR(ary);
- p2 = p1 + RARRAY_LEN(ary) - 1; /* points last item */
+ if (RARRAY(ary)->len > 1) {
+ p1 = RARRAY(ary)->ptr;
+ p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
while (p1 < p2) {
tmp = *p1;
@@ -1461,7 +1658,8 @@ rb_ary_reverse(VALUE ary)
*/
static VALUE
-rb_ary_reverse_bang(VALUE ary)
+rb_ary_reverse_bang(ary)
+ VALUE ary;
{
return rb_ary_reverse(ary);
}
@@ -1477,7 +1675,8 @@ rb_ary_reverse_bang(VALUE ary)
*/
static VALUE
-rb_ary_reverse_m(VALUE ary)
+rb_ary_reverse_m(ary)
+ VALUE ary;
{
return rb_ary_reverse(rb_ary_dup(ary));
}
@@ -1489,30 +1688,34 @@ struct ary_sort_data {
};
static void
-ary_sort_check(struct ary_sort_data *data)
+ary_sort_check(data)
+ struct ary_sort_data *data;
{
- if (RARRAY_PTR(data->ary) != data->ptr || RARRAY_LEN(data->ary) != data->len) {
- rb_raise(rb_eRuntimeError, "array modified during sort");
+ if (RARRAY(data->ary)->ptr != data->ptr || RARRAY(data->ary)->len != data->len) {
+ rb_raise(rb_eArgError, "array modified during sort");
}
}
static int
-sort_1(const void *ap, const void *bp, void *data)
+sort_1(a, b, data)
+ VALUE *a, *b;
+ struct ary_sort_data *data;
{
- VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
- VALUE retval = rb_yield_values(2, a, b);
+ VALUE retval = rb_yield_values(2, *a, *b);
int n;
- n = rb_cmpint(retval, a, b);
- ary_sort_check((struct ary_sort_data *)data);
+ n = rb_cmpint(retval, *a, *b);
+ ary_sort_check(data);
return n;
}
static int
-sort_2(const void *ap, const void *bp, void *data)
+sort_2(ap, bp, data)
+ VALUE *ap, *bp;
+ struct ary_sort_data *data;
{
VALUE retval;
- VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
+ VALUE a = *ap, b = *bp;
int n;
if (FIXNUM_P(a) && FIXNUM_P(b)) {
@@ -1526,27 +1729,29 @@ sort_2(const void *ap, const void *bp, void *data)
retval = rb_funcall(a, id_cmp, 1, b);
n = rb_cmpint(retval, a, b);
- ary_sort_check((struct ary_sort_data *)data);
+ ary_sort_check(data);
return n;
}
static VALUE
-sort_i(VALUE ary)
+sort_internal(ary)
+ VALUE ary;
{
struct ary_sort_data data;
data.ary = ary;
- data.ptr = RARRAY_PTR(ary); data.len = RARRAY_LEN(ary);
- ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE),
+ data.ptr = RARRAY(ary)->ptr; data.len = RARRAY(ary)->len;
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),
rb_block_given_p()?sort_1:sort_2, &data);
return ary;
}
static VALUE
-sort_unlock(VALUE ary)
+sort_unlock(ary)
+ VALUE ary;
{
- FL_UNSET(ary, ARY_SORTLOCK);
+ FL_UNSET(ary, ARY_TMPLOCK);
return ary;
}
@@ -1567,13 +1772,13 @@ sort_unlock(VALUE ary)
*/
VALUE
-rb_ary_sort_bang(VALUE ary)
+rb_ary_sort_bang(ary)
+ VALUE ary;
{
rb_ary_modify(ary);
- ary_iter_check(ary);
- if (RARRAY_LEN(ary) > 1) {
- FL_SET(ary, ARY_SORTLOCK); /* prohibit modification during sort */
- rb_ensure(sort_i, ary, sort_unlock, ary);
+ if (RARRAY(ary)->len > 1) {
+ FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
+ rb_ensure(sort_internal, ary, sort_unlock, ary);
}
return ary;
}
@@ -1595,27 +1800,14 @@ rb_ary_sort_bang(VALUE ary)
*/
VALUE
-rb_ary_sort(VALUE ary)
+rb_ary_sort(ary)
+ VALUE ary;
{
ary = rb_ary_dup(ary);
rb_ary_sort_bang(ary);
return ary;
}
-
-static VALUE
-collect_i(VALUE ary)
-{
- long i;
- VALUE collect;
-
- collect = rb_ary_new2(RARRAY_LEN(ary));
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- rb_ary_push(collect, rb_yield(RARRAY_PTR(ary)[i]));
- }
- return collect;
-}
-
/*
* call-seq:
* array.collect {|item| block } -> an_array
@@ -1631,23 +1823,21 @@ collect_i(VALUE ary)
*/
static VALUE
-rb_ary_collect(VALUE ary)
-{
- RETURN_ENUMERATOR(ary, 0, 0);
- ITERATE(collect_i, ary);
-}
-
-
-static VALUE
-collect_bang_i(VALUE ary)
+rb_ary_collect(ary)
+ VALUE ary;
{
long i;
+ VALUE collect;
- rb_ary_modify(ary);
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- RARRAY_PTR(ary)[i] = rb_yield(RARRAY_PTR(ary)[i]);
+ if (!rb_block_given_p()) {
+ return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
}
- return ary;
+
+ collect = rb_ary_new2(RARRAY(ary)->len);
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i]));
+ }
+ return collect;
}
/*
@@ -1665,14 +1855,26 @@ collect_bang_i(VALUE ary)
*/
static VALUE
-rb_ary_collect_bang(VALUE ary)
+rb_ary_collect_bang(ary)
+ VALUE ary;
{
+ long i;
+
RETURN_ENUMERATOR(ary, 0, 0);
- ITERATE(collect_bang_i, ary);
+ rb_ary_modify(ary);
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ rb_ary_store(ary, i, rb_yield(RARRAY(ary)->ptr[i]));
+ }
+ return ary;
}
VALUE
-rb_get_values_at(VALUE obj, long olen, int argc, VALUE *argv, VALUE (*func) (VALUE, long))
+rb_values_at(obj, olen, argc, argv, func)
+ VALUE obj;
+ long olen;
+ int argc;
+ VALUE *argv;
+ VALUE (*func) _((VALUE,long));
{
VALUE result = rb_ary_new2(argc);
long beg, len, i, j;
@@ -1716,25 +1918,12 @@ rb_get_values_at(VALUE obj, long olen, int argc, VALUE *argv, VALUE (*func) (VAL
*/
static VALUE
-rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
-{
- return rb_get_values_at(ary, RARRAY_LEN(ary), argc, argv, rb_ary_entry);
-}
-
-
-static VALUE
-select_i(VALUE ary)
+rb_ary_values_at(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
- VALUE result;
- long i;
-
- result = rb_ary_new2(RARRAY_LEN(ary));
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
- rb_ary_push(result, rb_ary_elt(ary, i));
- }
- }
- return result;
+ return rb_values_at(ary, RARRAY(ary)->len, argc, argv, rb_ary_entry);
}
/*
@@ -1750,10 +1939,20 @@ select_i(VALUE ary)
*/
static VALUE
-rb_ary_select(VALUE ary)
+rb_ary_select(ary)
+ VALUE ary;
{
+ VALUE result;
+ long i;
+
RETURN_ENUMERATOR(ary, 0, 0);
- ITERATE(select_i, ary);
+ result = rb_ary_new2(RARRAY(ary)->len);
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ if (RTEST(rb_yield(RARRAY(ary)->ptr[i]))) {
+ rb_ary_push(result, rb_ary_elt(ary, i));
+ }
+ }
+ return result;
}
/*
@@ -1774,12 +1973,14 @@ rb_ary_select(VALUE ary)
*/
VALUE
-rb_ary_delete(VALUE ary, VALUE item)
+rb_ary_delete(ary, item)
+ VALUE ary;
+ VALUE item;
{
long i1, i2;
- for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
- VALUE e = RARRAY_PTR(ary)[i1];
+ for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
+ VALUE e = RARRAY(ary)->ptr[i1];
if (rb_equal(e, item)) continue;
if (i1 != i2) {
@@ -1787,7 +1988,7 @@ rb_ary_delete(VALUE ary, VALUE item)
}
i2++;
}
- if (RARRAY_LEN(ary) == i2) {
+ if (RARRAY(ary)->len == i2) {
if (rb_block_given_p()) {
return rb_yield(item);
}
@@ -1795,12 +1996,12 @@ rb_ary_delete(VALUE ary, VALUE item)
}
rb_ary_modify(ary);
- ary_iter_check(ary);
- if (RARRAY_LEN(ary) > i2) {
+ if (RARRAY(ary)->len > i2) {
RARRAY(ary)->len = i2;
- if (i2 * 2 < ARY_CAPA(ary) &&
- ARY_CAPA(ary) > ARY_DEFAULT_SIZE) {
- RESIZE_CAPA(ary, i2*2);
+ if (i2 * 2 < RARRAY(ary)->aux.capa &&
+ RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2);
+ RARRAY(ary)->aux.capa = i2 * 2;
}
}
@@ -1808,9 +2009,11 @@ rb_ary_delete(VALUE ary, VALUE item)
}
VALUE
-rb_ary_delete_at(VALUE ary, long pos)
+rb_ary_delete_at(ary, pos)
+ VALUE ary;
+ long pos;
{
- long len = RARRAY_LEN(ary);
+ long i, len = RARRAY(ary)->len;
VALUE del;
if (pos >= len) return Qnil;
@@ -1820,11 +2023,11 @@ rb_ary_delete_at(VALUE ary, long pos)
}
rb_ary_modify(ary);
- ary_iter_check(ary);
- del = RARRAY_PTR(ary)[pos];
- MEMMOVE(RARRAY_PTR(ary)+pos, RARRAY_PTR(ary)+pos+1, VALUE,
- RARRAY_LEN(ary)-pos-1);
- RARRAY(ary)->len--;
+ del = RARRAY(ary)->ptr[pos];
+ for (i = pos + 1; i < len; i++, pos++) {
+ RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
+ }
+ RARRAY(ary)->len = pos;
return del;
}
@@ -1844,7 +2047,8 @@ rb_ary_delete_at(VALUE ary, long pos)
*/
static VALUE
-rb_ary_delete_at_m(VALUE ary, VALUE pos)
+rb_ary_delete_at_m(ary, pos)
+ VALUE ary, pos;
{
return rb_ary_delete_at(ary, NUM2LONG(pos));
}
@@ -1875,21 +2079,33 @@ rb_ary_delete_at_m(VALUE ary, VALUE pos)
*/
static VALUE
-rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
+rb_ary_slice_bang(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE arg1, arg2;
- long pos, len;
+ long pos, len, orig_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 = RARRAY_LEN(ary) + pos;
+ pos += orig_len;
if (pos < 0) return Qnil;
}
- arg2 = rb_ary_subseq(ary, pos, len);
- rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */
+ else if (orig_len < pos) return Qnil;
+ if (orig_len < pos + len) {
+ len = orig_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 */
return arg2;
}
@@ -1910,27 +2126,6 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
return rb_ary_delete_at(ary, NUM2LONG(arg1));
}
-static VALUE
-reject_bang_i(VALUE ary)
-{
- long i1, i2;
-
- rb_ary_modify(ary);
- for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
- VALUE v = RARRAY_PTR(ary)[i1];
- if (RTEST(rb_yield(v))) continue;
- if (i1 != i2) {
- rb_ary_store(ary, i2, v);
- }
- i2++;
- }
-
- if (RARRAY_LEN(ary) == i2) return Qnil;
- if (i2 < RARRAY_LEN(ary))
- RARRAY(ary)->len = i2;
- return ary;
-}
-
/*
* call-seq:
* array.reject! {|item| block } -> array or nil
@@ -1942,11 +2137,26 @@ reject_bang_i(VALUE ary)
*/
static VALUE
-rb_ary_reject_bang(VALUE ary)
+rb_ary_reject_bang(ary)
+ VALUE ary;
{
+ long i1, i2;
+
RETURN_ENUMERATOR(ary, 0, 0);
- ary_iter_check(ary);
- ITERATE(reject_bang_i, ary);
+ rb_ary_modify(ary);
+ for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
+ VALUE v = RARRAY(ary)->ptr[i1];
+ if (RTEST(rb_yield(v))) continue;
+ if (i1 != i2) {
+ rb_ary_store(ary, i2, v);
+ }
+ i2++;
+ }
+ if (RARRAY(ary)->len == i2) return Qnil;
+ if (i2 < RARRAY(ary)->len)
+ RARRAY(ary)->len = i2;
+
+ return ary;
}
/*
@@ -1958,7 +2168,8 @@ rb_ary_reject_bang(VALUE ary)
*/
static VALUE
-rb_ary_reject(VALUE ary)
+rb_ary_reject(ary)
+ VALUE ary;
{
RETURN_ENUMERATOR(ary, 0, 0);
ary = rb_ary_dup(ary);
@@ -1978,14 +2189,77 @@ rb_ary_reject(VALUE ary)
*/
static VALUE
-rb_ary_delete_if(VALUE ary)
+rb_ary_delete_if(ary)
+ VALUE ary;
{
+ RETURN_ENUMERATOR(ary, 0, 0);
rb_ary_reject_bang(ary);
return ary;
}
/*
* call-seq:
+ * array.zip(arg, ...) -> an_array
+ * array.zip(arg, ...) {| arr | block } -> nil
+ *
+ * Converts any arguments to arrays, then merges elements of
+ * <i>self</i> with corresponding elements from each argument. This
+ * generates a sequence of <code>self.size</code> <em>n</em>-element
+ * arrays, where <em>n</em> is one more that the count of arguments. If
+ * the size of any argument is less than <code>enumObj.size</code>,
+ * <code>nil</code> values are supplied. If a block given, it is
+ * invoked for each output array, otherwise an array of arrays is
+ * returned.
+ *
+ * a = [ 4, 5, 6 ]
+ * b = [ 7, 8, 9 ]
+ *
+ * [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
+ * [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]]
+ * a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]]
+ */
+
+static VALUE
+rb_ary_zip(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ int i, j;
+ long len;
+ VALUE result;
+
+ for (i=0; i<argc; i++) {
+ argv[i] = to_ary(argv[i]);
+ }
+ if (rb_block_given_p()) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ VALUE tmp = rb_ary_new2(argc+1);
+
+ rb_ary_push(tmp, rb_ary_elt(ary, i));
+ for (j=0; j<argc; j++) {
+ rb_ary_push(tmp, rb_ary_elt(argv[j], i));
+ }
+ rb_yield(tmp);
+ }
+ return Qnil;
+ }
+ len = RARRAY(ary)->len;
+ result = rb_ary_new2(len);
+ for (i=0; i<len; i++) {
+ VALUE tmp = rb_ary_new2(argc+1);
+
+ rb_ary_push(tmp, rb_ary_elt(ary, i));
+ for (j=0; j<argc; j++) {
+ rb_ary_push(tmp, rb_ary_elt(argv[j], i));
+ }
+ rb_ary_push(result, tmp);
+ }
+ return result;
+}
+
+/*
+ * call-seq:
* array.transpose -> an_array
*
* Assumes that <i>self</i> is an array of arrays and transposes the
@@ -1996,25 +2270,26 @@ rb_ary_delete_if(VALUE ary)
*/
static VALUE
-rb_ary_transpose(VALUE ary)
+rb_ary_transpose(ary)
+ VALUE ary;
{
long elen = -1, alen, i, j;
VALUE tmp, result = 0;
- alen = RARRAY_LEN(ary);
+ alen = RARRAY(ary)->len;
if (alen == 0) return rb_ary_dup(ary);
for (i=0; i<alen; i++) {
tmp = to_ary(rb_ary_elt(ary, i));
if (elen < 0) { /* first element */
- elen = RARRAY_LEN(tmp);
+ elen = RARRAY(tmp)->len;
result = rb_ary_new2(elen);
for (j=0; j<elen; j++) {
rb_ary_store(result, j, rb_ary_new2(alen));
}
}
- else if (elen != RARRAY_LEN(tmp)) {
- rb_raise(rb_eIndexError, "element size differs (%ld should be %ld)",
- RARRAY_LEN(tmp), elen);
+ else if (elen != RARRAY(tmp)->len) {
+ rb_raise(rb_eIndexError, "element size differs (%d should be %d)",
+ RARRAY(tmp)->len, elen);
}
for (j=0; j<elen; j++) {
rb_ary_store(rb_ary_elt(result, j), i, rb_ary_elt(tmp, j));
@@ -2035,21 +2310,18 @@ rb_ary_transpose(VALUE ary)
* a #=> ["x", "y", "z"]
*/
-VALUE
-rb_ary_replace(VALUE copy, VALUE orig)
+static VALUE
+rb_ary_replace(copy, orig)
+ VALUE copy, orig;
{
VALUE shared;
- VALUE *ptr;
+ rb_ary_modify(copy);
orig = to_ary(orig);
- rb_ary_modify_check(copy);
- ary_iter_check(copy);
if (copy == orig) return copy;
shared = ary_make_shared(orig);
- if (!ARY_SHARED_P(copy)) {
- ptr = RARRAY(copy)->ptr;
- xfree(ptr);
- }
+ if (RARRAY(copy)->ptr && !FL_TEST(copy, ELTS_SHARED))
+ free(RARRAY(copy)->ptr);
RARRAY(copy)->ptr = RARRAY(orig)->ptr;
RARRAY(copy)->len = RARRAY(orig)->len;
RARRAY(copy)->aux.shared = shared;
@@ -2069,13 +2341,14 @@ rb_ary_replace(VALUE copy, VALUE orig)
*/
VALUE
-rb_ary_clear(VALUE ary)
+rb_ary_clear(ary)
+ VALUE ary;
{
rb_ary_modify(ary);
- ary_iter_check(ary);
RARRAY(ary)->len = 0;
- if (ARY_DEFAULT_SIZE * 2 < ARY_CAPA(ary)) {
- RESIZE_CAPA(ary, ARY_DEFAULT_SIZE * 2);
+ if (ARY_DEFAULT_SIZE * 2 < RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, ARY_DEFAULT_SIZE * 2);
+ RARRAY(ary)->aux.capa = ARY_DEFAULT_SIZE * 2;
}
return ary;
}
@@ -2105,7 +2378,10 @@ rb_ary_clear(VALUE ary)
*/
static VALUE
-rb_ary_fill(int argc, VALUE *argv, VALUE ary)
+rb_ary_fill(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
VALUE item, arg1, arg2;
long beg = 0, end = 0, len = 0;
@@ -2123,34 +2399,36 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
switch (argc) {
case 1:
beg = 0;
- len = RARRAY_LEN(ary);
+ len = RARRAY(ary)->len;
break;
case 2:
- if (rb_range_beg_len(arg1, &beg, &len, RARRAY_LEN(ary), 1)) {
+ if (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 1)) {
break;
}
/* fall through */
case 3:
beg = NIL_P(arg1) ? 0 : NUM2LONG(arg1);
if (beg < 0) {
- beg = RARRAY_LEN(ary) + beg;
+ beg = RARRAY(ary)->len + beg;
if (beg < 0) beg = 0;
}
- len = NIL_P(arg2) ? RARRAY_LEN(ary) - beg : NUM2LONG(arg2);
- if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
+ len = NIL_P(arg2) ? RARRAY(ary)->len - beg : NUM2LONG(arg2);
break;
}
rb_ary_modify(ary);
- ary_iter_check(ary);
- end = beg + len;
- if (end < 0) {
+ if (len < 0) {
+ return ary;
+ }
+ if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) {
rb_raise(rb_eArgError, "argument too big");
}
- if (RARRAY_LEN(ary) < end) {
- if (end >= ARY_CAPA(ary)) {
- RESIZE_CAPA(ary, end);
+ end = beg + len;
+ if (end > RARRAY(ary)->len) {
+ if (end >= RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, end);
+ RARRAY(ary)->aux.capa = end;
}
- rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), end - RARRAY_LEN(ary));
+ rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len, end - RARRAY(ary)->len);
RARRAY(ary)->len = end;
}
@@ -2160,12 +2438,12 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
for (i=beg; i<end; i++) {
v = rb_yield(LONG2NUM(i));
- if (i>=RARRAY_LEN(ary)) break;
- RARRAY_PTR(ary)[i] = v;
+ if (i>=RARRAY(ary)->len) break;
+ RARRAY(ary)->ptr[i] = v;
}
}
else {
- p = RARRAY_PTR(ary) + beg;
+ p = RARRAY(ary)->ptr + beg;
pend = p + len;
while (p < pend) {
*p++ = item;
@@ -2185,16 +2463,17 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
*/
VALUE
-rb_ary_plus(VALUE x, VALUE y)
+rb_ary_plus(x, y)
+ VALUE x, y;
{
VALUE z;
long len;
y = to_ary(y);
- len = RARRAY_LEN(x) + RARRAY_LEN(y);
+ len = RARRAY(x)->len + RARRAY(y)->len;
z = rb_ary_new2(len);
- MEMCPY(RARRAY_PTR(z), RARRAY_PTR(x), VALUE, RARRAY_LEN(x));
- MEMCPY(RARRAY_PTR(z) + RARRAY_LEN(x), RARRAY_PTR(y), VALUE, RARRAY_LEN(y));
+ MEMCPY(RARRAY(z)->ptr, RARRAY(x)->ptr, VALUE, RARRAY(x)->len);
+ MEMCPY(RARRAY(z)->ptr + RARRAY(x)->len, RARRAY(y)->ptr, VALUE, RARRAY(y)->len);
RARRAY(z)->len = len;
return z;
}
@@ -2210,11 +2489,12 @@ rb_ary_plus(VALUE x, VALUE y)
VALUE
-rb_ary_concat(VALUE x, VALUE y)
+rb_ary_concat(x, y)
+ VALUE x, y;
{
y = to_ary(y);
- if (RARRAY_LEN(y) > 0) {
- rb_ary_splice(x, RARRAY_LEN(x), 0, y);
+ if (RARRAY(y)->len > 0) {
+ rb_ary_splice(x, RARRAY(x)->len, 0, y);
}
return x;
}
@@ -2236,7 +2516,8 @@ rb_ary_concat(VALUE x, VALUE y)
*/
static VALUE
-rb_ary_times(VALUE ary, VALUE times)
+rb_ary_times(ary, times)
+ VALUE ary, times;
{
VALUE ary2, tmp;
long i, len;
@@ -2251,16 +2532,16 @@ rb_ary_times(VALUE ary, VALUE times)
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
- if (LONG_MAX/len < RARRAY_LEN(ary)) {
+ if (ARY_MAX_SIZE/len < RARRAY(ary)->len) {
rb_raise(rb_eArgError, "argument too big");
}
- len *= RARRAY_LEN(ary);
+ len *= RARRAY(ary)->len;
ary2 = ary_new(rb_obj_class(ary), len);
RARRAY(ary2)->len = len;
- for (i=0; i<len; i+=RARRAY_LEN(ary)) {
- MEMCPY(RARRAY_PTR(ary2)+i, RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
+ for (i=0; i<len; i+=RARRAY(ary)->len) {
+ MEMCPY(RARRAY(ary2)->ptr+i, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
}
OBJ_INFECT(ary2, ary);
@@ -2288,15 +2569,16 @@ rb_ary_times(VALUE ary, VALUE times)
*/
VALUE
-rb_ary_assoc(VALUE ary, VALUE key)
+rb_ary_assoc(ary, key)
+ VALUE ary, key;
{
long i;
VALUE v;
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- v = rb_check_array_type(RARRAY_PTR(ary)[i]);
- if (!NIL_P(v) && RARRAY_LEN(v) > 0 &&
- rb_equal(RARRAY_PTR(v)[0], key))
+ 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 &&
+ rb_equal(RARRAY(v)->ptr[0], key))
return v;
}
return Qnil;
@@ -2304,10 +2586,10 @@ rb_ary_assoc(VALUE ary, VALUE key)
/*
* call-seq:
- * array.rassoc(obj) -> an_array or nil
+ * array.rassoc(key) -> an_array or nil
*
* Searches through the array whose elements are also arrays. Compares
- * _obj_ with the second element of each contained array using
+ * <em>key</em> with the second element of each contained array using
* <code>==</code>. Returns the first contained array that matches. See
* also <code>Array#assoc</code>.
*
@@ -2317,28 +2599,32 @@ rb_ary_assoc(VALUE ary, VALUE key)
*/
VALUE
-rb_ary_rassoc(VALUE ary, VALUE value)
+rb_ary_rassoc(ary, value)
+ VALUE ary, value;
{
long i;
VALUE v;
- for (i = 0; i < RARRAY_LEN(ary); ++i) {
- v = RARRAY_PTR(ary)[i];
+ for (i = 0; i < RARRAY(ary)->len; ++i) {
+ v = RARRAY(ary)->ptr[i];
if (TYPE(v) == T_ARRAY &&
- RARRAY_LEN(v) > 1 &&
- rb_equal(RARRAY_PTR(v)[1], value))
+ RARRAY(v)->len > 1 &&
+ rb_equal(RARRAY(v)->ptr[1], value))
return v;
}
return Qnil;
}
+static VALUE recursive_equal _((VALUE, VALUE, int));
static VALUE
-recursive_equal(VALUE ary1, VALUE ary2, int recur)
+recursive_equal(ary1, ary2, recur)
+ VALUE ary1, ary2;
+ int recur;
{
long i;
if (recur) return Qfalse;
- for (i=0; i<RARRAY_LEN(ary1); i++) {
+ for (i=0; i<RARRAY(ary1)->len; i++) {
if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
}
@@ -2360,7 +2646,8 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
*/
static VALUE
-rb_ary_equal(VALUE ary1, VALUE ary2)
+rb_ary_equal(ary1, ary2)
+ VALUE ary1, ary2;
{
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) {
@@ -2369,10 +2656,26 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
}
return rb_equal(ary2, ary1);
}
- if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
+ 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)))
+ return Qfalse;
+ }
+ return Qtrue;
+}
+
/*
* call-seq:
* array.eql?(other) -> true or false
@@ -2382,22 +2685,21 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
*/
static VALUE
-rb_ary_eql(VALUE ary1, VALUE ary2)
+rb_ary_eql(ary1, ary2)
+ VALUE ary1, ary2;
{
- long i;
-
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
- if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- for (i=0; i<RARRAY_LEN(ary1); i++) {
- if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
- return Qfalse;
- }
- return Qtrue;
+ 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(VALUE ary, VALUE dummy, int recur)
+recursive_hash(ary, dummy, recur)
+ VALUE ary;
+ VALUE dummy;
+ int recur;
{
long i, h;
VALUE n;
@@ -2405,10 +2707,11 @@ recursive_hash(VALUE ary, VALUE dummy, int recur)
if (recur) {
return LONG2FIX(0);
}
- h = RARRAY_LEN(ary);
- for (i=0; i<RARRAY_LEN(ary); i++) {
+
+ h = RARRAY(ary)->len;
+ for (i=0; i<RARRAY(ary)->len; i++) {
h = (h << 1) | (h<0 ? 1 : 0);
- n = rb_hash(RARRAY_PTR(ary)[i]);
+ n = rb_hash(RARRAY(ary)->ptr[i]);
h ^= NUM2LONG(n);
}
return LONG2FIX(h);
@@ -2423,7 +2726,8 @@ recursive_hash(VALUE ary, VALUE dummy, int recur)
*/
static VALUE
-rb_ary_hash(VALUE ary)
+rb_ary_hash(ary)
+ VALUE ary;
{
return rb_exec_recursive(recursive_hash, ary, 0);
}
@@ -2442,12 +2746,14 @@ rb_ary_hash(VALUE ary)
*/
VALUE
-rb_ary_includes(VALUE ary, VALUE item)
+rb_ary_includes(ary, item)
+ VALUE ary;
+ VALUE item;
{
long i;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- if (rb_equal(RARRAY_PTR(ary)[i], item)) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ if (rb_equal(RARRAY(ary)->ptr[i], item)) {
return Qtrue;
}
}
@@ -2455,6 +2761,29 @@ rb_ary_includes(VALUE ary, VALUE 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
@@ -2476,39 +2805,35 @@ rb_ary_includes(VALUE ary, VALUE item)
*/
VALUE
-rb_ary_cmp(VALUE ary1, VALUE ary2)
+rb_ary_cmp(ary1, ary2)
+ VALUE ary1, ary2;
{
- long i, len;
+ long len;
+ VALUE v;
ary2 = to_ary(ary2);
- len = RARRAY_LEN(ary1);
- if (len > RARRAY_LEN(ary2)) {
- len = RARRAY_LEN(ary2);
- }
- 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_LEN(ary1) - RARRAY_LEN(ary2);
+ if (ary1 == ary2) return INT2FIX(0);
+ v = rb_exec_recursive(recursive_cmp, ary1, ary2);
+ if (v != Qundef) return v;
+ len = RARRAY(ary1)->len - RARRAY(ary2)->len;
if (len == 0) return INT2FIX(0);
if (len > 0) return INT2FIX(1);
return INT2FIX(-1);
}
static VALUE
-ary_make_hash(VALUE ary1, VALUE ary2)
+ary_make_hash(ary1, ary2)
+ VALUE ary1, ary2;
{
VALUE hash = rb_hash_new();
long i;
- for (i=0; i<RARRAY_LEN(ary1); i++) {
- rb_hash_aset(hash, RARRAY_PTR(ary1)[i], Qtrue);
+ for (i=0; i<RARRAY(ary1)->len; i++) {
+ rb_hash_aset(hash, RARRAY(ary1)->ptr[i], Qtrue);
}
if (ary2) {
- for (i=0; i<RARRAY_LEN(ary2); i++) {
- rb_hash_aset(hash, RARRAY_PTR(ary2)[i], Qtrue);
+ for (i=0; i<RARRAY(ary2)->len; i++) {
+ rb_hash_aset(hash, RARRAY(ary2)->ptr[i], Qtrue);
}
}
return hash;
@@ -2527,7 +2852,8 @@ ary_make_hash(VALUE ary1, VALUE ary2)
*/
static VALUE
-rb_ary_diff(VALUE ary1, VALUE ary2)
+rb_ary_diff(ary1, ary2)
+ VALUE ary1, ary2;
{
VALUE ary3;
volatile VALUE hash;
@@ -2536,8 +2862,8 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
hash = ary_make_hash(to_ary(ary2), 0);
ary3 = rb_ary_new();
- for (i=0; i<RARRAY_LEN(ary1); i++) {
- if (st_lookup(RHASH_TBL(hash), RARRAY_PTR(ary1)[i], 0)) continue;
+ for (i=0; i<RARRAY(ary1)->len; i++) {
+ if (st_lookup(RHASH(hash)->tbl, RARRAY(ary1)->ptr[i], 0)) continue;
rb_ary_push(ary3, rb_ary_elt(ary1, i));
}
return ary3;
@@ -2555,22 +2881,20 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
static VALUE
-rb_ary_and(VALUE ary1, VALUE ary2)
+rb_ary_and(ary1, ary2)
+ VALUE ary1, ary2;
{
VALUE hash, ary3, v, vv;
long i;
ary2 = to_ary(ary2);
- ary3 = rb_ary_new2(RARRAY_LEN(ary1) < RARRAY_LEN(ary2) ?
- RARRAY_LEN(ary1) : RARRAY_LEN(ary2));
+ ary3 = rb_ary_new2(RARRAY(ary1)->len < RARRAY(ary2)->len ?
+ RARRAY(ary1)->len : RARRAY(ary2)->len);
hash = ary_make_hash(ary2, 0);
- if (RHASH_EMPTY_P(hash))
- return ary3;
-
- for (i=0; i<RARRAY_LEN(ary1); i++) {
+ for (i=0; i<RARRAY(ary1)->len; i++) {
v = vv = rb_ary_elt(ary1, i);
- if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -2590,25 +2914,26 @@ rb_ary_and(VALUE ary1, VALUE ary2)
*/
static VALUE
-rb_ary_or(VALUE ary1, VALUE ary2)
+rb_ary_or(ary1, ary2)
+ VALUE ary1, ary2;
{
VALUE hash, ary3;
VALUE v, vv;
long i;
ary2 = to_ary(ary2);
- ary3 = rb_ary_new2(RARRAY_LEN(ary1)+RARRAY_LEN(ary2));
+ ary3 = rb_ary_new2(RARRAY(ary1)->len+RARRAY(ary2)->len);
hash = ary_make_hash(ary1, ary2);
- for (i=0; i<RARRAY_LEN(ary1); i++) {
+ for (i=0; i<RARRAY(ary1)->len; i++) {
v = vv = rb_ary_elt(ary1, i);
- if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
- for (i=0; i<RARRAY_LEN(ary2); i++) {
+ for (i=0; i<RARRAY(ary2)->len; i++) {
v = vv = rb_ary_elt(ary2, i);
- if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -2630,20 +2955,20 @@ rb_ary_or(VALUE ary1, VALUE ary2)
*/
static VALUE
-rb_ary_uniq_bang(VALUE ary)
+rb_ary_uniq_bang(ary)
+ VALUE ary;
{
VALUE hash, v, vv;
long i, j;
- ary_iter_check(ary);
hash = ary_make_hash(ary, 0);
- if (RARRAY_LEN(ary) == RHASH_SIZE(hash)) {
+ if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) {
return Qnil;
}
- for (i=j=0; i<RARRAY_LEN(ary); i++) {
+ for (i=j=0; i<RARRAY(ary)->len; i++) {
v = vv = rb_ary_elt(ary, i);
- if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) {
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_store(ary, j++, v);
}
}
@@ -2663,7 +2988,8 @@ rb_ary_uniq_bang(VALUE ary)
*/
static VALUE
-rb_ary_uniq(VALUE ary)
+rb_ary_uniq(ary)
+ VALUE ary;
{
ary = rb_ary_dup(ary);
rb_ary_uniq_bang(ary);
@@ -2682,26 +3008,24 @@ rb_ary_uniq(VALUE ary)
*/
static VALUE
-rb_ary_compact_bang(VALUE ary)
+rb_ary_compact_bang(ary)
+ VALUE ary;
{
VALUE *p, *t, *end;
- long n;
rb_ary_modify(ary);
- ary_iter_check(ary);
- p = t = RARRAY_PTR(ary);
- end = p + RARRAY_LEN(ary);
+ p = t = RARRAY(ary)->ptr;
+ end = p + RARRAY(ary)->len;
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
- if (RARRAY_LEN(ary) == (p - RARRAY_PTR(ary))) {
+ if (RARRAY(ary)->len == (p - RARRAY(ary)->ptr)) {
return Qnil;
}
- n = p - RARRAY_PTR(ary);
- RESIZE_CAPA(ary, n);
- RARRAY(ary)->len = n;
+ RARRAY(ary)->len = RARRAY(ary)->aux.capa = (p - RARRAY(ary)->ptr);
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
return ary;
}
@@ -2717,7 +3041,8 @@ rb_ary_compact_bang(VALUE ary)
*/
static VALUE
-rb_ary_compact(VALUE ary)
+rb_ary_compact(ary)
+ VALUE ary;
{
ary = rb_ary_dup(ary);
rb_ary_compact_bang(ary);
@@ -2727,68 +3052,109 @@ rb_ary_compact(VALUE ary)
/*
* call-seq:
* array.nitems -> int
- * array.nitems { |item| block } -> int
*
* Returns the number of non-<code>nil</code> elements in _self_.
- * If a block is given, the elements yielding a true value are
- * counted.
*
* May be zero.
*
* [ 1, nil, 3, nil, 5 ].nitems #=> 3
- * [5,6,7,8,9].nitems { |x| x % 2 != 0 } #=> 3
*/
static VALUE
-rb_ary_nitems(VALUE ary)
+rb_ary_nitems(ary)
+ VALUE ary;
{
long n = 0;
-
- if (rb_block_given_p()) {
- long i;
+ VALUE *p, *pend;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- VALUE v = RARRAY_PTR(ary)[i];
- if (RTEST(rb_yield(v))) n++;
- }
+ for (p = RARRAY(ary)->ptr, pend = p + RARRAY(ary)->len; p < pend; p++) {
+ if (!NIL_P(*p)) n++;
+ }
+ 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;
+ VALUE ary;
+{
+ 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 *p = RARRAY_PTR(ary);
- VALUE *pend = p + RARRAY_LEN(ary);
+ VALUE obj, *p, *pend;
- while (p < pend) {
- if (!NIL_P(*p)) n++;
- p++;
- }
+ 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++;
+ }
}
+
return LONG2NUM(n);
}
static VALUE
-flatten(VALUE ary, int level, int *modified)
+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 = rb_ary_new();
- result = rb_ary_new();
+ 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_LEN(ary)) {
- elt = RARRAY_PTR(ary)[i++];
+ while (i < RARRAY(ary)->len) {
+ elt = RARRAY(ary)->ptr[i++];
tmp = rb_check_array_type(elt);
- if (NIL_P(tmp) || (level >= 0 && RARRAY_LEN(stack) / 2 >= level)) {
+ 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);
@@ -2798,7 +3164,7 @@ flatten(VALUE ary, int level, int *modified)
i = 0;
}
}
- if (RARRAY_LEN(stack) == 0) {
+ if (RARRAY(stack)->len == 0) {
break;
}
id = (st_data_t)ary;
@@ -2808,6 +3174,9 @@ flatten(VALUE ary, int level, int *modified)
ary = rb_ary_pop(stack);
}
+ st_free_table(memo);
+
+ RBASIC(result)->klass = rb_class_of(ary);
return result;
}
@@ -2819,7 +3188,7 @@ flatten(VALUE ary, int level, int *modified)
* 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 determins the level of recursion to flatten.
+ * argument determines the level of recursion to flatten.
*
* a = [ 1, 2, [3, [4, 5] ] ]
* a.flatten! #=> [1, 2, 3, 4, 5]
@@ -2830,7 +3199,10 @@ flatten(VALUE ary, int level, int *modified)
*/
static VALUE
-rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
+rb_ary_flatten_bang(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
int mod = 0, level = -1;
VALUE result, lv;
@@ -2854,18 +3226,21 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
* 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 determins the level of recursion to flatten.
+ * <i>level</i> argument determines the level of recursion to flatten.
*
* 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.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]]
*/
static VALUE
-rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
+rb_ary_flatten(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
int mod = 0, level = -1;
VALUE result, lv;
@@ -2889,17 +3264,17 @@ rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
static VALUE
-rb_ary_shuffle_bang(VALUE ary)
+rb_ary_shuffle_bang(ary)
+ VALUE ary;
{
- long i = RARRAY_LEN(ary);
+ long i = RARRAY(ary)->len;
rb_ary_modify(ary);
- ary_iter_check(ary);
while (i) {
long j = rb_genrand_real()*i;
- VALUE tmp = RARRAY_PTR(ary)[--i];
- RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j];
- RARRAY_PTR(ary)[j] = tmp;
+ VALUE tmp = RARRAY(ary)->ptr[--i];
+ RARRAY(ary)->ptr[i] = RARRAY(ary)->ptr[j];
+ RARRAY(ary)->ptr[j] = tmp;
}
return ary;
}
@@ -2933,50 +3308,63 @@ rb_ary_shuffle(VALUE ary)
static VALUE
-rb_ary_choice(VALUE ary)
+rb_ary_choice(ary)
+ VALUE ary;
{
long i, j;
- i = RARRAY_LEN(ary);
+ i = RARRAY(ary)->len;
if (i == 0) return Qnil;
j = rb_genrand_real()*i;
- return RARRAY_PTR(ary)[j];
+ return RARRAY(ary)->ptr[j];
}
/*
* call-seq:
* ary.cycle {|obj| block }
+ * ary.cycle(n) {|obj| block }
*
- * Calls <i>block</i> repeatedly forever.
+ * 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(VALUE ary)
+rb_ary_cycle(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
{
- long i;
+ long n, i;
+ VALUE nv = Qnil;
- RETURN_ENUMERATOR(ary, 0, 0);
- while (RARRAY_LEN(ary) > 0) {
- for (i=0; i<RARRAY_LEN(ary); i++) {
- rb_yield(RARRAY_PTR(ary)[i]);
- }
+ 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;
}
-static VALUE
-tmpbuf(int n, int size)
-{
- VALUE buf = rb_str_new(0, n*size);
-
- RBASIC(buf)->klass = 0;
- return buf;
-}
+#define tmpbuf(n, size) rb_str_tmp_new((n)*(size))
/*
* Recursively compute permutations of r elements of the set [0..n-1].
@@ -2991,7 +3379,10 @@ tmpbuf(int n, int size)
* values: the Ruby array that holds the actual values to permute
*/
static void
-permute0(long n, long r, long *p, long index, int *used, VALUE values)
+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++) {
@@ -3008,8 +3399,8 @@ permute0(long n, long r, long *p, long index, int *used, VALUE values)
/* 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_PTR(result);
- const VALUE *values_array = RARRAY_PTR(values);
+ 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;
@@ -3035,23 +3426,27 @@ permute0(long n, long r, long *p, long index, int *used, VALUE values)
* 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
+ * 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(int argc, VALUE *argv, VALUE ary)
+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 */
- n = RARRAY_LEN(ary); /* Array length */
rb_scan_args(argc, argv, "01", &num);
r = NIL_P(num) ? n : NUM2LONG(num); /* Permutation size from argument */
@@ -3062,15 +3457,15 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
rb_yield(rb_ary_new2(0));
}
else if (r == 1) { /* this is a special, easy case */
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i]));
+ 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_PTR(t0);
+ long *p = (long*)RSTRING(t0)->ptr;
volatile VALUE t1 = tmpbuf(n,sizeof(int));
- int *used = (int*)RSTRING_PTR(t1);
+ 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 */
@@ -3083,7 +3478,8 @@ rb_ary_permutation(int argc, VALUE *argv, VALUE ary)
}
static long
-combi_len(long n, long k)
+combi_len(n, k)
+ long n, k;
{
long i, val = 1;
@@ -3092,7 +3488,11 @@ combi_len(long n, long k)
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;
@@ -3111,24 +3511,27 @@ combi_len(long n, long k)
* 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
+ * 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(VALUE ary, VALUE num)
+rb_ary_combination(ary, num)
+ VALUE ary;
+ VALUE num;
{
long n, i, len;
- RETURN_ENUMERATOR(ary, 1, &num);
n = NUM2LONG(num);
- len = RARRAY_LEN(ary);
+ RETURN_ENUMERATOR(ary, 1, &num);
+ len = RARRAY(ary)->len;
if (n < 0 || len < n) {
/* yield nothing */
}
@@ -3137,24 +3540,24 @@ rb_ary_combination(VALUE ary, VALUE num)
}
else if (n == 1) {
for (i = 0; i < len; i++) {
- rb_yield(rb_ary_new3(1, RARRAY_PTR(ary)[i]));
+ rb_yield(rb_ary_new3(1, RARRAY(ary)->ptr[i]));
}
}
else {
volatile VALUE t0 = tmpbuf(n+1, sizeof(long));
- long *stack = (long*)RSTRING_PTR(t0);
+ long *stack = (long*)RSTRING(t0)->ptr;
long nlen = combi_len(len, n);
volatile VALUE cc = rb_ary_new2(n);
- VALUE *chosen = RARRAY_PTR(cc);
+ 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_PTR(ary)[stack[lev+1]];
+ chosen[lev] = RARRAY(ary)->ptr[stack[lev+1]];
for (lev++; lev < n; lev++) {
- chosen[lev] = RARRAY_PTR(ary)[stack[lev+1] = stack[lev]+1];
+ chosen[lev] = RARRAY(ary)->ptr[stack[lev+1] = stack[lev]+1];
}
rb_yield(rb_ary_new4(n, chosen));
do {
@@ -3182,13 +3585,16 @@ rb_ary_combination(VALUE ary, VALUE num)
*/
static VALUE
-rb_ary_product(int argc, VALUE *argv, VALUE ary)
+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_PTR(t0); /* The arrays we're computing the product of */
- int *counters = (int*)RSTRING_PTR(t1); /* The current position in each one */
+ 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;
@@ -3205,8 +3611,12 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
/* Compute the length of the result array; return [] if any is empty */
for (i = 0; i < n; i++) {
- resultlen *= RARRAY_LEN(arrays[i]);
- if (resultlen == 0) return rb_ary_new2(0);
+ 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 */
@@ -3228,7 +3638,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
*/
m = n-1;
counters[m]++;
- while (m > 0 && counters[m] == RARRAY_LEN(arrays[m])) {
+ while (m > 0 && counters[m] == RARRAY(arrays[m])->len) {
counters[m] = 0;
m--;
counters[m]++;
@@ -3238,6 +3648,109 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
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.
@@ -3248,18 +3761,17 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)
*/
void
-Init_Array(void)
+Init_Array()
{
rb_cArray = rb_define_class("Array", rb_cObject);
rb_include_module(rb_cArray, rb_mEnumerable);
rb_define_alloc_func(rb_cArray, ary_alloc);
rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1);
- rb_define_singleton_method(rb_cArray, "try_convert", rb_ary_s_try_convert, 1);
rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1);
rb_define_method(rb_cArray, "initialize_copy", rb_ary_replace, 1);
- rb_define_method(rb_cArray, "to_s", rb_ary_inspect, 0);
+ rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0);
rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0);
rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0);
rb_define_method(rb_cArray, "to_ary", rb_ary_to_ary_m, 0);
@@ -3288,8 +3800,11 @@ Init_Array(void)
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, "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);
rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0);
rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0);
@@ -3306,6 +3821,7 @@ Init_Array(void)
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
rb_define_method(rb_cArray, "reject", rb_ary_reject, 0);
rb_define_method(rb_cArray, "reject!", rb_ary_reject_bang, 0);
+ rb_define_method(rb_cArray, "zip", rb_ary_zip, -1);
rb_define_method(rb_cArray, "transpose", rb_ary_transpose, 0);
rb_define_method(rb_cArray, "replace", rb_ary_replace, 1);
rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
@@ -3333,13 +3849,20 @@ Init_Array(void)
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, "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, 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 ca9f0adc00..713b5c69df 100644
--- a/bcc32/Makefile.sub
+++ b/bcc32/Makefile.sub
@@ -3,10 +3,6 @@
SHELL = $(COMSPEC)
MKFILES = Makefile
-!ifndef MFLAGS
-MFLAGS=-
-!endif
-
#### Start of system configuration section. ####
!ifndef OS
OS = bccwin32
@@ -15,8 +11,6 @@ OS = bccwin32
!error RT not defined. Retry from configure pass.
!endif
-arch = $(ARCH)-$(OS)
-
## variables may be overridden by $(compile_dir)/Makefile
!ifndef srcdir
srcdir = ..
@@ -33,7 +27,7 @@ RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw)
RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w
!endif
!ifndef RUBY_SO_NAME
-RUBY_SO_NAME = $(RT)-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)$(TEENY)
+RUBY_SO_NAME = $(RT)-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)
!endif
!ifndef icondirs
!ifdef ICONDIRS
@@ -46,6 +40,7 @@ iconinc=-I$(icondirs: = -I)
!endif
###############
+VPATH = $(srcdir):$(srcdir)/missing
.SUFFIXES: .y
!ifndef CC
@@ -58,21 +53,15 @@ CPP = cpp32
RC = brcc32
!endif
!ifndef YACC
-YACC = bison
-YFLAGS = -o y.tab.c
+YACC = byacc
!endif
!ifndef AR
AR = tlib
!endif
-!ifndef BASERUBY
-BASERUBY = ruby
-!endif
PURIFY =
AUTOCONF = autoconf
RM = $(srcdir:/=\)\win32\rm.bat
-CP = copy > nul
-MV = ren > nul
!if !defined(PROCESSOR_ARCHITECTURE)
PROCESSOR_ARCHITECTURE = x86
@@ -109,7 +98,7 @@ exec_prefix = $(prefix)
libdir = $(exec_prefix)/lib
!endif
!if !defined(datadir)
-datadir = $(prefix)/share
+datadir = /share
!endif
!ifndef EXTOUT
EXTOUT = .ext
@@ -124,24 +113,13 @@ TESTUI = console
TESTS =
!endif
!ifndef RDOCTARGET
-RDOCTARGET = install-doc
+RDOCTARGET = install-nodoc
!endif
OUTFLAG = -o
-COUTFLAG = -o
!ifndef CFLAGS
CFLAGS = -q -tWR -tWC $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) -w- -wsus -wcpt -wdup -wext -wrng -wrpt -wzdi
!endif
-!ifndef DEFS
-DEFS =
-!endif
-!ifndef CPPFLAGS
-CPPFLAGS =
-!endif
-CPPFLAGS = $(DEFS) $(CPPFLAGS)
-!ifndef CXXFLAGS
-CXXFLAGS = $(CFLAGS)
-!endif
!ifndef LDFLAGS
LDFLAGS = -S:$(STACK)
!endif
@@ -155,13 +133,13 @@ EXTLIBS =
MEMLIB =
!endif
LIBS = $(MEMLIB) cw32i.lib import32.lib ws2_32.lib $(EXTLIBS)
-MISSING = acosh.obj crypt.obj erf.obj strlcat.obj strlcpy.obj win32.obj
+MISSING = acosh.obj crypt.obj erf.obj win32.obj
!ifndef STACK
STACK = 0x2000000
!endif
-XCFLAGS = -DRUBY_EXPORT -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/missing
+XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)/missing
ARFLAGS = /a /p32
LD = ilink32 -q -Gn
@@ -179,8 +157,8 @@ EXEEXT = .exe
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT)
RUBYDEF = $(RUBY_SO_NAME).def
-MINIRUBY = .\miniruby$(EXEEXT) $(MINIRUBYOPT)
-RUNRUBY = .\ruby$(EXEEXT) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
+MINIRUBY = .\miniruby$(EXEEXT) -I$(srcdir)/lib $(MINIRUBYOPT)
+RUNRUBY = .\$(PROGRAM) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
ORGLIBPATH = $(LIB)
@@ -190,39 +168,32 @@ LIBRUBY_A = $(RUBY_SO_NAME)-static.lib
LIBRUBY_SO = $(RUBY_SO_NAME).dll
LIBRUBY = $(RUBY_SO_NAME).lib
LIBRUBYARG = $(LIBRUBY)
-THREAD_MODEL = win32
PREP = miniruby$(EXEEXT)
OBJEXT = obj
-ASMEXT = asm
INSTALLED_LIST= .installed.list
WINMAINOBJ = winmain.$(OBJEXT)
-MINIOBJS = dmydln.$(OBJEXT) miniprelude.$(OBJEXT)
-
-arch_hdrdir = $(EXTOUT)/include/$(arch)
-hdrdir = $(srcdir)/include
-VPATH = $(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)/enc;$(srcdir)/missing;$(srcdir)/win32
+MINIOBJS = dmydln.$(OBJEXT)
-.path.c = .;$(srcdir);$(srcdir)/enc;$(srcdir)/win32;$(srcdir)/missing
-.path.ci = $(srcdir)
-.path.inc = .;$(srcdir)
-.path.def = .;$(srcdir)
-.path.h = .;$(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)/win32;$(srcdir)/missing
+.path.c = .;$(srcdir);$(srcdir)/win32;$(srcdir)/missing
+.path.h = .;$(srcdir);$(srcdir)/win32;$(srcdir)/missing
.path.y = $(srcdir)
.path. = $(srcdir)
.c.obj:
- $(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) $(COUTFLAG)$@ -c $(<:/=\)
-
-.c.asm:
- $(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) $(COUTFLAG)$@ -S $(<:\=/)
+ $(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -c $(<:/=\)
.rc.res:
$(RC) $(RFLAGS) -I. -I$(<D). $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:/=\)
+.y.c:
+ $(YACC) $(YFLAGS) $(<:\=/)
+ sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $(@F)
+ @del y.tab.c
+
all: $(srcdir)/bcc32/Makefile.sub $(srcdir)/common.mk
ruby: $(PROGRAM)
@@ -238,7 +209,6 @@ PHONY: nul
@exit
|
-RUBY_CONFIG_H = $(arch_hdrdir)/ruby/config.h
CONFIG_H = ./.config.h.time
config: config.status
@@ -246,22 +216,19 @@ config: config.status
config.status: $(CONFIG_H)
$(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
- @if not exist $(arch_hdrdir:/=\) md $(arch_hdrdir:/=\)
- @if not exist $(arch_hdrdir:/=\)\ruby md $(arch_hdrdir:/=\)\ruby
- @$(srcdir:/=\)\win32\ifchange.bat $(RUBY_CONFIG_H:/=\) &&|
+ @$(srcdir:/=\)\win32\ifchange.bat config.h &&|
\#define HAVE_SYS_TYPES_H 1
\#define HAVE_SYS_STAT_H 1
\#define HAVE_STDLIB_H 1
\#define HAVE_STRING_H 1
\#define HAVE_MEMORY_H 1
-\#define HAVE_LONG_LONG 1
\#define HAVE_OFF_T 1
\#define SIZEOF_INT 4
\#define SIZEOF_SHORT 2
\#define SIZEOF_LONG 4
\#define SIZEOF_LONG_LONG 0
\#define SIZEOF___INT64 8
-\#define SIZEOF_OFF_T 8
+\#define SIZEOF_OFF_T 4
\#define SIZEOF_VOIDP 4
\#define SIZEOF_FLOAT 4
\#define SIZEOF_DOUBLE 8
@@ -296,7 +263,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
\#define HAVE_STRTOD 1
\#define HAVE_STRTOL 1
\#define HAVE_STRTOUL 1
-\#define HAVE_SNPRINTF 1
\#define HAVE_VSNPRINTF 1
\#define HAVE_ISNAN 1
\#define HAVE_FINITE 1
@@ -305,9 +271,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/bcc32/Makefile.sub
\#define HAVE_WAITPID 1
\#define HAVE_FSYNC 1
\#define HAVE_GETCWD 1
-\#define HAVE_TRUNCATE 1
-\#define HAVE_FSEEKO 1
-\#define HAVE_FTELLO 1
+\#define HAVE_CHSIZE 1
\#define HAVE_TIMES 1
\#define HAVE_FCNTL 1
\#define HAVE_LINK 1
@@ -319,22 +283,25 @@ $(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
\#define DEFAULT_KCODE KCODE_NONE
\#define DLEXT ".so"
-\#define RUBY_LIB "/lib/ruby/$(MAJOR).$(MINOR).$(TEENY)"
+\#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).$(TEENY)"
+\#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).$(TEENY)"
+\#define RUBY_VENDOR_LIB2 "/lib/ruby/vendor_ruby/$(MAJOR).$(MINOR)"
\#define RUBY_PLATFORM "$(ARCH)-$(OS)"
-\#define RUBY_ARCHLIB "/lib/ruby/$(MAJOR).$(MINOR).$(TEENY)/$(ARCH)-$(OS)"
-\#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/$(MAJOR).$(MINOR).$(TEENY)/$(ARCH)-$(OS)"
-\#define RUBY_VENDOR_ARCHLIB "/lib/ruby/vendor_ruby/$(MAJOR).$(MINOR).$(TEENY)/$(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 > $(@:/=\)
+ @exit > $@
config.status: $(MKFILES) $(srcdir)/bcc32/Makefile.sub $(srcdir)/common.mk
@echo Creating $@
@@ -344,14 +311,13 @@ s,@SHELL@,$$(COMSPEC),;t t
s,@BUILD_FILE_SEPARATOR@,\,;t t
s,@PATH_SEPARATOR@,;,;t t
s,@CFLAGS@,$(CFLAGS),;t t
-s,@DEFS@,$(DEFS),;t t
s,@CPPFLAGS@,$(CPPFLAGS),;t t
s,@CXXFLAGS@,$(CXXFLAGS),;t t
s,@FFLAGS@,$(FFLAGS),;t t
s,@LDFLAGS@,,;t t
s,@LIBS@,$(LIBS),;t t
s,@exec_prefix@,$${prefix},;t t
-s,@prefix@,$(prefix),;t t
+s,@prefix@,,;t t
s,@program_transform_name@,s,,,,;t t
s,@bindir@,$${exec_prefix}/bin,;t t
s,@sbindir@,$${exec_prefix}/sbin,;t t
@@ -382,17 +348,14 @@ s,@target_vendor@,pc,;t t
s,@target_os@,$(OS),;t t
s,@CC@,$(CC),;t t
s,@CPP@,cpp32,;t t
-s,@CXX@,$$(CC),;t t
-s,@LD@,$(LD),;t t
s,@YACC@,$(YACC),;t t
s,@RANLIB@,,;t t
s,@AR@,$(AR),;t t
s,@ARFLAGS@,$(ARFLAGS) ,;t t
s,@LN_S@,$(LN_S),;t t
s,@SET_MAKE@,MFLAGS = -$$(MAKEFLAGS),;t t
-s,@RM@,$$(top_srcdir:/=\)\win32\rm.bat,;t t
s,@CP@,copy > nul,;t t
-s,@LIBOBJS@, acosh.obj crypt.obj erf.obj strlcat.obj strlcpy.obj win32.obj,;t t
+s,@LIBOBJS@, acosh.obj crypt.obj erf.obj win32.obj,;t t
s,@ALLOCA@,$(ALLOCA),;t t
s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t
s,@EXEEXT@,.exe,;t t
@@ -432,14 +395,13 @@ s,@SOLIBS@,$(SOLIBS),;t t
s,@DLDLIBS@,$(DLDLIBS),;t t
s,@ENABLE_SHARED@,yes,;t t
s,@OUTFLAG@,$(OUTFLAG),;t t
-s,@COUTFLAG@,$(COUTFLAG),;t t
s,@CPPOUTFILE@,,;t t
s,@LIBPATHFLAG@, -L"%s",;t t
s,@RPATHFLAG@,,;t t
s,@LIBARG@,%s.lib,;t t
-s,@LINK_SO@,$$(LDSHARED) $$(DLDFLAGS) $$(LIBPATH) $$(OBJS:/=\), $$(@:/=\), nul, $$(LIBS) $$(LOCAL_LIBS), $$(DEFFILE:/=\), $$(RESFILE:/=\),;t t
-s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) $(COUTFLAG)$$(@) -c $$(<:/=\),;t t
-s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -P $(COUTFLAG)$$(@) -c $$(<:/=\),;t t
+s,@LINK_SO@,$$(LDSHARED) $$(DLDFLAGS) $$(LIBPATH) $$(OBJS), $$(@:/=\), nul, $$(LIBS) $$(LOCAL_LIBS), $$(DEFFILE), $$(RESFILE),;t t
+s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c $$(<:/=\),;t t
+s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -P -c $$(<:/=\),;t t
s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t
s,@RULE_SUBST@,{.;$$(VPATH)}%s,;t t
s,@COMMON_LIBS@,m advapi32 avicap32 avifil32 cap comctl32 comdlg32 dlcapi gdi32 glu32 imagehlp imm32 inetmib1 kernel32 loadperf lsapi32 lz32 mapi32 mgmtapi mpr msacm32 msvfw32 nddeapi netapi32 ole32 oleaut32 oledlg olepro32 opengl32 pdh pkpd32 rasapi32 rasdlg rassapi rpcrt4 setupapi shell32 shfolder snmpapi sporder tapi32 url user32 vdmdbg version win32spl winmm wintrust wsock32,;t t
@@ -451,9 +413,6 @@ 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,@rubyhdrdir@,$$(includedir)/ruby-$$(MAJOR).$$(MINOR).$$(TEENY),;t t
-s,@sitehdrdir@,$$(rubyhdrdir)/site_ruby,;t t
-s,@vendorhdrdir@,$$(rubyhdrdir)/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
@@ -462,7 +421,7 @@ s,@top_srcdir@,$(srcdir),;t t
miniruby$(EXEEXT):
@echo $(LIBS)
- $(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS:/=\) $(DMYEXT),$@,nul,$(LIBS)
+ $(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(MINIOBJS),$@,nul,$(LIBRUBY_A) $(LIBS)
$(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME).res
$(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ),$@,nul,$(LIBRUBYARG) $(LIBS),,$(RUBY_INSTALL_NAME).res
@@ -494,9 +453,6 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb
-so_name=$(RUBY_SO_NAME) \
. $(icondirs) $(srcdir)/win32
-lex.c: {$(srcdir)}lex.c.blt
- copy "$(?:/=\)" $@
-
post-install-bin::
@$(NULLCMD)
post-install-lib::
@@ -511,19 +467,50 @@ post-install-doc::
@$(NULLCMD)
clean-local::
- @$(RM) ext\extinit.c ext\extinit.$(OBJEXT) *.tds *.il? $(RUBY_SO_NAME).lib
+ @$(RM) $(WINMAINOBJ) 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) $(COUTFLAG)$@ -c ext/extinit.c
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -o$@ -c ext/extinit.c
main.$(OBJEXT): win32.h
-ascii.$(OBJEXT): win32.h
array.$(OBJEXT): win32.h
bignum.$(OBJEXT): win32.h
class.$(OBJEXT): win32.h
@@ -532,7 +519,6 @@ dir.$(OBJEXT): dir.h win32.h
dln.$(OBJEXT): win32.h
enum.$(OBJEXT): win32.h
error.$(OBJEXT): win32.h
-euc_jp.$(OBJEXT): win32.h
eval.$(OBJEXT): win32.h
file.$(OBJEXT): win32.h
gc.$(OBJEXT): win32.h
@@ -550,21 +536,14 @@ prec.$(OBJEXT): win32.h
random.$(OBJEXT): win32.h
range.$(OBJEXT): win32.h
re.$(OBJEXT): win32.h
-regcomp.$(OBJEXT): win32.h
-regenc.$(OBJEXT): win32.h
-regerror.$(OBJEXT): win32.h
-regexec.$(OBJEXT): win32.h
-reggnu.$(OBJEXT): win32.h
-regparse.$(OBJEXT): win32.h
+regex.$(OBJEXT): win32.h
ruby.$(OBJEXT): win32.h
signal.$(OBJEXT): win32.h
-sjis.$(OBJEXT): win32.h
sprintf.$(OBJEXT): win32.h
st.$(OBJEXT): win32.h
string.$(OBJEXT): win32.h
struct.$(OBJEXT): win32.h
time.$(OBJEXT): win32.h
-utf8.$(OBJEXT): win32.h
util.$(OBJEXT): win32.h
variable.$(OBJEXT): win32.h
version.$(OBJEXT): win32.h
diff --git a/bcc32/README.bcc32 b/bcc32/README.bcc32
index fb19906c75..c27a1261f1 100644
--- a/bcc32/README.bcc32
+++ b/bcc32/README.bcc32
@@ -16,7 +16,7 @@
* ilink32
(3) If you want to build from CVS source, following commands are required.
- * bison ((<URL:http://gnuwin32.sourceforge.net/packages/bison.htm>))
+ * byacc ((<URL:http://gnuwin32.sourceforge.net/packages/byacc.htm>))
* sed ((<URL:http://gnuwin32.sourceforge.net/packages/sed.htm>))
(4) We strongly recommend to build ruby on C++Builder, to link following files.
@@ -30,12 +30,7 @@
== How to compile and install
(1) Execute bcc32\configure.bat on your build directory.
- ex. c:\src\ruby> bcc32\configure.bat
- You can specify the target platform as an argument.
- For example, run `((%configure i686-bccwin32%))'
- You can also specify the install directory.
- For example, run `((%configure --prefix=<install_directory>%))'
- Default of the install directory is /usr .
+ ex. c:\ruby-1.6.7>bcc32\configure.bat
(2) Change ((|RUBY_INSTALL_NAME|)) and ((|RUBY_SO_NAME|)) in (({Makefile}))
if you want to change the name of the executable files.
@@ -46,7 +41,7 @@
(4) Run `((%make test%))'
-(5) Run `((%make install%))'
+(5) Run `((%make DESTDIR=<install_directory> install%))'
This command will create following directories and install files onto them.
* <install_directory>\bin
@@ -59,7 +54,7 @@
* <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>\<PLATFORM>
* <install_directory>\man\man1
If Ruby's version is `x.y.z', the ((|<MAJOR>|)) is `x' and the ((|<MINOR>|)) is `y'.
- The default ((|<PLATFORM>|)) is `(({i386-bccwin32}))'.
+ The ((|<PLATFORM>|)) is usually `(({i586-bccwin32}))'.
(6) Requires dynamic RTL (cc3250.dll on C++Builder5) and borlndmm.dll (If built with
usebormm.lib) to use installed binary. These files are ordinary in bcc32's bin
@@ -95,10 +90,10 @@ in Japanese, but you can download at least.
C:
cd \ruby
- bcc32\configure --prefix=/usr/local
+ bcc32\configure
make
make test
- make install
+ make DESTDIR=/usr/local install
* Build on the relative directory from the ruby source directory and CPU type
i386.
@@ -113,10 +108,10 @@ in Japanese, but you can download at least.
cd \ruby
mkdir bccwin32
cd bccwin32
- ..\bcc32\configure --prefix=/usr/local
+ ..\bcc32\configure target i386-bccwin32
make
make test
- make install
+ make DESTDIR=/usr/local install
* Build on the different drive.
@@ -127,10 +122,10 @@ in Japanese, but you can download at least.
D:
cd D:\build\ruby
- C:\src\ruby\bcc32\configure --prefix=C:/usr/local
+ C:\src\ruby\bcc32\configure
make
make test
- make install
+ make DESTDIR=C:/usr/local install
== Bugs
diff --git a/bcc32/configure.bat b/bcc32/configure.bat
index 8cdfc64b03..95575cbc60 100755
--- a/bcc32/configure.bat
+++ b/bcc32/configure.bat
@@ -30,8 +30,6 @@ 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" == "--with-baseruby" goto :baseruby
-if "%1" == "BASERUBY" goto :baseruby
if "%1" == "--path" goto :path
if "%1" == "-h" goto :help
if "%1" == "--help" goto :help
@@ -109,14 +107,6 @@ goto :loop
shift
shift
goto :loop
-:baseruby
- echo>>confargs.mk !ifndef BASERUBY
- echo>>confargs.mk BASERUBY = %2
- echo>>confargs.mk !endif
- echo>>confargs.tmp %1=%2 \
- shift
- shift
-goto :loop
:path
echo>>pathlist.tmp %2;\
echo>>confargs.tmp %1=%2 \
@@ -132,9 +122,8 @@ goto :loop
echo System types:
echo --target=TARGET configure for TARGET [i386-bccwin32]
echo Optional Package:
- echo --with-baseruby=RUBY use RUBY as baseruby [ruby]
echo --with-static-linked-ext link external modules statically
- echo --enable-install-doc install rdoc indexes during install
+ echo --disable-install-doc install rdoc indexes during install
del *.tmp
del ~tmp~.mak
goto :exit
diff --git a/bcc32/mkexports.rb b/bcc32/mkexports.rb
index 1b498f8515..dc523e2541 100755
--- a/bcc32/mkexports.rb
+++ b/bcc32/mkexports.rb
@@ -1,24 +1,27 @@
#!./miniruby -s
-$:.unshift(File.expand_path("../..", __FILE__))
-require 'win32/mkexports'
+$name = $library = $description = nil
-class Exports::Bcc < Exports
- Forwards = /^rb_w32_(\w+)/
-
- def forwarding(internal, export)
- internal[/\A_?/]+export
+SYM = {}
+STDIN.reopen(open("nul"))
+ARGV.each do |obj|
+ IO.foreach("|tdump -q -oiPUBDEF -oiPUBD32 #{obj.tr('/', '\\')}") do |l|
+ next unless /(?:PUBDEF|PUBD32)/ =~ l
+ SYM[$1] = true if /'(.*?)'/ =~ l
end
+end
- def each_export(objs)
- objs.each do |obj|
- opt = /\.(?:so|dll)\z/i =~ obj ? "-ee" : "-oiPUBDEF -oiPUBD32"
- IO.foreach("|tdump -q #{opt} #{obj.tr('/', '\\')} < nul") do |l|
- next unless /(?:PUBDEF|PUBD32|EXPORT)/ =~ l
- yield $1 if /'(.*?)'/ =~ l
- end
- end
- yield "_strcasecmp", "_stricmp"
- yield "_strncasecmp", "_strnicmp"
- end
+exports = []
+if $name
+ exports << "Name " + $name
+elsif $library
+ exports << "Library " + $library
+end
+exports << "Description " + $description.dump if $description
+exports << "EXPORTS" << SYM.keys.sort
+
+if $output
+ open($output, 'w') {|f| f.puts exports.join("\n")}
+else
+ puts exports.join("\n")
end
diff --git a/bcc32/setup.mak b/bcc32/setup.mak
index 0e0bb45d09..483292ed51 100644
--- a/bcc32/setup.mak
+++ b/bcc32/setup.mak
@@ -84,7 +84,6 @@ $(BANG)endif
-version-: nul
@cpp32 -I$(srcdir) -P- -o$(MAKEFILE) > nul &&|
-\#define RUBY_REVISION 0
\#include "version.h"
MAJOR = RUBY_VERSION_MAJOR
MINOR = RUBY_VERSION_MINOR
@@ -148,11 +147,6 @@ $(BANG)endif
@$(APPEND) PROCESSOR_LEVEL = 6
@$(APPEND) !endif
--epilogue-: -encs-
-
--encs-: nul
- @$(MAKE) -f $(srcdir)/win32/enc-setup.mak srcdir="$(srcdir)" MAKEFILE=$(MAKEFILE)
-
-epilogue-: nul
@type >> $(MAKEFILE) &&|
diff --git a/benchmark/bm_app_answer.rb b/benchmark/bm_app_answer.rb
deleted file mode 100644
index 3cd8a8fd37..0000000000
--- a/benchmark/bm_app_answer.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-def ack(m, n)
- if m == 0 then
- n + 1
- elsif n == 0 then
- ack(m - 1, 1)
- else
- ack(m - 1, ack(m, n - 1))
- end
-end
-
-def the_answer_to_life_the_universe_and_everything
- (ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i
-end
-
-answer = the_answer_to_life_the_universe_and_everything
diff --git a/benchmark/bm_app_erb.rb b/benchmark/bm_app_erb.rb
deleted file mode 100644
index e58b7a34a1..0000000000
--- a/benchmark/bm_app_erb.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Create many HTML strings with ERB.
-#
-
-require 'erb'
-
-data = DATA.read
-max = 5_000
-title = "hello world!"
-content = "hello world!\n" * 10
-
-max.times{
- ERB.new(data).result(binding)
-}
-
-__END__
-
-<html>
- <head> <%= title %> </head>
- <body>
- <h1> <%= title %> </h1>
- <p>
- <%= content %>
- </p>
- </body>
-</html>
diff --git a/benchmark/bm_app_factorial.rb b/benchmark/bm_app_factorial.rb
deleted file mode 100644
index a5a5de0426..0000000000
--- a/benchmark/bm_app_factorial.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-def fact(n)
- if(n > 1)
- n * fact(n-1)
- else
- 1
- end
-end
-
-8.times{
- fact(5000)
-} \ No newline at end of file
diff --git a/benchmark/bm_app_fib.rb b/benchmark/bm_app_fib.rb
deleted file mode 100644
index 34a7b2e725..0000000000
--- a/benchmark/bm_app_fib.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-def fib n
- if n < 3
- 1
- else
- fib(n-1) + fib(n-2)
- end
-end
-
-fib(34)
-
diff --git a/benchmark/bm_app_mandelbrot.rb b/benchmark/bm_app_mandelbrot.rb
deleted file mode 100644
index a0dcf5e874..0000000000
--- a/benchmark/bm_app_mandelbrot.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'complex'
-
-def mandelbrot? z
- i = 0
- while i<100
- i+=1
- z = z * z
- return false if z.abs > 2
- end
- true
-end
-
-ary = []
-
-(0..100).each{|dx|
- (0..100).each{|dy|
- x = dx / 50.0
- y = dy / 50.0
- c = Complex(x, y)
- ary << c if mandelbrot?(c)
- }
-}
-
diff --git a/benchmark/bm_app_pentomino.rb b/benchmark/bm_app_pentomino.rb
deleted file mode 100644
index 59c63f358e..0000000000
--- a/benchmark/bm_app_pentomino.rb
+++ /dev/null
@@ -1,259 +0,0 @@
-#!/usr/local/bin/ruby
-# This program is contributed by Shin Nishiyama
-
-
-# modified by K.Sasada
-
-NP = 5
-ROW = 8 + NP
-COL = 8
-
-$p = []
-$b = []
-$no = 0
-
-def piece(n, a, nb)
- nb.each{|x|
- a[n] = x
- if n == NP-1
- $p << [a.sort]
- else
- nbc=nb.dup
- [-ROW, -1, 1, ROW].each{|d|
- if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
- nbc << x+d
- end
- }
- nbc.delete x
- piece(n+1,a[0..n],nbc)
- end
- }
-end
-
-def kikaku(a)
- a.collect {|x| x - a[0]}
-end
-def ud(a)
- kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
-end
-def rl(a)
- kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
-end
-def xy(a)
- kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
-end
-
-def mkpieces
- piece(0,[],[0])
- $p.each do |a|
- a0 = a[0]
- a[1] = ud(a0)
- a[2] = rl(a0)
- a[3] = ud(rl(a0))
- a[4] = xy(a0)
- a[5] = ud(xy(a0))
- a[6] = rl(xy(a0))
- a[7] = ud(rl(xy(a0)))
- a.sort!
- a.uniq!
- end
- $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
-end
-
-def mkboard
- (0...ROW*COL).each{|i|
- if i % ROW >= ROW-NP
- $b[i] = -2
- else
- $b[i] = -1
- end
- $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
- }
-end
-
-def pboard
- return # skip print
- print "No. #$no\n"
- (0...COL).each{|i|
- print "|"
- (0...ROW-NP).each{|j|
- x = $b[i*ROW+j]
- if x < 0
- print "..|"
- else
- printf "%2d|",x+1
- end
- }
- print "\n"
- }
- print "\n"
-end
-
-$pnum=[]
-def setpiece(a,pos)
- if a.length == $p.length then
- $no += 1
- pboard
- return
- end
- while $b[pos] != -1
- pos += 1
- end
- ($pnum - a).each do |i|
- $p[i].each do |x|
- f = 0
- x.each{|s|
- if $b[pos+s] != -1
- f=1
- break
- end
- }
- if f == 0 then
- x.each{|s|
- $b[pos+s] = i
- }
- a << i
- setpiece(a.dup, pos)
- a.pop
- x.each{|s|
- $b[pos+s] = -1
- }
- end
- end
- end
-end
-
-mkpieces
-mkboard
-$p[4] = [$p[4][0]]
-$pnum = (0...$p.length).to_a
-setpiece([],0)
-
-
-__END__
-
-# original
-
-NP = 5
-ROW = 8 + NP
-COL = 8
-
-$p = []
-$b = []
-$no = 0
-
-def piece(n,a,nb)
- for x in nb
- a[n] = x
- if n == NP-1
- $p << [a.sort]
- else
- nbc=nb.dup
- for d in [-ROW, -1, 1, ROW]
- if x+d > 0 and not a.include?(x+d) and not nbc.include?(x+d)
- nbc << x+d
- end
- end
- nbc.delete x
- piece(n+1,a[0..n],nbc)
- end
- end
-end
-
-def kikaku(a)
- a.collect {|x| x - a[0]}
-end
-def ud(a)
- kikaku(a.collect {|x| ((x+NP)%ROW)-ROW*((x+NP)/ROW) }.sort)
-end
-def rl(a)
- kikaku(a.collect {|x| ROW*((x+NP)/ROW)+ROW-((x+NP)%ROW)}.sort)
-end
-def xy(a)
- kikaku(a.collect {|x| ROW*((x+NP)%ROW) + (x+NP)/ROW }.sort)
-end
-
-def mkpieces
- piece(0,[],[0])
- $p.each do |a|
- a0 = a[0]
- a[1] = ud(a0)
- a[2] = rl(a0)
- a[3] = ud(rl(a0))
- a[4] = xy(a0)
- a[5] = ud(xy(a0))
- a[6] = rl(xy(a0))
- a[7] = ud(rl(xy(a0)))
- a.sort!
- a.uniq!
- end
- $p.uniq!.sort! {|x,y| x[0] <=> y[0] }
-end
-
-def mkboard
- for i in 0...ROW*COL
- if i % ROW >= ROW-NP
- $b[i] = -2
- else
- $b[i] = -1
- end
- $b[3*ROW+3]=$b[3*ROW+4]=$b[4*ROW+3]=$b[4*ROW+4]=-2
- end
-end
-
-def pboard
- print "No. #$no\n"
- for i in 0...COL
- print "|"
- for j in 0...ROW-NP
- x = $b[i*ROW+j]
- if x < 0
- print "..|"
- else
- printf "%2d|",x+1
- end
- end
- print "\n"
- end
- print "\n"
-end
-
-$pnum=[]
-def setpiece(a,pos)
- if a.length == $p.length then
- $no += 1
- pboard
- return
- end
- while $b[pos] != -1
- pos += 1
- end
- ($pnum - a).each do |i|
- $p[i].each do |x|
- f = 0
- for s in x do
- if $b[pos+s] != -1
- f=1
- break
- end
- end
- if f == 0 then
- for s in x do
- $b[pos+s] = i
- end
- a << i
- setpiece(a.dup, pos)
- a.pop
- for s in x do
- $b[pos+s] = -1
- end
- end
- end
- end
-end
-
-mkpieces
-mkboard
-$p[4] = [$p[4][0]]
-$pnum = (0...$p.length).to_a
-setpiece([],0)
diff --git a/benchmark/bm_app_raise.rb b/benchmark/bm_app_raise.rb
deleted file mode 100644
index 01d2ae3219..0000000000
--- a/benchmark/bm_app_raise.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-i=0
-while i<300000
- i+=1
- begin
- raise
- rescue
- end
-end
diff --git a/benchmark/bm_app_strconcat.rb b/benchmark/bm_app_strconcat.rb
deleted file mode 100644
index c6ef817263..0000000000
--- a/benchmark/bm_app_strconcat.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-i=0
-while i<500000
- "#{1+1} #{1+1} #{1+1}"
- i+=1
-end
diff --git a/benchmark/bm_app_tak.rb b/benchmark/bm_app_tak.rb
deleted file mode 100644
index efe5380f4e..0000000000
--- a/benchmark/bm_app_tak.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-def tak x, y, z
- unless y < x
- z
- else
- tak( tak(x-1, y, z),
- tak(y-1, z, x),
- tak(z-1, x, y))
- end
-end
-
-tak(18, 9, 0)
-
diff --git a/benchmark/bm_app_tarai.rb b/benchmark/bm_app_tarai.rb
deleted file mode 100644
index 4c146f5ccf..0000000000
--- a/benchmark/bm_app_tarai.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-def tarai( x, y, z )
- if x <= y
- then y
- else tarai(tarai(x-1, y, z),
- tarai(y-1, z, x),
- tarai(z-1, x, y))
- end
-end
-
-tarai(12, 6, 0)
diff --git a/benchmark/bm_app_uri.rb b/benchmark/bm_app_uri.rb
deleted file mode 100644
index 586edfd5dc..0000000000
--- a/benchmark/bm_app_uri.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'uri'
-
-100_000.times{
- uri = URI.parse('http://www.ruby-lang.org')
- uri.scheme
- uri.host
- uri.port
-}
diff --git a/benchmark/bm_io_file_create.rb b/benchmark/bm_io_file_create.rb
deleted file mode 100644
index 7adbe9ea5e..0000000000
--- a/benchmark/bm_io_file_create.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Create files
-#
-
-max = 50_000
-file = './tmpfile_of_bm_io_file_create'
-
-max.times{
- f = open(file, 'w')
- f.close#(true)
-}
-File.unlink(file)
-
diff --git a/benchmark/bm_io_file_read.rb b/benchmark/bm_io_file_read.rb
deleted file mode 100644
index 2b4212db76..0000000000
--- a/benchmark/bm_io_file_read.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Seek and Read file.
-#
-
-require 'tempfile'
-
-max = 20_000
-str = "Hello world! " * 1000
-f = Tempfile.new('yarv-benchmark')
-f.write str
-
-max.times{
- f.seek 0
- f.read
-}
diff --git a/benchmark/bm_io_file_write.rb b/benchmark/bm_io_file_write.rb
deleted file mode 100644
index 3cec58c6ae..0000000000
--- a/benchmark/bm_io_file_write.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Seek and Write file.
-#
-
-require 'tempfile'
-
-max = 20_000
-str = "Hello world! " * 1000
-f = Tempfile.new('yarv-benchmark')
-
-max.times{
- f.seek 0
- f.write str
-}
diff --git a/benchmark/bm_loop_generator.rb b/benchmark/bm_loop_generator.rb
deleted file mode 100644
index d3375c744c..0000000000
--- a/benchmark/bm_loop_generator.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-max = 600000
-
-if defined? Fiber
- gen = (1..max).each
- loop do
- gen.next
- end
-else
- require 'generator'
- gen = Generator.new((0..max))
- while gen.next?
- gen.next
- end
-end
diff --git a/benchmark/bm_loop_times.rb b/benchmark/bm_loop_times.rb
deleted file mode 100644
index c5317b8228..0000000000
--- a/benchmark/bm_loop_times.rb
+++ /dev/null
@@ -1 +0,0 @@
-30000000.times{|e|}
diff --git a/benchmark/bm_loop_whileloop.rb b/benchmark/bm_loop_whileloop.rb
deleted file mode 100644
index 43d35e1131..0000000000
--- a/benchmark/bm_loop_whileloop.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-i=0
-while i<30_000_000 # benchmark loop 1
- i+=1
-end
diff --git a/benchmark/bm_loop_whileloop2.rb b/benchmark/bm_loop_whileloop2.rb
deleted file mode 100644
index e514989661..0000000000
--- a/benchmark/bm_loop_whileloop2.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-i=0
-while i< 6_000_000 # benchmark loop 2
- i+=1
-end
diff --git a/benchmark/bm_so_ackermann.rb b/benchmark/bm_so_ackermann.rb
deleted file mode 100644
index 7db5be9050..0000000000
--- a/benchmark/bm_so_ackermann.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: ackermann-ruby.code,v 1.4 2004/11/13 07:40:41 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-
-def ack(m, n)
- if m == 0 then
- n + 1
- elsif n == 0 then
- ack(m - 1, 1)
- else
- ack(m - 1, ack(m, n - 1))
- end
-end
-
-NUM = 9
-ack(3, NUM)
-
-
diff --git a/benchmark/bm_so_array.rb b/benchmark/bm_so_array.rb
deleted file mode 100644
index 2b8fce8f99..0000000000
--- a/benchmark/bm_so_array.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: ary-ruby.code,v 1.4 2004/11/13 07:41:27 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# with help from Paul Brannan and Mark Hubbart
-
-n = 9000 # Integer(ARGV.shift || 1)
-
-x = Array.new(n)
-y = Array.new(n, 0)
-
-n.times{|bi|
- x[bi] = bi + 1
-}
-
-(0 .. 999).each do |e|
- (n-1).step(0,-1) do |bi|
- y[bi] += x.at(bi)
- end
-end
-# puts "#{y.first} #{y.last}"
-
-
diff --git a/benchmark/bm_so_binary_trees.rb b/benchmark/bm_so_binary_trees.rb
deleted file mode 100644
index 6a26465578..0000000000
--- a/benchmark/bm_so_binary_trees.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# The Computer Language Shootout Benchmarks
-# http://shootout.alioth.debian.org
-#
-# contributed by Jesse Millikan
-
-# disable output
-def STDOUT.write_ *args
-end
-
-def item_check(tree)
- if tree[0] == nil
- tree[1]
- else
- tree[1] + item_check(tree[0]) - item_check(tree[2])
- end
-end
-
-def bottom_up_tree(item, depth)
- if depth > 0
- item_item = 2 * item
- depth -= 1
- [bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)]
- else
- [nil, item, nil]
- end
-end
-
-max_depth = 12 # 16 # ARGV[0].to_i
-min_depth = 4
-
-max_depth = min_depth + 2 if min_depth + 2 > max_depth
-
-stretch_depth = max_depth + 1
-stretch_tree = bottom_up_tree(0, stretch_depth)
-
-puts "stretch tree of depth #{stretch_depth}\t check: #{item_check(stretch_tree)}"
-stretch_tree = nil
-
-long_lived_tree = bottom_up_tree(0, max_depth)
-
-min_depth.step(max_depth + 1, 2) do |depth|
- iterations = 2**(max_depth - depth + min_depth)
-
- check = 0
-
- for i in 1..iterations
- temp_tree = bottom_up_tree(i, depth)
- check += item_check(temp_tree)
-
- temp_tree = bottom_up_tree(-i, depth)
- check += item_check(temp_tree)
- end
-
- puts "#{iterations * 2}\t trees of depth #{depth}\t check: #{check}"
-end
-
-puts "long lived tree of depth #{max_depth}\t check: #{item_check(long_lived_tree)}"
diff --git a/benchmark/bm_so_concatenate.rb b/benchmark/bm_so_concatenate.rb
deleted file mode 100644
index 82629688b7..0000000000
--- a/benchmark/bm_so_concatenate.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: strcat-ruby.code,v 1.4 2004/11/13 07:43:28 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# based on code from Aristarkh A Zagorodnikov and Dat Nguyen
-
-STUFF = "hello\n"
-i=0
-while i<10
- i+=1
- hello = ''
- 400000.times do |e|
- hello << STUFF
- end
-end
-# puts hello.length
-
-
diff --git a/benchmark/bm_so_count_words.rb b/benchmark/bm_so_count_words.rb
deleted file mode 100644
index 65f6337a4a..0000000000
--- a/benchmark/bm_so_count_words.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: wc-ruby.code,v 1.4 2004/11/13 07:43:32 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# with help from Paul Brannan
-
-input = open(File.join(File.dirname($0), 'wc.input'), 'rb')
-
-nl = nw = nc = 0
-while true
- tmp = input.read(4096) or break
- data = tmp << (input.gets || "")
- nc += data.length
- nl += data.count("\n")
- ((data.strip! || data).tr!("\n", " ") || data).squeeze!
- nw += data.count(" ") + 1
-end
-# STDERR.puts "#{nl} #{nw} #{nc}"
-
diff --git a/benchmark/bm_so_exception.rb b/benchmark/bm_so_exception.rb
deleted file mode 100644
index d8b461290c..0000000000
--- a/benchmark/bm_so_exception.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: except-ruby.code,v 1.4 2004/11/13 07:41:33 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-
-$HI = 0
-$LO = 0
-NUM = 250000 # Integer(ARGV[0] || 1)
-
-
-class Lo_Exception < Exception
- def initialize(num)
- @value = num
- end
-end
-
-class Hi_Exception < Exception
- def initialize(num)
- @value = num
- end
-end
-
-def some_function(num)
- begin
- hi_function(num)
- rescue
- print "We shouldn't get here, exception is: #{$!.type}\n"
- end
-end
-
-def hi_function(num)
- begin
- lo_function(num)
- rescue Hi_Exception
- $HI = $HI + 1
- end
-end
-
-def lo_function(num)
- begin
- blowup(num)
- rescue Lo_Exception
- $LO = $LO + 1
- end
-end
-
-def blowup(num)
- if num % 2 == 0
- raise Lo_Exception.new(num)
- else
- raise Hi_Exception.new(num)
- end
-end
-
-
-i = 1
-max = NUM+1
-while i < max
- i+=1
- some_function(i+1)
-end
diff --git a/benchmark/bm_so_fannkuch.rb b/benchmark/bm_so_fannkuch.rb
deleted file mode 100644
index a214f2e205..0000000000
--- a/benchmark/bm_so_fannkuch.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-# Contributed by Sokolov Yura
-# Modified by Ryan Williams
-
-def fannkuch(n)
- maxFlips, m, r, check = 0, n-1, n, 0
- count = (1..n).to_a
- perm = (1..n).to_a
-
- while true
- if check < 30
- puts "#{perm}"
- check += 1
- end
-
- while r != 1
- count[r-1] = r
- r -= 1
- end
-
- if perm[0] != 1 and perm[m] != n
- perml = perm.clone #.dup
- flips = 0
- while (k = perml.first ) != 1
- perml = perml.slice!(0, k).reverse + perml
- flips += 1
- end
- maxFlips = flips if flips > maxFlips
- end
- while true
- if r==n then return maxFlips end
- perm.insert r,perm.shift
- break if (count[r] -= 1) > 0
- r += 1
- end
- end
-end
-
-def puts *args
-end
-
-N = 10 # (ARGV[0] || 1).to_i
-puts "Pfannkuchen(#{N}) = #{fannkuch(N)}"
-
diff --git a/benchmark/bm_so_fasta.rb b/benchmark/bm_so_fasta.rb
deleted file mode 100644
index 3f759ba7ae..0000000000
--- a/benchmark/bm_so_fasta.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-# Contributed by Sokolov Yura
-
-$last = 42.0
-def gen_random (max,im=139968,ia=3877,ic=29573)
- (max * ($last = ($last * ia + ic) % im)) / im
-end
-
-alu =
- "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
- "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA"+
- "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT"+
- "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA"+
- "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG"+
- "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC"+
- "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
-
-iub = [
- ["a", 0.27],
- ["c", 0.12],
- ["g", 0.12],
- ["t", 0.27],
-
- ["B", 0.02],
- ["D", 0.02],
- ["H", 0.02],
- ["K", 0.02],
- ["M", 0.02],
- ["N", 0.02],
- ["R", 0.02],
- ["S", 0.02],
- ["V", 0.02],
- ["W", 0.02],
- ["Y", 0.02],
-]
-homosapiens = [
- ["a", 0.3029549426680],
- ["c", 0.1979883004921],
- ["g", 0.1975473066391],
- ["t", 0.3015094502008],
-]
-
-def make_repeat_fasta(id, desc, src, n)
- puts ">#{id} #{desc}"
- v = nil
- width = 60
- l = src.length
- s = src * ((n / l) + 1)
- s.slice!(n, l)
- puts(s.scan(/.{1,#{width}}/).join("\n"))
-end
-
-def make_random_fasta(id, desc, table, n)
- puts ">#{id} #{desc}"
- rand, v = nil,nil
- width = 60
- chunk = 1 * width
- prob = 0.0
- table.each{|v| v[1]= (prob += v[1])}
- for i in 1..(n/width)
- puts((1..width).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
- if n%width != 0
- puts((1..(n%width)).collect{
- rand = gen_random(1.0)
- table.find{|v| v[1]>rand}[0]
- }.join)
- end
-end
-
-
-n = (ARGV[0] or 250_000).to_i
-
-make_repeat_fasta('ONE', 'Homo sapiens alu', alu, n*2)
-make_random_fasta('TWO', 'IUB ambiguity codes', iub, n*3)
-make_random_fasta('THREE', 'Homo sapiens frequency', homosapiens, n*5)
-
diff --git a/benchmark/bm_so_k_nucleotide.rb b/benchmark/bm_so_k_nucleotide.rb
deleted file mode 100644
index dadab3e79c..0000000000
--- a/benchmark/bm_so_k_nucleotide.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org
-#
-# contributed by jose fco. gonzalez
-# modified by Sokolov Yura
-
-seq = String.new
-
-def frecuency( seq,length )
- n, table = seq.length - length + 1, Hash.new(0)
- f, i = nil, nil
- (0 ... length).each do |f|
- (f ... n).step(length) do |i|
- table[seq[i,length]] += 1
- end
- end
- [n,table]
-
-end
-
-def sort_by_freq( seq,length )
- n,table = frecuency( seq,length )
- a, b, v = nil, nil, nil
- table.sort{|a,b| b[1] <=> a[1]}.each do |v|
- puts "%s %.3f" % [v[0].upcase,((v[1]*100).to_f/n)]
- end
- puts
-end
-
-def find_seq( seq,s )
- n,table = frecuency( seq,s.length )
- puts "#{table[s].to_s}\t#{s.upcase}"
-end
-
-input = open(File.join(File.dirname($0), 'fasta.output.100000'), 'rb')
-
-line = input.gets while line !~ /^>THREE/
-line = input.gets
-
-while (line !~ /^>/) & line do
- seq << line.chomp
- line = input.gets
-end
-
-[1,2].each {|i| sort_by_freq( seq,i ) }
-
-%w(ggt ggta ggtatt ggtattttaatt ggtattttaatttatagt).each{|s| find_seq( seq,s) }
-
diff --git a/benchmark/bm_so_lists.rb b/benchmark/bm_so_lists.rb
deleted file mode 100644
index 3652288881..0000000000
--- a/benchmark/bm_so_lists.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-#from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
-
-NUM = 100
-SIZE = 10000
-
-def test_lists()
- # create a list of integers (Li1) from 1 to SIZE
- li1 = (1..SIZE).to_a
- # copy the list to li2 (not by individual items)
- li2 = li1.dup
- # remove each individual item from left side of li2 and
- # append to right side of li3 (preserving order)
- li3 = Array.new
- while (not li2.empty?)
- li3.push(li2.shift)
- end
- # li2 must now be empty
- # remove each individual item from right side of li3 and
- # append to right side of li2 (reversing list)
- while (not li3.empty?)
- li2.push(li3.pop)
- end
- # li3 must now be empty
- # reverse li1 in place
- li1.reverse!
- # check that first item is now SIZE
- if li1[0] != SIZE then
- p "not SIZE"
- 0
- else
- # compare li1 and li2 for equality
- if li1 != li2 then
- return(0)
- else
- # return the length of the list
- li1.length
- end
- end
-end
-
-i = 0
-while i<NUM
- i+=1
- result = test_lists()
-end
-
-result
diff --git a/benchmark/bm_so_mandelbrot.rb b/benchmark/bm_so_mandelbrot.rb
deleted file mode 100644
index 76331c64b8..0000000000
--- a/benchmark/bm_so_mandelbrot.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# The Computer Language Benchmarks Game
-# http://shootout.alioth.debian.org/
-#
-# contributed by Karl von Laudermann
-# modified by Jeremy Echols
-
-size = 600 # ARGV[0].to_i
-
-puts "P4\n#{size} #{size}"
-
-ITER = 49 # Iterations - 1 for easy for..in looping
-LIMIT_SQUARED = 4.0 # Presquared limit
-
-byte_acc = 0
-bit_num = 0
-
-count_size = size - 1 # Precomputed size for easy for..in looping
-
-# For..in loops are faster than .upto, .downto, .times, etc.
-for y in 0..count_size
- for x in 0..count_size
- zr = 0.0
- zi = 0.0
- cr = (2.0*x/size)-1.5
- ci = (2.0*y/size)-1.0
- escape = false
-
- # To make use of the for..in code, we use a dummy variable,
- # like one would in C
- for dummy in 0..ITER
- tr = zr*zr - zi*zi + cr
- ti = 2*zr*zi + ci
- zr, zi = tr, ti
-
- if (zr*zr+zi*zi) > LIMIT_SQUARED
- escape = true
- break
- end
- end
-
- byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1)
- bit_num += 1
-
- # Code is very similar for these cases, but using separate blocks
- # ensures we skip the shifting when it's unnecessary, which is most cases.
- if (bit_num == 8)
- print byte_acc.chr
- byte_acc = 0
- bit_num = 0
- elsif (x == count_size)
- byte_acc <<= (8 - bit_num)
- print byte_acc.chr
- byte_acc = 0
- bit_num = 0
- end
- end
-end
diff --git a/benchmark/bm_so_matrix.rb b/benchmark/bm_so_matrix.rb
deleted file mode 100644
index 0f274ad06c..0000000000
--- a/benchmark/bm_so_matrix.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-
-n = 60 #Integer(ARGV.shift || 1)
-
-size = 30
-
-def mkmatrix(rows, cols)
- count = 1
- mx = Array.new(rows)
- (0 .. (rows - 1)).each do |bi|
- row = Array.new(cols, 0)
- (0 .. (cols - 1)).each do |j|
- row[j] = count
- count += 1
- end
- mx[bi] = row
- end
- mx
-end
-
-def mmult(rows, cols, m1, m2)
- m3 = Array.new(rows)
- (0 .. (rows - 1)).each do |bi|
- row = Array.new(cols, 0)
- (0 .. (cols - 1)).each do |j|
- val = 0
- (0 .. (cols - 1)).each do |k|
- val += m1.at(bi).at(k) * m2.at(k).at(j)
- end
- row[j] = val
- end
- m3[bi] = row
- end
- m3
-end
-
-m1 = mkmatrix(size, size)
-m2 = mkmatrix(size, size)
-mm = Array.new
-n.times do
- mm = mmult(size, size, m1, m2)
-end
-# puts "#{mm[0][0]} #{mm[2][3]} #{mm[3][2]} #{mm[4][4]}"
-
-
diff --git a/benchmark/bm_so_meteor_contest.rb b/benchmark/bm_so_meteor_contest.rb
deleted file mode 100644
index 99cf6a91cc..0000000000
--- a/benchmark/bm_so_meteor_contest.rb
+++ /dev/null
@@ -1,564 +0,0 @@
-#!/usr/bin/env ruby
-#
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org
-# contributed by Kevin Barnes (Ruby novice)
-
-# PROGRAM: the main body is at the bottom.
-# 1) read about the problem here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
-# 2) see how I represent a board as a bitmask by reading the blank_board comments
-# 3) read as your mental paths take you
-
-def print *args
-end
-
-# class to represent all information about a particular rotation of a particular piece
-class Rotation
- # an array (by location) containing a bit mask for how the piece maps at the given location.
- # if the rotation is invalid at that location the mask will contain false
- attr_reader :start_masks
-
- # maps a direction to a relative location. these differ depending on whether it is an even or
- # odd row being mapped from
- @@rotation_even_adder = { :west => -1, :east => 1, :nw => -7, :ne => -6, :sw => 5, :se => 6 }
- @@rotation_odd_adder = { :west => -1, :east => 1, :nw => -6, :ne => -5, :sw => 6, :se => 7 }
-
- def initialize( directions )
- @even_offsets, @odd_offsets = normalize_offsets( get_values( directions ))
-
- @even_mask = mask_for_offsets( @even_offsets)
- @odd_mask = mask_for_offsets( @odd_offsets)
-
- @start_masks = Array.new(60)
-
- # create the rotational masks by placing the base mask at the location and seeing if
- # 1) it overlaps the boundries and 2) it produces a prunable board. if either of these
- # is true the piece cannot be placed
- 0.upto(59) do | offset |
- mask = is_even(offset) ? (@even_mask << offset) : (@odd_mask << offset)
- if (blank_board & mask == 0 && !prunable(blank_board | mask, 0, true)) then
- imask = compute_required( mask, offset)
- @start_masks[offset] = [ mask, imask, imask | mask ]
- else
- @start_masks[offset] = false
- end
- end
- end
-
- def compute_required( mask, offset )
- board = blank_board
- 0.upto(offset) { | i | board |= 1 << i }
- board |= mask
- return 0 if (!prunable(board | mask, offset))
- board = flood_fill(board,58)
- count = 0
- imask = 0
- 0.upto(59) do | i |
- if (board[i] == 0) then
- imask |= (1 << i)
- count += 1
- end
- end
- (count > 0 && count < 5) ? imask : 0
- end
-
- def flood_fill( board, location)
- return board if (board[location] == 1)
- board |= 1 << location
- row, col = location.divmod(6)
- board = flood_fill( board, location - 1) if (col > 0)
- board = flood_fill( board, location + 1) if (col < 4)
- if (row % 2 == 0) then
- board = flood_fill( board, location - 7) if (col > 0 && row > 0)
- board = flood_fill( board, location - 6) if (row > 0)
- board = flood_fill( board, location + 6) if (row < 9)
- board = flood_fill( board, location + 5) if (col > 0 && row < 9)
- else
- board = flood_fill( board, location - 5) if (col < 4 && row > 0)
- board = flood_fill( board, location - 6) if (row > 0)
- board = flood_fill( board, location + 6) if (row < 9)
- board = flood_fill( board, location + 7) if (col < 4 && row < 9)
- end
- board
- end
-
- # given a location, produces a list of relative locations covered by the piece at this rotation
- def offsets( location)
- if is_even( location) then
- @even_offsets.collect { | value | value + location }
- else
- @odd_offsets.collect { | value | value + location }
- end
- end
-
- # returns a set of offsets relative to the top-left most piece of the rotation (by even or odd rows)
- # this is hard to explain. imagine we have this partial board:
- # 0 0 0 0 0 x [positions 0-5]
- # 0 0 1 1 0 x [positions 6-11]
- # 0 0 1 0 0 x [positions 12-17]
- # 0 1 0 0 0 x [positions 18-23]
- # 0 1 0 0 0 x [positions 24-29]
- # 0 0 0 0 0 x [positions 30-35]
- # ...
- # The top-left of the piece is at position 8, the
- # board would be passed as a set of positions (values array) containing [8,9,14,19,25] not necessarily in that
- # sorted order. Since that array starts on an odd row, the offsets for an odd row are: [0,1,6,11,17] obtained
- # by subtracting 8 from everything. Now imagine the piece shifted up and to the right so it's on an even row:
- # 0 0 0 1 1 x [positions 0-5]
- # 0 0 1 0 0 x [positions 6-11]
- # 0 0 1 0 0 x [positions 12-17]
- # 0 1 0 0 0 x [positions 18-23]
- # 0 0 0 0 0 x [positions 24-29]
- # 0 0 0 0 0 x [positions 30-35]
- # ...
- # Now the positions are [3,4,8,14,19] which after subtracting the lowest value (3) gives [0,1,5,11,16] thus, the
- # offsets for this particular piece are (in even, odd order) [0,1,5,11,16],[0,1,6,11,17] which is what
- # this function would return
- def normalize_offsets( values)
- min = values.min
- even_min = is_even(min)
- other_min = even_min ? min + 6 : min + 7
- other_values = values.collect do | value |
- if is_even(value) then
- value + 6 - other_min
- else
- value + 7 - other_min
- end
- end
- values.collect! { | value | value - min }
-
- if even_min then
- [values, other_values]
- else
- [other_values, values]
- end
- end
-
- # produce a bitmask representation of an array of offset locations
- def mask_for_offsets( offsets )
- mask = 0
- offsets.each { | value | mask = mask + ( 1 << value ) }
- mask
- end
-
- # finds a "safe" position that a position as described by a list of directions can be placed
- # without falling off any edge of the board. the values returned a location to place the first piece
- # at so it will fit after making the described moves
- def start_adjust( directions )
- south = east = 0;
- directions.each do | direction |
- east += 1 if ( direction == :sw || direction == :nw || direction == :west )
- south += 1 if ( direction == :nw || direction == :ne )
- end
- south * 6 + east
- end
-
- # given a set of directions places the piece (as defined by a set of directions) on the board at
- # a location that will not take it off the edge
- def get_values ( directions )
- start = start_adjust(directions)
- values = [ start ]
- directions.each do | direction |
- if (start % 12 >= 6) then
- start += @@rotation_odd_adder[direction]
- else
- start += @@rotation_even_adder[direction]
- end
- values += [ start ]
- end
-
- # some moves take you back to an existing location, we'll strip duplicates
- values.uniq
- end
-end
-
-# describes a piece and caches information about its rotations to as to be efficient for iteration
-# ATTRIBUTES:
-# rotations -- all the rotations of the piece
-# type -- a numeic "name" of the piece
-# masks -- an array by location of all legal rotational masks (a n inner array) for that location
-# placed -- the mask that this piece was last placed at (not a location, but the actual mask used)
-class Piece
- attr_reader :rotations, :type, :masks
- attr_accessor :placed
-
- # transform hashes that change one direction into another when you either flip or rotate a set of directions
- @@flip_converter = { :west => :west, :east => :east, :nw => :sw, :ne => :se, :sw => :nw, :se => :ne }
- @@rotate_converter = { :west => :nw, :east => :se, :nw => :ne, :ne => :east, :sw => :west, :se => :sw }
-
- def initialize( directions, type )
- @type = type
- @rotations = Array.new();
- @map = {}
-
- generate_rotations( directions )
- directions.collect! { | value | @@flip_converter[value] }
- generate_rotations( directions )
-
- # creates the masks AND a map that returns [location, rotation] for any given mask
- # this is used when a board is found and we want to draw it, otherwise the map is unused
- @masks = Array.new();
- 0.upto(59) do | i |
- even = true
- @masks[i] = @rotations.collect do | rotation |
- mask = rotation.start_masks[i]
- @map[mask[0]] = [ i, rotation ] if (mask)
- mask || nil
- end
- @masks[i].compact!
- end
- end
-
- # rotates a set of directions through all six angles and adds a Rotation to the list for each one
- def generate_rotations( directions )
- 6.times do
- rotations.push( Rotation.new(directions))
- directions.collect! { | value | @@rotate_converter[value] }
- end
- end
-
- # given a board string, adds this piece to the board at whatever location/rotation
- # important: the outbound board string is 5 wide, the normal location notation is six wide (padded)
- def fill_string( board_string)
- location, rotation = @map[@placed]
- rotation.offsets(location).each do | offset |
- row, col = offset.divmod(6)
- board_string[ row*5 + col, 1 ] = @type.to_s
- end
- end
-end
-
-# a blank bit board having this form:
-#
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 0 0 0 0 0 1
-# 1 1 1 1 1 1
-#
-# where left lest significant bit is the top left and the most significant is the lower right
-# the actual board only consists of the 0 places, the 1 places are blockers to keep things from running
-# off the edges or bottom
-def blank_board
- 0b111111100000100000100000100000100000100000100000100000100000100000
-end
-
-def full_board
- 0b111111111111111111111111111111111111111111111111111111111111111111
-end
-
-# determines if a location (bit position) is in an even row
-def is_even( location)
- (location % 12) < 6
-end
-
-# support function that create three utility maps:
-# $converter -- for each row an array that maps a five bit row (via array mapping)
-# to the a a five bit representation of the bits below it
-# $bit_count -- maps a five bit row (via array mapping) to the number of 1s in the row
-# @@new_regions -- maps a five bit row (via array mapping) to an array of "region" arrays
-# a region array has three values the first is a mask of bits in the region,
-# the second is the count of those bits and the third is identical to the first
-# examples:
-# 0b10010 => [ 0b01100, 2, 0b01100 ], [ 0b00001, 1, 0b00001]
-# 0b01010 => [ 0b10000, 1, 0b10000 ], [ 0b00100, 1, 0b00100 ], [ 0b00001, 1, 0b00001]
-# 0b10001 => [ 0b01110, 3, 0b01110 ]
-def create_collector_support
- odd_map = [0b11, 0b110, 0b1100, 0b11000, 0b10000]
- even_map = [0b1, 0b11, 0b110, 0b1100, 0b11000]
-
- all_odds = Array.new(0b100000)
- all_evens = Array.new(0b100000)
- bit_counts = Array.new(0b100000)
- new_regions = Array.new(0b100000)
- 0.upto(0b11111) do | i |
- bit_count = odd = even = 0
- 0.upto(4) do | bit |
- if (i[bit] == 1) then
- bit_count += 1
- odd |= odd_map[bit]
- even |= even_map[bit]
- end
- end
- all_odds[i] = odd
- all_evens[i] = even
- bit_counts[i] = bit_count
- new_regions[i] = create_regions( i)
- end
-
- $converter = []
- 10.times { | row | $converter.push((row % 2 == 0) ? all_evens : all_odds) }
- $bit_counts = bit_counts
- $regions = new_regions.collect { | set | set.collect { | value | [ value, bit_counts[value], value] } }
-end
-
-# determines if a board is punable, meaning that there is no possibility that it
-# can be filled up with pieces. A board is prunable if there is a grouping of unfilled spaces
-# that are not a multiple of five. The following board is an example of a prunable board:
-# 0 0 1 0 0
-# 0 1 0 0 0
-# 1 1 0 0 0
-# 0 1 0 0 0
-# 0 0 0 0 0
-# ...
-#
-# This board is prunable because the top left corner is only 3 bits in area, no piece will ever fit it
-# parameters:
-# board -- an initial bit board (6 bit padded rows, see blank_board for format)
-# location -- starting location, everything above and to the left is already full
-# slotting -- set to true only when testing initial pieces, when filling normally
-# additional assumptions are possible
-#
-# Algorithm:
-# The algorithm starts at the top row (as determined by location) and iterates a row at a time
-# maintainng counts of active open areas (kept in the collector array) each collector contains
-# three values at the start of an iteration:
-# 0: mask of bits that would be adjacent to the collector in this row
-# 1: the number of bits collected so far
-# 2: a scratch space starting as zero, but used during the computation to represent
-# the empty bits in the new row that are adjacent (position 0)
-# The exact procedure is described in-code
-def prunable( board, location, slotting = false)
- collectors = []
- # loop accross the rows
- (location / 6).to_i.upto(9) do | row_on |
- # obtain a set of regions representing the bits of the curent row.
- regions = $regions[(board >> (row_on * 6)) & 0b11111]
- converter = $converter[row_on]
-
- # track the number of collectors at the start of the cycle so that
- # we don't compute against newly created collectors, only existing collectors
- initial_collector_count = collectors.length
-
- # loop against the regions. For each region of the row
- # we will see if it connects to one or more existing collectors.
- # if it connects to 1 collector, the bits from the region are added to the
- # bits of the collector and the mask is placed in collector[2]
- # If the region overlaps more than one collector then all the collectors
- # it overlaps with are merged into the first one (the others are set to nil in the array)
- # if NO collectors are found then the region is copied as a new collector
- regions.each do | region |
- collector_found = nil
- region_mask = region[2]
- initial_collector_count.times do | collector_num |
- collector = collectors[collector_num]
- if (collector) then
- collector_mask = collector[0]
- if (collector_mask & region_mask != 0) then
- if (collector_found) then
- collector_found[0] |= collector_mask
- collector_found[1] += collector[1]
- collector_found[2] |= collector[2]
- collectors[collector_num] = nil
- else
- collector_found = collector
- collector[1] += region[1]
- collector[2] |= region_mask
- end
- end
- end
- end
- if (collector_found == nil) then
- collectors.push(Array.new(region))
- end
- end
-
- # check the existing collectors, if any collector overlapped no bits in the region its [2] value will
- # be zero. The size of any such reaason is tested if it is not a muliple of five true is returned since
- # the board is prunable. if it is a multiple of five it is removed.
- # Collector that are still active have a new adjacent value [0] set based n the matched bits
- # and have [2] cleared out for the next cycle.
- collectors.length.times do | collector_num |
- collector = collectors[collector_num]
- if (collector) then
- if (collector[2] == 0) then
- return true if (collector[1] % 5 != 0)
- collectors[collector_num] = nil
- else
- # if a collector matches all bits in the row then we can return unprunable early for the
- # follwing reasons:
- # 1) there can be no more unavailable bits bince we fill from the top left downward
- # 2) all previous regions have been closed or joined so only this region can fail
- # 3) this region must be good since there can never be only 1 region that is nuot
- # a multiple of five
- # this rule only applies when filling normally, so we ignore the rule if we are "slotting"
- # in pieces to see what configurations work for them (the only other time this algorithm is used).
- return false if (collector[2] == 0b11111 && !slotting)
- collector[0] = converter[collector[2]]
- collector[2] = 0
- end
- end
- end
-
- # get rid of all the empty converters for the next round
- collectors.compact!
- end
- return false if (collectors.length <= 1) # 1 collector or less and the region is fine
- collectors.any? { | collector | (collector[1] % 5) != 0 } # more than 1 and we test them all for bad size
-end
-
-# creates a region given a row mask. see prunable for what a "region" is
-def create_regions( value )
- regions = []
- cur_region = 0
- 5.times do | bit |
- if (value[bit] == 0) then
- cur_region |= 1 << bit
- else
- if (cur_region != 0 ) then
- regions.push( cur_region)
- cur_region = 0;
- end
- end
- end
- regions.push(cur_region) if (cur_region != 0)
- regions
-end
-
-# find up to the counted number of solutions (or all solutions) and prints the final result
-def find_all
- find_top( 1)
- find_top( 0)
- print_results
-end
-
-# show the board
-def print_results
- print "#{@boards_found} solutions found\n\n"
- print_full_board( @min_board)
- print "\n"
- print_full_board( @max_board)
- print "\n"
-end
-
-# finds solutions. This special version of the main function is only used for the top level
-# the reason for it is basically to force a particular ordering on how the rotations are tested for
-# the first piece. It is called twice, first looking for placements of the odd rotations and then
-# looking for placements of the even locations.
-#
-# WHY?
-# Since any found solution has an inverse we want to maximize finding solutions that are not already found
-# as an inverse. The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away
-# (an odd number). Checking even vs odd then produces a higher probability of finding more pieces earlier
-# in the cycle. We still need to keep checking all the permutations, but our probability of finding one will
-# diminsh over time. Since we are TOLD how many to search for this lets us exit before checking all pieces
-# this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the
-# maximum number
-def find_top( rotation_skip)
- board = blank_board
- (@pieces.length-1).times do
- piece = @pieces.shift
- piece.masks[0].each do | mask, imask, cmask |
- if ((rotation_skip += 1) % 2 == 0) then
- piece.placed = mask
- find( 1, 1, board | mask)
- end
- end
- @pieces.push(piece)
- end
- piece = @pieces.shift
- @pieces.push(piece)
-end
-
-# the normail find routine, iterates through the available pieces, checks all rotations at the current location
-# and adds any boards found. depth is acheived via recursion. the overall approach is described
-# here: http://www-128.ibm.com/developerworks/java/library/j-javaopt/
-# parameters:
-# start_location -- where to start looking for place for the next piece at
-# placed -- number of pieces placed
-# board -- current state of the board
-#
-# see in-code comments
-def find( start_location, placed, board)
- # find the next location to place a piece by looking for an empty bit
- while board[start_location] == 1
- start_location += 1
- end
-
- @pieces.length.times do
- piece = @pieces.shift
- piece.masks[start_location].each do | mask, imask, cmask |
- if ( board & cmask == imask) then
- piece.placed = mask
- if (placed == 9) then
- add_board
- else
- find( start_location + 1, placed + 1, board | mask)
- end
- end
- end
- @pieces.push(piece)
- end
-end
-
-# print the board
-def print_full_board( board_string)
- 10.times do | row |
- print " " if (row % 2 == 1)
- 5.times do | col |
- print "#{board_string[row*5 + col,1]} "
- end
- print "\n"
- end
-end
-
-# when a board is found we "draw it" into a string and then flip that string, adding both to
-# the list (hash) of solutions if they are unique.
-def add_board
- board_string = "99999999999999999999999999999999999999999999999999"
- @all_pieces.each { | piece | piece.fill_string( board_string ) }
- save( board_string)
- save( board_string.reverse)
-end
-
-# adds a board string to the list (if new) and updates the current best/worst board
-def save( board_string)
- if (@all_boards[board_string] == nil) then
- @min_board = board_string if (board_string < @min_board)
- @max_board = board_string if (board_string > @max_board)
- @all_boards.store(board_string,true)
- @boards_found += 1
-
- # the exit motif is a time saver. Ideally the function should return, but those tests
- # take noticable time (performance).
- if (@boards_found == @stop_count) then
- print_results
- exit(0)
- end
- end
-end
-
-
-##
-## MAIN BODY :)
-##
-create_collector_support
-@pieces = [
- Piece.new( [ :nw, :ne, :east, :east ], 2),
- Piece.new( [ :ne, :se, :east, :ne ], 7),
- Piece.new( [ :ne, :east, :ne, :nw ], 1),
- Piece.new( [ :east, :sw, :sw, :se ], 6),
- Piece.new( [ :east, :ne, :se, :ne ], 5),
- Piece.new( [ :east, :east, :east, :se ], 0),
- Piece.new( [ :ne, :nw, :se, :east, :se ], 4),
- Piece.new( [ :se, :se, :se, :west ], 9),
- Piece.new( [ :se, :se, :east, :se ], 8),
- Piece.new( [ :east, :east, :sw, :se ], 3)
- ];
-
-@all_pieces = Array.new( @pieces)
-
-@min_board = "99999999999999999999999999999999999999999999999999"
-@max_board = "00000000000000000000000000000000000000000000000000"
-@stop_count = ARGV[0].to_i || 2089
-@all_boards = {}
-@boards_found = 0
-
-find_all ######## DO IT!!!
-
diff --git a/benchmark/bm_so_nbody.rb b/benchmark/bm_so_nbody.rb
deleted file mode 100644
index d6c5bb9e61..0000000000
--- a/benchmark/bm_so_nbody.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org
-#
-# Optimized for Ruby by Jesse Millikan
-# From version ported by Michael Neumann from the C gcc version,
-# which was written by Christoph Bauer.
-
-SOLAR_MASS = 4 * Math::PI**2
-DAYS_PER_YEAR = 365.24
-
-def _puts *args
-end
-
-class Planet
- attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass
-
- def initialize(x, y, z, vx, vy, vz, mass)
- @x, @y, @z = x, y, z
- @vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR
- @mass = mass * SOLAR_MASS
- end
-
- def move_from_i(bodies, nbodies, dt, i)
- while i < nbodies
- b2 = bodies[i]
- dx = @x - b2.x
- dy = @y - b2.y
- dz = @z - b2.z
-
- distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
- mag = dt / (distance * distance * distance)
- b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag
-
- @vx -= dx * b2_mass_mag
- @vy -= dy * b2_mass_mag
- @vz -= dz * b2_mass_mag
- b2.vx += dx * b_mass_mag
- b2.vy += dy * b_mass_mag
- b2.vz += dz * b_mass_mag
- i += 1
- end
-
- @x += dt * @vx
- @y += dt * @vy
- @z += dt * @vz
- end
-end
-
-def energy(bodies)
- e = 0.0
- nbodies = bodies.size
-
- for i in 0 ... nbodies
- b = bodies[i]
- e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz)
- for j in (i + 1) ... nbodies
- b2 = bodies[j]
- dx = b.x - b2.x
- dy = b.y - b2.y
- dz = b.z - b2.z
- distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
- e -= (b.mass * b2.mass) / distance
- end
- end
- e
-end
-
-def offset_momentum(bodies)
- px, py, pz = 0.0, 0.0, 0.0
-
- for b in bodies
- m = b.mass
- px += b.vx * m
- py += b.vy * m
- pz += b.vz * m
- end
-
- b = bodies[0]
- b.vx = - px / SOLAR_MASS
- b.vy = - py / SOLAR_MASS
- b.vz = - pz / SOLAR_MASS
-end
-
-BODIES = [
- # sun
- Planet.new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0),
-
- # jupiter
- Planet.new(
- 4.84143144246472090e+00,
- -1.16032004402742839e+00,
- -1.03622044471123109e-01,
- 1.66007664274403694e-03,
- 7.69901118419740425e-03,
- -6.90460016972063023e-05,
- 9.54791938424326609e-04),
-
- # saturn
- Planet.new(
- 8.34336671824457987e+00,
- 4.12479856412430479e+00,
- -4.03523417114321381e-01,
- -2.76742510726862411e-03,
- 4.99852801234917238e-03,
- 2.30417297573763929e-05,
- 2.85885980666130812e-04),
-
- # uranus
- Planet.new(
- 1.28943695621391310e+01,
- -1.51111514016986312e+01,
- -2.23307578892655734e-01,
- 2.96460137564761618e-03,
- 2.37847173959480950e-03,
- -2.96589568540237556e-05,
- 4.36624404335156298e-05),
-
- # neptune
- Planet.new(
- 1.53796971148509165e+01,
- -2.59193146099879641e+01,
- 1.79258772950371181e-01,
- 2.68067772490389322e-03,
- 1.62824170038242295e-03,
- -9.51592254519715870e-05,
- 5.15138902046611451e-05)
-]
-
-init = 200_000 # ARGV[0]
-n = Integer(init)
-
-offset_momentum(BODIES)
-
-puts "%.9f" % energy(BODIES)
-
-nbodies = BODIES.size
-dt = 0.01
-
-n.times do
- i = 0
- while i < nbodies
- b = BODIES[i]
- b.move_from_i(BODIES, nbodies, dt, i + 1)
- i += 1
- end
-end
-
-puts "%.9f" % energy(BODIES)
diff --git a/benchmark/bm_so_nested_loop.rb b/benchmark/bm_so_nested_loop.rb
deleted file mode 100644
index a0513f8c47..0000000000
--- a/benchmark/bm_so_nested_loop.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: nestedloop-ruby.code,v 1.4 2004/11/13 07:42:22 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# from Avi Bryant
-
-n = 16 # Integer(ARGV.shift || 1)
-x = 0
-n.times do
- n.times do
- n.times do
- n.times do
- n.times do
- n.times do
- x += 1
- end
- end
- end
- end
- end
-end
-# puts x
-
-
diff --git a/benchmark/bm_so_nsieve.rb b/benchmark/bm_so_nsieve.rb
deleted file mode 100644
index a65cc78233..0000000000
--- a/benchmark/bm_so_nsieve.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# contributed by Glenn Parker, March 2005
-# modified by Evan Phoenix, Sept 2006
-
-def sieve(m)
- flags = Flags.dup[0,m]
- count = 0
- pmax = m - 1
- p = 2
- while p <= pmax
- unless flags[p].zero?
- count += 1
- mult = p
- while mult <= pmax
- flags[mult] = 0
- mult += p
- end
- end
- p += 1
- end
- count
-end
-
-n = 9 # (ARGV[0] || 2).to_i
-Flags = ("\x1" * ( 2 ** n * 10_000)).unpack("c*")
-
-n.downto(n-2) do |exponent|
- break if exponent < 0
- m = (1 << exponent) * 10_000
- # m = (2 ** exponent) * 10_000
- count = sieve(m)
- printf "Primes up to %8d %8d\n", m, count
-end
diff --git a/benchmark/bm_so_nsieve_bits.rb b/benchmark/bm_so_nsieve_bits.rb
deleted file mode 100644
index 019b8b6382..0000000000
--- a/benchmark/bm_so_nsieve_bits.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/ruby
-#
-# The Great Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# nsieve-bits in Ruby
-# Contributed by Glenn Parker, March 2005
-
-CharExponent = 3
-BitsPerChar = 1 << CharExponent
-LowMask = BitsPerChar - 1
-
-def sieve(m)
- items = "\xFF" * ((m / BitsPerChar) + 1)
- masks = ""
- BitsPerChar.times do |b|
- masks << (1 << b).chr
- end
-
- count = 0
- pmax = m - 1
- 2.step(pmax, 1) do |p|
- if items[p >> CharExponent][p & LowMask] == 1
- count += 1
- p.step(pmax, p) do |mult|
- a = mult >> CharExponent
- b = mult & LowMask
- items[a] -= masks[b] if items[a][b] != 0
- end
- end
- end
- count
-end
-
-n = 9 # (ARGV[0] || 2).to_i
-n.step(n - 2, -1) do |exponent|
- break if exponent < 0
- m = 2 ** exponent * 10_000
- count = sieve(m)
- printf "Primes up to %8d %8d\n", m, count
-end
-
diff --git a/benchmark/bm_so_object.rb b/benchmark/bm_so_object.rb
deleted file mode 100644
index e8607c7199..0000000000
--- a/benchmark/bm_so_object.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/ruby
-# -*- mode: ruby -*-
-# $Id: objinst-ruby.code,v 1.4 2004/11/13 07:42:25 bfulgham Exp $
-# http://www.bagley.org/~doug/shootout/
-# with help from Aristarkh Zagorodnikov
-
-class Toggle
- def initialize(start_state)
- @bool = start_state
- end
-
- def value
- @bool
- end
-
- def activate
- @bool = !@bool
- self
- end
-end
-
-class NthToggle < Toggle
- def initialize(start_state, max_counter)
- super start_state
- @count_max = max_counter
- @counter = 0
- end
-
- def activate
- @counter += 1
- if @counter >= @count_max
- @bool = !@bool
- @counter = 0
- end
- self
- end
-end
-
-n = 1500000 # (ARGV.shift || 1).to_i
-
-toggle = Toggle.new 1
-5.times do
- toggle.activate.value ? 'true' : 'false'
-end
-n.times do
- toggle = Toggle.new 1
-end
-
-ntoggle = NthToggle.new 1, 3
-8.times do
- ntoggle.activate.value ? 'true' : 'false'
-end
-n.times do
- ntoggle = NthToggle.new 1, 3
-end
-
diff --git a/benchmark/bm_so_partial_sums.rb b/benchmark/bm_so_partial_sums.rb
deleted file mode 100644
index 630b45cb8d..0000000000
--- a/benchmark/bm_so_partial_sums.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-n = 2_500_000 # (ARGV.shift || 1).to_i
-
-alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0
-
-1.upto(n) do |d|
- d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d)
-
- s0 += (2.0 / 3.0) ** (d - 1.0)
- s1 += 1.0 / Math.sqrt(d)
- s2 += 1.0 / (d * (d + 1.0))
- s3 += 1.0 / (d3 * ds * ds)
- s4 += 1.0 / (d3 * dc * dc)
- s5 += 1.0 / d
- s6 += 1.0 / d2
- s7 += alt / d
- s8 += alt / (2.0 * d - 1.0)
-
- alt = -alt
-end
-
-if false
- printf("%.9f\t(2/3)^k\n", s0)
- printf("%.9f\tk^-0.5\n", s1)
- printf("%.9f\t1/k(k+1)\n", s2)
- printf("%.9f\tFlint Hills\n", s3)
- printf("%.9f\tCookson Hills\n", s4)
- printf("%.9f\tHarmonic\n", s5)
- printf("%.9f\tRiemann Zeta\n", s6)
- printf("%.9f\tAlternating Harmonic\n", s7)
- printf("%.9f\tGregory\n", s8)
-end
diff --git a/benchmark/bm_so_pidigits.rb b/benchmark/bm_so_pidigits.rb
deleted file mode 100644
index c7d6fbfb4d..0000000000
--- a/benchmark/bm_so_pidigits.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-# The Great Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# contributed by Gabriele Renzi
-
-class PiDigitSpigot
-
- def initialize()
- @z = Transformation.new 1,0,0,1
- @x = Transformation.new 0,0,0,0
- @inverse = Transformation.new 0,0,0,0
- end
-
- def next!
- @y = @z.extract(3)
- if safe? @y
- @z = produce(@y)
- @y
- else
- @z = consume @x.next!()
- next!()
- end
- end
-
- def safe?(digit)
- digit == @z.extract(4)
- end
-
- def produce(i)
- @inverse.qrst(10,-10*i,0,1).compose(@z)
- end
-
- def consume(a)
- @z.compose(a)
- end
-end
-
-
-class Transformation
- attr_reader :q, :r, :s, :t
- def initialize (q, r, s, t)
- @q,@r,@s,@t,@k = q,r,s,t,0
- end
-
- def next!()
- @q = @k = @k + 1
- @r = 4 * @k + 2
- @s = 0
- @t = 2 * @k + 1
- self
- end
-
- def extract(j)
- (@q * j + @r) / (@s * j + @t)
- end
-
- def compose(a)
- self.class.new( @q * a.q,
- @q * a.r + r * a.t,
- @s * a.q + t * a.s,
- @s * a.r + t * a.t
- )
- end
-
- def qrst *args
- initialize *args
- self
- end
-
-
-end
-
-
-WIDTH = 10
-n = 2_500 # Integer(ARGV[0])
-j = 0
-
-digits = PiDigitSpigot.new
-
-while n > 0
- if n >= WIDTH
- WIDTH.times {print digits.next!}
- j += WIDTH
- else
- n.times {print digits.next!}
- (WIDTH-n).times {print " "}
- j += n
- end
- puts "\t:"+j.to_s
- n -= WIDTH
-end
-
diff --git a/benchmark/bm_so_random.rb b/benchmark/bm_so_random.rb
deleted file mode 100644
index 83c0d6d380..0000000000
--- a/benchmark/bm_so_random.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# from http://www.bagley.org/~doug/shootout/bench/random/random.ruby
-
-IM = 139968.0
-IA = 3877.0
-IC = 29573.0
-
-$last = 42.0
-
-def gen_random(max)
- (max * ($last = ($last * IA + IC) % IM)) / IM
-end
-
-N = 1000000
-
-i=0
-while i<N
- i+=1
- gen_random(100.0)
-end
-# "%.9f" % gen_random(100.0)
diff --git a/benchmark/bm_so_reverse_complement.rb b/benchmark/bm_so_reverse_complement.rb
deleted file mode 100644
index 82ea666994..0000000000
--- a/benchmark/bm_so_reverse_complement.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/ruby
-# The Great Computer Language Shootout
-# http://shootout.alioth.debian.org/
-#
-# Contributed by Peter Bjarke Olsen
-# Modified by Doug King
-
-seq=Array.new
-
-def revcomp(seq)
- seq.reverse!.tr!('wsatugcyrkmbdhvnATUGCYRKMBDHVN','WSTAACGRYMKVHDBNTAACGRYMKVHDBN')
- stringlen=seq.length
- 0.step(stringlen-1,60) {|x| print seq.slice(x,60) , "\n"}
-end
-
-input = open(File.join(File.dirname($0), 'fasta.output.2500000'), 'rb')
-
-while input.gets
- if $_ =~ />/
- if seq.length != 0
- revcomp(seq.join)
- seq=Array.new
- end
- puts $_
- else
- $_.sub(/\n/,'')
- seq.push $_
- end
-end
-revcomp(seq.join)
diff --git a/benchmark/bm_so_sieve.rb b/benchmark/bm_so_sieve.rb
deleted file mode 100644
index dbe2bfa63d..0000000000
--- a/benchmark/bm_so_sieve.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# from http://www.bagley.org/~doug/shootout/bench/sieve/sieve.ruby
-num = 40
-count = i = j = 0
-flags0 = Array.new(8192,1)
-k = 0
-while k < num
- k+=1
- count = 0
- flags = flags0.dup
- i = 2
- while i<8192
- i+=1
- if flags[i]
- # remove all multiples of prime: i
- j = i*i
- while j < 8192
- j += i
- flags[j] = nil
- end
- count += 1
- end
- end
-end
-count
diff --git a/benchmark/bm_so_spectralnorm.rb b/benchmark/bm_so_spectralnorm.rb
deleted file mode 100644
index 6b97206689..0000000000
--- a/benchmark/bm_so_spectralnorm.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-# The Computer Language Shootout
-# http://shootout.alioth.debian.org/
-# Contributed by Sokolov Yura
-
-def eval_A(i,j)
- return 1.0/((i+j)*(i+j+1)/2+i+1)
-end
-
-def eval_A_times_u(u)
- v, i = nil, nil
- (0..u.length-1).collect { |i|
- v = 0
- for j in 0..u.length-1
- v += eval_A(i,j)*u[j]
- end
- v
- }
-end
-
-def eval_At_times_u(u)
- v, i = nil, nil
- (0..u.length-1).collect{|i|
- v = 0
- for j in 0..u.length-1
- v += eval_A(j,i)*u[j]
- end
- v
- }
-end
-
-def eval_AtA_times_u(u)
- return eval_At_times_u(eval_A_times_u(u))
-end
-
-n = 500 # ARGV[0].to_i
-
-u=[1]*n
-for i in 1..10
- v=eval_AtA_times_u(u)
- u=eval_AtA_times_u(v)
-end
-vBv=0
-vv=0
-for i in 0..n-1
- vBv += u[i]*v[i]
- vv += v[i]*v[i]
-end
-
-str = "%0.9f" % (Math.sqrt(vBv/vv)), "\n"
-# print str
diff --git a/benchmark/bm_vm1_block.rb b/benchmark/bm_vm1_block.rb
deleted file mode 100644
index 2dc4e72be5..0000000000
--- a/benchmark/bm_vm1_block.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-def m
- yield
-end
-
-i=0
-while i<30000000 # while loop 1
- i+=1
- m{
- }
-end \ No newline at end of file
diff --git a/benchmark/bm_vm1_const.rb b/benchmark/bm_vm1_const.rb
deleted file mode 100644
index 3e395d9478..0000000000
--- a/benchmark/bm_vm1_const.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-Const = 1
-
-i = 0
-while i<30000000 # while loop 1
- i+= 1
- j = Const
- k = Const
-end
diff --git a/benchmark/bm_vm1_ensure.rb b/benchmark/bm_vm1_ensure.rb
deleted file mode 100644
index c3b71ead5a..0000000000
--- a/benchmark/bm_vm1_ensure.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-i=0
-while i<30000000 # benchmark loop 1
- i+=1
- begin
- begin
- ensure
- end
- ensure
- end
-end
-
diff --git a/benchmark/bm_vm1_ivar.rb b/benchmark/bm_vm1_ivar.rb
deleted file mode 100644
index 4de833a316..0000000000
--- a/benchmark/bm_vm1_ivar.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-@a = 1
-
-i = 0
-while i<30000000 # while loop 1
- i+= 1
- j = @a
- k = @a
-end
diff --git a/benchmark/bm_vm1_ivar_set.rb b/benchmark/bm_vm1_ivar_set.rb
deleted file mode 100644
index c8076c6ab6..0000000000
--- a/benchmark/bm_vm1_ivar_set.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-i = 0
-while i<30_000_000 # while loop 1
- i+= 1
- @a = 1
- @b = 2
-end
diff --git a/benchmark/bm_vm1_length.rb b/benchmark/bm_vm1_length.rb
deleted file mode 100644
index 2d7d7f0b52..0000000000
--- a/benchmark/bm_vm1_length.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-a = 'abc'
-b = [1, 2, 3]
-i=0
-while i<30000000 # while loop 1
- i+=1
- a.length
- b.length
-end
-
diff --git a/benchmark/bm_vm1_neq.rb b/benchmark/bm_vm1_neq.rb
deleted file mode 100644
index 212f056c6e..0000000000
--- a/benchmark/bm_vm1_neq.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-i = 0
-obj1 = Object.new
-obj2 = Object.new
-
-while i<30000000 # while loop 1
- i+= 1
- obj1 != obj2
-end
diff --git a/benchmark/bm_vm1_not.rb b/benchmark/bm_vm1_not.rb
deleted file mode 100644
index f139fed8be..0000000000
--- a/benchmark/bm_vm1_not.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-i = 0
-obj = Object.new
-
-while i<30000000 # while loop 1
- i+= 1
- !obj
-end
diff --git a/benchmark/bm_vm1_rescue.rb b/benchmark/bm_vm1_rescue.rb
deleted file mode 100644
index 0c98d00e0d..0000000000
--- a/benchmark/bm_vm1_rescue.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-i=0
-while i<30000000 # while loop 1
- i+=1
- begin
- rescue
- end
-end
diff --git a/benchmark/bm_vm1_simplereturn.rb b/benchmark/bm_vm1_simplereturn.rb
deleted file mode 100644
index c843ee3d97..0000000000
--- a/benchmark/bm_vm1_simplereturn.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-def m
- return 1
-end
-i=0
-while i<30000000 # while loop 1
- i+=1
- m
-end
-
diff --git a/benchmark/bm_vm1_swap.rb b/benchmark/bm_vm1_swap.rb
deleted file mode 100644
index a565b6f6dc..0000000000
--- a/benchmark/bm_vm1_swap.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-a = 1
-b = 2
-i=0
-while i<30000000 # while loop 1
- i+=1
- a, b = b, a
-end
-
diff --git a/benchmark/bm_vm2_array.rb b/benchmark/bm_vm2_array.rb
deleted file mode 100644
index e29c11200f..0000000000
--- a/benchmark/bm_vm2_array.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
- a = [1,2,3,4,5,6,7,8,9,10]
-end
diff --git a/benchmark/bm_vm2_case.rb b/benchmark/bm_vm2_case.rb
deleted file mode 100644
index 1ec34ad692..0000000000
--- a/benchmark/bm_vm2_case.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-i=0
-while i<6000000 # while loop 2
- case :foo
- when :bar
- raise
- when :baz
- raise
- when :boo
- raise
- when :foo
- i+=1
- end
-end
-
diff --git a/benchmark/bm_vm2_eval.rb b/benchmark/bm_vm2_eval.rb
deleted file mode 100644
index 375dccc00e..0000000000
--- a/benchmark/bm_vm2_eval.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
- eval("1")
-end
-
diff --git a/benchmark/bm_vm2_method.rb b/benchmark/bm_vm2_method.rb
deleted file mode 100644
index cc94b8ab3d..0000000000
--- a/benchmark/bm_vm2_method.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-def m
- nil
-end
-
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
- m; m; m; m; m; m; m; m;
-end
diff --git a/benchmark/bm_vm2_mutex.rb b/benchmark/bm_vm2_mutex.rb
deleted file mode 100644
index 9ec1a0f136..0000000000
--- a/benchmark/bm_vm2_mutex.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'thread'
-
-m = Mutex.new
-
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
- m.synchronize{}
-end
diff --git a/benchmark/bm_vm2_poly_method.rb b/benchmark/bm_vm2_poly_method.rb
deleted file mode 100644
index ac9953ce5f..0000000000
--- a/benchmark/bm_vm2_poly_method.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class C1
- def m
- 1
- end
-end
-class C2
- def m
- 2
- end
-end
-
-o1 = C1.new
-o2 = C2.new
-
-i=0
-while i<6000000 # benchmark loop 2
- o = (i % 2 == 0) ? o1 : o2
- o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i+=1
-end
diff --git a/benchmark/bm_vm2_poly_method_ov.rb b/benchmark/bm_vm2_poly_method_ov.rb
deleted file mode 100644
index 856ba9b161..0000000000
--- a/benchmark/bm_vm2_poly_method_ov.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-class C1
- def m
- 1
- end
-end
-class C2
- def m
- 2
- end
-end
-
-o1 = C1.new
-o2 = C2.new
-
-i=0
-while i<6000000 # benchmark loop 2
- o = (i % 2 == 0) ? o1 : o2
-# o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m
- i+=1
-end
diff --git a/benchmark/bm_vm2_proc.rb b/benchmark/bm_vm2_proc.rb
deleted file mode 100644
index 0bd05b9544..0000000000
--- a/benchmark/bm_vm2_proc.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-def m &b
- b
-end
-
-pr = m{
- a = 1
-}
-
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
- pr.call
-end
-
diff --git a/benchmark/bm_vm2_regexp.rb b/benchmark/bm_vm2_regexp.rb
deleted file mode 100644
index 44f6ed402e..0000000000
--- a/benchmark/bm_vm2_regexp.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-i=0
-str = 'xxxhogexxx'
-while i<6000000 # benchmark loop 2
- /hoge/ =~ str
- i+=1
-end
diff --git a/benchmark/bm_vm2_send.rb b/benchmark/bm_vm2_send.rb
deleted file mode 100644
index c20dbdd26c..0000000000
--- a/benchmark/bm_vm2_send.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class C
- def m
- end
-end
-
-o = C.new
-
-i=0
-while i<6000000 # benchmark loop 2
- i+=1
- o.__send__ :m
-end
diff --git a/benchmark/bm_vm2_super.rb b/benchmark/bm_vm2_super.rb
deleted file mode 100644
index 70c86b376f..0000000000
--- a/benchmark/bm_vm2_super.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-
-class C
- def m
- 1
- end
-end
-
-class CC < C
- def m
- super()
- end
-end
-
-obj = CC.new
-
-i = 0
-while i<6000000 # benchmark loop 2
- obj.m
- i+=1
-end
diff --git a/benchmark/bm_vm2_unif1.rb b/benchmark/bm_vm2_unif1.rb
deleted file mode 100644
index e12bd2ade0..0000000000
--- a/benchmark/bm_vm2_unif1.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-i = 0
-def m a, b
-end
-
-while i<6000000 # benchmark loop 2
- i+=1
- m 100, 200
-end
diff --git a/benchmark/bm_vm2_zsuper.rb b/benchmark/bm_vm2_zsuper.rb
deleted file mode 100644
index 3a75960403..0000000000
--- a/benchmark/bm_vm2_zsuper.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-i = 0
-
-class C
- def m a
- 1
- end
-end
-
-class CC < C
- def m a
- super
- end
-end
-
-obj = CC.new
-
-while i<6000000 # benchmark loop 2
- obj.m 10
- i+=1
-end
diff --git a/benchmark/bm_vm3_thread_create_join.rb b/benchmark/bm_vm3_thread_create_join.rb
deleted file mode 100644
index 325a66d587..0000000000
--- a/benchmark/bm_vm3_thread_create_join.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-i=0
-while i<100_000 # benchmark loop 3
- i+=1
- Thread.new{
- }.join
-end
diff --git a/benchmark/bm_vm3_thread_mutex.rb b/benchmark/bm_vm3_thread_mutex.rb
deleted file mode 100644
index 649f1fddac..0000000000
--- a/benchmark/bm_vm3_thread_mutex.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'thread'
-m = Mutex.new
-r = 0
-max = 1000
-(1..max).map{
- Thread.new{
- i=0
- while i<max
- i+=1
- m.synchronize{
- r += 1
- }
- end
- }
-}.each{|e|
- e.join
-}
-raise r.to_s if r != max * max
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
deleted file mode 100644
index 4a1afe360b..0000000000
--- a/benchmark/driver.rb
+++ /dev/null
@@ -1,253 +0,0 @@
-#
-# Ruby Benchmark driver
-#
-
-first = true
-
-p RUBY_VERSION
-
-begin
- require 'optparse'
-rescue LoadError
- if first
- first = false
- $:.unshift File.join(File.dirname(__FILE__), '../lib')
- retry
- else
- raise
- end
-end
-
-require 'benchmark'
-require 'pp'
-
-class BenchmarkDriver
- def self.benchmark(opt)
- driver = self.new(opt[:execs], opt[:dir], opt)
- begin
- driver.run
- ensure
- driver.show_results
- end
- end
-
- def output *args
- puts(*args)
- @output and @output.puts(*args)
- end
-
- def message *args
- output(*args) if @verbose
- end
-
- def message_print *args
- if @verbose
- print(*args)
- STDOUT.flush
- @output and @output.print(*args)
- end
- end
-
- def progress_message *args
- unless STDOUT.tty?
- STDERR.print(*args)
- STDERR.flush
- end
- end
-
- def initialize execs, dir, opt = {}
- @execs = execs.map{|e|
- e.strip!
- next if e.empty?
-
- if /(.+)::(.+)/ =~ e
- # ex) ruby-a::/path/to/ruby-a
- v = $1.strip
- e = $2
- else
- v = `#{e} -v`.chomp
- v.sub!(/ patchlevel \d+/, '')
- end
- [e, v]
- }.compact
-
- @dir = dir
- @repeat = opt[:repeat] || 1
- @repeat = 1 if @repeat < 1
- @pattern = opt[:pattern] || nil
- @verbose = opt[:quiet] ? false : (opt[:verbose] || false)
- @output = opt[:output] ? open(opt[:output], 'w') : nil
- @loop_wl1 = @loop_wl2 = nil
- @opt = opt
-
- # [[name, [[r-1-1, r-1-2, ...], [r-2-1, r-2-2, ...]]], ...]
- @results = []
-
- if @verbose
- @start_time = Time.now
- message @start_time
- @execs.each_with_index{|(e, v), i|
- message "target #{i}: #{v}"
- }
- end
- end
-
- def show_results
- output
-
- if @verbose
- message '-----------------------------------------------------------'
- message 'raw data:'
- message
- message PP.pp(@results, "", 79)
- message
- message "Elapesed time: #{Time.now - @start_time} (sec)"
- end
-
- output '-----------------------------------------------------------'
- output 'benchmark results:'
-
- if @verbose and @repeat > 1
- output "minimum results in each #{@repeat} measurements."
- end
-
- output "name\t#{@execs.map{|(e, v)| v}.join("\t")}"
- @results.each{|v, result|
- rets = []
- s = nil
- result.each_with_index{|e, i|
- r = e.min
- case v
- when /^vm1_/
- if @loop_wl1
- r -= @loop_wl1[i]
- s = '*'
- end
- when /^vm2_/
- if @loop_wl2
- r -= @loop_wl2[i]
- s = '*'
- end
- end
- rets << sprintf("%.3f", r)
- }
- output "#{v}#{s}\t#{rets.join("\t")}"
- }
- end
-
- def files
- flag = {}
- vm1 = vm2 = wl1 = wl2 = false
- @files = Dir.glob(File.join(@dir, 'bm*.rb')).map{|file|
- next if @pattern && /#{@pattern}/ !~ File.basename(file)
- case file
- when /bm_(vm[12])_/, /bm_loop_(whileloop2?).rb/
- flag[$1] = true
- end
- file
- }.compact
-
- if flag['vm1'] && !flag['whileloop']
- @files << File.join(@dir, 'bm_loop_whileloop.rb')
- elsif flag['vm2'] && !flag['whileloop2']
- @files << File.join(@dir, 'bm_loop_whileloop2.rb')
- end
-
- @files.sort!
- progress_message "total: #{@files.size * @repeat} trial(s) (#{@repeat} trial(s) for #{@files.size} benchmark(s))\n"
- @files
- end
-
- def run
- files.each_with_index{|file, i|
- @i = i
- r = measure_file(file)
-
- if /bm_loop_whileloop.rb/ =~ file
- @loop_wl1 = r[1].map{|e| e.min}
- elsif /bm_loop_whileloop2.rb/ =~ file
- @loop_wl2 = r[1].map{|e| e.min}
- end
- }
- end
-
- def measure_file file
- name = File.basename(file, '.rb').sub(/^bm_/, '')
- prepare_file = File.join(File.dirname(file), "prepare_#{name}.rb")
- load prepare_file if FileTest.exist?(prepare_file)
-
- if @verbose
- output
- output '-----------------------------------------------------------'
- output name
- output
- output File.read(file)
- output
- end
-
- result = [name]
- result << @execs.map{|(e, v)|
- (0...@repeat).map{
- message_print "#{v}\t"
- progress_message '.'
-
- m = measure(e, file)
- message "#{m}"
- m
- }
- }
- @results << result
- result
- end
-
- def measure executable, file
- cmd = "#{executable} #{file}"
- m = Benchmark.measure{
- `#{cmd}`
- }
-
- if $? != 0
- raise "Benchmark process exited with abnormal status (#{$?})"
- end
-
- m.real
- end
-end
-
-if __FILE__ == $0
- opt = {
- :execs => ['ruby'],
- :dir => './',
- :repeat => 1,
- :output => "bmlog-#{Time.now.strftime('%Y%m%d-%H%M%S')}.#{$$}",
- }
-
- parser = OptionParser.new{|o|
- o.on('-e', '--executables [EXECS]',
- "Specify benchmark one or more targets. (exec1; exec2; exec3, ...)"){|e|
- opt[:execs] = e.split(/;/)
- }
- o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d|
- opt[:dir] = d
- }
- o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p|
- opt[:pattern] = p
- }
- o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n|
- opt[:repeat] = n.to_i
- }
- o.on('-o', '--output-file [FILE]', "Output file"){|o|
- opt[:output] = o
- }
- o.on('-q', '--quiet', "Run without notify information except result table."){|q|
- opt[:quiet] = q
- }
- o.on('-v', '--verbose'){|v|
- opt[:verbose] = v
- }
- }
-
- parser.parse!(ARGV)
- BenchmarkDriver.benchmark(opt)
-end
-
diff --git a/benchmark/make_fasta_output.rb b/benchmark/make_fasta_output.rb
deleted file mode 100644
index b6d787ae27..0000000000
--- a/benchmark/make_fasta_output.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# prepare 'fasta.output'
-
-def prepare_fasta_output n
- filebase = File.join(File.dirname($0), 'fasta.output')
- script = File.join(File.dirname($0), 'bm_so_fasta.rb')
- file = "#{filebase}.#{n}"
-
- unless FileTest.exist?(file)
- STDERR.puts "preparing #{file}"
-
- open(file, 'w'){|f|
- ARGV[0] = n
- $stdout = f
- load script
- $stdout = STDOUT
- }
- end
-end
-
diff --git a/benchmark/other-lang/ack.pl b/benchmark/other-lang/ack.pl
deleted file mode 100644
index 201e22ddfa..0000000000
--- a/benchmark/other-lang/ack.pl
+++ /dev/null
@@ -1,11 +0,0 @@
-use integer;
-
-sub Ack {
- return $_[0] ? ($_[1] ? Ack($_[0]-1, Ack($_[0], $_[1]-1))
- : Ack($_[0]-1, 1))
- : $_[1]+1;
-}
-
-my $NUM = 9;
-$NUM = 1 if ($NUM < 1);
-my $ack = Ack(3, $NUM);
diff --git a/benchmark/other-lang/ack.py b/benchmark/other-lang/ack.py
deleted file mode 100644
index 9968e7cfcf..0000000000
--- a/benchmark/other-lang/ack.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import sys
-sys.setrecursionlimit(5000000)
-
-def Ack(M, N):
- if (not M):
- return( N + 1 )
- if (not N):
- return( Ack(M-1, 1) )
- return( Ack(M-1, Ack(M, N-1)) )
-
-def main():
- NUM = 9
- sys.setrecursionlimit(10000)
- Ack(3, NUM)
-
-main()
diff --git a/benchmark/other-lang/ack.rb b/benchmark/other-lang/ack.rb
deleted file mode 100644
index 7451bed6c4..0000000000
--- a/benchmark/other-lang/ack.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-def ack(m, n)
- if m == 0 then
- n + 1
- elsif n == 0 then
- ack(m - 1, 1)
- else
- ack(m - 1, ack(m, n - 1))
- end
-end
-
-NUM = 9
-ack(3, NUM)
diff --git a/benchmark/other-lang/ack.scm b/benchmark/other-lang/ack.scm
deleted file mode 100644
index a80b73ba55..0000000000
--- a/benchmark/other-lang/ack.scm
+++ /dev/null
@@ -1,7 +0,0 @@
-(define (ack m n)
- (cond ((zero? m) (+ n 1))
- ((zero? n) (ack (- m 1) 1))
- (else (ack (- m 1) (ack m (- n 1))))))
-
-(ack 3 9)
-
diff --git a/benchmark/other-lang/eval.rb b/benchmark/other-lang/eval.rb
deleted file mode 100644
index 3875927389..0000000000
--- a/benchmark/other-lang/eval.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-
-Bench = %w(
- loop
- ack
- fib
- tak
- fact
-)
-
-Lang = <<EOP.map{|l| l.strip}
- ruby-cyg
- ../../../test6/miniruby
- perl
- python
- gosh
-EOP
-
-Bench.replace ['loop2']
-Lang.replace ['ruby-cyg']
-
-Ext = %w(
- .rb
- .rb
- .pl
- .py
- .scm
-)
-
-p Bench
-p Lang
-
-require 'benchmark'
-
-def bench cmd
- m = Benchmark.measure{
- #p cmd
- system(cmd)
- }
- [m.utime, m.real]
-end
-
-Result = []
-Bench.each{|b|
- r = []
- Lang.each_with_index{|l, idx|
- cmd = "#{l} #{b}#{Ext[idx]}"
- r << bench(cmd)
- }
- Result << r
-}
-
-require 'pp'
-# utime
-puts Lang.join("\t")
-Bench.each_with_index{|b, bi|
- print b, "\t"
- puts Result[bi].map{|e| e[0]}.join("\t")
-}
-
-# rtime
-puts Lang.join("\t")
-Bench.each_with_index{|b, bi|
- print b, "\t"
- puts Result[bi].map{|e| e[1]}.join("\t")
-}
-
diff --git a/benchmark/other-lang/fact.pl b/benchmark/other-lang/fact.pl
deleted file mode 100644
index a9b0b69cdf..0000000000
--- a/benchmark/other-lang/fact.pl
+++ /dev/null
@@ -1,13 +0,0 @@
-sub fact{
- my $n = @_[0];
- if($n < 2){
- return 1;
- }
- else{
- return $n * fact($n-1);
- }
-}
-
-for($i=0; $i<10000; $i++){
- &fact(100);
-}
diff --git a/benchmark/other-lang/fact.py b/benchmark/other-lang/fact.py
deleted file mode 100644
index 01593965d9..0000000000
--- a/benchmark/other-lang/fact.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#import sys
-#sys.setrecursionlimit(1000)
-
-def factL(n):
- r = 1
- for x in range(2, n):
- r *= x
- return r
-
-def factR(n):
- if n < 2:
- return 1
- else:
- return n * factR(n-1)
-
-for i in range(10000):
- factR(100)
-
diff --git a/benchmark/other-lang/fact.rb b/benchmark/other-lang/fact.rb
deleted file mode 100644
index 7e97b22b39..0000000000
--- a/benchmark/other-lang/fact.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-def fact(n)
- if n < 2
- 1
- else
- n * fact(n-1)
- end
-end
-
-i=0
-while i<10000
- i+=1
- fact(100)
-end
diff --git a/benchmark/other-lang/fact.scm b/benchmark/other-lang/fact.scm
deleted file mode 100644
index c98a7fedd3..0000000000
--- a/benchmark/other-lang/fact.scm
+++ /dev/null
@@ -1,8 +0,0 @@
-(define (fact n)
- (if (< n 2)
- 1
- (* n (fact (- n 1)))))
-
-(dotimes (i 10000)
- (fact 100))
-
diff --git a/benchmark/other-lang/fib.pl b/benchmark/other-lang/fib.pl
deleted file mode 100644
index a46f666d1e..0000000000
--- a/benchmark/other-lang/fib.pl
+++ /dev/null
@@ -1,11 +0,0 @@
-sub fib{
- my $n = $_[0];
- if($n < 3){
- return 1;
- }
- else{
- return fib($n-1) + fib($n-2);
- }
-};
-
-&fib(34);
diff --git a/benchmark/other-lang/fib.py b/benchmark/other-lang/fib.py
deleted file mode 100644
index 45f2bceb8d..0000000000
--- a/benchmark/other-lang/fib.py
+++ /dev/null
@@ -1,7 +0,0 @@
-def fib(n):
- if n < 3:
- return 1
- else:
- return fib(n-1) + fib(n-2)
-
-fib(34)
diff --git a/benchmark/other-lang/fib.rb b/benchmark/other-lang/fib.rb
deleted file mode 100644
index ec587eabe0..0000000000
--- a/benchmark/other-lang/fib.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-def fib n
- if n < 3
- 1
- else
- fib(n-1) + fib(n-2)
- end
-end
-
-fib(34)
diff --git a/benchmark/other-lang/fib.scm b/benchmark/other-lang/fib.scm
deleted file mode 100644
index 2fc4e225bd..0000000000
--- a/benchmark/other-lang/fib.scm
+++ /dev/null
@@ -1,7 +0,0 @@
-(define (fib n)
- (if (< n 3)
- 1
- (+ (fib (- n 1)) (fib (- n 2)))))
-
-(fib 34)
-
diff --git a/benchmark/other-lang/loop.pl b/benchmark/other-lang/loop.pl
deleted file mode 100644
index 2777490aaa..0000000000
--- a/benchmark/other-lang/loop.pl
+++ /dev/null
@@ -1,3 +0,0 @@
-for($i=0; $i<30000000; $i++){
-}
-
diff --git a/benchmark/other-lang/loop.py b/benchmark/other-lang/loop.py
deleted file mode 100644
index 003749bf3a..0000000000
--- a/benchmark/other-lang/loop.py
+++ /dev/null
@@ -1,2 +0,0 @@
-for i in xrange(30000000):
- pass
diff --git a/benchmark/other-lang/loop.rb b/benchmark/other-lang/loop.rb
deleted file mode 100644
index d43cef61f3..0000000000
--- a/benchmark/other-lang/loop.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-i=0
-while i<30000000
- i+=1
-end
diff --git a/benchmark/other-lang/loop.scm b/benchmark/other-lang/loop.scm
deleted file mode 100644
index 3364f7e679..0000000000
--- a/benchmark/other-lang/loop.scm
+++ /dev/null
@@ -1 +0,0 @@
-(dotimes (x 30000000))
diff --git a/benchmark/other-lang/loop2.rb b/benchmark/other-lang/loop2.rb
deleted file mode 100644
index df8fffc1ff..0000000000
--- a/benchmark/other-lang/loop2.rb
+++ /dev/null
@@ -1 +0,0 @@
-30000000.times{}
diff --git a/benchmark/other-lang/tak.pl b/benchmark/other-lang/tak.pl
deleted file mode 100644
index 7e748a67c6..0000000000
--- a/benchmark/other-lang/tak.pl
+++ /dev/null
@@ -1,11 +0,0 @@
-sub tak {
- local($x, $y, $z) = @_;
- if (!($y < $x)) {
- return $z;
- } else {
- return &tak(&tak($x - 1, $y, $z),
- &tak($y - 1, $z, $x),
- &tak($z - 1, $x, $y));
- }
-}
-&tak(18, 9, 0);
diff --git a/benchmark/other-lang/tak.py b/benchmark/other-lang/tak.py
deleted file mode 100644
index 04f3f6829c..0000000000
--- a/benchmark/other-lang/tak.py
+++ /dev/null
@@ -1,8 +0,0 @@
-def tak(x, y, z):
- if not(y<x):
- return z
- else:
- return tak(tak(x-1, y, z),
- tak(y-1, z, x),
- tak(z-1, x, y))
-tak(18, 9, 0)
diff --git a/benchmark/other-lang/tak.rb b/benchmark/other-lang/tak.rb
deleted file mode 100644
index efe5380f4e..0000000000
--- a/benchmark/other-lang/tak.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-def tak x, y, z
- unless y < x
- z
- else
- tak( tak(x-1, y, z),
- tak(y-1, z, x),
- tak(z-1, x, y))
- end
-end
-
-tak(18, 9, 0)
-
diff --git a/benchmark/other-lang/tak.scm b/benchmark/other-lang/tak.scm
deleted file mode 100644
index 52a7629ee5..0000000000
--- a/benchmark/other-lang/tak.scm
+++ /dev/null
@@ -1,10 +0,0 @@
-(define (tak x y z)
- (if (not (< y x))
- z
- (tak (tak (- x 1) y z)
- (tak (- y 1) z x)
- (tak (- z 1) x y))))
-
-(tak 18 9 0)
-
-
diff --git a/benchmark/prepare_so_count_words.rb b/benchmark/prepare_so_count_words.rb
deleted file mode 100644
index ee2138cdb2..0000000000
--- a/benchmark/prepare_so_count_words.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# prepare 'wc.input'
-
-def prepare_wc_input
- wcinput = File.join(File.dirname($0), 'wc.input')
- wcbase = File.join(File.dirname($0), 'wc.input.base')
- unless FileTest.exist?(wcinput)
- data = File.read(wcbase)
- 13.times{
- data << data
- }
- open(wcinput, 'w'){|f| f.write data}
- end
-end
-
-prepare_wc_input
diff --git a/benchmark/prepare_so_k_nucleotide.rb b/benchmark/prepare_so_k_nucleotide.rb
deleted file mode 100644
index f28f4460a1..0000000000
--- a/benchmark/prepare_so_k_nucleotide.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require File.join(File.dirname(__FILE__), 'make_fasta_output')
-prepare_fasta_output(100_000)
diff --git a/benchmark/prepare_so_reverse_complement.rb b/benchmark/prepare_so_reverse_complement.rb
deleted file mode 100644
index 7f089109de..0000000000
--- a/benchmark/prepare_so_reverse_complement.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require File.join(File.dirname(__FILE__), 'make_fasta_output')
-prepare_fasta_output(2_500_000)
diff --git a/benchmark/report.rb b/benchmark/report.rb
deleted file mode 100644
index 8305330b45..0000000000
--- a/benchmark/report.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-#
-# YARV benchmark driver
-#
-
-require 'yarvutil'
-require 'benchmark'
-require 'rbconfig'
-
-def exec_command type, file, w
- <<-EOP
- $DRIVER_PATH = '#{File.dirname($0)}'
- $LOAD_PATH.replace $LOAD_PATH | #{$LOAD_PATH.inspect}
- require 'benchmark'
- require 'yarvutil'
-# print '#{type}'
- begin
- puts Benchmark.measure{
- #{w}('#{file}')
- }.utime
- rescue Exception => exec_command_error_variable
- puts "\t" + exec_command_error_variable.message
- end
- EOP
-end
-
-def benchmark cmd
- rubybin = ENV['RUBY'] || File.join(
- Config::CONFIG["bindir"],
- Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"])
-
- IO.popen(rubybin, 'r+'){|io|
- io.write cmd
- io.close_write
- return io.gets
- }
-end
-
-def ruby_exec file
- prog = exec_command 'ruby', file, 'load'
- benchmark prog
-end
-
-def yarv_exec file
- prog = exec_command 'yarv', file, 'YARVUtil.load_bm'
- benchmark prog
-end
-
-$wr = $wy = nil
-
-def measure bench
- file = File.dirname($0) + "/bm_#{bench}.rb"
- r = ruby_exec(file).to_f
- y = yarv_exec(file).to_f
- puts "#{bench}\t#{r}\t#{y}"
-end
-
-def measure2
- r = ruby_exec.to_f
- y = yarv_exec.to_f
- puts r/y
-end
-
-if $0 == __FILE__
- %w{
- whileloop
- whileloop2
- times
- const
- method
- poly_method
- block
- rescue
- rescue2
- }.each{|bench|
- measure bench
- }
-end
-
-
-
-
diff --git a/benchmark/run.rb b/benchmark/run.rb
deleted file mode 100644
index 6ef2943642..0000000000
--- a/benchmark/run.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-#
-# Ruby benchmark driver
-#
-
-require 'benchmark'
-require 'rbconfig'
-
-$matzrubyonly = false
-$rubyonly = false
-
-$results = []
-
-# prepare 'wc.input'
-def prepare_wc_input
- wcinput = File.join(File.dirname($0), 'wc.input')
- wcbase = File.join(File.dirname($0), 'wc.input.base')
- unless FileTest.exist?(wcinput)
- data = File.read(wcbase)
- 13.times{
- data << data
- }
- open(wcinput, 'w'){|f| f.write data}
- end
-end
-
-prepare_wc_input
-
-def bm file
- prog = File.readlines(file).map{|e| e.rstrip}.join("\n")
- return if prog.empty?
-
- /[a-z]+_(.+)\.rb/ =~ file
- bm_name = $1
- puts '-----------------------------------------------------------' unless $rubyonly || $matzrubyonly
- puts "#{bm_name}: "
-
-
-puts <<EOS unless $matzrubyonly || $rubyonly
-#{prog}
---
-EOS
- begin
- result = [bm_name]
- result << matzruby_exec(file) unless $rubyonly
- result << ruby_exec(file) unless $matzrubyonly
- $results << result
-
- rescue Exception => e
- puts
- puts "** benchmark failure: #{e}"
- puts e.backtrace
- end
-end
-
-def benchmark file, bin
- m = Benchmark.measure{
- `#{bin} #{$opts} #{file}`
- }
- sec = '%.3f' % m.real
- puts " #{sec}"
- sec
-end
-
-def ruby_exec file
- print 'ruby'
- benchmark file, $ruby_program
-end
-
-def matzruby_exec file
- print 'matz'
- rubylib = ENV['RUBYLIB']
- ENV['RUBYLIB'] = ''
- r = benchmark file, $matzruby_program
- ENV['RUBYLIB'] = rubylib
- r
-end
-
-if $0 == __FILE__
- ARGV.each{|arg|
- case arg
- when /\A--ruby=(.+)/
- $ruby_program = $1
- when /\A--matzruby=(.+)/
- $matzruby_program = $1
- when /\A--opts=(.+)/
- $opts = $1
- when /\A(-r|--only-ruby)\z/
- $rubyonly = true
- when /\A(-m|--only-matzruby)\z/
- $matzrubyonly = true
- end
- }
- ARGV.delete_if{|arg|
- /\A-/ =~ arg
- }
-
- puts "MatzRuby:"
- system("#{$matzruby_program} -v")
- puts "Ruby:"
- system("#{$ruby_program} -v")
- puts
-
- if ARGV.empty?
- Dir.glob(File.dirname(__FILE__) + '/bm_*.rb').sort.each{|file|
- bm file
- }
- else
- ARGV.each{|file|
- Dir.glob(File.join(File.dirname(__FILE__), file + '*')){|ef|
- # file = "#{File.dirname(__FILE__)}/#{file}.rb"
- bm ef
- }
- }
- end
-
- puts
- puts "-- benchmark summary ---------------------------"
- $results.each{|res|
- print res.shift, "\t"
- (res||[]).each{|result|
- /([\d\.]+)/ =~ result
- print $1 + "\t" if $1
- }
- puts
- }
-end
-
diff --git a/benchmark/runc.rb b/benchmark/runc.rb
deleted file mode 100644
index 14ab171c12..0000000000
--- a/benchmark/runc.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#
-#
-
-require 'benchmark'
-require 'rbconfig'
-
-$rubybin = ENV['RUBY'] || File.join(
- Config::CONFIG["bindir"],
- Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"])
-
-def runfile file
- puts file
- file = File.join(File.dirname($0), 'contrib', file)
- Benchmark.bm{|x|
- x.report('ruby'){
- system("#{$rubybin} #{file}")
- }
- x.report('yarv'){
- system("#{$rubybin} -rite -I.. #{file}")
- }
- }
-end
-
-ARGV.each{|file|
- runfile file
-}
-
-
diff --git a/benchmark/wc.input.base b/benchmark/wc.input.base
deleted file mode 100644
index 41143fbac0..0000000000
--- a/benchmark/wc.input.base
+++ /dev/null
@@ -1,25 +0,0 @@
-Subject: Re: Who was Izchak Miller?
-From: "Jane D. Anonymous" <nobody@yale.edu>
-Date: 1996/04/28
-Message-Id: <4lv7bc$oh@news.ycc.yale.edu>
-References: <317C405E.5DFA@panix.com> <4lk6vl$gde@ns.oar.net>
-To: 75176.2330@compuserve.com
-Content-Type: text/plain; charset=us-ascii
-Organization: Yale University
-X-Url: news:4lk6vl$gde@ns.oar.net
-Mime-Version: 1.0
-Newsgroups: rec.games.roguelike.nethack
-X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
-
-Hello there, Izchak Miller was my father. When I was younger I spent
-many a night, hunched over the keyboard with a cup of tea, playing
-nethack with him and my brother. my dad was a philosopher with a strong
-weakness for fantasy/sci fi. I remember when he started to get involved
-with the Nethack team- my brother's Dungeons and Dragons monster book
-found a regular place beside my dad's desk. it's nice to see him living
-on in the game he loved so much :-).
- Tamar Miller
-
-The following is a really long word of 5000 characters:
-
-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
diff --git a/bignum.c b/bignum.c
index 490944aa76..7f14aee709 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6,11 +6,12 @@
$Date$
created at: Fri Jun 10 00:48:55 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
+#include "rubysig.h"
#include <math.h>
#include <float.h>
@@ -25,7 +26,7 @@ VALUE rb_cBignum;
#define USHORT _USHORT
#endif
-#define BDIGITS(x) (RBIGNUM_DIGITS(x))
+#define BDIGITS(x) ((BDIGIT*)RBIGNUM(x)->digits)
#define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT)
#define BIGRAD ((BDIGIT_DBL)1 << BITSPERDIG)
#define DIGSPERLONG ((unsigned int)(SIZEOF_LONG/SIZEOF_BDIGITS))
@@ -37,68 +38,33 @@ VALUE rb_cBignum;
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
#define BDIGMAX ((BDIGIT)-1)
-#define BIGZEROP(x) (RBIGNUM_LEN(x) == 0 || (RBIGNUM_LEN(x) == 1 && BDIGITS(x)[0] == 0))
+#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || \
+ (BDIGITS(x)[0] == 0 && \
+ (RBIGNUM(x)->len == 1 || bigzero_p(x))))
-#define RBIGNUM_SET_LEN(b,l) \
- ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
- (RBASIC(b)->flags = (RBASIC(b)->flags & ~RBIGNUM_EMBED_LEN_MASK) | \
- ((l) << RBIGNUM_EMBED_LEN_SHIFT)) : \
- (RBIGNUM(b)->as.heap.len = (l)))
-
-static void
-rb_big_realloc(VALUE big, long len)
+static int bigzero_p(VALUE);
+static int
+bigzero_p(x)
+ VALUE x;
{
- BDIGIT *ds;
- if (RBASIC(big)->flags & RBIGNUM_EMBED_FLAG) {
- if (RBIGNUM_EMBED_LEN_MAX < len) {
- ds = ALLOC_N(BDIGIT, len);
- MEMCPY(ds, RBIGNUM(big)->as.ary, BDIGIT, RBIGNUM_EMBED_LEN_MAX);
- RBIGNUM(big)->as.heap.len = RBIGNUM_LEN(big);
- RBIGNUM(big)->as.heap.digits = ds;
- RBASIC(big)->flags &= ~RBIGNUM_EMBED_FLAG;
- }
- }
- else {
- if (len <= RBIGNUM_EMBED_LEN_MAX) {
- ds = RBIGNUM(big)->as.heap.digits;
- RBASIC(big)->flags |= RBIGNUM_EMBED_FLAG;
- RBIGNUM_SET_LEN(big, len);
- if (ds) {
- MEMCPY(RBIGNUM(big)->as.ary, ds, BDIGIT, len);
- free(ds);
- }
- }
- else {
- if (RBIGNUM_LEN(big) == 0) {
- RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len);
- }
- else {
- REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len);
- }
- }
+ long i;
+ for (i = 0; i < RBIGNUM(x)->len; ++i) {
+ if (BDIGITS(x)[i]) return 0;
}
-}
-
-void
-rb_big_resize(VALUE big, long len)
-{
- rb_big_realloc(big, len);
- RBIGNUM_SET_LEN(big, len);
+ return 1;
}
static VALUE
-bignew_1(VALUE klass, long len, int sign)
+bignew_1(klass, len, sign)
+ VALUE klass;
+ long len;
+ int sign;
{
NEWOBJ(big, struct RBignum);
OBJSETUP(big, klass, T_BIGNUM);
- RBIGNUM_SET_SIGN(big, sign?1:0);
- if (len <= RBIGNUM_EMBED_LEN_MAX) {
- RBASIC(big)->flags |= RBIGNUM_EMBED_FLAG;
- RBIGNUM_SET_LEN(big, len);
- }
- else {
- rb_big_resize((VALUE)big, len);
- }
+ big->sign = sign?1:0;
+ big->len = len;
+ big->digits = ALLOC_N(BDIGIT, len);
return (VALUE)big;
}
@@ -106,19 +72,21 @@ bignew_1(VALUE klass, long len, int sign)
#define bignew(len,sign) bignew_1(rb_cBignum,len,sign)
VALUE
-rb_big_clone(VALUE x)
+rb_big_clone(x)
+ VALUE x;
{
- VALUE z = bignew_1(CLASS_OF(x), RBIGNUM_LEN(x), RBIGNUM_SIGN(x));
+ VALUE z = bignew_1(CLASS_OF(x), RBIGNUM(x)->len, RBIGNUM(x)->sign);
- MEMCPY(BDIGITS(z), BDIGITS(x), BDIGIT, RBIGNUM_LEN(x));
+ MEMCPY(BDIGITS(z), BDIGITS(x), BDIGIT, RBIGNUM(x)->len);
return z;
}
/* modify a bignum by 2's complement */
static void
-get2comp(VALUE x)
+get2comp(x)
+ VALUE x;
{
- long i = RBIGNUM_LEN(x);
+ long i = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
BDIGIT_DBL num;
@@ -129,45 +97,48 @@ get2comp(VALUE x)
num += ds[i];
ds[i++] = BIGLO(num);
num = BIGDN(num);
- } while (i < RBIGNUM_LEN(x));
+ } while (i < RBIGNUM(x)->len);
if (num != 0) {
- rb_big_resize(x, RBIGNUM_LEN(x)+1);
+ REALLOC_N(RBIGNUM(x)->digits, BDIGIT, ++RBIGNUM(x)->len);
ds = BDIGITS(x);
- ds[RBIGNUM_LEN(x)-1] = 1;
+ ds[RBIGNUM(x)->len-1] = RBIGNUM(x)->sign ? ~0 : 1;
}
}
void
-rb_big_2comp(VALUE x) /* get 2's complement */
+rb_big_2comp(x) /* get 2's complement */
+ VALUE x;
{
get2comp(x);
}
static VALUE
-bigtrunc(VALUE x)
+bigtrunc(x)
+ VALUE x;
{
- long len = RBIGNUM_LEN(x);
+ long len = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
if (len == 0) return x;
while (--len && !ds[len]);
- rb_big_resize(x, len+1);
+ RBIGNUM(x)->len = ++len;
return x;
}
static VALUE
-bigfixize(VALUE x)
+bigfixize(x)
+ VALUE x;
{
- long len = RBIGNUM_LEN(x);
+ long len = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
- if (len*SIZEOF_BDIGITS <= sizeof(long)) {
+ if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
long num = 0;
while (len--) {
num = BIGUP(num) + ds[len];
}
if (num >= 0) {
- if (RBIGNUM_SIGN(x)) {
+ if (RBIGNUM(x)->sign) {
if (POSFIXABLE(num)) return LONG2FIX(num);
}
else {
@@ -179,7 +150,8 @@ bigfixize(VALUE x)
}
static VALUE
-bignorm(VALUE x)
+bignorm(x)
+ VALUE x;
{
if (!FIXNUM_P(x) && TYPE(x) == T_BIGNUM) {
x = bigfixize(bigtrunc(x));
@@ -188,13 +160,15 @@ bignorm(VALUE x)
}
VALUE
-rb_big_norm(VALUE x)
+rb_big_norm(x)
+ VALUE x;
{
return bignorm(x);
}
VALUE
-rb_uint2big(VALUE n)
+rb_uint2big(n)
+ unsigned long n;
{
BDIGIT_DBL num = n;
long i = 0;
@@ -210,12 +184,13 @@ rb_uint2big(VALUE n)
i = DIGSPERLONG;
while (--i && !digits[i]) ;
- RBIGNUM_SET_LEN(big, i+1);
+ RBIGNUM(big)->len = i+1;
return big;
}
VALUE
-rb_int2big(SIGNED_VALUE n)
+rb_int2big(n)
+ long n;
{
long neg = 0;
VALUE big;
@@ -226,20 +201,22 @@ rb_int2big(SIGNED_VALUE n)
}
big = rb_uint2big(n);
if (neg) {
- RBIGNUM_SET_SIGN(big, 0);
+ RBIGNUM(big)->sign = 0;
}
return big;
}
VALUE
-rb_uint2inum(VALUE n)
+rb_uint2inum(n)
+ unsigned long n;
{
if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_uint2big(n);
}
VALUE
-rb_int2inum(SIGNED_VALUE n)
+rb_int2inum(n)
+ long n;
{
if (FIXABLE(n)) return LONG2FIX(n);
return rb_int2big(n);
@@ -248,7 +225,9 @@ rb_int2inum(SIGNED_VALUE n)
#ifdef HAVE_LONG_LONG
void
-rb_quad_pack(char *buf, VALUE val)
+rb_quad_pack(buf, val)
+ char *buf;
+ VALUE val;
{
LONG_LONG q;
@@ -257,25 +236,26 @@ rb_quad_pack(char *buf, VALUE val)
q = FIX2LONG(val);
}
else {
- long len = RBIGNUM_LEN(val);
+ long len = RBIGNUM(val)->len;
BDIGIT *ds;
- if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS) {
- len = SIZEOF_LONG_LONG/SIZEOF_BDIGITS;
- }
+ if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS)
+ rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
ds = BDIGITS(val);
q = 0;
while (len--) {
q = BIGUP(q);
q += ds[len];
}
- if (!RBIGNUM_SIGN(val)) q = -q;
+ if (!RBIGNUM(val)->sign) q = -q;
}
memcpy(buf, (char*)&q, SIZEOF_LONG_LONG);
}
VALUE
-rb_quad_unpack(const char *buf, int sign)
+rb_quad_unpack(buf, sign)
+ const char *buf;
+ int sign;
{
unsigned LONG_LONG q;
long neg = 0;
@@ -305,10 +285,10 @@ rb_quad_unpack(const char *buf, int sign)
i = DIGSPERLL;
while (i-- && !digits[i]) ;
- RBIGNUM_SET_LEN(big, i+1);
+ RBIGNUM(big)->len = i+1;
if (neg) {
- RBIGNUM_SET_SIGN(big, 0);
+ RBIGNUM(big)->sign = 0;
}
return bignorm(big);
}
@@ -318,7 +298,9 @@ rb_quad_unpack(const char *buf, int sign)
#define QUAD_SIZE 8
void
-rb_quad_pack(char *buf, VALUE val)
+rb_quad_pack(buf, val)
+ char *buf;
+ VALUE val;
{
long len;
@@ -327,12 +309,12 @@ rb_quad_pack(char *buf, VALUE val)
if (FIXNUM_P(val)) {
val = rb_int2big(FIX2LONG(val));
}
- len = RBIGNUM_LEN(val) * SIZEOF_BDIGITS;
+ len = RBIGNUM(val)->len * SIZEOF_BDIGITS;
if (len > QUAD_SIZE) {
rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
}
memcpy(buf, (char*)BDIGITS(val), len);
- if (!RBIGNUM_SIGN(val)) {
+ if (!RBIGNUM(val)->sign) {
len = QUAD_SIZE;
while (len--) {
*buf = ~*buf;
@@ -344,7 +326,9 @@ rb_quad_pack(char *buf, VALUE val)
#define BNEG(b) (RSHIFT(((BDIGIT*)b)[QUAD_SIZE/SIZEOF_BDIGITS-1],BITSPERDIG-1) != 0)
VALUE
-rb_quad_unpack(const char *buf, int sign)
+rb_quad_unpack(buf, sign)
+ const char *buf;
+ int sign;
{
VALUE big = bignew(QUAD_SIZE/SIZEOF_BDIGITS, 1);
@@ -353,7 +337,7 @@ rb_quad_unpack(const char *buf, int sign)
long len = QUAD_SIZE;
char *tmp = (char*)BDIGITS(big);
- RBIGNUM_SET_SIGN(big, 0);
+ RBIGNUM(big)->sign = 0;
while (len--) {
*tmp = ~*tmp;
tmp++;
@@ -366,7 +350,10 @@ rb_quad_unpack(const char *buf, int sign)
#endif
VALUE
-rb_cstr_to_inum(const char *str, int base, int badcheck)
+rb_cstr_to_inum(str, base, badcheck)
+ const char *str;
+ int base;
+ int badcheck;
{
const char *s = str;
char *end;
@@ -389,7 +376,12 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
if (badcheck) goto bad;
return INT2FIX(0);
}
- while (ISSPACE(*str)) str++;
+ if (badcheck) {
+ while (ISSPACE(*str)) str++;
+ }
+ else {
+ while (ISSPACE(*str) || *str == '_') str++;
+ }
if (str[0] == '+') {
str++;
@@ -439,7 +431,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
len = 2;
break;
case 8:
- if (str[0] == '0' && (str[1] == 'o'||str[1] == 'O'||str[1] == '_')) {
+ if (str[0] == '0' && (str[1] == 'o'||str[1] == 'O')) {
str += 2;
}
case 4: case 5: case 6: case 7:
@@ -460,7 +452,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
break;
default:
if (base < 2 || 36 < base) {
- rb_raise(rb_eArgError, "invalid radix %d", base);
+ rb_raise(rb_eArgError, "illegal radix %d", base);
}
if (base <= 32) {
len = 5;
@@ -471,7 +463,14 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
break;
}
if (*str == '0') { /* squeeze preceeding 0s */
- while (*++str == '0');
+ int us = 0;
+ while ((c = *++str) == '0' || c == '_') {
+ if (c == '_') {
+ if (++us >= 2)
+ break;
+ } else
+ us = 0;
+ }
if (!(c = *str) || ISSPACE(c)) --str;
}
c = *str;
@@ -482,10 +481,10 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
}
len *= strlen(str)*sizeof(char);
- if (len <= (sizeof(long)*CHAR_BIT)) {
- unsigned long val = strtoul(str, &end, base);
+ if (len <= (sizeof(VALUE)*CHAR_BIT)) {
+ unsigned long val = strtoul((char*)str, &end, base);
- if (str < end && *end == '_') goto bigparse;
+ if (*end == '_') goto bigparse;
if (badcheck) {
if (end == str) goto bad; /* no number */
while (*end && ISSPACE(*end)) end++;
@@ -501,7 +500,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
}
else {
VALUE big = rb_uint2big(val);
- RBIGNUM_SET_SIGN(big, sign);
+ RBIGNUM(big)->sign = sign;
return bignorm(big);
}
}
@@ -514,10 +513,11 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
for (i=len;i--;) zds[i]=0;
while ((c = *str++) != 0) {
if (c == '_') {
- if (badcheck) {
- if (nondigit) goto bad;
- nondigit = c;
+ if (nondigit) {
+ if (badcheck) goto bad;
+ break;
}
+ nondigit = c;
continue;
}
else if ((c = conv_digit(c)) < 0) {
@@ -554,7 +554,10 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
}
VALUE
-rb_str_to_inum(VALUE str, int base, int badcheck)
+rb_str_to_inum(str, base, badcheck)
+ VALUE str;
+ int base;
+ int badcheck;
{
char *s;
long len;
@@ -564,10 +567,10 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
s = StringValueCStr(str);
}
else {
- s = RSTRING_PTR(str);
+ s = RSTRING(str)->ptr;
}
if (s) {
- len = RSTRING_LEN(str);
+ len = RSTRING(str)->len;
if (s[len]) { /* no sentinel somehow */
char *p = ALLOCA_N(char, len+1);
@@ -581,8 +584,9 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
#if HAVE_LONG_LONG
-static VALUE
-rb_ull2big(unsigned LONG_LONG n)
+VALUE
+rb_ull2big(n)
+ unsigned LONG_LONG n;
{
BDIGIT_DBL num = n;
long i = 0;
@@ -598,12 +602,13 @@ rb_ull2big(unsigned LONG_LONG n)
i = DIGSPERLL;
while (i-- && !digits[i]) ;
- RBIGNUM_SET_LEN(big, i+1);
+ RBIGNUM(big)->len = i+1;
return big;
}
-static VALUE
-rb_ll2big(LONG_LONG n)
+VALUE
+rb_ll2big(n)
+ LONG_LONG n;
{
long neg = 0;
VALUE big;
@@ -614,20 +619,22 @@ rb_ll2big(LONG_LONG n)
}
big = rb_ull2big(n);
if (neg) {
- RBIGNUM_SET_SIGN(big, 0);
+ RBIGNUM(big)->sign = 0;
}
return big;
}
VALUE
-rb_ull2inum(unsigned LONG_LONG n)
+rb_ull2inum(n)
+ unsigned LONG_LONG n;
{
if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_ull2big(n);
}
VALUE
-rb_ll2inum(LONG_LONG n)
+rb_ll2inum(n)
+ LONG_LONG n;
{
if (FIXABLE(n)) return LONG2FIX(n);
return rb_ll2big(n);
@@ -636,304 +643,115 @@ rb_ll2inum(LONG_LONG n)
#endif /* HAVE_LONG_LONG */
VALUE
-rb_cstr2inum(const char *str, int base)
+rb_cstr2inum(str, base)
+ const char *str;
+ int base;
{
return rb_cstr_to_inum(str, base, base==0);
}
VALUE
-rb_str2inum(VALUE str, int base)
+rb_str2inum(str, base)
+ VALUE str;
+ int base;
{
return rb_str_to_inum(str, base, base==0);
}
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-
-static VALUE bigsqr(VALUE x);
-static void bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp);
-
-#define POW2_P(x) (((x)&((x)-1))==0)
-
-static inline int
-ones(register unsigned long x)
-{
-#if SIZEOF_LONG == 8
-# define MASK_55 0x5555555555555555UL
-# define MASK_33 0x3333333333333333UL
-# define MASK_0f 0x0f0f0f0f0f0f0f0fUL
-#else
-# define MASK_55 0x55555555UL
-# define MASK_33 0x33333333UL
-# define MASK_0f 0x0f0f0f0fUL
-#endif
- x -= (x >> 1) & MASK_55;
- x = ((x >> 2) & MASK_33) + (x & MASK_33);
- x = ((x >> 4) + x) & MASK_0f;
- x += (x >> 8);
- x += (x >> 16);
-#if SIZEOF_LONG == 8
- x += (x >> 32);
-#endif
- return (int)(x & 0x7f);
-#undef MASK_0f
-#undef MASK_33
-#undef MASK_55
-}
-
-static inline unsigned long
-next_pow2(register unsigned long x)
-{
- x |= x >> 1;
- x |= x >> 2;
- x |= x >> 4;
- x |= x >> 8;
- x |= x >> 16;
-#if SIZEOF_LONG == 8
- x |= x >> 32;
-#endif
- return x + 1;
-}
-
-static inline int
-floor_log2(register unsigned long x)
-{
- x |= x >> 1;
- x |= x >> 2;
- x |= x >> 4;
- x |= x >> 8;
- x |= x >> 16;
-#if SIZEOF_LONG == 8
- x |= x >> 32;
-#endif
- return (int)ones(x) - 1;
-}
-
-static inline int
-ceil_log2(register unsigned long x)
-{
- return floor_log2(x) + !POW2_P(x);
-}
-
-#define LOG2_KARATSUBA_DIGITS 7
-#define KARATSUBA_DIGITS (1L<<LOG2_KARATSUBA_DIGITS)
-#define MAX_BIG2STR_TABLE_ENTRIES 64
-
-static VALUE big2str_power_cache[35][MAX_BIG2STR_TABLE_ENTRIES];
-
-static void
-power_cache_init(void)
-{
- int i, j;
- for (i = 0; i < 35; ++i) {
- big2str_power_cache[i][0] =
- rb_big_pow(rb_int2big(i+2), INT2FIX(KARATSUBA_DIGITS));
- rb_global_variable(&big2str_power_cache[i][0]);
- for (j = 1; j < MAX_BIG2STR_TABLE_ENTRIES; ++j) {
- big2str_power_cache[i][j] = Qnil;
- }
- }
-}
-
-static inline VALUE
-power_cache_get_power0(int base, int i)
-{
- if (NIL_P(big2str_power_cache[base - 2][i])) {
- big2str_power_cache[base - 2][i] =
- bigsqr(power_cache_get_power0(base, i - 1));
- rb_global_variable(&big2str_power_cache[base - 2][i]);
- }
- return big2str_power_cache[base - 2][i];
-}
-
-static VALUE
-power_cache_get_power(int base, long n1, long* m1)
-{
- long i, j, m;
- VALUE t;
-
- if (n1 <= KARATSUBA_DIGITS)
- rb_bug("n1 > KARATSUBA_DIGITS");
-
- m = ceil_log2(n1);
- if (m1) *m1 = 1 << m;
- i = m - LOG2_KARATSUBA_DIGITS;
- if (i >= MAX_BIG2STR_TABLE_ENTRIES)
- i = MAX_BIG2STR_TABLE_ENTRIES - 1;
- t = power_cache_get_power0(base, i);
-
- j = KARATSUBA_DIGITS*(1 << i);
- while (n1 > j) {
- t = bigsqr(t);
- j *= 2;
- }
- return t;
-}
-
-/* big2str_muraken_find_n1
- *
- * Let a natural number x is given by:
- * x = 2^0 * x_0 + 2^1 * x_1 + ... + 2^(B*n_0 - 1) * x_{B*n_0 - 1},
- * where B is BITSPERDIG (i.e. BDIGITS*CHAR_BIT) and n_0 is
- * RBIGNUM_LEN(x).
- *
- * Now, we assume n_1 = min_n \{ n | 2^(B*n_0/2) <= b_1^(n_1) \}, so
- * it is realized that 2^(B*n_0) <= {b_1}^{2*n_1}, where b_1 is a
- * given radix number. And then, we have n_1 <= (B*n_0) /
- * (2*log_2(b_1)), therefore n_1 is given by ceil((B*n_0) /
- * (2*log_2(b_1))).
- */
-static long
-big2str_find_n1(VALUE x, int base)
-{
- static const double log_2[] = {
- 1.0, 1.58496250072116, 2.0,
- 2.32192809488736, 2.58496250072116, 2.8073549220576,
- 3.0, 3.16992500144231, 3.32192809488736,
- 3.4594316186373, 3.58496250072116, 3.70043971814109,
- 3.8073549220576, 3.90689059560852, 4.0,
- 4.08746284125034, 4.16992500144231, 4.24792751344359,
- 4.32192809488736, 4.39231742277876, 4.4594316186373,
- 4.52356195605701, 4.58496250072116, 4.64385618977472,
- 4.70043971814109, 4.75488750216347, 4.8073549220576,
- 4.85798099512757, 4.90689059560852, 4.95419631038688,
- 5.0, 5.04439411935845, 5.08746284125034,
- 5.12928301694497, 5.16992500144231
- };
- long bits;
-
- if (base < 2 || 36 < base)
- rb_bug("invalid radix %d", base);
-
- if (FIXNUM_P(x)) {
- bits = (SIZEOF_LONG*CHAR_BIT - 1)/2 + 1;
- }
- else if (BIGZEROP(x)) {
- return 0;
- }
- else {
- bits = BITSPERDIG*RBIGNUM_LEN(x);
- }
-
- return (long)ceil(bits/log_2[base - 2]);
-}
-
-static long
-big2str_orig(VALUE x, int base, char* ptr, long len, long hbase, int trim)
-{
- long i = RBIGNUM_LEN(x), j = len;
- BDIGIT* ds = BDIGITS(x);
-
- while (i && j > 0) {
- long k = i;
- BDIGIT_DBL num = 0;
-
- while (k--) { /* x / hbase */
- num = BIGUP(num) + ds[k];
- ds[k] = (BDIGIT)(num / hbase);
- num %= hbase;
- }
- if (trim && ds[i-1] == 0) i--;
- k = SIZEOF_BDIGITS;
- while (k--) {
- ptr[--j] = ruby_digitmap[num % base];
- num /= base;
- if (j <= 0) break;
- if (trim && i == 0 && num == 0) break;
- }
- }
- if (trim) {
- while (j < len && ptr[j] == '0') j++;
- MEMMOVE(ptr, ptr + j, char, len - j);
- len -= j;
- }
- return len;
-}
-
-static long
-big2str_karatsuba(VALUE x, int base, char* ptr,
- long n1, long len, long hbase, int trim)
+VALUE
+rb_big2str0(x, base, trim)
+ VALUE x;
+ int base;
+ int trim;
{
- long lh, ll, m1;
- VALUE b, q, r;
+ volatile VALUE t;
+ BDIGIT *ds;
+ long i, j, hbase;
+ VALUE ss;
+ char *s;
if (FIXNUM_P(x)) {
- VALUE str = rb_fix2str(x, base);
- char* str_ptr = RSTRING_PTR(str);
- long str_len = RSTRING_LEN(str);
- if (trim) {
- if (FIX2INT(x) == 0) return 0;
- MEMCPY(ptr, str_ptr, char, str_len);
- return str_len;
- }
- else {
- memset(ptr, '0', len - str_len);
- MEMCPY(ptr + len - str_len, str_ptr, char, str_len);
- return len;
- }
+ return rb_fix2str(x, base);
}
+ i = RBIGNUM(x)->len;
if (BIGZEROP(x)) {
- if (trim) return 0;
- else {
- memset(ptr, '0', len);
- return len;
- }
- }
-
- if (n1 <= KARATSUBA_DIGITS) {
- return big2str_orig(x, base, ptr, len, hbase, trim);
+ return rb_str_new2("0");
}
-
- b = power_cache_get_power(base, n1, &m1);
- bigdivmod(x, b, &q, &r);
- lh = big2str_karatsuba(q, base, ptr, (len - m1)/2,
- len - m1, hbase, trim);
- ll = big2str_karatsuba(r, base, ptr + lh, m1/2,
- m1, hbase, !lh && trim);
-
- return lh + ll;
-}
-
-VALUE
-rb_big2str0(VALUE x, int base, int trim)
-{
- int off;
- VALUE ss, xx;
- long n1, n2, len, hbase;
- char* ptr;
-
- if (FIXNUM_P(x)) {
- return rb_fix2str(x, base);
+ if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
}
- if (BIGZEROP(x)) {
- return rb_str_new2("0");
+ j = SIZEOF_BDIGITS*CHAR_BIT*i;
+ switch (base) {
+ case 2: break;
+ case 3:
+ j = j * 53L / 84 + 1;
+ break;
+ case 4: case 5: case 6: case 7:
+ j = (j + 1) / 2;
+ break;
+ case 8: case 9:
+ j = (j + 2) / 3;
+ break;
+ case 10: case 11: case 12: case 13: case 14: case 15:
+ j = j * 28L / 93 + 1;
+ break;
+ case 16: case 17: case 18: case 19: case 20: case 21:
+ case 22: case 23: case 24: case 25: case 26: case 27:
+ case 28: case 29: case 30: case 31:
+ j = (j + 3) / 4;
+ break;
+ case 32: case 33: case 34: case 35: case 36:
+ j = (j + 4) / 5;
+ break;
+ default:
+ rb_raise(rb_eArgError, "illegal radix %d", base);
+ break;
}
+ j++; /* space for sign */
- if (base < 2 || 36 < base)
- rb_raise(rb_eArgError, "invalid radix %d", base);
-
- n2 = big2str_find_n1(x, base);
- n1 = (n2 + 1) / 2;
- ss = rb_str_new(0, n2 + 1); /* plus one for sign */
- ptr = RSTRING_PTR(ss);
- ptr[0] = RBIGNUM_SIGN(x) ? '+' : '-';
-
- hbase = base*base;
+ hbase = base * base;
#if SIZEOF_BDIGITS > 2
hbase *= hbase;
#endif
- off = !(trim && RBIGNUM_SIGN(x)); /* erase plus sign if trim */
- xx = rb_big_clone(x);
- RBIGNUM_SET_SIGN(xx, 1);
- if (n1 <= KARATSUBA_DIGITS) {
- len = off + big2str_orig(xx, base, ptr + off, n2, hbase, trim);
+
+ t = rb_big_clone(x);
+ ds = BDIGITS(t);
+ ss = rb_str_new(0, j+1);
+ s = RSTRING(ss)->ptr;
+
+ s[0] = RBIGNUM(x)->sign ? '+' : '-';
+ TRAP_BEG;
+ while (i && j > 1) {
+ long k = i;
+ BDIGIT_DBL num = 0;
+
+ while (k--) {
+ num = BIGUP(num) + ds[k];
+ ds[k] = (BDIGIT)(num / hbase);
+ num %= hbase;
+ }
+ if (trim && ds[i-1] == 0) i--;
+ k = SIZEOF_BDIGITS;
+ while (k--) {
+ s[--j] = ruby_digitmap[num % base];
+ num /= base;
+ if (!trim && j <= 1) break;
+ if (trim && 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 {
- len = off + big2str_karatsuba(xx, base, ptr + off, n1,
- n2, hbase, trim);
+ memmove(s+1, s+j, i);
+ RSTRING(ss)->len = i;
}
-
- ptr[len] = '\0';
- rb_str_resize(ss, len);
+ s[RSTRING(ss)->len] = '\0';
+ TRAP_END;
return ss;
}
@@ -941,7 +759,7 @@ rb_big2str0(VALUE x, int base, int trim)
VALUE
rb_big2str(VALUE x, int base)
{
- return rb_big2str0(x, base, 1);
+ return rb_big2str0(x, base, Qtrue);
}
/*
@@ -959,7 +777,10 @@ rb_big2str(VALUE x, int base)
*/
static VALUE
-rb_big_to_s(int argc, VALUE *argv, VALUE x)
+rb_big_to_s(argc, argv, x)
+ int argc;
+ VALUE *argv;
+ VALUE x;
{
VALUE b;
int base;
@@ -970,18 +791,17 @@ rb_big_to_s(int argc, VALUE *argv, VALUE x)
return rb_big2str(x, base);
}
-static VALUE
-big2ulong(VALUE x, const char *type, int check)
+static unsigned long
+big2ulong(x, type)
+ VALUE x;
+ char *type;
{
- long len = RBIGNUM_LEN(x);
+ long len = RBIGNUM(x)->len;
BDIGIT_DBL num;
BDIGIT *ds;
- if (len > DIGSPERLONG) {
- if (check)
- rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
- len = DIGSPERLONG;
- }
+ if (len > SIZEOF_LONG/SIZEOF_BDIGITS)
+ rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
ds = BDIGITS(x);
num = 0;
while (len--) {
@@ -991,23 +811,25 @@ big2ulong(VALUE x, const char *type, int check)
return num;
}
-VALUE
-rb_big2ulong_pack(VALUE x)
+unsigned long
+rb_big2ulong_pack(x)
+ VALUE x;
{
- VALUE num = big2ulong(x, "unsigned long", Qfalse);
- if (!RBIGNUM_SIGN(x)) {
+ unsigned long num = big2ulong(x, "unsigned long");
+ if (!RBIGNUM(x)->sign) {
return -num;
}
return num;
}
-VALUE
-rb_big2ulong(VALUE x)
+unsigned long
+rb_big2ulong(x)
+ VALUE x;
{
- VALUE num = big2ulong(x, "unsigned long", Qtrue);
+ unsigned long num = big2ulong(x, "unsigned long");
- if (!RBIGNUM_SIGN(x)) {
- if ((SIGNED_VALUE)num < 0) {
+ if (!RBIGNUM(x)->sign) {
+ if ((long)num < 0) {
rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
}
return -num;
@@ -1015,25 +837,27 @@ rb_big2ulong(VALUE x)
return num;
}
-SIGNED_VALUE
-rb_big2long(VALUE x)
+long
+rb_big2long(x)
+ VALUE x;
{
- VALUE num = big2ulong(x, "long", Qtrue);
+ unsigned long num = big2ulong(x, "long");
- if ((SIGNED_VALUE)num < 0 &&
- (RBIGNUM_SIGN(x) || (SIGNED_VALUE)num != LONG_MIN)) {
+ if ((long)num < 0 && (RBIGNUM(x)->sign || (long)num != LONG_MIN)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
}
- if (!RBIGNUM_SIGN(x)) return -(SIGNED_VALUE)num;
+ if (!RBIGNUM(x)->sign) return -(long)num;
return num;
}
#if HAVE_LONG_LONG
static unsigned LONG_LONG
-big2ull(VALUE x, const char *type)
+big2ull(x, type)
+ VALUE x;
+ char *type;
{
- long len = RBIGNUM_LEN(x);
+ long len = RBIGNUM(x)->len;
BDIGIT_DBL num;
BDIGIT *ds;
@@ -1049,31 +873,34 @@ big2ull(VALUE x, const char *type)
}
unsigned LONG_LONG
-rb_big2ull(VALUE x)
+rb_big2ull(x)
+ VALUE x;
{
unsigned LONG_LONG num = big2ull(x, "unsigned long long");
- if (!RBIGNUM_SIGN(x)) return -num;
+ if (!RBIGNUM(x)->sign) return -num;
return num;
}
LONG_LONG
-rb_big2ll(VALUE x)
+rb_big2ll(x)
+ VALUE x;
{
unsigned LONG_LONG num = big2ull(x, "long long");
- if ((LONG_LONG)num < 0 && (RBIGNUM_SIGN(x)
+ if ((LONG_LONG)num < 0 && (RBIGNUM(x)->sign
|| (LONG_LONG)num != LLONG_MIN)) {
rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
}
- if (!RBIGNUM_SIGN(x)) return -(LONG_LONG)num;
+ if (!RBIGNUM(x)->sign) return -(LONG_LONG)num;
return num;
}
#endif /* HAVE_LONG_LONG */
static VALUE
-dbl2big(double d)
+dbl2big(d)
+ double d;
{
long i = 0;
BDIGIT c;
@@ -1105,27 +932,30 @@ dbl2big(double d)
}
VALUE
-rb_dbl2big(double d)
+rb_dbl2big(d)
+ double d;
{
return bignorm(dbl2big(d));
}
static double
-big2dbl(VALUE x)
+big2dbl(x)
+ VALUE x;
{
double d = 0.0;
- long i = RBIGNUM_LEN(x);
+ long i = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
while (i--) {
d = ds[i] + BIGRAD*d;
}
- if (!RBIGNUM_SIGN(x)) d = -d;
+ if (!RBIGNUM(x)->sign) d = -d;
return d;
}
double
-rb_big2dbl(VALUE x)
+rb_big2dbl(x)
+ VALUE x;
{
double d = big2dbl(x);
@@ -1146,9 +976,10 @@ rb_big2dbl(VALUE x)
*/
static VALUE
-rb_big_to_f(VALUE x)
+rb_big_to_f(x)
+ VALUE x;
{
- return DOUBLE2NUM(rb_big2dbl(x));
+ return rb_float_new(rb_big2dbl(x));
}
/*
@@ -1161,10 +992,11 @@ rb_big_to_f(VALUE x)
*
*/
-VALUE
-rb_big_cmp(VALUE x, VALUE y)
+static VALUE
+rb_big_cmp(x, y)
+ VALUE x, y;
{
- long xlen = RBIGNUM_LEN(x);
+ long xlen = RBIGNUM(x)->len;
switch (TYPE(y)) {
case T_FIXNUM:
@@ -1175,24 +1007,24 @@ rb_big_cmp(VALUE x, VALUE y)
break;
case T_FLOAT:
- return rb_dbl_cmp(rb_big2dbl(x), RFLOAT_VALUE(y));
+ return rb_dbl_cmp(rb_big2dbl(x), RFLOAT(y)->value);
default:
return rb_num_coerce_cmp(x, y);
}
- if (RBIGNUM_SIGN(x) > RBIGNUM_SIGN(y)) return INT2FIX(1);
- if (RBIGNUM_SIGN(x) < RBIGNUM_SIGN(y)) return INT2FIX(-1);
- if (xlen < RBIGNUM_LEN(y))
- return (RBIGNUM_SIGN(x)) ? INT2FIX(-1) : INT2FIX(1);
- if (xlen > RBIGNUM_LEN(y))
- return (RBIGNUM_SIGN(x)) ? INT2FIX(1) : INT2FIX(-1);
+ if (RBIGNUM(x)->sign > RBIGNUM(y)->sign) return INT2FIX(1);
+ if (RBIGNUM(x)->sign < RBIGNUM(y)->sign) return INT2FIX(-1);
+ if (xlen < RBIGNUM(y)->len)
+ return (RBIGNUM(x)->sign) ? INT2FIX(-1) : INT2FIX(1);
+ if (xlen > RBIGNUM(y)->len)
+ return (RBIGNUM(x)->sign) ? INT2FIX(1) : INT2FIX(-1);
while(xlen-- && (BDIGITS(x)[xlen]==BDIGITS(y)[xlen]));
if (-1 == xlen) return INT2FIX(0);
return (BDIGITS(x)[xlen] > BDIGITS(y)[xlen]) ?
- (RBIGNUM_SIGN(x) ? INT2FIX(1) : INT2FIX(-1)) :
- (RBIGNUM_SIGN(x) ? INT2FIX(-1) : INT2FIX(1));
+ (RBIGNUM(x)->sign ? INT2FIX(1) : INT2FIX(-1)) :
+ (RBIGNUM(x)->sign ? INT2FIX(-1) : INT2FIX(1));
}
/*
@@ -1206,8 +1038,9 @@ rb_big_cmp(VALUE x, VALUE y)
* 68719476736 == 68719476736.0 #=> true
*/
-VALUE
-rb_big_eq(VALUE x, VALUE y)
+static VALUE
+rb_big_eq(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
@@ -1216,10 +1049,10 @@ rb_big_eq(VALUE x, VALUE y)
case T_BIGNUM:
break;
case T_FLOAT:
- {
+ {
volatile double a, b;
- a = RFLOAT_VALUE(y);
+ a = RFLOAT(y)->value;
if (isnan(a)) return Qfalse;
b = rb_big2dbl(x);
return (a == b)?Qtrue:Qfalse;
@@ -1227,9 +1060,9 @@ rb_big_eq(VALUE x, VALUE y)
default:
return rb_equal(y, x);
}
- if (RBIGNUM_SIGN(x) != RBIGNUM_SIGN(y)) return Qfalse;
- if (RBIGNUM_LEN(x) != RBIGNUM_LEN(y)) return Qfalse;
- if (MEMCMP(BDIGITS(x),BDIGITS(y),BDIGIT,RBIGNUM_LEN(y)) != 0) return Qfalse;
+ if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
+ if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
+ if (MEMCMP(BDIGITS(x),BDIGITS(y),BDIGIT,RBIGNUM(y)->len) != 0) return Qfalse;
return Qtrue;
}
@@ -1245,12 +1078,13 @@ rb_big_eq(VALUE x, VALUE y)
*/
static VALUE
-rb_big_eql(VALUE x, VALUE y)
+rb_big_eql(x, y)
+ VALUE x, y;
{
if (TYPE(y) != T_BIGNUM) return Qfalse;
- if (RBIGNUM_SIGN(x) != RBIGNUM_SIGN(y)) return Qfalse;
- if (RBIGNUM_LEN(x) != RBIGNUM_LEN(y)) return Qfalse;
- if (MEMCMP(BDIGITS(x),BDIGITS(y),BDIGIT,RBIGNUM_LEN(y)) != 0) return Qfalse;
+ if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
+ if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
+ if (MEMCMP(BDIGITS(x),BDIGITS(y),BDIGIT,RBIGNUM(y)->len) != 0) return Qfalse;
return Qtrue;
}
@@ -1262,11 +1096,12 @@ rb_big_eql(VALUE x, VALUE y)
*/
static VALUE
-rb_big_uminus(VALUE x)
+rb_big_uminus(x)
+ VALUE x;
{
VALUE z = rb_big_clone(x);
- RBIGNUM_SET_SIGN(z, !RBIGNUM_SIGN(x));
+ RBIGNUM(z)->sign = !RBIGNUM(x)->sign;
return bignorm(z);
}
@@ -1284,38 +1119,38 @@ rb_big_uminus(VALUE x)
*/
static VALUE
-rb_big_neg(VALUE x)
+rb_big_neg(x)
+ VALUE x;
{
VALUE z = rb_big_clone(x);
- BDIGIT *ds;
long i;
+ BDIGIT *ds;
- if (!RBIGNUM_SIGN(x)) get2comp(z);
+ if (!RBIGNUM(x)->sign) get2comp(z);
ds = BDIGITS(z);
- i = RBIGNUM_LEN(x);
- if (!i) return INT2FIX(~(SIGNED_VALUE)0);
- while (i--) {
- ds[i] = ~ds[i];
- }
- RBIGNUM_SET_SIGN(z, !RBIGNUM_SIGN(z));
- if (RBIGNUM_SIGN(x)) get2comp(z);
+ i = RBIGNUM(x)->len;
+ if (!i) return INT2FIX(~0);
+ while (i--) ds[i] = ~ds[i];
+ RBIGNUM(z)->sign = !RBIGNUM(z)->sign;
+ if (RBIGNUM(x)->sign) get2comp(z);
return bignorm(z);
}
static VALUE
-bigsub(VALUE x, VALUE y)
+bigsub(x, y)
+ VALUE x, y;
{
VALUE z = 0;
BDIGIT *zds;
BDIGIT_DBL_SIGNED num;
- long i = RBIGNUM_LEN(x);
+ long i = RBIGNUM(x)->len;
/* if x is larger than y, swap */
- if (RBIGNUM_LEN(x) < RBIGNUM_LEN(y)) {
+ if (RBIGNUM(x)->len < RBIGNUM(y)->len) {
z = x; x = y; y = z; /* swap x y */
}
- else if (RBIGNUM_LEN(x) == RBIGNUM_LEN(y)) {
+ else if (RBIGNUM(x)->len == RBIGNUM(y)->len) {
while (i > 0) {
i--;
if (BDIGITS(x)[i] > BDIGITS(y)[i]) {
@@ -1328,20 +1163,20 @@ bigsub(VALUE x, VALUE y)
}
}
- z = bignew(RBIGNUM_LEN(x), z==0);
+ z = bignew(RBIGNUM(x)->len, z==0);
zds = BDIGITS(z);
- for (i = 0, num = 0; i < RBIGNUM_LEN(y); 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_LEN(x)) {
+ while (num && i < RBIGNUM(x)->len) {
num += BDIGITS(x)[i];
zds[i++] = BIGLO(num);
num = BIGDN(num);
}
- while (i < RBIGNUM_LEN(x)) {
+ while (i < RBIGNUM(x)->len) {
zds[i] = BDIGITS(x)[i];
i++;
}
@@ -1350,34 +1185,36 @@ bigsub(VALUE x, VALUE y)
}
static VALUE
-bigadd(VALUE x, VALUE y, int sign)
+bigadd(x, y, sign)
+ VALUE x, y;
+ int sign;
{
VALUE z;
BDIGIT_DBL num;
long i, len;
- sign = (sign == RBIGNUM_SIGN(y));
- if (RBIGNUM_SIGN(x) != sign) {
+ sign = (sign == RBIGNUM(y)->sign);
+ if (RBIGNUM(x)->sign != sign) {
if (sign) return bigsub(y, x);
return bigsub(x, y);
}
- if (RBIGNUM_LEN(x) > RBIGNUM_LEN(y)) {
- len = RBIGNUM_LEN(x) + 1;
- z = x; x = y; y = z;
+ if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
+ len = RBIGNUM(x)->len + 1;
+ z = x; x = y; y = z;
}
else {
- len = RBIGNUM_LEN(y) + 1;
+ len = RBIGNUM(y)->len + 1;
}
z = bignew(len, sign);
- len = RBIGNUM_LEN(x);
+ len = RBIGNUM(x)->len;
for (i = 0, num = 0; i < len; i++) {
num += (BDIGIT_DBL)BDIGITS(x)[i] + BDIGITS(y)[i];
BDIGITS(z)[i] = BIGLO(num);
num = BIGDN(num);
}
- len = RBIGNUM_LEN(y);
+ len = RBIGNUM(y)->len;
while (num && i < len) {
num += BDIGITS(y)[i];
BDIGITS(z)[i++] = BIGLO(num);
@@ -1400,7 +1237,8 @@ bigadd(VALUE x, VALUE y, int sign)
*/
VALUE
-rb_big_plus(VALUE x, VALUE y)
+rb_big_plus(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
@@ -1410,7 +1248,7 @@ rb_big_plus(VALUE x, VALUE y)
return bignorm(bigadd(x, y, 1));
case T_FLOAT:
- return DOUBLE2NUM(rb_big2dbl(x) + RFLOAT_VALUE(y));
+ return rb_float_new(rb_big2dbl(x) + RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
@@ -1425,7 +1263,8 @@ rb_big_plus(VALUE x, VALUE y)
*/
VALUE
-rb_big_minus(VALUE x, VALUE y)
+rb_big_minus(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
@@ -1435,62 +1274,23 @@ rb_big_minus(VALUE x, VALUE y)
return bignorm(bigadd(x, y, 0));
case T_FLOAT:
- return DOUBLE2NUM(rb_big2dbl(x) - RFLOAT_VALUE(y));
+ return rb_float_new(rb_big2dbl(x) - RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}
}
-static void
-rb_big_stop(void *ptr)
-{
- VALUE *stop = (VALUE*)ptr;
- *stop = Qtrue;
-}
-
-struct big_mul_struct {
- VALUE x, y, stop;
-};
-
-static VALUE
-bigmul1(void *ptr)
+VALUE
+rb_big_mul0(x, y)
+ VALUE x, y;
{
- struct big_mul_struct *bms = (struct big_mul_struct*)ptr;
long i, j;
BDIGIT_DBL n = 0;
- VALUE x = bms->x, y = bms->y, z;
- BDIGIT *zds;
-
- j = RBIGNUM_LEN(x) + RBIGNUM_LEN(y) + 1;
- z = bignew(j, RBIGNUM_SIGN(x)==RBIGNUM_SIGN(y));
- zds = BDIGITS(z);
- while (j--) zds[j] = 0;
- for (i = 0; i < RBIGNUM_LEN(x); i++) {
- BDIGIT_DBL dd;
- if (bms->stop) return Qnil;
- dd = BDIGITS(x)[i];
- if (dd == 0) continue;
- n = 0;
- for (j = 0; j < RBIGNUM_LEN(y); j++) {
- BDIGIT_DBL ee = n + (BDIGIT_DBL)dd * BDIGITS(y)[j];
- n = zds[i + j] + ee;
- if (ee) zds[i + j] = BIGLO(n);
- n = BIGDN(n);
- }
- if (n) {
- zds[i + j] = n;
- }
- }
- return z;
-}
-
-static VALUE
-rb_big_mul0(VALUE x, VALUE y)
-{
- struct big_mul_struct bms;
VALUE z;
+ BDIGIT *zds;
+ if (FIXNUM_P(x)) x = rb_int2big(FIX2LONG(x));
switch (TYPE(y)) {
case T_FIXNUM:
y = rb_int2big(FIX2LONG(y));
@@ -1500,21 +1300,29 @@ rb_big_mul0(VALUE x, VALUE y)
break;
case T_FLOAT:
- return DOUBLE2NUM(rb_big2dbl(x) * RFLOAT_VALUE(y));
+ return rb_float_new(rb_big2dbl(x) * RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}
- bms.x = x;
- bms.y = y;
- bms.stop = Qfalse;
-
- if (RBIGNUM_LEN(x) + RBIGNUM_LEN(y) > 10000) {
- z = rb_thread_blocking_region(bigmul1, &bms, rb_big_stop, &bms.stop);
- }
- else {
- z = bigmul1(&bms);
+ j = RBIGNUM(x)->len + RBIGNUM(y)->len + 1;
+ z = bignew(j, RBIGNUM(x)->sign==RBIGNUM(y)->sign);
+ zds = BDIGITS(z);
+ while (j--) zds[j] = 0;
+ for (i = 0; i < RBIGNUM(x)->len; i++) {
+ BDIGIT_DBL dd = BDIGITS(x)[i];
+ if (dd == 0) continue;
+ n = 0;
+ for (j = 0; j < RBIGNUM(y)->len; j++) {
+ BDIGIT_DBL ee = n + (BDIGIT_DBL)dd * BDIGITS(y)[j];
+ n = zds[i + j] + ee;
+ if (ee) zds[i + j] = BIGLO(n);
+ n = BIGDN(n);
+ }
+ if (n) {
+ zds[i + j] = n;
+ }
}
return z;
@@ -1528,21 +1336,18 @@ rb_big_mul0(VALUE x, VALUE y)
*/
VALUE
-rb_big_mul(VALUE x, VALUE y)
+rb_big_mul(x, y)
+ VALUE x, y;
{
return bignorm(rb_big_mul0(x, y));
}
-struct big_div_struct {
- VALUE x, y, *divp, *modp, stop;
-};
-
-static VALUE
-bigdivrem1(void *ptr)
+static void
+bigdivrem(x, y, divp, modp)
+ VALUE x, y;
+ VALUE *divp, *modp;
{
- struct big_div_struct *bds = (struct big_div_struct*)ptr;
- VALUE x = bds->x, y = bds->y, *divp = bds->divp, *modp = bds->modp;
- long nx = RBIGNUM_LEN(x), ny = RBIGNUM_LEN(y);
+ long nx = RBIGNUM(x)->len, ny = RBIGNUM(y)->len;
long i, j;
VALUE yy, z;
BDIGIT *xds, *yds, *zds, *tds;
@@ -1555,7 +1360,7 @@ bigdivrem1(void *ptr)
if (nx < ny || (nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1])) {
if (divp) *divp = rb_int2big(0);
if (modp) *modp = x;
- return Qnil;
+ return;
}
xds = BDIGITS(x);
if (ny == 1) {
@@ -1568,23 +1373,23 @@ bigdivrem1(void *ptr)
zds[i] = (BDIGIT)(t2 / dd);
t2 %= dd;
}
- RBIGNUM_SET_SIGN(z, RBIGNUM_SIGN(x)==RBIGNUM_SIGN(y));
+ RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
if (modp) {
- *modp = rb_uint2big((VALUE)t2);
- RBIGNUM_SET_SIGN(*modp, RBIGNUM_SIGN(x));
+ *modp = rb_uint2big((unsigned long)t2);
+ RBIGNUM(*modp)->sign = RBIGNUM(x)->sign;
}
if (divp) *divp = z;
- return Qnil;
+ return;
}
- z = bignew(nx==ny?nx+2:nx+1, RBIGNUM_SIGN(x)==RBIGNUM_SIGN(y));
+ z = bignew(nx==ny?nx+2:nx+1, RBIGNUM(x)->sign==RBIGNUM(y)->sign);
zds = BDIGITS(z);
if (nx==ny) zds[nx+1] = 0;
while (!yds[ny-1]) ny--;
dd = 0;
q = yds[ny-1];
- while ((q & (1UL<<(BITSPERDIG-1))) == 0) {
- q <<= 1UL;
+ while ((q & (1U<<(BITSPERDIG-1))) == 0) {
+ q <<= 1;
dd++;
}
if (dd) {
@@ -1615,7 +1420,6 @@ bigdivrem1(void *ptr)
j = nx==ny?nx+1:nx;
do {
- if (bds->stop) return Qnil;
if (zds[j] == yds[ny-1]) q = BIGRAD-1;
else q = (BDIGIT)((BIGUP(zds[j]) + zds[j-1])/yds[ny-1]);
if (q) {
@@ -1648,7 +1452,7 @@ bigdivrem1(void *ptr)
zds = BDIGITS(*divp);
j = (nx==ny ? nx+2 : nx+1) - ny;
for (i = 0;i < j;i++) zds[i] = zds[i+ny];
- RBIGNUM_SET_LEN(*divp, i);
+ RBIGNUM(*divp)->len = i;
}
if (modp) { /* normalize remainder */
*modp = rb_big_clone(z);
@@ -1663,39 +1467,20 @@ bigdivrem1(void *ptr)
t2 = BIGUP(q);
}
}
- RBIGNUM_SET_LEN(*modp, ny);
- RBIGNUM_SET_SIGN(*modp, RBIGNUM_SIGN(x));
- }
- return Qnil;
-}
-
-static VALUE
-bigdivrem(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
-{
- struct big_div_struct bds;
- VALUE z;
-
- bds.x = x;
- bds.y = y;
- bds.divp = divp;
- bds.modp = modp;
- bds.stop = Qfalse;
- if (RBIGNUM_LEN(x) > 10000 || RBIGNUM_LEN(y) > 10000) {
- z = rb_thread_blocking_region(bigdivrem1, &bds, rb_big_stop, &bds.stop);
- }
- else {
- z = bigdivrem1(&bds);
+ RBIGNUM(*modp)->len = ny;
+ RBIGNUM(*modp)->sign = RBIGNUM(x)->sign;
}
- return z;
}
static void
-bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
+bigdivmod(x, y, divp, modp)
+ VALUE x, y;
+ VALUE *divp, *modp;
{
VALUE mod;
bigdivrem(x, y, divp, &mod);
- if (RBIGNUM_SIGN(x) != RBIGNUM_SIGN(y) && !BIGZEROP(mod)) {
+ if (RBIGNUM(x)->sign != RBIGNUM(y)->sign && !BIGZEROP(mod)) {
if (divp) *divp = bigadd(*divp, rb_int2big(1), 0);
if (modp) *modp = bigadd(mod, y, 1);
}
@@ -1713,8 +1498,9 @@ bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
* Divides big by other, returning the result.
*/
-VALUE
-rb_big_div(VALUE x, VALUE y)
+static VALUE
+rb_big_div(x, y)
+ VALUE x, y;
{
VALUE z;
@@ -1726,9 +1512,6 @@ rb_big_div(VALUE x, VALUE y)
case T_BIGNUM:
break;
- case T_FLOAT:
- return DOUBLE2NUM(rb_big2dbl(x) / RFLOAT_VALUE(y));
-
default:
return rb_num_coerce_bin(x, y);
}
@@ -1746,8 +1529,9 @@ rb_big_div(VALUE x, VALUE y)
* information.
*/
-VALUE
-rb_big_modulo(VALUE x, VALUE y)
+static VALUE
+rb_big_modulo(x, y)
+ VALUE x, y;
{
VALUE z;
@@ -1777,7 +1561,8 @@ rb_big_modulo(VALUE x, VALUE y)
* -1234567890987654321.remainder(13731.24) #=> -9906.22531493148
*/
static VALUE
-rb_big_remainder(VALUE x, VALUE y)
+rb_big_remainder(x, y)
+ VALUE x, y;
{
VALUE z;
@@ -1797,34 +1582,6 @@ rb_big_remainder(VALUE x, VALUE y)
return bignorm(z);
}
-/*
- * call-seq:
- * big.divmod(numeric) => array
- *
- * See <code>Numeric#divmod</code>.
- *
- */
-VALUE
-rb_big_divmod(VALUE x, VALUE y)
-{
- VALUE div, mod;
-
- switch (TYPE(y)) {
- case T_FIXNUM:
- y = rb_int2big(FIX2LONG(y));
- break;
-
- case T_BIGNUM:
- break;
-
- default:
- return rb_num_coerce_bin(x, y);
- }
- bigdivmod(x, y, &div, &mod);
-
- return rb_assoc_new(bignorm(div), bignorm(mod));
-}
-
static int
bdigbitsize(BDIGIT x)
{
@@ -1846,10 +1603,12 @@ bdigbitsize(BDIGIT x)
return size;
}
-static VALUE big_lshift(VALUE, unsigned long);
-static VALUE big_rshift(VALUE, unsigned long);
+static VALUE big_lshift _((VALUE, unsigned long));
+static VALUE big_rshift _((VALUE, unsigned long));
-static VALUE big_shift(VALUE x, int n)
+static VALUE big_shift(x, n)
+ VALUE x;
+ int n;
{
if (n < 0)
return big_lshift(x, (unsigned int)n);
@@ -1860,6 +1619,35 @@ static VALUE big_shift(VALUE x, int n)
/*
* call-seq:
+ * big.divmod(numeric) => array
+ *
+ * See <code>Numeric#divmod</code>.
+ *
+ */
+VALUE
+rb_big_divmod(x, y)
+ VALUE x, y;
+{
+ VALUE div, mod;
+
+ switch (TYPE(y)) {
+ case T_FIXNUM:
+ y = rb_int2big(FIX2LONG(y));
+ break;
+
+ case T_BIGNUM:
+ break;
+
+ default:
+ return rb_num_coerce_bin(x, y);
+ }
+ bigdivmod(x, y, &div, &mod);
+
+ return rb_assoc_new(bignorm(div), bignorm(mod));
+}
+
+/*
+ * call-seq:
* big.quo(numeric) -> float
* big.fdiv(numeric) -> float
*
@@ -1872,7 +1660,8 @@ static VALUE big_shift(VALUE x, int n)
*/
static VALUE
-rb_big_quo(VALUE x, VALUE y)
+rb_big_quo(x, y)
+ VALUE x, y;
{
double dx = big2dbl(x);
double dy;
@@ -1882,8 +1671,8 @@ rb_big_quo(VALUE x, VALUE y)
VALUE z;
int ex, ey;
- ex = (RBIGNUM_LEN(bigtrunc(x)) - 1) * BITSPERDIG;
- ex += bdigbitsize(BDIGITS(x)[RBIGNUM_LEN(x) - 1]);
+ 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);
@@ -1891,16 +1680,16 @@ rb_big_quo(VALUE x, VALUE y)
case T_FIXNUM:
y = rb_int2big(FIX2LONG(y));
case T_BIGNUM: {
- ey = (RBIGNUM_LEN(bigtrunc(y)) - 1) * BITSPERDIG;
- ey += bdigbitsize(BDIGITS(y)[RBIGNUM_LEN(y) - 1]);
+ 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 DOUBLE2NUM(ldexp(big2dbl(z), ex - ey));
+ return rb_float_new(ldexp(big2dbl(z), ex - ey));
}
case T_FLOAT:
- y = dbl2big(ldexp(frexp(RFLOAT_VALUE(y), &ey), DBL_MANT_DIG));
+ y = dbl2big(ldexp(frexp(RFLOAT(y)->value, &ey), DBL_MANT_DIG));
ey -= DBL_MANT_DIG;
goto bignum;
}
@@ -1915,24 +1704,25 @@ rb_big_quo(VALUE x, VALUE y)
break;
case T_FLOAT:
- dy = RFLOAT_VALUE(y);
+ dy = RFLOAT(y)->value;
break;
default:
return rb_num_coerce_bin(x, y);
}
- return DOUBLE2NUM(dx / dy);
+ return rb_float_new(dx / dy);
}
static VALUE
-bigsqr(VALUE x)
+bigsqr(x)
+ VALUE x;
{
- long len = RBIGNUM_LEN(x), k = len / 2, i;
+ long len = RBIGNUM(x)->len, k = len / 2, i;
VALUE a, b, a2, z;
BDIGIT_DBL num;
if (len < 4000 / BITSPERDIG) {
- return bigtrunc(rb_big_mul0(x, x));
+ return rb_big_mul0(x, x);
}
a = bignew(len - k, 1);
@@ -1942,30 +1732,28 @@ bigsqr(VALUE x)
a2 = bigtrunc(bigsqr(a));
z = bigsqr(b);
- rb_big_realloc(z, (len = 2 * k + RBIGNUM_LEN(a2)) + 1);
- while (RBIGNUM_LEN(z) < 2 * k) {
- BDIGITS(z)[RBIGNUM_LEN(z)] = 0;
- RBIGNUM_SET_LEN(z, RBIGNUM_LEN(z)+1);
- }
- MEMCPY(BDIGITS(z) + 2 * k, BDIGITS(a2), BDIGIT, RBIGNUM_LEN(a2));
- RBIGNUM_SET_LEN(z, len);
+ 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_LEN(a2);
+ 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_LEN(z);
+ 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_LEN(z)] = BIGLO(num);
- RBIGNUM_SET_LEN(z, RBIGNUM_LEN(z)+1);
+ BDIGITS(z)[RBIGNUM(z)->len++] = BIGLO(num);
}
}
return bigtrunc(z);
@@ -1985,15 +1773,16 @@ bigsqr(VALUE x)
*/
VALUE
-rb_big_pow(VALUE x, VALUE y)
+rb_big_pow(x, y)
+ VALUE x, y;
{
double d;
- SIGNED_VALUE yy;
+ long yy;
if (y == INT2FIX(0)) return INT2FIX(1);
switch (TYPE(y)) {
case T_FLOAT:
- d = RFLOAT_VALUE(y);
+ d = RFLOAT(y)->value;
break;
case T_BIGNUM:
@@ -2005,11 +1794,11 @@ rb_big_pow(VALUE x, VALUE y)
yy = FIX2LONG(y);
if (yy > 0) {
VALUE z = 0;
- SIGNED_VALUE mask;
+ long mask;
const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS;
- if ((RBIGNUM_LEN(x) > BIGLEN_LIMIT) ||
- (RBIGNUM_LEN(x) > BIGLEN_LIMIT / yy)) {
+ if ((RBIGNUM(x)->len > BIGLEN_LIMIT) ||
+ (RBIGNUM(x)->len > BIGLEN_LIMIT / yy)) {
rb_warn("in a**b, b may be too big");
d = (double)yy;
break;
@@ -2028,7 +1817,7 @@ rb_big_pow(VALUE x, VALUE y)
default:
return rb_num_coerce_bin(x, y);
}
- return DOUBLE2NUM(pow(rb_big2dbl(x), d));
+ return rb_float_new(pow(rb_big2dbl(x), d));
}
/*
@@ -2039,7 +1828,8 @@ rb_big_pow(VALUE x, VALUE y)
*/
VALUE
-rb_big_and(VALUE xx, VALUE yy)
+rb_big_and(xx, yy)
+ VALUE xx, yy;
{
volatile VALUE x, y, z;
BDIGIT *ds1, *ds2, *zds;
@@ -2051,29 +1841,29 @@ rb_big_and(VALUE xx, VALUE yy)
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
- if (!RBIGNUM_SIGN(y)) {
+ if (!RBIGNUM(y)->sign) {
y = rb_big_clone(y);
get2comp(y);
}
- if (!RBIGNUM_SIGN(x)) {
+ if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
get2comp(x);
}
- if (RBIGNUM_LEN(x) > RBIGNUM_LEN(y)) {
- l1 = RBIGNUM_LEN(y);
- l2 = RBIGNUM_LEN(x);
+ if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
+ l1 = RBIGNUM(y)->len;
+ l2 = RBIGNUM(x)->len;
ds1 = BDIGITS(y);
ds2 = BDIGITS(x);
- sign = RBIGNUM_SIGN(y);
+ sign = RBIGNUM(y)->sign;
}
else {
- l1 = RBIGNUM_LEN(x);
- l2 = RBIGNUM_LEN(y);
+ l1 = RBIGNUM(x)->len;
+ l2 = RBIGNUM(y)->len;
ds1 = BDIGITS(x);
ds2 = BDIGITS(y);
- sign = RBIGNUM_SIGN(x);
+ sign = RBIGNUM(x)->sign;
}
- z = bignew(l2, RBIGNUM_SIGN(x) || RBIGNUM_SIGN(y));
+ z = bignew(l2, RBIGNUM(x)->sign || RBIGNUM(y)->sign);
zds = BDIGITS(z);
for (i=0; i<l1; i++) {
@@ -2082,7 +1872,7 @@ rb_big_and(VALUE xx, VALUE yy)
for (; i<l2; i++) {
zds[i] = sign?0:ds2[i];
}
- if (!RBIGNUM_SIGN(z)) get2comp(z);
+ if (!RBIGNUM(z)->sign) get2comp(z);
return bignorm(z);
}
@@ -2094,7 +1884,8 @@ rb_big_and(VALUE xx, VALUE yy)
*/
VALUE
-rb_big_or(VALUE xx, VALUE yy)
+rb_big_or(xx, yy)
+ VALUE xx, yy;
{
volatile VALUE x, y, z;
BDIGIT *ds1, *ds2, *zds;
@@ -2106,30 +1897,29 @@ rb_big_or(VALUE xx, VALUE yy)
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
-
- if (!RBIGNUM_SIGN(y)) {
+ if (!RBIGNUM(y)->sign) {
y = rb_big_clone(y);
get2comp(y);
}
- if (!RBIGNUM_SIGN(x)) {
+ if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
get2comp(x);
}
- if (RBIGNUM_LEN(x) > RBIGNUM_LEN(y)) {
- l1 = RBIGNUM_LEN(y);
- l2 = RBIGNUM_LEN(x);
+ if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
+ l1 = RBIGNUM(y)->len;
+ l2 = RBIGNUM(x)->len;
ds1 = BDIGITS(y);
ds2 = BDIGITS(x);
- sign = RBIGNUM_SIGN(y);
+ sign = RBIGNUM(y)->sign;
}
else {
- l1 = RBIGNUM_LEN(x);
- l2 = RBIGNUM_LEN(y);
+ l1 = RBIGNUM(x)->len;
+ l2 = RBIGNUM(y)->len;
ds1 = BDIGITS(x);
ds2 = BDIGITS(y);
- sign = RBIGNUM_SIGN(x);
+ sign = RBIGNUM(x)->sign;
}
- z = bignew(l2, RBIGNUM_SIGN(x) && RBIGNUM_SIGN(y));
+ z = bignew(l2, RBIGNUM(x)->sign && RBIGNUM(y)->sign);
zds = BDIGITS(z);
for (i=0; i<l1; i++) {
@@ -2138,7 +1928,7 @@ rb_big_or(VALUE xx, VALUE yy)
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:(BIGRAD-1);
}
- if (!RBIGNUM_SIGN(z)) get2comp(z);
+ if (!RBIGNUM(z)->sign) get2comp(z);
return bignorm(z);
}
@@ -2151,7 +1941,8 @@ rb_big_or(VALUE xx, VALUE yy)
*/
VALUE
-rb_big_xor(VALUE xx, VALUE yy)
+rb_big_xor(xx, yy)
+ VALUE xx, yy;
{
volatile VALUE x, y;
VALUE z;
@@ -2164,32 +1955,31 @@ rb_big_xor(VALUE xx, VALUE yy)
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
-
- if (!RBIGNUM_SIGN(y)) {
+ if (!RBIGNUM(y)->sign) {
y = rb_big_clone(y);
get2comp(y);
}
- if (!RBIGNUM_SIGN(x)) {
+ if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
get2comp(x);
}
- if (RBIGNUM_LEN(x) > RBIGNUM_LEN(y)) {
- l1 = RBIGNUM_LEN(y);
- l2 = RBIGNUM_LEN(x);
+ if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
+ l1 = RBIGNUM(y)->len;
+ l2 = RBIGNUM(x)->len;
ds1 = BDIGITS(y);
ds2 = BDIGITS(x);
- sign = RBIGNUM_SIGN(y);
+ sign = RBIGNUM(y)->sign;
}
else {
- l1 = RBIGNUM_LEN(x);
- l2 = RBIGNUM_LEN(y);
+ l1 = RBIGNUM(x)->len;
+ l2 = RBIGNUM(y)->len;
ds1 = BDIGITS(x);
ds2 = BDIGITS(y);
- sign = RBIGNUM_SIGN(x);
+ sign = RBIGNUM(x)->sign;
}
- RBIGNUM_SET_SIGN(x, RBIGNUM_SIGN(x)?1:0);
- RBIGNUM_SET_SIGN(y, RBIGNUM_SIGN(y)?1:0);
- z = bignew(l2, !(RBIGNUM_SIGN(x) ^ RBIGNUM_SIGN(y)));
+ RBIGNUM(x)->sign = RBIGNUM(x)->sign?1:0;
+ RBIGNUM(y)->sign = RBIGNUM(y)->sign?1:0;
+ z = bignew(l2, !(RBIGNUM(x)->sign ^ RBIGNUM(y)->sign));
zds = BDIGITS(z);
for (i=0; i<l1; i++) {
@@ -2198,7 +1988,7 @@ rb_big_xor(VALUE xx, VALUE yy)
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:~ds2[i];
}
- if (!RBIGNUM_SIGN(z)) get2comp(z);
+ if (!RBIGNUM(z)->sign) get2comp(z);
return bignorm(z);
}
@@ -2206,9 +1996,9 @@ rb_big_xor(VALUE xx, VALUE yy)
static VALUE
check_shiftdown(VALUE y, VALUE x)
{
- if (!RBIGNUM_LEN(x)) return INT2FIX(0);
- if (RBIGNUM_LEN(y) > SIZEOF_LONG / SIZEOF_BDIGITS) {
- return RBIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(-1);
+ if (!RBIGNUM(x)->len) return INT2FIX(0);
+ if (RBIGNUM(y)->len > SIZEOF_LONG / SIZEOF_BDIGITS) {
+ return RBIGNUM(x)->sign ? INT2FIX(0) : INT2FIX(-1);
}
return Qnil;
}
@@ -2221,7 +2011,8 @@ check_shiftdown(VALUE y, VALUE x)
*/
VALUE
-rb_big_lshift(VALUE x, VALUE y)
+rb_big_lshift(x, y)
+ VALUE x, y;
{
long shift;
int neg = 0;
@@ -2236,12 +2027,12 @@ rb_big_lshift(VALUE x, VALUE y)
break;
}
else if (TYPE(y) == T_BIGNUM) {
- if (!RBIGNUM_SIGN(y)) {
+ if (!RBIGNUM(y)->sign) {
VALUE t = check_shiftdown(y, x);
if (!NIL_P(t)) return t;
neg = 1;
}
- shift = big2ulong(y, "long", Qtrue);
+ shift = big2ulong(y, "long");
break;
}
y = rb_to_int(y);
@@ -2252,7 +2043,9 @@ rb_big_lshift(VALUE x, VALUE y)
}
static VALUE
-big_lshift(VALUE x, unsigned long shift)
+big_lshift(x, shift)
+ VALUE x;
+ unsigned long shift;
{
BDIGIT *xds, *zds;
long s1 = shift/BITSPERDIG;
@@ -2261,8 +2054,8 @@ big_lshift(VALUE x, unsigned long shift)
BDIGIT_DBL num = 0;
long len, i;
- len = RBIGNUM_LEN(x);
- z = bignew(len+s1+1, RBIGNUM_SIGN(x));
+ len = RBIGNUM(x)->len;
+ z = bignew(len+s1+1, RBIGNUM(x)->sign);
zds = BDIGITS(z);
for (i=0; i<s1; i++) {
*zds++ = 0;
@@ -2285,7 +2078,8 @@ big_lshift(VALUE x, unsigned long shift)
*/
VALUE
-rb_big_rshift(VALUE x, VALUE y)
+rb_big_rshift(x, y)
+ VALUE x, y;
{
long shift;
int neg = 0;
@@ -2300,14 +2094,14 @@ rb_big_rshift(VALUE x, VALUE y)
break;
}
else if (TYPE(y) == T_BIGNUM) {
- if (RBIGNUM_SIGN(y)) {
+ if (RBIGNUM(y)->sign) {
VALUE t = check_shiftdown(y, x);
if (!NIL_P(t)) return t;
}
else {
neg = 1;
}
- shift = big2ulong(y, "long", Qtrue);
+ shift = big2ulong(y, "long");
break;
}
y = rb_to_int(y);
@@ -2318,7 +2112,9 @@ rb_big_rshift(VALUE x, VALUE y)
}
static VALUE
-big_rshift(VALUE x, unsigned long shift)
+big_rshift(x, shift)
+ VALUE x;
+ unsigned long shift;
{
BDIGIT *xds, *zds;
long s1 = shift/BITSPERDIG;
@@ -2328,24 +2124,24 @@ big_rshift(VALUE x, unsigned long shift)
long i, j;
volatile VALUE save_x;
- if (s1 > RBIGNUM_LEN(x)) {
- if (RBIGNUM_SIGN(x))
+ if (s1 > RBIGNUM(x)->len) {
+ if (RBIGNUM(x)->sign)
return INT2FIX(0);
else
return INT2FIX(-1);
}
- if (!RBIGNUM_SIGN(x)) {
+ if (!RBIGNUM(x)->sign) {
save_x = x = rb_big_clone(x);
get2comp(x);
}
xds = BDIGITS(x);
- i = RBIGNUM_LEN(x); j = i - s1;
+ i = RBIGNUM(x)->len; j = i - s1;
if (j == 0) {
- if (RBIGNUM_SIGN(x)) return INT2FIX(0);
+ if (RBIGNUM(x)->sign) return INT2FIX(0);
else return INT2FIX(-1);
}
- z = bignew(j, RBIGNUM_SIGN(x));
- if (!RBIGNUM_SIGN(x)) {
+ z = bignew(j, RBIGNUM(x)->sign);
+ if (!RBIGNUM(x)->sign) {
num = ((BDIGIT_DBL)~0) << BITSPERDIG;
}
zds = BDIGITS(z);
@@ -2354,7 +2150,7 @@ big_rshift(VALUE x, unsigned long shift)
zds[j] = BIGLO(num);
num = BIGUP(xds[i]);
}
- if (!RBIGNUM_SIGN(x)) {
+ if (!RBIGNUM(x)->sign) {
get2comp(z);
}
return bignorm(z);
@@ -2380,21 +2176,22 @@ big_rshift(VALUE x, unsigned long shift)
*/
static VALUE
-rb_big_aref(VALUE x, VALUE y)
+rb_big_aref(x, y)
+ VALUE x, y;
{
BDIGIT *xds;
BDIGIT_DBL num;
- VALUE shift;
+ unsigned long shift;
long i, s1, s2;
if (TYPE(y) == T_BIGNUM) {
- if (!RBIGNUM_SIGN(y))
+ if (!RBIGNUM(y)->sign)
return INT2FIX(0);
- if (RBIGNUM_LEN(bigtrunc(y)) > DIGSPERLONG) {
+ if (RBIGNUM(bigtrunc(y))->len > SIZEOF_LONG/SIZEOF_BDIGITS) {
out_of_range:
- return RBIGNUM_SIGN(x) ? INT2FIX(0) : INT2FIX(1);
+ return RBIGNUM(x)->sign ? INT2FIX(0) : INT2FIX(1);
}
- shift = big2ulong(y, "long", Qfalse);
+ shift = big2ulong(y, "long");
}
else {
i = NUM2LONG(y);
@@ -2404,8 +2201,8 @@ rb_big_aref(VALUE x, VALUE y)
s1 = shift/BITSPERDIG;
s2 = shift%BITSPERDIG;
- if (s1 >= RBIGNUM_LEN(x)) goto out_of_range;
- if (!RBIGNUM_SIGN(x)) {
+ 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) {
@@ -2428,12 +2225,17 @@ rb_big_aref(VALUE x, VALUE y)
*/
static VALUE
-rb_big_hash(VALUE x)
+rb_big_hash(x)
+ VALUE x;
{
- int hash;
+ long i, len, key;
+ BDIGIT *digits;
- hash = rb_memhash(BDIGITS(x), sizeof(BDIGIT)*RBIGNUM_LEN(x)) ^ RBIGNUM_SIGN(x);
- return INT2FIX(hash);
+ key = 0; digits = BDIGITS(x); len = RBIGNUM(x)->len;
+ for (i=0; i<len; i++) {
+ key ^= *digits++;
+ }
+ return LONG2FIX(key);
}
/*
@@ -2441,7 +2243,8 @@ rb_big_hash(VALUE x)
*/
static VALUE
-rb_big_coerce(VALUE x, VALUE y)
+rb_big_coerce(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
return rb_assoc_new(rb_int2big(FIX2LONG(y)), x);
@@ -2467,15 +2270,37 @@ rb_big_coerce(VALUE x, VALUE y)
*/
static VALUE
-rb_big_abs(VALUE x)
+rb_big_abs(x)
+ VALUE x;
{
- if (!RBIGNUM_SIGN(x)) {
+ if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
- RBIGNUM_SET_SIGN(x, 1);
+ RBIGNUM(x)->sign = 1;
}
return x;
}
+VALUE
+rb_big_rand(max, rand_buf)
+ VALUE max;
+ double *rand_buf;
+{
+ VALUE v;
+ long len = RBIGNUM(max)->len;
+
+ if (BIGZEROP(max)) {
+ return rb_float_new(rand_buf[0]);
+ }
+ v = bignew(len,1);
+ len--;
+ BDIGITS(v)[len] = BDIGITS(max)[len] * rand_buf[len];
+ while (len--) {
+ BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
+ }
+
+ return v;
+}
+
/*
* call-seq:
* big.size -> integer
@@ -2489,41 +2314,10 @@ rb_big_abs(VALUE x)
*/
static VALUE
-rb_big_size(VALUE big)
-{
- return LONG2FIX(RBIGNUM_LEN(big)*SIZEOF_BDIGITS);
-}
-
-/*
- * call-seq:
- * big.odd? -> true or false
- *
- * Returns <code>true</code> if <i>big</i> is an odd number.
- */
-
-static VALUE
-rb_big_odd_p(VALUE num)
-{
- if (BDIGITS(num)[0] & 1) {
- return Qtrue;
- }
- return Qfalse;
-}
-
-/*
- * call-seq:
- * big.even? -> true or false
- *
- * Returns <code>true</code> if <i>big</i> is an even number.
- */
-
-static VALUE
-rb_big_even_p(VALUE num)
+rb_big_size(big)
+ VALUE big;
{
- if (BDIGITS(num)[0] & 1) {
- return Qfalse;
- }
- return Qtrue;
+ return LONG2FIX(RBIGNUM(big)->len*SIZEOF_BDIGITS);
}
/*
@@ -2545,7 +2339,7 @@ rb_big_even_p(VALUE num)
*/
void
-Init_Bignum(void)
+Init_Bignum()
{
rb_cBignum = rb_define_class("Bignum", rb_cInteger);
@@ -2579,8 +2373,4 @@ Init_Bignum(void)
rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0);
rb_define_method(rb_cBignum, "abs", rb_big_abs, 0);
rb_define_method(rb_cBignum, "size", rb_big_size, 0);
- rb_define_method(rb_cBignum, "odd?", rb_big_odd_p, 0);
- rb_define_method(rb_cBignum, "even?", rb_big_even_p, 0);
-
- power_cache_init();
}
diff --git a/bin/gem b/bin/gem
deleted file mode 100755
index 5478606c52..0000000000
--- a/bin/gem
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-require 'rubygems/gem_runner'
-
-required_version = Gem::Requirement.new ">= 1.8.2"
-
-unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then
- abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"
-end
-
-# We need to preserve the original ARGV to use for passing gem options
-# to source gems. If there is a -- in the line, strip all options after
-# it...its for the source building process.
-args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
-
-Gem::GemRunner.new.run args
-
diff --git a/bin/irb b/bin/irb
index c833aa866a..f277bc4b69 100644
--- a/bin/irb
+++ b/bin/irb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
#
-# irb.rb - interactive ruby
+# irb.rb - intaractive ruby
# $Release Version: 0.9.5 $
# $Revision$
# $Date$
diff --git a/bin/rake b/bin/rake
deleted file mode 100755
index c9e95da611..0000000000
--- a/bin/rake
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env ruby
-
-#--
-# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#++
-
-begin
- require 'rake'
-rescue LoadError
- require 'rubygems'
- require 'rake'
-end
-Rake.application.run
diff --git a/bin/rdoc b/bin/rdoc
index 7192db2655..fe619137fd 100644
--- a/bin/rdoc
+++ b/bin/rdoc
@@ -46,7 +46,7 @@ end
$:.each do |path|
if /site_ruby/ =~ path
rdoc_path = File.join(path, 'rdoc', 'rdoc.rb')
- if File.exist?(rdoc_path)
+ if File.exists?(rdoc_path)
adjust_for_existing_rdoc(path)
break
end
diff --git a/bin/ri b/bin/ri
index ae793f6962..fb3e00eda3 100755
--- a/bin/ri
+++ b/bin/ri
@@ -7,7 +7,7 @@
#
# Class | Class::method | Class#method | Class.method | method
#
-# All names may be abbreviated to their minimum unambiguous form. If a name
+# All names may be abbreviated to their minimum unbiguous form. If a name
# _is_ ambiguous, all valid options will be listed.
#
# The form '.' method matches either class or instance methods, while
diff --git a/blockinlining.c b/blockinlining.c
deleted file mode 100644
index 3c6fda4a6b..0000000000
--- a/blockinlining.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/**********************************************************************
-
- blockinlining.c -
-
- $Author$
- $Date$
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "vm_core.h"
-
-static VALUE
-iseq_special_block(rb_iseq_t *iseq, void *builder)
-{
-#if OPT_BLOCKINLINING
- VALUE parent = Qfalse;
- VALUE iseqval;
-
- if (iseq->argc > 1 || iseq->arg_simple == 0) {
- /* argument check */
- return 0;
- }
-
- if (iseq->cached_special_block_builder) {
- if (iseq->cached_special_block_builder == builder) {
- return iseq->cached_special_block;
- }
- else {
- return 0;
- }
- }
- else {
- iseq->cached_special_block_builder = (void *)1;
- }
-
- if (iseq->parent_iseq) {
- parent = iseq->parent_iseq->self;
- }
- iseqval = rb_iseq_new_with_bopt(iseq->node, iseq->name, iseq->filename,
- parent, iseq->type,
- GC_GUARDED_PTR(builder));
- if (0) {
- printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
- }
- iseq->cached_special_block = iseqval;
- iseq->cached_special_block_builder = builder;
- return iseqval;
-#else
- return 0;
-#endif
-}
-
-static NODE *
-new_block(NODE * head, NODE * tail)
-{
- head = NEW_BLOCK(head);
- tail = NEW_BLOCK(tail);
- head->nd_next = tail;
- return head;
-}
-
-static NODE *
-new_ary(NODE * head, NODE * tail)
-{
- head = NEW_ARRAY(head);
- head->nd_next = tail;
- return head;
-}
-
-static NODE *
-new_assign(NODE * lnode, NODE * rhs)
-{
- switch (nd_type(lnode)) {
- case NODE_LASGN:{
- return NEW_NODE(NODE_LASGN, lnode->nd_vid, rhs, lnode->nd_cnt);
- /* NEW_LASGN(lnode->nd_vid, rhs); */
- }
- case NODE_GASGN:{
- return NEW_GASGN(lnode->nd_vid, rhs);
- }
- case NODE_DASGN:{
- return NEW_DASGN(lnode->nd_vid, rhs);
- }
- case NODE_ATTRASGN:{
- NODE *args = 0;
- if (lnode->nd_args) {
- args = NEW_ARRAY(lnode->nd_args->nd_head);
- args->nd_next = NEW_ARRAY(rhs);
- args->nd_alen = 2;
- }
- else {
- args = NEW_ARRAY(rhs);
- }
-
- return NEW_ATTRASGN(lnode->nd_recv,
- lnode->nd_mid,
- args);
- }
- default:
- rb_bug("unimplemented (block inlining): %s", ruby_node_name(nd_type(lnode)));
- }
- return 0;
-}
-
-static NODE *
-build_Integer_times_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
- VALUE param_vars, VALUE local_vars)
-{
- /* Special Block for Integer#times
- {|e, _self|
- _e = e
- while(e < _self)
- e = _e
- redo_point:
- BODY
- next_point:
- _e = _e.succ
- end
- }
-
- {|e, _self|
- while(e < _self)
- BODY
- next_point:
- e = e.succ
- end
- }
- */
- ID _self = rb_intern("#_self");
- if (iseq->argc == 0) {
- ID e = rb_intern("#e");
- rb_ary_push(param_vars, ID2SYM(e));
- rb_ary_push(param_vars, ID2SYM(_self));
- iseq->argc += 2;
-
- node =
- NEW_WHILE(NEW_CALL
- (NEW_DVAR(e), idLT, new_ary(NEW_DVAR(_self), 0)),
- new_block(NEW_OPTBLOCK(node),
- NEW_DASGN(e,
- NEW_CALL(NEW_DVAR(e), idSucc, 0))),
- Qundef);
- }
- else {
- ID _e = rb_intern("#_e");
- ID e = SYM2ID(rb_ary_entry(param_vars, 0));
- NODE *assign;
-
- rb_ary_push(param_vars, ID2SYM(_self));
- rb_ary_push(local_vars, ID2SYM(_e));
- iseq->argc++;
-
- if (nd_type(lnode) == NODE_DASGN_CURR) {
- assign = NEW_DASGN(e, NEW_DVAR(_e));
- }
- else {
- assign = new_assign(lnode, NEW_DVAR(_e));
- }
-
- node =
- new_block(NEW_DASGN(_e, NEW_DVAR(e)),
- NEW_WHILE(NEW_CALL
- (NEW_DVAR(_e), idLT,
- new_ary(NEW_DVAR(_self), 0)),
- new_block(assign,
- new_block(NEW_OPTBLOCK(node),
- NEW_DASGN(_e,
- NEW_CALL
- (NEW_DVAR(_e),
- idSucc, 0)))),
- Qundef));
- }
- return node;
-}
-
-VALUE
-invoke_Integer_times_special_block(VALUE num)
-{
- rb_thread_t *th = GET_THREAD();
- rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
-
- if (orig_block && BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
- VALUE tsiseqval = iseq_special_block(orig_block->iseq,
- build_Integer_times_node);
- rb_iseq_t *tsiseq;
- VALUE argv[2], val;
-
- if (tsiseqval) {
- rb_block_t block = *orig_block;
- GetISeqPtr(tsiseqval, tsiseq);
- block.iseq = tsiseq;
- th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
- argv[0] = INT2FIX(0);
- argv[1] = num;
- val = vm_yield(th, 2, argv);
- if (val == Qundef) {
- return num;
- }
- else {
- return val;
- }
- }
- }
- return Qundef;
-}
-
-static NODE *
-build_Range_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
- VALUE param_vars, VALUE local_vars, ID mid)
-{
- /* Special Block for Range#each
- {|e, _last|
- _e = e
- while _e < _last
- e = _e
- next_point:
- BODY
- redo_point:
- _e = _e.succ
- end
- }
- {|e, _last|
- while e < _last
- BODY
- redo_point:
- e = e.succ
- end
- }
- */
- ID _last = rb_intern("#_last");
- if (iseq->argc == 0) {
- ID e = rb_intern("#e");
- rb_ary_push(param_vars, ID2SYM(e));
- rb_ary_push(param_vars, ID2SYM(_last));
- iseq->argc += 2;
-
- node =
- NEW_WHILE(NEW_CALL(NEW_DVAR(e), mid, new_ary(NEW_DVAR(_last), 0)),
- new_block(NEW_OPTBLOCK(node),
- NEW_DASGN(e,
- NEW_CALL(NEW_DVAR(e), idSucc, 0))),
- Qundef);
- }
- else {
- ID _e = rb_intern("#_e");
- ID e = SYM2ID(rb_ary_entry(param_vars, 0));
- NODE *assign;
-
- rb_ary_push(param_vars, ID2SYM(_last));
- rb_ary_push(local_vars, ID2SYM(_e));
- iseq->argc++;
-
- if (nd_type(lnode) == NODE_DASGN_CURR) {
- assign = NEW_DASGN(e, NEW_DVAR(_e));
- }
- else {
- assign = new_assign(lnode, NEW_DVAR(_e));
- }
-
- node =
- new_block(NEW_DASGN(_e, NEW_DVAR(e)),
- NEW_WHILE(NEW_CALL
- (NEW_DVAR(_e), mid,
- new_ary(NEW_DVAR(_last), 0)),
- new_block(assign,
- new_block(NEW_OPTBLOCK(node),
- NEW_DASGN(_e,
- NEW_CALL
- (NEW_DVAR(_e),
- idSucc, 0)))),
- Qundef));
- }
- return node;
-}
-
-static NODE *
-build_Range_each_node_LE(rb_iseq_t *iseq, NODE * node, NODE * lnode,
- VALUE param_vars, VALUE local_vars)
-{
- return build_Range_each_node(iseq, node, lnode,
- param_vars, local_vars, idLE);
-}
-
-static NODE *
-build_Range_each_node_LT(rb_iseq_t *iseq, NODE * node, NODE * lnode,
- VALUE param_vars, VALUE local_vars)
-{
- return build_Range_each_node(iseq, node, lnode,
- param_vars, local_vars, idLT);
-}
-
-VALUE
-invoke_Range_each_special_block(VALUE range,
- VALUE beg, VALUE end, int excl)
-{
- rb_thread_t *th = GET_THREAD();
- rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
-
- if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
- void *builder =
- excl ? build_Range_each_node_LT : build_Range_each_node_LE;
- VALUE tsiseqval = iseq_special_block(orig_block->iseq, builder);
- rb_iseq_t *tsiseq;
- VALUE argv[2];
-
- if (tsiseqval) {
- VALUE val;
- rb_block_t block = *orig_block;
- GetISeqPtr(tsiseqval, tsiseq);
- block.iseq = tsiseq;
- th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
- argv[0] = beg;
- argv[1] = end;
- val = vm_yield(th, 2, argv);
- if (val == Qundef) {
- return range;
- }
- else {
- return val;
- }
- }
- }
- return Qundef;
-}
-
-
-static NODE *
-build_Array_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
- VALUE param_vars, VALUE local_vars)
-{
- /* Special block for Array#each
- ary.each{|e|
- BODY
- }
- =>
- {|e, _self|
- _i = 0
- while _i < _self.length
- e = _self[_i]
- redo_point:
- BODY
- next_point:
- _i = _i.succ
- end
- }
-
- ary.each{
- BODY
- }
- =>
- {|_i, _self|
- _i = 0
- while _i < _self.length
- redo_point:
- BODY
- next_point:
- _i = _i.succ
- end
- }
- */
-
- ID _self = rb_intern("#_self");
- ID _i = rb_intern("#_i");
-
- if (iseq->argc == 0) {
- ID _e = rb_intern("#_e");
- rb_ary_push(param_vars, ID2SYM(_e));
- rb_ary_push(param_vars, ID2SYM(_self));
- iseq->argc += 2;
- rb_ary_push(local_vars, ID2SYM(_i));
-
- node =
- new_block(NEW_DASGN(_i, NEW_LIT(INT2FIX(0))),
- NEW_WHILE(NEW_CALL(NEW_DVAR(_i), idLT,
- new_ary(NEW_CALL
- (NEW_DVAR(_self), idLength,
- 0), 0)),
- new_block(NEW_OPTBLOCK(node),
- NEW_DASGN(_i,
- NEW_CALL(NEW_DVAR(_i),
- idSucc, 0))),
- Qundef));
- }
- else {
- ID e = SYM2ID(rb_ary_entry(param_vars, 0));
- NODE *assign;
-
- rb_ary_push(param_vars, ID2SYM(_self));
- iseq->argc++;
- rb_ary_push(local_vars, ID2SYM(_i));
-
- if (nd_type(lnode) == NODE_DASGN_CURR) {
- assign = NEW_DASGN(e,
- NEW_CALL(NEW_DVAR(_self), idAREF,
- new_ary(NEW_DVAR(_i), 0)));
- }
- else {
- assign = new_assign(lnode,
- NEW_CALL(NEW_DVAR(_self), idAREF,
- new_ary(NEW_DVAR(_i), 0)));
- }
-
- node =
- new_block(NEW_DASGN(_i, NEW_LIT(INT2FIX(0))),
- NEW_WHILE(NEW_CALL(NEW_DVAR(_i), idLT,
- new_ary(NEW_CALL
- (NEW_DVAR(_self), idLength,
- 0), 0)), new_block(assign,
- new_block
- (NEW_OPTBLOCK
- (node),
- NEW_DASGN
- (_i,
- NEW_CALL
- (NEW_DVAR
- (_i),
- idSucc,
- 0)))),
- Qundef));
- }
- return node;
-}
-
-VALUE
-invoke_Array_each_special_block(VALUE ary)
-{
- rb_thread_t *th = GET_THREAD();
- rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
-
- if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
- VALUE tsiseqval = iseq_special_block(orig_block->iseq,
- build_Array_each_node);
- rb_iseq_t *tsiseq;
- VALUE argv[2];
-
- if (tsiseqval) {
- VALUE val;
- rb_block_t block = *orig_block;
- GetISeqPtr(tsiseqval, tsiseq);
- block.iseq = tsiseq;
- th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
- argv[0] = 0;
- argv[1] = ary;
- val = vm_yield(th, 2, argv);
- if (val == Qundef) {
- return ary;
- }
- else {
- return val;
- }
- }
- }
- return Qundef;
-}
diff --git a/bootstraptest/pending.rb b/bootstraptest/pending.rb
deleted file mode 100644
index 9629cea636..0000000000
--- a/bootstraptest/pending.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-assert_equal 'ok', %q{
- 1.times{
- eval("break")
- }
- :ok
-}, '[ruby-dev:32525]'
-
-assert_equal "ok", %q{
- module Foo
- end
-
- begin
- def foo(&b)
- Foo.module_eval &b
- end
- foo{
- def bar
- end
- }
- bar
- rescue NoMethodError
- :ok
- end
-}, '[ruby-core:14378]'
-
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
deleted file mode 100644
index fd921f4675..0000000000
--- a/bootstraptest/runner.rb
+++ /dev/null
@@ -1,318 +0,0 @@
-# $Id$
-
-# NOTE:
-# Never use optparse in this file.
-# Never use test/unit in this file.
-# Never use Ruby extensions in this file.
-
-begin
- require 'fileutils'
- require 'tmpdir'
-rescue LoadError
- $:.unshift File.join(File.dirname(__FILE__), '../lib')
- retry
-end
-
-if !Dir.respond_to?(:mktmpdir)
- # copied from lib/tmpdir.rb
- def Dir.mktmpdir(prefix="d", tmpdir=nil)
- tmpdir ||= Dir.tmpdir
- t = Time.now.strftime("%Y%m%d")
- n = nil
- begin
- path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
- path << "-#{n}" if n
- Dir.mkdir(path, 0700)
- rescue Errno::EEXIST
- n ||= 0
- n += 1
- retry
- end
-
- if block_given?
- begin
- yield path
- ensure
- FileUtils.remove_entry_secure path
- end
- else
- path
- end
- end
-end
-
-def main
- @ruby = File.expand_path('miniruby')
- @verbose = false
- dir = nil
- quiet = false
- tests = nil
- ARGV.delete_if {|arg|
- case arg
- when /\A--ruby=(.*)/
- @ruby = File.expand_path($1)
- true
- when /\A--sets=(.*)/
- tests = Dir.glob("#{File.dirname($0)}/test_{#{$1}}*.rb")
- puts tests.map {|path| File.basename(path) }.inspect
- true
- when /\A--dir=(.*)/
- dir = $1
- true
- when /\A(--stress|-s)/
- $stress = true
- when /\A(-q|--q(uiet))\z/
- quiet = true
- true
- when /\A(-v|--v(erbose))\z/
- @verbose = true
- when /\A(-h|--h(elp)?)\z/
- puts(<<-End)
-Usage: #{File.basename($0, '.*')} --ruby=PATH [--sets=NAME,NAME,...]
- --sets=NAME,NAME,... Name of test sets.
- --dir=DIRECTORY Working directory.
- default: /tmp/bootstraptest.tmpwd
- -s, --stress stress test.
- -v, --verbose Output test name before exec.
- -q, --quiet Don\'t print header message.
- -h, --help Print this message and quit.
-End
- exit 0
- else
- false
- end
- }
- if tests and not ARGV.empty?
- $stderr.puts "--tests and arguments are exclusive"
- exit 1
- end
- tests ||= ARGV
- tests = Dir.glob("#{File.dirname($0)}/test_*.rb") if tests.empty?
- pathes = tests.map {|path| File.expand_path(path) }
-
- unless quiet
- puts Time.now
- patchlevel = defined?(RUBY_PATCHLEVEL) ? " patchlevel #{RUBY_PATCHLEVEL}" : ''
- puts "Driver is ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}#{patchlevel}) [#{RUBY_PLATFORM}]"
- puts "Target is #{`#{@ruby} -v`}"
- puts
- $stdout.flush
- end
-
- in_temporary_working_directory(dir) {
- exec_test pathes
- }
-end
-
-def exec_test(pathes)
- @count = 0
- @error = 0
- @errbuf = []
- @location = nil
- pathes.each do |path|
- $stderr.print "\n#{File.basename(path)} "
- load File.expand_path(path)
- end
- $stderr.puts
- if @error == 0
- $stderr.puts "PASS #{@count} tests"
- exit 0
- else
- @errbuf.each do |msg|
- $stderr.puts msg
- end
- $stderr.puts "FAIL #{@error}/#{@count} tests failed"
- exit 1
- end
-end
-
-def assert_check(testsrc, message = '')
- $stderr.puts "\##{@count} #{@location}" if @verbose
- result = get_result_string(testsrc)
- check_coredump
- faildesc = yield(result)
- if !faildesc
- $stderr.print '.'
- else
- $stderr.print 'F'
- error faildesc, message
- end
-rescue Exception => err
- $stderr.print 'E'
- error err.message, message
-end
-
-def assert_equal(expected, testsrc, message = '')
- newtest
- assert_check(testsrc, message) {|result|
- if expected == result
- nil
- else
- desc = "#{result.inspect} (expected #{expected.inspect})"
- pretty(testsrc, desc, result)
- end
- }
-end
-
-def assert_match(expected_pattern, testsrc, message = '')
- newtest
- assert_check(testsrc, message) {|result|
- if expected_pattern =~ result
- nil
- else
- desc = "#{expected_pattern.inspect} expected to be =~\n#{result.inspect}"
- pretty(testsrc, desc, result)
- end
- }
-end
-
-def assert_not_match(unexpected_pattern, testsrc, message = '')
- newtest
- assert_check(testsrc, message) {|result|
- if unexpected_pattern !~ result
- nil
- else
- desc = "#{unexpected_pattern.inspect} expected to be !~\n#{result.inspect}"
- pretty(testsrc, desc, result)
- end
- }
-end
-
-def assert_normal_exit(testsrc, message = '')
- newtest
- $stderr.puts "\##{@count} #{@location}" if @verbose
- faildesc = nil
- filename = make_srcfile(testsrc)
- `#{@ruby} -W0 #{filename}`
- if $?.signaled?
- signo = $?.termsig
- signame = Signal.list.invert[signo]
- sigdesc = "signal #{signo}"
- if signame
- sigdesc = "SIG#{signame} (#{sigdesc})"
- end
- faildesc = pretty(testsrc, "killed by #{sigdesc}", nil)
- end
- if !faildesc
- $stderr.print '.'
- else
- $stderr.print 'F'
- error faildesc, message
- end
-rescue Exception => err
- $stderr.print 'E'
- error err.message, message
-end
-
-def assert_finish(timeout_seconds, testsrc, message = '')
- newtest
- $stderr.puts "\##{@count} #{@location}" if @verbose
- faildesc = nil
- filename = make_srcfile(testsrc)
- io = IO.popen("#{@ruby} -W0 #{filename}")
- pid = io.pid
- waited = false
- tlimit = Time.now + timeout_seconds
- while Time.now < tlimit
- if Process.waitpid pid, Process::WNOHANG
- waited = true
- break
- end
- sleep 0.1
- end
- if !waited
- Process.kill(:KILL, pid)
- Process.waitpid pid
- faildesc = pretty(testsrc, "not finished in #{timeout_seconds} seconds", nil)
- end
- io.close
- if !faildesc
- $stderr.print '.'
- else
- $stderr.print 'F'
- error faildesc, message
- end
-rescue Exception => err
- $stderr.print 'E'
- error err.message, message
-end
-
-def pretty(src, desc, result)
- src = src.sub(/\A.*\n/, '')
- (/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) + " #=> #{desc}"
-end
-
-INDENT = 27
-
-def adjust_indent(src)
- untabify(src).gsub(/^ {#{INDENT}}/o, '').gsub(/^/, ' ')
-end
-
-def untabify(str)
- str.gsub(/^\t+/) {|tabs| ' ' * (8 * tabs.size) }
-end
-
-def make_srcfile(src)
- filename = 'bootstraptest.tmp.rb'
- File.open(filename, 'w') {|f|
- f.puts "GC.stress = true" if $stress
- f.puts "print(begin; #{src}; end)"
- }
- filename
-end
-
-def get_result_string(src)
- if @ruby
- filename = make_srcfile(src)
- begin
- `#{@ruby} -W0 #{filename}`
- ensure
- raise CoreDumpError, "core dumped" if $? and $?.coredump?
- end
- else
- eval(src).to_s
- end
-end
-
-def newtest
- @location = File.basename(caller(2).first)
- @count += 1
- cleanup_coredump
-end
-
-def error(msg, additional_message)
- @errbuf.push "\##{@count} #{@location}: #{msg} #{additional_message}"
- @error += 1
-end
-
-def in_temporary_working_directory(dir)
- if dir
- Dir.mkdir dir
- Dir.chdir(dir) {
- yield
- }
- else
- Dir.mktmpdir("bootstraptest.tmpwd") {|d|
- Dir.chdir(d) {
- yield
- }
- }
- end
-end
-
-def cleanup_coredump
- FileUtils.rm_f 'core'
- FileUtils.rm_f Dir.glob('core.*')
- FileUtils.rm_f @ruby+'.stackdump' if @ruby
-end
-
-class CoreDumpError < StandardError; end
-
-def check_coredump
- if File.file?('core') or not Dir.glob('core.*').empty? or
- (@ruby and File.exist?(@ruby+'.stackdump'))
- raise CoreDumpError, "core dumped"
- end
-end
-
-main
diff --git a/bootstraptest/test_block.rb b/bootstraptest/test_block.rb
deleted file mode 100644
index 2db149063e..0000000000
--- a/bootstraptest/test_block.rb
+++ /dev/null
@@ -1,549 +0,0 @@
-assert_equal %q{1}, %q{
- 1.times{
- begin
- a = 1
- ensure
- foo = nil
- end
- }
-}
-assert_equal %q{2}, %q{
- [1,2,3].find{|x| x == 2}
-}
-assert_equal %q{2}, %q{
- class E
- include Enumerable
- def each(&block)
- [1, 2, 3].each(&block)
- end
- end
- E.new.find {|x| x == 2 }
-}
-assert_equal %q{6}, %q{
- sum = 0
- for x in [1, 2, 3]
- sum += x
- end
- sum
-}
-assert_equal %q{15}, %q{
- sum = 0
- for x in (1..5)
- sum += x
- end
- sum
-}
-assert_equal %q{0}, %q{
- sum = 0
- for x in []
- sum += x
- end
- sum
-}
-assert_equal %q{1}, %q{
- ans = []
- 1.times{
- for n in 1..3
- a = n
- ans << a
- end
- }
-}
-assert_equal %q{1..3}, %q{
- ans = []
- for m in 1..3
- for n in 1..3
- a = [m, n]
- ans << a
- end
- end
-}
-assert_equal %q{[1, 2, 3]}, %q{
- (1..3).to_a
-}
-assert_equal %q{[4, 8, 12]}, %q{
- (1..3).map{|e|
- e * 4
- }
-}
-assert_equal %q{[1, 2, 3]}, %q{
- class C
- include Enumerable
- def each
- [1,2,3].each{|e|
- yield e
- }
- end
- end
-
- C.new.to_a
-}
-assert_equal %q{[4, 5, 6]}, %q{
- class C
- include Enumerable
- def each
- [1,2,3].each{|e|
- yield e
- }
- end
- end
-
- C.new.map{|e|
- e + 3
- }
-}
-assert_equal %q{100}, %q{
- def m
- yield
- end
- def n
- yield
- end
-
- m{
- n{
- 100
- }
- }
-}
-assert_equal %q{20}, %q{
- def m
- yield 1
- end
-
- m{|ib|
- m{|jb|
- i = 20
- }
- }
-}
-assert_equal %q{2}, %q{
- def m
- yield 1
- end
-
- m{|ib|
- m{|jb|
- ib = 20
- kb = 2
- }
- }
-}
-assert_equal %q{3}, %q{
- def iter1
- iter2{
- yield
- }
- end
-
- def iter2
- yield
- end
-
- iter1{
- jb = 2
- iter1{
- jb = 3
- }
- jb
- }
-}
-assert_equal %q{2}, %q{
- def iter1
- iter2{
- yield
- }
- end
-
- def iter2
- yield
- end
-
- iter1{
- jb = 2
- iter1{
- jb
- }
- jb
- }
-}
-assert_equal %q{2}, %q{
- def m
- yield 1
- end
- m{|ib|
- ib*2
- }
-}
-assert_equal %q{92580}, %q{
- def m
- yield 12345, 67890
- end
- m{|ib,jb|
- ib*2+jb
- }
-}
-assert_equal %q{[10, nil]}, %q{
- def iter
- yield 10
- end
-
- a = nil
- [iter{|a|
- a
- }, a]
-}
-assert_equal %q{21}, %q{
- def iter
- yield 10
- end
-
- iter{|a|
- iter{|a|
- a + 1
- } + a
- }
-}
-assert_equal %q{[10, 20, 30, 40, nil, nil, nil, nil]}, %q{
- def iter
- yield 10, 20, 30, 40
- end
-
- a = b = c = d = nil
- iter{|a, b, c, d|
- [a, b, c, d]
- } + [a, b, c, d]
-}
-assert_equal %q{[10, 20, 30, 40, nil, nil]}, %q{
- def iter
- yield 10, 20, 30, 40
- end
-
- a = b = nil
- iter{|a, b, c, d|
- [a, b, c, d]
- } + [a, b]
-}
-assert_equal %q{[1]}, %q{
- $a = []
-
- def iter
- yield 1
- end
-
- def m
- x = iter{|x|
- $a << x
- y = 0
- }
- end
- m
- $a
-}
-assert_equal %q{[1, [2]]}, %q{
- def iter
- yield 1, 2
- end
-
- iter{|a, *b|
- [a, b]
- }
-}
-assert_equal %q{[[1, 2]]}, %q{
- def iter
- yield 1, 2
- end
-
- iter{|*a|
- [a]
- }
-}
-assert_equal %q{[1, 2, []]}, %q{
- def iter
- yield 1, 2
- end
-
- iter{|a, b, *c|
- [a, b, c]
- }
-}
-assert_equal %q{[1, 2, nil, []]}, %q{
- def iter
- yield 1, 2
- end
-
- iter{|a, b, c, *d|
- [a, b, c, d]
- }
-}
-assert_equal %q{1}, %q{
- def m
- yield
- end
- m{
- 1
- }
-}
-assert_equal %q{15129}, %q{
- def m
- yield 123
- end
- m{|ib|
- m{|jb|
- ib*jb
- }
- }
-}
-assert_equal %q{2}, %q{
- def m a
- yield a
- end
- m(1){|ib|
- m(2){|jb|
- ib*jb
- }
- }
-}
-assert_equal %q{9}, %q{
- sum = 0
- 3.times{|ib|
- 2.times{|jb|
- sum += ib + jb
- }}
- sum
-}
-assert_equal %q{10}, %q{
- 3.times{|bl|
- break 10
- }
-}
-assert_equal %q{[1, 2]}, %q{
- def iter
- yield 1,2,3
- end
-
- iter{|i, j|
- [i, j]
- }
-}
-assert_equal %q{[1, nil]}, %q{
- def iter
- yield 1
- end
-
- iter{|i, j|
- [i, j]
- }
-}
-
-assert_equal '0', %q{
-def m()
-end
-m {|(v0,*,(*)),|}
-m {|(*v0,(*)),|}
-m {|(v0,*v1,(*)),|}
-m {|((v0,*v1,v2)),|}
-m {|(v0,*v1,v2),|}
-m {|(v0,*v1,(v2)),|}
-m {|((*),*v0,v1),|}
-m {|((v0),*v1,v2),|}
-m {|(v0,v1,*v2,v3),|}
-m {|v0,(v1,*v2,v3),|}
-m {|(v0,*v1,v2),v3,|}
-m {|(v0,*v1,v2)|}
-m {|(v0,*v1,v2),&v3|}
-m {|(v0,*v1,v2),*|}
-m {|(v0,*v1,v2),*,&v3|}
-m {|*,(v0,*v1,v2)|}
-m {|*,(v0,*v1,v2),&v3|}
-m {|v0,*,(v1,*v2,v3)|}
-m {|v0,*,(v1,*v2,v3),&v4|}
-m {|(v0,*v1,v2),*,v3|}
-m {|(v0,*v1,v2),*,v3,&v4|}
-m {|(v0, *v1, v2)|}
-m {|(*,v)|}
-0
-}, "block parameter (shouldn't SEGV: [ruby-dev:31143])"
-
-assert_equal 'nil', %q{
- def m
- yield
- end
- m{|&b| b}.inspect
-}, '[ruby-dev:31147]'
-
-assert_equal 'nil', %q{
- def m()
- yield
- end
- m {|(v,(*))|}.inspect
-}, '[ruby-dev:31160]'
-
-assert_equal 'nil', %q{
- def m()
- yield
- end
- m {|(*,a,b)|}.inspect
-}, '[ruby-dev:31153]'
-
-assert_equal 'nil', %q{
- def m()
- yield
- end
- m {|((*))|}.inspect
-}
-
-assert_equal %q{[1, 1, [1, nil], [1, nil], [1, nil], [1, nil], [1, 1], 1, [1, nil], [1, nil], [1, nil], [1, nil], [[1, 1], [1, 1]], [1, 1], [1, 1], [1, 1], [1, nil], [1, nil], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[1, 1], [1, 1]], [[1, 1], [1, 1]], [[1, 1], [1, 1]], [1, 1], [1, 1], [[[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[1, 1], [1, 1]], [[1, 1], [1, 1]]]}, %q{
-def m(ary = [])
- yield(ary)
-end
-
-$ans = []
-o = 1
-5.times{
- v,(*) = o; $ans << o
- m(o){|(v,(*))| $ans << v}
- ((x, y)) = o; $ans << [x, y]
- m(o){|((x, y))| $ans << [x, y]}
- (((x, y))) = o; $ans << [x, y]
- m(o){|(((x, y)))| $ans << [x, y]}
- o = [o, o]
-}; $ans
-}
-
-assert_equal '0', %q{
- def m()
- yield [0]
- end
- m {|*,v| v}.inspect
-}, '[ruby-dev:31437]'
-assert_equal '[0]', %q{
- def m
- yield [0]
- end
- m{|v, &b| v}.inspect
-}, '[ruby-dev:31440]'
-assert_equal 'ok', %q{
- begin
- lambda{|a|}.call(1, 2)
- rescue ArgumentError
- :ok
- else
- :ng
- end
-}, '[ruby-dev:31464]'
-assert_equal 'ok', %q{
- begin
- lambda{|&b|}.call(3)
- rescue ArgumentError
- :ok
- else
- :ng
- end
-}, '[ruby-dev:31472]'
-assert_equal 'ok', %q{
- class C
- def each
- yield [1,2]
- yield 1,2
- end
- end
- vs1 = []
- C.new.each {|*v| vs1 << v }
- vs2 = []
- C.new.to_enum.each {|*v| vs2 << v }
- vs1 == vs2 ? :ok : :ng
-}, '[ruby-dev:32329]'
-
-assert_normal_exit %q{
- e = [1,2,3].each
- 10000.times {
- e = [e].each
- }
- Thread.new { GC.start }.join
-}, '[ruby-dev:32604]'
-
-
-assert_equal '[nil, []]', %q{
- def m() yield nil,[] end
- l = lambda {|*v| v}
- GC.stress=true
- r = m(&l)
- GC.stress=false
- r.inspect
-}, '[ruby-dev:32567]'
-
-assert_equal NilClass.to_s, %q{
- r = false; 1.times{|&b| r = b}; r.class
-}
-
-assert_equal 'ok', %q{
- class C
- define_method(:foo) do |arg, &block|
- if block then block.call else arg end
- end
- end
- C.new.foo("ng") {"ok"}
-}, '[ruby-talk:266422]'
-
-assert_equal 'ok', %q{
- STDERR.reopen(STDOUT)
- class C
- define_method(:foo) do |&block|
- block.call if block
- end
- result = "ng"
- new.foo() {result = "ok"}
- result
- end
-}
-
-assert_equal "ok", %q{
- class Bar
- def bar; :ok; end
- end
- def foo
- yield(Bar.new) if block_given?
- end
- foo(&:bar)
-}, '[ruby-core:14279]'
-
-assert_normal_exit %q{
- class Controller
- def respond_to(&block)
- responder = Responder.new
- block.call(responder)
- responder.respond
- end
- def test_for_bug
- respond_to{|format|
- format.js{
- puts "in test"
- render{|obj|
- puts obj
- }
- }
- }
- end
- def render(&block)
- puts "in render"
- end
- end
-
- class Responder
- def method_missing(symbol, &block)
- puts "enter method_missing"
- @response = Proc.new{
- puts 'in method missing'
- block.call
- }
- puts "leave method_missing"
- end
- def respond
- @response.call
- end
- end
- t = Controller.new
- t.test_for_bug
-}, '[ruby-core:14395]'
-
diff --git a/bootstraptest/test_class.rb b/bootstraptest/test_class.rb
deleted file mode 100644
index 93bb51d234..0000000000
--- a/bootstraptest/test_class.rb
+++ /dev/null
@@ -1,217 +0,0 @@
-# class
-assert_equal 'true', %q( class C; end
- Object.const_defined?(:C) )
-assert_equal 'Class', %q( class C; end
- C.class )
-assert_equal 'C', %q( class C; end
- C.name )
-assert_equal 'C', %q( class C; end
- C.new.class )
-assert_equal 'C', %q( class C; end
- C.new.class.name )
-assert_equal 'Class', %q( class C; end
- C.new.class.class )
-
-# inherited class
-assert_equal 'true', %q( class A; end
- class C < A; end
- Object.const_defined?(:C) )
-assert_equal 'Class', %q( class A; end
- class C < A; end
- C.class )
-assert_equal 'C', %q( class A; end
- class C < A; end
- C.name )
-assert_equal 'C', %q( class A; end
- class C < A; end
- C.new.class )
-assert_equal 'C', %q( class A; end
- class C < A; end
- C.new.class.name )
-assert_equal 'Class', %q( class A; end
- class C < A; end
- C.new.class.class )
-
-# module
-assert_equal 'true', %q( module M; end
- Object.const_defined?(:M) )
-assert_equal 'Module', %q( module M; end
- M.class )
-assert_equal 'M', %q( module M; end
- M.name )
-assert_equal 'C', %q( module M; end
- class C; include M; end
- C.new.class )
-
-# nested class
-assert_equal 'A::B', %q( class A; end
- class A::B; end
- A::B )
-assert_equal 'A::B', %q( class A; end
- class A::B; end
- A::B.name )
-assert_equal 'A::B', %q( class A; end
- class A::B; end
- A::B.new.class )
-assert_equal 'Class', %q( class A; end
- class A::B; end
- A::B.new.class.class )
-assert_equal 'A::B::C', %q( class A; end
- class A::B; end
- class A::B::C; end
- A::B::C )
-assert_equal 'A::B::C', %q( class A; end
- class A::B; end
- class A::B::C; end
- A::B::C.name )
-assert_equal 'Class', %q( class A; end
- class A::B; end
- class A::B::C; end
- A::B::C.class )
-assert_equal 'A::B::C', %q( class A; end
- class A::B; end
- class A::B::C; end
- A::B::C.new.class )
-assert_equal 'Class', %q( class A; end
- class A::B; end
- class A::B::C; end
- A::B::C.new.class.class )
-assert_equal 'A::B2', %q( class A; end
- class A::B; end
- class A::B2 < A::B; end
- A::B2 )
-assert_equal 'Class', %q( class A; end
- class A::B; end
- class A::B2 < A::B; end
- A::B2.class )
-
-# reopen
-assert_equal 'true', %q( class C; end; c1 = ::C
- class C; end; c2 = ::C
- c1.equal?(c2) )
-assert_equal '1', %q( class C; end
- class A; end
- begin class C < A; end; rescue TypeError; 1 end )
-assert_equal '1', %q( class C; end
- begin module C; end; rescue TypeError; 1 end )
-assert_equal '1', %q( C = 1 # [yarv-dev:782]
- begin class C; end; rescue TypeError; 1 end )
-assert_equal '1', %q( C = 1 # [yarv-dev:800]
- begin module C; end; rescue TypeError; 1 end )
-
-# colon2, colon3
-assert_equal '1', %q( class A; end; A::C = 1; A::C )
-assert_equal '1', %q( A = 7; begin A::C = 7; rescue TypeError; 1 end )
-assert_equal '1', %q( begin 7::C = 7; rescue TypeError; 1 end )
-assert_equal 'C', %q( class A; class ::C; end end; C )
-assert_equal 'Class', %q( class A; class ::C; end end; C.class )
-assert_equal 'OK', %q( class A; ::C = "OK"; end; C )
-assert_equal 'String', %q( class A; ::C = "OK"; end; C.class )
-
-# class/module dup
-assert_equal 'Class', %q( class C; end; C.dup.class )
-assert_equal 'Module', %q( module M; end; M.dup.class )
-
-__END__
-
- def test_singletonclass
- ae %q{
- obj = ''
- class << obj
- def m
- :OK
- end
- end
- obj.m
- }
- ae %q{
- obj = ''
- Const = :NG
- class << obj
- Const = :OK
- def m
- Const
- end
- end
- obj.m
- }
- ae %q{
- obj = ''
- class C
- def m
- :NG
- end
- end
- class << obj
- class C
- def m
- :OK
- end
- end
- def m
- C.new.m
- end
- end
- obj.m
- }
- ae %q{ # [yarv-dev:818]
- class A
- end
- class << A
- C = "OK"
- def m
- class << Object
- $a = C
- end
- end
- end
- A.m
- $a
- }
- end
-
- def test_initialize
- class C
- def initialize
- @a = :C
- end
- def a
- @a
- end
- end
- C.new.a
- end
-
- def test_attr
- class C
- def set
- @a = 1
- end
- def get
- @a
- end
- end
- c = C.new
- c.set
- c.get
- end
-
- def test_attr_accessor
- class C
- attr_accessor :a
- attr_reader :b
- attr_writer :c
- def b_write
- @b = 'huga'
- end
- def m a
- 'test_attr_accessor' + @b + @c
- end
- end
-
- c = C.new
- c.a = true
- c.c = 'hoge'
- c.b_write
- c.m(c.b)
- end
diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb
deleted file mode 100644
index b2a5762460..0000000000
--- a/bootstraptest/test_eval.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-assert_equal %q{ok}, %q{
- def m
- a = :ok
- $b = binding
- end
- m
- eval('a', $b)
-}
-assert_equal %q{[:ok, :ok2]}, %q{
- def m
- a = :ok
- $b = binding
- end
- m
- eval('b = :ok2', $b)
- eval('[a, b]', $b)
-}
-assert_equal %q{[nil, 1]}, %q{
- $ans = []
- def m
- $b = binding
- end
- m
- $ans << eval(%q{
- $ans << eval(%q{
- a
- }, $b)
- a = 1
- }, $b)
- $ans
-}
-assert_equal %q{C}, %q{
- Const = :top
- class C
- Const = :C
- def m
- binding
- end
- end
- eval('Const', C.new.m)
-}
-assert_equal %q{top}, %q{
- Const = :top
- a = 1
- class C
- Const = :C
- def m
- eval('Const', TOPLEVEL_BINDING)
- end
- end
- C.new.m
-}
-assert_equal %q{:ok
-ok}, %q{
- class C
- $b = binding
- end
- eval %q{
- def m
- :ok
- end
- }, $b
- p C.new.m
-}
-assert_equal %q{ok}, %q{
- b = proc{
- a = :ok
- binding
- }.call
- a = :ng
- eval("a", b)
-}
-assert_equal %q{C}, %q{
- class C
- def foo
- binding
- end
- end
- C.new.foo.eval("self.class.to_s")
-}
-assert_equal %q{1}, %q{
- eval('1')
-}
-assert_equal %q{1}, %q{
- eval('a=1; a')
-}
-assert_equal %q{1}, %q{
- a = 1
- eval('a')
-}
-assert_equal %q{ok}, %q{
- __send__ :eval, %{
- :ok
- }
-}
-assert_equal %q{ok}, %q{
- 1.__send__ :instance_eval, %{
- :ok
- }
-}
-assert_equal %q{1}, %q{
- 1.instance_eval{
- self
- }
-}
-assert_equal %q{foo}, %q{
- 'foo'.instance_eval{
- self
- }
-}
-assert_equal %q{1}, %q{
- class Fixnum
- Const = 1
- end
- 1.instance_eval %{
- Const
- }
-}
-assert_equal %q{C}, %q{
- Const = :top
- class C
- Const = :C
- end
- C.module_eval{
- Const
- }
-}
-assert_equal %q{C}, %q{
- Const = :top
- class C
- Const = :C
- end
- C.class_eval %{
- def m
- Const
- end
- }
- C.new.m
-}
-assert_equal %q{C}, %q{
- Const = :top
- class C
- Const = :C
- end
- C.class_eval{
- def m
- Const
- end
- }
- C.new.m
-}
-assert_equal %q{[:top, :C, :top, :C]}, %q{
- Const = :top
- class C
- Const = :C
- end
- $nest = false
- $ans = []
- def m
- $ans << Const
- C.module_eval %{
- $ans << Const
- Boo = false unless defined? Boo
- unless $nest
- $nest = true
- m
- end
- }
- end
- m
- $ans
-}
-assert_equal %q{[10, main]}, %q{
- $nested = false
- $ans = []
- $pr = proc{
- $ans << self
- unless $nested
- $nested = true
- $pr.call
- end
- }
- class C
- def initialize &b
- 10.instance_eval(&b)
- end
- end
- C.new(&$pr)
- $ans
-}
-
-%w[break next redo].each do |keyword|
- assert_match %r"Can't escape from eval with #{keyword}\z", %{
- begin
- eval "0 rescue #{keyword}"
- rescue SyntaxError => e
- e.message
- end
- }, '[ruby-dev:31372]'
-end
diff --git a/bootstraptest/test_exception.rb b/bootstraptest/test_exception.rb
deleted file mode 100644
index bd3d02ade3..0000000000
--- a/bootstraptest/test_exception.rb
+++ /dev/null
@@ -1,404 +0,0 @@
-assert_equal %q{2}, %q{
- begin
- 1+1
- ensure
- 2+2
- end
-}
-assert_equal %q{4}, %q{
- begin
- 1+1
- begin
- 2+2
- ensure
- 3+3
- end
- ensure
- 4+4
- end
-}
-assert_equal %q{4}, %q{
- begin
- 1+1
- begin
- 2+2
- ensure
- 3+3
- end
- ensure
- 4+4
- begin
- 5+5
- ensure
- 6+6
- end
- end
-}
-assert_equal %q{NilClass}, %q{
- a = nil
- 1.times{|e|
- begin
- rescue => err
- end
- a = err.class
- }
- a
-}
-assert_equal %q{RuntimeError}, %q{
- a = nil
- 1.times{|e|
- begin
- raise
- rescue => err
- end
- a = err.class
- }
- a
-}
-assert_equal %q{}, %q{
- $!
-}
-assert_equal %q{FOO}, %q{
- begin
- raise "FOO"
- rescue
- $!
- end
-}
-assert_equal %q{FOO}, %q{
- def m
- $!
- end
- begin
- raise "FOO"
- rescue
- m()
- end
-}
-assert_equal %q{[#<RuntimeError: BAR>, #<RuntimeError: FOO>]}, %q{
- $ans = []
- def m
- $!
- end
- begin
- raise "FOO"
- rescue
- begin
- raise "BAR"
- rescue
- $ans << m()
- end
- $ans << m()
- end
- $ans
-}
-assert_equal %q{[#<RuntimeError: FOO>, #<RuntimeError: FOO>]}, %q{
- $ans = []
- def m
- $!
- end
-
- begin
- begin
- raise "FOO"
- ensure
- $ans << m()
- end
- rescue
- $ans << m()
- end
-}
-assert_equal %q{[nil]}, %q{
- $ans = []
- def m
- $!
- end
- def m2
- 1.times{
- begin
- return
- ensure
- $ans << m
- end
- }
- end
- m2
- $ans
-}
-assert_equal %q{ok}, %q{
- begin
- raise
- rescue
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- begin
- raise
- rescue
- :ok
- ensure
- :ng
- end
-}
-assert_equal %q{RuntimeError}, %q{
- begin
- raise
- rescue => e
- e.class
- end
-}
-assert_equal %q{ng}, %q{
- begin
- raise
- rescue StandardError
- :ng
- rescue Exception
- :ok
- end
-}
-assert_equal %q{c}, %q{
- begin
- begin
- raise "a"
- rescue
- raise "b"
- ensure
- raise "c"
- end
- rescue => e
- e.message
- end
-}
-assert_equal %q{33}, %q{
- def m a, b
- a + b
- end
- m(1, begin
- raise
- rescue
- 2
- end) +
- m(10, begin
- raise
- rescue
- 20
- ensure
- 30
- end)
-}
-assert_equal %q{3}, %q{
- def m a, b
- a + b
- end
- m(begin
- raise
- rescue
- 1
- end,
- begin
- raise
- rescue
- 2
- end)
-}
-assert_equal %q{ok3}, %q{
- class E1 < Exception
- end
-
- def m
- yield
- end
-
- begin
- begin
- begin
- m{
- raise
- }
- rescue E1
- :ok2
- ensure
- end
- rescue
- :ok3
- ensure
- end
- rescue E1
- :ok
- ensure
- end
-}
-assert_equal %q{7}, %q{
- $i = 0
- def m
- iter{
- begin
- $i += 1
- begin
- $i += 2
- break
- ensure
-
- end
- ensure
- $i += 4
- end
- $i = 0
- }
- end
-
- def iter
- yield
- end
- m
- $i
-}
-assert_equal %q{10}, %q{
- $i = 0
- def m
- begin
- $i += 1
- begin
- $i += 2
- return
- ensure
- $i += 3
- end
- ensure
- $i += 4
- end
- p :end
- end
- m
- $i
-}
-assert_equal %q{1}, %q{
- begin
- 1
- rescue
- 2
- end
-}
-assert_equal %q{4}, %q{
- begin
- 1
- begin
- 2
- rescue
- 3
- end
- 4
- rescue
- 5
- end
-}
-assert_equal %q{3}, %q{
- begin
- 1
- rescue
- 2
- else
- 3
- end
-}
-assert_equal %q{2}, %q{
- begin
- 1+1
- rescue
- 2+2
- ensure
- 3+3
- end
- }
-assert_equal %q{2}, %q{
- begin
- 1+1
- rescue
- 2+2
- ensure
- 3+3
- end
- }
-assert_equal %q{6}, %q{
- begin
- 1+1
- rescue
- 2+2
- else
- 3+3
- ensure
- 4+4
- end
- }
-assert_equal %q{12}, %q{
- begin
- 1+1
- begin
- 2+2
- rescue
- 3+3
- else
- 4+4
- end
- rescue
- 5+5
- else
- 6+6
- ensure
- 7+7
- end
- }
-assert_equal %q{ok}, %q{ #
- proc{
- begin
- raise
- break
- rescue
- :ok
- end
- }.call
-}
-assert_equal %q{}, %q{
- proc do
- begin
- raise StandardError
- redo
- rescue StandardError
- end
- end.call
-}
-
-##
-assert_match /undefined method `foo\'/, %q{
- STDERR.reopen(STDOUT)
- class C
- def inspect
- bar {}
- end
-
- def bar
- raise
- ensure
- end
- end
- C.new.foo
-}, "[ruby-dev:31407]"
-
-assert_equal 'nil', %q{
- doit = false
- exc = nil
- t = Thread.new {
- begin
- doit = true
- sleep 10
- ensure
- exc = $!
- end
- }
- Thread.pass until doit
- t.kill
- t.join
- exc.inspect
-}, '[ruby-dev:32608]'
-
diff --git a/bootstraptest/test_flip.rb b/bootstraptest/test_flip.rb
deleted file mode 100644
index ff194868b2..0000000000
--- a/bootstraptest/test_flip.rb
+++ /dev/null
@@ -1 +0,0 @@
-assert_equal %q{E}, %q{$_ = "E"; eval("nil if true..~/^E/",nil,"-e"); $_}
diff --git a/bootstraptest/test_flow.rb b/bootstraptest/test_flow.rb
deleted file mode 100644
index 9964dfb2ed..0000000000
--- a/bootstraptest/test_flow.rb
+++ /dev/null
@@ -1,491 +0,0 @@
-assert_equal %q{[1, 2, 4, 5, 6, 7, 8]}, %q{$a = []; begin; ; $a << 1
- [1,2].each{; $a << 2
- break; $a << 3
- }; $a << 4
- begin; $a << 5
- ensure; $a << 6
- end; $a << 7
-; $a << 8
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 6, 7, 8]}, %q{$a = []; begin; ; $a << 1
- begin; $a << 2
- [1,2].each do; $a << 3
- break; $a << 4
- end; $a << 5
- ensure; $a << 6
- end; $a << 7
-; $a << 8
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{ok}, %q{
- ["a"].inject("ng"){|x,y|
- break :ok
- }
-}
-assert_equal %q{ok}, %q{
- unless ''.respond_to? :lines
- class String
- def lines
- self
- end
- end
- end
-
- ('a').lines.map{|e|
- break :ok
- }
-}
-assert_equal %q{[1, 2, 4, 5]}, %q{$a = []; begin; ; $a << 1
- ["a"].inject("ng"){|x,y|; $a << 2
- break :ok; $a << 3
- }; $a << 4
-; $a << 5
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 4, 5]}, %q{$a = []; begin; ; $a << 1
- ('a'..'b').map{|e|; $a << 2
- break :ok; $a << 3
- }; $a << 4
-; $a << 5
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1
- [1,2].each do; $a << 2
- begin; $a << 3
- break; $a << 4
- ensure; $a << 5
- end; $a << 6
- end; $a << 7
-; $a << 8
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 6, 9, 10]}, %q{$a = []; begin; ; $a << 1
- i=0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- begin; $a << 5
- ensure; $a << 6
- break; $a << 7
- end; $a << 8
- end; $a << 9
-; $a << 10
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 7, 10, 11]}, %q{$a = []; begin; ; $a << 1
- i=0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- begin; $a << 5
- raise; $a << 6
- ensure; $a << 7
- break; $a << 8
- end; $a << 9
- end; $a << 10
-; $a << 11
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 7, 10, 11]}, %q{$a = []; begin; ; $a << 1
- i=0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- begin; $a << 5
- raise; $a << 6
- rescue; $a << 7
- break; $a << 8
- end; $a << 9
- end; $a << 10
-; $a << 11
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1
- [1,2].each do; $a << 2
- begin; $a << 3
- raise StandardError; $a << 4
- ensure; $a << 5
- break; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1
- [1,2].each do; $a << 2
- begin; $a << 3
- raise StandardError; $a << 4
- rescue; $a << 5
- break; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 6, 8, 10, 11]}, %q{$a = []; begin; ; $a << 1
- [1,2].each do; $a << 2
- begin; $a << 3
- begin; $a << 4
- break; $a << 5
- ensure; $a << 6
- end; $a << 7
- ensure; $a << 8
- end; $a << 9
- end; $a << 10
-; $a << 11
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15]}, %q{$a = []; begin; ; $a << 1
- i = 0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- j = 0; $a << 5
- while j<3; $a << 6
- j+=1; $a << 7
- begin; $a << 8
- raise; $a << 9
- rescue; $a << 10
- break; $a << 11
- end; $a << 12
- end; $a << 13
- end; $a << 14
-; $a << 15
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 16, 17]}, %q{$a = []; begin; ; $a << 1
- i = 0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- j = 0; $a << 5
- while j<3; $a << 6
- j+=1; $a << 7
- 1.times{; $a << 8
- begin; $a << 9
- raise; $a << 10
- rescue; $a << 11
- break; $a << 12
- end; $a << 13
- }; $a << 14
- end; $a << 15
- end; $a << 16
-; $a << 17
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15]}, %q{$a = []; begin; ; $a << 1
- i = 0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- j = 0; $a << 5
- while j<3; $a << 6
- j+=1; $a << 7
- begin; $a << 8
- raise; $a << 9
- ensure; $a << 10
- break; $a << 11
- end; $a << 12
- end; $a << 13
- end; $a << 14
-; $a << 15
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 16, 17]}, %q{$a = []; begin; ; $a << 1
- i = 0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- j = 0; $a << 5
- while j<3; $a << 6
- j+=1; $a << 7
- 1.times{; $a << 8
- begin; $a << 9
- raise; $a << 10
- ensure; $a << 11
- break; $a << 12
- end; $a << 13
- }; $a << 14
- end; $a << 15
- end; $a << 16
-; $a << 17
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1
- while true; $a << 2
- begin; $a << 3
- break; $a << 4
- ensure; $a << 5
- break; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 99]}, %q{$a = []; begin; ; $a << 1
- while true; $a << 2
- begin; $a << 3
- break; $a << 4
- ensure; $a << 5
- raise; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 6, 8, 9, 10, 11]}, %q{$a = []; begin; ; $a << 1
- begin; $a << 2
- [1,2].each do; $a << 3
- begin; $a << 4
- break; $a << 5
- ensure; $a << 6
- end; $a << 7
- end; $a << 8
- ensure; $a << 9
- end; $a << 10
-; $a << 11
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 4, 99]}, %q{$a = []; begin; ; $a << 1
- begin; $a << 2
- raise StandardError; $a << 3
- ensure; $a << 4
- end; $a << 5
-; $a << 6
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4]}, %q{$a = []; begin; ; $a << 1
- begin; $a << 2
- ensure; $a << 3
- end ; $a << 4
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 5, 99]}, %q{$a = []; begin; ; $a << 1
- [1,2].each do; $a << 2
- begin; $a << 3
- break; $a << 4
- ensure; $a << 5
- raise StandardError; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{3}, %q{
- def m a, b
- a + b
- end
- m(1,
- while true
- break 2
- end
- )
-}
-assert_equal %q{4}, %q{
- def m a, b
- a + b
- end
- m(1,
- (i=0; while i<2
- i+=1
- class C
- next 2
- end
- end; 3)
- )
-}
-assert_equal %q{34}, %q{
- def m a, b
- a+b
- end
- m(1, 1.times{break 3}) +
- m(10, (1.times{next 3}; 20))
-}
-assert_equal %q{[1, 2, 3, 6, 7]}, %q{$a = []; begin; ; $a << 1
- 3.times{; $a << 2
- class C; $a << 3
- break; $a << 4
- end; $a << 5
- }; $a << 6
-; $a << 7
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 8, 9]}, %q{$a = []; begin; ; $a << 1
- 3.times{; $a << 2
- class A; $a << 3
- class B; $a << 4
- break; $a << 5
- end; $a << 6
- end; $a << 7
- }; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 2, 3, 2, 3, 6, 7]}, %q{$a = []; begin; ; $a << 1
- 3.times{; $a << 2
- class C; $a << 3
- next; $a << 4
- end; $a << 5
- }; $a << 6
-; $a << 7
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 2, 3, 4, 2, 3, 4, 8, 9]}, %q{$a = []; begin; ; $a << 1
- 3.times{; $a << 2
- class C; $a << 3
- class D; $a << 4
- next; $a << 5
- end; $a << 6
- end; $a << 7
- }; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 6, 7]}, %q{$a = []; begin; ; $a << 1
- while true; $a << 2
- class C; $a << 3
- break; $a << 4
- end; $a << 5
- end; $a << 6
-; $a << 7
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 8, 9]}, %q{$a = []; begin; ; $a << 1
- while true; $a << 2
- class C; $a << 3
- class D; $a << 4
- break; $a << 5
- end; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1
- i=0; $a << 2
- while i<3; $a << 3
- i+=1; $a << 4
- class C; $a << 5
- next 10; $a << 6
- end; $a << 7
- end; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{1}, %q{
- 1.times{
- while true
- class C
- begin
- break
- ensure
- break
- end
- end
- end
- }
-}
-assert_equal %q{[1, 2, 3, 5, 2, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1
- [1,2].each do; $a << 2
- begin; $a << 3
- next; $a << 4
- ensure; $a << 5
- end; $a << 6
- end; $a << 7
-; $a << 8
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 2, 6, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1
- o = "test"; $a << 2
- def o.test(a); $a << 3
- return a; $a << 4
- ensure; $a << 5
- end; $a << 6
- o.test(123); $a << 7
-; $a << 8
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 4, 7, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1
- def m1 *args; $a << 2
- ; $a << 3
- end; $a << 4
- def m2; $a << 5
- m1(:a, :b, (return 1; :c)); $a << 6
- end; $a << 7
- m2; $a << 8
-; $a << 9
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 8, 2, 3, 4, 5, 9, 10]}, %q{$a = []; begin; ; $a << 1
- def m(); $a << 2
- begin; $a << 3
- 2; $a << 4
- ensure; $a << 5
- return 3; $a << 6
- end; $a << 7
- end; $a << 8
- m; $a << 9
-; $a << 10
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 3, 11, 4, 5, 6, 7, 12, 13]}, %q{$a = []; begin; ; $a << 1
- def m2; $a << 2
- end; $a << 3
- def m(); $a << 4
- m2(begin; $a << 5
- 2; $a << 6
- ensure; $a << 7
- return 3; $a << 8
- end); $a << 9
- 4; $a << 10
- end; $a << 11
- m(); $a << 12
-; $a << 13
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[1, 16, 2, 3, 4, 5, 6, 7, 10, 11, 17, 18]}, %q{$a = []; begin; ; $a << 1
- def m; $a << 2
- 1; $a << 3
- 1.times{; $a << 4
- 2; $a << 5
- begin; $a << 6
- 3; $a << 7
- return; $a << 8
- 4; $a << 9
- ensure; $a << 10
- 5; $a << 11
- end; $a << 12
- 6; $a << 13
- }; $a << 14
- 7; $a << 15
- end; $a << 16
- m(); $a << 17
-; $a << 18
-; rescue Exception; $a << 99; end; $a}
-assert_equal %q{[:ok, :ok2, :last]}, %q{
- a = []
- i = 0
- begin
- while i < 1
- i+=1
- begin
- begin
- next
- ensure
- a << :ok
- end
- ensure
- a << :ok2
- end
- end
- ensure
- a << :last
- end
- a
-}
-assert_equal %q{[:ok, :ok2, :last]}, %q{
- a = []
- i = 0
- begin
- while i < 1
- i+=1
- begin
- begin
- break
- ensure
- a << :ok
- end
- ensure
- a << :ok2
- end
- end
- ensure
- a << :last
- end
- a
-}
-assert_equal %q{[:ok, :ok2, :last]}, %q{
- a = []
- i = 0
- begin
- while i < 1
- if i>0
- break
- end
- i+=1
- begin
- begin
- redo
- ensure
- a << :ok
- end
- ensure
- a << :ok2
- end
- end
- ensure
- a << :last
- end
- a
- }
diff --git a/bootstraptest/test_fork.rb b/bootstraptest/test_fork.rb
deleted file mode 100644
index 743c22c250..0000000000
--- a/bootstraptest/test_fork.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-assert_equal '0', %q{
- begin
- GC.stress = true
- pid = fork {}
- Process.wait pid
- $?.to_i
- rescue NotImplementedError
- 0
- end
-}, '[ruby-dev:32404]'
diff --git a/bootstraptest/test_io.rb b/bootstraptest/test_io.rb
deleted file mode 100644
index 019a82d9bd..0000000000
--- a/bootstraptest/test_io.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-assert_finish 5, %q{
- r, w = IO.pipe
- t1 = Thread.new { r.sysread(1) }
- t2 = Thread.new { r.sysread(1) }
- sleep 0.1
- w.write "a"
- sleep 0.1
- w.write "a"
-}, '[ruby-dev:31866]'
-
-assert_finish 10, %q{
- begin
- require "io/nonblock"
- r, w = IO.pipe
- w.nonblock = true
- w.write_nonblock("a" * 100000)
- w.nonblock = false
- t1 = Thread.new { w.write("b" * 4096) }
- t2 = Thread.new { w.write("c" * 4096) }
- sleep 0.5
- r.sysread(4096).length
- sleep 0.5
- r.sysread(4096).length
- t1.join
- t2.join
- rescue LoadError
- end
-}, '[ruby-dev:32566]'
-
-assert_finish 1, %q{
- r, w = IO.pipe
- Thread.new {
- w << "ab"
- sleep 0.1
- w << "ab"
- }
- p r.gets("abab")
-}
diff --git a/bootstraptest/test_jump.rb b/bootstraptest/test_jump.rb
deleted file mode 100644
index bc1a613b56..0000000000
--- a/bootstraptest/test_jump.rb
+++ /dev/null
@@ -1,250 +0,0 @@
-assert_equal %q{ok}, %q{
- def m
- :ng1
- mm{
- yield
- }
- :ng2
- end
-
- def mm
- :ng3
- yield
- :ng4
- end
-
- m{
- break :ok
- }
-}
-assert_equal %q{ok}, %q{
- 3.times{
- break :ok
- }
-}
-assert_equal %q{}, %q{
- catch(:foo){
- throw :foo
- }
-}
-assert_equal %q{false}, %q{
- catch(:foo){
- throw :foo, false
- }
-}
-assert_equal %q{}, %q{
- catch(:foo){
- throw :foo, nil
- }
-}
-assert_equal %q{ok}, %q{
- catch(:foo){
- throw :foo, :ok
- }
-}
-assert_equal %q{}, %q{
- catch(:foo){
- 1.times{
- throw :foo
- }
- }
-}
-assert_equal %q{ok}, %q{
- catch(:foo){
- 1.times{
- throw :foo, :ok
- }
- }
-}
-assert_equal %q{ok}, %q{
- catch(:foo){
- catch(:bar){
- throw :foo, :ok
- }
- :ng
- }
-}
-assert_equal %q{ok}, %q{
- catch(:foo){
- catch(:bar){
- 1.times{
- throw :foo, :ok
- }
- }
- :ng
- }
-}
-assert_equal %q{2}, %q{
- module Enumerable
- def all_?
- self.each{|e|
- unless yield(e)
- return false
- end
- }
- true
- end
- end
-
- xxx = 0
- [1,2].each{|bi|
- [3,4].each{|bj|
- [true, nil, true].all_?{|be| be}
- break
- }
- xxx += 1
- }
- xxx
-}
-assert_equal %q{ok}, %q{
- def m
- yield
- end
-
- m{
- begin
- ensure
- break :ok
- end
- }
-}
-assert_equal %q{ok}, %q{
- def m
- yield
- :ok
- end
- i=0
- m{
- if i>10
- i*i
- else
- i+=1
- next
- end
- }
-}
-assert_equal %q{ok}, %q{
- def m
- yield
- end
-
- m{
- next :ok
- }
-}
-assert_equal %q{131}, %q{
- def m
- yield + 10
- end
- i=0
- m{
- if i>10
- i*i
- else
- i+=1
- redo
- end
- }
-}
-assert_equal %q{ok}, %q{
-begin
- eval %q{
- 1.times{
- retry
- }
- }
-rescue SyntaxError
- :ok
-end
-}
-assert_equal %q{3}, %q{
- def m
- return 3
- end
- m
-}
-assert_equal %q{ok}, %q{
- def m
- :ng1
- mm{
- return :ok
- }
- :ng2
- end
-
- def mm
- :ng3
- yield
- :ng4
- end
- m
-}
-assert_equal %q{100}, %q{
- $i = 0
- def m
- begin
- iter{
- return
- }
- ensure
- $i = 100
- end
- end
-
- def iter
- yield
- end
- m
- $i
-}
-assert_equal %q{ok}, %q{
- def m
- begin
- raise
- rescue
- return :ok
- end
- :ng
- end
- m
-}
-assert_equal %q{1}, %q{
- def m
- begin
- raise
- rescue
- return 1
- end
- end
-
- m
-}
-assert_equal %q{1}, %q{
- def m
- begin
- #
- ensure
- return 1
- end
- end
-
- m
-}
-assert_equal 'ok', %q{
- begin
- catch {|t| throw t, :ok }
- rescue ArgumentError
- :ng
- end
-}, '[ruby-dev:31609]'
-
-assert_equal "1", %q{
- catch do |t|
- begin
- throw t, 1
- 2
- ensure
- 3
- end
- end
-}, "[ruby-dev:31698]"
diff --git a/bootstraptest/test_knownbug.rb b/bootstraptest/test_knownbug.rb
deleted file mode 100644
index 39dc6a9b8b..0000000000
--- a/bootstraptest/test_knownbug.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-#
-# This test file concludes tests which point out known bugs.
-# So all tests will cause failure.
-#
diff --git a/bootstraptest/test_literal.rb b/bootstraptest/test_literal.rb
deleted file mode 100644
index fe4e966a00..0000000000
--- a/bootstraptest/test_literal.rb
+++ /dev/null
@@ -1,178 +0,0 @@
-# empty program
-assert_equal '', ''
-assert_equal '', ' '
-assert_equal '', "\n"
-
-# special const
-assert_equal 'true', 'true'
-assert_equal 'TrueClass', 'true.class'
-assert_equal 'false', 'false'
-assert_equal 'FalseClass', 'false.class'
-assert_equal '', 'nil'
-assert_equal 'nil', 'nil.inspect'
-assert_equal 'NilClass', 'nil.class'
-assert_equal 'sym', ':sym'
-assert_equal ':sym', ':sym.inspect'
-assert_equal 'Symbol', ':sym.class'
-assert_equal '1234', '1234'
-assert_equal 'Fixnum', '1234.class'
-assert_equal '1234', '1_2_3_4'
-assert_equal 'Fixnum', '1_2_3_4.class'
-assert_equal '18', '0x12'
-assert_equal 'Fixnum', '0x12.class'
-assert_equal '15', '0o17'
-assert_equal 'Fixnum', '0o17.class'
-assert_equal '5', '0b101'
-assert_equal 'Fixnum', '0b101.class'
-assert_equal '123456789012345678901234567890', '123456789012345678901234567890'
-assert_equal 'Bignum', '123456789012345678901234567890.class'
-assert_equal '2.0', '2.0'
-assert_equal 'Float', '1.3.class'
-
-# self
-assert_equal 'main', 'self'
-assert_equal 'Object', 'self.class'
-
-# string literal
-assert_equal 'a', '?a'
-assert_equal 'String', '?a.class'
-assert_equal 'A', '?A'
-assert_equal 'String', '?A.class'
-assert_equal "\n", '?\n'
-assert_equal 'String', '?\n.class'
-assert_equal ' ', '?\ '
-assert_equal 'String', '?\ .class'
-assert_equal 'string', "'string'"
-assert_equal 'string', '"string"'
-assert_equal 'string', '%(string)'
-assert_equal 'string', '%q(string)'
-assert_equal 'string', '%Q(string)'
-assert_equal 'string string', '"string string"'
-assert_equal ' ', '" "'
-assert_equal "\0", '"\0"'
-assert_equal "\1", '"\1"'
-assert_equal "3", '"\x33"'
-assert_equal "\n", '"\n"'
-
-# dynamic string literal
-assert_equal '2', '"#{1 + 1}"'
-assert_equal '16', '"#{2 ** 4}"'
-assert_equal 'string', 's = "string"; "#{s}"'
-
-# dynamic symbol literal
-assert_equal 'a3c', ':"a#{1+2}c"'
-assert_equal ':a3c', ':"a#{1+2}c".inspect'
-assert_equal 'Symbol', ':"a#{1+2}c".class'
-
-# xstring
-assert_equal "foo\n", %q(`echo foo`)
-assert_equal "foo\n", %q(s = "foo"; `echo #{s}`)
-
-# regexp
-assert_equal '', '//.source'
-assert_equal 'Regexp', '//.class'
-assert_equal '0', '// =~ "a"'
-assert_equal '0', '// =~ ""'
-assert_equal 'a', '/a/.source'
-assert_equal 'Regexp', '/a/.class'
-assert_equal '0', '/a/ =~ "a"'
-assert_equal '0', '/test/ =~ "test"'
-assert_equal '', '/test/ =~ "tes"'
-assert_equal '0', 're = /test/; re =~ "test"'
-assert_equal '0', 'str = "test"; /test/ =~ str'
-assert_equal '0', 're = /test/; str = "test"; re =~ str'
-
-# dynacmi regexp
-assert_equal 'regexp', %q(/re#{'ge'}xp/.source)
-assert_equal 'Regexp', %q(/re#{'ge'}xp/.class)
-
-# array
-assert_equal 'Array', '[].class'
-assert_equal '0', '[].size'
-assert_equal '0', '[].length'
-assert_equal '[]', '[].inspect'
-assert_equal 'Array', '[0].class'
-assert_equal '1', '[3].size'
-assert_equal '[3]', '[3].inspect'
-assert_equal '3', 'a = [3]; a[0]'
-assert_equal 'Array', '[1,2].class'
-assert_equal '2', '[1,2].size'
-assert_equal '[1, 2]', '[1,2].inspect'
-assert_equal 'Array', '[1,2,3,4,5].class'
-assert_equal '5', '[1,2,3,4,5].size'
-assert_equal '[1, 2, 3, 4, 5]', '[1,2,3,4,5].inspect'
-assert_equal '1', 'a = [1,2]; a[0]'
-assert_equal '2', 'a = [1,2]; a[1]'
-assert_equal 'Array', 'a = [1 + 2, 3 + 4, 5 + 6]; a.class'
-assert_equal '[3, 7, 11]', 'a = [1 + 2, 3 + 4, 5 + 6]; a.inspect'
-assert_equal '7', 'a = [1 + 2, 3 + 4, 5 + 6]; a[1]'
-assert_equal '1', '([0][0] += 1)'
-assert_equal '1', '([2][0] -= 1)'
-assert_equal 'Array', 'a = [obj = Object.new]; a.class'
-assert_equal '1', 'a = [obj = Object.new]; a.size'
-assert_equal 'true', 'a = [obj = Object.new]; a[0] == obj'
-assert_equal '5', 'a = [1,2,3]; a[1] = 5; a[1]'
-assert_equal 'bar', '[*:foo];:bar'
-assert_equal '[1, 2]', 'def nil.to_a; [2]; end; [1, *nil]'
-assert_equal '[1, 2]', 'def nil.to_a; [1, 2]; end; [*nil]'
-assert_equal '[0, 1, {2=>3}]', '[0, *[1], 2=>3]', "[ruby-dev:31592]"
-
-
-# hash
-assert_equal 'Hash', '{}.class'
-assert_equal '{}', '{}.inspect'
-assert_equal 'Hash', '{1=>2}.class'
-assert_equal '{1=>2}', '{1=>2}.inspect'
-assert_equal '2', 'h = {1 => 2}; h[1]'
-assert_equal '0', 'h = {1 => 2}; h.delete(1); h.size'
-assert_equal '', 'h = {1 => 2}; h.delete(1); h[1]'
-assert_equal '2', 'h = {"string" => "literal", "goto" => "hell"}; h.size'
-assert_equal 'literal', 'h = {"string"=>"literal", "goto"=>"hell"}; h["string"]'
-assert_equal 'hell', 'h = {"string"=>"literal", "goto"=>"hell"}; h["goto"]'
-
-# range
-assert_equal 'Range', '(1..2).class'
-assert_equal '1..2', '(1..2).inspect'
-assert_equal '1', '(1..2).begin'
-assert_equal '2', '(1..2).end'
-assert_equal 'false', '(1..2).exclude_end?'
-assert_equal 'Range', 'r = 1..2; r.class'
-assert_equal '1..2', 'r = 1..2; r.inspect'
-assert_equal '1', 'r = 1..2; r.begin'
-assert_equal '2', 'r = 1..2; r.end'
-assert_equal 'false', 'r = 1..2; r.exclude_end?'
-assert_equal 'Range', '(1...3).class'
-assert_equal '1...3', '(1...3).inspect'
-assert_equal '1', '(1...3).begin'
-assert_equal '3', '(1...3).end'
-assert_equal 'true', '(1...3).exclude_end?'
-assert_equal 'Range', 'r = (1...3); r.class'
-assert_equal '1...3', 'r = (1...3); r.inspect'
-assert_equal '1', 'r = (1...3); r.begin'
-assert_equal '3', 'r = (1...3); r.end'
-assert_equal 'true', 'r = (1...3); r.exclude_end?'
-assert_equal 'Range', 'r = (1+2 .. 3+4); r.class'
-assert_equal '3..7', 'r = (1+2 .. 3+4); r.inspect'
-assert_equal '3', 'r = (1+2 .. 3+4); r.begin'
-assert_equal '7', 'r = (1+2 .. 3+4); r.end'
-assert_equal 'false', 'r = (1+2 .. 3+4); r.exclude_end?'
-assert_equal 'Range', 'r = (1+2 ... 3+4); r.class'
-assert_equal '3...7', 'r = (1+2 ... 3+4); r.inspect'
-assert_equal '3', 'r = (1+2 ... 3+4); r.begin'
-assert_equal '7', 'r = (1+2 ... 3+4); r.end'
-assert_equal 'true', 'r = (1+2 ... 3+4); r.exclude_end?'
-assert_equal 'Range', 'r = ("a".."c"); r.class'
-assert_equal '"a".."c"', 'r = ("a".."c"); r.inspect'
-assert_equal 'a', 'r = ("a".."c"); r.begin'
-assert_equal 'c', 'r = ("a".."c"); r.end'
-
-assert_equal 'String', '__FILE__.class'
-assert_equal 'Fixnum', '__LINE__.class'
-
-###
-
-assert_equal 'ok', %q{
- # this cause "called on terminated object".
- ObjectSpace.each_object(Module) {|m| m.name.inspect }
- :ok
-}
diff --git a/bootstraptest/test_load.rb b/bootstraptest/test_load.rb
deleted file mode 100644
index 18e8cc06a4..0000000000
--- a/bootstraptest/test_load.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-assert_equal 'ok', %q{
- open("require-lock-test.rb", "w") {|f|
- f.puts "sleep 0.1"
- f.puts "module M"
- f.puts "end"
- }
- $:.unshift Dir.pwd
- vs = (1..2).map {|i|
- Thread.start {
- require "require-lock-test"
- M
- }
- }.map {|t| t.value }
- vs[0] == M && vs[1] == M ? :ok : :ng
-}, '[ruby-dev:32048]'
diff --git a/bootstraptest/test_m17n.rb b/bootstraptest/test_m17n.rb
deleted file mode 100644
index d69a110f3d..0000000000
--- a/bootstraptest/test_m17n.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-assert_normal_exit %q{
- "abcdefghij\xf0".force_encoding("utf-8").reverse.inspect
-}, '[ruby-dev:32448]'
-
-assert_equal 'true', %q{
- "abc".sub(/b/, "\xa1\xa1".force_encoding("euc-jp")) ==
- "a\xa1\xa1c".force_encoding("euc-jp")
-}
-
-assert_equal 'ok', %q{
- begin
- if ("\xa1\xa2\xa1\xa3").force_encoding("euc-jp").split(//) ==
- ["\xa1\xa2".force_encoding("euc-jp"), "\xa1\xa3".force_encoding("euc-jp")]
- :ok
- else
- :ng
- end
- rescue
- :ng
- end
-}, '[ruby-dev:32452]'
-
-assert_equal 'ok', %q{
- begin
- "\xa1\xa1".force_encoding("euc-jp") + "\xa1".force_encoding("ascii-8bit")
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'ok', %q{
- begin
- "%s%s" % ["\xc2\xa1".force_encoding("sjis"), "\xc2\xa1".force_encoding("euc-jp")]
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal '0', %q{
- "\xa1\xa2".force_encoding("euc-jp").count("z")
-}
-
-assert_equal '1', %q{
- "\xa1\xa2".force_encoding("euc-jp").delete("z").length
-}
-
-assert_equal 'false', %q{
- "\xa1\xa2\xa3\xa4".force_encoding("euc-jp").include?("\xa3".force_encoding("euc-jp"))
-}
-
-assert_equal 'ok', %q{
- "\xa1\xa2\xa3\xa4".force_encoding("euc-jp").index("\xa3".force_encoding("euc-jp")) or :ok
-}
-
-assert_equal 'ok', %q{
- "\xa1\xa2\xa3\xa4".force_encoding("euc-jp").rindex("\xa3".force_encoding("euc-jp")) or :ok
-}
-
-assert_equal 'false', %q{
- s1 = "\xa1\xa1".force_encoding("euc-jp")
- s2 = s1.dup
- (94*94+94).times { s2.next! }
- s1 == s2
-}
-
-assert_equal 'ok', %q{
- "\xa1\xa2a\xa3\xa4".force_encoding("euc-jp").scan(/a/)
- :ok
-}
-
-assert_equal 'ok', %q{
- "\xa1\xa2a\xa3\xa4".force_encoding("euc-jp").split(/a/)
- :ok
-}
-
-assert_equal 'ok', %q{
- s1 = "\xa1\xa2".force_encoding("euc-jp")
- s2 = "\xa1\xa2".force_encoding("sjis")
- begin
- s1.upto(s2) {|x| break }
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'true', %q{
- "%s" % "\xa1\xa1".force_encoding("euc-jp") ==
- "\xa1\xa1".force_encoding("euc-jp")
-}
-
-assert_equal 'a', %q{
- s = "a".dup.force_encoding("EUC-JP")
- s.length
- s[0,2]
-}
-
-assert_equal 'ok', %q{
- s1 = "\x81\x41".force_encoding("sjis")
- s2 = "\x81\x61".force_encoding("sjis")
- s1.casecmp(s2) == 0 ? :ng : :ok
-}
-
-assert_equal 'EUC-JP', %q{ ("\xc2\xa1 %s".force_encoding("EUC-JP") % "foo").encoding.name }
-assert_equal 'true', %q{ "\xa1\xa2\xa3\xa4".force_encoding("euc-jp")["\xa2\xa3".force_encoding("euc-jp")] == nil }
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- begin
- s["\xb0\xa3"] = "foo"
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'EUC-JP', %q{ "\xa3\xb0".force_encoding("EUC-JP").center(10).encoding.name }
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- begin
- s.chomp("\xa3\xb4".force_encoding("shift_jis"))
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- begin
- s.count("\xa3\xb0".force_encoding("ascii-8bit"))
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- begin
- s.delete("\xa3\xb2".force_encoding("ascii-8bit"))
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- begin
- s.each_line("\xa3\xb1".force_encoding("ascii-8bit")) {|l| }
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'true', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- s.gsub(/\xa3\xb1/e, "z") == "\xa3\xb0z\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
-}
-
-assert_equal 'false', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- s.include?("\xb0\xa3".force_encoding("euc-jp"))
-}
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- s.index("\xb3\xa3".force_encoding("euc-jp")) or :ok
-}
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- s.insert(-1, "a")
- :ok
-}
-
-assert_finish 1, %q{ "\xa3\xfe".force_encoding("euc-jp").next }
-
-assert_equal 'ok', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- begin
- s.rindex("\xb1\xa3".force_encoding("ascii-8bit"))
- :ng
- rescue ArgumentError
- :ok
- end
-}
-
-assert_equal 'true', %q{
- s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- s.split("\xa3\xb1".force_encoding("euc-jp")) == [
- "\xa3\xb0".force_encoding("euc-jp"),
- "\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- ]
-}, '[ruby-dev:32452]'
-
-assert_normal_exit %q{ // =~ :a }
diff --git a/bootstraptest/test_marshal.rb b/bootstraptest/test_marshal.rb
deleted file mode 100644
index ecbcb60c91..0000000000
--- a/bootstraptest/test_marshal.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-
-assert_normal_exit %q{
- Marshal.load(Marshal.dump({"k"=>"v"}), lambda {|v| })
-}
-
diff --git a/bootstraptest/test_massign.rb b/bootstraptest/test_massign.rb
deleted file mode 100644
index ad31729a73..0000000000
--- a/bootstraptest/test_massign.rb
+++ /dev/null
@@ -1,176 +0,0 @@
-assert_equal '[[1], 2, 3]', '*v1, (a, b) = [1,[2, 3]]; [v1, a, b]'
-assert_equal '[[1], 2, 3]', '*v1,(*), (a, b) = [1,:x,[2, 3]]; [v1, a, b]'
-
-assert_equal '[]', '*a = *nil; a'
-assert_equal '[nil]', '*a = nil; a'
-assert_equal '2', 'a, a = 1, 2; a', "[ruby-dev:31522]"
-assert_equal '[1, 2]', 'a, b = 1, 2'
-assert_equal '[1, 2]', %q{
- ans = []
- trace_var(:$a){|v| ans << v}
- trace_var(:$b){|v| ans << v}
- $a, $b = 1, 2
- ans
-}
-
-assert_equal 'ok', %q{
- r = :ok
- :ng.tap {|(r)|}
- r
-}, '[ruby-dev:31507]'
-
-=begin
-# generated by this script:
-
-3.times{|i|
- 8.times{|e|
- ary = (0...e).to_a
- a,b,c,d,e,f = nil
- vals = %w(a b c d e f)
- vals[i] = '*' + vals[i]
- program = "#{vals.join(", ")} = *ary"
- eval(program)
- ans = [a,b,c,d,e,f]
- puts %Q{
- assert_equal "#{ans.inspect}", %q{
- ary = #{ary.inspect}
- #{program}; [a, b, c, d, e, f]
- }}
- }
-}
-=end
-
- assert_equal "[[], nil, nil, nil, nil, nil]", %q{
- ary = []
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[], 0, nil, nil, nil, nil]", %q{
- ary = [0]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[], 0, 1, nil, nil, nil]", %q{
- ary = [0, 1]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[], 0, 1, 2, nil, nil]", %q{
- ary = [0, 1, 2]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[], 0, 1, 2, 3, nil]", %q{
- ary = [0, 1, 2, 3]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[], 0, 1, 2, 3, 4]", %q{
- ary = [0, 1, 2, 3, 4]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[0], 1, 2, 3, 4, 5]", %q{
- ary = [0, 1, 2, 3, 4, 5]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[[0, 1], 2, 3, 4, 5, 6]", %q{
- ary = [0, 1, 2, 3, 4, 5, 6]
- *a, b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[nil, [], nil, nil, nil, nil]", %q{
- ary = []
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [], nil, nil, nil, nil]", %q{
- ary = [0]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [], 1, nil, nil, nil]", %q{
- ary = [0, 1]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [], 1, 2, nil, nil]", %q{
- ary = [0, 1, 2]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [], 1, 2, 3, nil]", %q{
- ary = [0, 1, 2, 3]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [], 1, 2, 3, 4]", %q{
- ary = [0, 1, 2, 3, 4]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [1], 2, 3, 4, 5]", %q{
- ary = [0, 1, 2, 3, 4, 5]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, [1, 2], 3, 4, 5, 6]", %q{
- ary = [0, 1, 2, 3, 4, 5, 6]
- a, *b, c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[nil, nil, [], nil, nil, nil]", %q{
- ary = []
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, nil, [], nil, nil, nil]", %q{
- ary = [0]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, 1, [], nil, nil, nil]", %q{
- ary = [0, 1]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, 1, [], 2, nil, nil]", %q{
- ary = [0, 1, 2]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, 1, [], 2, 3, nil]", %q{
- ary = [0, 1, 2, 3]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, 1, [], 2, 3, 4]", %q{
- ary = [0, 1, 2, 3, 4]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, 1, [2], 3, 4, 5]", %q{
- ary = [0, 1, 2, 3, 4, 5]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
- assert_equal "[0, 1, [2, 3], 4, 5, 6]", %q{
- ary = [0, 1, 2, 3, 4, 5, 6]
- a, b, *c, d, e, f = *ary; [a, b, c, d, e, f]
- }
-
-
-#
-assert_equal 'ok', %q{
- a,s=[],"aaa"
- 300.times { a<<s; s=s.succ }
- eval <<-END__
- GC.stress=true
- Fiber.new do
- #{ a.join(",") },*zzz=1
- end.resume
- END__
- :ok
-}, '[ruby-dev:32581]'
-
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
deleted file mode 100644
index 8b5d584e31..0000000000
--- a/bootstraptest/test_method.rb
+++ /dev/null
@@ -1,1028 +0,0 @@
-# regular argument
-assert_equal '1', 'def m() 1 end; m()'
-assert_equal '1', 'def m(a) a end; m(1)'
-assert_equal '[1, 2]', 'def m(a,b) [a, b] end; m(1,2)'
-assert_equal '[1, 2, 3]', 'def m(a,b,c) [a, b, c] end; m(1,2,3)'
-assert_equal 'wrong number of arguments (1 for 0)', %q{
- def m; end
- begin
- m(1)
- rescue => e
- e.message
- end
-}
-
-assert_equal 'wrong number of arguments (0 for 1)', %q{
- def m a; end
- begin
- m
- rescue => e
- e.message
- end
-}
-
-# default argument
-assert_equal '1', 'def m(x=1) x end; m()'
-assert_equal '1', 'def m(x=7) x end; m(1)'
-assert_equal '1', 'def m(a,x=1) x end; m(7)'
-assert_equal '1', 'def m(a,x=7) x end; m(7,1)'
-assert_equal '1', 'def m(a,b,x=1) x end; m(7,7)'
-assert_equal '1', 'def m(a,b,x=7) x end; m(7,7,1)'
-assert_equal '1', 'def m(a,x=1,y=1) x end; m(7)'
-assert_equal '1', 'def m(a,x=1,y=1) y end; m(7)'
-assert_equal '1', 'def m(a,x=7,y=1) x end; m(7,1)'
-assert_equal '1', 'def m(a,x=7,y=1) y end; m(7,1)'
-assert_equal '1', 'def m(a,x=7,y=7) x end; m(7,1,1)'
-assert_equal '1', 'def m(a,x=7,y=7) y end; m(7,1,1)'
-
-# rest argument
-assert_equal '[]', 'def m(*a) a end; m().inspect'
-assert_equal '[1]', 'def m(*a) a end; m(1).inspect'
-assert_equal '[1, 2]', 'def m(*a) a end; m(1,2).inspect'
-assert_equal '[]', 'def m(x,*a) a end; m(7).inspect'
-assert_equal '[1]', 'def m(x,*a) a end; m(7,1).inspect'
-assert_equal '[1, 2]', 'def m(x,*a) a end; m(7,1,2).inspect'
-assert_equal '[]', 'def m(x,y,*a) a end; m(7,7).inspect'
-assert_equal '[1]', 'def m(x,y,*a) a end; m(7,7,1).inspect'
-assert_equal '[1, 2]', 'def m(x,y,*a) a end; m(7,7,1,2).inspect'
-assert_equal '[]', 'def m(x,y=7,*a) a end; m(7).inspect'
-assert_equal '[]', 'def m(x,y,z=7,*a) a end; m(7,7).inspect'
-assert_equal '[]', 'def m(x,y,z=7,*a) a end; m(7,7,7).inspect'
-assert_equal '[]', 'def m(x,y,z=7,zz=7,*a) a end; m(7,7,7).inspect'
-assert_equal '[]', 'def m(x,y,z=7,zz=7,*a) a end; m(7,7,7,7).inspect'
-assert_equal '1', 'def m(x,y,z=7,zz=1,*a) zz end; m(7,7,7).inspect'
-assert_equal '1', 'def m(x,y,z=7,zz=1,*a) zz end; m(7,7,7).inspect'
-assert_equal '1', 'def m(x,y,z=7,zz=7,*a) zz end; m(7,7,7,1).inspect'
-
-# block argument
-assert_equal 'Proc', 'def m(&block) block end; m{}.class'
-assert_equal 'nil', 'def m(&block) block end; m().inspect'
-assert_equal 'Proc', 'def m(a,&block) block end; m(7){}.class'
-assert_equal 'nil', 'def m(a,&block) block end; m(7).inspect'
-assert_equal '1', 'def m(a,&block) a end; m(1){}'
-assert_equal 'Proc', 'def m(a,b=nil,&block) block end; m(7){}.class'
-assert_equal 'nil', 'def m(a,b=nil,&block) block end; m(7).inspect'
-assert_equal 'Proc', 'def m(a,b=nil,&block) block end; m(7,7){}.class'
-assert_equal '1', 'def m(a,b=nil,&block) b end; m(7,1){}'
-assert_equal 'Proc', 'def m(a,b=nil,*c,&block) block end; m(7){}.class'
-assert_equal 'nil', 'def m(a,b=nil,*c,&block) block end; m(7).inspect'
-assert_equal '1', 'def m(a,b=nil,*c,&block) a end; m(1).inspect'
-assert_equal '1', 'def m(a,b=1,*c,&block) b end; m(7).inspect'
-assert_equal '1', 'def m(a,b=7,*c,&block) b end; m(7,1).inspect'
-assert_equal '[1]', 'def m(a,b=7,*c,&block) c end; m(7,7,1).inspect'
-
-# splat
-assert_equal '1', 'def m(a) a end; m(*[1])'
-assert_equal '1', 'def m(x,a) a end; m(7,*[1])'
-assert_equal '1', 'def m(x,y,a) a end; m(7,7,*[1])'
-assert_equal '1', 'def m(a,b) a end; m(*[1,7])'
-assert_equal '1', 'def m(a,b) b end; m(*[7,1])'
-assert_equal '1', 'def m(x,a,b) b end; m(7,*[7,1])'
-assert_equal '1', 'def m(x,y,a,b) b end; m(7,7,*[7,1])'
-assert_equal '1', 'def m(a,b,c) a end; m(*[1,7,7])'
-assert_equal '1', 'def m(a,b,c) b end; m(*[7,1,7])'
-assert_equal '1', 'def m(a,b,c) c end; m(*[7,7,1])'
-assert_equal '1', 'def m(x,a,b,c) a end; m(7,*[1,7,7])'
-assert_equal '1', 'def m(x,y,a,b,c) a end; m(7,7,*[1,7,7])'
-
-# hash argument
-assert_equal '1', 'def m(h) h end; m(7=>1)[7]'
-assert_equal '1', 'def m(h) h end; m(7=>1).size'
-assert_equal '1', 'def m(h) h end; m(7=>1, 8=>7)[7]'
-assert_equal '2', 'def m(h) h end; m(7=>1, 8=>7).size'
-assert_equal '1', 'def m(h) h end; m(7=>1, 8=>7, 9=>7)[7]'
-assert_equal '3', 'def m(h) h end; m(7=>1, 8=>7, 9=>7).size'
-assert_equal '1', 'def m(x,h) h end; m(7, 7=>1)[7]'
-assert_equal '1', 'def m(x,h) h end; m(7, 7=>1, 8=>7)[7]'
-assert_equal '1', 'def m(x,h) h end; m(7, 7=>1, 8=>7, 9=>7)[7]'
-assert_equal '1', 'def m(x,y,h) h end; m(7,7, 7=>1)[7]'
-assert_equal '1', 'def m(x,y,h) h end; m(7,7, 7=>1, 8=>7)[7]'
-assert_equal '1', 'def m(x,y,h) h end; m(7,7, 7=>1, 8=>7, 9=>7)[7]'
-
-# block argument
-assert_equal '1', %q(def m(&block) mm(&block) end
- def mm() yield 1 end
- m {|a| a })
-assert_equal '1', %q(def m(x,&block) mm(x,&block) end
- def mm(x) yield 1 end
- m(7) {|a| a })
-assert_equal '1', %q(def m(x,y,&block) mm(x,y,&block) end
- def mm(x,y) yield 1 end
- m(7,7) {|a| a })
-
-# recursive call
-assert_equal '1', %q(def m(n) n == 0 ? 1 : m(n-1) end; m(5))
-
-# instance method
-assert_equal '1', %q(class C; def m() 1 end end; C.new.m)
-assert_equal '1', %q(class C; def m(a) a end end; C.new.m(1))
-assert_equal '1', %q(class C; def m(a = 1) a end end; C.new.m)
-assert_equal '[1]', %q(class C; def m(*a) a end end; C.new.m(1).inspect)
-assert_equal '1', %q( class C
- def m() mm() end
- def mm() 1 end
- end
- C.new.m )
-
-# singleton method (const)
-assert_equal '1', %q(class C; def C.m() 1 end end; C.m)
-assert_equal '1', %q(class C; def C.m(a) a end end; C.m(1))
-assert_equal '1', %q(class C; def C.m(a = 1) a end end; C.m)
-assert_equal '[1]', %q(class C; def C.m(*a) a end end; C.m(1).inspect)
-assert_equal '1', %q(class C; end; def C.m() 1 end; C.m)
-assert_equal '1', %q(class C; end; def C.m(a) a end; C.m(1))
-assert_equal '1', %q(class C; end; def C.m(a = 1) a end; C.m)
-assert_equal '[1]', %q(class C; end; def C.m(*a) a end; C.m(1).inspect)
-assert_equal '1', %q(class C; def m() 7 end end; def C.m() 1 end; C.m)
-assert_equal '1', %q( class C
- def C.m() mm() end
- def C.mm() 1 end
- end
- C.m )
-
-# singleton method (lvar)
-assert_equal '1', %q(obj = Object.new; def obj.m() 1 end; obj.m)
-assert_equal '1', %q(obj = Object.new; def obj.m(a) a end; obj.m(1))
-assert_equal '1', %q(obj = Object.new; def obj.m(a=1) a end; obj.m)
-assert_equal '[1]', %q(obj = Object.new; def obj.m(*a) a end; obj.m(1))
-assert_equal '1', %q(class C; def m() 7 end; end
- obj = C.new
- def obj.m() 1 end
- obj.m)
-
-# inheritance
-assert_equal '1', %q(class A; def m(a) a end end
- class B < A; end
- B.new.m(1))
-assert_equal '1', %q(class A; end
- class B < A; def m(a) a end end
- B.new.m(1))
-assert_equal '1', %q(class A; def m(a) a end end
- class B < A; end
- class C < B; end
- C.new.m(1))
-
-# include
-assert_equal '1', %q(class A; def m(a) a end end
- module M; end
- class B < A; include M; end
- B.new.m(1))
-assert_equal '1', %q(class A; end
- module M; def m(a) a end end
- class B < A; include M; end
- B.new.m(1))
-
-# alias
-assert_equal '1', %q( def a() 1 end
- alias m a
- m() )
-assert_equal '1', %q( class C
- def a() 1 end
- alias m a
- end
- C.new.m )
-assert_equal '1', %q( class C
- def a() 1 end
- alias :m a
- end
- C.new.m )
-assert_equal '1', %q( class C
- def a() 1 end
- alias m :a
- end
- C.new.m )
-assert_equal '1', %q( class C
- def a() 1 end
- alias :m :a
- end
- C.new.m )
-assert_equal '1', %q( class C
- def a() 1 end
- alias m a
- undef a
- end
- C.new.m )
-
-# undef
-assert_equal '1', %q( class C
- def m() end
- undef m
- end
- begin C.new.m; rescue NoMethodError; 1 end )
-assert_equal '1', %q( class A
- def m() end
- end
- class C < A
- def m() end
- undef m
- end
- begin C.new.m; rescue NoMethodError; 1 end )
-assert_equal '1', %q( class A; def a() end end # [yarv-dev:999]
- class B < A
- def b() end
- undef a, b
- end
- begin B.new.a; rescue NoMethodError; 1 end )
-assert_equal '1', %q( class A; def a() end end # [yarv-dev:999]
- class B < A
- def b() end
- undef a, b
- end
- begin B.new.b; rescue NoMethodError; 1 end )
-
-assert_equal '3', %q{
- def m1
- 1
- end
- alias m2 m1
- alias :"#{'m3'}" m1
- m1 + m2 + m3
-}, '[ruby-dev:32308]'
-assert_equal '1', %q{
- def foobar
- end
- undef :"foo#{:bar}"
- 1
-}, '[ruby-dev:32308]'
-assert_equal '1', %q{
- def foobar
- 1
- end
- alias :"bar#{:baz}" :"foo#{:bar}"
- barbaz
-}, '[ruby-dev:32308]'
-
-# private
-assert_equal '1', %q( class C
- def m() mm() end
- def mm() 1 end
- private :mm
- end
- C.new.m )
-assert_equal '1', %q( class C
- def m() 7 end
- private :m
- end
- begin C.m; rescue NoMethodError; 1 end )
-assert_equal '1', %q( class C
- def C.m() mm() end
- def C.mm() 1 end
- private_class_method :mm
- end
- C.m )
-assert_equal '1', %q( class C
- def C.m() 7 end
- private_class_method :m
- end
- begin C.m; rescue NoMethodError; 1 end )
-assert_equal '1', %q( class C; def m() 1 end end
- C.new.m # cache
- class C
- alias mm m; private :mm
- end
- C.new.m
- begin C.new.mm; 7; rescue NoMethodError; 1 end )
-
-# nested method
-assert_equal '1', %q( class C
- def m
- def mm() 1 end
- end
- end
- C.new.m
- C.new.mm )
-assert_equal '1', %q( class C
- def m
- def mm() 1 end
- end
- end
- instance_eval "C.new.m; C.new.mm" )
-
-# method_missing
-assert_equal ':m', %q( class C
- def method_missing(mid, *args) mid end
- end
- C.new.m.inspect )
-assert_equal ':mm', %q( class C
- def method_missing(mid, *args) mid end
- end
- C.new.mm.inspect )
-assert_equal '[1, 2]', %q( class C
- def method_missing(mid, *args) args end
- end
- C.new.m(1,2).inspect )
-assert_equal '1', %q( class C
- def method_missing(mid, *args) yield 1 end
- end
- C.new.m {|a| a })
-assert_equal 'nil', %q( class C
- def method_missing(mid, *args, &block) block end
- end
- C.new.m.inspect )
-
-# send
-assert_equal '1', %q( class C; def m() 1 end end;
- C.new.__send__(:m) )
-assert_equal '1', %q( class C; def m() 1 end end;
- C.new.send(:m) )
-assert_equal '1', %q( class C; def m(a) a end end;
- C.new.send(:m,1) )
-assert_equal '1', %q( class C; def m(a,b) a end end;
- C.new.send(:m,1,7) )
-assert_equal '1', %q( class C; def m(x,a=1) a end end;
- C.new.send(:m,7) )
-assert_equal '1', %q( class C; def m(x,a=7) a end end;
- C.new.send(:m,7,1) )
-assert_equal '[1, 2]', %q( class C; def m(*a) a end end;
- C.new.send(:m,1,2).inspect )
-assert_equal '1', %q( class C; def m() 7 end; private :m end
- begin C.new.public_send(:m); rescue NoMethodError; 1 end )
-assert_equal '1', %q( class C; def m() 1 end; private :m end
- C.new.send(:m) )
-
-# with block
-assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]',
-%q{
- class C
- def [](a)
- $ary << [yield, a]
- end
- def []=(a, b)
- $ary << [yield, a, b]
- end
- end
-
- $ary = []
- C.new[:foo, &lambda{:ok1}]
- C.new[:foo, &lambda{:ok2}] = :bar
- $ary
-}
-
-# with
-assert_equal '[:ok1, [:ok2, 11]]', %q{
- class C
- def []
- $ary << :ok1
- 10
- end
- def []=(a)
- $ary << [:ok2, a]
- end
- end
- $ary = []
- C.new[]+=1
- $ary
-}
-
-# splat and block arguments
-assert_equal %q{[[[:x, :y, :z], NilClass], [[1, :x, :y, :z], NilClass], [[1, 2, :x, :y, :z], NilClass], [[:obj], NilClass], [[1, :obj], NilClass], [[1, 2, :obj], NilClass], [[], Proc], [[1], Proc], [[1, 2], Proc], [[], Proc], [[1], Proc], [[1, 2], Proc], [[:x, :y, :z], Proc], [[1, :x, :y, :z], Proc], [[1, 2, :x, :y, :z], Proc]]}, %q{
-def m(*args, &b)
- $result << [args, b.class]
-end
-$result = []
-ary = [:x, :y, :z]
-obj = :obj
-b = Proc.new{}
-
-m(*ary)
-m(1,*ary)
-m(1,2,*ary)
-m(*obj)
-m(1,*obj)
-m(1,2,*obj)
-m(){}
-m(1){}
-m(1,2){}
-m(&b)
-m(1,&b)
-m(1,2,&b)
-m(*ary,&b)
-m(1,*ary,&b)
-m(1,2,*ary,&b)
-$result
-}
-
-# post test
-assert_equal %q{[1, 2, :o1, :o2, [], 3, 4, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4)}
-
-assert_equal %q{[1, 2, 3, :o2, [], 4, 5, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5)}
-
-assert_equal %q{[1, 2, 3, 4, [], 5, 6, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6)}
-
-assert_equal %q{[1, 2, 3, 4, [5], 6, 7, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7)}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6], 7, 8, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8)}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6, 7], 8, 9, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8, 9)}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6, 7, 8], 9, 10, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6, 7, 8, 9], 10, 11, NilClass, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)}
-
-assert_equal %q{[1, 2, :o1, :o2, [], 3, 4, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4){}}
-
-assert_equal %q{[1, 2, 3, :o2, [], 4, 5, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5){}}
-
-assert_equal %q{[1, 2, 3, 4, [], 5, 6, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6){}}
-
-assert_equal %q{[1, 2, 3, 4, [5], 6, 7, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7){}}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6], 7, 8, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8){}}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6, 7], 8, 9, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8, 9){}}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6, 7, 8], 9, 10, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8, 9, 10){}}
-
-assert_equal %q{[1, 2, 3, 4, [5, 6, 7, 8, 9], 10, 11, Proc, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2, &b)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, b.class, x, y]
-end
-; m(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11){}}
-
-assert_equal %q{[1, 2, :o1, :o2, [], 3, 4, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, x, y]
-end
-; m(1, 2, 3, 4)}
-
-assert_equal %q{[1, 2, 3, :o2, [], 4, 5, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, x, y]
-end
-; m(1, 2, 3, 4, 5)}
-
-assert_equal %q{[1, 2, 3, 4, [], 5, 6, nil, nil]}, %q{
-def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2)
- x, y = :x, :y if $foo
- [m1, m2, o1, o2, r, p1, p2, x, y]
-end
-; m(1, 2, 3, 4, 5, 6)}
-
-
-#
-# super
-#
-=begin
-# below programs are generated by this program:
-
-BASE = <<EOS__
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; <TEST>; super; end; end
-EOS__
-
-tests = {
-%q{
- def m
-} => %q{
- C1.new.m
-},
-#
-%q{
- def m a
-} => %q{
- C1.new.m 1
-},
-%q{
- def m a
- a = :a
-} => %q{
- C1.new.m 1
-},
-#
-%q{
- def m a, o=:o
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
-},
-%q{
- def m a, o=:o
- a = :a
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
-},
-%q{
- def m a, o=:o
- o = :x
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
-},
-#
-%q{
- def m a, *r
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
- C1.new.m 1, 2, 3
-},
-%q{
- def m a, *r
- r = [:x, :y]
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
- C1.new.m 1, 2, 3
-},
-#
-%q{
- def m a, o=:o, *r
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
- C1.new.m 1, 2, 3
- C1.new.m 1, 2, 3, 4
-},
-#
-%q{
- def m a, o=:o, *r, &b
-} => %q{
- C1.new.m 1
- C1.new.m 1, 2
- C1.new.m 1, 2, 3
- C1.new.m 1, 2, 3, 4
- C1.new.m(1){}
- C1.new.m(1, 2){}
- C1.new.m(1, 2, 3){}
- C1.new.m(1, 2, 3, 4){}
-},
-#
-"def m(m1, m2, o1=:o1, o2=:o2, p1, p2)" =>
-%q{
-C1.new.m(1,2,3,4)
-C1.new.m(1,2,3,4,5)
-C1.new.m(1,2,3,4,5,6)
-},
-#
-"def m(m1, m2, *r, p1, p2)" =>
-%q{
-C1.new.m(1,2,3,4)
-C1.new.m(1,2,3,4,5)
-C1.new.m(1,2,3,4,5,6)
-C1.new.m(1,2,3,4,5,6,7)
-C1.new.m(1,2,3,4,5,6,7,8)
-},
-#
-"def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2)" =>
-%q{
-C1.new.m(1,2,3,4)
-C1.new.m(1,2,3,4,5)
-C1.new.m(1,2,3,4,5,6)
-C1.new.m(1,2,3,4,5,6,7)
-C1.new.m(1,2,3,4,5,6,7,8)
-C1.new.m(1,2,3,4,5,6,7,8,9)
-},
-
-###
-}
-
-
-tests.each{|setup, methods| setup = setup.dup; setup.strip!
- setup = BASE.gsub(/<TEST>/){setup}
- methods.split(/\n/).each{|m| m = m.dup; m.strip!
- next if m.empty?
- expr = "#{setup}; #{m}"
- result = eval(expr)
- puts "assert_equal %q{#{result.inspect}}, %q{\n#{expr}}"
- puts
- }
-}
-
-=end
-
-assert_equal %q{[:C0_m, [1, 2, :o1, :o2, 3, 4]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, p1, p2); super; end; end
-; C1.new.m(1,2,3,4)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, :o2, 4, 5]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6)}
-
-assert_equal %q{[:C0_m, [1, :o]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, 2]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:C0_m, [1, 2, 3]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r; super; end; end
-; C1.new.m 1, 2, 3}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r; super; end; end
-; C1.new.m 1, 2, 3, 4}
-
-assert_equal %q{[:C0_m, [:a]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a
- a = :a; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6, 7]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6,7)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6, 7, 8]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6,7,8)}
-
-assert_equal %q{[:C0_m, [1, :o]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, 2]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:C0_m, [1, 2, 3]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m 1, 2, 3}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m 1, 2, 3, 4}
-
-assert_equal %q{[:C0_m, [1, :o]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m(1){}}
-
-assert_equal %q{[:C0_m, [1, 2]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m(1, 2){}}
-
-assert_equal %q{[:C0_m, [1, 2, 3]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m(1, 2, 3){}}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o, *r, &b; super; end; end
-; C1.new.m(1, 2, 3, 4){}}
-
-assert_equal %q{[:C0_m, [1, :x]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o
- o = :x; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, :x]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o
- o = :x; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:C0_m, [:a, :o]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o
- a = :a; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [:a, 2]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o
- a = :a; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:C0_m, [1]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, :x, :y]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, *r
- r = [:x, :y]; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, :x, :y]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, *r
- r = [:x, :y]; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:C0_m, [1, :x, :y]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, *r
- r = [:x, :y]; super; end; end
-; C1.new.m 1, 2, 3}
-
-assert_equal %q{[:C0_m, [1, 2, :o1, :o2, 3, 4]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, :o2, 4, 5]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6, 7]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6,7)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6, 7, 8]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6,7,8)}
-
-assert_equal %q{[:C0_m, [1, 2, 3, 4, 5, 6, 7, 8, 9]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m(m1, m2, o1=:o1, o2=:o2, *r, p1, p2); super; end; end
-; C1.new.m(1,2,3,4,5,6,7,8,9)}
-
-assert_equal %q{[:C0_m, [1]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, *r; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, 2]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, *r; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:C0_m, [1, 2, 3]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, *r; super; end; end
-; C1.new.m 1, 2, 3}
-
-assert_equal %q{[:C0_m, []]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m; super; end; end
-; C1.new.m}
-
-assert_equal %q{[:C0_m, [1, :o]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o; super; end; end
-; C1.new.m 1}
-
-assert_equal %q{[:C0_m, [1, 2]]}, %q{
-class C0; def m *args; [:C0_m, args]; end; end
-class C1 < C0; def m a, o=:o; super; end; end
-; C1.new.m 1, 2}
-
-assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{
- $ans = []
- class Foo
- def m
- end
- end
-
- c1 = c2 = nil
-
- lambda{
- $SAFE = 4
- c1 = Class.new{
- def m
- end
- }
- c2 = Class.new(Foo){
- alias mm m
- }
- }.call
-
- def test
- begin
- yield
- rescue SecurityError
- $ans << :ok
- else
- $ans << :ng
- end
- end
-
- o1 = c1.new
- o2 = c2.new
-
- test{o1.m}
- test{o2.mm}
- test{o1.send :m}
- test{o2.send :mm}
- test{o1.public_send :m}
- test{o2.public_send :mm}
- test{o1.method(:m).call}
- test{o2.method(:mm).call}
- $ans
-}
-
-assert_equal 'ok', %q{
- class C
- def x=(n)
- end
- def m
- self.x = :ok
- end
- end
- C.new.m
-}
-
-assert_equal 'ok', %q{
- proc{
- $SAFE = 1
- class C
- def m
- :ok
- end
- end
- }.call
- C.new.m
-}, '[ruby-core:11998]'
-
-assert_equal 'ok', %q{
- proc{
- $SAFE = 2
- class C
- def m
- :ok
- end
- end
- }.call
- C.new.m
-}, '[ruby-core:11998]'
-
-assert_equal 'ok', %q{
- proc{
- $SAFE = 3
- class C
- def m
- :ng
- end
- end
- }.call
- begin
- C.new.m
- rescue SecurityError
- :ok
- end
-}, '[ruby-core:11998]'
-
-assert_equal 'ok', %q{
- class B
- def m() :fail end
- end
- class C < B
- undef m
- begin
- remove_method :m
- rescue NameError
- end
- end
- begin
- C.new.m
- rescue NameError
- :ok
- end
-}, '[ruby-dev:31816], [ruby-dev:31817]'
-
-assert_normal_exit %q{
- begin
- Process.setrlimit(Process::RLIMIT_STACK, 1024*1024)
- rescue Exception
- exit
- end
- class C
- attr "a" * (2*1024*1024)
- end
-}, '[ruby-dev:31818]'
-
-assert_equal 'ok', %q{
- class Module
- def define_method2(name, &block)
- define_method(name, &block)
- end
- end
- class C
- define_method2(:m) {|x, y| :fail }
- end
- begin
- C.new.m([1,2])
- rescue ArgumentError
- :ok
- end
-}
-
-assert_not_match /method_missing/, %q{
- STDERR.reopen(STDOUT)
- variable_or_mehtod_not_exist
-}
diff --git a/bootstraptest/test_objectspace.rb b/bootstraptest/test_objectspace.rb
deleted file mode 100644
index 1a43d42017..0000000000
--- a/bootstraptest/test_objectspace.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-assert_normal_exit %q{
- eval("", TOPLEVEL_BINDING)
- minobj = ObjectSpace.to_enum(:each_object).min_by {|a| a.object_id }
- maxobj = ObjectSpace.to_enum(:each_object).max_by {|a| a.object_id }
- minobj.object_id.upto(maxobj.object_id) {|id|
- begin
- o = ObjectSpace._id2ref(id)
- rescue RangeError
- next
- end
- o.inspect if defined?(o.inspect)
- }
-}, '[ruby-dev:31911]'
-
-assert_normal_exit %q{
- ary = (1..10).to_a
- ary.permutation(2) {|x|
- if x == [1,2]
- ObjectSpace.each_object(String) {|s|
- s.clear if !s.frozen? && (s.length == 40 || s.length == 80)
- }
- end
- }
-}, '[ruby-dev:31982]'
-
-assert_normal_exit %q{
- ary = (1..100).to_a
- ary.permutation(2) {|x|
- if x == [1,2]
- ObjectSpace.each_object(Array) {|o| o.clear if o == ary && o.object_id != ary.object_id }
- end
- }
-}, '[ruby-dev:31985]'
diff --git a/bootstraptest/test_proc.rb b/bootstraptest/test_proc.rb
deleted file mode 100644
index 049bc99131..0000000000
--- a/bootstraptest/test_proc.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-assert_equal %q{[1, 2, 3]}, %q{
- def getproc &b
- b
- end
-
- def m
- yield
- end
-
- m{
- i = 1
- m{
- j = 2
- m{
- k = 3
- getproc{
- [i, j, k]
- }
- }
- }
- }.call
-}
-assert_equal %q{7}, %q{
- def make_proc(&b)
- b
- end
-
- def make_closure
- a = 0
- make_proc{
- a+=1
- }
- end
-
- cl = make_closure
- cl.call + cl.call * cl.call
-}
-assert_equal %q{ok}, %q{
- class C
- def foo
- :ok
- end
- end
-
- def block
- C.method(:new).to_proc
- end
- b = block()
- b.call.foo
-}
-assert_equal %q{[0, 1, :last, 0, 2, :last]}, %q{
- def proc &b
- b
- end
-
- pr = []
- proc{|i_b|
- p3 = proc{|j_b|
- pr << proc{|k_b|
- [i_b, j_b, k_b]
- }
- }
- p3.call(1)
- p3.call(2)
- }.call(0)
-
- pr[0].call(:last).concat pr[1].call(:last)
-}
-assert_equal %q{12}, %q{
- def iter
- yield
- end
-
- def getproc &b
- b
- end
-
- iter{
- bvar = 3
- getproc{
- bvar2 = 4
- bvar * bvar2
- }
- }.call
-}
-assert_equal %q{200}, %q{
- def iter
- yield
- end
-
- def getproc &b
- b
- end
-
- loc1 = 0
- pr1 = iter{
- bl1 = 1
- getproc{
- loc1 += 1
- bl1 += 1
- loc1 + bl1
- }
- }
-
- pr2 = iter{
- bl1 = 1
- getproc{
- loc1 += 1
- bl1 += 1
- loc1 + bl1
- }
- }
-
- pr1.call; pr2.call
- pr1.call; pr2.call
- pr1.call; pr2.call
- (pr1.call + pr2.call) * loc1
-}
-assert_equal %q{[1, 2]}, %q{
- def proc(&pr)
- pr
- end
-
- def m
- a = 1
- m2{
- a
- }
- end
-
- def m2
- b = 2
- proc{
- [yield, b]
- }
- end
-
- pr = m
- x = ['a', 1,2,3,4,5,6,7,8,9,0,
- 1,2,3,4,5,6,7,8,9,0,
- 1,2,3,4,5,6,7,8,9,0,
- 1,2,3,4,5,6,7,8,9,0,
- 1,2,3,4,5,6,7,8,9,0,]
- pr.call
-}
-assert_equal %q{1}, %q{
- def proc(&pr)
- pr
- end
-
- def m
- a = 1
- m2{
- a
- }
- end
-
- def m2
- b = 2
- proc{
- [yield, b]
- }
- 100000.times{|x|
- "#{x}"
- }
- yield
- end
- m
-}
-assert_equal %q{[:C, :C]}, %q{
- Const = :top
- class C
- Const = :C
- $pr = proc{
- (1..2).map{
- Const
- }
- }
- end
- $pr.call
-}
-assert_equal %q{top}, %q{
- Const = :top
- class C
- Const = :C
- end
- pr = proc{
- Const
- }
- C.class_eval %q{
- pr.call
- }
-}
-assert_equal %q{1}, %q{
- def m(&b)
- b
- end
-
- m{|e_proctest| e_proctest}.call(1)
-}
-assert_equal %q{12}, %q{
- def m(&b)
- b
- end
-
- m{|e_proctest1, e_proctest2|
- a = e_proctest1 * e_proctest2 * 2
- a * 3
- }.call(1, 2)
-}
-assert_equal %q{[[], [1], [1, 2], [1, 2, 3]]}, %q{
- [
- Proc.new{|*args| args}.call(),
- Proc.new{|*args| args}.call(1),
- Proc.new{|*args| args}.call(1, 2),
- Proc.new{|*args| args}.call(1, 2, 3),
- ]
-}
-assert_equal %q{[[nil, []], [1, []], [1, [2]], [1, [2, 3]]]}, %q{
- [
- Proc.new{|a, *b| [a, b]}.call(),
- Proc.new{|a, *b| [a, b]}.call(1),
- Proc.new{|a, *b| [a, b]}.call(1, 2),
- Proc.new{|a, *b| [a, b]}.call(1, 2, 3),
- ]
-}
-assert_equal %q{0}, %q{
- pr = proc{
- $SAFE
- }
- $SAFE = 1
- pr.call
-}
-assert_equal %q{[1, 0]}, %q{
- pr = proc{
- $SAFE += 1
- }
- [pr.call, $SAFE]
-}
-assert_equal %q{1}, %q{
- def m(&b)
- b
- end
- m{1}.call
-}
-assert_equal %q{3}, %q{
- def m(&b)
- b
- end
-
- m{
- a = 1
- a + 2
- }.call
-}
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
deleted file mode 100644
index ed47d59876..0000000000
--- a/bootstraptest/test_syntax.rb
+++ /dev/null
@@ -1,748 +0,0 @@
-assert_equal %q{4}, %q{1 && 2 && 3 && 4}
-assert_equal %q{}, %q{1 && nil && 3 && 4}
-assert_equal %q{}, %q{1 && 2 && 3 && nil}
-assert_equal %q{false}, %q{1 && 2 && 3 && false}
-assert_equal %q{4}, %q{1 and 2 and 3 and 4}
-assert_equal %q{}, %q{1 and nil and 3 and 4}
-assert_equal %q{}, %q{1 and 2 and 3 and nil}
-assert_equal %q{false}, %q{1 and 2 and 3 and false}
-assert_equal %q{}, %q{nil && true}
-assert_equal %q{false}, %q{false && true}
-assert_equal %q{}, %q{
- case 1
- when 2
- :ng
- end}
-assert_equal %q{ok}, %q{
- case 1
- when 10,20,30
- :ng1
- when 1,2,3
- :ok
- when 100,200,300
- :ng2
- else
- :elseng
- end}
-assert_equal %q{elseok}, %q{
- case 123
- when 10,20,30
- :ng1
- when 1,2,3
- :ng2
- when 100,200,300
- :ng3
- else
- :elseok
- end
-}
-assert_equal %q{ok}, %q{
- case 'test'
- when /testx/
- :ng1
- when /test/
- :ok
- when /tetxx/
- :ng2
- else
- :ng_else
- end
-}
-assert_equal %q{ok}, %q{
- case Object.new
- when Object
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- case Object
- when Object.new
- :ng
- else
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- case 'test'
- when 'tes'
- :ng
- when 'te'
- :ng
- else
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- case 'test'
- when 'tes'
- :ng
- when 'te'
- :ng
- when 'test'
- :ok
- end
-}
-assert_equal %q{ng}, %q{
- case 'test'
- when 'tes'
- :ng
- when /te/
- :ng
- else
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- case 'test'
- when 'tes'
- :ng
- when /test/
- :ok
- else
- :ng
- end
-}
-assert_equal %q{100}, %q{
- def test(arg)
- case 1
- when 2
- 3
- end
- return arg
- end
-
- test(100)
-}
-assert_equal %q{ok}, %q{
- ary = [1, 2]
- case 1
- when *ary
- :ok
- else
- :ng
- end
-}
-assert_equal %q{ok}, %q{
- ary = [1, 2]
- case 3
- when *ary
- :ng
- else
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- ary = [1, 2]
- case 1
- when :x, *ary
- :ok
- when :z
- :ng1
- else
- :ng2
- end
-}
-assert_equal %q{ok}, %q{
- ary = [1, 2]
- case 3
- when :x, *ary
- :ng1
- when :z
- :ng2
- else
- :ok
- end
-}
-assert_equal %q{[:false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep]}, %q{
-
- def make_perm ary, num
- if num == 1
- ary.map{|e| [e]}
- else
- base = make_perm(ary, num-1)
- res = []
- base.each{|b|
- ary.each{|e|
- res << [e] + b
- }
- }
- res
- end
- end
-
- def each_test
- conds = make_perm(['fv', 'tv'], 3)
- bangs = make_perm(['', '!'], 3)
- exprs = make_perm(['and', 'or'], 3)
- ['if', 'unless'].each{|syn|
- conds.each{|cs|
- bangs.each{|bs|
- exprs.each{|es|
- yield(syn, cs, bs, es)
- }
- }
- }
- }
- end
-
- fv = false
- tv = true
-
- $ans = []
- each_test{|syn, conds, bangs, exprs|
- c1, c2, c3 = conds
- bang1, bang2, bang3 = bangs
- e1, e2 = exprs
- eval %Q{
- #{syn} #{bang1}#{c1} #{e1} #{bang2}#{c2} #{e2} #{bang3}#{c3}
- $ans << :then
- else
- $ans << :false
- end
- }
- }
-
- each_test{|syn, conds, bangs, exprs|
- c1, c2, c3 = conds
- bang1, bang2, bang3 = bangs
- e1, e2 = exprs
- eval %Q{
- #{syn} #{bang1}#{c1} #{e1} #{bang2}#{c2} #{e2} #{bang3}#{c3}
- $ans << :then
- end
- $ans << :sep
- }
- }
- $ans
-}
-assert_equal %q{}, %q{
- defined?(m)
-}
-assert_equal %q{method}, %q{
- def m
- end
- defined?(m)
-}
-assert_equal %q{}, %q{
- defined?(a.class)
-}
-assert_equal %q{method}, %q{
- a = 1
- defined?(a.class)
-}
-assert_equal %q{["method", "method", "method", "method", nil, nil, "method", "method", "method", nil]}, %q{
- class C
- def test
- [defined?(m1()), defined?(self.m1), defined?(C.new.m1),
- defined?(m2()), defined?(self.m2), defined?(C.new.m2),
- defined?(m3()), defined?(self.m3), defined?(C.new.m3)]
- end
- def m1
- end
- private
- def m2
- end
- protected
- def m3
- end
- end
- C.new.test + [defined?(C.new.m3)]
-}
-assert_equal %q{[nil, nil, nil, nil, "global-variable", "global-variable", nil, nil]}, %q{
- $ans = [defined?($1), defined?($2), defined?($3), defined?($4)]
- /(a)(b)/ =~ 'ab'
- $ans + [defined?($1), defined?($2), defined?($3), defined?($4)]
-}
-assert_equal %q{nilselftruefalse}, %q{
- defined?(nil) + defined?(self) +
- defined?(true) + defined?(false)
-}
-assert_equal %q{}, %q{
- defined?(@a)
-}
-assert_equal %q{instance-variable}, %q{
- @a = 1
- defined?(@a)
-}
-assert_equal %q{}, %q{
- defined?(@@a)
-}
-assert_equal %q{class variable}, %q{
- @@a = 1
- defined?(@@a)
-}
-assert_equal %q{}, %q{
- defined?($a)
-}
-assert_equal %q{global-variable}, %q{
- $a = 1
- defined?($a)
-}
-assert_equal %q{}, %q{
- defined?(C_definedtest)
-}
-assert_equal %q{constant}, %q{
- C_definedtest = 1
- defined?(C_definedtest)
-}
-assert_equal %q{}, %q{
- defined?(::C_definedtest)
-}
-assert_equal %q{constant}, %q{
- C_definedtest = 1
- defined?(::C_definedtest)
-}
-assert_equal %q{}, %q{
- defined?(C_definedtestA::C_definedtestB::C_definedtestC)
-}
-assert_equal %q{constant}, %q{
- class C_definedtestA
- class C_definedtestB
- C_definedtestC = 1
- end
- end
- defined?(C_definedtestA::C_definedtestB::C_definedtestC)
-}
-assert_equal %q{30}, %q{
- sum = 0
- 30.times{|ib|
- if ib % 10 == 0 .. true
- sum += ib
- end
- }
- sum
-}
-assert_equal %q{63}, %q{
- sum = 0
- 30.times{|ib|
- if ib % 10 == 0 ... true
- sum += ib
- end
- }
- sum
-}
-assert_equal %q{[["NUM", "Type: NUM\n"], ["NUM", "123\n"], ["NUM", "456\n"], ["NUM", "Type: ARP\n"], ["NUM", "aaa\n"], ["NUM", "bbb\n"], ["NUM", "\f\n"], ["ARP", "Type: ARP\n"], ["ARP", "aaa\n"], ["ARP", "bbb\n"]]}, %q{
- t = nil
- unless ''.respond_to? :lines
- class String
- def lines
- self
- end
- end
- end
- ary = []
-"this must not print
-Type: NUM
-123
-456
-Type: ARP
-aaa
-bbb
-\f
-this must not print
-hoge
-Type: ARP
-aaa
-bbb
-".lines.each{|l|
- if (t = l[/^Type: (.*)/, 1])..(/^\f/ =~ l)
- ary << [t, l]
- end
- }
- ary
-}
-assert_equal %q{1}, %q{if true then 1 ; end}
-assert_equal %q{}, %q{if false then 1 ; end}
-assert_equal %q{1}, %q{if true then 1 ; else; 2; end}
-assert_equal %q{2}, %q{if false then 1 ; else; 2; end}
-assert_equal %q{}, %q{if true then ; elsif true then ; 1 ; end}
-assert_equal %q{1}, %q{if false then ; elsif true then ; 1 ; end}
-assert_equal %q{}, %q{unless true then 1 ; end}
-assert_equal %q{1}, %q{unless false then 1 ; end}
-assert_equal %q{2}, %q{unless true then 1 ; else; 2; end}
-assert_equal %q{1}, %q{unless false then 1 ; else; 2; end}
-assert_equal %q{1}, %q{1 if true}
-assert_equal %q{}, %q{1 if false}
-assert_equal %q{}, %q{1 if nil}
-assert_equal %q{}, %q{1 unless true}
-assert_equal %q{1}, %q{1 unless false}
-assert_equal %q{1}, %q{1 unless nil}
-assert_equal %q{1}, %q{1 || 2 || 3 || 4}
-assert_equal %q{1}, %q{1 || false || 3 || 4}
-assert_equal %q{2}, %q{nil || 2 || 3 || 4}
-assert_equal %q{2}, %q{false || 2 || 3 || 4}
-assert_equal %q{false}, %q{nil || false || nil || false}
-assert_equal %q{1}, %q{1 or 2 or 3 or 4}
-assert_equal %q{1}, %q{1 or false or 3 or 4}
-assert_equal %q{2}, %q{nil or 2 or 3 or 4}
-assert_equal %q{2}, %q{false or 2 or 3 or 4}
-assert_equal %q{false}, %q{nil or false or nil or false}
-assert_equal %q{elseng}, %q{
- case
- when 1==2, 2==3
- :ng1
- when false, 4==5
- :ok
- when false
- :ng2
- else
- :elseng
- end
-}
-assert_equal %q{ok}, %q{
- case
- when nil, nil
- :ng1
- when 1,2,3
- :ok
- when false, false
- :ng2
- else
- :elseng
- end
-}
-assert_equal %q{elseok}, %q{
- case
- when nil
- :ng1
- when false
- :ng2
- else
- :elseok
- end}
-assert_equal %q{}, %q{
- case
- when 1
- end
-}
-assert_equal %q{ok}, %q{
- r = nil
- ary = []
- case
- when false
- r = :ng1
- when false, false
- r = :ng2
- when *ary
- r = :ng3
- when false, *ary
- r = :ng4
- when true, *ary
- r = :ok
- end
- r
-}
-assert_equal %q{ok}, %q{
- ary = []
- case
- when false, *ary
- :ng
- else
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- ary = [false, nil]
- case
- when *ary
- :ng
- else
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- ary = [false, nil]
- case
- when *ary
- :ng
- when true
- :ok
- else
- :ng2
- end
-}
-assert_equal %q{ng}, %q{
- ary = [false, nil]
- case
- when *ary
- :ok
- else
- :ng
- end
-}
-assert_equal %q{ok}, %q{
- ary = [false, true]
- case
- when *ary
- :ok
- else
- :ng
- end
-}
-assert_equal %q{ok}, %q{
- ary = [false, true]
- case
- when false, false
- when false, *ary
- :ok
- else
- :ng
- end
-}
-assert_equal %q{}, %q{
- i = 0
- while i < 10
- i+=1
- end}
-assert_equal %q{10}, %q{
- i = 0
- while i < 10
- i+=1
- end; i}
-assert_equal %q{}, %q{
- i = 0
- until i > 10
- i+=1
- end}
-assert_equal %q{11}, %q{
- i = 0
- until i > 10
- i+=1
- end; i}
-assert_equal %q{1}, %q{
- i = 0
- begin
- i+=1
- end while false
- i
-}
-assert_equal %q{1}, %q{
- i = 0
- begin
- i+=1
- end until true
- i
-}
-def assert_syntax_error expected, code, message = ''
- assert_equal "#{expected}",
- "begin eval(%q{#{code}}, nil, '', 0)"'; rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end', message
-end
-assert_syntax_error "unterminated string meets end of file", '().."', '[ruby-dev:29732]'
-assert_equal %q{[]}, %q{$&;[]}, '[ruby-dev:31068]'
-assert_syntax_error "syntax error, unexpected tSTAR, expecting '}'", %q{{*0}}, '[ruby-dev:31072]'
-assert_syntax_error "empty symbol literal", %q{0..:""}, '[ruby-dev:31085]'
-assert_syntax_error "`@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]'
-assert_syntax_error "identifier $00 is not valid to get", %q{$00..0}, '[ruby-dev:31100]'
-assert_syntax_error "identifier $00 is not valid to set", %q{0..$00=1}
-assert_equal %q{0}, %q{[*0];0}, '[ruby-dev:31102]'
-assert_syntax_error "syntax error, unexpected ')'", %q{v0,(*,v1,) = 0}, '[ruby-dev:31104]'
-assert_equal %q{1}, %q{
- class << (ary=[]); def []; 0; end; def []=(x); super(0,x);end;end; ary[]+=1
-}, '[ruby-dev:31110]'
-assert_syntax_error "Can't set variable $1", %q{0..$1=1}, '[ruby-dev:31118]'
-assert_syntax_error "void value expression", %q{1.times{1+(1&&next)}}, '[ruby-dev:31119]'
-assert_syntax_error "void value expression", %q{x=-1;loop{x+=1&&redo if (x+=1).zero?}}, '[ruby-dev:31119]'
-assert_syntax_error %q{syntax error, unexpected $end}, %q{!}, '[ruby-dev:31243]'
-assert_equal %q{[nil]}, %q{[()]}, '[ruby-dev:31252]'
-assert_equal %q{true}, %q{!_=()}, '[ruby-dev:31263]'
-assert_equal 'ok', %q{while true; redo; end if 1 == 2; :ok}, '[ruby-dev:31360]'
-assert_equal 'ok', %q{
- 1.times {
- begin
- ensure
- next
- end
- }; :ok
-}, '[ruby-dev:31373]'
-assert_equal 'ok', %q{
- flag = false
- 1.times {
- next if flag
- flag = true
- begin
- ensure
- redo
- end
- }; :ok
-}, '[ruby-dev:31373]'
-
-assert_equal 'ok', %q{
- 1.times{
- p(1, (next; 2))
- }; :ok
-}
-assert_equal '3', %q{
- i = 0
- 1 + (while true
- break 2 if (i+=1) > 1
- next
- end)
-}
-assert_equal '3', %q{
- i = 0
- 1 + (while true
- break 2 if (i+=1) > 1
- p(1, (next; 2))
- end)
-}
-# redo
-assert_equal 'ok', %q{
- i = 0
- 1.times{
- break if i>1
- i+=1
- p(1, (redo; 2))
- }; :ok
-}
-assert_equal '3', %q{
- i = 0
- 1 + (while true
- break 2 if (i+=1) > 1
- redo
- end)
-}
-assert_equal '3', %q{
- i = 0
- 1 + (while true
- break 2 if (i+=1) > 1
- p(1, (redo; 2))
- end)
-}
-assert_equal '1', %q{
- a = [0]
- a[*a]+=1
-}
-assert_equal '2', %q{
- ary = [0]
- case 1
- when *ary, 1
- 1
- end +
- case
- when *ary
- 1
- end
-}
-
-assert_match /invalid multibyte char/, %q{
- STDERR.reopen(STDOUT)
- eval("\"\xf0".force_encoding("utf-8"))
-}, '[ruby-dev:32429]'
-
-# method ! and !=
-assert_equal 'true', %q{!false}
-assert_equal 'true', %q{1 == 1}
-assert_equal 'true', %q{1 != 2}
-assert_equal 'true', %q{
- class C; def !=(obj); true; end; end
- C.new != 1
-}
-assert_equal 'true', %q{
- class C; def !@; true; end; end
- !C.new
-}
-assert_normal_exit %q{
- eval "while true; return; end rescue p $!"
-}, '[ruby-dev:31663]'
-assert_equal '1', %q{
- def bar
- raise
- end
-
- def foo
- 1.times{
- begin
- return bar
- rescue
- :ok
- end
- }
- end
-
- foo
-}
-
-assert_equal 'ok', %q{
- counter = 2
- while true
- counter -= 1
- next if counter != 0
- break
- end
- :ok
-}, '[ruby-core:14385]'
-
-assert_equal 'ok', %q{
- counter = 2
- while true
- counter -= 1
- next if counter != 0
- break :ok
- end # direct
-}, '[ruby-core:14385]'
-
-assert_equal 'ok', %q{
- counter = 2
- while true
- counter -= 1
- break if counter == 0
- "#{next}"
- end
- :ok
-}, 'reported by Yusuke ENDOH'
-
-assert_equal 'ok', %q{
- counter = 2
- while true
- counter -= 1
- break if counter == 0
- next
- redo
- end
- :ok
-}, 'reported by Yusuke ENDOH'
-
-assert_equal 'ok', %q{
- counter = 2
- while true
- counter -= 1
- break if counter == 0
- next
- "#{ redo }"
- end
- :ok
-}, 'reported by Yusuke ENDOH'
-
-assert_normal_exit %q{
- begin
- raise
- rescue
- counter = 2
- while true
- counter -= 1
- break if counter == 0
- next
- retry
- end
- end
-}, 'reported by Yusuke ENDOH'
-
-assert_normal_exit %q{
- counter = 2
- while true
- counter -= 1
- break if counter == 0
- next
- "#{ break }"
- end
-}, 'reported by Yusuke ENDOH'
-
-assert_normal_exit %q{
- counter = 2
- while true
- counter -= 1
- next if counter != 0
- "#{ break }"
- end
-}, 'reported by Yusuke ENDOH'
-
diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb
deleted file mode 100644
index b3592e9bd7..0000000000
--- a/bootstraptest/test_thread.rb
+++ /dev/null
@@ -1,195 +0,0 @@
-assert_equal %q{ok}, %q{
- Thread.new{
- }.join
- :ok
-}
-assert_equal %q{ok}, %q{
- Thread.new{
- :ok
- }.value
-}
-assert_equal %q{20100}, %q{
- v = 0
- (1..200).map{|i|
- Thread.new{
- i
- }
- }.each{|t|
- v += t.value
- }
- v
-}
-assert_equal %q{5000}, %q{
- 5000.times{|e|
- (1..2).map{
- Thread.new{
- }
- }.each{|e|
- e.join()
- }
- }
-}
-assert_equal %q{5000}, %q{
- 5000.times{|e|
- (1..2).map{
- Thread.new{
- }
- }.each{|e|
- e.join(1000000000)
- }
- }
-}
-assert_equal %q{5000}, %q{
- 5000.times{
- t = Thread.new{}
- while t.alive?
- Thread.pass
- end
- }
-}
-assert_equal %q{100}, %q{
- 100.times{
- Thread.new{loop{Thread.pass}}
- }
-}
-assert_equal %q{ok}, %q{
- Thread.new{
- :ok
- }.join.value
-}
-assert_equal %q{ok}, %q{
- begin
- Thread.new{
- raise "ok"
- }.join
- rescue => e
- e
- end
-}
-assert_equal %q{ok}, %q{
- ans = nil
- t = Thread.new{
- begin
- sleep 0.5
- ensure
- ans = :ok
- end
- }
- Thread.pass
- t.kill
- t.join
- ans
-}
-assert_equal %q{ok}, %q{
- t = Thread.new{
- sleep
- }
- sleep 0.1
- t.raise
- begin
- t.join
- :ng
- rescue
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- t = Thread.new{
- loop{}
- }
- Thread.pass
- t.raise
- begin
- t.join
- :ng
- rescue
- :ok
- end
-}
-assert_equal %q{ok}, %q{
- t = Thread.new{
- }
- Thread.pass
- t.join
- t.raise # raise to exited thread
- begin
- t.join
- :ok
- rescue
- :ng
- end
-}
-assert_equal %q{run}, %q{
- t = Thread.new{
- loop{}
- }
- st = t.status
- t.kill
- st
-}
-assert_equal %q{sleep}, %q{
- t = Thread.new{
- sleep
- }
- sleep 0.1
- st = t.status
- t.kill
- st
-}
-assert_equal %q{false}, %q{
- t = Thread.new{
- }
- t.kill
- sleep 0.1
- t.status
-}
-assert_equal %q{[ThreadGroup, true]}, %q{
- ptg = Thread.current.group
- Thread.new{
- ctg = Thread.current.group
- [ctg.class, ctg == ptg]
- }.value
-}
-assert_equal %q{[1, 1]}, %q{
- thg = ThreadGroup.new
-
- t = Thread.new{
- thg.add Thread.current
- sleep
- }
- sleep 0.1
- [thg.list.size, ThreadGroup::Default.list.size]
-}
-assert_equal %q{[true, nil, true]}, %q{
- /a/ =~ 'a'
- $a = $~
- Thread.new{
- $b = $~
- /a/ =~ 'a'
- $c = $~
- }
- $d = $~
- [$a == $d, $b, $c != $d]
-}
-assert_equal %q{11}, %q{
- Thread.current[:a] = 1
- Thread.new{
- Thread.current[:a] = 10
- Thread.pass
- Thread.current[:a]
- }.value + Thread.current[:a]
-}
-assert_equal %q{100}, %q{
-begin
- 100.times do |i|
- begin
- Thread.start(Thread.current) {|u| u.raise }
- raise
- rescue
- ensure
- end
- end
-rescue
- 100
-end
-}, '[ruby-dev:31371]'
diff --git a/class.c b/class.c
index 5bb801d2e0..096c7fbdf1 100644
--- a/class.c
+++ b/class.c
@@ -6,64 +6,45 @@
$Date$
created at: Tue Aug 10 15:05:44 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/signal.h"
-#include "ruby/node.h"
-#include "ruby/st.h"
+#include "ruby.h"
+#include "rubysig.h"
+#include "node.h"
+#include "st.h"
#include <ctype.h>
extern st_table *rb_class_tbl;
-static VALUE
-class_alloc(VALUE flags, VALUE klass)
-{
- rb_classext_t *ext = ALLOC(rb_classext_t);
- NEWOBJ(obj, struct RClass);
- OBJSETUP(obj, klass, flags);
- obj->ptr = ext;
- RCLASS_IV_TBL(obj) = 0;
- RCLASS_M_TBL(obj) = 0;
- RCLASS_SUPER(obj) = 0;
- RCLASS_IV_INDEX_TBL(obj) = 0;
- return (VALUE)obj;
-}
-
VALUE
-rb_class_boot(VALUE super)
+rb_class_boot(super)
+ VALUE super;
{
- VALUE klass = class_alloc(T_CLASS, rb_cClass);
+ NEWOBJ(klass, struct RClass);
+ OBJSETUP(klass, rb_cClass, T_CLASS);
- RCLASS_SUPER(klass) = super;
- RCLASS_M_TBL(klass) = st_init_numtable();
+ klass->super = super;
+ klass->iv_tbl = 0;
+ klass->m_tbl = 0; /* safe GC */
+ klass->m_tbl = st_init_numtable();
OBJ_INFECT(klass, super);
return (VALUE)klass;
}
-void
-rb_check_inheritable(VALUE super)
-{
- if (TYPE(super) != T_CLASS) {
- rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
- rb_obj_classname(super));
- }
- if (RBASIC(super)->flags & FL_SINGLETON) {
- rb_raise(rb_eTypeError, "can't make subclass of singleton class");
- }
-}
-
VALUE
-rb_class_new(VALUE super)
+rb_class_new(super)
+ VALUE super;
{
Check_Type(super, T_CLASS);
- rb_check_inheritable(super);
if (super == rb_cClass) {
rb_raise(rb_eTypeError, "can't make subclass of Class");
}
+ if (FL_TEST(super, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
+ }
return rb_class_boot(super);
}
@@ -73,47 +54,47 @@ struct clone_method_data {
};
static int
-clone_method(ID mid, NODE *body, struct clone_method_data *data)
+clone_method(mid, body, data)
+ ID mid;
+ NODE *body;
+ struct clone_method_data *data;
{
- if (body == 0) {
- st_insert(data->tbl, mid, 0);
- }
- else {
- st_insert(data->tbl, mid,
- (st_data_t)
- NEW_FBODY(
- NEW_METHOD(body->nd_body->nd_body,
- data->klass, /* TODO */
- body->nd_body->nd_noex),
- 0));
+ NODE *fbody = body->nd_body;
+
+ if (fbody && nd_type(fbody) == NODE_SCOPE) {
+ fbody = rb_copy_node_scope(fbody, ruby_cref);
}
+ st_insert(data->tbl, mid, (st_data_t)NEW_METHOD(fbody, body->nd_noex));
return ST_CONTINUE;
}
/* :nodoc: */
VALUE
-rb_mod_init_copy(VALUE clone, VALUE orig)
+rb_mod_init_copy(clone, orig)
+ VALUE clone, orig;
{
rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
- RBASIC(clone)->klass = rb_singleton_class_clone(orig);
+ RBASIC(clone)->klass = RBASIC(orig)->klass;
+ RBASIC(clone)->klass = rb_singleton_class_clone(clone);
}
- RCLASS_SUPER(clone) = RCLASS_SUPER(orig);
- if (RCLASS_IV_TBL(orig)) {
+ RCLASS(clone)->super = RCLASS(orig)->super;
+ if (RCLASS(orig)->iv_tbl) {
ID id;
- RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
+ RCLASS(clone)->iv_tbl = st_copy(RCLASS(orig)->iv_tbl);
id = rb_intern("__classpath__");
- st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0);
+ st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
id = rb_intern("__classid__");
- st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0);
+ st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
}
- if (RCLASS_M_TBL(orig)) {
+ if (RCLASS(orig)->m_tbl) {
struct clone_method_data data;
- data.tbl = RCLASS_M_TBL(clone) = st_init_numtable();
- data.klass = clone;
- st_foreach(RCLASS_M_TBL(orig), clone_method,
- (st_data_t)&data);
+
+ data.tbl = RCLASS(clone)->m_tbl = st_init_numtable();
+ data.klass = (VALUE)clone;
+
+ st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)&data);
}
return clone;
@@ -121,9 +102,10 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
/* :nodoc: */
VALUE
-rb_class_init_copy(VALUE clone, VALUE orig)
+rb_class_init_copy(clone, orig)
+ VALUE clone, orig;
{
- if (RCLASS_SUPER(clone) != 0) {
+ if (RCLASS(clone)->super != 0) {
rb_raise(rb_eTypeError, "already initialized class");
}
if (FL_TEST(orig, FL_SINGLETON)) {
@@ -133,16 +115,17 @@ rb_class_init_copy(VALUE clone, VALUE orig)
}
VALUE
-rb_singleton_class_clone(VALUE obj)
+rb_singleton_class_clone(obj)
+ VALUE obj;
{
VALUE klass = RBASIC(obj)->klass;
if (!FL_TEST(klass, FL_SINGLETON))
return klass;
else {
- struct clone_method_data data;
/* copy singleton(unnamed) class */
- VALUE clone = class_alloc(RBASIC(klass)->flags, 0);
+ NEWOBJ(clone, struct RClass);
+ OBJSETUP(clone, 0, RBASIC(klass)->flags);
if (BUILTIN_TYPE(obj) == T_CLASS) {
RBASIC(clone)->klass = (VALUE)clone;
@@ -151,15 +134,28 @@ rb_singleton_class_clone(VALUE obj)
RBASIC(clone)->klass = rb_singleton_class_clone(klass);
}
- RCLASS_SUPER(clone) = RCLASS_SUPER(klass);
- if (RCLASS_IV_TBL(klass)) {
- RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(klass));
+ clone->super = RCLASS(klass)->super;
+ clone->iv_tbl = 0;
+ clone->m_tbl = 0;
+ if (RCLASS(klass)->iv_tbl) {
+ clone->iv_tbl = st_copy(RCLASS(klass)->iv_tbl);
+ }
+ {
+ struct clone_method_data data;
+
+ data.tbl = clone->m_tbl = st_init_numtable();
+ switch (TYPE(obj)) {
+ case T_CLASS:
+ case T_MODULE:
+ data.klass = obj;
+ break;
+ default:
+ data.klass = 0;
+ break;
+ }
+
+ st_foreach(RCLASS(klass)->m_tbl, clone_method, (st_data_t)&data);
}
- RCLASS_M_TBL(clone) = st_init_numtable();
- data.tbl = RCLASS_M_TBL(clone);
- data.klass = (VALUE)clone;
- st_foreach(RCLASS_M_TBL(klass), clone_method,
- (st_data_t)&data);
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
FL_SET(clone, FL_SINGLETON);
return (VALUE)clone;
@@ -167,41 +163,45 @@ rb_singleton_class_clone(VALUE obj)
}
void
-rb_singleton_class_attached(VALUE klass, VALUE obj)
+rb_singleton_class_attached(klass, obj)
+ VALUE klass, obj;
{
if (FL_TEST(klass, FL_SINGLETON)) {
- if (!RCLASS_IV_TBL(klass)) {
- RCLASS_IV_TBL(klass) = st_init_numtable();
+ if (!RCLASS(klass)->iv_tbl) {
+ RCLASS(klass)->iv_tbl = st_init_numtable();
}
- st_insert(RCLASS_IV_TBL(klass), rb_intern("__attached__"), obj);
+ st_insert(RCLASS(klass)->iv_tbl, rb_intern("__attached__"), obj);
}
}
VALUE
-rb_make_metaclass(VALUE obj, VALUE super)
+rb_make_metaclass(obj, super)
+ VALUE obj, super;
{
+ VALUE klass = rb_class_boot(super);
+ FL_SET(klass, FL_SINGLETON);
+ RBASIC(obj)->klass = klass;
+ rb_singleton_class_attached(klass, obj);
if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) {
- return RBASIC(obj)->klass = rb_cClass;
+ RBASIC(klass)->klass = klass;
+ RCLASS(klass)->super = RBASIC(rb_class_real(RCLASS(obj)->super))->klass;
}
else {
- VALUE metasuper;
- VALUE klass = rb_class_boot(super);
-
- FL_SET(klass, FL_SINGLETON);
- RBASIC(obj)->klass = klass;
- rb_singleton_class_attached(klass, obj);
+ VALUE metasuper = RBASIC(rb_class_real(super))->klass;
- metasuper = RBASIC(rb_class_real(super))->klass;
/* metaclass of a superclass may be NULL at boot time */
if (metasuper) {
RBASIC(klass)->klass = metasuper;
}
- return klass;
}
+
+ return klass;
}
VALUE
-rb_define_class_id(ID id, VALUE super)
+rb_define_class_id(id, super)
+ ID id;
+ VALUE super;
{
VALUE klass;
@@ -212,15 +212,31 @@ rb_define_class_id(ID id, VALUE super)
return klass;
}
+void
+rb_check_inheritable(super)
+ VALUE super;
+{
+ if (TYPE(super) != T_CLASS) {
+ rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
+ rb_obj_classname(super));
+ }
+ if (RBASIC(super)->flags & FL_SINGLETON) {
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
+ }
+}
+
VALUE
-rb_class_inherited(VALUE super, VALUE klass)
+rb_class_inherited(super, klass)
+ VALUE super, klass;
{
if (!super) super = rb_cObject;
return rb_funcall(super, rb_intern("inherited"), 1, klass);
}
VALUE
-rb_define_class(const char *name, VALUE super)
+rb_define_class(name, super)
+ const char *name;
+ VALUE super;
{
VALUE klass;
ID id;
@@ -231,7 +247,7 @@ rb_define_class(const char *name, VALUE super)
if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class", name);
}
- if (rb_class_real(RCLASS_SUPER(klass)) != super) {
+ if (rb_class_real(RCLASS(klass)->super) != super) {
rb_name_error(id, "%s is already defined", name);
}
return klass;
@@ -249,7 +265,10 @@ rb_define_class(const char *name, VALUE super)
}
VALUE
-rb_define_class_under(VALUE outer, const char *name, VALUE super)
+rb_define_class_under(outer, name, super)
+ VALUE outer;
+ const char *name;
+ VALUE super;
{
VALUE klass;
ID id;
@@ -260,7 +279,7 @@ rb_define_class_under(VALUE outer, const char *name, VALUE super)
if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class", name);
}
- if (rb_class_real(RCLASS_SUPER(klass)) != super) {
+ if (rb_class_real(RCLASS(klass)->super) != super) {
rb_name_error(id, "%s is already defined", name);
}
return klass;
@@ -278,17 +297,22 @@ rb_define_class_under(VALUE outer, const char *name, VALUE super)
}
VALUE
-rb_module_new(void)
+rb_module_new()
{
- VALUE mdl = class_alloc(T_MODULE, rb_cModule);
+ NEWOBJ(mdl, struct RClass);
+ OBJSETUP(mdl, rb_cModule, T_MODULE);
- RCLASS_M_TBL(mdl) = st_init_numtable();
+ mdl->super = 0;
+ mdl->iv_tbl = 0;
+ mdl->m_tbl = 0;
+ mdl->m_tbl = st_init_numtable();
return (VALUE)mdl;
}
VALUE
-rb_define_module_id(ID id)
+rb_define_module_id(id)
+ ID id;
{
VALUE mdl;
@@ -299,7 +323,8 @@ rb_define_module_id(ID id)
}
VALUE
-rb_define_module(const char *name)
+rb_define_module(name)
+ const char *name;
{
VALUE module;
ID id;
@@ -319,7 +344,9 @@ rb_define_module(const char *name)
}
VALUE
-rb_define_module_under(VALUE outer, const char *name)
+rb_define_module_under(outer, name)
+ VALUE outer;
+ const char *name;
{
VALUE module;
ID id;
@@ -340,19 +367,21 @@ rb_define_module_under(VALUE outer, const char *name)
}
static VALUE
-include_class_new(VALUE module, VALUE super)
+include_class_new(module, super)
+ VALUE module, super;
{
- VALUE klass = class_alloc(T_ICLASS, rb_cClass);
+ NEWOBJ(klass, struct RClass);
+ OBJSETUP(klass, rb_cClass, T_ICLASS);
if (BUILTIN_TYPE(module) == T_ICLASS) {
module = RBASIC(module)->klass;
}
- if (!RCLASS_IV_TBL(module)) {
- RCLASS_IV_TBL(module) = st_init_numtable();
+ if (!RCLASS(module)->iv_tbl) {
+ RCLASS(module)->iv_tbl = st_init_numtable();
}
- RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
- RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
- RCLASS_SUPER(klass) = super;
+ klass->iv_tbl = RCLASS(module)->iv_tbl;
+ klass->m_tbl = RCLASS(module)->m_tbl;
+ klass->super = super;
if (TYPE(module) == T_ICLASS) {
RBASIC(klass)->klass = RBASIC(module)->klass;
}
@@ -366,7 +395,8 @@ include_class_new(VALUE module, VALUE super)
}
void
-rb_include_module(VALUE klass, VALUE module)
+rb_include_module(klass, module)
+ VALUE klass, module;
{
VALUE p, c;
int changed = 0;
@@ -383,30 +413,30 @@ rb_include_module(VALUE klass, VALUE module)
OBJ_INFECT(klass, module);
c = klass;
while (module) {
- int superclass_seen = Qfalse;
+ int superclass_seen = Qfalse;
- if (RCLASS_M_TBL(klass) == RCLASS_M_TBL(module))
+ if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl)
rb_raise(rb_eArgError, "cyclic include detected");
- /* ignore if the module included already in superclasses */
- for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) {
- switch (BUILTIN_TYPE(p)) {
- case T_ICLASS:
- if (RCLASS_M_TBL(p) == RCLASS_M_TBL(module)) {
- if (!superclass_seen) {
- c = p; /* move insertion point */
- }
- goto skip;
- }
- break;
- case T_CLASS:
- superclass_seen = Qtrue;
- break;
- }
- }
- c = RCLASS_SUPER(c) = include_class_new(module, RCLASS_SUPER(c));
+ /* ignore if the module included already in superclasses */
+ for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
+ switch (BUILTIN_TYPE(p)) {
+ case T_ICLASS:
+ if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
+ if (!superclass_seen) {
+ c = p; /* move insertion point */
+ }
+ goto skip;
+ }
+ break;
+ case T_CLASS:
+ superclass_seen = Qtrue;
+ break;
+ }
+ }
+ c = RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
changed = 1;
skip:
- module = RCLASS_SUPER(module);
+ module = RCLASS(module)->super;
}
if (changed) rb_clear_cache();
}
@@ -429,12 +459,13 @@ rb_include_module(VALUE klass, VALUE module)
*/
VALUE
-rb_mod_included_modules(VALUE mod)
+rb_mod_included_modules(mod)
+ VALUE mod;
{
VALUE ary = rb_ary_new();
VALUE p;
- for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
+ for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
@@ -462,12 +493,14 @@ rb_mod_included_modules(VALUE mod)
*/
VALUE
-rb_mod_include_p(VALUE mod, VALUE mod2)
+rb_mod_include_p(mod, mod2)
+ VALUE mod;
+ VALUE mod2;
{
VALUE p;
Check_Type(mod2, T_MODULE);
- for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
+ for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) {
if (BUILTIN_TYPE(p) == T_ICLASS) {
if (RBASIC(p)->klass == mod2) return Qtrue;
}
@@ -492,11 +525,12 @@ rb_mod_include_p(VALUE mod, VALUE mod2)
*/
VALUE
-rb_mod_ancestors(VALUE mod)
+rb_mod_ancestors(mod)
+ VALUE mod;
{
VALUE p, ary = rb_ary_new();
- for (p = mod; p; p = RCLASS_SUPER(p)) {
+ for (p = mod; p; p = RCLASS(p)->super) {
if (FL_TEST(p, FL_SINGLETON))
continue;
if (BUILTIN_TYPE(p) == T_ICLASS) {
@@ -513,10 +547,13 @@ rb_mod_ancestors(VALUE mod)
#define VISI_CHECK(x,f) (VISI(x) == (f))
static int
-ins_methods_push(ID name, long type, VALUE ary, long visi)
+ins_methods_push(name, type, ary, visi)
+ ID name;
+ long type;
+ VALUE ary;
+ long visi;
{
if (type == -1) return ST_CONTINUE;
-
switch (visi) {
case NOEX_PRIVATE:
case NOEX_PROTECTED:
@@ -528,58 +565,70 @@ ins_methods_push(ID name, long type, VALUE ary, long visi)
break;
}
if (visi) {
- rb_ary_push(ary, ID2SYM(name));
+ rb_ary_push(ary, rb_str_new2(rb_id2name(name)));
}
return ST_CONTINUE;
}
static int
-ins_methods_i(ID name, long type, VALUE ary)
+ins_methods_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
{
return ins_methods_push(name, type, ary, -1); /* everything but private */
}
static int
-ins_methods_prot_i(ID name, long type, VALUE ary)
+ins_methods_prot_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
{
return ins_methods_push(name, type, ary, NOEX_PROTECTED);
}
static int
-ins_methods_priv_i(ID name, long type, VALUE ary)
+ins_methods_priv_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
{
return ins_methods_push(name, type, ary, NOEX_PRIVATE);
}
static int
-ins_methods_pub_i(ID name, long type, VALUE ary)
+ins_methods_pub_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
{
return ins_methods_push(name, type, ary, NOEX_PUBLIC);
}
static int
-method_entry(ID key, NODE *body, st_table *list)
+method_entry(key, body, list)
+ ID key;
+ NODE *body;
+ st_table *list;
{
long type;
- if (key == ID_ALLOCATOR) {
- return ST_CONTINUE;
- }
-
+ if (key == ID_ALLOCATOR) return ST_CONTINUE;
if (!st_lookup(list, key, 0)) {
- if (body ==0 || !body->nd_body->nd_body) {
- type = -1; /* none */
- }
- else {
- type = VISI(body->nd_body->nd_noex);
- }
+ if (!body->nd_body) type = -1; /* none */
+ else type = VISI(body->nd_noex);
st_add_direct(list, key, type);
}
return ST_CONTINUE;
}
static VALUE
-class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, long, VALUE))
+class_instance_method_list(argc, argv, mod, func)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+ int (*func) _((ID, long, VALUE));
{
VALUE ary;
int recur;
@@ -595,8 +644,8 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
}
list = st_init_numtable();
- for (; mod; mod = RCLASS_SUPER(mod)) {
- st_foreach(RCLASS_M_TBL(mod), method_entry, (st_data_t)list);
+ for (; mod; mod = RCLASS(mod)->super) {
+ st_foreach(RCLASS(mod)->m_tbl, method_entry, (st_data_t)list);
if (BUILTIN_TYPE(mod) == T_ICLASS) continue;
if (FL_TEST(mod, FL_SINGLETON)) continue;
if (!recur) break;
@@ -636,7 +685,10 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
*/
VALUE
-rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
+rb_class_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
return class_instance_method_list(argc, argv, mod, ins_methods_i);
}
@@ -651,7 +703,10 @@ rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
*/
VALUE
-rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
+rb_class_protected_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
return class_instance_method_list(argc, argv, mod, ins_methods_prot_i);
}
@@ -674,7 +729,10 @@ rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
*/
VALUE
-rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
+rb_class_private_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
return class_instance_method_list(argc, argv, mod, ins_methods_priv_i);
}
@@ -689,7 +747,10 @@ rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
*/
VALUE
-rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
+rb_class_public_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
return class_instance_method_list(argc, argv, mod, ins_methods_pub_i);
}
@@ -727,7 +788,10 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
*/
VALUE
-rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
+rb_obj_singleton_methods(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE recur, ary, klass;
st_table *list;
@@ -739,13 +803,13 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
klass = CLASS_OF(obj);
list = st_init_numtable();
if (klass && FL_TEST(klass, FL_SINGLETON)) {
- st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
- klass = RCLASS_SUPER(klass);
+ st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
+ klass = RCLASS(klass)->super;
}
if (RTEST(recur)) {
while (klass && (FL_TEST(klass, FL_SINGLETON) || TYPE(klass) == T_ICLASS)) {
- st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
- klass = RCLASS_SUPER(klass);
+ st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
+ klass = RCLASS(klass)->super;
}
}
ary = rb_ary_new();
@@ -756,31 +820,53 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
}
void
-rb_define_method_id(VALUE klass, ID name, VALUE (*func)(ANYARGS), int argc)
+rb_define_method_id(klass, name, func, argc)
+ VALUE klass;
+ ID name;
+ VALUE (*func)();
+ int argc;
{
rb_add_method(klass, name, NEW_CFUNC(func,argc), NOEX_PUBLIC);
}
void
-rb_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc)
+rb_define_method(klass, name, func, argc)
+ VALUE klass;
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
- rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PUBLIC);
+ ID id = rb_intern(name);
+ int ex = NOEX_PUBLIC;
+
+
+ rb_add_method(klass, id, NEW_CFUNC(func, argc), ex);
}
void
-rb_define_protected_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc)
+rb_define_protected_method(klass, name, func, argc)
+ VALUE klass;
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PROTECTED);
}
void
-rb_define_private_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc)
+rb_define_private_method(klass, name, func, argc)
+ VALUE klass;
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PRIVATE);
}
void
-rb_undef_method(VALUE klass, const char *name)
+rb_undef_method(klass, name)
+ VALUE klass;
+ const char *name;
{
rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
}
@@ -792,7 +878,8 @@ rb_undef_method(VALUE klass, const char *name)
} while (0)
VALUE
-rb_singleton_class(VALUE obj)
+rb_singleton_class(obj)
+ VALUE obj;
{
VALUE klass;
@@ -827,47 +914,77 @@ rb_singleton_class(VALUE obj)
}
void
-rb_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS), int argc)
+rb_define_singleton_method(obj, name, func, argc)
+ VALUE obj;
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
rb_define_method(rb_singleton_class(obj), name, func, argc);
}
void
-rb_define_module_function(VALUE module, const char *name, VALUE (*func)(ANYARGS), int argc)
+rb_define_module_function(module, name, func, argc)
+ VALUE module;
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
rb_define_private_method(module, name, func, argc);
rb_define_singleton_method(module, name, func, argc);
}
void
-rb_define_global_function(const char *name, VALUE (*func)(ANYARGS), int argc)
+rb_define_global_function(name, func, argc)
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
rb_define_module_function(rb_mKernel, name, func, argc);
}
void
-rb_define_alias(VALUE klass, const char *name1, const char *name2)
+rb_define_alias(klass, name1, name2)
+ VALUE klass;
+ const char *name1, *name2;
{
rb_alias(klass, rb_intern(name1), rb_intern(name2));
}
void
-rb_define_attr(VALUE klass, const char *name, int read, int write)
+rb_define_attr(klass, name, read, write)
+ VALUE klass;
+ const char *name;
+ int read, write;
{
rb_attr(klass, rb_intern(name), read, write, Qfalse);
}
+#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
int
+#ifdef HAVE_STDARG_PROTOTYPES
rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
+#else
+rb_scan_args(argc, argv, fmt, va_alist)
+ int argc;
+ const VALUE *argv;
+ const char *fmt;
+ va_dcl
+#endif
{
int n, i = 0;
const char *p = fmt;
VALUE *var;
va_list vargs;
- va_start(vargs, fmt);
+ va_init_list(vargs, fmt);
if (*p == '*') goto rest_arg;
diff --git a/common.mk b/common.mk
index 3c80cdb11e..bf49aade4a 100644
--- a/common.mk
+++ b/common.mk
@@ -2,9 +2,12 @@ bin: $(PROGRAM) $(WPROGRAM)
lib: $(LIBRUBY)
dll: $(LIBRUBY_SO)
-.SUFFIXES: .inc
+RUBYLIB = -
+RUBYOPT = -
-RUBYOPT =
+SPEC_GIT_BASE = git://github.com/rubyspec
+MSPEC_GIT_URL = $(SPEC_GIT_BASE)/mspec.git
+RUBYSPEC_GIT_URL = $(SPEC_GIT_BASE)/rubyspec.git
STATIC_RUBY = static-ruby
@@ -14,23 +17,20 @@ LIBRUBY_EXTS = ./.libruby-with-ext.time
RDOCOUT = $(EXTOUT)/rdoc
DMYEXT = dmyext.$(OBJEXT)
-NORMALMAINOBJ = main.$(OBJEXT)
-MAINOBJ = $(NORMALMAINOBJ)
+MAINOBJ = main.$(OBJEXT)
EXTOBJS =
DLDOBJS = $(DMYEXT)
-COMMONOBJS = array.$(OBJEXT) \
+OBJS = array.$(OBJEXT) \
bignum.$(OBJEXT) \
class.$(OBJEXT) \
compar.$(OBJEXT) \
dir.$(OBJEXT) \
- encoding.$(OBJEXT) \
+ dln.$(OBJEXT) \
enum.$(OBJEXT) \
enumerator.$(OBJEXT) \
error.$(OBJEXT) \
eval.$(OBJEXT) \
- load.$(OBJEXT) \
- proc.$(OBJEXT) \
file.$(OBJEXT) \
gc.$(OBJEXT) \
hash.$(OBJEXT) \
@@ -47,12 +47,7 @@ COMMONOBJS = array.$(OBJEXT) \
random.$(OBJEXT) \
range.$(OBJEXT) \
re.$(OBJEXT) \
- regcomp.$(OBJEXT) \
- regenc.$(OBJEXT) \
- regerror.$(OBJEXT) \
- regexec.$(OBJEXT) \
- regparse.$(OBJEXT) \
- regsyntax.$(OBJEXT) \
+ regex.$(OBJEXT) \
ruby.$(OBJEXT) \
signal.$(OBJEXT) \
sprintf.$(OBJEXT) \
@@ -60,35 +55,22 @@ COMMONOBJS = array.$(OBJEXT) \
string.$(OBJEXT) \
struct.$(OBJEXT) \
time.$(OBJEXT) \
- transcode.$(OBJEXT) \
util.$(OBJEXT) \
variable.$(OBJEXT) \
version.$(OBJEXT) \
- blockinlining.$(OBJEXT) \
- compile.$(OBJEXT) \
- debug.$(OBJEXT) \
- iseq.$(OBJEXT) \
- vm.$(OBJEXT) \
- vm_dump.$(OBJEXT) \
- thread.$(OBJEXT) \
- cont.$(OBJEXT) \
- id.$(OBJEXT) \
- $(BUILTIN_ENCOBJS) \
$(MISSING)
-OBJS = dln.$(OBJEXT) \
- prelude.$(OBJEXT) \
- $(COMMONOBJS)
-
-GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)
-
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) --installed-list $(INSTALLED_LIST)
+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)
@@ -96,19 +78,11 @@ PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil'
TESTSDIR = $(srcdir)/test
TESTWORKDIR = testwork
-BOOTSTRAPRUBY = $(BASERUBY)
-
-all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY) encs
- @$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
+all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
+ @$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS)
prog: $(PROGRAM) $(WPROGRAM)
-miniruby$(EXEEXT): config.status $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE)
-
-GORUBY = go$(RUBY_INSTALL_NAME)
-golf: $(LIBRUBY) $(GOLFOBJS)
- $(MAKE) $(MFLAGS) MAINOBJ="$(GOLFOBJS)" PROGRAM=$(GORUBY)$(EXEEXT) program
-
-program: $(PROGRAM)
+miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(MINIOBJS) $(OBJS) $(DMYEXT)
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
@@ -123,8 +97,8 @@ $(STATIC_RUBY)$(EXEEXT): $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A)
@$(RM) $@
$(PURIFY) $(CC) $(MAINOBJ) $(DLDOBJS) $(EXTOBJS) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)$@ $(LDFLAGS) $(XLDFLAGS)
-ruby.imp: $(COMMONOBJS)
- @$(NM) -Pgp $(COMMONOBJS) | awk 'BEGIN{print "#!"}; $$2~/^[BD]$$/{print $$1}' | sort -u -o $@
+ruby.imp: $(OBJS)
+ @$(NM) -Pgp $(OBJS) | awk 'BEGIN{print "#!"}; $$2~/^[BD]$$/{print $$1}' | sort -u -o $@
install: install-nodoc $(RDOCTARGET)
install-all: install-nodoc install-doc
@@ -132,65 +106,68 @@ 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 $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
+ $(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
post-install-nodoc:: post-install-local post-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 $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
+ $(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
+loadpath: $(PREP)
+ $(MINIRUBY) -e 'p $$:'
+
post-install-local:: post-install-bin post-install-lib post-install-man
install-ext: pre-install-ext do-install-ext post-install-ext
pre-install-ext:: pre-install-ext-arch pre-install-ext-comm
do-install-ext:
- $(MINIRUBY) $(srcdir)/instruby.rb $(INSTRUBY_ARGS) --install=ext
+ $(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 $(INSTRUBY_ARGS) --install=bin --install=ext-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 $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man
+ $(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 $(INSTRUBY_ARGS) --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 $(INSTRUBY_ARGS) --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 $(INSTRUBY_ARGS) --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 $(INSTRUBY_ARGS) --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 $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
+ $(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
post-install-man::
@$(NULLCMD)
@@ -203,42 +180,42 @@ what-where-nodoc: no-install-nodoc
no-install-nodoc: pre-no-install-nodoc dont-install-nodoc post-no-install-nodoc
pre-no-install-nodoc:: pre-no-install-local pre-no-install-ext
dont-install-nodoc:
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
+ $(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --mantype="$(MANTYPE)"
post-no-install-nodoc:: post-no-install-local post-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 $(INSTRUBY_ARGS) --install=local --mantype="$(MANTYPE)"
+ $(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
what-where-ext: no-install-ext
no-install-ext: pre-no-install-ext dont-install-ext post-no-install-ext
pre-no-install-ext:: pre-no-install-ext-arch pre-no-install-ext-comm
dont-install-ext:
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext
+ $(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 $(INSTRUBY_ARGS) --install=bin --install=ext-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 $(INSTRUBY_ARGS) --install=lib --install=ext-comm --install=man
+ $(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 $(INSTRUBY_ARGS) --install=bin
+ $(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=bin
post-no-install-bin::
@$(NULLCMD)
@@ -246,7 +223,7 @@ what-where-lib: no-install-lib
no-install-lib: pre-no-install-lib dont-install-lib post-no-install-lib
pre-no-install-lib:: install-prereq
dont-install-lib:
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=lib
+ $(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=lib
post-no-install-lib::
@$(NULLCMD)
@@ -254,7 +231,7 @@ what-where-ext-comm: no-install-ext-comm
no-install-ext-comm: pre-no-install-ext-comm dont-install-ext-comm post-no-install-ext-comm
pre-no-install-ext-comm:: install-prereq
dont-install-ext-comm:
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext-comm
+ $(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext-comm
post-no-install-ext-comm::
@$(NULLCMD)
@@ -262,7 +239,7 @@ what-where-ext-arch: no-install-ext-arch
no-install-ext-arch: pre-no-install-ext-arch dont-install-ext-arch post-no-install-ext-arch
pre-no-install-ext-arch:: install-prereq
dont-install-ext-arch:
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=ext-arch
+ $(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=ext-arch
post-no-install-ext-arch::
@$(NULLCMD)
@@ -270,14 +247,14 @@ what-where-man: no-install-man
no-install-man: pre-no-install-man dont-install-man post-no-install-man
pre-no-install-man:: install-prereq
dont-install-man:
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=man --mantype="$(MANTYPE)"
+ $(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 $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
+ $(MINIRUBY) $(srcdir)/instruby.rb --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
post-install-doc::
@$(NULLCMD)
@@ -289,7 +266,7 @@ what-where-doc: no-install-doc
no-install-doc: pre-no-install-doc dont-install-doc post-no-install-doc
pre-no-install-doc:: install-prereq
dont-install-doc::
- $(MINIRUBY) $(srcdir)/instruby.rb -n $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
+ $(MINIRUBY) $(srcdir)/instruby.rb -n --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc --rdoc-output="$(RDOCOUT)"
post-no-install-doc::
@$(NULLCMD)
@@ -302,51 +279,36 @@ clear-installed-list:
clean: clean-ext clean-local
clean-local::
- @$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
+ @$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
@$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time
- @$(RM) *.inc
+ @$(RM) y.tab.c y.output
clean-ext:
- @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) clean
-clean-enc:
- @-$(MAKE) -f enc.mk $(MFLAGS) clean
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(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 y.tab.c y.output $(PREP)
+ @$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP)
distclean-ext:
- @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) distclean
-# -$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h
-# -rmdir -p $(arch_hdrdir)/ruby
-distclean-enc: clean-enc
- @-$(MAKE) -f enc.mk $(MFLAGS) distclean
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) distclean
realclean:: realclean-ext realclean-local
realclean-local:: distclean-local
@$(RM) parse.c lex.c
realclean-ext::
- @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS) realclean
-realclean-enc:: distclean-enc
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) realclean
check: test test-all
-btest: miniruby$(EXEEXT) PHONY
- $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(MINIRUBY)" $(OPTS)
-
-btest-miniruby: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
- @$(MINIRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(MINIRUBY)" -q
-
-test-sample: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
+test: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
@$(MINIRUBY) $(srcdir)/rubytest.rb
-test: test-sample btest-miniruby
-
test-all:
$(RUNRUBY) "$(srcdir)/test/runner.rb" --basedir="$(TESTSDIR)" --runner=$(TESTUI) $(TESTS)
extconf:
- $(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTCONFDIR)"
+ $(MINIRUBY) -run -e mkdir -- -p "$(EXTCONFDIR)"
$(RUNRUBY) -C "$(EXTCONFDIR)" $(EXTCONF) $(EXTCONFARGS)
$(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
@@ -354,27 +316,13 @@ $(RBCONFIG): $(srcdir)/mkconfig.rb config.status $(PREP)
-install_name=$(RUBY_INSTALL_NAME) \
-so_name=$(RUBY_SO_NAME) rbconfig.rb
-encs: enc.mk
- $(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTOUT)/$(arch)/enc/trans" enc/trans
- $(MAKE) -f enc.mk $(MFLAGS)
-
-enc.mk: $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend \
- $(srcdir)/lib/mkmf.rb $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/enc/make_encmake.rb --builtin-encs="$(BUILTIN_ENCOBJS)" $@
-
.PRECIOUS: $(MKFILES)
.PHONY: test install install-nodoc install-doc dist
PHONY:
-{$(VPATH)}parse.c: {$(VPATH)}parse.y $(srcdir)/tool/ytab.sed
-
-{$(srcdir)}.y.c:
- $(YACC) $(YFLAGS) -o y.tab.c $<
- sed -f $(srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@.new
- @$(RM) $@ y.tab.c
- @$(MV) $@.new $@
+{$(VPATH)}parse.c: parse.y
acosh.$(OBJEXT): {$(VPATH)}acosh.c
alloca.$(OBJEXT): {$(VPATH)}alloca.c
@@ -386,6 +334,7 @@ flock.$(OBJEXT): {$(VPATH)}flock.c
memcmp.$(OBJEXT): {$(VPATH)}memcmp.c
memmove.$(OBJEXT): {$(VPATH)}memmove.c
mkdir.$(OBJEXT): {$(VPATH)}mkdir.c
+vsnprintf.$(OBJEXT): {$(VPATH)}vsnprintf.c
strcasecmp.$(OBJEXT): {$(VPATH)}strcasecmp.c
strncasecmp.$(OBJEXT): {$(VPATH)}strncasecmp.c
strchr.$(OBJEXT): {$(VPATH)}strchr.c
@@ -409,338 +358,111 @@ win32.$(OBJEXT): {$(VPATH)}win32.c
###
-array.$(OBJEXT): {$(VPATH)}array.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+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 {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-class.$(OBJEXT): {$(VPATH)}class.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+bignum.$(OBJEXT): {$(VPATH)}bignum.c {$(VPATH)}ruby.h config.h \
+ {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
+ {$(VPATH)}rubysig.h
+class.$(OBJEXT): {$(VPATH)}class.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}signal.h {$(VPATH)}node.h {$(VPATH)}st.h
-compar.$(OBJEXT): {$(VPATH)}compar.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}rubysig.h {$(VPATH)}node.h {$(VPATH)}st.h
+compar.$(OBJEXT): {$(VPATH)}compar.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-dir.$(OBJEXT): {$(VPATH)}dir.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+dir.$(OBJEXT): {$(VPATH)}dir.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}util.h
-dln.$(OBJEXT): {$(VPATH)}dln.c {$(VPATH)}ruby.h {$(VPATH)}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 {$(VPATH)}dln.c {$(VPATH)}ruby.h \
- {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}dln.h
+dmydln.$(OBJEXT): {$(VPATH)}dmydln.c dln.$(OBJEXT)
dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
-encoding.$(OBJEXT): {$(VPATH)}encoding.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
- {$(VPATH)}regenc.h
-enum.$(OBJEXT): {$(VPATH)}enum.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+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 {$(VPATH)}config.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 {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}st.h {$(VPATH)}vm_opts.h {$(VPATH)}signal.h \
- {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}node.h {$(VPATH)}debug.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h
-eval.$(OBJEXT): {$(VPATH)}eval.c {$(VPATH)}eval_error.c {$(VPATH)}eval_intern.h \
- {$(VPATH)}eval_method.c {$(VPATH)}eval_safe.c {$(VPATH)}eval_jump.c \
- {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}vm_core.h {$(VPATH)}id.h \
+error.$(OBJEXT): {$(VPATH)}error.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}signal.h \
- {$(VPATH)}st.h {$(VPATH)}dln.h {$(VPATH)}debug.h \
- {$(VPATH)}vm_opts.h {$(VPATH)}thread_$(THREAD_MODEL).h
-load.$(OBJEXT): {$(VPATH)}load.c {$(VPATH)}eval_intern.h \
- {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}env.h {$(VPATH)}st.h
+eval.$(OBJEXT): {$(VPATH)}eval.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}vm_core.h {$(VPATH)}id.h \
- {$(VPATH)}signal.h {$(VPATH)}st.h {$(VPATH)}dln.h {$(VPATH)}debug.h \
- {$(VPATH)}vm_opts.h {$(VPATH)}thread_$(THREAD_MODEL).h
-file.$(OBJEXT): {$(VPATH)}file.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}node.h {$(VPATH)}env.h {$(VPATH)}util.h \
+ {$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}dln.h
+file.$(OBJEXT): {$(VPATH)}file.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}io.h {$(VPATH)}signal.h {$(VPATH)}util.h \
+ {$(VPATH)}rubyio.h {$(VPATH)}rubysig.h {$(VPATH)}util.h \
{$(VPATH)}dln.h
-gc.$(OBJEXT): {$(VPATH)}gc.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+gc.$(OBJEXT): {$(VPATH)}gc.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}signal.h {$(VPATH)}st.h {$(VPATH)}node.h \
- {$(VPATH)}re.h {$(VPATH)}io.h {$(VPATH)}regex.h {$(VPATH)}oniguruma.h \
- {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h
-hash.$(OBJEXT): {$(VPATH)}hash.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}rubysig.h {$(VPATH)}st.h {$(VPATH)}node.h \
+ {$(VPATH)}env.h {$(VPATH)}re.h {$(VPATH)}regex.h
+hash.$(OBJEXT): {$(VPATH)}hash.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}signal.h
-inits.$(OBJEXT): {$(VPATH)}inits.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}rubysig.h
+inits.$(OBJEXT): {$(VPATH)}inits.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-io.$(OBJEXT): {$(VPATH)}io.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+io.$(OBJEXT): {$(VPATH)}io.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}io.h {$(VPATH)}signal.h {$(VPATH)}util.h
-main.$(OBJEXT): {$(VPATH)}main.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}rubyio.h {$(VPATH)}rubysig.h {$(VPATH)}util.h \
+ {$(VPATH)}env.h
+main.$(OBJEXT): {$(VPATH)}main.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-marshal.$(OBJEXT): {$(VPATH)}marshal.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+marshal.$(OBJEXT): {$(VPATH)}marshal.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}io.h {$(VPATH)}st.h {$(VPATH)}util.h
-math.$(OBJEXT): {$(VPATH)}math.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}rubyio.h {$(VPATH)}st.h {$(VPATH)}util.h
+math.$(OBJEXT): {$(VPATH)}math.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-numeric.$(OBJEXT): {$(VPATH)}numeric.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}encoding.h \
+numeric.$(OBJEXT): {$(VPATH)}numeric.c {$(VPATH)}ruby.h config.h \
+ {$(VPATH)}env.h {$(VPATH)}defines.h {$(VPATH)}intern.h \
{$(VPATH)}missing.h
-object.$(OBJEXT): {$(VPATH)}object.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+object.$(OBJEXT): {$(VPATH)}object.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}debug.h
-pack.$(OBJEXT): {$(VPATH)}pack.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}st.h {$(VPATH)}util.h
+pack.$(OBJEXT): {$(VPATH)}pack.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-parse.$(OBJEXT): {$(VPATH)}parse.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+parse.$(OBJEXT): {$(VPATH)}parse.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}st.h {$(VPATH)}oniguruma.h \
- {$(VPATH)}regenc.h {$(VPATH)}regex.h {$(VPATH)}util.h {$(VPATH)}lex.c
-prec.$(OBJEXT): {$(VPATH)}prec.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}env.h {$(VPATH)}node.h {$(VPATH)}st.h \
+ {$(VPATH)}regex.h {$(VPATH)}util.h {$(VPATH)}lex.c
+prec.$(OBJEXT): {$(VPATH)}prec.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \
- {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}vm_core.h {$(VPATH)}id.h \
+process.$(OBJEXT): {$(VPATH)}process.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}gc.h \
- {$(VPATH)}signal.h {$(VPATH)}st.h {$(VPATH)}dln.h \
- {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h
-process.$(OBJEXT): {$(VPATH)}process.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}signal.h {$(VPATH)}st.h {$(VPATH)}vm_core.h {$(VPATH)}id.h
-random.$(OBJEXT): {$(VPATH)}random.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}rubysig.h {$(VPATH)}st.h
+random.$(OBJEXT): {$(VPATH)}random.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-range.$(OBJEXT): {$(VPATH)}range.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+range.$(OBJEXT): {$(VPATH)}range.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-re.$(OBJEXT): {$(VPATH)}re.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}re.h {$(VPATH)}regex.h \
- {$(VPATH)}regint.h {$(VPATH)}regenc.h {$(VPATH)}signal.h
-regcomp.$(OBJEXT): {$(VPATH)}regcomp.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}regint.h {$(VPATH)}regparse.h \
- {$(VPATH)}regenc.h {$(VPATH)}signal.h
-regenc.$(OBJEXT): {$(VPATH)}regenc.c {$(VPATH)}regint.h \
- {$(VPATH)}regenc.h {$(VPATH)}oniguruma.h {$(VPATH)}ruby.h \
- {$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \
- {$(VPATH)}signal.h {$(VPATH)}config.h
-regerror.$(OBJEXT): {$(VPATH)}regerror.c {$(VPATH)}regint.h \
- {$(VPATH)}regenc.h {$(VPATH)}oniguruma.h {$(VPATH)}config.h \
- {$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
- {$(VPATH)}intern.h {$(VPATH)}signal.h
-regexec.$(OBJEXT): {$(VPATH)}regexec.c {$(VPATH)}regint.h \
- {$(VPATH)}regenc.h {$(VPATH)}oniguruma.h {$(VPATH)}config.h \
- {$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
- {$(VPATH)}intern.h {$(VPATH)}signal.h
-regparse.$(OBJEXT): {$(VPATH)}regparse.c {$(VPATH)}oniguruma.h \
- {$(VPATH)}regint.h {$(VPATH)}regparse.h {$(VPATH)}regenc.h {$(VPATH)}config.h \
- {$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
- {$(VPATH)}intern.h {$(VPATH)}signal.h
-regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c {$(VPATH)}oniguruma.h \
- {$(VPATH)}regint.h {$(VPATH)}regenc.h {$(VPATH)}config.h \
- {$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h
-ruby.$(OBJEXT): {$(VPATH)}ruby.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}dln.h {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}encoding.h
-signal.$(OBJEXT): {$(VPATH)}signal.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+re.$(OBJEXT): {$(VPATH)}re.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}signal.h {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}node.h \
- {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h
-sprintf.$(OBJEXT): {$(VPATH)}sprintf.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}re.h {$(VPATH)}regex.h
+regex.$(OBJEXT): {$(VPATH)}regex.c config.h {$(VPATH)}regex.h
+ruby.$(OBJEXT): {$(VPATH)}ruby.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}re.h {$(VPATH)}regex.h {$(VPATH)}oniguruma.h \
- {$(VPATH)}vsnprintf.c
-st.$(OBJEXT): {$(VPATH)}st.c {$(VPATH)}config.h {$(VPATH)}st.h {$(VPATH)}defines.h
-string.$(OBJEXT): {$(VPATH)}string.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}dln.h {$(VPATH)}node.h {$(VPATH)}util.h
+signal.$(OBJEXT): {$(VPATH)}signal.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}re.h {$(VPATH)}regex.h {$(VPATH)}encoding.h
-struct.$(OBJEXT): {$(VPATH)}struct.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}rubysig.h
+sprintf.$(OBJEXT): {$(VPATH)}sprintf.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \
- {$(VPATH)}thread_win32.h {$(VPATH)}thread_pthread.h \
- {$(VPATH)}thread_win32.c {$(VPATH)}thread_pthread.c \
- {$(VPATH)}ruby.h {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}config.h \
+st.$(OBJEXT): {$(VPATH)}st.c config.h {$(VPATH)}st.h
+string.$(OBJEXT): {$(VPATH)}string.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}util.h \
- {$(VPATH)}signal.h {$(VPATH)}st.h {$(VPATH)}dln.h
-transcode.$(OBJEXT): {$(VPATH)}transcode.c {$(VPATH)}transcode_data.h {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h {$(VPATH)}encoding.h
-cont.$(OBJEXT): {$(VPATH)}cont.c {$(VPATH)}eval_intern.h \
- {$(VPATH)}ruby.h {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}util.h \
- {$(VPATH)}signal.h {$(VPATH)}st.h {$(VPATH)}dln.h
-time.$(OBJEXT): {$(VPATH)}time.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}re.h {$(VPATH)}regex.h
+struct.$(OBJEXT): {$(VPATH)}struct.c {$(VPATH)}ruby.h config.h \
+ {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
+time.$(OBJEXT): {$(VPATH)}time.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-util.$(OBJEXT): {$(VPATH)}util.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+util.$(OBJEXT): {$(VPATH)}util.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
{$(VPATH)}util.h
-variable.$(OBJEXT): {$(VPATH)}variable.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+variable.$(OBJEXT): {$(VPATH)}variable.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}node.h {$(VPATH)}st.h {$(VPATH)}util.h
-version.$(OBJEXT): {$(VPATH)}version.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
+ {$(VPATH)}env.h {$(VPATH)}node.h {$(VPATH)}st.h {$(VPATH)}util.h
+version.$(OBJEXT): {$(VPATH)}version.c {$(VPATH)}ruby.h config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h \
- {$(VPATH)}version.h {$(VPATH)}revision.h
-
-compile.$(OBJEXT): {$(VPATH)}compile.c {$(VPATH)}vm_core.h {$(VPATH)}id.h \
- {$(VPATH)}compile.h {$(VPATH)}debug.h {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \
- {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}signal.h \
- {$(VPATH)}insns_info.inc {$(VPATH)}optinsn.inc \
- {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc {$(VPATH)}vm_opts.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h
-iseq.$(OBJEXT): {$(VPATH)}iseq.c {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}debug.h \
- {$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
- {$(VPATH)}intern.h {$(VPATH)}st.h {$(VPATH)}signal.h \
- {$(VPATH)}gc.h {$(VPATH)}vm_opts.h {$(VPATH)}config.h {$(VPATH)}node.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}insns_info.inc \
- {$(VPATH)}node_name.inc
-vm.$(OBJEXT): {$(VPATH)}vm.c {$(VPATH)}vm.h {$(VPATH)}vm_core.h {$(VPATH)}id.h \
- {$(VPATH)}debug.h {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}st.h \
- {$(VPATH)}node.h {$(VPATH)}util.h {$(VPATH)}signal.h {$(VPATH)}dln.h \
- {$(VPATH)}insnhelper.h {$(VPATH)}vm_insnhelper.c {$(VPATH)}vm_evalbody.c \
- {$(VPATH)}insns.inc {$(VPATH)}vm.inc {$(VPATH)}vmtc.inc \
- {$(VPATH)}vm_opts.h {$(VPATH)}eval_intern.h \
- {$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \
- {$(VPATH)}gc.h {$(VPATH)}thread_$(THREAD_MODEL).h
-vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}vm.h \
- {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
- {$(VPATH)}intern.h {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}debug.h \
- {$(VPATH)}signal.h {$(VPATH)}vm_opts.h {$(VPATH)}thread_$(THREAD_MODEL).h
-debug.$(OBJEXT): {$(VPATH)}debug.h {$(VPATH)}ruby.h {$(VPATH)}defines.h \
- {$(VPATH)}missing.h {$(VPATH)}intern.h {$(VPATH)}st.h {$(VPATH)}config.h \
- {$(VPATH)}st.h
-blockinlining.$(OBJEXT): {$(VPATH)}blockinlining.c \
- {$(VPATH)}ruby.h {$(VPATH)}defines.h \
- {$(VPATH)}missing.h {$(VPATH)}intern.h {$(VPATH)}st.h {$(VPATH)}config.h \
- {$(VPATH)}node.h {$(VPATH)}vm_core.h {$(VPATH)}id.h {$(VPATH)}signal.h \
- {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
- {$(VPATH)}thread_$(THREAD_MODEL).h
-id.$(OBJEXT): {$(VPATH)}id.c {$(VPATH)}ruby.h
-miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
-prelude.$(OBJEXT): {$(VPATH)}prelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
-golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
-goruby.$(OBJEXT): {$(VPATH)}goruby.c {$(VPATH)}main.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
- {$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
-
-ascii.$(OBJEXT): {$(VPATH)}ascii.c {$(VPATH)}regenc.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
-euc_jp.$(OBJEXT): {$(VPATH)}euc_jp.c {$(VPATH)}regenc.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
-sjis.$(OBJEXT): {$(VPATH)}sjis.c {$(VPATH)}regenc.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
-unicode.$(OBJEXT): {$(VPATH)}unicode.c {$(VPATH)}regenc.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
-utf8.$(OBJEXT): {$(VPATH)}utf8.c {$(VPATH)}regenc.h \
- {$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
-
-INSNS = opt_sc.inc optinsn.inc optunifs.inc insns.inc \
- vmtc.inc vm.inc
-
-INSNS2VMOPT = --srcdir="$(srcdir)"
-
-$(INSNS): $(srcdir)/insns.def {$(VPATH)}vm_opts.h
- $(RM) $(PROGRAM)
- $(BASERUBY) $(srcdir)/tool/insns2vm.rb $(INSNS2VMOPT)
-
-minsns.inc: $(srcdir)/template/minsns.inc.tmpl
-
-opt_sc.inc: $(srcdir)/template/opt_sc.inc.tmpl
-
-optinsn.inc: $(srcdir)/template/optinsn.inc.tmpl
-
-optunifs.inc: $(srcdir)/template/optunifs.inc.tmpl
-
-insns.inc: $(srcdir)/template/insns.inc.tmpl
-
-insns_info.inc: $(srcdir)/template/insns_info.inc.tmpl
-
-vmtc.inc: $(srcdir)/template/vmtc.inc.tmpl
-
-vm.inc: $(srcdir)/template/vm.inc.tmpl
-
-srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c $(srcdir)/ext/ripper/ripper.c
-
-incs: $(INSNS) {$(VPATH)}node_name.inc {$(VPATH)}revision.h
-
-node_name.inc: {$(VPATH)}node.h
- $(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@
-
-miniprelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb
- $(BASERUBY) -I$(srcdir) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $@
-
-prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $(RBCONFIG)
- $(MINIRUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $@
-
-golf_prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/golf_prelude.rb
- $(BASERUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/golf_prelude.rb $@
-
-prereq: incs srcs preludes
-
-preludes: {$(VPATH)}miniprelude.c
-preludes: {$(srcdir)}golf_prelude.c
-
-docs:
- $(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)
-
-revision.h:
- exit > $@
-
-$(srcdir)/ext/ripper/ripper.c:
- cd $(srcdir)/ext/ripper && exec $(MAKE) -f depend $(MFLAGS) top_srcdir=../.. srcdir=.
-
-##
-
-run: miniruby$(EXEEXT) PHONY
- $(MINIRUBY) -I$(srcdir)/lib $(srcdir)/test.rb $(RUNOPT)
-
-runruby: $(PROGRAM) PHONY
- $(RUNRUBY) $(srcdir)/test.rb
-
-parse: miniruby$(EXEEXT) PHONY
- $(MINIRUBY) $(srcdir)/tool/parse.rb $(srcdir)/test.rb
-
-COMPARE_RUBY = $(BASERUBY)
-ITEM =
-OPTS =
-
-benchmark: $(PROGRAM) PHONY
- $(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
- --executables="$(COMPARE_RUBY); $(RUNRUBY)" \
- --pattern='bm_' --directory=$(srcdir)/benchmark $(OPTS)
-
-benchmark-each: $(PROGRAM) PHONY
- $(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
- --executables="$(COMPARE_RUBY); $(RUNRUBY)" \
- --pattern=$(ITEM) --directory=$(srcdir)/benchmark $(OPTS)
-
-tbench: $(PROGRAM) PHONY
- $(BASERUBY) $(srcdir)/benchmark/driver.rb -v \
- --executables="$(COMPARE_RUBY); $(RUNRUBY)" \
- --pattern='bmx_' --directory=$(srcdir)/benchmark $(OPTS)
-
-aotc: $(PROGRAM) PHONY
- ./$(PROGRAM) -I$(srcdir)/lib $(srcdir)/bin/ruby2cext $(srcdir)/test.rb
-
-vmasm: vm.$(ASMEXT)
-
-# vm.o : CFLAGS += -fno-crossjumping
-
-run.gdb:
- echo b ruby_debug_breakpoint > run.gdb
- echo '# handle SIGINT nostop' >> run.gdb
- echo '# handle SIGPIPE nostop' >> run.gdb
- echo '# b rb_longjmp' >> run.gdb
- echo source $(srcdir)/breakpoints.gdb >> run.gdb
- echo source $(srcdir)/.gdbinit >> run.gdb
- echo run >> run.gdb
-
-gdb: miniruby$(EXEEXT) run.gdb PHONY
- gdb -x run.gdb --quiet --args $(MINIRUBY) -I$(srcdir)/lib $(srcdir)/test.rb
-
-# Intel VTune
-
-vtune: miniruby$(EXEEXT)
- vtl activity -c sampling -app ".\miniruby$(EXEEXT)","-I$(srcdir)/lib $(srcdir)/test.rb" run
- vtl view -hf -mn miniruby$(EXEEXT) -sum -sort -cd
- vtl view -ha -mn miniruby$(EXEEXT) -sum -sort -cd | $(RUNRUBY) $(srcdir)/tool/vtlh.rb > ha.lines
+ {$(VPATH)}version.h
dist: $(PROGRAM)
$(RUNRUBY) $(srcdir)/distruby.rb
diff --git a/compar.c b/compar.c
index c1eb2d2861..1488b2c65d 100644
--- a/compar.c
+++ b/compar.c
@@ -6,25 +6,26 @@
$Date$
created at: Thu Aug 26 14:39:48 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
VALUE rb_mComparable;
static ID cmp;
int
-rb_cmpint(VALUE val, VALUE a, VALUE b)
+rb_cmpint(val, a, b)
+ VALUE val, a, b;
{
if (NIL_P(val)) {
rb_cmperr(a, b);
}
if (FIXNUM_P(val)) return FIX2INT(val);
if (TYPE(val) == T_BIGNUM) {
- if (RBIGNUM_SIGN(val)) return 1;
+ if (RBIGNUM(val)->sign) return 1;
return -1;
}
if (RTEST(rb_funcall(val, '>', 1, INT2FIX(0)))) return 1;
@@ -33,7 +34,8 @@ rb_cmpint(VALUE val, VALUE a, VALUE b)
}
void
-rb_cmperr(VALUE x, VALUE y)
+rb_cmperr(x, y)
+ VALUE x, y;
{
const char *classname;
@@ -48,20 +50,23 @@ rb_cmperr(VALUE x, VALUE y)
rb_obj_classname(x), classname);
}
+#define cmperr() (rb_cmperr(x, y), Qnil)
+
static VALUE
-cmp_eq(VALUE *a)
+cmp_eq(a)
+ VALUE *a;
{
VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
- if (NIL_P(c)) return Qfalse;
+ if (NIL_P(c)) return Qnil;
if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
return Qfalse;
}
static VALUE
-cmp_failed(void)
+cmp_failed()
{
- return Qfalse;
+ return Qnil;
}
/*
@@ -74,7 +79,8 @@ cmp_failed(void)
*/
static VALUE
-cmp_equal(VALUE x, VALUE y)
+cmp_equal(x, y)
+ VALUE x, y;
{
VALUE a[2];
@@ -93,10 +99,12 @@ cmp_equal(VALUE x, VALUE y)
*/
static VALUE
-cmp_gt(VALUE x, VALUE y)
+cmp_gt(x, y)
+ VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
+ if (NIL_P(c)) return cmperr();
if (rb_cmpint(c, x, y) > 0) return Qtrue;
return Qfalse;
}
@@ -110,10 +118,12 @@ cmp_gt(VALUE x, VALUE y)
*/
static VALUE
-cmp_ge(VALUE x, VALUE y)
+cmp_ge(x, y)
+ VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
+ if (NIL_P(c)) return cmperr();
if (rb_cmpint(c, x, y) >= 0) return Qtrue;
return Qfalse;
}
@@ -127,14 +137,17 @@ cmp_ge(VALUE x, VALUE y)
*/
static VALUE
-cmp_lt(VALUE x, VALUE y)
+cmp_lt(x, y)
+ VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
+ if (NIL_P(c)) return cmperr();
if (rb_cmpint(c, x, y) < 0) return Qtrue;
return Qfalse;
}
+
/*
* call-seq:
* obj <= other => true or false
@@ -144,10 +157,12 @@ cmp_lt(VALUE x, VALUE y)
*/
static VALUE
-cmp_le(VALUE x, VALUE y)
+cmp_le(x, y)
+ VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
+ if (NIL_P(c)) return cmperr();
if (rb_cmpint(c, x, y) <= 0) return Qtrue;
return Qfalse;
}
@@ -168,7 +183,8 @@ cmp_le(VALUE x, VALUE y)
*/
static VALUE
-cmp_between(VALUE x, VALUE min, VALUE max)
+cmp_between(x, min, max)
+ VALUE x, min, max;
{
if (RTEST(cmp_lt(x, min))) return Qfalse;
if (RTEST(cmp_gt(x, max))) return Qfalse;
@@ -213,7 +229,7 @@ cmp_between(VALUE x, VALUE min, VALUE max)
*/
void
-Init_Comparable(void)
+Init_Comparable()
{
rb_mComparable = rb_define_module("Comparable");
rb_define_method(rb_mComparable, "==", cmp_equal, 1);
diff --git a/compile.c b/compile.c
deleted file mode 100644
index 1e26d45419..0000000000
--- a/compile.c
+++ /dev/null
@@ -1,4913 +0,0 @@
-/**********************************************************************
-
- compile.c - ruby node tree -> VM instruction sequence
-
- $Author$
- $Date$
- created at: 04/01/01 03:42:15 JST
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-
-#define USE_INSN_STACK_INCREASE 1
-#include "vm_core.h"
-#include "compile.h"
-#include "insns.inc"
-#include "insns_info.inc"
-
-#ifdef HAVE_STDARG_PROTOTYPES
-#include <stdarg.h>
-#define va_init_list(a,b) va_start(a,b)
-#else
-#include <varargs.h>
-#define va_init_list(a,b) va_start(a)
-#endif
-
-/* iseq.c */
-VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt);
-
-/* vm.c */
-VALUE vm_eval(void *);
-
-/* types */
-
-#define ISEQ_ELEMENT_NONE INT2FIX(0x00)
-#define ISEQ_ELEMENT_LABEL INT2FIX(0x01)
-#define ISEQ_ELEMENT_INSN INT2FIX(0x02)
-#define ISEQ_ELEMENT_SEQ INT2FIX(0x03)
-
-typedef struct iseq_link_element {
- int type;
- struct iseq_link_element *next;
- struct iseq_link_element *prev;
-} LINK_ELEMENT;
-
-typedef struct iseq_link_anchor {
- LINK_ELEMENT anchor;
- LINK_ELEMENT *last;
-} LINK_ANCHOR;
-
-typedef struct iseq_label_data {
- LINK_ELEMENT link;
- int label_no;
- int position;
- int sc_state;
- int set;
- int sp;
-} LABEL;
-
-typedef struct iseq_insn_data {
- LINK_ELEMENT link;
- int insn_id;
- int line_no;
- int operand_size;
- int sc_state;
- VALUE *operands;
-} INSN;
-
-struct ensure_range {
- LABEL *begin;
- LABEL *end;
- struct ensure_range *next;
-};
-
-struct iseq_compile_data_ensure_node_stack {
- NODE *ensure_node;
- struct iseq_compile_data_ensure_node_stack *prev;
- struct ensure_range *erange;
-};
-
-#include "optinsn.inc"
-#if OPT_INSTRUCTIONS_UNIFICATION
-#include "optunifs.inc"
-#endif
-
-/* for debug */
-#if CPDEBUG > 0
-static long gl_node_level = 0;
-static void debug_list(LINK_ANCHOR *anchor);
-#endif
-
-static void dump_disasm_list(LINK_ELEMENT *elem);
-
-static int insn_data_length(INSN *iobj);
-static int insn_data_line_no(INSN *iobj);
-static int calc_sp_depth(int depth, INSN *iobj);
-
-static void ADD_ELEM(LINK_ANCHOR *anchor, LINK_ELEMENT *elem);
-
-static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...);
-static LABEL *new_label_body(rb_iseq_t *iseq, int line);
-
-static int iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * n, int);
-static int iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
-static int iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
-static int iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
-
-static int iseq_set_local_table(rb_iseq_t *iseq, ID *tbl);
-static int iseq_set_exception_local_table(rb_iseq_t *iseq);
-static int iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * node);
-
-static int iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
-static int iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
-static int iseq_set_exception_table(rb_iseq_t *iseq);
-static int iseq_set_optargs_table(rb_iseq_t *iseq);
-
-static int
-iseq_add_mark_object(rb_iseq_t *iseq, VALUE v)
-{
- if (!SPECIAL_CONST_P(v)) {
- rb_ary_push(iseq->mark_ary, v);
- }
- return COMPILE_OK;
-}
-
-static int
-iseq_add_mark_object_compile_time(rb_iseq_t *iseq, VALUE v)
-{
- if (!SPECIAL_CONST_P(v)) {
- rb_ary_push(iseq->compile_data->mark_ary, v);
- }
- return COMPILE_OK;
-}
-
-VALUE
-iseq_compile(VALUE self, NODE *node)
-{
- DECL_ANCHOR(ret);
- rb_iseq_t *iseq;
- INIT_ANCHOR(ret);
- GetISeqPtr(self, iseq);
-
- if (node == 0) {
- COMPILE(ret, "nil", node);
- iseq_set_local_table(iseq, 0);
- }
- else if (nd_type(node) == NODE_SCOPE) {
- /* iseq type of top, method, class, block */
- iseq_set_local_table(iseq, node->nd_tbl);
- iseq_set_arguments(iseq, ret, node->nd_args);
-
- switch (iseq->type) {
- case ISEQ_TYPE_BLOCK: {
- LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0);
- LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0);
-
- ADD_LABEL(ret, iseq->compile_data->start_label);
- COMPILE(ret, "block body", node->nd_body);
- ADD_LABEL(ret, iseq->compile_data->end_label);
-
- /* wide range catch handler must put at last */
- ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, 0, start);
- ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, end);
- break;
- }
- case ISEQ_TYPE_CLASS: {
- ADD_TRACE(ret, nd_line(node), RUBY_EVENT_CLASS);
- COMPILE(ret, "scoped node", node->nd_body);
- ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END);
- break;
- }
- case ISEQ_TYPE_METHOD: {
- ADD_TRACE(ret, nd_line(node), RUBY_EVENT_CALL);
- COMPILE(ret, "scoped node", node->nd_body);
- ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
- break;
- }
- default: {
- COMPILE(ret, "scoped node", node->nd_body);
- break;
- }
- }
- }
- else {
- switch (iseq->type) {
- case ISEQ_TYPE_METHOD:
- case ISEQ_TYPE_CLASS:
- case ISEQ_TYPE_BLOCK:
- case ISEQ_TYPE_EVAL:
- case ISEQ_TYPE_TOP:
- rb_compile_error(ERROR_ARGS "compile/should not be reached: %s:%d",
- __FILE__, __LINE__);
- break;
- case ISEQ_TYPE_RESCUE:
- iseq_set_exception_local_table(iseq);
- COMPILE(ret, "rescue", node);
- break;
- case ISEQ_TYPE_ENSURE:
- iseq_set_exception_local_table(iseq);
- COMPILE_POPED(ret, "ensure", node);
- break;
- case ISEQ_TYPE_DEFINED_GUARD:
- COMPILE(ret, "defined guard", node);
- break;
- default:
- rb_bug("unknown scope");
- }
- }
-
- if (iseq->type == ISEQ_TYPE_RESCUE || iseq->type == ISEQ_TYPE_ENSURE) {
- ADD_INSN2(ret, 0, getdynamic, INT2FIX(1), INT2FIX(0));
- ADD_INSN1(ret, 0, throw, INT2FIX(0) /* continue throw */ );
- }
- else {
- ADD_INSN(ret, iseq->compile_data->last_line, leave);
- }
-
- return iseq_setup(iseq, ret);
-}
-
-int
-iseq_translate_threaded_code(rb_iseq_t *iseq)
-{
-#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
-
-#if OPT_DIRECT_THREADED_CODE
- const void *const *table = (const void **)vm_eval(0);
-#else
- extern const void *const *get_insns_address_table();
- const void *const *table = get_insns_address_table();
-#endif
- int i;
-
- iseq->iseq_encoded = ALLOC_N(VALUE, iseq->iseq_size);
- MEMCPY(iseq->iseq_encoded, iseq->iseq, VALUE, iseq->iseq_size);
-
- for (i = 0; i < iseq->iseq_size; /* */ ) {
- int insn = iseq->iseq_encoded[i];
- int len = insn_len(insn);
- iseq->iseq_encoded[i] = (VALUE)table[insn];
- i += len;
- }
-#else
- iseq->iseq_encoded = iseq->iseq;
-#endif
- return COMPILE_OK;
-}
-
-/*********************************************/
-/* definition of data structure for compiler */
-/*********************************************/
-
-static void *
-compile_data_alloc(rb_iseq_t *iseq, size_t size)
-{
- void *ptr = 0;
- struct iseq_compile_data_storage *storage =
- iseq->compile_data->storage_current;
-
- if (storage->pos + size > storage->size) {
- unsigned long alloc_size = storage->size * 2;
-
- retry:
- if (alloc_size < size) {
- alloc_size *= 2;
- goto retry;
- }
- storage->next = (void *)ALLOC_N(char, alloc_size +
- sizeof(struct
- iseq_compile_data_storage));
- storage = iseq->compile_data->storage_current = storage->next;
- storage->next = 0;
- storage->pos = 0;
- storage->size = alloc_size;
- storage->buff = (char *)(&storage->buff + 1);
- }
-
- ptr = (void *)&storage->buff[storage->pos];
- storage->pos += size;
- return ptr;
-}
-
-static INSN *
-compile_data_alloc_insn(rb_iseq_t *iseq)
-{
- return (INSN *)compile_data_alloc(iseq, sizeof(INSN));
-}
-
-static LABEL *
-compile_data_alloc_label(rb_iseq_t *iseq)
-{
- return (LABEL *)compile_data_alloc(iseq, sizeof(LABEL));
-}
-
-/*
- * To make Array to LinkedList, use link_anchor
- */
-
-static void
-verify_list(char *info, LINK_ANCHOR *anchor)
-{
-#if CPDEBUG > 0
- int flag = 0;
- LINK_ELEMENT *list = anchor->anchor.next, *plist = &anchor->anchor;
-
- while (list) {
- if (plist != list->prev) {
- flag += 1;
- }
- plist = list;
- list = list->next;
- }
-
- if (anchor->last != plist && anchor->last != 0) {
- flag |= 0x70000;
- }
-
- if (flag != 0) {
- rb_bug("list verify error: %08x (%s)", flag, info);
- }
-#endif
-}
-
-/*
- * elem1, elem2 => elem1, elem2, elem
- */
-static void
-ADD_ELEM(LINK_ANCHOR *anchor, LINK_ELEMENT *elem)
-{
- elem->prev = anchor->last;
- anchor->last->next = elem;
- anchor->last = elem;
- verify_list("add", anchor);
-}
-
-#if 0 /* unused */
-/*
- * elem1, elemX => elem1, elem2, elemX
- */
-static void
-INSERT_ELEM_NEXT(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
-{
- elem2->next = elem1->next;
- elem2->prev = elem1;
- elem1->next = elem2;
- if (elem2->next) {
- elem2->next->prev = elem2;
- }
-}
-#endif
-
-#if 0 /* unused */
-/*
- * elemX, elem1 => elemX, elem2, elem1
- */
-static void
-INSERT_ELEM_PREV(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
-{
- elem2->prev = elem1->prev;
- elem2->next = elem1;
- elem1->prev = elem2;
- if (elem2->prev) {
- elem2->prev->next = elem2;
- }
-}
-#endif
-
-/*
- * elemX, elem1, elemY => elemX, elem2, elemY
- */
-static void
-REPLACE_ELEM(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
-{
- elem2->prev = elem1->prev;
- elem2->next = elem1->next;
- if (elem1->prev) {
- elem1->prev->next = elem2;
- }
- if (elem1->next) {
- elem1->next->prev = elem2;
- }
-}
-
-static void
-REMOVE_ELEM(LINK_ELEMENT *elem)
-{
- elem->prev->next = elem->next;
- if (elem->next) {
- elem->next->prev = elem->prev;
- }
-}
-
-static LINK_ELEMENT *
-FIRST_ELEMENT(LINK_ANCHOR *anchor)
-{
- return anchor->anchor.next;
-}
-
-#if 0 /* unused */
-static LINK_ELEMENT *
-LAST_ELEMENT(LINK_ANCHOR *anchor)
-{
- return anchor->last;
-}
-#endif
-
-static LINK_ELEMENT *
-POP_ELEMENT(LINK_ANCHOR *anchor)
-{
- LINK_ELEMENT *elem = anchor->last;
- anchor->last = anchor->last->prev;
- anchor->last->next = 0;
- verify_list("pop", anchor);
- return elem;
-}
-
-#if 0 /* unused */
-static LINK_ELEMENT *
-SHIFT_ELEMENT(LINK_ANCHOR *anchor)
-{
- LINK_ELEMENT *elem = anchor->anchor.next;
- if (elem) {
- anchor->anchor.next = elem->next;
- }
- return elem;
-}
-#endif
-
-#if 0 /* unused */
-static int
-LIST_SIZE(LINK_ANCHOR *anchor)
-{
- LINK_ELEMENT *elem = anchor->anchor.next;
- int size = 0;
- while (elem) {
- size += 1;
- elem = elem->next;
- }
- return size;
-}
-#endif
-
-static int
-LIST_SIZE_ZERO(LINK_ANCHOR *anchor)
-{
- if (anchor->anchor.next == 0) {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-/*
- * anc1: e1, e2, e3
- * anc2: e4, e5
- *#=>
- * anc1: e1, e2, e3, e4, e5
- * anc2: e4, e5 (broken)
- */
-static void
-APPEND_LIST(LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
-{
- if (anc2->anchor.next) {
- anc1->last->next = anc2->anchor.next;
- anc2->anchor.next->prev = anc1->last;
- anc1->last = anc2->last;
- }
- verify_list("append", anc1);
-}
-
-/*
- * anc1: e1, e2, e3
- * anc2: e4, e5
- *#=>
- * anc1: e4, e5, e1, e2, e3
- * anc2: e4, e5 (broken)
- */
-static void
-INSERT_LIST(LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
-{
- if (anc2->anchor.next) {
- LINK_ELEMENT *first = anc1->anchor.next;
- anc1->anchor.next = anc2->anchor.next;
- anc1->anchor.next->prev = &anc1->anchor;
- anc2->last->next = first;
- if (first) {
- first->prev = anc2->last;
- }
- else {
- anc1->last = anc2->last;
- }
- }
-
- verify_list("append", anc1);
-}
-
-#if 0 /* unused */
-/*
- * anc1: e1, e2, e3
- * anc2: e4, e5
- *#=>
- * anc1: e4, e5
- * anc2: e1, e2, e3
- */
-static void
-SWAP_LIST(LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
-{
- LINK_ANCHOR tmp = *anc2;
-
- /* it has bug */
- *anc2 = *anc1;
- *anc1 = tmp;
-
- verify_list("swap1", anc1);
- verify_list("swap2", anc2);
-}
-
-static LINK_ANCHOR *
-REVERSE_LIST(LINK_ANCHOR *anc)
-{
- LINK_ELEMENT *first, *last, *elem, *e;
- first = &anc->anchor;
- elem = first->next;
- last = anc->last;
-
- if (elem != 0) {
- anc->anchor.next = last;
- anc->last = elem;
- }
- else {
- /* null list */
- return anc;
- }
- while (elem) {
- e = elem->next;
- elem->next = elem->prev;
- elem->prev = e;
- elem = e;
- }
-
- first->next = last;
- last->prev = first;
- anc->last->next = 0;
-
- verify_list("reverse", anc);
- return anc;
-}
-#endif
-
-#if CPDEBUG > 0
-static void
-debug_list(LINK_ANCHOR *anchor)
-{
- LINK_ELEMENT *list = FIRST_ELEMENT(anchor);
- printf("----\n");
- printf("anch: %p, frst: %p, last: %p\n", &anchor->anchor,
- anchor->anchor.next, anchor->last);
- while (list) {
- printf("curr: %p, next: %p, prev: %p, type: %d\n", list, list->next,
- list->prev, FIX2INT(list->type));
- list = list->next;
- }
- printf("----\n");
-
- dump_disasm_list(anchor->anchor.next);
- verify_list("debug list", anchor);
-}
-#endif
-
-static LABEL *
-new_label_body(rb_iseq_t *iseq, int line)
-{
- LABEL *labelobj = compile_data_alloc_label(iseq);
- static int label_no = 0;
-
- labelobj->link.type = ISEQ_ELEMENT_LABEL;
- labelobj->link.next = 0;
-
- labelobj->label_no = label_no++;
- labelobj->sc_state = 0;
- labelobj->sp = -1;
- return labelobj;
-}
-
-static INSN *
-new_insn_core(rb_iseq_t *iseq, int line_no,
- int insn_id, int argc, VALUE *argv)
-{
- INSN *iobj = compile_data_alloc_insn(iseq);
-
- iobj->link.type = ISEQ_ELEMENT_INSN;
- iobj->link.next = 0;
- iobj->insn_id = insn_id;
- iobj->line_no = line_no;
- iobj->operands = argv;
- iobj->operand_size = argc;
- iobj->sc_state = 0;
- return iobj;
-}
-
-static INSN *
-new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...)
-{
- VALUE *operands = 0;
- va_list argv;
- if (argc > 0) {
- int i;
- va_init_list(argv, argc);
- operands = (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * argc);
- for (i = 0; i < argc; i++) {
- VALUE v = va_arg(argv, VALUE);
- operands[i] = v;
- }
- va_end(argv);
- }
- return new_insn_core(iseq, line_no, insn_id, argc, operands);
-}
-
-static INSN *
-new_insn_send(rb_iseq_t *iseq, int line_no,
- VALUE id, VALUE argc, VALUE block, VALUE flag)
-{
- INSN *iobj = 0;
- VALUE *operands =
- (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * 5);
- operands[0] = id;
- operands[1] = argc;
- operands[2] = block;
- operands[3] = flag;
- operands[4] = 0;
- iobj = new_insn_core(iseq, line_no, BIN(send), 5, operands);
- return iobj;
-}
-
-static VALUE
-new_child_iseq(rb_iseq_t *iseq, NODE *node,
- VALUE name, VALUE parent, VALUE type)
-{
- VALUE ret;
-
- debugs("[new_child_iseq]> ---------------------------------------\n");
- ret = rb_iseq_new_with_opt(node, name, iseq_filename(iseq->self),
- parent, type, iseq->compile_data->option);
- debugs("[new_child_iseq]< ---------------------------------------\n");
- iseq_add_mark_object(iseq, ret);
- return ret;
-}
-
-static int
-iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
-{
- /* debugs("[compile step 2] (iseq_array_to_linkedlist)\n"); */
-
- if (CPDEBUG > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
-
- debugs("[compile step 3.1 (iseq_optimize)]\n");
- iseq_optimize(iseq, anchor);
-
- if (CPDEBUG > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
-
- if (iseq->compile_data->option->instructions_unification) {
- debugs("[compile step 3.2 (iseq_insns_unification)]\n");
- iseq_insns_unification(iseq, anchor);
- if (CPDEBUG > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
- }
-
- if (iseq->compile_data->option->stack_caching) {
- debugs("[compile step 3.3 (iseq_set_sequence_stackcaching)]\n");
- iseq_set_sequence_stackcaching(iseq, anchor);
- if (CPDEBUG > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
- }
-
- debugs("[compile step 4.1 (iseq_set_sequence)]\n");
- iseq_set_sequence(iseq, anchor);
- if (CPDEBUG > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
-
- debugs("[compile step 4.2 (iseq_set_exception_table)]\n");
- iseq_set_exception_table(iseq);
-
- debugs("[compile step 4.3 (set_optargs_table)] \n");
- iseq_set_optargs_table(iseq);
-
- debugs("[compile step 5 (iseq_translate_threaded_code)] \n");
- iseq_translate_threaded_code(iseq);
-
- if (CPDEBUG > 1) {
- VALUE str = ruby_iseq_disasm(iseq->self);
- printf("%s\n", StringValueCStr(str));
- fflush(stdout);
- }
- debugs("[compile step: finish]\n");
-
- return 0;
-}
-
-static int
-iseq_set_exception_local_table(rb_iseq_t *iseq)
-{
- static ID id_dollar_bang;
-
- if (!id_dollar_bang) {
- id_dollar_bang = rb_intern("#$!");
- }
- iseq->local_table = (ID *)ALLOC_N(ID *, 1);
- iseq->local_table_size = iseq->local_size = 1;
- iseq->local_table[0] = id_dollar_bang;
- return COMPILE_OK;
-}
-
-static int
-get_dyna_var_idx_at_raw(rb_iseq_t *iseq, ID id)
-{
- int i;
-
- for (i = 0; i < iseq->local_table_size; i++) {
- if (iseq->local_table[i] == id) {
- return i;
- }
- }
- return -1;
-}
-
-static int
-get_local_var_idx(rb_iseq_t *iseq, ID id)
-{
- int idx = get_dyna_var_idx_at_raw(iseq->local_iseq, id);
-
- if (idx < 0) {
- rb_bug("get_local_var_idx: %d", idx);
- }
-
- return idx;
-}
-
-static int
-get_dyna_var_idx(rb_iseq_t *iseq, ID id, int *level, int *ls)
-{
- int lv = 0, idx = -1;
-
- while (iseq) {
- idx = get_dyna_var_idx_at_raw(iseq, id);
- if (idx >= 0) {
- break;
- }
- iseq = iseq->parent_iseq;
- lv++;
- }
-
- if (idx < 0) {
- rb_bug("get_dyna_var_idx: -1");
- }
-
- *level = lv;
- *ls = iseq->local_size;
- return idx;
-}
-
-static int
-iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
-{
- debugs("iseq_set_arguments: %s\n", node_args ? "" : "0");
-
- if (node_args) {
- NODE *node_aux = node_args->nd_next;
- NODE *node_opt = node_args->nd_opt;
- ID rest_id = 0;
- int last_comma = 0;
- ID block_id = 0;
- NODE *node_init = 0;
-
- if (nd_type(node_args) != NODE_ARGS) {
- rb_bug("iseq_set_arguments: NODE_ARGS is expected, but %s",
- ruby_node_name(nd_type(node_args)));
- }
-
- /*
- * new argument infromation:
- * NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
- * NODE_ARGS_AUX [r: ID, b: ID, ->]
- * NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
- * optarg information:
- * NODE_OPT_ARGS [idx, expr, next ->]
- * init arg:
- * NODE_AND(m_init, p_init)
- * if "r" is 1, it's means "{|x,|}" type block parameter.
- */
-
- iseq->argc = node_args->nd_frml;
- debugs(" - argc: %d\n", iseq->argc);
-
- if (node_aux) {
- rest_id = node_aux->nd_rest;
- if (rest_id == 1) {
- last_comma = 1;
- rest_id = 0;
- }
- block_id = (ID)node_aux->nd_body;
- node_aux = node_aux->nd_next;
-
- if (node_aux) {
- ID post_start_id = node_aux->nd_pid;
- iseq->arg_post_start = get_dyna_var_idx_at_raw(iseq, post_start_id);
- iseq->arg_post_len = node_aux->nd_plen;
- node_init = node_aux->nd_next;
- }
- }
-
- if (node_opt) {
- NODE *node = node_opt;
- LABEL *label;
- VALUE labels = rb_ary_new();
- int i = 0, j;
-
- while (node) {
- label = NEW_LABEL(nd_line(node));
- rb_ary_push(labels, (VALUE)label | 1);
- ADD_LABEL(optargs, label);
- COMPILE_POPED(optargs, "optarg", node->nd_body);
- node = node->nd_next;
- i += 1;
- }
-
- /* last label */
- label = NEW_LABEL(nd_line(node_args));
- rb_ary_push(labels, (VALUE)label | 1);
- ADD_LABEL(optargs, label);
- i += 1;
-
- iseq->arg_opts = i;
- iseq->arg_opt_table = ALLOC_N(VALUE, i);
- MEMCPY(iseq->arg_opt_table, RARRAY_PTR(labels), VALUE, i);
- for (j = 0; j < i; j++) {
- iseq->arg_opt_table[j] &= ~1;
- }
- }
- else {
- iseq->arg_opts = 0;
- }
-
- if (node_init) {
- if (node_init->nd_1st) { /* m_init */
- COMPILE_POPED(optargs, "init arguments (m)", node_init->nd_1st);
- }
- if (node_init->nd_2nd) { /* p_init */
- COMPILE_POPED(optargs, "init arguments (p)", node_init->nd_2nd);
- }
- }
-
- if (rest_id) {
- iseq->arg_rest = get_dyna_var_idx_at_raw(iseq, rest_id);
-
- if (iseq->arg_rest == -1) {
- rb_bug("arg_rest: -1");
- }
-
- if (iseq->arg_post_start == 0) {
- iseq->arg_post_start = iseq->arg_rest + 1;
- }
- }
-
- if (block_id) {
- iseq->arg_block = get_dyna_var_idx_at_raw(iseq, block_id);
- }
-
- if (iseq->arg_opts != 0 || iseq->arg_post_len != 0 ||
- iseq->arg_rest != -1 || iseq->arg_block != -1) {
- iseq->arg_simple = 0;
-
- /* set arg_size: size of arguments */
- if (iseq->arg_block != -1) {
- iseq->arg_size = iseq->arg_block + 1;
- }
- else if (iseq->arg_post_len) {
- iseq->arg_size = iseq->arg_post_start + iseq->arg_post_len;
- }
- else if (iseq->arg_rest != -1) {
- iseq->arg_size = iseq->arg_rest + 1;
- }
- else if (iseq->arg_opts) {
- iseq->arg_size = iseq->argc + iseq->arg_opts - 1;
- }
- else {
- iseq->arg_size = iseq->argc;
- }
- }
- else {
- iseq->arg_simple = 1;
- iseq->arg_size = iseq->argc;
- }
-
- if (iseq->type == ISEQ_TYPE_BLOCK) {
- if (iseq->arg_opts == 0 && iseq->arg_post_len == 0 && iseq->arg_rest == -1) {
- if (iseq->argc == 1 && last_comma == 0) {
- /* {|a|} */
- iseq->arg_simple |= 0x02;
- }
- }
- }
- }
- else {
- iseq->arg_simple = 1;
- }
-
- return COMPILE_OK;
-}
-
-static int
-iseq_set_local_table(rb_iseq_t *iseq, ID *tbl)
-{
- int size;
-
- if (tbl) {
- size = *tbl;
- tbl++;
- }
- else {
- size = 0;
- }
-
- if (size > 0) {
- iseq->local_table = (ID *)ALLOC_N(ID *, size);
- MEMCPY(iseq->local_table, tbl, ID *, size);
- }
-
- iseq->local_size = iseq->local_table_size = size;
-
- if (iseq->type == ISEQ_TYPE_METHOD ||
- iseq->type == ISEQ_TYPE_CLASS ||
- iseq->type == ISEQ_TYPE_TOP) {
- iseq->local_size += 1 /* svar */;
- }
-
- debugs("iseq_set_local_table: %d, %d\n", iseq->local_size, iseq->local_table_size);
- return COMPILE_OK;
-}
-
-/**
- ruby insn object array -> raw instruction sequence
- */
-static int
-iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
-{
- LABEL *lobj;
- INSN *iobj;
- struct iseq_insn_info_entry *insn_info_table;
- LINK_ELEMENT *list;
- VALUE *generated_iseq;
-
- int k, pos, sp, stack_max = 0, line = 0;
-
- /* set label position */
- list = FIRST_ELEMENT(anchor);
- k = pos = 0;
- while (list) {
- switch (list->type) {
- case ISEQ_ELEMENT_INSN:
- {
- iobj = (INSN *)list;
- pos += insn_data_length(iobj);
- line = iobj->line_no;
-
- k += 1;
- break;
- }
- case ISEQ_ELEMENT_LABEL:
- {
- lobj = (LABEL *)list;
- lobj->position = pos;
- lobj->set = Qtrue;
- break;
- }
- case ISEQ_ELEMENT_NONE:
- {
- /* ignore */
- break;
- }
- default:
- dump_disasm_list(FIRST_ELEMENT(anchor));
- dump_disasm_list(list);
- rb_compile_error(RSTRING_PTR(iseq->filename), line,
- "error: set_sequence");
- break;
- }
- list = list->next;
- }
-
- /* make instruction sequence */
- generated_iseq = ALLOC_N(VALUE, pos);
- insn_info_table = ALLOC_N(struct iseq_insn_info_entry, k);
-
- list = FIRST_ELEMENT(anchor);
- k = pos = sp = 0;
-
- while (list) {
- switch (list->type) {
- case ISEQ_ELEMENT_INSN:
- {
- int j, len, insn;
- char *types;
- VALUE *operands;
-
- iobj = (INSN *)list;
-
- if (iobj->insn_id == BIN(emptstack) && sp == 0) {
- iobj->insn_id = BIN(nop);
- }
- else {
- sp = calc_sp_depth(sp, iobj);
- if (sp > stack_max) {
- stack_max = sp;
- }
- }
-
- /* fprintf(stderr, "insn: %-16s, sp: %d\n", insn_name(iobj->insn_id), sp); */
-
- operands = iobj->operands;
- insn = iobj->insn_id;
- generated_iseq[pos] = insn;
- types = insn_op_types(insn);
- len = insn_len(insn);
-
- /* operand check */
- if (iobj->operand_size != len - 1) {
- dump_disasm_list(list);
- rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
- "operand size miss! (%d for %d)",
- iobj->operand_size, len - 1);
- return 0;
- }
-
- for (j = 0; types[j]; j++) {
- char type = types[j];
- /* printf("--> [%c - (%d-%d)]\n", type, k, j); */
- switch (type) {
- case TS_OFFSET:
- {
- /* label(destination position) */
- lobj = (LABEL *)operands[j];
- if (lobj->set != Qtrue) {
- rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
- "unknown label");
- }
- if (lobj->sp == -1) {
- lobj->sp = sp;
- }
- generated_iseq[pos + 1 + j] =
- lobj->position - (pos + len);
- break;
- }
- case TS_CDHASH:
- {
- /*
- * [obj, label, ...]
- */
- int i;
- VALUE lits = operands[j];
- VALUE map = rb_hash_new();
-
- for (i=0; i < RARRAY_LEN(lits); i+=2) {
- VALUE obj = rb_ary_entry(lits, i);
- VALUE lv = rb_ary_entry(lits, i+1);
- lobj = (LABEL *)(lv & ~1);
-
- if (lobj->set != Qtrue) {
- rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
- "unknown label");
- }
- rb_hash_aset(map, obj, INT2FIX(lobj->position - (pos+len)));
- }
- generated_iseq[pos + 1 + j] = map;
- iseq_add_mark_object(iseq, map);
- break;
- }
- case TS_LINDEX:
- case TS_DINDEX:
- case TS_NUM: /* ulong */
- generated_iseq[pos + 1 + j] = FIX2INT(operands[j]);
- break;
- case TS_ISEQ: /* iseq */
- {
- VALUE v = operands[j];
- rb_iseq_t *block = 0;
- if (v) {
- GetISeqPtr(v, block);
- }
- generated_iseq[pos + 1 + j] = (VALUE)block;
- break;
- }
- case TS_VALUE: /* VALUE */
- {
- VALUE v = operands[j];
- generated_iseq[pos + 1 + j] = v;
- /* to mark ruby object */
- iseq_add_mark_object(iseq, v);
- break;
- }
- case TS_IC: /* inline cache */
- {
- VALUE v = (VALUE)NEW_INLINE_CACHE_ENTRY();
- generated_iseq[pos + 1 + j] = v;
- iseq_add_mark_object(iseq, v);
- break;
- }
- case TS_ID: /* ID */
- generated_iseq[pos + 1 + j] = SYM2ID(operands[j]);
- break;
- case TS_GENTRY:
- {
- struct global_entry *entry =
- (struct global_entry *)(operands[j] & (~1));
- generated_iseq[pos + 1 + j] = (VALUE)entry;
- }
- break;
- default:
- rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
- "unknown operand type: %c", type);
- return 0;
- }
- }
- insn_info_table[k].line_no = iobj->line_no;
- insn_info_table[k].position = pos;
- insn_info_table[k].sp = sp;
- pos += len;
- k++;
- break;
- }
- case ISEQ_ELEMENT_LABEL:
- {
- lobj = (LABEL *)list;
- if (lobj->sp == -1) {
- lobj->sp = sp;
- }
- else {
- sp = lobj->sp;
- }
- break;
- }
- default:
- /* ignore */
- break;
- }
- list = list->next;
- }
-
-#if 0
- /* this check need dead code elimination */
- if (sp != 0) {
- rb_bug("SP is not 0 on %s (%d)\n", RSTRING_PTR(iseq->name), sp);
- }
-#endif
-
- iseq->iseq = (void *)generated_iseq;
- iseq->iseq_size = pos;
- iseq->insn_info_table = insn_info_table;
- iseq->insn_info_size = k;
- iseq->stack_max = stack_max;
-
- return COMPILE_OK;
-}
-
-static int
-label_get_position(LABEL *lobj)
-{
- return lobj->position;
-}
-
-static int
-label_get_sp(LABEL *lobj)
-{
- return lobj->sp;
-}
-
-static int
-iseq_set_exception_table(rb_iseq_t *iseq)
-{
- VALUE *tptr, *ptr;
- int tlen, i;
- struct iseq_catch_table_entry *entry;
-
- tlen = RARRAY_LEN(iseq->compile_data->catch_table_ary);
- tptr = RARRAY_PTR(iseq->compile_data->catch_table_ary);
-
- iseq->catch_table = ALLOC_N(struct iseq_catch_table_entry, tlen);
- iseq->catch_table_size = tlen;
-
- for (i = 0; i < tlen; i++) {
- ptr = RARRAY_PTR(tptr[i]);
- entry = &iseq->catch_table[i];
- entry->type = ptr[0] & 0xffff;
- entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
- entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
- entry->iseq = ptr[3];
-
- /* register iseq as mark object */
- if (entry->iseq != 0) {
- iseq_add_mark_object(iseq, entry->iseq);
- }
-
- /* stack depth */
- if (ptr[4]) {
- LABEL *lobj = (LABEL *)(ptr[4] & ~1);
- entry->cont = label_get_position(lobj);
- entry->sp = label_get_sp(lobj);
-
- /* TODO: Dirty Hack! Fix me */
- if (entry->type == CATCH_TYPE_RESCUE ||
- entry->type == CATCH_TYPE_BREAK ||
- (((ptr[0] & 0x10000) == 0)
- && entry->type == CATCH_TYPE_NEXT)) {
- entry->sp--;
- }
- }
- else {
- entry->cont = 0;
- }
- }
-
- iseq->compile_data->catch_table_ary = 0; /* free */
- return COMPILE_OK;
-}
-
-/*
- * set optional argument table
- * def foo(a, b=expr1, c=expr2)
- * =>
- * b:
- * expr1
- * c:
- * expr2
- */
-static int
-iseq_set_optargs_table(rb_iseq_t *iseq)
-{
- int i;
-
- if (iseq->arg_opts != 0) {
- for (i = 0; i < iseq->arg_opts; i++) {
- iseq->arg_opt_table[i] =
- label_get_position((LABEL *)iseq->arg_opt_table[i]);
- }
- }
- return COMPILE_OK;
-}
-
-static LINK_ELEMENT *
-get_destination_insn(INSN *iobj)
-{
- LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
- LINK_ELEMENT *list;
-
- list = lobj->link.next;
- while (list) {
- if (list->type == ISEQ_ELEMENT_INSN) {
- break;
- }
- list = list->next;
- }
- return list;
-}
-
-static LINK_ELEMENT *
-get_next_insn(INSN *iobj)
-{
- LINK_ELEMENT *list = iobj->link.next;
-
- while (list) {
- if (list->type == ISEQ_ELEMENT_INSN) {
- return list;
- }
- list = list->next;
- }
- return 0;
-}
-
-static LINK_ELEMENT *
-get_prev_insn(INSN *iobj)
-{
- LINK_ELEMENT *list = iobj->link.prev;
-
- while (list) {
- if (list->type == ISEQ_ELEMENT_INSN) {
- return list;
- }
- list = list->prev;
- }
- return 0;
-}
-
-static int
-iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcallopt)
-{
- INSN *iobj = (INSN *)list;
- again:
- if (iobj->insn_id == BIN(jump)) {
- INSN *niobj, *diobj, *piobj;
- /*
- * useless jump elimination:
- * jump LABEL1
- * ...
- * LABEL1:
- * jump LABEL2
- *
- * => in this case, first jump instruction should jump tp
- * LABEL2 directly
- */
- diobj = (INSN *)get_destination_insn(iobj);
- niobj = (INSN *)get_next_insn(iobj);
-
- if (diobj == niobj) {
- /*
- * jump LABEL
- * LABEL:
- * =>
- * LABEL:
- */
- REMOVE_ELEM(&iobj->link);
- }
- else if (iobj != diobj && diobj->insn_id == BIN(jump)) {
- if (OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {
- OPERAND_AT(iobj, 0) = OPERAND_AT(diobj, 0);
- goto again;
- }
- }
- else if (diobj->insn_id == BIN(leave)) {
- /*
- * jump LABEL
- * ...
- * LABEL:
- * leave
- * =>
- * leave
- * ...
- * LABEL:
- * leave
- */
- INSN *eiobj = new_insn_core(iseq, iobj->line_no, BIN(leave),
- diobj->operand_size,
- diobj->operands);
- /* replace */
- REPLACE_ELEM((LINK_ELEMENT *)iobj, (LINK_ELEMENT *)eiobj);
- iobj = eiobj;
- }
- /*
- * useless jump elimination (if/unless destination):
- * if L1
- * jump L2
- * L1:
- * ...
- * L2:
- *
- * ==>
- * unless L2
- * L1:
- * ...
- * L2:
- */
- else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&
- (piobj->insn_id == BIN(branchif) ||
- piobj->insn_id == BIN(branchunless))) {
- if (niobj == (INSN *)get_destination_insn(piobj)) {
- piobj->insn_id = (piobj->insn_id == BIN(branchif))
- ? BIN(branchunless) : BIN(branchif);
- OPERAND_AT(piobj, 0) = OPERAND_AT(iobj, 0);
- REMOVE_ELEM(&iobj->link);
- }
- }
- }
-
- if (iobj->insn_id == BIN(branchif) ||
- iobj->insn_id == BIN(branchunless)) {
- /*
- * if L1
- * ...
- * L1:
- * jump L2
- * =>
- * if L2
- */
- INSN *nobj = (INSN *)get_destination_insn(iobj);
- if (nobj->insn_id == BIN(jump)) {
- OPERAND_AT(iobj, 0) = OPERAND_AT(nobj, 0);
- }
- }
-
- if (do_tailcallopt && iobj->insn_id == BIN(leave)) {
- /*
- * send ...
- * leave
- * =>
- * send ..., ... | VM_CALL_TAILCALL_BIT, ...
- * leave # unreachable
- */
- INSN *piobj = (INSN *)get_prev_insn((INSN *)list);
-
- if (piobj->insn_id == BIN(send) &&
- piobj->operands[2] == 0 /* block */
- ) {
- piobj->operands[3] = INT2FIX(FIX2INT(piobj->operands[3]) | VM_CALL_TAILCALL_BIT);
- }
- }
- return COMPILE_OK;
-}
-
-static int
-insn_set_specialized_instruction(INSN *iobj, int insn_id)
-{
- iobj->insn_id = insn_id;
- iobj->operand_size = 0;
- return COMPILE_OK;
-}
-
-static int
-insn_set_specialized_instruction_with_ic(INSN *iobj, int insn_id, int n)
-{
- int i;
- iobj->insn_id = insn_id;
- iobj->operand_size = n;
-
- /* max of n is 4 */
- for (i=0; i<n; i++) {
- iobj->operands[i] = Qnil;
- }
-
- return COMPILE_OK;
-}
-
-
-static int
-iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
-{
- if (iobj->insn_id == BIN(send)) {
- ID mid = SYM2ID(OPERAND_AT(iobj, 0));
- int argc = FIX2INT(OPERAND_AT(iobj, 1));
- VALUE block = OPERAND_AT(iobj, 2);
- VALUE flag = OPERAND_AT(iobj, 3);
-
- /* TODO: should be more sophisticated search */
- if (block == 0 && flag == INT2FIX(0)) {
- if (argc == 0) {
- if (mid == idLength) {
- insn_set_specialized_instruction(iobj, BIN(opt_length));
- }
- else if (mid == idSucc) {
- insn_set_specialized_instruction(iobj, BIN(opt_succ));
- }
- else if (mid == idNot) {
- insn_set_specialized_instruction_with_ic(iobj, BIN(opt_not), 1);
- }
- }
- else if (argc == 1) {
- if (0) {
- }
- else if (mid == idPLUS) {
- insn_set_specialized_instruction(iobj, BIN(opt_plus));
- }
- else if (mid == idMINUS) {
- insn_set_specialized_instruction(iobj, BIN(opt_minus));
- }
- else if (mid == idMULT) {
- insn_set_specialized_instruction(iobj, BIN(opt_mult));
- }
- else if (mid == idDIV) {
- insn_set_specialized_instruction(iobj, BIN(opt_div));
- }
- else if (mid == idMOD) {
- insn_set_specialized_instruction(iobj, BIN(opt_mod));
- }
- else if (mid == idEq) {
- insn_set_specialized_instruction_with_ic(iobj, BIN(opt_eq), 1);
- }
- else if (mid == idNeq) {
- insn_set_specialized_instruction_with_ic(iobj, BIN(opt_neq), 2);
- }
- else if (mid == idLT) {
- insn_set_specialized_instruction(iobj, BIN(opt_lt));
- }
- else if (mid == idLE) {
- insn_set_specialized_instruction(iobj, BIN(opt_le));
- }
- else if (mid == idGT) {
- insn_set_specialized_instruction(iobj, BIN(opt_gt));
- }
- else if (mid == idGE) {
- insn_set_specialized_instruction(iobj, BIN(opt_ge));
- }
- else if (mid == idLTLT) {
- insn_set_specialized_instruction(iobj, BIN(opt_ltlt));
- }
- else if (mid == idAREF) {
- insn_set_specialized_instruction(iobj, BIN(opt_aref));
- }
- }
- }
-
- if (argc > 0) {
- if (mid == idSend || mid == id__send__ ) {
- OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BIT);
- }
- }
- }
- return COMPILE_OK;
-}
-
-static int
-iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
-{
- LINK_ELEMENT *list;
- const int do_peepholeopt = iseq->compile_data->option->peephole_optimization;
- const int do_tailcallopt = iseq->compile_data->option->tailcall_optimization;
- const int do_si = iseq->compile_data->option->specialized_instruction;
- const int do_ou = iseq->compile_data->option->operands_unification;
- list = FIRST_ELEMENT(anchor);
-
- while (list) {
- if (list->type == ISEQ_ELEMENT_INSN) {
- if (do_peepholeopt) {
- iseq_peephole_optimize(iseq, list, do_tailcallopt);
- }
- if (do_si) {
- iseq_specialized_instruction(iseq, (INSN *)list);
- }
- if (do_ou) {
- insn_operands_unification((INSN *)list);
- }
- }
- list = list->next;
- }
- return COMPILE_OK;
-}
-
-#if OPT_INSTRUCTIONS_UNIFICATION
-static INSN *
-new_unified_insn(rb_iseq_t *iseq,
- int insn_id, int size, LINK_ELEMENT *seq_list)
-{
- INSN *iobj = 0;
- LINK_ELEMENT *list = seq_list;
- int i, argc = 0;
- VALUE *operands = 0, *ptr = 0;
-
-
- /* count argc */
- for (i = 0; i < size; i++) {
- iobj = (INSN *)list;
- argc += iobj->operand_size;
- list = list->next;
- }
-
- if (argc > 0) {
- ptr = operands =
- (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * argc);
- }
-
- /* copy operands */
- list = seq_list;
- for (i = 0; i < size; i++) {
- iobj = (INSN *)list;
- MEMCPY(ptr, iobj->operands, VALUE, iobj->operand_size);
- ptr += iobj->operand_size;
- list = list->next;
- }
-
- return new_insn_core(iseq, iobj->line_no, insn_id, argc, operands);
-}
-#endif
-
-/*
- * This scheme can get more performance if do this optimize with
- * label address resolving.
- * It's future work (if compile time was bottle neck).
- */
-static int
-iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
-{
-#if OPT_INSTRUCTIONS_UNIFICATION
- LINK_ELEMENT *list;
- INSN *iobj, *niobj;
- int id, j, k;
-
- list = FIRST_ELEMENT(anchor);
- while (list) {
- if (list->type == ISEQ_ELEMENT_INSN) {
- iobj = (INSN *)list;
- id = iobj->insn_id;
- if (unified_insns_data[id] != 0) {
- int **entry = unified_insns_data[id];
- for (j = 1; j < (int)entry[0]; j++) {
- int *unified = entry[j];
- LINK_ELEMENT *li = list->next;
- for (k = 2; k < unified[1]; k++) {
- if (li->type != ISEQ_ELEMENT_INSN ||
- ((INSN *)li)->insn_id != unified[k]) {
- goto miss;
- }
- li = li->next;
- }
- /* matched */
- niobj =
- new_unified_insn(iseq, unified[0], unified[1] - 1,
- list);
-
- /* insert to list */
- niobj->link.prev = (LINK_ELEMENT *)iobj->link.prev;
- niobj->link.next = li;
- if (li) {
- li->prev = (LINK_ELEMENT *)niobj;
- }
-
- list->prev->next = (LINK_ELEMENT *)niobj;
- list = (LINK_ELEMENT *)niobj;
- break;
- miss:;
- }
- }
- }
- list = list->next;
- }
-#endif
- return COMPILE_OK;
-}
-
-#if OPT_STACK_CACHING
-
-#define SC_INSN(insn, stat) sc_insn_info[(insn)][(stat)]
-#define SC_NEXT(insn) sc_insn_next[insn]
-
-#include "opt_sc.inc"
-
-static int
-insn_set_sc_state(rb_iseq_t *iseq, INSN *iobj, int state)
-{
- int nstate;
- int insn_id;
-
- insn_id = iobj->insn_id;
- iobj->insn_id = SC_INSN(insn_id, state);
- nstate = SC_NEXT(iobj->insn_id);
-
- if (insn_id == BIN(jump) ||
- insn_id == BIN(branchif) || insn_id == BIN(branchunless)) {
- LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
-
- if (lobj->sc_state != 0) {
- if (lobj->sc_state != nstate) {
- dump_disasm_list((LINK_ELEMENT *)iobj);
- dump_disasm_list((LINK_ELEMENT *)lobj);
- printf("\n-- %d, %d\n", lobj->sc_state, nstate);
- rb_compile_error(RSTRING_PTR(iseq->filename), iobj->lineno,
- "insn_set_sc_state error\n");
- return 0;
- }
- }
- else {
- lobj->sc_state = nstate;
- }
- if (insn_id == BIN(jump)) {
- nstate = SCS_XX;
- }
- }
- else if (insn_id == BIN(leave)) {
- nstate = SCS_XX;
- }
-
- return nstate;
-}
-
-static int
-label_set_sc_state(LABEL *lobj, int state)
-{
- if (lobj->sc_state != 0) {
- if (lobj->sc_state != state) {
- state = lobj->sc_state;
- }
- }
- else {
- lobj->sc_state = state;
- }
-
- return state;
-}
-
-
-#endif
-
-static int
-iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
-{
-#if OPT_STACK_CACHING
- LINK_ELEMENT *list;
- int state, insn_id;
-
- /* initialize */
- state = SCS_XX;
- list = FIRST_ELEMENT(anchor);
- /* dump_disasm_list(list); */
-
- /* for each list element */
- while (list) {
- redo_point:
- switch (list->type) {
- case ISEQ_ELEMENT_INSN:
- {
- INSN *iobj = (INSN *)list;
- insn_id = iobj->insn_id;
-
- /* dump_disasm_list(list); */
-
- switch (insn_id) {
- case BIN(nop):
- {
- /* exception merge point */
- if (state != SCS_AX) {
- INSN *rpobj =
- new_insn_body(iseq, 0, BIN(reput), 0);
-
- /* replace this insn */
- REPLACE_ELEM(list, (LINK_ELEMENT *)rpobj);
- list = (LINK_ELEMENT *)rpobj;
- goto redo_point;
- }
- break;
- }
- case BIN(swap):
- {
- if (state == SCS_AB || state == SCS_BA) {
- state = (state == SCS_AB ? SCS_BA : SCS_AB);
-
- REMOVE_ELEM(list);
- list = list->next;
- goto redo_point;
- }
- break;
- }
- case BIN(pop):
- {
- switch (state) {
- case SCS_AX:
- case SCS_BX:
- state = SCS_XX;
- break;
- case SCS_AB:
- state = SCS_AX;
- break;
- case SCS_BA:
- state = SCS_BX;
- break;
- case SCS_XX:
- goto normal_insn;
- default:
- rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
- "unreachable");
- }
- /* remove useless pop */
- REMOVE_ELEM(list);
- list = list->next;
- goto redo_point;
- }
- default:;
- /* none */
- } /* end of switch */
- normal_insn:
- state = insn_set_sc_state(iseq, iobj, state);
- break;
- }
- case ISEQ_ELEMENT_LABEL:
- {
- LABEL *lobj;
- lobj = (LABEL *)list;
-
- state = label_set_sc_state(lobj, state);
- }
- default:
- break;
- }
- list = list->next;
- }
-#endif
- return COMPILE_OK;
-}
-
-
-
-static int
-compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node)
-{
- NODE *list = node->nd_next;
- VALUE lit = node->nd_lit;
- int cnt = 1;
-
- debugp_param("nd_lit", lit);
- ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
-
- while (list) {
- COMPILE(ret, "each string", list->nd_head);
- cnt++;
- list = list->nd_next;
- }
-
- ADD_INSN1(ret, nd_line(node), concatstrings, INT2FIX(cnt));
- return COMPILE_OK;
-}
-
-static int
-compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond,
- LABEL *then_label, LABEL *else_label)
-{
- switch (nd_type(cond)) {
- case NODE_AND:
- {
- LABEL *label = NEW_LABEL(nd_line(cond));
- compile_branch_condition(iseq, ret, cond->nd_1st, label,
- else_label);
- ADD_LABEL(ret, label);
- compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
- else_label);
- break;
- }
- case NODE_OR:
- {
- LABEL *label = NEW_LABEL(nd_line(cond));
- compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
- label);
- ADD_LABEL(ret, label);
- compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
- else_label);
- break;
- }
- case NODE_LIT: /* NODE_LIT is always not true */
- case NODE_TRUE:
- case NODE_STR:
- /* printf("useless conditon eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
- ADD_INSNL(ret, nd_line(cond), jump, then_label);
- break;
- case NODE_FALSE:
- case NODE_NIL:
- /* printf("useless conditon eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
- ADD_INSNL(ret, nd_line(cond), jump, else_label);
- break;
- default:
- COMPILE(ret, "branch condition", cond);
- ADD_INSNL(ret, nd_line(cond), branchunless, else_label);
- ADD_INSNL(ret, nd_line(cond), jump, then_label);
- break;
- }
- return COMPILE_OK;
-}
-
-static int
-compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
- VALUE opt_p, int poped)
-{
- NODE *node = node_root;
- int len = node->nd_alen, line = nd_line(node), i=0;
- DECL_ANCHOR(anchor);
-
- INIT_ANCHOR(anchor);
- if (nd_type(node) != NODE_ZARRAY) {
- while (node) {
- if (nd_type(node) != NODE_ARRAY) {
- rb_bug("compile_array: This node is not NODE_ARRAY, but %s",
- ruby_node_name(nd_type(node)));
- }
-
- i++;
- if (opt_p && nd_type(node->nd_head) != NODE_LIT) {
- opt_p = Qfalse;
- }
- COMPILE_(anchor, "array element", node->nd_head, poped);
- node = node->nd_next;
- }
- }
-
- if (len != i) {
- if (0) {
- rb_bug("node error: compile_array (%d: %d-%d)",
- (int)nd_line(node_root), len, i);
- }
- len = i;
- }
-
- if (opt_p == Qtrue) {
- if (!poped) {
- VALUE ary = rb_ary_new();
- node = node_root;
- while (node) {
- rb_ary_push(ary, node->nd_head->nd_lit);
- node = node->nd_next;
- }
-
- iseq_add_mark_object_compile_time(iseq, ary);
- ADD_INSN1(ret, nd_line(node_root), duparray, ary);
- }
- }
- else {
- if (!poped) {
- ADD_INSN1(anchor, line, newarray, INT2FIX(len));
- }
- APPEND_LIST(ret, anchor);
- }
- return len;
-}
-
-static VALUE
-compile_array(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root, VALUE opt_p)
-{
- return compile_array_(iseq, ret, node_root, opt_p, 0);
-}
-
-static VALUE
-case_when_optimizable_literal(NODE * node)
-{
- switch (nd_type(node)) {
- case NODE_LIT: {
- VALUE v = node->nd_lit;
- if (SYMBOL_P(v) || rb_obj_is_kind_of(v, rb_cNumeric)) {
- return v;
- }
- break;
- }
- case NODE_STR:
- return node->nd_lit;
- }
- return Qfalse;
-}
-
-static VALUE
-when_vals(rb_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, VALUE special_literals)
-{
- while (vals) {
- VALUE lit;
- NODE* val;
-
- val = vals->nd_head;
-
- if (special_literals &&
- (lit = case_when_optimizable_literal(val)) != Qfalse) {
- rb_ary_push(special_literals, lit);
- rb_ary_push(special_literals, (VALUE)(l1) | 1);
- }
- else {
- special_literals = Qfalse;
- }
-
- COMPILE(cond_seq, "when cond", val);
- ADD_INSN1(cond_seq, nd_line(val), topn, INT2FIX(1));
- ADD_SEND(cond_seq, nd_line(val), ID2SYM(idEqq), INT2FIX(1));
- ADD_INSNL(cond_seq, nd_line(val), branchif, l1);
- vals = vals->nd_next;
- }
- return special_literals;
-}
-
-static int
-compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node)
-{
- switch (nd_type(node)) {
- case NODE_ATTRASGN: {
- INSN *iobj;
- VALUE dupidx;
-
- COMPILE_POPED(ret, "masgn lhs (NODE_ATTRASGN)", node);
- POP_ELEMENT(ret); /* pop pop insn */
- iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */
-
- dupidx = iobj->operands[1];
- dupidx = INT2FIX(FIX2INT(dupidx) + 1);
- iobj->operands[1] = dupidx;
-
- ADD_INSN1(ret, nd_line(node), topn, dupidx);
- ADD_ELEM(ret, (LINK_ELEMENT *)iobj);
- ADD_INSN(ret, nd_line(node), pop); /* result */
- ADD_INSN(ret, nd_line(node), pop); /* rhs */
- break;
- }
- case NODE_MASGN: {
- DECL_ANCHOR(anchor);
- INIT_ANCHOR(anchor);
- COMPILE_POPED(anchor, "nest masgn lhs", node);
- REMOVE_ELEM(FIRST_ELEMENT(anchor));
- ADD_SEQ(ret, anchor);
- break;
- }
- default: {
- DECL_ANCHOR(anchor);
- INIT_ANCHOR(anchor);
- COMPILE_POPED(anchor, "masgn lhs", node);
- REMOVE_ELEM(FIRST_ELEMENT(anchor));
- ADD_SEQ(ret, anchor);
- }
- }
-
- return COMPILE_OK;
-}
-
-static void
-compile_massign_opt_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *lhsn)
-{
- if (lhsn) {
- compile_massign_opt_lhs(iseq, ret, lhsn->nd_next);
- compile_massign_lhs(iseq, ret, lhsn->nd_head);
- }
-}
-
-static int
-compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *ret,
- NODE *rhsn, NODE *orig_lhsn)
-{
- int memsize = 64;
- int memindex = 0;
- VALUE *mem = ALLOCA_N(VALUE, memsize);
- int llen = 0, rlen = 0;
- int i;
- NODE *lhsn = orig_lhsn;
-
-#define MEMORY(v) { \
- int i; \
- if (memindex == memsize) return 0; \
- for (i=0; i<memindex; i++) { \
- if (mem[i] == (v)) return 0; \
- } \
- mem[memindex++] = (v); \
-}
-
- if (rhsn == 0 || nd_type(rhsn) != NODE_ARRAY) {
- return 0;
- }
-
- while (lhsn) {
- NODE *ln = lhsn->nd_head;
- switch (nd_type(ln)) {
- case NODE_LASGN:
- MEMORY(ln->nd_vid);
- break;
- case NODE_DASGN:
- case NODE_DASGN_CURR:
- case NODE_IASGN:
- case NODE_IASGN2:
- case NODE_CVASGN:
- MEMORY(ln->nd_vid);
- break;
- default:
- return 0;
- }
- lhsn = lhsn->nd_next;
- llen++;
- }
-
- while (rhsn) {
- if (llen <= rlen) {
- COMPILE_POPED(ret, "masgn val (poped)", rhsn->nd_head);
- }
- else {
- COMPILE(ret, "masgn val", rhsn->nd_head);
- }
- rhsn = rhsn->nd_next;
- rlen++;
- }
-
- if (llen > rlen) {
- for (i=0; i<llen-rlen; i++) {
- ADD_INSN(ret, nd_line(orig_lhsn), putnil);
- }
- }
-
- compile_massign_opt_lhs(iseq, ret, orig_lhsn);
- return 1;
-}
-
-static int
-compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node, int poped)
-{
- NODE *rhsn = node->nd_value;
- NODE *splatn = node->nd_args;
- NODE *lhsn = node->nd_head;
- int lhs_splat = (splatn && (VALUE)splatn != (VALUE)-1) ? 1 : 0;
-
- if (!poped || splatn || !compile_massign_opt(iseq, ret, rhsn, lhsn)) {
- int llen = 0;
- DECL_ANCHOR(lhsseq);
-
- INIT_ANCHOR(lhsseq);
-
- while (lhsn) {
- compile_massign_lhs(iseq, lhsseq, lhsn->nd_head);
- llen += 1;
- lhsn = lhsn->nd_next;
- }
-
- COMPILE(ret, "normal masgn rhs", rhsn);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
-
- ADD_INSN2(ret, nd_line(node), expandarray,
- INT2FIX(llen), INT2FIX(lhs_splat));
- ADD_SEQ(ret, lhsseq);
-
- if (lhs_splat) {
- if (nd_type(splatn) == NODE_POSTARG) {
- /*a, b, *r, p1, p2 */
- NODE *postn = splatn->nd_2nd;
- NODE *restn = splatn->nd_1st;
- int num = postn->nd_alen;
- int flag = 0x02 | (((VALUE)restn == (VALUE)-1) ? 0x00 : 0x01);
-
- ADD_INSN2(ret, nd_line(splatn), expandarray,
- INT2FIX(num), INT2FIX(flag));
-
- if ((VALUE)restn != (VALUE)-1) {
- compile_massign_lhs(iseq, ret, restn);
- }
- while (postn) {
- compile_massign_lhs(iseq, ret, postn->nd_head);
- postn = postn->nd_next;
- }
- }
- else {
- /* a, b, *r */
- compile_massign_lhs(iseq, ret, splatn);
- }
- }
- }
- return COMPILE_OK;
-}
-
-static int
-compile_colon2(rb_iseq_t *iseq, NODE * node,
- LINK_ANCHOR *pref, LINK_ANCHOR *body)
-{
- switch (nd_type(node)) {
- case NODE_CONST:
- debugi("compile_colon2 - colon", node->nd_vid);
- ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_vid));
- break;
- case NODE_COLON3:
- debugi("compile_colon2 - colon3", node->nd_mid);
- ADD_INSN(body, nd_line(node), pop);
- ADD_INSN1(body, nd_line(node), putobject, rb_cObject);
- ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
- break;
- case NODE_COLON2:
- compile_colon2(iseq, node->nd_head, pref, body);
- debugi("compile_colon2 - colon2", node->nd_mid);
- ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
- break;
- default:
- COMPILE(pref, "const colon2 prefix", node);
- break;
- }
- return COMPILE_OK;
-}
-
-static int
-compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
-{
- if (cpath->nd_head) {
- COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
- }
- else if (nd_type(cpath) == NODE_COLON2) {
- COMPILE(ret, "cpath (NODE_COLON2)", cpath->nd_head);
- }
- else {
- ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
- }
- return COMPILE_OK;
-}
-
-static int
-defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
- NODE * node, LABEL *lfinish, VALUE needstr)
-{
- char *estr = 0;
- enum node_type type;
-
- switch (type = nd_type(node)) {
-
- /* easy literals */
- case NODE_NIL:
- estr = "nil";
- break;
- case NODE_SELF:
- estr = "self";
- break;
- case NODE_TRUE:
- estr = "true";
- break;
- case NODE_FALSE:
- estr = "false";
- break;
-
- case NODE_ARRAY:{
- LABEL *lfalse = NULL;
- NODE *vals = node;
-
- do {
- defined_expr(iseq, ret, vals->nd_head, lfinish, Qfalse);
-
- if (lfalse) {
- ADD_INSNL(ret, nd_line(node), branchunless, lfalse);
- }
- else {
- LABEL *lcont = NEW_LABEL(nd_line(node));
- lfalse = NEW_LABEL(nd_line(node));
- ADD_INSNL(ret, nd_line(node), branchif, lcont);
- ADD_LABEL(ret, lfalse);
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSNL(ret, nd_line(node), jump, lfinish);
- ADD_LABEL(ret, lcont);
- }
- } while ((vals = vals->nd_next) != NULL);
- }
- case NODE_STR:
- case NODE_LIT:
- case NODE_ZARRAY:
- estr = "expression";
- break;
-
- /* variables */
- case NODE_LVAR:
- case NODE_DVAR:
- estr = "local-variable";
- break;
-
- case NODE_IVAR:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_IVAR),
- ID2SYM(node->nd_vid), needstr);
- return 1;
-
- case NODE_GVAR:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_GVAR),
- ((VALUE)node->nd_entry) | 1, needstr);
- return 1;
-
- case NODE_CVAR:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CVAR),
- ID2SYM(node->nd_vid), needstr);
- return 1;
-
- case NODE_CONST:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CONST),
- ID2SYM(node->nd_vid), needstr);
- return 1;
- case NODE_COLON2:
- if (rb_is_const_id(node->nd_mid)) {
- LABEL *lcont = NEW_LABEL(nd_line(node));
- defined_expr(iseq, ret, node->nd_head, lfinish, Qfalse);
-
- ADD_INSNL(ret, nd_line(node), branchif, lcont);
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSNL(ret, nd_line(node), jump, lfinish);
-
- ADD_LABEL(ret, lcont);
- COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CONST),
- ID2SYM(node->nd_mid), needstr);
- }
- else {
- LABEL *lcont = NEW_LABEL(nd_line(node));
- defined_expr(iseq, ret, node->nd_head, lfinish, Qfalse);
-
- ADD_INSNL(ret, nd_line(node), branchif, lcont);
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSNL(ret, nd_line(node), jump, lfinish);
-
- ADD_LABEL(ret, lcont);
- COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_METHOD),
- ID2SYM(node->nd_mid), needstr);
- }
- return 1;
- case NODE_COLON3:
- ADD_INSN1(ret, nd_line(node), putobject, rb_cObject);
- ADD_INSN3(ret, nd_line(node), defined,
- INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr);
- return 1;
-
- /* method dispatch */
- case NODE_CALL:
- case NODE_VCALL:
- case NODE_FCALL:
- case NODE_ATTRASGN:{
- LABEL *lfalse = NULL;
- int self = Qtrue;
-
- switch (type) {
- case NODE_ATTRASGN:
- if (node->nd_recv == (NODE *)1) break;
- case NODE_CALL:
- self = Qfalse;
- break;
- default:
- /* through */;
- }
- if (node->nd_args) {
- lfalse = NEW_LABEL(nd_line(node));
- defined_expr(iseq, ret, node->nd_args, lfinish, Qfalse);
- ADD_INSNL(ret, nd_line(node), branchunless, lfalse);
- }
- if (!self) {
- LABEL *lcont = NEW_LABEL(nd_line(node));
-
- defined_expr(iseq, ret, node->nd_recv, lfinish, Qfalse);
- ADD_INSNL(ret, nd_line(node), branchif, lcont);
- if (lfalse) {
- ADD_LABEL(ret, lfalse);
- }
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSNL(ret, nd_line(node), jump, lfinish);
-
- ADD_LABEL(ret, lcont);
- COMPILE(ret, "defined/recv", node->nd_recv);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_METHOD),
- ID2SYM(node->nd_mid), needstr);
- }
- else {
- ADD_INSN(ret, nd_line(node), putself);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_FUNC),
- ID2SYM(node->nd_mid), needstr);
- ADD_INSNL(ret, nd_line(node), jump, lfinish);
- if (lfalse) {
- ADD_LABEL(ret, lfalse);
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSNL(ret, nd_line(node), jump, lfinish);
- }
- }
- return 1;
- }
-
- case NODE_YIELD:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_YIELD), 0,
- needstr);
- return 1;
-
- case NODE_BACK_REF:
- case NODE_NTH_REF:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_REF),
- INT2FIX(node->nd_nth << 1 | type == NODE_BACK_REF),
- needstr);
- return 1;
-
- case NODE_ZSUPER:
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_ZSUPER), 0,
- needstr);
- return 1;
-
- case NODE_OP_ASGN1:
- case NODE_OP_ASGN2:
- case NODE_MASGN:
- case NODE_LASGN:
- case NODE_DASGN:
- case NODE_DASGN_CURR:
- case NODE_GASGN:
- case NODE_IASGN:
- case NODE_CDECL:
- case NODE_CVDECL:
- case NODE_CVASGN:
- estr = "assignment";
- break;
-
- default:{
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
- LABEL *ldefed = NEW_LABEL(nd_line(node));
- VALUE ensure = NEW_CHILD_ISEQVAL(NEW_NIL(),
- rb_str_concat(rb_str_new2
- ("defined guard in "),
- iseq->name),
- ISEQ_TYPE_DEFINED_GUARD);
-
- ADD_LABEL(ret, lstart);
- COMPILE(ret, "defined expr (others)", node);
- ADD_INSNL(ret, nd_line(node), branchif, ldefed);
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSNL(ret, nd_line(node), jump, lend);
- ADD_LABEL(ret, ldefed);
- if (needstr) {
- ADD_INSN1(ret, nd_line(node), putstring, rb_str_new2("expression"));
- }
- else {
- ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
- }
- ADD_LABEL(ret, lend);
-
- ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, lstart, lend, ensure, lfinish);
- return 1;
- } /* end of default */
- }
-
- if (estr != 0) {
- if (needstr != Qfalse) {
- VALUE str = rb_str_new2(estr);
- ADD_INSN1(ret, nd_line(node), putstring, str);
- iseq_add_mark_object_compile_time(iseq, str);
- }
- else {
- ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
- }
- return 1;
- }
- return 0;
-}
-
-#define BUFSIZE 0x100
-
-static VALUE
-make_name_for_block(rb_iseq_t *iseq)
-{
- if (iseq->parent_iseq == 0) {
- return rb_sprintf("block in %s", RSTRING_PTR(iseq->name));
- }
- else {
- int level = 1;
- rb_iseq_t *ip = iseq;
- while (ip->local_iseq != ip) {
- ip = ip->parent_iseq;
- level++;
- }
- return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->name));
- }
-}
-
-static void
-add_ensure_range(rb_iseq_t *iseq, struct ensure_range *erange,
- LABEL *lstart, LABEL *lend)
-{
- struct ensure_range *ne =
- compile_data_alloc(iseq, sizeof(struct ensure_range));
-
- while (erange->next != 0) {
- erange = erange->next;
- }
- ne->next = 0;
- ne->begin = lend;
- ne->end = erange->end;
- erange->end = lstart;
-
- erange->next = ne;
-}
-
-static void
-add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq)
-{
- struct iseq_compile_data_ensure_node_stack *enlp =
- iseq->compile_data->ensure_node_stack;
- struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp;
- DECL_ANCHOR(ensure);
-
- INIT_ANCHOR(ensure);
- while (enlp) {
- DECL_ANCHOR(ensure_part);
- LABEL *lstart = NEW_LABEL(0);
- LABEL *lend = NEW_LABEL(0);
-
- INIT_ANCHOR(ensure_part);
- add_ensure_range(iseq, enlp->erange, lstart, lend);
-
- iseq->compile_data->ensure_node_stack = enlp->prev;
- ADD_LABEL(ensure_part, lstart);
- COMPILE_POPED(ensure_part, "ensure part", enlp->ensure_node);
- ADD_LABEL(ensure_part, lend);
-
- ADD_SEQ(ensure, ensure_part);
- enlp = enlp->prev;
- }
- iseq->compile_data->ensure_node_stack = prev_enlp;
- ADD_SEQ(ret, ensure);
-}
-
-static VALUE
-setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned long *flag)
-{
- VALUE argc = INT2FIX(0);
- int nsplat = 0;
- DECL_ANCHOR(arg_block);
- DECL_ANCHOR(args_splat);
-
- INIT_ANCHOR(arg_block);
- INIT_ANCHOR(args_splat);
- if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
- COMPILE(arg_block, "block", argn->nd_body);
- *flag |= VM_CALL_ARGS_BLOCKARG_BIT;
- argn = argn->nd_head;
- }
-
- setup_argn:
- if (argn) {
- switch (nd_type(argn)) {
- case NODE_SPLAT: {
- COMPILE(args, "args (splat)", argn->nd_head);
- argc = INT2FIX(1);
- nsplat++;
- *flag |= VM_CALL_ARGS_SPLAT_BIT;
- break;
- }
- case NODE_ARGSCAT:
- case NODE_ARGSPUSH: {
- int next_is_array = (nd_type(argn->nd_head) == NODE_ARRAY);
- DECL_ANCHOR(tmp);
-
- INIT_ANCHOR(tmp);
- COMPILE(tmp, "args (cat: splat)", argn->nd_body);
- if (next_is_array && nsplat == 0) {
- /* none */
- }
- else {
- if (nd_type(argn) == NODE_ARGSCAT) {
- ADD_INSN1(tmp, nd_line(argn), splatarray, Qfalse);
- }
- else {
- ADD_INSN1(tmp, nd_line(argn), newarray, INT2FIX(1));
- }
- }
- INSERT_LIST(args_splat, tmp);
- nsplat++;
- *flag |= VM_CALL_ARGS_SPLAT_BIT;
-
- if (next_is_array) {
- argc = INT2FIX(compile_array(iseq, args, argn->nd_head, Qfalse) + 1);
- POP_ELEMENT(args);
- }
- else {
- argn = argn->nd_head;
- goto setup_argn;
- }
- break;
- }
- case NODE_ARRAY: {
- argc = INT2FIX(compile_array(iseq, args, argn, Qfalse));
- POP_ELEMENT(args);
- break;
- }
- default: {
- rb_bug("setup_arg: unknown node: %s\n", ruby_node_name(nd_type(argn)));
- }
- }
- }
-
- if (nsplat > 1) {
- int i;
- for (i=1; i<nsplat; i++) {
- ADD_INSN(args_splat, nd_line(args), concatarray);
- }
- }
-
- if (!LIST_SIZE_ZERO(args_splat)) {
- ADD_SEQ(args, args_splat);
- }
-
- if (*flag & VM_CALL_ARGS_BLOCKARG_BIT) {
- ADD_SEQ(args, arg_block);
- }
- return argc;
-}
-
-
-/**
- compile each node
-
- self: InstructionSequence
- node: Ruby compiled node
- poped: This node will be poped
- */
-static int
-iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
-{
- enum node_type type;
-
- if (node == 0) {
- if (!poped) {
- debugs("node: NODE_NIL(implicit)\n");
- ADD_INSN(ret, iseq->compile_data->last_line, putnil);
- }
- return COMPILE_OK;
- }
-
- iseq->compile_data->last_line = nd_line(node);
- debug_node_start(node);
-
- type = nd_type(node);
-
- if (node->flags & NODE_NEWLINE) {
- ADD_TRACE(ret, nd_line(node), RUBY_EVENT_LINE);
- }
-
- switch (type) {
- case NODE_BLOCK:{
- while (node && nd_type(node) == NODE_BLOCK) {
- COMPILE_(ret, "BLOCK body", node->nd_head,
- (node->nd_next == 0 && poped == 0) ? 0 : 1);
- node = node->nd_next;
- }
- if (node) {
- COMPILE_(ret, "BLOCK next", node->nd_next, poped);
- }
- break;
- }
- case NODE_IF:{
- DECL_ANCHOR(cond_seq);
- DECL_ANCHOR(then_seq);
- DECL_ANCHOR(else_seq);
- LABEL *then_label, *else_label, *end_label;
-
- INIT_ANCHOR(cond_seq);
- INIT_ANCHOR(then_seq);
- INIT_ANCHOR(else_seq);
- then_label = NEW_LABEL(nd_line(node));
- else_label = NEW_LABEL(nd_line(node));
- end_label = NEW_LABEL(nd_line(node));
-
- compile_branch_condition(iseq, cond_seq, node->nd_cond,
- then_label, else_label);
- COMPILE_(then_seq, "then", node->nd_body, poped);
- COMPILE_(else_seq, "else", node->nd_else, poped);
-
- ADD_SEQ(ret, cond_seq);
-
- ADD_LABEL(ret, then_label);
- ADD_SEQ(ret, then_seq);
- ADD_INSNL(ret, nd_line(node), jump, end_label);
-
- ADD_LABEL(ret, else_label);
- ADD_SEQ(ret, else_seq);
-
- ADD_LABEL(ret, end_label);
-
- break;
- }
- case NODE_CASE:{
- NODE *vals;
- NODE *tempnode = node;
- LABEL *endlabel, *elselabel;
- DECL_ANCHOR(head);
- DECL_ANCHOR(body_seq);
- DECL_ANCHOR(cond_seq);
- VALUE special_literals = rb_ary_new();
-
- INIT_ANCHOR(head);
- INIT_ANCHOR(body_seq);
- INIT_ANCHOR(cond_seq);
- if (node->nd_head == 0) {
- COMPILE_(ret, "when", node->nd_body, poped);
- break;
- }
- COMPILE(head, "case base", node->nd_head);
-
- node = node->nd_body;
- type = nd_type(node);
-
- if (type != NODE_WHEN) {
- COMPILE_ERROR((ERROR_ARGS "NODE_CASE: unexpected node. must be NODE_WHEN, but %s", ruby_node_name(type)));
- }
-
- endlabel = NEW_LABEL(nd_line(node));
- elselabel = NEW_LABEL(nd_line(node));
-
- ADD_SEQ(ret, head); /* case VAL */
-
- while (type == NODE_WHEN) {
- LABEL *l1;
-
- l1 = NEW_LABEL(nd_line(node));
- ADD_LABEL(body_seq, l1);
- ADD_INSN(body_seq, nd_line(node), pop);
- COMPILE_(body_seq, "when body", node->nd_body, poped);
- ADD_INSNL(body_seq, nd_line(node), jump, endlabel);
-
- vals = node->nd_head;
- if (vals) {
- if (nd_type(vals) == NODE_ARRAY) {
- special_literals = when_vals(iseq, cond_seq, vals, l1, special_literals);
- }
- else if (nd_type(vals) == NODE_SPLAT ||
- nd_type(vals) == NODE_ARGSCAT ||
- nd_type(vals) == NODE_ARGSPUSH) {
- NODE *val = vals->nd_head;
- special_literals = 0;
-
- if (nd_type(vals) == NODE_ARGSCAT ||
- nd_type(vals) == NODE_ARGSPUSH) {
- when_vals(iseq, cond_seq, vals->nd_head, l1, 0);
- val = vals->nd_body;
- }
-
- COMPILE(cond_seq, "when/cond splat", val);
- ADD_INSN1(cond_seq, nd_line(val), checkincludearray, Qtrue);
- ADD_INSNL(cond_seq, nd_line(val), branchif, l1);
- }
- else {
- rb_bug("NODE_CASE: unknown node (%s)",
- ruby_node_name(nd_type(vals)));
- }
- }
- else {
- rb_bug("NODE_CASE: must be NODE_ARRAY, but 0");
- }
-
- node = node->nd_next;
- if (!node) {
- break;
- }
- type = nd_type(node);
- }
- /* else */
- if (node) {
- ADD_LABEL(cond_seq, elselabel);
- ADD_INSN(cond_seq, nd_line(node), pop);
- COMPILE_(cond_seq, "else", node, poped);
- ADD_INSNL(cond_seq, nd_line(node), jump, endlabel);
- }
- else {
- debugs("== else (implicit)\n");
- ADD_LABEL(cond_seq, elselabel);
- ADD_INSN(cond_seq, nd_line(tempnode), pop);
- if (!poped) {
- ADD_INSN(cond_seq, nd_line(tempnode), putnil);
- }
- ADD_INSNL(cond_seq, nd_line(tempnode), jump, endlabel);
- }
-
- if (special_literals) {
- ADD_INSN(ret, nd_line(tempnode), dup);
- ADD_INSN2(ret, nd_line(tempnode), opt_case_dispatch,
- special_literals, elselabel);
- iseq_add_mark_object_compile_time(iseq, special_literals);
- }
-
- ADD_SEQ(ret, cond_seq);
- ADD_SEQ(ret, body_seq);
- ADD_LABEL(ret, endlabel);
- break;
- }
- case NODE_WHEN:{
- NODE *vals;
- NODE *val;
- NODE *orig_node = node;
- LABEL *endlabel;
- DECL_ANCHOR(body_seq);
-
- INIT_ANCHOR(body_seq);
- endlabel = NEW_LABEL(nd_line(node));
-
- while (node && nd_type(node) == NODE_WHEN) {
- LABEL *l1 = NEW_LABEL(nd_line(node));
- ADD_LABEL(body_seq, l1);
- COMPILE_(body_seq, "when", node->nd_body, poped);
- ADD_INSNL(body_seq, nd_line(node), jump, endlabel);
-
- vals = node->nd_head;
- if (vals && nd_type(vals) == NODE_ARRAY) {
- while (vals) {
- val = vals->nd_head;
- COMPILE(ret, "when2", val);
- ADD_INSNL(ret, nd_line(val), branchif, l1);
- vals = vals->nd_next;
- }
- }
- else if (nd_type(vals) == NODE_SPLAT ||
- nd_type(vals) == NODE_ARGSCAT ||
- nd_type(vals) == NODE_ARGSPUSH) {
-
- NODE *val = vals->nd_head;
-
- if (nd_type(vals) == NODE_ARGSCAT || nd_type(vals) == NODE_ARGSPUSH) {
- NODE *vs = vals->nd_head;
- val = vals->nd_body;
-
- while (vs) {
- NODE* val = vs->nd_head;
- COMPILE(ret, "when/argscat", val);
- ADD_INSNL(ret, nd_line(val), branchif, l1);
- vs = vs->nd_next;
- }
- }
-
- ADD_INSN(ret, nd_line(val), putnil);
- COMPILE(ret, "when2/splat", val);
- ADD_INSN1(ret, nd_line(val), checkincludearray, Qfalse);
- ADD_INSN(ret, nd_line(val), pop);
- ADD_INSNL(ret, nd_line(val), branchif, l1);
- }
- else {
- rb_bug("err");
- }
- node = node->nd_next;
- }
- /* else */
- COMPILE_(ret, "else", node, poped);
- ADD_INSNL(ret, nd_line(orig_node), jump, endlabel);
-
- ADD_SEQ(ret, body_seq);
- ADD_LABEL(ret, endlabel);
-
- break;
- }
- case NODE_OPT_N:
- case NODE_WHILE:
- case NODE_UNTIL:{
- LABEL *prev_start_label = iseq->compile_data->start_label;
- LABEL *prev_end_label = iseq->compile_data->end_label;
- LABEL *prev_redo_label = iseq->compile_data->redo_label;
- VALUE prev_loopval_popped = iseq->compile_data->loopval_popped;
-
- struct iseq_compile_data_ensure_node_stack *enlp =
- iseq->compile_data->ensure_node_stack;
-
- LABEL *next_label = iseq->compile_data->start_label = NEW_LABEL(nd_line(node)); /* next */
- LABEL *redo_label = iseq->compile_data->redo_label = NEW_LABEL(nd_line(node)); /* redo */
- LABEL *break_label = iseq->compile_data->end_label = NEW_LABEL(nd_line(node)); /* break */
- LABEL *end_label = NEW_LABEL(nd_line(node));
-
- iseq->compile_data->loopval_popped = 0;
- iseq->compile_data->ensure_node_stack = 0;
-
- if (type == NODE_OPT_N || node->nd_state == 1) {
- ADD_INSNL(ret, nd_line(node), jump, next_label);
- }
-
- ADD_LABEL(ret, redo_label);
- COMPILE_POPED(ret, "while body", node->nd_body);
- ADD_LABEL(ret, next_label); /* next */
-
- if (type == NODE_WHILE) {
- compile_branch_condition(iseq, ret, node->nd_cond,
- redo_label, end_label);
- }
- else if (type == NODE_UNTIL) {
- /* untile */
- compile_branch_condition(iseq, ret, node->nd_cond,
- end_label, redo_label);
- }
- else {
- ADD_CALL_RECEIVER(ret, nd_line(node));
- ADD_CALL(ret, nd_line(node), ID2SYM(idGets), INT2FIX(0));
- ADD_INSNL(ret, nd_line(node), branchif, redo_label);
- /* opt_n */
- }
-
- ADD_LABEL(ret, end_label);
-
- if (node->nd_state == Qundef) {
- /* ADD_INSN(ret, nd_line(node), putundef); */
- rb_bug("unsupported: putundef");
- }
- else {
- ADD_INSN(ret, nd_line(node), putnil);
- }
-
- ADD_LABEL(ret, break_label); /* braek */
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
-
- ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, redo_label, break_label,
- 0, break_label);
- ADD_CATCH_ENTRY(CATCH_TYPE_NEXT | 0x10000, redo_label,
- break_label, 0, iseq->compile_data->start_label);
- ADD_CATCH_ENTRY(CATCH_TYPE_REDO, redo_label, break_label, 0,
- iseq->compile_data->redo_label);
-
- iseq->compile_data->start_label = prev_start_label;
- iseq->compile_data->end_label = prev_end_label;
- iseq->compile_data->redo_label = prev_redo_label;
- iseq->compile_data->loopval_popped = prev_loopval_popped;
- iseq->compile_data->ensure_node_stack = enlp;
- break;
- }
- case NODE_ITER:
- case NODE_FOR:{
- VALUE prevblock = iseq->compile_data->current_block;
- LABEL *retry_label = NEW_LABEL(nd_line(node));
- LABEL *retry_end_l = NEW_LABEL(nd_line(node));
- ID mid = 0;
-
- ADD_LABEL(ret, retry_label);
- if (nd_type(node) == NODE_FOR) {
- COMPILE(ret, "iter caller (for)", node->nd_iter);
-
- iseq->compile_data->current_block =
- NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
- ISEQ_TYPE_BLOCK);
-
- mid = idEach;
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0),
- iseq->compile_data->current_block, INT2FIX(0));
- }
- else {
- iseq->compile_data->current_block =
- NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
- ISEQ_TYPE_BLOCK);
- COMPILE(ret, "iter caller", node->nd_iter);
- }
- ADD_LABEL(ret, retry_end_l);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
-
- iseq->compile_data->current_block = prevblock;
-
- ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, 0, retry_end_l);
-
- break;
- }
- case NODE_BREAK:{
- unsigned long level = 0;
-
- if (iseq->compile_data->redo_label != 0) {
- /* while/until */
-#if 0
- add_ensure_iseq(ret, iseq);
- COMPILE_(ret, "break val (while/until)", node->nd_stts,
- iseq->compile_data->loopval_popped);
- ADD_INSNL(ret, nd_line(node), jump,
- iseq->compile_data->end_label);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
-#else
- level = 0x8000 | 0x4000;
- COMPILE(ret, "break val (while/until)", node->nd_stts);
- ADD_INSN1(ret, nd_line(node), throw,
- INT2FIX(level | 0x02) /* TAG_BREAK */ );
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
-#endif
- }
- else if (iseq->type == ISEQ_TYPE_BLOCK) {
- break_by_insn:
- /* escape from block */
- COMPILE(ret, "break val (block)", node->nd_stts);
- ADD_INSN1(ret, nd_line(node), throw,
- INT2FIX(level | 0x02) /* TAG_BREAK */ );
- }
- else if (iseq->type == ISEQ_TYPE_EVAL) {
- break_in_eval:
- COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with break"));
- }
- else {
- rb_iseq_t *ip = iseq->parent_iseq;
- while (ip) {
- level++;
- if (ip->compile_data->redo_label != 0) {
- level = 0x8000;
- if (ip->compile_data->loopval_popped == 0) {
- /* need value */
- level |= 0x4000;
- }
- goto break_by_insn;
- }
- else if (ip->type == ISEQ_TYPE_BLOCK) {
- level <<= 16;
- goto break_by_insn;
- }
- else if (ip->type == ISEQ_TYPE_EVAL) {
- goto break_in_eval;
- }
- ip = ip->parent_iseq;
- }
- COMPILE_ERROR((ERROR_ARGS "Invalid break"));
- }
- break;
- }
- case NODE_NEXT:{
- unsigned long level = 0;
- int pop_after_throw = 0;
-
- if (iseq->compile_data->redo_label != 0) {
- /* next in while loop */
- debugs("next in while\n");
- pop_after_throw = poped;
- goto next_by_throw;
- }
- else if (iseq->compile_data->end_label) {
- debugs("next in block\n");
- ADD_INSN (ret, nd_line(node), emptstack);
- COMPILE(ret, "next val", node->nd_stts);
- add_ensure_iseq(ret, iseq);
- ADD_INSNL(ret, nd_line(node), jump,
- iseq->compile_data->end_label);
- }
- else if (iseq->type == ISEQ_TYPE_EVAL) {
- next_in_eval:
- COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with next"));
- }
- else {
- rb_iseq_t *ip;
- next_by_throw:
- ip = iseq;
- while (ip) {
- level = 0x8000;
- if (ip->compile_data->redo_label != 0) {
- /* while loop */
- break;
- }
- else if (ip->type == ISEQ_TYPE_BLOCK) {
- level |= 0x4000;
- break;
- }
- else if (ip->type == ISEQ_TYPE_EVAL) {
- goto next_in_eval;
- }
- ip = ip->parent_iseq;
- }
- if (ip != 0) {
- COMPILE(ret, "next val", node->nd_stts);
- ADD_INSN1(ret, nd_line(node), throw,
- INT2FIX(level | 0x03) /* TAG_NEXT */ );
- if (pop_after_throw) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- }
- else {
- COMPILE_ERROR((ERROR_ARGS "Invalid next"));
- }
- }
- break;
- }
- case NODE_REDO:{
- int pop_after_throw = 0;
- if (iseq->compile_data->redo_label) {
- debugs("redo in while");
-#if 1
- pop_after_throw = poped;
- goto redo_by_throw;
-#else
- add_ensure_iseq(ret, iseq);
- ADD_INSNL(ret, nd_line(node), jump,
- iseq->compile_data->redo_label);
- if (!poped) { /* for stack consistency */
- ADD_INSN(ret, nd_line(node), putnil);
- }
-#endif
- }
- else if (iseq->type == ISEQ_TYPE_EVAL) {
- redo_in_eval:
- COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with redo"));
- }
- else if (iseq->compile_data->start_label) {
- ADD_INSN (ret, nd_line(node), emptstack);
- add_ensure_iseq(ret, iseq);
- ADD_INSNL(ret, nd_line(node), jump,
- iseq->compile_data->start_label);
- if (!poped) { /* for stack consistency */
- ADD_INSN(ret, nd_line(node), putnil);
- }
- }
- else {
- rb_iseq_t *ip;
- unsigned long level;
- redo_by_throw:
- level = 0x8000 | 0x4000;
- ip = iseq;
- while (ip) {
- if (ip->compile_data->redo_label != 0) {
- break;
- }
- else if (ip->type == ISEQ_TYPE_BLOCK) {
- break;
- }
- else if (ip->type == ISEQ_TYPE_EVAL) {
- goto redo_in_eval;
- }
- ip = ip->parent_iseq;
- }
- if (ip != 0) {
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN1(ret, nd_line(node), throw,
- INT2FIX(level | 0x05) /* TAG_REDO */ );
-
- if (pop_after_throw) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- }
- else {
- COMPILE_ERROR((ERROR_ARGS "Invalid redo"));
- }
- }
- break;
- }
- case NODE_RETRY:{
- if (iseq->type == ISEQ_TYPE_RESCUE) {
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN1(ret, nd_line(node), throw,
- INT2FIX(0x04) /* TAG_RETRY */ );
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- }
- else {
- COMPILE_ERROR((ERROR_ARGS "Invalid retry"));
- }
- break;
- }
- case NODE_BEGIN:{
- COMPILE_(ret, "NODE_BEGIN", node->nd_body, poped);
- break;
- }
- case NODE_RESCUE:{
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
- LABEL *lcont = NEW_LABEL(nd_line(node));
- VALUE rescue = NEW_CHILD_ISEQVAL(node->nd_resq,
- rb_str_concat(rb_str_new2
- ("rescue in "),
- iseq->name),
- ISEQ_TYPE_RESCUE);
-
- ADD_LABEL(ret, lstart);
- COMPILE(ret, "rescue head", node->nd_head);
- ADD_LABEL(ret, lend);
- if (node->nd_else) {
- ADD_INSN(ret, nd_line(node), pop);
- COMPILE(ret, "rescue else", node->nd_else);
- }
- ADD_INSN(ret, nd_line(node), nop);
- ADD_LABEL(ret, lcont);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
-
- /* resgister catch entry */
- ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lcont);
- ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, lend, lcont, 0, lstart);
- break;
- }
- case NODE_RESBODY:{
- NODE *resq = node;
- NODE *narg;
- LABEL *label_miss, *label_hit;
-
- while (resq) {
- label_miss = NEW_LABEL(nd_line(node));
- label_hit = NEW_LABEL(nd_line(node));
-
- narg = resq->nd_args;
- while (narg) {
- COMPILE(ret, "rescue arg", narg->nd_head);
- ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1),
- INT2FIX(0));
- ADD_SEND(ret, nd_line(node), ID2SYM(idEqq), INT2FIX(1));
- ADD_INSNL(ret, nd_line(node), branchif, label_hit);
- narg = narg->nd_next;
- }
- if (resq->nd_args == 0) {
- ADD_INSN1(ret, nd_line(node), putobject,
- rb_eStandardError);
- ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1),
- INT2FIX(0));
- ADD_SEND(ret, nd_line(node), ID2SYM(idEqq), INT2FIX(1));
- ADD_INSNL(ret, nd_line(node), branchif, label_hit);
- }
- ADD_INSNL(ret, nd_line(node), jump, label_miss);
- ADD_LABEL(ret, label_hit);
- COMPILE(ret, "resbody body", resq->nd_body);
- if (iseq->compile_data->option->tailcall_optimization) {
- ADD_INSN(ret, nd_line(node), nop);
- }
- ADD_INSN(ret, nd_line(node), leave);
- ADD_LABEL(ret, label_miss);
- resq = resq->nd_head;
- }
- break;
- }
- case NODE_ENSURE:{
- DECL_ANCHOR(ensr);
- VALUE ensure = NEW_CHILD_ISEQVAL(node->nd_ensr,
- rb_str_concat(rb_str_new2
- ("ensure in "),
- iseq->name),
- ISEQ_TYPE_ENSURE);
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
- LABEL *lcont = NEW_LABEL(nd_line(node));
- struct ensure_range er = { 0 };
- struct iseq_compile_data_ensure_node_stack enl;
- struct ensure_range *erange;
-
- INIT_ANCHOR(ensr);
- er.begin = lstart;
- er.end = lend;
- enl.ensure_node = node->nd_ensr;
- enl.prev = iseq->compile_data->ensure_node_stack; /* prev */
- enl.erange = &er;
- COMPILE_POPED(ensr, "ensure ensr", node->nd_ensr);
-
- iseq->compile_data->ensure_node_stack = &enl;
-
- ADD_LABEL(ret, lstart);
- COMPILE_(ret, "ensure head", node->nd_head, poped);
- ADD_LABEL(ret, lend);
- if (ensr->anchor.next == 0) {
- ADD_INSN(ret, nd_line(node), nop);
- }
- else {
- ADD_SEQ(ret, ensr);
- }
- ADD_LABEL(ret, lcont);
-
- erange = iseq->compile_data->ensure_node_stack->erange;
- while (erange) {
- ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, erange->begin, erange->end,
- ensure, lcont);
- erange = erange->next;
- }
- iseq->compile_data->ensure_node_stack = enl.prev;
- break;
- }
-
- case NODE_AND:
- case NODE_OR:{
- LABEL *end_label = NEW_LABEL(nd_line(node));
- COMPILE(ret, "nd_1st", node->nd_1st);
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
- if (type == NODE_AND) {
- ADD_INSNL(ret, nd_line(node), branchunless, end_label);
- }
- else {
- ADD_INSNL(ret, nd_line(node), branchif, end_label);
- }
- if (!poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- COMPILE_(ret, "nd_2nd", node->nd_2nd, poped);
- ADD_LABEL(ret, end_label);
- break;
- }
-
- case NODE_MASGN:{
- compile_massign(iseq, ret, node, poped);
- break;
- }
-
- case NODE_LASGN:{
- ID id = node->nd_vid;
- int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
-
- debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
- COMPILE(ret, "rvalue", node->nd_value);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
- ADD_INSN1(ret, nd_line(node), setlocal, INT2FIX(idx));
-
- break;
- }
- case NODE_DASGN:
- case NODE_DASGN_CURR:{
- int idx, lv, ls;
- COMPILE(ret, "dvalue", node->nd_value);
- debugp_param("dassn id", rb_str_new2(rb_id2name(node->nd_vid) ? rb_id2name(node->nd_vid) : "*"));
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
-
- idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
-
- if (idx < 0) {
- rb_bug("NODE_DASGN(_CURR): unknown id (%s)", rb_id2name(node->nd_vid));
- }
-
- ADD_INSN2(ret, nd_line(node), setdynamic,
- INT2FIX(ls - idx), INT2FIX(lv));
- break;
- }
- case NODE_GASGN:{
- COMPILE(ret, "lvalue", node->nd_value);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
- ADD_INSN1(ret, nd_line(node), setglobal,
- (((long)node->nd_entry) | 1));
- break;
- }
- case NODE_IASGN:
- case NODE_IASGN2:{
- COMPILE(ret, "lvalue", node->nd_value);
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
- ADD_INSN1(ret, nd_line(node), setinstancevariable,
- ID2SYM(node->nd_vid));
- break;
- }
- case NODE_CDECL:{
- COMPILE(ret, "lvalue", node->nd_value);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
-
- if (node->nd_vid) {
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN1(ret, nd_line(node), setconstant,
- ID2SYM(node->nd_vid));
- }
- else {
- compile_cpath(ret, iseq, node->nd_else);
- ADD_INSN1(ret, nd_line(node), setconstant,
- ID2SYM(node->nd_else->nd_mid));
- }
- break;
- }
- case NODE_CVASGN:{
- COMPILE(ret, "cvasgn val", node->nd_value);
- if (!poped) {
- ADD_INSN(ret, nd_line(node), dup);
- }
- ADD_INSN1(ret, nd_line(node), setclassvariable,
- ID2SYM(node->nd_vid));
- break;
- }
- case NODE_OP_ASGN1: {
- DECL_ANCHOR(args);
- VALUE argc;
- unsigned long flag = 0;
- ID id = node->nd_mid;
-
- /*
- * a[x] (op)= y
- *
- * eval a # a
- * eval x # a x
- * dupn 2 # a x a x
- * send :[] # a x a[x]
- * eval y # a x a[x] y
- * send op # a x a[x]+y
- * send []= # ret
- */
-
- /*
- * nd_recv[nd_args->nd_body] (nd_mid)= nd_args->nd_head;
- * NODE_OP_ASGN nd_recv
- * nd_args->nd_head
- * nd_args->nd_body
- * nd_mid
- */
-
- COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
- if (nd_type(node->nd_args->nd_body) != NODE_ZARRAY) {
- INIT_ANCHOR(args);
- argc = setup_args(iseq, args, node->nd_args->nd_body, &flag);
- ADD_SEQ(ret, args);
- }
- else {
- argc = INT2FIX(0);
- }
- ADD_INSN1(ret, nd_line(node), dupn, INT2FIX(FIX2INT(argc)+1));
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
-
- if (id == 0 || id == 1) {
- /* 0: or, 1: and
- a[x] ||= y
-
- unless/if a[x]
- a[x]= y
- else
- nil
- end
- */
- LABEL *label = NEW_LABEL(nd_line(node));
- LABEL *lfin = NEW_LABEL(nd_line(node));
-
- if (id == 0) {
- /* or */
- ADD_INSN(ret, nd_line(node), dup);
- ADD_INSNL(ret, nd_line(node), branchif, label);
- ADD_INSN(ret, nd_line(node), pop);
- }
- else {
- /* and */
- ADD_INSNL(ret, nd_line(node), branchunless, label);
- }
-
- COMPILE(ret, "NODE_OP_ASGN1 args->head: ", node->nd_args->nd_head);
- if (flag & VM_CALL_ARGS_SPLAT_BIT) {
- ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
- ADD_INSN(ret, nd_line(node), concatarray);
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
- argc, Qfalse, LONG2FIX(flag));
- }
- else {
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
- INT2FIX(FIX2INT(argc) + 1), Qfalse, LONG2FIX(flag));
- }
- ADD_INSNL(ret, nd_line(node), jump, lfin);
- ADD_LABEL(ret, label);
- if (id == 0) { /* or */
- ADD_INSN(ret, nd_line(node), swap);
- ADD_INSN(ret, nd_line(node), pop);
- ADD_INSN(ret, nd_line(node), swap);
- ADD_INSN(ret, nd_line(node), pop);
- }
- else if (id == 1) { /* and */
- ADD_INSN(ret, nd_line(node), pop);
- ADD_INSN(ret, nd_line(node), pop);
- ADD_INSN(ret, nd_line(node), putnil);
- }
- ADD_LABEL(ret, lfin);
- }
- else {
- COMPILE(ret, "NODE_OP_ASGN1 args->head: ", node->nd_args->nd_head);
- ADD_SEND(ret, nd_line(node), ID2SYM(id), INT2FIX(1));
- if (flag & VM_CALL_ARGS_SPLAT_BIT) {
- ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
- ADD_INSN(ret, nd_line(node), concatarray);
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
- argc, Qfalse, LONG2FIX(flag));
- }
- else {
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
- INT2FIX(FIX2INT(argc) + 1), Qfalse, LONG2FIX(flag));
- }
- }
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
-
- break;
- }
- case NODE_OP_ASGN2:{
- ID atype = node->nd_next->nd_mid;
- LABEL *lfin = NEW_LABEL(nd_line(node));
- LABEL *lcfin = NEW_LABEL(nd_line(node));
- /*
- class C; attr_accessor :c; end
- r = C.new
- r.a &&= v # asgn2
-
- eval r # r
- dup # r r
- eval r.a # r o
-
- # or
- dup # r o o
- if lcfin # r o
- pop # r
- eval v # r v
- send a= # v
- jump lfin # v
-
- lcfin: # r o
- swap # o r
- pop # o
-
- lfin: # v
-
- # and
- dup # r o o
- unless lcfin
- pop # r
- eval v # r v
- send a= # v
- jump lfin # v
-
- # others
- eval v # r o v
- send ?? # r w
- send a= # w
-
- */
-
- COMPILE(ret, "NODE_OP_ASGN2#recv", node->nd_recv);
- ADD_INSN(ret, nd_line(node), dup);
- ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_vid),
- INT2FIX(0));
-
- if (atype == 0 || atype == 1) { /* 0: OR or 1: AND */
- ADD_INSN(ret, nd_line(node), dup);
- if (atype == 0) {
- ADD_INSNL(ret, nd_line(node), branchif, lcfin);
- }
- else {
- ADD_INSNL(ret, nd_line(node), branchunless, lcfin);
- }
- ADD_INSN(ret, nd_line(node), pop);
- COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value);
- ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_aid),
- INT2FIX(1));
- ADD_INSNL(ret, nd_line(node), jump, lfin);
-
- ADD_LABEL(ret, lcfin);
- ADD_INSN(ret, nd_line(node), swap);
- ADD_INSN(ret, nd_line(node), pop);
-
- ADD_LABEL(ret, lfin);
- }
- else {
- COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value);
- ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_mid),
- INT2FIX(1));
- ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_aid),
- INT2FIX(1));
- }
-
- if (poped) {
- /* we can apply more optimize */
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_OP_ASGN_AND:
- case NODE_OP_ASGN_OR:{
- LABEL *lfin = NEW_LABEL(nd_line(node));
- LABEL *lassign = NEW_LABEL(nd_line(node));
-
- if (nd_type(node) == NODE_OP_ASGN_OR) {
- defined_expr(iseq, ret, node->nd_head, lassign, Qfalse);
- ADD_INSNL(ret, nd_line(node), branchunless, lassign);
- }
-
- COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", node->nd_head);
- ADD_INSN(ret, nd_line(node), dup);
-
- if (nd_type(node) == NODE_OP_ASGN_AND) {
- ADD_INSNL(ret, nd_line(node), branchunless, lfin);
- }
- else {
- ADD_INSNL(ret, nd_line(node), branchif, lfin);
- }
-
- ADD_INSN(ret, nd_line(node), pop);
- ADD_LABEL(ret, lassign);
- COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_value", node->nd_value);
- ADD_LABEL(ret, lfin);
-
- if (poped) {
- /* we can apply more optimize */
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_CALL:
- case NODE_FCALL:
- case NODE_VCALL:{ /* VCALL: variable or call */
- /*
- call: obj.method(...)
- fcall: func(...)
- vcall: func
- */
- DECL_ANCHOR(recv);
- DECL_ANCHOR(args);
- ID mid = node->nd_mid;
- VALUE argc;
- unsigned long flag = 0;
- VALUE parent_block = iseq->compile_data->current_block;
- iseq->compile_data->current_block = Qfalse;
-
- INIT_ANCHOR(recv);
- INIT_ANCHOR(args);
-#if SUPPORT_JOKE
- if (nd_type(node) == NODE_VCALL) {
- if (mid == idBitblt) {
- ADD_INSN(ret, nd_line(node), bitblt);
- break;
- }
- else if (mid == idAnswer) {
- ADD_INSN(ret, nd_line(node), answer);
- break;
- }
- }
- /* only joke */
- {
- static ID goto_id;
- static ID label_id;
- VALUE label;
- VALUE label_sym;
-
- if (goto_id == 0) {
- goto_id = rb_intern("__goto__");
- label_id = rb_intern("__label__");
- }
-
- if (nd_type(node) == NODE_FCALL &&
- (mid == goto_id || mid == label_id)) {
- if (nd_type(node->nd_args->nd_head) == NODE_LIT &&
- SYMBOL_P(node->nd_args->nd_head->nd_lit)) {
-
- label_sym = label = node->nd_args->nd_head->nd_lit;
- if ((label =
- rb_hash_aref(iseq->compile_data,
- label_sym)) == Qnil) {
- rb_hash_aset(iseq->compile_data, label_sym,
- label = NEW_LABEL(nd_line(node)));
- }
- }
- else {
- rb_bug("invalid goto/label format");
- }
-
-
- if (mid == goto_id) {
- ADD_INSNL(ret, nd_line(node), jump, label);
- }
- else {
- ADD_LABEL(ret, label);
- }
- break;
- }
- }
-#endif
- /* reciever */
- if (type == NODE_CALL) {
- COMPILE(recv, "recv", node->nd_recv);
- }
- else if (type == NODE_FCALL || type == NODE_VCALL) {
- ADD_CALL_RECEIVER(recv, nd_line(node));
- }
-
- /* args */
- if (nd_type(node) != NODE_VCALL) {
- argc = setup_args(iseq, args, node->nd_args, &flag);
- }
- else {
- argc = INT2FIX(0);
- }
-
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, args);
-
- debugp_param("call args argc", argc);
- debugp_param("call method", ID2SYM(mid));
-
- switch (nd_type(node)) {
- case NODE_VCALL:
- flag |= VM_CALL_VCALL_BIT;
- /* VCALL is funcall, so fall through */
- case NODE_FCALL:
- flag |= VM_CALL_FCALL_BIT;
- }
-
- ADD_SEND_R(ret, nd_line(node), ID2SYM(mid),
- argc, parent_block, LONG2FIX(flag));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_SUPER:
- case NODE_ZSUPER:{
- DECL_ANCHOR(args);
- VALUE argc;
- unsigned long flag = 0;
- VALUE parent_block = iseq->compile_data->current_block;
-
- INIT_ANCHOR(args);
- iseq->compile_data->current_block = Qfalse;
- if (nd_type(node) == NODE_SUPER) {
- argc = setup_args(iseq, args, node->nd_args, &flag);
- }
- else {
- /* NODE_ZSUPER */
- int i;
- rb_iseq_t *liseq = iseq->local_iseq;
-
- argc = INT2FIX(liseq->argc);
-
- /* normal arguments */
- for (i = 0; i < liseq->argc; i++) {
- int idx = liseq->local_size - i;
- ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
- }
-
- if (!liseq->arg_simple) {
- if (liseq->arg_opts) {
- /* optional arguments */
- int j;
- for (j = 0; j < liseq->arg_opts - 1; j++) {
- int idx = liseq->local_size - (i + j);
- ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
- }
- i += j;
- argc = INT2FIX(i);
- }
-
- if (liseq->arg_rest != -1) {
- /* rest argument */
- int idx = liseq->local_size - liseq->arg_rest;
- ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
- argc = INT2FIX(liseq->arg_rest + 1);
- flag |= VM_CALL_ARGS_SPLAT_BIT;
- }
-
- if (liseq->arg_post_len) {
- /* post arguments */
- int post_len = liseq->arg_post_len;
- int post_start = liseq->arg_post_start;
-
- if (liseq->arg_rest != -1) {
- int j;
- for (j=0; j<post_len; j++) {
- int idx = liseq->local_size - (post_start + j);
- ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
- }
- ADD_INSN1(args, nd_line(node), newarray, INT2FIX(j));
- ADD_INSN (args, nd_line(node), concatarray);
- /* argc is setteled at above */
- }
- else {
- int j;
- for (j=0; j<post_len; j++) {
- int idx = liseq->local_size - (post_start + j);
- ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
- }
- argc = INT2FIX(post_len + post_start);
- }
- }
- }
- }
-
- /* dummy reciever */
- ADD_INSN1(ret, nd_line(node), putobject,
- nd_type(node) == NODE_ZSUPER ? Qfalse : Qtrue);
- ADD_SEQ(ret, args);
- ADD_INSN3(ret, nd_line(node), invokesuper,
- argc, parent_block, LONG2FIX(flag));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_ARRAY:{
- compile_array_(iseq, ret, node, Qtrue, poped);
- break;
- }
- case NODE_ZARRAY:{
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(0));
- }
- break;
- }
- case NODE_VALUES:{
- NODE *n = node;
- while (n) {
- COMPILE(ret, "values item", n->nd_head);
- n = n->nd_next;
- }
- ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(node->nd_alen));
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_HASH:{
- DECL_ANCHOR(list);
- VALUE size = 0;
- int type = node->nd_head ? nd_type(node->nd_head) : NODE_ZARRAY;
-
- INIT_ANCHOR(list);
- switch (type) {
- case NODE_ARRAY:{
- compile_array(iseq, list, node->nd_head, Qfalse);
- size = OPERAND_AT(POP_ELEMENT(list), 0);
- ADD_SEQ(ret, list);
- break;
- }
- case NODE_ZARRAY:
- size = INT2FIX(0);
- break;
-
- default:
- rb_bug("can't make hash with this node: %s", ruby_node_name(type));
- }
-
- ADD_INSN1(ret, nd_line(node), newhash, size);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_RETURN:{
- rb_iseq_t *is = iseq;
-
- while (is) {
- if (is->type == ISEQ_TYPE_TOP || is->type == ISEQ_TYPE_CLASS) {
- COMPILE_ERROR((ERROR_ARGS "Invalid return"));
- break;
- }
- else {
- if (is->type == ISEQ_TYPE_METHOD) {
- ADD_INSN(ret, nd_line(node), emptstack);
- }
-
- COMPILE(ret, "return nd_stts (return val)", node->nd_stts);
-
- if (is->type == ISEQ_TYPE_METHOD) {
- add_ensure_iseq(ret, iseq);
- ADD_INSN(ret, nd_line(node), leave);
- }
- else {
- ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x01) /* TAG_RETURN */ );
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- }
- break;
- }
- }
- break;
- }
- case NODE_YIELD:{
- DECL_ANCHOR(args);
- VALUE argc;
- unsigned long flag = 0;
-
- INIT_ANCHOR(args);
- if (iseq->type == ISEQ_TYPE_TOP || iseq->type == ISEQ_TYPE_CLASS) {
- COMPILE_ERROR((ERROR_ARGS "Invalid yield"));
- }
-
- if (node->nd_head) {
- argc = setup_args(iseq, args, node->nd_head, &flag);
- }
- else {
- argc = INT2FIX(0);
- }
-
- ADD_SEQ(ret, args);
- ADD_INSN2(ret, nd_line(node), invokeblock, argc, LONG2FIX(flag));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_LVAR:{
- if (!poped) {
- ID id = node->nd_vid;
- int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
-
- debugs("id: %s idx: %d\n", rb_id2name(id), idx);
- ADD_INSN1(ret, nd_line(node), getlocal, INT2FIX(idx));
- }
- break;
- }
- case NODE_DVAR:{
- int lv, idx, ls;
- debugi("nd_vid", node->nd_vid);
- if (!poped) {
- idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
- if (idx < 0) {
- rb_bug("unknown dvar (%s)", rb_id2name(node->nd_vid));
- }
- ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(ls - idx),
- INT2FIX(lv));
- }
- break;
- }
- case NODE_GVAR:{
- ADD_INSN1(ret, nd_line(node), getglobal,
- (((long)node->nd_entry) | 1));
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_IVAR:{
- debugi("nd_vid", node->nd_vid);
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), getinstancevariable,
- ID2SYM(node->nd_vid));
- }
- break;
- }
- case NODE_CONST:{
- debugi("nd_vid", node->nd_vid);
-
- if (iseq->compile_data->option->inline_const_cache) {
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
-
- ADD_LABEL(ret, lstart);
- ADD_INSN2(ret, nd_line(node), getinlinecache, 0, lend);
- ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_vid));
- ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
- ADD_LABEL(ret, lend);
- }
- else {
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_vid));
- }
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_CVAR:{
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), getclassvariable,
- ID2SYM(node->nd_vid));
- }
- break;
- }
- case NODE_NTH_REF:{
- if (!poped) {
- ADD_INSN2(ret, nd_line(node), getspecial, INT2FIX(1) /* '~' */,
- INT2FIX(node->nd_nth << 1));
- }
- break;
- }
- case NODE_BACK_REF:{
- if (!poped) {
- ADD_INSN2(ret, nd_line(node), getspecial, INT2FIX(1) /* '~' */,
- INT2FIX(0x01 | (node->nd_nth << 1)));
- }
- break;
- }
- case NODE_MATCH:
- case NODE_MATCH2:
- case NODE_MATCH3:{
- DECL_ANCHOR(recv);
- DECL_ANCHOR(val);
-
- INIT_ANCHOR(recv);
- INIT_ANCHOR(val);
- switch(nd_type(node)) {
- case NODE_MATCH:
- ADD_INSN1(recv, nd_line(node), putobject, node->nd_lit);
- ADD_INSN2(val, nd_line(node), getspecial, INT2FIX(0),
- INT2FIX(0));
- break;
- case NODE_MATCH2:
- COMPILE(recv, "reciever", node->nd_recv);
- COMPILE(val, "value", node->nd_value);
- break;
- case NODE_MATCH3:
- COMPILE(recv, "reciever", node->nd_value);
- COMPILE(val, "value", node->nd_recv);
- break;
- }
-
- if (iseq->compile_data->option->specialized_instruction) {
- /* TODO: detect by node */
- if (recv->last == recv->anchor.next &&
- INSN_OF(recv->last) == BIN(putobject) &&
- nd_type(node) == NODE_MATCH2) {
- ADD_SEQ(ret, val);
- ADD_INSN1(ret, nd_line(node), opt_regexpmatch1,
- OPERAND_AT(recv->last, 0));
- }
- else {
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, val);
- ADD_INSN(ret, nd_line(node), opt_regexpmatch2);
- }
- }
- else {
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, val);
- ADD_SEND(ret, nd_line(node), ID2SYM(idEqTilde), INT2FIX(1));
- }
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_LIT:{
- debugp_param("lit", node->nd_lit);
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
- }
- break;
- }
- case NODE_STR:{
- debugp_param("nd_lit", node->nd_lit);
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), putstring, node->nd_lit);
- }
- break;
- }
- case NODE_DSTR:{
- compile_dstr(iseq, ret, node);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_XSTR:{
- ADD_CALL_RECEIVER(ret, nd_line(node));
- ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
- ADD_CALL(ret, nd_line(node), ID2SYM(idBackquote), INT2FIX(1));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_DXSTR:{
- ADD_CALL_RECEIVER(ret, nd_line(node));
- compile_dstr(iseq, ret, node);
- ADD_CALL(ret, nd_line(node), ID2SYM(idBackquote), INT2FIX(1));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_EVSTR:{
- COMPILE(ret, "nd_body", node->nd_body);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- else {
- ADD_INSN(ret, nd_line(node), tostring);
- }
- break;
- }
- case NODE_DREGX:{
- compile_dstr(iseq, ret, node);
- ADD_INSN1(ret, nd_line(node), toregexp, INT2FIX(node->nd_cflag));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_DREGX_ONCE:{
- /* TODO: once? */
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
-
- ADD_LABEL(ret, lstart);
- ADD_INSN2(ret, nd_line(node), onceinlinecache, 0, lend);
- ADD_INSN(ret, nd_line(node), pop);
-
- compile_dstr(iseq, ret, node);
- ADD_INSN1(ret, nd_line(node), toregexp, INT2FIX(node->nd_cflag));
-
- ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
- ADD_LABEL(ret, lend);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_ARGSCAT:{
- COMPILE(ret, "argscat head", node->nd_head);
- COMPILE(ret, "argscat body", node->nd_body);
- ADD_INSN(ret, nd_line(node), concatarray);
- break;
- }
- case NODE_ARGSPUSH:{
- COMPILE(ret, "arsgpush head", node->nd_head);
- COMPILE(ret, "argspush body", node->nd_body);
- ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
- ADD_INSN(ret, nd_line(node), concatarray);
- break;
- }
- case NODE_SPLAT:{
- COMPILE(ret, "splat", node->nd_head);
- ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_DEFN:{
- VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
- rb_str_dup(rb_id2str(node->nd_mid)),
- ISEQ_TYPE_METHOD);
-
- debugp_param("defn/iseq", iseqval);
-
- ADD_INSN (ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), definemethod,
- ID2SYM(node->nd_mid), iseqval, INT2FIX(0));
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- debugp_param("defn", iseqval);
- break;
- }
- case NODE_DEFS:{
- VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
- rb_str_dup(rb_id2str(node->nd_mid)),
- ISEQ_TYPE_METHOD);
-
- debugp_param("defs/iseq", iseqval);
-
- COMPILE(ret, "defs: recv", node->nd_recv);
- ADD_INSN3(ret, nd_line(node), definemethod,
- ID2SYM(node->nd_mid), iseqval, INT2FIX(1));
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- break;
- }
- case NODE_ALIAS:{
- COMPILE(ret, "alias arg1", node->u1.node);
- COMPILE(ret, "alias arg2", node->u2.node);
-
- ADD_INSN1(ret, nd_line(node), alias, Qfalse);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- break;
- }
- case NODE_VALIAS:{
- ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u1.id));
- ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u2.id));
- ADD_INSN1(ret, nd_line(node), alias, Qtrue);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- break;
- }
- case NODE_UNDEF:{
- COMPILE(ret, "undef arg", node->u2.node);
- ADD_INSN(ret, nd_line(node), undef);
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- break;
- }
- case NODE_CLASS:{
- VALUE iseqval =
- NEW_CHILD_ISEQVAL(
- node->nd_body,
- rb_sprintf("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)),
- ISEQ_TYPE_CLASS);
- compile_cpath(ret, iseq, node->nd_cpath);
- COMPILE(ret, "super", node->nd_super);
- ADD_INSN3(ret, nd_line(node), defineclass,
- ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(0));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_MODULE:{
- VALUE iseqval = NEW_CHILD_ISEQVAL(
- node->nd_body,
- rb_sprintf("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)),
- ISEQ_TYPE_CLASS);
-
- COMPILE(ret, "mbase", node->nd_cpath->nd_head);
- ADD_INSN (ret, nd_line(node), putnil); /* dummy */
- ADD_INSN3(ret, nd_line(node), defineclass,
- ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(2));
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_SCLASS:{
- VALUE iseqval =
- NEW_ISEQVAL(node->nd_body, rb_str_new2("singletonclass"),
- ISEQ_TYPE_CLASS);
-
- COMPILE(ret, "sclass#recv", node->nd_recv);
- ADD_INSN (ret, nd_line(node), putnil);
- ADD_INSN3(ret, nd_line(node), defineclass,
- ID2SYM(rb_intern("singletonclass")), iseqval, INT2FIX(1));
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_COLON2:{
- if (rb_is_const_id(node->nd_mid)) {
- /* constant */
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
- DECL_ANCHOR(pref);
- DECL_ANCHOR(body);
-
- INIT_ANCHOR(pref);
- INIT_ANCHOR(body);
- compile_colon2(iseq, node, pref, body);
- if (LIST_SIZE_ZERO(pref)) {
- if (iseq->compile_data->option->inline_const_cache) {
- ADD_LABEL(ret, lstart);
- ADD_INSN2(ret, nd_line(node), getinlinecache, 0, lend);
- }
- else {
- ADD_INSN(ret, nd_line(node), putnil);
- }
-
- ADD_SEQ(ret, body);
-
- if (iseq->compile_data->option->inline_const_cache) {
- ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
- ADD_LABEL(ret, lend);
- }
- }
- else {
- ADD_SEQ(ret, pref);
- ADD_SEQ(ret, body);
- }
- }
- else {
- /* function call */
- ADD_CALL_RECEIVER(ret, nd_line(node));
- COMPILE(ret, "colon2#nd_head", node->nd_head);
- ADD_CALL(ret, nd_line(node), ID2SYM(node->nd_mid),
- INT2FIX(1));
- }
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_COLON3:{
- LABEL *lstart = NEW_LABEL(nd_line(node));
- LABEL *lend = NEW_LABEL(nd_line(node));
- debugi("colon3#nd_mid", node->nd_mid);
-
- /* add cache insn */
- if (iseq->compile_data->option->inline_const_cache) {
- ADD_LABEL(ret, lstart);
- ADD_INSN2(ret, nd_line(node), getinlinecache, 0, lend);
- ADD_INSN(ret, nd_line(node), pop);
- }
-
- ADD_INSN1(ret, nd_line(node), putobject, rb_cObject);
- ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_mid));
-
- if (iseq->compile_data->option->inline_const_cache) {
- ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
- ADD_LABEL(ret, lend);
- }
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_DOT2:
- case NODE_DOT3:{
- int flag = type == NODE_DOT2 ? INT2FIX(0) : INT2FIX(1);
- COMPILE(ret, "min", (NODE *) node->nd_beg);
- COMPILE(ret, "max", (NODE *) node->nd_end);
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- ADD_INSN(ret, nd_line(node), pop);
- }
- else {
- ADD_INSN1(ret, nd_line(node), newrange, flag);
- }
- break;
- }
- case NODE_FLIP2:
- case NODE_FLIP3:{
- LABEL *lend = NEW_LABEL(nd_line(node));
- LABEL *lfin = NEW_LABEL(nd_line(node));
- LABEL *ltrue = NEW_LABEL(nd_line(node));
- VALUE key = rb_sprintf("flipflag/%s-%p-%d",
- RSTRING_PTR(iseq->name), iseq,
- iseq->compile_data->flip_cnt++);
-
- iseq_add_mark_object_compile_time(iseq, key);
- ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0));
- ADD_INSNL(ret, nd_line(node), branchif, lend);
-
- /* *flip == 0 */
- COMPILE(ret, "flip2 beg", node->nd_beg);
- ADD_INSN(ret, nd_line(node), dup);
- ADD_INSNL(ret, nd_line(node), branchunless, lfin);
- if (nd_type(node) == NODE_FLIP3) {
- ADD_INSN(ret, nd_line(node), dup);
- ADD_INSN1(ret, nd_line(node), setspecial, key);
- ADD_INSNL(ret, nd_line(node), jump, lfin);
- }
- else {
- ADD_INSN1(ret, nd_line(node), setspecial, key);
- }
-
- /* *flip == 1 */
- ADD_LABEL(ret, lend);
- COMPILE(ret, "flip2 end", node->nd_end);
- ADD_INSNL(ret, nd_line(node), branchunless, ltrue);
- ADD_INSN1(ret, nd_line(node), putobject, Qfalse);
- ADD_INSN1(ret, nd_line(node), setspecial, key);
-
- ADD_LABEL(ret, ltrue);
- ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
-
- ADD_LABEL(ret, lfin);
- break;
- }
- case NODE_SELF:{
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putself);
- }
- break;
- }
- case NODE_NIL:{
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- break;
- }
- case NODE_TRUE:{
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
- }
- break;
- }
- case NODE_FALSE:{
- if (!poped) {
- ADD_INSN1(ret, nd_line(node), putobject, Qfalse);
- }
- break;
- }
- case NODE_ERRINFO:{
- if (!poped) {
- if (iseq->type == ISEQ_TYPE_RESCUE) {
- ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1),
- INT2FIX(0));
- }
- else {
- rb_iseq_t *ip = iseq;
- int level = 0;
- while (ip) {
- if (ip->type == ISEQ_TYPE_RESCUE) {
- break;
- }
- ip = ip->parent_iseq;
- level++;
- }
- if (ip) {
- ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1),
- INT2FIX(level));
- }
- else {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- }
- }
- break;
- }
- case NODE_DEFINED:{
- if (!poped) {
- LABEL *lfinish = NEW_LABEL(nd_line(node));
- defined_expr(iseq, ret, node->nd_head, lfinish, Qtrue);
- ADD_LABEL(ret, lfinish);
- }
- break;
- }
- case NODE_POSTEXE:{
- VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK);
- ADD_INSN1(ret, nd_line(node), postexe, block);
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- }
- break;
- }
- case NODE_DSYM:{
- compile_dstr(iseq, ret, node);
- if (!poped) {
- ADD_SEND(ret, nd_line(node), ID2SYM(idIntern), INT2FIX(0));
- }
- else {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- case NODE_ATTRASGN:{
- DECL_ANCHOR(recv);
- DECL_ANCHOR(args);
- unsigned long flag = 0;
- VALUE argc;
-
- INIT_ANCHOR(recv);
- INIT_ANCHOR(args);
- argc = setup_args(iseq, args, node->nd_args, &flag);
-
- if (node->nd_recv == (NODE *) 1) {
- flag |= VM_CALL_FCALL_BIT;
- ADD_INSN(recv, nd_line(node), putself);
- }
- else {
- COMPILE(recv, "recv", node->nd_recv);
- }
-
- debugp_param("argc", argc);
- debugp_param("nd_mid", ID2SYM(node->nd_mid));
-
- if (!poped) {
- ADD_INSN(ret, nd_line(node), putnil);
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, args);
-
- if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
- ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
- ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 3));
- ADD_INSN (ret, nd_line(node), pop);
- }
- else {
- ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 1));
- }
- }
- else {
- ADD_SEQ(ret, recv);
- ADD_SEQ(ret, args);
- }
- ADD_SEND_R(ret, nd_line(node), ID2SYM(node->nd_mid), argc, 0, LONG2FIX(flag));
- ADD_INSN(ret, nd_line(node), pop);
-
- break;
- }
- case NODE_OPTBLOCK:{
- /* for optimize */
- LABEL *redo_label = NEW_LABEL(0);
- LABEL *next_label = NEW_LABEL(0);
-
- iseq->compile_data->start_label = next_label;
- iseq->compile_data->redo_label = redo_label;
-
- ADD_LABEL(ret, redo_label);
- COMPILE_(ret, "optblock body", node->nd_head, 1 /* pop */ );
- ADD_LABEL(ret, next_label);
- ADD_INSN(ret, 0, opt_checkenv);
- break;
- }
- case NODE_PRELUDE:{
- COMPILE_POPED(ret, "prelude", node->nd_head);
- COMPILE_(ret, "body", node->nd_body, poped);
- break;
- }
- case NODE_LAMBDA:{
- /* compile same as lambda{...} */
- VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK);
- VALUE argc = INT2FIX(0);
- ADD_CALL_RECEIVER(ret, nd_line(node));
- ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block);
-
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- break;
- }
- default:
- rb_bug("iseq_compile_each: unknown node: %s", ruby_node_name(type));
- return Qnil;
- }
-
- debug_node_end();
- return COMPILE_OK;
-}
-
-/***************************/
-/* instruction information */
-/***************************/
-
-static int
-insn_data_length(INSN *iobj)
-{
- return insn_len(iobj->insn_id);
-}
-
-static int
-calc_sp_depth(int depth, INSN *insn)
-{
- return insn_stack_increase(depth, insn->insn_id, insn->operands);
-}
-
-static int
-insn_data_line_no(INSN *iobj)
-{
- return insn_len(iobj->line_no);
-}
-
-static VALUE
-insn_data_to_s_detail(INSN *iobj)
-{
- VALUE str = rb_str_new(0, 0);
-
- str = rb_sprintf("%-16s", insn_name(iobj->insn_id));
- if (iobj->operands) {
- char *types = insn_op_types(iobj->insn_id);
- int j;
-
- for (j = 0; types[j]; j++) {
- char type = types[j];
-
- switch (type) {
- case TS_OFFSET: /* label(destination position) */
- {
- char buff[0x100];
- LABEL *lobj = (LABEL *)OPERAND_AT(iobj, j);
- snprintf(buff, sizeof(buff), "<L%03d>", lobj->label_no);
- rb_str_concat(str, rb_str_new2(buff));
- break;
- }
- break;
- case TS_ISEQ: /* iseq */
- {
- rb_iseq_t *iseq = (rb_iseq_t *)OPERAND_AT(iobj, j);
- VALUE val = Qnil;
- if (iseq) {
- val = iseq->self;
- }
- rb_str_concat(str, rb_inspect(val));
- }
- break;
- case TS_LINDEX:
- case TS_DINDEX:
- case TS_NUM: /* ulong */
- case TS_VALUE: /* VALUE */
- rb_str_concat(str, rb_inspect(OPERAND_AT(iobj, j)));
- break;
- case TS_ID: /* ID */
- rb_str_concat(str, rb_inspect(OPERAND_AT(iobj, j)));
- break;
- case TS_GENTRY:
- {
- struct global_entry *entry = (struct global_entry *)
- (OPERAND_AT(iobj, j) & (~1));
- rb_str_cat2(str, rb_id2name(entry->id));
- }
- case TS_IC: /* method cache */
- rb_str_cat2(str, "<ic>");
- break;
- case TS_CDHASH: /* case/when condition cache */
- rb_str_cat2(str, "<ch>");
- break;
- default:{
- rb_raise(rb_eSyntaxError, "unknown operand type: %c", type);
- }
- }
- if (types[j + 1]) {
- rb_str_cat2(str, ", ");
- }
- }
- }
- return str;
-}
-
-static void
-dump_disasm_list(struct iseq_link_element *link)
-{
- int pos = 0;
- INSN *iobj;
- LABEL *lobj;
- VALUE str;
-
- printf("-- raw disasm--------\n");
-
- while (link) {
- switch (link->type) {
- case ISEQ_ELEMENT_INSN:
- {
- iobj = (INSN *)link;
- str = insn_data_to_s_detail(iobj);
- printf("%04d %-65s(%4d)\n", pos, StringValueCStr(str),
- insn_data_line_no(iobj));
- pos += insn_data_length(iobj);
- break;
- }
- case ISEQ_ELEMENT_LABEL:
- {
- lobj = (LABEL *)link;
- printf("<L%03d>\n", lobj->label_no);
- break;
- }
- case ISEQ_ELEMENT_NONE:
- {
- printf("[none]\n");
- break;
- }
- default:
- /* ignore */
- rb_raise(rb_eSyntaxError, "dump_disasm_list error: %ld\n", FIX2LONG(link->type));
- }
- link = link->next;
- }
- printf("---------------------\n");
-}
-
-VALUE
-insns_name_array(void)
-{
- VALUE ary = rb_ary_new();
- int i;
- for (i = 0; i < sizeof(insn_name_info) / sizeof(insn_name_info[0]); i++) {
- rb_ary_push(ary, rb_str_new2(insn_name_info[i]));
- }
- return ary;
-}
-
-static LABEL *
-register_label(rb_iseq_t *iseq, struct st_table *labels_table, VALUE obj)
-{
- LABEL *label = 0;
- st_data_t tmp;
- obj = rb_convert_type(obj, T_SYMBOL, "Symbol", "to_sym");
-
- if (st_lookup(labels_table, obj, &tmp) == 0) {
- label = NEW_LABEL(0);
- st_insert(labels_table, obj, (st_data_t)label);
- }
- else {
- label = (LABEL *)tmp;
- }
- return label;
-}
-
-static VALUE
-get_exception_sym2type(VALUE sym)
-{
- static VALUE symRescue, symEnsure, symRetry;
- static VALUE symBreak, symRedo, symNext;
-
- if (symRescue == 0) {
- symRescue = ID2SYM(rb_intern("rescue"));
- symEnsure = ID2SYM(rb_intern("ensure"));
- symRetry = ID2SYM(rb_intern("retry"));
- symBreak = ID2SYM(rb_intern("break"));
- symRedo = ID2SYM(rb_intern("redo"));
- symNext = ID2SYM(rb_intern("next"));
- }
-
- if (sym == symRescue) return CATCH_TYPE_RESCUE;
- if (sym == symEnsure) return CATCH_TYPE_ENSURE;
- if (sym == symRetry) return CATCH_TYPE_RETRY;
- if (sym == symBreak) return CATCH_TYPE_BREAK;
- if (sym == symRedo) return CATCH_TYPE_REDO;
- if (sym == symNext) return CATCH_TYPE_NEXT;
- rb_raise(rb_eSyntaxError, "invalid exception symbol: %s",
- RSTRING_PTR(rb_inspect(sym)));
- return 0;
-}
-
-static int
-iseq_build_exception(rb_iseq_t *iseq, struct st_table *labels_table,
- VALUE exception)
-{
- int i;
-
- for (i=0; i<RARRAY_LEN(exception); i++) {
- VALUE v, type, *ptr, eiseqval;
- LABEL *lstart, *lend, *lcont;
- int sp;
-
- RB_GC_GUARD(v) = rb_convert_type(RARRAY_PTR(exception)[i], T_ARRAY,
- "Array", "to_ary");
- if (RARRAY_LEN(v) != 6) {
- rb_raise(rb_eSyntaxError, "wrong exception entry");
- }
- ptr = RARRAY_PTR(v);
- type = get_exception_sym2type(ptr[0]);
- if (ptr[1] == Qnil) {
- eiseqval = 0;
- }
- else {
- eiseqval = iseq_load(0, ptr[1], iseq->self, Qnil);
- }
-
- lstart = register_label(iseq, labels_table, ptr[2]);
- lend = register_label(iseq, labels_table, ptr[3]);
- lcont = register_label(iseq, labels_table, ptr[4]);
- sp = NUM2INT(ptr[5]);
-
- ADD_CATCH_ENTRY(type, lstart, lend, eiseqval, lcont);
- }
- return COMPILE_OK;
-}
-
-struct st_table *insn_make_insn_table(void);
-
-static int
-iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
- VALUE body, struct st_table *labels_table)
-{
- /* TODO: body should be freezed */
- VALUE *ptr = RARRAY_PTR(body);
- int len = RARRAY_LEN(body);
- int i, j;
- int line_no = 0;
- /*
- * index -> LABEL *label
- */
- static struct st_table *insn_table;
-
- if (insn_table == 0) {
- insn_table = insn_make_insn_table();
- }
-
- for (i=0; i<len; i++) {
- VALUE obj = ptr[i];
-
- if (SYMBOL_P(obj)) {
- LABEL *label = register_label(iseq, labels_table, obj);
- ADD_LABEL(anchor, label);
- }
- else if (FIXNUM_P(obj)) {
- line_no = NUM2INT(obj);
- }
- else if (TYPE(obj) == T_ARRAY) {
- VALUE *argv = 0;
- int argc = RARRAY_LEN(obj) - 1;
- VALUE insn_id;
- VALUE insn;
-
- insn = (argc < 0) ? Qnil : RARRAY_PTR(obj)[0];
- if (st_lookup(insn_table, insn, &insn_id) == 0) {
- /* TODO: exception */
- RB_GC_GUARD(insn) = rb_inspect(insn);
- rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
- "unknown instruction: %s", RSTRING_PTR(insn));
- }
-
- if (argc != insn_len(insn_id)-1) {
- rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
- "operand size mismatch");
- }
-
- if (argc > 0) {
- argv = compile_data_alloc(iseq, sizeof(VALUE) * argc);
- for (j=0; j<argc; j++) {
- VALUE op = rb_ary_entry(obj, j+1);
- switch (insn_op_type(insn_id, j)) {
- case TS_OFFSET: {
- LABEL *label = register_label(iseq, labels_table, op);
- argv[j] = (VALUE)label;
- break;
- }
- case TS_LINDEX:
- case TS_DINDEX:
- case TS_NUM:
- argv[j] = (NUM2INT(op), op);
- break;
- case TS_VALUE:
- argv[j] = op;
- iseq_add_mark_object(iseq, op);
- break;
- case TS_ISEQ:
- {
- if (op != Qnil) {
- if (TYPE(op) == T_ARRAY) {
- argv[j] = iseq_load(0, op, iseq->self, Qnil);
- }
- else if (CLASS_OF(op) == rb_cISeq) {
- argv[j] = op;
- }
- else {
- rb_raise(rb_eSyntaxError, "ISEQ is required");
- }
- iseq_add_mark_object(iseq, argv[j]);
- }
- else {
- argv[j] = 0;
- }
- }
- break;
- case TS_GENTRY:
- op = rb_convert_type(op, T_SYMBOL, "Symbol", "to_sym");
- argv[j] = (VALUE)rb_global_entry(SYM2ID(op));
- break;
- case TS_IC:
- argv[j] = (VALUE)NEW_INLINE_CACHE_ENTRY();
- iseq_add_mark_object(iseq, argv[j]);
- break;
- case TS_ID:
- argv[j] = rb_convert_type(op, T_SYMBOL,
- "Symbol", "to_sym");
- break;
- case TS_CDHASH:
- {
- int i;
- op = rb_convert_type(op, T_ARRAY, "Array", "to_ary");
- for (i=0; i<RARRAY_LEN(op); i+=2) {
- VALUE sym = rb_ary_entry(op, i+1);
- LABEL *label =
- register_label(iseq, labels_table, sym);
- rb_ary_store(op, i+1, (VALUE)label | 1);
- }
- argv[j] = op;
- }
- break;
- default:
- rb_raise(rb_eSyntaxError, "unknown operand: %c", insn_op_type(insn_id, j));
- }
- }
- }
- ADD_ELEM(anchor,
- (LINK_ELEMENT*)new_insn_core(iseq, line_no,
- insn_id, argc, argv));
- }
- else {
- rb_raise(rb_eTypeError, "unexpected object for instruction");
- }
- }
- st_free_table(labels_table);
- iseq_setup(iseq, anchor);
- return COMPILE_OK;
-}
-
-#define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary")
-#define CHECK_STRING(v) rb_convert_type(v, T_STRING, "String", "to_str")
-#define CHECK_SYMBOL(v) rb_convert_type(v, T_SYMBOL, "Symbol", "to_sym")
-#define CHECK_INTEGER(v) (NUM2LONG(v), v)
-
-VALUE
-iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
- VALUE exception, VALUE body)
-{
- int i;
- int opt = 0;
- ID *tbl;
- struct st_table *labels_table = st_init_numtable();
-
- DECL_ANCHOR(anchor);
-
- INIT_ANCHOR(anchor);
- if (iseq->type == ISEQ_TYPE_METHOD ||
- iseq->type == ISEQ_TYPE_TOP ||
- iseq->type == ISEQ_TYPE_CLASS) {
- opt = 1;
- }
-
- iseq->local_table_size = opt + RARRAY_LEN(locals);
- iseq->local_table = tbl = (ID *)ALLOC_N(ID *, iseq->local_table_size);
- iseq->local_size = opt + iseq->local_table_size;
-
- for (i=0; i<RARRAY_LEN(locals); i++) {
- VALUE lv = RARRAY_PTR(locals)[i];
- tbl[i] = FIXNUM_P(lv) ? FIX2INT(lv) : SYM2ID(CHECK_SYMBOL(lv));
- }
-
- /* args */
- if (FIXNUM_P(args)) {
- iseq->arg_size = iseq->argc = FIX2INT(args);
- iseq->arg_simple = 1;
- }
- else {
- int i = 0;
- VALUE argc = CHECK_INTEGER(rb_ary_entry(args, i++));
- VALUE arg_opts = CHECK_INTEGER(rb_ary_entry(args, i++));
- VALUE arg_opt_labels = CHECK_ARRAY(rb_ary_entry(args, i++));
- VALUE arg_post_len = CHECK_INTEGER(rb_ary_entry(args, i++));
- VALUE arg_post_start = CHECK_INTEGER(rb_ary_entry(args, i++));
- VALUE arg_rest = CHECK_INTEGER(rb_ary_entry(args, i++));
- VALUE arg_block = CHECK_INTEGER(rb_ary_entry(args, i++));
-
- iseq->argc = FIX2INT(argc);
- iseq->arg_opts = FIX2INT(arg_opts);
- iseq->arg_rest = FIX2INT(arg_rest);
- iseq->arg_post_len = FIX2INT(arg_post_len);
- iseq->arg_post_start = FIX2INT(arg_post_start);
- iseq->arg_block = FIX2INT(arg_block);
- iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, iseq->arg_opts);
-
- if (iseq->arg_block != -1) {
- iseq->arg_size = iseq->arg_block + 1;
- }
- else if (iseq->arg_post_len) {
- iseq->arg_size = iseq->arg_post_start + iseq->arg_post_len;
- }
- else if (iseq->arg_rest != -1) {
- iseq->arg_size = iseq->arg_rest + 1;
- }
- else {
- iseq->arg_size = iseq->argc + iseq->arg_opts;
- }
-
- for (i=0; i<RARRAY_LEN(arg_opt_labels); i++) {
- iseq->arg_opt_table[i] =
- (VALUE)register_label(iseq, labels_table,
- rb_ary_entry(arg_opt_labels, i));
- }
- }
-
- /* exception */
- iseq_build_exception(iseq, labels_table, exception);
-
- /* body */
- iseq_build_body(iseq, anchor, body, labels_table);
- return iseq->self;
-}
diff --git a/compile.h b/compile.h
deleted file mode 100644
index 5581a7af2e..0000000000
--- a/compile.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/**********************************************************************
-
- compile.h -
-
- $Author$
- $Date$
- created at: 04/01/01 23:36:57 JST
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#ifndef RUBY_COMPILE_H
-#define RUBY_COMPILE_H
-
-/* */
-/**
- * debug function(macro) interface depend on CPDEBUG
- *
- * debug level:
- * 0: no debug output
- * 1: show node type
- * 2: show node important parameters
- * ...
- * 5: show other parameters
- * 10: show every AST array
- */
-
-#ifndef CPDEBUG
-#define CPDEBUG 0
-#endif
-
-#if 0
-#undef CPDEBUG
-#define CPDEBUG 2
-#endif
-
-NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
-
-#if CPDEBUG > 0
-
-#define debugp(header, value) \
- (ruby_debug_print_indent(0, CPDEBUG, gl_node_level * 2), \
- ruby_debug_print_value(0, CPDEBUG, header, value))
-
-#define debugi(header, id) \
- (ruby_debug_print_indent(0, CPDEBUG, gl_node_level * 2), \
- ruby_debug_print_id(0, CPDEBUG, header, id))
-
-#define debugp_param(header, value) \
- (ruby_debug_print_indent(1, CPDEBUG, gl_node_level * 2), \
- ruby_debug_print_value(1, CPDEBUG, header, value))
-
-#define debugp_verbose(header, value) \
- (ruby_debug_print_indent(2, CPDEBUG, gl_node_level * 2), \
- ruby_debug_print_value(2, CPDEBUG, header, value))
-
-#define debugp_verbose_node(header, value) \
- (ruby_debug_print_indent(10, CPDEBUG, gl_node_level * 2), \
- ruby_debug_print_value(10, CPDEBUG, header, value))
-
-#define debug_node_start(node) \
- (ruby_debug_print_indent(-1, CPDEBUG, gl_node_level*2), \
- ruby_debug_print_node(1, CPDEBUG, "", (NODE *)node), gl_node_level++) \
-
-#define debug_node_end() gl_node_level --;
-
-#else
-
-static inline ID
-r_id(ID id)
-{
- return id;
-}
-
-static inline VALUE
-r_value(VALUE value)
-{
- return value;
-}
-
-#define debugi(header, id) r_id(id)
-#define debugp(header, value) r_value(value)
-#define debugp_verbose(header, value) r_value(value)
-#define debugp_verbose_node(header, value) r_value(value)
-#define debugp_param(header, value) r_value(value)
-#define debug_node_start(node)
-#define debug_node_end()
-#endif
-
-#if CPDEBUG > 1
-#define debugs ruby_debug_print_indent(-1, CPDEBUG, gl_node_level*2), printf
-#define debug_compile(msg, v) (ruby_debug_print_indent(-1, CPDEBUG, gl_node_level*2), printf("%s", msg), (v))
-#else
-#define debugs if(0)printf
-#define debug_compile(msg, v) (v)
-#endif
-
-
-/* create new label */
-#define NEW_LABEL(l) new_label_body(iseq, l)
-
-#define iseq_filename(iseq) \
- (((rb_iseq_t*)DATA_PTR(iseq))->filename)
-
-#define NEW_ISEQVAL(node, name, type) \
- new_child_iseq(iseq, node, name, 0, type)
-
-#define NEW_CHILD_ISEQVAL(node, name, type) \
- new_child_iseq(iseq, node, name, iseq->self, type)
-
-#define NEW_SPECIAQL_BLOCK_ISEQVAL(iseq, sym) \
- new_child_iseq(iseq, iseq->node, iseq->name, iseq->parent_iseq, iseq->type, sym)
-
-/* add instructions */
-#define ADD_SEQ(seq1, seq2) \
- APPEND_LIST(seq1, seq2)
-
-/* add an instruction */
-#define ADD_INSN(seq, line, insn) \
- ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, BIN(insn), 0))
-
-/* add an instruction with label operand */
-#define ADD_INSNL(seq, line, insn, label) \
- ADD_ELEM(seq, (LINK_ELEMENT *) \
- new_insn_body(iseq, line, BIN(insn), 1, (VALUE)label))
-
-/* add an instruction with some operands (1, 2, 3, 5) */
-#define ADD_INSN1(seq, line, insn, op1) \
- ADD_ELEM(seq, (LINK_ELEMENT *) \
- new_insn_body(iseq, line, BIN(insn), 1, (VALUE)op1))
-
-#define ADD_INSN2(seq, line, insn, op1, op2) \
- ADD_ELEM(seq, (LINK_ELEMENT *) \
- new_insn_body(iseq, line, BIN(insn), 2, (VALUE)op1, (VALUE)op2))
-
-#define ADD_INSN3(seq, line, insn, op1, op2, op3) \
- ADD_ELEM(seq, (LINK_ELEMENT *) \
- new_insn_body(iseq, line, BIN(insn), 3, (VALUE)op1, (VALUE)op2, (VALUE)op3))
-
-/* Specific Insn factory */
-#define ADD_SEND(seq, line, id, argc) \
- ADD_SEND_R(seq, line, id, argc, (VALUE)Qfalse, (VALUE)INT2FIX(0))
-
-#define ADD_CALL_RECEIVER(seq, line) \
- ADD_INSN(seq, line, putnil)
-
-#define ADD_CALL(seq, line, id, argc) \
- ADD_SEND_R(seq, line, id, argc, (VALUE)Qfalse, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
-
-#define ADD_CALL_WITH_BLOCK(seq, line, id, argc, block) \
- ADD_SEND_R(seq, line, id, argc, block, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
-
-#define ADD_SEND_R(seq, line, id, argc, block, flag) \
- ADD_ELEM(seq, (LINK_ELEMENT *) \
- new_insn_send(iseq, line, \
- (VALUE)id, (VALUE)argc, (VALUE)block, (VALUE)flag))
-
-#define ADD_TRACE(seq, line, event) \
- if (iseq->compile_data->option->trace_instruction) { \
- ADD_INSN1(seq, line, trace, INT2FIX(event)); \
- }
-
-/* add label */
-#define ADD_LABEL(seq, label) \
- ADD_ELEM(seq, (LINK_ELEMENT *)label)
-
-#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc) \
- (rb_ary_push(iseq->compile_data->catch_table_ary, \
- rb_ary_new3(5, type, \
- (VALUE)(ls) | 1, (VALUE)(le) | 1, \
- iseqv, (VALUE)(lc) | 1)))
-
-/* compile node */
-#define COMPILE(anchor, desc, node) \
- (debug_compile("== " desc "\n", \
- iseq_compile_each(iseq, anchor, node, 0)))
-
-/* compile node, this node's value will be poped */
-#define COMPILE_POPED(anchor, desc, node) \
- (debug_compile("== " desc "\n", \
- iseq_compile_each(iseq, anchor, node, 1)))
-
-/* compile node, which is poped when 'poped' is true */
-#define COMPILE_(anchor, desc, node, poped) \
- (debug_compile("== " desc "\n", \
- iseq_compile_each(iseq, anchor, node, poped)))
-
-#define OPERAND_AT(insn, idx) \
- (((INSN*)(insn))->operands[idx])
-
-#define INSN_OF(insn) \
- (((INSN*)(insn))->insn_id)
-
-/* error */
-#define COMPILE_ERROR(strs) \
-{ \
- VALUE tmp = GET_THREAD()->errinfo; \
- if(CPDEBUG)rb_bug strs; \
- GET_THREAD()->errinfo = iseq->compile_data->err_info; \
- rb_compile_error strs; \
- iseq->compile_data->err_info = GET_THREAD()->errinfo; \
- GET_THREAD()->errinfo = tmp; \
- ret = 0; \
- break; \
-}
-
-#define ERROR_ARGS (node)->nd_file, nd_line(node),
-
-
-#define COMPILE_OK 1
-#define COMPILE_NG 0
-
-
-/* leave name uninitialized so that compiler warn if INIT_ANCHOR is
- * missing */
-#define DECL_ANCHOR(name) \
- LINK_ANCHOR *name, name##_body__ = {{0,},}
-#define INIT_ANCHOR(name) \
- (name##_body__.last = &name##_body__.anchor, name = &name##_body__)
-
-#endif /* RUBY_COMPILE_H */
diff --git a/config.sub b/config.sub
index 463186dbfd..506d3ab77f 100644
--- a/config.sub
+++ b/config.sub
@@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
-timestamp='2004-01-05'
+timestamp='2004-06-11'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -1130,7 +1130,7 @@ case $os in
os=-sysv4.2uw
;;
-gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ os=`echo $os | sed -e 's|gnu/linux|linux|'`
;;
# First accept the basic system types.
# The portable systems comes first.
@@ -1183,7 +1183,7 @@ case $os in
os=-linux-dietlibc
;;
-linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ os=-linux
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
diff --git a/configure.in b/configure.in
index f0cdc2ee5a..5633bc3c44 100644
--- a/configure.in
+++ b/configure.in
@@ -3,25 +3,6 @@ AC_INIT()
AC_PREREQ(2.58)
-AC_ARG_WITH(baseruby,
- [ --with-baseruby=RUBY use RUBY as baseruby; RUBY is the pathname of ruby],
- [
- case "$withval" in
- *ruby*)
- BASERUBY=$withval
- ;;
- *)
- AC_MSG_ERROR(need ruby)
- ;;
- esac
- ],
- [
- BASERUBY="ruby"
- ])
-test "`$BASERUBY -e 'p 42' 2>/dev/null`" = 42 ||
- BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
-AC_SUBST(BASERUBY)
-
AC_DEFUN([RUBY_MINGW32],
[case "$host_os" in
cygwin*)
@@ -63,10 +44,20 @@ 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)
@@ -90,11 +81,11 @@ fi
if test "$program_prefix" = NONE; then
program_prefix=
fi
-
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
@@ -148,6 +139,7 @@ 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;;
@@ -168,7 +160,6 @@ if test x"${build}" != x"${host}"; then
AC_CHECK_TOOL(CC, gcc)
fi
AC_PROG_CC
-AC_PROG_CXX
AC_PROG_GCC_TRADITIONAL
if test "$GCC" = yes; then
linker_flag=-Wl,
@@ -180,12 +171,15 @@ RUBY_PROG_GNU_LD
RUBY_CPPOUTFILE
: ${OUTFLAG='-o '}
-: ${COUTFLAG=${OUTFLAG}}
AC_SUBST(OUTFLAG)
-AC_SUBST(COUTFLAG)
RUBY_MINGW32
+AC_PROG_YACC
+if test "$YACC" = "yacc"; then
+ AC_DEFINE([OLD_YACC])
+fi
+
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(AR, ar)
if test -z "$AR"; then
@@ -210,10 +204,19 @@ cygwin*|mingw*)
AC_TRY_LINK([#include <stdio.h>],
[FILE* volatile f = stdin; return 0;],
[rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
- tr A-Z a-z |
+ tr A-Z a-z |
sed -n '/^[[ ]]*dll name: \(msvc.*\)\.dll$/{s//\1/p;q;}'`],
[rb_cv_msvcrt=msvcrt])
test "$rb_cv_msvcrt" = "" && rb_cv_msvcrt=msvcrt])
+ AC_ARG_WITH(winsock2,
+ [ --with-winsock2 link winsock2 (MinGW only)], [
+ case $withval in
+ yes) with_winsock2=yes;;
+ *) with_winsock2=no;;
+ esac], [with_winsock2=no])
+ if test "$with_winsock2" = yes; then
+ AC_DEFINE(USE_WINSOCK2)
+ fi
esac
: ${enable_shared=yes}
;;
@@ -237,11 +240,10 @@ AC_MINIX
AC_SUBST(RM, ['rm -f'])
AC_SUBST(CP, ['cp'])
if $as_mkdir_p; then
- MAKEDIRS='mkdir -p'
+ AC_SUBST(MAKEDIRS, ['mkdir -p'])
else
- MAKEDIRS='install -d'
+ AC_SUBST(MAKEDIRS, ['install -d'])
fi
-AC_SUBST(MAKEDIRS)
dnl check for large file stuff
mv confdefs.h confdefs1.h
@@ -251,13 +253,6 @@ mv confdefs.h largefile.h
mv confdefs1.h confdefs.h
cat largefile.h >> confdefs.h
-case "$target_os" in
-mingw*)
- ac_cv_type_off_t=yes
- ac_cv_sizeof_off_t=8
- ;;
-esac
-
AC_CHECK_TYPES([long long, off_t])
AC_CHECK_SIZEOF(int, 4)
@@ -271,40 +266,10 @@ AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
AC_CHECK_SIZEOF(time_t, 0)
-dnl RUBY_REPLACE_TYPE [typename] [default type] [macro type] [included]
-AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
- AC_CHECK_TYPE([$1],
- [AC_DEFINE_UNQUOTED(rb_[$1], [$1])],
- [AC_DEFINE_UNQUOTED(rb_[$1], [$2])],
- [$4])
- AC_CACHE_CHECK([for convertible type of [$1]], rb_cv_[$1]_convertible, [
- u= t=
- AC_COMPILE_IFELSE(
- [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
- [$4], [(rb_[$1])-1 > 0])],
- [u=U])
- if test x"$t" = x; then
- AC_COMPILE_IFELSE(
- [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
- [$4], [sizeof(rb_[$1]) > sizeof(long)])],
- [t=LL])
- fi
- if test x"$t" = x; then
- AC_COMPILE_IFELSE(
- [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT]
- [$4], [sizeof(rb_[$1]) == sizeof(long)])],
- [t=LONG])
- fi
- if test x"$t" = x; then
- t=INT
- fi
- rb_cv_[$1]_convertible=${u}${t}])
- AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
- AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
-])
-RUBY_REPLACE_TYPE(pid_t, int, PIDT)
-RUBY_REPLACE_TYPE(uid_t, int, UIDT)
-RUBY_REPLACE_TYPE(gid_t, int, GIDT)
+for id in pid_t gid_t uid_t; do
+ AC_CHECK_TYPE($id, [typ=$id], [typ=int])
+ AC_DEFINE_UNQUOTED(rb_$id, $typ)
+done
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
@@ -325,41 +290,6 @@ else
AC_DEFINE(TOKEN_PASTE(x,y),[x/**/y])
fi
-AC_CACHE_CHECK(stringization, rb_cv_stringization, [
- rb_cv_stringization=no
- for string in "#expr" '"expr"'; do
- AC_COMPILE_IFELSE([
- AC_LANG_BOOL_COMPILE_TRY([
-#define STRINGIZE0(expr) $string
-#define STRINGIZE(expr) STRINGIZE0(expr)
-#undef real_test_for_stringization
-#define test_for_stringization -.real_test_for_stringization.-
-const char stringized[[]] = STRINGIZE(test_for_stringization);
-], [sizeof(stringized) == 32])],
- [rb_cv_stringization="$string"; break],
- [rb_cv_stringization=no])
- done]
-)
-AC_DEFINE(STRINGIZE(expr),STRINGIZE0(expr))
-if test x"$rb_cv_stringization" != xno -a "$rb_cv_stringization" != "#expr"; then
- AC_DEFINE_UNQUOTED(STRINGIZE0(expr),$rb_cv_stringization)
- AC_DEFINE(OLD_FASHIONED_STRINGIZATION,1)
-fi
-
-AC_CACHE_CHECK([string literal concatenation],
- rb_cv_string_literal_concatenation, [
- AC_COMPILE_IFELSE([
- AC_LANG_BOOL_COMPILE_TRY([
-const char concatenated_literal[[]] = "literals" "to"
- "be" "concatenated.";
-], [sizeof(concatenated_literal) == 26])],
- [rb_cv_string_literal_concatenation=yes],
- [rb_cv_string_literal_concatenation=no])]
-)
-if test "$rb_cv_string_literal_concatenation" = no; then
- AC_DEFINE(NO_STRING_LITERAL_CONCATENATION,1)
-fi
-
AC_CACHE_CHECK(for variable length prototypes and stdarg.h, rb_cv_stdarg,
[AC_TRY_COMPILE([
#include <stdarg.h>
@@ -413,11 +343,7 @@ AS_VAR_POPDEF([rbcv])
])
RUBY_FUNC_ATTRIBUTE(noreturn, NORETURN)
-RUBY_FUNC_ATTRIBUTE(deprecated, DEPRECATED)
RUBY_FUNC_ATTRIBUTE(noinline, NOINLINE)
-RUBY_FUNC_ATTRIBUTE(stdcall)
-RUBY_FUNC_ATTRIBUTE(cdecl)
-RUBY_FUNC_ATTRIBUTE(fastcall)
AC_CACHE_CHECK([for RUBY_EXTERN], rb_cv_ruby_extern,
[rb_cv_ruby_extern=no
@@ -434,50 +360,57 @@ dnl Check whether we need to define sys_nerr locally
AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
#include <errno.h>])
-case "$target_os" in
-freebsd*)
- AC_CACHE_CHECK([whether pthread should be enabled by default],
- rb_cv_enable_pthread_default,
- [AC_TRY_CPP([
-#include <osreldate.h>
-#if __FreeBSD_version < 502102
-#error pthread should be disabled on this platform
-#endif
- ],
- rb_cv_enable_pthread_default=yes,
- rb_cv_enable_pthread_default=no)])
- enable_pthread_default=$rb_cv_enable_pthread_default
- ;;
-mingw*)
- enable_pthread_default=no
- ;;
-*)
- enable_pthread_default=yes
- ;;
-esac
+dnl whether link libc_r or not
+AC_ARG_WITH(libc_r,
+ [ --with-libc_r link libc_r if possible (FreeBSD only)], [
+ case $withval in
+ yes) with_libc_r=yes;;
+ *) with_libc_r=no;;
+ esac], [with_libc_r=no])
AC_ARG_ENABLE(pthread,
[ --enable-pthread use pthread library.],
- [enable_pthread=$enableval], [enable_pthread=$enable_pthread_default])
+ [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";;
+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)
+ ])
+ ;;
hpux*) LIBS="-lm $LIBS"
ac_cv_c_inline=no;;
human*) ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
;;
beos*) ac_cv_func_link=no;;
-cygwin*) rb_cv_have_daylight=no
- ac_cv_var_tzname=no
- ac_cv_func__setjmp=no
- ac_cv_func_setitimer=no
- ;;
-mingw*) LIBS="-lshell32 -lws2_32 $LIBS"
+cygwin*) ;;
+mingw*) if test "$with_winsock2" = yes; then
+ LIBS="-lws2_32 $LIBS"
+ else
+ LIBS="-lwsock32 $LIBS"
+ fi
+ LIBS="-lshell32 $LIBS"
ac_cv_header_a_out_h=no
ac_cv_header_pwd_h=no
ac_cv_header_utime_h=no
@@ -490,7 +423,6 @@ mingw*) LIBS="-lshell32 -lws2_32 $LIBS"
ac_cv_func_times=yes
ac_cv_func_waitpid=yes
ac_cv_func_fsync=yes
- ac_cv_func_snprintf=yes
ac_cv_func_vsnprintf=yes
ac_cv_func_seekdir=yes
ac_cv_func_telldir=yes
@@ -498,9 +430,6 @@ mingw*) LIBS="-lshell32 -lws2_32 $LIBS"
ac_cv_func_isnan=yes
ac_cv_func_finite=yes
ac_cv_func_link=yes
- ac_cv_func_truncate=yes
- ac_cv_func_fseeko=yes
- ac_cv_func_ftello=yes
ac_cv_lib_crypt_crypt=no
ac_cv_func_getpgrp_void=no
ac_cv_func_setpgrp_void=yes
@@ -508,6 +437,7 @@ mingw*) LIBS="-lshell32 -lws2_32 $LIBS"
ac_cv_lib_dl_dlopen=no
rb_cv_binary_elf=no
rb_cv_negative_time_t=no
+ enable_pthread=no
ac_cv_func_fcntl=yes
;;
os2-emx*) LIBS="-lm $LIBS"
@@ -515,11 +445,12 @@ os2-emx*) LIBS="-lm $LIBS"
msdosdjgpp*) LIBS="-lm $LIBS"
ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
- ac_cv_sizeof_rlim_t=4
- ac_cv_func_fork=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],
@@ -537,6 +468,22 @@ freebsd*) LIBS="-lm $LIBS"
if test "$rb_cv_lib_xpg4_needed" = yes; then
AC_CHECK_LIB(xpg4, setlocale)
fi
+ if test "$with_libc_r" = yes; then
+ AC_CACHE_CHECK([whether libc_r is supplementary to libc],
+ rb_cv_supplementary_lib_c_r,
+ [AC_TRY_CPP([
+#include <osreldate.h>
+#if 500016 <= __FreeBSD_version
+#error libc_r is supplementary to libc
+#endif
+ ],
+ rb_cv_supplementary_lib_c_r=no,
+ rb_cv_supplementary_lib_c_r=yes,
+ rb_cv_supplementary_lib_c_r=yes)])
+ if test "$rb_cv_supplementary_lib_c_r" = yes; then
+ MAINLIBS="-lc_r $MAINLIBS"
+ fi
+ fi
;;
dragonfly*) LIBS="-lm $LIBS"
;;
@@ -544,12 +491,16 @@ bow) ac_cv_func_setitimer=no
;;
superux*) ac_cv_func_setitimer=no
;;
+solaris*2.1*) if test -z "$GCC"; then
+ ac_cv_func_isinf=yes
+ fi
+ LIBS="-lm $LIBS"
+ ;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
-AC_CHECK_LIB(socket, socketpair) # SunOS/Solaris
AC_CHECK_LIB(rt, clock_gettime) # GNU/Linux
case "$target_cpu" in
@@ -567,7 +518,7 @@ AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h sys/
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
sys/mkdev.h sys/utime.h netinet/in_systm.h float.h ieeefp.h pthread.h \
- ucontext.h intrinsics.h langinfo.h locale.h)
+ ucontext.h intrinsics.h)
dnl Check additional types.
AC_CHECK_SIZEOF(rlim_t, 0, [
@@ -591,31 +542,6 @@ AC_TYPE_SIZE_T
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_RDEV
-AC_CHECK_MEMBERS([struct stat.st_atim])
-AC_CHECK_MEMBERS([struct stat.st_atimespec])
-AC_CHECK_MEMBERS([struct stat.st_atimensec])
-AC_CHECK_MEMBERS([struct stat.st_mtim])
-AC_CHECK_MEMBERS([struct stat.st_mtimespec])
-AC_CHECK_MEMBERS([struct stat.st_mtimensec])
-AC_CHECK_MEMBERS([struct stat.st_ctim])
-AC_CHECK_MEMBERS([struct stat.st_ctimespec])
-AC_CHECK_MEMBERS([struct stat.st_ctimensec])
-
-AC_CHECK_TYPES(struct timespec)
-
-AC_CHECK_TYPE(fd_mask, [AC_DEFINE(HAVE_RB_FD_INIT, 1)])
-
-AC_CACHE_CHECK(for stack end address, rb_cv_stack_end_address,
-[rb_cv_stack_end_address=no
-for addr in __libc_stack_end _SEND; do
- AC_TRY_LINK(
- [extern void *$addr;],
- [if (!$addr) return 1;],
- [rb_cv_stack_end_address="$addr"; break])
-done])
-if test $rb_cv_stack_end_address != no; then
- AC_DEFINE_UNQUOTED(STACK_END_ADDRESS, $rb_cv_stack_end_address)
-fi
dnl Checks for library functions.
AC_TYPE_GETGROUPS
@@ -632,20 +558,92 @@ powerpc-darwin*)
;;
esac
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_broken_glibc_ia64_erfc,
+ [AC_TRY_RUN([
+#include <math.h>
+int
+main()
+{
+ erfc(10000.0);
+ return 0;
+}
+],
+ rb_broken_glibc_ia64_erfc=no,
+ rb_broken_glibc_ia64_erfc=yes,
+ rb_broken_glibc_ia64_erfc=no)])
+case $rb_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 strlcpy strlcat)
-AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd eaccess\
- truncate chsize times utimes utimensat fcntl lockf lstat\
- link symlink readlink\
- setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
- setrgid setegid setregid setresgid issetugid pause lchown lchmod\
- getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
- getpriority getrlimit setrlimit sysconf group_member\
- dlopen sigprocmask sigaction _setjmp vsnprintf snprintf\
- setsid telldir seekdir fchmod cosh sinh tanh log2 round\
- setuid setgid daemon select_large_fdset setenv unsetenv\
- mktime timegm clock_gettime gettimeofday)
+ isnan finite isinf hypot acosh erf)
+AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd eaccess\
+ truncate ftruncate chsize times utimes fcntl lockf lstat symlink link\
+ readlink setitimer setruid seteuid setreuid setresuid\
+ setproctitle setrgid setegid setregid setresgid issetugid pause\
+ lchown lchmod getpgrp setpgrp getpgid setpgid initgroups\
+ getgroups setgroups getpriority getrlimit setrlimit sysconf\
+ group_member dlopen sigprocmask\
+ sigaction sigsetjmp _setjmp _longjmp 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])
@@ -674,15 +672,23 @@ fi
AC_DEFUN([RUBY_CHECK_VARTYPE], [dnl
AC_CACHE_CHECK([for external $1], rb_cv_var_$1,
[rb_cv_var_$1=no
- AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
- $2
- const volatile void *volatile t;],
+ AC_TRY_COMPILE([
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 1
+#endif
+$2
+;
+const volatile void *volatile t;],
[t = &(&$1)[0];],
[for t in $3; do
- AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
- $2
- extern $t $1;
- const volatile void *volatile t;],
+ AC_TRY_COMPILE([
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 1
+#endif
+$2
+;
+extern $t $1;
+const volatile void *volatile t;],
[t = &(&$1)[0];],
[rb_cv_var_$1=$t; break])
done])])
@@ -690,13 +696,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
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])]
@@ -748,6 +754,7 @@ fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
else
+ AC_CHECK_FUNCS(sigsetmask)
AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
[AC_TRY_RUN([
#include <stdio.h>
@@ -770,7 +777,7 @@ main()
],
rb_cv_bsd_signal=yes,
rb_cv_bsd_signal=no,
- rb_cv_bsd_signal=no)])
+ rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
if test "$rb_cv_bsd_signal" = yes; then
AC_DEFINE(BSD_SIGNAL)
fi
@@ -884,6 +891,69 @@ else
fi
fi
+AC_DEFUN([RUBY_CHECK_IO_NEED],
+[AC_CACHE_CHECK(whether need to [$1], [$2],
+ [AC_TRY_RUN([
+#include <stdio.h>
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+#define before_seek(f) ]ifelse(index($2,flush_before_seek),-1,[fflush(f)],[(f,0)])[
+#define reset_rw(f) ]ifelse(index($2,seek_between_rw),-1,[do_seek(f,SEEK_CUR)],[(f,0)])[
+#define do_seek(f, w) (before_seek(f), fseek(f,0,w))
+
+char *fn = "conftest.dat";
+char *wombat = "wombat\n";
+char *koara = "koara\n";
+char *kangaroo = "kangaroo\n";
+
+int main()
+{
+ char buf[BUFSIZ];
+ FILE *f;
+ int r = 1;
+
+ if (!(f = fopen(fn, "w+"))) return 1;
+ fputs(wombat, f);
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ reset_rw(f);
+ fputs(koara, f);
+ fputs(kangaroo, f);
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ reset_rw(f);
+ fputc('X', f);
+ reset_rw(f);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara+1)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || buf[0] != 'X' || strcmp(buf+1, koara+1)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
+ r = 0;
+ fail:
+ fclose(f);
+ unlink(fn);
+ return r;
+}
+], [$2]=no, [$2]=yes, [$2]=[$3])])])
+RUBY_CHECK_IO_NEED(seek between R/W, rb_cv_need_io_seek_between_rw, yes)
+if test "$rb_cv_need_io_seek_between_rw" = yes; then
+ AC_DEFINE(NEED_IO_SEEK_BETWEEN_RW, 1)
+fi
+dnl RUBY_CHECK_IO_NEED(flush before seek, rb_cv_need_io_flush_before_seek, no)
+dnl if test "$rb_cv_need_io_flush_before_seek" = yes; then
+dnl AC_DEFINE(NEED_IO_FLUSH_BEFORE_SEEK, 1)
+dnl fi
+
AC_CACHE_CHECK([whether st_ino is huge], rb_cv_huge_st_ino,
[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([
#include <sys/stat.h>
@@ -938,7 +1008,7 @@ int main()
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
if test x"$enable_pthread" = xyes; then
- for pthread_lib in thr pthread pthreads c c_r; do
+ for pthread_lib in pthread pthreads c c_r; do
AC_CHECK_LIB($pthread_lib, pthread_kill,
rb_with_pthread=yes, rb_with_pthread=no)
if test "$rb_with_pthread" = "yes"; then break; fi
@@ -974,11 +1044,19 @@ if test x"$ac_cv_header_ucontext_h" = xyes; then
fi
fi
-AC_CHECK_FUNCS(backtrace)
-
-AC_ARG_WITH(valgrind,
- [ --with-valgrind enable valgrind memcheck support.],
- [AC_CHECK_HEADERS(valgrind/memcheck.h)])
+dnl default value for $KANJI
+DEFAULT_KCODE="KCODE_NONE"
+
+AC_ARG_WITH(default-kcode,
+ [ --with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
+ [case $withval in
+ utf8) DEFAULT_KCODE="KCODE_UTF8";;
+ euc) DEFAULT_KCODE="KCODE_EUC";;
+ sjis) DEFAULT_KCODE="KCODE_SJIS";;
+ none) DEFAULT_KCODE="KCODE_NONE";;
+ *) AC_MSG_WARN($withval is not valid kcode; ignored);;
+ esac])
+AC_DEFINE_UNQUOTED(DEFAULT_KCODE, $DEFAULT_KCODE)
dnl wheather use dln_a_out or not
AC_ARG_WITH(dln-a-out,
@@ -1030,7 +1108,6 @@ AC_SUBST(ARCH_FLAG)dnl
AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
AC_SUBST(LDSHARED)dnl
-AC_SUBST(LDSHAREDXX)dnl
AC_SUBST(DLEXT)dnl
AC_SUBST(DLEXT2)dnl
AC_SUBST(LIBEXT)dnl
@@ -1061,11 +1138,23 @@ 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'}
@@ -1136,11 +1225,11 @@ if test "$with_dln_a_out" != yes; then
LDSHARED="$LDSHARED ${linker_flag}-G"
DLDFLAGS='-eInit_$(TARGET)'
XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
- : ${ARCHFILE="ruby.imp"}
+ : ${ARCHFILE="ruby.imp"}
TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
- : ${LIBPATHENV=SHLIB_PATH}
- rb_cv_dlopen=yes ;;
+ : ${LIBPATHENV=SHLIB_PATH}
+ rb_cv_dlopen=yes ;;
human*) : ${DLDFLAGS=''}
: ${LDSHARED=''}
: ${LDFLAGS=''}
@@ -1163,7 +1252,7 @@ if test "$with_dln_a_out" != yes; then
LDFLAGS="$LDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
rb_cv_dlopen=yes;;
cygwin*|mingw*) : ${LDSHARED="${CC} -shared -s"}
- XLDFLAGS="$XLDFLAGS -Wl,--stack,0x00200000"
+ XLDFLAGS="$XLDFLAGS -Wl,--stack,0x02000000"
DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
: ${LIBPATHENV=""}
rb_cv_dlopen=yes ;;
@@ -1175,31 +1264,7 @@ 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"
- RPATHFLAG=" ${linker_flag}-R%1\$-s"
- fi
fi
-if test "${LDSHAREDXX}" = ""; then
- case "${LDSHARED}" in
- *'$(CC)'*)
- LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\$(CC)/$(CXX)/'`
- ;;
- *'${CC}'*)
- LDSHAREDXX=`echo "${LDSHARED}" | sed 's/\${CC}/${CXX}/'`
- ;;
- *$CC*)
- LDSHAREDXX=`echo "${LDSHARED}" | sed "s|$CC|$CXX|"`
- ;;
- ld" "*)
- ;;
- esac
-fi
-
AC_SUBST(LINK_SO)
AC_SUBST(LIBPATHFLAG)
AC_SUBST(RPATHFLAG)
@@ -1236,12 +1301,11 @@ if test "$dln_a_out_works" = yes; then
else
case "$target_os" in
hpux*) DLEXT=sl;;
- nextstep*) DLEXT=bundle;;
- openstep*) DLEXT=bundle;;
- rhapsody*) DLEXT=bundle;;
- darwin*) DLEXT=bundle;;
+ nextstep*|openstep*|rhapsody*|darwin*)
+ DLEXT=bundle;;
os2-emx*) DLEXT=dll;;
- cygwin*|mingw*) DLEXT=so;;
+ cygwin*|mingw*)
+ DLEXT=so DLEXT2=dll;;
*) DLEXT=so;;
esac
fi
@@ -1251,7 +1315,6 @@ 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(DLEXT)
AC_SUBST(STRIP)dnl
if test "$with_dln_a_out" = yes; then
@@ -1360,14 +1423,15 @@ if test x"$cross_compiling" = xyes; then
PREP=fake.rb
RUNRUBY='$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`'
else
- MINIRUBY='./miniruby$(EXEEXT)'
+ MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib'
+ MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common -I./- -r$(srcdir)/ext/purelib.rb'
PREP='miniruby$(EXEEXT)'
RUNRUBY='$(MINIRUBY) $(srcdir)/runruby.rb --extout=$(EXTOUT)'
fi
AC_SUBST(MINIRUBY)
AC_SUBST(PREP)
AC_SUBST(RUNRUBY)
-AC_SUBST(EXTOUT, [${EXTOUT=.ext}])
+AC_SUBST(EXTOUT, [${EXTOUT-.ext}])
FIRSTMAKEFILE=""
LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
@@ -1483,17 +1547,13 @@ AC_SUBST(ARCHFILE)
dnl build rdoc index if requested
RDOCTARGET=""
AC_ARG_ENABLE(install-doc,
- [ --disable-install-doc do not install rdoc indexes during install ],
- [install_doc=$enableval], [install_doc=yes])
+ [ --enable-install-doc build and install rdoc indexes during install ],
+ [install_doc=$enableval], [install_doc=no])
if test "$install_doc" != no; then
RDOCTARGET="install-doc"
fi
AC_SUBST(RDOCTARGET)
-if test "$rb_with_pthread" = "yes"; then
- THREAD_MODEL=pthread
-fi
-MINIDLNOBJ=dln.o
case "$target_os" in
linux*)
XCFLAGS="$XCFLAGS -D_GNU_SOURCE=1"
@@ -1517,7 +1577,7 @@ case "$target_os" in
;;
darwin*)
CFLAGS="$CFLAGS -pipe -fno-common"
- MINIDLNOBJ=dmydln.o
+ MINIOBJS=dmydln.o
;;
os2-emx)
CFLAGS="$CFLAGS -DOS2 -Zmts"
@@ -1549,38 +1609,35 @@ case "$target_os" in
esac
;;
cygwin*|mingw*)
- LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
case "$target_os" in
cygwin*)
if test x"$enable_shared" = xyes; then
- LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}${TEENY}.dll
+ LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}.dll
+ LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
fi
- AC_LIBOBJ([strftime])
;;
mingw*)
- RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}${TEENY}
+ RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
if test x"$enable_shared" = xyes; then
LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
- LIBRUBY_DLDFLAGS="${LIBRUBY_DLDFLAGS}"' $(RUBYDEF)'
+ LIBRUBY='lib$(LIBRUBY_SO).a'
fi
AC_LIBOBJ([win32])
COMMON_LIBS=m
# COMMON_MACROS="WIN32_LEAN_AND_MEAN="
- COMMON_HEADERS="winsock2.h windows.h"
- THREAD_MODEL=win32
+ COMMON_HEADERS="windows.h winsock.h"
;;
esac
+ LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
LIBRUBY_ALIASES=''
FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
SOLIBS='$(LIBS)'
- if test x"$enable_shared" = xyes; then
- LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
- else
+ if test x"$enable_shared" = xno; then
LIBRUBY_SO=dummy
LIBRUBY='lib$(RUBY_SO_NAME).a'
LIBRUBYARG='-l$(RUBY_SO_NAME)'
fi
- MINIDLNOBJ=dmydln.o
+ MINIOBJS=dmydln.o
;;
hpux*)
case "$YACC" in
@@ -1589,12 +1646,11 @@ case "$target_os" in
YACC="$YACC -Nl40000 -Nm40000"
;;
esac
- MINIDLNOBJ=dmydln.o
+ MINIOBJS=dmydln.o
;;
*)
;;
esac
-MINIOBJS="$MINIDLNOBJ"
case "$build_os" in
*msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
@@ -1604,7 +1660,7 @@ 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(cflags, ['${optflags} ${debugflags}'])dnl
AC_SUBST(optflags)dnl
AC_SUBST(debugflags)dnl
AC_SUBST(XCFLAGS)dnl
@@ -1631,7 +1687,6 @@ AC_SUBST(COMMON_MACROS)
AC_SUBST(COMMON_HEADERS)
AC_SUBST(EXPORT_PREFIX)
AC_SUBST(MINIOBJS)
-AC_SUBST(THREAD_MODEL)
MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
MAKEFILES="`echo $MAKEFILES`"
@@ -1652,47 +1707,45 @@ case "$target_os" in
rubyw_install_name="$RUBYW_INSTALL_NAME"
;;
esac
-case "$target_os" in
- cygwin*|mingw*|*djgpp*|os2-emx*)
- RUBY_LIB_PREFIX="/lib/ruby"
- ;;
- *)
- RUBY_LIB_PREFIX="${prefix}/lib/ruby"
- ;;
-esac
-RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}.${TEENY}"
+RUBY_LIB_PREFIX=`eval echo \\"${libdir}/ruby\\"`
AC_ARG_WITH(sitedir,
- [ --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
+ [ --with-sitedir=DIR site libraries in DIR [[LIBDIR/ruby/site_ruby]]],
[sitedir=$withval],
- [sitedir='${prefix}/lib/ruby/site_ruby'])
+ [sitedir='${libdir}/ruby/site_ruby'])
SITE_DIR=`eval echo \\"${sitedir}\\"`
+
case "$target_os" in
cygwin*|mingw*|*djgpp*|os2-emx*)
- RUBY_SITE_LIB_PATH="`expr "$SITE_DIR" : "$prefix\(/.*\)"`" ||
- RUBY_SITE_LIB_PATH="$SITE_DIR";;
+ 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_SITE_LIB_PATH="$SITE_DIR";;
+ RUBY_LIB_PREFIX="`eval echo \\"$RUBY_LIB_PREFIX\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+ RUBY_SITE_LIB_PATH="`eval echo \\"$SITE_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+ ;;
esac
-RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}.${TEENY}"
+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 [PREFIX/lib/ruby/vendor_ruby]],
+ [ --with-vendordir=DIR vendor libraries in DIR [[LIBDIR/ruby/vendor_ruby]]],
[vendordir=$withval],
- [vendordir='${prefix}/lib/ruby/vendor_ruby'])
+ [vendordir='${libdir}/ruby/vendor_ruby'])
VENDOR_DIR=`eval echo \\"${vendordir}\\"`
case "$target_os" in
cygwin*|mingw*|*djgpp*|os2-emx*)
- RUBY_VENDOR_LIB_PATH="`expr "$VENDOR_DIR" : "$prefix\(/.*\)"`" ||
- RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+ RUBY_VENDOR_LIB_PATH="`eval echo "$VENDOR_DIR" | sed 's|^NONE/|/|;s|^'"$prefix"'/|/|'`"
+ ;;
*)
- RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+ RUBY_VENDOR_LIB_PATH="`eval echo \\"$VENDOR_DIR\\" | sed 's|^NONE/|'"$prefix"'/|'`"
+ ;;
esac
-RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}.${TEENY}"
+RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}"
AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
@@ -1722,7 +1775,7 @@ else
fi
case "$target_os" in
- mingw*) sitearch="i386-$rb_cv_msvcrt" ;;
+ mingw*) sitearch="$target_cpu-$rb_cv_msvcrt" ;;
*) sitearch="${arch}" ;;
esac
@@ -1737,25 +1790,6 @@ if test "$search_path" != ""; then
AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
fi
-AC_ARG_WITH(rubyhdrdir,
- [ --with-ruby-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
- [rubyhdrdir=$withval],
- [rubyhdrdir='${includedir}/ruby-${MAJOR}.${MINOR}.${TEENY}'])
-
-AC_ARG_WITH(sitehdrdir,
- [ --with-site-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
- [sitehdrdir=$withval],
- [sitehdrdir='${rubyhdrdir}/site_ruby'])
-
-AC_ARG_WITH(vendorhdrdir,
- [ --with-vendor-hdrdir=DIR core headers in DIR [INCLUDEDIR]],
- [vendorhdrdir=$withval],
- [vendorhdrdir='${rubyhdrdir}/vendor_ruby'])
-
-AC_SUBST(rubyhdrdir)dnl
-AC_SUBST(sitehdrdir)dnl
-AC_SUBST(vendorhdrdir)dnl
-
AC_ARG_WITH(mantype,
[ --with-mantype=TYPE specify man page type; TYPE is one of man and doc],
[
@@ -1778,23 +1812,14 @@ if test -z "$MANTYPE"; then
fi
AC_SUBST(MANTYPE)
-arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
-$MAKEDIRS "${arch_hdrdir}"
-config_h="${arch_hdrdir}/config.h"
-if test -f "${config_h}" && tr -d '\015' < confdefs.h | cmp -s "${config_h}" -; then
+if test -f config.h && tr -d '\015' < confdefs.h | cmp -s config.h -; then
echo "config.h unchanged"
else
echo "creating config.h"
- tr -d '\015' < confdefs.h > "${config_h}"
+ tr -d '\015' < confdefs.h > config.h
fi
tr -d '\015' < largefile.h > confdefs.h
-
-BUILTIN_ENCS=["`sed -n -e '/^BUILTIN_ENCS[ ]*=/{' \
- -e s/// -e :l -e '/\\\\$/N' -e 's/\\\\\\n/ /' -e 't l' -e p \
- -e '}' "${srcdir}/enc/Makefile.in"`"]
-BUILTIN_ENCOBJS=
-for e in $BUILTIN_ENCS; do BUILTIN_ENCOBJS="$BUILTIN_ENCOBJS `basename $e .c`"'.$(OBJEXT)'; done
-AC_SUBST(BUILTIN_ENCOBJS)
+rm largefile.h
AC_CONFIG_FILES($FIRSTMAKEFILE)
AC_CONFIG_FILES(Makefile, [{
diff --git a/cont.c b/cont.c
deleted file mode 100644
index 43b0ea77f2..0000000000
--- a/cont.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/**********************************************************************
-
- cont.c -
-
- $Author$
- $Date$
- created at: Thu May 23 09:03:43 2007
-
- Copyright (C) 2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-#include "vm_core.h"
-#include "gc.h"
-#include "eval_intern.h"
-
-enum context_type {
- CONTINUATION_CONTEXT = 0,
- FIBER_CONTEXT = 1,
- ROOT_FIBER_CONTEXT = 2,
-};
-
-typedef struct rb_context_struct {
- VALUE self;
- VALUE value;
- VALUE *vm_stack;
- VALUE *machine_stack;
- VALUE *machine_stack_src;
-#ifdef __ia64
- VALUE *machine_register_stack;
- VALUE *machine_register_stack_src;
- int machine_register_stack_size;
-#endif
- rb_thread_t saved_thread;
- rb_jmpbuf_t jmpbuf;
- int machine_stack_size;
- VALUE prev;
- int alive;
- enum context_type type;
-} rb_context_t;
-
-static VALUE rb_cContinuation;
-static VALUE rb_cFiber;
-static VALUE rb_eFiberError;
-
-#define GetContPtr(obj, ptr) \
- Data_Get_Struct(obj, rb_context_t, ptr)
-
-NOINLINE(static VALUE cont_capture(volatile int *stat));
-
-void rb_thread_mark(rb_thread_t *th);
-
-static void
-cont_mark(void *ptr)
-{
- RUBY_MARK_ENTER("cont");
- if (ptr) {
- rb_context_t *cont = ptr;
- rb_gc_mark(cont->value);
- rb_gc_mark(cont->prev);
- rb_thread_mark(&cont->saved_thread);
-
- if (cont->vm_stack) {
- rb_gc_mark_locations(cont->vm_stack,
- cont->vm_stack + cont->saved_thread.stack_size);
- }
-
- if (cont->machine_stack) {
- rb_gc_mark_locations(cont->machine_stack,
- cont->machine_stack + cont->machine_stack_size);
- }
-#ifdef __ia64
- if (cont->machine_register_stack) {
- rb_gc_mark_locations(cont->machine_register_stack,
- cont->machine_register_stack + cont->machine_register_stack_size);
- }
-#endif
- }
- RUBY_MARK_LEAVE("cont");
-}
-
-static void
-cont_free(void *ptr)
-{
- RUBY_FREE_ENTER("cont");
- if (ptr) {
- rb_context_t *cont = ptr;
- RUBY_FREE_UNLESS_NULL(cont->saved_thread.stack);
- RUBY_FREE_UNLESS_NULL(cont->machine_stack);
-#ifdef __ia64
- RUBY_FREE_UNLESS_NULL(cont->machine_register_stack);
-#endif
- RUBY_FREE_UNLESS_NULL(cont->vm_stack);
-
- if (cont->type == FIBER_CONTEXT) {
- st_free_table(cont->saved_thread.local_storage);
- }
-
- ruby_xfree(ptr);
- }
- RUBY_FREE_LEAVE("cont");
-}
-
-static void
-cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
-{
- int size;
- rb_thread_t *sth = &cont->saved_thread;
-
- SET_MACHINE_STACK_END(&th->machine_stack_end);
-#ifdef __ia64
- th->machine_register_stack_end = rb_ia64_bsp();
-#endif
-
- if (th->machine_stack_start > th->machine_stack_end) {
- size = cont->machine_stack_size = th->machine_stack_start - th->machine_stack_end;
- cont->machine_stack_src = th->machine_stack_end;
- }
- else {
- size = cont->machine_stack_size = th->machine_stack_end - th->machine_stack_start;
- cont->machine_stack_src = th->machine_stack_start;
- }
-
- if (cont->machine_stack) {
- REALLOC_N(cont->machine_stack, VALUE, size);
- }
- else {
- cont->machine_stack = ALLOC_N(VALUE, size);
- }
-
- FLUSH_REGISTER_WINDOWS;
- MEMCPY(cont->machine_stack, cont->machine_stack_src, VALUE, size);
-
-#ifdef __ia64
- rb_ia64_flushrs();
- size = cont->machine_register_stack_size = th->machine_register_stack_end - th->machine_register_stack_start;
- cont->machine_register_stack_src = th->machine_register_stack_start;
- if (cont->machine_register_stack) {
- REALLOC_N(cont->machine_register_stack, VALUE, size);
- }
- else {
- cont->machine_register_stack = ALLOC_N(VALUE, size);
- }
-
- MEMCPY(cont->machine_register_stack, cont->machine_register_stack_src, VALUE, size);
-#endif
-
- sth->machine_stack_start = sth->machine_stack_end = 0;
-#ifdef __ia64
- sth->machine_register_stack_start = sth->machine_register_stack_end = 0;
-#endif
-}
-
-static rb_context_t *
-cont_new(VALUE klass)
-{
- rb_context_t *cont;
- volatile VALUE contval;
- rb_thread_t *th = GET_THREAD();
-
- contval = Data_Make_Struct(klass, rb_context_t,
- cont_mark, cont_free, cont);
-
- cont->self = contval;
- cont->alive = Qtrue;
-
- /* save thread context */
- cont->saved_thread = *th;
-
- return cont;
-}
-
-void vm_stack_to_heap(rb_thread_t *th);
-
-static VALUE
-cont_capture(volatile int *stat)
-{
- rb_context_t *cont;
- rb_thread_t *th = GET_THREAD(), *sth;
- volatile VALUE contval;
-
- vm_stack_to_heap(th);
- cont = cont_new(rb_cContinuation);
- contval = cont->self;
- sth = &cont->saved_thread;
-
- cont->vm_stack = ALLOC_N(VALUE, th->stack_size);
- MEMCPY(cont->vm_stack, th->stack, VALUE, th->stack_size);
- sth->stack = 0;
-
- cont_save_machine_stack(th, cont);
-
- if (ruby_setjmp(cont->jmpbuf)) {
- VALUE value;
-
- value = cont->value;
- cont->value = Qnil;
- *stat = 1;
- return value;
- }
- else {
- *stat = 0;
- return cont->self;
- }
-}
-
-NORETURN(static void cont_restore_1(rb_context_t *));
-
-static void
-cont_restore_1(rb_context_t *cont)
-{
- rb_thread_t *th = GET_THREAD(), *sth = &cont->saved_thread;
-
- /* restore thread context */
- if (cont->type == CONTINUATION_CONTEXT) {
- /* continuation */
- VALUE fib;
-
- th->fiber = sth->fiber;
- fib = th->fiber ? th->fiber : th->root_fiber;
-
- if (fib) {
- rb_context_t *fcont;
- GetContPtr(fib, fcont);
- th->stack_size = fcont->saved_thread.stack_size;
- th->stack = fcont->saved_thread.stack;
- }
- MEMCPY(th->stack, cont->vm_stack, VALUE, sth->stack_size);
- }
- else {
- /* fiber */
- th->stack = sth->stack;
- th->stack_size = sth->stack_size;
- th->local_storage = sth->local_storage;
- th->fiber = cont->self;
- }
-
- th->cfp = sth->cfp;
- th->safe_level = sth->safe_level;
- th->raised_flag = sth->raised_flag;
- th->state = sth->state;
- th->status = sth->status;
- th->tag = sth->tag;
- th->trap_tag = sth->trap_tag;
- th->errinfo = sth->errinfo;
- th->first_proc = sth->first_proc;
-
- /* restore machine stack */
-#ifdef _M_AMD64
- {
- /* workaround for x64 SEH */
- jmp_buf buf;
- setjmp(buf);
- ((_JUMP_BUFFER*)(&cont->jmpbuf))->Frame =
- ((_JUMP_BUFFER*)(&buf))->Frame;
- }
-#endif
- if (cont->machine_stack_src) {
- FLUSH_REGISTER_WINDOWS;
- MEMCPY(cont->machine_stack_src, cont->machine_stack,
- VALUE, cont->machine_stack_size);
- }
-
-#ifdef __ia64
- if (cont->machine_register_stack_src) {
- MEMCPY(cont->machine_register_stack_src, cont->machine_register_stack,
- VALUE, cont->machine_register_stack_size);
- }
-#endif
-
- ruby_longjmp(cont->jmpbuf, 1);
-}
-
-NORETURN(NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *)));
-
-#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_context_t *, VALUE *)));
-static void
-register_stack_extend(rb_context_t *cont, 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 < cont->machine_register_stack_src+cont->machine_register_stack_size) {
- register_stack_extend(cont, (VALUE*)rb_ia64_bsp());
- }
- cont_restore_1(cont);
-}
-#undef C
-#undef E
-#endif
-
-static void
-cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
-{
- if (cont->machine_stack_src) {
-#define STACK_PAD_SIZE 1024
- VALUE space[STACK_PAD_SIZE];
-
-#if STACK_GROW_DIRECTION < 0 /* downward */
- if (addr_in_prev_frame > cont->machine_stack_src) {
- cont_restore_0(cont, &space[0]);
- }
-#elif STACK_GROW_DIRECTION > 0 /* upward */
- if (addr_in_prev_frame < cont->machine_stack_src + cont->machine_stack_size) {
- cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
- }
-#else
- if (addr_in_prev_frame > &space[0]) {
- /* Stack grows downward */
- if (addr_in_prev_frame > cont->saved_thread.machine_stack_src) {
- cont_restore_0(cont, &space[0]);
- }
- }
- else {
- /* Stack grows upward */
- if (addr_in_prev_frame < cont->machine_stack_src + cont->machine_stack_size) {
- cont_restore_0(cont, &space[STACK_PAD_SIZE-1]);
- }
- }
-#endif
- }
-#ifdef __ia64
- register_stack_extend(cont, (VALUE*)rb_ia64_bsp());
-#else
- cont_restore_1(cont);
-#endif
-}
-
-/*
- * Document-class: Continuation
- *
- * Continuation objects are generated by
- * <code>Kernel#callcc</code>. They hold a return address and execution
- * context, allowing a nonlocal return to the end of the
- * <code>callcc</code> block from anywhere within a program.
- * Continuations are somewhat analogous to a structured version of C's
- * <code>setjmp/longjmp</code> (although they contain more state, so
- * you might consider them closer to threads).
- *
- * For instance:
- *
- * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
- * callcc{|$cc|}
- * puts(message = arr.shift)
- * $cc.call unless message =~ /Max/
- *
- * <em>produces:</em>
- *
- * Freddie
- * Herbie
- * Ron
- * Max
- *
- * This (somewhat contrived) example allows the inner loop to abandon
- * processing early:
- *
- * callcc {|cont|
- * for i in 0..4
- * print "\n#{i}: "
- * for j in i*5...(i+1)*5
- * cont.call() if j == 17
- * printf "%3d", j
- * end
- * end
- * }
- * print "\n"
- *
- * <em>produces:</em>
- *
- * 0: 0 1 2 3 4
- * 1: 5 6 7 8 9
- * 2: 10 11 12 13 14
- * 3: 15 16
- */
-
-/*
- * call-seq:
- * callcc {|cont| block } => obj
- *
- * Generates a <code>Continuation</code> object, which it passes to the
- * associated block. Performing a <em>cont</em><code>.call</code> will
- * cause the <code>callcc</code> to return (as will falling through the
- * end of the block). The value returned by the <code>callcc</code> is
- * the value of the block, or the value passed to
- * <em>cont</em><code>.call</code>. See class <code>Continuation</code>
- * for more details. Also see <code>Kernel::throw</code> for
- * an alternative mechanism for unwinding a call stack.
- */
-
-static VALUE
-rb_callcc(VALUE self)
-{
- volatile int called;
- volatile VALUE val = cont_capture(&called);
-
- if (called) {
- return val;
- }
- else {
- return rb_yield(val);
- }
-}
-
-static VALUE
-make_passing_arg(int argc, VALUE *argv)
-{
- switch(argc) {
- case 0:
- return Qnil;
- case 1:
- return argv[0];
- default:
- return rb_ary_new4(argc, argv);
- }
-}
-
-/*
- * call-seq:
- * cont.call(args, ...)
- * cont[args, ...]
- *
- * Invokes the continuation. The program continues from the end of the
- * <code>callcc</code> block. If no arguments are given, the original
- * <code>callcc</code> returns <code>nil</code>. If one argument is
- * given, <code>callcc</code> returns it. Otherwise, an array
- * containing <i>args</i> is returned.
- *
- * callcc {|cont| cont.call } #=> nil
- * callcc {|cont| cont.call 1 } #=> 1
- * callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
- */
-
-static VALUE
-rb_cont_call(int argc, VALUE *argv, VALUE contval)
-{
- rb_context_t *cont;
- rb_thread_t *th = GET_THREAD();
- GetContPtr(contval, cont);
-
- if (cont->saved_thread.self != th->self) {
- rb_raise(rb_eRuntimeError, "continuation called across threads");
- }
- if (cont->saved_thread.trap_tag != th->trap_tag) {
- rb_raise(rb_eRuntimeError, "continuation called across trap");
- }
- if (cont->saved_thread.fiber) {
- rb_context_t *fcont;
- GetContPtr(cont->saved_thread.fiber, fcont);
-
- if (th->fiber != cont->saved_thread.fiber) {
- rb_raise(rb_eRuntimeError, "continuation called across fiber");
- }
-
- if (!fcont->alive) {
- rb_raise(rb_eRuntimeError, "continuation called dead fiber");
- }
- }
-
- cont->value = make_passing_arg(argc, argv);
-
- cont_restore_0(cont, &contval);
- return Qnil; /* unreachable */
-}
-
-/*********/
-/* fiber */
-/*********/
-
-#define FIBER_VM_STACK_SIZE (4 * 1024)
-
-static rb_context_t *
-fiber_alloc(VALUE klass)
-{
- rb_context_t *cont = cont_new(klass);
-
- cont->type = FIBER_CONTEXT;
- cont->prev = Qnil;
-
- return cont;
-}
-
-static VALUE
-fiber_new(VALUE klass, VALUE proc)
-{
- rb_context_t *cont = fiber_alloc(klass);
- VALUE contval = cont->self;
- rb_thread_t *th = &cont->saved_thread;
-
- /* initialize */
- cont->vm_stack = 0;
-
- th->stack = 0;
- th->stack_size = FIBER_VM_STACK_SIZE;
- th->stack = ALLOC_N(VALUE, th->stack_size);
-
- th->cfp = (void *)(th->stack + th->stack_size);
- th->cfp--;
- th->cfp->pc = 0;
- th->cfp->sp = th->stack + 1;
- th->cfp->bp = 0;
- th->cfp->lfp = th->stack;
- *th->cfp->lfp = 0;
- th->cfp->dfp = th->stack;
- th->cfp->self = Qnil;
- th->cfp->flag = 0;
- th->cfp->iseq = 0;
- th->cfp->proc = 0;
- th->cfp->block_iseq = 0;
- th->tag = 0;
- th->local_storage = st_init_numtable();
-
- th->first_proc = proc;
-
- MEMCPY(&cont->jmpbuf, &th->root_jmpbuf, rb_jmpbuf_t, 1);
-
- return contval;
-}
-
-VALUE
-rb_fiber_new(VALUE (*func)(ANYARGS), VALUE obj)
-{
- return fiber_new(rb_cFiber, rb_proc_new(func, obj));
-}
-
-static VALUE
-rb_fiber_s_new(VALUE self)
-{
- return fiber_new(self, rb_block_proc());
-}
-
-static VALUE
-return_fiber(void)
-{
- rb_context_t *cont;
- VALUE curr = rb_fiber_current();
- GetContPtr(curr, cont);
-
- if (cont->prev == Qnil) {
- rb_thread_t *th = GET_THREAD();
-
- if (th->root_fiber != curr) {
- return th->root_fiber;
- }
- else {
- rb_raise(rb_eFiberError, "can't yield from root fiber");
- }
- }
- else {
- VALUE prev = cont->prev;
- cont->prev = Qnil;
- return prev;
- }
-}
-
-VALUE rb_fiber_transfer(VALUE fib, int argc, VALUE *argv);
-
-static void
-rb_fiber_terminate(rb_context_t *cont)
-{
- VALUE value = cont->value;
- cont->alive = Qfalse;
- rb_fiber_transfer(return_fiber(), 1, &value);
-}
-
-void
-rb_fiber_start(void)
-{
- rb_thread_t *th = GET_THREAD();
- rb_context_t *cont;
- rb_proc_t *proc;
- VALUE args;
- int state;
-
- GetContPtr(th->fiber, cont);
- TH_PUSH_TAG(th);
- if ((state = EXEC_TAG()) == 0) {
- GetProcPtr(cont->saved_thread.first_proc, proc);
- args = cont->value;
- cont->value = Qnil;
- th->errinfo = Qnil;
- th->local_lfp = proc->block.lfp;
- th->local_svar = Qnil;
-
- cont->value = vm_invoke_proc(th, proc, proc->block.self, 1, &args, 0);
- }
- TH_POP_TAG();
-
- if (state) {
- if (TAG_RAISE) {
- th->thrown_errinfo = th->errinfo;
- }
- else {
- th->thrown_errinfo =
- vm_make_jump_tag_but_local_jump(state, th->errinfo);
- }
- RUBY_VM_SET_INTERRUPT(th);
- }
-
- rb_fiber_terminate(cont);
- rb_bug("rb_fiber_start: unreachable");
-}
-
-VALUE
-rb_fiber_current()
-{
- rb_thread_t *th = GET_THREAD();
- if (th->fiber == 0) {
- /* save root */
- rb_context_t *cont = fiber_alloc(rb_cFiber);
- cont->type = ROOT_FIBER_CONTEXT;
- th->root_fiber = th->fiber = cont->self;
- }
- return th->fiber;
-}
-
-static VALUE
-fiber_store(rb_context_t *next_cont)
-{
- rb_thread_t *th = GET_THREAD();
- rb_context_t *cont;
-
- if (th->fiber) {
- GetContPtr(th->fiber, cont);
- cont->saved_thread = *th;
- }
- else {
- /* create current fiber */
- cont = fiber_alloc(rb_cFiber); /* no need to allocate vm stack */
- cont->type = ROOT_FIBER_CONTEXT;
- th->root_fiber = th->fiber = cont->self;
- }
-
- cont_save_machine_stack(th, cont);
-
- if (ruby_setjmp(cont->jmpbuf)) {
- /* restored */
- GetContPtr(th->fiber, cont);
- return cont->value;
- }
- else {
- return Qundef;
- }
-}
-
-static inline VALUE
-fiber_switch(VALUE fib, int argc, VALUE *argv, int is_resume)
-{
- VALUE value;
- rb_context_t *cont;
- rb_thread_t *th = GET_THREAD();
-
- GetContPtr(fib, cont);
-
- if (cont->saved_thread.self != th->self) {
- rb_raise(rb_eFiberError, "fiber called across threads");
- }
- else if (cont->saved_thread.trap_tag != th->trap_tag) {
- rb_raise(rb_eFiberError, "fiber called across trap");
- }
- else if (!cont->alive) {
- rb_raise(rb_eFiberError, "dead fiber called");
- }
-
- if (is_resume) {
- cont->prev = rb_fiber_current();
- }
-
- cont->value = make_passing_arg(argc, argv);
-
- if ((value = fiber_store(cont)) == Qundef) {
- cont_restore_0(cont, &value);
- rb_bug("rb_fiber_resume: unreachable");
- }
-
- RUBY_VM_CHECK_INTS();
-
- return value;
-}
-
-VALUE
-rb_fiber_transfer(VALUE fib, int argc, VALUE *argv)
-{
- return fiber_switch(fib, argc, argv, 0);
-}
-
-VALUE
-rb_fiber_resume(VALUE fib, int argc, VALUE *argv)
-{
- rb_context_t *cont;
- GetContPtr(fib, cont);
-
- if (cont->prev != Qnil) {
- rb_raise(rb_eFiberError, "double resume");
- }
-
- return fiber_switch(fib, argc, argv, 1);
-}
-
-VALUE
-rb_fiber_yield(int argc, VALUE *argv)
-{
- return rb_fiber_transfer(return_fiber(), argc, argv);
-}
-
-VALUE
-rb_fiber_alive_p(VALUE fib)
-{
- rb_context_t *cont;
- GetContPtr(fib, cont);
- return cont->alive;
-}
-
-static VALUE
-rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
-{
- return rb_fiber_resume(fib, argc, argv);
-}
-
-static VALUE
-rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fib)
-{
- return rb_fiber_transfer(fib, argc, argv);
-}
-
-static VALUE
-rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
-{
- return rb_fiber_yield(argc, argv);
-}
-
-static VALUE
-rb_fiber_s_current(VALUE klass)
-{
- return rb_fiber_current();
-}
-
-void
-Init_Cont(void)
-{
- rb_cFiber = rb_define_class("Fiber", rb_cObject);
- rb_undef_alloc_func(rb_cFiber);
- rb_eFiberError = rb_define_class("FiberError", rb_eStandardError);
- rb_define_singleton_method(rb_cFiber, "new", rb_fiber_s_new, 0);
- rb_define_singleton_method(rb_cFiber, "yield", rb_fiber_s_yield, -1);
- rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1);
-}
-
-void
-Init_Continuation_body(void)
-{
- rb_cContinuation = rb_define_class("Continuation", rb_cObject);
- rb_undef_alloc_func(rb_cContinuation);
- rb_undef_method(CLASS_OF(rb_cContinuation), "new");
- rb_define_method(rb_cContinuation, "call", rb_cont_call, -1);
- rb_define_method(rb_cContinuation, "[]", rb_cont_call, -1);
- rb_define_global_function("callcc", rb_callcc, 0);
-}
-
-void
-Init_Fiber_as_Coroutine(void)
-{
- rb_define_method(rb_cFiber, "transfer", rb_fiber_m_transfer, -1);
- rb_define_method(rb_cFiber, "alive?", rb_fiber_alive_p, 0);
- rb_define_singleton_method(rb_cFiber, "current", rb_fiber_s_current, 0);
-}
diff --git a/cygwin/GNUmakefile.in b/cygwin/GNUmakefile.in
index a55e750883..03208df11c 100644
--- a/cygwin/GNUmakefile.in
+++ b/cygwin/GNUmakefile.in
@@ -28,7 +28,6 @@ WPROGRAM = $(RUBYW_INSTALL_NAME)$(EXEEXT)
SOLIBS := $(DLL_BASE_NAME).res.@OBJEXT@ $(SOLIBS)
EXTOBJS += $(@:$(EXEEXT)=.res.@OBJEXT@)
RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc
-RUBYDEF = $(RUBY_SO_NAME).def
ruby: $(PROGRAM)
rubyw: $(WPROGRAM)
@@ -61,18 +60,13 @@ $(RUBY_EXP): $(LIBRUBY_A)
GNUmakefile: $(srcdir)/cygwin/GNUmakefile.in
ifeq (@target_os@,mingw32)
-$(OBJS) $(MAINOBJ): win32.h
-
-$(LIBRUBY_SO): $(RUBYDEF)
-
-$(RUBYDEF): $(LIBRUBY_A) $(PREP) $(RBCONFIG)
- $(MINIRUBY) $(srcdir)/win32/mkexports.rb -output=$@ $(LIBRUBY_A)
+$(OBJS) $(MAINOBJ): win32/win32.h
endif
ifeq (@target_os@,cygwin)
-cygwin-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)$(TEENY).dll: $(LIBRUBY_A)
+cygwin-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR).dll: $(LIBRUBY_A)
@NM@ --extern --defined $(LIBRUBY_A) | \
- $(MINIRUBY) -ne 'BEGIN{puts "EXPORTS"}; puts $$1+"=$(@F)."+$$1 if / [CDT] _(.*)$$/' >rubydll.def
+ $(MINIRUBY) -ne 'BEGIN{puts "EXPORTS"}; puts $$1+"=cyg$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)."+$$1 if / [CDT] _(.*)$$/' >rubydll.def
@DLLWRAP@ -s --def=rubydll.def -o $@
@rm -f rubydll.def
endif
diff --git a/debug.c b/debug.c
deleted file mode 100644
index abc1daa7eb..0000000000
--- a/debug.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/**********************************************************************
-
- debug.c -
-
- $Author$
- $Date$
- created at: 04/08/25 02:31:54 JST
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-#include "ruby/encoding.h"
-#include "debug.h"
-#include "vm_core.h"
-
-/* for gdb */
-static const union {
- enum ruby_special_consts special_consts;
- enum ruby_value_type value_type;
- enum node_type node_type;
- enum {
- RUBY_ENCODING_INLINE_MAX = ENCODING_INLINE_MAX,
- RUBY_ENCODING_SHIFT = ENCODING_SHIFT,
- RUBY_ENCODING_MASK = ENCODING_MASK,
- RUBY_ENC_CODERANGE_MASK = ENC_CODERANGE_MASK,
- RUBY_ENC_CODERANGE_UNKNOWN = ENC_CODERANGE_UNKNOWN,
- RUBY_ENC_CODERANGE_7BIT = ENC_CODERANGE_7BIT,
- RUBY_ENC_CODERANGE_VALID = ENC_CODERANGE_VALID,
- RUBY_ENC_CODERANGE_BROKEN = ENC_CODERANGE_BROKEN,
- RUBY_FL_MARK = FL_MARK,
- RUBY_FL_RESERVED = FL_RESERVED,
- RUBY_FL_FINALIZE = FL_FINALIZE,
- RUBY_FL_TAINT = FL_TAINT,
- RUBY_FL_EXIVAR = FL_EXIVAR,
- RUBY_FL_FREEZE = FL_FREEZE,
- RUBY_FL_SINGLETON = FL_SINGLETON,
- RUBY_FL_USER0 = FL_USER0,
- RUBY_FL_USER1 = FL_USER1,
- RUBY_FL_USER2 = FL_USER2,
- RUBY_FL_USER3 = FL_USER3,
- RUBY_FL_USER4 = FL_USER4,
- RUBY_FL_USER5 = FL_USER5,
- RUBY_FL_USER6 = FL_USER6,
- RUBY_FL_USER7 = FL_USER7,
- RUBY_FL_USER8 = FL_USER8,
- RUBY_FL_USER9 = FL_USER9,
- RUBY_FL_USER10 = FL_USER10,
- RUBY_FL_USER11 = FL_USER11,
- RUBY_FL_USER12 = FL_USER12,
- RUBY_FL_USER13 = FL_USER13,
- RUBY_FL_USER14 = FL_USER14,
- RUBY_FL_USER15 = FL_USER15,
- RUBY_FL_USER16 = FL_USER16,
- RUBY_FL_USER17 = FL_USER17,
- RUBY_FL_USER18 = FL_USER18,
- RUBY_FL_USER19 = FL_USER19,
- RUBY_FL_USHIFT = FL_USHIFT,
- RUBY_NODE_NEWLINE = NODE_NEWLINE,
- RUBY_NODE_TYPESHIFT = NODE_TYPESHIFT,
- RUBY_NODE_TYPEMASK = NODE_TYPEMASK,
- RUBY_NODE_LSHIFT = NODE_LSHIFT,
- RUBY_NODE_LMASK = NODE_LMASK,
- } various;
-} dummy_gdb_enums;
-
-const VALUE RUBY_FL_USER20 = FL_USER20;
-
-void
-ruby_debug_print_indent(int level, int debug_level, int indent_level)
-{
- if (level < debug_level) {
- int i;
- for (i = 0; i < indent_level; i++) {
- fprintf(stderr, " ");
- }
- fflush(stderr);
- }
-}
-
-VALUE
-ruby_debug_print_value(int level, int debug_level, const char *header, VALUE obj)
-{
- if (level < debug_level) {
- VALUE str;
- str = rb_inspect(obj);
- fprintf(stderr, "DBG> %s: %s\n", header,
- obj == -1 ? "" : StringValueCStr(str));
- fflush(stderr);
- }
- return obj;
-}
-
-void
-ruby_debug_print_v(VALUE v)
-{
- ruby_debug_print_value(0, 1, "", v);
-}
-
-ID
-ruby_debug_print_id(int level, int debug_level, const char *header, ID id)
-{
- if (level < debug_level) {
- fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
- fflush(stderr);
- }
- return id;
-}
-
-NODE *
-ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node)
-{
- if (level < debug_level) {
- fprintf(stderr, "DBG> %s: %s (%lu)\n", header,
- ruby_node_name(nd_type(node)), nd_line(node));
- }
- return (NODE *)node;
-}
-
-void
-ruby_debug_breakpoint(void)
-{
- /* */
-}
-
-#ifdef RUBY_DEBUG_ENV
-#include <ctype.h>
-
-void
-ruby_set_debug_option(const char *str)
-{
- const char *end;
- int len;
-
- if (!str) return;
- for (; *str; str = end) {
- while (ISSPACE(*str) || *str == ',') str++;
- if (!*str) break;
- end = str;
- while (*end && !ISSPACE(*end) && *end != ',') end++;
- len = end - str;
-#define SET_WHEN(name, var) \
- if (len == sizeof(name) - 1 && \
- strncmp(str, name, len) == 0) { \
- extern int ruby_##var; \
- ruby_##var = 1; \
- continue; \
- }
- SET_WHEN("gc_stress", gc_stress);
- SET_WHEN("core", enable_coredump);
- fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
- }
-}
-#endif
diff --git a/debug.h b/debug.h
deleted file mode 100644
index 782173ca9d..0000000000
--- a/debug.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**********************************************************************
-
- debug.h - YARV Debug function interface
-
- $Author$
- $Date$
- created at: 04/08/25 02:33:49 JST
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#ifndef RUBY_DEBUG_H
-#define RUBY_DEBUG_H
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-
-#define dpv(h,v) ruby_debug_print_value(-1, 0, h, v)
-#define dp(v) ruby_debug_print_value(-1, 0, "", v)
-#define dpi(i) ruby_debug_print_id(-1, 0, "", i)
-#define dpn(n) ruby_debug_print_node(-1, 0, "", n)
-
-#define bp() ruby_debug_breakpoint()
-
-VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
-ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
-NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
-void ruby_debug_print_indent(int level, int debug_level, int indent_level);
-void ruby_debug_breakpoint(void);
-void ruby_debug_gc_check_func(void);
-
-#endif /* RUBY_DEBUG_H */
diff --git a/defines.h b/defines.h
new file mode 100644
index 0000000000..f39097fea4
--- /dev/null
+++ b/defines.h
@@ -0,0 +1,273 @@
+/************************************************
+
+ defines.h -
+
+ $Author$
+ $Date$
+ created at: Wed May 18 00:21:44 JST 1994
+
+************************************************/
+#ifndef DEFINES_H
+#define DEFINES_H
+
+#define RUBY
+
+#ifdef __cplusplus
+# ifndef HAVE_PROTOTYPES
+# define HAVE_PROTOTYPES 1
+# endif
+# ifndef HAVE_STDARG_PROTOTYPES
+# define HAVE_STDARG_PROTOTYPES 1
+# endif
+#endif
+
+#undef _
+#ifdef HAVE_PROTOTYPES
+# define _(args) args
+#else
+# define _(args) ()
+#endif
+
+#undef __
+#ifdef HAVE_STDARG_PROTOTYPES
+# define __(args) args
+#else
+# define __(args) ()
+#endif
+
+#ifdef __cplusplus
+#define ANYARGS ...
+#else
+#define ANYARGS
+#endif
+
+#define xmalloc ruby_xmalloc
+#define xcalloc ruby_xcalloc
+#define xrealloc ruby_xrealloc
+#define xfree ruby_xfree
+
+void *xmalloc _((long));
+void *xcalloc _((long,long));
+void *xrealloc _((void*,long));
+void xfree _((void*));
+
+#if SIZEOF_LONG_LONG > 0
+# define LONG_LONG long long
+#elif SIZEOF___INT64 > 0
+# define HAVE_LONG_LONG 1
+# define LONG_LONG __int64
+# undef SIZEOF_LONG_LONG
+# define SIZEOF_LONG_LONG SIZEOF___INT64
+#endif
+
+#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
+# define BDIGIT unsigned int
+# define SIZEOF_BDIGITS SIZEOF_INT
+# define BDIGIT_DBL unsigned LONG_LONG
+# define BDIGIT_DBL_SIGNED LONG_LONG
+#elif SIZEOF_INT*2 <= SIZEOF_LONG
+# define BDIGIT unsigned int
+# define SIZEOF_BDIGITS SIZEOF_INT
+# define BDIGIT_DBL unsigned long
+# define BDIGIT_DBL_SIGNED long
+#elif SIZEOF_SHORT*2 <= SIZEOF_LONG
+# define BDIGIT unsigned short
+# define SIZEOF_BDIGITS SIZEOF_SHORT
+# define BDIGIT_DBL unsigned long
+# define BDIGIT_DBL_SIGNED long
+#else
+# define BDIGIT unsigned short
+# define SIZEOF_BDIGITS (SIZEOF_LONG/2)
+# define BDIGIT_DBL unsigned long
+# define BDIGIT_DBL_SIGNED long
+#endif
+
+#ifdef __CYGWIN__
+#undef _WIN32
+#endif
+
+#if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__)
+#define DOSISH 1
+#ifndef _WIN32_WCE
+# define DOSISH_DRIVE_LETTER
+#endif
+#endif
+
+/* define RUBY_USE_EUC/SJIS for default kanji-code */
+#ifndef DEFAULT_KCODE
+#if defined(DOSISH) || defined(__CYGWIN__) || defined(__MACOS__) || defined(OS2)
+#define DEFAULT_KCODE KCODE_SJIS
+#else
+#define DEFAULT_KCODE KCODE_EUC
+#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
+#define S_IRUSR 0000400 /* read permission, owner */
+#endif
+#ifndef S_IRGRP
+#define S_IRGRP 0000040 /* read permission, group */
+#endif
+#ifndef S_IROTH
+#define S_IROTH 0000004 /* read permission, other */
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR 0000200 /* write permission, owner */
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP 0000020 /* write permission, group */
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH 0000002 /* write permission, other */
+#endif
+#ifndef S_IXUSR
+#define S_IXUSR 0000100 /* execute/search permission, owner */
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP 0000010 /* execute/search permission, group */
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 0000001 /* execute/search permission, other */
+#endif
+#ifndef S_IRWXU
+#define S_IRWXU 0000700 /* read, write, execute permissions, owner */
+#endif
+#ifndef S_IRWXG
+#define S_IRWXG 0000070 /* read, write, execute permissions, group */
+#endif
+#ifndef S_IRWXO
+#define S_IRWXO 0000007 /* read, write, execute permissions, other */
+#endif
+#ifndef S_ISBLK
+#define S_ISBLK(mode) (((mode) & (0170000)) == (0060000))
+#endif
+#ifndef S_ISCHR
+#define S_ISCHR(mode) (((mode) & (0170000)) == (0020000))
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & (0170000)) == (0040000))
+#endif
+#ifndef S_ISFIFO
+#define S_ISFIFO(mode) (((mode) & (0170000)) == (0010000))
+#endif
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & (0170000)) == (0100000))
+#endif
+#ifndef __APPLE__
+/* NextStep, OpenStep (but not Rhapsody) */
+#ifndef GETPGRP_VOID
+#define GETPGRP_VOID 1
+#endif
+#ifndef WNOHANG
+#define WNOHANG 01
+#endif
+#ifndef WUNTRACED
+#define WUNTRACED 02
+#endif
+#ifndef X_OK
+#define X_OK 1
+#endif
+#endif /* __APPLE__ */
+#endif /* NeXT */
+
+#ifdef _WIN32
+#include "win32/win32.h"
+#endif
+
+#if defined(__VMS)
+#include "vms.h"
+#endif
+
+#if defined(__BEOS__)
+#include <net/socket.h> /* intern.h needs fd_set definition */
+#endif
+
+#ifdef RUBY_EXPORT
+#undef RUBY_EXTERN
+#endif
+
+#ifndef RUBY_EXTERN
+#define RUBY_EXTERN extern
+#endif
+
+#ifndef EXTERN
+#define EXTERN RUBY_EXTERN /* deprecated */
+#endif
+
+#ifndef RUBY_MBCHAR_MAXSIZE
+#define RUBY_MBCHAR_MAXSIZE INT_MAX
+ /* MB_CUR_MAX will not work well in C locale */
+#endif
+
+#if defined(sparc) || defined(__sparc__)
+static inline void
+flush_register_windows(void)
+{
+ asm
+#ifdef __GNUC__
+ volatile
+#endif
+# if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
+ ("flushw")
+# else
+ ("ta 0x03")
+# endif /* trap always to flush register windows if we are on a Sparc system */
+ ;
+}
+# define FLUSH_REGISTER_WINDOWS flush_register_windows()
+#elif defined(__ia64)
+void *rb_ia64_bsp(void);
+void rb_ia64_flushrs(void);
+# define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
+#else
+# define FLUSH_REGISTER_WINDOWS ((void)0)
+#endif
+
+#if defined(DOSISH)
+#define PATH_SEP ";"
+#elif defined(riscos)
+#define PATH_SEP ","
+#else
+#define PATH_SEP ":"
+#endif
+#define PATH_SEP_CHAR PATH_SEP[0]
+
+#if defined(__human68k__)
+#define PATH_ENV "path"
+#else
+#define PATH_ENV "PATH"
+#endif
+
+#if defined(DOSISH) && !defined(__human68k__) && !defined(__EMX__)
+#define ENV_IGNORECASE
+#endif
+
+#ifndef CASEFOLD_FILESYSTEM
+# if defined DOSISH || defined __VMS
+# define CASEFOLD_FILESYSTEM 1
+# else
+# define CASEFOLD_FILESYSTEM 0
+# endif
+#endif
+
+#ifndef DLEXT_MAXLEN
+#define DLEXT_MAXLEN 4
+#endif
+
+#ifndef RUBY_PLATFORM
+#define RUBY_PLATFORM "unknown-unknown"
+#endif
+
+#endif
diff --git a/dir.c b/dir.c
index 8163a639de..c2c3f9452f 100644
--- a/dir.c
+++ b/dir.c
@@ -6,13 +6,13 @@
$Date$
created at: Wed Jan 5 09:51:01 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -56,12 +56,12 @@ char *getenv();
#endif
#ifndef HAVE_STRING_H
-char *strchr(char*,char);
+char *strchr _((char*,char));
#endif
#include <ctype.h>
-#include "ruby/util.h"
+#include "util.h"
#if !defined HAVE_LSTAT && !defined lstat
#define lstat stat
@@ -174,10 +174,10 @@ CompareImpl(const char *p1, const char *p2, int nocase)
#endif /* environment */
static char *
-bracket(
- const char *p, /* pattern (next to '[') */
- const char *s, /* string */
- int flags)
+bracket(p, s, flags)
+ const char *p; /* pattern (next to '[') */
+ const char *s; /* string */
+ int flags;
{
const int nocase = flags & FNM_CASEFOLD;
const int escape = !(flags & FNM_NOESCAPE);
@@ -224,10 +224,10 @@ bracket(
#define RETURN(val) return *pcur = p, *scur = s, (val);
static int
-fnmatch_helper(
- const char **pcur, /* pattern */
- const char **scur, /* string */
- int flags)
+fnmatch_helper(pcur, scur, flags)
+ const char **pcur; /* pattern */
+ const char **scur; /* string */
+ int flags;
{
const int period = !(flags & FNM_DOTMATCH);
const int pathname = flags & FNM_PATHNAME;
@@ -301,10 +301,10 @@ fnmatch_helper(
}
static int
-fnmatch(
- const char *p, /* pattern */
- const char *s, /* string */
- int flags)
+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;
@@ -354,7 +354,8 @@ struct dir_data {
};
static void
-free_dir(struct dir_data *dir)
+free_dir(dir)
+ struct dir_data *dir;
{
if (dir) {
if (dir->dir) closedir(dir->dir);
@@ -363,10 +364,12 @@ free_dir(struct dir_data *dir)
free(dir);
}
-static VALUE dir_close(VALUE);
+static VALUE dir_close _((VALUE));
+static VALUE dir_s_alloc _((VALUE));
static VALUE
-dir_s_alloc(VALUE klass)
+dir_s_alloc(klass)
+ VALUE klass;
{
struct dir_data *dirp;
VALUE obj = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dirp);
@@ -384,27 +387,28 @@ dir_s_alloc(VALUE klass)
* Returns a new directory object for the named directory.
*/
static VALUE
-dir_initialize(VALUE dir, VALUE dirname)
+dir_initialize(dir, dirname)
+ VALUE dir, dirname;
{
struct dir_data *dp;
- FilePathValue(dirname);
+ SafeStringValue(dirname);
Data_Get_Struct(dir, struct dir_data, dp);
if (dp->dir) closedir(dp->dir);
if (dp->path) free(dp->path);
dp->dir = NULL;
dp->path = NULL;
- dp->dir = opendir(RSTRING_PTR(dirname));
+ dp->dir = opendir(RSTRING(dirname)->ptr);
if (dp->dir == NULL) {
if (errno == EMFILE || errno == ENFILE) {
rb_gc();
- dp->dir = opendir(RSTRING_PTR(dirname));
+ dp->dir = opendir(RSTRING(dirname)->ptr);
}
if (dp->dir == NULL) {
- rb_sys_fail(RSTRING_PTR(dirname));
+ rb_sys_fail(RSTRING(dirname)->ptr);
}
}
- dp->path = strdup(RSTRING_PTR(dirname));
+ dp->path = strdup(RSTRING(dirname)->ptr);
return dir;
}
@@ -420,8 +424,10 @@ dir_initialize(VALUE dir, VALUE dirname)
* the block, and <code>Dir::open</code> returns the value of the
* block.
*/
+
static VALUE
-dir_s_open(VALUE klass, VALUE dirname)
+dir_s_open(klass, dirname)
+ VALUE klass, dirname;
{
struct dir_data *dp;
VALUE dir = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dp);
@@ -435,13 +441,14 @@ dir_s_open(VALUE klass, VALUE dirname)
}
static void
-dir_closed(void)
+dir_closed()
{
rb_raise(rb_eIOError, "closed directory");
}
static void
-dir_check(VALUE dir)
+dir_check(dir)
+ VALUE dir;
{
if (!OBJ_TAINTED(dir) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: operation on untainted Dir");
@@ -461,13 +468,14 @@ dir_check(VALUE dir)
* Return a string describing this Dir object.
*/
static VALUE
-dir_inspect(VALUE dir)
+dir_inspect(dir)
+ VALUE dir;
{
struct dir_data *dirp;
Data_Get_Struct(dir, struct dir_data, dirp);
if (dirp->path) {
- char *c = rb_obj_classname(dir);
+ 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);
@@ -486,7 +494,8 @@ dir_inspect(VALUE dir)
* d.path #=> ".."
*/
static VALUE
-dir_path(VALUE dir)
+dir_path(dir)
+ VALUE dir;
{
struct dir_data *dirp;
@@ -508,7 +517,8 @@ dir_path(VALUE dir)
* d.read #=> "config.h"
*/
static VALUE
-dir_read(VALUE dir)
+dir_read(dir)
+ VALUE dir;
{
struct dir_data *dirp;
struct dirent *dp;
@@ -546,7 +556,8 @@ dir_read(VALUE dir)
* Got main.rb
*/
static VALUE
-dir_each(VALUE dir)
+dir_each(dir)
+ VALUE dir;
{
struct dir_data *dirp;
struct dirent *dp;
@@ -575,13 +586,14 @@ dir_each(VALUE dir)
* d.tell #=> 12
*/
static VALUE
-dir_tell(VALUE dir)
+dir_tell(dir)
+ VALUE dir;
{
#ifdef HAVE_TELLDIR
struct dir_data *dirp;
long pos;
- Data_Get_Struct(dir, struct dir_data, dirp);
+ GetDIR(dir, dirp);
pos = telldir(dirp->dir);
return rb_int2inum(pos);
#else
@@ -604,7 +616,8 @@ dir_tell(VALUE dir)
* d.read #=> ".."
*/
static VALUE
-dir_seek(VALUE dir, VALUE pos)
+dir_seek(dir, pos)
+ VALUE dir, pos;
{
struct dir_data *dirp;
off_t p = NUM2OFFT(pos);
@@ -633,7 +646,8 @@ dir_seek(VALUE dir, VALUE pos)
* d.read #=> ".."
*/
static VALUE
-dir_set_pos(VALUE dir, VALUE pos)
+dir_set_pos(dir, pos)
+ VALUE dir, pos;
{
dir_seek(dir, pos);
return pos;
@@ -651,7 +665,8 @@ dir_set_pos(VALUE dir, VALUE pos)
* d.read #=> "."
*/
static VALUE
-dir_rewind(VALUE dir)
+dir_rewind(dir)
+ VALUE dir;
{
struct dir_data *dirp;
@@ -674,7 +689,8 @@ dir_rewind(VALUE dir)
* d.close #=> nil
*/
static VALUE
-dir_close(VALUE dir)
+dir_close(dir)
+ VALUE dir;
{
struct dir_data *dirp;
@@ -686,10 +702,11 @@ dir_close(VALUE dir)
}
static void
-dir_chdir(VALUE path)
+dir_chdir(path)
+ VALUE path;
{
- if (chdir(RSTRING_PTR(path)) < 0)
- rb_sys_fail(RSTRING_PTR(path));
+ if (chdir(RSTRING(path)->ptr) < 0)
+ rb_sys_fail(RSTRING(path)->ptr);
}
static int chdir_blocking = 0;
@@ -701,7 +718,8 @@ struct chdir_data {
};
static VALUE
-chdir_yield(struct chdir_data *args)
+chdir_yield(args)
+ struct chdir_data *args;
{
dir_chdir(args->new_path);
args->done = Qtrue;
@@ -712,7 +730,8 @@ chdir_yield(struct chdir_data *args)
}
static VALUE
-chdir_restore(struct chdir_data *args)
+chdir_restore(args)
+ struct chdir_data *args;
{
if (args->done) {
chdir_blocking--;
@@ -763,13 +782,16 @@ chdir_restore(struct chdir_data *args)
* /var/spool/mail
*/
static VALUE
-dir_s_chdir(int argc, VALUE *argv, VALUE obj)
+dir_s_chdir(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE path = Qnil;
rb_secure(2);
if (rb_scan_args(argc, argv, "01", &path) == 1) {
- FilePathValue(path);
+ SafeStringValue(path);
}
else {
const char *dist = getenv("HOME");
@@ -811,7 +833,8 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
* Dir.getwd #=> "/tmp"
*/
static VALUE
-dir_s_getwd(VALUE dir)
+dir_s_getwd(dir)
+ VALUE dir;
{
char *path;
VALUE cwd;
@@ -824,14 +847,16 @@ dir_s_getwd(VALUE dir)
return cwd;
}
+static void check_dirname _((volatile VALUE *));
static void
-check_dirname(volatile VALUE *dir)
+check_dirname(dir)
+ volatile VALUE *dir;
{
char *path, *pend;
+ SafeStringValue(*dir);
rb_secure(2);
- FilePathValue(*dir);
- path = RSTRING_PTR(*dir);
+ path = RSTRING(*dir)->ptr;
if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
*dir = rb_str_new(path, pend - path);
}
@@ -847,13 +872,14 @@ check_dirname(volatile VALUE *dir)
* information.
*/
static VALUE
-dir_s_chroot(VALUE dir, VALUE path)
+dir_s_chroot(dir, path)
+ VALUE dir, path;
{
#if defined(HAVE_CHROOT) && !defined(__CHECKER__)
check_dirname(&path);
- if (chroot(RSTRING_PTR(path)) == -1)
- rb_sys_fail(RSTRING_PTR(path));
+ if (chroot(RSTRING(path)->ptr) == -1)
+ rb_sys_fail(RSTRING(path)->ptr);
return INT2FIX(0);
#else
@@ -876,7 +902,10 @@ dir_s_chroot(VALUE dir, VALUE path)
*
*/
static VALUE
-dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
+dir_s_mkdir(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE path, vmode;
int mode;
@@ -889,8 +918,8 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
}
check_dirname(&path);
- if (mkdir(RSTRING_PTR(path), mode) == -1)
- rb_sys_fail(RSTRING_PTR(path));
+ if (mkdir(RSTRING(path)->ptr, mode) == -1)
+ rb_sys_fail(RSTRING(path)->ptr);
return INT2FIX(0);
}
@@ -905,24 +934,26 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
* <code>SystemCallError</code> if the directory isn't empty.
*/
static VALUE
-dir_s_rmdir(VALUE obj, VALUE dir)
+dir_s_rmdir(obj, dir)
+ VALUE obj, dir;
{
check_dirname(&dir);
- if (rmdir(RSTRING_PTR(dir)) < 0)
- rb_sys_fail(RSTRING_PTR(dir));
+ if (rmdir(RSTRING(dir)->ptr) < 0)
+ rb_sys_fail(RSTRING(dir)->ptr);
return INT2FIX(0);
}
static void
-sys_warning_1(const char* mesg)
+sys_warning_1(mesg)
+ const char* mesg;
{
rb_sys_warning("%s", mesg);
}
#define GLOB_VERBOSE (1UL << (sizeof(int) * CHAR_BIT - 1))
#define sys_warning(val) \
- (void)((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)(VALUE))sys_warning_1, (VALUE)(val), 0))
+ (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))
@@ -968,7 +999,9 @@ do_opendir(const char *path, int flags)
/* Return nonzero if S has any special globbing chars in it. */
static int
-has_magic(const char *s, int flags)
+has_magic(s, flags)
+ const char *s;
+ int flags;
{
const int escape = !(flags & FNM_NOESCAPE);
const int nocase = flags & FNM_CASEFOLD;
@@ -1035,9 +1068,10 @@ find_dirsep(const char *s, int flags)
return (char *)p-1;
}
-/* Remove escaping baskclashes */
+/* Remove escaping backslashes */
static void
-remove_backslashes(char *p)
+remove_backslashes(p)
+ char *p;
{
char *t = p;
char *s = p;
@@ -1155,10 +1189,6 @@ join_path(const char *path, int dirsep, const char *name)
enum answer { YES, NO, UNKNOWN };
-#ifndef S_ISDIR
-# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
-#endif
-
#ifndef S_ISLNK
# ifndef S_IFLNK
# define S_ISLNK(m) (0)
@@ -1167,34 +1197,43 @@ enum answer { YES, NO, UNKNOWN };
# endif
#endif
+#ifndef S_ISDIR
+# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#endif
+
struct glob_args {
- void (*func)(const char *, VALUE);
- const char *path;
- VALUE value;
+ void (*func) _((const char*, VALUE));
+ const char *c;
+ VALUE v;
};
+static VALUE glob_func_caller _((VALUE));
+
static VALUE
-glob_func_caller(VALUE val)
+glob_func_caller(val)
+ VALUE val;
{
struct glob_args *args = (struct glob_args *)val;
- (*args->func)(args->path, args->value);
+ (*args->func)(args->c, args->v);
return Qnil;
}
#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,
- int dirsep, /* '/' should be placed before appending child entry's name to 'path'. */
- enum answer exist, /* Does 'path' indicate an existing entry? */
- enum answer isdir, /* Does 'path' indicate a directory or a symlink to a directory? */
- struct glob_pattern **beg,
- struct glob_pattern **end,
- int flags,
- ruby_glob_func *func,
- VALUE arg)
+glob_helper(path, dirsep, exist, isdir, beg, end, 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;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
{
struct stat st;
int status = 0;
@@ -1209,19 +1248,19 @@ glob_helper(
p = p->next;
}
switch (p->type) {
- case PLAIN:
+ case PLAIN:
plain = 1;
break;
- case MAGICAL:
+ case MAGICAL:
magical = 1;
break;
- case MATCH_ALL:
+ case MATCH_ALL:
match_all = 1;
break;
- case MATCH_DIR:
+ case MATCH_DIR:
match_dir = 1;
break;
- case RECURSIVE:
+ case RECURSIVE:
rb_bug("continuous RECURSIVEs");
}
}
@@ -1369,7 +1408,11 @@ glob_helper(
}
static int
-ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg)
+ruby_glob0(path, flags, func, arg)
+ const char *path;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
{
struct glob_pattern *list;
const char *root, *start;
@@ -1404,29 +1447,41 @@ ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg)
}
int
-ruby_glob(const char *path, int flags, ruby_glob_func *func, VALUE arg)
+ruby_glob(path, flags, func, arg)
+ const char *path;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
{
return ruby_glob0(path, flags & ~GLOB_VERBOSE, func, arg);
}
+static int rb_glob_caller _((const char *, VALUE));
+
static int
-rb_glob_caller(const char *path, VALUE a)
+rb_glob_caller(path, a)
+ const char *path;
+ VALUE a;
{
int status;
struct glob_args *args = (struct glob_args *)a;
- args->path = path;
+ args->c = path;
rb_protect(glob_func_caller, a, &status);
return status;
}
static int
-rb_glob2(const char *path, int flags, void (*func)(const char *, VALUE), VALUE arg)
+rb_glob2(path, flags, func, arg)
+ const char *path;
+ int flags;
+ void (*func) _((const char *, VALUE));
+ VALUE arg;
{
struct glob_args args;
args.func = func;
- args.value = arg;
+ args.v = arg;
if (flags & FNM_SYSCASE) {
rb_warning("Dir.glob() ignores File::FNM_CASEFOLD");
@@ -1436,20 +1491,30 @@ rb_glob2(const char *path, int flags, void (*func)(const char *, VALUE), VALUE a
}
void
-rb_glob(const char *path, void (*func)(const char *, VALUE), VALUE arg)
+rb_glob(path, func, arg)
+ const char *path;
+ void (*func) _((const char*, VALUE));
+ VALUE arg;
{
int status = rb_glob2(path, 0, func, arg);
if (status) GLOB_JUMP_TAG(status);
}
+static void push_pattern _((const char* path, VALUE ary));
static void
-push_pattern(const char *path, VALUE ary)
+push_pattern(path, ary)
+ const char *path;
+ VALUE ary;
{
rb_ary_push(ary, rb_tainted_str_new2(path));
}
int
-ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg)
+ruby_brace_expand(str, flags, func, arg)
+ const char *str;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
{
const int escape = !(flags & FNM_NOESCAPE);
const char *p = str;
@@ -1510,8 +1575,11 @@ struct brace_args {
int flags;
};
+static int glob_brace _((const char *, VALUE));
static int
-glob_brace(const char *path, VALUE val)
+glob_brace(path, val)
+ const char *path;
+ VALUE val;
{
struct brace_args *arg = (struct brace_args *)val;
@@ -1519,7 +1587,11 @@ glob_brace(const char *path, VALUE val)
}
static int
-ruby_brace_glob0(const char *str, int flags, ruby_glob_func *func, VALUE arg)
+ruby_brace_glob0(str, flags, func, arg)
+ const char *str;
+ int flags;
+ ruby_glob_func *func;
+ VALUE arg;
{
struct brace_args args;
@@ -1530,7 +1602,11 @@ ruby_brace_glob0(const char *str, int flags, ruby_glob_func *func, VALUE arg)
}
int
-ruby_brace_glob(const char *str, int flags, ruby_glob_func *func, VALUE arg)
+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);
}
@@ -1541,37 +1617,42 @@ push_glob(VALUE ary, const char *str, int flags)
struct glob_args args;
args.func = push_pattern;
- args.value = ary;
+ args.v = ary;
return ruby_brace_glob0(str, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
}
static VALUE
-rb_push_glob(VALUE str, int flags) /* '\0' is delimiter */
+rb_push_glob(str, flags) /* '\0' is delimiter */
+ VALUE str;
+ int flags;
{
long offset = 0;
VALUE ary;
- StringValue(str);
ary = rb_ary_new();
+ SafeStringValue(str);
while (offset < RSTRING_LEN(str)) {
- int status = push_glob(ary, RSTRING_PTR(str) + offset, flags);
+ 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_PTR(str) + offset;
+ p = RSTRING(str)->ptr + offset;
p += strlen(p) + 1;
- pend = RSTRING_PTR(str) + RSTRING_LEN(str);
+ pend = RSTRING(str)->ptr + RSTRING_LEN(str);
while (p < pend && !*p)
p++;
- offset = p - RSTRING_PTR(str);
+ offset = p - RSTRING(str)->ptr;
}
return ary;
}
static VALUE
-dir_globs(long argc, VALUE *argv, int flags)
+dir_globs(argc, argv, flags)
+ long argc;
+ VALUE *argv;
+ int flags;
{
VALUE ary = rb_ary_new();
long i;
@@ -1580,7 +1661,7 @@ dir_globs(long argc, VALUE *argv, int flags)
int status;
VALUE str = argv[i];
StringValue(str);
- status = push_glob(ary, RSTRING_PTR(str), flags);
+ status = push_glob(ary, RSTRING(str)->ptr, flags);
if (status) GLOB_JUMP_TAG(status);
}
@@ -1593,18 +1674,18 @@ dir_globs(long argc, VALUE *argv, int flags)
* Dir[ string [, string ...] ] => array
*
* Equivalent to calling
- * <code>Dir.glob(</code><i>array,</i><code>0)</code> and
+ * <code>Dir.glob(</code><i>array,</i><code>0)</code> and
* <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
*
*/
static VALUE
dir_s_aref(int argc, VALUE *argv, VALUE obj)
-{
+ {
if (argc == 1) {
return rb_push_glob(argv[0], 0);
}
return dir_globs(argc, argv, 0);
-}
+ }
/*
* call-seq:
@@ -1667,7 +1748,10 @@ dir_s_aref(int argc, VALUE *argv, VALUE obj)
* Dir.glob(librbfiles) #=> ["lib/song.rb"]
*/
static VALUE
-dir_s_glob(int argc, VALUE *argv, VALUE obj)
+dir_s_glob(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE str, rflags, ary;
int flags;
@@ -1694,7 +1778,8 @@ dir_s_glob(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-dir_open_dir(VALUE path)
+dir_open_dir(path)
+ VALUE path;
{
VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path);
@@ -1725,7 +1810,8 @@ dir_open_dir(VALUE path)
*
*/
static VALUE
-dir_foreach(VALUE io, VALUE dirname)
+dir_foreach(io, dirname)
+ VALUE io, dirname;
{
VALUE dir;
@@ -1747,7 +1833,8 @@ dir_foreach(VALUE io, VALUE dirname)
*
*/
static VALUE
-dir_entries(VALUE io, VALUE dirname)
+dir_entries(io, dirname)
+ VALUE io, dirname;
{
VALUE dir;
@@ -1837,7 +1924,10 @@ dir_entries(VALUE io, VALUE dirname)
* File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
*/
static VALUE
-file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
+file_s_fnmatch(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE pattern, path;
VALUE rflags;
@@ -1849,9 +1939,9 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
flags = 0;
StringValue(pattern);
- FilePathStringValue(path);
+ StringValue(path);
- if (fnmatch(RSTRING_PTR(pattern), RSTRING_PTR(path), flags) == 0)
+ if (fnmatch(RSTRING(pattern)->ptr, RSTRING(path)->ptr, flags) == 0)
return Qtrue;
return Qfalse;
@@ -1869,7 +1959,7 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
* (<code>.</code>).
*/
void
-Init_Dir(void)
+Init_Dir()
{
rb_cDir = rb_define_class("Dir", rb_cObject);
@@ -1903,8 +1993,6 @@ Init_Dir(void)
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,"exist?", rb_file_directory_p, 1); /* in file.c */
- rb_define_singleton_method(rb_cDir,"exists?", rb_file_directory_p, 1); /* in file.c */
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/djgpp/config.hin b/djgpp/config.hin
index f90f2ed061..8ee427c92f 100644
--- a/djgpp/config.hin
+++ b/djgpp/config.hin
@@ -106,9 +106,9 @@
#define NEED_IO_FLUSH_BETWEEN_RW 1
#define DEFAULT_KCODE KCODE_NONE
#define DLEXT ".so"
-#define RUBY_LIB "/lib/ruby/@MAJOR@.@MINOR@.@TEENY@"
+#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@.@TEENY@"
+#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/@MAJOR@.@MINOR@"
#define RUBY_PLATFORM "i386-msdosdjgpp"
-#define RUBY_ARCHLIB "/lib/ruby/@MAJOR@.@MINOR@.@TEENY@/i386-msdosdjgpp"
-#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/@MAJOR@.@MINOR@.@TEENY@/i386-msdosdjgpp"
+#define RUBY_ARCHLIB "/lib/ruby/@MAJOR@.@MINOR@/i386-msdosdjgpp"
+#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/@MAJOR@.@MINOR@/i386-msdosdjgpp"
diff --git a/dln.c b/dln.c
index 6403e9a87c..5ba25b6415 100644
--- a/dln.c
+++ b/dln.c
@@ -6,11 +6,11 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "dln.h"
#ifdef HAVE_STDLIB_H
@@ -110,7 +110,9 @@ char *getenv();
#endif
static int
-init_funcname_len(char **buf, const char *file)
+init_funcname_len(buf, file)
+ char **buf;
+ const char *file;
{
char *p;
const char *slash;
@@ -182,8 +184,8 @@ static int dln_init_p = 0;
#define INVALID_OBJECT(h) (N_MAGIC(h) != OMAGIC)
-#include "ruby/util.h"
-#include "ruby/st.h"
+#include "util.h"
+#include "st.h"
static st_table *sym_tbl;
static st_table *undef_tbl;
@@ -191,7 +193,10 @@ static st_table *undef_tbl;
static int load_lib();
static int
-load_header(int fd, struct exec *hdrp, long disp)
+load_header(fd, hdrp, disp)
+ int fd;
+ struct exec *hdrp;
+ long disp;
{
int size;
@@ -261,7 +266,10 @@ static int reloc_r_length[] = {
#endif
static struct relocation_info *
-load_reloc(int fd, struct exec *hdrp, long disp)
+load_reloc(fd, hdrp, disp)
+ int fd;
+ struct exec *hdrp;
+ long disp;
{
struct relocation_info *reloc;
int size;
@@ -284,7 +292,10 @@ load_reloc(int fd, struct exec *hdrp, long disp)
}
static struct nlist *
-load_sym(int fd, struct exec *hdrp, long disp)
+load_sym(fd, hdrp, disp)
+ int fd;
+ struct exec *hdrp;
+ long disp;
{
struct nlist * buffer;
struct nlist * sym;
@@ -325,7 +336,9 @@ load_sym(int fd, struct exec *hdrp, long disp)
}
static st_table *
-sym_hash(struct exec *hdrp, struct nlist *syms)
+sym_hash(hdrp, syms)
+ struct exec *hdrp;
+ struct nlist *syms;
{
st_table *tbl;
struct nlist *sym = syms;
@@ -345,7 +358,8 @@ sym_hash(struct exec *hdrp, struct nlist *syms)
}
static int
-dln_init(const char *prog)
+dln_init(prog)
+ const char *prog;
{
char *file;
int fd;
@@ -419,7 +433,11 @@ dln_init(const char *prog)
}
static long
-load_text_data(int fd, struct exec *hdrp, int bss, long disp)
+load_text_data(fd, hdrp, bss, disp)
+ int fd;
+ struct exec *hdrp;
+ int bss;
+ long disp;
{
int size;
unsigned char* addr;
@@ -453,7 +471,8 @@ load_text_data(int fd, struct exec *hdrp, int bss, long disp)
}
static int
-undef_print(char *key, char *value)
+undef_print(key, value)
+ char *key, *value;
{
fprintf(stderr, " %s\n", key);
return ST_CONTINUE;
@@ -490,7 +509,10 @@ struct undef {
static st_table *reloc_tbl = NULL;
static void
-link_undef(const char *name, long base, struct relocation_info *reloc)
+link_undef(name, base, reloc)
+ const char *name;
+ long base;
+ struct relocation_info *reloc;
{
static int u_no = 0;
struct undef *obj;
@@ -523,7 +545,10 @@ struct reloc_arg {
};
static int
-reloc_undef(int no, struct undef *undef, struct reloc_arg *arg)
+reloc_undef(no, undef, arg)
+ int no;
+ struct undef *undef;
+ struct reloc_arg *arg;
{
int datum;
char *address;
@@ -584,7 +609,9 @@ reloc_undef(int no, struct undef *undef, struct reloc_arg *arg)
}
static void
-unlink_undef(const char *name, long value)
+unlink_undef(name, value)
+ const char *name;
+ long value;
{
struct reloc_arg arg;
@@ -599,7 +626,10 @@ struct indr_data {
};
static int
-reloc_repl(int no, struct undef *undef, struct indr_data *data)
+reloc_repl(no, undef, data)
+ int no;
+ struct undef *undef;
+ struct indr_data *data;
{
if (strcmp(data->name0, undef->name) == 0) {
free(undef->name);
@@ -610,7 +640,10 @@ reloc_repl(int no, struct undef *undef, struct indr_data *data)
#endif
static int
-load_1(int fd, long disp, const char *need_init)
+load_1(fd, disp, need_init)
+ int fd;
+ long disp;
+ const char *need_init;
{
static const char *libc = LIBC_NAME;
struct exec hdr;
@@ -891,7 +924,10 @@ load_1(int fd, long disp, const char *need_init)
static int target_offset;
static int
-search_undef(const char *key, int value, st_table *lib_tbl)
+search_undef(key, value, lib_tbl)
+ const char *key;
+ int value;
+ st_table *lib_tbl;
{
long offset;
@@ -908,7 +944,8 @@ struct symdef {
char *dln_librrb_ary_path = DLN_DEFAULT_LIB_PATH;
static int
-load_lib(const char *lib)
+load_lib(lib)
+ const char *lib;
{
char *path, *file;
char armagic[SARMAG];
@@ -1045,7 +1082,8 @@ load_lib(const char *lib)
}
static int
-load(const char *file)
+load(file)
+ const char *file;
{
int fd;
int result;
@@ -1070,7 +1108,8 @@ load(const char *file)
}
void*
-dln_sym(const char *name)
+dln_sym(name)
+ const char *name;
{
struct nlist *sym;
@@ -1082,7 +1121,12 @@ dln_sym(const char *name)
#endif /* USE_DLN_A_OUT */
#ifdef USE_DLN_DLOPEN
-# include <dlfcn.h>
+# if defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ < 105000000
+# include <nlist.h>
+# include <link.h>
+# else
+# include <dlfcn.h>
+# endif
#endif
#ifdef __hpux
@@ -1125,7 +1169,7 @@ dln_sym(const char *name)
#endif
static const char *
-dln_strerror(void)
+dln_strerror()
{
#ifdef USE_DLN_A_OUT
char *strerror();
@@ -1223,10 +1267,24 @@ aix_loaderror(const char *pathname)
}
#endif
+#if defined(__VMS)
+#include <starlet.h>
+#include <rms.h>
+#include <stsdef.h>
+#include <unixlib.h>
+#include <descrip.h>
+#include <lib$routines.h>
+
+static char *vms_filespec;
+static int vms_fileact(char *filespec, int type);
+static long vms_fisexh(long *sigarr, long *mecarr);
+#endif
+
#endif /* NO_DLN_LOAD */
void*
-dln_load(const char *file)
+dln_load(file)
+ const char *file;
{
#ifdef NO_DLN_LOAD
rb_raise(rb_eLoadError, "this executable file can't load extension libraries");
@@ -1528,9 +1586,16 @@ dln_load(const char *file)
#if defined(__VMS)
#define DLN_DEFINED
{
- void *handle, (*init_fct)();
+ long status;
+ void (*init_fct)();
char *fname, *p1, *p2;
+ $DESCRIPTOR(fname_d, "");
+ $DESCRIPTOR(image_d, "");
+ $DESCRIPTOR(buf_d, "");
+
+ decc$to_vms(file, vms_fileact, 0, 0);
+
fname = (char *)__alloca(strlen(file)+1);
strcpy(fname,file);
if (p1 = strrchr(fname,'/'))
@@ -1538,19 +1603,35 @@ dln_load(const char *file)
if (p2 = strrchr(fname,'.'))
*p2 = '\0';
- if ((handle = (void*)dlopen(fname, 0)) == NULL) {
+ fname_d.dsc$w_length = strlen(fname);
+ fname_d.dsc$a_pointer = fname;
+ image_d.dsc$w_length = strlen(vms_filespec);
+ image_d.dsc$a_pointer = vms_filespec;
+ buf_d.dsc$w_length = strlen(buf);
+ buf_d.dsc$a_pointer = buf;
+
+ lib$establish(vms_fisexh);
+
+ status = lib$find_image_symbol (
+ &fname_d,
+ &buf_d,
+ &init_fct,
+ &image_d);
+
+ lib$establish(0);
+
+ if (status == RMS$_FNF) {
error = dln_strerror();
goto failed;
- }
-
- if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) {
+ } else if (!$VMS_STATUS_SUCCESS(status)) {
error = DLN_ERROR();
- dlclose(handle);
goto failed;
}
+
/* Call the init code */
(*init_fct)();
- return handle;
+
+ return 1;
}
#endif /* __VMS */
@@ -1569,10 +1650,12 @@ dln_load(const char *file)
return 0; /* dummy return */
}
-static char *dln_find_1(const char *fname, const char *path, int exe_flag);
+static char *dln_find_1();
char *
-dln_find_exe(const char *fname, const char *path)
+dln_find_exe(fname, path)
+ const char *fname;
+ const char *path;
{
if (!path) {
path = getenv(PATH_ENV);
@@ -1589,7 +1672,9 @@ dln_find_exe(const char *fname, const char *path)
}
char *
-dln_find_file(const char *fname, const char *path)
+dln_find_file(fname, path)
+ const char *fname;
+ const char *path;
{
#ifndef __MACOS__
if (!path) path = ".";
@@ -1603,7 +1688,10 @@ dln_find_file(const char *fname, const char *path)
static char fbuf[MAXPATHLEN];
static char *
-dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking for executable. */)
+dln_find_1(fname, path, exe_flag)
+ const char *fname;
+ const char *path;
+ int exe_flag; /* non 0 if looking for executable. */
{
register const char *dp;
register const char *ep;
@@ -1613,23 +1701,21 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
const char* mac_fullpath;
#endif
-#define RETURN_IF(expr) if (expr) return (char *)fname;
-
- RETURN_IF(!fname);
- RETURN_IF(fname[0] == '/');
- RETURN_IF(strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0);
- RETURN_IF(exe_flag && strchr(fname, '/'));
+ if (!fname) return (char *)fname;
+ if (fname[0] == '/') return (char *)fname;
+ if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
+ return (char *)fname;
+ if (exe_flag && strchr(fname, '/')) return (char *)fname;
#ifdef DOSISH
- RETURN_IF(fname[0] == '\\');
+ if (fname[0] == '\\') return (char *)fname;
# ifdef DOSISH_DRIVE_LETTER
- RETURN_IF(strlen(fname) > 2 && fname[1] == ':');
+ if (strlen(fname) > 2 && fname[1] == ':') return (char *)fname;
# endif
- RETURN_IF(strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0);
- RETURN_IF(exe_flag && strchr(fname, '\\'));
+ if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
+ return (char *)fname;
+ if (exe_flag && strchr(fname, '\\')) return (char *)fname;
#endif
-#undef RETURN_IF
-
for (dp = path;; dp = ++ep) {
register int l;
int i;
@@ -1695,26 +1781,9 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
}
memcpy(bp, fname, i + 1);
-#ifndef __MACOS__
- if (stat(fbuf, &st) == 0) {
- if (exe_flag == 0) return fbuf;
- /* looking for executable */
- if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0)
- return fbuf;
- }
-#else
- if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) {
- if (exe_flag == 0) return mac_fullpath;
- /* looking for executable */
- if (stat(mac_fullpath, &st) == 0) {
- if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0)
- return mac_fullpath;
- }
- }
-#endif
#if defined(DOSISH)
if (exe_flag) {
- static const char *const extension[] = {
+ static const char extension[][5] = {
#if defined(MSDOS)
".com", ".exe", ".bat",
#if defined(DJGPP)
@@ -1727,11 +1796,10 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
".r", ".R", ".x", ".X", ".bat", ".BAT",
/* __human68k__ */
#endif
- (char *) NULL
};
int j;
- for (j = 0; extension[j]; j++) {
+ for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) {
if (fspace < strlen(extension[j])) {
fprintf(stderr, "openpath: pathname too long (ignored)\n");
fprintf(stderr, "\tDirectory \"%.*s\"\n", (int) (bp - fbuf), fbuf);
@@ -1748,9 +1816,28 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
#endif
}
+ goto next;
}
#endif /* MSDOS or _WIN32 or __human68k__ or __EMX__ */
+#ifndef __MACOS__
+ if (stat(fbuf, &st) == 0) {
+ if (exe_flag == 0) return fbuf;
+ /* looking for executable */
+ if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0)
+ return fbuf;
+ }
+#else
+ if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) {
+ if (exe_flag == 0) return mac_fullpath;
+ /* looking for executable */
+ if (stat(mac_fullpath, &st) == 0) {
+ if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0)
+ return mac_fullpath;
+ }
+ }
+#endif
+
next:
/* if not, and no other alternatives, life is bleak */
if (*ep == '\0') {
@@ -1760,3 +1847,24 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
/* otherwise try the next component in the search path */
}
}
+
+#if defined(__VMS)
+
+/* action routine for decc$to_vms */
+static int vms_fileact(char *filespec, int type)
+{
+ if (vms_filespec)
+ free(vms_filespec);
+ vms_filespec = malloc(strlen(filespec)+1);
+ strcpy(vms_filespec, filespec);
+ return 1;
+}
+
+/* exception handler for LIB$FIND_IMAGE_SYMBOL */
+static long vms_fisexh(long *sigarr, long *mecarr)
+{
+ sys$unwind(1, 0);
+ return 1;
+}
+
+#endif /* __VMS */
diff --git a/dln.h b/dln.h
index 6905a36d5a..182cf9f9f4 100644
--- a/dln.h
+++ b/dln.h
@@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 19 16:53:09 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -29,12 +29,12 @@
# define _(args) ()
#endif
-char *dln_find_exe(const char*,const char*);
-char *dln_find_file(const char*,const char*);
+char *dln_find_exe _((const char*,const char*));
+char *dln_find_file _((const char*,const char*));
#ifdef USE_DLN_A_OUT
extern char *dln_argv0;
#endif
-void *dln_load(const char*);
+void *dln_load _((const char*));
#endif
diff --git a/dmyext.c b/dmyext.c
index 4d273f7faf..4120d493c3 100644
--- a/dmyext.c
+++ b/dmyext.c
@@ -1,4 +1,4 @@
void
-Init_ext(void)
+Init_ext()
{
}
diff --git a/doc/ChangeLog-YARV b/doc/ChangeLog-YARV
deleted file mode 100644
index c9d32916cf..0000000000
--- a/doc/ChangeLog-YARV
+++ /dev/null
@@ -1,6917 +0,0 @@
-# $Id: ChangeLog 590 2006-12-31 09:02:34Z ko1 $
-#
-# YARV ChangeLog
-# from Mon, 03 May 2004 01:24:19 +0900
-#
-
-Sun Dec 31 18:01:50 2006 Koichi Sasada <ko1@atdot.net>
-
- * bin/* : ruby/trunk/bin 11437
-
-
-Sun Dec 31 17:42:05 2006 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : remove old Kernel#funcall definition
-
-
-2006-12-30(Sat) 07:59:26 +0900 Koichi Sasada <ko1@atdot.net>
-
- * catch up ruby/trunk 11437
-
- * eval_intern.h : reorder tag initialization
-
- * eval.c : fix to support __send!, funcall and prohibit funcall as
- send
-
- * eval_error.h, eval_jump.h, eval_safe.h : fix prototypes
-
- * eval_method.h, vm.c : check re-definition at rb_add_method()
-
- * yarvcore.h : fix typo
-
- * compile.c : fix white spaces
-
- * lib/delegate.rb : fix to support __send, ...
-
- * lib/getoptlong.rb : fix to work on YARV
-
- * lib/rss/parser.rb : use __send! instead of __send__
-
- * sample/test.rb : comment out codes which use |&b| type block parameter
-
- * ext/ripper/extconf.rb : turn off
-
- * test/ripper/test_files.rb, test_parser_events.rb,
- test_scanner_events.rb : fix to check it has ripper module
-
- * vm_dump.c : remove showing file path length limitation
-
- * yarvtest/test_eval.rb : use __send! instead of __send__
-
-
-2006-12-19(Tue) 11:46:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * doc/* : added
-
- * ext/openssl : added
-
- * ext/ripper : added
-
- * test/openssl : added
-
- * test/ripper : added
-
- * misc : added
-
- * rb/ -> tool/ : renamed
-
- * common.mk : fixed for above change
-
- * ruby_doc/* : move to topdir
-
- * sample/* : added
-
- * test2.rb : removed
-
-
-2006-12-15(Fri) 09:42:46 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : remove obsolete codes
-
- * insns.def : fix a comment of getconstant
-
-
-2006-12-13(Wed) 16:26:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, compile.c, compile.h, debug.c, debug.h,
- insnhelper.h, insns.def, iseq.c, thread.c, thread_pthread.ci,
- thread_pthread.h, thread_win32.ci, thread_win32.h, vm.c, vm.h,
- vm_dump.c, vm_evalbody.ci, vm_opts.h.base, yarv.h,
- yarv_version.h, yarvcore.c, yarvcore.h :
- add a header includes copyright
-
-
-2006-12-12(Tue) 13:13:32 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb : add PREFETCH() statement
-
- * vm.h : ditto
-
- * yarvcore.h : fix LIKELY(x) and
- remove main_thread_val field from yarv_vm_t
-
- * yarvcore.c : ditto
-
- * thread.c : support fork
-
- * eval_thread.c : ditto
-
- * process.c : ditto
-
- * signal.c : ditto
-
- * test/ruby/test_signal.rb :
-
- * thread_pthread.ci : rename timer thread functions
-
- * thread_win32.ci : ditto
-
-
-2006-11-10(Fri) 21:29:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix to compile arguments
-
- * insns.def : fix to duplicate first array value on concatarray
- instruction
-
- * yarvtest/test_bin.rb : add a test for above change
-
- * sample/test.rb : fix to catch up Ruby HEAD (fix to remove test about
- module duplicate)
-
-
-2006-11-10(Fri) 12:49:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm_macro.def : fix to inherit visibility on
- NODE_SUPER method invocation
-
-
-2006-11-10(Fri) 09:13:46 +0900 Koichi Sasada <ko1@atdot.net>
-
- * class.c : revert module duplicate inclusion
-
- * parse.y : catch up current Ruby HEAD
-
- * node.h : ditto
-
- * compile.c : ditto
-
- * gc.c : ditto
-
- * iseq.c : ditto
-
- * eval_thread.c : define Continuation (null class)
-
- * vm_dump.c : fix to output backtrae to stderr
-
- * yarvtest/test_block.rb : remove unsupported test
-
- * yarvtest/test_class.rb : add a test about super
-
- * yarvtest/test_syntax.rb : add a test about case/when
-
-
-2006-11-09(Thu) 10:22:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * call_cfunc.h -> call_cfunc.ci : renamed
-
- * vm_evalbody.h, vm_evalbody.ci : ditto
-
- * thread_pthread.h, thread_pthread.ci : separate declaration and
- implementation
-
- * thread_win32.h, thread_win32.ci : ditto
-
- * thread.c : use *.ci instead of *.c as implementation
-
- * vm.c : ditto
-
- * common.mk : fix rules for above changes
-
-
-2006-11-08(Wed) 17:23:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm_dump.c : show C level backtrace (pointer only) with
- backtrace() function (glibc feature)
-
- * configure.in : ditto
-
- * yarvcore.c : add NSDR method (show C level backtrace)
-
- * error.c : fix indent
-
-
-2006-11-07(Tue) 13:17:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (rb_set_errinfo) : added
-
- * ruby.h : ditto
-
- * version.h : fix version number
-
- * lib/webrick/utils.rb : fix to remove Thread.critical
-
- * ext/dbm, dl, gdbm, iconv, io, pty, sdbm : added
-
- * test/dbm, gdbm, io, logger, net, readline, sdbm, soap,
- webrick, win32ole, wsdl, xsd : added
-
-
-2006-11-06(Mon) 22:32:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c : import Ruby HEAD
-
- * ext/socket/extconf.rb : ditto
-
- * ext/socket/socket.c : ditto
-
- * gc.c : ditto
-
- * lib/date.rb : ditto
-
- * lib/net/imap.rb : ditto
-
- * lib/rss/0.9.rb : ditto
-
- * lib/set.rb : ditto
-
- * lib/soap/mapping/rubytypeFactory.rb : ditto
-
- * lib/soap/mimemessage.rb : ditto
-
- * lib/soap/property.rb : ditto
-
- * lib/webrick/httprequest.rb : ditto
-
- * lib/webrick/httputils.rb : ditto
-
- * lib/xmlrpc/create.rb : ditto
-
- * lib/xsd/codegen/gensupport.rb : ditto
-
- * object.c : ditto
-
- * ruby.h : ditto
-
- * string.c : ditto
-
- * version.h : ditto
-
- * rb/ir.rb : fix to use "diffs" directory
-
- * vm_dump.c : add "const"
-
-
-2006-11-06(Mon) 16:36:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_proc.c : remove "static" from external global variables
-
- * eval_thread.c : ditto
-
- * array.c : fix indent
-
- * insns.def : add a suitable cast
-
- * vm_macro.def : allow scalar value on splat arguments
-
- * yarvtest/test_block.rb : fix to synchronize Ruby HEAD
-
- * rb/insns2vm.rb : remove String#each for 1.9
-
- * template/vm.inc.tmpl : ditto (remove String#each_with_index)
-
-
-2006-11-06(Mon) 13:22:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * iseq.c : fixed GC debugging outputs
-
- * rb/parse.rb : fixed output format
-
-
-2006-11-04(Sat) 09:46:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix to duplicate "#{'foo'}" string
-
- * yarvtest/test_bin.rb : add a test for above
-
- * ext/readline/readline.c : import Ruby HEAD
-
- * keywords : ditto
-
- * lex.c : ditto
-
- * parse.y : ditto
-
- * lib/mkmf.rb : ditto
-
- * test/ruby/test_hash.rb : fix to current specification
-
- * test/ruby/test_string.rb : ditto
-
-
-2006-11-03(Fri) 20:58:36 +0900 Koichi Sasada <ko1@atdot.net>
-
- * ext/nkf/nkf-utf8/utf8tbl.h : missed to add
-
- * configure.in : import ruby HEAD
-
- * test/ruby/test_array.rb : ditto
-
- * test/ruby/test_assignment.rb : ditto
-
- * test/ruby/test_clone.rb : ditto
-
- * test/socket/test_socket.rb : ditto
-
- * test/socket/test_unix.rb : ditto
-
- * test/strscan/test_stringscanner.rb : ditto
-
- * test/testunit/collector/test_dir.rb : ditto
-
-
-2006-11-03(Fri) 20:22:24 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c : import current ruby HEAD and apply API changes
- This version has some known bugs
-
- * bignum.c : ditto
-
- * blockinlining.c : ditto
-
- * class.c : ditto
-
- * compile.c : ditto
-
- * dir.c : ditto
-
- * dln.c : ditto
-
- * enum.c : ditto
-
- * enumerator.c : ditto
-
- * error.c : ditto
-
- * eval.c : ditto
-
- * eval_error.h : ditto
-
- * eval_jump.h : ditto
-
- * eval_load.c : ditto
-
- * eval_proc.c : ditto
-
- * ext/*
-
- * file.c : ditto
-
- * gc.c : ditto
-
- * hash.c : ditto
-
- * insns.def : ditto
-
- * instruby.rb : ditto
-
- * intern.h : ditto
-
- * io.c : ditto
-
- * iseq.c : ditto
-
- * lib/*
-
- * marshal.c : ditto
-
- * math.c : ditto
-
- * missing/vsnprintf.c : ditto
-
- * mkconfig.rb : ditto
-
- * node.h : ditto
-
- * numeric.c : ditto
-
- * object.c : ditto
-
- * oniguruma.h : ditto
-
- * pack.c : ditto
-
- * parse.y : ditto
-
- * prec.c : ditto
-
- * process.c : ditto
-
- * random.c : ditto
-
- * range.c : ditto
-
- * rb/ir.rb : ditto
-
- * re.c : ditto
-
- * regcomp.c : ditto
-
- * regerror.c : ditto
-
- * regexec.c : ditto
-
- * regint.h : ditto
-
- * regparse.c : ditto
-
- * regparse.h : ditto
-
- * ruby.c : ditto
-
- * ruby.h : ditto
-
- * rubytest.rb : ditto
-
- * runruby.rb : ditto
-
- * sample/test.rb : ditto
-
- * signal.c : ditto
-
- * sprintf.c : ditto
-
- * st.c : ditto
-
- * st.h : ditto
-
- * string.c : ditto
-
- * struct.c : ditto
-
- * test/*
-
- * thread.c : ditto
-
- * time.c : ditto
-
- * util.c : ditto
-
- * variable.c : ditto
-
- * version.h : ditto
-
- * vm.c : ditto
-
- * vm_dump.c : ditto
-
- * vm_macro.def : ditto
-
- * win32/*
-
-
-2006-10-31(Tue) 22:47:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * parse.y : fix NEWHEAP bugs (import HEAD)
-
- * ruby.c, intern.h, yarvcore.c (rb_load_file) : change to
- return parsed node pointer
-
- * rb/ir.rb : add check mode
-
-
-2006-09-01(Fri) 22:05:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix a bug of peephole optimization and enable
- regexp optimization
-
-
-2006-08-21(Mon) 05:27:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/mathn.rb : remove "remove_method :gcd2"
-
- * opt_insn_unif.def : unset opt setting
-
- * opt_operand.def : ditto
-
-
-2006-08-18(Fri) 17:55:31 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add dependency of yarvcore.h to thread.o
-
- * gc.c : change comment line
-
- * thread.c : remove some line break
-
- * yarvcore.c : reoder initialize sequence to mark main thread
-
-
-2006-08-18(Fri) 16:51:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : add a support for cache values per thread
-
- * yarvcore.c : ditto
-
- * gc.c : ditto
-
- * thread.c : move a expression after acquiring lock
-
- * compile.c : add a cast to remove warning
-
-
-2006-08-18(Fri) 02:07:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix to return rhs value on ATTRASGIN
-
- * insns.def (setn) : add insn setn
-
- * yarvtest/test_bin.rb : add tests for above
-
-
-2006-08-17(Thu) 22:46:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : clear callee_id ([yarv-dev:1073])
-
-
-2006-08-17(Thu) 22:14:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.h : fix error message
-
-
-2006-08-17(Thu) 12:23:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : change initilize routine order ([yarv-dev:1067])
-
- * yarvcore.c (Init_yarv) : init th->machine_stack_start
-
- * thread_pthread.h : add malloc value check ([yarv-dev:1066])
-
- * insns.def (opt_eq) : fix typo ([yarv-dev:1072])
-
- * yarvtest/test_opts.rb : add a test for above
-
- * yarvtest/test_class.rb : add a test for last commit
-
-
-2006-08-17(Thu) 11:02:16 +0900 Koichi Sasada <ko1@atdot.net>
-
- * class.c (clone_method) : check undef-ed method ([yarv-dev:1068])
-
-
-2006-08-15(Tue) 15:07:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix opt_plus routine ([yarv-dev-en:149])
-
- * yarvtest/test_opts.rb : add tests for above
-
-
-2006-08-06(Sun) 06:24:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : fix build rule (build only ruby binary when benchmark)
-
- * yarvcore.[ch] : fix and add yarv_iseq_new_with_* API
-
- * blockinlining.c : ditto
-
- * compile.c : ditto
-
- * compile.h : ditto
-
- * iseq.c : ditto
-
- * eval_method.h : check redefinition for specialized instruction
-
- * insnhelper.h : ditto
-
- * insns.def : ditto
-
- * vm.c : ditto
-
- * vm.h : ditto
-
- * numeric.c : add Fixnum#succ
-
- * thread.c : remove duplicated method Thread#current
-
- * yarvcore.c : remove duplicated method Proc#clone
-
- * yarvtest/test_opts.rb : added
-
-
-2006-07-20(Thu) 04:10:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix [yarv-dev:1041] problem (raise TypeError)
-
- * eval.c : rb_funcall2 send as NOEX_PRIVATE and check scope
-
-
-2006-07-20(Thu) 03:38:46 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : fix [yarv-dev:1040] bug
-
-
-2006-07-18(Tue) 18:45:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * some files : set property "svn:eol-style" as native
-
-
-2006-07-18(Tue) 18:35:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * gc.h : fix a static function name
-
- * vm.c : remove Japanese comments
-
- * yarvcore.c : add a comment
-
- * some files : set property "svn:eol-style" as native
-
-
-2006-07-18(Tue) 16:48:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : remove unused code
-
- * compile.c : add checking value
-
- * iseq.c : ditto
-
- * yarvcore.c : fix yarv_th_eval prototype declaration
-
- * yarvtest/yarvtest.rb : use compile instead of parse method
-
-
-2006-07-12(Wed) 15:18:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarv_version.h : 0.4.1
-
- * Changes : ditto
-
-
-2006-07-12(Wed) 13:38:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : fix indent
-
- * gc.h : fix syntax bug
-
- * thread_pthread.h : vanish warnning message
-
- * iseq.c : ditto
-
- * compile.c : ditto
-
- * thread.c : ditto
-
- * vm.c : ditto
-
- * yarvcore.c : prohibit tail call optimization to mark
- iseq object
-
- * yarvcore.h : add some allocator function declaration
-
- * yarvtest/test_eval.rb : remove output
-
-
-2006-07-12(Wed) 05:01:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : undef alloc funcs
-
- * eval_proc.c : ditto (use factory faction)
-
- * thread.c : ditto
-
- * vm.c : ditto
-
- * iseq.c : fix compile option creation
-
- * rb/allload.rb : use compile_file method
-
- * rb/compile.rb : ditto
-
- * rb/parse.rb : ditto
-
- * template/insnstbl.html : hide mail addr
-
-
-2006-07-11(Tue) 21:34:29 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_dir.rb: new test test_JVN_13947696.
-
-
-2006-07-11(Tue) 21:26:41 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_alias.rb: new test test_JVN_83768862.
-
-
-2006-07-11(Tue) 11:33:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix compile error on C90
-
-
-2006-07-11(Tue) 10:40:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * disasm.c : removed
-
- * iseq.c : added
-
- * common.mk : ditto
-
- * blockinlining.c : Get*Val => Get*Ptr
-
- * eval.c : ditto
-
- * yarvcore.c : ditto
-
- * eval_proc.c : ditto
-
- * vm_dump.c : ditto
-
- * vm_macro.def : ditto
-
- * signal.c : ditto
-
- * vm.c : ditto
-
- * thread.c : ditto
-
- * compile.c : rename local variable insnobj => iobj
-
- * compile.c : support yarv_compile_option_t
-
- * gc.h : added
-
- * insns.def : use OPT_CHECKED_RUN instead of IGNORE_OPTIMIZE
-
- * rb/compile.rb : use compile option
-
- * template/optinsn.inc.tmpl : fix function name
-
- * vm_opts.h.base : change macros
-
- * rb/insns2vm.rb : ditto
-
- * yarv.h : fix yarvcore_eval_parsed parameter type
-
- * yarvcore.c : fix some interfaces (functions)
-
- * yarvcore.h : add a type yarv_compile_option_t
-
-
-2006-07-06(Thu) 13:45:20 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/yasm.rb : pass builder object if block arity == 1
-
-
-2006-07-05(Wed) 11:23:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/yasm.rb : fix method name
-
- * vm.c (th_set_top_stack) : check toplevel or not
-
-
-2006-07-04(Tue) 20:05:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/compile.rb : added
-
- * yarvtest/yarvtest.rb : disable load/store test
-
-
-2006-07-04(Tue) 18:17:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix some bugs about load iseq data
-
- * disasm.c : ditto (store)
-
- * eval.c (rb_f_local_variables) : fix bugs
-
- * insns.def : fix otp_ltlt condition bug
-
- * vm.c : ditto
-
- * yarvcore.c : rename some functions
-
- * yarvtest/yarvtest.rb : add iseq load/store tests
- (to enable this, remove comment)
-
-
-2006-07-03(Mon) 01:54:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_thread.c : add parameter "th" to thread_set_raised
-
- * yarvcore.h : ditto
-
- * eval_intern.h : ditto
-
- * eval.c : ditto
-
- * eval_error.h : declare with ANSI style
-
- * disasm.c : rename iseq_iseq2simpledata() to iseq_data_to_ary
-
- * lib/yasm.rb : rename Instruction#to_simpledata to
- Instruction#to_a
-
- * yarvcore.c : ditto
-
- * vm.c : fix bug (Proc.new{|*args| p args}.call(1) #=> 1)
-
- * yarvtest/test_proc.rb : add a tests for above
-
-
-2006-06-21(Wed) 09:19:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : remove yarv_iseq_t#catch_table_ary and
- add yarv_iseq_t#compile_data#catch_table_ary
-
- * compile.h : ditto
-
- * yarvcore.c : ditto
-
- * yarvcore.h : ditto
-
- * eval_thread.c : remove unused code
-
- * thread.c : add rb_gc_mark_threads() (from eval_thread.c)
-
-
-2006-05-31(Wed) 21:26:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * parse.y : prohibit tail call optimization to mark vparsr
- object
-
-
-2006-05-25(Thu) 15:37:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c : support NEW_ATTRASGN node
-
- * class.c : skip undefined method to collect ([yarv-dev:999])
-
- * yarvtest/test_class.rb : add a test for above
-
- * compile.c : fix opt_regexpmatch1 condition
-
- * lib/monitor.rb : fix [yarv-dev:1009]
-
- * rb/insns2vm.rb : fix typo
-
- * thread.c : prohibit unlock by not mutex owner thread
-
- * vm_opts.h.base : change default option
-
-
-2006-05-18(Thu) 16:00:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * intern.h : fix prototype declarations for last re.c change
-
-
-2006-05-18(Thu) 12:12:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/runruby.rb : added
-
- * thread.c (rb_thread_alone) : check if vm->living_threads
- is available
-
-
-2006-05-18(Thu) 12:05:35 +0900 Koichi Sasada <ko1@atdot.net>
-
- * signal.c : not mask SIGSEGV
-
- * thread.c : fix debug output on Win32
-
- * thread.c, thread_pthread.h : add some debug prints
-
- * yarvcore.c : mark machine registers on thread_mark
-
-
-2006-05-17(Wed) 18:09:20 +900 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (sys_warning): should not call a vararg function
- rb_sys_warning() indirectly. [ruby-core:07886]
-
-
-2006-05-17(Wed) 16:41:41 +900 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_initialize): should not allow modifying literal
- regexps. frozen check moved from rb_reg_initialize_m as well.
-
- * re.c (rb_reg_initialize): should not modify untainted objects in
- safe levels higher than 3.
-
- * re.c (rb_memcmp): type change from char* to const void*.
-
- * dir.c (dir_close): should not close untainted dir stream.
-
- * dir.c (GetDIR): add tainted/frozen check for each dir operation.
-
-
-2006-05-07(Sun) 21:06:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c : remove Mutex#unlock_and_stop and add Mutex#sleep
-
- * lib/monitor.rb : ditto
-
- * lib/thread.rb : ditto
-
- * thread_pthread.h : fix stack size
-
- * thread_win32.h : fix sleep
-
- * yarvcore.h : disable to use get/setcontext
-
- * lib/webrick/server.rb : add experimental implementation
- using thraeds pool
-
-
-2006-05-05(Fri) 13:59:00 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_signal.rb : disable a test
-
- * thread.c : do trylock before lock on mutex_lock
-
- * thread_win32.h : use CriticalSection instead of Mutex
-
-
-2006-05-05(Fri) 03:03:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : vtune rule make run test.rb
-
- * disasm.c : fix syntax errors (on VC)
-
- * yarvcore.c : ditto
-
- * lib/thread.rb : Mutex#synchronize is defined here
-
- * lib/*.rb : ditto
-
- * signal.c : separate pthread or not
-
- * thread.c : support lightweight wakeup
-
- * thread_pthread.h : ditto
-
- * thread_win32.h : ditto
-
- * yarvcore.h : ditto
-
- * yarvtest/test_thread.rb : restore last change
-
-
-2006-05-04(Thu) 18:11:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_thread.c : remove rb_thread_interrupt
-
- * intern.h : ditto
-
- * signal.c : change signal transfer route
-
- * thread.c : ditto
-
- * thread_pthread.h : ditto
-
- * thread_win32.h : ditto
-
- * yarv.h : support GET_VM()
-
- * yarvcore.h : change yarv_thread_t/yarv_vm_t structure
-
- * yarvtest/test_thread.rb : decrease threads to test
-
-
-2006-05-04(Thu) 00:26:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.h : experimental support of thread cache
-
-
-2006-04-25(Tue) 22:30:14 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : remove struct yarv_cmethod_info, add
- data structure for profiling and extend yarv_control_frame_t
-
- * vm.c : make pop_frame() and apply above change
-
- * eval.c : ditto
-
- * vm_dump.c : ditto
-
- * vm_macro.def : ditto
-
- * insns.def (leave): use pop_frame() instead of
- POP_CONTROL_STACK_FRAME() macro
-
- * insnhelper.h : remove some macros
-
- * yarvcore.c : change th_set_top_stack() prototype
-
-
-2006-04-18(Tue) 18:37:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, disasm.c : support export/import exception
- information
-
- * yarvcore.h : change "struct catch_table_entry" member variable
- order
-
-
-2006-04-13(Thu) 17:11:30 +0900 Koichi Sasada <ko1@atdot.net>
-
- * bignum.c : import ruby 1.9 HEAD (Ruby 1.9.0 2006-04-08)
-
- * dir.c : ditto
-
- * enumerator.c : ditto
-
- * ext/.document : ditto
-
- * ext/extmk.rb : ditto
-
- * ext/nkf/lib/kconv.rb : ditto
-
- * ext/nkf/nkf-utf8/nkf.c : ditto
-
- * ext/nkf/nkf-utf8/utf8tbl.c : ditto
-
- * ext/nkf/nkf.c : ditto
-
- * ext/nkf/test.rb : ditto
-
- * ext/socket/.cvsignore : ditto
-
- * ext/win32ole/sample/excel2.rb : ditto
-
- * ext/win32ole/tests/testOLEMETHOD.rb : ditto
-
- * ext/win32ole/tests/testOLEPARAM.rb : ditto
-
- * ext/win32ole/tests/testOLETYPE.rb : ditto
-
- * ext/win32ole/tests/testOLETYPELIB.rb : ditto
-
- * ext/win32ole/tests/testOLEVARIABLE.rb : ditto
-
- * ext/win32ole/tests/testOLEVARIANT.rb : ditto
-
- * ext/win32ole/tests/testWIN32OLE.rb : ditto
-
- * ext/win32ole/tests/testall.rb : ditto
-
- * ext/win32ole/win32ole.c : ditto
-
- * gc.c : ditto
-
- * instruby.rb : ditto
-
- * io.c : ditto
-
- * lib/delegate.rb : ditto
-
- * lib/fileutils.rb : ditto
-
- * lib/find.rb : ditto
-
- * lib/irb/ruby-lex.rb : ditto
-
- * lib/mkmf.rb : ditto
-
- * lib/net/http.rb : ditto
-
- * lib/open-uri.rb : ditto
-
- * lib/pathname.rb : ditto
-
- * lib/rational.rb : ditto
-
- * lib/rdoc/parsers/parse_rb.rb : ditto
-
- * lib/rdoc/ri/ri_paths.rb : ditto
-
- * lib/resolv.rb : ditto
-
- * lib/test/unit/collector/objectspace.rb : ditto
-
- * lib/webrick/httpservlet/cgihandler.rb : ditto
-
- * math.c : ditto
-
- * mkconfig.rb : ditto
-
- * object.c : ditto
-
- * oniguruma.h : ditto
-
- * pack.c : ditto
-
- * parse.y : ditto
-
- * re.c : ditto
-
- * re.h : ditto
-
- * regcomp.c : ditto
-
- * regerror.c : ditto
-
- * regparse.c : ditto
-
- * ruby.h : ditto
-
- * rubytest.rb : ditto
-
- * runruby.rb : ditto
-
- * string.c : ditto
-
- * test/digest/test_digest.rb : ditto
-
- * test/pathname/test_pathname.rb : ditto
-
- * test/ruby/envutil.rb : ditto
-
- * test/ruby/test_float.rb : ditto
-
- * test/ruby/test_pack.rb : ditto
-
- * time.c : ditto
-
- * util.c : ditto
-
- * version.h : ditto
-
- * win32/mkexports.rb : ditto
-
- * win32/resource.rb : ditto
-
- * win32/win32.c : ditto
-
-
-2006-04-11(Tue) 11:26:53 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/yasm.rb : move to lib/yasm.rb
-
-
-2006-04-09(Sun) 03:04:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : change to accept method iseq object when loading from
- simple data
-
- * yarvcore.c : add a debug output
-
- * rb/yasm.rb : change some interfaces
-
-
-2006-04-07(Fri) 20:25:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix miss about range of catch "next"
-
- * eval.c : add braces
-
-
-2006-04-07(Fri) 11:09:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : fix some make rules
-
- * insns.def : rename some instructions name
-
- * rb/insns2vm.rb : change some operand type name
-
- * vm_evalbody.h : ditto
-
- * template/insns.inc.tmpl : add YARV_MAX_INSTRUCTION_SIZE macro
-
- * compile.c, disasm.c, yarvcore.c : support load/store iseq from/to simple
- data structure such as array, literals, and so on
-
- * rb/yasm.rb : supported
-
- * vm.c : change interface of eval_define_method
-
- * yarvcore.h : remove unused externals
-
-
-2006-03-08(Wed) 10:31:29 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/delegate.rb (DelegateClass): do not delegate #send and
- #funcall.
-
-
-2006-02-27(Mon) 22:39:17 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/thread.rb: last commit causes busy loop, revert it. [yarv-dev:990]
-
- * lib/thread.rb: non_block=true wrongly caused ThreadError.
-
-
-2006-02-27(Mon) 21:33:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : fix to display command line
-
- * compile.c : fix comparison between a pointer and 0
-
- * debug.c : fix to output stder
-
- * disasm.c : add debug function
-
- * vm_dump.c : ditto
-
- * eval_proc.c : fix to skip class definition
-
- * ruby.h : fix T_VALUE to T_VALUES
-
- * gc.c : ditto
-
- * node.h : fix prototypes
-
- * vm.c : add VM_DEBUG macro
-
- * vm.c : fix compile error on VC++
-
- * vm.c : fix to inherit last lfp[0] on th_set_finish_env
-
- * vm.c : fix to add one svar location for any frame
-
- * vm_macro.def : ditto
-
- * yarvcore.h : add YARV_CLASS_SPECIAL_P() and YARV_BLOCK_PTR_P()
-
- * rdoc/ : removed
-
- * insns.def : fix to propagete throw state
-
-
-2006-02-27(Mon) 13:54:47 +0900 Minero Aoki <aamine@loveruby.net>
-
- * ext/syslog: imported from Ruby CVS trunk HEAD.
-
- * ext/racc: ditto.
-
-
-2006-02-27(Mon) 12:47:10 +0900 Minero Aoki <aamine@loveruby.net>
-
- * parse.y: follow coding style change.
-
-
-2006-02-27(Mon) 11:53:07 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/README: imported from Ruby CVS trunk HEAD.
-
- * lib/gserver.rb: ditto.
-
- * lib/readbytes.rb: ditto.
-
- * lib/parsearg.rb: ditto.
-
- * lib/racc: ditto.
-
- * lib/rinda: ditto.
-
-
-2006-02-27(Mon) 11:27:19 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/thread.rb (Queue#pop): faster code. [yarv-dev:973]
-
- * lib/thread.rb (Queue#pop): avoid to push same thread in to
- @waiting.
-
-
-2006-02-23(Thu) 23:32:53 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/open3.rb: imported from Ruby CVS trunk HEAD (rev 1.12).
-
-
-2006-02-23(Thu) 15:10:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : support rb_frame_self()
-
- * eval_intern.h (th_get_ruby_level_cfp) : return 0 if no cfp
-
- * eval_load.c : comment out scope set
-
- * yarvcore.c : fix to initialize/free process of iseq
-
- * vm.c (th_invoke_proc) : fix to set special cref always
-
- * yarvtest/test_proc.rb : add a test for above
-
-
-2006-02-22(Wed) 23:33:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add rule "runruby"
-
- * eval_thread.c : remove obsolete comment
-
- * eval.c : remove unused functions
-
- * signal.c : ditto
-
- * gc.c : add rb_register_mark_object() and use it
-
- * eval_load.c : ditto
-
- * eval_proc.c : ditto
-
- * ext/etc/etc.c : ditto
-
- * ext/win32ole/win32ole.c : ditto
-
- * ruby.h : ditto
-
- * yarvcore.h : ditto
-
- * thread.c : add rb_thread_run_parallel()
-
- * yarvcore.c : change bootstrap
-
-
-2006-02-22(Wed) 19:27:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * ext/win32ole/.cvsignore : removed
-
- * ext/win32ole/.document : ditto
-
-
-2006-02-22(Wed) 18:17:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : set Binding as YARVCore::VM::Binding
-
-
-2006-02-22(Wed) 12:54:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * ChangeLog : remove needless line
-
-
-2006-02-22(Wed) 12:49:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rubysig.h : remove CHECK_INTS
-
- * eval.c : ditto
-
- * eval_load.c : ditto
-
- * ext/readline/readline.c : ditto
-
- * thread.c : ditto
-
- * win32/win32.c : ditto
-
- * yarv_version.h : 0.4.0
-
- * Changes : ditto
-
-
-2006-02-22(Wed) 11:36:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test.rb : removed
-
-
-2006-02-22(Wed) 11:12:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * README : renewed
-
- * version.c : fixed version message
-
- * yarvext/ : removed
-
-
-2006-02-22(Wed) 10:33:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/.document : imported from Ruby 1.9 HEAD
-
- * .document : ditto
-
- * ext/.document : ditto
-
- * lib/ftools.rb : ditto
-
- * lib/rdoc/ : ditto
-
- * eval_thread.c : remove unused functions
-
- * process.c : ditto
-
- * rb/insns2vm.rb : compare modified date of vm_opts.h and
- vm_opts.h.base
-
- * ruby.h : rename RValue to RValues
-
- * gc.c : ditto
-
- * vm.c : ditto
-
-
-2006-02-22(Wed) 06:32:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * configure.in : remove last commit
-
-
-2006-02-22(Wed) 06:18:53 +0900 Koichi Sasada <ko1@atdot.net>
-
- * configure.in : add default program prefix "-yarv"
-
-
-2006-02-22(Wed) 06:11:36 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : change default rule (same as HEAD)
-
- * configure : removed
-
- * eval.c : remove last commit
-
- * vm.c : fix stack traverse
-
- * yarvcore.c : initialize top of control frame
-
- * version.c : 2.0
-
- * version.h : ditto
-
-
-2006-02-22(Wed) 04:50:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : change to rewind C level control frame
-
- * vm.c : change to initialize cfp#proc and fix comparison of
- cfp and limit_cfp
-
- * yarvcore.c : remove last commit
-
-
-2006-02-22(Wed) 03:25:56 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : initialize each stack of thread
-
-
-2006-02-22(Wed) 00:02:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c : fix synchornize return value ([yarv-dev:957])
- and some synchornization error
-
- * thread_pthread.h : add debug helper function
-
-
-2006-02-21(Tue) 20:54:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : fix place of rb_thread_terminate_all()
-
- * eval_thread.c : remove unused functions
-
- * yarv.h : remove GET_VM()
-
- * eval_jump.h : ditto
-
- * insns.def : ditto
-
- * vm_dump.c :
-
- * intern.h : change rb_thread_signal_raise/exit interface
-
- * signal.c : ditto
-
- * thread.c : ditto
-
- * test/ruby/test_beginendblock.rb : use block with IO.popen
-
- * thread_pthread.h : fix interrupt process
-
- * thread_win32.h : ditto
-
- * yarvcore.c : fix thread free process
-
- * yarvcore.h : remove yarv_vm_t#thread_critical, etc
-
-
-2006-02-21(Tue) 12:42:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_thread.c : remove unused function rb_thread_schedule()
-
- * thread.c : rename yarv_thread_schedule to rb_thread_schedule()
-
- * thread.c, eval.c : fix to terminate all thread and barrier at
- eval.c#ruby_cleanup()
-
- * thread_win32.h : remove native_thread_cleanup()
-
- * thread_pthread.h : ditto
-
- * yarvcore.c : ditto
-
- * yarvtest/test_thread.rb : separete assersions to tests
-
-
-2006-02-21(Tue) 02:13:33 +900 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (f_arglist): should set command_start = Qtrue for
- command body. [ruby-talk:180648]
-
-
-2006-02-20(Mon) 20:41:07 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c : fix to synchronize signal_thread_list access
- and fix typo
-
-
-2006-02-20(Mon) 17:54:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_proc.c : remove unused Binding functions and
- set is_lambda of Proc used define_method
-
- * yarvcore.c : support Proc#dup/clone, Binding#dup/clone
-
- * sample/test.rb : remove unsupport features (Proc as Binding)
-
-
-2006-02-20(Mon) 16:28:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add a dependency to vm.c on eval_intern.h
-
- * eval_intern.h : fix to initialize tag->tag
-
- * yarvtest/test_jump.rb : add tests for above
-
- * eval_jump.h : use local variable
-
-
-2006-02-20(Mon) 15:13:24 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_vm3_thread_create_join.rb : added
-
- * test/yaml/test_yaml.rb : imported from Ruby CVS trunk HEAD
-
-
-2006-02-20(Mon) 14:49:46 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/yaml.rb: imported from Ruby CVS trunk HEAD.
-
- * lib/yaml: ditto.
-
- * ext/syck: ditto.
-
-
-2006-02-20(Mon) 13:58:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support block parameter which is NODE_ATTRASGN
-
- * yarvtest/test_block.rb : add tests for above
-
- * compile.c : fix NODE_DASGN_CURR level check
-
- * compile.c : fix "||=" (at firtst, check "defined? val")
-
- * compile.c : fix NODE_MATCH3 (permute receiver and argument)
-
- * yarvtest/test_bin.rb : add tests for above
-
- * eval.c : add rb_each()
-
- * test/ruby/test_signal.rb : increment a timeout value
-
- * thread.c, yarvcore.h : fix "join" flow
-
- * thread_pthread.h : ditto
-
- * thread_win32.h : ditto
-
- * yarvtest/test_thread.rb : add a test for above
-
- * vm.h, vm.c, vm_dump.c, insns.def : add FRAME_MAGIC_LAMBDA and
- support return from lambda (especially retrun from method defined
- by "define_method")
-
- * yarvtest/test_method.rb : add a test for above
-
- * yarvcore.c : remove unused functions
-
-
-2006-02-20(Mon) 11:22:31 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_eval.rb: now Object#funcall is defined.
-
-
-2006-02-20(Mon) 11:04:32 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/irb/lc/ja/CVS: removed.
-
-
-2006-02-20(Mon) 10:55:59 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/mutex_m.rb: imported from Ruby CVS trunk HEAD.
-
- * lib/observer.rb: ditto.
-
- * lib/wsdl: ditto.
-
- * lib/monitor.rb: ditto (removing Thread.critical=).
-
- * lib/xsd: ditto.
-
- * lib/soap: ditto.
-
- * lib/drb.rb: ditto.
-
- * lib/drb: ditto.
-
-
-2006-02-20(Mon) 10:49:31 +0900 Minero Aoki <aamine@loveruby.net>
-
- * yarvcore.c (Init_yarvcore): fix typo (duo -> dup).
-
-
-2006-02-19(Sun) 01:27:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : "return" from lambda{} break block
-
- * eval.c : Unsupport Proc as Binding
-
- * test/ruby/test_eval.rb : apply above changes
-
- * yarvcore.c : remove unused function yarv_yield_values()
-
-
-2006-02-18(Sat) 03:19:36 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c, insns.def : fix passing value when thread killed
-
- * yarvtest/test_thread.rb : add tests for above
-
-
-2006-02-19(Sun) 01:19:42 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/thread.rb (SizedQueue): didn't work. This patch was
- contributed by yukimizake. [yarv-dev:916]
-
-
-2006-02-18(Sat) 03:19:36 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c, insns.def : fix passing value when thread killed
-
- * yarvtest/test_thread.rb : add tests for above
-
-
-2006-02-18(Sat) 02:40:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, vm.c, vm_macro.def : change BMETHOD algorithm
- ([yarv-dev:914])
-
- * yarvtest/test_class.rb : add a test for above
-
-
-2006-02-17(Fri) 23:59:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, yarv.h : change th_invoke_proc() interface
-
- * eval_proc.c : ditto
-
- * signal.c : ditto
-
- * thread.c : ditto
-
- * yarvcore.c : ditto
-
- * vm_macro.def : ditto and fix NODE_BMETHOD call
-
- * vm.c : change name ("th_set_env()" to "push_frame()") and
- change interface
-
- * insns.def : ditto
-
- * eval.c : remove proc_jump_error()
-
- * benchmark/bm_app_answer.rb : added
-
- * vm_opts.h.base : add optimize option
-
-
-2006-02-17(Fri) 13:37:57 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, ruby.h : add rb_errinfo()
-
- * eval_error.h (error_pos) : fix process order
-
- * bin/erb : imported from ruby 1.9
-
- * bin/irb : ditto
-
- * bin/rdoc : ditto
-
- * bin/ri : ditto
-
- * bin/testrb : ditto
-
- * ext/curses/.cvsignore : ditto
-
- * ext/curses/curses.c : ditto
-
- * ext/curses/depend : ditto
-
- * ext/curses/extconf.rb : ditto
-
- * ext/curses/hello.rb : ditto
-
- * ext/curses/mouse.rb : ditto
-
- * ext/curses/rain.rb : ditto
-
- * ext/curses/view.rb : ditto
-
- * ext/curses/view2.rb : ditto
-
- * ext/fcntl/.cvsignore : ditto
-
- * ext/fcntl/depend : ditto
-
- * ext/fcntl/extconf.rb : ditto
-
- * ext/fcntl/fcntl.c : ditto
-
- * ext/readline/README : ditto
-
- * ext/readline/README.ja : ditto
-
- * ext/readline/depend : ditto
-
- * ext/readline/extconf.rb : ditto
-
- * ext/readline/readline.c : ditto
-
- * ext/win32ole/.document : ditto
-
- * ext/zlib/doc/zlib.rd : ditto
-
- * ext/zlib/extconf.rb : ditto
-
- * ext/zlib/zlib.c : ditto
-
- * lib/cgi/.document : ditto
-
- * lib/cgi/session.rb : ditto
-
- * lib/cgi/session/pstore.rb : ditto
-
- * lib/shell/builtin-command.rb : ditto
-
- * lib/shell/command-processor.rb : ditto
-
- * lib/shell/error.rb : ditto
-
- * lib/shell/filter.rb : ditto
-
- * lib/shell/process-controller.rb : ditto
-
- * lib/shell/system-command.rb : ditto
-
- * lib/shell/version.rb : ditto
-
- * lib/xmlrpc/.document : ditto
-
- * lib/xmlrpc/README.rdoc : ditto
-
- * lib/xmlrpc/README.txt : ditto
-
- * lib/xmlrpc/base64.rb : ditto
-
- * lib/xmlrpc/client.rb : ditto
-
- * lib/xmlrpc/config.rb : ditto
-
- * lib/xmlrpc/create.rb : ditto
-
- * lib/xmlrpc/datetime.rb : ditto
-
- * lib/xmlrpc/httpserver.rb : ditto
-
- * lib/xmlrpc/marshal.rb : ditto
-
- * lib/xmlrpc/parser.rb : ditto
-
- * lib/xmlrpc/server.rb : ditto
-
- * lib/xmlrpc/utils.rb : ditto
-
- * rdoc/README : ditto
-
- * rdoc/code_objects.rb : ditto
-
- * rdoc/diagram.rb : ditto
-
- * rdoc/dot/dot.rb : ditto
-
- * rdoc/generators/chm_generator.rb : ditto
-
- * rdoc/generators/html_generator.rb : ditto
-
- * rdoc/generators/ri_generator.rb : ditto
-
- * rdoc/generators/template/chm/chm.rb : ditto
-
- * rdoc/generators/template/html/hefss.rb : ditto
-
- * rdoc/generators/template/html/html.rb : ditto
-
- * rdoc/generators/template/html/kilmer.rb : ditto
-
- * rdoc/generators/template/html/old_html.rb : ditto
-
- * rdoc/generators/template/html/one_page_html.rb : ditto
-
- * rdoc/generators/template/xml/rdf.rb : ditto
-
- * rdoc/generators/template/xml/xml.rb : ditto
-
- * rdoc/generators/xml_generator.rb : ditto
-
- * rdoc/markup/sample/rdoc2latex.rb : ditto
-
- * rdoc/markup/sample/sample.rb : ditto
-
- * rdoc/markup/simple_markup.rb : ditto
-
- * rdoc/markup/simple_markup/fragments.rb : ditto
-
- * rdoc/markup/simple_markup/inline.rb : ditto
-
- * rdoc/markup/simple_markup/lines.rb : ditto
-
- * rdoc/markup/simple_markup/preprocess.rb : ditto
-
- * rdoc/markup/simple_markup/to_flow.rb : ditto
-
- * rdoc/markup/simple_markup/to_html.rb : ditto
-
- * rdoc/markup/simple_markup/to_latex.rb : ditto
-
- * rdoc/markup/test/AllTests.rb : ditto
-
- * rdoc/markup/test/TestInline.rb : ditto
-
- * rdoc/markup/test/TestParse.rb : ditto
-
- * rdoc/options.rb : ditto
-
- * rdoc/parsers/parse_c.rb : ditto
-
- * rdoc/parsers/parse_f95.rb : ditto
-
- * rdoc/parsers/parse_rb.rb : ditto
-
- * rdoc/parsers/parse_simple.rb : ditto
-
- * rdoc/parsers/parserfactory.rb : ditto
-
- * rdoc/rdoc.rb : ditto
-
- * rdoc/ri/ri_cache.rb : ditto
-
- * rdoc/ri/ri_descriptions.rb : ditto
-
- * rdoc/ri/ri_display.rb : ditto
-
- * rdoc/ri/ri_driver.rb : ditto
-
- * rdoc/ri/ri_formatter.rb : ditto
-
- * rdoc/ri/ri_options.rb : ditto
-
- * rdoc/ri/ri_paths.rb : ditto
-
- * rdoc/ri/ri_reader.rb : ditto
-
- * rdoc/ri/ri_util.rb : ditto
-
- * rdoc/ri/ri_writer.rb : ditto
-
- * rdoc/template.rb : ditto
-
- * rdoc/tokenstream.rb : ditto
-
- * rdoc/usage.rb : ditto
-
- * test/xmlrpc/data/bug_bool.expected : ditto
-
- * test/xmlrpc/data/bug_bool.xml : ditto
-
- * test/xmlrpc/data/bug_cdata.expected : ditto
-
- * test/xmlrpc/data/bug_cdata.xml : ditto
-
- * test/xmlrpc/data/bug_covert.expected : ditto
-
- * test/xmlrpc/data/bug_covert.xml : ditto
-
- * test/xmlrpc/data/datetime_iso8601.xml : ditto
-
- * test/xmlrpc/data/fault.xml : ditto
-
- * test/xmlrpc/data/value.expected : ditto
-
- * test/xmlrpc/data/value.xml : ditto
-
- * test/xmlrpc/data/xml1.expected : ditto
-
- * test/xmlrpc/data/xml1.xml : ditto
-
- * test/xmlrpc/test_datetime.rb : ditto
-
- * test/xmlrpc/test_features.rb : ditto
-
- * test/xmlrpc/test_marshal.rb : ditto
-
- * test/xmlrpc/test_parser.rb : ditto
-
- * test/xmlrpc/test_webrick_server.rb : ditto
-
- * test/xmlrpc/webrick_testing.rb : ditto
-
- * test/zlib/test_zlib.rb : ditto
-
-
-2006-02-17(Fri) 09:41:35 +900 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * thread.c (sleep_timeval): sleep should always sleep for
- specified amount of time. [ruby-talk:180067]
-
-
-2006-02-17(Fri) 02:20:32 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_safe.h, ruby.h : remove ruby_safe_level and add
- rb_safe_level() and rb_set_safe_level_force()
-
- * eval.c : use above functions
-
- * eval_jump.h : ditto
-
- * eval_load.c : ditto
-
- * eval_method.h : ditto
-
- * eval_proc.c : ditto
-
- * eval_thread.c : ditto
-
- * gc.c : ditto
-
- * signal.c : ditto
-
- * variable.c : ditto
-
- * ext/win32ole/win32ole.c : ditto
-
- * vm.c (th_invoke_proc) : save and restore safe level
-
- * yarvtest/test_proc.rb : add tests for above
-
- * thread.c : remove unused functions
-
-
-2006-02-17(Fri) 01:08:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : remove a setspecial second unused operand
-
- * eval_load.c : remove unused variable th
-
- * eval_proc.c, yarvcore.c : remove some functions from eval_proc.c
- and move to yarvcore.c
-
- * insns.def : fix to delete warnings
-
- * sample/test.rb : comment out Proc#clone tests
-
- * version.c : add constant RUBY_VM_DATE
-
- * vm.c : fix some functions
-
-
-2006-02-16(Thu) 22:58:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, vm.c : use th_yield_setup_args at yield and Proc#call
-
-
-2006-02-16(Thu) 19:51:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix analysis of block parameter
-
- * disasm.c : remove rb_bug() (temporarily)
-
- * insns.def, vm.c : fix passing block parameter
-
- * sample/test.rb : add "Proc = YARVCore::VM::Proc"
-
- * test/ruby/test_readpartial.rb : disable on mswin32
-
- * test/socket/test_tcp.rb : ditto
-
- * thread.c : fix syntax error (for non GCC)
-
-
-2006-02-15(Wed) 22:34:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h : move rb_clear_cache_by_id position
-
- * thread.c : fix Thread#kill
-
- * test/ruby/test_readpartial.rb : enable tests except cygwin version
-
- * test/ruby/test_signal.rb : ditto and enable timeout
-
-
-2006-02-15(Wed) 22:13:29 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/runit: forgot to commit.
-
-
-2006-02-15(Wed) 22:12:25 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/weakref.rb: do not use Thread.critical=.
-
- * lib/singleton.rb: ditto.
-
- * lib/timeout.rb: ditto.
-
- * lib/thread.rb: ditto.
-
- * test/inlinetest.rb: forgot to commit.
-
-
-2006-02-15(Wed) 21:34:17 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/test_pp.rb: imported from Ruby CVS trunk HEAD.
-
- * test/test_shellwords.rb: ditto.
-
- * test/test_set.rb: ditto.
-
- * test/test_time.rb: ditto.
-
- * test/test_ipaddr.rb: ditto.
-
- * test/test_prettyprint.rb: ditto.
-
- * test/test_tsort.rb: ditto.
-
- * test/strscan: ditto.
-
- * test/testunit: ditto.
-
-
-2006-02-15(Wed) 20:03:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h : duplicate NODE_METHOD at make an alias
-
- * yarvtest/test_method.rb : add a test for above
-
-
-2006-02-15(Wed) 19:48:59 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/rss: imported from Ruby CVS trunk HEAD.
-
-
-2006-02-15(Wed) 19:47:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c, vm.c : remove methoddef, singletonmethoddef
- instructions and make new insn definemethod
-
- * yarvcore.c : set toplevel visibility to private
-
-
-2006-02-15(Wed) 17:39:16 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_intern.h :
-
- * eval_jump.h, vm.c : localjump_error() and jump_tag_but_local_jump()
- move to th_localjump_error and th_jump_tag_but_local_jump at vm.c
-
- * eval.c : ditto
-
- * eval_load.c : ditto
-
- * insns.def : ditto
-
- * vm.c : ditto
-
- * vm.c (th_make_jump_tag_but_local_jump) : added
-
- * opt_insn_unif.def : fix indnet (revert change)
-
- * opt_operand.def : ditto
-
- * rb/insns2vm.rb : fix error message
-
- * thread.c : raise exception at join if illegal local jump
-
-
-2006-02-15(Wed) 14:21:45 +900 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ChangeLog: add local variables line to support Emacs.
-
- * eval.c (rb_obj_instance_exec): add new method from 1.9.
-
- * eval.c (rb_mod_module_exec): ditto.
-
- * eval.c (yield_under_i): should not pass self as an argument to
- the block for instance_eval. [ruby-core:07364]
-
- * eval.c (rb_obj_instance_eval): should be no singleton classes for
- true, false, and nil. [ruby-dev:28186]
-
-
-2006-02-14(Tue) 19:30:20 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c : fix indent
-
- * eval.c : fix block_given
-
- * gc.c : add STACK_START and use it as a substitute for
- rb_gc_stack_start
-
- * vm.c : fix to raise error if th_yield doesn't have block given
-
- * yarvcore.c : fix to skip iseq mark array at ObjectSpace.each_object
-
-
-2006-02-14(Tue) 18:15:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * configure.in : enable pthread by deafult
-
- * ascii.c : import ruby 1.9 HEAD
-
- * bignum.c : ditto
-
- * compar.c : ditto
-
- * configure : ditto
-
- * defines.h : ditto
-
- * dln.c : ditto
-
- * dln.h : ditto
-
- * enum.c : ditto
-
- * enumerator.c : ditto
-
- * euc_jp.c : ditto
-
- * ext/win32ole/tests/testWIN32OLE.rb : ditto
-
- * ext/win32ole/win32ole.c : ditto
-
- * file.c : ditto
-
- * hash.c : ditto
-
- * io.c : ditto
-
- * lex.c : ditto
-
- * lib/irb/init.rb : ditto
-
- * lib/rexml/document.rb : ditto
-
- * main.c : ditto
-
- * marshal.c : ditto
-
- * math.c : ditto
-
- * missing.h : ditto
-
- * object.c : ditto
-
- * oniguruma.h : ditto
-
- * pack.c : ditto
-
- * process.c : ditto
-
- * random.c : ditto
-
- * range.c : ditto
-
- * rb/ir.rb : ditto
-
- * re.c : ditto
-
- * regcomp.c : ditto
-
- * regenc.c : ditto
-
- * regenc.h : ditto
-
- * regerror.c : ditto
-
- * regexec.c : ditto
-
- * regint.h : ditto
-
- * regparse.c : ditto
-
- * regparse.h : ditto
-
- * ruby.c : ditto
-
- * ruby.h : ditto
-
- * rubyio.h : ditto
-
- * sjis.c : ditto
-
- * sprintf.c : ditto
-
- * st.c : ditto
-
- * st.h : ditto
-
- * struct.c : ditto
-
- * test/ruby/envutil.rb : ditto
-
- * test/ruby/test_struct.rb : ditto
-
- * time.c : ditto
-
- * utf8.c : ditto
-
- * util.c : ditto
-
- * util.h : ditto
-
- * version.h : ditto
-
- * win32/Makefile.sub : ditto
-
- * win32/win32.c : ditto
-
-
-2006-02-14(Tue) 16:40:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, eval_proc.c : fix rb_proc_arity
-
- * eval.c : declare funcall same as send (temporarily)
-
- * lib/thread.rb : added
-
- * test/pathname/test_pathname.rb : imported from ruby 1.9
-
- * test/scanf/data.txt : ditto
-
- * test/scanf/test_scanf.rb : ditto
-
- * test/scanf/test_scanfblocks.rb : ditto
-
- * test/scanf/test_scanfio.rb : ditto
-
- * test/socket/test_socket.rb : ditto
-
- * test/socket/test_tcp.rb : ditto
-
- * test/socket/test_udp.rb : ditto
-
- * test/socket/test_unix.rb : ditto
-
- * test/stringio/test_stringio.rb : ditto
-
- * test/uri/test_common.rb : ditto
-
- * test/uri/test_ftp.rb : ditto
-
- * test/uri/test_generic.rb : ditto
-
- * test/uri/test_http.rb : ditto
-
- * test/uri/test_ldap.rb : ditto
-
- * test/uri/test_mailto.rb : ditto
-
-
-2006-02-14(Tue) 15:59:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c : Change Thread.critical warnning message
-
- * lib/webrick.rb : imported from ruby 1.9
-
- * lib/webrick/accesslog.rb : ditto
-
- * lib/webrick/cgi.rb : ditto
-
- * lib/webrick/compat.rb : ditto
-
- * lib/webrick/config.rb : ditto
-
- * lib/webrick/cookie.rb : ditto
-
- * lib/webrick/htmlutils.rb : ditto
-
- * lib/webrick/httpauth.rb : ditto
-
- * lib/webrick/httpauth/authenticator.rb : ditto
-
- * lib/webrick/httpauth/basicauth.rb : ditto
-
- * lib/webrick/httpauth/digestauth.rb : ditto
-
- * lib/webrick/httpauth/htdigest.rb : ditto
-
- * lib/webrick/httpauth/htgroup.rb : ditto
-
- * lib/webrick/httpauth/htpasswd.rb : ditto
-
- * lib/webrick/httpauth/userdb.rb : ditto
-
- * lib/webrick/httpproxy.rb : ditto
-
- * lib/webrick/httprequest.rb : ditto
-
- * lib/webrick/httpresponse.rb : ditto
-
- * lib/webrick/https.rb : ditto
-
- * lib/webrick/httpserver.rb : ditto
-
- * lib/webrick/httpservlet.rb : ditto
-
- * lib/webrick/httpservlet/abstract.rb : ditto
-
- * lib/webrick/httpservlet/cgi_runner.rb : ditto
-
- * lib/webrick/httpservlet/cgihandler.rb : ditto
-
- * lib/webrick/httpservlet/erbhandler.rb : ditto
-
- * lib/webrick/httpservlet/filehandler.rb : ditto
-
- * lib/webrick/httpservlet/prochandler.rb : ditto
-
- * lib/webrick/httpstatus.rb : ditto
-
- * lib/webrick/httputils.rb : ditto
-
- * lib/webrick/httpversion.rb : ditto
-
- * lib/webrick/log.rb : ditto
-
- * lib/webrick/server.rb : ditto
-
- * lib/webrick/ssl.rb : ditto
-
- * lib/webrick/utils.rb : ditto
-
- * lib/webrick/version.rb : ditto
-
-
-2006-02-14(Tue) 14:55:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : support "defined?($1)", ...
-
- * yarvtest/test_syntax.rb : add a test for above
-
- * rb/makedocs.rb : fix template directory path
-
- * vm.c : fix to handle break from proc
-
-
-2006-02-14(Tue) 12:42:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : fix rb_iterate hook
-
- * yarvtest/test_block.rb : add a tests for above
-
- * vm.c : remove unused comment
-
-
-2006-02-14(Tue) 12:01:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : fix to check passed block at block_given_p
-
- * eval_proc.c : fix to pass block at Method#call
-
- * runruby.rb : fix to apply ruby
-
- * test/runner.rb : GC.stress (comment out)
-
- * vm.c : fix indnet
-
-
-2006-02-14(Tue) 08:04:33 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/tempfile.rb: use Mutex instead of Thread.critical.
-
- * lib/rss/dublincore.rb: |x,| -> |x,_| to avoid YARV bug (tmp).
-
- * lib/rexml: imported from ruby CVS trunk HEAD.
-
- * test/digest: ditto.
-
- * test/fileutils: ditto.
-
- * test/ostruct: ditto.
-
- * test/erb: ditto.
-
- * test/optparse: ditto.
-
- * test/ruby/test_signal.rb: turn off a test to avoid unknown error
- (tmp).
-
-
-2006-02-14(Tue) 07:52:03 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/digest: imported from ruby CVS trunk HEAD.
-
- * test/fileutils: ditto.
-
- * test/ostruct: ditto.
-
- * test/erb: ditto.
-
- * test/optparse: ditto.
-
-
-2006-02-14(Tue) 06:26:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, parse.y : support BEGIN{} (remove local scope)
-
- * test/ruby/beginmainend.rb : fix to apply YARV's specification
-
- * test/ruby/test_beginendblock.rb : enable BEGIN{} test
-
- * signal.c : exit at double segv
-
- * insns.def (preexe) : remove instruction "preexe"
-
-
-2006-02-14(Tue) 05:53:56 +0900 Minero Aoki <aamine@loveruby.net>
-
- * eval.c (ruby_cleanup): th->errinfo contains a NODE while
- break'ing, check it before refering klass.
-
-
-2006-02-14(Tue) 05:45:07 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix stack calc of send
-
- * sample/test.rb : remove SEGV causing code
-
-
-2006-02-14(Tue) 02:24:21 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_module.rb: list order is not a matter.
-
- * test/csv: imported from ruby CVS trunk HEAD.
-
-
-2006-02-14(Tue) 02:06:25 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_beginendblock.rb: unlock tests.
-
- * test/ruby/beginmainend.rb: new file (imported from ruby CVS
- trunk HEAD).
-
- * test/ruby/endblockwarn.rb: new file (imported from ruby CVS
- trunk HEAD).
-
- * test/ruby/test_file.rb: new file (imported from ruby CVS trunk
- HEAD).
-
-
-2006-02-14(Tue) 01:42:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * error.c : fix include file positon
-
- * test/ruby/test_signal.rb : skip test_exit_action on cygwin
-
-
-2006-02-14(Tue) 01:36:57 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_class.rb: new file (imported from rubicon).
-
-
-2006-02-14(Tue) 01:32:23 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_module.rb: ignore PP mixins.
-
-
-2006-02-14(Tue) 01:24:56 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_lambda.rb: removed (->(){...} syntax is
- obsolete).
-
-
-2006-02-14(Tue) 01:20:54 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_module.rb: import many tests from rubicon.
-
-
-2006-02-14(Tue) 01:06:57 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix to avoid stack consistency error
-
- * yarvtest/test_exception.rb : add a test for above
-
-
-2006-02-14(Tue) 00:42:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, vm_macro.def : rename VM_CALL_SUPER to VM_CALL_SUPER_BIT
-
- * insns.def (send) : set a flag of super as fcall
-
- * yarvtest/test_class.rb : add a test for above
-
-
-2006-02-14(Tue) 00:31:24 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_eval.rb: fix typo.
-
- * test/ruby/test_signal.rb: unlock tests.
-
-
-2006-02-13(Mon) 23:53:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, vm_macro.def : fix NODE_ZSUPER dispatch and
- fix error message when super without suitable method ([yarv-dev:846])
-
- * yarvcore.h : add VM_CALL_SUPER definition
-
- * yarvtest/test_method.rb : add a test of Module#private_class_method
-
-
-2006-02-13(Mon) 22:49:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : traverse all iseq to find super method ([yarv-dev:859])
-
- * yarvtest/test_class.rb : add a test for above
-
- * yarvcore.c : add clear iseq->defined_method_id
-
- * signal.c : fix to prohibit double segv handler kicked
-
-
-2006-02-13(Mon) 22:09:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_DECL, NODE_CLASS with NODE_CLON3 prefix
-
- * yarvtest/test_class.rb : add tests for above
-
-
-2006-02-13(Mon) 21:20:57 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix indent
-
- * compile.c : fix to prohibit "redo" from eval expression
-
-
-2006-02-13(Mon) 20:36:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : fix constant search bug ([yarv-dev:788])
-
- * yarvtest/test_class.rb : add a test of [yarv-dev:788]
-
-
-2006-02-13(Mon) 18:09:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/ruby/test_clone.rb : enable tests with Class#clone
-
- * test/ruby/test_marshal.rb : ditto
-
-
-2006-02-13(Mon) 17:42:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * class.c : support Class#clone
-
- * compile.c, insns.def : remove popcref
-
- * yarvcore.h, vm.c, insns.def : remove yarv_thread_t#cref_stack
-
- * eval.c, eval_intern.h, eval_load.c : ditto
-
- * yarvtest/test_class.rb : add tests for singleton class
-
- * gc.c : remove "FRAME *" unused variable
-
- * insnhelper.h : fix COPY_CREF
-
- * rb/mklog.rb : add default message
-
- * vm_macro.def : support NODE_ZSUPER as method type
-
-
-2006-02-13(Mon) 00:11:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c : refoctoring with CFLAGS+=-Wunused
-
- * eval.c : ditto
-
- * eval_intern.h : ditto
-
- * eval_load.c : ditto
-
- * eval_method.h : ditto
-
- * eval_proc.c : ditto
-
- * eval_thread.c : ditto
-
- * insns.def : ditto
-
- * parse.y : ditto
-
- * thread.c : ditto
-
- * vm.c : ditto
-
-
-2006-02-13(Mon) 02:32:34 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_const.rb: show better message.
-
- * test/ruby/test_eval.rb: ditto.
-
- * test/ruby/test_module.rb: new file.
-
-
-2006-02-12(Sun) 22:22:35 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c : revert last commit
-
- * ascii.c : ditto
-
- * bignum.c : ditto
-
- * class.c : ditto
-
- * compar.c : ditto
-
- * defines.h : ditto
-
- * dir.c : ditto
-
- * dln.c : ditto
-
- * dln.h : ditto
-
- * enum.c : ditto
-
- * enumerator.c : ditto
-
- * error.c : ditto
-
- * euc_jp.c : ditto
-
- * file.c : ditto
-
- * gc.c : ditto
-
- * hash.c : ditto
-
- * intern.h : ditto
-
- * io.c : ditto
-
- * lex.c : ditto
-
- * main.c : ditto
-
- * marshal.c : ditto
-
- * math.c : ditto
-
- * missing.h : ditto
-
- * node.h : ditto
-
- * numeric.c : ditto
-
- * object.c : ditto
-
- * oniguruma.h : ditto
-
- * pack.c : ditto
-
- * prec.c : ditto
-
- * process.c : ditto
-
- * random.c : ditto
-
- * range.c : ditto
-
- * rb/mklog.rb : ditto
-
- * re.c : ditto
-
- * regcomp.c : ditto
-
- * regenc.c : ditto
-
- * regenc.h : ditto
-
- * regerror.c : ditto
-
- * regex.h : ditto
-
- * regexec.c : ditto
-
- * regint.h : ditto
-
- * regparse.c : ditto
-
- * regparse.h : ditto
-
- * ruby.c : ditto
-
- * ruby.h : ditto
-
- * rubyio.h : ditto
-
- * rubysig.h : ditto
-
- * signal.c : ditto
-
- * sjis.c : ditto
-
- * sprintf.c : ditto
-
- * st.c : ditto
-
- * st.h : ditto
-
- * string.c : ditto
-
- * struct.c : ditto
-
- * time.c : ditto
-
- * utf8.c : ditto
-
- * util.c : ditto
-
- * util.h : ditto
-
- * variable.c : ditto
-
- * version.c : ditto
-
-
-2006-02-12(Sun) 21:33:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c : fix to ruby's indent
-
- * ascii.c : ditto
-
- * bignum.c : ditto
-
- * blockinlining.c : ditto
-
- * call_cfunc.h : ditto
-
- * class.c : ditto
-
- * compar.c : ditto
-
- * compile.c : ditto
-
- * compile.h : ditto
-
- * debug.c : ditto
-
- * debug.h : ditto
-
- * defines.h : ditto
-
- * dir.c : ditto
-
- * disasm.c : ditto
-
- * dln.c : ditto
-
- * dln.h : ditto
-
- * enum.c : ditto
-
- * enumerator.c : ditto
-
- * error.c : ditto
-
- * euc_jp.c : ditto
-
- * eval.c : ditto
-
- * eval_error.h : ditto
-
- * eval_intern.h : ditto
-
- * eval_jump.h : ditto
-
- * eval_load.c : ditto
-
- * eval_method.h : ditto
-
- * eval_proc.c : ditto
-
- * eval_safe.h : ditto
-
- * eval_thread.c : ditto
-
- * file.c : ditto
-
- * gc.c : ditto
-
- * hash.c : ditto
-
- * insnhelper.h : ditto
-
- * insns.def : ditto
-
- * intern.h : ditto
-
- * io.c : ditto
-
- * lex.c : ditto
-
- * main.c : ditto
-
- * marshal.c : ditto
-
- * math.c : ditto
-
- * missing.h : ditto
-
- * node.h : ditto
-
- * numeric.c : ditto
-
- * object.c : ditto
-
- * oniguruma.h : ditto
-
- * opt_insn_unif.def : ditto
-
- * opt_operand.def : ditto
-
- * pack.c : ditto
-
- * prec.c : ditto
-
- * process.c : ditto
-
- * random.c : ditto
-
- * range.c : ditto
-
- * re.c : ditto
-
- * re.h : ditto
-
- * regcomp.c : ditto
-
- * regenc.c : ditto
-
- * regenc.h : ditto
-
- * regerror.c : ditto
-
- * regex.h : ditto
-
- * regexec.c : ditto
-
- * regint.h : ditto
-
- * regparse.c : ditto
-
- * regparse.h : ditto
-
- * ruby.c : ditto
-
- * ruby.h : ditto
-
- * rubyio.h : ditto
-
- * rubysig.h : ditto
-
- * signal.c : ditto
-
- * sjis.c : ditto
-
- * sprintf.c : ditto
-
- * st.c : ditto
-
- * st.h : ditto
-
- * string.c : ditto
-
- * struct.c : ditto
-
- * test.rb : ditto
-
- * thread.c : ditto
-
- * thread_pthread.h : ditto
-
- * thread_win32.h : ditto
-
- * time.c : ditto
-
- * utf8.c : ditto
-
- * util.c : ditto
-
- * util.h : ditto
-
- * variable.c : ditto
-
- * version.c : ditto
-
- * vm.c : ditto
-
- * vm.h : ditto
-
- * vm_dump.c : ditto
-
- * vm_evalbody.h : ditto
-
- * vm_macro.def : ditto
-
- * yarv.h : ditto
-
- * yarv_version.h : ditto
-
- * yarvcore.c : ditto
-
- * yarvcore.h : ditto
-
-
-2006-02-12(Sun) 15:53:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/abbrev.rb : added
-
- * lib/base64.rb : ditto
-
- * lib/cgi-lib.rb : ditto
-
- * lib/csv.rb : ditto
-
- * lib/date2.rb : ditto
-
- * lib/eregex.rb : ditto
-
- * lib/ipaddr.rb : ditto
-
- * lib/irb.rb : ditto
-
- * lib/irb/cmd/chws.rb : ditto
-
- * lib/irb/cmd/fork.rb : ditto
-
- * lib/irb/cmd/help.rb : ditto
-
- * lib/irb/cmd/load.rb : ditto
-
- * lib/irb/cmd/nop.rb : ditto
-
- * lib/irb/cmd/pushws.rb : ditto
-
- * lib/irb/cmd/subirb.rb : ditto
-
- * lib/irb/completion.rb : ditto
-
- * lib/irb/context.rb : ditto
-
- * lib/irb/ext/change-ws.rb : ditto
-
- * lib/irb/ext/history.rb : ditto
-
- * lib/irb/ext/loader.rb : ditto
-
- * lib/irb/ext/math-mode.rb : ditto
-
- * lib/irb/ext/multi-irb.rb : ditto
-
- * lib/irb/ext/save-history.rb : ditto
-
- * lib/irb/ext/tracer.rb : ditto
-
- * lib/irb/ext/use-loader.rb : ditto
-
- * lib/irb/ext/workspaces.rb : ditto
-
- * lib/irb/extend-command.rb : ditto
-
- * lib/irb/frame.rb : ditto
-
- * lib/irb/help.rb : ditto
-
- * lib/irb/init.rb : ditto
-
- * lib/irb/input-method.rb : ditto
-
- * lib/irb/lc/error.rb : ditto
-
- * lib/irb/lc/help-message : ditto
-
- * lib/irb/lc/ja/CVS/Entries : ditto
-
- * lib/irb/lc/ja/CVS/Repository : ditto
-
- * lib/irb/lc/ja/CVS/Root : ditto
-
- * lib/irb/lc/ja/error.rb : ditto
-
- * lib/irb/lc/ja/help-message : ditto
-
- * lib/irb/locale.rb : ditto
-
- * lib/irb/notifier.rb : ditto
-
- * lib/irb/output-method.rb : ditto
-
- * lib/irb/ruby-lex.rb : ditto
-
- * lib/irb/ruby-token.rb : ditto
-
- * lib/irb/slex.rb : ditto
-
- * lib/irb/version.rb : ditto
-
- * lib/irb/workspace.rb : ditto
-
- * lib/irb/ws-for-case-2.rb : ditto
-
- * lib/irb/xmp.rb : ditto
-
- * lib/jcode.rb : ditto
-
- * lib/logger.rb : ditto
-
- * lib/mailread.rb : ditto
-
- * lib/mathn.rb : ditto
-
- * lib/parsedate.rb : ditto
-
- * lib/pathname.rb : ditto
-
- * lib/ping.rb : ditto
-
- * lib/pstore.rb : ditto
-
- * lib/resolv-replace.rb : ditto
-
- * lib/resolv.rb : ditto
-
- * lib/rss.rb : ditto
-
- * lib/rss/0.9.rb : ditto
-
- * lib/rss/1.0.rb : ditto
-
- * lib/rss/2.0.rb : ditto
-
- * lib/rss/content.rb : ditto
-
- * lib/rss/converter.rb : ditto
-
- * lib/rss/dublincore.rb : ditto
-
- * lib/rss/image.rb : ditto
-
- * lib/rss/maker.rb : ditto
-
- * lib/rss/maker/0.9.rb : ditto
-
- * lib/rss/maker/1.0.rb : ditto
-
- * lib/rss/maker/2.0.rb : ditto
-
- * lib/rss/maker/base.rb : ditto
-
- * lib/rss/maker/content.rb : ditto
-
- * lib/rss/maker/dublincore.rb : ditto
-
- * lib/rss/maker/image.rb : ditto
-
- * lib/rss/maker/syndication.rb : ditto
-
- * lib/rss/maker/taxonomy.rb : ditto
-
- * lib/rss/maker/trackback.rb : ditto
-
- * lib/rss/parser.rb : ditto
-
- * lib/rss/rexmlparser.rb : ditto
-
- * lib/rss/rss.rb : ditto
-
- * lib/rss/syndication.rb : ditto
-
- * lib/rss/taxonomy.rb : ditto
-
- * lib/rss/trackback.rb : ditto
-
- * lib/rss/utils.rb : ditto
-
- * lib/rss/xml-stylesheet.rb : ditto
-
- * lib/rss/xmlparser.rb : ditto
-
- * lib/rss/xmlscanner.rb : ditto
-
- * lib/rubyunit.rb : ditto
-
- * lib/scanf.rb : ditto
-
- * lib/shell.rb : ditto
-
- * lib/singleton.rb : ditto
-
- * lib/tsort.rb : ditto
-
- * lib/weakref.rb : ditto
-
- * eval_jump.c : removed
-
-
-2006-02-12(Sun) 15:39:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * parse.y : fix to remove including env.h
-
- * yarvtest/test_exception.rb : fix syntax (add 'end')
-
-
-2006-02-12(Sun) 15:14:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * env.h : removed
-
- * common.mk : remove env.h dependency
-
- * compile.c, eval_intern.h : remove include env.h
-
- * vm.c : ditto
-
- * ruby.h, gc.c, error.c : remove T_SCOPE, T_VARMAP
-
- * parse.y, eval.c : use rb_parse_in_eval() instead of ruby_in_eval
-
- * yarvcore.c, yarvcore.h : add a prase_in_eval member to yarv_thread_t
-
- * insns.def : add push value to throw instruction
- for stack consistency
-
- * yarvtest/test_exception.rb : add a test for above
-
- * test/ruby/test_gc.rb : fix typo
-
-
-2006-02-12(Sun) 05:05:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, eval_intern.h, eval_load.c, eval_proc.c, node.h,
- insnhelper.h, insns.def, vm.c, yarvcore.c, yarvcore.h :
- change cref data structure and unify ruby_class and ruby_cbase
- and some refoctoring
-
-
-2006-02-11(Sat) 23:41:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (methoddef) : fix method declaration in method
-
- * thread.c : Thread.critical to show warning (no effect)
-
-
-2006-02-11(Sat) 20:20:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix [yarv-dev:831]
-
- * yarvtest/test_class.rb : add a test for above
-
-
-2006-02-11(Sat) 14:29:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/mklog.rb : use svk
-
- * error.c : remove newline
-
- * eval.c (rb_block_call) : added
-
- * eval_thread.c : remove some unused functions, comments
-
- * thread.c : add comments (move from eval_thread.c) and support Mutex
-
- * thread.c (rb_thread_select) : supported
-
- * thread_pthread.h (native_mutex_trylock) : added (macro)
-
- * thread_win32.h (native_mutex_trylock) : added
-
- * yarvcore.c : remove unused code
-
- * array.c : import ruby 1.9
-
- * compar.c : ditto
-
- * dln.c : ditto
-
- * enum.c : ditto
-
- * enumerator.c : ditto
-
- * ext/digest/digest.c : ditto
-
- * ext/digest/digest.h : ditto
-
- * ext/digest/sha2/sha2.c : ditto
-
- * ext/etc/etc.c : ditto
-
- * ext/win32ole/win32ole.c : ditto
-
- * hash.c : ditto
-
- * intern.h : ditto
-
- * io.c : ditto
-
- * main.c : ditto
-
- * missing.h : ditto
-
- * missing/flock.c : ditto
-
- * missing/isinf.c : ditto
-
- * missing/vsnprintf.c : ditto
-
- * lib/cgi.rb : ditto
-
- * lib/complex.rb : ditto
-
- * lib/delegate.rb : ditto
-
- * lib/erb.rb : ditto
-
- * lib/fileutils.rb : ditto
-
- * lib/matrix.rb : ditto
-
- * lib/mkmf.rb : ditto
-
- * lib/optparse.rb : ditto
-
- * lib/ostruct.rb : ditto
-
- * lib/pp.rb : ditto
-
- * lib/timeout.rb : ditto
-
- * lib/tmpdir.rb : ditto
-
- * lib/test/unit/autorunner.rb : ditto
-
- * node.h : ditto
-
- * object.c : ditto
-
- * parse.y : ditto
-
- * ruby.c : ditto
-
- * sample/test.rb : ditto
-
- * sprintf.c : ditto
-
- * st.c : ditto
-
- * test/ruby/test_whileuntil.rb : ditto
-
- * test/runner.rb : ditto
-
- * time.c : ditto
-
- * lib/net/.document : added
-
- * lib/net/ftp.rb : ditto
-
- * lib/net/http.rb : ditto
-
- * lib/net/https.rb : ditto
-
- * lib/net/imap.rb : ditto
-
- * lib/net/pop.rb : ditto
-
- * lib/net/protocol.rb : ditto
-
- * lib/net/smtp.rb : ditto
-
- * lib/net/telnet.rb : ditto
-
- * lib/open-uri.rb : ditto
-
-
-2006-02-10(Fri) 08:07:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def, yarvcore.h : support defined?(private_method) and
- defined?(protected_method) (separate DEFINE_METHOD / DEFINE_FUNC)
-
- * yarvtest/test_syntax.rb : add a test for above
-
- * compile.c (iseq_compile_each) : fix NODE_RETURN bug
- (double ensure invoke)
-
- * yarvtest/test_flow.rb : add a test for above
-
- * eval.c (get_errinfo) : fix to search $!
-
- * yarvtest/test_exception.rb : add tests for above
-
- * eval_safe.h : support $SAFE
-
- * ext/socket/socket.c : import ruby 1.9
-
- * gc.c (gc_mark_children) : fix making T_VALUE
-
- * test/ruby/test_gc.rb : use GC.stress
-
- * signal.c (sighandler) : send interrupt signal if thread blocked
-
- * test/ruby/test_proc.rb : remove assert false
-
- * test/ruby/test_readpartial.rb : change fail message
-
- * test/ruby/test_signal.rb : remove assert false
-
- * thread.c (thread_start_func_2) : set local_lfp/local_svar
- at thread creation
-
- * thread_pthread.h : export native_thread_interrupt
-
- * thread_win32.h : export native_thread_interrupt
-
- * version.h : import ruby 1.9
-
- * vm.c (lfp_svar), yarvcore.h : fix to use Thread local svar
-
- * yarvtest/test_thread.rb : add a test for above
-
- * win32/Makefile.sub : import ruby 1.9
-
- * win32/dir.h : ditto
-
- * win32/setup.mak : ditto
-
- * win32/win32.c : ditto
-
- * yarvtest/yarvtest.rb : fix to remove using ARGV
-
-
-2006-02-10(Fri) 01:04:58 +0900 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (rb_gc_call_finalizer_at_exit): turn on during_gc while
- invoking finalizers.
-
- * gc.c (rb_gc_finalize_deferred): ditto.
-
-
-2006-02-08(Wed) 23:17:44 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_proc.rb: method names were wrongly duplicated.
-
-
-2006-02-08(Wed) 21:30:01 +0900 Minero Aoki <aamine@loveruby.net>
-
- * ext/nkf: added (imported from ruby CVS trunk HEAD).
-
- * ext/nkf/depend: new file (rev 1.5).
-
- * ext/nkf/extconf.rb: new file (rev 1.2).
-
- * ext/nkf/nkf.c: new file (rev 1.12).
-
- * ext/nkf/test.rb: new file (rev 1.7).
-
- * ext/nkf/nkf-utf8/nkf.c: new file (rev 1.17).
-
- * ext/nkf/nkf-utf8/config.h: new file (rev 1.4).
-
- * ext/nkf/nkf-utf8/utf8tbl.c: new file (rev 1.6).
-
- * ext/nkf/lib/kconv.rb: new file (rev 1.13).
-
- * test/nkf: added (imported from ruby CVS trunk HEAD).
-
- * test/nkf/test_kconv.rb: new file (rev 1.1).
-
- * test/nkf/test_nkf.rb: new file (rev 1.1).
-
-
-2006-02-08(Wed) 21:07:36 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/find.rb: new file (imported from ruby CVS trunk HEAD,
- rev 1.15).
-
-
-2006-02-07(Tue) 17:58:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : support BEGIN{} and add preexe instruction
-
- * insns.def : fix getspecial/setspecial instructions
- to catch up svar change
-
- * test/ruby/test_system.rb : remove stopper
-
- * thread.c (rb_thread_fd_writable) : add a debug output
-
- * thread.c (rb_thread_wait_fd) : add a debug output
-
- * vm.c (lfp_svar) : refactoring and fix some problems
-
- * vm_dump.c (yarv_bug) : add branch
-
- * yarv.h : remove unused declarations
-
- * yarvcore.c (vm_free) : VM object should not free by GC
-
-
-2006-02-07(Tue) 14:42:25 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, eval_load.c : remove rb_thread_start_1()
-
- * eval.c : fix some prototypes and indents
-
- * eval_thread.c, thread.c : move some functions
- from eval_thread.c to thread.c
-
- * signal.c (sighandler) : add line braek in error message
-
- * yarvcore.c, yarvcore.h, thread.c : support ThreadGroup
-
- * ruby.h, gc.c, vm.c : make new basic type RValue and T_VALUE.
- RValue includes three values in itself. RValue is used as
- svar
-
-
-2006-02-06(Mon) 23:51:41 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_hash.rb: import many tests from rubicon.
-
-
-2006-02-04(Sat) 18:36:41 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_array.rb: import many tests from rubicon.
-
-
-2006-02-04(Sat) 17:47:44 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_signal.rb (test_exit_action): lib/timeout.rb is
- not implemented yet.
-
-
-2006-02-04(Sat) 17:42:31 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_readpartial.rb: lib/timeout.rb is not implemented
- yet.
-
-
-2006-02-04(Sat) 16:22:38 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_pipe.rb: remove useless require.
-
- * test/ruby/test_signal.rb: turn off the test case which causes
- segmentation fault (tmp).
-
-
-2006-02-04(Sat) 08:19:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add dependency to yarvcore.h on signal.o
-
- * compile.c (iseq_compile_each) : fix [yarv-dev:795] problem
- (prohibit "break", "next" jump from eval)
-
- * eval.c : fix indent
-
- * eval_thread.c, thread.c : remove some functions and move to thread.c
-
- * insns.def, vm.c : fix [yarv-dev:799] and [yarv-dev:800]
-
- * yarvtest/test_class.rb : add a test for above
-
- * test/ruby/test_gc.rb : remove GC.debug_flag control
-
- * test/ruby/test_readpartial.rb : disable
-
- * test/ruby/test_signal.rb : disable
-
- * thread.c : fix thread_debug() and many bugs
-
- * thread.c (yarv_thread_s_new) : move living_threads setting
-
- * thread.c (yarv_thread_join) : fix
-
- * thread_pthread.h : add type native_thread_data_t (dummy)
- and support interrupt blocking thread
-
- * thread_pthread.h (native_thread_apply_priority) : added
-
- * thread_win32.h : add type native_thread_data_t (dummy)
- and support interrupt blocking thread
-
- * yarvcore.h : use win32 thread system on cygwin and fix
- some struct members
-
- * yarvtest/test_thread.rb : added
-
-
-2006-02-03(Fri) 00:08:09 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_string.rb: import many tests from rubicon.
-
-
-2006-02-02(Thu) 23:20:13 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/envutil.rb: new file (imported from ruby trunk HEAD).
-
- * test/ruby/marshaltestlib.rb: ditto.
-
- * test/ruby/test_array.rb: ditto.
-
- * test/ruby/test_beginendblock.rb: ditto.
-
- * test/ruby/test_clone.rb: ditto.
-
- * test/ruby/test_dir.rb: ditto.
-
- * test/ruby/test_env.rb: ditto.
-
- * test/ruby/test_file.rb: ditto.
-
- * test/ruby/test_float.rb: ditto.
-
- * test/ruby/test_fnmatch.rb: ditto.
-
- * test/ruby/test_hash.rb: ditto.
-
- * test/ruby/test_io.rb: ditto.
-
- * test/ruby/test_marshal.rb: ditto.
-
- * test/ruby/test_math.rb: ditto.
-
- * test/ruby/test_pack.rb: ditto.
-
- * test/ruby/test_path.rb: ditto.
-
- * test/ruby/test_pipe.rb: ditto.
-
- * test/ruby/test_rand.rb: ditto.
-
- * test/ruby/test_range.rb: ditto.
-
- * test/ruby/test_readpartial.rb: ditto.
-
- * test/ruby/test_regexp.rb: ditto.
-
- * test/ruby/test_settracefunc.rb: ditto.
-
- * test/ruby/test_signal.rb: ditto.
-
- * test/ruby/test_sprintf.rb: ditto.
-
- * test/ruby/test_string.rb: ditto.
-
- * test/ruby/test_stringchar.rb: ditto.
-
- * test/ruby/test_struct.rb: ditto.
-
- * test/ruby/test_symbol.rb: ditto.
-
- * test/ruby/test_system.rb: ditto.
-
- * test/ruby/test_time.rb: ditto.
-
- * test/ruby/ut_eof.rb: ditto.
-
-
-2006-02-02(Thu) 22:53:44 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_proc.rb: test [yarv-dev:777].
-
-
-2006-02-01(Wed) 03:51:39 +0900 Koichi Sasada <ko1@atdot.net>
-
- * gc.c : add GC.debug_flag= method
-
- * insns.def : support method definition in method
-
- * yarvtest/test_method.rb : add tests for above
-
-
-2006-01-29(Sun) 11:40:26 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_proc.c (proc_alloc) : fix [yarv-dev:777]
-
- * yarvtest/test_proc.rb : add a test for above
-
- * insns.def : fix [yarv-dev:782] and add YARV_CHECK_INTS()
-
- * yarvtest/test_class.rb : add a test for above
-
- * thread_win32.h : fix [yarv-dev-en:23]
-
- * vm.c (th_call0) : add YARV_CHECK_INTS()
-
-
-2006-01-09(Mon) 11:56:34 +0900 Minero Aoki <aamine@loveruby.net>
-
- * yarvcore.h: add prototype (remove warning).
-
- * vm.c (th_invoke_proc): make save variables volatile.
-
- * eval.c (eval): initialize local variables (remove warnings).
-
- * eval_thread.c (rb_exec_recursive): ditto.
-
- * yarvcore.c (thread_mark): ditto.
-
- * vm.c (th_invoke_proc): ditto.
-
- * eval.c: remove useless prototypes.
-
-
-2006-01-09(Mon) 10:25:12 +0900 Minero Aoki <aamine@loveruby.net>
-
- * eval_thread.c: rb_thread_join is required to build ruby on
- Linux.
-
- * compile.c: unify coding style.
-
- * yarvcore.c: ditto.
-
-
-2006-01-06(Fri) 09:21:34 +0900 Minero Aoki <aamine@loveruby.net>
-
- * vm.c: coding style change only.
-
-
-2006-01-04(Wed) 14:12:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (ruby_init), eval_intern.h : use POP_TAG_INIT() at bootstrap
-
- * eval_thread.c : remove unused functions and comments
-
- * intern.h : expose rb_make_exception()
-
- * signal.c : support signal
-
- * thread.c (yarv_thread_execute_interrupts) : added
-
- * thread_pthread.h (thread_timer) : set interrupt_flag of
- current runnning threads
-
- * vm.c (th_invoke_proc) : jump with JUMP_TAG() if some exception
- occurres
-
- * yarv.h : add yarv_set_current_running_thread_raw() for bootstrap
-
- * yarvcore.c : add yarv_segv() and segv() method for test
-
- * yarvcore.c (Init_yarvcore) : set yarv_thread_t#running_thread
-
- * yarvcore.h : fix yarv_thread_t members
-
-
-2006-01-03(Tue) 22:25:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * disasm.c (insn_operand_intern) : fix to add child iseq
-
- * eval.c, gc.c : remove obsolete static variables (ruby_scope,
- ruby_dyna_vars, ruby_frame)
-
- * eval.c (rb_mod_s_constants) : use ruby_cref()
-
- * eval.c (eval) : use th_restore_klass()
-
- * eval_proc.c (rb_f_binding) : use th_store_klass()
-
- * insns.def (concatarray) : fix insn ([expr, *nil] => [expr])
-
- * vm.c (th_set_env), insnhelper.h : remove macro
-
- * vm.c (eval_get_cvar_base) : use get_cref
-
- * vm.c (th_make_proc) : use th_store_klass()
-
- * vm_macro.def (macro_eval_invoke_func) : fix option args size
-
- * vm_macro.def (macro_eval_invoke_func) : raise stack overflow error
-
- * yarvcore.h : add yarv_stored_klass_t type
-
- * yarvcore.c : fix mark functions around yarv_stored_klass_t
-
-
-2006-01-01(Sun) 05:14:26 +0900 Minero Aoki <aamine@loveruby.net>
-
- * lib/benchmark.rb: new file (imported from original ruby, rev
- 1.10).
-
-
-2006-01-01(Sun) 03:51:10 +0900 Minero Aoki <aamine@loveruby.net>
-
- * yarvcore.c: add prototype.
-
- * re.c: remove warning: long -> unsigned long.
-
- * debug.c: adjust coding style.
-
- * yarv.h: ditto.
-
-
-2006-01-01(Sun) 03:43:33 +0900 Minero Aoki <aamine@loveruby.net>
-
- * variable.c: add prototype.
-
- * eval.c: ditto.
-
- * eval_load.c: ditto.
-
-
-2006-01-01(Sun) 02:41:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add address analyse to vtune rule
-
- * rb/vtlh.rb : added for above
-
- * rb/insns2vm.rb, template/vm.inc.tmpl : insert #line directive
- to reference above
-
- * vm_macro.def (macro_eval_invoke_cfunc) : fix indent
-
- * yarvtest/test_method.rb : fix indent, spacing
- and add a test for alias
-
-
-2005-12-31(Sat) 12:42:05 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add Intel VTune rule (make vtune)
-
- * eval.c, yarvcore.h : fix to remove yarv_thread_t#local_*
-
- * parse.y (top_local_init_gen) : fix a problem ([yarv-dev:765])
-
- * yarvtest/test_eval.rb : add a test for above
-
- * vm.c (thread_eval) :remove unused function
-
- * yarvcore.c (Init_yarvcore) : remove YARVCore::Thread::eval method
-
- * yarvcore.c (thread_eval) : remove unused function
-
-
-2005-12-31(Sat) 06:05:00 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (eval_search_super_klass) : pass block to method missing
-
- * vm_macro.def (macro_eval_invoke_method) : ditto
-
- * yarvtest/test_method.rb : add a test for above
-
-
-2005-12-31(Sat) 03:11:14 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c (eval), eval_proc.c (rb_f_binding) : save klass, etc to
- binding and use it at eval
-
- * eval_intern.h : ditto
-
- * yarvtest/test_eval.rb : add tests for above
-
- * yarvcore.c (th_get_special_cref) : added
-
- * yarvcore.h : add a prototype of above
-
- * vm.c (th_get_cref) : refactoring
-
- * vm.c (eval_get_ev_const) : fix SEGV at A::B (A is not class/module)
- ([yarv-dev:758])
-
- * yarvtest/test_bin.rb : add a test for above
-
- * rb/mklog.rb : use external diff command and show function name
-
-
-2005-12-30(Fri) 19:07:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, yarvcore.h, eval.c, eval_proc.c : support
- Ruby's Binding
-
- * yarvcore.c : support TOPLEVEL_BINDING
-
- * yarvtest/test_eval.rb : add tests for above
-
-
-2005-12-30(Fri) 13:12:28 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_eval.rb: more tests for
- module_eval/instance_eval.
-
-
-2005-12-30(Fri) 05:06:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add dependency (yarvcore.h) for gc.c
-
- * eval.c, eval_intern.h, eval_load.c, eval_method.h,
- insns.def, insnhelper.h, vm.c, yarvcore.c, yarvcore.h :
- re-write class reference
-
- * yarvtest/test_eval.rb : added
-
- * yarvtest/test_proc.rb :
-
-
-2005-12-29(Thu) 12:27:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.h :
- remvoe needless yarv_iseq_t#rewind_frame_size
-
-
-2005-12-29(Thu) 11:17:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add dependency to test-all rule
-
- * eval.c (rb_sourceline), vm.c (th_get_sourceline) :
- fix to skip process if iseq is ifunc
-
- * test/ruby/test_lambda.rb : assert(fail, ...) instead of assert_fail
-
- * test/ruby/test_proc.rb : ditto
-
- * vm_dump.c : fix stack dump (iseq name)
-
- * vm_macro.def : store proc (block proc) to cfp#proc for GC mark
-
- * yarvcore.c : mark above on thread_mark
-
- * eval.c (exec_under) : replace block#self ([yarv-dev:751])
-
-
-2005-12-29(Thu) 01:56:46 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : fix setting of Proc cref ([yarv-dev:741])
-
- * yarvcore.c : fix indent
-
-
-2005-12-29(Thu) 00:17:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * disasm.c : show (block) local variable simple (not as symbol)
-
- * gc.c : fix syntax error
-
-
-2005-12-28(Wed) 23:35:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * class.c (method_entry) : fixed for undefed method ([yarv-dev:743])
-
- * compile.c : fix errinfo dvar id (#$!)
- and fix NODE_ERRINFO compilation
-
- * eval_proc.c, yarvcore.c : support YARVCore::VM::Proc.new
-
- * insns.def : remove useless TODO comments
-
- * insns.def : fix to use strict array conversion on
- checkarrayinclude
-
- * insns.def : fix defined?(yield) ([yarv-dev:744])
-
- * yarvcore.h : change yarv_iseq_t layout
-
-
-2005-12-28(Wed) 16:49:55 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_eval.rb: add TODO comment.
-
- * test/ruby/test_iterator.rb: rename YARVCore::VM::Proc -> Proc
- (tmp).
-
- * test/ruby/test_lambda.rb: use assert_fail.
-
- * test/ruby/test_proc.rb: ditto.
-
-
-2005-12-28(Wed) 16:28:35 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_clone.rb: removed (tmp).
-
- * test/ruby/test_eval.rb: define missing method Object#funcall
- (tmp).
-
- * test/ruby/test_lambda.rb: turn off tests for "->".
-
- * test/ruby/test_proc.rb: turn off tests for |&b|.
-
- * test/ruby/test_proc.rb: turn off tests for $SAFE setter.
-
-
-2005-12-28(Wed) 15:31:46 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix calculation of stack_max
-
- * eval.c (rb_iter) : fix block/retry handling
-
- * yarvtest/test_flow.rb : add tests for above
-
- * insns.def : fix block passing on super (super(&nil))
-
- * vm_macro.def, insns.def : fix convert method of object to array
-
- * yarvtest/test_method.rb : fix a test for above
-
- * vm.c : fix backtrace generate algorithm
-
-
-2005-12-28(Wed) 10:36:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, compile.h : refactoring (remove self passing, etc)
-
- * disasm.c : support showing ID of method/dynamic local variables
-
- * rb/allload.rb : add verbose version (it's enable by $DEBUG)
-
- * template/insns.inc.tmpl, template/insns_info.inc.tmpl,
- template/minsns.inc.tmpl, template/opt_sc.inc.tmpl,
- template/optinsn.inc.tmpl, template/optunifs.inc.tmpl,
- template/vmtc.inc.tmpl : fix a comment
-
- * variable.c (mod_av_set) : fix to clear inline cache ([yarv-dev:720])
-
- * eval_method.h : fix to clear inline method cache
-
- * vm.c, rb/insns2vm.rb, template/insns_info.inc.tmpl, compile.c,
- insns.def, vm_evalbody.h, vm_macro.def :
- fix operands types (ulong -> num_t, ...)
-
- * vm_macro.def : fix to check SPECIAL_CONST_P() at splat array
- ([yarv-dev:722])
-
- * yarvcore.c : fix to throw syntax error
-
- * yarvcore.h, eval.c, eval_error.h, eval_jump.h :
- add yarv_vm_t#exit_code to fix problem at cleanup ([yarv-dev:723])
-
- * insns.def : fix to invoke zsuper in method defined by define_method
- ([yarv-dev:704])
-
- * yarvtest/test_class.rb : add tests for above
-
- * yarvtest/test_method.rb : fix comments
-
-
-2005-12-27(Tue) 01:52:07 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c, intern.h, insns.def : expose rb_ary_replace and use it
- in insns.def
-
- * eval.c : fix to use SCOPE_* to NOEX_*
-
- * eval_intern.h : remove SCOPE_*
- and fix SCOPE_TEST() and SCOPE_SET(f)
-
- * eval_load.c : save and store klass and visibility
- at require and load
-
- * eval_method.h : fix undefed method node ([yarv-dev-en:8])
-
- * eval_proc.c : fix define_method ([yarv-dev:704])
-
- * insnhelper.h, vm.h : remove GET_VM_STATE_VERSION(),
- INC_VM_STATE_VERSION() and move these to vm.h
-
- * insns.def : supportintg visibility
-
- * node.h : remove NOEX_RECV
-
- * variable.c, vm.c : add rb_vm_change_state() and use it in
- remove_const
-
- * vm.c, insns.def, yarvcore.h, yarvcore.c : add eval_push_cref(),
- eval_pop_cref() and th_cref_init to manage current visibility
-
- * yarv.h : add a prototype of rb_vm_change_state()
-
- * yarvcore.h, insns.def : add defined_method_id and support
- super in define_method scope
-
- * yarvtest/test_class.rb : add tests for above
-
-
-2005-12-26(Mon) 20:44:38 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_basicinstructions.rb: new file.
-
-
-2005-12-26(Mon) 08:40:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c (eval_get_ev_const) : fix to skip nil
-
-
-2005-12-26(Mon) 08:27:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.h : fix GET_CVAR_EV_KLASS [yarv-dev:703]
-
-
-2005-12-26(Mon) 07:51:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : add emptstack insn for all NODE_RETURN
- and optimize it if it's not needed
-
- * yarvtest/test_flow.rb : add a test for above
-
-
-2005-12-26(Mon) 07:08:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, gc.c : add "gc_debug_flag" to debug gc
-
- * insns.def : add emptstack
-
- * compile.c, rb/insns2vm.rb, template/insns_info.inc.tmpl :
- change interface of insn_stack_increase
-
- * compile.c : fix return from ensure in method [yarv-dev:702]
-
- * yarvtest/test_flow.rb : add tests for above
-
-
-2005-12-26(Mon) 02:15:02 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/ruby/test_alias.rb: do not use unimplemented defined?.
-
-
-2005-12-26(Mon) 02:00:11 +0900 Minero Aoki <aamine@loveruby.net>
-
- * test/runner.rb: new file.
-
- * test/ruby/test_alias.rb: new file.
-
- * test/ruby/test_clone.rb: new file.
-
- * test/ruby/test_eval.rb: new file.
-
- * test/ruby/test_iterator.rb: new file.
-
- * test/ruby/test_lambda.rb: new file.
-
- * test/ruby/test_proc.rb: new file.
-
- * test/ruby/test_super.rb: new file.
-
- * test/ruby/test_assignment.rb: new file.
-
- * test/ruby/test_bignum.rb: new file.
-
- * test/ruby/test_call.rb: new file.
-
- * test/ruby/test_case.rb: new file.
-
- * test/ruby/test_condition.rb: new file.
-
- * test/ruby/test_const.rb: new file.
-
- * test/ruby/test_defined.rb: new file.
-
- * test/ruby/test_exception.rb: new file.
-
- * test/ruby/test_gc.rb: new file.
-
- * test/ruby/test_ifunless.rb: new file.
-
- * test/ruby/test_method.rb: new file.
-
- * test/ruby/test_trace.rb: new file.
-
- * test/ruby/test_variable.rb: new file.
-
- * test/ruby/test_whileuntil.rb: new file.
-
-
-2005-12-25(Sun) 07:40:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, compile.c : fix block inlining
-
- * rb/insns2vm.rb : fix to support tracing stack depth
- with operands unification
-
- * vm_dump.c : fix to print Qundef on stack dump
-
-
-2005-12-25(Sun) 01:45:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c, rb/insns2vm.rb, template/insns_info.inc.tmpl :
- trace stack depth at compile time
- and use it as cont_sp for exception handling
-
- * yarvtest/test_exception.rb : add tests for above
-
- * yarvtest/test_flow.rb : ditto
-
- * Merry Xmas :)
-
-
-2005-12-24(Sat) 19:34:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, compile.h : fix ADD_CATCH_ENTRY and add LABEL#sp
-
- * eval_jump.h : fix catch to remove illegal error
-
-
-2005-12-24(Sat) 09:05:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_method.h : change data structure for RClass#m_tbl
-
- * class.c, eval.c, eval_proc.c : fix for above changes
-
- * node.h, gc.c : change NODE_FBODY, NODE_METHOD members
- for above changes
-
- * insns.def : support private/protected visibility
-
- * vm_macro.def : ditto
-
- * vm.c : ditto
-
- * thread.c : fix typo
-
- * thread_pthread.h : fix typo
-
- * thread_win32.h : fix typo
-
- * eval.c, yarvcore.h : add yarv_thread_t#method_missing_reason
- to pass method_missing reason and use it to build error message
-
- * compile.c : use ADD_CALL instead of ADD_SEND for
- NODE_X(D)STR, NODE_CONST (func)
-
-
-2005-12-22(Thu) 02:45:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarv_version.h, Changes : 0.3.3
-
-
-2005-12-20(Tue) 04:04:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix self::Const access
-
- * yarvtest/test_bin.rb : add a test for above
-
-
-2005-12-20(Tue) 01:52:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix to expand VALUES value
-
- * yarvtest/test_massign.rb : add a test for above
-
-
-2005-12-20(Tue) 01:32:35 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, insnhelper.h : fix cvar in singleton method/class
-
- * yarvtest/test_bin.rb : add tests for above
-
-
-2005-12-20(Tue) 01:03:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.h : support all defined?() syntax
-
- * compile.c : fix NODE_COLON2
-
- * yarvtest/test_bin.rb : add or fix tests for above
-
- * win32/* : update all
-
-
-2005-12-17(Sat) 10:46:08 +0900 Minero Aoki <aamine@loveruby.net>
-
- * vm_macro.def: fix printf type mismatch for LP64 system (again).
-
- * parse.y: introduce descriptive macro for special values of
- lvtbl->dvars.
-
-
-2005-12-17(Sat) 09:39:27 +0900 Minero Aoki <aamine@loveruby.net>
-
- * vm_macro.def (macro_eval_invoke_method): fix printf type mismatch
- for LP64 system.
-
-
-2005-12-14(Wed) 03:49:40 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : change rescue/ensure iseq name
-
- * eval.c, intern.h : fix a prototype
-
- * insns.def, yarvcore.h : add trace_function
-
- * vm.c : fix deadly bug (illegal pointer cast)
-
- * vm_dump.c : remove unused local variables
-
- * vm_macro.def : add parameter size check
-
- * yarvtest/test_bin.rb : comment out 2 assertions
-
-
-2005-12-13(Tue) 03:55:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_proc.c : fix indent
-
- * insns.def : fix getspecial instruction to return nil
- if no entry
-
- * yarvtest/test_syntax.rb : add a test for above
-
- * lib/un.rb : added
-
- * template/*.tmpl : fix typo
-
-
-2005-12-13(Mon) 01:38:17 +0900 Minero Aoki <aamine@loveruby.net>
-
- * yarv.h: add prototypes.
-
- * intern.h: ditto.
-
- * eval.c: ditto.
-
- * debug.c: ditto.
-
- * thread_pthread.h: fix printf type mismatch for LP64 system
- (Linux/AMD64).
-
- * variable.c: ditto.
-
- * object.c: ditto.
-
- * gc.c: ditto.
-
- * process.c: ditto.
-
- * error.c: ditto.
-
- * vm.c: ditto.
-
- * vm.h: ditto.
-
- * vm_dump.c: ditto.
-
- * disasm.c: ditto.
-
- * marshal.c: ditto.
-
- * eval_thread.c: ditto.
-
-
-2005-12-11(Sun) 22:00:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : call "inherited" method when a class is inherited
-
- * yarvcore.h : fix yarv_iseq_t field layout
-
- * common.mk : add dependence on yarvcore.h to eval*.o files
-
- * compile.c : fix NODE_POSTEXE logic
-
- * insnhelper.h : use GC_GUARDED_PTR_REF instead of magic number
-
- * eval_proc.c : fix indent
-
- * configure : re-autoconf
-
-
-2005-12-10(Sat) 03:57:20 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : fix blockinlining.o build rule
-
- * insns.def : remove logic for zsuper
-
- * template/optinsn.inc.tmpl :
-
- * vm.c : remove thread_yield_light_prepare, thread_yield_light_invoke
-
- * compile.c : support NODE_ZSUPER with optargs, restarg
-
- * yarvtest/test_class.rb : add tests for above
-
-
-2005-12-09(Fri) 01:13:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c, numeric.c, range.c : add prototype of
- block inlining function
-
- * blockinlining.c, vm_opts.h.base : add block inlining flag
-
- * common.mk, debug.h, debug.c : add debug_breakpoint() for gdb
-
- * compile.c : fix to use size_t on compile_data_alloc(),
- fix illegal cast, fix to set arg_simple at compiling block,
-
- * compile.c, vm.c : fix NODE_NEXT, NODE_BREAK logic
-
- * yarvtest/test_flow.rb : add a test for above
-
- * yarvcore.c, yarvcore.h, compile.c, eval.c : remove
- yarv_iseq_t#root_iseq and add yarv_iseq_t#local_iseq and fix
- to use this member field
-
- * eval_method.h : fix indent
-
- * gc.c : fix indent
-
- * insns.def, compile.c : remove "zsuper" instruction (use "super"
- instead). This is because NODE_ZSUPER represent with only "super"
- instruction
-
- * yarvcore.c : add proc_arity
-
-
-2005-12-05(Mon) 03:58:30 +0900 Koichi Sasada <ko1@atdot.net>
-
- * array.c, blockinlining.c : support block inlining for Array#each
-
- * disasm.c : fix catch table format
-
- * insns.def : fix stack consistency error message
-
- * vm.c : fix to skip pushing value at "next"
-
- * yarvcore.h : move definision of
- "struct iseq_compile_data_ensure_node_stack" to compile.c
-
- * compile.c : fix ensure catch table creation
-
- * yarvtest/test_flow.rb : add tests for above
-
-
-2005-12-03(Sat) 22:27:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, compile.c, yarvcore.c, yarvcore.h,
- numeric.c, range.c : collect block inlining logic to blockinlining.c
-
-
-2005-12-03(Sat) 20:24:07 +0900 Koichi Sasada <ko1@atdot.net>
-
- * blockinlining.c, common.mk : add blockinlining.c
-
- * yarvcore.c, yarvcore.h, blockinlining.c, compile.c, compile.h,
- gc.c, node.h, numeric.c, range.c :
- support block inlining for Integer#times, Range#each
-
- * compile.c : fix to set block redo/next point at last,
- and fix NODE_OP_ASGN1
-
- * compile.c, vm.c : add specialized instruction "opt_le"
-
- * disasm.c : fix to show block, and to show catch type as string
- and change node_name logic
-
- * eval_thread.c : fix function type declaration
-
- * insns.def : add instruction "putundef", "opt_checkenv"
- to support block inlining and add stack check routine
-
- * lib/cgi.rb : add global variable $CGI_DONTINPUT
-
- * opt_operand.def : add some operand unification rules
-
- * rb/insns2vm.rb : fix operand unification logic for BLOCKISEQ
-
- * vm.c : fix exception handling routine (collect stack operations)
-
- * vm_macro.def : fix macro_eval_invoke_bmethod
-
- * yarvsubst.c : removed
-
- * yarvtest/test_syn.rb : rename to yarvtest/test_syntax.rb
-
- * yarvtest/yarvtest.rb : remove tempfile explicitly
-
-
-2005-11-30(Wed) 01:13:57 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add vm_opts.h rule
-
- * vm.c, insns.def : fix proc creation under class and block
- environment
-
-
-2005-11-29(Tue) 16:39:07 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, eval_proc.c, vm.c, vm_macro.def :
- support define_method and invoke NODE_BMETHOD method
-
-
-2005-11-29(Tue) 13:18:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : add iseq_add_mark_object, iseq_add_mark_object_compile_time
- and use it to mark objects on iseq
-
- * compile.h, compile.c : remove cast on NEW_CHILD_ISEQVAL, NEW_ISEQVAL
- and interface
-
- * compile.c, disasm.c, insns.def, vm_macro.def, rb/insns2vm.rb :
- add BLOCKISEQ parameter type
-
- * gc.c : fix garbage_collect to return true if only allocate memory
-
- * vm.c : fix insertion order of proc/env
-
- * vm_evalbody.h : add typedef yarv_iseq_t *BLOCKISEQ
-
- * yarvcore.c, yarvcore.c : add idTimes
-
- * yarvcore.c : fix proc_mark, env_mark around iseq mark
-
-
-2005-11-28(Mon) 09:02:57 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def, vm_evalbody.h : support super
- with splat argument and block (and zsuper with block)
-
- * yarvtest/test_class.rb : add tests for above
-
- * compile.c, yarvcore.h, yarvcore.c, insns.def, time.c, string.c :
- add opt_succ insn
-
- * eval_method.h : fix indent
-
- * eval_thread.c : apply cast to vanish a warning
-
- * lib/tempfile.rb, lib/tmpdir.rb : added
-
- * vm.c : eval_method_missing added
-
- * vm_macro.def : refactoring
-
-
-2005-11-21(Mon) 21:21:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, compile.h, yarvcore.c : remove "iseqobj"
- variables and rename to "iseq"
-
-
-2005-11-21(Mon) 07:31:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix block parameter error
-
- * ext/* : added
-
- * lib/optparse* : added
-
- * benchmark/bm_so_sieve.rb : fix parameter
-
-
-
-2005-11-21(Mon) 03:47:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : optimize condition in literal
-
- * thread_win32.h : fix win32 thread function prototype
-
-
-2005-11-20(Sun) 17:58:24 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix NODE_AND/OR bug
-
- * eval.c : support rb_frame_this_func()
-
-
-2005-11-20(Sun) 12:32:31 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.c, yarvcore.h : support NODE_OPT_N
-
- * compile.h : add macro ADD_CALL
-
- * debug.c : add debug_v() and change to use only printf
- on debug_id()
-
- * sample/test.rb :
-
- * vm.c : fix make_proc_from_block
-
-
-2005-11-19(Sat) 14:55:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * import ruby 1.9.0 (2005-11-18)
-
-
-2005-11-19(Sat) 06:08:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/test : added
-
-
-2005-11-19(Sat) 05:48:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : useless jump elimination (if/unless destination)
-
- * eval.c : rb_iter_break support,
- fix rb_iterate (clear errinfo if break)
-
- * eval_proc.c : support rb_node_arity (YARV_METHOD_NODE)
-
- * insns.def : change variable name
-
- * vm.c : fix th_invoke_yield and add th_iter_break()
-
- * vm_dump.c : fix yarv_bug()
-
- * yarvcore.c : fix proc_mark to check IFUNC node and add
- global ruby method SDR() for debug
-
- * yarvtest/test_syn.rb : add a test for all condition combination
-
-
-2005-11-15(Tue) 05:52:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/forwardable.rb : added
-
- * common.mk : remove "vm.o : CFLAGS += -fno-crossjumping" rule
-
- * compile.c, yarvcore.h, insns.def : add FCALL/VCALL flag
-
- * compile.c, insns.def : add onceinlinecache instruction
-
- * eval.c : support $!, $@, raise (== raise $!)
-
- * opt_operand.def : add some unification rule (send flags)
-
- * vm.c : fix return process
-
- * vm_macro.def : fix option prameters
-
- * yarvtest/test_method.rb : add tests for above
-
-
-2005-11-15(Tue) 00:42:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : support rb_frame_pop() and rb_frame_callee(),
- add rb_sourcefile(), rb_souceline(),
-
-
- * compile.c : support postposition while/until,
- fix block parameter index
-
- * yarvtest/test_syn.rb : add tests for above
-
- * yarvcore.c : fix env_mark
-
- * vm.h, yarvcore.h : move vm.h#cmethod_info to
- yarvcore.h#yarv_cmethod_info
-
- * vm.c : add th_get_sourceline()
-
- * eval_intern.h : fix PASS_PASSED_BLOCK()
-
- * eval_load.c : fix re-enter require (temporalily)
-
- * insns.def : permit re-open class when superclass is same
-
-
-2005-11-11(Fri) 01:20:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : add "allload" rule
-
- * compile.c, yarvcore.h, insns.def, vm_macro.def, disasm.c :
- change arg_rest, arg_block offset (1)
-
- * insns.def : add postexe instruction
-
- * insns.def, vm.c : support rest block parameter
-
- * yarvtest/test_block.rb : add tests for above
-
- * rb/allload.rb : get path from ARGV
-
- * vm_opts.h.base : set default off
-
-
-2005-11-01(Tue) 08:28:19 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/other-lang/eval.rb : fix path
-
- * lib/English.rb, lib/cgi.rb, lib/complex.rb, lib/delegate.rb :
- added
-
-
-2005-11-01(Tue) 08:18:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : push and pop values after checkincludearray for
- stack caching
-
-
-2005-10-31(Mon) 15:37:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_app_mandelbrot.rb : added
-
- * benchmark/bm_app_factorial.rb : fixed parameter
-
- * benchmark/bm_so_count_words.rb, benchmark/run_rite.rb : use
- real file
-
- * common.mk : add "ext" rule, add some dependencies and add option
- to bench-each rule (renamed from bench-item)
-
- * compile.c : fix get_root_iseq_object (check iseq type),
- support splat case/when. support //o (regexp)
-
- * eval.c : support *_eval, fix rb_obj_call_init to pass block
-
- * eval_jump.h : support throw/catch
-
- * eval_load.c : save klass_nest_stack when require
-
- * eval_method.h : fix ruby_cbase()
-
- * insnhelper.h : GET_EV_KLASS checks toplevel or not
-
- * insns.def, yarvcore.c : fix singleton method definition and fix
- super class's method
-
- * lib/shellwords.rb : use String() instead of String.new()
-
- * vm.c : check class iseq or not when making Proc and
- add eval_search_super_klass function
-
- * vm.h : CMETHOD_INFO_P to yarvcore.h
-
- * vm_macro.def : splat if object type is T_ARRAY
-
- * vm_opts.h, vm_opts.h.base : rename to vm_opts.h.base
- insns2vm.rb will copy it to build directory
-
- * yarvcore.c : add Proc#[]
-
- * yarvcore.h : change INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE
- to 512
-
- * yarvtest/test_* : invalidate splat non array code (like: "*1")
-
- * yarvtest/yarvtest.rb : use tempfile instead of popen
-
-
-2005-10-28(Fri) 09:11:53 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvtest/test_method.rb : fix test
-
-
-2005-10-28(Fri) 08:43:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run_rite.rb : add -I options to run benchmark
-
- * common.mk : pass options to some rules with RUNOPT
- and add -I options
-
- * compile.c : fix massign with constant
-
- * yarvtest/test_massign.rb : add tests for above
-
- * eval_load.c : fix load_wait()
-
- * eval_method.h : support ruby_cbase()
-
- * lib/*.rb : add or modify libraries to run on yarv
- * parse.y : change to ANSI C style
-
- * vm.c : fix making proc process under cfunc/ifunc environment
-
- * vm_macro.def : fix block pass
-
- * yarvtest/test_method.rb : add tests for above
-
- * yarvcore.c : add yarv_obj_is_proc()
-
- * eval.c : fix rb_obj_is_proc to use yarv_obj_is_proc()
-
-
-2005-10-27(Thu) 11:50:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * some files : import from ruby 1.9.0 (2005-10-12)
-
-
-2005-10-16(Sun) 14:50:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c, yarvcore.h, yarvcore.c : add insns "bitblt" and "answer"
-
-
-2005-10-11(Tue) 17:01:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarv_version.h, Changes : 0.3.2
-
-
-2005-10-11(Tue) 13:35:25 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : add YARV_CHECK_INTS()
-
- * thread.c, thread_pthread.h, thread_win32.h : kick timer thread
- when another thread kicked
-
- * vm.c : remove debug print
-
- * vm_opts.h : add OPT_CALL_THREADED_CODE
-
- * yarvtest/yarvtest.rb : remove "\r" from answer
-
-
-2005-10-07(Fri) 09:36:36 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : add member variable "interrupt_flag" to yarv_thread_t
-
-
-2005-10-05(Wed) 21:20:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eva.c, eval_thread.c, ruby.h, eval_error.h, eval_jump.h,
- eval_load.c, thread.c, error.c, compile.h : remove ruby_errinfo
-
- * thread_win32.h, thread_pthread.h : set stack size to 4KB
-
- * vm.c : fix making env routine
-
- * vm_dump.c, vm.h : support frame type "EVAL" and fix magic number
-
- * yarvcore.c : fix some mark/free routine
-
-
-2005-10-05(Wed) 09:08:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, eval_intern.h, vm.c, eval_jump.h, yarvcore.h :
- re-define PUSH/POP/EXEC/JUMP_TAG to use thread local tag
-
- * inits.c, yarvcore.c : fix boostrap
-
-
-2005-10-03(Mon) 22:28:24 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix NODE_COLON2 bugs
-
- * compile.h : fix debug routine
-
- * disasm.c : add space between insn and operand
-
- * insns.def : add comment of classdef, singletonclassdef
-
- * vm.c, yarv.h : fix invoke_light routine
-
- * yarvcore.c : fix to mark each threads
-
-
-2005-10-02(Sun) 05:55:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread_pthread.h : add "system_working" global variable
-
-
-2005-10-02(Sun) 01:23:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c : add raw gets (for test), and fix indent
-
-
-2005-10-01(Sat) 23:06:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread_win32.h, common.mk : add thread_win32.h
-
- * thread.c : support _WIN32 thread
-
- * thread.c, thread_pthread.h : fix some interface
-
- * eval_thread.c : remove debug print
-
- * gc.c : fix stack region
-
- * win32/Makefile.sub : add -MD flag to LDFLAGS
-
- * yarvcore.c : fix mark and sweep debug print
-
- * yarvcore.h : fix VM#living_threads data type to st_table
-
-
-2005-10-01(Sat) 00:25:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c, yarvcore.h : rename GIL (Global Interpreter Lock) to
- GVL (Global VM Lock)
-
- * thread_pthread.h : fix pthread mutex initialize
-
-
-2005-09-30(Fri) 20:11:19 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c : support join with timeout
-
- * yarvcore.h : use GET_VM()
-
-
-2005-09-30(Fri) 14:59:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * thread.c, common.mk : add thread.c
-
- * thread.c, gc.c, eval_thread.c, yarvcore.c, yarvcore.h :
- support native thread (on pthread)
-
- * insns.def : add YARV_CHECK_INTS() check
-
- * yarv.h : add GET_VM() macro
-
-
-2005-09-29(Thu) 22:43:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_intern.h, eval_thread.c : move thread_status to eval_intern.h
-
- * yarvcore.c : fix thread/vm value
-
- * yarvcore.h : add some parameter to yarv_thread_t
-
-
-2005-09-29(Thu) 01:52:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.h : add line number on last end instruction
-
- * vm.c : fix line no detection
-
-
-2005-09-28(Wed) 00:02:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk, eval_load.c, eval.c, eval_intern.h : add eval_load.c
-
- * disasm.c : fix around block local variables
-
- * eval_proc.c : fix typo
-
-
-2005-09-27(Tue) 16:45:20 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : remove debug print
-
-
-2005-09-27(Tue) 16:41:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : support Kernel.local_variables
-
- * parse.y, yarvcore.c : move some functions
- (rb_(backref|lastline)_(get|set)) from parse.y to yarvcore.c
-
- * yarvcore.h : fix typo of YARV_PREVIOUS_CONTROL_FRAME
-
-
-2005-09-26(Mon) 18:51:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c, compile.c, parse.y, vm.c, yarvcore.h :
- eval() works with binding (Env)
-
- * vm.c : add th_set_eval_stack
-
- * yarvtest/test_syn.rb : remove an assert "defined?(local_var)"
-
-
-2005-09-25(Sun) 19:30:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_vm2_send.rb : added
-
- * common.mk : add rule "bench-item"
-
- * eval_intern.h : add PASS_PASSED_BLOCK()
-
- * eval_proc.c : support some functions
-
- * rb/mklog.rb : added
-
- * vm.c : fix prototype style and coding style
-
- * yarv.h : add some prototypes of functions
-
- * yarvcore.c, yarvcore.h, eval.c : yarv_thread_t#ifuncnode -> passed_block,
- and add yarv_proc_t#safe_level
-
-
-2005-09-25(Sun) 11:01:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * some files : import from ruby 1.9.0 (2005-09-25)
-
- * eval*, vm.c, vm_macro.def : remove frame, scope, ...
-
- * yarvcore.c : remove yarv_block_given_p()
-
- * yarvcore.h, insnhelper.h : move some macro from insnhelper.h to yarvcore.h
- to use these in eval.c
-
-
-2005-09-24(Sat) 15:51:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval* : remove dependency to ruby_dyna_vars and ruby_class
-
-
-2005-09-23(Fri) 20:39:14 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval_*.[ch] : split eval.c to some files
-
- * *.[ch] : import ruby 1.9.0 (2004-09-23)
-
- * parse.y : remove dependency to ruby_dyna_vars and ruby_scope
-
-
-2005-09-15(Thu) 16:51:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.h : fix "for" scope
-
- * yarvtest/test_block.rb : add tests for above
-
-
-2005-09-14(Wed) 06:11:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, vm_evalbody.h, vm.h, vm_dump.c,
- compile.c, yarvcore.c : use #ifdef insted of #if for recognize
- vm options
-
- * vm_opts.h : fix default options
-
-
-2005-09-10(Sat) 14:10:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm_opts.h : added
-
- * yarvcore.h, rb/insns2vm.h : use vm_opts.h
-
-
-2005-09-10(Sat) 04:53:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, insns.def, compile.c : add DEFINED_YIELD
-
- * yarvtest/test_yield.rb : add test_1_ary_and_1_params
-
- * insns.def : fix splat and svalue
-
- * vm.c : fix to perform with proc with ifunc (incomplete)
-
- * sample/test.rb : added (comment out unsupported features)
-
- * common.mk : add rule "runtest"
-
-
-2005-09-09(Fri) 19:32:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c : add splatarray
-
- * yarvtest/test_massign.rb : add tests for above
-
-
-2005-08-31(Wed) 22:55:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c (yarvcore_eval_parsed): fix to return value
-
- * yarv_version.h, Changes : 0.3.1
-
-
-2005-08-20(Sat) 10:19:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/ir.rb : add some check
-
- * import today's ruby HEAD
-
-
-2005-08-18(Thu) 23:29:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : fix object file extension
-
- * rb/ir.rb : added (import ruby script)
-
- * rb/diff.rb : removed
-
- * import today's ruby HEAD
-
-
-2005-08-18(Thu) 12:59:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk : rule test -> test2, test1 -> test
-
- * compile.c : fix when clause bug and splat arugment
-
-
-2005-08-17(Wed) 05:22:31 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix block local parameter setting routine and support
- massign in block parameter initialze
-
- * yarvtest/test_yield.rb : add tests for above
-
- * insns.def, compile.c : support array concat (ex: "[x, *y]")
-
- * yarvtest/test_bin.rb : add tests for above
-
-
-2005-08-16(Tue) 19:51:19 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support nested massign
-
- * yarvtest/test_massign.rb : add tests for above
-
-
-2005-08-16(Tue) 10:25:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : support rb_yield_0 with 0 args
-
-
-2005-08-16(Tue) 09:09:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * lib/fileutils.rb : imported
-
- * insns.def : fix yield argument (same as last commit)
-
- * yarvtest/test_yield.rb : add tests for above
-
-
-2005-08-16(Tue) 08:29:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : fix to support rb_yield_0 with multiple values
-
- * common.mk : add parse, run1p ruelse
-
- * compile.c : support yield with ARGSCAT/SPLAT
-
- * vm.c, insns.def : fix yield arguments to do compatible behaviour
-
- * yarvtest/test_yield.rb : added for above
-
-
-2005-08-16(Tue) 06:00:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix to set klass_nest_stack on singleton
- method definition
-
- * yarvtest/test_method.rb : add a test for above
-
-
-2005-08-16(Tue) 05:34:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test1.rb : added. gdb and run1 rule run this script
-
- * compile.c : fix error handled variable access
-
- * yarvtest/test_exception.rb : add tests for above
-
-
-2005-08-16(Tue) 04:26:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * base ruby : ruby 1.9.0 (2005-08-15)
-
-
-2005-08-16(Tue) 03:54:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * common.mk, Makefile.in : move some rules to common.mk
-
- * rb/diff.rb : added
-
- * yarvtest/yarvtest.rb : fix to compare output last value
-
-
-2005-08-15(Mon) 18:27:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * Changes : 0.3.0
-
-
-2005-08-15(Mon) 17:56:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : fix to add prototype
-
- * all files : propset svn:eol-style native
-
-
-2005-08-15(Mon) 10:48:53 +0900 Koichi Sasada <ko1@atdot.net>
-
- * eval.c : support rb_load
-
-
-2005-08-15(Mon) 09:42:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : define SDR()
-
- * vm_dump.c : stack_dump_raw() -> vm_stack_dump_raw()
-
- * yarvtest/yarvtest.rb : add rite test scheme
-
- * benchmark/run_rite.rb : added
-
- * yarvcore.c, inits.c : add Init_vm()
-
- * yarv.h : add some prototype declarations, GET_THREAD()
-
- * eval.c : remove unused functions
-
- * eval.c : support Kernel.eval, some schemes (same as evalc.patch)
-
-
-2005-08-15(Mon) 00:53:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarv_version.h : move configurations to yarvcore.h
-
- * yarvcore.c : remove VALUE yarv_get_current_running_thread() and
- add yarv_thread_t *yarv_get_current_running_thread(), ...
-
- * yarvcore.h : yarv_thread_t#vm -> vm_value
-
- * compile.c : fix "break from nested classes"
-
- * yarvext/extconf.rb : use have_func instead of defined?(YARV_PACHED)
-
- * depend : fix pass
-
- * eval.c : change to kick VM
-
- * version.c : fix to show yarv version
-
- * common.mk : fix dependent
-
- * inits.c : fix to kick Init_yarvcore
-
-
-2005-08-14(Sun) 02:05:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * README : add description
-
- * yarvext/depend : move to topdir/depend
-
-2005-08-14(Sun) 01:50:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * merge yarv to ruby (prepare)
-
- * make yarvext/ to build as extension
-
-
-2005-08-13(Sat) 09:36:26 +0900 Koichi Sasada <ko1@atdot.net>
-
- * evalc.patch, insns.def, compile.c : fix to support current
- ruby HEAD.
-
- * 0.2.3
-
-
-2005-08-08(Mon) 19:13:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h, Changes : 0.2.2
-
-
-2005-08-08(Mon) 17:17:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.h, vm.c, insns.def, yarvcore.h, yarvcore.c :
- remove yarv_iseq_t#iseq_dt and add yarv_iseq_t#encoded.
- use yarv_iseq_t#encoded anytime
-
- * vm_evalbody.h, vm.h, extconf.rb, version.h :
- support call threaded code (incomplete)
-
-
-2005-08-01(Mon) 05:26:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : support yield with multiple values
-
- * compile.c : fix dynavars
-
- * yarvcore.h : fix to mark defined method
-
-
-2005-07-31(Sun) 23:27:24 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, vm.c, insns.def : fix search object path
-
- * compile.c : fix "for" statement
-
- * vm_macro.def : fix rest, opt arguments
-
-
-2005-07-31(Sun) 14:52:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm_macro.def : fix block parameter
-
- * compile.c : fix to unuse compile_data->in_ensure
-
- * insns.def : add orphan check when return
-
-
-2005-07-31(Sun) 03:25:05 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, compile.c, yarvcore.h, insns.def :
- support jump from rescue/ensure/class/module
-
- * test/test_flow.rb : add tests for above fix
-
-
-2005-07-30(Sat) 04:44:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : struct iseq_compile_data_ensure_node_stack is added
-
- * compile.c : insert ensure clause before break/next/redo
-
- * vm.c : fix return/break handling
-
- * yarv.h, vm.c : fix lightweight yield
-
- * vm.c, insns.def, vm_macro.def : change arguments of th_set_env (add sp)
-
- * test/test_flow.rb : added
-
- * test/yarvtest.rb : add ae_flow
-
- * compile.c, vm_macro.def : add tail-call/tail-recursion optimization
- (experimental)
-
-
-2005-07-29(Fri) 20:14:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : make_name_for_block and make_name_with_str
- are added
-
- * insns.def : fix if unmatched size arg size to yield
-
- * test/test_block.rb : add test for above fix
-
- * vm.c : add th_backtrace_each and fix backtrace notation
-
- * yarvcore.c : set top level iseq name to "<main>"
-
-
-2005-07-29(Fri) 13:20:19 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : fix yarv_iseq_t to pass VC (cl)
-
- * vm_dump.c : ditto
-
- * compile.h : ditto
-
- * insnhelper.h : ditto
-
- * vm_evalbody.h : include 'math.h'
-
- * insns.def, vm.c : raise error when yield without block
-
- * vm.c : implement thread_backtrace
-
- * vm.c, yarvsubst.c, yarv.h : implement thread_yield_light_prepare and
- thread_yield_light_invoke
-
- * yarvcore.c : Integer#times uses yarv specific version
-
-
-2005-07-28(Thu) 21:35:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : add another mark function for thread/stack
-
- * vm_evalbody.h : fix register allocation for x86_64
-
- * vm.h : use asm for tc on x86_64
-
-
-2005-07-28(Thu) 20:17:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : add mark/free message to debug gc
-
- * insnhelper.h, insns.def, vm_macro.def : remove and
- add new RESTORE_REGS
-
- * vm_evalbody.h : fix register allocation
-
-
-2005-07-28(Thu) 02:00:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, etc : change VM stack structure. re-write all
- vm functions to do it
-
- * vm_macro.def : added
-
-
-2005-07-08(Fri) 01:36:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : don't use fmod on AMD64
-
-
-2005-07-08(Fri) 00:14:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * Changes : added
-
-
-2005-07-07(Thu) 23:54:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : 0.3.0
-
-
-2005-07-07(Thu) 23:52:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * 0.2.1 : released
-
-
-2005-07-07(Thu) 23:50:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : 0.2.1
-
-
-2005-07-07(Thu) 23:47:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb, extconf.rb : add --[enable|disable]-opt-unify-all-combination
- and --disable-opts
-
- * vm.h : DISPATCH_ARCH_DEPEND_WAY is only enabled on GCC 3.x
-
-
-2005-07-06(Wed) 13:20:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * depend, rb/eval.rb : add ITEMS option to benchmark rule
-
- * benchmark/* : changed
-
- * benchmark/other-lang/* : added
-
-
-2005-07-04(Mon) 04:02:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h. yarvcore.c : add idDIV, idMOD, idEq, idLength
-
- * compile.c, insns.def : add specialized insn for above method id
-
- * test/test_bin.rb : add tests for above
-
-
-2005-07-03(Sun) 20:31:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, yarvcore.h : remove cYarvThrowObject (unused)
-
- * yarvcore.c, yarvcore.h, insns.def :
- thread_object#stack_mark_poinetr
-
- * depend, rb/eval.rb : BOPT, TOPT -> OPT
-
-
-2005-07-03(Sun) 13:53:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, compile.h : INSN_OBJECT, LABEL_OBJECT -> INSN, LABEL,
- ISEQ_LINK_ELEMENT, ISEQ_LINK_ANCHOR -> LINK_ELEMENT, LINK_ANCHOR,
- and some fixes
-
- * tmpl/optinsn.inc.tmpl : ditto
-
- * yarvcore.c, yarvcore.h : remove label_object, insn_object
- prepare_iseq_build, cleanup_iseq_build are added
-
- * insns.def : remove unused variable from send
-
-
-2005-07-02(Sat) 04:19:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : add GC protect for opt_aset
-
-
-2005-07-02(Sat) 03:49:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : add option -fno-reorder-blocks to vm.asm rule
-
- * insns.def : fix opt_aset bugs
-
- * test/test_bin.rb : add tests for aset, aref
-
-
-2005-07-02(Sat) 03:05:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb : fix output
-
- * vm_evalbody.h : add register for x86_64
-
- * rb/asm_parse.rb : fix to shor size and length
-
-
-2005-07-02(Sat) 02:56:31 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : move specialized instruction point (new_insn_send)
-
- * insns.def : add opt_aref, opt_aset
-
-
-2005-07-01(Fri) 11:04:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.h : fix to pass VALUE type to new_insn_body
-
- * insnhelper.h : add cast
-
- * compile.c : fix getdynamic argument (0 == Qfalse -> I2F(0))
-
-
-2005-06-30(Thu) 23:34:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/eval.rb : add and fix some rules
-
- * rb/insns2vm.rb : generate all
-
- * benchmark/run.rb : add -r (ruby only) option
-
-
-2005-06-30(Thu) 23:25:23 +0900 Koichi Sasada <ko1@atdot.net>
-
- * tmpl/vmtc.inc.tmpl : add const prefix
-
- * /rb/asm_parse.rb, extconf.rb : added and make assembler analised output
-
- * opt_operand.def : add send operands unification
-
- * insnhelper.h : add HEAP_CLASS_OF(obj)
-
- * insns.def : fix opt_plus, opt_ltlt
-
- * vm_evalbody.h : move _tag
-
- * benchmark/run.rb : fix file select
-
-
-2005-06-30(Thu) 06:07:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : add collect-usage-analysis option
-
- * opt_operand.def, opt_insn_unif.def : add some rules
-
-
-2005-06-29(Wed) 23:28:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, extconf.rb, vm.h, compile.c :
- DISPATCH_DIRECT_THREADED_CODE, DISPATCH_THREADED_CODE
- -> OPT_DIRECT_THREADED_CODE, OPT_INDIRECT_THREADED_CODE.
- if at least one of then is defined, OPT_THREADED_CODE is defined
-
- * benchmark/* : fix name and parameters
-
- * rb/eval.rb : added for YARV evaluation
-
-
-2005-06-29(Wed) 16:16:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb : fix output format
-
- * call_cfunc.inc -> call_cfunc.h
-
- * vm.h : add sign by asm statement
-
-
-2005-06-28(Tue) 22:28:40 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : fix method search
-
-
-2005-06-28(Tue) 22:26:34 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : fix options
-
-
-2005-06-28(Tue) 21:50:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb : fix output format
-
-
-2005-06-28(Tue) 21:34:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * depend : add option TOPT to test rules
-
- * benchmark/run.rb : fix output format
-
-
-2005-06-28(Tue) 21:15:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix opt_case_dispatch instruction
-
- * benchmark/run.rb : output all usertimes when exit benchmark
-
-
-2005-06-28(Tue) 20:35:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb, compile.c, tmpl/optinsn.inc.tmpl, vm.c :
- change extconf options
-
-2005-06-28(Tue) 13:20:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb : add -y, --yarv-only option
-
- * depend : add BOPT to tbench rule
-
-
-2005-06-27(Mon) 23:31:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * depend : add gdb rule
-
- * vm.h : use inline assembler for x86 (to support gcc 3.4.x)
-
-
-2005-06-27(Mon) 20:04:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, compile.c, disasm.c : remove unused variables
-
- * vm.h, insnhelper.h, debug.h : fix to reduce warning
-
- * vm.c, vm_dump.c : move VM state dump (debug) functions to vm_dump.c
-
- * depend : adde reconf rule
-
- * insnhelper.h :
-
- * vm_evalbody.inc : rename to vm_evalbody.h
-
-
-2005-06-27(Mon) 16:50:31 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns2vm.rb : fix generating unif insn
-
- * compile.c : add useless pop/swap insn elimination with stack caching
-
- * depend : remove compiled.o dependency
-
-
-2005-06-26(Sun) 14:06:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb : use tmpfile instead of popen
-
- * rb/insns2vm.rb : fix generating insn unification logic
-
- * opt_insn_unif.def : add some unification rules
-
- * compile.c : add verify_list function and fix unification logic
-
-
-2005-06-22(Wed) 12:58:26 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c, insns.def, compile.c : add mult optimization
-
- * test/test_bin.rb : add test_fact
-
-
-2005-06-21(Tue) 22:34:07 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, compile.[ch], tmpl/optinsn.inc.tmpl, rb/insns2vm.rb :
- change data structure (don't use Ruby's array to represent a
- instruction sequence)
-
- * disasm.c : add separator
-
-
-2005-06-14(Tue) 07:48:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support "for" statement
-
- * test/test_block.rb : add test for above
-
- * yarvcore.[ch] : add global id idEach
-
-
-2005-06-08(Wed) 22:30:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : add if/unless(L1) jump (L2) :L1 => unless/if(L2)
- optimize (condition reversal) and fix typo
-
-
-2005-06-07(Tue) 08:29:41 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : fix to remove compiler warning
-
- * version.h : 0.2.1
-
-
-2005-06-07(Tue) 08:16:22 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : iseq_link_element changed to double linked list
-
- * disasm.c : support dump struct iseq_link_element
-
- * compile.c : use double linked list instead of array
- for intermediate representation
-
-
-2005-06-06(Mon) 15:38:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c : add link structure to insn and label object
-
- * compile.h, compile.c : remove some variables in function top scope
- of iseq_compile_each and some optimization (now working)
-
-
-2005-06-04(Sat) 16:12:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix previous commit
-
-
-2005-06-04(Sat) 15:56:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix stack caching (after jump state)
-
-
-2005-06-04(Sat) 09:12:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix some point for previous commit
-
-
-2005-06-04(Sat) 07:31:21 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : optimize case/when statement
- (dispatch on constant time)
-
- * yarvcore.h, disasm.c, rb/insns2vm.rb : fixed for above
- (CDHASH)
-
- * test/test_syn.rb : add test for above
-
-
-2005-06-04(Sat) 03:41:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c : add some temporary variable test
- (it'll be vanished)
-
- * compile.c : NODE_CASE optimize (use topn instead of dup/swap)
-
-
-2005-06-03(Fri) 00:54:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : apply flow optimization for while/until statement
-
-
-2005-03-04(Fri) 19:34:32 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb : fix category (comment)
-
- * depend : remove space betweeen target name and colon
-
-
-2005-03-04(Fri) 15:55:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * tmpl/yarvarch.ja : fix typo
-
-
-2005-03-04(Fri) 13:30:19 +0900 Koichi Sasada <ko1@atdot.net>
-
- * depend : add a rule for jitcompile.o
-
- * vm.h : fix a macro argument
-
- * version.h : 0.2.0
-
-
-2005-03-03(Thu) 08:35:14 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : remove vm_evalbody.inc call_cfunc.inc from clean target
-
-
-2005-03-03(Thu) 00:54:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * tmpl/insns.inc.tmpl : fixed typo
-
- * insns.def : store th->pc to current pc
-
-
-2005-03-03(Thu) 00:31:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * tmpl/yarvarch.ja, doc/yarv.rb : write current architecture of yarv
-
-
-2005-03-01(Tue) 13:50:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c (yarvcore_eval_parsed) : added
- (separeted from yarvcore_eval)
-
- * yarvcore.c, compile.c : iseq_translate_direct_threaded_code
- is moved to compile.c
-
- * depend : add rule for yasmdata.rb
-
- * rb/yasm.rb : support top-level and method-level assemble
-
-
-2005-02-26(Sat) 08:09:57 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb, compile.c, vm.h : change type long to OFFSET
-
- * tmpl/yasmdata.rb.tmpl : added
-
- * rb/insns2vm.rb : add yasmdata_rb method
-
- * rb/yasm.rb : fix some interface (incomplete)
-
- * compile.c : iseq_setup added
-
- * yarvcore.c : YARVCore::InstructionSequence::Instruction#make added
-
-
-2005-02-24(Thu) 07:45:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/yasm.rb : added
-
-
-2005-02-24(Thu) 01:13:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : remove useless statements
-
-
-2005-02-24(Thu) 00:46:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb (InsnInfo) : add @is_sc attr and remove
- is_sc method
-
- * compile.c : fix NODE_CASE/NODE_WHEN bug (cond at 'when'
- must not be popped)
-
- * compile.c : support NODE_OP_ASGN1 to &&= and ||=
-
- * test/test_bin.rb : add tests for above
-
-
-2005-02-23(Wed) 09:17:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, yarvcore.c : thread_svar added and fix svar location
-
-
-2005-02-21(Mon) 08:38:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h : make type "struct iseq_compile_data"
-
- * yarvcore.h : iseq_object#insn_info_ary to iseq_object#insn_info_tbl
-
-
-2005-02-21(Mon) 05:24:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c (compile_string) : remove null check of node
-
-
-2005-02-19(Sat) 03:52:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : 0.1.1
-
-
-2005-02-18(Fri) 20:57:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c : add idLTLT, idMethodMissing
-
- * compile.c : suopport lval (or others) block parameter
-
- * test/test_block.rb : add tests for above
-
- * insns.def (send) : support method_missing
-
- * test/test_method.rb : add tests for above
-
- * insns.def : opt_ltlt and
-
-
-2005-02-18(Fri) 08:54:40 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/runc.rb : added
-
- * benchmark/contrib/pentomino.rb : added opt_ltlt
- and Float, String plus specialization
-
-
-2005-02-18(Fri) 07:49:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : remove debug print
-
- * rb/aotcompile.rb : skip if yarvcore.so is not created
-
-
-2005-02-18(Fri) 06:46:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix block passing
- and block argument
-
-
-2005-02-18(Fri) 05:52:41 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : thread_get_ev_const, thread_get_ev_defined is added
- (separated from insns.def)
-
- * insnhelper.h : GET_EV_KLASS(klass) is added
- (separated from insns.def)
-
- * yarvcore.h, insns.def, compile.c : support defined? expression (limited)
-
- * test/test_syn.rb : tests for above is added
-
- * compile.c, insns.def : support block passed method dispatch
-
- * test/test_method.rb : tests for above is added
-
- * compile.h : CALL_ARGS_SPLAT is removed
-
-
-2005-02-16(Wed) 13:32:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * disasm.c : fix ID to String method
-
- * compile.c : NODE_SUPER, NODE_ZSUPER check 'poped'
- and NODE_RETURN check outer type
- and NODE_DREGX_ONCE supported (temporarily)
-
- * test/test_syn.rb : add a test
-
- * test/test_jump.rb : add a test
-
-
-2005-02-16(Wed) 06:07:41 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.[hc] : use Symbol instead of Fixnum to represent ID
-
- * rb/insns2vm.rb : add attr_reader :insns, :insn_map
-
- * vm.h, rb/insns2vm.rb : END_INSN have one arg
-
- * jitcompile.c : jit compiler framework (experimental)
-
- * rb/aotcompile.rb : refactoring
-
- * compiled.c : add constant pool
-
- * vm_evalbody.inc, call_cfunc.inc, vm.c : separeted from vm.c
-
- * insns.def : fix return val
-
- * depend : add rules for compiled.o
-
-
-2005-02-14(Mon) 13:09:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insnhelper.h, yarvcore.h: move YARV_METHOD_NODE to yarvcore.h
-
- * yarvcore.h : add 2 members jit_compiled and iseq_orig
- to struct iseq_object
-
- * yarvcore.c : add yarv_jitcompile and global function jitcompile
-
- * insns.def : insn opt_call_native_compiled added
-
- * jitcompile.c : added
-
-
-2005-02-12(Sat) 05:38:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (putstring) : fixed to duplicate string object
-
- * rb/insns2vm.rb, tmpl/optunifs.inc.tmpl, compile.c : support
- instructions unification (aka super instruction)
-
- * opt_insn_unif.def : added for above
-
- * benchmark/bm_unif1.rb : added to measure efficiency of unification
-
- * depend : fixed for above
-
- * extconf.rb : add option --(enable|disalbe)-opt-insns-unification
-
-
-2005-02-11(Fri) 12:14:39 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, vm.c, insns.def : permit to access svar from
- cfunc environment
-
- * test/test_method.rb : add tests for above
-
-
-2005-02-09(Wed) 19:31:06 +0900 Koichi Sasada <ko1@atdot.net>
-
- * ite.rb : added (ruby -rite [script file])
-
-
-2005-02-09(Wed) 02:25:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.[hc] : add member compile_data (hash) to iseq_object
-
- * compile.c, yarvcore.h : check label is already set
-
- * compile.c, extconf.rb : support __goto__ and __label__ statement
-
-
-2005-01-25(Tue) 12:49:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_block.rb : add break test to test_times
-
-
-2005-01-25(Tue) 03:34:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : check ruby version if yarv patch is applied or not
-
- * evalc.patch : fixed for rb_call_super and above check
-
-
-2005-01-25(Tue) 03:21:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb : refactoring (mainly, make InsnsDef::InsnInfo
- to represent each instruction information)
-
- * depend, rb/makedocs.rb : fixed for above
-
- * yarvcore.c (thread_call_super) : added
-
- * vm.c (thread_call_super) : added
-
- * vm.h : add struct cmethod_info
-
- * insns.def, vm.c : use cmethod_info to represent C method info
-
- * insns.def : use iseq_object#klass_nest_stack
- to search super/zsuper's class
-
- * prosym.rb : removed
-
- * ToDo : write todo things on wiki
-
-
-
-2005-01-18(Tue) 23:44:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb : check ENV['RUBY'] to use ruby binary
-
-
-2005-01-10(Mon) 08:44:40 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : 0.1.0
-
-
-2005-01-09(Sun) 22:01:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * repository : svn propset svn:eol-style native *.c *.h tmpl/*.tmpl
-
-
-2005-01-09(Sun) 21:48:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : FREE_UNLESS_NULL, MARK_UNLESS_NULL macros are added
-
- * yarvcore.c : some insn/label methods are added
-
- * yarvcore.h : add structure menber "insns_ary" to iseq_object
-
- * vm.c, insns.def (thread_eval_body) : return values with throw
-
- * prosym.rb : added
-
- * insns.def : add YARV_AOT_COMPILED and some procedure
-
- * depend : add compiled.c
-
- * compiled.c : added to build compiled Ruby program (C source)
- by AOT compiler
-
- * rb/aotcompile.rb : AOT compiler
-
- * aotct.rb, rb/aotctest.rb : test and benchmark AOT compiler
-
- * rb/allload.rb : added
-
-
-2005-01-09(Sun) 08:30:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c (yarv_yield_values) : added
-
- * vm.c (thread_call0) : change interface. substitute rb_call0 in
- yarv environment
-
- * yarvcore.c (yarv_call0) : fix for above
-
- * yarvcore.c (yarv_call0_cfunc) : removed
-
- * yarvcore.c : change passing items for yarv_setup
-
- * evalc.patch : fix for above
-
- * benchmark/bm_lists.rb : fix (unsupport block passing)
-
- * benchmark/run.rb : use full path to ruby
-
- * insns.def (yield): raise error if argc > expected argc
-
-
-2005-01-08(Sat) 16:07:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : add descrioptions
-
- * compile.c : fix bugs (getinlinecache operands)
-
- * yarvcore.c : initial value of yarvGlobalStateVersion
- to 1
-
-
-2005-01-08(Sat) 14:39:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, vm.c, evalc.patch : support making backtrace
- (incompatible with current ruby interpreter)
-
-
-2005-01-08(Sat) 11:25:46 +0900 Koichi Sasada <ko1@atdot.net>
-
- * evalc.patch : commit for previous commit change
-
- * yarvcore.h, compile.c, insns.def : MC to IC (inline cache),
- and changed to using IC by set/getinlinecache
-
-
-2005-01-08(Sat) 10:04:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : add global variable sym[IC]FUNC
-
- * yarvcore.c (yarv_iterate, yarv_call0_cfunc) : added
- (each called from rb_iterate, rb_call0 with NODE_CFUNC)
-
- * vm.c (stack_dump_raw) : fixed to prints more detail
-
- * vm.c (stack_dump_th, stack_dump_thobj) : added to
- dumps thread_object states (for VALUE, struct pointer)
-
- * vm.c (thread_dump_regs) : added
-
- * vm.c (thread_call0, thread_call0_cfunc, thread_invoke_yield,
- thread_invoke_yield_cfunc), insns.def (yield, send) :
- fixed, added to support IFUNC
-
- * vm.c, yarvcore.c, insns.def : change type purpose
- thread_object#block_ptr (it holds IFUNC block information,
- so this type was changed to 'NODE *')
-
- * vm.c (stack_dump_each) : fixed for above
-
- * test/test_block.rb (test_ifunc) : test for above
-
- * vm.c (get_block_objec, thread_make_env_object) : fixed bugs
-
- * test/test_bin.rb (test_xstr) : remove `ls` test
-
-
-2005-01-06(Thu) 21:35:18 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarv : trying to support NODE_IFUNC (rb_iterate)
-
-
-2005-01-05(Wed) 06:50:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, insns.def, disasm.c, rb/insns2vm.rb, compile.[ch] :
- support inline method cache
-
- * extconf.rb : add -*-inline-method-cache (default: enable)
-
- * test/test_method.rb : add a test for above
-
- * benchmark/bm_poly_method.rb : added
-
- * yarvcore.c : add option string
-
-
-2005-01-04(Tue) 17:15:41 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c : add compile_array and duparray insn
- to optimize only literal array creation
-
- * benchmark/bm_array.rb : added
-
-
-2005-01-04(Tue) 10:02:40 +0900 Koichi Sasada <ko1@atdot.net>
-
- * README : fix version
-
-
-2005-01-04(Tue) 09:57:25 +0900 Koichi Sasada <ko1@atdot.net>
-
- * ToDo : reflect current status
-
-
-2005-01-04(Tue) 09:43:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_VALUES, NODE_ARGSCAT, NODE_SPLAT
-
- * test/test_massign.rb : add tests for above
-
- * benchmark/bm_swap.rb : added
-
-
-2005-01-04(Tue) 06:25:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.h : COMPILE_ERROR break contol (instead of return)
-
- * compile.c : support NODE_MASGN
-
- * insns.def : change expandarray for massign and add topn insn
-
- * test/test_massign.rb : added
-
-
-2005-01-03(Mon) 21:20:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : store block when create proc
-
- * test/test_proc.rb : add a test for above change
-
- * yarvcore.c : add global function "once"
-
-
-2005-01-02(Sun) 00:40:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_super.rb : fix bug (remove infinite loop)
-
-
-2005-01-01(Sat) 23:45:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_z?super.rb : added
-
-
-2005-01-01(Sat) 23:37:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bmx_so_object.rb : rename to benchmark/bm_so_object.rb
-
-
-2005-01-01(Sat) 23:19:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_OP_ASGN2, NODE_OP_ASGN_AND, NODE_OP_ASGN_OR,
- NODE_SUPER, NODE_ZSUPER, NODE_MATCH
-
- * insns.def : support super, zsuper (currently, super can't
- handle with block)
-
- * test/test_bin.rb : add test for op_asgin2, op_assgin_and/or
-
- * test/test_class.rb : add test for super, zsuper
-
-
-2005-01-01(Sat) 20:39:29 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_MATCH
-
- * yarvcore.c : fix yarv_svar bug (fix condition boundary)
-
- * insnhelper.h : save cfp/lfp/dfp vars to thread_object (th)
-
-
-2005-01-01(Sat) 20:03:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : 0.0.1
-
- * yarvcore.h : add idIntern declaration
-
- * insns.def : add getspecial, setspecial.
- implement getclassvariable, setclassvariable.
- store lfp before reg match (opt_regexpmatch1)
-
- * compile.c : support ditto, flipflop
-
- * yarvcore.c : support svar
-
- * test/test_syn.rb : add test for flipflop
-
- * test/test_bin.rb : add test for dsym, cvar, backref
-
-
-2005-01-01(Sat) 09:09:32 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : add getspecial insn
-
- * compile.c : support NODE_NTH_REF, NODE_BACK_REF
-
-
-2005-01-01(Sat) 06:53:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c : support alias, undef
-
- * test/test_method.rb : test for above
-
- * rb/insns2vm.rb : fix enbug
-
-
-2005-01-01(Sat) 06:00:32 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_jump.rb : add test (next with value)
-
- * yarvcore.h, yarvcore.c, compile.c, compile.h :
- raise compile error exception instead of rb_bug
-
- * yarvcore.c, evalc.patch : support "require"
-
- * test.rb : restore $" after evaluation with ruby
-
- * rb/insns2vm.rb : remove unnecesary each
-
-
-2004-12-17(Fri) 18:56:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix newhash
-
-
-2004-12-15(Wed) 13:29:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : add version string
-
- * compile.c : fix rescure clause bug
-
-
-2004-12-14(Tue) 22:46:30 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : add reput insn
-
- * vm.h : show stack cache registers when stack dump
-
- * rb/insns2vm.rb, compile.c : fix stack caching bugs
-
-
-2004-12-14(Tue) 00:51:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns2vm.rb, compile.c, tmpl/opt_sc.inc.tmpl : fix bugs
-
- * rb/mixc-asm.rb : added
-
-
-2004-12-14(Tue) 00:17:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c, compile.c : fix SC bugs
- (SC state management)
-
- * extconf.rb : add option -[enable|disable]-opt-stack-caching
-
- * insns2vm.rb : accept CPPFLAGS options
-
- * vm.c : support restrore register for pc
-
-
-2004-12-13(Mon) 16:53:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb : add macro INSN_IS_SC()
-
-
-2004-12-11(Sat) 10:51:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, compile.c : support singleton method definition
-
- * test/test_method.rb : add test for above
-
-
-2004-12-11(Sat) 03:17:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/*.rb : modify
-
- * extconf.rb : add $cleanfiles
-
-
-2004-12-08(Wed) 13:01:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : change to disable stack caching
-
-
-2004-12-07(Tue) 19:37:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.rb : add default after
-
- * insns.def : fix to work on stack caching
-
-
-2004-12-07(Tue) 15:07:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * depend : add some dependency to *.inc files
-
- * vm.c : add "register" and asm("regname") descriptor
-
- * rb/insns2vm.rb, compile.c : add stack caching support
-
- * tmpl/opt_sc.inc.tmpl : added to above change
-
- * rb/makedocs.rb : fix file path
-
- * extconf.rb : fix option selection
-
-
-2004-12-06(Mon) 11:20:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * extconf.rb : add vm.asm target if compiler is gcc
-
-
-2004-12-06(Mon) 09:56:24 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.h : rename method_frame's member block to block_ptr
-
- * extconf.rb : add "-fno-crossjumping" option when compiler
- is gcc
-
- * opt_operand.def : add unification insn send
-
- * rb/insns2vm.rb : define symbol instead of declare const
- variable (for more optmize on VC)
-
- * insns.def : move enter point in send
-
-
-2004-12-06(Mon) 04:53:51 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, opt_operand.def, rb/insns2vm.rb, depend :
- support operand unification
-
-
-2004-12-05(Sun) 03:16:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, insns.def : speed up throw/catch scheme
-
-
-2004-12-05(Sun) 01:47:05 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : fix catch handler bugs
-
- * test/test_jump.rb : test_complex_jump added
-
-
-2004-12-03(Fri) 20:39:05 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/contrib/mcq.rb : added
- (from URABE Syouhei)
-
-
-2004-12-03(Fri) 20:35:28 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : support break in rb_yield block
-
-
-2004-12-03(Fri) 14:26:35 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support block local variable in current
- ruby specification (patche from Kent Sibilev)
-
- * insns.def : support attr_* (patch from Kent Sibilev)
-
-
-2004-12-02(Thu) 21:04:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * opt_operand.def : added
-
-
-2004-12-02(Thu) 13:20:41 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c, vm.h, vm.c, insns.def, insnhelper.h, yarvutil.rb :
- add usage analisys framework
-
- * disasm.c : insn_operand_intern to separate function
-
- * benchmark/run.rb : run each benchmark on another process
-
-
-2004-12-01(Wed) 10:26:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : yield check block is given
-
- * benchmark/bm_lists.rb : rename to bmx_lists.rb
- (because it's not work ... bug?)
-
- * insns.def : opt_* support other type calc
-
-
-2004-11-30(Tue) 16:14:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_so_array.rb : added
-
- * benchmark/bm_so_matrix.rb : added
-
-
-2004-11-30(Tue) 14:11:30 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/getrev.rb : added
-
- * yarvcore.c : add YARVCore::REV, YARVCore::DATE constant
-
-
-2004-11-30(Tue) 13:05:42 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_OP_ASGN1 (incomplete)
-
- * insns.def : add dupn
-
-
-2004-11-30(Tue) 08:52:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : 0.0.0.f
-
-
-2004-11-30(Tue) 08:43:59 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_class.rb : add test_initialize and test_to_s
-
- * yarvsubst.c : use rb_funcall instead of yarv_funcall
-
- * evalc.patch : fix ruby's patch
-
- * benchmark/bm_so_*.rb : change naming rule. "bm_so_*" from
- language shootout
-
- * depend : tbench target item is ITEM env val (default: bmx_temp)
-
- * vm.c : show raw address if environment is in heap at dumping stack trace
-
- * vm.c : thread_call0 added
-
- * vm.c : fix thread_yield_light_invoke
-
- * yarv.h, yarvcore.c : remove yarv_funcall
-
-
-2004-11-29(Mon) 11:37:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test/test_proc.rb : add test test_nestproc
-
- * yarvsubst.c : comment out yarv_Array_each
-
- * insns.def : restore lfp/dfp after call_cfunc
-
- * vm.c : fix stack dump routine
-
- * vm.c : impliment thread_funcall (temporarily)
-
- * yarv.h : add IS_YARV_WORKING(), SET_YARV_START(), SET_YARV_STOP()
-
- * yarvcore.c : remove check with yarv_in_work
-
- * evalc.patch : added
-
-
-2004-11-27(Sat) 00:19:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.c : free -> ruby_xfree
-
-
-2004-11-26(Fri) 02:11:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm,c : fix bug
-
-
-2004-11-22(Mon) 11:19:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/bm_ackermann.rb, bm_proc.rb, bm_simpleiter.rb,
- bm_so_exception.rb, bm_wc.rb, wc.input added
-
-
-2004-11-22(Mon) 02:31:56 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_proc.rb : add some test
-
- * yarvcore.c, vm.c : support yield in C method (as rb_yield)
-
- * vm.c (thread_yield_light_(prepare|invoke)) : support lightweight
- yield
-
- * yarv.h : added
-
- * yarvcore.c, yarv.h : support yarv_is_working, yarv_block_given_p,
- yarv_yield, yarv_funcall (only dummy function)
-
- * vm.c : thread_eval_body changed return value
-
- * yarvsubst.c : added and add yarv_Integer_times, yarv_Array_each
-
- * yarvcore.h : block_ptr is added to struct thread_object
-
- * insns.def : pass block when C method call
-
- * insnhelper.h : add GET_ISEQOBJ(cfp) macro
-
-
-2004-11-21(Sun) 07:25:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c : support Proc#call
-
- * test/test_proc.rb : added
-
-
-2004-11-19(Fri) 18:04:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def, vm.c : support creating Proc object
-
-
-2004-11-15(Mon) 14:19:27 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def (send) : use clear_local_size to specify
- clear local table vars.
-
- * insns.def : block represent data shares lfp, dfp with frame data
-
-
-2004-11-13(Sat) 18:19:41 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, insns.def : add VM_CALL_ARGS_SPLAT_BIT and
- VM_CALL_ARGS_BLOCKARG_BIT
-
- * compile.c, compile.h : add ADD_SEND, ADD_SEND_R
-
-
-2004-11-10(Wed) 08:26:25 +0900 Koichi Sasada <ko1@atdot.net>
-
- * add "vm_" prefix to (block_object, proc_object, env_object)
-
-
-2004-11-03(Wed) 15:52:14 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c, disasm.c, compile.c, insns.def, vm.c :
- fix to move x86_64 (illegal cast, etc)
-
-
-2004-11-01(Mon) 04:45:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, compile.c, debug.c, version.h :
- redesgin gc debug scheme (GC_CHECK())
-
- * yarvcore.c : mark iseqobj->current_block on GC
-
- * insns.def, compile.c : last "throw" in ensure/rescue block
- use operand throwobj and before this insn, use "getdynamic 0, 1"
-
- * benchmark/bm_temp.rb : move to benchmark bmx_temp.rb
-
- * depend : change some targets
-
-
-2004-10-25(Mon) 19:57:58 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : push exception iseq to iseqobj->iseq_mark_ary
- to mark for GC
-
-
-2004-10-10(Sun) 16:25:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : remove $_, $' area from method local frame
- and provide that's special method local variables pointer(LFP[-1])
-
- * disasm.c : change environment showing format
-
- * yarvcore.(h|c) : add YarvProc, YarvEnv
-
- * yarvcore.h : add arg_block field to iseq_object
- and init -1 as default value
-
-
-2004-09-30(Thu) 19:50:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : support passing splat argument
-
- * compile.c, insns.def : support rest argument
-
- * compile.c, insns.def : support optional argument initializer
-
- * test/test_method.rb : add tests for above
-
-
-2004-09-29(Wed) 10:50:03 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix rescue clause popped
-
- * benchmark/bm_random.rb : move to benchmark/bmx_random.rb
-
-
-2004-09-29(Wed) 01:25:35 +0900 Koichi Sasada <ko1@atdot.net>
-
- * many many files: change stack frame design
-
-
-2004-09-16(Thu) 08:51:37 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.h : support 'return' from method
- in ensure clause
-
-
-2004-09-13(Mon) 21:56:40 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support inline cache constant access
- on NODE_COLON2, NODE_COLON3
-
- * depend : add 'vtest' rule(verbose test)
-
-
-2004-09-13(Mon) 10:58:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, yarvcore.h : support redo/next/break in
- while/until
-
-
-2004-09-13(Mon) 08:50:19 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_jump.rb : added(correctly)
-
- * benchamark/bm_(ensure|rescue|simplereturn).rb added
-
-
-2004-09-12(Sun) 23:30:20 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_jump.rb : added
-
- * insns.def, compile.c : add 'putnil' insn
-
- * compile.c : use '===' when rescue check
-
- * insns.def : remove 'rescuecheck' insn
-
- * compile.c : support retry in begin/rescue clause
-
- * ToDo : added
-
-
-2004-09-08(Wed) 12:34:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvcore.h, yarvcore.c : add idThrow*
-
- * insns.def, compile.c, vm.c : support retry, break,
- next, redo, return(imcomplete)
-
-
-2004-09-03(Fri) 13:40:08 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : add nop after rescue body
-
- * insns.def, vm.c : support stack rewind when thrown
-
-
-2004-09-01(Wed) 17:31:01 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_exception.rb : added
-
-
-2004-09-01(Wed) 13:15:14 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.c, insns.def : implementing exception handling
-
-
-2004-09-01(Wed) 00:18:54 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : add 'throw' insn
-
- * compile.c : support 'rescue' and 'ensure' clause
-
- * yarvcore.c, yarvcore.h : add 'catch_table' to iseq_struct
-
-
-2004-08-30(Mon) 19:06:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.h : NEW_ISEQOBJ don't pass self as parent
-
- * compile.c : use NEW_CHILD_ISEQOBJ explicitly
-
-
-2004-08-29(Sun) 21:09:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : trying to implement rescue/ensure
-
- * insns.def : fix yield bug(lfp, dfp link)
-
-
-2004-08-28(Sat) 13:52:15 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix dvar bug
-
- * test/test_block.rb : add test
-
- * insns.def, insnhelper.h : remove unused source code
-
-
-2004-08-28(Sat) 08:51:26 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_DASGN
-
- * test/test_block.rb : add test
-
-
-2004-08-28(Sat) 08:13:04 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : support access to instance variable
-
- * test/test_class.rb : add test of instance variable
-
- * benchmark/bm_block.rb : added
-
-
-2004-08-28(Sat) 07:48:43 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_block.rb : fix block parameter name
-
-
-2004-08-28(Sat) 07:27:52 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c, insns.def : support method call with block
- and yield and add some functions
-
- * compile.c, insns.def : support dynavars accessor
-
- * test/test_block.rb : added
-
- * vm.c : fix block parameter stack dump
-
-
-2004-08-27(Fri) 23:56:47 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c(iseq_compile) : remove parameter iseqtype
- (this information can access via self)
-
-2004-08-27(Fri) 17:13:35 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_bin.rb : add test(absolute path constant)
-
- * yarvcore.h, compile.c(iseq_compile) : change parameter
-
- * insns.def(classdef) : fix bug
-
-
-2004-08-27(Fri) 04:53:13 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : support setconstant, getconstant, classdef,
- moduledef
-
- * vm.h : fix debug levels and so on
-
- * vm.h : foo_WORD -> foo_WC
-
- * test/test_class.rb : added
-
-
-2004-08-25(Wed) 17:51:50 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix getconstant/setconstant/classdef
-
-
-2004-08-25(Wed) 14:27:10 +0900 Koichi Sasada <ko1@atdot.net>
-
- * debug.[ch] : added
-
- * compile.c, disasm.c : use debug interface
-
- * compile.c : support some nodes
-
- * compile.c, rb/insns2vm.rb : remove TS_CPATH
-
- * insns.def : modify classdef/moduledef/singletonclassdef
- and add popcref
-
- * and others...
-
-
-2004-08-18(Wed) 20:16:45 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix case/when statement with empty else clause
-
- * insns.def : enable compile
-
- * yarvcore.h : add class search path scheme
-
- * test/test_syn.rb : add switch/case test case
-
- * tmpl/yarvarch.ja : update documents
-
-
-2004-05-22(Sat) 01:30:44 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvutil.rb : add eval_in_wrap
-
- * test/test_*.rb : change to use eval_in_wrap
-
-
-2004-05-20(Thu) 02:50:32 +0900 Koichi Sasada <ko1@atdot.net>
-
- * support global variables
-
- * benchmark/bm_*.rb : add some benchmarks
-
- * compile.c : support NODE_ATTRASGN
-
- * compile.c : add debugi(...)
-
-
-2004-05-19(Wed) 23:19:38 +0900 Koichi Sasada <ko1@atdot.net>
-
- * test/test_method.rb : added
-
-
-2004-05-19(Wed) 22:56:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : fix typo
-
- * benchmark/run.rb : sort benchmark order by filename
-
- * extconf.rb : use --enable/disable-xxx
-
- * version.h : ditto(don't touch to change yarv options)
-
-
-2004-05-19(Wed) 21:18:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * yarvutil.rb : added
-
- * test.rb, test/*, benchmark/run.rb : use yarvutil.rb
-
- * version.h : USE_OPTIMIZED_REGEXP_MATCH added
-
- * yarvcore.h : add idEqTilde
-
- * yarvcore.c(yarvcore_parse, yarvcore_eval) : require file and line
- parameter
-
- * test/test_bin.rb : add regexp test
-
- * benchmark/bm_regexp.rb : added
-
-
-2004-05-19(Wed) 13:57:31 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : add compile_dstr(self, node)
-
- * compile.c : support NODE_MATCH2, NODE_MATCH3, NODE_DXSTR
-
- * insns.def : add toregexp
-
-
-2004-05-18(Tue) 10:12:20 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_XDSTR
-
- * test/test_bin.rb : add test for above change
-
-
-2004-05-18(Tue) 09:46:33 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def(send) : store regs before call_cfunc
-
-
-2004-05-18(Tue) 08:55:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : support NODE_DSTR, NODE_EVSTR
-
- * compile.c : support NODE_XSTR
-
- * insns.def : add tostring operation
-
- * rb/makedocs.rb : fix directory path
-
- * depend : add tbench rule
-
- * yarvcore.h : add 'exten ID idBackquote'
-
-
-2004-05-18(Tue) 00:09:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h : add USE_OPTIMIZED_BASIC_OPERATION
-
- * yarvcore.h(struct thread_object) : add 'VALUE stat_insn_usage'
-
-
-2004-05-17(Mon) 11:28:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * version.h, insns.def, yarvcore.c : add FAKE_INLINE_METHOD_CACHE
-
-
-2004-05-17(Mon) 09:05:53 +0900 Koichi Sasada <ko1@atdot.net>
-
- * compile.c : fix generating opt_* insn process
-
-
-2004-05-17(Mon) 08:58:49 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/(bm_tarai.rb, bm_fib.rb) : added
-
-
-2004-05-17(Mon) 08:20:12 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/(bm_tak.rb, bm_reccount.rb) : added
-
- * insns.def : test method cache(incomplete)
-
- * insns.def : add expandarray insn
-
- * yarvcore.c(iseq_init) : add parameter 'parent'
-
-
-2004-05-17(Mon) 01:49:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * benchmark/run.rb, bm_factorial.rb, bm_whileloop.rb : added
-
- * insns.def(send) : set id to ruby_frame->orig_func
-
- * check behavior on mswin32 and cygwin
-
- * insns.def(send) : check stack overflow
-
-
-2004-05-16(Sun) 08:00:55 +0900 Koichi Sasada <ko1@atdot.net>
-
- * change frame structure(debugging)
-
-
-2004-05-14(Fri) 15:06:02 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns2vm.rb : support file name arguments
-
-
-2004-05-14(Fri) 04:33:09 +0900 Koichi Sasada <ko1@atdot.net>
-
- * insns.def : support (easy) constant
-
-
-2004-05-12(Wed) 01:51:48 +0900 Koichi Sasada <ko1@atdot.net>
-
- * rb/insns2vm.b : set directory prefix
-
- * disasm.c : fix bug
-
-
-2004-05-12(Wed) 00:00:17 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.h, compiler.h, version.h : move *DEBUG defs to version.h
-
-
-2004-05-11(Tue) 23:00:11 +0900 Koichi Sasada <ko1@atdot.net>
-
- * vm.h, version.h, yarvcore.h : move gcc ver check to version.h
- and include version.h from yarvcore.h
-
-
-2004-05-11(Tue) 19:16:26 +0900 Koichi Sasada <ko1@atdot.net>
-
- * 0.0.0.d : imported
-
-
-Local variables:
-add-log-time-format: (lambda ()
- (let* ((time (current-time))
- (diff (+ (cadr time) 32400))
- (lo (% diff 65536))
- (hi (+ (car time) (/ diff 65536))))
- (format-time-string "%Y-%m-%d(%a) %H:%M:%S +900" (list hi lo) t)))
-indent-tabs-mode: t
-tab-width: 8
-end:
diff --git a/doc/NEWS b/doc/NEWS
deleted file mode 100644
index d2a5a23210..0000000000
--- a/doc/NEWS
+++ /dev/null
@@ -1,207 +0,0 @@
-Changes for 1.9
-
-Incompatible (Severe)
-
- * New syntax and semantics
- o Block arguments are always local
- o Block arguments
- o New semantics for block arguments
- o Block local variables
- * String
- o No longer an Enumerable
- o ?c semantics
- o "One-char-wide" semantics for String#[] and String#[]= [Ruby2]
- o Encoding-awareness
- * IO operations
- o IO#getc
-
-Incompatible (Trivial)
-
- * New syntax and semantics
- o Method used for splat arguments: #to_splat
- o defined? and local variables
- * Kernel and Object
- o Kernel#require
- * Class and Module
- o Class variables behavior
- o Module#attr is an alias of attr_reader
- o Module#instance_methods, #private_instance_methods, #public_instance_methods
- o Extra subclassing check when binding UnboundMethods
- * Exceptions
- o Equality of exceptions
- o SystemStackError
- o SecurityError
- o Removed Exception#to_str [Ruby2]
- * Array
- o Array#nitems
- o Array#[m,n] = nil places nil in the array.
- * Hash
- o Hash#to_s is equivalent to Hash#inspect
- o Semantics for Hash#each and Hash#each_pair
- o Hash#select
- * Integer
- o Integer(nil) raises TypeError
- * Struct
- o Struct#inspect
- * File and Dir operations
- o #to_path in File.path, File.chmod, File.lchmod, File.chown, File.lchown, File.utime, File.unlink... [Ruby2]
- o Dir.[], Dir.glob
- o Dir.exist?
- * IO operations
- o Non-blocking IO
- o IO#getbyte, IO#readbyte, StringIO#getbyte, StringIO#readbyte
- o Kernel#open takes encoding specified
- o IO#initialize now accepts an IO argument
- o StringIO#readpartial
- o IO#lines
- o IO#bytes
- o IO.try_convert
- o Limit input in IO#gets, IO#readline, IO#readlines, IO#each_line, IO#lines, IO.foreach, IO.readlines, StringIO#gets, StringIO#readline, StringIO#each, StringIO#readlines
- o IO#ungetc, StringIO#ungetc
- o IO#internal_encoding, IO#external_encoding, IO#set_encoding
- o IO.pipe takes encoding option
- * Time
- o New format in Time#to_s
- o Timezone information preserved on Marshal.dump/load
- * Symbols: restriction on literal symbols
- * $SAFE and bound methods
- * Deprecation
- o VERSION and friends
- o Kernel.to_a
- o Kernel#getc
- o Object#type
- o Hash#index
- o ENV.index
- o Symbol#to_int
- o Removed Array and Hash #indices, #indexes
- o libraries: base64, mailread, getopts, parsearg, soap, wsdl
-
-Compatible
-
- * New syntax and semantics
- o New literal hash syntax
- o New syntax for lambdas
- o .() and calling Procs without #call/#[]
- o Mandatory arguments after optional arguments allowed
- o Multiple splats allowed
- o Arguments to #[]
- o printf-style formatted strings (%)
- o Newlines allowed before ternary colon
- * Kernel and Object
- o BasicObject
- o #instance_exec
- o Object#=~
- o Object#tap
- o Kernel#instance_variable_defined?
- o Kernel#define_singleton_method
- o Kernel#singleton_methods, Kernel#methods
- * Class and Module
- o Module#const_defined?, #const_get and #method_defined?
- o Module#class_variable_defined?
- o #class_variable_{set,get}
- o Class of singleton classes
- o #module_exec
- * Binding#eval
- * Blocks and Procs
- o Arity of blocks without arguments
- o proc is now a synonym of Proc.new
- * Blocks and Procs
- o Proc#yield
- o Passing blocks to #[]
- o Proc#lambda?
- * Enumerable and Enumerator
- o Enumerable methods called without a block
- o Enumerable#cycle
- o Enumerable#each_with_index
- o Enumerable#first(n)
- o Enumerable#group_by
- o Enumerable#find_index
- o Enumerable#take
- o Enumerable#drop
- o Enumerable#take_while
- o Enumerable#drop_while
- o Enumerator#each
- o Enumerable#inject (#reduce) without a block
- o Enumerable#count
- o Enumerable#reduce
- o Enumerator#with_index
- o Enumerable##min_by, #max_by
- o Enumerable#zip
- o Enumerable#minmax and minmax_by
- o Enumerator#rewind
- o Enumerator#next
- * Regexp#match, String#match
- o Regexp#match, String#match
- * Fiber: coroutines/micro-threads
- * Array
- o Block argument to Array#index, Array#rindex [Ruby2]
- o Array#combination
- o Array#permutation
- o Array#product
- o Array#pop, Array#shift
- o Array#to_s is equivalent to Array#inspect
- o Array.try_convert
- * Hash
- o preserving item insertion order
- o Hash#_compare_by_identity and Hash#compare_by_identity?
- o Hash.try_convert
- * Integer
- o Integer#odd?, #even?
- o Integer#pred
- * Method
- o Method#receiver
- o Method#name
- o Method#owner
- * Numeric
- o Numeric#upto, #downto, #times, #step
- o Numeric#scalar?, Complex#scalar?
- o Numeric#div
- o Numeric#fdiv
- * Range
- o Range#cover?
- o Range#include?
- o Range#min, Range#max
- * Regexp
- o Regexp#=== matches symbols
- o Regexp.try_convert
- * String
- o String#clear
- o String#each_char
- o String#ord
- o String#partition, #rpartition
- o String#lines
- o String#bytes
- o String#encoding
- o String#force_encoding
- o String#start_with?, #end_with?
- o String#unpack with a block
- o String#hash
- o String#upto
- o String.try_convert
- o String.encoding, String#force_encoding, String#encode
- * Symbol
- o Zero-length symbols allowed
- o Symbol#=== matches strings
- o Symbol#intern
- o Symbol#encoding
- o Symbol methods similar to those in String
- * Math
- o Math#log and Math#log2
- * File and Dir operations
- o New methods
- * Process
- o Process.setrlimit
- o Process.daemon
- o Process.exec
- * Misc. new methods
- o public_send
- o GC.stress, GC.stress=
- o Method#hash, Proc#hash
- o __method__ and __callee__
- o Symbol#to_proc
-
-* Implementation
- * Memory Diet
- * Object Compaction - Object, Array, String, Hash, Struct, Class, Module
- * st_table compaction (inlining small tables)
- * YARV
diff --git a/doc/NEWS-1.8.0 b/doc/NEWS-1.8.0
new file mode 100644
index 0000000000..b4445fa59f
--- /dev/null
+++ b/doc/NEWS-1.8.0
@@ -0,0 +1,837 @@
+= command line options
+
+: -W option
+
+ new option to specify warning level. -W0 to shut up warnings, -W1 for normal level,
+ -W2 for verbose level. -w equals to -W2.
+
+= language syntax
+
+: arbitrary delimited string array
+
+ %W(...) notation, word list literal like %w(...) with the
+ exception that #{} interpolation is allowed.
+
+: arbitrary delimited symbol literl
+
+ :"foo", :"foo#{bar}", etc.
+
+: expression interpolation in strings
+
+ Now arbitrary statements are allowed inside #{} interpolation
+ without escapes. In other hand, they can no longer access to
+ variables defined in eval.
+
+: negative number literals
+
+ Digits preceded minus sign is a literal integer.
+
+: array expansion
+
+ Fixed with the following behavior:
+
+ a = *[1]
+ p a #=> [1]
+
+ Now 1-element array in rhs is expanded properly.
+
+ a = *[1]
+ p a #=> 1
+
+: break and next
+
+ Extended to take an optional expression, which is used as a value
+ for termination.
+
+: direct assignment to Foo::Bar is allowed
+
+ also, you can define "class Foo::Bar; end".
+
+= language core
+
+: $stdin, $stdout, $stderr
+
+ can be assignable again. the original stdio are preserved as STDIN,
+ STDOUT, STDERR.
+
+: $VERBOSE now has 3 levels
+
+ nil - silence, false - medium (default), true - verbose
+
+: allocation framework
+
+ any instance of class can be allocated by class.allocate,
+ (except for a few classes).
+
+: comparison of exception classes in a rescue clause
+
+ changed to use Module#=== for comparing $! with the exception
+ class specified in each rescue clause.
+
+ as the previous behavior was to use kind_of?, the effect is limited
+ to the SystemCallError case. SystemCallError.=== has been newly
+ defined to return true when the two have the same errno. With this
+ change, SystemCallError's with the same errno, such as Errno::EAGAIN
+ and Errno::EWOULDBLOCK, can both be rescued by listing just one of
+ them.
+
+: constants lookup
+
+ improved at the performance of searching by using an internal hash
+ table.
+
+ calls const_missing method of the class/module, if constant is not
+ found in the look up path.
+
+: expression parenthesis in the first argument
+
+ altered to get the following code (note the space after p):
+
+ p ("xx"*2).to_i
+
+ Interpreted as:
+
+ p (("xx"*2).to_i)
+
+ Instead of:
+
+ (p("xx"*2)).to_i
+
+: implicit comparison in conditional expressions
+
+ Obsoleted except when it is used in -e.
+
+ : between Range and $.
+ Use explicit comparison instead.
+
+ : between Regexp and $_
+ Use the unary method ~/re/ instead.
+
+: to_str
+
+ added to get objects which define to_str() treated as String's.
+
+ now almost all the built-in methods try each argument with to_str()
+ when they expect it to be a String.
+
+ foo = Object.new
+ class <<foo
+ def to_str
+ "foo"
+ end
+ end
+ p File.open(foo)
+ => -:7:in `open': wrong argument type Object (expected String) (TypeError)
+ ruby 1.6.4 (2001-04-19) [i586-linux]
+ => -:7:in `open': No such file or directory - "foo" (Errno::ENOENT)
+ ruby 1.7.0 (2001-05-02) [i586-linux]
+
+: multiple assignment behavior
+
+ Fixed so that "*a = nil" results in "a == []".
+
+= changes in core class library
+
+: open
+
+ Extended so that when the third argument is permission flags it
+ calls open(2) instead of fopen(3).
+
+: sprintf
+
+ new format specifier "%p" is available.
+
+: lambda and proc
+
+ Proc object returns from these methods has the following attributes:
+
+ * strict argument number check
+ * break and return terminates the proc execution.
+
+: warn(message)
+
+ a method to give warnings.
+
+: abort()
+
+ takes optional terminate message argument.
+
+: Object#initialize_copy
+
+ copy constructor for clone and dup.
+
+: Object#instance_variable_set, Object#instance_variable_get
+
+ added.
+
+: Object#singleton_method_removed
+: Object#singleton_method_undefined
+
+ Added.
+
+: Array#transpose
+
+ added.
+
+: Array#fetch(index [, default])
+
+ Added. If a default value isn't given, raises index error if index
+ is out of range.
+
+: Array#insert(n, other, ...)
+
+ Added. [ruby-talk:14289]
+
+ This is much the same as (({ary[n,0] = [other,...]})) except
+ returing self.
+
+ ary = [0,1,2,3]
+ ary[2, 0] = [4, 5, 6]
+ p ary
+
+ ary = [0,1,2,3]
+ ary.insert(2, 4, 5, 6)
+ p ary
+
+: Array#sort!
+
+ Changed to always return self without checking whether the sequence
+ of the elements was modified or not.
+
+ Beware that this behavior is not guaranteed to continue in the
+ future. Do not rely on its return value. [ruby-dev:12506]
+
+: Array#filter
+
+ Previously deprecated, now removed. Use Array#collect!.
+
+: Array#pack, String#unpack
+
+ Allows comment in template strings.
+
+: Array#pack, String#unpack
+
+ New templates 'q' and 'Q' for 64bit integer (signed and unsigned respectively).
+
+: Array#new
+
+ Now takes block to fill initial values. E.g.
+
+ Array.new(10) { |i| i + 1 }
+ => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+
+: Array#fill
+
+ Takes block to get the values to fill.
+
+: Array#fetch
+
+ Takes block to get the default value.
+
+: Array#zip
+
+ added.
+
+: Hash#update
+
+ Takes block to resolve key conflict.
+
+: Hash#merge and Hash#merge!
+
+ update hash. Hash#merge! is a synonym of Hash#update.
+
+: String#split
+
+ if "sep" argument is a string, regular expression meta characters
+ are escaped internally.
+
+: String#rstrip
+
+ chop off NULs at the end of strings.
+
+: String#to_i
+
+ Now accepts optional base argument.
+
+ "101".to_i(10) => 101
+ "101".to_i(2) => 5
+ "101".to_i(8) => 65
+ "101".to_i(16) => 257
+
+ A base argument of 0 guesses at the base.
+
+ "101".to_i(0) => 101
+ "0b101".to_i(0) => 5
+ "0101".to_i(0) => 65
+ "0x101".to_i(0) => 257
+
+: String#[regexp, nth]
+
+ Extended to accepts optional second argument.
+
+ It tries match between self and REGEXP, then returns the
+ content of the NTH regexp register.
+
+: String#casecmp
+
+ Added. This is a case insensitive version of String#<=>.
+
+: String#chomp
+
+ If $/ == "\n", chops off last newlines (any of \n, \r, \r\n).
+
+: String#eql?
+
+ Changed to be always case sensitive.
+
+: String#insert(n, other)
+
+ Added.
+
+ This is much the same as (({str[n, 0] = other})) except returing
+ self.
+
+: String#lstrip, rstrip, lstrip!, rstrip!
+
+ Added. These strip only left or right part of a string.
+
+: String#match
+
+ Added.
+
+: String/Array methods
+
+ Returns an instance of receivers class.
+
+: String.new
+
+ The first argument becomes optional.
+
+: Symbol#intern
+
+ Added.
+
+: Symbol.all_symbols
+
+ Added. [ruby-dev:12921]
+
+: IO
+
+ 64bit off_t support by Janathan Baker.
+
+: IO#read
+: IO#sysread
+
+ takes optinal second argument for read buffer.
+
+: IO::sysopen
+
+ New method to get a raw file descriptor.
+
+: IO#sysseek
+
+ Added.
+
+: IO#fsync
+
+ new method that copies all in-memory parts of a file to disk and
+ waits until the device reports that all parts are on stable storage.
+ Implemented with fsync(2) or equivalent.
+
+: IO.open
+
+ Made public. Can only associate an IO object with a file number
+ like IO.new and IO.for_fd, but can take a block.
+
+: IO.for_fd
+
+ Added as a synonym for IO.new.
+
+: IO.read
+
+ Added. Like IO.readlines, except it returns the entire file as a
+ string. [ruby-talk:9460]
+
+: File#fnmatch, File::Constants::FNM_*
+
+ Added. Refer to the fnmatch(3) manpage for details.
+
+ Localism is FNM_DOTMATCH which has the opposite meaning of the
+ commonly known FNM_PERIOD, which does not exist in Ruby.
+
+ e.g.
+
+ # exclude files matching "*.bak" case-insensitively.
+ files.reject! {|fn| File.fnmatch?("*.bak", fn, File::FNM_CASEFOLD) }
+
+: File.lchmod
+: File.lchown
+
+ Added.
+
+: File.open, IO.open
+
+ File mode can be specified by flags like open(2),
+ e.g. File::open(path, File::CREAT|File::WRONLY).
+
+: Regexp#options
+
+ Added.
+
+: Regexp.last_match(n)
+
+ Extended to take an optional argument.
+
+: MatchData#captures
+
+ added.
+
+: Dir#path
+
+ Added.
+
+: Dir.chdir
+
+ Extended to take a block.
+
+: Dir.glob
+
+ Made to support meta-character escaping by a backslash. Wildcards
+ and spaces may now be escaped using a backslash.
+
+: Dir.open
+
+ Changed to return what the block returns when a block is given, just
+ as File.open does. (It always returned (({nil})) in 1.6 and
+ prior)
+
+: Dir.chdir
+
+ Changed to warn only when invoked from multiple threads or no block
+ is given. [ruby-dev:13823]
+
+ Dir.chdir('foo') {
+ Dir.chdir('bar') { # previously warned
+ puts Dir.pwd
+ }
+ }
+
+: Dir#pos=
+
+ Returns the new position instead of self.
+
+: Dir::glob
+
+ Now accepts optional FNM_* flags via the second argument, whereas
+ Dir::[] doesn't.
+
+ Dir.glob("makefile", File::FNM_CASEFOLD) #=> ['Makefile', 'makefile']
+
+: Class#inherited
+
+ Method is called when Class is inherited by another class.
+
+ class A; end
+ def A.inherited(by)
+ puts "A inherited by #{by.inspect}"
+ end
+ class B < A; end
+
+ Prints out "A inherited by B"
+
+: Module#include?
+
+ Added. [ruby-dev:13941]
+
+: Module#included
+
+ Added. This is a hook called after Module#append_feature.
+
+: Module#method_removed
+: Module#method_undefined
+
+ Added.
+
+: Module.new, Class.new
+
+ Extended to take block.
+
+: Time
+
+ Extended to accept a negative time_t. (Only when the platform
+ supports it)
+
+ p Time.at(-1)
+ => Thu Jan 01 08:59:59 JST 1970
+
+: Time#to_a
+: Time#zone
+
+ Made to return "UTC" under gmtime. It used to return a platform
+ dependent value, typically "GMT", in 1.6 and prior.
+
+: Marshal to use marshal_dump and marshal_load
+
+ if a dumping object responds to 'marshal_dump', Marshal.dump calls
+ it, and dumps object returned. Marshal.load allocates a new instance
+ using "allocate", then calls its "marshal_load" with dumped data.
+ Marshal format version is now 4.8 (was 4.6 in 1.6.8).
+
+: Marshal
+
+ Fixed not to dump anonymous classes/modules.
+
+ Fixed with loading modules.
+
+: Thread#group
+
+ new method to get belonging ThreadGroup.
+
+: Thread#terminate
+
+ synonym of Thread#exit
+
+: Thread#join
+
+ Optional argument limits maximum time to wait the thread in second.
+ And returns nil if timed out.
+
+: ThreagGroup#enclose
+
+ prohibits thread movement from/to enclosed groups.
+
+: Range#step([step=1])
+
+ Added.
+
+: SystemCallError
+
+ SystemCallError's "===" match (used in rescue also) is now based on its errno.
+
+: Interrupt
+
+ Made a subclass of SignalException. (It was a subclass of
+ Exception in 1.6 and prior)
+
+: NameError and NoMethodError
+
+ Moved and now NoMethodError < NameError < StandardError.
+
+: NoMethodError
+
+ Added. [ruby-dev:12763]
+
+: NotImplementError
+
+ Finally obsoleted. Use NotImplementedError.
+
+: SystemCallError.===
+
+ Added. (See the "Comparison of exception classes in a rescue clause"
+ paragraph above) [ruby-dev:12670]
+
+: SystemExit#status
+
+ Added.
+
+: Proc#==
+
+ Added.
+
+: Method#==
+
+ Added.
+
+: UnboundMethod is no longer subclass of Method
+
+ class hierarchy changed.
+
+: Enumerable#all?
+: Enumerable#any?
+: Enumerable#inject
+: Enumerable#sort_by
+
+ Added.
+
+: Math.acos(x)
+: Math.asin(x)
+: Math.atan(x)
+: Math.cosh(x)
+: Math.hypot(x,y)
+: Math.sinh(x)
+: Math.tanh(x)
+
+ Added.
+
+: Process.abort
+: Process.exit
+
+ synonym of Kernel#abort, and Kernel#exit respectively.
+
+: Process::detach(pid)
+
+ new method to detach child process. child process will be "wait"ed
+ automagically.
+
+: Process.times
+
+ Moved from Time.times. (Time.times still remains but emits a
+ warning)
+
+: Process.waitall
+
+ Added.
+
+: Process::Status
+
+ Added. (({$?})) is now an instance of this class.
+
+: Process::UID, Process::GID, Process::Sys,
+
+ Added.
+
+: Signal
+
+ Added. This module has module functions Signal.trap and Signal.list.
+
+= changes in bundled libraries
+
+: lib/cgi.rb
+
+ cgi[name] returns CGI::QueryExtension::Value that wraps string
+ value, no longer array.
+
+: lib/timeout
+
+ timeout "function" wrapped in Timeout module.
+
+: TCPServer#accept, UNIXServer#accept, Socket#accept
+
+ New methods to return an accepted socket fd.
+
+: Date and DateTime
+
+ lib/date.rb now provides both Date and DateTime.
+
+ Some methods have been renamed. But the old names are still alive.
+
+ Some new methods have been added (Date::parse, Date#strftime, etc.).
+
+ Date#mjd now returns the chronological modified Julian day number.
+
+ All facilities about tjd have been removed.
+
+: Curses
+
+ Updated. New methods and constants for using the mouse, character
+ attributes, colors and key codes have been added.
+
+: Net::HTTP
+
+ New version of Net::HTTP has introduced seriously incompatible
+ changes. For details, see document embedded in net/http.rb itself.
+
+: Socket.pack_sockaddr_in, Socket.unpack_sockaddr_in
+
+ Added. Utility for direct Socket access.
+
+: Socket.pack_sockaddr_un, Socket.unpack_sockaddr_un
+
+ Added. Utility for direct Socket access.
+
+: TCPServer#listen, UNIXServer#listen
+
+ Added.
+
+: TCPSocket.new
+: TCPSocket.open
+
+ Extended to take an address and a port number for the local side in
+ optional 3rd and 4th arguments.
+
+= newly bundled library
+
+: ext/bigdecimal
+
+ variable precision decimal number
+
+: ext/dl
+
+ an interface to the dynamic linker.
+
+: ext/enumerator
+
+ a helper module for the Enumerable interface.
+
+: ext/io/wait
+
+ IO wait methods.
+
+: ext/iconv
+
+ wrapper library of (({iconv})).
+
+: ext/openssl
+
+ OpenSSL for Ruby
+
+: ext/racc/cparse
+
+ Racc runtime library in C. (Racc is a parser generator for ruby)
+
+: ext/stringio
+
+ Pseudo (({IO})) class from/to (({String})).
+
+: ext/strscan
+
+ Fast string scanner library.
+
+: ext/syck
+
+ fast YAML parser.
+
+: lib/abbrev
+
+ creates an abbreviation table from a list
+
+: lib/benchmark
+
+ Ruby scripts benchmarker
+
+: lib/cgi/session/pstore
+
+ cgi/session back-end using pstore
+
+: lib/csv
+
+ reads/writes CSV files.
+
+: lib/date/format
+
+ strftime for Date class
+
+: lib/drb
+
+ dRuby or distributed Ruby
+
+: lib/fileutils
+
+ file utility library.
+
+: lib/generator
+
+ converts an internal iterator to an external iterator
+
+: lib/gserver
+
+ generic server used by xmlrpc
+
+: lib/ipaddr
+
+ manipulates IP address.
+
+: lib/multi-tk
+
+ to allow safe Tk, etc.
+
+: lib/open-uri
+
+ easy-to-use wrapper for net/http and net/ftp
+
+: lib/optparse
+
+ command line options utility library
+
+: lib/pathname
+
+ handles pathname in OO manner.
+
+: lib/pp
+
+ prettyprinter for Ruby objects
+
+: lib/prettyprint
+
+ implements prettyprint algorithm.
+
+: lib/profiler
+
+ library to implement -r "profile"
+
+: lib/racc/parser
+
+ RACC parser generator runtime in Ruby.
+
+: lib/scanf
+
+ scan string and retrieve object with format
+
+: lib/set
+
+ Set class
+
+: lib/runit
+
+ RubyUnit compatible layer for test/unit
+
+: lib/test/unit
+
+ unit testing framework for Ruby
+
+: lib/tmpdir
+
+ get temporary directory path.
+
+: lib/tsort
+
+ topological sorting library.
+
+: lib/rexml
+
+ REXML XML library
+
+: lib/webrick
+
+ generic internet server kit
+
+: lib/xmlrpc
+
+ simple RPC via XML
+
+: lib/un
+
+ used like 'ruby -run -e cp -- -p foo bar'. neat, isn't it?
+
+: lib/win32/registry
+
+ win32/registry is registry accessor
+
+: lib/yaml
+
+ YAML Ain't Mark-up Language
+
+= removed libraries
+
+: lib/ftplib
+
+ use net/ftp instead.
+
+: lib/telnet
+
+ use net/telnet instead.
+
+= new port
+
+: WindowsCE port
+: Win32 BCC
+
+= interpreter implementation
+
+: garbage collector
+
+ faster, but uses more memory for the worst case.
+
+: string concatenation
+
+ faster by avoiding too frequent realloc(3).
diff --git a/enc/Makefile.in b/enc/Makefile.in
deleted file mode 100644
index 948cd26c2e..0000000000
--- a/enc/Makefile.in
+++ /dev/null
@@ -1,46 +0,0 @@
-encsrcdir = @srcdir@
-topdir = .
-libdir = @libdir@
-top_srcdir = $(encsrcdir:/enc=)
-srcdir = $(top_srcdir)
-arch = @arch@
-EXTOUT = @EXTOUT@
-hdrdir = $(srcdir)/include
-arch_hdrdir = $(EXTOUT)/include/$(arch)
-ENCSODIR = $(EXTOUT)/$(arch)/enc
-TRANSSODIR = $(ENCSODIR)/trans
-DLEXT = @DLEXT@
-OBJEXT = @OBJEXT@
-
-BUILTIN_ENCS = ascii.c \
- euc_jp.c sjis.c \
- unicode.c utf8.c
-
-RUBY_SO_NAME = @RUBY_SO_NAME@
-LIBRUBY = @LIBRUBY@
-LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
-LIBRUBYARG_STATIC = $(LIBRUBYARG_SHARED)
-
-empty =
-CC = @CC@
-OUTFLAG = @OUTFLAG@$(empty)
-COUTFLAG = @COUTFLAG@$(empty)
-CFLAGS = $(CCDLFLAGS) @CFLAGS@ @ARCH_FLAG@
-CCDLFLAGS = @CCDLFLAGS@
-INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(top_srcdir)
-DEFS = @DEFS@
-CPPFLAGS = @CPPFLAGS@ -DONIG_ENC_REGISTER=rb_enc_register
-LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
-XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
-LIBS = @LIBRUBYARG@ @LIBS@ $(EXTLIBS)
-LDSHARED = @LDSHARED@
-DLDFLAGS = @DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
-
-RM = @RM@
-
-all:
-
-clean:
-
-distclean: clean
- $(RM) enc.mk
diff --git a/enc/ascii.c b/enc/ascii.c
deleted file mode 100644
index f9a619d700..0000000000
--- a/enc/ascii.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/**********************************************************************
- ascii.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-OnigEncodingDefine(ascii, ASCII) = {
- onigenc_single_byte_mbc_enc_len,
- "ASCII-8BIT",/* name */
- 1, /* max byte length */
- 1, /* min byte length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- onigenc_ascii_mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- onigenc_ascii_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/depend b/enc/depend
deleted file mode 100644
index 099d827ed5..0000000000
--- a/enc/depend
+++ /dev/null
@@ -1,63 +0,0 @@
-% deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"])
-% encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS
-% encs.each {|e| e.chomp!(".c")}
-% alphanumeric_order = proc {|e| e.split(/(\d+)/).map {|n| Integer(n) rescue n}}
-% encs = encs.sort_by(&alphanumeric_order)
-% trans = Dir.open($srcdir+"/trans") {|d| d.select {|e| e.chomp!('.c')}}
-% trans = trans.sort_by(&alphanumeric_order)
-% trans.map! {|e| "trans/#{e}"}
-% dependencies = encs + trans
-
-VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(srcdir) $(encsrcdir)].join(CONFIG["PATH_SEPARATOR"])%>
-LIBPATH = <%=libpathflag($DEFLIBPATH)%>
-
-ENCOBJS = <%=encs.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if encs.size>1%>
-ENCDEFS = <%=encs.map {|e|"enc/#{e}.def"}.join(" \\\n\t ") if deffile%><%="\n" if encs.size>1%>
-ENCSOS = <%=encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>
-
-TRANSOBJS = <%=trans.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
-TRANSDEFS = <%=trans.map {|e|"enc/#{e}.def"}.join(" \\\n\t ") if deffile%><%="\n" if trans.size>1%>
-TRANSSOS = <%=trans.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>
-
-all: $(ENCSOS) $(TRANSSOS)
-
-% COMPILE_RULES.each do |rule|
-<%= rule % %w[c $(OBJEXT)] %>
- <%=COMPILE_C%>
-
-% end
-% unless encs.empty? or trans.empty?
-
-% unless encs.empty?
-$(ENCOBJS): regenc.h oniguruma.h config.h defines.h
-% end
-% unless trans.empty?
-$(TRANSOBJS): ruby.h intern.h config.h defines.h transcode_data.h
-% end
-
-% end
-% link_so = LINK_SO.gsub(/\n/, "\n\t")
-% link_so.gsub!(/(-(?:implib|pdb):\S+)-\$\(arch\)\./, '\1.')
-% dependencies.each do |e|
-% obj = "enc/#{e}.$(OBJEXT)"
-% df = ("enc/#{e}.def" if deffile)
-$(ENCSODIR)/<%=e%>.$(DLEXT): <%=obj%>
-% if df
- echo EXPORTS > <%=df%>
- echo <%=EXPORT_PREFIX%>Init_<%=File.basename(e)%> >> <%=df%>
-% end
- <%=link_so.sub(/\$\(OBJS\)/) {obj}.sub(/\$\(DEFFILE\)/) {df}.gsub(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}%>
-
-% end
-% dependencies.each do |e|
-enc/<%=e%>.$(OBJEXT): $(srcdir)/enc/<%=e%>.c
- <%=COMPILE_C.sub(/\$\(<(?:.*)\)/) {"$(srcdir)/enc/#{e}.c"}%>
-% end
-
-clean:
- $(RM) $(ENCSOS)
- $(RM) $(ENCDEFS)
- $(RM) $(ENCOBJS)
- $(RM) $(TRANSSOS)
- $(RM) $(TRANSDEFS)
- $(RM) $(TRANSOBJS)
diff --git a/enc/euc_jp.c b/enc/euc_jp.c
deleted file mode 100644
index eca698c271..0000000000
--- a/enc/euc_jp.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/**********************************************************************
- euc_jp.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-#define eucjp_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1)
-
-static const int EncLen_EUCJP[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1
-};
-
-typedef enum { FAILURE = -2, ACCEPT = -1, S0 = 0, S1, S2 } state_t;
-#define A ACCEPT
-#define F FAILURE
-static const signed char trans[][0x100] = {
- { /* S0 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 1 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 2 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 3 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 4 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 5 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 6 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 7 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, 1, 2,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* d */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* e */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, F
- },
- { /* S1 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* b */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* c */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* d */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* e */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* f */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, F
- },
- { /* S2 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* d */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* e */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, F
- },
-
-};
-#undef A
-#undef F
-
-static int
-mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc)
-{
- int firstbyte = *p++;
- state_t s;
- s = trans[0][firstbyte];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_EUCJP[firstbyte]-1);
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_EUCJP[firstbyte]-2);
- s = trans[s][*p++];
- return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(3) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-}
-
-static OnigCodePoint
-mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- int c, i, len;
- OnigCodePoint n;
-
- len = enc_len(ONIG_ENCODING_EUC_JP, p, end);
- n = (OnigCodePoint )*p++;
- if (len == 1) return n;
-
- for (i = 1; i < len; i++) {
- if (p >= end) break;
- c = *p++;
- n <<= 8; n += c;
- }
- return n;
-}
-
-static int
-code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
-{
- if (ONIGENC_IS_CODE_ASCII(code)) return 1;
- else if (code > 0xffffff) return 0;
- else if ((code & 0xff0000) >= 0x800000) return 3;
- else if ((code & 0xff00) >= 0x8000) return 2;
- else return 0;
-}
-
-#if 0
-static int
-code_to_mbc_first(OnigCodePoint code)
-{
- int first;
-
- if ((code & 0xff0000) != 0) {
- first = (code >> 16) & 0xff;
- }
- else if ((code & 0xff00) != 0) {
- first = (code >> 8) & 0xff;
- }
- else {
- return (int )code;
- }
- return first;
-}
-#endif
-
-static int
-code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
-{
- UChar *p = buf;
-
- if ((code & 0xff0000) != 0) *p++ = (UChar )(((code >> 16) & 0xff));
- if ((code & 0xff00) != 0) *p++ = (UChar )(((code >> 8) & 0xff));
- *p++ = (UChar )(code & 0xff);
-
-#if 1
- if (enc_len(ONIG_ENCODING_EUC_JP, buf, p) != (p - buf))
- return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
-#endif
- return p - buf;
-}
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- int len;
- const UChar* p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
- *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
- }
- else {
- int i;
-
- len = enc_len(ONIG_ENCODING_EUC_JP, p, end);
- for (i = 0; i < len; i++) {
- *lower++ = *p++;
- }
- (*pp) += len;
- return len; /* return byte length of converted char to lower */
- }
-}
-
-static UChar*
-left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
-{
- /* In this encoding
- mb-trail bytes doesn't mix with single bytes.
- */
- const UChar *p;
- int len;
-
- if (s <= start) return (UChar* )s;
- p = s;
-
- while (!eucjp_islead(*p) && p > start) p--;
- len = enc_len(ONIG_ENCODING_EUC_JP, p, s);
- if (p + len > s) return (UChar* )p;
- p += len;
- return (UChar* )(p + ((s - p) & ~1));
-}
-
-static int
-is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc)
-{
- const UChar c = *s;
- if (c <= 0x7e || c == 0x8e || c == 0x8f)
- return TRUE;
- else
- return FALSE;
-}
-
-
-static int PropertyInited = 0;
-static const OnigCodePoint** PropertyList;
-static int PropertyListNum;
-static int PropertyListSize;
-static hash_table_type* PropertyNameTable;
-
-static const OnigCodePoint CR_Hiragana[] = {
- 1,
- 0xa4a1, 0xa4f3
-}; /* CR_Hiragana */
-
-static const OnigCodePoint CR_Katakana[] = {
- 3,
- 0xa5a1, 0xa5f6,
- 0xaaa6, 0xaaaf,
- 0xaab1, 0xaadd
-}; /* CR_Katakana */
-
-static int
-init_property_list(void)
-{
- int r;
-
- PROPERTY_LIST_ADD_PROP("Hiragana", CR_Hiragana);
- PROPERTY_LIST_ADD_PROP("Katakana", CR_Katakana);
- PropertyInited = 1;
-
- end:
- return r;
-}
-
-static int
-property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
-{
- int ctype;
-
- PROPERTY_LIST_INIT_CHECK;
-
- if (onig_st_lookup_strend(PropertyNameTable, p, end, (void*)&ctype) == 0) {
- return onigenc_minimum_property_name_to_ctype(enc, p, end);
- }
-
- return ctype;
-}
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (ctype <= ONIGENC_MAX_STD_CTYPE) {
- if (code < 128)
- return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
- else {
- if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
- return (code_to_mbclen(code, enc) > 1 ? TRUE : FALSE);
- }
- }
- }
- else {
- PROPERTY_LIST_INIT_CHECK;
-
- ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
- if (ctype >= (unsigned int )PropertyListNum)
- return ONIGENC_ERR_TYPE_BUG;
-
- return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
- }
-
- return FALSE;
-}
-
-static int
-get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
- const OnigCodePoint* ranges[], OnigEncoding enc)
-{
- if (ctype <= ONIGENC_MAX_STD_CTYPE) {
- return ONIG_NO_SUPPORT_CONFIG;
- }
- else {
- *sb_out = 0x80;
-
- PROPERTY_LIST_INIT_CHECK;
-
- ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
- if (ctype >= PropertyListNum)
- return ONIGENC_ERR_TYPE_BUG;
-
- *ranges = PropertyList[ctype];
- return 0;
- }
-}
-
-
-OnigEncodingDefine(euc_jp, EUC_JP) = {
- mbc_enc_len,
- "EUC-JP", /* name */
- 3, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- mbc_to_code,
- code_to_mbclen,
- code_to_mbc,
- mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- property_name_to_ctype,
- is_code_ctype,
- get_ctype_code_range,
- left_adjust_char_head,
- is_allowed_reverse_match,
- 0
-};
diff --git a/enc/iso_8859_1.c b/enc/iso_8859_1.c
deleted file mode 100644
index 0c85c8befb..0000000000
--- a/enc/iso_8859_1.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/**********************************************************************
- iso8859_1.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_IS_ISO_8859_1_CTYPE(code,ctype) \
- ((EncISO_8859_1_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const unsigned short EncISO_8859_1_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0,
- 0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- if (0x41 <= *p && *p <= 0x5a) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p + 0x20);
- if (*p == 0x53 && end > p + 1
- && (*(p+1) == 0x53 || *(p+1) == 0x73)) { /* SS */
- items[1].byte_len = 2;
- items[1].code_len = 1;
- items[1].code[0] = (OnigCodePoint )0xdf;
- return 2;
- }
- else
- return 1;
- }
- else if (0x61 <= *p && *p <= 0x7a) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p - 0x20);
- if (*p == 0x73 && end > p + 1
- && (*(p+1) == 0x73 || *(p+1) == 0x53)) { /* ss */
- items[1].byte_len = 2;
- items[1].code_len = 1;
- items[1].code[0] = (OnigCodePoint )0xdf;
- return 2;
- }
- else
- return 1;
- }
- else if (0xc0 <= *p && *p <= 0xcf) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p + 0x20);
- return 1;
- }
- else if (0xd0 <= *p && *p <= 0xdf) {
- if (*p == 0xdf) {
- items[0].byte_len = 1;
- items[0].code_len = 2;
- items[0].code[0] = (OnigCodePoint )'s';
- items[0].code[1] = (OnigCodePoint )'s';
-
- items[1].byte_len = 1;
- items[1].code_len = 2;
- items[1].code[0] = (OnigCodePoint )'S';
- items[1].code[1] = (OnigCodePoint )'S';
-
- items[2].byte_len = 1;
- items[2].code_len = 2;
- items[2].code[0] = (OnigCodePoint )'s';
- items[2].code[1] = (OnigCodePoint )'S';
-
- items[3].byte_len = 1;
- items[3].code_len = 2;
- items[3].code[0] = (OnigCodePoint )'S';
- items[3].code[1] = (OnigCodePoint )'s';
-
- return 4;
- }
- else if (*p != 0xd7) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p + 0x20);
- return 1;
- }
- }
- else if (0xe0 <= *p && *p <= 0xef) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p - 0x20);
- return 1;
- }
- else if (0xf0 <= *p && *p <= 0xfe) {
- if (*p != 0xf7) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p - 0x20);
- return 1;
- }
- }
-
- return 0;
-}
-
-static int
-mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
- UChar* lower, OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_1_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- /* 0xdf, 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
- if (*p >= 0xaa && *p <= 0xba)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_1_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-OnigEncodingDefine(iso_8859_1, ISO_8859_1) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-1", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- mbc_case_fold,
- apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_10.c b/enc/iso_8859_10.c
deleted file mode 100644
index 2b5affa4ee..0000000000
--- a/enc/iso_8859_10.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/**********************************************************************
- iso8859_10.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_10_TO_LOWER_CASE(c) EncISO_8859_10_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_10_CTYPE(code,ctype) \
- ((EncISO_8859_10_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_10_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\261', '\262', '\263', '\264', '\265', '\266', '\247',
- '\270', '\271', '\272', '\273', '\274', '\255', '\276', '\277',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_10_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x34a2,
- 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x01a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x01a0, 0x30e2, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-static int
-iso_8859_10_mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_10_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-iso_8859_10_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_10_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-iso_8859_10_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_10_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xb1 },
- { 0xa2, 0xb2 },
- { 0xa3, 0xb3 },
- { 0xa4, 0xb4 },
- { 0xa5, 0xb5 },
- { 0xa6, 0xb6 },
- { 0xa8, 0xb8 },
- { 0xa9, 0xb9 },
- { 0xaa, 0xba },
- { 0xab, 0xbb },
- { 0xac, 0xbc },
- { 0xae, 0xbe },
- { 0xaf, 0xbf },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd7, 0xf7 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-iso_8859_10_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-iso_8859_10_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_10, ISO_8859_10) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-10", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- iso_8859_10_mbc_case_fold,
- iso_8859_10_apply_all_case_fold,
- iso_8859_10_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_10_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_11.c b/enc/iso_8859_11.c
deleted file mode 100644
index 343993d01c..0000000000
--- a/enc/iso_8859_11.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**********************************************************************
- iso8859_11.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_IS_ISO_8859_11_CTYPE(code,ctype) \
- ((EncISO_8859_11_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const unsigned short EncISO_8859_11_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-static int
-iso_8859_11_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_11_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-OnigEncodingDefine(iso_8859_11, ISO_8859_11) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-11", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- onigenc_ascii_mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_11_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_13.c b/enc/iso_8859_13.c
deleted file mode 100644
index 4b6db1adf3..0000000000
--- a/enc/iso_8859_13.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/**********************************************************************
- iso8859_13.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_13_TO_LOWER_CASE(c) EncISO_8859_13_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_13_CTYPE(code,ctype) \
- ((EncISO_8859_13_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_13_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\270', '\251', '\272', '\253', '\254', '\255', '\256', '\277',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_13_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
- 0x34a2, 0x00a0, 0x34a2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x34a2,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x01a0, 0x30e2, 0x00a0, 0x01a0,
- 0x30e2, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x01a0
-};
-
-static int
-iso_8859_13_mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_13_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-iso_8859_13_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_13_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- /* 0xdf, 0xb5 are lower case letter, but can't convert. */
- if (*p == 0xb5)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-iso_8859_13_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_13_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-iso_8859_13_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-iso_8859_13_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_13, ISO_8859_13) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-13", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- iso_8859_13_mbc_case_fold,
- iso_8859_13_apply_all_case_fold,
- iso_8859_13_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_13_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_14.c b/enc/iso_8859_14.c
deleted file mode 100644
index c54d8fcbd2..0000000000
--- a/enc/iso_8859_14.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/**********************************************************************
- iso8859_14.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_14_TO_LOWER_CASE(c) EncISO_8859_14_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_14_CTYPE(code,ctype) \
- ((EncISO_8859_14_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_14_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\242', '\242', '\243', '\245', '\245', '\253', '\247',
- '\270', '\251', '\272', '\253', '\274', '\255', '\256', '\377',
- '\261', '\261', '\263', '\263', '\265', '\265', '\266', '\271',
- '\270', '\271', '\272', '\277', '\274', '\276', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_14_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x30e2, 0x00a0, 0x34a2, 0x30e2, 0x34a2, 0x00a0,
- 0x34a2, 0x00a0, 0x34a2, 0x30e2, 0x34a2, 0x01a0, 0x00a0, 0x34a2,
- 0x34a2, 0x30e2, 0x34a2, 0x30e2, 0x34a2, 0x30e2, 0x00a0, 0x34a2,
- 0x30e2, 0x30e2, 0x30e2, 0x34a2, 0x30e2, 0x34a2, 0x30e2, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-static int
-iso_8859_14_mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_14_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
-}
-
-#if 0
-static int
-iso_8859_14_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_14_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-iso_8859_14_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_14_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xa2 },
- { 0xa4, 0xa5 },
- { 0xa6, 0xab },
- { 0xa8, 0xb8 },
- { 0xaa, 0xba },
- { 0xac, 0xbc },
- { 0xaf, 0xff },
-
- { 0xb0, 0xb1 },
- { 0xb2, 0xb3 },
- { 0xb4, 0xb5 },
- { 0xb7, 0xb9 },
- { 0xbb, 0xbf },
- { 0xbd, 0xbe },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd7, 0xf7 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-iso_8859_14_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-iso_8859_14_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_14, ISO_8859_14) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-14", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- iso_8859_14_mbc_case_fold,
- iso_8859_14_apply_all_case_fold,
- iso_8859_14_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_14_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_15.c b/enc/iso_8859_15.c
deleted file mode 100644
index de963706f4..0000000000
--- a/enc/iso_8859_15.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/**********************************************************************
- iso8859_15.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_15_TO_LOWER_CASE(c) EncISO_8859_15_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_15_CTYPE(code,ctype) \
- ((EncISO_8859_15_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_15_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\250', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\270', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\275', '\275', '\377', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_15_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x34a2, 0x00a0,
- 0x30e2, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x34a2, 0x30e2, 0x00a0, 0x01a0,
- 0x30e2, 0x10a0, 0x30e2, 0x01a0, 0x34a2, 0x30e2, 0x34a2, 0x01a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-static int
-iso_8859_15_mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_15_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
-}
-
-#if 0
-static int
-iso_8859_15_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_15_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- /* 0xdf etc.. are lower case letter, but can't convert. */
- if (*p == 0xaa || *p == 0xb5 || *p == 0xba)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-iso_8859_15_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_15_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa6, 0xa8 },
-
- { 0xb4, 0xb8 },
- { 0xbc, 0xbd },
- { 0xbe, 0xff },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-iso_8859_15_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-iso_8859_15_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_15, ISO_8859_15) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-15", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- iso_8859_15_mbc_case_fold,
- iso_8859_15_apply_all_case_fold,
- iso_8859_15_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_15_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_16.c b/enc/iso_8859_16.c
deleted file mode 100644
index 1cf4f65672..0000000000
--- a/enc/iso_8859_16.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/**********************************************************************
- iso8859_16.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_16_TO_LOWER_CASE(c) EncISO_8859_16_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_16_CTYPE(code,ctype) \
- ((EncISO_8859_16_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_16_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\242', '\242', '\263', '\245', '\245', '\250', '\247',
- '\250', '\251', '\272', '\253', '\256', '\255', '\256', '\277',
- '\260', '\261', '\271', '\263', '\270', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\275', '\275', '\377', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_16_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x30e2, 0x34a2, 0x00a0, 0x01a0, 0x34a2, 0x00a0,
- 0x30e2, 0x00a0, 0x34a2, 0x01a0, 0x34a2, 0x01a0, 0x30e2, 0x34a2,
- 0x00a0, 0x00a0, 0x34a2, 0x30e2, 0x34a2, 0x01a0, 0x00a0, 0x01a0,
- 0x30e2, 0x30e2, 0x30e2, 0x01a0, 0x34a2, 0x30e2, 0x34a2, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-static int
-iso_8859_16_mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_16_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
-}
-
-#if 0
-static int
-iso_8859_16_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_16_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-iso_8859_16_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_16_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xa2 },
- { 0xa3, 0xb3 },
- { 0xa6, 0xa8 },
- { 0xaa, 0xba },
- { 0xac, 0xae },
- { 0xaf, 0xbf },
-
- { 0xb2, 0xb9 },
- { 0xb4, 0xb8 },
- { 0xbc, 0xbd },
- { 0xbe, 0xff },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd7, 0xf7 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-iso_8859_16_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-iso_8859_16_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_16, ISO_8859_16) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-16", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- iso_8859_16_mbc_case_fold,
- iso_8859_16_apply_all_case_fold,
- iso_8859_16_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_16_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_2.c b/enc/iso_8859_2.c
deleted file mode 100644
index 57340b3e15..0000000000
--- a/enc/iso_8859_2.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/**********************************************************************
- iso8859_2.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_2_TO_LOWER_CASE(c) EncISO_8859_2_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_2_CTYPE(code,ctype) \
- ((EncISO_8859_2_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_2_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\261', '\242', '\263', '\244', '\265', '\266', '\247',
- '\250', '\271', '\272', '\273', '\274', '\255', '\276', '\277',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_2_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x00a0, 0x34a2, 0x00a0, 0x34a2, 0x34a2, 0x00a0,
- 0x00a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x34a2,
- 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x30e2, 0x00a0,
- 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, 0x30e2, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0
-};
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_2_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_2_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xb1 },
- { 0xa3, 0xb3 },
- { 0xa5, 0xb5 },
- { 0xa6, 0xb6 },
- { 0xa9, 0xb9 },
- { 0xaa, 0xba },
- { 0xab, 0xbb },
- { 0xac, 0xbc },
- { 0xae, 0xbe },
- { 0xaf, 0xbf },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_2_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-OnigEncodingDefine(iso_8859_2, ISO_8859_2) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-2", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- mbc_case_fold,
- apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_3.c b/enc/iso_8859_3.c
deleted file mode 100644
index 90c2636d5c..0000000000
--- a/enc/iso_8859_3.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/**********************************************************************
- iso8859_3.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_3_TO_LOWER_CASE(c) EncISO_8859_3_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_3_CTYPE(code,ctype) \
- ((EncISO_8859_3_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_3_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\261', '\242', '\243', '\244', '\245', '\266', '\247',
- '\250', '\271', '\272', '\273', '\274', '\255', '\256', '\277',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\340', '\341', '\342', '\303', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\320', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_3_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x00a0, 0x00a0, 0x00a0, 0x0000, 0x34a2, 0x00a0,
- 0x00a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x0000, 0x34a2,
- 0x00a0, 0x30e2, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x30e2, 0x01a0,
- 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x11a0, 0x0000, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x0000, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x0000, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x0000, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x0000, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0
-};
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_3_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_3_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- /* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
- if (*p == 0xb5)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_3_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xb1 },
- { 0xa6, 0xb6 },
- { 0xa9, 0xb9 },
- { 0xaa, 0xba },
- { 0xab, 0xbb },
- { 0xac, 0xbc },
- { 0xaf, 0xbf },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-
-static int
-apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_3, ISO_8859_3) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-3", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- mbc_case_fold,
- apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_4.c b/enc/iso_8859_4.c
deleted file mode 100644
index cc103cd924..0000000000
--- a/enc/iso_8859_4.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/**********************************************************************
- iso8859_4.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_4_TO_LOWER_CASE(c) EncISO_8859_4_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_4_CTYPE(code,ctype) \
- ((EncISO_8859_4_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_4_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\261', '\242', '\263', '\244', '\265', '\266', '\247',
- '\250', '\271', '\272', '\273', '\274', '\255', '\276', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\277', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_4_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x30e2, 0x34a2, 0x00a0, 0x34a2, 0x34a2, 0x00a0,
- 0x00a0, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x00a0,
- 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x00a0, 0x30e2, 0x30e2, 0x00a0,
- 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x34a2, 0x30e2, 0x30e2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0
-};
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_4_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_4_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- if (*p == 0xa2)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_4_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xb1 },
- { 0xa3, 0xb3 },
- { 0xa5, 0xb5 },
- { 0xa6, 0xb6 },
- { 0xa9, 0xb9 },
- { 0xaa, 0xba },
- { 0xab, 0xbb },
- { 0xac, 0xbc },
- { 0xae, 0xbe },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_4, ISO_8859_4) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-4", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- mbc_case_fold,
- apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_5.c b/enc/iso_8859_5.c
deleted file mode 100644
index de7a0fd8bb..0000000000
--- a/enc/iso_8859_5.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/**********************************************************************
- iso8859_5.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_5_TO_LOWER_CASE(c) EncISO_8859_5_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_5_CTYPE(code,ctype) \
- ((EncISO_8859_5_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_5_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\255', '\376', '\377',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_5_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x00a0, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0, 0x30e2, 0x30e2
-};
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- *lower = ENC_ISO_8859_5_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- (*pp)++;
- v = (EncISO_8859_5_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_5_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xa1, 0xf1 },
- { 0xa2, 0xf2 },
- { 0xa3, 0xf3 },
- { 0xa4, 0xf4 },
- { 0xa5, 0xf5 },
- { 0xa6, 0xf6 },
- { 0xa7, 0xf7 },
- { 0xa8, 0xf8 },
- { 0xa9, 0xf9 },
- { 0xaa, 0xfa },
- { 0xab, 0xfb },
- { 0xac, 0xfc },
- { 0xae, 0xfe },
- { 0xaf, 0xff },
-
- { 0xb0, 0xd0 },
- { 0xb1, 0xd1 },
- { 0xb2, 0xd2 },
- { 0xb3, 0xd3 },
- { 0xb4, 0xd4 },
- { 0xb5, 0xd5 },
- { 0xb6, 0xd6 },
- { 0xb7, 0xd7 },
- { 0xb8, 0xd8 },
- { 0xb9, 0xd9 },
- { 0xba, 0xda },
- { 0xbb, 0xdb },
- { 0xbc, 0xdc },
- { 0xbd, 0xdd },
- { 0xbe, 0xdf },
- { 0xbf, 0xdf },
-
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef }
-};
-
-static int
-apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,
- flag, f, arg);
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_5, ISO_8859_5) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-5", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- mbc_case_fold,
- apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_6.c b/enc/iso_8859_6.c
deleted file mode 100644
index c0f3027904..0000000000
--- a/enc/iso_8859_6.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**********************************************************************
- iso8859_6.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_IS_ISO_8859_6_CTYPE(code,ctype) \
- ((EncISO_8859_6_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const unsigned short EncISO_8859_6_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x0000, 0x0000, 0x0000, 0x00a0, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0, 0x01a0, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x01a0, 0x0000, 0x0000, 0x0000, 0x01a0,
- 0x0000, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_6_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-OnigEncodingDefine(iso_8859_6, ISO_8859_6) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-6", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- onigenc_ascii_mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_7.c b/enc/iso_8859_7.c
deleted file mode 100644
index 2ff42ed53f..0000000000
--- a/enc/iso_8859_7.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/**********************************************************************
- iso8859_7.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_7_TO_LOWER_CASE(c) EncISO_8859_7_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_7_CTYPE(code,ctype) \
- ((EncISO_8859_7_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_7_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\334', '\267',
- '\335', '\336', '\337', '\273', '\374', '\275', '\375', '\376',
- '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\322', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_7_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x01a0, 0x01a0, 0x00a0, 0x0000, 0x0000, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x0000, 0x01a0, 0x00a0, 0x01a0, 0x0000, 0x01a0,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x00a0, 0x34a2, 0x01a0,
- 0x34a2, 0x34a2, 0x34a2, 0x01a0, 0x34a2, 0x10a0, 0x34a2, 0x34a2,
- 0x30e2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x0000, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x0000
-};
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- *lower = ENC_ISO_8859_7_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- (*pp)++;
- v = (EncISO_8859_7_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- if (*p == 0xc0 || *p == 0xe0)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_7_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xb6, 0xdc },
- { 0xb8, 0xdd },
- { 0xb9, 0xde },
- { 0xba, 0xdf },
- { 0xbc, 0xfc },
- { 0xbe, 0xfd },
- { 0xbf, 0xfe },
-
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd7, 0xf7 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb }
-};
-
-static int
-apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,
- flag, f, arg);
-}
-
-static int
-get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 0,
- flag, p, end, items);
-}
-
-
-OnigEncodingDefine(iso_8859_7, ISO_8859_7) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-7", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- mbc_case_fold,
- apply_all_case_fold,
- get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_8.c b/enc/iso_8859_8.c
deleted file mode 100644
index 3a075b0af3..0000000000
--- a/enc/iso_8859_8.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/**********************************************************************
- iso8859_8.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_IS_ISO_8859_8_CTYPE(code,ctype) \
- ((EncISO_8859_8_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const unsigned short EncISO_8859_8_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x0000, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x00a0, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0,
- 0x00a0, 0x10a0, 0x00a0, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01a0,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2, 0x30a2,
- 0x30a2, 0x30a2, 0x30a2, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-static int
-iso_8859_8_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_8_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-OnigEncodingDefine(iso_8859_8, ISO_8859_8) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-8", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- onigenc_ascii_mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_8_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/iso_8859_9.c b/enc/iso_8859_9.c
deleted file mode 100644
index 1921c591ba..0000000000
--- a/enc/iso_8859_9.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/**********************************************************************
- iso8859_9.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define ENC_ISO_8859_9_TO_LOWER_CASE(c) EncISO_8859_9_ToLowerCaseTable[c]
-#define ENC_IS_ISO_8859_9_CTYPE(code,ctype) \
- ((EncISO_8859_9_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-
-static const UChar EncISO_8859_9_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\335', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-static const unsigned short EncISO_8859_9_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0,
- 0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-static int
-iso_8859_9_mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- *lower++ = 's';
- *lower = 's';
- (*pp)++;
- return 2;
- }
-
- *lower = ENC_ISO_8859_9_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
-}
-
-#if 0
-static int
-iso_8859_9_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- int v;
- const UChar* p = *pp;
-
- if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- (*pp)++;
- return TRUE;
- }
-
- (*pp)++;
- v = (EncISO_8859_9_CtypeTable[*p] & (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
- if ((v | BIT_CTYPE_LOWER) != 0) {
- /* 0xdf etc.. are lower case letter, but can't convert. */
- if (*p >= 0xaa && *p <= 0xba)
- return FALSE;
- else
- return TRUE;
- }
-
- return (v != 0 ? TRUE : FALSE);
-}
-#endif
-
-static int
-iso_8859_9_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (code < 256)
- return ENC_IS_ISO_8859_9_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-static const OnigPairCaseFoldCodes CaseFoldMap[] = {
- { 0xc0, 0xe0 },
- { 0xc1, 0xe1 },
- { 0xc2, 0xe2 },
- { 0xc3, 0xe3 },
- { 0xc4, 0xe4 },
- { 0xc5, 0xe5 },
- { 0xc6, 0xe6 },
- { 0xc7, 0xe7 },
- { 0xc8, 0xe8 },
- { 0xc9, 0xe9 },
- { 0xca, 0xea },
- { 0xcb, 0xeb },
- { 0xcc, 0xec },
- { 0xcd, 0xed },
- { 0xce, 0xee },
- { 0xcf, 0xef },
-
- { 0xd0, 0xf0 },
- { 0xd1, 0xf1 },
- { 0xd2, 0xf2 },
- { 0xd3, 0xf3 },
- { 0xd4, 0xf4 },
- { 0xd5, 0xf5 },
- { 0xd6, 0xf6 },
- { 0xd8, 0xf8 },
- { 0xd9, 0xf9 },
- { 0xda, 0xfa },
- { 0xdb, 0xfb },
- { 0xdc, 0xfc },
- { 0xdd, 0xfd },
- { 0xde, 0xfe }
-};
-
-static int
-iso_8859_9_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- return onigenc_apply_all_case_fold_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, f, arg);
-}
-
-static int
-iso_8859_9_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_get_case_fold_codes_by_str_with_map(
- sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(iso_8859_9, ISO_8859_9) = {
- onigenc_single_byte_mbc_enc_len,
- "ISO-8859-9", /* name */
- 1, /* max enc length */
- 1, /* min enc length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- iso_8859_9_mbc_case_fold,
- iso_8859_9_apply_all_case_fold,
- iso_8859_9_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- iso_8859_9_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb
deleted file mode 100644
index d491b28d6e..0000000000
--- a/enc/make_encmake.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#! ./miniruby
-
-dir = File.expand_path("../..", __FILE__)
-$:.unshift(File.join(dir, "lib"))
-$:.unshift(dir)
-$:.unshift(".")
-require 'mkmf'
-require 'erb'
-
-if /--builtin-encs=/ =~ ARGV[0]
- BUILTIN_ENCS = $'.split.map {|e| File.basename(e, '.*') << '.c'}
- ARGV.shift
-else
- BUILTIN_ENCS = []
-end
-
-if File.exist?(depend = File.join($srcdir, "depend"))
- erb = ERB.new(File.read(depend), nil, '%')
- erb.filename = depend
- tmp = erb.result(binding)
- dep = "\n#### depend ####\n\n" << depend_rules(tmp).join
-else
- dep = ""
-end
-mkin = File.read(File.join($srcdir, "Makefile.in"))
-mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
-open(ARGV[0], 'wb') {|f|
- f.puts mkin, dep
-}
diff --git a/enc/sjis.c b/enc/sjis.c
deleted file mode 100644
index 5540a1fb70..0000000000
--- a/enc/sjis.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/**********************************************************************
- sjis.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-static const int EncLen_SJIS[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1
-};
-
-static const char SJIS_CAN_BE_TRAIL_TABLE[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0
-};
-
-#define SJIS_ISMB_FIRST(byte) (EncLen_SJIS[byte] > 1)
-#define SJIS_ISMB_TRAIL(byte) SJIS_CAN_BE_TRAIL_TABLE[(byte)]
-
-typedef enum { FAILURE = -2, ACCEPT = -1, S0 = 0, S1 } state_t;
-#define A ACCEPT
-#define F FAILURE
-static const signed char trans[][0x100] = {
- { /* S0 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 1 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 2 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 3 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 4 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 5 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 6 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 7 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 8 */ F, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* 9 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* a */ F, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* b */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* c */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* d */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* e */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, F, F, F
- },
- { /* S1 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 5 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 6 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 7 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, F,
- /* 8 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 9 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* a */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* b */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* c */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* d */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* e */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* f */ A, A, A, A, A, A, A, A, A, A, A, A, A, F, F, F
- }
-};
-#undef A
-#undef F
-
-static int
-mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc)
-{
- int firstbyte = *p++;
- state_t s;
- s = trans[0][firstbyte];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_SJIS[firstbyte]-1);
- s = trans[s][*p++];
- return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-}
-
-static int
-code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
-{
- if (code < 256) {
- if (EncLen_SJIS[(int )code] == 1)
- return 1;
- else
- return 0;
- }
- else if (code <= 0xffff) {
- return 2;
- }
- else
- return 0;
-}
-
-static OnigCodePoint
-mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- int c, i, len;
- OnigCodePoint n;
-
- len = enc_len(ONIG_ENCODING_SJIS, p, end);
- c = *p++;
- n = c;
- if (len == 1) return n;
-
- for (i = 1; i < len; i++) {
- if (p >= end) break;
- c = *p++;
- n <<= 8; n += c;
- }
- return n;
-}
-
-static int
-code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
-{
- UChar *p = buf;
-
- if ((code & 0xff00) != 0) *p++ = (UChar )(((code >> 8) & 0xff));
- *p++ = (UChar )(code & 0xff);
-
-#if 0
- if (enc_len(ONIG_ENCODING_SJIS, buf) != (p - buf))
- return REGERR_INVALID_WIDE_CHAR_VALUE;
-#endif
- return p - buf;
-}
-
-static int
-mbc_case_fold(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower,
- OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
- *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
- }
- else {
- int i;
- int len = enc_len(ONIG_ENCODING_SJIS, p, end);
-
- for (i = 0; i < len; i++) {
- *lower++ = *p++;
- }
- (*pp) += len;
- return len; /* return byte length of converted char to lower */
- }
-}
-
-#if 0
-static int
-is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- return onigenc_mbn_is_mbc_ambiguous(ONIG_ENCODING_SJIS, flag, pp, end);
-
-}
-#endif
-
-#if 0
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype)
-{
- if (code < 128)
- return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
- else {
- if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
- return (code_to_mbclen(code) > 1 ? TRUE : FALSE);
- }
- }
-
- return FALSE;
-}
-#endif
-
-static UChar*
-left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
-{
- const UChar *p;
- int len;
-
- if (s <= start) return (UChar* )s;
- p = s;
-
- if (SJIS_ISMB_TRAIL(*p)) {
- while (p > start) {
- if (! SJIS_ISMB_FIRST(*--p)) {
- p++;
- break;
- }
- }
- }
- len = enc_len(ONIG_ENCODING_SJIS, p, s);
- if (p + len > s) return (UChar* )p;
- p += len;
- return (UChar* )(p + ((s - p) & ~1));
-}
-
-static int
-is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc)
-{
- const UChar c = *s;
- return (SJIS_ISMB_TRAIL(c) ? FALSE : TRUE);
-}
-
-
-static int PropertyInited = 0;
-static const OnigCodePoint** PropertyList;
-static int PropertyListNum;
-static int PropertyListSize;
-static hash_table_type* PropertyNameTable;
-
-static const OnigCodePoint CR_Hiragana[] = {
- 1,
- 0x829f, 0x82f1
-}; /* CR_Hiragana */
-
-static const OnigCodePoint CR_Katakana[] = {
- 4,
- 0x00a6, 0x00af,
- 0x00b1, 0x00dd,
- 0x8340, 0x837e,
- 0x8380, 0x8396,
-}; /* CR_Katakana */
-
-static int
-init_property_list(void)
-{
- int r;
-
- PROPERTY_LIST_ADD_PROP("Hiragana", CR_Hiragana);
- PROPERTY_LIST_ADD_PROP("Katakana", CR_Katakana);
- PropertyInited = 1;
-
- end:
- return r;
-}
-
-static int
-property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
-{
- int ctype;
-
- PROPERTY_LIST_INIT_CHECK;
-
- if (onig_st_lookup_strend(PropertyNameTable, p, end, (void*)&ctype) == 0) {
- return onigenc_minimum_property_name_to_ctype(enc, p, end);
- }
-
- return ctype;
-}
-
-static int
-is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (ctype <= ONIGENC_MAX_STD_CTYPE) {
- if (code < 128)
- return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
- else {
- if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
- return (code_to_mbclen(code, enc) > 1 ? TRUE : FALSE);
- }
- }
- }
- else {
- PROPERTY_LIST_INIT_CHECK;
-
- ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
- if (ctype >= (unsigned int )PropertyListNum)
- return ONIGENC_ERR_TYPE_BUG;
-
- return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
- }
-
- return FALSE;
-}
-
-static int
-get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
- const OnigCodePoint* ranges[], OnigEncoding enc)
-{
- if (ctype <= ONIGENC_MAX_STD_CTYPE) {
- return ONIG_NO_SUPPORT_CONFIG;
- }
- else {
- *sb_out = 0x80;
-
- PROPERTY_LIST_INIT_CHECK;
-
- ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
- if (ctype >= PropertyListNum)
- return ONIGENC_ERR_TYPE_BUG;
-
- *ranges = PropertyList[ctype];
- return 0;
- }
-}
-
-OnigEncodingDefine(sjis, SJIS) = {
- mbc_enc_len,
- "Shift_JIS", /* name */
- 2, /* max byte length */
- 1, /* min byte length */
- onigenc_is_mbc_newline_0x0a,
- mbc_to_code,
- code_to_mbclen,
- code_to_mbc,
- mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- property_name_to_ctype,
- is_code_ctype,
- get_ctype_code_range,
- left_adjust_char_head,
- is_allowed_reverse_match,
- 0
-};
diff --git a/enc/trans/japanese.c b/enc/trans/japanese.c
deleted file mode 100644
index 3ac71882af..0000000000
--- a/enc/trans/japanese.c
+++ /dev/null
@@ -1,23868 +0,0 @@
-#include "transcode_data.h"
-
-static const unsigned char
-from_SHIFT_JIS_81_offsets[256] = {
- 147,147,147,147,147,147,147,147, 147,147,147,147,147,147,147,147,
- 147,147,147,147,147,147,147,147, 147,147,147,147,147,147,147,147,
- 147,147,147,147,147,147,147,147, 147,147,147,147,147,147,147,147,
- 147,147,147,147,147,147,147,147, 147,147,147,147,147,147,147,147,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,147,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99,100,101,102, 103,104,105,106,107,147,147,147,
- 147,147,147,147,147,147,147,147, 108,109,110,111,112,113,114,115,
- 147,147,147,147,147,147,147,147, 116,117,118,119,120,121,122,147,
- 147,147,147,147,147,147,147,147, 147,147,123,124,125,126,127,128,
- 129,130,131,132,133,134,135,136, 137,147,147,147,147,147,147,147,
- 138,139,140,141,142,143,144,145, 147,147,147,147,146,147,147,147,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_81_infos[148] = {
- o3(0xE3,0x80,0x80), o3(0xE3,0x80,0x81),
- o3(0xE3,0x80,0x82), o3(0xEF,0xBC,0x8C),
- o3(0xEF,0xBC,0x8E), o3(0xE3,0x83,0xBB),
- o3(0xEF,0xBC,0x9A), o3(0xEF,0xBC,0x9B),
- o3(0xEF,0xBC,0x9F), o3(0xEF,0xBC,0x81),
- o3(0xE3,0x82,0x9B), o3(0xE3,0x82,0x9C),
- o2(0xC2,0xB4), o3(0xEF,0xBD,0x80),
- o2(0xC2,0xA8), o3(0xEF,0xBC,0xBE),
- o3(0xEF,0xBF,0xA3), o3(0xEF,0xBC,0xBF),
- o3(0xE3,0x83,0xBD), o3(0xE3,0x83,0xBE),
- o3(0xE3,0x82,0x9D), o3(0xE3,0x82,0x9E),
- o3(0xE3,0x80,0x83), o3(0xE4,0xBB,0x9D),
- o3(0xE3,0x80,0x85), o3(0xE3,0x80,0x86),
- o3(0xE3,0x80,0x87), o3(0xE3,0x83,0xBC),
- o3(0xE2,0x80,0x95), o3(0xE2,0x80,0x90),
- o3(0xEF,0xBC,0x8F), o3(0xEF,0xBC,0xBC),
- o3(0xEF,0xBD,0x9E), o3(0xE2,0x88,0xA5),
- o3(0xEF,0xBD,0x9C), o3(0xE2,0x80,0xA6),
- o3(0xE2,0x80,0xA5), o3(0xE2,0x80,0x98),
- o3(0xE2,0x80,0x99), o3(0xE2,0x80,0x9C),
- o3(0xE2,0x80,0x9D), o3(0xEF,0xBC,0x88),
- o3(0xEF,0xBC,0x89), o3(0xE3,0x80,0x94),
- o3(0xE3,0x80,0x95), o3(0xEF,0xBC,0xBB),
- o3(0xEF,0xBC,0xBD), o3(0xEF,0xBD,0x9B),
- o3(0xEF,0xBD,0x9D), o3(0xE3,0x80,0x88),
- o3(0xE3,0x80,0x89), o3(0xE3,0x80,0x8A),
- o3(0xE3,0x80,0x8B), o3(0xE3,0x80,0x8C),
- o3(0xE3,0x80,0x8D), o3(0xE3,0x80,0x8E),
- o3(0xE3,0x80,0x8F), o3(0xE3,0x80,0x90),
- o3(0xE3,0x80,0x91), o3(0xEF,0xBC,0x8B),
- o3(0xEF,0xBC,0x8D), o2(0xC2,0xB1),
- o2(0xC3,0x97), o2(0xC3,0xB7),
- o3(0xEF,0xBC,0x9D), o3(0xE2,0x89,0xA0),
- o3(0xEF,0xBC,0x9C), o3(0xEF,0xBC,0x9E),
- o3(0xE2,0x89,0xA6), o3(0xE2,0x89,0xA7),
- o3(0xE2,0x88,0x9E), o3(0xE2,0x88,0xB4),
- o3(0xE2,0x99,0x82), o3(0xE2,0x99,0x80),
- o2(0xC2,0xB0), o3(0xE2,0x80,0xB2),
- o3(0xE2,0x80,0xB3), o3(0xE2,0x84,0x83),
- o3(0xEF,0xBF,0xA5), o3(0xEF,0xBC,0x84),
- o3(0xEF,0xBF,0xA0), o3(0xEF,0xBF,0xA1),
- o3(0xEF,0xBC,0x85), o3(0xEF,0xBC,0x83),
- o3(0xEF,0xBC,0x86), o3(0xEF,0xBC,0x8A),
- o3(0xEF,0xBC,0xA0), o2(0xC2,0xA7),
- o3(0xE2,0x98,0x86), o3(0xE2,0x98,0x85),
- o3(0xE2,0x97,0x8B), o3(0xE2,0x97,0x8F),
- o3(0xE2,0x97,0x8E), o3(0xE2,0x97,0x87),
- o3(0xE2,0x97,0x86), o3(0xE2,0x96,0xA1),
- o3(0xE2,0x96,0xA0), o3(0xE2,0x96,0xB3),
- o3(0xE2,0x96,0xB2), o3(0xE2,0x96,0xBD),
- o3(0xE2,0x96,0xBC), o3(0xE2,0x80,0xBB),
- o3(0xE3,0x80,0x92), o3(0xE2,0x86,0x92),
- o3(0xE2,0x86,0x90), o3(0xE2,0x86,0x91),
- o3(0xE2,0x86,0x93), o3(0xE3,0x80,0x93),
- o3(0xE2,0x88,0x88), o3(0xE2,0x88,0x8B),
- o3(0xE2,0x8A,0x86), o3(0xE2,0x8A,0x87),
- o3(0xE2,0x8A,0x82), o3(0xE2,0x8A,0x83),
- o3(0xE2,0x88,0xAA), o3(0xE2,0x88,0xA9),
- o3(0xE2,0x88,0xA7), o3(0xE2,0x88,0xA8),
- o3(0xEF,0xBF,0xA2), o3(0xE2,0x87,0x92),
- o3(0xE2,0x87,0x94), o3(0xE2,0x88,0x80),
- o3(0xE2,0x88,0x83), o3(0xE2,0x88,0xA0),
- o3(0xE2,0x8A,0xA5), o3(0xE2,0x8C,0x92),
- o3(0xE2,0x88,0x82), o3(0xE2,0x88,0x87),
- o3(0xE2,0x89,0xA1), o3(0xE2,0x89,0x92),
- o3(0xE2,0x89,0xAA), o3(0xE2,0x89,0xAB),
- o3(0xE2,0x88,0x9A), o3(0xE2,0x88,0xBD),
- o3(0xE2,0x88,0x9D), o3(0xE2,0x88,0xB5),
- o3(0xE2,0x88,0xAB), o3(0xE2,0x88,0xAC),
- o3(0xE2,0x84,0xAB), o3(0xE2,0x80,0xB0),
- o3(0xE2,0x99,0xAF), o3(0xE2,0x99,0xAD),
- o3(0xE2,0x99,0xAA), o3(0xE2,0x80,0xA0),
- o3(0xE2,0x80,0xA1), o2(0xC2,0xB6),
- o3(0xE2,0x97,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_81 = {
- from_SHIFT_JIS_81_offsets,
- from_SHIFT_JIS_81_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_82_offsets[256] = {
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9,145,145,145,145,145,145,145,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,145,145,145,145,145,145,
- 145, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,145,145,145,145, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99,100,101,102, 103,104,105,106,107,108,109,110,
- 111,112,113,114,115,116,117,118, 119,120,121,122,123,124,125,126,
- 127,128,129,130,131,132,133,134, 135,136,137,138,139,140,141,142,
- 143,144,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_82_infos[146] = {
- o3(0xEF,0xBC,0x90), o3(0xEF,0xBC,0x91),
- o3(0xEF,0xBC,0x92), o3(0xEF,0xBC,0x93),
- o3(0xEF,0xBC,0x94), o3(0xEF,0xBC,0x95),
- o3(0xEF,0xBC,0x96), o3(0xEF,0xBC,0x97),
- o3(0xEF,0xBC,0x98), o3(0xEF,0xBC,0x99),
- o3(0xEF,0xBC,0xA1), o3(0xEF,0xBC,0xA2),
- o3(0xEF,0xBC,0xA3), o3(0xEF,0xBC,0xA4),
- o3(0xEF,0xBC,0xA5), o3(0xEF,0xBC,0xA6),
- o3(0xEF,0xBC,0xA7), o3(0xEF,0xBC,0xA8),
- o3(0xEF,0xBC,0xA9), o3(0xEF,0xBC,0xAA),
- o3(0xEF,0xBC,0xAB), o3(0xEF,0xBC,0xAC),
- o3(0xEF,0xBC,0xAD), o3(0xEF,0xBC,0xAE),
- o3(0xEF,0xBC,0xAF), o3(0xEF,0xBC,0xB0),
- o3(0xEF,0xBC,0xB1), o3(0xEF,0xBC,0xB2),
- o3(0xEF,0xBC,0xB3), o3(0xEF,0xBC,0xB4),
- o3(0xEF,0xBC,0xB5), o3(0xEF,0xBC,0xB6),
- o3(0xEF,0xBC,0xB7), o3(0xEF,0xBC,0xB8),
- o3(0xEF,0xBC,0xB9), o3(0xEF,0xBC,0xBA),
- o3(0xEF,0xBD,0x81), o3(0xEF,0xBD,0x82),
- o3(0xEF,0xBD,0x83), o3(0xEF,0xBD,0x84),
- o3(0xEF,0xBD,0x85), o3(0xEF,0xBD,0x86),
- o3(0xEF,0xBD,0x87), o3(0xEF,0xBD,0x88),
- o3(0xEF,0xBD,0x89), o3(0xEF,0xBD,0x8A),
- o3(0xEF,0xBD,0x8B), o3(0xEF,0xBD,0x8C),
- o3(0xEF,0xBD,0x8D), o3(0xEF,0xBD,0x8E),
- o3(0xEF,0xBD,0x8F), o3(0xEF,0xBD,0x90),
- o3(0xEF,0xBD,0x91), o3(0xEF,0xBD,0x92),
- o3(0xEF,0xBD,0x93), o3(0xEF,0xBD,0x94),
- o3(0xEF,0xBD,0x95), o3(0xEF,0xBD,0x96),
- o3(0xEF,0xBD,0x97), o3(0xEF,0xBD,0x98),
- o3(0xEF,0xBD,0x99), o3(0xEF,0xBD,0x9A),
- o3(0xE3,0x81,0x81), o3(0xE3,0x81,0x82),
- o3(0xE3,0x81,0x83), o3(0xE3,0x81,0x84),
- o3(0xE3,0x81,0x85), o3(0xE3,0x81,0x86),
- o3(0xE3,0x81,0x87), o3(0xE3,0x81,0x88),
- o3(0xE3,0x81,0x89), o3(0xE3,0x81,0x8A),
- o3(0xE3,0x81,0x8B), o3(0xE3,0x81,0x8C),
- o3(0xE3,0x81,0x8D), o3(0xE3,0x81,0x8E),
- o3(0xE3,0x81,0x8F), o3(0xE3,0x81,0x90),
- o3(0xE3,0x81,0x91), o3(0xE3,0x81,0x92),
- o3(0xE3,0x81,0x93), o3(0xE3,0x81,0x94),
- o3(0xE3,0x81,0x95), o3(0xE3,0x81,0x96),
- o3(0xE3,0x81,0x97), o3(0xE3,0x81,0x98),
- o3(0xE3,0x81,0x99), o3(0xE3,0x81,0x9A),
- o3(0xE3,0x81,0x9B), o3(0xE3,0x81,0x9C),
- o3(0xE3,0x81,0x9D), o3(0xE3,0x81,0x9E),
- o3(0xE3,0x81,0x9F), o3(0xE3,0x81,0xA0),
- o3(0xE3,0x81,0xA1), o3(0xE3,0x81,0xA2),
- o3(0xE3,0x81,0xA3), o3(0xE3,0x81,0xA4),
- o3(0xE3,0x81,0xA5), o3(0xE3,0x81,0xA6),
- o3(0xE3,0x81,0xA7), o3(0xE3,0x81,0xA8),
- o3(0xE3,0x81,0xA9), o3(0xE3,0x81,0xAA),
- o3(0xE3,0x81,0xAB), o3(0xE3,0x81,0xAC),
- o3(0xE3,0x81,0xAD), o3(0xE3,0x81,0xAE),
- o3(0xE3,0x81,0xAF), o3(0xE3,0x81,0xB0),
- o3(0xE3,0x81,0xB1), o3(0xE3,0x81,0xB2),
- o3(0xE3,0x81,0xB3), o3(0xE3,0x81,0xB4),
- o3(0xE3,0x81,0xB5), o3(0xE3,0x81,0xB6),
- o3(0xE3,0x81,0xB7), o3(0xE3,0x81,0xB8),
- o3(0xE3,0x81,0xB9), o3(0xE3,0x81,0xBA),
- o3(0xE3,0x81,0xBB), o3(0xE3,0x81,0xBC),
- o3(0xE3,0x81,0xBD), o3(0xE3,0x81,0xBE),
- o3(0xE3,0x81,0xBF), o3(0xE3,0x82,0x80),
- o3(0xE3,0x82,0x81), o3(0xE3,0x82,0x82),
- o3(0xE3,0x82,0x83), o3(0xE3,0x82,0x84),
- o3(0xE3,0x82,0x85), o3(0xE3,0x82,0x86),
- o3(0xE3,0x82,0x87), o3(0xE3,0x82,0x88),
- o3(0xE3,0x82,0x89), o3(0xE3,0x82,0x8A),
- o3(0xE3,0x82,0x8B), o3(0xE3,0x82,0x8C),
- o3(0xE3,0x82,0x8D), o3(0xE3,0x82,0x8E),
- o3(0xE3,0x82,0x8F), o3(0xE3,0x82,0x90),
- o3(0xE3,0x82,0x91), o3(0xE3,0x82,0x92),
- o3(0xE3,0x82,0x93), UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_82 = {
- from_SHIFT_JIS_82_offsets,
- from_SHIFT_JIS_82_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_83_offsets[256] = {
- 134,134,134,134,134,134,134,134, 134,134,134,134,134,134,134,134,
- 134,134,134,134,134,134,134,134, 134,134,134,134,134,134,134,134,
- 134,134,134,134,134,134,134,134, 134,134,134,134,134,134,134,134,
- 134,134,134,134,134,134,134,134, 134,134,134,134,134,134,134,134,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,134,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85,134, 134,134,134,134,134,134,134, 86,
- 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,
- 103,104,105,106,107,108,109,134, 134,134,134,134,134,134,134,110,
- 111,112,113,114,115,116,117,118, 119,120,121,122,123,124,125,126,
- 127,128,129,130,131,132,133,134, 134,134,134,134,134,134,134,134,
- 134,134,134,134,134,134,134,134, 134,134,134,134,134,134,134,134,
- 134,134,134,134,134,134,134,134, 134,134,134,134,134,134,134,134,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_83_infos[135] = {
- o3(0xE3,0x82,0xA1), o3(0xE3,0x82,0xA2),
- o3(0xE3,0x82,0xA3), o3(0xE3,0x82,0xA4),
- o3(0xE3,0x82,0xA5), o3(0xE3,0x82,0xA6),
- o3(0xE3,0x82,0xA7), o3(0xE3,0x82,0xA8),
- o3(0xE3,0x82,0xA9), o3(0xE3,0x82,0xAA),
- o3(0xE3,0x82,0xAB), o3(0xE3,0x82,0xAC),
- o3(0xE3,0x82,0xAD), o3(0xE3,0x82,0xAE),
- o3(0xE3,0x82,0xAF), o3(0xE3,0x82,0xB0),
- o3(0xE3,0x82,0xB1), o3(0xE3,0x82,0xB2),
- o3(0xE3,0x82,0xB3), o3(0xE3,0x82,0xB4),
- o3(0xE3,0x82,0xB5), o3(0xE3,0x82,0xB6),
- o3(0xE3,0x82,0xB7), o3(0xE3,0x82,0xB8),
- o3(0xE3,0x82,0xB9), o3(0xE3,0x82,0xBA),
- o3(0xE3,0x82,0xBB), o3(0xE3,0x82,0xBC),
- o3(0xE3,0x82,0xBD), o3(0xE3,0x82,0xBE),
- o3(0xE3,0x82,0xBF), o3(0xE3,0x83,0x80),
- o3(0xE3,0x83,0x81), o3(0xE3,0x83,0x82),
- o3(0xE3,0x83,0x83), o3(0xE3,0x83,0x84),
- o3(0xE3,0x83,0x85), o3(0xE3,0x83,0x86),
- o3(0xE3,0x83,0x87), o3(0xE3,0x83,0x88),
- o3(0xE3,0x83,0x89), o3(0xE3,0x83,0x8A),
- o3(0xE3,0x83,0x8B), o3(0xE3,0x83,0x8C),
- o3(0xE3,0x83,0x8D), o3(0xE3,0x83,0x8E),
- o3(0xE3,0x83,0x8F), o3(0xE3,0x83,0x90),
- o3(0xE3,0x83,0x91), o3(0xE3,0x83,0x92),
- o3(0xE3,0x83,0x93), o3(0xE3,0x83,0x94),
- o3(0xE3,0x83,0x95), o3(0xE3,0x83,0x96),
- o3(0xE3,0x83,0x97), o3(0xE3,0x83,0x98),
- o3(0xE3,0x83,0x99), o3(0xE3,0x83,0x9A),
- o3(0xE3,0x83,0x9B), o3(0xE3,0x83,0x9C),
- o3(0xE3,0x83,0x9D), o3(0xE3,0x83,0x9E),
- o3(0xE3,0x83,0x9F), o3(0xE3,0x83,0xA0),
- o3(0xE3,0x83,0xA1), o3(0xE3,0x83,0xA2),
- o3(0xE3,0x83,0xA3), o3(0xE3,0x83,0xA4),
- o3(0xE3,0x83,0xA5), o3(0xE3,0x83,0xA6),
- o3(0xE3,0x83,0xA7), o3(0xE3,0x83,0xA8),
- o3(0xE3,0x83,0xA9), o3(0xE3,0x83,0xAA),
- o3(0xE3,0x83,0xAB), o3(0xE3,0x83,0xAC),
- o3(0xE3,0x83,0xAD), o3(0xE3,0x83,0xAE),
- o3(0xE3,0x83,0xAF), o3(0xE3,0x83,0xB0),
- o3(0xE3,0x83,0xB1), o3(0xE3,0x83,0xB2),
- o3(0xE3,0x83,0xB3), o3(0xE3,0x83,0xB4),
- o3(0xE3,0x83,0xB5), o3(0xE3,0x83,0xB6),
- o2(0xCE,0x91), o2(0xCE,0x92),
- o2(0xCE,0x93), o2(0xCE,0x94),
- o2(0xCE,0x95), o2(0xCE,0x96),
- o2(0xCE,0x97), o2(0xCE,0x98),
- o2(0xCE,0x99), o2(0xCE,0x9A),
- o2(0xCE,0x9B), o2(0xCE,0x9C),
- o2(0xCE,0x9D), o2(0xCE,0x9E),
- o2(0xCE,0x9F), o2(0xCE,0xA0),
- o2(0xCE,0xA1), o2(0xCE,0xA3),
- o2(0xCE,0xA4), o2(0xCE,0xA5),
- o2(0xCE,0xA6), o2(0xCE,0xA7),
- o2(0xCE,0xA8), o2(0xCE,0xA9),
- o2(0xCE,0xB1), o2(0xCE,0xB2),
- o2(0xCE,0xB3), o2(0xCE,0xB4),
- o2(0xCE,0xB5), o2(0xCE,0xB6),
- o2(0xCE,0xB7), o2(0xCE,0xB8),
- o2(0xCE,0xB9), o2(0xCE,0xBA),
- o2(0xCE,0xBB), o2(0xCE,0xBC),
- o2(0xCE,0xBD), o2(0xCE,0xBE),
- o2(0xCE,0xBF), o2(0xCF,0x80),
- o2(0xCF,0x81), o2(0xCF,0x83),
- o2(0xCF,0x84), o2(0xCF,0x85),
- o2(0xCF,0x86), o2(0xCF,0x87),
- o2(0xCF,0x88), o2(0xCF,0x89),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_83 = {
- from_SHIFT_JIS_83_offsets,
- from_SHIFT_JIS_83_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_84_offsets[256] = {
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 98,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 66,
- 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_84_infos[99] = {
- o2(0xD0,0x90), o2(0xD0,0x91),
- o2(0xD0,0x92), o2(0xD0,0x93),
- o2(0xD0,0x94), o2(0xD0,0x95),
- o2(0xD0,0x81), o2(0xD0,0x96),
- o2(0xD0,0x97), o2(0xD0,0x98),
- o2(0xD0,0x99), o2(0xD0,0x9A),
- o2(0xD0,0x9B), o2(0xD0,0x9C),
- o2(0xD0,0x9D), o2(0xD0,0x9E),
- o2(0xD0,0x9F), o2(0xD0,0xA0),
- o2(0xD0,0xA1), o2(0xD0,0xA2),
- o2(0xD0,0xA3), o2(0xD0,0xA4),
- o2(0xD0,0xA5), o2(0xD0,0xA6),
- o2(0xD0,0xA7), o2(0xD0,0xA8),
- o2(0xD0,0xA9), o2(0xD0,0xAA),
- o2(0xD0,0xAB), o2(0xD0,0xAC),
- o2(0xD0,0xAD), o2(0xD0,0xAE),
- o2(0xD0,0xAF), o2(0xD0,0xB0),
- o2(0xD0,0xB1), o2(0xD0,0xB2),
- o2(0xD0,0xB3), o2(0xD0,0xB4),
- o2(0xD0,0xB5), o2(0xD1,0x91),
- o2(0xD0,0xB6), o2(0xD0,0xB7),
- o2(0xD0,0xB8), o2(0xD0,0xB9),
- o2(0xD0,0xBA), o2(0xD0,0xBB),
- o2(0xD0,0xBC), o2(0xD0,0xBD),
- o2(0xD0,0xBE), o2(0xD0,0xBF),
- o2(0xD1,0x80), o2(0xD1,0x81),
- o2(0xD1,0x82), o2(0xD1,0x83),
- o2(0xD1,0x84), o2(0xD1,0x85),
- o2(0xD1,0x86), o2(0xD1,0x87),
- o2(0xD1,0x88), o2(0xD1,0x89),
- o2(0xD1,0x8A), o2(0xD1,0x8B),
- o2(0xD1,0x8C), o2(0xD1,0x8D),
- o2(0xD1,0x8E), o2(0xD1,0x8F),
- o3(0xE2,0x94,0x80), o3(0xE2,0x94,0x82),
- o3(0xE2,0x94,0x8C), o3(0xE2,0x94,0x90),
- o3(0xE2,0x94,0x98), o3(0xE2,0x94,0x94),
- o3(0xE2,0x94,0x9C), o3(0xE2,0x94,0xAC),
- o3(0xE2,0x94,0xA4), o3(0xE2,0x94,0xB4),
- o3(0xE2,0x94,0xBC), o3(0xE2,0x94,0x81),
- o3(0xE2,0x94,0x83), o3(0xE2,0x94,0x8F),
- o3(0xE2,0x94,0x93), o3(0xE2,0x94,0x9B),
- o3(0xE2,0x94,0x97), o3(0xE2,0x94,0xA3),
- o3(0xE2,0x94,0xB3), o3(0xE2,0x94,0xAB),
- o3(0xE2,0x94,0xBB), o3(0xE2,0x95,0x8B),
- o3(0xE2,0x94,0xA0), o3(0xE2,0x94,0xAF),
- o3(0xE2,0x94,0xA8), o3(0xE2,0x94,0xB7),
- o3(0xE2,0x94,0xBF), o3(0xE2,0x94,0x9D),
- o3(0xE2,0x94,0xB0), o3(0xE2,0x94,0xA5),
- o3(0xE2,0x94,0xB8), o3(0xE2,0x95,0x82),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_84 = {
- from_SHIFT_JIS_84_offsets,
- from_SHIFT_JIS_84_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_87_offsets[256] = {
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 83, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 83, 83, 83, 83, 83, 83, 83, 83, 53, 83,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_87_infos[84] = {
- /* used from from_SHIFT_JIS_87 */
- /* used from from_EUC_JP_AD */
- o3(0xE2,0x91,0xA0), o3(0xE2,0x91,0xA1),
- o3(0xE2,0x91,0xA2), o3(0xE2,0x91,0xA3),
- o3(0xE2,0x91,0xA4), o3(0xE2,0x91,0xA5),
- o3(0xE2,0x91,0xA6), o3(0xE2,0x91,0xA7),
- o3(0xE2,0x91,0xA8), o3(0xE2,0x91,0xA9),
- o3(0xE2,0x91,0xAA), o3(0xE2,0x91,0xAB),
- o3(0xE2,0x91,0xAC), o3(0xE2,0x91,0xAD),
- o3(0xE2,0x91,0xAE), o3(0xE2,0x91,0xAF),
- o3(0xE2,0x91,0xB0), o3(0xE2,0x91,0xB1),
- o3(0xE2,0x91,0xB2), o3(0xE2,0x91,0xB3),
- o3(0xE2,0x85,0xA0), o3(0xE2,0x85,0xA1),
- o3(0xE2,0x85,0xA2), o3(0xE2,0x85,0xA3),
- o3(0xE2,0x85,0xA4), o3(0xE2,0x85,0xA5),
- o3(0xE2,0x85,0xA6), o3(0xE2,0x85,0xA7),
- o3(0xE2,0x85,0xA8), o3(0xE2,0x85,0xA9),
- o3(0xE3,0x8D,0x89), o3(0xE3,0x8C,0x94),
- o3(0xE3,0x8C,0xA2), o3(0xE3,0x8D,0x8D),
- o3(0xE3,0x8C,0x98), o3(0xE3,0x8C,0xA7),
- o3(0xE3,0x8C,0x83), o3(0xE3,0x8C,0xB6),
- o3(0xE3,0x8D,0x91), o3(0xE3,0x8D,0x97),
- o3(0xE3,0x8C,0x8D), o3(0xE3,0x8C,0xA6),
- o3(0xE3,0x8C,0xA3), o3(0xE3,0x8C,0xAB),
- o3(0xE3,0x8D,0x8A), o3(0xE3,0x8C,0xBB),
- o3(0xE3,0x8E,0x9C), o3(0xE3,0x8E,0x9D),
- o3(0xE3,0x8E,0x9E), o3(0xE3,0x8E,0x8E),
- o3(0xE3,0x8E,0x8F), o3(0xE3,0x8F,0x84),
- o3(0xE3,0x8E,0xA1), o3(0xE3,0x8D,0xBB),
- o3(0xE3,0x80,0x9D), o3(0xE3,0x80,0x9F),
- o3(0xE2,0x84,0x96), o3(0xE3,0x8F,0x8D),
- o3(0xE2,0x84,0xA1), o3(0xE3,0x8A,0xA4),
- o3(0xE3,0x8A,0xA5), o3(0xE3,0x8A,0xA6),
- o3(0xE3,0x8A,0xA7), o3(0xE3,0x8A,0xA8),
- o3(0xE3,0x88,0xB1), o3(0xE3,0x88,0xB2),
- o3(0xE3,0x88,0xB9), o3(0xE3,0x8D,0xBE),
- o3(0xE3,0x8D,0xBD), o3(0xE3,0x8D,0xBC),
- o3(0xE2,0x89,0x92), o3(0xE2,0x89,0xA1),
- o3(0xE2,0x88,0xAB), o3(0xE2,0x88,0xAE),
- o3(0xE2,0x88,0x91), o3(0xE2,0x88,0x9A),
- o3(0xE2,0x8A,0xA5), o3(0xE2,0x88,0xA0),
- o3(0xE2,0x88,0x9F), o3(0xE2,0x8A,0xBF),
- o3(0xE2,0x88,0xB5), o3(0xE2,0x88,0xA9),
- o3(0xE2,0x88,0xAA), UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_87 = {
- from_SHIFT_JIS_87_offsets,
- from_SHIFT_JIS_87_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_88_offsets[256] = {
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 94,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_88_infos[95] = {
- /* used from from_SHIFT_JIS_88 */
- /* used from from_EUC_JP_B0 */
- o3(0xE4,0xBA,0x9C), o3(0xE5,0x94,0x96),
- o3(0xE5,0xA8,0x83), o3(0xE9,0x98,0xBF),
- o3(0xE5,0x93,0x80), o3(0xE6,0x84,0x9B),
- o3(0xE6,0x8C,0xA8), o3(0xE5,0xA7,0xB6),
- o3(0xE9,0x80,0xA2), o3(0xE8,0x91,0xB5),
- o3(0xE8,0x8C,0x9C), o3(0xE7,0xA9,0x90),
- o3(0xE6,0x82,0xAA), o3(0xE6,0x8F,0xA1),
- o3(0xE6,0xB8,0xA5), o3(0xE6,0x97,0xAD),
- o3(0xE8,0x91,0xA6), o3(0xE8,0x8A,0xA6),
- o3(0xE9,0xAF,0xB5), o3(0xE6,0xA2,0x93),
- o3(0xE5,0x9C,0xA7), o3(0xE6,0x96,0xA1),
- o3(0xE6,0x89,0xB1), o3(0xE5,0xAE,0x9B),
- o3(0xE5,0xA7,0x90), o3(0xE8,0x99,0xBB),
- o3(0xE9,0xA3,0xB4), o3(0xE7,0xB5,0xA2),
- o3(0xE7,0xB6,0xBE), o3(0xE9,0xAE,0x8E),
- o3(0xE6,0x88,0x96), o3(0xE7,0xB2,0x9F),
- o3(0xE8,0xA2,0xB7), o3(0xE5,0xAE,0x89),
- o3(0xE5,0xBA,0xB5), o3(0xE6,0x8C,0x89),
- o3(0xE6,0x9A,0x97), o3(0xE6,0xA1,0x88),
- o3(0xE9,0x97,0x87), o3(0xE9,0x9E,0x8D),
- o3(0xE6,0x9D,0x8F), o3(0xE4,0xBB,0xA5),
- o3(0xE4,0xBC,0x8A), o3(0xE4,0xBD,0x8D),
- o3(0xE4,0xBE,0x9D), o3(0xE5,0x81,0x89),
- o3(0xE5,0x9B,0xB2), o3(0xE5,0xA4,0xB7),
- o3(0xE5,0xA7,0x94), o3(0xE5,0xA8,0x81),
- o3(0xE5,0xB0,0x89), o3(0xE6,0x83,0x9F),
- o3(0xE6,0x84,0x8F), o3(0xE6,0x85,0xB0),
- o3(0xE6,0x98,0x93), o3(0xE6,0xA4,0x85),
- o3(0xE7,0x82,0xBA), o3(0xE7,0x95,0x8F),
- o3(0xE7,0x95,0xB0), o3(0xE7,0xA7,0xBB),
- o3(0xE7,0xB6,0xAD), o3(0xE7,0xB7,0xAF),
- o3(0xE8,0x83,0x83), o3(0xE8,0x90,0x8E),
- o3(0xE8,0xA1,0xA3), o3(0xE8,0xAC,0x82),
- o3(0xE9,0x81,0x95), o3(0xE9,0x81,0xBA),
- o3(0xE5,0x8C,0xBB), o3(0xE4,0xBA,0x95),
- o3(0xE4,0xBA,0xA5), o3(0xE5,0x9F,0x9F),
- o3(0xE8,0x82,0xB2), o3(0xE9,0x83,0x81),
- o3(0xE7,0xA3,0xAF), o3(0xE4,0xB8,0x80),
- o3(0xE5,0xA3,0xB1), o3(0xE6,0xBA,0xA2),
- o3(0xE9,0x80,0xB8), o3(0xE7,0xA8,0xB2),
- o3(0xE8,0x8C,0xA8), o3(0xE8,0x8A,0x8B),
- o3(0xE9,0xB0,0xAF), o3(0xE5,0x85,0x81),
- o3(0xE5,0x8D,0xB0), o3(0xE5,0x92,0xBD),
- o3(0xE5,0x93,0xA1), o3(0xE5,0x9B,0xA0),
- o3(0xE5,0xA7,0xBB), o3(0xE5,0xBC,0x95),
- o3(0xE9,0xA3,0xB2), o3(0xE6,0xB7,0xAB),
- o3(0xE8,0x83,0xA4), o3(0xE8,0x94,0xAD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_88 = {
- from_SHIFT_JIS_88_offsets,
- from_SHIFT_JIS_88_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_89_offsets[256] = {
- /* used from from_SHIFT_JIS_89 */
- /* used from from_SHIFT_JIS_8A */
- /* used from from_SHIFT_JIS_8B */
- /* used from from_SHIFT_JIS_8C */
- /* used from from_SHIFT_JIS_8D */
- /* used from from_SHIFT_JIS_8E */
- /* used from from_SHIFT_JIS_8F */
- /* used from from_SHIFT_JIS_90 */
- /* used from from_SHIFT_JIS_91 */
- /* used from from_SHIFT_JIS_92 */
- /* used from from_SHIFT_JIS_93 */
- /* used from from_SHIFT_JIS_94 */
- /* used from from_SHIFT_JIS_95 */
- /* used from from_SHIFT_JIS_96 */
- /* used from from_SHIFT_JIS_97 */
- /* used from from_SHIFT_JIS_99 */
- /* used from from_SHIFT_JIS_9A */
- /* used from from_SHIFT_JIS_9B */
- /* used from from_SHIFT_JIS_9C */
- /* used from from_SHIFT_JIS_9D */
- /* used from from_SHIFT_JIS_9E */
- /* used from from_SHIFT_JIS_9F */
- /* used from from_SHIFT_JIS_E0 */
- /* used from from_SHIFT_JIS_E1 */
- /* used from from_SHIFT_JIS_E2 */
- /* used from from_SHIFT_JIS_E3 */
- /* used from from_SHIFT_JIS_E4 */
- /* used from from_SHIFT_JIS_E5 */
- /* used from from_SHIFT_JIS_E6 */
- /* used from from_SHIFT_JIS_E7 */
- /* used from from_SHIFT_JIS_E8 */
- /* used from from_SHIFT_JIS_E9 */
- /* used from from_SHIFT_JIS_FB */
- 188,188,188,188,188,188,188,188, 188,188,188,188,188,188,188,188,
- 188,188,188,188,188,188,188,188, 188,188,188,188,188,188,188,188,
- 188,188,188,188,188,188,188,188, 188,188,188,188,188,188,188,188,
- 188,188,188,188,188,188,188,188, 188,188,188,188,188,188,188,188,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,188,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99,100,101,102, 103,104,105,106,107,108,109,110,
- 111,112,113,114,115,116,117,118, 119,120,121,122,123,124,125,126,
- 127,128,129,130,131,132,133,134, 135,136,137,138,139,140,141,142,
- 143,144,145,146,147,148,149,150, 151,152,153,154,155,156,157,158,
- 159,160,161,162,163,164,165,166, 167,168,169,170,171,172,173,174,
- 175,176,177,178,179,180,181,182, 183,184,185,186,187,188,188,188,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_89_infos[189] = {
- o3(0xE9,0x99,0xA2), o3(0xE9,0x99,0xB0),
- o3(0xE9,0x9A,0xA0), o3(0xE9,0x9F,0xBB),
- o3(0xE5,0x90,0x8B), o3(0xE5,0x8F,0xB3),
- o3(0xE5,0xAE,0x87), o3(0xE7,0x83,0x8F),
- o3(0xE7,0xBE,0xBD), o3(0xE8,0xBF,0x82),
- o3(0xE9,0x9B,0xA8), o3(0xE5,0x8D,0xAF),
- o3(0xE9,0xB5,0x9C), o3(0xE7,0xAA,0xBA),
- o3(0xE4,0xB8,0x91), o3(0xE7,0xA2,0x93),
- o3(0xE8,0x87,0xBC), o3(0xE6,0xB8,0xA6),
- o3(0xE5,0x98,0x98), o3(0xE5,0x94,0x84),
- o3(0xE6,0xAC,0x9D), o3(0xE8,0x94,0x9A),
- o3(0xE9,0xB0,0xBB), o3(0xE5,0xA7,0xA5),
- o3(0xE5,0x8E,0xA9), o3(0xE6,0xB5,0xA6),
- o3(0xE7,0x93,0x9C), o3(0xE9,0x96,0x8F),
- o3(0xE5,0x99,0x82), o3(0xE4,0xBA,0x91),
- o3(0xE9,0x81,0x8B), o3(0xE9,0x9B,0xB2),
- o3(0xE8,0x8D,0x8F), o3(0xE9,0xA4,0x8C),
- o3(0xE5,0x8F,0xA1), o3(0xE5,0x96,0xB6),
- o3(0xE5,0xAC,0xB0), o3(0xE5,0xBD,0xB1),
- o3(0xE6,0x98,0xA0), o3(0xE6,0x9B,0xB3),
- o3(0xE6,0xA0,0x84), o3(0xE6,0xB0,0xB8),
- o3(0xE6,0xB3,0xB3), o3(0xE6,0xB4,0xA9),
- o3(0xE7,0x91,0x9B), o3(0xE7,0x9B,0x88),
- o3(0xE7,0xA9,0x8E), o3(0xE9,0xA0,0xB4),
- o3(0xE8,0x8B,0xB1), o3(0xE8,0xA1,0x9B),
- o3(0xE8,0xA9,0xA0), o3(0xE9,0x8B,0xAD),
- o3(0xE6,0xB6,0xB2), o3(0xE7,0x96,0xAB),
- o3(0xE7,0x9B,0x8A), o3(0xE9,0xA7,0x85),
- o3(0xE6,0x82,0xA6), o3(0xE8,0xAC,0x81),
- o3(0xE8,0xB6,0x8A), o3(0xE9,0x96,0xB2),
- o3(0xE6,0xA6,0x8E), o3(0xE5,0x8E,0xAD),
- o3(0xE5,0x86,0x86), o3(0xE5,0x9C,0x92),
- o3(0xE5,0xA0,0xB0), o3(0xE5,0xA5,0x84),
- o3(0xE5,0xAE,0xB4), o3(0xE5,0xBB,0xB6),
- o3(0xE6,0x80,0xA8), o3(0xE6,0x8E,0xA9),
- o3(0xE6,0x8F,0xB4), o3(0xE6,0xB2,0xBF),
- o3(0xE6,0xBC,0x94), o3(0xE7,0x82,0x8E),
- o3(0xE7,0x84,0x94), o3(0xE7,0x85,0x99),
- o3(0xE7,0x87,0x95), o3(0xE7,0x8C,0xBF),
- o3(0xE7,0xB8,0x81), o3(0xE8,0x89,0xB6),
- o3(0xE8,0x8B,0x91), o3(0xE8,0x96,0x97),
- o3(0xE9,0x81,0xA0), o3(0xE9,0x89,0x9B),
- o3(0xE9,0xB4,0x9B), o3(0xE5,0xA1,0xA9),
- o3(0xE6,0x96,0xBC), o3(0xE6,0xB1,0x9A),
- o3(0xE7,0x94,0xA5), o3(0xE5,0x87,0xB9),
- o3(0xE5,0xA4,0xAE), o3(0xE5,0xA5,0xA5),
- o3(0xE5,0xBE,0x80), o3(0xE5,0xBF,0x9C),
- o3(0xE6,0x8A,0xBC), o3(0xE6,0x97,0xBA),
- o3(0xE6,0xA8,0xAA), o3(0xE6,0xAC,0xA7),
- o3(0xE6,0xAE,0xB4), o3(0xE7,0x8E,0x8B),
- o3(0xE7,0xBF,0x81), o3(0xE8,0xA5,0x96),
- o3(0xE9,0xB4,0xAC), o3(0xE9,0xB4,0x8E),
- o3(0xE9,0xBB,0x84), o3(0xE5,0xB2,0xA1),
- o3(0xE6,0xB2,0x96), o3(0xE8,0x8D,0xBB),
- o3(0xE5,0x84,0x84), o3(0xE5,0xB1,0x8B),
- o3(0xE6,0x86,0xB6), o3(0xE8,0x87,0x86),
- o3(0xE6,0xA1,0xB6), o3(0xE7,0x89,0xA1),
- o3(0xE4,0xB9,0x99), o3(0xE4,0xBF,0xBA),
- o3(0xE5,0x8D,0xB8), o3(0xE6,0x81,0xA9),
- o3(0xE6,0xB8,0xA9), o3(0xE7,0xA9,0x8F),
- o3(0xE9,0x9F,0xB3), o3(0xE4,0xB8,0x8B),
- o3(0xE5,0x8C,0x96), o3(0xE4,0xBB,0xAE),
- o3(0xE4,0xBD,0x95), o3(0xE4,0xBC,0xBD),
- o3(0xE4,0xBE,0xA1), o3(0xE4,0xBD,0xB3),
- o3(0xE5,0x8A,0xA0), o3(0xE5,0x8F,0xAF),
- o3(0xE5,0x98,0x89), o3(0xE5,0xA4,0x8F),
- o3(0xE5,0xAB,0x81), o3(0xE5,0xAE,0xB6),
- o3(0xE5,0xAF,0xA1), o3(0xE7,0xA7,0x91),
- o3(0xE6,0x9A,0x87), o3(0xE6,0x9E,0x9C),
- o3(0xE6,0x9E,0xB6), o3(0xE6,0xAD,0x8C),
- o3(0xE6,0xB2,0xB3), o3(0xE7,0x81,0xAB),
- o3(0xE7,0x8F,0x82), o3(0xE7,0xA6,0x8D),
- o3(0xE7,0xA6,0xBE), o3(0xE7,0xA8,0xBC),
- o3(0xE7,0xAE,0x87), o3(0xE8,0x8A,0xB1),
- o3(0xE8,0x8B,0x9B), o3(0xE8,0x8C,0x84),
- o3(0xE8,0x8D,0xB7), o3(0xE8,0x8F,0xAF),
- o3(0xE8,0x8F,0x93), o3(0xE8,0x9D,0xA6),
- o3(0xE8,0xAA,0xB2), o3(0xE5,0x98,0xA9),
- o3(0xE8,0xB2,0xA8), o3(0xE8,0xBF,0xA6),
- o3(0xE9,0x81,0x8E), o3(0xE9,0x9C,0x9E),
- o3(0xE8,0x9A,0x8A), o3(0xE4,0xBF,0x84),
- o3(0xE5,0xB3,0xA8), o3(0xE6,0x88,0x91),
- o3(0xE7,0x89,0x99), o3(0xE7,0x94,0xBB),
- o3(0xE8,0x87,0xA5), o3(0xE8,0x8A,0xBD),
- o3(0xE8,0x9B,0xBE), o3(0xE8,0xB3,0x80),
- o3(0xE9,0x9B,0x85), o3(0xE9,0xA4,0x93),
- o3(0xE9,0xA7,0x95), o3(0xE4,0xBB,0x8B),
- o3(0xE4,0xBC,0x9A), o3(0xE8,0xA7,0xA3),
- o3(0xE5,0x9B,0x9E), o3(0xE5,0xA1,0x8A),
- o3(0xE5,0xA3,0x8A), o3(0xE5,0xBB,0xBB),
- o3(0xE5,0xBF,0xAB), o3(0xE6,0x80,0xAA),
- o3(0xE6,0x82,0x94), o3(0xE6,0x81,0xA2),
- o3(0xE6,0x87,0x90), o3(0xE6,0x88,0x92),
- o3(0xE6,0x8B,0x90), o3(0xE6,0x94,0xB9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_89 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_89_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_8A_infos[189] = {
- o3(0xE9,0xAD,0x81), o3(0xE6,0x99,0xA6),
- o3(0xE6,0xA2,0xB0), o3(0xE6,0xB5,0xB7),
- o3(0xE7,0x81,0xB0), o3(0xE7,0x95,0x8C),
- o3(0xE7,0x9A,0x86), o3(0xE7,0xB5,0xB5),
- o3(0xE8,0x8A,0xA5), o3(0xE8,0x9F,0xB9),
- o3(0xE9,0x96,0x8B), o3(0xE9,0x9A,0x8E),
- o3(0xE8,0xB2,0x9D), o3(0xE5,0x87,0xB1),
- o3(0xE5,0x8A,0xBE), o3(0xE5,0xA4,0x96),
- o3(0xE5,0x92,0xB3), o3(0xE5,0xAE,0xB3),
- o3(0xE5,0xB4,0x96), o3(0xE6,0x85,0xA8),
- o3(0xE6,0xA6,0x82), o3(0xE6,0xB6,0xAF),
- o3(0xE7,0xA2,0x8D), o3(0xE8,0x93,0x8B),
- o3(0xE8,0xA1,0x97), o3(0xE8,0xA9,0xB2),
- o3(0xE9,0x8E,0xA7), o3(0xE9,0xAA,0xB8),
- o3(0xE6,0xB5,0xAC), o3(0xE9,0xA6,0xA8),
- o3(0xE8,0x9B,0x99), o3(0xE5,0x9E,0xA3),
- o3(0xE6,0x9F,0xBF), o3(0xE8,0x9B,0x8E),
- o3(0xE9,0x88,0x8E), o3(0xE5,0x8A,0x83),
- o3(0xE5,0x9A,0x87), o3(0xE5,0x90,0x84),
- o3(0xE5,0xBB,0x93), o3(0xE6,0x8B,0xA1),
- o3(0xE6,0x92,0xB9), o3(0xE6,0xA0,0xBC),
- o3(0xE6,0xA0,0xB8), o3(0xE6,0xAE,0xBB),
- o3(0xE7,0x8D,0xB2), o3(0xE7,0xA2,0xBA),
- o3(0xE7,0xA9,0xAB), o3(0xE8,0xA6,0x9A),
- o3(0xE8,0xA7,0x92), o3(0xE8,0xB5,0xAB),
- o3(0xE8,0xBC,0x83), o3(0xE9,0x83,0xAD),
- o3(0xE9,0x96,0xA3), o3(0xE9,0x9A,0x94),
- o3(0xE9,0x9D,0xA9), o3(0xE5,0xAD,0xA6),
- o3(0xE5,0xB2,0xB3), o3(0xE6,0xA5,0xBD),
- o3(0xE9,0xA1,0x8D), o3(0xE9,0xA1,0x8E),
- o3(0xE6,0x8E,0x9B), o3(0xE7,0xAC,0xA0),
- o3(0xE6,0xA8,0xAB), o3(0xE6,0xA9,0xBF),
- o3(0xE6,0xA2,0xB6), o3(0xE9,0xB0,0x8D),
- o3(0xE6,0xBD,0x9F), o3(0xE5,0x89,0xB2),
- o3(0xE5,0x96,0x9D), o3(0xE6,0x81,0xB0),
- o3(0xE6,0x8B,0xAC), o3(0xE6,0xB4,0xBB),
- o3(0xE6,0xB8,0x87), o3(0xE6,0xBB,0x91),
- o3(0xE8,0x91,0x9B), o3(0xE8,0xA4,0x90),
- o3(0xE8,0xBD,0x84), o3(0xE4,0xB8,0x94),
- o3(0xE9,0xB0,0xB9), o3(0xE5,0x8F,0xB6),
- o3(0xE6,0xA4,0x9B), o3(0xE6,0xA8,0xBA),
- o3(0xE9,0x9E,0x84), o3(0xE6,0xA0,0xAA),
- o3(0xE5,0x85,0x9C), o3(0xE7,0xAB,0x83),
- o3(0xE8,0x92,0xB2), o3(0xE9,0x87,0x9C),
- o3(0xE9,0x8E,0x8C), o3(0xE5,0x99,0x9B),
- o3(0xE9,0xB4,0xA8), o3(0xE6,0xA0,0xA2),
- o3(0xE8,0x8C,0x85), o3(0xE8,0x90,0xB1),
- o3(0xE7,0xB2,0xA5), o3(0xE5,0x88,0x88),
- o3(0xE8,0x8B,0x85), o3(0xE7,0x93,0xA6),
- o3(0xE4,0xB9,0xBE), o3(0xE4,0xBE,0x83),
- o3(0xE5,0x86,0xA0), o3(0xE5,0xAF,0x92),
- o3(0xE5,0x88,0x8A), o3(0xE5,0x8B,0x98),
- o3(0xE5,0x8B,0xA7), o3(0xE5,0xB7,0xBB),
- o3(0xE5,0x96,0x9A), o3(0xE5,0xA0,0xAA),
- o3(0xE5,0xA7,0xA6), o3(0xE5,0xAE,0x8C),
- o3(0xE5,0xAE,0x98), o3(0xE5,0xAF,0x9B),
- o3(0xE5,0xB9,0xB2), o3(0xE5,0xB9,0xB9),
- o3(0xE6,0x82,0xA3), o3(0xE6,0x84,0x9F),
- o3(0xE6,0x85,0xA3), o3(0xE6,0x86,0xBE),
- o3(0xE6,0x8F,0x9B), o3(0xE6,0x95,0xA2),
- o3(0xE6,0x9F,0x91), o3(0xE6,0xA1,0x93),
- o3(0xE6,0xA3,0xBA), o3(0xE6,0xAC,0xBE),
- o3(0xE6,0xAD,0x93), o3(0xE6,0xB1,0x97),
- o3(0xE6,0xBC,0xA2), o3(0xE6,0xBE,0x97),
- o3(0xE6,0xBD,0x85), o3(0xE7,0x92,0xB0),
- o3(0xE7,0x94,0x98), o3(0xE7,0x9B,0xA3),
- o3(0xE7,0x9C,0x8B), o3(0xE7,0xAB,0xBF),
- o3(0xE7,0xAE,0xA1), o3(0xE7,0xB0,0xA1),
- o3(0xE7,0xB7,0xA9), o3(0xE7,0xBC,0xB6),
- o3(0xE7,0xBF,0xB0), o3(0xE8,0x82,0x9D),
- o3(0xE8,0x89,0xA6), o3(0xE8,0x8E,0x9E),
- o3(0xE8,0xA6,0xB3), o3(0xE8,0xAB,0x8C),
- o3(0xE8,0xB2,0xAB), o3(0xE9,0x82,0x84),
- o3(0xE9,0x91,0x91), o3(0xE9,0x96,0x93),
- o3(0xE9,0x96,0x91), o3(0xE9,0x96,0xA2),
- o3(0xE9,0x99,0xA5), o3(0xE9,0x9F,0x93),
- o3(0xE9,0xA4,0xA8), o3(0xE8,0x88,0x98),
- o3(0xE4,0xB8,0xB8), o3(0xE5,0x90,0xAB),
- o3(0xE5,0xB2,0xB8), o3(0xE5,0xB7,0x8C),
- o3(0xE7,0x8E,0xA9), o3(0xE7,0x99,0x8C),
- o3(0xE7,0x9C,0xBC), o3(0xE5,0xB2,0xA9),
- o3(0xE7,0xBF,0xAB), o3(0xE8,0xB4,0x8B),
- o3(0xE9,0x9B,0x81), o3(0xE9,0xA0,0x91),
- o3(0xE9,0xA1,0x94), o3(0xE9,0xA1,0x98),
- o3(0xE4,0xBC,0x81), o3(0xE4,0xBC,0x8E),
- o3(0xE5,0x8D,0xB1), o3(0xE5,0x96,0x9C),
- o3(0xE5,0x99,0xA8), o3(0xE5,0x9F,0xBA),
- o3(0xE5,0xA5,0x87), o3(0xE5,0xAC,0x89),
- o3(0xE5,0xAF,0x84), o3(0xE5,0xB2,0x90),
- o3(0xE5,0xB8,0x8C), o3(0xE5,0xB9,0xBE),
- o3(0xE5,0xBF,0x8C), o3(0xE6,0x8F,0xAE),
- o3(0xE6,0x9C,0xBA), o3(0xE6,0x97,0x97),
- o3(0xE6,0x97,0xA2), o3(0xE6,0x9C,0x9F),
- o3(0xE6,0xA3,0x8B), o3(0xE6,0xA3,0x84),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_8A = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_8A_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_8B_infos[189] = {
- o3(0xE6,0xA9,0x9F), o3(0xE5,0xB8,0xB0),
- o3(0xE6,0xAF,0x85), o3(0xE6,0xB0,0x97),
- o3(0xE6,0xB1,0xBD), o3(0xE7,0x95,0xBF),
- o3(0xE7,0xA5,0x88), o3(0xE5,0xAD,0xA3),
- o3(0xE7,0xA8,0x80), o3(0xE7,0xB4,0x80),
- o3(0xE5,0xBE,0xBD), o3(0xE8,0xA6,0x8F),
- o3(0xE8,0xA8,0x98), o3(0xE8,0xB2,0xB4),
- o3(0xE8,0xB5,0xB7), o3(0xE8,0xBB,0x8C),
- o3(0xE8,0xBC,0x9D), o3(0xE9,0xA3,0xA2),
- o3(0xE9,0xA8,0x8E), o3(0xE9,0xAC,0xBC),
- o3(0xE4,0xBA,0x80), o3(0xE5,0x81,0xBD),
- o3(0xE5,0x84,0x80), o3(0xE5,0xA6,0x93),
- o3(0xE5,0xAE,0x9C), o3(0xE6,0x88,0xAF),
- o3(0xE6,0x8A,0x80), o3(0xE6,0x93,0xAC),
- o3(0xE6,0xAC,0xBA), o3(0xE7,0x8A,0xA0),
- o3(0xE7,0x96,0x91), o3(0xE7,0xA5,0x87),
- o3(0xE7,0xBE,0xA9), o3(0xE8,0x9F,0xBB),
- o3(0xE8,0xAA,0xBC), o3(0xE8,0xAD,0xB0),
- o3(0xE6,0x8E,0xAC), o3(0xE8,0x8F,0x8A),
- o3(0xE9,0x9E,0xA0), o3(0xE5,0x90,0x89),
- o3(0xE5,0x90,0x83), o3(0xE5,0x96,0xAB),
- o3(0xE6,0xA1,0x94), o3(0xE6,0xA9,0x98),
- o3(0xE8,0xA9,0xB0), o3(0xE7,0xA0,0xA7),
- o3(0xE6,0x9D,0xB5), o3(0xE9,0xBB,0x8D),
- o3(0xE5,0x8D,0xB4), o3(0xE5,0xAE,0xA2),
- o3(0xE8,0x84,0x9A), o3(0xE8,0x99,0x90),
- o3(0xE9,0x80,0x86), o3(0xE4,0xB8,0x98),
- o3(0xE4,0xB9,0x85), o3(0xE4,0xBB,0x87),
- o3(0xE4,0xBC,0x91), o3(0xE5,0x8F,0x8A),
- o3(0xE5,0x90,0xB8), o3(0xE5,0xAE,0xAE),
- o3(0xE5,0xBC,0x93), o3(0xE6,0x80,0xA5),
- o3(0xE6,0x95,0x91), o3(0xE6,0x9C,0xBD),
- o3(0xE6,0xB1,0x82), o3(0xE6,0xB1,0xB2),
- o3(0xE6,0xB3,0xA3), o3(0xE7,0x81,0xB8),
- o3(0xE7,0x90,0x83), o3(0xE7,0xA9,0xB6),
- o3(0xE7,0xAA,0xAE), o3(0xE7,0xAC,0x88),
- o3(0xE7,0xB4,0x9A), o3(0xE7,0xB3,0xBE),
- o3(0xE7,0xB5,0xA6), o3(0xE6,0x97,0xA7),
- o3(0xE7,0x89,0x9B), o3(0xE5,0x8E,0xBB),
- o3(0xE5,0xB1,0x85), o3(0xE5,0xB7,0xA8),
- o3(0xE6,0x8B,0x92), o3(0xE6,0x8B,0xA0),
- o3(0xE6,0x8C,0x99), o3(0xE6,0xB8,0xA0),
- o3(0xE8,0x99,0x9A), o3(0xE8,0xA8,0xB1),
- o3(0xE8,0xB7,0x9D), o3(0xE9,0x8B,0xB8),
- o3(0xE6,0xBC,0x81), o3(0xE7,0xA6,0xA6),
- o3(0xE9,0xAD,0x9A), o3(0xE4,0xBA,0xA8),
- o3(0xE4,0xBA,0xAB), o3(0xE4,0xBA,0xAC),
- o3(0xE4,0xBE,0x9B), o3(0xE4,0xBE,0xA0),
- o3(0xE5,0x83,0x91), o3(0xE5,0x85,0x87),
- o3(0xE7,0xAB,0xB6), o3(0xE5,0x85,0xB1),
- o3(0xE5,0x87,0xB6), o3(0xE5,0x8D,0x94),
- o3(0xE5,0x8C,0xA1), o3(0xE5,0x8D,0xBF),
- o3(0xE5,0x8F,0xAB), o3(0xE5,0x96,0xAC),
- o3(0xE5,0xA2,0x83), o3(0xE5,0xB3,0xA1),
- o3(0xE5,0xBC,0xB7), o3(0xE5,0xBD,0x8A),
- o3(0xE6,0x80,0xAF), o3(0xE6,0x81,0x90),
- o3(0xE6,0x81,0xAD), o3(0xE6,0x8C,0x9F),
- o3(0xE6,0x95,0x99), o3(0xE6,0xA9,0x8B),
- o3(0xE6,0xB3,0x81), o3(0xE7,0x8B,0x82),
- o3(0xE7,0x8B,0xAD), o3(0xE7,0x9F,0xAF),
- o3(0xE8,0x83,0xB8), o3(0xE8,0x84,0x85),
- o3(0xE8,0x88,0x88), o3(0xE8,0x95,0x8E),
- o3(0xE9,0x83,0xB7), o3(0xE9,0x8F,0xA1),
- o3(0xE9,0x9F,0xBF), o3(0xE9,0xA5,0x97),
- o3(0xE9,0xA9,0x9A), o3(0xE4,0xBB,0xB0),
- o3(0xE5,0x87,0x9D), o3(0xE5,0xB0,0xAD),
- o3(0xE6,0x9A,0x81), o3(0xE6,0xA5,0xAD),
- o3(0xE5,0xB1,0x80), o3(0xE6,0x9B,0xB2),
- o3(0xE6,0xA5,0xB5), o3(0xE7,0x8E,0x89),
- o3(0xE6,0xA1,0x90), o3(0xE7,0xB2,0x81),
- o3(0xE5,0x83,0x85), o3(0xE5,0x8B,0xA4),
- o3(0xE5,0x9D,0x87), o3(0xE5,0xB7,0xBE),
- o3(0xE9,0x8C,0xA6), o3(0xE6,0x96,0xA4),
- o3(0xE6,0xAC,0xA3), o3(0xE6,0xAC,0xBD),
- o3(0xE7,0x90,0xB4), o3(0xE7,0xA6,0x81),
- o3(0xE7,0xA6,0xBD), o3(0xE7,0xAD,0x8B),
- o3(0xE7,0xB7,0x8A), o3(0xE8,0x8A,0xB9),
- o3(0xE8,0x8F,0x8C), o3(0xE8,0xA1,0xBF),
- o3(0xE8,0xA5,0x9F), o3(0xE8,0xAC,0xB9),
- o3(0xE8,0xBF,0x91), o3(0xE9,0x87,0x91),
- o3(0xE5,0x90,0x9F), o3(0xE9,0x8A,0x80),
- o3(0xE4,0xB9,0x9D), o3(0xE5,0x80,0xB6),
- o3(0xE5,0x8F,0xA5), o3(0xE5,0x8C,0xBA),
- o3(0xE7,0x8B,0x97), o3(0xE7,0x8E,0x96),
- o3(0xE7,0x9F,0xA9), o3(0xE8,0x8B,0xA6),
- o3(0xE8,0xBA,0xAF), o3(0xE9,0xA7,0x86),
- o3(0xE9,0xA7,0x88), o3(0xE9,0xA7,0x92),
- o3(0xE5,0x85,0xB7), o3(0xE6,0x84,0x9A),
- o3(0xE8,0x99,0x9E), o3(0xE5,0x96,0xB0),
- o3(0xE7,0xA9,0xBA), o3(0xE5,0x81,0xB6),
- o3(0xE5,0xAF,0x93), o3(0xE9,0x81,0x87),
- o3(0xE9,0x9A,0x85), o3(0xE4,0xB8,0xB2),
- o3(0xE6,0xAB,0x9B), o3(0xE9,0x87,0xA7),
- o3(0xE5,0xB1,0x91), o3(0xE5,0xB1,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_8B = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_8B_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_8C_infos[189] = {
- o3(0xE6,0x8E,0x98), o3(0xE7,0xAA,0x9F),
- o3(0xE6,0xB2,0x93), o3(0xE9,0x9D,0xB4),
- o3(0xE8,0xBD,0xA1), o3(0xE7,0xAA,0xAA),
- o3(0xE7,0x86,0x8A), o3(0xE9,0x9A,0x88),
- o3(0xE7,0xB2,0x82), o3(0xE6,0xA0,0x97),
- o3(0xE7,0xB9,0xB0), o3(0xE6,0xA1,0x91),
- o3(0xE9,0x8D,0xAC), o3(0xE5,0x8B,0xB2),
- o3(0xE5,0x90,0x9B), o3(0xE8,0x96,0xAB),
- o3(0xE8,0xA8,0x93), o3(0xE7,0xBE,0xA4),
- o3(0xE8,0xBB,0x8D), o3(0xE9,0x83,0xA1),
- o3(0xE5,0x8D,0xA6), o3(0xE8,0xA2,0x88),
- o3(0xE7,0xA5,0x81), o3(0xE4,0xBF,0x82),
- o3(0xE5,0x82,0xBE), o3(0xE5,0x88,0x91),
- o3(0xE5,0x85,0x84), o3(0xE5,0x95,0x93),
- o3(0xE5,0x9C,0xAD), o3(0xE7,0x8F,0xAA),
- o3(0xE5,0x9E,0x8B), o3(0xE5,0xA5,0x91),
- o3(0xE5,0xBD,0xA2), o3(0xE5,0xBE,0x84),
- o3(0xE6,0x81,0xB5), o3(0xE6,0x85,0xB6),
- o3(0xE6,0x85,0xA7), o3(0xE6,0x86,0xA9),
- o3(0xE6,0x8E,0xB2), o3(0xE6,0x90,0xBA),
- o3(0xE6,0x95,0xAC), o3(0xE6,0x99,0xAF),
- o3(0xE6,0xA1,0x82), o3(0xE6,0xB8,0x93),
- o3(0xE7,0x95,0xA6), o3(0xE7,0xA8,0xBD),
- o3(0xE7,0xB3,0xBB), o3(0xE7,0xB5,0x8C),
- o3(0xE7,0xB6,0x99), o3(0xE7,0xB9,0x8B),
- o3(0xE7,0xBD,0xAB), o3(0xE8,0x8C,0x8E),
- o3(0xE8,0x8D,0x8A), o3(0xE8,0x9B,0x8D),
- o3(0xE8,0xA8,0x88), o3(0xE8,0xA9,0xA3),
- o3(0xE8,0xAD,0xA6), o3(0xE8,0xBB,0xBD),
- o3(0xE9,0xA0,0x9A), o3(0xE9,0xB6,0x8F),
- o3(0xE8,0x8A,0xB8), o3(0xE8,0xBF,0x8E),
- o3(0xE9,0xAF,0xA8), o3(0xE5,0x8A,0x87),
- o3(0xE6,0x88,0x9F), o3(0xE6,0x92,0x83),
- o3(0xE6,0xBF,0x80), o3(0xE9,0x9A,0x99),
- o3(0xE6,0xA1,0x81), o3(0xE5,0x82,0x91),
- o3(0xE6,0xAC,0xA0), o3(0xE6,0xB1,0xBA),
- o3(0xE6,0xBD,0x94), o3(0xE7,0xA9,0xB4),
- o3(0xE7,0xB5,0x90), o3(0xE8,0xA1,0x80),
- o3(0xE8,0xA8,0xA3), o3(0xE6,0x9C,0x88),
- o3(0xE4,0xBB,0xB6), o3(0xE5,0x80,0xB9),
- o3(0xE5,0x80,0xA6), o3(0xE5,0x81,0xA5),
- o3(0xE5,0x85,0xBC), o3(0xE5,0x88,0xB8),
- o3(0xE5,0x89,0xA3), o3(0xE5,0x96,0xA7),
- o3(0xE5,0x9C,0x8F), o3(0xE5,0xA0,0x85),
- o3(0xE5,0xAB,0x8C), o3(0xE5,0xBB,0xBA),
- o3(0xE6,0x86,0xB2), o3(0xE6,0x87,0xB8),
- o3(0xE6,0x8B,0xB3), o3(0xE6,0x8D,0xB2),
- o3(0xE6,0xA4,0x9C), o3(0xE6,0xA8,0xA9),
- o3(0xE7,0x89,0xBD), o3(0xE7,0x8A,0xAC),
- o3(0xE7,0x8C,0xAE), o3(0xE7,0xA0,0x94),
- o3(0xE7,0xA1,0xAF), o3(0xE7,0xB5,0xB9),
- o3(0xE7,0x9C,0x8C), o3(0xE8,0x82,0xA9),
- o3(0xE8,0xA6,0x8B), o3(0xE8,0xAC,0x99),
- o3(0xE8,0xB3,0xA2), o3(0xE8,0xBB,0x92),
- o3(0xE9,0x81,0xA3), o3(0xE9,0x8D,0xB5),
- o3(0xE9,0x99,0xBA), o3(0xE9,0xA1,0x95),
- o3(0xE9,0xA8,0x93), o3(0xE9,0xB9,0xB8),
- o3(0xE5,0x85,0x83), o3(0xE5,0x8E,0x9F),
- o3(0xE5,0x8E,0xB3), o3(0xE5,0xB9,0xBB),
- o3(0xE5,0xBC,0xA6), o3(0xE6,0xB8,0x9B),
- o3(0xE6,0xBA,0x90), o3(0xE7,0x8E,0x84),
- o3(0xE7,0x8F,0xBE), o3(0xE7,0xB5,0x83),
- o3(0xE8,0x88,0xB7), o3(0xE8,0xA8,0x80),
- o3(0xE8,0xAB,0xBA), o3(0xE9,0x99,0x90),
- o3(0xE4,0xB9,0x8E), o3(0xE5,0x80,0x8B),
- o3(0xE5,0x8F,0xA4), o3(0xE5,0x91,0xBC),
- o3(0xE5,0x9B,0xBA), o3(0xE5,0xA7,0x91),
- o3(0xE5,0xAD,0xA4), o3(0xE5,0xB7,0xB1),
- o3(0xE5,0xBA,0xAB), o3(0xE5,0xBC,0xA7),
- o3(0xE6,0x88,0xB8), o3(0xE6,0x95,0x85),
- o3(0xE6,0x9E,0xAF), o3(0xE6,0xB9,0x96),
- o3(0xE7,0x8B,0x90), o3(0xE7,0xB3,0x8A),
- o3(0xE8,0xA2,0xB4), o3(0xE8,0x82,0xA1),
- o3(0xE8,0x83,0xA1), o3(0xE8,0x8F,0xB0),
- o3(0xE8,0x99,0x8E), o3(0xE8,0xAA,0x87),
- o3(0xE8,0xB7,0xA8), o3(0xE9,0x88,0xB7),
- o3(0xE9,0x9B,0x87), o3(0xE9,0xA1,0xA7),
- o3(0xE9,0xBC,0x93), o3(0xE4,0xBA,0x94),
- o3(0xE4,0xBA,0x92), o3(0xE4,0xBC,0x8D),
- o3(0xE5,0x8D,0x88), o3(0xE5,0x91,0x89),
- o3(0xE5,0x90,0xBE), o3(0xE5,0xA8,0xAF),
- o3(0xE5,0xBE,0x8C), o3(0xE5,0xBE,0xA1),
- o3(0xE6,0x82,0x9F), o3(0xE6,0xA2,0xA7),
- o3(0xE6,0xAA,0x8E), o3(0xE7,0x91,0x9A),
- o3(0xE7,0xA2,0x81), o3(0xE8,0xAA,0x9E),
- o3(0xE8,0xAA,0xA4), o3(0xE8,0xAD,0xB7),
- o3(0xE9,0x86,0x90), o3(0xE4,0xB9,0x9E),
- o3(0xE9,0xAF,0x89), o3(0xE4,0xBA,0xA4),
- o3(0xE4,0xBD,0xBC), o3(0xE4,0xBE,0xAF),
- o3(0xE5,0x80,0x99), o3(0xE5,0x80,0x96),
- o3(0xE5,0x85,0x89), o3(0xE5,0x85,0xAC),
- o3(0xE5,0x8A,0x9F), o3(0xE5,0x8A,0xB9),
- o3(0xE5,0x8B,0xBE), o3(0xE5,0x8E,0x9A),
- o3(0xE5,0x8F,0xA3), o3(0xE5,0x90,0x91),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_8C = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_8C_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_8D_infos[189] = {
- o3(0xE5,0x90,0x8E), o3(0xE5,0x96,0x89),
- o3(0xE5,0x9D,0x91), o3(0xE5,0x9E,0xA2),
- o3(0xE5,0xA5,0xBD), o3(0xE5,0xAD,0x94),
- o3(0xE5,0xAD,0x9D), o3(0xE5,0xAE,0x8F),
- o3(0xE5,0xB7,0xA5), o3(0xE5,0xB7,0xA7),
- o3(0xE5,0xB7,0xB7), o3(0xE5,0xB9,0xB8),
- o3(0xE5,0xBA,0x83), o3(0xE5,0xBA,0x9A),
- o3(0xE5,0xBA,0xB7), o3(0xE5,0xBC,0x98),
- o3(0xE6,0x81,0x92), o3(0xE6,0x85,0x8C),
- o3(0xE6,0x8A,0x97), o3(0xE6,0x8B,0x98),
- o3(0xE6,0x8E,0xA7), o3(0xE6,0x94,0xBB),
- o3(0xE6,0x98,0x82), o3(0xE6,0x99,0x83),
- o3(0xE6,0x9B,0xB4), o3(0xE6,0x9D,0xAD),
- o3(0xE6,0xA0,0xA1), o3(0xE6,0xA2,0x97),
- o3(0xE6,0xA7,0x8B), o3(0xE6,0xB1,0x9F),
- o3(0xE6,0xB4,0xAA), o3(0xE6,0xB5,0xA9),
- o3(0xE6,0xB8,0xAF), o3(0xE6,0xBA,0x9D),
- o3(0xE7,0x94,0xB2), o3(0xE7,0x9A,0x87),
- o3(0xE7,0xA1,0xAC), o3(0xE7,0xA8,0xBF),
- o3(0xE7,0xB3,0xA0), o3(0xE7,0xB4,0x85),
- o3(0xE7,0xB4,0x98), o3(0xE7,0xB5,0x9E),
- o3(0xE7,0xB6,0xB1), o3(0xE8,0x80,0x95),
- o3(0xE8,0x80,0x83), o3(0xE8,0x82,0xAF),
- o3(0xE8,0x82,0xB1), o3(0xE8,0x85,0x94),
- o3(0xE8,0x86,0x8F), o3(0xE8,0x88,0xAA),
- o3(0xE8,0x8D,0x92), o3(0xE8,0xA1,0x8C),
- o3(0xE8,0xA1,0xA1), o3(0xE8,0xAC,0x9B),
- o3(0xE8,0xB2,0xA2), o3(0xE8,0xB3,0xBC),
- o3(0xE9,0x83,0x8A), o3(0xE9,0x85,0xB5),
- o3(0xE9,0x89,0xB1), o3(0xE7,0xA0,0xBF),
- o3(0xE9,0x8B,0xBC), o3(0xE9,0x96,0xA4),
- o3(0xE9,0x99,0x8D), o3(0xE9,0xA0,0x85),
- o3(0xE9,0xA6,0x99), o3(0xE9,0xAB,0x98),
- o3(0xE9,0xB4,0xBB), o3(0xE5,0x89,0x9B),
- o3(0xE5,0x8A,0xAB), o3(0xE5,0x8F,0xB7),
- o3(0xE5,0x90,0x88), o3(0xE5,0xA3,0x95),
- o3(0xE6,0x8B,0xB7), o3(0xE6,0xBF,0xA0),
- o3(0xE8,0xB1,0xAA), o3(0xE8,0xBD,0x9F),
- o3(0xE9,0xBA,0xB9), o3(0xE5,0x85,0x8B),
- o3(0xE5,0x88,0xBB), o3(0xE5,0x91,0x8A),
- o3(0xE5,0x9B,0xBD), o3(0xE7,0xA9,0x80),
- o3(0xE9,0x85,0xB7), o3(0xE9,0xB5,0xA0),
- o3(0xE9,0xBB,0x92), o3(0xE7,0x8D,0x84),
- o3(0xE6,0xBC,0x89), o3(0xE8,0x85,0xB0),
- o3(0xE7,0x94,0x91), o3(0xE5,0xBF,0xBD),
- o3(0xE6,0x83,0x9A), o3(0xE9,0xAA,0xA8),
- o3(0xE7,0x8B,0x9B), o3(0xE8,0xBE,0xBC),
- o3(0xE6,0xAD,0xA4), o3(0xE9,0xA0,0x83),
- o3(0xE4,0xBB,0x8A), o3(0xE5,0x9B,0xB0),
- o3(0xE5,0x9D,0xA4), o3(0xE5,0xA2,0xBE),
- o3(0xE5,0xA9,0x9A), o3(0xE6,0x81,0xA8),
- o3(0xE6,0x87,0x87), o3(0xE6,0x98,0x8F),
- o3(0xE6,0x98,0x86), o3(0xE6,0xA0,0xB9),
- o3(0xE6,0xA2,0xB1), o3(0xE6,0xB7,0xB7),
- o3(0xE7,0x97,0x95), o3(0xE7,0xB4,0xBA),
- o3(0xE8,0x89,0xAE), o3(0xE9,0xAD,0x82),
- o3(0xE4,0xBA,0x9B), o3(0xE4,0xBD,0x90),
- o3(0xE5,0x8F,0x89), o3(0xE5,0x94,0x86),
- o3(0xE5,0xB5,0xAF), o3(0xE5,0xB7,0xA6),
- o3(0xE5,0xB7,0xAE), o3(0xE6,0x9F,0xBB),
- o3(0xE6,0xB2,0x99), o3(0xE7,0x91,0xB3),
- o3(0xE7,0xA0,0x82), o3(0xE8,0xA9,0x90),
- o3(0xE9,0x8E,0x96), o3(0xE8,0xA3,0x9F),
- o3(0xE5,0x9D,0x90), o3(0xE5,0xBA,0xA7),
- o3(0xE6,0x8C,0xAB), o3(0xE5,0x82,0xB5),
- o3(0xE5,0x82,0xAC), o3(0xE5,0x86,0x8D),
- o3(0xE6,0x9C,0x80), o3(0xE5,0x93,0x89),
- o3(0xE5,0xA1,0x9E), o3(0xE5,0xA6,0xBB),
- o3(0xE5,0xAE,0xB0), o3(0xE5,0xBD,0xA9),
- o3(0xE6,0x89,0x8D), o3(0xE6,0x8E,0xA1),
- o3(0xE6,0xA0,0xBD), o3(0xE6,0xAD,0xB3),
- o3(0xE6,0xB8,0x88), o3(0xE7,0x81,0xBD),
- o3(0xE9,0x87,0x87), o3(0xE7,0x8A,0x80),
- o3(0xE7,0xA0,0x95), o3(0xE7,0xA0,0xA6),
- o3(0xE7,0xA5,0xAD), o3(0xE6,0x96,0x8E),
- o3(0xE7,0xB4,0xB0), o3(0xE8,0x8F,0x9C),
- o3(0xE8,0xA3,0x81), o3(0xE8,0xBC,0x89),
- o3(0xE9,0x9A,0x9B), o3(0xE5,0x89,0xA4),
- o3(0xE5,0x9C,0xA8), o3(0xE6,0x9D,0x90),
- o3(0xE7,0xBD,0xAA), o3(0xE8,0xB2,0xA1),
- o3(0xE5,0x86,0xB4), o3(0xE5,0x9D,0x82),
- o3(0xE9,0x98,0xAA), o3(0xE5,0xA0,0xBA),
- o3(0xE6,0xA6,0x8A), o3(0xE8,0x82,0xB4),
- o3(0xE5,0x92,0xB2), o3(0xE5,0xB4,0x8E),
- o3(0xE5,0x9F,0xBC), o3(0xE7,0xA2,0x95),
- o3(0xE9,0xB7,0xBA), o3(0xE4,0xBD,0x9C),
- o3(0xE5,0x89,0x8A), o3(0xE5,0x92,0x8B),
- o3(0xE6,0x90,0xBE), o3(0xE6,0x98,0xA8),
- o3(0xE6,0x9C,0x94), o3(0xE6,0x9F,0xB5),
- o3(0xE7,0xAA,0x84), o3(0xE7,0xAD,0x96),
- o3(0xE7,0xB4,0xA2), o3(0xE9,0x8C,0xAF),
- o3(0xE6,0xA1,0x9C), o3(0xE9,0xAE,0xAD),
- o3(0xE7,0xAC,0xB9), o3(0xE5,0x8C,0x99),
- o3(0xE5,0x86,0x8A), o3(0xE5,0x88,0xB7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_8D = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_8D_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_8E_infos[189] = {
- o3(0xE5,0xAF,0x9F), o3(0xE6,0x8B,0xB6),
- o3(0xE6,0x92,0xAE), o3(0xE6,0x93,0xA6),
- o3(0xE6,0x9C,0xAD), o3(0xE6,0xAE,0xBA),
- o3(0xE8,0x96,0xA9), o3(0xE9,0x9B,0x91),
- o3(0xE7,0x9A,0x90), o3(0xE9,0xAF,0x96),
- o3(0xE6,0x8D,0x8C), o3(0xE9,0x8C,0x86),
- o3(0xE9,0xAE,0xAB), o3(0xE7,0x9A,0xBF),
- o3(0xE6,0x99,0x92), o3(0xE4,0xB8,0x89),
- o3(0xE5,0x82,0x98), o3(0xE5,0x8F,0x82),
- o3(0xE5,0xB1,0xB1), o3(0xE6,0x83,0xA8),
- o3(0xE6,0x92,0x92), o3(0xE6,0x95,0xA3),
- o3(0xE6,0xA1,0x9F), o3(0xE7,0x87,0xA6),
- o3(0xE7,0x8F,0x8A), o3(0xE7,0x94,0xA3),
- o3(0xE7,0xAE,0x97), o3(0xE7,0xBA,0x82),
- o3(0xE8,0x9A,0x95), o3(0xE8,0xAE,0x83),
- o3(0xE8,0xB3,0x9B), o3(0xE9,0x85,0xB8),
- o3(0xE9,0xA4,0x90), o3(0xE6,0x96,0xAC),
- o3(0xE6,0x9A,0xAB), o3(0xE6,0xAE,0x8B),
- o3(0xE4,0xBB,0x95), o3(0xE4,0xBB,0x94),
- o3(0xE4,0xBC,0xBA), o3(0xE4,0xBD,0xBF),
- o3(0xE5,0x88,0xBA), o3(0xE5,0x8F,0xB8),
- o3(0xE5,0x8F,0xB2), o3(0xE5,0x97,0xA3),
- o3(0xE5,0x9B,0x9B), o3(0xE5,0xA3,0xAB),
- o3(0xE5,0xA7,0x8B), o3(0xE5,0xA7,0x89),
- o3(0xE5,0xA7,0xBF), o3(0xE5,0xAD,0x90),
- o3(0xE5,0xB1,0x8D), o3(0xE5,0xB8,0x82),
- o3(0xE5,0xB8,0xAB), o3(0xE5,0xBF,0x97),
- o3(0xE6,0x80,0x9D), o3(0xE6,0x8C,0x87),
- o3(0xE6,0x94,0xAF), o3(0xE5,0xAD,0x9C),
- o3(0xE6,0x96,0xAF), o3(0xE6,0x96,0xBD),
- o3(0xE6,0x97,0xA8), o3(0xE6,0x9E,0x9D),
- o3(0xE6,0xAD,0xA2), o3(0xE6,0xAD,0xBB),
- o3(0xE6,0xB0,0x8F), o3(0xE7,0x8D,0x85),
- o3(0xE7,0xA5,0x89), o3(0xE7,0xA7,0x81),
- o3(0xE7,0xB3,0xB8), o3(0xE7,0xB4,0x99),
- o3(0xE7,0xB4,0xAB), o3(0xE8,0x82,0xA2),
- o3(0xE8,0x84,0x82), o3(0xE8,0x87,0xB3),
- o3(0xE8,0xA6,0x96), o3(0xE8,0xA9,0x9E),
- o3(0xE8,0xA9,0xA9), o3(0xE8,0xA9,0xA6),
- o3(0xE8,0xAA,0x8C), o3(0xE8,0xAB,0xAE),
- o3(0xE8,0xB3,0x87), o3(0xE8,0xB3,0x9C),
- o3(0xE9,0x9B,0x8C), o3(0xE9,0xA3,0xBC),
- o3(0xE6,0xAD,0xAF), o3(0xE4,0xBA,0x8B),
- o3(0xE4,0xBC,0xBC), o3(0xE4,0xBE,0x8D),
- o3(0xE5,0x85,0x90), o3(0xE5,0xAD,0x97),
- o3(0xE5,0xAF,0xBA), o3(0xE6,0x85,0x88),
- o3(0xE6,0x8C,0x81), o3(0xE6,0x99,0x82),
- o3(0xE6,0xAC,0xA1), o3(0xE6,0xBB,0x8B),
- o3(0xE6,0xB2,0xBB), o3(0xE7,0x88,0xBE),
- o3(0xE7,0x92,0xBD), o3(0xE7,0x97,0x94),
- o3(0xE7,0xA3,0x81), o3(0xE7,0xA4,0xBA),
- o3(0xE8,0x80,0x8C), o3(0xE8,0x80,0xB3),
- o3(0xE8,0x87,0xAA), o3(0xE8,0x92,0x94),
- o3(0xE8,0xBE,0x9E), o3(0xE6,0xB1,0x90),
- o3(0xE9,0xB9,0xBF), o3(0xE5,0xBC,0x8F),
- o3(0xE8,0xAD,0x98), o3(0xE9,0xB4,0xAB),
- o3(0xE7,0xAB,0xBA), o3(0xE8,0xBB,0xB8),
- o3(0xE5,0xAE,0x8D), o3(0xE9,0x9B,0xAB),
- o3(0xE4,0xB8,0x83), o3(0xE5,0x8F,0xB1),
- o3(0xE5,0x9F,0xB7), o3(0xE5,0xA4,0xB1),
- o3(0xE5,0xAB,0x89), o3(0xE5,0xAE,0xA4),
- o3(0xE6,0x82,0x89), o3(0xE6,0xB9,0xBF),
- o3(0xE6,0xBC,0x86), o3(0xE7,0x96,0xBE),
- o3(0xE8,0xB3,0xAA), o3(0xE5,0xAE,0x9F),
- o3(0xE8,0x94,0x80), o3(0xE7,0xAF,0xA0),
- o3(0xE5,0x81,0xB2), o3(0xE6,0x9F,0xB4),
- o3(0xE8,0x8A,0x9D), o3(0xE5,0xB1,0xA1),
- o3(0xE8,0x95,0x8A), o3(0xE7,0xB8,0x9E),
- o3(0xE8,0x88,0x8E), o3(0xE5,0x86,0x99),
- o3(0xE5,0xB0,0x84), o3(0xE6,0x8D,0xA8),
- o3(0xE8,0xB5,0xA6), o3(0xE6,0x96,0x9C),
- o3(0xE7,0x85,0xAE), o3(0xE7,0xA4,0xBE),
- o3(0xE7,0xB4,0x97), o3(0xE8,0x80,0x85),
- o3(0xE8,0xAC,0x9D), o3(0xE8,0xBB,0x8A),
- o3(0xE9,0x81,0xAE), o3(0xE8,0x9B,0x87),
- o3(0xE9,0x82,0xAA), o3(0xE5,0x80,0x9F),
- o3(0xE5,0x8B,0xBA), o3(0xE5,0xB0,0xBA),
- o3(0xE6,0x9D,0x93), o3(0xE7,0x81,0xBC),
- o3(0xE7,0x88,0xB5), o3(0xE9,0x85,0x8C),
- o3(0xE9,0x87,0x88), o3(0xE9,0x8C,0xAB),
- o3(0xE8,0x8B,0xA5), o3(0xE5,0xAF,0x82),
- o3(0xE5,0xBC,0xB1), o3(0xE6,0x83,0xB9),
- o3(0xE4,0xB8,0xBB), o3(0xE5,0x8F,0x96),
- o3(0xE5,0xAE,0x88), o3(0xE6,0x89,0x8B),
- o3(0xE6,0x9C,0xB1), o3(0xE6,0xAE,0x8A),
- o3(0xE7,0x8B,0xA9), o3(0xE7,0x8F,0xA0),
- o3(0xE7,0xA8,0xAE), o3(0xE8,0x85,0xAB),
- o3(0xE8,0xB6,0xA3), o3(0xE9,0x85,0x92),
- o3(0xE9,0xA6,0x96), o3(0xE5,0x84,0x92),
- o3(0xE5,0x8F,0x97), o3(0xE5,0x91,0xAA),
- o3(0xE5,0xAF,0xBF), o3(0xE6,0x8E,0x88),
- o3(0xE6,0xA8,0xB9), o3(0xE7,0xB6,0xAC),
- o3(0xE9,0x9C,0x80), o3(0xE5,0x9B,0x9A),
- o3(0xE5,0x8F,0x8E), o3(0xE5,0x91,0xA8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_8E = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_8E_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_8F_infos[189] = {
- o3(0xE5,0xAE,0x97), o3(0xE5,0xB0,0xB1),
- o3(0xE5,0xB7,0x9E), o3(0xE4,0xBF,0xAE),
- o3(0xE6,0x84,0x81), o3(0xE6,0x8B,0xBE),
- o3(0xE6,0xB4,0xB2), o3(0xE7,0xA7,0x80),
- o3(0xE7,0xA7,0x8B), o3(0xE7,0xB5,0x82),
- o3(0xE7,0xB9,0x8D), o3(0xE7,0xBF,0x92),
- o3(0xE8,0x87,0xAD), o3(0xE8,0x88,0x9F),
- o3(0xE8,0x92,0x90), o3(0xE8,0xA1,0x86),
- o3(0xE8,0xA5,0xB2), o3(0xE8,0xAE,0x90),
- o3(0xE8,0xB9,0xB4), o3(0xE8,0xBC,0xAF),
- o3(0xE9,0x80,0xB1), o3(0xE9,0x85,0x8B),
- o3(0xE9,0x85,0xAC), o3(0xE9,0x9B,0x86),
- o3(0xE9,0x86,0x9C), o3(0xE4,0xBB,0x80),
- o3(0xE4,0xBD,0x8F), o3(0xE5,0x85,0x85),
- o3(0xE5,0x8D,0x81), o3(0xE5,0xBE,0x93),
- o3(0xE6,0x88,0x8E), o3(0xE6,0x9F,0x94),
- o3(0xE6,0xB1,0x81), o3(0xE6,0xB8,0x8B),
- o3(0xE7,0x8D,0xA3), o3(0xE7,0xB8,0xA6),
- o3(0xE9,0x87,0x8D), o3(0xE9,0x8A,0x83),
- o3(0xE5,0x8F,0x94), o3(0xE5,0xA4,0x99),
- o3(0xE5,0xAE,0xBF), o3(0xE6,0xB7,0x91),
- o3(0xE7,0xA5,0x9D), o3(0xE7,0xB8,0xAE),
- o3(0xE7,0xB2,0x9B), o3(0xE5,0xA1,0xBE),
- o3(0xE7,0x86,0x9F), o3(0xE5,0x87,0xBA),
- o3(0xE8,0xA1,0x93), o3(0xE8,0xBF,0xB0),
- o3(0xE4,0xBF,0x8A), o3(0xE5,0xB3,0xBB),
- o3(0xE6,0x98,0xA5), o3(0xE7,0x9E,0xAC),
- o3(0xE7,0xAB,0xA3), o3(0xE8,0x88,0x9C),
- o3(0xE9,0xA7,0xBF), o3(0xE5,0x87,0x86),
- o3(0xE5,0xBE,0xAA), o3(0xE6,0x97,0xAC),
- o3(0xE6,0xA5,0xAF), o3(0xE6,0xAE,0x89),
- o3(0xE6,0xB7,0xB3), o3(0xE6,0xBA,0x96),
- o3(0xE6,0xBD,0xA4), o3(0xE7,0x9B,0xBE),
- o3(0xE7,0xB4,0x94), o3(0xE5,0xB7,0xA1),
- o3(0xE9,0x81,0xB5), o3(0xE9,0x86,0x87),
- o3(0xE9,0xA0,0x86), o3(0xE5,0x87,0xA6),
- o3(0xE5,0x88,0x9D), o3(0xE6,0x89,0x80),
- o3(0xE6,0x9A,0x91), o3(0xE6,0x9B,0x99),
- o3(0xE6,0xB8,0x9A), o3(0xE5,0xBA,0xB6),
- o3(0xE7,0xB7,0x92), o3(0xE7,0xBD,0xB2),
- o3(0xE6,0x9B,0xB8), o3(0xE8,0x96,0xAF),
- o3(0xE8,0x97,0xB7), o3(0xE8,0xAB,0xB8),
- o3(0xE5,0x8A,0xA9), o3(0xE5,0x8F,0x99),
- o3(0xE5,0xA5,0xB3), o3(0xE5,0xBA,0x8F),
- o3(0xE5,0xBE,0x90), o3(0xE6,0x81,0x95),
- o3(0xE9,0x8B,0xA4), o3(0xE9,0x99,0xA4),
- o3(0xE5,0x82,0xB7), o3(0xE5,0x84,0x9F),
- o3(0xE5,0x8B,0x9D), o3(0xE5,0x8C,0xA0),
- o3(0xE5,0x8D,0x87), o3(0xE5,0x8F,0xAC),
- o3(0xE5,0x93,0xA8), o3(0xE5,0x95,0x86),
- o3(0xE5,0x94,0xB1), o3(0xE5,0x98,0x97),
- o3(0xE5,0xA5,0xA8), o3(0xE5,0xA6,0xBE),
- o3(0xE5,0xA8,0xBC), o3(0xE5,0xAE,0xB5),
- o3(0xE5,0xB0,0x86), o3(0xE5,0xB0,0x8F),
- o3(0xE5,0xB0,0x91), o3(0xE5,0xB0,0x9A),
- o3(0xE5,0xBA,0x84), o3(0xE5,0xBA,0x8A),
- o3(0xE5,0xBB,0xA0), o3(0xE5,0xBD,0xB0),
- o3(0xE6,0x89,0xBF), o3(0xE6,0x8A,0x84),
- o3(0xE6,0x8B,0x9B), o3(0xE6,0x8E,0x8C),
- o3(0xE6,0x8D,0xB7), o3(0xE6,0x98,0x87),
- o3(0xE6,0x98,0x8C), o3(0xE6,0x98,0xAD),
- o3(0xE6,0x99,0xB6), o3(0xE6,0x9D,0xBE),
- o3(0xE6,0xA2,0xA2), o3(0xE6,0xA8,0x9F),
- o3(0xE6,0xA8,0xB5), o3(0xE6,0xB2,0xBC),
- o3(0xE6,0xB6,0x88), o3(0xE6,0xB8,0x89),
- o3(0xE6,0xB9,0x98), o3(0xE7,0x84,0xBC),
- o3(0xE7,0x84,0xA6), o3(0xE7,0x85,0xA7),
- o3(0xE7,0x97,0x87), o3(0xE7,0x9C,0x81),
- o3(0xE7,0xA1,0x9D), o3(0xE7,0xA4,0x81),
- o3(0xE7,0xA5,0xA5), o3(0xE7,0xA7,0xB0),
- o3(0xE7,0xAB,0xA0), o3(0xE7,0xAC,0x91),
- o3(0xE7,0xB2,0xA7), o3(0xE7,0xB4,0xB9),
- o3(0xE8,0x82,0x96), o3(0xE8,0x8F,0x96),
- o3(0xE8,0x92,0x8B), o3(0xE8,0x95,0x89),
- o3(0xE8,0xA1,0x9D), o3(0xE8,0xA3,0xB3),
- o3(0xE8,0xA8,0x9F), o3(0xE8,0xA8,0xBC),
- o3(0xE8,0xA9,0x94), o3(0xE8,0xA9,0xB3),
- o3(0xE8,0xB1,0xA1), o3(0xE8,0xB3,0x9E),
- o3(0xE9,0x86,0xA4), o3(0xE9,0x89,0xA6),
- o3(0xE9,0x8D,0xBE), o3(0xE9,0x90,0x98),
- o3(0xE9,0x9A,0x9C), o3(0xE9,0x9E,0x98),
- o3(0xE4,0xB8,0x8A), o3(0xE4,0xB8,0x88),
- o3(0xE4,0xB8,0x9E), o3(0xE4,0xB9,0x97),
- o3(0xE5,0x86,0x97), o3(0xE5,0x89,0xB0),
- o3(0xE5,0x9F,0x8E), o3(0xE5,0xA0,0xB4),
- o3(0xE5,0xA3,0x8C), o3(0xE5,0xAC,0xA2),
- o3(0xE5,0xB8,0xB8), o3(0xE6,0x83,0x85),
- o3(0xE6,0x93,0xBE), o3(0xE6,0x9D,0xA1),
- o3(0xE6,0x9D,0x96), o3(0xE6,0xB5,0x84),
- o3(0xE7,0x8A,0xB6), o3(0xE7,0x95,0xB3),
- o3(0xE7,0xA9,0xA3), o3(0xE8,0x92,0xB8),
- o3(0xE8,0xAD,0xB2), o3(0xE9,0x86,0xB8),
- o3(0xE9,0x8C,0xA0), o3(0xE5,0x98,0xB1),
- o3(0xE5,0x9F,0xB4), o3(0xE9,0xA3,0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_8F = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_8F_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_90_infos[189] = {
- o3(0xE6,0x8B,0xAD), o3(0xE6,0xA4,0x8D),
- o3(0xE6,0xAE,0x96), o3(0xE7,0x87,0xAD),
- o3(0xE7,0xB9,0x94), o3(0xE8,0x81,0xB7),
- o3(0xE8,0x89,0xB2), o3(0xE8,0xA7,0xA6),
- o3(0xE9,0xA3,0x9F), o3(0xE8,0x9D,0x95),
- o3(0xE8,0xBE,0xB1), o3(0xE5,0xB0,0xBB),
- o3(0xE4,0xBC,0xB8), o3(0xE4,0xBF,0xA1),
- o3(0xE4,0xBE,0xB5), o3(0xE5,0x94,0x87),
- o3(0xE5,0xA8,0xA0), o3(0xE5,0xAF,0x9D),
- o3(0xE5,0xAF,0xA9), o3(0xE5,0xBF,0x83),
- o3(0xE6,0x85,0x8E), o3(0xE6,0x8C,0xAF),
- o3(0xE6,0x96,0xB0), o3(0xE6,0x99,0x8B),
- o3(0xE6,0xA3,0xAE), o3(0xE6,0xA6,0x9B),
- o3(0xE6,0xB5,0xB8), o3(0xE6,0xB7,0xB1),
- o3(0xE7,0x94,0xB3), o3(0xE7,0x96,0xB9),
- o3(0xE7,0x9C,0x9F), o3(0xE7,0xA5,0x9E),
- o3(0xE7,0xA7,0xA6), o3(0xE7,0xB4,0xB3),
- o3(0xE8,0x87,0xA3), o3(0xE8,0x8A,0xAF),
- o3(0xE8,0x96,0xAA), o3(0xE8,0xA6,0xAA),
- o3(0xE8,0xA8,0xBA), o3(0xE8,0xBA,0xAB),
- o3(0xE8,0xBE,0x9B), o3(0xE9,0x80,0xB2),
- o3(0xE9,0x87,0x9D), o3(0xE9,0x9C,0x87),
- o3(0xE4,0xBA,0xBA), o3(0xE4,0xBB,0x81),
- o3(0xE5,0x88,0x83), o3(0xE5,0xA1,0xB5),
- o3(0xE5,0xA3,0xAC), o3(0xE5,0xB0,0x8B),
- o3(0xE7,0x94,0x9A), o3(0xE5,0xB0,0xBD),
- o3(0xE8,0x85,0x8E), o3(0xE8,0xA8,0x8A),
- o3(0xE8,0xBF,0x85), o3(0xE9,0x99,0xA3),
- o3(0xE9,0x9D,0xAD), o3(0xE7,0xAC,0xA5),
- o3(0xE8,0xAB,0x8F), o3(0xE9,0xA0,0x88),
- o3(0xE9,0x85,0xA2), o3(0xE5,0x9B,0xB3),
- o3(0xE5,0x8E,0xA8), o3(0xE9,0x80,0x97),
- o3(0xE5,0x90,0xB9), o3(0xE5,0x9E,0x82),
- o3(0xE5,0xB8,0xA5), o3(0xE6,0x8E,0xA8),
- o3(0xE6,0xB0,0xB4), o3(0xE7,0x82,0x8A),
- o3(0xE7,0x9D,0xA1), o3(0xE7,0xB2,0x8B),
- o3(0xE7,0xBF,0xA0), o3(0xE8,0xA1,0xB0),
- o3(0xE9,0x81,0x82), o3(0xE9,0x85,0x94),
- o3(0xE9,0x8C,0x90), o3(0xE9,0x8C,0x98),
- o3(0xE9,0x9A,0x8F), o3(0xE7,0x91,0x9E),
- o3(0xE9,0xAB,0x84), o3(0xE5,0xB4,0x87),
- o3(0xE5,0xB5,0xA9), o3(0xE6,0x95,0xB0),
- o3(0xE6,0x9E,0xA2), o3(0xE8,0xB6,0xA8),
- o3(0xE9,0x9B,0x9B), o3(0xE6,0x8D,0xAE),
- o3(0xE6,0x9D,0x89), o3(0xE6,0xA4,0x99),
- o3(0xE8,0x8F,0x85), o3(0xE9,0xA0,0x97),
- o3(0xE9,0x9B,0x80), o3(0xE8,0xA3,0xBE),
- o3(0xE6,0xBE,0x84), o3(0xE6,0x91,0xBA),
- o3(0xE5,0xAF,0xB8), o3(0xE4,0xB8,0x96),
- o3(0xE7,0x80,0xAC), o3(0xE7,0x95,0x9D),
- o3(0xE6,0x98,0xAF), o3(0xE5,0x87,0x84),
- o3(0xE5,0x88,0xB6), o3(0xE5,0x8B,0xA2),
- o3(0xE5,0xA7,0x93), o3(0xE5,0xBE,0x81),
- o3(0xE6,0x80,0xA7), o3(0xE6,0x88,0x90),
- o3(0xE6,0x94,0xBF), o3(0xE6,0x95,0xB4),
- o3(0xE6,0x98,0x9F), o3(0xE6,0x99,0xB4),
- o3(0xE6,0xA3,0xB2), o3(0xE6,0xA0,0x96),
- o3(0xE6,0xAD,0xA3), o3(0xE6,0xB8,0x85),
- o3(0xE7,0x89,0xB2), o3(0xE7,0x94,0x9F),
- o3(0xE7,0x9B,0x9B), o3(0xE7,0xB2,0xBE),
- o3(0xE8,0x81,0x96), o3(0xE5,0xA3,0xB0),
- o3(0xE8,0xA3,0xBD), o3(0xE8,0xA5,0xBF),
- o3(0xE8,0xAA,0xA0), o3(0xE8,0xAA,0x93),
- o3(0xE8,0xAB,0x8B), o3(0xE9,0x80,0x9D),
- o3(0xE9,0x86,0x92), o3(0xE9,0x9D,0x92),
- o3(0xE9,0x9D,0x99), o3(0xE6,0x96,0x89),
- o3(0xE7,0xA8,0x8E), o3(0xE8,0x84,0x86),
- o3(0xE9,0x9A,0xBB), o3(0xE5,0xB8,0xAD),
- o3(0xE6,0x83,0x9C), o3(0xE6,0x88,0x9A),
- o3(0xE6,0x96,0xA5), o3(0xE6,0x98,0x94),
- o3(0xE6,0x9E,0x90), o3(0xE7,0x9F,0xB3),
- o3(0xE7,0xA9,0x8D), o3(0xE7,0xB1,0x8D),
- o3(0xE7,0xB8,0xBE), o3(0xE8,0x84,0x8A),
- o3(0xE8,0xB2,0xAC), o3(0xE8,0xB5,0xA4),
- o3(0xE8,0xB7,0xA1), o3(0xE8,0xB9,0x9F),
- o3(0xE7,0xA2,0xA9), o3(0xE5,0x88,0x87),
- o3(0xE6,0x8B,0x99), o3(0xE6,0x8E,0xA5),
- o3(0xE6,0x91,0x82), o3(0xE6,0x8A,0x98),
- o3(0xE8,0xA8,0xAD), o3(0xE7,0xAA,0x83),
- o3(0xE7,0xAF,0x80), o3(0xE8,0xAA,0xAC),
- o3(0xE9,0x9B,0xAA), o3(0xE7,0xB5,0xB6),
- o3(0xE8,0x88,0x8C), o3(0xE8,0x9D,0x89),
- o3(0xE4,0xBB,0x99), o3(0xE5,0x85,0x88),
- o3(0xE5,0x8D,0x83), o3(0xE5,0x8D,0xA0),
- o3(0xE5,0xAE,0xA3), o3(0xE5,0xB0,0x82),
- o3(0xE5,0xB0,0x96), o3(0xE5,0xB7,0x9D),
- o3(0xE6,0x88,0xA6), o3(0xE6,0x89,0x87),
- o3(0xE6,0x92,0xB0), o3(0xE6,0xA0,0x93),
- o3(0xE6,0xA0,0xB4), o3(0xE6,0xB3,0x89),
- o3(0xE6,0xB5,0x85), o3(0xE6,0xB4,0x97),
- o3(0xE6,0x9F,0x93), o3(0xE6,0xBD,0x9C),
- o3(0xE7,0x85,0x8E), o3(0xE7,0x85,0xBD),
- o3(0xE6,0x97,0x8B), o3(0xE7,0xA9,0xBF),
- o3(0xE7,0xAE,0xAD), o3(0xE7,0xB7,0x9A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_90 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_90_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_91_infos[189] = {
- o3(0xE7,0xB9,0x8A), o3(0xE7,0xBE,0xA8),
- o3(0xE8,0x85,0xBA), o3(0xE8,0x88,0x9B),
- o3(0xE8,0x88,0xB9), o3(0xE8,0x96,0xA6),
- o3(0xE8,0xA9,0xAE), o3(0xE8,0xB3,0x8E),
- o3(0xE8,0xB7,0xB5), o3(0xE9,0x81,0xB8),
- o3(0xE9,0x81,0xB7), o3(0xE9,0x8A,0xAD),
- o3(0xE9,0x8A,0x91), o3(0xE9,0x96,0x83),
- o3(0xE9,0xAE,0xAE), o3(0xE5,0x89,0x8D),
- o3(0xE5,0x96,0x84), o3(0xE6,0xBC,0xB8),
- o3(0xE7,0x84,0xB6), o3(0xE5,0x85,0xA8),
- o3(0xE7,0xA6,0x85), o3(0xE7,0xB9,0x95),
- o3(0xE8,0x86,0xB3), o3(0xE7,0xB3,0x8E),
- o3(0xE5,0x99,0x8C), o3(0xE5,0xA1,0x91),
- o3(0xE5,0xB2,0xA8), o3(0xE6,0x8E,0xAA),
- o3(0xE6,0x9B,0xBE), o3(0xE6,0x9B,0xBD),
- o3(0xE6,0xA5,0x9A), o3(0xE7,0x8B,0x99),
- o3(0xE7,0x96,0x8F), o3(0xE7,0x96,0x8E),
- o3(0xE7,0xA4,0x8E), o3(0xE7,0xA5,0x96),
- o3(0xE7,0xA7,0x9F), o3(0xE7,0xB2,0x97),
- o3(0xE7,0xB4,0xA0), o3(0xE7,0xB5,0x84),
- o3(0xE8,0x98,0x87), o3(0xE8,0xA8,0xB4),
- o3(0xE9,0x98,0xBB), o3(0xE9,0x81,0xA1),
- o3(0xE9,0xBC,0xA0), o3(0xE5,0x83,0xA7),
- o3(0xE5,0x89,0xB5), o3(0xE5,0x8F,0x8C),
- o3(0xE5,0x8F,0xA2), o3(0xE5,0x80,0x89),
- o3(0xE5,0x96,0xAA), o3(0xE5,0xA3,0xAE),
- o3(0xE5,0xA5,0x8F), o3(0xE7,0x88,0xBD),
- o3(0xE5,0xAE,0x8B), o3(0xE5,0xB1,0xA4),
- o3(0xE5,0x8C,0x9D), o3(0xE6,0x83,0xA3),
- o3(0xE6,0x83,0xB3), o3(0xE6,0x8D,0x9C),
- o3(0xE6,0x8E,0x83), o3(0xE6,0x8C,0xBF),
- o3(0xE6,0x8E,0xBB), o3(0xE6,0x93,0x8D),
- o3(0xE6,0x97,0xA9), o3(0xE6,0x9B,0xB9),
- o3(0xE5,0xB7,0xA3), o3(0xE6,0xA7,0x8D),
- o3(0xE6,0xA7,0xBD), o3(0xE6,0xBC,0x95),
- o3(0xE7,0x87,0xA5), o3(0xE4,0xBA,0x89),
- o3(0xE7,0x97,0xA9), o3(0xE7,0x9B,0xB8),
- o3(0xE7,0xAA,0x93), o3(0xE7,0xB3,0x9F),
- o3(0xE7,0xB7,0x8F), o3(0xE7,0xB6,0x9C),
- o3(0xE8,0x81,0xA1), o3(0xE8,0x8D,0x89),
- o3(0xE8,0x8D,0x98), o3(0xE8,0x91,0xAC),
- o3(0xE8,0x92,0xBC), o3(0xE8,0x97,0xBB),
- o3(0xE8,0xA3,0x85), o3(0xE8,0xB5,0xB0),
- o3(0xE9,0x80,0x81), o3(0xE9,0x81,0xAD),
- o3(0xE9,0x8E,0x97), o3(0xE9,0x9C,0x9C),
- o3(0xE9,0xA8,0x92), o3(0xE5,0x83,0x8F),
- o3(0xE5,0xA2,0x97), o3(0xE6,0x86,0x8E),
- o3(0xE8,0x87,0x93), o3(0xE8,0x94,0xB5),
- o3(0xE8,0xB4,0x88), o3(0xE9,0x80,0xA0),
- o3(0xE4,0xBF,0x83), o3(0xE5,0x81,0xB4),
- o3(0xE5,0x89,0x87), o3(0xE5,0x8D,0xB3),
- o3(0xE6,0x81,0xAF), o3(0xE6,0x8D,0x89),
- o3(0xE6,0x9D,0x9F), o3(0xE6,0xB8,0xAC),
- o3(0xE8,0xB6,0xB3), o3(0xE9,0x80,0x9F),
- o3(0xE4,0xBF,0x97), o3(0xE5,0xB1,0x9E),
- o3(0xE8,0xB3,0x8A), o3(0xE6,0x97,0x8F),
- o3(0xE7,0xB6,0x9A), o3(0xE5,0x8D,0x92),
- o3(0xE8,0xA2,0x96), o3(0xE5,0x85,0xB6),
- o3(0xE6,0x8F,0x83), o3(0xE5,0xAD,0x98),
- o3(0xE5,0xAD,0xAB), o3(0xE5,0xB0,0x8A),
- o3(0xE6,0x90,0x8D), o3(0xE6,0x9D,0x91),
- o3(0xE9,0x81,0x9C), o3(0xE4,0xBB,0x96),
- o3(0xE5,0xA4,0x9A), o3(0xE5,0xA4,0xAA),
- o3(0xE6,0xB1,0xB0), o3(0xE8,0xA9,0x91),
- o3(0xE5,0x94,0xBE), o3(0xE5,0xA0,0x95),
- o3(0xE5,0xA6,0xA5), o3(0xE6,0x83,0xB0),
- o3(0xE6,0x89,0x93), o3(0xE6,0x9F,0x81),
- o3(0xE8,0x88,0xB5), o3(0xE6,0xA5,0x95),
- o3(0xE9,0x99,0x80), o3(0xE9,0xA7,0x84),
- o3(0xE9,0xA8,0xA8), o3(0xE4,0xBD,0x93),
- o3(0xE5,0xA0,0x86), o3(0xE5,0xAF,0xBE),
- o3(0xE8,0x80,0x90), o3(0xE5,0xB2,0xB1),
- o3(0xE5,0xB8,0xAF), o3(0xE5,0xBE,0x85),
- o3(0xE6,0x80,0xA0), o3(0xE6,0x85,0x8B),
- o3(0xE6,0x88,0xB4), o3(0xE6,0x9B,0xBF),
- o3(0xE6,0xB3,0xB0), o3(0xE6,0xBB,0x9E),
- o3(0xE8,0x83,0x8E), o3(0xE8,0x85,0xBF),
- o3(0xE8,0x8B,0x94), o3(0xE8,0xA2,0x8B),
- o3(0xE8,0xB2,0xB8), o3(0xE9,0x80,0x80),
- o3(0xE9,0x80,0xAE), o3(0xE9,0x9A,0x8A),
- o3(0xE9,0xBB,0x9B), o3(0xE9,0xAF,0x9B),
- o3(0xE4,0xBB,0xA3), o3(0xE5,0x8F,0xB0),
- o3(0xE5,0xA4,0xA7), o3(0xE7,0xAC,0xAC),
- o3(0xE9,0x86,0x8D), o3(0xE9,0xA1,0x8C),
- o3(0xE9,0xB7,0xB9), o3(0xE6,0xBB,0x9D),
- o3(0xE7,0x80,0xA7), o3(0xE5,0x8D,0x93),
- o3(0xE5,0x95,0x84), o3(0xE5,0xAE,0x85),
- o3(0xE6,0x89,0x98), o3(0xE6,0x8A,0x9E),
- o3(0xE6,0x8B,0x93), o3(0xE6,0xB2,0xA2),
- o3(0xE6,0xBF,0xAF), o3(0xE7,0x90,0xA2),
- o3(0xE8,0xA8,0x97), o3(0xE9,0x90,0xB8),
- o3(0xE6,0xBF,0x81), o3(0xE8,0xAB,0xBE),
- o3(0xE8,0x8C,0xB8), o3(0xE5,0x87,0xA7),
- o3(0xE8,0x9B,0xB8), o3(0xE5,0x8F,0xAA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_91 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_91_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_92_infos[189] = {
- o3(0xE5,0x8F,0xA9), o3(0xE4,0xBD,0x86),
- o3(0xE9,0x81,0x94), o3(0xE8,0xBE,0xB0),
- o3(0xE5,0xA5,0xAA), o3(0xE8,0x84,0xB1),
- o3(0xE5,0xB7,0xBD), o3(0xE7,0xAB,0xAA),
- o3(0xE8,0xBE,0xBF), o3(0xE6,0xA3,0x9A),
- o3(0xE8,0xB0,0xB7), o3(0xE7,0x8B,0xB8),
- o3(0xE9,0xB1,0x88), o3(0xE6,0xA8,0xBD),
- o3(0xE8,0xAA,0xB0), o3(0xE4,0xB8,0xB9),
- o3(0xE5,0x8D,0x98), o3(0xE5,0x98,0x86),
- o3(0xE5,0x9D,0xA6), o3(0xE6,0x8B,0x85),
- o3(0xE6,0x8E,0xA2), o3(0xE6,0x97,0xA6),
- o3(0xE6,0xAD,0x8E), o3(0xE6,0xB7,0xA1),
- o3(0xE6,0xB9,0x9B), o3(0xE7,0x82,0xAD),
- o3(0xE7,0x9F,0xAD), o3(0xE7,0xAB,0xAF),
- o3(0xE7,0xAE,0xAA), o3(0xE7,0xB6,0xBB),
- o3(0xE8,0x80,0xBD), o3(0xE8,0x83,0x86),
- o3(0xE8,0x9B,0x8B), o3(0xE8,0xAA,0x95),
- o3(0xE9,0x8D,0x9B), o3(0xE5,0x9B,0xA3),
- o3(0xE5,0xA3,0x87), o3(0xE5,0xBC,0xBE),
- o3(0xE6,0x96,0xAD), o3(0xE6,0x9A,0x96),
- o3(0xE6,0xAA,0x80), o3(0xE6,0xAE,0xB5),
- o3(0xE7,0x94,0xB7), o3(0xE8,0xAB,0x87),
- o3(0xE5,0x80,0xA4), o3(0xE7,0x9F,0xA5),
- o3(0xE5,0x9C,0xB0), o3(0xE5,0xBC,0x9B),
- o3(0xE6,0x81,0xA5), o3(0xE6,0x99,0xBA),
- o3(0xE6,0xB1,0xA0), o3(0xE7,0x97,0xB4),
- o3(0xE7,0xA8,0x9A), o3(0xE7,0xBD,0xAE),
- o3(0xE8,0x87,0xB4), o3(0xE8,0x9C,0x98),
- o3(0xE9,0x81,0x85), o3(0xE9,0xA6,0xB3),
- o3(0xE7,0xAF,0x89), o3(0xE7,0x95,0x9C),
- o3(0xE7,0xAB,0xB9), o3(0xE7,0xAD,0x91),
- o3(0xE8,0x93,0x84), o3(0xE9,0x80,0x90),
- o3(0xE7,0xA7,0xA9), o3(0xE7,0xAA,0x92),
- o3(0xE8,0x8C,0xB6), o3(0xE5,0xAB,0xA1),
- o3(0xE7,0x9D,0x80), o3(0xE4,0xB8,0xAD),
- o3(0xE4,0xBB,0xB2), o3(0xE5,0xAE,0x99),
- o3(0xE5,0xBF,0xA0), o3(0xE6,0x8A,0xBD),
- o3(0xE6,0x98,0xBC), o3(0xE6,0x9F,0xB1),
- o3(0xE6,0xB3,0xA8), o3(0xE8,0x99,0xAB),
- o3(0xE8,0xA1,0xB7), o3(0xE8,0xA8,0xBB),
- o3(0xE9,0x85,0x8E), o3(0xE9,0x8B,0xB3),
- o3(0xE9,0xA7,0x90), o3(0xE6,0xA8,0x97),
- o3(0xE7,0x80,0xA6), o3(0xE7,0x8C,0xAA),
- o3(0xE8,0x8B,0xA7), o3(0xE8,0x91,0x97),
- o3(0xE8,0xB2,0xAF), o3(0xE4,0xB8,0x81),
- o3(0xE5,0x85,0x86), o3(0xE5,0x87,0x8B),
- o3(0xE5,0x96,0x8B), o3(0xE5,0xAF,0xB5),
- o3(0xE5,0xB8,0x96), o3(0xE5,0xB8,0xB3),
- o3(0xE5,0xBA,0x81), o3(0xE5,0xBC,0x94),
- o3(0xE5,0xBC,0xB5), o3(0xE5,0xBD,0xAB),
- o3(0xE5,0xBE,0xB4), o3(0xE6,0x87,0xB2),
- o3(0xE6,0x8C,0x91), o3(0xE6,0x9A,0xA2),
- o3(0xE6,0x9C,0x9D), o3(0xE6,0xBD,0xAE),
- o3(0xE7,0x89,0x92), o3(0xE7,0x94,0xBA),
- o3(0xE7,0x9C,0xBA), o3(0xE8,0x81,0xB4),
- o3(0xE8,0x84,0xB9), o3(0xE8,0x85,0xB8),
- o3(0xE8,0x9D,0xB6), o3(0xE8,0xAA,0xBF),
- o3(0xE8,0xAB,0x9C), o3(0xE8,0xB6,0x85),
- o3(0xE8,0xB7,0xB3), o3(0xE9,0x8A,0x9A),
- o3(0xE9,0x95,0xB7), o3(0xE9,0xA0,0x82),
- o3(0xE9,0xB3,0xA5), o3(0xE5,0x8B,0x85),
- o3(0xE6,0x8D,0x97), o3(0xE7,0x9B,0xB4),
- o3(0xE6,0x9C,0x95), o3(0xE6,0xB2,0x88),
- o3(0xE7,0x8F,0x8D), o3(0xE8,0xB3,0x83),
- o3(0xE9,0x8E,0xAE), o3(0xE9,0x99,0xB3),
- o3(0xE6,0xB4,0xA5), o3(0xE5,0xA2,0x9C),
- o3(0xE6,0xA4,0x8E), o3(0xE6,0xA7,0x8C),
- o3(0xE8,0xBF,0xBD), o3(0xE9,0x8E,0x9A),
- o3(0xE7,0x97,0x9B), o3(0xE9,0x80,0x9A),
- o3(0xE5,0xA1,0x9A), o3(0xE6,0xA0,0x82),
- o3(0xE6,0x8E,0xB4), o3(0xE6,0xA7,0xBB),
- o3(0xE4,0xBD,0x83), o3(0xE6,0xBC,0xAC),
- o3(0xE6,0x9F,0x98), o3(0xE8,0xBE,0xBB),
- o3(0xE8,0x94,0xA6), o3(0xE7,0xB6,0xB4),
- o3(0xE9,0x8D,0x94), o3(0xE6,0xA4,0xBF),
- o3(0xE6,0xBD,0xB0), o3(0xE5,0x9D,0xAA),
- o3(0xE5,0xA3,0xB7), o3(0xE5,0xAC,0xAC),
- o3(0xE7,0xB4,0xAC), o3(0xE7,0x88,0xAA),
- o3(0xE5,0x90,0x8A), o3(0xE9,0x87,0xA3),
- o3(0xE9,0xB6,0xB4), o3(0xE4,0xBA,0xAD),
- o3(0xE4,0xBD,0x8E), o3(0xE5,0x81,0x9C),
- o3(0xE5,0x81,0xB5), o3(0xE5,0x89,0x83),
- o3(0xE8,0xB2,0x9E), o3(0xE5,0x91,0x88),
- o3(0xE5,0xA0,0xA4), o3(0xE5,0xAE,0x9A),
- o3(0xE5,0xB8,0x9D), o3(0xE5,0xBA,0x95),
- o3(0xE5,0xBA,0xAD), o3(0xE5,0xBB,0xB7),
- o3(0xE5,0xBC,0x9F), o3(0xE6,0x82,0x8C),
- o3(0xE6,0x8A,0xB5), o3(0xE6,0x8C,0xBA),
- o3(0xE6,0x8F,0x90), o3(0xE6,0xA2,0xAF),
- o3(0xE6,0xB1,0x80), o3(0xE7,0xA2,0x87),
- o3(0xE7,0xA6,0x8E), o3(0xE7,0xA8,0x8B),
- o3(0xE7,0xB7,0xA0), o3(0xE8,0x89,0x87),
- o3(0xE8,0xA8,0x82), o3(0xE8,0xAB,0xA6),
- o3(0xE8,0xB9,0x84), o3(0xE9,0x80,0x93),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_92 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_92_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_93_infos[189] = {
- o3(0xE9,0x82,0xB8), o3(0xE9,0x84,0xAD),
- o3(0xE9,0x87,0x98), o3(0xE9,0xBC,0x8E),
- o3(0xE6,0xB3,0xA5), o3(0xE6,0x91,0x98),
- o3(0xE6,0x93,0xA2), o3(0xE6,0x95,0xB5),
- o3(0xE6,0xBB,0xB4), o3(0xE7,0x9A,0x84),
- o3(0xE7,0xAC,0x9B), o3(0xE9,0x81,0xA9),
- o3(0xE9,0x8F,0x91), o3(0xE6,0xBA,0xBA),
- o3(0xE5,0x93,0xB2), o3(0xE5,0xBE,0xB9),
- o3(0xE6,0x92,0xA4), o3(0xE8,0xBD,0x8D),
- o3(0xE8,0xBF,0xAD), o3(0xE9,0x89,0x84),
- o3(0xE5,0x85,0xB8), o3(0xE5,0xA1,0xAB),
- o3(0xE5,0xA4,0xA9), o3(0xE5,0xB1,0x95),
- o3(0xE5,0xBA,0x97), o3(0xE6,0xB7,0xBB),
- o3(0xE7,0xBA,0x8F), o3(0xE7,0x94,0x9C),
- o3(0xE8,0xB2,0xBC), o3(0xE8,0xBB,0xA2),
- o3(0xE9,0xA1,0x9B), o3(0xE7,0x82,0xB9),
- o3(0xE4,0xBC,0x9D), o3(0xE6,0xAE,0xBF),
- o3(0xE6,0xBE,0xB1), o3(0xE7,0x94,0xB0),
- o3(0xE9,0x9B,0xBB), o3(0xE5,0x85,0x8E),
- o3(0xE5,0x90,0x90), o3(0xE5,0xA0,0xB5),
- o3(0xE5,0xA1,0x97), o3(0xE5,0xA6,0xAC),
- o3(0xE5,0xB1,0xA0), o3(0xE5,0xBE,0x92),
- o3(0xE6,0x96,0x97), o3(0xE6,0x9D,0x9C),
- o3(0xE6,0xB8,0xA1), o3(0xE7,0x99,0xBB),
- o3(0xE8,0x8F,0x9F), o3(0xE8,0xB3,0xAD),
- o3(0xE9,0x80,0x94), o3(0xE9,0x83,0xBD),
- o3(0xE9,0x8D,0x8D), o3(0xE7,0xA0,0xA5),
- o3(0xE7,0xA0,0xBA), o3(0xE5,0x8A,0xAA),
- o3(0xE5,0xBA,0xA6), o3(0xE5,0x9C,0x9F),
- o3(0xE5,0xA5,0xB4), o3(0xE6,0x80,0x92),
- o3(0xE5,0x80,0x92), o3(0xE5,0x85,0x9A),
- o3(0xE5,0x86,0xAC), o3(0xE5,0x87,0x8D),
- o3(0xE5,0x88,0x80), o3(0xE5,0x94,0x90),
- o3(0xE5,0xA1,0x94), o3(0xE5,0xA1,0x98),
- o3(0xE5,0xA5,0x97), o3(0xE5,0xAE,0x95),
- o3(0xE5,0xB3,0xB6), o3(0xE5,0xB6,0x8B),
- o3(0xE6,0x82,0xBC), o3(0xE6,0x8A,0x95),
- o3(0xE6,0x90,0xAD), o3(0xE6,0x9D,0xB1),
- o3(0xE6,0xA1,0x83), o3(0xE6,0xA2,0xBC),
- o3(0xE6,0xA3,0x9F), o3(0xE7,0x9B,0x97),
- o3(0xE6,0xB7,0x98), o3(0xE6,0xB9,0xAF),
- o3(0xE6,0xB6,0x9B), o3(0xE7,0x81,0xAF),
- o3(0xE7,0x87,0x88), o3(0xE5,0xBD,0x93),
- o3(0xE7,0x97,0x98), o3(0xE7,0xA5,0xB7),
- o3(0xE7,0xAD,0x89), o3(0xE7,0xAD,0x94),
- o3(0xE7,0xAD,0x92), o3(0xE7,0xB3,0x96),
- o3(0xE7,0xB5,0xB1), o3(0xE5,0x88,0xB0),
- o3(0xE8,0x91,0xA3), o3(0xE8,0x95,0xA9),
- o3(0xE8,0x97,0xA4), o3(0xE8,0xA8,0x8E),
- o3(0xE8,0xAC,0x84), o3(0xE8,0xB1,0x86),
- o3(0xE8,0xB8,0x8F), o3(0xE9,0x80,0x83),
- o3(0xE9,0x80,0x8F), o3(0xE9,0x90,0x99),
- o3(0xE9,0x99,0xB6), o3(0xE9,0xA0,0xAD),
- o3(0xE9,0xA8,0xB0), o3(0xE9,0x97,0x98),
- o3(0xE5,0x83,0x8D), o3(0xE5,0x8B,0x95),
- o3(0xE5,0x90,0x8C), o3(0xE5,0xA0,0x82),
- o3(0xE5,0xB0,0x8E), o3(0xE6,0x86,0xA7),
- o3(0xE6,0x92,0x9E), o3(0xE6,0xB4,0x9E),
- o3(0xE7,0x9E,0xB3), o3(0xE7,0xAB,0xA5),
- o3(0xE8,0x83,0xB4), o3(0xE8,0x90,0x84),
- o3(0xE9,0x81,0x93), o3(0xE9,0x8A,0x85),
- o3(0xE5,0xB3,0xA0), o3(0xE9,0xB4,0x87),
- o3(0xE5,0x8C,0xBF), o3(0xE5,0xBE,0x97),
- o3(0xE5,0xBE,0xB3), o3(0xE6,0xB6,0x9C),
- o3(0xE7,0x89,0xB9), o3(0xE7,0x9D,0xA3),
- o3(0xE7,0xA6,0xBF), o3(0xE7,0xAF,0xA4),
- o3(0xE6,0xAF,0x92), o3(0xE7,0x8B,0xAC),
- o3(0xE8,0xAA,0xAD), o3(0xE6,0xA0,0x83),
- o3(0xE6,0xA9,0xA1), o3(0xE5,0x87,0xB8),
- o3(0xE7,0xAA,0x81), o3(0xE6,0xA4,0xB4),
- o3(0xE5,0xB1,0x8A), o3(0xE9,0xB3,0xB6),
- o3(0xE8,0x8B,0xAB), o3(0xE5,0xAF,0x85),
- o3(0xE9,0x85,0x89), o3(0xE7,0x80,0x9E),
- o3(0xE5,0x99,0xB8), o3(0xE5,0xB1,0xAF),
- o3(0xE6,0x83,0x87), o3(0xE6,0x95,0xA6),
- o3(0xE6,0xB2,0x8C), o3(0xE8,0xB1,0x9A),
- o3(0xE9,0x81,0x81), o3(0xE9,0xA0,0x93),
- o3(0xE5,0x91,0x91), o3(0xE6,0x9B,0x87),
- o3(0xE9,0x88,0x8D), o3(0xE5,0xA5,0x88),
- o3(0xE9,0x82,0xA3), o3(0xE5,0x86,0x85),
- o3(0xE4,0xB9,0x8D), o3(0xE5,0x87,0xAA),
- o3(0xE8,0x96,0x99), o3(0xE8,0xAC,0x8E),
- o3(0xE7,0x81,0x98), o3(0xE6,0x8D,0xBA),
- o3(0xE9,0x8D,0x8B), o3(0xE6,0xA5,0xA2),
- o3(0xE9,0xA6,0xB4), o3(0xE7,0xB8,0x84),
- o3(0xE7,0x95,0xB7), o3(0xE5,0x8D,0x97),
- o3(0xE6,0xA5,0xA0), o3(0xE8,0xBB,0x9F),
- o3(0xE9,0x9B,0xA3), o3(0xE6,0xB1,0x9D),
- o3(0xE4,0xBA,0x8C), o3(0xE5,0xB0,0xBC),
- o3(0xE5,0xBC,0x90), o3(0xE8,0xBF,0xA9),
- o3(0xE5,0x8C,0x82), o3(0xE8,0xB3,0x91),
- o3(0xE8,0x82,0x89), o3(0xE8,0x99,0xB9),
- o3(0xE5,0xBB,0xBF), o3(0xE6,0x97,0xA5),
- o3(0xE4,0xB9,0xB3), o3(0xE5,0x85,0xA5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_93 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_93_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_94_infos[189] = {
- o3(0xE5,0xA6,0x82), o3(0xE5,0xB0,0xBF),
- o3(0xE9,0x9F,0xAE), o3(0xE4,0xBB,0xBB),
- o3(0xE5,0xA6,0x8A), o3(0xE5,0xBF,0x8D),
- o3(0xE8,0xAA,0x8D), o3(0xE6,0xBF,0xA1),
- o3(0xE7,0xA6,0xB0), o3(0xE7,0xA5,0xA2),
- o3(0xE5,0xAF,0xA7), o3(0xE8,0x91,0xB1),
- o3(0xE7,0x8C,0xAB), o3(0xE7,0x86,0xB1),
- o3(0xE5,0xB9,0xB4), o3(0xE5,0xBF,0xB5),
- o3(0xE6,0x8D,0xBB), o3(0xE6,0x92,0x9A),
- o3(0xE7,0x87,0x83), o3(0xE7,0xB2,0x98),
- o3(0xE4,0xB9,0x83), o3(0xE5,0xBB,0xBC),
- o3(0xE4,0xB9,0x8B), o3(0xE5,0x9F,0x9C),
- o3(0xE5,0x9A,0xA2), o3(0xE6,0x82,0xA9),
- o3(0xE6,0xBF,0x83), o3(0xE7,0xB4,0x8D),
- o3(0xE8,0x83,0xBD), o3(0xE8,0x84,0xB3),
- o3(0xE8,0x86,0xBF), o3(0xE8,0xBE,0xB2),
- o3(0xE8,0xA6,0x97), o3(0xE8,0x9A,0xA4),
- o3(0xE5,0xB7,0xB4), o3(0xE6,0x8A,0x8A),
- o3(0xE6,0x92,0xAD), o3(0xE8,0xA6,0x87),
- o3(0xE6,0x9D,0xB7), o3(0xE6,0xB3,0xA2),
- o3(0xE6,0xB4,0xBE), o3(0xE7,0x90,0xB6),
- o3(0xE7,0xA0,0xB4), o3(0xE5,0xA9,0x86),
- o3(0xE7,0xBD,0xB5), o3(0xE8,0x8A,0xAD),
- o3(0xE9,0xA6,0xAC), o3(0xE4,0xBF,0xB3),
- o3(0xE5,0xBB,0x83), o3(0xE6,0x8B,0x9D),
- o3(0xE6,0x8E,0x92), o3(0xE6,0x95,0x97),
- o3(0xE6,0x9D,0xAF), o3(0xE7,0x9B,0x83),
- o3(0xE7,0x89,0x8C), o3(0xE8,0x83,0x8C),
- o3(0xE8,0x82,0xBA), o3(0xE8,0xBC,0xA9),
- o3(0xE9,0x85,0x8D), o3(0xE5,0x80,0x8D),
- o3(0xE5,0x9F,0xB9), o3(0xE5,0xAA,0x92),
- o3(0xE6,0xA2,0x85), o3(0xE6,0xA5,0xB3),
- o3(0xE7,0x85,0xA4), o3(0xE7,0x8B,0xBD),
- o3(0xE8,0xB2,0xB7), o3(0xE5,0xA3,0xB2),
- o3(0xE8,0xB3,0xA0), o3(0xE9,0x99,0xAA),
- o3(0xE9,0x80,0x99), o3(0xE8,0x9D,0xBF),
- o3(0xE7,0xA7,0xA4), o3(0xE7,0x9F,0xA7),
- o3(0xE8,0x90,0xA9), o3(0xE4,0xBC,0xAF),
- o3(0xE5,0x89,0xA5), o3(0xE5,0x8D,0x9A),
- o3(0xE6,0x8B,0x8D), o3(0xE6,0x9F,0x8F),
- o3(0xE6,0xB3,0x8A), o3(0xE7,0x99,0xBD),
- o3(0xE7,0xAE,0x94), o3(0xE7,0xB2,0x95),
- o3(0xE8,0x88,0xB6), o3(0xE8,0x96,0x84),
- o3(0xE8,0xBF,0xAB), o3(0xE6,0x9B,0x9D),
- o3(0xE6,0xBC,0xA0), o3(0xE7,0x88,0x86),
- o3(0xE7,0xB8,0x9B), o3(0xE8,0x8E,0xAB),
- o3(0xE9,0xA7,0x81), o3(0xE9,0xBA,0xA6),
- o3(0xE5,0x87,0xBD), o3(0xE7,0xAE,0xB1),
- o3(0xE7,0xA1,0xB2), o3(0xE7,0xAE,0xB8),
- o3(0xE8,0x82,0x87), o3(0xE7,0xAD,0x88),
- o3(0xE6,0xAB,0xA8), o3(0xE5,0xB9,0xA1),
- o3(0xE8,0x82,0x8C), o3(0xE7,0x95,0x91),
- o3(0xE7,0x95,0xA0), o3(0xE5,0x85,0xAB),
- o3(0xE9,0x89,0xA2), o3(0xE6,0xBA,0x8C),
- o3(0xE7,0x99,0xBA), o3(0xE9,0x86,0x97),
- o3(0xE9,0xAB,0xAA), o3(0xE4,0xBC,0x90),
- o3(0xE7,0xBD,0xB0), o3(0xE6,0x8A,0x9C),
- o3(0xE7,0xAD,0x8F), o3(0xE9,0x96,0xA5),
- o3(0xE9,0xB3,0xA9), o3(0xE5,0x99,0xBA),
- o3(0xE5,0xA1,0x99), o3(0xE8,0x9B,0xA4),
- o3(0xE9,0x9A,0xBC), o3(0xE4,0xBC,0xB4),
- o3(0xE5,0x88,0xA4), o3(0xE5,0x8D,0x8A),
- o3(0xE5,0x8F,0x8D), o3(0xE5,0x8F,0x9B),
- o3(0xE5,0xB8,0x86), o3(0xE6,0x90,0xAC),
- o3(0xE6,0x96,0x91), o3(0xE6,0x9D,0xBF),
- o3(0xE6,0xB0,0xBE), o3(0xE6,0xB1,0x8E),
- o3(0xE7,0x89,0x88), o3(0xE7,0x8A,0xAF),
- o3(0xE7,0x8F,0xAD), o3(0xE7,0x95,0x94),
- o3(0xE7,0xB9,0x81), o3(0xE8,0x88,0xAC),
- o3(0xE8,0x97,0xA9), o3(0xE8,0xB2,0xA9),
- o3(0xE7,0xAF,0x84), o3(0xE9,0x87,0x86),
- o3(0xE7,0x85,0xA9), o3(0xE9,0xA0,0x92),
- o3(0xE9,0xA3,0xAF), o3(0xE6,0x8C,0xBD),
- o3(0xE6,0x99,0xA9), o3(0xE7,0x95,0xAA),
- o3(0xE7,0x9B,0xA4), o3(0xE7,0xA3,0x90),
- o3(0xE8,0x95,0x83), o3(0xE8,0x9B,0xAE),
- o3(0xE5,0x8C,0xAA), o3(0xE5,0x8D,0x91),
- o3(0xE5,0x90,0xA6), o3(0xE5,0xA6,0x83),
- o3(0xE5,0xBA,0x87), o3(0xE5,0xBD,0xBC),
- o3(0xE6,0x82,0xB2), o3(0xE6,0x89,0x89),
- o3(0xE6,0x89,0xB9), o3(0xE6,0x8A,0xAB),
- o3(0xE6,0x96,0x90), o3(0xE6,0xAF,0x94),
- o3(0xE6,0xB3,0x8C), o3(0xE7,0x96,0xB2),
- o3(0xE7,0x9A,0xAE), o3(0xE7,0xA2,0x91),
- o3(0xE7,0xA7,0x98), o3(0xE7,0xB7,0x8B),
- o3(0xE7,0xBD,0xB7), o3(0xE8,0x82,0xA5),
- o3(0xE8,0xA2,0xAB), o3(0xE8,0xAA,0xB9),
- o3(0xE8,0xB2,0xBB), o3(0xE9,0x81,0xBF),
- o3(0xE9,0x9D,0x9E), o3(0xE9,0xA3,0x9B),
- o3(0xE6,0xA8,0x8B), o3(0xE7,0xB0,0xB8),
- o3(0xE5,0x82,0x99), o3(0xE5,0xB0,0xBE),
- o3(0xE5,0xBE,0xAE), o3(0xE6,0x9E,0x87),
- o3(0xE6,0xAF,0x98), o3(0xE7,0x90,0xB5),
- o3(0xE7,0x9C,0x89), o3(0xE7,0xBE,0x8E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_94 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_94_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_95_infos[189] = {
- o3(0xE9,0xBC,0xBB), o3(0xE6,0x9F,0x8A),
- o3(0xE7,0xA8,0x97), o3(0xE5,0x8C,0xB9),
- o3(0xE7,0x96,0x8B), o3(0xE9,0xAB,0xAD),
- o3(0xE5,0xBD,0xA6), o3(0xE8,0x86,0x9D),
- o3(0xE8,0x8F,0xB1), o3(0xE8,0x82,0x98),
- o3(0xE5,0xBC,0xBC), o3(0xE5,0xBF,0x85),
- o3(0xE7,0x95,0xA2), o3(0xE7,0xAD,0x86),
- o3(0xE9,0x80,0xBC), o3(0xE6,0xA1,0xA7),
- o3(0xE5,0xA7,0xAB), o3(0xE5,0xAA,0x9B),
- o3(0xE7,0xB4,0x90), o3(0xE7,0x99,0xBE),
- o3(0xE8,0xAC,0xAC), o3(0xE4,0xBF,0xB5),
- o3(0xE5,0xBD,0xAA), o3(0xE6,0xA8,0x99),
- o3(0xE6,0xB0,0xB7), o3(0xE6,0xBC,0x82),
- o3(0xE7,0x93,0xA2), o3(0xE7,0xA5,0xA8),
- o3(0xE8,0xA1,0xA8), o3(0xE8,0xA9,0x95),
- o3(0xE8,0xB1,0xB9), o3(0xE5,0xBB,0x9F),
- o3(0xE6,0x8F,0x8F), o3(0xE7,0x97,0x85),
- o3(0xE7,0xA7,0x92), o3(0xE8,0x8B,0x97),
- o3(0xE9,0x8C,0xA8), o3(0xE9,0x8B,0xB2),
- o3(0xE8,0x92,0x9C), o3(0xE8,0x9B,0xAD),
- o3(0xE9,0xB0,0xAD), o3(0xE5,0x93,0x81),
- o3(0xE5,0xBD,0xAC), o3(0xE6,0x96,0x8C),
- o3(0xE6,0xB5,0x9C), o3(0xE7,0x80,0x95),
- o3(0xE8,0xB2,0xA7), o3(0xE8,0xB3,0x93),
- o3(0xE9,0xA0,0xBB), o3(0xE6,0x95,0x8F),
- o3(0xE7,0x93,0xB6), o3(0xE4,0xB8,0x8D),
- o3(0xE4,0xBB,0x98), o3(0xE5,0x9F,0xA0),
- o3(0xE5,0xA4,0xAB), o3(0xE5,0xA9,0xA6),
- o3(0xE5,0xAF,0x8C), o3(0xE5,0x86,0xA8),
- o3(0xE5,0xB8,0x83), o3(0xE5,0xBA,0x9C),
- o3(0xE6,0x80,0x96), o3(0xE6,0x89,0xB6),
- o3(0xE6,0x95,0xB7), o3(0xE6,0x96,0xA7),
- o3(0xE6,0x99,0xAE), o3(0xE6,0xB5,0xAE),
- o3(0xE7,0x88,0xB6), o3(0xE7,0xAC,0xA6),
- o3(0xE8,0x85,0x90), o3(0xE8,0x86,0x9A),
- o3(0xE8,0x8A,0x99), o3(0xE8,0xAD,0x9C),
- o3(0xE8,0xB2,0xA0), o3(0xE8,0xB3,0xA6),
- o3(0xE8,0xB5,0xB4), o3(0xE9,0x98,0x9C),
- o3(0xE9,0x99,0x84), o3(0xE4,0xBE,0xAE),
- o3(0xE6,0x92,0xAB), o3(0xE6,0xAD,0xA6),
- o3(0xE8,0x88,0x9E), o3(0xE8,0x91,0xA1),
- o3(0xE8,0x95,0xAA), o3(0xE9,0x83,0xA8),
- o3(0xE5,0xB0,0x81), o3(0xE6,0xA5,0x93),
- o3(0xE9,0xA2,0xA8), o3(0xE8,0x91,0xBA),
- o3(0xE8,0x95,0x97), o3(0xE4,0xBC,0x8F),
- o3(0xE5,0x89,0xAF), o3(0xE5,0xBE,0xA9),
- o3(0xE5,0xB9,0x85), o3(0xE6,0x9C,0x8D),
- o3(0xE7,0xA6,0x8F), o3(0xE8,0x85,0xB9),
- o3(0xE8,0xA4,0x87), o3(0xE8,0xA6,0x86),
- o3(0xE6,0xB7,0xB5), o3(0xE5,0xBC,0x97),
- o3(0xE6,0x89,0x95), o3(0xE6,0xB2,0xB8),
- o3(0xE4,0xBB,0x8F), o3(0xE7,0x89,0xA9),
- o3(0xE9,0xAE,0x92), o3(0xE5,0x88,0x86),
- o3(0xE5,0x90,0xBB), o3(0xE5,0x99,0xB4),
- o3(0xE5,0xA2,0xB3), o3(0xE6,0x86,0xA4),
- o3(0xE6,0x89,0xAE), o3(0xE7,0x84,0x9A),
- o3(0xE5,0xA5,0xAE), o3(0xE7,0xB2,0x89),
- o3(0xE7,0xB3,0x9E), o3(0xE7,0xB4,0x9B),
- o3(0xE9,0x9B,0xB0), o3(0xE6,0x96,0x87),
- o3(0xE8,0x81,0x9E), o3(0xE4,0xB8,0x99),
- o3(0xE4,0xBD,0xB5), o3(0xE5,0x85,0xB5),
- o3(0xE5,0xA1,0x80), o3(0xE5,0xB9,0xA3),
- o3(0xE5,0xB9,0xB3), o3(0xE5,0xBC,0x8A),
- o3(0xE6,0x9F,0x84), o3(0xE4,0xB8,0xA6),
- o3(0xE8,0x94,0xBD), o3(0xE9,0x96,0x89),
- o3(0xE9,0x99,0x9B), o3(0xE7,0xB1,0xB3),
- o3(0xE9,0xA0,0x81), o3(0xE5,0x83,0xBB),
- o3(0xE5,0xA3,0x81), o3(0xE7,0x99,0x96),
- o3(0xE7,0xA2,0xA7), o3(0xE5,0x88,0xA5),
- o3(0xE7,0x9E,0xA5), o3(0xE8,0x94,0x91),
- o3(0xE7,0xAE,0x86), o3(0xE5,0x81,0x8F),
- o3(0xE5,0xA4,0x89), o3(0xE7,0x89,0x87),
- o3(0xE7,0xAF,0x87), o3(0xE7,0xB7,0xA8),
- o3(0xE8,0xBE,0xBA), o3(0xE8,0xBF,0x94),
- o3(0xE9,0x81,0x8D), o3(0xE4,0xBE,0xBF),
- o3(0xE5,0x8B,0x89), o3(0xE5,0xA8,0xA9),
- o3(0xE5,0xBC,0x81), o3(0xE9,0x9E,0xAD),
- o3(0xE4,0xBF,0x9D), o3(0xE8,0x88,0x97),
- o3(0xE9,0x8B,0xAA), o3(0xE5,0x9C,0x83),
- o3(0xE6,0x8D,0x95), o3(0xE6,0xAD,0xA9),
- o3(0xE7,0x94,0xAB), o3(0xE8,0xA3,0x9C),
- o3(0xE8,0xBC,0x94), o3(0xE7,0xA9,0x82),
- o3(0xE5,0x8B,0x9F), o3(0xE5,0xA2,0x93),
- o3(0xE6,0x85,0x95), o3(0xE6,0x88,0x8A),
- o3(0xE6,0x9A,0xAE), o3(0xE6,0xAF,0x8D),
- o3(0xE7,0xB0,0xBF), o3(0xE8,0x8F,0xA9),
- o3(0xE5,0x80,0xA3), o3(0xE4,0xBF,0xB8),
- o3(0xE5,0x8C,0x85), o3(0xE5,0x91,0x86),
- o3(0xE5,0xA0,0xB1), o3(0xE5,0xA5,0x89),
- o3(0xE5,0xAE,0x9D), o3(0xE5,0xB3,0xB0),
- o3(0xE5,0xB3,0xAF), o3(0xE5,0xB4,0xA9),
- o3(0xE5,0xBA,0x96), o3(0xE6,0x8A,0xB1),
- o3(0xE6,0x8D,0xA7), o3(0xE6,0x94,0xBE),
- o3(0xE6,0x96,0xB9), o3(0xE6,0x9C,0x8B),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_95 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_95_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_96_infos[189] = {
- o3(0xE6,0xB3,0x95), o3(0xE6,0xB3,0xA1),
- o3(0xE7,0x83,0xB9), o3(0xE7,0xA0,0xB2),
- o3(0xE7,0xB8,0xAB), o3(0xE8,0x83,0x9E),
- o3(0xE8,0x8A,0xB3), o3(0xE8,0x90,0x8C),
- o3(0xE8,0x93,0xAC), o3(0xE8,0x9C,0x82),
- o3(0xE8,0xA4,0x92), o3(0xE8,0xA8,0xAA),
- o3(0xE8,0xB1,0x8A), o3(0xE9,0x82,0xA6),
- o3(0xE9,0x8B,0x92), o3(0xE9,0xA3,0xBD),
- o3(0xE9,0xB3,0xB3), o3(0xE9,0xB5,0xAC),
- o3(0xE4,0xB9,0x8F), o3(0xE4,0xBA,0xA1),
- o3(0xE5,0x82,0x8D), o3(0xE5,0x89,0x96),
- o3(0xE5,0x9D,0x8A), o3(0xE5,0xA6,0xA8),
- o3(0xE5,0xB8,0xBD), o3(0xE5,0xBF,0x98),
- o3(0xE5,0xBF,0x99), o3(0xE6,0x88,0xBF),
- o3(0xE6,0x9A,0xB4), o3(0xE6,0x9C,0x9B),
- o3(0xE6,0x9F,0x90), o3(0xE6,0xA3,0x92),
- o3(0xE5,0x86,0x92), o3(0xE7,0xB4,0xA1),
- o3(0xE8,0x82,0xAA), o3(0xE8,0x86,0xA8),
- o3(0xE8,0xAC,0x80), o3(0xE8,0xB2,0x8C),
- o3(0xE8,0xB2,0xBF), o3(0xE9,0x89,0xBE),
- o3(0xE9,0x98,0xB2), o3(0xE5,0x90,0xA0),
- o3(0xE9,0xA0,0xAC), o3(0xE5,0x8C,0x97),
- o3(0xE5,0x83,0x95), o3(0xE5,0x8D,0x9C),
- o3(0xE5,0xA2,0xA8), o3(0xE6,0x92,0xB2),
- o3(0xE6,0x9C,0xB4), o3(0xE7,0x89,0xA7),
- o3(0xE7,0x9D,0xA6), o3(0xE7,0xA9,0x86),
- o3(0xE9,0x87,0xA6), o3(0xE5,0x8B,0x83),
- o3(0xE6,0xB2,0xA1), o3(0xE6,0xAE,0x86),
- o3(0xE5,0xA0,0x80), o3(0xE5,0xB9,0x8C),
- o3(0xE5,0xA5,0x94), o3(0xE6,0x9C,0xAC),
- o3(0xE7,0xBF,0xBB), o3(0xE5,0x87,0xA1),
- o3(0xE7,0x9B,0x86), o3(0xE6,0x91,0xA9),
- o3(0xE7,0xA3,0xA8), o3(0xE9,0xAD,0x94),
- o3(0xE9,0xBA,0xBB), o3(0xE5,0x9F,0x8B),
- o3(0xE5,0xA6,0xB9), o3(0xE6,0x98,0xA7),
- o3(0xE6,0x9E,0x9A), o3(0xE6,0xAF,0x8E),
- o3(0xE5,0x93,0xA9), o3(0xE6,0xA7,0x99),
- o3(0xE5,0xB9,0x95), o3(0xE8,0x86,0x9C),
- o3(0xE6,0x9E,0x95), o3(0xE9,0xAE,0xAA),
- o3(0xE6,0x9F,0xBE), o3(0xE9,0xB1,0x92),
- o3(0xE6,0xA1,0x9D), o3(0xE4,0xBA,0xA6),
- o3(0xE4,0xBF,0xA3), o3(0xE5,0x8F,0x88),
- o3(0xE6,0x8A,0xB9), o3(0xE6,0x9C,0xAB),
- o3(0xE6,0xB2,0xAB), o3(0xE8,0xBF,0x84),
- o3(0xE4,0xBE,0xAD), o3(0xE7,0xB9,0xAD),
- o3(0xE9,0xBA,0xBF), o3(0xE4,0xB8,0x87),
- o3(0xE6,0x85,0xA2), o3(0xE6,0xBA,0x80),
- o3(0xE6,0xBC,0xAB), o3(0xE8,0x94,0x93),
- o3(0xE5,0x91,0xB3), o3(0xE6,0x9C,0xAA),
- o3(0xE9,0xAD,0x85), o3(0xE5,0xB7,0xB3),
- o3(0xE7,0xAE,0x95), o3(0xE5,0xB2,0xAC),
- o3(0xE5,0xAF,0x86), o3(0xE8,0x9C,0x9C),
- o3(0xE6,0xB9,0x8A), o3(0xE8,0x93,0x91),
- o3(0xE7,0xA8,0x94), o3(0xE8,0x84,0x88),
- o3(0xE5,0xA6,0x99), o3(0xE7,0xB2,0x8D),
- o3(0xE6,0xB0,0x91), o3(0xE7,0x9C,0xA0),
- o3(0xE5,0x8B,0x99), o3(0xE5,0xA4,0xA2),
- o3(0xE7,0x84,0xA1), o3(0xE7,0x89,0x9F),
- o3(0xE7,0x9F,0x9B), o3(0xE9,0x9C,0xA7),
- o3(0xE9,0xB5,0xA1), o3(0xE6,0xA4,0x8B),
- o3(0xE5,0xA9,0xBF), o3(0xE5,0xA8,0x98),
- o3(0xE5,0x86,0xA5), o3(0xE5,0x90,0x8D),
- o3(0xE5,0x91,0xBD), o3(0xE6,0x98,0x8E),
- o3(0xE7,0x9B,0x9F), o3(0xE8,0xBF,0xB7),
- o3(0xE9,0x8A,0x98), o3(0xE9,0xB3,0xB4),
- o3(0xE5,0xA7,0xAA), o3(0xE7,0x89,0x9D),
- o3(0xE6,0xBB,0x85), o3(0xE5,0x85,0x8D),
- o3(0xE6,0xA3,0x89), o3(0xE7,0xB6,0xBF),
- o3(0xE7,0xB7,0xAC), o3(0xE9,0x9D,0xA2),
- o3(0xE9,0xBA,0xBA), o3(0xE6,0x91,0xB8),
- o3(0xE6,0xA8,0xA1), o3(0xE8,0x8C,0x82),
- o3(0xE5,0xA6,0x84), o3(0xE5,0xAD,0x9F),
- o3(0xE6,0xAF,0x9B), o3(0xE7,0x8C,0x9B),
- o3(0xE7,0x9B,0xB2), o3(0xE7,0xB6,0xB2),
- o3(0xE8,0x80,0x97), o3(0xE8,0x92,0x99),
- o3(0xE5,0x84,0xB2), o3(0xE6,0x9C,0xA8),
- o3(0xE9,0xBB,0x99), o3(0xE7,0x9B,0xAE),
- o3(0xE6,0x9D,0xA2), o3(0xE5,0x8B,0xBF),
- o3(0xE9,0xA4,0x85), o3(0xE5,0xB0,0xA4),
- o3(0xE6,0x88,0xBB), o3(0xE7,0xB1,0xBE),
- o3(0xE8,0xB2,0xB0), o3(0xE5,0x95,0x8F),
- o3(0xE6,0x82,0xB6), o3(0xE7,0xB4,0x8B),
- o3(0xE9,0x96,0x80), o3(0xE5,0x8C,0x81),
- o3(0xE4,0xB9,0x9F), o3(0xE5,0x86,0xB6),
- o3(0xE5,0xA4,0x9C), o3(0xE7,0x88,0xBA),
- o3(0xE8,0x80,0xB6), o3(0xE9,0x87,0x8E),
- o3(0xE5,0xBC,0xA5), o3(0xE7,0x9F,0xA2),
- o3(0xE5,0x8E,0x84), o3(0xE5,0xBD,0xB9),
- o3(0xE7,0xB4,0x84), o3(0xE8,0x96,0xAC),
- o3(0xE8,0xA8,0xB3), o3(0xE8,0xBA,0x8D),
- o3(0xE9,0x9D,0x96), o3(0xE6,0x9F,0xB3),
- o3(0xE8,0x96,0xAE), o3(0xE9,0x91,0x93),
- o3(0xE6,0x84,0x89), o3(0xE6,0x84,0x88),
- o3(0xE6,0xB2,0xB9), o3(0xE7,0x99,0x92),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_96 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_96_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_97_infos[189] = {
- o3(0xE8,0xAB,0xAD), o3(0xE8,0xBC,0xB8),
- o3(0xE5,0x94,0xAF), o3(0xE4,0xBD,0x91),
- o3(0xE5,0x84,0xAA), o3(0xE5,0x8B,0x87),
- o3(0xE5,0x8F,0x8B), o3(0xE5,0xAE,0xA5),
- o3(0xE5,0xB9,0xBD), o3(0xE6,0x82,0xA0),
- o3(0xE6,0x86,0x82), o3(0xE6,0x8F,0x96),
- o3(0xE6,0x9C,0x89), o3(0xE6,0x9F,0x9A),
- o3(0xE6,0xB9,0xA7), o3(0xE6,0xB6,0x8C),
- o3(0xE7,0x8C,0xB6), o3(0xE7,0x8C,0xB7),
- o3(0xE7,0x94,0xB1), o3(0xE7,0xA5,0x90),
- o3(0xE8,0xA3,0x95), o3(0xE8,0xAA,0x98),
- o3(0xE9,0x81,0x8A), o3(0xE9,0x82,0x91),
- o3(0xE9,0x83,0xB5), o3(0xE9,0x9B,0x84),
- o3(0xE8,0x9E,0x8D), o3(0xE5,0xA4,0x95),
- o3(0xE4,0xBA,0x88), o3(0xE4,0xBD,0x99),
- o3(0xE4,0xB8,0x8E), o3(0xE8,0xAA,0x89),
- o3(0xE8,0xBC,0xBF), o3(0xE9,0xA0,0x90),
- o3(0xE5,0x82,0xAD), o3(0xE5,0xB9,0xBC),
- o3(0xE5,0xA6,0x96), o3(0xE5,0xAE,0xB9),
- o3(0xE5,0xBA,0xB8), o3(0xE6,0x8F,0x9A),
- o3(0xE6,0x8F,0xBA), o3(0xE6,0x93,0x81),
- o3(0xE6,0x9B,0x9C), o3(0xE6,0xA5,0x8A),
- o3(0xE6,0xA7,0x98), o3(0xE6,0xB4,0x8B),
- o3(0xE6,0xBA,0xB6), o3(0xE7,0x86,0x94),
- o3(0xE7,0x94,0xA8), o3(0xE7,0xAA,0xAF),
- o3(0xE7,0xBE,0x8A), o3(0xE8,0x80,0x80),
- o3(0xE8,0x91,0x89), o3(0xE8,0x93,0x89),
- o3(0xE8,0xA6,0x81), o3(0xE8,0xAC,0xA1),
- o3(0xE8,0xB8,0x8A), o3(0xE9,0x81,0xA5),
- o3(0xE9,0x99,0xBD), o3(0xE9,0xA4,0x8A),
- o3(0xE6,0x85,0xBE), o3(0xE6,0x8A,0x91),
- o3(0xE6,0xAC,0xB2), o3(0xE6,0xB2,0x83),
- o3(0xE6,0xB5,0xB4), o3(0xE7,0xBF,0x8C),
- o3(0xE7,0xBF,0xBC), o3(0xE6,0xB7,0x80),
- o3(0xE7,0xBE,0x85), o3(0xE8,0x9E,0xBA),
- o3(0xE8,0xA3,0xB8), o3(0xE6,0x9D,0xA5),
- o3(0xE8,0x8E,0xB1), o3(0xE9,0xA0,0xBC),
- o3(0xE9,0x9B,0xB7), o3(0xE6,0xB4,0x9B),
- o3(0xE7,0xB5,0xA1), o3(0xE8,0x90,0xBD),
- o3(0xE9,0x85,0xAA), o3(0xE4,0xB9,0xB1),
- o3(0xE5,0x8D,0xB5), o3(0xE5,0xB5,0x90),
- o3(0xE6,0xAC,0x84), o3(0xE6,0xBF,0xAB),
- o3(0xE8,0x97,0x8D), o3(0xE8,0x98,0xAD),
- o3(0xE8,0xA6,0xA7), o3(0xE5,0x88,0xA9),
- o3(0xE5,0x90,0x8F), o3(0xE5,0xB1,0xA5),
- o3(0xE6,0x9D,0x8E), o3(0xE6,0xA2,0xA8),
- o3(0xE7,0x90,0x86), o3(0xE7,0x92,0x83),
- o3(0xE7,0x97,0xA2), o3(0xE8,0xA3,0x8F),
- o3(0xE8,0xA3,0xA1), o3(0xE9,0x87,0x8C),
- o3(0xE9,0x9B,0xA2), o3(0xE9,0x99,0xB8),
- o3(0xE5,0xBE,0x8B), o3(0xE7,0x8E,0x87),
- o3(0xE7,0xAB,0x8B), o3(0xE8,0x91,0x8E),
- o3(0xE6,0x8E,0xA0), o3(0xE7,0x95,0xA5),
- o3(0xE5,0x8A,0x89), o3(0xE6,0xB5,0x81),
- o3(0xE6,0xBA,0x9C), o3(0xE7,0x90,0x89),
- o3(0xE7,0x95,0x99), o3(0xE7,0xA1,0xAB),
- o3(0xE7,0xB2,0x92), o3(0xE9,0x9A,0x86),
- o3(0xE7,0xAB,0x9C), o3(0xE9,0xBE,0x8D),
- o3(0xE4,0xBE,0xB6), o3(0xE6,0x85,0xAE),
- o3(0xE6,0x97,0x85), o3(0xE8,0x99,0x9C),
- o3(0xE4,0xBA,0x86), o3(0xE4,0xBA,0xAE),
- o3(0xE5,0x83,0x9A), o3(0xE4,0xB8,0xA1),
- o3(0xE5,0x87,0x8C), o3(0xE5,0xAF,0xAE),
- o3(0xE6,0x96,0x99), o3(0xE6,0xA2,0x81),
- o3(0xE6,0xB6,0xBC), o3(0xE7,0x8C,0x9F),
- o3(0xE7,0x99,0x82), o3(0xE7,0x9E,0xAD),
- o3(0xE7,0xA8,0x9C), o3(0xE7,0xB3,0xA7),
- o3(0xE8,0x89,0xAF), o3(0xE8,0xAB,0x92),
- o3(0xE9,0x81,0xBC), o3(0xE9,0x87,0x8F),
- o3(0xE9,0x99,0xB5), o3(0xE9,0xA0,0x98),
- o3(0xE5,0x8A,0x9B), o3(0xE7,0xB7,0x91),
- o3(0xE5,0x80,0xAB), o3(0xE5,0x8E,0x98),
- o3(0xE6,0x9E,0x97), o3(0xE6,0xB7,0x8B),
- o3(0xE7,0x87,0x90), o3(0xE7,0x90,0xB3),
- o3(0xE8,0x87,0xA8), o3(0xE8,0xBC,0xAA),
- o3(0xE9,0x9A,0xA3), o3(0xE9,0xB1,0x97),
- o3(0xE9,0xBA,0x9F), o3(0xE7,0x91,0xA0),
- o3(0xE5,0xA1,0x81), o3(0xE6,0xB6,0x99),
- o3(0xE7,0xB4,0xAF), o3(0xE9,0xA1,0x9E),
- o3(0xE4,0xBB,0xA4), o3(0xE4,0xBC,0xB6),
- o3(0xE4,0xBE,0x8B), o3(0xE5,0x86,0xB7),
- o3(0xE5,0x8A,0xB1), o3(0xE5,0xB6,0xBA),
- o3(0xE6,0x80,0x9C), o3(0xE7,0x8E,0xB2),
- o3(0xE7,0xA4,0xBC), o3(0xE8,0x8B,0x93),
- o3(0xE9,0x88,0xB4), o3(0xE9,0x9A,0xB7),
- o3(0xE9,0x9B,0xB6), o3(0xE9,0x9C,0x8A),
- o3(0xE9,0xBA,0x97), o3(0xE9,0xBD,0xA2),
- o3(0xE6,0x9A,0xA6), o3(0xE6,0xAD,0xB4),
- o3(0xE5,0x88,0x97), o3(0xE5,0x8A,0xA3),
- o3(0xE7,0x83,0x88), o3(0xE8,0xA3,0x82),
- o3(0xE5,0xBB,0x89), o3(0xE6,0x81,0x8B),
- o3(0xE6,0x86,0x90), o3(0xE6,0xBC,0xA3),
- o3(0xE7,0x85,0x89), o3(0xE7,0xB0,0xBE),
- o3(0xE7,0xB7,0xB4), o3(0xE8,0x81,0xAF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_97 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_97_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_98_offsets[256] = {
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145,145,
- 145,145,145,145,145,145,145,145, 145,145,145,145,145,145,145, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
- 100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115,
- 116,117,118,119,120,121,122,123, 124,125,126,127,128,129,130,131,
- 132,133,134,135,136,137,138,139, 140,141,142,143,144,145,145,145,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_98_infos[146] = {
- o3(0xE8,0x93,0xAE), o3(0xE9,0x80,0xA3),
- o3(0xE9,0x8C,0xAC), o3(0xE5,0x91,0x82),
- o3(0xE9,0xAD,0xAF), o3(0xE6,0xAB,0x93),
- o3(0xE7,0x82,0x89), o3(0xE8,0xB3,0x82),
- o3(0xE8,0xB7,0xAF), o3(0xE9,0x9C,0xB2),
- o3(0xE5,0x8A,0xB4), o3(0xE5,0xA9,0x81),
- o3(0xE5,0xBB,0x8A), o3(0xE5,0xBC,0x84),
- o3(0xE6,0x9C,0x97), o3(0xE6,0xA5,0xBC),
- o3(0xE6,0xA6,0x94), o3(0xE6,0xB5,0xAA),
- o3(0xE6,0xBC,0x8F), o3(0xE7,0x89,0xA2),
- o3(0xE7,0x8B,0xBC), o3(0xE7,0xAF,0xAD),
- o3(0xE8,0x80,0x81), o3(0xE8,0x81,0xBE),
- o3(0xE8,0x9D,0x8B), o3(0xE9,0x83,0x8E),
- o3(0xE5,0x85,0xAD), o3(0xE9,0xBA,0x93),
- o3(0xE7,0xA6,0x84), o3(0xE8,0x82,0x8B),
- o3(0xE9,0x8C,0xB2), o3(0xE8,0xAB,0x96),
- o3(0xE5,0x80,0xAD), o3(0xE5,0x92,0x8C),
- o3(0xE8,0xA9,0xB1), o3(0xE6,0xAD,0xAA),
- o3(0xE8,0xB3,0x84), o3(0xE8,0x84,0x87),
- o3(0xE6,0x83,0x91), o3(0xE6,0x9E,0xA0),
- o3(0xE9,0xB7,0xB2), o3(0xE4,0xBA,0x99),
- o3(0xE4,0xBA,0x98), o3(0xE9,0xB0,0x90),
- o3(0xE8,0xA9,0xAB), o3(0xE8,0x97,0x81),
- o3(0xE8,0x95,0xA8), o3(0xE6,0xA4,0x80),
- o3(0xE6,0xB9,0xBE), o3(0xE7,0xA2,0x97),
- o3(0xE8,0x85,0x95), o3(0xE5,0xBC,0x8C),
- o3(0xE4,0xB8,0x90), o3(0xE4,0xB8,0x95),
- o3(0xE4,0xB8,0xAA), o3(0xE4,0xB8,0xB1),
- o3(0xE4,0xB8,0xB6), o3(0xE4,0xB8,0xBC),
- o3(0xE4,0xB8,0xBF), o3(0xE4,0xB9,0x82),
- o3(0xE4,0xB9,0x96), o3(0xE4,0xB9,0x98),
- o3(0xE4,0xBA,0x82), o3(0xE4,0xBA,0x85),
- o3(0xE8,0xB1,0xAB), o3(0xE4,0xBA,0x8A),
- o3(0xE8,0x88,0x92), o3(0xE5,0xBC,0x8D),
- o3(0xE4,0xBA,0x8E), o3(0xE4,0xBA,0x9E),
- o3(0xE4,0xBA,0x9F), o3(0xE4,0xBA,0xA0),
- o3(0xE4,0xBA,0xA2), o3(0xE4,0xBA,0xB0),
- o3(0xE4,0xBA,0xB3), o3(0xE4,0xBA,0xB6),
- o3(0xE4,0xBB,0x8E), o3(0xE4,0xBB,0x8D),
- o3(0xE4,0xBB,0x84), o3(0xE4,0xBB,0x86),
- o3(0xE4,0xBB,0x82), o3(0xE4,0xBB,0x97),
- o3(0xE4,0xBB,0x9E), o3(0xE4,0xBB,0xAD),
- o3(0xE4,0xBB,0x9F), o3(0xE4,0xBB,0xB7),
- o3(0xE4,0xBC,0x89), o3(0xE4,0xBD,0x9A),
- o3(0xE4,0xBC,0xB0), o3(0xE4,0xBD,0x9B),
- o3(0xE4,0xBD,0x9D), o3(0xE4,0xBD,0x97),
- o3(0xE4,0xBD,0x87), o3(0xE4,0xBD,0xB6),
- o3(0xE4,0xBE,0x88), o3(0xE4,0xBE,0x8F),
- o3(0xE4,0xBE,0x98), o3(0xE4,0xBD,0xBB),
- o3(0xE4,0xBD,0xA9), o3(0xE4,0xBD,0xB0),
- o3(0xE4,0xBE,0x91), o3(0xE4,0xBD,0xAF),
- o3(0xE4,0xBE,0x86), o3(0xE4,0xBE,0x96),
- o3(0xE5,0x84,0x98), o3(0xE4,0xBF,0x94),
- o3(0xE4,0xBF,0x9F), o3(0xE4,0xBF,0x8E),
- o3(0xE4,0xBF,0x98), o3(0xE4,0xBF,0x9B),
- o3(0xE4,0xBF,0x91), o3(0xE4,0xBF,0x9A),
- o3(0xE4,0xBF,0x90), o3(0xE4,0xBF,0xA4),
- o3(0xE4,0xBF,0xA5), o3(0xE5,0x80,0x9A),
- o3(0xE5,0x80,0xA8), o3(0xE5,0x80,0x94),
- o3(0xE5,0x80,0xAA), o3(0xE5,0x80,0xA5),
- o3(0xE5,0x80,0x85), o3(0xE4,0xBC,0x9C),
- o3(0xE4,0xBF,0xB6), o3(0xE5,0x80,0xA1),
- o3(0xE5,0x80,0xA9), o3(0xE5,0x80,0xAC),
- o3(0xE4,0xBF,0xBE), o3(0xE4,0xBF,0xAF),
- o3(0xE5,0x80,0x91), o3(0xE5,0x80,0x86),
- o3(0xE5,0x81,0x83), o3(0xE5,0x81,0x87),
- o3(0xE6,0x9C,0x83), o3(0xE5,0x81,0x95),
- o3(0xE5,0x81,0x90), o3(0xE5,0x81,0x88),
- o3(0xE5,0x81,0x9A), o3(0xE5,0x81,0x96),
- o3(0xE5,0x81,0xAC), o3(0xE5,0x81,0xB8),
- o3(0xE5,0x82,0x80), o3(0xE5,0x82,0x9A),
- o3(0xE5,0x82,0x85), o3(0xE5,0x82,0xB4),
- o3(0xE5,0x82,0xB2), UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_98 = {
- from_SHIFT_JIS_98_offsets,
- from_SHIFT_JIS_98_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_99_infos[189] = {
- o3(0xE5,0x83,0x89), o3(0xE5,0x83,0x8A),
- o3(0xE5,0x82,0xB3), o3(0xE5,0x83,0x82),
- o3(0xE5,0x83,0x96), o3(0xE5,0x83,0x9E),
- o3(0xE5,0x83,0xA5), o3(0xE5,0x83,0xAD),
- o3(0xE5,0x83,0xA3), o3(0xE5,0x83,0xAE),
- o3(0xE5,0x83,0xB9), o3(0xE5,0x83,0xB5),
- o3(0xE5,0x84,0x89), o3(0xE5,0x84,0x81),
- o3(0xE5,0x84,0x82), o3(0xE5,0x84,0x96),
- o3(0xE5,0x84,0x95), o3(0xE5,0x84,0x94),
- o3(0xE5,0x84,0x9A), o3(0xE5,0x84,0xA1),
- o3(0xE5,0x84,0xBA), o3(0xE5,0x84,0xB7),
- o3(0xE5,0x84,0xBC), o3(0xE5,0x84,0xBB),
- o3(0xE5,0x84,0xBF), o3(0xE5,0x85,0x80),
- o3(0xE5,0x85,0x92), o3(0xE5,0x85,0x8C),
- o3(0xE5,0x85,0x94), o3(0xE5,0x85,0xA2),
- o3(0xE7,0xAB,0xB8), o3(0xE5,0x85,0xA9),
- o3(0xE5,0x85,0xAA), o3(0xE5,0x85,0xAE),
- o3(0xE5,0x86,0x80), o3(0xE5,0x86,0x82),
- o3(0xE5,0x9B,0x98), o3(0xE5,0x86,0x8C),
- o3(0xE5,0x86,0x89), o3(0xE5,0x86,0x8F),
- o3(0xE5,0x86,0x91), o3(0xE5,0x86,0x93),
- o3(0xE5,0x86,0x95), o3(0xE5,0x86,0x96),
- o3(0xE5,0x86,0xA4), o3(0xE5,0x86,0xA6),
- o3(0xE5,0x86,0xA2), o3(0xE5,0x86,0xA9),
- o3(0xE5,0x86,0xAA), o3(0xE5,0x86,0xAB),
- o3(0xE5,0x86,0xB3), o3(0xE5,0x86,0xB1),
- o3(0xE5,0x86,0xB2), o3(0xE5,0x86,0xB0),
- o3(0xE5,0x86,0xB5), o3(0xE5,0x86,0xBD),
- o3(0xE5,0x87,0x85), o3(0xE5,0x87,0x89),
- o3(0xE5,0x87,0x9B), o3(0xE5,0x87,0xA0),
- o3(0xE8,0x99,0x95), o3(0xE5,0x87,0xA9),
- o3(0xE5,0x87,0xAD), o3(0xE5,0x87,0xB0),
- o3(0xE5,0x87,0xB5), o3(0xE5,0x87,0xBE),
- o3(0xE5,0x88,0x84), o3(0xE5,0x88,0x8B),
- o3(0xE5,0x88,0x94), o3(0xE5,0x88,0x8E),
- o3(0xE5,0x88,0xA7), o3(0xE5,0x88,0xAA),
- o3(0xE5,0x88,0xAE), o3(0xE5,0x88,0xB3),
- o3(0xE5,0x88,0xB9), o3(0xE5,0x89,0x8F),
- o3(0xE5,0x89,0x84), o3(0xE5,0x89,0x8B),
- o3(0xE5,0x89,0x8C), o3(0xE5,0x89,0x9E),
- o3(0xE5,0x89,0x94), o3(0xE5,0x89,0xAA),
- o3(0xE5,0x89,0xB4), o3(0xE5,0x89,0xA9),
- o3(0xE5,0x89,0xB3), o3(0xE5,0x89,0xBF),
- o3(0xE5,0x89,0xBD), o3(0xE5,0x8A,0x8D),
- o3(0xE5,0x8A,0x94), o3(0xE5,0x8A,0x92),
- o3(0xE5,0x89,0xB1), o3(0xE5,0x8A,0x88),
- o3(0xE5,0x8A,0x91), o3(0xE8,0xBE,0xA8),
- o3(0xE8,0xBE,0xA7), o3(0xE5,0x8A,0xAC),
- o3(0xE5,0x8A,0xAD), o3(0xE5,0x8A,0xBC),
- o3(0xE5,0x8A,0xB5), o3(0xE5,0x8B,0x81),
- o3(0xE5,0x8B,0x8D), o3(0xE5,0x8B,0x97),
- o3(0xE5,0x8B,0x9E), o3(0xE5,0x8B,0xA3),
- o3(0xE5,0x8B,0xA6), o3(0xE9,0xA3,0xAD),
- o3(0xE5,0x8B,0xA0), o3(0xE5,0x8B,0xB3),
- o3(0xE5,0x8B,0xB5), o3(0xE5,0x8B,0xB8),
- o3(0xE5,0x8B,0xB9), o3(0xE5,0x8C,0x86),
- o3(0xE5,0x8C,0x88), o3(0xE7,0x94,0xB8),
- o3(0xE5,0x8C,0x8D), o3(0xE5,0x8C,0x90),
- o3(0xE5,0x8C,0x8F), o3(0xE5,0x8C,0x95),
- o3(0xE5,0x8C,0x9A), o3(0xE5,0x8C,0xA3),
- o3(0xE5,0x8C,0xAF), o3(0xE5,0x8C,0xB1),
- o3(0xE5,0x8C,0xB3), o3(0xE5,0x8C,0xB8),
- o3(0xE5,0x8D,0x80), o3(0xE5,0x8D,0x86),
- o3(0xE5,0x8D,0x85), o3(0xE4,0xB8,0x97),
- o3(0xE5,0x8D,0x89), o3(0xE5,0x8D,0x8D),
- o3(0xE5,0x87,0x96), o3(0xE5,0x8D,0x9E),
- o3(0xE5,0x8D,0xA9), o3(0xE5,0x8D,0xAE),
- o3(0xE5,0xA4,0x98), o3(0xE5,0x8D,0xBB),
- o3(0xE5,0x8D,0xB7), o3(0xE5,0x8E,0x82),
- o3(0xE5,0x8E,0x96), o3(0xE5,0x8E,0xA0),
- o3(0xE5,0x8E,0xA6), o3(0xE5,0x8E,0xA5),
- o3(0xE5,0x8E,0xAE), o3(0xE5,0x8E,0xB0),
- o3(0xE5,0x8E,0xB6), o3(0xE5,0x8F,0x83),
- o3(0xE7,0xB0,0x92), o3(0xE9,0x9B,0x99),
- o3(0xE5,0x8F,0x9F), o3(0xE6,0x9B,0xBC),
- o3(0xE7,0x87,0xAE), o3(0xE5,0x8F,0xAE),
- o3(0xE5,0x8F,0xA8), o3(0xE5,0x8F,0xAD),
- o3(0xE5,0x8F,0xBA), o3(0xE5,0x90,0x81),
- o3(0xE5,0x90,0xBD), o3(0xE5,0x91,0x80),
- o3(0xE5,0x90,0xAC), o3(0xE5,0x90,0xAD),
- o3(0xE5,0x90,0xBC), o3(0xE5,0x90,0xAE),
- o3(0xE5,0x90,0xB6), o3(0xE5,0x90,0xA9),
- o3(0xE5,0x90,0x9D), o3(0xE5,0x91,0x8E),
- o3(0xE5,0x92,0x8F), o3(0xE5,0x91,0xB5),
- o3(0xE5,0x92,0x8E), o3(0xE5,0x91,0x9F),
- o3(0xE5,0x91,0xB1), o3(0xE5,0x91,0xB7),
- o3(0xE5,0x91,0xB0), o3(0xE5,0x92,0x92),
- o3(0xE5,0x91,0xBB), o3(0xE5,0x92,0x80),
- o3(0xE5,0x91,0xB6), o3(0xE5,0x92,0x84),
- o3(0xE5,0x92,0x90), o3(0xE5,0x92,0x86),
- o3(0xE5,0x93,0x87), o3(0xE5,0x92,0xA2),
- o3(0xE5,0x92,0xB8), o3(0xE5,0x92,0xA5),
- o3(0xE5,0x92,0xAC), o3(0xE5,0x93,0x84),
- o3(0xE5,0x93,0x88), o3(0xE5,0x92,0xA8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_99 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_99_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_9A_infos[189] = {
- o3(0xE5,0x92,0xAB), o3(0xE5,0x93,0x82),
- o3(0xE5,0x92,0xA4), o3(0xE5,0x92,0xBE),
- o3(0xE5,0x92,0xBC), o3(0xE5,0x93,0x98),
- o3(0xE5,0x93,0xA5), o3(0xE5,0x93,0xA6),
- o3(0xE5,0x94,0x8F), o3(0xE5,0x94,0x94),
- o3(0xE5,0x93,0xBD), o3(0xE5,0x93,0xAE),
- o3(0xE5,0x93,0xAD), o3(0xE5,0x93,0xBA),
- o3(0xE5,0x93,0xA2), o3(0xE5,0x94,0xB9),
- o3(0xE5,0x95,0x80), o3(0xE5,0x95,0xA3),
- o3(0xE5,0x95,0x8C), o3(0xE5,0x94,0xAE),
- o3(0xE5,0x95,0x9C), o3(0xE5,0x95,0x85),
- o3(0xE5,0x95,0x96), o3(0xE5,0x95,0x97),
- o3(0xE5,0x94,0xB8), o3(0xE5,0x94,0xB3),
- o3(0xE5,0x95,0x9D), o3(0xE5,0x96,0x99),
- o3(0xE5,0x96,0x80), o3(0xE5,0x92,0xAF),
- o3(0xE5,0x96,0x8A), o3(0xE5,0x96,0x9F),
- o3(0xE5,0x95,0xBB), o3(0xE5,0x95,0xBE),
- o3(0xE5,0x96,0x98), o3(0xE5,0x96,0x9E),
- o3(0xE5,0x96,0xAE), o3(0xE5,0x95,0xBC),
- o3(0xE5,0x96,0x83), o3(0xE5,0x96,0xA9),
- o3(0xE5,0x96,0x87), o3(0xE5,0x96,0xA8),
- o3(0xE5,0x97,0x9A), o3(0xE5,0x97,0x85),
- o3(0xE5,0x97,0x9F), o3(0xE5,0x97,0x84),
- o3(0xE5,0x97,0x9C), o3(0xE5,0x97,0xA4),
- o3(0xE5,0x97,0x94), o3(0xE5,0x98,0x94),
- o3(0xE5,0x97,0xB7), o3(0xE5,0x98,0x96),
- o3(0xE5,0x97,0xBE), o3(0xE5,0x97,0xBD),
- o3(0xE5,0x98,0x9B), o3(0xE5,0x97,0xB9),
- o3(0xE5,0x99,0x8E), o3(0xE5,0x99,0x90),
- o3(0xE7,0x87,0x9F), o3(0xE5,0x98,0xB4),
- o3(0xE5,0x98,0xB6), o3(0xE5,0x98,0xB2),
- o3(0xE5,0x98,0xB8), o3(0xE5,0x99,0xAB),
- o3(0xE5,0x99,0xA4), o3(0xE5,0x98,0xAF),
- o3(0xE5,0x99,0xAC), o3(0xE5,0x99,0xAA),
- o3(0xE5,0x9A,0x86), o3(0xE5,0x9A,0x80),
- o3(0xE5,0x9A,0x8A), o3(0xE5,0x9A,0xA0),
- o3(0xE5,0x9A,0x94), o3(0xE5,0x9A,0x8F),
- o3(0xE5,0x9A,0xA5), o3(0xE5,0x9A,0xAE),
- o3(0xE5,0x9A,0xB6), o3(0xE5,0x9A,0xB4),
- o3(0xE5,0x9B,0x82), o3(0xE5,0x9A,0xBC),
- o3(0xE5,0x9B,0x81), o3(0xE5,0x9B,0x83),
- o3(0xE5,0x9B,0x80), o3(0xE5,0x9B,0x88),
- o3(0xE5,0x9B,0x8E), o3(0xE5,0x9B,0x91),
- o3(0xE5,0x9B,0x93), o3(0xE5,0x9B,0x97),
- o3(0xE5,0x9B,0xAE), o3(0xE5,0x9B,0xB9),
- o3(0xE5,0x9C,0x80), o3(0xE5,0x9B,0xBF),
- o3(0xE5,0x9C,0x84), o3(0xE5,0x9C,0x89),
- o3(0xE5,0x9C,0x88), o3(0xE5,0x9C,0x8B),
- o3(0xE5,0x9C,0x8D), o3(0xE5,0x9C,0x93),
- o3(0xE5,0x9C,0x98), o3(0xE5,0x9C,0x96),
- o3(0xE5,0x97,0x87), o3(0xE5,0x9C,0x9C),
- o3(0xE5,0x9C,0xA6), o3(0xE5,0x9C,0xB7),
- o3(0xE5,0x9C,0xB8), o3(0xE5,0x9D,0x8E),
- o3(0xE5,0x9C,0xBB), o3(0xE5,0x9D,0x80),
- o3(0xE5,0x9D,0x8F), o3(0xE5,0x9D,0xA9),
- o3(0xE5,0x9F,0x80), o3(0xE5,0x9E,0x88),
- o3(0xE5,0x9D,0xA1), o3(0xE5,0x9D,0xBF),
- o3(0xE5,0x9E,0x89), o3(0xE5,0x9E,0x93),
- o3(0xE5,0x9E,0xA0), o3(0xE5,0x9E,0xB3),
- o3(0xE5,0x9E,0xA4), o3(0xE5,0x9E,0xAA),
- o3(0xE5,0x9E,0xB0), o3(0xE5,0x9F,0x83),
- o3(0xE5,0x9F,0x86), o3(0xE5,0x9F,0x94),
- o3(0xE5,0x9F,0x92), o3(0xE5,0x9F,0x93),
- o3(0xE5,0xA0,0x8A), o3(0xE5,0x9F,0x96),
- o3(0xE5,0x9F,0xA3), o3(0xE5,0xA0,0x8B),
- o3(0xE5,0xA0,0x99), o3(0xE5,0xA0,0x9D),
- o3(0xE5,0xA1,0xB2), o3(0xE5,0xA0,0xA1),
- o3(0xE5,0xA1,0xA2), o3(0xE5,0xA1,0x8B),
- o3(0xE5,0xA1,0xB0), o3(0xE6,0xAF,0x80),
- o3(0xE5,0xA1,0x92), o3(0xE5,0xA0,0xBD),
- o3(0xE5,0xA1,0xB9), o3(0xE5,0xA2,0x85),
- o3(0xE5,0xA2,0xB9), o3(0xE5,0xA2,0x9F),
- o3(0xE5,0xA2,0xAB), o3(0xE5,0xA2,0xBA),
- o3(0xE5,0xA3,0x9E), o3(0xE5,0xA2,0xBB),
- o3(0xE5,0xA2,0xB8), o3(0xE5,0xA2,0xAE),
- o3(0xE5,0xA3,0x85), o3(0xE5,0xA3,0x93),
- o3(0xE5,0xA3,0x91), o3(0xE5,0xA3,0x97),
- o3(0xE5,0xA3,0x99), o3(0xE5,0xA3,0x98),
- o3(0xE5,0xA3,0xA5), o3(0xE5,0xA3,0x9C),
- o3(0xE5,0xA3,0xA4), o3(0xE5,0xA3,0x9F),
- o3(0xE5,0xA3,0xAF), o3(0xE5,0xA3,0xBA),
- o3(0xE5,0xA3,0xB9), o3(0xE5,0xA3,0xBB),
- o3(0xE5,0xA3,0xBC), o3(0xE5,0xA3,0xBD),
- o3(0xE5,0xA4,0x82), o3(0xE5,0xA4,0x8A),
- o3(0xE5,0xA4,0x90), o3(0xE5,0xA4,0x9B),
- o3(0xE6,0xA2,0xA6), o3(0xE5,0xA4,0xA5),
- o3(0xE5,0xA4,0xAC), o3(0xE5,0xA4,0xAD),
- o3(0xE5,0xA4,0xB2), o3(0xE5,0xA4,0xB8),
- o3(0xE5,0xA4,0xBE), o3(0xE7,0xAB,0x92),
- o3(0xE5,0xA5,0x95), o3(0xE5,0xA5,0x90),
- o3(0xE5,0xA5,0x8E), o3(0xE5,0xA5,0x9A),
- o3(0xE5,0xA5,0x98), o3(0xE5,0xA5,0xA2),
- o3(0xE5,0xA5,0xA0), o3(0xE5,0xA5,0xA7),
- o3(0xE5,0xA5,0xAC), o3(0xE5,0xA5,0xA9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_9A = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_9A_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_9B_infos[189] = {
- o3(0xE5,0xA5,0xB8), o3(0xE5,0xA6,0x81),
- o3(0xE5,0xA6,0x9D), o3(0xE4,0xBD,0x9E),
- o3(0xE4,0xBE,0xAB), o3(0xE5,0xA6,0xA3),
- o3(0xE5,0xA6,0xB2), o3(0xE5,0xA7,0x86),
- o3(0xE5,0xA7,0xA8), o3(0xE5,0xA7,0x9C),
- o3(0xE5,0xA6,0x8D), o3(0xE5,0xA7,0x99),
- o3(0xE5,0xA7,0x9A), o3(0xE5,0xA8,0xA5),
- o3(0xE5,0xA8,0x9F), o3(0xE5,0xA8,0x91),
- o3(0xE5,0xA8,0x9C), o3(0xE5,0xA8,0x89),
- o3(0xE5,0xA8,0x9A), o3(0xE5,0xA9,0x80),
- o3(0xE5,0xA9,0xAC), o3(0xE5,0xA9,0x89),
- o3(0xE5,0xA8,0xB5), o3(0xE5,0xA8,0xB6),
- o3(0xE5,0xA9,0xA2), o3(0xE5,0xA9,0xAA),
- o3(0xE5,0xAA,0x9A), o3(0xE5,0xAA,0xBC),
- o3(0xE5,0xAA,0xBE), o3(0xE5,0xAB,0x8B),
- o3(0xE5,0xAB,0x82), o3(0xE5,0xAA,0xBD),
- o3(0xE5,0xAB,0xA3), o3(0xE5,0xAB,0x97),
- o3(0xE5,0xAB,0xA6), o3(0xE5,0xAB,0xA9),
- o3(0xE5,0xAB,0x96), o3(0xE5,0xAB,0xBA),
- o3(0xE5,0xAB,0xBB), o3(0xE5,0xAC,0x8C),
- o3(0xE5,0xAC,0x8B), o3(0xE5,0xAC,0x96),
- o3(0xE5,0xAC,0xB2), o3(0xE5,0xAB,0x90),
- o3(0xE5,0xAC,0xAA), o3(0xE5,0xAC,0xB6),
- o3(0xE5,0xAC,0xBE), o3(0xE5,0xAD,0x83),
- o3(0xE5,0xAD,0x85), o3(0xE5,0xAD,0x80),
- o3(0xE5,0xAD,0x91), o3(0xE5,0xAD,0x95),
- o3(0xE5,0xAD,0x9A), o3(0xE5,0xAD,0x9B),
- o3(0xE5,0xAD,0xA5), o3(0xE5,0xAD,0xA9),
- o3(0xE5,0xAD,0xB0), o3(0xE5,0xAD,0xB3),
- o3(0xE5,0xAD,0xB5), o3(0xE5,0xAD,0xB8),
- o3(0xE6,0x96,0x88), o3(0xE5,0xAD,0xBA),
- o3(0xE5,0xAE,0x80), o3(0xE5,0xAE,0x83),
- o3(0xE5,0xAE,0xA6), o3(0xE5,0xAE,0xB8),
- o3(0xE5,0xAF,0x83), o3(0xE5,0xAF,0x87),
- o3(0xE5,0xAF,0x89), o3(0xE5,0xAF,0x94),
- o3(0xE5,0xAF,0x90), o3(0xE5,0xAF,0xA4),
- o3(0xE5,0xAF,0xA6), o3(0xE5,0xAF,0xA2),
- o3(0xE5,0xAF,0x9E), o3(0xE5,0xAF,0xA5),
- o3(0xE5,0xAF,0xAB), o3(0xE5,0xAF,0xB0),
- o3(0xE5,0xAF,0xB6), o3(0xE5,0xAF,0xB3),
- o3(0xE5,0xB0,0x85), o3(0xE5,0xB0,0x87),
- o3(0xE5,0xB0,0x88), o3(0xE5,0xB0,0x8D),
- o3(0xE5,0xB0,0x93), o3(0xE5,0xB0,0xA0),
- o3(0xE5,0xB0,0xA2), o3(0xE5,0xB0,0xA8),
- o3(0xE5,0xB0,0xB8), o3(0xE5,0xB0,0xB9),
- o3(0xE5,0xB1,0x81), o3(0xE5,0xB1,0x86),
- o3(0xE5,0xB1,0x8E), o3(0xE5,0xB1,0x93),
- o3(0xE5,0xB1,0x90), o3(0xE5,0xB1,0x8F),
- o3(0xE5,0xAD,0xB1), o3(0xE5,0xB1,0xAC),
- o3(0xE5,0xB1,0xAE), o3(0xE4,0xB9,0xA2),
- o3(0xE5,0xB1,0xB6), o3(0xE5,0xB1,0xB9),
- o3(0xE5,0xB2,0x8C), o3(0xE5,0xB2,0x91),
- o3(0xE5,0xB2,0x94), o3(0xE5,0xA6,0x9B),
- o3(0xE5,0xB2,0xAB), o3(0xE5,0xB2,0xBB),
- o3(0xE5,0xB2,0xB6), o3(0xE5,0xB2,0xBC),
- o3(0xE5,0xB2,0xB7), o3(0xE5,0xB3,0x85),
- o3(0xE5,0xB2,0xBE), o3(0xE5,0xB3,0x87),
- o3(0xE5,0xB3,0x99), o3(0xE5,0xB3,0xA9),
- o3(0xE5,0xB3,0xBD), o3(0xE5,0xB3,0xBA),
- o3(0xE5,0xB3,0xAD), o3(0xE5,0xB6,0x8C),
- o3(0xE5,0xB3,0xAA), o3(0xE5,0xB4,0x8B),
- o3(0xE5,0xB4,0x95), o3(0xE5,0xB4,0x97),
- o3(0xE5,0xB5,0x9C), o3(0xE5,0xB4,0x9F),
- o3(0xE5,0xB4,0x9B), o3(0xE5,0xB4,0x91),
- o3(0xE5,0xB4,0x94), o3(0xE5,0xB4,0xA2),
- o3(0xE5,0xB4,0x9A), o3(0xE5,0xB4,0x99),
- o3(0xE5,0xB4,0x98), o3(0xE5,0xB5,0x8C),
- o3(0xE5,0xB5,0x92), o3(0xE5,0xB5,0x8E),
- o3(0xE5,0xB5,0x8B), o3(0xE5,0xB5,0xAC),
- o3(0xE5,0xB5,0xB3), o3(0xE5,0xB5,0xB6),
- o3(0xE5,0xB6,0x87), o3(0xE5,0xB6,0x84),
- o3(0xE5,0xB6,0x82), o3(0xE5,0xB6,0xA2),
- o3(0xE5,0xB6,0x9D), o3(0xE5,0xB6,0xAC),
- o3(0xE5,0xB6,0xAE), o3(0xE5,0xB6,0xBD),
- o3(0xE5,0xB6,0x90), o3(0xE5,0xB6,0xB7),
- o3(0xE5,0xB6,0xBC), o3(0xE5,0xB7,0x89),
- o3(0xE5,0xB7,0x8D), o3(0xE5,0xB7,0x93),
- o3(0xE5,0xB7,0x92), o3(0xE5,0xB7,0x96),
- o3(0xE5,0xB7,0x9B), o3(0xE5,0xB7,0xAB),
- o3(0xE5,0xB7,0xB2), o3(0xE5,0xB7,0xB5),
- o3(0xE5,0xB8,0x8B), o3(0xE5,0xB8,0x9A),
- o3(0xE5,0xB8,0x99), o3(0xE5,0xB8,0x91),
- o3(0xE5,0xB8,0x9B), o3(0xE5,0xB8,0xB6),
- o3(0xE5,0xB8,0xB7), o3(0xE5,0xB9,0x84),
- o3(0xE5,0xB9,0x83), o3(0xE5,0xB9,0x80),
- o3(0xE5,0xB9,0x8E), o3(0xE5,0xB9,0x97),
- o3(0xE5,0xB9,0x94), o3(0xE5,0xB9,0x9F),
- o3(0xE5,0xB9,0xA2), o3(0xE5,0xB9,0xA4),
- o3(0xE5,0xB9,0x87), o3(0xE5,0xB9,0xB5),
- o3(0xE5,0xB9,0xB6), o3(0xE5,0xB9,0xBA),
- o3(0xE9,0xBA,0xBC), o3(0xE5,0xB9,0xBF),
- o3(0xE5,0xBA,0xA0), o3(0xE5,0xBB,0x81),
- o3(0xE5,0xBB,0x82), o3(0xE5,0xBB,0x88),
- o3(0xE5,0xBB,0x90), o3(0xE5,0xBB,0x8F),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_9B = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_9B_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_9C_infos[189] = {
- o3(0xE5,0xBB,0x96), o3(0xE5,0xBB,0xA3),
- o3(0xE5,0xBB,0x9D), o3(0xE5,0xBB,0x9A),
- o3(0xE5,0xBB,0x9B), o3(0xE5,0xBB,0xA2),
- o3(0xE5,0xBB,0xA1), o3(0xE5,0xBB,0xA8),
- o3(0xE5,0xBB,0xA9), o3(0xE5,0xBB,0xAC),
- o3(0xE5,0xBB,0xB1), o3(0xE5,0xBB,0xB3),
- o3(0xE5,0xBB,0xB0), o3(0xE5,0xBB,0xB4),
- o3(0xE5,0xBB,0xB8), o3(0xE5,0xBB,0xBE),
- o3(0xE5,0xBC,0x83), o3(0xE5,0xBC,0x89),
- o3(0xE5,0xBD,0x9D), o3(0xE5,0xBD,0x9C),
- o3(0xE5,0xBC,0x8B), o3(0xE5,0xBC,0x91),
- o3(0xE5,0xBC,0x96), o3(0xE5,0xBC,0xA9),
- o3(0xE5,0xBC,0xAD), o3(0xE5,0xBC,0xB8),
- o3(0xE5,0xBD,0x81), o3(0xE5,0xBD,0x88),
- o3(0xE5,0xBD,0x8C), o3(0xE5,0xBD,0x8E),
- o3(0xE5,0xBC,0xAF), o3(0xE5,0xBD,0x91),
- o3(0xE5,0xBD,0x96), o3(0xE5,0xBD,0x97),
- o3(0xE5,0xBD,0x99), o3(0xE5,0xBD,0xA1),
- o3(0xE5,0xBD,0xAD), o3(0xE5,0xBD,0xB3),
- o3(0xE5,0xBD,0xB7), o3(0xE5,0xBE,0x83),
- o3(0xE5,0xBE,0x82), o3(0xE5,0xBD,0xBF),
- o3(0xE5,0xBE,0x8A), o3(0xE5,0xBE,0x88),
- o3(0xE5,0xBE,0x91), o3(0xE5,0xBE,0x87),
- o3(0xE5,0xBE,0x9E), o3(0xE5,0xBE,0x99),
- o3(0xE5,0xBE,0x98), o3(0xE5,0xBE,0xA0),
- o3(0xE5,0xBE,0xA8), o3(0xE5,0xBE,0xAD),
- o3(0xE5,0xBE,0xBC), o3(0xE5,0xBF,0x96),
- o3(0xE5,0xBF,0xBB), o3(0xE5,0xBF,0xA4),
- o3(0xE5,0xBF,0xB8), o3(0xE5,0xBF,0xB1),
- o3(0xE5,0xBF,0x9D), o3(0xE6,0x82,0xB3),
- o3(0xE5,0xBF,0xBF), o3(0xE6,0x80,0xA1),
- o3(0xE6,0x81,0xA0), o3(0xE6,0x80,0x99),
- o3(0xE6,0x80,0x90), o3(0xE6,0x80,0xA9),
- o3(0xE6,0x80,0x8E), o3(0xE6,0x80,0xB1),
- o3(0xE6,0x80,0x9B), o3(0xE6,0x80,0x95),
- o3(0xE6,0x80,0xAB), o3(0xE6,0x80,0xA6),
- o3(0xE6,0x80,0x8F), o3(0xE6,0x80,0xBA),
- o3(0xE6,0x81,0x9A), o3(0xE6,0x81,0x81),
- o3(0xE6,0x81,0xAA), o3(0xE6,0x81,0xB7),
- o3(0xE6,0x81,0x9F), o3(0xE6,0x81,0x8A),
- o3(0xE6,0x81,0x86), o3(0xE6,0x81,0x8D),
- o3(0xE6,0x81,0xA3), o3(0xE6,0x81,0x83),
- o3(0xE6,0x81,0xA4), o3(0xE6,0x81,0x82),
- o3(0xE6,0x81,0xAC), o3(0xE6,0x81,0xAB),
- o3(0xE6,0x81,0x99), o3(0xE6,0x82,0x81),
- o3(0xE6,0x82,0x8D), o3(0xE6,0x83,0xA7),
- o3(0xE6,0x82,0x83), o3(0xE6,0x82,0x9A),
- o3(0xE6,0x82,0x84), o3(0xE6,0x82,0x9B),
- o3(0xE6,0x82,0x96), o3(0xE6,0x82,0x97),
- o3(0xE6,0x82,0x92), o3(0xE6,0x82,0xA7),
- o3(0xE6,0x82,0x8B), o3(0xE6,0x83,0xA1),
- o3(0xE6,0x82,0xB8), o3(0xE6,0x83,0xA0),
- o3(0xE6,0x83,0x93), o3(0xE6,0x82,0xB4),
- o3(0xE5,0xBF,0xB0), o3(0xE6,0x82,0xBD),
- o3(0xE6,0x83,0x86), o3(0xE6,0x82,0xB5),
- o3(0xE6,0x83,0x98), o3(0xE6,0x85,0x8D),
- o3(0xE6,0x84,0x95), o3(0xE6,0x84,0x86),
- o3(0xE6,0x83,0xB6), o3(0xE6,0x83,0xB7),
- o3(0xE6,0x84,0x80), o3(0xE6,0x83,0xB4),
- o3(0xE6,0x83,0xBA), o3(0xE6,0x84,0x83),
- o3(0xE6,0x84,0xA1), o3(0xE6,0x83,0xBB),
- o3(0xE6,0x83,0xB1), o3(0xE6,0x84,0x8D),
- o3(0xE6,0x84,0x8E), o3(0xE6,0x85,0x87),
- o3(0xE6,0x84,0xBE), o3(0xE6,0x84,0xA8),
- o3(0xE6,0x84,0xA7), o3(0xE6,0x85,0x8A),
- o3(0xE6,0x84,0xBF), o3(0xE6,0x84,0xBC),
- o3(0xE6,0x84,0xAC), o3(0xE6,0x84,0xB4),
- o3(0xE6,0x84,0xBD), o3(0xE6,0x85,0x82),
- o3(0xE6,0x85,0x84), o3(0xE6,0x85,0xB3),
- o3(0xE6,0x85,0xB7), o3(0xE6,0x85,0x98),
- o3(0xE6,0x85,0x99), o3(0xE6,0x85,0x9A),
- o3(0xE6,0x85,0xAB), o3(0xE6,0x85,0xB4),
- o3(0xE6,0x85,0xAF), o3(0xE6,0x85,0xA5),
- o3(0xE6,0x85,0xB1), o3(0xE6,0x85,0x9F),
- o3(0xE6,0x85,0x9D), o3(0xE6,0x85,0x93),
- o3(0xE6,0x85,0xB5), o3(0xE6,0x86,0x99),
- o3(0xE6,0x86,0x96), o3(0xE6,0x86,0x87),
- o3(0xE6,0x86,0xAC), o3(0xE6,0x86,0x94),
- o3(0xE6,0x86,0x9A), o3(0xE6,0x86,0x8A),
- o3(0xE6,0x86,0x91), o3(0xE6,0x86,0xAB),
- o3(0xE6,0x86,0xAE), o3(0xE6,0x87,0x8C),
- o3(0xE6,0x87,0x8A), o3(0xE6,0x87,0x89),
- o3(0xE6,0x87,0xB7), o3(0xE6,0x87,0x88),
- o3(0xE6,0x87,0x83), o3(0xE6,0x87,0x86),
- o3(0xE6,0x86,0xBA), o3(0xE6,0x87,0x8B),
- o3(0xE7,0xBD,0xB9), o3(0xE6,0x87,0x8D),
- o3(0xE6,0x87,0xA6), o3(0xE6,0x87,0xA3),
- o3(0xE6,0x87,0xB6), o3(0xE6,0x87,0xBA),
- o3(0xE6,0x87,0xB4), o3(0xE6,0x87,0xBF),
- o3(0xE6,0x87,0xBD), o3(0xE6,0x87,0xBC),
- o3(0xE6,0x87,0xBE), o3(0xE6,0x88,0x80),
- o3(0xE6,0x88,0x88), o3(0xE6,0x88,0x89),
- o3(0xE6,0x88,0x8D), o3(0xE6,0x88,0x8C),
- o3(0xE6,0x88,0x94), o3(0xE6,0x88,0x9B),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_9C = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_9C_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_9D_infos[189] = {
- o3(0xE6,0x88,0x9E), o3(0xE6,0x88,0xA1),
- o3(0xE6,0x88,0xAA), o3(0xE6,0x88,0xAE),
- o3(0xE6,0x88,0xB0), o3(0xE6,0x88,0xB2),
- o3(0xE6,0x88,0xB3), o3(0xE6,0x89,0x81),
- o3(0xE6,0x89,0x8E), o3(0xE6,0x89,0x9E),
- o3(0xE6,0x89,0xA3), o3(0xE6,0x89,0x9B),
- o3(0xE6,0x89,0xA0), o3(0xE6,0x89,0xA8),
- o3(0xE6,0x89,0xBC), o3(0xE6,0x8A,0x82),
- o3(0xE6,0x8A,0x89), o3(0xE6,0x89,0xBE),
- o3(0xE6,0x8A,0x92), o3(0xE6,0x8A,0x93),
- o3(0xE6,0x8A,0x96), o3(0xE6,0x8B,0x94),
- o3(0xE6,0x8A,0x83), o3(0xE6,0x8A,0x94),
- o3(0xE6,0x8B,0x97), o3(0xE6,0x8B,0x91),
- o3(0xE6,0x8A,0xBB), o3(0xE6,0x8B,0x8F),
- o3(0xE6,0x8B,0xBF), o3(0xE6,0x8B,0x86),
- o3(0xE6,0x93,0x94), o3(0xE6,0x8B,0x88),
- o3(0xE6,0x8B,0x9C), o3(0xE6,0x8B,0x8C),
- o3(0xE6,0x8B,0x8A), o3(0xE6,0x8B,0x82),
- o3(0xE6,0x8B,0x87), o3(0xE6,0x8A,0x9B),
- o3(0xE6,0x8B,0x89), o3(0xE6,0x8C,0x8C),
- o3(0xE6,0x8B,0xAE), o3(0xE6,0x8B,0xB1),
- o3(0xE6,0x8C,0xA7), o3(0xE6,0x8C,0x82),
- o3(0xE6,0x8C,0x88), o3(0xE6,0x8B,0xAF),
- o3(0xE6,0x8B,0xB5), o3(0xE6,0x8D,0x90),
- o3(0xE6,0x8C,0xBE), o3(0xE6,0x8D,0x8D),
- o3(0xE6,0x90,0x9C), o3(0xE6,0x8D,0x8F),
- o3(0xE6,0x8E,0x96), o3(0xE6,0x8E,0x8E),
- o3(0xE6,0x8E,0x80), o3(0xE6,0x8E,0xAB),
- o3(0xE6,0x8D,0xB6), o3(0xE6,0x8E,0xA3),
- o3(0xE6,0x8E,0x8F), o3(0xE6,0x8E,0x89),
- o3(0xE6,0x8E,0x9F), o3(0xE6,0x8E,0xB5),
- o3(0xE6,0x8D,0xAB), o3(0xE6,0x8D,0xA9),
- o3(0xE6,0x8E,0xBE), o3(0xE6,0x8F,0xA9),
- o3(0xE6,0x8F,0x80), o3(0xE6,0x8F,0x86),
- o3(0xE6,0x8F,0xA3), o3(0xE6,0x8F,0x89),
- o3(0xE6,0x8F,0x92), o3(0xE6,0x8F,0xB6),
- o3(0xE6,0x8F,0x84), o3(0xE6,0x90,0x96),
- o3(0xE6,0x90,0xB4), o3(0xE6,0x90,0x86),
- o3(0xE6,0x90,0x93), o3(0xE6,0x90,0xA6),
- o3(0xE6,0x90,0xB6), o3(0xE6,0x94,0x9D),
- o3(0xE6,0x90,0x97), o3(0xE6,0x90,0xA8),
- o3(0xE6,0x90,0x8F), o3(0xE6,0x91,0xA7),
- o3(0xE6,0x91,0xAF), o3(0xE6,0x91,0xB6),
- o3(0xE6,0x91,0x8E), o3(0xE6,0x94,0xAA),
- o3(0xE6,0x92,0x95), o3(0xE6,0x92,0x93),
- o3(0xE6,0x92,0xA5), o3(0xE6,0x92,0xA9),
- o3(0xE6,0x92,0x88), o3(0xE6,0x92,0xBC),
- o3(0xE6,0x93,0x9A), o3(0xE6,0x93,0x92),
- o3(0xE6,0x93,0x85), o3(0xE6,0x93,0x87),
- o3(0xE6,0x92,0xBB), o3(0xE6,0x93,0x98),
- o3(0xE6,0x93,0x82), o3(0xE6,0x93,0xB1),
- o3(0xE6,0x93,0xA7), o3(0xE8,0x88,0x89),
- o3(0xE6,0x93,0xA0), o3(0xE6,0x93,0xA1),
- o3(0xE6,0x8A,0xAC), o3(0xE6,0x93,0xA3),
- o3(0xE6,0x93,0xAF), o3(0xE6,0x94,0xAC),
- o3(0xE6,0x93,0xB6), o3(0xE6,0x93,0xB4),
- o3(0xE6,0x93,0xB2), o3(0xE6,0x93,0xBA),
- o3(0xE6,0x94,0x80), o3(0xE6,0x93,0xBD),
- o3(0xE6,0x94,0x98), o3(0xE6,0x94,0x9C),
- o3(0xE6,0x94,0x85), o3(0xE6,0x94,0xA4),
- o3(0xE6,0x94,0xA3), o3(0xE6,0x94,0xAB),
- o3(0xE6,0x94,0xB4), o3(0xE6,0x94,0xB5),
- o3(0xE6,0x94,0xB7), o3(0xE6,0x94,0xB6),
- o3(0xE6,0x94,0xB8), o3(0xE7,0x95,0x8B),
- o3(0xE6,0x95,0x88), o3(0xE6,0x95,0x96),
- o3(0xE6,0x95,0x95), o3(0xE6,0x95,0x8D),
- o3(0xE6,0x95,0x98), o3(0xE6,0x95,0x9E),
- o3(0xE6,0x95,0x9D), o3(0xE6,0x95,0xB2),
- o3(0xE6,0x95,0xB8), o3(0xE6,0x96,0x82),
- o3(0xE6,0x96,0x83), o3(0xE8,0xAE,0x8A),
- o3(0xE6,0x96,0x9B), o3(0xE6,0x96,0x9F),
- o3(0xE6,0x96,0xAB), o3(0xE6,0x96,0xB7),
- o3(0xE6,0x97,0x83), o3(0xE6,0x97,0x86),
- o3(0xE6,0x97,0x81), o3(0xE6,0x97,0x84),
- o3(0xE6,0x97,0x8C), o3(0xE6,0x97,0x92),
- o3(0xE6,0x97,0x9B), o3(0xE6,0x97,0x99),
- o3(0xE6,0x97,0xA0), o3(0xE6,0x97,0xA1),
- o3(0xE6,0x97,0xB1), o3(0xE6,0x9D,0xB2),
- o3(0xE6,0x98,0x8A), o3(0xE6,0x98,0x83),
- o3(0xE6,0x97,0xBB), o3(0xE6,0x9D,0xB3),
- o3(0xE6,0x98,0xB5), o3(0xE6,0x98,0xB6),
- o3(0xE6,0x98,0xB4), o3(0xE6,0x98,0x9C),
- o3(0xE6,0x99,0x8F), o3(0xE6,0x99,0x84),
- o3(0xE6,0x99,0x89), o3(0xE6,0x99,0x81),
- o3(0xE6,0x99,0x9E), o3(0xE6,0x99,0x9D),
- o3(0xE6,0x99,0xA4), o3(0xE6,0x99,0xA7),
- o3(0xE6,0x99,0xA8), o3(0xE6,0x99,0x9F),
- o3(0xE6,0x99,0xA2), o3(0xE6,0x99,0xB0),
- o3(0xE6,0x9A,0x83), o3(0xE6,0x9A,0x88),
- o3(0xE6,0x9A,0x8E), o3(0xE6,0x9A,0x89),
- o3(0xE6,0x9A,0x84), o3(0xE6,0x9A,0x98),
- o3(0xE6,0x9A,0x9D), o3(0xE6,0x9B,0x81),
- o3(0xE6,0x9A,0xB9), o3(0xE6,0x9B,0x89),
- o3(0xE6,0x9A,0xBE), o3(0xE6,0x9A,0xBC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_9D = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_9D_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_9E_infos[189] = {
- o3(0xE6,0x9B,0x84), o3(0xE6,0x9A,0xB8),
- o3(0xE6,0x9B,0x96), o3(0xE6,0x9B,0x9A),
- o3(0xE6,0x9B,0xA0), o3(0xE6,0x98,0xBF),
- o3(0xE6,0x9B,0xA6), o3(0xE6,0x9B,0xA9),
- o3(0xE6,0x9B,0xB0), o3(0xE6,0x9B,0xB5),
- o3(0xE6,0x9B,0xB7), o3(0xE6,0x9C,0x8F),
- o3(0xE6,0x9C,0x96), o3(0xE6,0x9C,0x9E),
- o3(0xE6,0x9C,0xA6), o3(0xE6,0x9C,0xA7),
- o3(0xE9,0x9C,0xB8), o3(0xE6,0x9C,0xAE),
- o3(0xE6,0x9C,0xBF), o3(0xE6,0x9C,0xB6),
- o3(0xE6,0x9D,0x81), o3(0xE6,0x9C,0xB8),
- o3(0xE6,0x9C,0xB7), o3(0xE6,0x9D,0x86),
- o3(0xE6,0x9D,0x9E), o3(0xE6,0x9D,0xA0),
- o3(0xE6,0x9D,0x99), o3(0xE6,0x9D,0xA3),
- o3(0xE6,0x9D,0xA4), o3(0xE6,0x9E,0x89),
- o3(0xE6,0x9D,0xB0), o3(0xE6,0x9E,0xA9),
- o3(0xE6,0x9D,0xBC), o3(0xE6,0x9D,0xAA),
- o3(0xE6,0x9E,0x8C), o3(0xE6,0x9E,0x8B),
- o3(0xE6,0x9E,0xA6), o3(0xE6,0x9E,0xA1),
- o3(0xE6,0x9E,0x85), o3(0xE6,0x9E,0xB7),
- o3(0xE6,0x9F,0xAF), o3(0xE6,0x9E,0xB4),
- o3(0xE6,0x9F,0xAC), o3(0xE6,0x9E,0xB3),
- o3(0xE6,0x9F,0xA9), o3(0xE6,0x9E,0xB8),
- o3(0xE6,0x9F,0xA4), o3(0xE6,0x9F,0x9E),
- o3(0xE6,0x9F,0x9D), o3(0xE6,0x9F,0xA2),
- o3(0xE6,0x9F,0xAE), o3(0xE6,0x9E,0xB9),
- o3(0xE6,0x9F,0x8E), o3(0xE6,0x9F,0x86),
- o3(0xE6,0x9F,0xA7), o3(0xE6,0xAA,0x9C),
- o3(0xE6,0xA0,0x9E), o3(0xE6,0xA1,0x86),
- o3(0xE6,0xA0,0xA9), o3(0xE6,0xA1,0x80),
- o3(0xE6,0xA1,0x8D), o3(0xE6,0xA0,0xB2),
- o3(0xE6,0xA1,0x8E), o3(0xE6,0xA2,0xB3),
- o3(0xE6,0xA0,0xAB), o3(0xE6,0xA1,0x99),
- o3(0xE6,0xA1,0xA3), o3(0xE6,0xA1,0xB7),
- o3(0xE6,0xA1,0xBF), o3(0xE6,0xA2,0x9F),
- o3(0xE6,0xA2,0x8F), o3(0xE6,0xA2,0xAD),
- o3(0xE6,0xA2,0x94), o3(0xE6,0xA2,0x9D),
- o3(0xE6,0xA2,0x9B), o3(0xE6,0xA2,0x83),
- o3(0xE6,0xAA,0xAE), o3(0xE6,0xA2,0xB9),
- o3(0xE6,0xA1,0xB4), o3(0xE6,0xA2,0xB5),
- o3(0xE6,0xA2,0xA0), o3(0xE6,0xA2,0xBA),
- o3(0xE6,0xA4,0x8F), o3(0xE6,0xA2,0x8D),
- o3(0xE6,0xA1,0xBE), o3(0xE6,0xA4,0x81),
- o3(0xE6,0xA3,0x8A), o3(0xE6,0xA4,0x88),
- o3(0xE6,0xA3,0x98), o3(0xE6,0xA4,0xA2),
- o3(0xE6,0xA4,0xA6), o3(0xE6,0xA3,0xA1),
- o3(0xE6,0xA4,0x8C), o3(0xE6,0xA3,0x8D),
- o3(0xE6,0xA3,0x94), o3(0xE6,0xA3,0xA7),
- o3(0xE6,0xA3,0x95), o3(0xE6,0xA4,0xB6),
- o3(0xE6,0xA4,0x92), o3(0xE6,0xA4,0x84),
- o3(0xE6,0xA3,0x97), o3(0xE6,0xA3,0xA3),
- o3(0xE6,0xA4,0xA5), o3(0xE6,0xA3,0xB9),
- o3(0xE6,0xA3,0xA0), o3(0xE6,0xA3,0xAF),
- o3(0xE6,0xA4,0xA8), o3(0xE6,0xA4,0xAA),
- o3(0xE6,0xA4,0x9A), o3(0xE6,0xA4,0xA3),
- o3(0xE6,0xA4,0xA1), o3(0xE6,0xA3,0x86),
- o3(0xE6,0xA5,0xB9), o3(0xE6,0xA5,0xB7),
- o3(0xE6,0xA5,0x9C), o3(0xE6,0xA5,0xB8),
- o3(0xE6,0xA5,0xAB), o3(0xE6,0xA5,0x94),
- o3(0xE6,0xA5,0xBE), o3(0xE6,0xA5,0xAE),
- o3(0xE6,0xA4,0xB9), o3(0xE6,0xA5,0xB4),
- o3(0xE6,0xA4,0xBD), o3(0xE6,0xA5,0x99),
- o3(0xE6,0xA4,0xB0), o3(0xE6,0xA5,0xA1),
- o3(0xE6,0xA5,0x9E), o3(0xE6,0xA5,0x9D),
- o3(0xE6,0xA6,0x81), o3(0xE6,0xA5,0xAA),
- o3(0xE6,0xA6,0xB2), o3(0xE6,0xA6,0xAE),
- o3(0xE6,0xA7,0x90), o3(0xE6,0xA6,0xBF),
- o3(0xE6,0xA7,0x81), o3(0xE6,0xA7,0x93),
- o3(0xE6,0xA6,0xBE), o3(0xE6,0xA7,0x8E),
- o3(0xE5,0xAF,0xA8), o3(0xE6,0xA7,0x8A),
- o3(0xE6,0xA7,0x9D), o3(0xE6,0xA6,0xBB),
- o3(0xE6,0xA7,0x83), o3(0xE6,0xA6,0xA7),
- o3(0xE6,0xA8,0xAE), o3(0xE6,0xA6,0x91),
- o3(0xE6,0xA6,0xA0), o3(0xE6,0xA6,0x9C),
- o3(0xE6,0xA6,0x95), o3(0xE6,0xA6,0xB4),
- o3(0xE6,0xA7,0x9E), o3(0xE6,0xA7,0xA8),
- o3(0xE6,0xA8,0x82), o3(0xE6,0xA8,0x9B),
- o3(0xE6,0xA7,0xBF), o3(0xE6,0xAC,0x8A),
- o3(0xE6,0xA7,0xB9), o3(0xE6,0xA7,0xB2),
- o3(0xE6,0xA7,0xA7), o3(0xE6,0xA8,0x85),
- o3(0xE6,0xA6,0xB1), o3(0xE6,0xA8,0x9E),
- o3(0xE6,0xA7,0xAD), o3(0xE6,0xA8,0x94),
- o3(0xE6,0xA7,0xAB), o3(0xE6,0xA8,0x8A),
- o3(0xE6,0xA8,0x92), o3(0xE6,0xAB,0x81),
- o3(0xE6,0xA8,0xA3), o3(0xE6,0xA8,0x93),
- o3(0xE6,0xA9,0x84), o3(0xE6,0xA8,0x8C),
- o3(0xE6,0xA9,0xB2), o3(0xE6,0xA8,0xB6),
- o3(0xE6,0xA9,0xB8), o3(0xE6,0xA9,0x87),
- o3(0xE6,0xA9,0xA2), o3(0xE6,0xA9,0x99),
- o3(0xE6,0xA9,0xA6), o3(0xE6,0xA9,0x88),
- o3(0xE6,0xA8,0xB8), o3(0xE6,0xA8,0xA2),
- o3(0xE6,0xAA,0x90), o3(0xE6,0xAA,0x8D),
- o3(0xE6,0xAA,0xA0), o3(0xE6,0xAA,0x84),
- o3(0xE6,0xAA,0xA2), o3(0xE6,0xAA,0xA3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_9E = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_9E_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_9F_infos[189] = {
- o3(0xE6,0xAA,0x97), o3(0xE8,0x98,0x97),
- o3(0xE6,0xAA,0xBB), o3(0xE6,0xAB,0x83),
- o3(0xE6,0xAB,0x82), o3(0xE6,0xAA,0xB8),
- o3(0xE6,0xAA,0xB3), o3(0xE6,0xAA,0xAC),
- o3(0xE6,0xAB,0x9E), o3(0xE6,0xAB,0x91),
- o3(0xE6,0xAB,0x9F), o3(0xE6,0xAA,0xAA),
- o3(0xE6,0xAB,0x9A), o3(0xE6,0xAB,0xAA),
- o3(0xE6,0xAB,0xBB), o3(0xE6,0xAC,0x85),
- o3(0xE8,0x98,0x96), o3(0xE6,0xAB,0xBA),
- o3(0xE6,0xAC,0x92), o3(0xE6,0xAC,0x96),
- o3(0xE9,0xAC,0xB1), o3(0xE6,0xAC,0x9F),
- o3(0xE6,0xAC,0xB8), o3(0xE6,0xAC,0xB7),
- o3(0xE7,0x9B,0x9C), o3(0xE6,0xAC,0xB9),
- o3(0xE9,0xA3,0xAE), o3(0xE6,0xAD,0x87),
- o3(0xE6,0xAD,0x83), o3(0xE6,0xAD,0x89),
- o3(0xE6,0xAD,0x90), o3(0xE6,0xAD,0x99),
- o3(0xE6,0xAD,0x94), o3(0xE6,0xAD,0x9B),
- o3(0xE6,0xAD,0x9F), o3(0xE6,0xAD,0xA1),
- o3(0xE6,0xAD,0xB8), o3(0xE6,0xAD,0xB9),
- o3(0xE6,0xAD,0xBF), o3(0xE6,0xAE,0x80),
- o3(0xE6,0xAE,0x84), o3(0xE6,0xAE,0x83),
- o3(0xE6,0xAE,0x8D), o3(0xE6,0xAE,0x98),
- o3(0xE6,0xAE,0x95), o3(0xE6,0xAE,0x9E),
- o3(0xE6,0xAE,0xA4), o3(0xE6,0xAE,0xAA),
- o3(0xE6,0xAE,0xAB), o3(0xE6,0xAE,0xAF),
- o3(0xE6,0xAE,0xB2), o3(0xE6,0xAE,0xB1),
- o3(0xE6,0xAE,0xB3), o3(0xE6,0xAE,0xB7),
- o3(0xE6,0xAE,0xBC), o3(0xE6,0xAF,0x86),
- o3(0xE6,0xAF,0x8B), o3(0xE6,0xAF,0x93),
- o3(0xE6,0xAF,0x9F), o3(0xE6,0xAF,0xAC),
- o3(0xE6,0xAF,0xAB), o3(0xE6,0xAF,0xB3),
- o3(0xE6,0xAF,0xAF), o3(0xE9,0xBA,0xBE),
- o3(0xE6,0xB0,0x88), o3(0xE6,0xB0,0x93),
- o3(0xE6,0xB0,0x94), o3(0xE6,0xB0,0x9B),
- o3(0xE6,0xB0,0xA4), o3(0xE6,0xB0,0xA3),
- o3(0xE6,0xB1,0x9E), o3(0xE6,0xB1,0x95),
- o3(0xE6,0xB1,0xA2), o3(0xE6,0xB1,0xAA),
- o3(0xE6,0xB2,0x82), o3(0xE6,0xB2,0x8D),
- o3(0xE6,0xB2,0x9A), o3(0xE6,0xB2,0x81),
- o3(0xE6,0xB2,0x9B), o3(0xE6,0xB1,0xBE),
- o3(0xE6,0xB1,0xA8), o3(0xE6,0xB1,0xB3),
- o3(0xE6,0xB2,0x92), o3(0xE6,0xB2,0x90),
- o3(0xE6,0xB3,0x84), o3(0xE6,0xB3,0xB1),
- o3(0xE6,0xB3,0x93), o3(0xE6,0xB2,0xBD),
- o3(0xE6,0xB3,0x97), o3(0xE6,0xB3,0x85),
- o3(0xE6,0xB3,0x9D), o3(0xE6,0xB2,0xAE),
- o3(0xE6,0xB2,0xB1), o3(0xE6,0xB2,0xBE),
- o3(0xE6,0xB2,0xBA), o3(0xE6,0xB3,0x9B),
- o3(0xE6,0xB3,0xAF), o3(0xE6,0xB3,0x99),
- o3(0xE6,0xB3,0xAA), o3(0xE6,0xB4,0x9F),
- o3(0xE8,0xA1,0x8D), o3(0xE6,0xB4,0xB6),
- o3(0xE6,0xB4,0xAB), o3(0xE6,0xB4,0xBD),
- o3(0xE6,0xB4,0xB8), o3(0xE6,0xB4,0x99),
- o3(0xE6,0xB4,0xB5), o3(0xE6,0xB4,0xB3),
- o3(0xE6,0xB4,0x92), o3(0xE6,0xB4,0x8C),
- o3(0xE6,0xB5,0xA3), o3(0xE6,0xB6,0x93),
- o3(0xE6,0xB5,0xA4), o3(0xE6,0xB5,0x9A),
- o3(0xE6,0xB5,0xB9), o3(0xE6,0xB5,0x99),
- o3(0xE6,0xB6,0x8E), o3(0xE6,0xB6,0x95),
- o3(0xE6,0xBF,0xA4), o3(0xE6,0xB6,0x85),
- o3(0xE6,0xB7,0xB9), o3(0xE6,0xB8,0x95),
- o3(0xE6,0xB8,0x8A), o3(0xE6,0xB6,0xB5),
- o3(0xE6,0xB7,0x87), o3(0xE6,0xB7,0xA6),
- o3(0xE6,0xB6,0xB8), o3(0xE6,0xB7,0x86),
- o3(0xE6,0xB7,0xAC), o3(0xE6,0xB7,0x9E),
- o3(0xE6,0xB7,0x8C), o3(0xE6,0xB7,0xA8),
- o3(0xE6,0xB7,0x92), o3(0xE6,0xB7,0x85),
- o3(0xE6,0xB7,0xBA), o3(0xE6,0xB7,0x99),
- o3(0xE6,0xB7,0xA4), o3(0xE6,0xB7,0x95),
- o3(0xE6,0xB7,0xAA), o3(0xE6,0xB7,0xAE),
- o3(0xE6,0xB8,0xAD), o3(0xE6,0xB9,0xAE),
- o3(0xE6,0xB8,0xAE), o3(0xE6,0xB8,0x99),
- o3(0xE6,0xB9,0xB2), o3(0xE6,0xB9,0x9F),
- o3(0xE6,0xB8,0xBE), o3(0xE6,0xB8,0xA3),
- o3(0xE6,0xB9,0xAB), o3(0xE6,0xB8,0xAB),
- o3(0xE6,0xB9,0xB6), o3(0xE6,0xB9,0x8D),
- o3(0xE6,0xB8,0x9F), o3(0xE6,0xB9,0x83),
- o3(0xE6,0xB8,0xBA), o3(0xE6,0xB9,0x8E),
- o3(0xE6,0xB8,0xA4), o3(0xE6,0xBB,0xBF),
- o3(0xE6,0xB8,0x9D), o3(0xE6,0xB8,0xB8),
- o3(0xE6,0xBA,0x82), o3(0xE6,0xBA,0xAA),
- o3(0xE6,0xBA,0x98), o3(0xE6,0xBB,0x89),
- o3(0xE6,0xBA,0xB7), o3(0xE6,0xBB,0x93),
- o3(0xE6,0xBA,0xBD), o3(0xE6,0xBA,0xAF),
- o3(0xE6,0xBB,0x84), o3(0xE6,0xBA,0xB2),
- o3(0xE6,0xBB,0x94), o3(0xE6,0xBB,0x95),
- o3(0xE6,0xBA,0x8F), o3(0xE6,0xBA,0xA5),
- o3(0xE6,0xBB,0x82), o3(0xE6,0xBA,0x9F),
- o3(0xE6,0xBD,0x81), o3(0xE6,0xBC,0x91),
- o3(0xE7,0x81,0x8C), o3(0xE6,0xBB,0xAC),
- o3(0xE6,0xBB,0xB8), o3(0xE6,0xBB,0xBE),
- o3(0xE6,0xBC,0xBF), o3(0xE6,0xBB,0xB2),
- o3(0xE6,0xBC,0xB1), o3(0xE6,0xBB,0xAF),
- o3(0xE6,0xBC,0xB2), o3(0xE6,0xBB,0x8C),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_9F = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_9F_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E0_infos[189] = {
- o3(0xE6,0xBC,0xBE), o3(0xE6,0xBC,0x93),
- o3(0xE6,0xBB,0xB7), o3(0xE6,0xBE,0x86),
- o3(0xE6,0xBD,0xBA), o3(0xE6,0xBD,0xB8),
- o3(0xE6,0xBE,0x81), o3(0xE6,0xBE,0x80),
- o3(0xE6,0xBD,0xAF), o3(0xE6,0xBD,0x9B),
- o3(0xE6,0xBF,0xB3), o3(0xE6,0xBD,0xAD),
- o3(0xE6,0xBE,0x82), o3(0xE6,0xBD,0xBC),
- o3(0xE6,0xBD,0x98), o3(0xE6,0xBE,0x8E),
- o3(0xE6,0xBE,0x91), o3(0xE6,0xBF,0x82),
- o3(0xE6,0xBD,0xA6), o3(0xE6,0xBE,0xB3),
- o3(0xE6,0xBE,0xA3), o3(0xE6,0xBE,0xA1),
- o3(0xE6,0xBE,0xA4), o3(0xE6,0xBE,0xB9),
- o3(0xE6,0xBF,0x86), o3(0xE6,0xBE,0xAA),
- o3(0xE6,0xBF,0x9F), o3(0xE6,0xBF,0x95),
- o3(0xE6,0xBF,0xAC), o3(0xE6,0xBF,0x94),
- o3(0xE6,0xBF,0x98), o3(0xE6,0xBF,0xB1),
- o3(0xE6,0xBF,0xAE), o3(0xE6,0xBF,0x9B),
- o3(0xE7,0x80,0x89), o3(0xE7,0x80,0x8B),
- o3(0xE6,0xBF,0xBA), o3(0xE7,0x80,0x91),
- o3(0xE7,0x80,0x81), o3(0xE7,0x80,0x8F),
- o3(0xE6,0xBF,0xBE), o3(0xE7,0x80,0x9B),
- o3(0xE7,0x80,0x9A), o3(0xE6,0xBD,0xB4),
- o3(0xE7,0x80,0x9D), o3(0xE7,0x80,0x98),
- o3(0xE7,0x80,0x9F), o3(0xE7,0x80,0xB0),
- o3(0xE7,0x80,0xBE), o3(0xE7,0x80,0xB2),
- o3(0xE7,0x81,0x91), o3(0xE7,0x81,0xA3),
- o3(0xE7,0x82,0x99), o3(0xE7,0x82,0x92),
- o3(0xE7,0x82,0xAF), o3(0xE7,0x83,0xB1),
- o3(0xE7,0x82,0xAC), o3(0xE7,0x82,0xB8),
- o3(0xE7,0x82,0xB3), o3(0xE7,0x82,0xAE),
- o3(0xE7,0x83,0x9F), o3(0xE7,0x83,0x8B),
- o3(0xE7,0x83,0x9D), o3(0xE7,0x83,0x99),
- o3(0xE7,0x84,0x89), o3(0xE7,0x83,0xBD),
- o3(0xE7,0x84,0x9C), o3(0xE7,0x84,0x99),
- o3(0xE7,0x85,0xA5), o3(0xE7,0x85,0x95),
- o3(0xE7,0x86,0x88), o3(0xE7,0x85,0xA6),
- o3(0xE7,0x85,0xA2), o3(0xE7,0x85,0x8C),
- o3(0xE7,0x85,0x96), o3(0xE7,0x85,0xAC),
- o3(0xE7,0x86,0x8F), o3(0xE7,0x87,0xBB),
- o3(0xE7,0x86,0x84), o3(0xE7,0x86,0x95),
- o3(0xE7,0x86,0xA8), o3(0xE7,0x86,0xAC),
- o3(0xE7,0x87,0x97), o3(0xE7,0x86,0xB9),
- o3(0xE7,0x86,0xBE), o3(0xE7,0x87,0x92),
- o3(0xE7,0x87,0x89), o3(0xE7,0x87,0x94),
- o3(0xE7,0x87,0x8E), o3(0xE7,0x87,0xA0),
- o3(0xE7,0x87,0xAC), o3(0xE7,0x87,0xA7),
- o3(0xE7,0x87,0xB5), o3(0xE7,0x87,0xBC),
- o3(0xE7,0x87,0xB9), o3(0xE7,0x87,0xBF),
- o3(0xE7,0x88,0x8D), o3(0xE7,0x88,0x90),
- o3(0xE7,0x88,0x9B), o3(0xE7,0x88,0xA8),
- o3(0xE7,0x88,0xAD), o3(0xE7,0x88,0xAC),
- o3(0xE7,0x88,0xB0), o3(0xE7,0x88,0xB2),
- o3(0xE7,0x88,0xBB), o3(0xE7,0x88,0xBC),
- o3(0xE7,0x88,0xBF), o3(0xE7,0x89,0x80),
- o3(0xE7,0x89,0x86), o3(0xE7,0x89,0x8B),
- o3(0xE7,0x89,0x98), o3(0xE7,0x89,0xB4),
- o3(0xE7,0x89,0xBE), o3(0xE7,0x8A,0x82),
- o3(0xE7,0x8A,0x81), o3(0xE7,0x8A,0x87),
- o3(0xE7,0x8A,0x92), o3(0xE7,0x8A,0x96),
- o3(0xE7,0x8A,0xA2), o3(0xE7,0x8A,0xA7),
- o3(0xE7,0x8A,0xB9), o3(0xE7,0x8A,0xB2),
- o3(0xE7,0x8B,0x83), o3(0xE7,0x8B,0x86),
- o3(0xE7,0x8B,0x84), o3(0xE7,0x8B,0x8E),
- o3(0xE7,0x8B,0x92), o3(0xE7,0x8B,0xA2),
- o3(0xE7,0x8B,0xA0), o3(0xE7,0x8B,0xA1),
- o3(0xE7,0x8B,0xB9), o3(0xE7,0x8B,0xB7),
- o3(0xE5,0x80,0x8F), o3(0xE7,0x8C,0x97),
- o3(0xE7,0x8C,0x8A), o3(0xE7,0x8C,0x9C),
- o3(0xE7,0x8C,0x96), o3(0xE7,0x8C,0x9D),
- o3(0xE7,0x8C,0xB4), o3(0xE7,0x8C,0xAF),
- o3(0xE7,0x8C,0xA9), o3(0xE7,0x8C,0xA5),
- o3(0xE7,0x8C,0xBE), o3(0xE7,0x8D,0x8E),
- o3(0xE7,0x8D,0x8F), o3(0xE9,0xBB,0x98),
- o3(0xE7,0x8D,0x97), o3(0xE7,0x8D,0xAA),
- o3(0xE7,0x8D,0xA8), o3(0xE7,0x8D,0xB0),
- o3(0xE7,0x8D,0xB8), o3(0xE7,0x8D,0xB5),
- o3(0xE7,0x8D,0xBB), o3(0xE7,0x8D,0xBA),
- o3(0xE7,0x8F,0x88), o3(0xE7,0x8E,0xB3),
- o3(0xE7,0x8F,0x8E), o3(0xE7,0x8E,0xBB),
- o3(0xE7,0x8F,0x80), o3(0xE7,0x8F,0xA5),
- o3(0xE7,0x8F,0xAE), o3(0xE7,0x8F,0x9E),
- o3(0xE7,0x92,0xA2), o3(0xE7,0x90,0x85),
- o3(0xE7,0x91,0xAF), o3(0xE7,0x90,0xA5),
- o3(0xE7,0x8F,0xB8), o3(0xE7,0x90,0xB2),
- o3(0xE7,0x90,0xBA), o3(0xE7,0x91,0x95),
- o3(0xE7,0x90,0xBF), o3(0xE7,0x91,0x9F),
- o3(0xE7,0x91,0x99), o3(0xE7,0x91,0x81),
- o3(0xE7,0x91,0x9C), o3(0xE7,0x91,0xA9),
- o3(0xE7,0x91,0xB0), o3(0xE7,0x91,0xA3),
- o3(0xE7,0x91,0xAA), o3(0xE7,0x91,0xB6),
- o3(0xE7,0x91,0xBE), o3(0xE7,0x92,0x8B),
- o3(0xE7,0x92,0x9E), o3(0xE7,0x92,0xA7),
- o3(0xE7,0x93,0x8A), o3(0xE7,0x93,0x8F),
- o3(0xE7,0x93,0x94), o3(0xE7,0x8F,0xB1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E0 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E0_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E1_infos[189] = {
- o3(0xE7,0x93,0xA0), o3(0xE7,0x93,0xA3),
- o3(0xE7,0x93,0xA7), o3(0xE7,0x93,0xA9),
- o3(0xE7,0x93,0xAE), o3(0xE7,0x93,0xB2),
- o3(0xE7,0x93,0xB0), o3(0xE7,0x93,0xB1),
- o3(0xE7,0x93,0xB8), o3(0xE7,0x93,0xB7),
- o3(0xE7,0x94,0x84), o3(0xE7,0x94,0x83),
- o3(0xE7,0x94,0x85), o3(0xE7,0x94,0x8C),
- o3(0xE7,0x94,0x8E), o3(0xE7,0x94,0x8D),
- o3(0xE7,0x94,0x95), o3(0xE7,0x94,0x93),
- o3(0xE7,0x94,0x9E), o3(0xE7,0x94,0xA6),
- o3(0xE7,0x94,0xAC), o3(0xE7,0x94,0xBC),
- o3(0xE7,0x95,0x84), o3(0xE7,0x95,0x8D),
- o3(0xE7,0x95,0x8A), o3(0xE7,0x95,0x89),
- o3(0xE7,0x95,0x9B), o3(0xE7,0x95,0x86),
- o3(0xE7,0x95,0x9A), o3(0xE7,0x95,0xA9),
- o3(0xE7,0x95,0xA4), o3(0xE7,0x95,0xA7),
- o3(0xE7,0x95,0xAB), o3(0xE7,0x95,0xAD),
- o3(0xE7,0x95,0xB8), o3(0xE7,0x95,0xB6),
- o3(0xE7,0x96,0x86), o3(0xE7,0x96,0x87),
- o3(0xE7,0x95,0xB4), o3(0xE7,0x96,0x8A),
- o3(0xE7,0x96,0x89), o3(0xE7,0x96,0x82),
- o3(0xE7,0x96,0x94), o3(0xE7,0x96,0x9A),
- o3(0xE7,0x96,0x9D), o3(0xE7,0x96,0xA5),
- o3(0xE7,0x96,0xA3), o3(0xE7,0x97,0x82),
- o3(0xE7,0x96,0xB3), o3(0xE7,0x97,0x83),
- o3(0xE7,0x96,0xB5), o3(0xE7,0x96,0xBD),
- o3(0xE7,0x96,0xB8), o3(0xE7,0x96,0xBC),
- o3(0xE7,0x96,0xB1), o3(0xE7,0x97,0x8D),
- o3(0xE7,0x97,0x8A), o3(0xE7,0x97,0x92),
- o3(0xE7,0x97,0x99), o3(0xE7,0x97,0xA3),
- o3(0xE7,0x97,0x9E), o3(0xE7,0x97,0xBE),
- o3(0xE7,0x97,0xBF), o3(0xE7,0x97,0xBC),
- o3(0xE7,0x98,0x81), o3(0xE7,0x97,0xB0),
- o3(0xE7,0x97,0xBA), o3(0xE7,0x97,0xB2),
- o3(0xE7,0x97,0xB3), o3(0xE7,0x98,0x8B),
- o3(0xE7,0x98,0x8D), o3(0xE7,0x98,0x89),
- o3(0xE7,0x98,0x9F), o3(0xE7,0x98,0xA7),
- o3(0xE7,0x98,0xA0), o3(0xE7,0x98,0xA1),
- o3(0xE7,0x98,0xA2), o3(0xE7,0x98,0xA4),
- o3(0xE7,0x98,0xB4), o3(0xE7,0x98,0xB0),
- o3(0xE7,0x98,0xBB), o3(0xE7,0x99,0x87),
- o3(0xE7,0x99,0x88), o3(0xE7,0x99,0x86),
- o3(0xE7,0x99,0x9C), o3(0xE7,0x99,0x98),
- o3(0xE7,0x99,0xA1), o3(0xE7,0x99,0xA2),
- o3(0xE7,0x99,0xA8), o3(0xE7,0x99,0xA9),
- o3(0xE7,0x99,0xAA), o3(0xE7,0x99,0xA7),
- o3(0xE7,0x99,0xAC), o3(0xE7,0x99,0xB0),
- o3(0xE7,0x99,0xB2), o3(0xE7,0x99,0xB6),
- o3(0xE7,0x99,0xB8), o3(0xE7,0x99,0xBC),
- o3(0xE7,0x9A,0x80), o3(0xE7,0x9A,0x83),
- o3(0xE7,0x9A,0x88), o3(0xE7,0x9A,0x8B),
- o3(0xE7,0x9A,0x8E), o3(0xE7,0x9A,0x96),
- o3(0xE7,0x9A,0x93), o3(0xE7,0x9A,0x99),
- o3(0xE7,0x9A,0x9A), o3(0xE7,0x9A,0xB0),
- o3(0xE7,0x9A,0xB4), o3(0xE7,0x9A,0xB8),
- o3(0xE7,0x9A,0xB9), o3(0xE7,0x9A,0xBA),
- o3(0xE7,0x9B,0x82), o3(0xE7,0x9B,0x8D),
- o3(0xE7,0x9B,0x96), o3(0xE7,0x9B,0x92),
- o3(0xE7,0x9B,0x9E), o3(0xE7,0x9B,0xA1),
- o3(0xE7,0x9B,0xA5), o3(0xE7,0x9B,0xA7),
- o3(0xE7,0x9B,0xAA), o3(0xE8,0x98,0xAF),
- o3(0xE7,0x9B,0xBB), o3(0xE7,0x9C,0x88),
- o3(0xE7,0x9C,0x87), o3(0xE7,0x9C,0x84),
- o3(0xE7,0x9C,0xA9), o3(0xE7,0x9C,0xA4),
- o3(0xE7,0x9C,0x9E), o3(0xE7,0x9C,0xA5),
- o3(0xE7,0x9C,0xA6), o3(0xE7,0x9C,0x9B),
- o3(0xE7,0x9C,0xB7), o3(0xE7,0x9C,0xB8),
- o3(0xE7,0x9D,0x87), o3(0xE7,0x9D,0x9A),
- o3(0xE7,0x9D,0xA8), o3(0xE7,0x9D,0xAB),
- o3(0xE7,0x9D,0x9B), o3(0xE7,0x9D,0xA5),
- o3(0xE7,0x9D,0xBF), o3(0xE7,0x9D,0xBE),
- o3(0xE7,0x9D,0xB9), o3(0xE7,0x9E,0x8E),
- o3(0xE7,0x9E,0x8B), o3(0xE7,0x9E,0x91),
- o3(0xE7,0x9E,0xA0), o3(0xE7,0x9E,0x9E),
- o3(0xE7,0x9E,0xB0), o3(0xE7,0x9E,0xB6),
- o3(0xE7,0x9E,0xB9), o3(0xE7,0x9E,0xBF),
- o3(0xE7,0x9E,0xBC), o3(0xE7,0x9E,0xBD),
- o3(0xE7,0x9E,0xBB), o3(0xE7,0x9F,0x87),
- o3(0xE7,0x9F,0x8D), o3(0xE7,0x9F,0x97),
- o3(0xE7,0x9F,0x9A), o3(0xE7,0x9F,0x9C),
- o3(0xE7,0x9F,0xA3), o3(0xE7,0x9F,0xAE),
- o3(0xE7,0x9F,0xBC), o3(0xE7,0xA0,0x8C),
- o3(0xE7,0xA0,0x92), o3(0xE7,0xA4,0xA6),
- o3(0xE7,0xA0,0xA0), o3(0xE7,0xA4,0xAA),
- o3(0xE7,0xA1,0x85), o3(0xE7,0xA2,0x8E),
- o3(0xE7,0xA1,0xB4), o3(0xE7,0xA2,0x86),
- o3(0xE7,0xA1,0xBC), o3(0xE7,0xA2,0x9A),
- o3(0xE7,0xA2,0x8C), o3(0xE7,0xA2,0xA3),
- o3(0xE7,0xA2,0xB5), o3(0xE7,0xA2,0xAA),
- o3(0xE7,0xA2,0xAF), o3(0xE7,0xA3,0x91),
- o3(0xE7,0xA3,0x86), o3(0xE7,0xA3,0x8B),
- o3(0xE7,0xA3,0x94), o3(0xE7,0xA2,0xBE),
- o3(0xE7,0xA2,0xBC), o3(0xE7,0xA3,0x85),
- o3(0xE7,0xA3,0x8A), o3(0xE7,0xA3,0xAC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E1 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E1_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E2_infos[189] = {
- o3(0xE7,0xA3,0xA7), o3(0xE7,0xA3,0x9A),
- o3(0xE7,0xA3,0xBD), o3(0xE7,0xA3,0xB4),
- o3(0xE7,0xA4,0x87), o3(0xE7,0xA4,0x92),
- o3(0xE7,0xA4,0x91), o3(0xE7,0xA4,0x99),
- o3(0xE7,0xA4,0xAC), o3(0xE7,0xA4,0xAB),
- o3(0xE7,0xA5,0x80), o3(0xE7,0xA5,0xA0),
- o3(0xE7,0xA5,0x97), o3(0xE7,0xA5,0x9F),
- o3(0xE7,0xA5,0x9A), o3(0xE7,0xA5,0x95),
- o3(0xE7,0xA5,0x93), o3(0xE7,0xA5,0xBA),
- o3(0xE7,0xA5,0xBF), o3(0xE7,0xA6,0x8A),
- o3(0xE7,0xA6,0x9D), o3(0xE7,0xA6,0xA7),
- o3(0xE9,0xBD,0x8B), o3(0xE7,0xA6,0xAA),
- o3(0xE7,0xA6,0xAE), o3(0xE7,0xA6,0xB3),
- o3(0xE7,0xA6,0xB9), o3(0xE7,0xA6,0xBA),
- o3(0xE7,0xA7,0x89), o3(0xE7,0xA7,0x95),
- o3(0xE7,0xA7,0xA7), o3(0xE7,0xA7,0xAC),
- o3(0xE7,0xA7,0xA1), o3(0xE7,0xA7,0xA3),
- o3(0xE7,0xA8,0x88), o3(0xE7,0xA8,0x8D),
- o3(0xE7,0xA8,0x98), o3(0xE7,0xA8,0x99),
- o3(0xE7,0xA8,0xA0), o3(0xE7,0xA8,0x9F),
- o3(0xE7,0xA6,0x80), o3(0xE7,0xA8,0xB1),
- o3(0xE7,0xA8,0xBB), o3(0xE7,0xA8,0xBE),
- o3(0xE7,0xA8,0xB7), o3(0xE7,0xA9,0x83),
- o3(0xE7,0xA9,0x97), o3(0xE7,0xA9,0x89),
- o3(0xE7,0xA9,0xA1), o3(0xE7,0xA9,0xA2),
- o3(0xE7,0xA9,0xA9), o3(0xE9,0xBE,0x9D),
- o3(0xE7,0xA9,0xB0), o3(0xE7,0xA9,0xB9),
- o3(0xE7,0xA9,0xBD), o3(0xE7,0xAA,0x88),
- o3(0xE7,0xAA,0x97), o3(0xE7,0xAA,0x95),
- o3(0xE7,0xAA,0x98), o3(0xE7,0xAA,0x96),
- o3(0xE7,0xAA,0xA9), o3(0xE7,0xAB,0x88),
- o3(0xE7,0xAA,0xB0), o3(0xE7,0xAA,0xB6),
- o3(0xE7,0xAB,0x85), o3(0xE7,0xAB,0x84),
- o3(0xE7,0xAA,0xBF), o3(0xE9,0x82,0x83),
- o3(0xE7,0xAB,0x87), o3(0xE7,0xAB,0x8A),
- o3(0xE7,0xAB,0x8D), o3(0xE7,0xAB,0x8F),
- o3(0xE7,0xAB,0x95), o3(0xE7,0xAB,0x93),
- o3(0xE7,0xAB,0x99), o3(0xE7,0xAB,0x9A),
- o3(0xE7,0xAB,0x9D), o3(0xE7,0xAB,0xA1),
- o3(0xE7,0xAB,0xA2), o3(0xE7,0xAB,0xA6),
- o3(0xE7,0xAB,0xAD), o3(0xE7,0xAB,0xB0),
- o3(0xE7,0xAC,0x82), o3(0xE7,0xAC,0x8F),
- o3(0xE7,0xAC,0x8A), o3(0xE7,0xAC,0x86),
- o3(0xE7,0xAC,0xB3), o3(0xE7,0xAC,0x98),
- o3(0xE7,0xAC,0x99), o3(0xE7,0xAC,0x9E),
- o3(0xE7,0xAC,0xB5), o3(0xE7,0xAC,0xA8),
- o3(0xE7,0xAC,0xB6), o3(0xE7,0xAD,0x90),
- o3(0xE7,0xAD,0xBA), o3(0xE7,0xAC,0x84),
- o3(0xE7,0xAD,0x8D), o3(0xE7,0xAC,0x8B),
- o3(0xE7,0xAD,0x8C), o3(0xE7,0xAD,0x85),
- o3(0xE7,0xAD,0xB5), o3(0xE7,0xAD,0xA5),
- o3(0xE7,0xAD,0xB4), o3(0xE7,0xAD,0xA7),
- o3(0xE7,0xAD,0xB0), o3(0xE7,0xAD,0xB1),
- o3(0xE7,0xAD,0xAC), o3(0xE7,0xAD,0xAE),
- o3(0xE7,0xAE,0x9D), o3(0xE7,0xAE,0x98),
- o3(0xE7,0xAE,0x9F), o3(0xE7,0xAE,0x8D),
- o3(0xE7,0xAE,0x9C), o3(0xE7,0xAE,0x9A),
- o3(0xE7,0xAE,0x8B), o3(0xE7,0xAE,0x92),
- o3(0xE7,0xAE,0x8F), o3(0xE7,0xAD,0x9D),
- o3(0xE7,0xAE,0x99), o3(0xE7,0xAF,0x8B),
- o3(0xE7,0xAF,0x81), o3(0xE7,0xAF,0x8C),
- o3(0xE7,0xAF,0x8F), o3(0xE7,0xAE,0xB4),
- o3(0xE7,0xAF,0x86), o3(0xE7,0xAF,0x9D),
- o3(0xE7,0xAF,0xA9), o3(0xE7,0xB0,0x91),
- o3(0xE7,0xB0,0x94), o3(0xE7,0xAF,0xA6),
- o3(0xE7,0xAF,0xA5), o3(0xE7,0xB1,0xA0),
- o3(0xE7,0xB0,0x80), o3(0xE7,0xB0,0x87),
- o3(0xE7,0xB0,0x93), o3(0xE7,0xAF,0xB3),
- o3(0xE7,0xAF,0xB7), o3(0xE7,0xB0,0x97),
- o3(0xE7,0xB0,0x8D), o3(0xE7,0xAF,0xB6),
- o3(0xE7,0xB0,0xA3), o3(0xE7,0xB0,0xA7),
- o3(0xE7,0xB0,0xAA), o3(0xE7,0xB0,0x9F),
- o3(0xE7,0xB0,0xB7), o3(0xE7,0xB0,0xAB),
- o3(0xE7,0xB0,0xBD), o3(0xE7,0xB1,0x8C),
- o3(0xE7,0xB1,0x83), o3(0xE7,0xB1,0x94),
- o3(0xE7,0xB1,0x8F), o3(0xE7,0xB1,0x80),
- o3(0xE7,0xB1,0x90), o3(0xE7,0xB1,0x98),
- o3(0xE7,0xB1,0x9F), o3(0xE7,0xB1,0xA4),
- o3(0xE7,0xB1,0x96), o3(0xE7,0xB1,0xA5),
- o3(0xE7,0xB1,0xAC), o3(0xE7,0xB1,0xB5),
- o3(0xE7,0xB2,0x83), o3(0xE7,0xB2,0x90),
- o3(0xE7,0xB2,0xA4), o3(0xE7,0xB2,0xAD),
- o3(0xE7,0xB2,0xA2), o3(0xE7,0xB2,0xAB),
- o3(0xE7,0xB2,0xA1), o3(0xE7,0xB2,0xA8),
- o3(0xE7,0xB2,0xB3), o3(0xE7,0xB2,0xB2),
- o3(0xE7,0xB2,0xB1), o3(0xE7,0xB2,0xAE),
- o3(0xE7,0xB2,0xB9), o3(0xE7,0xB2,0xBD),
- o3(0xE7,0xB3,0x80), o3(0xE7,0xB3,0x85),
- o3(0xE7,0xB3,0x82), o3(0xE7,0xB3,0x98),
- o3(0xE7,0xB3,0x92), o3(0xE7,0xB3,0x9C),
- o3(0xE7,0xB3,0xA2), o3(0xE9,0xAC,0xBB),
- o3(0xE7,0xB3,0xAF), o3(0xE7,0xB3,0xB2),
- o3(0xE7,0xB3,0xB4), o3(0xE7,0xB3,0xB6),
- o3(0xE7,0xB3,0xBA), o3(0xE7,0xB4,0x86),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E2 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E2_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E3_infos[189] = {
- o3(0xE7,0xB4,0x82), o3(0xE7,0xB4,0x9C),
- o3(0xE7,0xB4,0x95), o3(0xE7,0xB4,0x8A),
- o3(0xE7,0xB5,0x85), o3(0xE7,0xB5,0x8B),
- o3(0xE7,0xB4,0xAE), o3(0xE7,0xB4,0xB2),
- o3(0xE7,0xB4,0xBF), o3(0xE7,0xB4,0xB5),
- o3(0xE7,0xB5,0x86), o3(0xE7,0xB5,0xB3),
- o3(0xE7,0xB5,0x96), o3(0xE7,0xB5,0x8E),
- o3(0xE7,0xB5,0xB2), o3(0xE7,0xB5,0xA8),
- o3(0xE7,0xB5,0xAE), o3(0xE7,0xB5,0x8F),
- o3(0xE7,0xB5,0xA3), o3(0xE7,0xB6,0x93),
- o3(0xE7,0xB6,0x89), o3(0xE7,0xB5,0x9B),
- o3(0xE7,0xB6,0x8F), o3(0xE7,0xB5,0xBD),
- o3(0xE7,0xB6,0x9B), o3(0xE7,0xB6,0xBA),
- o3(0xE7,0xB6,0xAE), o3(0xE7,0xB6,0xA3),
- o3(0xE7,0xB6,0xB5), o3(0xE7,0xB7,0x87),
- o3(0xE7,0xB6,0xBD), o3(0xE7,0xB6,0xAB),
- o3(0xE7,0xB8,0xBD), o3(0xE7,0xB6,0xA2),
- o3(0xE7,0xB6,0xAF), o3(0xE7,0xB7,0x9C),
- o3(0xE7,0xB6,0xB8), o3(0xE7,0xB6,0x9F),
- o3(0xE7,0xB6,0xB0), o3(0xE7,0xB7,0x98),
- o3(0xE7,0xB7,0x9D), o3(0xE7,0xB7,0xA4),
- o3(0xE7,0xB7,0x9E), o3(0xE7,0xB7,0xBB),
- o3(0xE7,0xB7,0xB2), o3(0xE7,0xB7,0xA1),
- o3(0xE7,0xB8,0x85), o3(0xE7,0xB8,0x8A),
- o3(0xE7,0xB8,0xA3), o3(0xE7,0xB8,0xA1),
- o3(0xE7,0xB8,0x92), o3(0xE7,0xB8,0xB1),
- o3(0xE7,0xB8,0x9F), o3(0xE7,0xB8,0x89),
- o3(0xE7,0xB8,0x8B), o3(0xE7,0xB8,0xA2),
- o3(0xE7,0xB9,0x86), o3(0xE7,0xB9,0xA6),
- o3(0xE7,0xB8,0xBB), o3(0xE7,0xB8,0xB5),
- o3(0xE7,0xB8,0xB9), o3(0xE7,0xB9,0x83),
- o3(0xE7,0xB8,0xB7), o3(0xE7,0xB8,0xB2),
- o3(0xE7,0xB8,0xBA), o3(0xE7,0xB9,0xA7),
- o3(0xE7,0xB9,0x9D), o3(0xE7,0xB9,0x96),
- o3(0xE7,0xB9,0x9E), o3(0xE7,0xB9,0x99),
- o3(0xE7,0xB9,0x9A), o3(0xE7,0xB9,0xB9),
- o3(0xE7,0xB9,0xAA), o3(0xE7,0xB9,0xA9),
- o3(0xE7,0xB9,0xBC), o3(0xE7,0xB9,0xBB),
- o3(0xE7,0xBA,0x83), o3(0xE7,0xB7,0x95),
- o3(0xE7,0xB9,0xBD), o3(0xE8,0xBE,0xAE),
- o3(0xE7,0xB9,0xBF), o3(0xE7,0xBA,0x88),
- o3(0xE7,0xBA,0x89), o3(0xE7,0xBA,0x8C),
- o3(0xE7,0xBA,0x92), o3(0xE7,0xBA,0x90),
- o3(0xE7,0xBA,0x93), o3(0xE7,0xBA,0x94),
- o3(0xE7,0xBA,0x96), o3(0xE7,0xBA,0x8E),
- o3(0xE7,0xBA,0x9B), o3(0xE7,0xBA,0x9C),
- o3(0xE7,0xBC,0xB8), o3(0xE7,0xBC,0xBA),
- o3(0xE7,0xBD,0x85), o3(0xE7,0xBD,0x8C),
- o3(0xE7,0xBD,0x8D), o3(0xE7,0xBD,0x8E),
- o3(0xE7,0xBD,0x90), o3(0xE7,0xBD,0x91),
- o3(0xE7,0xBD,0x95), o3(0xE7,0xBD,0x94),
- o3(0xE7,0xBD,0x98), o3(0xE7,0xBD,0x9F),
- o3(0xE7,0xBD,0xA0), o3(0xE7,0xBD,0xA8),
- o3(0xE7,0xBD,0xA9), o3(0xE7,0xBD,0xA7),
- o3(0xE7,0xBD,0xB8), o3(0xE7,0xBE,0x82),
- o3(0xE7,0xBE,0x86), o3(0xE7,0xBE,0x83),
- o3(0xE7,0xBE,0x88), o3(0xE7,0xBE,0x87),
- o3(0xE7,0xBE,0x8C), o3(0xE7,0xBE,0x94),
- o3(0xE7,0xBE,0x9E), o3(0xE7,0xBE,0x9D),
- o3(0xE7,0xBE,0x9A), o3(0xE7,0xBE,0xA3),
- o3(0xE7,0xBE,0xAF), o3(0xE7,0xBE,0xB2),
- o3(0xE7,0xBE,0xB9), o3(0xE7,0xBE,0xAE),
- o3(0xE7,0xBE,0xB6), o3(0xE7,0xBE,0xB8),
- o3(0xE8,0xAD,0xB1), o3(0xE7,0xBF,0x85),
- o3(0xE7,0xBF,0x86), o3(0xE7,0xBF,0x8A),
- o3(0xE7,0xBF,0x95), o3(0xE7,0xBF,0x94),
- o3(0xE7,0xBF,0xA1), o3(0xE7,0xBF,0xA6),
- o3(0xE7,0xBF,0xA9), o3(0xE7,0xBF,0xB3),
- o3(0xE7,0xBF,0xB9), o3(0xE9,0xA3,0x9C),
- o3(0xE8,0x80,0x86), o3(0xE8,0x80,0x84),
- o3(0xE8,0x80,0x8B), o3(0xE8,0x80,0x92),
- o3(0xE8,0x80,0x98), o3(0xE8,0x80,0x99),
- o3(0xE8,0x80,0x9C), o3(0xE8,0x80,0xA1),
- o3(0xE8,0x80,0xA8), o3(0xE8,0x80,0xBF),
- o3(0xE8,0x80,0xBB), o3(0xE8,0x81,0x8A),
- o3(0xE8,0x81,0x86), o3(0xE8,0x81,0x92),
- o3(0xE8,0x81,0x98), o3(0xE8,0x81,0x9A),
- o3(0xE8,0x81,0x9F), o3(0xE8,0x81,0xA2),
- o3(0xE8,0x81,0xA8), o3(0xE8,0x81,0xB3),
- o3(0xE8,0x81,0xB2), o3(0xE8,0x81,0xB0),
- o3(0xE8,0x81,0xB6), o3(0xE8,0x81,0xB9),
- o3(0xE8,0x81,0xBD), o3(0xE8,0x81,0xBF),
- o3(0xE8,0x82,0x84), o3(0xE8,0x82,0x86),
- o3(0xE8,0x82,0x85), o3(0xE8,0x82,0x9B),
- o3(0xE8,0x82,0x93), o3(0xE8,0x82,0x9A),
- o3(0xE8,0x82,0xAD), o3(0xE5,0x86,0x90),
- o3(0xE8,0x82,0xAC), o3(0xE8,0x83,0x9B),
- o3(0xE8,0x83,0xA5), o3(0xE8,0x83,0x99),
- o3(0xE8,0x83,0x9D), o3(0xE8,0x83,0x84),
- o3(0xE8,0x83,0x9A), o3(0xE8,0x83,0x96),
- o3(0xE8,0x84,0x89), o3(0xE8,0x83,0xAF),
- o3(0xE8,0x83,0xB1), o3(0xE8,0x84,0x9B),
- o3(0xE8,0x84,0xA9), o3(0xE8,0x84,0xA3),
- o3(0xE8,0x84,0xAF), o3(0xE8,0x85,0x8B),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E3 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E3_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E4_infos[189] = {
- o3(0xE9,0x9A,0x8B), o3(0xE8,0x85,0x86),
- o3(0xE8,0x84,0xBE), o3(0xE8,0x85,0x93),
- o3(0xE8,0x85,0x91), o3(0xE8,0x83,0xBC),
- o3(0xE8,0x85,0xB1), o3(0xE8,0x85,0xAE),
- o3(0xE8,0x85,0xA5), o3(0xE8,0x85,0xA6),
- o3(0xE8,0x85,0xB4), o3(0xE8,0x86,0x83),
- o3(0xE8,0x86,0x88), o3(0xE8,0x86,0x8A),
- o3(0xE8,0x86,0x80), o3(0xE8,0x86,0x82),
- o3(0xE8,0x86,0xA0), o3(0xE8,0x86,0x95),
- o3(0xE8,0x86,0xA4), o3(0xE8,0x86,0xA3),
- o3(0xE8,0x85,0x9F), o3(0xE8,0x86,0x93),
- o3(0xE8,0x86,0xA9), o3(0xE8,0x86,0xB0),
- o3(0xE8,0x86,0xB5), o3(0xE8,0x86,0xBE),
- o3(0xE8,0x86,0xB8), o3(0xE8,0x86,0xBD),
- o3(0xE8,0x87,0x80), o3(0xE8,0x87,0x82),
- o3(0xE8,0x86,0xBA), o3(0xE8,0x87,0x89),
- o3(0xE8,0x87,0x8D), o3(0xE8,0x87,0x91),
- o3(0xE8,0x87,0x99), o3(0xE8,0x87,0x98),
- o3(0xE8,0x87,0x88), o3(0xE8,0x87,0x9A),
- o3(0xE8,0x87,0x9F), o3(0xE8,0x87,0xA0),
- o3(0xE8,0x87,0xA7), o3(0xE8,0x87,0xBA),
- o3(0xE8,0x87,0xBB), o3(0xE8,0x87,0xBE),
- o3(0xE8,0x88,0x81), o3(0xE8,0x88,0x82),
- o3(0xE8,0x88,0x85), o3(0xE8,0x88,0x87),
- o3(0xE8,0x88,0x8A), o3(0xE8,0x88,0x8D),
- o3(0xE8,0x88,0x90), o3(0xE8,0x88,0x96),
- o3(0xE8,0x88,0xA9), o3(0xE8,0x88,0xAB),
- o3(0xE8,0x88,0xB8), o3(0xE8,0x88,0xB3),
- o3(0xE8,0x89,0x80), o3(0xE8,0x89,0x99),
- o3(0xE8,0x89,0x98), o3(0xE8,0x89,0x9D),
- o3(0xE8,0x89,0x9A), o3(0xE8,0x89,0x9F),
- o3(0xE8,0x89,0xA4), o3(0xE8,0x89,0xA2),
- o3(0xE8,0x89,0xA8), o3(0xE8,0x89,0xAA),
- o3(0xE8,0x89,0xAB), o3(0xE8,0x88,0xAE),
- o3(0xE8,0x89,0xB1), o3(0xE8,0x89,0xB7),
- o3(0xE8,0x89,0xB8), o3(0xE8,0x89,0xBE),
- o3(0xE8,0x8A,0x8D), o3(0xE8,0x8A,0x92),
- o3(0xE8,0x8A,0xAB), o3(0xE8,0x8A,0x9F),
- o3(0xE8,0x8A,0xBB), o3(0xE8,0x8A,0xAC),
- o3(0xE8,0x8B,0xA1), o3(0xE8,0x8B,0xA3),
- o3(0xE8,0x8B,0x9F), o3(0xE8,0x8B,0x92),
- o3(0xE8,0x8B,0xB4), o3(0xE8,0x8B,0xB3),
- o3(0xE8,0x8B,0xBA), o3(0xE8,0x8E,0x93),
- o3(0xE8,0x8C,0x83), o3(0xE8,0x8B,0xBB),
- o3(0xE8,0x8B,0xB9), o3(0xE8,0x8B,0x9E),
- o3(0xE8,0x8C,0x86), o3(0xE8,0x8B,0x9C),
- o3(0xE8,0x8C,0x89), o3(0xE8,0x8B,0x99),
- o3(0xE8,0x8C,0xB5), o3(0xE8,0x8C,0xB4),
- o3(0xE8,0x8C,0x96), o3(0xE8,0x8C,0xB2),
- o3(0xE8,0x8C,0xB1), o3(0xE8,0x8D,0x80),
- o3(0xE8,0x8C,0xB9), o3(0xE8,0x8D,0x90),
- o3(0xE8,0x8D,0x85), o3(0xE8,0x8C,0xAF),
- o3(0xE8,0x8C,0xAB), o3(0xE8,0x8C,0x97),
- o3(0xE8,0x8C,0x98), o3(0xE8,0x8E,0x85),
- o3(0xE8,0x8E,0x9A), o3(0xE8,0x8E,0xAA),
- o3(0xE8,0x8E,0x9F), o3(0xE8,0x8E,0xA2),
- o3(0xE8,0x8E,0x96), o3(0xE8,0x8C,0xA3),
- o3(0xE8,0x8E,0x8E), o3(0xE8,0x8E,0x87),
- o3(0xE8,0x8E,0x8A), o3(0xE8,0x8D,0xBC),
- o3(0xE8,0x8E,0xB5), o3(0xE8,0x8D,0xB3),
- o3(0xE8,0x8D,0xB5), o3(0xE8,0x8E,0xA0),
- o3(0xE8,0x8E,0x89), o3(0xE8,0x8E,0xA8),
- o3(0xE8,0x8F,0xB4), o3(0xE8,0x90,0x93),
- o3(0xE8,0x8F,0xAB), o3(0xE8,0x8F,0x8E),
- o3(0xE8,0x8F,0xBD), o3(0xE8,0x90,0x83),
- o3(0xE8,0x8F,0x98), o3(0xE8,0x90,0x8B),
- o3(0xE8,0x8F,0x81), o3(0xE8,0x8F,0xB7),
- o3(0xE8,0x90,0x87), o3(0xE8,0x8F,0xA0),
- o3(0xE8,0x8F,0xB2), o3(0xE8,0x90,0x8D),
- o3(0xE8,0x90,0xA2), o3(0xE8,0x90,0xA0),
- o3(0xE8,0x8E,0xBD), o3(0xE8,0x90,0xB8),
- o3(0xE8,0x94,0x86), o3(0xE8,0x8F,0xBB),
- o3(0xE8,0x91,0xAD), o3(0xE8,0x90,0xAA),
- o3(0xE8,0x90,0xBC), o3(0xE8,0x95,0x9A),
- o3(0xE8,0x92,0x84), o3(0xE8,0x91,0xB7),
- o3(0xE8,0x91,0xAB), o3(0xE8,0x92,0xAD),
- o3(0xE8,0x91,0xAE), o3(0xE8,0x92,0x82),
- o3(0xE8,0x91,0xA9), o3(0xE8,0x91,0x86),
- o3(0xE8,0x90,0xAC), o3(0xE8,0x91,0xAF),
- o3(0xE8,0x91,0xB9), o3(0xE8,0x90,0xB5),
- o3(0xE8,0x93,0x8A), o3(0xE8,0x91,0xA2),
- o3(0xE8,0x92,0xB9), o3(0xE8,0x92,0xBF),
- o3(0xE8,0x92,0x9F), o3(0xE8,0x93,0x99),
- o3(0xE8,0x93,0x8D), o3(0xE8,0x92,0xBB),
- o3(0xE8,0x93,0x9A), o3(0xE8,0x93,0x90),
- o3(0xE8,0x93,0x81), o3(0xE8,0x93,0x86),
- o3(0xE8,0x93,0x96), o3(0xE8,0x92,0xA1),
- o3(0xE8,0x94,0xA1), o3(0xE8,0x93,0xBF),
- o3(0xE8,0x93,0xB4), o3(0xE8,0x94,0x97),
- o3(0xE8,0x94,0x98), o3(0xE8,0x94,0xAC),
- o3(0xE8,0x94,0x9F), o3(0xE8,0x94,0x95),
- o3(0xE8,0x94,0x94), o3(0xE8,0x93,0xBC),
- o3(0xE8,0x95,0x80), o3(0xE8,0x95,0xA3),
- o3(0xE8,0x95,0x98), o3(0xE8,0x95,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E4 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E4_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E5_infos[189] = {
- o3(0xE8,0x95,0x81), o3(0xE8,0x98,0x82),
- o3(0xE8,0x95,0x8B), o3(0xE8,0x95,0x95),
- o3(0xE8,0x96,0x80), o3(0xE8,0x96,0xA4),
- o3(0xE8,0x96,0x88), o3(0xE8,0x96,0x91),
- o3(0xE8,0x96,0x8A), o3(0xE8,0x96,0xA8),
- o3(0xE8,0x95,0xAD), o3(0xE8,0x96,0x94),
- o3(0xE8,0x96,0x9B), o3(0xE8,0x97,0xAA),
- o3(0xE8,0x96,0x87), o3(0xE8,0x96,0x9C),
- o3(0xE8,0x95,0xB7), o3(0xE8,0x95,0xBE),
- o3(0xE8,0x96,0x90), o3(0xE8,0x97,0x89),
- o3(0xE8,0x96,0xBA), o3(0xE8,0x97,0x8F),
- o3(0xE8,0x96,0xB9), o3(0xE8,0x97,0x90),
- o3(0xE8,0x97,0x95), o3(0xE8,0x97,0x9D),
- o3(0xE8,0x97,0xA5), o3(0xE8,0x97,0x9C),
- o3(0xE8,0x97,0xB9), o3(0xE8,0x98,0x8A),
- o3(0xE8,0x98,0x93), o3(0xE8,0x98,0x8B),
- o3(0xE8,0x97,0xBE), o3(0xE8,0x97,0xBA),
- o3(0xE8,0x98,0x86), o3(0xE8,0x98,0xA2),
- o3(0xE8,0x98,0x9A), o3(0xE8,0x98,0xB0),
- o3(0xE8,0x98,0xBF), o3(0xE8,0x99,0x8D),
- o3(0xE4,0xB9,0x95), o3(0xE8,0x99,0x94),
- o3(0xE8,0x99,0x9F), o3(0xE8,0x99,0xA7),
- o3(0xE8,0x99,0xB1), o3(0xE8,0x9A,0x93),
- o3(0xE8,0x9A,0xA3), o3(0xE8,0x9A,0xA9),
- o3(0xE8,0x9A,0xAA), o3(0xE8,0x9A,0x8B),
- o3(0xE8,0x9A,0x8C), o3(0xE8,0x9A,0xB6),
- o3(0xE8,0x9A,0xAF), o3(0xE8,0x9B,0x84),
- o3(0xE8,0x9B,0x86), o3(0xE8,0x9A,0xB0),
- o3(0xE8,0x9B,0x89), o3(0xE8,0xA0,0xA3),
- o3(0xE8,0x9A,0xAB), o3(0xE8,0x9B,0x94),
- o3(0xE8,0x9B,0x9E), o3(0xE8,0x9B,0xA9),
- o3(0xE8,0x9B,0xAC), o3(0xE8,0x9B,0x9F),
- o3(0xE8,0x9B,0x9B), o3(0xE8,0x9B,0xAF),
- o3(0xE8,0x9C,0x92), o3(0xE8,0x9C,0x86),
- o3(0xE8,0x9C,0x88), o3(0xE8,0x9C,0x80),
- o3(0xE8,0x9C,0x83), o3(0xE8,0x9B,0xBB),
- o3(0xE8,0x9C,0x91), o3(0xE8,0x9C,0x89),
- o3(0xE8,0x9C,0x8D), o3(0xE8,0x9B,0xB9),
- o3(0xE8,0x9C,0x8A), o3(0xE8,0x9C,0xB4),
- o3(0xE8,0x9C,0xBF), o3(0xE8,0x9C,0xB7),
- o3(0xE8,0x9C,0xBB), o3(0xE8,0x9C,0xA5),
- o3(0xE8,0x9C,0xA9), o3(0xE8,0x9C,0x9A),
- o3(0xE8,0x9D,0xA0), o3(0xE8,0x9D,0x9F),
- o3(0xE8,0x9D,0xB8), o3(0xE8,0x9D,0x8C),
- o3(0xE8,0x9D,0x8E), o3(0xE8,0x9D,0xB4),
- o3(0xE8,0x9D,0x97), o3(0xE8,0x9D,0xA8),
- o3(0xE8,0x9D,0xAE), o3(0xE8,0x9D,0x99),
- o3(0xE8,0x9D,0x93), o3(0xE8,0x9D,0xA3),
- o3(0xE8,0x9D,0xAA), o3(0xE8,0xA0,0x85),
- o3(0xE8,0x9E,0xA2), o3(0xE8,0x9E,0x9F),
- o3(0xE8,0x9E,0x82), o3(0xE8,0x9E,0xAF),
- o3(0xE8,0x9F,0x8B), o3(0xE8,0x9E,0xBD),
- o3(0xE8,0x9F,0x80), o3(0xE8,0x9F,0x90),
- o3(0xE9,0x9B,0x96), o3(0xE8,0x9E,0xAB),
- o3(0xE8,0x9F,0x84), o3(0xE8,0x9E,0xB3),
- o3(0xE8,0x9F,0x87), o3(0xE8,0x9F,0x86),
- o3(0xE8,0x9E,0xBB), o3(0xE8,0x9F,0xAF),
- o3(0xE8,0x9F,0xB2), o3(0xE8,0x9F,0xA0),
- o3(0xE8,0xA0,0x8F), o3(0xE8,0xA0,0x8D),
- o3(0xE8,0x9F,0xBE), o3(0xE8,0x9F,0xB6),
- o3(0xE8,0x9F,0xB7), o3(0xE8,0xA0,0x8E),
- o3(0xE8,0x9F,0x92), o3(0xE8,0xA0,0x91),
- o3(0xE8,0xA0,0x96), o3(0xE8,0xA0,0x95),
- o3(0xE8,0xA0,0xA2), o3(0xE8,0xA0,0xA1),
- o3(0xE8,0xA0,0xB1), o3(0xE8,0xA0,0xB6),
- o3(0xE8,0xA0,0xB9), o3(0xE8,0xA0,0xA7),
- o3(0xE8,0xA0,0xBB), o3(0xE8,0xA1,0x84),
- o3(0xE8,0xA1,0x82), o3(0xE8,0xA1,0x92),
- o3(0xE8,0xA1,0x99), o3(0xE8,0xA1,0x9E),
- o3(0xE8,0xA1,0xA2), o3(0xE8,0xA1,0xAB),
- o3(0xE8,0xA2,0x81), o3(0xE8,0xA1,0xBE),
- o3(0xE8,0xA2,0x9E), o3(0xE8,0xA1,0xB5),
- o3(0xE8,0xA1,0xBD), o3(0xE8,0xA2,0xB5),
- o3(0xE8,0xA1,0xB2), o3(0xE8,0xA2,0x82),
- o3(0xE8,0xA2,0x97), o3(0xE8,0xA2,0x92),
- o3(0xE8,0xA2,0xAE), o3(0xE8,0xA2,0x99),
- o3(0xE8,0xA2,0xA2), o3(0xE8,0xA2,0x8D),
- o3(0xE8,0xA2,0xA4), o3(0xE8,0xA2,0xB0),
- o3(0xE8,0xA2,0xBF), o3(0xE8,0xA2,0xB1),
- o3(0xE8,0xA3,0x83), o3(0xE8,0xA3,0x84),
- o3(0xE8,0xA3,0x94), o3(0xE8,0xA3,0x98),
- o3(0xE8,0xA3,0x99), o3(0xE8,0xA3,0x9D),
- o3(0xE8,0xA3,0xB9), o3(0xE8,0xA4,0x82),
- o3(0xE8,0xA3,0xBC), o3(0xE8,0xA3,0xB4),
- o3(0xE8,0xA3,0xA8), o3(0xE8,0xA3,0xB2),
- o3(0xE8,0xA4,0x84), o3(0xE8,0xA4,0x8C),
- o3(0xE8,0xA4,0x8A), o3(0xE8,0xA4,0x93),
- o3(0xE8,0xA5,0x83), o3(0xE8,0xA4,0x9E),
- o3(0xE8,0xA4,0xA5), o3(0xE8,0xA4,0xAA),
- o3(0xE8,0xA4,0xAB), o3(0xE8,0xA5,0x81),
- o3(0xE8,0xA5,0x84), o3(0xE8,0xA4,0xBB),
- o3(0xE8,0xA4,0xB6), o3(0xE8,0xA4,0xB8),
- o3(0xE8,0xA5,0x8C), o3(0xE8,0xA4,0x9D),
- o3(0xE8,0xA5,0xA0), o3(0xE8,0xA5,0x9E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E5 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E5_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E6_infos[189] = {
- o3(0xE8,0xA5,0xA6), o3(0xE8,0xA5,0xA4),
- o3(0xE8,0xA5,0xAD), o3(0xE8,0xA5,0xAA),
- o3(0xE8,0xA5,0xAF), o3(0xE8,0xA5,0xB4),
- o3(0xE8,0xA5,0xB7), o3(0xE8,0xA5,0xBE),
- o3(0xE8,0xA6,0x83), o3(0xE8,0xA6,0x88),
- o3(0xE8,0xA6,0x8A), o3(0xE8,0xA6,0x93),
- o3(0xE8,0xA6,0x98), o3(0xE8,0xA6,0xA1),
- o3(0xE8,0xA6,0xA9), o3(0xE8,0xA6,0xA6),
- o3(0xE8,0xA6,0xAC), o3(0xE8,0xA6,0xAF),
- o3(0xE8,0xA6,0xB2), o3(0xE8,0xA6,0xBA),
- o3(0xE8,0xA6,0xBD), o3(0xE8,0xA6,0xBF),
- o3(0xE8,0xA7,0x80), o3(0xE8,0xA7,0x9A),
- o3(0xE8,0xA7,0x9C), o3(0xE8,0xA7,0x9D),
- o3(0xE8,0xA7,0xA7), o3(0xE8,0xA7,0xB4),
- o3(0xE8,0xA7,0xB8), o3(0xE8,0xA8,0x83),
- o3(0xE8,0xA8,0x96), o3(0xE8,0xA8,0x90),
- o3(0xE8,0xA8,0x8C), o3(0xE8,0xA8,0x9B),
- o3(0xE8,0xA8,0x9D), o3(0xE8,0xA8,0xA5),
- o3(0xE8,0xA8,0xB6), o3(0xE8,0xA9,0x81),
- o3(0xE8,0xA9,0x9B), o3(0xE8,0xA9,0x92),
- o3(0xE8,0xA9,0x86), o3(0xE8,0xA9,0x88),
- o3(0xE8,0xA9,0xBC), o3(0xE8,0xA9,0xAD),
- o3(0xE8,0xA9,0xAC), o3(0xE8,0xA9,0xA2),
- o3(0xE8,0xAA,0x85), o3(0xE8,0xAA,0x82),
- o3(0xE8,0xAA,0x84), o3(0xE8,0xAA,0xA8),
- o3(0xE8,0xAA,0xA1), o3(0xE8,0xAA,0x91),
- o3(0xE8,0xAA,0xA5), o3(0xE8,0xAA,0xA6),
- o3(0xE8,0xAA,0x9A), o3(0xE8,0xAA,0xA3),
- o3(0xE8,0xAB,0x84), o3(0xE8,0xAB,0x8D),
- o3(0xE8,0xAB,0x82), o3(0xE8,0xAB,0x9A),
- o3(0xE8,0xAB,0xAB), o3(0xE8,0xAB,0xB3),
- o3(0xE8,0xAB,0xA7), o3(0xE8,0xAB,0xA4),
- o3(0xE8,0xAB,0xB1), o3(0xE8,0xAC,0x94),
- o3(0xE8,0xAB,0xA0), o3(0xE8,0xAB,0xA2),
- o3(0xE8,0xAB,0xB7), o3(0xE8,0xAB,0x9E),
- o3(0xE8,0xAB,0x9B), o3(0xE8,0xAC,0x8C),
- o3(0xE8,0xAC,0x87), o3(0xE8,0xAC,0x9A),
- o3(0xE8,0xAB,0xA1), o3(0xE8,0xAC,0x96),
- o3(0xE8,0xAC,0x90), o3(0xE8,0xAC,0x97),
- o3(0xE8,0xAC,0xA0), o3(0xE8,0xAC,0xB3),
- o3(0xE9,0x9E,0xAB), o3(0xE8,0xAC,0xA6),
- o3(0xE8,0xAC,0xAB), o3(0xE8,0xAC,0xBE),
- o3(0xE8,0xAC,0xA8), o3(0xE8,0xAD,0x81),
- o3(0xE8,0xAD,0x8C), o3(0xE8,0xAD,0x8F),
- o3(0xE8,0xAD,0x8E), o3(0xE8,0xAD,0x89),
- o3(0xE8,0xAD,0x96), o3(0xE8,0xAD,0x9B),
- o3(0xE8,0xAD,0x9A), o3(0xE8,0xAD,0xAB),
- o3(0xE8,0xAD,0x9F), o3(0xE8,0xAD,0xAC),
- o3(0xE8,0xAD,0xAF), o3(0xE8,0xAD,0xB4),
- o3(0xE8,0xAD,0xBD), o3(0xE8,0xAE,0x80),
- o3(0xE8,0xAE,0x8C), o3(0xE8,0xAE,0x8E),
- o3(0xE8,0xAE,0x92), o3(0xE8,0xAE,0x93),
- o3(0xE8,0xAE,0x96), o3(0xE8,0xAE,0x99),
- o3(0xE8,0xAE,0x9A), o3(0xE8,0xB0,0xBA),
- o3(0xE8,0xB1,0x81), o3(0xE8,0xB0,0xBF),
- o3(0xE8,0xB1,0x88), o3(0xE8,0xB1,0x8C),
- o3(0xE8,0xB1,0x8E), o3(0xE8,0xB1,0x90),
- o3(0xE8,0xB1,0x95), o3(0xE8,0xB1,0xA2),
- o3(0xE8,0xB1,0xAC), o3(0xE8,0xB1,0xB8),
- o3(0xE8,0xB1,0xBA), o3(0xE8,0xB2,0x82),
- o3(0xE8,0xB2,0x89), o3(0xE8,0xB2,0x85),
- o3(0xE8,0xB2,0x8A), o3(0xE8,0xB2,0x8D),
- o3(0xE8,0xB2,0x8E), o3(0xE8,0xB2,0x94),
- o3(0xE8,0xB1,0xBC), o3(0xE8,0xB2,0x98),
- o3(0xE6,0x88,0x9D), o3(0xE8,0xB2,0xAD),
- o3(0xE8,0xB2,0xAA), o3(0xE8,0xB2,0xBD),
- o3(0xE8,0xB2,0xB2), o3(0xE8,0xB2,0xB3),
- o3(0xE8,0xB2,0xAE), o3(0xE8,0xB2,0xB6),
- o3(0xE8,0xB3,0x88), o3(0xE8,0xB3,0x81),
- o3(0xE8,0xB3,0xA4), o3(0xE8,0xB3,0xA3),
- o3(0xE8,0xB3,0x9A), o3(0xE8,0xB3,0xBD),
- o3(0xE8,0xB3,0xBA), o3(0xE8,0xB3,0xBB),
- o3(0xE8,0xB4,0x84), o3(0xE8,0xB4,0x85),
- o3(0xE8,0xB4,0x8A), o3(0xE8,0xB4,0x87),
- o3(0xE8,0xB4,0x8F), o3(0xE8,0xB4,0x8D),
- o3(0xE8,0xB4,0x90), o3(0xE9,0xBD,0x8E),
- o3(0xE8,0xB4,0x93), o3(0xE8,0xB3,0x8D),
- o3(0xE8,0xB4,0x94), o3(0xE8,0xB4,0x96),
- o3(0xE8,0xB5,0xA7), o3(0xE8,0xB5,0xAD),
- o3(0xE8,0xB5,0xB1), o3(0xE8,0xB5,0xB3),
- o3(0xE8,0xB6,0x81), o3(0xE8,0xB6,0x99),
- o3(0xE8,0xB7,0x82), o3(0xE8,0xB6,0xBE),
- o3(0xE8,0xB6,0xBA), o3(0xE8,0xB7,0x8F),
- o3(0xE8,0xB7,0x9A), o3(0xE8,0xB7,0x96),
- o3(0xE8,0xB7,0x8C), o3(0xE8,0xB7,0x9B),
- o3(0xE8,0xB7,0x8B), o3(0xE8,0xB7,0xAA),
- o3(0xE8,0xB7,0xAB), o3(0xE8,0xB7,0x9F),
- o3(0xE8,0xB7,0xA3), o3(0xE8,0xB7,0xBC),
- o3(0xE8,0xB8,0x88), o3(0xE8,0xB8,0x89),
- o3(0xE8,0xB7,0xBF), o3(0xE8,0xB8,0x9D),
- o3(0xE8,0xB8,0x9E), o3(0xE8,0xB8,0x90),
- o3(0xE8,0xB8,0x9F), o3(0xE8,0xB9,0x82),
- o3(0xE8,0xB8,0xB5), o3(0xE8,0xB8,0xB0),
- o3(0xE8,0xB8,0xB4), o3(0xE8,0xB9,0x8A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E6 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E6_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E7_infos[189] = {
- o3(0xE8,0xB9,0x87), o3(0xE8,0xB9,0x89),
- o3(0xE8,0xB9,0x8C), o3(0xE8,0xB9,0x90),
- o3(0xE8,0xB9,0x88), o3(0xE8,0xB9,0x99),
- o3(0xE8,0xB9,0xA4), o3(0xE8,0xB9,0xA0),
- o3(0xE8,0xB8,0xAA), o3(0xE8,0xB9,0xA3),
- o3(0xE8,0xB9,0x95), o3(0xE8,0xB9,0xB6),
- o3(0xE8,0xB9,0xB2), o3(0xE8,0xB9,0xBC),
- o3(0xE8,0xBA,0x81), o3(0xE8,0xBA,0x87),
- o3(0xE8,0xBA,0x85), o3(0xE8,0xBA,0x84),
- o3(0xE8,0xBA,0x8B), o3(0xE8,0xBA,0x8A),
- o3(0xE8,0xBA,0x93), o3(0xE8,0xBA,0x91),
- o3(0xE8,0xBA,0x94), o3(0xE8,0xBA,0x99),
- o3(0xE8,0xBA,0xAA), o3(0xE8,0xBA,0xA1),
- o3(0xE8,0xBA,0xAC), o3(0xE8,0xBA,0xB0),
- o3(0xE8,0xBB,0x86), o3(0xE8,0xBA,0xB1),
- o3(0xE8,0xBA,0xBE), o3(0xE8,0xBB,0x85),
- o3(0xE8,0xBB,0x88), o3(0xE8,0xBB,0x8B),
- o3(0xE8,0xBB,0x9B), o3(0xE8,0xBB,0xA3),
- o3(0xE8,0xBB,0xBC), o3(0xE8,0xBB,0xBB),
- o3(0xE8,0xBB,0xAB), o3(0xE8,0xBB,0xBE),
- o3(0xE8,0xBC,0x8A), o3(0xE8,0xBC,0x85),
- o3(0xE8,0xBC,0x95), o3(0xE8,0xBC,0x92),
- o3(0xE8,0xBC,0x99), o3(0xE8,0xBC,0x93),
- o3(0xE8,0xBC,0x9C), o3(0xE8,0xBC,0x9F),
- o3(0xE8,0xBC,0x9B), o3(0xE8,0xBC,0x8C),
- o3(0xE8,0xBC,0xA6), o3(0xE8,0xBC,0xB3),
- o3(0xE8,0xBC,0xBB), o3(0xE8,0xBC,0xB9),
- o3(0xE8,0xBD,0x85), o3(0xE8,0xBD,0x82),
- o3(0xE8,0xBC,0xBE), o3(0xE8,0xBD,0x8C),
- o3(0xE8,0xBD,0x89), o3(0xE8,0xBD,0x86),
- o3(0xE8,0xBD,0x8E), o3(0xE8,0xBD,0x97),
- o3(0xE8,0xBD,0x9C), o3(0xE8,0xBD,0xA2),
- o3(0xE8,0xBD,0xA3), o3(0xE8,0xBD,0xA4),
- o3(0xE8,0xBE,0x9C), o3(0xE8,0xBE,0x9F),
- o3(0xE8,0xBE,0xA3), o3(0xE8,0xBE,0xAD),
- o3(0xE8,0xBE,0xAF), o3(0xE8,0xBE,0xB7),
- o3(0xE8,0xBF,0x9A), o3(0xE8,0xBF,0xA5),
- o3(0xE8,0xBF,0xA2), o3(0xE8,0xBF,0xAA),
- o3(0xE8,0xBF,0xAF), o3(0xE9,0x82,0x87),
- o3(0xE8,0xBF,0xB4), o3(0xE9,0x80,0x85),
- o3(0xE8,0xBF,0xB9), o3(0xE8,0xBF,0xBA),
- o3(0xE9,0x80,0x91), o3(0xE9,0x80,0x95),
- o3(0xE9,0x80,0xA1), o3(0xE9,0x80,0x8D),
- o3(0xE9,0x80,0x9E), o3(0xE9,0x80,0x96),
- o3(0xE9,0x80,0x8B), o3(0xE9,0x80,0xA7),
- o3(0xE9,0x80,0xB6), o3(0xE9,0x80,0xB5),
- o3(0xE9,0x80,0xB9), o3(0xE8,0xBF,0xB8),
- o3(0xE9,0x81,0x8F), o3(0xE9,0x81,0x90),
- o3(0xE9,0x81,0x91), o3(0xE9,0x81,0x92),
- o3(0xE9,0x80,0x8E), o3(0xE9,0x81,0x89),
- o3(0xE9,0x80,0xBE), o3(0xE9,0x81,0x96),
- o3(0xE9,0x81,0x98), o3(0xE9,0x81,0x9E),
- o3(0xE9,0x81,0xA8), o3(0xE9,0x81,0xAF),
- o3(0xE9,0x81,0xB6), o3(0xE9,0x9A,0xA8),
- o3(0xE9,0x81,0xB2), o3(0xE9,0x82,0x82),
- o3(0xE9,0x81,0xBD), o3(0xE9,0x82,0x81),
- o3(0xE9,0x82,0x80), o3(0xE9,0x82,0x8A),
- o3(0xE9,0x82,0x89), o3(0xE9,0x82,0x8F),
- o3(0xE9,0x82,0xA8), o3(0xE9,0x82,0xAF),
- o3(0xE9,0x82,0xB1), o3(0xE9,0x82,0xB5),
- o3(0xE9,0x83,0xA2), o3(0xE9,0x83,0xA4),
- o3(0xE6,0x89,0x88), o3(0xE9,0x83,0x9B),
- o3(0xE9,0x84,0x82), o3(0xE9,0x84,0x92),
- o3(0xE9,0x84,0x99), o3(0xE9,0x84,0xB2),
- o3(0xE9,0x84,0xB0), o3(0xE9,0x85,0x8A),
- o3(0xE9,0x85,0x96), o3(0xE9,0x85,0x98),
- o3(0xE9,0x85,0xA3), o3(0xE9,0x85,0xA5),
- o3(0xE9,0x85,0xA9), o3(0xE9,0x85,0xB3),
- o3(0xE9,0x85,0xB2), o3(0xE9,0x86,0x8B),
- o3(0xE9,0x86,0x89), o3(0xE9,0x86,0x82),
- o3(0xE9,0x86,0xA2), o3(0xE9,0x86,0xAB),
- o3(0xE9,0x86,0xAF), o3(0xE9,0x86,0xAA),
- o3(0xE9,0x86,0xB5), o3(0xE9,0x86,0xB4),
- o3(0xE9,0x86,0xBA), o3(0xE9,0x87,0x80),
- o3(0xE9,0x87,0x81), o3(0xE9,0x87,0x89),
- o3(0xE9,0x87,0x8B), o3(0xE9,0x87,0x90),
- o3(0xE9,0x87,0x96), o3(0xE9,0x87,0x9F),
- o3(0xE9,0x87,0xA1), o3(0xE9,0x87,0x9B),
- o3(0xE9,0x87,0xBC), o3(0xE9,0x87,0xB5),
- o3(0xE9,0x87,0xB6), o3(0xE9,0x88,0x9E),
- o3(0xE9,0x87,0xBF), o3(0xE9,0x88,0x94),
- o3(0xE9,0x88,0xAC), o3(0xE9,0x88,0x95),
- o3(0xE9,0x88,0x91), o3(0xE9,0x89,0x9E),
- o3(0xE9,0x89,0x97), o3(0xE9,0x89,0x85),
- o3(0xE9,0x89,0x89), o3(0xE9,0x89,0xA4),
- o3(0xE9,0x89,0x88), o3(0xE9,0x8A,0x95),
- o3(0xE9,0x88,0xBF), o3(0xE9,0x89,0x8B),
- o3(0xE9,0x89,0x90), o3(0xE9,0x8A,0x9C),
- o3(0xE9,0x8A,0x96), o3(0xE9,0x8A,0x93),
- o3(0xE9,0x8A,0x9B), o3(0xE9,0x89,0x9A),
- o3(0xE9,0x8B,0x8F), o3(0xE9,0x8A,0xB9),
- o3(0xE9,0x8A,0xB7), o3(0xE9,0x8B,0xA9),
- o3(0xE9,0x8C,0x8F), o3(0xE9,0x8B,0xBA),
- o3(0xE9,0x8D,0x84), o3(0xE9,0x8C,0xAE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E7 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E7_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E8_infos[189] = {
- o3(0xE9,0x8C,0x99), o3(0xE9,0x8C,0xA2),
- o3(0xE9,0x8C,0x9A), o3(0xE9,0x8C,0xA3),
- o3(0xE9,0x8C,0xBA), o3(0xE9,0x8C,0xB5),
- o3(0xE9,0x8C,0xBB), o3(0xE9,0x8D,0x9C),
- o3(0xE9,0x8D,0xA0), o3(0xE9,0x8D,0xBC),
- o3(0xE9,0x8D,0xAE), o3(0xE9,0x8D,0x96),
- o3(0xE9,0x8E,0xB0), o3(0xE9,0x8E,0xAC),
- o3(0xE9,0x8E,0xAD), o3(0xE9,0x8E,0x94),
- o3(0xE9,0x8E,0xB9), o3(0xE9,0x8F,0x96),
- o3(0xE9,0x8F,0x97), o3(0xE9,0x8F,0xA8),
- o3(0xE9,0x8F,0xA5), o3(0xE9,0x8F,0x98),
- o3(0xE9,0x8F,0x83), o3(0xE9,0x8F,0x9D),
- o3(0xE9,0x8F,0x90), o3(0xE9,0x8F,0x88),
- o3(0xE9,0x8F,0xA4), o3(0xE9,0x90,0x9A),
- o3(0xE9,0x90,0x94), o3(0xE9,0x90,0x93),
- o3(0xE9,0x90,0x83), o3(0xE9,0x90,0x87),
- o3(0xE9,0x90,0x90), o3(0xE9,0x90,0xB6),
- o3(0xE9,0x90,0xAB), o3(0xE9,0x90,0xB5),
- o3(0xE9,0x90,0xA1), o3(0xE9,0x90,0xBA),
- o3(0xE9,0x91,0x81), o3(0xE9,0x91,0x92),
- o3(0xE9,0x91,0x84), o3(0xE9,0x91,0x9B),
- o3(0xE9,0x91,0xA0), o3(0xE9,0x91,0xA2),
- o3(0xE9,0x91,0x9E), o3(0xE9,0x91,0xAA),
- o3(0xE9,0x88,0xA9), o3(0xE9,0x91,0xB0),
- o3(0xE9,0x91,0xB5), o3(0xE9,0x91,0xB7),
- o3(0xE9,0x91,0xBD), o3(0xE9,0x91,0x9A),
- o3(0xE9,0x91,0xBC), o3(0xE9,0x91,0xBE),
- o3(0xE9,0x92,0x81), o3(0xE9,0x91,0xBF),
- o3(0xE9,0x96,0x82), o3(0xE9,0x96,0x87),
- o3(0xE9,0x96,0x8A), o3(0xE9,0x96,0x94),
- o3(0xE9,0x96,0x96), o3(0xE9,0x96,0x98),
- o3(0xE9,0x96,0x99), o3(0xE9,0x96,0xA0),
- o3(0xE9,0x96,0xA8), o3(0xE9,0x96,0xA7),
- o3(0xE9,0x96,0xAD), o3(0xE9,0x96,0xBC),
- o3(0xE9,0x96,0xBB), o3(0xE9,0x96,0xB9),
- o3(0xE9,0x96,0xBE), o3(0xE9,0x97,0x8A),
- o3(0xE6,0xBF,0xB6), o3(0xE9,0x97,0x83),
- o3(0xE9,0x97,0x8D), o3(0xE9,0x97,0x8C),
- o3(0xE9,0x97,0x95), o3(0xE9,0x97,0x94),
- o3(0xE9,0x97,0x96), o3(0xE9,0x97,0x9C),
- o3(0xE9,0x97,0xA1), o3(0xE9,0x97,0xA5),
- o3(0xE9,0x97,0xA2), o3(0xE9,0x98,0xA1),
- o3(0xE9,0x98,0xA8), o3(0xE9,0x98,0xAE),
- o3(0xE9,0x98,0xAF), o3(0xE9,0x99,0x82),
- o3(0xE9,0x99,0x8C), o3(0xE9,0x99,0x8F),
- o3(0xE9,0x99,0x8B), o3(0xE9,0x99,0xB7),
- o3(0xE9,0x99,0x9C), o3(0xE9,0x99,0x9E),
- o3(0xE9,0x99,0x9D), o3(0xE9,0x99,0x9F),
- o3(0xE9,0x99,0xA6), o3(0xE9,0x99,0xB2),
- o3(0xE9,0x99,0xAC), o3(0xE9,0x9A,0x8D),
- o3(0xE9,0x9A,0x98), o3(0xE9,0x9A,0x95),
- o3(0xE9,0x9A,0x97), o3(0xE9,0x9A,0xAA),
- o3(0xE9,0x9A,0xA7), o3(0xE9,0x9A,0xB1),
- o3(0xE9,0x9A,0xB2), o3(0xE9,0x9A,0xB0),
- o3(0xE9,0x9A,0xB4), o3(0xE9,0x9A,0xB6),
- o3(0xE9,0x9A,0xB8), o3(0xE9,0x9A,0xB9),
- o3(0xE9,0x9B,0x8E), o3(0xE9,0x9B,0x8B),
- o3(0xE9,0x9B,0x89), o3(0xE9,0x9B,0x8D),
- o3(0xE8,0xA5,0x8D), o3(0xE9,0x9B,0x9C),
- o3(0xE9,0x9C,0x8D), o3(0xE9,0x9B,0x95),
- o3(0xE9,0x9B,0xB9), o3(0xE9,0x9C,0x84),
- o3(0xE9,0x9C,0x86), o3(0xE9,0x9C,0x88),
- o3(0xE9,0x9C,0x93), o3(0xE9,0x9C,0x8E),
- o3(0xE9,0x9C,0x91), o3(0xE9,0x9C,0x8F),
- o3(0xE9,0x9C,0x96), o3(0xE9,0x9C,0x99),
- o3(0xE9,0x9C,0xA4), o3(0xE9,0x9C,0xAA),
- o3(0xE9,0x9C,0xB0), o3(0xE9,0x9C,0xB9),
- o3(0xE9,0x9C,0xBD), o3(0xE9,0x9C,0xBE),
- o3(0xE9,0x9D,0x84), o3(0xE9,0x9D,0x86),
- o3(0xE9,0x9D,0x88), o3(0xE9,0x9D,0x82),
- o3(0xE9,0x9D,0x89), o3(0xE9,0x9D,0x9C),
- o3(0xE9,0x9D,0xA0), o3(0xE9,0x9D,0xA4),
- o3(0xE9,0x9D,0xA6), o3(0xE9,0x9D,0xA8),
- o3(0xE5,0x8B,0x92), o3(0xE9,0x9D,0xAB),
- o3(0xE9,0x9D,0xB1), o3(0xE9,0x9D,0xB9),
- o3(0xE9,0x9E,0x85), o3(0xE9,0x9D,0xBC),
- o3(0xE9,0x9E,0x81), o3(0xE9,0x9D,0xBA),
- o3(0xE9,0x9E,0x86), o3(0xE9,0x9E,0x8B),
- o3(0xE9,0x9E,0x8F), o3(0xE9,0x9E,0x90),
- o3(0xE9,0x9E,0x9C), o3(0xE9,0x9E,0xA8),
- o3(0xE9,0x9E,0xA6), o3(0xE9,0x9E,0xA3),
- o3(0xE9,0x9E,0xB3), o3(0xE9,0x9E,0xB4),
- o3(0xE9,0x9F,0x83), o3(0xE9,0x9F,0x86),
- o3(0xE9,0x9F,0x88), o3(0xE9,0x9F,0x8B),
- o3(0xE9,0x9F,0x9C), o3(0xE9,0x9F,0xAD),
- o3(0xE9,0xBD,0x8F), o3(0xE9,0x9F,0xB2),
- o3(0xE7,0xAB,0x9F), o3(0xE9,0x9F,0xB6),
- o3(0xE9,0x9F,0xB5), o3(0xE9,0xA0,0x8F),
- o3(0xE9,0xA0,0x8C), o3(0xE9,0xA0,0xB8),
- o3(0xE9,0xA0,0xA4), o3(0xE9,0xA0,0xA1),
- o3(0xE9,0xA0,0xB7), o3(0xE9,0xA0,0xBD),
- o3(0xE9,0xA1,0x86), o3(0xE9,0xA1,0x8F),
- o3(0xE9,0xA1,0x8B), o3(0xE9,0xA1,0xAB),
- o3(0xE9,0xA1,0xAF), o3(0xE9,0xA1,0xB0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E8 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E8_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_E9_infos[189] = {
- o3(0xE9,0xA1,0xB1), o3(0xE9,0xA1,0xB4),
- o3(0xE9,0xA1,0xB3), o3(0xE9,0xA2,0xAA),
- o3(0xE9,0xA2,0xAF), o3(0xE9,0xA2,0xB1),
- o3(0xE9,0xA2,0xB6), o3(0xE9,0xA3,0x84),
- o3(0xE9,0xA3,0x83), o3(0xE9,0xA3,0x86),
- o3(0xE9,0xA3,0xA9), o3(0xE9,0xA3,0xAB),
- o3(0xE9,0xA4,0x83), o3(0xE9,0xA4,0x89),
- o3(0xE9,0xA4,0x92), o3(0xE9,0xA4,0x94),
- o3(0xE9,0xA4,0x98), o3(0xE9,0xA4,0xA1),
- o3(0xE9,0xA4,0x9D), o3(0xE9,0xA4,0x9E),
- o3(0xE9,0xA4,0xA4), o3(0xE9,0xA4,0xA0),
- o3(0xE9,0xA4,0xAC), o3(0xE9,0xA4,0xAE),
- o3(0xE9,0xA4,0xBD), o3(0xE9,0xA4,0xBE),
- o3(0xE9,0xA5,0x82), o3(0xE9,0xA5,0x89),
- o3(0xE9,0xA5,0x85), o3(0xE9,0xA5,0x90),
- o3(0xE9,0xA5,0x8B), o3(0xE9,0xA5,0x91),
- o3(0xE9,0xA5,0x92), o3(0xE9,0xA5,0x8C),
- o3(0xE9,0xA5,0x95), o3(0xE9,0xA6,0x97),
- o3(0xE9,0xA6,0x98), o3(0xE9,0xA6,0xA5),
- o3(0xE9,0xA6,0xAD), o3(0xE9,0xA6,0xAE),
- o3(0xE9,0xA6,0xBC), o3(0xE9,0xA7,0x9F),
- o3(0xE9,0xA7,0x9B), o3(0xE9,0xA7,0x9D),
- o3(0xE9,0xA7,0x98), o3(0xE9,0xA7,0x91),
- o3(0xE9,0xA7,0xAD), o3(0xE9,0xA7,0xAE),
- o3(0xE9,0xA7,0xB1), o3(0xE9,0xA7,0xB2),
- o3(0xE9,0xA7,0xBB), o3(0xE9,0xA7,0xB8),
- o3(0xE9,0xA8,0x81), o3(0xE9,0xA8,0x8F),
- o3(0xE9,0xA8,0x85), o3(0xE9,0xA7,0xA2),
- o3(0xE9,0xA8,0x99), o3(0xE9,0xA8,0xAB),
- o3(0xE9,0xA8,0xB7), o3(0xE9,0xA9,0x85),
- o3(0xE9,0xA9,0x82), o3(0xE9,0xA9,0x80),
- o3(0xE9,0xA9,0x83), o3(0xE9,0xA8,0xBE),
- o3(0xE9,0xA9,0x95), o3(0xE9,0xA9,0x8D),
- o3(0xE9,0xA9,0x9B), o3(0xE9,0xA9,0x97),
- o3(0xE9,0xA9,0x9F), o3(0xE9,0xA9,0xA2),
- o3(0xE9,0xA9,0xA5), o3(0xE9,0xA9,0xA4),
- o3(0xE9,0xA9,0xA9), o3(0xE9,0xA9,0xAB),
- o3(0xE9,0xA9,0xAA), o3(0xE9,0xAA,0xAD),
- o3(0xE9,0xAA,0xB0), o3(0xE9,0xAA,0xBC),
- o3(0xE9,0xAB,0x80), o3(0xE9,0xAB,0x8F),
- o3(0xE9,0xAB,0x91), o3(0xE9,0xAB,0x93),
- o3(0xE9,0xAB,0x94), o3(0xE9,0xAB,0x9E),
- o3(0xE9,0xAB,0x9F), o3(0xE9,0xAB,0xA2),
- o3(0xE9,0xAB,0xA3), o3(0xE9,0xAB,0xA6),
- o3(0xE9,0xAB,0xAF), o3(0xE9,0xAB,0xAB),
- o3(0xE9,0xAB,0xAE), o3(0xE9,0xAB,0xB4),
- o3(0xE9,0xAB,0xB1), o3(0xE9,0xAB,0xB7),
- o3(0xE9,0xAB,0xBB), o3(0xE9,0xAC,0x86),
- o3(0xE9,0xAC,0x98), o3(0xE9,0xAC,0x9A),
- o3(0xE9,0xAC,0x9F), o3(0xE9,0xAC,0xA2),
- o3(0xE9,0xAC,0xA3), o3(0xE9,0xAC,0xA5),
- o3(0xE9,0xAC,0xA7), o3(0xE9,0xAC,0xA8),
- o3(0xE9,0xAC,0xA9), o3(0xE9,0xAC,0xAA),
- o3(0xE9,0xAC,0xAE), o3(0xE9,0xAC,0xAF),
- o3(0xE9,0xAC,0xB2), o3(0xE9,0xAD,0x84),
- o3(0xE9,0xAD,0x83), o3(0xE9,0xAD,0x8F),
- o3(0xE9,0xAD,0x8D), o3(0xE9,0xAD,0x8E),
- o3(0xE9,0xAD,0x91), o3(0xE9,0xAD,0x98),
- o3(0xE9,0xAD,0xB4), o3(0xE9,0xAE,0x93),
- o3(0xE9,0xAE,0x83), o3(0xE9,0xAE,0x91),
- o3(0xE9,0xAE,0x96), o3(0xE9,0xAE,0x97),
- o3(0xE9,0xAE,0x9F), o3(0xE9,0xAE,0xA0),
- o3(0xE9,0xAE,0xA8), o3(0xE9,0xAE,0xB4),
- o3(0xE9,0xAF,0x80), o3(0xE9,0xAF,0x8A),
- o3(0xE9,0xAE,0xB9), o3(0xE9,0xAF,0x86),
- o3(0xE9,0xAF,0x8F), o3(0xE9,0xAF,0x91),
- o3(0xE9,0xAF,0x92), o3(0xE9,0xAF,0xA3),
- o3(0xE9,0xAF,0xA2), o3(0xE9,0xAF,0xA4),
- o3(0xE9,0xAF,0x94), o3(0xE9,0xAF,0xA1),
- o3(0xE9,0xB0,0xBA), o3(0xE9,0xAF,0xB2),
- o3(0xE9,0xAF,0xB1), o3(0xE9,0xAF,0xB0),
- o3(0xE9,0xB0,0x95), o3(0xE9,0xB0,0x94),
- o3(0xE9,0xB0,0x89), o3(0xE9,0xB0,0x93),
- o3(0xE9,0xB0,0x8C), o3(0xE9,0xB0,0x86),
- o3(0xE9,0xB0,0x88), o3(0xE9,0xB0,0x92),
- o3(0xE9,0xB0,0x8A), o3(0xE9,0xB0,0x84),
- o3(0xE9,0xB0,0xAE), o3(0xE9,0xB0,0x9B),
- o3(0xE9,0xB0,0xA5), o3(0xE9,0xB0,0xA4),
- o3(0xE9,0xB0,0xA1), o3(0xE9,0xB0,0xB0),
- o3(0xE9,0xB1,0x87), o3(0xE9,0xB0,0xB2),
- o3(0xE9,0xB1,0x86), o3(0xE9,0xB0,0xBE),
- o3(0xE9,0xB1,0x9A), o3(0xE9,0xB1,0xA0),
- o3(0xE9,0xB1,0xA7), o3(0xE9,0xB1,0xB6),
- o3(0xE9,0xB1,0xB8), o3(0xE9,0xB3,0xA7),
- o3(0xE9,0xB3,0xAC), o3(0xE9,0xB3,0xB0),
- o3(0xE9,0xB4,0x89), o3(0xE9,0xB4,0x88),
- o3(0xE9,0xB3,0xAB), o3(0xE9,0xB4,0x83),
- o3(0xE9,0xB4,0x86), o3(0xE9,0xB4,0xAA),
- o3(0xE9,0xB4,0xA6), o3(0xE9,0xB6,0xAF),
- o3(0xE9,0xB4,0xA3), o3(0xE9,0xB4,0x9F),
- o3(0xE9,0xB5,0x84), o3(0xE9,0xB4,0x95),
- o3(0xE9,0xB4,0x92), o3(0xE9,0xB5,0x81),
- o3(0xE9,0xB4,0xBF), o3(0xE9,0xB4,0xBE),
- o3(0xE9,0xB5,0x86), o3(0xE9,0xB5,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_E9 = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_E9_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_EA_offsets[256] = {
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,100,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
- 100,100,100,100,100,100,100,100, 100,100,100,100,100,100,100,100,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_EA_infos[101] = {
- o3(0xE9,0xB5,0x9D), o3(0xE9,0xB5,0x9E),
- o3(0xE9,0xB5,0xA4), o3(0xE9,0xB5,0x91),
- o3(0xE9,0xB5,0x90), o3(0xE9,0xB5,0x99),
- o3(0xE9,0xB5,0xB2), o3(0xE9,0xB6,0x89),
- o3(0xE9,0xB6,0x87), o3(0xE9,0xB6,0xAB),
- o3(0xE9,0xB5,0xAF), o3(0xE9,0xB5,0xBA),
- o3(0xE9,0xB6,0x9A), o3(0xE9,0xB6,0xA4),
- o3(0xE9,0xB6,0xA9), o3(0xE9,0xB6,0xB2),
- o3(0xE9,0xB7,0x84), o3(0xE9,0xB7,0x81),
- o3(0xE9,0xB6,0xBB), o3(0xE9,0xB6,0xB8),
- o3(0xE9,0xB6,0xBA), o3(0xE9,0xB7,0x86),
- o3(0xE9,0xB7,0x8F), o3(0xE9,0xB7,0x82),
- o3(0xE9,0xB7,0x99), o3(0xE9,0xB7,0x93),
- o3(0xE9,0xB7,0xB8), o3(0xE9,0xB7,0xA6),
- o3(0xE9,0xB7,0xAD), o3(0xE9,0xB7,0xAF),
- o3(0xE9,0xB7,0xBD), o3(0xE9,0xB8,0x9A),
- o3(0xE9,0xB8,0x9B), o3(0xE9,0xB8,0x9E),
- o3(0xE9,0xB9,0xB5), o3(0xE9,0xB9,0xB9),
- o3(0xE9,0xB9,0xBD), o3(0xE9,0xBA,0x81),
- o3(0xE9,0xBA,0x88), o3(0xE9,0xBA,0x8B),
- o3(0xE9,0xBA,0x8C), o3(0xE9,0xBA,0x92),
- o3(0xE9,0xBA,0x95), o3(0xE9,0xBA,0x91),
- o3(0xE9,0xBA,0x9D), o3(0xE9,0xBA,0xA5),
- o3(0xE9,0xBA,0xA9), o3(0xE9,0xBA,0xB8),
- o3(0xE9,0xBA,0xAA), o3(0xE9,0xBA,0xAD),
- o3(0xE9,0x9D,0xA1), o3(0xE9,0xBB,0x8C),
- o3(0xE9,0xBB,0x8E), o3(0xE9,0xBB,0x8F),
- o3(0xE9,0xBB,0x90), o3(0xE9,0xBB,0x94),
- o3(0xE9,0xBB,0x9C), o3(0xE9,0xBB,0x9E),
- o3(0xE9,0xBB,0x9D), o3(0xE9,0xBB,0xA0),
- o3(0xE9,0xBB,0xA5), o3(0xE9,0xBB,0xA8),
- o3(0xE9,0xBB,0xAF), o3(0xE9,0xBB,0xB4),
- o3(0xE9,0xBB,0xB6), o3(0xE9,0xBB,0xB7),
- o3(0xE9,0xBB,0xB9), o3(0xE9,0xBB,0xBB),
- o3(0xE9,0xBB,0xBC), o3(0xE9,0xBB,0xBD),
- o3(0xE9,0xBC,0x87), o3(0xE9,0xBC,0x88),
- o3(0xE7,0x9A,0xB7), o3(0xE9,0xBC,0x95),
- o3(0xE9,0xBC,0xA1), o3(0xE9,0xBC,0xAC),
- o3(0xE9,0xBC,0xBE), o3(0xE9,0xBD,0x8A),
- o3(0xE9,0xBD,0x92), o3(0xE9,0xBD,0x94),
- o3(0xE9,0xBD,0xA3), o3(0xE9,0xBD,0x9F),
- o3(0xE9,0xBD,0xA0), o3(0xE9,0xBD,0xA1),
- o3(0xE9,0xBD,0xA6), o3(0xE9,0xBD,0xA7),
- o3(0xE9,0xBD,0xAC), o3(0xE9,0xBD,0xAA),
- o3(0xE9,0xBD,0xB7), o3(0xE9,0xBD,0xB2),
- o3(0xE9,0xBD,0xB6), o3(0xE9,0xBE,0x95),
- o3(0xE9,0xBE,0x9C), o3(0xE9,0xBE,0xA0),
- o3(0xE5,0xA0,0xAF), o3(0xE6,0xA7,0x87),
- o3(0xE9,0x81,0x99), o3(0xE7,0x91,0xA4),
- o3(0xE5,0x87,0x9C), o3(0xE7,0x86,0x99),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_EA = {
- from_SHIFT_JIS_EA_offsets,
- from_SHIFT_JIS_EA_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_FA_offsets[256] = {
- 173,173,173,173,173,173,173,173, 173,173,173,173,173,173,173,173,
- 173,173,173,173,173,173,173,173, 173,173,173,173,173,173,173,173,
- 173,173,173,173,173,173,173,173, 173,173,173,173,173,173,173,173,
- 173,173,173,173,173,173,173,173, 173,173,173,173,173,173,173,173,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,173,173,173,173,173,173,
- 173,173,173,173,173, 10, 11, 12, 173,173,173,173, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,173,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99,100,101,102,103, 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119, 120,121,122,123,124,125,126,127,
- 128,129,130,131,132,133,134,135, 136,137,138,139,140,141,142,143,
- 144,145,146,147,148,149,150,151, 152,153,154,155,156,157,158,159,
- 160,161,162,163,164,165,166,167, 168,169,170,171,172,173,173,173,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_FA_infos[174] = {
- o3(0xE2,0x85,0xB0), o3(0xE2,0x85,0xB1),
- o3(0xE2,0x85,0xB2), o3(0xE2,0x85,0xB3),
- o3(0xE2,0x85,0xB4), o3(0xE2,0x85,0xB5),
- o3(0xE2,0x85,0xB6), o3(0xE2,0x85,0xB7),
- o3(0xE2,0x85,0xB8), o3(0xE2,0x85,0xB9),
- o3(0xEF,0xBF,0xA4), o3(0xEF,0xBC,0x87),
- o3(0xEF,0xBC,0x82), o3(0xE7,0xBA,0x8A),
- o3(0xE8,0xA4,0x9C), o3(0xE9,0x8D,0x88),
- o3(0xE9,0x8A,0x88), o3(0xE8,0x93,0x9C),
- o3(0xE4,0xBF,0x89), o3(0xE7,0x82,0xBB),
- o3(0xE6,0x98,0xB1), o3(0xE6,0xA3,0x88),
- o3(0xE9,0x8B,0xB9), o3(0xE6,0x9B,0xBB),
- o3(0xE5,0xBD,0x85), o3(0xE4,0xB8,0xA8),
- o3(0xE4,0xBB,0xA1), o3(0xE4,0xBB,0xBC),
- o3(0xE4,0xBC,0x80), o3(0xE4,0xBC,0x83),
- o3(0xE4,0xBC,0xB9), o3(0xE4,0xBD,0x96),
- o3(0xE4,0xBE,0x92), o3(0xE4,0xBE,0x8A),
- o3(0xE4,0xBE,0x9A), o3(0xE4,0xBE,0x94),
- o3(0xE4,0xBF,0x8D), o3(0xE5,0x81,0x80),
- o3(0xE5,0x80,0xA2), o3(0xE4,0xBF,0xBF),
- o3(0xE5,0x80,0x9E), o3(0xE5,0x81,0x86),
- o3(0xE5,0x81,0xB0), o3(0xE5,0x81,0x82),
- o3(0xE5,0x82,0x94), o3(0xE5,0x83,0xB4),
- o3(0xE5,0x83,0x98), o3(0xE5,0x85,0x8A),
- o3(0xE5,0x85,0xA4), o3(0xE5,0x86,0x9D),
- o3(0xE5,0x86,0xBE), o3(0xE5,0x87,0xAC),
- o3(0xE5,0x88,0x95), o3(0xE5,0x8A,0x9C),
- o3(0xE5,0x8A,0xA6), o3(0xE5,0x8B,0x80),
- o3(0xE5,0x8B,0x9B), o3(0xE5,0x8C,0x80),
- o3(0xE5,0x8C,0x87), o3(0xE5,0x8C,0xA4),
- o3(0xE5,0x8D,0xB2), o3(0xE5,0x8E,0x93),
- o3(0xE5,0x8E,0xB2), o3(0xE5,0x8F,0x9D),
- o3(0xEF,0xA8,0x8E), o3(0xE5,0x92,0x9C),
- o3(0xE5,0x92,0x8A), o3(0xE5,0x92,0xA9),
- o3(0xE5,0x93,0xBF), o3(0xE5,0x96,0x86),
- o3(0xE5,0x9D,0x99), o3(0xE5,0x9D,0xA5),
- o3(0xE5,0x9E,0xAC), o3(0xE5,0x9F,0x88),
- o3(0xE5,0x9F,0x87), o3(0xEF,0xA8,0x8F),
- o3(0xEF,0xA8,0x90), o3(0xE5,0xA2,0x9E),
- o3(0xE5,0xA2,0xB2), o3(0xE5,0xA4,0x8B),
- o3(0xE5,0xA5,0x93), o3(0xE5,0xA5,0x9B),
- o3(0xE5,0xA5,0x9D), o3(0xE5,0xA5,0xA3),
- o3(0xE5,0xA6,0xA4), o3(0xE5,0xA6,0xBA),
- o3(0xE5,0xAD,0x96), o3(0xE5,0xAF,0x80),
- o3(0xE7,0x94,0xAF), o3(0xE5,0xAF,0x98),
- o3(0xE5,0xAF,0xAC), o3(0xE5,0xB0,0x9E),
- o3(0xE5,0xB2,0xA6), o3(0xE5,0xB2,0xBA),
- o3(0xE5,0xB3,0xB5), o3(0xE5,0xB4,0xA7),
- o3(0xE5,0xB5,0x93), o3(0xEF,0xA8,0x91),
- o3(0xE5,0xB5,0x82), o3(0xE5,0xB5,0xAD),
- o3(0xE5,0xB6,0xB8), o3(0xE5,0xB6,0xB9),
- o3(0xE5,0xB7,0x90), o3(0xE5,0xBC,0xA1),
- o3(0xE5,0xBC,0xB4), o3(0xE5,0xBD,0xA7),
- o3(0xE5,0xBE,0xB7), o3(0xE5,0xBF,0x9E),
- o3(0xE6,0x81,0x9D), o3(0xE6,0x82,0x85),
- o3(0xE6,0x82,0x8A), o3(0xE6,0x83,0x9E),
- o3(0xE6,0x83,0x95), o3(0xE6,0x84,0xA0),
- o3(0xE6,0x83,0xB2), o3(0xE6,0x84,0x91),
- o3(0xE6,0x84,0xB7), o3(0xE6,0x84,0xB0),
- o3(0xE6,0x86,0x98), o3(0xE6,0x88,0x93),
- o3(0xE6,0x8A,0xA6), o3(0xE6,0x8F,0xB5),
- o3(0xE6,0x91,0xA0), o3(0xE6,0x92,0x9D),
- o3(0xE6,0x93,0x8E), o3(0xE6,0x95,0x8E),
- o3(0xE6,0x98,0x80), o3(0xE6,0x98,0x95),
- o3(0xE6,0x98,0xBB), o3(0xE6,0x98,0x89),
- o3(0xE6,0x98,0xAE), o3(0xE6,0x98,0x9E),
- o3(0xE6,0x98,0xA4), o3(0xE6,0x99,0xA5),
- o3(0xE6,0x99,0x97), o3(0xE6,0x99,0x99),
- o3(0xEF,0xA8,0x92), o3(0xE6,0x99,0xB3),
- o3(0xE6,0x9A,0x99), o3(0xE6,0x9A,0xA0),
- o3(0xE6,0x9A,0xB2), o3(0xE6,0x9A,0xBF),
- o3(0xE6,0x9B,0xBA), o3(0xE6,0x9C,0x8E),
- o3(0xEF,0xA4,0xA9), o3(0xE6,0x9D,0xA6),
- o3(0xE6,0x9E,0xBB), o3(0xE6,0xA1,0x92),
- o3(0xE6,0x9F,0x80), o3(0xE6,0xA0,0x81),
- o3(0xE6,0xA1,0x84), o3(0xE6,0xA3,0x8F),
- o3(0xEF,0xA8,0x93), o3(0xE6,0xA5,0xA8),
- o3(0xEF,0xA8,0x94), o3(0xE6,0xA6,0x98),
- o3(0xE6,0xA7,0xA2), o3(0xE6,0xA8,0xB0),
- o3(0xE6,0xA9,0xAB), o3(0xE6,0xA9,0x86),
- o3(0xE6,0xA9,0xB3), o3(0xE6,0xA9,0xBE),
- o3(0xE6,0xAB,0xA2), o3(0xE6,0xAB,0xA4),
- o3(0xE6,0xAF,0x96), o3(0xE6,0xB0,0xBF),
- o3(0xE6,0xB1,0x9C), o3(0xE6,0xB2,0x86),
- o3(0xE6,0xB1,0xAF), o3(0xE6,0xB3,0x9A),
- o3(0xE6,0xB4,0x84), o3(0xE6,0xB6,0x87),
- o3(0xE6,0xB5,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_FA = {
- from_SHIFT_JIS_FA_offsets,
- from_SHIFT_JIS_FA_infos
-};
-
-static const struct byte_lookup* const
-from_SHIFT_JIS_FB_infos[189] = {
- o3(0xE6,0xB6,0x96), o3(0xE6,0xB6,0xAC),
- o3(0xE6,0xB7,0x8F), o3(0xE6,0xB7,0xB8),
- o3(0xE6,0xB7,0xB2), o3(0xE6,0xB7,0xBC),
- o3(0xE6,0xB8,0xB9), o3(0xE6,0xB9,0x9C),
- o3(0xE6,0xB8,0xA7), o3(0xE6,0xB8,0xBC),
- o3(0xE6,0xBA,0xBF), o3(0xE6,0xBE,0x88),
- o3(0xE6,0xBE,0xB5), o3(0xE6,0xBF,0xB5),
- o3(0xE7,0x80,0x85), o3(0xE7,0x80,0x87),
- o3(0xE7,0x80,0xA8), o3(0xE7,0x82,0x85),
- o3(0xE7,0x82,0xAB), o3(0xE7,0x84,0x8F),
- o3(0xE7,0x84,0x84), o3(0xE7,0x85,0x9C),
- o3(0xE7,0x85,0x86), o3(0xE7,0x85,0x87),
- o3(0xEF,0xA8,0x95), o3(0xE7,0x87,0x81),
- o3(0xE7,0x87,0xBE), o3(0xE7,0x8A,0xB1),
- o3(0xE7,0x8A,0xBE), o3(0xE7,0x8C,0xA4),
- o3(0xEF,0xA8,0x96), o3(0xE7,0x8D,0xB7),
- o3(0xE7,0x8E,0xBD), o3(0xE7,0x8F,0x89),
- o3(0xE7,0x8F,0x96), o3(0xE7,0x8F,0xA3),
- o3(0xE7,0x8F,0x92), o3(0xE7,0x90,0x87),
- o3(0xE7,0x8F,0xB5), o3(0xE7,0x90,0xA6),
- o3(0xE7,0x90,0xAA), o3(0xE7,0x90,0xA9),
- o3(0xE7,0x90,0xAE), o3(0xE7,0x91,0xA2),
- o3(0xE7,0x92,0x89), o3(0xE7,0x92,0x9F),
- o3(0xE7,0x94,0x81), o3(0xE7,0x95,0xAF),
- o3(0xE7,0x9A,0x82), o3(0xE7,0x9A,0x9C),
- o3(0xE7,0x9A,0x9E), o3(0xE7,0x9A,0x9B),
- o3(0xE7,0x9A,0xA6), o3(0xEF,0xA8,0x97),
- o3(0xE7,0x9D,0x86), o3(0xE5,0x8A,0xAF),
- o3(0xE7,0xA0,0xA1), o3(0xE7,0xA1,0x8E),
- o3(0xE7,0xA1,0xA4), o3(0xE7,0xA1,0xBA),
- o3(0xE7,0xA4,0xB0), o3(0xEF,0xA8,0x98),
- o3(0xEF,0xA8,0x99), o3(0xEF,0xA8,0x9A),
- o3(0xE7,0xA6,0x94), o3(0xEF,0xA8,0x9B),
- o3(0xE7,0xA6,0x9B), o3(0xE7,0xAB,0x91),
- o3(0xE7,0xAB,0xA7), o3(0xEF,0xA8,0x9C),
- o3(0xE7,0xAB,0xAB), o3(0xE7,0xAE,0x9E),
- o3(0xEF,0xA8,0x9D), o3(0xE7,0xB5,0x88),
- o3(0xE7,0xB5,0x9C), o3(0xE7,0xB6,0xB7),
- o3(0xE7,0xB6,0xA0), o3(0xE7,0xB7,0x96),
- o3(0xE7,0xB9,0x92), o3(0xE7,0xBD,0x87),
- o3(0xE7,0xBE,0xA1), o3(0xEF,0xA8,0x9E),
- o3(0xE8,0x8C,0x81), o3(0xE8,0x8D,0xA2),
- o3(0xE8,0x8D,0xBF), o3(0xE8,0x8F,0x87),
- o3(0xE8,0x8F,0xB6), o3(0xE8,0x91,0x88),
- o3(0xE8,0x92,0xB4), o3(0xE8,0x95,0x93),
- o3(0xE8,0x95,0x99), o3(0xE8,0x95,0xAB),
- o3(0xEF,0xA8,0x9F), o3(0xE8,0x96,0xB0),
- o3(0xEF,0xA8,0xA0), o3(0xEF,0xA8,0xA1),
- o3(0xE8,0xA0,0x87), o3(0xE8,0xA3,0xB5),
- o3(0xE8,0xA8,0x92), o3(0xE8,0xA8,0xB7),
- o3(0xE8,0xA9,0xB9), o3(0xE8,0xAA,0xA7),
- o3(0xE8,0xAA,0xBE), o3(0xE8,0xAB,0x9F),
- o3(0xEF,0xA8,0xA2), o3(0xE8,0xAB,0xB6),
- o3(0xE8,0xAD,0x93), o3(0xE8,0xAD,0xBF),
- o3(0xE8,0xB3,0xB0), o3(0xE8,0xB3,0xB4),
- o3(0xE8,0xB4,0x92), o3(0xE8,0xB5,0xB6),
- o3(0xEF,0xA8,0xA3), o3(0xE8,0xBB,0x8F),
- o3(0xEF,0xA8,0xA4), o3(0xEF,0xA8,0xA5),
- o3(0xE9,0x81,0xA7), o3(0xE9,0x83,0x9E),
- o3(0xEF,0xA8,0xA6), o3(0xE9,0x84,0x95),
- o3(0xE9,0x84,0xA7), o3(0xE9,0x87,0x9A),
- o3(0xE9,0x87,0x97), o3(0xE9,0x87,0x9E),
- o3(0xE9,0x87,0xAD), o3(0xE9,0x87,0xAE),
- o3(0xE9,0x87,0xA4), o3(0xE9,0x87,0xA5),
- o3(0xE9,0x88,0x86), o3(0xE9,0x88,0x90),
- o3(0xE9,0x88,0x8A), o3(0xE9,0x88,0xBA),
- o3(0xE9,0x89,0x80), o3(0xE9,0x88,0xBC),
- o3(0xE9,0x89,0x8E), o3(0xE9,0x89,0x99),
- o3(0xE9,0x89,0x91), o3(0xE9,0x88,0xB9),
- o3(0xE9,0x89,0xA7), o3(0xE9,0x8A,0xA7),
- o3(0xE9,0x89,0xB7), o3(0xE9,0x89,0xB8),
- o3(0xE9,0x8B,0xA7), o3(0xE9,0x8B,0x97),
- o3(0xE9,0x8B,0x99), o3(0xE9,0x8B,0x90),
- o3(0xEF,0xA8,0xA7), o3(0xE9,0x8B,0x95),
- o3(0xE9,0x8B,0xA0), o3(0xE9,0x8B,0x93),
- o3(0xE9,0x8C,0xA5), o3(0xE9,0x8C,0xA1),
- o3(0xE9,0x8B,0xBB), o3(0xEF,0xA8,0xA8),
- o3(0xE9,0x8C,0x9E), o3(0xE9,0x8B,0xBF),
- o3(0xE9,0x8C,0x9D), o3(0xE9,0x8C,0x82),
- o3(0xE9,0x8D,0xB0), o3(0xE9,0x8D,0x97),
- o3(0xE9,0x8E,0xA4), o3(0xE9,0x8F,0x86),
- o3(0xE9,0x8F,0x9E), o3(0xE9,0x8F,0xB8),
- o3(0xE9,0x90,0xB1), o3(0xE9,0x91,0x85),
- o3(0xE9,0x91,0x88), o3(0xE9,0x96,0x92),
- o3(0xEF,0xA7,0x9C), o3(0xEF,0xA8,0xA9),
- o3(0xE9,0x9A,0x9D), o3(0xE9,0x9A,0xAF),
- o3(0xE9,0x9C,0xB3), o3(0xE9,0x9C,0xBB),
- o3(0xE9,0x9D,0x83), o3(0xE9,0x9D,0x8D),
- o3(0xE9,0x9D,0x8F), o3(0xE9,0x9D,0x91),
- o3(0xE9,0x9D,0x95), o3(0xE9,0xA1,0x97),
- o3(0xE9,0xA1,0xA5), o3(0xEF,0xA8,0xAA),
- o3(0xEF,0xA8,0xAB), o3(0xE9,0xA4,0xA7),
- o3(0xEF,0xA8,0xAC), o3(0xE9,0xA6,0x9E),
- o3(0xE9,0xA9,0x8E), o3(0xE9,0xAB,0x99),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_FB = {
- from_SHIFT_JIS_89_offsets,
- from_SHIFT_JIS_FB_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_FC_offsets[256] = {
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_FC_infos[13] = {
- o3(0xE9,0xAB,0x9C), o3(0xE9,0xAD,0xB5),
- o3(0xE9,0xAD,0xB2), o3(0xE9,0xAE,0x8F),
- o3(0xE9,0xAE,0xB1), o3(0xE9,0xAE,0xBB),
- o3(0xE9,0xB0,0x80), o3(0xE9,0xB5,0xB0),
- o3(0xE9,0xB5,0xAB), o3(0xEF,0xA8,0xAD),
- o3(0xE9,0xB8,0x99), o3(0xE9,0xBB,0x91),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS_FC = {
- from_SHIFT_JIS_FC_offsets,
- from_SHIFT_JIS_FC_infos
-};
-
-static const unsigned char
-from_SHIFT_JIS_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 107, 1, 2, 3, 4,107,107, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 107, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 99,100, 101,102,103,107,107,107,107,107,
- 107,107,107,107,107,107,107,107, 107,107,104,105,106,107,107,107,
-};
-static const struct byte_lookup* const
-from_SHIFT_JIS_infos[108] = {
- NOMAP, &from_SHIFT_JIS_81,
- &from_SHIFT_JIS_82, &from_SHIFT_JIS_83,
- &from_SHIFT_JIS_84, &from_SHIFT_JIS_87,
- &from_SHIFT_JIS_88, &from_SHIFT_JIS_89,
- &from_SHIFT_JIS_8A, &from_SHIFT_JIS_8B,
- &from_SHIFT_JIS_8C, &from_SHIFT_JIS_8D,
- &from_SHIFT_JIS_8E, &from_SHIFT_JIS_8F,
- &from_SHIFT_JIS_90, &from_SHIFT_JIS_91,
- &from_SHIFT_JIS_92, &from_SHIFT_JIS_93,
- &from_SHIFT_JIS_94, &from_SHIFT_JIS_95,
- &from_SHIFT_JIS_96, &from_SHIFT_JIS_97,
- &from_SHIFT_JIS_98, &from_SHIFT_JIS_99,
- &from_SHIFT_JIS_9A, &from_SHIFT_JIS_9B,
- &from_SHIFT_JIS_9C, &from_SHIFT_JIS_9D,
- &from_SHIFT_JIS_9E, &from_SHIFT_JIS_9F,
- o3(0xEF,0xBD,0xA1), o3(0xEF,0xBD,0xA2),
- o3(0xEF,0xBD,0xA3), o3(0xEF,0xBD,0xA4),
- o3(0xEF,0xBD,0xA5), o3(0xEF,0xBD,0xA6),
- o3(0xEF,0xBD,0xA7), o3(0xEF,0xBD,0xA8),
- o3(0xEF,0xBD,0xA9), o3(0xEF,0xBD,0xAA),
- o3(0xEF,0xBD,0xAB), o3(0xEF,0xBD,0xAC),
- o3(0xEF,0xBD,0xAD), o3(0xEF,0xBD,0xAE),
- o3(0xEF,0xBD,0xAF), o3(0xEF,0xBD,0xB0),
- o3(0xEF,0xBD,0xB1), o3(0xEF,0xBD,0xB2),
- o3(0xEF,0xBD,0xB3), o3(0xEF,0xBD,0xB4),
- o3(0xEF,0xBD,0xB5), o3(0xEF,0xBD,0xB6),
- o3(0xEF,0xBD,0xB7), o3(0xEF,0xBD,0xB8),
- o3(0xEF,0xBD,0xB9), o3(0xEF,0xBD,0xBA),
- o3(0xEF,0xBD,0xBB), o3(0xEF,0xBD,0xBC),
- o3(0xEF,0xBD,0xBD), o3(0xEF,0xBD,0xBE),
- o3(0xEF,0xBD,0xBF), o3(0xEF,0xBE,0x80),
- o3(0xEF,0xBE,0x81), o3(0xEF,0xBE,0x82),
- o3(0xEF,0xBE,0x83), o3(0xEF,0xBE,0x84),
- o3(0xEF,0xBE,0x85), o3(0xEF,0xBE,0x86),
- o3(0xEF,0xBE,0x87), o3(0xEF,0xBE,0x88),
- o3(0xEF,0xBE,0x89), o3(0xEF,0xBE,0x8A),
- o3(0xEF,0xBE,0x8B), o3(0xEF,0xBE,0x8C),
- o3(0xEF,0xBE,0x8D), o3(0xEF,0xBE,0x8E),
- o3(0xEF,0xBE,0x8F), o3(0xEF,0xBE,0x90),
- o3(0xEF,0xBE,0x91), o3(0xEF,0xBE,0x92),
- o3(0xEF,0xBE,0x93), o3(0xEF,0xBE,0x94),
- o3(0xEF,0xBE,0x95), o3(0xEF,0xBE,0x96),
- o3(0xEF,0xBE,0x97), o3(0xEF,0xBE,0x98),
- o3(0xEF,0xBE,0x99), o3(0xEF,0xBE,0x9A),
- o3(0xEF,0xBE,0x9B), o3(0xEF,0xBE,0x9C),
- o3(0xEF,0xBE,0x9D), o3(0xEF,0xBE,0x9E),
- o3(0xEF,0xBE,0x9F), &from_SHIFT_JIS_E0,
- &from_SHIFT_JIS_E1, &from_SHIFT_JIS_E2,
- &from_SHIFT_JIS_E3, &from_SHIFT_JIS_E4,
- &from_SHIFT_JIS_E5, &from_SHIFT_JIS_E6,
- &from_SHIFT_JIS_E7, &from_SHIFT_JIS_E8,
- &from_SHIFT_JIS_E9, &from_SHIFT_JIS_EA,
- &from_SHIFT_JIS_FA, &from_SHIFT_JIS_FB,
- &from_SHIFT_JIS_FC, UNDEF,
-};
-static const BYTE_LOOKUP
-from_SHIFT_JIS = {
- from_SHIFT_JIS_offsets,
- from_SHIFT_JIS_infos
-};
-static rb_transcoder
-rb_from_SHIFT_JIS = {
- "SHIFT_JIS", "UTF-8", &from_SHIFT_JIS, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_SHIFT_JIS_C2_offsets[64] = {
- /* used from to_SHIFT_JIS_C2 */
- /* used from to_EUC_JP_C2 */
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 0, 1, 13, 2, 3, 4, 5, 13, 13, 13, 6, 13, 13, 7,
- 8, 9, 13, 13, 10, 13, 11, 13, 12, 13, 13, 13, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_C2_infos[14] = {
- o2(0x81,0x91), o2(0x81,0x92), o2(0x81,0x8F), o2(0xFA,0x55),
- o2(0x81,0x98), o2(0x81,0x4E), o2(0x81,0xCA), o2(0x81,0x50),
- o2(0x81,0x8B), o2(0x81,0x7D), o2(0x81,0x4C), o2(0x81,0xF7),
- o2(0x81,0x43), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_C2 = {
- to_SHIFT_JIS_C2_offsets,
- to_SHIFT_JIS_C2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_C3_offsets[64] = {
- /* used from to_SHIFT_JIS_C3 */
- /* used from to_EUC_JP_C3 */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_C3_infos[3] = {
- o2(0x81,0x7E), o2(0x81,0x80), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_C3 = {
- to_SHIFT_JIS_C3_offsets,
- to_SHIFT_JIS_C3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_CE_offsets[64] = {
- /* used from to_SHIFT_JIS_CE */
- /* used from to_EUC_JP_CE */
- 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 39, 17, 18, 19, 20, 21, 22, 23, 39, 39, 39, 39, 39, 39,
- 39, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_CE_infos[40] = {
- o2(0x83,0x9F), o2(0x83,0xA0), o2(0x83,0xA1), o2(0x83,0xA2),
- o2(0x83,0xA3), o2(0x83,0xA4), o2(0x83,0xA5), o2(0x83,0xA6),
- o2(0x83,0xA7), o2(0x83,0xA8), o2(0x83,0xA9), o2(0x83,0xAA),
- o2(0x83,0xAB), o2(0x83,0xAC), o2(0x83,0xAD), o2(0x83,0xAE),
- o2(0x83,0xAF), o2(0x83,0xB0), o2(0x83,0xB1), o2(0x83,0xB2),
- o2(0x83,0xB3), o2(0x83,0xB4), o2(0x83,0xB5), o2(0x83,0xB6),
- o2(0x83,0xBF), o2(0x83,0xC0), o2(0x83,0xC1), o2(0x83,0xC2),
- o2(0x83,0xC3), o2(0x83,0xC4), o2(0x83,0xC5), o2(0x83,0xC6),
- o2(0x83,0xC7), o2(0x83,0xC8), o2(0x83,0xC9), o2(0x83,0xCA),
- o2(0x83,0xCB), o2(0x83,0xCC), o2(0x83,0xCD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_CE = {
- to_SHIFT_JIS_CE_offsets,
- to_SHIFT_JIS_CE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_CF_offsets[64] = {
- /* used from to_SHIFT_JIS_CF */
- /* used from to_EUC_JP_CF */
- 0, 1, 9, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_CF_infos[10] = {
- o2(0x83,0xCE), o2(0x83,0xCF), o2(0x83,0xD0), o2(0x83,0xD1),
- o2(0x83,0xD2), o2(0x83,0xD3), o2(0x83,0xD4), o2(0x83,0xD5),
- o2(0x83,0xD6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_CF = {
- to_SHIFT_JIS_CF_offsets,
- to_SHIFT_JIS_CF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_D0_offsets[64] = {
- /* used from to_SHIFT_JIS_D0 */
- /* used from to_EUC_JP_D0 */
- 49, 0, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_D0_infos[50] = {
- o2(0x84,0x46), o2(0x84,0x40), o2(0x84,0x41), o2(0x84,0x42),
- o2(0x84,0x43), o2(0x84,0x44), o2(0x84,0x45), o2(0x84,0x47),
- o2(0x84,0x48), o2(0x84,0x49), o2(0x84,0x4A), o2(0x84,0x4B),
- o2(0x84,0x4C), o2(0x84,0x4D), o2(0x84,0x4E), o2(0x84,0x4F),
- o2(0x84,0x50), o2(0x84,0x51), o2(0x84,0x52), o2(0x84,0x53),
- o2(0x84,0x54), o2(0x84,0x55), o2(0x84,0x56), o2(0x84,0x57),
- o2(0x84,0x58), o2(0x84,0x59), o2(0x84,0x5A), o2(0x84,0x5B),
- o2(0x84,0x5C), o2(0x84,0x5D), o2(0x84,0x5E), o2(0x84,0x5F),
- o2(0x84,0x60), o2(0x84,0x70), o2(0x84,0x71), o2(0x84,0x72),
- o2(0x84,0x73), o2(0x84,0x74), o2(0x84,0x75), o2(0x84,0x77),
- o2(0x84,0x78), o2(0x84,0x79), o2(0x84,0x7A), o2(0x84,0x7B),
- o2(0x84,0x7C), o2(0x84,0x7D), o2(0x84,0x7E), o2(0x84,0x80),
- o2(0x84,0x81), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_D0 = {
- to_SHIFT_JIS_D0_offsets,
- to_SHIFT_JIS_D0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_D1_offsets[64] = {
- /* used from to_SHIFT_JIS_D1 */
- /* used from to_EUC_JP_D1 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_D1_infos[18] = {
- o2(0x84,0x82), o2(0x84,0x83), o2(0x84,0x84), o2(0x84,0x85),
- o2(0x84,0x86), o2(0x84,0x87), o2(0x84,0x88), o2(0x84,0x89),
- o2(0x84,0x8A), o2(0x84,0x8B), o2(0x84,0x8C), o2(0x84,0x8D),
- o2(0x84,0x8E), o2(0x84,0x8F), o2(0x84,0x90), o2(0x84,0x91),
- o2(0x84,0x76), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_D1 = {
- to_SHIFT_JIS_D1_offsets,
- to_SHIFT_JIS_D1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_80 */
- /* used from to_EUC_JP_E2_80 */
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 0, 15, 15, 15, 1, 15, 2, 15, 3, 4, 15, 15, 5, 6, 15, 15,
- 7, 8, 15, 15, 15, 9, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 11, 15, 12, 13, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_80_infos[16] = {
- o2(0x81,0x5D), o2(0x81,0x5C), o2(0x81,0x61), o2(0x81,0x65),
- o2(0x81,0x66), o2(0x81,0x67), o2(0x81,0x68), o2(0x81,0xF5),
- o2(0x81,0xF6), o2(0x81,0x64), o2(0x81,0x63), o2(0x81,0xF1),
- o2(0x81,0x8C), o2(0x81,0x8D), o2(0x81,0xA6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_80 = {
- to_SHIFT_JIS_E2_80_offsets,
- to_SHIFT_JIS_E2_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_84_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_84 */
- /* used from to_EUC_JP_E2_84 */
- 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_84_infos[5] = {
- o2(0x81,0x8E), o2(0x87,0x82), o2(0x87,0x84), o2(0x81,0xF0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_84 = {
- to_SHIFT_JIS_E2_84_offsets,
- to_SHIFT_JIS_E2_84_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_85_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_85 */
- /* used from to_EUC_JP_E2_85 */
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20, 20, 20, 20, 20, 20,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 20, 20, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_85_infos[21] = {
- o2(0x87,0x54), o2(0x87,0x55), o2(0x87,0x56), o2(0x87,0x57),
- o2(0x87,0x58), o2(0x87,0x59), o2(0x87,0x5A), o2(0x87,0x5B),
- o2(0x87,0x5C), o2(0x87,0x5D), o2(0xFA,0x40), o2(0xFA,0x41),
- o2(0xFA,0x42), o2(0xFA,0x43), o2(0xFA,0x44), o2(0xFA,0x45),
- o2(0xFA,0x46), o2(0xFA,0x47), o2(0xFA,0x48), o2(0xFA,0x49),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_85 = {
- to_SHIFT_JIS_E2_85_offsets,
- to_SHIFT_JIS_E2_85_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_86_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_86 */
- /* used from to_EUC_JP_E2_86 */
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_86_infos[5] = {
- o2(0x81,0xA9), o2(0x81,0xAA), o2(0x81,0xA8), o2(0x81,0xAB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_86 = {
- to_SHIFT_JIS_E2_86_offsets,
- to_SHIFT_JIS_E2_86_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_87_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_87 */
- /* used from to_EUC_JP_E2_87 */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_87_infos[3] = {
- o2(0x81,0xCB), o2(0x81,0xCC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_87 = {
- to_SHIFT_JIS_E2_87_offsets,
- to_SHIFT_JIS_E2_87_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_88 */
- /* used from to_EUC_JP_E2_88 */
- 0, 23, 1, 2, 23, 23, 23, 3, 4, 23, 23, 5, 23, 23, 23, 23,
- 23, 6, 7, 23, 23, 23, 23, 23, 23, 23, 8, 23, 23, 9, 10, 11,
- 12, 23, 23, 23, 23, 23, 23, 13, 14, 15, 16, 17, 18, 23, 19, 23,
- 23, 23, 23, 23, 20, 21, 23, 23, 23, 23, 23, 23, 23, 22, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_88_infos[24] = {
- o2(0x81,0xCD), o2(0x81,0xDD), o2(0x81,0xCE), o2(0x81,0xDE),
- o2(0x81,0xB8), o2(0x81,0xB9), o2(0x87,0x94), o2(0x81,0x7C),
- o2(0x87,0x95), o2(0x81,0xE5), o2(0x81,0x87), o2(0x87,0x98),
- o2(0x87,0x97), o2(0x81,0xC8), o2(0x81,0xC9), o2(0x87,0x9B),
- o2(0x87,0x9C), o2(0x87,0x92), o2(0x81,0xE8), o2(0x87,0x93),
- o2(0x81,0x88), o2(0x87,0x9A), o2(0x81,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_88 = {
- to_SHIFT_JIS_E2_88_offsets,
- to_SHIFT_JIS_E2_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_89_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_89 */
- /* used from to_EUC_JP_E2_89 */
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 1, 2, 7, 7, 7, 7, 3, 4, 7, 7, 5, 6, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_89_infos[8] = {
- o2(0x87,0x90), o2(0x81,0x82), o2(0x87,0x91), o2(0x81,0x85),
- o2(0x81,0x86), o2(0x81,0xE1), o2(0x81,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_89 = {
- to_SHIFT_JIS_E2_89_offsets,
- to_SHIFT_JIS_E2_89_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_8A */
- /* used from to_EUC_JP_E2_8A */
- 6, 6, 0, 1, 6, 6, 2, 3, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_8A_infos[7] = {
- o2(0x81,0xBC), o2(0x81,0xBD), o2(0x81,0xBA), o2(0x81,0xBB),
- o2(0x87,0x96), o2(0x87,0x99), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_8A = {
- to_SHIFT_JIS_E2_8A_offsets,
- to_SHIFT_JIS_E2_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_8C */
- /* used from to_EUC_JP_E2_8C */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_8C_infos[2] = {
- o2(0x81,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_8C = {
- to_SHIFT_JIS_E2_8C_offsets,
- to_SHIFT_JIS_E2_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_91_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_91 */
- /* used from to_EUC_JP_E2_91 */
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_91_infos[21] = {
- o2(0x87,0x40), o2(0x87,0x41), o2(0x87,0x42), o2(0x87,0x43),
- o2(0x87,0x44), o2(0x87,0x45), o2(0x87,0x46), o2(0x87,0x47),
- o2(0x87,0x48), o2(0x87,0x49), o2(0x87,0x4A), o2(0x87,0x4B),
- o2(0x87,0x4C), o2(0x87,0x4D), o2(0x87,0x4E), o2(0x87,0x4F),
- o2(0x87,0x50), o2(0x87,0x51), o2(0x87,0x52), o2(0x87,0x53),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_91 = {
- to_SHIFT_JIS_E2_91_offsets,
- to_SHIFT_JIS_E2_91_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_94_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_94 */
- /* used from to_EUC_JP_E2_94 */
- 0, 1, 2, 3, 30, 30, 30, 30, 30, 30, 30, 30, 4, 30, 30, 5,
- 6, 30, 30, 7, 8, 30, 30, 9, 10, 30, 30, 11, 12, 13, 30, 30,
- 14, 30, 30, 15, 16, 17, 30, 30, 18, 30, 30, 19, 20, 30, 30, 21,
- 22, 30, 30, 23, 24, 30, 30, 25, 26, 30, 30, 27, 28, 30, 30, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_94_infos[31] = {
- o2(0x84,0x9F), o2(0x84,0xAA), o2(0x84,0xA0), o2(0x84,0xAB),
- o2(0x84,0xA1), o2(0x84,0xAC), o2(0x84,0xA2), o2(0x84,0xAD),
- o2(0x84,0xA4), o2(0x84,0xAF), o2(0x84,0xA3), o2(0x84,0xAE),
- o2(0x84,0xA5), o2(0x84,0xBA), o2(0x84,0xB5), o2(0x84,0xB0),
- o2(0x84,0xA7), o2(0x84,0xBC), o2(0x84,0xB7), o2(0x84,0xB2),
- o2(0x84,0xA6), o2(0x84,0xB6), o2(0x84,0xBB), o2(0x84,0xB1),
- o2(0x84,0xA8), o2(0x84,0xB8), o2(0x84,0xBD), o2(0x84,0xB3),
- o2(0x84,0xA9), o2(0x84,0xB9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_94 = {
- to_SHIFT_JIS_E2_94_offsets,
- to_SHIFT_JIS_E2_94_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_95_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_95 */
- /* used from to_EUC_JP_E2_95 */
- 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_95_infos[3] = {
- o2(0x84,0xBE), o2(0x84,0xB4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_95 = {
- to_SHIFT_JIS_E2_95_offsets,
- to_SHIFT_JIS_E2_95_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_96_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_96 */
- /* used from to_EUC_JP_E2_96 */
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 0, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 2, 3, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, 6,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_96_infos[7] = {
- o2(0x81,0xA1), o2(0x81,0xA0), o2(0x81,0xA3), o2(0x81,0xA2),
- o2(0x81,0xA5), o2(0x81,0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_96 = {
- to_SHIFT_JIS_E2_96_offsets,
- to_SHIFT_JIS_E2_96_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_97_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_97 */
- /* used from to_EUC_JP_E2_97 */
- 6, 6, 6, 6, 6, 6, 0, 1, 6, 6, 6, 2, 6, 6, 3, 4,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_97_infos[7] = {
- o2(0x81,0x9F), o2(0x81,0x9E), o2(0x81,0x9B), o2(0x81,0x9D),
- o2(0x81,0x9C), o2(0x81,0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_97 = {
- to_SHIFT_JIS_E2_97_offsets,
- to_SHIFT_JIS_E2_97_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_98_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_98 */
- /* used from to_EUC_JP_E2_98 */
- 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_98_infos[3] = {
- o2(0x81,0x9A), o2(0x81,0x99), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_98 = {
- to_SHIFT_JIS_E2_98_offsets,
- to_SHIFT_JIS_E2_98_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_99_offsets[64] = {
- /* used from to_SHIFT_JIS_E2_99 */
- /* used from to_EUC_JP_E2_99 */
- 0, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 5, 5, 3, 5, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_99_infos[6] = {
- o2(0x81,0x8A), o2(0x81,0x89), o2(0x81,0xF4), o2(0x81,0xF3),
- o2(0x81,0xF2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2_99 = {
- to_SHIFT_JIS_E2_99_offsets,
- to_SHIFT_JIS_E2_99_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E2_offsets[64] = {
- /* used from to_SHIFT_JIS_E2 */
- /* used from to_EUC_JP_E2 */
- 0, 16, 16, 16, 1, 2, 3, 4, 5, 6, 7, 16, 8, 16, 16, 16,
- 16, 9, 16, 16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E2_infos[17] = {
- &to_SHIFT_JIS_E2_80, &to_SHIFT_JIS_E2_84,
- &to_SHIFT_JIS_E2_85, &to_SHIFT_JIS_E2_86,
- &to_SHIFT_JIS_E2_87, &to_SHIFT_JIS_E2_88,
- &to_SHIFT_JIS_E2_89, &to_SHIFT_JIS_E2_8A,
- &to_SHIFT_JIS_E2_8C, &to_SHIFT_JIS_E2_91,
- &to_SHIFT_JIS_E2_94, &to_SHIFT_JIS_E2_95,
- &to_SHIFT_JIS_E2_96, &to_SHIFT_JIS_E2_97,
- &to_SHIFT_JIS_E2_98, &to_SHIFT_JIS_E2_99,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E2 = {
- to_SHIFT_JIS_E2_offsets,
- to_SHIFT_JIS_E2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_80 */
- /* used from to_EUC_JP_E3_80 */
- 0, 1, 2, 3, 24, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 24, 24, 24, 24, 24, 24, 21, 22, 24, 23,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_80_infos[25] = {
- o2(0x81,0x40), o2(0x81,0x41), o2(0x81,0x42), o2(0x81,0x56),
- o2(0x81,0x58), o2(0x81,0x59), o2(0x81,0x5A), o2(0x81,0x71),
- o2(0x81,0x72), o2(0x81,0x73), o2(0x81,0x74), o2(0x81,0x75),
- o2(0x81,0x76), o2(0x81,0x77), o2(0x81,0x78), o2(0x81,0x79),
- o2(0x81,0x7A), o2(0x81,0xA7), o2(0x81,0xAC), o2(0x81,0x6B),
- o2(0x81,0x6C), o2(0x81,0x60), o2(0x87,0x80), o2(0x87,0x81),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_80 = {
- to_SHIFT_JIS_E3_80_offsets,
- to_SHIFT_JIS_E3_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_81_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_81 */
- /* used from to_EUC_JP_E3_81 */
- 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_81_infos[64] = {
- o2(0x82,0x9F), o2(0x82,0xA0), o2(0x82,0xA1), o2(0x82,0xA2),
- o2(0x82,0xA3), o2(0x82,0xA4), o2(0x82,0xA5), o2(0x82,0xA6),
- o2(0x82,0xA7), o2(0x82,0xA8), o2(0x82,0xA9), o2(0x82,0xAA),
- o2(0x82,0xAB), o2(0x82,0xAC), o2(0x82,0xAD), o2(0x82,0xAE),
- o2(0x82,0xAF), o2(0x82,0xB0), o2(0x82,0xB1), o2(0x82,0xB2),
- o2(0x82,0xB3), o2(0x82,0xB4), o2(0x82,0xB5), o2(0x82,0xB6),
- o2(0x82,0xB7), o2(0x82,0xB8), o2(0x82,0xB9), o2(0x82,0xBA),
- o2(0x82,0xBB), o2(0x82,0xBC), o2(0x82,0xBD), o2(0x82,0xBE),
- o2(0x82,0xBF), o2(0x82,0xC0), o2(0x82,0xC1), o2(0x82,0xC2),
- o2(0x82,0xC3), o2(0x82,0xC4), o2(0x82,0xC5), o2(0x82,0xC6),
- o2(0x82,0xC7), o2(0x82,0xC8), o2(0x82,0xC9), o2(0x82,0xCA),
- o2(0x82,0xCB), o2(0x82,0xCC), o2(0x82,0xCD), o2(0x82,0xCE),
- o2(0x82,0xCF), o2(0x82,0xD0), o2(0x82,0xD1), o2(0x82,0xD2),
- o2(0x82,0xD3), o2(0x82,0xD4), o2(0x82,0xD5), o2(0x82,0xD6),
- o2(0x82,0xD7), o2(0x82,0xD8), o2(0x82,0xD9), o2(0x82,0xDA),
- o2(0x82,0xDB), o2(0x82,0xDC), o2(0x82,0xDD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_81 = {
- to_SHIFT_JIS_E3_81_offsets,
- to_SHIFT_JIS_E3_81_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_82_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_82 */
- /* used from to_EUC_JP_E3_82 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 55, 55, 55, 55, 55, 55, 55, 20, 21, 22, 23, 55,
- 55, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_82_infos[56] = {
- o2(0x82,0xDE), o2(0x82,0xDF), o2(0x82,0xE0), o2(0x82,0xE1),
- o2(0x82,0xE2), o2(0x82,0xE3), o2(0x82,0xE4), o2(0x82,0xE5),
- o2(0x82,0xE6), o2(0x82,0xE7), o2(0x82,0xE8), o2(0x82,0xE9),
- o2(0x82,0xEA), o2(0x82,0xEB), o2(0x82,0xEC), o2(0x82,0xED),
- o2(0x82,0xEE), o2(0x82,0xEF), o2(0x82,0xF0), o2(0x82,0xF1),
- o2(0x81,0x4A), o2(0x81,0x4B), o2(0x81,0x54), o2(0x81,0x55),
- o2(0x83,0x40), o2(0x83,0x41), o2(0x83,0x42), o2(0x83,0x43),
- o2(0x83,0x44), o2(0x83,0x45), o2(0x83,0x46), o2(0x83,0x47),
- o2(0x83,0x48), o2(0x83,0x49), o2(0x83,0x4A), o2(0x83,0x4B),
- o2(0x83,0x4C), o2(0x83,0x4D), o2(0x83,0x4E), o2(0x83,0x4F),
- o2(0x83,0x50), o2(0x83,0x51), o2(0x83,0x52), o2(0x83,0x53),
- o2(0x83,0x54), o2(0x83,0x55), o2(0x83,0x56), o2(0x83,0x57),
- o2(0x83,0x58), o2(0x83,0x59), o2(0x83,0x5A), o2(0x83,0x5B),
- o2(0x83,0x5C), o2(0x83,0x5D), o2(0x83,0x5E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_82 = {
- to_SHIFT_JIS_E3_82_offsets,
- to_SHIFT_JIS_E3_82_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_83_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_83 */
- /* used from to_EUC_JP_E3_83 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 59, 59, 59, 59, 55, 56, 57, 58, 59,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_83_infos[60] = {
- o2(0x83,0x5F), o2(0x83,0x60), o2(0x83,0x61), o2(0x83,0x62),
- o2(0x83,0x63), o2(0x83,0x64), o2(0x83,0x65), o2(0x83,0x66),
- o2(0x83,0x67), o2(0x83,0x68), o2(0x83,0x69), o2(0x83,0x6A),
- o2(0x83,0x6B), o2(0x83,0x6C), o2(0x83,0x6D), o2(0x83,0x6E),
- o2(0x83,0x6F), o2(0x83,0x70), o2(0x83,0x71), o2(0x83,0x72),
- o2(0x83,0x73), o2(0x83,0x74), o2(0x83,0x75), o2(0x83,0x76),
- o2(0x83,0x77), o2(0x83,0x78), o2(0x83,0x79), o2(0x83,0x7A),
- o2(0x83,0x7B), o2(0x83,0x7C), o2(0x83,0x7D), o2(0x83,0x7E),
- o2(0x83,0x80), o2(0x83,0x81), o2(0x83,0x82), o2(0x83,0x83),
- o2(0x83,0x84), o2(0x83,0x85), o2(0x83,0x86), o2(0x83,0x87),
- o2(0x83,0x88), o2(0x83,0x89), o2(0x83,0x8A), o2(0x83,0x8B),
- o2(0x83,0x8C), o2(0x83,0x8D), o2(0x83,0x8E), o2(0x83,0x8F),
- o2(0x83,0x90), o2(0x83,0x91), o2(0x83,0x92), o2(0x83,0x93),
- o2(0x83,0x94), o2(0x83,0x95), o2(0x83,0x96), o2(0x81,0x45),
- o2(0x81,0x5B), o2(0x81,0x52), o2(0x81,0x53), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_83 = {
- to_SHIFT_JIS_E3_83_offsets,
- to_SHIFT_JIS_E3_83_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_88 */
- /* used from to_EUC_JP_E3_88 */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 0, 1, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_88_infos[4] = {
- o2(0x87,0x8A), o2(0x87,0x8B), o2(0x87,0x8C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_88 = {
- to_SHIFT_JIS_E3_88_offsets,
- to_SHIFT_JIS_E3_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_8A */
- /* used from to_EUC_JP_E3_8A */
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_8A_infos[6] = {
- o2(0x87,0x85), o2(0x87,0x86), o2(0x87,0x87), o2(0x87,0x88),
- o2(0x87,0x89), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_8A = {
- to_SHIFT_JIS_E3_8A_offsets,
- to_SHIFT_JIS_E3_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_8C */
- /* used from to_EUC_JP_E3_8C */
- 11, 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 1, 11, 11,
- 11, 11, 11, 11, 2, 11, 11, 11, 3, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 4, 5, 11, 11, 6, 7, 11, 11, 11, 8, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 9, 11, 11, 11, 11, 10, 11, 11, 11, 11,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_8C_infos[12] = {
- o2(0x87,0x65), o2(0x87,0x69), o2(0x87,0x60), o2(0x87,0x63),
- o2(0x87,0x61), o2(0x87,0x6B), o2(0x87,0x6A), o2(0x87,0x64),
- o2(0x87,0x6C), o2(0x87,0x66), o2(0x87,0x6E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_8C = {
- to_SHIFT_JIS_E3_8C_offsets,
- to_SHIFT_JIS_E3_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_8D_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_8D */
- /* used from to_EUC_JP_E3_8D */
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 1, 9, 9, 2, 9, 9,
- 9, 3, 9, 9, 9, 9, 9, 4, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 6, 7, 8, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_8D_infos[10] = {
- o2(0x87,0x5F), o2(0x87,0x6D), o2(0x87,0x62), o2(0x87,0x67),
- o2(0x87,0x68), o2(0x87,0x7E), o2(0x87,0x8F), o2(0x87,0x8E),
- o2(0x87,0x8D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_8D = {
- to_SHIFT_JIS_E3_8D_offsets,
- to_SHIFT_JIS_E3_8D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_8E_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_8E */
- /* used from to_EUC_JP_E3_8E */
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 1,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 4, 6,
- 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_8E_infos[7] = {
- o2(0x87,0x72), o2(0x87,0x73), o2(0x87,0x6F), o2(0x87,0x70),
- o2(0x87,0x71), o2(0x87,0x75), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_8E = {
- to_SHIFT_JIS_E3_8E_offsets,
- to_SHIFT_JIS_E3_8E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_8F_offsets[64] = {
- /* used from to_SHIFT_JIS_E3_8F */
- /* used from to_EUC_JP_E3_8F */
- 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_8F_infos[3] = {
- o2(0x87,0x74), o2(0x87,0x83), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3_8F = {
- to_SHIFT_JIS_E3_8F_offsets,
- to_SHIFT_JIS_E3_8F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E3_offsets[64] = {
- /* used from to_SHIFT_JIS_E3 */
- /* used from to_EUC_JP_E3 */
- 0, 1, 2, 3, 10, 10, 10, 10, 4, 10, 5, 10, 6, 7, 8, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E3_infos[11] = {
- &to_SHIFT_JIS_E3_80, &to_SHIFT_JIS_E3_81,
- &to_SHIFT_JIS_E3_82, &to_SHIFT_JIS_E3_83,
- &to_SHIFT_JIS_E3_88, &to_SHIFT_JIS_E3_8A,
- &to_SHIFT_JIS_E3_8C, &to_SHIFT_JIS_E3_8D,
- &to_SHIFT_JIS_E3_8E, &to_SHIFT_JIS_E3_8F,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E3 = {
- to_SHIFT_JIS_E3_offsets,
- to_SHIFT_JIS_E3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_B8_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_B8 */
- /* used from to_EUC_JP_E4_B8 */
- 0, 1, 32, 2, 32, 32, 32, 3, 4, 5, 6, 7, 32, 8, 9, 32,
- 10, 11, 32, 32, 12, 13, 14, 15, 16, 17, 32, 32, 32, 32, 18, 32,
- 32, 19, 32, 32, 32, 32, 20, 32, 21, 32, 22, 32, 32, 23, 32, 32,
- 32, 24, 25, 32, 32, 32, 26, 32, 27, 28, 32, 29, 30, 32, 32, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_B8_infos[33] = {
- o2(0x88,0xEA), o2(0x92,0x9A), o2(0x8E,0xB5), o2(0x96,0x9C),
- o2(0x8F,0xE4), o2(0x8E,0x4F), o2(0x8F,0xE3), o2(0x89,0xBA),
- o2(0x95,0x73), o2(0x97,0x5E), o2(0x98,0xA0), o2(0x89,0x4E),
- o2(0x8A,0x8E), o2(0x98,0xA1), o2(0x90,0xA2), o2(0x99,0xC0),
- o2(0x8B,0x75), o2(0x95,0xB8), o2(0x8F,0xE5), o2(0x97,0xBC),
- o2(0x95,0xC0), o2(0xFA,0x68), o2(0x98,0xA2), o2(0x92,0x86),
- o2(0x98,0xA3), o2(0x8B,0xF8), o2(0x98,0xA4), o2(0x8A,0xDB),
- o2(0x92,0x4F), o2(0x8E,0xE5), o2(0x98,0xA5), o2(0x98,0xA6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_B8 = {
- to_SHIFT_JIS_E4_B8_offsets,
- to_SHIFT_JIS_E4_B8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_B9_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_B9 */
- /* used from to_EUC_JP_E4_B9 */
- 19, 19, 0, 1, 19, 2, 19, 19, 19, 19, 19, 3, 19, 4, 5, 6,
- 19, 19, 19, 19, 19, 7, 8, 9, 10, 11, 19, 19, 19, 12, 13, 14,
- 19, 19, 15, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 16, 19, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_B9_infos[20] = {
- o2(0x98,0xA7), o2(0x94,0x54), o2(0x8B,0x76), o2(0x94,0x56),
- o2(0x93,0xE1), o2(0x8C,0xC1), o2(0x96,0x52), o2(0xE5,0x68),
- o2(0x98,0xA8), o2(0x8F,0xE6), o2(0x98,0xA9), o2(0x89,0xB3),
- o2(0x8B,0xE3), o2(0x8C,0xEE), o2(0x96,0xE7), o2(0x9B,0xA4),
- o2(0x97,0x90), o2(0x93,0xFB), o2(0x8A,0xA3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_B9 = {
- to_SHIFT_JIS_E4_B9_offsets,
- to_SHIFT_JIS_E4_B9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_BA_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_BA */
- /* used from to_EUC_JP_E4_BA */
- 0, 35, 1, 35, 35, 2, 3, 35, 4, 5, 6, 7, 8, 35, 9, 35,
- 35, 10, 11, 35, 12, 13, 35, 35, 14, 15, 35, 16, 17, 35, 18, 19,
- 20, 21, 22, 35, 23, 24, 25, 35, 26, 35, 35, 27, 28, 29, 30, 35,
- 31, 35, 35, 32, 35, 35, 33, 35, 35, 35, 34, 35, 35, 35, 35, 35,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_BA_infos[36] = {
- o2(0x8B,0x54), o2(0x98,0xAA), o2(0x98,0xAB), o2(0x97,0xB9),
- o2(0x97,0x5C), o2(0x91,0x88), o2(0x98,0xAD), o2(0x8E,0x96),
- o2(0x93,0xF1), o2(0x98,0xB0), o2(0x89,0x5D), o2(0x8C,0xDD),
- o2(0x8C,0xDC), o2(0x88,0xE4), o2(0x98,0x6A), o2(0x98,0x69),
- o2(0x8D,0xB1), o2(0x88,0x9F), o2(0x98,0xB1), o2(0x98,0xB2),
- o2(0x98,0xB3), o2(0x96,0x53), o2(0x98,0xB4), o2(0x8C,0xF0),
- o2(0x88,0xE5), o2(0x96,0x92), o2(0x8B,0x9C), o2(0x8B,0x9D),
- o2(0x8B,0x9E), o2(0x92,0xE0), o2(0x97,0xBA), o2(0x98,0xB5),
- o2(0x98,0xB6), o2(0x98,0xB7), o2(0x90,0x6C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_BA = {
- to_SHIFT_JIS_E4_BA_offsets,
- to_SHIFT_JIS_E4_BA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_BB_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_BB */
- /* used from to_EUC_JP_E4_BB */
- 0, 1, 2, 32, 3, 32, 4, 5, 32, 32, 6, 7, 32, 8, 9, 10,
- 32, 32, 32, 32, 11, 12, 13, 14, 15, 16, 32, 32, 32, 17, 18, 19,
- 32, 20, 32, 21, 22, 23, 32, 32, 32, 32, 32, 32, 32, 24, 25, 32,
- 26, 32, 27, 32, 32, 32, 28, 29, 32, 32, 32, 30, 31, 32, 32, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_BB_infos[33] = {
- o2(0x8F,0x59), o2(0x90,0x6D), o2(0x98,0xBC), o2(0x98,0xBA),
- o2(0x98,0xBB), o2(0x8B,0x77), o2(0x8D,0xA1), o2(0x89,0xEE),
- o2(0x98,0xB9), o2(0x98,0xB8), o2(0x95,0xA7), o2(0x8E,0x65),
- o2(0x8E,0x64), o2(0x91,0xBC), o2(0x98,0xBD), o2(0x95,0x74),
- o2(0x90,0xE5), o2(0x81,0x57), o2(0x98,0xBE), o2(0x98,0xC0),
- o2(0xFA,0x69), o2(0x91,0xE3), o2(0x97,0xDF), o2(0x88,0xC8),
- o2(0x98,0xBF), o2(0x89,0xBC), o2(0x8B,0xC2), o2(0x92,0x87),
- o2(0x8C,0x8F), o2(0x98,0xC1), o2(0x94,0x43), o2(0xFA,0x6A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_BB = {
- to_SHIFT_JIS_E4_BB_offsets,
- to_SHIFT_JIS_E4_BB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_BC */
- /* used from to_EUC_JP_E4_BC */
- 0, 1, 22, 2, 22, 22, 22, 22, 22, 3, 4, 22, 22, 5, 6, 7,
- 8, 9, 22, 22, 22, 22, 22, 22, 22, 22, 10, 22, 11, 12, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 13,
- 14, 22, 22, 22, 15, 22, 16, 22, 17, 18, 19, 22, 20, 21, 22, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_BC_infos[23] = {
- o2(0xFA,0x6B), o2(0x8A,0xE9), o2(0xFA,0x6C), o2(0x98,0xC2),
- o2(0x88,0xC9), o2(0x8C,0xDE), o2(0x8A,0xEA), o2(0x95,0x9A),
- o2(0x94,0xB0), o2(0x8B,0x78), o2(0x89,0xEF), o2(0x98,0xE5),
- o2(0x93,0x60), o2(0x94,0x8C), o2(0x98,0xC4), o2(0x94,0xBA),
- o2(0x97,0xE0), o2(0x90,0x4C), o2(0xFA,0x6D), o2(0x8E,0x66),
- o2(0x8E,0x97), o2(0x89,0xBE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_BC = {
- to_SHIFT_JIS_E4_BC_offsets,
- to_SHIFT_JIS_E4_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_BD */
- /* used from to_EUC_JP_E4_BD */
- 27, 27, 27, 0, 27, 27, 1, 2, 27, 27, 27, 27, 27, 3, 4, 5,
- 6, 7, 27, 8, 27, 9, 10, 11, 27, 12, 13, 14, 15, 16, 17, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 18, 27, 27, 27, 27, 27, 19,
- 20, 27, 27, 21, 27, 22, 23, 27, 27, 27, 27, 24, 25, 27, 27, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_BD_infos[28] = {
- o2(0x92,0xCF), o2(0x92,0x41), o2(0x98,0xC8), o2(0x88,0xCA),
- o2(0x92,0xE1), o2(0x8F,0x5A), o2(0x8D,0xB2), o2(0x97,0x43),
- o2(0x91,0xCC), o2(0x89,0xBD), o2(0xFA,0x6E), o2(0x98,0xC7),
- o2(0x97,0x5D), o2(0x98,0xC3), o2(0x98,0xC5), o2(0x8D,0xEC),
- o2(0x98,0xC6), o2(0x9B,0x43), o2(0x98,0xCE), o2(0x98,0xD1),
- o2(0x98,0xCF), o2(0x89,0xC0), o2(0x95,0xB9), o2(0x98,0xC9),
- o2(0x98,0xCD), o2(0x8C,0xF1), o2(0x8E,0x67), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_BD = {
- to_SHIFT_JIS_E4_BD_offsets,
- to_SHIFT_JIS_E4_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_BE */
- /* used from to_EUC_JP_E4_BE */
- 24, 24, 24, 0, 24, 24, 1, 24, 2, 24, 3, 4, 24, 5, 24, 6,
- 24, 7, 8, 24, 9, 24, 10, 24, 11, 24, 12, 13, 24, 14, 24, 24,
- 15, 16, 24, 24, 24, 24, 24, 24, 24, 24, 24, 17, 24, 18, 19, 20,
- 24, 24, 24, 24, 24, 21, 22, 24, 24, 24, 24, 24, 24, 24, 24, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_BE_infos[25] = {
- o2(0x8A,0xA4), o2(0x98,0xD2), o2(0x98,0xCA), o2(0xFA,0x70),
- o2(0x97,0xE1), o2(0x8E,0x98), o2(0x98,0xCB), o2(0x98,0xD0),
- o2(0xFA,0x6F), o2(0xFA,0x72), o2(0x98,0xD3), o2(0x98,0xCC),
- o2(0xFA,0x71), o2(0x8B,0x9F), o2(0x88,0xCB), o2(0x8B,0xA0),
- o2(0x89,0xBF), o2(0x9B,0x44), o2(0x96,0x99), o2(0x95,0x8E),
- o2(0x8C,0xF2), o2(0x90,0x4E), o2(0x97,0xB5), o2(0x95,0xD6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_BE = {
- to_SHIFT_JIS_E4_BE_offsets,
- to_SHIFT_JIS_E4_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_BF_offsets[64] = {
- /* used from to_SHIFT_JIS_E4_BF */
- /* used from to_EUC_JP_E4_BF */
- 29, 29, 0, 1, 2, 29, 29, 29, 29, 3, 4, 29, 29, 5, 6, 29,
- 7, 8, 29, 29, 9, 29, 29, 10, 11, 29, 12, 13, 29, 14, 29, 15,
- 29, 16, 29, 17, 18, 19, 29, 29, 29, 29, 29, 29, 29, 29, 20, 21,
- 29, 29, 29, 22, 29, 23, 24, 29, 25, 29, 26, 29, 29, 29, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_BF_infos[30] = {
- o2(0x8C,0x57), o2(0x91,0xA3), o2(0x89,0xE2), o2(0xFA,0x61),
- o2(0x8F,0x72), o2(0xFA,0x73), o2(0x98,0xD7), o2(0x98,0xDC),
- o2(0x98,0xDA), o2(0x98,0xD5), o2(0x91,0xAD), o2(0x98,0xD8),
- o2(0x98,0xDB), o2(0x98,0xD9), o2(0x95,0xDB), o2(0x98,0xD6),
- o2(0x90,0x4D), o2(0x96,0x93), o2(0x98,0xDD), o2(0x98,0xDE),
- o2(0x8F,0x43), o2(0x98,0xEB), o2(0x94,0x6F), o2(0x95,0x55),
- o2(0x98,0xE6), o2(0x95,0xEE), o2(0x89,0xB4), o2(0x98,0xEA),
- o2(0xFA,0x76), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4_BF = {
- to_SHIFT_JIS_E4_BF_offsets,
- to_SHIFT_JIS_E4_BF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E4_offsets[64] = {
- /* used from to_SHIFT_JIS_E4 */
- /* used from to_EUC_JP_E4 */
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 0, 1, 2, 3, 4, 5, 6, 7,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E4_infos[9] = {
- &to_SHIFT_JIS_E4_B8, &to_SHIFT_JIS_E4_B9,
- &to_SHIFT_JIS_E4_BA, &to_SHIFT_JIS_E4_BB,
- &to_SHIFT_JIS_E4_BC, &to_SHIFT_JIS_E4_BD,
- &to_SHIFT_JIS_E4_BE, &to_SHIFT_JIS_E4_BF,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E4 = {
- to_SHIFT_JIS_E4_offsets,
- to_SHIFT_JIS_E4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_80 */
- /* used from to_EUC_JP_E5_80 */
- 28, 28, 28, 28, 28, 0, 1, 28, 28, 2, 28, 3, 28, 4, 28, 5,
- 28, 6, 7, 28, 8, 28, 9, 28, 28, 10, 11, 28, 28, 28, 12, 13,
- 28, 14, 15, 16, 17, 18, 19, 28, 20, 21, 22, 23, 24, 25, 28, 28,
- 28, 28, 28, 28, 28, 28, 26, 28, 28, 27, 28, 28, 28, 28, 28, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_80_infos[29] = {
- o2(0x98,0xE4), o2(0x98,0xED), o2(0x91,0x71), o2(0x8C,0xC2),
- o2(0x94,0x7B), o2(0xE0,0xC5), o2(0x98,0xEC), o2(0x93,0x7C),
- o2(0x98,0xE1), o2(0x8C,0xF4), o2(0x8C,0xF3), o2(0x98,0xDF),
- o2(0xFA,0x77), o2(0x8E,0xD8), o2(0x98,0xE7), o2(0xFA,0x75),
- o2(0x95,0xED), o2(0x92,0x6C), o2(0x98,0xE3), o2(0x8C,0x91),
- o2(0x98,0xE0), o2(0x98,0xE8), o2(0x98,0xE2), o2(0x97,0xCF),
- o2(0x98,0xE9), o2(0x98,0x60), o2(0x8B,0xE4), o2(0x8C,0x90),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_80 = {
- to_SHIFT_JIS_E5_80_offsets,
- to_SHIFT_JIS_E5_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_81_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_81 */
- /* used from to_EUC_JP_E5_81 */
- 0, 22, 1, 2, 22, 22, 3, 4, 5, 6, 22, 22, 22, 22, 22, 7,
- 8, 22, 22, 22, 22, 9, 10, 22, 22, 22, 11, 22, 12, 22, 22, 22,
- 22, 22, 22, 22, 22, 13, 22, 22, 22, 22, 22, 22, 14, 22, 22, 22,
- 15, 22, 16, 22, 17, 18, 19, 22, 20, 22, 22, 22, 22, 21, 22, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_81_infos[23] = {
- o2(0xFA,0x74), o2(0xFA,0x7A), o2(0x98,0xEE), o2(0xFA,0x78),
- o2(0x98,0xEF), o2(0x98,0xF3), o2(0x88,0xCC), o2(0x95,0xCE),
- o2(0x98,0xF2), o2(0x98,0xF1), o2(0x98,0xF5), o2(0x98,0xF4),
- o2(0x92,0xE2), o2(0x8C,0x92), o2(0x98,0xF6), o2(0xFA,0x79),
- o2(0x8E,0xC3), o2(0x91,0xA4), o2(0x92,0xE3), o2(0x8B,0xF4),
- o2(0x98,0xF7), o2(0x8B,0x55), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_81 = {
- to_SHIFT_JIS_E5_81_offsets,
- to_SHIFT_JIS_E5_81_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_82_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_82 */
- /* used from to_EUC_JP_E5_82 */
- 0, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 16, 2, 16, 16,
- 16, 3, 16, 16, 4, 16, 16, 16, 5, 6, 7, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 9, 16, 16,
- 16, 16, 10, 11, 12, 13, 16, 14, 16, 16, 16, 16, 16, 16, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_82_infos[17] = {
- o2(0x98,0xF8), o2(0x98,0xFA), o2(0x96,0x54), o2(0x8C,0x86),
- o2(0xFA,0x7B), o2(0x8E,0x50), o2(0x94,0xF5), o2(0x98,0xF9),
- o2(0x8D,0xC3), o2(0x97,0x62), o2(0x98,0xFC), o2(0x99,0x42),
- o2(0x98,0xFB), o2(0x8D,0xC2), o2(0x8F,0x9D), o2(0x8C,0x58),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_82 = {
- to_SHIFT_JIS_E5_82_offsets,
- to_SHIFT_JIS_E5_82_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_83_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_83 */
- /* used from to_EUC_JP_E5_83 */
- 21, 21, 0, 21, 21, 1, 21, 21, 21, 2, 3, 21, 21, 4, 21, 5,
- 21, 6, 21, 21, 21, 7, 8, 21, 9, 21, 10, 21, 21, 21, 11, 21,
- 21, 21, 21, 12, 21, 13, 21, 14, 21, 21, 21, 21, 21, 15, 16, 21,
- 21, 21, 21, 21, 17, 18, 21, 21, 21, 19, 21, 20, 21, 21, 21, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_83_infos[22] = {
- o2(0x99,0x43), o2(0x8B,0xCD), o2(0x99,0x40), o2(0x99,0x41),
- o2(0x93,0xAD), o2(0x91,0x9C), o2(0x8B,0xA1), o2(0x96,0x6C),
- o2(0x99,0x44), o2(0xFA,0x7D), o2(0x97,0xBB), o2(0x99,0x45),
- o2(0x99,0x48), o2(0x99,0x46), o2(0x91,0x6D), o2(0x99,0x47),
- o2(0x99,0x49), o2(0xFA,0x7C), o2(0x99,0x4B), o2(0x99,0x4A),
- o2(0x95,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_83 = {
- to_SHIFT_JIS_E5_83_offsets,
- to_SHIFT_JIS_E5_83_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_84_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_84 */
- /* used from to_EUC_JP_E5_84 */
- 0, 1, 2, 20, 3, 20, 20, 20, 20, 4, 20, 20, 20, 20, 20, 20,
- 20, 20, 5, 20, 6, 7, 8, 20, 9, 20, 10, 20, 20, 20, 20, 11,
- 20, 12, 20, 20, 20, 20, 20, 20, 20, 20, 13, 20, 20, 20, 20, 20,
- 20, 20, 14, 20, 20, 20, 20, 15, 20, 20, 16, 17, 18, 20, 20, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_84_infos[21] = {
- o2(0x8B,0x56), o2(0x99,0x4D), o2(0x99,0x4E), o2(0x89,0xAD),
- o2(0x99,0x4C), o2(0x8E,0xF2), o2(0x99,0x51), o2(0x99,0x50),
- o2(0x99,0x4F), o2(0x98,0xD4), o2(0x99,0x52), o2(0x8F,0x9E),
- o2(0x99,0x53), o2(0x97,0x44), o2(0x96,0xD7), o2(0x99,0x55),
- o2(0x99,0x54), o2(0x99,0x57), o2(0x99,0x56), o2(0x99,0x58),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_84 = {
- to_SHIFT_JIS_E5_84_offsets,
- to_SHIFT_JIS_E5_84_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_85_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_85 */
- /* used from to_EUC_JP_E5_85 */
- 0, 1, 35, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 35,
- 14, 35, 15, 35, 16, 35, 35, 35, 35, 35, 17, 35, 18, 35, 35, 35,
- 35, 35, 19, 35, 20, 21, 35, 35, 22, 23, 24, 25, 26, 27, 28, 35,
- 35, 29, 35, 35, 35, 30, 31, 32, 33, 35, 35, 35, 34, 35, 35, 35,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_85_infos[36] = {
- o2(0x99,0x59), o2(0x88,0xF2), o2(0x8C,0xB3), o2(0x8C,0x5A),
- o2(0x8F,0x5B), o2(0x92,0x9B), o2(0x8B,0xA2), o2(0x90,0xE6),
- o2(0x8C,0xF5), o2(0xFA,0x7E), o2(0x8D,0x8E), o2(0x99,0x5B),
- o2(0x96,0xC6), o2(0x93,0x65), o2(0x8E,0x99), o2(0x99,0x5A),
- o2(0x99,0x5C), o2(0x93,0x7D), o2(0x8A,0x95), o2(0x99,0x5D),
- o2(0xFA,0x80), o2(0x93,0xFC), o2(0x91,0x53), o2(0x99,0x5F),
- o2(0x99,0x60), o2(0x94,0xAA), o2(0x8C,0xF6), o2(0x98,0x5A),
- o2(0x99,0x61), o2(0x8B,0xA4), o2(0x95,0xBA), o2(0x91,0xB4),
- o2(0x8B,0xEF), o2(0x93,0x54), o2(0x8C,0x93), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_85 = {
- to_SHIFT_JIS_E5_85_offsets,
- to_SHIFT_JIS_E5_85_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_86_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_86 */
- /* used from to_EUC_JP_E5_86 */
- 0, 38, 1, 38, 38, 2, 3, 38, 38, 4, 5, 38, 6, 7, 38, 8,
- 9, 10, 11, 12, 38, 13, 14, 15, 38, 16, 38, 38, 38, 17, 38, 38,
- 18, 38, 19, 38, 20, 21, 22, 38, 23, 24, 25, 26, 27, 38, 38, 38,
- 28, 29, 30, 31, 32, 33, 34, 35, 38, 38, 38, 38, 38, 36, 37, 38,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_86_infos[39] = {
- o2(0x99,0x62), o2(0x99,0x63), o2(0x93,0xE0), o2(0x89,0x7E),
- o2(0x99,0x66), o2(0x8D,0xFB), o2(0x99,0x65), o2(0x8D,0xC4),
- o2(0x99,0x67), o2(0xE3,0xEC), o2(0x99,0x68), o2(0x96,0x60),
- o2(0x99,0x69), o2(0x99,0x6A), o2(0x99,0x6B), o2(0x8F,0xE7),
- o2(0x8E,0xCA), o2(0xFA,0x81), o2(0x8A,0xA5), o2(0x99,0x6E),
- o2(0x99,0x6C), o2(0x96,0xBB), o2(0x99,0x6D), o2(0x95,0x79),
- o2(0x99,0x6F), o2(0x99,0x70), o2(0x99,0x71), o2(0x93,0x7E),
- o2(0x99,0x75), o2(0x99,0x73), o2(0x99,0x74), o2(0x99,0x72),
- o2(0x8D,0xE1), o2(0x99,0x76), o2(0x96,0xE8), o2(0x97,0xE2),
- o2(0x99,0x77), o2(0xFA,0x82), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_86 = {
- to_SHIFT_JIS_E5_86_offsets,
- to_SHIFT_JIS_E5_86_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_87_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_87 */
- /* used from to_EUC_JP_E5_87 */
- 28, 28, 28, 28, 0, 1, 2, 28, 28, 3, 28, 4, 5, 6, 28, 28,
- 28, 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 8, 9, 10, 28, 28,
- 11, 12, 28, 28, 28, 28, 13, 14, 28, 15, 16, 28, 17, 18, 28, 28,
- 19, 20, 28, 28, 28, 21, 22, 28, 23, 24, 25, 28, 28, 26, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_87_infos[29] = {
- o2(0x90,0xA6), o2(0x99,0x78), o2(0x8F,0x79), o2(0x99,0x79),
- o2(0x92,0x9C), o2(0x97,0xBD), o2(0x93,0x80), o2(0x99,0xC3),
- o2(0x99,0x7A), o2(0xEA,0xA3), o2(0x8B,0xC3), o2(0x99,0x7B),
- o2(0x96,0x7D), o2(0x8F,0x88), o2(0x91,0xFA), o2(0x99,0x7D),
- o2(0x93,0xE2), o2(0xFA,0x83), o2(0x99,0x7E), o2(0x99,0x80),
- o2(0x8A,0x4D), o2(0x99,0x81), o2(0x8B,0xA5), o2(0x93,0xCA),
- o2(0x89,0x9A), o2(0x8F,0x6F), o2(0x94,0x9F), o2(0x99,0x82),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_87 = {
- to_SHIFT_JIS_E5_87_offsets,
- to_SHIFT_JIS_E5_87_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_88 */
- /* used from to_EUC_JP_E5_88 */
- 0, 28, 28, 1, 2, 28, 3, 4, 5, 28, 6, 7, 28, 28, 8, 28,
- 28, 9, 28, 28, 10, 11, 28, 12, 28, 28, 28, 28, 28, 13, 28, 28,
- 28, 28, 28, 28, 14, 15, 28, 16, 28, 17, 18, 28, 28, 28, 19, 28,
- 20, 28, 28, 21, 28, 28, 22, 23, 24, 25, 26, 27, 28, 28, 28, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_88_infos[29] = {
- o2(0x93,0x81), o2(0x90,0x6E), o2(0x99,0x83), o2(0x95,0xAA),
- o2(0x90,0xD8), o2(0x8A,0xA0), o2(0x8A,0xA7), o2(0x99,0x84),
- o2(0x99,0x86), o2(0x8C,0x59), o2(0x99,0x85), o2(0xFA,0x84),
- o2(0x97,0xF1), o2(0x8F,0x89), o2(0x94,0xBB), o2(0x95,0xCA),
- o2(0x99,0x87), o2(0x97,0x98), o2(0x99,0x88), o2(0x99,0x89),
- o2(0x93,0x9E), o2(0x99,0x8A), o2(0x90,0xA7), o2(0x8D,0xFC),
- o2(0x8C,0x94), o2(0x99,0x8B), o2(0x8E,0x68), o2(0x8D,0x8F),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_88 = {
- to_SHIFT_JIS_E5_88_offsets,
- to_SHIFT_JIS_E5_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_89_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_89 */
- /* used from to_EUC_JP_E5_89 */
- 26, 26, 26, 0, 1, 26, 26, 2, 26, 26, 3, 4, 5, 6, 26, 7,
- 26, 26, 26, 26, 8, 26, 9, 26, 26, 26, 26, 10, 26, 26, 11, 26,
- 26, 26, 26, 12, 13, 14, 26, 26, 26, 15, 16, 26, 26, 26, 26, 17,
- 18, 19, 20, 21, 22, 23, 26, 26, 26, 26, 26, 26, 26, 24, 26, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_89_infos[27] = {
- o2(0x92,0xE4), o2(0x99,0x8D), o2(0x91,0xA5), o2(0x8D,0xED),
- o2(0x99,0x8E), o2(0x99,0x8F), o2(0x91,0x4F), o2(0x99,0x8C),
- o2(0x99,0x91), o2(0x96,0x55), o2(0x8D,0x84), o2(0x99,0x90),
- o2(0x8C,0x95), o2(0x8D,0xDC), o2(0x94,0x8D), o2(0x99,0x94),
- o2(0x99,0x92), o2(0x95,0x9B), o2(0x8F,0xE8), o2(0x99,0x9B),
- o2(0x8A,0x84), o2(0x99,0x95), o2(0x99,0x93), o2(0x91,0x6E),
- o2(0x99,0x97), o2(0x99,0x96), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_89 = {
- to_SHIFT_JIS_E5_89_offsets,
- to_SHIFT_JIS_E5_89_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_8A */
- /* used from to_EUC_JP_E5_8A */
- 26, 26, 26, 0, 26, 26, 26, 1, 2, 3, 26, 26, 26, 4, 26, 26,
- 26, 5, 6, 26, 7, 26, 26, 26, 26, 26, 26, 8, 9, 26, 26, 10,
- 11, 26, 26, 12, 26, 26, 13, 26, 26, 14, 15, 16, 17, 18, 26, 19,
- 26, 20, 26, 26, 21, 22, 26, 26, 26, 23, 26, 26, 24, 26, 25, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_8A_infos[27] = {
- o2(0x8A,0x63), o2(0x8C,0x80), o2(0x99,0x9C), o2(0x97,0xAB),
- o2(0x99,0x98), o2(0x99,0x9D), o2(0x99,0x9A), o2(0x99,0x99),
- o2(0x97,0xCD), o2(0xFA,0x85), o2(0x8C,0xF7), o2(0x89,0xC1),
- o2(0x97,0xF2), o2(0xFA,0x86), o2(0x8F,0x95), o2(0x93,0x77),
- o2(0x8D,0x85), o2(0x99,0xA0), o2(0x99,0xA1), o2(0xFB,0x77),
- o2(0x97,0xE3), o2(0x98,0x4A), o2(0x99,0xA3), o2(0x8C,0xF8),
- o2(0x99,0xA2), o2(0x8A,0x4E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_8A = {
- to_SHIFT_JIS_E5_8A_offsets,
- to_SHIFT_JIS_E5_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_8B_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_8B */
- /* used from to_EUC_JP_E5_8B */
- 0, 1, 30, 2, 30, 3, 30, 4, 30, 5, 30, 30, 30, 6, 30, 30,
- 30, 30, 7, 30, 30, 8, 30, 9, 10, 11, 30, 12, 30, 13, 14, 15,
- 16, 30, 17, 18, 19, 30, 20, 21, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 22, 23, 30, 24, 30, 30, 25, 26, 27, 30, 30, 30, 28, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_8B_infos[31] = {
- o2(0xFA,0x87), o2(0x99,0xA4), o2(0x96,0x75), o2(0x92,0xBA),
- o2(0x97,0x45), o2(0x95,0xD7), o2(0x99,0xA5), o2(0xE8,0xD3),
- o2(0x93,0xAE), o2(0x99,0xA6), o2(0x8A,0xA8), o2(0x96,0xB1),
- o2(0xFA,0x88), o2(0x8F,0x9F), o2(0x99,0xA7), o2(0x95,0xE5),
- o2(0x99,0xAB), o2(0x90,0xA8), o2(0x99,0xA8), o2(0x8B,0xCE),
- o2(0x99,0xA9), o2(0x8A,0xA9), o2(0x8C,0x4D), o2(0x99,0xAC),
- o2(0x99,0xAD), o2(0x99,0xAE), o2(0x99,0xAF), o2(0x8E,0xD9),
- o2(0x8C,0xF9), o2(0x96,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_8B = {
- to_SHIFT_JIS_E5_8B_offsets,
- to_SHIFT_JIS_E5_8B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_8C */
- /* used from to_EUC_JP_E5_8C */
- 0, 1, 2, 29, 29, 3, 4, 5, 6, 29, 29, 29, 29, 7, 29, 8,
- 9, 29, 29, 29, 29, 10, 11, 12, 29, 13, 14, 29, 29, 15, 29, 29,
- 16, 17, 29, 18, 19, 29, 29, 29, 29, 29, 20, 29, 29, 29, 29, 21,
- 29, 22, 29, 23, 29, 29, 29, 29, 24, 25, 26, 27, 29, 29, 29, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_8C_infos[30] = {
- o2(0xFA,0x89), o2(0x96,0xE6), o2(0x93,0xF5), o2(0x95,0xEF),
- o2(0x99,0xB0), o2(0xFA,0x8A), o2(0x99,0xB1), o2(0x99,0xB3),
- o2(0x99,0xB5), o2(0x99,0xB4), o2(0x99,0xB6), o2(0x89,0xBB),
- o2(0x96,0x6B), o2(0x8D,0xFA), o2(0x99,0xB7), o2(0x91,0x78),
- o2(0x8F,0xA0), o2(0x8B,0xA7), o2(0x99,0xB8), o2(0xFA,0x8B),
- o2(0x94,0xD9), o2(0x99,0xB9), o2(0x99,0xBA), o2(0x99,0xBB),
- o2(0x99,0xBC), o2(0x95,0x43), o2(0x8B,0xE6), o2(0x88,0xE3),
- o2(0x93,0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_8C = {
- to_SHIFT_JIS_E5_8C_offsets,
- to_SHIFT_JIS_E5_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_8D_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_8D */
- /* used from to_EUC_JP_E5_8D */
- 0, 1, 34, 2, 34, 3, 4, 5, 6, 7, 8, 34, 34, 9, 34, 34,
- 34, 10, 11, 12, 13, 34, 34, 14, 15, 34, 16, 34, 17, 34, 18, 34,
- 19, 34, 34, 34, 34, 34, 20, 34, 34, 21, 34, 34, 34, 34, 22, 23,
- 24, 25, 26, 27, 28, 29, 34, 30, 31, 34, 34, 32, 34, 34, 34, 33,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_8D_infos[35] = {
- o2(0x99,0xBD), o2(0x8F,0x5C), o2(0x90,0xE7), o2(0x99,0xBF),
- o2(0x99,0xBE), o2(0x8F,0xA1), o2(0x8C,0xDF), o2(0x99,0xC1),
- o2(0x94,0xBC), o2(0x99,0xC2), o2(0x94,0xDA), o2(0x91,0xB2),
- o2(0x91,0xEC), o2(0x8B,0xA6), o2(0x93,0xEC), o2(0x92,0x50),
- o2(0x94,0x8E), o2(0x96,0x6D), o2(0x99,0xC4), o2(0x90,0xE8),
- o2(0x8C,0x54), o2(0x99,0xC5), o2(0x99,0xC6), o2(0x89,0x4B),
- o2(0x88,0xF3), o2(0x8A,0xEB), o2(0xFA,0x8C), o2(0x91,0xA6),
- o2(0x8B,0x70), o2(0x97,0x91), o2(0x99,0xC9), o2(0x89,0xB5),
- o2(0x99,0xC8), o2(0x8B,0xA8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_8D = {
- to_SHIFT_JIS_E5_8D_offsets,
- to_SHIFT_JIS_E5_8D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_8E_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_8E */
- /* used from to_EUC_JP_E5_8E */
- 19, 19, 0, 19, 1, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 2, 19, 19, 3, 19, 4, 19, 5, 19, 19, 19, 19, 6,
- 7, 19, 19, 19, 19, 8, 9, 19, 10, 11, 19, 19, 19, 12, 13, 19,
- 14, 19, 15, 16, 19, 19, 17, 19, 19, 19, 19, 18, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_8E_infos[20] = {
- o2(0x99,0xCA), o2(0x96,0xEF), o2(0xFA,0x8D), o2(0x99,0xCB),
- o2(0x97,0xD0), o2(0x8C,0xFA), o2(0x8C,0xB4), o2(0x99,0xCC),
- o2(0x99,0xCE), o2(0x99,0xCD), o2(0x90,0x7E), o2(0x89,0x58),
- o2(0x89,0x7D), o2(0x99,0xCF), o2(0x99,0xD0), o2(0xFA,0x8E),
- o2(0x8C,0xB5), o2(0x99,0xD1), o2(0x8B,0x8E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_8E = {
- to_SHIFT_JIS_E5_8E_offsets,
- to_SHIFT_JIS_E5_8E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_8F_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_8F */
- /* used from to_EUC_JP_E5_8F */
- 37, 37, 0, 1, 37, 37, 37, 37, 2, 3, 4, 5, 6, 7, 8, 37,
- 37, 37, 37, 37, 9, 37, 10, 11, 37, 12, 37, 13, 37, 14, 37, 15,
- 37, 16, 17, 18, 19, 20, 37, 37, 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 37, 37, 33, 34, 35, 37, 36, 37, 37, 37, 37, 37,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_8F_infos[38] = {
- o2(0x8E,0x51), o2(0x99,0xD2), o2(0x96,0x94), o2(0x8D,0xB3),
- o2(0x8B,0x79), o2(0x97,0x46), o2(0x91,0x6F), o2(0x94,0xBD),
- o2(0x8E,0xFB), o2(0x8F,0x66), o2(0x8E,0xE6), o2(0x8E,0xF3),
- o2(0x8F,0x96), o2(0x94,0xBE), o2(0xFA,0x8F), o2(0x99,0xD5),
- o2(0x89,0x62), o2(0x91,0x70), o2(0x8C,0xFB), o2(0x8C,0xC3),
- o2(0x8B,0xE5), o2(0x99,0xD9), o2(0x92,0x40), o2(0x91,0xFC),
- o2(0x8B,0xA9), o2(0x8F,0xA2), o2(0x99,0xDA), o2(0x99,0xD8),
- o2(0x89,0xC2), o2(0x91,0xE4), o2(0x8E,0xB6), o2(0x8E,0x6A),
- o2(0x89,0x45), o2(0x8A,0x90), o2(0x8D,0x86), o2(0x8E,0x69),
- o2(0x99,0xDB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_8F = {
- to_SHIFT_JIS_E5_8F_offsets,
- to_SHIFT_JIS_E5_8F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_90_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_90 */
- /* used from to_EUC_JP_E5_90 */
- 30, 0, 30, 1, 2, 30, 30, 30, 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 30, 30, 30, 30, 30, 30, 30, 30, 30, 13, 30, 14, 30, 15,
- 16, 30, 30, 30, 30, 30, 17, 30, 30, 18, 30, 19, 20, 21, 22, 30,
- 30, 30, 30, 30, 30, 30, 23, 30, 24, 25, 30, 26, 27, 28, 29, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_90_infos[31] = {
- o2(0x99,0xDC), o2(0x8B,0x68), o2(0x8A,0x65), o2(0x8D,0x87),
- o2(0x8B,0x67), o2(0x92,0xDD), o2(0x89,0x44), o2(0x93,0xAF),
- o2(0x96,0xBC), o2(0x8D,0x40), o2(0x97,0x99), o2(0x93,0x66),
- o2(0x8C,0xFC), o2(0x8C,0x4E), o2(0x99,0xE5), o2(0x8B,0xE1),
- o2(0x96,0x69), o2(0x94,0xDB), o2(0x99,0xE4), o2(0x8A,0xDC),
- o2(0x99,0xDF), o2(0x99,0xE0), o2(0x99,0xE2), o2(0x99,0xE3),
- o2(0x8B,0x7A), o2(0x90,0x81), o2(0x95,0xAB), o2(0x99,0xE1),
- o2(0x99,0xDD), o2(0x8C,0xE1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_90 = {
- to_SHIFT_JIS_E5_90_offsets,
- to_SHIFT_JIS_E5_90_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_91_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_91 */
- /* used from to_EUC_JP_E5_91 */
- 0, 20, 1, 20, 20, 20, 2, 20, 3, 4, 5, 20, 20, 20, 6, 20,
- 20, 7, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 8,
- 20, 20, 20, 20, 20, 20, 20, 20, 9, 20, 10, 20, 20, 20, 20, 20,
- 11, 12, 20, 13, 20, 14, 15, 16, 20, 20, 20, 17, 18, 19, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_91_infos[21] = {
- o2(0x99,0xDE), o2(0x98,0x43), o2(0x95,0xF0), o2(0x92,0xE6),
- o2(0x8C,0xE0), o2(0x8D,0x90), o2(0x99,0xE6), o2(0x93,0xDB),
- o2(0x99,0xEA), o2(0x8E,0xFC), o2(0x8E,0xF4), o2(0x99,0xED),
- o2(0x99,0xEB), o2(0x96,0xA1), o2(0x99,0xE8), o2(0x99,0xF1),
- o2(0x99,0xEC), o2(0x99,0xEF), o2(0x8C,0xC4), o2(0x96,0xBD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_91 = {
- to_SHIFT_JIS_E5_91_offsets,
- to_SHIFT_JIS_E5_91_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_92_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_92 */
- /* used from to_EUC_JP_E5_92 */
- 0, 25, 25, 25, 1, 25, 2, 25, 25, 25, 3, 4, 5, 25, 6, 7,
- 8, 25, 9, 25, 25, 25, 25, 25, 25, 25, 25, 25, 10, 25, 25, 25,
- 25, 25, 11, 25, 12, 13, 25, 25, 14, 15, 25, 16, 17, 25, 25, 18,
- 25, 25, 19, 20, 25, 25, 25, 25, 21, 25, 25, 25, 22, 23, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_92_infos[26] = {
- o2(0x99,0xF0), o2(0x99,0xF2), o2(0x99,0xF4), o2(0xFA,0x92),
- o2(0x8D,0xEE), o2(0x98,0x61), o2(0x99,0xE9), o2(0x99,0xE7),
- o2(0x99,0xF3), o2(0x99,0xEE), o2(0xFA,0x91), o2(0x99,0xF6),
- o2(0x9A,0x42), o2(0x99,0xF8), o2(0x99,0xFC), o2(0xFA,0x93),
- o2(0x9A,0x40), o2(0x99,0xF9), o2(0x9A,0x5D), o2(0x8D,0xE7),
- o2(0x8A,0x50), o2(0x99,0xF7), o2(0x9A,0x44), o2(0x88,0xF4),
- o2(0x9A,0x43), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_92 = {
- to_SHIFT_JIS_E5_92_offsets,
- to_SHIFT_JIS_E5_92_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_93_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_93 */
- /* used from to_EUC_JP_E5_93 */
- 0, 1, 2, 20, 3, 20, 20, 4, 5, 6, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 7, 20, 20, 20, 20, 20, 20, 20,
- 20, 8, 9, 20, 20, 10, 11, 20, 12, 13, 20, 20, 20, 14, 15, 20,
- 20, 20, 16, 20, 20, 20, 20, 20, 20, 20, 17, 20, 20, 18, 20, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_93_infos[21] = {
- o2(0x88,0xA3), o2(0x95,0x69), o2(0x9A,0x41), o2(0x99,0xFA),
- o2(0x99,0xF5), o2(0x99,0xFB), o2(0x8D,0xC6), o2(0x9A,0x45),
- o2(0x88,0xF5), o2(0x9A,0x4E), o2(0x9A,0x46), o2(0x9A,0x47),
- o2(0x8F,0xA3), o2(0x96,0x89), o2(0x9A,0x4C), o2(0x9A,0x4B),
- o2(0x93,0x4E), o2(0x9A,0x4D), o2(0x9A,0x4A), o2(0xFA,0x94),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_93 = {
- to_SHIFT_JIS_E5_93_offsets,
- to_SHIFT_JIS_E5_93_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_94_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_94 */
- /* used from to_EUC_JP_E5_94 */
- 14, 14, 14, 14, 0, 14, 1, 2, 14, 14, 14, 14, 14, 14, 14, 3,
- 4, 14, 14, 14, 5, 14, 6, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 7, 8,
- 14, 9, 14, 10, 14, 14, 14, 14, 11, 12, 14, 14, 14, 14, 13, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_94_infos[15] = {
- o2(0x89,0x53), o2(0x8D,0xB4), o2(0x90,0x4F), o2(0x9A,0x48),
- o2(0x93,0x82), o2(0x9A,0x49), o2(0x88,0xA0), o2(0x9A,0x53),
- o2(0x97,0x42), o2(0x8F,0xA5), o2(0x9A,0x59), o2(0x9A,0x58),
- o2(0x9A,0x4F), o2(0x91,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_94 = {
- to_SHIFT_JIS_E5_94_offsets,
- to_SHIFT_JIS_E5_94_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_95_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_95 */
- /* used from to_EUC_JP_E5_95 */
- 0, 15, 15, 15, 1, 2, 3, 15, 15, 15, 15, 15, 4, 15, 15, 5,
- 15, 15, 15, 6, 15, 15, 7, 8, 15, 15, 15, 15, 9, 10, 15, 15,
- 15, 15, 15, 11, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 13, 15, 14, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_95_infos[16] = {
- o2(0x9A,0x50), o2(0x91,0xED), o2(0x9A,0x55), o2(0x8F,0xA4),
- o2(0x9A,0x52), o2(0x96,0xE2), o2(0x8C,0x5B), o2(0x9A,0x56),
- o2(0x9A,0x57), o2(0x9A,0x54), o2(0x9A,0x5A), o2(0x9A,0x51),
- o2(0x9A,0x60), o2(0x9A,0x65), o2(0x9A,0x61), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_95 = {
- to_SHIFT_JIS_E5_95_offsets,
- to_SHIFT_JIS_E5_95_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_96_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_96 */
- /* used from to_EUC_JP_E5_96 */
- 0, 24, 24, 1, 2, 24, 3, 4, 24, 5, 6, 7, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 8, 9, 10, 24, 11, 12, 13, 14,
- 24, 24, 24, 24, 24, 24, 24, 15, 16, 17, 18, 19, 20, 24, 21, 24,
- 22, 24, 24, 24, 24, 24, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_96_infos[25] = {
- o2(0x9A,0x5C), o2(0x9A,0x66), o2(0x91,0x50), o2(0xFA,0x95),
- o2(0x9A,0x68), o2(0x8D,0x41), o2(0x9A,0x5E), o2(0x92,0x9D),
- o2(0x9A,0x62), o2(0x9A,0x5B), o2(0x8A,0xAB), o2(0x8A,0xEC),
- o2(0x8A,0x85), o2(0x9A,0x63), o2(0x9A,0x5F), o2(0x8C,0x96),
- o2(0x9A,0x69), o2(0x9A,0x67), o2(0x91,0x72), o2(0x8B,0x69),
- o2(0x8B,0xAA), o2(0x9A,0x64), o2(0x8B,0xF2), o2(0x89,0x63),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_96 = {
- to_SHIFT_JIS_E5_96_offsets,
- to_SHIFT_JIS_E5_96_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_97_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_97 */
- /* used from to_EUC_JP_E5_97 */
- 13, 13, 13, 13, 0, 1, 13, 2, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 3, 13, 13, 13, 13, 13, 4, 13, 5, 13, 13, 6,
- 13, 13, 13, 7, 8, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 9, 13, 10, 13, 13, 13, 11, 12, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_97_infos[14] = {
- o2(0x9A,0x6D), o2(0x9A,0x6B), o2(0x9A,0xA5), o2(0x9A,0x70),
- o2(0x9A,0x6A), o2(0x9A,0x6E), o2(0x9A,0x6C), o2(0x8E,0x6B),
- o2(0x9A,0x6F), o2(0x9A,0x72), o2(0x9A,0x77), o2(0x9A,0x75),
- o2(0x9A,0x74), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_97 = {
- to_SHIFT_JIS_E5_97_offsets,
- to_SHIFT_JIS_E5_97_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_98_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_98 */
- /* used from to_EUC_JP_E5_98 */
- 14, 14, 14, 14, 14, 14, 0, 14, 14, 1, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 2, 14, 3, 4, 5, 14, 14, 6, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 7, 14, 14, 14, 14, 14, 8,
- 14, 9, 10, 14, 11, 14, 12, 14, 13, 14, 14, 14, 14, 14, 14, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_98_infos[15] = {
- o2(0x92,0x51), o2(0x89,0xC3), o2(0x9A,0x71), o2(0x9A,0x73),
- o2(0x8F,0xA6), o2(0x89,0x52), o2(0x9A,0x76), o2(0x89,0xDC),
- o2(0x9A,0x82), o2(0x8F,0xFA), o2(0x9A,0x7D), o2(0x9A,0x7B),
- o2(0x9A,0x7C), o2(0x9A,0x7E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_98 = {
- to_SHIFT_JIS_E5_98_offsets,
- to_SHIFT_JIS_E5_98_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_99_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_99 */
- /* used from to_EUC_JP_E5_99 */
- 13, 13, 0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1, 13, 2, 13,
- 3, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 4, 13, 13, 13, 13,
- 13, 13, 13, 13, 5, 13, 13, 13, 6, 13, 7, 8, 9, 13, 13, 13,
- 13, 13, 13, 13, 10, 13, 13, 13, 11, 13, 12, 13, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_99_infos[14] = {
- o2(0x89,0x5C), o2(0x91,0x58), o2(0x9A,0x78), o2(0x9A,0x79),
- o2(0x8A,0x9A), o2(0x9A,0x81), o2(0x8A,0xED), o2(0x9A,0x84),
- o2(0x9A,0x80), o2(0x9A,0x83), o2(0x95,0xAC), o2(0x93,0xD3),
- o2(0x94,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_99 = {
- to_SHIFT_JIS_E5_99_offsets,
- to_SHIFT_JIS_E5_99_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_9A_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_9A */
- /* used from to_EUC_JP_E5_9A */
- 0, 13, 13, 13, 13, 13, 1, 2, 13, 13, 3, 13, 13, 13, 13, 4,
- 13, 13, 13, 13, 5, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 6, 13, 7, 13, 13, 8, 13, 13, 13, 13, 13, 13, 13, 13, 9, 13,
- 13, 13, 13, 13, 10, 13, 11, 13, 13, 13, 13, 13, 12, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_9A_infos[14] = {
- o2(0x9A,0x86), o2(0x9A,0x85), o2(0x8A,0x64), o2(0x9A,0x87),
- o2(0x9A,0x8A), o2(0x9A,0x89), o2(0x9A,0x88), o2(0x94,0x58),
- o2(0x9A,0x8B), o2(0x9A,0x8C), o2(0x9A,0x8E), o2(0x9A,0x8D),
- o2(0x9A,0x90), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_9A = {
- to_SHIFT_JIS_E5_9A_offsets,
- to_SHIFT_JIS_E5_9A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_9B_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_9B */
- /* used from to_EUC_JP_E5_9B */
- 0, 1, 2, 3, 23, 23, 23, 23, 4, 23, 23, 23, 23, 23, 5, 23,
- 23, 6, 23, 7, 23, 23, 23, 8, 9, 23, 10, 11, 23, 23, 12, 23,
- 13, 23, 23, 14, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 15, 23,
- 16, 23, 17, 18, 23, 23, 23, 23, 23, 19, 20, 23, 23, 21, 23, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_9B_infos[24] = {
- o2(0x9A,0x93), o2(0x9A,0x91), o2(0x9A,0x8F), o2(0x9A,0x92),
- o2(0x9A,0x94), o2(0x9A,0x95), o2(0x9A,0x96), o2(0x9A,0x97),
- o2(0x9A,0x98), o2(0x99,0x64), o2(0x8E,0xFA), o2(0x8E,0x6C),
- o2(0x89,0xF1), o2(0x88,0xF6), o2(0x92,0x63), o2(0x9A,0x99),
- o2(0x8D,0xA2), o2(0x88,0xCD), o2(0x90,0x7D), o2(0x9A,0x9A),
- o2(0x8C,0xC5), o2(0x8D,0x91), o2(0x9A,0x9C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_9B = {
- to_SHIFT_JIS_E5_9B_offsets,
- to_SHIFT_JIS_E5_9B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_9C_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_9C */
- /* used from to_EUC_JP_E5_9C */
- 0, 22, 22, 1, 2, 22, 22, 22, 3, 4, 22, 5, 22, 6, 22, 7,
- 22, 22, 8, 9, 22, 22, 10, 22, 11, 22, 22, 22, 12, 22, 22, 13,
- 22, 22, 22, 22, 22, 22, 14, 15, 16, 22, 22, 22, 22, 17, 22, 22,
- 18, 22, 22, 22, 22, 22, 22, 19, 20, 22, 22, 21, 22, 22, 22, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_9C_infos[23] = {
- o2(0x9A,0x9B), o2(0x95,0xDE), o2(0x9A,0x9D), o2(0x9A,0x9F),
- o2(0x9A,0x9E), o2(0x9A,0xA0), o2(0x9A,0xA1), o2(0x8C,0x97),
- o2(0x89,0x80), o2(0x9A,0xA2), o2(0x9A,0xA4), o2(0x9A,0xA3),
- o2(0x9A,0xA6), o2(0x93,0x79), o2(0x9A,0xA7), o2(0x88,0xB3),
- o2(0x8D,0xDD), o2(0x8C,0x5C), o2(0x92,0x6E), o2(0x9A,0xA8),
- o2(0x9A,0xA9), o2(0x9A,0xAB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_9C = {
- to_SHIFT_JIS_E5_9C_offsets,
- to_SHIFT_JIS_E5_9C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_9D_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_9D */
- /* used from to_EUC_JP_E5_9D */
- 0, 16, 1, 16, 16, 16, 16, 2, 16, 16, 3, 16, 16, 16, 4, 5,
- 6, 7, 16, 16, 16, 16, 16, 16, 16, 8, 16, 16, 16, 16, 16, 16,
- 16, 9, 16, 16, 10, 11, 12, 16, 16, 13, 14, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_9D_infos[17] = {
- o2(0x9A,0xAC), o2(0x8D,0xE2), o2(0x8B,0xCF), o2(0x96,0x56),
- o2(0x9A,0xAA), o2(0x9A,0xAD), o2(0x8D,0xBF), o2(0x8D,0x42),
- o2(0xFA,0x96), o2(0x9A,0xB1), o2(0x8D,0xA3), o2(0xFA,0x97),
- o2(0x92,0x52), o2(0x9A,0xAE), o2(0x92,0xD8), o2(0x9A,0xB2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_9D = {
- to_SHIFT_JIS_E5_9D_offsets,
- to_SHIFT_JIS_E5_9D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_9E_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_9E */
- /* used from to_EUC_JP_E5_9E */
- 13, 13, 0, 13, 13, 13, 13, 13, 1, 2, 13, 3, 13, 13, 13, 13,
- 13, 13, 13, 4, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 5, 13, 6, 7, 8, 13, 13, 13, 13, 13, 9, 13, 10, 13, 13, 13,
- 11, 13, 13, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_9E_infos[14] = {
- o2(0x90,0x82), o2(0x9A,0xB0), o2(0x9A,0xB3), o2(0x8C,0x5E),
- o2(0x9A,0xB4), o2(0x9A,0xB5), o2(0x8D,0x43), o2(0x8A,0x5F),
- o2(0x9A,0xB7), o2(0x9A,0xB8), o2(0xFA,0x98), o2(0x9A,0xB9),
- o2(0x9A,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_9E = {
- to_SHIFT_JIS_E5_9E_offsets,
- to_SHIFT_JIS_E5_9E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_9F_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_9F */
- /* used from to_EUC_JP_E5_9F */
- 0, 20, 20, 1, 20, 20, 2, 3, 4, 20, 20, 5, 20, 20, 6, 20,
- 20, 20, 7, 8, 9, 20, 10, 20, 20, 20, 20, 20, 11, 20, 20, 12,
- 13, 20, 20, 14, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 15, 20, 20, 16, 20, 17, 18, 20, 19, 20, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_9F_infos[21] = {
- o2(0x9A,0xAF), o2(0x9A,0xBA), o2(0x9A,0xBB), o2(0xFA,0x9A),
- o2(0xFA,0x99), o2(0x96,0x84), o2(0x8F,0xE9), o2(0x9A,0xBD),
- o2(0x9A,0xBE), o2(0x9A,0xBC), o2(0x9A,0xC0), o2(0x94,0x57),
- o2(0x88,0xE6), o2(0x95,0x75), o2(0x9A,0xC1), o2(0x8F,0xFB),
- o2(0x8E,0xB7), o2(0x94,0x7C), o2(0x8A,0xEE), o2(0x8D,0xE9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_9F = {
- to_SHIFT_JIS_E5_9F_offsets,
- to_SHIFT_JIS_E5_9F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A0_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A0 */
- /* used from to_EUC_JP_E5_A0 */
- 0, 19, 1, 19, 19, 2, 3, 19, 19, 19, 4, 5, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 6, 19, 19, 19, 7, 19, 19, 19, 8, 19, 19,
- 19, 9, 19, 19, 10, 19, 19, 19, 19, 19, 11, 19, 19, 19, 19, 12,
- 13, 14, 19, 19, 15, 16, 19, 19, 19, 19, 17, 19, 19, 18, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A0_infos[20] = {
- o2(0x96,0x78), o2(0x93,0xB0), o2(0x8C,0x98), o2(0x91,0xCD),
- o2(0x9A,0xBF), o2(0x9A,0xC2), o2(0x91,0xC2), o2(0x9A,0xC3),
- o2(0x9A,0xC4), o2(0x9A,0xC6), o2(0x92,0xE7), o2(0x8A,0xAC),
- o2(0xEA,0x9F), o2(0x89,0x81), o2(0x95,0xF1), o2(0x8F,0xEA),
- o2(0x93,0x67), o2(0x8D,0xE4), o2(0x9A,0xCC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A0 = {
- to_SHIFT_JIS_E5_A0_offsets,
- to_SHIFT_JIS_E5_A0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A1_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A1 */
- /* used from to_EUC_JP_E5_A1 */
- 0, 1, 20, 20, 20, 20, 20, 20, 20, 20, 2, 3, 20, 20, 20, 20,
- 20, 4, 5, 20, 6, 20, 20, 7, 8, 9, 10, 20, 20, 20, 11, 20,
- 20, 20, 12, 20, 20, 20, 20, 20, 20, 13, 20, 14, 20, 20, 20, 20,
- 15, 20, 16, 20, 20, 17, 20, 20, 20, 18, 20, 20, 20, 20, 19, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A1_infos[21] = {
- o2(0x95,0xBB), o2(0x97,0xDB), o2(0x89,0xF2), o2(0x9A,0xC8),
- o2(0x91,0x59), o2(0x9A,0xCB), o2(0x93,0x83), o2(0x93,0x68),
- o2(0x93,0x84), o2(0x94,0xB7), o2(0x92,0xCB), o2(0x8D,0xC7),
- o2(0x9A,0xC7), o2(0x89,0x96), o2(0x93,0x55), o2(0x9A,0xC9),
- o2(0x9A,0xC5), o2(0x90,0x6F), o2(0x9A,0xCD), o2(0x8F,0x6D),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A1 = {
- to_SHIFT_JIS_E5_A1_offsets,
- to_SHIFT_JIS_E5_A1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A2_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A2 */
- /* used from to_EUC_JP_E5_A2 */
- 17, 17, 17, 0, 17, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 2, 17, 17, 17, 3, 17, 17, 17, 17, 4, 17, 5, 6,
- 17, 17, 17, 17, 17, 17, 17, 17, 7, 17, 17, 8, 17, 17, 9, 17,
- 17, 17, 10, 11, 17, 17, 17, 17, 12, 13, 14, 15, 17, 17, 16, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A2_infos[18] = {
- o2(0x8B,0xAB), o2(0x9A,0xCE), o2(0x95,0xE6), o2(0x91,0x9D),
- o2(0x92,0xC4), o2(0xFA,0x9D), o2(0x9A,0xD0), o2(0x96,0x6E),
- o2(0x9A,0xD1), o2(0x9A,0xD6), o2(0xFA,0x9E), o2(0x95,0xAD),
- o2(0x9A,0xD5), o2(0x9A,0xCF), o2(0x9A,0xD2), o2(0x9A,0xD4),
- o2(0x8D,0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A2 = {
- to_SHIFT_JIS_E5_A2_offsets,
- to_SHIFT_JIS_E5_A2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A3_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A3 */
- /* used from to_EUC_JP_E5_A3 */
- 29, 0, 29, 29, 29, 1, 29, 2, 29, 29, 3, 29, 4, 29, 29, 29,
- 29, 5, 29, 6, 29, 7, 29, 8, 9, 10, 29, 29, 11, 29, 12, 13,
- 29, 29, 29, 29, 14, 15, 29, 29, 29, 29, 29, 16, 17, 29, 18, 19,
- 20, 21, 22, 29, 29, 29, 29, 23, 29, 24, 25, 26, 27, 28, 29, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A3_infos[30] = {
- o2(0x95,0xC7), o2(0x9A,0xD7), o2(0x92,0x64), o2(0x89,0xF3),
- o2(0x8F,0xEB), o2(0x9A,0xD9), o2(0x9A,0xD8), o2(0x8D,0x88),
- o2(0x9A,0xDA), o2(0x9A,0xDC), o2(0x9A,0xDB), o2(0x9A,0xDE),
- o2(0x9A,0xD3), o2(0x9A,0xE0), o2(0x9A,0xDF), o2(0x9A,0xDD),
- o2(0x8E,0x6D), o2(0x90,0x70), o2(0x91,0x73), o2(0x9A,0xE1),
- o2(0x90,0xBA), o2(0x88,0xEB), o2(0x94,0x84), o2(0x92,0xD9),
- o2(0x9A,0xE3), o2(0x9A,0xE2), o2(0x9A,0xE4), o2(0x9A,0xE5),
- o2(0x9A,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A3 = {
- to_SHIFT_JIS_E5_A3_offsets,
- to_SHIFT_JIS_E5_A3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A4_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A4 */
- /* used from to_EUC_JP_E5_A4 */
- 27, 27, 0, 27, 27, 27, 27, 27, 27, 1, 2, 3, 27, 27, 27, 4,
- 5, 27, 27, 27, 27, 6, 7, 27, 8, 9, 10, 11, 12, 27, 27, 27,
- 27, 27, 13, 27, 27, 14, 27, 15, 27, 16, 17, 18, 19, 20, 21, 27,
- 27, 22, 23, 27, 27, 27, 27, 24, 25, 27, 27, 27, 27, 27, 26, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A4_infos[28] = {
- o2(0x9A,0xE7), o2(0x95,0xCF), o2(0x9A,0xE8), o2(0xFA,0x9F),
- o2(0x89,0xC4), o2(0x9A,0xE9), o2(0x97,0x5B), o2(0x8A,0x4F),
- o2(0x99,0xC7), o2(0x8F,0x67), o2(0x91,0xBD), o2(0x9A,0xEA),
- o2(0x96,0xE9), o2(0x96,0xB2), o2(0x9A,0xEC), o2(0x91,0xE5),
- o2(0x93,0x56), o2(0x91,0xBE), o2(0x95,0x76), o2(0x9A,0xED),
- o2(0x9A,0xEE), o2(0x89,0x9B), o2(0x8E,0xB8), o2(0x9A,0xEF),
- o2(0x88,0xCE), o2(0x9A,0xF0), o2(0x9A,0xF1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A4 = {
- to_SHIFT_JIS_E5_A4_offsets,
- to_SHIFT_JIS_E5_A4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A5_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A5 */
- /* used from to_EUC_JP_E5_A5 */
- 30, 30, 30, 30, 0, 30, 30, 1, 2, 3, 30, 30, 30, 30, 4, 5,
- 6, 7, 30, 8, 9, 10, 30, 11, 12, 30, 13, 14, 30, 15, 30, 30,
- 16, 30, 17, 18, 30, 19, 30, 20, 21, 22, 23, 30, 24, 30, 25, 30,
- 30, 30, 30, 26, 27, 30, 30, 30, 28, 30, 30, 30, 30, 29, 30, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A5_infos[31] = {
- o2(0x89,0x82), o2(0x8A,0xEF), o2(0x93,0xDE), o2(0x95,0xF2),
- o2(0x9A,0xF5), o2(0x91,0x74), o2(0x9A,0xF4), o2(0x8C,0x5F),
- o2(0xFA,0xA0), o2(0x96,0x7A), o2(0x9A,0xF3), o2(0x93,0x85),
- o2(0x9A,0xF7), o2(0x9A,0xF6), o2(0xFA,0xA1), o2(0xFA,0xA2),
- o2(0x9A,0xF9), o2(0x9A,0xF8), o2(0xFA,0xA3), o2(0x89,0x9C),
- o2(0x9A,0xFA), o2(0x8F,0xA7), o2(0x9A,0xFC), o2(0x92,0x44),
- o2(0x9A,0xFB), o2(0x95,0xB1), o2(0x8F,0x97), o2(0x93,0x7A),
- o2(0x9B,0x40), o2(0x8D,0x44), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A5 = {
- to_SHIFT_JIS_E5_A5_offsets,
- to_SHIFT_JIS_E5_A5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A6_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A6 */
- /* used from to_EUC_JP_E5_A6 */
- 21, 0, 1, 2, 3, 21, 21, 21, 21, 21, 4, 21, 21, 5, 21, 21,
- 21, 21, 21, 6, 21, 21, 7, 21, 21, 8, 21, 9, 21, 10, 21, 21,
- 21, 21, 21, 11, 12, 13, 21, 21, 14, 21, 21, 21, 15, 21, 21, 21,
- 21, 21, 16, 21, 21, 21, 21, 21, 21, 17, 18, 19, 21, 21, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A6_infos[22] = {
- o2(0x9B,0x41), o2(0x94,0x40), o2(0x94,0xDC), o2(0x96,0xCF),
- o2(0x94,0x44), o2(0x9B,0x4A), o2(0x8B,0x57), o2(0x97,0x64),
- o2(0x96,0xAD), o2(0x9B,0xAA), o2(0x9B,0x42), o2(0x9B,0x45),
- o2(0xFA,0xA4), o2(0x91,0xC3), o2(0x96,0x57), o2(0x93,0x69),
- o2(0x9B,0x46), o2(0x96,0x85), o2(0xFA,0xA5), o2(0x8D,0xC8),
- o2(0x8F,0xA8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A6 = {
- to_SHIFT_JIS_E5_A6_offsets,
- to_SHIFT_JIS_E5_A6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A7_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A7 */
- /* used from to_EUC_JP_E5_A7 */
- 18, 18, 18, 18, 18, 18, 0, 18, 18, 1, 18, 2, 18, 18, 18, 18,
- 3, 4, 18, 5, 6, 18, 18, 18, 18, 7, 8, 18, 9, 18, 18, 18,
- 18, 18, 18, 18, 18, 10, 11, 18, 12, 18, 13, 14, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 15, 18, 18, 18, 18, 16, 18, 18, 18, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A7_infos[19] = {
- o2(0x9B,0x47), o2(0x8E,0x6F), o2(0x8E,0x6E), o2(0x88,0xB7),
- o2(0x8C,0xC6), o2(0x90,0xA9), o2(0x88,0xCF), o2(0x9B,0x4B),
- o2(0x9B,0x4C), o2(0x9B,0x49), o2(0x89,0x57), o2(0x8A,0xAD),
- o2(0x9B,0x48), o2(0x96,0xC3), o2(0x95,0x50), o2(0x88,0xA6),
- o2(0x88,0xF7), o2(0x8E,0x70), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A7 = {
- to_SHIFT_JIS_E5_A7_offsets,
- to_SHIFT_JIS_E5_A7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A8_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A8 */
- /* used from to_EUC_JP_E5_A8 */
- 15, 0, 15, 1, 15, 15, 15, 15, 15, 2, 15, 15, 15, 15, 15, 15,
- 15, 3, 15, 15, 15, 15, 15, 15, 4, 15, 5, 15, 6, 15, 15, 7,
- 8, 15, 15, 15, 15, 9, 15, 15, 15, 10, 15, 15, 15, 15, 15, 11,
- 15, 15, 15, 15, 15, 12, 13, 15, 15, 15, 15, 15, 14, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A8_infos[16] = {
- o2(0x88,0xD0), o2(0x88,0xA1), o2(0x9B,0x51), o2(0x9B,0x4F),
- o2(0x96,0xBA), o2(0x9B,0x52), o2(0x9B,0x50), o2(0x9B,0x4E),
- o2(0x90,0x50), o2(0x9B,0x4D), o2(0x95,0xD8), o2(0x8C,0xE2),
- o2(0x9B,0x56), o2(0x9B,0x57), o2(0x8F,0xA9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A8 = {
- to_SHIFT_JIS_E5_A8_offsets,
- to_SHIFT_JIS_E5_A8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_A9_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_A9 */
- /* used from to_EUC_JP_E5_A9 */
- 0, 1, 10, 10, 10, 10, 2, 10, 10, 3, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 4, 10, 10, 10, 10, 10,
- 10, 10, 5, 10, 10, 10, 6, 10, 10, 10, 7, 10, 8, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_A9_infos[11] = {
- o2(0x9B,0x53), o2(0x98,0x4B), o2(0x94,0x6B), o2(0x9B,0x55),
- o2(0x8D,0xA5), o2(0x9B,0x58), o2(0x95,0x77), o2(0x9B,0x59),
- o2(0x9B,0x54), o2(0x96,0xB9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_A9 = {
- to_SHIFT_JIS_E5_A9_offsets,
- to_SHIFT_JIS_E5_A9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_AA_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_AA */
- /* used from to_EUC_JP_E5_AA */
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 1, 2, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 4, 5, 6,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_AA_infos[7] = {
- o2(0x94,0x7D), o2(0x9B,0x5A), o2(0x95,0x51), o2(0x9B,0x5B),
- o2(0x9B,0x5F), o2(0x9B,0x5C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_AA = {
- to_SHIFT_JIS_E5_AA_offsets,
- to_SHIFT_JIS_E5_AA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_AB_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_AB */
- /* used from to_EUC_JP_E5_AB */
- 14, 0, 1, 14, 14, 14, 14, 14, 14, 2, 14, 3, 4, 14, 14, 14,
- 5, 14, 14, 14, 14, 14, 6, 7, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 8, 14, 9, 14, 14, 10, 14, 14, 11, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 12, 13, 14, 14, 14, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_AB_infos[15] = {
- o2(0x89,0xC5), o2(0x9B,0x5E), o2(0x8E,0xB9), o2(0x9B,0x5D),
- o2(0x8C,0x99), o2(0x9B,0x6B), o2(0x9B,0x64), o2(0x9B,0x61),
- o2(0x92,0x84), o2(0x9B,0x60), o2(0x9B,0x62), o2(0x9B,0x63),
- o2(0x9B,0x65), o2(0x9B,0x66), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_AB = {
- to_SHIFT_JIS_E5_AB_offsets,
- to_SHIFT_JIS_E5_AB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_AC_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_AC */
- /* used from to_EUC_JP_E5_AC */
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 11, 1, 2, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 3, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 4, 11, 11, 11, 11, 11, 11, 11, 5, 11, 6, 11, 11, 11,
- 7, 11, 8, 11, 11, 11, 9, 11, 11, 11, 11, 11, 11, 11, 10, 11,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_AC_infos[12] = {
- o2(0x8A,0xF0), o2(0x9B,0x68), o2(0x9B,0x67), o2(0x9B,0x69),
- o2(0x8F,0xEC), o2(0x9B,0x6C), o2(0x92,0xDA), o2(0x89,0x64),
- o2(0x9B,0x6A), o2(0x9B,0x6D), o2(0x9B,0x6E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_AC = {
- to_SHIFT_JIS_E5_AC_offsets,
- to_SHIFT_JIS_E5_AC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_AD_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_AD */
- /* used from to_EUC_JP_E5_AD */
- 0, 27, 27, 1, 27, 2, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 3, 4, 27, 27, 5, 6, 7, 8, 9, 27, 10, 11, 12, 13, 27, 14,
- 27, 27, 27, 15, 16, 17, 18, 27, 27, 19, 27, 20, 27, 27, 27, 27,
- 21, 22, 27, 23, 27, 24, 27, 27, 25, 27, 26, 27, 27, 27, 27, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_AD_infos[28] = {
- o2(0x9B,0x71), o2(0x9B,0x6F), o2(0x9B,0x70), o2(0x8E,0x71),
- o2(0x9B,0x72), o2(0x8D,0x45), o2(0x9B,0x73), o2(0xFA,0xA6),
- o2(0x8E,0x9A), o2(0x91,0xB6), o2(0x9B,0x74), o2(0x9B,0x75),
- o2(0x8E,0x79), o2(0x8D,0x46), o2(0x96,0xD0), o2(0x8B,0x47),
- o2(0x8C,0xC7), o2(0x9B,0x76), o2(0x8A,0x77), o2(0x9B,0x77),
- o2(0x91,0xB7), o2(0x9B,0x78), o2(0x9B,0xA1), o2(0x9B,0x79),
- o2(0x9B,0x7A), o2(0x9B,0x7B), o2(0x9B,0x7D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_AD = {
- to_SHIFT_JIS_E5_AD_offsets,
- to_SHIFT_JIS_E5_AD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_AE_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_AE */
- /* used from to_EUC_JP_E5_AE */
- 0, 33, 33, 1, 33, 2, 33, 3, 4, 5, 33, 6, 7, 8, 33, 9,
- 33, 33, 33, 33, 33, 10, 33, 11, 12, 13, 14, 15, 16, 17, 33, 18,
- 33, 33, 19, 20, 21, 22, 23, 33, 33, 33, 33, 33, 33, 33, 24, 33,
- 25, 33, 33, 26, 27, 28, 29, 33, 30, 31, 33, 33, 33, 33, 33, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_AE_infos[34] = {
- o2(0x9B,0x7E), o2(0x9B,0x80), o2(0x91,0xEE), o2(0x89,0x46),
- o2(0x8E,0xE7), o2(0x88,0xC0), o2(0x91,0x76), o2(0x8A,0xAE),
- o2(0x8E,0xB3), o2(0x8D,0x47), o2(0x93,0x86), o2(0x8F,0x40),
- o2(0x8A,0xAF), o2(0x92,0x88), o2(0x92,0xE8), o2(0x88,0xB6),
- o2(0x8B,0x58), o2(0x95,0xF3), o2(0x8E,0xC0), o2(0x8B,0x71),
- o2(0x90,0xE9), o2(0x8E,0xBA), o2(0x97,0x47), o2(0x9B,0x81),
- o2(0x8B,0x7B), o2(0x8D,0xC9), o2(0x8A,0x51), o2(0x89,0x83),
- o2(0x8F,0xAA), o2(0x89,0xC6), o2(0x9B,0x82), o2(0x97,0x65),
- o2(0x8F,0x68), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_AE = {
- to_SHIFT_JIS_E5_AE_offsets,
- to_SHIFT_JIS_E5_AE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_AF_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_AF */
- /* used from to_EUC_JP_E5_AF */
- 0, 37, 1, 2, 3, 4, 5, 6, 37, 7, 37, 37, 8, 37, 37, 37,
- 9, 37, 10, 11, 12, 37, 37, 37, 13, 37, 37, 14, 37, 15, 16, 17,
- 37, 18, 19, 37, 20, 21, 22, 23, 24, 25, 37, 26, 27, 37, 28, 37,
- 29, 37, 37, 30, 37, 31, 32, 37, 33, 37, 34, 37, 37, 37, 35, 36,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_AF_infos[38] = {
- o2(0xFA,0xA7), o2(0x8E,0xE2), o2(0x9B,0x83), o2(0x8A,0xF1),
- o2(0x93,0xD0), o2(0x96,0xA7), o2(0x9B,0x84), o2(0x9B,0x85),
- o2(0x95,0x78), o2(0x9B,0x87), o2(0x8A,0xA6), o2(0x8B,0xF5),
- o2(0x9B,0x86), o2(0xFA,0xA9), o2(0x8A,0xB0), o2(0x90,0x51),
- o2(0x9B,0x8B), o2(0x8E,0x40), o2(0x89,0xC7), o2(0x9B,0x8A),
- o2(0x9B,0x88), o2(0x9B,0x8C), o2(0x9B,0x89), o2(0x94,0x4A),
- o2(0x9E,0xCB), o2(0x90,0x52), o2(0x9B,0x8D), o2(0xFA,0xAA),
- o2(0x97,0xBE), o2(0x9B,0x8E), o2(0x9B,0x90), o2(0x92,0x9E),
- o2(0x9B,0x8F), o2(0x90,0xA1), o2(0x8E,0x9B), o2(0x91,0xCE),
- o2(0x8E,0xF5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_AF = {
- to_SHIFT_JIS_E5_AF_offsets,
- to_SHIFT_JIS_E5_AF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B0_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B0 */
- /* used from to_EUC_JP_E5_B0 */
- 32, 0, 1, 32, 2, 3, 4, 5, 6, 7, 8, 9, 32, 10, 11, 12,
- 32, 13, 32, 14, 32, 32, 15, 32, 32, 32, 16, 32, 32, 32, 17, 32,
- 18, 32, 19, 32, 20, 32, 32, 32, 21, 32, 32, 32, 32, 22, 32, 32,
- 32, 23, 32, 32, 32, 32, 32, 32, 24, 25, 26, 27, 28, 29, 30, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B0_infos[33] = {
- o2(0x95,0x95), o2(0x90,0xEA), o2(0x8E,0xCB), o2(0x9B,0x91),
- o2(0x8F,0xAB), o2(0x9B,0x92), o2(0x9B,0x93), o2(0x88,0xD1),
- o2(0x91,0xB8), o2(0x90,0x71), o2(0x9B,0x94), o2(0x93,0xB1),
- o2(0x8F,0xAC), o2(0x8F,0xAD), o2(0x9B,0x95), o2(0x90,0xEB),
- o2(0x8F,0xAE), o2(0xFA,0xAB), o2(0x9B,0x96), o2(0x9B,0x97),
- o2(0x96,0xDE), o2(0x9B,0x98), o2(0x8B,0xC4), o2(0x8F,0x41),
- o2(0x9B,0x99), o2(0x9B,0x9A), o2(0x8E,0xDA), o2(0x90,0x4B),
- o2(0x93,0xF2), o2(0x90,0x73), o2(0x94,0xF6), o2(0x94,0x41),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B0 = {
- to_SHIFT_JIS_E5_B0_offsets,
- to_SHIFT_JIS_E5_B0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B1_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B1 */
- /* used from to_EUC_JP_E5_B1 */
- 0, 1, 25, 25, 25, 2, 3, 25, 4, 25, 5, 6, 25, 7, 8, 9,
- 10, 11, 25, 12, 25, 13, 25, 25, 25, 25, 25, 25, 25, 25, 14, 25,
- 15, 16, 25, 25, 17, 18, 25, 25, 25, 25, 25, 25, 19, 25, 20, 21,
- 25, 22, 25, 25, 25, 25, 23, 25, 25, 24, 25, 25, 25, 25, 25, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B1_infos[26] = {
- o2(0x8B,0xC7), o2(0x9B,0x9B), o2(0x8B,0x8F), o2(0x9B,0x9C),
- o2(0x8B,0xFC), o2(0x93,0xCD), o2(0x89,0xAE), o2(0x8E,0x72),
- o2(0x9B,0x9D), o2(0x9B,0xA0), o2(0x9B,0x9F), o2(0x8B,0xFB),
- o2(0x9B,0x9E), o2(0x93,0x57), o2(0x91,0xAE), o2(0x93,0x6A),
- o2(0x8E,0xC6), o2(0x91,0x77), o2(0x97,0x9A), o2(0x9B,0xA2),
- o2(0x9B,0xA3), o2(0x93,0xD4), o2(0x8E,0x52), o2(0x9B,0xA5),
- o2(0x9B,0xA6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B1 = {
- to_SHIFT_JIS_E5_B1_offsets,
- to_SHIFT_JIS_E5_B1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B2_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B2 */
- /* used from to_EUC_JP_E5_B2 */
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 19, 19, 19,
- 1, 2, 19, 19, 3, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 4, 19, 19, 19, 19, 5, 19, 6, 7, 19, 8, 9, 19, 19, 19,
- 19, 10, 19, 11, 19, 19, 12, 13, 14, 19, 15, 16, 17, 19, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B2_infos[20] = {
- o2(0x9B,0xA7), o2(0x8A,0xF2), o2(0x9B,0xA8), o2(0x9B,0xA9),
- o2(0x89,0xAA), o2(0xFA,0xAC), o2(0x91,0x5A), o2(0x8A,0xE2),
- o2(0x9B,0xAB), o2(0x96,0xA6), o2(0x91,0xD0), o2(0x8A,0x78),
- o2(0x9B,0xAD), o2(0x9B,0xAF), o2(0x8A,0xDD), o2(0xFA,0xAD),
- o2(0x9B,0xAC), o2(0x9B,0xAE), o2(0x9B,0xB1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B2 = {
- to_SHIFT_JIS_E5_B2_offsets,
- to_SHIFT_JIS_E5_B2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B3_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B3 */
- /* used from to_EUC_JP_E5_B3 */
- 16, 16, 16, 16, 16, 0, 16, 1, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 2, 16, 16, 16, 16, 16, 16,
- 3, 4, 16, 16, 16, 16, 16, 16, 5, 6, 7, 16, 16, 8, 16, 9,
- 10, 16, 16, 16, 16, 11, 12, 16, 16, 16, 13, 14, 16, 15, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B3_infos[17] = {
- o2(0x9B,0xB0), o2(0x9B,0xB2), o2(0x9B,0xB3), o2(0x93,0xBB),
- o2(0x8B,0xAC), o2(0x89,0xE3), o2(0x9B,0xB4), o2(0x9B,0xB9),
- o2(0x9B,0xB7), o2(0x95,0xF5), o2(0x95,0xF4), o2(0xFA,0xAE),
- o2(0x93,0x87), o2(0x9B,0xB6), o2(0x8F,0x73), o2(0x9B,0xB5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B3 = {
- to_SHIFT_JIS_E5_B3_offsets,
- to_SHIFT_JIS_E5_B3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B4_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B4 */
- /* used from to_EUC_JP_E5_B4 */
- 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 1, 16, 16, 2, 16,
- 16, 3, 16, 16, 4, 5, 6, 7, 8, 9, 10, 11, 16, 16, 16, 12,
- 16, 16, 13, 16, 16, 16, 16, 14, 16, 15, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B4_infos[17] = {
- o2(0x90,0x92), o2(0x9B,0xBA), o2(0x8D,0xE8), o2(0x9B,0xC0),
- o2(0x9B,0xC1), o2(0x9B,0xBB), o2(0x8A,0x52), o2(0x9B,0xBC),
- o2(0x9B,0xC5), o2(0x9B,0xC4), o2(0x9B,0xC3), o2(0x9B,0xBF),
- o2(0x9B,0xBE), o2(0x9B,0xC2), o2(0xFA,0xAF), o2(0x95,0xF6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B4 = {
- to_SHIFT_JIS_E5_B4_offsets,
- to_SHIFT_JIS_E5_B4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B5_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B5 */
- /* used from to_EUC_JP_E5_B5 */
- 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 1, 2, 14, 3, 14,
- 4, 14, 5, 6, 14, 14, 14, 14, 14, 14, 14, 14, 7, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 8, 14, 14, 9, 10, 14, 11,
- 14, 14, 14, 12, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B5_infos[15] = {
- o2(0xFA,0xB2), o2(0x9B,0xC9), o2(0x9B,0xC6), o2(0x9B,0xC8),
- o2(0x97,0x92), o2(0x9B,0xC7), o2(0xFA,0xB0), o2(0x9B,0xBD),
- o2(0x90,0x93), o2(0x9B,0xCA), o2(0xFA,0xB3), o2(0x8D,0xB5),
- o2(0x9B,0xCB), o2(0x9B,0xCC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B5 = {
- to_SHIFT_JIS_E5_B5_offsets,
- to_SHIFT_JIS_E5_B5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B6_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B6 */
- /* used from to_EUC_JP_E5_B6 */
- 16, 16, 0, 16, 1, 16, 16, 2, 16, 16, 16, 3, 4, 16, 16, 16,
- 5, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 16,
- 16, 16, 7, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 9, 16,
- 16, 16, 16, 16, 16, 16, 16, 10, 11, 12, 13, 16, 14, 15, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B6_infos[17] = {
- o2(0x9B,0xCF), o2(0x9B,0xCE), o2(0x9B,0xCD), o2(0x93,0x88),
- o2(0x9B,0xB8), o2(0x9B,0xD5), o2(0x9B,0xD1), o2(0x9B,0xD0),
- o2(0x9B,0xD2), o2(0x9B,0xD3), o2(0x9B,0xD6), o2(0xFA,0xB4),
- o2(0xFA,0xB5), o2(0x97,0xE4), o2(0x9B,0xD7), o2(0x9B,0xD4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B6 = {
- to_SHIFT_JIS_E5_B6_offsets,
- to_SHIFT_JIS_E5_B6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B7_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B7 */
- /* used from to_EUC_JP_E5_B7 */
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 27, 27, 1, 2, 27, 27,
- 3, 27, 4, 5, 27, 27, 6, 27, 27, 27, 27, 7, 27, 8, 9, 27,
- 27, 10, 27, 11, 27, 12, 13, 14, 15, 27, 27, 16, 27, 27, 17, 27,
- 27, 18, 19, 20, 21, 22, 27, 23, 27, 27, 27, 24, 27, 25, 26, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B7_infos[28] = {
- o2(0x9B,0xD8), o2(0x8A,0xDE), o2(0x9B,0xD9), o2(0xFA,0xB6),
- o2(0x9B,0xDB), o2(0x9B,0xDA), o2(0x9B,0xDC), o2(0x9B,0xDD),
- o2(0x90,0xEC), o2(0x8F,0x42), o2(0x8F,0x84), o2(0x91,0x83),
- o2(0x8D,0x48), o2(0x8D,0xB6), o2(0x8D,0x49), o2(0x8B,0x90),
- o2(0x9B,0xDE), o2(0x8D,0xB7), o2(0x8C,0xC8), o2(0x9B,0xDF),
- o2(0x96,0xA4), o2(0x94,0x62), o2(0x9B,0xE0), o2(0x8D,0x4A),
- o2(0x8A,0xAA), o2(0x92,0x46), o2(0x8B,0xD0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B7 = {
- to_SHIFT_JIS_E5_B7_offsets,
- to_SHIFT_JIS_E5_B7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B8_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B8 */
- /* used from to_EUC_JP_E5_B8 */
- 21, 21, 0, 1, 21, 21, 2, 21, 21, 21, 21, 3, 4, 21, 21, 21,
- 21, 5, 21, 21, 21, 21, 6, 21, 21, 7, 8, 9, 21, 10, 21, 21,
- 21, 21, 21, 21, 21, 11, 21, 21, 21, 21, 21, 12, 21, 13, 21, 14,
- 15, 21, 21, 16, 21, 21, 17, 18, 19, 21, 21, 21, 21, 20, 21, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B8_infos[22] = {
- o2(0x8E,0x73), o2(0x95,0x7A), o2(0x94,0xBF), o2(0x9B,0xE1),
- o2(0x8A,0xF3), o2(0x9B,0xE4), o2(0x92,0x9F), o2(0x9B,0xE3),
- o2(0x9B,0xE2), o2(0x9B,0xE5), o2(0x92,0xE9), o2(0x90,0x83),
- o2(0x8E,0x74), o2(0x90,0xC8), o2(0x91,0xD1), o2(0x8B,0x41),
- o2(0x92,0xA0), o2(0x9B,0xE6), o2(0x9B,0xE7), o2(0x8F,0xED),
- o2(0x96,0x58), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B8 = {
- to_SHIFT_JIS_E5_B8_offsets,
- to_SHIFT_JIS_E5_B8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_B9_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_B9 */
- /* used from to_EUC_JP_E5_B9 */
- 0, 28, 28, 1, 2, 3, 28, 4, 28, 28, 28, 28, 5, 28, 6, 28,
- 28, 28, 28, 28, 7, 8, 28, 9, 28, 28, 28, 28, 28, 28, 28, 10,
- 28, 11, 12, 13, 14, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 15, 16, 17, 18, 19, 28, 20, 21, 22, 23, 24, 25, 26, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_B9_infos[29] = {
- o2(0x9B,0xEA), o2(0x9B,0xE9), o2(0x9B,0xE8), o2(0x95,0x9D),
- o2(0x9B,0xF1), o2(0x96,0x79), o2(0x9B,0xEB), o2(0x9B,0xED),
- o2(0x96,0x8B), o2(0x9B,0xEC), o2(0x9B,0xEE), o2(0x94,0xA6),
- o2(0x9B,0xEF), o2(0x95,0xBC), o2(0x9B,0xF0), o2(0x8A,0xB1),
- o2(0x95,0xBD), o2(0x94,0x4E), o2(0x9B,0xF2), o2(0x9B,0xF3),
- o2(0x8D,0x4B), o2(0x8A,0xB2), o2(0x9B,0xF4), o2(0x8C,0xB6),
- o2(0x97,0x63), o2(0x97,0x48), o2(0x8A,0xF4), o2(0x9B,0xF6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_B9 = {
- to_SHIFT_JIS_E5_B9_offsets,
- to_SHIFT_JIS_E5_B9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_BA_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_BA */
- /* used from to_EUC_JP_E5_BA */
- 20, 0, 20, 1, 2, 20, 20, 3, 20, 20, 4, 20, 20, 20, 20, 5,
- 20, 20, 20, 20, 20, 6, 7, 8, 20, 20, 9, 20, 10, 20, 20, 20,
- 11, 20, 20, 20, 20, 20, 12, 13, 20, 20, 20, 14, 20, 15, 20, 20,
- 20, 20, 20, 20, 20, 16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_BA_infos[21] = {
- o2(0x92,0xA1), o2(0x8D,0x4C), o2(0x8F,0xAF), o2(0x94,0xDD),
- o2(0x8F,0xB0), o2(0x8F,0x98), o2(0x92,0xEA), o2(0x95,0xF7),
- o2(0x93,0x58), o2(0x8D,0x4D), o2(0x95,0x7B), o2(0x9B,0xF7),
- o2(0x93,0x78), o2(0x8D,0xC0), o2(0x8C,0xC9), o2(0x92,0xEB),
- o2(0x88,0xC1), o2(0x8F,0x8E), o2(0x8D,0x4E), o2(0x97,0x66),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_BA = {
- to_SHIFT_JIS_E5_BA_offsets,
- to_SHIFT_JIS_E5_BA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_BB_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_BB */
- /* used from to_EUC_JP_E5_BB */
- 33, 0, 1, 2, 33, 33, 33, 33, 3, 4, 5, 33, 33, 33, 33, 6,
- 7, 33, 33, 8, 33, 33, 9, 33, 33, 33, 10, 11, 33, 12, 33, 13,
- 14, 15, 16, 17, 33, 33, 33, 33, 18, 19, 33, 33, 20, 33, 33, 33,
- 21, 22, 33, 23, 24, 33, 25, 26, 27, 33, 28, 29, 30, 33, 31, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_BB_infos[34] = {
- o2(0x9B,0xF8), o2(0x9B,0xF9), o2(0x94,0x70), o2(0x9B,0xFA),
- o2(0x97,0xF5), o2(0x98,0x4C), o2(0x9B,0xFC), o2(0x9B,0xFB),
- o2(0x8A,0x66), o2(0x9C,0x40), o2(0x9C,0x43), o2(0x9C,0x44),
- o2(0x9C,0x42), o2(0x95,0x5F), o2(0x8F,0xB1), o2(0x9C,0x46),
- o2(0x9C,0x45), o2(0x9C,0x41), o2(0x9C,0x47), o2(0x9C,0x48),
- o2(0x9C,0x49), o2(0x9C,0x4C), o2(0x9C,0x4A), o2(0x9C,0x4B),
- o2(0x9C,0x4D), o2(0x89,0x84), o2(0x92,0xEC), o2(0x9C,0x4E),
- o2(0x8C,0x9A), o2(0x89,0xF4), o2(0x94,0x55), o2(0x9C,0x4F),
- o2(0x93,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_BB = {
- to_SHIFT_JIS_E5_BB_offsets,
- to_SHIFT_JIS_E5_BB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_BC */
- /* used from to_EUC_JP_E5_BC */
- 33, 0, 33, 1, 2, 33, 33, 33, 33, 3, 4, 5, 6, 7, 33, 8,
- 9, 10, 33, 11, 12, 13, 14, 15, 16, 33, 33, 17, 33, 33, 33, 18,
- 33, 19, 33, 33, 33, 20, 21, 22, 33, 23, 33, 33, 33, 24, 33, 25,
- 33, 26, 33, 33, 27, 28, 33, 29, 30, 33, 33, 33, 31, 33, 32, 33,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_BC_infos[34] = {
- o2(0x95,0xD9), o2(0x9C,0x50), o2(0x98,0x4D), o2(0x9C,0x51),
- o2(0x95,0xBE), o2(0x9C,0x54), o2(0x98,0x9F), o2(0x98,0xAF),
- o2(0x8E,0xAE), o2(0x93,0xF3), o2(0x9C,0x55), o2(0x8B,0x7C),
- o2(0x92,0xA2), o2(0x88,0xF8), o2(0x9C,0x56), o2(0x95,0xA4),
- o2(0x8D,0x4F), o2(0x92,0x6F), o2(0x92,0xED), o2(0xFA,0xB7),
- o2(0x96,0xED), o2(0x8C,0xB7), o2(0x8C,0xCA), o2(0x9C,0x57),
- o2(0x9C,0x58), o2(0x9C,0x5E), o2(0x8E,0xE3), o2(0xFA,0xB8),
- o2(0x92,0xA3), o2(0x8B,0xAD), o2(0x9C,0x59), o2(0x95,0x4A),
- o2(0x92,0x65), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_BC = {
- to_SHIFT_JIS_E5_BC_offsets,
- to_SHIFT_JIS_E5_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_BD */
- /* used from to_EUC_JP_E5_BD */
- 29, 0, 29, 29, 29, 1, 29, 29, 2, 29, 3, 29, 4, 29, 5, 29,
- 29, 6, 29, 7, 29, 29, 8, 9, 29, 10, 29, 29, 11, 12, 29, 29,
- 29, 13, 14, 29, 29, 29, 15, 16, 29, 17, 18, 19, 20, 21, 29, 29,
- 22, 23, 29, 24, 29, 29, 29, 25, 29, 26, 29, 29, 27, 29, 29, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_BD_infos[30] = {
- o2(0x9C,0x5A), o2(0xFA,0x67), o2(0x9C,0x5B), o2(0x8B,0xAE),
- o2(0x9C,0x5C), o2(0x9C,0x5D), o2(0x9C,0x5F), o2(0x93,0x96),
- o2(0x9C,0x60), o2(0x9C,0x61), o2(0x9C,0x62), o2(0x9C,0x53),
- o2(0x9C,0x52), o2(0x9C,0x63), o2(0x8C,0x60), o2(0x95,0x46),
- o2(0xFA,0xB9), o2(0x8D,0xCA), o2(0x95,0x56), o2(0x92,0xA4),
- o2(0x95,0x6A), o2(0x9C,0x64), o2(0x8F,0xB2), o2(0x89,0x65),
- o2(0x9C,0x65), o2(0x9C,0x66), o2(0x96,0xF0), o2(0x94,0xDE),
- o2(0x9C,0x69), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_BD = {
- to_SHIFT_JIS_E5_BD_offsets,
- to_SHIFT_JIS_E5_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_BE */
- /* used from to_EUC_JP_E5_BE */
- 0, 1, 2, 3, 4, 5, 32, 6, 7, 32, 8, 9, 10, 32, 32, 32,
- 11, 12, 13, 14, 32, 32, 32, 15, 16, 17, 32, 32, 32, 32, 18, 32,
- 19, 20, 32, 32, 32, 32, 32, 32, 21, 22, 23, 32, 32, 24, 25, 32,
- 32, 32, 32, 26, 27, 32, 32, 28, 32, 29, 32, 32, 30, 31, 32, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_BE_infos[33] = {
- o2(0x89,0x9D), o2(0x90,0xAA), o2(0x9C,0x68), o2(0x9C,0x67),
- o2(0x8C,0x61), o2(0x91,0xD2), o2(0x9C,0x6D), o2(0x9C,0x6B),
- o2(0x9C,0x6A), o2(0x97,0xA5), o2(0x8C,0xE3), o2(0x8F,0x99),
- o2(0x9C,0x6C), o2(0x93,0x6B), o2(0x8F,0x5D), o2(0x93,0xBE),
- o2(0x9C,0x70), o2(0x9C,0x6F), o2(0x9C,0x6E), o2(0x9C,0x71),
- o2(0x8C,0xE4), o2(0x9C,0x72), o2(0x95,0x9C), o2(0x8F,0x7A),
- o2(0x9C,0x73), o2(0x94,0xF7), o2(0x93,0xBF), o2(0x92,0xA5),
- o2(0xFA,0xBA), o2(0x93,0x4F), o2(0x9C,0x74), o2(0x8B,0x4A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_BE = {
- to_SHIFT_JIS_E5_BE_offsets,
- to_SHIFT_JIS_E5_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_BF_offsets[64] = {
- /* used from to_SHIFT_JIS_E5_BF */
- /* used from to_EUC_JP_E5_BF */
- 21, 21, 21, 0, 21, 1, 21, 21, 21, 21, 21, 21, 2, 3, 21, 21,
- 21, 21, 21, 21, 21, 21, 4, 5, 6, 7, 21, 21, 8, 9, 10, 21,
- 11, 21, 21, 21, 12, 21, 21, 21, 21, 21, 21, 13, 21, 21, 21, 21,
- 14, 15, 21, 21, 21, 16, 21, 21, 17, 21, 21, 18, 21, 19, 21, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_BF_infos[22] = {
- o2(0x90,0x53), o2(0x95,0x4B), o2(0x8A,0xF5), o2(0x94,0x45),
- o2(0x9C,0x75), o2(0x8E,0x75), o2(0x96,0x59), o2(0x96,0x5A),
- o2(0x89,0x9E), o2(0x9C,0x7A), o2(0xFA,0xBB), o2(0x92,0x89),
- o2(0x9C,0x77), o2(0x89,0xF5), o2(0x9C,0xAB), o2(0x9C,0x79),
- o2(0x94,0x4F), o2(0x9C,0x78), o2(0x9C,0x76), o2(0x8D,0x9A),
- o2(0x9C,0x7C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5_BF = {
- to_SHIFT_JIS_E5_BF_offsets,
- to_SHIFT_JIS_E5_BF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E5_offsets[64] = {
- /* used from to_SHIFT_JIS_E5 */
- /* used from to_SHIFT_JIS_E6 */
- /* used from to_EUC_JP_E5 */
- /* used from to_EUC_JP_E6 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E5_infos[64] = {
- &to_SHIFT_JIS_E5_80, &to_SHIFT_JIS_E5_81,
- &to_SHIFT_JIS_E5_82, &to_SHIFT_JIS_E5_83,
- &to_SHIFT_JIS_E5_84, &to_SHIFT_JIS_E5_85,
- &to_SHIFT_JIS_E5_86, &to_SHIFT_JIS_E5_87,
- &to_SHIFT_JIS_E5_88, &to_SHIFT_JIS_E5_89,
- &to_SHIFT_JIS_E5_8A, &to_SHIFT_JIS_E5_8B,
- &to_SHIFT_JIS_E5_8C, &to_SHIFT_JIS_E5_8D,
- &to_SHIFT_JIS_E5_8E, &to_SHIFT_JIS_E5_8F,
- &to_SHIFT_JIS_E5_90, &to_SHIFT_JIS_E5_91,
- &to_SHIFT_JIS_E5_92, &to_SHIFT_JIS_E5_93,
- &to_SHIFT_JIS_E5_94, &to_SHIFT_JIS_E5_95,
- &to_SHIFT_JIS_E5_96, &to_SHIFT_JIS_E5_97,
- &to_SHIFT_JIS_E5_98, &to_SHIFT_JIS_E5_99,
- &to_SHIFT_JIS_E5_9A, &to_SHIFT_JIS_E5_9B,
- &to_SHIFT_JIS_E5_9C, &to_SHIFT_JIS_E5_9D,
- &to_SHIFT_JIS_E5_9E, &to_SHIFT_JIS_E5_9F,
- &to_SHIFT_JIS_E5_A0, &to_SHIFT_JIS_E5_A1,
- &to_SHIFT_JIS_E5_A2, &to_SHIFT_JIS_E5_A3,
- &to_SHIFT_JIS_E5_A4, &to_SHIFT_JIS_E5_A5,
- &to_SHIFT_JIS_E5_A6, &to_SHIFT_JIS_E5_A7,
- &to_SHIFT_JIS_E5_A8, &to_SHIFT_JIS_E5_A9,
- &to_SHIFT_JIS_E5_AA, &to_SHIFT_JIS_E5_AB,
- &to_SHIFT_JIS_E5_AC, &to_SHIFT_JIS_E5_AD,
- &to_SHIFT_JIS_E5_AE, &to_SHIFT_JIS_E5_AF,
- &to_SHIFT_JIS_E5_B0, &to_SHIFT_JIS_E5_B1,
- &to_SHIFT_JIS_E5_B2, &to_SHIFT_JIS_E5_B3,
- &to_SHIFT_JIS_E5_B4, &to_SHIFT_JIS_E5_B5,
- &to_SHIFT_JIS_E5_B6, &to_SHIFT_JIS_E5_B7,
- &to_SHIFT_JIS_E5_B8, &to_SHIFT_JIS_E5_B9,
- &to_SHIFT_JIS_E5_BA, &to_SHIFT_JIS_E5_BB,
- &to_SHIFT_JIS_E5_BC, &to_SHIFT_JIS_E5_BD,
- &to_SHIFT_JIS_E5_BE, &to_SHIFT_JIS_E5_BF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E5 = {
- to_SHIFT_JIS_E5_offsets,
- to_SHIFT_JIS_E5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_80 */
- /* used from to_EUC_JP_E6_80 */
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 1,
- 2, 22, 3, 22, 22, 4, 5, 22, 22, 6, 22, 7, 8, 9, 22, 22,
- 10, 11, 22, 22, 22, 12, 13, 14, 15, 16, 17, 18, 22, 22, 22, 19,
- 22, 20, 22, 22, 22, 22, 22, 22, 22, 22, 21, 22, 22, 22, 22, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_80_infos[23] = {
- o2(0x9C,0x83), o2(0x9C,0x89), o2(0x9C,0x81), o2(0x93,0x7B),
- o2(0x9C,0x86), o2(0x95,0x7C), o2(0x9C,0x80), o2(0x9C,0x85),
- o2(0x97,0xE5), o2(0x8E,0x76), o2(0x91,0xD3), o2(0x9C,0x7D),
- o2(0x8B,0x7D), o2(0x9C,0x88), o2(0x90,0xAB), o2(0x89,0x85),
- o2(0x9C,0x82), o2(0x89,0xF6), o2(0x9C,0x87), o2(0x8B,0xAF),
- o2(0x9C,0x84), o2(0x9C,0x8A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_80 = {
- to_SHIFT_JIS_E6_80_offsets,
- to_SHIFT_JIS_E6_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_81_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_81 */
- /* used from to_EUC_JP_E6_81 */
- 29, 0, 1, 2, 29, 29, 3, 29, 29, 29, 4, 5, 29, 6, 29, 29,
- 7, 29, 8, 29, 29, 9, 29, 29, 29, 10, 11, 29, 29, 12, 29, 13,
- 14, 29, 15, 16, 17, 18, 29, 29, 19, 20, 21, 22, 23, 24, 29, 25,
- 26, 29, 29, 29, 29, 27, 29, 28, 29, 29, 29, 29, 29, 29, 29, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_81_infos[30] = {
- o2(0x9C,0x8C), o2(0x9C,0x96), o2(0x9C,0x94), o2(0x9C,0x91),
- o2(0x9C,0x90), o2(0x97,0xF6), o2(0x9C,0x92), o2(0x8B,0xB0),
- o2(0x8D,0x50), o2(0x8F,0x9A), o2(0x9C,0x99), o2(0x9C,0x8B),
- o2(0xFA,0xBC), o2(0x9C,0x8F), o2(0x9C,0x7E), o2(0x89,0xF8),
- o2(0x9C,0x93), o2(0x9C,0x95), o2(0x92,0x70), o2(0x8D,0xA6),
- o2(0x89,0xB6), o2(0x9C,0x8D), o2(0x9C,0x98), o2(0x9C,0x97),
- o2(0x8B,0xB1), o2(0x91,0xA7), o2(0x8A,0x86), o2(0x8C,0x62),
- o2(0x9C,0x8E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_81 = {
- to_SHIFT_JIS_E6_81_offsets,
- to_SHIFT_JIS_E6_81_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_82_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_82 */
- /* used from to_EUC_JP_E6_82 */
- 30, 0, 30, 1, 2, 3, 30, 30, 30, 4, 5, 6, 7, 8, 30, 30,
- 30, 30, 9, 30, 10, 30, 11, 12, 30, 30, 13, 14, 30, 30, 30, 15,
- 16, 30, 30, 17, 30, 30, 18, 19, 30, 20, 21, 30, 30, 30, 30, 30,
- 30, 30, 22, 23, 24, 25, 26, 30, 27, 30, 30, 30, 28, 29, 30, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_82_infos[31] = {
- o2(0x9C,0x9A), o2(0x9C,0x9D), o2(0x9C,0x9F), o2(0xFA,0xBD),
- o2(0x8E,0xBB), o2(0xFA,0xBE), o2(0x9C,0xA5), o2(0x92,0xEE),
- o2(0x9C,0x9B), o2(0x9C,0xA3), o2(0x89,0xF7), o2(0x9C,0xA1),
- o2(0x9C,0xA2), o2(0x9C,0x9E), o2(0x9C,0xA0), o2(0x8C,0xE5),
- o2(0x97,0x49), o2(0x8A,0xB3), o2(0x89,0x78), o2(0x9C,0xA4),
- o2(0x94,0x59), o2(0x88,0xAB), o2(0x94,0xDF), o2(0x9C,0x7B),
- o2(0x9C,0xAA), o2(0x9C,0xAE), o2(0x96,0xE3), o2(0x9C,0xA7),
- o2(0x93,0x89), o2(0x9C,0xAC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_82 = {
- to_SHIFT_JIS_E6_82_offsets,
- to_SHIFT_JIS_E6_82_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_83_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_83 */
- /* used from to_EUC_JP_E6_83 */
- 26, 26, 26, 26, 26, 0, 1, 2, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 3, 26, 4, 26, 5, 26, 26, 6, 26, 7, 26, 8, 26, 9, 10,
- 11, 12, 26, 13, 26, 26, 26, 14, 15, 26, 26, 26, 26, 26, 26, 26,
- 16, 17, 18, 19, 20, 26, 21, 22, 26, 23, 24, 25, 26, 26, 26, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_83_infos[27] = {
- o2(0x8F,0xEE), o2(0x9C,0xAD), o2(0x93,0xD5), o2(0x98,0x66),
- o2(0x9C,0xA9), o2(0xFA,0xC0), o2(0x9C,0xAF), o2(0x8D,0x9B),
- o2(0x90,0xC9), o2(0xFA,0xBF), o2(0x88,0xD2), o2(0x9C,0xA8),
- o2(0x9C,0xA6), o2(0x91,0x79), o2(0x9C,0x9C), o2(0x8E,0x53),
- o2(0x91,0xC4), o2(0x9C,0xBB), o2(0xFA,0xC2), o2(0x91,0x7A),
- o2(0x9C,0xB6), o2(0x9C,0xB3), o2(0x9C,0xB4), o2(0x8E,0xE4),
- o2(0x9C,0xB7), o2(0x9C,0xBA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_83 = {
- to_SHIFT_JIS_E6_83_offsets,
- to_SHIFT_JIS_E6_83_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_84_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_84 */
- /* used from to_EUC_JP_E6_84 */
- 0, 1, 26, 2, 26, 26, 3, 26, 4, 5, 26, 26, 26, 6, 7, 8,
- 26, 9, 26, 26, 26, 10, 26, 26, 26, 26, 11, 12, 26, 26, 26, 13,
- 14, 15, 26, 26, 26, 26, 26, 16, 17, 26, 26, 26, 18, 26, 26, 26,
- 19, 26, 26, 26, 20, 26, 26, 21, 26, 26, 26, 26, 22, 23, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_84_infos[27] = {
- o2(0x9C,0xB5), o2(0x8F,0x44), o2(0x9C,0xB8), o2(0x9C,0xB2),
- o2(0x96,0xFA), o2(0x96,0xF9), o2(0x9C,0xBC), o2(0x9C,0xBD),
- o2(0x88,0xD3), o2(0xFA,0xC3), o2(0x9C,0xB1), o2(0x8B,0xF0),
- o2(0x88,0xA4), o2(0x8A,0xB4), o2(0xFA,0xC1), o2(0x9C,0xB9),
- o2(0x9C,0xC1), o2(0x9C,0xC0), o2(0x9C,0xC5), o2(0xFA,0xC5),
- o2(0x9C,0xC6), o2(0xFA,0xC4), o2(0x9C,0xC4), o2(0x9C,0xC7),
- o2(0x9C,0xBF), o2(0x9C,0xC3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_84 = {
- to_SHIFT_JIS_E6_84_offsets,
- to_SHIFT_JIS_E6_84_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_85_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_85 */
- /* used from to_EUC_JP_E6_85 */
- 32, 32, 0, 32, 1, 32, 32, 2, 3, 32, 4, 5, 6, 7, 8, 32,
- 32, 32, 32, 9, 32, 10, 32, 32, 11, 12, 13, 32, 32, 14, 32, 15,
- 32, 32, 16, 17, 32, 18, 32, 19, 20, 32, 32, 21, 32, 32, 22, 23,
- 24, 25, 32, 26, 27, 28, 29, 30, 32, 32, 32, 32, 32, 32, 31, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_85_infos[33] = {
- o2(0x9C,0xC8), o2(0x9C,0xC9), o2(0x9C,0xBE), o2(0x8E,0x9C),
- o2(0x9C,0xC2), o2(0x91,0xD4), o2(0x8D,0x51), o2(0x9C,0xB0),
- o2(0x90,0x54), o2(0x9C,0xD6), o2(0x95,0xE7), o2(0x9C,0xCC),
- o2(0x9C,0xCD), o2(0x9C,0xCE), o2(0x9C,0xD5), o2(0x9C,0xD4),
- o2(0x96,0x9D), o2(0x8A,0xB5), o2(0x9C,0xD2), o2(0x8C,0x64),
- o2(0x8A,0x53), o2(0x9C,0xCF), o2(0x97,0xB6), o2(0x9C,0xD1),
- o2(0x88,0xD4), o2(0x9C,0xD3), o2(0x9C,0xCA), o2(0x9C,0xD0),
- o2(0x9C,0xD7), o2(0x8C,0x63), o2(0x9C,0xCB), o2(0x97,0x7C),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_85 = {
- to_SHIFT_JIS_E6_85_offsets,
- to_SHIFT_JIS_E6_85_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_86_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_86 */
- /* used from to_EUC_JP_E6_86 */
- 21, 21, 0, 21, 21, 21, 21, 1, 21, 21, 2, 21, 21, 21, 3, 21,
- 4, 5, 21, 21, 6, 21, 7, 21, 8, 9, 10, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 11, 21, 21, 12, 21, 13, 21, 14, 15, 21, 16, 21,
- 21, 21, 17, 21, 21, 21, 18, 21, 21, 21, 19, 21, 21, 21, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_86_infos[22] = {
- o2(0x97,0x4A), o2(0x9C,0xDA), o2(0x9C,0xDE), o2(0x91,0x9E),
- o2(0x97,0xF7), o2(0x9C,0xDF), o2(0x9C,0xDC), o2(0x9C,0xD9),
- o2(0xFA,0xC6), o2(0x9C,0xD8), o2(0x9C,0xDD), o2(0x95,0xAE),
- o2(0x93,0xB2), o2(0x8C,0x65), o2(0x9C,0xE0), o2(0x9C,0xDB),
- o2(0x9C,0xE1), o2(0x8C,0x9B), o2(0x89,0xAF), o2(0x9C,0xE9),
- o2(0x8A,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_86 = {
- to_SHIFT_JIS_E6_86_offsets,
- to_SHIFT_JIS_E6_86_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_87_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_87 */
- /* used from to_EUC_JP_E6_87 */
- 22, 22, 22, 0, 22, 22, 1, 2, 3, 4, 5, 6, 7, 8, 22, 22,
- 9, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 10, 22, 22, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 12, 22, 13, 22, 14, 15, 16, 22, 17, 22, 18, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_87_infos[23] = {
- o2(0x9C,0xE7), o2(0x9C,0xE8), o2(0x8D,0xA7), o2(0x9C,0xE6),
- o2(0x9C,0xE4), o2(0x9C,0xE3), o2(0x9C,0xEA), o2(0x9C,0xE2),
- o2(0x9C,0xEC), o2(0x89,0xF9), o2(0x9C,0xEE), o2(0x9C,0xED),
- o2(0x92,0xA6), o2(0x9C,0xF1), o2(0x9C,0xEF), o2(0x9C,0xE5),
- o2(0x8C,0x9C), o2(0x9C,0xF0), o2(0x9C,0xF4), o2(0x9C,0xF3),
- o2(0x9C,0xF5), o2(0x9C,0xF2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_87 = {
- to_SHIFT_JIS_E6_87_offsets,
- to_SHIFT_JIS_E6_87_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_88 */
- /* used from to_EUC_JP_E6_88 */
- 0, 30, 30, 30, 30, 30, 30, 30, 1, 2, 3, 30, 4, 5, 6, 30,
- 7, 8, 9, 10, 11, 30, 12, 30, 30, 30, 13, 14, 30, 15, 16, 17,
- 30, 18, 30, 30, 30, 30, 19, 30, 30, 30, 20, 30, 30, 30, 21, 22,
- 23, 30, 24, 25, 26, 30, 30, 30, 27, 30, 30, 28, 30, 30, 30, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_88_infos[31] = {
- o2(0x9C,0xF6), o2(0x9C,0xF7), o2(0x9C,0xF8), o2(0x95,0xE8),
- o2(0x9C,0xFA), o2(0x9C,0xF9), o2(0x8F,0x5E), o2(0x90,0xAC),
- o2(0x89,0xE4), o2(0x89,0xFA), o2(0xFA,0xC7), o2(0x9C,0xFB),
- o2(0x88,0xBD), o2(0x90,0xCA), o2(0x9C,0xFC), o2(0xE6,0xC1),
- o2(0x9D,0x40), o2(0x8C,0x81), o2(0x9D,0x41), o2(0x90,0xED),
- o2(0x9D,0x42), o2(0x9D,0x43), o2(0x8B,0x59), o2(0x9D,0x44),
- o2(0x9D,0x45), o2(0x9D,0x46), o2(0x91,0xD5), o2(0x8C,0xCB),
- o2(0x96,0xDF), o2(0x96,0x5B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_88 = {
- to_SHIFT_JIS_E6_88_offsets,
- to_SHIFT_JIS_E6_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_89_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_89 */
- /* used from to_EUC_JP_E6_89 */
- 0, 1, 23, 23, 23, 23, 23, 2, 3, 4, 23, 5, 23, 6, 7, 23,
- 23, 23, 23, 8, 23, 9, 23, 23, 10, 23, 23, 11, 23, 23, 12, 23,
- 13, 23, 23, 14, 23, 23, 23, 23, 15, 23, 23, 23, 23, 23, 16, 23,
- 23, 17, 23, 23, 23, 23, 18, 23, 23, 19, 23, 23, 20, 23, 21, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_89_infos[24] = {
- o2(0x8F,0x8A), o2(0x9D,0x47), o2(0x90,0xEE), o2(0xE7,0xBB),
- o2(0x94,0xE0), o2(0x8E,0xE8), o2(0x8D,0xCB), o2(0x9D,0x48),
- o2(0x91,0xC5), o2(0x95,0xA5), o2(0x91,0xEF), o2(0x9D,0x4B),
- o2(0x9D,0x49), o2(0x9D,0x4C), o2(0x9D,0x4A), o2(0x9D,0x4D),
- o2(0x95,0xAF), o2(0x88,0xB5), o2(0x95,0x7D), o2(0x94,0xE1),
- o2(0x9D,0x4E), o2(0x9D,0x51), o2(0x8F,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_89 = {
- to_SHIFT_JIS_E6_89_offsets,
- to_SHIFT_JIS_E6_89_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_8A */
- /* used from to_EUC_JP_E6_8A */
- 0, 26, 1, 2, 3, 26, 26, 26, 26, 4, 5, 26, 26, 26, 26, 26,
- 26, 6, 7, 8, 9, 10, 11, 12, 13, 26, 26, 14, 15, 26, 16, 26,
- 26, 26, 26, 26, 26, 26, 17, 26, 26, 26, 26, 18, 19, 26, 26, 26,
- 26, 20, 26, 26, 26, 21, 26, 26, 26, 22, 26, 23, 24, 25, 26, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_8A_infos[27] = {
- o2(0x8B,0x5A), o2(0x9D,0x4F), o2(0x9D,0x56), o2(0x8F,0xB4),
- o2(0x9D,0x50), o2(0x94,0x63), o2(0x97,0x7D), o2(0x9D,0x52),
- o2(0x9D,0x53), o2(0x9D,0x57), o2(0x93,0x8A), o2(0x9D,0x54),
- o2(0x8D,0x52), o2(0x90,0xDC), o2(0x9D,0x65), o2(0x94,0xB2),
- o2(0x91,0xF0), o2(0xFA,0xC8), o2(0x94,0xE2), o2(0x9D,0xAB),
- o2(0x95,0xF8), o2(0x92,0xEF), o2(0x96,0x95), o2(0x9D,0x5A),
- o2(0x89,0x9F), o2(0x92,0x8A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_8A = {
- to_SHIFT_JIS_E6_8A_offsets,
- to_SHIFT_JIS_E6_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_8B_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_8B */
- /* used from to_EUC_JP_E6_8B */
- 34, 34, 0, 34, 34, 1, 2, 3, 4, 5, 6, 34, 7, 8, 34, 9,
- 10, 11, 12, 13, 14, 34, 34, 15, 16, 17, 34, 18, 19, 20, 34, 34,
- 21, 22, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 23, 24, 25, 26,
- 34, 27, 34, 28, 34, 29, 30, 31, 34, 34, 34, 34, 34, 34, 32, 33,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_8B_infos[35] = {
- o2(0x9D,0x63), o2(0x92,0x53), o2(0x9D,0x5D), o2(0x9D,0x64),
- o2(0x9D,0x5F), o2(0x9D,0x66), o2(0x9D,0x62), o2(0x9D,0x61),
- o2(0x94,0x8F), o2(0x9D,0x5B), o2(0x89,0xFB), o2(0x9D,0x59),
- o2(0x8B,0x91), o2(0x91,0xF1), o2(0x9D,0x55), o2(0x9D,0x58),
- o2(0x8D,0x53), o2(0x90,0xD9), o2(0x8F,0xB5), o2(0x9D,0x60),
- o2(0x94,0x71), o2(0x8B,0x92), o2(0x8A,0x67), o2(0x8A,0x87),
- o2(0x90,0x40), o2(0x9D,0x68), o2(0x9D,0x6D), o2(0x9D,0x69),
- o2(0x8C,0x9D), o2(0x9D,0x6E), o2(0x8E,0x41), o2(0x8D,0x89),
- o2(0x8F,0x45), o2(0x9D,0x5C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_8B = {
- to_SHIFT_JIS_E6_8B_offsets,
- to_SHIFT_JIS_E6_8B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_8C */
- /* used from to_EUC_JP_E6_8C */
- 17, 0, 1, 17, 17, 17, 17, 2, 3, 4, 17, 17, 5, 17, 17, 17,
- 17, 6, 17, 17, 17, 17, 17, 17, 17, 7, 17, 17, 17, 17, 17, 8,
- 17, 17, 17, 17, 17, 17, 17, 9, 10, 17, 17, 11, 17, 17, 17, 12,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 13, 17, 17, 14, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_8C_infos[18] = {
- o2(0x8E,0x9D), o2(0x9D,0x6B), o2(0x8E,0x77), o2(0x9D,0x6C),
- o2(0x88,0xC2), o2(0x9D,0x67), o2(0x92,0xA7), o2(0x8B,0x93),
- o2(0x8B,0xB2), o2(0x9D,0x6A), o2(0x88,0xA5), o2(0x8D,0xC1),
- o2(0x90,0x55), o2(0x92,0xF0), o2(0x94,0xD2), o2(0x9D,0x70),
- o2(0x91,0x7D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_8C = {
- to_SHIFT_JIS_E6_8C_offsets,
- to_SHIFT_JIS_E6_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_8D_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_8D */
- /* used from to_EUC_JP_E6_8D */
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 18, 18, 1, 2, 18, 3,
- 4, 18, 18, 18, 18, 5, 18, 6, 18, 18, 18, 18, 7, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 8, 9, 10, 18, 11, 18, 18, 12, 18,
- 18, 18, 13, 18, 18, 18, 14, 15, 18, 18, 16, 17, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_8D_infos[19] = {
- o2(0x91,0xA8), o2(0x8E,0x4A), o2(0x9D,0x71), o2(0x9D,0x73),
- o2(0x9D,0x6F), o2(0x95,0xDF), o2(0x92,0xBB), o2(0x91,0x7B),
- o2(0x95,0xF9), o2(0x8E,0xCC), o2(0x9D,0x80), o2(0x9D,0x7E),
- o2(0x90,0x98), o2(0x8C,0x9E), o2(0x9D,0x78), o2(0x8F,0xB7),
- o2(0x93,0xE6), o2(0x94,0x50), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_8D = {
- to_SHIFT_JIS_E6_8D_offsets,
- to_SHIFT_JIS_E6_8D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_8E_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_8E */
- /* used from to_EUC_JP_E6_8E */
- 0, 28, 28, 1, 28, 28, 28, 28, 2, 3, 28, 28, 4, 28, 5, 6,
- 28, 28, 7, 28, 28, 28, 8, 28, 9, 28, 28, 10, 28, 28, 28, 11,
- 12, 13, 14, 15, 28, 16, 28, 17, 18, 19, 20, 21, 22, 28, 28, 28,
- 28, 28, 23, 28, 24, 25, 28, 28, 28, 28, 28, 26, 28, 28, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_8E_infos[29] = {
- o2(0x9D,0x76), o2(0x91,0x7C), o2(0x8E,0xF6), o2(0x9D,0x7B),
- o2(0x8F,0xB6), o2(0x9D,0x75), o2(0x9D,0x7A), o2(0x94,0x72),
- o2(0x9D,0x74), o2(0x8C,0x40), o2(0x8A,0x7C), o2(0x9D,0x7C),
- o2(0x97,0xA9), o2(0x8D,0xCC), o2(0x92,0x54), o2(0x9D,0x79),
- o2(0x90,0xDA), o2(0x8D,0x54), o2(0x90,0x84), o2(0x89,0x86),
- o2(0x91,0x5B), o2(0x9D,0x77), o2(0x8B,0x64), o2(0x8C,0x66),
- o2(0x92,0xCD), o2(0x9D,0x7D), o2(0x91,0x7E), o2(0x9D,0x81),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_8E = {
- to_SHIFT_JIS_E6_8E_offsets,
- to_SHIFT_JIS_E6_8E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_8F_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_8F */
- /* used from to_EUC_JP_E6_8F */
- 0, 19, 19, 1, 2, 19, 3, 19, 19, 4, 19, 19, 19, 19, 19, 5,
- 6, 19, 7, 19, 19, 19, 8, 19, 19, 19, 9, 10, 19, 19, 19, 19,
- 19, 11, 19, 12, 19, 19, 19, 19, 19, 13, 19, 19, 19, 19, 14, 19,
- 19, 19, 19, 19, 15, 16, 17, 19, 19, 19, 18, 19, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_8F_infos[20] = {
- o2(0x9D,0x83), o2(0x91,0xB5), o2(0x9D,0x89), o2(0x9D,0x84),
- o2(0x9D,0x86), o2(0x95,0x60), o2(0x92,0xF1), o2(0x9D,0x87),
- o2(0x97,0x4B), o2(0x97,0x67), o2(0x8A,0xB7), o2(0x88,0xAC),
- o2(0x9D,0x85), o2(0x9D,0x82), o2(0x8A,0xF6), o2(0x89,0x87),
- o2(0xFA,0xC9), o2(0x9D,0x88), o2(0x97,0x68), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_8F = {
- to_SHIFT_JIS_E6_8F_offsets,
- to_SHIFT_JIS_E6_8F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_90_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_90 */
- /* used from to_EUC_JP_E6_90 */
- 15, 15, 15, 15, 15, 15, 0, 15, 15, 15, 15, 15, 15, 1, 15, 2,
- 15, 15, 15, 3, 15, 15, 4, 5, 15, 15, 15, 15, 6, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 7, 15, 8, 15, 15, 15, 9, 10, 15, 15,
- 15, 15, 15, 15, 11, 15, 12, 15, 15, 15, 13, 15, 15, 15, 14, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_90_infos[16] = {
- o2(0x9D,0x8C), o2(0x91,0xB9), o2(0x9D,0x93), o2(0x9D,0x8D),
- o2(0x9D,0x8A), o2(0x9D,0x91), o2(0x9D,0x72), o2(0x9D,0x8E),
- o2(0x9D,0x92), o2(0x94,0xC0), o2(0x93,0x8B), o2(0x9D,0x8B),
- o2(0x9D,0x8F), o2(0x8C,0x67), o2(0x8D,0xEF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_90 = {
- to_SHIFT_JIS_E6_90_offsets,
- to_SHIFT_JIS_E6_90_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_91_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_91 */
- /* used from to_EUC_JP_E6_91 */
- 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 2, 10, 10, 10, 10, 10, 10, 10,
- 3, 10, 10, 10, 10, 10, 10, 4, 10, 5, 10, 10, 10, 10, 10, 6,
- 10, 10, 10, 10, 10, 10, 7, 10, 8, 10, 9, 10, 10, 10, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_91_infos[11] = {
- o2(0x90,0xDB), o2(0x9D,0x97), o2(0x93,0x45), o2(0xFA,0xCA),
- o2(0x9D,0x94), o2(0x96,0x80), o2(0x9D,0x95), o2(0x9D,0x96),
- o2(0x96,0xCC), o2(0x90,0xA0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_91 = {
- to_SHIFT_JIS_E6_91_offsets,
- to_SHIFT_JIS_E6_91_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_92_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_92 */
- /* used from to_EUC_JP_E6_92 */
- 19, 19, 19, 0, 19, 19, 19, 19, 1, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 2, 3, 19, 4, 19, 19, 19, 19, 5, 19, 19, 6, 7, 19,
- 19, 19, 19, 19, 8, 9, 19, 19, 19, 10, 19, 11, 19, 12, 13, 19,
- 14, 19, 15, 19, 19, 19, 19, 19, 19, 16, 19, 17, 18, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_92_infos[20] = {
- o2(0x8C,0x82), o2(0x9D,0x9D), o2(0x8E,0x54), o2(0x9D,0x9A),
- o2(0x9D,0x99), o2(0x94,0x51), o2(0xFA,0xCB), o2(0x93,0xB3),
- o2(0x93,0x50), o2(0x9D,0x9B), o2(0x9D,0x9C), o2(0x95,0x8F),
- o2(0x94,0x64), o2(0x8E,0x42), o2(0x90,0xEF), o2(0x96,0x6F),
- o2(0x8A,0x68), o2(0x9D,0xA3), o2(0x9D,0x9E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_92 = {
- to_SHIFT_JIS_E6_92_offsets,
- to_SHIFT_JIS_E6_92_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_93_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_93 */
- /* used from to_EUC_JP_E6_93 */
- 25, 0, 1, 25, 25, 2, 25, 3, 25, 25, 25, 25, 25, 4, 5, 25,
- 25, 25, 6, 25, 7, 25, 25, 25, 8, 25, 9, 25, 25, 25, 25, 25,
- 10, 11, 12, 13, 25, 25, 14, 15, 25, 25, 25, 25, 16, 25, 25, 17,
- 25, 18, 19, 25, 20, 25, 21, 25, 25, 25, 22, 25, 25, 23, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_93_infos[26] = {
- o2(0x97,0x69), o2(0x9D,0xA5), o2(0x9D,0xA1), o2(0x9D,0xA2),
- o2(0x91,0x80), o2(0xFA,0xCC), o2(0x9D,0xA0), o2(0x9D,0x5E),
- o2(0x9D,0xA4), o2(0x9D,0x9F), o2(0x9D,0xA9), o2(0x9D,0xAA),
- o2(0x93,0x46), o2(0x9D,0xAC), o2(0x8E,0x43), o2(0x9D,0xA7),
- o2(0x8B,0x5B), o2(0x9D,0xAD), o2(0x9D,0xA6), o2(0x9D,0xB1),
- o2(0x9D,0xB0), o2(0x9D,0xAF), o2(0x9D,0xB2), o2(0x9D,0xB4),
- o2(0x8F,0xEF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_93 = {
- to_SHIFT_JIS_E6_93_offsets,
- to_SHIFT_JIS_E6_93_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_94_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_94 */
- /* used from to_EUC_JP_E6_94 */
- 0, 20, 20, 20, 20, 1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 2, 20, 20, 20, 3, 4, 20, 20,
- 20, 20, 20, 5, 6, 20, 20, 20, 20, 20, 7, 8, 9, 20, 20, 10,
- 20, 20, 20, 20, 11, 12, 13, 14, 15, 16, 20, 17, 20, 20, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_94_infos[21] = {
- o2(0x9D,0xB3), o2(0x9D,0xB7), o2(0x9D,0xB5), o2(0x9D,0xB6),
- o2(0x9D,0x90), o2(0x9D,0xB9), o2(0x9D,0xB8), o2(0x9D,0x98),
- o2(0x9D,0xBA), o2(0x9D,0xAE), o2(0x8E,0x78), o2(0x9D,0xBB),
- o2(0x9D,0xBC), o2(0x9D,0xBE), o2(0x9D,0xBD), o2(0x9D,0xBF),
- o2(0x89,0xFC), o2(0x8D,0x55), o2(0x95,0xFA), o2(0x90,0xAD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_94 = {
- to_SHIFT_JIS_E6_94_offsets,
- to_SHIFT_JIS_E6_94_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_95_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_95 */
- /* used from to_EUC_JP_E6_95 */
- 23, 23, 23, 23, 23, 0, 23, 23, 1, 23, 23, 23, 23, 2, 3, 4,
- 23, 5, 23, 23, 23, 6, 7, 8, 9, 10, 23, 23, 23, 11, 12, 23,
- 23, 23, 13, 14, 23, 23, 15, 23, 23, 23, 23, 23, 16, 23, 23, 23,
- 17, 23, 18, 23, 19, 20, 23, 21, 22, 23, 23, 23, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_95_infos[24] = {
- o2(0x8C,0xCC), o2(0x9D,0xC1), o2(0x9D,0xC4), o2(0xFA,0xCD),
- o2(0x95,0x71), o2(0x8B,0x7E), o2(0x9D,0xC3), o2(0x9D,0xC2),
- o2(0x94,0x73), o2(0x9D,0xC5), o2(0x8B,0xB3), o2(0x9D,0xC7),
- o2(0x9D,0xC6), o2(0x8A,0xB8), o2(0x8E,0x55), o2(0x93,0xD6),
- o2(0x8C,0x68), o2(0x90,0x94), o2(0x9D,0xC8), o2(0x90,0xAE),
- o2(0x93,0x47), o2(0x95,0x7E), o2(0x9D,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_95 = {
- to_SHIFT_JIS_E6_95_offsets,
- to_SHIFT_JIS_E6_95_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_96_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_96 */
- /* used from to_EUC_JP_E6_96 */
- 27, 27, 0, 1, 27, 27, 27, 2, 3, 4, 27, 27, 5, 27, 6, 27,
- 7, 8, 27, 27, 27, 27, 27, 9, 27, 10, 27, 11, 12, 27, 27, 13,
- 27, 14, 27, 27, 15, 16, 27, 17, 27, 27, 27, 18, 19, 20, 27, 21,
- 22, 27, 27, 27, 27, 27, 27, 23, 27, 24, 27, 27, 25, 26, 27, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_96_infos[28] = {
- o2(0x9D,0xCA), o2(0x9D,0xCB), o2(0x95,0xB6), o2(0x9B,0x7C),
- o2(0x90,0xC4), o2(0x95,0x6B), o2(0x8D,0xD6), o2(0x94,0xE3),
- o2(0x94,0xC1), o2(0x93,0x6C), o2(0x97,0xBF), o2(0x9D,0xCD),
- o2(0x8E,0xCE), o2(0x9D,0xCE), o2(0x88,0xB4), o2(0x8B,0xD2),
- o2(0x90,0xCB), o2(0x95,0x80), o2(0x9D,0xCF), o2(0x8E,0x61),
- o2(0x92,0x66), o2(0x8E,0x7A), o2(0x90,0x56), o2(0x9D,0xD0),
- o2(0x95,0xFB), o2(0x89,0x97), o2(0x8E,0x7B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_96 = {
- to_SHIFT_JIS_E6_96_offsets,
- to_SHIFT_JIS_E6_96_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_97_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_97 */
- /* used from to_EUC_JP_E6_97 */
- 25, 0, 25, 1, 2, 3, 4, 25, 25, 25, 25, 5, 6, 25, 25, 7,
- 25, 25, 8, 25, 25, 25, 25, 9, 25, 10, 25, 11, 25, 25, 25, 25,
- 12, 13, 14, 25, 25, 15, 16, 17, 18, 19, 25, 25, 20, 21, 25, 25,
- 25, 22, 25, 25, 25, 25, 25, 25, 25, 25, 23, 24, 25, 25, 25, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_97_infos[26] = {
- o2(0x9D,0xD3), o2(0x9D,0xD1), o2(0x9D,0xD4), o2(0x97,0xB7),
- o2(0x9D,0xD2), o2(0x90,0xF9), o2(0x9D,0xD5), o2(0x91,0xB0),
- o2(0x9D,0xD6), o2(0x8A,0xF8), o2(0x9D,0xD8), o2(0x9D,0xD7),
- o2(0x9D,0xD9), o2(0x9D,0xDA), o2(0x8A,0xF9), o2(0x93,0xFA),
- o2(0x92,0x55), o2(0x8B,0x8C), o2(0x8E,0x7C), o2(0x91,0x81),
- o2(0x8F,0x7B), o2(0x88,0xAE), o2(0x9D,0xDB), o2(0x89,0xA0),
- o2(0x9D,0xDF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_97 = {
- to_SHIFT_JIS_E6_97_offsets,
- to_SHIFT_JIS_E6_97_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_98_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_98 */
- /* used from to_EUC_JP_E6_98 */
- 0, 31, 1, 2, 31, 31, 3, 4, 31, 5, 6, 31, 7, 31, 8, 9,
- 31, 31, 31, 10, 11, 12, 31, 31, 31, 31, 31, 31, 13, 31, 14, 15,
- 16, 31, 31, 31, 17, 18, 31, 19, 20, 31, 31, 31, 31, 21, 22, 23,
- 31, 24, 31, 31, 25, 26, 27, 31, 31, 31, 31, 28, 29, 31, 31, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_98_infos[32] = {
- o2(0xFA,0xCE), o2(0x8D,0x56), o2(0x9D,0xDE), o2(0x8D,0xA9),
- o2(0x8F,0xB8), o2(0xFA,0xD1), o2(0x9D,0xDD), o2(0x8F,0xB9),
- o2(0x96,0xBE), o2(0x8D,0xA8), o2(0x88,0xD5), o2(0x90,0xCC),
- o2(0xFA,0xCF), o2(0x9D,0xE4), o2(0xFA,0xD3), o2(0x90,0xAF),
- o2(0x89,0x66), o2(0xFA,0xD4), o2(0x8F,0x74), o2(0x96,0x86),
- o2(0x8D,0xF0), o2(0x8F,0xBA), o2(0xFA,0xD2), o2(0x90,0xA5),
- o2(0xFA,0x63), o2(0x9D,0xE3), o2(0x9D,0xE1), o2(0x9D,0xE2),
- o2(0xFA,0xD0), o2(0x92,0x8B), o2(0x9E,0x45), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_98 = {
- to_SHIFT_JIS_E6_98_offsets,
- to_SHIFT_JIS_E6_98_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_99_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_99 */
- /* used from to_EUC_JP_E6_99 */
- 27, 0, 1, 2, 3, 27, 27, 27, 27, 4, 27, 5, 27, 27, 27, 6,
- 27, 27, 7, 27, 27, 27, 27, 8, 27, 9, 27, 27, 27, 10, 11, 12,
- 27, 27, 13, 27, 14, 15, 16, 17, 18, 19, 27, 27, 27, 27, 20, 21,
- 22, 27, 27, 23, 24, 27, 25, 27, 27, 27, 26, 27, 27, 27, 27, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_99_infos[28] = {
- o2(0x9D,0xE8), o2(0x8E,0x9E), o2(0x8D,0x57), o2(0x9D,0xE6),
- o2(0x9D,0xE7), o2(0x90,0x57), o2(0x9D,0xE5), o2(0x8E,0x4E),
- o2(0xFA,0xD6), o2(0xFA,0xD7), o2(0x9D,0xEA), o2(0x9D,0xE9),
- o2(0x9D,0xEE), o2(0x9D,0xEF), o2(0x9D,0xEB), o2(0xFA,0xD5),
- o2(0x8A,0x41), o2(0x9D,0xEC), o2(0x9D,0xED), o2(0x94,0xD3),
- o2(0x95,0x81), o2(0x8C,0x69), o2(0x9D,0xF0), o2(0xFA,0xD9),
- o2(0x90,0xB0), o2(0x8F,0xBB), o2(0x92,0x71), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_99 = {
- to_SHIFT_JIS_E6_99_offsets,
- to_SHIFT_JIS_E6_99_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_9A_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_9A */
- /* used from to_EUC_JP_E6_9A */
- 25, 0, 25, 1, 2, 25, 25, 3, 4, 5, 25, 25, 25, 25, 6, 25,
- 25, 7, 25, 25, 25, 25, 8, 9, 10, 11, 25, 25, 25, 12, 25, 25,
- 13, 25, 14, 25, 25, 25, 15, 25, 25, 25, 25, 16, 25, 25, 17, 25,
- 25, 25, 18, 25, 19, 25, 25, 25, 20, 21, 25, 25, 22, 25, 23, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_9A_infos[26] = {
- o2(0x8B,0xC5), o2(0x9D,0xF1), o2(0x9D,0xF5), o2(0x89,0xC9),
- o2(0x9D,0xF2), o2(0x9D,0xF4), o2(0x9D,0xF3), o2(0x8F,0x8B),
- o2(0x92,0x67), o2(0x88,0xC3), o2(0x9D,0xF6), o2(0xFA,0xDA),
- o2(0x9D,0xF7), o2(0xFA,0xDB), o2(0x92,0xA8), o2(0x97,0xEF),
- o2(0x8E,0x62), o2(0x95,0xE9), o2(0xFA,0xDC), o2(0x96,0x5C),
- o2(0x9E,0x41), o2(0x9D,0xF9), o2(0x9D,0xFC), o2(0x9D,0xFB),
- o2(0xFA,0xDD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_9A = {
- to_SHIFT_JIS_E6_9A_offsets,
- to_SHIFT_JIS_E6_9A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_9B_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_9B */
- /* used from to_EUC_JP_E6_9B */
- 26, 0, 26, 26, 1, 26, 26, 2, 26, 3, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 4, 26, 26, 5, 6, 26, 7, 8, 26, 26,
- 9, 26, 26, 26, 26, 26, 10, 26, 26, 11, 26, 26, 26, 26, 26, 26,
- 12, 26, 13, 14, 15, 16, 26, 17, 18, 19, 20, 21, 22, 23, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_9B_infos[27] = {
- o2(0x9D,0xF8), o2(0x9E,0x40), o2(0x93,0xDC), o2(0x9D,0xFA),
- o2(0x9E,0x42), o2(0x8F,0x8C), o2(0x9E,0x43), o2(0x97,0x6A),
- o2(0x94,0x98), o2(0x9E,0x44), o2(0x9E,0x46), o2(0x9E,0x47),
- o2(0x9E,0x48), o2(0x8B,0xC8), o2(0x89,0x67), o2(0x8D,0x58),
- o2(0x9E,0x49), o2(0x9E,0x4A), o2(0x8F,0x91), o2(0x91,0x82),
- o2(0xFA,0xDE), o2(0xFA,0x66), o2(0x99,0xD6), o2(0x91,0x5D),
- o2(0x91,0x5C), o2(0x91,0xD6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_9B = {
- to_SHIFT_JIS_E6_9B_offsets,
- to_SHIFT_JIS_E6_9B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_9C_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_9C */
- /* used from to_EUC_JP_E6_9C */
- 0, 32, 32, 1, 32, 32, 32, 32, 2, 3, 32, 4, 32, 5, 6, 7,
- 32, 32, 32, 32, 8, 9, 10, 11, 32, 32, 32, 12, 32, 13, 14, 15,
- 32, 32, 32, 32, 32, 32, 16, 17, 18, 32, 19, 20, 21, 22, 23, 32,
- 32, 24, 32, 32, 25, 32, 26, 27, 28, 32, 29, 32, 32, 30, 32, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_9C_infos[33] = {
- o2(0x8D,0xC5), o2(0x98,0xF0), o2(0x8C,0x8E), o2(0x97,0x4C),
- o2(0x95,0xFC), o2(0x95,0x9E), o2(0xFA,0xDF), o2(0x9E,0x4B),
- o2(0x8D,0xF1), o2(0x92,0xBD), o2(0x9E,0x4C), o2(0x98,0x4E),
- o2(0x96,0x5D), o2(0x92,0xA9), o2(0x9E,0x4D), o2(0x8A,0xFA),
- o2(0x9E,0x4E), o2(0x9E,0x4F), o2(0x96,0xD8), o2(0x96,0xA2),
- o2(0x96,0x96), o2(0x96,0x7B), o2(0x8E,0x44), o2(0x9E,0x51),
- o2(0x8E,0xE9), o2(0x96,0x70), o2(0x9E,0x53), o2(0x9E,0x56),
- o2(0x9E,0x55), o2(0x8A,0xF7), o2(0x8B,0x80), o2(0x9E,0x52),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_9C = {
- to_SHIFT_JIS_E6_9C_offsets,
- to_SHIFT_JIS_E6_9C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_9D_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_9D */
- /* used from to_EUC_JP_E6_9D */
- 32, 0, 32, 32, 32, 32, 1, 32, 32, 2, 32, 32, 32, 32, 3, 4,
- 5, 6, 32, 7, 32, 32, 8, 32, 32, 9, 32, 32, 10, 32, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 32, 32, 32, 20, 32, 32, 21, 32, 22,
- 23, 24, 25, 26, 32, 27, 32, 28, 32, 32, 32, 32, 29, 32, 30, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_9D_infos[33] = {
- o2(0x9E,0x54), o2(0x9E,0x57), o2(0x90,0x99), o2(0x97,0x9B),
- o2(0x88,0xC7), o2(0x8D,0xDE), o2(0x91,0xBA), o2(0x8E,0xDB),
- o2(0x8F,0xF1), o2(0x9E,0x5A), o2(0x93,0x6D), o2(0x9E,0x58),
- o2(0x91,0xA9), o2(0x9E,0x59), o2(0x8F,0xF0), o2(0x96,0xDB),
- o2(0x9E,0x5B), o2(0x9E,0x5C), o2(0x97,0x88), o2(0xFA,0xE1),
- o2(0x9E,0x61), o2(0x8D,0x59), o2(0x94,0x74), o2(0x9E,0x5E),
- o2(0x93,0x8C), o2(0x9D,0xDC), o2(0x9D,0xE0), o2(0x8B,0x6E),
- o2(0x94,0x66), o2(0x9E,0x60), o2(0x8F,0xBC), o2(0x94,0xC2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_9D = {
- to_SHIFT_JIS_E6_9D_offsets,
- to_SHIFT_JIS_E6_9D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_9E_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_9E */
- /* used from to_EUC_JP_E6_9E */
- 24, 24, 24, 24, 24, 0, 24, 1, 24, 2, 24, 3, 4, 24, 24, 24,
- 5, 24, 24, 24, 24, 6, 24, 7, 24, 24, 8, 24, 9, 10, 24, 24,
- 11, 12, 13, 24, 24, 24, 14, 24, 24, 15, 24, 24, 24, 24, 24, 16,
- 24, 24, 24, 17, 18, 24, 19, 20, 21, 22, 24, 23, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_9E_infos[25] = {
- o2(0x9E,0x66), o2(0x94,0xF8), o2(0x9E,0x5D), o2(0x9E,0x63),
- o2(0x9E,0x62), o2(0x90,0xCD), o2(0x96,0x8D), o2(0x97,0xD1),
- o2(0x96,0x87), o2(0x89,0xCA), o2(0x8E,0x7D), o2(0x98,0x67),
- o2(0x9E,0x65), o2(0x90,0x95), o2(0x9E,0x64), o2(0x9E,0x5F),
- o2(0x8C,0xCD), o2(0x9E,0x6B), o2(0x9E,0x69), o2(0x89,0xCB),
- o2(0x9E,0x67), o2(0x9E,0x6D), o2(0x9E,0x73), o2(0xFA,0xE2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_9E = {
- to_SHIFT_JIS_E6_9E_offsets,
- to_SHIFT_JIS_E6_9E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_9F_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_9F */
- /* used from to_EUC_JP_E6_9F */
- 0, 1, 29, 29, 2, 29, 3, 29, 29, 29, 4, 29, 29, 29, 5, 6,
- 7, 8, 29, 9, 10, 29, 29, 29, 11, 29, 12, 29, 29, 13, 14, 29,
- 29, 29, 15, 29, 16, 29, 29, 17, 29, 18, 29, 29, 19, 29, 20, 21,
- 29, 22, 29, 23, 24, 25, 29, 29, 29, 29, 29, 26, 29, 29, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_9F_infos[30] = {
- o2(0xFA,0xE4), o2(0x91,0xC6), o2(0x95,0xBF), o2(0x9E,0x75),
- o2(0x95,0x41), o2(0x9E,0x74), o2(0x94,0x90), o2(0x96,0x5E),
- o2(0x8A,0xB9), o2(0x90,0xF5), o2(0x8F,0x5F), o2(0x92,0xD1),
- o2(0x97,0x4D), o2(0x9E,0x70), o2(0x9E,0x6F), o2(0x9E,0x71),
- o2(0x9E,0x6E), o2(0x9E,0x76), o2(0x9E,0x6C), o2(0x9E,0x6A),
- o2(0x9E,0x72), o2(0x9E,0x68), o2(0x92,0x8C), o2(0x96,0xF6),
- o2(0x8E,0xC4), o2(0x8D,0xF2), o2(0x8D,0xB8), o2(0x96,0x8F),
- o2(0x8A,0x60), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_9F = {
- to_SHIFT_JIS_E6_9F_offsets,
- to_SHIFT_JIS_E6_9F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A0_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A0 */
- /* used from to_EUC_JP_E6_A0 */
- 19, 0, 1, 2, 3, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 4, 19, 19, 5, 6, 19, 19, 19, 19, 19, 19, 7, 19,
- 19, 8, 9, 19, 19, 19, 19, 19, 19, 10, 11, 12, 19, 19, 19, 19,
- 19, 19, 13, 19, 14, 19, 19, 19, 15, 16, 19, 19, 17, 18, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A0_infos[20] = {
- o2(0xFA,0xE5), o2(0x92,0xCC), o2(0x93,0xC8), o2(0x89,0x68),
- o2(0x90,0xF0), o2(0x90,0xB2), o2(0x8C,0x49), o2(0x9E,0x78),
- o2(0x8D,0x5A), o2(0x8A,0x9C), o2(0x9E,0x7A), o2(0x8A,0x94),
- o2(0x9E,0x81), o2(0x9E,0x7D), o2(0x90,0xF1), o2(0x8A,0x6A),
- o2(0x8D,0xAA), o2(0x8A,0x69), o2(0x8D,0xCD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A0 = {
- to_SHIFT_JIS_E6_A0_offsets,
- to_SHIFT_JIS_E6_A0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A1_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A1 */
- /* used from to_EUC_JP_E6_A1 */
- 0, 1, 2, 3, 4, 25, 5, 25, 6, 25, 25, 25, 25, 7, 8, 25,
- 9, 10, 11, 12, 13, 25, 25, 25, 25, 14, 25, 25, 15, 16, 25, 17,
- 25, 25, 25, 18, 25, 25, 25, 19, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 20, 25, 21, 22, 25, 25, 25, 25, 25, 25, 23, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A1_infos[26] = {
- o2(0x9E,0x7B), o2(0x8C,0x85), o2(0x8C,0x6A), o2(0x93,0x8D),
- o2(0xFA,0xE6), o2(0x9E,0x79), o2(0x88,0xC4), o2(0x9E,0x7C),
- o2(0x9E,0x7E), o2(0x8B,0xCB), o2(0x8C,0x4B), o2(0xFA,0xE3),
- o2(0x8A,0xBA), o2(0x8B,0x6A), o2(0x9E,0x82), o2(0x8D,0xF7),
- o2(0x96,0x91), o2(0x8E,0x56), o2(0x9E,0x83), o2(0x95,0x4F),
- o2(0x9E,0x8F), o2(0x89,0xB1), o2(0x9E,0x84), o2(0x9E,0x95),
- o2(0x9E,0x85), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A1 = {
- to_SHIFT_JIS_E6_A1_offsets,
- to_SHIFT_JIS_E6_A1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A2_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A2 */
- /* used from to_EUC_JP_E6_A2 */
- 26, 0, 26, 1, 26, 2, 26, 26, 26, 26, 26, 26, 26, 3, 26, 4,
- 26, 26, 26, 5, 6, 26, 26, 7, 26, 26, 26, 8, 26, 9, 26, 10,
- 11, 26, 12, 26, 26, 26, 13, 14, 15, 26, 26, 26, 26, 16, 26, 17,
- 18, 19, 26, 20, 26, 21, 22, 26, 26, 23, 24, 26, 25, 26, 26, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A2_infos[27] = {
- o2(0x97,0xC0), o2(0x9E,0x8C), o2(0x94,0x7E), o2(0x9E,0x94),
- o2(0x9E,0x87), o2(0x88,0xB2), o2(0x9E,0x89), o2(0x8D,0x5B),
- o2(0x9E,0x8B), o2(0x9E,0x8A), o2(0x9E,0x86), o2(0x9E,0x91),
- o2(0x8F,0xBD), o2(0x9A,0xEB), o2(0x8C,0xE6), o2(0x97,0x9C),
- o2(0x9E,0x88), o2(0x92,0xF2), o2(0x8A,0x42), o2(0x8D,0xAB),
- o2(0x9E,0x80), o2(0x9E,0x90), o2(0x8A,0x81), o2(0x9E,0x8E),
- o2(0x9E,0x92), o2(0x93,0x8E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A2 = {
- to_SHIFT_JIS_E6_A2_offsets,
- to_SHIFT_JIS_E6_A2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A3_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A3 */
- /* used from to_EUC_JP_E6_A3 */
- 24, 24, 24, 24, 0, 24, 1, 24, 2, 3, 4, 5, 24, 6, 24, 7,
- 24, 24, 8, 24, 9, 10, 24, 11, 12, 24, 13, 24, 24, 24, 24, 14,
- 15, 16, 24, 17, 24, 24, 24, 18, 24, 24, 24, 24, 24, 24, 19, 20,
- 24, 24, 21, 24, 24, 24, 24, 24, 24, 22, 23, 24, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A3_infos[25] = {
- o2(0x8A,0xFC), o2(0x9E,0xB0), o2(0xFA,0x64), o2(0x96,0xC7),
- o2(0x9E,0x97), o2(0x8A,0xFB), o2(0x9E,0x9E), o2(0xFA,0xE7),
- o2(0x96,0x5F), o2(0x9E,0x9F), o2(0x9E,0xA1), o2(0x9E,0xA5),
- o2(0x9E,0x99), o2(0x92,0x49), o2(0x93,0x8F), o2(0x9E,0xA9),
- o2(0x9E,0x9C), o2(0x9E,0xA6), o2(0x9E,0xA0), o2(0x90,0x58),
- o2(0x9E,0xAA), o2(0x90,0xB1), o2(0x9E,0xA8), o2(0x8A,0xBB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A3 = {
- to_SHIFT_JIS_E6_A3_offsets,
- to_SHIFT_JIS_E6_A3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A4_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A4 */
- /* used from to_EUC_JP_E6_A4 */
- 0, 1, 28, 28, 2, 3, 28, 28, 4, 28, 28, 5, 6, 7, 8, 9,
- 28, 28, 10, 28, 28, 28, 28, 28, 28, 11, 12, 13, 14, 28, 28, 28,
- 28, 15, 16, 17, 28, 18, 19, 28, 20, 28, 21, 28, 28, 28, 28, 28,
- 22, 28, 28, 28, 23, 28, 24, 28, 28, 25, 28, 28, 28, 26, 28, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A4_infos[29] = {
- o2(0x98,0x6F), o2(0x9E,0x96), o2(0x9E,0xA4), o2(0x88,0xD6),
- o2(0x9E,0x98), o2(0x96,0xB8), o2(0x9E,0x9D), o2(0x90,0x41),
- o2(0x92,0xC5), o2(0x9E,0x93), o2(0x9E,0xA3), o2(0x90,0x9A),
- o2(0x9E,0xAD), o2(0x8A,0x91), o2(0x8C,0x9F), o2(0x9E,0xAF),
- o2(0x9E,0x9A), o2(0x9E,0xAE), o2(0x9E,0xA7), o2(0x9E,0x9B),
- o2(0x9E,0xAB), o2(0x9E,0xAC), o2(0x9E,0xBD), o2(0x93,0xCC),
- o2(0x9E,0xA2), o2(0x9E,0xB9), o2(0x9E,0xBB), o2(0x92,0xD6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A4 = {
- to_SHIFT_JIS_E6_A4_offsets,
- to_SHIFT_JIS_E6_A4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A5_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A5 */
- /* used from to_EUC_JP_E6_A5 */
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 27, 27, 27, 27, 27,
- 27, 27, 27, 1, 2, 3, 27, 27, 27, 4, 5, 27, 6, 7, 8, 27,
- 9, 10, 11, 27, 27, 27, 27, 27, 12, 27, 13, 14, 27, 15, 16, 17,
- 27, 27, 27, 18, 19, 20, 27, 21, 22, 23, 27, 27, 24, 25, 26, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A5_infos[28] = {
- o2(0x97,0x6B), o2(0x95,0x96), o2(0x9E,0xB6), o2(0x91,0xC8),
- o2(0x9E,0xBC), o2(0x91,0x5E), o2(0x9E,0xB3), o2(0x9E,0xC0),
- o2(0x9E,0xBF), o2(0x93,0xED), o2(0x9E,0xBE), o2(0x93,0xE8),
- o2(0xFA,0xE9), o2(0x9E,0xC2), o2(0x9E,0xB5), o2(0x8B,0xC6),
- o2(0x9E,0xB8), o2(0x8F,0x7C), o2(0x94,0x80), o2(0x9E,0xBA),
- o2(0x8B,0xC9), o2(0x9E,0xB2), o2(0x9E,0xB4), o2(0x9E,0xB1),
- o2(0x98,0x4F), o2(0x8A,0x79), o2(0x9E,0xB7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A5 = {
- to_SHIFT_JIS_E6_A5_offsets,
- to_SHIFT_JIS_E6_A5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A6_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A6 */
- /* used from to_EUC_JP_E6_A6 */
- 19, 0, 1, 19, 19, 19, 19, 19, 19, 19, 2, 19, 19, 19, 3, 19,
- 19, 4, 19, 19, 5, 6, 19, 19, 7, 19, 19, 8, 9, 19, 19, 19,
- 10, 19, 19, 19, 19, 19, 19, 11, 19, 19, 19, 19, 19, 19, 12, 19,
- 19, 13, 14, 19, 15, 19, 19, 19, 19, 19, 19, 16, 19, 19, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A6_infos[20] = {
- o2(0x9E,0xC1), o2(0x8A,0x54), o2(0x8D,0xE5), o2(0x89,0x7C),
- o2(0x9E,0xD2), o2(0x98,0x50), o2(0x9E,0xD5), o2(0xFA,0xEB),
- o2(0x90,0x59), o2(0x9E,0xD4), o2(0x9E,0xD3), o2(0x9E,0xD0),
- o2(0x9E,0xC4), o2(0x9E,0xE1), o2(0x9E,0xC3), o2(0x9E,0xD6),
- o2(0x9E,0xCE), o2(0x9E,0xC9), o2(0x9E,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A6 = {
- to_SHIFT_JIS_E6_A6_offsets,
- to_SHIFT_JIS_E6_A6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A7_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A7 */
- /* used from to_EUC_JP_E6_A7 */
- 24, 0, 24, 1, 24, 24, 24, 2, 24, 24, 3, 4, 5, 6, 7, 24,
- 8, 24, 24, 9, 24, 24, 24, 24, 10, 11, 24, 24, 24, 12, 13, 24,
- 24, 24, 14, 24, 24, 24, 24, 15, 16, 24, 24, 17, 24, 18, 24, 24,
- 24, 24, 19, 24, 24, 24, 24, 24, 24, 20, 24, 21, 24, 22, 24, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A7_infos[25] = {
- o2(0x9E,0xC7), o2(0x9E,0xCF), o2(0xEA,0xA0), o2(0x9E,0xCC),
- o2(0x8D,0x5C), o2(0x92,0xC6), o2(0x91,0x84), o2(0x9E,0xCA),
- o2(0x9E,0xC5), o2(0x9E,0xC8), o2(0x97,0x6C), o2(0x96,0x8A),
- o2(0x9E,0xCD), o2(0x9E,0xD7), o2(0xFA,0xEC), o2(0x9E,0xDF),
- o2(0x9E,0xD8), o2(0x9E,0xE5), o2(0x9E,0xE3), o2(0x9E,0xDE),
- o2(0x9E,0xDD), o2(0x92,0xCE), o2(0x91,0x85), o2(0x9E,0xDB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A7 = {
- to_SHIFT_JIS_E6_A7_offsets,
- to_SHIFT_JIS_E6_A7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A8_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A8 */
- /* used from to_EUC_JP_E6_A8 */
- 27, 27, 0, 27, 27, 1, 27, 27, 27, 27, 2, 3, 4, 27, 27, 27,
- 27, 27, 5, 6, 7, 27, 27, 8, 27, 9, 27, 10, 27, 27, 11, 12,
- 27, 13, 14, 15, 27, 27, 27, 27, 27, 16, 17, 18, 27, 27, 19, 27,
- 20, 27, 27, 27, 27, 21, 22, 27, 23, 24, 25, 27, 27, 26, 27, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A8_infos[28] = {
- o2(0x9E,0xD9), o2(0x9E,0xE0), o2(0x9E,0xE6), o2(0x94,0xF3),
- o2(0x9E,0xEC), o2(0x9E,0xE7), o2(0x9E,0xEA), o2(0x9E,0xE4),
- o2(0x92,0x94), o2(0x95,0x57), o2(0x9E,0xDA), o2(0x9E,0xE2),
- o2(0x8F,0xBE), o2(0x96,0xCD), o2(0x9E,0xF6), o2(0x9E,0xE9),
- o2(0x8C,0xA0), o2(0x89,0xA1), o2(0x8A,0x7E), o2(0x9E,0xD1),
- o2(0xFA,0xED), o2(0x8F,0xBF), o2(0x9E,0xEE), o2(0x9E,0xF5),
- o2(0x8E,0xF7), o2(0x8A,0x92), o2(0x92,0x4D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A8 = {
- to_SHIFT_JIS_E6_A8_offsets,
- to_SHIFT_JIS_E6_A8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_A9_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_A9 */
- /* used from to_EUC_JP_E6_A9 */
- 17, 17, 17, 17, 0, 17, 1, 2, 3, 17, 17, 4, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 5, 6, 17, 17, 17, 17, 17, 7,
- 17, 8, 9, 17, 17, 17, 10, 17, 17, 17, 17, 11, 17, 17, 17, 17,
- 17, 17, 12, 13, 17, 17, 17, 17, 14, 17, 17, 17, 17, 17, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_A9_infos[18] = {
- o2(0x9E,0xEB), o2(0xFA,0xEF), o2(0x9E,0xF0), o2(0x9E,0xF4),
- o2(0x8B,0xB4), o2(0x8B,0x6B), o2(0x9E,0xF2), o2(0x8B,0x40),
- o2(0x93,0xC9), o2(0x9E,0xF1), o2(0x9E,0xF3), o2(0xFA,0xEE),
- o2(0x9E,0xED), o2(0xFA,0xF0), o2(0x9E,0xEF), o2(0xFA,0xF1),
- o2(0x8A,0x80), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_A9 = {
- to_SHIFT_JIS_E6_A9_offsets,
- to_SHIFT_JIS_E6_A9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_AA_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_AA */
- /* used from to_EUC_JP_E6_AA */
- 0, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 16, 16, 2, 3, 16,
- 4, 16, 16, 16, 16, 16, 16, 5, 16, 16, 16, 16, 6, 16, 16, 16,
- 7, 16, 8, 9, 16, 16, 16, 16, 16, 16, 10, 16, 11, 16, 12, 16,
- 16, 16, 16, 13, 16, 16, 16, 16, 14, 16, 16, 15, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_AA_infos[17] = {
- o2(0x92,0x68), o2(0x9E,0xFA), o2(0x9E,0xF8), o2(0x8C,0xE7),
- o2(0x9E,0xF7), o2(0x9F,0x40), o2(0x9E,0x77), o2(0x9E,0xF9),
- o2(0x9E,0xFB), o2(0x9E,0xFC), o2(0x9F,0x4B), o2(0x9F,0x47),
- o2(0x9E,0x8D), o2(0x9F,0x46), o2(0x9F,0x45), o2(0x9F,0x42),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_AA = {
- to_SHIFT_JIS_E6_AA_offsets,
- to_SHIFT_JIS_E6_AA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_AB_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_AB */
- /* used from to_EUC_JP_E6_AB */
- 15, 0, 1, 2, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 3, 15, 4, 15, 15, 15, 15, 15, 15, 5, 6, 15, 15, 7, 8,
- 15, 15, 9, 15, 10, 15, 15, 15, 11, 15, 12, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 13, 14, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_AB_infos[16] = {
- o2(0x9E,0xE8), o2(0x9F,0x44), o2(0x9F,0x43), o2(0x9F,0x49),
- o2(0x98,0x45), o2(0x9F,0x4C), o2(0x8B,0xF9), o2(0x9F,0x48),
- o2(0x9F,0x4A), o2(0xFA,0xF2), o2(0xFA,0xF3), o2(0x94,0xA5),
- o2(0x9F,0x4D), o2(0x9F,0x51), o2(0x9F,0x4E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_AB = {
- to_SHIFT_JIS_E6_AB_offsets,
- to_SHIFT_JIS_E6_AB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_AC_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_AC */
- /* used from to_EUC_JP_E6_AC */
- 18, 18, 18, 18, 0, 1, 18, 18, 18, 18, 2, 18, 18, 18, 18, 18,
- 18, 18, 3, 18, 18, 18, 4, 18, 18, 18, 18, 18, 18, 5, 18, 6,
- 7, 8, 18, 9, 18, 18, 18, 10, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 11, 18, 18, 18, 18, 12, 13, 14, 15, 18, 18, 16, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_AC_infos[19] = {
- o2(0x97,0x93), o2(0x9F,0x4F), o2(0x9E,0xDC), o2(0x9F,0x52),
- o2(0x9F,0x53), o2(0x89,0x54), o2(0x9F,0x55), o2(0x8C,0x87),
- o2(0x8E,0x9F), o2(0x8B,0xD3), o2(0x89,0xA2), o2(0x97,0x7E),
- o2(0x9F,0x57), o2(0x9F,0x56), o2(0x9F,0x59), o2(0x8B,0x5C),
- o2(0x8B,0xD4), o2(0x8A,0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_AC = {
- to_SHIFT_JIS_E6_AC_offsets,
- to_SHIFT_JIS_E6_AC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_AD_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_AD */
- /* used from to_EUC_JP_E6_AD */
- 25, 25, 25, 0, 25, 25, 25, 1, 25, 2, 25, 25, 3, 25, 4, 25,
- 5, 25, 25, 6, 7, 25, 25, 25, 25, 8, 25, 9, 25, 25, 25, 10,
- 25, 11, 12, 13, 14, 25, 15, 25, 25, 16, 17, 25, 25, 25, 25, 18,
- 25, 25, 25, 19, 20, 25, 25, 25, 21, 22, 25, 23, 25, 25, 25, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_AD_infos[26] = {
- o2(0x9F,0x5C), o2(0x9F,0x5B), o2(0x9F,0x5D), o2(0x89,0xCC),
- o2(0x92,0x56), o2(0x9F,0x5E), o2(0x8A,0xBD), o2(0x9F,0x60),
- o2(0x9F,0x5F), o2(0x9F,0x61), o2(0x9F,0x62), o2(0x9F,0x63),
- o2(0x8E,0x7E), o2(0x90,0xB3), o2(0x8D,0x9F), o2(0x95,0x90),
- o2(0x95,0xE0), o2(0x98,0x63), o2(0x8E,0x95), o2(0x8D,0xCE),
- o2(0x97,0xF0), o2(0x9F,0x64), o2(0x9F,0x65), o2(0x8E,0x80),
- o2(0x9F,0x66), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_AD = {
- to_SHIFT_JIS_E6_AD_offsets,
- to_SHIFT_JIS_E6_AD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_AE_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_AE */
- /* used from to_EUC_JP_E6_AE */
- 0, 26, 26, 1, 2, 26, 3, 26, 26, 4, 5, 6, 26, 7, 26, 26,
- 26, 26, 26, 26, 26, 8, 9, 26, 10, 26, 26, 26, 26, 26, 11, 26,
- 26, 26, 26, 26, 12, 26, 26, 26, 26, 26, 13, 14, 26, 26, 26, 15,
- 26, 16, 17, 18, 19, 20, 26, 21, 26, 26, 22, 23, 24, 26, 26, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_AE_infos[27] = {
- o2(0x9F,0x67), o2(0x9F,0x69), o2(0x9F,0x68), o2(0x96,0x77),
- o2(0x8F,0x7D), o2(0x8E,0xEA), o2(0x8E,0x63), o2(0x9F,0x6A),
- o2(0x9F,0x6C), o2(0x90,0x42), o2(0x9F,0x6B), o2(0x9F,0x6D),
- o2(0x9F,0x6E), o2(0x9F,0x6F), o2(0x9F,0x70), o2(0x9F,0x71),
- o2(0x9F,0x73), o2(0x9F,0x72), o2(0x9F,0x74), o2(0x89,0xA3),
- o2(0x92,0x69), o2(0x9F,0x75), o2(0x8E,0x45), o2(0x8A,0x6B),
- o2(0x9F,0x76), o2(0x93,0x61), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_AE = {
- to_SHIFT_JIS_E6_AE_offsets,
- to_SHIFT_JIS_E6_AE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_AF_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_AF */
- /* used from to_EUC_JP_E6_AF */
- 0, 17, 17, 17, 17, 1, 2, 17, 17, 17, 17, 3, 17, 4, 5, 17,
- 17, 17, 6, 7, 8, 17, 9, 17, 10, 17, 17, 11, 17, 17, 17, 12,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 13, 14, 17, 17, 15,
- 17, 17, 17, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_AF_infos[18] = {
- o2(0x9A,0xCA), o2(0x8B,0x42), o2(0x9F,0x77), o2(0x9F,0x78),
- o2(0x95,0xEA), o2(0x96,0x88), o2(0x93,0xC5), o2(0x9F,0x79),
- o2(0x94,0xE4), o2(0xFA,0xF4), o2(0x94,0xF9), o2(0x96,0xD1),
- o2(0x9F,0x7A), o2(0x9F,0x7C), o2(0x9F,0x7B), o2(0x9F,0x7E),
- o2(0x9F,0x7D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_AF = {
- to_SHIFT_JIS_E6_AF_offsets,
- to_SHIFT_JIS_E6_AF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B0_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B0 */
- /* used from to_EUC_JP_E6_B0 */
- 14, 14, 14, 14, 14, 14, 14, 14, 0, 14, 14, 14, 14, 14, 14, 1,
- 14, 2, 14, 3, 4, 14, 14, 5, 14, 14, 14, 6, 14, 14, 14, 14,
- 14, 14, 14, 7, 8, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 9, 14, 14, 10, 11, 14, 14, 14, 14, 14, 12, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B0_infos[15] = {
- o2(0x9F,0x81), o2(0x8E,0x81), o2(0x96,0xAF), o2(0x9F,0x82),
- o2(0x9F,0x83), o2(0x8B,0x43), o2(0x9F,0x84), o2(0x9F,0x86),
- o2(0x9F,0x85), o2(0x90,0x85), o2(0x95,0x58), o2(0x89,0x69),
- o2(0x94,0xC3), o2(0xFA,0xF5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B0 = {
- to_SHIFT_JIS_E6_B0_offsets,
- to_SHIFT_JIS_E6_B0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B1_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B1 */
- /* used from to_EUC_JP_E6_B1 */
- 0, 1, 2, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 3, 23,
- 4, 23, 23, 23, 23, 5, 23, 6, 23, 23, 7, 23, 8, 9, 10, 11,
- 12, 23, 13, 23, 23, 23, 23, 23, 14, 23, 15, 23, 23, 23, 23, 16,
- 17, 23, 18, 19, 23, 23, 23, 23, 23, 23, 20, 23, 23, 21, 22, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B1_infos[24] = {
- o2(0x92,0xF3), o2(0x8F,0x60), o2(0x8B,0x81), o2(0x94,0xC4),
- o2(0x8E,0xAC), o2(0x9F,0x88), o2(0x8A,0xBE), o2(0x89,0x98),
- o2(0xFA,0xF6), o2(0x93,0xF0), o2(0x9F,0x87), o2(0x8D,0x5D),
- o2(0x92,0x72), o2(0x9F,0x89), o2(0x9F,0x91), o2(0x9F,0x8A),
- o2(0xFA,0xF8), o2(0x91,0xBF), o2(0x8B,0x82), o2(0x9F,0x92),
- o2(0x8C,0x88), o2(0x8B,0x44), o2(0x9F,0x90), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B1 = {
- to_SHIFT_JIS_E6_B1_offsets,
- to_SHIFT_JIS_E6_B1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B2_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B2 */
- /* used from to_EUC_JP_E6_B2 */
- 28, 0, 1, 2, 28, 28, 3, 28, 4, 28, 28, 28, 5, 6, 28, 28,
- 7, 28, 8, 9, 28, 28, 10, 28, 28, 11, 12, 13, 28, 28, 28, 28,
- 28, 14, 15, 28, 28, 28, 28, 28, 28, 28, 28, 16, 28, 28, 17, 28,
- 28, 18, 28, 19, 28, 28, 28, 28, 20, 21, 22, 23, 24, 25, 26, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B2_infos[29] = {
- o2(0x9F,0x8E), o2(0x9F,0x8B), o2(0x97,0x80), o2(0xFA,0xF7),
- o2(0x92,0xBE), o2(0x93,0xD7), o2(0x9F,0x8C), o2(0x9F,0x94),
- o2(0x9F,0x93), o2(0x8C,0x42), o2(0x89,0xAB), o2(0x8D,0xB9),
- o2(0x9F,0x8D), o2(0x9F,0x8F), o2(0x96,0x76), o2(0x91,0xF2),
- o2(0x96,0x97), o2(0x9F,0x9C), o2(0x9F,0x9D), o2(0x89,0xCD),
- o2(0x95,0xA6), o2(0x96,0xFB), o2(0x9F,0x9F), o2(0x8E,0xA1),
- o2(0x8F,0xC0), o2(0x9F,0x98), o2(0x9F,0x9E), o2(0x89,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B2 = {
- to_SHIFT_JIS_E6_B2_offsets,
- to_SHIFT_JIS_E6_B2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B3_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B3 */
- /* used from to_EUC_JP_E6_B3 */
- 23, 0, 23, 23, 1, 2, 23, 23, 23, 3, 4, 23, 5, 23, 23, 23,
- 23, 23, 23, 6, 23, 7, 23, 8, 23, 9, 10, 11, 23, 12, 23, 23,
- 23, 13, 14, 15, 23, 16, 23, 23, 17, 23, 18, 23, 23, 23, 23, 19,
- 20, 21, 23, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B3_infos[24] = {
- o2(0x8B,0xB5), o2(0x9F,0x95), o2(0x9F,0x9A), o2(0x90,0xF2),
- o2(0x94,0x91), o2(0x94,0xE5), o2(0x9F,0x97), o2(0x96,0x40),
- o2(0x9F,0x99), o2(0x9F,0xA2), o2(0xFA,0xF9), o2(0x9F,0xA0),
- o2(0x9F,0x9B), o2(0x96,0x41), o2(0x94,0x67), o2(0x8B,0x83),
- o2(0x93,0x44), o2(0x92,0x8D), o2(0x9F,0xA3), o2(0x9F,0xA1),
- o2(0x91,0xD7), o2(0x9F,0x96), o2(0x89,0x6A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B3 = {
- to_SHIFT_JIS_E6_B3_offsets,
- to_SHIFT_JIS_E6_B3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B4_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B4 */
- /* used from to_EUC_JP_E6_B4 */
- 21, 21, 21, 21, 0, 21, 21, 21, 21, 21, 21, 1, 2, 21, 21, 21,
- 21, 21, 3, 21, 21, 21, 21, 4, 21, 5, 21, 6, 21, 21, 7, 8,
- 21, 21, 21, 21, 21, 9, 21, 21, 21, 10, 11, 12, 21, 21, 21, 21,
- 21, 21, 13, 14, 21, 15, 16, 21, 17, 21, 21, 18, 21, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B4_infos[22] = {
- o2(0xFA,0xFA), o2(0x97,0x6D), o2(0x9F,0xAE), o2(0x9F,0xAD),
- o2(0x90,0xF4), o2(0x9F,0xAA), o2(0x97,0x8C), o2(0x93,0xB4),
- o2(0x9F,0xA4), o2(0x92,0xC3), o2(0x89,0x6B), o2(0x8D,0x5E),
- o2(0x9F,0xA7), o2(0x8F,0x46), o2(0x9F,0xAC), o2(0x9F,0xAB),
- o2(0x9F,0xA6), o2(0x9F,0xA9), o2(0x8A,0x88), o2(0x9F,0xA8),
- o2(0x94,0x68), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B4 = {
- to_SHIFT_JIS_E6_B4_offsets,
- to_SHIFT_JIS_E6_B4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B5_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B5 */
- /* used from to_EUC_JP_E6_B5 */
- 18, 0, 18, 18, 1, 2, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 3, 4, 18, 5, 18, 18, 18,
- 18, 18, 18, 6, 7, 18, 8, 18, 18, 9, 10, 18, 11, 18, 12, 13,
- 18, 18, 18, 18, 14, 18, 18, 15, 16, 17, 18, 18, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B5_infos[19] = {
- o2(0x97,0xAC), o2(0x8F,0xF2), o2(0x90,0xF3), o2(0x9F,0xB4),
- o2(0x9F,0xB2), o2(0x95,0x6C), o2(0x9F,0xAF), o2(0x9F,0xB1),
- o2(0x89,0x59), o2(0x8D,0x5F), o2(0x98,0x51), o2(0x8A,0x5C),
- o2(0x95,0x82), o2(0xFA,0xFC), o2(0x97,0x81), o2(0x8A,0x43),
- o2(0x90,0x5A), o2(0x9F,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B5 = {
- to_SHIFT_JIS_E6_B5_offsets,
- to_SHIFT_JIS_E6_B5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B6_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B6 */
- /* used from to_EUC_JP_E6_B6 */
- 17, 17, 17, 17, 17, 0, 17, 1, 2, 17, 17, 17, 3, 17, 4, 17,
- 17, 17, 17, 5, 17, 6, 7, 17, 17, 8, 17, 9, 10, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 11, 17, 17, 12,
- 17, 17, 13, 17, 17, 14, 17, 17, 15, 17, 17, 17, 16, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B6_infos[18] = {
- o2(0x9F,0xB8), o2(0xFA,0xFB), o2(0x8F,0xC1), o2(0x97,0x4F),
- o2(0x9F,0xB5), o2(0x9F,0xB0), o2(0x9F,0xB6), o2(0xFB,0x40),
- o2(0x97,0xDC), o2(0x93,0x93), o2(0x93,0xC0), o2(0xFB,0x41),
- o2(0x8A,0x55), o2(0x89,0x74), o2(0x9F,0xBC), o2(0x9F,0xBF),
- o2(0x97,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B6 = {
- to_SHIFT_JIS_E6_B6_offsets,
- to_SHIFT_JIS_E6_B6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B7_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B7 */
- /* used from to_EUC_JP_E6_B7 */
- 0, 31, 31, 31, 31, 1, 2, 3, 31, 31, 31, 4, 5, 31, 31, 6,
- 31, 7, 8, 31, 31, 9, 31, 31, 10, 11, 31, 31, 31, 31, 12, 31,
- 31, 13, 31, 31, 14, 31, 15, 31, 16, 31, 17, 18, 19, 31, 20, 31,
- 31, 21, 22, 23, 31, 24, 31, 25, 26, 27, 28, 29, 30, 31, 31, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B7_infos[32] = {
- o2(0x97,0x84), o2(0x9F,0xC6), o2(0x9F,0xC0), o2(0x9F,0xBD),
- o2(0x97,0xD2), o2(0x9F,0xC3), o2(0xFB,0x42), o2(0x8F,0x69),
- o2(0x9F,0xC5), o2(0x9F,0xCA), o2(0x93,0x91), o2(0x9F,0xC8),
- o2(0x9F,0xC2), o2(0x92,0x57), o2(0x9F,0xC9), o2(0x9F,0xBE),
- o2(0x9F,0xC4), o2(0x9F,0xCB), o2(0x88,0xFA), o2(0x9F,0xC1),
- o2(0x9F,0xCC), o2(0x90,0x5B), o2(0xFB,0x44), o2(0x8F,0x7E),
- o2(0x95,0xA3), o2(0x8D,0xAC), o2(0xFB,0x43), o2(0x9F,0xB9),
- o2(0x9F,0xC7), o2(0x93,0x59), o2(0xFB,0x45), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B7 = {
- to_SHIFT_JIS_E6_B7_offsets,
- to_SHIFT_JIS_E6_B7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B8_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B8 */
- /* used from to_EUC_JP_E6_B8 */
- 31, 31, 31, 31, 31, 0, 31, 1, 2, 3, 4, 5, 31, 31, 31, 31,
- 31, 31, 31, 6, 31, 7, 31, 31, 31, 8, 9, 10, 31, 11, 31, 12,
- 13, 14, 31, 15, 16, 17, 18, 19, 31, 20, 31, 21, 22, 23, 24, 25,
- 31, 31, 31, 31, 31, 31, 31, 31, 26, 27, 28, 31, 29, 31, 30, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B8_infos[32] = {
- o2(0x90,0xB4), o2(0x8A,0x89), o2(0x8D,0xCF), o2(0x8F,0xC2),
- o2(0x9F,0xBB), o2(0x8F,0x61), o2(0x8C,0x6B), o2(0x9F,0xBA),
- o2(0x9F,0xD0), o2(0x8F,0x8D), o2(0x8C,0xB8), o2(0x9F,0xDF),
- o2(0x9F,0xD9), o2(0x8B,0x94), o2(0x93,0x6E), o2(0x9F,0xD4),
- o2(0x9F,0xDD), o2(0x88,0xAD), o2(0x89,0x51), o2(0xFB,0x48),
- o2(0x89,0xB7), o2(0x9F,0xD6), o2(0x91,0xAA), o2(0x9F,0xCD),
- o2(0x9F,0xCF), o2(0x8D,0x60), o2(0x9F,0xE0), o2(0xFB,0x46),
- o2(0x9F,0xDB), o2(0xFB,0x49), o2(0x9F,0xD3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B8 = {
- to_SHIFT_JIS_E6_B8_offsets,
- to_SHIFT_JIS_E6_B8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_B9_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_B9 */
- /* used from to_EUC_JP_E6_B9 */
- 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 1, 17, 17, 2, 3, 17,
- 17, 17, 17, 17, 17, 17, 4, 17, 5, 17, 17, 6, 7, 17, 17, 8,
- 17, 17, 17, 17, 17, 17, 17, 9, 17, 17, 17, 10, 17, 17, 11, 12,
- 17, 17, 13, 17, 17, 17, 14, 17, 17, 17, 17, 17, 17, 17, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_B9_infos[18] = {
- o2(0x9F,0xDA), o2(0x96,0xA9), o2(0x9F,0xD8), o2(0x9F,0xDC),
- o2(0x8C,0xCE), o2(0x8F,0xC3), o2(0x92,0x58), o2(0xFB,0x47),
- o2(0x9F,0xD2), o2(0x97,0x4E), o2(0x9F,0xD5), o2(0x9F,0xCE),
- o2(0x93,0x92), o2(0x9F,0xD1), o2(0x9F,0xD7), o2(0x98,0x70),
- o2(0x8E,0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_B9 = {
- to_SHIFT_JIS_E6_B9_offsets,
- to_SHIFT_JIS_E6_B9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_BA_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_BA */
- /* used from to_EUC_JP_E6_BA */
- 0, 20, 1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 2, 20, 20, 3,
- 4, 20, 20, 20, 20, 20, 5, 20, 6, 20, 20, 20, 7, 8, 20, 9,
- 20, 20, 10, 20, 20, 11, 20, 20, 20, 20, 12, 20, 20, 20, 20, 13,
- 20, 20, 14, 20, 20, 20, 15, 16, 20, 20, 17, 20, 20, 18, 20, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_BA_infos[21] = {
- o2(0x96,0x9E), o2(0x9F,0xE1), o2(0x94,0xAC), o2(0x9F,0xED),
- o2(0x8C,0xB9), o2(0x8F,0x80), o2(0x9F,0xE3), o2(0x97,0xAD),
- o2(0x8D,0x61), o2(0x9F,0xF0), o2(0x88,0xEC), o2(0x9F,0xEE),
- o2(0x9F,0xE2), o2(0x9F,0xE8), o2(0x9F,0xEA), o2(0x97,0x6E),
- o2(0x9F,0xE5), o2(0x93,0x4D), o2(0x9F,0xE7), o2(0xFB,0x4A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_BA = {
- to_SHIFT_JIS_E6_BA_offsets,
- to_SHIFT_JIS_E6_BA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_BB_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_BB */
- /* used from to_EUC_JP_E6_BB */
- 20, 20, 0, 20, 1, 2, 20, 20, 20, 3, 20, 4, 5, 20, 20, 20,
- 20, 6, 20, 7, 8, 9, 20, 20, 20, 20, 20, 20, 20, 10, 11, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 12, 20, 20, 13,
- 20, 20, 14, 20, 15, 20, 20, 16, 17, 20, 20, 20, 20, 20, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_BB_infos[21] = {
- o2(0x9F,0xEF), o2(0x9F,0xE9), o2(0x96,0xC5), o2(0x9F,0xE4),
- o2(0x8E,0xA0), o2(0x9F,0xFC), o2(0x8A,0x8A), o2(0x9F,0xE6),
- o2(0x9F,0xEB), o2(0x9F,0xEC), o2(0x91,0xEA), o2(0x91,0xD8),
- o2(0x9F,0xF4), o2(0x9F,0xFA), o2(0x9F,0xF8), o2(0x93,0x48),
- o2(0xE0,0x42), o2(0x9F,0xF5), o2(0x9F,0xF6), o2(0x9F,0xDE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_BB = {
- to_SHIFT_JIS_E6_BB_offsets,
- to_SHIFT_JIS_E6_BB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_BC */
- /* used from to_EUC_JP_E6_BC */
- 19, 0, 1, 19, 19, 19, 2, 19, 19, 3, 19, 19, 19, 19, 19, 4,
- 19, 5, 19, 6, 7, 8, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 9, 19, 10, 11, 19, 19, 19, 19, 19, 19, 19, 12, 13, 19, 19, 19,
- 19, 14, 15, 19, 19, 19, 19, 19, 16, 19, 19, 19, 19, 19, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_BC_infos[20] = {
- o2(0x8B,0x99), o2(0x95,0x59), o2(0x8E,0xBD), o2(0x8D,0x97),
- o2(0x98,0x52), o2(0x9F,0xF2), o2(0xE0,0x41), o2(0x89,0x89),
- o2(0x91,0x86), o2(0x94,0x99), o2(0x8A,0xBF), o2(0x97,0xF8),
- o2(0x96,0x9F), o2(0x92,0xD0), o2(0x9F,0xF9), o2(0x9F,0xFB),
- o2(0x91,0x51), o2(0xE0,0x40), o2(0x9F,0xF7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_BC = {
- to_SHIFT_JIS_E6_BC_offsets,
- to_SHIFT_JIS_E6_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_BD */
- /* used from to_EUC_JP_E6_BD */
- 17, 0, 17, 17, 17, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 2, 17, 17, 17, 3, 17, 17, 4, 5, 17, 17, 6,
- 17, 17, 17, 17, 7, 17, 8, 17, 17, 17, 17, 17, 17, 9, 10, 11,
- 12, 17, 17, 17, 13, 17, 17, 17, 14, 17, 15, 17, 16, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_BD_infos[18] = {
- o2(0x9F,0xF1), o2(0x8A,0xC1), o2(0x8C,0x89), o2(0xE0,0x4E),
- o2(0xE0,0x49), o2(0x90,0xF6), o2(0x8A,0x83), o2(0x8F,0x81),
- o2(0xE0,0x52), o2(0xE0,0x4B), o2(0x92,0xAA), o2(0xE0,0x48),
- o2(0x92,0xD7), o2(0xE0,0x6B), o2(0xE0,0x45), o2(0xE0,0x44),
- o2(0xE0,0x4D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_BD = {
- to_SHIFT_JIS_E6_BD_offsets,
- to_SHIFT_JIS_E6_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_BE */
- /* used from to_EUC_JP_E6_BE */
- 0, 1, 2, 17, 3, 17, 4, 17, 5, 17, 17, 17, 17, 17, 6, 17,
- 17, 7, 17, 17, 17, 17, 17, 8, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 9, 17, 10, 11, 17, 17, 17, 17, 17, 12, 17, 17, 17, 17, 17,
- 17, 13, 17, 14, 17, 15, 17, 17, 17, 16, 17, 17, 17, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_BE_infos[18] = {
- o2(0xE0,0x47), o2(0xE0,0x46), o2(0xE0,0x4C), o2(0x90,0x9F),
- o2(0xE0,0x43), o2(0xFB,0x4B), o2(0xE0,0x4F), o2(0xE0,0x50),
- o2(0x8A,0xC0), o2(0xE0,0x55), o2(0xE0,0x54), o2(0xE0,0x56),
- o2(0xE0,0x59), o2(0x93,0x62), o2(0xE0,0x53), o2(0xFB,0x4C),
- o2(0xE0,0x57), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_BE = {
- to_SHIFT_JIS_E6_BE_offsets,
- to_SHIFT_JIS_E6_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E6_BF_offsets[64] = {
- /* used from to_SHIFT_JIS_E6_BF */
- /* used from to_EUC_JP_E6_BF */
- 0, 1, 2, 3, 23, 23, 4, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 5, 6, 23, 23, 7, 23, 23, 8, 23, 23, 23, 9,
- 10, 11, 23, 23, 12, 23, 23, 23, 23, 23, 23, 13, 14, 23, 15, 16,
- 23, 17, 23, 18, 23, 19, 20, 23, 23, 23, 21, 23, 23, 23, 22, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_BF_infos[24] = {
- o2(0x8C,0x83), o2(0x91,0xF7), o2(0xE0,0x51), o2(0x94,0x5A),
- o2(0xE0,0x58), o2(0xE0,0x5D), o2(0xE0,0x5B), o2(0xE0,0x5E),
- o2(0xE0,0x61), o2(0xE0,0x5A), o2(0x8D,0x8A), o2(0x94,0x47),
- o2(0x9F,0xB7), o2(0x97,0x94), o2(0xE0,0x5C), o2(0xE0,0x60),
- o2(0x91,0xF3), o2(0xE0,0x5F), o2(0xE0,0x4A), o2(0xFB,0x4D),
- o2(0xE8,0x89), o2(0xE0,0x64), o2(0xE0,0x68), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6_BF = {
- to_SHIFT_JIS_E6_BF_offsets,
- to_SHIFT_JIS_E6_BF_infos
-};
-
-static const struct byte_lookup* const
-to_SHIFT_JIS_E6_infos[64] = {
- &to_SHIFT_JIS_E6_80, &to_SHIFT_JIS_E6_81,
- &to_SHIFT_JIS_E6_82, &to_SHIFT_JIS_E6_83,
- &to_SHIFT_JIS_E6_84, &to_SHIFT_JIS_E6_85,
- &to_SHIFT_JIS_E6_86, &to_SHIFT_JIS_E6_87,
- &to_SHIFT_JIS_E6_88, &to_SHIFT_JIS_E6_89,
- &to_SHIFT_JIS_E6_8A, &to_SHIFT_JIS_E6_8B,
- &to_SHIFT_JIS_E6_8C, &to_SHIFT_JIS_E6_8D,
- &to_SHIFT_JIS_E6_8E, &to_SHIFT_JIS_E6_8F,
- &to_SHIFT_JIS_E6_90, &to_SHIFT_JIS_E6_91,
- &to_SHIFT_JIS_E6_92, &to_SHIFT_JIS_E6_93,
- &to_SHIFT_JIS_E6_94, &to_SHIFT_JIS_E6_95,
- &to_SHIFT_JIS_E6_96, &to_SHIFT_JIS_E6_97,
- &to_SHIFT_JIS_E6_98, &to_SHIFT_JIS_E6_99,
- &to_SHIFT_JIS_E6_9A, &to_SHIFT_JIS_E6_9B,
- &to_SHIFT_JIS_E6_9C, &to_SHIFT_JIS_E6_9D,
- &to_SHIFT_JIS_E6_9E, &to_SHIFT_JIS_E6_9F,
- &to_SHIFT_JIS_E6_A0, &to_SHIFT_JIS_E6_A1,
- &to_SHIFT_JIS_E6_A2, &to_SHIFT_JIS_E6_A3,
- &to_SHIFT_JIS_E6_A4, &to_SHIFT_JIS_E6_A5,
- &to_SHIFT_JIS_E6_A6, &to_SHIFT_JIS_E6_A7,
- &to_SHIFT_JIS_E6_A8, &to_SHIFT_JIS_E6_A9,
- &to_SHIFT_JIS_E6_AA, &to_SHIFT_JIS_E6_AB,
- &to_SHIFT_JIS_E6_AC, &to_SHIFT_JIS_E6_AD,
- &to_SHIFT_JIS_E6_AE, &to_SHIFT_JIS_E6_AF,
- &to_SHIFT_JIS_E6_B0, &to_SHIFT_JIS_E6_B1,
- &to_SHIFT_JIS_E6_B2, &to_SHIFT_JIS_E6_B3,
- &to_SHIFT_JIS_E6_B4, &to_SHIFT_JIS_E6_B5,
- &to_SHIFT_JIS_E6_B6, &to_SHIFT_JIS_E6_B7,
- &to_SHIFT_JIS_E6_B8, &to_SHIFT_JIS_E6_B9,
- &to_SHIFT_JIS_E6_BA, &to_SHIFT_JIS_E6_BB,
- &to_SHIFT_JIS_E6_BC, &to_SHIFT_JIS_E6_BD,
- &to_SHIFT_JIS_E6_BE, &to_SHIFT_JIS_E6_BF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E6 = {
- to_SHIFT_JIS_E5_offsets,
- to_SHIFT_JIS_E6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_80 */
- /* used from to_EUC_JP_E7_80 */
- 21, 0, 21, 21, 21, 1, 21, 2, 21, 3, 21, 4, 21, 21, 21, 5,
- 21, 6, 21, 21, 21, 7, 21, 21, 8, 21, 9, 10, 21, 11, 12, 13,
- 21, 21, 21, 21, 21, 21, 14, 15, 16, 21, 21, 21, 17, 21, 21, 21,
- 18, 21, 19, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_80_infos[22] = {
- o2(0xE0,0x66), o2(0xFB,0x4E), o2(0xFB,0x4F), o2(0xE0,0x62),
- o2(0xE0,0x63), o2(0xE0,0x67), o2(0xE0,0x65), o2(0x95,0x6D),
- o2(0xE0,0x6D), o2(0xE0,0x6A), o2(0xE0,0x69), o2(0xE0,0x6C),
- o2(0x93,0xD2), o2(0xE0,0x6E), o2(0x92,0x95), o2(0x91,0xEB),
- o2(0xFB,0x50), o2(0x90,0xA3), o2(0xE0,0x6F), o2(0xE0,0x71),
- o2(0xE0,0x70), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_80 = {
- to_SHIFT_JIS_E7_80_offsets,
- to_SHIFT_JIS_E7_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_81_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_81 */
- /* used from to_EUC_JP_E7_81 */
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 10, 10, 10,
- 10, 1, 10, 10, 10, 10, 10, 10, 2, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 3, 10, 10, 10, 10, 10, 10, 10, 4, 10, 10, 10, 5,
- 6, 10, 10, 10, 10, 10, 10, 10, 7, 10, 10, 10, 8, 9, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_81_infos[11] = {
- o2(0x9F,0xF3), o2(0xE0,0x72), o2(0x93,0xE5), o2(0xE0,0x73),
- o2(0x89,0xCE), o2(0x93,0x94), o2(0x8A,0x44), o2(0x8B,0x84),
- o2(0x8E,0xDC), o2(0x8D,0xD0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_81 = {
- to_SHIFT_JIS_E7_81_offsets,
- to_SHIFT_JIS_E7_81_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_82_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_82 */
- /* used from to_EUC_JP_E7_82 */
- 16, 16, 16, 16, 16, 0, 16, 16, 16, 1, 2, 16, 16, 16, 3, 16,
- 16, 16, 4, 16, 16, 16, 16, 16, 16, 5, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 7, 8, 9, 10,
- 16, 16, 16, 11, 16, 16, 16, 16, 12, 13, 14, 15, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_82_infos[17] = {
- o2(0xFB,0x51), o2(0x98,0x46), o2(0x90,0x86), o2(0x89,0x8A),
- o2(0xE0,0x75), o2(0xE0,0x74), o2(0xFB,0x52), o2(0xE0,0x78),
- o2(0x92,0x59), o2(0xE0,0x7B), o2(0xE0,0x76), o2(0xE0,0x7A),
- o2(0xE0,0x79), o2(0x93,0x5F), o2(0x88,0xD7), o2(0xFA,0x62),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_82 = {
- to_SHIFT_JIS_E7_82_offsets,
- to_SHIFT_JIS_E7_82_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_83_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_83 */
- /* used from to_EUC_JP_E7_83 */
- 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 1, 9, 9, 9, 2,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 9, 9, 9, 4, 9, 5,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 6, 9, 9, 9, 9, 9, 9, 9, 7, 9, 9, 9, 8, 9, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_83_infos[10] = {
- o2(0x97,0xF3), o2(0xE0,0x7D), o2(0x89,0x47), o2(0xE0,0x80),
- o2(0xE0,0x7E), o2(0xE0,0x7C), o2(0xE0,0x77), o2(0x96,0x42),
- o2(0xE0,0x82), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_83 = {
- to_SHIFT_JIS_E7_83_offsets,
- to_SHIFT_JIS_E7_83_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_84_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_84 */
- /* used from to_EUC_JP_E7_84 */
- 11, 11, 11, 11, 0, 11, 11, 11, 11, 1, 11, 11, 11, 11, 11, 2,
- 11, 11, 11, 11, 3, 11, 11, 11, 11, 4, 5, 11, 6, 11, 11, 11,
- 11, 7, 11, 11, 11, 11, 8, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 9, 11, 11, 11, 11, 11, 10, 11, 11, 11,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_84_infos[12] = {
- o2(0xFB,0x54), o2(0xE0,0x81), o2(0xFB,0x53), o2(0x89,0x8B),
- o2(0xE0,0x84), o2(0x95,0xB0), o2(0xE0,0x83), o2(0x96,0xB3),
- o2(0x8F,0xC5), o2(0x91,0x52), o2(0x8F,0xC4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_84 = {
- to_SHIFT_JIS_E7_84_offsets,
- to_SHIFT_JIS_E7_84_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_85_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_85 */
- /* used from to_EUC_JP_E7_85 */
- 18, 18, 18, 18, 18, 18, 0, 1, 18, 2, 18, 18, 3, 18, 4, 18,
- 18, 18, 18, 18, 18, 5, 6, 18, 18, 7, 18, 18, 8, 18, 18, 18,
- 18, 18, 9, 18, 10, 11, 12, 13, 18, 14, 18, 18, 15, 18, 16, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_85_infos[19] = {
- o2(0xFB,0x56), o2(0xFB,0x57), o2(0x97,0xF9), o2(0xE0,0x8A),
- o2(0x90,0xF7), o2(0xE0,0x86), o2(0xE0,0x8B), o2(0x89,0x8C),
- o2(0xFB,0x55), o2(0xE0,0x89), o2(0x94,0x81), o2(0xE0,0x85),
- o2(0xE0,0x88), o2(0x8F,0xC6), o2(0x94,0xCF), o2(0xE0,0x8C),
- o2(0x8E,0xCF), o2(0x90,0xF8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_85 = {
- to_SHIFT_JIS_E7_85_offsets,
- to_SHIFT_JIS_E7_85_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_86_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_86 */
- /* used from to_EUC_JP_E7_86 */
- 13, 13, 13, 13, 0, 13, 13, 13, 1, 13, 2, 13, 13, 13, 13, 3,
- 13, 13, 13, 13, 4, 5, 13, 13, 13, 6, 13, 13, 13, 13, 13, 7,
- 13, 13, 13, 13, 13, 13, 13, 13, 8, 13, 13, 13, 9, 13, 13, 13,
- 13, 10, 13, 13, 13, 13, 13, 13, 13, 11, 13, 13, 13, 13, 12, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_86_infos[14] = {
- o2(0xE0,0x8F), o2(0xE0,0x87), o2(0x8C,0x46), o2(0xE0,0x8D),
- o2(0x97,0x6F), o2(0xE0,0x90), o2(0xEA,0xA4), o2(0x8F,0x6E),
- o2(0xE0,0x91), o2(0xE0,0x92), o2(0x94,0x4D), o2(0xE0,0x94),
- o2(0xE0,0x95), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_86 = {
- to_SHIFT_JIS_E7_86_offsets,
- to_SHIFT_JIS_E7_86_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_87_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_87 */
- /* used from to_EUC_JP_E7_87 */
- 24, 0, 24, 1, 24, 24, 24, 24, 2, 3, 24, 24, 24, 24, 4, 24,
- 5, 24, 6, 24, 7, 8, 24, 9, 24, 24, 24, 24, 24, 24, 24, 10,
- 11, 24, 24, 24, 24, 12, 13, 14, 24, 24, 24, 24, 15, 16, 17, 24,
- 24, 24, 24, 24, 24, 18, 24, 24, 24, 19, 24, 20, 21, 24, 22, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_87_infos[25] = {
- o2(0xFB,0x59), o2(0x94,0x52), o2(0x93,0x95), o2(0xE0,0x97),
- o2(0xE0,0x99), o2(0x97,0xD3), o2(0xE0,0x96), o2(0xE0,0x98),
- o2(0x89,0x8D), o2(0xE0,0x93), o2(0x9A,0x7A), o2(0xE0,0x9A),
- o2(0x91,0x87), o2(0x8E,0x57), o2(0xE0,0x9C), o2(0xE0,0x9B),
- o2(0x90,0x43), o2(0x99,0xD7), o2(0xE0,0x9D), o2(0xE0,0x9F),
- o2(0xE0,0x8E), o2(0xE0,0x9E), o2(0xFB,0x5A), o2(0xE0,0xA0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_87 = {
- to_SHIFT_JIS_E7_87_offsets,
- to_SHIFT_JIS_E7_87_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_88 */
- /* used from to_EUC_JP_E7_88 */
- 18, 18, 18, 18, 18, 18, 0, 18, 18, 18, 18, 18, 18, 1, 18, 18,
- 2, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 3, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 4, 18, 5, 18, 6, 7, 18, 18,
- 8, 18, 9, 18, 18, 10, 11, 18, 18, 18, 12, 13, 14, 15, 16, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_88_infos[19] = {
- o2(0x94,0x9A), o2(0xE0,0xA1), o2(0xE0,0xA2), o2(0xE0,0xA3),
- o2(0xE0,0xA4), o2(0x92,0xDC), o2(0xE0,0xA6), o2(0xE0,0xA5),
- o2(0xE0,0xA7), o2(0xE0,0xA8), o2(0x8E,0xDD), o2(0x95,0x83),
- o2(0x96,0xEA), o2(0xE0,0xA9), o2(0xE0,0xAA), o2(0x91,0x75),
- o2(0x8E,0xA2), o2(0xE0,0xAB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_88 = {
- to_SHIFT_JIS_E7_88_offsets,
- to_SHIFT_JIS_E7_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_89_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_89 */
- /* used from to_EUC_JP_E7_89 */
- 0, 21, 21, 21, 21, 21, 1, 2, 3, 21, 21, 4, 5, 21, 21, 21,
- 21, 21, 6, 21, 21, 21, 21, 21, 7, 8, 21, 9, 21, 10, 21, 11,
- 21, 12, 13, 21, 21, 21, 21, 14, 21, 15, 21, 21, 21, 21, 21, 21,
- 21, 21, 16, 21, 17, 21, 21, 21, 21, 18, 21, 21, 21, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_89_infos[22] = {
- o2(0xE0,0xAC), o2(0xE0,0xAD), o2(0x95,0xD0), o2(0x94,0xC5),
- o2(0xE0,0xAE), o2(0x94,0x76), o2(0x92,0xAB), o2(0xE0,0xAF),
- o2(0x89,0xE5), o2(0x8B,0x8D), o2(0x96,0xC4), o2(0x96,0xB4),
- o2(0x89,0xB2), o2(0x98,0x53), o2(0x96,0x71), o2(0x95,0xA8),
- o2(0x90,0xB5), o2(0xE0,0xB0), o2(0x93,0xC1), o2(0x8C,0xA1),
- o2(0xE0,0xB1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_89 = {
- to_SHIFT_JIS_E7_89_offsets,
- to_SHIFT_JIS_E7_89_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_8A */
- /* used from to_EUC_JP_E7_8A */
- 0, 1, 2, 16, 16, 16, 16, 3, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 4, 16, 16, 16, 5, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 6, 16, 7, 16, 16, 16, 16, 8, 16, 16, 16, 16, 9, 16, 16, 10,
- 16, 11, 12, 16, 16, 16, 13, 16, 16, 14, 16, 16, 16, 16, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_8A_infos[17] = {
- o2(0x8D,0xD2), o2(0xE0,0xB3), o2(0xE0,0xB2), o2(0xE0,0xB4),
- o2(0xE0,0xB5), o2(0xE0,0xB6), o2(0x8B,0x5D), o2(0xE0,0xB7),
- o2(0xE0,0xB8), o2(0x8C,0xA2), o2(0x94,0xC6), o2(0xFB,0x5B),
- o2(0xE0,0xBA), o2(0x8F,0xF3), o2(0xE0,0xB9), o2(0xFB,0x5C),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_8A = {
- to_SHIFT_JIS_E7_8A_offsets,
- to_SHIFT_JIS_E7_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_8B_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_8B */
- /* used from to_EUC_JP_E7_8B */
- 21, 21, 0, 1, 2, 21, 3, 21, 21, 21, 21, 21, 21, 21, 4, 21,
- 5, 21, 6, 21, 21, 21, 21, 7, 21, 8, 21, 9, 21, 21, 21, 21,
- 10, 11, 12, 21, 21, 21, 21, 21, 21, 13, 21, 21, 14, 15, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 16, 17, 18, 21, 21, 19, 20, 21, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_8B_infos[22] = {
- o2(0x8B,0xB6), o2(0xE0,0xBB), o2(0xE0,0xBD), o2(0xE0,0xBC),
- o2(0xE0,0xBE), o2(0x8C,0xCF), o2(0xE0,0xBF), o2(0x8B,0xE7),
- o2(0x91,0x5F), o2(0x8D,0x9D), o2(0xE0,0xC1), o2(0xE0,0xC2),
- o2(0xE0,0xC0), o2(0x8E,0xEB), o2(0x93,0xC6), o2(0x8B,0xB7),
- o2(0xE0,0xC4), o2(0x92,0x4B), o2(0xE0,0xC3), o2(0x98,0x54),
- o2(0x94,0x82), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_8B = {
- to_SHIFT_JIS_E7_8B_offsets,
- to_SHIFT_JIS_E7_8B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_8C */
- /* used from to_EUC_JP_E7_8C */
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 1, 2, 19, 19, 19, 3, 4, 5, 19, 6,
- 19, 19, 19, 19, 7, 8, 19, 19, 19, 9, 10, 11, 19, 19, 12, 13,
- 19, 19, 19, 19, 14, 19, 15, 16, 19, 19, 19, 19, 19, 19, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_8C_infos[20] = {
- o2(0xE0,0xC7), o2(0xE0,0xC9), o2(0xE0,0xC6), o2(0x96,0xD2),
- o2(0xE0,0xC8), o2(0xE0,0xCA), o2(0x97,0xC2), o2(0xFB,0x5D),
- o2(0xE0,0xCE), o2(0xE0,0xCD), o2(0x92,0x96), o2(0x94,0x4C),
- o2(0x8C,0xA3), o2(0xE0,0xCC), o2(0xE0,0xCB), o2(0x97,0x50),
- o2(0x97,0x51), o2(0xE0,0xCF), o2(0x89,0x8E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_8C = {
- to_SHIFT_JIS_E7_8C_offsets,
- to_SHIFT_JIS_E7_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_8D_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_8D */
- /* used from to_EUC_JP_E7_8D */
- 15, 15, 15, 15, 0, 1, 15, 15, 15, 15, 15, 15, 15, 15, 2, 3,
- 15, 15, 15, 15, 15, 15, 15, 4, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 5, 15, 15, 15, 15, 6, 15, 7, 15, 15, 15, 15, 15,
- 8, 15, 9, 15, 15, 10, 15, 11, 12, 15, 13, 14, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_8D_infos[16] = {
- o2(0x8D,0x96), o2(0x8E,0x82), o2(0xE0,0xD0), o2(0xE0,0xD1),
- o2(0xE0,0xD3), o2(0x8F,0x62), o2(0xE0,0xD5), o2(0xE0,0xD4),
- o2(0xE0,0xD6), o2(0x8A,0x6C), o2(0xE0,0xD8), o2(0xFB,0x5F),
- o2(0xE0,0xD7), o2(0xE0,0xDA), o2(0xE0,0xD9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_8D = {
- to_SHIFT_JIS_E7_8D_offsets,
- to_SHIFT_JIS_E7_8D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_8E_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_8E */
- /* used from to_EUC_JP_E7_8E */
- 10, 10, 10, 10, 0, 10, 10, 1, 10, 2, 10, 3, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 4, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 10, 10, 10, 10, 10, 10,
- 10, 10, 6, 7, 10, 10, 10, 10, 10, 10, 10, 8, 10, 9, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_8E_infos[11] = {
- o2(0x8C,0xBA), o2(0x97,0xA6), o2(0x8B,0xCA), o2(0x89,0xA4),
- o2(0x8B,0xE8), o2(0x8A,0xDF), o2(0x97,0xE6), o2(0xE0,0xDC),
- o2(0xE0,0xDE), o2(0xFB,0x60), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_8E = {
- to_SHIFT_JIS_E7_8E_offsets,
- to_SHIFT_JIS_E7_8E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_8F_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_8F */
- /* used from to_EUC_JP_E7_8F */
- 0, 20, 1, 20, 20, 20, 20, 20, 2, 3, 4, 20, 20, 5, 6, 20,
- 20, 20, 7, 20, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 9, 20,
- 10, 20, 20, 11, 20, 12, 20, 20, 20, 20, 13, 20, 20, 14, 15, 20,
- 20, 16, 20, 20, 20, 17, 20, 20, 18, 20, 20, 20, 20, 20, 19, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_8F_infos[21] = {
- o2(0xE0,0xDF), o2(0x89,0xCF), o2(0xE0,0xDB), o2(0xFB,0x61),
- o2(0x8E,0x58), o2(0x92,0xBF), o2(0xE0,0xDD), o2(0xFB,0x64),
- o2(0xFB,0x62), o2(0xE0,0xE2), o2(0x8E,0xEC), o2(0xFB,0x63),
- o2(0xE0,0xE0), o2(0x8C,0x5D), o2(0x94,0xC7), o2(0xE0,0xE1),
- o2(0xE0,0xFC), o2(0xFB,0x66), o2(0xE0,0xE7), o2(0x8C,0xBB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_8F = {
- to_SHIFT_JIS_E7_8F_offsets,
- to_SHIFT_JIS_E7_8F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_90_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_90 */
- /* used from to_EUC_JP_E7_90 */
- 18, 18, 18, 0, 18, 1, 2, 3, 18, 4, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 5, 18, 18, 6, 7, 18, 18, 8, 9, 18, 18, 18, 10, 18,
- 18, 18, 11, 12, 13, 14, 15, 18, 18, 18, 16, 18, 18, 18, 18, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_90_infos[19] = {
- o2(0x8B,0x85), o2(0xE0,0xE4), o2(0x97,0x9D), o2(0xFB,0x65),
- o2(0x97,0xAE), o2(0x91,0xF4), o2(0xE0,0xE6), o2(0xFB,0x67),
- o2(0xFB,0x69), o2(0xFB,0x68), o2(0xFB,0x6A), o2(0xE0,0xE8),
- o2(0x97,0xD4), o2(0x8B,0xD5), o2(0x94,0xFA), o2(0x94,0x69),
- o2(0xE0,0xE9), o2(0xE0,0xEB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_90 = {
- to_SHIFT_JIS_E7_90_offsets,
- to_SHIFT_JIS_E7_90_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_91_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_91 */
- /* used from to_EUC_JP_E7_91 */
- 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 1, 19, 19, 19, 2, 3, 4, 5, 19, 6, 7,
- 8, 19, 9, 10, 11, 19, 19, 19, 19, 12, 13, 19, 19, 19, 19, 14,
- 15, 19, 19, 16, 19, 19, 17, 19, 19, 19, 19, 19, 19, 19, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_91_infos[20] = {
- o2(0xE0,0xEE), o2(0xE0,0xEA), o2(0xE0,0xED), o2(0x8C,0xE8),
- o2(0x89,0x6C), o2(0xE0,0xEF), o2(0x90,0x90), o2(0xE0,0xEC),
- o2(0x97,0xDA), o2(0xFB,0x6B), o2(0xE0,0xF2), o2(0xEA,0xA2),
- o2(0xE0,0xF0), o2(0xE0,0xF3), o2(0xE0,0xE5), o2(0xE0,0xF1),
- o2(0x8D,0xBA), o2(0xE0,0xF4), o2(0xE0,0xF5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_91 = {
- to_SHIFT_JIS_E7_91_offsets,
- to_SHIFT_JIS_E7_91_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_92_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_92 */
- /* used from to_EUC_JP_E7_92 */
- 9, 9, 9, 0, 9, 9, 9, 9, 9, 1, 9, 2, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 4,
- 9, 9, 5, 9, 9, 9, 9, 6, 9, 9, 9, 9, 9, 9, 9, 9,
- 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 9, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_92_infos[10] = {
- o2(0x97,0x9E), o2(0xFB,0x6C), o2(0xE0,0xF6), o2(0xE0,0xF7),
- o2(0xFB,0x6D), o2(0xE0,0xE3), o2(0xE0,0xF8), o2(0x8A,0xC2),
- o2(0x8E,0xA3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_92 = {
- to_SHIFT_JIS_E7_92_offsets,
- to_SHIFT_JIS_E7_92_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_93_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_93 */
- /* used from to_EUC_JP_E7_93 */
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 1,
- 17, 17, 17, 17, 2, 17, 17, 17, 17, 17, 17, 17, 3, 17, 17, 17,
- 4, 17, 5, 6, 17, 17, 7, 8, 17, 9, 17, 17, 17, 17, 10, 17,
- 11, 12, 13, 17, 17, 17, 14, 15, 16, 17, 17, 17, 17, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_93_infos[18] = {
- o2(0xE0,0xF9), o2(0xE0,0xFA), o2(0xE0,0xFB), o2(0x89,0x5A),
- o2(0xE1,0x40), o2(0x95,0x5A), o2(0xE1,0x41), o2(0x8A,0xA2),
- o2(0xE1,0x42), o2(0xE1,0x43), o2(0xE1,0x44), o2(0xE1,0x46),
- o2(0xE1,0x47), o2(0xE1,0x45), o2(0x95,0x72), o2(0xE1,0x49),
- o2(0xE1,0x48), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_93 = {
- to_SHIFT_JIS_E7_93_offsets,
- to_SHIFT_JIS_E7_93_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_94_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_94 */
- /* used from to_EUC_JP_E7_94 */
- 31, 0, 31, 1, 2, 3, 31, 31, 31, 31, 31, 31, 4, 5, 6, 31,
- 31, 7, 31, 8, 31, 9, 31, 31, 10, 31, 11, 31, 12, 31, 13, 14,
- 31, 31, 31, 15, 31, 16, 17, 31, 18, 31, 31, 19, 20, 31, 31, 21,
- 22, 23, 24, 25, 31, 31, 31, 26, 27, 31, 28, 29, 30, 31, 31, 31,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_94_infos[32] = {
- o2(0xFB,0x6E), o2(0xE1,0x4B), o2(0xE1,0x4A), o2(0xE1,0x4C),
- o2(0xE1,0x4D), o2(0xE1,0x4F), o2(0xE1,0x4E), o2(0x8D,0x99),
- o2(0xE1,0x51), o2(0xE1,0x50), o2(0x8A,0xC3), o2(0x90,0x72),
- o2(0x93,0x5B), o2(0xE1,0x52), o2(0x90,0xB6), o2(0x8E,0x59),
- o2(0x89,0x99), o2(0xE1,0x53), o2(0x97,0x70), o2(0x95,0xE1),
- o2(0xE1,0x54), o2(0xFA,0xA8), o2(0x93,0x63), o2(0x97,0x52),
- o2(0x8D,0x62), o2(0x90,0x5C), o2(0x92,0x6A), o2(0x99,0xB2),
- o2(0x92,0xAC), o2(0x89,0xE6), o2(0xE1,0x55), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_94 = {
- to_SHIFT_JIS_E7_94_offsets,
- to_SHIFT_JIS_E7_94_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_95_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_95 */
- /* used from to_EUC_JP_E7_95 */
- 33, 33, 33, 33, 0, 33, 1, 33, 33, 2, 3, 4, 5, 6, 33, 7,
- 33, 8, 33, 33, 9, 33, 33, 33, 33, 10, 11, 12, 13, 14, 33, 33,
- 15, 33, 16, 33, 17, 18, 19, 20, 33, 21, 22, 23, 33, 24, 33, 25,
- 26, 33, 33, 27, 28, 33, 29, 30, 31, 33, 33, 33, 33, 33, 33, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_95_infos[34] = {
- o2(0xE1,0x56), o2(0xE1,0x5B), o2(0xE1,0x59), o2(0xE1,0x58),
- o2(0x9D,0xC0), o2(0x8A,0x45), o2(0xE1,0x57), o2(0x88,0xD8),
- o2(0x94,0xA8), o2(0x94,0xC8), o2(0x97,0xAF), o2(0xE1,0x5C),
- o2(0xE1,0x5A), o2(0x92,0x7B), o2(0x90,0xA4), o2(0x94,0xA9),
- o2(0x95,0x4C), o2(0xE1,0x5E), o2(0x97,0xAA), o2(0x8C,0x6C),
- o2(0xE1,0x5F), o2(0xE1,0x5D), o2(0x94,0xD4), o2(0xE1,0x60),
- o2(0xE1,0x61), o2(0xFB,0x6F), o2(0x88,0xD9), o2(0x8F,0xF4),
- o2(0xE1,0x66), o2(0xE1,0x63), o2(0x93,0xEB), o2(0xE1,0x62),
- o2(0x8B,0x45), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_95 = {
- to_SHIFT_JIS_E7_95_offsets,
- to_SHIFT_JIS_E7_95_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_96_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_96 */
- /* used from to_EUC_JP_E7_96 */
- 24, 24, 0, 24, 24, 24, 1, 2, 24, 3, 4, 5, 24, 24, 6, 7,
- 24, 8, 24, 24, 9, 24, 24, 24, 24, 24, 10, 24, 24, 11, 24, 24,
- 24, 24, 24, 12, 24, 13, 24, 24, 24, 24, 24, 14, 24, 24, 24, 24,
- 24, 15, 16, 17, 24, 18, 24, 24, 19, 20, 24, 24, 21, 22, 23, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_96_infos[25] = {
- o2(0xE1,0x69), o2(0xE1,0x64), o2(0xE1,0x65), o2(0xE1,0x68),
- o2(0xE1,0x67), o2(0x95,0x44), o2(0x91,0x61), o2(0x91,0x60),
- o2(0x8B,0x5E), o2(0xE1,0x6A), o2(0xE1,0x6B), o2(0xE1,0x6C),
- o2(0xE1,0x6E), o2(0xE1,0x6D), o2(0x89,0x75), o2(0xE1,0x76),
- o2(0x94,0xE6), o2(0xE1,0x70), o2(0xE1,0x72), o2(0xE1,0x74),
- o2(0x90,0x5D), o2(0xE1,0x75), o2(0xE1,0x73), o2(0x8E,0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_96 = {
- to_SHIFT_JIS_E7_96_offsets,
- to_SHIFT_JIS_E7_96_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_97_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_97 */
- /* used from to_EUC_JP_E7_97 */
- 24, 24, 0, 1, 24, 2, 24, 3, 24, 24, 4, 24, 24, 5, 24, 24,
- 24, 24, 6, 24, 7, 8, 24, 24, 9, 10, 24, 11, 24, 24, 12, 24,
- 24, 24, 13, 14, 24, 24, 24, 24, 24, 15, 24, 24, 24, 24, 24, 24,
- 16, 24, 17, 18, 19, 24, 24, 24, 24, 24, 20, 24, 21, 24, 22, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_97_infos[25] = {
- o2(0xE1,0x6F), o2(0xE1,0x71), o2(0x95,0x61), o2(0x8F,0xC7),
- o2(0xE1,0x78), o2(0xE1,0x77), o2(0xE1,0x79), o2(0x8E,0xA4),
- o2(0x8D,0xAD), o2(0x93,0x97), o2(0xE1,0x7A), o2(0x92,0xC9),
- o2(0xE1,0x7C), o2(0x97,0x9F), o2(0xE1,0x7B), o2(0x91,0x89),
- o2(0xE1,0x82), o2(0xE1,0x84), o2(0xE1,0x85), o2(0x92,0x73),
- o2(0xE1,0x83), o2(0xE1,0x80), o2(0xE1,0x7D), o2(0xE1,0x7E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_97 = {
- to_SHIFT_JIS_E7_97_offsets,
- to_SHIFT_JIS_E7_97_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_98_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_98 */
- /* used from to_EUC_JP_E7_98 */
- 13, 0, 13, 13, 13, 13, 13, 13, 13, 1, 13, 2, 13, 3, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 4,
- 5, 6, 7, 13, 8, 13, 13, 9, 13, 13, 13, 13, 13, 13, 13, 13,
- 10, 13, 13, 13, 11, 13, 13, 13, 13, 13, 13, 12, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_98_infos[14] = {
- o2(0xE1,0x81), o2(0xE1,0x88), o2(0xE1,0x86), o2(0xE1,0x87),
- o2(0xE1,0x89), o2(0xE1,0x8B), o2(0xE1,0x8C), o2(0xE1,0x8D),
- o2(0xE1,0x8E), o2(0xE1,0x8A), o2(0xE1,0x90), o2(0xE1,0x8F),
- o2(0xE1,0x91), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_98 = {
- to_SHIFT_JIS_E7_98_offsets,
- to_SHIFT_JIS_E7_98_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_99_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_99 */
- /* used from to_EUC_JP_E7_99 */
- 25, 25, 0, 25, 25, 25, 1, 2, 3, 25, 25, 25, 4, 25, 25, 25,
- 25, 25, 5, 25, 25, 25, 6, 25, 7, 25, 25, 25, 8, 25, 25, 25,
- 25, 9, 10, 25, 25, 25, 25, 11, 12, 13, 14, 25, 15, 25, 25, 25,
- 16, 25, 17, 25, 25, 25, 18, 25, 19, 25, 20, 21, 22, 23, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_99_infos[26] = {
- o2(0x97,0xC3), o2(0xE1,0x94), o2(0xE1,0x92), o2(0xE1,0x93),
- o2(0x8A,0xE0), o2(0x96,0xFC), o2(0x95,0xC8), o2(0xE1,0x96),
- o2(0xE1,0x95), o2(0xE1,0x97), o2(0xE1,0x98), o2(0xE1,0x9C),
- o2(0xE1,0x99), o2(0xE1,0x9A), o2(0xE1,0x9B), o2(0xE1,0x9D),
- o2(0xE1,0x9E), o2(0xE1,0x9F), o2(0xE1,0xA0), o2(0xE1,0xA1),
- o2(0x94,0xAD), o2(0x93,0x6F), o2(0xE1,0xA2), o2(0x94,0x92),
- o2(0x95,0x53), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_99 = {
- to_SHIFT_JIS_E7_99_offsets,
- to_SHIFT_JIS_E7_99_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_9A_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_9A */
- /* used from to_EUC_JP_E7_9A */
- 0, 26, 1, 2, 3, 26, 4, 5, 6, 26, 26, 7, 26, 26, 8, 26,
- 9, 26, 26, 10, 26, 26, 11, 26, 26, 12, 13, 14, 15, 26, 16, 26,
- 26, 26, 26, 26, 26, 26, 17, 26, 26, 26, 26, 26, 26, 26, 18, 26,
- 19, 26, 26, 26, 20, 26, 26, 21, 22, 23, 24, 26, 26, 26, 26, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_9A_infos[27] = {
- o2(0xE1,0xA3), o2(0xFB,0x70), o2(0xE1,0xA4), o2(0x93,0x49),
- o2(0x8A,0x46), o2(0x8D,0x63), o2(0xE1,0xA5), o2(0xE1,0xA6),
- o2(0xE1,0xA7), o2(0x8E,0x48), o2(0xE1,0xA9), o2(0xE1,0xA8),
- o2(0xE1,0xAA), o2(0xE1,0xAB), o2(0xFB,0x73), o2(0xFB,0x71),
- o2(0xFB,0x72), o2(0xFB,0x74), o2(0x94,0xE7), o2(0xE1,0xAC),
- o2(0xE1,0xAD), o2(0xEA,0x89), o2(0xE1,0xAE), o2(0xE1,0xAF),
- o2(0xE1,0xB0), o2(0x8E,0x4D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_9A = {
- to_SHIFT_JIS_E7_9A_offsets,
- to_SHIFT_JIS_E7_9A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_9B_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_9B */
- /* used from to_EUC_JP_E7_9B */
- 25, 25, 0, 1, 25, 25, 2, 25, 3, 25, 4, 25, 25, 5, 25, 25,
- 25, 25, 6, 25, 25, 25, 7, 8, 25, 25, 25, 9, 10, 25, 11, 12,
- 25, 13, 25, 14, 15, 16, 25, 17, 25, 25, 18, 25, 25, 25, 19, 25,
- 25, 25, 20, 25, 21, 25, 25, 25, 22, 25, 25, 23, 25, 25, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_9B_infos[26] = {
- o2(0xE1,0xB1), o2(0x94,0x75), o2(0x96,0x7E), o2(0x89,0x6D),
- o2(0x89,0x76), o2(0xE1,0xB2), o2(0xE1,0xB4), o2(0xE1,0xB3),
- o2(0x93,0x90), o2(0x90,0xB7), o2(0x9F,0x58), o2(0xE1,0xB5),
- o2(0x96,0xBF), o2(0xE1,0xB6), o2(0x8A,0xC4), o2(0x94,0xD5),
- o2(0xE1,0xB7), o2(0xE1,0xB8), o2(0xE1,0xB9), o2(0x96,0xDA),
- o2(0x96,0xD3), o2(0x92,0xBC), o2(0x91,0x8A), o2(0xE1,0xBB),
- o2(0x8F,0x82), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_9B = {
- to_SHIFT_JIS_E7_9B_offsets,
- to_SHIFT_JIS_E7_9B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_9C_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_9C */
- /* used from to_EUC_JP_E7_9C */
- 19, 0, 19, 19, 1, 19, 19, 2, 3, 4, 19, 5, 6, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 7, 19, 19, 8, 9,
- 10, 19, 19, 19, 11, 12, 13, 19, 19, 14, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 15, 16, 19, 17, 19, 18, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_9C_infos[20] = {
- o2(0x8F,0xC8), o2(0xE1,0xBE), o2(0xE1,0xBD), o2(0xE1,0xBC),
- o2(0x94,0xFB), o2(0x8A,0xC5), o2(0x8C,0xA7), o2(0xE1,0xC4),
- o2(0xE1,0xC1), o2(0x90,0x5E), o2(0x96,0xB0), o2(0xE1,0xC0),
- o2(0xE1,0xC2), o2(0xE1,0xC3), o2(0xE1,0xBF), o2(0xE1,0xC5),
- o2(0xE1,0xC6), o2(0x92,0xAD), o2(0x8A,0xE1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_9C = {
- to_SHIFT_JIS_E7_9C_offsets,
- to_SHIFT_JIS_E7_9C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_9D_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_9D */
- /* used from to_EUC_JP_E7_9D */
- 0, 14, 14, 14, 14, 14, 1, 2, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 3, 4, 14, 14, 14, 14,
- 14, 5, 14, 6, 14, 7, 8, 14, 9, 14, 14, 10, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 11, 14, 14, 14, 14, 12, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_9D_infos[15] = {
- o2(0x92,0x85), o2(0xFB,0x76), o2(0xE1,0xC7), o2(0xE1,0xC8),
- o2(0xE1,0xCB), o2(0x90,0x87), o2(0x93,0xC2), o2(0xE1,0xCC),
- o2(0x96,0x72), o2(0xE1,0xC9), o2(0xE1,0xCA), o2(0xE1,0xCF),
- o2(0xE1,0xCE), o2(0xE1,0xCD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_9D = {
- to_SHIFT_JIS_E7_9D_offsets,
- to_SHIFT_JIS_E7_9D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_9E_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_9E */
- /* used from to_EUC_JP_E7_9E */
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 1, 16,
- 16, 2, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 16,
- 4, 16, 16, 16, 16, 5, 16, 16, 16, 16, 16, 16, 6, 7, 16, 16,
- 8, 16, 16, 9, 16, 16, 10, 16, 16, 11, 16, 12, 13, 14, 16, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_9E_infos[17] = {
- o2(0xE1,0xD1), o2(0xE1,0xD0), o2(0xE1,0xD2), o2(0xE1,0xD4),
- o2(0xE1,0xD3), o2(0x95,0xCB), o2(0x8F,0x75), o2(0x97,0xC4),
- o2(0xE1,0xD5), o2(0x93,0xB5), o2(0xE1,0xD6), o2(0xE1,0xD7),
- o2(0xE1,0xDB), o2(0xE1,0xD9), o2(0xE1,0xDA), o2(0xE1,0xD8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_9E = {
- to_SHIFT_JIS_E7_9E_offsets,
- to_SHIFT_JIS_E7_9E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_9F_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_9F */
- /* used from to_EUC_JP_E7_9F */
- 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 1, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 2, 16, 16, 3, 4, 5, 16, 16, 16,
- 16, 16, 6, 7, 16, 8, 16, 9, 16, 10, 16, 16, 16, 11, 12, 13,
- 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_9F_infos[17] = {
- o2(0xE1,0xDC), o2(0xE1,0xDD), o2(0xE1,0xDE), o2(0xE1,0xDF),
- o2(0x96,0xB5), o2(0xE1,0xE0), o2(0x96,0xEE), o2(0xE1,0xE1),
- o2(0x92,0x6D), o2(0x94,0x8A), o2(0x8B,0xE9), o2(0x92,0x5A),
- o2(0xE1,0xE2), o2(0x8B,0xB8), o2(0x90,0xCE), o2(0xE1,0xE3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_9F = {
- to_SHIFT_JIS_E7_9F_offsets,
- to_SHIFT_JIS_E7_9F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A0_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A0 */
- /* used from to_EUC_JP_E7_A0 */
- 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 1, 14, 14, 14,
- 14, 14, 2, 14, 3, 4, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 5, 6, 14, 14, 14, 7, 8, 9, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 10, 14, 11, 14, 14, 14, 14, 14, 12, 14, 14, 14, 14, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A0_infos[15] = {
- o2(0x8D,0xBB), o2(0xE1,0xE4), o2(0xE1,0xE5), o2(0x8C,0xA4),
- o2(0x8D,0xD3), o2(0xE1,0xE7), o2(0xFB,0x78), o2(0x93,0x75),
- o2(0x8D,0xD4), o2(0x8B,0x6D), o2(0x96,0x43), o2(0x94,0x6A),
- o2(0x93,0x76), o2(0x8D,0x7B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A0 = {
- to_SHIFT_JIS_E7_A0_offsets,
- to_SHIFT_JIS_E7_A0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A1_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A1 */
- /* used from to_EUC_JP_E7_A1 */
- 11, 11, 11, 11, 11, 0, 11, 11, 11, 11, 11, 11, 11, 11, 1, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, 11,
- 11, 11, 11, 11, 3, 11, 11, 11, 11, 11, 11, 4, 5, 11, 11, 6,
- 11, 11, 7, 11, 8, 11, 11, 11, 11, 11, 9, 11, 10, 11, 11, 11,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A1_infos[12] = {
- o2(0xE1,0xE9), o2(0xFB,0x79), o2(0x8F,0xC9), o2(0xFB,0x7A),
- o2(0x97,0xB0), o2(0x8D,0x64), o2(0x8C,0xA5), o2(0x94,0xA1),
- o2(0xE1,0xEB), o2(0xFB,0x7B), o2(0xE1,0xED), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A1 = {
- to_SHIFT_JIS_E7_A1_offsets,
- to_SHIFT_JIS_E7_A1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A2_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A2 */
- /* used from to_EUC_JP_E7_A2 */
- 20, 0, 20, 20, 20, 20, 1, 2, 20, 20, 20, 20, 3, 4, 5, 20,
- 20, 6, 20, 7, 20, 8, 20, 9, 20, 20, 10, 20, 20, 20, 20, 20,
- 20, 20, 20, 11, 20, 20, 20, 12, 20, 13, 14, 20, 20, 20, 20, 15,
- 20, 20, 20, 20, 20, 16, 20, 20, 20, 20, 17, 20, 18, 20, 19, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A2_infos[21] = {
- o2(0x8C,0xE9), o2(0xE1,0xEC), o2(0x92,0xF4), o2(0xE1,0xEF),
- o2(0x8A,0x56), o2(0xE1,0xEA), o2(0x94,0xE8), o2(0x89,0x4F),
- o2(0x8D,0xEA), o2(0x98,0x71), o2(0xE1,0xEE), o2(0xE1,0xF0),
- o2(0x95,0xC9), o2(0x90,0xD7), o2(0xE1,0xF2), o2(0xE1,0xF3),
- o2(0xE1,0xF1), o2(0x8A,0x6D), o2(0xE1,0xF9), o2(0xE1,0xF8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A2 = {
- to_SHIFT_JIS_E7_A2_offsets,
- to_SHIFT_JIS_E7_A2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A3_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A3 */
- /* used from to_EUC_JP_E7_A3 */
- 15, 0, 15, 15, 15, 1, 2, 15, 15, 15, 3, 4, 15, 15, 15, 15,
- 5, 6, 15, 15, 7, 15, 15, 15, 15, 15, 8, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 9, 10, 15, 15, 15, 11, 15, 15, 12,
- 15, 15, 15, 15, 13, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A3_infos[16] = {
- o2(0x8E,0xA5), o2(0xE1,0xFA), o2(0xE1,0xF5), o2(0xE1,0xFB),
- o2(0xE1,0xF6), o2(0x94,0xD6), o2(0xE1,0xF4), o2(0xE1,0xF7),
- o2(0xE2,0x41), o2(0xE2,0x40), o2(0x96,0x81), o2(0xE1,0xFC),
- o2(0x88,0xE9), o2(0xE2,0x43), o2(0xE2,0x42), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A3 = {
- to_SHIFT_JIS_E7_A3_offsets,
- to_SHIFT_JIS_E7_A3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A4_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A4 */
- /* used from to_EUC_JP_E7_A4 */
- 14, 0, 14, 14, 14, 14, 14, 1, 14, 14, 14, 14, 14, 14, 2, 14,
- 14, 3, 4, 14, 14, 14, 14, 14, 14, 5, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 6, 14, 14, 14, 7, 8, 9, 14, 14, 14,
- 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 11, 14, 12, 14, 13, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A4_infos[15] = {
- o2(0x8F,0xCA), o2(0xE2,0x44), o2(0x91,0x62), o2(0xE2,0x46),
- o2(0xE2,0x45), o2(0xE2,0x47), o2(0xE1,0xE6), o2(0xE1,0xE8),
- o2(0xE2,0x49), o2(0xE2,0x48), o2(0xFB,0x7C), o2(0x8E,0xA6),
- o2(0x97,0xE7), o2(0x8E,0xD0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A4 = {
- to_SHIFT_JIS_E7_A4_offsets,
- to_SHIFT_JIS_E7_A4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A5_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A5 */
- /* used from to_EUC_JP_E7_A5 */
- 0, 1, 22, 22, 22, 22, 22, 2, 3, 4, 22, 22, 22, 22, 22, 22,
- 5, 22, 22, 6, 22, 7, 8, 9, 22, 22, 10, 22, 22, 11, 12, 13,
- 14, 22, 15, 22, 22, 16, 22, 22, 17, 22, 22, 22, 22, 18, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 19, 22, 22, 20, 22, 22, 22, 22, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A5_infos[23] = {
- o2(0xE2,0x4A), o2(0x8C,0x56), o2(0x8B,0x5F), o2(0x8B,0x46),
- o2(0x8E,0x83), o2(0x97,0x53), o2(0xE2,0x50), o2(0xE2,0x4F),
- o2(0x91,0x63), o2(0xE2,0x4C), o2(0xE2,0x4E), o2(0x8F,0x6A),
- o2(0x90,0x5F), o2(0xE2,0x4D), o2(0xE2,0x4B), o2(0x94,0x49),
- o2(0x8F,0xCB), o2(0x95,0x5B), o2(0x8D,0xD5), o2(0x93,0x98),
- o2(0xE2,0x51), o2(0xE2,0x52), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A5 = {
- to_SHIFT_JIS_E7_A5_offsets,
- to_SHIFT_JIS_E7_A5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A6_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A6 */
- /* used from to_EUC_JP_E7_A6 */
- 0, 1, 22, 22, 2, 3, 22, 22, 22, 22, 4, 22, 22, 5, 6, 7,
- 22, 22, 22, 22, 8, 22, 22, 22, 22, 22, 22, 9, 22, 10, 22, 22,
- 22, 22, 22, 22, 22, 22, 11, 12, 22, 22, 13, 22, 22, 22, 14, 22,
- 15, 22, 22, 16, 22, 22, 22, 22, 22, 17, 18, 22, 22, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A6_infos[23] = {
- o2(0xE2,0x68), o2(0x8B,0xD6), o2(0x98,0x5C), o2(0x91,0x54),
- o2(0xE2,0x53), o2(0x89,0xD0), o2(0x92,0xF5), o2(0x95,0x9F),
- o2(0xFB,0x81), o2(0xFB,0x83), o2(0xE2,0x54), o2(0x8B,0x9A),
- o2(0xE2,0x55), o2(0xE2,0x57), o2(0xE2,0x58), o2(0x94,0x48),
- o2(0xE2,0x59), o2(0xE2,0x5A), o2(0xE2,0x5B), o2(0x8B,0xD7),
- o2(0x89,0xD1), o2(0x93,0xC3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A6 = {
- to_SHIFT_JIS_E7_A6_offsets,
- to_SHIFT_JIS_E7_A6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A7_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A7 */
- /* used from to_EUC_JP_E7_A7 */
- 0, 1, 18, 18, 18, 18, 18, 18, 18, 2, 18, 3, 18, 18, 18, 18,
- 18, 4, 5, 18, 18, 6, 18, 18, 7, 18, 18, 18, 18, 18, 18, 8,
- 18, 9, 18, 10, 11, 18, 12, 13, 18, 14, 18, 18, 15, 18, 18, 18,
- 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A7_infos[19] = {
- o2(0x8F,0x47), o2(0x8E,0x84), o2(0xE2,0x5C), o2(0x8F,0x48),
- o2(0x89,0xC8), o2(0x95,0x62), o2(0xE2,0x5D), o2(0x94,0xE9),
- o2(0x91,0x64), o2(0xE2,0x60), o2(0xE2,0x61), o2(0x94,0x89),
- o2(0x90,0x60), o2(0xE2,0x5E), o2(0x92,0x81), o2(0xE2,0x5F),
- o2(0x8F,0xCC), o2(0x88,0xDA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A7 = {
- to_SHIFT_JIS_E7_A7_offsets,
- to_SHIFT_JIS_E7_A7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A8_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A8 */
- /* used from to_EUC_JP_E7_A8 */
- 0, 22, 22, 22, 22, 22, 22, 22, 1, 22, 22, 2, 22, 3, 4, 22,
- 22, 22, 22, 22, 5, 22, 22, 6, 7, 8, 9, 22, 10, 22, 22, 11,
- 12, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 13, 22,
- 22, 14, 15, 22, 22, 22, 22, 16, 22, 22, 22, 17, 18, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A8_infos[23] = {
- o2(0x8B,0x48), o2(0xE2,0x62), o2(0x92,0xF6), o2(0xE2,0x63),
- o2(0x90,0xC5), o2(0x96,0xAB), o2(0x95,0x42), o2(0xE2,0x64),
- o2(0xE2,0x65), o2(0x92,0x74), o2(0x97,0xC5), o2(0xE2,0x67),
- o2(0xE2,0x66), o2(0x8E,0xED), o2(0xE2,0x69), o2(0x88,0xEE),
- o2(0xE2,0x6C), o2(0xE2,0x6A), o2(0x89,0xD2), o2(0x8C,0x6D),
- o2(0xE2,0x6B), o2(0x8D,0x65), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A8 = {
- to_SHIFT_JIS_E7_A8_offsets,
- to_SHIFT_JIS_E7_A8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_A9_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_A9 */
- /* used from to_EUC_JP_E7_A9 */
- 0, 22, 1, 2, 22, 22, 3, 22, 22, 4, 22, 22, 22, 5, 6, 7,
- 8, 22, 22, 22, 22, 22, 22, 9, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 10, 11, 12, 22, 22, 22, 22, 22, 13, 22, 14, 22, 22, 22, 22,
- 15, 22, 22, 22, 16, 22, 17, 22, 22, 18, 19, 22, 22, 20, 22, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_A9_infos[23] = {
- o2(0x8D,0x92), o2(0x95,0xE4), o2(0xE2,0x6D), o2(0x96,0x73),
- o2(0xE2,0x6F), o2(0x90,0xCF), o2(0x89,0x6E), o2(0x89,0xB8),
- o2(0x88,0xAA), o2(0xE2,0x6E), o2(0xE2,0x70), o2(0xE2,0x71),
- o2(0x8F,0xF5), o2(0xE2,0x72), o2(0x8A,0x6E), o2(0xE2,0x74),
- o2(0x8C,0x8A), o2(0x8B,0x86), o2(0xE2,0x75), o2(0x8B,0xF3),
- o2(0xE2,0x76), o2(0x90,0xFA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_A9 = {
- to_SHIFT_JIS_E7_A9_offsets,
- to_SHIFT_JIS_E7_A9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_AA_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_AA */
- /* used from to_EUC_JP_E7_AA */
- 19, 0, 19, 1, 2, 19, 19, 19, 3, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 4, 5, 19, 6, 7, 8, 9, 19, 19, 19, 19, 19, 19, 10,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 11, 12, 19, 19, 19, 13, 14,
- 15, 19, 19, 19, 19, 19, 16, 19, 19, 19, 17, 19, 19, 19, 19, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_AA_infos[20] = {
- o2(0x93,0xCB), o2(0x90,0xDE), o2(0x8D,0xF3), o2(0xE2,0x77),
- o2(0x92,0x82), o2(0x91,0x8B), o2(0xE2,0x79), o2(0xE2,0x7B),
- o2(0xE2,0x78), o2(0xE2,0x7A), o2(0x8C,0x41), o2(0xE2,0x7C),
- o2(0x8C,0x45), o2(0x8B,0x87), o2(0x97,0x71), o2(0xE2,0x7E),
- o2(0xE2,0x80), o2(0x89,0x4D), o2(0xE2,0x83), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_AA = {
- to_SHIFT_JIS_E7_AA_offsets,
- to_SHIFT_JIS_E7_AA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_AB_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_AB */
- /* used from to_EUC_JP_E7_AB */
- 35, 35, 35, 0, 1, 2, 35, 3, 4, 35, 5, 6, 35, 7, 35, 8,
- 35, 9, 10, 11, 35, 12, 35, 35, 35, 13, 14, 35, 15, 16, 35, 17,
- 18, 19, 20, 21, 35, 22, 23, 24, 35, 35, 25, 26, 35, 27, 35, 28,
- 29, 35, 35, 35, 35, 35, 30, 35, 31, 32, 33, 35, 35, 35, 35, 34,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_AB_infos[36] = {
- o2(0x8A,0x96), o2(0xE2,0x82), o2(0xE2,0x81), o2(0xE2,0x85),
- o2(0xE2,0x7D), o2(0xE2,0x86), o2(0x97,0xA7), o2(0xE2,0x87),
- o2(0xE2,0x88), o2(0xFB,0x84), o2(0x9A,0xF2), o2(0xE2,0x8A),
- o2(0xE2,0x89), o2(0xE2,0x8B), o2(0xE2,0x8C), o2(0x97,0xB3),
- o2(0xE2,0x8D), o2(0xE8,0xED), o2(0x8F,0xCD), o2(0xE2,0x8E),
- o2(0xE2,0x8F), o2(0x8F,0x76), o2(0x93,0xB6), o2(0xE2,0x90),
- o2(0xFB,0x85), o2(0x92,0x47), o2(0xFB,0x87), o2(0xE2,0x91),
- o2(0x92,0x5B), o2(0xE2,0x92), o2(0x8B,0xA3), o2(0x99,0x5E),
- o2(0x92,0x7C), o2(0x8E,0xB1), o2(0x8A,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_AB = {
- to_SHIFT_JIS_E7_AB_offsets,
- to_SHIFT_JIS_E7_AB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_AC_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_AC */
- /* used from to_EUC_JP_E7_AC */
- 21, 21, 0, 21, 1, 21, 2, 21, 3, 21, 4, 5, 21, 21, 21, 6,
- 21, 7, 21, 21, 21, 21, 21, 21, 8, 9, 21, 10, 21, 21, 11, 21,
- 12, 21, 21, 21, 21, 13, 14, 21, 15, 21, 21, 21, 16, 21, 21, 21,
- 21, 21, 21, 17, 21, 18, 19, 21, 21, 20, 21, 21, 21, 21, 21, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_AC_infos[22] = {
- o2(0xE2,0x93), o2(0xE2,0xA0), o2(0xE2,0x96), o2(0x8B,0x88),
- o2(0xE2,0x95), o2(0xE2,0xA2), o2(0xE2,0x94), o2(0x8F,0xCE),
- o2(0xE2,0x98), o2(0xE2,0x99), o2(0x93,0x4A), o2(0xE2,0x9A),
- o2(0x8A,0x7D), o2(0x90,0x79), o2(0x95,0x84), o2(0xE2,0x9C),
- o2(0x91,0xE6), o2(0xE2,0x97), o2(0xE2,0x9B), o2(0xE2,0x9D),
- o2(0x8D,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_AC = {
- to_SHIFT_JIS_E7_AC_offsets,
- to_SHIFT_JIS_E7_AC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_AD_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_AD */
- /* used from to_EUC_JP_E7_AD */
- 23, 23, 23, 23, 23, 0, 1, 23, 2, 3, 23, 4, 5, 6, 23, 7,
- 8, 9, 10, 23, 11, 23, 12, 23, 23, 23, 23, 23, 23, 13, 23, 23,
- 23, 23, 23, 23, 23, 14, 23, 15, 23, 23, 23, 23, 16, 23, 17, 23,
- 18, 19, 23, 23, 20, 21, 23, 23, 23, 23, 22, 23, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_AD_infos[24] = {
- o2(0xE2,0xA4), o2(0x95,0x4D), o2(0x94,0xA4), o2(0x93,0x99),
- o2(0x8B,0xD8), o2(0xE2,0xA3), o2(0xE2,0xA1), o2(0x94,0xB3),
- o2(0xE2,0x9E), o2(0x92,0x7D), o2(0x93,0x9B), o2(0x93,0x9A),
- o2(0x8D,0xF4), o2(0xE2,0xB6), o2(0xE2,0xA6), o2(0xE2,0xA8),
- o2(0xE2,0xAB), o2(0xE2,0xAC), o2(0xE2,0xA9), o2(0xE2,0xAA),
- o2(0xE2,0xA7), o2(0xE2,0xA5), o2(0xE2,0x9F), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_AD = {
- to_SHIFT_JIS_E7_AD_offsets,
- to_SHIFT_JIS_E7_AD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_AE_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_AE */
- /* used from to_EUC_JP_E7_AE */
- 22, 22, 22, 22, 22, 22, 0, 1, 22, 22, 22, 2, 22, 3, 22, 4,
- 22, 22, 5, 22, 6, 7, 22, 8, 9, 10, 11, 22, 12, 13, 14, 15,
- 22, 16, 22, 22, 22, 22, 22, 22, 22, 22, 17, 22, 22, 18, 22, 22,
- 22, 19, 22, 22, 20, 22, 22, 22, 21, 22, 22, 22, 22, 22, 22, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_AE_infos[23] = {
- o2(0x95,0xCD), o2(0x89,0xD3), o2(0xE2,0xB3), o2(0xE2,0xB0),
- o2(0xE2,0xB5), o2(0xE2,0xB4), o2(0x94,0x93), o2(0x96,0xA5),
- o2(0x8E,0x5A), o2(0xE2,0xAE), o2(0xE2,0xB7), o2(0xE2,0xB2),
- o2(0xE2,0xB1), o2(0xE2,0xAD), o2(0xFB,0x88), o2(0xE2,0xAF),
- o2(0x8A,0xC7), o2(0x92,0x5C), o2(0x90,0xFB), o2(0x94,0xA0),
- o2(0xE2,0xBC), o2(0x94,0xA2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_AE = {
- to_SHIFT_JIS_E7_AE_offsets,
- to_SHIFT_JIS_E7_AE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_AF_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_AF */
- /* used from to_EUC_JP_E7_AF */
- 0, 1, 19, 19, 2, 19, 3, 4, 19, 5, 19, 6, 7, 19, 19, 8,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 9, 19, 19,
- 10, 19, 19, 19, 11, 12, 13, 19, 19, 14, 19, 19, 19, 15, 19, 19,
- 19, 19, 19, 16, 19, 19, 17, 18, 19, 19, 19, 19, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_AF_infos[20] = {
- o2(0x90,0xDF), o2(0xE2,0xB9), o2(0x94,0xCD), o2(0xE2,0xBD),
- o2(0x95,0xD1), o2(0x92,0x7A), o2(0xE2,0xB8), o2(0xE2,0xBA),
- o2(0xE2,0xBB), o2(0xE2,0xBE), o2(0x8E,0xC2), o2(0x93,0xC4),
- o2(0xE2,0xC3), o2(0xE2,0xC2), o2(0xE2,0xBF), o2(0x98,0x55),
- o2(0xE2,0xC8), o2(0xE2,0xCC), o2(0xE2,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_AF = {
- to_SHIFT_JIS_E7_AF_offsets,
- to_SHIFT_JIS_E7_AF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B0_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B0 */
- /* used from to_EUC_JP_E7_B0 */
- 0, 19, 19, 19, 19, 19, 19, 1, 19, 19, 19, 19, 19, 2, 19, 19,
- 19, 3, 4, 5, 6, 19, 19, 7, 19, 19, 19, 19, 19, 19, 19, 8,
- 19, 9, 19, 10, 19, 19, 19, 11, 19, 19, 12, 13, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 14, 15, 19, 19, 19, 19, 16, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B0_infos[20] = {
- o2(0xE2,0xC5), o2(0xE2,0xC6), o2(0xE2,0xCB), o2(0xE2,0xC0),
- o2(0x99,0xD3), o2(0xE2,0xC7), o2(0xE2,0xC1), o2(0xE2,0xCA),
- o2(0xE2,0xD0), o2(0x8A,0xC8), o2(0xE2,0xCD), o2(0xE2,0xCE),
- o2(0xE2,0xCF), o2(0xE2,0xD2), o2(0xE2,0xD1), o2(0x94,0xF4),
- o2(0xE2,0xD3), o2(0x97,0xFA), o2(0x95,0xEB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B0 = {
- to_SHIFT_JIS_E7_B0_offsets,
- to_SHIFT_JIS_E7_B0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B1_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B1 */
- /* used from to_EUC_JP_E7_B1 */
- 0, 17, 17, 1, 17, 17, 17, 17, 17, 17, 17, 17, 2, 3, 17, 4,
- 5, 17, 17, 17, 6, 17, 7, 17, 8, 17, 17, 17, 17, 17, 17, 9,
- 10, 17, 17, 17, 11, 12, 17, 17, 17, 17, 17, 17, 13, 17, 17, 17,
- 17, 17, 17, 14, 17, 15, 17, 17, 17, 17, 17, 17, 17, 17, 16, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B1_infos[18] = {
- o2(0xE2,0xD8), o2(0xE2,0xD5), o2(0xE2,0xD4), o2(0x90,0xD0),
- o2(0xE2,0xD7), o2(0xE2,0xD9), o2(0xE2,0xD6), o2(0xE2,0xDD),
- o2(0xE2,0xDA), o2(0xE2,0xDB), o2(0xE2,0xC4), o2(0xE2,0xDC),
- o2(0xE2,0xDE), o2(0xE2,0xDF), o2(0x95,0xC4), o2(0xE2,0xE0),
- o2(0x96,0xE0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B1 = {
- to_SHIFT_JIS_E7_B1_offsets,
- to_SHIFT_JIS_E7_B1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B2_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B2 */
- /* used from to_EUC_JP_E7_B2 */
- 28, 0, 1, 2, 28, 28, 28, 28, 28, 3, 28, 4, 28, 5, 28, 28,
- 6, 28, 7, 28, 28, 8, 28, 9, 10, 28, 28, 11, 28, 28, 28, 12,
- 28, 13, 14, 28, 15, 16, 28, 17, 18, 28, 28, 19, 28, 20, 21, 28,
- 28, 22, 23, 24, 28, 28, 28, 28, 28, 25, 28, 28, 28, 26, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B2_infos[29] = {
- o2(0x8B,0xCC), o2(0x8C,0x48), o2(0xE2,0xE1), o2(0x95,0xB2),
- o2(0x90,0x88), o2(0x96,0xAE), o2(0xE2,0xE2), o2(0x97,0xB1),
- o2(0x94,0x94), o2(0x91,0x65), o2(0x94,0x53), o2(0x8F,0x6C),
- o2(0x88,0xBE), o2(0xE2,0xE7), o2(0xE2,0xE5), o2(0xE2,0xE3),
- o2(0x8A,0x9F), o2(0x8F,0xCF), o2(0xE2,0xE8), o2(0xE2,0xE6),
- o2(0xE2,0xE4), o2(0xE2,0xEC), o2(0xE2,0xEB), o2(0xE2,0xEA),
- o2(0xE2,0xE9), o2(0xE2,0xED), o2(0xE2,0xEE), o2(0x90,0xB8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B2 = {
- to_SHIFT_JIS_E7_B2_offsets,
- to_SHIFT_JIS_E7_B2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B3_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B3 */
- /* used from to_EUC_JP_E7_B3 */
- 0, 22, 1, 22, 22, 2, 22, 22, 22, 22, 3, 22, 22, 22, 4, 22,
- 22, 22, 5, 22, 22, 22, 6, 22, 7, 22, 22, 22, 8, 22, 9, 10,
- 11, 22, 12, 22, 22, 22, 22, 13, 22, 22, 22, 22, 22, 22, 22, 14,
- 22, 22, 15, 22, 16, 22, 17, 22, 18, 22, 19, 20, 22, 22, 21, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B3_infos[23] = {
- o2(0xE2,0xEF), o2(0xE2,0xF1), o2(0xE2,0xF0), o2(0x8C,0xD0),
- o2(0x91,0x57), o2(0xE2,0xF3), o2(0x93,0x9C), o2(0xE2,0xF2),
- o2(0xE2,0xF4), o2(0x95,0xB3), o2(0x91,0x8C), o2(0x8D,0x66),
- o2(0xE2,0xF5), o2(0x97,0xC6), o2(0xE2,0xF7), o2(0xE2,0xF8),
- o2(0xE2,0xF9), o2(0xE2,0xFA), o2(0x8E,0x85), o2(0xE2,0xFB),
- o2(0x8C,0x6E), o2(0x8B,0x8A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B3 = {
- to_SHIFT_JIS_E7_B3_offsets,
- to_SHIFT_JIS_E7_B3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B4_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B4 */
- /* used from to_EUC_JP_E7_B4 */
- 0, 31, 1, 31, 2, 3, 4, 31, 31, 31, 5, 6, 31, 7, 31, 31,
- 8, 31, 31, 31, 9, 10, 31, 11, 12, 13, 14, 15, 16, 31, 31, 31,
- 17, 18, 19, 31, 31, 31, 31, 31, 31, 31, 31, 20, 21, 31, 22, 23,
- 24, 31, 25, 26, 31, 27, 31, 31, 31, 28, 29, 31, 31, 31, 31, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B4_infos[32] = {
- o2(0x8B,0x49), o2(0xE3,0x40), o2(0x96,0xF1), o2(0x8D,0x67),
- o2(0xE2,0xFC), o2(0xE3,0x43), o2(0x96,0xE4), o2(0x94,0x5B),
- o2(0x95,0x52), o2(0x8F,0x83), o2(0xE3,0x42), o2(0x8E,0xD1),
- o2(0x8D,0x68), o2(0x8E,0x86), o2(0x8B,0x89), o2(0x95,0xB4),
- o2(0xE3,0x41), o2(0x91,0x66), o2(0x96,0x61), o2(0x8D,0xF5),
- o2(0x8E,0x87), o2(0x92,0xDB), o2(0xE3,0x46), o2(0x97,0xDD),
- o2(0x8D,0xD7), o2(0xE3,0x47), o2(0x90,0x61), o2(0xE3,0x49),
- o2(0x8F,0xD0), o2(0x8D,0xAE), o2(0xE3,0x48), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B4 = {
- to_SHIFT_JIS_E7_B4_offsets,
- to_SHIFT_JIS_E7_B4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B5_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B5 */
- /* used from to_EUC_JP_E7_B5 */
- 28, 28, 0, 1, 2, 3, 4, 28, 5, 28, 28, 6, 7, 28, 8, 9,
- 10, 28, 28, 28, 28, 28, 11, 28, 28, 28, 28, 12, 13, 28, 14, 28,
- 28, 15, 16, 17, 28, 28, 18, 28, 19, 28, 28, 28, 28, 28, 20, 28,
- 28, 21, 22, 23, 28, 24, 25, 28, 28, 26, 28, 28, 28, 27, 28, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B5_infos[29] = {
- o2(0x8F,0x49), o2(0x8C,0xBC), o2(0x91,0x67), o2(0xE3,0x44),
- o2(0xE3,0x4A), o2(0xFB,0x8A), o2(0xE3,0x45), o2(0x8C,0x6F),
- o2(0xE3,0x4D), o2(0xE3,0x51), o2(0x8C,0x8B), o2(0xE3,0x4C),
- o2(0xE3,0x55), o2(0xFB,0x8B), o2(0x8D,0x69), o2(0x97,0x8D),
- o2(0x88,0xBA), o2(0xE3,0x52), o2(0x8B,0x8B), o2(0xE3,0x4F),
- o2(0xE3,0x50), o2(0x93,0x9D), o2(0xE3,0x4E), o2(0xE3,0x4B),
- o2(0x8A,0x47), o2(0x90,0xE2), o2(0x8C,0xA6), o2(0xE3,0x57),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B5 = {
- to_SHIFT_JIS_E7_B5_offsets,
- to_SHIFT_JIS_E7_B5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B6_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B6 */
- /* used from to_EUC_JP_E7_B6 */
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 0, 28, 28, 28, 28, 28, 1,
- 28, 28, 28, 2, 28, 28, 28, 28, 28, 3, 4, 5, 6, 28, 28, 7,
- 8, 28, 9, 10, 28, 28, 28, 28, 28, 28, 28, 11, 12, 13, 14, 15,
- 16, 17, 18, 28, 19, 20, 28, 21, 22, 28, 23, 24, 28, 25, 26, 27,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B6_infos[29] = {
- o2(0xE3,0x54), o2(0xE3,0x56), o2(0xE3,0x53), o2(0x8C,0x70),
- o2(0x91,0xB1), o2(0xE3,0x58), o2(0x91,0x8E), o2(0xE3,0x65),
- o2(0xFB,0x8D), o2(0xE3,0x61), o2(0xE3,0x5B), o2(0xE3,0x5F),
- o2(0x8E,0xF8), o2(0x88,0xDB), o2(0xE3,0x5A), o2(0xE3,0x62),
- o2(0xE3,0x66), o2(0x8D,0x6A), o2(0x96,0xD4), o2(0x92,0xD4),
- o2(0xE3,0x5C), o2(0xFB,0x8C), o2(0xE3,0x64), o2(0xE3,0x59),
- o2(0x92,0x5D), o2(0xE3,0x5E), o2(0x88,0xBB), o2(0x96,0xC8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B6 = {
- to_SHIFT_JIS_E7_B6_offsets,
- to_SHIFT_JIS_E7_B6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B7_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B7 */
- /* used from to_EUC_JP_E7_B7 */
- 23, 23, 23, 23, 23, 23, 23, 0, 23, 23, 1, 2, 23, 23, 23, 3,
- 23, 4, 5, 23, 23, 6, 7, 23, 8, 23, 9, 23, 10, 11, 12, 23,
- 13, 14, 23, 23, 15, 23, 23, 23, 16, 17, 23, 23, 18, 23, 23, 19,
- 23, 23, 20, 23, 21, 23, 23, 23, 23, 23, 23, 22, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B7_infos[24] = {
- o2(0xE3,0x5D), o2(0x8B,0xD9), o2(0x94,0xEA), o2(0x91,0x8D),
- o2(0x97,0xCE), o2(0x8F,0x8F), o2(0xE3,0x8E), o2(0xFB,0x8E),
- o2(0xE3,0x67), o2(0x90,0xFC), o2(0xE3,0x63), o2(0xE3,0x68),
- o2(0xE3,0x6A), o2(0x92,0xF7), o2(0xE3,0x6D), o2(0xE3,0x69),
- o2(0x95,0xD2), o2(0x8A,0xC9), o2(0x96,0xC9), o2(0x88,0xDC),
- o2(0xE3,0x6C), o2(0x97,0xFB), o2(0xE3,0x6B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B7 = {
- to_SHIFT_JIS_E7_B7_offsets,
- to_SHIFT_JIS_E7_B7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B8_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B8 */
- /* used from to_EUC_JP_E7_B8 */
- 25, 0, 25, 25, 1, 2, 25, 25, 25, 3, 4, 5, 25, 25, 25, 25,
- 25, 25, 6, 25, 25, 25, 25, 25, 25, 25, 25, 7, 25, 25, 8, 9,
- 25, 10, 11, 12, 25, 25, 13, 25, 25, 25, 25, 14, 25, 25, 15, 25,
- 25, 16, 17, 25, 25, 18, 25, 19, 25, 20, 21, 22, 25, 23, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B8_infos[26] = {
- o2(0x89,0x8F), o2(0x93,0xEA), o2(0xE3,0x6E), o2(0xE3,0x75),
- o2(0xE3,0x6F), o2(0xE3,0x76), o2(0xE3,0x72), o2(0x94,0x9B),
- o2(0x8E,0xC8), o2(0xE3,0x74), o2(0xE3,0x71), o2(0xE3,0x77),
- o2(0xE3,0x70), o2(0x8F,0x63), o2(0x96,0x44), o2(0x8F,0x6B),
- o2(0xE3,0x73), o2(0xE3,0x80), o2(0xE3,0x7B), o2(0xE3,0x7E),
- o2(0xE3,0x7C), o2(0xE3,0x81), o2(0xE3,0x7A), o2(0xE3,0x60),
- o2(0x90,0xD1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B8 = {
- to_SHIFT_JIS_E7_B8_offsets,
- to_SHIFT_JIS_E7_B8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_B9_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_B9 */
- /* used from to_EUC_JP_E7_B9 */
- 25, 0, 25, 1, 25, 25, 2, 25, 25, 25, 3, 4, 25, 5, 25, 25,
- 25, 25, 6, 25, 7, 8, 9, 25, 25, 10, 11, 25, 25, 12, 13, 25,
- 25, 25, 25, 25, 25, 25, 14, 15, 25, 16, 17, 25, 25, 18, 25, 25,
- 19, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, 21, 22, 23, 25, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_B9_infos[26] = {
- o2(0x94,0xC9), o2(0xE3,0x7D), o2(0xE3,0x78), o2(0x91,0x40),
- o2(0x8C,0x71), o2(0x8F,0x4A), o2(0xFB,0x8F), o2(0x90,0x44),
- o2(0x91,0x55), o2(0xE3,0x84), o2(0xE3,0x86), o2(0xE3,0x87),
- o2(0xE3,0x83), o2(0xE3,0x85), o2(0xE3,0x79), o2(0xE3,0x82),
- o2(0xE3,0x8A), o2(0xE3,0x89), o2(0x96,0x9A), o2(0x8C,0x4A),
- o2(0xE3,0x88), o2(0xE3,0x8C), o2(0xE3,0x8B), o2(0xE3,0x8F),
- o2(0xE3,0x91), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_B9 = {
- to_SHIFT_JIS_E7_B9_offsets,
- to_SHIFT_JIS_E7_B9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_BA_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_BA */
- /* used from to_EUC_JP_E7_BA */
- 15, 15, 0, 1, 15, 15, 15, 15, 2, 3, 4, 15, 5, 15, 6, 7,
- 8, 15, 9, 10, 11, 15, 12, 15, 15, 15, 15, 13, 14, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_BA_infos[16] = {
- o2(0x8E,0x5B), o2(0xE3,0x8D), o2(0xE3,0x92), o2(0xE3,0x93),
- o2(0xFA,0x5C), o2(0xE3,0x94), o2(0xE3,0x9A), o2(0x93,0x5A),
- o2(0xE3,0x96), o2(0xE3,0x95), o2(0xE3,0x97), o2(0xE3,0x98),
- o2(0xE3,0x99), o2(0xE3,0x9B), o2(0xE3,0x9C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_BA = {
- to_SHIFT_JIS_E7_BA_offsets,
- to_SHIFT_JIS_E7_BA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_BC */
- /* used from to_EUC_JP_E7_BC */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 0, 3, 1, 3, 2, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_BC_infos[4] = {
- o2(0x8A,0xCA), o2(0xE3,0x9D), o2(0xE3,0x9E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_BC = {
- to_SHIFT_JIS_E7_BC_offsets,
- to_SHIFT_JIS_E7_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_BD */
- /* used from to_EUC_JP_E7_BD */
- 24, 24, 24, 24, 24, 0, 24, 1, 24, 24, 24, 24, 2, 3, 4, 24,
- 5, 6, 24, 24, 7, 8, 24, 24, 9, 24, 24, 24, 24, 24, 24, 10,
- 11, 24, 24, 24, 24, 24, 24, 12, 13, 14, 15, 16, 24, 24, 17, 24,
- 18, 24, 19, 24, 24, 20, 24, 21, 22, 23, 24, 24, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_BD_infos[25] = {
- o2(0xE3,0x9F), o2(0xFB,0x90), o2(0xE3,0xA0), o2(0xE3,0xA1),
- o2(0xE3,0xA2), o2(0xE3,0xA3), o2(0xE3,0xA4), o2(0xE3,0xA6),
- o2(0xE3,0xA5), o2(0xE3,0xA7), o2(0xE3,0xA8), o2(0xE3,0xA9),
- o2(0xE3,0xAC), o2(0xE3,0xAA), o2(0xE3,0xAB), o2(0x8D,0xDF),
- o2(0x8C,0x72), o2(0x92,0x75), o2(0x94,0xB1), o2(0x8F,0x90),
- o2(0x94,0x6C), o2(0x94,0xEB), o2(0xE3,0xAD), o2(0x9C,0xEB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_BD = {
- to_SHIFT_JIS_E7_BD_offsets,
- to_SHIFT_JIS_E7_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_BE */
- /* used from to_EUC_JP_E7_BE */
- 25, 25, 0, 1, 25, 2, 3, 4, 5, 25, 6, 25, 7, 25, 8, 25,
- 25, 25, 25, 25, 9, 25, 25, 25, 25, 25, 10, 25, 25, 11, 12, 25,
- 25, 13, 25, 14, 15, 25, 25, 25, 16, 17, 25, 25, 25, 25, 18, 19,
- 25, 25, 20, 25, 25, 25, 21, 25, 22, 23, 25, 25, 25, 24, 25, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_BE_infos[26] = {
- o2(0xE3,0xAE), o2(0xE3,0xB0), o2(0x97,0x85), o2(0xE3,0xAF),
- o2(0xE3,0xB2), o2(0xE3,0xB1), o2(0x97,0x72), o2(0xE3,0xB3),
- o2(0x94,0xFC), o2(0xE3,0xB4), o2(0xE3,0xB7), o2(0xE3,0xB6),
- o2(0xE3,0xB5), o2(0xFB,0x91), o2(0xE3,0xB8), o2(0x8C,0x51),
- o2(0x91,0x41), o2(0x8B,0x60), o2(0xE3,0xBC), o2(0xE3,0xB9),
- o2(0xE3,0xBA), o2(0xE3,0xBD), o2(0xE3,0xBE), o2(0xE3,0xBB),
- o2(0x89,0x48), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_BE = {
- to_SHIFT_JIS_E7_BE_offsets,
- to_SHIFT_JIS_E7_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_BF_offsets[64] = {
- /* used from to_SHIFT_JIS_E7_BF */
- /* used from to_EUC_JP_E7_BF */
- 18, 0, 18, 18, 18, 1, 2, 18, 18, 18, 3, 18, 4, 18, 18, 18,
- 18, 18, 5, 18, 6, 7, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 8, 9, 18, 18, 18, 18, 10, 18, 18, 11, 18, 12, 18, 18, 18, 18,
- 13, 18, 18, 14, 18, 18, 18, 18, 18, 15, 18, 16, 17, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_BF_infos[19] = {
- o2(0x89,0xA5), o2(0xE3,0xC0), o2(0xE3,0xC1), o2(0xE3,0xC2),
- o2(0x97,0x82), o2(0x8F,0x4B), o2(0xE3,0xC4), o2(0xE3,0xC3),
- o2(0x90,0x89), o2(0xE3,0xC5), o2(0xE3,0xC6), o2(0xE3,0xC7),
- o2(0x8A,0xE3), o2(0x8A,0xCB), o2(0xE3,0xC8), o2(0xE3,0xC9),
- o2(0x96,0x7C), o2(0x97,0x83), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7_BF = {
- to_SHIFT_JIS_E7_BF_offsets,
- to_SHIFT_JIS_E7_BF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E7_offsets[64] = {
- /* used from to_SHIFT_JIS_E7 */
- /* used from to_EUC_JP_E7 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 63, 59, 60, 61, 62,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E7_infos[64] = {
- &to_SHIFT_JIS_E7_80, &to_SHIFT_JIS_E7_81,
- &to_SHIFT_JIS_E7_82, &to_SHIFT_JIS_E7_83,
- &to_SHIFT_JIS_E7_84, &to_SHIFT_JIS_E7_85,
- &to_SHIFT_JIS_E7_86, &to_SHIFT_JIS_E7_87,
- &to_SHIFT_JIS_E7_88, &to_SHIFT_JIS_E7_89,
- &to_SHIFT_JIS_E7_8A, &to_SHIFT_JIS_E7_8B,
- &to_SHIFT_JIS_E7_8C, &to_SHIFT_JIS_E7_8D,
- &to_SHIFT_JIS_E7_8E, &to_SHIFT_JIS_E7_8F,
- &to_SHIFT_JIS_E7_90, &to_SHIFT_JIS_E7_91,
- &to_SHIFT_JIS_E7_92, &to_SHIFT_JIS_E7_93,
- &to_SHIFT_JIS_E7_94, &to_SHIFT_JIS_E7_95,
- &to_SHIFT_JIS_E7_96, &to_SHIFT_JIS_E7_97,
- &to_SHIFT_JIS_E7_98, &to_SHIFT_JIS_E7_99,
- &to_SHIFT_JIS_E7_9A, &to_SHIFT_JIS_E7_9B,
- &to_SHIFT_JIS_E7_9C, &to_SHIFT_JIS_E7_9D,
- &to_SHIFT_JIS_E7_9E, &to_SHIFT_JIS_E7_9F,
- &to_SHIFT_JIS_E7_A0, &to_SHIFT_JIS_E7_A1,
- &to_SHIFT_JIS_E7_A2, &to_SHIFT_JIS_E7_A3,
- &to_SHIFT_JIS_E7_A4, &to_SHIFT_JIS_E7_A5,
- &to_SHIFT_JIS_E7_A6, &to_SHIFT_JIS_E7_A7,
- &to_SHIFT_JIS_E7_A8, &to_SHIFT_JIS_E7_A9,
- &to_SHIFT_JIS_E7_AA, &to_SHIFT_JIS_E7_AB,
- &to_SHIFT_JIS_E7_AC, &to_SHIFT_JIS_E7_AD,
- &to_SHIFT_JIS_E7_AE, &to_SHIFT_JIS_E7_AF,
- &to_SHIFT_JIS_E7_B0, &to_SHIFT_JIS_E7_B1,
- &to_SHIFT_JIS_E7_B2, &to_SHIFT_JIS_E7_B3,
- &to_SHIFT_JIS_E7_B4, &to_SHIFT_JIS_E7_B5,
- &to_SHIFT_JIS_E7_B6, &to_SHIFT_JIS_E7_B7,
- &to_SHIFT_JIS_E7_B8, &to_SHIFT_JIS_E7_B9,
- &to_SHIFT_JIS_E7_BA, &to_SHIFT_JIS_E7_BC,
- &to_SHIFT_JIS_E7_BD, &to_SHIFT_JIS_E7_BE,
- &to_SHIFT_JIS_E7_BF, UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E7 = {
- to_SHIFT_JIS_E7_offsets,
- to_SHIFT_JIS_E7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_80 */
- /* used from to_EUC_JP_E8_80 */
- 0, 1, 22, 2, 3, 4, 5, 22, 22, 22, 22, 6, 7, 22, 22, 22,
- 8, 22, 9, 22, 22, 10, 22, 11, 12, 13, 22, 22, 14, 22, 22, 22,
- 22, 15, 22, 22, 22, 22, 22, 22, 16, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 17, 22, 22, 18, 22, 22, 22, 22, 19, 22, 20, 22, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_80_infos[23] = {
- o2(0x97,0x73), o2(0x98,0x56), o2(0x8D,0x6C), o2(0xE3,0xCC),
- o2(0x8E,0xD2), o2(0xE3,0xCB), o2(0xE3,0xCD), o2(0x8E,0xA7),
- o2(0x91,0xCF), o2(0xE3,0xCE), o2(0x8D,0x6B), o2(0x96,0xD5),
- o2(0xE3,0xCF), o2(0xE3,0xD0), o2(0xE3,0xD1), o2(0xE3,0xD2),
- o2(0xE3,0xD3), o2(0x8E,0xA8), o2(0x96,0xEB), o2(0xE3,0xD5),
- o2(0x92,0x5E), o2(0xE3,0xD4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_80 = {
- to_SHIFT_JIS_E8_80_offsets,
- to_SHIFT_JIS_E8_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_81_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_81 */
- /* used from to_EUC_JP_E8_81 */
- 22, 22, 22, 22, 22, 22, 0, 22, 22, 22, 1, 22, 22, 22, 22, 22,
- 22, 22, 2, 22, 22, 22, 3, 22, 4, 22, 5, 22, 22, 22, 6, 7,
- 22, 8, 9, 22, 22, 22, 22, 22, 10, 22, 22, 22, 22, 22, 22, 11,
- 12, 22, 13, 14, 15, 22, 16, 17, 22, 18, 22, 22, 22, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_81_infos[23] = {
- o2(0xE3,0xD7), o2(0xE3,0xD6), o2(0xE3,0xD8), o2(0x90,0xB9),
- o2(0xE3,0xD9), o2(0xE3,0xDA), o2(0x95,0xB7), o2(0xE3,0xDB),
- o2(0x91,0x8F), o2(0xE3,0xDC), o2(0xE3,0xDD), o2(0x97,0xFC),
- o2(0xE3,0xE0), o2(0xE3,0xDF), o2(0xE3,0xDE), o2(0x92,0xAE),
- o2(0xE3,0xE1), o2(0x90,0x45), o2(0xE3,0xE2), o2(0xE3,0xE3),
- o2(0x98,0x57), o2(0xE3,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_81 = {
- to_SHIFT_JIS_E8_81_offsets,
- to_SHIFT_JIS_E8_81_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_82_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_82 */
- /* used from to_EUC_JP_E8_82 */
- 25, 25, 25, 25, 0, 1, 2, 3, 25, 4, 25, 5, 6, 25, 25, 25,
- 25, 25, 25, 7, 25, 25, 8, 25, 9, 25, 10, 11, 25, 12, 25, 25,
- 25, 13, 14, 25, 25, 15, 25, 25, 25, 16, 17, 25, 18, 19, 25, 20,
- 25, 21, 22, 25, 23, 25, 25, 25, 25, 25, 24, 25, 25, 25, 25, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_82_infos[26] = {
- o2(0xE3,0xE5), o2(0xE3,0xE7), o2(0xE3,0xE6), o2(0x94,0xA3),
- o2(0x93,0xF7), o2(0x98,0x5D), o2(0x94,0xA7), o2(0xE3,0xE9),
- o2(0x8F,0xD1), o2(0x95,0x49), o2(0xE3,0xEA), o2(0xE3,0xE8),
- o2(0x8A,0xCC), o2(0x8C,0xD2), o2(0x8E,0x88), o2(0x94,0xEC),
- o2(0x8C,0xA8), o2(0x96,0x62), o2(0xE3,0xED), o2(0xE3,0xEB),
- o2(0x8D,0x6D), o2(0x8D,0x6E), o2(0x88,0xE7), o2(0x8D,0xE6),
- o2(0x94,0x78), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_82 = {
- to_SHIFT_JIS_E8_82_offsets,
- to_SHIFT_JIS_E8_82_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_83_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_83 */
- /* used from to_EUC_JP_E8_83 */
- 20, 20, 20, 0, 1, 20, 2, 20, 20, 20, 20, 20, 3, 20, 4, 20,
- 20, 20, 20, 20, 20, 20, 5, 20, 20, 6, 7, 8, 20, 9, 10, 20,
- 20, 11, 20, 20, 12, 13, 20, 20, 20, 20, 20, 20, 20, 20, 20, 14,
- 20, 15, 20, 20, 16, 20, 20, 20, 17, 20, 20, 20, 18, 19, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_83_infos[21] = {
- o2(0x88,0xDD), o2(0xE3,0xF2), o2(0x92,0x5F), o2(0x94,0x77),
- o2(0x91,0xD9), o2(0xE3,0xF4), o2(0xE3,0xF0), o2(0xE3,0xF3),
- o2(0xE3,0xEE), o2(0xE3,0xF1), o2(0x96,0x45), o2(0x8C,0xD3),
- o2(0x88,0xFB), o2(0xE3,0xEF), o2(0xE3,0xF6), o2(0xE3,0xF7),
- o2(0x93,0xB7), o2(0x8B,0xB9), o2(0xE4,0x45), o2(0x94,0x5C),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_83 = {
- to_SHIFT_JIS_E8_83_offsets,
- to_SHIFT_JIS_E8_83_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_84_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_84 */
- /* used from to_EUC_JP_E8_84 */
- 16, 16, 0, 16, 16, 1, 2, 3, 4, 5, 6, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 7, 8, 16, 16, 16, 16,
- 16, 16, 16, 9, 16, 16, 16, 16, 16, 10, 16, 16, 16, 16, 16, 11,
- 16, 12, 16, 13, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_84_infos[17] = {
- o2(0x8E,0x89), o2(0x8B,0xBA), o2(0x90,0xC6), o2(0x98,0x65),
- o2(0x96,0xAC), o2(0xE3,0xF5), o2(0x90,0xD2), o2(0x8B,0x72),
- o2(0xE3,0xF8), o2(0xE3,0xFA), o2(0xE3,0xF9), o2(0xE3,0xFB),
- o2(0x92,0x45), o2(0x94,0x5D), o2(0x92,0xAF), o2(0xE4,0x42),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_84 = {
- to_SHIFT_JIS_E8_84_offsets,
- to_SHIFT_JIS_E8_84_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_85_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_85 */
- /* used from to_EUC_JP_E8_85 */
- 20, 20, 20, 20, 20, 20, 0, 20, 20, 20, 20, 1, 20, 20, 2, 20,
- 3, 4, 20, 5, 6, 7, 20, 20, 20, 20, 20, 20, 20, 20, 20, 8,
- 20, 20, 20, 20, 20, 9, 10, 20, 20, 20, 20, 11, 20, 20, 12, 20,
- 13, 14, 20, 20, 15, 20, 20, 20, 16, 17, 18, 20, 20, 20, 20, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_85_infos[21] = {
- o2(0xE4,0x41), o2(0xE3,0xFC), o2(0x90,0x74), o2(0x95,0x85),
- o2(0xE4,0x44), o2(0xE4,0x43), o2(0x8D,0x6F), o2(0x98,0x72),
- o2(0xE4,0x54), o2(0xE4,0x48), o2(0xE4,0x49), o2(0x8E,0xEE),
- o2(0xE4,0x47), o2(0x8D,0x98), o2(0xE4,0x46), o2(0xE4,0x4A),
- o2(0x92,0xB0), o2(0x95,0xA0), o2(0x91,0x42), o2(0x91,0xDA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_85 = {
- to_SHIFT_JIS_E8_85_offsets,
- to_SHIFT_JIS_E8_85_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_86_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_86 */
- /* used from to_EUC_JP_E8_86 */
- 0, 24, 1, 2, 24, 24, 24, 24, 3, 24, 4, 24, 24, 24, 24, 5,
- 24, 24, 24, 6, 24, 7, 24, 24, 24, 24, 8, 24, 9, 10, 24, 24,
- 11, 24, 24, 12, 13, 24, 24, 24, 14, 15, 24, 24, 24, 24, 24, 24,
- 16, 24, 24, 17, 24, 18, 24, 24, 19, 24, 20, 24, 24, 21, 22, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_86_infos[25] = {
- o2(0xE4,0x4E), o2(0xE4,0x4F), o2(0xE4,0x4B), o2(0xE4,0x4C),
- o2(0xE4,0x4D), o2(0x8D,0x70), o2(0xE4,0x55), o2(0xE4,0x51),
- o2(0x95,0x86), o2(0x96,0x8C), o2(0x95,0x47), o2(0xE4,0x50),
- o2(0xE4,0x53), o2(0xE4,0x52), o2(0x96,0x63), o2(0xE4,0x56),
- o2(0xE4,0x57), o2(0x91,0x56), o2(0xE4,0x58), o2(0xE4,0x5A),
- o2(0xE4,0x5E), o2(0xE4,0x5B), o2(0xE4,0x59), o2(0x94,0x5E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_86 = {
- to_SHIFT_JIS_E8_86_offsets,
- to_SHIFT_JIS_E8_86_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_87_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_87 */
- /* used from to_EUC_JP_E8_87 */
- 0, 25, 1, 25, 25, 25, 2, 25, 3, 4, 25, 25, 25, 5, 25, 25,
- 25, 6, 25, 7, 25, 25, 25, 25, 8, 9, 10, 25, 25, 25, 25, 11,
- 12, 25, 25, 13, 25, 14, 25, 15, 16, 25, 17, 25, 25, 18, 25, 25,
- 25, 25, 25, 19, 20, 25, 25, 25, 25, 25, 21, 22, 23, 25, 24, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_87_infos[26] = {
- o2(0xE4,0x5C), o2(0xE4,0x5D), o2(0x89,0xB0), o2(0xE4,0x64),
- o2(0xE4,0x5F), o2(0xE4,0x60), o2(0xE4,0x61), o2(0x91,0x9F),
- o2(0xE4,0x63), o2(0xE4,0x62), o2(0xE4,0x65), o2(0xE4,0x66),
- o2(0xE4,0x67), o2(0x90,0x62), o2(0x89,0xE7), o2(0xE4,0x68),
- o2(0x97,0xD5), o2(0x8E,0xA9), o2(0x8F,0x4C), o2(0x8E,0x8A),
- o2(0x92,0x76), o2(0xE4,0x69), o2(0xE4,0x6A), o2(0x89,0x50),
- o2(0xE4,0x6B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_87 = {
- to_SHIFT_JIS_E8_87_offsets,
- to_SHIFT_JIS_E8_87_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_88 */
- /* used from to_EUC_JP_E8_88 */
- 30, 0, 1, 30, 30, 2, 30, 3, 4, 5, 6, 30, 7, 8, 9, 30,
- 10, 30, 11, 30, 30, 30, 12, 13, 14, 30, 30, 15, 16, 30, 17, 18,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 19, 20, 21, 22, 30, 23, 30,
- 30, 30, 30, 24, 30, 25, 26, 27, 28, 29, 30, 30, 30, 30, 30, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_88_infos[31] = {
- o2(0xE4,0x6C), o2(0xE4,0x6D), o2(0xE4,0x6E), o2(0xE4,0x6F),
- o2(0x8B,0xBB), o2(0x9D,0xA8), o2(0xE4,0x70), o2(0x90,0xE3),
- o2(0xE4,0x71), o2(0x8E,0xC9), o2(0xE4,0x72), o2(0x98,0xAE),
- o2(0xE4,0x73), o2(0x95,0xDC), o2(0x8A,0xDA), o2(0x91,0x43),
- o2(0x8F,0x77), o2(0x95,0x91), o2(0x8F,0x4D), o2(0xE4,0x74),
- o2(0x8D,0x71), o2(0xE4,0x75), o2(0x94,0xCA), o2(0xE4,0x84),
- o2(0xE4,0x77), o2(0x91,0xC7), o2(0x94,0x95), o2(0x8C,0xBD),
- o2(0xE4,0x76), o2(0x91,0x44), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_88 = {
- to_SHIFT_JIS_E8_88_offsets,
- to_SHIFT_JIS_E8_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_89_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_89 */
- /* used from to_EUC_JP_E8_89 */
- 0, 21, 21, 21, 21, 21, 21, 1, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 2, 3, 4, 21, 21, 5, 21, 6,
- 21, 21, 7, 21, 8, 21, 9, 21, 10, 21, 11, 12, 21, 21, 13, 14,
- 21, 15, 16, 21, 21, 21, 17, 18, 19, 21, 21, 21, 21, 21, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_89_infos[22] = {
- o2(0xE4,0x78), o2(0x92,0xF8), o2(0xE4,0x7A), o2(0xE4,0x79),
- o2(0xE4,0x7C), o2(0xE4,0x7B), o2(0xE4,0x7D), o2(0xE4,0x80),
- o2(0xE4,0x7E), o2(0x8A,0xCD), o2(0xE4,0x81), o2(0xE4,0x82),
- o2(0xE4,0x83), o2(0x8D,0xAF), o2(0x97,0xC7), o2(0xE4,0x85),
- o2(0x90,0x46), o2(0x89,0x90), o2(0xE4,0x86), o2(0xE4,0x87),
- o2(0xE4,0x88), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_89 = {
- to_SHIFT_JIS_E8_89_offsets,
- to_SHIFT_JIS_E8_89_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_8A */
- /* used from to_EUC_JP_E8_8A */
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 18, 1, 18, 18,
- 18, 18, 2, 18, 18, 18, 18, 18, 18, 3, 18, 18, 18, 4, 18, 5,
- 18, 18, 18, 18, 18, 6, 7, 18, 18, 18, 18, 8, 9, 10, 18, 11,
- 18, 12, 18, 13, 18, 18, 18, 18, 14, 15, 18, 16, 18, 17, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_8A_infos[19] = {
- o2(0x88,0xF0), o2(0xE4,0x89), o2(0xE4,0x8A), o2(0x95,0x87),
- o2(0x8E,0xC5), o2(0xE4,0x8C), o2(0x8A,0x48), o2(0x88,0xB0),
- o2(0xE4,0x8B), o2(0xE4,0x8E), o2(0x94,0x6D), o2(0x90,0x63),
- o2(0x89,0xD4), o2(0x96,0x46), o2(0x8C,0x7C), o2(0x8B,0xDA),
- o2(0xE4,0x8D), o2(0x89,0xE8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_8A = {
- to_SHIFT_JIS_E8_8A_offsets,
- to_SHIFT_JIS_E8_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_8B_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_8B */
- /* used from to_EUC_JP_E8_8B */
- 23, 23, 23, 23, 23, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 1, 2, 3, 4, 23, 23, 5, 23, 6, 23, 7, 8, 23, 9, 10,
- 23, 11, 23, 12, 23, 13, 14, 15, 23, 23, 23, 16, 23, 23, 23, 23,
- 23, 17, 23, 18, 19, 23, 23, 23, 23, 20, 21, 22, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_8B_infos[24] = {
- o2(0x8A,0xA1), o2(0x89,0x91), o2(0xE4,0x92), o2(0x97,0xE8),
- o2(0x91,0xDB), o2(0x95,0x63), o2(0xE4,0x9E), o2(0x89,0xD5),
- o2(0xE4,0x9C), o2(0xE4,0x9A), o2(0xE4,0x91), o2(0xE4,0x8F),
- o2(0xE4,0x90), o2(0x8E,0xE1), o2(0x8B,0xEA), o2(0x92,0x97),
- o2(0x93,0xCF), o2(0x89,0x70), o2(0xE4,0x94), o2(0xE4,0x93),
- o2(0xE4,0x99), o2(0xE4,0x95), o2(0xE4,0x98), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_8B = {
- to_SHIFT_JIS_E8_8B_offsets,
- to_SHIFT_JIS_E8_8B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_8C */
- /* used from to_EUC_JP_E8_8C */
- 23, 0, 1, 2, 3, 4, 5, 23, 23, 6, 23, 23, 23, 23, 7, 23,
- 23, 23, 23, 23, 23, 23, 8, 9, 10, 23, 23, 23, 11, 23, 23, 23,
- 23, 23, 23, 12, 23, 23, 23, 23, 13, 23, 23, 14, 23, 23, 23, 15,
- 23, 16, 17, 23, 18, 19, 20, 23, 21, 22, 23, 23, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_8C_infos[24] = {
- o2(0xFB,0x93), o2(0x96,0xCE), o2(0xE4,0x97), o2(0x89,0xD6),
- o2(0x8A,0x9D), o2(0xE4,0x9B), o2(0xE4,0x9D), o2(0x8C,0x73),
- o2(0xE4,0xA1), o2(0xE4,0xAA), o2(0xE4,0xAB), o2(0x88,0xA9),
- o2(0xE4,0xB2), o2(0x88,0xEF), o2(0xE4,0xA9), o2(0xE4,0xA8),
- o2(0xE4,0xA3), o2(0xE4,0xA2), o2(0xE4,0xA0), o2(0xE4,0x9F),
- o2(0x92,0x83), o2(0x91,0xF9), o2(0xE4,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_8C = {
- to_SHIFT_JIS_E8_8C_offsets,
- to_SHIFT_JIS_E8_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_8D_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_8D */
- /* used from to_EUC_JP_E8_8D */
- 0, 15, 15, 15, 15, 1, 15, 15, 15, 2, 3, 15, 15, 15, 15, 4,
- 5, 15, 6, 15, 15, 15, 15, 15, 7, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 8, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 9, 15, 10, 15, 11, 15, 15, 15, 12, 13, 15, 15, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_8D_infos[16] = {
- o2(0xE4,0xA4), o2(0xE4,0xA7), o2(0x91,0x90), o2(0x8C,0x74),
- o2(0x89,0x60), o2(0xE4,0xA6), o2(0x8D,0x72), o2(0x91,0x91),
- o2(0xFB,0x94), o2(0xE4,0xB8), o2(0xE4,0xB9), o2(0x89,0xD7),
- o2(0x89,0xAC), o2(0xE4,0xB6), o2(0xFB,0x95), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_8D = {
- to_SHIFT_JIS_E8_8D_offsets,
- to_SHIFT_JIS_E8_8D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_8E_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_8E */
- /* used from to_EUC_JP_E8_8E */
- 18, 18, 18, 18, 18, 0, 18, 1, 18, 2, 3, 18, 18, 18, 4, 18,
- 18, 18, 18, 5, 18, 18, 6, 18, 18, 18, 7, 18, 18, 18, 8, 9,
- 10, 18, 11, 18, 18, 18, 18, 18, 12, 18, 13, 14, 18, 18, 18, 18,
- 18, 15, 18, 18, 18, 16, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_8E_infos[19] = {
- o2(0xE4,0xAC), o2(0xE4,0xB4), o2(0xE4,0xBB), o2(0xE4,0xB5),
- o2(0xE4,0xB3), o2(0xE4,0x96), o2(0xE4,0xB1), o2(0xE4,0xAD),
- o2(0x8A,0xCE), o2(0xE4,0xAF), o2(0xE4,0xBA), o2(0xE4,0xB0),
- o2(0xE4,0xBC), o2(0xE4,0xAE), o2(0x94,0x9C), o2(0x97,0x89),
- o2(0xE4,0xB7), o2(0xE4,0xCD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_8E = {
- to_SHIFT_JIS_E8_8E_offsets,
- to_SHIFT_JIS_E8_8E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_8F_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_8F */
- /* used from to_EUC_JP_E8_8F */
- 23, 0, 23, 23, 23, 1, 23, 2, 23, 23, 3, 23, 4, 23, 5, 23,
- 23, 23, 23, 6, 23, 23, 7, 23, 8, 23, 23, 23, 9, 23, 23, 10,
- 11, 23, 23, 23, 23, 23, 23, 23, 23, 12, 23, 13, 23, 23, 23, 14,
- 15, 16, 17, 23, 18, 23, 19, 20, 23, 23, 23, 21, 23, 22, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_8F_infos[24] = {
- o2(0xE4,0xC5), o2(0x90,0x9B), o2(0xFB,0x96), o2(0x8B,0x65),
- o2(0x8B,0xDB), o2(0xE4,0xC0), o2(0x89,0xD9), o2(0x8F,0xD2),
- o2(0xE4,0xC3), o2(0x8D,0xD8), o2(0x93,0x70), o2(0xE4,0xC8),
- o2(0x95,0xEC), o2(0xE4,0xBF), o2(0x89,0xD8), o2(0x8C,0xD4),
- o2(0x95,0x48), o2(0xE4,0xC9), o2(0xE4,0xBD), o2(0xFB,0x97),
- o2(0xE4,0xC6), o2(0xE4,0xD0), o2(0xE4,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_8F = {
- to_SHIFT_JIS_E8_8F_offsets,
- to_SHIFT_JIS_E8_8F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_90_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_90 */
- /* used from to_EUC_JP_E8_90 */
- 18, 18, 18, 0, 1, 18, 18, 2, 18, 18, 18, 3, 4, 5, 6, 18,
- 18, 18, 18, 7, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 8, 18, 9, 18, 18, 18, 18, 18, 18, 10, 11, 18, 12, 18, 18, 18,
- 18, 13, 18, 18, 18, 14, 18, 18, 15, 18, 18, 18, 16, 17, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_90_infos[19] = {
- o2(0xE4,0xC2), o2(0x93,0xB8), o2(0xE4,0xC7), o2(0xE4,0xC4),
- o2(0x96,0x47), o2(0xE4,0xCA), o2(0x88,0xDE), o2(0xE4,0xBE),
- o2(0xE4,0xCC), o2(0xE4,0xCB), o2(0x94,0x8B), o2(0xE4,0xD2),
- o2(0xE4,0xDD), o2(0x8A,0x9E), o2(0xE4,0xE0), o2(0xE4,0xCE),
- o2(0xE4,0xD3), o2(0x97,0x8E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_90 = {
- to_SHIFT_JIS_E8_90_offsets,
- to_SHIFT_JIS_E8_90_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_91_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_91 */
- /* used from to_EUC_JP_E8_91 */
- 21, 21, 21, 21, 21, 21, 0, 21, 1, 2, 21, 21, 21, 21, 3, 21,
- 21, 21, 21, 21, 21, 21, 21, 4, 21, 21, 21, 5, 21, 21, 21, 21,
- 21, 6, 7, 8, 21, 21, 9, 21, 21, 10, 21, 11, 12, 13, 14, 15,
- 21, 16, 21, 21, 21, 17, 21, 18, 21, 19, 20, 21, 21, 21, 21, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_91_infos[22] = {
- o2(0xE4,0xDC), o2(0xFB,0x98), o2(0x97,0x74), o2(0x97,0xA8),
- o2(0x92,0x98), o2(0x8A,0x8B), o2(0x95,0x92), o2(0xE4,0xE2),
- o2(0x93,0x9F), o2(0x88,0xAF), o2(0xE4,0xDB), o2(0xE4,0xD7),
- o2(0x91,0x92), o2(0xE4,0xD1), o2(0xE4,0xD9), o2(0xE4,0xDE),
- o2(0x94,0x4B), o2(0x88,0xA8), o2(0xE4,0xD6), o2(0xE4,0xDF),
- o2(0x95,0x98), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_91 = {
- to_SHIFT_JIS_E8_91_offsets,
- to_SHIFT_JIS_E8_91_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_92_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_92 */
- /* used from to_EUC_JP_E8_92 */
- 17, 17, 0, 17, 1, 17, 17, 17, 17, 17, 17, 2, 17, 17, 17, 17,
- 3, 17, 17, 17, 4, 17, 17, 17, 17, 5, 17, 17, 6, 17, 17, 7,
- 17, 8, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 9, 17, 17,
- 17, 17, 10, 17, 11, 17, 17, 17, 12, 13, 17, 14, 15, 17, 17, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_92_infos[18] = {
- o2(0xE4,0xDA), o2(0xE4,0xD5), o2(0x8F,0xD3), o2(0x8F,0x4E),
- o2(0x8E,0xAA), o2(0x96,0xD6), o2(0x95,0x66), o2(0xE4,0xE5),
- o2(0xE4,0xEE), o2(0xE4,0xD8), o2(0x8A,0x97), o2(0xFB,0x99),
- o2(0x8F,0xF6), o2(0xE4,0xE3), o2(0xE4,0xE8), o2(0x91,0x93),
- o2(0xE4,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_92 = {
- to_SHIFT_JIS_E8_92_offsets,
- to_SHIFT_JIS_E8_92_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_93_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_93 */
- /* used from to_EUC_JP_E8_93 */
- 18, 0, 18, 18, 1, 18, 2, 18, 18, 3, 4, 5, 18, 6, 18, 18,
- 7, 8, 18, 18, 18, 18, 9, 18, 18, 10, 11, 18, 12, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 13, 18, 14, 18,
- 18, 18, 18, 18, 15, 18, 18, 18, 18, 18, 18, 18, 16, 18, 18, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_93_infos[19] = {
- o2(0xE4,0xEB), o2(0x92,0x7E), o2(0xE4,0xEC), o2(0x97,0x75),
- o2(0xE4,0xE1), o2(0x8A,0x57), o2(0xE4,0xE7), o2(0xE4,0xEA),
- o2(0x96,0xAA), o2(0xE4,0xED), o2(0xE4,0xE6), o2(0xE4,0xE9),
- o2(0xFA,0x60), o2(0x96,0x48), o2(0x98,0x40), o2(0xE4,0xF1),
- o2(0xE4,0xF8), o2(0xE4,0xF0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_93 = {
- to_SHIFT_JIS_E8_93_offsets,
- to_SHIFT_JIS_E8_93_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_94_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_94 */
- /* used from to_EUC_JP_E8_94 */
- 0, 16, 16, 16, 16, 16, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 2, 16, 3, 4, 5, 16, 6, 7, 16, 8, 16, 16, 16, 16, 9,
- 16, 10, 16, 16, 16, 16, 11, 16, 16, 16, 16, 16, 12, 13, 16, 16,
- 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_94_infos[17] = {
- o2(0x8E,0xC1), o2(0xE4,0xCF), o2(0x95,0xCC), o2(0x96,0xA0),
- o2(0xE4,0xF7), o2(0xE4,0xF6), o2(0xE4,0xF2), o2(0xE4,0xF3),
- o2(0x89,0x55), o2(0xE4,0xF5), o2(0xE4,0xEF), o2(0x92,0xD3),
- o2(0xE4,0xF4), o2(0x88,0xFC), o2(0x91,0xA0), o2(0x95,0xC1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_94 = {
- to_SHIFT_JIS_E8_94_offsets,
- to_SHIFT_JIS_E8_94_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_95_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_95 */
- /* used from to_EUC_JP_E8_95 */
- 0, 1, 22, 2, 22, 22, 22, 22, 3, 4, 5, 6, 22, 22, 7, 22,
- 22, 22, 22, 8, 22, 9, 22, 10, 11, 12, 13, 22, 22, 22, 22, 22,
- 22, 22, 22, 14, 22, 22, 22, 22, 15, 16, 17, 18, 22, 19, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 20, 22, 22, 22, 22, 22, 22, 21, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_95_infos[23] = {
- o2(0xE4,0xF9), o2(0xE5,0x40), o2(0x94,0xD7), o2(0xE4,0xFC),
- o2(0x8F,0xD4), o2(0x8E,0xC7), o2(0xE5,0x42), o2(0x8B,0xBC),
- o2(0xFB,0x9A), o2(0xE5,0x43), o2(0x95,0x99), o2(0xE4,0xFB),
- o2(0xFB,0x9B), o2(0xE4,0xD4), o2(0xE4,0xFA), o2(0x98,0x6E),
- o2(0x93,0xA0), o2(0x95,0x93), o2(0xFB,0x9C), o2(0xE5,0x4A),
- o2(0xE5,0x50), o2(0xE5,0x51), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_95 = {
- to_SHIFT_JIS_E8_95_offsets,
- to_SHIFT_JIS_E8_95_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_96_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_96 */
- /* used from to_EUC_JP_E8_96 */
- 0, 24, 24, 24, 1, 24, 24, 2, 3, 24, 4, 24, 24, 24, 24, 24,
- 5, 6, 24, 24, 7, 24, 24, 8, 24, 9, 24, 10, 11, 24, 24, 24,
- 24, 24, 24, 24, 12, 24, 13, 24, 14, 15, 16, 17, 18, 24, 19, 20,
- 21, 24, 24, 24, 24, 24, 24, 24, 24, 22, 23, 24, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_96_infos[25] = {
- o2(0xE5,0x44), o2(0x94,0x96), o2(0xE5,0x4E), o2(0xE5,0x46),
- o2(0xE5,0x48), o2(0xE5,0x52), o2(0xE5,0x47), o2(0xE5,0x4B),
- o2(0x89,0x92), o2(0x93,0xE3), o2(0xE5,0x4C), o2(0xE5,0x4F),
- o2(0xE5,0x45), o2(0x91,0x45), o2(0xE5,0x49), o2(0x8E,0x46),
- o2(0x90,0x64), o2(0x8C,0x4F), o2(0x96,0xF2), o2(0x96,0xF7),
- o2(0x8F,0x92), o2(0xFB,0x9E), o2(0xE5,0x56), o2(0xE5,0x54),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_96 = {
- to_SHIFT_JIS_E8_96_offsets,
- to_SHIFT_JIS_E8_96_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_97_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_97 */
- /* used from to_EUC_JP_E8_97 */
- 17, 0, 17, 17, 17, 17, 17, 17, 17, 1, 17, 17, 17, 2, 17, 3,
- 4, 17, 17, 17, 17, 5, 17, 17, 17, 17, 17, 17, 6, 7, 17, 17,
- 17, 17, 17, 17, 8, 9, 17, 17, 17, 10, 11, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 12, 17, 13, 14, 15, 17, 17, 16, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_97_infos[18] = {
- o2(0x98,0x6D), o2(0xE5,0x53), o2(0x97,0x95), o2(0xE5,0x55),
- o2(0xE5,0x57), o2(0xE5,0x58), o2(0xE5,0x5B), o2(0xE5,0x59),
- o2(0x93,0xA1), o2(0xE5,0x5A), o2(0x94,0xCB), o2(0xE5,0x4D),
- o2(0x8F,0x93), o2(0xE5,0x5C), o2(0xE5,0x61), o2(0x91,0x94),
- o2(0xE5,0x60), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_97 = {
- to_SHIFT_JIS_E8_97_offsets,
- to_SHIFT_JIS_E8_97_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_98_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_98 */
- /* used from to_EUC_JP_E8_98 */
- 14, 14, 0, 14, 14, 14, 1, 2, 14, 14, 3, 4, 14, 14, 14, 14,
- 14, 14, 14, 5, 14, 14, 6, 7, 14, 14, 8, 14, 14, 14, 14, 14,
- 14, 14, 9, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 10, 14, 11,
- 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_98_infos[15] = {
- o2(0xE5,0x41), o2(0xE5,0x62), o2(0x91,0x68), o2(0xE5,0x5D),
- o2(0xE5,0x5F), o2(0xE5,0x5E), o2(0x9F,0x50), o2(0x9F,0x41),
- o2(0xE5,0x64), o2(0xE5,0x63), o2(0x97,0x96), o2(0xE1,0xBA),
- o2(0xE5,0x65), o2(0xE5,0x66), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_98 = {
- to_SHIFT_JIS_E8_98_offsets,
- to_SHIFT_JIS_E8_98_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_99_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_99 */
- /* used from to_EUC_JP_E8_99 */
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 1, 14,
- 2, 14, 14, 14, 3, 4, 14, 14, 14, 14, 5, 14, 6, 14, 7, 8,
- 14, 14, 14, 14, 14, 14, 14, 9, 14, 14, 14, 10, 14, 14, 14, 14,
- 14, 11, 14, 14, 14, 14, 14, 14, 14, 12, 14, 13, 14, 14, 14, 14,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_99_infos[15] = {
- o2(0xE5,0x67), o2(0x8C,0xD5), o2(0x8B,0x73), o2(0xE5,0x69),
- o2(0x99,0x7C), o2(0x8B,0x95), o2(0x97,0xB8), o2(0x8B,0xF1),
- o2(0xE5,0x6A), o2(0xE5,0x6B), o2(0x92,0x8E), o2(0xE5,0x6C),
- o2(0x93,0xF8), o2(0x88,0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_99 = {
- to_SHIFT_JIS_E8_99_offsets,
- to_SHIFT_JIS_E8_99_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_9A_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_9A */
- /* used from to_EUC_JP_E8_9A */
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 1, 2, 13, 13, 13,
- 13, 13, 13, 3, 13, 4, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 5, 6, 13, 13, 13, 13, 7, 8, 9, 13, 13, 13, 10,
- 11, 13, 13, 13, 13, 13, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_9A_infos[14] = {
- o2(0x89,0xE1), o2(0xE5,0x71), o2(0xE5,0x72), o2(0xE5,0x6D),
- o2(0x8E,0x5C), o2(0xE5,0x6E), o2(0x94,0x61), o2(0xE5,0x6F),
- o2(0xE5,0x70), o2(0xE5,0x7A), o2(0xE5,0x74), o2(0xE5,0x77),
- o2(0xE5,0x73), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_9A = {
- to_SHIFT_JIS_E8_9A_offsets,
- to_SHIFT_JIS_E8_9A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_9B_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_9B */
- /* used from to_EUC_JP_E8_9B */
- 22, 22, 22, 22, 0, 22, 1, 2, 22, 3, 22, 4, 22, 5, 6, 22,
- 22, 22, 22, 22, 7, 22, 22, 22, 22, 8, 22, 9, 22, 22, 10, 11,
- 22, 22, 22, 22, 12, 22, 22, 22, 22, 13, 22, 22, 14, 15, 16, 17,
- 22, 22, 22, 22, 22, 22, 22, 22, 18, 19, 22, 20, 22, 22, 21, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_9B_infos[23] = {
- o2(0xE5,0x75), o2(0xE5,0x76), o2(0x8E,0xD6), o2(0xE5,0x78),
- o2(0x92,0x60), o2(0x8C,0x75), o2(0x8A,0x61), o2(0xE5,0x7B),
- o2(0x8A,0x5E), o2(0xE5,0x81), o2(0xE5,0x7C), o2(0xE5,0x80),
- o2(0x94,0xB8), o2(0xE5,0x7D), o2(0xE5,0x7E), o2(0x95,0x67),
- o2(0x94,0xD8), o2(0xE5,0x82), o2(0x91,0xFB), o2(0xE5,0x8C),
- o2(0xE5,0x88), o2(0x89,0xE9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_9B = {
- to_SHIFT_JIS_E8_9B_offsets,
- to_SHIFT_JIS_E8_9B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_9C_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_9C */
- /* used from to_EUC_JP_E8_9C */
- 0, 19, 1, 2, 19, 19, 3, 19, 4, 5, 6, 19, 19, 7, 19, 19,
- 19, 8, 9, 19, 19, 19, 19, 19, 10, 19, 11, 19, 12, 19, 19, 19,
- 19, 19, 19, 19, 19, 13, 19, 19, 19, 14, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 15, 19, 19, 16, 19, 19, 19, 17, 19, 19, 19, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_9C_infos[20] = {
- o2(0xE5,0x86), o2(0x96,0x49), o2(0xE5,0x87), o2(0xE5,0x84),
- o2(0xE5,0x85), o2(0xE5,0x8A), o2(0xE5,0x8D), o2(0xE5,0x8B),
- o2(0xE5,0x89), o2(0xE5,0x83), o2(0x92,0x77), o2(0xE5,0x94),
- o2(0x96,0xA8), o2(0xE5,0x92), o2(0xE5,0x93), o2(0xE5,0x8E),
- o2(0xE5,0x90), o2(0xE5,0x91), o2(0xE5,0x8F), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_9C = {
- to_SHIFT_JIS_E8_9C_offsets,
- to_SHIFT_JIS_E8_9C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_9D_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_9D */
- /* used from to_EUC_JP_E8_9D */
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 19, 1, 2, 19, 3, 19,
- 19, 19, 19, 4, 19, 5, 19, 6, 19, 7, 19, 19, 19, 19, 19, 8,
- 9, 19, 19, 10, 19, 19, 11, 19, 12, 19, 13, 19, 19, 19, 14, 19,
- 19, 19, 19, 19, 15, 19, 16, 19, 17, 19, 19, 19, 19, 19, 19, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_9D_infos[20] = {
- o2(0x90,0xE4), o2(0x98,0x58), o2(0xE5,0x98), o2(0xE5,0x99),
- o2(0xE5,0x9F), o2(0x90,0x49), o2(0xE5,0x9B), o2(0xE5,0x9E),
- o2(0xE5,0x96), o2(0xE5,0x95), o2(0xE5,0xA0), o2(0x89,0xDA),
- o2(0xE5,0x9C), o2(0xE5,0xA1), o2(0xE5,0x9D), o2(0xE5,0x9A),
- o2(0x92,0xB1), o2(0xE5,0x97), o2(0x94,0x88), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_9D = {
- to_SHIFT_JIS_E8_9D_offsets,
- to_SHIFT_JIS_E8_9D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_9E_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_9E */
- /* used from to_EUC_JP_E8_9E */
- 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 2,
- 10, 10, 3, 10, 10, 10, 10, 10, 10, 10, 10, 4, 10, 10, 10, 5,
- 10, 10, 10, 6, 10, 10, 10, 10, 10, 10, 7, 8, 10, 9, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_9E_infos[11] = {
- o2(0xE5,0xA5), o2(0x97,0x5A), o2(0xE5,0xA4), o2(0xE5,0xA3),
- o2(0xE5,0xAC), o2(0xE5,0xA6), o2(0xE5,0xAE), o2(0x97,0x86),
- o2(0xE5,0xB1), o2(0xE5,0xA8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_9E = {
- to_SHIFT_JIS_E8_9E_offsets,
- to_SHIFT_JIS_E8_9E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_9F_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_9F */
- /* used from to_EUC_JP_E8_9F */
- 0, 15, 15, 15, 1, 15, 2, 3, 15, 15, 15, 4, 15, 15, 15, 15,
- 5, 15, 6, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 8,
- 15, 15, 9, 15, 15, 15, 10, 11, 15, 12, 15, 13, 15, 15, 14, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_9F_infos[16] = {
- o2(0xE5,0xA9), o2(0xE5,0xAD), o2(0xE5,0xB0), o2(0xE5,0xAF),
- o2(0xE5,0xA7), o2(0xE5,0xAA), o2(0xE5,0xBB), o2(0xE5,0xB4),
- o2(0xE5,0xB2), o2(0xE5,0xB3), o2(0xE5,0xB8), o2(0xE5,0xB9),
- o2(0x8A,0x49), o2(0x8B,0x61), o2(0xE5,0xB7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_9F = {
- to_SHIFT_JIS_E8_9F_offsets,
- to_SHIFT_JIS_E8_9F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A0_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A0 */
- /* used from to_EUC_JP_E8_A0 */
- 16, 16, 16, 16, 16, 0, 16, 1, 16, 16, 16, 16, 16, 2, 3, 4,
- 16, 5, 16, 16, 16, 6, 7, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 8, 9, 10, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 12, 16, 16, 16, 16, 13, 16, 16, 14, 16, 15, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A0_infos[17] = {
- o2(0xE5,0xA2), o2(0xFB,0xA1), o2(0xE5,0xB6), o2(0xE5,0xBA),
- o2(0xE5,0xB5), o2(0xE5,0xBC), o2(0xE5,0xBE), o2(0xE5,0xBD),
- o2(0xE5,0xC0), o2(0xE5,0xBF), o2(0xE5,0x79), o2(0xE5,0xC4),
- o2(0xE5,0xC1), o2(0xE5,0xC2), o2(0xE5,0xC3), o2(0xE5,0xC5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A0 = {
- to_SHIFT_JIS_E8_A0_offsets,
- to_SHIFT_JIS_E8_A0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A1_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A1 */
- /* used from to_EUC_JP_E8_A1 */
- 0, 25, 1, 25, 2, 25, 3, 25, 25, 25, 25, 25, 4, 5, 25, 25,
- 25, 25, 6, 7, 25, 25, 25, 8, 25, 9, 25, 10, 25, 11, 12, 25,
- 25, 13, 14, 15, 25, 25, 25, 25, 16, 25, 25, 17, 25, 25, 25, 25,
- 18, 25, 19, 25, 25, 20, 25, 21, 25, 25, 25, 25, 25, 22, 23, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A1_infos[26] = {
- o2(0x8C,0x8C), o2(0xE5,0xC7), o2(0xE5,0xC6), o2(0x8F,0x4F),
- o2(0x8D,0x73), o2(0x9F,0xA5), o2(0xE5,0xC8), o2(0x8F,0x70),
- o2(0x8A,0x58), o2(0xE5,0xC9), o2(0x89,0x71), o2(0x8F,0xD5),
- o2(0xE5,0xCA), o2(0x8D,0x74), o2(0xE5,0xCB), o2(0x88,0xDF),
- o2(0x95,0x5C), o2(0xE5,0xCC), o2(0x90,0x8A), o2(0xE5,0xD3),
- o2(0xE5,0xD0), o2(0x92,0x8F), o2(0xE5,0xD1), o2(0xE5,0xCE),
- o2(0x8B,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A1 = {
- to_SHIFT_JIS_E8_A1_offsets,
- to_SHIFT_JIS_E8_A1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A2_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A2 */
- /* used from to_EUC_JP_E8_A2 */
- 20, 0, 1, 20, 20, 20, 20, 20, 2, 20, 20, 3, 20, 4, 20, 20,
- 20, 20, 5, 20, 20, 20, 6, 7, 20, 8, 20, 20, 20, 20, 9, 20,
- 20, 20, 10, 20, 11, 20, 20, 20, 20, 20, 20, 12, 20, 20, 13, 20,
- 14, 15, 20, 20, 16, 17, 20, 18, 20, 20, 20, 20, 20, 20, 20, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A2_infos[21] = {
- o2(0xE5,0xCD), o2(0xE5,0xD4), o2(0x8C,0x55), o2(0x91,0xDC),
- o2(0xE5,0xDA), o2(0xE5,0xD6), o2(0x91,0xB3), o2(0xE5,0xD5),
- o2(0xE5,0xD8), o2(0xE5,0xCF), o2(0xE5,0xD9), o2(0xE5,0xDB),
- o2(0x94,0xED), o2(0xE5,0xD7), o2(0xE5,0xDC), o2(0xE5,0xDE),
- o2(0x8C,0xD1), o2(0xE5,0xD2), o2(0x88,0xBF), o2(0xE5,0xDD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A2 = {
- to_SHIFT_JIS_E8_A2_offsets,
- to_SHIFT_JIS_E8_A2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A3_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A3 */
- /* used from to_EUC_JP_E8_A3 */
- 24, 0, 1, 2, 3, 4, 24, 24, 24, 24, 24, 24, 24, 24, 24, 5,
- 24, 24, 24, 24, 6, 7, 24, 24, 8, 9, 24, 24, 10, 11, 24, 12,
- 24, 13, 24, 24, 24, 24, 24, 24, 14, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 15, 16, 17, 18, 24, 24, 19, 20, 24, 24, 21, 22, 23, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A3_infos[25] = {
- o2(0x8D,0xD9), o2(0x97,0xF4), o2(0xE5,0xDF), o2(0xE5,0xE0),
- o2(0x91,0x95), o2(0x97,0xA0), o2(0xE5,0xE1), o2(0x97,0x54),
- o2(0xE5,0xE2), o2(0xE5,0xE3), o2(0x95,0xE2), o2(0xE5,0xE4),
- o2(0x8D,0xBE), o2(0x97,0xA1), o2(0xE5,0xE9), o2(0xE5,0xEA),
- o2(0x8F,0xD6), o2(0xE5,0xE8), o2(0xFB,0xA2), o2(0x97,0x87),
- o2(0xE5,0xE5), o2(0xE5,0xE7), o2(0x90,0xBB), o2(0x90,0x9E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A3 = {
- to_SHIFT_JIS_E8_A3_offsets,
- to_SHIFT_JIS_E8_A3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A4_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A4 */
- /* used from to_EUC_JP_E8_A4 */
- 17, 17, 0, 17, 1, 17, 17, 2, 17, 17, 3, 17, 4, 17, 17, 17,
- 5, 17, 6, 7, 17, 17, 17, 17, 17, 17, 17, 17, 8, 9, 10, 17,
- 17, 17, 17, 17, 17, 11, 17, 17, 17, 17, 12, 13, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 14, 17, 15, 17, 17, 16, 17, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A4_infos[18] = {
- o2(0xE5,0xE6), o2(0xE5,0xEB), o2(0x95,0xA1), o2(0xE5,0xED),
- o2(0xE5,0xEC), o2(0x8A,0x8C), o2(0x96,0x4A), o2(0xE5,0xEE),
- o2(0xFA,0x5D), o2(0xE5,0xFA), o2(0xE5,0xF0), o2(0xE5,0xF1),
- o2(0xE5,0xF2), o2(0xE5,0xF3), o2(0xE5,0xF7), o2(0xE5,0xF8),
- o2(0xE5,0xF6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A4 = {
- to_SHIFT_JIS_E8_A4_offsets,
- to_SHIFT_JIS_E8_A4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A5_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A5 */
- /* used from to_EUC_JP_E8_A5 */
- 19, 0, 19, 1, 2, 19, 19, 19, 19, 19, 19, 19, 3, 4, 19, 19,
- 19, 19, 19, 19, 19, 19, 5, 19, 19, 19, 19, 19, 19, 19, 6, 7,
- 8, 19, 19, 19, 9, 19, 10, 19, 19, 19, 11, 19, 19, 12, 19, 13,
- 19, 19, 14, 19, 15, 19, 19, 16, 19, 19, 19, 19, 19, 19, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A5_infos[20] = {
- o2(0xE5,0xF4), o2(0xE5,0xEF), o2(0xE5,0xF5), o2(0xE5,0xF9),
- o2(0xE8,0xB5), o2(0x89,0xA6), o2(0xE5,0xFC), o2(0x8B,0xDD),
- o2(0xE5,0xFB), o2(0xE6,0x41), o2(0xE6,0x40), o2(0xE6,0x43),
- o2(0xE6,0x42), o2(0xE6,0x44), o2(0x8F,0x50), o2(0xE6,0x45),
- o2(0xE6,0x46), o2(0xE6,0x47), o2(0x90,0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A5 = {
- to_SHIFT_JIS_E8_A5_offsets,
- to_SHIFT_JIS_E8_A5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A6_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A6 */
- /* used from to_EUC_JP_E8_A6 */
- 25, 0, 25, 1, 25, 25, 2, 3, 4, 25, 5, 6, 25, 25, 25, 7,
- 25, 25, 25, 8, 25, 25, 9, 10, 11, 25, 12, 25, 25, 25, 25, 25,
- 25, 13, 25, 25, 25, 25, 14, 15, 25, 16, 17, 25, 18, 25, 25, 19,
- 25, 25, 20, 21, 25, 25, 25, 25, 25, 25, 22, 25, 25, 23, 25, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A6_infos[26] = {
- o2(0x97,0x76), o2(0xE6,0x48), o2(0x95,0xA2), o2(0x94,0x65),
- o2(0xE6,0x49), o2(0xE6,0x4A), o2(0x8C,0xA9), o2(0x8B,0x4B),
- o2(0xE6,0x4B), o2(0x8E,0x8B), o2(0x94,0x60), o2(0xE6,0x4C),
- o2(0x8A,0x6F), o2(0xE6,0x4D), o2(0xE6,0x4F), o2(0x97,0x97),
- o2(0xE6,0x4E), o2(0x90,0x65), o2(0xE6,0x50), o2(0xE6,0x51),
- o2(0xE6,0x52), o2(0x8A,0xCF), o2(0xE6,0x53), o2(0xE6,0x54),
- o2(0xE6,0x55), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A6 = {
- to_SHIFT_JIS_E8_A6_offsets,
- to_SHIFT_JIS_E8_A6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A7_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A7 */
- /* used from to_EUC_JP_E8_A7 */
- 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 1, 10, 10, 10, 10, 10, 10, 10, 2, 10, 3, 4, 10, 10,
- 10, 10, 10, 5, 10, 10, 6, 7, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 8, 10, 10, 10, 9, 10, 10, 10, 10, 10, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A7_infos[11] = {
- o2(0xE6,0x56), o2(0x8A,0x70), o2(0xE6,0x57), o2(0xE6,0x58),
- o2(0xE6,0x59), o2(0x89,0xF0), o2(0x90,0x47), o2(0xE6,0x5A),
- o2(0xE6,0x5B), o2(0xE6,0x5C), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A7 = {
- to_SHIFT_JIS_E8_A7_offsets,
- to_SHIFT_JIS_E8_A7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A8_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A8 */
- /* used from to_EUC_JP_E8_A8 */
- 0, 28, 1, 2, 28, 28, 28, 28, 3, 28, 4, 28, 5, 28, 6, 28,
- 7, 28, 8, 9, 28, 28, 10, 11, 12, 28, 28, 13, 28, 14, 28, 15,
- 28, 28, 28, 16, 28, 17, 28, 28, 28, 28, 18, 28, 28, 19, 28, 28,
- 28, 20, 28, 21, 22, 28, 23, 24, 28, 28, 25, 26, 27, 28, 28, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A8_infos[29] = {
- o2(0x8C,0xBE), o2(0x92,0xF9), o2(0xE6,0x5D), o2(0x8C,0x76),
- o2(0x90,0x75), o2(0xE6,0x60), o2(0x93,0xA2), o2(0xE6,0x5F),
- o2(0xFB,0xA3), o2(0x8C,0x50), o2(0xE6,0x5E), o2(0x91,0xF5),
- o2(0x8B,0x4C), o2(0xE6,0x61), o2(0xE6,0x62), o2(0x8F,0xD7),
- o2(0x8C,0x8D), o2(0xE6,0x63), o2(0x96,0x4B), o2(0x90,0xDD),
- o2(0x8B,0x96), o2(0x96,0xF3), o2(0x91,0x69), o2(0xE6,0x64),
- o2(0xFB,0xA4), o2(0x90,0x66), o2(0x92,0x90), o2(0x8F,0xD8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A8 = {
- to_SHIFT_JIS_E8_A8_offsets,
- to_SHIFT_JIS_E8_A8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_A9_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_A9 */
- /* used from to_EUC_JP_E8_A9 */
- 25, 0, 25, 25, 25, 25, 1, 25, 2, 25, 25, 25, 25, 25, 25, 25,
- 3, 4, 5, 25, 6, 7, 25, 25, 25, 25, 25, 8, 25, 25, 9, 25,
- 10, 25, 11, 12, 25, 25, 13, 25, 25, 14, 25, 15, 16, 17, 18, 25,
- 19, 20, 21, 22, 25, 25, 25, 25, 25, 23, 25, 25, 24, 25, 25, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_A9_infos[26] = {
- o2(0xE6,0x65), o2(0xE6,0x68), o2(0xE6,0x69), o2(0x8D,0xBC),
- o2(0x91,0xC0), o2(0xE6,0x67), o2(0x8F,0xD9), o2(0x95,0x5D),
- o2(0xE6,0x66), o2(0x8E,0x8C), o2(0x89,0x72), o2(0xE6,0x6D),
- o2(0x8C,0x77), o2(0x8E,0x8E), o2(0x8E,0x8D), o2(0x98,0x6C),
- o2(0xE6,0x6C), o2(0xE6,0x6B), o2(0x91,0x46), o2(0x8B,0x6C),
- o2(0x98,0x62), o2(0x8A,0x59), o2(0x8F,0xDA), o2(0xFB,0xA5),
- o2(0xE6,0x6A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_A9 = {
- to_SHIFT_JIS_E8_A9_offsets,
- to_SHIFT_JIS_E8_A9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_AA_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_AA */
- /* used from to_EUC_JP_E8_AA */
- 29, 29, 0, 29, 1, 2, 29, 3, 29, 4, 29, 29, 5, 6, 29, 29,
- 29, 7, 29, 8, 29, 9, 29, 29, 10, 29, 11, 29, 29, 29, 12, 29,
- 13, 14, 29, 15, 16, 17, 18, 19, 20, 29, 29, 29, 21, 22, 29, 29,
- 23, 29, 24, 29, 29, 29, 29, 29, 29, 25, 29, 29, 26, 29, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_AA_infos[30] = {
- o2(0xE6,0x6F), o2(0xE6,0x70), o2(0xE6,0x6E), o2(0x8C,0xD6),
- o2(0x97,0x5F), o2(0x8E,0x8F), o2(0x94,0x46), o2(0xE6,0x73),
- o2(0x90,0xBE), o2(0x92,0x61), o2(0x97,0x55), o2(0xE6,0x76),
- o2(0x8C,0xEA), o2(0x90,0xBD), o2(0xE6,0x72), o2(0xE6,0x77),
- o2(0x8C,0xEB), o2(0xE6,0x74), o2(0xE6,0x75), o2(0xFB,0xA6),
- o2(0xE6,0x71), o2(0x90,0xE0), o2(0x93,0xC7), o2(0x92,0x4E),
- o2(0x89,0xDB), o2(0x94,0xEE), o2(0x8B,0x62), o2(0xFB,0xA7),
- o2(0x92,0xB2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_AA = {
- to_SHIFT_JIS_E8_AA_offsets,
- to_SHIFT_JIS_E8_AA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_AB_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_AB */
- /* used from to_EUC_JP_E8_AB */
- 30, 30, 0, 30, 1, 30, 30, 2, 30, 30, 30, 3, 4, 5, 30, 6,
- 30, 30, 7, 30, 30, 30, 8, 30, 30, 30, 9, 10, 11, 30, 12, 13,
- 14, 15, 16, 30, 17, 30, 18, 19, 30, 30, 30, 20, 30, 21, 22, 30,
- 30, 23, 30, 24, 30, 30, 25, 26, 27, 30, 28, 30, 30, 30, 29, 30,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_AB_infos[31] = {
- o2(0xE6,0x7A), o2(0xE6,0x78), o2(0x92,0x6B), o2(0x90,0xBF),
- o2(0x8A,0xD0), o2(0xE6,0x79), o2(0x90,0x7A), o2(0x97,0xC8),
- o2(0x98,0x5F), o2(0xE6,0x7B), o2(0xE6,0x87), o2(0x92,0xB3),
- o2(0xE6,0x86), o2(0xFB,0xA8), o2(0xE6,0x83), o2(0xE6,0x8B),
- o2(0xE6,0x84), o2(0xE6,0x80), o2(0x92,0xFA), o2(0xE6,0x7E),
- o2(0xE6,0x7C), o2(0x97,0x40), o2(0x8E,0x90), o2(0xE6,0x81),
- o2(0xE6,0x7D), o2(0xFB,0xAA), o2(0xE6,0x85), o2(0x8F,0x94),
- o2(0x8C,0xBF), o2(0x91,0xF8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_AB = {
- to_SHIFT_JIS_E8_AB_offsets,
- to_SHIFT_JIS_E8_AB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_AC_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_AC */
- /* used from to_EUC_JP_E8_AC */
- 0, 1, 2, 24, 3, 24, 24, 4, 24, 24, 24, 24, 5, 24, 6, 24,
- 7, 24, 24, 24, 8, 24, 9, 10, 24, 11, 12, 13, 24, 14, 24, 24,
- 15, 16, 24, 24, 24, 24, 17, 24, 18, 24, 24, 19, 20, 24, 24, 24,
- 24, 24, 24, 21, 24, 24, 24, 24, 24, 22, 24, 24, 24, 24, 23, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_AC_infos[25] = {
- o2(0x96,0x64), o2(0x89,0x79), o2(0x88,0xE0), o2(0x93,0xA3),
- o2(0xE6,0x89), o2(0xE6,0x88), o2(0x93,0xE4), o2(0xE6,0x8D),
- o2(0xE6,0x82), o2(0xE6,0x8C), o2(0xE6,0x8E), o2(0x8C,0xAA),
- o2(0xE6,0x8A), o2(0x8D,0x75), o2(0x8E,0xD3), o2(0xE6,0x8F),
- o2(0x97,0x77), o2(0xE6,0x92), o2(0xE6,0x95), o2(0xE6,0x93),
- o2(0x95,0x54), o2(0xE6,0x90), o2(0x8B,0xDE), o2(0xE6,0x94),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_AC = {
- to_SHIFT_JIS_E8_AC_offsets,
- to_SHIFT_JIS_E8_AC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_AD_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_AD */
- /* used from to_EUC_JP_E8_AD */
- 23, 0, 23, 23, 23, 23, 23, 23, 23, 1, 23, 23, 2, 23, 3, 4,
- 23, 23, 23, 5, 23, 23, 6, 23, 7, 23, 8, 9, 10, 23, 23, 11,
- 23, 23, 23, 23, 23, 23, 12, 23, 23, 23, 23, 13, 14, 23, 23, 15,
- 16, 17, 18, 23, 19, 23, 23, 20, 23, 23, 23, 23, 23, 21, 23, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_AD_infos[24] = {
- o2(0xE6,0x96), o2(0xE6,0x9A), o2(0xE6,0x97), o2(0xE6,0x99),
- o2(0xE6,0x98), o2(0xFB,0xAB), o2(0xE6,0x9B), o2(0x8E,0xAF),
- o2(0xE6,0x9D), o2(0xE6,0x9C), o2(0x95,0x88), o2(0xE6,0x9F),
- o2(0x8C,0x78), o2(0xE6,0x9E), o2(0xE6,0xA0), o2(0xE6,0xA1),
- o2(0x8B,0x63), o2(0xE3,0xBF), o2(0x8F,0xF7), o2(0xE6,0xA2),
- o2(0x8C,0xEC), o2(0xE6,0xA3), o2(0xFB,0xAC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_AD = {
- to_SHIFT_JIS_E8_AD_offsets,
- to_SHIFT_JIS_E8_AD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_AE_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_AE */
- /* used from to_EUC_JP_E8_AE */
- 0, 11, 11, 1, 11, 11, 11, 11, 11, 11, 2, 11, 3, 11, 4, 11,
- 5, 11, 6, 7, 11, 11, 8, 11, 11, 9, 10, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_AE_infos[12] = {
- o2(0xE6,0xA4), o2(0x8E,0x5D), o2(0x9D,0xCC), o2(0xE6,0xA5),
- o2(0xE6,0xA6), o2(0x8F,0x51), o2(0xE6,0xA7), o2(0xE6,0xA8),
- o2(0xE6,0xA9), o2(0xE6,0xAA), o2(0xE6,0xAB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_AE = {
- to_SHIFT_JIS_E8_AE_offsets,
- to_SHIFT_JIS_E8_AE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B0_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B0 */
- /* used from to_EUC_JP_E8_B0 */
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 1, 3, 3, 3, 3, 2,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B0_infos[4] = {
- o2(0x92,0x4A), o2(0xE6,0xAC), o2(0xE6,0xAE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B0 = {
- to_SHIFT_JIS_E8_B0_offsets,
- to_SHIFT_JIS_E8_B0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B1_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B1 */
- /* used from to_EUC_JP_E8_B1 */
- 18, 0, 18, 18, 18, 18, 1, 18, 2, 18, 3, 18, 4, 18, 5, 18,
- 6, 18, 18, 18, 18, 7, 18, 18, 18, 18, 8, 18, 18, 18, 18, 18,
- 18, 9, 10, 18, 18, 18, 18, 18, 18, 18, 11, 12, 13, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 14, 15, 16, 18, 17, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B1_infos[19] = {
- o2(0xE6,0xAD), o2(0x93,0xA4), o2(0xE6,0xAF), o2(0x96,0x4C),
- o2(0xE6,0xB0), o2(0xE6,0xB1), o2(0xE6,0xB2), o2(0xE6,0xB3),
- o2(0x93,0xD8), o2(0x8F,0xDB), o2(0xE6,0xB4), o2(0x8D,0x8B),
- o2(0x98,0xAC), o2(0xE6,0xB5), o2(0xE6,0xB6), o2(0x95,0x5E),
- o2(0xE6,0xB7), o2(0xE6,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B1 = {
- to_SHIFT_JIS_E8_B1_offsets,
- to_SHIFT_JIS_E8_B1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B2_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B2 */
- /* used from to_EUC_JP_E8_B2 */
- 34, 34, 0, 34, 34, 1, 34, 34, 34, 2, 3, 34, 4, 5, 6, 34,
- 34, 34, 34, 34, 7, 34, 34, 34, 8, 34, 34, 34, 34, 9, 10, 34,
- 11, 12, 13, 34, 34, 34, 34, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 34, 24, 25, 26, 34, 27, 28, 29, 34, 34, 30, 31, 32, 34, 33,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B2_infos[35] = {
- o2(0xE6,0xB8), o2(0xE6,0xBA), o2(0xE6,0xB9), o2(0xE6,0xBB),
- o2(0x96,0x65), o2(0xE6,0xBC), o2(0xE6,0xBD), o2(0xE6,0xBE),
- o2(0xE6,0xC0), o2(0x8A,0x4C), o2(0x92,0xE5), o2(0x95,0x89),
- o2(0x8D,0xE0), o2(0x8D,0x76), o2(0x95,0x6E), o2(0x89,0xDD),
- o2(0x94,0xCC), o2(0xE6,0xC3), o2(0x8A,0xD1), o2(0x90,0xD3),
- o2(0xE6,0xC2), o2(0xE6,0xC7), o2(0x92,0x99), o2(0x96,0xE1),
- o2(0xE6,0xC5), o2(0xE6,0xC6), o2(0x8B,0x4D), o2(0xE6,0xC8),
- o2(0x94,0x83), o2(0x91,0xDD), o2(0x94,0xEF), o2(0x93,0x5C),
- o2(0xE6,0xC4), o2(0x96,0x66), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B2 = {
- to_SHIFT_JIS_E8_B2_offsets,
- to_SHIFT_JIS_E8_B2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B3_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B3 */
- /* used from to_EUC_JP_E8_B3 */
- 0, 1, 2, 3, 4, 29, 29, 5, 6, 29, 7, 29, 29, 8, 9, 29,
- 29, 10, 29, 11, 29, 29, 29, 29, 29, 29, 12, 13, 14, 29, 15, 29,
- 16, 29, 17, 18, 19, 29, 20, 29, 29, 29, 21, 29, 29, 22, 29, 29,
- 23, 29, 29, 29, 24, 29, 29, 29, 29, 29, 25, 26, 27, 28, 29, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B3_infos[30] = {
- o2(0x89,0xEA), o2(0xE6,0xCA), o2(0x98,0x47), o2(0x92,0xC0),
- o2(0x98,0x64), o2(0x8E,0x91), o2(0xE6,0xC9), o2(0x91,0xAF),
- o2(0xE6,0xDA), o2(0x91,0x47), o2(0x93,0xF6), o2(0x95,0x6F),
- o2(0xE6,0xCD), o2(0x8E,0x5E), o2(0x8E,0x92), o2(0x8F,0xDC),
- o2(0x94,0x85), o2(0x8C,0xAB), o2(0xE6,0xCC), o2(0xE6,0xCB),
- o2(0x95,0x8A), o2(0x8E,0xBF), o2(0x93,0x71), o2(0xFB,0xAD),
- o2(0xFB,0xAE), o2(0xE6,0xCF), o2(0xE6,0xD0), o2(0x8D,0x77),
- o2(0xE6,0xCE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B3 = {
- to_SHIFT_JIS_E8_B3_offsets,
- to_SHIFT_JIS_E8_B3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B4_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B4 */
- /* used from to_EUC_JP_E8_B4 */
- 13, 13, 13, 13, 0, 1, 13, 2, 3, 13, 4, 5, 13, 6, 13, 7,
- 8, 13, 9, 10, 11, 13, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B4_infos[14] = {
- o2(0xE6,0xD1), o2(0xE6,0xD2), o2(0xE6,0xD4), o2(0x91,0xA1),
- o2(0xE6,0xD3), o2(0x8A,0xE4), o2(0xE6,0xD6), o2(0xE6,0xD5),
- o2(0xE6,0xD7), o2(0xFB,0xAF), o2(0xE6,0xD9), o2(0xE6,0xDB),
- o2(0xE6,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B4 = {
- to_SHIFT_JIS_E8_B4_offsets,
- to_SHIFT_JIS_E8_B4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B5_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B5 */
- /* used from to_EUC_JP_E8_B5 */
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 0, 11, 1, 2, 11, 11, 11, 3, 11, 4, 11, 11,
- 5, 6, 11, 7, 8, 11, 9, 10, 11, 11, 11, 11, 11, 11, 11, 11,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B5_infos[12] = {
- o2(0x90,0xD4), o2(0x8E,0xCD), o2(0xE6,0xDD), o2(0x8A,0x71),
- o2(0xE6,0xDE), o2(0x91,0x96), o2(0xE6,0xDF), o2(0xE6,0xE0),
- o2(0x95,0x8B), o2(0xFB,0xB0), o2(0x8B,0x4E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B5 = {
- to_SHIFT_JIS_E8_B5_offsets,
- to_SHIFT_JIS_E8_B5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B6_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B6 */
- /* used from to_EUC_JP_E8_B6 */
- 9, 0, 9, 9, 9, 1, 9, 9, 9, 9, 2, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 4, 9, 9, 9, 9, 5, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 6, 9, 9, 9, 9, 9, 9, 7, 9, 9, 9, 8, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B6_infos[10] = {
- o2(0xE6,0xE1), o2(0x92,0xB4), o2(0x89,0x7A), o2(0xE6,0xE2),
- o2(0x8E,0xEF), o2(0x90,0x96), o2(0x91,0xAB), o2(0xE6,0xE5),
- o2(0xE6,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B6 = {
- to_SHIFT_JIS_E8_B6_offsets,
- to_SHIFT_JIS_E8_B6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B7_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B7 */
- /* used from to_EUC_JP_E8_B7 */
- 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 1, 2, 19, 19, 3,
- 19, 19, 19, 19, 19, 19, 4, 19, 19, 19, 5, 6, 19, 7, 19, 8,
- 19, 9, 19, 10, 19, 19, 19, 19, 11, 19, 12, 13, 19, 19, 19, 14,
- 19, 19, 19, 15, 19, 16, 19, 19, 19, 19, 19, 19, 17, 19, 19, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B7_infos[20] = {
- o2(0xE6,0xE3), o2(0xE6,0xEB), o2(0xE6,0xE9), o2(0xE6,0xE6),
- o2(0xE6,0xE8), o2(0xE6,0xE7), o2(0xE6,0xEA), o2(0x8B,0x97),
- o2(0xE6,0xEE), o2(0x90,0xD5), o2(0xE6,0xEF), o2(0x8C,0xD7),
- o2(0xE6,0xEC), o2(0xE6,0xED), o2(0x98,0x48), o2(0x92,0xB5),
- o2(0x91,0x48), o2(0xE6,0xF0), o2(0xE6,0xF3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B7 = {
- to_SHIFT_JIS_E8_B7_offsets,
- to_SHIFT_JIS_E8_B7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B8_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B8 */
- /* used from to_EUC_JP_E8_B8 */
- 12, 12, 12, 12, 12, 12, 12, 12, 0, 1, 2, 12, 12, 12, 12, 3,
- 4, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 5, 6, 7,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 8, 12, 12, 12, 12, 12,
- 9, 12, 12, 12, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B8_infos[13] = {
- o2(0xE6,0xF1), o2(0xE6,0xF2), o2(0x97,0x78), o2(0x93,0xA5),
- o2(0xE6,0xF6), o2(0xE6,0xF4), o2(0xE6,0xF5), o2(0xE6,0xF7),
- o2(0xE7,0x48), o2(0xE6,0xFA), o2(0xE6,0xFB), o2(0xE6,0xF9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B8 = {
- to_SHIFT_JIS_E8_B8_offsets,
- to_SHIFT_JIS_E8_B8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_B9_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_B9 */
- /* used from to_EUC_JP_E8_B9 */
- 18, 18, 0, 18, 1, 18, 18, 2, 3, 4, 5, 18, 6, 18, 18, 18,
- 7, 18, 18, 18, 18, 8, 18, 18, 18, 9, 18, 18, 18, 18, 18, 10,
- 11, 18, 18, 12, 13, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 14, 18, 15, 18, 16, 18, 18, 18, 18, 18, 17, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_B9_infos[19] = {
- o2(0xE6,0xF8), o2(0x92,0xFB), o2(0xE7,0x40), o2(0xE7,0x44),
- o2(0xE7,0x41), o2(0xE6,0xFC), o2(0xE7,0x42), o2(0xE7,0x43),
- o2(0xE7,0x4A), o2(0xE7,0x45), o2(0x90,0xD6), o2(0xE7,0x47),
- o2(0xE7,0x49), o2(0xE7,0x46), o2(0xE7,0x4C), o2(0x8F,0x52),
- o2(0xE7,0x4B), o2(0xE7,0x4D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_B9 = {
- to_SHIFT_JIS_E8_B9_offsets,
- to_SHIFT_JIS_E8_B9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_BA_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_BA */
- /* used from to_EUC_JP_E8_BA */
- 19, 0, 19, 19, 1, 2, 19, 3, 19, 19, 4, 5, 19, 6, 19, 19,
- 19, 7, 19, 8, 9, 19, 19, 19, 19, 10, 19, 19, 19, 19, 19, 19,
- 19, 11, 19, 19, 19, 19, 19, 19, 19, 19, 12, 13, 14, 19, 19, 15,
- 16, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_BA_infos[20] = {
- o2(0xE7,0x4E), o2(0xE7,0x51), o2(0xE7,0x50), o2(0xE7,0x4F),
- o2(0xE7,0x53), o2(0xE7,0x52), o2(0x96,0xF4), o2(0xE7,0x55),
- o2(0xE7,0x54), o2(0xE7,0x56), o2(0xE7,0x57), o2(0xE7,0x59),
- o2(0xE7,0x58), o2(0x90,0x67), o2(0xE7,0x5A), o2(0x8B,0xEB),
- o2(0xE7,0x5B), o2(0xE7,0x5D), o2(0xE7,0x5E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_BA = {
- to_SHIFT_JIS_E8_BA_offsets,
- to_SHIFT_JIS_E8_BA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_BB_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_BB */
- /* used from to_EUC_JP_E8_BB */
- 19, 19, 19, 19, 19, 0, 1, 19, 2, 19, 3, 4, 5, 6, 19, 7,
- 19, 19, 8, 19, 19, 19, 19, 19, 19, 19, 19, 9, 19, 19, 19, 10,
- 19, 19, 11, 12, 19, 19, 19, 19, 19, 19, 19, 13, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 14, 19, 19, 15, 16, 17, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_BB_infos[20] = {
- o2(0xE7,0x5F), o2(0xE7,0x5C), o2(0xE7,0x60), o2(0x8E,0xD4),
- o2(0xE7,0x61), o2(0x8B,0x4F), o2(0x8C,0x52), o2(0xFB,0xB2),
- o2(0x8C,0xAC), o2(0xE7,0x62), o2(0x93,0xEE), o2(0x93,0x5D),
- o2(0xE7,0x63), o2(0xE7,0x66), o2(0x8E,0xB2), o2(0xE7,0x65),
- o2(0xE7,0x64), o2(0x8C,0x79), o2(0xE7,0x67), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_BB = {
- to_SHIFT_JIS_E8_BB_offsets,
- to_SHIFT_JIS_E8_BB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_BC */
- /* used from to_EUC_JP_E8_BC */
- 24, 24, 24, 0, 24, 1, 24, 24, 24, 2, 3, 24, 4, 24, 24, 24,
- 24, 24, 5, 6, 7, 8, 24, 24, 24, 9, 24, 10, 11, 12, 24, 13,
- 24, 24, 24, 24, 24, 24, 14, 24, 24, 15, 16, 24, 24, 24, 24, 17,
- 24, 24, 24, 18, 24, 24, 24, 24, 19, 20, 24, 21, 24, 24, 22, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_BC_infos[25] = {
- o2(0x8A,0x72), o2(0xE7,0x69), o2(0x8D,0xDA), o2(0xE7,0x68),
- o2(0xE7,0x71), o2(0xE7,0x6B), o2(0xE7,0x6D), o2(0x95,0xE3),
- o2(0xE7,0x6A), o2(0xE7,0x6C), o2(0xE7,0x70), o2(0xE7,0x6E),
- o2(0x8B,0x50), o2(0xE7,0x6F), o2(0xE7,0x72), o2(0x94,0x79),
- o2(0x97,0xD6), o2(0x8F,0x53), o2(0xE7,0x73), o2(0x97,0x41),
- o2(0xE7,0x75), o2(0xE7,0x74), o2(0xE7,0x78), o2(0x97,0x60),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_BC = {
- to_SHIFT_JIS_E8_BC_offsets,
- to_SHIFT_JIS_E8_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_BD */
- /* used from to_EUC_JP_E8_BD */
- 15, 15, 0, 15, 1, 2, 3, 15, 15, 4, 15, 15, 5, 6, 7, 15,
- 15, 15, 15, 15, 15, 15, 15, 8, 15, 15, 15, 15, 9, 15, 15, 10,
- 15, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_BD_infos[16] = {
- o2(0xE7,0x77), o2(0x8A,0x8D), o2(0xE7,0x76), o2(0xE7,0x7B),
- o2(0xE7,0x7A), o2(0xE7,0x79), o2(0x93,0x51), o2(0xE7,0x7C),
- o2(0xE7,0x7D), o2(0xE7,0x7E), o2(0x8D,0x8C), o2(0x8C,0x44),
- o2(0xE7,0x80), o2(0xE7,0x81), o2(0xE7,0x82), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_BD = {
- to_SHIFT_JIS_E8_BD_offsets,
- to_SHIFT_JIS_E8_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_BE */
- /* used from to_EUC_JP_E8_BE */
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 1, 18, 2, 3,
- 18, 18, 18, 4, 18, 18, 18, 5, 6, 18, 18, 18, 18, 7, 8, 9,
- 10, 11, 12, 18, 18, 18, 18, 13, 18, 18, 14, 15, 16, 18, 18, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_BE_infos[19] = {
- o2(0x90,0x68), o2(0xE7,0x83), o2(0x8E,0xAB), o2(0xE7,0x84),
- o2(0xE7,0x85), o2(0x99,0x9F), o2(0x99,0x9E), o2(0xE7,0x86),
- o2(0xE3,0x90), o2(0xE7,0x87), o2(0x92,0x43), o2(0x90,0x4A),
- o2(0x94,0x5F), o2(0xE7,0x88), o2(0x95,0xD3), o2(0x92,0xD2),
- o2(0x8D,0x9E), o2(0x92,0x48), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_BE = {
- to_SHIFT_JIS_E8_BE_offsets,
- to_SHIFT_JIS_E8_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_BF_offsets[64] = {
- /* used from to_SHIFT_JIS_E8_BF */
- /* used from to_EUC_JP_E8_BF */
- 22, 22, 0, 22, 1, 2, 22, 22, 22, 22, 22, 22, 22, 22, 3, 22,
- 22, 4, 22, 22, 5, 22, 22, 22, 22, 22, 6, 22, 22, 22, 22, 22,
- 22, 22, 7, 22, 22, 8, 9, 22, 22, 10, 11, 12, 22, 13, 22, 14,
- 15, 22, 22, 22, 16, 22, 22, 17, 18, 19, 20, 22, 22, 21, 22, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_BF_infos[23] = {
- o2(0x89,0x49), o2(0x96,0x98), o2(0x90,0x76), o2(0x8C,0x7D),
- o2(0x8B,0xDF), o2(0x95,0xD4), o2(0xE7,0x89), o2(0xE7,0x8B),
- o2(0xE7,0x8A), o2(0x89,0xDE), o2(0x93,0xF4), o2(0xE7,0x8C),
- o2(0x94,0x97), o2(0x93,0x52), o2(0xE7,0x8D), o2(0x8F,0x71),
- o2(0xE7,0x8F), o2(0x96,0xC0), o2(0xE7,0x9E), o2(0xE7,0x91),
- o2(0xE7,0x92), o2(0x92,0xC7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8_BF = {
- to_SHIFT_JIS_E8_BF_offsets,
- to_SHIFT_JIS_E8_BF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E8_offsets[64] = {
- /* used from to_SHIFT_JIS_E8 */
- /* used from to_EUC_JP_E8 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 63,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E8_infos[64] = {
- &to_SHIFT_JIS_E8_80, &to_SHIFT_JIS_E8_81,
- &to_SHIFT_JIS_E8_82, &to_SHIFT_JIS_E8_83,
- &to_SHIFT_JIS_E8_84, &to_SHIFT_JIS_E8_85,
- &to_SHIFT_JIS_E8_86, &to_SHIFT_JIS_E8_87,
- &to_SHIFT_JIS_E8_88, &to_SHIFT_JIS_E8_89,
- &to_SHIFT_JIS_E8_8A, &to_SHIFT_JIS_E8_8B,
- &to_SHIFT_JIS_E8_8C, &to_SHIFT_JIS_E8_8D,
- &to_SHIFT_JIS_E8_8E, &to_SHIFT_JIS_E8_8F,
- &to_SHIFT_JIS_E8_90, &to_SHIFT_JIS_E8_91,
- &to_SHIFT_JIS_E8_92, &to_SHIFT_JIS_E8_93,
- &to_SHIFT_JIS_E8_94, &to_SHIFT_JIS_E8_95,
- &to_SHIFT_JIS_E8_96, &to_SHIFT_JIS_E8_97,
- &to_SHIFT_JIS_E8_98, &to_SHIFT_JIS_E8_99,
- &to_SHIFT_JIS_E8_9A, &to_SHIFT_JIS_E8_9B,
- &to_SHIFT_JIS_E8_9C, &to_SHIFT_JIS_E8_9D,
- &to_SHIFT_JIS_E8_9E, &to_SHIFT_JIS_E8_9F,
- &to_SHIFT_JIS_E8_A0, &to_SHIFT_JIS_E8_A1,
- &to_SHIFT_JIS_E8_A2, &to_SHIFT_JIS_E8_A3,
- &to_SHIFT_JIS_E8_A4, &to_SHIFT_JIS_E8_A5,
- &to_SHIFT_JIS_E8_A6, &to_SHIFT_JIS_E8_A7,
- &to_SHIFT_JIS_E8_A8, &to_SHIFT_JIS_E8_A9,
- &to_SHIFT_JIS_E8_AA, &to_SHIFT_JIS_E8_AB,
- &to_SHIFT_JIS_E8_AC, &to_SHIFT_JIS_E8_AD,
- &to_SHIFT_JIS_E8_AE, &to_SHIFT_JIS_E8_B0,
- &to_SHIFT_JIS_E8_B1, &to_SHIFT_JIS_E8_B2,
- &to_SHIFT_JIS_E8_B3, &to_SHIFT_JIS_E8_B4,
- &to_SHIFT_JIS_E8_B5, &to_SHIFT_JIS_E8_B6,
- &to_SHIFT_JIS_E8_B7, &to_SHIFT_JIS_E8_B8,
- &to_SHIFT_JIS_E8_B9, &to_SHIFT_JIS_E8_BA,
- &to_SHIFT_JIS_E8_BB, &to_SHIFT_JIS_E8_BC,
- &to_SHIFT_JIS_E8_BD, &to_SHIFT_JIS_E8_BE,
- &to_SHIFT_JIS_E8_BF, UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E8 = {
- to_SHIFT_JIS_E8_offsets,
- to_SHIFT_JIS_E8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_80_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_80 */
- /* used from to_EUC_JP_E9_80 */
- 0, 1, 35, 2, 35, 3, 4, 35, 35, 35, 35, 5, 35, 6, 7, 8,
- 9, 10, 35, 11, 12, 13, 14, 15, 35, 16, 17, 35, 35, 18, 19, 20,
- 21, 22, 23, 24, 35, 35, 35, 25, 35, 35, 35, 35, 35, 35, 26, 35,
- 35, 27, 28, 35, 35, 29, 30, 35, 31, 32, 35, 35, 33, 35, 34, 35,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_80_infos[36] = {
- o2(0x91,0xDE), o2(0x91,0x97), o2(0x93,0xA6), o2(0xE7,0x90),
- o2(0x8B,0x74), o2(0xE7,0x99), o2(0xE7,0x96), o2(0xE7,0xA3),
- o2(0x93,0xA7), o2(0x92,0x80), o2(0xE7,0x93), o2(0x92,0xFC),
- o2(0x93,0x72), o2(0xE7,0x94), o2(0xE7,0x98), o2(0x90,0x80),
- o2(0x94,0x87), o2(0x92,0xCA), o2(0x90,0xC0), o2(0xE7,0x97),
- o2(0x91,0xAC), o2(0x91,0xA2), o2(0xE7,0x95), o2(0x88,0xA7),
- o2(0x98,0x41), o2(0xE7,0x9A), o2(0x91,0xDF), o2(0x8F,0x54),
- o2(0x90,0x69), o2(0xE7,0x9C), o2(0xE7,0x9B), o2(0x88,0xED),
- o2(0xE7,0x9D), o2(0x95,0x4E), o2(0xE7,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_80 = {
- to_SHIFT_JIS_E9_80_offsets,
- to_SHIFT_JIS_E9_80_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_81_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_81 */
- /* used from to_EUC_JP_E9_81 */
- 40, 0, 1, 40, 40, 2, 40, 3, 40, 4, 5, 6, 40, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 40, 17, 18, 40, 40, 19, 40, 20, 40,
- 21, 22, 40, 23, 40, 24, 40, 25, 26, 27, 40, 40, 40, 28, 29, 30,
- 40, 40, 31, 40, 40, 32, 33, 34, 35, 40, 36, 40, 37, 38, 40, 39,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_81_infos[41] = {
- o2(0x93,0xD9), o2(0x90,0x8B), o2(0x92,0x78), o2(0x8B,0xF6),
- o2(0xE7,0xA4), o2(0x97,0x56), o2(0x89,0x5E), o2(0x95,0xD5),
- o2(0x89,0xDF), o2(0xE7,0x9F), o2(0xE7,0xA0), o2(0xE7,0xA1),
- o2(0xE7,0xA2), o2(0x93,0xB9), o2(0x92,0x42), o2(0x88,0xE1),
- o2(0xE7,0xA6), o2(0xE7,0xA7), o2(0xEA,0xA1), o2(0x91,0xBB),
- o2(0xE7,0xA8), o2(0x89,0x93), o2(0x91,0x6B), o2(0x8C,0xAD),
- o2(0x97,0x79), o2(0xFB,0xB5), o2(0xE7,0xA9), o2(0x93,0x4B),
- o2(0x91,0x98), o2(0x8E,0xD5), o2(0xE7,0xAA), o2(0xE7,0xAD),
- o2(0x8F,0x85), o2(0xE7,0xAB), o2(0x91,0x4A), o2(0x91,0x49),
- o2(0x88,0xE2), o2(0x97,0xC9), o2(0xE7,0xAF), o2(0x94,0xF0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_81 = {
- to_SHIFT_JIS_E9_81_offsets,
- to_SHIFT_JIS_E9_81_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_82_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_82 */
- /* used from to_EUC_JP_E9_82 */
- 0, 1, 2, 3, 4, 18, 18, 5, 18, 6, 7, 18, 18, 18, 18, 8,
- 18, 9, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 10, 18, 18, 11, 18, 12, 18, 13, 18, 18, 18, 18, 14,
- 18, 15, 18, 18, 18, 16, 18, 18, 17, 18, 18, 18, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_82_infos[19] = {
- o2(0xE7,0xB1), o2(0xE7,0xB0), o2(0xE7,0xAE), o2(0xE2,0x84),
- o2(0x8A,0xD2), o2(0xE7,0x8E), o2(0xE7,0xB3), o2(0xE7,0xB2),
- o2(0xE7,0xB4), o2(0x97,0x57), o2(0x93,0xDF), o2(0x96,0x4D),
- o2(0xE7,0xB5), o2(0x8E,0xD7), o2(0xE7,0xB6), o2(0xE7,0xB7),
- o2(0xE7,0xB8), o2(0x93,0x40), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_82 = {
- to_SHIFT_JIS_E9_82_offsets,
- to_SHIFT_JIS_E9_82_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_83_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_83 */
- /* used from to_EUC_JP_E9_83 */
- 13, 0, 13, 13, 13, 13, 13, 13, 13, 13, 1, 13, 13, 13, 2, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 3, 13, 13, 4, 13,
- 13, 5, 6, 13, 7, 13, 13, 13, 8, 13, 13, 13, 13, 9, 13, 13,
- 13, 13, 13, 13, 13, 10, 13, 11, 13, 13, 13, 13, 13, 12, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_83_infos[14] = {
- o2(0x88,0xE8), o2(0x8D,0x78), o2(0x98,0x59), o2(0xE7,0xBC),
- o2(0xFB,0xB6), o2(0x8C,0x53), o2(0xE7,0xB9), o2(0xE7,0xBA),
- o2(0x95,0x94), o2(0x8A,0x73), o2(0x97,0x58), o2(0x8B,0xBD),
- o2(0x93,0x73), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_83 = {
- to_SHIFT_JIS_E9_83_offsets,
- to_SHIFT_JIS_E9_83_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_84_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_84 */
- /* used from to_EUC_JP_E9_84 */
- 8, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 1, 8, 8, 2, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 5, 8, 8,
- 6, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_84_infos[9] = {
- o2(0xE7,0xBD), o2(0xE7,0xBE), o2(0xFB,0xB8), o2(0xE7,0xBF),
- o2(0xFB,0xB9), o2(0x93,0x41), o2(0xE7,0xC1), o2(0xE7,0xC0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_84 = {
- to_SHIFT_JIS_E9_84_offsets,
- to_SHIFT_JIS_E9_84_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_85_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_85 */
- /* used from to_EUC_JP_E9_85 */
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 1, 2, 3, 4, 5, 21,
- 21, 21, 6, 21, 7, 21, 8, 21, 9, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 10, 11, 21, 12, 21, 21, 21, 13, 14, 21, 15, 21, 21, 21,
- 21, 21, 16, 17, 21, 18, 21, 19, 20, 21, 21, 21, 21, 21, 21, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_85_infos[22] = {
- o2(0x93,0xD1), o2(0xE7,0xC2), o2(0x8F,0x55), o2(0x8E,0xDE),
- o2(0x94,0x7A), o2(0x92,0x91), o2(0x8E,0xF0), o2(0x90,0x8C),
- o2(0xE7,0xC3), o2(0xE7,0xC4), o2(0x90,0x7C), o2(0xE7,0xC5),
- o2(0xE7,0xC6), o2(0xE7,0xC7), o2(0x97,0x8F), o2(0x8F,0x56),
- o2(0xE7,0xC9), o2(0xE7,0xC8), o2(0x8D,0x79), o2(0x8D,0x93),
- o2(0x8E,0x5F), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_85 = {
- to_SHIFT_JIS_E9_85_offsets,
- to_SHIFT_JIS_E9_85_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_86_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_86 */
- /* used from to_EUC_JP_E9_86 */
- 18, 18, 0, 18, 18, 18, 18, 1, 18, 2, 18, 3, 18, 4, 18, 18,
- 5, 18, 6, 18, 18, 18, 18, 7, 18, 18, 18, 18, 8, 18, 18, 18,
- 18, 18, 9, 18, 10, 18, 18, 18, 18, 18, 11, 12, 18, 18, 18, 13,
- 18, 18, 18, 18, 14, 15, 18, 18, 16, 18, 17, 18, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_86_infos[19] = {
- o2(0xE7,0xCC), o2(0x8F,0x86), o2(0xE7,0xCB), o2(0xE7,0xCA),
- o2(0x91,0xE7), o2(0x8C,0xED), o2(0x90,0xC1), o2(0x94,0xAE),
- o2(0x8F,0x58), o2(0xE7,0xCD), o2(0x8F,0xDD), o2(0xE7,0xD0),
- o2(0xE7,0xCE), o2(0xE7,0xCF), o2(0xE7,0xD2), o2(0xE7,0xD1),
- o2(0x8F,0xF8), o2(0xE7,0xD3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_86 = {
- to_SHIFT_JIS_E9_86_offsets,
- to_SHIFT_JIS_E9_86_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_87_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_87 */
- /* used from to_EUC_JP_E9_87 */
- 0, 1, 34, 34, 34, 34, 2, 3, 4, 5, 34, 6, 7, 8, 9, 10,
- 11, 12, 34, 34, 34, 34, 13, 14, 15, 34, 16, 17, 18, 19, 20, 21,
- 34, 22, 34, 23, 24, 25, 26, 27, 34, 34, 34, 34, 34, 28, 29, 34,
- 34, 34, 34, 34, 34, 30, 31, 34, 34, 34, 34, 34, 32, 34, 34, 33,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_87_infos[35] = {
- o2(0xE7,0xD4), o2(0xE7,0xD5), o2(0x94,0xCE), o2(0x8D,0xD1),
- o2(0x8E,0xDF), o2(0xE7,0xD6), o2(0xE7,0xD7), o2(0x97,0xA2),
- o2(0x8F,0x64), o2(0x96,0xEC), o2(0x97,0xCA), o2(0xE7,0xD8),
- o2(0x8B,0xE0), o2(0xE7,0xD9), o2(0xFB,0xBB), o2(0x93,0x42),
- o2(0xFB,0xBA), o2(0xE7,0xDC), o2(0x8A,0x98), o2(0x90,0x6A),
- o2(0xFB,0xBC), o2(0xE7,0xDA), o2(0xE7,0xDB), o2(0x92,0xDE),
- o2(0xFB,0xBF), o2(0xFB,0xC0), o2(0x96,0x74), o2(0x8B,0xFA),
- o2(0xFB,0xBD), o2(0xFB,0xBE), o2(0xE7,0xDE), o2(0xE7,0xDF),
- o2(0xE7,0xDD), o2(0xE7,0xE1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_87 = {
- to_SHIFT_JIS_E9_87_offsets,
- to_SHIFT_JIS_E9_87_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_88_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_88 */
- /* used from to_EUC_JP_E9_88 */
- 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 1, 17, 17, 2, 3, 17,
- 4, 5, 17, 17, 6, 7, 17, 17, 17, 17, 17, 17, 17, 17, 8, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 9, 17, 17, 10, 17, 17, 17,
- 17, 17, 17, 17, 11, 17, 17, 12, 17, 13, 14, 17, 15, 17, 17, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_88_infos[18] = {
- o2(0xFB,0xC1), o2(0xFB,0xC3), o2(0x93,0xDD), o2(0x8A,0x62),
- o2(0xFB,0xC2), o2(0xE7,0xE5), o2(0xE7,0xE2), o2(0xE7,0xE4),
- o2(0xE7,0xE0), o2(0xE8,0x6E), o2(0xE7,0xE3), o2(0x97,0xE9),
- o2(0x8C,0xD8), o2(0xFB,0xCA), o2(0xFB,0xC4), o2(0xFB,0xC6),
- o2(0xE7,0xED), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_88 = {
- to_SHIFT_JIS_E9_88_offsets,
- to_SHIFT_JIS_E9_88_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_89_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_89 */
- /* used from to_EUC_JP_E9_89 */
- 0, 22, 22, 22, 1, 2, 22, 22, 3, 4, 22, 5, 22, 22, 6, 22,
- 7, 8, 22, 22, 22, 22, 22, 9, 22, 10, 11, 12, 22, 22, 13, 22,
- 22, 22, 14, 22, 15, 22, 16, 17, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 18, 22, 22, 22, 22, 22, 19, 20, 22, 22, 22, 22, 22, 21, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_89_infos[23] = {
- o2(0xFB,0xC5), o2(0x93,0x53), o2(0xE7,0xE8), o2(0xE7,0xEB),
- o2(0xE7,0xE9), o2(0xE7,0xEE), o2(0xFB,0xC7), o2(0xE7,0xEF),
- o2(0xFB,0xC9), o2(0xE7,0xE7), o2(0xFB,0xC8), o2(0xE7,0xF4),
- o2(0x89,0x94), o2(0xE7,0xE6), o2(0x94,0xAB), o2(0xE7,0xEA),
- o2(0x8F,0xDE), o2(0xFB,0xCB), o2(0x8D,0x7A), o2(0xFB,0xCD),
- o2(0xFB,0xCE), o2(0x96,0x67), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_89 = {
- to_SHIFT_JIS_E9_89_offsets,
- to_SHIFT_JIS_E9_89_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_8A_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_8A */
- /* used from to_EUC_JP_E9_8A */
- 0, 16, 16, 1, 16, 2, 16, 16, 3, 16, 16, 16, 16, 16, 16, 16,
- 16, 4, 16, 5, 16, 6, 7, 16, 8, 16, 9, 10, 11, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 16, 16, 13, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 15, 16, 16, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_8A_infos[17] = {
- o2(0x8B,0xE2), o2(0x8F,0x65), o2(0x93,0xBA), o2(0xFA,0x5F),
- o2(0x91,0x4C), o2(0xE7,0xF2), o2(0xE7,0xEC), o2(0xE7,0xF1),
- o2(0x96,0xC1), o2(0x92,0xB6), o2(0xE7,0xF3), o2(0xE7,0xF0),
- o2(0xFB,0xCC), o2(0x91,0x4B), o2(0xE7,0xF7), o2(0xE7,0xF6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_8A = {
- to_SHIFT_JIS_E9_8A_offsets,
- to_SHIFT_JIS_E9_8A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_8B_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_8B */
- /* used from to_EUC_JP_E9_8B */
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0,
- 1, 21, 2, 3, 21, 4, 21, 5, 21, 6, 21, 21, 21, 21, 21, 21,
- 7, 21, 21, 21, 8, 21, 21, 9, 21, 10, 11, 21, 21, 12, 21, 21,
- 21, 21, 13, 14, 21, 21, 21, 21, 15, 16, 17, 18, 19, 21, 21, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_8B_infos[22] = {
- o2(0xE7,0xF5), o2(0xFB,0xD2), o2(0x96,0x4E), o2(0xFB,0xD6),
- o2(0xFB,0xD4), o2(0xFB,0xD0), o2(0xFB,0xD1), o2(0xFB,0xD5),
- o2(0x8F,0x9B), o2(0xFB,0xCF), o2(0xE7,0xF8), o2(0x95,0xDD),
- o2(0x89,0x73), o2(0x95,0x65), o2(0x92,0x92), o2(0x8B,0x98),
- o2(0xFA,0x65), o2(0xE7,0xFA), o2(0xFB,0xD9), o2(0x8D,0x7C),
- o2(0xFB,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_8B = {
- to_SHIFT_JIS_E9_8B_offsets,
- to_SHIFT_JIS_E9_8B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_8C_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_8C */
- /* used from to_EUC_JP_E9_8C */
- 24, 24, 0, 24, 24, 24, 1, 24, 24, 24, 24, 24, 24, 24, 24, 2,
- 3, 24, 24, 24, 24, 24, 24, 24, 4, 5, 6, 24, 24, 7, 8, 24,
- 9, 10, 11, 12, 24, 13, 14, 24, 15, 24, 24, 16, 17, 24, 18, 19,
- 24, 24, 20, 24, 24, 21, 24, 24, 24, 24, 22, 23, 24, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_8C_infos[25] = {
- o2(0xFB,0xDE), o2(0x8E,0x4B), o2(0xE7,0xF9), o2(0x90,0x8D),
- o2(0x90,0x8E), o2(0xE8,0x40), o2(0xE8,0x42), o2(0xFB,0xDD),
- o2(0xFB,0xDB), o2(0x8F,0xF9), o2(0xFB,0xD8), o2(0xE8,0x41),
- o2(0xE8,0x43), o2(0xFB,0xD7), o2(0x8B,0xD1), o2(0x95,0x64),
- o2(0x8E,0xE0), o2(0x98,0x42), o2(0xE7,0xFC), o2(0x8D,0xF6),
- o2(0x98,0x5E), o2(0xE8,0x45), o2(0xE8,0x44), o2(0xE8,0x46),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_8C = {
- to_SHIFT_JIS_E9_8C_offsets,
- to_SHIFT_JIS_E9_8C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_8D_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_8D */
- /* used from to_EUC_JP_E9_8D */
- 16, 16, 16, 16, 0, 16, 16, 16, 1, 16, 16, 2, 16, 3, 16, 16,
- 16, 16, 16, 16, 4, 16, 5, 6, 16, 16, 16, 7, 8, 16, 16, 16,
- 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 10, 16, 11, 16,
- 12, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 14, 16, 15, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_8D_infos[17] = {
- o2(0xE7,0xFB), o2(0xFA,0x5E), o2(0x93,0xE7), o2(0x93,0x74),
- o2(0x92,0xD5), o2(0xE8,0x4B), o2(0xFB,0xE0), o2(0x92,0x62),
- o2(0xE8,0x47), o2(0xE8,0x48), o2(0x8C,0x4C), o2(0xE8,0x4A),
- o2(0xFB,0xDF), o2(0x8C,0xAE), o2(0xE8,0x49), o2(0x8F,0xDF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_8D = {
- to_SHIFT_JIS_E9_8D_offsets,
- to_SHIFT_JIS_E9_8D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_8E_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_8E */
- /* used from to_EUC_JP_E9_8E */
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 12, 12, 12,
- 12, 12, 12, 12, 1, 12, 2, 3, 12, 12, 4, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 5, 12, 12, 6, 12, 12, 12, 12, 7, 8, 9, 12,
- 10, 12, 12, 12, 12, 12, 12, 12, 12, 11, 12, 12, 12, 12, 12, 12,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_8E_infos[13] = {
- o2(0x8A,0x99), o2(0xE8,0x4F), o2(0x8D,0xBD), o2(0x91,0x99),
- o2(0x92,0xC8), o2(0xFB,0xE1), o2(0x8A,0x5A), o2(0xE8,0x4D),
- o2(0xE8,0x4E), o2(0x92,0xC1), o2(0xE8,0x4C), o2(0xE8,0x50),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_8E = {
- to_SHIFT_JIS_E9_8E_offsets,
- to_SHIFT_JIS_E9_8E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_8F_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_8F */
- /* used from to_EUC_JP_E9_8F */
- 15, 15, 15, 0, 15, 15, 1, 15, 2, 15, 15, 15, 15, 15, 15, 15,
- 3, 4, 15, 15, 15, 15, 5, 6, 7, 15, 15, 15, 15, 8, 9, 15,
- 15, 10, 15, 15, 11, 12, 15, 15, 13, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_8F_infos[16] = {
- o2(0xE8,0x56), o2(0xFB,0xE2), o2(0xE8,0x59), o2(0xE8,0x58),
- o2(0x93,0x4C), o2(0xE8,0x51), o2(0xE8,0x52), o2(0xE8,0x55),
- o2(0xE8,0x57), o2(0xFB,0xE3), o2(0x8B,0xBE), o2(0xE8,0x5A),
- o2(0xE8,0x54), o2(0xE8,0x53), o2(0xFB,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_8F = {
- to_SHIFT_JIS_E9_8F_offsets,
- to_SHIFT_JIS_E9_8F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_90_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_90 */
- /* used from to_EUC_JP_E9_90 */
- 15, 15, 15, 0, 15, 15, 15, 1, 15, 15, 15, 15, 15, 15, 15, 15,
- 2, 15, 15, 3, 4, 15, 15, 15, 5, 6, 7, 15, 15, 15, 15, 15,
- 15, 8, 15, 15, 15, 15, 15, 15, 15, 15, 15, 9, 15, 15, 15, 15,
- 15, 10, 15, 15, 15, 11, 12, 15, 13, 15, 14, 15, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_90_infos[16] = {
- o2(0xE8,0x5E), o2(0xE8,0x5F), o2(0xE8,0x60), o2(0xE8,0x5D),
- o2(0xE8,0x5C), o2(0x8F,0xE0), o2(0x93,0xA8), o2(0xE8,0x5B),
- o2(0xE8,0x64), o2(0xE8,0x62), o2(0xFB,0xE5), o2(0xE8,0x63),
- o2(0xE8,0x61), o2(0x91,0xF6), o2(0xE8,0x65), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_90 = {
- to_SHIFT_JIS_E9_90_offsets,
- to_SHIFT_JIS_E9_90_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_91_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_91 */
- /* used from to_EUC_JP_E9_91 */
- 20, 0, 20, 20, 1, 2, 20, 20, 3, 20, 20, 20, 20, 20, 20, 20,
- 20, 4, 5, 6, 20, 20, 20, 20, 20, 20, 7, 8, 20, 20, 9, 20,
- 10, 20, 11, 20, 20, 20, 20, 20, 20, 20, 12, 20, 20, 20, 20, 20,
- 13, 20, 20, 20, 20, 14, 20, 15, 20, 20, 20, 20, 16, 17, 18, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_91_infos[21] = {
- o2(0xE8,0x66), o2(0xE8,0x68), o2(0xFB,0xE6), o2(0xFB,0xE7),
- o2(0x8A,0xD3), o2(0xE8,0x67), o2(0x96,0xF8), o2(0xE8,0x73),
- o2(0xE8,0x69), o2(0xE8,0x6C), o2(0xE8,0x6A), o2(0xE8,0x6B),
- o2(0xE8,0x6D), o2(0xE8,0x6F), o2(0xE8,0x70), o2(0xE8,0x71),
- o2(0xE8,0x74), o2(0xE8,0x72), o2(0xE8,0x75), o2(0xE8,0x77),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_91 = {
- to_SHIFT_JIS_E9_91_offsets,
- to_SHIFT_JIS_E9_91_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_92_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_92 */
- /* used from to_EUC_JP_E9_92 */
- 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_92_infos[2] = {
- o2(0xE8,0x76), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_92 = {
- to_SHIFT_JIS_E9_92_offsets,
- to_SHIFT_JIS_E9_92_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_95_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_95 */
- /* used from to_EUC_JP_E9_95 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_95_infos[2] = {
- o2(0x92,0xB7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_95 = {
- to_SHIFT_JIS_E9_95_offsets,
- to_SHIFT_JIS_E9_95_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_96_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_96 */
- /* used from to_EUC_JP_E9_96 */
- 0, 28, 1, 2, 28, 28, 28, 3, 28, 4, 5, 6, 28, 28, 28, 7,
- 28, 8, 9, 10, 11, 28, 12, 28, 13, 14, 28, 28, 28, 28, 28, 28,
- 15, 28, 16, 17, 18, 19, 28, 20, 21, 28, 28, 28, 28, 22, 28, 28,
- 28, 28, 23, 28, 28, 28, 28, 28, 28, 24, 28, 25, 26, 28, 27, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_96_infos[29] = {
- o2(0x96,0xE5), o2(0xE8,0x78), o2(0x91,0x4D), o2(0xE8,0x79),
- o2(0x95,0xC2), o2(0xE8,0x7A), o2(0x8A,0x4A), o2(0x89,0x5B),
- o2(0x8A,0xD5), o2(0xFB,0xE8), o2(0x8A,0xD4), o2(0xE8,0x7B),
- o2(0xE8,0x7C), o2(0xE8,0x7D), o2(0xE8,0x7E), o2(0xE8,0x80),
- o2(0x8A,0xD6), o2(0x8A,0x74), o2(0x8D,0x7D), o2(0x94,0xB4),
- o2(0xE8,0x82), o2(0xE8,0x81), o2(0xE8,0x83), o2(0x89,0x7B),
- o2(0xE8,0x86), o2(0xE8,0x85), o2(0xE8,0x84), o2(0xE8,0x87),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_96 = {
- to_SHIFT_JIS_E9_96_offsets,
- to_SHIFT_JIS_E9_96_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_97_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_97 */
- /* used from to_EUC_JP_E9_97 */
- 13, 13, 13, 0, 13, 13, 13, 1, 13, 13, 2, 13, 3, 4, 13, 13,
- 13, 13, 13, 13, 5, 6, 7, 13, 8, 13, 13, 13, 9, 13, 13, 13,
- 13, 10, 11, 13, 13, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_97_infos[14] = {
- o2(0xE8,0x8A), o2(0x88,0xC5), o2(0xE8,0x88), o2(0xE8,0x8C),
- o2(0xE8,0x8B), o2(0xE8,0x8E), o2(0xE8,0x8D), o2(0xE8,0x8F),
- o2(0x93,0xAC), o2(0xE8,0x90), o2(0xE8,0x91), o2(0xE8,0x93),
- o2(0xE8,0x92), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_97 = {
- to_SHIFT_JIS_E9_97_offsets,
- to_SHIFT_JIS_E9_97_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_98_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_98 */
- /* used from to_EUC_JP_E9_98 */
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9,
- 9, 1, 9, 9, 9, 9, 9, 9, 2, 9, 3, 9, 9, 9, 4, 5,
- 9, 9, 6, 9, 9, 9, 9, 9, 9, 9, 9, 7, 9, 9, 9, 8,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_98_infos[10] = {
- o2(0x95,0x8C), o2(0xE8,0x94), o2(0xE8,0x95), o2(0x8D,0xE3),
- o2(0xE8,0x96), o2(0xE8,0x97), o2(0x96,0x68), o2(0x91,0x6A),
- o2(0x88,0xA2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_98 = {
- to_SHIFT_JIS_E9_98_offsets,
- to_SHIFT_JIS_E9_98_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_99_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_99 */
- /* used from to_EUC_JP_E9_99 */
- 0, 29, 1, 29, 2, 29, 29, 29, 29, 29, 29, 3, 4, 5, 29, 6,
- 7, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 8, 9, 10, 11, 12,
- 29, 29, 13, 14, 15, 16, 17, 29, 29, 29, 18, 29, 19, 29, 29, 29,
- 20, 29, 21, 22, 29, 23, 24, 25, 26, 29, 27, 29, 29, 28, 29, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_99_infos[30] = {
- o2(0x91,0xC9), o2(0xE8,0x98), o2(0x95,0x8D), o2(0xE8,0x9B),
- o2(0xE8,0x99), o2(0x8D,0x7E), o2(0xE8,0x9A), o2(0x8C,0xC0),
- o2(0x95,0xC3), o2(0xE8,0x9D), o2(0xE8,0x9F), o2(0xE8,0x9E),
- o2(0xE8,0xA0), o2(0x89,0x40), o2(0x90,0x77), o2(0x8F,0x9C),
- o2(0x8A,0xD7), o2(0xE8,0xA1), o2(0x94,0x86), o2(0xE8,0xA3),
- o2(0x89,0x41), o2(0xE8,0xA2), o2(0x92,0xC2), o2(0x97,0xCB),
- o2(0x93,0xA9), o2(0xE8,0x9C), o2(0x97,0xA4), o2(0x8C,0xAF),
- o2(0x97,0x7A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_99 = {
- to_SHIFT_JIS_E9_99_offsets,
- to_SHIFT_JIS_E9_99_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_9A_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_9A */
- /* used from to_EUC_JP_E9_9A */
- 32, 32, 32, 32, 32, 0, 1, 32, 2, 32, 3, 4, 32, 5, 6, 7,
- 32, 32, 32, 32, 8, 9, 32, 10, 11, 12, 32, 13, 14, 15, 32, 32,
- 16, 32, 32, 17, 32, 32, 32, 18, 19, 32, 20, 32, 32, 32, 32, 21,
- 22, 23, 24, 32, 25, 32, 26, 27, 28, 29, 32, 30, 31, 32, 32, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_9A_infos[33] = {
- o2(0x8B,0xF7), o2(0x97,0xB2), o2(0x8C,0x47), o2(0x91,0xE0),
- o2(0xE4,0x40), o2(0xE8,0xA4), o2(0x8A,0x4B), o2(0x90,0x8F),
- o2(0x8A,0x75), o2(0xE8,0xA6), o2(0xE8,0xA7), o2(0xE8,0xA5),
- o2(0x8C,0x84), o2(0x8D,0xDB), o2(0x8F,0xE1), o2(0xFB,0xEB),
- o2(0x89,0x42), o2(0x97,0xD7), o2(0xE8,0xA9), o2(0xE7,0xAC),
- o2(0xE8,0xA8), o2(0xFB,0xEC), o2(0xE8,0xAC), o2(0xE8,0xAA),
- o2(0xE8,0xAB), o2(0xE8,0xAD), o2(0xE8,0xAE), o2(0x97,0xEA),
- o2(0xE8,0xAF), o2(0xE8,0xB0), o2(0x90,0xC7), o2(0x94,0xB9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_9A = {
- to_SHIFT_JIS_E9_9A_offsets,
- to_SHIFT_JIS_E9_9A_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_9B_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_9B */
- /* used from to_EUC_JP_E9_9B */
- 0, 1, 28, 28, 2, 3, 4, 5, 28, 6, 28, 7, 8, 9, 10, 28,
- 28, 11, 28, 28, 28, 12, 13, 28, 28, 14, 28, 15, 16, 28, 28, 28,
- 28, 28, 17, 18, 28, 28, 28, 28, 19, 28, 20, 21, 28, 28, 28, 28,
- 22, 28, 23, 28, 28, 28, 24, 25, 28, 26, 28, 27, 28, 28, 28, 28,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_9B_infos[29] = {
- o2(0x90,0x9D), o2(0x8A,0xE5), o2(0x97,0x59), o2(0x89,0xEB),
- o2(0x8F,0x57), o2(0x8C,0xD9), o2(0xE8,0xB3), o2(0xE8,0xB2),
- o2(0x8E,0x93), o2(0xE8,0xB4), o2(0xE8,0xB1), o2(0x8E,0x47),
- o2(0xE8,0xB8), o2(0xE5,0xAB), o2(0x99,0xD4), o2(0x90,0x97),
- o2(0xE8,0xB6), o2(0x97,0xA3), o2(0x93,0xEF), o2(0x89,0x4A),
- o2(0x90,0xE1), o2(0x8E,0xB4), o2(0x95,0xB5), o2(0x89,0x5F),
- o2(0x97,0xEB), o2(0x97,0x8B), o2(0xE8,0xB9), o2(0x93,0x64),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_9B = {
- to_SHIFT_JIS_E9_9B_offsets,
- to_SHIFT_JIS_E9_9B_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_9C_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_9C */
- /* used from to_EUC_JP_E9_9C */
- 0, 26, 26, 26, 1, 26, 2, 3, 4, 26, 5, 26, 26, 6, 7, 8,
- 26, 9, 26, 10, 26, 26, 11, 26, 26, 12, 26, 26, 13, 26, 14, 26,
- 26, 26, 26, 26, 15, 26, 26, 16, 26, 26, 17, 26, 26, 26, 26, 26,
- 18, 26, 19, 20, 26, 26, 26, 26, 21, 22, 26, 23, 26, 24, 25, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_9C_infos[27] = {
- o2(0x8E,0xF9), o2(0xE8,0xBA), o2(0xE8,0xBB), o2(0x90,0x6B),
- o2(0xE8,0xBC), o2(0x97,0xEC), o2(0xE8,0xB7), o2(0xE8,0xBE),
- o2(0xE8,0xC0), o2(0xE8,0xBF), o2(0xE8,0xBD), o2(0xE8,0xC1),
- o2(0xE8,0xC2), o2(0x91,0x9A), o2(0x89,0xE0), o2(0xE8,0xC3),
- o2(0x96,0xB6), o2(0xE8,0xC4), o2(0xE8,0xC5), o2(0x98,0x49),
- o2(0xFB,0xED), o2(0x9E,0x50), o2(0xE8,0xC6), o2(0xFB,0xEE),
- o2(0xE8,0xC7), o2(0xE8,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_9C = {
- to_SHIFT_JIS_E9_9C_offsets,
- to_SHIFT_JIS_E9_9C_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_9D_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_9D */
- /* used from to_EUC_JP_E9_9D */
- 29, 29, 0, 1, 2, 29, 3, 29, 4, 5, 29, 29, 29, 6, 29, 7,
- 29, 8, 9, 29, 29, 10, 11, 29, 29, 12, 29, 29, 13, 29, 14, 29,
- 15, 16, 17, 29, 18, 29, 19, 29, 20, 21, 29, 22, 29, 23, 29, 29,
- 29, 24, 29, 29, 25, 29, 29, 29, 29, 26, 27, 29, 28, 29, 29, 29,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_9D_infos[30] = {
- o2(0xE8,0xCC), o2(0xFB,0xEF), o2(0xE8,0xC9), o2(0xE8,0xCA),
- o2(0xE8,0xCB), o2(0xE8,0xCD), o2(0xFB,0xF0), o2(0xFB,0xF1),
- o2(0xFB,0xF2), o2(0x90,0xC2), o2(0xFB,0xF3), o2(0x96,0xF5),
- o2(0x90,0xC3), o2(0xE8,0xCE), o2(0x94,0xF1), o2(0xE8,0xCF),
- o2(0xEA,0x72), o2(0x96,0xCA), o2(0xE8,0xD0), o2(0xE8,0xD1),
- o2(0xE8,0xD2), o2(0x8A,0x76), o2(0xE8,0xD4), o2(0x90,0x78),
- o2(0xE8,0xD5), o2(0x8C,0x43), o2(0xE8,0xD6), o2(0xE8,0xDA),
- o2(0xE8,0xD8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_9D = {
- to_SHIFT_JIS_E9_9D_offsets,
- to_SHIFT_JIS_E9_9D_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_9E_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_9E */
- /* used from to_EUC_JP_E9_9E */
- 18, 0, 18, 18, 1, 2, 3, 18, 18, 18, 18, 4, 18, 5, 18, 6,
- 7, 18, 18, 18, 18, 18, 18, 18, 8, 18, 18, 18, 9, 18, 18, 18,
- 10, 18, 18, 11, 18, 18, 12, 18, 13, 18, 18, 14, 18, 15, 18, 18,
- 18, 18, 18, 16, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_9E_infos[19] = {
- o2(0xE8,0xD9), o2(0x8A,0x93), o2(0xE8,0xD7), o2(0xE8,0xDB),
- o2(0xE8,0xDC), o2(0x88,0xC6), o2(0xE8,0xDD), o2(0xE8,0xDE),
- o2(0x8F,0xE2), o2(0xE8,0xDF), o2(0x8B,0x66), o2(0xE8,0xE2),
- o2(0xE8,0xE1), o2(0xE8,0xE0), o2(0xE6,0x91), o2(0x95,0xDA),
- o2(0xE8,0xE3), o2(0xE8,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_9E = {
- to_SHIFT_JIS_E9_9E_offsets,
- to_SHIFT_JIS_E9_9E_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_9F_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_9F */
- /* used from to_EUC_JP_E9_9F */
- 14, 14, 14, 0, 14, 14, 1, 14, 2, 14, 14, 3, 14, 14, 14, 14,
- 14, 14, 14, 4, 14, 14, 14, 14, 14, 14, 14, 14, 5, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 6, 7, 14,
- 14, 14, 8, 9, 14, 10, 11, 14, 14, 14, 14, 12, 14, 14, 14, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_9F_infos[15] = {
- o2(0xE8,0xE5), o2(0xE8,0xE6), o2(0xE8,0xE7), o2(0xE8,0xE8),
- o2(0x8A,0xD8), o2(0xE8,0xE9), o2(0xE8,0xEA), o2(0x94,0x42),
- o2(0xE8,0xEC), o2(0x89,0xB9), o2(0xE8,0xEF), o2(0xE8,0xEE),
- o2(0x89,0x43), o2(0x8B,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_9F = {
- to_SHIFT_JIS_E9_9F_offsets,
- to_SHIFT_JIS_E9_9F_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A0_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A0 */
- /* used from to_EUC_JP_E9_A0 */
- 25, 0, 1, 2, 25, 3, 4, 25, 5, 25, 25, 25, 6, 25, 25, 7,
- 8, 9, 10, 11, 25, 25, 25, 12, 13, 25, 14, 25, 25, 25, 25, 25,
- 25, 15, 25, 25, 16, 25, 25, 25, 25, 25, 25, 25, 17, 18, 25, 25,
- 25, 25, 25, 25, 19, 25, 25, 20, 21, 25, 25, 22, 23, 24, 25, 25,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A0_infos[26] = {
- o2(0x95,0xC5), o2(0x92,0xB8), o2(0x8D,0xA0), o2(0x8D,0x80),
- o2(0x8F,0x87), o2(0x90,0x7B), o2(0xE8,0xF1), o2(0xE8,0xF0),
- o2(0x97,0x61), o2(0x8A,0xE6), o2(0x94,0xD0), o2(0x93,0xDA),
- o2(0x90,0x9C), o2(0x97,0xCC), o2(0x8C,0x7A), o2(0xE8,0xF4),
- o2(0xE8,0xF3), o2(0x96,0x6A), o2(0x93,0xAA), o2(0x89,0x6F),
- o2(0xE8,0xF5), o2(0xE8,0xF2), o2(0x95,0x70), o2(0x97,0x8A),
- o2(0xE8,0xF6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A0 = {
- to_SHIFT_JIS_E9_A0_offsets,
- to_SHIFT_JIS_E9_A0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A1_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A1 */
- /* used from to_EUC_JP_E9_A1 */
- 20, 20, 20, 20, 20, 20, 0, 20, 20, 20, 20, 1, 2, 3, 4, 5,
- 20, 20, 20, 20, 6, 7, 20, 8, 9, 20, 20, 10, 20, 20, 11, 20,
- 20, 20, 20, 20, 20, 12, 20, 13, 20, 20, 20, 14, 20, 20, 20, 15,
- 16, 17, 20, 18, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A1_infos[21] = {
- o2(0xE8,0xF7), o2(0xE8,0xF9), o2(0x91,0xE8), o2(0x8A,0x7A),
- o2(0x8A,0x7B), o2(0xE8,0xF8), o2(0x8A,0xE7), o2(0x8C,0xB0),
- o2(0xFB,0xF4), o2(0x8A,0xE8), o2(0x93,0x5E), o2(0x97,0xDE),
- o2(0xFB,0xF5), o2(0x8C,0xDA), o2(0xE8,0xFA), o2(0xE8,0xFB),
- o2(0xE8,0xFC), o2(0xE9,0x40), o2(0xE9,0x42), o2(0xE9,0x41),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A1 = {
- to_SHIFT_JIS_E9_A1_offsets,
- to_SHIFT_JIS_E9_A1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A2_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A2 */
- /* used from to_EUC_JP_E9_A2 */
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 1, 5, 5, 5, 5, 2,
- 5, 3, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A2_infos[6] = {
- o2(0x95,0x97), o2(0xE9,0x43), o2(0xE9,0x44), o2(0xE9,0x45),
- o2(0xE9,0x46), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A2 = {
- to_SHIFT_JIS_E9_A2_offsets,
- to_SHIFT_JIS_E9_A2_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A3_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A3 */
- /* used from to_EUC_JP_E9_A3 */
- 17, 17, 17, 0, 1, 17, 2, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 3, 4, 17, 17, 5,
- 17, 17, 6, 17, 17, 17, 17, 17, 17, 7, 17, 8, 17, 9, 10, 11,
- 17, 17, 12, 17, 13, 17, 17, 17, 17, 17, 17, 17, 14, 15, 16, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A3_infos[18] = {
- o2(0xE9,0x48), o2(0xE9,0x47), o2(0xE9,0x49), o2(0x94,0xF2),
- o2(0xE3,0xCA), o2(0x90,0x48), o2(0x8B,0x51), o2(0xE9,0x4A),
- o2(0xE9,0x4B), o2(0x99,0xAA), o2(0x9F,0x5A), o2(0x94,0xD1),
- o2(0x88,0xF9), o2(0x88,0xB9), o2(0x8E,0x94), o2(0x96,0x4F),
- o2(0x8F,0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A3 = {
- to_SHIFT_JIS_E9_A3_offsets,
- to_SHIFT_JIS_E9_A3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A4_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A4 */
- /* used from to_EUC_JP_E9_A4 */
- 21, 21, 21, 0, 21, 1, 21, 21, 21, 2, 3, 21, 4, 21, 21, 21,
- 5, 21, 6, 7, 8, 21, 21, 21, 9, 21, 21, 21, 21, 10, 11, 21,
- 12, 13, 21, 21, 14, 21, 21, 15, 16, 21, 21, 21, 17, 21, 18, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 19, 20, 21,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A4_infos[22] = {
- o2(0xE9,0x4C), o2(0x96,0xDD), o2(0xE9,0x4D), o2(0x97,0x7B),
- o2(0x89,0x61), o2(0x8E,0x60), o2(0xE9,0x4E), o2(0x89,0xEC),
- o2(0xE9,0x4F), o2(0xE9,0x50), o2(0xE9,0x52), o2(0xE9,0x53),
- o2(0xE9,0x55), o2(0xE9,0x51), o2(0xE9,0x54), o2(0xFB,0xF8),
- o2(0x8A,0xD9), o2(0xE9,0x56), o2(0xE9,0x57), o2(0xE9,0x58),
- o2(0xE9,0x59), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A4 = {
- to_SHIFT_JIS_E9_A4_offsets,
- to_SHIFT_JIS_E9_A4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A5_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A5 */
- /* used from to_EUC_JP_E9_A5 */
- 10, 10, 0, 10, 10, 1, 10, 10, 10, 2, 10, 3, 4, 10, 10, 10,
- 5, 6, 7, 10, 10, 8, 10, 9, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A5_infos[11] = {
- o2(0xE9,0x5A), o2(0xE9,0x5C), o2(0xE9,0x5B), o2(0xE9,0x5E),
- o2(0xE9,0x61), o2(0xE9,0x5D), o2(0xE9,0x5F), o2(0xE9,0x60),
- o2(0xE9,0x62), o2(0x8B,0xC0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A5 = {
- to_SHIFT_JIS_E9_A5_offsets,
- to_SHIFT_JIS_E9_A5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A6_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A6 */
- /* used from to_EUC_JP_E9_A6 */
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 0, 1, 2, 3, 13, 13, 13, 13, 4, 13,
- 13, 13, 13, 13, 13, 5, 13, 13, 6, 13, 13, 13, 7, 8, 9, 13,
- 13, 13, 13, 10, 11, 13, 13, 13, 13, 13, 13, 13, 12, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A6_infos[14] = {
- o2(0x8E,0xF1), o2(0xE9,0x63), o2(0xE9,0x64), o2(0x8D,0x81),
- o2(0xFB,0xFA), o2(0xE9,0x65), o2(0x8A,0x5D), o2(0x94,0x6E),
- o2(0xE9,0x66), o2(0xE9,0x67), o2(0x92,0x79), o2(0x93,0xE9),
- o2(0xE9,0x68), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A6 = {
- to_SHIFT_JIS_E9_A6_offsets,
- to_SHIFT_JIS_E9_A6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A7_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A7 */
- /* used from to_EUC_JP_E9_A7 */
- 21, 0, 21, 21, 1, 2, 3, 21, 4, 21, 21, 21, 21, 21, 21, 21,
- 5, 6, 7, 21, 21, 8, 21, 21, 9, 21, 21, 10, 21, 11, 21, 12,
- 21, 21, 13, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 14, 15, 21,
- 21, 16, 17, 21, 21, 21, 21, 21, 18, 21, 21, 19, 21, 21, 21, 20,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A7_infos[22] = {
- o2(0x94,0x9D), o2(0x91,0xCA), o2(0x89,0x77), o2(0x8B,0xEC),
- o2(0x8B,0xED), o2(0x92,0x93), o2(0xE9,0x6D), o2(0x8B,0xEE),
- o2(0x89,0xED), o2(0xE9,0x6C), o2(0xE9,0x6A), o2(0xE9,0x6B),
- o2(0xE9,0x69), o2(0xE9,0x77), o2(0xE9,0x6E), o2(0xE9,0x6F),
- o2(0xE9,0x70), o2(0xE9,0x71), o2(0xE9,0x73), o2(0xE9,0x72),
- o2(0x8F,0x78), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A7 = {
- to_SHIFT_JIS_E9_A7_offsets,
- to_SHIFT_JIS_E9_A7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A8_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A8 */
- /* used from to_EUC_JP_E9_A8 */
- 12, 0, 12, 12, 12, 1, 12, 12, 12, 12, 12, 12, 12, 12, 2, 3,
- 12, 12, 4, 5, 12, 12, 12, 12, 12, 6, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 7, 12, 12, 8, 12, 12, 12, 12,
- 9, 12, 12, 12, 12, 12, 12, 10, 12, 12, 12, 12, 12, 12, 11, 12,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A8_infos[13] = {
- o2(0xE9,0x74), o2(0xE9,0x76), o2(0x8B,0x52), o2(0xE9,0x75),
- o2(0x91,0x9B), o2(0x8C,0xB1), o2(0xE9,0x78), o2(0x91,0xCB),
- o2(0xE9,0x79), o2(0x93,0xAB), o2(0xE9,0x7A), o2(0xE9,0x80),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A8 = {
- to_SHIFT_JIS_E9_A8_offsets,
- to_SHIFT_JIS_E9_A8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_A9_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_A9 */
- /* used from to_EUC_JP_E9_A9 */
- 0, 17, 1, 2, 17, 3, 17, 17, 17, 17, 17, 17, 17, 4, 5, 17,
- 17, 17, 17, 17, 17, 6, 17, 7, 17, 17, 8, 9, 17, 17, 17, 10,
- 17, 17, 11, 17, 12, 13, 17, 17, 17, 14, 15, 16, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_A9_infos[18] = {
- o2(0xE9,0x7D), o2(0xE9,0x7C), o2(0xE9,0x7E), o2(0xE9,0x7B),
- o2(0xE9,0x82), o2(0xFB,0xFB), o2(0xE9,0x81), o2(0xE9,0x84),
- o2(0x8B,0xC1), o2(0xE9,0x83), o2(0xE9,0x85), o2(0xE9,0x86),
- o2(0xE9,0x88), o2(0xE9,0x87), o2(0xE9,0x89), o2(0xE9,0x8B),
- o2(0xE9,0x8A), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_A9 = {
- to_SHIFT_JIS_E9_A9_offsets,
- to_SHIFT_JIS_E9_A9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_AA_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_AA */
- /* used from to_EUC_JP_E9_AA */
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 1, 5, 5,
- 2, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 4, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_AA_infos[6] = {
- o2(0x8D,0x9C), o2(0xE9,0x8C), o2(0xE9,0x8D), o2(0x8A,0x5B),
- o2(0xE9,0x8E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_AA = {
- to_SHIFT_JIS_E9_AA_offsets,
- to_SHIFT_JIS_E9_AA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_AB_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_AB */
- /* used from to_EUC_JP_E9_AB */
- 0, 23, 23, 23, 1, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 2,
- 23, 3, 23, 4, 5, 23, 23, 23, 6, 7, 23, 23, 8, 23, 9, 10,
- 23, 23, 11, 12, 23, 23, 13, 23, 23, 23, 14, 15, 23, 16, 17, 18,
- 23, 19, 23, 23, 20, 23, 23, 21, 23, 23, 23, 22, 23, 23, 23, 23,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_AB_infos[24] = {
- o2(0xE9,0x8F), o2(0x90,0x91), o2(0xE9,0x90), o2(0xE9,0x91),
- o2(0xE9,0x92), o2(0xE9,0x93), o2(0x8D,0x82), o2(0xFB,0xFC),
- o2(0xFC,0x40), o2(0xE9,0x94), o2(0xE9,0x95), o2(0xE9,0x96),
- o2(0xE9,0x97), o2(0xE9,0x98), o2(0x94,0xAF), o2(0xE9,0x9A),
- o2(0x95,0x45), o2(0xE9,0x9B), o2(0xE9,0x99), o2(0xE9,0x9D),
- o2(0xE9,0x9C), o2(0xE9,0x9E), o2(0xE9,0x9F), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_AB = {
- to_SHIFT_JIS_E9_AB_offsets,
- to_SHIFT_JIS_E9_AB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_AC_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_AC */
- /* used from to_EUC_JP_E9_AC */
- 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 1, 17, 2, 17, 17, 17, 17, 3,
- 17, 17, 4, 5, 17, 6, 17, 7, 8, 9, 10, 17, 17, 17, 11, 12,
- 17, 13, 14, 17, 17, 17, 17, 17, 17, 17, 17, 15, 16, 17, 17, 17,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_AC_infos[18] = {
- o2(0xE9,0xA0), o2(0xE9,0xA1), o2(0xE9,0xA2), o2(0xE9,0xA3),
- o2(0xE9,0xA4), o2(0xE9,0xA5), o2(0xE9,0xA6), o2(0xE9,0xA7),
- o2(0xE9,0xA8), o2(0xE9,0xA9), o2(0xE9,0xAA), o2(0xE9,0xAB),
- o2(0xE9,0xAC), o2(0x9F,0x54), o2(0xE9,0xAD), o2(0xE2,0xF6),
- o2(0x8B,0x53), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_AC = {
- to_SHIFT_JIS_E9_AC_offsets,
- to_SHIFT_JIS_E9_AC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_AD_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_AD */
- /* used from to_EUC_JP_E9_AD */
- 16, 0, 1, 2, 3, 4, 16, 16, 16, 16, 16, 16, 16, 5, 6, 7,
- 16, 8, 16, 16, 9, 16, 16, 16, 10, 16, 11, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 12,
- 16, 16, 13, 16, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_AD_infos[17] = {
- o2(0x8A,0x40), o2(0x8D,0xB0), o2(0xE9,0xAF), o2(0xE9,0xAE),
- o2(0x96,0xA3), o2(0xE9,0xB1), o2(0xE9,0xB2), o2(0xE9,0xB0),
- o2(0xE9,0xB3), o2(0x96,0x82), o2(0xE9,0xB4), o2(0x8B,0x9B),
- o2(0x98,0x44), o2(0xFC,0x42), o2(0xE9,0xB5), o2(0xFC,0x41),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_AD = {
- to_SHIFT_JIS_E9_AD_offsets,
- to_SHIFT_JIS_E9_AD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_AE_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_AE */
- /* used from to_EUC_JP_E9_AE */
- 19, 19, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 1, 2,
- 19, 3, 4, 5, 19, 19, 6, 7, 19, 19, 19, 19, 19, 19, 19, 8,
- 9, 19, 19, 19, 19, 19, 19, 19, 10, 19, 11, 12, 19, 13, 14, 19,
- 19, 15, 19, 19, 16, 19, 19, 19, 19, 17, 19, 18, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_AE_infos[20] = {
- o2(0xE9,0xB7), o2(0x88,0xBC), o2(0xFC,0x43), o2(0xE9,0xB8),
- o2(0x95,0xA9), o2(0xE9,0xB6), o2(0xE9,0xB9), o2(0xE9,0xBA),
- o2(0xE9,0xBB), o2(0xE9,0xBC), o2(0xE9,0xBD), o2(0x96,0x8E),
- o2(0x8E,0x4C), o2(0x8D,0xF8), o2(0x91,0x4E), o2(0xFC,0x44),
- o2(0xE9,0xBE), o2(0xE9,0xC1), o2(0xFC,0x45), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_AE = {
- to_SHIFT_JIS_E9_AE_offsets,
- to_SHIFT_JIS_E9_AE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_AF_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_AF */
- /* used from to_EUC_JP_E9_AF */
- 0, 19, 19, 19, 19, 19, 1, 19, 19, 2, 3, 19, 19, 19, 19, 4,
- 19, 5, 6, 19, 7, 19, 8, 19, 19, 19, 19, 9, 19, 19, 19, 19,
- 19, 10, 11, 12, 13, 19, 19, 19, 14, 19, 19, 19, 19, 19, 19, 19,
- 15, 16, 17, 19, 19, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_AF_infos[20] = {
- o2(0xE9,0xBF), o2(0xE9,0xC2), o2(0x8C,0xEF), o2(0xE9,0xC0),
- o2(0xE9,0xC3), o2(0xE9,0xC4), o2(0xE9,0xC5), o2(0xE9,0xC9),
- o2(0x8E,0x49), o2(0x91,0xE2), o2(0xE9,0xCA), o2(0xE9,0xC7),
- o2(0xE9,0xC6), o2(0xE9,0xC8), o2(0x8C,0x7E), o2(0xE9,0xCE),
- o2(0xE9,0xCD), o2(0xE9,0xCC), o2(0x88,0xB1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_AF = {
- to_SHIFT_JIS_E9_AF_offsets,
- to_SHIFT_JIS_E9_AF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B0_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B0 */
- /* used from to_EUC_JP_E9_B0 */
- 0, 26, 26, 26, 1, 26, 2, 26, 3, 4, 5, 26, 6, 7, 26, 26,
- 8, 26, 9, 10, 11, 12, 26, 26, 26, 26, 26, 13, 26, 26, 26, 26,
- 26, 14, 26, 26, 15, 16, 26, 26, 26, 26, 26, 26, 26, 17, 18, 19,
- 20, 26, 21, 26, 26, 26, 26, 26, 26, 22, 23, 24, 26, 26, 25, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B0_infos[27] = {
- o2(0xFC,0x46), o2(0xE9,0xD8), o2(0xE9,0xD4), o2(0xE9,0xD5),
- o2(0xE9,0xD1), o2(0xE9,0xD7), o2(0xE9,0xD3), o2(0x8A,0x82),
- o2(0x98,0x6B), o2(0xE9,0xD6), o2(0xE9,0xD2), o2(0xE9,0xD0),
- o2(0xE9,0xCF), o2(0xE9,0xDA), o2(0xE9,0xDD), o2(0xE9,0xDC),
- o2(0xE9,0xDB), o2(0x95,0x68), o2(0xE9,0xD9), o2(0x88,0xF1),
- o2(0xE9,0xDE), o2(0xE9,0xE0), o2(0x8A,0x8F), o2(0xE9,0xCB),
- o2(0x89,0x56), o2(0xE9,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B0 = {
- to_SHIFT_JIS_E9_B0_offsets,
- to_SHIFT_JIS_E9_B0_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B1_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B1 */
- /* used from to_EUC_JP_E9_B1 */
- 10, 10, 10, 10, 10, 10, 0, 1, 2, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 3, 10, 10, 10, 10, 4, 10, 10, 5, 10, 10, 10, 10, 10,
- 6, 10, 10, 10, 10, 10, 10, 7, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 8, 10, 9, 10, 10, 10, 10, 10, 10, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B1_infos[11] = {
- o2(0xE9,0xE1), o2(0xE9,0xDF), o2(0x92,0x4C), o2(0x96,0x90),
- o2(0x97,0xD8), o2(0xE9,0xE3), o2(0xE9,0xE4), o2(0xE9,0xE5),
- o2(0xE9,0xE6), o2(0xE9,0xE7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B1 = {
- to_SHIFT_JIS_E9_B1_offsets,
- to_SHIFT_JIS_E9_B1_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B3_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B3 */
- /* used from to_EUC_JP_E9_B3 */
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 0, 9, 1, 9, 2, 9, 3, 4, 9, 9, 9,
- 5, 9, 9, 6, 7, 9, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B3_infos[10] = {
- o2(0x92,0xB9), o2(0xE9,0xE8), o2(0x94,0xB5), o2(0xE9,0xED),
- o2(0xE9,0xE9), o2(0xE9,0xEA), o2(0x96,0x50), o2(0x96,0xC2),
- o2(0x93,0xCE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B3 = {
- to_SHIFT_JIS_E9_B3_offsets,
- to_SHIFT_JIS_E9_B3_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B4_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B4 */
- /* used from to_EUC_JP_E9_B4 */
- 19, 19, 19, 0, 19, 19, 1, 2, 3, 4, 19, 19, 19, 19, 5, 19,
- 19, 19, 6, 19, 19, 7, 19, 19, 19, 19, 19, 8, 19, 19, 19, 9,
- 19, 19, 19, 10, 19, 19, 11, 19, 12, 19, 13, 14, 15, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 16, 19, 19, 17, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B4_infos[20] = {
- o2(0xE9,0xEE), o2(0xE9,0xEF), o2(0x93,0xBC), o2(0xE9,0xEC),
- o2(0xE9,0xEB), o2(0x89,0xA8), o2(0xE9,0xF7), o2(0xE9,0xF6),
- o2(0x89,0x95), o2(0xE9,0xF4), o2(0xE9,0xF3), o2(0xE9,0xF1),
- o2(0x8A,0x9B), o2(0xE9,0xF0), o2(0x8E,0xB0), o2(0x89,0xA7),
- o2(0x8D,0x83), o2(0xE9,0xFA), o2(0xE9,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B4 = {
- to_SHIFT_JIS_E9_B4_offsets,
- to_SHIFT_JIS_E9_B4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B5_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B5 */
- /* used from to_EUC_JP_E9_B5 */
- 19, 0, 19, 19, 1, 19, 2, 19, 3, 19, 19, 19, 19, 19, 19, 19,
- 4, 5, 19, 19, 19, 19, 19, 19, 19, 6, 19, 19, 7, 8, 9, 19,
- 10, 11, 19, 19, 12, 19, 19, 19, 19, 19, 19, 13, 14, 19, 19, 15,
- 16, 19, 17, 19, 19, 19, 19, 19, 19, 19, 18, 19, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B5_infos[20] = {
- o2(0xE9,0xF8), o2(0xE9,0xF5), o2(0xE9,0xFB), o2(0xE9,0xFC),
- o2(0xEA,0x44), o2(0xEA,0x43), o2(0xEA,0x45), o2(0x89,0x4C),
- o2(0xEA,0x40), o2(0xEA,0x41), o2(0x8D,0x94), o2(0x96,0xB7),
- o2(0xEA,0x42), o2(0xFC,0x48), o2(0x96,0x51), o2(0xEA,0x4A),
- o2(0xFC,0x47), o2(0xEA,0x46), o2(0xEA,0x4B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B5 = {
- to_SHIFT_JIS_E9_B5_offsets,
- to_SHIFT_JIS_E9_B5_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B6_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B6 */
- /* used from to_EUC_JP_E9_B6 */
- 13, 13, 13, 13, 13, 13, 13, 0, 13, 1, 13, 13, 13, 13, 13, 2,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 3, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 4, 13, 13, 13, 13, 5, 13, 6, 13, 13, 13, 7,
- 13, 13, 8, 13, 9, 13, 13, 13, 10, 13, 11, 12, 13, 13, 13, 13,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B6_infos[14] = {
- o2(0xEA,0x48), o2(0xEA,0x47), o2(0x8C,0x7B), o2(0xEA,0x4C),
- o2(0xEA,0x4D), o2(0xEA,0x4E), o2(0xEA,0x49), o2(0xE9,0xF2),
- o2(0xEA,0x4F), o2(0x92,0xDF), o2(0xEA,0x53), o2(0xEA,0x54),
- o2(0xEA,0x52), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B6 = {
- to_SHIFT_JIS_E9_B6_offsets,
- to_SHIFT_JIS_E9_B6_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B7_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B7 */
- /* used from to_EUC_JP_E9_B7 */
- 15, 0, 1, 15, 2, 15, 3, 15, 15, 15, 15, 15, 15, 15, 15, 4,
- 15, 15, 15, 5, 15, 15, 15, 15, 15, 6, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 7, 15, 15, 15, 15, 15, 15, 8, 15, 9,
- 15, 15, 10, 15, 15, 15, 15, 15, 11, 12, 13, 15, 15, 14, 15, 15,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B7_infos[16] = {
- o2(0xEA,0x51), o2(0xEA,0x57), o2(0xEA,0x50), o2(0xEA,0x55),
- o2(0xEA,0x56), o2(0xEA,0x59), o2(0xEA,0x58), o2(0xEA,0x5B),
- o2(0xEA,0x5C), o2(0xEA,0x5D), o2(0x98,0x68), o2(0xEA,0x5A),
- o2(0x91,0xE9), o2(0x8D,0xEB), o2(0xEA,0x5E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B7 = {
- to_SHIFT_JIS_E9_B7_offsets,
- to_SHIFT_JIS_E9_B7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B8_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B8 */
- /* used from to_EUC_JP_E9_B8 */
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 1, 2, 4, 4, 3, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B8_infos[5] = {
- o2(0xFC,0x4A), o2(0xEA,0x5F), o2(0xEA,0x60), o2(0xEA,0x61),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B8 = {
- to_SHIFT_JIS_E9_B8_offsets,
- to_SHIFT_JIS_E9_B8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_B9_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_B9 */
- /* used from to_EUC_JP_E9_B9 */
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 0, 5, 5, 1, 2, 5, 5, 5, 3, 5, 4,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_B9_infos[6] = {
- o2(0xEA,0x62), o2(0x8C,0xB2), o2(0xEA,0x63), o2(0xEA,0x64),
- o2(0x8E,0xAD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_B9 = {
- to_SHIFT_JIS_E9_B9_offsets,
- to_SHIFT_JIS_E9_B9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_BA_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_BA */
- /* used from to_EUC_JP_E9_BA */
- 23, 0, 23, 23, 23, 23, 23, 23, 1, 23, 23, 2, 3, 23, 23, 23,
- 23, 4, 5, 6, 23, 7, 23, 8, 23, 23, 23, 23, 23, 9, 23, 10,
- 23, 23, 23, 23, 23, 11, 12, 23, 23, 13, 14, 23, 23, 15, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 16, 17, 18, 19, 20, 23, 21, 22,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_BA_infos[24] = {
- o2(0xEA,0x65), o2(0xEA,0x66), o2(0xEA,0x67), o2(0xEA,0x68),
- o2(0xEA,0x6B), o2(0xEA,0x69), o2(0x98,0x5B), o2(0xEA,0x6A),
- o2(0x97,0xED), o2(0xEA,0x6C), o2(0x97,0xD9), o2(0xEA,0x6D),
- o2(0x94,0x9E), o2(0xEA,0x6E), o2(0xEA,0x70), o2(0xEA,0x71),
- o2(0xEA,0x6F), o2(0x8D,0x8D), o2(0x96,0xCB), o2(0x96,0x83),
- o2(0x9B,0xF5), o2(0x9F,0x80), o2(0x96,0x9B), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_BA = {
- to_SHIFT_JIS_E9_BA_offsets,
- to_SHIFT_JIS_E9_BA_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_BB_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_BB */
- /* used from to_EUC_JP_E9_BB */
- 26, 26, 26, 26, 0, 26, 26, 26, 26, 26, 26, 26, 1, 2, 3, 4,
- 5, 6, 7, 26, 8, 26, 26, 26, 9, 10, 26, 11, 12, 13, 14, 26,
- 15, 26, 26, 26, 26, 16, 26, 26, 17, 26, 26, 26, 26, 26, 26, 18,
- 26, 26, 26, 26, 19, 26, 20, 21, 26, 22, 26, 23, 24, 25, 26, 26,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_BB_infos[27] = {
- o2(0x89,0xA9), o2(0xEA,0x73), o2(0x8B,0x6F), o2(0xEA,0x74),
- o2(0xEA,0x75), o2(0xEA,0x76), o2(0xFC,0x4B), o2(0x8D,0x95),
- o2(0xEA,0x77), o2(0xE0,0xD2), o2(0x96,0xD9), o2(0x91,0xE1),
- o2(0xEA,0x78), o2(0xEA,0x7A), o2(0xEA,0x79), o2(0xEA,0x7B),
- o2(0xEA,0x7C), o2(0xEA,0x7D), o2(0xEA,0x7E), o2(0xEA,0x80),
- o2(0xEA,0x81), o2(0xEA,0x82), o2(0xEA,0x83), o2(0xEA,0x84),
- o2(0xEA,0x85), o2(0xEA,0x86), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_BB = {
- to_SHIFT_JIS_E9_BB_offsets,
- to_SHIFT_JIS_E9_BB_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_BC */
- /* used from to_EUC_JP_E9_BC */
- 10, 10, 10, 10, 10, 10, 10, 0, 1, 10, 10, 10, 10, 10, 2, 10,
- 10, 10, 10, 3, 10, 4, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 5, 6, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 10, 10, 9, 10,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_BC_infos[11] = {
- o2(0xEA,0x87), o2(0xEA,0x88), o2(0x93,0x43), o2(0x8C,0xDB),
- o2(0xEA,0x8A), o2(0x91,0x6C), o2(0xEA,0x8B), o2(0xEA,0x8C),
- o2(0x95,0x40), o2(0xEA,0x8D), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_BC = {
- to_SHIFT_JIS_E9_BC_offsets,
- to_SHIFT_JIS_E9_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_BD */
- /* used from to_EUC_JP_E9_BD */
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 1, 18, 18, 2, 3,
- 18, 18, 4, 18, 5, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 6,
- 7, 8, 9, 10, 18, 18, 11, 12, 18, 18, 13, 18, 14, 18, 18, 18,
- 18, 18, 15, 18, 18, 18, 16, 17, 18, 18, 18, 18, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_BD_infos[19] = {
- o2(0xEA,0x8E), o2(0xE2,0x56), o2(0xE6,0xD8), o2(0xE8,0xEB),
- o2(0xEA,0x8F), o2(0xEA,0x90), o2(0xEA,0x92), o2(0xEA,0x93),
- o2(0xEA,0x94), o2(0x97,0xEE), o2(0xEA,0x91), o2(0xEA,0x95),
- o2(0xEA,0x96), o2(0xEA,0x98), o2(0xEA,0x97), o2(0xEA,0x9A),
- o2(0xEA,0x9B), o2(0xEA,0x99), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_BD = {
- to_SHIFT_JIS_E9_BD_offsets,
- to_SHIFT_JIS_E9_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_E9_BE */
- /* used from to_EUC_JP_E9_BE */
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5,
- 5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 2, 3, 5, 5,
- 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_BE_infos[6] = {
- o2(0x97,0xB4), o2(0xEA,0x9C), o2(0xEA,0x9D), o2(0xE2,0x73),
- o2(0xEA,0x9E), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9_BE = {
- to_SHIFT_JIS_E9_BE_offsets,
- to_SHIFT_JIS_E9_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_E9_offsets[64] = {
- /* used from to_SHIFT_JIS_E9 */
- /* used from to_EUC_JP_E9 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 60, 60, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 60, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_E9_infos[61] = {
- &to_SHIFT_JIS_E9_80, &to_SHIFT_JIS_E9_81,
- &to_SHIFT_JIS_E9_82, &to_SHIFT_JIS_E9_83,
- &to_SHIFT_JIS_E9_84, &to_SHIFT_JIS_E9_85,
- &to_SHIFT_JIS_E9_86, &to_SHIFT_JIS_E9_87,
- &to_SHIFT_JIS_E9_88, &to_SHIFT_JIS_E9_89,
- &to_SHIFT_JIS_E9_8A, &to_SHIFT_JIS_E9_8B,
- &to_SHIFT_JIS_E9_8C, &to_SHIFT_JIS_E9_8D,
- &to_SHIFT_JIS_E9_8E, &to_SHIFT_JIS_E9_8F,
- &to_SHIFT_JIS_E9_90, &to_SHIFT_JIS_E9_91,
- &to_SHIFT_JIS_E9_92, &to_SHIFT_JIS_E9_95,
- &to_SHIFT_JIS_E9_96, &to_SHIFT_JIS_E9_97,
- &to_SHIFT_JIS_E9_98, &to_SHIFT_JIS_E9_99,
- &to_SHIFT_JIS_E9_9A, &to_SHIFT_JIS_E9_9B,
- &to_SHIFT_JIS_E9_9C, &to_SHIFT_JIS_E9_9D,
- &to_SHIFT_JIS_E9_9E, &to_SHIFT_JIS_E9_9F,
- &to_SHIFT_JIS_E9_A0, &to_SHIFT_JIS_E9_A1,
- &to_SHIFT_JIS_E9_A2, &to_SHIFT_JIS_E9_A3,
- &to_SHIFT_JIS_E9_A4, &to_SHIFT_JIS_E9_A5,
- &to_SHIFT_JIS_E9_A6, &to_SHIFT_JIS_E9_A7,
- &to_SHIFT_JIS_E9_A8, &to_SHIFT_JIS_E9_A9,
- &to_SHIFT_JIS_E9_AA, &to_SHIFT_JIS_E9_AB,
- &to_SHIFT_JIS_E9_AC, &to_SHIFT_JIS_E9_AD,
- &to_SHIFT_JIS_E9_AE, &to_SHIFT_JIS_E9_AF,
- &to_SHIFT_JIS_E9_B0, &to_SHIFT_JIS_E9_B1,
- &to_SHIFT_JIS_E9_B3, &to_SHIFT_JIS_E9_B4,
- &to_SHIFT_JIS_E9_B5, &to_SHIFT_JIS_E9_B6,
- &to_SHIFT_JIS_E9_B7, &to_SHIFT_JIS_E9_B8,
- &to_SHIFT_JIS_E9_B9, &to_SHIFT_JIS_E9_BA,
- &to_SHIFT_JIS_E9_BB, &to_SHIFT_JIS_E9_BC,
- &to_SHIFT_JIS_E9_BD, &to_SHIFT_JIS_E9_BE,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_E9 = {
- to_SHIFT_JIS_E9_offsets,
- to_SHIFT_JIS_E9_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_A4_offsets[64] = {
- /* used from to_SHIFT_JIS_EF_A4 */
- /* used from to_EUC_JP_EF_A4 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_A4_infos[2] = {
- o2(0xFA,0xE0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF_A4 = {
- to_SHIFT_JIS_EF_A4_offsets,
- to_SHIFT_JIS_EF_A4_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_A7_offsets[64] = {
- /* used from to_SHIFT_JIS_EF_A7 */
- /* used from to_EUC_JP_EF_A7 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_A7_infos[2] = {
- o2(0xFB,0xE9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF_A7 = {
- to_SHIFT_JIS_EF_A7_offsets,
- to_SHIFT_JIS_EF_A7_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_A8_offsets[64] = {
- /* used from to_SHIFT_JIS_EF_A8 */
- /* used from to_EUC_JP_EF_A8 */
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 0, 1,
- 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_A8_infos[33] = {
- o2(0xFA,0x90), o2(0xFA,0x9B), o2(0xFA,0x9C), o2(0xFA,0xB1),
- o2(0xFA,0xD8), o2(0xFA,0xE8), o2(0xFA,0xEA), o2(0xFB,0x58),
- o2(0xFB,0x5E), o2(0xFB,0x75), o2(0xFB,0x7D), o2(0xFB,0x7E),
- o2(0xFB,0x80), o2(0xFB,0x82), o2(0xFB,0x86), o2(0xFB,0x89),
- o2(0xFB,0x92), o2(0xFB,0x9D), o2(0xFB,0x9F), o2(0xFB,0xA0),
- o2(0xFB,0xA9), o2(0xFB,0xB1), o2(0xFB,0xB3), o2(0xFB,0xB4),
- o2(0xFB,0xB7), o2(0xFB,0xD3), o2(0xFB,0xDA), o2(0xFB,0xEA),
- o2(0xFB,0xF6), o2(0xFB,0xF7), o2(0xFB,0xF9), o2(0xFC,0x49),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF_A8 = {
- to_SHIFT_JIS_EF_A8_offsets,
- to_SHIFT_JIS_EF_A8_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_BC_offsets[64] = {
- /* used from to_SHIFT_JIS_EF_BC */
- /* used from to_EUC_JP_EF_BC */
- 61, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 61, 61, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_BC_infos[62] = {
- o2(0x81,0x49), o2(0xFA,0x57), o2(0x81,0x94), o2(0x81,0x90),
- o2(0x81,0x93), o2(0x81,0x95), o2(0xFA,0x56), o2(0x81,0x69),
- o2(0x81,0x6A), o2(0x81,0x96), o2(0x81,0x7B), o2(0x81,0x44),
- o2(0x81,0x5E), o2(0x82,0x4F), o2(0x82,0x50), o2(0x82,0x51),
- o2(0x82,0x52), o2(0x82,0x53), o2(0x82,0x54), o2(0x82,0x55),
- o2(0x82,0x56), o2(0x82,0x57), o2(0x82,0x58), o2(0x81,0x46),
- o2(0x81,0x47), o2(0x81,0x83), o2(0x81,0x81), o2(0x81,0x84),
- o2(0x81,0x48), o2(0x81,0x97), o2(0x82,0x60), o2(0x82,0x61),
- o2(0x82,0x62), o2(0x82,0x63), o2(0x82,0x64), o2(0x82,0x65),
- o2(0x82,0x66), o2(0x82,0x67), o2(0x82,0x68), o2(0x82,0x69),
- o2(0x82,0x6A), o2(0x82,0x6B), o2(0x82,0x6C), o2(0x82,0x6D),
- o2(0x82,0x6E), o2(0x82,0x6F), o2(0x82,0x70), o2(0x82,0x71),
- o2(0x82,0x72), o2(0x82,0x73), o2(0x82,0x74), o2(0x82,0x75),
- o2(0x82,0x76), o2(0x82,0x77), o2(0x82,0x78), o2(0x82,0x79),
- o2(0x81,0x6D), o2(0x81,0x5F), o2(0x81,0x6E), o2(0x81,0x4F),
- o2(0x81,0x51), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF_BC = {
- to_SHIFT_JIS_EF_BC_offsets,
- to_SHIFT_JIS_EF_BC_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_BD_offsets[64] = {
- /* used from to_SHIFT_JIS_EF_BD */
- /* used from to_EUC_JP_EF_BD */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 61, 61,
- 61, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_BD_infos[62] = {
- o2(0x81,0x4D), o2(0x82,0x81), o2(0x82,0x82), o2(0x82,0x83),
- o2(0x82,0x84), o2(0x82,0x85), o2(0x82,0x86), o2(0x82,0x87),
- o2(0x82,0x88), o2(0x82,0x89), o2(0x82,0x8A), o2(0x82,0x8B),
- o2(0x82,0x8C), o2(0x82,0x8D), o2(0x82,0x8E), o2(0x82,0x8F),
- o2(0x82,0x90), o2(0x82,0x91), o2(0x82,0x92), o2(0x82,0x93),
- o2(0x82,0x94), o2(0x82,0x95), o2(0x82,0x96), o2(0x82,0x97),
- o2(0x82,0x98), o2(0x82,0x99), o2(0x82,0x9A), o2(0x81,0x6F),
- o2(0x81,0x62), o2(0x81,0x70), o1(0xA1), o1(0xA2),
- o1(0xA3), o1(0xA4), o1(0xA5), o1(0xA6),
- o1(0xA7), o1(0xA8), o1(0xA9), o1(0xAA),
- o1(0xAB), o1(0xAC), o1(0xAD), o1(0xAE),
- o1(0xAF), o1(0xB0), o1(0xB1), o1(0xB2),
- o1(0xB3), o1(0xB4), o1(0xB5), o1(0xB6),
- o1(0xB7), o1(0xB8), o1(0xB9), o1(0xBA),
- o1(0xBB), o1(0xBC), o1(0xBD), o1(0xBE),
- o1(0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF_BD = {
- to_SHIFT_JIS_EF_BD_offsets,
- to_SHIFT_JIS_EF_BD_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_BE_offsets[64] = {
- /* used from to_SHIFT_JIS_EF_BE */
- /* used from to_EUC_JP_EF_BE */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_BE_infos[33] = {
- o1(0xC0), o1(0xC1), o1(0xC2), o1(0xC3),
- o1(0xC4), o1(0xC5), o1(0xC6), o1(0xC7),
- o1(0xC8), o1(0xC9), o1(0xCA), o1(0xCB),
- o1(0xCC), o1(0xCD), o1(0xCE), o1(0xCF),
- o1(0xD0), o1(0xD1), o1(0xD2), o1(0xD3),
- o1(0xD4), o1(0xD5), o1(0xD6), o1(0xD7),
- o1(0xD8), o1(0xD9), o1(0xDA), o1(0xDB),
- o1(0xDC), o1(0xDD), o1(0xDE), o1(0xDF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF_BE = {
- to_SHIFT_JIS_EF_BE_offsets,
- to_SHIFT_JIS_EF_BE_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_EF_offsets[64] = {
- /* used from to_SHIFT_JIS_EF */
- /* used from to_EUC_JP_EF */
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 0, 6, 6, 1, 2, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 4, 5, 6,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_EF_infos[7] = {
- &to_SHIFT_JIS_EF_A4, &to_SHIFT_JIS_EF_A7,
- &to_SHIFT_JIS_EF_A8, &to_SHIFT_JIS_EF_BC,
- &to_SHIFT_JIS_EF_BD, &to_SHIFT_JIS_EF_BE,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS_EF = {
- to_SHIFT_JIS_EF_offsets,
- to_SHIFT_JIS_EF_infos
-};
-
-static const unsigned char
-to_SHIFT_JIS_offsets[256] = {
- /* used from to_SHIFT_JIS */
- /* used from to_EUC_JP */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 1, 2, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 4,
- 5, 6, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 7, 8, 9, 10, 11, 12, 13, 14, 16, 16, 16, 16, 16, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-};
-static const struct byte_lookup* const
-to_SHIFT_JIS_infos[17] = {
- NOMAP, &to_SHIFT_JIS_C2, &to_SHIFT_JIS_C3, &to_SHIFT_JIS_CE,
- &to_SHIFT_JIS_CF, &to_SHIFT_JIS_D0, &to_SHIFT_JIS_D1, &to_SHIFT_JIS_E2,
- &to_SHIFT_JIS_E3, &to_SHIFT_JIS_E4, &to_SHIFT_JIS_E5, &to_SHIFT_JIS_E6,
- &to_SHIFT_JIS_E7, &to_SHIFT_JIS_E8, &to_SHIFT_JIS_E9, &to_SHIFT_JIS_EF,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_SHIFT_JIS = {
- to_SHIFT_JIS_offsets,
- to_SHIFT_JIS_infos
-};
-static rb_transcoder
-rb_to_SHIFT_JIS = {
- "UTF-8", "SHIFT_JIS", &to_SHIFT_JIS, 2, 1,
- NULL, NULL,
-};
-
-static const unsigned char
-from_EUC_JP_8E_offsets[256] = {
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-};
-static const struct byte_lookup* const
-from_EUC_JP_8E_infos[64] = {
- o3(0xEF,0xBD,0xA1), o3(0xEF,0xBD,0xA2),
- o3(0xEF,0xBD,0xA3), o3(0xEF,0xBD,0xA4),
- o3(0xEF,0xBD,0xA5), o3(0xEF,0xBD,0xA6),
- o3(0xEF,0xBD,0xA7), o3(0xEF,0xBD,0xA8),
- o3(0xEF,0xBD,0xA9), o3(0xEF,0xBD,0xAA),
- o3(0xEF,0xBD,0xAB), o3(0xEF,0xBD,0xAC),
- o3(0xEF,0xBD,0xAD), o3(0xEF,0xBD,0xAE),
- o3(0xEF,0xBD,0xAF), o3(0xEF,0xBD,0xB0),
- o3(0xEF,0xBD,0xB1), o3(0xEF,0xBD,0xB2),
- o3(0xEF,0xBD,0xB3), o3(0xEF,0xBD,0xB4),
- o3(0xEF,0xBD,0xB5), o3(0xEF,0xBD,0xB6),
- o3(0xEF,0xBD,0xB7), o3(0xEF,0xBD,0xB8),
- o3(0xEF,0xBD,0xB9), o3(0xEF,0xBD,0xBA),
- o3(0xEF,0xBD,0xBB), o3(0xEF,0xBD,0xBC),
- o3(0xEF,0xBD,0xBD), o3(0xEF,0xBD,0xBE),
- o3(0xEF,0xBD,0xBF), o3(0xEF,0xBE,0x80),
- o3(0xEF,0xBE,0x81), o3(0xEF,0xBE,0x82),
- o3(0xEF,0xBE,0x83), o3(0xEF,0xBE,0x84),
- o3(0xEF,0xBE,0x85), o3(0xEF,0xBE,0x86),
- o3(0xEF,0xBE,0x87), o3(0xEF,0xBE,0x88),
- o3(0xEF,0xBE,0x89), o3(0xEF,0xBE,0x8A),
- o3(0xEF,0xBE,0x8B), o3(0xEF,0xBE,0x8C),
- o3(0xEF,0xBE,0x8D), o3(0xEF,0xBE,0x8E),
- o3(0xEF,0xBE,0x8F), o3(0xEF,0xBE,0x90),
- o3(0xEF,0xBE,0x91), o3(0xEF,0xBE,0x92),
- o3(0xEF,0xBE,0x93), o3(0xEF,0xBE,0x94),
- o3(0xEF,0xBE,0x95), o3(0xEF,0xBE,0x96),
- o3(0xEF,0xBE,0x97), o3(0xEF,0xBE,0x98),
- o3(0xEF,0xBE,0x99), o3(0xEF,0xBE,0x9A),
- o3(0xEF,0xBE,0x9B), o3(0xEF,0xBE,0x9C),
- o3(0xEF,0xBE,0x9D), o3(0xEF,0xBE,0x9E),
- o3(0xEF,0xBE,0x9F), UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_8E = {
- from_EUC_JP_8E_offsets,
- from_EUC_JP_8E_infos
-};
-
-static const unsigned char
-from_EUC_JP_A1_offsets[256] = {
- /* used from from_EUC_JP_A1 */
- /* used from from_EUC_JP_B0 */
- /* used from from_EUC_JP_B1 */
- /* used from from_EUC_JP_B2 */
- /* used from from_EUC_JP_B3 */
- /* used from from_EUC_JP_B4 */
- /* used from from_EUC_JP_B5 */
- /* used from from_EUC_JP_B6 */
- /* used from from_EUC_JP_B7 */
- /* used from from_EUC_JP_B8 */
- /* used from from_EUC_JP_B9 */
- /* used from from_EUC_JP_BA */
- /* used from from_EUC_JP_BB */
- /* used from from_EUC_JP_BC */
- /* used from from_EUC_JP_BD */
- /* used from from_EUC_JP_BE */
- /* used from from_EUC_JP_BF */
- /* used from from_EUC_JP_C0 */
- /* used from from_EUC_JP_C1 */
- /* used from from_EUC_JP_C2 */
- /* used from from_EUC_JP_C3 */
- /* used from from_EUC_JP_C4 */
- /* used from from_EUC_JP_C5 */
- /* used from from_EUC_JP_C6 */
- /* used from from_EUC_JP_C7 */
- /* used from from_EUC_JP_C8 */
- /* used from from_EUC_JP_C9 */
- /* used from from_EUC_JP_CA */
- /* used from from_EUC_JP_CB */
- /* used from from_EUC_JP_CC */
- /* used from from_EUC_JP_CD */
- /* used from from_EUC_JP_CE */
- /* used from from_EUC_JP_D0 */
- /* used from from_EUC_JP_D1 */
- /* used from from_EUC_JP_D2 */
- /* used from from_EUC_JP_D3 */
- /* used from from_EUC_JP_D4 */
- /* used from from_EUC_JP_D5 */
- /* used from from_EUC_JP_D6 */
- /* used from from_EUC_JP_D7 */
- /* used from from_EUC_JP_D8 */
- /* used from from_EUC_JP_D9 */
- /* used from from_EUC_JP_DA */
- /* used from from_EUC_JP_DB */
- /* used from from_EUC_JP_DC */
- /* used from from_EUC_JP_DD */
- /* used from from_EUC_JP_DE */
- /* used from from_EUC_JP_DF */
- /* used from from_EUC_JP_E0 */
- /* used from from_EUC_JP_E1 */
- /* used from from_EUC_JP_E2 */
- /* used from from_EUC_JP_E3 */
- /* used from from_EUC_JP_E4 */
- /* used from from_EUC_JP_E5 */
- /* used from from_EUC_JP_E6 */
- /* used from from_EUC_JP_E7 */
- /* used from from_EUC_JP_E8 */
- /* used from from_EUC_JP_E9 */
- /* used from from_EUC_JP_EA */
- /* used from from_EUC_JP_EB */
- /* used from from_EUC_JP_EC */
- /* used from from_EUC_JP_ED */
- /* used from from_EUC_JP_EE */
- /* used from from_EUC_JP_EF */
- /* used from from_EUC_JP_F0 */
- /* used from from_EUC_JP_F1 */
- /* used from from_EUC_JP_F2 */
- /* used from from_EUC_JP_F3 */
- /* used from from_EUC_JP_F9 */
- /* used from from_EUC_JP_FA */
- /* used from from_EUC_JP_FB */
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
- 94, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A1_infos[95] = {
- o3(0xE3,0x80,0x80), o3(0xE3,0x80,0x81),
- o3(0xE3,0x80,0x82), o3(0xEF,0xBC,0x8C),
- o3(0xEF,0xBC,0x8E), o3(0xE3,0x83,0xBB),
- o3(0xEF,0xBC,0x9A), o3(0xEF,0xBC,0x9B),
- o3(0xEF,0xBC,0x9F), o3(0xEF,0xBC,0x81),
- o3(0xE3,0x82,0x9B), o3(0xE3,0x82,0x9C),
- o2(0xC2,0xB4), o3(0xEF,0xBD,0x80),
- o2(0xC2,0xA8), o3(0xEF,0xBC,0xBE),
- o3(0xEF,0xBF,0xA3), o3(0xEF,0xBC,0xBF),
- o3(0xE3,0x83,0xBD), o3(0xE3,0x83,0xBE),
- o3(0xE3,0x82,0x9D), o3(0xE3,0x82,0x9E),
- o3(0xE3,0x80,0x83), o3(0xE4,0xBB,0x9D),
- o3(0xE3,0x80,0x85), o3(0xE3,0x80,0x86),
- o3(0xE3,0x80,0x87), o3(0xE3,0x83,0xBC),
- o3(0xE2,0x80,0x95), o3(0xE2,0x80,0x90),
- o3(0xEF,0xBC,0x8F), o3(0xEF,0xBC,0xBC),
- o3(0xEF,0xBD,0x9E), o3(0xE2,0x88,0xA5),
- o3(0xEF,0xBD,0x9C), o3(0xE2,0x80,0xA6),
- o3(0xE2,0x80,0xA5), o3(0xE2,0x80,0x98),
- o3(0xE2,0x80,0x99), o3(0xE2,0x80,0x9C),
- o3(0xE2,0x80,0x9D), o3(0xEF,0xBC,0x88),
- o3(0xEF,0xBC,0x89), o3(0xE3,0x80,0x94),
- o3(0xE3,0x80,0x95), o3(0xEF,0xBC,0xBB),
- o3(0xEF,0xBC,0xBD), o3(0xEF,0xBD,0x9B),
- o3(0xEF,0xBD,0x9D), o3(0xE3,0x80,0x88),
- o3(0xE3,0x80,0x89), o3(0xE3,0x80,0x8A),
- o3(0xE3,0x80,0x8B), o3(0xE3,0x80,0x8C),
- o3(0xE3,0x80,0x8D), o3(0xE3,0x80,0x8E),
- o3(0xE3,0x80,0x8F), o3(0xE3,0x80,0x90),
- o3(0xE3,0x80,0x91), o3(0xEF,0xBC,0x8B),
- o3(0xEF,0xBC,0x8D), o2(0xC2,0xB1),
- o2(0xC3,0x97), o2(0xC3,0xB7),
- o3(0xEF,0xBC,0x9D), o3(0xE2,0x89,0xA0),
- o3(0xEF,0xBC,0x9C), o3(0xEF,0xBC,0x9E),
- o3(0xE2,0x89,0xA6), o3(0xE2,0x89,0xA7),
- o3(0xE2,0x88,0x9E), o3(0xE2,0x88,0xB4),
- o3(0xE2,0x99,0x82), o3(0xE2,0x99,0x80),
- o2(0xC2,0xB0), o3(0xE2,0x80,0xB2),
- o3(0xE2,0x80,0xB3), o3(0xE2,0x84,0x83),
- o3(0xEF,0xBF,0xA5), o3(0xEF,0xBC,0x84),
- o3(0xEF,0xBF,0xA0), o3(0xEF,0xBF,0xA1),
- o3(0xEF,0xBC,0x85), o3(0xEF,0xBC,0x83),
- o3(0xEF,0xBC,0x86), o3(0xEF,0xBC,0x8A),
- o3(0xEF,0xBC,0xA0), o2(0xC2,0xA7),
- o3(0xE2,0x98,0x86), o3(0xE2,0x98,0x85),
- o3(0xE2,0x97,0x8B), o3(0xE2,0x97,0x8F),
- o3(0xE2,0x97,0x8E), o3(0xE2,0x97,0x87),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A1 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_A1_infos
-};
-
-static const unsigned char
-from_EUC_JP_A2_offsets[256] = {
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 14, 15, 16, 17, 18, 19,
- 20, 21, 53, 53, 53, 53, 53, 53, 53, 53, 22, 23, 24, 25, 26, 27,
- 28, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 53, 53, 53, 53, 53,
- 53, 53, 44, 45, 46, 47, 48, 49, 50, 51, 53, 53, 53, 53, 52, 53,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A2_infos[54] = {
- o3(0xE2,0x97,0x86), o3(0xE2,0x96,0xA1),
- o3(0xE2,0x96,0xA0), o3(0xE2,0x96,0xB3),
- o3(0xE2,0x96,0xB2), o3(0xE2,0x96,0xBD),
- o3(0xE2,0x96,0xBC), o3(0xE2,0x80,0xBB),
- o3(0xE3,0x80,0x92), o3(0xE2,0x86,0x92),
- o3(0xE2,0x86,0x90), o3(0xE2,0x86,0x91),
- o3(0xE2,0x86,0x93), o3(0xE3,0x80,0x93),
- o3(0xE2,0x88,0x88), o3(0xE2,0x88,0x8B),
- o3(0xE2,0x8A,0x86), o3(0xE2,0x8A,0x87),
- o3(0xE2,0x8A,0x82), o3(0xE2,0x8A,0x83),
- o3(0xE2,0x88,0xAA), o3(0xE2,0x88,0xA9),
- o3(0xE2,0x88,0xA7), o3(0xE2,0x88,0xA8),
- o3(0xEF,0xBF,0xA2), o3(0xE2,0x87,0x92),
- o3(0xE2,0x87,0x94), o3(0xE2,0x88,0x80),
- o3(0xE2,0x88,0x83), o3(0xE2,0x88,0xA0),
- o3(0xE2,0x8A,0xA5), o3(0xE2,0x8C,0x92),
- o3(0xE2,0x88,0x82), o3(0xE2,0x88,0x87),
- o3(0xE2,0x89,0xA1), o3(0xE2,0x89,0x92),
- o3(0xE2,0x89,0xAA), o3(0xE2,0x89,0xAB),
- o3(0xE2,0x88,0x9A), o3(0xE2,0x88,0xBD),
- o3(0xE2,0x88,0x9D), o3(0xE2,0x88,0xB5),
- o3(0xE2,0x88,0xAB), o3(0xE2,0x88,0xAC),
- o3(0xE2,0x84,0xAB), o3(0xE2,0x80,0xB0),
- o3(0xE2,0x99,0xAF), o3(0xE2,0x99,0xAD),
- o3(0xE2,0x99,0xAA), o3(0xE2,0x80,0xA0),
- o3(0xE2,0x80,0xA1), o2(0xC2,0xB6),
- o3(0xE2,0x97,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A2 = {
- from_EUC_JP_A2_offsets,
- from_EUC_JP_A2_infos
-};
-
-static const unsigned char
-from_EUC_JP_A3_offsets[256] = {
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 62, 62, 62, 62, 62, 62,
- 62, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 62, 62, 62, 62, 62,
- 62, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 62, 62, 62, 62,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A3_infos[63] = {
- o3(0xEF,0xBC,0x90), o3(0xEF,0xBC,0x91),
- o3(0xEF,0xBC,0x92), o3(0xEF,0xBC,0x93),
- o3(0xEF,0xBC,0x94), o3(0xEF,0xBC,0x95),
- o3(0xEF,0xBC,0x96), o3(0xEF,0xBC,0x97),
- o3(0xEF,0xBC,0x98), o3(0xEF,0xBC,0x99),
- o3(0xEF,0xBC,0xA1), o3(0xEF,0xBC,0xA2),
- o3(0xEF,0xBC,0xA3), o3(0xEF,0xBC,0xA4),
- o3(0xEF,0xBC,0xA5), o3(0xEF,0xBC,0xA6),
- o3(0xEF,0xBC,0xA7), o3(0xEF,0xBC,0xA8),
- o3(0xEF,0xBC,0xA9), o3(0xEF,0xBC,0xAA),
- o3(0xEF,0xBC,0xAB), o3(0xEF,0xBC,0xAC),
- o3(0xEF,0xBC,0xAD), o3(0xEF,0xBC,0xAE),
- o3(0xEF,0xBC,0xAF), o3(0xEF,0xBC,0xB0),
- o3(0xEF,0xBC,0xB1), o3(0xEF,0xBC,0xB2),
- o3(0xEF,0xBC,0xB3), o3(0xEF,0xBC,0xB4),
- o3(0xEF,0xBC,0xB5), o3(0xEF,0xBC,0xB6),
- o3(0xEF,0xBC,0xB7), o3(0xEF,0xBC,0xB8),
- o3(0xEF,0xBC,0xB9), o3(0xEF,0xBC,0xBA),
- o3(0xEF,0xBD,0x81), o3(0xEF,0xBD,0x82),
- o3(0xEF,0xBD,0x83), o3(0xEF,0xBD,0x84),
- o3(0xEF,0xBD,0x85), o3(0xEF,0xBD,0x86),
- o3(0xEF,0xBD,0x87), o3(0xEF,0xBD,0x88),
- o3(0xEF,0xBD,0x89), o3(0xEF,0xBD,0x8A),
- o3(0xEF,0xBD,0x8B), o3(0xEF,0xBD,0x8C),
- o3(0xEF,0xBD,0x8D), o3(0xEF,0xBD,0x8E),
- o3(0xEF,0xBD,0x8F), o3(0xEF,0xBD,0x90),
- o3(0xEF,0xBD,0x91), o3(0xEF,0xBD,0x92),
- o3(0xEF,0xBD,0x93), o3(0xEF,0xBD,0x94),
- o3(0xEF,0xBD,0x95), o3(0xEF,0xBD,0x96),
- o3(0xEF,0xBD,0x97), o3(0xEF,0xBD,0x98),
- o3(0xEF,0xBD,0x99), o3(0xEF,0xBD,0x9A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A3 = {
- from_EUC_JP_A3_offsets,
- from_EUC_JP_A3_infos
-};
-
-static const unsigned char
-from_EUC_JP_A4_offsets[256] = {
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A4_infos[84] = {
- o3(0xE3,0x81,0x81), o3(0xE3,0x81,0x82),
- o3(0xE3,0x81,0x83), o3(0xE3,0x81,0x84),
- o3(0xE3,0x81,0x85), o3(0xE3,0x81,0x86),
- o3(0xE3,0x81,0x87), o3(0xE3,0x81,0x88),
- o3(0xE3,0x81,0x89), o3(0xE3,0x81,0x8A),
- o3(0xE3,0x81,0x8B), o3(0xE3,0x81,0x8C),
- o3(0xE3,0x81,0x8D), o3(0xE3,0x81,0x8E),
- o3(0xE3,0x81,0x8F), o3(0xE3,0x81,0x90),
- o3(0xE3,0x81,0x91), o3(0xE3,0x81,0x92),
- o3(0xE3,0x81,0x93), o3(0xE3,0x81,0x94),
- o3(0xE3,0x81,0x95), o3(0xE3,0x81,0x96),
- o3(0xE3,0x81,0x97), o3(0xE3,0x81,0x98),
- o3(0xE3,0x81,0x99), o3(0xE3,0x81,0x9A),
- o3(0xE3,0x81,0x9B), o3(0xE3,0x81,0x9C),
- o3(0xE3,0x81,0x9D), o3(0xE3,0x81,0x9E),
- o3(0xE3,0x81,0x9F), o3(0xE3,0x81,0xA0),
- o3(0xE3,0x81,0xA1), o3(0xE3,0x81,0xA2),
- o3(0xE3,0x81,0xA3), o3(0xE3,0x81,0xA4),
- o3(0xE3,0x81,0xA5), o3(0xE3,0x81,0xA6),
- o3(0xE3,0x81,0xA7), o3(0xE3,0x81,0xA8),
- o3(0xE3,0x81,0xA9), o3(0xE3,0x81,0xAA),
- o3(0xE3,0x81,0xAB), o3(0xE3,0x81,0xAC),
- o3(0xE3,0x81,0xAD), o3(0xE3,0x81,0xAE),
- o3(0xE3,0x81,0xAF), o3(0xE3,0x81,0xB0),
- o3(0xE3,0x81,0xB1), o3(0xE3,0x81,0xB2),
- o3(0xE3,0x81,0xB3), o3(0xE3,0x81,0xB4),
- o3(0xE3,0x81,0xB5), o3(0xE3,0x81,0xB6),
- o3(0xE3,0x81,0xB7), o3(0xE3,0x81,0xB8),
- o3(0xE3,0x81,0xB9), o3(0xE3,0x81,0xBA),
- o3(0xE3,0x81,0xBB), o3(0xE3,0x81,0xBC),
- o3(0xE3,0x81,0xBD), o3(0xE3,0x81,0xBE),
- o3(0xE3,0x81,0xBF), o3(0xE3,0x82,0x80),
- o3(0xE3,0x82,0x81), o3(0xE3,0x82,0x82),
- o3(0xE3,0x82,0x83), o3(0xE3,0x82,0x84),
- o3(0xE3,0x82,0x85), o3(0xE3,0x82,0x86),
- o3(0xE3,0x82,0x87), o3(0xE3,0x82,0x88),
- o3(0xE3,0x82,0x89), o3(0xE3,0x82,0x8A),
- o3(0xE3,0x82,0x8B), o3(0xE3,0x82,0x8C),
- o3(0xE3,0x82,0x8D), o3(0xE3,0x82,0x8E),
- o3(0xE3,0x82,0x8F), o3(0xE3,0x82,0x90),
- o3(0xE3,0x82,0x91), o3(0xE3,0x82,0x92),
- o3(0xE3,0x82,0x93), UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A4 = {
- from_EUC_JP_A4_offsets,
- from_EUC_JP_A4_infos
-};
-
-static const unsigned char
-from_EUC_JP_A5_offsets[256] = {
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 86, 86, 86, 86, 86, 86, 86, 86,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A5_infos[87] = {
- o3(0xE3,0x82,0xA1), o3(0xE3,0x82,0xA2),
- o3(0xE3,0x82,0xA3), o3(0xE3,0x82,0xA4),
- o3(0xE3,0x82,0xA5), o3(0xE3,0x82,0xA6),
- o3(0xE3,0x82,0xA7), o3(0xE3,0x82,0xA8),
- o3(0xE3,0x82,0xA9), o3(0xE3,0x82,0xAA),
- o3(0xE3,0x82,0xAB), o3(0xE3,0x82,0xAC),
- o3(0xE3,0x82,0xAD), o3(0xE3,0x82,0xAE),
- o3(0xE3,0x82,0xAF), o3(0xE3,0x82,0xB0),
- o3(0xE3,0x82,0xB1), o3(0xE3,0x82,0xB2),
- o3(0xE3,0x82,0xB3), o3(0xE3,0x82,0xB4),
- o3(0xE3,0x82,0xB5), o3(0xE3,0x82,0xB6),
- o3(0xE3,0x82,0xB7), o3(0xE3,0x82,0xB8),
- o3(0xE3,0x82,0xB9), o3(0xE3,0x82,0xBA),
- o3(0xE3,0x82,0xBB), o3(0xE3,0x82,0xBC),
- o3(0xE3,0x82,0xBD), o3(0xE3,0x82,0xBE),
- o3(0xE3,0x82,0xBF), o3(0xE3,0x83,0x80),
- o3(0xE3,0x83,0x81), o3(0xE3,0x83,0x82),
- o3(0xE3,0x83,0x83), o3(0xE3,0x83,0x84),
- o3(0xE3,0x83,0x85), o3(0xE3,0x83,0x86),
- o3(0xE3,0x83,0x87), o3(0xE3,0x83,0x88),
- o3(0xE3,0x83,0x89), o3(0xE3,0x83,0x8A),
- o3(0xE3,0x83,0x8B), o3(0xE3,0x83,0x8C),
- o3(0xE3,0x83,0x8D), o3(0xE3,0x83,0x8E),
- o3(0xE3,0x83,0x8F), o3(0xE3,0x83,0x90),
- o3(0xE3,0x83,0x91), o3(0xE3,0x83,0x92),
- o3(0xE3,0x83,0x93), o3(0xE3,0x83,0x94),
- o3(0xE3,0x83,0x95), o3(0xE3,0x83,0x96),
- o3(0xE3,0x83,0x97), o3(0xE3,0x83,0x98),
- o3(0xE3,0x83,0x99), o3(0xE3,0x83,0x9A),
- o3(0xE3,0x83,0x9B), o3(0xE3,0x83,0x9C),
- o3(0xE3,0x83,0x9D), o3(0xE3,0x83,0x9E),
- o3(0xE3,0x83,0x9F), o3(0xE3,0x83,0xA0),
- o3(0xE3,0x83,0xA1), o3(0xE3,0x83,0xA2),
- o3(0xE3,0x83,0xA3), o3(0xE3,0x83,0xA4),
- o3(0xE3,0x83,0xA5), o3(0xE3,0x83,0xA6),
- o3(0xE3,0x83,0xA7), o3(0xE3,0x83,0xA8),
- o3(0xE3,0x83,0xA9), o3(0xE3,0x83,0xAA),
- o3(0xE3,0x83,0xAB), o3(0xE3,0x83,0xAC),
- o3(0xE3,0x83,0xAD), o3(0xE3,0x83,0xAE),
- o3(0xE3,0x83,0xAF), o3(0xE3,0x83,0xB0),
- o3(0xE3,0x83,0xB1), o3(0xE3,0x83,0xB2),
- o3(0xE3,0x83,0xB3), o3(0xE3,0x83,0xB4),
- o3(0xE3,0x83,0xB5), o3(0xE3,0x83,0xB6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A5 = {
- from_EUC_JP_A5_offsets,
- from_EUC_JP_A5_infos
-};
-
-static const unsigned char
-from_EUC_JP_A6_offsets[256] = {
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 48, 48, 48, 48, 48, 48, 48,
- 48, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A6_infos[49] = {
- o2(0xCE,0x91), o2(0xCE,0x92), o2(0xCE,0x93), o2(0xCE,0x94),
- o2(0xCE,0x95), o2(0xCE,0x96), o2(0xCE,0x97), o2(0xCE,0x98),
- o2(0xCE,0x99), o2(0xCE,0x9A), o2(0xCE,0x9B), o2(0xCE,0x9C),
- o2(0xCE,0x9D), o2(0xCE,0x9E), o2(0xCE,0x9F), o2(0xCE,0xA0),
- o2(0xCE,0xA1), o2(0xCE,0xA3), o2(0xCE,0xA4), o2(0xCE,0xA5),
- o2(0xCE,0xA6), o2(0xCE,0xA7), o2(0xCE,0xA8), o2(0xCE,0xA9),
- o2(0xCE,0xB1), o2(0xCE,0xB2), o2(0xCE,0xB3), o2(0xCE,0xB4),
- o2(0xCE,0xB5), o2(0xCE,0xB6), o2(0xCE,0xB7), o2(0xCE,0xB8),
- o2(0xCE,0xB9), o2(0xCE,0xBA), o2(0xCE,0xBB), o2(0xCE,0xBC),
- o2(0xCE,0xBD), o2(0xCE,0xBE), o2(0xCE,0xBF), o2(0xCF,0x80),
- o2(0xCF,0x81), o2(0xCF,0x83), o2(0xCF,0x84), o2(0xCF,0x85),
- o2(0xCF,0x86), o2(0xCF,0x87), o2(0xCF,0x88), o2(0xCF,0x89),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A6 = {
- from_EUC_JP_A6_offsets,
- from_EUC_JP_A6_infos
-};
-
-static const unsigned char
-from_EUC_JP_A7_offsets[256] = {
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- 66, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A7_infos[67] = {
- o2(0xD0,0x90), o2(0xD0,0x91), o2(0xD0,0x92), o2(0xD0,0x93),
- o2(0xD0,0x94), o2(0xD0,0x95), o2(0xD0,0x81), o2(0xD0,0x96),
- o2(0xD0,0x97), o2(0xD0,0x98), o2(0xD0,0x99), o2(0xD0,0x9A),
- o2(0xD0,0x9B), o2(0xD0,0x9C), o2(0xD0,0x9D), o2(0xD0,0x9E),
- o2(0xD0,0x9F), o2(0xD0,0xA0), o2(0xD0,0xA1), o2(0xD0,0xA2),
- o2(0xD0,0xA3), o2(0xD0,0xA4), o2(0xD0,0xA5), o2(0xD0,0xA6),
- o2(0xD0,0xA7), o2(0xD0,0xA8), o2(0xD0,0xA9), o2(0xD0,0xAA),
- o2(0xD0,0xAB), o2(0xD0,0xAC), o2(0xD0,0xAD), o2(0xD0,0xAE),
- o2(0xD0,0xAF), o2(0xD0,0xB0), o2(0xD0,0xB1), o2(0xD0,0xB2),
- o2(0xD0,0xB3), o2(0xD0,0xB4), o2(0xD0,0xB5), o2(0xD1,0x91),
- o2(0xD0,0xB6), o2(0xD0,0xB7), o2(0xD0,0xB8), o2(0xD0,0xB9),
- o2(0xD0,0xBA), o2(0xD0,0xBB), o2(0xD0,0xBC), o2(0xD0,0xBD),
- o2(0xD0,0xBE), o2(0xD0,0xBF), o2(0xD1,0x80), o2(0xD1,0x81),
- o2(0xD1,0x82), o2(0xD1,0x83), o2(0xD1,0x84), o2(0xD1,0x85),
- o2(0xD1,0x86), o2(0xD1,0x87), o2(0xD1,0x88), o2(0xD1,0x89),
- o2(0xD1,0x8A), o2(0xD1,0x8B), o2(0xD1,0x8C), o2(0xD1,0x8D),
- o2(0xD1,0x8E), o2(0xD1,0x8F), UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A7 = {
- from_EUC_JP_A7_offsets,
- from_EUC_JP_A7_infos
-};
-
-static const unsigned char
-from_EUC_JP_A8_offsets[256] = {
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-};
-static const struct byte_lookup* const
-from_EUC_JP_A8_infos[33] = {
- o3(0xE2,0x94,0x80), o3(0xE2,0x94,0x82),
- o3(0xE2,0x94,0x8C), o3(0xE2,0x94,0x90),
- o3(0xE2,0x94,0x98), o3(0xE2,0x94,0x94),
- o3(0xE2,0x94,0x9C), o3(0xE2,0x94,0xAC),
- o3(0xE2,0x94,0xA4), o3(0xE2,0x94,0xB4),
- o3(0xE2,0x94,0xBC), o3(0xE2,0x94,0x81),
- o3(0xE2,0x94,0x83), o3(0xE2,0x94,0x8F),
- o3(0xE2,0x94,0x93), o3(0xE2,0x94,0x9B),
- o3(0xE2,0x94,0x97), o3(0xE2,0x94,0xA3),
- o3(0xE2,0x94,0xB3), o3(0xE2,0x94,0xAB),
- o3(0xE2,0x94,0xBB), o3(0xE2,0x95,0x8B),
- o3(0xE2,0x94,0xA0), o3(0xE2,0x94,0xAF),
- o3(0xE2,0x94,0xA8), o3(0xE2,0x94,0xB7),
- o3(0xE2,0x94,0xBF), o3(0xE2,0x94,0x9D),
- o3(0xE2,0x94,0xB0), o3(0xE2,0x94,0xA5),
- o3(0xE2,0x94,0xB8), o3(0xE2,0x95,0x82),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_A8 = {
- from_EUC_JP_A8_offsets,
- from_EUC_JP_A8_infos
-};
-
-static const unsigned char
-from_EUC_JP_AD_offsets[256] = {
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 83,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 83, 83, 83, 83, 83, 83, 83, 83, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 83, 83,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_AD = {
- from_EUC_JP_AD_offsets,
- from_SHIFT_JIS_87_infos
-};
-
-static const BYTE_LOOKUP
-from_EUC_JP_B0 = {
- from_EUC_JP_A1_offsets,
- from_SHIFT_JIS_88_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B1_infos[95] = {
- o3(0xE9,0x99,0xA2), o3(0xE9,0x99,0xB0),
- o3(0xE9,0x9A,0xA0), o3(0xE9,0x9F,0xBB),
- o3(0xE5,0x90,0x8B), o3(0xE5,0x8F,0xB3),
- o3(0xE5,0xAE,0x87), o3(0xE7,0x83,0x8F),
- o3(0xE7,0xBE,0xBD), o3(0xE8,0xBF,0x82),
- o3(0xE9,0x9B,0xA8), o3(0xE5,0x8D,0xAF),
- o3(0xE9,0xB5,0x9C), o3(0xE7,0xAA,0xBA),
- o3(0xE4,0xB8,0x91), o3(0xE7,0xA2,0x93),
- o3(0xE8,0x87,0xBC), o3(0xE6,0xB8,0xA6),
- o3(0xE5,0x98,0x98), o3(0xE5,0x94,0x84),
- o3(0xE6,0xAC,0x9D), o3(0xE8,0x94,0x9A),
- o3(0xE9,0xB0,0xBB), o3(0xE5,0xA7,0xA5),
- o3(0xE5,0x8E,0xA9), o3(0xE6,0xB5,0xA6),
- o3(0xE7,0x93,0x9C), o3(0xE9,0x96,0x8F),
- o3(0xE5,0x99,0x82), o3(0xE4,0xBA,0x91),
- o3(0xE9,0x81,0x8B), o3(0xE9,0x9B,0xB2),
- o3(0xE8,0x8D,0x8F), o3(0xE9,0xA4,0x8C),
- o3(0xE5,0x8F,0xA1), o3(0xE5,0x96,0xB6),
- o3(0xE5,0xAC,0xB0), o3(0xE5,0xBD,0xB1),
- o3(0xE6,0x98,0xA0), o3(0xE6,0x9B,0xB3),
- o3(0xE6,0xA0,0x84), o3(0xE6,0xB0,0xB8),
- o3(0xE6,0xB3,0xB3), o3(0xE6,0xB4,0xA9),
- o3(0xE7,0x91,0x9B), o3(0xE7,0x9B,0x88),
- o3(0xE7,0xA9,0x8E), o3(0xE9,0xA0,0xB4),
- o3(0xE8,0x8B,0xB1), o3(0xE8,0xA1,0x9B),
- o3(0xE8,0xA9,0xA0), o3(0xE9,0x8B,0xAD),
- o3(0xE6,0xB6,0xB2), o3(0xE7,0x96,0xAB),
- o3(0xE7,0x9B,0x8A), o3(0xE9,0xA7,0x85),
- o3(0xE6,0x82,0xA6), o3(0xE8,0xAC,0x81),
- o3(0xE8,0xB6,0x8A), o3(0xE9,0x96,0xB2),
- o3(0xE6,0xA6,0x8E), o3(0xE5,0x8E,0xAD),
- o3(0xE5,0x86,0x86), o3(0xE5,0x9C,0x92),
- o3(0xE5,0xA0,0xB0), o3(0xE5,0xA5,0x84),
- o3(0xE5,0xAE,0xB4), o3(0xE5,0xBB,0xB6),
- o3(0xE6,0x80,0xA8), o3(0xE6,0x8E,0xA9),
- o3(0xE6,0x8F,0xB4), o3(0xE6,0xB2,0xBF),
- o3(0xE6,0xBC,0x94), o3(0xE7,0x82,0x8E),
- o3(0xE7,0x84,0x94), o3(0xE7,0x85,0x99),
- o3(0xE7,0x87,0x95), o3(0xE7,0x8C,0xBF),
- o3(0xE7,0xB8,0x81), o3(0xE8,0x89,0xB6),
- o3(0xE8,0x8B,0x91), o3(0xE8,0x96,0x97),
- o3(0xE9,0x81,0xA0), o3(0xE9,0x89,0x9B),
- o3(0xE9,0xB4,0x9B), o3(0xE5,0xA1,0xA9),
- o3(0xE6,0x96,0xBC), o3(0xE6,0xB1,0x9A),
- o3(0xE7,0x94,0xA5), o3(0xE5,0x87,0xB9),
- o3(0xE5,0xA4,0xAE), o3(0xE5,0xA5,0xA5),
- o3(0xE5,0xBE,0x80), o3(0xE5,0xBF,0x9C),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B1 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B1_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B2_infos[95] = {
- o3(0xE6,0x8A,0xBC), o3(0xE6,0x97,0xBA),
- o3(0xE6,0xA8,0xAA), o3(0xE6,0xAC,0xA7),
- o3(0xE6,0xAE,0xB4), o3(0xE7,0x8E,0x8B),
- o3(0xE7,0xBF,0x81), o3(0xE8,0xA5,0x96),
- o3(0xE9,0xB4,0xAC), o3(0xE9,0xB4,0x8E),
- o3(0xE9,0xBB,0x84), o3(0xE5,0xB2,0xA1),
- o3(0xE6,0xB2,0x96), o3(0xE8,0x8D,0xBB),
- o3(0xE5,0x84,0x84), o3(0xE5,0xB1,0x8B),
- o3(0xE6,0x86,0xB6), o3(0xE8,0x87,0x86),
- o3(0xE6,0xA1,0xB6), o3(0xE7,0x89,0xA1),
- o3(0xE4,0xB9,0x99), o3(0xE4,0xBF,0xBA),
- o3(0xE5,0x8D,0xB8), o3(0xE6,0x81,0xA9),
- o3(0xE6,0xB8,0xA9), o3(0xE7,0xA9,0x8F),
- o3(0xE9,0x9F,0xB3), o3(0xE4,0xB8,0x8B),
- o3(0xE5,0x8C,0x96), o3(0xE4,0xBB,0xAE),
- o3(0xE4,0xBD,0x95), o3(0xE4,0xBC,0xBD),
- o3(0xE4,0xBE,0xA1), o3(0xE4,0xBD,0xB3),
- o3(0xE5,0x8A,0xA0), o3(0xE5,0x8F,0xAF),
- o3(0xE5,0x98,0x89), o3(0xE5,0xA4,0x8F),
- o3(0xE5,0xAB,0x81), o3(0xE5,0xAE,0xB6),
- o3(0xE5,0xAF,0xA1), o3(0xE7,0xA7,0x91),
- o3(0xE6,0x9A,0x87), o3(0xE6,0x9E,0x9C),
- o3(0xE6,0x9E,0xB6), o3(0xE6,0xAD,0x8C),
- o3(0xE6,0xB2,0xB3), o3(0xE7,0x81,0xAB),
- o3(0xE7,0x8F,0x82), o3(0xE7,0xA6,0x8D),
- o3(0xE7,0xA6,0xBE), o3(0xE7,0xA8,0xBC),
- o3(0xE7,0xAE,0x87), o3(0xE8,0x8A,0xB1),
- o3(0xE8,0x8B,0x9B), o3(0xE8,0x8C,0x84),
- o3(0xE8,0x8D,0xB7), o3(0xE8,0x8F,0xAF),
- o3(0xE8,0x8F,0x93), o3(0xE8,0x9D,0xA6),
- o3(0xE8,0xAA,0xB2), o3(0xE5,0x98,0xA9),
- o3(0xE8,0xB2,0xA8), o3(0xE8,0xBF,0xA6),
- o3(0xE9,0x81,0x8E), o3(0xE9,0x9C,0x9E),
- o3(0xE8,0x9A,0x8A), o3(0xE4,0xBF,0x84),
- o3(0xE5,0xB3,0xA8), o3(0xE6,0x88,0x91),
- o3(0xE7,0x89,0x99), o3(0xE7,0x94,0xBB),
- o3(0xE8,0x87,0xA5), o3(0xE8,0x8A,0xBD),
- o3(0xE8,0x9B,0xBE), o3(0xE8,0xB3,0x80),
- o3(0xE9,0x9B,0x85), o3(0xE9,0xA4,0x93),
- o3(0xE9,0xA7,0x95), o3(0xE4,0xBB,0x8B),
- o3(0xE4,0xBC,0x9A), o3(0xE8,0xA7,0xA3),
- o3(0xE5,0x9B,0x9E), o3(0xE5,0xA1,0x8A),
- o3(0xE5,0xA3,0x8A), o3(0xE5,0xBB,0xBB),
- o3(0xE5,0xBF,0xAB), o3(0xE6,0x80,0xAA),
- o3(0xE6,0x82,0x94), o3(0xE6,0x81,0xA2),
- o3(0xE6,0x87,0x90), o3(0xE6,0x88,0x92),
- o3(0xE6,0x8B,0x90), o3(0xE6,0x94,0xB9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B2 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B2_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B3_infos[95] = {
- o3(0xE9,0xAD,0x81), o3(0xE6,0x99,0xA6),
- o3(0xE6,0xA2,0xB0), o3(0xE6,0xB5,0xB7),
- o3(0xE7,0x81,0xB0), o3(0xE7,0x95,0x8C),
- o3(0xE7,0x9A,0x86), o3(0xE7,0xB5,0xB5),
- o3(0xE8,0x8A,0xA5), o3(0xE8,0x9F,0xB9),
- o3(0xE9,0x96,0x8B), o3(0xE9,0x9A,0x8E),
- o3(0xE8,0xB2,0x9D), o3(0xE5,0x87,0xB1),
- o3(0xE5,0x8A,0xBE), o3(0xE5,0xA4,0x96),
- o3(0xE5,0x92,0xB3), o3(0xE5,0xAE,0xB3),
- o3(0xE5,0xB4,0x96), o3(0xE6,0x85,0xA8),
- o3(0xE6,0xA6,0x82), o3(0xE6,0xB6,0xAF),
- o3(0xE7,0xA2,0x8D), o3(0xE8,0x93,0x8B),
- o3(0xE8,0xA1,0x97), o3(0xE8,0xA9,0xB2),
- o3(0xE9,0x8E,0xA7), o3(0xE9,0xAA,0xB8),
- o3(0xE6,0xB5,0xAC), o3(0xE9,0xA6,0xA8),
- o3(0xE8,0x9B,0x99), o3(0xE5,0x9E,0xA3),
- o3(0xE6,0x9F,0xBF), o3(0xE8,0x9B,0x8E),
- o3(0xE9,0x88,0x8E), o3(0xE5,0x8A,0x83),
- o3(0xE5,0x9A,0x87), o3(0xE5,0x90,0x84),
- o3(0xE5,0xBB,0x93), o3(0xE6,0x8B,0xA1),
- o3(0xE6,0x92,0xB9), o3(0xE6,0xA0,0xBC),
- o3(0xE6,0xA0,0xB8), o3(0xE6,0xAE,0xBB),
- o3(0xE7,0x8D,0xB2), o3(0xE7,0xA2,0xBA),
- o3(0xE7,0xA9,0xAB), o3(0xE8,0xA6,0x9A),
- o3(0xE8,0xA7,0x92), o3(0xE8,0xB5,0xAB),
- o3(0xE8,0xBC,0x83), o3(0xE9,0x83,0xAD),
- o3(0xE9,0x96,0xA3), o3(0xE9,0x9A,0x94),
- o3(0xE9,0x9D,0xA9), o3(0xE5,0xAD,0xA6),
- o3(0xE5,0xB2,0xB3), o3(0xE6,0xA5,0xBD),
- o3(0xE9,0xA1,0x8D), o3(0xE9,0xA1,0x8E),
- o3(0xE6,0x8E,0x9B), o3(0xE7,0xAC,0xA0),
- o3(0xE6,0xA8,0xAB), o3(0xE6,0xA9,0xBF),
- o3(0xE6,0xA2,0xB6), o3(0xE9,0xB0,0x8D),
- o3(0xE6,0xBD,0x9F), o3(0xE5,0x89,0xB2),
- o3(0xE5,0x96,0x9D), o3(0xE6,0x81,0xB0),
- o3(0xE6,0x8B,0xAC), o3(0xE6,0xB4,0xBB),
- o3(0xE6,0xB8,0x87), o3(0xE6,0xBB,0x91),
- o3(0xE8,0x91,0x9B), o3(0xE8,0xA4,0x90),
- o3(0xE8,0xBD,0x84), o3(0xE4,0xB8,0x94),
- o3(0xE9,0xB0,0xB9), o3(0xE5,0x8F,0xB6),
- o3(0xE6,0xA4,0x9B), o3(0xE6,0xA8,0xBA),
- o3(0xE9,0x9E,0x84), o3(0xE6,0xA0,0xAA),
- o3(0xE5,0x85,0x9C), o3(0xE7,0xAB,0x83),
- o3(0xE8,0x92,0xB2), o3(0xE9,0x87,0x9C),
- o3(0xE9,0x8E,0x8C), o3(0xE5,0x99,0x9B),
- o3(0xE9,0xB4,0xA8), o3(0xE6,0xA0,0xA2),
- o3(0xE8,0x8C,0x85), o3(0xE8,0x90,0xB1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B3 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B3_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B4_infos[95] = {
- o3(0xE7,0xB2,0xA5), o3(0xE5,0x88,0x88),
- o3(0xE8,0x8B,0x85), o3(0xE7,0x93,0xA6),
- o3(0xE4,0xB9,0xBE), o3(0xE4,0xBE,0x83),
- o3(0xE5,0x86,0xA0), o3(0xE5,0xAF,0x92),
- o3(0xE5,0x88,0x8A), o3(0xE5,0x8B,0x98),
- o3(0xE5,0x8B,0xA7), o3(0xE5,0xB7,0xBB),
- o3(0xE5,0x96,0x9A), o3(0xE5,0xA0,0xAA),
- o3(0xE5,0xA7,0xA6), o3(0xE5,0xAE,0x8C),
- o3(0xE5,0xAE,0x98), o3(0xE5,0xAF,0x9B),
- o3(0xE5,0xB9,0xB2), o3(0xE5,0xB9,0xB9),
- o3(0xE6,0x82,0xA3), o3(0xE6,0x84,0x9F),
- o3(0xE6,0x85,0xA3), o3(0xE6,0x86,0xBE),
- o3(0xE6,0x8F,0x9B), o3(0xE6,0x95,0xA2),
- o3(0xE6,0x9F,0x91), o3(0xE6,0xA1,0x93),
- o3(0xE6,0xA3,0xBA), o3(0xE6,0xAC,0xBE),
- o3(0xE6,0xAD,0x93), o3(0xE6,0xB1,0x97),
- o3(0xE6,0xBC,0xA2), o3(0xE6,0xBE,0x97),
- o3(0xE6,0xBD,0x85), o3(0xE7,0x92,0xB0),
- o3(0xE7,0x94,0x98), o3(0xE7,0x9B,0xA3),
- o3(0xE7,0x9C,0x8B), o3(0xE7,0xAB,0xBF),
- o3(0xE7,0xAE,0xA1), o3(0xE7,0xB0,0xA1),
- o3(0xE7,0xB7,0xA9), o3(0xE7,0xBC,0xB6),
- o3(0xE7,0xBF,0xB0), o3(0xE8,0x82,0x9D),
- o3(0xE8,0x89,0xA6), o3(0xE8,0x8E,0x9E),
- o3(0xE8,0xA6,0xB3), o3(0xE8,0xAB,0x8C),
- o3(0xE8,0xB2,0xAB), o3(0xE9,0x82,0x84),
- o3(0xE9,0x91,0x91), o3(0xE9,0x96,0x93),
- o3(0xE9,0x96,0x91), o3(0xE9,0x96,0xA2),
- o3(0xE9,0x99,0xA5), o3(0xE9,0x9F,0x93),
- o3(0xE9,0xA4,0xA8), o3(0xE8,0x88,0x98),
- o3(0xE4,0xB8,0xB8), o3(0xE5,0x90,0xAB),
- o3(0xE5,0xB2,0xB8), o3(0xE5,0xB7,0x8C),
- o3(0xE7,0x8E,0xA9), o3(0xE7,0x99,0x8C),
- o3(0xE7,0x9C,0xBC), o3(0xE5,0xB2,0xA9),
- o3(0xE7,0xBF,0xAB), o3(0xE8,0xB4,0x8B),
- o3(0xE9,0x9B,0x81), o3(0xE9,0xA0,0x91),
- o3(0xE9,0xA1,0x94), o3(0xE9,0xA1,0x98),
- o3(0xE4,0xBC,0x81), o3(0xE4,0xBC,0x8E),
- o3(0xE5,0x8D,0xB1), o3(0xE5,0x96,0x9C),
- o3(0xE5,0x99,0xA8), o3(0xE5,0x9F,0xBA),
- o3(0xE5,0xA5,0x87), o3(0xE5,0xAC,0x89),
- o3(0xE5,0xAF,0x84), o3(0xE5,0xB2,0x90),
- o3(0xE5,0xB8,0x8C), o3(0xE5,0xB9,0xBE),
- o3(0xE5,0xBF,0x8C), o3(0xE6,0x8F,0xAE),
- o3(0xE6,0x9C,0xBA), o3(0xE6,0x97,0x97),
- o3(0xE6,0x97,0xA2), o3(0xE6,0x9C,0x9F),
- o3(0xE6,0xA3,0x8B), o3(0xE6,0xA3,0x84),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B4 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B4_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B5_infos[95] = {
- o3(0xE6,0xA9,0x9F), o3(0xE5,0xB8,0xB0),
- o3(0xE6,0xAF,0x85), o3(0xE6,0xB0,0x97),
- o3(0xE6,0xB1,0xBD), o3(0xE7,0x95,0xBF),
- o3(0xE7,0xA5,0x88), o3(0xE5,0xAD,0xA3),
- o3(0xE7,0xA8,0x80), o3(0xE7,0xB4,0x80),
- o3(0xE5,0xBE,0xBD), o3(0xE8,0xA6,0x8F),
- o3(0xE8,0xA8,0x98), o3(0xE8,0xB2,0xB4),
- o3(0xE8,0xB5,0xB7), o3(0xE8,0xBB,0x8C),
- o3(0xE8,0xBC,0x9D), o3(0xE9,0xA3,0xA2),
- o3(0xE9,0xA8,0x8E), o3(0xE9,0xAC,0xBC),
- o3(0xE4,0xBA,0x80), o3(0xE5,0x81,0xBD),
- o3(0xE5,0x84,0x80), o3(0xE5,0xA6,0x93),
- o3(0xE5,0xAE,0x9C), o3(0xE6,0x88,0xAF),
- o3(0xE6,0x8A,0x80), o3(0xE6,0x93,0xAC),
- o3(0xE6,0xAC,0xBA), o3(0xE7,0x8A,0xA0),
- o3(0xE7,0x96,0x91), o3(0xE7,0xA5,0x87),
- o3(0xE7,0xBE,0xA9), o3(0xE8,0x9F,0xBB),
- o3(0xE8,0xAA,0xBC), o3(0xE8,0xAD,0xB0),
- o3(0xE6,0x8E,0xAC), o3(0xE8,0x8F,0x8A),
- o3(0xE9,0x9E,0xA0), o3(0xE5,0x90,0x89),
- o3(0xE5,0x90,0x83), o3(0xE5,0x96,0xAB),
- o3(0xE6,0xA1,0x94), o3(0xE6,0xA9,0x98),
- o3(0xE8,0xA9,0xB0), o3(0xE7,0xA0,0xA7),
- o3(0xE6,0x9D,0xB5), o3(0xE9,0xBB,0x8D),
- o3(0xE5,0x8D,0xB4), o3(0xE5,0xAE,0xA2),
- o3(0xE8,0x84,0x9A), o3(0xE8,0x99,0x90),
- o3(0xE9,0x80,0x86), o3(0xE4,0xB8,0x98),
- o3(0xE4,0xB9,0x85), o3(0xE4,0xBB,0x87),
- o3(0xE4,0xBC,0x91), o3(0xE5,0x8F,0x8A),
- o3(0xE5,0x90,0xB8), o3(0xE5,0xAE,0xAE),
- o3(0xE5,0xBC,0x93), o3(0xE6,0x80,0xA5),
- o3(0xE6,0x95,0x91), o3(0xE6,0x9C,0xBD),
- o3(0xE6,0xB1,0x82), o3(0xE6,0xB1,0xB2),
- o3(0xE6,0xB3,0xA3), o3(0xE7,0x81,0xB8),
- o3(0xE7,0x90,0x83), o3(0xE7,0xA9,0xB6),
- o3(0xE7,0xAA,0xAE), o3(0xE7,0xAC,0x88),
- o3(0xE7,0xB4,0x9A), o3(0xE7,0xB3,0xBE),
- o3(0xE7,0xB5,0xA6), o3(0xE6,0x97,0xA7),
- o3(0xE7,0x89,0x9B), o3(0xE5,0x8E,0xBB),
- o3(0xE5,0xB1,0x85), o3(0xE5,0xB7,0xA8),
- o3(0xE6,0x8B,0x92), o3(0xE6,0x8B,0xA0),
- o3(0xE6,0x8C,0x99), o3(0xE6,0xB8,0xA0),
- o3(0xE8,0x99,0x9A), o3(0xE8,0xA8,0xB1),
- o3(0xE8,0xB7,0x9D), o3(0xE9,0x8B,0xB8),
- o3(0xE6,0xBC,0x81), o3(0xE7,0xA6,0xA6),
- o3(0xE9,0xAD,0x9A), o3(0xE4,0xBA,0xA8),
- o3(0xE4,0xBA,0xAB), o3(0xE4,0xBA,0xAC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B5 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B5_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B6_infos[95] = {
- o3(0xE4,0xBE,0x9B), o3(0xE4,0xBE,0xA0),
- o3(0xE5,0x83,0x91), o3(0xE5,0x85,0x87),
- o3(0xE7,0xAB,0xB6), o3(0xE5,0x85,0xB1),
- o3(0xE5,0x87,0xB6), o3(0xE5,0x8D,0x94),
- o3(0xE5,0x8C,0xA1), o3(0xE5,0x8D,0xBF),
- o3(0xE5,0x8F,0xAB), o3(0xE5,0x96,0xAC),
- o3(0xE5,0xA2,0x83), o3(0xE5,0xB3,0xA1),
- o3(0xE5,0xBC,0xB7), o3(0xE5,0xBD,0x8A),
- o3(0xE6,0x80,0xAF), o3(0xE6,0x81,0x90),
- o3(0xE6,0x81,0xAD), o3(0xE6,0x8C,0x9F),
- o3(0xE6,0x95,0x99), o3(0xE6,0xA9,0x8B),
- o3(0xE6,0xB3,0x81), o3(0xE7,0x8B,0x82),
- o3(0xE7,0x8B,0xAD), o3(0xE7,0x9F,0xAF),
- o3(0xE8,0x83,0xB8), o3(0xE8,0x84,0x85),
- o3(0xE8,0x88,0x88), o3(0xE8,0x95,0x8E),
- o3(0xE9,0x83,0xB7), o3(0xE9,0x8F,0xA1),
- o3(0xE9,0x9F,0xBF), o3(0xE9,0xA5,0x97),
- o3(0xE9,0xA9,0x9A), o3(0xE4,0xBB,0xB0),
- o3(0xE5,0x87,0x9D), o3(0xE5,0xB0,0xAD),
- o3(0xE6,0x9A,0x81), o3(0xE6,0xA5,0xAD),
- o3(0xE5,0xB1,0x80), o3(0xE6,0x9B,0xB2),
- o3(0xE6,0xA5,0xB5), o3(0xE7,0x8E,0x89),
- o3(0xE6,0xA1,0x90), o3(0xE7,0xB2,0x81),
- o3(0xE5,0x83,0x85), o3(0xE5,0x8B,0xA4),
- o3(0xE5,0x9D,0x87), o3(0xE5,0xB7,0xBE),
- o3(0xE9,0x8C,0xA6), o3(0xE6,0x96,0xA4),
- o3(0xE6,0xAC,0xA3), o3(0xE6,0xAC,0xBD),
- o3(0xE7,0x90,0xB4), o3(0xE7,0xA6,0x81),
- o3(0xE7,0xA6,0xBD), o3(0xE7,0xAD,0x8B),
- o3(0xE7,0xB7,0x8A), o3(0xE8,0x8A,0xB9),
- o3(0xE8,0x8F,0x8C), o3(0xE8,0xA1,0xBF),
- o3(0xE8,0xA5,0x9F), o3(0xE8,0xAC,0xB9),
- o3(0xE8,0xBF,0x91), o3(0xE9,0x87,0x91),
- o3(0xE5,0x90,0x9F), o3(0xE9,0x8A,0x80),
- o3(0xE4,0xB9,0x9D), o3(0xE5,0x80,0xB6),
- o3(0xE5,0x8F,0xA5), o3(0xE5,0x8C,0xBA),
- o3(0xE7,0x8B,0x97), o3(0xE7,0x8E,0x96),
- o3(0xE7,0x9F,0xA9), o3(0xE8,0x8B,0xA6),
- o3(0xE8,0xBA,0xAF), o3(0xE9,0xA7,0x86),
- o3(0xE9,0xA7,0x88), o3(0xE9,0xA7,0x92),
- o3(0xE5,0x85,0xB7), o3(0xE6,0x84,0x9A),
- o3(0xE8,0x99,0x9E), o3(0xE5,0x96,0xB0),
- o3(0xE7,0xA9,0xBA), o3(0xE5,0x81,0xB6),
- o3(0xE5,0xAF,0x93), o3(0xE9,0x81,0x87),
- o3(0xE9,0x9A,0x85), o3(0xE4,0xB8,0xB2),
- o3(0xE6,0xAB,0x9B), o3(0xE9,0x87,0xA7),
- o3(0xE5,0xB1,0x91), o3(0xE5,0xB1,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B6 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B6_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B7_infos[95] = {
- o3(0xE6,0x8E,0x98), o3(0xE7,0xAA,0x9F),
- o3(0xE6,0xB2,0x93), o3(0xE9,0x9D,0xB4),
- o3(0xE8,0xBD,0xA1), o3(0xE7,0xAA,0xAA),
- o3(0xE7,0x86,0x8A), o3(0xE9,0x9A,0x88),
- o3(0xE7,0xB2,0x82), o3(0xE6,0xA0,0x97),
- o3(0xE7,0xB9,0xB0), o3(0xE6,0xA1,0x91),
- o3(0xE9,0x8D,0xAC), o3(0xE5,0x8B,0xB2),
- o3(0xE5,0x90,0x9B), o3(0xE8,0x96,0xAB),
- o3(0xE8,0xA8,0x93), o3(0xE7,0xBE,0xA4),
- o3(0xE8,0xBB,0x8D), o3(0xE9,0x83,0xA1),
- o3(0xE5,0x8D,0xA6), o3(0xE8,0xA2,0x88),
- o3(0xE7,0xA5,0x81), o3(0xE4,0xBF,0x82),
- o3(0xE5,0x82,0xBE), o3(0xE5,0x88,0x91),
- o3(0xE5,0x85,0x84), o3(0xE5,0x95,0x93),
- o3(0xE5,0x9C,0xAD), o3(0xE7,0x8F,0xAA),
- o3(0xE5,0x9E,0x8B), o3(0xE5,0xA5,0x91),
- o3(0xE5,0xBD,0xA2), o3(0xE5,0xBE,0x84),
- o3(0xE6,0x81,0xB5), o3(0xE6,0x85,0xB6),
- o3(0xE6,0x85,0xA7), o3(0xE6,0x86,0xA9),
- o3(0xE6,0x8E,0xB2), o3(0xE6,0x90,0xBA),
- o3(0xE6,0x95,0xAC), o3(0xE6,0x99,0xAF),
- o3(0xE6,0xA1,0x82), o3(0xE6,0xB8,0x93),
- o3(0xE7,0x95,0xA6), o3(0xE7,0xA8,0xBD),
- o3(0xE7,0xB3,0xBB), o3(0xE7,0xB5,0x8C),
- o3(0xE7,0xB6,0x99), o3(0xE7,0xB9,0x8B),
- o3(0xE7,0xBD,0xAB), o3(0xE8,0x8C,0x8E),
- o3(0xE8,0x8D,0x8A), o3(0xE8,0x9B,0x8D),
- o3(0xE8,0xA8,0x88), o3(0xE8,0xA9,0xA3),
- o3(0xE8,0xAD,0xA6), o3(0xE8,0xBB,0xBD),
- o3(0xE9,0xA0,0x9A), o3(0xE9,0xB6,0x8F),
- o3(0xE8,0x8A,0xB8), o3(0xE8,0xBF,0x8E),
- o3(0xE9,0xAF,0xA8), o3(0xE5,0x8A,0x87),
- o3(0xE6,0x88,0x9F), o3(0xE6,0x92,0x83),
- o3(0xE6,0xBF,0x80), o3(0xE9,0x9A,0x99),
- o3(0xE6,0xA1,0x81), o3(0xE5,0x82,0x91),
- o3(0xE6,0xAC,0xA0), o3(0xE6,0xB1,0xBA),
- o3(0xE6,0xBD,0x94), o3(0xE7,0xA9,0xB4),
- o3(0xE7,0xB5,0x90), o3(0xE8,0xA1,0x80),
- o3(0xE8,0xA8,0xA3), o3(0xE6,0x9C,0x88),
- o3(0xE4,0xBB,0xB6), o3(0xE5,0x80,0xB9),
- o3(0xE5,0x80,0xA6), o3(0xE5,0x81,0xA5),
- o3(0xE5,0x85,0xBC), o3(0xE5,0x88,0xB8),
- o3(0xE5,0x89,0xA3), o3(0xE5,0x96,0xA7),
- o3(0xE5,0x9C,0x8F), o3(0xE5,0xA0,0x85),
- o3(0xE5,0xAB,0x8C), o3(0xE5,0xBB,0xBA),
- o3(0xE6,0x86,0xB2), o3(0xE6,0x87,0xB8),
- o3(0xE6,0x8B,0xB3), o3(0xE6,0x8D,0xB2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B7 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B7_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B8_infos[95] = {
- o3(0xE6,0xA4,0x9C), o3(0xE6,0xA8,0xA9),
- o3(0xE7,0x89,0xBD), o3(0xE7,0x8A,0xAC),
- o3(0xE7,0x8C,0xAE), o3(0xE7,0xA0,0x94),
- o3(0xE7,0xA1,0xAF), o3(0xE7,0xB5,0xB9),
- o3(0xE7,0x9C,0x8C), o3(0xE8,0x82,0xA9),
- o3(0xE8,0xA6,0x8B), o3(0xE8,0xAC,0x99),
- o3(0xE8,0xB3,0xA2), o3(0xE8,0xBB,0x92),
- o3(0xE9,0x81,0xA3), o3(0xE9,0x8D,0xB5),
- o3(0xE9,0x99,0xBA), o3(0xE9,0xA1,0x95),
- o3(0xE9,0xA8,0x93), o3(0xE9,0xB9,0xB8),
- o3(0xE5,0x85,0x83), o3(0xE5,0x8E,0x9F),
- o3(0xE5,0x8E,0xB3), o3(0xE5,0xB9,0xBB),
- o3(0xE5,0xBC,0xA6), o3(0xE6,0xB8,0x9B),
- o3(0xE6,0xBA,0x90), o3(0xE7,0x8E,0x84),
- o3(0xE7,0x8F,0xBE), o3(0xE7,0xB5,0x83),
- o3(0xE8,0x88,0xB7), o3(0xE8,0xA8,0x80),
- o3(0xE8,0xAB,0xBA), o3(0xE9,0x99,0x90),
- o3(0xE4,0xB9,0x8E), o3(0xE5,0x80,0x8B),
- o3(0xE5,0x8F,0xA4), o3(0xE5,0x91,0xBC),
- o3(0xE5,0x9B,0xBA), o3(0xE5,0xA7,0x91),
- o3(0xE5,0xAD,0xA4), o3(0xE5,0xB7,0xB1),
- o3(0xE5,0xBA,0xAB), o3(0xE5,0xBC,0xA7),
- o3(0xE6,0x88,0xB8), o3(0xE6,0x95,0x85),
- o3(0xE6,0x9E,0xAF), o3(0xE6,0xB9,0x96),
- o3(0xE7,0x8B,0x90), o3(0xE7,0xB3,0x8A),
- o3(0xE8,0xA2,0xB4), o3(0xE8,0x82,0xA1),
- o3(0xE8,0x83,0xA1), o3(0xE8,0x8F,0xB0),
- o3(0xE8,0x99,0x8E), o3(0xE8,0xAA,0x87),
- o3(0xE8,0xB7,0xA8), o3(0xE9,0x88,0xB7),
- o3(0xE9,0x9B,0x87), o3(0xE9,0xA1,0xA7),
- o3(0xE9,0xBC,0x93), o3(0xE4,0xBA,0x94),
- o3(0xE4,0xBA,0x92), o3(0xE4,0xBC,0x8D),
- o3(0xE5,0x8D,0x88), o3(0xE5,0x91,0x89),
- o3(0xE5,0x90,0xBE), o3(0xE5,0xA8,0xAF),
- o3(0xE5,0xBE,0x8C), o3(0xE5,0xBE,0xA1),
- o3(0xE6,0x82,0x9F), o3(0xE6,0xA2,0xA7),
- o3(0xE6,0xAA,0x8E), o3(0xE7,0x91,0x9A),
- o3(0xE7,0xA2,0x81), o3(0xE8,0xAA,0x9E),
- o3(0xE8,0xAA,0xA4), o3(0xE8,0xAD,0xB7),
- o3(0xE9,0x86,0x90), o3(0xE4,0xB9,0x9E),
- o3(0xE9,0xAF,0x89), o3(0xE4,0xBA,0xA4),
- o3(0xE4,0xBD,0xBC), o3(0xE4,0xBE,0xAF),
- o3(0xE5,0x80,0x99), o3(0xE5,0x80,0x96),
- o3(0xE5,0x85,0x89), o3(0xE5,0x85,0xAC),
- o3(0xE5,0x8A,0x9F), o3(0xE5,0x8A,0xB9),
- o3(0xE5,0x8B,0xBE), o3(0xE5,0x8E,0x9A),
- o3(0xE5,0x8F,0xA3), o3(0xE5,0x90,0x91),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B8 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B8_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_B9_infos[95] = {
- o3(0xE5,0x90,0x8E), o3(0xE5,0x96,0x89),
- o3(0xE5,0x9D,0x91), o3(0xE5,0x9E,0xA2),
- o3(0xE5,0xA5,0xBD), o3(0xE5,0xAD,0x94),
- o3(0xE5,0xAD,0x9D), o3(0xE5,0xAE,0x8F),
- o3(0xE5,0xB7,0xA5), o3(0xE5,0xB7,0xA7),
- o3(0xE5,0xB7,0xB7), o3(0xE5,0xB9,0xB8),
- o3(0xE5,0xBA,0x83), o3(0xE5,0xBA,0x9A),
- o3(0xE5,0xBA,0xB7), o3(0xE5,0xBC,0x98),
- o3(0xE6,0x81,0x92), o3(0xE6,0x85,0x8C),
- o3(0xE6,0x8A,0x97), o3(0xE6,0x8B,0x98),
- o3(0xE6,0x8E,0xA7), o3(0xE6,0x94,0xBB),
- o3(0xE6,0x98,0x82), o3(0xE6,0x99,0x83),
- o3(0xE6,0x9B,0xB4), o3(0xE6,0x9D,0xAD),
- o3(0xE6,0xA0,0xA1), o3(0xE6,0xA2,0x97),
- o3(0xE6,0xA7,0x8B), o3(0xE6,0xB1,0x9F),
- o3(0xE6,0xB4,0xAA), o3(0xE6,0xB5,0xA9),
- o3(0xE6,0xB8,0xAF), o3(0xE6,0xBA,0x9D),
- o3(0xE7,0x94,0xB2), o3(0xE7,0x9A,0x87),
- o3(0xE7,0xA1,0xAC), o3(0xE7,0xA8,0xBF),
- o3(0xE7,0xB3,0xA0), o3(0xE7,0xB4,0x85),
- o3(0xE7,0xB4,0x98), o3(0xE7,0xB5,0x9E),
- o3(0xE7,0xB6,0xB1), o3(0xE8,0x80,0x95),
- o3(0xE8,0x80,0x83), o3(0xE8,0x82,0xAF),
- o3(0xE8,0x82,0xB1), o3(0xE8,0x85,0x94),
- o3(0xE8,0x86,0x8F), o3(0xE8,0x88,0xAA),
- o3(0xE8,0x8D,0x92), o3(0xE8,0xA1,0x8C),
- o3(0xE8,0xA1,0xA1), o3(0xE8,0xAC,0x9B),
- o3(0xE8,0xB2,0xA2), o3(0xE8,0xB3,0xBC),
- o3(0xE9,0x83,0x8A), o3(0xE9,0x85,0xB5),
- o3(0xE9,0x89,0xB1), o3(0xE7,0xA0,0xBF),
- o3(0xE9,0x8B,0xBC), o3(0xE9,0x96,0xA4),
- o3(0xE9,0x99,0x8D), o3(0xE9,0xA0,0x85),
- o3(0xE9,0xA6,0x99), o3(0xE9,0xAB,0x98),
- o3(0xE9,0xB4,0xBB), o3(0xE5,0x89,0x9B),
- o3(0xE5,0x8A,0xAB), o3(0xE5,0x8F,0xB7),
- o3(0xE5,0x90,0x88), o3(0xE5,0xA3,0x95),
- o3(0xE6,0x8B,0xB7), o3(0xE6,0xBF,0xA0),
- o3(0xE8,0xB1,0xAA), o3(0xE8,0xBD,0x9F),
- o3(0xE9,0xBA,0xB9), o3(0xE5,0x85,0x8B),
- o3(0xE5,0x88,0xBB), o3(0xE5,0x91,0x8A),
- o3(0xE5,0x9B,0xBD), o3(0xE7,0xA9,0x80),
- o3(0xE9,0x85,0xB7), o3(0xE9,0xB5,0xA0),
- o3(0xE9,0xBB,0x92), o3(0xE7,0x8D,0x84),
- o3(0xE6,0xBC,0x89), o3(0xE8,0x85,0xB0),
- o3(0xE7,0x94,0x91), o3(0xE5,0xBF,0xBD),
- o3(0xE6,0x83,0x9A), o3(0xE9,0xAA,0xA8),
- o3(0xE7,0x8B,0x9B), o3(0xE8,0xBE,0xBC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_B9 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_B9_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_BA_infos[95] = {
- o3(0xE6,0xAD,0xA4), o3(0xE9,0xA0,0x83),
- o3(0xE4,0xBB,0x8A), o3(0xE5,0x9B,0xB0),
- o3(0xE5,0x9D,0xA4), o3(0xE5,0xA2,0xBE),
- o3(0xE5,0xA9,0x9A), o3(0xE6,0x81,0xA8),
- o3(0xE6,0x87,0x87), o3(0xE6,0x98,0x8F),
- o3(0xE6,0x98,0x86), o3(0xE6,0xA0,0xB9),
- o3(0xE6,0xA2,0xB1), o3(0xE6,0xB7,0xB7),
- o3(0xE7,0x97,0x95), o3(0xE7,0xB4,0xBA),
- o3(0xE8,0x89,0xAE), o3(0xE9,0xAD,0x82),
- o3(0xE4,0xBA,0x9B), o3(0xE4,0xBD,0x90),
- o3(0xE5,0x8F,0x89), o3(0xE5,0x94,0x86),
- o3(0xE5,0xB5,0xAF), o3(0xE5,0xB7,0xA6),
- o3(0xE5,0xB7,0xAE), o3(0xE6,0x9F,0xBB),
- o3(0xE6,0xB2,0x99), o3(0xE7,0x91,0xB3),
- o3(0xE7,0xA0,0x82), o3(0xE8,0xA9,0x90),
- o3(0xE9,0x8E,0x96), o3(0xE8,0xA3,0x9F),
- o3(0xE5,0x9D,0x90), o3(0xE5,0xBA,0xA7),
- o3(0xE6,0x8C,0xAB), o3(0xE5,0x82,0xB5),
- o3(0xE5,0x82,0xAC), o3(0xE5,0x86,0x8D),
- o3(0xE6,0x9C,0x80), o3(0xE5,0x93,0x89),
- o3(0xE5,0xA1,0x9E), o3(0xE5,0xA6,0xBB),
- o3(0xE5,0xAE,0xB0), o3(0xE5,0xBD,0xA9),
- o3(0xE6,0x89,0x8D), o3(0xE6,0x8E,0xA1),
- o3(0xE6,0xA0,0xBD), o3(0xE6,0xAD,0xB3),
- o3(0xE6,0xB8,0x88), o3(0xE7,0x81,0xBD),
- o3(0xE9,0x87,0x87), o3(0xE7,0x8A,0x80),
- o3(0xE7,0xA0,0x95), o3(0xE7,0xA0,0xA6),
- o3(0xE7,0xA5,0xAD), o3(0xE6,0x96,0x8E),
- o3(0xE7,0xB4,0xB0), o3(0xE8,0x8F,0x9C),
- o3(0xE8,0xA3,0x81), o3(0xE8,0xBC,0x89),
- o3(0xE9,0x9A,0x9B), o3(0xE5,0x89,0xA4),
- o3(0xE5,0x9C,0xA8), o3(0xE6,0x9D,0x90),
- o3(0xE7,0xBD,0xAA), o3(0xE8,0xB2,0xA1),
- o3(0xE5,0x86,0xB4), o3(0xE5,0x9D,0x82),
- o3(0xE9,0x98,0xAA), o3(0xE5,0xA0,0xBA),
- o3(0xE6,0xA6,0x8A), o3(0xE8,0x82,0xB4),
- o3(0xE5,0x92,0xB2), o3(0xE5,0xB4,0x8E),
- o3(0xE5,0x9F,0xBC), o3(0xE7,0xA2,0x95),
- o3(0xE9,0xB7,0xBA), o3(0xE4,0xBD,0x9C),
- o3(0xE5,0x89,0x8A), o3(0xE5,0x92,0x8B),
- o3(0xE6,0x90,0xBE), o3(0xE6,0x98,0xA8),
- o3(0xE6,0x9C,0x94), o3(0xE6,0x9F,0xB5),
- o3(0xE7,0xAA,0x84), o3(0xE7,0xAD,0x96),
- o3(0xE7,0xB4,0xA2), o3(0xE9,0x8C,0xAF),
- o3(0xE6,0xA1,0x9C), o3(0xE9,0xAE,0xAD),
- o3(0xE7,0xAC,0xB9), o3(0xE5,0x8C,0x99),
- o3(0xE5,0x86,0x8A), o3(0xE5,0x88,0xB7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_BA = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_BA_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_BB_infos[95] = {
- o3(0xE5,0xAF,0x9F), o3(0xE6,0x8B,0xB6),
- o3(0xE6,0x92,0xAE), o3(0xE6,0x93,0xA6),
- o3(0xE6,0x9C,0xAD), o3(0xE6,0xAE,0xBA),
- o3(0xE8,0x96,0xA9), o3(0xE9,0x9B,0x91),
- o3(0xE7,0x9A,0x90), o3(0xE9,0xAF,0x96),
- o3(0xE6,0x8D,0x8C), o3(0xE9,0x8C,0x86),
- o3(0xE9,0xAE,0xAB), o3(0xE7,0x9A,0xBF),
- o3(0xE6,0x99,0x92), o3(0xE4,0xB8,0x89),
- o3(0xE5,0x82,0x98), o3(0xE5,0x8F,0x82),
- o3(0xE5,0xB1,0xB1), o3(0xE6,0x83,0xA8),
- o3(0xE6,0x92,0x92), o3(0xE6,0x95,0xA3),
- o3(0xE6,0xA1,0x9F), o3(0xE7,0x87,0xA6),
- o3(0xE7,0x8F,0x8A), o3(0xE7,0x94,0xA3),
- o3(0xE7,0xAE,0x97), o3(0xE7,0xBA,0x82),
- o3(0xE8,0x9A,0x95), o3(0xE8,0xAE,0x83),
- o3(0xE8,0xB3,0x9B), o3(0xE9,0x85,0xB8),
- o3(0xE9,0xA4,0x90), o3(0xE6,0x96,0xAC),
- o3(0xE6,0x9A,0xAB), o3(0xE6,0xAE,0x8B),
- o3(0xE4,0xBB,0x95), o3(0xE4,0xBB,0x94),
- o3(0xE4,0xBC,0xBA), o3(0xE4,0xBD,0xBF),
- o3(0xE5,0x88,0xBA), o3(0xE5,0x8F,0xB8),
- o3(0xE5,0x8F,0xB2), o3(0xE5,0x97,0xA3),
- o3(0xE5,0x9B,0x9B), o3(0xE5,0xA3,0xAB),
- o3(0xE5,0xA7,0x8B), o3(0xE5,0xA7,0x89),
- o3(0xE5,0xA7,0xBF), o3(0xE5,0xAD,0x90),
- o3(0xE5,0xB1,0x8D), o3(0xE5,0xB8,0x82),
- o3(0xE5,0xB8,0xAB), o3(0xE5,0xBF,0x97),
- o3(0xE6,0x80,0x9D), o3(0xE6,0x8C,0x87),
- o3(0xE6,0x94,0xAF), o3(0xE5,0xAD,0x9C),
- o3(0xE6,0x96,0xAF), o3(0xE6,0x96,0xBD),
- o3(0xE6,0x97,0xA8), o3(0xE6,0x9E,0x9D),
- o3(0xE6,0xAD,0xA2), o3(0xE6,0xAD,0xBB),
- o3(0xE6,0xB0,0x8F), o3(0xE7,0x8D,0x85),
- o3(0xE7,0xA5,0x89), o3(0xE7,0xA7,0x81),
- o3(0xE7,0xB3,0xB8), o3(0xE7,0xB4,0x99),
- o3(0xE7,0xB4,0xAB), o3(0xE8,0x82,0xA2),
- o3(0xE8,0x84,0x82), o3(0xE8,0x87,0xB3),
- o3(0xE8,0xA6,0x96), o3(0xE8,0xA9,0x9E),
- o3(0xE8,0xA9,0xA9), o3(0xE8,0xA9,0xA6),
- o3(0xE8,0xAA,0x8C), o3(0xE8,0xAB,0xAE),
- o3(0xE8,0xB3,0x87), o3(0xE8,0xB3,0x9C),
- o3(0xE9,0x9B,0x8C), o3(0xE9,0xA3,0xBC),
- o3(0xE6,0xAD,0xAF), o3(0xE4,0xBA,0x8B),
- o3(0xE4,0xBC,0xBC), o3(0xE4,0xBE,0x8D),
- o3(0xE5,0x85,0x90), o3(0xE5,0xAD,0x97),
- o3(0xE5,0xAF,0xBA), o3(0xE6,0x85,0x88),
- o3(0xE6,0x8C,0x81), o3(0xE6,0x99,0x82),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_BB = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_BB_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_BC_infos[95] = {
- o3(0xE6,0xAC,0xA1), o3(0xE6,0xBB,0x8B),
- o3(0xE6,0xB2,0xBB), o3(0xE7,0x88,0xBE),
- o3(0xE7,0x92,0xBD), o3(0xE7,0x97,0x94),
- o3(0xE7,0xA3,0x81), o3(0xE7,0xA4,0xBA),
- o3(0xE8,0x80,0x8C), o3(0xE8,0x80,0xB3),
- o3(0xE8,0x87,0xAA), o3(0xE8,0x92,0x94),
- o3(0xE8,0xBE,0x9E), o3(0xE6,0xB1,0x90),
- o3(0xE9,0xB9,0xBF), o3(0xE5,0xBC,0x8F),
- o3(0xE8,0xAD,0x98), o3(0xE9,0xB4,0xAB),
- o3(0xE7,0xAB,0xBA), o3(0xE8,0xBB,0xB8),
- o3(0xE5,0xAE,0x8D), o3(0xE9,0x9B,0xAB),
- o3(0xE4,0xB8,0x83), o3(0xE5,0x8F,0xB1),
- o3(0xE5,0x9F,0xB7), o3(0xE5,0xA4,0xB1),
- o3(0xE5,0xAB,0x89), o3(0xE5,0xAE,0xA4),
- o3(0xE6,0x82,0x89), o3(0xE6,0xB9,0xBF),
- o3(0xE6,0xBC,0x86), o3(0xE7,0x96,0xBE),
- o3(0xE8,0xB3,0xAA), o3(0xE5,0xAE,0x9F),
- o3(0xE8,0x94,0x80), o3(0xE7,0xAF,0xA0),
- o3(0xE5,0x81,0xB2), o3(0xE6,0x9F,0xB4),
- o3(0xE8,0x8A,0x9D), o3(0xE5,0xB1,0xA1),
- o3(0xE8,0x95,0x8A), o3(0xE7,0xB8,0x9E),
- o3(0xE8,0x88,0x8E), o3(0xE5,0x86,0x99),
- o3(0xE5,0xB0,0x84), o3(0xE6,0x8D,0xA8),
- o3(0xE8,0xB5,0xA6), o3(0xE6,0x96,0x9C),
- o3(0xE7,0x85,0xAE), o3(0xE7,0xA4,0xBE),
- o3(0xE7,0xB4,0x97), o3(0xE8,0x80,0x85),
- o3(0xE8,0xAC,0x9D), o3(0xE8,0xBB,0x8A),
- o3(0xE9,0x81,0xAE), o3(0xE8,0x9B,0x87),
- o3(0xE9,0x82,0xAA), o3(0xE5,0x80,0x9F),
- o3(0xE5,0x8B,0xBA), o3(0xE5,0xB0,0xBA),
- o3(0xE6,0x9D,0x93), o3(0xE7,0x81,0xBC),
- o3(0xE7,0x88,0xB5), o3(0xE9,0x85,0x8C),
- o3(0xE9,0x87,0x88), o3(0xE9,0x8C,0xAB),
- o3(0xE8,0x8B,0xA5), o3(0xE5,0xAF,0x82),
- o3(0xE5,0xBC,0xB1), o3(0xE6,0x83,0xB9),
- o3(0xE4,0xB8,0xBB), o3(0xE5,0x8F,0x96),
- o3(0xE5,0xAE,0x88), o3(0xE6,0x89,0x8B),
- o3(0xE6,0x9C,0xB1), o3(0xE6,0xAE,0x8A),
- o3(0xE7,0x8B,0xA9), o3(0xE7,0x8F,0xA0),
- o3(0xE7,0xA8,0xAE), o3(0xE8,0x85,0xAB),
- o3(0xE8,0xB6,0xA3), o3(0xE9,0x85,0x92),
- o3(0xE9,0xA6,0x96), o3(0xE5,0x84,0x92),
- o3(0xE5,0x8F,0x97), o3(0xE5,0x91,0xAA),
- o3(0xE5,0xAF,0xBF), o3(0xE6,0x8E,0x88),
- o3(0xE6,0xA8,0xB9), o3(0xE7,0xB6,0xAC),
- o3(0xE9,0x9C,0x80), o3(0xE5,0x9B,0x9A),
- o3(0xE5,0x8F,0x8E), o3(0xE5,0x91,0xA8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_BC = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_BC_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_BD_infos[95] = {
- o3(0xE5,0xAE,0x97), o3(0xE5,0xB0,0xB1),
- o3(0xE5,0xB7,0x9E), o3(0xE4,0xBF,0xAE),
- o3(0xE6,0x84,0x81), o3(0xE6,0x8B,0xBE),
- o3(0xE6,0xB4,0xB2), o3(0xE7,0xA7,0x80),
- o3(0xE7,0xA7,0x8B), o3(0xE7,0xB5,0x82),
- o3(0xE7,0xB9,0x8D), o3(0xE7,0xBF,0x92),
- o3(0xE8,0x87,0xAD), o3(0xE8,0x88,0x9F),
- o3(0xE8,0x92,0x90), o3(0xE8,0xA1,0x86),
- o3(0xE8,0xA5,0xB2), o3(0xE8,0xAE,0x90),
- o3(0xE8,0xB9,0xB4), o3(0xE8,0xBC,0xAF),
- o3(0xE9,0x80,0xB1), o3(0xE9,0x85,0x8B),
- o3(0xE9,0x85,0xAC), o3(0xE9,0x9B,0x86),
- o3(0xE9,0x86,0x9C), o3(0xE4,0xBB,0x80),
- o3(0xE4,0xBD,0x8F), o3(0xE5,0x85,0x85),
- o3(0xE5,0x8D,0x81), o3(0xE5,0xBE,0x93),
- o3(0xE6,0x88,0x8E), o3(0xE6,0x9F,0x94),
- o3(0xE6,0xB1,0x81), o3(0xE6,0xB8,0x8B),
- o3(0xE7,0x8D,0xA3), o3(0xE7,0xB8,0xA6),
- o3(0xE9,0x87,0x8D), o3(0xE9,0x8A,0x83),
- o3(0xE5,0x8F,0x94), o3(0xE5,0xA4,0x99),
- o3(0xE5,0xAE,0xBF), o3(0xE6,0xB7,0x91),
- o3(0xE7,0xA5,0x9D), o3(0xE7,0xB8,0xAE),
- o3(0xE7,0xB2,0x9B), o3(0xE5,0xA1,0xBE),
- o3(0xE7,0x86,0x9F), o3(0xE5,0x87,0xBA),
- o3(0xE8,0xA1,0x93), o3(0xE8,0xBF,0xB0),
- o3(0xE4,0xBF,0x8A), o3(0xE5,0xB3,0xBB),
- o3(0xE6,0x98,0xA5), o3(0xE7,0x9E,0xAC),
- o3(0xE7,0xAB,0xA3), o3(0xE8,0x88,0x9C),
- o3(0xE9,0xA7,0xBF), o3(0xE5,0x87,0x86),
- o3(0xE5,0xBE,0xAA), o3(0xE6,0x97,0xAC),
- o3(0xE6,0xA5,0xAF), o3(0xE6,0xAE,0x89),
- o3(0xE6,0xB7,0xB3), o3(0xE6,0xBA,0x96),
- o3(0xE6,0xBD,0xA4), o3(0xE7,0x9B,0xBE),
- o3(0xE7,0xB4,0x94), o3(0xE5,0xB7,0xA1),
- o3(0xE9,0x81,0xB5), o3(0xE9,0x86,0x87),
- o3(0xE9,0xA0,0x86), o3(0xE5,0x87,0xA6),
- o3(0xE5,0x88,0x9D), o3(0xE6,0x89,0x80),
- o3(0xE6,0x9A,0x91), o3(0xE6,0x9B,0x99),
- o3(0xE6,0xB8,0x9A), o3(0xE5,0xBA,0xB6),
- o3(0xE7,0xB7,0x92), o3(0xE7,0xBD,0xB2),
- o3(0xE6,0x9B,0xB8), o3(0xE8,0x96,0xAF),
- o3(0xE8,0x97,0xB7), o3(0xE8,0xAB,0xB8),
- o3(0xE5,0x8A,0xA9), o3(0xE5,0x8F,0x99),
- o3(0xE5,0xA5,0xB3), o3(0xE5,0xBA,0x8F),
- o3(0xE5,0xBE,0x90), o3(0xE6,0x81,0x95),
- o3(0xE9,0x8B,0xA4), o3(0xE9,0x99,0xA4),
- o3(0xE5,0x82,0xB7), o3(0xE5,0x84,0x9F),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_BD = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_BD_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_BE_infos[95] = {
- o3(0xE5,0x8B,0x9D), o3(0xE5,0x8C,0xA0),
- o3(0xE5,0x8D,0x87), o3(0xE5,0x8F,0xAC),
- o3(0xE5,0x93,0xA8), o3(0xE5,0x95,0x86),
- o3(0xE5,0x94,0xB1), o3(0xE5,0x98,0x97),
- o3(0xE5,0xA5,0xA8), o3(0xE5,0xA6,0xBE),
- o3(0xE5,0xA8,0xBC), o3(0xE5,0xAE,0xB5),
- o3(0xE5,0xB0,0x86), o3(0xE5,0xB0,0x8F),
- o3(0xE5,0xB0,0x91), o3(0xE5,0xB0,0x9A),
- o3(0xE5,0xBA,0x84), o3(0xE5,0xBA,0x8A),
- o3(0xE5,0xBB,0xA0), o3(0xE5,0xBD,0xB0),
- o3(0xE6,0x89,0xBF), o3(0xE6,0x8A,0x84),
- o3(0xE6,0x8B,0x9B), o3(0xE6,0x8E,0x8C),
- o3(0xE6,0x8D,0xB7), o3(0xE6,0x98,0x87),
- o3(0xE6,0x98,0x8C), o3(0xE6,0x98,0xAD),
- o3(0xE6,0x99,0xB6), o3(0xE6,0x9D,0xBE),
- o3(0xE6,0xA2,0xA2), o3(0xE6,0xA8,0x9F),
- o3(0xE6,0xA8,0xB5), o3(0xE6,0xB2,0xBC),
- o3(0xE6,0xB6,0x88), o3(0xE6,0xB8,0x89),
- o3(0xE6,0xB9,0x98), o3(0xE7,0x84,0xBC),
- o3(0xE7,0x84,0xA6), o3(0xE7,0x85,0xA7),
- o3(0xE7,0x97,0x87), o3(0xE7,0x9C,0x81),
- o3(0xE7,0xA1,0x9D), o3(0xE7,0xA4,0x81),
- o3(0xE7,0xA5,0xA5), o3(0xE7,0xA7,0xB0),
- o3(0xE7,0xAB,0xA0), o3(0xE7,0xAC,0x91),
- o3(0xE7,0xB2,0xA7), o3(0xE7,0xB4,0xB9),
- o3(0xE8,0x82,0x96), o3(0xE8,0x8F,0x96),
- o3(0xE8,0x92,0x8B), o3(0xE8,0x95,0x89),
- o3(0xE8,0xA1,0x9D), o3(0xE8,0xA3,0xB3),
- o3(0xE8,0xA8,0x9F), o3(0xE8,0xA8,0xBC),
- o3(0xE8,0xA9,0x94), o3(0xE8,0xA9,0xB3),
- o3(0xE8,0xB1,0xA1), o3(0xE8,0xB3,0x9E),
- o3(0xE9,0x86,0xA4), o3(0xE9,0x89,0xA6),
- o3(0xE9,0x8D,0xBE), o3(0xE9,0x90,0x98),
- o3(0xE9,0x9A,0x9C), o3(0xE9,0x9E,0x98),
- o3(0xE4,0xB8,0x8A), o3(0xE4,0xB8,0x88),
- o3(0xE4,0xB8,0x9E), o3(0xE4,0xB9,0x97),
- o3(0xE5,0x86,0x97), o3(0xE5,0x89,0xB0),
- o3(0xE5,0x9F,0x8E), o3(0xE5,0xA0,0xB4),
- o3(0xE5,0xA3,0x8C), o3(0xE5,0xAC,0xA2),
- o3(0xE5,0xB8,0xB8), o3(0xE6,0x83,0x85),
- o3(0xE6,0x93,0xBE), o3(0xE6,0x9D,0xA1),
- o3(0xE6,0x9D,0x96), o3(0xE6,0xB5,0x84),
- o3(0xE7,0x8A,0xB6), o3(0xE7,0x95,0xB3),
- o3(0xE7,0xA9,0xA3), o3(0xE8,0x92,0xB8),
- o3(0xE8,0xAD,0xB2), o3(0xE9,0x86,0xB8),
- o3(0xE9,0x8C,0xA0), o3(0xE5,0x98,0xB1),
- o3(0xE5,0x9F,0xB4), o3(0xE9,0xA3,0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_BE = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_BE_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_BF_infos[95] = {
- o3(0xE6,0x8B,0xAD), o3(0xE6,0xA4,0x8D),
- o3(0xE6,0xAE,0x96), o3(0xE7,0x87,0xAD),
- o3(0xE7,0xB9,0x94), o3(0xE8,0x81,0xB7),
- o3(0xE8,0x89,0xB2), o3(0xE8,0xA7,0xA6),
- o3(0xE9,0xA3,0x9F), o3(0xE8,0x9D,0x95),
- o3(0xE8,0xBE,0xB1), o3(0xE5,0xB0,0xBB),
- o3(0xE4,0xBC,0xB8), o3(0xE4,0xBF,0xA1),
- o3(0xE4,0xBE,0xB5), o3(0xE5,0x94,0x87),
- o3(0xE5,0xA8,0xA0), o3(0xE5,0xAF,0x9D),
- o3(0xE5,0xAF,0xA9), o3(0xE5,0xBF,0x83),
- o3(0xE6,0x85,0x8E), o3(0xE6,0x8C,0xAF),
- o3(0xE6,0x96,0xB0), o3(0xE6,0x99,0x8B),
- o3(0xE6,0xA3,0xAE), o3(0xE6,0xA6,0x9B),
- o3(0xE6,0xB5,0xB8), o3(0xE6,0xB7,0xB1),
- o3(0xE7,0x94,0xB3), o3(0xE7,0x96,0xB9),
- o3(0xE7,0x9C,0x9F), o3(0xE7,0xA5,0x9E),
- o3(0xE7,0xA7,0xA6), o3(0xE7,0xB4,0xB3),
- o3(0xE8,0x87,0xA3), o3(0xE8,0x8A,0xAF),
- o3(0xE8,0x96,0xAA), o3(0xE8,0xA6,0xAA),
- o3(0xE8,0xA8,0xBA), o3(0xE8,0xBA,0xAB),
- o3(0xE8,0xBE,0x9B), o3(0xE9,0x80,0xB2),
- o3(0xE9,0x87,0x9D), o3(0xE9,0x9C,0x87),
- o3(0xE4,0xBA,0xBA), o3(0xE4,0xBB,0x81),
- o3(0xE5,0x88,0x83), o3(0xE5,0xA1,0xB5),
- o3(0xE5,0xA3,0xAC), o3(0xE5,0xB0,0x8B),
- o3(0xE7,0x94,0x9A), o3(0xE5,0xB0,0xBD),
- o3(0xE8,0x85,0x8E), o3(0xE8,0xA8,0x8A),
- o3(0xE8,0xBF,0x85), o3(0xE9,0x99,0xA3),
- o3(0xE9,0x9D,0xAD), o3(0xE7,0xAC,0xA5),
- o3(0xE8,0xAB,0x8F), o3(0xE9,0xA0,0x88),
- o3(0xE9,0x85,0xA2), o3(0xE5,0x9B,0xB3),
- o3(0xE5,0x8E,0xA8), o3(0xE9,0x80,0x97),
- o3(0xE5,0x90,0xB9), o3(0xE5,0x9E,0x82),
- o3(0xE5,0xB8,0xA5), o3(0xE6,0x8E,0xA8),
- o3(0xE6,0xB0,0xB4), o3(0xE7,0x82,0x8A),
- o3(0xE7,0x9D,0xA1), o3(0xE7,0xB2,0x8B),
- o3(0xE7,0xBF,0xA0), o3(0xE8,0xA1,0xB0),
- o3(0xE9,0x81,0x82), o3(0xE9,0x85,0x94),
- o3(0xE9,0x8C,0x90), o3(0xE9,0x8C,0x98),
- o3(0xE9,0x9A,0x8F), o3(0xE7,0x91,0x9E),
- o3(0xE9,0xAB,0x84), o3(0xE5,0xB4,0x87),
- o3(0xE5,0xB5,0xA9), o3(0xE6,0x95,0xB0),
- o3(0xE6,0x9E,0xA2), o3(0xE8,0xB6,0xA8),
- o3(0xE9,0x9B,0x9B), o3(0xE6,0x8D,0xAE),
- o3(0xE6,0x9D,0x89), o3(0xE6,0xA4,0x99),
- o3(0xE8,0x8F,0x85), o3(0xE9,0xA0,0x97),
- o3(0xE9,0x9B,0x80), o3(0xE8,0xA3,0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_BF = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_BF_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C0_infos[95] = {
- o3(0xE6,0xBE,0x84), o3(0xE6,0x91,0xBA),
- o3(0xE5,0xAF,0xB8), o3(0xE4,0xB8,0x96),
- o3(0xE7,0x80,0xAC), o3(0xE7,0x95,0x9D),
- o3(0xE6,0x98,0xAF), o3(0xE5,0x87,0x84),
- o3(0xE5,0x88,0xB6), o3(0xE5,0x8B,0xA2),
- o3(0xE5,0xA7,0x93), o3(0xE5,0xBE,0x81),
- o3(0xE6,0x80,0xA7), o3(0xE6,0x88,0x90),
- o3(0xE6,0x94,0xBF), o3(0xE6,0x95,0xB4),
- o3(0xE6,0x98,0x9F), o3(0xE6,0x99,0xB4),
- o3(0xE6,0xA3,0xB2), o3(0xE6,0xA0,0x96),
- o3(0xE6,0xAD,0xA3), o3(0xE6,0xB8,0x85),
- o3(0xE7,0x89,0xB2), o3(0xE7,0x94,0x9F),
- o3(0xE7,0x9B,0x9B), o3(0xE7,0xB2,0xBE),
- o3(0xE8,0x81,0x96), o3(0xE5,0xA3,0xB0),
- o3(0xE8,0xA3,0xBD), o3(0xE8,0xA5,0xBF),
- o3(0xE8,0xAA,0xA0), o3(0xE8,0xAA,0x93),
- o3(0xE8,0xAB,0x8B), o3(0xE9,0x80,0x9D),
- o3(0xE9,0x86,0x92), o3(0xE9,0x9D,0x92),
- o3(0xE9,0x9D,0x99), o3(0xE6,0x96,0x89),
- o3(0xE7,0xA8,0x8E), o3(0xE8,0x84,0x86),
- o3(0xE9,0x9A,0xBB), o3(0xE5,0xB8,0xAD),
- o3(0xE6,0x83,0x9C), o3(0xE6,0x88,0x9A),
- o3(0xE6,0x96,0xA5), o3(0xE6,0x98,0x94),
- o3(0xE6,0x9E,0x90), o3(0xE7,0x9F,0xB3),
- o3(0xE7,0xA9,0x8D), o3(0xE7,0xB1,0x8D),
- o3(0xE7,0xB8,0xBE), o3(0xE8,0x84,0x8A),
- o3(0xE8,0xB2,0xAC), o3(0xE8,0xB5,0xA4),
- o3(0xE8,0xB7,0xA1), o3(0xE8,0xB9,0x9F),
- o3(0xE7,0xA2,0xA9), o3(0xE5,0x88,0x87),
- o3(0xE6,0x8B,0x99), o3(0xE6,0x8E,0xA5),
- o3(0xE6,0x91,0x82), o3(0xE6,0x8A,0x98),
- o3(0xE8,0xA8,0xAD), o3(0xE7,0xAA,0x83),
- o3(0xE7,0xAF,0x80), o3(0xE8,0xAA,0xAC),
- o3(0xE9,0x9B,0xAA), o3(0xE7,0xB5,0xB6),
- o3(0xE8,0x88,0x8C), o3(0xE8,0x9D,0x89),
- o3(0xE4,0xBB,0x99), o3(0xE5,0x85,0x88),
- o3(0xE5,0x8D,0x83), o3(0xE5,0x8D,0xA0),
- o3(0xE5,0xAE,0xA3), o3(0xE5,0xB0,0x82),
- o3(0xE5,0xB0,0x96), o3(0xE5,0xB7,0x9D),
- o3(0xE6,0x88,0xA6), o3(0xE6,0x89,0x87),
- o3(0xE6,0x92,0xB0), o3(0xE6,0xA0,0x93),
- o3(0xE6,0xA0,0xB4), o3(0xE6,0xB3,0x89),
- o3(0xE6,0xB5,0x85), o3(0xE6,0xB4,0x97),
- o3(0xE6,0x9F,0x93), o3(0xE6,0xBD,0x9C),
- o3(0xE7,0x85,0x8E), o3(0xE7,0x85,0xBD),
- o3(0xE6,0x97,0x8B), o3(0xE7,0xA9,0xBF),
- o3(0xE7,0xAE,0xAD), o3(0xE7,0xB7,0x9A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C0 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C0_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C1_infos[95] = {
- o3(0xE7,0xB9,0x8A), o3(0xE7,0xBE,0xA8),
- o3(0xE8,0x85,0xBA), o3(0xE8,0x88,0x9B),
- o3(0xE8,0x88,0xB9), o3(0xE8,0x96,0xA6),
- o3(0xE8,0xA9,0xAE), o3(0xE8,0xB3,0x8E),
- o3(0xE8,0xB7,0xB5), o3(0xE9,0x81,0xB8),
- o3(0xE9,0x81,0xB7), o3(0xE9,0x8A,0xAD),
- o3(0xE9,0x8A,0x91), o3(0xE9,0x96,0x83),
- o3(0xE9,0xAE,0xAE), o3(0xE5,0x89,0x8D),
- o3(0xE5,0x96,0x84), o3(0xE6,0xBC,0xB8),
- o3(0xE7,0x84,0xB6), o3(0xE5,0x85,0xA8),
- o3(0xE7,0xA6,0x85), o3(0xE7,0xB9,0x95),
- o3(0xE8,0x86,0xB3), o3(0xE7,0xB3,0x8E),
- o3(0xE5,0x99,0x8C), o3(0xE5,0xA1,0x91),
- o3(0xE5,0xB2,0xA8), o3(0xE6,0x8E,0xAA),
- o3(0xE6,0x9B,0xBE), o3(0xE6,0x9B,0xBD),
- o3(0xE6,0xA5,0x9A), o3(0xE7,0x8B,0x99),
- o3(0xE7,0x96,0x8F), o3(0xE7,0x96,0x8E),
- o3(0xE7,0xA4,0x8E), o3(0xE7,0xA5,0x96),
- o3(0xE7,0xA7,0x9F), o3(0xE7,0xB2,0x97),
- o3(0xE7,0xB4,0xA0), o3(0xE7,0xB5,0x84),
- o3(0xE8,0x98,0x87), o3(0xE8,0xA8,0xB4),
- o3(0xE9,0x98,0xBB), o3(0xE9,0x81,0xA1),
- o3(0xE9,0xBC,0xA0), o3(0xE5,0x83,0xA7),
- o3(0xE5,0x89,0xB5), o3(0xE5,0x8F,0x8C),
- o3(0xE5,0x8F,0xA2), o3(0xE5,0x80,0x89),
- o3(0xE5,0x96,0xAA), o3(0xE5,0xA3,0xAE),
- o3(0xE5,0xA5,0x8F), o3(0xE7,0x88,0xBD),
- o3(0xE5,0xAE,0x8B), o3(0xE5,0xB1,0xA4),
- o3(0xE5,0x8C,0x9D), o3(0xE6,0x83,0xA3),
- o3(0xE6,0x83,0xB3), o3(0xE6,0x8D,0x9C),
- o3(0xE6,0x8E,0x83), o3(0xE6,0x8C,0xBF),
- o3(0xE6,0x8E,0xBB), o3(0xE6,0x93,0x8D),
- o3(0xE6,0x97,0xA9), o3(0xE6,0x9B,0xB9),
- o3(0xE5,0xB7,0xA3), o3(0xE6,0xA7,0x8D),
- o3(0xE6,0xA7,0xBD), o3(0xE6,0xBC,0x95),
- o3(0xE7,0x87,0xA5), o3(0xE4,0xBA,0x89),
- o3(0xE7,0x97,0xA9), o3(0xE7,0x9B,0xB8),
- o3(0xE7,0xAA,0x93), o3(0xE7,0xB3,0x9F),
- o3(0xE7,0xB7,0x8F), o3(0xE7,0xB6,0x9C),
- o3(0xE8,0x81,0xA1), o3(0xE8,0x8D,0x89),
- o3(0xE8,0x8D,0x98), o3(0xE8,0x91,0xAC),
- o3(0xE8,0x92,0xBC), o3(0xE8,0x97,0xBB),
- o3(0xE8,0xA3,0x85), o3(0xE8,0xB5,0xB0),
- o3(0xE9,0x80,0x81), o3(0xE9,0x81,0xAD),
- o3(0xE9,0x8E,0x97), o3(0xE9,0x9C,0x9C),
- o3(0xE9,0xA8,0x92), o3(0xE5,0x83,0x8F),
- o3(0xE5,0xA2,0x97), o3(0xE6,0x86,0x8E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C1 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C1_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C2_infos[95] = {
- o3(0xE8,0x87,0x93), o3(0xE8,0x94,0xB5),
- o3(0xE8,0xB4,0x88), o3(0xE9,0x80,0xA0),
- o3(0xE4,0xBF,0x83), o3(0xE5,0x81,0xB4),
- o3(0xE5,0x89,0x87), o3(0xE5,0x8D,0xB3),
- o3(0xE6,0x81,0xAF), o3(0xE6,0x8D,0x89),
- o3(0xE6,0x9D,0x9F), o3(0xE6,0xB8,0xAC),
- o3(0xE8,0xB6,0xB3), o3(0xE9,0x80,0x9F),
- o3(0xE4,0xBF,0x97), o3(0xE5,0xB1,0x9E),
- o3(0xE8,0xB3,0x8A), o3(0xE6,0x97,0x8F),
- o3(0xE7,0xB6,0x9A), o3(0xE5,0x8D,0x92),
- o3(0xE8,0xA2,0x96), o3(0xE5,0x85,0xB6),
- o3(0xE6,0x8F,0x83), o3(0xE5,0xAD,0x98),
- o3(0xE5,0xAD,0xAB), o3(0xE5,0xB0,0x8A),
- o3(0xE6,0x90,0x8D), o3(0xE6,0x9D,0x91),
- o3(0xE9,0x81,0x9C), o3(0xE4,0xBB,0x96),
- o3(0xE5,0xA4,0x9A), o3(0xE5,0xA4,0xAA),
- o3(0xE6,0xB1,0xB0), o3(0xE8,0xA9,0x91),
- o3(0xE5,0x94,0xBE), o3(0xE5,0xA0,0x95),
- o3(0xE5,0xA6,0xA5), o3(0xE6,0x83,0xB0),
- o3(0xE6,0x89,0x93), o3(0xE6,0x9F,0x81),
- o3(0xE8,0x88,0xB5), o3(0xE6,0xA5,0x95),
- o3(0xE9,0x99,0x80), o3(0xE9,0xA7,0x84),
- o3(0xE9,0xA8,0xA8), o3(0xE4,0xBD,0x93),
- o3(0xE5,0xA0,0x86), o3(0xE5,0xAF,0xBE),
- o3(0xE8,0x80,0x90), o3(0xE5,0xB2,0xB1),
- o3(0xE5,0xB8,0xAF), o3(0xE5,0xBE,0x85),
- o3(0xE6,0x80,0xA0), o3(0xE6,0x85,0x8B),
- o3(0xE6,0x88,0xB4), o3(0xE6,0x9B,0xBF),
- o3(0xE6,0xB3,0xB0), o3(0xE6,0xBB,0x9E),
- o3(0xE8,0x83,0x8E), o3(0xE8,0x85,0xBF),
- o3(0xE8,0x8B,0x94), o3(0xE8,0xA2,0x8B),
- o3(0xE8,0xB2,0xB8), o3(0xE9,0x80,0x80),
- o3(0xE9,0x80,0xAE), o3(0xE9,0x9A,0x8A),
- o3(0xE9,0xBB,0x9B), o3(0xE9,0xAF,0x9B),
- o3(0xE4,0xBB,0xA3), o3(0xE5,0x8F,0xB0),
- o3(0xE5,0xA4,0xA7), o3(0xE7,0xAC,0xAC),
- o3(0xE9,0x86,0x8D), o3(0xE9,0xA1,0x8C),
- o3(0xE9,0xB7,0xB9), o3(0xE6,0xBB,0x9D),
- o3(0xE7,0x80,0xA7), o3(0xE5,0x8D,0x93),
- o3(0xE5,0x95,0x84), o3(0xE5,0xAE,0x85),
- o3(0xE6,0x89,0x98), o3(0xE6,0x8A,0x9E),
- o3(0xE6,0x8B,0x93), o3(0xE6,0xB2,0xA2),
- o3(0xE6,0xBF,0xAF), o3(0xE7,0x90,0xA2),
- o3(0xE8,0xA8,0x97), o3(0xE9,0x90,0xB8),
- o3(0xE6,0xBF,0x81), o3(0xE8,0xAB,0xBE),
- o3(0xE8,0x8C,0xB8), o3(0xE5,0x87,0xA7),
- o3(0xE8,0x9B,0xB8), o3(0xE5,0x8F,0xAA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C2 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C2_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C3_infos[95] = {
- o3(0xE5,0x8F,0xA9), o3(0xE4,0xBD,0x86),
- o3(0xE9,0x81,0x94), o3(0xE8,0xBE,0xB0),
- o3(0xE5,0xA5,0xAA), o3(0xE8,0x84,0xB1),
- o3(0xE5,0xB7,0xBD), o3(0xE7,0xAB,0xAA),
- o3(0xE8,0xBE,0xBF), o3(0xE6,0xA3,0x9A),
- o3(0xE8,0xB0,0xB7), o3(0xE7,0x8B,0xB8),
- o3(0xE9,0xB1,0x88), o3(0xE6,0xA8,0xBD),
- o3(0xE8,0xAA,0xB0), o3(0xE4,0xB8,0xB9),
- o3(0xE5,0x8D,0x98), o3(0xE5,0x98,0x86),
- o3(0xE5,0x9D,0xA6), o3(0xE6,0x8B,0x85),
- o3(0xE6,0x8E,0xA2), o3(0xE6,0x97,0xA6),
- o3(0xE6,0xAD,0x8E), o3(0xE6,0xB7,0xA1),
- o3(0xE6,0xB9,0x9B), o3(0xE7,0x82,0xAD),
- o3(0xE7,0x9F,0xAD), o3(0xE7,0xAB,0xAF),
- o3(0xE7,0xAE,0xAA), o3(0xE7,0xB6,0xBB),
- o3(0xE8,0x80,0xBD), o3(0xE8,0x83,0x86),
- o3(0xE8,0x9B,0x8B), o3(0xE8,0xAA,0x95),
- o3(0xE9,0x8D,0x9B), o3(0xE5,0x9B,0xA3),
- o3(0xE5,0xA3,0x87), o3(0xE5,0xBC,0xBE),
- o3(0xE6,0x96,0xAD), o3(0xE6,0x9A,0x96),
- o3(0xE6,0xAA,0x80), o3(0xE6,0xAE,0xB5),
- o3(0xE7,0x94,0xB7), o3(0xE8,0xAB,0x87),
- o3(0xE5,0x80,0xA4), o3(0xE7,0x9F,0xA5),
- o3(0xE5,0x9C,0xB0), o3(0xE5,0xBC,0x9B),
- o3(0xE6,0x81,0xA5), o3(0xE6,0x99,0xBA),
- o3(0xE6,0xB1,0xA0), o3(0xE7,0x97,0xB4),
- o3(0xE7,0xA8,0x9A), o3(0xE7,0xBD,0xAE),
- o3(0xE8,0x87,0xB4), o3(0xE8,0x9C,0x98),
- o3(0xE9,0x81,0x85), o3(0xE9,0xA6,0xB3),
- o3(0xE7,0xAF,0x89), o3(0xE7,0x95,0x9C),
- o3(0xE7,0xAB,0xB9), o3(0xE7,0xAD,0x91),
- o3(0xE8,0x93,0x84), o3(0xE9,0x80,0x90),
- o3(0xE7,0xA7,0xA9), o3(0xE7,0xAA,0x92),
- o3(0xE8,0x8C,0xB6), o3(0xE5,0xAB,0xA1),
- o3(0xE7,0x9D,0x80), o3(0xE4,0xB8,0xAD),
- o3(0xE4,0xBB,0xB2), o3(0xE5,0xAE,0x99),
- o3(0xE5,0xBF,0xA0), o3(0xE6,0x8A,0xBD),
- o3(0xE6,0x98,0xBC), o3(0xE6,0x9F,0xB1),
- o3(0xE6,0xB3,0xA8), o3(0xE8,0x99,0xAB),
- o3(0xE8,0xA1,0xB7), o3(0xE8,0xA8,0xBB),
- o3(0xE9,0x85,0x8E), o3(0xE9,0x8B,0xB3),
- o3(0xE9,0xA7,0x90), o3(0xE6,0xA8,0x97),
- o3(0xE7,0x80,0xA6), o3(0xE7,0x8C,0xAA),
- o3(0xE8,0x8B,0xA7), o3(0xE8,0x91,0x97),
- o3(0xE8,0xB2,0xAF), o3(0xE4,0xB8,0x81),
- o3(0xE5,0x85,0x86), o3(0xE5,0x87,0x8B),
- o3(0xE5,0x96,0x8B), o3(0xE5,0xAF,0xB5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C3 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C3_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C4_infos[95] = {
- o3(0xE5,0xB8,0x96), o3(0xE5,0xB8,0xB3),
- o3(0xE5,0xBA,0x81), o3(0xE5,0xBC,0x94),
- o3(0xE5,0xBC,0xB5), o3(0xE5,0xBD,0xAB),
- o3(0xE5,0xBE,0xB4), o3(0xE6,0x87,0xB2),
- o3(0xE6,0x8C,0x91), o3(0xE6,0x9A,0xA2),
- o3(0xE6,0x9C,0x9D), o3(0xE6,0xBD,0xAE),
- o3(0xE7,0x89,0x92), o3(0xE7,0x94,0xBA),
- o3(0xE7,0x9C,0xBA), o3(0xE8,0x81,0xB4),
- o3(0xE8,0x84,0xB9), o3(0xE8,0x85,0xB8),
- o3(0xE8,0x9D,0xB6), o3(0xE8,0xAA,0xBF),
- o3(0xE8,0xAB,0x9C), o3(0xE8,0xB6,0x85),
- o3(0xE8,0xB7,0xB3), o3(0xE9,0x8A,0x9A),
- o3(0xE9,0x95,0xB7), o3(0xE9,0xA0,0x82),
- o3(0xE9,0xB3,0xA5), o3(0xE5,0x8B,0x85),
- o3(0xE6,0x8D,0x97), o3(0xE7,0x9B,0xB4),
- o3(0xE6,0x9C,0x95), o3(0xE6,0xB2,0x88),
- o3(0xE7,0x8F,0x8D), o3(0xE8,0xB3,0x83),
- o3(0xE9,0x8E,0xAE), o3(0xE9,0x99,0xB3),
- o3(0xE6,0xB4,0xA5), o3(0xE5,0xA2,0x9C),
- o3(0xE6,0xA4,0x8E), o3(0xE6,0xA7,0x8C),
- o3(0xE8,0xBF,0xBD), o3(0xE9,0x8E,0x9A),
- o3(0xE7,0x97,0x9B), o3(0xE9,0x80,0x9A),
- o3(0xE5,0xA1,0x9A), o3(0xE6,0xA0,0x82),
- o3(0xE6,0x8E,0xB4), o3(0xE6,0xA7,0xBB),
- o3(0xE4,0xBD,0x83), o3(0xE6,0xBC,0xAC),
- o3(0xE6,0x9F,0x98), o3(0xE8,0xBE,0xBB),
- o3(0xE8,0x94,0xA6), o3(0xE7,0xB6,0xB4),
- o3(0xE9,0x8D,0x94), o3(0xE6,0xA4,0xBF),
- o3(0xE6,0xBD,0xB0), o3(0xE5,0x9D,0xAA),
- o3(0xE5,0xA3,0xB7), o3(0xE5,0xAC,0xAC),
- o3(0xE7,0xB4,0xAC), o3(0xE7,0x88,0xAA),
- o3(0xE5,0x90,0x8A), o3(0xE9,0x87,0xA3),
- o3(0xE9,0xB6,0xB4), o3(0xE4,0xBA,0xAD),
- o3(0xE4,0xBD,0x8E), o3(0xE5,0x81,0x9C),
- o3(0xE5,0x81,0xB5), o3(0xE5,0x89,0x83),
- o3(0xE8,0xB2,0x9E), o3(0xE5,0x91,0x88),
- o3(0xE5,0xA0,0xA4), o3(0xE5,0xAE,0x9A),
- o3(0xE5,0xB8,0x9D), o3(0xE5,0xBA,0x95),
- o3(0xE5,0xBA,0xAD), o3(0xE5,0xBB,0xB7),
- o3(0xE5,0xBC,0x9F), o3(0xE6,0x82,0x8C),
- o3(0xE6,0x8A,0xB5), o3(0xE6,0x8C,0xBA),
- o3(0xE6,0x8F,0x90), o3(0xE6,0xA2,0xAF),
- o3(0xE6,0xB1,0x80), o3(0xE7,0xA2,0x87),
- o3(0xE7,0xA6,0x8E), o3(0xE7,0xA8,0x8B),
- o3(0xE7,0xB7,0xA0), o3(0xE8,0x89,0x87),
- o3(0xE8,0xA8,0x82), o3(0xE8,0xAB,0xA6),
- o3(0xE8,0xB9,0x84), o3(0xE9,0x80,0x93),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C4 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C4_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C5_infos[95] = {
- o3(0xE9,0x82,0xB8), o3(0xE9,0x84,0xAD),
- o3(0xE9,0x87,0x98), o3(0xE9,0xBC,0x8E),
- o3(0xE6,0xB3,0xA5), o3(0xE6,0x91,0x98),
- o3(0xE6,0x93,0xA2), o3(0xE6,0x95,0xB5),
- o3(0xE6,0xBB,0xB4), o3(0xE7,0x9A,0x84),
- o3(0xE7,0xAC,0x9B), o3(0xE9,0x81,0xA9),
- o3(0xE9,0x8F,0x91), o3(0xE6,0xBA,0xBA),
- o3(0xE5,0x93,0xB2), o3(0xE5,0xBE,0xB9),
- o3(0xE6,0x92,0xA4), o3(0xE8,0xBD,0x8D),
- o3(0xE8,0xBF,0xAD), o3(0xE9,0x89,0x84),
- o3(0xE5,0x85,0xB8), o3(0xE5,0xA1,0xAB),
- o3(0xE5,0xA4,0xA9), o3(0xE5,0xB1,0x95),
- o3(0xE5,0xBA,0x97), o3(0xE6,0xB7,0xBB),
- o3(0xE7,0xBA,0x8F), o3(0xE7,0x94,0x9C),
- o3(0xE8,0xB2,0xBC), o3(0xE8,0xBB,0xA2),
- o3(0xE9,0xA1,0x9B), o3(0xE7,0x82,0xB9),
- o3(0xE4,0xBC,0x9D), o3(0xE6,0xAE,0xBF),
- o3(0xE6,0xBE,0xB1), o3(0xE7,0x94,0xB0),
- o3(0xE9,0x9B,0xBB), o3(0xE5,0x85,0x8E),
- o3(0xE5,0x90,0x90), o3(0xE5,0xA0,0xB5),
- o3(0xE5,0xA1,0x97), o3(0xE5,0xA6,0xAC),
- o3(0xE5,0xB1,0xA0), o3(0xE5,0xBE,0x92),
- o3(0xE6,0x96,0x97), o3(0xE6,0x9D,0x9C),
- o3(0xE6,0xB8,0xA1), o3(0xE7,0x99,0xBB),
- o3(0xE8,0x8F,0x9F), o3(0xE8,0xB3,0xAD),
- o3(0xE9,0x80,0x94), o3(0xE9,0x83,0xBD),
- o3(0xE9,0x8D,0x8D), o3(0xE7,0xA0,0xA5),
- o3(0xE7,0xA0,0xBA), o3(0xE5,0x8A,0xAA),
- o3(0xE5,0xBA,0xA6), o3(0xE5,0x9C,0x9F),
- o3(0xE5,0xA5,0xB4), o3(0xE6,0x80,0x92),
- o3(0xE5,0x80,0x92), o3(0xE5,0x85,0x9A),
- o3(0xE5,0x86,0xAC), o3(0xE5,0x87,0x8D),
- o3(0xE5,0x88,0x80), o3(0xE5,0x94,0x90),
- o3(0xE5,0xA1,0x94), o3(0xE5,0xA1,0x98),
- o3(0xE5,0xA5,0x97), o3(0xE5,0xAE,0x95),
- o3(0xE5,0xB3,0xB6), o3(0xE5,0xB6,0x8B),
- o3(0xE6,0x82,0xBC), o3(0xE6,0x8A,0x95),
- o3(0xE6,0x90,0xAD), o3(0xE6,0x9D,0xB1),
- o3(0xE6,0xA1,0x83), o3(0xE6,0xA2,0xBC),
- o3(0xE6,0xA3,0x9F), o3(0xE7,0x9B,0x97),
- o3(0xE6,0xB7,0x98), o3(0xE6,0xB9,0xAF),
- o3(0xE6,0xB6,0x9B), o3(0xE7,0x81,0xAF),
- o3(0xE7,0x87,0x88), o3(0xE5,0xBD,0x93),
- o3(0xE7,0x97,0x98), o3(0xE7,0xA5,0xB7),
- o3(0xE7,0xAD,0x89), o3(0xE7,0xAD,0x94),
- o3(0xE7,0xAD,0x92), o3(0xE7,0xB3,0x96),
- o3(0xE7,0xB5,0xB1), o3(0xE5,0x88,0xB0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C5 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C5_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C6_infos[95] = {
- o3(0xE8,0x91,0xA3), o3(0xE8,0x95,0xA9),
- o3(0xE8,0x97,0xA4), o3(0xE8,0xA8,0x8E),
- o3(0xE8,0xAC,0x84), o3(0xE8,0xB1,0x86),
- o3(0xE8,0xB8,0x8F), o3(0xE9,0x80,0x83),
- o3(0xE9,0x80,0x8F), o3(0xE9,0x90,0x99),
- o3(0xE9,0x99,0xB6), o3(0xE9,0xA0,0xAD),
- o3(0xE9,0xA8,0xB0), o3(0xE9,0x97,0x98),
- o3(0xE5,0x83,0x8D), o3(0xE5,0x8B,0x95),
- o3(0xE5,0x90,0x8C), o3(0xE5,0xA0,0x82),
- o3(0xE5,0xB0,0x8E), o3(0xE6,0x86,0xA7),
- o3(0xE6,0x92,0x9E), o3(0xE6,0xB4,0x9E),
- o3(0xE7,0x9E,0xB3), o3(0xE7,0xAB,0xA5),
- o3(0xE8,0x83,0xB4), o3(0xE8,0x90,0x84),
- o3(0xE9,0x81,0x93), o3(0xE9,0x8A,0x85),
- o3(0xE5,0xB3,0xA0), o3(0xE9,0xB4,0x87),
- o3(0xE5,0x8C,0xBF), o3(0xE5,0xBE,0x97),
- o3(0xE5,0xBE,0xB3), o3(0xE6,0xB6,0x9C),
- o3(0xE7,0x89,0xB9), o3(0xE7,0x9D,0xA3),
- o3(0xE7,0xA6,0xBF), o3(0xE7,0xAF,0xA4),
- o3(0xE6,0xAF,0x92), o3(0xE7,0x8B,0xAC),
- o3(0xE8,0xAA,0xAD), o3(0xE6,0xA0,0x83),
- o3(0xE6,0xA9,0xA1), o3(0xE5,0x87,0xB8),
- o3(0xE7,0xAA,0x81), o3(0xE6,0xA4,0xB4),
- o3(0xE5,0xB1,0x8A), o3(0xE9,0xB3,0xB6),
- o3(0xE8,0x8B,0xAB), o3(0xE5,0xAF,0x85),
- o3(0xE9,0x85,0x89), o3(0xE7,0x80,0x9E),
- o3(0xE5,0x99,0xB8), o3(0xE5,0xB1,0xAF),
- o3(0xE6,0x83,0x87), o3(0xE6,0x95,0xA6),
- o3(0xE6,0xB2,0x8C), o3(0xE8,0xB1,0x9A),
- o3(0xE9,0x81,0x81), o3(0xE9,0xA0,0x93),
- o3(0xE5,0x91,0x91), o3(0xE6,0x9B,0x87),
- o3(0xE9,0x88,0x8D), o3(0xE5,0xA5,0x88),
- o3(0xE9,0x82,0xA3), o3(0xE5,0x86,0x85),
- o3(0xE4,0xB9,0x8D), o3(0xE5,0x87,0xAA),
- o3(0xE8,0x96,0x99), o3(0xE8,0xAC,0x8E),
- o3(0xE7,0x81,0x98), o3(0xE6,0x8D,0xBA),
- o3(0xE9,0x8D,0x8B), o3(0xE6,0xA5,0xA2),
- o3(0xE9,0xA6,0xB4), o3(0xE7,0xB8,0x84),
- o3(0xE7,0x95,0xB7), o3(0xE5,0x8D,0x97),
- o3(0xE6,0xA5,0xA0), o3(0xE8,0xBB,0x9F),
- o3(0xE9,0x9B,0xA3), o3(0xE6,0xB1,0x9D),
- o3(0xE4,0xBA,0x8C), o3(0xE5,0xB0,0xBC),
- o3(0xE5,0xBC,0x90), o3(0xE8,0xBF,0xA9),
- o3(0xE5,0x8C,0x82), o3(0xE8,0xB3,0x91),
- o3(0xE8,0x82,0x89), o3(0xE8,0x99,0xB9),
- o3(0xE5,0xBB,0xBF), o3(0xE6,0x97,0xA5),
- o3(0xE4,0xB9,0xB3), o3(0xE5,0x85,0xA5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C6 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C6_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C7_infos[95] = {
- o3(0xE5,0xA6,0x82), o3(0xE5,0xB0,0xBF),
- o3(0xE9,0x9F,0xAE), o3(0xE4,0xBB,0xBB),
- o3(0xE5,0xA6,0x8A), o3(0xE5,0xBF,0x8D),
- o3(0xE8,0xAA,0x8D), o3(0xE6,0xBF,0xA1),
- o3(0xE7,0xA6,0xB0), o3(0xE7,0xA5,0xA2),
- o3(0xE5,0xAF,0xA7), o3(0xE8,0x91,0xB1),
- o3(0xE7,0x8C,0xAB), o3(0xE7,0x86,0xB1),
- o3(0xE5,0xB9,0xB4), o3(0xE5,0xBF,0xB5),
- o3(0xE6,0x8D,0xBB), o3(0xE6,0x92,0x9A),
- o3(0xE7,0x87,0x83), o3(0xE7,0xB2,0x98),
- o3(0xE4,0xB9,0x83), o3(0xE5,0xBB,0xBC),
- o3(0xE4,0xB9,0x8B), o3(0xE5,0x9F,0x9C),
- o3(0xE5,0x9A,0xA2), o3(0xE6,0x82,0xA9),
- o3(0xE6,0xBF,0x83), o3(0xE7,0xB4,0x8D),
- o3(0xE8,0x83,0xBD), o3(0xE8,0x84,0xB3),
- o3(0xE8,0x86,0xBF), o3(0xE8,0xBE,0xB2),
- o3(0xE8,0xA6,0x97), o3(0xE8,0x9A,0xA4),
- o3(0xE5,0xB7,0xB4), o3(0xE6,0x8A,0x8A),
- o3(0xE6,0x92,0xAD), o3(0xE8,0xA6,0x87),
- o3(0xE6,0x9D,0xB7), o3(0xE6,0xB3,0xA2),
- o3(0xE6,0xB4,0xBE), o3(0xE7,0x90,0xB6),
- o3(0xE7,0xA0,0xB4), o3(0xE5,0xA9,0x86),
- o3(0xE7,0xBD,0xB5), o3(0xE8,0x8A,0xAD),
- o3(0xE9,0xA6,0xAC), o3(0xE4,0xBF,0xB3),
- o3(0xE5,0xBB,0x83), o3(0xE6,0x8B,0x9D),
- o3(0xE6,0x8E,0x92), o3(0xE6,0x95,0x97),
- o3(0xE6,0x9D,0xAF), o3(0xE7,0x9B,0x83),
- o3(0xE7,0x89,0x8C), o3(0xE8,0x83,0x8C),
- o3(0xE8,0x82,0xBA), o3(0xE8,0xBC,0xA9),
- o3(0xE9,0x85,0x8D), o3(0xE5,0x80,0x8D),
- o3(0xE5,0x9F,0xB9), o3(0xE5,0xAA,0x92),
- o3(0xE6,0xA2,0x85), o3(0xE6,0xA5,0xB3),
- o3(0xE7,0x85,0xA4), o3(0xE7,0x8B,0xBD),
- o3(0xE8,0xB2,0xB7), o3(0xE5,0xA3,0xB2),
- o3(0xE8,0xB3,0xA0), o3(0xE9,0x99,0xAA),
- o3(0xE9,0x80,0x99), o3(0xE8,0x9D,0xBF),
- o3(0xE7,0xA7,0xA4), o3(0xE7,0x9F,0xA7),
- o3(0xE8,0x90,0xA9), o3(0xE4,0xBC,0xAF),
- o3(0xE5,0x89,0xA5), o3(0xE5,0x8D,0x9A),
- o3(0xE6,0x8B,0x8D), o3(0xE6,0x9F,0x8F),
- o3(0xE6,0xB3,0x8A), o3(0xE7,0x99,0xBD),
- o3(0xE7,0xAE,0x94), o3(0xE7,0xB2,0x95),
- o3(0xE8,0x88,0xB6), o3(0xE8,0x96,0x84),
- o3(0xE8,0xBF,0xAB), o3(0xE6,0x9B,0x9D),
- o3(0xE6,0xBC,0xA0), o3(0xE7,0x88,0x86),
- o3(0xE7,0xB8,0x9B), o3(0xE8,0x8E,0xAB),
- o3(0xE9,0xA7,0x81), o3(0xE9,0xBA,0xA6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C7 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C7_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C8_infos[95] = {
- o3(0xE5,0x87,0xBD), o3(0xE7,0xAE,0xB1),
- o3(0xE7,0xA1,0xB2), o3(0xE7,0xAE,0xB8),
- o3(0xE8,0x82,0x87), o3(0xE7,0xAD,0x88),
- o3(0xE6,0xAB,0xA8), o3(0xE5,0xB9,0xA1),
- o3(0xE8,0x82,0x8C), o3(0xE7,0x95,0x91),
- o3(0xE7,0x95,0xA0), o3(0xE5,0x85,0xAB),
- o3(0xE9,0x89,0xA2), o3(0xE6,0xBA,0x8C),
- o3(0xE7,0x99,0xBA), o3(0xE9,0x86,0x97),
- o3(0xE9,0xAB,0xAA), o3(0xE4,0xBC,0x90),
- o3(0xE7,0xBD,0xB0), o3(0xE6,0x8A,0x9C),
- o3(0xE7,0xAD,0x8F), o3(0xE9,0x96,0xA5),
- o3(0xE9,0xB3,0xA9), o3(0xE5,0x99,0xBA),
- o3(0xE5,0xA1,0x99), o3(0xE8,0x9B,0xA4),
- o3(0xE9,0x9A,0xBC), o3(0xE4,0xBC,0xB4),
- o3(0xE5,0x88,0xA4), o3(0xE5,0x8D,0x8A),
- o3(0xE5,0x8F,0x8D), o3(0xE5,0x8F,0x9B),
- o3(0xE5,0xB8,0x86), o3(0xE6,0x90,0xAC),
- o3(0xE6,0x96,0x91), o3(0xE6,0x9D,0xBF),
- o3(0xE6,0xB0,0xBE), o3(0xE6,0xB1,0x8E),
- o3(0xE7,0x89,0x88), o3(0xE7,0x8A,0xAF),
- o3(0xE7,0x8F,0xAD), o3(0xE7,0x95,0x94),
- o3(0xE7,0xB9,0x81), o3(0xE8,0x88,0xAC),
- o3(0xE8,0x97,0xA9), o3(0xE8,0xB2,0xA9),
- o3(0xE7,0xAF,0x84), o3(0xE9,0x87,0x86),
- o3(0xE7,0x85,0xA9), o3(0xE9,0xA0,0x92),
- o3(0xE9,0xA3,0xAF), o3(0xE6,0x8C,0xBD),
- o3(0xE6,0x99,0xA9), o3(0xE7,0x95,0xAA),
- o3(0xE7,0x9B,0xA4), o3(0xE7,0xA3,0x90),
- o3(0xE8,0x95,0x83), o3(0xE8,0x9B,0xAE),
- o3(0xE5,0x8C,0xAA), o3(0xE5,0x8D,0x91),
- o3(0xE5,0x90,0xA6), o3(0xE5,0xA6,0x83),
- o3(0xE5,0xBA,0x87), o3(0xE5,0xBD,0xBC),
- o3(0xE6,0x82,0xB2), o3(0xE6,0x89,0x89),
- o3(0xE6,0x89,0xB9), o3(0xE6,0x8A,0xAB),
- o3(0xE6,0x96,0x90), o3(0xE6,0xAF,0x94),
- o3(0xE6,0xB3,0x8C), o3(0xE7,0x96,0xB2),
- o3(0xE7,0x9A,0xAE), o3(0xE7,0xA2,0x91),
- o3(0xE7,0xA7,0x98), o3(0xE7,0xB7,0x8B),
- o3(0xE7,0xBD,0xB7), o3(0xE8,0x82,0xA5),
- o3(0xE8,0xA2,0xAB), o3(0xE8,0xAA,0xB9),
- o3(0xE8,0xB2,0xBB), o3(0xE9,0x81,0xBF),
- o3(0xE9,0x9D,0x9E), o3(0xE9,0xA3,0x9B),
- o3(0xE6,0xA8,0x8B), o3(0xE7,0xB0,0xB8),
- o3(0xE5,0x82,0x99), o3(0xE5,0xB0,0xBE),
- o3(0xE5,0xBE,0xAE), o3(0xE6,0x9E,0x87),
- o3(0xE6,0xAF,0x98), o3(0xE7,0x90,0xB5),
- o3(0xE7,0x9C,0x89), o3(0xE7,0xBE,0x8E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C8 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C8_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_C9_infos[95] = {
- o3(0xE9,0xBC,0xBB), o3(0xE6,0x9F,0x8A),
- o3(0xE7,0xA8,0x97), o3(0xE5,0x8C,0xB9),
- o3(0xE7,0x96,0x8B), o3(0xE9,0xAB,0xAD),
- o3(0xE5,0xBD,0xA6), o3(0xE8,0x86,0x9D),
- o3(0xE8,0x8F,0xB1), o3(0xE8,0x82,0x98),
- o3(0xE5,0xBC,0xBC), o3(0xE5,0xBF,0x85),
- o3(0xE7,0x95,0xA2), o3(0xE7,0xAD,0x86),
- o3(0xE9,0x80,0xBC), o3(0xE6,0xA1,0xA7),
- o3(0xE5,0xA7,0xAB), o3(0xE5,0xAA,0x9B),
- o3(0xE7,0xB4,0x90), o3(0xE7,0x99,0xBE),
- o3(0xE8,0xAC,0xAC), o3(0xE4,0xBF,0xB5),
- o3(0xE5,0xBD,0xAA), o3(0xE6,0xA8,0x99),
- o3(0xE6,0xB0,0xB7), o3(0xE6,0xBC,0x82),
- o3(0xE7,0x93,0xA2), o3(0xE7,0xA5,0xA8),
- o3(0xE8,0xA1,0xA8), o3(0xE8,0xA9,0x95),
- o3(0xE8,0xB1,0xB9), o3(0xE5,0xBB,0x9F),
- o3(0xE6,0x8F,0x8F), o3(0xE7,0x97,0x85),
- o3(0xE7,0xA7,0x92), o3(0xE8,0x8B,0x97),
- o3(0xE9,0x8C,0xA8), o3(0xE9,0x8B,0xB2),
- o3(0xE8,0x92,0x9C), o3(0xE8,0x9B,0xAD),
- o3(0xE9,0xB0,0xAD), o3(0xE5,0x93,0x81),
- o3(0xE5,0xBD,0xAC), o3(0xE6,0x96,0x8C),
- o3(0xE6,0xB5,0x9C), o3(0xE7,0x80,0x95),
- o3(0xE8,0xB2,0xA7), o3(0xE8,0xB3,0x93),
- o3(0xE9,0xA0,0xBB), o3(0xE6,0x95,0x8F),
- o3(0xE7,0x93,0xB6), o3(0xE4,0xB8,0x8D),
- o3(0xE4,0xBB,0x98), o3(0xE5,0x9F,0xA0),
- o3(0xE5,0xA4,0xAB), o3(0xE5,0xA9,0xA6),
- o3(0xE5,0xAF,0x8C), o3(0xE5,0x86,0xA8),
- o3(0xE5,0xB8,0x83), o3(0xE5,0xBA,0x9C),
- o3(0xE6,0x80,0x96), o3(0xE6,0x89,0xB6),
- o3(0xE6,0x95,0xB7), o3(0xE6,0x96,0xA7),
- o3(0xE6,0x99,0xAE), o3(0xE6,0xB5,0xAE),
- o3(0xE7,0x88,0xB6), o3(0xE7,0xAC,0xA6),
- o3(0xE8,0x85,0x90), o3(0xE8,0x86,0x9A),
- o3(0xE8,0x8A,0x99), o3(0xE8,0xAD,0x9C),
- o3(0xE8,0xB2,0xA0), o3(0xE8,0xB3,0xA6),
- o3(0xE8,0xB5,0xB4), o3(0xE9,0x98,0x9C),
- o3(0xE9,0x99,0x84), o3(0xE4,0xBE,0xAE),
- o3(0xE6,0x92,0xAB), o3(0xE6,0xAD,0xA6),
- o3(0xE8,0x88,0x9E), o3(0xE8,0x91,0xA1),
- o3(0xE8,0x95,0xAA), o3(0xE9,0x83,0xA8),
- o3(0xE5,0xB0,0x81), o3(0xE6,0xA5,0x93),
- o3(0xE9,0xA2,0xA8), o3(0xE8,0x91,0xBA),
- o3(0xE8,0x95,0x97), o3(0xE4,0xBC,0x8F),
- o3(0xE5,0x89,0xAF), o3(0xE5,0xBE,0xA9),
- o3(0xE5,0xB9,0x85), o3(0xE6,0x9C,0x8D),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_C9 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_C9_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_CA_infos[95] = {
- o3(0xE7,0xA6,0x8F), o3(0xE8,0x85,0xB9),
- o3(0xE8,0xA4,0x87), o3(0xE8,0xA6,0x86),
- o3(0xE6,0xB7,0xB5), o3(0xE5,0xBC,0x97),
- o3(0xE6,0x89,0x95), o3(0xE6,0xB2,0xB8),
- o3(0xE4,0xBB,0x8F), o3(0xE7,0x89,0xA9),
- o3(0xE9,0xAE,0x92), o3(0xE5,0x88,0x86),
- o3(0xE5,0x90,0xBB), o3(0xE5,0x99,0xB4),
- o3(0xE5,0xA2,0xB3), o3(0xE6,0x86,0xA4),
- o3(0xE6,0x89,0xAE), o3(0xE7,0x84,0x9A),
- o3(0xE5,0xA5,0xAE), o3(0xE7,0xB2,0x89),
- o3(0xE7,0xB3,0x9E), o3(0xE7,0xB4,0x9B),
- o3(0xE9,0x9B,0xB0), o3(0xE6,0x96,0x87),
- o3(0xE8,0x81,0x9E), o3(0xE4,0xB8,0x99),
- o3(0xE4,0xBD,0xB5), o3(0xE5,0x85,0xB5),
- o3(0xE5,0xA1,0x80), o3(0xE5,0xB9,0xA3),
- o3(0xE5,0xB9,0xB3), o3(0xE5,0xBC,0x8A),
- o3(0xE6,0x9F,0x84), o3(0xE4,0xB8,0xA6),
- o3(0xE8,0x94,0xBD), o3(0xE9,0x96,0x89),
- o3(0xE9,0x99,0x9B), o3(0xE7,0xB1,0xB3),
- o3(0xE9,0xA0,0x81), o3(0xE5,0x83,0xBB),
- o3(0xE5,0xA3,0x81), o3(0xE7,0x99,0x96),
- o3(0xE7,0xA2,0xA7), o3(0xE5,0x88,0xA5),
- o3(0xE7,0x9E,0xA5), o3(0xE8,0x94,0x91),
- o3(0xE7,0xAE,0x86), o3(0xE5,0x81,0x8F),
- o3(0xE5,0xA4,0x89), o3(0xE7,0x89,0x87),
- o3(0xE7,0xAF,0x87), o3(0xE7,0xB7,0xA8),
- o3(0xE8,0xBE,0xBA), o3(0xE8,0xBF,0x94),
- o3(0xE9,0x81,0x8D), o3(0xE4,0xBE,0xBF),
- o3(0xE5,0x8B,0x89), o3(0xE5,0xA8,0xA9),
- o3(0xE5,0xBC,0x81), o3(0xE9,0x9E,0xAD),
- o3(0xE4,0xBF,0x9D), o3(0xE8,0x88,0x97),
- o3(0xE9,0x8B,0xAA), o3(0xE5,0x9C,0x83),
- o3(0xE6,0x8D,0x95), o3(0xE6,0xAD,0xA9),
- o3(0xE7,0x94,0xAB), o3(0xE8,0xA3,0x9C),
- o3(0xE8,0xBC,0x94), o3(0xE7,0xA9,0x82),
- o3(0xE5,0x8B,0x9F), o3(0xE5,0xA2,0x93),
- o3(0xE6,0x85,0x95), o3(0xE6,0x88,0x8A),
- o3(0xE6,0x9A,0xAE), o3(0xE6,0xAF,0x8D),
- o3(0xE7,0xB0,0xBF), o3(0xE8,0x8F,0xA9),
- o3(0xE5,0x80,0xA3), o3(0xE4,0xBF,0xB8),
- o3(0xE5,0x8C,0x85), o3(0xE5,0x91,0x86),
- o3(0xE5,0xA0,0xB1), o3(0xE5,0xA5,0x89),
- o3(0xE5,0xAE,0x9D), o3(0xE5,0xB3,0xB0),
- o3(0xE5,0xB3,0xAF), o3(0xE5,0xB4,0xA9),
- o3(0xE5,0xBA,0x96), o3(0xE6,0x8A,0xB1),
- o3(0xE6,0x8D,0xA7), o3(0xE6,0x94,0xBE),
- o3(0xE6,0x96,0xB9), o3(0xE6,0x9C,0x8B),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_CA = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_CA_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_CB_infos[95] = {
- o3(0xE6,0xB3,0x95), o3(0xE6,0xB3,0xA1),
- o3(0xE7,0x83,0xB9), o3(0xE7,0xA0,0xB2),
- o3(0xE7,0xB8,0xAB), o3(0xE8,0x83,0x9E),
- o3(0xE8,0x8A,0xB3), o3(0xE8,0x90,0x8C),
- o3(0xE8,0x93,0xAC), o3(0xE8,0x9C,0x82),
- o3(0xE8,0xA4,0x92), o3(0xE8,0xA8,0xAA),
- o3(0xE8,0xB1,0x8A), o3(0xE9,0x82,0xA6),
- o3(0xE9,0x8B,0x92), o3(0xE9,0xA3,0xBD),
- o3(0xE9,0xB3,0xB3), o3(0xE9,0xB5,0xAC),
- o3(0xE4,0xB9,0x8F), o3(0xE4,0xBA,0xA1),
- o3(0xE5,0x82,0x8D), o3(0xE5,0x89,0x96),
- o3(0xE5,0x9D,0x8A), o3(0xE5,0xA6,0xA8),
- o3(0xE5,0xB8,0xBD), o3(0xE5,0xBF,0x98),
- o3(0xE5,0xBF,0x99), o3(0xE6,0x88,0xBF),
- o3(0xE6,0x9A,0xB4), o3(0xE6,0x9C,0x9B),
- o3(0xE6,0x9F,0x90), o3(0xE6,0xA3,0x92),
- o3(0xE5,0x86,0x92), o3(0xE7,0xB4,0xA1),
- o3(0xE8,0x82,0xAA), o3(0xE8,0x86,0xA8),
- o3(0xE8,0xAC,0x80), o3(0xE8,0xB2,0x8C),
- o3(0xE8,0xB2,0xBF), o3(0xE9,0x89,0xBE),
- o3(0xE9,0x98,0xB2), o3(0xE5,0x90,0xA0),
- o3(0xE9,0xA0,0xAC), o3(0xE5,0x8C,0x97),
- o3(0xE5,0x83,0x95), o3(0xE5,0x8D,0x9C),
- o3(0xE5,0xA2,0xA8), o3(0xE6,0x92,0xB2),
- o3(0xE6,0x9C,0xB4), o3(0xE7,0x89,0xA7),
- o3(0xE7,0x9D,0xA6), o3(0xE7,0xA9,0x86),
- o3(0xE9,0x87,0xA6), o3(0xE5,0x8B,0x83),
- o3(0xE6,0xB2,0xA1), o3(0xE6,0xAE,0x86),
- o3(0xE5,0xA0,0x80), o3(0xE5,0xB9,0x8C),
- o3(0xE5,0xA5,0x94), o3(0xE6,0x9C,0xAC),
- o3(0xE7,0xBF,0xBB), o3(0xE5,0x87,0xA1),
- o3(0xE7,0x9B,0x86), o3(0xE6,0x91,0xA9),
- o3(0xE7,0xA3,0xA8), o3(0xE9,0xAD,0x94),
- o3(0xE9,0xBA,0xBB), o3(0xE5,0x9F,0x8B),
- o3(0xE5,0xA6,0xB9), o3(0xE6,0x98,0xA7),
- o3(0xE6,0x9E,0x9A), o3(0xE6,0xAF,0x8E),
- o3(0xE5,0x93,0xA9), o3(0xE6,0xA7,0x99),
- o3(0xE5,0xB9,0x95), o3(0xE8,0x86,0x9C),
- o3(0xE6,0x9E,0x95), o3(0xE9,0xAE,0xAA),
- o3(0xE6,0x9F,0xBE), o3(0xE9,0xB1,0x92),
- o3(0xE6,0xA1,0x9D), o3(0xE4,0xBA,0xA6),
- o3(0xE4,0xBF,0xA3), o3(0xE5,0x8F,0x88),
- o3(0xE6,0x8A,0xB9), o3(0xE6,0x9C,0xAB),
- o3(0xE6,0xB2,0xAB), o3(0xE8,0xBF,0x84),
- o3(0xE4,0xBE,0xAD), o3(0xE7,0xB9,0xAD),
- o3(0xE9,0xBA,0xBF), o3(0xE4,0xB8,0x87),
- o3(0xE6,0x85,0xA2), o3(0xE6,0xBA,0x80),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_CB = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_CB_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_CC_infos[95] = {
- o3(0xE6,0xBC,0xAB), o3(0xE8,0x94,0x93),
- o3(0xE5,0x91,0xB3), o3(0xE6,0x9C,0xAA),
- o3(0xE9,0xAD,0x85), o3(0xE5,0xB7,0xB3),
- o3(0xE7,0xAE,0x95), o3(0xE5,0xB2,0xAC),
- o3(0xE5,0xAF,0x86), o3(0xE8,0x9C,0x9C),
- o3(0xE6,0xB9,0x8A), o3(0xE8,0x93,0x91),
- o3(0xE7,0xA8,0x94), o3(0xE8,0x84,0x88),
- o3(0xE5,0xA6,0x99), o3(0xE7,0xB2,0x8D),
- o3(0xE6,0xB0,0x91), o3(0xE7,0x9C,0xA0),
- o3(0xE5,0x8B,0x99), o3(0xE5,0xA4,0xA2),
- o3(0xE7,0x84,0xA1), o3(0xE7,0x89,0x9F),
- o3(0xE7,0x9F,0x9B), o3(0xE9,0x9C,0xA7),
- o3(0xE9,0xB5,0xA1), o3(0xE6,0xA4,0x8B),
- o3(0xE5,0xA9,0xBF), o3(0xE5,0xA8,0x98),
- o3(0xE5,0x86,0xA5), o3(0xE5,0x90,0x8D),
- o3(0xE5,0x91,0xBD), o3(0xE6,0x98,0x8E),
- o3(0xE7,0x9B,0x9F), o3(0xE8,0xBF,0xB7),
- o3(0xE9,0x8A,0x98), o3(0xE9,0xB3,0xB4),
- o3(0xE5,0xA7,0xAA), o3(0xE7,0x89,0x9D),
- o3(0xE6,0xBB,0x85), o3(0xE5,0x85,0x8D),
- o3(0xE6,0xA3,0x89), o3(0xE7,0xB6,0xBF),
- o3(0xE7,0xB7,0xAC), o3(0xE9,0x9D,0xA2),
- o3(0xE9,0xBA,0xBA), o3(0xE6,0x91,0xB8),
- o3(0xE6,0xA8,0xA1), o3(0xE8,0x8C,0x82),
- o3(0xE5,0xA6,0x84), o3(0xE5,0xAD,0x9F),
- o3(0xE6,0xAF,0x9B), o3(0xE7,0x8C,0x9B),
- o3(0xE7,0x9B,0xB2), o3(0xE7,0xB6,0xB2),
- o3(0xE8,0x80,0x97), o3(0xE8,0x92,0x99),
- o3(0xE5,0x84,0xB2), o3(0xE6,0x9C,0xA8),
- o3(0xE9,0xBB,0x99), o3(0xE7,0x9B,0xAE),
- o3(0xE6,0x9D,0xA2), o3(0xE5,0x8B,0xBF),
- o3(0xE9,0xA4,0x85), o3(0xE5,0xB0,0xA4),
- o3(0xE6,0x88,0xBB), o3(0xE7,0xB1,0xBE),
- o3(0xE8,0xB2,0xB0), o3(0xE5,0x95,0x8F),
- o3(0xE6,0x82,0xB6), o3(0xE7,0xB4,0x8B),
- o3(0xE9,0x96,0x80), o3(0xE5,0x8C,0x81),
- o3(0xE4,0xB9,0x9F), o3(0xE5,0x86,0xB6),
- o3(0xE5,0xA4,0x9C), o3(0xE7,0x88,0xBA),
- o3(0xE8,0x80,0xB6), o3(0xE9,0x87,0x8E),
- o3(0xE5,0xBC,0xA5), o3(0xE7,0x9F,0xA2),
- o3(0xE5,0x8E,0x84), o3(0xE5,0xBD,0xB9),
- o3(0xE7,0xB4,0x84), o3(0xE8,0x96,0xAC),
- o3(0xE8,0xA8,0xB3), o3(0xE8,0xBA,0x8D),
- o3(0xE9,0x9D,0x96), o3(0xE6,0x9F,0xB3),
- o3(0xE8,0x96,0xAE), o3(0xE9,0x91,0x93),
- o3(0xE6,0x84,0x89), o3(0xE6,0x84,0x88),
- o3(0xE6,0xB2,0xB9), o3(0xE7,0x99,0x92),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_CC = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_CC_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_CD_infos[95] = {
- o3(0xE8,0xAB,0xAD), o3(0xE8,0xBC,0xB8),
- o3(0xE5,0x94,0xAF), o3(0xE4,0xBD,0x91),
- o3(0xE5,0x84,0xAA), o3(0xE5,0x8B,0x87),
- o3(0xE5,0x8F,0x8B), o3(0xE5,0xAE,0xA5),
- o3(0xE5,0xB9,0xBD), o3(0xE6,0x82,0xA0),
- o3(0xE6,0x86,0x82), o3(0xE6,0x8F,0x96),
- o3(0xE6,0x9C,0x89), o3(0xE6,0x9F,0x9A),
- o3(0xE6,0xB9,0xA7), o3(0xE6,0xB6,0x8C),
- o3(0xE7,0x8C,0xB6), o3(0xE7,0x8C,0xB7),
- o3(0xE7,0x94,0xB1), o3(0xE7,0xA5,0x90),
- o3(0xE8,0xA3,0x95), o3(0xE8,0xAA,0x98),
- o3(0xE9,0x81,0x8A), o3(0xE9,0x82,0x91),
- o3(0xE9,0x83,0xB5), o3(0xE9,0x9B,0x84),
- o3(0xE8,0x9E,0x8D), o3(0xE5,0xA4,0x95),
- o3(0xE4,0xBA,0x88), o3(0xE4,0xBD,0x99),
- o3(0xE4,0xB8,0x8E), o3(0xE8,0xAA,0x89),
- o3(0xE8,0xBC,0xBF), o3(0xE9,0xA0,0x90),
- o3(0xE5,0x82,0xAD), o3(0xE5,0xB9,0xBC),
- o3(0xE5,0xA6,0x96), o3(0xE5,0xAE,0xB9),
- o3(0xE5,0xBA,0xB8), o3(0xE6,0x8F,0x9A),
- o3(0xE6,0x8F,0xBA), o3(0xE6,0x93,0x81),
- o3(0xE6,0x9B,0x9C), o3(0xE6,0xA5,0x8A),
- o3(0xE6,0xA7,0x98), o3(0xE6,0xB4,0x8B),
- o3(0xE6,0xBA,0xB6), o3(0xE7,0x86,0x94),
- o3(0xE7,0x94,0xA8), o3(0xE7,0xAA,0xAF),
- o3(0xE7,0xBE,0x8A), o3(0xE8,0x80,0x80),
- o3(0xE8,0x91,0x89), o3(0xE8,0x93,0x89),
- o3(0xE8,0xA6,0x81), o3(0xE8,0xAC,0xA1),
- o3(0xE8,0xB8,0x8A), o3(0xE9,0x81,0xA5),
- o3(0xE9,0x99,0xBD), o3(0xE9,0xA4,0x8A),
- o3(0xE6,0x85,0xBE), o3(0xE6,0x8A,0x91),
- o3(0xE6,0xAC,0xB2), o3(0xE6,0xB2,0x83),
- o3(0xE6,0xB5,0xB4), o3(0xE7,0xBF,0x8C),
- o3(0xE7,0xBF,0xBC), o3(0xE6,0xB7,0x80),
- o3(0xE7,0xBE,0x85), o3(0xE8,0x9E,0xBA),
- o3(0xE8,0xA3,0xB8), o3(0xE6,0x9D,0xA5),
- o3(0xE8,0x8E,0xB1), o3(0xE9,0xA0,0xBC),
- o3(0xE9,0x9B,0xB7), o3(0xE6,0xB4,0x9B),
- o3(0xE7,0xB5,0xA1), o3(0xE8,0x90,0xBD),
- o3(0xE9,0x85,0xAA), o3(0xE4,0xB9,0xB1),
- o3(0xE5,0x8D,0xB5), o3(0xE5,0xB5,0x90),
- o3(0xE6,0xAC,0x84), o3(0xE6,0xBF,0xAB),
- o3(0xE8,0x97,0x8D), o3(0xE8,0x98,0xAD),
- o3(0xE8,0xA6,0xA7), o3(0xE5,0x88,0xA9),
- o3(0xE5,0x90,0x8F), o3(0xE5,0xB1,0xA5),
- o3(0xE6,0x9D,0x8E), o3(0xE6,0xA2,0xA8),
- o3(0xE7,0x90,0x86), o3(0xE7,0x92,0x83),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_CD = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_CD_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_CE_infos[95] = {
- o3(0xE7,0x97,0xA2), o3(0xE8,0xA3,0x8F),
- o3(0xE8,0xA3,0xA1), o3(0xE9,0x87,0x8C),
- o3(0xE9,0x9B,0xA2), o3(0xE9,0x99,0xB8),
- o3(0xE5,0xBE,0x8B), o3(0xE7,0x8E,0x87),
- o3(0xE7,0xAB,0x8B), o3(0xE8,0x91,0x8E),
- o3(0xE6,0x8E,0xA0), o3(0xE7,0x95,0xA5),
- o3(0xE5,0x8A,0x89), o3(0xE6,0xB5,0x81),
- o3(0xE6,0xBA,0x9C), o3(0xE7,0x90,0x89),
- o3(0xE7,0x95,0x99), o3(0xE7,0xA1,0xAB),
- o3(0xE7,0xB2,0x92), o3(0xE9,0x9A,0x86),
- o3(0xE7,0xAB,0x9C), o3(0xE9,0xBE,0x8D),
- o3(0xE4,0xBE,0xB6), o3(0xE6,0x85,0xAE),
- o3(0xE6,0x97,0x85), o3(0xE8,0x99,0x9C),
- o3(0xE4,0xBA,0x86), o3(0xE4,0xBA,0xAE),
- o3(0xE5,0x83,0x9A), o3(0xE4,0xB8,0xA1),
- o3(0xE5,0x87,0x8C), o3(0xE5,0xAF,0xAE),
- o3(0xE6,0x96,0x99), o3(0xE6,0xA2,0x81),
- o3(0xE6,0xB6,0xBC), o3(0xE7,0x8C,0x9F),
- o3(0xE7,0x99,0x82), o3(0xE7,0x9E,0xAD),
- o3(0xE7,0xA8,0x9C), o3(0xE7,0xB3,0xA7),
- o3(0xE8,0x89,0xAF), o3(0xE8,0xAB,0x92),
- o3(0xE9,0x81,0xBC), o3(0xE9,0x87,0x8F),
- o3(0xE9,0x99,0xB5), o3(0xE9,0xA0,0x98),
- o3(0xE5,0x8A,0x9B), o3(0xE7,0xB7,0x91),
- o3(0xE5,0x80,0xAB), o3(0xE5,0x8E,0x98),
- o3(0xE6,0x9E,0x97), o3(0xE6,0xB7,0x8B),
- o3(0xE7,0x87,0x90), o3(0xE7,0x90,0xB3),
- o3(0xE8,0x87,0xA8), o3(0xE8,0xBC,0xAA),
- o3(0xE9,0x9A,0xA3), o3(0xE9,0xB1,0x97),
- o3(0xE9,0xBA,0x9F), o3(0xE7,0x91,0xA0),
- o3(0xE5,0xA1,0x81), o3(0xE6,0xB6,0x99),
- o3(0xE7,0xB4,0xAF), o3(0xE9,0xA1,0x9E),
- o3(0xE4,0xBB,0xA4), o3(0xE4,0xBC,0xB6),
- o3(0xE4,0xBE,0x8B), o3(0xE5,0x86,0xB7),
- o3(0xE5,0x8A,0xB1), o3(0xE5,0xB6,0xBA),
- o3(0xE6,0x80,0x9C), o3(0xE7,0x8E,0xB2),
- o3(0xE7,0xA4,0xBC), o3(0xE8,0x8B,0x93),
- o3(0xE9,0x88,0xB4), o3(0xE9,0x9A,0xB7),
- o3(0xE9,0x9B,0xB6), o3(0xE9,0x9C,0x8A),
- o3(0xE9,0xBA,0x97), o3(0xE9,0xBD,0xA2),
- o3(0xE6,0x9A,0xA6), o3(0xE6,0xAD,0xB4),
- o3(0xE5,0x88,0x97), o3(0xE5,0x8A,0xA3),
- o3(0xE7,0x83,0x88), o3(0xE8,0xA3,0x82),
- o3(0xE5,0xBB,0x89), o3(0xE6,0x81,0x8B),
- o3(0xE6,0x86,0x90), o3(0xE6,0xBC,0xA3),
- o3(0xE7,0x85,0x89), o3(0xE7,0xB0,0xBE),
- o3(0xE7,0xB7,0xB4), o3(0xE8,0x81,0xAF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_CE = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_CE_infos
-};
-
-static const unsigned char
-from_EUC_JP_CF_offsets[256] = {
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
-};
-static const struct byte_lookup* const
-from_EUC_JP_CF_infos[52] = {
- o3(0xE8,0x93,0xAE), o3(0xE9,0x80,0xA3),
- o3(0xE9,0x8C,0xAC), o3(0xE5,0x91,0x82),
- o3(0xE9,0xAD,0xAF), o3(0xE6,0xAB,0x93),
- o3(0xE7,0x82,0x89), o3(0xE8,0xB3,0x82),
- o3(0xE8,0xB7,0xAF), o3(0xE9,0x9C,0xB2),
- o3(0xE5,0x8A,0xB4), o3(0xE5,0xA9,0x81),
- o3(0xE5,0xBB,0x8A), o3(0xE5,0xBC,0x84),
- o3(0xE6,0x9C,0x97), o3(0xE6,0xA5,0xBC),
- o3(0xE6,0xA6,0x94), o3(0xE6,0xB5,0xAA),
- o3(0xE6,0xBC,0x8F), o3(0xE7,0x89,0xA2),
- o3(0xE7,0x8B,0xBC), o3(0xE7,0xAF,0xAD),
- o3(0xE8,0x80,0x81), o3(0xE8,0x81,0xBE),
- o3(0xE8,0x9D,0x8B), o3(0xE9,0x83,0x8E),
- o3(0xE5,0x85,0xAD), o3(0xE9,0xBA,0x93),
- o3(0xE7,0xA6,0x84), o3(0xE8,0x82,0x8B),
- o3(0xE9,0x8C,0xB2), o3(0xE8,0xAB,0x96),
- o3(0xE5,0x80,0xAD), o3(0xE5,0x92,0x8C),
- o3(0xE8,0xA9,0xB1), o3(0xE6,0xAD,0xAA),
- o3(0xE8,0xB3,0x84), o3(0xE8,0x84,0x87),
- o3(0xE6,0x83,0x91), o3(0xE6,0x9E,0xA0),
- o3(0xE9,0xB7,0xB2), o3(0xE4,0xBA,0x99),
- o3(0xE4,0xBA,0x98), o3(0xE9,0xB0,0x90),
- o3(0xE8,0xA9,0xAB), o3(0xE8,0x97,0x81),
- o3(0xE8,0x95,0xA8), o3(0xE6,0xA4,0x80),
- o3(0xE6,0xB9,0xBE), o3(0xE7,0xA2,0x97),
- o3(0xE8,0x85,0x95), UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_CF = {
- from_EUC_JP_CF_offsets,
- from_EUC_JP_CF_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D0_infos[95] = {
- o3(0xE5,0xBC,0x8C), o3(0xE4,0xB8,0x90),
- o3(0xE4,0xB8,0x95), o3(0xE4,0xB8,0xAA),
- o3(0xE4,0xB8,0xB1), o3(0xE4,0xB8,0xB6),
- o3(0xE4,0xB8,0xBC), o3(0xE4,0xB8,0xBF),
- o3(0xE4,0xB9,0x82), o3(0xE4,0xB9,0x96),
- o3(0xE4,0xB9,0x98), o3(0xE4,0xBA,0x82),
- o3(0xE4,0xBA,0x85), o3(0xE8,0xB1,0xAB),
- o3(0xE4,0xBA,0x8A), o3(0xE8,0x88,0x92),
- o3(0xE5,0xBC,0x8D), o3(0xE4,0xBA,0x8E),
- o3(0xE4,0xBA,0x9E), o3(0xE4,0xBA,0x9F),
- o3(0xE4,0xBA,0xA0), o3(0xE4,0xBA,0xA2),
- o3(0xE4,0xBA,0xB0), o3(0xE4,0xBA,0xB3),
- o3(0xE4,0xBA,0xB6), o3(0xE4,0xBB,0x8E),
- o3(0xE4,0xBB,0x8D), o3(0xE4,0xBB,0x84),
- o3(0xE4,0xBB,0x86), o3(0xE4,0xBB,0x82),
- o3(0xE4,0xBB,0x97), o3(0xE4,0xBB,0x9E),
- o3(0xE4,0xBB,0xAD), o3(0xE4,0xBB,0x9F),
- o3(0xE4,0xBB,0xB7), o3(0xE4,0xBC,0x89),
- o3(0xE4,0xBD,0x9A), o3(0xE4,0xBC,0xB0),
- o3(0xE4,0xBD,0x9B), o3(0xE4,0xBD,0x9D),
- o3(0xE4,0xBD,0x97), o3(0xE4,0xBD,0x87),
- o3(0xE4,0xBD,0xB6), o3(0xE4,0xBE,0x88),
- o3(0xE4,0xBE,0x8F), o3(0xE4,0xBE,0x98),
- o3(0xE4,0xBD,0xBB), o3(0xE4,0xBD,0xA9),
- o3(0xE4,0xBD,0xB0), o3(0xE4,0xBE,0x91),
- o3(0xE4,0xBD,0xAF), o3(0xE4,0xBE,0x86),
- o3(0xE4,0xBE,0x96), o3(0xE5,0x84,0x98),
- o3(0xE4,0xBF,0x94), o3(0xE4,0xBF,0x9F),
- o3(0xE4,0xBF,0x8E), o3(0xE4,0xBF,0x98),
- o3(0xE4,0xBF,0x9B), o3(0xE4,0xBF,0x91),
- o3(0xE4,0xBF,0x9A), o3(0xE4,0xBF,0x90),
- o3(0xE4,0xBF,0xA4), o3(0xE4,0xBF,0xA5),
- o3(0xE5,0x80,0x9A), o3(0xE5,0x80,0xA8),
- o3(0xE5,0x80,0x94), o3(0xE5,0x80,0xAA),
- o3(0xE5,0x80,0xA5), o3(0xE5,0x80,0x85),
- o3(0xE4,0xBC,0x9C), o3(0xE4,0xBF,0xB6),
- o3(0xE5,0x80,0xA1), o3(0xE5,0x80,0xA9),
- o3(0xE5,0x80,0xAC), o3(0xE4,0xBF,0xBE),
- o3(0xE4,0xBF,0xAF), o3(0xE5,0x80,0x91),
- o3(0xE5,0x80,0x86), o3(0xE5,0x81,0x83),
- o3(0xE5,0x81,0x87), o3(0xE6,0x9C,0x83),
- o3(0xE5,0x81,0x95), o3(0xE5,0x81,0x90),
- o3(0xE5,0x81,0x88), o3(0xE5,0x81,0x9A),
- o3(0xE5,0x81,0x96), o3(0xE5,0x81,0xAC),
- o3(0xE5,0x81,0xB8), o3(0xE5,0x82,0x80),
- o3(0xE5,0x82,0x9A), o3(0xE5,0x82,0x85),
- o3(0xE5,0x82,0xB4), o3(0xE5,0x82,0xB2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D0 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D0_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D1_infos[95] = {
- o3(0xE5,0x83,0x89), o3(0xE5,0x83,0x8A),
- o3(0xE5,0x82,0xB3), o3(0xE5,0x83,0x82),
- o3(0xE5,0x83,0x96), o3(0xE5,0x83,0x9E),
- o3(0xE5,0x83,0xA5), o3(0xE5,0x83,0xAD),
- o3(0xE5,0x83,0xA3), o3(0xE5,0x83,0xAE),
- o3(0xE5,0x83,0xB9), o3(0xE5,0x83,0xB5),
- o3(0xE5,0x84,0x89), o3(0xE5,0x84,0x81),
- o3(0xE5,0x84,0x82), o3(0xE5,0x84,0x96),
- o3(0xE5,0x84,0x95), o3(0xE5,0x84,0x94),
- o3(0xE5,0x84,0x9A), o3(0xE5,0x84,0xA1),
- o3(0xE5,0x84,0xBA), o3(0xE5,0x84,0xB7),
- o3(0xE5,0x84,0xBC), o3(0xE5,0x84,0xBB),
- o3(0xE5,0x84,0xBF), o3(0xE5,0x85,0x80),
- o3(0xE5,0x85,0x92), o3(0xE5,0x85,0x8C),
- o3(0xE5,0x85,0x94), o3(0xE5,0x85,0xA2),
- o3(0xE7,0xAB,0xB8), o3(0xE5,0x85,0xA9),
- o3(0xE5,0x85,0xAA), o3(0xE5,0x85,0xAE),
- o3(0xE5,0x86,0x80), o3(0xE5,0x86,0x82),
- o3(0xE5,0x9B,0x98), o3(0xE5,0x86,0x8C),
- o3(0xE5,0x86,0x89), o3(0xE5,0x86,0x8F),
- o3(0xE5,0x86,0x91), o3(0xE5,0x86,0x93),
- o3(0xE5,0x86,0x95), o3(0xE5,0x86,0x96),
- o3(0xE5,0x86,0xA4), o3(0xE5,0x86,0xA6),
- o3(0xE5,0x86,0xA2), o3(0xE5,0x86,0xA9),
- o3(0xE5,0x86,0xAA), o3(0xE5,0x86,0xAB),
- o3(0xE5,0x86,0xB3), o3(0xE5,0x86,0xB1),
- o3(0xE5,0x86,0xB2), o3(0xE5,0x86,0xB0),
- o3(0xE5,0x86,0xB5), o3(0xE5,0x86,0xBD),
- o3(0xE5,0x87,0x85), o3(0xE5,0x87,0x89),
- o3(0xE5,0x87,0x9B), o3(0xE5,0x87,0xA0),
- o3(0xE8,0x99,0x95), o3(0xE5,0x87,0xA9),
- o3(0xE5,0x87,0xAD), o3(0xE5,0x87,0xB0),
- o3(0xE5,0x87,0xB5), o3(0xE5,0x87,0xBE),
- o3(0xE5,0x88,0x84), o3(0xE5,0x88,0x8B),
- o3(0xE5,0x88,0x94), o3(0xE5,0x88,0x8E),
- o3(0xE5,0x88,0xA7), o3(0xE5,0x88,0xAA),
- o3(0xE5,0x88,0xAE), o3(0xE5,0x88,0xB3),
- o3(0xE5,0x88,0xB9), o3(0xE5,0x89,0x8F),
- o3(0xE5,0x89,0x84), o3(0xE5,0x89,0x8B),
- o3(0xE5,0x89,0x8C), o3(0xE5,0x89,0x9E),
- o3(0xE5,0x89,0x94), o3(0xE5,0x89,0xAA),
- o3(0xE5,0x89,0xB4), o3(0xE5,0x89,0xA9),
- o3(0xE5,0x89,0xB3), o3(0xE5,0x89,0xBF),
- o3(0xE5,0x89,0xBD), o3(0xE5,0x8A,0x8D),
- o3(0xE5,0x8A,0x94), o3(0xE5,0x8A,0x92),
- o3(0xE5,0x89,0xB1), o3(0xE5,0x8A,0x88),
- o3(0xE5,0x8A,0x91), o3(0xE8,0xBE,0xA8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D1 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D1_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D2_infos[95] = {
- o3(0xE8,0xBE,0xA7), o3(0xE5,0x8A,0xAC),
- o3(0xE5,0x8A,0xAD), o3(0xE5,0x8A,0xBC),
- o3(0xE5,0x8A,0xB5), o3(0xE5,0x8B,0x81),
- o3(0xE5,0x8B,0x8D), o3(0xE5,0x8B,0x97),
- o3(0xE5,0x8B,0x9E), o3(0xE5,0x8B,0xA3),
- o3(0xE5,0x8B,0xA6), o3(0xE9,0xA3,0xAD),
- o3(0xE5,0x8B,0xA0), o3(0xE5,0x8B,0xB3),
- o3(0xE5,0x8B,0xB5), o3(0xE5,0x8B,0xB8),
- o3(0xE5,0x8B,0xB9), o3(0xE5,0x8C,0x86),
- o3(0xE5,0x8C,0x88), o3(0xE7,0x94,0xB8),
- o3(0xE5,0x8C,0x8D), o3(0xE5,0x8C,0x90),
- o3(0xE5,0x8C,0x8F), o3(0xE5,0x8C,0x95),
- o3(0xE5,0x8C,0x9A), o3(0xE5,0x8C,0xA3),
- o3(0xE5,0x8C,0xAF), o3(0xE5,0x8C,0xB1),
- o3(0xE5,0x8C,0xB3), o3(0xE5,0x8C,0xB8),
- o3(0xE5,0x8D,0x80), o3(0xE5,0x8D,0x86),
- o3(0xE5,0x8D,0x85), o3(0xE4,0xB8,0x97),
- o3(0xE5,0x8D,0x89), o3(0xE5,0x8D,0x8D),
- o3(0xE5,0x87,0x96), o3(0xE5,0x8D,0x9E),
- o3(0xE5,0x8D,0xA9), o3(0xE5,0x8D,0xAE),
- o3(0xE5,0xA4,0x98), o3(0xE5,0x8D,0xBB),
- o3(0xE5,0x8D,0xB7), o3(0xE5,0x8E,0x82),
- o3(0xE5,0x8E,0x96), o3(0xE5,0x8E,0xA0),
- o3(0xE5,0x8E,0xA6), o3(0xE5,0x8E,0xA5),
- o3(0xE5,0x8E,0xAE), o3(0xE5,0x8E,0xB0),
- o3(0xE5,0x8E,0xB6), o3(0xE5,0x8F,0x83),
- o3(0xE7,0xB0,0x92), o3(0xE9,0x9B,0x99),
- o3(0xE5,0x8F,0x9F), o3(0xE6,0x9B,0xBC),
- o3(0xE7,0x87,0xAE), o3(0xE5,0x8F,0xAE),
- o3(0xE5,0x8F,0xA8), o3(0xE5,0x8F,0xAD),
- o3(0xE5,0x8F,0xBA), o3(0xE5,0x90,0x81),
- o3(0xE5,0x90,0xBD), o3(0xE5,0x91,0x80),
- o3(0xE5,0x90,0xAC), o3(0xE5,0x90,0xAD),
- o3(0xE5,0x90,0xBC), o3(0xE5,0x90,0xAE),
- o3(0xE5,0x90,0xB6), o3(0xE5,0x90,0xA9),
- o3(0xE5,0x90,0x9D), o3(0xE5,0x91,0x8E),
- o3(0xE5,0x92,0x8F), o3(0xE5,0x91,0xB5),
- o3(0xE5,0x92,0x8E), o3(0xE5,0x91,0x9F),
- o3(0xE5,0x91,0xB1), o3(0xE5,0x91,0xB7),
- o3(0xE5,0x91,0xB0), o3(0xE5,0x92,0x92),
- o3(0xE5,0x91,0xBB), o3(0xE5,0x92,0x80),
- o3(0xE5,0x91,0xB6), o3(0xE5,0x92,0x84),
- o3(0xE5,0x92,0x90), o3(0xE5,0x92,0x86),
- o3(0xE5,0x93,0x87), o3(0xE5,0x92,0xA2),
- o3(0xE5,0x92,0xB8), o3(0xE5,0x92,0xA5),
- o3(0xE5,0x92,0xAC), o3(0xE5,0x93,0x84),
- o3(0xE5,0x93,0x88), o3(0xE5,0x92,0xA8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D2 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D2_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D3_infos[95] = {
- o3(0xE5,0x92,0xAB), o3(0xE5,0x93,0x82),
- o3(0xE5,0x92,0xA4), o3(0xE5,0x92,0xBE),
- o3(0xE5,0x92,0xBC), o3(0xE5,0x93,0x98),
- o3(0xE5,0x93,0xA5), o3(0xE5,0x93,0xA6),
- o3(0xE5,0x94,0x8F), o3(0xE5,0x94,0x94),
- o3(0xE5,0x93,0xBD), o3(0xE5,0x93,0xAE),
- o3(0xE5,0x93,0xAD), o3(0xE5,0x93,0xBA),
- o3(0xE5,0x93,0xA2), o3(0xE5,0x94,0xB9),
- o3(0xE5,0x95,0x80), o3(0xE5,0x95,0xA3),
- o3(0xE5,0x95,0x8C), o3(0xE5,0x94,0xAE),
- o3(0xE5,0x95,0x9C), o3(0xE5,0x95,0x85),
- o3(0xE5,0x95,0x96), o3(0xE5,0x95,0x97),
- o3(0xE5,0x94,0xB8), o3(0xE5,0x94,0xB3),
- o3(0xE5,0x95,0x9D), o3(0xE5,0x96,0x99),
- o3(0xE5,0x96,0x80), o3(0xE5,0x92,0xAF),
- o3(0xE5,0x96,0x8A), o3(0xE5,0x96,0x9F),
- o3(0xE5,0x95,0xBB), o3(0xE5,0x95,0xBE),
- o3(0xE5,0x96,0x98), o3(0xE5,0x96,0x9E),
- o3(0xE5,0x96,0xAE), o3(0xE5,0x95,0xBC),
- o3(0xE5,0x96,0x83), o3(0xE5,0x96,0xA9),
- o3(0xE5,0x96,0x87), o3(0xE5,0x96,0xA8),
- o3(0xE5,0x97,0x9A), o3(0xE5,0x97,0x85),
- o3(0xE5,0x97,0x9F), o3(0xE5,0x97,0x84),
- o3(0xE5,0x97,0x9C), o3(0xE5,0x97,0xA4),
- o3(0xE5,0x97,0x94), o3(0xE5,0x98,0x94),
- o3(0xE5,0x97,0xB7), o3(0xE5,0x98,0x96),
- o3(0xE5,0x97,0xBE), o3(0xE5,0x97,0xBD),
- o3(0xE5,0x98,0x9B), o3(0xE5,0x97,0xB9),
- o3(0xE5,0x99,0x8E), o3(0xE5,0x99,0x90),
- o3(0xE7,0x87,0x9F), o3(0xE5,0x98,0xB4),
- o3(0xE5,0x98,0xB6), o3(0xE5,0x98,0xB2),
- o3(0xE5,0x98,0xB8), o3(0xE5,0x99,0xAB),
- o3(0xE5,0x99,0xA4), o3(0xE5,0x98,0xAF),
- o3(0xE5,0x99,0xAC), o3(0xE5,0x99,0xAA),
- o3(0xE5,0x9A,0x86), o3(0xE5,0x9A,0x80),
- o3(0xE5,0x9A,0x8A), o3(0xE5,0x9A,0xA0),
- o3(0xE5,0x9A,0x94), o3(0xE5,0x9A,0x8F),
- o3(0xE5,0x9A,0xA5), o3(0xE5,0x9A,0xAE),
- o3(0xE5,0x9A,0xB6), o3(0xE5,0x9A,0xB4),
- o3(0xE5,0x9B,0x82), o3(0xE5,0x9A,0xBC),
- o3(0xE5,0x9B,0x81), o3(0xE5,0x9B,0x83),
- o3(0xE5,0x9B,0x80), o3(0xE5,0x9B,0x88),
- o3(0xE5,0x9B,0x8E), o3(0xE5,0x9B,0x91),
- o3(0xE5,0x9B,0x93), o3(0xE5,0x9B,0x97),
- o3(0xE5,0x9B,0xAE), o3(0xE5,0x9B,0xB9),
- o3(0xE5,0x9C,0x80), o3(0xE5,0x9B,0xBF),
- o3(0xE5,0x9C,0x84), o3(0xE5,0x9C,0x89),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D3 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D3_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D4_infos[95] = {
- o3(0xE5,0x9C,0x88), o3(0xE5,0x9C,0x8B),
- o3(0xE5,0x9C,0x8D), o3(0xE5,0x9C,0x93),
- o3(0xE5,0x9C,0x98), o3(0xE5,0x9C,0x96),
- o3(0xE5,0x97,0x87), o3(0xE5,0x9C,0x9C),
- o3(0xE5,0x9C,0xA6), o3(0xE5,0x9C,0xB7),
- o3(0xE5,0x9C,0xB8), o3(0xE5,0x9D,0x8E),
- o3(0xE5,0x9C,0xBB), o3(0xE5,0x9D,0x80),
- o3(0xE5,0x9D,0x8F), o3(0xE5,0x9D,0xA9),
- o3(0xE5,0x9F,0x80), o3(0xE5,0x9E,0x88),
- o3(0xE5,0x9D,0xA1), o3(0xE5,0x9D,0xBF),
- o3(0xE5,0x9E,0x89), o3(0xE5,0x9E,0x93),
- o3(0xE5,0x9E,0xA0), o3(0xE5,0x9E,0xB3),
- o3(0xE5,0x9E,0xA4), o3(0xE5,0x9E,0xAA),
- o3(0xE5,0x9E,0xB0), o3(0xE5,0x9F,0x83),
- o3(0xE5,0x9F,0x86), o3(0xE5,0x9F,0x94),
- o3(0xE5,0x9F,0x92), o3(0xE5,0x9F,0x93),
- o3(0xE5,0xA0,0x8A), o3(0xE5,0x9F,0x96),
- o3(0xE5,0x9F,0xA3), o3(0xE5,0xA0,0x8B),
- o3(0xE5,0xA0,0x99), o3(0xE5,0xA0,0x9D),
- o3(0xE5,0xA1,0xB2), o3(0xE5,0xA0,0xA1),
- o3(0xE5,0xA1,0xA2), o3(0xE5,0xA1,0x8B),
- o3(0xE5,0xA1,0xB0), o3(0xE6,0xAF,0x80),
- o3(0xE5,0xA1,0x92), o3(0xE5,0xA0,0xBD),
- o3(0xE5,0xA1,0xB9), o3(0xE5,0xA2,0x85),
- o3(0xE5,0xA2,0xB9), o3(0xE5,0xA2,0x9F),
- o3(0xE5,0xA2,0xAB), o3(0xE5,0xA2,0xBA),
- o3(0xE5,0xA3,0x9E), o3(0xE5,0xA2,0xBB),
- o3(0xE5,0xA2,0xB8), o3(0xE5,0xA2,0xAE),
- o3(0xE5,0xA3,0x85), o3(0xE5,0xA3,0x93),
- o3(0xE5,0xA3,0x91), o3(0xE5,0xA3,0x97),
- o3(0xE5,0xA3,0x99), o3(0xE5,0xA3,0x98),
- o3(0xE5,0xA3,0xA5), o3(0xE5,0xA3,0x9C),
- o3(0xE5,0xA3,0xA4), o3(0xE5,0xA3,0x9F),
- o3(0xE5,0xA3,0xAF), o3(0xE5,0xA3,0xBA),
- o3(0xE5,0xA3,0xB9), o3(0xE5,0xA3,0xBB),
- o3(0xE5,0xA3,0xBC), o3(0xE5,0xA3,0xBD),
- o3(0xE5,0xA4,0x82), o3(0xE5,0xA4,0x8A),
- o3(0xE5,0xA4,0x90), o3(0xE5,0xA4,0x9B),
- o3(0xE6,0xA2,0xA6), o3(0xE5,0xA4,0xA5),
- o3(0xE5,0xA4,0xAC), o3(0xE5,0xA4,0xAD),
- o3(0xE5,0xA4,0xB2), o3(0xE5,0xA4,0xB8),
- o3(0xE5,0xA4,0xBE), o3(0xE7,0xAB,0x92),
- o3(0xE5,0xA5,0x95), o3(0xE5,0xA5,0x90),
- o3(0xE5,0xA5,0x8E), o3(0xE5,0xA5,0x9A),
- o3(0xE5,0xA5,0x98), o3(0xE5,0xA5,0xA2),
- o3(0xE5,0xA5,0xA0), o3(0xE5,0xA5,0xA7),
- o3(0xE5,0xA5,0xAC), o3(0xE5,0xA5,0xA9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D4 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D4_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D5_infos[95] = {
- o3(0xE5,0xA5,0xB8), o3(0xE5,0xA6,0x81),
- o3(0xE5,0xA6,0x9D), o3(0xE4,0xBD,0x9E),
- o3(0xE4,0xBE,0xAB), o3(0xE5,0xA6,0xA3),
- o3(0xE5,0xA6,0xB2), o3(0xE5,0xA7,0x86),
- o3(0xE5,0xA7,0xA8), o3(0xE5,0xA7,0x9C),
- o3(0xE5,0xA6,0x8D), o3(0xE5,0xA7,0x99),
- o3(0xE5,0xA7,0x9A), o3(0xE5,0xA8,0xA5),
- o3(0xE5,0xA8,0x9F), o3(0xE5,0xA8,0x91),
- o3(0xE5,0xA8,0x9C), o3(0xE5,0xA8,0x89),
- o3(0xE5,0xA8,0x9A), o3(0xE5,0xA9,0x80),
- o3(0xE5,0xA9,0xAC), o3(0xE5,0xA9,0x89),
- o3(0xE5,0xA8,0xB5), o3(0xE5,0xA8,0xB6),
- o3(0xE5,0xA9,0xA2), o3(0xE5,0xA9,0xAA),
- o3(0xE5,0xAA,0x9A), o3(0xE5,0xAA,0xBC),
- o3(0xE5,0xAA,0xBE), o3(0xE5,0xAB,0x8B),
- o3(0xE5,0xAB,0x82), o3(0xE5,0xAA,0xBD),
- o3(0xE5,0xAB,0xA3), o3(0xE5,0xAB,0x97),
- o3(0xE5,0xAB,0xA6), o3(0xE5,0xAB,0xA9),
- o3(0xE5,0xAB,0x96), o3(0xE5,0xAB,0xBA),
- o3(0xE5,0xAB,0xBB), o3(0xE5,0xAC,0x8C),
- o3(0xE5,0xAC,0x8B), o3(0xE5,0xAC,0x96),
- o3(0xE5,0xAC,0xB2), o3(0xE5,0xAB,0x90),
- o3(0xE5,0xAC,0xAA), o3(0xE5,0xAC,0xB6),
- o3(0xE5,0xAC,0xBE), o3(0xE5,0xAD,0x83),
- o3(0xE5,0xAD,0x85), o3(0xE5,0xAD,0x80),
- o3(0xE5,0xAD,0x91), o3(0xE5,0xAD,0x95),
- o3(0xE5,0xAD,0x9A), o3(0xE5,0xAD,0x9B),
- o3(0xE5,0xAD,0xA5), o3(0xE5,0xAD,0xA9),
- o3(0xE5,0xAD,0xB0), o3(0xE5,0xAD,0xB3),
- o3(0xE5,0xAD,0xB5), o3(0xE5,0xAD,0xB8),
- o3(0xE6,0x96,0x88), o3(0xE5,0xAD,0xBA),
- o3(0xE5,0xAE,0x80), o3(0xE5,0xAE,0x83),
- o3(0xE5,0xAE,0xA6), o3(0xE5,0xAE,0xB8),
- o3(0xE5,0xAF,0x83), o3(0xE5,0xAF,0x87),
- o3(0xE5,0xAF,0x89), o3(0xE5,0xAF,0x94),
- o3(0xE5,0xAF,0x90), o3(0xE5,0xAF,0xA4),
- o3(0xE5,0xAF,0xA6), o3(0xE5,0xAF,0xA2),
- o3(0xE5,0xAF,0x9E), o3(0xE5,0xAF,0xA5),
- o3(0xE5,0xAF,0xAB), o3(0xE5,0xAF,0xB0),
- o3(0xE5,0xAF,0xB6), o3(0xE5,0xAF,0xB3),
- o3(0xE5,0xB0,0x85), o3(0xE5,0xB0,0x87),
- o3(0xE5,0xB0,0x88), o3(0xE5,0xB0,0x8D),
- o3(0xE5,0xB0,0x93), o3(0xE5,0xB0,0xA0),
- o3(0xE5,0xB0,0xA2), o3(0xE5,0xB0,0xA8),
- o3(0xE5,0xB0,0xB8), o3(0xE5,0xB0,0xB9),
- o3(0xE5,0xB1,0x81), o3(0xE5,0xB1,0x86),
- o3(0xE5,0xB1,0x8E), o3(0xE5,0xB1,0x93),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D5 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D5_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D6_infos[95] = {
- o3(0xE5,0xB1,0x90), o3(0xE5,0xB1,0x8F),
- o3(0xE5,0xAD,0xB1), o3(0xE5,0xB1,0xAC),
- o3(0xE5,0xB1,0xAE), o3(0xE4,0xB9,0xA2),
- o3(0xE5,0xB1,0xB6), o3(0xE5,0xB1,0xB9),
- o3(0xE5,0xB2,0x8C), o3(0xE5,0xB2,0x91),
- o3(0xE5,0xB2,0x94), o3(0xE5,0xA6,0x9B),
- o3(0xE5,0xB2,0xAB), o3(0xE5,0xB2,0xBB),
- o3(0xE5,0xB2,0xB6), o3(0xE5,0xB2,0xBC),
- o3(0xE5,0xB2,0xB7), o3(0xE5,0xB3,0x85),
- o3(0xE5,0xB2,0xBE), o3(0xE5,0xB3,0x87),
- o3(0xE5,0xB3,0x99), o3(0xE5,0xB3,0xA9),
- o3(0xE5,0xB3,0xBD), o3(0xE5,0xB3,0xBA),
- o3(0xE5,0xB3,0xAD), o3(0xE5,0xB6,0x8C),
- o3(0xE5,0xB3,0xAA), o3(0xE5,0xB4,0x8B),
- o3(0xE5,0xB4,0x95), o3(0xE5,0xB4,0x97),
- o3(0xE5,0xB5,0x9C), o3(0xE5,0xB4,0x9F),
- o3(0xE5,0xB4,0x9B), o3(0xE5,0xB4,0x91),
- o3(0xE5,0xB4,0x94), o3(0xE5,0xB4,0xA2),
- o3(0xE5,0xB4,0x9A), o3(0xE5,0xB4,0x99),
- o3(0xE5,0xB4,0x98), o3(0xE5,0xB5,0x8C),
- o3(0xE5,0xB5,0x92), o3(0xE5,0xB5,0x8E),
- o3(0xE5,0xB5,0x8B), o3(0xE5,0xB5,0xAC),
- o3(0xE5,0xB5,0xB3), o3(0xE5,0xB5,0xB6),
- o3(0xE5,0xB6,0x87), o3(0xE5,0xB6,0x84),
- o3(0xE5,0xB6,0x82), o3(0xE5,0xB6,0xA2),
- o3(0xE5,0xB6,0x9D), o3(0xE5,0xB6,0xAC),
- o3(0xE5,0xB6,0xAE), o3(0xE5,0xB6,0xBD),
- o3(0xE5,0xB6,0x90), o3(0xE5,0xB6,0xB7),
- o3(0xE5,0xB6,0xBC), o3(0xE5,0xB7,0x89),
- o3(0xE5,0xB7,0x8D), o3(0xE5,0xB7,0x93),
- o3(0xE5,0xB7,0x92), o3(0xE5,0xB7,0x96),
- o3(0xE5,0xB7,0x9B), o3(0xE5,0xB7,0xAB),
- o3(0xE5,0xB7,0xB2), o3(0xE5,0xB7,0xB5),
- o3(0xE5,0xB8,0x8B), o3(0xE5,0xB8,0x9A),
- o3(0xE5,0xB8,0x99), o3(0xE5,0xB8,0x91),
- o3(0xE5,0xB8,0x9B), o3(0xE5,0xB8,0xB6),
- o3(0xE5,0xB8,0xB7), o3(0xE5,0xB9,0x84),
- o3(0xE5,0xB9,0x83), o3(0xE5,0xB9,0x80),
- o3(0xE5,0xB9,0x8E), o3(0xE5,0xB9,0x97),
- o3(0xE5,0xB9,0x94), o3(0xE5,0xB9,0x9F),
- o3(0xE5,0xB9,0xA2), o3(0xE5,0xB9,0xA4),
- o3(0xE5,0xB9,0x87), o3(0xE5,0xB9,0xB5),
- o3(0xE5,0xB9,0xB6), o3(0xE5,0xB9,0xBA),
- o3(0xE9,0xBA,0xBC), o3(0xE5,0xB9,0xBF),
- o3(0xE5,0xBA,0xA0), o3(0xE5,0xBB,0x81),
- o3(0xE5,0xBB,0x82), o3(0xE5,0xBB,0x88),
- o3(0xE5,0xBB,0x90), o3(0xE5,0xBB,0x8F),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D6 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D6_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D7_infos[95] = {
- o3(0xE5,0xBB,0x96), o3(0xE5,0xBB,0xA3),
- o3(0xE5,0xBB,0x9D), o3(0xE5,0xBB,0x9A),
- o3(0xE5,0xBB,0x9B), o3(0xE5,0xBB,0xA2),
- o3(0xE5,0xBB,0xA1), o3(0xE5,0xBB,0xA8),
- o3(0xE5,0xBB,0xA9), o3(0xE5,0xBB,0xAC),
- o3(0xE5,0xBB,0xB1), o3(0xE5,0xBB,0xB3),
- o3(0xE5,0xBB,0xB0), o3(0xE5,0xBB,0xB4),
- o3(0xE5,0xBB,0xB8), o3(0xE5,0xBB,0xBE),
- o3(0xE5,0xBC,0x83), o3(0xE5,0xBC,0x89),
- o3(0xE5,0xBD,0x9D), o3(0xE5,0xBD,0x9C),
- o3(0xE5,0xBC,0x8B), o3(0xE5,0xBC,0x91),
- o3(0xE5,0xBC,0x96), o3(0xE5,0xBC,0xA9),
- o3(0xE5,0xBC,0xAD), o3(0xE5,0xBC,0xB8),
- o3(0xE5,0xBD,0x81), o3(0xE5,0xBD,0x88),
- o3(0xE5,0xBD,0x8C), o3(0xE5,0xBD,0x8E),
- o3(0xE5,0xBC,0xAF), o3(0xE5,0xBD,0x91),
- o3(0xE5,0xBD,0x96), o3(0xE5,0xBD,0x97),
- o3(0xE5,0xBD,0x99), o3(0xE5,0xBD,0xA1),
- o3(0xE5,0xBD,0xAD), o3(0xE5,0xBD,0xB3),
- o3(0xE5,0xBD,0xB7), o3(0xE5,0xBE,0x83),
- o3(0xE5,0xBE,0x82), o3(0xE5,0xBD,0xBF),
- o3(0xE5,0xBE,0x8A), o3(0xE5,0xBE,0x88),
- o3(0xE5,0xBE,0x91), o3(0xE5,0xBE,0x87),
- o3(0xE5,0xBE,0x9E), o3(0xE5,0xBE,0x99),
- o3(0xE5,0xBE,0x98), o3(0xE5,0xBE,0xA0),
- o3(0xE5,0xBE,0xA8), o3(0xE5,0xBE,0xAD),
- o3(0xE5,0xBE,0xBC), o3(0xE5,0xBF,0x96),
- o3(0xE5,0xBF,0xBB), o3(0xE5,0xBF,0xA4),
- o3(0xE5,0xBF,0xB8), o3(0xE5,0xBF,0xB1),
- o3(0xE5,0xBF,0x9D), o3(0xE6,0x82,0xB3),
- o3(0xE5,0xBF,0xBF), o3(0xE6,0x80,0xA1),
- o3(0xE6,0x81,0xA0), o3(0xE6,0x80,0x99),
- o3(0xE6,0x80,0x90), o3(0xE6,0x80,0xA9),
- o3(0xE6,0x80,0x8E), o3(0xE6,0x80,0xB1),
- o3(0xE6,0x80,0x9B), o3(0xE6,0x80,0x95),
- o3(0xE6,0x80,0xAB), o3(0xE6,0x80,0xA6),
- o3(0xE6,0x80,0x8F), o3(0xE6,0x80,0xBA),
- o3(0xE6,0x81,0x9A), o3(0xE6,0x81,0x81),
- o3(0xE6,0x81,0xAA), o3(0xE6,0x81,0xB7),
- o3(0xE6,0x81,0x9F), o3(0xE6,0x81,0x8A),
- o3(0xE6,0x81,0x86), o3(0xE6,0x81,0x8D),
- o3(0xE6,0x81,0xA3), o3(0xE6,0x81,0x83),
- o3(0xE6,0x81,0xA4), o3(0xE6,0x81,0x82),
- o3(0xE6,0x81,0xAC), o3(0xE6,0x81,0xAB),
- o3(0xE6,0x81,0x99), o3(0xE6,0x82,0x81),
- o3(0xE6,0x82,0x8D), o3(0xE6,0x83,0xA7),
- o3(0xE6,0x82,0x83), o3(0xE6,0x82,0x9A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D7 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D7_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D8_infos[95] = {
- o3(0xE6,0x82,0x84), o3(0xE6,0x82,0x9B),
- o3(0xE6,0x82,0x96), o3(0xE6,0x82,0x97),
- o3(0xE6,0x82,0x92), o3(0xE6,0x82,0xA7),
- o3(0xE6,0x82,0x8B), o3(0xE6,0x83,0xA1),
- o3(0xE6,0x82,0xB8), o3(0xE6,0x83,0xA0),
- o3(0xE6,0x83,0x93), o3(0xE6,0x82,0xB4),
- o3(0xE5,0xBF,0xB0), o3(0xE6,0x82,0xBD),
- o3(0xE6,0x83,0x86), o3(0xE6,0x82,0xB5),
- o3(0xE6,0x83,0x98), o3(0xE6,0x85,0x8D),
- o3(0xE6,0x84,0x95), o3(0xE6,0x84,0x86),
- o3(0xE6,0x83,0xB6), o3(0xE6,0x83,0xB7),
- o3(0xE6,0x84,0x80), o3(0xE6,0x83,0xB4),
- o3(0xE6,0x83,0xBA), o3(0xE6,0x84,0x83),
- o3(0xE6,0x84,0xA1), o3(0xE6,0x83,0xBB),
- o3(0xE6,0x83,0xB1), o3(0xE6,0x84,0x8D),
- o3(0xE6,0x84,0x8E), o3(0xE6,0x85,0x87),
- o3(0xE6,0x84,0xBE), o3(0xE6,0x84,0xA8),
- o3(0xE6,0x84,0xA7), o3(0xE6,0x85,0x8A),
- o3(0xE6,0x84,0xBF), o3(0xE6,0x84,0xBC),
- o3(0xE6,0x84,0xAC), o3(0xE6,0x84,0xB4),
- o3(0xE6,0x84,0xBD), o3(0xE6,0x85,0x82),
- o3(0xE6,0x85,0x84), o3(0xE6,0x85,0xB3),
- o3(0xE6,0x85,0xB7), o3(0xE6,0x85,0x98),
- o3(0xE6,0x85,0x99), o3(0xE6,0x85,0x9A),
- o3(0xE6,0x85,0xAB), o3(0xE6,0x85,0xB4),
- o3(0xE6,0x85,0xAF), o3(0xE6,0x85,0xA5),
- o3(0xE6,0x85,0xB1), o3(0xE6,0x85,0x9F),
- o3(0xE6,0x85,0x9D), o3(0xE6,0x85,0x93),
- o3(0xE6,0x85,0xB5), o3(0xE6,0x86,0x99),
- o3(0xE6,0x86,0x96), o3(0xE6,0x86,0x87),
- o3(0xE6,0x86,0xAC), o3(0xE6,0x86,0x94),
- o3(0xE6,0x86,0x9A), o3(0xE6,0x86,0x8A),
- o3(0xE6,0x86,0x91), o3(0xE6,0x86,0xAB),
- o3(0xE6,0x86,0xAE), o3(0xE6,0x87,0x8C),
- o3(0xE6,0x87,0x8A), o3(0xE6,0x87,0x89),
- o3(0xE6,0x87,0xB7), o3(0xE6,0x87,0x88),
- o3(0xE6,0x87,0x83), o3(0xE6,0x87,0x86),
- o3(0xE6,0x86,0xBA), o3(0xE6,0x87,0x8B),
- o3(0xE7,0xBD,0xB9), o3(0xE6,0x87,0x8D),
- o3(0xE6,0x87,0xA6), o3(0xE6,0x87,0xA3),
- o3(0xE6,0x87,0xB6), o3(0xE6,0x87,0xBA),
- o3(0xE6,0x87,0xB4), o3(0xE6,0x87,0xBF),
- o3(0xE6,0x87,0xBD), o3(0xE6,0x87,0xBC),
- o3(0xE6,0x87,0xBE), o3(0xE6,0x88,0x80),
- o3(0xE6,0x88,0x88), o3(0xE6,0x88,0x89),
- o3(0xE6,0x88,0x8D), o3(0xE6,0x88,0x8C),
- o3(0xE6,0x88,0x94), o3(0xE6,0x88,0x9B),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D8 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D8_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_D9_infos[95] = {
- o3(0xE6,0x88,0x9E), o3(0xE6,0x88,0xA1),
- o3(0xE6,0x88,0xAA), o3(0xE6,0x88,0xAE),
- o3(0xE6,0x88,0xB0), o3(0xE6,0x88,0xB2),
- o3(0xE6,0x88,0xB3), o3(0xE6,0x89,0x81),
- o3(0xE6,0x89,0x8E), o3(0xE6,0x89,0x9E),
- o3(0xE6,0x89,0xA3), o3(0xE6,0x89,0x9B),
- o3(0xE6,0x89,0xA0), o3(0xE6,0x89,0xA8),
- o3(0xE6,0x89,0xBC), o3(0xE6,0x8A,0x82),
- o3(0xE6,0x8A,0x89), o3(0xE6,0x89,0xBE),
- o3(0xE6,0x8A,0x92), o3(0xE6,0x8A,0x93),
- o3(0xE6,0x8A,0x96), o3(0xE6,0x8B,0x94),
- o3(0xE6,0x8A,0x83), o3(0xE6,0x8A,0x94),
- o3(0xE6,0x8B,0x97), o3(0xE6,0x8B,0x91),
- o3(0xE6,0x8A,0xBB), o3(0xE6,0x8B,0x8F),
- o3(0xE6,0x8B,0xBF), o3(0xE6,0x8B,0x86),
- o3(0xE6,0x93,0x94), o3(0xE6,0x8B,0x88),
- o3(0xE6,0x8B,0x9C), o3(0xE6,0x8B,0x8C),
- o3(0xE6,0x8B,0x8A), o3(0xE6,0x8B,0x82),
- o3(0xE6,0x8B,0x87), o3(0xE6,0x8A,0x9B),
- o3(0xE6,0x8B,0x89), o3(0xE6,0x8C,0x8C),
- o3(0xE6,0x8B,0xAE), o3(0xE6,0x8B,0xB1),
- o3(0xE6,0x8C,0xA7), o3(0xE6,0x8C,0x82),
- o3(0xE6,0x8C,0x88), o3(0xE6,0x8B,0xAF),
- o3(0xE6,0x8B,0xB5), o3(0xE6,0x8D,0x90),
- o3(0xE6,0x8C,0xBE), o3(0xE6,0x8D,0x8D),
- o3(0xE6,0x90,0x9C), o3(0xE6,0x8D,0x8F),
- o3(0xE6,0x8E,0x96), o3(0xE6,0x8E,0x8E),
- o3(0xE6,0x8E,0x80), o3(0xE6,0x8E,0xAB),
- o3(0xE6,0x8D,0xB6), o3(0xE6,0x8E,0xA3),
- o3(0xE6,0x8E,0x8F), o3(0xE6,0x8E,0x89),
- o3(0xE6,0x8E,0x9F), o3(0xE6,0x8E,0xB5),
- o3(0xE6,0x8D,0xAB), o3(0xE6,0x8D,0xA9),
- o3(0xE6,0x8E,0xBE), o3(0xE6,0x8F,0xA9),
- o3(0xE6,0x8F,0x80), o3(0xE6,0x8F,0x86),
- o3(0xE6,0x8F,0xA3), o3(0xE6,0x8F,0x89),
- o3(0xE6,0x8F,0x92), o3(0xE6,0x8F,0xB6),
- o3(0xE6,0x8F,0x84), o3(0xE6,0x90,0x96),
- o3(0xE6,0x90,0xB4), o3(0xE6,0x90,0x86),
- o3(0xE6,0x90,0x93), o3(0xE6,0x90,0xA6),
- o3(0xE6,0x90,0xB6), o3(0xE6,0x94,0x9D),
- o3(0xE6,0x90,0x97), o3(0xE6,0x90,0xA8),
- o3(0xE6,0x90,0x8F), o3(0xE6,0x91,0xA7),
- o3(0xE6,0x91,0xAF), o3(0xE6,0x91,0xB6),
- o3(0xE6,0x91,0x8E), o3(0xE6,0x94,0xAA),
- o3(0xE6,0x92,0x95), o3(0xE6,0x92,0x93),
- o3(0xE6,0x92,0xA5), o3(0xE6,0x92,0xA9),
- o3(0xE6,0x92,0x88), o3(0xE6,0x92,0xBC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_D9 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_D9_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_DA_infos[95] = {
- o3(0xE6,0x93,0x9A), o3(0xE6,0x93,0x92),
- o3(0xE6,0x93,0x85), o3(0xE6,0x93,0x87),
- o3(0xE6,0x92,0xBB), o3(0xE6,0x93,0x98),
- o3(0xE6,0x93,0x82), o3(0xE6,0x93,0xB1),
- o3(0xE6,0x93,0xA7), o3(0xE8,0x88,0x89),
- o3(0xE6,0x93,0xA0), o3(0xE6,0x93,0xA1),
- o3(0xE6,0x8A,0xAC), o3(0xE6,0x93,0xA3),
- o3(0xE6,0x93,0xAF), o3(0xE6,0x94,0xAC),
- o3(0xE6,0x93,0xB6), o3(0xE6,0x93,0xB4),
- o3(0xE6,0x93,0xB2), o3(0xE6,0x93,0xBA),
- o3(0xE6,0x94,0x80), o3(0xE6,0x93,0xBD),
- o3(0xE6,0x94,0x98), o3(0xE6,0x94,0x9C),
- o3(0xE6,0x94,0x85), o3(0xE6,0x94,0xA4),
- o3(0xE6,0x94,0xA3), o3(0xE6,0x94,0xAB),
- o3(0xE6,0x94,0xB4), o3(0xE6,0x94,0xB5),
- o3(0xE6,0x94,0xB7), o3(0xE6,0x94,0xB6),
- o3(0xE6,0x94,0xB8), o3(0xE7,0x95,0x8B),
- o3(0xE6,0x95,0x88), o3(0xE6,0x95,0x96),
- o3(0xE6,0x95,0x95), o3(0xE6,0x95,0x8D),
- o3(0xE6,0x95,0x98), o3(0xE6,0x95,0x9E),
- o3(0xE6,0x95,0x9D), o3(0xE6,0x95,0xB2),
- o3(0xE6,0x95,0xB8), o3(0xE6,0x96,0x82),
- o3(0xE6,0x96,0x83), o3(0xE8,0xAE,0x8A),
- o3(0xE6,0x96,0x9B), o3(0xE6,0x96,0x9F),
- o3(0xE6,0x96,0xAB), o3(0xE6,0x96,0xB7),
- o3(0xE6,0x97,0x83), o3(0xE6,0x97,0x86),
- o3(0xE6,0x97,0x81), o3(0xE6,0x97,0x84),
- o3(0xE6,0x97,0x8C), o3(0xE6,0x97,0x92),
- o3(0xE6,0x97,0x9B), o3(0xE6,0x97,0x99),
- o3(0xE6,0x97,0xA0), o3(0xE6,0x97,0xA1),
- o3(0xE6,0x97,0xB1), o3(0xE6,0x9D,0xB2),
- o3(0xE6,0x98,0x8A), o3(0xE6,0x98,0x83),
- o3(0xE6,0x97,0xBB), o3(0xE6,0x9D,0xB3),
- o3(0xE6,0x98,0xB5), o3(0xE6,0x98,0xB6),
- o3(0xE6,0x98,0xB4), o3(0xE6,0x98,0x9C),
- o3(0xE6,0x99,0x8F), o3(0xE6,0x99,0x84),
- o3(0xE6,0x99,0x89), o3(0xE6,0x99,0x81),
- o3(0xE6,0x99,0x9E), o3(0xE6,0x99,0x9D),
- o3(0xE6,0x99,0xA4), o3(0xE6,0x99,0xA7),
- o3(0xE6,0x99,0xA8), o3(0xE6,0x99,0x9F),
- o3(0xE6,0x99,0xA2), o3(0xE6,0x99,0xB0),
- o3(0xE6,0x9A,0x83), o3(0xE6,0x9A,0x88),
- o3(0xE6,0x9A,0x8E), o3(0xE6,0x9A,0x89),
- o3(0xE6,0x9A,0x84), o3(0xE6,0x9A,0x98),
- o3(0xE6,0x9A,0x9D), o3(0xE6,0x9B,0x81),
- o3(0xE6,0x9A,0xB9), o3(0xE6,0x9B,0x89),
- o3(0xE6,0x9A,0xBE), o3(0xE6,0x9A,0xBC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_DA = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_DA_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_DB_infos[95] = {
- o3(0xE6,0x9B,0x84), o3(0xE6,0x9A,0xB8),
- o3(0xE6,0x9B,0x96), o3(0xE6,0x9B,0x9A),
- o3(0xE6,0x9B,0xA0), o3(0xE6,0x98,0xBF),
- o3(0xE6,0x9B,0xA6), o3(0xE6,0x9B,0xA9),
- o3(0xE6,0x9B,0xB0), o3(0xE6,0x9B,0xB5),
- o3(0xE6,0x9B,0xB7), o3(0xE6,0x9C,0x8F),
- o3(0xE6,0x9C,0x96), o3(0xE6,0x9C,0x9E),
- o3(0xE6,0x9C,0xA6), o3(0xE6,0x9C,0xA7),
- o3(0xE9,0x9C,0xB8), o3(0xE6,0x9C,0xAE),
- o3(0xE6,0x9C,0xBF), o3(0xE6,0x9C,0xB6),
- o3(0xE6,0x9D,0x81), o3(0xE6,0x9C,0xB8),
- o3(0xE6,0x9C,0xB7), o3(0xE6,0x9D,0x86),
- o3(0xE6,0x9D,0x9E), o3(0xE6,0x9D,0xA0),
- o3(0xE6,0x9D,0x99), o3(0xE6,0x9D,0xA3),
- o3(0xE6,0x9D,0xA4), o3(0xE6,0x9E,0x89),
- o3(0xE6,0x9D,0xB0), o3(0xE6,0x9E,0xA9),
- o3(0xE6,0x9D,0xBC), o3(0xE6,0x9D,0xAA),
- o3(0xE6,0x9E,0x8C), o3(0xE6,0x9E,0x8B),
- o3(0xE6,0x9E,0xA6), o3(0xE6,0x9E,0xA1),
- o3(0xE6,0x9E,0x85), o3(0xE6,0x9E,0xB7),
- o3(0xE6,0x9F,0xAF), o3(0xE6,0x9E,0xB4),
- o3(0xE6,0x9F,0xAC), o3(0xE6,0x9E,0xB3),
- o3(0xE6,0x9F,0xA9), o3(0xE6,0x9E,0xB8),
- o3(0xE6,0x9F,0xA4), o3(0xE6,0x9F,0x9E),
- o3(0xE6,0x9F,0x9D), o3(0xE6,0x9F,0xA2),
- o3(0xE6,0x9F,0xAE), o3(0xE6,0x9E,0xB9),
- o3(0xE6,0x9F,0x8E), o3(0xE6,0x9F,0x86),
- o3(0xE6,0x9F,0xA7), o3(0xE6,0xAA,0x9C),
- o3(0xE6,0xA0,0x9E), o3(0xE6,0xA1,0x86),
- o3(0xE6,0xA0,0xA9), o3(0xE6,0xA1,0x80),
- o3(0xE6,0xA1,0x8D), o3(0xE6,0xA0,0xB2),
- o3(0xE6,0xA1,0x8E), o3(0xE6,0xA2,0xB3),
- o3(0xE6,0xA0,0xAB), o3(0xE6,0xA1,0x99),
- o3(0xE6,0xA1,0xA3), o3(0xE6,0xA1,0xB7),
- o3(0xE6,0xA1,0xBF), o3(0xE6,0xA2,0x9F),
- o3(0xE6,0xA2,0x8F), o3(0xE6,0xA2,0xAD),
- o3(0xE6,0xA2,0x94), o3(0xE6,0xA2,0x9D),
- o3(0xE6,0xA2,0x9B), o3(0xE6,0xA2,0x83),
- o3(0xE6,0xAA,0xAE), o3(0xE6,0xA2,0xB9),
- o3(0xE6,0xA1,0xB4), o3(0xE6,0xA2,0xB5),
- o3(0xE6,0xA2,0xA0), o3(0xE6,0xA2,0xBA),
- o3(0xE6,0xA4,0x8F), o3(0xE6,0xA2,0x8D),
- o3(0xE6,0xA1,0xBE), o3(0xE6,0xA4,0x81),
- o3(0xE6,0xA3,0x8A), o3(0xE6,0xA4,0x88),
- o3(0xE6,0xA3,0x98), o3(0xE6,0xA4,0xA2),
- o3(0xE6,0xA4,0xA6), o3(0xE6,0xA3,0xA1),
- o3(0xE6,0xA4,0x8C), o3(0xE6,0xA3,0x8D),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_DB = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_DB_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_DC_infos[95] = {
- o3(0xE6,0xA3,0x94), o3(0xE6,0xA3,0xA7),
- o3(0xE6,0xA3,0x95), o3(0xE6,0xA4,0xB6),
- o3(0xE6,0xA4,0x92), o3(0xE6,0xA4,0x84),
- o3(0xE6,0xA3,0x97), o3(0xE6,0xA3,0xA3),
- o3(0xE6,0xA4,0xA5), o3(0xE6,0xA3,0xB9),
- o3(0xE6,0xA3,0xA0), o3(0xE6,0xA3,0xAF),
- o3(0xE6,0xA4,0xA8), o3(0xE6,0xA4,0xAA),
- o3(0xE6,0xA4,0x9A), o3(0xE6,0xA4,0xA3),
- o3(0xE6,0xA4,0xA1), o3(0xE6,0xA3,0x86),
- o3(0xE6,0xA5,0xB9), o3(0xE6,0xA5,0xB7),
- o3(0xE6,0xA5,0x9C), o3(0xE6,0xA5,0xB8),
- o3(0xE6,0xA5,0xAB), o3(0xE6,0xA5,0x94),
- o3(0xE6,0xA5,0xBE), o3(0xE6,0xA5,0xAE),
- o3(0xE6,0xA4,0xB9), o3(0xE6,0xA5,0xB4),
- o3(0xE6,0xA4,0xBD), o3(0xE6,0xA5,0x99),
- o3(0xE6,0xA4,0xB0), o3(0xE6,0xA5,0xA1),
- o3(0xE6,0xA5,0x9E), o3(0xE6,0xA5,0x9D),
- o3(0xE6,0xA6,0x81), o3(0xE6,0xA5,0xAA),
- o3(0xE6,0xA6,0xB2), o3(0xE6,0xA6,0xAE),
- o3(0xE6,0xA7,0x90), o3(0xE6,0xA6,0xBF),
- o3(0xE6,0xA7,0x81), o3(0xE6,0xA7,0x93),
- o3(0xE6,0xA6,0xBE), o3(0xE6,0xA7,0x8E),
- o3(0xE5,0xAF,0xA8), o3(0xE6,0xA7,0x8A),
- o3(0xE6,0xA7,0x9D), o3(0xE6,0xA6,0xBB),
- o3(0xE6,0xA7,0x83), o3(0xE6,0xA6,0xA7),
- o3(0xE6,0xA8,0xAE), o3(0xE6,0xA6,0x91),
- o3(0xE6,0xA6,0xA0), o3(0xE6,0xA6,0x9C),
- o3(0xE6,0xA6,0x95), o3(0xE6,0xA6,0xB4),
- o3(0xE6,0xA7,0x9E), o3(0xE6,0xA7,0xA8),
- o3(0xE6,0xA8,0x82), o3(0xE6,0xA8,0x9B),
- o3(0xE6,0xA7,0xBF), o3(0xE6,0xAC,0x8A),
- o3(0xE6,0xA7,0xB9), o3(0xE6,0xA7,0xB2),
- o3(0xE6,0xA7,0xA7), o3(0xE6,0xA8,0x85),
- o3(0xE6,0xA6,0xB1), o3(0xE6,0xA8,0x9E),
- o3(0xE6,0xA7,0xAD), o3(0xE6,0xA8,0x94),
- o3(0xE6,0xA7,0xAB), o3(0xE6,0xA8,0x8A),
- o3(0xE6,0xA8,0x92), o3(0xE6,0xAB,0x81),
- o3(0xE6,0xA8,0xA3), o3(0xE6,0xA8,0x93),
- o3(0xE6,0xA9,0x84), o3(0xE6,0xA8,0x8C),
- o3(0xE6,0xA9,0xB2), o3(0xE6,0xA8,0xB6),
- o3(0xE6,0xA9,0xB8), o3(0xE6,0xA9,0x87),
- o3(0xE6,0xA9,0xA2), o3(0xE6,0xA9,0x99),
- o3(0xE6,0xA9,0xA6), o3(0xE6,0xA9,0x88),
- o3(0xE6,0xA8,0xB8), o3(0xE6,0xA8,0xA2),
- o3(0xE6,0xAA,0x90), o3(0xE6,0xAA,0x8D),
- o3(0xE6,0xAA,0xA0), o3(0xE6,0xAA,0x84),
- o3(0xE6,0xAA,0xA2), o3(0xE6,0xAA,0xA3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_DC = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_DC_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_DD_infos[95] = {
- o3(0xE6,0xAA,0x97), o3(0xE8,0x98,0x97),
- o3(0xE6,0xAA,0xBB), o3(0xE6,0xAB,0x83),
- o3(0xE6,0xAB,0x82), o3(0xE6,0xAA,0xB8),
- o3(0xE6,0xAA,0xB3), o3(0xE6,0xAA,0xAC),
- o3(0xE6,0xAB,0x9E), o3(0xE6,0xAB,0x91),
- o3(0xE6,0xAB,0x9F), o3(0xE6,0xAA,0xAA),
- o3(0xE6,0xAB,0x9A), o3(0xE6,0xAB,0xAA),
- o3(0xE6,0xAB,0xBB), o3(0xE6,0xAC,0x85),
- o3(0xE8,0x98,0x96), o3(0xE6,0xAB,0xBA),
- o3(0xE6,0xAC,0x92), o3(0xE6,0xAC,0x96),
- o3(0xE9,0xAC,0xB1), o3(0xE6,0xAC,0x9F),
- o3(0xE6,0xAC,0xB8), o3(0xE6,0xAC,0xB7),
- o3(0xE7,0x9B,0x9C), o3(0xE6,0xAC,0xB9),
- o3(0xE9,0xA3,0xAE), o3(0xE6,0xAD,0x87),
- o3(0xE6,0xAD,0x83), o3(0xE6,0xAD,0x89),
- o3(0xE6,0xAD,0x90), o3(0xE6,0xAD,0x99),
- o3(0xE6,0xAD,0x94), o3(0xE6,0xAD,0x9B),
- o3(0xE6,0xAD,0x9F), o3(0xE6,0xAD,0xA1),
- o3(0xE6,0xAD,0xB8), o3(0xE6,0xAD,0xB9),
- o3(0xE6,0xAD,0xBF), o3(0xE6,0xAE,0x80),
- o3(0xE6,0xAE,0x84), o3(0xE6,0xAE,0x83),
- o3(0xE6,0xAE,0x8D), o3(0xE6,0xAE,0x98),
- o3(0xE6,0xAE,0x95), o3(0xE6,0xAE,0x9E),
- o3(0xE6,0xAE,0xA4), o3(0xE6,0xAE,0xAA),
- o3(0xE6,0xAE,0xAB), o3(0xE6,0xAE,0xAF),
- o3(0xE6,0xAE,0xB2), o3(0xE6,0xAE,0xB1),
- o3(0xE6,0xAE,0xB3), o3(0xE6,0xAE,0xB7),
- o3(0xE6,0xAE,0xBC), o3(0xE6,0xAF,0x86),
- o3(0xE6,0xAF,0x8B), o3(0xE6,0xAF,0x93),
- o3(0xE6,0xAF,0x9F), o3(0xE6,0xAF,0xAC),
- o3(0xE6,0xAF,0xAB), o3(0xE6,0xAF,0xB3),
- o3(0xE6,0xAF,0xAF), o3(0xE9,0xBA,0xBE),
- o3(0xE6,0xB0,0x88), o3(0xE6,0xB0,0x93),
- o3(0xE6,0xB0,0x94), o3(0xE6,0xB0,0x9B),
- o3(0xE6,0xB0,0xA4), o3(0xE6,0xB0,0xA3),
- o3(0xE6,0xB1,0x9E), o3(0xE6,0xB1,0x95),
- o3(0xE6,0xB1,0xA2), o3(0xE6,0xB1,0xAA),
- o3(0xE6,0xB2,0x82), o3(0xE6,0xB2,0x8D),
- o3(0xE6,0xB2,0x9A), o3(0xE6,0xB2,0x81),
- o3(0xE6,0xB2,0x9B), o3(0xE6,0xB1,0xBE),
- o3(0xE6,0xB1,0xA8), o3(0xE6,0xB1,0xB3),
- o3(0xE6,0xB2,0x92), o3(0xE6,0xB2,0x90),
- o3(0xE6,0xB3,0x84), o3(0xE6,0xB3,0xB1),
- o3(0xE6,0xB3,0x93), o3(0xE6,0xB2,0xBD),
- o3(0xE6,0xB3,0x97), o3(0xE6,0xB3,0x85),
- o3(0xE6,0xB3,0x9D), o3(0xE6,0xB2,0xAE),
- o3(0xE6,0xB2,0xB1), o3(0xE6,0xB2,0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_DD = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_DD_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_DE_infos[95] = {
- o3(0xE6,0xB2,0xBA), o3(0xE6,0xB3,0x9B),
- o3(0xE6,0xB3,0xAF), o3(0xE6,0xB3,0x99),
- o3(0xE6,0xB3,0xAA), o3(0xE6,0xB4,0x9F),
- o3(0xE8,0xA1,0x8D), o3(0xE6,0xB4,0xB6),
- o3(0xE6,0xB4,0xAB), o3(0xE6,0xB4,0xBD),
- o3(0xE6,0xB4,0xB8), o3(0xE6,0xB4,0x99),
- o3(0xE6,0xB4,0xB5), o3(0xE6,0xB4,0xB3),
- o3(0xE6,0xB4,0x92), o3(0xE6,0xB4,0x8C),
- o3(0xE6,0xB5,0xA3), o3(0xE6,0xB6,0x93),
- o3(0xE6,0xB5,0xA4), o3(0xE6,0xB5,0x9A),
- o3(0xE6,0xB5,0xB9), o3(0xE6,0xB5,0x99),
- o3(0xE6,0xB6,0x8E), o3(0xE6,0xB6,0x95),
- o3(0xE6,0xBF,0xA4), o3(0xE6,0xB6,0x85),
- o3(0xE6,0xB7,0xB9), o3(0xE6,0xB8,0x95),
- o3(0xE6,0xB8,0x8A), o3(0xE6,0xB6,0xB5),
- o3(0xE6,0xB7,0x87), o3(0xE6,0xB7,0xA6),
- o3(0xE6,0xB6,0xB8), o3(0xE6,0xB7,0x86),
- o3(0xE6,0xB7,0xAC), o3(0xE6,0xB7,0x9E),
- o3(0xE6,0xB7,0x8C), o3(0xE6,0xB7,0xA8),
- o3(0xE6,0xB7,0x92), o3(0xE6,0xB7,0x85),
- o3(0xE6,0xB7,0xBA), o3(0xE6,0xB7,0x99),
- o3(0xE6,0xB7,0xA4), o3(0xE6,0xB7,0x95),
- o3(0xE6,0xB7,0xAA), o3(0xE6,0xB7,0xAE),
- o3(0xE6,0xB8,0xAD), o3(0xE6,0xB9,0xAE),
- o3(0xE6,0xB8,0xAE), o3(0xE6,0xB8,0x99),
- o3(0xE6,0xB9,0xB2), o3(0xE6,0xB9,0x9F),
- o3(0xE6,0xB8,0xBE), o3(0xE6,0xB8,0xA3),
- o3(0xE6,0xB9,0xAB), o3(0xE6,0xB8,0xAB),
- o3(0xE6,0xB9,0xB6), o3(0xE6,0xB9,0x8D),
- o3(0xE6,0xB8,0x9F), o3(0xE6,0xB9,0x83),
- o3(0xE6,0xB8,0xBA), o3(0xE6,0xB9,0x8E),
- o3(0xE6,0xB8,0xA4), o3(0xE6,0xBB,0xBF),
- o3(0xE6,0xB8,0x9D), o3(0xE6,0xB8,0xB8),
- o3(0xE6,0xBA,0x82), o3(0xE6,0xBA,0xAA),
- o3(0xE6,0xBA,0x98), o3(0xE6,0xBB,0x89),
- o3(0xE6,0xBA,0xB7), o3(0xE6,0xBB,0x93),
- o3(0xE6,0xBA,0xBD), o3(0xE6,0xBA,0xAF),
- o3(0xE6,0xBB,0x84), o3(0xE6,0xBA,0xB2),
- o3(0xE6,0xBB,0x94), o3(0xE6,0xBB,0x95),
- o3(0xE6,0xBA,0x8F), o3(0xE6,0xBA,0xA5),
- o3(0xE6,0xBB,0x82), o3(0xE6,0xBA,0x9F),
- o3(0xE6,0xBD,0x81), o3(0xE6,0xBC,0x91),
- o3(0xE7,0x81,0x8C), o3(0xE6,0xBB,0xAC),
- o3(0xE6,0xBB,0xB8), o3(0xE6,0xBB,0xBE),
- o3(0xE6,0xBC,0xBF), o3(0xE6,0xBB,0xB2),
- o3(0xE6,0xBC,0xB1), o3(0xE6,0xBB,0xAF),
- o3(0xE6,0xBC,0xB2), o3(0xE6,0xBB,0x8C),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_DE = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_DE_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_DF_infos[95] = {
- o3(0xE6,0xBC,0xBE), o3(0xE6,0xBC,0x93),
- o3(0xE6,0xBB,0xB7), o3(0xE6,0xBE,0x86),
- o3(0xE6,0xBD,0xBA), o3(0xE6,0xBD,0xB8),
- o3(0xE6,0xBE,0x81), o3(0xE6,0xBE,0x80),
- o3(0xE6,0xBD,0xAF), o3(0xE6,0xBD,0x9B),
- o3(0xE6,0xBF,0xB3), o3(0xE6,0xBD,0xAD),
- o3(0xE6,0xBE,0x82), o3(0xE6,0xBD,0xBC),
- o3(0xE6,0xBD,0x98), o3(0xE6,0xBE,0x8E),
- o3(0xE6,0xBE,0x91), o3(0xE6,0xBF,0x82),
- o3(0xE6,0xBD,0xA6), o3(0xE6,0xBE,0xB3),
- o3(0xE6,0xBE,0xA3), o3(0xE6,0xBE,0xA1),
- o3(0xE6,0xBE,0xA4), o3(0xE6,0xBE,0xB9),
- o3(0xE6,0xBF,0x86), o3(0xE6,0xBE,0xAA),
- o3(0xE6,0xBF,0x9F), o3(0xE6,0xBF,0x95),
- o3(0xE6,0xBF,0xAC), o3(0xE6,0xBF,0x94),
- o3(0xE6,0xBF,0x98), o3(0xE6,0xBF,0xB1),
- o3(0xE6,0xBF,0xAE), o3(0xE6,0xBF,0x9B),
- o3(0xE7,0x80,0x89), o3(0xE7,0x80,0x8B),
- o3(0xE6,0xBF,0xBA), o3(0xE7,0x80,0x91),
- o3(0xE7,0x80,0x81), o3(0xE7,0x80,0x8F),
- o3(0xE6,0xBF,0xBE), o3(0xE7,0x80,0x9B),
- o3(0xE7,0x80,0x9A), o3(0xE6,0xBD,0xB4),
- o3(0xE7,0x80,0x9D), o3(0xE7,0x80,0x98),
- o3(0xE7,0x80,0x9F), o3(0xE7,0x80,0xB0),
- o3(0xE7,0x80,0xBE), o3(0xE7,0x80,0xB2),
- o3(0xE7,0x81,0x91), o3(0xE7,0x81,0xA3),
- o3(0xE7,0x82,0x99), o3(0xE7,0x82,0x92),
- o3(0xE7,0x82,0xAF), o3(0xE7,0x83,0xB1),
- o3(0xE7,0x82,0xAC), o3(0xE7,0x82,0xB8),
- o3(0xE7,0x82,0xB3), o3(0xE7,0x82,0xAE),
- o3(0xE7,0x83,0x9F), o3(0xE7,0x83,0x8B),
- o3(0xE7,0x83,0x9D), o3(0xE7,0x83,0x99),
- o3(0xE7,0x84,0x89), o3(0xE7,0x83,0xBD),
- o3(0xE7,0x84,0x9C), o3(0xE7,0x84,0x99),
- o3(0xE7,0x85,0xA5), o3(0xE7,0x85,0x95),
- o3(0xE7,0x86,0x88), o3(0xE7,0x85,0xA6),
- o3(0xE7,0x85,0xA2), o3(0xE7,0x85,0x8C),
- o3(0xE7,0x85,0x96), o3(0xE7,0x85,0xAC),
- o3(0xE7,0x86,0x8F), o3(0xE7,0x87,0xBB),
- o3(0xE7,0x86,0x84), o3(0xE7,0x86,0x95),
- o3(0xE7,0x86,0xA8), o3(0xE7,0x86,0xAC),
- o3(0xE7,0x87,0x97), o3(0xE7,0x86,0xB9),
- o3(0xE7,0x86,0xBE), o3(0xE7,0x87,0x92),
- o3(0xE7,0x87,0x89), o3(0xE7,0x87,0x94),
- o3(0xE7,0x87,0x8E), o3(0xE7,0x87,0xA0),
- o3(0xE7,0x87,0xAC), o3(0xE7,0x87,0xA7),
- o3(0xE7,0x87,0xB5), o3(0xE7,0x87,0xBC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_DF = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_DF_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E0_infos[95] = {
- o3(0xE7,0x87,0xB9), o3(0xE7,0x87,0xBF),
- o3(0xE7,0x88,0x8D), o3(0xE7,0x88,0x90),
- o3(0xE7,0x88,0x9B), o3(0xE7,0x88,0xA8),
- o3(0xE7,0x88,0xAD), o3(0xE7,0x88,0xAC),
- o3(0xE7,0x88,0xB0), o3(0xE7,0x88,0xB2),
- o3(0xE7,0x88,0xBB), o3(0xE7,0x88,0xBC),
- o3(0xE7,0x88,0xBF), o3(0xE7,0x89,0x80),
- o3(0xE7,0x89,0x86), o3(0xE7,0x89,0x8B),
- o3(0xE7,0x89,0x98), o3(0xE7,0x89,0xB4),
- o3(0xE7,0x89,0xBE), o3(0xE7,0x8A,0x82),
- o3(0xE7,0x8A,0x81), o3(0xE7,0x8A,0x87),
- o3(0xE7,0x8A,0x92), o3(0xE7,0x8A,0x96),
- o3(0xE7,0x8A,0xA2), o3(0xE7,0x8A,0xA7),
- o3(0xE7,0x8A,0xB9), o3(0xE7,0x8A,0xB2),
- o3(0xE7,0x8B,0x83), o3(0xE7,0x8B,0x86),
- o3(0xE7,0x8B,0x84), o3(0xE7,0x8B,0x8E),
- o3(0xE7,0x8B,0x92), o3(0xE7,0x8B,0xA2),
- o3(0xE7,0x8B,0xA0), o3(0xE7,0x8B,0xA1),
- o3(0xE7,0x8B,0xB9), o3(0xE7,0x8B,0xB7),
- o3(0xE5,0x80,0x8F), o3(0xE7,0x8C,0x97),
- o3(0xE7,0x8C,0x8A), o3(0xE7,0x8C,0x9C),
- o3(0xE7,0x8C,0x96), o3(0xE7,0x8C,0x9D),
- o3(0xE7,0x8C,0xB4), o3(0xE7,0x8C,0xAF),
- o3(0xE7,0x8C,0xA9), o3(0xE7,0x8C,0xA5),
- o3(0xE7,0x8C,0xBE), o3(0xE7,0x8D,0x8E),
- o3(0xE7,0x8D,0x8F), o3(0xE9,0xBB,0x98),
- o3(0xE7,0x8D,0x97), o3(0xE7,0x8D,0xAA),
- o3(0xE7,0x8D,0xA8), o3(0xE7,0x8D,0xB0),
- o3(0xE7,0x8D,0xB8), o3(0xE7,0x8D,0xB5),
- o3(0xE7,0x8D,0xBB), o3(0xE7,0x8D,0xBA),
- o3(0xE7,0x8F,0x88), o3(0xE7,0x8E,0xB3),
- o3(0xE7,0x8F,0x8E), o3(0xE7,0x8E,0xBB),
- o3(0xE7,0x8F,0x80), o3(0xE7,0x8F,0xA5),
- o3(0xE7,0x8F,0xAE), o3(0xE7,0x8F,0x9E),
- o3(0xE7,0x92,0xA2), o3(0xE7,0x90,0x85),
- o3(0xE7,0x91,0xAF), o3(0xE7,0x90,0xA5),
- o3(0xE7,0x8F,0xB8), o3(0xE7,0x90,0xB2),
- o3(0xE7,0x90,0xBA), o3(0xE7,0x91,0x95),
- o3(0xE7,0x90,0xBF), o3(0xE7,0x91,0x9F),
- o3(0xE7,0x91,0x99), o3(0xE7,0x91,0x81),
- o3(0xE7,0x91,0x9C), o3(0xE7,0x91,0xA9),
- o3(0xE7,0x91,0xB0), o3(0xE7,0x91,0xA3),
- o3(0xE7,0x91,0xAA), o3(0xE7,0x91,0xB6),
- o3(0xE7,0x91,0xBE), o3(0xE7,0x92,0x8B),
- o3(0xE7,0x92,0x9E), o3(0xE7,0x92,0xA7),
- o3(0xE7,0x93,0x8A), o3(0xE7,0x93,0x8F),
- o3(0xE7,0x93,0x94), o3(0xE7,0x8F,0xB1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E0 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E0_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E1_infos[95] = {
- o3(0xE7,0x93,0xA0), o3(0xE7,0x93,0xA3),
- o3(0xE7,0x93,0xA7), o3(0xE7,0x93,0xA9),
- o3(0xE7,0x93,0xAE), o3(0xE7,0x93,0xB2),
- o3(0xE7,0x93,0xB0), o3(0xE7,0x93,0xB1),
- o3(0xE7,0x93,0xB8), o3(0xE7,0x93,0xB7),
- o3(0xE7,0x94,0x84), o3(0xE7,0x94,0x83),
- o3(0xE7,0x94,0x85), o3(0xE7,0x94,0x8C),
- o3(0xE7,0x94,0x8E), o3(0xE7,0x94,0x8D),
- o3(0xE7,0x94,0x95), o3(0xE7,0x94,0x93),
- o3(0xE7,0x94,0x9E), o3(0xE7,0x94,0xA6),
- o3(0xE7,0x94,0xAC), o3(0xE7,0x94,0xBC),
- o3(0xE7,0x95,0x84), o3(0xE7,0x95,0x8D),
- o3(0xE7,0x95,0x8A), o3(0xE7,0x95,0x89),
- o3(0xE7,0x95,0x9B), o3(0xE7,0x95,0x86),
- o3(0xE7,0x95,0x9A), o3(0xE7,0x95,0xA9),
- o3(0xE7,0x95,0xA4), o3(0xE7,0x95,0xA7),
- o3(0xE7,0x95,0xAB), o3(0xE7,0x95,0xAD),
- o3(0xE7,0x95,0xB8), o3(0xE7,0x95,0xB6),
- o3(0xE7,0x96,0x86), o3(0xE7,0x96,0x87),
- o3(0xE7,0x95,0xB4), o3(0xE7,0x96,0x8A),
- o3(0xE7,0x96,0x89), o3(0xE7,0x96,0x82),
- o3(0xE7,0x96,0x94), o3(0xE7,0x96,0x9A),
- o3(0xE7,0x96,0x9D), o3(0xE7,0x96,0xA5),
- o3(0xE7,0x96,0xA3), o3(0xE7,0x97,0x82),
- o3(0xE7,0x96,0xB3), o3(0xE7,0x97,0x83),
- o3(0xE7,0x96,0xB5), o3(0xE7,0x96,0xBD),
- o3(0xE7,0x96,0xB8), o3(0xE7,0x96,0xBC),
- o3(0xE7,0x96,0xB1), o3(0xE7,0x97,0x8D),
- o3(0xE7,0x97,0x8A), o3(0xE7,0x97,0x92),
- o3(0xE7,0x97,0x99), o3(0xE7,0x97,0xA3),
- o3(0xE7,0x97,0x9E), o3(0xE7,0x97,0xBE),
- o3(0xE7,0x97,0xBF), o3(0xE7,0x97,0xBC),
- o3(0xE7,0x98,0x81), o3(0xE7,0x97,0xB0),
- o3(0xE7,0x97,0xBA), o3(0xE7,0x97,0xB2),
- o3(0xE7,0x97,0xB3), o3(0xE7,0x98,0x8B),
- o3(0xE7,0x98,0x8D), o3(0xE7,0x98,0x89),
- o3(0xE7,0x98,0x9F), o3(0xE7,0x98,0xA7),
- o3(0xE7,0x98,0xA0), o3(0xE7,0x98,0xA1),
- o3(0xE7,0x98,0xA2), o3(0xE7,0x98,0xA4),
- o3(0xE7,0x98,0xB4), o3(0xE7,0x98,0xB0),
- o3(0xE7,0x98,0xBB), o3(0xE7,0x99,0x87),
- o3(0xE7,0x99,0x88), o3(0xE7,0x99,0x86),
- o3(0xE7,0x99,0x9C), o3(0xE7,0x99,0x98),
- o3(0xE7,0x99,0xA1), o3(0xE7,0x99,0xA2),
- o3(0xE7,0x99,0xA8), o3(0xE7,0x99,0xA9),
- o3(0xE7,0x99,0xAA), o3(0xE7,0x99,0xA7),
- o3(0xE7,0x99,0xAC), o3(0xE7,0x99,0xB0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E1 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E1_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E2_infos[95] = {
- o3(0xE7,0x99,0xB2), o3(0xE7,0x99,0xB6),
- o3(0xE7,0x99,0xB8), o3(0xE7,0x99,0xBC),
- o3(0xE7,0x9A,0x80), o3(0xE7,0x9A,0x83),
- o3(0xE7,0x9A,0x88), o3(0xE7,0x9A,0x8B),
- o3(0xE7,0x9A,0x8E), o3(0xE7,0x9A,0x96),
- o3(0xE7,0x9A,0x93), o3(0xE7,0x9A,0x99),
- o3(0xE7,0x9A,0x9A), o3(0xE7,0x9A,0xB0),
- o3(0xE7,0x9A,0xB4), o3(0xE7,0x9A,0xB8),
- o3(0xE7,0x9A,0xB9), o3(0xE7,0x9A,0xBA),
- o3(0xE7,0x9B,0x82), o3(0xE7,0x9B,0x8D),
- o3(0xE7,0x9B,0x96), o3(0xE7,0x9B,0x92),
- o3(0xE7,0x9B,0x9E), o3(0xE7,0x9B,0xA1),
- o3(0xE7,0x9B,0xA5), o3(0xE7,0x9B,0xA7),
- o3(0xE7,0x9B,0xAA), o3(0xE8,0x98,0xAF),
- o3(0xE7,0x9B,0xBB), o3(0xE7,0x9C,0x88),
- o3(0xE7,0x9C,0x87), o3(0xE7,0x9C,0x84),
- o3(0xE7,0x9C,0xA9), o3(0xE7,0x9C,0xA4),
- o3(0xE7,0x9C,0x9E), o3(0xE7,0x9C,0xA5),
- o3(0xE7,0x9C,0xA6), o3(0xE7,0x9C,0x9B),
- o3(0xE7,0x9C,0xB7), o3(0xE7,0x9C,0xB8),
- o3(0xE7,0x9D,0x87), o3(0xE7,0x9D,0x9A),
- o3(0xE7,0x9D,0xA8), o3(0xE7,0x9D,0xAB),
- o3(0xE7,0x9D,0x9B), o3(0xE7,0x9D,0xA5),
- o3(0xE7,0x9D,0xBF), o3(0xE7,0x9D,0xBE),
- o3(0xE7,0x9D,0xB9), o3(0xE7,0x9E,0x8E),
- o3(0xE7,0x9E,0x8B), o3(0xE7,0x9E,0x91),
- o3(0xE7,0x9E,0xA0), o3(0xE7,0x9E,0x9E),
- o3(0xE7,0x9E,0xB0), o3(0xE7,0x9E,0xB6),
- o3(0xE7,0x9E,0xB9), o3(0xE7,0x9E,0xBF),
- o3(0xE7,0x9E,0xBC), o3(0xE7,0x9E,0xBD),
- o3(0xE7,0x9E,0xBB), o3(0xE7,0x9F,0x87),
- o3(0xE7,0x9F,0x8D), o3(0xE7,0x9F,0x97),
- o3(0xE7,0x9F,0x9A), o3(0xE7,0x9F,0x9C),
- o3(0xE7,0x9F,0xA3), o3(0xE7,0x9F,0xAE),
- o3(0xE7,0x9F,0xBC), o3(0xE7,0xA0,0x8C),
- o3(0xE7,0xA0,0x92), o3(0xE7,0xA4,0xA6),
- o3(0xE7,0xA0,0xA0), o3(0xE7,0xA4,0xAA),
- o3(0xE7,0xA1,0x85), o3(0xE7,0xA2,0x8E),
- o3(0xE7,0xA1,0xB4), o3(0xE7,0xA2,0x86),
- o3(0xE7,0xA1,0xBC), o3(0xE7,0xA2,0x9A),
- o3(0xE7,0xA2,0x8C), o3(0xE7,0xA2,0xA3),
- o3(0xE7,0xA2,0xB5), o3(0xE7,0xA2,0xAA),
- o3(0xE7,0xA2,0xAF), o3(0xE7,0xA3,0x91),
- o3(0xE7,0xA3,0x86), o3(0xE7,0xA3,0x8B),
- o3(0xE7,0xA3,0x94), o3(0xE7,0xA2,0xBE),
- o3(0xE7,0xA2,0xBC), o3(0xE7,0xA3,0x85),
- o3(0xE7,0xA3,0x8A), o3(0xE7,0xA3,0xAC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E2 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E2_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E3_infos[95] = {
- o3(0xE7,0xA3,0xA7), o3(0xE7,0xA3,0x9A),
- o3(0xE7,0xA3,0xBD), o3(0xE7,0xA3,0xB4),
- o3(0xE7,0xA4,0x87), o3(0xE7,0xA4,0x92),
- o3(0xE7,0xA4,0x91), o3(0xE7,0xA4,0x99),
- o3(0xE7,0xA4,0xAC), o3(0xE7,0xA4,0xAB),
- o3(0xE7,0xA5,0x80), o3(0xE7,0xA5,0xA0),
- o3(0xE7,0xA5,0x97), o3(0xE7,0xA5,0x9F),
- o3(0xE7,0xA5,0x9A), o3(0xE7,0xA5,0x95),
- o3(0xE7,0xA5,0x93), o3(0xE7,0xA5,0xBA),
- o3(0xE7,0xA5,0xBF), o3(0xE7,0xA6,0x8A),
- o3(0xE7,0xA6,0x9D), o3(0xE7,0xA6,0xA7),
- o3(0xE9,0xBD,0x8B), o3(0xE7,0xA6,0xAA),
- o3(0xE7,0xA6,0xAE), o3(0xE7,0xA6,0xB3),
- o3(0xE7,0xA6,0xB9), o3(0xE7,0xA6,0xBA),
- o3(0xE7,0xA7,0x89), o3(0xE7,0xA7,0x95),
- o3(0xE7,0xA7,0xA7), o3(0xE7,0xA7,0xAC),
- o3(0xE7,0xA7,0xA1), o3(0xE7,0xA7,0xA3),
- o3(0xE7,0xA8,0x88), o3(0xE7,0xA8,0x8D),
- o3(0xE7,0xA8,0x98), o3(0xE7,0xA8,0x99),
- o3(0xE7,0xA8,0xA0), o3(0xE7,0xA8,0x9F),
- o3(0xE7,0xA6,0x80), o3(0xE7,0xA8,0xB1),
- o3(0xE7,0xA8,0xBB), o3(0xE7,0xA8,0xBE),
- o3(0xE7,0xA8,0xB7), o3(0xE7,0xA9,0x83),
- o3(0xE7,0xA9,0x97), o3(0xE7,0xA9,0x89),
- o3(0xE7,0xA9,0xA1), o3(0xE7,0xA9,0xA2),
- o3(0xE7,0xA9,0xA9), o3(0xE9,0xBE,0x9D),
- o3(0xE7,0xA9,0xB0), o3(0xE7,0xA9,0xB9),
- o3(0xE7,0xA9,0xBD), o3(0xE7,0xAA,0x88),
- o3(0xE7,0xAA,0x97), o3(0xE7,0xAA,0x95),
- o3(0xE7,0xAA,0x98), o3(0xE7,0xAA,0x96),
- o3(0xE7,0xAA,0xA9), o3(0xE7,0xAB,0x88),
- o3(0xE7,0xAA,0xB0), o3(0xE7,0xAA,0xB6),
- o3(0xE7,0xAB,0x85), o3(0xE7,0xAB,0x84),
- o3(0xE7,0xAA,0xBF), o3(0xE9,0x82,0x83),
- o3(0xE7,0xAB,0x87), o3(0xE7,0xAB,0x8A),
- o3(0xE7,0xAB,0x8D), o3(0xE7,0xAB,0x8F),
- o3(0xE7,0xAB,0x95), o3(0xE7,0xAB,0x93),
- o3(0xE7,0xAB,0x99), o3(0xE7,0xAB,0x9A),
- o3(0xE7,0xAB,0x9D), o3(0xE7,0xAB,0xA1),
- o3(0xE7,0xAB,0xA2), o3(0xE7,0xAB,0xA6),
- o3(0xE7,0xAB,0xAD), o3(0xE7,0xAB,0xB0),
- o3(0xE7,0xAC,0x82), o3(0xE7,0xAC,0x8F),
- o3(0xE7,0xAC,0x8A), o3(0xE7,0xAC,0x86),
- o3(0xE7,0xAC,0xB3), o3(0xE7,0xAC,0x98),
- o3(0xE7,0xAC,0x99), o3(0xE7,0xAC,0x9E),
- o3(0xE7,0xAC,0xB5), o3(0xE7,0xAC,0xA8),
- o3(0xE7,0xAC,0xB6), o3(0xE7,0xAD,0x90),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E3 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E3_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E4_infos[95] = {
- o3(0xE7,0xAD,0xBA), o3(0xE7,0xAC,0x84),
- o3(0xE7,0xAD,0x8D), o3(0xE7,0xAC,0x8B),
- o3(0xE7,0xAD,0x8C), o3(0xE7,0xAD,0x85),
- o3(0xE7,0xAD,0xB5), o3(0xE7,0xAD,0xA5),
- o3(0xE7,0xAD,0xB4), o3(0xE7,0xAD,0xA7),
- o3(0xE7,0xAD,0xB0), o3(0xE7,0xAD,0xB1),
- o3(0xE7,0xAD,0xAC), o3(0xE7,0xAD,0xAE),
- o3(0xE7,0xAE,0x9D), o3(0xE7,0xAE,0x98),
- o3(0xE7,0xAE,0x9F), o3(0xE7,0xAE,0x8D),
- o3(0xE7,0xAE,0x9C), o3(0xE7,0xAE,0x9A),
- o3(0xE7,0xAE,0x8B), o3(0xE7,0xAE,0x92),
- o3(0xE7,0xAE,0x8F), o3(0xE7,0xAD,0x9D),
- o3(0xE7,0xAE,0x99), o3(0xE7,0xAF,0x8B),
- o3(0xE7,0xAF,0x81), o3(0xE7,0xAF,0x8C),
- o3(0xE7,0xAF,0x8F), o3(0xE7,0xAE,0xB4),
- o3(0xE7,0xAF,0x86), o3(0xE7,0xAF,0x9D),
- o3(0xE7,0xAF,0xA9), o3(0xE7,0xB0,0x91),
- o3(0xE7,0xB0,0x94), o3(0xE7,0xAF,0xA6),
- o3(0xE7,0xAF,0xA5), o3(0xE7,0xB1,0xA0),
- o3(0xE7,0xB0,0x80), o3(0xE7,0xB0,0x87),
- o3(0xE7,0xB0,0x93), o3(0xE7,0xAF,0xB3),
- o3(0xE7,0xAF,0xB7), o3(0xE7,0xB0,0x97),
- o3(0xE7,0xB0,0x8D), o3(0xE7,0xAF,0xB6),
- o3(0xE7,0xB0,0xA3), o3(0xE7,0xB0,0xA7),
- o3(0xE7,0xB0,0xAA), o3(0xE7,0xB0,0x9F),
- o3(0xE7,0xB0,0xB7), o3(0xE7,0xB0,0xAB),
- o3(0xE7,0xB0,0xBD), o3(0xE7,0xB1,0x8C),
- o3(0xE7,0xB1,0x83), o3(0xE7,0xB1,0x94),
- o3(0xE7,0xB1,0x8F), o3(0xE7,0xB1,0x80),
- o3(0xE7,0xB1,0x90), o3(0xE7,0xB1,0x98),
- o3(0xE7,0xB1,0x9F), o3(0xE7,0xB1,0xA4),
- o3(0xE7,0xB1,0x96), o3(0xE7,0xB1,0xA5),
- o3(0xE7,0xB1,0xAC), o3(0xE7,0xB1,0xB5),
- o3(0xE7,0xB2,0x83), o3(0xE7,0xB2,0x90),
- o3(0xE7,0xB2,0xA4), o3(0xE7,0xB2,0xAD),
- o3(0xE7,0xB2,0xA2), o3(0xE7,0xB2,0xAB),
- o3(0xE7,0xB2,0xA1), o3(0xE7,0xB2,0xA8),
- o3(0xE7,0xB2,0xB3), o3(0xE7,0xB2,0xB2),
- o3(0xE7,0xB2,0xB1), o3(0xE7,0xB2,0xAE),
- o3(0xE7,0xB2,0xB9), o3(0xE7,0xB2,0xBD),
- o3(0xE7,0xB3,0x80), o3(0xE7,0xB3,0x85),
- o3(0xE7,0xB3,0x82), o3(0xE7,0xB3,0x98),
- o3(0xE7,0xB3,0x92), o3(0xE7,0xB3,0x9C),
- o3(0xE7,0xB3,0xA2), o3(0xE9,0xAC,0xBB),
- o3(0xE7,0xB3,0xAF), o3(0xE7,0xB3,0xB2),
- o3(0xE7,0xB3,0xB4), o3(0xE7,0xB3,0xB6),
- o3(0xE7,0xB3,0xBA), o3(0xE7,0xB4,0x86),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E4 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E4_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E5_infos[95] = {
- o3(0xE7,0xB4,0x82), o3(0xE7,0xB4,0x9C),
- o3(0xE7,0xB4,0x95), o3(0xE7,0xB4,0x8A),
- o3(0xE7,0xB5,0x85), o3(0xE7,0xB5,0x8B),
- o3(0xE7,0xB4,0xAE), o3(0xE7,0xB4,0xB2),
- o3(0xE7,0xB4,0xBF), o3(0xE7,0xB4,0xB5),
- o3(0xE7,0xB5,0x86), o3(0xE7,0xB5,0xB3),
- o3(0xE7,0xB5,0x96), o3(0xE7,0xB5,0x8E),
- o3(0xE7,0xB5,0xB2), o3(0xE7,0xB5,0xA8),
- o3(0xE7,0xB5,0xAE), o3(0xE7,0xB5,0x8F),
- o3(0xE7,0xB5,0xA3), o3(0xE7,0xB6,0x93),
- o3(0xE7,0xB6,0x89), o3(0xE7,0xB5,0x9B),
- o3(0xE7,0xB6,0x8F), o3(0xE7,0xB5,0xBD),
- o3(0xE7,0xB6,0x9B), o3(0xE7,0xB6,0xBA),
- o3(0xE7,0xB6,0xAE), o3(0xE7,0xB6,0xA3),
- o3(0xE7,0xB6,0xB5), o3(0xE7,0xB7,0x87),
- o3(0xE7,0xB6,0xBD), o3(0xE7,0xB6,0xAB),
- o3(0xE7,0xB8,0xBD), o3(0xE7,0xB6,0xA2),
- o3(0xE7,0xB6,0xAF), o3(0xE7,0xB7,0x9C),
- o3(0xE7,0xB6,0xB8), o3(0xE7,0xB6,0x9F),
- o3(0xE7,0xB6,0xB0), o3(0xE7,0xB7,0x98),
- o3(0xE7,0xB7,0x9D), o3(0xE7,0xB7,0xA4),
- o3(0xE7,0xB7,0x9E), o3(0xE7,0xB7,0xBB),
- o3(0xE7,0xB7,0xB2), o3(0xE7,0xB7,0xA1),
- o3(0xE7,0xB8,0x85), o3(0xE7,0xB8,0x8A),
- o3(0xE7,0xB8,0xA3), o3(0xE7,0xB8,0xA1),
- o3(0xE7,0xB8,0x92), o3(0xE7,0xB8,0xB1),
- o3(0xE7,0xB8,0x9F), o3(0xE7,0xB8,0x89),
- o3(0xE7,0xB8,0x8B), o3(0xE7,0xB8,0xA2),
- o3(0xE7,0xB9,0x86), o3(0xE7,0xB9,0xA6),
- o3(0xE7,0xB8,0xBB), o3(0xE7,0xB8,0xB5),
- o3(0xE7,0xB8,0xB9), o3(0xE7,0xB9,0x83),
- o3(0xE7,0xB8,0xB7), o3(0xE7,0xB8,0xB2),
- o3(0xE7,0xB8,0xBA), o3(0xE7,0xB9,0xA7),
- o3(0xE7,0xB9,0x9D), o3(0xE7,0xB9,0x96),
- o3(0xE7,0xB9,0x9E), o3(0xE7,0xB9,0x99),
- o3(0xE7,0xB9,0x9A), o3(0xE7,0xB9,0xB9),
- o3(0xE7,0xB9,0xAA), o3(0xE7,0xB9,0xA9),
- o3(0xE7,0xB9,0xBC), o3(0xE7,0xB9,0xBB),
- o3(0xE7,0xBA,0x83), o3(0xE7,0xB7,0x95),
- o3(0xE7,0xB9,0xBD), o3(0xE8,0xBE,0xAE),
- o3(0xE7,0xB9,0xBF), o3(0xE7,0xBA,0x88),
- o3(0xE7,0xBA,0x89), o3(0xE7,0xBA,0x8C),
- o3(0xE7,0xBA,0x92), o3(0xE7,0xBA,0x90),
- o3(0xE7,0xBA,0x93), o3(0xE7,0xBA,0x94),
- o3(0xE7,0xBA,0x96), o3(0xE7,0xBA,0x8E),
- o3(0xE7,0xBA,0x9B), o3(0xE7,0xBA,0x9C),
- o3(0xE7,0xBC,0xB8), o3(0xE7,0xBC,0xBA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E5 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E5_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E6_infos[95] = {
- o3(0xE7,0xBD,0x85), o3(0xE7,0xBD,0x8C),
- o3(0xE7,0xBD,0x8D), o3(0xE7,0xBD,0x8E),
- o3(0xE7,0xBD,0x90), o3(0xE7,0xBD,0x91),
- o3(0xE7,0xBD,0x95), o3(0xE7,0xBD,0x94),
- o3(0xE7,0xBD,0x98), o3(0xE7,0xBD,0x9F),
- o3(0xE7,0xBD,0xA0), o3(0xE7,0xBD,0xA8),
- o3(0xE7,0xBD,0xA9), o3(0xE7,0xBD,0xA7),
- o3(0xE7,0xBD,0xB8), o3(0xE7,0xBE,0x82),
- o3(0xE7,0xBE,0x86), o3(0xE7,0xBE,0x83),
- o3(0xE7,0xBE,0x88), o3(0xE7,0xBE,0x87),
- o3(0xE7,0xBE,0x8C), o3(0xE7,0xBE,0x94),
- o3(0xE7,0xBE,0x9E), o3(0xE7,0xBE,0x9D),
- o3(0xE7,0xBE,0x9A), o3(0xE7,0xBE,0xA3),
- o3(0xE7,0xBE,0xAF), o3(0xE7,0xBE,0xB2),
- o3(0xE7,0xBE,0xB9), o3(0xE7,0xBE,0xAE),
- o3(0xE7,0xBE,0xB6), o3(0xE7,0xBE,0xB8),
- o3(0xE8,0xAD,0xB1), o3(0xE7,0xBF,0x85),
- o3(0xE7,0xBF,0x86), o3(0xE7,0xBF,0x8A),
- o3(0xE7,0xBF,0x95), o3(0xE7,0xBF,0x94),
- o3(0xE7,0xBF,0xA1), o3(0xE7,0xBF,0xA6),
- o3(0xE7,0xBF,0xA9), o3(0xE7,0xBF,0xB3),
- o3(0xE7,0xBF,0xB9), o3(0xE9,0xA3,0x9C),
- o3(0xE8,0x80,0x86), o3(0xE8,0x80,0x84),
- o3(0xE8,0x80,0x8B), o3(0xE8,0x80,0x92),
- o3(0xE8,0x80,0x98), o3(0xE8,0x80,0x99),
- o3(0xE8,0x80,0x9C), o3(0xE8,0x80,0xA1),
- o3(0xE8,0x80,0xA8), o3(0xE8,0x80,0xBF),
- o3(0xE8,0x80,0xBB), o3(0xE8,0x81,0x8A),
- o3(0xE8,0x81,0x86), o3(0xE8,0x81,0x92),
- o3(0xE8,0x81,0x98), o3(0xE8,0x81,0x9A),
- o3(0xE8,0x81,0x9F), o3(0xE8,0x81,0xA2),
- o3(0xE8,0x81,0xA8), o3(0xE8,0x81,0xB3),
- o3(0xE8,0x81,0xB2), o3(0xE8,0x81,0xB0),
- o3(0xE8,0x81,0xB6), o3(0xE8,0x81,0xB9),
- o3(0xE8,0x81,0xBD), o3(0xE8,0x81,0xBF),
- o3(0xE8,0x82,0x84), o3(0xE8,0x82,0x86),
- o3(0xE8,0x82,0x85), o3(0xE8,0x82,0x9B),
- o3(0xE8,0x82,0x93), o3(0xE8,0x82,0x9A),
- o3(0xE8,0x82,0xAD), o3(0xE5,0x86,0x90),
- o3(0xE8,0x82,0xAC), o3(0xE8,0x83,0x9B),
- o3(0xE8,0x83,0xA5), o3(0xE8,0x83,0x99),
- o3(0xE8,0x83,0x9D), o3(0xE8,0x83,0x84),
- o3(0xE8,0x83,0x9A), o3(0xE8,0x83,0x96),
- o3(0xE8,0x84,0x89), o3(0xE8,0x83,0xAF),
- o3(0xE8,0x83,0xB1), o3(0xE8,0x84,0x9B),
- o3(0xE8,0x84,0xA9), o3(0xE8,0x84,0xA3),
- o3(0xE8,0x84,0xAF), o3(0xE8,0x85,0x8B),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E6 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E6_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E7_infos[95] = {
- o3(0xE9,0x9A,0x8B), o3(0xE8,0x85,0x86),
- o3(0xE8,0x84,0xBE), o3(0xE8,0x85,0x93),
- o3(0xE8,0x85,0x91), o3(0xE8,0x83,0xBC),
- o3(0xE8,0x85,0xB1), o3(0xE8,0x85,0xAE),
- o3(0xE8,0x85,0xA5), o3(0xE8,0x85,0xA6),
- o3(0xE8,0x85,0xB4), o3(0xE8,0x86,0x83),
- o3(0xE8,0x86,0x88), o3(0xE8,0x86,0x8A),
- o3(0xE8,0x86,0x80), o3(0xE8,0x86,0x82),
- o3(0xE8,0x86,0xA0), o3(0xE8,0x86,0x95),
- o3(0xE8,0x86,0xA4), o3(0xE8,0x86,0xA3),
- o3(0xE8,0x85,0x9F), o3(0xE8,0x86,0x93),
- o3(0xE8,0x86,0xA9), o3(0xE8,0x86,0xB0),
- o3(0xE8,0x86,0xB5), o3(0xE8,0x86,0xBE),
- o3(0xE8,0x86,0xB8), o3(0xE8,0x86,0xBD),
- o3(0xE8,0x87,0x80), o3(0xE8,0x87,0x82),
- o3(0xE8,0x86,0xBA), o3(0xE8,0x87,0x89),
- o3(0xE8,0x87,0x8D), o3(0xE8,0x87,0x91),
- o3(0xE8,0x87,0x99), o3(0xE8,0x87,0x98),
- o3(0xE8,0x87,0x88), o3(0xE8,0x87,0x9A),
- o3(0xE8,0x87,0x9F), o3(0xE8,0x87,0xA0),
- o3(0xE8,0x87,0xA7), o3(0xE8,0x87,0xBA),
- o3(0xE8,0x87,0xBB), o3(0xE8,0x87,0xBE),
- o3(0xE8,0x88,0x81), o3(0xE8,0x88,0x82),
- o3(0xE8,0x88,0x85), o3(0xE8,0x88,0x87),
- o3(0xE8,0x88,0x8A), o3(0xE8,0x88,0x8D),
- o3(0xE8,0x88,0x90), o3(0xE8,0x88,0x96),
- o3(0xE8,0x88,0xA9), o3(0xE8,0x88,0xAB),
- o3(0xE8,0x88,0xB8), o3(0xE8,0x88,0xB3),
- o3(0xE8,0x89,0x80), o3(0xE8,0x89,0x99),
- o3(0xE8,0x89,0x98), o3(0xE8,0x89,0x9D),
- o3(0xE8,0x89,0x9A), o3(0xE8,0x89,0x9F),
- o3(0xE8,0x89,0xA4), o3(0xE8,0x89,0xA2),
- o3(0xE8,0x89,0xA8), o3(0xE8,0x89,0xAA),
- o3(0xE8,0x89,0xAB), o3(0xE8,0x88,0xAE),
- o3(0xE8,0x89,0xB1), o3(0xE8,0x89,0xB7),
- o3(0xE8,0x89,0xB8), o3(0xE8,0x89,0xBE),
- o3(0xE8,0x8A,0x8D), o3(0xE8,0x8A,0x92),
- o3(0xE8,0x8A,0xAB), o3(0xE8,0x8A,0x9F),
- o3(0xE8,0x8A,0xBB), o3(0xE8,0x8A,0xAC),
- o3(0xE8,0x8B,0xA1), o3(0xE8,0x8B,0xA3),
- o3(0xE8,0x8B,0x9F), o3(0xE8,0x8B,0x92),
- o3(0xE8,0x8B,0xB4), o3(0xE8,0x8B,0xB3),
- o3(0xE8,0x8B,0xBA), o3(0xE8,0x8E,0x93),
- o3(0xE8,0x8C,0x83), o3(0xE8,0x8B,0xBB),
- o3(0xE8,0x8B,0xB9), o3(0xE8,0x8B,0x9E),
- o3(0xE8,0x8C,0x86), o3(0xE8,0x8B,0x9C),
- o3(0xE8,0x8C,0x89), o3(0xE8,0x8B,0x99),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E7 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E7_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E8_infos[95] = {
- o3(0xE8,0x8C,0xB5), o3(0xE8,0x8C,0xB4),
- o3(0xE8,0x8C,0x96), o3(0xE8,0x8C,0xB2),
- o3(0xE8,0x8C,0xB1), o3(0xE8,0x8D,0x80),
- o3(0xE8,0x8C,0xB9), o3(0xE8,0x8D,0x90),
- o3(0xE8,0x8D,0x85), o3(0xE8,0x8C,0xAF),
- o3(0xE8,0x8C,0xAB), o3(0xE8,0x8C,0x97),
- o3(0xE8,0x8C,0x98), o3(0xE8,0x8E,0x85),
- o3(0xE8,0x8E,0x9A), o3(0xE8,0x8E,0xAA),
- o3(0xE8,0x8E,0x9F), o3(0xE8,0x8E,0xA2),
- o3(0xE8,0x8E,0x96), o3(0xE8,0x8C,0xA3),
- o3(0xE8,0x8E,0x8E), o3(0xE8,0x8E,0x87),
- o3(0xE8,0x8E,0x8A), o3(0xE8,0x8D,0xBC),
- o3(0xE8,0x8E,0xB5), o3(0xE8,0x8D,0xB3),
- o3(0xE8,0x8D,0xB5), o3(0xE8,0x8E,0xA0),
- o3(0xE8,0x8E,0x89), o3(0xE8,0x8E,0xA8),
- o3(0xE8,0x8F,0xB4), o3(0xE8,0x90,0x93),
- o3(0xE8,0x8F,0xAB), o3(0xE8,0x8F,0x8E),
- o3(0xE8,0x8F,0xBD), o3(0xE8,0x90,0x83),
- o3(0xE8,0x8F,0x98), o3(0xE8,0x90,0x8B),
- o3(0xE8,0x8F,0x81), o3(0xE8,0x8F,0xB7),
- o3(0xE8,0x90,0x87), o3(0xE8,0x8F,0xA0),
- o3(0xE8,0x8F,0xB2), o3(0xE8,0x90,0x8D),
- o3(0xE8,0x90,0xA2), o3(0xE8,0x90,0xA0),
- o3(0xE8,0x8E,0xBD), o3(0xE8,0x90,0xB8),
- o3(0xE8,0x94,0x86), o3(0xE8,0x8F,0xBB),
- o3(0xE8,0x91,0xAD), o3(0xE8,0x90,0xAA),
- o3(0xE8,0x90,0xBC), o3(0xE8,0x95,0x9A),
- o3(0xE8,0x92,0x84), o3(0xE8,0x91,0xB7),
- o3(0xE8,0x91,0xAB), o3(0xE8,0x92,0xAD),
- o3(0xE8,0x91,0xAE), o3(0xE8,0x92,0x82),
- o3(0xE8,0x91,0xA9), o3(0xE8,0x91,0x86),
- o3(0xE8,0x90,0xAC), o3(0xE8,0x91,0xAF),
- o3(0xE8,0x91,0xB9), o3(0xE8,0x90,0xB5),
- o3(0xE8,0x93,0x8A), o3(0xE8,0x91,0xA2),
- o3(0xE8,0x92,0xB9), o3(0xE8,0x92,0xBF),
- o3(0xE8,0x92,0x9F), o3(0xE8,0x93,0x99),
- o3(0xE8,0x93,0x8D), o3(0xE8,0x92,0xBB),
- o3(0xE8,0x93,0x9A), o3(0xE8,0x93,0x90),
- o3(0xE8,0x93,0x81), o3(0xE8,0x93,0x86),
- o3(0xE8,0x93,0x96), o3(0xE8,0x92,0xA1),
- o3(0xE8,0x94,0xA1), o3(0xE8,0x93,0xBF),
- o3(0xE8,0x93,0xB4), o3(0xE8,0x94,0x97),
- o3(0xE8,0x94,0x98), o3(0xE8,0x94,0xAC),
- o3(0xE8,0x94,0x9F), o3(0xE8,0x94,0x95),
- o3(0xE8,0x94,0x94), o3(0xE8,0x93,0xBC),
- o3(0xE8,0x95,0x80), o3(0xE8,0x95,0xA3),
- o3(0xE8,0x95,0x98), o3(0xE8,0x95,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E8 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E8_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_E9_infos[95] = {
- o3(0xE8,0x95,0x81), o3(0xE8,0x98,0x82),
- o3(0xE8,0x95,0x8B), o3(0xE8,0x95,0x95),
- o3(0xE8,0x96,0x80), o3(0xE8,0x96,0xA4),
- o3(0xE8,0x96,0x88), o3(0xE8,0x96,0x91),
- o3(0xE8,0x96,0x8A), o3(0xE8,0x96,0xA8),
- o3(0xE8,0x95,0xAD), o3(0xE8,0x96,0x94),
- o3(0xE8,0x96,0x9B), o3(0xE8,0x97,0xAA),
- o3(0xE8,0x96,0x87), o3(0xE8,0x96,0x9C),
- o3(0xE8,0x95,0xB7), o3(0xE8,0x95,0xBE),
- o3(0xE8,0x96,0x90), o3(0xE8,0x97,0x89),
- o3(0xE8,0x96,0xBA), o3(0xE8,0x97,0x8F),
- o3(0xE8,0x96,0xB9), o3(0xE8,0x97,0x90),
- o3(0xE8,0x97,0x95), o3(0xE8,0x97,0x9D),
- o3(0xE8,0x97,0xA5), o3(0xE8,0x97,0x9C),
- o3(0xE8,0x97,0xB9), o3(0xE8,0x98,0x8A),
- o3(0xE8,0x98,0x93), o3(0xE8,0x98,0x8B),
- o3(0xE8,0x97,0xBE), o3(0xE8,0x97,0xBA),
- o3(0xE8,0x98,0x86), o3(0xE8,0x98,0xA2),
- o3(0xE8,0x98,0x9A), o3(0xE8,0x98,0xB0),
- o3(0xE8,0x98,0xBF), o3(0xE8,0x99,0x8D),
- o3(0xE4,0xB9,0x95), o3(0xE8,0x99,0x94),
- o3(0xE8,0x99,0x9F), o3(0xE8,0x99,0xA7),
- o3(0xE8,0x99,0xB1), o3(0xE8,0x9A,0x93),
- o3(0xE8,0x9A,0xA3), o3(0xE8,0x9A,0xA9),
- o3(0xE8,0x9A,0xAA), o3(0xE8,0x9A,0x8B),
- o3(0xE8,0x9A,0x8C), o3(0xE8,0x9A,0xB6),
- o3(0xE8,0x9A,0xAF), o3(0xE8,0x9B,0x84),
- o3(0xE8,0x9B,0x86), o3(0xE8,0x9A,0xB0),
- o3(0xE8,0x9B,0x89), o3(0xE8,0xA0,0xA3),
- o3(0xE8,0x9A,0xAB), o3(0xE8,0x9B,0x94),
- o3(0xE8,0x9B,0x9E), o3(0xE8,0x9B,0xA9),
- o3(0xE8,0x9B,0xAC), o3(0xE8,0x9B,0x9F),
- o3(0xE8,0x9B,0x9B), o3(0xE8,0x9B,0xAF),
- o3(0xE8,0x9C,0x92), o3(0xE8,0x9C,0x86),
- o3(0xE8,0x9C,0x88), o3(0xE8,0x9C,0x80),
- o3(0xE8,0x9C,0x83), o3(0xE8,0x9B,0xBB),
- o3(0xE8,0x9C,0x91), o3(0xE8,0x9C,0x89),
- o3(0xE8,0x9C,0x8D), o3(0xE8,0x9B,0xB9),
- o3(0xE8,0x9C,0x8A), o3(0xE8,0x9C,0xB4),
- o3(0xE8,0x9C,0xBF), o3(0xE8,0x9C,0xB7),
- o3(0xE8,0x9C,0xBB), o3(0xE8,0x9C,0xA5),
- o3(0xE8,0x9C,0xA9), o3(0xE8,0x9C,0x9A),
- o3(0xE8,0x9D,0xA0), o3(0xE8,0x9D,0x9F),
- o3(0xE8,0x9D,0xB8), o3(0xE8,0x9D,0x8C),
- o3(0xE8,0x9D,0x8E), o3(0xE8,0x9D,0xB4),
- o3(0xE8,0x9D,0x97), o3(0xE8,0x9D,0xA8),
- o3(0xE8,0x9D,0xAE), o3(0xE8,0x9D,0x99),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_E9 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_E9_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_EA_infos[95] = {
- o3(0xE8,0x9D,0x93), o3(0xE8,0x9D,0xA3),
- o3(0xE8,0x9D,0xAA), o3(0xE8,0xA0,0x85),
- o3(0xE8,0x9E,0xA2), o3(0xE8,0x9E,0x9F),
- o3(0xE8,0x9E,0x82), o3(0xE8,0x9E,0xAF),
- o3(0xE8,0x9F,0x8B), o3(0xE8,0x9E,0xBD),
- o3(0xE8,0x9F,0x80), o3(0xE8,0x9F,0x90),
- o3(0xE9,0x9B,0x96), o3(0xE8,0x9E,0xAB),
- o3(0xE8,0x9F,0x84), o3(0xE8,0x9E,0xB3),
- o3(0xE8,0x9F,0x87), o3(0xE8,0x9F,0x86),
- o3(0xE8,0x9E,0xBB), o3(0xE8,0x9F,0xAF),
- o3(0xE8,0x9F,0xB2), o3(0xE8,0x9F,0xA0),
- o3(0xE8,0xA0,0x8F), o3(0xE8,0xA0,0x8D),
- o3(0xE8,0x9F,0xBE), o3(0xE8,0x9F,0xB6),
- o3(0xE8,0x9F,0xB7), o3(0xE8,0xA0,0x8E),
- o3(0xE8,0x9F,0x92), o3(0xE8,0xA0,0x91),
- o3(0xE8,0xA0,0x96), o3(0xE8,0xA0,0x95),
- o3(0xE8,0xA0,0xA2), o3(0xE8,0xA0,0xA1),
- o3(0xE8,0xA0,0xB1), o3(0xE8,0xA0,0xB6),
- o3(0xE8,0xA0,0xB9), o3(0xE8,0xA0,0xA7),
- o3(0xE8,0xA0,0xBB), o3(0xE8,0xA1,0x84),
- o3(0xE8,0xA1,0x82), o3(0xE8,0xA1,0x92),
- o3(0xE8,0xA1,0x99), o3(0xE8,0xA1,0x9E),
- o3(0xE8,0xA1,0xA2), o3(0xE8,0xA1,0xAB),
- o3(0xE8,0xA2,0x81), o3(0xE8,0xA1,0xBE),
- o3(0xE8,0xA2,0x9E), o3(0xE8,0xA1,0xB5),
- o3(0xE8,0xA1,0xBD), o3(0xE8,0xA2,0xB5),
- o3(0xE8,0xA1,0xB2), o3(0xE8,0xA2,0x82),
- o3(0xE8,0xA2,0x97), o3(0xE8,0xA2,0x92),
- o3(0xE8,0xA2,0xAE), o3(0xE8,0xA2,0x99),
- o3(0xE8,0xA2,0xA2), o3(0xE8,0xA2,0x8D),
- o3(0xE8,0xA2,0xA4), o3(0xE8,0xA2,0xB0),
- o3(0xE8,0xA2,0xBF), o3(0xE8,0xA2,0xB1),
- o3(0xE8,0xA3,0x83), o3(0xE8,0xA3,0x84),
- o3(0xE8,0xA3,0x94), o3(0xE8,0xA3,0x98),
- o3(0xE8,0xA3,0x99), o3(0xE8,0xA3,0x9D),
- o3(0xE8,0xA3,0xB9), o3(0xE8,0xA4,0x82),
- o3(0xE8,0xA3,0xBC), o3(0xE8,0xA3,0xB4),
- o3(0xE8,0xA3,0xA8), o3(0xE8,0xA3,0xB2),
- o3(0xE8,0xA4,0x84), o3(0xE8,0xA4,0x8C),
- o3(0xE8,0xA4,0x8A), o3(0xE8,0xA4,0x93),
- o3(0xE8,0xA5,0x83), o3(0xE8,0xA4,0x9E),
- o3(0xE8,0xA4,0xA5), o3(0xE8,0xA4,0xAA),
- o3(0xE8,0xA4,0xAB), o3(0xE8,0xA5,0x81),
- o3(0xE8,0xA5,0x84), o3(0xE8,0xA4,0xBB),
- o3(0xE8,0xA4,0xB6), o3(0xE8,0xA4,0xB8),
- o3(0xE8,0xA5,0x8C), o3(0xE8,0xA4,0x9D),
- o3(0xE8,0xA5,0xA0), o3(0xE8,0xA5,0x9E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_EA = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_EA_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_EB_infos[95] = {
- o3(0xE8,0xA5,0xA6), o3(0xE8,0xA5,0xA4),
- o3(0xE8,0xA5,0xAD), o3(0xE8,0xA5,0xAA),
- o3(0xE8,0xA5,0xAF), o3(0xE8,0xA5,0xB4),
- o3(0xE8,0xA5,0xB7), o3(0xE8,0xA5,0xBE),
- o3(0xE8,0xA6,0x83), o3(0xE8,0xA6,0x88),
- o3(0xE8,0xA6,0x8A), o3(0xE8,0xA6,0x93),
- o3(0xE8,0xA6,0x98), o3(0xE8,0xA6,0xA1),
- o3(0xE8,0xA6,0xA9), o3(0xE8,0xA6,0xA6),
- o3(0xE8,0xA6,0xAC), o3(0xE8,0xA6,0xAF),
- o3(0xE8,0xA6,0xB2), o3(0xE8,0xA6,0xBA),
- o3(0xE8,0xA6,0xBD), o3(0xE8,0xA6,0xBF),
- o3(0xE8,0xA7,0x80), o3(0xE8,0xA7,0x9A),
- o3(0xE8,0xA7,0x9C), o3(0xE8,0xA7,0x9D),
- o3(0xE8,0xA7,0xA7), o3(0xE8,0xA7,0xB4),
- o3(0xE8,0xA7,0xB8), o3(0xE8,0xA8,0x83),
- o3(0xE8,0xA8,0x96), o3(0xE8,0xA8,0x90),
- o3(0xE8,0xA8,0x8C), o3(0xE8,0xA8,0x9B),
- o3(0xE8,0xA8,0x9D), o3(0xE8,0xA8,0xA5),
- o3(0xE8,0xA8,0xB6), o3(0xE8,0xA9,0x81),
- o3(0xE8,0xA9,0x9B), o3(0xE8,0xA9,0x92),
- o3(0xE8,0xA9,0x86), o3(0xE8,0xA9,0x88),
- o3(0xE8,0xA9,0xBC), o3(0xE8,0xA9,0xAD),
- o3(0xE8,0xA9,0xAC), o3(0xE8,0xA9,0xA2),
- o3(0xE8,0xAA,0x85), o3(0xE8,0xAA,0x82),
- o3(0xE8,0xAA,0x84), o3(0xE8,0xAA,0xA8),
- o3(0xE8,0xAA,0xA1), o3(0xE8,0xAA,0x91),
- o3(0xE8,0xAA,0xA5), o3(0xE8,0xAA,0xA6),
- o3(0xE8,0xAA,0x9A), o3(0xE8,0xAA,0xA3),
- o3(0xE8,0xAB,0x84), o3(0xE8,0xAB,0x8D),
- o3(0xE8,0xAB,0x82), o3(0xE8,0xAB,0x9A),
- o3(0xE8,0xAB,0xAB), o3(0xE8,0xAB,0xB3),
- o3(0xE8,0xAB,0xA7), o3(0xE8,0xAB,0xA4),
- o3(0xE8,0xAB,0xB1), o3(0xE8,0xAC,0x94),
- o3(0xE8,0xAB,0xA0), o3(0xE8,0xAB,0xA2),
- o3(0xE8,0xAB,0xB7), o3(0xE8,0xAB,0x9E),
- o3(0xE8,0xAB,0x9B), o3(0xE8,0xAC,0x8C),
- o3(0xE8,0xAC,0x87), o3(0xE8,0xAC,0x9A),
- o3(0xE8,0xAB,0xA1), o3(0xE8,0xAC,0x96),
- o3(0xE8,0xAC,0x90), o3(0xE8,0xAC,0x97),
- o3(0xE8,0xAC,0xA0), o3(0xE8,0xAC,0xB3),
- o3(0xE9,0x9E,0xAB), o3(0xE8,0xAC,0xA6),
- o3(0xE8,0xAC,0xAB), o3(0xE8,0xAC,0xBE),
- o3(0xE8,0xAC,0xA8), o3(0xE8,0xAD,0x81),
- o3(0xE8,0xAD,0x8C), o3(0xE8,0xAD,0x8F),
- o3(0xE8,0xAD,0x8E), o3(0xE8,0xAD,0x89),
- o3(0xE8,0xAD,0x96), o3(0xE8,0xAD,0x9B),
- o3(0xE8,0xAD,0x9A), o3(0xE8,0xAD,0xAB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_EB = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_EB_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_EC_infos[95] = {
- o3(0xE8,0xAD,0x9F), o3(0xE8,0xAD,0xAC),
- o3(0xE8,0xAD,0xAF), o3(0xE8,0xAD,0xB4),
- o3(0xE8,0xAD,0xBD), o3(0xE8,0xAE,0x80),
- o3(0xE8,0xAE,0x8C), o3(0xE8,0xAE,0x8E),
- o3(0xE8,0xAE,0x92), o3(0xE8,0xAE,0x93),
- o3(0xE8,0xAE,0x96), o3(0xE8,0xAE,0x99),
- o3(0xE8,0xAE,0x9A), o3(0xE8,0xB0,0xBA),
- o3(0xE8,0xB1,0x81), o3(0xE8,0xB0,0xBF),
- o3(0xE8,0xB1,0x88), o3(0xE8,0xB1,0x8C),
- o3(0xE8,0xB1,0x8E), o3(0xE8,0xB1,0x90),
- o3(0xE8,0xB1,0x95), o3(0xE8,0xB1,0xA2),
- o3(0xE8,0xB1,0xAC), o3(0xE8,0xB1,0xB8),
- o3(0xE8,0xB1,0xBA), o3(0xE8,0xB2,0x82),
- o3(0xE8,0xB2,0x89), o3(0xE8,0xB2,0x85),
- o3(0xE8,0xB2,0x8A), o3(0xE8,0xB2,0x8D),
- o3(0xE8,0xB2,0x8E), o3(0xE8,0xB2,0x94),
- o3(0xE8,0xB1,0xBC), o3(0xE8,0xB2,0x98),
- o3(0xE6,0x88,0x9D), o3(0xE8,0xB2,0xAD),
- o3(0xE8,0xB2,0xAA), o3(0xE8,0xB2,0xBD),
- o3(0xE8,0xB2,0xB2), o3(0xE8,0xB2,0xB3),
- o3(0xE8,0xB2,0xAE), o3(0xE8,0xB2,0xB6),
- o3(0xE8,0xB3,0x88), o3(0xE8,0xB3,0x81),
- o3(0xE8,0xB3,0xA4), o3(0xE8,0xB3,0xA3),
- o3(0xE8,0xB3,0x9A), o3(0xE8,0xB3,0xBD),
- o3(0xE8,0xB3,0xBA), o3(0xE8,0xB3,0xBB),
- o3(0xE8,0xB4,0x84), o3(0xE8,0xB4,0x85),
- o3(0xE8,0xB4,0x8A), o3(0xE8,0xB4,0x87),
- o3(0xE8,0xB4,0x8F), o3(0xE8,0xB4,0x8D),
- o3(0xE8,0xB4,0x90), o3(0xE9,0xBD,0x8E),
- o3(0xE8,0xB4,0x93), o3(0xE8,0xB3,0x8D),
- o3(0xE8,0xB4,0x94), o3(0xE8,0xB4,0x96),
- o3(0xE8,0xB5,0xA7), o3(0xE8,0xB5,0xAD),
- o3(0xE8,0xB5,0xB1), o3(0xE8,0xB5,0xB3),
- o3(0xE8,0xB6,0x81), o3(0xE8,0xB6,0x99),
- o3(0xE8,0xB7,0x82), o3(0xE8,0xB6,0xBE),
- o3(0xE8,0xB6,0xBA), o3(0xE8,0xB7,0x8F),
- o3(0xE8,0xB7,0x9A), o3(0xE8,0xB7,0x96),
- o3(0xE8,0xB7,0x8C), o3(0xE8,0xB7,0x9B),
- o3(0xE8,0xB7,0x8B), o3(0xE8,0xB7,0xAA),
- o3(0xE8,0xB7,0xAB), o3(0xE8,0xB7,0x9F),
- o3(0xE8,0xB7,0xA3), o3(0xE8,0xB7,0xBC),
- o3(0xE8,0xB8,0x88), o3(0xE8,0xB8,0x89),
- o3(0xE8,0xB7,0xBF), o3(0xE8,0xB8,0x9D),
- o3(0xE8,0xB8,0x9E), o3(0xE8,0xB8,0x90),
- o3(0xE8,0xB8,0x9F), o3(0xE8,0xB9,0x82),
- o3(0xE8,0xB8,0xB5), o3(0xE8,0xB8,0xB0),
- o3(0xE8,0xB8,0xB4), o3(0xE8,0xB9,0x8A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_EC = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_EC_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_ED_infos[95] = {
- o3(0xE8,0xB9,0x87), o3(0xE8,0xB9,0x89),
- o3(0xE8,0xB9,0x8C), o3(0xE8,0xB9,0x90),
- o3(0xE8,0xB9,0x88), o3(0xE8,0xB9,0x99),
- o3(0xE8,0xB9,0xA4), o3(0xE8,0xB9,0xA0),
- o3(0xE8,0xB8,0xAA), o3(0xE8,0xB9,0xA3),
- o3(0xE8,0xB9,0x95), o3(0xE8,0xB9,0xB6),
- o3(0xE8,0xB9,0xB2), o3(0xE8,0xB9,0xBC),
- o3(0xE8,0xBA,0x81), o3(0xE8,0xBA,0x87),
- o3(0xE8,0xBA,0x85), o3(0xE8,0xBA,0x84),
- o3(0xE8,0xBA,0x8B), o3(0xE8,0xBA,0x8A),
- o3(0xE8,0xBA,0x93), o3(0xE8,0xBA,0x91),
- o3(0xE8,0xBA,0x94), o3(0xE8,0xBA,0x99),
- o3(0xE8,0xBA,0xAA), o3(0xE8,0xBA,0xA1),
- o3(0xE8,0xBA,0xAC), o3(0xE8,0xBA,0xB0),
- o3(0xE8,0xBB,0x86), o3(0xE8,0xBA,0xB1),
- o3(0xE8,0xBA,0xBE), o3(0xE8,0xBB,0x85),
- o3(0xE8,0xBB,0x88), o3(0xE8,0xBB,0x8B),
- o3(0xE8,0xBB,0x9B), o3(0xE8,0xBB,0xA3),
- o3(0xE8,0xBB,0xBC), o3(0xE8,0xBB,0xBB),
- o3(0xE8,0xBB,0xAB), o3(0xE8,0xBB,0xBE),
- o3(0xE8,0xBC,0x8A), o3(0xE8,0xBC,0x85),
- o3(0xE8,0xBC,0x95), o3(0xE8,0xBC,0x92),
- o3(0xE8,0xBC,0x99), o3(0xE8,0xBC,0x93),
- o3(0xE8,0xBC,0x9C), o3(0xE8,0xBC,0x9F),
- o3(0xE8,0xBC,0x9B), o3(0xE8,0xBC,0x8C),
- o3(0xE8,0xBC,0xA6), o3(0xE8,0xBC,0xB3),
- o3(0xE8,0xBC,0xBB), o3(0xE8,0xBC,0xB9),
- o3(0xE8,0xBD,0x85), o3(0xE8,0xBD,0x82),
- o3(0xE8,0xBC,0xBE), o3(0xE8,0xBD,0x8C),
- o3(0xE8,0xBD,0x89), o3(0xE8,0xBD,0x86),
- o3(0xE8,0xBD,0x8E), o3(0xE8,0xBD,0x97),
- o3(0xE8,0xBD,0x9C), o3(0xE8,0xBD,0xA2),
- o3(0xE8,0xBD,0xA3), o3(0xE8,0xBD,0xA4),
- o3(0xE8,0xBE,0x9C), o3(0xE8,0xBE,0x9F),
- o3(0xE8,0xBE,0xA3), o3(0xE8,0xBE,0xAD),
- o3(0xE8,0xBE,0xAF), o3(0xE8,0xBE,0xB7),
- o3(0xE8,0xBF,0x9A), o3(0xE8,0xBF,0xA5),
- o3(0xE8,0xBF,0xA2), o3(0xE8,0xBF,0xAA),
- o3(0xE8,0xBF,0xAF), o3(0xE9,0x82,0x87),
- o3(0xE8,0xBF,0xB4), o3(0xE9,0x80,0x85),
- o3(0xE8,0xBF,0xB9), o3(0xE8,0xBF,0xBA),
- o3(0xE9,0x80,0x91), o3(0xE9,0x80,0x95),
- o3(0xE9,0x80,0xA1), o3(0xE9,0x80,0x8D),
- o3(0xE9,0x80,0x9E), o3(0xE9,0x80,0x96),
- o3(0xE9,0x80,0x8B), o3(0xE9,0x80,0xA7),
- o3(0xE9,0x80,0xB6), o3(0xE9,0x80,0xB5),
- o3(0xE9,0x80,0xB9), o3(0xE8,0xBF,0xB8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_ED = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_ED_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_EE_infos[95] = {
- o3(0xE9,0x81,0x8F), o3(0xE9,0x81,0x90),
- o3(0xE9,0x81,0x91), o3(0xE9,0x81,0x92),
- o3(0xE9,0x80,0x8E), o3(0xE9,0x81,0x89),
- o3(0xE9,0x80,0xBE), o3(0xE9,0x81,0x96),
- o3(0xE9,0x81,0x98), o3(0xE9,0x81,0x9E),
- o3(0xE9,0x81,0xA8), o3(0xE9,0x81,0xAF),
- o3(0xE9,0x81,0xB6), o3(0xE9,0x9A,0xA8),
- o3(0xE9,0x81,0xB2), o3(0xE9,0x82,0x82),
- o3(0xE9,0x81,0xBD), o3(0xE9,0x82,0x81),
- o3(0xE9,0x82,0x80), o3(0xE9,0x82,0x8A),
- o3(0xE9,0x82,0x89), o3(0xE9,0x82,0x8F),
- o3(0xE9,0x82,0xA8), o3(0xE9,0x82,0xAF),
- o3(0xE9,0x82,0xB1), o3(0xE9,0x82,0xB5),
- o3(0xE9,0x83,0xA2), o3(0xE9,0x83,0xA4),
- o3(0xE6,0x89,0x88), o3(0xE9,0x83,0x9B),
- o3(0xE9,0x84,0x82), o3(0xE9,0x84,0x92),
- o3(0xE9,0x84,0x99), o3(0xE9,0x84,0xB2),
- o3(0xE9,0x84,0xB0), o3(0xE9,0x85,0x8A),
- o3(0xE9,0x85,0x96), o3(0xE9,0x85,0x98),
- o3(0xE9,0x85,0xA3), o3(0xE9,0x85,0xA5),
- o3(0xE9,0x85,0xA9), o3(0xE9,0x85,0xB3),
- o3(0xE9,0x85,0xB2), o3(0xE9,0x86,0x8B),
- o3(0xE9,0x86,0x89), o3(0xE9,0x86,0x82),
- o3(0xE9,0x86,0xA2), o3(0xE9,0x86,0xAB),
- o3(0xE9,0x86,0xAF), o3(0xE9,0x86,0xAA),
- o3(0xE9,0x86,0xB5), o3(0xE9,0x86,0xB4),
- o3(0xE9,0x86,0xBA), o3(0xE9,0x87,0x80),
- o3(0xE9,0x87,0x81), o3(0xE9,0x87,0x89),
- o3(0xE9,0x87,0x8B), o3(0xE9,0x87,0x90),
- o3(0xE9,0x87,0x96), o3(0xE9,0x87,0x9F),
- o3(0xE9,0x87,0xA1), o3(0xE9,0x87,0x9B),
- o3(0xE9,0x87,0xBC), o3(0xE9,0x87,0xB5),
- o3(0xE9,0x87,0xB6), o3(0xE9,0x88,0x9E),
- o3(0xE9,0x87,0xBF), o3(0xE9,0x88,0x94),
- o3(0xE9,0x88,0xAC), o3(0xE9,0x88,0x95),
- o3(0xE9,0x88,0x91), o3(0xE9,0x89,0x9E),
- o3(0xE9,0x89,0x97), o3(0xE9,0x89,0x85),
- o3(0xE9,0x89,0x89), o3(0xE9,0x89,0xA4),
- o3(0xE9,0x89,0x88), o3(0xE9,0x8A,0x95),
- o3(0xE9,0x88,0xBF), o3(0xE9,0x89,0x8B),
- o3(0xE9,0x89,0x90), o3(0xE9,0x8A,0x9C),
- o3(0xE9,0x8A,0x96), o3(0xE9,0x8A,0x93),
- o3(0xE9,0x8A,0x9B), o3(0xE9,0x89,0x9A),
- o3(0xE9,0x8B,0x8F), o3(0xE9,0x8A,0xB9),
- o3(0xE9,0x8A,0xB7), o3(0xE9,0x8B,0xA9),
- o3(0xE9,0x8C,0x8F), o3(0xE9,0x8B,0xBA),
- o3(0xE9,0x8D,0x84), o3(0xE9,0x8C,0xAE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_EE = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_EE_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_EF_infos[95] = {
- o3(0xE9,0x8C,0x99), o3(0xE9,0x8C,0xA2),
- o3(0xE9,0x8C,0x9A), o3(0xE9,0x8C,0xA3),
- o3(0xE9,0x8C,0xBA), o3(0xE9,0x8C,0xB5),
- o3(0xE9,0x8C,0xBB), o3(0xE9,0x8D,0x9C),
- o3(0xE9,0x8D,0xA0), o3(0xE9,0x8D,0xBC),
- o3(0xE9,0x8D,0xAE), o3(0xE9,0x8D,0x96),
- o3(0xE9,0x8E,0xB0), o3(0xE9,0x8E,0xAC),
- o3(0xE9,0x8E,0xAD), o3(0xE9,0x8E,0x94),
- o3(0xE9,0x8E,0xB9), o3(0xE9,0x8F,0x96),
- o3(0xE9,0x8F,0x97), o3(0xE9,0x8F,0xA8),
- o3(0xE9,0x8F,0xA5), o3(0xE9,0x8F,0x98),
- o3(0xE9,0x8F,0x83), o3(0xE9,0x8F,0x9D),
- o3(0xE9,0x8F,0x90), o3(0xE9,0x8F,0x88),
- o3(0xE9,0x8F,0xA4), o3(0xE9,0x90,0x9A),
- o3(0xE9,0x90,0x94), o3(0xE9,0x90,0x93),
- o3(0xE9,0x90,0x83), o3(0xE9,0x90,0x87),
- o3(0xE9,0x90,0x90), o3(0xE9,0x90,0xB6),
- o3(0xE9,0x90,0xAB), o3(0xE9,0x90,0xB5),
- o3(0xE9,0x90,0xA1), o3(0xE9,0x90,0xBA),
- o3(0xE9,0x91,0x81), o3(0xE9,0x91,0x92),
- o3(0xE9,0x91,0x84), o3(0xE9,0x91,0x9B),
- o3(0xE9,0x91,0xA0), o3(0xE9,0x91,0xA2),
- o3(0xE9,0x91,0x9E), o3(0xE9,0x91,0xAA),
- o3(0xE9,0x88,0xA9), o3(0xE9,0x91,0xB0),
- o3(0xE9,0x91,0xB5), o3(0xE9,0x91,0xB7),
- o3(0xE9,0x91,0xBD), o3(0xE9,0x91,0x9A),
- o3(0xE9,0x91,0xBC), o3(0xE9,0x91,0xBE),
- o3(0xE9,0x92,0x81), o3(0xE9,0x91,0xBF),
- o3(0xE9,0x96,0x82), o3(0xE9,0x96,0x87),
- o3(0xE9,0x96,0x8A), o3(0xE9,0x96,0x94),
- o3(0xE9,0x96,0x96), o3(0xE9,0x96,0x98),
- o3(0xE9,0x96,0x99), o3(0xE9,0x96,0xA0),
- o3(0xE9,0x96,0xA8), o3(0xE9,0x96,0xA7),
- o3(0xE9,0x96,0xAD), o3(0xE9,0x96,0xBC),
- o3(0xE9,0x96,0xBB), o3(0xE9,0x96,0xB9),
- o3(0xE9,0x96,0xBE), o3(0xE9,0x97,0x8A),
- o3(0xE6,0xBF,0xB6), o3(0xE9,0x97,0x83),
- o3(0xE9,0x97,0x8D), o3(0xE9,0x97,0x8C),
- o3(0xE9,0x97,0x95), o3(0xE9,0x97,0x94),
- o3(0xE9,0x97,0x96), o3(0xE9,0x97,0x9C),
- o3(0xE9,0x97,0xA1), o3(0xE9,0x97,0xA5),
- o3(0xE9,0x97,0xA2), o3(0xE9,0x98,0xA1),
- o3(0xE9,0x98,0xA8), o3(0xE9,0x98,0xAE),
- o3(0xE9,0x98,0xAF), o3(0xE9,0x99,0x82),
- o3(0xE9,0x99,0x8C), o3(0xE9,0x99,0x8F),
- o3(0xE9,0x99,0x8B), o3(0xE9,0x99,0xB7),
- o3(0xE9,0x99,0x9C), o3(0xE9,0x99,0x9E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_EF = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_EF_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_F0_infos[95] = {
- o3(0xE9,0x99,0x9D), o3(0xE9,0x99,0x9F),
- o3(0xE9,0x99,0xA6), o3(0xE9,0x99,0xB2),
- o3(0xE9,0x99,0xAC), o3(0xE9,0x9A,0x8D),
- o3(0xE9,0x9A,0x98), o3(0xE9,0x9A,0x95),
- o3(0xE9,0x9A,0x97), o3(0xE9,0x9A,0xAA),
- o3(0xE9,0x9A,0xA7), o3(0xE9,0x9A,0xB1),
- o3(0xE9,0x9A,0xB2), o3(0xE9,0x9A,0xB0),
- o3(0xE9,0x9A,0xB4), o3(0xE9,0x9A,0xB6),
- o3(0xE9,0x9A,0xB8), o3(0xE9,0x9A,0xB9),
- o3(0xE9,0x9B,0x8E), o3(0xE9,0x9B,0x8B),
- o3(0xE9,0x9B,0x89), o3(0xE9,0x9B,0x8D),
- o3(0xE8,0xA5,0x8D), o3(0xE9,0x9B,0x9C),
- o3(0xE9,0x9C,0x8D), o3(0xE9,0x9B,0x95),
- o3(0xE9,0x9B,0xB9), o3(0xE9,0x9C,0x84),
- o3(0xE9,0x9C,0x86), o3(0xE9,0x9C,0x88),
- o3(0xE9,0x9C,0x93), o3(0xE9,0x9C,0x8E),
- o3(0xE9,0x9C,0x91), o3(0xE9,0x9C,0x8F),
- o3(0xE9,0x9C,0x96), o3(0xE9,0x9C,0x99),
- o3(0xE9,0x9C,0xA4), o3(0xE9,0x9C,0xAA),
- o3(0xE9,0x9C,0xB0), o3(0xE9,0x9C,0xB9),
- o3(0xE9,0x9C,0xBD), o3(0xE9,0x9C,0xBE),
- o3(0xE9,0x9D,0x84), o3(0xE9,0x9D,0x86),
- o3(0xE9,0x9D,0x88), o3(0xE9,0x9D,0x82),
- o3(0xE9,0x9D,0x89), o3(0xE9,0x9D,0x9C),
- o3(0xE9,0x9D,0xA0), o3(0xE9,0x9D,0xA4),
- o3(0xE9,0x9D,0xA6), o3(0xE9,0x9D,0xA8),
- o3(0xE5,0x8B,0x92), o3(0xE9,0x9D,0xAB),
- o3(0xE9,0x9D,0xB1), o3(0xE9,0x9D,0xB9),
- o3(0xE9,0x9E,0x85), o3(0xE9,0x9D,0xBC),
- o3(0xE9,0x9E,0x81), o3(0xE9,0x9D,0xBA),
- o3(0xE9,0x9E,0x86), o3(0xE9,0x9E,0x8B),
- o3(0xE9,0x9E,0x8F), o3(0xE9,0x9E,0x90),
- o3(0xE9,0x9E,0x9C), o3(0xE9,0x9E,0xA8),
- o3(0xE9,0x9E,0xA6), o3(0xE9,0x9E,0xA3),
- o3(0xE9,0x9E,0xB3), o3(0xE9,0x9E,0xB4),
- o3(0xE9,0x9F,0x83), o3(0xE9,0x9F,0x86),
- o3(0xE9,0x9F,0x88), o3(0xE9,0x9F,0x8B),
- o3(0xE9,0x9F,0x9C), o3(0xE9,0x9F,0xAD),
- o3(0xE9,0xBD,0x8F), o3(0xE9,0x9F,0xB2),
- o3(0xE7,0xAB,0x9F), o3(0xE9,0x9F,0xB6),
- o3(0xE9,0x9F,0xB5), o3(0xE9,0xA0,0x8F),
- o3(0xE9,0xA0,0x8C), o3(0xE9,0xA0,0xB8),
- o3(0xE9,0xA0,0xA4), o3(0xE9,0xA0,0xA1),
- o3(0xE9,0xA0,0xB7), o3(0xE9,0xA0,0xBD),
- o3(0xE9,0xA1,0x86), o3(0xE9,0xA1,0x8F),
- o3(0xE9,0xA1,0x8B), o3(0xE9,0xA1,0xAB),
- o3(0xE9,0xA1,0xAF), o3(0xE9,0xA1,0xB0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_F0 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_F0_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_F1_infos[95] = {
- o3(0xE9,0xA1,0xB1), o3(0xE9,0xA1,0xB4),
- o3(0xE9,0xA1,0xB3), o3(0xE9,0xA2,0xAA),
- o3(0xE9,0xA2,0xAF), o3(0xE9,0xA2,0xB1),
- o3(0xE9,0xA2,0xB6), o3(0xE9,0xA3,0x84),
- o3(0xE9,0xA3,0x83), o3(0xE9,0xA3,0x86),
- o3(0xE9,0xA3,0xA9), o3(0xE9,0xA3,0xAB),
- o3(0xE9,0xA4,0x83), o3(0xE9,0xA4,0x89),
- o3(0xE9,0xA4,0x92), o3(0xE9,0xA4,0x94),
- o3(0xE9,0xA4,0x98), o3(0xE9,0xA4,0xA1),
- o3(0xE9,0xA4,0x9D), o3(0xE9,0xA4,0x9E),
- o3(0xE9,0xA4,0xA4), o3(0xE9,0xA4,0xA0),
- o3(0xE9,0xA4,0xAC), o3(0xE9,0xA4,0xAE),
- o3(0xE9,0xA4,0xBD), o3(0xE9,0xA4,0xBE),
- o3(0xE9,0xA5,0x82), o3(0xE9,0xA5,0x89),
- o3(0xE9,0xA5,0x85), o3(0xE9,0xA5,0x90),
- o3(0xE9,0xA5,0x8B), o3(0xE9,0xA5,0x91),
- o3(0xE9,0xA5,0x92), o3(0xE9,0xA5,0x8C),
- o3(0xE9,0xA5,0x95), o3(0xE9,0xA6,0x97),
- o3(0xE9,0xA6,0x98), o3(0xE9,0xA6,0xA5),
- o3(0xE9,0xA6,0xAD), o3(0xE9,0xA6,0xAE),
- o3(0xE9,0xA6,0xBC), o3(0xE9,0xA7,0x9F),
- o3(0xE9,0xA7,0x9B), o3(0xE9,0xA7,0x9D),
- o3(0xE9,0xA7,0x98), o3(0xE9,0xA7,0x91),
- o3(0xE9,0xA7,0xAD), o3(0xE9,0xA7,0xAE),
- o3(0xE9,0xA7,0xB1), o3(0xE9,0xA7,0xB2),
- o3(0xE9,0xA7,0xBB), o3(0xE9,0xA7,0xB8),
- o3(0xE9,0xA8,0x81), o3(0xE9,0xA8,0x8F),
- o3(0xE9,0xA8,0x85), o3(0xE9,0xA7,0xA2),
- o3(0xE9,0xA8,0x99), o3(0xE9,0xA8,0xAB),
- o3(0xE9,0xA8,0xB7), o3(0xE9,0xA9,0x85),
- o3(0xE9,0xA9,0x82), o3(0xE9,0xA9,0x80),
- o3(0xE9,0xA9,0x83), o3(0xE9,0xA8,0xBE),
- o3(0xE9,0xA9,0x95), o3(0xE9,0xA9,0x8D),
- o3(0xE9,0xA9,0x9B), o3(0xE9,0xA9,0x97),
- o3(0xE9,0xA9,0x9F), o3(0xE9,0xA9,0xA2),
- o3(0xE9,0xA9,0xA5), o3(0xE9,0xA9,0xA4),
- o3(0xE9,0xA9,0xA9), o3(0xE9,0xA9,0xAB),
- o3(0xE9,0xA9,0xAA), o3(0xE9,0xAA,0xAD),
- o3(0xE9,0xAA,0xB0), o3(0xE9,0xAA,0xBC),
- o3(0xE9,0xAB,0x80), o3(0xE9,0xAB,0x8F),
- o3(0xE9,0xAB,0x91), o3(0xE9,0xAB,0x93),
- o3(0xE9,0xAB,0x94), o3(0xE9,0xAB,0x9E),
- o3(0xE9,0xAB,0x9F), o3(0xE9,0xAB,0xA2),
- o3(0xE9,0xAB,0xA3), o3(0xE9,0xAB,0xA6),
- o3(0xE9,0xAB,0xAF), o3(0xE9,0xAB,0xAB),
- o3(0xE9,0xAB,0xAE), o3(0xE9,0xAB,0xB4),
- o3(0xE9,0xAB,0xB1), o3(0xE9,0xAB,0xB7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_F1 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_F1_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_F2_infos[95] = {
- o3(0xE9,0xAB,0xBB), o3(0xE9,0xAC,0x86),
- o3(0xE9,0xAC,0x98), o3(0xE9,0xAC,0x9A),
- o3(0xE9,0xAC,0x9F), o3(0xE9,0xAC,0xA2),
- o3(0xE9,0xAC,0xA3), o3(0xE9,0xAC,0xA5),
- o3(0xE9,0xAC,0xA7), o3(0xE9,0xAC,0xA8),
- o3(0xE9,0xAC,0xA9), o3(0xE9,0xAC,0xAA),
- o3(0xE9,0xAC,0xAE), o3(0xE9,0xAC,0xAF),
- o3(0xE9,0xAC,0xB2), o3(0xE9,0xAD,0x84),
- o3(0xE9,0xAD,0x83), o3(0xE9,0xAD,0x8F),
- o3(0xE9,0xAD,0x8D), o3(0xE9,0xAD,0x8E),
- o3(0xE9,0xAD,0x91), o3(0xE9,0xAD,0x98),
- o3(0xE9,0xAD,0xB4), o3(0xE9,0xAE,0x93),
- o3(0xE9,0xAE,0x83), o3(0xE9,0xAE,0x91),
- o3(0xE9,0xAE,0x96), o3(0xE9,0xAE,0x97),
- o3(0xE9,0xAE,0x9F), o3(0xE9,0xAE,0xA0),
- o3(0xE9,0xAE,0xA8), o3(0xE9,0xAE,0xB4),
- o3(0xE9,0xAF,0x80), o3(0xE9,0xAF,0x8A),
- o3(0xE9,0xAE,0xB9), o3(0xE9,0xAF,0x86),
- o3(0xE9,0xAF,0x8F), o3(0xE9,0xAF,0x91),
- o3(0xE9,0xAF,0x92), o3(0xE9,0xAF,0xA3),
- o3(0xE9,0xAF,0xA2), o3(0xE9,0xAF,0xA4),
- o3(0xE9,0xAF,0x94), o3(0xE9,0xAF,0xA1),
- o3(0xE9,0xB0,0xBA), o3(0xE9,0xAF,0xB2),
- o3(0xE9,0xAF,0xB1), o3(0xE9,0xAF,0xB0),
- o3(0xE9,0xB0,0x95), o3(0xE9,0xB0,0x94),
- o3(0xE9,0xB0,0x89), o3(0xE9,0xB0,0x93),
- o3(0xE9,0xB0,0x8C), o3(0xE9,0xB0,0x86),
- o3(0xE9,0xB0,0x88), o3(0xE9,0xB0,0x92),
- o3(0xE9,0xB0,0x8A), o3(0xE9,0xB0,0x84),
- o3(0xE9,0xB0,0xAE), o3(0xE9,0xB0,0x9B),
- o3(0xE9,0xB0,0xA5), o3(0xE9,0xB0,0xA4),
- o3(0xE9,0xB0,0xA1), o3(0xE9,0xB0,0xB0),
- o3(0xE9,0xB1,0x87), o3(0xE9,0xB0,0xB2),
- o3(0xE9,0xB1,0x86), o3(0xE9,0xB0,0xBE),
- o3(0xE9,0xB1,0x9A), o3(0xE9,0xB1,0xA0),
- o3(0xE9,0xB1,0xA7), o3(0xE9,0xB1,0xB6),
- o3(0xE9,0xB1,0xB8), o3(0xE9,0xB3,0xA7),
- o3(0xE9,0xB3,0xAC), o3(0xE9,0xB3,0xB0),
- o3(0xE9,0xB4,0x89), o3(0xE9,0xB4,0x88),
- o3(0xE9,0xB3,0xAB), o3(0xE9,0xB4,0x83),
- o3(0xE9,0xB4,0x86), o3(0xE9,0xB4,0xAA),
- o3(0xE9,0xB4,0xA6), o3(0xE9,0xB6,0xAF),
- o3(0xE9,0xB4,0xA3), o3(0xE9,0xB4,0x9F),
- o3(0xE9,0xB5,0x84), o3(0xE9,0xB4,0x95),
- o3(0xE9,0xB4,0x92), o3(0xE9,0xB5,0x81),
- o3(0xE9,0xB4,0xBF), o3(0xE9,0xB4,0xBE),
- o3(0xE9,0xB5,0x86), o3(0xE9,0xB5,0x88),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_F2 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_F2_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_F3_infos[95] = {
- o3(0xE9,0xB5,0x9D), o3(0xE9,0xB5,0x9E),
- o3(0xE9,0xB5,0xA4), o3(0xE9,0xB5,0x91),
- o3(0xE9,0xB5,0x90), o3(0xE9,0xB5,0x99),
- o3(0xE9,0xB5,0xB2), o3(0xE9,0xB6,0x89),
- o3(0xE9,0xB6,0x87), o3(0xE9,0xB6,0xAB),
- o3(0xE9,0xB5,0xAF), o3(0xE9,0xB5,0xBA),
- o3(0xE9,0xB6,0x9A), o3(0xE9,0xB6,0xA4),
- o3(0xE9,0xB6,0xA9), o3(0xE9,0xB6,0xB2),
- o3(0xE9,0xB7,0x84), o3(0xE9,0xB7,0x81),
- o3(0xE9,0xB6,0xBB), o3(0xE9,0xB6,0xB8),
- o3(0xE9,0xB6,0xBA), o3(0xE9,0xB7,0x86),
- o3(0xE9,0xB7,0x8F), o3(0xE9,0xB7,0x82),
- o3(0xE9,0xB7,0x99), o3(0xE9,0xB7,0x93),
- o3(0xE9,0xB7,0xB8), o3(0xE9,0xB7,0xA6),
- o3(0xE9,0xB7,0xAD), o3(0xE9,0xB7,0xAF),
- o3(0xE9,0xB7,0xBD), o3(0xE9,0xB8,0x9A),
- o3(0xE9,0xB8,0x9B), o3(0xE9,0xB8,0x9E),
- o3(0xE9,0xB9,0xB5), o3(0xE9,0xB9,0xB9),
- o3(0xE9,0xB9,0xBD), o3(0xE9,0xBA,0x81),
- o3(0xE9,0xBA,0x88), o3(0xE9,0xBA,0x8B),
- o3(0xE9,0xBA,0x8C), o3(0xE9,0xBA,0x92),
- o3(0xE9,0xBA,0x95), o3(0xE9,0xBA,0x91),
- o3(0xE9,0xBA,0x9D), o3(0xE9,0xBA,0xA5),
- o3(0xE9,0xBA,0xA9), o3(0xE9,0xBA,0xB8),
- o3(0xE9,0xBA,0xAA), o3(0xE9,0xBA,0xAD),
- o3(0xE9,0x9D,0xA1), o3(0xE9,0xBB,0x8C),
- o3(0xE9,0xBB,0x8E), o3(0xE9,0xBB,0x8F),
- o3(0xE9,0xBB,0x90), o3(0xE9,0xBB,0x94),
- o3(0xE9,0xBB,0x9C), o3(0xE9,0xBB,0x9E),
- o3(0xE9,0xBB,0x9D), o3(0xE9,0xBB,0xA0),
- o3(0xE9,0xBB,0xA5), o3(0xE9,0xBB,0xA8),
- o3(0xE9,0xBB,0xAF), o3(0xE9,0xBB,0xB4),
- o3(0xE9,0xBB,0xB6), o3(0xE9,0xBB,0xB7),
- o3(0xE9,0xBB,0xB9), o3(0xE9,0xBB,0xBB),
- o3(0xE9,0xBB,0xBC), o3(0xE9,0xBB,0xBD),
- o3(0xE9,0xBC,0x87), o3(0xE9,0xBC,0x88),
- o3(0xE7,0x9A,0xB7), o3(0xE9,0xBC,0x95),
- o3(0xE9,0xBC,0xA1), o3(0xE9,0xBC,0xAC),
- o3(0xE9,0xBC,0xBE), o3(0xE9,0xBD,0x8A),
- o3(0xE9,0xBD,0x92), o3(0xE9,0xBD,0x94),
- o3(0xE9,0xBD,0xA3), o3(0xE9,0xBD,0x9F),
- o3(0xE9,0xBD,0xA0), o3(0xE9,0xBD,0xA1),
- o3(0xE9,0xBD,0xA6), o3(0xE9,0xBD,0xA7),
- o3(0xE9,0xBD,0xAC), o3(0xE9,0xBD,0xAA),
- o3(0xE9,0xBD,0xB7), o3(0xE9,0xBD,0xB2),
- o3(0xE9,0xBD,0xB6), o3(0xE9,0xBE,0x95),
- o3(0xE9,0xBE,0x9C), o3(0xE9,0xBE,0xA0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_F3 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_F3_infos
-};
-
-static const unsigned char
-from_EUC_JP_F4_offsets[256] = {
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-from_EUC_JP_F4_infos[7] = {
- o3(0xE5,0xA0,0xAF), o3(0xE6,0xA7,0x87),
- o3(0xE9,0x81,0x99), o3(0xE7,0x91,0xA4),
- o3(0xE5,0x87,0x9C), o3(0xE7,0x86,0x99),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_F4 = {
- from_EUC_JP_F4_offsets,
- from_EUC_JP_F4_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_F9_infos[95] = {
- o3(0xE7,0xBA,0x8A), o3(0xE8,0xA4,0x9C),
- o3(0xE9,0x8D,0x88), o3(0xE9,0x8A,0x88),
- o3(0xE8,0x93,0x9C), o3(0xE4,0xBF,0x89),
- o3(0xE7,0x82,0xBB), o3(0xE6,0x98,0xB1),
- o3(0xE6,0xA3,0x88), o3(0xE9,0x8B,0xB9),
- o3(0xE6,0x9B,0xBB), o3(0xE5,0xBD,0x85),
- o3(0xE4,0xB8,0xA8), o3(0xE4,0xBB,0xA1),
- o3(0xE4,0xBB,0xBC), o3(0xE4,0xBC,0x80),
- o3(0xE4,0xBC,0x83), o3(0xE4,0xBC,0xB9),
- o3(0xE4,0xBD,0x96), o3(0xE4,0xBE,0x92),
- o3(0xE4,0xBE,0x8A), o3(0xE4,0xBE,0x9A),
- o3(0xE4,0xBE,0x94), o3(0xE4,0xBF,0x8D),
- o3(0xE5,0x81,0x80), o3(0xE5,0x80,0xA2),
- o3(0xE4,0xBF,0xBF), o3(0xE5,0x80,0x9E),
- o3(0xE5,0x81,0x86), o3(0xE5,0x81,0xB0),
- o3(0xE5,0x81,0x82), o3(0xE5,0x82,0x94),
- o3(0xE5,0x83,0xB4), o3(0xE5,0x83,0x98),
- o3(0xE5,0x85,0x8A), o3(0xE5,0x85,0xA4),
- o3(0xE5,0x86,0x9D), o3(0xE5,0x86,0xBE),
- o3(0xE5,0x87,0xAC), o3(0xE5,0x88,0x95),
- o3(0xE5,0x8A,0x9C), o3(0xE5,0x8A,0xA6),
- o3(0xE5,0x8B,0x80), o3(0xE5,0x8B,0x9B),
- o3(0xE5,0x8C,0x80), o3(0xE5,0x8C,0x87),
- o3(0xE5,0x8C,0xA4), o3(0xE5,0x8D,0xB2),
- o3(0xE5,0x8E,0x93), o3(0xE5,0x8E,0xB2),
- o3(0xE5,0x8F,0x9D), o3(0xEF,0xA8,0x8E),
- o3(0xE5,0x92,0x9C), o3(0xE5,0x92,0x8A),
- o3(0xE5,0x92,0xA9), o3(0xE5,0x93,0xBF),
- o3(0xE5,0x96,0x86), o3(0xE5,0x9D,0x99),
- o3(0xE5,0x9D,0xA5), o3(0xE5,0x9E,0xAC),
- o3(0xE5,0x9F,0x88), o3(0xE5,0x9F,0x87),
- o3(0xEF,0xA8,0x8F), o3(0xEF,0xA8,0x90),
- o3(0xE5,0xA2,0x9E), o3(0xE5,0xA2,0xB2),
- o3(0xE5,0xA4,0x8B), o3(0xE5,0xA5,0x93),
- o3(0xE5,0xA5,0x9B), o3(0xE5,0xA5,0x9D),
- o3(0xE5,0xA5,0xA3), o3(0xE5,0xA6,0xA4),
- o3(0xE5,0xA6,0xBA), o3(0xE5,0xAD,0x96),
- o3(0xE5,0xAF,0x80), o3(0xE7,0x94,0xAF),
- o3(0xE5,0xAF,0x98), o3(0xE5,0xAF,0xAC),
- o3(0xE5,0xB0,0x9E), o3(0xE5,0xB2,0xA6),
- o3(0xE5,0xB2,0xBA), o3(0xE5,0xB3,0xB5),
- o3(0xE5,0xB4,0xA7), o3(0xE5,0xB5,0x93),
- o3(0xEF,0xA8,0x91), o3(0xE5,0xB5,0x82),
- o3(0xE5,0xB5,0xAD), o3(0xE5,0xB6,0xB8),
- o3(0xE5,0xB6,0xB9), o3(0xE5,0xB7,0x90),
- o3(0xE5,0xBC,0xA1), o3(0xE5,0xBC,0xB4),
- o3(0xE5,0xBD,0xA7), o3(0xE5,0xBE,0xB7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_F9 = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_F9_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_FA_infos[95] = {
- o3(0xE5,0xBF,0x9E), o3(0xE6,0x81,0x9D),
- o3(0xE6,0x82,0x85), o3(0xE6,0x82,0x8A),
- o3(0xE6,0x83,0x9E), o3(0xE6,0x83,0x95),
- o3(0xE6,0x84,0xA0), o3(0xE6,0x83,0xB2),
- o3(0xE6,0x84,0x91), o3(0xE6,0x84,0xB7),
- o3(0xE6,0x84,0xB0), o3(0xE6,0x86,0x98),
- o3(0xE6,0x88,0x93), o3(0xE6,0x8A,0xA6),
- o3(0xE6,0x8F,0xB5), o3(0xE6,0x91,0xA0),
- o3(0xE6,0x92,0x9D), o3(0xE6,0x93,0x8E),
- o3(0xE6,0x95,0x8E), o3(0xE6,0x98,0x80),
- o3(0xE6,0x98,0x95), o3(0xE6,0x98,0xBB),
- o3(0xE6,0x98,0x89), o3(0xE6,0x98,0xAE),
- o3(0xE6,0x98,0x9E), o3(0xE6,0x98,0xA4),
- o3(0xE6,0x99,0xA5), o3(0xE6,0x99,0x97),
- o3(0xE6,0x99,0x99), o3(0xEF,0xA8,0x92),
- o3(0xE6,0x99,0xB3), o3(0xE6,0x9A,0x99),
- o3(0xE6,0x9A,0xA0), o3(0xE6,0x9A,0xB2),
- o3(0xE6,0x9A,0xBF), o3(0xE6,0x9B,0xBA),
- o3(0xE6,0x9C,0x8E), o3(0xEF,0xA4,0xA9),
- o3(0xE6,0x9D,0xA6), o3(0xE6,0x9E,0xBB),
- o3(0xE6,0xA1,0x92), o3(0xE6,0x9F,0x80),
- o3(0xE6,0xA0,0x81), o3(0xE6,0xA1,0x84),
- o3(0xE6,0xA3,0x8F), o3(0xEF,0xA8,0x93),
- o3(0xE6,0xA5,0xA8), o3(0xEF,0xA8,0x94),
- o3(0xE6,0xA6,0x98), o3(0xE6,0xA7,0xA2),
- o3(0xE6,0xA8,0xB0), o3(0xE6,0xA9,0xAB),
- o3(0xE6,0xA9,0x86), o3(0xE6,0xA9,0xB3),
- o3(0xE6,0xA9,0xBE), o3(0xE6,0xAB,0xA2),
- o3(0xE6,0xAB,0xA4), o3(0xE6,0xAF,0x96),
- o3(0xE6,0xB0,0xBF), o3(0xE6,0xB1,0x9C),
- o3(0xE6,0xB2,0x86), o3(0xE6,0xB1,0xAF),
- o3(0xE6,0xB3,0x9A), o3(0xE6,0xB4,0x84),
- o3(0xE6,0xB6,0x87), o3(0xE6,0xB5,0xAF),
- o3(0xE6,0xB6,0x96), o3(0xE6,0xB6,0xAC),
- o3(0xE6,0xB7,0x8F), o3(0xE6,0xB7,0xB8),
- o3(0xE6,0xB7,0xB2), o3(0xE6,0xB7,0xBC),
- o3(0xE6,0xB8,0xB9), o3(0xE6,0xB9,0x9C),
- o3(0xE6,0xB8,0xA7), o3(0xE6,0xB8,0xBC),
- o3(0xE6,0xBA,0xBF), o3(0xE6,0xBE,0x88),
- o3(0xE6,0xBE,0xB5), o3(0xE6,0xBF,0xB5),
- o3(0xE7,0x80,0x85), o3(0xE7,0x80,0x87),
- o3(0xE7,0x80,0xA8), o3(0xE7,0x82,0x85),
- o3(0xE7,0x82,0xAB), o3(0xE7,0x84,0x8F),
- o3(0xE7,0x84,0x84), o3(0xE7,0x85,0x9C),
- o3(0xE7,0x85,0x86), o3(0xE7,0x85,0x87),
- o3(0xEF,0xA8,0x95), o3(0xE7,0x87,0x81),
- o3(0xE7,0x87,0xBE), o3(0xE7,0x8A,0xB1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_FA = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_FA_infos
-};
-
-static const struct byte_lookup* const
-from_EUC_JP_FB_infos[95] = {
- o3(0xE7,0x8A,0xBE), o3(0xE7,0x8C,0xA4),
- o3(0xEF,0xA8,0x96), o3(0xE7,0x8D,0xB7),
- o3(0xE7,0x8E,0xBD), o3(0xE7,0x8F,0x89),
- o3(0xE7,0x8F,0x96), o3(0xE7,0x8F,0xA3),
- o3(0xE7,0x8F,0x92), o3(0xE7,0x90,0x87),
- o3(0xE7,0x8F,0xB5), o3(0xE7,0x90,0xA6),
- o3(0xE7,0x90,0xAA), o3(0xE7,0x90,0xA9),
- o3(0xE7,0x90,0xAE), o3(0xE7,0x91,0xA2),
- o3(0xE7,0x92,0x89), o3(0xE7,0x92,0x9F),
- o3(0xE7,0x94,0x81), o3(0xE7,0x95,0xAF),
- o3(0xE7,0x9A,0x82), o3(0xE7,0x9A,0x9C),
- o3(0xE7,0x9A,0x9E), o3(0xE7,0x9A,0x9B),
- o3(0xE7,0x9A,0xA6), o3(0xEF,0xA8,0x97),
- o3(0xE7,0x9D,0x86), o3(0xE5,0x8A,0xAF),
- o3(0xE7,0xA0,0xA1), o3(0xE7,0xA1,0x8E),
- o3(0xE7,0xA1,0xA4), o3(0xE7,0xA1,0xBA),
- o3(0xE7,0xA4,0xB0), o3(0xEF,0xA8,0x98),
- o3(0xEF,0xA8,0x99), o3(0xEF,0xA8,0x9A),
- o3(0xE7,0xA6,0x94), o3(0xEF,0xA8,0x9B),
- o3(0xE7,0xA6,0x9B), o3(0xE7,0xAB,0x91),
- o3(0xE7,0xAB,0xA7), o3(0xEF,0xA8,0x9C),
- o3(0xE7,0xAB,0xAB), o3(0xE7,0xAE,0x9E),
- o3(0xEF,0xA8,0x9D), o3(0xE7,0xB5,0x88),
- o3(0xE7,0xB5,0x9C), o3(0xE7,0xB6,0xB7),
- o3(0xE7,0xB6,0xA0), o3(0xE7,0xB7,0x96),
- o3(0xE7,0xB9,0x92), o3(0xE7,0xBD,0x87),
- o3(0xE7,0xBE,0xA1), o3(0xEF,0xA8,0x9E),
- o3(0xE8,0x8C,0x81), o3(0xE8,0x8D,0xA2),
- o3(0xE8,0x8D,0xBF), o3(0xE8,0x8F,0x87),
- o3(0xE8,0x8F,0xB6), o3(0xE8,0x91,0x88),
- o3(0xE8,0x92,0xB4), o3(0xE8,0x95,0x93),
- o3(0xE8,0x95,0x99), o3(0xE8,0x95,0xAB),
- o3(0xEF,0xA8,0x9F), o3(0xE8,0x96,0xB0),
- o3(0xEF,0xA8,0xA0), o3(0xEF,0xA8,0xA1),
- o3(0xE8,0xA0,0x87), o3(0xE8,0xA3,0xB5),
- o3(0xE8,0xA8,0x92), o3(0xE8,0xA8,0xB7),
- o3(0xE8,0xA9,0xB9), o3(0xE8,0xAA,0xA7),
- o3(0xE8,0xAA,0xBE), o3(0xE8,0xAB,0x9F),
- o3(0xEF,0xA8,0xA2), o3(0xE8,0xAB,0xB6),
- o3(0xE8,0xAD,0x93), o3(0xE8,0xAD,0xBF),
- o3(0xE8,0xB3,0xB0), o3(0xE8,0xB3,0xB4),
- o3(0xE8,0xB4,0x92), o3(0xE8,0xB5,0xB6),
- o3(0xEF,0xA8,0xA3), o3(0xE8,0xBB,0x8F),
- o3(0xEF,0xA8,0xA4), o3(0xEF,0xA8,0xA5),
- o3(0xE9,0x81,0xA7), o3(0xE9,0x83,0x9E),
- o3(0xEF,0xA8,0xA6), o3(0xE9,0x84,0x95),
- o3(0xE9,0x84,0xA7), o3(0xE9,0x87,0x9A),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_FB = {
- from_EUC_JP_A1_offsets,
- from_EUC_JP_FB_infos
-};
-
-static const unsigned char
-from_EUC_JP_FC_offsets[256] = {
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 91,
- 91, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 91, 88, 89, 90, 91,
-};
-static const struct byte_lookup* const
-from_EUC_JP_FC_infos[92] = {
- o3(0xE9,0x87,0x97), o3(0xE9,0x87,0x9E),
- o3(0xE9,0x87,0xAD), o3(0xE9,0x87,0xAE),
- o3(0xE9,0x87,0xA4), o3(0xE9,0x87,0xA5),
- o3(0xE9,0x88,0x86), o3(0xE9,0x88,0x90),
- o3(0xE9,0x88,0x8A), o3(0xE9,0x88,0xBA),
- o3(0xE9,0x89,0x80), o3(0xE9,0x88,0xBC),
- o3(0xE9,0x89,0x8E), o3(0xE9,0x89,0x99),
- o3(0xE9,0x89,0x91), o3(0xE9,0x88,0xB9),
- o3(0xE9,0x89,0xA7), o3(0xE9,0x8A,0xA7),
- o3(0xE9,0x89,0xB7), o3(0xE9,0x89,0xB8),
- o3(0xE9,0x8B,0xA7), o3(0xE9,0x8B,0x97),
- o3(0xE9,0x8B,0x99), o3(0xE9,0x8B,0x90),
- o3(0xEF,0xA8,0xA7), o3(0xE9,0x8B,0x95),
- o3(0xE9,0x8B,0xA0), o3(0xE9,0x8B,0x93),
- o3(0xE9,0x8C,0xA5), o3(0xE9,0x8C,0xA1),
- o3(0xE9,0x8B,0xBB), o3(0xEF,0xA8,0xA8),
- o3(0xE9,0x8C,0x9E), o3(0xE9,0x8B,0xBF),
- o3(0xE9,0x8C,0x9D), o3(0xE9,0x8C,0x82),
- o3(0xE9,0x8D,0xB0), o3(0xE9,0x8D,0x97),
- o3(0xE9,0x8E,0xA4), o3(0xE9,0x8F,0x86),
- o3(0xE9,0x8F,0x9E), o3(0xE9,0x8F,0xB8),
- o3(0xE9,0x90,0xB1), o3(0xE9,0x91,0x85),
- o3(0xE9,0x91,0x88), o3(0xE9,0x96,0x92),
- o3(0xEF,0xA7,0x9C), o3(0xEF,0xA8,0xA9),
- o3(0xE9,0x9A,0x9D), o3(0xE9,0x9A,0xAF),
- o3(0xE9,0x9C,0xB3), o3(0xE9,0x9C,0xBB),
- o3(0xE9,0x9D,0x83), o3(0xE9,0x9D,0x8D),
- o3(0xE9,0x9D,0x8F), o3(0xE9,0x9D,0x91),
- o3(0xE9,0x9D,0x95), o3(0xE9,0xA1,0x97),
- o3(0xE9,0xA1,0xA5), o3(0xEF,0xA8,0xAA),
- o3(0xEF,0xA8,0xAB), o3(0xE9,0xA4,0xA7),
- o3(0xEF,0xA8,0xAC), o3(0xE9,0xA6,0x9E),
- o3(0xE9,0xA9,0x8E), o3(0xE9,0xAB,0x99),
- o3(0xE9,0xAB,0x9C), o3(0xE9,0xAD,0xB5),
- o3(0xE9,0xAD,0xB2), o3(0xE9,0xAE,0x8F),
- o3(0xE9,0xAE,0xB1), o3(0xE9,0xAE,0xBB),
- o3(0xE9,0xB0,0x80), o3(0xE9,0xB5,0xB0),
- o3(0xE9,0xB5,0xAB), o3(0xEF,0xA8,0xAD),
- o3(0xE9,0xB8,0x99), o3(0xE9,0xBB,0x91),
- o3(0xE2,0x85,0xB0), o3(0xE2,0x85,0xB1),
- o3(0xE2,0x85,0xB2), o3(0xE2,0x85,0xB3),
- o3(0xE2,0x85,0xB4), o3(0xE2,0x85,0xB5),
- o3(0xE2,0x85,0xB6), o3(0xE2,0x85,0xB7),
- o3(0xE2,0x85,0xB8), o3(0xE2,0x85,0xB9),
- o3(0xEF,0xBF,0xA4), o3(0xEF,0xBC,0x87),
- o3(0xEF,0xBC,0x82), UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP_FC = {
- from_EUC_JP_FC_offsets,
- from_EUC_JP_FC_infos
-};
-
-static const unsigned char
-from_EUC_JP_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 1, 84,
- 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
- 84, 2, 3, 4, 5, 6, 7, 8, 9, 84, 84, 84, 84, 10, 84, 84,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 84, 84, 84, 84, 80, 81, 82, 83, 84, 84, 84,
-};
-static const struct byte_lookup* const
-from_EUC_JP_infos[85] = {
- NOMAP, &from_EUC_JP_8E, &from_EUC_JP_A1, &from_EUC_JP_A2,
- &from_EUC_JP_A3, &from_EUC_JP_A4, &from_EUC_JP_A5, &from_EUC_JP_A6,
- &from_EUC_JP_A7, &from_EUC_JP_A8, &from_EUC_JP_AD, &from_EUC_JP_B0,
- &from_EUC_JP_B1, &from_EUC_JP_B2, &from_EUC_JP_B3, &from_EUC_JP_B4,
- &from_EUC_JP_B5, &from_EUC_JP_B6, &from_EUC_JP_B7, &from_EUC_JP_B8,
- &from_EUC_JP_B9, &from_EUC_JP_BA, &from_EUC_JP_BB, &from_EUC_JP_BC,
- &from_EUC_JP_BD, &from_EUC_JP_BE, &from_EUC_JP_BF, &from_EUC_JP_C0,
- &from_EUC_JP_C1, &from_EUC_JP_C2, &from_EUC_JP_C3, &from_EUC_JP_C4,
- &from_EUC_JP_C5, &from_EUC_JP_C6, &from_EUC_JP_C7, &from_EUC_JP_C8,
- &from_EUC_JP_C9, &from_EUC_JP_CA, &from_EUC_JP_CB, &from_EUC_JP_CC,
- &from_EUC_JP_CD, &from_EUC_JP_CE, &from_EUC_JP_CF, &from_EUC_JP_D0,
- &from_EUC_JP_D1, &from_EUC_JP_D2, &from_EUC_JP_D3, &from_EUC_JP_D4,
- &from_EUC_JP_D5, &from_EUC_JP_D6, &from_EUC_JP_D7, &from_EUC_JP_D8,
- &from_EUC_JP_D9, &from_EUC_JP_DA, &from_EUC_JP_DB, &from_EUC_JP_DC,
- &from_EUC_JP_DD, &from_EUC_JP_DE, &from_EUC_JP_DF, &from_EUC_JP_E0,
- &from_EUC_JP_E1, &from_EUC_JP_E2, &from_EUC_JP_E3, &from_EUC_JP_E4,
- &from_EUC_JP_E5, &from_EUC_JP_E6, &from_EUC_JP_E7, &from_EUC_JP_E8,
- &from_EUC_JP_E9, &from_EUC_JP_EA, &from_EUC_JP_EB, &from_EUC_JP_EC,
- &from_EUC_JP_ED, &from_EUC_JP_EE, &from_EUC_JP_EF, &from_EUC_JP_F0,
- &from_EUC_JP_F1, &from_EUC_JP_F2, &from_EUC_JP_F3, &from_EUC_JP_F4,
- &from_EUC_JP_F9, &from_EUC_JP_FA, &from_EUC_JP_FB, &from_EUC_JP_FC,
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_EUC_JP = {
- from_EUC_JP_offsets,
- from_EUC_JP_infos
-};
-static rb_transcoder
-rb_from_EUC_JP = {
- "EUC-JP", "UTF-8", &from_EUC_JP, 3, 0,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_C2_infos[14] = {
- o2(0xA1,0xF1), o2(0xA1,0xF2), o2(0xA1,0xEF), o2(0xFC,0xFC),
- o2(0xA1,0xF8), o2(0xA1,0xAF), o2(0xA2,0xCC), o2(0xA1,0xB1),
- o2(0xA1,0xEB), o2(0xA1,0xDE), o2(0xA1,0xAD), o2(0xA2,0xF9),
- o2(0xA1,0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_C2 = {
- to_SHIFT_JIS_C2_offsets,
- to_EUC_JP_C2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_C3_infos[3] = {
- o2(0xA1,0xDF), o2(0xA1,0xE0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_C3 = {
- to_SHIFT_JIS_C3_offsets,
- to_EUC_JP_C3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_CE_infos[40] = {
- o2(0xA6,0xA1), o2(0xA6,0xA2), o2(0xA6,0xA3), o2(0xA6,0xA4),
- o2(0xA6,0xA5), o2(0xA6,0xA6), o2(0xA6,0xA7), o2(0xA6,0xA8),
- o2(0xA6,0xA9), o2(0xA6,0xAA), o2(0xA6,0xAB), o2(0xA6,0xAC),
- o2(0xA6,0xAD), o2(0xA6,0xAE), o2(0xA6,0xAF), o2(0xA6,0xB0),
- o2(0xA6,0xB1), o2(0xA6,0xB2), o2(0xA6,0xB3), o2(0xA6,0xB4),
- o2(0xA6,0xB5), o2(0xA6,0xB6), o2(0xA6,0xB7), o2(0xA6,0xB8),
- o2(0xA6,0xC1), o2(0xA6,0xC2), o2(0xA6,0xC3), o2(0xA6,0xC4),
- o2(0xA6,0xC5), o2(0xA6,0xC6), o2(0xA6,0xC7), o2(0xA6,0xC8),
- o2(0xA6,0xC9), o2(0xA6,0xCA), o2(0xA6,0xCB), o2(0xA6,0xCC),
- o2(0xA6,0xCD), o2(0xA6,0xCE), o2(0xA6,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_CE = {
- to_SHIFT_JIS_CE_offsets,
- to_EUC_JP_CE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_CF_infos[10] = {
- o2(0xA6,0xD0), o2(0xA6,0xD1), o2(0xA6,0xD2), o2(0xA6,0xD3),
- o2(0xA6,0xD4), o2(0xA6,0xD5), o2(0xA6,0xD6), o2(0xA6,0xD7),
- o2(0xA6,0xD8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_CF = {
- to_SHIFT_JIS_CF_offsets,
- to_EUC_JP_CF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_D0_infos[50] = {
- o2(0xA7,0xA7), o2(0xA7,0xA1), o2(0xA7,0xA2), o2(0xA7,0xA3),
- o2(0xA7,0xA4), o2(0xA7,0xA5), o2(0xA7,0xA6), o2(0xA7,0xA8),
- o2(0xA7,0xA9), o2(0xA7,0xAA), o2(0xA7,0xAB), o2(0xA7,0xAC),
- o2(0xA7,0xAD), o2(0xA7,0xAE), o2(0xA7,0xAF), o2(0xA7,0xB0),
- o2(0xA7,0xB1), o2(0xA7,0xB2), o2(0xA7,0xB3), o2(0xA7,0xB4),
- o2(0xA7,0xB5), o2(0xA7,0xB6), o2(0xA7,0xB7), o2(0xA7,0xB8),
- o2(0xA7,0xB9), o2(0xA7,0xBA), o2(0xA7,0xBB), o2(0xA7,0xBC),
- o2(0xA7,0xBD), o2(0xA7,0xBE), o2(0xA7,0xBF), o2(0xA7,0xC0),
- o2(0xA7,0xC1), o2(0xA7,0xD1), o2(0xA7,0xD2), o2(0xA7,0xD3),
- o2(0xA7,0xD4), o2(0xA7,0xD5), o2(0xA7,0xD6), o2(0xA7,0xD8),
- o2(0xA7,0xD9), o2(0xA7,0xDA), o2(0xA7,0xDB), o2(0xA7,0xDC),
- o2(0xA7,0xDD), o2(0xA7,0xDE), o2(0xA7,0xDF), o2(0xA7,0xE0),
- o2(0xA7,0xE1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_D0 = {
- to_SHIFT_JIS_D0_offsets,
- to_EUC_JP_D0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_D1_infos[18] = {
- o2(0xA7,0xE2), o2(0xA7,0xE3), o2(0xA7,0xE4), o2(0xA7,0xE5),
- o2(0xA7,0xE6), o2(0xA7,0xE7), o2(0xA7,0xE8), o2(0xA7,0xE9),
- o2(0xA7,0xEA), o2(0xA7,0xEB), o2(0xA7,0xEC), o2(0xA7,0xED),
- o2(0xA7,0xEE), o2(0xA7,0xEF), o2(0xA7,0xF0), o2(0xA7,0xF1),
- o2(0xA7,0xD7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_D1 = {
- to_SHIFT_JIS_D1_offsets,
- to_EUC_JP_D1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_80_infos[16] = {
- o2(0xA1,0xBE), o2(0xA1,0xBD), o2(0xA1,0xC2), o2(0xA1,0xC6),
- o2(0xA1,0xC7), o2(0xA1,0xC8), o2(0xA1,0xC9), o2(0xA2,0xF7),
- o2(0xA2,0xF8), o2(0xA1,0xC5), o2(0xA1,0xC4), o2(0xA2,0xF3),
- o2(0xA1,0xEC), o2(0xA1,0xED), o2(0xA2,0xA8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_80 = {
- to_SHIFT_JIS_E2_80_offsets,
- to_EUC_JP_E2_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_84_infos[5] = {
- o2(0xA1,0xEE), o2(0xAD,0xE2), o2(0xAD,0xE4), o2(0xA2,0xF2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_84 = {
- to_SHIFT_JIS_E2_84_offsets,
- to_EUC_JP_E2_84_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_85_infos[21] = {
- o2(0xAD,0xB5), o2(0xAD,0xB6), o2(0xAD,0xB7), o2(0xAD,0xB8),
- o2(0xAD,0xB9), o2(0xAD,0xBA), o2(0xAD,0xBB), o2(0xAD,0xBC),
- o2(0xAD,0xBD), o2(0xAD,0xBE), o2(0xFC,0xF1), o2(0xFC,0xF2),
- o2(0xFC,0xF3), o2(0xFC,0xF4), o2(0xFC,0xF5), o2(0xFC,0xF6),
- o2(0xFC,0xF7), o2(0xFC,0xF8), o2(0xFC,0xF9), o2(0xFC,0xFA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_85 = {
- to_SHIFT_JIS_E2_85_offsets,
- to_EUC_JP_E2_85_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_86_infos[5] = {
- o2(0xA2,0xAB), o2(0xA2,0xAC), o2(0xA2,0xAA), o2(0xA2,0xAD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_86 = {
- to_SHIFT_JIS_E2_86_offsets,
- to_EUC_JP_E2_86_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_87_infos[3] = {
- o2(0xA2,0xCD), o2(0xA2,0xCE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_87 = {
- to_SHIFT_JIS_E2_87_offsets,
- to_EUC_JP_E2_87_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_88_infos[24] = {
- o2(0xA2,0xCF), o2(0xA2,0xDF), o2(0xA2,0xD0), o2(0xA2,0xE0),
- o2(0xA2,0xBA), o2(0xA2,0xBB), o2(0xAD,0xF4), o2(0xA1,0xDD),
- o2(0xAD,0xF5), o2(0xA2,0xE7), o2(0xA1,0xE7), o2(0xAD,0xF8),
- o2(0xAD,0xF7), o2(0xA2,0xCA), o2(0xA2,0xCB), o2(0xAD,0xFB),
- o2(0xAD,0xFC), o2(0xAD,0xF2), o2(0xA2,0xEA), o2(0xAD,0xF3),
- o2(0xA1,0xE8), o2(0xAD,0xFA), o2(0xA2,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_88 = {
- to_SHIFT_JIS_E2_88_offsets,
- to_EUC_JP_E2_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_89_infos[8] = {
- o2(0xAD,0xF0), o2(0xA1,0xE2), o2(0xAD,0xF1), o2(0xA1,0xE5),
- o2(0xA1,0xE6), o2(0xA2,0xE3), o2(0xA2,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_89 = {
- to_SHIFT_JIS_E2_89_offsets,
- to_EUC_JP_E2_89_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_8A_infos[7] = {
- o2(0xA2,0xBE), o2(0xA2,0xBF), o2(0xA2,0xBC), o2(0xA2,0xBD),
- o2(0xAD,0xF6), o2(0xAD,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_8A = {
- to_SHIFT_JIS_E2_8A_offsets,
- to_EUC_JP_E2_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_8C_infos[2] = {
- o2(0xA2,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_8C = {
- to_SHIFT_JIS_E2_8C_offsets,
- to_EUC_JP_E2_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_91_infos[21] = {
- o2(0xAD,0xA1), o2(0xAD,0xA2), o2(0xAD,0xA3), o2(0xAD,0xA4),
- o2(0xAD,0xA5), o2(0xAD,0xA6), o2(0xAD,0xA7), o2(0xAD,0xA8),
- o2(0xAD,0xA9), o2(0xAD,0xAA), o2(0xAD,0xAB), o2(0xAD,0xAC),
- o2(0xAD,0xAD), o2(0xAD,0xAE), o2(0xAD,0xAF), o2(0xAD,0xB0),
- o2(0xAD,0xB1), o2(0xAD,0xB2), o2(0xAD,0xB3), o2(0xAD,0xB4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_91 = {
- to_SHIFT_JIS_E2_91_offsets,
- to_EUC_JP_E2_91_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_94_infos[31] = {
- o2(0xA8,0xA1), o2(0xA8,0xAC), o2(0xA8,0xA2), o2(0xA8,0xAD),
- o2(0xA8,0xA3), o2(0xA8,0xAE), o2(0xA8,0xA4), o2(0xA8,0xAF),
- o2(0xA8,0xA6), o2(0xA8,0xB1), o2(0xA8,0xA5), o2(0xA8,0xB0),
- o2(0xA8,0xA7), o2(0xA8,0xBC), o2(0xA8,0xB7), o2(0xA8,0xB2),
- o2(0xA8,0xA9), o2(0xA8,0xBE), o2(0xA8,0xB9), o2(0xA8,0xB4),
- o2(0xA8,0xA8), o2(0xA8,0xB8), o2(0xA8,0xBD), o2(0xA8,0xB3),
- o2(0xA8,0xAA), o2(0xA8,0xBA), o2(0xA8,0xBF), o2(0xA8,0xB5),
- o2(0xA8,0xAB), o2(0xA8,0xBB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_94 = {
- to_SHIFT_JIS_E2_94_offsets,
- to_EUC_JP_E2_94_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_95_infos[3] = {
- o2(0xA8,0xC0), o2(0xA8,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_95 = {
- to_SHIFT_JIS_E2_95_offsets,
- to_EUC_JP_E2_95_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_96_infos[7] = {
- o2(0xA2,0xA3), o2(0xA2,0xA2), o2(0xA2,0xA5), o2(0xA2,0xA4),
- o2(0xA2,0xA7), o2(0xA2,0xA6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_96 = {
- to_SHIFT_JIS_E2_96_offsets,
- to_EUC_JP_E2_96_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_97_infos[7] = {
- o2(0xA2,0xA1), o2(0xA1,0xFE), o2(0xA1,0xFB), o2(0xA1,0xFD),
- o2(0xA1,0xFC), o2(0xA2,0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_97 = {
- to_SHIFT_JIS_E2_97_offsets,
- to_EUC_JP_E2_97_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_98_infos[3] = {
- o2(0xA1,0xFA), o2(0xA1,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_98 = {
- to_SHIFT_JIS_E2_98_offsets,
- to_EUC_JP_E2_98_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_99_infos[6] = {
- o2(0xA1,0xEA), o2(0xA1,0xE9), o2(0xA2,0xF6), o2(0xA2,0xF5),
- o2(0xA2,0xF4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2_99 = {
- to_SHIFT_JIS_E2_99_offsets,
- to_EUC_JP_E2_99_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E2_infos[17] = {
- &to_EUC_JP_E2_80, &to_EUC_JP_E2_84, &to_EUC_JP_E2_85, &to_EUC_JP_E2_86,
- &to_EUC_JP_E2_87, &to_EUC_JP_E2_88, &to_EUC_JP_E2_89, &to_EUC_JP_E2_8A,
- &to_EUC_JP_E2_8C, &to_EUC_JP_E2_91, &to_EUC_JP_E2_94, &to_EUC_JP_E2_95,
- &to_EUC_JP_E2_96, &to_EUC_JP_E2_97, &to_EUC_JP_E2_98, &to_EUC_JP_E2_99,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E2 = {
- to_SHIFT_JIS_E2_offsets,
- to_EUC_JP_E2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_80_infos[25] = {
- o2(0xA1,0xA1), o2(0xA1,0xA2), o2(0xA1,0xA3), o2(0xA1,0xB7),
- o2(0xA1,0xB9), o2(0xA1,0xBA), o2(0xA1,0xBB), o2(0xA1,0xD2),
- o2(0xA1,0xD3), o2(0xA1,0xD4), o2(0xA1,0xD5), o2(0xA1,0xD6),
- o2(0xA1,0xD7), o2(0xA1,0xD8), o2(0xA1,0xD9), o2(0xA1,0xDA),
- o2(0xA1,0xDB), o2(0xA2,0xA9), o2(0xA2,0xAE), o2(0xA1,0xCC),
- o2(0xA1,0xCD), o2(0xA1,0xC1), o2(0xAD,0xE0), o2(0xAD,0xE1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_80 = {
- to_SHIFT_JIS_E3_80_offsets,
- to_EUC_JP_E3_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_81_infos[64] = {
- o2(0xA4,0xA1), o2(0xA4,0xA2), o2(0xA4,0xA3), o2(0xA4,0xA4),
- o2(0xA4,0xA5), o2(0xA4,0xA6), o2(0xA4,0xA7), o2(0xA4,0xA8),
- o2(0xA4,0xA9), o2(0xA4,0xAA), o2(0xA4,0xAB), o2(0xA4,0xAC),
- o2(0xA4,0xAD), o2(0xA4,0xAE), o2(0xA4,0xAF), o2(0xA4,0xB0),
- o2(0xA4,0xB1), o2(0xA4,0xB2), o2(0xA4,0xB3), o2(0xA4,0xB4),
- o2(0xA4,0xB5), o2(0xA4,0xB6), o2(0xA4,0xB7), o2(0xA4,0xB8),
- o2(0xA4,0xB9), o2(0xA4,0xBA), o2(0xA4,0xBB), o2(0xA4,0xBC),
- o2(0xA4,0xBD), o2(0xA4,0xBE), o2(0xA4,0xBF), o2(0xA4,0xC0),
- o2(0xA4,0xC1), o2(0xA4,0xC2), o2(0xA4,0xC3), o2(0xA4,0xC4),
- o2(0xA4,0xC5), o2(0xA4,0xC6), o2(0xA4,0xC7), o2(0xA4,0xC8),
- o2(0xA4,0xC9), o2(0xA4,0xCA), o2(0xA4,0xCB), o2(0xA4,0xCC),
- o2(0xA4,0xCD), o2(0xA4,0xCE), o2(0xA4,0xCF), o2(0xA4,0xD0),
- o2(0xA4,0xD1), o2(0xA4,0xD2), o2(0xA4,0xD3), o2(0xA4,0xD4),
- o2(0xA4,0xD5), o2(0xA4,0xD6), o2(0xA4,0xD7), o2(0xA4,0xD8),
- o2(0xA4,0xD9), o2(0xA4,0xDA), o2(0xA4,0xDB), o2(0xA4,0xDC),
- o2(0xA4,0xDD), o2(0xA4,0xDE), o2(0xA4,0xDF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_81 = {
- to_SHIFT_JIS_E3_81_offsets,
- to_EUC_JP_E3_81_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_82_infos[56] = {
- o2(0xA4,0xE0), o2(0xA4,0xE1), o2(0xA4,0xE2), o2(0xA4,0xE3),
- o2(0xA4,0xE4), o2(0xA4,0xE5), o2(0xA4,0xE6), o2(0xA4,0xE7),
- o2(0xA4,0xE8), o2(0xA4,0xE9), o2(0xA4,0xEA), o2(0xA4,0xEB),
- o2(0xA4,0xEC), o2(0xA4,0xED), o2(0xA4,0xEE), o2(0xA4,0xEF),
- o2(0xA4,0xF0), o2(0xA4,0xF1), o2(0xA4,0xF2), o2(0xA4,0xF3),
- o2(0xA1,0xAB), o2(0xA1,0xAC), o2(0xA1,0xB5), o2(0xA1,0xB6),
- o2(0xA5,0xA1), o2(0xA5,0xA2), o2(0xA5,0xA3), o2(0xA5,0xA4),
- o2(0xA5,0xA5), o2(0xA5,0xA6), o2(0xA5,0xA7), o2(0xA5,0xA8),
- o2(0xA5,0xA9), o2(0xA5,0xAA), o2(0xA5,0xAB), o2(0xA5,0xAC),
- o2(0xA5,0xAD), o2(0xA5,0xAE), o2(0xA5,0xAF), o2(0xA5,0xB0),
- o2(0xA5,0xB1), o2(0xA5,0xB2), o2(0xA5,0xB3), o2(0xA5,0xB4),
- o2(0xA5,0xB5), o2(0xA5,0xB6), o2(0xA5,0xB7), o2(0xA5,0xB8),
- o2(0xA5,0xB9), o2(0xA5,0xBA), o2(0xA5,0xBB), o2(0xA5,0xBC),
- o2(0xA5,0xBD), o2(0xA5,0xBE), o2(0xA5,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_82 = {
- to_SHIFT_JIS_E3_82_offsets,
- to_EUC_JP_E3_82_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_83_infos[60] = {
- o2(0xA5,0xC0), o2(0xA5,0xC1), o2(0xA5,0xC2), o2(0xA5,0xC3),
- o2(0xA5,0xC4), o2(0xA5,0xC5), o2(0xA5,0xC6), o2(0xA5,0xC7),
- o2(0xA5,0xC8), o2(0xA5,0xC9), o2(0xA5,0xCA), o2(0xA5,0xCB),
- o2(0xA5,0xCC), o2(0xA5,0xCD), o2(0xA5,0xCE), o2(0xA5,0xCF),
- o2(0xA5,0xD0), o2(0xA5,0xD1), o2(0xA5,0xD2), o2(0xA5,0xD3),
- o2(0xA5,0xD4), o2(0xA5,0xD5), o2(0xA5,0xD6), o2(0xA5,0xD7),
- o2(0xA5,0xD8), o2(0xA5,0xD9), o2(0xA5,0xDA), o2(0xA5,0xDB),
- o2(0xA5,0xDC), o2(0xA5,0xDD), o2(0xA5,0xDE), o2(0xA5,0xDF),
- o2(0xA5,0xE0), o2(0xA5,0xE1), o2(0xA5,0xE2), o2(0xA5,0xE3),
- o2(0xA5,0xE4), o2(0xA5,0xE5), o2(0xA5,0xE6), o2(0xA5,0xE7),
- o2(0xA5,0xE8), o2(0xA5,0xE9), o2(0xA5,0xEA), o2(0xA5,0xEB),
- o2(0xA5,0xEC), o2(0xA5,0xED), o2(0xA5,0xEE), o2(0xA5,0xEF),
- o2(0xA5,0xF0), o2(0xA5,0xF1), o2(0xA5,0xF2), o2(0xA5,0xF3),
- o2(0xA5,0xF4), o2(0xA5,0xF5), o2(0xA5,0xF6), o2(0xA1,0xA6),
- o2(0xA1,0xBC), o2(0xA1,0xB3), o2(0xA1,0xB4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_83 = {
- to_SHIFT_JIS_E3_83_offsets,
- to_EUC_JP_E3_83_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_88_infos[4] = {
- o2(0xAD,0xEA), o2(0xAD,0xEB), o2(0xAD,0xEC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_88 = {
- to_SHIFT_JIS_E3_88_offsets,
- to_EUC_JP_E3_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_8A_infos[6] = {
- o2(0xAD,0xE5), o2(0xAD,0xE6), o2(0xAD,0xE7), o2(0xAD,0xE8),
- o2(0xAD,0xE9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_8A = {
- to_SHIFT_JIS_E3_8A_offsets,
- to_EUC_JP_E3_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_8C_infos[12] = {
- o2(0xAD,0xC6), o2(0xAD,0xCA), o2(0xAD,0xC1), o2(0xAD,0xC4),
- o2(0xAD,0xC2), o2(0xAD,0xCC), o2(0xAD,0xCB), o2(0xAD,0xC5),
- o2(0xAD,0xCD), o2(0xAD,0xC7), o2(0xAD,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_8C = {
- to_SHIFT_JIS_E3_8C_offsets,
- to_EUC_JP_E3_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_8D_infos[10] = {
- o2(0xAD,0xC0), o2(0xAD,0xCE), o2(0xAD,0xC3), o2(0xAD,0xC8),
- o2(0xAD,0xC9), o2(0xAD,0xDF), o2(0xAD,0xEF), o2(0xAD,0xEE),
- o2(0xAD,0xED), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_8D = {
- to_SHIFT_JIS_E3_8D_offsets,
- to_EUC_JP_E3_8D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_8E_infos[7] = {
- o2(0xAD,0xD3), o2(0xAD,0xD4), o2(0xAD,0xD0), o2(0xAD,0xD1),
- o2(0xAD,0xD2), o2(0xAD,0xD6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_8E = {
- to_SHIFT_JIS_E3_8E_offsets,
- to_EUC_JP_E3_8E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_8F_infos[3] = {
- o2(0xAD,0xD5), o2(0xAD,0xE3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3_8F = {
- to_SHIFT_JIS_E3_8F_offsets,
- to_EUC_JP_E3_8F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E3_infos[11] = {
- &to_EUC_JP_E3_80, &to_EUC_JP_E3_81, &to_EUC_JP_E3_82, &to_EUC_JP_E3_83,
- &to_EUC_JP_E3_88, &to_EUC_JP_E3_8A, &to_EUC_JP_E3_8C, &to_EUC_JP_E3_8D,
- &to_EUC_JP_E3_8E, &to_EUC_JP_E3_8F, UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E3 = {
- to_SHIFT_JIS_E3_offsets,
- to_EUC_JP_E3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_B8_infos[33] = {
- o2(0xB0,0xEC), o2(0xC3,0xFA), o2(0xBC,0xB7), o2(0xCB,0xFC),
- o2(0xBE,0xE6), o2(0xBB,0xB0), o2(0xBE,0xE5), o2(0xB2,0xBC),
- o2(0xC9,0xD4), o2(0xCD,0xBF), o2(0xD0,0xA2), o2(0xB1,0xAF),
- o2(0xB3,0xEE), o2(0xD0,0xA3), o2(0xC0,0xA4), o2(0xD2,0xC2),
- o2(0xB5,0xD6), o2(0xCA,0xBA), o2(0xBE,0xE7), o2(0xCE,0xBE),
- o2(0xCA,0xC2), o2(0xF9,0xAD), o2(0xD0,0xA4), o2(0xC3,0xE6),
- o2(0xD0,0xA5), o2(0xB6,0xFA), o2(0xD0,0xA6), o2(0xB4,0xDD),
- o2(0xC3,0xB0), o2(0xBC,0xE7), o2(0xD0,0xA7), o2(0xD0,0xA8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_B8 = {
- to_SHIFT_JIS_E4_B8_offsets,
- to_EUC_JP_E4_B8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_B9_infos[20] = {
- o2(0xD0,0xA9), o2(0xC7,0xB5), o2(0xB5,0xD7), o2(0xC7,0xB7),
- o2(0xC6,0xE3), o2(0xB8,0xC3), o2(0xCB,0xB3), o2(0xE9,0xC9),
- o2(0xD0,0xAA), o2(0xBE,0xE8), o2(0xD0,0xAB), o2(0xB2,0xB5),
- o2(0xB6,0xE5), o2(0xB8,0xF0), o2(0xCC,0xE9), o2(0xD6,0xA6),
- o2(0xCD,0xF0), o2(0xC6,0xFD), o2(0xB4,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_B9 = {
- to_SHIFT_JIS_E4_B9_offsets,
- to_EUC_JP_E4_B9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_BA_infos[36] = {
- o2(0xB5,0xB5), o2(0xD0,0xAC), o2(0xD0,0xAD), o2(0xCE,0xBB),
- o2(0xCD,0xBD), o2(0xC1,0xE8), o2(0xD0,0xAF), o2(0xBB,0xF6),
- o2(0xC6,0xF3), o2(0xD0,0xB2), o2(0xB1,0xBE), o2(0xB8,0xDF),
- o2(0xB8,0xDE), o2(0xB0,0xE6), o2(0xCF,0xCB), o2(0xCF,0xCA),
- o2(0xBA,0xB3), o2(0xB0,0xA1), o2(0xD0,0xB3), o2(0xD0,0xB4),
- o2(0xD0,0xB5), o2(0xCB,0xB4), o2(0xD0,0xB6), o2(0xB8,0xF2),
- o2(0xB0,0xE7), o2(0xCB,0xF2), o2(0xB5,0xFC), o2(0xB5,0xFD),
- o2(0xB5,0xFE), o2(0xC4,0xE2), o2(0xCE,0xBC), o2(0xD0,0xB7),
- o2(0xD0,0xB8), o2(0xD0,0xB9), o2(0xBF,0xCD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_BA = {
- to_SHIFT_JIS_E4_BA_offsets,
- to_EUC_JP_E4_BA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_BB_infos[33] = {
- o2(0xBD,0xBA), o2(0xBF,0xCE), o2(0xD0,0xBE), o2(0xD0,0xBC),
- o2(0xD0,0xBD), o2(0xB5,0xD8), o2(0xBA,0xA3), o2(0xB2,0xF0),
- o2(0xD0,0xBB), o2(0xD0,0xBA), o2(0xCA,0xA9), o2(0xBB,0xC6),
- o2(0xBB,0xC5), o2(0xC2,0xBE), o2(0xD0,0xBF), o2(0xC9,0xD5),
- o2(0xC0,0xE7), o2(0xA1,0xB8), o2(0xD0,0xC0), o2(0xD0,0xC2),
- o2(0xF9,0xAE), o2(0xC2,0xE5), o2(0xCE,0xE1), o2(0xB0,0xCA),
- o2(0xD0,0xC1), o2(0xB2,0xBE), o2(0xB6,0xC4), o2(0xC3,0xE7),
- o2(0xB7,0xEF), o2(0xD0,0xC3), o2(0xC7,0xA4), o2(0xF9,0xAF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_BB = {
- to_SHIFT_JIS_E4_BB_offsets,
- to_EUC_JP_E4_BB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_BC_infos[23] = {
- o2(0xF9,0xB0), o2(0xB4,0xEB), o2(0xF9,0xB1), o2(0xD0,0xC4),
- o2(0xB0,0xCB), o2(0xB8,0xE0), o2(0xB4,0xEC), o2(0xC9,0xFA),
- o2(0xC8,0xB2), o2(0xB5,0xD9), o2(0xB2,0xF1), o2(0xD0,0xE7),
- o2(0xC5,0xC1), o2(0xC7,0xEC), o2(0xD0,0xC6), o2(0xC8,0xBC),
- o2(0xCE,0xE2), o2(0xBF,0xAD), o2(0xF9,0xB2), o2(0xBB,0xC7),
- o2(0xBB,0xF7), o2(0xB2,0xC0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_BC = {
- to_SHIFT_JIS_E4_BC_offsets,
- to_EUC_JP_E4_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_BD_infos[28] = {
- o2(0xC4,0xD1), o2(0xC3,0xA2), o2(0xD0,0xCA), o2(0xB0,0xCC),
- o2(0xC4,0xE3), o2(0xBD,0xBB), o2(0xBA,0xB4), o2(0xCD,0xA4),
- o2(0xC2,0xCE), o2(0xB2,0xBF), o2(0xF9,0xB3), o2(0xD0,0xC9),
- o2(0xCD,0xBE), o2(0xD0,0xC5), o2(0xD0,0xC7), o2(0xBA,0xEE),
- o2(0xD0,0xC8), o2(0xD5,0xA4), o2(0xD0,0xD0), o2(0xD0,0xD3),
- o2(0xD0,0xD1), o2(0xB2,0xC2), o2(0xCA,0xBB), o2(0xD0,0xCB),
- o2(0xD0,0xCF), o2(0xB8,0xF3), o2(0xBB,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_BD = {
- to_SHIFT_JIS_E4_BD_offsets,
- to_EUC_JP_E4_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_BE_infos[25] = {
- o2(0xB4,0xA6), o2(0xD0,0xD4), o2(0xD0,0xCC), o2(0xF9,0xB5),
- o2(0xCE,0xE3), o2(0xBB,0xF8), o2(0xD0,0xCD), o2(0xD0,0xD2),
- o2(0xF9,0xB4), o2(0xF9,0xB7), o2(0xD0,0xD5), o2(0xD0,0xCE),
- o2(0xF9,0xB6), o2(0xB6,0xA1), o2(0xB0,0xCD), o2(0xB6,0xA2),
- o2(0xB2,0xC1), o2(0xD5,0xA5), o2(0xCB,0xF9), o2(0xC9,0xEE),
- o2(0xB8,0xF4), o2(0xBF,0xAF), o2(0xCE,0xB7), o2(0xCA,0xD8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_BE = {
- to_SHIFT_JIS_E4_BE_offsets,
- to_EUC_JP_E4_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_BF_infos[30] = {
- o2(0xB7,0xB8), o2(0xC2,0xA5), o2(0xB2,0xE4), o2(0xF9,0xA6),
- o2(0xBD,0xD3), o2(0xF9,0xB8), o2(0xD0,0xD9), o2(0xD0,0xDE),
- o2(0xD0,0xDC), o2(0xD0,0xD7), o2(0xC2,0xAF), o2(0xD0,0xDA),
- o2(0xD0,0xDD), o2(0xD0,0xDB), o2(0xCA,0xDD), o2(0xD0,0xD8),
- o2(0xBF,0xAE), o2(0xCB,0xF3), o2(0xD0,0xDF), o2(0xD0,0xE0),
- o2(0xBD,0xA4), o2(0xD0,0xED), o2(0xC7,0xD0), o2(0xC9,0xB6),
- o2(0xD0,0xE8), o2(0xCA,0xF0), o2(0xB2,0xB6), o2(0xD0,0xEC),
- o2(0xF9,0xBB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4_BF = {
- to_SHIFT_JIS_E4_BF_offsets,
- to_EUC_JP_E4_BF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E4_infos[9] = {
- &to_EUC_JP_E4_B8, &to_EUC_JP_E4_B9, &to_EUC_JP_E4_BA, &to_EUC_JP_E4_BB,
- &to_EUC_JP_E4_BC, &to_EUC_JP_E4_BD, &to_EUC_JP_E4_BE, &to_EUC_JP_E4_BF,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E4 = {
- to_SHIFT_JIS_E4_offsets,
- to_EUC_JP_E4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_80_infos[29] = {
- o2(0xD0,0xE6), o2(0xD0,0xEF), o2(0xC1,0xD2), o2(0xB8,0xC4),
- o2(0xC7,0xDC), o2(0xE0,0xC7), o2(0xD0,0xEE), o2(0xC5,0xDD),
- o2(0xD0,0xE3), o2(0xB8,0xF6), o2(0xB8,0xF5), o2(0xD0,0xE1),
- o2(0xF9,0xBC), o2(0xBC,0xDA), o2(0xD0,0xE9), o2(0xF9,0xBA),
- o2(0xCA,0xEF), o2(0xC3,0xCD), o2(0xD0,0xE5), o2(0xB7,0xF1),
- o2(0xD0,0xE2), o2(0xD0,0xEA), o2(0xD0,0xE4), o2(0xCE,0xD1),
- o2(0xD0,0xEB), o2(0xCF,0xC1), o2(0xB6,0xE6), o2(0xB7,0xF0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_80 = {
- to_SHIFT_JIS_E5_80_offsets,
- to_EUC_JP_E5_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_81_infos[23] = {
- o2(0xF9,0xB9), o2(0xF9,0xBF), o2(0xD0,0xF0), o2(0xF9,0xBD),
- o2(0xD0,0xF1), o2(0xD0,0xF5), o2(0xB0,0xCE), o2(0xCA,0xD0),
- o2(0xD0,0xF4), o2(0xD0,0xF3), o2(0xD0,0xF7), o2(0xD0,0xF6),
- o2(0xC4,0xE4), o2(0xB7,0xF2), o2(0xD0,0xF8), o2(0xF9,0xBE),
- o2(0xBC,0xC5), o2(0xC2,0xA6), o2(0xC4,0xE5), o2(0xB6,0xF6),
- o2(0xD0,0xF9), o2(0xB5,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_81 = {
- to_SHIFT_JIS_E5_81_offsets,
- to_EUC_JP_E5_81_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_82_infos[17] = {
- o2(0xD0,0xFA), o2(0xD0,0xFC), o2(0xCB,0xB5), o2(0xB7,0xE6),
- o2(0xF9,0xC0), o2(0xBB,0xB1), o2(0xC8,0xF7), o2(0xD0,0xFB),
- o2(0xBA,0xC5), o2(0xCD,0xC3), o2(0xD0,0xFE), o2(0xD1,0xA3),
- o2(0xD0,0xFD), o2(0xBA,0xC4), o2(0xBD,0xFD), o2(0xB7,0xB9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_82 = {
- to_SHIFT_JIS_E5_82_offsets,
- to_EUC_JP_E5_82_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_83_infos[22] = {
- o2(0xD1,0xA4), o2(0xB6,0xCF), o2(0xD1,0xA1), o2(0xD1,0xA2),
- o2(0xC6,0xAF), o2(0xC1,0xFC), o2(0xB6,0xA3), o2(0xCB,0xCD),
- o2(0xD1,0xA5), o2(0xF9,0xC2), o2(0xCE,0xBD), o2(0xD1,0xA6),
- o2(0xD1,0xA9), o2(0xD1,0xA7), o2(0xC1,0xCE), o2(0xD1,0xA8),
- o2(0xD1,0xAA), o2(0xF9,0xC1), o2(0xD1,0xAC), o2(0xD1,0xAB),
- o2(0xCA,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_83 = {
- to_SHIFT_JIS_E5_83_offsets,
- to_EUC_JP_E5_83_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_84_infos[21] = {
- o2(0xB5,0xB7), o2(0xD1,0xAE), o2(0xD1,0xAF), o2(0xB2,0xAF),
- o2(0xD1,0xAD), o2(0xBC,0xF4), o2(0xD1,0xB2), o2(0xD1,0xB1),
- o2(0xD1,0xB0), o2(0xD0,0xD6), o2(0xD1,0xB3), o2(0xBD,0xFE),
- o2(0xD1,0xB4), o2(0xCD,0xA5), o2(0xCC,0xD9), o2(0xD1,0xB6),
- o2(0xD1,0xB5), o2(0xD1,0xB8), o2(0xD1,0xB7), o2(0xD1,0xB9),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_84 = {
- to_SHIFT_JIS_E5_84_offsets,
- to_EUC_JP_E5_84_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_85_infos[36] = {
- o2(0xD1,0xBA), o2(0xB0,0xF4), o2(0xB8,0xB5), o2(0xB7,0xBB),
- o2(0xBD,0xBC), o2(0xC3,0xFB), o2(0xB6,0xA4), o2(0xC0,0xE8),
- o2(0xB8,0xF7), o2(0xF9,0xC3), o2(0xB9,0xEE), o2(0xD1,0xBC),
- o2(0xCC,0xC8), o2(0xC5,0xC6), o2(0xBB,0xF9), o2(0xD1,0xBB),
- o2(0xD1,0xBD), o2(0xC5,0xDE), o2(0xB3,0xF5), o2(0xD1,0xBE),
- o2(0xF9,0xC4), o2(0xC6,0xFE), o2(0xC1,0xB4), o2(0xD1,0xC0),
- o2(0xD1,0xC1), o2(0xC8,0xAC), o2(0xB8,0xF8), o2(0xCF,0xBB),
- o2(0xD1,0xC2), o2(0xB6,0xA6), o2(0xCA,0xBC), o2(0xC2,0xB6),
- o2(0xB6,0xF1), o2(0xC5,0xB5), o2(0xB7,0xF3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_85 = {
- to_SHIFT_JIS_E5_85_offsets,
- to_EUC_JP_E5_85_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_86_infos[39] = {
- o2(0xD1,0xC3), o2(0xD1,0xC4), o2(0xC6,0xE2), o2(0xB1,0xDF),
- o2(0xD1,0xC7), o2(0xBA,0xFD), o2(0xD1,0xC6), o2(0xBA,0xC6),
- o2(0xD1,0xC8), o2(0xE6,0xEE), o2(0xD1,0xC9), o2(0xCB,0xC1),
- o2(0xD1,0xCA), o2(0xD1,0xCB), o2(0xD1,0xCC), o2(0xBE,0xE9),
- o2(0xBC,0xCC), o2(0xF9,0xC5), o2(0xB4,0xA7), o2(0xD1,0xCF),
- o2(0xD1,0xCD), o2(0xCC,0xBD), o2(0xD1,0xCE), o2(0xC9,0xDA),
- o2(0xD1,0xD0), o2(0xD1,0xD1), o2(0xD1,0xD2), o2(0xC5,0xDF),
- o2(0xD1,0xD6), o2(0xD1,0xD4), o2(0xD1,0xD5), o2(0xD1,0xD3),
- o2(0xBA,0xE3), o2(0xD1,0xD7), o2(0xCC,0xEA), o2(0xCE,0xE4),
- o2(0xD1,0xD8), o2(0xF9,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_86 = {
- to_SHIFT_JIS_E5_86_offsets,
- to_EUC_JP_E5_86_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_87_infos[29] = {
- o2(0xC0,0xA8), o2(0xD1,0xD9), o2(0xBD,0xDA), o2(0xD1,0xDA),
- o2(0xC3,0xFC), o2(0xCE,0xBF), o2(0xC5,0xE0), o2(0xD2,0xC5),
- o2(0xD1,0xDB), o2(0xF4,0xA5), o2(0xB6,0xC5), o2(0xD1,0xDC),
- o2(0xCB,0xDE), o2(0xBD,0xE8), o2(0xC2,0xFC), o2(0xD1,0xDE),
- o2(0xC6,0xE4), o2(0xF9,0xC7), o2(0xD1,0xDF), o2(0xD1,0xE0),
- o2(0xB3,0xAE), o2(0xD1,0xE1), o2(0xB6,0xA7), o2(0xC6,0xCC),
- o2(0xB1,0xFA), o2(0xBD,0xD0), o2(0xC8,0xA1), o2(0xD1,0xE2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_87 = {
- to_SHIFT_JIS_E5_87_offsets,
- to_EUC_JP_E5_87_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_88_infos[29] = {
- o2(0xC5,0xE1), o2(0xBF,0xCF), o2(0xD1,0xE3), o2(0xCA,0xAC),
- o2(0xC0,0xDA), o2(0xB4,0xA2), o2(0xB4,0xA9), o2(0xD1,0xE4),
- o2(0xD1,0xE6), o2(0xB7,0xBA), o2(0xD1,0xE5), o2(0xF9,0xC8),
- o2(0xCE,0xF3), o2(0xBD,0xE9), o2(0xC8,0xBD), o2(0xCA,0xCC),
- o2(0xD1,0xE7), o2(0xCD,0xF8), o2(0xD1,0xE8), o2(0xD1,0xE9),
- o2(0xC5,0xFE), o2(0xD1,0xEA), o2(0xC0,0xA9), o2(0xBA,0xFE),
- o2(0xB7,0xF4), o2(0xD1,0xEB), o2(0xBB,0xC9), o2(0xB9,0xEF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_88 = {
- to_SHIFT_JIS_E5_88_offsets,
- to_EUC_JP_E5_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_89_infos[27] = {
- o2(0xC4,0xE6), o2(0xD1,0xED), o2(0xC2,0xA7), o2(0xBA,0xEF),
- o2(0xD1,0xEE), o2(0xD1,0xEF), o2(0xC1,0xB0), o2(0xD1,0xEC),
- o2(0xD1,0xF1), o2(0xCB,0xB6), o2(0xB9,0xE4), o2(0xD1,0xF0),
- o2(0xB7,0xF5), o2(0xBA,0xDE), o2(0xC7,0xED), o2(0xD1,0xF4),
- o2(0xD1,0xF2), o2(0xC9,0xFB), o2(0xBE,0xEA), o2(0xD1,0xFB),
- o2(0xB3,0xE4), o2(0xD1,0xF5), o2(0xD1,0xF3), o2(0xC1,0xCF),
- o2(0xD1,0xF7), o2(0xD1,0xF6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_89 = {
- to_SHIFT_JIS_E5_89_offsets,
- to_EUC_JP_E5_89_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_8A_infos[27] = {
- o2(0xB3,0xC4), o2(0xB7,0xE0), o2(0xD1,0xFC), o2(0xCE,0xAD),
- o2(0xD1,0xF8), o2(0xD1,0xFD), o2(0xD1,0xFA), o2(0xD1,0xF9),
- o2(0xCE,0xCF), o2(0xF9,0xC9), o2(0xB8,0xF9), o2(0xB2,0xC3),
- o2(0xCE,0xF4), o2(0xF9,0xCA), o2(0xBD,0xF5), o2(0xC5,0xD8),
- o2(0xB9,0xE5), o2(0xD2,0xA2), o2(0xD2,0xA3), o2(0xFB,0xBC),
- o2(0xCE,0xE5), o2(0xCF,0xAB), o2(0xD2,0xA5), o2(0xB8,0xFA),
- o2(0xD2,0xA4), o2(0xB3,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_8A = {
- to_SHIFT_JIS_E5_8A_offsets,
- to_EUC_JP_E5_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_8B_infos[31] = {
- o2(0xF9,0xCB), o2(0xD2,0xA6), o2(0xCB,0xD6), o2(0xC4,0xBC),
- o2(0xCD,0xA6), o2(0xCA,0xD9), o2(0xD2,0xA7), o2(0xF0,0xD5),
- o2(0xC6,0xB0), o2(0xD2,0xA8), o2(0xB4,0xAA), o2(0xCC,0xB3),
- o2(0xF9,0xCC), o2(0xBE,0xA1), o2(0xD2,0xA9), o2(0xCA,0xE7),
- o2(0xD2,0xAD), o2(0xC0,0xAA), o2(0xD2,0xAA), o2(0xB6,0xD0),
- o2(0xD2,0xAB), o2(0xB4,0xAB), o2(0xB7,0xAE), o2(0xD2,0xAE),
- o2(0xD2,0xAF), o2(0xD2,0xB0), o2(0xD2,0xB1), o2(0xBC,0xDB),
- o2(0xB8,0xFB), o2(0xCC,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_8B = {
- to_SHIFT_JIS_E5_8B_offsets,
- to_EUC_JP_E5_8B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_8C_infos[30] = {
- o2(0xF9,0xCD), o2(0xCC,0xE8), o2(0xC6,0xF7), o2(0xCA,0xF1),
- o2(0xD2,0xB2), o2(0xF9,0xCE), o2(0xD2,0xB3), o2(0xD2,0xB5),
- o2(0xD2,0xB7), o2(0xD2,0xB6), o2(0xD2,0xB8), o2(0xB2,0xBD),
- o2(0xCB,0xCC), o2(0xBA,0xFC), o2(0xD2,0xB9), o2(0xC1,0xD9),
- o2(0xBE,0xA2), o2(0xB6,0xA9), o2(0xD2,0xBA), o2(0xF9,0xCF),
- o2(0xC8,0xDB), o2(0xD2,0xBB), o2(0xD2,0xBC), o2(0xD2,0xBD),
- o2(0xD2,0xBE), o2(0xC9,0xA4), o2(0xB6,0xE8), o2(0xB0,0xE5),
- o2(0xC6,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_8C = {
- to_SHIFT_JIS_E5_8C_offsets,
- to_EUC_JP_E5_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_8D_infos[35] = {
- o2(0xD2,0xBF), o2(0xBD,0xBD), o2(0xC0,0xE9), o2(0xD2,0xC1),
- o2(0xD2,0xC0), o2(0xBE,0xA3), o2(0xB8,0xE1), o2(0xD2,0xC3),
- o2(0xC8,0xBE), o2(0xD2,0xC4), o2(0xC8,0xDC), o2(0xC2,0xB4),
- o2(0xC2,0xEE), o2(0xB6,0xA8), o2(0xC6,0xEE), o2(0xC3,0xB1),
- o2(0xC7,0xEE), o2(0xCB,0xCE), o2(0xD2,0xC6), o2(0xC0,0xEA),
- o2(0xB7,0xB5), o2(0xD2,0xC7), o2(0xD2,0xC8), o2(0xB1,0xAC),
- o2(0xB0,0xF5), o2(0xB4,0xED), o2(0xF9,0xD0), o2(0xC2,0xA8),
- o2(0xB5,0xD1), o2(0xCD,0xF1), o2(0xD2,0xCB), o2(0xB2,0xB7),
- o2(0xD2,0xCA), o2(0xB6,0xAA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_8D = {
- to_SHIFT_JIS_E5_8D_offsets,
- to_EUC_JP_E5_8D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_8E_infos[20] = {
- o2(0xD2,0xCC), o2(0xCC,0xF1), o2(0xF9,0xD1), o2(0xD2,0xCD),
- o2(0xCE,0xD2), o2(0xB8,0xFC), o2(0xB8,0xB6), o2(0xD2,0xCE),
- o2(0xD2,0xD0), o2(0xD2,0xCF), o2(0xBF,0xDF), o2(0xB1,0xB9),
- o2(0xB1,0xDE), o2(0xD2,0xD1), o2(0xD2,0xD2), o2(0xF9,0xD2),
- o2(0xB8,0xB7), o2(0xD2,0xD3), o2(0xB5,0xEE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_8E = {
- to_SHIFT_JIS_E5_8E_offsets,
- to_EUC_JP_E5_8E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_8F_infos[38] = {
- o2(0xBB,0xB2), o2(0xD2,0xD4), o2(0xCB,0xF4), o2(0xBA,0xB5),
- o2(0xB5,0xDA), o2(0xCD,0xA7), o2(0xC1,0xD0), o2(0xC8,0xBF),
- o2(0xBC,0xFD), o2(0xBD,0xC7), o2(0xBC,0xE8), o2(0xBC,0xF5),
- o2(0xBD,0xF6), o2(0xC8,0xC0), o2(0xF9,0xD3), o2(0xD2,0xD7),
- o2(0xB1,0xC3), o2(0xC1,0xD1), o2(0xB8,0xFD), o2(0xB8,0xC5),
- o2(0xB6,0xE7), o2(0xD2,0xDB), o2(0xC3,0xA1), o2(0xC2,0xFE),
- o2(0xB6,0xAB), o2(0xBE,0xA4), o2(0xD2,0xDC), o2(0xD2,0xDA),
- o2(0xB2,0xC4), o2(0xC2,0xE6), o2(0xBC,0xB8), o2(0xBB,0xCB),
- o2(0xB1,0xA6), o2(0xB3,0xF0), o2(0xB9,0xE6), o2(0xBB,0xCA),
- o2(0xD2,0xDD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_8F = {
- to_SHIFT_JIS_E5_8F_offsets,
- to_EUC_JP_E5_8F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_90_infos[31] = {
- o2(0xD2,0xDE), o2(0xB5,0xC9), o2(0xB3,0xC6), o2(0xB9,0xE7),
- o2(0xB5,0xC8), o2(0xC4,0xDF), o2(0xB1,0xA5), o2(0xC6,0xB1),
- o2(0xCC,0xBE), o2(0xB9,0xA1), o2(0xCD,0xF9), o2(0xC5,0xC7),
- o2(0xB8,0xFE), o2(0xB7,0xAF), o2(0xD2,0xE7), o2(0xB6,0xE3),
- o2(0xCB,0xCA), o2(0xC8,0xDD), o2(0xD2,0xE6), o2(0xB4,0xDE),
- o2(0xD2,0xE1), o2(0xD2,0xE2), o2(0xD2,0xE4), o2(0xD2,0xE5),
- o2(0xB5,0xDB), o2(0xBF,0xE1), o2(0xCA,0xAD), o2(0xD2,0xE3),
- o2(0xD2,0xDF), o2(0xB8,0xE3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_90 = {
- to_SHIFT_JIS_E5_90_offsets,
- to_EUC_JP_E5_90_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_91_infos[21] = {
- o2(0xD2,0xE0), o2(0xCF,0xA4), o2(0xCA,0xF2), o2(0xC4,0xE8),
- o2(0xB8,0xE2), o2(0xB9,0xF0), o2(0xD2,0xE8), o2(0xC6,0xDD),
- o2(0xD2,0xEC), o2(0xBC,0xFE), o2(0xBC,0xF6), o2(0xD2,0xEF),
- o2(0xD2,0xED), o2(0xCC,0xA3), o2(0xD2,0xEA), o2(0xD2,0xF3),
- o2(0xD2,0xEE), o2(0xD2,0xF1), o2(0xB8,0xC6), o2(0xCC,0xBF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_91 = {
- to_SHIFT_JIS_E5_91_offsets,
- to_EUC_JP_E5_91_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_92_infos[26] = {
- o2(0xD2,0xF2), o2(0xD2,0xF4), o2(0xD2,0xF6), o2(0xF9,0xD6),
- o2(0xBA,0xF0), o2(0xCF,0xC2), o2(0xD2,0xEB), o2(0xD2,0xE9),
- o2(0xD2,0xF5), o2(0xD2,0xF0), o2(0xF9,0xD5), o2(0xD2,0xF8),
- o2(0xD3,0xA3), o2(0xD2,0xFA), o2(0xD2,0xFE), o2(0xF9,0xD7),
- o2(0xD3,0xA1), o2(0xD2,0xFB), o2(0xD3,0xBE), o2(0xBA,0xE9),
- o2(0xB3,0xB1), o2(0xD2,0xF9), o2(0xD3,0xA5), o2(0xB0,0xF6),
- o2(0xD3,0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_92 = {
- to_SHIFT_JIS_E5_92_offsets,
- to_EUC_JP_E5_92_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_93_infos[21] = {
- o2(0xB0,0xA5), o2(0xC9,0xCA), o2(0xD3,0xA2), o2(0xD2,0xFC),
- o2(0xD2,0xF7), o2(0xD2,0xFD), o2(0xBA,0xC8), o2(0xD3,0xA6),
- o2(0xB0,0xF7), o2(0xD3,0xAF), o2(0xD3,0xA7), o2(0xD3,0xA8),
- o2(0xBE,0xA5), o2(0xCB,0xE9), o2(0xD3,0xAD), o2(0xD3,0xAC),
- o2(0xC5,0xAF), o2(0xD3,0xAE), o2(0xD3,0xAB), o2(0xF9,0xD8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_93 = {
- to_SHIFT_JIS_E5_93_offsets,
- to_EUC_JP_E5_93_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_94_infos[15] = {
- o2(0xB1,0xB4), o2(0xBA,0xB6), o2(0xBF,0xB0), o2(0xD3,0xA9),
- o2(0xC5,0xE2), o2(0xD3,0xAA), o2(0xB0,0xA2), o2(0xD3,0xB4),
- o2(0xCD,0xA3), o2(0xBE,0xA7), o2(0xD3,0xBA), o2(0xD3,0xB9),
- o2(0xD3,0xB0), o2(0xC2,0xC3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_94 = {
- to_SHIFT_JIS_E5_94_offsets,
- to_EUC_JP_E5_94_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_95_infos[16] = {
- o2(0xD3,0xB1), o2(0xC2,0xEF), o2(0xD3,0xB6), o2(0xBE,0xA6),
- o2(0xD3,0xB3), o2(0xCC,0xE4), o2(0xB7,0xBC), o2(0xD3,0xB7),
- o2(0xD3,0xB8), o2(0xD3,0xB5), o2(0xD3,0xBB), o2(0xD3,0xB2),
- o2(0xD3,0xC1), o2(0xD3,0xC6), o2(0xD3,0xC2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_95 = {
- to_SHIFT_JIS_E5_95_offsets,
- to_EUC_JP_E5_95_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_96_infos[25] = {
- o2(0xD3,0xBD), o2(0xD3,0xC7), o2(0xC1,0xB1), o2(0xF9,0xD9),
- o2(0xD3,0xC9), o2(0xB9,0xA2), o2(0xD3,0xBF), o2(0xC3,0xFD),
- o2(0xD3,0xC3), o2(0xD3,0xBC), o2(0xB4,0xAD), o2(0xB4,0xEE),
- o2(0xB3,0xE5), o2(0xD3,0xC4), o2(0xD3,0xC0), o2(0xB7,0xF6),
- o2(0xD3,0xCA), o2(0xD3,0xC8), o2(0xC1,0xD3), o2(0xB5,0xCA),
- o2(0xB6,0xAC), o2(0xD3,0xC5), o2(0xB6,0xF4), o2(0xB1,0xC4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_96 = {
- to_SHIFT_JIS_E5_96_offsets,
- to_EUC_JP_E5_96_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_97_infos[14] = {
- o2(0xD3,0xCE), o2(0xD3,0xCC), o2(0xD4,0xA7), o2(0xD3,0xD1),
- o2(0xD3,0xCB), o2(0xD3,0xCF), o2(0xD3,0xCD), o2(0xBB,0xCC),
- o2(0xD3,0xD0), o2(0xD3,0xD3), o2(0xD3,0xD8), o2(0xD3,0xD6),
- o2(0xD3,0xD5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_97 = {
- to_SHIFT_JIS_E5_97_offsets,
- to_EUC_JP_E5_97_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_98_infos[15] = {
- o2(0xC3,0xB2), o2(0xB2,0xC5), o2(0xD3,0xD2), o2(0xD3,0xD4),
- o2(0xBE,0xA8), o2(0xB1,0xB3), o2(0xD3,0xD7), o2(0xB2,0xDE),
- o2(0xD3,0xE2), o2(0xBE,0xFC), o2(0xD3,0xDE), o2(0xD3,0xDC),
- o2(0xD3,0xDD), o2(0xD3,0xDF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_98 = {
- to_SHIFT_JIS_E5_98_offsets,
- to_EUC_JP_E5_98_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_99_infos[14] = {
- o2(0xB1,0xBD), o2(0xC1,0xB9), o2(0xD3,0xD9), o2(0xD3,0xDA),
- o2(0xB3,0xFA), o2(0xD3,0xE1), o2(0xB4,0xEF), o2(0xD3,0xE4),
- o2(0xD3,0xE0), o2(0xD3,0xE3), o2(0xCA,0xAE), o2(0xC6,0xD5),
- o2(0xC8,0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_99 = {
- to_SHIFT_JIS_E5_99_offsets,
- to_EUC_JP_E5_99_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_9A_infos[14] = {
- o2(0xD3,0xE6), o2(0xD3,0xE5), o2(0xB3,0xC5), o2(0xD3,0xE7),
- o2(0xD3,0xEA), o2(0xD3,0xE9), o2(0xD3,0xE8), o2(0xC7,0xB9),
- o2(0xD3,0xEB), o2(0xD3,0xEC), o2(0xD3,0xEE), o2(0xD3,0xED),
- o2(0xD3,0xF0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_9A = {
- to_SHIFT_JIS_E5_9A_offsets,
- to_EUC_JP_E5_9A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_9B_infos[24] = {
- o2(0xD3,0xF3), o2(0xD3,0xF1), o2(0xD3,0xEF), o2(0xD3,0xF2),
- o2(0xD3,0xF4), o2(0xD3,0xF5), o2(0xD3,0xF6), o2(0xD3,0xF7),
- o2(0xD3,0xF8), o2(0xD1,0xC5), o2(0xBC,0xFC), o2(0xBB,0xCD),
- o2(0xB2,0xF3), o2(0xB0,0xF8), o2(0xC3,0xC4), o2(0xD3,0xF9),
- o2(0xBA,0xA4), o2(0xB0,0xCF), o2(0xBF,0xDE), o2(0xD3,0xFA),
- o2(0xB8,0xC7), o2(0xB9,0xF1), o2(0xD3,0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_9B = {
- to_SHIFT_JIS_E5_9B_offsets,
- to_EUC_JP_E5_9B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_9C_infos[23] = {
- o2(0xD3,0xFB), o2(0xCA,0xE0), o2(0xD3,0xFD), o2(0xD4,0xA1),
- o2(0xD3,0xFE), o2(0xD4,0xA2), o2(0xD4,0xA3), o2(0xB7,0xF7),
- o2(0xB1,0xE0), o2(0xD4,0xA4), o2(0xD4,0xA6), o2(0xD4,0xA5),
- o2(0xD4,0xA8), o2(0xC5,0xDA), o2(0xD4,0xA9), o2(0xB0,0xB5),
- o2(0xBA,0xDF), o2(0xB7,0xBD), o2(0xC3,0xCF), o2(0xD4,0xAA),
- o2(0xD4,0xAB), o2(0xD4,0xAD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_9C = {
- to_SHIFT_JIS_E5_9C_offsets,
- to_EUC_JP_E5_9C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_9D_infos[17] = {
- o2(0xD4,0xAE), o2(0xBA,0xE4), o2(0xB6,0xD1), o2(0xCB,0xB7),
- o2(0xD4,0xAC), o2(0xD4,0xAF), o2(0xBA,0xC1), o2(0xB9,0xA3),
- o2(0xF9,0xDA), o2(0xD4,0xB3), o2(0xBA,0xA5), o2(0xF9,0xDB),
- o2(0xC3,0xB3), o2(0xD4,0xB0), o2(0xC4,0xDA), o2(0xD4,0xB4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_9D = {
- to_SHIFT_JIS_E5_9D_offsets,
- to_EUC_JP_E5_9D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_9E_infos[14] = {
- o2(0xBF,0xE2), o2(0xD4,0xB2), o2(0xD4,0xB5), o2(0xB7,0xBF),
- o2(0xD4,0xB6), o2(0xD4,0xB7), o2(0xB9,0xA4), o2(0xB3,0xC0),
- o2(0xD4,0xB9), o2(0xD4,0xBA), o2(0xF9,0xDC), o2(0xD4,0xBB),
- o2(0xD4,0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_9E = {
- to_SHIFT_JIS_E5_9E_offsets,
- to_EUC_JP_E5_9E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_9F_infos[21] = {
- o2(0xD4,0xB1), o2(0xD4,0xBC), o2(0xD4,0xBD), o2(0xF9,0xDE),
- o2(0xF9,0xDD), o2(0xCB,0xE4), o2(0xBE,0xEB), o2(0xD4,0xBF),
- o2(0xD4,0xC0), o2(0xD4,0xBE), o2(0xD4,0xC2), o2(0xC7,0xB8),
- o2(0xB0,0xE8), o2(0xC9,0xD6), o2(0xD4,0xC3), o2(0xBE,0xFD),
- o2(0xBC,0xB9), o2(0xC7,0xDD), o2(0xB4,0xF0), o2(0xBA,0xEB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_9F = {
- to_SHIFT_JIS_E5_9F_offsets,
- to_EUC_JP_E5_9F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A0_infos[20] = {
- o2(0xCB,0xD9), o2(0xC6,0xB2), o2(0xB7,0xF8), o2(0xC2,0xCF),
- o2(0xD4,0xC1), o2(0xD4,0xC4), o2(0xC2,0xC4), o2(0xD4,0xC5),
- o2(0xD4,0xC6), o2(0xD4,0xC8), o2(0xC4,0xE9), o2(0xB4,0xAE),
- o2(0xF4,0xA1), o2(0xB1,0xE1), o2(0xCA,0xF3), o2(0xBE,0xEC),
- o2(0xC5,0xC8), o2(0xBA,0xE6), o2(0xD4,0xCE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A0 = {
- to_SHIFT_JIS_E5_A0_offsets,
- to_EUC_JP_E5_A0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A1_infos[21] = {
- o2(0xCA,0xBD), o2(0xCE,0xDD), o2(0xB2,0xF4), o2(0xD4,0xCA),
- o2(0xC1,0xBA), o2(0xD4,0xCD), o2(0xC5,0xE3), o2(0xC5,0xC9),
- o2(0xC5,0xE4), o2(0xC8,0xB9), o2(0xC4,0xCD), o2(0xBA,0xC9),
- o2(0xD4,0xC9), o2(0xB1,0xF6), o2(0xC5,0xB6), o2(0xD4,0xCB),
- o2(0xD4,0xC7), o2(0xBF,0xD0), o2(0xD4,0xCF), o2(0xBD,0xCE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A1 = {
- to_SHIFT_JIS_E5_A1_offsets,
- to_EUC_JP_E5_A1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A2_infos[18] = {
- o2(0xB6,0xAD), o2(0xD4,0xD0), o2(0xCA,0xE8), o2(0xC1,0xFD),
- o2(0xC4,0xC6), o2(0xF9,0xE1), o2(0xD4,0xD2), o2(0xCB,0xCF),
- o2(0xD4,0xD3), o2(0xD4,0xD8), o2(0xF9,0xE2), o2(0xCA,0xAF),
- o2(0xD4,0xD7), o2(0xD4,0xD1), o2(0xD4,0xD4), o2(0xD4,0xD6),
- o2(0xBA,0xA6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A2 = {
- to_SHIFT_JIS_E5_A2_offsets,
- to_EUC_JP_E5_A2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A3_infos[30] = {
- o2(0xCA,0xC9), o2(0xD4,0xD9), o2(0xC3,0xC5), o2(0xB2,0xF5),
- o2(0xBE,0xED), o2(0xD4,0xDB), o2(0xD4,0xDA), o2(0xB9,0xE8),
- o2(0xD4,0xDC), o2(0xD4,0xDE), o2(0xD4,0xDD), o2(0xD4,0xE0),
- o2(0xD4,0xD5), o2(0xD4,0xE2), o2(0xD4,0xE1), o2(0xD4,0xDF),
- o2(0xBB,0xCE), o2(0xBF,0xD1), o2(0xC1,0xD4), o2(0xD4,0xE3),
- o2(0xC0,0xBC), o2(0xB0,0xED), o2(0xC7,0xE4), o2(0xC4,0xDB),
- o2(0xD4,0xE5), o2(0xD4,0xE4), o2(0xD4,0xE6), o2(0xD4,0xE7),
- o2(0xD4,0xE8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A3 = {
- to_SHIFT_JIS_E5_A3_offsets,
- to_EUC_JP_E5_A3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A4_infos[28] = {
- o2(0xD4,0xE9), o2(0xCA,0xD1), o2(0xD4,0xEA), o2(0xF9,0xE3),
- o2(0xB2,0xC6), o2(0xD4,0xEB), o2(0xCD,0xBC), o2(0xB3,0xB0),
- o2(0xD2,0xC9), o2(0xBD,0xC8), o2(0xC2,0xBF), o2(0xD4,0xEC),
- o2(0xCC,0xEB), o2(0xCC,0xB4), o2(0xD4,0xEE), o2(0xC2,0xE7),
- o2(0xC5,0xB7), o2(0xC2,0xC0), o2(0xC9,0xD7), o2(0xD4,0xEF),
- o2(0xD4,0xF0), o2(0xB1,0xFB), o2(0xBC,0xBA), o2(0xD4,0xF1),
- o2(0xB0,0xD0), o2(0xD4,0xF2), o2(0xD4,0xF3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A4 = {
- to_SHIFT_JIS_E5_A4_offsets,
- to_EUC_JP_E5_A4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A5_infos[31] = {
- o2(0xB1,0xE2), o2(0xB4,0xF1), o2(0xC6,0xE0), o2(0xCA,0xF4),
- o2(0xD4,0xF7), o2(0xC1,0xD5), o2(0xD4,0xF6), o2(0xB7,0xC0),
- o2(0xF9,0xE4), o2(0xCB,0xDB), o2(0xD4,0xF5), o2(0xC5,0xE5),
- o2(0xD4,0xF9), o2(0xD4,0xF8), o2(0xF9,0xE5), o2(0xF9,0xE6),
- o2(0xD4,0xFB), o2(0xD4,0xFA), o2(0xF9,0xE7), o2(0xB1,0xFC),
- o2(0xD4,0xFC), o2(0xBE,0xA9), o2(0xD4,0xFE), o2(0xC3,0xA5),
- o2(0xD4,0xFD), o2(0xCA,0xB3), o2(0xBD,0xF7), o2(0xC5,0xDB),
- o2(0xD5,0xA1), o2(0xB9,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A5 = {
- to_SHIFT_JIS_E5_A5_offsets,
- to_EUC_JP_E5_A5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A6_infos[22] = {
- o2(0xD5,0xA2), o2(0xC7,0xA1), o2(0xC8,0xDE), o2(0xCC,0xD1),
- o2(0xC7,0xA5), o2(0xD5,0xAB), o2(0xB5,0xB8), o2(0xCD,0xC5),
- o2(0xCC,0xAF), o2(0xD6,0xAC), o2(0xD5,0xA3), o2(0xD5,0xA6),
- o2(0xF9,0xE8), o2(0xC2,0xC5), o2(0xCB,0xB8), o2(0xC5,0xCA),
- o2(0xD5,0xA7), o2(0xCB,0xE5), o2(0xF9,0xE9), o2(0xBA,0xCA),
- o2(0xBE,0xAA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A6 = {
- to_SHIFT_JIS_E5_A6_offsets,
- to_EUC_JP_E5_A6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A7_infos[19] = {
- o2(0xD5,0xA8), o2(0xBB,0xD0), o2(0xBB,0xCF), o2(0xB0,0xB9),
- o2(0xB8,0xC8), o2(0xC0,0xAB), o2(0xB0,0xD1), o2(0xD5,0xAC),
- o2(0xD5,0xAD), o2(0xD5,0xAA), o2(0xB1,0xB8), o2(0xB4,0xAF),
- o2(0xD5,0xA9), o2(0xCC,0xC5), o2(0xC9,0xB1), o2(0xB0,0xA8),
- o2(0xB0,0xF9), o2(0xBB,0xD1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A7 = {
- to_SHIFT_JIS_E5_A7_offsets,
- to_EUC_JP_E5_A7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A8_infos[16] = {
- o2(0xB0,0xD2), o2(0xB0,0xA3), o2(0xD5,0xB2), o2(0xD5,0xB0),
- o2(0xCC,0xBC), o2(0xD5,0xB3), o2(0xD5,0xB1), o2(0xD5,0xAF),
- o2(0xBF,0xB1), o2(0xD5,0xAE), o2(0xCA,0xDA), o2(0xB8,0xE4),
- o2(0xD5,0xB7), o2(0xD5,0xB8), o2(0xBE,0xAB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A8 = {
- to_SHIFT_JIS_E5_A8_offsets,
- to_EUC_JP_E5_A8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_A9_infos[11] = {
- o2(0xD5,0xB4), o2(0xCF,0xAC), o2(0xC7,0xCC), o2(0xD5,0xB6),
- o2(0xBA,0xA7), o2(0xD5,0xB9), o2(0xC9,0xD8), o2(0xD5,0xBA),
- o2(0xD5,0xB5), o2(0xCC,0xBB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_A9 = {
- to_SHIFT_JIS_E5_A9_offsets,
- to_EUC_JP_E5_A9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_AA_infos[7] = {
- o2(0xC7,0xDE), o2(0xD5,0xBB), o2(0xC9,0xB2), o2(0xD5,0xBC),
- o2(0xD5,0xC0), o2(0xD5,0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_AA = {
- to_SHIFT_JIS_E5_AA_offsets,
- to_EUC_JP_E5_AA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_AB_infos[15] = {
- o2(0xB2,0xC7), o2(0xD5,0xBF), o2(0xBC,0xBB), o2(0xD5,0xBE),
- o2(0xB7,0xF9), o2(0xD5,0xCC), o2(0xD5,0xC5), o2(0xD5,0xC2),
- o2(0xC3,0xE4), o2(0xD5,0xC1), o2(0xD5,0xC3), o2(0xD5,0xC4),
- o2(0xD5,0xC6), o2(0xD5,0xC7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_AB = {
- to_SHIFT_JIS_E5_AB_offsets,
- to_EUC_JP_E5_AB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_AC_infos[12] = {
- o2(0xB4,0xF2), o2(0xD5,0xC9), o2(0xD5,0xC8), o2(0xD5,0xCA),
- o2(0xBE,0xEE), o2(0xD5,0xCD), o2(0xC4,0xDC), o2(0xB1,0xC5),
- o2(0xD5,0xCB), o2(0xD5,0xCE), o2(0xD5,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_AC = {
- to_SHIFT_JIS_E5_AC_offsets,
- to_EUC_JP_E5_AC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_AD_infos[28] = {
- o2(0xD5,0xD2), o2(0xD5,0xD0), o2(0xD5,0xD1), o2(0xBB,0xD2),
- o2(0xD5,0xD3), o2(0xB9,0xA6), o2(0xD5,0xD4), o2(0xF9,0xEA),
- o2(0xBB,0xFA), o2(0xC2,0xB8), o2(0xD5,0xD5), o2(0xD5,0xD6),
- o2(0xBB,0xDA), o2(0xB9,0xA7), o2(0xCC,0xD2), o2(0xB5,0xA8),
- o2(0xB8,0xC9), o2(0xD5,0xD7), o2(0xB3,0xD8), o2(0xD5,0xD8),
- o2(0xC2,0xB9), o2(0xD5,0xD9), o2(0xD6,0xA3), o2(0xD5,0xDA),
- o2(0xD5,0xDB), o2(0xD5,0xDC), o2(0xD5,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_AD = {
- to_SHIFT_JIS_E5_AD_offsets,
- to_EUC_JP_E5_AD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_AE_infos[34] = {
- o2(0xD5,0xDF), o2(0xD5,0xE0), o2(0xC2,0xF0), o2(0xB1,0xA7),
- o2(0xBC,0xE9), o2(0xB0,0xC2), o2(0xC1,0xD7), o2(0xB4,0xB0),
- o2(0xBC,0xB5), o2(0xB9,0xA8), o2(0xC5,0xE6), o2(0xBD,0xA1),
- o2(0xB4,0xB1), o2(0xC3,0xE8), o2(0xC4,0xEA), o2(0xB0,0xB8),
- o2(0xB5,0xB9), o2(0xCA,0xF5), o2(0xBC,0xC2), o2(0xB5,0xD2),
- o2(0xC0,0xEB), o2(0xBC,0xBC), o2(0xCD,0xA8), o2(0xD5,0xE1),
- o2(0xB5,0xDC), o2(0xBA,0xCB), o2(0xB3,0xB2), o2(0xB1,0xE3),
- o2(0xBE,0xAC), o2(0xB2,0xC8), o2(0xD5,0xE2), o2(0xCD,0xC6),
- o2(0xBD,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_AE = {
- to_SHIFT_JIS_E5_AE_offsets,
- to_EUC_JP_E5_AE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_AF_infos[38] = {
- o2(0xF9,0xEB), o2(0xBC,0xE4), o2(0xD5,0xE3), o2(0xB4,0xF3),
- o2(0xC6,0xD2), o2(0xCC,0xA9), o2(0xD5,0xE4), o2(0xD5,0xE5),
- o2(0xC9,0xD9), o2(0xD5,0xE7), o2(0xB4,0xA8), o2(0xB6,0xF7),
- o2(0xD5,0xE6), o2(0xF9,0xED), o2(0xB4,0xB2), o2(0xBF,0xB2),
- o2(0xD5,0xEB), o2(0xBB,0xA1), o2(0xB2,0xC9), o2(0xD5,0xEA),
- o2(0xD5,0xE8), o2(0xD5,0xEC), o2(0xD5,0xE9), o2(0xC7,0xAB),
- o2(0xDC,0xCD), o2(0xBF,0xB3), o2(0xD5,0xED), o2(0xF9,0xEE),
- o2(0xCE,0xC0), o2(0xD5,0xEE), o2(0xD5,0xF0), o2(0xC3,0xFE),
- o2(0xD5,0xEF), o2(0xC0,0xA3), o2(0xBB,0xFB), o2(0xC2,0xD0),
- o2(0xBC,0xF7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_AF = {
- to_SHIFT_JIS_E5_AF_offsets,
- to_EUC_JP_E5_AF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B0_infos[33] = {
- o2(0xC9,0xF5), o2(0xC0,0xEC), o2(0xBC,0xCD), o2(0xD5,0xF1),
- o2(0xBE,0xAD), o2(0xD5,0xF2), o2(0xD5,0xF3), o2(0xB0,0xD3),
- o2(0xC2,0xBA), o2(0xBF,0xD2), o2(0xD5,0xF4), o2(0xC6,0xB3),
- o2(0xBE,0xAE), o2(0xBE,0xAF), o2(0xD5,0xF5), o2(0xC0,0xED),
- o2(0xBE,0xB0), o2(0xF9,0xEF), o2(0xD5,0xF6), o2(0xD5,0xF7),
- o2(0xCC,0xE0), o2(0xD5,0xF8), o2(0xB6,0xC6), o2(0xBD,0xA2),
- o2(0xD5,0xF9), o2(0xD5,0xFA), o2(0xBC,0xDC), o2(0xBF,0xAC),
- o2(0xC6,0xF4), o2(0xBF,0xD4), o2(0xC8,0xF8), o2(0xC7,0xA2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B0 = {
- to_SHIFT_JIS_E5_B0_offsets,
- to_EUC_JP_E5_B0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B1_infos[26] = {
- o2(0xB6,0xC9), o2(0xD5,0xFB), o2(0xB5,0xEF), o2(0xD5,0xFC),
- o2(0xB6,0xFE), o2(0xC6,0xCF), o2(0xB2,0xB0), o2(0xBB,0xD3),
- o2(0xD5,0xFD), o2(0xD6,0xA2), o2(0xD6,0xA1), o2(0xB6,0xFD),
- o2(0xD5,0xFE), o2(0xC5,0xB8), o2(0xC2,0xB0), o2(0xC5,0xCB),
- o2(0xBC,0xC8), o2(0xC1,0xD8), o2(0xCD,0xFA), o2(0xD6,0xA4),
- o2(0xD6,0xA5), o2(0xC6,0xD6), o2(0xBB,0xB3), o2(0xD6,0xA7),
- o2(0xD6,0xA8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B1 = {
- to_SHIFT_JIS_E5_B1_offsets,
- to_EUC_JP_E5_B1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B2_infos[20] = {
- o2(0xD6,0xA9), o2(0xB4,0xF4), o2(0xD6,0xAA), o2(0xD6,0xAB),
- o2(0xB2,0xAC), o2(0xF9,0xF0), o2(0xC1,0xBB), o2(0xB4,0xE4),
- o2(0xD6,0xAD), o2(0xCC,0xA8), o2(0xC2,0xD2), o2(0xB3,0xD9),
- o2(0xD6,0xAF), o2(0xD6,0xB1), o2(0xB4,0xDF), o2(0xF9,0xF1),
- o2(0xD6,0xAE), o2(0xD6,0xB0), o2(0xD6,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B2 = {
- to_SHIFT_JIS_E5_B2_offsets,
- to_EUC_JP_E5_B2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B3_infos[17] = {
- o2(0xD6,0xB2), o2(0xD6,0xB4), o2(0xD6,0xB5), o2(0xC6,0xBD),
- o2(0xB6,0xAE), o2(0xB2,0xE5), o2(0xD6,0xB6), o2(0xD6,0xBB),
- o2(0xD6,0xB9), o2(0xCA,0xF7), o2(0xCA,0xF6), o2(0xF9,0xF2),
- o2(0xC5,0xE7), o2(0xD6,0xB8), o2(0xBD,0xD4), o2(0xD6,0xB7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B3 = {
- to_SHIFT_JIS_E5_B3_offsets,
- to_EUC_JP_E5_B3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B4_infos[17] = {
- o2(0xBF,0xF2), o2(0xD6,0xBC), o2(0xBA,0xEA), o2(0xD6,0xC2),
- o2(0xD6,0xC3), o2(0xD6,0xBD), o2(0xB3,0xB3), o2(0xD6,0xBE),
- o2(0xD6,0xC7), o2(0xD6,0xC6), o2(0xD6,0xC5), o2(0xD6,0xC1),
- o2(0xD6,0xC0), o2(0xD6,0xC4), o2(0xF9,0xF3), o2(0xCA,0xF8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B4 = {
- to_SHIFT_JIS_E5_B4_offsets,
- to_EUC_JP_E5_B4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B5_infos[15] = {
- o2(0xF9,0xF6), o2(0xD6,0xCB), o2(0xD6,0xC8), o2(0xD6,0xCA),
- o2(0xCD,0xF2), o2(0xD6,0xC9), o2(0xF9,0xF4), o2(0xD6,0xBF),
- o2(0xBF,0xF3), o2(0xD6,0xCC), o2(0xF9,0xF7), o2(0xBA,0xB7),
- o2(0xD6,0xCD), o2(0xD6,0xCE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B5 = {
- to_SHIFT_JIS_E5_B5_offsets,
- to_EUC_JP_E5_B5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B6_infos[17] = {
- o2(0xD6,0xD1), o2(0xD6,0xD0), o2(0xD6,0xCF), o2(0xC5,0xE8),
- o2(0xD6,0xBA), o2(0xD6,0xD7), o2(0xD6,0xD3), o2(0xD6,0xD2),
- o2(0xD6,0xD4), o2(0xD6,0xD5), o2(0xD6,0xD8), o2(0xF9,0xF8),
- o2(0xF9,0xF9), o2(0xCE,0xE6), o2(0xD6,0xD9), o2(0xD6,0xD6),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B6 = {
- to_SHIFT_JIS_E5_B6_offsets,
- to_EUC_JP_E5_B6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B7_infos[28] = {
- o2(0xD6,0xDA), o2(0xB4,0xE0), o2(0xD6,0xDB), o2(0xF9,0xFA),
- o2(0xD6,0xDD), o2(0xD6,0xDC), o2(0xD6,0xDE), o2(0xD6,0xDF),
- o2(0xC0,0xEE), o2(0xBD,0xA3), o2(0xBD,0xE4), o2(0xC1,0xE3),
- o2(0xB9,0xA9), o2(0xBA,0xB8), o2(0xB9,0xAA), o2(0xB5,0xF0),
- o2(0xD6,0xE0), o2(0xBA,0xB9), o2(0xB8,0xCA), o2(0xD6,0xE1),
- o2(0xCC,0xA6), o2(0xC7,0xC3), o2(0xD6,0xE2), o2(0xB9,0xAB),
- o2(0xB4,0xAC), o2(0xC3,0xA7), o2(0xB6,0xD2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B7 = {
- to_SHIFT_JIS_E5_B7_offsets,
- to_EUC_JP_E5_B7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B8_infos[22] = {
- o2(0xBB,0xD4), o2(0xC9,0xDB), o2(0xC8,0xC1), o2(0xD6,0xE3),
- o2(0xB4,0xF5), o2(0xD6,0xE6), o2(0xC4,0xA1), o2(0xD6,0xE5),
- o2(0xD6,0xE4), o2(0xD6,0xE7), o2(0xC4,0xEB), o2(0xBF,0xE3),
- o2(0xBB,0xD5), o2(0xC0,0xCA), o2(0xC2,0xD3), o2(0xB5,0xA2),
- o2(0xC4,0xA2), o2(0xD6,0xE8), o2(0xD6,0xE9), o2(0xBE,0xEF),
- o2(0xCB,0xB9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B8 = {
- to_SHIFT_JIS_E5_B8_offsets,
- to_EUC_JP_E5_B8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_B9_infos[29] = {
- o2(0xD6,0xEC), o2(0xD6,0xEB), o2(0xD6,0xEA), o2(0xC9,0xFD),
- o2(0xD6,0xF3), o2(0xCB,0xDA), o2(0xD6,0xED), o2(0xD6,0xEF),
- o2(0xCB,0xEB), o2(0xD6,0xEE), o2(0xD6,0xF0), o2(0xC8,0xA8),
- o2(0xD6,0xF1), o2(0xCA,0xBE), o2(0xD6,0xF2), o2(0xB4,0xB3),
- o2(0xCA,0xBF), o2(0xC7,0xAF), o2(0xD6,0xF4), o2(0xD6,0xF5),
- o2(0xB9,0xAC), o2(0xB4,0xB4), o2(0xD6,0xF6), o2(0xB8,0xB8),
- o2(0xCD,0xC4), o2(0xCD,0xA9), o2(0xB4,0xF6), o2(0xD6,0xF8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_B9 = {
- to_SHIFT_JIS_E5_B9_offsets,
- to_EUC_JP_E5_B9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_BA_infos[21] = {
- o2(0xC4,0xA3), o2(0xB9,0xAD), o2(0xBE,0xB1), o2(0xC8,0xDF),
- o2(0xBE,0xB2), o2(0xBD,0xF8), o2(0xC4,0xEC), o2(0xCA,0xF9),
- o2(0xC5,0xB9), o2(0xB9,0xAE), o2(0xC9,0xDC), o2(0xD6,0xF9),
- o2(0xC5,0xD9), o2(0xBA,0xC2), o2(0xB8,0xCB), o2(0xC4,0xED),
- o2(0xB0,0xC3), o2(0xBD,0xEE), o2(0xB9,0xAF), o2(0xCD,0xC7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_BA = {
- to_SHIFT_JIS_E5_BA_offsets,
- to_EUC_JP_E5_BA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_BB_infos[34] = {
- o2(0xD6,0xFA), o2(0xD6,0xFB), o2(0xC7,0xD1), o2(0xD6,0xFC),
- o2(0xCE,0xF7), o2(0xCF,0xAD), o2(0xD6,0xFE), o2(0xD6,0xFD),
- o2(0xB3,0xC7), o2(0xD7,0xA1), o2(0xD7,0xA4), o2(0xD7,0xA5),
- o2(0xD7,0xA3), o2(0xC9,0xC0), o2(0xBE,0xB3), o2(0xD7,0xA7),
- o2(0xD7,0xA6), o2(0xD7,0xA2), o2(0xD7,0xA8), o2(0xD7,0xA9),
- o2(0xD7,0xAA), o2(0xD7,0xAD), o2(0xD7,0xAB), o2(0xD7,0xAC),
- o2(0xD7,0xAE), o2(0xB1,0xE4), o2(0xC4,0xEE), o2(0xD7,0xAF),
- o2(0xB7,0xFA), o2(0xB2,0xF6), o2(0xC7,0xB6), o2(0xD7,0xB0),
- o2(0xC6,0xFB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_BB = {
- to_SHIFT_JIS_E5_BB_offsets,
- to_EUC_JP_E5_BB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_BC_infos[34] = {
- o2(0xCA,0xDB), o2(0xD7,0xB1), o2(0xCF,0xAE), o2(0xD7,0xB2),
- o2(0xCA,0xC0), o2(0xD7,0xB5), o2(0xD0,0xA1), o2(0xD0,0xB1),
- o2(0xBC,0xB0), o2(0xC6,0xF5), o2(0xD7,0xB6), o2(0xB5,0xDD),
- o2(0xC4,0xA4), o2(0xB0,0xFA), o2(0xD7,0xB7), o2(0xCA,0xA6),
- o2(0xB9,0xB0), o2(0xC3,0xD0), o2(0xC4,0xEF), o2(0xF9,0xFB),
- o2(0xCC,0xEF), o2(0xB8,0xB9), o2(0xB8,0xCC), o2(0xD7,0xB8),
- o2(0xD7,0xB9), o2(0xD7,0xBF), o2(0xBC,0xE5), o2(0xF9,0xFC),
- o2(0xC4,0xA5), o2(0xB6,0xAF), o2(0xD7,0xBA), o2(0xC9,0xAB),
- o2(0xC3,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_BC = {
- to_SHIFT_JIS_E5_BC_offsets,
- to_EUC_JP_E5_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_BD_infos[30] = {
- o2(0xD7,0xBB), o2(0xF9,0xAC), o2(0xD7,0xBC), o2(0xB6,0xB0),
- o2(0xD7,0xBD), o2(0xD7,0xBE), o2(0xD7,0xC0), o2(0xC5,0xF6),
- o2(0xD7,0xC1), o2(0xD7,0xC2), o2(0xD7,0xC3), o2(0xD7,0xB4),
- o2(0xD7,0xB3), o2(0xD7,0xC4), o2(0xB7,0xC1), o2(0xC9,0xA7),
- o2(0xF9,0xFD), o2(0xBA,0xCC), o2(0xC9,0xB7), o2(0xC4,0xA6),
- o2(0xC9,0xCB), o2(0xD7,0xC5), o2(0xBE,0xB4), o2(0xB1,0xC6),
- o2(0xD7,0xC6), o2(0xD7,0xC7), o2(0xCC,0xF2), o2(0xC8,0xE0),
- o2(0xD7,0xCA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_BD = {
- to_SHIFT_JIS_E5_BD_offsets,
- to_EUC_JP_E5_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_BE_infos[33] = {
- o2(0xB1,0xFD), o2(0xC0,0xAC), o2(0xD7,0xC9), o2(0xD7,0xC8),
- o2(0xB7,0xC2), o2(0xC2,0xD4), o2(0xD7,0xCE), o2(0xD7,0xCC),
- o2(0xD7,0xCB), o2(0xCE,0xA7), o2(0xB8,0xE5), o2(0xBD,0xF9),
- o2(0xD7,0xCD), o2(0xC5,0xCC), o2(0xBD,0xBE), o2(0xC6,0xC0),
- o2(0xD7,0xD1), o2(0xD7,0xD0), o2(0xD7,0xCF), o2(0xD7,0xD2),
- o2(0xB8,0xE6), o2(0xD7,0xD3), o2(0xC9,0xFC), o2(0xBD,0xDB),
- o2(0xD7,0xD4), o2(0xC8,0xF9), o2(0xC6,0xC1), o2(0xC4,0xA7),
- o2(0xF9,0xFE), o2(0xC5,0xB0), o2(0xD7,0xD5), o2(0xB5,0xAB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_BE = {
- to_SHIFT_JIS_E5_BE_offsets,
- to_EUC_JP_E5_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_BF_infos[22] = {
- o2(0xBF,0xB4), o2(0xC9,0xAC), o2(0xB4,0xF7), o2(0xC7,0xA6),
- o2(0xD7,0xD6), o2(0xBB,0xD6), o2(0xCB,0xBA), o2(0xCB,0xBB),
- o2(0xB1,0xFE), o2(0xD7,0xDB), o2(0xFA,0xA1), o2(0xC3,0xE9),
- o2(0xD7,0xD8), o2(0xB2,0xF7), o2(0xD8,0xAD), o2(0xD7,0xDA),
- o2(0xC7,0xB0), o2(0xD7,0xD9), o2(0xD7,0xD7), o2(0xB9,0xFA),
- o2(0xD7,0xDD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5_BF = {
- to_SHIFT_JIS_E5_BF_offsets,
- to_EUC_JP_E5_BF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E5_infos[64] = {
- &to_EUC_JP_E5_80, &to_EUC_JP_E5_81, &to_EUC_JP_E5_82, &to_EUC_JP_E5_83,
- &to_EUC_JP_E5_84, &to_EUC_JP_E5_85, &to_EUC_JP_E5_86, &to_EUC_JP_E5_87,
- &to_EUC_JP_E5_88, &to_EUC_JP_E5_89, &to_EUC_JP_E5_8A, &to_EUC_JP_E5_8B,
- &to_EUC_JP_E5_8C, &to_EUC_JP_E5_8D, &to_EUC_JP_E5_8E, &to_EUC_JP_E5_8F,
- &to_EUC_JP_E5_90, &to_EUC_JP_E5_91, &to_EUC_JP_E5_92, &to_EUC_JP_E5_93,
- &to_EUC_JP_E5_94, &to_EUC_JP_E5_95, &to_EUC_JP_E5_96, &to_EUC_JP_E5_97,
- &to_EUC_JP_E5_98, &to_EUC_JP_E5_99, &to_EUC_JP_E5_9A, &to_EUC_JP_E5_9B,
- &to_EUC_JP_E5_9C, &to_EUC_JP_E5_9D, &to_EUC_JP_E5_9E, &to_EUC_JP_E5_9F,
- &to_EUC_JP_E5_A0, &to_EUC_JP_E5_A1, &to_EUC_JP_E5_A2, &to_EUC_JP_E5_A3,
- &to_EUC_JP_E5_A4, &to_EUC_JP_E5_A5, &to_EUC_JP_E5_A6, &to_EUC_JP_E5_A7,
- &to_EUC_JP_E5_A8, &to_EUC_JP_E5_A9, &to_EUC_JP_E5_AA, &to_EUC_JP_E5_AB,
- &to_EUC_JP_E5_AC, &to_EUC_JP_E5_AD, &to_EUC_JP_E5_AE, &to_EUC_JP_E5_AF,
- &to_EUC_JP_E5_B0, &to_EUC_JP_E5_B1, &to_EUC_JP_E5_B2, &to_EUC_JP_E5_B3,
- &to_EUC_JP_E5_B4, &to_EUC_JP_E5_B5, &to_EUC_JP_E5_B6, &to_EUC_JP_E5_B7,
- &to_EUC_JP_E5_B8, &to_EUC_JP_E5_B9, &to_EUC_JP_E5_BA, &to_EUC_JP_E5_BB,
- &to_EUC_JP_E5_BC, &to_EUC_JP_E5_BD, &to_EUC_JP_E5_BE, &to_EUC_JP_E5_BF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E5 = {
- to_SHIFT_JIS_E5_offsets,
- to_EUC_JP_E5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_80_infos[23] = {
- o2(0xD7,0xE3), o2(0xD7,0xE9), o2(0xD7,0xE1), o2(0xC5,0xDC),
- o2(0xD7,0xE6), o2(0xC9,0xDD), o2(0xD7,0xE0), o2(0xD7,0xE5),
- o2(0xCE,0xE7), o2(0xBB,0xD7), o2(0xC2,0xD5), o2(0xD7,0xDE),
- o2(0xB5,0xDE), o2(0xD7,0xE8), o2(0xC0,0xAD), o2(0xB1,0xE5),
- o2(0xD7,0xE2), o2(0xB2,0xF8), o2(0xD7,0xE7), o2(0xB6,0xB1),
- o2(0xD7,0xE4), o2(0xD7,0xEA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_80 = {
- to_SHIFT_JIS_E6_80_offsets,
- to_EUC_JP_E6_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_81_infos[30] = {
- o2(0xD7,0xEC), o2(0xD7,0xF6), o2(0xD7,0xF4), o2(0xD7,0xF1),
- o2(0xD7,0xF0), o2(0xCE,0xF8), o2(0xD7,0xF2), o2(0xB6,0xB2),
- o2(0xB9,0xB1), o2(0xBD,0xFA), o2(0xD7,0xF9), o2(0xD7,0xEB),
- o2(0xFA,0xA2), o2(0xD7,0xEF), o2(0xD7,0xDF), o2(0xB2,0xFA),
- o2(0xD7,0xF3), o2(0xD7,0xF5), o2(0xC3,0xD1), o2(0xBA,0xA8),
- o2(0xB2,0xB8), o2(0xD7,0xED), o2(0xD7,0xF8), o2(0xD7,0xF7),
- o2(0xB6,0xB3), o2(0xC2,0xA9), o2(0xB3,0xE6), o2(0xB7,0xC3),
- o2(0xD7,0xEE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_81 = {
- to_SHIFT_JIS_E6_81_offsets,
- to_EUC_JP_E6_81_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_82_infos[31] = {
- o2(0xD7,0xFA), o2(0xD7,0xFD), o2(0xD8,0xA1), o2(0xFA,0xA3),
- o2(0xBC,0xBD), o2(0xFA,0xA4), o2(0xD8,0xA7), o2(0xC4,0xF0),
- o2(0xD7,0xFB), o2(0xD8,0xA5), o2(0xB2,0xF9), o2(0xD8,0xA3),
- o2(0xD8,0xA4), o2(0xD7,0xFE), o2(0xD8,0xA2), o2(0xB8,0xE7),
- o2(0xCD,0xAA), o2(0xB4,0xB5), o2(0xB1,0xD9), o2(0xD8,0xA6),
- o2(0xC7,0xBA), o2(0xB0,0xAD), o2(0xC8,0xE1), o2(0xD7,0xDC),
- o2(0xD8,0xAC), o2(0xD8,0xB0), o2(0xCC,0xE5), o2(0xD8,0xA9),
- o2(0xC5,0xE9), o2(0xD8,0xAE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_82 = {
- to_SHIFT_JIS_E6_82_offsets,
- to_EUC_JP_E6_82_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_83_infos[27] = {
- o2(0xBE,0xF0), o2(0xD8,0xAF), o2(0xC6,0xD7), o2(0xCF,0xC7),
- o2(0xD8,0xAB), o2(0xFA,0xA6), o2(0xD8,0xB1), o2(0xB9,0xFB),
- o2(0xC0,0xCB), o2(0xFA,0xA5), o2(0xB0,0xD4), o2(0xD8,0xAA),
- o2(0xD8,0xA8), o2(0xC1,0xDA), o2(0xD7,0xFC), o2(0xBB,0xB4),
- o2(0xC2,0xC6), o2(0xD8,0xBD), o2(0xFA,0xA8), o2(0xC1,0xDB),
- o2(0xD8,0xB8), o2(0xD8,0xB5), o2(0xD8,0xB6), o2(0xBC,0xE6),
- o2(0xD8,0xB9), o2(0xD8,0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_83 = {
- to_SHIFT_JIS_E6_83_offsets,
- to_EUC_JP_E6_83_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_84_infos[27] = {
- o2(0xD8,0xB7), o2(0xBD,0xA5), o2(0xD8,0xBA), o2(0xD8,0xB4),
- o2(0xCC,0xFC), o2(0xCC,0xFB), o2(0xD8,0xBE), o2(0xD8,0xBF),
- o2(0xB0,0xD5), o2(0xFA,0xA9), o2(0xD8,0xB3), o2(0xB6,0xF2),
- o2(0xB0,0xA6), o2(0xB4,0xB6), o2(0xFA,0xA7), o2(0xD8,0xBB),
- o2(0xD8,0xC3), o2(0xD8,0xC2), o2(0xD8,0xC7), o2(0xFA,0xAB),
- o2(0xD8,0xC8), o2(0xFA,0xAA), o2(0xD8,0xC6), o2(0xD8,0xC9),
- o2(0xD8,0xC1), o2(0xD8,0xC5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_84 = {
- to_SHIFT_JIS_E6_84_offsets,
- to_EUC_JP_E6_84_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_85_infos[33] = {
- o2(0xD8,0xCA), o2(0xD8,0xCB), o2(0xD8,0xC0), o2(0xBB,0xFC),
- o2(0xD8,0xC4), o2(0xC2,0xD6), o2(0xB9,0xB2), o2(0xD8,0xB2),
- o2(0xBF,0xB5), o2(0xD8,0xD8), o2(0xCA,0xE9), o2(0xD8,0xCE),
- o2(0xD8,0xCF), o2(0xD8,0xD0), o2(0xD8,0xD7), o2(0xD8,0xD6),
- o2(0xCB,0xFD), o2(0xB4,0xB7), o2(0xD8,0xD4), o2(0xB7,0xC5),
- o2(0xB3,0xB4), o2(0xD8,0xD1), o2(0xCE,0xB8), o2(0xD8,0xD3),
- o2(0xB0,0xD6), o2(0xD8,0xD5), o2(0xD8,0xCC), o2(0xD8,0xD2),
- o2(0xD8,0xD9), o2(0xB7,0xC4), o2(0xD8,0xCD), o2(0xCD,0xDD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_85 = {
- to_SHIFT_JIS_E6_85_offsets,
- to_EUC_JP_E6_85_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_86_infos[22] = {
- o2(0xCD,0xAB), o2(0xD8,0xDC), o2(0xD8,0xE0), o2(0xC1,0xFE),
- o2(0xCE,0xF9), o2(0xD8,0xE1), o2(0xD8,0xDE), o2(0xD8,0xDB),
- o2(0xFA,0xAC), o2(0xD8,0xDA), o2(0xD8,0xDF), o2(0xCA,0xB0),
- o2(0xC6,0xB4), o2(0xB7,0xC6), o2(0xD8,0xE2), o2(0xD8,0xDD),
- o2(0xD8,0xE3), o2(0xB7,0xFB), o2(0xB2,0xB1), o2(0xD8,0xEB),
- o2(0xB4,0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_86 = {
- to_SHIFT_JIS_E6_86_offsets,
- to_EUC_JP_E6_86_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_87_infos[23] = {
- o2(0xD8,0xE9), o2(0xD8,0xEA), o2(0xBA,0xA9), o2(0xD8,0xE8),
- o2(0xD8,0xE6), o2(0xD8,0xE5), o2(0xD8,0xEC), o2(0xD8,0xE4),
- o2(0xD8,0xEE), o2(0xB2,0xFB), o2(0xD8,0xF0), o2(0xD8,0xEF),
- o2(0xC4,0xA8), o2(0xD8,0xF3), o2(0xD8,0xF1), o2(0xD8,0xE7),
- o2(0xB7,0xFC), o2(0xD8,0xF2), o2(0xD8,0xF6), o2(0xD8,0xF5),
- o2(0xD8,0xF7), o2(0xD8,0xF4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_87 = {
- to_SHIFT_JIS_E6_87_offsets,
- to_EUC_JP_E6_87_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_88_infos[31] = {
- o2(0xD8,0xF8), o2(0xD8,0xF9), o2(0xD8,0xFA), o2(0xCA,0xEA),
- o2(0xD8,0xFC), o2(0xD8,0xFB), o2(0xBD,0xBF), o2(0xC0,0xAE),
- o2(0xB2,0xE6), o2(0xB2,0xFC), o2(0xFA,0xAD), o2(0xD8,0xFD),
- o2(0xB0,0xBF), o2(0xC0,0xCC), o2(0xD8,0xFE), o2(0xEC,0xC3),
- o2(0xD9,0xA1), o2(0xB7,0xE1), o2(0xD9,0xA2), o2(0xC0,0xEF),
- o2(0xD9,0xA3), o2(0xD9,0xA4), o2(0xB5,0xBA), o2(0xD9,0xA5),
- o2(0xD9,0xA6), o2(0xD9,0xA7), o2(0xC2,0xD7), o2(0xB8,0xCD),
- o2(0xCC,0xE1), o2(0xCB,0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_88 = {
- to_SHIFT_JIS_E6_88_offsets,
- to_EUC_JP_E6_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_89_infos[24] = {
- o2(0xBD,0xEA), o2(0xD9,0xA8), o2(0xC0,0xF0), o2(0xEE,0xBD),
- o2(0xC8,0xE2), o2(0xBC,0xEA), o2(0xBA,0xCD), o2(0xD9,0xA9),
- o2(0xC2,0xC7), o2(0xCA,0xA7), o2(0xC2,0xF1), o2(0xD9,0xAC),
- o2(0xD9,0xAA), o2(0xD9,0xAD), o2(0xD9,0xAB), o2(0xD9,0xAE),
- o2(0xCA,0xB1), o2(0xB0,0xB7), o2(0xC9,0xDE), o2(0xC8,0xE3),
- o2(0xD9,0xAF), o2(0xD9,0xB2), o2(0xBE,0xB5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_89 = {
- to_SHIFT_JIS_E6_89_offsets,
- to_EUC_JP_E6_89_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_8A_infos[27] = {
- o2(0xB5,0xBB), o2(0xD9,0xB0), o2(0xD9,0xB7), o2(0xBE,0xB6),
- o2(0xD9,0xB1), o2(0xC7,0xC4), o2(0xCD,0xDE), o2(0xD9,0xB3),
- o2(0xD9,0xB4), o2(0xD9,0xB8), o2(0xC5,0xEA), o2(0xD9,0xB5),
- o2(0xB9,0xB3), o2(0xC0,0xDE), o2(0xD9,0xC6), o2(0xC8,0xB4),
- o2(0xC2,0xF2), o2(0xFA,0xAE), o2(0xC8,0xE4), o2(0xDA,0xAD),
- o2(0xCA,0xFA), o2(0xC4,0xF1), o2(0xCB,0xF5), o2(0xD9,0xBB),
- o2(0xB2,0xA1), o2(0xC3,0xEA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_8A = {
- to_SHIFT_JIS_E6_8A_offsets,
- to_EUC_JP_E6_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_8B_infos[35] = {
- o2(0xD9,0xC4), o2(0xC3,0xB4), o2(0xD9,0xBE), o2(0xD9,0xC5),
- o2(0xD9,0xC0), o2(0xD9,0xC7), o2(0xD9,0xC3), o2(0xD9,0xC2),
- o2(0xC7,0xEF), o2(0xD9,0xBC), o2(0xB2,0xFD), o2(0xD9,0xBA),
- o2(0xB5,0xF1), o2(0xC2,0xF3), o2(0xD9,0xB6), o2(0xD9,0xB9),
- o2(0xB9,0xB4), o2(0xC0,0xDB), o2(0xBE,0xB7), o2(0xD9,0xC1),
- o2(0xC7,0xD2), o2(0xB5,0xF2), o2(0xB3,0xC8), o2(0xB3,0xE7),
- o2(0xBF,0xA1), o2(0xD9,0xC9), o2(0xD9,0xCE), o2(0xD9,0xCA),
- o2(0xB7,0xFD), o2(0xD9,0xCF), o2(0xBB,0xA2), o2(0xB9,0xE9),
- o2(0xBD,0xA6), o2(0xD9,0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_8B = {
- to_SHIFT_JIS_E6_8B_offsets,
- to_EUC_JP_E6_8B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_8C_infos[18] = {
- o2(0xBB,0xFD), o2(0xD9,0xCC), o2(0xBB,0xD8), o2(0xD9,0xCD),
- o2(0xB0,0xC4), o2(0xD9,0xC8), o2(0xC4,0xA9), o2(0xB5,0xF3),
- o2(0xB6,0xB4), o2(0xD9,0xCB), o2(0xB0,0xA7), o2(0xBA,0xC3),
- o2(0xBF,0xB6), o2(0xC4,0xF2), o2(0xC8,0xD4), o2(0xD9,0xD1),
- o2(0xC1,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_8C = {
- to_SHIFT_JIS_E6_8C_offsets,
- to_EUC_JP_E6_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_8D_infos[19] = {
- o2(0xC2,0xAA), o2(0xBB,0xAB), o2(0xD9,0xD2), o2(0xD9,0xD4),
- o2(0xD9,0xD0), o2(0xCA,0xE1), o2(0xC4,0xBD), o2(0xC1,0xDC),
- o2(0xCA,0xFB), o2(0xBC,0xCE), o2(0xD9,0xE0), o2(0xD9,0xDF),
- o2(0xBF,0xF8), o2(0xB7,0xFE), o2(0xD9,0xD9), o2(0xBE,0xB9),
- o2(0xC6,0xE8), o2(0xC7,0xB1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_8D = {
- to_SHIFT_JIS_E6_8D_offsets,
- to_EUC_JP_E6_8D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_8E_infos[29] = {
- o2(0xD9,0xD7), o2(0xC1,0xDD), o2(0xBC,0xF8), o2(0xD9,0xDC),
- o2(0xBE,0xB8), o2(0xD9,0xD6), o2(0xD9,0xDB), o2(0xC7,0xD3),
- o2(0xD9,0xD5), o2(0xB7,0xA1), o2(0xB3,0xDD), o2(0xD9,0xDD),
- o2(0xCE,0xAB), o2(0xBA,0xCE), o2(0xC3,0xB5), o2(0xD9,0xDA),
- o2(0xC0,0xDC), o2(0xB9,0xB5), o2(0xBF,0xE4), o2(0xB1,0xE6),
- o2(0xC1,0xBC), o2(0xD9,0xD8), o2(0xB5,0xC5), o2(0xB7,0xC7),
- o2(0xC4,0xCF), o2(0xD9,0xDE), o2(0xC1,0xDF), o2(0xD9,0xE1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_8E = {
- to_SHIFT_JIS_E6_8E_offsets,
- to_EUC_JP_E6_8E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_8F_infos[20] = {
- o2(0xD9,0xE3), o2(0xC2,0xB7), o2(0xD9,0xE9), o2(0xD9,0xE4),
- o2(0xD9,0xE6), o2(0xC9,0xC1), o2(0xC4,0xF3), o2(0xD9,0xE7),
- o2(0xCD,0xAC), o2(0xCD,0xC8), o2(0xB4,0xB9), o2(0xB0,0xAE),
- o2(0xD9,0xE5), o2(0xD9,0xE2), o2(0xB4,0xF8), o2(0xB1,0xE7),
- o2(0xFA,0xAF), o2(0xD9,0xE8), o2(0xCD,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_8F = {
- to_SHIFT_JIS_E6_8F_offsets,
- to_EUC_JP_E6_8F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_90_infos[16] = {
- o2(0xD9,0xEC), o2(0xC2,0xBB), o2(0xD9,0xF3), o2(0xD9,0xED),
- o2(0xD9,0xEA), o2(0xD9,0xF1), o2(0xD9,0xD3), o2(0xD9,0xEE),
- o2(0xD9,0xF2), o2(0xC8,0xC2), o2(0xC5,0xEB), o2(0xD9,0xEB),
- o2(0xD9,0xEF), o2(0xB7,0xC8), o2(0xBA,0xF1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_90 = {
- to_SHIFT_JIS_E6_90_offsets,
- to_EUC_JP_E6_90_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_91_infos[11] = {
- o2(0xC0,0xDD), o2(0xD9,0xF7), o2(0xC5,0xA6), o2(0xFA,0xB0),
- o2(0xD9,0xF4), o2(0xCB,0xE0), o2(0xD9,0xF5), o2(0xD9,0xF6),
- o2(0xCC,0xCE), o2(0xC0,0xA2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_91 = {
- to_SHIFT_JIS_E6_91_offsets,
- to_EUC_JP_E6_91_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_92_infos[20] = {
- o2(0xB7,0xE2), o2(0xD9,0xFD), o2(0xBB,0xB5), o2(0xD9,0xFA),
- o2(0xD9,0xF9), o2(0xC7,0xB2), o2(0xFA,0xB1), o2(0xC6,0xB5),
- o2(0xC5,0xB1), o2(0xD9,0xFB), o2(0xD9,0xFC), o2(0xC9,0xEF),
- o2(0xC7,0xC5), o2(0xBB,0xA3), o2(0xC0,0xF1), o2(0xCB,0xD0),
- o2(0xB3,0xC9), o2(0xDA,0xA5), o2(0xD9,0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_92 = {
- to_SHIFT_JIS_E6_92_offsets,
- to_EUC_JP_E6_92_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_93_infos[26] = {
- o2(0xCD,0xCA), o2(0xDA,0xA7), o2(0xDA,0xA3), o2(0xDA,0xA4),
- o2(0xC1,0xE0), o2(0xFA,0xB2), o2(0xDA,0xA2), o2(0xD9,0xBF),
- o2(0xDA,0xA6), o2(0xDA,0xA1), o2(0xDA,0xAB), o2(0xDA,0xAC),
- o2(0xC5,0xA7), o2(0xDA,0xAE), o2(0xBB,0xA4), o2(0xDA,0xA9),
- o2(0xB5,0xBC), o2(0xDA,0xAF), o2(0xDA,0xA8), o2(0xDA,0xB3),
- o2(0xDA,0xB2), o2(0xDA,0xB1), o2(0xDA,0xB4), o2(0xDA,0xB6),
- o2(0xBE,0xF1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_93 = {
- to_SHIFT_JIS_E6_93_offsets,
- to_EUC_JP_E6_93_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_94_infos[21] = {
- o2(0xDA,0xB5), o2(0xDA,0xB9), o2(0xDA,0xB7), o2(0xDA,0xB8),
- o2(0xD9,0xF0), o2(0xDA,0xBB), o2(0xDA,0xBA), o2(0xD9,0xF8),
- o2(0xDA,0xBC), o2(0xDA,0xB0), o2(0xBB,0xD9), o2(0xDA,0xBD),
- o2(0xDA,0xBE), o2(0xDA,0xC0), o2(0xDA,0xBF), o2(0xDA,0xC1),
- o2(0xB2,0xFE), o2(0xB9,0xB6), o2(0xCA,0xFC), o2(0xC0,0xAF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_94 = {
- to_SHIFT_JIS_E6_94_offsets,
- to_EUC_JP_E6_94_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_95_infos[24] = {
- o2(0xB8,0xCE), o2(0xDA,0xC3), o2(0xDA,0xC6), o2(0xFA,0xB3),
- o2(0xC9,0xD2), o2(0xB5,0xDF), o2(0xDA,0xC5), o2(0xDA,0xC4),
- o2(0xC7,0xD4), o2(0xDA,0xC7), o2(0xB6,0xB5), o2(0xDA,0xC9),
- o2(0xDA,0xC8), o2(0xB4,0xBA), o2(0xBB,0xB6), o2(0xC6,0xD8),
- o2(0xB7,0xC9), o2(0xBF,0xF4), o2(0xDA,0xCA), o2(0xC0,0xB0),
- o2(0xC5,0xA8), o2(0xC9,0xDF), o2(0xDA,0xCB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_95 = {
- to_SHIFT_JIS_E6_95_offsets,
- to_EUC_JP_E6_95_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_96_infos[28] = {
- o2(0xDA,0xCC), o2(0xDA,0xCD), o2(0xCA,0xB8), o2(0xD5,0xDD),
- o2(0xC0,0xC6), o2(0xC9,0xCC), o2(0xBA,0xD8), o2(0xC8,0xE5),
- o2(0xC8,0xC3), o2(0xC5,0xCD), o2(0xCE,0xC1), o2(0xDA,0xCF),
- o2(0xBC,0xD0), o2(0xDA,0xD0), o2(0xB0,0xB6), o2(0xB6,0xD4),
- o2(0xC0,0xCD), o2(0xC9,0xE0), o2(0xDA,0xD1), o2(0xBB,0xC2),
- o2(0xC3,0xC7), o2(0xBB,0xDB), o2(0xBF,0xB7), o2(0xDA,0xD2),
- o2(0xCA,0xFD), o2(0xB1,0xF7), o2(0xBB,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_96 = {
- to_SHIFT_JIS_E6_96_offsets,
- to_EUC_JP_E6_96_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_97_infos[26] = {
- o2(0xDA,0xD5), o2(0xDA,0xD3), o2(0xDA,0xD6), o2(0xCE,0xB9),
- o2(0xDA,0xD4), o2(0xC0,0xFB), o2(0xDA,0xD7), o2(0xC2,0xB2),
- o2(0xDA,0xD8), o2(0xB4,0xFA), o2(0xDA,0xDA), o2(0xDA,0xD9),
- o2(0xDA,0xDB), o2(0xDA,0xDC), o2(0xB4,0xFB), o2(0xC6,0xFC),
- o2(0xC3,0xB6), o2(0xB5,0xEC), o2(0xBB,0xDD), o2(0xC1,0xE1),
- o2(0xBD,0xDC), o2(0xB0,0xB0), o2(0xDA,0xDD), o2(0xB2,0xA2),
- o2(0xDA,0xE1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_97 = {
- to_SHIFT_JIS_E6_97_offsets,
- to_EUC_JP_E6_97_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_98_infos[32] = {
- o2(0xFA,0xB4), o2(0xB9,0xB7), o2(0xDA,0xE0), o2(0xBA,0xAB),
- o2(0xBE,0xBA), o2(0xFA,0xB7), o2(0xDA,0xDF), o2(0xBE,0xBB),
- o2(0xCC,0xC0), o2(0xBA,0xAA), o2(0xB0,0xD7), o2(0xC0,0xCE),
- o2(0xFA,0xB5), o2(0xDA,0xE6), o2(0xFA,0xB9), o2(0xC0,0xB1),
- o2(0xB1,0xC7), o2(0xFA,0xBA), o2(0xBD,0xD5), o2(0xCB,0xE6),
- o2(0xBA,0xF2), o2(0xBE,0xBC), o2(0xFA,0xB8), o2(0xC0,0xA7),
- o2(0xF9,0xA8), o2(0xDA,0xE5), o2(0xDA,0xE3), o2(0xDA,0xE4),
- o2(0xFA,0xB6), o2(0xC3,0xEB), o2(0xDB,0xA6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_98 = {
- to_SHIFT_JIS_E6_98_offsets,
- to_EUC_JP_E6_98_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_99_infos[28] = {
- o2(0xDA,0xEA), o2(0xBB,0xFE), o2(0xB9,0xB8), o2(0xDA,0xE8),
- o2(0xDA,0xE9), o2(0xBF,0xB8), o2(0xDA,0xE7), o2(0xBB,0xAF),
- o2(0xFA,0xBC), o2(0xFA,0xBD), o2(0xDA,0xEC), o2(0xDA,0xEB),
- o2(0xDA,0xF0), o2(0xDA,0xF1), o2(0xDA,0xED), o2(0xFA,0xBB),
- o2(0xB3,0xA2), o2(0xDA,0xEE), o2(0xDA,0xEF), o2(0xC8,0xD5),
- o2(0xC9,0xE1), o2(0xB7,0xCA), o2(0xDA,0xF2), o2(0xFA,0xBF),
- o2(0xC0,0xB2), o2(0xBE,0xBD), o2(0xC3,0xD2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_99 = {
- to_SHIFT_JIS_E6_99_offsets,
- to_EUC_JP_E6_99_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_9A_infos[26] = {
- o2(0xB6,0xC7), o2(0xDA,0xF3), o2(0xDA,0xF7), o2(0xB2,0xCB),
- o2(0xDA,0xF4), o2(0xDA,0xF6), o2(0xDA,0xF5), o2(0xBD,0xEB),
- o2(0xC3,0xC8), o2(0xB0,0xC5), o2(0xDA,0xF8), o2(0xFA,0xC0),
- o2(0xDA,0xF9), o2(0xFA,0xC1), o2(0xC4,0xAA), o2(0xCE,0xF1),
- o2(0xBB,0xC3), o2(0xCA,0xEB), o2(0xFA,0xC2), o2(0xCB,0xBD),
- o2(0xDB,0xA2), o2(0xDA,0xFB), o2(0xDA,0xFE), o2(0xDA,0xFD),
- o2(0xFA,0xC3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_9A = {
- to_SHIFT_JIS_E6_9A_offsets,
- to_EUC_JP_E6_9A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_9B_infos[27] = {
- o2(0xDA,0xFA), o2(0xDB,0xA1), o2(0xC6,0xDE), o2(0xDA,0xFC),
- o2(0xDB,0xA3), o2(0xBD,0xEC), o2(0xDB,0xA4), o2(0xCD,0xCB),
- o2(0xC7,0xF8), o2(0xDB,0xA5), o2(0xDB,0xA7), o2(0xDB,0xA8),
- o2(0xDB,0xA9), o2(0xB6,0xCA), o2(0xB1,0xC8), o2(0xB9,0xB9),
- o2(0xDB,0xAA), o2(0xDB,0xAB), o2(0xBD,0xF1), o2(0xC1,0xE2),
- o2(0xFA,0xC4), o2(0xF9,0xAB), o2(0xD2,0xD8), o2(0xC1,0xBE),
- o2(0xC1,0xBD), o2(0xC2,0xD8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_9B = {
- to_SHIFT_JIS_E6_9B_offsets,
- to_EUC_JP_E6_9B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_9C_infos[33] = {
- o2(0xBA,0xC7), o2(0xD0,0xF2), o2(0xB7,0xEE), o2(0xCD,0xAD),
- o2(0xCA,0xFE), o2(0xC9,0xFE), o2(0xFA,0xC5), o2(0xDB,0xAC),
- o2(0xBA,0xF3), o2(0xC4,0xBF), o2(0xDB,0xAD), o2(0xCF,0xAF),
- o2(0xCB,0xBE), o2(0xC4,0xAB), o2(0xDB,0xAE), o2(0xB4,0xFC),
- o2(0xDB,0xAF), o2(0xDB,0xB0), o2(0xCC,0xDA), o2(0xCC,0xA4),
- o2(0xCB,0xF6), o2(0xCB,0xDC), o2(0xBB,0xA5), o2(0xDB,0xB2),
- o2(0xBC,0xEB), o2(0xCB,0xD1), o2(0xDB,0xB4), o2(0xDB,0xB7),
- o2(0xDB,0xB6), o2(0xB4,0xF9), o2(0xB5,0xE0), o2(0xDB,0xB3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_9C = {
- to_SHIFT_JIS_E6_9C_offsets,
- to_EUC_JP_E6_9C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_9D_infos[33] = {
- o2(0xDB,0xB5), o2(0xDB,0xB8), o2(0xBF,0xF9), o2(0xCD,0xFB),
- o2(0xB0,0xC9), o2(0xBA,0xE0), o2(0xC2,0xBC), o2(0xBC,0xDD),
- o2(0xBE,0xF3), o2(0xDB,0xBB), o2(0xC5,0xCE), o2(0xDB,0xB9),
- o2(0xC2,0xAB), o2(0xDB,0xBA), o2(0xBE,0xF2), o2(0xCC,0xDD),
- o2(0xDB,0xBC), o2(0xDB,0xBD), o2(0xCD,0xE8), o2(0xFA,0xC7),
- o2(0xDB,0xC2), o2(0xB9,0xBA), o2(0xC7,0xD5), o2(0xDB,0xBF),
- o2(0xC5,0xEC), o2(0xDA,0xDE), o2(0xDA,0xE2), o2(0xB5,0xCF),
- o2(0xC7,0xC7), o2(0xDB,0xC1), o2(0xBE,0xBE), o2(0xC8,0xC4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_9D = {
- to_SHIFT_JIS_E6_9D_offsets,
- to_EUC_JP_E6_9D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_9E_infos[25] = {
- o2(0xDB,0xC7), o2(0xC8,0xFA), o2(0xDB,0xBE), o2(0xDB,0xC4),
- o2(0xDB,0xC3), o2(0xC0,0xCF), o2(0xCB,0xED), o2(0xCE,0xD3),
- o2(0xCB,0xE7), o2(0xB2,0xCC), o2(0xBB,0xDE), o2(0xCF,0xC8),
- o2(0xDB,0xC6), o2(0xBF,0xF5), o2(0xDB,0xC5), o2(0xDB,0xC0),
- o2(0xB8,0xCF), o2(0xDB,0xCC), o2(0xDB,0xCA), o2(0xB2,0xCD),
- o2(0xDB,0xC8), o2(0xDB,0xCE), o2(0xDB,0xD4), o2(0xFA,0xC8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_9E = {
- to_SHIFT_JIS_E6_9E_offsets,
- to_EUC_JP_E6_9E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_9F_infos[30] = {
- o2(0xFA,0xCA), o2(0xC2,0xC8), o2(0xCA,0xC1), o2(0xDB,0xD6),
- o2(0xC9,0xA2), o2(0xDB,0xD5), o2(0xC7,0xF0), o2(0xCB,0xBF),
- o2(0xB4,0xBB), o2(0xC0,0xF7), o2(0xBD,0xC0), o2(0xC4,0xD3),
- o2(0xCD,0xAE), o2(0xDB,0xD1), o2(0xDB,0xD0), o2(0xDB,0xD2),
- o2(0xDB,0xCF), o2(0xDB,0xD7), o2(0xDB,0xCD), o2(0xDB,0xCB),
- o2(0xDB,0xD3), o2(0xDB,0xC9), o2(0xC3,0xEC), o2(0xCC,0xF8),
- o2(0xBC,0xC6), o2(0xBA,0xF4), o2(0xBA,0xBA), o2(0xCB,0xEF),
- o2(0xB3,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_9F = {
- to_SHIFT_JIS_E6_9F_offsets,
- to_EUC_JP_E6_9F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A0_infos[20] = {
- o2(0xFA,0xCB), o2(0xC4,0xCE), o2(0xC6,0xCA), o2(0xB1,0xC9),
- o2(0xC0,0xF2), o2(0xC0,0xB4), o2(0xB7,0xAA), o2(0xDB,0xD9),
- o2(0xB9,0xBB), o2(0xB3,0xFC), o2(0xDB,0xDB), o2(0xB3,0xF4),
- o2(0xDB,0xE1), o2(0xDB,0xDE), o2(0xC0,0xF3), o2(0xB3,0xCB),
- o2(0xBA,0xAC), o2(0xB3,0xCA), o2(0xBA,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A0 = {
- to_SHIFT_JIS_E6_A0_offsets,
- to_EUC_JP_E6_A0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A1_infos[26] = {
- o2(0xDB,0xDC), o2(0xB7,0xE5), o2(0xB7,0xCB), o2(0xC5,0xED),
- o2(0xFA,0xCC), o2(0xDB,0xDA), o2(0xB0,0xC6), o2(0xDB,0xDD),
- o2(0xDB,0xDF), o2(0xB6,0xCD), o2(0xB7,0xAC), o2(0xFA,0xC9),
- o2(0xB4,0xBC), o2(0xB5,0xCB), o2(0xDB,0xE2), o2(0xBA,0xF9),
- o2(0xCB,0xF1), o2(0xBB,0xB7), o2(0xDB,0xE3), o2(0xC9,0xB0),
- o2(0xDB,0xEF), o2(0xB2,0xB3), o2(0xDB,0xE4), o2(0xDB,0xF5),
- o2(0xDB,0xE5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A1 = {
- to_SHIFT_JIS_E6_A1_offsets,
- to_EUC_JP_E6_A1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A2_infos[27] = {
- o2(0xCE,0xC2), o2(0xDB,0xEC), o2(0xC7,0xDF), o2(0xDB,0xF4),
- o2(0xDB,0xE7), o2(0xB0,0xB4), o2(0xDB,0xE9), o2(0xB9,0xBC),
- o2(0xDB,0xEB), o2(0xDB,0xEA), o2(0xDB,0xE6), o2(0xDB,0xF1),
- o2(0xBE,0xBF), o2(0xD4,0xED), o2(0xB8,0xE8), o2(0xCD,0xFC),
- o2(0xDB,0xE8), o2(0xC4,0xF4), o2(0xB3,0xA3), o2(0xBA,0xAD),
- o2(0xDB,0xE0), o2(0xDB,0xF0), o2(0xB3,0xE1), o2(0xDB,0xEE),
- o2(0xDB,0xF2), o2(0xC5,0xEE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A2 = {
- to_SHIFT_JIS_E6_A2_offsets,
- to_EUC_JP_E6_A2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A3_infos[25] = {
- o2(0xB4,0xFE), o2(0xDC,0xB2), o2(0xF9,0xA9), o2(0xCC,0xC9),
- o2(0xDB,0xF7), o2(0xB4,0xFD), o2(0xDB,0xFE), o2(0xFA,0xCD),
- o2(0xCB,0xC0), o2(0xDC,0xA1), o2(0xDC,0xA3), o2(0xDC,0xA7),
- o2(0xDB,0xF9), o2(0xC3,0xAA), o2(0xC5,0xEF), o2(0xDC,0xAB),
- o2(0xDB,0xFC), o2(0xDC,0xA8), o2(0xDC,0xA2), o2(0xBF,0xB9),
- o2(0xDC,0xAC), o2(0xC0,0xB3), o2(0xDC,0xAA), o2(0xB4,0xBD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A3 = {
- to_SHIFT_JIS_E6_A3_offsets,
- to_EUC_JP_E6_A3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A4_infos[29] = {
- o2(0xCF,0xD0), o2(0xDB,0xF6), o2(0xDC,0xA6), o2(0xB0,0xD8),
- o2(0xDB,0xF8), o2(0xCC,0xBA), o2(0xDB,0xFD), o2(0xBF,0xA2),
- o2(0xC4,0xC7), o2(0xDB,0xF3), o2(0xDC,0xA5), o2(0xBF,0xFA),
- o2(0xDC,0xAF), o2(0xB3,0xF1), o2(0xB8,0xA1), o2(0xDC,0xB1),
- o2(0xDB,0xFA), o2(0xDC,0xB0), o2(0xDC,0xA9), o2(0xDB,0xFB),
- o2(0xDC,0xAD), o2(0xDC,0xAE), o2(0xDC,0xBF), o2(0xC6,0xCE),
- o2(0xDC,0xA4), o2(0xDC,0xBB), o2(0xDC,0xBD), o2(0xC4,0xD8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A4 = {
- to_SHIFT_JIS_E6_A4_offsets,
- to_EUC_JP_E6_A4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A5_infos[28] = {
- o2(0xCD,0xCC), o2(0xC9,0xF6), o2(0xDC,0xB8), o2(0xC2,0xCA),
- o2(0xDC,0xBE), o2(0xC1,0xBF), o2(0xDC,0xB5), o2(0xDC,0xC2),
- o2(0xDC,0xC1), o2(0xC6,0xEF), o2(0xDC,0xC0), o2(0xC6,0xEA),
- o2(0xFA,0xCF), o2(0xDC,0xC4), o2(0xDC,0xB7), o2(0xB6,0xC8),
- o2(0xDC,0xBA), o2(0xBD,0xDD), o2(0xC7,0xE0), o2(0xDC,0xBC),
- o2(0xB6,0xCB), o2(0xDC,0xB4), o2(0xDC,0xB6), o2(0xDC,0xB3),
- o2(0xCF,0xB0), o2(0xB3,0xDA), o2(0xDC,0xB9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A5 = {
- to_SHIFT_JIS_E6_A5_offsets,
- to_EUC_JP_E6_A5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A6_infos[20] = {
- o2(0xDC,0xC3), o2(0xB3,0xB5), o2(0xBA,0xE7), o2(0xB1,0xDD),
- o2(0xDC,0xD4), o2(0xCF,0xB1), o2(0xDC,0xD7), o2(0xFA,0xD1),
- o2(0xBF,0xBA), o2(0xDC,0xD6), o2(0xDC,0xD5), o2(0xDC,0xD2),
- o2(0xDC,0xC6), o2(0xDC,0xE3), o2(0xDC,0xC5), o2(0xDC,0xD8),
- o2(0xDC,0xD0), o2(0xDC,0xCB), o2(0xDC,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A6 = {
- to_SHIFT_JIS_E6_A6_offsets,
- to_EUC_JP_E6_A6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A7_infos[25] = {
- o2(0xDC,0xC9), o2(0xDC,0xD1), o2(0xF4,0xA2), o2(0xDC,0xCE),
- o2(0xB9,0xBD), o2(0xC4,0xC8), o2(0xC1,0xE4), o2(0xDC,0xCC),
- o2(0xDC,0xC7), o2(0xDC,0xCA), o2(0xCD,0xCD), o2(0xCB,0xEA),
- o2(0xDC,0xCF), o2(0xDC,0xD9), o2(0xFA,0xD2), o2(0xDC,0xE1),
- o2(0xDC,0xDA), o2(0xDC,0xE7), o2(0xDC,0xE5), o2(0xDC,0xE0),
- o2(0xDC,0xDF), o2(0xC4,0xD0), o2(0xC1,0xE5), o2(0xDC,0xDD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A7 = {
- to_SHIFT_JIS_E6_A7_offsets,
- to_EUC_JP_E6_A7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A8_infos[28] = {
- o2(0xDC,0xDB), o2(0xDC,0xE2), o2(0xDC,0xE8), o2(0xC8,0xF5),
- o2(0xDC,0xEE), o2(0xDC,0xE9), o2(0xDC,0xEC), o2(0xDC,0xE6),
- o2(0xC3,0xF4), o2(0xC9,0xB8), o2(0xDC,0xDC), o2(0xDC,0xE4),
- o2(0xBE,0xC0), o2(0xCC,0xCF), o2(0xDC,0xF8), o2(0xDC,0xEB),
- o2(0xB8,0xA2), o2(0xB2,0xA3), o2(0xB3,0xDF), o2(0xDC,0xD3),
- o2(0xFA,0xD3), o2(0xBE,0xC1), o2(0xDC,0xF0), o2(0xDC,0xF7),
- o2(0xBC,0xF9), o2(0xB3,0xF2), o2(0xC3,0xAE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A8 = {
- to_SHIFT_JIS_E6_A8_offsets,
- to_EUC_JP_E6_A8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_A9_infos[18] = {
- o2(0xDC,0xED), o2(0xFA,0xD5), o2(0xDC,0xF2), o2(0xDC,0xF6),
- o2(0xB6,0xB6), o2(0xB5,0xCC), o2(0xDC,0xF4), o2(0xB5,0xA1),
- o2(0xC6,0xCB), o2(0xDC,0xF3), o2(0xDC,0xF5), o2(0xFA,0xD4),
- o2(0xDC,0xEF), o2(0xFA,0xD6), o2(0xDC,0xF1), o2(0xFA,0xD7),
- o2(0xB3,0xE0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_A9 = {
- to_SHIFT_JIS_E6_A9_offsets,
- to_EUC_JP_E6_A9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_AA_infos[17] = {
- o2(0xC3,0xC9), o2(0xDC,0xFC), o2(0xDC,0xFA), o2(0xB8,0xE9),
- o2(0xDC,0xF9), o2(0xDD,0xA1), o2(0xDB,0xD8), o2(0xDC,0xFB),
- o2(0xDC,0xFD), o2(0xDC,0xFE), o2(0xDD,0xAC), o2(0xDD,0xA8),
- o2(0xDB,0xED), o2(0xDD,0xA7), o2(0xDD,0xA6), o2(0xDD,0xA3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_AA = {
- to_SHIFT_JIS_E6_AA_offsets,
- to_EUC_JP_E6_AA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_AB_infos[16] = {
- o2(0xDC,0xEA), o2(0xDD,0xA5), o2(0xDD,0xA4), o2(0xDD,0xAA),
- o2(0xCF,0xA6), o2(0xDD,0xAD), o2(0xB6,0xFB), o2(0xDD,0xA9),
- o2(0xDD,0xAB), o2(0xFA,0xD8), o2(0xFA,0xD9), o2(0xC8,0xA7),
- o2(0xDD,0xAE), o2(0xDD,0xB2), o2(0xDD,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_AB = {
- to_SHIFT_JIS_E6_AB_offsets,
- to_EUC_JP_E6_AB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_AC_infos[19] = {
- o2(0xCD,0xF3), o2(0xDD,0xB0), o2(0xDC,0xDE), o2(0xDD,0xB3),
- o2(0xDD,0xB4), o2(0xB1,0xB5), o2(0xDD,0xB6), o2(0xB7,0xE7),
- o2(0xBC,0xA1), o2(0xB6,0xD5), o2(0xB2,0xA4), o2(0xCD,0xDF),
- o2(0xDD,0xB8), o2(0xDD,0xB7), o2(0xDD,0xBA), o2(0xB5,0xBD),
- o2(0xB6,0xD6), o2(0xB4,0xBE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_AC = {
- to_SHIFT_JIS_E6_AC_offsets,
- to_EUC_JP_E6_AC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_AD_infos[26] = {
- o2(0xDD,0xBD), o2(0xDD,0xBC), o2(0xDD,0xBE), o2(0xB2,0xCE),
- o2(0xC3,0xB7), o2(0xDD,0xBF), o2(0xB4,0xBF), o2(0xDD,0xC1),
- o2(0xDD,0xC0), o2(0xDD,0xC2), o2(0xDD,0xC3), o2(0xDD,0xC4),
- o2(0xBB,0xDF), o2(0xC0,0xB5), o2(0xBA,0xA1), o2(0xC9,0xF0),
- o2(0xCA,0xE2), o2(0xCF,0xC4), o2(0xBB,0xF5), o2(0xBA,0xD0),
- o2(0xCE,0xF2), o2(0xDD,0xC5), o2(0xDD,0xC6), o2(0xBB,0xE0),
- o2(0xDD,0xC7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_AD = {
- to_SHIFT_JIS_E6_AD_offsets,
- to_EUC_JP_E6_AD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_AE_infos[27] = {
- o2(0xDD,0xC8), o2(0xDD,0xCA), o2(0xDD,0xC9), o2(0xCB,0xD8),
- o2(0xBD,0xDE), o2(0xBC,0xEC), o2(0xBB,0xC4), o2(0xDD,0xCB),
- o2(0xDD,0xCD), o2(0xBF,0xA3), o2(0xDD,0xCC), o2(0xDD,0xCE),
- o2(0xDD,0xCF), o2(0xDD,0xD0), o2(0xDD,0xD1), o2(0xDD,0xD2),
- o2(0xDD,0xD4), o2(0xDD,0xD3), o2(0xDD,0xD5), o2(0xB2,0xA5),
- o2(0xC3,0xCA), o2(0xDD,0xD6), o2(0xBB,0xA6), o2(0xB3,0xCC),
- o2(0xDD,0xD7), o2(0xC5,0xC2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_AE = {
- to_SHIFT_JIS_E6_AE_offsets,
- to_EUC_JP_E6_AE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_AF_infos[18] = {
- o2(0xD4,0xCC), o2(0xB5,0xA3), o2(0xDD,0xD8), o2(0xDD,0xD9),
- o2(0xCA,0xEC), o2(0xCB,0xE8), o2(0xC6,0xC7), o2(0xDD,0xDA),
- o2(0xC8,0xE6), o2(0xFA,0xDA), o2(0xC8,0xFB), o2(0xCC,0xD3),
- o2(0xDD,0xDB), o2(0xDD,0xDD), o2(0xDD,0xDC), o2(0xDD,0xDF),
- o2(0xDD,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_AF = {
- to_SHIFT_JIS_E6_AF_offsets,
- to_EUC_JP_E6_AF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B0_infos[15] = {
- o2(0xDD,0xE1), o2(0xBB,0xE1), o2(0xCC,0xB1), o2(0xDD,0xE2),
- o2(0xDD,0xE3), o2(0xB5,0xA4), o2(0xDD,0xE4), o2(0xDD,0xE6),
- o2(0xDD,0xE5), o2(0xBF,0xE5), o2(0xC9,0xB9), o2(0xB1,0xCA),
- o2(0xC8,0xC5), o2(0xFA,0xDB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B0 = {
- to_SHIFT_JIS_E6_B0_offsets,
- to_EUC_JP_E6_B0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B1_infos[24] = {
- o2(0xC4,0xF5), o2(0xBD,0xC1), o2(0xB5,0xE1), o2(0xC8,0xC6),
- o2(0xBC,0xAE), o2(0xDD,0xE8), o2(0xB4,0xC0), o2(0xB1,0xF8),
- o2(0xFA,0xDC), o2(0xC6,0xF2), o2(0xDD,0xE7), o2(0xB9,0xBE),
- o2(0xC3,0xD3), o2(0xDD,0xE9), o2(0xDD,0xF1), o2(0xDD,0xEA),
- o2(0xFA,0xDE), o2(0xC2,0xC1), o2(0xB5,0xE2), o2(0xDD,0xF2),
- o2(0xB7,0xE8), o2(0xB5,0xA5), o2(0xDD,0xF0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B1 = {
- to_SHIFT_JIS_E6_B1_offsets,
- to_EUC_JP_E6_B1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B2_infos[29] = {
- o2(0xDD,0xEE), o2(0xDD,0xEB), o2(0xCD,0xE0), o2(0xFA,0xDD),
- o2(0xC4,0xC0), o2(0xC6,0xD9), o2(0xDD,0xEC), o2(0xDD,0xF4),
- o2(0xDD,0xF3), o2(0xB7,0xA3), o2(0xB2,0xAD), o2(0xBA,0xBB),
- o2(0xDD,0xED), o2(0xDD,0xEF), o2(0xCB,0xD7), o2(0xC2,0xF4),
- o2(0xCB,0xF7), o2(0xDD,0xFC), o2(0xDD,0xFD), o2(0xB2,0xCF),
- o2(0xCA,0xA8), o2(0xCC,0xFD), o2(0xDE,0xA1), o2(0xBC,0xA3),
- o2(0xBE,0xC2), o2(0xDD,0xF8), o2(0xDD,0xFE), o2(0xB1,0xE8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B2 = {
- to_SHIFT_JIS_E6_B2_offsets,
- to_EUC_JP_E6_B2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B3_infos[24] = {
- o2(0xB6,0xB7), o2(0xDD,0xF5), o2(0xDD,0xFA), o2(0xC0,0xF4),
- o2(0xC7,0xF1), o2(0xC8,0xE7), o2(0xDD,0xF7), o2(0xCB,0xA1),
- o2(0xDD,0xF9), o2(0xDE,0xA4), o2(0xFA,0xDF), o2(0xDE,0xA2),
- o2(0xDD,0xFB), o2(0xCB,0xA2), o2(0xC7,0xC8), o2(0xB5,0xE3),
- o2(0xC5,0xA5), o2(0xC3,0xED), o2(0xDE,0xA5), o2(0xDE,0xA3),
- o2(0xC2,0xD9), o2(0xDD,0xF6), o2(0xB1,0xCB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B3 = {
- to_SHIFT_JIS_E6_B3_offsets,
- to_EUC_JP_E6_B3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B4_infos[22] = {
- o2(0xFA,0xE0), o2(0xCD,0xCE), o2(0xDE,0xB0), o2(0xDE,0xAF),
- o2(0xC0,0xF6), o2(0xDE,0xAC), o2(0xCD,0xEC), o2(0xC6,0xB6),
- o2(0xDE,0xA6), o2(0xC4,0xC5), o2(0xB1,0xCC), o2(0xB9,0xBF),
- o2(0xDE,0xA9), o2(0xBD,0xA7), o2(0xDE,0xAE), o2(0xDE,0xAD),
- o2(0xDE,0xA8), o2(0xDE,0xAB), o2(0xB3,0xE8), o2(0xDE,0xAA),
- o2(0xC7,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B4 = {
- to_SHIFT_JIS_E6_B4_offsets,
- to_EUC_JP_E6_B4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B5_infos[19] = {
- o2(0xCE,0xAE), o2(0xBE,0xF4), o2(0xC0,0xF5), o2(0xDE,0xB6),
- o2(0xDE,0xB4), o2(0xC9,0xCD), o2(0xDE,0xB1), o2(0xDE,0xB3),
- o2(0xB1,0xBA), o2(0xB9,0xC0), o2(0xCF,0xB2), o2(0xB3,0xBD),
- o2(0xC9,0xE2), o2(0xFA,0xE2), o2(0xCD,0xE1), o2(0xB3,0xA4),
- o2(0xBF,0xBB), o2(0xDE,0xB5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B5 = {
- to_SHIFT_JIS_E6_B5_offsets,
- to_EUC_JP_E6_B5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B6_infos[18] = {
- o2(0xDE,0xBA), o2(0xFA,0xE1), o2(0xBE,0xC3), o2(0xCD,0xB0),
- o2(0xDE,0xB7), o2(0xDE,0xB2), o2(0xDE,0xB8), o2(0xFA,0xE3),
- o2(0xCE,0xDE), o2(0xC5,0xF3), o2(0xC6,0xC2), o2(0xFA,0xE4),
- o2(0xB3,0xB6), o2(0xB1,0xD5), o2(0xDE,0xBE), o2(0xDE,0xC1),
- o2(0xCE,0xC3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B6 = {
- to_SHIFT_JIS_E6_B6_offsets,
- to_EUC_JP_E6_B6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B7_infos[32] = {
- o2(0xCD,0xE4), o2(0xDE,0xC8), o2(0xDE,0xC2), o2(0xDE,0xBF),
- o2(0xCE,0xD4), o2(0xDE,0xC5), o2(0xFA,0xE5), o2(0xBD,0xCA),
- o2(0xDE,0xC7), o2(0xDE,0xCC), o2(0xC5,0xF1), o2(0xDE,0xCA),
- o2(0xDE,0xC4), o2(0xC3,0xB8), o2(0xDE,0xCB), o2(0xDE,0xC0),
- o2(0xDE,0xC6), o2(0xDE,0xCD), o2(0xB0,0xFC), o2(0xDE,0xC3),
- o2(0xDE,0xCE), o2(0xBF,0xBC), o2(0xFA,0xE7), o2(0xBD,0xDF),
- o2(0xCA,0xA5), o2(0xBA,0xAE), o2(0xFA,0xE6), o2(0xDE,0xBB),
- o2(0xDE,0xC9), o2(0xC5,0xBA), o2(0xFA,0xE8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B7 = {
- to_SHIFT_JIS_E6_B7_offsets,
- to_EUC_JP_E6_B7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B8_infos[32] = {
- o2(0xC0,0xB6), o2(0xB3,0xE9), o2(0xBA,0xD1), o2(0xBE,0xC4),
- o2(0xDE,0xBD), o2(0xBD,0xC2), o2(0xB7,0xCC), o2(0xDE,0xBC),
- o2(0xDE,0xD2), o2(0xBD,0xED), o2(0xB8,0xBA), o2(0xDE,0xE1),
- o2(0xDE,0xDB), o2(0xB5,0xF4), o2(0xC5,0xCF), o2(0xDE,0xD6),
- o2(0xDE,0xDF), o2(0xB0,0xAF), o2(0xB1,0xB2), o2(0xFA,0xEB),
- o2(0xB2,0xB9), o2(0xDE,0xD8), o2(0xC2,0xAC), o2(0xDE,0xCF),
- o2(0xDE,0xD1), o2(0xB9,0xC1), o2(0xDE,0xE2), o2(0xFA,0xE9),
- o2(0xDE,0xDD), o2(0xFA,0xEC), o2(0xDE,0xD5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B8 = {
- to_SHIFT_JIS_E6_B8_offsets,
- to_EUC_JP_E6_B8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_B9_infos[18] = {
- o2(0xDE,0xDC), o2(0xCC,0xAB), o2(0xDE,0xDA), o2(0xDE,0xDE),
- o2(0xB8,0xD0), o2(0xBE,0xC5), o2(0xC3,0xB9), o2(0xFA,0xEA),
- o2(0xDE,0xD4), o2(0xCD,0xAF), o2(0xDE,0xD7), o2(0xDE,0xD0),
- o2(0xC5,0xF2), o2(0xDE,0xD3), o2(0xDE,0xD9), o2(0xCF,0xD1),
- o2(0xBC,0xBE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_B9 = {
- to_SHIFT_JIS_E6_B9_offsets,
- to_EUC_JP_E6_B9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_BA_infos[21] = {
- o2(0xCB,0xFE), o2(0xDE,0xE3), o2(0xC8,0xAE), o2(0xDE,0xEF),
- o2(0xB8,0xBB), o2(0xBD,0xE0), o2(0xDE,0xE5), o2(0xCE,0xAF),
- o2(0xB9,0xC2), o2(0xDE,0xF2), o2(0xB0,0xEE), o2(0xDE,0xF0),
- o2(0xDE,0xE4), o2(0xDE,0xEA), o2(0xDE,0xEC), o2(0xCD,0xCF),
- o2(0xDE,0xE7), o2(0xC5,0xAE), o2(0xDE,0xE9), o2(0xFA,0xED),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_BA = {
- to_SHIFT_JIS_E6_BA_offsets,
- to_EUC_JP_E6_BA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_BB_infos[21] = {
- o2(0xDE,0xF1), o2(0xDE,0xEB), o2(0xCC,0xC7), o2(0xDE,0xE6),
- o2(0xBC,0xA2), o2(0xDE,0xFE), o2(0xB3,0xEA), o2(0xDE,0xE8),
- o2(0xDE,0xED), o2(0xDE,0xEE), o2(0xC2,0xEC), o2(0xC2,0xDA),
- o2(0xDE,0xF6), o2(0xDE,0xFC), o2(0xDE,0xFA), o2(0xC5,0xA9),
- o2(0xDF,0xA3), o2(0xDE,0xF7), o2(0xDE,0xF8), o2(0xDE,0xE0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_BB = {
- to_SHIFT_JIS_E6_BB_offsets,
- to_EUC_JP_E6_BB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_BC_infos[20] = {
- o2(0xB5,0xF9), o2(0xC9,0xBA), o2(0xBC,0xBF), o2(0xB9,0xF7),
- o2(0xCF,0xB3), o2(0xDE,0xF4), o2(0xDF,0xA2), o2(0xB1,0xE9),
- o2(0xC1,0xE6), o2(0xC7,0xF9), o2(0xB4,0xC1), o2(0xCE,0xFA),
- o2(0xCC,0xA1), o2(0xC4,0xD2), o2(0xDE,0xFB), o2(0xDE,0xFD),
- o2(0xC1,0xB2), o2(0xDF,0xA1), o2(0xDE,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_BC = {
- to_SHIFT_JIS_E6_BC_offsets,
- to_EUC_JP_E6_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_BD_infos[18] = {
- o2(0xDE,0xF3), o2(0xB4,0xC3), o2(0xB7,0xE9), o2(0xDF,0xAF),
- o2(0xDF,0xAA), o2(0xC0,0xF8), o2(0xB3,0xE3), o2(0xBD,0xE1),
- o2(0xDF,0xB3), o2(0xDF,0xAC), o2(0xC4,0xAC), o2(0xDF,0xA9),
- o2(0xC4,0xD9), o2(0xDF,0xCC), o2(0xDF,0xA6), o2(0xDF,0xA5),
- o2(0xDF,0xAE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_BD = {
- to_SHIFT_JIS_E6_BD_offsets,
- to_EUC_JP_E6_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_BE_infos[18] = {
- o2(0xDF,0xA8), o2(0xDF,0xA7), o2(0xDF,0xAD), o2(0xC0,0xA1),
- o2(0xDF,0xA4), o2(0xFA,0xEE), o2(0xDF,0xB0), o2(0xDF,0xB1),
- o2(0xB4,0xC2), o2(0xDF,0xB6), o2(0xDF,0xB5), o2(0xDF,0xB7),
- o2(0xDF,0xBA), o2(0xC5,0xC3), o2(0xDF,0xB4), o2(0xFA,0xEF),
- o2(0xDF,0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_BE = {
- to_SHIFT_JIS_E6_BE_offsets,
- to_EUC_JP_E6_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_BF_infos[24] = {
- o2(0xB7,0xE3), o2(0xC2,0xF9), o2(0xDF,0xB2), o2(0xC7,0xBB),
- o2(0xDF,0xB9), o2(0xDF,0xBE), o2(0xDF,0xBC), o2(0xDF,0xBF),
- o2(0xDF,0xC2), o2(0xDF,0xBB), o2(0xB9,0xEA), o2(0xC7,0xA8),
- o2(0xDE,0xB9), o2(0xCD,0xF4), o2(0xDF,0xBD), o2(0xDF,0xC1),
- o2(0xC2,0xF5), o2(0xDF,0xC0), o2(0xDF,0xAB), o2(0xFA,0xF0),
- o2(0xEF,0xE9), o2(0xDF,0xC5), o2(0xDF,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6_BF = {
- to_SHIFT_JIS_E6_BF_offsets,
- to_EUC_JP_E6_BF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E6_infos[64] = {
- &to_EUC_JP_E6_80, &to_EUC_JP_E6_81, &to_EUC_JP_E6_82, &to_EUC_JP_E6_83,
- &to_EUC_JP_E6_84, &to_EUC_JP_E6_85, &to_EUC_JP_E6_86, &to_EUC_JP_E6_87,
- &to_EUC_JP_E6_88, &to_EUC_JP_E6_89, &to_EUC_JP_E6_8A, &to_EUC_JP_E6_8B,
- &to_EUC_JP_E6_8C, &to_EUC_JP_E6_8D, &to_EUC_JP_E6_8E, &to_EUC_JP_E6_8F,
- &to_EUC_JP_E6_90, &to_EUC_JP_E6_91, &to_EUC_JP_E6_92, &to_EUC_JP_E6_93,
- &to_EUC_JP_E6_94, &to_EUC_JP_E6_95, &to_EUC_JP_E6_96, &to_EUC_JP_E6_97,
- &to_EUC_JP_E6_98, &to_EUC_JP_E6_99, &to_EUC_JP_E6_9A, &to_EUC_JP_E6_9B,
- &to_EUC_JP_E6_9C, &to_EUC_JP_E6_9D, &to_EUC_JP_E6_9E, &to_EUC_JP_E6_9F,
- &to_EUC_JP_E6_A0, &to_EUC_JP_E6_A1, &to_EUC_JP_E6_A2, &to_EUC_JP_E6_A3,
- &to_EUC_JP_E6_A4, &to_EUC_JP_E6_A5, &to_EUC_JP_E6_A6, &to_EUC_JP_E6_A7,
- &to_EUC_JP_E6_A8, &to_EUC_JP_E6_A9, &to_EUC_JP_E6_AA, &to_EUC_JP_E6_AB,
- &to_EUC_JP_E6_AC, &to_EUC_JP_E6_AD, &to_EUC_JP_E6_AE, &to_EUC_JP_E6_AF,
- &to_EUC_JP_E6_B0, &to_EUC_JP_E6_B1, &to_EUC_JP_E6_B2, &to_EUC_JP_E6_B3,
- &to_EUC_JP_E6_B4, &to_EUC_JP_E6_B5, &to_EUC_JP_E6_B6, &to_EUC_JP_E6_B7,
- &to_EUC_JP_E6_B8, &to_EUC_JP_E6_B9, &to_EUC_JP_E6_BA, &to_EUC_JP_E6_BB,
- &to_EUC_JP_E6_BC, &to_EUC_JP_E6_BD, &to_EUC_JP_E6_BE, &to_EUC_JP_E6_BF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E6 = {
- to_SHIFT_JIS_E5_offsets,
- to_EUC_JP_E6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_80_infos[22] = {
- o2(0xDF,0xC7), o2(0xFA,0xF1), o2(0xFA,0xF2), o2(0xDF,0xC3),
- o2(0xDF,0xC4), o2(0xDF,0xC8), o2(0xDF,0xC6), o2(0xC9,0xCE),
- o2(0xDF,0xCE), o2(0xDF,0xCB), o2(0xDF,0xCA), o2(0xDF,0xCD),
- o2(0xC6,0xD4), o2(0xDF,0xCF), o2(0xC3,0xF5), o2(0xC2,0xED),
- o2(0xFA,0xF3), o2(0xC0,0xA5), o2(0xDF,0xD0), o2(0xDF,0xD2),
- o2(0xDF,0xD1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_80 = {
- to_SHIFT_JIS_E7_80_offsets,
- to_EUC_JP_E7_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_81_infos[11] = {
- o2(0xDE,0xF5), o2(0xDF,0xD3), o2(0xC6,0xE7), o2(0xDF,0xD4),
- o2(0xB2,0xD0), o2(0xC5,0xF4), o2(0xB3,0xA5), o2(0xB5,0xE4),
- o2(0xBC,0xDE), o2(0xBA,0xD2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_81 = {
- to_SHIFT_JIS_E7_81_offsets,
- to_EUC_JP_E7_81_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_82_infos[17] = {
- o2(0xFA,0xF4), o2(0xCF,0xA7), o2(0xBF,0xE6), o2(0xB1,0xEA),
- o2(0xDF,0xD6), o2(0xDF,0xD5), o2(0xFA,0xF5), o2(0xDF,0xD9),
- o2(0xC3,0xBA), o2(0xDF,0xDC), o2(0xDF,0xD7), o2(0xDF,0xDB),
- o2(0xDF,0xDA), o2(0xC5,0xC0), o2(0xB0,0xD9), o2(0xF9,0xA7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_82 = {
- to_SHIFT_JIS_E7_82_offsets,
- to_EUC_JP_E7_82_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_83_infos[10] = {
- o2(0xCE,0xF5), o2(0xDF,0xDE), o2(0xB1,0xA8), o2(0xDF,0xE0),
- o2(0xDF,0xDF), o2(0xDF,0xDD), o2(0xDF,0xD8), o2(0xCB,0xA3),
- o2(0xDF,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_83 = {
- to_SHIFT_JIS_E7_83_offsets,
- to_EUC_JP_E7_83_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_84_infos[12] = {
- o2(0xFA,0xF7), o2(0xDF,0xE1), o2(0xFA,0xF6), o2(0xB1,0xEB),
- o2(0xDF,0xE4), o2(0xCA,0xB2), o2(0xDF,0xE3), o2(0xCC,0xB5),
- o2(0xBE,0xC7), o2(0xC1,0xB3), o2(0xBE,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_84 = {
- to_SHIFT_JIS_E7_84_offsets,
- to_EUC_JP_E7_84_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_85_infos[19] = {
- o2(0xFA,0xF9), o2(0xFA,0xFA), o2(0xCE,0xFB), o2(0xDF,0xEA),
- o2(0xC0,0xF9), o2(0xDF,0xE6), o2(0xDF,0xEB), o2(0xB1,0xEC),
- o2(0xFA,0xF8), o2(0xDF,0xE9), o2(0xC7,0xE1), o2(0xDF,0xE5),
- o2(0xDF,0xE8), o2(0xBE,0xC8), o2(0xC8,0xD1), o2(0xDF,0xEC),
- o2(0xBC,0xD1), o2(0xC0,0xFA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_85 = {
- to_SHIFT_JIS_E7_85_offsets,
- to_EUC_JP_E7_85_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_86_infos[14] = {
- o2(0xDF,0xEF), o2(0xDF,0xE7), o2(0xB7,0xA7), o2(0xDF,0xED),
- o2(0xCD,0xD0), o2(0xDF,0xF0), o2(0xF4,0xA6), o2(0xBD,0xCF),
- o2(0xDF,0xF1), o2(0xDF,0xF2), o2(0xC7,0xAE), o2(0xDF,0xF4),
- o2(0xDF,0xF5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_86 = {
- to_SHIFT_JIS_E7_86_offsets,
- to_EUC_JP_E7_86_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_87_infos[25] = {
- o2(0xFA,0xFC), o2(0xC7,0xB3), o2(0xC5,0xF5), o2(0xDF,0xF7),
- o2(0xDF,0xF9), o2(0xCE,0xD5), o2(0xDF,0xF6), o2(0xDF,0xF8),
- o2(0xB1,0xED), o2(0xDF,0xF3), o2(0xD3,0xDB), o2(0xDF,0xFA),
- o2(0xC1,0xE7), o2(0xBB,0xB8), o2(0xDF,0xFC), o2(0xDF,0xFB),
- o2(0xBF,0xA4), o2(0xD2,0xD9), o2(0xDF,0xFD), o2(0xE0,0xA1),
- o2(0xDF,0xEE), o2(0xDF,0xFE), o2(0xFA,0xFD), o2(0xE0,0xA2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_87 = {
- to_SHIFT_JIS_E7_87_offsets,
- to_EUC_JP_E7_87_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_88_infos[19] = {
- o2(0xC7,0xFA), o2(0xE0,0xA3), o2(0xE0,0xA4), o2(0xE0,0xA5),
- o2(0xE0,0xA6), o2(0xC4,0xDE), o2(0xE0,0xA8), o2(0xE0,0xA7),
- o2(0xE0,0xA9), o2(0xE0,0xAA), o2(0xBC,0xDF), o2(0xC9,0xE3),
- o2(0xCC,0xEC), o2(0xE0,0xAB), o2(0xE0,0xAC), o2(0xC1,0xD6),
- o2(0xBC,0xA4), o2(0xE0,0xAD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_88 = {
- to_SHIFT_JIS_E7_88_offsets,
- to_EUC_JP_E7_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_89_infos[22] = {
- o2(0xE0,0xAE), o2(0xE0,0xAF), o2(0xCA,0xD2), o2(0xC8,0xC7),
- o2(0xE0,0xB0), o2(0xC7,0xD7), o2(0xC4,0xAD), o2(0xE0,0xB1),
- o2(0xB2,0xE7), o2(0xB5,0xED), o2(0xCC,0xC6), o2(0xCC,0xB6),
- o2(0xB2,0xB4), o2(0xCF,0xB4), o2(0xCB,0xD2), o2(0xCA,0xAA),
- o2(0xC0,0xB7), o2(0xE0,0xB2), o2(0xC6,0xC3), o2(0xB8,0xA3),
- o2(0xE0,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_89 = {
- to_SHIFT_JIS_E7_89_offsets,
- to_EUC_JP_E7_89_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_8A_infos[17] = {
- o2(0xBA,0xD4), o2(0xE0,0xB5), o2(0xE0,0xB4), o2(0xE0,0xB6),
- o2(0xE0,0xB7), o2(0xE0,0xB8), o2(0xB5,0xBE), o2(0xE0,0xB9),
- o2(0xE0,0xBA), o2(0xB8,0xA4), o2(0xC8,0xC8), o2(0xFA,0xFE),
- o2(0xE0,0xBC), o2(0xBE,0xF5), o2(0xE0,0xBB), o2(0xFB,0xA1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_8A = {
- to_SHIFT_JIS_E7_8A_offsets,
- to_EUC_JP_E7_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_8B_infos[22] = {
- o2(0xB6,0xB8), o2(0xE0,0xBD), o2(0xE0,0xBF), o2(0xE0,0xBE),
- o2(0xE0,0xC0), o2(0xB8,0xD1), o2(0xE0,0xC1), o2(0xB6,0xE9),
- o2(0xC1,0xC0), o2(0xB9,0xFD), o2(0xE0,0xC3), o2(0xE0,0xC4),
- o2(0xE0,0xC2), o2(0xBC,0xED), o2(0xC6,0xC8), o2(0xB6,0xB9),
- o2(0xE0,0xC6), o2(0xC3,0xAC), o2(0xE0,0xC5), o2(0xCF,0xB5),
- o2(0xC7,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_8B = {
- to_SHIFT_JIS_E7_8B_offsets,
- to_EUC_JP_E7_8B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_8C_infos[20] = {
- o2(0xE0,0xC9), o2(0xE0,0xCB), o2(0xE0,0xC8), o2(0xCC,0xD4),
- o2(0xE0,0xCA), o2(0xE0,0xCC), o2(0xCE,0xC4), o2(0xFB,0xA2),
- o2(0xE0,0xD0), o2(0xE0,0xCF), o2(0xC3,0xF6), o2(0xC7,0xAD),
- o2(0xB8,0xA5), o2(0xE0,0xCE), o2(0xE0,0xCD), o2(0xCD,0xB1),
- o2(0xCD,0xB2), o2(0xE0,0xD1), o2(0xB1,0xEE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_8C = {
- to_SHIFT_JIS_E7_8C_offsets,
- to_EUC_JP_E7_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_8D_infos[16] = {
- o2(0xB9,0xF6), o2(0xBB,0xE2), o2(0xE0,0xD2), o2(0xE0,0xD3),
- o2(0xE0,0xD5), o2(0xBD,0xC3), o2(0xE0,0xD7), o2(0xE0,0xD6),
- o2(0xE0,0xD8), o2(0xB3,0xCD), o2(0xE0,0xDA), o2(0xFB,0xA4),
- o2(0xE0,0xD9), o2(0xE0,0xDC), o2(0xE0,0xDB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_8D = {
- to_SHIFT_JIS_E7_8D_offsets,
- to_EUC_JP_E7_8D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_8E_infos[11] = {
- o2(0xB8,0xBC), o2(0xCE,0xA8), o2(0xB6,0xCC), o2(0xB2,0xA6),
- o2(0xB6,0xEA), o2(0xB4,0xE1), o2(0xCE,0xE8), o2(0xE0,0xDE),
- o2(0xE0,0xE0), o2(0xFB,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_8E = {
- to_SHIFT_JIS_E7_8E_offsets,
- to_EUC_JP_E7_8E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_8F_infos[21] = {
- o2(0xE0,0xE1), o2(0xB2,0xD1), o2(0xE0,0xDD), o2(0xFB,0xA6),
- o2(0xBB,0xB9), o2(0xC4,0xC1), o2(0xE0,0xDF), o2(0xFB,0xA9),
- o2(0xFB,0xA7), o2(0xE0,0xE4), o2(0xBC,0xEE), o2(0xFB,0xA8),
- o2(0xE0,0xE2), o2(0xB7,0xBE), o2(0xC8,0xC9), o2(0xE0,0xE3),
- o2(0xE0,0xFE), o2(0xFB,0xAB), o2(0xE0,0xE9), o2(0xB8,0xBD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_8F = {
- to_SHIFT_JIS_E7_8F_offsets,
- to_EUC_JP_E7_8F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_90_infos[19] = {
- o2(0xB5,0xE5), o2(0xE0,0xE6), o2(0xCD,0xFD), o2(0xFB,0xAA),
- o2(0xCE,0xB0), o2(0xC2,0xF6), o2(0xE0,0xE8), o2(0xFB,0xAC),
- o2(0xFB,0xAE), o2(0xFB,0xAD), o2(0xFB,0xAF), o2(0xE0,0xEA),
- o2(0xCE,0xD6), o2(0xB6,0xD7), o2(0xC8,0xFC), o2(0xC7,0xCA),
- o2(0xE0,0xEB), o2(0xE0,0xED), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_90 = {
- to_SHIFT_JIS_E7_90_offsets,
- to_EUC_JP_E7_90_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_91_infos[20] = {
- o2(0xE0,0xF0), o2(0xE0,0xEC), o2(0xE0,0xEF), o2(0xB8,0xEA),
- o2(0xB1,0xCD), o2(0xE0,0xF1), o2(0xBF,0xF0), o2(0xE0,0xEE),
- o2(0xCE,0xDC), o2(0xFB,0xB0), o2(0xE0,0xF4), o2(0xF4,0xA4),
- o2(0xE0,0xF2), o2(0xE0,0xF5), o2(0xE0,0xE7), o2(0xE0,0xF3),
- o2(0xBA,0xBC), o2(0xE0,0xF6), o2(0xE0,0xF7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_91 = {
- to_SHIFT_JIS_E7_91_offsets,
- to_EUC_JP_E7_91_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_92_infos[10] = {
- o2(0xCD,0xFE), o2(0xFB,0xB1), o2(0xE0,0xF8), o2(0xE0,0xF9),
- o2(0xFB,0xB2), o2(0xE0,0xE5), o2(0xE0,0xFA), o2(0xB4,0xC4),
- o2(0xBC,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_92 = {
- to_SHIFT_JIS_E7_92_offsets,
- to_EUC_JP_E7_92_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_93_infos[18] = {
- o2(0xE0,0xFB), o2(0xE0,0xFC), o2(0xE0,0xFD), o2(0xB1,0xBB),
- o2(0xE1,0xA1), o2(0xC9,0xBB), o2(0xE1,0xA2), o2(0xB4,0xA4),
- o2(0xE1,0xA3), o2(0xE1,0xA4), o2(0xE1,0xA5), o2(0xE1,0xA7),
- o2(0xE1,0xA8), o2(0xE1,0xA6), o2(0xC9,0xD3), o2(0xE1,0xAA),
- o2(0xE1,0xA9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_93 = {
- to_SHIFT_JIS_E7_93_offsets,
- to_EUC_JP_E7_93_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_94_infos[32] = {
- o2(0xFB,0xB3), o2(0xE1,0xAC), o2(0xE1,0xAB), o2(0xE1,0xAD),
- o2(0xE1,0xAE), o2(0xE1,0xB0), o2(0xE1,0xAF), o2(0xB9,0xF9),
- o2(0xE1,0xB2), o2(0xE1,0xB1), o2(0xB4,0xC5), o2(0xBF,0xD3),
- o2(0xC5,0xBC), o2(0xE1,0xB3), o2(0xC0,0xB8), o2(0xBB,0xBA),
- o2(0xB1,0xF9), o2(0xE1,0xB4), o2(0xCD,0xD1), o2(0xCA,0xE3),
- o2(0xE1,0xB5), o2(0xF9,0xEC), o2(0xC5,0xC4), o2(0xCD,0xB3),
- o2(0xB9,0xC3), o2(0xBF,0xBD), o2(0xC3,0xCB), o2(0xD2,0xB4),
- o2(0xC4,0xAE), o2(0xB2,0xE8), o2(0xE1,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_94 = {
- to_SHIFT_JIS_E7_94_offsets,
- to_EUC_JP_E7_94_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_95_infos[34] = {
- o2(0xE1,0xB7), o2(0xE1,0xBC), o2(0xE1,0xBA), o2(0xE1,0xB9),
- o2(0xDA,0xC2), o2(0xB3,0xA6), o2(0xE1,0xB8), o2(0xB0,0xDA),
- o2(0xC8,0xAA), o2(0xC8,0xCA), o2(0xCE,0xB1), o2(0xE1,0xBD),
- o2(0xE1,0xBB), o2(0xC3,0xDC), o2(0xC0,0xA6), o2(0xC8,0xAB),
- o2(0xC9,0xAD), o2(0xE1,0xBF), o2(0xCE,0xAC), o2(0xB7,0xCD),
- o2(0xE1,0xC0), o2(0xE1,0xBE), o2(0xC8,0xD6), o2(0xE1,0xC1),
- o2(0xE1,0xC2), o2(0xFB,0xB4), o2(0xB0,0xDB), o2(0xBE,0xF6),
- o2(0xE1,0xC7), o2(0xE1,0xC4), o2(0xC6,0xED), o2(0xE1,0xC3),
- o2(0xB5,0xA6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_95 = {
- to_SHIFT_JIS_E7_95_offsets,
- to_EUC_JP_E7_95_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_96_infos[25] = {
- o2(0xE1,0xCA), o2(0xE1,0xC5), o2(0xE1,0xC6), o2(0xE1,0xC9),
- o2(0xE1,0xC8), o2(0xC9,0xA5), o2(0xC1,0xC2), o2(0xC1,0xC1),
- o2(0xB5,0xBF), o2(0xE1,0xCB), o2(0xE1,0xCC), o2(0xE1,0xCD),
- o2(0xE1,0xCF), o2(0xE1,0xCE), o2(0xB1,0xD6), o2(0xE1,0xD7),
- o2(0xC8,0xE8), o2(0xE1,0xD1), o2(0xE1,0xD3), o2(0xE1,0xD5),
- o2(0xBF,0xBE), o2(0xE1,0xD6), o2(0xE1,0xD4), o2(0xBC,0xC0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_96 = {
- to_SHIFT_JIS_E7_96_offsets,
- to_EUC_JP_E7_96_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_97_infos[25] = {
- o2(0xE1,0xD0), o2(0xE1,0xD2), o2(0xC9,0xC2), o2(0xBE,0xC9),
- o2(0xE1,0xD9), o2(0xE1,0xD8), o2(0xE1,0xDA), o2(0xBC,0xA6),
- o2(0xBA,0xAF), o2(0xC5,0xF7), o2(0xE1,0xDB), o2(0xC4,0xCB),
- o2(0xE1,0xDD), o2(0xCE,0xA1), o2(0xE1,0xDC), o2(0xC1,0xE9),
- o2(0xE1,0xE2), o2(0xE1,0xE4), o2(0xE1,0xE5), o2(0xC3,0xD4),
- o2(0xE1,0xE3), o2(0xE1,0xE0), o2(0xE1,0xDE), o2(0xE1,0xDF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_97 = {
- to_SHIFT_JIS_E7_97_offsets,
- to_EUC_JP_E7_97_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_98_infos[14] = {
- o2(0xE1,0xE1), o2(0xE1,0xE8), o2(0xE1,0xE6), o2(0xE1,0xE7),
- o2(0xE1,0xE9), o2(0xE1,0xEB), o2(0xE1,0xEC), o2(0xE1,0xED),
- o2(0xE1,0xEE), o2(0xE1,0xEA), o2(0xE1,0xF0), o2(0xE1,0xEF),
- o2(0xE1,0xF1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_98 = {
- to_SHIFT_JIS_E7_98_offsets,
- to_EUC_JP_E7_98_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_99_infos[26] = {
- o2(0xCE,0xC5), o2(0xE1,0xF4), o2(0xE1,0xF2), o2(0xE1,0xF3),
- o2(0xB4,0xE2), o2(0xCC,0xFE), o2(0xCA,0xCA), o2(0xE1,0xF6),
- o2(0xE1,0xF5), o2(0xE1,0xF7), o2(0xE1,0xF8), o2(0xE1,0xFC),
- o2(0xE1,0xF9), o2(0xE1,0xFA), o2(0xE1,0xFB), o2(0xE1,0xFD),
- o2(0xE1,0xFE), o2(0xE2,0xA1), o2(0xE2,0xA2), o2(0xE2,0xA3),
- o2(0xC8,0xAF), o2(0xC5,0xD0), o2(0xE2,0xA4), o2(0xC7,0xF2),
- o2(0xC9,0xB4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_99 = {
- to_SHIFT_JIS_E7_99_offsets,
- to_EUC_JP_E7_99_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_9A_infos[27] = {
- o2(0xE2,0xA5), o2(0xFB,0xB5), o2(0xE2,0xA6), o2(0xC5,0xAA),
- o2(0xB3,0xA7), o2(0xB9,0xC4), o2(0xE2,0xA7), o2(0xE2,0xA8),
- o2(0xE2,0xA9), o2(0xBB,0xA9), o2(0xE2,0xAB), o2(0xE2,0xAA),
- o2(0xE2,0xAC), o2(0xE2,0xAD), o2(0xFB,0xB8), o2(0xFB,0xB6),
- o2(0xFB,0xB7), o2(0xFB,0xB9), o2(0xC8,0xE9), o2(0xE2,0xAE),
- o2(0xE2,0xAF), o2(0xF3,0xE9), o2(0xE2,0xB0), o2(0xE2,0xB1),
- o2(0xE2,0xB2), o2(0xBB,0xAE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_9A = {
- to_SHIFT_JIS_E7_9A_offsets,
- to_EUC_JP_E7_9A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_9B_infos[26] = {
- o2(0xE2,0xB3), o2(0xC7,0xD6), o2(0xCB,0xDF), o2(0xB1,0xCE),
- o2(0xB1,0xD7), o2(0xE2,0xB4), o2(0xE2,0xB6), o2(0xE2,0xB5),
- o2(0xC5,0xF0), o2(0xC0,0xB9), o2(0xDD,0xB9), o2(0xE2,0xB7),
- o2(0xCC,0xC1), o2(0xE2,0xB8), o2(0xB4,0xC6), o2(0xC8,0xD7),
- o2(0xE2,0xB9), o2(0xE2,0xBA), o2(0xE2,0xBB), o2(0xCC,0xDC),
- o2(0xCC,0xD5), o2(0xC4,0xBE), o2(0xC1,0xEA), o2(0xE2,0xBD),
- o2(0xBD,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_9B = {
- to_SHIFT_JIS_E7_9B_offsets,
- to_EUC_JP_E7_9B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_9C_infos[20] = {
- o2(0xBE,0xCA), o2(0xE2,0xC0), o2(0xE2,0xBF), o2(0xE2,0xBE),
- o2(0xC8,0xFD), o2(0xB4,0xC7), o2(0xB8,0xA9), o2(0xE2,0xC6),
- o2(0xE2,0xC3), o2(0xBF,0xBF), o2(0xCC,0xB2), o2(0xE2,0xC2),
- o2(0xE2,0xC4), o2(0xE2,0xC5), o2(0xE2,0xC1), o2(0xE2,0xC7),
- o2(0xE2,0xC8), o2(0xC4,0xAF), o2(0xB4,0xE3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_9C = {
- to_SHIFT_JIS_E7_9C_offsets,
- to_EUC_JP_E7_9C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_9D_infos[15] = {
- o2(0xC3,0xE5), o2(0xFB,0xBB), o2(0xE2,0xC9), o2(0xE2,0xCA),
- o2(0xE2,0xCD), o2(0xBF,0xE7), o2(0xC6,0xC4), o2(0xE2,0xCE),
- o2(0xCB,0xD3), o2(0xE2,0xCB), o2(0xE2,0xCC), o2(0xE2,0xD1),
- o2(0xE2,0xD0), o2(0xE2,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_9D = {
- to_SHIFT_JIS_E7_9D_offsets,
- to_EUC_JP_E7_9D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_9E_infos[17] = {
- o2(0xE2,0xD3), o2(0xE2,0xD2), o2(0xE2,0xD4), o2(0xE2,0xD6),
- o2(0xE2,0xD5), o2(0xCA,0xCD), o2(0xBD,0xD6), o2(0xCE,0xC6),
- o2(0xE2,0xD7), o2(0xC6,0xB7), o2(0xE2,0xD8), o2(0xE2,0xD9),
- o2(0xE2,0xDD), o2(0xE2,0xDB), o2(0xE2,0xDC), o2(0xE2,0xDA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_9E = {
- to_SHIFT_JIS_E7_9E_offsets,
- to_EUC_JP_E7_9E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_9F_infos[17] = {
- o2(0xE2,0xDE), o2(0xE2,0xDF), o2(0xE2,0xE0), o2(0xE2,0xE1),
- o2(0xCC,0xB7), o2(0xE2,0xE2), o2(0xCC,0xF0), o2(0xE2,0xE3),
- o2(0xC3,0xCE), o2(0xC7,0xEA), o2(0xB6,0xEB), o2(0xC3,0xBB),
- o2(0xE2,0xE4), o2(0xB6,0xBA), o2(0xC0,0xD0), o2(0xE2,0xE5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_9F = {
- to_SHIFT_JIS_E7_9F_offsets,
- to_EUC_JP_E7_9F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A0_infos[15] = {
- o2(0xBA,0xBD), o2(0xE2,0xE6), o2(0xE2,0xE7), o2(0xB8,0xA6),
- o2(0xBA,0xD5), o2(0xE2,0xE9), o2(0xFB,0xBD), o2(0xC5,0xD6),
- o2(0xBA,0xD6), o2(0xB5,0xCE), o2(0xCB,0xA4), o2(0xC7,0xCB),
- o2(0xC5,0xD7), o2(0xB9,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A0 = {
- to_SHIFT_JIS_E7_A0_offsets,
- to_EUC_JP_E7_A0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A1_infos[12] = {
- o2(0xE2,0xEB), o2(0xFB,0xBE), o2(0xBE,0xCB), o2(0xFB,0xBF),
- o2(0xCE,0xB2), o2(0xB9,0xC5), o2(0xB8,0xA7), o2(0xC8,0xA3),
- o2(0xE2,0xED), o2(0xFB,0xC0), o2(0xE2,0xEF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A1 = {
- to_SHIFT_JIS_E7_A1_offsets,
- to_EUC_JP_E7_A1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A2_infos[21] = {
- o2(0xB8,0xEB), o2(0xE2,0xEE), o2(0xC4,0xF6), o2(0xE2,0xF1),
- o2(0xB3,0xB7), o2(0xE2,0xEC), o2(0xC8,0xEA), o2(0xB1,0xB0),
- o2(0xBA,0xEC), o2(0xCF,0xD2), o2(0xE2,0xF0), o2(0xE2,0xF2),
- o2(0xCA,0xCB), o2(0xC0,0xD9), o2(0xE2,0xF4), o2(0xE2,0xF5),
- o2(0xE2,0xF3), o2(0xB3,0xCE), o2(0xE2,0xFB), o2(0xE2,0xFA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A2 = {
- to_SHIFT_JIS_E7_A2_offsets,
- to_EUC_JP_E7_A2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A3_infos[16] = {
- o2(0xBC,0xA7), o2(0xE2,0xFC), o2(0xE2,0xF7), o2(0xE2,0xFD),
- o2(0xE2,0xF8), o2(0xC8,0xD8), o2(0xE2,0xF6), o2(0xE2,0xF9),
- o2(0xE3,0xA2), o2(0xE3,0xA1), o2(0xCB,0xE1), o2(0xE2,0xFE),
- o2(0xB0,0xEB), o2(0xE3,0xA4), o2(0xE3,0xA3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A3 = {
- to_SHIFT_JIS_E7_A3_offsets,
- to_EUC_JP_E7_A3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A4_infos[15] = {
- o2(0xBE,0xCC), o2(0xE3,0xA5), o2(0xC1,0xC3), o2(0xE3,0xA7),
- o2(0xE3,0xA6), o2(0xE3,0xA8), o2(0xE2,0xE8), o2(0xE2,0xEA),
- o2(0xE3,0xAA), o2(0xE3,0xA9), o2(0xFB,0xC1), o2(0xBC,0xA8),
- o2(0xCE,0xE9), o2(0xBC,0xD2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A4 = {
- to_SHIFT_JIS_E7_A4_offsets,
- to_EUC_JP_E7_A4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A5_infos[23] = {
- o2(0xE3,0xAB), o2(0xB7,0xB7), o2(0xB5,0xC0), o2(0xB5,0xA7),
- o2(0xBB,0xE3), o2(0xCD,0xB4), o2(0xE3,0xB1), o2(0xE3,0xB0),
- o2(0xC1,0xC4), o2(0xE3,0xAD), o2(0xE3,0xAF), o2(0xBD,0xCB),
- o2(0xBF,0xC0), o2(0xE3,0xAE), o2(0xE3,0xAC), o2(0xC7,0xAA),
- o2(0xBE,0xCD), o2(0xC9,0xBC), o2(0xBA,0xD7), o2(0xC5,0xF8),
- o2(0xE3,0xB2), o2(0xE3,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A5 = {
- to_SHIFT_JIS_E7_A5_offsets,
- to_EUC_JP_E7_A5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A6_infos[23] = {
- o2(0xE3,0xC9), o2(0xB6,0xD8), o2(0xCF,0xBD), o2(0xC1,0xB5),
- o2(0xE3,0xB4), o2(0xB2,0xD2), o2(0xC4,0xF7), o2(0xCA,0xA1),
- o2(0xFB,0xC5), o2(0xFB,0xC7), o2(0xE3,0xB5), o2(0xB5,0xFA),
- o2(0xE3,0xB6), o2(0xE3,0xB8), o2(0xE3,0xB9), o2(0xC7,0xA9),
- o2(0xE3,0xBA), o2(0xE3,0xBB), o2(0xE3,0xBC), o2(0xB6,0xD9),
- o2(0xB2,0xD3), o2(0xC6,0xC5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A6 = {
- to_SHIFT_JIS_E7_A6_offsets,
- to_EUC_JP_E7_A6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A7_infos[19] = {
- o2(0xBD,0xA8), o2(0xBB,0xE4), o2(0xE3,0xBD), o2(0xBD,0xA9),
- o2(0xB2,0xCA), o2(0xC9,0xC3), o2(0xE3,0xBE), o2(0xC8,0xEB),
- o2(0xC1,0xC5), o2(0xE3,0xC1), o2(0xE3,0xC2), o2(0xC7,0xE9),
- o2(0xBF,0xC1), o2(0xE3,0xBF), o2(0xC3,0xE1), o2(0xE3,0xC0),
- o2(0xBE,0xCE), o2(0xB0,0xDC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A7 = {
- to_SHIFT_JIS_E7_A7_offsets,
- to_EUC_JP_E7_A7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A8_infos[23] = {
- o2(0xB5,0xA9), o2(0xE3,0xC3), o2(0xC4,0xF8), o2(0xE3,0xC4),
- o2(0xC0,0xC7), o2(0xCC,0xAD), o2(0xC9,0xA3), o2(0xE3,0xC5),
- o2(0xE3,0xC6), o2(0xC3,0xD5), o2(0xCE,0xC7), o2(0xE3,0xC8),
- o2(0xE3,0xC7), o2(0xBC,0xEF), o2(0xE3,0xCA), o2(0xB0,0xF0),
- o2(0xE3,0xCD), o2(0xE3,0xCB), o2(0xB2,0xD4), o2(0xB7,0xCE),
- o2(0xE3,0xCC), o2(0xB9,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A8 = {
- to_SHIFT_JIS_E7_A8_offsets,
- to_EUC_JP_E7_A8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_A9_infos[23] = {
- o2(0xB9,0xF2), o2(0xCA,0xE6), o2(0xE3,0xCE), o2(0xCB,0xD4),
- o2(0xE3,0xD0), o2(0xC0,0xD1), o2(0xB1,0xCF), o2(0xB2,0xBA),
- o2(0xB0,0xAC), o2(0xE3,0xCF), o2(0xE3,0xD1), o2(0xE3,0xD2),
- o2(0xBE,0xF7), o2(0xE3,0xD3), o2(0xB3,0xCF), o2(0xE3,0xD5),
- o2(0xB7,0xEA), o2(0xB5,0xE6), o2(0xE3,0xD6), o2(0xB6,0xF5),
- o2(0xE3,0xD7), o2(0xC0,0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_A9 = {
- to_SHIFT_JIS_E7_A9_offsets,
- to_EUC_JP_E7_A9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_AA_infos[20] = {
- o2(0xC6,0xCD), o2(0xC0,0xE0), o2(0xBA,0xF5), o2(0xE3,0xD8),
- o2(0xC3,0xE2), o2(0xC1,0xEB), o2(0xE3,0xDA), o2(0xE3,0xDC),
- o2(0xE3,0xD9), o2(0xE3,0xDB), o2(0xB7,0xA2), o2(0xE3,0xDD),
- o2(0xB7,0xA6), o2(0xB5,0xE7), o2(0xCD,0xD2), o2(0xE3,0xDF),
- o2(0xE3,0xE0), o2(0xB1,0xAE), o2(0xE3,0xE3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_AA = {
- to_SHIFT_JIS_E7_AA_offsets,
- to_EUC_JP_E7_AA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_AB_infos[36] = {
- o2(0xB3,0xF6), o2(0xE3,0xE2), o2(0xE3,0xE1), o2(0xE3,0xE5),
- o2(0xE3,0xDE), o2(0xE3,0xE6), o2(0xCE,0xA9), o2(0xE3,0xE7),
- o2(0xE3,0xE8), o2(0xFB,0xC8), o2(0xD4,0xF4), o2(0xE3,0xEA),
- o2(0xE3,0xE9), o2(0xE3,0xEB), o2(0xE3,0xEC), o2(0xCE,0xB5),
- o2(0xE3,0xED), o2(0xF0,0xEF), o2(0xBE,0xCF), o2(0xE3,0xEE),
- o2(0xE3,0xEF), o2(0xBD,0xD7), o2(0xC6,0xB8), o2(0xE3,0xF0),
- o2(0xFB,0xC9), o2(0xC3,0xA8), o2(0xFB,0xCB), o2(0xE3,0xF1),
- o2(0xC3,0xBC), o2(0xE3,0xF2), o2(0xB6,0xA5), o2(0xD1,0xBF),
- o2(0xC3,0xDD), o2(0xBC,0xB3), o2(0xB4,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_AB = {
- to_SHIFT_JIS_E7_AB_offsets,
- to_EUC_JP_E7_AB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_AC_infos[22] = {
- o2(0xE3,0xF3), o2(0xE4,0xA2), o2(0xE3,0xF6), o2(0xB5,0xE8),
- o2(0xE3,0xF5), o2(0xE4,0xA4), o2(0xE3,0xF4), o2(0xBE,0xD0),
- o2(0xE3,0xF8), o2(0xE3,0xF9), o2(0xC5,0xAB), o2(0xE3,0xFA),
- o2(0xB3,0xDE), o2(0xBF,0xDA), o2(0xC9,0xE4), o2(0xE3,0xFC),
- o2(0xC2,0xE8), o2(0xE3,0xF7), o2(0xE3,0xFB), o2(0xE3,0xFD),
- o2(0xBA,0xFB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_AC = {
- to_SHIFT_JIS_E7_AC_offsets,
- to_EUC_JP_E7_AC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_AD_infos[24] = {
- o2(0xE4,0xA6), o2(0xC9,0xAE), o2(0xC8,0xA6), o2(0xC5,0xF9),
- o2(0xB6,0xDA), o2(0xE4,0xA5), o2(0xE4,0xA3), o2(0xC8,0xB5),
- o2(0xE3,0xFE), o2(0xC3,0xDE), o2(0xC5,0xFB), o2(0xC5,0xFA),
- o2(0xBA,0xF6), o2(0xE4,0xB8), o2(0xE4,0xA8), o2(0xE4,0xAA),
- o2(0xE4,0xAD), o2(0xE4,0xAE), o2(0xE4,0xAB), o2(0xE4,0xAC),
- o2(0xE4,0xA9), o2(0xE4,0xA7), o2(0xE4,0xA1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_AD = {
- to_SHIFT_JIS_E7_AD_offsets,
- to_EUC_JP_E7_AD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_AE_infos[23] = {
- o2(0xCA,0xCF), o2(0xB2,0xD5), o2(0xE4,0xB5), o2(0xE4,0xB2),
- o2(0xE4,0xB7), o2(0xE4,0xB6), o2(0xC7,0xF3), o2(0xCC,0xA7),
- o2(0xBB,0xBB), o2(0xE4,0xB0), o2(0xE4,0xB9), o2(0xE4,0xB4),
- o2(0xE4,0xB3), o2(0xE4,0xAF), o2(0xFB,0xCC), o2(0xE4,0xB1),
- o2(0xB4,0xC9), o2(0xC3,0xBD), o2(0xC0,0xFD), o2(0xC8,0xA2),
- o2(0xE4,0xBE), o2(0xC8,0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_AE = {
- to_SHIFT_JIS_E7_AE_offsets,
- to_EUC_JP_E7_AE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_AF_infos[20] = {
- o2(0xC0,0xE1), o2(0xE4,0xBB), o2(0xC8,0xCF), o2(0xE4,0xBF),
- o2(0xCA,0xD3), o2(0xC3,0xDB), o2(0xE4,0xBA), o2(0xE4,0xBC),
- o2(0xE4,0xBD), o2(0xE4,0xC0), o2(0xBC,0xC4), o2(0xC6,0xC6),
- o2(0xE4,0xC5), o2(0xE4,0xC4), o2(0xE4,0xC1), o2(0xCF,0xB6),
- o2(0xE4,0xCA), o2(0xE4,0xCE), o2(0xE4,0xCB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_AF = {
- to_SHIFT_JIS_E7_AF_offsets,
- to_EUC_JP_E7_AF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B0_infos[20] = {
- o2(0xE4,0xC7), o2(0xE4,0xC8), o2(0xE4,0xCD), o2(0xE4,0xC2),
- o2(0xD2,0xD5), o2(0xE4,0xC9), o2(0xE4,0xC3), o2(0xE4,0xCC),
- o2(0xE4,0xD2), o2(0xB4,0xCA), o2(0xE4,0xCF), o2(0xE4,0xD0),
- o2(0xE4,0xD1), o2(0xE4,0xD4), o2(0xE4,0xD3), o2(0xC8,0xF6),
- o2(0xE4,0xD5), o2(0xCE,0xFC), o2(0xCA,0xED), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B0 = {
- to_SHIFT_JIS_E7_B0_offsets,
- to_EUC_JP_E7_B0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B1_infos[18] = {
- o2(0xE4,0xDA), o2(0xE4,0xD7), o2(0xE4,0xD6), o2(0xC0,0xD2),
- o2(0xE4,0xD9), o2(0xE4,0xDB), o2(0xE4,0xD8), o2(0xE4,0xDF),
- o2(0xE4,0xDC), o2(0xE4,0xDD), o2(0xE4,0xC6), o2(0xE4,0xDE),
- o2(0xE4,0xE0), o2(0xE4,0xE1), o2(0xCA,0xC6), o2(0xE4,0xE2),
- o2(0xCC,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B1 = {
- to_SHIFT_JIS_E7_B1_offsets,
- to_EUC_JP_E7_B1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B2_infos[29] = {
- o2(0xB6,0xCE), o2(0xB7,0xA9), o2(0xE4,0xE3), o2(0xCA,0xB4),
- o2(0xBF,0xE8), o2(0xCC,0xB0), o2(0xE4,0xE4), o2(0xCE,0xB3),
- o2(0xC7,0xF4), o2(0xC1,0xC6), o2(0xC7,0xB4), o2(0xBD,0xCD),
- o2(0xB0,0xC0), o2(0xE4,0xE9), o2(0xE4,0xE7), o2(0xE4,0xE5),
- o2(0xB4,0xA1), o2(0xBE,0xD1), o2(0xE4,0xEA), o2(0xE4,0xE8),
- o2(0xE4,0xE6), o2(0xE4,0xEE), o2(0xE4,0xED), o2(0xE4,0xEC),
- o2(0xE4,0xEB), o2(0xE4,0xEF), o2(0xE4,0xF0), o2(0xC0,0xBA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B2 = {
- to_SHIFT_JIS_E7_B2_offsets,
- to_EUC_JP_E7_B2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B3_infos[23] = {
- o2(0xE4,0xF1), o2(0xE4,0xF3), o2(0xE4,0xF2), o2(0xB8,0xD2),
- o2(0xC1,0xB8), o2(0xE4,0xF5), o2(0xC5,0xFC), o2(0xE4,0xF4),
- o2(0xE4,0xF6), o2(0xCA,0xB5), o2(0xC1,0xEC), o2(0xB9,0xC7),
- o2(0xE4,0xF7), o2(0xCE,0xC8), o2(0xE4,0xF9), o2(0xE4,0xFA),
- o2(0xE4,0xFB), o2(0xE4,0xFC), o2(0xBB,0xE5), o2(0xE4,0xFD),
- o2(0xB7,0xCF), o2(0xB5,0xEA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B3 = {
- to_SHIFT_JIS_E7_B3_offsets,
- to_EUC_JP_E7_B3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B4_infos[32] = {
- o2(0xB5,0xAA), o2(0xE5,0xA1), o2(0xCC,0xF3), o2(0xB9,0xC8),
- o2(0xE4,0xFE), o2(0xE5,0xA4), o2(0xCC,0xE6), o2(0xC7,0xBC),
- o2(0xC9,0xB3), o2(0xBD,0xE3), o2(0xE5,0xA3), o2(0xBC,0xD3),
- o2(0xB9,0xC9), o2(0xBB,0xE6), o2(0xB5,0xE9), o2(0xCA,0xB6),
- o2(0xE5,0xA2), o2(0xC1,0xC7), o2(0xCB,0xC2), o2(0xBA,0xF7),
- o2(0xBB,0xE7), o2(0xC4,0xDD), o2(0xE5,0xA7), o2(0xCE,0xDF),
- o2(0xBA,0xD9), o2(0xE5,0xA8), o2(0xBF,0xC2), o2(0xE5,0xAA),
- o2(0xBE,0xD2), o2(0xBA,0xB0), o2(0xE5,0xA9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B4 = {
- to_SHIFT_JIS_E7_B4_offsets,
- to_EUC_JP_E7_B4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B5_infos[29] = {
- o2(0xBD,0xAA), o2(0xB8,0xBE), o2(0xC1,0xC8), o2(0xE5,0xA5),
- o2(0xE5,0xAB), o2(0xFB,0xCE), o2(0xE5,0xA6), o2(0xB7,0xD0),
- o2(0xE5,0xAE), o2(0xE5,0xB2), o2(0xB7,0xEB), o2(0xE5,0xAD),
- o2(0xE5,0xB6), o2(0xFB,0xCF), o2(0xB9,0xCA), o2(0xCD,0xED),
- o2(0xB0,0xBC), o2(0xE5,0xB3), o2(0xB5,0xEB), o2(0xE5,0xB0),
- o2(0xE5,0xB1), o2(0xC5,0xFD), o2(0xE5,0xAF), o2(0xE5,0xAC),
- o2(0xB3,0xA8), o2(0xC0,0xE4), o2(0xB8,0xA8), o2(0xE5,0xB8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B5 = {
- to_SHIFT_JIS_E7_B5_offsets,
- to_EUC_JP_E7_B5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B6_infos[29] = {
- o2(0xE5,0xB5), o2(0xE5,0xB7), o2(0xE5,0xB4), o2(0xB7,0xD1),
- o2(0xC2,0xB3), o2(0xE5,0xB9), o2(0xC1,0xEE), o2(0xE5,0xC6),
- o2(0xFB,0xD1), o2(0xE5,0xC2), o2(0xE5,0xBC), o2(0xE5,0xC0),
- o2(0xBC,0xFA), o2(0xB0,0xDD), o2(0xE5,0xBB), o2(0xE5,0xC3),
- o2(0xE5,0xC7), o2(0xB9,0xCB), o2(0xCC,0xD6), o2(0xC4,0xD6),
- o2(0xE5,0xBD), o2(0xFB,0xD0), o2(0xE5,0xC5), o2(0xE5,0xBA),
- o2(0xC3,0xBE), o2(0xE5,0xBF), o2(0xB0,0xBD), o2(0xCC,0xCA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B6 = {
- to_SHIFT_JIS_E7_B6_offsets,
- to_EUC_JP_E7_B6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B7_infos[24] = {
- o2(0xE5,0xBE), o2(0xB6,0xDB), o2(0xC8,0xEC), o2(0xC1,0xED),
- o2(0xCE,0xD0), o2(0xBD,0xEF), o2(0xE5,0xEE), o2(0xFB,0xD2),
- o2(0xE5,0xC8), o2(0xC0,0xFE), o2(0xE5,0xC4), o2(0xE5,0xC9),
- o2(0xE5,0xCB), o2(0xC4,0xF9), o2(0xE5,0xCE), o2(0xE5,0xCA),
- o2(0xCA,0xD4), o2(0xB4,0xCB), o2(0xCC,0xCB), o2(0xB0,0xDE),
- o2(0xE5,0xCD), o2(0xCE,0xFD), o2(0xE5,0xCC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B7 = {
- to_SHIFT_JIS_E7_B7_offsets,
- to_EUC_JP_E7_B7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B8_infos[26] = {
- o2(0xB1,0xEF), o2(0xC6,0xEC), o2(0xE5,0xCF), o2(0xE5,0xD6),
- o2(0xE5,0xD0), o2(0xE5,0xD7), o2(0xE5,0xD3), o2(0xC7,0xFB),
- o2(0xBC,0xCA), o2(0xE5,0xD5), o2(0xE5,0xD2), o2(0xE5,0xD8),
- o2(0xE5,0xD1), o2(0xBD,0xC4), o2(0xCB,0xA5), o2(0xBD,0xCC),
- o2(0xE5,0xD4), o2(0xE5,0xE0), o2(0xE5,0xDC), o2(0xE5,0xDF),
- o2(0xE5,0xDD), o2(0xE5,0xE1), o2(0xE5,0xDB), o2(0xE5,0xC1),
- o2(0xC0,0xD3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B8 = {
- to_SHIFT_JIS_E7_B8_offsets,
- to_EUC_JP_E7_B8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_B9_infos[26] = {
- o2(0xC8,0xCB), o2(0xE5,0xDE), o2(0xE5,0xD9), o2(0xC1,0xA1),
- o2(0xB7,0xD2), o2(0xBD,0xAB), o2(0xFB,0xD3), o2(0xBF,0xA5),
- o2(0xC1,0xB6), o2(0xE5,0xE4), o2(0xE5,0xE6), o2(0xE5,0xE7),
- o2(0xE5,0xE3), o2(0xE5,0xE5), o2(0xE5,0xDA), o2(0xE5,0xE2),
- o2(0xE5,0xEA), o2(0xE5,0xE9), o2(0xCB,0xFA), o2(0xB7,0xAB),
- o2(0xE5,0xE8), o2(0xE5,0xEC), o2(0xE5,0xEB), o2(0xE5,0xEF),
- o2(0xE5,0xF1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_B9 = {
- to_SHIFT_JIS_E7_B9_offsets,
- to_EUC_JP_E7_B9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_BA_infos[16] = {
- o2(0xBB,0xBC), o2(0xE5,0xED), o2(0xE5,0xF2), o2(0xE5,0xF3),
- o2(0xF9,0xA1), o2(0xE5,0xF4), o2(0xE5,0xFA), o2(0xC5,0xBB),
- o2(0xE5,0xF6), o2(0xE5,0xF5), o2(0xE5,0xF7), o2(0xE5,0xF8),
- o2(0xE5,0xF9), o2(0xE5,0xFB), o2(0xE5,0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_BA = {
- to_SHIFT_JIS_E7_BA_offsets,
- to_EUC_JP_E7_BA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_BC_infos[4] = {
- o2(0xB4,0xCC), o2(0xE5,0xFD), o2(0xE5,0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_BC = {
- to_SHIFT_JIS_E7_BC_offsets,
- to_EUC_JP_E7_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_BD_infos[25] = {
- o2(0xE6,0xA1), o2(0xFB,0xD4), o2(0xE6,0xA2), o2(0xE6,0xA3),
- o2(0xE6,0xA4), o2(0xE6,0xA5), o2(0xE6,0xA6), o2(0xE6,0xA8),
- o2(0xE6,0xA7), o2(0xE6,0xA9), o2(0xE6,0xAA), o2(0xE6,0xAB),
- o2(0xE6,0xAE), o2(0xE6,0xAC), o2(0xE6,0xAD), o2(0xBA,0xE1),
- o2(0xB7,0xD3), o2(0xC3,0xD6), o2(0xC8,0xB3), o2(0xBD,0xF0),
- o2(0xC7,0xCD), o2(0xC8,0xED), o2(0xE6,0xAF), o2(0xD8,0xED),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_BD = {
- to_SHIFT_JIS_E7_BD_offsets,
- to_EUC_JP_E7_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_BE_infos[26] = {
- o2(0xE6,0xB0), o2(0xE6,0xB2), o2(0xCD,0xE5), o2(0xE6,0xB1),
- o2(0xE6,0xB4), o2(0xE6,0xB3), o2(0xCD,0xD3), o2(0xE6,0xB5),
- o2(0xC8,0xFE), o2(0xE6,0xB6), o2(0xE6,0xB9), o2(0xE6,0xB8),
- o2(0xE6,0xB7), o2(0xFB,0xD5), o2(0xE6,0xBA), o2(0xB7,0xB2),
- o2(0xC1,0xA2), o2(0xB5,0xC1), o2(0xE6,0xBE), o2(0xE6,0xBB),
- o2(0xE6,0xBC), o2(0xE6,0xBF), o2(0xE6,0xC0), o2(0xE6,0xBD),
- o2(0xB1,0xA9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_BE = {
- to_SHIFT_JIS_E7_BE_offsets,
- to_EUC_JP_E7_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_BF_infos[19] = {
- o2(0xB2,0xA7), o2(0xE6,0xC2), o2(0xE6,0xC3), o2(0xE6,0xC4),
- o2(0xCD,0xE2), o2(0xBD,0xAC), o2(0xE6,0xC6), o2(0xE6,0xC5),
- o2(0xBF,0xE9), o2(0xE6,0xC7), o2(0xE6,0xC8), o2(0xE6,0xC9),
- o2(0xB4,0xE5), o2(0xB4,0xCD), o2(0xE6,0xCA), o2(0xE6,0xCB),
- o2(0xCB,0xDD), o2(0xCD,0xE3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7_BF = {
- to_SHIFT_JIS_E7_BF_offsets,
- to_EUC_JP_E7_BF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E7_infos[64] = {
- &to_EUC_JP_E7_80, &to_EUC_JP_E7_81, &to_EUC_JP_E7_82, &to_EUC_JP_E7_83,
- &to_EUC_JP_E7_84, &to_EUC_JP_E7_85, &to_EUC_JP_E7_86, &to_EUC_JP_E7_87,
- &to_EUC_JP_E7_88, &to_EUC_JP_E7_89, &to_EUC_JP_E7_8A, &to_EUC_JP_E7_8B,
- &to_EUC_JP_E7_8C, &to_EUC_JP_E7_8D, &to_EUC_JP_E7_8E, &to_EUC_JP_E7_8F,
- &to_EUC_JP_E7_90, &to_EUC_JP_E7_91, &to_EUC_JP_E7_92, &to_EUC_JP_E7_93,
- &to_EUC_JP_E7_94, &to_EUC_JP_E7_95, &to_EUC_JP_E7_96, &to_EUC_JP_E7_97,
- &to_EUC_JP_E7_98, &to_EUC_JP_E7_99, &to_EUC_JP_E7_9A, &to_EUC_JP_E7_9B,
- &to_EUC_JP_E7_9C, &to_EUC_JP_E7_9D, &to_EUC_JP_E7_9E, &to_EUC_JP_E7_9F,
- &to_EUC_JP_E7_A0, &to_EUC_JP_E7_A1, &to_EUC_JP_E7_A2, &to_EUC_JP_E7_A3,
- &to_EUC_JP_E7_A4, &to_EUC_JP_E7_A5, &to_EUC_JP_E7_A6, &to_EUC_JP_E7_A7,
- &to_EUC_JP_E7_A8, &to_EUC_JP_E7_A9, &to_EUC_JP_E7_AA, &to_EUC_JP_E7_AB,
- &to_EUC_JP_E7_AC, &to_EUC_JP_E7_AD, &to_EUC_JP_E7_AE, &to_EUC_JP_E7_AF,
- &to_EUC_JP_E7_B0, &to_EUC_JP_E7_B1, &to_EUC_JP_E7_B2, &to_EUC_JP_E7_B3,
- &to_EUC_JP_E7_B4, &to_EUC_JP_E7_B5, &to_EUC_JP_E7_B6, &to_EUC_JP_E7_B7,
- &to_EUC_JP_E7_B8, &to_EUC_JP_E7_B9, &to_EUC_JP_E7_BA, &to_EUC_JP_E7_BC,
- &to_EUC_JP_E7_BD, &to_EUC_JP_E7_BE, &to_EUC_JP_E7_BF, UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E7 = {
- to_SHIFT_JIS_E7_offsets,
- to_EUC_JP_E7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_80_infos[23] = {
- o2(0xCD,0xD4), o2(0xCF,0xB7), o2(0xB9,0xCD), o2(0xE6,0xCE),
- o2(0xBC,0xD4), o2(0xE6,0xCD), o2(0xE6,0xCF), o2(0xBC,0xA9),
- o2(0xC2,0xD1), o2(0xE6,0xD0), o2(0xB9,0xCC), o2(0xCC,0xD7),
- o2(0xE6,0xD1), o2(0xE6,0xD2), o2(0xE6,0xD3), o2(0xE6,0xD4),
- o2(0xE6,0xD5), o2(0xBC,0xAA), o2(0xCC,0xED), o2(0xE6,0xD7),
- o2(0xC3,0xBF), o2(0xE6,0xD6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_80 = {
- to_SHIFT_JIS_E8_80_offsets,
- to_EUC_JP_E8_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_81_infos[23] = {
- o2(0xE6,0xD9), o2(0xE6,0xD8), o2(0xE6,0xDA), o2(0xC0,0xBB),
- o2(0xE6,0xDB), o2(0xE6,0xDC), o2(0xCA,0xB9), o2(0xE6,0xDD),
- o2(0xC1,0xEF), o2(0xE6,0xDE), o2(0xE6,0xDF), o2(0xCE,0xFE),
- o2(0xE6,0xE2), o2(0xE6,0xE1), o2(0xE6,0xE0), o2(0xC4,0xB0),
- o2(0xE6,0xE3), o2(0xBF,0xA6), o2(0xE6,0xE4), o2(0xE6,0xE5),
- o2(0xCF,0xB8), o2(0xE6,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_81 = {
- to_SHIFT_JIS_E8_81_offsets,
- to_EUC_JP_E8_81_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_82_infos[26] = {
- o2(0xE6,0xE7), o2(0xE6,0xE9), o2(0xE6,0xE8), o2(0xC8,0xA5),
- o2(0xC6,0xF9), o2(0xCF,0xBE), o2(0xC8,0xA9), o2(0xE6,0xEB),
- o2(0xBE,0xD3), o2(0xC9,0xAA), o2(0xE6,0xEC), o2(0xE6,0xEA),
- o2(0xB4,0xCE), o2(0xB8,0xD4), o2(0xBB,0xE8), o2(0xC8,0xEE),
- o2(0xB8,0xAA), o2(0xCB,0xC3), o2(0xE6,0xEF), o2(0xE6,0xED),
- o2(0xB9,0xCE), o2(0xB9,0xCF), o2(0xB0,0xE9), o2(0xBA,0xE8),
- o2(0xC7,0xD9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_82 = {
- to_SHIFT_JIS_E8_82_offsets,
- to_EUC_JP_E8_82_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_83_infos[21] = {
- o2(0xB0,0xDF), o2(0xE6,0xF4), o2(0xC3,0xC0), o2(0xC7,0xD8),
- o2(0xC2,0xDB), o2(0xE6,0xF6), o2(0xE6,0xF2), o2(0xE6,0xF5),
- o2(0xE6,0xF0), o2(0xE6,0xF3), o2(0xCB,0xA6), o2(0xB8,0xD5),
- o2(0xB0,0xFD), o2(0xE6,0xF1), o2(0xE6,0xF8), o2(0xE6,0xF9),
- o2(0xC6,0xB9), o2(0xB6,0xBB), o2(0xE7,0xA6), o2(0xC7,0xBD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_83 = {
- to_SHIFT_JIS_E8_83_offsets,
- to_EUC_JP_E8_83_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_84_infos[17] = {
- o2(0xBB,0xE9), o2(0xB6,0xBC), o2(0xC0,0xC8), o2(0xCF,0xC6),
- o2(0xCC,0xAE), o2(0xE6,0xF7), o2(0xC0,0xD4), o2(0xB5,0xD3),
- o2(0xE6,0xFA), o2(0xE6,0xFC), o2(0xE6,0xFB), o2(0xE6,0xFD),
- o2(0xC3,0xA6), o2(0xC7,0xBE), o2(0xC4,0xB1), o2(0xE7,0xA3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_84 = {
- to_SHIFT_JIS_E8_84_offsets,
- to_EUC_JP_E8_84_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_85_infos[21] = {
- o2(0xE7,0xA2), o2(0xE6,0xFE), o2(0xBF,0xD5), o2(0xC9,0xE5),
- o2(0xE7,0xA5), o2(0xE7,0xA4), o2(0xB9,0xD0), o2(0xCF,0xD3),
- o2(0xE7,0xB5), o2(0xE7,0xA9), o2(0xE7,0xAA), o2(0xBC,0xF0),
- o2(0xE7,0xA8), o2(0xB9,0xF8), o2(0xE7,0xA7), o2(0xE7,0xAB),
- o2(0xC4,0xB2), o2(0xCA,0xA2), o2(0xC1,0xA3), o2(0xC2,0xDC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_85 = {
- to_SHIFT_JIS_E8_85_offsets,
- to_EUC_JP_E8_85_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_86_infos[25] = {
- o2(0xE7,0xAF), o2(0xE7,0xB0), o2(0xE7,0xAC), o2(0xE7,0xAD),
- o2(0xE7,0xAE), o2(0xB9,0xD1), o2(0xE7,0xB6), o2(0xE7,0xB2),
- o2(0xC9,0xE6), o2(0xCB,0xEC), o2(0xC9,0xA8), o2(0xE7,0xB1),
- o2(0xE7,0xB4), o2(0xE7,0xB3), o2(0xCB,0xC4), o2(0xE7,0xB7),
- o2(0xE7,0xB8), o2(0xC1,0xB7), o2(0xE7,0xB9), o2(0xE7,0xBB),
- o2(0xE7,0xBF), o2(0xE7,0xBC), o2(0xE7,0xBA), o2(0xC7,0xBF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_86 = {
- to_SHIFT_JIS_E8_86_offsets,
- to_EUC_JP_E8_86_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_87_infos[26] = {
- o2(0xE7,0xBD), o2(0xE7,0xBE), o2(0xB2,0xB2), o2(0xE7,0xC5),
- o2(0xE7,0xC0), o2(0xE7,0xC1), o2(0xE7,0xC2), o2(0xC2,0xA1),
- o2(0xE7,0xC4), o2(0xE7,0xC3), o2(0xE7,0xC6), o2(0xE7,0xC7),
- o2(0xE7,0xC8), o2(0xBF,0xC3), o2(0xB2,0xE9), o2(0xE7,0xC9),
- o2(0xCE,0xD7), o2(0xBC,0xAB), o2(0xBD,0xAD), o2(0xBB,0xEA),
- o2(0xC3,0xD7), o2(0xE7,0xCA), o2(0xE7,0xCB), o2(0xB1,0xB1),
- o2(0xE7,0xCC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_87 = {
- to_SHIFT_JIS_E8_87_offsets,
- to_EUC_JP_E8_87_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_88_infos[31] = {
- o2(0xE7,0xCD), o2(0xE7,0xCE), o2(0xE7,0xCF), o2(0xE7,0xD0),
- o2(0xB6,0xBD), o2(0xDA,0xAA), o2(0xE7,0xD1), o2(0xC0,0xE5),
- o2(0xE7,0xD2), o2(0xBC,0xCB), o2(0xE7,0xD3), o2(0xD0,0xB0),
- o2(0xE7,0xD4), o2(0xCA,0xDE), o2(0xB4,0xDC), o2(0xC1,0xA4),
- o2(0xBD,0xD8), o2(0xC9,0xF1), o2(0xBD,0xAE), o2(0xE7,0xD5),
- o2(0xB9,0xD2), o2(0xE7,0xD6), o2(0xC8,0xCC), o2(0xE7,0xE4),
- o2(0xE7,0xD8), o2(0xC2,0xC9), o2(0xC7,0xF5), o2(0xB8,0xBF),
- o2(0xE7,0xD7), o2(0xC1,0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_88 = {
- to_SHIFT_JIS_E8_88_offsets,
- to_EUC_JP_E8_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_89_infos[22] = {
- o2(0xE7,0xD9), o2(0xC4,0xFA), o2(0xE7,0xDB), o2(0xE7,0xDA),
- o2(0xE7,0xDD), o2(0xE7,0xDC), o2(0xE7,0xDE), o2(0xE7,0xE0),
- o2(0xE7,0xDF), o2(0xB4,0xCF), o2(0xE7,0xE1), o2(0xE7,0xE2),
- o2(0xE7,0xE3), o2(0xBA,0xB1), o2(0xCE,0xC9), o2(0xE7,0xE5),
- o2(0xBF,0xA7), o2(0xB1,0xF0), o2(0xE7,0xE6), o2(0xE7,0xE7),
- o2(0xE7,0xE8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_89 = {
- to_SHIFT_JIS_E8_89_offsets,
- to_EUC_JP_E8_89_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_8A_infos[19] = {
- o2(0xB0,0xF2), o2(0xE7,0xE9), o2(0xE7,0xEA), o2(0xC9,0xE7),
- o2(0xBC,0xC7), o2(0xE7,0xEC), o2(0xB3,0xA9), o2(0xB0,0xB2),
- o2(0xE7,0xEB), o2(0xE7,0xEE), o2(0xC7,0xCE), o2(0xBF,0xC4),
- o2(0xB2,0xD6), o2(0xCB,0xA7), o2(0xB7,0xDD), o2(0xB6,0xDC),
- o2(0xE7,0xED), o2(0xB2,0xEA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_8A = {
- to_SHIFT_JIS_E8_8A_offsets,
- to_EUC_JP_E8_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_8B_infos[24] = {
- o2(0xB4,0xA3), o2(0xB1,0xF1), o2(0xE7,0xF2), o2(0xCE,0xEA),
- o2(0xC2,0xDD), o2(0xC9,0xC4), o2(0xE7,0xFE), o2(0xB2,0xD7),
- o2(0xE7,0xFC), o2(0xE7,0xFA), o2(0xE7,0xF1), o2(0xE7,0xEF),
- o2(0xE7,0xF0), o2(0xBC,0xE3), o2(0xB6,0xEC), o2(0xC3,0xF7),
- o2(0xC6,0xD1), o2(0xB1,0xD1), o2(0xE7,0xF4), o2(0xE7,0xF3),
- o2(0xE7,0xF9), o2(0xE7,0xF5), o2(0xE7,0xF8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_8B = {
- to_SHIFT_JIS_E8_8B_offsets,
- to_EUC_JP_E8_8B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_8C_infos[24] = {
- o2(0xFB,0xD7), o2(0xCC,0xD0), o2(0xE7,0xF7), o2(0xB2,0xD8),
- o2(0xB3,0xFD), o2(0xE7,0xFB), o2(0xE7,0xFD), o2(0xB7,0xD4),
- o2(0xE8,0xA3), o2(0xE8,0xAC), o2(0xE8,0xAD), o2(0xB0,0xAB),
- o2(0xE8,0xB4), o2(0xB0,0xF1), o2(0xE8,0xAB), o2(0xE8,0xAA),
- o2(0xE8,0xA5), o2(0xE8,0xA4), o2(0xE8,0xA2), o2(0xE8,0xA1),
- o2(0xC3,0xE3), o2(0xC2,0xFB), o2(0xE8,0xA7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_8C = {
- to_SHIFT_JIS_E8_8C_offsets,
- to_EUC_JP_E8_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_8D_infos[16] = {
- o2(0xE8,0xA6), o2(0xE8,0xA9), o2(0xC1,0xF0), o2(0xB7,0xD5),
- o2(0xB1,0xC1), o2(0xE8,0xA8), o2(0xB9,0xD3), o2(0xC1,0xF1),
- o2(0xFB,0xD8), o2(0xE8,0xBA), o2(0xE8,0xBB), o2(0xB2,0xD9),
- o2(0xB2,0xAE), o2(0xE8,0xB8), o2(0xFB,0xD9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_8D = {
- to_SHIFT_JIS_E8_8D_offsets,
- to_EUC_JP_E8_8D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_8E_infos[19] = {
- o2(0xE8,0xAE), o2(0xE8,0xB6), o2(0xE8,0xBD), o2(0xE8,0xB7),
- o2(0xE8,0xB5), o2(0xE7,0xF6), o2(0xE8,0xB3), o2(0xE8,0xAF),
- o2(0xB4,0xD0), o2(0xE8,0xB1), o2(0xE8,0xBC), o2(0xE8,0xB2),
- o2(0xE8,0xBE), o2(0xE8,0xB0), o2(0xC7,0xFC), o2(0xCD,0xE9),
- o2(0xE8,0xB9), o2(0xE8,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_8E = {
- to_SHIFT_JIS_E8_8E_offsets,
- to_EUC_JP_E8_8E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_8F_infos[24] = {
- o2(0xE8,0xC7), o2(0xBF,0xFB), o2(0xFB,0xDA), o2(0xB5,0xC6),
- o2(0xB6,0xDD), o2(0xE8,0xC2), o2(0xB2,0xDB), o2(0xBE,0xD4),
- o2(0xE8,0xC5), o2(0xBA,0xDA), o2(0xC5,0xD1), o2(0xE8,0xCA),
- o2(0xCA,0xEE), o2(0xE8,0xC1), o2(0xB2,0xDA), o2(0xB8,0xD6),
- o2(0xC9,0xA9), o2(0xE8,0xCB), o2(0xE8,0xBF), o2(0xFB,0xDB),
- o2(0xE8,0xC8), o2(0xE8,0xD2), o2(0xE8,0xC3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_8F = {
- to_SHIFT_JIS_E8_8F_offsets,
- to_EUC_JP_E8_8F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_90_infos[19] = {
- o2(0xE8,0xC4), o2(0xC6,0xBA), o2(0xE8,0xC9), o2(0xE8,0xC6),
- o2(0xCB,0xA8), o2(0xE8,0xCC), o2(0xB0,0xE0), o2(0xE8,0xC0),
- o2(0xE8,0xCE), o2(0xE8,0xCD), o2(0xC7,0xEB), o2(0xE8,0xD4),
- o2(0xE8,0xDF), o2(0xB3,0xFE), o2(0xE8,0xE2), o2(0xE8,0xD0),
- o2(0xE8,0xD5), o2(0xCD,0xEE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_90 = {
- to_SHIFT_JIS_E8_90_offsets,
- to_EUC_JP_E8_90_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_91_infos[22] = {
- o2(0xE8,0xDE), o2(0xFB,0xDC), o2(0xCD,0xD5), o2(0xCE,0xAA),
- o2(0xC3,0xF8), o2(0xB3,0xEB), o2(0xC9,0xF2), o2(0xE8,0xE4),
- o2(0xC6,0xA1), o2(0xB0,0xB1), o2(0xE8,0xDD), o2(0xE8,0xD9),
- o2(0xC1,0xF2), o2(0xE8,0xD3), o2(0xE8,0xDB), o2(0xE8,0xE0),
- o2(0xC7,0xAC), o2(0xB0,0xAA), o2(0xE8,0xD8), o2(0xE8,0xE1),
- o2(0xC9,0xF8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_91 = {
- to_SHIFT_JIS_E8_91_offsets,
- to_EUC_JP_E8_91_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_92_infos[18] = {
- o2(0xE8,0xDC), o2(0xE8,0xD7), o2(0xBE,0xD5), o2(0xBD,0xAF),
- o2(0xBC,0xAC), o2(0xCC,0xD8), o2(0xC9,0xC7), o2(0xE8,0xE7),
- o2(0xE8,0xF0), o2(0xE8,0xDA), o2(0xB3,0xF7), o2(0xFB,0xDD),
- o2(0xBE,0xF8), o2(0xE8,0xE5), o2(0xE8,0xEA), o2(0xC1,0xF3),
- o2(0xE8,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_92 = {
- to_SHIFT_JIS_E8_92_offsets,
- to_EUC_JP_E8_92_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_93_infos[19] = {
- o2(0xE8,0xED), o2(0xC3,0xDF), o2(0xE8,0xEE), o2(0xCD,0xD6),
- o2(0xE8,0xE3), o2(0xB3,0xB8), o2(0xE8,0xE9), o2(0xE8,0xEC),
- o2(0xCC,0xAC), o2(0xE8,0xEF), o2(0xE8,0xE8), o2(0xE8,0xEB),
- o2(0xF9,0xA5), o2(0xCB,0xA9), o2(0xCF,0xA1), o2(0xE8,0xF3),
- o2(0xE8,0xFA), o2(0xE8,0xF2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_93 = {
- to_SHIFT_JIS_E8_93_offsets,
- to_EUC_JP_E8_93_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_94_infos[17] = {
- o2(0xBC,0xC3), o2(0xE8,0xD1), o2(0xCA,0xCE), o2(0xCC,0xA2),
- o2(0xE8,0xF9), o2(0xE8,0xF8), o2(0xE8,0xF4), o2(0xE8,0xF5),
- o2(0xB1,0xB6), o2(0xE8,0xF7), o2(0xE8,0xF1), o2(0xC4,0xD5),
- o2(0xE8,0xF6), o2(0xB0,0xFE), o2(0xC2,0xA2), o2(0xCA,0xC3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_94 = {
- to_SHIFT_JIS_E8_94_offsets,
- to_EUC_JP_E8_94_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_95_infos[23] = {
- o2(0xE8,0xFB), o2(0xE9,0xA1), o2(0xC8,0xD9), o2(0xE8,0xFE),
- o2(0xBE,0xD6), o2(0xBC,0xC9), o2(0xE9,0xA3), o2(0xB6,0xBE),
- o2(0xFB,0xDE), o2(0xE9,0xA4), o2(0xC9,0xF9), o2(0xE8,0xFD),
- o2(0xFB,0xDF), o2(0xE8,0xD6), o2(0xE8,0xFC), o2(0xCF,0xCF),
- o2(0xC6,0xA2), o2(0xC9,0xF3), o2(0xFB,0xE0), o2(0xE9,0xAB),
- o2(0xE9,0xB1), o2(0xE9,0xB2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_95 = {
- to_SHIFT_JIS_E8_95_offsets,
- to_EUC_JP_E8_95_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_96_infos[25] = {
- o2(0xE9,0xA5), o2(0xC7,0xF6), o2(0xE9,0xAF), o2(0xE9,0xA7),
- o2(0xE9,0xA9), o2(0xE9,0xB3), o2(0xE9,0xA8), o2(0xE9,0xAC),
- o2(0xB1,0xF2), o2(0xC6,0xE5), o2(0xE9,0xAD), o2(0xE9,0xB0),
- o2(0xE9,0xA6), o2(0xC1,0xA6), o2(0xE9,0xAA), o2(0xBB,0xA7),
- o2(0xBF,0xC5), o2(0xB7,0xB0), o2(0xCC,0xF4), o2(0xCC,0xF9),
- o2(0xBD,0xF2), o2(0xFB,0xE2), o2(0xE9,0xB7), o2(0xE9,0xB5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_96 = {
- to_SHIFT_JIS_E8_96_offsets,
- to_EUC_JP_E8_96_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_97_infos[18] = {
- o2(0xCF,0xCE), o2(0xE9,0xB4), o2(0xCD,0xF5), o2(0xE9,0xB6),
- o2(0xE9,0xB8), o2(0xE9,0xB9), o2(0xE9,0xBC), o2(0xE9,0xBA),
- o2(0xC6,0xA3), o2(0xE9,0xBB), o2(0xC8,0xCD), o2(0xE9,0xAE),
- o2(0xBD,0xF3), o2(0xE9,0xBD), o2(0xE9,0xC2), o2(0xC1,0xF4),
- o2(0xE9,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_97 = {
- to_SHIFT_JIS_E8_97_offsets,
- to_EUC_JP_E8_97_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_98_infos[15] = {
- o2(0xE9,0xA2), o2(0xE9,0xC3), o2(0xC1,0xC9), o2(0xE9,0xBE),
- o2(0xE9,0xC0), o2(0xE9,0xBF), o2(0xDD,0xB1), o2(0xDD,0xA2),
- o2(0xE9,0xC5), o2(0xE9,0xC4), o2(0xCD,0xF6), o2(0xE2,0xBC),
- o2(0xE9,0xC6), o2(0xE9,0xC7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_98 = {
- to_SHIFT_JIS_E8_98_offsets,
- to_EUC_JP_E8_98_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_99_infos[15] = {
- o2(0xE9,0xC8), o2(0xB8,0xD7), o2(0xB5,0xD4), o2(0xE9,0xCA),
- o2(0xD1,0xDD), o2(0xB5,0xF5), o2(0xCE,0xBA), o2(0xB6,0xF3),
- o2(0xE9,0xCB), o2(0xE9,0xCC), o2(0xC3,0xEE), o2(0xE9,0xCD),
- o2(0xC6,0xFA), o2(0xB0,0xBA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_99 = {
- to_SHIFT_JIS_E8_99_offsets,
- to_EUC_JP_E8_99_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_9A_infos[14] = {
- o2(0xB2,0xE3), o2(0xE9,0xD2), o2(0xE9,0xD3), o2(0xE9,0xCE),
- o2(0xBB,0xBD), o2(0xE9,0xCF), o2(0xC7,0xC2), o2(0xE9,0xD0),
- o2(0xE9,0xD1), o2(0xE9,0xDB), o2(0xE9,0xD5), o2(0xE9,0xD8),
- o2(0xE9,0xD4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_9A = {
- to_SHIFT_JIS_E8_9A_offsets,
- to_EUC_JP_E8_9A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_9B_infos[23] = {
- o2(0xE9,0xD6), o2(0xE9,0xD7), o2(0xBC,0xD8), o2(0xE9,0xD9),
- o2(0xC3,0xC1), o2(0xB7,0xD6), o2(0xB3,0xC2), o2(0xE9,0xDC),
- o2(0xB3,0xBF), o2(0xE9,0xE1), o2(0xE9,0xDD), o2(0xE9,0xE0),
- o2(0xC8,0xBA), o2(0xE9,0xDE), o2(0xE9,0xDF), o2(0xC9,0xC8),
- o2(0xC8,0xDA), o2(0xE9,0xE2), o2(0xC2,0xFD), o2(0xE9,0xEC),
- o2(0xE9,0xE8), o2(0xB2,0xEB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_9B = {
- to_SHIFT_JIS_E8_9B_offsets,
- to_EUC_JP_E8_9B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_9C_infos[20] = {
- o2(0xE9,0xE6), o2(0xCB,0xAA), o2(0xE9,0xE7), o2(0xE9,0xE4),
- o2(0xE9,0xE5), o2(0xE9,0xEA), o2(0xE9,0xED), o2(0xE9,0xEB),
- o2(0xE9,0xE9), o2(0xE9,0xE3), o2(0xC3,0xD8), o2(0xE9,0xF4),
- o2(0xCC,0xAA), o2(0xE9,0xF2), o2(0xE9,0xF3), o2(0xE9,0xEE),
- o2(0xE9,0xF0), o2(0xE9,0xF1), o2(0xE9,0xEF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_9C = {
- to_SHIFT_JIS_E8_9C_offsets,
- to_EUC_JP_E8_9C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_9D_infos[20] = {
- o2(0xC0,0xE6), o2(0xCF,0xB9), o2(0xE9,0xF8), o2(0xE9,0xF9),
- o2(0xEA,0xA1), o2(0xBF,0xAA), o2(0xE9,0xFB), o2(0xE9,0xFE),
- o2(0xE9,0xF6), o2(0xE9,0xF5), o2(0xEA,0xA2), o2(0xB2,0xDC),
- o2(0xE9,0xFC), o2(0xEA,0xA3), o2(0xE9,0xFD), o2(0xE9,0xFA),
- o2(0xC4,0xB3), o2(0xE9,0xF7), o2(0xC7,0xE8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_9D = {
- to_SHIFT_JIS_E8_9D_offsets,
- to_EUC_JP_E8_9D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_9E_infos[11] = {
- o2(0xEA,0xA7), o2(0xCD,0xBB), o2(0xEA,0xA6), o2(0xEA,0xA5),
- o2(0xEA,0xAE), o2(0xEA,0xA8), o2(0xEA,0xB0), o2(0xCD,0xE6),
- o2(0xEA,0xB3), o2(0xEA,0xAA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_9E = {
- to_SHIFT_JIS_E8_9E_offsets,
- to_EUC_JP_E8_9E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_9F_infos[16] = {
- o2(0xEA,0xAB), o2(0xEA,0xAF), o2(0xEA,0xB2), o2(0xEA,0xB1),
- o2(0xEA,0xA9), o2(0xEA,0xAC), o2(0xEA,0xBD), o2(0xEA,0xB6),
- o2(0xEA,0xB4), o2(0xEA,0xB5), o2(0xEA,0xBA), o2(0xEA,0xBB),
- o2(0xB3,0xAA), o2(0xB5,0xC2), o2(0xEA,0xB9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_9F = {
- to_SHIFT_JIS_E8_9F_offsets,
- to_EUC_JP_E8_9F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A0_infos[17] = {
- o2(0xEA,0xA4), o2(0xFB,0xE5), o2(0xEA,0xB8), o2(0xEA,0xBC),
- o2(0xEA,0xB7), o2(0xEA,0xBE), o2(0xEA,0xC0), o2(0xEA,0xBF),
- o2(0xEA,0xC2), o2(0xEA,0xC1), o2(0xE9,0xDA), o2(0xEA,0xC6),
- o2(0xEA,0xC3), o2(0xEA,0xC4), o2(0xEA,0xC5), o2(0xEA,0xC7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A0 = {
- to_SHIFT_JIS_E8_A0_offsets,
- to_EUC_JP_E8_A0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A1_infos[26] = {
- o2(0xB7,0xEC), o2(0xEA,0xC9), o2(0xEA,0xC8), o2(0xBD,0xB0),
- o2(0xB9,0xD4), o2(0xDE,0xA7), o2(0xEA,0xCA), o2(0xBD,0xD1),
- o2(0xB3,0xB9), o2(0xEA,0xCB), o2(0xB1,0xD2), o2(0xBE,0xD7),
- o2(0xEA,0xCC), o2(0xB9,0xD5), o2(0xEA,0xCD), o2(0xB0,0xE1),
- o2(0xC9,0xBD), o2(0xEA,0xCE), o2(0xBF,0xEA), o2(0xEA,0xD5),
- o2(0xEA,0xD2), o2(0xC3,0xEF), o2(0xEA,0xD3), o2(0xEA,0xD0),
- o2(0xB6,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A1 = {
- to_SHIFT_JIS_E8_A1_offsets,
- to_EUC_JP_E8_A1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A2_infos[21] = {
- o2(0xEA,0xCF), o2(0xEA,0xD6), o2(0xB7,0xB6), o2(0xC2,0xDE),
- o2(0xEA,0xDC), o2(0xEA,0xD8), o2(0xC2,0xB5), o2(0xEA,0xD7),
- o2(0xEA,0xDA), o2(0xEA,0xD1), o2(0xEA,0xDB), o2(0xEA,0xDD),
- o2(0xC8,0xEF), o2(0xEA,0xD9), o2(0xEA,0xDE), o2(0xEA,0xE0),
- o2(0xB8,0xD3), o2(0xEA,0xD4), o2(0xB0,0xC1), o2(0xEA,0xDF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A2 = {
- to_SHIFT_JIS_E8_A2_offsets,
- to_EUC_JP_E8_A2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A3_infos[25] = {
- o2(0xBA,0xDB), o2(0xCE,0xF6), o2(0xEA,0xE1), o2(0xEA,0xE2),
- o2(0xC1,0xF5), o2(0xCE,0xA2), o2(0xEA,0xE3), o2(0xCD,0xB5),
- o2(0xEA,0xE4), o2(0xEA,0xE5), o2(0xCA,0xE4), o2(0xEA,0xE6),
- o2(0xBA,0xC0), o2(0xCE,0xA3), o2(0xEA,0xEB), o2(0xEA,0xEC),
- o2(0xBE,0xD8), o2(0xEA,0xEA), o2(0xFB,0xE6), o2(0xCD,0xE7),
- o2(0xEA,0xE7), o2(0xEA,0xE9), o2(0xC0,0xBD), o2(0xBF,0xFE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A3 = {
- to_SHIFT_JIS_E8_A3_offsets,
- to_EUC_JP_E8_A3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A4_infos[18] = {
- o2(0xEA,0xE8), o2(0xEA,0xED), o2(0xCA,0xA3), o2(0xEA,0xEF),
- o2(0xEA,0xEE), o2(0xB3,0xEC), o2(0xCB,0xAB), o2(0xEA,0xF0),
- o2(0xF9,0xA2), o2(0xEA,0xFC), o2(0xEA,0xF2), o2(0xEA,0xF3),
- o2(0xEA,0xF4), o2(0xEA,0xF5), o2(0xEA,0xF9), o2(0xEA,0xFA),
- o2(0xEA,0xF8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A4 = {
- to_SHIFT_JIS_E8_A4_offsets,
- to_EUC_JP_E8_A4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A5_infos[20] = {
- o2(0xEA,0xF6), o2(0xEA,0xF1), o2(0xEA,0xF7), o2(0xEA,0xFB),
- o2(0xF0,0xB7), o2(0xB2,0xA8), o2(0xEA,0xFE), o2(0xB6,0xDF),
- o2(0xEA,0xFD), o2(0xEB,0xA2), o2(0xEB,0xA1), o2(0xEB,0xA4),
- o2(0xEB,0xA3), o2(0xEB,0xA5), o2(0xBD,0xB1), o2(0xEB,0xA6),
- o2(0xEB,0xA7), o2(0xEB,0xA8), o2(0xC0,0xBE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A5 = {
- to_SHIFT_JIS_E8_A5_offsets,
- to_EUC_JP_E8_A5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A6_infos[26] = {
- o2(0xCD,0xD7), o2(0xEB,0xA9), o2(0xCA,0xA4), o2(0xC7,0xC6),
- o2(0xEB,0xAA), o2(0xEB,0xAB), o2(0xB8,0xAB), o2(0xB5,0xAC),
- o2(0xEB,0xAC), o2(0xBB,0xEB), o2(0xC7,0xC1), o2(0xEB,0xAD),
- o2(0xB3,0xD0), o2(0xEB,0xAE), o2(0xEB,0xB0), o2(0xCD,0xF7),
- o2(0xEB,0xAF), o2(0xBF,0xC6), o2(0xEB,0xB1), o2(0xEB,0xB2),
- o2(0xEB,0xB3), o2(0xB4,0xD1), o2(0xEB,0xB4), o2(0xEB,0xB5),
- o2(0xEB,0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A6 = {
- to_SHIFT_JIS_E8_A6_offsets,
- to_EUC_JP_E8_A6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A7_infos[11] = {
- o2(0xEB,0xB7), o2(0xB3,0xD1), o2(0xEB,0xB8), o2(0xEB,0xB9),
- o2(0xEB,0xBA), o2(0xB2,0xF2), o2(0xBF,0xA8), o2(0xEB,0xBB),
- o2(0xEB,0xBC), o2(0xEB,0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A7 = {
- to_SHIFT_JIS_E8_A7_offsets,
- to_EUC_JP_E8_A7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A8_infos[29] = {
- o2(0xB8,0xC0), o2(0xC4,0xFB), o2(0xEB,0xBE), o2(0xB7,0xD7),
- o2(0xBF,0xD6), o2(0xEB,0xC1), o2(0xC6,0xA4), o2(0xEB,0xC0),
- o2(0xFB,0xE7), o2(0xB7,0xB1), o2(0xEB,0xBF), o2(0xC2,0xF7),
- o2(0xB5,0xAD), o2(0xEB,0xC2), o2(0xEB,0xC3), o2(0xBE,0xD9),
- o2(0xB7,0xED), o2(0xEB,0xC4), o2(0xCB,0xAC), o2(0xC0,0xDF),
- o2(0xB5,0xF6), o2(0xCC,0xF5), o2(0xC1,0xCA), o2(0xEB,0xC5),
- o2(0xFB,0xE8), o2(0xBF,0xC7), o2(0xC3,0xF0), o2(0xBE,0xDA),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A8 = {
- to_SHIFT_JIS_E8_A8_offsets,
- to_EUC_JP_E8_A8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_A9_infos[26] = {
- o2(0xEB,0xC6), o2(0xEB,0xC9), o2(0xEB,0xCA), o2(0xBA,0xBE),
- o2(0xC2,0xC2), o2(0xEB,0xC8), o2(0xBE,0xDB), o2(0xC9,0xBE),
- o2(0xEB,0xC7), o2(0xBB,0xEC), o2(0xB1,0xD3), o2(0xEB,0xCE),
- o2(0xB7,0xD8), o2(0xBB,0xEE), o2(0xBB,0xED), o2(0xCF,0xCD),
- o2(0xEB,0xCD), o2(0xEB,0xCC), o2(0xC1,0xA7), o2(0xB5,0xCD),
- o2(0xCF,0xC3), o2(0xB3,0xBA), o2(0xBE,0xDC), o2(0xFB,0xE9),
- o2(0xEB,0xCB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_A9 = {
- to_SHIFT_JIS_E8_A9_offsets,
- to_EUC_JP_E8_A9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_AA_infos[30] = {
- o2(0xEB,0xD0), o2(0xEB,0xD1), o2(0xEB,0xCF), o2(0xB8,0xD8),
- o2(0xCD,0xC0), o2(0xBB,0xEF), o2(0xC7,0xA7), o2(0xEB,0xD4),
- o2(0xC0,0xC0), o2(0xC3,0xC2), o2(0xCD,0xB6), o2(0xEB,0xD7),
- o2(0xB8,0xEC), o2(0xC0,0xBF), o2(0xEB,0xD3), o2(0xEB,0xD8),
- o2(0xB8,0xED), o2(0xEB,0xD5), o2(0xEB,0xD6), o2(0xFB,0xEA),
- o2(0xEB,0xD2), o2(0xC0,0xE2), o2(0xC6,0xC9), o2(0xC3,0xAF),
- o2(0xB2,0xDD), o2(0xC8,0xF0), o2(0xB5,0xC3), o2(0xFB,0xEB),
- o2(0xC4,0xB4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_AA = {
- to_SHIFT_JIS_E8_AA_offsets,
- to_EUC_JP_E8_AA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_AB_infos[31] = {
- o2(0xEB,0xDB), o2(0xEB,0xD9), o2(0xC3,0xCC), o2(0xC0,0xC1),
- o2(0xB4,0xD2), o2(0xEB,0xDA), o2(0xBF,0xDB), o2(0xCE,0xCA),
- o2(0xCF,0xC0), o2(0xEB,0xDC), o2(0xEB,0xE7), o2(0xC4,0xB5),
- o2(0xEB,0xE6), o2(0xFB,0xEC), o2(0xEB,0xE3), o2(0xEB,0xEB),
- o2(0xEB,0xE4), o2(0xEB,0xE0), o2(0xC4,0xFC), o2(0xEB,0xDF),
- o2(0xEB,0xDD), o2(0xCD,0xA1), o2(0xBB,0xF0), o2(0xEB,0xE1),
- o2(0xEB,0xDE), o2(0xFB,0xEE), o2(0xEB,0xE5), o2(0xBD,0xF4),
- o2(0xB8,0xC1), o2(0xC2,0xFA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_AB = {
- to_SHIFT_JIS_E8_AB_offsets,
- to_EUC_JP_E8_AB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_AC_infos[25] = {
- o2(0xCB,0xC5), o2(0xB1,0xDA), o2(0xB0,0xE2), o2(0xC6,0xA5),
- o2(0xEB,0xE9), o2(0xEB,0xE8), o2(0xC6,0xE6), o2(0xEB,0xED),
- o2(0xEB,0xE2), o2(0xEB,0xEC), o2(0xEB,0xEE), o2(0xB8,0xAC),
- o2(0xEB,0xEA), o2(0xB9,0xD6), o2(0xBC,0xD5), o2(0xEB,0xEF),
- o2(0xCD,0xD8), o2(0xEB,0xF2), o2(0xEB,0xF5), o2(0xEB,0xF3),
- o2(0xC9,0xB5), o2(0xEB,0xF0), o2(0xB6,0xE0), o2(0xEB,0xF4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_AC = {
- to_SHIFT_JIS_E8_AC_offsets,
- to_EUC_JP_E8_AC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_AD_infos[24] = {
- o2(0xEB,0xF6), o2(0xEB,0xFA), o2(0xEB,0xF7), o2(0xEB,0xF9),
- o2(0xEB,0xF8), o2(0xFB,0xEF), o2(0xEB,0xFB), o2(0xBC,0xB1),
- o2(0xEB,0xFD), o2(0xEB,0xFC), o2(0xC9,0xE8), o2(0xEC,0xA1),
- o2(0xB7,0xD9), o2(0xEB,0xFE), o2(0xEC,0xA2), o2(0xEC,0xA3),
- o2(0xB5,0xC4), o2(0xE6,0xC1), o2(0xBE,0xF9), o2(0xEC,0xA4),
- o2(0xB8,0xEE), o2(0xEC,0xA5), o2(0xFB,0xF0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_AD = {
- to_SHIFT_JIS_E8_AD_offsets,
- to_EUC_JP_E8_AD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_AE_infos[12] = {
- o2(0xEC,0xA6), o2(0xBB,0xBE), o2(0xDA,0xCE), o2(0xEC,0xA7),
- o2(0xEC,0xA8), o2(0xBD,0xB2), o2(0xEC,0xA9), o2(0xEC,0xAA),
- o2(0xEC,0xAB), o2(0xEC,0xAC), o2(0xEC,0xAD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_AE = {
- to_SHIFT_JIS_E8_AE_offsets,
- to_EUC_JP_E8_AE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B0_infos[4] = {
- o2(0xC3,0xAB), o2(0xEC,0xAE), o2(0xEC,0xB0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B0 = {
- to_SHIFT_JIS_E8_B0_offsets,
- to_EUC_JP_E8_B0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B1_infos[19] = {
- o2(0xEC,0xAF), o2(0xC6,0xA6), o2(0xEC,0xB1), o2(0xCB,0xAD),
- o2(0xEC,0xB2), o2(0xEC,0xB3), o2(0xEC,0xB4), o2(0xEC,0xB5),
- o2(0xC6,0xDA), o2(0xBE,0xDD), o2(0xEC,0xB6), o2(0xB9,0xEB),
- o2(0xD0,0xAE), o2(0xEC,0xB7), o2(0xEC,0xB8), o2(0xC9,0xBF),
- o2(0xEC,0xB9), o2(0xEC,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B1 = {
- to_SHIFT_JIS_E8_B1_offsets,
- to_EUC_JP_E8_B1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B2_infos[35] = {
- o2(0xEC,0xBA), o2(0xEC,0xBC), o2(0xEC,0xBB), o2(0xEC,0xBD),
- o2(0xCB,0xC6), o2(0xEC,0xBE), o2(0xEC,0xBF), o2(0xEC,0xC0),
- o2(0xEC,0xC2), o2(0xB3,0xAD), o2(0xC4,0xE7), o2(0xC9,0xE9),
- o2(0xBA,0xE2), o2(0xB9,0xD7), o2(0xC9,0xCF), o2(0xB2,0xDF),
- o2(0xC8,0xCE), o2(0xEC,0xC5), o2(0xB4,0xD3), o2(0xC0,0xD5),
- o2(0xEC,0xC4), o2(0xEC,0xC9), o2(0xC3,0xF9), o2(0xCC,0xE3),
- o2(0xEC,0xC7), o2(0xEC,0xC8), o2(0xB5,0xAE), o2(0xEC,0xCA),
- o2(0xC7,0xE3), o2(0xC2,0xDF), o2(0xC8,0xF1), o2(0xC5,0xBD),
- o2(0xEC,0xC6), o2(0xCB,0xC7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B2 = {
- to_SHIFT_JIS_E8_B2_offsets,
- to_EUC_JP_E8_B2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B3_infos[30] = {
- o2(0xB2,0xEC), o2(0xEC,0xCC), o2(0xCF,0xA8), o2(0xC4,0xC2),
- o2(0xCF,0xC5), o2(0xBB,0xF1), o2(0xEC,0xCB), o2(0xC2,0xB1),
- o2(0xEC,0xDC), o2(0xC1,0xA8), o2(0xC6,0xF8), o2(0xC9,0xD0),
- o2(0xEC,0xCF), o2(0xBB,0xBF), o2(0xBB,0xF2), o2(0xBE,0xDE),
- o2(0xC7,0xE5), o2(0xB8,0xAD), o2(0xEC,0xCE), o2(0xEC,0xCD),
- o2(0xC9,0xEA), o2(0xBC,0xC1), o2(0xC5,0xD2), o2(0xFB,0xF1),
- o2(0xFB,0xF2), o2(0xEC,0xD1), o2(0xEC,0xD2), o2(0xB9,0xD8),
- o2(0xEC,0xD0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B3 = {
- to_SHIFT_JIS_E8_B3_offsets,
- to_EUC_JP_E8_B3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B4_infos[14] = {
- o2(0xEC,0xD3), o2(0xEC,0xD4), o2(0xEC,0xD6), o2(0xC2,0xA3),
- o2(0xEC,0xD5), o2(0xB4,0xE6), o2(0xEC,0xD8), o2(0xEC,0xD7),
- o2(0xEC,0xD9), o2(0xFB,0xF3), o2(0xEC,0xDB), o2(0xEC,0xDD),
- o2(0xEC,0xDE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B4 = {
- to_SHIFT_JIS_E8_B4_offsets,
- to_EUC_JP_E8_B4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B5_infos[12] = {
- o2(0xC0,0xD6), o2(0xBC,0xCF), o2(0xEC,0xDF), o2(0xB3,0xD2),
- o2(0xEC,0xE0), o2(0xC1,0xF6), o2(0xEC,0xE1), o2(0xEC,0xE2),
- o2(0xC9,0xEB), o2(0xFB,0xF4), o2(0xB5,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B5 = {
- to_SHIFT_JIS_E8_B5_offsets,
- to_EUC_JP_E8_B5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B6_infos[10] = {
- o2(0xEC,0xE3), o2(0xC4,0xB6), o2(0xB1,0xDB), o2(0xEC,0xE4),
- o2(0xBC,0xF1), o2(0xBF,0xF6), o2(0xC2,0xAD), o2(0xEC,0xE7),
- o2(0xEC,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B6 = {
- to_SHIFT_JIS_E8_B6_offsets,
- to_EUC_JP_E8_B6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B7_infos[20] = {
- o2(0xEC,0xE5), o2(0xEC,0xED), o2(0xEC,0xEB), o2(0xEC,0xE8),
- o2(0xEC,0xEA), o2(0xEC,0xE9), o2(0xEC,0xEC), o2(0xB5,0xF7),
- o2(0xEC,0xF0), o2(0xC0,0xD7), o2(0xEC,0xF1), o2(0xB8,0xD9),
- o2(0xEC,0xEE), o2(0xEC,0xEF), o2(0xCF,0xA9), o2(0xC4,0xB7),
- o2(0xC1,0xA9), o2(0xEC,0xF2), o2(0xEC,0xF5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B7 = {
- to_SHIFT_JIS_E8_B7_offsets,
- to_EUC_JP_E8_B7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B8_infos[13] = {
- o2(0xEC,0xF3), o2(0xEC,0xF4), o2(0xCD,0xD9), o2(0xC6,0xA7),
- o2(0xEC,0xF8), o2(0xEC,0xF6), o2(0xEC,0xF7), o2(0xEC,0xF9),
- o2(0xED,0xA9), o2(0xEC,0xFC), o2(0xEC,0xFD), o2(0xEC,0xFB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B8 = {
- to_SHIFT_JIS_E8_B8_offsets,
- to_EUC_JP_E8_B8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_B9_infos[19] = {
- o2(0xEC,0xFA), o2(0xC4,0xFD), o2(0xED,0xA1), o2(0xED,0xA5),
- o2(0xED,0xA2), o2(0xEC,0xFE), o2(0xED,0xA3), o2(0xED,0xA4),
- o2(0xED,0xAB), o2(0xED,0xA6), o2(0xC0,0xD8), o2(0xED,0xA8),
- o2(0xED,0xAA), o2(0xED,0xA7), o2(0xED,0xAD), o2(0xBD,0xB3),
- o2(0xED,0xAC), o2(0xED,0xAE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_B9 = {
- to_SHIFT_JIS_E8_B9_offsets,
- to_EUC_JP_E8_B9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_BA_infos[20] = {
- o2(0xED,0xAF), o2(0xED,0xB2), o2(0xED,0xB1), o2(0xED,0xB0),
- o2(0xED,0xB4), o2(0xED,0xB3), o2(0xCC,0xF6), o2(0xED,0xB6),
- o2(0xED,0xB5), o2(0xED,0xB7), o2(0xED,0xB8), o2(0xED,0xBA),
- o2(0xED,0xB9), o2(0xBF,0xC8), o2(0xED,0xBB), o2(0xB6,0xED),
- o2(0xED,0xBC), o2(0xED,0xBE), o2(0xED,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_BA = {
- to_SHIFT_JIS_E8_BA_offsets,
- to_EUC_JP_E8_BA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_BB_infos[20] = {
- o2(0xED,0xC0), o2(0xED,0xBD), o2(0xED,0xC1), o2(0xBC,0xD6),
- o2(0xED,0xC2), o2(0xB5,0xB0), o2(0xB7,0xB3), o2(0xFB,0xF6),
- o2(0xB8,0xAE), o2(0xED,0xC3), o2(0xC6,0xF0), o2(0xC5,0xBE),
- o2(0xED,0xC4), o2(0xED,0xC7), o2(0xBC,0xB4), o2(0xED,0xC6),
- o2(0xED,0xC5), o2(0xB7,0xDA), o2(0xED,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_BB = {
- to_SHIFT_JIS_E8_BB_offsets,
- to_EUC_JP_E8_BB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_BC_infos[25] = {
- o2(0xB3,0xD3), o2(0xED,0xCA), o2(0xBA,0xDC), o2(0xED,0xC9),
- o2(0xED,0xD2), o2(0xED,0xCC), o2(0xED,0xCE), o2(0xCA,0xE5),
- o2(0xED,0xCB), o2(0xED,0xCD), o2(0xED,0xD1), o2(0xED,0xCF),
- o2(0xB5,0xB1), o2(0xED,0xD0), o2(0xED,0xD3), o2(0xC7,0xDA),
- o2(0xCE,0xD8), o2(0xBD,0xB4), o2(0xED,0xD4), o2(0xCD,0xA2),
- o2(0xED,0xD6), o2(0xED,0xD5), o2(0xED,0xD9), o2(0xCD,0xC1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_BC = {
- to_SHIFT_JIS_E8_BC_offsets,
- to_EUC_JP_E8_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_BD_infos[16] = {
- o2(0xED,0xD8), o2(0xB3,0xED), o2(0xED,0xD7), o2(0xED,0xDC),
- o2(0xED,0xDB), o2(0xED,0xDA), o2(0xC5,0xB2), o2(0xED,0xDD),
- o2(0xED,0xDE), o2(0xED,0xDF), o2(0xB9,0xEC), o2(0xB7,0xA5),
- o2(0xED,0xE0), o2(0xED,0xE1), o2(0xED,0xE2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_BD = {
- to_SHIFT_JIS_E8_BD_offsets,
- to_EUC_JP_E8_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_BE_infos[19] = {
- o2(0xBF,0xC9), o2(0xED,0xE3), o2(0xBC,0xAD), o2(0xED,0xE4),
- o2(0xED,0xE5), o2(0xD2,0xA1), o2(0xD1,0xFE), o2(0xED,0xE6),
- o2(0xE5,0xF0), o2(0xED,0xE7), o2(0xC3,0xA4), o2(0xBF,0xAB),
- o2(0xC7,0xC0), o2(0xED,0xE8), o2(0xCA,0xD5), o2(0xC4,0xD4),
- o2(0xB9,0xFE), o2(0xC3,0xA9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_BE = {
- to_SHIFT_JIS_E8_BE_offsets,
- to_EUC_JP_E8_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_BF_infos[23] = {
- o2(0xB1,0xAA), o2(0xCB,0xF8), o2(0xBF,0xD7), o2(0xB7,0xDE),
- o2(0xB6,0xE1), o2(0xCA,0xD6), o2(0xED,0xE9), o2(0xED,0xEB),
- o2(0xED,0xEA), o2(0xB2,0xE0), o2(0xC6,0xF6), o2(0xED,0xEC),
- o2(0xC7,0xF7), o2(0xC5,0xB3), o2(0xED,0xED), o2(0xBD,0xD2),
- o2(0xED,0xEF), o2(0xCC,0xC2), o2(0xED,0xFE), o2(0xED,0xF1),
- o2(0xED,0xF2), o2(0xC4,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8_BF = {
- to_SHIFT_JIS_E8_BF_offsets,
- to_EUC_JP_E8_BF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E8_infos[64] = {
- &to_EUC_JP_E8_80, &to_EUC_JP_E8_81, &to_EUC_JP_E8_82, &to_EUC_JP_E8_83,
- &to_EUC_JP_E8_84, &to_EUC_JP_E8_85, &to_EUC_JP_E8_86, &to_EUC_JP_E8_87,
- &to_EUC_JP_E8_88, &to_EUC_JP_E8_89, &to_EUC_JP_E8_8A, &to_EUC_JP_E8_8B,
- &to_EUC_JP_E8_8C, &to_EUC_JP_E8_8D, &to_EUC_JP_E8_8E, &to_EUC_JP_E8_8F,
- &to_EUC_JP_E8_90, &to_EUC_JP_E8_91, &to_EUC_JP_E8_92, &to_EUC_JP_E8_93,
- &to_EUC_JP_E8_94, &to_EUC_JP_E8_95, &to_EUC_JP_E8_96, &to_EUC_JP_E8_97,
- &to_EUC_JP_E8_98, &to_EUC_JP_E8_99, &to_EUC_JP_E8_9A, &to_EUC_JP_E8_9B,
- &to_EUC_JP_E8_9C, &to_EUC_JP_E8_9D, &to_EUC_JP_E8_9E, &to_EUC_JP_E8_9F,
- &to_EUC_JP_E8_A0, &to_EUC_JP_E8_A1, &to_EUC_JP_E8_A2, &to_EUC_JP_E8_A3,
- &to_EUC_JP_E8_A4, &to_EUC_JP_E8_A5, &to_EUC_JP_E8_A6, &to_EUC_JP_E8_A7,
- &to_EUC_JP_E8_A8, &to_EUC_JP_E8_A9, &to_EUC_JP_E8_AA, &to_EUC_JP_E8_AB,
- &to_EUC_JP_E8_AC, &to_EUC_JP_E8_AD, &to_EUC_JP_E8_AE, &to_EUC_JP_E8_B0,
- &to_EUC_JP_E8_B1, &to_EUC_JP_E8_B2, &to_EUC_JP_E8_B3, &to_EUC_JP_E8_B4,
- &to_EUC_JP_E8_B5, &to_EUC_JP_E8_B6, &to_EUC_JP_E8_B7, &to_EUC_JP_E8_B8,
- &to_EUC_JP_E8_B9, &to_EUC_JP_E8_BA, &to_EUC_JP_E8_BB, &to_EUC_JP_E8_BC,
- &to_EUC_JP_E8_BD, &to_EUC_JP_E8_BE, &to_EUC_JP_E8_BF, UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E8 = {
- to_SHIFT_JIS_E8_offsets,
- to_EUC_JP_E8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_80_infos[36] = {
- o2(0xC2,0xE0), o2(0xC1,0xF7), o2(0xC6,0xA8), o2(0xED,0xF0),
- o2(0xB5,0xD5), o2(0xED,0xF9), o2(0xED,0xF6), o2(0xEE,0xA5),
- o2(0xC6,0xA9), o2(0xC3,0xE0), o2(0xED,0xF3), o2(0xC4,0xFE),
- o2(0xC5,0xD3), o2(0xED,0xF4), o2(0xED,0xF8), o2(0xBF,0xE0),
- o2(0xC7,0xE7), o2(0xC4,0xCC), o2(0xC0,0xC2), o2(0xED,0xF7),
- o2(0xC2,0xAE), o2(0xC2,0xA4), o2(0xED,0xF5), o2(0xB0,0xA9),
- o2(0xCF,0xA2), o2(0xED,0xFA), o2(0xC2,0xE1), o2(0xBD,0xB5),
- o2(0xBF,0xCA), o2(0xED,0xFC), o2(0xED,0xFB), o2(0xB0,0xEF),
- o2(0xED,0xFD), o2(0xC9,0xAF), o2(0xEE,0xA7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_80 = {
- to_SHIFT_JIS_E9_80_offsets,
- to_EUC_JP_E9_80_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_81_infos[41] = {
- o2(0xC6,0xDB), o2(0xBF,0xEB), o2(0xC3,0xD9), o2(0xB6,0xF8),
- o2(0xEE,0xA6), o2(0xCD,0xB7), o2(0xB1,0xBF), o2(0xCA,0xD7),
- o2(0xB2,0xE1), o2(0xEE,0xA1), o2(0xEE,0xA2), o2(0xEE,0xA3),
- o2(0xEE,0xA4), o2(0xC6,0xBB), o2(0xC3,0xA3), o2(0xB0,0xE3),
- o2(0xEE,0xA8), o2(0xEE,0xA9), o2(0xF4,0xA3), o2(0xC2,0xBD),
- o2(0xEE,0xAA), o2(0xB1,0xF3), o2(0xC1,0xCC), o2(0xB8,0xAF),
- o2(0xCD,0xDA), o2(0xFB,0xF9), o2(0xEE,0xAB), o2(0xC5,0xAC),
- o2(0xC1,0xF8), o2(0xBC,0xD7), o2(0xEE,0xAC), o2(0xEE,0xAF),
- o2(0xBD,0xE5), o2(0xEE,0xAD), o2(0xC1,0xAB), o2(0xC1,0xAA),
- o2(0xB0,0xE4), o2(0xCE,0xCB), o2(0xEE,0xB1), o2(0xC8,0xF2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_81 = {
- to_SHIFT_JIS_E9_81_offsets,
- to_EUC_JP_E9_81_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_82_infos[19] = {
- o2(0xEE,0xB3), o2(0xEE,0xB2), o2(0xEE,0xB0), o2(0xE3,0xE4),
- o2(0xB4,0xD4), o2(0xED,0xEE), o2(0xEE,0xB5), o2(0xEE,0xB4),
- o2(0xEE,0xB6), o2(0xCD,0xB8), o2(0xC6,0xE1), o2(0xCB,0xAE),
- o2(0xEE,0xB7), o2(0xBC,0xD9), o2(0xEE,0xB8), o2(0xEE,0xB9),
- o2(0xEE,0xBA), o2(0xC5,0xA1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_82 = {
- to_SHIFT_JIS_E9_82_offsets,
- to_EUC_JP_E9_82_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_83_infos[14] = {
- o2(0xB0,0xEA), o2(0xB9,0xD9), o2(0xCF,0xBA), o2(0xEE,0xBE),
- o2(0xFB,0xFA), o2(0xB7,0xB4), o2(0xEE,0xBB), o2(0xEE,0xBC),
- o2(0xC9,0xF4), o2(0xB3,0xD4), o2(0xCD,0xB9), o2(0xB6,0xBF),
- o2(0xC5,0xD4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_83 = {
- to_SHIFT_JIS_E9_83_offsets,
- to_EUC_JP_E9_83_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_84_infos[9] = {
- o2(0xEE,0xBF), o2(0xEE,0xC0), o2(0xFB,0xFC), o2(0xEE,0xC1),
- o2(0xFB,0xFD), o2(0xC5,0xA2), o2(0xEE,0xC3), o2(0xEE,0xC2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_84 = {
- to_SHIFT_JIS_E9_84_offsets,
- to_EUC_JP_E9_84_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_85_infos[22] = {
- o2(0xC6,0xD3), o2(0xEE,0xC4), o2(0xBD,0xB6), o2(0xBC,0xE0),
- o2(0xC7,0xDB), o2(0xC3,0xF1), o2(0xBC,0xF2), o2(0xBF,0xEC),
- o2(0xEE,0xC5), o2(0xEE,0xC6), o2(0xBF,0xDD), o2(0xEE,0xC7),
- o2(0xEE,0xC8), o2(0xEE,0xC9), o2(0xCD,0xEF), o2(0xBD,0xB7),
- o2(0xEE,0xCB), o2(0xEE,0xCA), o2(0xB9,0xDA), o2(0xB9,0xF3),
- o2(0xBB,0xC0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_85 = {
- to_SHIFT_JIS_E9_85_offsets,
- to_EUC_JP_E9_85_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_86_infos[19] = {
- o2(0xEE,0xCE), o2(0xBD,0xE6), o2(0xEE,0xCD), o2(0xEE,0xCC),
- o2(0xC2,0xE9), o2(0xB8,0xEF), o2(0xC0,0xC3), o2(0xC8,0xB0),
- o2(0xBD,0xB9), o2(0xEE,0xCF), o2(0xBE,0xDF), o2(0xEE,0xD2),
- o2(0xEE,0xD0), o2(0xEE,0xD1), o2(0xEE,0xD4), o2(0xEE,0xD3),
- o2(0xBE,0xFA), o2(0xEE,0xD5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_86 = {
- to_SHIFT_JIS_E9_86_offsets,
- to_EUC_JP_E9_86_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_87_infos[35] = {
- o2(0xEE,0xD6), o2(0xEE,0xD7), o2(0xC8,0xD0), o2(0xBA,0xD3),
- o2(0xBC,0xE1), o2(0xEE,0xD8), o2(0xEE,0xD9), o2(0xCE,0xA4),
- o2(0xBD,0xC5), o2(0xCC,0xEE), o2(0xCE,0xCC), o2(0xEE,0xDA),
- o2(0xB6,0xE2), o2(0xEE,0xDB), o2(0xFC,0xA1), o2(0xC5,0xA3),
- o2(0xFB,0xFE), o2(0xEE,0xDE), o2(0xB3,0xF8), o2(0xBF,0xCB),
- o2(0xFC,0xA2), o2(0xEE,0xDC), o2(0xEE,0xDD), o2(0xC4,0xE0),
- o2(0xFC,0xA5), o2(0xFC,0xA6), o2(0xCB,0xD5), o2(0xB6,0xFC),
- o2(0xFC,0xA3), o2(0xFC,0xA4), o2(0xEE,0xE0), o2(0xEE,0xE1),
- o2(0xEE,0xDF), o2(0xEE,0xE3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_87 = {
- to_SHIFT_JIS_E9_87_offsets,
- to_EUC_JP_E9_87_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_88_infos[18] = {
- o2(0xFC,0xA7), o2(0xFC,0xA9), o2(0xC6,0xDF), o2(0xB3,0xC3),
- o2(0xFC,0xA8), o2(0xEE,0xE7), o2(0xEE,0xE4), o2(0xEE,0xE6),
- o2(0xEE,0xE2), o2(0xEF,0xCF), o2(0xEE,0xE5), o2(0xCE,0xEB),
- o2(0xB8,0xDA), o2(0xFC,0xB0), o2(0xFC,0xAA), o2(0xFC,0xAC),
- o2(0xEE,0xEF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_88 = {
- to_SHIFT_JIS_E9_88_offsets,
- to_EUC_JP_E9_88_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_89_infos[23] = {
- o2(0xFC,0xAB), o2(0xC5,0xB4), o2(0xEE,0xEA), o2(0xEE,0xED),
- o2(0xEE,0xEB), o2(0xEE,0xF0), o2(0xFC,0xAD), o2(0xEE,0xF1),
- o2(0xFC,0xAF), o2(0xEE,0xE9), o2(0xFC,0xAE), o2(0xEE,0xF6),
- o2(0xB1,0xF4), o2(0xEE,0xE8), o2(0xC8,0xAD), o2(0xEE,0xEC),
- o2(0xBE,0xE0), o2(0xFC,0xB1), o2(0xB9,0xDB), o2(0xFC,0xB3),
- o2(0xFC,0xB4), o2(0xCB,0xC8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_89 = {
- to_SHIFT_JIS_E9_89_offsets,
- to_EUC_JP_E9_89_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_8A_infos[17] = {
- o2(0xB6,0xE4), o2(0xBD,0xC6), o2(0xC6,0xBC), o2(0xF9,0xA4),
- o2(0xC1,0xAD), o2(0xEE,0xF4), o2(0xEE,0xEE), o2(0xEE,0xF3),
- o2(0xCC,0xC3), o2(0xC4,0xB8), o2(0xEE,0xF5), o2(0xEE,0xF2),
- o2(0xFC,0xB2), o2(0xC1,0xAC), o2(0xEE,0xF9), o2(0xEE,0xF8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_8A = {
- to_SHIFT_JIS_E9_8A_offsets,
- to_EUC_JP_E9_8A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_8B_infos[22] = {
- o2(0xEE,0xF7), o2(0xFC,0xB8), o2(0xCB,0xAF), o2(0xFC,0xBC),
- o2(0xFC,0xBA), o2(0xFC,0xB6), o2(0xFC,0xB7), o2(0xFC,0xBB),
- o2(0xBD,0xFB), o2(0xFC,0xB5), o2(0xEE,0xFA), o2(0xCA,0xDF),
- o2(0xB1,0xD4), o2(0xC9,0xC6), o2(0xC3,0xF2), o2(0xB5,0xF8),
- o2(0xF9,0xAA), o2(0xEE,0xFC), o2(0xFC,0xBF), o2(0xB9,0xDD),
- o2(0xFC,0xC2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_8B = {
- to_SHIFT_JIS_E9_8B_offsets,
- to_EUC_JP_E9_8B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_8C_infos[25] = {
- o2(0xFC,0xC4), o2(0xBB,0xAC), o2(0xEE,0xFB), o2(0xBF,0xED),
- o2(0xBF,0xEE), o2(0xEF,0xA1), o2(0xEF,0xA3), o2(0xFC,0xC3),
- o2(0xFC,0xC1), o2(0xBE,0xFB), o2(0xFC,0xBE), o2(0xEF,0xA2),
- o2(0xEF,0xA4), o2(0xFC,0xBD), o2(0xB6,0xD3), o2(0xC9,0xC5),
- o2(0xBC,0xE2), o2(0xCF,0xA3), o2(0xEE,0xFE), o2(0xBA,0xF8),
- o2(0xCF,0xBF), o2(0xEF,0xA6), o2(0xEF,0xA5), o2(0xEF,0xA7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_8C = {
- to_SHIFT_JIS_E9_8C_offsets,
- to_EUC_JP_E9_8C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_8D_infos[17] = {
- o2(0xEE,0xFD), o2(0xF9,0xA3), o2(0xC6,0xE9), o2(0xC5,0xD5),
- o2(0xC4,0xD7), o2(0xEF,0xAC), o2(0xFC,0xC6), o2(0xC3,0xC3),
- o2(0xEF,0xA8), o2(0xEF,0xA9), o2(0xB7,0xAD), o2(0xEF,0xAB),
- o2(0xFC,0xC5), o2(0xB8,0xB0), o2(0xEF,0xAA), o2(0xBE,0xE1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_8D = {
- to_SHIFT_JIS_E9_8D_offsets,
- to_EUC_JP_E9_8D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_8E_infos[13] = {
- o2(0xB3,0xF9), o2(0xEF,0xB0), o2(0xBA,0xBF), o2(0xC1,0xF9),
- o2(0xC4,0xCA), o2(0xFC,0xC7), o2(0xB3,0xBB), o2(0xEF,0xAE),
- o2(0xEF,0xAF), o2(0xC4,0xC3), o2(0xEF,0xAD), o2(0xEF,0xB1),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_8E = {
- to_SHIFT_JIS_E9_8E_offsets,
- to_EUC_JP_E9_8E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_8F_infos[16] = {
- o2(0xEF,0xB7), o2(0xFC,0xC8), o2(0xEF,0xBA), o2(0xEF,0xB9),
- o2(0xC5,0xAD), o2(0xEF,0xB2), o2(0xEF,0xB3), o2(0xEF,0xB6),
- o2(0xEF,0xB8), o2(0xFC,0xC9), o2(0xB6,0xC0), o2(0xEF,0xBB),
- o2(0xEF,0xB5), o2(0xEF,0xB4), o2(0xFC,0xCA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_8F = {
- to_SHIFT_JIS_E9_8F_offsets,
- to_EUC_JP_E9_8F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_90_infos[16] = {
- o2(0xEF,0xBF), o2(0xEF,0xC0), o2(0xEF,0xC1), o2(0xEF,0xBE),
- o2(0xEF,0xBD), o2(0xBE,0xE2), o2(0xC6,0xAA), o2(0xEF,0xBC),
- o2(0xEF,0xC5), o2(0xEF,0xC3), o2(0xFC,0xCB), o2(0xEF,0xC4),
- o2(0xEF,0xC2), o2(0xC2,0xF8), o2(0xEF,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_90 = {
- to_SHIFT_JIS_E9_90_offsets,
- to_EUC_JP_E9_90_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_91_infos[21] = {
- o2(0xEF,0xC7), o2(0xEF,0xC9), o2(0xFC,0xCC), o2(0xFC,0xCD),
- o2(0xB4,0xD5), o2(0xEF,0xC8), o2(0xCC,0xFA), o2(0xEF,0xD4),
- o2(0xEF,0xCA), o2(0xEF,0xCD), o2(0xEF,0xCB), o2(0xEF,0xCC),
- o2(0xEF,0xCE), o2(0xEF,0xD0), o2(0xEF,0xD1), o2(0xEF,0xD2),
- o2(0xEF,0xD5), o2(0xEF,0xD3), o2(0xEF,0xD6), o2(0xEF,0xD8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_91 = {
- to_SHIFT_JIS_E9_91_offsets,
- to_EUC_JP_E9_91_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_92_infos[2] = {
- o2(0xEF,0xD7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_92 = {
- to_SHIFT_JIS_E9_92_offsets,
- to_EUC_JP_E9_92_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_95_infos[2] = {
- o2(0xC4,0xB9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_95 = {
- to_SHIFT_JIS_E9_95_offsets,
- to_EUC_JP_E9_95_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_96_infos[29] = {
- o2(0xCC,0xE7), o2(0xEF,0xD9), o2(0xC1,0xAE), o2(0xEF,0xDA),
- o2(0xCA,0xC4), o2(0xEF,0xDB), o2(0xB3,0xAB), o2(0xB1,0xBC),
- o2(0xB4,0xD7), o2(0xFC,0xCE), o2(0xB4,0xD6), o2(0xEF,0xDC),
- o2(0xEF,0xDD), o2(0xEF,0xDE), o2(0xEF,0xDF), o2(0xEF,0xE0),
- o2(0xB4,0xD8), o2(0xB3,0xD5), o2(0xB9,0xDE), o2(0xC8,0xB6),
- o2(0xEF,0xE2), o2(0xEF,0xE1), o2(0xEF,0xE3), o2(0xB1,0xDC),
- o2(0xEF,0xE6), o2(0xEF,0xE5), o2(0xEF,0xE4), o2(0xEF,0xE7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_96 = {
- to_SHIFT_JIS_E9_96_offsets,
- to_EUC_JP_E9_96_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_97_infos[14] = {
- o2(0xEF,0xEA), o2(0xB0,0xC7), o2(0xEF,0xE8), o2(0xEF,0xEC),
- o2(0xEF,0xEB), o2(0xEF,0xEE), o2(0xEF,0xED), o2(0xEF,0xEF),
- o2(0xC6,0xAE), o2(0xEF,0xF0), o2(0xEF,0xF1), o2(0xEF,0xF3),
- o2(0xEF,0xF2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_97 = {
- to_SHIFT_JIS_E9_97_offsets,
- to_EUC_JP_E9_97_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_98_infos[10] = {
- o2(0xC9,0xEC), o2(0xEF,0xF4), o2(0xEF,0xF5), o2(0xBA,0xE5),
- o2(0xEF,0xF6), o2(0xEF,0xF7), o2(0xCB,0xC9), o2(0xC1,0xCB),
- o2(0xB0,0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_98 = {
- to_SHIFT_JIS_E9_98_offsets,
- to_EUC_JP_E9_98_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_99_infos[30] = {
- o2(0xC2,0xCB), o2(0xEF,0xF8), o2(0xC9,0xED), o2(0xEF,0xFB),
- o2(0xEF,0xF9), o2(0xB9,0xDF), o2(0xEF,0xFA), o2(0xB8,0xC2),
- o2(0xCA,0xC5), o2(0xEF,0xFD), o2(0xF0,0xA1), o2(0xEF,0xFE),
- o2(0xF0,0xA2), o2(0xB1,0xA1), o2(0xBF,0xD8), o2(0xBD,0xFC),
- o2(0xB4,0xD9), o2(0xF0,0xA3), o2(0xC7,0xE6), o2(0xF0,0xA5),
- o2(0xB1,0xA2), o2(0xF0,0xA4), o2(0xC4,0xC4), o2(0xCE,0xCD),
- o2(0xC6,0xAB), o2(0xEF,0xFC), o2(0xCE,0xA6), o2(0xB8,0xB1),
- o2(0xCD,0xDB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_99 = {
- to_SHIFT_JIS_E9_99_offsets,
- to_EUC_JP_E9_99_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_9A_infos[33] = {
- o2(0xB6,0xF9), o2(0xCE,0xB4), o2(0xB7,0xA8), o2(0xC2,0xE2),
- o2(0xE7,0xA1), o2(0xF0,0xA6), o2(0xB3,0xAC), o2(0xBF,0xEF),
- o2(0xB3,0xD6), o2(0xF0,0xA8), o2(0xF0,0xA9), o2(0xF0,0xA7),
- o2(0xB7,0xE4), o2(0xBA,0xDD), o2(0xBE,0xE3), o2(0xFC,0xD1),
- o2(0xB1,0xA3), o2(0xCE,0xD9), o2(0xF0,0xAB), o2(0xEE,0xAE),
- o2(0xF0,0xAA), o2(0xFC,0xD2), o2(0xF0,0xAE), o2(0xF0,0xAC),
- o2(0xF0,0xAD), o2(0xF0,0xAF), o2(0xF0,0xB0), o2(0xCE,0xEC),
- o2(0xF0,0xB1), o2(0xF0,0xB2), o2(0xC0,0xC9), o2(0xC8,0xBB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_9A = {
- to_SHIFT_JIS_E9_9A_offsets,
- to_EUC_JP_E9_9A_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_9B_infos[29] = {
- o2(0xBF,0xFD), o2(0xB4,0xE7), o2(0xCD,0xBA), o2(0xB2,0xED),
- o2(0xBD,0xB8), o2(0xB8,0xDB), o2(0xF0,0xB5), o2(0xF0,0xB4),
- o2(0xBB,0xF3), o2(0xF0,0xB6), o2(0xF0,0xB3), o2(0xBB,0xA8),
- o2(0xF0,0xBA), o2(0xEA,0xAD), o2(0xD2,0xD6), o2(0xBF,0xF7),
- o2(0xF0,0xB8), o2(0xCE,0xA5), o2(0xC6,0xF1), o2(0xB1,0xAB),
- o2(0xC0,0xE3), o2(0xBC,0xB6), o2(0xCA,0xB7), o2(0xB1,0xC0),
- o2(0xCE,0xED), o2(0xCD,0xEB), o2(0xF0,0xBB), o2(0xC5,0xC5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_9B = {
- to_SHIFT_JIS_E9_9B_offsets,
- to_EUC_JP_E9_9B_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_9C_infos[27] = {
- o2(0xBC,0xFB), o2(0xF0,0xBC), o2(0xF0,0xBD), o2(0xBF,0xCC),
- o2(0xF0,0xBE), o2(0xCE,0xEE), o2(0xF0,0xB9), o2(0xF0,0xC0),
- o2(0xF0,0xC2), o2(0xF0,0xC1), o2(0xF0,0xBF), o2(0xF0,0xC3),
- o2(0xF0,0xC4), o2(0xC1,0xFA), o2(0xB2,0xE2), o2(0xF0,0xC5),
- o2(0xCC,0xB8), o2(0xF0,0xC6), o2(0xF0,0xC7), o2(0xCF,0xAA),
- o2(0xFC,0xD3), o2(0xDB,0xB1), o2(0xF0,0xC8), o2(0xFC,0xD4),
- o2(0xF0,0xC9), o2(0xF0,0xCA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_9C = {
- to_SHIFT_JIS_E9_9C_offsets,
- to_EUC_JP_E9_9C_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_9D_infos[30] = {
- o2(0xF0,0xCE), o2(0xFC,0xD5), o2(0xF0,0xCB), o2(0xF0,0xCC),
- o2(0xF0,0xCD), o2(0xF0,0xCF), o2(0xFC,0xD6), o2(0xFC,0xD7),
- o2(0xFC,0xD8), o2(0xC0,0xC4), o2(0xFC,0xD9), o2(0xCC,0xF7),
- o2(0xC0,0xC5), o2(0xF0,0xD0), o2(0xC8,0xF3), o2(0xF0,0xD1),
- o2(0xF3,0xD3), o2(0xCC,0xCC), o2(0xF0,0xD2), o2(0xF0,0xD3),
- o2(0xF0,0xD4), o2(0xB3,0xD7), o2(0xF0,0xD6), o2(0xBF,0xD9),
- o2(0xF0,0xD7), o2(0xB7,0xA4), o2(0xF0,0xD8), o2(0xF0,0xDC),
- o2(0xF0,0xDA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_9D = {
- to_SHIFT_JIS_E9_9D_offsets,
- to_EUC_JP_E9_9D_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_9E_infos[19] = {
- o2(0xF0,0xDB), o2(0xB3,0xF3), o2(0xF0,0xD9), o2(0xF0,0xDD),
- o2(0xF0,0xDE), o2(0xB0,0xC8), o2(0xF0,0xDF), o2(0xF0,0xE0),
- o2(0xBE,0xE4), o2(0xF0,0xE1), o2(0xB5,0xC7), o2(0xF0,0xE4),
- o2(0xF0,0xE3), o2(0xF0,0xE2), o2(0xEB,0xF1), o2(0xCA,0xDC),
- o2(0xF0,0xE5), o2(0xF0,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_9E = {
- to_SHIFT_JIS_E9_9E_offsets,
- to_EUC_JP_E9_9E_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_9F_infos[15] = {
- o2(0xF0,0xE7), o2(0xF0,0xE8), o2(0xF0,0xE9), o2(0xF0,0xEA),
- o2(0xB4,0xDA), o2(0xF0,0xEB), o2(0xF0,0xEC), o2(0xC7,0xA3),
- o2(0xF0,0xEE), o2(0xB2,0xBB), o2(0xF0,0xF1), o2(0xF0,0xF0),
- o2(0xB1,0xA4), o2(0xB6,0xC1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_9F = {
- to_SHIFT_JIS_E9_9F_offsets,
- to_EUC_JP_E9_9F_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A0_infos[26] = {
- o2(0xCA,0xC7), o2(0xC4,0xBA), o2(0xBA,0xA2), o2(0xB9,0xE0),
- o2(0xBD,0xE7), o2(0xBF,0xDC), o2(0xF0,0xF3), o2(0xF0,0xF2),
- o2(0xCD,0xC2), o2(0xB4,0xE8), o2(0xC8,0xD2), o2(0xC6,0xDC),
- o2(0xBF,0xFC), o2(0xCE,0xCE), o2(0xB7,0xDB), o2(0xF0,0xF6),
- o2(0xF0,0xF5), o2(0xCB,0xCB), o2(0xC6,0xAC), o2(0xB1,0xD0),
- o2(0xF0,0xF7), o2(0xF0,0xF4), o2(0xC9,0xD1), o2(0xCD,0xEA),
- o2(0xF0,0xF8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A0 = {
- to_SHIFT_JIS_E9_A0_offsets,
- to_EUC_JP_E9_A0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A1_infos[21] = {
- o2(0xF0,0xF9), o2(0xF0,0xFB), o2(0xC2,0xEA), o2(0xB3,0xDB),
- o2(0xB3,0xDC), o2(0xF0,0xFA), o2(0xB4,0xE9), o2(0xB8,0xB2),
- o2(0xFC,0xDA), o2(0xB4,0xEA), o2(0xC5,0xBF), o2(0xCE,0xE0),
- o2(0xFC,0xDB), o2(0xB8,0xDC), o2(0xF0,0xFC), o2(0xF0,0xFD),
- o2(0xF0,0xFE), o2(0xF1,0xA1), o2(0xF1,0xA3), o2(0xF1,0xA2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A1 = {
- to_SHIFT_JIS_E9_A1_offsets,
- to_EUC_JP_E9_A1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A2_infos[6] = {
- o2(0xC9,0xF7), o2(0xF1,0xA4), o2(0xF1,0xA5), o2(0xF1,0xA6),
- o2(0xF1,0xA7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A2 = {
- to_SHIFT_JIS_E9_A2_offsets,
- to_EUC_JP_E9_A2_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A3_infos[18] = {
- o2(0xF1,0xA9), o2(0xF1,0xA8), o2(0xF1,0xAA), o2(0xC8,0xF4),
- o2(0xE6,0xCC), o2(0xBF,0xA9), o2(0xB5,0xB2), o2(0xF1,0xAB),
- o2(0xF1,0xAC), o2(0xD2,0xAC), o2(0xDD,0xBB), o2(0xC8,0xD3),
- o2(0xB0,0xFB), o2(0xB0,0xBB), o2(0xBB,0xF4), o2(0xCB,0xB0),
- o2(0xBE,0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A3 = {
- to_SHIFT_JIS_E9_A3_offsets,
- to_EUC_JP_E9_A3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A4_infos[22] = {
- o2(0xF1,0xAD), o2(0xCC,0xDF), o2(0xF1,0xAE), o2(0xCD,0xDC),
- o2(0xB1,0xC2), o2(0xBB,0xC1), o2(0xF1,0xAF), o2(0xB2,0xEE),
- o2(0xF1,0xB0), o2(0xF1,0xB1), o2(0xF1,0xB3), o2(0xF1,0xB4),
- o2(0xF1,0xB6), o2(0xF1,0xB2), o2(0xF1,0xB5), o2(0xFC,0xDE),
- o2(0xB4,0xDB), o2(0xF1,0xB7), o2(0xF1,0xB8), o2(0xF1,0xB9),
- o2(0xF1,0xBA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A4 = {
- to_SHIFT_JIS_E9_A4_offsets,
- to_EUC_JP_E9_A4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A5_infos[11] = {
- o2(0xF1,0xBB), o2(0xF1,0xBD), o2(0xF1,0xBC), o2(0xF1,0xBF),
- o2(0xF1,0xC2), o2(0xF1,0xBE), o2(0xF1,0xC0), o2(0xF1,0xC1),
- o2(0xF1,0xC3), o2(0xB6,0xC2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A5 = {
- to_SHIFT_JIS_E9_A5_offsets,
- to_EUC_JP_E9_A5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A6_infos[14] = {
- o2(0xBC,0xF3), o2(0xF1,0xC4), o2(0xF1,0xC5), o2(0xB9,0xE1),
- o2(0xFC,0xE0), o2(0xF1,0xC6), o2(0xB3,0xBE), o2(0xC7,0xCF),
- o2(0xF1,0xC7), o2(0xF1,0xC8), o2(0xC3,0xDA), o2(0xC6,0xEB),
- o2(0xF1,0xC9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A6 = {
- to_SHIFT_JIS_E9_A6_offsets,
- to_EUC_JP_E9_A6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A7_infos[22] = {
- o2(0xC7,0xFD), o2(0xC2,0xCC), o2(0xB1,0xD8), o2(0xB6,0xEE),
- o2(0xB6,0xEF), o2(0xC3,0xF3), o2(0xF1,0xCE), o2(0xB6,0xF0),
- o2(0xB2,0xEF), o2(0xF1,0xCD), o2(0xF1,0xCB), o2(0xF1,0xCC),
- o2(0xF1,0xCA), o2(0xF1,0xD8), o2(0xF1,0xCF), o2(0xF1,0xD0),
- o2(0xF1,0xD1), o2(0xF1,0xD2), o2(0xF1,0xD4), o2(0xF1,0xD3),
- o2(0xBD,0xD9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A7 = {
- to_SHIFT_JIS_E9_A7_offsets,
- to_EUC_JP_E9_A7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A8_infos[13] = {
- o2(0xF1,0xD5), o2(0xF1,0xD7), o2(0xB5,0xB3), o2(0xF1,0xD6),
- o2(0xC1,0xFB), o2(0xB8,0xB3), o2(0xF1,0xD9), o2(0xC2,0xCD),
- o2(0xF1,0xDA), o2(0xC6,0xAD), o2(0xF1,0xDB), o2(0xF1,0xE0),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A8 = {
- to_SHIFT_JIS_E9_A8_offsets,
- to_EUC_JP_E9_A8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_A9_infos[18] = {
- o2(0xF1,0xDE), o2(0xF1,0xDD), o2(0xF1,0xDF), o2(0xF1,0xDC),
- o2(0xF1,0xE2), o2(0xFC,0xE1), o2(0xF1,0xE1), o2(0xF1,0xE4),
- o2(0xB6,0xC3), o2(0xF1,0xE3), o2(0xF1,0xE5), o2(0xF1,0xE6),
- o2(0xF1,0xE8), o2(0xF1,0xE7), o2(0xF1,0xE9), o2(0xF1,0xEB),
- o2(0xF1,0xEA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_A9 = {
- to_SHIFT_JIS_E9_A9_offsets,
- to_EUC_JP_E9_A9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_AA_infos[6] = {
- o2(0xB9,0xFC), o2(0xF1,0xEC), o2(0xF1,0xED), o2(0xB3,0xBC),
- o2(0xF1,0xEE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_AA = {
- to_SHIFT_JIS_E9_AA_offsets,
- to_EUC_JP_E9_AA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_AB_infos[24] = {
- o2(0xF1,0xEF), o2(0xBF,0xF1), o2(0xF1,0xF0), o2(0xF1,0xF1),
- o2(0xF1,0xF2), o2(0xF1,0xF3), o2(0xB9,0xE2), o2(0xFC,0xE2),
- o2(0xFC,0xE3), o2(0xF1,0xF4), o2(0xF1,0xF5), o2(0xF1,0xF6),
- o2(0xF1,0xF7), o2(0xF1,0xF8), o2(0xC8,0xB1), o2(0xF1,0xFA),
- o2(0xC9,0xA6), o2(0xF1,0xFB), o2(0xF1,0xF9), o2(0xF1,0xFD),
- o2(0xF1,0xFC), o2(0xF1,0xFE), o2(0xF2,0xA1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_AB = {
- to_SHIFT_JIS_E9_AB_offsets,
- to_EUC_JP_E9_AB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_AC_infos[18] = {
- o2(0xF2,0xA2), o2(0xF2,0xA3), o2(0xF2,0xA4), o2(0xF2,0xA5),
- o2(0xF2,0xA6), o2(0xF2,0xA7), o2(0xF2,0xA8), o2(0xF2,0xA9),
- o2(0xF2,0xAA), o2(0xF2,0xAB), o2(0xF2,0xAC), o2(0xF2,0xAD),
- o2(0xF2,0xAE), o2(0xDD,0xB5), o2(0xF2,0xAF), o2(0xE4,0xF8),
- o2(0xB5,0xB4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_AC = {
- to_SHIFT_JIS_E9_AC_offsets,
- to_EUC_JP_E9_AC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_AD_infos[17] = {
- o2(0xB3,0xA1), o2(0xBA,0xB2), o2(0xF2,0xB1), o2(0xF2,0xB0),
- o2(0xCC,0xA5), o2(0xF2,0xB3), o2(0xF2,0xB4), o2(0xF2,0xB2),
- o2(0xF2,0xB5), o2(0xCB,0xE2), o2(0xF2,0xB6), o2(0xB5,0xFB),
- o2(0xCF,0xA5), o2(0xFC,0xE5), o2(0xF2,0xB7), o2(0xFC,0xE4),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_AD = {
- to_SHIFT_JIS_E9_AD_offsets,
- to_EUC_JP_E9_AD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_AE_infos[20] = {
- o2(0xF2,0xB9), o2(0xB0,0xBE), o2(0xFC,0xE6), o2(0xF2,0xBA),
- o2(0xCA,0xAB), o2(0xF2,0xB8), o2(0xF2,0xBB), o2(0xF2,0xBC),
- o2(0xF2,0xBD), o2(0xF2,0xBE), o2(0xF2,0xBF), o2(0xCB,0xEE),
- o2(0xBB,0xAD), o2(0xBA,0xFA), o2(0xC1,0xAF), o2(0xFC,0xE7),
- o2(0xF2,0xC0), o2(0xF2,0xC3), o2(0xFC,0xE8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_AE = {
- to_SHIFT_JIS_E9_AE_offsets,
- to_EUC_JP_E9_AE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_AF_infos[20] = {
- o2(0xF2,0xC1), o2(0xF2,0xC4), o2(0xB8,0xF1), o2(0xF2,0xC2),
- o2(0xF2,0xC5), o2(0xF2,0xC6), o2(0xF2,0xC7), o2(0xF2,0xCB),
- o2(0xBB,0xAA), o2(0xC2,0xE4), o2(0xF2,0xCC), o2(0xF2,0xC9),
- o2(0xF2,0xC8), o2(0xF2,0xCA), o2(0xB7,0xDF), o2(0xF2,0xD0),
- o2(0xF2,0xCF), o2(0xF2,0xCE), o2(0xB0,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_AF = {
- to_SHIFT_JIS_E9_AF_offsets,
- to_EUC_JP_E9_AF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B0_infos[27] = {
- o2(0xFC,0xE9), o2(0xF2,0xDA), o2(0xF2,0xD6), o2(0xF2,0xD7),
- o2(0xF2,0xD3), o2(0xF2,0xD9), o2(0xF2,0xD5), o2(0xB3,0xE2),
- o2(0xCF,0xCC), o2(0xF2,0xD8), o2(0xF2,0xD4), o2(0xF2,0xD2),
- o2(0xF2,0xD1), o2(0xF2,0xDC), o2(0xF2,0xDF), o2(0xF2,0xDE),
- o2(0xF2,0xDD), o2(0xC9,0xC9), o2(0xF2,0xDB), o2(0xB0,0xF3),
- o2(0xF2,0xE0), o2(0xF2,0xE2), o2(0xB3,0xEF), o2(0xF2,0xCD),
- o2(0xB1,0xB7), o2(0xF2,0xE4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B0 = {
- to_SHIFT_JIS_E9_B0_offsets,
- to_EUC_JP_E9_B0_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B1_infos[11] = {
- o2(0xF2,0xE3), o2(0xF2,0xE1), o2(0xC3,0xAD), o2(0xCB,0xF0),
- o2(0xCE,0xDA), o2(0xF2,0xE5), o2(0xF2,0xE6), o2(0xF2,0xE7),
- o2(0xF2,0xE8), o2(0xF2,0xE9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B1 = {
- to_SHIFT_JIS_E9_B1_offsets,
- to_EUC_JP_E9_B1_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B3_infos[10] = {
- o2(0xC4,0xBB), o2(0xF2,0xEA), o2(0xC8,0xB7), o2(0xF2,0xEF),
- o2(0xF2,0xEB), o2(0xF2,0xEC), o2(0xCB,0xB1), o2(0xCC,0xC4),
- o2(0xC6,0xD0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B3 = {
- to_SHIFT_JIS_E9_B3_offsets,
- to_EUC_JP_E9_B3_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B4_infos[20] = {
- o2(0xF2,0xF0), o2(0xF2,0xF1), o2(0xC6,0xBE), o2(0xF2,0xEE),
- o2(0xF2,0xED), o2(0xB2,0xAA), o2(0xF2,0xF9), o2(0xF2,0xF8),
- o2(0xB1,0xF5), o2(0xF2,0xF6), o2(0xF2,0xF5), o2(0xF2,0xF3),
- o2(0xB3,0xFB), o2(0xF2,0xF2), o2(0xBC,0xB2), o2(0xB2,0xA9),
- o2(0xB9,0xE3), o2(0xF2,0xFC), o2(0xF2,0xFB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B4 = {
- to_SHIFT_JIS_E9_B4_offsets,
- to_EUC_JP_E9_B4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B5_infos[20] = {
- o2(0xF2,0xFA), o2(0xF2,0xF7), o2(0xF2,0xFD), o2(0xF2,0xFE),
- o2(0xF3,0xA5), o2(0xF3,0xA4), o2(0xF3,0xA6), o2(0xB1,0xAD),
- o2(0xF3,0xA1), o2(0xF3,0xA2), o2(0xB9,0xF4), o2(0xCC,0xB9),
- o2(0xF3,0xA3), o2(0xFC,0xEB), o2(0xCB,0xB2), o2(0xF3,0xAB),
- o2(0xFC,0xEA), o2(0xF3,0xA7), o2(0xF3,0xAC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B5 = {
- to_SHIFT_JIS_E9_B5_offsets,
- to_EUC_JP_E9_B5_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B6_infos[14] = {
- o2(0xF3,0xA9), o2(0xF3,0xA8), o2(0xB7,0xDC), o2(0xF3,0xAD),
- o2(0xF3,0xAE), o2(0xF3,0xAF), o2(0xF3,0xAA), o2(0xF2,0xF4),
- o2(0xF3,0xB0), o2(0xC4,0xE1), o2(0xF3,0xB4), o2(0xF3,0xB5),
- o2(0xF3,0xB3), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B6 = {
- to_SHIFT_JIS_E9_B6_offsets,
- to_EUC_JP_E9_B6_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B7_infos[16] = {
- o2(0xF3,0xB2), o2(0xF3,0xB8), o2(0xF3,0xB1), o2(0xF3,0xB6),
- o2(0xF3,0xB7), o2(0xF3,0xBA), o2(0xF3,0xB9), o2(0xF3,0xBC),
- o2(0xF3,0xBD), o2(0xF3,0xBE), o2(0xCF,0xC9), o2(0xF3,0xBB),
- o2(0xC2,0xEB), o2(0xBA,0xED), o2(0xF3,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B7 = {
- to_SHIFT_JIS_E9_B7_offsets,
- to_EUC_JP_E9_B7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B8_infos[5] = {
- o2(0xFC,0xED), o2(0xF3,0xC0), o2(0xF3,0xC1), o2(0xF3,0xC2),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B8 = {
- to_SHIFT_JIS_E9_B8_offsets,
- to_EUC_JP_E9_B8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_B9_infos[6] = {
- o2(0xF3,0xC3), o2(0xB8,0xB4), o2(0xF3,0xC4), o2(0xF3,0xC5),
- o2(0xBC,0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_B9 = {
- to_SHIFT_JIS_E9_B9_offsets,
- to_EUC_JP_E9_B9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_BA_infos[24] = {
- o2(0xF3,0xC6), o2(0xF3,0xC7), o2(0xF3,0xC8), o2(0xF3,0xC9),
- o2(0xF3,0xCC), o2(0xF3,0xCA), o2(0xCF,0xBC), o2(0xF3,0xCB),
- o2(0xCE,0xEF), o2(0xF3,0xCD), o2(0xCE,0xDB), o2(0xF3,0xCE),
- o2(0xC7,0xFE), o2(0xF3,0xCF), o2(0xF3,0xD1), o2(0xF3,0xD2),
- o2(0xF3,0xD0), o2(0xB9,0xED), o2(0xCC,0xCD), o2(0xCB,0xE3),
- o2(0xD6,0xF7), o2(0xDD,0xE0), o2(0xCB,0xFB), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_BA = {
- to_SHIFT_JIS_E9_BA_offsets,
- to_EUC_JP_E9_BA_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_BB_infos[27] = {
- o2(0xB2,0xAB), o2(0xF3,0xD4), o2(0xB5,0xD0), o2(0xF3,0xD5),
- o2(0xF3,0xD6), o2(0xF3,0xD7), o2(0xFC,0xEE), o2(0xB9,0xF5),
- o2(0xF3,0xD8), o2(0xE0,0xD4), o2(0xCC,0xDB), o2(0xC2,0xE3),
- o2(0xF3,0xD9), o2(0xF3,0xDB), o2(0xF3,0xDA), o2(0xF3,0xDC),
- o2(0xF3,0xDD), o2(0xF3,0xDE), o2(0xF3,0xDF), o2(0xF3,0xE0),
- o2(0xF3,0xE1), o2(0xF3,0xE2), o2(0xF3,0xE3), o2(0xF3,0xE4),
- o2(0xF3,0xE5), o2(0xF3,0xE6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_BB = {
- to_SHIFT_JIS_E9_BB_offsets,
- to_EUC_JP_E9_BB_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_BC_infos[11] = {
- o2(0xF3,0xE7), o2(0xF3,0xE8), o2(0xC5,0xA4), o2(0xB8,0xDD),
- o2(0xF3,0xEA), o2(0xC1,0xCD), o2(0xF3,0xEB), o2(0xF3,0xEC),
- o2(0xC9,0xA1), o2(0xF3,0xED), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_BC = {
- to_SHIFT_JIS_E9_BC_offsets,
- to_EUC_JP_E9_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_BD_infos[19] = {
- o2(0xF3,0xEE), o2(0xE3,0xB7), o2(0xEC,0xDA), o2(0xF0,0xED),
- o2(0xF3,0xEF), o2(0xF3,0xF0), o2(0xF3,0xF2), o2(0xF3,0xF3),
- o2(0xF3,0xF4), o2(0xCE,0xF0), o2(0xF3,0xF1), o2(0xF3,0xF5),
- o2(0xF3,0xF6), o2(0xF3,0xF8), o2(0xF3,0xF7), o2(0xF3,0xFA),
- o2(0xF3,0xFB), o2(0xF3,0xF9), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_BD = {
- to_SHIFT_JIS_E9_BD_offsets,
- to_EUC_JP_E9_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_BE_infos[6] = {
- o2(0xCE,0xB6), o2(0xF3,0xFC), o2(0xF3,0xFD), o2(0xE3,0xD4),
- o2(0xF3,0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9_BE = {
- to_SHIFT_JIS_E9_BE_offsets,
- to_EUC_JP_E9_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_E9_infos[61] = {
- &to_EUC_JP_E9_80, &to_EUC_JP_E9_81, &to_EUC_JP_E9_82, &to_EUC_JP_E9_83,
- &to_EUC_JP_E9_84, &to_EUC_JP_E9_85, &to_EUC_JP_E9_86, &to_EUC_JP_E9_87,
- &to_EUC_JP_E9_88, &to_EUC_JP_E9_89, &to_EUC_JP_E9_8A, &to_EUC_JP_E9_8B,
- &to_EUC_JP_E9_8C, &to_EUC_JP_E9_8D, &to_EUC_JP_E9_8E, &to_EUC_JP_E9_8F,
- &to_EUC_JP_E9_90, &to_EUC_JP_E9_91, &to_EUC_JP_E9_92, &to_EUC_JP_E9_95,
- &to_EUC_JP_E9_96, &to_EUC_JP_E9_97, &to_EUC_JP_E9_98, &to_EUC_JP_E9_99,
- &to_EUC_JP_E9_9A, &to_EUC_JP_E9_9B, &to_EUC_JP_E9_9C, &to_EUC_JP_E9_9D,
- &to_EUC_JP_E9_9E, &to_EUC_JP_E9_9F, &to_EUC_JP_E9_A0, &to_EUC_JP_E9_A1,
- &to_EUC_JP_E9_A2, &to_EUC_JP_E9_A3, &to_EUC_JP_E9_A4, &to_EUC_JP_E9_A5,
- &to_EUC_JP_E9_A6, &to_EUC_JP_E9_A7, &to_EUC_JP_E9_A8, &to_EUC_JP_E9_A9,
- &to_EUC_JP_E9_AA, &to_EUC_JP_E9_AB, &to_EUC_JP_E9_AC, &to_EUC_JP_E9_AD,
- &to_EUC_JP_E9_AE, &to_EUC_JP_E9_AF, &to_EUC_JP_E9_B0, &to_EUC_JP_E9_B1,
- &to_EUC_JP_E9_B3, &to_EUC_JP_E9_B4, &to_EUC_JP_E9_B5, &to_EUC_JP_E9_B6,
- &to_EUC_JP_E9_B7, &to_EUC_JP_E9_B8, &to_EUC_JP_E9_B9, &to_EUC_JP_E9_BA,
- &to_EUC_JP_E9_BB, &to_EUC_JP_E9_BC, &to_EUC_JP_E9_BD, &to_EUC_JP_E9_BE,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_E9 = {
- to_SHIFT_JIS_E9_offsets,
- to_EUC_JP_E9_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_A4_infos[2] = {
- o2(0xFA,0xC6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF_A4 = {
- to_SHIFT_JIS_EF_A4_offsets,
- to_EUC_JP_EF_A4_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_A7_infos[2] = {
- o2(0xFC,0xCF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF_A7 = {
- to_SHIFT_JIS_EF_A7_offsets,
- to_EUC_JP_EF_A7_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_A8_infos[33] = {
- o2(0xF9,0xD4), o2(0xF9,0xDF), o2(0xF9,0xE0), o2(0xF9,0xF5),
- o2(0xFA,0xBE), o2(0xFA,0xCE), o2(0xFA,0xD0), o2(0xFA,0xFB),
- o2(0xFB,0xA3), o2(0xFB,0xBA), o2(0xFB,0xC2), o2(0xFB,0xC3),
- o2(0xFB,0xC4), o2(0xFB,0xC6), o2(0xFB,0xCA), o2(0xFB,0xCD),
- o2(0xFB,0xD6), o2(0xFB,0xE1), o2(0xFB,0xE3), o2(0xFB,0xE4),
- o2(0xFB,0xED), o2(0xFB,0xF5), o2(0xFB,0xF7), o2(0xFB,0xF8),
- o2(0xFB,0xFB), o2(0xFC,0xB9), o2(0xFC,0xC0), o2(0xFC,0xD0),
- o2(0xFC,0xDC), o2(0xFC,0xDD), o2(0xFC,0xDF), o2(0xFC,0xEC),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF_A8 = {
- to_SHIFT_JIS_EF_A8_offsets,
- to_EUC_JP_EF_A8_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_BC_infos[62] = {
- o2(0xA1,0xAA), o2(0xFC,0xFE), o2(0xA1,0xF4), o2(0xA1,0xF0),
- o2(0xA1,0xF3), o2(0xA1,0xF5), o2(0xFC,0xFD), o2(0xA1,0xCA),
- o2(0xA1,0xCB), o2(0xA1,0xF6), o2(0xA1,0xDC), o2(0xA1,0xA5),
- o2(0xA1,0xBF), o2(0xA3,0xB0), o2(0xA3,0xB1), o2(0xA3,0xB2),
- o2(0xA3,0xB3), o2(0xA3,0xB4), o2(0xA3,0xB5), o2(0xA3,0xB6),
- o2(0xA3,0xB7), o2(0xA3,0xB8), o2(0xA3,0xB9), o2(0xA1,0xA7),
- o2(0xA1,0xA8), o2(0xA1,0xE3), o2(0xA1,0xE1), o2(0xA1,0xE4),
- o2(0xA1,0xA9), o2(0xA1,0xF7), o2(0xA3,0xC1), o2(0xA3,0xC2),
- o2(0xA3,0xC3), o2(0xA3,0xC4), o2(0xA3,0xC5), o2(0xA3,0xC6),
- o2(0xA3,0xC7), o2(0xA3,0xC8), o2(0xA3,0xC9), o2(0xA3,0xCA),
- o2(0xA3,0xCB), o2(0xA3,0xCC), o2(0xA3,0xCD), o2(0xA3,0xCE),
- o2(0xA3,0xCF), o2(0xA3,0xD0), o2(0xA3,0xD1), o2(0xA3,0xD2),
- o2(0xA3,0xD3), o2(0xA3,0xD4), o2(0xA3,0xD5), o2(0xA3,0xD6),
- o2(0xA3,0xD7), o2(0xA3,0xD8), o2(0xA3,0xD9), o2(0xA3,0xDA),
- o2(0xA1,0xCE), o2(0xA1,0xC0), o2(0xA1,0xCF), o2(0xA1,0xB0),
- o2(0xA1,0xB2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF_BC = {
- to_SHIFT_JIS_EF_BC_offsets,
- to_EUC_JP_EF_BC_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_BD_infos[62] = {
- o2(0xA1,0xAE), o2(0xA3,0xE1), o2(0xA3,0xE2), o2(0xA3,0xE3),
- o2(0xA3,0xE4), o2(0xA3,0xE5), o2(0xA3,0xE6), o2(0xA3,0xE7),
- o2(0xA3,0xE8), o2(0xA3,0xE9), o2(0xA3,0xEA), o2(0xA3,0xEB),
- o2(0xA3,0xEC), o2(0xA3,0xED), o2(0xA3,0xEE), o2(0xA3,0xEF),
- o2(0xA3,0xF0), o2(0xA3,0xF1), o2(0xA3,0xF2), o2(0xA3,0xF3),
- o2(0xA3,0xF4), o2(0xA3,0xF5), o2(0xA3,0xF6), o2(0xA3,0xF7),
- o2(0xA3,0xF8), o2(0xA3,0xF9), o2(0xA3,0xFA), o2(0xA1,0xD0),
- o2(0xA1,0xC3), o2(0xA1,0xD1), o2(0x8E,0xA1), o2(0x8E,0xA2),
- o2(0x8E,0xA3), o2(0x8E,0xA4), o2(0x8E,0xA5), o2(0x8E,0xA6),
- o2(0x8E,0xA7), o2(0x8E,0xA8), o2(0x8E,0xA9), o2(0x8E,0xAA),
- o2(0x8E,0xAB), o2(0x8E,0xAC), o2(0x8E,0xAD), o2(0x8E,0xAE),
- o2(0x8E,0xAF), o2(0x8E,0xB0), o2(0x8E,0xB1), o2(0x8E,0xB2),
- o2(0x8E,0xB3), o2(0x8E,0xB4), o2(0x8E,0xB5), o2(0x8E,0xB6),
- o2(0x8E,0xB7), o2(0x8E,0xB8), o2(0x8E,0xB9), o2(0x8E,0xBA),
- o2(0x8E,0xBB), o2(0x8E,0xBC), o2(0x8E,0xBD), o2(0x8E,0xBE),
- o2(0x8E,0xBF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF_BD = {
- to_SHIFT_JIS_EF_BD_offsets,
- to_EUC_JP_EF_BD_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_BE_infos[33] = {
- o2(0x8E,0xC0), o2(0x8E,0xC1), o2(0x8E,0xC2), o2(0x8E,0xC3),
- o2(0x8E,0xC4), o2(0x8E,0xC5), o2(0x8E,0xC6), o2(0x8E,0xC7),
- o2(0x8E,0xC8), o2(0x8E,0xC9), o2(0x8E,0xCA), o2(0x8E,0xCB),
- o2(0x8E,0xCC), o2(0x8E,0xCD), o2(0x8E,0xCE), o2(0x8E,0xCF),
- o2(0x8E,0xD0), o2(0x8E,0xD1), o2(0x8E,0xD2), o2(0x8E,0xD3),
- o2(0x8E,0xD4), o2(0x8E,0xD5), o2(0x8E,0xD6), o2(0x8E,0xD7),
- o2(0x8E,0xD8), o2(0x8E,0xD9), o2(0x8E,0xDA), o2(0x8E,0xDB),
- o2(0x8E,0xDC), o2(0x8E,0xDD), o2(0x8E,0xDE), o2(0x8E,0xDF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF_BE = {
- to_SHIFT_JIS_EF_BE_offsets,
- to_EUC_JP_EF_BE_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_EF_infos[7] = {
- &to_EUC_JP_EF_A4, &to_EUC_JP_EF_A7, &to_EUC_JP_EF_A8, &to_EUC_JP_EF_BC,
- &to_EUC_JP_EF_BD, &to_EUC_JP_EF_BE, UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP_EF = {
- to_SHIFT_JIS_EF_offsets,
- to_EUC_JP_EF_infos
-};
-
-static const struct byte_lookup* const
-to_EUC_JP_infos[17] = {
- NOMAP, &to_EUC_JP_C2, &to_EUC_JP_C3, &to_EUC_JP_CE,
- &to_EUC_JP_CF, &to_EUC_JP_D0, &to_EUC_JP_D1, &to_EUC_JP_E2,
- &to_EUC_JP_E3, &to_EUC_JP_E4, &to_EUC_JP_E5, &to_EUC_JP_E6,
- &to_EUC_JP_E7, &to_EUC_JP_E8, &to_EUC_JP_E9, &to_EUC_JP_EF,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_EUC_JP = {
- to_SHIFT_JIS_offsets,
- to_EUC_JP_infos
-};
-static rb_transcoder
-rb_to_EUC_JP = {
- "UTF-8", "EUC-JP", &to_EUC_JP, 2, 1,
- NULL, NULL,
-};
-
-#define ISO_2022_ENCODING(escseq, byte) ((escseq<<8)|byte)
-enum ISO_2022_ESCSEQ {
- ISO_2022_CZD = '!',
- ISO_2022_C1D = '"',
- ISO_2022_GZD4 = '(',
- ISO_2022_G1D4 = ')',
- ISO_2022_G2D4 = '*',
- ISO_2022_G3D4 = '+',
- ISO_2022_G1D6 = '-',
- ISO_2022_G2D6 = '.',
- ISO_2022_G3D6 = '/',
- ISO_2022_GZDM4 = ISO_2022_ENCODING('$','('),
- ISO_2022_G1DM4 = ISO_2022_ENCODING('$',')'),
- ISO_2022_G2DM4 = ISO_2022_ENCODING('$','*'),
- ISO_2022_G3DM4 = ISO_2022_ENCODING('$','+'),
- ISO_2022_G1DM6 = ISO_2022_ENCODING('$','-'),
- ISO_2022_G2DM6 = ISO_2022_ENCODING('$','.'),
- ISO_2022_G3DM6 = ISO_2022_ENCODING('$','/'),
- ISO_2022_DOCS = ISO_2022_ENCODING('%','I'),
- ISO_2022_IRR = '&'
-};
-
-
-#define ISO_2022_GZ_ASCII ISO_2022_ENCODING(ISO_2022_GZD4, 'B')
-#define ISO_2022_GZ_JIS_X_0201_Katakana ISO_2022_ENCODING(ISO_2022_GZD4, 'I')
-#define ISO_2022_GZ_JIS_X_0201_Roman ISO_2022_ENCODING(ISO_2022_GZD4, 'J')
-#define ISO_2022_GZ_JIS_C_6226_1978 ISO_2022_ENCODING(ISO_2022_GZDM4,'@')
-#define ISO_2022_GZ_JIS_X_0208_1983 ISO_2022_ENCODING(ISO_2022_GZDM4,'B')
-#define ISO_2022_GZ_JIS_X_0212_1990 ISO_2022_ENCODING(ISO_2022_GZDM4,'D')
-#define ISO_2022_GZ_JIS_X_0213_2000_1 ISO_2022_ENCODING(ISO_2022_GZDM4,'O')
-#define ISO_2022_GZ_JIS_X_0213_2000_2 ISO_2022_ENCODING(ISO_2022_GZDM4,'P')
-#define ISO_2022_GZ_JIS_X_0213_2004_1 ISO_2022_ENCODING(ISO_2022_GZDM4,'Q')
-
-static int
-get_iso_2022_mode(char **in_pos)
-{
- int new_mode;
- char *in_p = *in_pos;
- switch (*in_p++)
- {
- case '(':
- switch (*in_p++)
- {
- case 'B': case 'I': case 'J':
- new_mode = ISO_2022_ENCODING(ISO_2022_GZD4, *(in_p-1));
- break;
- default:
- rb_raise(rb_eRuntimeError /*change exception*/, "this mode is not supported (ESC ( %c)", *(in_p-1));
- break;
- }
- break;
- case '$':
- switch (*in_p++)
- {
- case '@': case 'A': case 'B':
- new_mode = ISO_2022_ENCODING(ISO_2022_GZDM4, *(in_p-1));
- break;
- case '(':
- switch (*in_p++)
- {
- case 'D': case 'O': case 'P': case 'Q':
- new_mode = ISO_2022_ENCODING(ISO_2022_GZDM4, *(in_p-1));
- break;
- default:
- rb_raise(rb_eRuntimeError /*change exception*/, "this mode is not supported (ESC $ ( %c)", *(in_p-1));
- break;
- }
- break;
- default:
- rb_raise(rb_eRuntimeError /*change exception*/, "this mode is not supported (ESC $ %c)", *(in_p-1));
- break;
- }
- break;
- default:
- rb_raise(rb_eRuntimeError /*change exception*/, "this mode is not supported (ESC %c)", *(in_p-1));
- break;
- }
- *in_pos = in_p;
- return new_mode;
-}
-
-static void
-from_iso_2022_jp_transcoder_preprocessor(char **in_pos, char **out_pos,
- char *in_stop, char *out_stop,
- rb_transcoder *my_transcoder,
- rb_transcoding *my_transcoding)
-{
- char *in_p = *in_pos, *out_p = *out_pos;
- int cur_mode = ISO_2022_GZ_ASCII;
- unsigned char c1;
- char *out_s = out_stop - my_transcoder->max_output + 1;
- while (in_p < in_stop) {
- if (out_p >= out_s) {
- int len = (out_p - *out_pos);
- int new_len = (len + my_transcoder->max_output) * 2;
- *out_pos = (*my_transcoding->flush_func)(my_transcoding, len, new_len);
- out_p = *out_pos + len;
- out_s = *out_pos + new_len - my_transcoder->max_output;
- }
- c1 = *in_p++;
- if (c1 == 0x1B) {
- cur_mode = get_iso_2022_mode(&in_p);
- } else if (c1 == 0x1E || c1 == 0x1F) {
- /* SHIFT */
- rb_raise(rb_eRuntimeError /*change exception*/, "shift is not supported");
- } else if (c1 >= 0x80) {
- rb_raise(rb_eRuntimeError /*change exception*/, "illegal byte sequence");
- } else {
- switch (cur_mode) {
- case ISO_2022_GZ_ASCII:
- case ISO_2022_GZ_JIS_X_0201_Roman:
- *out_p++ = c1;
- break;
- case ISO_2022_GZ_JIS_X_0201_Katakana:
- *out_p++ = 0x8E;
- *out_p++ = c1 | 0x80;
- break;
- case ISO_2022_GZ_JIS_X_0212_1990:
- *out_p++ = 0x8F;
- case ISO_2022_GZ_JIS_C_6226_1978:
- case ISO_2022_GZ_JIS_X_0208_1983:
- *out_p++ = c1 | 0x80;
- *out_p++ = *in_p++ | 0x80;
- break;
- }
- }
- }
- /* cleanup */
- *in_pos = in_p;
- *out_pos = out_p;
-}
-
-static int
-select_iso_2022_mode(char **out_pos, int new_mode)
-{
- char *out_p = *out_pos;
- *out_p++ = '\x1b';
- switch (new_mode>>8)
- {
- case ISO_2022_GZD4:
- *out_p++ = new_mode >> 8;
- *out_p++ = new_mode & 0x7F;
- break;
- case ISO_2022_GZDM4:
- *out_p++ = new_mode >> 16;
- if ((new_mode & 0x7F) != '@' &&
- (new_mode & 0x7F) != 'A' &&
- (new_mode & 0x7F) != 'B')
- {
- *out_p++ = (new_mode>>8) & 0x7F;
- }
- *out_p++ = new_mode & 0x7F;
- break;
- default:
- rb_raise(rb_eRuntimeError /*change exception*/, "this mode is not supported.");
- break;
- }
- *out_pos = out_p;
- return new_mode;
-}
-
-static void
-to_iso_2022_jp_transcoder_postprocessor(char **in_pos, char **out_pos,
- char *in_stop, char *out_stop,
- rb_transcoder *my_transcoder,
- rb_transcoding *my_transcoding)
-{
- char *in_p = *in_pos, *out_p = *out_pos;
- int cur_mode = ISO_2022_GZ_ASCII, new_mode = 0;
- unsigned char next_byte;
- char *out_s = out_stop - my_transcoder->max_output + 1;
- while (in_p < in_stop) {
- if (out_p >= out_s) {
- int len = (out_p - *out_pos);
- int new_len = (len + my_transcoder->max_output) * 2;
- *out_pos = (*my_transcoding->flush_func)(my_transcoding, len, new_len);
- out_p = *out_pos + len;
- out_s = *out_pos + new_len - my_transcoder->max_output;
- }
- next_byte = *in_p++;
- if (next_byte < 0x80) {
- new_mode = ISO_2022_GZ_ASCII;
- } else if (next_byte == 0x8E) {
- new_mode = ISO_2022_GZ_JIS_X_0201_Katakana;
- next_byte = *in_p++;
- } else if (next_byte == 0x8F) {
- new_mode = ISO_2022_GZ_JIS_X_0212_1990;
- next_byte = *in_p++;
- } else {
- new_mode = ISO_2022_GZ_JIS_X_0208_1983;
- }
- if (cur_mode != new_mode)
- cur_mode = select_iso_2022_mode(&out_p, new_mode);
- if (cur_mode < 0xFFFF) {
- *out_p++ = next_byte & 0x7F;
- } else {
- *out_p++ = next_byte & 0x7F;
- *out_p++ = *in_p++ & 0x7F;
- }
- }
- if (cur_mode != ISO_2022_GZ_ASCII)
- cur_mode = select_iso_2022_mode(&out_p, ISO_2022_GZ_ASCII);
- /* cleanup */
- *in_pos = in_p;
- *out_pos = out_p;
-}
-
-static rb_transcoder
-rb_from_ISO_2022_JP = {
- "ISO-2022-JP", "UTF-8", &from_EUC_JP, 8, 0,
- &from_iso_2022_jp_transcoder_preprocessor, NULL,
-};
-
-static rb_transcoder
-rb_to_ISO_2022_JP = {
- "UTF-8", "ISO-2022-JP", &to_EUC_JP, 8, 1,
- NULL, &to_iso_2022_jp_transcoder_postprocessor,
-};
-
-void
-Init_japanese(void)
-{
- rb_register_transcoder(&rb_from_SHIFT_JIS);
- rb_register_transcoder(&rb_from_EUC_JP);
- rb_register_transcoder(&rb_to_SHIFT_JIS);
- rb_register_transcoder(&rb_to_EUC_JP);
- rb_register_transcoder(&rb_from_ISO_2022_JP);
- rb_register_transcoder(&rb_to_ISO_2022_JP);
-}
diff --git a/enc/trans/single_byte.c b/enc/trans/single_byte.c
deleted file mode 100644
index bbfb3f5f9a..0000000000
--- a/enc/trans/single_byte.c
+++ /dev/null
@@ -1,3020 +0,0 @@
-#include "transcode_data.h"
-
-static const unsigned char
-from_ISO_8859_1_offsets[256] = {
- /* used from from_ISO_8859_1 */
- /* used from from_ISO_8859_2 */
- /* used from from_ISO_8859_4 */
- /* used from from_ISO_8859_5 */
- /* used from from_ISO_8859_9 */
- /* used from from_ISO_8859_10 */
- /* used from from_ISO_8859_13 */
- /* used from from_ISO_8859_14 */
- /* used from from_ISO_8859_15 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
- 97, 98, 99,100,101,102,103,104, 105,106,107,108,109,110,111,112,
- 113,114,115,116,117,118,119,120, 121,122,123,124,125,126,127,128,
-};
-static const struct byte_lookup* const
-from_ISO_8859_1_infos[129] = {
- NOMAP, o2(0xC2,0x80), o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84), o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88), o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C), o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90), o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94), o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98), o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C), o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0), o2(0xC2,0xA1), o2(0xC2,0xA2),
- o2(0xC2,0xA3), o2(0xC2,0xA4), o2(0xC2,0xA5), o2(0xC2,0xA6),
- o2(0xC2,0xA7), o2(0xC2,0xA8), o2(0xC2,0xA9), o2(0xC2,0xAA),
- o2(0xC2,0xAB), o2(0xC2,0xAC), o2(0xC2,0xAD), o2(0xC2,0xAE),
- o2(0xC2,0xAF), o2(0xC2,0xB0), o2(0xC2,0xB1), o2(0xC2,0xB2),
- o2(0xC2,0xB3), o2(0xC2,0xB4), o2(0xC2,0xB5), o2(0xC2,0xB6),
- o2(0xC2,0xB7), o2(0xC2,0xB8), o2(0xC2,0xB9), o2(0xC2,0xBA),
- o2(0xC2,0xBB), o2(0xC2,0xBC), o2(0xC2,0xBD), o2(0xC2,0xBE),
- o2(0xC2,0xBF), o2(0xC3,0x80), o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC3,0x83), o2(0xC3,0x84), o2(0xC3,0x85), o2(0xC3,0x86),
- o2(0xC3,0x87), o2(0xC3,0x88), o2(0xC3,0x89), o2(0xC3,0x8A),
- o2(0xC3,0x8B), o2(0xC3,0x8C), o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC3,0x8F), o2(0xC3,0x90), o2(0xC3,0x91), o2(0xC3,0x92),
- o2(0xC3,0x93), o2(0xC3,0x94), o2(0xC3,0x95), o2(0xC3,0x96),
- o2(0xC3,0x97), o2(0xC3,0x98), o2(0xC3,0x99), o2(0xC3,0x9A),
- o2(0xC3,0x9B), o2(0xC3,0x9C), o2(0xC3,0x9D), o2(0xC3,0x9E),
- o2(0xC3,0x9F), o2(0xC3,0xA0), o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC3,0xA3), o2(0xC3,0xA4), o2(0xC3,0xA5), o2(0xC3,0xA6),
- o2(0xC3,0xA7), o2(0xC3,0xA8), o2(0xC3,0xA9), o2(0xC3,0xAA),
- o2(0xC3,0xAB), o2(0xC3,0xAC), o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC3,0xAF), o2(0xC3,0xB0), o2(0xC3,0xB1), o2(0xC3,0xB2),
- o2(0xC3,0xB3), o2(0xC3,0xB4), o2(0xC3,0xB5), o2(0xC3,0xB6),
- o2(0xC3,0xB7), o2(0xC3,0xB8), o2(0xC3,0xB9), o2(0xC3,0xBA),
- o2(0xC3,0xBB), o2(0xC3,0xBC), o2(0xC3,0xBD), o2(0xC3,0xBE),
- o2(0xC3,0xBF),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_1 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_1_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_1 = {
- "ISO-8859-1", "UTF-8", &from_ISO_8859_1, 2, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_1_C2_offsets[64] = {
- /* used from to_ISO_8859_1_C2 */
- /* used from to_ISO_8859_1_C3 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-};
-static const struct byte_lookup* const
-to_ISO_8859_1_C2_infos[64] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA1), o1(0xA2), o1(0xA3),
- o1(0xA4), o1(0xA5), o1(0xA6), o1(0xA7),
- o1(0xA8), o1(0xA9), o1(0xAA), o1(0xAB),
- o1(0xAC), o1(0xAD), o1(0xAE), o1(0xAF),
- o1(0xB0), o1(0xB1), o1(0xB2), o1(0xB3),
- o1(0xB4), o1(0xB5), o1(0xB6), o1(0xB7),
- o1(0xB8), o1(0xB9), o1(0xBA), o1(0xBB),
- o1(0xBC), o1(0xBD), o1(0xBE), o1(0xBF),
-};
-static const BYTE_LOOKUP
-to_ISO_8859_1_C2 = {
- /* used from to_ISO_8859_1 */
- /* used from to_ISO_8859_9 */
- to_ISO_8859_1_C2_offsets,
- to_ISO_8859_1_C2_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_1_C3_infos[64] = {
- o1(0xC0), o1(0xC1), o1(0xC2), o1(0xC3),
- o1(0xC4), o1(0xC5), o1(0xC6), o1(0xC7),
- o1(0xC8), o1(0xC9), o1(0xCA), o1(0xCB),
- o1(0xCC), o1(0xCD), o1(0xCE), o1(0xCF),
- o1(0xD0), o1(0xD1), o1(0xD2), o1(0xD3),
- o1(0xD4), o1(0xD5), o1(0xD6), o1(0xD7),
- o1(0xD8), o1(0xD9), o1(0xDA), o1(0xDB),
- o1(0xDC), o1(0xDD), o1(0xDE), o1(0xDF),
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE3),
- o1(0xE4), o1(0xE5), o1(0xE6), o1(0xE7),
- o1(0xE8), o1(0xE9), o1(0xEA), o1(0xEB),
- o1(0xEC), o1(0xED), o1(0xEE), o1(0xEF),
- o1(0xF0), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF7),
- o1(0xF8), o1(0xF9), o1(0xFA), o1(0xFB),
- o1(0xFC), o1(0xFD), o1(0xFE), o1(0xFF),
-};
-static const BYTE_LOOKUP
-to_ISO_8859_1_C3 = {
- /* used from to_ISO_8859_1 */
- /* used from to_ISO_8859_15 */
- to_ISO_8859_1_C2_offsets,
- to_ISO_8859_1_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_1_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_ISO_8859_1_infos[4] = {
- NOMAP, &to_ISO_8859_1_C2,
- &to_ISO_8859_1_C3, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_1 = {
- to_ISO_8859_1_offsets,
- to_ISO_8859_1_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_1 = {
- "UTF-8", "ISO-8859-1", &to_ISO_8859_1, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_2_infos[129] = {
- NOMAP, o2(0xC2,0x80), o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84), o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88), o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C), o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90), o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94), o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98), o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C), o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0), o2(0xC4,0x84), o2(0xCB,0x98),
- o2(0xC5,0x81), o2(0xC2,0xA4), o2(0xC4,0xBD), o2(0xC5,0x9A),
- o2(0xC2,0xA7), o2(0xC2,0xA8), o2(0xC5,0xA0), o2(0xC5,0x9E),
- o2(0xC5,0xA4), o2(0xC5,0xB9), o2(0xC2,0xAD), o2(0xC5,0xBD),
- o2(0xC5,0xBB), o2(0xC2,0xB0), o2(0xC4,0x85), o2(0xCB,0x9B),
- o2(0xC5,0x82), o2(0xC2,0xB4), o2(0xC4,0xBE), o2(0xC5,0x9B),
- o2(0xCB,0x87), o2(0xC2,0xB8), o2(0xC5,0xA1), o2(0xC5,0x9F),
- o2(0xC5,0xA5), o2(0xC5,0xBA), o2(0xCB,0x9D), o2(0xC5,0xBE),
- o2(0xC5,0xBC), o2(0xC5,0x94), o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC4,0x82), o2(0xC3,0x84), o2(0xC4,0xB9), o2(0xC4,0x86),
- o2(0xC3,0x87), o2(0xC4,0x8C), o2(0xC3,0x89), o2(0xC4,0x98),
- o2(0xC3,0x8B), o2(0xC4,0x9A), o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC4,0x8E), o2(0xC4,0x90), o2(0xC5,0x83), o2(0xC5,0x87),
- o2(0xC3,0x93), o2(0xC3,0x94), o2(0xC5,0x90), o2(0xC3,0x96),
- o2(0xC3,0x97), o2(0xC5,0x98), o2(0xC5,0xAE), o2(0xC3,0x9A),
- o2(0xC5,0xB0), o2(0xC3,0x9C), o2(0xC3,0x9D), o2(0xC5,0xA2),
- o2(0xC3,0x9F), o2(0xC5,0x95), o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC4,0x83), o2(0xC3,0xA4), o2(0xC4,0xBA), o2(0xC4,0x87),
- o2(0xC3,0xA7), o2(0xC4,0x8D), o2(0xC3,0xA9), o2(0xC4,0x99),
- o2(0xC3,0xAB), o2(0xC4,0x9B), o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC4,0x8F), o2(0xC4,0x91), o2(0xC5,0x84), o2(0xC5,0x88),
- o2(0xC3,0xB3), o2(0xC3,0xB4), o2(0xC5,0x91), o2(0xC3,0xB6),
- o2(0xC3,0xB7), o2(0xC5,0x99), o2(0xC5,0xAF), o2(0xC3,0xBA),
- o2(0xC5,0xB1), o2(0xC3,0xBC), o2(0xC3,0xBD), o2(0xC5,0xA3),
- o2(0xCB,0x99),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_2 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_2_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_2 = {
- "ISO-8859-2", "UTF-8", &from_ISO_8859_2, 2, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_2_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 40, 40, 40, 33, 40, 40, 34, 35, 40, 40, 40, 40, 36, 40, 40,
- 37, 40, 40, 40, 38, 40, 40, 40, 39, 40, 40, 40, 40, 40, 40, 40,
-};
-static const struct byte_lookup* const
-to_ISO_8859_2_C2_infos[41] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA4), o1(0xA7), o1(0xA8),
- o1(0xAD), o1(0xB0), o1(0xB4), o1(0xB8),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_2_C2 = {
- to_ISO_8859_2_C2_offsets,
- to_ISO_8859_2_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_2_C3_offsets[64] = {
- 31, 0, 1, 31, 2, 31, 31, 3, 31, 4, 31, 5, 31, 6, 7, 31,
- 31, 31, 31, 8, 9, 31, 10, 11, 31, 31, 12, 31, 13, 14, 31, 15,
- 31, 16, 17, 31, 18, 31, 31, 19, 31, 20, 31, 21, 31, 22, 23, 31,
- 31, 31, 31, 24, 25, 31, 26, 27, 31, 31, 28, 31, 29, 30, 31, 31,
-};
-static const struct byte_lookup* const
-to_ISO_8859_2_C3_infos[32] = {
- o1(0xC1), o1(0xC2), o1(0xC4), o1(0xC7),
- o1(0xC9), o1(0xCB), o1(0xCD), o1(0xCE),
- o1(0xD3), o1(0xD4), o1(0xD6), o1(0xD7),
- o1(0xDA), o1(0xDC), o1(0xDD), o1(0xDF),
- o1(0xE1), o1(0xE2), o1(0xE4), o1(0xE7),
- o1(0xE9), o1(0xEB), o1(0xED), o1(0xEE),
- o1(0xF3), o1(0xF4), o1(0xF6), o1(0xF7),
- o1(0xFA), o1(0xFC), o1(0xFD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_2_C3 = {
- to_ISO_8859_2_C3_offsets,
- to_ISO_8859_2_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_2_C4_offsets[64] = {
- 20, 20, 0, 1, 2, 3, 4, 5, 20, 20, 20, 20, 6, 7, 8, 9,
- 10, 11, 20, 20, 20, 20, 20, 20, 12, 13, 14, 15, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 17, 20, 20, 18, 19, 20,
-};
-static const struct byte_lookup* const
-to_ISO_8859_2_C4_infos[21] = {
- o1(0xC3), o1(0xE3), o1(0xA1), o1(0xB1),
- o1(0xC6), o1(0xE6), o1(0xC8), o1(0xE8),
- o1(0xCF), o1(0xEF), o1(0xD0), o1(0xF0),
- o1(0xCA), o1(0xEA), o1(0xCC), o1(0xEC),
- o1(0xC5), o1(0xE5), o1(0xA5), o1(0xB5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_2_C4 = {
- to_ISO_8859_2_C4_offsets,
- to_ISO_8859_2_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_2_C5_offsets[64] = {
- 32, 0, 1, 2, 3, 32, 32, 4, 5, 32, 32, 32, 32, 32, 32, 32,
- 6, 7, 32, 32, 8, 9, 32, 32, 10, 11, 12, 13, 32, 32, 14, 15,
- 16, 17, 18, 19, 20, 21, 32, 32, 32, 32, 32, 32, 32, 32, 22, 23,
- 24, 25, 32, 32, 32, 32, 32, 32, 32, 26, 27, 28, 29, 30, 31, 32,
-};
-static const struct byte_lookup* const
-to_ISO_8859_2_C5_infos[33] = {
- o1(0xA3), o1(0xB3), o1(0xD1), o1(0xF1),
- o1(0xD2), o1(0xF2), o1(0xD5), o1(0xF5),
- o1(0xC0), o1(0xE0), o1(0xD8), o1(0xF8),
- o1(0xA6), o1(0xB6), o1(0xAA), o1(0xBA),
- o1(0xA9), o1(0xB9), o1(0xDE), o1(0xFE),
- o1(0xAB), o1(0xBB), o1(0xD9), o1(0xF9),
- o1(0xDB), o1(0xFB), o1(0xAC), o1(0xBC),
- o1(0xAF), o1(0xBF), o1(0xAE), o1(0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_2_C5 = {
- to_ISO_8859_2_C5_offsets,
- to_ISO_8859_2_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_2_CB_offsets[64] = {
- 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 5, 3, 5, 4, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_ISO_8859_2_CB_infos[6] = {
- o1(0xB7), o1(0xA2), o1(0xFF), o1(0xB2),
- o1(0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_2_CB = {
- to_ISO_8859_2_CB_offsets,
- to_ISO_8859_2_CB_infos
-};
-
-static const unsigned char
-to_ISO_8859_2_offsets[256] = {
- /* used from to_ISO_8859_2 */
- /* used from to_ISO_8859_3 */
- /* used from to_ISO_8859_4 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 1, 2, 3, 4, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_ISO_8859_2_infos[7] = {
- NOMAP, &to_ISO_8859_2_C2,
- &to_ISO_8859_2_C3, &to_ISO_8859_2_C4,
- &to_ISO_8859_2_C5, &to_ISO_8859_2_CB,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_2 = {
- to_ISO_8859_2_offsets,
- to_ISO_8859_2_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_2 = {
- "UTF-8", "ISO-8859-2", &to_ISO_8859_2, 1, 1,
- NULL, NULL,
-};
-
-static const unsigned char
-from_ISO_8859_3_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37,122, 38, 39, 40, 41, 42, 43, 44, 45,122, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,122, 61,
- 62, 63, 64,122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 122, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
- 92, 93, 94,122, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,
- 122,107,108,109,110,111,112,113, 114,115,116,117,118,119,120,121,
-};
-static const struct byte_lookup* const
-from_ISO_8859_3_infos[123] = {
- NOMAP, o2(0xC2,0x80), o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84), o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88), o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C), o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90), o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94), o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98), o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C), o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0), o2(0xC4,0xA6), o2(0xCB,0x98),
- o2(0xC2,0xA3), o2(0xC2,0xA4), o2(0xC4,0xA4), o2(0xC2,0xA7),
- o2(0xC2,0xA8), o2(0xC4,0xB0), o2(0xC5,0x9E), o2(0xC4,0x9E),
- o2(0xC4,0xB4), o2(0xC2,0xAD), o2(0xC5,0xBB), o2(0xC2,0xB0),
- o2(0xC4,0xA7), o2(0xC2,0xB2), o2(0xC2,0xB3), o2(0xC2,0xB4),
- o2(0xC2,0xB5), o2(0xC4,0xA5), o2(0xC2,0xB7), o2(0xC2,0xB8),
- o2(0xC4,0xB1), o2(0xC5,0x9F), o2(0xC4,0x9F), o2(0xC4,0xB5),
- o2(0xC2,0xBD), o2(0xC5,0xBC), o2(0xC3,0x80), o2(0xC3,0x81),
- o2(0xC3,0x82), o2(0xC3,0x84), o2(0xC4,0x8A), o2(0xC4,0x88),
- o2(0xC3,0x87), o2(0xC3,0x88), o2(0xC3,0x89), o2(0xC3,0x8A),
- o2(0xC3,0x8B), o2(0xC3,0x8C), o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC3,0x8F), o2(0xC3,0x91), o2(0xC3,0x92), o2(0xC3,0x93),
- o2(0xC3,0x94), o2(0xC4,0xA0), o2(0xC3,0x96), o2(0xC3,0x97),
- o2(0xC4,0x9C), o2(0xC3,0x99), o2(0xC3,0x9A), o2(0xC3,0x9B),
- o2(0xC3,0x9C), o2(0xC5,0xAC), o2(0xC5,0x9C), o2(0xC3,0x9F),
- o2(0xC3,0xA0), o2(0xC3,0xA1), o2(0xC3,0xA2), o2(0xC3,0xA4),
- o2(0xC4,0x8B), o2(0xC4,0x89), o2(0xC3,0xA7), o2(0xC3,0xA8),
- o2(0xC3,0xA9), o2(0xC3,0xAA), o2(0xC3,0xAB), o2(0xC3,0xAC),
- o2(0xC3,0xAD), o2(0xC3,0xAE), o2(0xC3,0xAF), o2(0xC3,0xB1),
- o2(0xC3,0xB2), o2(0xC3,0xB3), o2(0xC3,0xB4), o2(0xC4,0xA1),
- o2(0xC3,0xB6), o2(0xC3,0xB7), o2(0xC4,0x9D), o2(0xC3,0xB9),
- o2(0xC3,0xBA), o2(0xC3,0xBB), o2(0xC3,0xBC), o2(0xC5,0xAD),
- o2(0xC5,0x9D), o2(0xCB,0x99), UNDEF,
-};
-static const BYTE_LOOKUP
-from_ISO_8859_3 = {
- from_ISO_8859_3_offsets,
- from_ISO_8859_3_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_3 = {
- "ISO-8859-3", "UTF-8", &from_ISO_8859_3, 2, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_3_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 46, 46, 33, 34, 46, 46, 35, 36, 46, 46, 46, 46, 37, 46, 46,
- 38, 46, 39, 40, 41, 42, 46, 43, 44, 46, 46, 46, 46, 45, 46, 46,
-};
-static const struct byte_lookup* const
-to_ISO_8859_3_C2_infos[47] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA3), o1(0xA4), o1(0xA7),
- o1(0xA8), o1(0xAD), o1(0xB0), o1(0xB2),
- o1(0xB3), o1(0xB4), o1(0xB5), o1(0xB7),
- o1(0xB8), o1(0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_3_C2 = {
- to_ISO_8859_3_C2_offsets,
- to_ISO_8859_3_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_3_C3_offsets[64] = {
- 0, 1, 2, 47, 3, 47, 47, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 47, 13, 14, 15, 16, 47, 17, 18, 47, 19, 20, 21, 22, 47, 47, 23,
- 24, 25, 26, 47, 27, 47, 47, 28, 29, 30, 31, 32, 33, 34, 35, 36,
- 47, 37, 38, 39, 40, 47, 41, 42, 47, 43, 44, 45, 46, 47, 47, 47,
-};
-static const struct byte_lookup* const
-to_ISO_8859_3_C3_infos[48] = {
- o1(0xC0), o1(0xC1), o1(0xC2), o1(0xC4),
- o1(0xC7), o1(0xC8), o1(0xC9), o1(0xCA),
- o1(0xCB), o1(0xCC), o1(0xCD), o1(0xCE),
- o1(0xCF), o1(0xD1), o1(0xD2), o1(0xD3),
- o1(0xD4), o1(0xD6), o1(0xD7), o1(0xD9),
- o1(0xDA), o1(0xDB), o1(0xDC), o1(0xDF),
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE4),
- o1(0xE7), o1(0xE8), o1(0xE9), o1(0xEA),
- o1(0xEB), o1(0xEC), o1(0xED), o1(0xEE),
- o1(0xEF), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF6), o1(0xF7), o1(0xF9),
- o1(0xFA), o1(0xFB), o1(0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_3_C3 = {
- to_ISO_8859_3_C3_offsets,
- to_ISO_8859_3_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_3_C4_offsets[64] = {
- 18, 18, 18, 18, 18, 18, 18, 18, 0, 1, 2, 3, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 4, 5, 6, 7,
- 8, 9, 18, 18, 10, 11, 12, 13, 18, 18, 18, 18, 18, 18, 18, 18,
- 14, 15, 18, 18, 16, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-};
-static const struct byte_lookup* const
-to_ISO_8859_3_C4_infos[19] = {
- o1(0xC6), o1(0xE6), o1(0xC5), o1(0xE5),
- o1(0xD8), o1(0xF8), o1(0xAB), o1(0xBB),
- o1(0xD5), o1(0xF5), o1(0xA6), o1(0xB6),
- o1(0xA1), o1(0xB1), o1(0xA9), o1(0xB9),
- o1(0xAC), o1(0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_3_C4 = {
- to_ISO_8859_3_C4_offsets,
- to_ISO_8859_3_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_3_C5_offsets[64] = {
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 1, 2, 3,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 5, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 8, 8,
-};
-static const struct byte_lookup* const
-to_ISO_8859_3_C5_infos[9] = {
- o1(0xDE), o1(0xFE), o1(0xAA), o1(0xBA),
- o1(0xDD), o1(0xFD), o1(0xAF), o1(0xBF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_3_C5 = {
- to_ISO_8859_3_C5_offsets,
- to_ISO_8859_3_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_3_CB_offsets[64] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_3_CB_infos[3] = {
- o1(0xA2), o1(0xFF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_3_CB = {
- to_ISO_8859_3_CB_offsets,
- to_ISO_8859_3_CB_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_3_infos[7] = {
- NOMAP, &to_ISO_8859_3_C2,
- &to_ISO_8859_3_C3, &to_ISO_8859_3_C4,
- &to_ISO_8859_3_C5, &to_ISO_8859_3_CB,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_3 = {
- to_ISO_8859_2_offsets,
- to_ISO_8859_3_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_3 = {
- "UTF-8", "ISO-8859-3", &to_ISO_8859_3, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_4_infos[129] = {
- NOMAP, o2(0xC2,0x80), o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84), o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88), o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C), o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90), o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94), o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98), o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C), o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0), o2(0xC4,0x84), o2(0xC4,0xB8),
- o2(0xC5,0x96), o2(0xC2,0xA4), o2(0xC4,0xA8), o2(0xC4,0xBB),
- o2(0xC2,0xA7), o2(0xC2,0xA8), o2(0xC5,0xA0), o2(0xC4,0x92),
- o2(0xC4,0xA2), o2(0xC5,0xA6), o2(0xC2,0xAD), o2(0xC5,0xBD),
- o2(0xC2,0xAF), o2(0xC2,0xB0), o2(0xC4,0x85), o2(0xCB,0x9B),
- o2(0xC5,0x97), o2(0xC2,0xB4), o2(0xC4,0xA9), o2(0xC4,0xBC),
- o2(0xCB,0x87), o2(0xC2,0xB8), o2(0xC5,0xA1), o2(0xC4,0x93),
- o2(0xC4,0xA3), o2(0xC5,0xA7), o2(0xC5,0x8A), o2(0xC5,0xBE),
- o2(0xC5,0x8B), o2(0xC4,0x80), o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC3,0x83), o2(0xC3,0x84), o2(0xC3,0x85), o2(0xC3,0x86),
- o2(0xC4,0xAE), o2(0xC4,0x8C), o2(0xC3,0x89), o2(0xC4,0x98),
- o2(0xC3,0x8B), o2(0xC4,0x96), o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC4,0xAA), o2(0xC4,0x90), o2(0xC5,0x85), o2(0xC5,0x8C),
- o2(0xC4,0xB6), o2(0xC3,0x94), o2(0xC3,0x95), o2(0xC3,0x96),
- o2(0xC3,0x97), o2(0xC3,0x98), o2(0xC5,0xB2), o2(0xC3,0x9A),
- o2(0xC3,0x9B), o2(0xC3,0x9C), o2(0xC5,0xA8), o2(0xC5,0xAA),
- o2(0xC3,0x9F), o2(0xC4,0x81), o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC3,0xA3), o2(0xC3,0xA4), o2(0xC3,0xA5), o2(0xC3,0xA6),
- o2(0xC4,0xAF), o2(0xC4,0x8D), o2(0xC3,0xA9), o2(0xC4,0x99),
- o2(0xC3,0xAB), o2(0xC4,0x97), o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC4,0xAB), o2(0xC4,0x91), o2(0xC5,0x86), o2(0xC5,0x8D),
- o2(0xC4,0xB7), o2(0xC3,0xB4), o2(0xC3,0xB5), o2(0xC3,0xB6),
- o2(0xC3,0xB7), o2(0xC3,0xB8), o2(0xC5,0xB3), o2(0xC3,0xBA),
- o2(0xC3,0xBB), o2(0xC3,0xBC), o2(0xC5,0xA9), o2(0xC5,0xAB),
- o2(0xCB,0x99),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_4 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_4_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_4 = {
- "ISO-8859-4", "UTF-8", &from_ISO_8859_4, 2, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_4_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 41, 41, 41, 33, 41, 41, 34, 35, 41, 41, 41, 41, 36, 41, 37,
- 38, 41, 41, 41, 39, 41, 41, 41, 40, 41, 41, 41, 41, 41, 41, 41,
-};
-static const struct byte_lookup* const
-to_ISO_8859_4_C2_infos[42] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA4), o1(0xA7), o1(0xA8),
- o1(0xAD), o1(0xAF), o1(0xB0), o1(0xB4),
- o1(0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_4_C2 = {
- to_ISO_8859_4_C2_offsets,
- to_ISO_8859_4_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_4_C3_offsets[64] = {
- 37, 0, 1, 2, 3, 4, 5, 37, 37, 6, 37, 7, 37, 8, 9, 37,
- 37, 37, 37, 37, 10, 11, 12, 13, 14, 37, 15, 16, 17, 37, 37, 18,
- 37, 19, 20, 21, 22, 23, 24, 37, 37, 25, 37, 26, 37, 27, 28, 37,
- 37, 37, 37, 37, 29, 30, 31, 32, 33, 37, 34, 35, 36, 37, 37, 37,
-};
-static const struct byte_lookup* const
-to_ISO_8859_4_C3_infos[38] = {
- o1(0xC1), o1(0xC2), o1(0xC3), o1(0xC4),
- o1(0xC5), o1(0xC6), o1(0xC9), o1(0xCB),
- o1(0xCD), o1(0xCE), o1(0xD4), o1(0xD5),
- o1(0xD6), o1(0xD7), o1(0xD8), o1(0xDA),
- o1(0xDB), o1(0xDC), o1(0xDF), o1(0xE1),
- o1(0xE2), o1(0xE3), o1(0xE4), o1(0xE5),
- o1(0xE6), o1(0xE9), o1(0xEB), o1(0xED),
- o1(0xEE), o1(0xF4), o1(0xF5), o1(0xF6),
- o1(0xF7), o1(0xF8), o1(0xFA), o1(0xFB),
- o1(0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_4_C3 = {
- to_ISO_8859_4_C3_offsets,
- to_ISO_8859_4_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_4_C4_offsets[64] = {
- /* used from to_ISO_8859_4_C4 */
- /* used from to_ISO_8859_10_C4 */
- 0, 1, 27, 27, 2, 3, 27, 27, 27, 27, 27, 27, 4, 5, 27, 27,
- 6, 7, 8, 9, 27, 27, 10, 11, 12, 13, 27, 27, 27, 27, 27, 27,
- 27, 27, 14, 15, 27, 27, 27, 27, 16, 17, 18, 19, 27, 27, 20, 21,
- 27, 27, 27, 27, 27, 27, 22, 23, 24, 27, 27, 25, 26, 27, 27, 27,
-};
-static const struct byte_lookup* const
-to_ISO_8859_4_C4_infos[28] = {
- o1(0xC0), o1(0xE0), o1(0xA1), o1(0xB1),
- o1(0xC8), o1(0xE8), o1(0xD0), o1(0xF0),
- o1(0xAA), o1(0xBA), o1(0xCC), o1(0xEC),
- o1(0xCA), o1(0xEA), o1(0xAB), o1(0xBB),
- o1(0xA5), o1(0xB5), o1(0xCF), o1(0xEF),
- o1(0xC7), o1(0xE7), o1(0xD3), o1(0xF3),
- o1(0xA2), o1(0xA6), o1(0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_4_C4 = {
- to_ISO_8859_4_C4_offsets,
- to_ISO_8859_4_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_4_C5_offsets[64] = {
- 20, 20, 20, 20, 20, 0, 1, 20, 20, 20, 2, 3, 4, 5, 20, 20,
- 20, 20, 20, 20, 20, 20, 6, 7, 20, 20, 20, 20, 20, 20, 20, 20,
- 8, 9, 20, 20, 20, 20, 10, 11, 12, 13, 14, 15, 20, 20, 20, 20,
- 20, 20, 16, 17, 20, 20, 20, 20, 20, 20, 20, 20, 20, 18, 19, 20,
-};
-static const struct byte_lookup* const
-to_ISO_8859_4_C5_infos[21] = {
- o1(0xD1), o1(0xF1), o1(0xBD), o1(0xBF),
- o1(0xD2), o1(0xF2), o1(0xA3), o1(0xB3),
- o1(0xA9), o1(0xB9), o1(0xAC), o1(0xBC),
- o1(0xDD), o1(0xFD), o1(0xDE), o1(0xFE),
- o1(0xD9), o1(0xF9), o1(0xAE), o1(0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_4_C5 = {
- to_ISO_8859_4_C5_offsets,
- to_ISO_8859_4_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_4_CB_offsets[64] = {
- 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 2, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_ISO_8859_4_CB_infos[4] = {
- o1(0xB7), o1(0xFF), o1(0xB2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_4_CB = {
- to_ISO_8859_4_CB_offsets,
- to_ISO_8859_4_CB_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_4_infos[7] = {
- NOMAP, &to_ISO_8859_4_C2,
- &to_ISO_8859_4_C3, &to_ISO_8859_4_C4,
- &to_ISO_8859_4_C5, &to_ISO_8859_4_CB,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_4 = {
- to_ISO_8859_2_offsets,
- to_ISO_8859_4_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_4 = {
- "UTF-8", "ISO-8859-4", &to_ISO_8859_4, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_5_infos[129] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o2(0xD0,0x81), o2(0xD0,0x82),
- o2(0xD0,0x83), o2(0xD0,0x84),
- o2(0xD0,0x85), o2(0xD0,0x86),
- o2(0xD0,0x87), o2(0xD0,0x88),
- o2(0xD0,0x89), o2(0xD0,0x8A),
- o2(0xD0,0x8B), o2(0xD0,0x8C),
- o2(0xC2,0xAD), o2(0xD0,0x8E),
- o2(0xD0,0x8F), o2(0xD0,0x90),
- o2(0xD0,0x91), o2(0xD0,0x92),
- o2(0xD0,0x93), o2(0xD0,0x94),
- o2(0xD0,0x95), o2(0xD0,0x96),
- o2(0xD0,0x97), o2(0xD0,0x98),
- o2(0xD0,0x99), o2(0xD0,0x9A),
- o2(0xD0,0x9B), o2(0xD0,0x9C),
- o2(0xD0,0x9D), o2(0xD0,0x9E),
- o2(0xD0,0x9F), o2(0xD0,0xA0),
- o2(0xD0,0xA1), o2(0xD0,0xA2),
- o2(0xD0,0xA3), o2(0xD0,0xA4),
- o2(0xD0,0xA5), o2(0xD0,0xA6),
- o2(0xD0,0xA7), o2(0xD0,0xA8),
- o2(0xD0,0xA9), o2(0xD0,0xAA),
- o2(0xD0,0xAB), o2(0xD0,0xAC),
- o2(0xD0,0xAD), o2(0xD0,0xAE),
- o2(0xD0,0xAF), o2(0xD0,0xB0),
- o2(0xD0,0xB1), o2(0xD0,0xB2),
- o2(0xD0,0xB3), o2(0xD0,0xB4),
- o2(0xD0,0xB5), o2(0xD0,0xB6),
- o2(0xD0,0xB7), o2(0xD0,0xB8),
- o2(0xD0,0xB9), o2(0xD0,0xBA),
- o2(0xD0,0xBB), o2(0xD0,0xBC),
- o2(0xD0,0xBD), o2(0xD0,0xBE),
- o2(0xD0,0xBF), o2(0xD1,0x80),
- o2(0xD1,0x81), o2(0xD1,0x82),
- o2(0xD1,0x83), o2(0xD1,0x84),
- o2(0xD1,0x85), o2(0xD1,0x86),
- o2(0xD1,0x87), o2(0xD1,0x88),
- o2(0xD1,0x89), o2(0xD1,0x8A),
- o2(0xD1,0x8B), o2(0xD1,0x8C),
- o2(0xD1,0x8D), o2(0xD1,0x8E),
- o2(0xD1,0x8F), o3(0xE2,0x84,0x96),
- o2(0xD1,0x91), o2(0xD1,0x92),
- o2(0xD1,0x93), o2(0xD1,0x94),
- o2(0xD1,0x95), o2(0xD1,0x96),
- o2(0xD1,0x97), o2(0xD1,0x98),
- o2(0xD1,0x99), o2(0xD1,0x9A),
- o2(0xD1,0x9B), o2(0xD1,0x9C),
- o2(0xC2,0xA7), o2(0xD1,0x9E),
- o2(0xD1,0x9F),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_5 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_5_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_5 = {
- "ISO-8859-5", "UTF-8", &from_ISO_8859_5, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_5_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 35, 35, 35, 35, 35, 35, 33, 35, 35, 35, 35, 35, 34, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
-};
-static const struct byte_lookup* const
-to_ISO_8859_5_C2_infos[36] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xFD), o1(0xAD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_5_C2 = {
- to_ISO_8859_5_C2_offsets,
- to_ISO_8859_5_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_5_D0_offsets[64] = {
- 62, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 62, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
-};
-static const struct byte_lookup* const
-to_ISO_8859_5_D0_infos[63] = {
- o1(0xA1), o1(0xA2), o1(0xA3), o1(0xA4),
- o1(0xA5), o1(0xA6), o1(0xA7), o1(0xA8),
- o1(0xA9), o1(0xAA), o1(0xAB), o1(0xAC),
- o1(0xAE), o1(0xAF), o1(0xB0), o1(0xB1),
- o1(0xB2), o1(0xB3), o1(0xB4), o1(0xB5),
- o1(0xB6), o1(0xB7), o1(0xB8), o1(0xB9),
- o1(0xBA), o1(0xBB), o1(0xBC), o1(0xBD),
- o1(0xBE), o1(0xBF), o1(0xC0), o1(0xC1),
- o1(0xC2), o1(0xC3), o1(0xC4), o1(0xC5),
- o1(0xC6), o1(0xC7), o1(0xC8), o1(0xC9),
- o1(0xCA), o1(0xCB), o1(0xCC), o1(0xCD),
- o1(0xCE), o1(0xCF), o1(0xD0), o1(0xD1),
- o1(0xD2), o1(0xD3), o1(0xD4), o1(0xD5),
- o1(0xD6), o1(0xD7), o1(0xD8), o1(0xD9),
- o1(0xDA), o1(0xDB), o1(0xDC), o1(0xDD),
- o1(0xDE), o1(0xDF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_5_D0 = {
- to_ISO_8859_5_D0_offsets,
- to_ISO_8859_5_D0_infos
-};
-
-static const unsigned char
-to_ISO_8859_5_D1_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 30, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 28, 29,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
-};
-static const struct byte_lookup* const
-to_ISO_8859_5_D1_infos[31] = {
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE3),
- o1(0xE4), o1(0xE5), o1(0xE6), o1(0xE7),
- o1(0xE8), o1(0xE9), o1(0xEA), o1(0xEB),
- o1(0xEC), o1(0xED), o1(0xEE), o1(0xEF),
- o1(0xF1), o1(0xF2), o1(0xF3), o1(0xF4),
- o1(0xF5), o1(0xF6), o1(0xF7), o1(0xF8),
- o1(0xF9), o1(0xFA), o1(0xFB), o1(0xFC),
- o1(0xFE), o1(0xFF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_5_D1 = {
- to_ISO_8859_5_D1_offsets,
- to_ISO_8859_5_D1_infos
-};
-
-static const unsigned char
-to_ISO_8859_5_E2_84_offsets[64] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_5_E2_84_infos[2] = {
- o1(0xF0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_5_E2_84 = {
- to_ISO_8859_5_E2_84_offsets,
- to_ISO_8859_5_E2_84_infos
-};
-
-static const unsigned char
-to_ISO_8859_5_E2_offsets[64] = {
- 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_5_E2_infos[2] = {
- &to_ISO_8859_5_E2_84, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_5_E2 = {
- to_ISO_8859_5_E2_offsets,
- to_ISO_8859_5_E2_infos
-};
-
-static const unsigned char
-to_ISO_8859_5_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 2, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_ISO_8859_5_infos[6] = {
- NOMAP, &to_ISO_8859_5_C2,
- &to_ISO_8859_5_D0, &to_ISO_8859_5_D1,
- &to_ISO_8859_5_E2, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_5 = {
- to_ISO_8859_5_offsets,
- to_ISO_8859_5_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_5 = {
- "UTF-8", "ISO-8859-5", &to_ISO_8859_5, 1, 1,
- NULL, NULL,
-};
-
-static const unsigned char
-from_ISO_8859_6_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 84, 84, 84, 34, 84, 84, 84, 84, 84, 84, 84, 35, 36, 84, 84,
- 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 37, 84, 84, 84, 38,
- 84, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 84, 84, 84, 84, 84,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
-};
-static const struct byte_lookup* const
-from_ISO_8859_6_infos[85] = {
- NOMAP, o2(0xC2,0x80), o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84), o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88), o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C), o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90), o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94), o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98), o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C), o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0), o2(0xC2,0xA4), o2(0xD8,0x8C),
- o2(0xC2,0xAD), o2(0xD8,0x9B), o2(0xD8,0x9F), o2(0xD8,0xA1),
- o2(0xD8,0xA2), o2(0xD8,0xA3), o2(0xD8,0xA4), o2(0xD8,0xA5),
- o2(0xD8,0xA6), o2(0xD8,0xA7), o2(0xD8,0xA8), o2(0xD8,0xA9),
- o2(0xD8,0xAA), o2(0xD8,0xAB), o2(0xD8,0xAC), o2(0xD8,0xAD),
- o2(0xD8,0xAE), o2(0xD8,0xAF), o2(0xD8,0xB0), o2(0xD8,0xB1),
- o2(0xD8,0xB2), o2(0xD8,0xB3), o2(0xD8,0xB4), o2(0xD8,0xB5),
- o2(0xD8,0xB6), o2(0xD8,0xB7), o2(0xD8,0xB8), o2(0xD8,0xB9),
- o2(0xD8,0xBA), o2(0xD9,0x80), o2(0xD9,0x81), o2(0xD9,0x82),
- o2(0xD9,0x83), o2(0xD9,0x84), o2(0xD9,0x85), o2(0xD9,0x86),
- o2(0xD9,0x87), o2(0xD9,0x88), o2(0xD9,0x89), o2(0xD9,0x8A),
- o2(0xD9,0x8B), o2(0xD9,0x8C), o2(0xD9,0x8D), o2(0xD9,0x8E),
- o2(0xD9,0x8F), o2(0xD9,0x90), o2(0xD9,0x91), o2(0xD9,0x92),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_ISO_8859_6 = {
- from_ISO_8859_6_offsets,
- from_ISO_8859_6_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_6 = {
- "ISO-8859-6", "UTF-8", &from_ISO_8859_6, 2, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_6_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 35, 35, 35, 33, 35, 35, 35, 35, 35, 35, 35, 35, 34, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
-};
-static const struct byte_lookup* const
-to_ISO_8859_6_C2_infos[36] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA4), o1(0xAD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_6_C2 = {
- to_ISO_8859_6_C2_offsets,
- to_ISO_8859_6_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_6_D8_offsets[64] = {
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 0, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 1, 29, 29, 29, 2,
- 29, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 29, 29, 29,
-};
-static const struct byte_lookup* const
-to_ISO_8859_6_D8_infos[30] = {
- o1(0xAC), o1(0xBB), o1(0xBF), o1(0xC1),
- o1(0xC2), o1(0xC3), o1(0xC4), o1(0xC5),
- o1(0xC6), o1(0xC7), o1(0xC8), o1(0xC9),
- o1(0xCA), o1(0xCB), o1(0xCC), o1(0xCD),
- o1(0xCE), o1(0xCF), o1(0xD0), o1(0xD1),
- o1(0xD2), o1(0xD3), o1(0xD4), o1(0xD5),
- o1(0xD6), o1(0xD7), o1(0xD8), o1(0xD9),
- o1(0xDA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_6_D8 = {
- to_ISO_8859_6_D8_offsets,
- to_ISO_8859_6_D8_infos
-};
-
-static const unsigned char
-to_ISO_8859_6_D9_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
-};
-static const struct byte_lookup* const
-to_ISO_8859_6_D9_infos[20] = {
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE3),
- o1(0xE4), o1(0xE5), o1(0xE6), o1(0xE7),
- o1(0xE8), o1(0xE9), o1(0xEA), o1(0xEB),
- o1(0xEC), o1(0xED), o1(0xEE), o1(0xEF),
- o1(0xF0), o1(0xF1), o1(0xF2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_6_D9 = {
- to_ISO_8859_6_D9_offsets,
- to_ISO_8859_6_D9_infos
-};
-
-static const unsigned char
-to_ISO_8859_6_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 2, 3, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_ISO_8859_6_infos[5] = {
- NOMAP, &to_ISO_8859_6_C2,
- &to_ISO_8859_6_D8, &to_ISO_8859_6_D9,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_6 = {
- to_ISO_8859_6_offsets,
- to_ISO_8859_6_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_6 = {
- "UTF-8", "ISO-8859-6", &to_ISO_8859_6, 1, 1,
- NULL, NULL,
-};
-
-static const unsigned char
-from_ISO_8859_7_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,126, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81,126, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99,100,101,102, 103,104,105,106,107,108,109,110,
- 111,112,113,114,115,116,117,118, 119,120,121,122,123,124,125,126,
-};
-static const struct byte_lookup* const
-from_ISO_8859_7_infos[127] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o3(0xE2,0x80,0x98), o3(0xE2,0x80,0x99),
- o2(0xC2,0xA3), o3(0xE2,0x82,0xAC),
- o3(0xE2,0x82,0xAF), o2(0xC2,0xA6),
- o2(0xC2,0xA7), o2(0xC2,0xA8),
- o2(0xC2,0xA9), o2(0xCD,0xBA),
- o2(0xC2,0xAB), o2(0xC2,0xAC),
- o2(0xC2,0xAD), o3(0xE2,0x80,0x95),
- o2(0xC2,0xB0), o2(0xC2,0xB1),
- o2(0xC2,0xB2), o2(0xC2,0xB3),
- o2(0xCE,0x84), o2(0xCE,0x85),
- o2(0xCE,0x86), o2(0xC2,0xB7),
- o2(0xCE,0x88), o2(0xCE,0x89),
- o2(0xCE,0x8A), o2(0xC2,0xBB),
- o2(0xCE,0x8C), o2(0xC2,0xBD),
- o2(0xCE,0x8E), o2(0xCE,0x8F),
- o2(0xCE,0x90), o2(0xCE,0x91),
- o2(0xCE,0x92), o2(0xCE,0x93),
- o2(0xCE,0x94), o2(0xCE,0x95),
- o2(0xCE,0x96), o2(0xCE,0x97),
- o2(0xCE,0x98), o2(0xCE,0x99),
- o2(0xCE,0x9A), o2(0xCE,0x9B),
- o2(0xCE,0x9C), o2(0xCE,0x9D),
- o2(0xCE,0x9E), o2(0xCE,0x9F),
- o2(0xCE,0xA0), o2(0xCE,0xA1),
- o2(0xCE,0xA3), o2(0xCE,0xA4),
- o2(0xCE,0xA5), o2(0xCE,0xA6),
- o2(0xCE,0xA7), o2(0xCE,0xA8),
- o2(0xCE,0xA9), o2(0xCE,0xAA),
- o2(0xCE,0xAB), o2(0xCE,0xAC),
- o2(0xCE,0xAD), o2(0xCE,0xAE),
- o2(0xCE,0xAF), o2(0xCE,0xB0),
- o2(0xCE,0xB1), o2(0xCE,0xB2),
- o2(0xCE,0xB3), o2(0xCE,0xB4),
- o2(0xCE,0xB5), o2(0xCE,0xB6),
- o2(0xCE,0xB7), o2(0xCE,0xB8),
- o2(0xCE,0xB9), o2(0xCE,0xBA),
- o2(0xCE,0xBB), o2(0xCE,0xBC),
- o2(0xCE,0xBD), o2(0xCE,0xBE),
- o2(0xCE,0xBF), o2(0xCF,0x80),
- o2(0xCF,0x81), o2(0xCF,0x82),
- o2(0xCF,0x83), o2(0xCF,0x84),
- o2(0xCF,0x85), o2(0xCF,0x86),
- o2(0xCF,0x87), o2(0xCF,0x88),
- o2(0xCF,0x89), o2(0xCF,0x8A),
- o2(0xCF,0x8B), o2(0xCF,0x8C),
- o2(0xCF,0x8D), o2(0xCF,0x8E),
- UNDEF,
-};
-static const BYTE_LOOKUP
-from_ISO_8859_7 = {
- from_ISO_8859_7_offsets,
- from_ISO_8859_7_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_7 = {
- "ISO-8859-7", "UTF-8", &from_ISO_8859_7, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_7_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 48, 48, 33, 48, 48, 34, 35, 36, 37, 48, 38, 39, 40, 48, 48,
- 41, 42, 43, 44, 48, 48, 48, 45, 48, 48, 48, 46, 48, 47, 48, 48,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_C2_infos[49] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA3), o1(0xA6), o1(0xA7),
- o1(0xA8), o1(0xA9), o1(0xAB), o1(0xAC),
- o1(0xAD), o1(0xB0), o1(0xB1), o1(0xB2),
- o1(0xB3), o1(0xB7), o1(0xBB), o1(0xBD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_C2 = {
- to_ISO_8859_7_C2_offsets,
- to_ISO_8859_7_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_CD_offsets[64] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_CD_infos[2] = {
- o1(0xAA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_CD = {
- to_ISO_8859_7_CD_offsets,
- to_ISO_8859_7_CD_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_CE_offsets[64] = {
- 56, 56, 56, 56, 0, 1, 2, 56, 3, 4, 5, 56, 6, 56, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 56, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_CE_infos[57] = {
- o1(0xB4), o1(0xB5), o1(0xB6), o1(0xB8),
- o1(0xB9), o1(0xBA), o1(0xBC), o1(0xBE),
- o1(0xBF), o1(0xC0), o1(0xC1), o1(0xC2),
- o1(0xC3), o1(0xC4), o1(0xC5), o1(0xC6),
- o1(0xC7), o1(0xC8), o1(0xC9), o1(0xCA),
- o1(0xCB), o1(0xCC), o1(0xCD), o1(0xCE),
- o1(0xCF), o1(0xD0), o1(0xD1), o1(0xD3),
- o1(0xD4), o1(0xD5), o1(0xD6), o1(0xD7),
- o1(0xD8), o1(0xD9), o1(0xDA), o1(0xDB),
- o1(0xDC), o1(0xDD), o1(0xDE), o1(0xDF),
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE3),
- o1(0xE4), o1(0xE5), o1(0xE6), o1(0xE7),
- o1(0xE8), o1(0xE9), o1(0xEA), o1(0xEB),
- o1(0xEC), o1(0xED), o1(0xEE), o1(0xEF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_CE = {
- to_ISO_8859_7_CE_offsets,
- to_ISO_8859_7_CE_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_CF_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_CF_infos[16] = {
- o1(0xF0), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF7),
- o1(0xF8), o1(0xF9), o1(0xFA), o1(0xFB),
- o1(0xFC), o1(0xFD), o1(0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_CF = {
- to_ISO_8859_7_CF_offsets,
- to_ISO_8859_7_CF_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_E2_80_offsets[64] = {
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 0, 3, 3, 1, 2, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_E2_80_infos[4] = {
- o1(0xAF), o1(0xA1), o1(0xA2), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_E2_80 = {
- to_ISO_8859_7_E2_80_offsets,
- to_ISO_8859_7_E2_80_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_E2_82_offsets[64] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_E2_82_infos[3] = {
- o1(0xA4), o1(0xA5), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_E2_82 = {
- to_ISO_8859_7_E2_82_offsets,
- to_ISO_8859_7_E2_82_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_E2_offsets[64] = {
- 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_E2_infos[3] = {
- &to_ISO_8859_7_E2_80, &to_ISO_8859_7_E2_82,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7_E2 = {
- to_ISO_8859_7_E2_offsets,
- to_ISO_8859_7_E2_infos
-};
-
-static const unsigned char
-to_ISO_8859_7_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 4,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_ISO_8859_7_infos[7] = {
- NOMAP, &to_ISO_8859_7_C2,
- &to_ISO_8859_7_CD, &to_ISO_8859_7_CE,
- &to_ISO_8859_7_CF, &to_ISO_8859_7_E2,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_7 = {
- to_ISO_8859_7_offsets,
- to_ISO_8859_7_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_7 = {
- "UTF-8", "ISO-8859-7", &to_ISO_8859_7, 1, 1,
- NULL, NULL,
-};
-
-static const unsigned char
-from_ISO_8859_8_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 93, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 93,
- 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93,
- 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 93, 93, 91, 92, 93,
-};
-static const struct byte_lookup* const
-from_ISO_8859_8_infos[94] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o2(0xC2,0xA2), o2(0xC2,0xA3),
- o2(0xC2,0xA4), o2(0xC2,0xA5),
- o2(0xC2,0xA6), o2(0xC2,0xA7),
- o2(0xC2,0xA8), o2(0xC2,0xA9),
- o2(0xC3,0x97), o2(0xC2,0xAB),
- o2(0xC2,0xAC), o2(0xC2,0xAD),
- o2(0xC2,0xAE), o2(0xC2,0xAF),
- o2(0xC2,0xB0), o2(0xC2,0xB1),
- o2(0xC2,0xB2), o2(0xC2,0xB3),
- o2(0xC2,0xB4), o2(0xC2,0xB5),
- o2(0xC2,0xB6), o2(0xC2,0xB7),
- o2(0xC2,0xB8), o2(0xC2,0xB9),
- o2(0xC3,0xB7), o2(0xC2,0xBB),
- o2(0xC2,0xBC), o2(0xC2,0xBD),
- o2(0xC2,0xBE), o3(0xE2,0x80,0x97),
- o2(0xD7,0x90), o2(0xD7,0x91),
- o2(0xD7,0x92), o2(0xD7,0x93),
- o2(0xD7,0x94), o2(0xD7,0x95),
- o2(0xD7,0x96), o2(0xD7,0x97),
- o2(0xD7,0x98), o2(0xD7,0x99),
- o2(0xD7,0x9A), o2(0xD7,0x9B),
- o2(0xD7,0x9C), o2(0xD7,0x9D),
- o2(0xD7,0x9E), o2(0xD7,0x9F),
- o2(0xD7,0xA0), o2(0xD7,0xA1),
- o2(0xD7,0xA2), o2(0xD7,0xA3),
- o2(0xD7,0xA4), o2(0xD7,0xA5),
- o2(0xD7,0xA6), o2(0xD7,0xA7),
- o2(0xD7,0xA8), o2(0xD7,0xA9),
- o2(0xD7,0xAA), o3(0xE2,0x80,0x8E),
- o3(0xE2,0x80,0x8F), UNDEF,
-};
-static const BYTE_LOOKUP
-from_ISO_8859_8 = {
- from_ISO_8859_8_offsets,
- from_ISO_8859_8_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_8 = {
- "ISO-8859-8", "UTF-8", &from_ISO_8859_8, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_8_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 60, 33, 34, 35, 36, 37, 38, 39, 40, 60, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 60, 56, 57, 58, 59, 60,
-};
-static const struct byte_lookup* const
-to_ISO_8859_8_C2_infos[61] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA2), o1(0xA3), o1(0xA4),
- o1(0xA5), o1(0xA6), o1(0xA7), o1(0xA8),
- o1(0xA9), o1(0xAB), o1(0xAC), o1(0xAD),
- o1(0xAE), o1(0xAF), o1(0xB0), o1(0xB1),
- o1(0xB2), o1(0xB3), o1(0xB4), o1(0xB5),
- o1(0xB6), o1(0xB7), o1(0xB8), o1(0xB9),
- o1(0xBB), o1(0xBC), o1(0xBD), o1(0xBE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_8_C2 = {
- to_ISO_8859_8_C2_offsets,
- to_ISO_8859_8_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_8_C3_offsets[64] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_8_C3_infos[3] = {
- o1(0xAA), o1(0xBA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_8_C3 = {
- to_ISO_8859_8_C3_offsets,
- to_ISO_8859_8_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_8_D7_offsets[64] = {
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-};
-static const struct byte_lookup* const
-to_ISO_8859_8_D7_infos[28] = {
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE3),
- o1(0xE4), o1(0xE5), o1(0xE6), o1(0xE7),
- o1(0xE8), o1(0xE9), o1(0xEA), o1(0xEB),
- o1(0xEC), o1(0xED), o1(0xEE), o1(0xEF),
- o1(0xF0), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF7),
- o1(0xF8), o1(0xF9), o1(0xFA), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_8_D7 = {
- to_ISO_8859_8_D7_offsets,
- to_ISO_8859_8_D7_infos
-};
-
-static const unsigned char
-to_ISO_8859_8_E2_80_offsets[64] = {
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 1,
- 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_ISO_8859_8_E2_80_infos[4] = {
- o1(0xFD), o1(0xFE), o1(0xDF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_8_E2_80 = {
- to_ISO_8859_8_E2_80_offsets,
- to_ISO_8859_8_E2_80_infos
-};
-
-static const unsigned char
-to_ISO_8859_8_E2_offsets[64] = {
- /* used from to_ISO_8859_8_E2 */
- /* used from to_ISO_8859_10_E2 */
- /* used from to_ISO_8859_13_E2 */
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_8_E2_infos[2] = {
- &to_ISO_8859_8_E2_80, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_8_E2 = {
- to_ISO_8859_8_E2_offsets,
- to_ISO_8859_8_E2_infos
-};
-
-static const unsigned char
-to_ISO_8859_8_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 1, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_ISO_8859_8_infos[6] = {
- NOMAP, &to_ISO_8859_8_C2,
- &to_ISO_8859_8_C3, &to_ISO_8859_8_D7,
- &to_ISO_8859_8_E2, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_8 = {
- to_ISO_8859_8_offsets,
- to_ISO_8859_8_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_8 = {
- "UTF-8", "ISO-8859-8", &to_ISO_8859_8, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_9_infos[129] = {
- NOMAP, o2(0xC2,0x80), o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84), o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88), o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C), o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90), o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94), o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98), o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C), o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0), o2(0xC2,0xA1), o2(0xC2,0xA2),
- o2(0xC2,0xA3), o2(0xC2,0xA4), o2(0xC2,0xA5), o2(0xC2,0xA6),
- o2(0xC2,0xA7), o2(0xC2,0xA8), o2(0xC2,0xA9), o2(0xC2,0xAA),
- o2(0xC2,0xAB), o2(0xC2,0xAC), o2(0xC2,0xAD), o2(0xC2,0xAE),
- o2(0xC2,0xAF), o2(0xC2,0xB0), o2(0xC2,0xB1), o2(0xC2,0xB2),
- o2(0xC2,0xB3), o2(0xC2,0xB4), o2(0xC2,0xB5), o2(0xC2,0xB6),
- o2(0xC2,0xB7), o2(0xC2,0xB8), o2(0xC2,0xB9), o2(0xC2,0xBA),
- o2(0xC2,0xBB), o2(0xC2,0xBC), o2(0xC2,0xBD), o2(0xC2,0xBE),
- o2(0xC2,0xBF), o2(0xC3,0x80), o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC3,0x83), o2(0xC3,0x84), o2(0xC3,0x85), o2(0xC3,0x86),
- o2(0xC3,0x87), o2(0xC3,0x88), o2(0xC3,0x89), o2(0xC3,0x8A),
- o2(0xC3,0x8B), o2(0xC3,0x8C), o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC3,0x8F), o2(0xC4,0x9E), o2(0xC3,0x91), o2(0xC3,0x92),
- o2(0xC3,0x93), o2(0xC3,0x94), o2(0xC3,0x95), o2(0xC3,0x96),
- o2(0xC3,0x97), o2(0xC3,0x98), o2(0xC3,0x99), o2(0xC3,0x9A),
- o2(0xC3,0x9B), o2(0xC3,0x9C), o2(0xC4,0xB0), o2(0xC5,0x9E),
- o2(0xC3,0x9F), o2(0xC3,0xA0), o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC3,0xA3), o2(0xC3,0xA4), o2(0xC3,0xA5), o2(0xC3,0xA6),
- o2(0xC3,0xA7), o2(0xC3,0xA8), o2(0xC3,0xA9), o2(0xC3,0xAA),
- o2(0xC3,0xAB), o2(0xC3,0xAC), o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC3,0xAF), o2(0xC4,0x9F), o2(0xC3,0xB1), o2(0xC3,0xB2),
- o2(0xC3,0xB3), o2(0xC3,0xB4), o2(0xC3,0xB5), o2(0xC3,0xB6),
- o2(0xC3,0xB7), o2(0xC3,0xB8), o2(0xC3,0xB9), o2(0xC3,0xBA),
- o2(0xC3,0xBB), o2(0xC3,0xBC), o2(0xC4,0xB1), o2(0xC5,0x9F),
- o2(0xC3,0xBF),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_9 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_9_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_9 = {
- "ISO-8859-9", "UTF-8", &from_ISO_8859_9, 2, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_9_C3_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 58, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 58, 58, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 58, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 58, 58, 57,
-};
-static const struct byte_lookup* const
-to_ISO_8859_9_C3_infos[59] = {
- o1(0xC0), o1(0xC1), o1(0xC2), o1(0xC3),
- o1(0xC4), o1(0xC5), o1(0xC6), o1(0xC7),
- o1(0xC8), o1(0xC9), o1(0xCA), o1(0xCB),
- o1(0xCC), o1(0xCD), o1(0xCE), o1(0xCF),
- o1(0xD1), o1(0xD2), o1(0xD3), o1(0xD4),
- o1(0xD5), o1(0xD6), o1(0xD7), o1(0xD8),
- o1(0xD9), o1(0xDA), o1(0xDB), o1(0xDC),
- o1(0xDF), o1(0xE0), o1(0xE1), o1(0xE2),
- o1(0xE3), o1(0xE4), o1(0xE5), o1(0xE6),
- o1(0xE7), o1(0xE8), o1(0xE9), o1(0xEA),
- o1(0xEB), o1(0xEC), o1(0xED), o1(0xEE),
- o1(0xEF), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF7),
- o1(0xF8), o1(0xF9), o1(0xFA), o1(0xFB),
- o1(0xFC), o1(0xFF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_9_C3 = {
- to_ISO_8859_9_C3_offsets,
- to_ISO_8859_9_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_9_C4_offsets[64] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 1,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_ISO_8859_9_C4_infos[5] = {
- o1(0xD0), o1(0xF0), o1(0xDD), o1(0xFD),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_9_C4 = {
- to_ISO_8859_9_C4_offsets,
- to_ISO_8859_9_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_9_C5_offsets[64] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_9_C5_infos[3] = {
- o1(0xDE), o1(0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_9_C5 = {
- to_ISO_8859_9_C5_offsets,
- to_ISO_8859_9_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_9_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_ISO_8859_9_infos[6] = {
- NOMAP, &to_ISO_8859_1_C2,
- &to_ISO_8859_9_C3, &to_ISO_8859_9_C4,
- &to_ISO_8859_9_C5, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_9 = {
- to_ISO_8859_9_offsets,
- to_ISO_8859_9_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_9 = {
- "UTF-8", "ISO-8859-9", &to_ISO_8859_9, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_10_infos[129] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o2(0xC4,0x84), o2(0xC4,0x92),
- o2(0xC4,0xA2), o2(0xC4,0xAA),
- o2(0xC4,0xA8), o2(0xC4,0xB6),
- o2(0xC2,0xA7), o2(0xC4,0xBB),
- o2(0xC4,0x90), o2(0xC5,0xA0),
- o2(0xC5,0xA6), o2(0xC5,0xBD),
- o2(0xC2,0xAD), o2(0xC5,0xAA),
- o2(0xC5,0x8A), o2(0xC2,0xB0),
- o2(0xC4,0x85), o2(0xC4,0x93),
- o2(0xC4,0xA3), o2(0xC4,0xAB),
- o2(0xC4,0xA9), o2(0xC4,0xB7),
- o2(0xC2,0xB7), o2(0xC4,0xBC),
- o2(0xC4,0x91), o2(0xC5,0xA1),
- o2(0xC5,0xA7), o2(0xC5,0xBE),
- o3(0xE2,0x80,0x95), o2(0xC5,0xAB),
- o2(0xC5,0x8B), o2(0xC4,0x80),
- o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC3,0x83), o2(0xC3,0x84),
- o2(0xC3,0x85), o2(0xC3,0x86),
- o2(0xC4,0xAE), o2(0xC4,0x8C),
- o2(0xC3,0x89), o2(0xC4,0x98),
- o2(0xC3,0x8B), o2(0xC4,0x96),
- o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC3,0x8F), o2(0xC3,0x90),
- o2(0xC5,0x85), o2(0xC5,0x8C),
- o2(0xC3,0x93), o2(0xC3,0x94),
- o2(0xC3,0x95), o2(0xC3,0x96),
- o2(0xC5,0xA8), o2(0xC3,0x98),
- o2(0xC5,0xB2), o2(0xC3,0x9A),
- o2(0xC3,0x9B), o2(0xC3,0x9C),
- o2(0xC3,0x9D), o2(0xC3,0x9E),
- o2(0xC3,0x9F), o2(0xC4,0x81),
- o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC3,0xA3), o2(0xC3,0xA4),
- o2(0xC3,0xA5), o2(0xC3,0xA6),
- o2(0xC4,0xAF), o2(0xC4,0x8D),
- o2(0xC3,0xA9), o2(0xC4,0x99),
- o2(0xC3,0xAB), o2(0xC4,0x97),
- o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC3,0xAF), o2(0xC3,0xB0),
- o2(0xC5,0x86), o2(0xC5,0x8D),
- o2(0xC3,0xB3), o2(0xC3,0xB4),
- o2(0xC3,0xB5), o2(0xC3,0xB6),
- o2(0xC5,0xA9), o2(0xC3,0xB8),
- o2(0xC5,0xB3), o2(0xC3,0xBA),
- o2(0xC3,0xBB), o2(0xC3,0xBC),
- o2(0xC3,0xBD), o2(0xC3,0xBE),
- o2(0xC4,0xB8),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_10 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_10_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_10 = {
- "ISO-8859-10", "UTF-8", &from_ISO_8859_10, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_10_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 37, 37, 37, 37, 37, 37, 33, 37, 37, 37, 37, 37, 34, 37, 37,
- 35, 37, 37, 37, 37, 37, 37, 36, 37, 37, 37, 37, 37, 37, 37, 37,
-};
-static const struct byte_lookup* const
-to_ISO_8859_10_C2_infos[38] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA7), o1(0xAD), o1(0xB0),
- o1(0xB7), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10_C2 = {
- to_ISO_8859_10_C2_offsets,
- to_ISO_8859_10_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_10_C3_offsets[64] = {
- 45, 0, 1, 2, 3, 4, 5, 45, 45, 6, 45, 7, 45, 8, 9, 10,
- 11, 45, 45, 12, 13, 14, 15, 45, 16, 45, 17, 18, 19, 20, 21, 22,
- 45, 23, 24, 25, 26, 27, 28, 45, 45, 29, 45, 30, 45, 31, 32, 33,
- 34, 45, 45, 35, 36, 37, 38, 45, 39, 45, 40, 41, 42, 43, 44, 45,
-};
-static const struct byte_lookup* const
-to_ISO_8859_10_C3_infos[46] = {
- o1(0xC1), o1(0xC2), o1(0xC3), o1(0xC4),
- o1(0xC5), o1(0xC6), o1(0xC9), o1(0xCB),
- o1(0xCD), o1(0xCE), o1(0xCF), o1(0xD0),
- o1(0xD3), o1(0xD4), o1(0xD5), o1(0xD6),
- o1(0xD8), o1(0xDA), o1(0xDB), o1(0xDC),
- o1(0xDD), o1(0xDE), o1(0xDF), o1(0xE1),
- o1(0xE2), o1(0xE3), o1(0xE4), o1(0xE5),
- o1(0xE6), o1(0xE9), o1(0xEB), o1(0xED),
- o1(0xEE), o1(0xEF), o1(0xF0), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF8),
- o1(0xFA), o1(0xFB), o1(0xFC), o1(0xFD),
- o1(0xFE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10_C3 = {
- to_ISO_8859_10_C3_offsets,
- to_ISO_8859_10_C3_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_10_C4_infos[28] = {
- o1(0xC0), o1(0xE0), o1(0xA1), o1(0xB1),
- o1(0xC8), o1(0xE8), o1(0xA9), o1(0xB9),
- o1(0xA2), o1(0xB2), o1(0xCC), o1(0xEC),
- o1(0xCA), o1(0xEA), o1(0xA3), o1(0xB3),
- o1(0xA5), o1(0xB5), o1(0xA4), o1(0xB4),
- o1(0xC7), o1(0xE7), o1(0xA6), o1(0xB6),
- o1(0xFF), o1(0xA8), o1(0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10_C4 = {
- to_ISO_8859_4_C4_offsets,
- to_ISO_8859_10_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_10_C5_offsets[64] = {
- 18, 18, 18, 18, 18, 0, 1, 18, 18, 18, 2, 3, 4, 5, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 6, 7, 18, 18, 18, 18, 8, 9, 10, 11, 12, 13, 18, 18, 18, 18,
- 18, 18, 14, 15, 18, 18, 18, 18, 18, 18, 18, 18, 18, 16, 17, 18,
-};
-static const struct byte_lookup* const
-to_ISO_8859_10_C5_infos[19] = {
- o1(0xD1), o1(0xF1), o1(0xAF), o1(0xBF),
- o1(0xD2), o1(0xF2), o1(0xAA), o1(0xBA),
- o1(0xAB), o1(0xBB), o1(0xD7), o1(0xF7),
- o1(0xAE), o1(0xBE), o1(0xD9), o1(0xF9),
- o1(0xAC), o1(0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10_C5 = {
- to_ISO_8859_10_C5_offsets,
- to_ISO_8859_10_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_10_E2_80_offsets[64] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_10_E2_80_infos[2] = {
- o1(0xBD), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10_E2_80 = {
- to_ISO_8859_10_E2_80_offsets,
- to_ISO_8859_10_E2_80_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_10_E2_infos[2] = {
- &to_ISO_8859_10_E2_80, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10_E2 = {
- to_ISO_8859_8_E2_offsets,
- to_ISO_8859_10_E2_infos
-};
-
-static const unsigned char
-to_ISO_8859_10_offsets[256] = {
- /* used from to_ISO_8859_10 */
- /* used from to_ISO_8859_13 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 1, 2, 3, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_ISO_8859_10_infos[7] = {
- NOMAP, &to_ISO_8859_10_C2,
- &to_ISO_8859_10_C3, &to_ISO_8859_10_C4,
- &to_ISO_8859_10_C5, &to_ISO_8859_10_E2,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_10 = {
- to_ISO_8859_10_offsets,
- to_ISO_8859_10_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_10 = {
- "UTF-8", "ISO-8859-10", &to_ISO_8859_10, 1, 1,
- NULL, NULL,
-};
-
-static const unsigned char
-from_ISO_8859_11_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,121,121,121,121, 92,
- 93, 94, 95, 96, 97, 98, 99,100, 101,102,103,104,105,106,107,108,
- 109,110,111,112,113,114,115,116, 117,118,119,120,121,121,121,121,
-};
-static const struct byte_lookup* const
-from_ISO_8859_11_infos[122] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o3(0xE0,0xB8,0x81), o3(0xE0,0xB8,0x82),
- o3(0xE0,0xB8,0x83), o3(0xE0,0xB8,0x84),
- o3(0xE0,0xB8,0x85), o3(0xE0,0xB8,0x86),
- o3(0xE0,0xB8,0x87), o3(0xE0,0xB8,0x88),
- o3(0xE0,0xB8,0x89), o3(0xE0,0xB8,0x8A),
- o3(0xE0,0xB8,0x8B), o3(0xE0,0xB8,0x8C),
- o3(0xE0,0xB8,0x8D), o3(0xE0,0xB8,0x8E),
- o3(0xE0,0xB8,0x8F), o3(0xE0,0xB8,0x90),
- o3(0xE0,0xB8,0x91), o3(0xE0,0xB8,0x92),
- o3(0xE0,0xB8,0x93), o3(0xE0,0xB8,0x94),
- o3(0xE0,0xB8,0x95), o3(0xE0,0xB8,0x96),
- o3(0xE0,0xB8,0x97), o3(0xE0,0xB8,0x98),
- o3(0xE0,0xB8,0x99), o3(0xE0,0xB8,0x9A),
- o3(0xE0,0xB8,0x9B), o3(0xE0,0xB8,0x9C),
- o3(0xE0,0xB8,0x9D), o3(0xE0,0xB8,0x9E),
- o3(0xE0,0xB8,0x9F), o3(0xE0,0xB8,0xA0),
- o3(0xE0,0xB8,0xA1), o3(0xE0,0xB8,0xA2),
- o3(0xE0,0xB8,0xA3), o3(0xE0,0xB8,0xA4),
- o3(0xE0,0xB8,0xA5), o3(0xE0,0xB8,0xA6),
- o3(0xE0,0xB8,0xA7), o3(0xE0,0xB8,0xA8),
- o3(0xE0,0xB8,0xA9), o3(0xE0,0xB8,0xAA),
- o3(0xE0,0xB8,0xAB), o3(0xE0,0xB8,0xAC),
- o3(0xE0,0xB8,0xAD), o3(0xE0,0xB8,0xAE),
- o3(0xE0,0xB8,0xAF), o3(0xE0,0xB8,0xB0),
- o3(0xE0,0xB8,0xB1), o3(0xE0,0xB8,0xB2),
- o3(0xE0,0xB8,0xB3), o3(0xE0,0xB8,0xB4),
- o3(0xE0,0xB8,0xB5), o3(0xE0,0xB8,0xB6),
- o3(0xE0,0xB8,0xB7), o3(0xE0,0xB8,0xB8),
- o3(0xE0,0xB8,0xB9), o3(0xE0,0xB8,0xBA),
- o3(0xE0,0xB8,0xBF), o3(0xE0,0xB9,0x80),
- o3(0xE0,0xB9,0x81), o3(0xE0,0xB9,0x82),
- o3(0xE0,0xB9,0x83), o3(0xE0,0xB9,0x84),
- o3(0xE0,0xB9,0x85), o3(0xE0,0xB9,0x86),
- o3(0xE0,0xB9,0x87), o3(0xE0,0xB9,0x88),
- o3(0xE0,0xB9,0x89), o3(0xE0,0xB9,0x8A),
- o3(0xE0,0xB9,0x8B), o3(0xE0,0xB9,0x8C),
- o3(0xE0,0xB9,0x8D), o3(0xE0,0xB9,0x8E),
- o3(0xE0,0xB9,0x8F), o3(0xE0,0xB9,0x90),
- o3(0xE0,0xB9,0x91), o3(0xE0,0xB9,0x92),
- o3(0xE0,0xB9,0x93), o3(0xE0,0xB9,0x94),
- o3(0xE0,0xB9,0x95), o3(0xE0,0xB9,0x96),
- o3(0xE0,0xB9,0x97), o3(0xE0,0xB9,0x98),
- o3(0xE0,0xB9,0x99), o3(0xE0,0xB9,0x9A),
- o3(0xE0,0xB9,0x9B), UNDEF,
-};
-static const BYTE_LOOKUP
-from_ISO_8859_11 = {
- from_ISO_8859_11_offsets,
- from_ISO_8859_11_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_11 = {
- "ISO-8859-11", "UTF-8", &from_ISO_8859_11, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_11_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
- 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
-};
-static const struct byte_lookup* const
-to_ISO_8859_11_C2_infos[34] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_11_C2 = {
- to_ISO_8859_11_C2_offsets,
- to_ISO_8859_11_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_11_E0_B8_offsets[64] = {
- 59, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 59, 59, 59, 58,
-};
-static const struct byte_lookup* const
-to_ISO_8859_11_E0_B8_infos[60] = {
- o1(0xA1), o1(0xA2), o1(0xA3), o1(0xA4),
- o1(0xA5), o1(0xA6), o1(0xA7), o1(0xA8),
- o1(0xA9), o1(0xAA), o1(0xAB), o1(0xAC),
- o1(0xAD), o1(0xAE), o1(0xAF), o1(0xB0),
- o1(0xB1), o1(0xB2), o1(0xB3), o1(0xB4),
- o1(0xB5), o1(0xB6), o1(0xB7), o1(0xB8),
- o1(0xB9), o1(0xBA), o1(0xBB), o1(0xBC),
- o1(0xBD), o1(0xBE), o1(0xBF), o1(0xC0),
- o1(0xC1), o1(0xC2), o1(0xC3), o1(0xC4),
- o1(0xC5), o1(0xC6), o1(0xC7), o1(0xC8),
- o1(0xC9), o1(0xCA), o1(0xCB), o1(0xCC),
- o1(0xCD), o1(0xCE), o1(0xCF), o1(0xD0),
- o1(0xD1), o1(0xD2), o1(0xD3), o1(0xD4),
- o1(0xD5), o1(0xD6), o1(0xD7), o1(0xD8),
- o1(0xD9), o1(0xDA), o1(0xDF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_11_E0_B8 = {
- to_ISO_8859_11_E0_B8_offsets,
- to_ISO_8859_11_E0_B8_infos
-};
-
-static const unsigned char
-to_ISO_8859_11_E0_B9_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-};
-static const struct byte_lookup* const
-to_ISO_8859_11_E0_B9_infos[29] = {
- o1(0xE0), o1(0xE1), o1(0xE2), o1(0xE3),
- o1(0xE4), o1(0xE5), o1(0xE6), o1(0xE7),
- o1(0xE8), o1(0xE9), o1(0xEA), o1(0xEB),
- o1(0xEC), o1(0xED), o1(0xEE), o1(0xEF),
- o1(0xF0), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF7),
- o1(0xF8), o1(0xF9), o1(0xFA), o1(0xFB),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_11_E0_B9 = {
- to_ISO_8859_11_E0_B9_offsets,
- to_ISO_8859_11_E0_B9_infos
-};
-
-static const unsigned char
-to_ISO_8859_11_E0_offsets[64] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_11_E0_infos[3] = {
- &to_ISO_8859_11_E0_B8, &to_ISO_8859_11_E0_B9,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_11_E0 = {
- to_ISO_8859_11_E0_offsets,
- to_ISO_8859_11_E0_infos
-};
-
-static const unsigned char
-to_ISO_8859_11_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-};
-static const struct byte_lookup* const
-to_ISO_8859_11_infos[4] = {
- NOMAP, &to_ISO_8859_11_C2,
- &to_ISO_8859_11_E0, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_11 = {
- to_ISO_8859_11_offsets,
- to_ISO_8859_11_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_11 = {
- "UTF-8", "ISO-8859-11", &to_ISO_8859_11, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_13_infos[129] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o3(0xE2,0x80,0x9D), o2(0xC2,0xA2),
- o2(0xC2,0xA3), o2(0xC2,0xA4),
- o3(0xE2,0x80,0x9E), o2(0xC2,0xA6),
- o2(0xC2,0xA7), o2(0xC3,0x98),
- o2(0xC2,0xA9), o2(0xC5,0x96),
- o2(0xC2,0xAB), o2(0xC2,0xAC),
- o2(0xC2,0xAD), o2(0xC2,0xAE),
- o2(0xC3,0x86), o2(0xC2,0xB0),
- o2(0xC2,0xB1), o2(0xC2,0xB2),
- o2(0xC2,0xB3), o3(0xE2,0x80,0x9C),
- o2(0xC2,0xB5), o2(0xC2,0xB6),
- o2(0xC2,0xB7), o2(0xC3,0xB8),
- o2(0xC2,0xB9), o2(0xC5,0x97),
- o2(0xC2,0xBB), o2(0xC2,0xBC),
- o2(0xC2,0xBD), o2(0xC2,0xBE),
- o2(0xC3,0xA6), o2(0xC4,0x84),
- o2(0xC4,0xAE), o2(0xC4,0x80),
- o2(0xC4,0x86), o2(0xC3,0x84),
- o2(0xC3,0x85), o2(0xC4,0x98),
- o2(0xC4,0x92), o2(0xC4,0x8C),
- o2(0xC3,0x89), o2(0xC5,0xB9),
- o2(0xC4,0x96), o2(0xC4,0xA2),
- o2(0xC4,0xB6), o2(0xC4,0xAA),
- o2(0xC4,0xBB), o2(0xC5,0xA0),
- o2(0xC5,0x83), o2(0xC5,0x85),
- o2(0xC3,0x93), o2(0xC5,0x8C),
- o2(0xC3,0x95), o2(0xC3,0x96),
- o2(0xC3,0x97), o2(0xC5,0xB2),
- o2(0xC5,0x81), o2(0xC5,0x9A),
- o2(0xC5,0xAA), o2(0xC3,0x9C),
- o2(0xC5,0xBB), o2(0xC5,0xBD),
- o2(0xC3,0x9F), o2(0xC4,0x85),
- o2(0xC4,0xAF), o2(0xC4,0x81),
- o2(0xC4,0x87), o2(0xC3,0xA4),
- o2(0xC3,0xA5), o2(0xC4,0x99),
- o2(0xC4,0x93), o2(0xC4,0x8D),
- o2(0xC3,0xA9), o2(0xC5,0xBA),
- o2(0xC4,0x97), o2(0xC4,0xA3),
- o2(0xC4,0xB7), o2(0xC4,0xAB),
- o2(0xC4,0xBC), o2(0xC5,0xA1),
- o2(0xC5,0x84), o2(0xC5,0x86),
- o2(0xC3,0xB3), o2(0xC5,0x8D),
- o2(0xC3,0xB5), o2(0xC3,0xB6),
- o2(0xC3,0xB7), o2(0xC5,0xB3),
- o2(0xC5,0x82), o2(0xC5,0x9B),
- o2(0xC5,0xAB), o2(0xC3,0xBC),
- o2(0xC5,0xBC), o2(0xC5,0xBE),
- o3(0xE2,0x80,0x99),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_13 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_13_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_13 = {
- "ISO-8859-13", "UTF-8", &from_ISO_8859_13, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_13_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 55, 33, 34, 35, 55, 36, 37, 55, 38, 55, 39, 40, 41, 42, 55,
- 43, 44, 45, 46, 55, 47, 48, 49, 55, 50, 55, 51, 52, 53, 54, 55,
-};
-static const struct byte_lookup* const
-to_ISO_8859_13_C2_infos[56] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA2), o1(0xA3), o1(0xA4),
- o1(0xA6), o1(0xA7), o1(0xA9), o1(0xAB),
- o1(0xAC), o1(0xAD), o1(0xAE), o1(0xB0),
- o1(0xB1), o1(0xB2), o1(0xB3), o1(0xB5),
- o1(0xB6), o1(0xB7), o1(0xB9), o1(0xBB),
- o1(0xBC), o1(0xBD), o1(0xBE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13_C2 = {
- to_ISO_8859_13_C2_offsets,
- to_ISO_8859_13_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_13_C3_offsets[64] = {
- 21, 21, 21, 21, 0, 1, 2, 21, 21, 3, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 4, 21, 5, 6, 7, 8, 21, 21, 21, 9, 21, 21, 10,
- 21, 21, 21, 21, 11, 12, 13, 21, 21, 14, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 15, 21, 16, 17, 18, 19, 21, 21, 21, 20, 21, 21, 21,
-};
-static const struct byte_lookup* const
-to_ISO_8859_13_C3_infos[22] = {
- o1(0xC4), o1(0xC5), o1(0xAF), o1(0xC9),
- o1(0xD3), o1(0xD5), o1(0xD6), o1(0xD7),
- o1(0xA8), o1(0xDC), o1(0xDF), o1(0xE4),
- o1(0xE5), o1(0xBF), o1(0xE9), o1(0xF3),
- o1(0xF5), o1(0xF6), o1(0xF7), o1(0xB8),
- o1(0xFC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13_C3 = {
- to_ISO_8859_13_C3_offsets,
- to_ISO_8859_13_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_13_C4_offsets[64] = {
- 0, 1, 24, 24, 2, 3, 4, 5, 24, 24, 24, 24, 6, 7, 24, 24,
- 24, 24, 8, 9, 24, 24, 10, 11, 12, 13, 24, 24, 24, 24, 24, 24,
- 24, 24, 14, 15, 24, 24, 24, 24, 24, 24, 16, 17, 24, 24, 18, 19,
- 24, 24, 24, 24, 24, 24, 20, 21, 24, 24, 24, 22, 23, 24, 24, 24,
-};
-static const struct byte_lookup* const
-to_ISO_8859_13_C4_infos[25] = {
- o1(0xC2), o1(0xE2), o1(0xC0), o1(0xE0),
- o1(0xC3), o1(0xE3), o1(0xC8), o1(0xE8),
- o1(0xC7), o1(0xE7), o1(0xCB), o1(0xEB),
- o1(0xC6), o1(0xE6), o1(0xCC), o1(0xEC),
- o1(0xCE), o1(0xEE), o1(0xC1), o1(0xE1),
- o1(0xCD), o1(0xED), o1(0xCF), o1(0xEF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13_C4 = {
- to_ISO_8859_13_C4_offsets,
- to_ISO_8859_13_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_13_C5_offsets[64] = {
- 24, 0, 1, 2, 3, 4, 5, 24, 24, 24, 24, 24, 6, 7, 24, 24,
- 24, 24, 24, 24, 24, 24, 8, 9, 24, 24, 10, 11, 24, 24, 24, 24,
- 12, 13, 24, 24, 24, 24, 24, 24, 24, 24, 14, 15, 24, 24, 24, 24,
- 24, 24, 16, 17, 24, 24, 24, 24, 24, 18, 19, 20, 21, 22, 23, 24,
-};
-static const struct byte_lookup* const
-to_ISO_8859_13_C5_infos[25] = {
- o1(0xD9), o1(0xF9), o1(0xD1), o1(0xF1),
- o1(0xD2), o1(0xF2), o1(0xD4), o1(0xF4),
- o1(0xAA), o1(0xBA), o1(0xDA), o1(0xFA),
- o1(0xD0), o1(0xF0), o1(0xDB), o1(0xFB),
- o1(0xD8), o1(0xF8), o1(0xCA), o1(0xEA),
- o1(0xDD), o1(0xFD), o1(0xDE), o1(0xFE),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13_C5 = {
- to_ISO_8859_13_C5_offsets,
- to_ISO_8859_13_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_13_E2_80_offsets[64] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 1, 2, 3, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_ISO_8859_13_E2_80_infos[5] = {
- o1(0xFF), o1(0xB4), o1(0xA1), o1(0xA5),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13_E2_80 = {
- to_ISO_8859_13_E2_80_offsets,
- to_ISO_8859_13_E2_80_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_13_E2_infos[2] = {
- &to_ISO_8859_13_E2_80, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13_E2 = {
- to_ISO_8859_8_E2_offsets,
- to_ISO_8859_13_E2_infos
-};
-
-static const struct byte_lookup* const
-to_ISO_8859_13_infos[7] = {
- NOMAP, &to_ISO_8859_13_C2,
- &to_ISO_8859_13_C3, &to_ISO_8859_13_C4,
- &to_ISO_8859_13_C5, &to_ISO_8859_13_E2,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_13 = {
- to_ISO_8859_10_offsets,
- to_ISO_8859_13_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_13 = {
- "UTF-8", "ISO-8859-13", &to_ISO_8859_13, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_14_infos[129] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o3(0xE1,0xB8,0x82), o3(0xE1,0xB8,0x83),
- o2(0xC2,0xA3), o2(0xC4,0x8A),
- o2(0xC4,0x8B), o3(0xE1,0xB8,0x8A),
- o2(0xC2,0xA7), o3(0xE1,0xBA,0x80),
- o2(0xC2,0xA9), o3(0xE1,0xBA,0x82),
- o3(0xE1,0xB8,0x8B), o3(0xE1,0xBB,0xB2),
- o2(0xC2,0xAD), o2(0xC2,0xAE),
- o2(0xC5,0xB8), o3(0xE1,0xB8,0x9E),
- o3(0xE1,0xB8,0x9F), o2(0xC4,0xA0),
- o2(0xC4,0xA1), o3(0xE1,0xB9,0x80),
- o3(0xE1,0xB9,0x81), o2(0xC2,0xB6),
- o3(0xE1,0xB9,0x96), o3(0xE1,0xBA,0x81),
- o3(0xE1,0xB9,0x97), o3(0xE1,0xBA,0x83),
- o3(0xE1,0xB9,0xA0), o3(0xE1,0xBB,0xB3),
- o3(0xE1,0xBA,0x84), o3(0xE1,0xBA,0x85),
- o3(0xE1,0xB9,0xA1), o2(0xC3,0x80),
- o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC3,0x83), o2(0xC3,0x84),
- o2(0xC3,0x85), o2(0xC3,0x86),
- o2(0xC3,0x87), o2(0xC3,0x88),
- o2(0xC3,0x89), o2(0xC3,0x8A),
- o2(0xC3,0x8B), o2(0xC3,0x8C),
- o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC3,0x8F), o2(0xC5,0xB4),
- o2(0xC3,0x91), o2(0xC3,0x92),
- o2(0xC3,0x93), o2(0xC3,0x94),
- o2(0xC3,0x95), o2(0xC3,0x96),
- o3(0xE1,0xB9,0xAA), o2(0xC3,0x98),
- o2(0xC3,0x99), o2(0xC3,0x9A),
- o2(0xC3,0x9B), o2(0xC3,0x9C),
- o2(0xC3,0x9D), o2(0xC5,0xB6),
- o2(0xC3,0x9F), o2(0xC3,0xA0),
- o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC3,0xA3), o2(0xC3,0xA4),
- o2(0xC3,0xA5), o2(0xC3,0xA6),
- o2(0xC3,0xA7), o2(0xC3,0xA8),
- o2(0xC3,0xA9), o2(0xC3,0xAA),
- o2(0xC3,0xAB), o2(0xC3,0xAC),
- o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC3,0xAF), o2(0xC5,0xB5),
- o2(0xC3,0xB1), o2(0xC3,0xB2),
- o2(0xC3,0xB3), o2(0xC3,0xB4),
- o2(0xC3,0xB5), o2(0xC3,0xB6),
- o3(0xE1,0xB9,0xAB), o2(0xC3,0xB8),
- o2(0xC3,0xB9), o2(0xC3,0xBA),
- o2(0xC3,0xBB), o2(0xC3,0xBC),
- o2(0xC3,0xBD), o2(0xC5,0xB7),
- o2(0xC3,0xBF),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_14 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_14_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_14 = {
- "ISO-8859-14", "UTF-8", &from_ISO_8859_14, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_14_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 39, 39, 33, 39, 39, 39, 34, 39, 35, 39, 39, 39, 36, 37, 39,
- 39, 39, 39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_C2_infos[40] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA3), o1(0xA7), o1(0xA9),
- o1(0xAD), o1(0xAE), o1(0xB6), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_C2 = {
- to_ISO_8859_14_C2_offsets,
- to_ISO_8859_14_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_C3_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 58, 16, 17, 18, 19, 20, 21, 58, 22, 23, 24, 25, 26, 27, 58, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 58, 45, 46, 47, 48, 49, 50, 58, 51, 52, 53, 54, 55, 56, 58, 57,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_C3_infos[59] = {
- o1(0xC0), o1(0xC1), o1(0xC2), o1(0xC3),
- o1(0xC4), o1(0xC5), o1(0xC6), o1(0xC7),
- o1(0xC8), o1(0xC9), o1(0xCA), o1(0xCB),
- o1(0xCC), o1(0xCD), o1(0xCE), o1(0xCF),
- o1(0xD1), o1(0xD2), o1(0xD3), o1(0xD4),
- o1(0xD5), o1(0xD6), o1(0xD8), o1(0xD9),
- o1(0xDA), o1(0xDB), o1(0xDC), o1(0xDD),
- o1(0xDF), o1(0xE0), o1(0xE1), o1(0xE2),
- o1(0xE3), o1(0xE4), o1(0xE5), o1(0xE6),
- o1(0xE7), o1(0xE8), o1(0xE9), o1(0xEA),
- o1(0xEB), o1(0xEC), o1(0xED), o1(0xEE),
- o1(0xEF), o1(0xF1), o1(0xF2), o1(0xF3),
- o1(0xF4), o1(0xF5), o1(0xF6), o1(0xF8),
- o1(0xF9), o1(0xFA), o1(0xFB), o1(0xFC),
- o1(0xFD), o1(0xFF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_C3 = {
- to_ISO_8859_14_C3_offsets,
- to_ISO_8859_14_C3_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_C4_offsets[64] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 1, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_C4_infos[5] = {
- o1(0xA4), o1(0xA5), o1(0xB2), o1(0xB3),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_C4 = {
- to_ISO_8859_14_C4_offsets,
- to_ISO_8859_14_C4_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_C5_offsets[64] = {
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_C5_infos[6] = {
- o1(0xD0), o1(0xF0), o1(0xDE), o1(0xFE),
- o1(0xAF), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_C5 = {
- to_ISO_8859_14_C5_offsets,
- to_ISO_8859_14_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_E1_B8_offsets[64] = {
- 6, 6, 0, 1, 6, 6, 6, 6, 6, 6, 2, 3, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_E1_B8_infos[7] = {
- o1(0xA1), o1(0xA2), o1(0xA6), o1(0xAB),
- o1(0xB0), o1(0xB1), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_E1_B8 = {
- to_ISO_8859_14_E1_B8_offsets,
- to_ISO_8859_14_E1_B8_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_E1_B9_offsets[64] = {
- 0, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 2, 3, 8, 8, 8, 8, 8, 8, 8, 8,
- 4, 5, 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_E1_B9_infos[9] = {
- o1(0xB4), o1(0xB5), o1(0xB7), o1(0xB9),
- o1(0xBB), o1(0xBF), o1(0xD7), o1(0xF7),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_E1_B9 = {
- to_ISO_8859_14_E1_B9_offsets,
- to_ISO_8859_14_E1_B9_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_E1_BA_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_E1_BA_infos[7] = {
- o1(0xA8), o1(0xB8), o1(0xAA), o1(0xBA),
- o1(0xBD), o1(0xBE), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_E1_BA = {
- to_ISO_8859_14_E1_BA_offsets,
- to_ISO_8859_14_E1_BA_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_E1_BB_offsets[64] = {
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_E1_BB_infos[3] = {
- o1(0xAC), o1(0xBC), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_E1_BB = {
- to_ISO_8859_14_E1_BB_offsets,
- to_ISO_8859_14_E1_BB_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_E1_offsets[64] = {
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 0, 1, 2, 3, 4, 4, 4, 4,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_E1_infos[5] = {
- &to_ISO_8859_14_E1_B8, &to_ISO_8859_14_E1_B9,
- &to_ISO_8859_14_E1_BA, &to_ISO_8859_14_E1_BB,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14_E1 = {
- to_ISO_8859_14_E1_offsets,
- to_ISO_8859_14_E1_infos
-};
-
-static const unsigned char
-to_ISO_8859_14_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 1, 2, 3, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-};
-static const struct byte_lookup* const
-to_ISO_8859_14_infos[7] = {
- NOMAP, &to_ISO_8859_14_C2,
- &to_ISO_8859_14_C3, &to_ISO_8859_14_C4,
- &to_ISO_8859_14_C5, &to_ISO_8859_14_E1,
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_14 = {
- to_ISO_8859_14_offsets,
- to_ISO_8859_14_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_14 = {
- "UTF-8", "ISO-8859-14", &to_ISO_8859_14, 1, 1,
- NULL, NULL,
-};
-
-static const struct byte_lookup* const
-from_ISO_8859_15_infos[129] = {
- NOMAP, o2(0xC2,0x80),
- o2(0xC2,0x81), o2(0xC2,0x82),
- o2(0xC2,0x83), o2(0xC2,0x84),
- o2(0xC2,0x85), o2(0xC2,0x86),
- o2(0xC2,0x87), o2(0xC2,0x88),
- o2(0xC2,0x89), o2(0xC2,0x8A),
- o2(0xC2,0x8B), o2(0xC2,0x8C),
- o2(0xC2,0x8D), o2(0xC2,0x8E),
- o2(0xC2,0x8F), o2(0xC2,0x90),
- o2(0xC2,0x91), o2(0xC2,0x92),
- o2(0xC2,0x93), o2(0xC2,0x94),
- o2(0xC2,0x95), o2(0xC2,0x96),
- o2(0xC2,0x97), o2(0xC2,0x98),
- o2(0xC2,0x99), o2(0xC2,0x9A),
- o2(0xC2,0x9B), o2(0xC2,0x9C),
- o2(0xC2,0x9D), o2(0xC2,0x9E),
- o2(0xC2,0x9F), o2(0xC2,0xA0),
- o2(0xC2,0xA1), o2(0xC2,0xA2),
- o2(0xC2,0xA3), o3(0xE2,0x82,0xAC),
- o2(0xC2,0xA5), o2(0xC5,0xA0),
- o2(0xC2,0xA7), o2(0xC5,0xA1),
- o2(0xC2,0xA9), o2(0xC2,0xAA),
- o2(0xC2,0xAB), o2(0xC2,0xAC),
- o2(0xC2,0xAD), o2(0xC2,0xAE),
- o2(0xC2,0xAF), o2(0xC2,0xB0),
- o2(0xC2,0xB1), o2(0xC2,0xB2),
- o2(0xC2,0xB3), o2(0xC5,0xBD),
- o2(0xC2,0xB5), o2(0xC2,0xB6),
- o2(0xC2,0xB7), o2(0xC5,0xBE),
- o2(0xC2,0xB9), o2(0xC2,0xBA),
- o2(0xC2,0xBB), o2(0xC5,0x92),
- o2(0xC5,0x93), o2(0xC5,0xB8),
- o2(0xC2,0xBF), o2(0xC3,0x80),
- o2(0xC3,0x81), o2(0xC3,0x82),
- o2(0xC3,0x83), o2(0xC3,0x84),
- o2(0xC3,0x85), o2(0xC3,0x86),
- o2(0xC3,0x87), o2(0xC3,0x88),
- o2(0xC3,0x89), o2(0xC3,0x8A),
- o2(0xC3,0x8B), o2(0xC3,0x8C),
- o2(0xC3,0x8D), o2(0xC3,0x8E),
- o2(0xC3,0x8F), o2(0xC3,0x90),
- o2(0xC3,0x91), o2(0xC3,0x92),
- o2(0xC3,0x93), o2(0xC3,0x94),
- o2(0xC3,0x95), o2(0xC3,0x96),
- o2(0xC3,0x97), o2(0xC3,0x98),
- o2(0xC3,0x99), o2(0xC3,0x9A),
- o2(0xC3,0x9B), o2(0xC3,0x9C),
- o2(0xC3,0x9D), o2(0xC3,0x9E),
- o2(0xC3,0x9F), o2(0xC3,0xA0),
- o2(0xC3,0xA1), o2(0xC3,0xA2),
- o2(0xC3,0xA3), o2(0xC3,0xA4),
- o2(0xC3,0xA5), o2(0xC3,0xA6),
- o2(0xC3,0xA7), o2(0xC3,0xA8),
- o2(0xC3,0xA9), o2(0xC3,0xAA),
- o2(0xC3,0xAB), o2(0xC3,0xAC),
- o2(0xC3,0xAD), o2(0xC3,0xAE),
- o2(0xC3,0xAF), o2(0xC3,0xB0),
- o2(0xC3,0xB1), o2(0xC3,0xB2),
- o2(0xC3,0xB3), o2(0xC3,0xB4),
- o2(0xC3,0xB5), o2(0xC3,0xB6),
- o2(0xC3,0xB7), o2(0xC3,0xB8),
- o2(0xC3,0xB9), o2(0xC3,0xBA),
- o2(0xC3,0xBB), o2(0xC3,0xBC),
- o2(0xC3,0xBD), o2(0xC3,0xBE),
- o2(0xC3,0xBF),
-};
-static const BYTE_LOOKUP
-from_ISO_8859_15 = {
- from_ISO_8859_1_offsets,
- from_ISO_8859_15_infos
-};
-static rb_transcoder
-rb_from_ISO_8859_15 = {
- "ISO-8859-15", "UTF-8", &from_ISO_8859_15, 3, 0,
- NULL, NULL,
-};
-
-static const unsigned char
-to_ISO_8859_15_C2_offsets[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 56, 36, 56, 37, 56, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 56, 49, 50, 51, 56, 52, 53, 54, 56, 56, 56, 55,
-};
-static const struct byte_lookup* const
-to_ISO_8859_15_C2_infos[57] = {
- o1(0x80), o1(0x81), o1(0x82), o1(0x83),
- o1(0x84), o1(0x85), o1(0x86), o1(0x87),
- o1(0x88), o1(0x89), o1(0x8A), o1(0x8B),
- o1(0x8C), o1(0x8D), o1(0x8E), o1(0x8F),
- o1(0x90), o1(0x91), o1(0x92), o1(0x93),
- o1(0x94), o1(0x95), o1(0x96), o1(0x97),
- o1(0x98), o1(0x99), o1(0x9A), o1(0x9B),
- o1(0x9C), o1(0x9D), o1(0x9E), o1(0x9F),
- o1(0xA0), o1(0xA1), o1(0xA2), o1(0xA3),
- o1(0xA5), o1(0xA7), o1(0xA9), o1(0xAA),
- o1(0xAB), o1(0xAC), o1(0xAD), o1(0xAE),
- o1(0xAF), o1(0xB0), o1(0xB1), o1(0xB2),
- o1(0xB3), o1(0xB5), o1(0xB6), o1(0xB7),
- o1(0xB9), o1(0xBA), o1(0xBB), o1(0xBF),
- UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_15_C2 = {
- to_ISO_8859_15_C2_offsets,
- to_ISO_8859_15_C2_infos
-};
-
-static const unsigned char
-to_ISO_8859_15_C5_offsets[64] = {
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 0, 1, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 2, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 4, 7, 7, 7, 7, 5, 6, 7,
-};
-static const struct byte_lookup* const
-to_ISO_8859_15_C5_infos[8] = {
- o1(0xBC), o1(0xBD), o1(0xA6), o1(0xA8),
- o1(0xBE), o1(0xB4), o1(0xB8), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_15_C5 = {
- to_ISO_8859_15_C5_offsets,
- to_ISO_8859_15_C5_infos
-};
-
-static const unsigned char
-to_ISO_8859_15_E2_82_offsets[64] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_15_E2_82_infos[2] = {
- o1(0xA4), UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_15_E2_82 = {
- to_ISO_8859_15_E2_82_offsets,
- to_ISO_8859_15_E2_82_infos
-};
-
-static const unsigned char
-to_ISO_8859_15_E2_offsets[64] = {
- 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-static const struct byte_lookup* const
-to_ISO_8859_15_E2_infos[2] = {
- &to_ISO_8859_15_E2_82, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_15_E2 = {
- to_ISO_8859_15_E2_offsets,
- to_ISO_8859_15_E2_infos
-};
-
-static const unsigned char
-to_ISO_8859_15_offsets[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 1, 2, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
-};
-static const struct byte_lookup* const
-to_ISO_8859_15_infos[6] = {
- NOMAP, &to_ISO_8859_15_C2,
- &to_ISO_8859_1_C3, &to_ISO_8859_15_C5,
- &to_ISO_8859_15_E2, UNDEF,
-};
-static const BYTE_LOOKUP
-to_ISO_8859_15 = {
- to_ISO_8859_15_offsets,
- to_ISO_8859_15_infos
-};
-static rb_transcoder
-rb_to_ISO_8859_15 = {
- "UTF-8", "ISO-8859-15", &to_ISO_8859_15, 1, 1,
- NULL, NULL,
-};
-
-void
-Init_single_byte(void)
-{
- rb_register_transcoder(&rb_from_ISO_8859_1);
- rb_register_transcoder(&rb_from_ISO_8859_2);
- rb_register_transcoder(&rb_from_ISO_8859_3);
- rb_register_transcoder(&rb_from_ISO_8859_4);
- rb_register_transcoder(&rb_from_ISO_8859_5);
- rb_register_transcoder(&rb_from_ISO_8859_6);
- rb_register_transcoder(&rb_from_ISO_8859_7);
- rb_register_transcoder(&rb_from_ISO_8859_8);
- rb_register_transcoder(&rb_from_ISO_8859_9);
- rb_register_transcoder(&rb_from_ISO_8859_10);
- rb_register_transcoder(&rb_from_ISO_8859_11);
- rb_register_transcoder(&rb_from_ISO_8859_13);
- rb_register_transcoder(&rb_from_ISO_8859_14);
- rb_register_transcoder(&rb_from_ISO_8859_15);
- rb_register_transcoder(&rb_to_ISO_8859_1);
- rb_register_transcoder(&rb_to_ISO_8859_2);
- rb_register_transcoder(&rb_to_ISO_8859_3);
- rb_register_transcoder(&rb_to_ISO_8859_4);
- rb_register_transcoder(&rb_to_ISO_8859_5);
- rb_register_transcoder(&rb_to_ISO_8859_6);
- rb_register_transcoder(&rb_to_ISO_8859_7);
- rb_register_transcoder(&rb_to_ISO_8859_8);
- rb_register_transcoder(&rb_to_ISO_8859_9);
- rb_register_transcoder(&rb_to_ISO_8859_10);
- rb_register_transcoder(&rb_to_ISO_8859_11);
- rb_register_transcoder(&rb_to_ISO_8859_13);
- rb_register_transcoder(&rb_to_ISO_8859_14);
- rb_register_transcoder(&rb_to_ISO_8859_15);
-}
-/* Footprint (bytes): gross: 26788, saved: 3728, net: 23060 */
diff --git a/enc/unicode.c b/enc/unicode.c
deleted file mode 100644
index 8b1a1308dc..0000000000
--- a/enc/unicode.c
+++ /dev/null
@@ -1,11345 +0,0 @@
-/**********************************************************************
- unicode.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-#define ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code,ctype) \
- ((EncUNICODE_ISO_8859_1_CtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-#if 0
-#define ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(code,cbit) \
- ((EncUNICODE_ISO_8859_1_CtypeTable[code] & (cbit)) != 0)
-#endif
-
-static const unsigned short EncUNICODE_ISO_8859_1_CtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x428c, 0x4289, 0x4288, 0x4288, 0x4288, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0288, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
- 0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x30e2, 0x01a0, 0x00a0, 0x00a8, 0x00a0, 0x00a0,
- 0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x30e2, 0x00a0, 0x01a0,
- 0x00a0, 0x10a0, 0x30e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x00a0,
- 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x00a0,
- 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2
-};
-
-/* 'NEWLINE' */
-static const OnigCodePoint CR_NEWLINE[] = {
- 1,
- 0x000a, 0x000a
-}; /* CR_NEWLINE */
-
-/* 'Alpha': [[:Alpha:]] */
-static const OnigCodePoint CR_Alpha[] = {
- 418,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0241,
- 0x0250, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ee, 0x02ee,
- 0x0300, 0x036f,
- 0x037a, 0x037a,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0561, 0x0587,
- 0x0591, 0x05b9,
- 0x05bb, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f2,
- 0x0610, 0x0615,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06de, 0x06e8,
- 0x06ea, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0963,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09f0, 0x09f1,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a70, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1050, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x135f,
- 0x1380, 0x138f,
- 0x13a0, 0x13f4,
- 0x1401, 0x166c,
- 0x166f, 0x1676,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x180b, 0x180d,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x1a00, 0x1a1b,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x2094,
- 0x20d0, 0x20eb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2ce4,
- 0x2d00, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3006,
- 0x302a, 0x302f,
- 0x3031, 0x3035,
- 0x303b, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x31a0, 0x31b7,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa800, 0xa827,
- 0xac00, 0xd7a3,
- 0xf900, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10300, 0x1031e,
- 0x10330, 0x10349,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10400, 0x1049d,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0xe0100, 0xe01ef
-}; /* CR_Alpha */
-
-/* 'Blank': [[:Blank:]] */
-static const OnigCodePoint CR_Blank[] = {
- 9,
- 0x0009, 0x0009,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x180e, 0x180e,
- 0x2000, 0x200a,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000
-}; /* CR_Blank */
-
-/* 'Cntrl': [[:Cntrl:]] */
-static const OnigCodePoint CR_Cntrl[] = {
- 19,
- 0x0000, 0x001f,
- 0x007f, 0x009f,
- 0x00ad, 0x00ad,
- 0x0600, 0x0603,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x17b4, 0x17b5,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x2063,
- 0x206a, 0x206f,
- 0xd800, 0xf8ff,
- 0xfeff, 0xfeff,
- 0xfff9, 0xfffb,
- 0x1d173, 0x1d17a,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd
-}; /* CR_Cntrl */
-
-/* 'Digit': [[:Digit:]] */
-static const OnigCodePoint CR_Digit[] = {
- 23,
- 0x0030, 0x0039,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0be6, 0x0bef,
- 0x0c66, 0x0c6f,
- 0x0ce6, 0x0cef,
- 0x0d66, 0x0d6f,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f29,
- 0x1040, 0x1049,
- 0x17e0, 0x17e9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19d9,
- 0xff10, 0xff19,
- 0x104a0, 0x104a9,
- 0x1d7ce, 0x1d7ff
-}; /* CR_Digit */
-
-/* 'Graph': [[:Graph:]] */
-static const OnigCodePoint CR_Graph[] = {
- 424,
- 0x0021, 0x007e,
- 0x00a1, 0x0241,
- 0x0250, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05b9,
- 0x05bb, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060b, 0x0615,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fd1,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1681, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180d,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x200b, 0x2027,
- 0x202a, 0x202e,
- 0x2030, 0x205e,
- 0x2060, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20eb,
- 0x2100, 0x214c,
- 0x2153, 0x2183,
- 0x2190, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27c6,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b13,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3001, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31cf,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa800, 0xa82b,
- 0xac00, 0xd7a3,
- 0xe000, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd
-}; /* CR_Graph */
-
-/* 'Lower': [[:Lower:]] */
-static const OnigCodePoint CR_Lower[] = {
- 480,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00df, 0x00f6,
- 0x00f8, 0x00ff,
- 0x0101, 0x0101,
- 0x0103, 0x0103,
- 0x0105, 0x0105,
- 0x0107, 0x0107,
- 0x0109, 0x0109,
- 0x010b, 0x010b,
- 0x010d, 0x010d,
- 0x010f, 0x010f,
- 0x0111, 0x0111,
- 0x0113, 0x0113,
- 0x0115, 0x0115,
- 0x0117, 0x0117,
- 0x0119, 0x0119,
- 0x011b, 0x011b,
- 0x011d, 0x011d,
- 0x011f, 0x011f,
- 0x0121, 0x0121,
- 0x0123, 0x0123,
- 0x0125, 0x0125,
- 0x0127, 0x0127,
- 0x0129, 0x0129,
- 0x012b, 0x012b,
- 0x012d, 0x012d,
- 0x012f, 0x012f,
- 0x0131, 0x0131,
- 0x0133, 0x0133,
- 0x0135, 0x0135,
- 0x0137, 0x0138,
- 0x013a, 0x013a,
- 0x013c, 0x013c,
- 0x013e, 0x013e,
- 0x0140, 0x0140,
- 0x0142, 0x0142,
- 0x0144, 0x0144,
- 0x0146, 0x0146,
- 0x0148, 0x0149,
- 0x014b, 0x014b,
- 0x014d, 0x014d,
- 0x014f, 0x014f,
- 0x0151, 0x0151,
- 0x0153, 0x0153,
- 0x0155, 0x0155,
- 0x0157, 0x0157,
- 0x0159, 0x0159,
- 0x015b, 0x015b,
- 0x015d, 0x015d,
- 0x015f, 0x015f,
- 0x0161, 0x0161,
- 0x0163, 0x0163,
- 0x0165, 0x0165,
- 0x0167, 0x0167,
- 0x0169, 0x0169,
- 0x016b, 0x016b,
- 0x016d, 0x016d,
- 0x016f, 0x016f,
- 0x0171, 0x0171,
- 0x0173, 0x0173,
- 0x0175, 0x0175,
- 0x0177, 0x0177,
- 0x017a, 0x017a,
- 0x017c, 0x017c,
- 0x017e, 0x0180,
- 0x0183, 0x0183,
- 0x0185, 0x0185,
- 0x0188, 0x0188,
- 0x018c, 0x018d,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019b,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01aa, 0x01ab,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01ba,
- 0x01bd, 0x01bf,
- 0x01c6, 0x01c6,
- 0x01c9, 0x01c9,
- 0x01cc, 0x01cc,
- 0x01ce, 0x01ce,
- 0x01d0, 0x01d0,
- 0x01d2, 0x01d2,
- 0x01d4, 0x01d4,
- 0x01d6, 0x01d6,
- 0x01d8, 0x01d8,
- 0x01da, 0x01da,
- 0x01dc, 0x01dd,
- 0x01df, 0x01df,
- 0x01e1, 0x01e1,
- 0x01e3, 0x01e3,
- 0x01e5, 0x01e5,
- 0x01e7, 0x01e7,
- 0x01e9, 0x01e9,
- 0x01eb, 0x01eb,
- 0x01ed, 0x01ed,
- 0x01ef, 0x01f0,
- 0x01f3, 0x01f3,
- 0x01f5, 0x01f5,
- 0x01f9, 0x01f9,
- 0x01fb, 0x01fb,
- 0x01fd, 0x01fd,
- 0x01ff, 0x01ff,
- 0x0201, 0x0201,
- 0x0203, 0x0203,
- 0x0205, 0x0205,
- 0x0207, 0x0207,
- 0x0209, 0x0209,
- 0x020b, 0x020b,
- 0x020d, 0x020d,
- 0x020f, 0x020f,
- 0x0211, 0x0211,
- 0x0213, 0x0213,
- 0x0215, 0x0215,
- 0x0217, 0x0217,
- 0x0219, 0x0219,
- 0x021b, 0x021b,
- 0x021d, 0x021d,
- 0x021f, 0x021f,
- 0x0221, 0x0221,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0239,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0250, 0x02af,
- 0x0390, 0x0390,
- 0x03ac, 0x03ce,
- 0x03d0, 0x03d1,
- 0x03d5, 0x03d7,
- 0x03d9, 0x03d9,
- 0x03db, 0x03db,
- 0x03dd, 0x03dd,
- 0x03df, 0x03df,
- 0x03e1, 0x03e1,
- 0x03e3, 0x03e3,
- 0x03e5, 0x03e5,
- 0x03e7, 0x03e7,
- 0x03e9, 0x03e9,
- 0x03eb, 0x03eb,
- 0x03ed, 0x03ed,
- 0x03ef, 0x03f3,
- 0x03f5, 0x03f5,
- 0x03f8, 0x03f8,
- 0x03fb, 0x03fc,
- 0x0430, 0x045f,
- 0x0461, 0x0461,
- 0x0463, 0x0463,
- 0x0465, 0x0465,
- 0x0467, 0x0467,
- 0x0469, 0x0469,
- 0x046b, 0x046b,
- 0x046d, 0x046d,
- 0x046f, 0x046f,
- 0x0471, 0x0471,
- 0x0473, 0x0473,
- 0x0475, 0x0475,
- 0x0477, 0x0477,
- 0x0479, 0x0479,
- 0x047b, 0x047b,
- 0x047d, 0x047d,
- 0x047f, 0x047f,
- 0x0481, 0x0481,
- 0x048b, 0x048b,
- 0x048d, 0x048d,
- 0x048f, 0x048f,
- 0x0491, 0x0491,
- 0x0493, 0x0493,
- 0x0495, 0x0495,
- 0x0497, 0x0497,
- 0x0499, 0x0499,
- 0x049b, 0x049b,
- 0x049d, 0x049d,
- 0x049f, 0x049f,
- 0x04a1, 0x04a1,
- 0x04a3, 0x04a3,
- 0x04a5, 0x04a5,
- 0x04a7, 0x04a7,
- 0x04a9, 0x04a9,
- 0x04ab, 0x04ab,
- 0x04ad, 0x04ad,
- 0x04af, 0x04af,
- 0x04b1, 0x04b1,
- 0x04b3, 0x04b3,
- 0x04b5, 0x04b5,
- 0x04b7, 0x04b7,
- 0x04b9, 0x04b9,
- 0x04bb, 0x04bb,
- 0x04bd, 0x04bd,
- 0x04bf, 0x04bf,
- 0x04c2, 0x04c2,
- 0x04c4, 0x04c4,
- 0x04c6, 0x04c6,
- 0x04c8, 0x04c8,
- 0x04ca, 0x04ca,
- 0x04cc, 0x04cc,
- 0x04ce, 0x04ce,
- 0x04d1, 0x04d1,
- 0x04d3, 0x04d3,
- 0x04d5, 0x04d5,
- 0x04d7, 0x04d7,
- 0x04d9, 0x04d9,
- 0x04db, 0x04db,
- 0x04dd, 0x04dd,
- 0x04df, 0x04df,
- 0x04e1, 0x04e1,
- 0x04e3, 0x04e3,
- 0x04e5, 0x04e5,
- 0x04e7, 0x04e7,
- 0x04e9, 0x04e9,
- 0x04eb, 0x04eb,
- 0x04ed, 0x04ed,
- 0x04ef, 0x04ef,
- 0x04f1, 0x04f1,
- 0x04f3, 0x04f3,
- 0x04f5, 0x04f5,
- 0x04f7, 0x04f7,
- 0x04f9, 0x04f9,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0561, 0x0587,
- 0x1d00, 0x1d2b,
- 0x1d62, 0x1d77,
- 0x1d79, 0x1d9a,
- 0x1e01, 0x1e01,
- 0x1e03, 0x1e03,
- 0x1e05, 0x1e05,
- 0x1e07, 0x1e07,
- 0x1e09, 0x1e09,
- 0x1e0b, 0x1e0b,
- 0x1e0d, 0x1e0d,
- 0x1e0f, 0x1e0f,
- 0x1e11, 0x1e11,
- 0x1e13, 0x1e13,
- 0x1e15, 0x1e15,
- 0x1e17, 0x1e17,
- 0x1e19, 0x1e19,
- 0x1e1b, 0x1e1b,
- 0x1e1d, 0x1e1d,
- 0x1e1f, 0x1e1f,
- 0x1e21, 0x1e21,
- 0x1e23, 0x1e23,
- 0x1e25, 0x1e25,
- 0x1e27, 0x1e27,
- 0x1e29, 0x1e29,
- 0x1e2b, 0x1e2b,
- 0x1e2d, 0x1e2d,
- 0x1e2f, 0x1e2f,
- 0x1e31, 0x1e31,
- 0x1e33, 0x1e33,
- 0x1e35, 0x1e35,
- 0x1e37, 0x1e37,
- 0x1e39, 0x1e39,
- 0x1e3b, 0x1e3b,
- 0x1e3d, 0x1e3d,
- 0x1e3f, 0x1e3f,
- 0x1e41, 0x1e41,
- 0x1e43, 0x1e43,
- 0x1e45, 0x1e45,
- 0x1e47, 0x1e47,
- 0x1e49, 0x1e49,
- 0x1e4b, 0x1e4b,
- 0x1e4d, 0x1e4d,
- 0x1e4f, 0x1e4f,
- 0x1e51, 0x1e51,
- 0x1e53, 0x1e53,
- 0x1e55, 0x1e55,
- 0x1e57, 0x1e57,
- 0x1e59, 0x1e59,
- 0x1e5b, 0x1e5b,
- 0x1e5d, 0x1e5d,
- 0x1e5f, 0x1e5f,
- 0x1e61, 0x1e61,
- 0x1e63, 0x1e63,
- 0x1e65, 0x1e65,
- 0x1e67, 0x1e67,
- 0x1e69, 0x1e69,
- 0x1e6b, 0x1e6b,
- 0x1e6d, 0x1e6d,
- 0x1e6f, 0x1e6f,
- 0x1e71, 0x1e71,
- 0x1e73, 0x1e73,
- 0x1e75, 0x1e75,
- 0x1e77, 0x1e77,
- 0x1e79, 0x1e79,
- 0x1e7b, 0x1e7b,
- 0x1e7d, 0x1e7d,
- 0x1e7f, 0x1e7f,
- 0x1e81, 0x1e81,
- 0x1e83, 0x1e83,
- 0x1e85, 0x1e85,
- 0x1e87, 0x1e87,
- 0x1e89, 0x1e89,
- 0x1e8b, 0x1e8b,
- 0x1e8d, 0x1e8d,
- 0x1e8f, 0x1e8f,
- 0x1e91, 0x1e91,
- 0x1e93, 0x1e93,
- 0x1e95, 0x1e9b,
- 0x1ea1, 0x1ea1,
- 0x1ea3, 0x1ea3,
- 0x1ea5, 0x1ea5,
- 0x1ea7, 0x1ea7,
- 0x1ea9, 0x1ea9,
- 0x1eab, 0x1eab,
- 0x1ead, 0x1ead,
- 0x1eaf, 0x1eaf,
- 0x1eb1, 0x1eb1,
- 0x1eb3, 0x1eb3,
- 0x1eb5, 0x1eb5,
- 0x1eb7, 0x1eb7,
- 0x1eb9, 0x1eb9,
- 0x1ebb, 0x1ebb,
- 0x1ebd, 0x1ebd,
- 0x1ebf, 0x1ebf,
- 0x1ec1, 0x1ec1,
- 0x1ec3, 0x1ec3,
- 0x1ec5, 0x1ec5,
- 0x1ec7, 0x1ec7,
- 0x1ec9, 0x1ec9,
- 0x1ecb, 0x1ecb,
- 0x1ecd, 0x1ecd,
- 0x1ecf, 0x1ecf,
- 0x1ed1, 0x1ed1,
- 0x1ed3, 0x1ed3,
- 0x1ed5, 0x1ed5,
- 0x1ed7, 0x1ed7,
- 0x1ed9, 0x1ed9,
- 0x1edb, 0x1edb,
- 0x1edd, 0x1edd,
- 0x1edf, 0x1edf,
- 0x1ee1, 0x1ee1,
- 0x1ee3, 0x1ee3,
- 0x1ee5, 0x1ee5,
- 0x1ee7, 0x1ee7,
- 0x1ee9, 0x1ee9,
- 0x1eeb, 0x1eeb,
- 0x1eed, 0x1eed,
- 0x1eef, 0x1eef,
- 0x1ef1, 0x1ef1,
- 0x1ef3, 0x1ef3,
- 0x1ef5, 0x1ef5,
- 0x1ef7, 0x1ef7,
- 0x1ef9, 0x1ef9,
- 0x1f00, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1f87,
- 0x1f90, 0x1f97,
- 0x1fa0, 0x1fa7,
- 0x1fb0, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x210a, 0x210a,
- 0x210e, 0x210f,
- 0x2113, 0x2113,
- 0x212f, 0x212f,
- 0x2134, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213d,
- 0x2146, 0x2149,
- 0x2c30, 0x2c5e,
- 0x2c81, 0x2c81,
- 0x2c83, 0x2c83,
- 0x2c85, 0x2c85,
- 0x2c87, 0x2c87,
- 0x2c89, 0x2c89,
- 0x2c8b, 0x2c8b,
- 0x2c8d, 0x2c8d,
- 0x2c8f, 0x2c8f,
- 0x2c91, 0x2c91,
- 0x2c93, 0x2c93,
- 0x2c95, 0x2c95,
- 0x2c97, 0x2c97,
- 0x2c99, 0x2c99,
- 0x2c9b, 0x2c9b,
- 0x2c9d, 0x2c9d,
- 0x2c9f, 0x2c9f,
- 0x2ca1, 0x2ca1,
- 0x2ca3, 0x2ca3,
- 0x2ca5, 0x2ca5,
- 0x2ca7, 0x2ca7,
- 0x2ca9, 0x2ca9,
- 0x2cab, 0x2cab,
- 0x2cad, 0x2cad,
- 0x2caf, 0x2caf,
- 0x2cb1, 0x2cb1,
- 0x2cb3, 0x2cb3,
- 0x2cb5, 0x2cb5,
- 0x2cb7, 0x2cb7,
- 0x2cb9, 0x2cb9,
- 0x2cbb, 0x2cbb,
- 0x2cbd, 0x2cbd,
- 0x2cbf, 0x2cbf,
- 0x2cc1, 0x2cc1,
- 0x2cc3, 0x2cc3,
- 0x2cc5, 0x2cc5,
- 0x2cc7, 0x2cc7,
- 0x2cc9, 0x2cc9,
- 0x2ccb, 0x2ccb,
- 0x2ccd, 0x2ccd,
- 0x2ccf, 0x2ccf,
- 0x2cd1, 0x2cd1,
- 0x2cd3, 0x2cd3,
- 0x2cd5, 0x2cd5,
- 0x2cd7, 0x2cd7,
- 0x2cd9, 0x2cd9,
- 0x2cdb, 0x2cdb,
- 0x2cdd, 0x2cdd,
- 0x2cdf, 0x2cdf,
- 0x2ce1, 0x2ce1,
- 0x2ce3, 0x2ce4,
- 0x2d00, 0x2d25,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x1d41a, 0x1d433,
- 0x1d44e, 0x1d454,
- 0x1d456, 0x1d467,
- 0x1d482, 0x1d49b,
- 0x1d4b6, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d4cf,
- 0x1d4ea, 0x1d503,
- 0x1d51e, 0x1d537,
- 0x1d552, 0x1d56b,
- 0x1d586, 0x1d59f,
- 0x1d5ba, 0x1d5d3,
- 0x1d5ee, 0x1d607,
- 0x1d622, 0x1d63b,
- 0x1d656, 0x1d66f,
- 0x1d68a, 0x1d6a5,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6e1,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d71b,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d755,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d78f,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9
-}; /* CR_Lower */
-
-/* 'Print': [[:Print:]] */
-static const OnigCodePoint CR_Print[] = {
- 423,
- 0x0009, 0x000d,
- 0x0020, 0x007e,
- 0x0085, 0x0085,
- 0x00a0, 0x0241,
- 0x0250, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05b9,
- 0x05bb, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060b, 0x0615,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fd1,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20eb,
- 0x2100, 0x214c,
- 0x2153, 0x2183,
- 0x2190, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27c6,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b13,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31cf,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa800, 0xa82b,
- 0xac00, 0xd7a3,
- 0xe000, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd
-}; /* CR_Print */
-
-/* 'Punct': [[:Punct:]] */
-static const OnigCodePoint CR_Punct[] = {
- 96,
- 0x0021, 0x0023,
- 0x0025, 0x002a,
- 0x002c, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005b, 0x005d,
- 0x005f, 0x005f,
- 0x007b, 0x007b,
- 0x007d, 0x007d,
- 0x00a1, 0x00a1,
- 0x00ab, 0x00ab,
- 0x00b7, 0x00b7,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x058a,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f3a, 0x0f3d,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd1,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1361, 0x1368,
- 0x166d, 0x166e,
- 0x169b, 0x169c,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x180a,
- 0x1944, 0x1945,
- 0x19de, 0x19df,
- 0x1a1e, 0x1a1f,
- 0x2010, 0x2027,
- 0x2030, 0x2043,
- 0x2045, 0x2051,
- 0x2053, 0x205e,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x2329, 0x232a,
- 0x23b4, 0x23b6,
- 0x2768, 0x2775,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27eb,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x3001, 0x3003,
- 0x3008, 0x3011,
- 0x3014, 0x301f,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fb,
- 0xfd3e, 0xfd3f,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe61,
- 0xfe63, 0xfe63,
- 0xfe68, 0xfe68,
- 0xfe6a, 0xfe6b,
- 0xff01, 0xff03,
- 0xff05, 0xff0a,
- 0xff0c, 0xff0f,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff20,
- 0xff3b, 0xff3d,
- 0xff3f, 0xff3f,
- 0xff5b, 0xff5b,
- 0xff5d, 0xff5d,
- 0xff5f, 0xff65,
- 0x10100, 0x10101,
- 0x1039f, 0x1039f,
- 0x10a50, 0x10a58
-}; /* CR_Punct */
-
-/* 'Space': [[:Space:]] */
-static const OnigCodePoint CR_Space[] = {
- 11,
- 0x0009, 0x000d,
- 0x0020, 0x0020,
- 0x0085, 0x0085,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x180e, 0x180e,
- 0x2000, 0x200a,
- 0x2028, 0x2029,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000
-}; /* CR_Space */
-
-/* 'Upper': [[:Upper:]] */
-static const OnigCodePoint CR_Upper[] = {
- 476,
- 0x0041, 0x005a,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00de,
- 0x0100, 0x0100,
- 0x0102, 0x0102,
- 0x0104, 0x0104,
- 0x0106, 0x0106,
- 0x0108, 0x0108,
- 0x010a, 0x010a,
- 0x010c, 0x010c,
- 0x010e, 0x010e,
- 0x0110, 0x0110,
- 0x0112, 0x0112,
- 0x0114, 0x0114,
- 0x0116, 0x0116,
- 0x0118, 0x0118,
- 0x011a, 0x011a,
- 0x011c, 0x011c,
- 0x011e, 0x011e,
- 0x0120, 0x0120,
- 0x0122, 0x0122,
- 0x0124, 0x0124,
- 0x0126, 0x0126,
- 0x0128, 0x0128,
- 0x012a, 0x012a,
- 0x012c, 0x012c,
- 0x012e, 0x012e,
- 0x0130, 0x0130,
- 0x0132, 0x0132,
- 0x0134, 0x0134,
- 0x0136, 0x0136,
- 0x0139, 0x0139,
- 0x013b, 0x013b,
- 0x013d, 0x013d,
- 0x013f, 0x013f,
- 0x0141, 0x0141,
- 0x0143, 0x0143,
- 0x0145, 0x0145,
- 0x0147, 0x0147,
- 0x014a, 0x014a,
- 0x014c, 0x014c,
- 0x014e, 0x014e,
- 0x0150, 0x0150,
- 0x0152, 0x0152,
- 0x0154, 0x0154,
- 0x0156, 0x0156,
- 0x0158, 0x0158,
- 0x015a, 0x015a,
- 0x015c, 0x015c,
- 0x015e, 0x015e,
- 0x0160, 0x0160,
- 0x0162, 0x0162,
- 0x0164, 0x0164,
- 0x0166, 0x0166,
- 0x0168, 0x0168,
- 0x016a, 0x016a,
- 0x016c, 0x016c,
- 0x016e, 0x016e,
- 0x0170, 0x0170,
- 0x0172, 0x0172,
- 0x0174, 0x0174,
- 0x0176, 0x0176,
- 0x0178, 0x0179,
- 0x017b, 0x017b,
- 0x017d, 0x017d,
- 0x0181, 0x0182,
- 0x0184, 0x0184,
- 0x0186, 0x0187,
- 0x0189, 0x018b,
- 0x018e, 0x0191,
- 0x0193, 0x0194,
- 0x0196, 0x0198,
- 0x019c, 0x019d,
- 0x019f, 0x01a0,
- 0x01a2, 0x01a2,
- 0x01a4, 0x01a4,
- 0x01a6, 0x01a7,
- 0x01a9, 0x01a9,
- 0x01ac, 0x01ac,
- 0x01ae, 0x01af,
- 0x01b1, 0x01b3,
- 0x01b5, 0x01b5,
- 0x01b7, 0x01b8,
- 0x01bc, 0x01bc,
- 0x01c4, 0x01c4,
- 0x01c7, 0x01c7,
- 0x01ca, 0x01ca,
- 0x01cd, 0x01cd,
- 0x01cf, 0x01cf,
- 0x01d1, 0x01d1,
- 0x01d3, 0x01d3,
- 0x01d5, 0x01d5,
- 0x01d7, 0x01d7,
- 0x01d9, 0x01d9,
- 0x01db, 0x01db,
- 0x01de, 0x01de,
- 0x01e0, 0x01e0,
- 0x01e2, 0x01e2,
- 0x01e4, 0x01e4,
- 0x01e6, 0x01e6,
- 0x01e8, 0x01e8,
- 0x01ea, 0x01ea,
- 0x01ec, 0x01ec,
- 0x01ee, 0x01ee,
- 0x01f1, 0x01f1,
- 0x01f4, 0x01f4,
- 0x01f6, 0x01f8,
- 0x01fa, 0x01fa,
- 0x01fc, 0x01fc,
- 0x01fe, 0x01fe,
- 0x0200, 0x0200,
- 0x0202, 0x0202,
- 0x0204, 0x0204,
- 0x0206, 0x0206,
- 0x0208, 0x0208,
- 0x020a, 0x020a,
- 0x020c, 0x020c,
- 0x020e, 0x020e,
- 0x0210, 0x0210,
- 0x0212, 0x0212,
- 0x0214, 0x0214,
- 0x0216, 0x0216,
- 0x0218, 0x0218,
- 0x021a, 0x021a,
- 0x021c, 0x021c,
- 0x021e, 0x021e,
- 0x0220, 0x0220,
- 0x0222, 0x0222,
- 0x0224, 0x0224,
- 0x0226, 0x0226,
- 0x0228, 0x0228,
- 0x022a, 0x022a,
- 0x022c, 0x022c,
- 0x022e, 0x022e,
- 0x0230, 0x0230,
- 0x0232, 0x0232,
- 0x023a, 0x023b,
- 0x023d, 0x023e,
- 0x0241, 0x0241,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03d2, 0x03d4,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f4, 0x03f4,
- 0x03f7, 0x03f7,
- 0x03f9, 0x03fa,
- 0x03fd, 0x042f,
- 0x0460, 0x0460,
- 0x0462, 0x0462,
- 0x0464, 0x0464,
- 0x0466, 0x0466,
- 0x0468, 0x0468,
- 0x046a, 0x046a,
- 0x046c, 0x046c,
- 0x046e, 0x046e,
- 0x0470, 0x0470,
- 0x0472, 0x0472,
- 0x0474, 0x0474,
- 0x0476, 0x0476,
- 0x0478, 0x0478,
- 0x047a, 0x047a,
- 0x047c, 0x047c,
- 0x047e, 0x047e,
- 0x0480, 0x0480,
- 0x048a, 0x048a,
- 0x048c, 0x048c,
- 0x048e, 0x048e,
- 0x0490, 0x0490,
- 0x0492, 0x0492,
- 0x0494, 0x0494,
- 0x0496, 0x0496,
- 0x0498, 0x0498,
- 0x049a, 0x049a,
- 0x049c, 0x049c,
- 0x049e, 0x049e,
- 0x04a0, 0x04a0,
- 0x04a2, 0x04a2,
- 0x04a4, 0x04a4,
- 0x04a6, 0x04a6,
- 0x04a8, 0x04a8,
- 0x04aa, 0x04aa,
- 0x04ac, 0x04ac,
- 0x04ae, 0x04ae,
- 0x04b0, 0x04b0,
- 0x04b2, 0x04b2,
- 0x04b4, 0x04b4,
- 0x04b6, 0x04b6,
- 0x04b8, 0x04b8,
- 0x04ba, 0x04ba,
- 0x04bc, 0x04bc,
- 0x04be, 0x04be,
- 0x04c0, 0x04c1,
- 0x04c3, 0x04c3,
- 0x04c5, 0x04c5,
- 0x04c7, 0x04c7,
- 0x04c9, 0x04c9,
- 0x04cb, 0x04cb,
- 0x04cd, 0x04cd,
- 0x04d0, 0x04d0,
- 0x04d2, 0x04d2,
- 0x04d4, 0x04d4,
- 0x04d6, 0x04d6,
- 0x04d8, 0x04d8,
- 0x04da, 0x04da,
- 0x04dc, 0x04dc,
- 0x04de, 0x04de,
- 0x04e0, 0x04e0,
- 0x04e2, 0x04e2,
- 0x04e4, 0x04e4,
- 0x04e6, 0x04e6,
- 0x04e8, 0x04e8,
- 0x04ea, 0x04ea,
- 0x04ec, 0x04ec,
- 0x04ee, 0x04ee,
- 0x04f0, 0x04f0,
- 0x04f2, 0x04f2,
- 0x04f4, 0x04f4,
- 0x04f6, 0x04f6,
- 0x04f8, 0x04f8,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x1e00, 0x1e00,
- 0x1e02, 0x1e02,
- 0x1e04, 0x1e04,
- 0x1e06, 0x1e06,
- 0x1e08, 0x1e08,
- 0x1e0a, 0x1e0a,
- 0x1e0c, 0x1e0c,
- 0x1e0e, 0x1e0e,
- 0x1e10, 0x1e10,
- 0x1e12, 0x1e12,
- 0x1e14, 0x1e14,
- 0x1e16, 0x1e16,
- 0x1e18, 0x1e18,
- 0x1e1a, 0x1e1a,
- 0x1e1c, 0x1e1c,
- 0x1e1e, 0x1e1e,
- 0x1e20, 0x1e20,
- 0x1e22, 0x1e22,
- 0x1e24, 0x1e24,
- 0x1e26, 0x1e26,
- 0x1e28, 0x1e28,
- 0x1e2a, 0x1e2a,
- 0x1e2c, 0x1e2c,
- 0x1e2e, 0x1e2e,
- 0x1e30, 0x1e30,
- 0x1e32, 0x1e32,
- 0x1e34, 0x1e34,
- 0x1e36, 0x1e36,
- 0x1e38, 0x1e38,
- 0x1e3a, 0x1e3a,
- 0x1e3c, 0x1e3c,
- 0x1e3e, 0x1e3e,
- 0x1e40, 0x1e40,
- 0x1e42, 0x1e42,
- 0x1e44, 0x1e44,
- 0x1e46, 0x1e46,
- 0x1e48, 0x1e48,
- 0x1e4a, 0x1e4a,
- 0x1e4c, 0x1e4c,
- 0x1e4e, 0x1e4e,
- 0x1e50, 0x1e50,
- 0x1e52, 0x1e52,
- 0x1e54, 0x1e54,
- 0x1e56, 0x1e56,
- 0x1e58, 0x1e58,
- 0x1e5a, 0x1e5a,
- 0x1e5c, 0x1e5c,
- 0x1e5e, 0x1e5e,
- 0x1e60, 0x1e60,
- 0x1e62, 0x1e62,
- 0x1e64, 0x1e64,
- 0x1e66, 0x1e66,
- 0x1e68, 0x1e68,
- 0x1e6a, 0x1e6a,
- 0x1e6c, 0x1e6c,
- 0x1e6e, 0x1e6e,
- 0x1e70, 0x1e70,
- 0x1e72, 0x1e72,
- 0x1e74, 0x1e74,
- 0x1e76, 0x1e76,
- 0x1e78, 0x1e78,
- 0x1e7a, 0x1e7a,
- 0x1e7c, 0x1e7c,
- 0x1e7e, 0x1e7e,
- 0x1e80, 0x1e80,
- 0x1e82, 0x1e82,
- 0x1e84, 0x1e84,
- 0x1e86, 0x1e86,
- 0x1e88, 0x1e88,
- 0x1e8a, 0x1e8a,
- 0x1e8c, 0x1e8c,
- 0x1e8e, 0x1e8e,
- 0x1e90, 0x1e90,
- 0x1e92, 0x1e92,
- 0x1e94, 0x1e94,
- 0x1ea0, 0x1ea0,
- 0x1ea2, 0x1ea2,
- 0x1ea4, 0x1ea4,
- 0x1ea6, 0x1ea6,
- 0x1ea8, 0x1ea8,
- 0x1eaa, 0x1eaa,
- 0x1eac, 0x1eac,
- 0x1eae, 0x1eae,
- 0x1eb0, 0x1eb0,
- 0x1eb2, 0x1eb2,
- 0x1eb4, 0x1eb4,
- 0x1eb6, 0x1eb6,
- 0x1eb8, 0x1eb8,
- 0x1eba, 0x1eba,
- 0x1ebc, 0x1ebc,
- 0x1ebe, 0x1ebe,
- 0x1ec0, 0x1ec0,
- 0x1ec2, 0x1ec2,
- 0x1ec4, 0x1ec4,
- 0x1ec6, 0x1ec6,
- 0x1ec8, 0x1ec8,
- 0x1eca, 0x1eca,
- 0x1ecc, 0x1ecc,
- 0x1ece, 0x1ece,
- 0x1ed0, 0x1ed0,
- 0x1ed2, 0x1ed2,
- 0x1ed4, 0x1ed4,
- 0x1ed6, 0x1ed6,
- 0x1ed8, 0x1ed8,
- 0x1eda, 0x1eda,
- 0x1edc, 0x1edc,
- 0x1ede, 0x1ede,
- 0x1ee0, 0x1ee0,
- 0x1ee2, 0x1ee2,
- 0x1ee4, 0x1ee4,
- 0x1ee6, 0x1ee6,
- 0x1ee8, 0x1ee8,
- 0x1eea, 0x1eea,
- 0x1eec, 0x1eec,
- 0x1eee, 0x1eee,
- 0x1ef0, 0x1ef0,
- 0x1ef2, 0x1ef2,
- 0x1ef4, 0x1ef4,
- 0x1ef6, 0x1ef6,
- 0x1ef8, 0x1ef8,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1fb8, 0x1fbb,
- 0x1fc8, 0x1fcb,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff8, 0x1ffb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210b, 0x210d,
- 0x2110, 0x2112,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x2130, 0x2131,
- 0x2133, 0x2133,
- 0x213e, 0x213f,
- 0x2145, 0x2145,
- 0x2c00, 0x2c2e,
- 0x2c80, 0x2c80,
- 0x2c82, 0x2c82,
- 0x2c84, 0x2c84,
- 0x2c86, 0x2c86,
- 0x2c88, 0x2c88,
- 0x2c8a, 0x2c8a,
- 0x2c8c, 0x2c8c,
- 0x2c8e, 0x2c8e,
- 0x2c90, 0x2c90,
- 0x2c92, 0x2c92,
- 0x2c94, 0x2c94,
- 0x2c96, 0x2c96,
- 0x2c98, 0x2c98,
- 0x2c9a, 0x2c9a,
- 0x2c9c, 0x2c9c,
- 0x2c9e, 0x2c9e,
- 0x2ca0, 0x2ca0,
- 0x2ca2, 0x2ca2,
- 0x2ca4, 0x2ca4,
- 0x2ca6, 0x2ca6,
- 0x2ca8, 0x2ca8,
- 0x2caa, 0x2caa,
- 0x2cac, 0x2cac,
- 0x2cae, 0x2cae,
- 0x2cb0, 0x2cb0,
- 0x2cb2, 0x2cb2,
- 0x2cb4, 0x2cb4,
- 0x2cb6, 0x2cb6,
- 0x2cb8, 0x2cb8,
- 0x2cba, 0x2cba,
- 0x2cbc, 0x2cbc,
- 0x2cbe, 0x2cbe,
- 0x2cc0, 0x2cc0,
- 0x2cc2, 0x2cc2,
- 0x2cc4, 0x2cc4,
- 0x2cc6, 0x2cc6,
- 0x2cc8, 0x2cc8,
- 0x2cca, 0x2cca,
- 0x2ccc, 0x2ccc,
- 0x2cce, 0x2cce,
- 0x2cd0, 0x2cd0,
- 0x2cd2, 0x2cd2,
- 0x2cd4, 0x2cd4,
- 0x2cd6, 0x2cd6,
- 0x2cd8, 0x2cd8,
- 0x2cda, 0x2cda,
- 0x2cdc, 0x2cdc,
- 0x2cde, 0x2cde,
- 0x2ce0, 0x2ce0,
- 0x2ce2, 0x2ce2,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x1d400, 0x1d419,
- 0x1d434, 0x1d44d,
- 0x1d468, 0x1d481,
- 0x1d49c, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b5,
- 0x1d4d0, 0x1d4e9,
- 0x1d504, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d538, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d56c, 0x1d585,
- 0x1d5a0, 0x1d5b9,
- 0x1d5d4, 0x1d5ed,
- 0x1d608, 0x1d621,
- 0x1d63c, 0x1d655,
- 0x1d670, 0x1d689,
- 0x1d6a8, 0x1d6c0,
- 0x1d6e2, 0x1d6fa,
- 0x1d71c, 0x1d734,
- 0x1d756, 0x1d76e,
- 0x1d790, 0x1d7a8
-}; /* CR_Upper */
-
-/* 'XDigit': [[:XDigit:]] */
-static const OnigCodePoint CR_XDigit[] = {
- 3,
- 0x0030, 0x0039,
- 0x0041, 0x0046,
- 0x0061, 0x0066
-}; /* CR_XDigit */
-
-/* 'Word': [[:Word:]] */
-static const OnigCodePoint CR_Word[] = {
- 464,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x005f, 0x005f,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b2, 0x00b3,
- 0x00b5, 0x00b5,
- 0x00b9, 0x00ba,
- 0x00bc, 0x00be,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0241,
- 0x0250, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ee, 0x02ee,
- 0x0300, 0x036f,
- 0x037a, 0x037a,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0561, 0x0587,
- 0x0591, 0x05b9,
- 0x05bb, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f2,
- 0x0610, 0x0615,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06de, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0963,
- 0x0966, 0x096f,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x09f4, 0x09f9,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b6f,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bf2,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f33,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1049,
- 0x1050, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x135f,
- 0x1369, 0x137c,
- 0x1380, 0x138f,
- 0x13a0, 0x13f4,
- 0x1401, 0x166c,
- 0x166f, 0x1676,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x180b, 0x180d,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x1a00, 0x1a1b,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x203f, 0x2040,
- 0x2054, 0x2054,
- 0x2070, 0x2071,
- 0x2074, 0x2079,
- 0x207f, 0x2089,
- 0x2090, 0x2094,
- 0x20d0, 0x20eb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x2153, 0x2183,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2ce4,
- 0x2cfd, 0x2cfd,
- 0x2d00, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3007,
- 0x3021, 0x302f,
- 0x3031, 0x3035,
- 0x3038, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3192, 0x3195,
- 0x31a0, 0x31b7,
- 0x31f0, 0x31ff,
- 0x3220, 0x3229,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa800, 0xa827,
- 0xac00, 0xd7a3,
- 0xf900, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff10, 0xff19,
- 0xff21, 0xff3a,
- 0xff3f, 0xff3f,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10107, 0x10133,
- 0x10140, 0x10178,
- 0x1018a, 0x1018a,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x103d1, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0xe0100, 0xe01ef
-}; /* CR_Word */
-
-/* 'Alnum': [[:Alnum:]] */
-static const OnigCodePoint CR_Alnum[] = {
- 436,
- 0x0030, 0x0039,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0241,
- 0x0250, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ee, 0x02ee,
- 0x0300, 0x036f,
- 0x037a, 0x037a,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03f5,
- 0x03f7, 0x0481,
- 0x0483, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0561, 0x0587,
- 0x0591, 0x05b9,
- 0x05bb, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f2,
- 0x0610, 0x0615,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x0669,
- 0x066e, 0x06d3,
- 0x06d5, 0x06dc,
- 0x06de, 0x06e8,
- 0x06ea, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0963,
- 0x0966, 0x096f,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09f1,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b6f,
- 0x0b71, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bef,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e4e,
- 0x0e50, 0x0e59,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f00,
- 0x0f18, 0x0f19,
- 0x0f20, 0x0f29,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1049,
- 0x1050, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x135f,
- 0x1380, 0x138f,
- 0x13a0, 0x13f4,
- 0x1401, 0x166c,
- 0x166f, 0x1676,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1734,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17b3,
- 0x17b6, 0x17d3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dd,
- 0x17e0, 0x17e9,
- 0x180b, 0x180d,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1946, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x1a00, 0x1a1b,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x2094,
- 0x20d0, 0x20eb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2ce4,
- 0x2d00, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3006,
- 0x302a, 0x302f,
- 0x3031, 0x3035,
- 0x303b, 0x303c,
- 0x3041, 0x3096,
- 0x3099, 0x309a,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x31a0, 0x31b7,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa800, 0xa827,
- 0xac00, 0xd7a3,
- 0xf900, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff10, 0xff19,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10300, 0x1031e,
- 0x10330, 0x10349,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0xe0100, 0xe01ef
-}; /* CR_Alnum */
-
-/* 'ASCII': [[:ASCII:]] */
-static const OnigCodePoint CR_ASCII[] = {
- 1,
- 0x0000, 0x007f
-}; /* CR_ASCII */
-
-#ifdef USE_UNICODE_PROPERTIES
-
-/* 'Any': - */
-static const OnigCodePoint CR_Any[] = {
- 1,
- 0x0000, 0x10ffff
-}; /* CR_Any */
-
-/* 'Assigned': - */
-static const OnigCodePoint CR_Assigned[] = {
- 420,
- 0x0000, 0x0241,
- 0x0250, 0x036f,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x037e, 0x037e,
- 0x0384, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x0589, 0x058a,
- 0x0591, 0x05b9,
- 0x05bb, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0x0600, 0x0603,
- 0x060b, 0x0615,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x0621, 0x063a,
- 0x0640, 0x065e,
- 0x0660, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x076d,
- 0x0780, 0x07b1,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0970,
- 0x097d, 0x097d,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4,
- 0x0e01, 0x0e3a,
- 0x0e3f, 0x0e5b,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fd1,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x13a0, 0x13f4,
- 0x1401, 0x1676,
- 0x1680, 0x169c,
- 0x16a0, 0x16f0,
- 0x1700, 0x170c,
- 0x170e, 0x1714,
- 0x1720, 0x1736,
- 0x1740, 0x1753,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x1a1b,
- 0x1a1e, 0x1a1f,
- 0x1d00, 0x1dc3,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2000, 0x2063,
- 0x206a, 0x2071,
- 0x2074, 0x208e,
- 0x2090, 0x2094,
- 0x20a0, 0x20b5,
- 0x20d0, 0x20eb,
- 0x2100, 0x214c,
- 0x2153, 0x2183,
- 0x2190, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27c6,
- 0x27d0, 0x27eb,
- 0x27f0, 0x2b13,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x303f,
- 0x3041, 0x3096,
- 0x3099, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x3190, 0x31b7,
- 0x31c0, 0x31cf,
- 0x31f0, 0x321e,
- 0x3220, 0x3243,
- 0x3250, 0x32fe,
- 0x3300, 0x4db5,
- 0x4dc0, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa800, 0xa82b,
- 0xac00, 0xd7a3,
- 0xd800, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3f,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfd,
- 0xfe00, 0xfe19,
- 0xfe20, 0xfe23,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xfeff, 0xfeff,
- 0xff01, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1018a,
- 0x10300, 0x1031e,
- 0x10320, 0x10323,
- 0x10330, 0x1034a,
- 0x10380, 0x1039d,
- 0x1039f, 0x103c3,
- 0x103c8, 0x103d5,
- 0x10400, 0x1049d,
- 0x104a0, 0x104a9,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d1dd,
- 0x1d200, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xe0100, 0xe01ef,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd
-}; /* CR_Assigned */
-
-/* 'C': Major Category */
-static const OnigCodePoint CR_C[] = {
- 422,
- 0x0000, 0x001f,
- 0x007f, 0x009f,
- 0x00ad, 0x00ad,
- 0x0242, 0x024f,
- 0x0370, 0x0373,
- 0x0376, 0x0379,
- 0x037b, 0x037d,
- 0x037f, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x03cf, 0x03cf,
- 0x0487, 0x0487,
- 0x04cf, 0x04cf,
- 0x04fa, 0x04ff,
- 0x0510, 0x0530,
- 0x0557, 0x0558,
- 0x0560, 0x0560,
- 0x0588, 0x0588,
- 0x058b, 0x0590,
- 0x05ba, 0x05ba,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ef,
- 0x05f5, 0x060a,
- 0x0616, 0x061a,
- 0x061c, 0x061d,
- 0x0620, 0x0620,
- 0x063b, 0x063f,
- 0x065f, 0x065f,
- 0x06dd, 0x06dd,
- 0x070e, 0x070f,
- 0x074b, 0x074c,
- 0x076e, 0x077f,
- 0x07b2, 0x0900,
- 0x093a, 0x093b,
- 0x094e, 0x094f,
- 0x0955, 0x0957,
- 0x0971, 0x097c,
- 0x097e, 0x0980,
- 0x0984, 0x0984,
- 0x098d, 0x098e,
- 0x0991, 0x0992,
- 0x09a9, 0x09a9,
- 0x09b1, 0x09b1,
- 0x09b3, 0x09b5,
- 0x09ba, 0x09bb,
- 0x09c5, 0x09c6,
- 0x09c9, 0x09ca,
- 0x09cf, 0x09d6,
- 0x09d8, 0x09db,
- 0x09de, 0x09de,
- 0x09e4, 0x09e5,
- 0x09fb, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a75, 0x0a80,
- 0x0a84, 0x0a84,
- 0x0a8e, 0x0a8e,
- 0x0a92, 0x0a92,
- 0x0aa9, 0x0aa9,
- 0x0ab1, 0x0ab1,
- 0x0ab4, 0x0ab4,
- 0x0aba, 0x0abb,
- 0x0ac6, 0x0ac6,
- 0x0aca, 0x0aca,
- 0x0ace, 0x0acf,
- 0x0ad1, 0x0adf,
- 0x0ae4, 0x0ae5,
- 0x0af0, 0x0af0,
- 0x0af2, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b44, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b55,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b62, 0x0b65,
- 0x0b72, 0x0b81,
- 0x0b84, 0x0b84,
- 0x0b8b, 0x0b8d,
- 0x0b91, 0x0b91,
- 0x0b96, 0x0b98,
- 0x0b9b, 0x0b9b,
- 0x0b9d, 0x0b9d,
- 0x0ba0, 0x0ba2,
- 0x0ba5, 0x0ba7,
- 0x0bab, 0x0bad,
- 0x0bba, 0x0bbd,
- 0x0bc3, 0x0bc5,
- 0x0bc9, 0x0bc9,
- 0x0bce, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c34, 0x0c34,
- 0x0c3a, 0x0c3d,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c5f,
- 0x0c62, 0x0c65,
- 0x0c70, 0x0c81,
- 0x0c84, 0x0c84,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdd,
- 0x0cdf, 0x0cdf,
- 0x0ce2, 0x0ce5,
- 0x0cf0, 0x0d01,
- 0x0d04, 0x0d04,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d29, 0x0d29,
- 0x0d3a, 0x0d3d,
- 0x0d44, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d4e, 0x0d56,
- 0x0d58, 0x0d5f,
- 0x0d62, 0x0d65,
- 0x0d70, 0x0d81,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e86,
- 0x0e89, 0x0e89,
- 0x0e8b, 0x0e8c,
- 0x0e8e, 0x0e93,
- 0x0e98, 0x0e98,
- 0x0ea0, 0x0ea0,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ea8, 0x0ea9,
- 0x0eac, 0x0eac,
- 0x0eba, 0x0eba,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ece, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ede, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6b, 0x0f70,
- 0x0f8c, 0x0f8f,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fce,
- 0x0fd2, 0x0fff,
- 0x1022, 0x1022,
- 0x1028, 0x1028,
- 0x102b, 0x102b,
- 0x1033, 0x1035,
- 0x103a, 0x103f,
- 0x105a, 0x109f,
- 0x10c6, 0x10cf,
- 0x10fd, 0x10ff,
- 0x115a, 0x115e,
- 0x11a3, 0x11a7,
- 0x11fa, 0x11ff,
- 0x1249, 0x1249,
- 0x124e, 0x124f,
- 0x1257, 0x1257,
- 0x1259, 0x1259,
- 0x125e, 0x125f,
- 0x1289, 0x1289,
- 0x128e, 0x128f,
- 0x12b1, 0x12b1,
- 0x12b6, 0x12b7,
- 0x12bf, 0x12bf,
- 0x12c1, 0x12c1,
- 0x12c6, 0x12c7,
- 0x12d7, 0x12d7,
- 0x1311, 0x1311,
- 0x1316, 0x1317,
- 0x135b, 0x135e,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f5, 0x1400,
- 0x1677, 0x167f,
- 0x169d, 0x169f,
- 0x16f1, 0x16ff,
- 0x170d, 0x170d,
- 0x1715, 0x171f,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17b4, 0x17b5,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x180f, 0x180f,
- 0x181a, 0x181f,
- 0x1878, 0x187f,
- 0x18aa, 0x18ff,
- 0x191d, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19aa, 0x19af,
- 0x19ca, 0x19cf,
- 0x19da, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a20, 0x1cff,
- 0x1dc4, 0x1dff,
- 0x1e9c, 0x1e9f,
- 0x1efa, 0x1eff,
- 0x1f16, 0x1f17,
- 0x1f1e, 0x1f1f,
- 0x1f46, 0x1f47,
- 0x1f4e, 0x1f4f,
- 0x1f58, 0x1f58,
- 0x1f5a, 0x1f5a,
- 0x1f5c, 0x1f5c,
- 0x1f5e, 0x1f5e,
- 0x1f7e, 0x1f7f,
- 0x1fb5, 0x1fb5,
- 0x1fc5, 0x1fc5,
- 0x1fd4, 0x1fd5,
- 0x1fdc, 0x1fdc,
- 0x1ff0, 0x1ff1,
- 0x1ff5, 0x1ff5,
- 0x1fff, 0x1fff,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x206f,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x2095, 0x209f,
- 0x20b6, 0x20cf,
- 0x20ec, 0x20ff,
- 0x214d, 0x2152,
- 0x2184, 0x218f,
- 0x23dc, 0x23ff,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x269d, 0x269f,
- 0x26b2, 0x2700,
- 0x2705, 0x2705,
- 0x270a, 0x270b,
- 0x2728, 0x2728,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x275f, 0x2760,
- 0x2795, 0x2797,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x27c7, 0x27cf,
- 0x27ec, 0x27ef,
- 0x2b14, 0x2bff,
- 0x2c2f, 0x2c2f,
- 0x2c5f, 0x2c7f,
- 0x2ceb, 0x2cf8,
- 0x2d26, 0x2d2f,
- 0x2d66, 0x2d6e,
- 0x2d70, 0x2d7f,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2dff,
- 0x2e18, 0x2e1b,
- 0x2e1e, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x312d, 0x3130,
- 0x318f, 0x318f,
- 0x31b8, 0x31bf,
- 0x31d0, 0x31ef,
- 0x321f, 0x321f,
- 0x3244, 0x324f,
- 0x32ff, 0x32ff,
- 0x4db6, 0x4dbf,
- 0x9fbc, 0x9fff,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa6ff,
- 0xa717, 0xa7ff,
- 0xa82c, 0xabff,
- 0xd7a4, 0xf8ff,
- 0xfa2e, 0xfa2f,
- 0xfa6b, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbb2, 0xfbd2,
- 0xfd40, 0xfd4f,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdef,
- 0xfdfe, 0xfdff,
- 0xfe1a, 0xfe1f,
- 0xfe24, 0xfe2f,
- 0xfe53, 0xfe53,
- 0xfe67, 0xfe67,
- 0xfe6c, 0xfe6f,
- 0xfe75, 0xfe75,
- 0xfefd, 0xff00,
- 0xffbf, 0xffc1,
- 0xffc8, 0xffc9,
- 0xffd0, 0xffd1,
- 0xffd8, 0xffd9,
- 0xffdd, 0xffdf,
- 0xffe7, 0xffe7,
- 0xffef, 0xfffb,
- 0xfffe, 0xffff,
- 0x1000c, 0x1000c,
- 0x10027, 0x10027,
- 0x1003b, 0x1003b,
- 0x1003e, 0x1003e,
- 0x1004e, 0x1004f,
- 0x1005e, 0x1007f,
- 0x100fb, 0x100ff,
- 0x10103, 0x10106,
- 0x10134, 0x10136,
- 0x1018b, 0x102ff,
- 0x1031f, 0x1031f,
- 0x10324, 0x1032f,
- 0x1034b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10840, 0x109ff,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a34, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a48, 0x10a4f,
- 0x10a59, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d129,
- 0x1d173, 0x1d17a,
- 0x1d1de, 0x1d1ff,
- 0x1d246, 0x1d2ff,
- 0x1d357, 0x1d3ff,
- 0x1d455, 0x1d455,
- 0x1d49d, 0x1d49d,
- 0x1d4a0, 0x1d4a1,
- 0x1d4a3, 0x1d4a4,
- 0x1d4a7, 0x1d4a8,
- 0x1d4ad, 0x1d4ad,
- 0x1d4ba, 0x1d4ba,
- 0x1d4bc, 0x1d4bc,
- 0x1d4c4, 0x1d4c4,
- 0x1d506, 0x1d506,
- 0x1d50b, 0x1d50c,
- 0x1d515, 0x1d515,
- 0x1d51d, 0x1d51d,
- 0x1d53a, 0x1d53a,
- 0x1d53f, 0x1d53f,
- 0x1d545, 0x1d545,
- 0x1d547, 0x1d549,
- 0x1d551, 0x1d551,
- 0x1d6a6, 0x1d6a7,
- 0x1d7ca, 0x1d7cd,
- 0x1d800, 0x1ffff,
- 0x2a6d7, 0x2f7ff,
- 0x2fa1e, 0xe00ff,
- 0xe01f0, 0x10ffff
-}; /* CR_C */
-
-/* 'Cc': General Category */
-static const OnigCodePoint CR_Cc[] = {
- 2,
- 0x0000, 0x001f,
- 0x007f, 0x009f
-}; /* CR_Cc */
-
-/* 'Cf': General Category */
-static const OnigCodePoint CR_Cf[] = {
- 14,
- 0x00ad, 0x00ad,
- 0x0600, 0x0603,
- 0x06dd, 0x06dd,
- 0x070f, 0x070f,
- 0x17b4, 0x17b5,
- 0x200b, 0x200f,
- 0x202a, 0x202e,
- 0x2060, 0x2063,
- 0x206a, 0x206f,
- 0xfeff, 0xfeff,
- 0xfff9, 0xfffb,
- 0x1d173, 0x1d17a,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f
-}; /* CR_Cf */
-
-/* 'Cn': General Category */
-static const OnigCodePoint CR_Cn[] = {
- 420,
- 0x0242, 0x024f,
- 0x0370, 0x0373,
- 0x0376, 0x0379,
- 0x037b, 0x037d,
- 0x037f, 0x0383,
- 0x038b, 0x038b,
- 0x038d, 0x038d,
- 0x03a2, 0x03a2,
- 0x03cf, 0x03cf,
- 0x0487, 0x0487,
- 0x04cf, 0x04cf,
- 0x04fa, 0x04ff,
- 0x0510, 0x0530,
- 0x0557, 0x0558,
- 0x0560, 0x0560,
- 0x0588, 0x0588,
- 0x058b, 0x0590,
- 0x05ba, 0x05ba,
- 0x05c8, 0x05cf,
- 0x05eb, 0x05ef,
- 0x05f5, 0x05ff,
- 0x0604, 0x060a,
- 0x0616, 0x061a,
- 0x061c, 0x061d,
- 0x0620, 0x0620,
- 0x063b, 0x063f,
- 0x065f, 0x065f,
- 0x070e, 0x070e,
- 0x074b, 0x074c,
- 0x076e, 0x077f,
- 0x07b2, 0x0900,
- 0x093a, 0x093b,
- 0x094e, 0x094f,
- 0x0955, 0x0957,
- 0x0971, 0x097c,
- 0x097e, 0x0980,
- 0x0984, 0x0984,
- 0x098d, 0x098e,
- 0x0991, 0x0992,
- 0x09a9, 0x09a9,
- 0x09b1, 0x09b1,
- 0x09b3, 0x09b5,
- 0x09ba, 0x09bb,
- 0x09c5, 0x09c6,
- 0x09c9, 0x09ca,
- 0x09cf, 0x09d6,
- 0x09d8, 0x09db,
- 0x09de, 0x09de,
- 0x09e4, 0x09e5,
- 0x09fb, 0x0a00,
- 0x0a04, 0x0a04,
- 0x0a0b, 0x0a0e,
- 0x0a11, 0x0a12,
- 0x0a29, 0x0a29,
- 0x0a31, 0x0a31,
- 0x0a34, 0x0a34,
- 0x0a37, 0x0a37,
- 0x0a3a, 0x0a3b,
- 0x0a3d, 0x0a3d,
- 0x0a43, 0x0a46,
- 0x0a49, 0x0a4a,
- 0x0a4e, 0x0a58,
- 0x0a5d, 0x0a5d,
- 0x0a5f, 0x0a65,
- 0x0a75, 0x0a80,
- 0x0a84, 0x0a84,
- 0x0a8e, 0x0a8e,
- 0x0a92, 0x0a92,
- 0x0aa9, 0x0aa9,
- 0x0ab1, 0x0ab1,
- 0x0ab4, 0x0ab4,
- 0x0aba, 0x0abb,
- 0x0ac6, 0x0ac6,
- 0x0aca, 0x0aca,
- 0x0ace, 0x0acf,
- 0x0ad1, 0x0adf,
- 0x0ae4, 0x0ae5,
- 0x0af0, 0x0af0,
- 0x0af2, 0x0b00,
- 0x0b04, 0x0b04,
- 0x0b0d, 0x0b0e,
- 0x0b11, 0x0b12,
- 0x0b29, 0x0b29,
- 0x0b31, 0x0b31,
- 0x0b34, 0x0b34,
- 0x0b3a, 0x0b3b,
- 0x0b44, 0x0b46,
- 0x0b49, 0x0b4a,
- 0x0b4e, 0x0b55,
- 0x0b58, 0x0b5b,
- 0x0b5e, 0x0b5e,
- 0x0b62, 0x0b65,
- 0x0b72, 0x0b81,
- 0x0b84, 0x0b84,
- 0x0b8b, 0x0b8d,
- 0x0b91, 0x0b91,
- 0x0b96, 0x0b98,
- 0x0b9b, 0x0b9b,
- 0x0b9d, 0x0b9d,
- 0x0ba0, 0x0ba2,
- 0x0ba5, 0x0ba7,
- 0x0bab, 0x0bad,
- 0x0bba, 0x0bbd,
- 0x0bc3, 0x0bc5,
- 0x0bc9, 0x0bc9,
- 0x0bce, 0x0bd6,
- 0x0bd8, 0x0be5,
- 0x0bfb, 0x0c00,
- 0x0c04, 0x0c04,
- 0x0c0d, 0x0c0d,
- 0x0c11, 0x0c11,
- 0x0c29, 0x0c29,
- 0x0c34, 0x0c34,
- 0x0c3a, 0x0c3d,
- 0x0c45, 0x0c45,
- 0x0c49, 0x0c49,
- 0x0c4e, 0x0c54,
- 0x0c57, 0x0c5f,
- 0x0c62, 0x0c65,
- 0x0c70, 0x0c81,
- 0x0c84, 0x0c84,
- 0x0c8d, 0x0c8d,
- 0x0c91, 0x0c91,
- 0x0ca9, 0x0ca9,
- 0x0cb4, 0x0cb4,
- 0x0cba, 0x0cbb,
- 0x0cc5, 0x0cc5,
- 0x0cc9, 0x0cc9,
- 0x0cce, 0x0cd4,
- 0x0cd7, 0x0cdd,
- 0x0cdf, 0x0cdf,
- 0x0ce2, 0x0ce5,
- 0x0cf0, 0x0d01,
- 0x0d04, 0x0d04,
- 0x0d0d, 0x0d0d,
- 0x0d11, 0x0d11,
- 0x0d29, 0x0d29,
- 0x0d3a, 0x0d3d,
- 0x0d44, 0x0d45,
- 0x0d49, 0x0d49,
- 0x0d4e, 0x0d56,
- 0x0d58, 0x0d5f,
- 0x0d62, 0x0d65,
- 0x0d70, 0x0d81,
- 0x0d84, 0x0d84,
- 0x0d97, 0x0d99,
- 0x0db2, 0x0db2,
- 0x0dbc, 0x0dbc,
- 0x0dbe, 0x0dbf,
- 0x0dc7, 0x0dc9,
- 0x0dcb, 0x0dce,
- 0x0dd5, 0x0dd5,
- 0x0dd7, 0x0dd7,
- 0x0de0, 0x0df1,
- 0x0df5, 0x0e00,
- 0x0e3b, 0x0e3e,
- 0x0e5c, 0x0e80,
- 0x0e83, 0x0e83,
- 0x0e85, 0x0e86,
- 0x0e89, 0x0e89,
- 0x0e8b, 0x0e8c,
- 0x0e8e, 0x0e93,
- 0x0e98, 0x0e98,
- 0x0ea0, 0x0ea0,
- 0x0ea4, 0x0ea4,
- 0x0ea6, 0x0ea6,
- 0x0ea8, 0x0ea9,
- 0x0eac, 0x0eac,
- 0x0eba, 0x0eba,
- 0x0ebe, 0x0ebf,
- 0x0ec5, 0x0ec5,
- 0x0ec7, 0x0ec7,
- 0x0ece, 0x0ecf,
- 0x0eda, 0x0edb,
- 0x0ede, 0x0eff,
- 0x0f48, 0x0f48,
- 0x0f6b, 0x0f70,
- 0x0f8c, 0x0f8f,
- 0x0f98, 0x0f98,
- 0x0fbd, 0x0fbd,
- 0x0fcd, 0x0fce,
- 0x0fd2, 0x0fff,
- 0x1022, 0x1022,
- 0x1028, 0x1028,
- 0x102b, 0x102b,
- 0x1033, 0x1035,
- 0x103a, 0x103f,
- 0x105a, 0x109f,
- 0x10c6, 0x10cf,
- 0x10fd, 0x10ff,
- 0x115a, 0x115e,
- 0x11a3, 0x11a7,
- 0x11fa, 0x11ff,
- 0x1249, 0x1249,
- 0x124e, 0x124f,
- 0x1257, 0x1257,
- 0x1259, 0x1259,
- 0x125e, 0x125f,
- 0x1289, 0x1289,
- 0x128e, 0x128f,
- 0x12b1, 0x12b1,
- 0x12b6, 0x12b7,
- 0x12bf, 0x12bf,
- 0x12c1, 0x12c1,
- 0x12c6, 0x12c7,
- 0x12d7, 0x12d7,
- 0x1311, 0x1311,
- 0x1316, 0x1317,
- 0x135b, 0x135e,
- 0x137d, 0x137f,
- 0x139a, 0x139f,
- 0x13f5, 0x1400,
- 0x1677, 0x167f,
- 0x169d, 0x169f,
- 0x16f1, 0x16ff,
- 0x170d, 0x170d,
- 0x1715, 0x171f,
- 0x1737, 0x173f,
- 0x1754, 0x175f,
- 0x176d, 0x176d,
- 0x1771, 0x1771,
- 0x1774, 0x177f,
- 0x17de, 0x17df,
- 0x17ea, 0x17ef,
- 0x17fa, 0x17ff,
- 0x180f, 0x180f,
- 0x181a, 0x181f,
- 0x1878, 0x187f,
- 0x18aa, 0x18ff,
- 0x191d, 0x191f,
- 0x192c, 0x192f,
- 0x193c, 0x193f,
- 0x1941, 0x1943,
- 0x196e, 0x196f,
- 0x1975, 0x197f,
- 0x19aa, 0x19af,
- 0x19ca, 0x19cf,
- 0x19da, 0x19dd,
- 0x1a1c, 0x1a1d,
- 0x1a20, 0x1cff,
- 0x1dc4, 0x1dff,
- 0x1e9c, 0x1e9f,
- 0x1efa, 0x1eff,
- 0x1f16, 0x1f17,
- 0x1f1e, 0x1f1f,
- 0x1f46, 0x1f47,
- 0x1f4e, 0x1f4f,
- 0x1f58, 0x1f58,
- 0x1f5a, 0x1f5a,
- 0x1f5c, 0x1f5c,
- 0x1f5e, 0x1f5e,
- 0x1f7e, 0x1f7f,
- 0x1fb5, 0x1fb5,
- 0x1fc5, 0x1fc5,
- 0x1fd4, 0x1fd5,
- 0x1fdc, 0x1fdc,
- 0x1ff0, 0x1ff1,
- 0x1ff5, 0x1ff5,
- 0x1fff, 0x1fff,
- 0x2064, 0x2069,
- 0x2072, 0x2073,
- 0x208f, 0x208f,
- 0x2095, 0x209f,
- 0x20b6, 0x20cf,
- 0x20ec, 0x20ff,
- 0x214d, 0x2152,
- 0x2184, 0x218f,
- 0x23dc, 0x23ff,
- 0x2427, 0x243f,
- 0x244b, 0x245f,
- 0x269d, 0x269f,
- 0x26b2, 0x2700,
- 0x2705, 0x2705,
- 0x270a, 0x270b,
- 0x2728, 0x2728,
- 0x274c, 0x274c,
- 0x274e, 0x274e,
- 0x2753, 0x2755,
- 0x2757, 0x2757,
- 0x275f, 0x2760,
- 0x2795, 0x2797,
- 0x27b0, 0x27b0,
- 0x27bf, 0x27bf,
- 0x27c7, 0x27cf,
- 0x27ec, 0x27ef,
- 0x2b14, 0x2bff,
- 0x2c2f, 0x2c2f,
- 0x2c5f, 0x2c7f,
- 0x2ceb, 0x2cf8,
- 0x2d26, 0x2d2f,
- 0x2d66, 0x2d6e,
- 0x2d70, 0x2d7f,
- 0x2d97, 0x2d9f,
- 0x2da7, 0x2da7,
- 0x2daf, 0x2daf,
- 0x2db7, 0x2db7,
- 0x2dbf, 0x2dbf,
- 0x2dc7, 0x2dc7,
- 0x2dcf, 0x2dcf,
- 0x2dd7, 0x2dd7,
- 0x2ddf, 0x2dff,
- 0x2e18, 0x2e1b,
- 0x2e1e, 0x2e7f,
- 0x2e9a, 0x2e9a,
- 0x2ef4, 0x2eff,
- 0x2fd6, 0x2fef,
- 0x2ffc, 0x2fff,
- 0x3040, 0x3040,
- 0x3097, 0x3098,
- 0x3100, 0x3104,
- 0x312d, 0x3130,
- 0x318f, 0x318f,
- 0x31b8, 0x31bf,
- 0x31d0, 0x31ef,
- 0x321f, 0x321f,
- 0x3244, 0x324f,
- 0x32ff, 0x32ff,
- 0x4db6, 0x4dbf,
- 0x9fbc, 0x9fff,
- 0xa48d, 0xa48f,
- 0xa4c7, 0xa6ff,
- 0xa717, 0xa7ff,
- 0xa82c, 0xabff,
- 0xd7a4, 0xd7ff,
- 0xfa2e, 0xfa2f,
- 0xfa6b, 0xfa6f,
- 0xfada, 0xfaff,
- 0xfb07, 0xfb12,
- 0xfb18, 0xfb1c,
- 0xfb37, 0xfb37,
- 0xfb3d, 0xfb3d,
- 0xfb3f, 0xfb3f,
- 0xfb42, 0xfb42,
- 0xfb45, 0xfb45,
- 0xfbb2, 0xfbd2,
- 0xfd40, 0xfd4f,
- 0xfd90, 0xfd91,
- 0xfdc8, 0xfdef,
- 0xfdfe, 0xfdff,
- 0xfe1a, 0xfe1f,
- 0xfe24, 0xfe2f,
- 0xfe53, 0xfe53,
- 0xfe67, 0xfe67,
- 0xfe6c, 0xfe6f,
- 0xfe75, 0xfe75,
- 0xfefd, 0xfefe,
- 0xff00, 0xff00,
- 0xffbf, 0xffc1,
- 0xffc8, 0xffc9,
- 0xffd0, 0xffd1,
- 0xffd8, 0xffd9,
- 0xffdd, 0xffdf,
- 0xffe7, 0xffe7,
- 0xffef, 0xfff8,
- 0xfffe, 0xffff,
- 0x1000c, 0x1000c,
- 0x10027, 0x10027,
- 0x1003b, 0x1003b,
- 0x1003e, 0x1003e,
- 0x1004e, 0x1004f,
- 0x1005e, 0x1007f,
- 0x100fb, 0x100ff,
- 0x10103, 0x10106,
- 0x10134, 0x10136,
- 0x1018b, 0x102ff,
- 0x1031f, 0x1031f,
- 0x10324, 0x1032f,
- 0x1034b, 0x1037f,
- 0x1039e, 0x1039e,
- 0x103c4, 0x103c7,
- 0x103d6, 0x103ff,
- 0x1049e, 0x1049f,
- 0x104aa, 0x107ff,
- 0x10806, 0x10807,
- 0x10809, 0x10809,
- 0x10836, 0x10836,
- 0x10839, 0x1083b,
- 0x1083d, 0x1083e,
- 0x10840, 0x109ff,
- 0x10a04, 0x10a04,
- 0x10a07, 0x10a0b,
- 0x10a14, 0x10a14,
- 0x10a18, 0x10a18,
- 0x10a34, 0x10a37,
- 0x10a3b, 0x10a3e,
- 0x10a48, 0x10a4f,
- 0x10a59, 0x1cfff,
- 0x1d0f6, 0x1d0ff,
- 0x1d127, 0x1d129,
- 0x1d1de, 0x1d1ff,
- 0x1d246, 0x1d2ff,
- 0x1d357, 0x1d3ff,
- 0x1d455, 0x1d455,
- 0x1d49d, 0x1d49d,
- 0x1d4a0, 0x1d4a1,
- 0x1d4a3, 0x1d4a4,
- 0x1d4a7, 0x1d4a8,
- 0x1d4ad, 0x1d4ad,
- 0x1d4ba, 0x1d4ba,
- 0x1d4bc, 0x1d4bc,
- 0x1d4c4, 0x1d4c4,
- 0x1d506, 0x1d506,
- 0x1d50b, 0x1d50c,
- 0x1d515, 0x1d515,
- 0x1d51d, 0x1d51d,
- 0x1d53a, 0x1d53a,
- 0x1d53f, 0x1d53f,
- 0x1d545, 0x1d545,
- 0x1d547, 0x1d549,
- 0x1d551, 0x1d551,
- 0x1d6a6, 0x1d6a7,
- 0x1d7ca, 0x1d7cd,
- 0x1d800, 0x1ffff,
- 0x2a6d7, 0x2f7ff,
- 0x2fa1e, 0xe0000,
- 0xe0002, 0xe001f,
- 0xe0080, 0xe00ff,
- 0xe01f0, 0xeffff,
- 0xffffe, 0xfffff,
- 0x10fffe, 0x10ffff
-}; /* CR_Cn */
-
-/* 'Co': General Category */
-static const OnigCodePoint CR_Co[] = {
- 3,
- 0xe000, 0xf8ff,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd
-}; /* CR_Co */
-
-/* 'Cs': General Category */
-static const OnigCodePoint CR_Cs[] = {
- 1,
- 0xd800, 0xdfff
-}; /* CR_Cs */
-
-/* 'L': Major Category */
-static const OnigCodePoint CR_L[] = {
- 347,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0241,
- 0x0250, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ee, 0x02ee,
- 0x037a, 0x037a,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03f5,
- 0x03f7, 0x0481,
- 0x048a, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x0531, 0x0556,
- 0x0559, 0x0559,
- 0x0561, 0x0587,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f2,
- 0x0621, 0x063a,
- 0x0640, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06e5, 0x06e6,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x076d,
- 0x0780, 0x07a5,
- 0x07b1, 0x07b1,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x097d, 0x097d,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a72, 0x0a74,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0abd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c60, 0x0c61,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d60, 0x0d61,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e46,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f88, 0x0f8b,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x1050, 0x1055,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10fc,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f4,
- 0x1401, 0x166c,
- 0x166f, 0x1676,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17d7, 0x17d7,
- 0x17dc, 0x17dc,
- 0x1820, 0x1877,
- 0x1880, 0x18a8,
- 0x1900, 0x191c,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19c1, 0x19c7,
- 0x1a00, 0x1a16,
- 0x1d00, 0x1dbf,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fbc,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fcc,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fe0, 0x1fec,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffc,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x2094,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210a, 0x2113,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x212f, 0x2131,
- 0x2133, 0x2139,
- 0x213c, 0x213f,
- 0x2145, 0x2149,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e,
- 0x2c80, 0x2ce4,
- 0x2d00, 0x2d25,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3005, 0x3006,
- 0x3031, 0x3035,
- 0x303b, 0x303c,
- 0x3041, 0x3096,
- 0x309d, 0x309f,
- 0x30a1, 0x30fa,
- 0x30fc, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x31a0, 0x31b7,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fbb,
- 0xa000, 0xa48c,
- 0xa800, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xac00, 0xd7a3,
- 0xf900, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a,
- 0xff66, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10300, 0x1031e,
- 0x10330, 0x10349,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10400, 0x1049d,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d6c0,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6fa,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d734,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d76e,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d7a8,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d
-}; /* CR_L */
-
-/* 'Ll': General Category */
-static const OnigCodePoint CR_Ll[] = {
- 480,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00b5, 0x00b5,
- 0x00ba, 0x00ba,
- 0x00df, 0x00f6,
- 0x00f8, 0x00ff,
- 0x0101, 0x0101,
- 0x0103, 0x0103,
- 0x0105, 0x0105,
- 0x0107, 0x0107,
- 0x0109, 0x0109,
- 0x010b, 0x010b,
- 0x010d, 0x010d,
- 0x010f, 0x010f,
- 0x0111, 0x0111,
- 0x0113, 0x0113,
- 0x0115, 0x0115,
- 0x0117, 0x0117,
- 0x0119, 0x0119,
- 0x011b, 0x011b,
- 0x011d, 0x011d,
- 0x011f, 0x011f,
- 0x0121, 0x0121,
- 0x0123, 0x0123,
- 0x0125, 0x0125,
- 0x0127, 0x0127,
- 0x0129, 0x0129,
- 0x012b, 0x012b,
- 0x012d, 0x012d,
- 0x012f, 0x012f,
- 0x0131, 0x0131,
- 0x0133, 0x0133,
- 0x0135, 0x0135,
- 0x0137, 0x0138,
- 0x013a, 0x013a,
- 0x013c, 0x013c,
- 0x013e, 0x013e,
- 0x0140, 0x0140,
- 0x0142, 0x0142,
- 0x0144, 0x0144,
- 0x0146, 0x0146,
- 0x0148, 0x0149,
- 0x014b, 0x014b,
- 0x014d, 0x014d,
- 0x014f, 0x014f,
- 0x0151, 0x0151,
- 0x0153, 0x0153,
- 0x0155, 0x0155,
- 0x0157, 0x0157,
- 0x0159, 0x0159,
- 0x015b, 0x015b,
- 0x015d, 0x015d,
- 0x015f, 0x015f,
- 0x0161, 0x0161,
- 0x0163, 0x0163,
- 0x0165, 0x0165,
- 0x0167, 0x0167,
- 0x0169, 0x0169,
- 0x016b, 0x016b,
- 0x016d, 0x016d,
- 0x016f, 0x016f,
- 0x0171, 0x0171,
- 0x0173, 0x0173,
- 0x0175, 0x0175,
- 0x0177, 0x0177,
- 0x017a, 0x017a,
- 0x017c, 0x017c,
- 0x017e, 0x0180,
- 0x0183, 0x0183,
- 0x0185, 0x0185,
- 0x0188, 0x0188,
- 0x018c, 0x018d,
- 0x0192, 0x0192,
- 0x0195, 0x0195,
- 0x0199, 0x019b,
- 0x019e, 0x019e,
- 0x01a1, 0x01a1,
- 0x01a3, 0x01a3,
- 0x01a5, 0x01a5,
- 0x01a8, 0x01a8,
- 0x01aa, 0x01ab,
- 0x01ad, 0x01ad,
- 0x01b0, 0x01b0,
- 0x01b4, 0x01b4,
- 0x01b6, 0x01b6,
- 0x01b9, 0x01ba,
- 0x01bd, 0x01bf,
- 0x01c6, 0x01c6,
- 0x01c9, 0x01c9,
- 0x01cc, 0x01cc,
- 0x01ce, 0x01ce,
- 0x01d0, 0x01d0,
- 0x01d2, 0x01d2,
- 0x01d4, 0x01d4,
- 0x01d6, 0x01d6,
- 0x01d8, 0x01d8,
- 0x01da, 0x01da,
- 0x01dc, 0x01dd,
- 0x01df, 0x01df,
- 0x01e1, 0x01e1,
- 0x01e3, 0x01e3,
- 0x01e5, 0x01e5,
- 0x01e7, 0x01e7,
- 0x01e9, 0x01e9,
- 0x01eb, 0x01eb,
- 0x01ed, 0x01ed,
- 0x01ef, 0x01f0,
- 0x01f3, 0x01f3,
- 0x01f5, 0x01f5,
- 0x01f9, 0x01f9,
- 0x01fb, 0x01fb,
- 0x01fd, 0x01fd,
- 0x01ff, 0x01ff,
- 0x0201, 0x0201,
- 0x0203, 0x0203,
- 0x0205, 0x0205,
- 0x0207, 0x0207,
- 0x0209, 0x0209,
- 0x020b, 0x020b,
- 0x020d, 0x020d,
- 0x020f, 0x020f,
- 0x0211, 0x0211,
- 0x0213, 0x0213,
- 0x0215, 0x0215,
- 0x0217, 0x0217,
- 0x0219, 0x0219,
- 0x021b, 0x021b,
- 0x021d, 0x021d,
- 0x021f, 0x021f,
- 0x0221, 0x0221,
- 0x0223, 0x0223,
- 0x0225, 0x0225,
- 0x0227, 0x0227,
- 0x0229, 0x0229,
- 0x022b, 0x022b,
- 0x022d, 0x022d,
- 0x022f, 0x022f,
- 0x0231, 0x0231,
- 0x0233, 0x0239,
- 0x023c, 0x023c,
- 0x023f, 0x0240,
- 0x0250, 0x02af,
- 0x0390, 0x0390,
- 0x03ac, 0x03ce,
- 0x03d0, 0x03d1,
- 0x03d5, 0x03d7,
- 0x03d9, 0x03d9,
- 0x03db, 0x03db,
- 0x03dd, 0x03dd,
- 0x03df, 0x03df,
- 0x03e1, 0x03e1,
- 0x03e3, 0x03e3,
- 0x03e5, 0x03e5,
- 0x03e7, 0x03e7,
- 0x03e9, 0x03e9,
- 0x03eb, 0x03eb,
- 0x03ed, 0x03ed,
- 0x03ef, 0x03f3,
- 0x03f5, 0x03f5,
- 0x03f8, 0x03f8,
- 0x03fb, 0x03fc,
- 0x0430, 0x045f,
- 0x0461, 0x0461,
- 0x0463, 0x0463,
- 0x0465, 0x0465,
- 0x0467, 0x0467,
- 0x0469, 0x0469,
- 0x046b, 0x046b,
- 0x046d, 0x046d,
- 0x046f, 0x046f,
- 0x0471, 0x0471,
- 0x0473, 0x0473,
- 0x0475, 0x0475,
- 0x0477, 0x0477,
- 0x0479, 0x0479,
- 0x047b, 0x047b,
- 0x047d, 0x047d,
- 0x047f, 0x047f,
- 0x0481, 0x0481,
- 0x048b, 0x048b,
- 0x048d, 0x048d,
- 0x048f, 0x048f,
- 0x0491, 0x0491,
- 0x0493, 0x0493,
- 0x0495, 0x0495,
- 0x0497, 0x0497,
- 0x0499, 0x0499,
- 0x049b, 0x049b,
- 0x049d, 0x049d,
- 0x049f, 0x049f,
- 0x04a1, 0x04a1,
- 0x04a3, 0x04a3,
- 0x04a5, 0x04a5,
- 0x04a7, 0x04a7,
- 0x04a9, 0x04a9,
- 0x04ab, 0x04ab,
- 0x04ad, 0x04ad,
- 0x04af, 0x04af,
- 0x04b1, 0x04b1,
- 0x04b3, 0x04b3,
- 0x04b5, 0x04b5,
- 0x04b7, 0x04b7,
- 0x04b9, 0x04b9,
- 0x04bb, 0x04bb,
- 0x04bd, 0x04bd,
- 0x04bf, 0x04bf,
- 0x04c2, 0x04c2,
- 0x04c4, 0x04c4,
- 0x04c6, 0x04c6,
- 0x04c8, 0x04c8,
- 0x04ca, 0x04ca,
- 0x04cc, 0x04cc,
- 0x04ce, 0x04ce,
- 0x04d1, 0x04d1,
- 0x04d3, 0x04d3,
- 0x04d5, 0x04d5,
- 0x04d7, 0x04d7,
- 0x04d9, 0x04d9,
- 0x04db, 0x04db,
- 0x04dd, 0x04dd,
- 0x04df, 0x04df,
- 0x04e1, 0x04e1,
- 0x04e3, 0x04e3,
- 0x04e5, 0x04e5,
- 0x04e7, 0x04e7,
- 0x04e9, 0x04e9,
- 0x04eb, 0x04eb,
- 0x04ed, 0x04ed,
- 0x04ef, 0x04ef,
- 0x04f1, 0x04f1,
- 0x04f3, 0x04f3,
- 0x04f5, 0x04f5,
- 0x04f7, 0x04f7,
- 0x04f9, 0x04f9,
- 0x0501, 0x0501,
- 0x0503, 0x0503,
- 0x0505, 0x0505,
- 0x0507, 0x0507,
- 0x0509, 0x0509,
- 0x050b, 0x050b,
- 0x050d, 0x050d,
- 0x050f, 0x050f,
- 0x0561, 0x0587,
- 0x1d00, 0x1d2b,
- 0x1d62, 0x1d77,
- 0x1d79, 0x1d9a,
- 0x1e01, 0x1e01,
- 0x1e03, 0x1e03,
- 0x1e05, 0x1e05,
- 0x1e07, 0x1e07,
- 0x1e09, 0x1e09,
- 0x1e0b, 0x1e0b,
- 0x1e0d, 0x1e0d,
- 0x1e0f, 0x1e0f,
- 0x1e11, 0x1e11,
- 0x1e13, 0x1e13,
- 0x1e15, 0x1e15,
- 0x1e17, 0x1e17,
- 0x1e19, 0x1e19,
- 0x1e1b, 0x1e1b,
- 0x1e1d, 0x1e1d,
- 0x1e1f, 0x1e1f,
- 0x1e21, 0x1e21,
- 0x1e23, 0x1e23,
- 0x1e25, 0x1e25,
- 0x1e27, 0x1e27,
- 0x1e29, 0x1e29,
- 0x1e2b, 0x1e2b,
- 0x1e2d, 0x1e2d,
- 0x1e2f, 0x1e2f,
- 0x1e31, 0x1e31,
- 0x1e33, 0x1e33,
- 0x1e35, 0x1e35,
- 0x1e37, 0x1e37,
- 0x1e39, 0x1e39,
- 0x1e3b, 0x1e3b,
- 0x1e3d, 0x1e3d,
- 0x1e3f, 0x1e3f,
- 0x1e41, 0x1e41,
- 0x1e43, 0x1e43,
- 0x1e45, 0x1e45,
- 0x1e47, 0x1e47,
- 0x1e49, 0x1e49,
- 0x1e4b, 0x1e4b,
- 0x1e4d, 0x1e4d,
- 0x1e4f, 0x1e4f,
- 0x1e51, 0x1e51,
- 0x1e53, 0x1e53,
- 0x1e55, 0x1e55,
- 0x1e57, 0x1e57,
- 0x1e59, 0x1e59,
- 0x1e5b, 0x1e5b,
- 0x1e5d, 0x1e5d,
- 0x1e5f, 0x1e5f,
- 0x1e61, 0x1e61,
- 0x1e63, 0x1e63,
- 0x1e65, 0x1e65,
- 0x1e67, 0x1e67,
- 0x1e69, 0x1e69,
- 0x1e6b, 0x1e6b,
- 0x1e6d, 0x1e6d,
- 0x1e6f, 0x1e6f,
- 0x1e71, 0x1e71,
- 0x1e73, 0x1e73,
- 0x1e75, 0x1e75,
- 0x1e77, 0x1e77,
- 0x1e79, 0x1e79,
- 0x1e7b, 0x1e7b,
- 0x1e7d, 0x1e7d,
- 0x1e7f, 0x1e7f,
- 0x1e81, 0x1e81,
- 0x1e83, 0x1e83,
- 0x1e85, 0x1e85,
- 0x1e87, 0x1e87,
- 0x1e89, 0x1e89,
- 0x1e8b, 0x1e8b,
- 0x1e8d, 0x1e8d,
- 0x1e8f, 0x1e8f,
- 0x1e91, 0x1e91,
- 0x1e93, 0x1e93,
- 0x1e95, 0x1e9b,
- 0x1ea1, 0x1ea1,
- 0x1ea3, 0x1ea3,
- 0x1ea5, 0x1ea5,
- 0x1ea7, 0x1ea7,
- 0x1ea9, 0x1ea9,
- 0x1eab, 0x1eab,
- 0x1ead, 0x1ead,
- 0x1eaf, 0x1eaf,
- 0x1eb1, 0x1eb1,
- 0x1eb3, 0x1eb3,
- 0x1eb5, 0x1eb5,
- 0x1eb7, 0x1eb7,
- 0x1eb9, 0x1eb9,
- 0x1ebb, 0x1ebb,
- 0x1ebd, 0x1ebd,
- 0x1ebf, 0x1ebf,
- 0x1ec1, 0x1ec1,
- 0x1ec3, 0x1ec3,
- 0x1ec5, 0x1ec5,
- 0x1ec7, 0x1ec7,
- 0x1ec9, 0x1ec9,
- 0x1ecb, 0x1ecb,
- 0x1ecd, 0x1ecd,
- 0x1ecf, 0x1ecf,
- 0x1ed1, 0x1ed1,
- 0x1ed3, 0x1ed3,
- 0x1ed5, 0x1ed5,
- 0x1ed7, 0x1ed7,
- 0x1ed9, 0x1ed9,
- 0x1edb, 0x1edb,
- 0x1edd, 0x1edd,
- 0x1edf, 0x1edf,
- 0x1ee1, 0x1ee1,
- 0x1ee3, 0x1ee3,
- 0x1ee5, 0x1ee5,
- 0x1ee7, 0x1ee7,
- 0x1ee9, 0x1ee9,
- 0x1eeb, 0x1eeb,
- 0x1eed, 0x1eed,
- 0x1eef, 0x1eef,
- 0x1ef1, 0x1ef1,
- 0x1ef3, 0x1ef3,
- 0x1ef5, 0x1ef5,
- 0x1ef7, 0x1ef7,
- 0x1ef9, 0x1ef9,
- 0x1f00, 0x1f07,
- 0x1f10, 0x1f15,
- 0x1f20, 0x1f27,
- 0x1f30, 0x1f37,
- 0x1f40, 0x1f45,
- 0x1f50, 0x1f57,
- 0x1f60, 0x1f67,
- 0x1f70, 0x1f7d,
- 0x1f80, 0x1f87,
- 0x1f90, 0x1f97,
- 0x1fa0, 0x1fa7,
- 0x1fb0, 0x1fb4,
- 0x1fb6, 0x1fb7,
- 0x1fbe, 0x1fbe,
- 0x1fc2, 0x1fc4,
- 0x1fc6, 0x1fc7,
- 0x1fd0, 0x1fd3,
- 0x1fd6, 0x1fd7,
- 0x1fe0, 0x1fe7,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ff7,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x210a, 0x210a,
- 0x210e, 0x210f,
- 0x2113, 0x2113,
- 0x212f, 0x212f,
- 0x2134, 0x2134,
- 0x2139, 0x2139,
- 0x213c, 0x213d,
- 0x2146, 0x2149,
- 0x2c30, 0x2c5e,
- 0x2c81, 0x2c81,
- 0x2c83, 0x2c83,
- 0x2c85, 0x2c85,
- 0x2c87, 0x2c87,
- 0x2c89, 0x2c89,
- 0x2c8b, 0x2c8b,
- 0x2c8d, 0x2c8d,
- 0x2c8f, 0x2c8f,
- 0x2c91, 0x2c91,
- 0x2c93, 0x2c93,
- 0x2c95, 0x2c95,
- 0x2c97, 0x2c97,
- 0x2c99, 0x2c99,
- 0x2c9b, 0x2c9b,
- 0x2c9d, 0x2c9d,
- 0x2c9f, 0x2c9f,
- 0x2ca1, 0x2ca1,
- 0x2ca3, 0x2ca3,
- 0x2ca5, 0x2ca5,
- 0x2ca7, 0x2ca7,
- 0x2ca9, 0x2ca9,
- 0x2cab, 0x2cab,
- 0x2cad, 0x2cad,
- 0x2caf, 0x2caf,
- 0x2cb1, 0x2cb1,
- 0x2cb3, 0x2cb3,
- 0x2cb5, 0x2cb5,
- 0x2cb7, 0x2cb7,
- 0x2cb9, 0x2cb9,
- 0x2cbb, 0x2cbb,
- 0x2cbd, 0x2cbd,
- 0x2cbf, 0x2cbf,
- 0x2cc1, 0x2cc1,
- 0x2cc3, 0x2cc3,
- 0x2cc5, 0x2cc5,
- 0x2cc7, 0x2cc7,
- 0x2cc9, 0x2cc9,
- 0x2ccb, 0x2ccb,
- 0x2ccd, 0x2ccd,
- 0x2ccf, 0x2ccf,
- 0x2cd1, 0x2cd1,
- 0x2cd3, 0x2cd3,
- 0x2cd5, 0x2cd5,
- 0x2cd7, 0x2cd7,
- 0x2cd9, 0x2cd9,
- 0x2cdb, 0x2cdb,
- 0x2cdd, 0x2cdd,
- 0x2cdf, 0x2cdf,
- 0x2ce1, 0x2ce1,
- 0x2ce3, 0x2ce4,
- 0x2d00, 0x2d25,
- 0xfb00, 0xfb06,
- 0xfb13, 0xfb17,
- 0xff41, 0xff5a,
- 0x10428, 0x1044f,
- 0x1d41a, 0x1d433,
- 0x1d44e, 0x1d454,
- 0x1d456, 0x1d467,
- 0x1d482, 0x1d49b,
- 0x1d4b6, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d4cf,
- 0x1d4ea, 0x1d503,
- 0x1d51e, 0x1d537,
- 0x1d552, 0x1d56b,
- 0x1d586, 0x1d59f,
- 0x1d5ba, 0x1d5d3,
- 0x1d5ee, 0x1d607,
- 0x1d622, 0x1d63b,
- 0x1d656, 0x1d66f,
- 0x1d68a, 0x1d6a5,
- 0x1d6c2, 0x1d6da,
- 0x1d6dc, 0x1d6e1,
- 0x1d6fc, 0x1d714,
- 0x1d716, 0x1d71b,
- 0x1d736, 0x1d74e,
- 0x1d750, 0x1d755,
- 0x1d770, 0x1d788,
- 0x1d78a, 0x1d78f,
- 0x1d7aa, 0x1d7c2,
- 0x1d7c4, 0x1d7c9
-}; /* CR_Ll */
-
-/* 'Lm': General Category */
-static const OnigCodePoint CR_Lm[] = {
- 26,
- 0x02b0, 0x02c1,
- 0x02c6, 0x02d1,
- 0x02e0, 0x02e4,
- 0x02ee, 0x02ee,
- 0x037a, 0x037a,
- 0x0559, 0x0559,
- 0x0640, 0x0640,
- 0x06e5, 0x06e6,
- 0x0e46, 0x0e46,
- 0x0ec6, 0x0ec6,
- 0x10fc, 0x10fc,
- 0x17d7, 0x17d7,
- 0x1843, 0x1843,
- 0x1d2c, 0x1d61,
- 0x1d78, 0x1d78,
- 0x1d9b, 0x1dbf,
- 0x2090, 0x2094,
- 0x2d6f, 0x2d6f,
- 0x3005, 0x3005,
- 0x3031, 0x3035,
- 0x303b, 0x303b,
- 0x309d, 0x309e,
- 0x30fc, 0x30fe,
- 0xa015, 0xa015,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f
-}; /* CR_Lm */
-
-/* 'Lo': General Category */
-static const OnigCodePoint CR_Lo[] = {
- 245,
- 0x01bb, 0x01bb,
- 0x01c0, 0x01c3,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f2,
- 0x0621, 0x063a,
- 0x0641, 0x064a,
- 0x066e, 0x066f,
- 0x0671, 0x06d3,
- 0x06d5, 0x06d5,
- 0x06ee, 0x06ef,
- 0x06fa, 0x06fc,
- 0x06ff, 0x06ff,
- 0x0710, 0x0710,
- 0x0712, 0x072f,
- 0x074d, 0x076d,
- 0x0780, 0x07a5,
- 0x07b1, 0x07b1,
- 0x0904, 0x0939,
- 0x093d, 0x093d,
- 0x0950, 0x0950,
- 0x0958, 0x0961,
- 0x097d, 0x097d,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bd, 0x09bd,
- 0x09ce, 0x09ce,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e1,
- 0x09f0, 0x09f1,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a72, 0x0a74,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abd, 0x0abd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae1,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3d, 0x0b3d,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b71, 0x0b71,
- 0x0b83, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c60, 0x0c61,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbd, 0x0cbd,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d60, 0x0d61,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0e01, 0x0e30,
- 0x0e32, 0x0e33,
- 0x0e40, 0x0e45,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb0,
- 0x0eb2, 0x0eb3,
- 0x0ebd, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0edc, 0x0edd,
- 0x0f00, 0x0f00,
- 0x0f40, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f88, 0x0f8b,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x1050, 0x1055,
- 0x10d0, 0x10fa,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x1380, 0x138f,
- 0x13a0, 0x13f4,
- 0x1401, 0x166c,
- 0x166f, 0x1676,
- 0x1681, 0x169a,
- 0x16a0, 0x16ea,
- 0x1700, 0x170c,
- 0x170e, 0x1711,
- 0x1720, 0x1731,
- 0x1740, 0x1751,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1780, 0x17b3,
- 0x17dc, 0x17dc,
- 0x1820, 0x1842,
- 0x1844, 0x1877,
- 0x1880, 0x18a8,
- 0x1900, 0x191c,
- 0x1950, 0x196d,
- 0x1970, 0x1974,
- 0x1980, 0x19a9,
- 0x19c1, 0x19c7,
- 0x1a00, 0x1a16,
- 0x2135, 0x2138,
- 0x2d30, 0x2d65,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde,
- 0x3006, 0x3006,
- 0x303c, 0x303c,
- 0x3041, 0x3096,
- 0x309f, 0x309f,
- 0x30a1, 0x30fa,
- 0x30ff, 0x30ff,
- 0x3105, 0x312c,
- 0x3131, 0x318e,
- 0x31a0, 0x31b7,
- 0x31f0, 0x31ff,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fbb,
- 0xa000, 0xa014,
- 0xa016, 0xa48c,
- 0xa800, 0xa801,
- 0xa803, 0xa805,
- 0xa807, 0xa80a,
- 0xa80c, 0xa822,
- 0xac00, 0xd7a3,
- 0xf900, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0xfb1d, 0xfb1d,
- 0xfb1f, 0xfb28,
- 0xfb2a, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfb,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc,
- 0xff66, 0xff6f,
- 0xff71, 0xff9d,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa,
- 0x10300, 0x1031e,
- 0x10330, 0x10349,
- 0x10380, 0x1039d,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103cf,
- 0x10450, 0x1049d,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f,
- 0x10a00, 0x10a00,
- 0x10a10, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d
-}; /* CR_Lo */
-
-/* 'Lt': General Category */
-static const OnigCodePoint CR_Lt[] = {
- 10,
- 0x01c5, 0x01c5,
- 0x01c8, 0x01c8,
- 0x01cb, 0x01cb,
- 0x01f2, 0x01f2,
- 0x1f88, 0x1f8f,
- 0x1f98, 0x1f9f,
- 0x1fa8, 0x1faf,
- 0x1fbc, 0x1fbc,
- 0x1fcc, 0x1fcc,
- 0x1ffc, 0x1ffc
-}; /* CR_Lt */
-
-/* 'Lu': General Category */
-static const OnigCodePoint CR_Lu[] = {
- 476,
- 0x0041, 0x005a,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00de,
- 0x0100, 0x0100,
- 0x0102, 0x0102,
- 0x0104, 0x0104,
- 0x0106, 0x0106,
- 0x0108, 0x0108,
- 0x010a, 0x010a,
- 0x010c, 0x010c,
- 0x010e, 0x010e,
- 0x0110, 0x0110,
- 0x0112, 0x0112,
- 0x0114, 0x0114,
- 0x0116, 0x0116,
- 0x0118, 0x0118,
- 0x011a, 0x011a,
- 0x011c, 0x011c,
- 0x011e, 0x011e,
- 0x0120, 0x0120,
- 0x0122, 0x0122,
- 0x0124, 0x0124,
- 0x0126, 0x0126,
- 0x0128, 0x0128,
- 0x012a, 0x012a,
- 0x012c, 0x012c,
- 0x012e, 0x012e,
- 0x0130, 0x0130,
- 0x0132, 0x0132,
- 0x0134, 0x0134,
- 0x0136, 0x0136,
- 0x0139, 0x0139,
- 0x013b, 0x013b,
- 0x013d, 0x013d,
- 0x013f, 0x013f,
- 0x0141, 0x0141,
- 0x0143, 0x0143,
- 0x0145, 0x0145,
- 0x0147, 0x0147,
- 0x014a, 0x014a,
- 0x014c, 0x014c,
- 0x014e, 0x014e,
- 0x0150, 0x0150,
- 0x0152, 0x0152,
- 0x0154, 0x0154,
- 0x0156, 0x0156,
- 0x0158, 0x0158,
- 0x015a, 0x015a,
- 0x015c, 0x015c,
- 0x015e, 0x015e,
- 0x0160, 0x0160,
- 0x0162, 0x0162,
- 0x0164, 0x0164,
- 0x0166, 0x0166,
- 0x0168, 0x0168,
- 0x016a, 0x016a,
- 0x016c, 0x016c,
- 0x016e, 0x016e,
- 0x0170, 0x0170,
- 0x0172, 0x0172,
- 0x0174, 0x0174,
- 0x0176, 0x0176,
- 0x0178, 0x0179,
- 0x017b, 0x017b,
- 0x017d, 0x017d,
- 0x0181, 0x0182,
- 0x0184, 0x0184,
- 0x0186, 0x0187,
- 0x0189, 0x018b,
- 0x018e, 0x0191,
- 0x0193, 0x0194,
- 0x0196, 0x0198,
- 0x019c, 0x019d,
- 0x019f, 0x01a0,
- 0x01a2, 0x01a2,
- 0x01a4, 0x01a4,
- 0x01a6, 0x01a7,
- 0x01a9, 0x01a9,
- 0x01ac, 0x01ac,
- 0x01ae, 0x01af,
- 0x01b1, 0x01b3,
- 0x01b5, 0x01b5,
- 0x01b7, 0x01b8,
- 0x01bc, 0x01bc,
- 0x01c4, 0x01c4,
- 0x01c7, 0x01c7,
- 0x01ca, 0x01ca,
- 0x01cd, 0x01cd,
- 0x01cf, 0x01cf,
- 0x01d1, 0x01d1,
- 0x01d3, 0x01d3,
- 0x01d5, 0x01d5,
- 0x01d7, 0x01d7,
- 0x01d9, 0x01d9,
- 0x01db, 0x01db,
- 0x01de, 0x01de,
- 0x01e0, 0x01e0,
- 0x01e2, 0x01e2,
- 0x01e4, 0x01e4,
- 0x01e6, 0x01e6,
- 0x01e8, 0x01e8,
- 0x01ea, 0x01ea,
- 0x01ec, 0x01ec,
- 0x01ee, 0x01ee,
- 0x01f1, 0x01f1,
- 0x01f4, 0x01f4,
- 0x01f6, 0x01f8,
- 0x01fa, 0x01fa,
- 0x01fc, 0x01fc,
- 0x01fe, 0x01fe,
- 0x0200, 0x0200,
- 0x0202, 0x0202,
- 0x0204, 0x0204,
- 0x0206, 0x0206,
- 0x0208, 0x0208,
- 0x020a, 0x020a,
- 0x020c, 0x020c,
- 0x020e, 0x020e,
- 0x0210, 0x0210,
- 0x0212, 0x0212,
- 0x0214, 0x0214,
- 0x0216, 0x0216,
- 0x0218, 0x0218,
- 0x021a, 0x021a,
- 0x021c, 0x021c,
- 0x021e, 0x021e,
- 0x0220, 0x0220,
- 0x0222, 0x0222,
- 0x0224, 0x0224,
- 0x0226, 0x0226,
- 0x0228, 0x0228,
- 0x022a, 0x022a,
- 0x022c, 0x022c,
- 0x022e, 0x022e,
- 0x0230, 0x0230,
- 0x0232, 0x0232,
- 0x023a, 0x023b,
- 0x023d, 0x023e,
- 0x0241, 0x0241,
- 0x0386, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x038f,
- 0x0391, 0x03a1,
- 0x03a3, 0x03ab,
- 0x03d2, 0x03d4,
- 0x03d8, 0x03d8,
- 0x03da, 0x03da,
- 0x03dc, 0x03dc,
- 0x03de, 0x03de,
- 0x03e0, 0x03e0,
- 0x03e2, 0x03e2,
- 0x03e4, 0x03e4,
- 0x03e6, 0x03e6,
- 0x03e8, 0x03e8,
- 0x03ea, 0x03ea,
- 0x03ec, 0x03ec,
- 0x03ee, 0x03ee,
- 0x03f4, 0x03f4,
- 0x03f7, 0x03f7,
- 0x03f9, 0x03fa,
- 0x03fd, 0x042f,
- 0x0460, 0x0460,
- 0x0462, 0x0462,
- 0x0464, 0x0464,
- 0x0466, 0x0466,
- 0x0468, 0x0468,
- 0x046a, 0x046a,
- 0x046c, 0x046c,
- 0x046e, 0x046e,
- 0x0470, 0x0470,
- 0x0472, 0x0472,
- 0x0474, 0x0474,
- 0x0476, 0x0476,
- 0x0478, 0x0478,
- 0x047a, 0x047a,
- 0x047c, 0x047c,
- 0x047e, 0x047e,
- 0x0480, 0x0480,
- 0x048a, 0x048a,
- 0x048c, 0x048c,
- 0x048e, 0x048e,
- 0x0490, 0x0490,
- 0x0492, 0x0492,
- 0x0494, 0x0494,
- 0x0496, 0x0496,
- 0x0498, 0x0498,
- 0x049a, 0x049a,
- 0x049c, 0x049c,
- 0x049e, 0x049e,
- 0x04a0, 0x04a0,
- 0x04a2, 0x04a2,
- 0x04a4, 0x04a4,
- 0x04a6, 0x04a6,
- 0x04a8, 0x04a8,
- 0x04aa, 0x04aa,
- 0x04ac, 0x04ac,
- 0x04ae, 0x04ae,
- 0x04b0, 0x04b0,
- 0x04b2, 0x04b2,
- 0x04b4, 0x04b4,
- 0x04b6, 0x04b6,
- 0x04b8, 0x04b8,
- 0x04ba, 0x04ba,
- 0x04bc, 0x04bc,
- 0x04be, 0x04be,
- 0x04c0, 0x04c1,
- 0x04c3, 0x04c3,
- 0x04c5, 0x04c5,
- 0x04c7, 0x04c7,
- 0x04c9, 0x04c9,
- 0x04cb, 0x04cb,
- 0x04cd, 0x04cd,
- 0x04d0, 0x04d0,
- 0x04d2, 0x04d2,
- 0x04d4, 0x04d4,
- 0x04d6, 0x04d6,
- 0x04d8, 0x04d8,
- 0x04da, 0x04da,
- 0x04dc, 0x04dc,
- 0x04de, 0x04de,
- 0x04e0, 0x04e0,
- 0x04e2, 0x04e2,
- 0x04e4, 0x04e4,
- 0x04e6, 0x04e6,
- 0x04e8, 0x04e8,
- 0x04ea, 0x04ea,
- 0x04ec, 0x04ec,
- 0x04ee, 0x04ee,
- 0x04f0, 0x04f0,
- 0x04f2, 0x04f2,
- 0x04f4, 0x04f4,
- 0x04f6, 0x04f6,
- 0x04f8, 0x04f8,
- 0x0500, 0x0500,
- 0x0502, 0x0502,
- 0x0504, 0x0504,
- 0x0506, 0x0506,
- 0x0508, 0x0508,
- 0x050a, 0x050a,
- 0x050c, 0x050c,
- 0x050e, 0x050e,
- 0x0531, 0x0556,
- 0x10a0, 0x10c5,
- 0x1e00, 0x1e00,
- 0x1e02, 0x1e02,
- 0x1e04, 0x1e04,
- 0x1e06, 0x1e06,
- 0x1e08, 0x1e08,
- 0x1e0a, 0x1e0a,
- 0x1e0c, 0x1e0c,
- 0x1e0e, 0x1e0e,
- 0x1e10, 0x1e10,
- 0x1e12, 0x1e12,
- 0x1e14, 0x1e14,
- 0x1e16, 0x1e16,
- 0x1e18, 0x1e18,
- 0x1e1a, 0x1e1a,
- 0x1e1c, 0x1e1c,
- 0x1e1e, 0x1e1e,
- 0x1e20, 0x1e20,
- 0x1e22, 0x1e22,
- 0x1e24, 0x1e24,
- 0x1e26, 0x1e26,
- 0x1e28, 0x1e28,
- 0x1e2a, 0x1e2a,
- 0x1e2c, 0x1e2c,
- 0x1e2e, 0x1e2e,
- 0x1e30, 0x1e30,
- 0x1e32, 0x1e32,
- 0x1e34, 0x1e34,
- 0x1e36, 0x1e36,
- 0x1e38, 0x1e38,
- 0x1e3a, 0x1e3a,
- 0x1e3c, 0x1e3c,
- 0x1e3e, 0x1e3e,
- 0x1e40, 0x1e40,
- 0x1e42, 0x1e42,
- 0x1e44, 0x1e44,
- 0x1e46, 0x1e46,
- 0x1e48, 0x1e48,
- 0x1e4a, 0x1e4a,
- 0x1e4c, 0x1e4c,
- 0x1e4e, 0x1e4e,
- 0x1e50, 0x1e50,
- 0x1e52, 0x1e52,
- 0x1e54, 0x1e54,
- 0x1e56, 0x1e56,
- 0x1e58, 0x1e58,
- 0x1e5a, 0x1e5a,
- 0x1e5c, 0x1e5c,
- 0x1e5e, 0x1e5e,
- 0x1e60, 0x1e60,
- 0x1e62, 0x1e62,
- 0x1e64, 0x1e64,
- 0x1e66, 0x1e66,
- 0x1e68, 0x1e68,
- 0x1e6a, 0x1e6a,
- 0x1e6c, 0x1e6c,
- 0x1e6e, 0x1e6e,
- 0x1e70, 0x1e70,
- 0x1e72, 0x1e72,
- 0x1e74, 0x1e74,
- 0x1e76, 0x1e76,
- 0x1e78, 0x1e78,
- 0x1e7a, 0x1e7a,
- 0x1e7c, 0x1e7c,
- 0x1e7e, 0x1e7e,
- 0x1e80, 0x1e80,
- 0x1e82, 0x1e82,
- 0x1e84, 0x1e84,
- 0x1e86, 0x1e86,
- 0x1e88, 0x1e88,
- 0x1e8a, 0x1e8a,
- 0x1e8c, 0x1e8c,
- 0x1e8e, 0x1e8e,
- 0x1e90, 0x1e90,
- 0x1e92, 0x1e92,
- 0x1e94, 0x1e94,
- 0x1ea0, 0x1ea0,
- 0x1ea2, 0x1ea2,
- 0x1ea4, 0x1ea4,
- 0x1ea6, 0x1ea6,
- 0x1ea8, 0x1ea8,
- 0x1eaa, 0x1eaa,
- 0x1eac, 0x1eac,
- 0x1eae, 0x1eae,
- 0x1eb0, 0x1eb0,
- 0x1eb2, 0x1eb2,
- 0x1eb4, 0x1eb4,
- 0x1eb6, 0x1eb6,
- 0x1eb8, 0x1eb8,
- 0x1eba, 0x1eba,
- 0x1ebc, 0x1ebc,
- 0x1ebe, 0x1ebe,
- 0x1ec0, 0x1ec0,
- 0x1ec2, 0x1ec2,
- 0x1ec4, 0x1ec4,
- 0x1ec6, 0x1ec6,
- 0x1ec8, 0x1ec8,
- 0x1eca, 0x1eca,
- 0x1ecc, 0x1ecc,
- 0x1ece, 0x1ece,
- 0x1ed0, 0x1ed0,
- 0x1ed2, 0x1ed2,
- 0x1ed4, 0x1ed4,
- 0x1ed6, 0x1ed6,
- 0x1ed8, 0x1ed8,
- 0x1eda, 0x1eda,
- 0x1edc, 0x1edc,
- 0x1ede, 0x1ede,
- 0x1ee0, 0x1ee0,
- 0x1ee2, 0x1ee2,
- 0x1ee4, 0x1ee4,
- 0x1ee6, 0x1ee6,
- 0x1ee8, 0x1ee8,
- 0x1eea, 0x1eea,
- 0x1eec, 0x1eec,
- 0x1eee, 0x1eee,
- 0x1ef0, 0x1ef0,
- 0x1ef2, 0x1ef2,
- 0x1ef4, 0x1ef4,
- 0x1ef6, 0x1ef6,
- 0x1ef8, 0x1ef8,
- 0x1f08, 0x1f0f,
- 0x1f18, 0x1f1d,
- 0x1f28, 0x1f2f,
- 0x1f38, 0x1f3f,
- 0x1f48, 0x1f4d,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f5f,
- 0x1f68, 0x1f6f,
- 0x1fb8, 0x1fbb,
- 0x1fc8, 0x1fcb,
- 0x1fd8, 0x1fdb,
- 0x1fe8, 0x1fec,
- 0x1ff8, 0x1ffb,
- 0x2102, 0x2102,
- 0x2107, 0x2107,
- 0x210b, 0x210d,
- 0x2110, 0x2112,
- 0x2115, 0x2115,
- 0x2119, 0x211d,
- 0x2124, 0x2124,
- 0x2126, 0x2126,
- 0x2128, 0x2128,
- 0x212a, 0x212d,
- 0x2130, 0x2131,
- 0x2133, 0x2133,
- 0x213e, 0x213f,
- 0x2145, 0x2145,
- 0x2c00, 0x2c2e,
- 0x2c80, 0x2c80,
- 0x2c82, 0x2c82,
- 0x2c84, 0x2c84,
- 0x2c86, 0x2c86,
- 0x2c88, 0x2c88,
- 0x2c8a, 0x2c8a,
- 0x2c8c, 0x2c8c,
- 0x2c8e, 0x2c8e,
- 0x2c90, 0x2c90,
- 0x2c92, 0x2c92,
- 0x2c94, 0x2c94,
- 0x2c96, 0x2c96,
- 0x2c98, 0x2c98,
- 0x2c9a, 0x2c9a,
- 0x2c9c, 0x2c9c,
- 0x2c9e, 0x2c9e,
- 0x2ca0, 0x2ca0,
- 0x2ca2, 0x2ca2,
- 0x2ca4, 0x2ca4,
- 0x2ca6, 0x2ca6,
- 0x2ca8, 0x2ca8,
- 0x2caa, 0x2caa,
- 0x2cac, 0x2cac,
- 0x2cae, 0x2cae,
- 0x2cb0, 0x2cb0,
- 0x2cb2, 0x2cb2,
- 0x2cb4, 0x2cb4,
- 0x2cb6, 0x2cb6,
- 0x2cb8, 0x2cb8,
- 0x2cba, 0x2cba,
- 0x2cbc, 0x2cbc,
- 0x2cbe, 0x2cbe,
- 0x2cc0, 0x2cc0,
- 0x2cc2, 0x2cc2,
- 0x2cc4, 0x2cc4,
- 0x2cc6, 0x2cc6,
- 0x2cc8, 0x2cc8,
- 0x2cca, 0x2cca,
- 0x2ccc, 0x2ccc,
- 0x2cce, 0x2cce,
- 0x2cd0, 0x2cd0,
- 0x2cd2, 0x2cd2,
- 0x2cd4, 0x2cd4,
- 0x2cd6, 0x2cd6,
- 0x2cd8, 0x2cd8,
- 0x2cda, 0x2cda,
- 0x2cdc, 0x2cdc,
- 0x2cde, 0x2cde,
- 0x2ce0, 0x2ce0,
- 0x2ce2, 0x2ce2,
- 0xff21, 0xff3a,
- 0x10400, 0x10427,
- 0x1d400, 0x1d419,
- 0x1d434, 0x1d44d,
- 0x1d468, 0x1d481,
- 0x1d49c, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b5,
- 0x1d4d0, 0x1d4e9,
- 0x1d504, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d538, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d56c, 0x1d585,
- 0x1d5a0, 0x1d5b9,
- 0x1d5d4, 0x1d5ed,
- 0x1d608, 0x1d621,
- 0x1d63c, 0x1d655,
- 0x1d670, 0x1d689,
- 0x1d6a8, 0x1d6c0,
- 0x1d6e2, 0x1d6fa,
- 0x1d71c, 0x1d734,
- 0x1d756, 0x1d76e,
- 0x1d790, 0x1d7a8
-}; /* CR_Lu */
-
-/* 'M': Major Category */
-static const OnigCodePoint CR_M[] = {
- 133,
- 0x0300, 0x036f,
- 0x0483, 0x0486,
- 0x0488, 0x0489,
- 0x0591, 0x05b9,
- 0x05bb, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x0615,
- 0x064b, 0x065e,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06de, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x0901, 0x0903,
- 0x093c, 0x093c,
- 0x093e, 0x094d,
- 0x0951, 0x0954,
- 0x0962, 0x0963,
- 0x0981, 0x0983,
- 0x09bc, 0x09bc,
- 0x09be, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cd,
- 0x09d7, 0x09d7,
- 0x09e2, 0x09e3,
- 0x0a01, 0x0a03,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a70, 0x0a71,
- 0x0a81, 0x0a83,
- 0x0abc, 0x0abc,
- 0x0abe, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0b01, 0x0b03,
- 0x0b3c, 0x0b3c,
- 0x0b3e, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b82, 0x0b82,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0c01, 0x0c03,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c82, 0x0c83,
- 0x0cbc, 0x0cbc,
- 0x0cbe, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0d02, 0x0d03,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d82, 0x0d83,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0eb9,
- 0x0ebb, 0x0ebc,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f3e, 0x0f3f,
- 0x0f71, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1056, 0x1059,
- 0x135f, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b6, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x18a9, 0x18a9,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x19b0, 0x19c0,
- 0x19c8, 0x19c9,
- 0x1a17, 0x1a1b,
- 0x1dc0, 0x1dc3,
- 0x20d0, 0x20eb,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa802, 0xa802,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa823, 0xa827,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x1d165, 0x1d169,
- 0x1d16d, 0x1d172,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0xe0100, 0xe01ef
-}; /* CR_M */
-
-/* 'Mc': General Category */
-static const OnigCodePoint CR_Mc[] = {
- 63,
- 0x0903, 0x0903,
- 0x093e, 0x0940,
- 0x0949, 0x094c,
- 0x0982, 0x0983,
- 0x09be, 0x09c0,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09cc,
- 0x09d7, 0x09d7,
- 0x0a03, 0x0a03,
- 0x0a3e, 0x0a40,
- 0x0a83, 0x0a83,
- 0x0abe, 0x0ac0,
- 0x0ac9, 0x0ac9,
- 0x0acb, 0x0acc,
- 0x0b02, 0x0b03,
- 0x0b3e, 0x0b3e,
- 0x0b40, 0x0b40,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4c,
- 0x0b57, 0x0b57,
- 0x0bbe, 0x0bbf,
- 0x0bc1, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcc,
- 0x0bd7, 0x0bd7,
- 0x0c01, 0x0c03,
- 0x0c41, 0x0c44,
- 0x0c82, 0x0c83,
- 0x0cbe, 0x0cbe,
- 0x0cc0, 0x0cc4,
- 0x0cc7, 0x0cc8,
- 0x0cca, 0x0ccb,
- 0x0cd5, 0x0cd6,
- 0x0d02, 0x0d03,
- 0x0d3e, 0x0d40,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4c,
- 0x0d57, 0x0d57,
- 0x0d82, 0x0d83,
- 0x0dcf, 0x0dd1,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df3,
- 0x0f3e, 0x0f3f,
- 0x0f7f, 0x0f7f,
- 0x102c, 0x102c,
- 0x1031, 0x1031,
- 0x1038, 0x1038,
- 0x1056, 0x1057,
- 0x17b6, 0x17b6,
- 0x17be, 0x17c5,
- 0x17c7, 0x17c8,
- 0x1923, 0x1926,
- 0x1929, 0x192b,
- 0x1930, 0x1931,
- 0x1933, 0x1938,
- 0x19b0, 0x19c0,
- 0x19c8, 0x19c9,
- 0x1a19, 0x1a1b,
- 0xa802, 0xa802,
- 0xa823, 0xa824,
- 0xa827, 0xa827,
- 0x1d165, 0x1d166,
- 0x1d16d, 0x1d172
-}; /* CR_Mc */
-
-/* 'Me': General Category */
-static const OnigCodePoint CR_Me[] = {
- 4,
- 0x0488, 0x0489,
- 0x06de, 0x06de,
- 0x20dd, 0x20e0,
- 0x20e2, 0x20e4
-}; /* CR_Me */
-
-/* 'Mn': General Category */
-static const OnigCodePoint CR_Mn[] = {
- 124,
- 0x0300, 0x036f,
- 0x0483, 0x0486,
- 0x0591, 0x05b9,
- 0x05bb, 0x05bd,
- 0x05bf, 0x05bf,
- 0x05c1, 0x05c2,
- 0x05c4, 0x05c5,
- 0x05c7, 0x05c7,
- 0x0610, 0x0615,
- 0x064b, 0x065e,
- 0x0670, 0x0670,
- 0x06d6, 0x06dc,
- 0x06df, 0x06e4,
- 0x06e7, 0x06e8,
- 0x06ea, 0x06ed,
- 0x0711, 0x0711,
- 0x0730, 0x074a,
- 0x07a6, 0x07b0,
- 0x0901, 0x0902,
- 0x093c, 0x093c,
- 0x0941, 0x0948,
- 0x094d, 0x094d,
- 0x0951, 0x0954,
- 0x0962, 0x0963,
- 0x0981, 0x0981,
- 0x09bc, 0x09bc,
- 0x09c1, 0x09c4,
- 0x09cd, 0x09cd,
- 0x09e2, 0x09e3,
- 0x0a01, 0x0a02,
- 0x0a3c, 0x0a3c,
- 0x0a41, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a70, 0x0a71,
- 0x0a81, 0x0a82,
- 0x0abc, 0x0abc,
- 0x0ac1, 0x0ac5,
- 0x0ac7, 0x0ac8,
- 0x0acd, 0x0acd,
- 0x0ae2, 0x0ae3,
- 0x0b01, 0x0b01,
- 0x0b3c, 0x0b3c,
- 0x0b3f, 0x0b3f,
- 0x0b41, 0x0b43,
- 0x0b4d, 0x0b4d,
- 0x0b56, 0x0b56,
- 0x0b82, 0x0b82,
- 0x0bc0, 0x0bc0,
- 0x0bcd, 0x0bcd,
- 0x0c3e, 0x0c40,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0cbc, 0x0cbc,
- 0x0cbf, 0x0cbf,
- 0x0cc6, 0x0cc6,
- 0x0ccc, 0x0ccd,
- 0x0d41, 0x0d43,
- 0x0d4d, 0x0d4d,
- 0x0dca, 0x0dca,
- 0x0dd2, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0e31, 0x0e31,
- 0x0e34, 0x0e3a,
- 0x0e47, 0x0e4e,
- 0x0eb1, 0x0eb1,
- 0x0eb4, 0x0eb9,
- 0x0ebb, 0x0ebc,
- 0x0ec8, 0x0ecd,
- 0x0f18, 0x0f19,
- 0x0f35, 0x0f35,
- 0x0f37, 0x0f37,
- 0x0f39, 0x0f39,
- 0x0f71, 0x0f7e,
- 0x0f80, 0x0f84,
- 0x0f86, 0x0f87,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fc6, 0x0fc6,
- 0x102d, 0x1030,
- 0x1032, 0x1032,
- 0x1036, 0x1037,
- 0x1039, 0x1039,
- 0x1058, 0x1059,
- 0x135f, 0x135f,
- 0x1712, 0x1714,
- 0x1732, 0x1734,
- 0x1752, 0x1753,
- 0x1772, 0x1773,
- 0x17b7, 0x17bd,
- 0x17c6, 0x17c6,
- 0x17c9, 0x17d3,
- 0x17dd, 0x17dd,
- 0x180b, 0x180d,
- 0x18a9, 0x18a9,
- 0x1920, 0x1922,
- 0x1927, 0x1928,
- 0x1932, 0x1932,
- 0x1939, 0x193b,
- 0x1a17, 0x1a18,
- 0x1dc0, 0x1dc3,
- 0x20d0, 0x20dc,
- 0x20e1, 0x20e1,
- 0x20e5, 0x20eb,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xa806, 0xa806,
- 0xa80b, 0xa80b,
- 0xa825, 0xa826,
- 0xfb1e, 0xfb1e,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0x10a01, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a0f,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a3f,
- 0x1d167, 0x1d169,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0x1d242, 0x1d244,
- 0xe0100, 0xe01ef
-}; /* CR_Mn */
-
-/* 'N': Major Category */
-static const OnigCodePoint CR_N[] = {
- 53,
- 0x0030, 0x0039,
- 0x00b2, 0x00b3,
- 0x00b9, 0x00b9,
- 0x00bc, 0x00be,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x09f4, 0x09f9,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0be6, 0x0bf2,
- 0x0c66, 0x0c6f,
- 0x0ce6, 0x0cef,
- 0x0d66, 0x0d6f,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f33,
- 0x1040, 0x1049,
- 0x1369, 0x137c,
- 0x16ee, 0x16f0,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19d9,
- 0x2070, 0x2070,
- 0x2074, 0x2079,
- 0x2080, 0x2089,
- 0x2153, 0x2183,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2cfd, 0x2cfd,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0x3192, 0x3195,
- 0x3220, 0x3229,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0xff10, 0xff19,
- 0x10107, 0x10133,
- 0x10140, 0x10178,
- 0x1018a, 0x1018a,
- 0x10320, 0x10323,
- 0x1034a, 0x1034a,
- 0x103d1, 0x103d5,
- 0x104a0, 0x104a9,
- 0x10a40, 0x10a47,
- 0x1d7ce, 0x1d7ff
-}; /* CR_N */
-
-/* 'Nd': General Category */
-static const OnigCodePoint CR_Nd[] = {
- 23,
- 0x0030, 0x0039,
- 0x0660, 0x0669,
- 0x06f0, 0x06f9,
- 0x0966, 0x096f,
- 0x09e6, 0x09ef,
- 0x0a66, 0x0a6f,
- 0x0ae6, 0x0aef,
- 0x0b66, 0x0b6f,
- 0x0be6, 0x0bef,
- 0x0c66, 0x0c6f,
- 0x0ce6, 0x0cef,
- 0x0d66, 0x0d6f,
- 0x0e50, 0x0e59,
- 0x0ed0, 0x0ed9,
- 0x0f20, 0x0f29,
- 0x1040, 0x1049,
- 0x17e0, 0x17e9,
- 0x1810, 0x1819,
- 0x1946, 0x194f,
- 0x19d0, 0x19d9,
- 0xff10, 0xff19,
- 0x104a0, 0x104a9,
- 0x1d7ce, 0x1d7ff
-}; /* CR_Nd */
-
-/* 'Nl': General Category */
-static const OnigCodePoint CR_Nl[] = {
- 8,
- 0x16ee, 0x16f0,
- 0x2160, 0x2183,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303a,
- 0x10140, 0x10174,
- 0x1034a, 0x1034a,
- 0x103d1, 0x103d5
-}; /* CR_Nl */
-
-/* 'No': General Category */
-static const OnigCodePoint CR_No[] = {
- 26,
- 0x00b2, 0x00b3,
- 0x00b9, 0x00b9,
- 0x00bc, 0x00be,
- 0x09f4, 0x09f9,
- 0x0bf0, 0x0bf2,
- 0x0f2a, 0x0f33,
- 0x1369, 0x137c,
- 0x17f0, 0x17f9,
- 0x2070, 0x2070,
- 0x2074, 0x2079,
- 0x2080, 0x2089,
- 0x2153, 0x215f,
- 0x2460, 0x249b,
- 0x24ea, 0x24ff,
- 0x2776, 0x2793,
- 0x2cfd, 0x2cfd,
- 0x3192, 0x3195,
- 0x3220, 0x3229,
- 0x3251, 0x325f,
- 0x3280, 0x3289,
- 0x32b1, 0x32bf,
- 0x10107, 0x10133,
- 0x10175, 0x10178,
- 0x1018a, 0x1018a,
- 0x10320, 0x10323,
- 0x10a40, 0x10a47
-}; /* CR_No */
-
-/* 'P': Major Category */
-static const OnigCodePoint CR_P[] = {
- 96,
- 0x0021, 0x0023,
- 0x0025, 0x002a,
- 0x002c, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005b, 0x005d,
- 0x005f, 0x005f,
- 0x007b, 0x007b,
- 0x007d, 0x007d,
- 0x00a1, 0x00a1,
- 0x00ab, 0x00ab,
- 0x00b7, 0x00b7,
- 0x00bb, 0x00bb,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x058a,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f3a, 0x0f3d,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd1,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1361, 0x1368,
- 0x166d, 0x166e,
- 0x169b, 0x169c,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x180a,
- 0x1944, 0x1945,
- 0x19de, 0x19df,
- 0x1a1e, 0x1a1f,
- 0x2010, 0x2027,
- 0x2030, 0x2043,
- 0x2045, 0x2051,
- 0x2053, 0x205e,
- 0x207d, 0x207e,
- 0x208d, 0x208e,
- 0x2329, 0x232a,
- 0x23b4, 0x23b6,
- 0x2768, 0x2775,
- 0x27c5, 0x27c6,
- 0x27e6, 0x27eb,
- 0x2983, 0x2998,
- 0x29d8, 0x29db,
- 0x29fc, 0x29fd,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x3001, 0x3003,
- 0x3008, 0x3011,
- 0x3014, 0x301f,
- 0x3030, 0x3030,
- 0x303d, 0x303d,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fb,
- 0xfd3e, 0xfd3f,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe61,
- 0xfe63, 0xfe63,
- 0xfe68, 0xfe68,
- 0xfe6a, 0xfe6b,
- 0xff01, 0xff03,
- 0xff05, 0xff0a,
- 0xff0c, 0xff0f,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff20,
- 0xff3b, 0xff3d,
- 0xff3f, 0xff3f,
- 0xff5b, 0xff5b,
- 0xff5d, 0xff5d,
- 0xff5f, 0xff65,
- 0x10100, 0x10101,
- 0x1039f, 0x1039f,
- 0x10a50, 0x10a58
-}; /* CR_P */
-
-/* 'Pc': General Category */
-static const OnigCodePoint CR_Pc[] = {
- 6,
- 0x005f, 0x005f,
- 0x203f, 0x2040,
- 0x2054, 0x2054,
- 0xfe33, 0xfe34,
- 0xfe4d, 0xfe4f,
- 0xff3f, 0xff3f
-}; /* CR_Pc */
-
-/* 'Pd': General Category */
-static const OnigCodePoint CR_Pd[] = {
- 12,
- 0x002d, 0x002d,
- 0x058a, 0x058a,
- 0x1806, 0x1806,
- 0x2010, 0x2015,
- 0x2e17, 0x2e17,
- 0x301c, 0x301c,
- 0x3030, 0x3030,
- 0x30a0, 0x30a0,
- 0xfe31, 0xfe32,
- 0xfe58, 0xfe58,
- 0xfe63, 0xfe63,
- 0xff0d, 0xff0d
-}; /* CR_Pd */
-
-/* 'Pe': General Category */
-static const OnigCodePoint CR_Pe[] = {
- 65,
- 0x0029, 0x0029,
- 0x005d, 0x005d,
- 0x007d, 0x007d,
- 0x0f3b, 0x0f3b,
- 0x0f3d, 0x0f3d,
- 0x169c, 0x169c,
- 0x2046, 0x2046,
- 0x207e, 0x207e,
- 0x208e, 0x208e,
- 0x232a, 0x232a,
- 0x23b5, 0x23b5,
- 0x2769, 0x2769,
- 0x276b, 0x276b,
- 0x276d, 0x276d,
- 0x276f, 0x276f,
- 0x2771, 0x2771,
- 0x2773, 0x2773,
- 0x2775, 0x2775,
- 0x27c6, 0x27c6,
- 0x27e7, 0x27e7,
- 0x27e9, 0x27e9,
- 0x27eb, 0x27eb,
- 0x2984, 0x2984,
- 0x2986, 0x2986,
- 0x2988, 0x2988,
- 0x298a, 0x298a,
- 0x298c, 0x298c,
- 0x298e, 0x298e,
- 0x2990, 0x2990,
- 0x2992, 0x2992,
- 0x2994, 0x2994,
- 0x2996, 0x2996,
- 0x2998, 0x2998,
- 0x29d9, 0x29d9,
- 0x29db, 0x29db,
- 0x29fd, 0x29fd,
- 0x3009, 0x3009,
- 0x300b, 0x300b,
- 0x300d, 0x300d,
- 0x300f, 0x300f,
- 0x3011, 0x3011,
- 0x3015, 0x3015,
- 0x3017, 0x3017,
- 0x3019, 0x3019,
- 0x301b, 0x301b,
- 0x301e, 0x301f,
- 0xfd3f, 0xfd3f,
- 0xfe18, 0xfe18,
- 0xfe36, 0xfe36,
- 0xfe38, 0xfe38,
- 0xfe3a, 0xfe3a,
- 0xfe3c, 0xfe3c,
- 0xfe3e, 0xfe3e,
- 0xfe40, 0xfe40,
- 0xfe42, 0xfe42,
- 0xfe44, 0xfe44,
- 0xfe48, 0xfe48,
- 0xfe5a, 0xfe5a,
- 0xfe5c, 0xfe5c,
- 0xfe5e, 0xfe5e,
- 0xff09, 0xff09,
- 0xff3d, 0xff3d,
- 0xff5d, 0xff5d,
- 0xff60, 0xff60,
- 0xff63, 0xff63
-}; /* CR_Pe */
-
-/* 'Pf': General Category */
-static const OnigCodePoint CR_Pf[] = {
- 9,
- 0x00bb, 0x00bb,
- 0x2019, 0x2019,
- 0x201d, 0x201d,
- 0x203a, 0x203a,
- 0x2e03, 0x2e03,
- 0x2e05, 0x2e05,
- 0x2e0a, 0x2e0a,
- 0x2e0d, 0x2e0d,
- 0x2e1d, 0x2e1d
-}; /* CR_Pf */
-
-/* 'Pi': General Category */
-static const OnigCodePoint CR_Pi[] = {
- 10,
- 0x00ab, 0x00ab,
- 0x2018, 0x2018,
- 0x201b, 0x201c,
- 0x201f, 0x201f,
- 0x2039, 0x2039,
- 0x2e02, 0x2e02,
- 0x2e04, 0x2e04,
- 0x2e09, 0x2e09,
- 0x2e0c, 0x2e0c,
- 0x2e1c, 0x2e1c
-}; /* CR_Pi */
-
-/* 'Po': General Category */
-static const OnigCodePoint CR_Po[] = {
- 88,
- 0x0021, 0x0023,
- 0x0025, 0x0027,
- 0x002a, 0x002a,
- 0x002c, 0x002c,
- 0x002e, 0x002f,
- 0x003a, 0x003b,
- 0x003f, 0x0040,
- 0x005c, 0x005c,
- 0x00a1, 0x00a1,
- 0x00b7, 0x00b7,
- 0x00bf, 0x00bf,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x055a, 0x055f,
- 0x0589, 0x0589,
- 0x05be, 0x05be,
- 0x05c0, 0x05c0,
- 0x05c3, 0x05c3,
- 0x05c6, 0x05c6,
- 0x05f3, 0x05f4,
- 0x060c, 0x060d,
- 0x061b, 0x061b,
- 0x061e, 0x061f,
- 0x066a, 0x066d,
- 0x06d4, 0x06d4,
- 0x0700, 0x070d,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x0df4, 0x0df4,
- 0x0e4f, 0x0e4f,
- 0x0e5a, 0x0e5b,
- 0x0f04, 0x0f12,
- 0x0f85, 0x0f85,
- 0x0fd0, 0x0fd1,
- 0x104a, 0x104f,
- 0x10fb, 0x10fb,
- 0x1361, 0x1368,
- 0x166d, 0x166e,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x17d4, 0x17d6,
- 0x17d8, 0x17da,
- 0x1800, 0x1805,
- 0x1807, 0x180a,
- 0x1944, 0x1945,
- 0x19de, 0x19df,
- 0x1a1e, 0x1a1f,
- 0x2016, 0x2017,
- 0x2020, 0x2027,
- 0x2030, 0x2038,
- 0x203b, 0x203e,
- 0x2041, 0x2043,
- 0x2047, 0x2051,
- 0x2053, 0x2053,
- 0x2055, 0x205e,
- 0x23b6, 0x23b6,
- 0x2cf9, 0x2cfc,
- 0x2cfe, 0x2cff,
- 0x2e00, 0x2e01,
- 0x2e06, 0x2e08,
- 0x2e0b, 0x2e0b,
- 0x2e0e, 0x2e16,
- 0x3001, 0x3003,
- 0x303d, 0x303d,
- 0x30fb, 0x30fb,
- 0xfe10, 0xfe16,
- 0xfe19, 0xfe19,
- 0xfe30, 0xfe30,
- 0xfe45, 0xfe46,
- 0xfe49, 0xfe4c,
- 0xfe50, 0xfe52,
- 0xfe54, 0xfe57,
- 0xfe5f, 0xfe61,
- 0xfe68, 0xfe68,
- 0xfe6a, 0xfe6b,
- 0xff01, 0xff03,
- 0xff05, 0xff07,
- 0xff0a, 0xff0a,
- 0xff0c, 0xff0c,
- 0xff0e, 0xff0f,
- 0xff1a, 0xff1b,
- 0xff1f, 0xff20,
- 0xff3c, 0xff3c,
- 0xff61, 0xff61,
- 0xff64, 0xff65,
- 0x10100, 0x10101,
- 0x1039f, 0x1039f,
- 0x10a50, 0x10a58
-}; /* CR_Po */
-
-/* 'Ps': General Category */
-static const OnigCodePoint CR_Ps[] = {
- 67,
- 0x0028, 0x0028,
- 0x005b, 0x005b,
- 0x007b, 0x007b,
- 0x0f3a, 0x0f3a,
- 0x0f3c, 0x0f3c,
- 0x169b, 0x169b,
- 0x201a, 0x201a,
- 0x201e, 0x201e,
- 0x2045, 0x2045,
- 0x207d, 0x207d,
- 0x208d, 0x208d,
- 0x2329, 0x2329,
- 0x23b4, 0x23b4,
- 0x2768, 0x2768,
- 0x276a, 0x276a,
- 0x276c, 0x276c,
- 0x276e, 0x276e,
- 0x2770, 0x2770,
- 0x2772, 0x2772,
- 0x2774, 0x2774,
- 0x27c5, 0x27c5,
- 0x27e6, 0x27e6,
- 0x27e8, 0x27e8,
- 0x27ea, 0x27ea,
- 0x2983, 0x2983,
- 0x2985, 0x2985,
- 0x2987, 0x2987,
- 0x2989, 0x2989,
- 0x298b, 0x298b,
- 0x298d, 0x298d,
- 0x298f, 0x298f,
- 0x2991, 0x2991,
- 0x2993, 0x2993,
- 0x2995, 0x2995,
- 0x2997, 0x2997,
- 0x29d8, 0x29d8,
- 0x29da, 0x29da,
- 0x29fc, 0x29fc,
- 0x3008, 0x3008,
- 0x300a, 0x300a,
- 0x300c, 0x300c,
- 0x300e, 0x300e,
- 0x3010, 0x3010,
- 0x3014, 0x3014,
- 0x3016, 0x3016,
- 0x3018, 0x3018,
- 0x301a, 0x301a,
- 0x301d, 0x301d,
- 0xfd3e, 0xfd3e,
- 0xfe17, 0xfe17,
- 0xfe35, 0xfe35,
- 0xfe37, 0xfe37,
- 0xfe39, 0xfe39,
- 0xfe3b, 0xfe3b,
- 0xfe3d, 0xfe3d,
- 0xfe3f, 0xfe3f,
- 0xfe41, 0xfe41,
- 0xfe43, 0xfe43,
- 0xfe47, 0xfe47,
- 0xfe59, 0xfe59,
- 0xfe5b, 0xfe5b,
- 0xfe5d, 0xfe5d,
- 0xff08, 0xff08,
- 0xff3b, 0xff3b,
- 0xff5b, 0xff5b,
- 0xff5f, 0xff5f,
- 0xff62, 0xff62
-}; /* CR_Ps */
-
-/* 'S': Major Category */
-static const OnigCodePoint CR_S[] = {
- 162,
- 0x0024, 0x0024,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00a2, 0x00a9,
- 0x00ac, 0x00ac,
- 0x00ae, 0x00b1,
- 0x00b4, 0x00b4,
- 0x00b6, 0x00b6,
- 0x00b8, 0x00b8,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x02c2, 0x02c5,
- 0x02d2, 0x02df,
- 0x02e5, 0x02ed,
- 0x02ef, 0x02ff,
- 0x0374, 0x0375,
- 0x0384, 0x0385,
- 0x03f6, 0x03f6,
- 0x0482, 0x0482,
- 0x060b, 0x060b,
- 0x060e, 0x060f,
- 0x06e9, 0x06e9,
- 0x06fd, 0x06fe,
- 0x09f2, 0x09f3,
- 0x09fa, 0x09fa,
- 0x0af1, 0x0af1,
- 0x0b70, 0x0b70,
- 0x0bf3, 0x0bfa,
- 0x0e3f, 0x0e3f,
- 0x0f01, 0x0f03,
- 0x0f13, 0x0f17,
- 0x0f1a, 0x0f1f,
- 0x0f34, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fcf, 0x0fcf,
- 0x1360, 0x1360,
- 0x1390, 0x1399,
- 0x17db, 0x17db,
- 0x1940, 0x1940,
- 0x19e0, 0x19ff,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x207a, 0x207c,
- 0x208a, 0x208c,
- 0x20a0, 0x20b5,
- 0x2100, 0x2101,
- 0x2103, 0x2106,
- 0x2108, 0x2109,
- 0x2114, 0x2114,
- 0x2116, 0x2118,
- 0x211e, 0x2123,
- 0x2125, 0x2125,
- 0x2127, 0x2127,
- 0x2129, 0x2129,
- 0x212e, 0x212e,
- 0x2132, 0x2132,
- 0x213a, 0x213b,
- 0x2140, 0x2144,
- 0x214a, 0x214c,
- 0x2190, 0x2328,
- 0x232b, 0x23b3,
- 0x23b7, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x249c, 0x24e9,
- 0x2500, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2794, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27c4,
- 0x27d0, 0x27e5,
- 0x27f0, 0x2982,
- 0x2999, 0x29d7,
- 0x29dc, 0x29fb,
- 0x29fe, 0x2b13,
- 0x2ce5, 0x2cea,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3004, 0x3004,
- 0x3012, 0x3013,
- 0x3020, 0x3020,
- 0x3036, 0x3037,
- 0x303e, 0x303f,
- 0x309b, 0x309c,
- 0x3190, 0x3191,
- 0x3196, 0x319f,
- 0x31c0, 0x31cf,
- 0x3200, 0x321e,
- 0x322a, 0x3243,
- 0x3250, 0x3250,
- 0x3260, 0x327f,
- 0x328a, 0x32b0,
- 0x32c0, 0x32fe,
- 0x3300, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa490, 0xa4c6,
- 0xa700, 0xa716,
- 0xa828, 0xa82b,
- 0xfb29, 0xfb29,
- 0xfdfc, 0xfdfd,
- 0xfe62, 0xfe62,
- 0xfe64, 0xfe66,
- 0xfe69, 0xfe69,
- 0xff04, 0xff04,
- 0xff0b, 0xff0b,
- 0xff1c, 0xff1e,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xff5c, 0xff5c,
- 0xff5e, 0xff5e,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfffc, 0xfffd,
- 0x10102, 0x10102,
- 0x10137, 0x1013f,
- 0x10179, 0x10189,
- 0x103d0, 0x103d0,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d164,
- 0x1d16a, 0x1d16c,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1dd,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d300, 0x1d356,
- 0x1d6c1, 0x1d6c1,
- 0x1d6db, 0x1d6db,
- 0x1d6fb, 0x1d6fb,
- 0x1d715, 0x1d715,
- 0x1d735, 0x1d735,
- 0x1d74f, 0x1d74f,
- 0x1d76f, 0x1d76f,
- 0x1d789, 0x1d789,
- 0x1d7a9, 0x1d7a9,
- 0x1d7c3, 0x1d7c3
-}; /* CR_S */
-
-/* 'Sc': General Category */
-static const OnigCodePoint CR_Sc[] = {
- 14,
- 0x0024, 0x0024,
- 0x00a2, 0x00a5,
- 0x060b, 0x060b,
- 0x09f2, 0x09f3,
- 0x0af1, 0x0af1,
- 0x0bf9, 0x0bf9,
- 0x0e3f, 0x0e3f,
- 0x17db, 0x17db,
- 0x20a0, 0x20b5,
- 0xfdfc, 0xfdfc,
- 0xfe69, 0xfe69,
- 0xff04, 0xff04,
- 0xffe0, 0xffe1,
- 0xffe5, 0xffe6
-}; /* CR_Sc */
-
-/* 'Sk': General Category */
-static const OnigCodePoint CR_Sk[] = {
- 23,
- 0x005e, 0x005e,
- 0x0060, 0x0060,
- 0x00a8, 0x00a8,
- 0x00af, 0x00af,
- 0x00b4, 0x00b4,
- 0x00b8, 0x00b8,
- 0x02c2, 0x02c5,
- 0x02d2, 0x02df,
- 0x02e5, 0x02ed,
- 0x02ef, 0x02ff,
- 0x0374, 0x0375,
- 0x0384, 0x0385,
- 0x1fbd, 0x1fbd,
- 0x1fbf, 0x1fc1,
- 0x1fcd, 0x1fcf,
- 0x1fdd, 0x1fdf,
- 0x1fed, 0x1fef,
- 0x1ffd, 0x1ffe,
- 0x309b, 0x309c,
- 0xa700, 0xa716,
- 0xff3e, 0xff3e,
- 0xff40, 0xff40,
- 0xffe3, 0xffe3
-}; /* CR_Sk */
-
-/* 'Sm': General Category */
-static const OnigCodePoint CR_Sm[] = {
- 59,
- 0x002b, 0x002b,
- 0x003c, 0x003e,
- 0x007c, 0x007c,
- 0x007e, 0x007e,
- 0x00ac, 0x00ac,
- 0x00b1, 0x00b1,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x03f6, 0x03f6,
- 0x2044, 0x2044,
- 0x2052, 0x2052,
- 0x207a, 0x207c,
- 0x208a, 0x208c,
- 0x2140, 0x2144,
- 0x214b, 0x214b,
- 0x2190, 0x2194,
- 0x219a, 0x219b,
- 0x21a0, 0x21a0,
- 0x21a3, 0x21a3,
- 0x21a6, 0x21a6,
- 0x21ae, 0x21ae,
- 0x21ce, 0x21cf,
- 0x21d2, 0x21d2,
- 0x21d4, 0x21d4,
- 0x21f4, 0x22ff,
- 0x2308, 0x230b,
- 0x2320, 0x2321,
- 0x237c, 0x237c,
- 0x239b, 0x23b3,
- 0x25b7, 0x25b7,
- 0x25c1, 0x25c1,
- 0x25f8, 0x25ff,
- 0x266f, 0x266f,
- 0x27c0, 0x27c4,
- 0x27d0, 0x27e5,
- 0x27f0, 0x27ff,
- 0x2900, 0x2982,
- 0x2999, 0x29d7,
- 0x29dc, 0x29fb,
- 0x29fe, 0x2aff,
- 0xfb29, 0xfb29,
- 0xfe62, 0xfe62,
- 0xfe64, 0xfe66,
- 0xff0b, 0xff0b,
- 0xff1c, 0xff1e,
- 0xff5c, 0xff5c,
- 0xff5e, 0xff5e,
- 0xffe2, 0xffe2,
- 0xffe9, 0xffec,
- 0x1d6c1, 0x1d6c1,
- 0x1d6db, 0x1d6db,
- 0x1d6fb, 0x1d6fb,
- 0x1d715, 0x1d715,
- 0x1d735, 0x1d735,
- 0x1d74f, 0x1d74f,
- 0x1d76f, 0x1d76f,
- 0x1d789, 0x1d789,
- 0x1d7a9, 0x1d7a9,
- 0x1d7c3, 0x1d7c3
-}; /* CR_Sm */
-
-/* 'So': General Category */
-static const OnigCodePoint CR_So[] = {
- 120,
- 0x00a6, 0x00a7,
- 0x00a9, 0x00a9,
- 0x00ae, 0x00ae,
- 0x00b0, 0x00b0,
- 0x00b6, 0x00b6,
- 0x0482, 0x0482,
- 0x060e, 0x060f,
- 0x06e9, 0x06e9,
- 0x06fd, 0x06fe,
- 0x09fa, 0x09fa,
- 0x0b70, 0x0b70,
- 0x0bf3, 0x0bf8,
- 0x0bfa, 0x0bfa,
- 0x0f01, 0x0f03,
- 0x0f13, 0x0f17,
- 0x0f1a, 0x0f1f,
- 0x0f34, 0x0f34,
- 0x0f36, 0x0f36,
- 0x0f38, 0x0f38,
- 0x0fbe, 0x0fc5,
- 0x0fc7, 0x0fcc,
- 0x0fcf, 0x0fcf,
- 0x1360, 0x1360,
- 0x1390, 0x1399,
- 0x1940, 0x1940,
- 0x19e0, 0x19ff,
- 0x2100, 0x2101,
- 0x2103, 0x2106,
- 0x2108, 0x2109,
- 0x2114, 0x2114,
- 0x2116, 0x2118,
- 0x211e, 0x2123,
- 0x2125, 0x2125,
- 0x2127, 0x2127,
- 0x2129, 0x2129,
- 0x212e, 0x212e,
- 0x2132, 0x2132,
- 0x213a, 0x213b,
- 0x214a, 0x214a,
- 0x214c, 0x214c,
- 0x2195, 0x2199,
- 0x219c, 0x219f,
- 0x21a1, 0x21a2,
- 0x21a4, 0x21a5,
- 0x21a7, 0x21ad,
- 0x21af, 0x21cd,
- 0x21d0, 0x21d1,
- 0x21d3, 0x21d3,
- 0x21d5, 0x21f3,
- 0x2300, 0x2307,
- 0x230c, 0x231f,
- 0x2322, 0x2328,
- 0x232b, 0x237b,
- 0x237d, 0x239a,
- 0x23b7, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x249c, 0x24e9,
- 0x2500, 0x25b6,
- 0x25b8, 0x25c0,
- 0x25c2, 0x25f7,
- 0x2600, 0x266e,
- 0x2670, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2767,
- 0x2794, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x2800, 0x28ff,
- 0x2b00, 0x2b13,
- 0x2ce5, 0x2cea,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x2ff0, 0x2ffb,
- 0x3004, 0x3004,
- 0x3012, 0x3013,
- 0x3020, 0x3020,
- 0x3036, 0x3037,
- 0x303e, 0x303f,
- 0x3190, 0x3191,
- 0x3196, 0x319f,
- 0x31c0, 0x31cf,
- 0x3200, 0x321e,
- 0x322a, 0x3243,
- 0x3250, 0x3250,
- 0x3260, 0x327f,
- 0x328a, 0x32b0,
- 0x32c0, 0x32fe,
- 0x3300, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa490, 0xa4c6,
- 0xa828, 0xa82b,
- 0xfdfd, 0xfdfd,
- 0xffe4, 0xffe4,
- 0xffe8, 0xffe8,
- 0xffed, 0xffee,
- 0xfffc, 0xfffd,
- 0x10102, 0x10102,
- 0x10137, 0x1013f,
- 0x10179, 0x10189,
- 0x103d0, 0x103d0,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d164,
- 0x1d16a, 0x1d16c,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1dd,
- 0x1d200, 0x1d241,
- 0x1d245, 0x1d245,
- 0x1d300, 0x1d356
-}; /* CR_So */
-
-/* 'Z': Major Category */
-static const OnigCodePoint CR_Z[] = {
- 9,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x180e, 0x180e,
- 0x2000, 0x200a,
- 0x2028, 0x2029,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000
-}; /* CR_Z */
-
-/* 'Zl': General Category */
-static const OnigCodePoint CR_Zl[] = {
- 1,
- 0x2028, 0x2028
-}; /* CR_Zl */
-
-/* 'Zp': General Category */
-static const OnigCodePoint CR_Zp[] = {
- 1,
- 0x2029, 0x2029
-}; /* CR_Zp */
-
-/* 'Zs': General Category */
-static const OnigCodePoint CR_Zs[] = {
- 8,
- 0x0020, 0x0020,
- 0x00a0, 0x00a0,
- 0x1680, 0x1680,
- 0x180e, 0x180e,
- 0x2000, 0x200a,
- 0x202f, 0x202f,
- 0x205f, 0x205f,
- 0x3000, 0x3000
-}; /* CR_Zs */
-
-/* 'Arabic': Script */
-static const OnigCodePoint CR_Arabic[] = {
- 17,
- 0x060b, 0x060b,
- 0x060d, 0x0615,
- 0x061e, 0x061e,
- 0x0621, 0x063a,
- 0x0641, 0x064a,
- 0x0656, 0x065e,
- 0x066a, 0x066f,
- 0x0671, 0x06dc,
- 0x06de, 0x06ff,
- 0x0750, 0x076d,
- 0xfb50, 0xfbb1,
- 0xfbd3, 0xfd3d,
- 0xfd50, 0xfd8f,
- 0xfd92, 0xfdc7,
- 0xfdf0, 0xfdfc,
- 0xfe70, 0xfe74,
- 0xfe76, 0xfefc
-}; /* CR_Arabic */
-
-/* 'Armenian': Script */
-static const OnigCodePoint CR_Armenian[] = {
- 5,
- 0x0531, 0x0556,
- 0x0559, 0x055f,
- 0x0561, 0x0587,
- 0x058a, 0x058a,
- 0xfb13, 0xfb17
-}; /* CR_Armenian */
-
-/* 'Bengali': Script */
-static const OnigCodePoint CR_Bengali[] = {
- 14,
- 0x0981, 0x0983,
- 0x0985, 0x098c,
- 0x098f, 0x0990,
- 0x0993, 0x09a8,
- 0x09aa, 0x09b0,
- 0x09b2, 0x09b2,
- 0x09b6, 0x09b9,
- 0x09bc, 0x09c4,
- 0x09c7, 0x09c8,
- 0x09cb, 0x09ce,
- 0x09d7, 0x09d7,
- 0x09dc, 0x09dd,
- 0x09df, 0x09e3,
- 0x09e6, 0x09fa
-}; /* CR_Bengali */
-
-/* 'Bopomofo': Script */
-static const OnigCodePoint CR_Bopomofo[] = {
- 2,
- 0x3105, 0x312c,
- 0x31a0, 0x31b7
-}; /* CR_Bopomofo */
-
-/* 'Braille': Script */
-static const OnigCodePoint CR_Braille[] = {
- 1,
- 0x2800, 0x28ff
-}; /* CR_Braille */
-
-/* 'Buginese': Script */
-static const OnigCodePoint CR_Buginese[] = {
- 2,
- 0x1a00, 0x1a1b,
- 0x1a1e, 0x1a1f
-}; /* CR_Buginese */
-
-/* 'Buhid': Script */
-static const OnigCodePoint CR_Buhid[] = {
- 1,
- 0x1740, 0x1753
-}; /* CR_Buhid */
-
-/* 'Canadian_Aboriginal': Script */
-static const OnigCodePoint CR_Canadian_Aboriginal[] = {
- 1,
- 0x1401, 0x1676
-}; /* CR_Canadian_Aboriginal */
-
-/* 'Cherokee': Script */
-static const OnigCodePoint CR_Cherokee[] = {
- 1,
- 0x13a0, 0x13f4
-}; /* CR_Cherokee */
-
-/* 'Common': Script */
-static const OnigCodePoint CR_Common[] = {
- 126,
- 0x0000, 0x0040,
- 0x005b, 0x0060,
- 0x007b, 0x00a9,
- 0x00ab, 0x00b9,
- 0x00bb, 0x00bf,
- 0x00d7, 0x00d7,
- 0x00f7, 0x00f7,
- 0x02b9, 0x02df,
- 0x02e5, 0x02ff,
- 0x037e, 0x037e,
- 0x0387, 0x0387,
- 0x0589, 0x0589,
- 0x0600, 0x0603,
- 0x060c, 0x060c,
- 0x061b, 0x061b,
- 0x061f, 0x061f,
- 0x0640, 0x0640,
- 0x0660, 0x0669,
- 0x06dd, 0x06dd,
- 0x0964, 0x0965,
- 0x0970, 0x0970,
- 0x0e3f, 0x0e3f,
- 0x10fb, 0x10fb,
- 0x16eb, 0x16ed,
- 0x1735, 0x1736,
- 0x2000, 0x200b,
- 0x200e, 0x2063,
- 0x206a, 0x2070,
- 0x2074, 0x207e,
- 0x2080, 0x208e,
- 0x20a0, 0x20b5,
- 0x2100, 0x2125,
- 0x2127, 0x2129,
- 0x212c, 0x214c,
- 0x2153, 0x2183,
- 0x2190, 0x23db,
- 0x2400, 0x2426,
- 0x2440, 0x244a,
- 0x2460, 0x269c,
- 0x26a0, 0x26b1,
- 0x2701, 0x2704,
- 0x2706, 0x2709,
- 0x270c, 0x2727,
- 0x2729, 0x274b,
- 0x274d, 0x274d,
- 0x274f, 0x2752,
- 0x2756, 0x2756,
- 0x2758, 0x275e,
- 0x2761, 0x2794,
- 0x2798, 0x27af,
- 0x27b1, 0x27be,
- 0x27c0, 0x27c6,
- 0x27d0, 0x27eb,
- 0x27f0, 0x27ff,
- 0x2900, 0x2b13,
- 0x2e00, 0x2e17,
- 0x2e1c, 0x2e1d,
- 0x2ff0, 0x2ffb,
- 0x3000, 0x3004,
- 0x3006, 0x3006,
- 0x3008, 0x3020,
- 0x3030, 0x3037,
- 0x303c, 0x303f,
- 0x309b, 0x309c,
- 0x30a0, 0x30a0,
- 0x30fb, 0x30fc,
- 0x3190, 0x319f,
- 0x31c0, 0x31cf,
- 0x3220, 0x3243,
- 0x3250, 0x325f,
- 0x327e, 0x32fe,
- 0x3300, 0x33ff,
- 0x4dc0, 0x4dff,
- 0xa700, 0xa716,
- 0xe000, 0xf8ff,
- 0xfd3e, 0xfd3f,
- 0xfdfd, 0xfdfd,
- 0xfe10, 0xfe19,
- 0xfe30, 0xfe52,
- 0xfe54, 0xfe66,
- 0xfe68, 0xfe6b,
- 0xfeff, 0xfeff,
- 0xff01, 0xff20,
- 0xff3b, 0xff40,
- 0xff5b, 0xff65,
- 0xff70, 0xff70,
- 0xff9e, 0xff9f,
- 0xffe0, 0xffe6,
- 0xffe8, 0xffee,
- 0xfff9, 0xfffd,
- 0x10100, 0x10102,
- 0x10107, 0x10133,
- 0x10137, 0x1013f,
- 0x1d000, 0x1d0f5,
- 0x1d100, 0x1d126,
- 0x1d12a, 0x1d166,
- 0x1d16a, 0x1d17a,
- 0x1d183, 0x1d184,
- 0x1d18c, 0x1d1a9,
- 0x1d1ae, 0x1d1dd,
- 0x1d300, 0x1d356,
- 0x1d400, 0x1d454,
- 0x1d456, 0x1d49c,
- 0x1d49e, 0x1d49f,
- 0x1d4a2, 0x1d4a2,
- 0x1d4a5, 0x1d4a6,
- 0x1d4a9, 0x1d4ac,
- 0x1d4ae, 0x1d4b9,
- 0x1d4bb, 0x1d4bb,
- 0x1d4bd, 0x1d4c3,
- 0x1d4c5, 0x1d505,
- 0x1d507, 0x1d50a,
- 0x1d50d, 0x1d514,
- 0x1d516, 0x1d51c,
- 0x1d51e, 0x1d539,
- 0x1d53b, 0x1d53e,
- 0x1d540, 0x1d544,
- 0x1d546, 0x1d546,
- 0x1d54a, 0x1d550,
- 0x1d552, 0x1d6a5,
- 0x1d6a8, 0x1d7c9,
- 0x1d7ce, 0x1d7ff,
- 0xe0001, 0xe0001,
- 0xe0020, 0xe007f,
- 0xf0000, 0xffffd,
- 0x100000, 0x10fffd
-}; /* CR_Common */
-
-/* 'Coptic': Script */
-static const OnigCodePoint CR_Coptic[] = {
- 3,
- 0x03e2, 0x03ef,
- 0x2c80, 0x2cea,
- 0x2cf9, 0x2cff
-}; /* CR_Coptic */
-
-/* 'Cypriot': Script */
-static const OnigCodePoint CR_Cypriot[] = {
- 6,
- 0x10800, 0x10805,
- 0x10808, 0x10808,
- 0x1080a, 0x10835,
- 0x10837, 0x10838,
- 0x1083c, 0x1083c,
- 0x1083f, 0x1083f
-}; /* CR_Cypriot */
-
-/* 'Cyrillic': Script */
-static const OnigCodePoint CR_Cyrillic[] = {
- 6,
- 0x0400, 0x0486,
- 0x0488, 0x04ce,
- 0x04d0, 0x04f9,
- 0x0500, 0x050f,
- 0x1d2b, 0x1d2b,
- 0x1d78, 0x1d78
-}; /* CR_Cyrillic */
-
-/* 'Deseret': Script */
-static const OnigCodePoint CR_Deseret[] = {
- 1,
- 0x10400, 0x1044f
-}; /* CR_Deseret */
-
-/* 'Devanagari': Script */
-static const OnigCodePoint CR_Devanagari[] = {
- 6,
- 0x0901, 0x0939,
- 0x093c, 0x094d,
- 0x0950, 0x0954,
- 0x0958, 0x0963,
- 0x0966, 0x096f,
- 0x097d, 0x097d
-}; /* CR_Devanagari */
-
-/* 'Ethiopic': Script */
-static const OnigCodePoint CR_Ethiopic[] = {
- 27,
- 0x1200, 0x1248,
- 0x124a, 0x124d,
- 0x1250, 0x1256,
- 0x1258, 0x1258,
- 0x125a, 0x125d,
- 0x1260, 0x1288,
- 0x128a, 0x128d,
- 0x1290, 0x12b0,
- 0x12b2, 0x12b5,
- 0x12b8, 0x12be,
- 0x12c0, 0x12c0,
- 0x12c2, 0x12c5,
- 0x12c8, 0x12d6,
- 0x12d8, 0x1310,
- 0x1312, 0x1315,
- 0x1318, 0x135a,
- 0x135f, 0x137c,
- 0x1380, 0x1399,
- 0x2d80, 0x2d96,
- 0x2da0, 0x2da6,
- 0x2da8, 0x2dae,
- 0x2db0, 0x2db6,
- 0x2db8, 0x2dbe,
- 0x2dc0, 0x2dc6,
- 0x2dc8, 0x2dce,
- 0x2dd0, 0x2dd6,
- 0x2dd8, 0x2dde
-}; /* CR_Ethiopic */
-
-/* 'Georgian': Script */
-static const OnigCodePoint CR_Georgian[] = {
- 4,
- 0x10a0, 0x10c5,
- 0x10d0, 0x10fa,
- 0x10fc, 0x10fc,
- 0x2d00, 0x2d25
-}; /* CR_Georgian */
-
-/* 'Glagolitic': Script */
-static const OnigCodePoint CR_Glagolitic[] = {
- 2,
- 0x2c00, 0x2c2e,
- 0x2c30, 0x2c5e
-}; /* CR_Glagolitic */
-
-/* 'Gothic': Script */
-static const OnigCodePoint CR_Gothic[] = {
- 1,
- 0x10330, 0x1034a
-}; /* CR_Gothic */
-
-/* 'Greek': Script */
-static const OnigCodePoint CR_Greek[] = {
- 31,
- 0x0374, 0x0375,
- 0x037a, 0x037a,
- 0x0384, 0x0386,
- 0x0388, 0x038a,
- 0x038c, 0x038c,
- 0x038e, 0x03a1,
- 0x03a3, 0x03ce,
- 0x03d0, 0x03e1,
- 0x03f0, 0x03ff,
- 0x1d26, 0x1d2a,
- 0x1d5d, 0x1d61,
- 0x1d66, 0x1d6a,
- 0x1f00, 0x1f15,
- 0x1f18, 0x1f1d,
- 0x1f20, 0x1f45,
- 0x1f48, 0x1f4d,
- 0x1f50, 0x1f57,
- 0x1f59, 0x1f59,
- 0x1f5b, 0x1f5b,
- 0x1f5d, 0x1f5d,
- 0x1f5f, 0x1f7d,
- 0x1f80, 0x1fb4,
- 0x1fb6, 0x1fc4,
- 0x1fc6, 0x1fd3,
- 0x1fd6, 0x1fdb,
- 0x1fdd, 0x1fef,
- 0x1ff2, 0x1ff4,
- 0x1ff6, 0x1ffe,
- 0x2126, 0x2126,
- 0x10140, 0x1018a,
- 0x1d200, 0x1d245
-}; /* CR_Greek */
-
-/* 'Gujarati': Script */
-static const OnigCodePoint CR_Gujarati[] = {
- 14,
- 0x0a81, 0x0a83,
- 0x0a85, 0x0a8d,
- 0x0a8f, 0x0a91,
- 0x0a93, 0x0aa8,
- 0x0aaa, 0x0ab0,
- 0x0ab2, 0x0ab3,
- 0x0ab5, 0x0ab9,
- 0x0abc, 0x0ac5,
- 0x0ac7, 0x0ac9,
- 0x0acb, 0x0acd,
- 0x0ad0, 0x0ad0,
- 0x0ae0, 0x0ae3,
- 0x0ae6, 0x0aef,
- 0x0af1, 0x0af1
-}; /* CR_Gujarati */
-
-/* 'Gurmukhi': Script */
-static const OnigCodePoint CR_Gurmukhi[] = {
- 15,
- 0x0a01, 0x0a03,
- 0x0a05, 0x0a0a,
- 0x0a0f, 0x0a10,
- 0x0a13, 0x0a28,
- 0x0a2a, 0x0a30,
- 0x0a32, 0x0a33,
- 0x0a35, 0x0a36,
- 0x0a38, 0x0a39,
- 0x0a3c, 0x0a3c,
- 0x0a3e, 0x0a42,
- 0x0a47, 0x0a48,
- 0x0a4b, 0x0a4d,
- 0x0a59, 0x0a5c,
- 0x0a5e, 0x0a5e,
- 0x0a66, 0x0a74
-}; /* CR_Gurmukhi */
-
-/* 'Han': Script */
-static const OnigCodePoint CR_Han[] = {
- 14,
- 0x2e80, 0x2e99,
- 0x2e9b, 0x2ef3,
- 0x2f00, 0x2fd5,
- 0x3005, 0x3005,
- 0x3007, 0x3007,
- 0x3021, 0x3029,
- 0x3038, 0x303b,
- 0x3400, 0x4db5,
- 0x4e00, 0x9fbb,
- 0xf900, 0xfa2d,
- 0xfa30, 0xfa6a,
- 0xfa70, 0xfad9,
- 0x20000, 0x2a6d6,
- 0x2f800, 0x2fa1d
-}; /* CR_Han */
-
-/* 'Hangul': Script */
-static const OnigCodePoint CR_Hangul[] = {
- 12,
- 0x1100, 0x1159,
- 0x115f, 0x11a2,
- 0x11a8, 0x11f9,
- 0x3131, 0x318e,
- 0x3200, 0x321e,
- 0x3260, 0x327d,
- 0xac00, 0xd7a3,
- 0xffa0, 0xffbe,
- 0xffc2, 0xffc7,
- 0xffca, 0xffcf,
- 0xffd2, 0xffd7,
- 0xffda, 0xffdc
-}; /* CR_Hangul */
-
-/* 'Hanunoo': Script */
-static const OnigCodePoint CR_Hanunoo[] = {
- 1,
- 0x1720, 0x1734
-}; /* CR_Hanunoo */
-
-/* 'Hebrew': Script */
-static const OnigCodePoint CR_Hebrew[] = {
- 10,
- 0x0591, 0x05b9,
- 0x05bb, 0x05c7,
- 0x05d0, 0x05ea,
- 0x05f0, 0x05f4,
- 0xfb1d, 0xfb36,
- 0xfb38, 0xfb3c,
- 0xfb3e, 0xfb3e,
- 0xfb40, 0xfb41,
- 0xfb43, 0xfb44,
- 0xfb46, 0xfb4f
-}; /* CR_Hebrew */
-
-/* 'Hiragana': Script */
-static const OnigCodePoint CR_Hiragana[] = {
- 2,
- 0x3041, 0x3096,
- 0x309d, 0x309f
-}; /* CR_Hiragana */
-
-/* 'Inherited': Script */
-static const OnigCodePoint CR_Inherited[] = {
- 15,
- 0x0300, 0x036f,
- 0x064b, 0x0655,
- 0x0670, 0x0670,
- 0x1dc0, 0x1dc3,
- 0x200c, 0x200d,
- 0x20d0, 0x20eb,
- 0x302a, 0x302f,
- 0x3099, 0x309a,
- 0xfe00, 0xfe0f,
- 0xfe20, 0xfe23,
- 0x1d167, 0x1d169,
- 0x1d17b, 0x1d182,
- 0x1d185, 0x1d18b,
- 0x1d1aa, 0x1d1ad,
- 0xe0100, 0xe01ef
-}; /* CR_Inherited */
-
-/* 'Kannada': Script */
-static const OnigCodePoint CR_Kannada[] = {
- 13,
- 0x0c82, 0x0c83,
- 0x0c85, 0x0c8c,
- 0x0c8e, 0x0c90,
- 0x0c92, 0x0ca8,
- 0x0caa, 0x0cb3,
- 0x0cb5, 0x0cb9,
- 0x0cbc, 0x0cc4,
- 0x0cc6, 0x0cc8,
- 0x0cca, 0x0ccd,
- 0x0cd5, 0x0cd6,
- 0x0cde, 0x0cde,
- 0x0ce0, 0x0ce1,
- 0x0ce6, 0x0cef
-}; /* CR_Kannada */
-
-/* 'Katakana': Script */
-static const OnigCodePoint CR_Katakana[] = {
- 5,
- 0x30a1, 0x30fa,
- 0x30fd, 0x30ff,
- 0x31f0, 0x31ff,
- 0xff66, 0xff6f,
- 0xff71, 0xff9d
-}; /* CR_Katakana */
-
-/* 'Kharoshthi': Script */
-static const OnigCodePoint CR_Kharoshthi[] = {
- 8,
- 0x10a00, 0x10a03,
- 0x10a05, 0x10a06,
- 0x10a0c, 0x10a13,
- 0x10a15, 0x10a17,
- 0x10a19, 0x10a33,
- 0x10a38, 0x10a3a,
- 0x10a3f, 0x10a47,
- 0x10a50, 0x10a58
-}; /* CR_Kharoshthi */
-
-/* 'Khmer': Script */
-static const OnigCodePoint CR_Khmer[] = {
- 4,
- 0x1780, 0x17dd,
- 0x17e0, 0x17e9,
- 0x17f0, 0x17f9,
- 0x19e0, 0x19ff
-}; /* CR_Khmer */
-
-/* 'Lao': Script */
-static const OnigCodePoint CR_Lao[] = {
- 18,
- 0x0e81, 0x0e82,
- 0x0e84, 0x0e84,
- 0x0e87, 0x0e88,
- 0x0e8a, 0x0e8a,
- 0x0e8d, 0x0e8d,
- 0x0e94, 0x0e97,
- 0x0e99, 0x0e9f,
- 0x0ea1, 0x0ea3,
- 0x0ea5, 0x0ea5,
- 0x0ea7, 0x0ea7,
- 0x0eaa, 0x0eab,
- 0x0ead, 0x0eb9,
- 0x0ebb, 0x0ebd,
- 0x0ec0, 0x0ec4,
- 0x0ec6, 0x0ec6,
- 0x0ec8, 0x0ecd,
- 0x0ed0, 0x0ed9,
- 0x0edc, 0x0edd
-}; /* CR_Lao */
-
-/* 'Latin': Script */
-static const OnigCodePoint CR_Latin[] = {
- 23,
- 0x0041, 0x005a,
- 0x0061, 0x007a,
- 0x00aa, 0x00aa,
- 0x00ba, 0x00ba,
- 0x00c0, 0x00d6,
- 0x00d8, 0x00f6,
- 0x00f8, 0x0241,
- 0x0250, 0x02b8,
- 0x02e0, 0x02e4,
- 0x1d00, 0x1d25,
- 0x1d2c, 0x1d5c,
- 0x1d62, 0x1d65,
- 0x1d6b, 0x1d77,
- 0x1d79, 0x1dbf,
- 0x1e00, 0x1e9b,
- 0x1ea0, 0x1ef9,
- 0x2071, 0x2071,
- 0x207f, 0x207f,
- 0x2090, 0x2094,
- 0x212a, 0x212b,
- 0xfb00, 0xfb06,
- 0xff21, 0xff3a,
- 0xff41, 0xff5a
-}; /* CR_Latin */
-
-/* 'Limbu': Script */
-static const OnigCodePoint CR_Limbu[] = {
- 5,
- 0x1900, 0x191c,
- 0x1920, 0x192b,
- 0x1930, 0x193b,
- 0x1940, 0x1940,
- 0x1944, 0x194f
-}; /* CR_Limbu */
-
-/* 'Linear_B': Script */
-static const OnigCodePoint CR_Linear_B[] = {
- 7,
- 0x10000, 0x1000b,
- 0x1000d, 0x10026,
- 0x10028, 0x1003a,
- 0x1003c, 0x1003d,
- 0x1003f, 0x1004d,
- 0x10050, 0x1005d,
- 0x10080, 0x100fa
-}; /* CR_Linear_B */
-
-/* 'Malayalam': Script */
-static const OnigCodePoint CR_Malayalam[] = {
- 11,
- 0x0d02, 0x0d03,
- 0x0d05, 0x0d0c,
- 0x0d0e, 0x0d10,
- 0x0d12, 0x0d28,
- 0x0d2a, 0x0d39,
- 0x0d3e, 0x0d43,
- 0x0d46, 0x0d48,
- 0x0d4a, 0x0d4d,
- 0x0d57, 0x0d57,
- 0x0d60, 0x0d61,
- 0x0d66, 0x0d6f
-}; /* CR_Malayalam */
-
-/* 'Mongolian': Script */
-static const OnigCodePoint CR_Mongolian[] = {
- 4,
- 0x1800, 0x180e,
- 0x1810, 0x1819,
- 0x1820, 0x1877,
- 0x1880, 0x18a9
-}; /* CR_Mongolian */
-
-/* 'Myanmar': Script */
-static const OnigCodePoint CR_Myanmar[] = {
- 6,
- 0x1000, 0x1021,
- 0x1023, 0x1027,
- 0x1029, 0x102a,
- 0x102c, 0x1032,
- 0x1036, 0x1039,
- 0x1040, 0x1059
-}; /* CR_Myanmar */
-
-/* 'New_Tai_Lue': Script */
-static const OnigCodePoint CR_New_Tai_Lue[] = {
- 4,
- 0x1980, 0x19a9,
- 0x19b0, 0x19c9,
- 0x19d0, 0x19d9,
- 0x19de, 0x19df
-}; /* CR_New_Tai_Lue */
-
-/* 'Ogham': Script */
-static const OnigCodePoint CR_Ogham[] = {
- 1,
- 0x1680, 0x169c
-}; /* CR_Ogham */
-
-/* 'Old_Italic': Script */
-static const OnigCodePoint CR_Old_Italic[] = {
- 2,
- 0x10300, 0x1031e,
- 0x10320, 0x10323
-}; /* CR_Old_Italic */
-
-/* 'Old_Persian': Script */
-static const OnigCodePoint CR_Old_Persian[] = {
- 2,
- 0x103a0, 0x103c3,
- 0x103c8, 0x103d5
-}; /* CR_Old_Persian */
-
-/* 'Oriya': Script */
-static const OnigCodePoint CR_Oriya[] = {
- 14,
- 0x0b01, 0x0b03,
- 0x0b05, 0x0b0c,
- 0x0b0f, 0x0b10,
- 0x0b13, 0x0b28,
- 0x0b2a, 0x0b30,
- 0x0b32, 0x0b33,
- 0x0b35, 0x0b39,
- 0x0b3c, 0x0b43,
- 0x0b47, 0x0b48,
- 0x0b4b, 0x0b4d,
- 0x0b56, 0x0b57,
- 0x0b5c, 0x0b5d,
- 0x0b5f, 0x0b61,
- 0x0b66, 0x0b71
-}; /* CR_Oriya */
-
-/* 'Osmanya': Script */
-static const OnigCodePoint CR_Osmanya[] = {
- 2,
- 0x10480, 0x1049d,
- 0x104a0, 0x104a9
-}; /* CR_Osmanya */
-
-/* 'Runic': Script */
-static const OnigCodePoint CR_Runic[] = {
- 2,
- 0x16a0, 0x16ea,
- 0x16ee, 0x16f0
-}; /* CR_Runic */
-
-/* 'Shavian': Script */
-static const OnigCodePoint CR_Shavian[] = {
- 1,
- 0x10450, 0x1047f
-}; /* CR_Shavian */
-
-/* 'Sinhala': Script */
-static const OnigCodePoint CR_Sinhala[] = {
- 11,
- 0x0d82, 0x0d83,
- 0x0d85, 0x0d96,
- 0x0d9a, 0x0db1,
- 0x0db3, 0x0dbb,
- 0x0dbd, 0x0dbd,
- 0x0dc0, 0x0dc6,
- 0x0dca, 0x0dca,
- 0x0dcf, 0x0dd4,
- 0x0dd6, 0x0dd6,
- 0x0dd8, 0x0ddf,
- 0x0df2, 0x0df4
-}; /* CR_Sinhala */
-
-/* 'Syloti_Nagri': Script */
-static const OnigCodePoint CR_Syloti_Nagri[] = {
- 1,
- 0xa800, 0xa82b
-}; /* CR_Syloti_Nagri */
-
-/* 'Syriac': Script */
-static const OnigCodePoint CR_Syriac[] = {
- 3,
- 0x0700, 0x070d,
- 0x070f, 0x074a,
- 0x074d, 0x074f
-}; /* CR_Syriac */
-
-/* 'Tagalog': Script */
-static const OnigCodePoint CR_Tagalog[] = {
- 2,
- 0x1700, 0x170c,
- 0x170e, 0x1714
-}; /* CR_Tagalog */
-
-/* 'Tagbanwa': Script */
-static const OnigCodePoint CR_Tagbanwa[] = {
- 3,
- 0x1760, 0x176c,
- 0x176e, 0x1770,
- 0x1772, 0x1773
-}; /* CR_Tagbanwa */
-
-/* 'Tai_Le': Script */
-static const OnigCodePoint CR_Tai_Le[] = {
- 2,
- 0x1950, 0x196d,
- 0x1970, 0x1974
-}; /* CR_Tai_Le */
-
-/* 'Tamil': Script */
-static const OnigCodePoint CR_Tamil[] = {
- 15,
- 0x0b82, 0x0b83,
- 0x0b85, 0x0b8a,
- 0x0b8e, 0x0b90,
- 0x0b92, 0x0b95,
- 0x0b99, 0x0b9a,
- 0x0b9c, 0x0b9c,
- 0x0b9e, 0x0b9f,
- 0x0ba3, 0x0ba4,
- 0x0ba8, 0x0baa,
- 0x0bae, 0x0bb9,
- 0x0bbe, 0x0bc2,
- 0x0bc6, 0x0bc8,
- 0x0bca, 0x0bcd,
- 0x0bd7, 0x0bd7,
- 0x0be6, 0x0bfa
-}; /* CR_Tamil */
-
-/* 'Telugu': Script */
-static const OnigCodePoint CR_Telugu[] = {
- 12,
- 0x0c01, 0x0c03,
- 0x0c05, 0x0c0c,
- 0x0c0e, 0x0c10,
- 0x0c12, 0x0c28,
- 0x0c2a, 0x0c33,
- 0x0c35, 0x0c39,
- 0x0c3e, 0x0c44,
- 0x0c46, 0x0c48,
- 0x0c4a, 0x0c4d,
- 0x0c55, 0x0c56,
- 0x0c60, 0x0c61,
- 0x0c66, 0x0c6f
-}; /* CR_Telugu */
-
-/* 'Thaana': Script */
-static const OnigCodePoint CR_Thaana[] = {
- 1,
- 0x0780, 0x07b1
-}; /* CR_Thaana */
-
-/* 'Thai': Script */
-static const OnigCodePoint CR_Thai[] = {
- 2,
- 0x0e01, 0x0e3a,
- 0x0e40, 0x0e5b
-}; /* CR_Thai */
-
-/* 'Tibetan': Script */
-static const OnigCodePoint CR_Tibetan[] = {
- 7,
- 0x0f00, 0x0f47,
- 0x0f49, 0x0f6a,
- 0x0f71, 0x0f8b,
- 0x0f90, 0x0f97,
- 0x0f99, 0x0fbc,
- 0x0fbe, 0x0fcc,
- 0x0fcf, 0x0fd1
-}; /* CR_Tibetan */
-
-/* 'Tifinagh': Script */
-static const OnigCodePoint CR_Tifinagh[] = {
- 2,
- 0x2d30, 0x2d65,
- 0x2d6f, 0x2d6f
-}; /* CR_Tifinagh */
-
-/* 'Ugaritic': Script */
-static const OnigCodePoint CR_Ugaritic[] = {
- 2,
- 0x10380, 0x1039d,
- 0x1039f, 0x1039f
-}; /* CR_Ugaritic */
-
-/* 'Yi': Script */
-static const OnigCodePoint CR_Yi[] = {
- 2,
- 0xa000, 0xa48c,
- 0xa490, 0xa4c6
-}; /* CR_Yi */
-
-
-#endif /* USE_UNICODE_PROPERTIES */
-
-
-typedef struct {
- int n;
- OnigCodePoint code[3];
-} CodePointList3;
-
-typedef struct {
- OnigCodePoint from;
- CodePointList3 to;
-} CaseFold_11_Type;
-
-typedef struct {
- OnigCodePoint from;
- CodePointList3 to;
-} CaseUnfold_11_Type;
-
-typedef struct {
- int n;
- OnigCodePoint code[2];
-} CodePointList2;
-
-typedef struct {
- OnigCodePoint from[2];
- CodePointList2 to;
-} CaseUnfold_12_Type;
-
-typedef struct {
- OnigCodePoint from[3];
- CodePointList2 to;
-} CaseUnfold_13_Type;
-
-static const CaseFold_11_Type CaseFold[] = {
- { 0x0041, {1, {0x0061}}},
- { 0x0042, {1, {0x0062}}},
- { 0x0043, {1, {0x0063}}},
- { 0x0044, {1, {0x0064}}},
- { 0x0045, {1, {0x0065}}},
- { 0x0046, {1, {0x0066}}},
- { 0x0047, {1, {0x0067}}},
- { 0x0048, {1, {0x0068}}},
- { 0x004a, {1, {0x006a}}},
- { 0x004b, {1, {0x006b}}},
- { 0x004c, {1, {0x006c}}},
- { 0x004d, {1, {0x006d}}},
- { 0x004e, {1, {0x006e}}},
- { 0x004f, {1, {0x006f}}},
- { 0x0050, {1, {0x0070}}},
- { 0x0051, {1, {0x0071}}},
- { 0x0052, {1, {0x0072}}},
- { 0x0053, {1, {0x0073}}},
- { 0x0054, {1, {0x0074}}},
- { 0x0055, {1, {0x0075}}},
- { 0x0056, {1, {0x0076}}},
- { 0x0057, {1, {0x0077}}},
- { 0x0058, {1, {0x0078}}},
- { 0x0059, {1, {0x0079}}},
- { 0x005a, {1, {0x007a}}},
- { 0x00b5, {1, {0x03bc}}},
- { 0x00c0, {1, {0x00e0}}},
- { 0x00c1, {1, {0x00e1}}},
- { 0x00c2, {1, {0x00e2}}},
- { 0x00c3, {1, {0x00e3}}},
- { 0x00c4, {1, {0x00e4}}},
- { 0x00c5, {1, {0x00e5}}},
- { 0x00c6, {1, {0x00e6}}},
- { 0x00c7, {1, {0x00e7}}},
- { 0x00c8, {1, {0x00e8}}},
- { 0x00c9, {1, {0x00e9}}},
- { 0x00ca, {1, {0x00ea}}},
- { 0x00cb, {1, {0x00eb}}},
- { 0x00cc, {1, {0x00ec}}},
- { 0x00cd, {1, {0x00ed}}},
- { 0x00ce, {1, {0x00ee}}},
- { 0x00cf, {1, {0x00ef}}},
- { 0x00d0, {1, {0x00f0}}},
- { 0x00d1, {1, {0x00f1}}},
- { 0x00d2, {1, {0x00f2}}},
- { 0x00d3, {1, {0x00f3}}},
- { 0x00d4, {1, {0x00f4}}},
- { 0x00d5, {1, {0x00f5}}},
- { 0x00d6, {1, {0x00f6}}},
- { 0x00d8, {1, {0x00f8}}},
- { 0x00d9, {1, {0x00f9}}},
- { 0x00da, {1, {0x00fa}}},
- { 0x00db, {1, {0x00fb}}},
- { 0x00dc, {1, {0x00fc}}},
- { 0x00dd, {1, {0x00fd}}},
- { 0x00de, {1, {0x00fe}}},
- { 0x00df, {2, {0x0073, 0x0073}}},
- { 0x0100, {1, {0x0101}}},
- { 0x0102, {1, {0x0103}}},
- { 0x0104, {1, {0x0105}}},
- { 0x0106, {1, {0x0107}}},
- { 0x0108, {1, {0x0109}}},
- { 0x010a, {1, {0x010b}}},
- { 0x010c, {1, {0x010d}}},
- { 0x010e, {1, {0x010f}}},
- { 0x0110, {1, {0x0111}}},
- { 0x0112, {1, {0x0113}}},
- { 0x0114, {1, {0x0115}}},
- { 0x0116, {1, {0x0117}}},
- { 0x0118, {1, {0x0119}}},
- { 0x011a, {1, {0x011b}}},
- { 0x011c, {1, {0x011d}}},
- { 0x011e, {1, {0x011f}}},
- { 0x0120, {1, {0x0121}}},
- { 0x0122, {1, {0x0123}}},
- { 0x0124, {1, {0x0125}}},
- { 0x0126, {1, {0x0127}}},
- { 0x0128, {1, {0x0129}}},
- { 0x012a, {1, {0x012b}}},
- { 0x012c, {1, {0x012d}}},
- { 0x012e, {1, {0x012f}}},
- { 0x0132, {1, {0x0133}}},
- { 0x0134, {1, {0x0135}}},
- { 0x0136, {1, {0x0137}}},
- { 0x0139, {1, {0x013a}}},
- { 0x013b, {1, {0x013c}}},
- { 0x013d, {1, {0x013e}}},
- { 0x013f, {1, {0x0140}}},
- { 0x0141, {1, {0x0142}}},
- { 0x0143, {1, {0x0144}}},
- { 0x0145, {1, {0x0146}}},
- { 0x0147, {1, {0x0148}}},
- { 0x0149, {2, {0x02bc, 0x006e}}},
- { 0x014a, {1, {0x014b}}},
- { 0x014c, {1, {0x014d}}},
- { 0x014e, {1, {0x014f}}},
- { 0x0150, {1, {0x0151}}},
- { 0x0152, {1, {0x0153}}},
- { 0x0154, {1, {0x0155}}},
- { 0x0156, {1, {0x0157}}},
- { 0x0158, {1, {0x0159}}},
- { 0x015a, {1, {0x015b}}},
- { 0x015c, {1, {0x015d}}},
- { 0x015e, {1, {0x015f}}},
- { 0x0160, {1, {0x0161}}},
- { 0x0162, {1, {0x0163}}},
- { 0x0164, {1, {0x0165}}},
- { 0x0166, {1, {0x0167}}},
- { 0x0168, {1, {0x0169}}},
- { 0x016a, {1, {0x016b}}},
- { 0x016c, {1, {0x016d}}},
- { 0x016e, {1, {0x016f}}},
- { 0x0170, {1, {0x0171}}},
- { 0x0172, {1, {0x0173}}},
- { 0x0174, {1, {0x0175}}},
- { 0x0176, {1, {0x0177}}},
- { 0x0178, {1, {0x00ff}}},
- { 0x0179, {1, {0x017a}}},
- { 0x017b, {1, {0x017c}}},
- { 0x017d, {1, {0x017e}}},
- { 0x017f, {1, {0x0073}}},
- { 0x0181, {1, {0x0253}}},
- { 0x0182, {1, {0x0183}}},
- { 0x0184, {1, {0x0185}}},
- { 0x0186, {1, {0x0254}}},
- { 0x0187, {1, {0x0188}}},
- { 0x0189, {1, {0x0256}}},
- { 0x018a, {1, {0x0257}}},
- { 0x018b, {1, {0x018c}}},
- { 0x018e, {1, {0x01dd}}},
- { 0x018f, {1, {0x0259}}},
- { 0x0190, {1, {0x025b}}},
- { 0x0191, {1, {0x0192}}},
- { 0x0193, {1, {0x0260}}},
- { 0x0194, {1, {0x0263}}},
- { 0x0196, {1, {0x0269}}},
- { 0x0197, {1, {0x0268}}},
- { 0x0198, {1, {0x0199}}},
- { 0x019c, {1, {0x026f}}},
- { 0x019d, {1, {0x0272}}},
- { 0x019f, {1, {0x0275}}},
- { 0x01a0, {1, {0x01a1}}},
- { 0x01a2, {1, {0x01a3}}},
- { 0x01a4, {1, {0x01a5}}},
- { 0x01a6, {1, {0x0280}}},
- { 0x01a7, {1, {0x01a8}}},
- { 0x01a9, {1, {0x0283}}},
- { 0x01ac, {1, {0x01ad}}},
- { 0x01ae, {1, {0x0288}}},
- { 0x01af, {1, {0x01b0}}},
- { 0x01b1, {1, {0x028a}}},
- { 0x01b2, {1, {0x028b}}},
- { 0x01b3, {1, {0x01b4}}},
- { 0x01b5, {1, {0x01b6}}},
- { 0x01b7, {1, {0x0292}}},
- { 0x01b8, {1, {0x01b9}}},
- { 0x01bc, {1, {0x01bd}}},
- { 0x01c4, {1, {0x01c6}}},
- { 0x01c5, {1, {0x01c6}}},
- { 0x01c7, {1, {0x01c9}}},
- { 0x01c8, {1, {0x01c9}}},
- { 0x01ca, {1, {0x01cc}}},
- { 0x01cb, {1, {0x01cc}}},
- { 0x01cd, {1, {0x01ce}}},
- { 0x01cf, {1, {0x01d0}}},
- { 0x01d1, {1, {0x01d2}}},
- { 0x01d3, {1, {0x01d4}}},
- { 0x01d5, {1, {0x01d6}}},
- { 0x01d7, {1, {0x01d8}}},
- { 0x01d9, {1, {0x01da}}},
- { 0x01db, {1, {0x01dc}}},
- { 0x01de, {1, {0x01df}}},
- { 0x01e0, {1, {0x01e1}}},
- { 0x01e2, {1, {0x01e3}}},
- { 0x01e4, {1, {0x01e5}}},
- { 0x01e6, {1, {0x01e7}}},
- { 0x01e8, {1, {0x01e9}}},
- { 0x01ea, {1, {0x01eb}}},
- { 0x01ec, {1, {0x01ed}}},
- { 0x01ee, {1, {0x01ef}}},
- { 0x01f0, {2, {0x006a, 0x030c}}},
- { 0x01f1, {1, {0x01f3}}},
- { 0x01f2, {1, {0x01f3}}},
- { 0x01f4, {1, {0x01f5}}},
- { 0x01f6, {1, {0x0195}}},
- { 0x01f7, {1, {0x01bf}}},
- { 0x01f8, {1, {0x01f9}}},
- { 0x01fa, {1, {0x01fb}}},
- { 0x01fc, {1, {0x01fd}}},
- { 0x01fe, {1, {0x01ff}}},
- { 0x0200, {1, {0x0201}}},
- { 0x0202, {1, {0x0203}}},
- { 0x0204, {1, {0x0205}}},
- { 0x0206, {1, {0x0207}}},
- { 0x0208, {1, {0x0209}}},
- { 0x020a, {1, {0x020b}}},
- { 0x020c, {1, {0x020d}}},
- { 0x020e, {1, {0x020f}}},
- { 0x0210, {1, {0x0211}}},
- { 0x0212, {1, {0x0213}}},
- { 0x0214, {1, {0x0215}}},
- { 0x0216, {1, {0x0217}}},
- { 0x0218, {1, {0x0219}}},
- { 0x021a, {1, {0x021b}}},
- { 0x021c, {1, {0x021d}}},
- { 0x021e, {1, {0x021f}}},
- { 0x0220, {1, {0x019e}}},
- { 0x0222, {1, {0x0223}}},
- { 0x0224, {1, {0x0225}}},
- { 0x0226, {1, {0x0227}}},
- { 0x0228, {1, {0x0229}}},
- { 0x022a, {1, {0x022b}}},
- { 0x022c, {1, {0x022d}}},
- { 0x022e, {1, {0x022f}}},
- { 0x0230, {1, {0x0231}}},
- { 0x0232, {1, {0x0233}}},
- { 0x023b, {1, {0x023c}}},
- { 0x023d, {1, {0x019a}}},
- { 0x0241, {1, {0x0294}}},
- { 0x0345, {1, {0x03b9}}},
- { 0x0386, {1, {0x03ac}}},
- { 0x0388, {1, {0x03ad}}},
- { 0x0389, {1, {0x03ae}}},
- { 0x038a, {1, {0x03af}}},
- { 0x038c, {1, {0x03cc}}},
- { 0x038e, {1, {0x03cd}}},
- { 0x038f, {1, {0x03ce}}},
- { 0x0390, {3, {0x03b9, 0x0308, 0x0301}}},
- { 0x0391, {1, {0x03b1}}},
- { 0x0392, {1, {0x03b2}}},
- { 0x0393, {1, {0x03b3}}},
- { 0x0394, {1, {0x03b4}}},
- { 0x0395, {1, {0x03b5}}},
- { 0x0396, {1, {0x03b6}}},
- { 0x0397, {1, {0x03b7}}},
- { 0x0398, {1, {0x03b8}}},
- { 0x0399, {1, {0x03b9}}},
- { 0x039a, {1, {0x03ba}}},
- { 0x039b, {1, {0x03bb}}},
- { 0x039c, {1, {0x03bc}}},
- { 0x039d, {1, {0x03bd}}},
- { 0x039e, {1, {0x03be}}},
- { 0x039f, {1, {0x03bf}}},
- { 0x03a0, {1, {0x03c0}}},
- { 0x03a1, {1, {0x03c1}}},
- { 0x03a3, {1, {0x03c3}}},
- { 0x03a4, {1, {0x03c4}}},
- { 0x03a5, {1, {0x03c5}}},
- { 0x03a6, {1, {0x03c6}}},
- { 0x03a7, {1, {0x03c7}}},
- { 0x03a8, {1, {0x03c8}}},
- { 0x03a9, {1, {0x03c9}}},
- { 0x03aa, {1, {0x03ca}}},
- { 0x03ab, {1, {0x03cb}}},
- { 0x03b0, {3, {0x03c5, 0x0308, 0x0301}}},
- { 0x03c2, {1, {0x03c3}}},
- { 0x03d0, {1, {0x03b2}}},
- { 0x03d1, {1, {0x03b8}}},
- { 0x03d5, {1, {0x03c6}}},
- { 0x03d6, {1, {0x03c0}}},
- { 0x03d8, {1, {0x03d9}}},
- { 0x03da, {1, {0x03db}}},
- { 0x03dc, {1, {0x03dd}}},
- { 0x03de, {1, {0x03df}}},
- { 0x03e0, {1, {0x03e1}}},
- { 0x03e2, {1, {0x03e3}}},
- { 0x03e4, {1, {0x03e5}}},
- { 0x03e6, {1, {0x03e7}}},
- { 0x03e8, {1, {0x03e9}}},
- { 0x03ea, {1, {0x03eb}}},
- { 0x03ec, {1, {0x03ed}}},
- { 0x03ee, {1, {0x03ef}}},
- { 0x03f0, {1, {0x03ba}}},
- { 0x03f1, {1, {0x03c1}}},
- { 0x03f4, {1, {0x03b8}}},
- { 0x03f5, {1, {0x03b5}}},
- { 0x03f7, {1, {0x03f8}}},
- { 0x03f9, {1, {0x03f2}}},
- { 0x03fa, {1, {0x03fb}}},
- { 0x0400, {1, {0x0450}}},
- { 0x0401, {1, {0x0451}}},
- { 0x0402, {1, {0x0452}}},
- { 0x0403, {1, {0x0453}}},
- { 0x0404, {1, {0x0454}}},
- { 0x0405, {1, {0x0455}}},
- { 0x0406, {1, {0x0456}}},
- { 0x0407, {1, {0x0457}}},
- { 0x0408, {1, {0x0458}}},
- { 0x0409, {1, {0x0459}}},
- { 0x040a, {1, {0x045a}}},
- { 0x040b, {1, {0x045b}}},
- { 0x040c, {1, {0x045c}}},
- { 0x040d, {1, {0x045d}}},
- { 0x040e, {1, {0x045e}}},
- { 0x040f, {1, {0x045f}}},
- { 0x0410, {1, {0x0430}}},
- { 0x0411, {1, {0x0431}}},
- { 0x0412, {1, {0x0432}}},
- { 0x0413, {1, {0x0433}}},
- { 0x0414, {1, {0x0434}}},
- { 0x0415, {1, {0x0435}}},
- { 0x0416, {1, {0x0436}}},
- { 0x0417, {1, {0x0437}}},
- { 0x0418, {1, {0x0438}}},
- { 0x0419, {1, {0x0439}}},
- { 0x041a, {1, {0x043a}}},
- { 0x041b, {1, {0x043b}}},
- { 0x041c, {1, {0x043c}}},
- { 0x041d, {1, {0x043d}}},
- { 0x041e, {1, {0x043e}}},
- { 0x041f, {1, {0x043f}}},
- { 0x0420, {1, {0x0440}}},
- { 0x0421, {1, {0x0441}}},
- { 0x0422, {1, {0x0442}}},
- { 0x0423, {1, {0x0443}}},
- { 0x0424, {1, {0x0444}}},
- { 0x0425, {1, {0x0445}}},
- { 0x0426, {1, {0x0446}}},
- { 0x0427, {1, {0x0447}}},
- { 0x0428, {1, {0x0448}}},
- { 0x0429, {1, {0x0449}}},
- { 0x042a, {1, {0x044a}}},
- { 0x042b, {1, {0x044b}}},
- { 0x042c, {1, {0x044c}}},
- { 0x042d, {1, {0x044d}}},
- { 0x042e, {1, {0x044e}}},
- { 0x042f, {1, {0x044f}}},
- { 0x0460, {1, {0x0461}}},
- { 0x0462, {1, {0x0463}}},
- { 0x0464, {1, {0x0465}}},
- { 0x0466, {1, {0x0467}}},
- { 0x0468, {1, {0x0469}}},
- { 0x046a, {1, {0x046b}}},
- { 0x046c, {1, {0x046d}}},
- { 0x046e, {1, {0x046f}}},
- { 0x0470, {1, {0x0471}}},
- { 0x0472, {1, {0x0473}}},
- { 0x0474, {1, {0x0475}}},
- { 0x0476, {1, {0x0477}}},
- { 0x0478, {1, {0x0479}}},
- { 0x047a, {1, {0x047b}}},
- { 0x047c, {1, {0x047d}}},
- { 0x047e, {1, {0x047f}}},
- { 0x0480, {1, {0x0481}}},
- { 0x048a, {1, {0x048b}}},
- { 0x048c, {1, {0x048d}}},
- { 0x048e, {1, {0x048f}}},
- { 0x0490, {1, {0x0491}}},
- { 0x0492, {1, {0x0493}}},
- { 0x0494, {1, {0x0495}}},
- { 0x0496, {1, {0x0497}}},
- { 0x0498, {1, {0x0499}}},
- { 0x049a, {1, {0x049b}}},
- { 0x049c, {1, {0x049d}}},
- { 0x049e, {1, {0x049f}}},
- { 0x04a0, {1, {0x04a1}}},
- { 0x04a2, {1, {0x04a3}}},
- { 0x04a4, {1, {0x04a5}}},
- { 0x04a6, {1, {0x04a7}}},
- { 0x04a8, {1, {0x04a9}}},
- { 0x04aa, {1, {0x04ab}}},
- { 0x04ac, {1, {0x04ad}}},
- { 0x04ae, {1, {0x04af}}},
- { 0x04b0, {1, {0x04b1}}},
- { 0x04b2, {1, {0x04b3}}},
- { 0x04b4, {1, {0x04b5}}},
- { 0x04b6, {1, {0x04b7}}},
- { 0x04b8, {1, {0x04b9}}},
- { 0x04ba, {1, {0x04bb}}},
- { 0x04bc, {1, {0x04bd}}},
- { 0x04be, {1, {0x04bf}}},
- { 0x04c1, {1, {0x04c2}}},
- { 0x04c3, {1, {0x04c4}}},
- { 0x04c5, {1, {0x04c6}}},
- { 0x04c7, {1, {0x04c8}}},
- { 0x04c9, {1, {0x04ca}}},
- { 0x04cb, {1, {0x04cc}}},
- { 0x04cd, {1, {0x04ce}}},
- { 0x04d0, {1, {0x04d1}}},
- { 0x04d2, {1, {0x04d3}}},
- { 0x04d4, {1, {0x04d5}}},
- { 0x04d6, {1, {0x04d7}}},
- { 0x04d8, {1, {0x04d9}}},
- { 0x04da, {1, {0x04db}}},
- { 0x04dc, {1, {0x04dd}}},
- { 0x04de, {1, {0x04df}}},
- { 0x04e0, {1, {0x04e1}}},
- { 0x04e2, {1, {0x04e3}}},
- { 0x04e4, {1, {0x04e5}}},
- { 0x04e6, {1, {0x04e7}}},
- { 0x04e8, {1, {0x04e9}}},
- { 0x04ea, {1, {0x04eb}}},
- { 0x04ec, {1, {0x04ed}}},
- { 0x04ee, {1, {0x04ef}}},
- { 0x04f0, {1, {0x04f1}}},
- { 0x04f2, {1, {0x04f3}}},
- { 0x04f4, {1, {0x04f5}}},
- { 0x04f6, {1, {0x04f7}}},
- { 0x04f8, {1, {0x04f9}}},
- { 0x0500, {1, {0x0501}}},
- { 0x0502, {1, {0x0503}}},
- { 0x0504, {1, {0x0505}}},
- { 0x0506, {1, {0x0507}}},
- { 0x0508, {1, {0x0509}}},
- { 0x050a, {1, {0x050b}}},
- { 0x050c, {1, {0x050d}}},
- { 0x050e, {1, {0x050f}}},
- { 0x0531, {1, {0x0561}}},
- { 0x0532, {1, {0x0562}}},
- { 0x0533, {1, {0x0563}}},
- { 0x0534, {1, {0x0564}}},
- { 0x0535, {1, {0x0565}}},
- { 0x0536, {1, {0x0566}}},
- { 0x0537, {1, {0x0567}}},
- { 0x0538, {1, {0x0568}}},
- { 0x0539, {1, {0x0569}}},
- { 0x053a, {1, {0x056a}}},
- { 0x053b, {1, {0x056b}}},
- { 0x053c, {1, {0x056c}}},
- { 0x053d, {1, {0x056d}}},
- { 0x053e, {1, {0x056e}}},
- { 0x053f, {1, {0x056f}}},
- { 0x0540, {1, {0x0570}}},
- { 0x0541, {1, {0x0571}}},
- { 0x0542, {1, {0x0572}}},
- { 0x0543, {1, {0x0573}}},
- { 0x0544, {1, {0x0574}}},
- { 0x0545, {1, {0x0575}}},
- { 0x0546, {1, {0x0576}}},
- { 0x0547, {1, {0x0577}}},
- { 0x0548, {1, {0x0578}}},
- { 0x0549, {1, {0x0579}}},
- { 0x054a, {1, {0x057a}}},
- { 0x054b, {1, {0x057b}}},
- { 0x054c, {1, {0x057c}}},
- { 0x054d, {1, {0x057d}}},
- { 0x054e, {1, {0x057e}}},
- { 0x054f, {1, {0x057f}}},
- { 0x0550, {1, {0x0580}}},
- { 0x0551, {1, {0x0581}}},
- { 0x0552, {1, {0x0582}}},
- { 0x0553, {1, {0x0583}}},
- { 0x0554, {1, {0x0584}}},
- { 0x0555, {1, {0x0585}}},
- { 0x0556, {1, {0x0586}}},
- { 0x0587, {2, {0x0565, 0x0582}}},
- { 0x10a0, {1, {0x2d00}}},
- { 0x10a1, {1, {0x2d01}}},
- { 0x10a2, {1, {0x2d02}}},
- { 0x10a3, {1, {0x2d03}}},
- { 0x10a4, {1, {0x2d04}}},
- { 0x10a5, {1, {0x2d05}}},
- { 0x10a6, {1, {0x2d06}}},
- { 0x10a7, {1, {0x2d07}}},
- { 0x10a8, {1, {0x2d08}}},
- { 0x10a9, {1, {0x2d09}}},
- { 0x10aa, {1, {0x2d0a}}},
- { 0x10ab, {1, {0x2d0b}}},
- { 0x10ac, {1, {0x2d0c}}},
- { 0x10ad, {1, {0x2d0d}}},
- { 0x10ae, {1, {0x2d0e}}},
- { 0x10af, {1, {0x2d0f}}},
- { 0x10b0, {1, {0x2d10}}},
- { 0x10b1, {1, {0x2d11}}},
- { 0x10b2, {1, {0x2d12}}},
- { 0x10b3, {1, {0x2d13}}},
- { 0x10b4, {1, {0x2d14}}},
- { 0x10b5, {1, {0x2d15}}},
- { 0x10b6, {1, {0x2d16}}},
- { 0x10b7, {1, {0x2d17}}},
- { 0x10b8, {1, {0x2d18}}},
- { 0x10b9, {1, {0x2d19}}},
- { 0x10ba, {1, {0x2d1a}}},
- { 0x10bb, {1, {0x2d1b}}},
- { 0x10bc, {1, {0x2d1c}}},
- { 0x10bd, {1, {0x2d1d}}},
- { 0x10be, {1, {0x2d1e}}},
- { 0x10bf, {1, {0x2d1f}}},
- { 0x10c0, {1, {0x2d20}}},
- { 0x10c1, {1, {0x2d21}}},
- { 0x10c2, {1, {0x2d22}}},
- { 0x10c3, {1, {0x2d23}}},
- { 0x10c4, {1, {0x2d24}}},
- { 0x10c5, {1, {0x2d25}}},
- { 0x1e00, {1, {0x1e01}}},
- { 0x1e02, {1, {0x1e03}}},
- { 0x1e04, {1, {0x1e05}}},
- { 0x1e06, {1, {0x1e07}}},
- { 0x1e08, {1, {0x1e09}}},
- { 0x1e0a, {1, {0x1e0b}}},
- { 0x1e0c, {1, {0x1e0d}}},
- { 0x1e0e, {1, {0x1e0f}}},
- { 0x1e10, {1, {0x1e11}}},
- { 0x1e12, {1, {0x1e13}}},
- { 0x1e14, {1, {0x1e15}}},
- { 0x1e16, {1, {0x1e17}}},
- { 0x1e18, {1, {0x1e19}}},
- { 0x1e1a, {1, {0x1e1b}}},
- { 0x1e1c, {1, {0x1e1d}}},
- { 0x1e1e, {1, {0x1e1f}}},
- { 0x1e20, {1, {0x1e21}}},
- { 0x1e22, {1, {0x1e23}}},
- { 0x1e24, {1, {0x1e25}}},
- { 0x1e26, {1, {0x1e27}}},
- { 0x1e28, {1, {0x1e29}}},
- { 0x1e2a, {1, {0x1e2b}}},
- { 0x1e2c, {1, {0x1e2d}}},
- { 0x1e2e, {1, {0x1e2f}}},
- { 0x1e30, {1, {0x1e31}}},
- { 0x1e32, {1, {0x1e33}}},
- { 0x1e34, {1, {0x1e35}}},
- { 0x1e36, {1, {0x1e37}}},
- { 0x1e38, {1, {0x1e39}}},
- { 0x1e3a, {1, {0x1e3b}}},
- { 0x1e3c, {1, {0x1e3d}}},
- { 0x1e3e, {1, {0x1e3f}}},
- { 0x1e40, {1, {0x1e41}}},
- { 0x1e42, {1, {0x1e43}}},
- { 0x1e44, {1, {0x1e45}}},
- { 0x1e46, {1, {0x1e47}}},
- { 0x1e48, {1, {0x1e49}}},
- { 0x1e4a, {1, {0x1e4b}}},
- { 0x1e4c, {1, {0x1e4d}}},
- { 0x1e4e, {1, {0x1e4f}}},
- { 0x1e50, {1, {0x1e51}}},
- { 0x1e52, {1, {0x1e53}}},
- { 0x1e54, {1, {0x1e55}}},
- { 0x1e56, {1, {0x1e57}}},
- { 0x1e58, {1, {0x1e59}}},
- { 0x1e5a, {1, {0x1e5b}}},
- { 0x1e5c, {1, {0x1e5d}}},
- { 0x1e5e, {1, {0x1e5f}}},
- { 0x1e60, {1, {0x1e61}}},
- { 0x1e62, {1, {0x1e63}}},
- { 0x1e64, {1, {0x1e65}}},
- { 0x1e66, {1, {0x1e67}}},
- { 0x1e68, {1, {0x1e69}}},
- { 0x1e6a, {1, {0x1e6b}}},
- { 0x1e6c, {1, {0x1e6d}}},
- { 0x1e6e, {1, {0x1e6f}}},
- { 0x1e70, {1, {0x1e71}}},
- { 0x1e72, {1, {0x1e73}}},
- { 0x1e74, {1, {0x1e75}}},
- { 0x1e76, {1, {0x1e77}}},
- { 0x1e78, {1, {0x1e79}}},
- { 0x1e7a, {1, {0x1e7b}}},
- { 0x1e7c, {1, {0x1e7d}}},
- { 0x1e7e, {1, {0x1e7f}}},
- { 0x1e80, {1, {0x1e81}}},
- { 0x1e82, {1, {0x1e83}}},
- { 0x1e84, {1, {0x1e85}}},
- { 0x1e86, {1, {0x1e87}}},
- { 0x1e88, {1, {0x1e89}}},
- { 0x1e8a, {1, {0x1e8b}}},
- { 0x1e8c, {1, {0x1e8d}}},
- { 0x1e8e, {1, {0x1e8f}}},
- { 0x1e90, {1, {0x1e91}}},
- { 0x1e92, {1, {0x1e93}}},
- { 0x1e94, {1, {0x1e95}}},
- { 0x1e96, {2, {0x0068, 0x0331}}},
- { 0x1e97, {2, {0x0074, 0x0308}}},
- { 0x1e98, {2, {0x0077, 0x030a}}},
- { 0x1e99, {2, {0x0079, 0x030a}}},
- { 0x1e9a, {2, {0x0061, 0x02be}}},
- { 0x1e9b, {1, {0x1e61}}},
- { 0x1ea0, {1, {0x1ea1}}},
- { 0x1ea2, {1, {0x1ea3}}},
- { 0x1ea4, {1, {0x1ea5}}},
- { 0x1ea6, {1, {0x1ea7}}},
- { 0x1ea8, {1, {0x1ea9}}},
- { 0x1eaa, {1, {0x1eab}}},
- { 0x1eac, {1, {0x1ead}}},
- { 0x1eae, {1, {0x1eaf}}},
- { 0x1eb0, {1, {0x1eb1}}},
- { 0x1eb2, {1, {0x1eb3}}},
- { 0x1eb4, {1, {0x1eb5}}},
- { 0x1eb6, {1, {0x1eb7}}},
- { 0x1eb8, {1, {0x1eb9}}},
- { 0x1eba, {1, {0x1ebb}}},
- { 0x1ebc, {1, {0x1ebd}}},
- { 0x1ebe, {1, {0x1ebf}}},
- { 0x1ec0, {1, {0x1ec1}}},
- { 0x1ec2, {1, {0x1ec3}}},
- { 0x1ec4, {1, {0x1ec5}}},
- { 0x1ec6, {1, {0x1ec7}}},
- { 0x1ec8, {1, {0x1ec9}}},
- { 0x1eca, {1, {0x1ecb}}},
- { 0x1ecc, {1, {0x1ecd}}},
- { 0x1ece, {1, {0x1ecf}}},
- { 0x1ed0, {1, {0x1ed1}}},
- { 0x1ed2, {1, {0x1ed3}}},
- { 0x1ed4, {1, {0x1ed5}}},
- { 0x1ed6, {1, {0x1ed7}}},
- { 0x1ed8, {1, {0x1ed9}}},
- { 0x1eda, {1, {0x1edb}}},
- { 0x1edc, {1, {0x1edd}}},
- { 0x1ede, {1, {0x1edf}}},
- { 0x1ee0, {1, {0x1ee1}}},
- { 0x1ee2, {1, {0x1ee3}}},
- { 0x1ee4, {1, {0x1ee5}}},
- { 0x1ee6, {1, {0x1ee7}}},
- { 0x1ee8, {1, {0x1ee9}}},
- { 0x1eea, {1, {0x1eeb}}},
- { 0x1eec, {1, {0x1eed}}},
- { 0x1eee, {1, {0x1eef}}},
- { 0x1ef0, {1, {0x1ef1}}},
- { 0x1ef2, {1, {0x1ef3}}},
- { 0x1ef4, {1, {0x1ef5}}},
- { 0x1ef6, {1, {0x1ef7}}},
- { 0x1ef8, {1, {0x1ef9}}},
- { 0x1f08, {1, {0x1f00}}},
- { 0x1f09, {1, {0x1f01}}},
- { 0x1f0a, {1, {0x1f02}}},
- { 0x1f0b, {1, {0x1f03}}},
- { 0x1f0c, {1, {0x1f04}}},
- { 0x1f0d, {1, {0x1f05}}},
- { 0x1f0e, {1, {0x1f06}}},
- { 0x1f0f, {1, {0x1f07}}},
- { 0x1f18, {1, {0x1f10}}},
- { 0x1f19, {1, {0x1f11}}},
- { 0x1f1a, {1, {0x1f12}}},
- { 0x1f1b, {1, {0x1f13}}},
- { 0x1f1c, {1, {0x1f14}}},
- { 0x1f1d, {1, {0x1f15}}},
- { 0x1f28, {1, {0x1f20}}},
- { 0x1f29, {1, {0x1f21}}},
- { 0x1f2a, {1, {0x1f22}}},
- { 0x1f2b, {1, {0x1f23}}},
- { 0x1f2c, {1, {0x1f24}}},
- { 0x1f2d, {1, {0x1f25}}},
- { 0x1f2e, {1, {0x1f26}}},
- { 0x1f2f, {1, {0x1f27}}},
- { 0x1f38, {1, {0x1f30}}},
- { 0x1f39, {1, {0x1f31}}},
- { 0x1f3a, {1, {0x1f32}}},
- { 0x1f3b, {1, {0x1f33}}},
- { 0x1f3c, {1, {0x1f34}}},
- { 0x1f3d, {1, {0x1f35}}},
- { 0x1f3e, {1, {0x1f36}}},
- { 0x1f3f, {1, {0x1f37}}},
- { 0x1f48, {1, {0x1f40}}},
- { 0x1f49, {1, {0x1f41}}},
- { 0x1f4a, {1, {0x1f42}}},
- { 0x1f4b, {1, {0x1f43}}},
- { 0x1f4c, {1, {0x1f44}}},
- { 0x1f4d, {1, {0x1f45}}},
- { 0x1f50, {2, {0x03c5, 0x0313}}},
- { 0x1f52, {3, {0x03c5, 0x0313, 0x0300}}},
- { 0x1f54, {3, {0x03c5, 0x0313, 0x0301}}},
- { 0x1f56, {3, {0x03c5, 0x0313, 0x0342}}},
- { 0x1f59, {1, {0x1f51}}},
- { 0x1f5b, {1, {0x1f53}}},
- { 0x1f5d, {1, {0x1f55}}},
- { 0x1f5f, {1, {0x1f57}}},
- { 0x1f68, {1, {0x1f60}}},
- { 0x1f69, {1, {0x1f61}}},
- { 0x1f6a, {1, {0x1f62}}},
- { 0x1f6b, {1, {0x1f63}}},
- { 0x1f6c, {1, {0x1f64}}},
- { 0x1f6d, {1, {0x1f65}}},
- { 0x1f6e, {1, {0x1f66}}},
- { 0x1f6f, {1, {0x1f67}}},
- { 0x1f80, {2, {0x1f00, 0x03b9}}},
- { 0x1f81, {2, {0x1f01, 0x03b9}}},
- { 0x1f82, {2, {0x1f02, 0x03b9}}},
- { 0x1f83, {2, {0x1f03, 0x03b9}}},
- { 0x1f84, {2, {0x1f04, 0x03b9}}},
- { 0x1f85, {2, {0x1f05, 0x03b9}}},
- { 0x1f86, {2, {0x1f06, 0x03b9}}},
- { 0x1f87, {2, {0x1f07, 0x03b9}}},
- { 0x1f88, {2, {0x1f00, 0x03b9}}},
- { 0x1f89, {2, {0x1f01, 0x03b9}}},
- { 0x1f8a, {2, {0x1f02, 0x03b9}}},
- { 0x1f8b, {2, {0x1f03, 0x03b9}}},
- { 0x1f8c, {2, {0x1f04, 0x03b9}}},
- { 0x1f8d, {2, {0x1f05, 0x03b9}}},
- { 0x1f8e, {2, {0x1f06, 0x03b9}}},
- { 0x1f8f, {2, {0x1f07, 0x03b9}}},
- { 0x1f90, {2, {0x1f20, 0x03b9}}},
- { 0x1f91, {2, {0x1f21, 0x03b9}}},
- { 0x1f92, {2, {0x1f22, 0x03b9}}},
- { 0x1f93, {2, {0x1f23, 0x03b9}}},
- { 0x1f94, {2, {0x1f24, 0x03b9}}},
- { 0x1f95, {2, {0x1f25, 0x03b9}}},
- { 0x1f96, {2, {0x1f26, 0x03b9}}},
- { 0x1f97, {2, {0x1f27, 0x03b9}}},
- { 0x1f98, {2, {0x1f20, 0x03b9}}},
- { 0x1f99, {2, {0x1f21, 0x03b9}}},
- { 0x1f9a, {2, {0x1f22, 0x03b9}}},
- { 0x1f9b, {2, {0x1f23, 0x03b9}}},
- { 0x1f9c, {2, {0x1f24, 0x03b9}}},
- { 0x1f9d, {2, {0x1f25, 0x03b9}}},
- { 0x1f9e, {2, {0x1f26, 0x03b9}}},
- { 0x1f9f, {2, {0x1f27, 0x03b9}}},
- { 0x1fa0, {2, {0x1f60, 0x03b9}}},
- { 0x1fa1, {2, {0x1f61, 0x03b9}}},
- { 0x1fa2, {2, {0x1f62, 0x03b9}}},
- { 0x1fa3, {2, {0x1f63, 0x03b9}}},
- { 0x1fa4, {2, {0x1f64, 0x03b9}}},
- { 0x1fa5, {2, {0x1f65, 0x03b9}}},
- { 0x1fa6, {2, {0x1f66, 0x03b9}}},
- { 0x1fa7, {2, {0x1f67, 0x03b9}}},
- { 0x1fa8, {2, {0x1f60, 0x03b9}}},
- { 0x1fa9, {2, {0x1f61, 0x03b9}}},
- { 0x1faa, {2, {0x1f62, 0x03b9}}},
- { 0x1fab, {2, {0x1f63, 0x03b9}}},
- { 0x1fac, {2, {0x1f64, 0x03b9}}},
- { 0x1fad, {2, {0x1f65, 0x03b9}}},
- { 0x1fae, {2, {0x1f66, 0x03b9}}},
- { 0x1faf, {2, {0x1f67, 0x03b9}}},
- { 0x1fb2, {2, {0x1f70, 0x03b9}}},
- { 0x1fb3, {2, {0x03b1, 0x03b9}}},
- { 0x1fb4, {2, {0x03ac, 0x03b9}}},
- { 0x1fb6, {2, {0x03b1, 0x0342}}},
- { 0x1fb7, {3, {0x03b1, 0x0342, 0x03b9}}},
- { 0x1fb8, {1, {0x1fb0}}},
- { 0x1fb9, {1, {0x1fb1}}},
- { 0x1fba, {1, {0x1f70}}},
- { 0x1fbb, {1, {0x1f71}}},
- { 0x1fbc, {2, {0x03b1, 0x03b9}}},
- { 0x1fbe, {1, {0x03b9}}},
- { 0x1fc2, {2, {0x1f74, 0x03b9}}},
- { 0x1fc3, {2, {0x03b7, 0x03b9}}},
- { 0x1fc4, {2, {0x03ae, 0x03b9}}},
- { 0x1fc6, {2, {0x03b7, 0x0342}}},
- { 0x1fc7, {3, {0x03b7, 0x0342, 0x03b9}}},
- { 0x1fc8, {1, {0x1f72}}},
- { 0x1fc9, {1, {0x1f73}}},
- { 0x1fca, {1, {0x1f74}}},
- { 0x1fcb, {1, {0x1f75}}},
- { 0x1fcc, {2, {0x03b7, 0x03b9}}},
- { 0x1fd2, {3, {0x03b9, 0x0308, 0x0300}}},
- { 0x1fd3, {3, {0x03b9, 0x0308, 0x0301}}},
- { 0x1fd6, {2, {0x03b9, 0x0342}}},
- { 0x1fd7, {3, {0x03b9, 0x0308, 0x0342}}},
- { 0x1fd8, {1, {0x1fd0}}},
- { 0x1fd9, {1, {0x1fd1}}},
- { 0x1fda, {1, {0x1f76}}},
- { 0x1fdb, {1, {0x1f77}}},
- { 0x1fe2, {3, {0x03c5, 0x0308, 0x0300}}},
- { 0x1fe3, {3, {0x03c5, 0x0308, 0x0301}}},
- { 0x1fe4, {2, {0x03c1, 0x0313}}},
- { 0x1fe6, {2, {0x03c5, 0x0342}}},
- { 0x1fe7, {3, {0x03c5, 0x0308, 0x0342}}},
- { 0x1fe8, {1, {0x1fe0}}},
- { 0x1fe9, {1, {0x1fe1}}},
- { 0x1fea, {1, {0x1f7a}}},
- { 0x1feb, {1, {0x1f7b}}},
- { 0x1fec, {1, {0x1fe5}}},
- { 0x1ff2, {2, {0x1f7c, 0x03b9}}},
- { 0x1ff3, {2, {0x03c9, 0x03b9}}},
- { 0x1ff4, {2, {0x03ce, 0x03b9}}},
- { 0x1ff6, {2, {0x03c9, 0x0342}}},
- { 0x1ff7, {3, {0x03c9, 0x0342, 0x03b9}}},
- { 0x1ff8, {1, {0x1f78}}},
- { 0x1ff9, {1, {0x1f79}}},
- { 0x1ffa, {1, {0x1f7c}}},
- { 0x1ffb, {1, {0x1f7d}}},
- { 0x1ffc, {2, {0x03c9, 0x03b9}}},
- { 0x2126, {1, {0x03c9}}},
- { 0x212a, {1, {0x006b}}},
- { 0x212b, {1, {0x00e5}}},
- { 0x2160, {1, {0x2170}}},
- { 0x2161, {1, {0x2171}}},
- { 0x2162, {1, {0x2172}}},
- { 0x2163, {1, {0x2173}}},
- { 0x2164, {1, {0x2174}}},
- { 0x2165, {1, {0x2175}}},
- { 0x2166, {1, {0x2176}}},
- { 0x2167, {1, {0x2177}}},
- { 0x2168, {1, {0x2178}}},
- { 0x2169, {1, {0x2179}}},
- { 0x216a, {1, {0x217a}}},
- { 0x216b, {1, {0x217b}}},
- { 0x216c, {1, {0x217c}}},
- { 0x216d, {1, {0x217d}}},
- { 0x216e, {1, {0x217e}}},
- { 0x216f, {1, {0x217f}}},
- { 0x24b6, {1, {0x24d0}}},
- { 0x24b7, {1, {0x24d1}}},
- { 0x24b8, {1, {0x24d2}}},
- { 0x24b9, {1, {0x24d3}}},
- { 0x24ba, {1, {0x24d4}}},
- { 0x24bb, {1, {0x24d5}}},
- { 0x24bc, {1, {0x24d6}}},
- { 0x24bd, {1, {0x24d7}}},
- { 0x24be, {1, {0x24d8}}},
- { 0x24bf, {1, {0x24d9}}},
- { 0x24c0, {1, {0x24da}}},
- { 0x24c1, {1, {0x24db}}},
- { 0x24c2, {1, {0x24dc}}},
- { 0x24c3, {1, {0x24dd}}},
- { 0x24c4, {1, {0x24de}}},
- { 0x24c5, {1, {0x24df}}},
- { 0x24c6, {1, {0x24e0}}},
- { 0x24c7, {1, {0x24e1}}},
- { 0x24c8, {1, {0x24e2}}},
- { 0x24c9, {1, {0x24e3}}},
- { 0x24ca, {1, {0x24e4}}},
- { 0x24cb, {1, {0x24e5}}},
- { 0x24cc, {1, {0x24e6}}},
- { 0x24cd, {1, {0x24e7}}},
- { 0x24ce, {1, {0x24e8}}},
- { 0x24cf, {1, {0x24e9}}},
- { 0x2c00, {1, {0x2c30}}},
- { 0x2c01, {1, {0x2c31}}},
- { 0x2c02, {1, {0x2c32}}},
- { 0x2c03, {1, {0x2c33}}},
- { 0x2c04, {1, {0x2c34}}},
- { 0x2c05, {1, {0x2c35}}},
- { 0x2c06, {1, {0x2c36}}},
- { 0x2c07, {1, {0x2c37}}},
- { 0x2c08, {1, {0x2c38}}},
- { 0x2c09, {1, {0x2c39}}},
- { 0x2c0a, {1, {0x2c3a}}},
- { 0x2c0b, {1, {0x2c3b}}},
- { 0x2c0c, {1, {0x2c3c}}},
- { 0x2c0d, {1, {0x2c3d}}},
- { 0x2c0e, {1, {0x2c3e}}},
- { 0x2c0f, {1, {0x2c3f}}},
- { 0x2c10, {1, {0x2c40}}},
- { 0x2c11, {1, {0x2c41}}},
- { 0x2c12, {1, {0x2c42}}},
- { 0x2c13, {1, {0x2c43}}},
- { 0x2c14, {1, {0x2c44}}},
- { 0x2c15, {1, {0x2c45}}},
- { 0x2c16, {1, {0x2c46}}},
- { 0x2c17, {1, {0x2c47}}},
- { 0x2c18, {1, {0x2c48}}},
- { 0x2c19, {1, {0x2c49}}},
- { 0x2c1a, {1, {0x2c4a}}},
- { 0x2c1b, {1, {0x2c4b}}},
- { 0x2c1c, {1, {0x2c4c}}},
- { 0x2c1d, {1, {0x2c4d}}},
- { 0x2c1e, {1, {0x2c4e}}},
- { 0x2c1f, {1, {0x2c4f}}},
- { 0x2c20, {1, {0x2c50}}},
- { 0x2c21, {1, {0x2c51}}},
- { 0x2c22, {1, {0x2c52}}},
- { 0x2c23, {1, {0x2c53}}},
- { 0x2c24, {1, {0x2c54}}},
- { 0x2c25, {1, {0x2c55}}},
- { 0x2c26, {1, {0x2c56}}},
- { 0x2c27, {1, {0x2c57}}},
- { 0x2c28, {1, {0x2c58}}},
- { 0x2c29, {1, {0x2c59}}},
- { 0x2c2a, {1, {0x2c5a}}},
- { 0x2c2b, {1, {0x2c5b}}},
- { 0x2c2c, {1, {0x2c5c}}},
- { 0x2c2d, {1, {0x2c5d}}},
- { 0x2c2e, {1, {0x2c5e}}},
- { 0x2c80, {1, {0x2c81}}},
- { 0x2c82, {1, {0x2c83}}},
- { 0x2c84, {1, {0x2c85}}},
- { 0x2c86, {1, {0x2c87}}},
- { 0x2c88, {1, {0x2c89}}},
- { 0x2c8a, {1, {0x2c8b}}},
- { 0x2c8c, {1, {0x2c8d}}},
- { 0x2c8e, {1, {0x2c8f}}},
- { 0x2c90, {1, {0x2c91}}},
- { 0x2c92, {1, {0x2c93}}},
- { 0x2c94, {1, {0x2c95}}},
- { 0x2c96, {1, {0x2c97}}},
- { 0x2c98, {1, {0x2c99}}},
- { 0x2c9a, {1, {0x2c9b}}},
- { 0x2c9c, {1, {0x2c9d}}},
- { 0x2c9e, {1, {0x2c9f}}},
- { 0x2ca0, {1, {0x2ca1}}},
- { 0x2ca2, {1, {0x2ca3}}},
- { 0x2ca4, {1, {0x2ca5}}},
- { 0x2ca6, {1, {0x2ca7}}},
- { 0x2ca8, {1, {0x2ca9}}},
- { 0x2caa, {1, {0x2cab}}},
- { 0x2cac, {1, {0x2cad}}},
- { 0x2cae, {1, {0x2caf}}},
- { 0x2cb0, {1, {0x2cb1}}},
- { 0x2cb2, {1, {0x2cb3}}},
- { 0x2cb4, {1, {0x2cb5}}},
- { 0x2cb6, {1, {0x2cb7}}},
- { 0x2cb8, {1, {0x2cb9}}},
- { 0x2cba, {1, {0x2cbb}}},
- { 0x2cbc, {1, {0x2cbd}}},
- { 0x2cbe, {1, {0x2cbf}}},
- { 0x2cc0, {1, {0x2cc1}}},
- { 0x2cc2, {1, {0x2cc3}}},
- { 0x2cc4, {1, {0x2cc5}}},
- { 0x2cc6, {1, {0x2cc7}}},
- { 0x2cc8, {1, {0x2cc9}}},
- { 0x2cca, {1, {0x2ccb}}},
- { 0x2ccc, {1, {0x2ccd}}},
- { 0x2cce, {1, {0x2ccf}}},
- { 0x2cd0, {1, {0x2cd1}}},
- { 0x2cd2, {1, {0x2cd3}}},
- { 0x2cd4, {1, {0x2cd5}}},
- { 0x2cd6, {1, {0x2cd7}}},
- { 0x2cd8, {1, {0x2cd9}}},
- { 0x2cda, {1, {0x2cdb}}},
- { 0x2cdc, {1, {0x2cdd}}},
- { 0x2cde, {1, {0x2cdf}}},
- { 0x2ce0, {1, {0x2ce1}}},
- { 0x2ce2, {1, {0x2ce3}}},
- { 0xfb00, {2, {0x0066, 0x0066}}},
- { 0xfb01, {2, {0x0066, 0x0069}}},
- { 0xfb02, {2, {0x0066, 0x006c}}},
- { 0xfb03, {3, {0x0066, 0x0066, 0x0069}}},
- { 0xfb04, {3, {0x0066, 0x0066, 0x006c}}},
- { 0xfb05, {2, {0x0073, 0x0074}}},
- { 0xfb06, {2, {0x0073, 0x0074}}},
- { 0xfb13, {2, {0x0574, 0x0576}}},
- { 0xfb14, {2, {0x0574, 0x0565}}},
- { 0xfb15, {2, {0x0574, 0x056b}}},
- { 0xfb16, {2, {0x057e, 0x0576}}},
- { 0xfb17, {2, {0x0574, 0x056d}}},
- { 0xff21, {1, {0xff41}}},
- { 0xff22, {1, {0xff42}}},
- { 0xff23, {1, {0xff43}}},
- { 0xff24, {1, {0xff44}}},
- { 0xff25, {1, {0xff45}}},
- { 0xff26, {1, {0xff46}}},
- { 0xff27, {1, {0xff47}}},
- { 0xff28, {1, {0xff48}}},
- { 0xff29, {1, {0xff49}}},
- { 0xff2a, {1, {0xff4a}}},
- { 0xff2b, {1, {0xff4b}}},
- { 0xff2c, {1, {0xff4c}}},
- { 0xff2d, {1, {0xff4d}}},
- { 0xff2e, {1, {0xff4e}}},
- { 0xff2f, {1, {0xff4f}}},
- { 0xff30, {1, {0xff50}}},
- { 0xff31, {1, {0xff51}}},
- { 0xff32, {1, {0xff52}}},
- { 0xff33, {1, {0xff53}}},
- { 0xff34, {1, {0xff54}}},
- { 0xff35, {1, {0xff55}}},
- { 0xff36, {1, {0xff56}}},
- { 0xff37, {1, {0xff57}}},
- { 0xff38, {1, {0xff58}}},
- { 0xff39, {1, {0xff59}}},
- { 0xff3a, {1, {0xff5a}}},
- { 0x10400, {1, {0x10428}}},
- { 0x10401, {1, {0x10429}}},
- { 0x10402, {1, {0x1042a}}},
- { 0x10403, {1, {0x1042b}}},
- { 0x10404, {1, {0x1042c}}},
- { 0x10405, {1, {0x1042d}}},
- { 0x10406, {1, {0x1042e}}},
- { 0x10407, {1, {0x1042f}}},
- { 0x10408, {1, {0x10430}}},
- { 0x10409, {1, {0x10431}}},
- { 0x1040a, {1, {0x10432}}},
- { 0x1040b, {1, {0x10433}}},
- { 0x1040c, {1, {0x10434}}},
- { 0x1040d, {1, {0x10435}}},
- { 0x1040e, {1, {0x10436}}},
- { 0x1040f, {1, {0x10437}}},
- { 0x10410, {1, {0x10438}}},
- { 0x10411, {1, {0x10439}}},
- { 0x10412, {1, {0x1043a}}},
- { 0x10413, {1, {0x1043b}}},
- { 0x10414, {1, {0x1043c}}},
- { 0x10415, {1, {0x1043d}}},
- { 0x10416, {1, {0x1043e}}},
- { 0x10417, {1, {0x1043f}}},
- { 0x10418, {1, {0x10440}}},
- { 0x10419, {1, {0x10441}}},
- { 0x1041a, {1, {0x10442}}},
- { 0x1041b, {1, {0x10443}}},
- { 0x1041c, {1, {0x10444}}},
- { 0x1041d, {1, {0x10445}}},
- { 0x1041e, {1, {0x10446}}},
- { 0x1041f, {1, {0x10447}}},
- { 0x10420, {1, {0x10448}}},
- { 0x10421, {1, {0x10449}}},
- { 0x10422, {1, {0x1044a}}},
- { 0x10423, {1, {0x1044b}}},
- { 0x10424, {1, {0x1044c}}},
- { 0x10425, {1, {0x1044d}}},
- { 0x10426, {1, {0x1044e}}},
- { 0x10427, {1, {0x1044f}}}
-};
-
-static const CaseFold_11_Type CaseFold_Locale[] = {
- { 0x0049, {1, {0x0069}}},
- { 0x0130, {2, {0x0069, 0x0307}}}
-};
-
-static const CaseUnfold_11_Type CaseUnfold_11[] = {
- { 0x0061, {1, {0x0041 }}},
- { 0x0062, {1, {0x0042 }}},
- { 0x0063, {1, {0x0043 }}},
- { 0x0064, {1, {0x0044 }}},
- { 0x0065, {1, {0x0045 }}},
- { 0x0066, {1, {0x0046 }}},
- { 0x0067, {1, {0x0047 }}},
- { 0x0068, {1, {0x0048 }}},
- { 0x006a, {1, {0x004a }}},
- { 0x006b, {2, {0x212a, 0x004b }}},
- { 0x006c, {1, {0x004c }}},
- { 0x006d, {1, {0x004d }}},
- { 0x006e, {1, {0x004e }}},
- { 0x006f, {1, {0x004f }}},
- { 0x0070, {1, {0x0050 }}},
- { 0x0071, {1, {0x0051 }}},
- { 0x0072, {1, {0x0052 }}},
- { 0x0073, {2, {0x0053, 0x017f }}},
- { 0x0074, {1, {0x0054 }}},
- { 0x0075, {1, {0x0055 }}},
- { 0x0076, {1, {0x0056 }}},
- { 0x0077, {1, {0x0057 }}},
- { 0x0078, {1, {0x0058 }}},
- { 0x0079, {1, {0x0059 }}},
- { 0x007a, {1, {0x005a }}},
- { 0x00e0, {1, {0x00c0 }}},
- { 0x00e1, {1, {0x00c1 }}},
- { 0x00e2, {1, {0x00c2 }}},
- { 0x00e3, {1, {0x00c3 }}},
- { 0x00e4, {1, {0x00c4 }}},
- { 0x00e5, {2, {0x212b, 0x00c5 }}},
- { 0x00e6, {1, {0x00c6 }}},
- { 0x00e7, {1, {0x00c7 }}},
- { 0x00e8, {1, {0x00c8 }}},
- { 0x00e9, {1, {0x00c9 }}},
- { 0x00ea, {1, {0x00ca }}},
- { 0x00eb, {1, {0x00cb }}},
- { 0x00ec, {1, {0x00cc }}},
- { 0x00ed, {1, {0x00cd }}},
- { 0x00ee, {1, {0x00ce }}},
- { 0x00ef, {1, {0x00cf }}},
- { 0x00f0, {1, {0x00d0 }}},
- { 0x00f1, {1, {0x00d1 }}},
- { 0x00f2, {1, {0x00d2 }}},
- { 0x00f3, {1, {0x00d3 }}},
- { 0x00f4, {1, {0x00d4 }}},
- { 0x00f5, {1, {0x00d5 }}},
- { 0x00f6, {1, {0x00d6 }}},
- { 0x00f8, {1, {0x00d8 }}},
- { 0x00f9, {1, {0x00d9 }}},
- { 0x00fa, {1, {0x00da }}},
- { 0x00fb, {1, {0x00db }}},
- { 0x00fc, {1, {0x00dc }}},
- { 0x00fd, {1, {0x00dd }}},
- { 0x00fe, {1, {0x00de }}},
- { 0x00ff, {1, {0x0178 }}},
- { 0x0101, {1, {0x0100 }}},
- { 0x0103, {1, {0x0102 }}},
- { 0x0105, {1, {0x0104 }}},
- { 0x0107, {1, {0x0106 }}},
- { 0x0109, {1, {0x0108 }}},
- { 0x010b, {1, {0x010a }}},
- { 0x010d, {1, {0x010c }}},
- { 0x010f, {1, {0x010e }}},
- { 0x0111, {1, {0x0110 }}},
- { 0x0113, {1, {0x0112 }}},
- { 0x0115, {1, {0x0114 }}},
- { 0x0117, {1, {0x0116 }}},
- { 0x0119, {1, {0x0118 }}},
- { 0x011b, {1, {0x011a }}},
- { 0x011d, {1, {0x011c }}},
- { 0x011f, {1, {0x011e }}},
- { 0x0121, {1, {0x0120 }}},
- { 0x0123, {1, {0x0122 }}},
- { 0x0125, {1, {0x0124 }}},
- { 0x0127, {1, {0x0126 }}},
- { 0x0129, {1, {0x0128 }}},
- { 0x012b, {1, {0x012a }}},
- { 0x012d, {1, {0x012c }}},
- { 0x012f, {1, {0x012e }}},
- { 0x0133, {1, {0x0132 }}},
- { 0x0135, {1, {0x0134 }}},
- { 0x0137, {1, {0x0136 }}},
- { 0x013a, {1, {0x0139 }}},
- { 0x013c, {1, {0x013b }}},
- { 0x013e, {1, {0x013d }}},
- { 0x0140, {1, {0x013f }}},
- { 0x0142, {1, {0x0141 }}},
- { 0x0144, {1, {0x0143 }}},
- { 0x0146, {1, {0x0145 }}},
- { 0x0148, {1, {0x0147 }}},
- { 0x014b, {1, {0x014a }}},
- { 0x014d, {1, {0x014c }}},
- { 0x014f, {1, {0x014e }}},
- { 0x0151, {1, {0x0150 }}},
- { 0x0153, {1, {0x0152 }}},
- { 0x0155, {1, {0x0154 }}},
- { 0x0157, {1, {0x0156 }}},
- { 0x0159, {1, {0x0158 }}},
- { 0x015b, {1, {0x015a }}},
- { 0x015d, {1, {0x015c }}},
- { 0x015f, {1, {0x015e }}},
- { 0x0161, {1, {0x0160 }}},
- { 0x0163, {1, {0x0162 }}},
- { 0x0165, {1, {0x0164 }}},
- { 0x0167, {1, {0x0166 }}},
- { 0x0169, {1, {0x0168 }}},
- { 0x016b, {1, {0x016a }}},
- { 0x016d, {1, {0x016c }}},
- { 0x016f, {1, {0x016e }}},
- { 0x0171, {1, {0x0170 }}},
- { 0x0173, {1, {0x0172 }}},
- { 0x0175, {1, {0x0174 }}},
- { 0x0177, {1, {0x0176 }}},
- { 0x017a, {1, {0x0179 }}},
- { 0x017c, {1, {0x017b }}},
- { 0x017e, {1, {0x017d }}},
- { 0x0183, {1, {0x0182 }}},
- { 0x0185, {1, {0x0184 }}},
- { 0x0188, {1, {0x0187 }}},
- { 0x018c, {1, {0x018b }}},
- { 0x0192, {1, {0x0191 }}},
- { 0x0195, {1, {0x01f6 }}},
- { 0x0199, {1, {0x0198 }}},
- { 0x019a, {1, {0x023d }}},
- { 0x019e, {1, {0x0220 }}},
- { 0x01a1, {1, {0x01a0 }}},
- { 0x01a3, {1, {0x01a2 }}},
- { 0x01a5, {1, {0x01a4 }}},
- { 0x01a8, {1, {0x01a7 }}},
- { 0x01ad, {1, {0x01ac }}},
- { 0x01b0, {1, {0x01af }}},
- { 0x01b4, {1, {0x01b3 }}},
- { 0x01b6, {1, {0x01b5 }}},
- { 0x01b9, {1, {0x01b8 }}},
- { 0x01bd, {1, {0x01bc }}},
- { 0x01bf, {1, {0x01f7 }}},
- { 0x01c6, {2, {0x01c4, 0x01c5 }}},
- { 0x01c9, {2, {0x01c7, 0x01c8 }}},
- { 0x01cc, {2, {0x01ca, 0x01cb }}},
- { 0x01ce, {1, {0x01cd }}},
- { 0x01d0, {1, {0x01cf }}},
- { 0x01d2, {1, {0x01d1 }}},
- { 0x01d4, {1, {0x01d3 }}},
- { 0x01d6, {1, {0x01d5 }}},
- { 0x01d8, {1, {0x01d7 }}},
- { 0x01da, {1, {0x01d9 }}},
- { 0x01dc, {1, {0x01db }}},
- { 0x01dd, {1, {0x018e }}},
- { 0x01df, {1, {0x01de }}},
- { 0x01e1, {1, {0x01e0 }}},
- { 0x01e3, {1, {0x01e2 }}},
- { 0x01e5, {1, {0x01e4 }}},
- { 0x01e7, {1, {0x01e6 }}},
- { 0x01e9, {1, {0x01e8 }}},
- { 0x01eb, {1, {0x01ea }}},
- { 0x01ed, {1, {0x01ec }}},
- { 0x01ef, {1, {0x01ee }}},
- { 0x01f3, {2, {0x01f1, 0x01f2 }}},
- { 0x01f5, {1, {0x01f4 }}},
- { 0x01f9, {1, {0x01f8 }}},
- { 0x01fb, {1, {0x01fa }}},
- { 0x01fd, {1, {0x01fc }}},
- { 0x01ff, {1, {0x01fe }}},
- { 0x0201, {1, {0x0200 }}},
- { 0x0203, {1, {0x0202 }}},
- { 0x0205, {1, {0x0204 }}},
- { 0x0207, {1, {0x0206 }}},
- { 0x0209, {1, {0x0208 }}},
- { 0x020b, {1, {0x020a }}},
- { 0x020d, {1, {0x020c }}},
- { 0x020f, {1, {0x020e }}},
- { 0x0211, {1, {0x0210 }}},
- { 0x0213, {1, {0x0212 }}},
- { 0x0215, {1, {0x0214 }}},
- { 0x0217, {1, {0x0216 }}},
- { 0x0219, {1, {0x0218 }}},
- { 0x021b, {1, {0x021a }}},
- { 0x021d, {1, {0x021c }}},
- { 0x021f, {1, {0x021e }}},
- { 0x0223, {1, {0x0222 }}},
- { 0x0225, {1, {0x0224 }}},
- { 0x0227, {1, {0x0226 }}},
- { 0x0229, {1, {0x0228 }}},
- { 0x022b, {1, {0x022a }}},
- { 0x022d, {1, {0x022c }}},
- { 0x022f, {1, {0x022e }}},
- { 0x0231, {1, {0x0230 }}},
- { 0x0233, {1, {0x0232 }}},
- { 0x023c, {1, {0x023b }}},
- { 0x0253, {1, {0x0181 }}},
- { 0x0254, {1, {0x0186 }}},
- { 0x0256, {1, {0x0189 }}},
- { 0x0257, {1, {0x018a }}},
- { 0x0259, {1, {0x018f }}},
- { 0x025b, {1, {0x0190 }}},
- { 0x0260, {1, {0x0193 }}},
- { 0x0263, {1, {0x0194 }}},
- { 0x0268, {1, {0x0197 }}},
- { 0x0269, {1, {0x0196 }}},
- { 0x026f, {1, {0x019c }}},
- { 0x0272, {1, {0x019d }}},
- { 0x0275, {1, {0x019f }}},
- { 0x0280, {1, {0x01a6 }}},
- { 0x0283, {1, {0x01a9 }}},
- { 0x0288, {1, {0x01ae }}},
- { 0x028a, {1, {0x01b1 }}},
- { 0x028b, {1, {0x01b2 }}},
- { 0x0292, {1, {0x01b7 }}},
- { 0x0294, {1, {0x0241 }}},
- { 0x03ac, {1, {0x0386 }}},
- { 0x03ad, {1, {0x0388 }}},
- { 0x03ae, {1, {0x0389 }}},
- { 0x03af, {1, {0x038a }}},
- { 0x03b1, {1, {0x0391 }}},
- { 0x03b2, {2, {0x0392, 0x03d0 }}},
- { 0x03b3, {1, {0x0393 }}},
- { 0x03b4, {1, {0x0394 }}},
- { 0x03b5, {2, {0x03f5, 0x0395 }}},
- { 0x03b6, {1, {0x0396 }}},
- { 0x03b7, {1, {0x0397 }}},
- { 0x03b8, {3, {0x03f4, 0x0398, 0x03d1 }}},
- { 0x03b9, {3, {0x1fbe, 0x0399, 0x0345 }}},
- { 0x03ba, {2, {0x03f0, 0x039a }}},
- { 0x03bb, {1, {0x039b }}},
- { 0x03bc, {2, {0x00b5, 0x039c }}},
- { 0x03bd, {1, {0x039d }}},
- { 0x03be, {1, {0x039e }}},
- { 0x03bf, {1, {0x039f }}},
- { 0x03c0, {2, {0x03a0, 0x03d6 }}},
- { 0x03c1, {2, {0x03f1, 0x03a1 }}},
- { 0x03c3, {2, {0x03a3, 0x03c2 }}},
- { 0x03c4, {1, {0x03a4 }}},
- { 0x03c5, {1, {0x03a5 }}},
- { 0x03c6, {2, {0x03a6, 0x03d5 }}},
- { 0x03c7, {1, {0x03a7 }}},
- { 0x03c8, {1, {0x03a8 }}},
- { 0x03c9, {2, {0x03a9, 0x2126 }}},
- { 0x03ca, {1, {0x03aa }}},
- { 0x03cb, {1, {0x03ab }}},
- { 0x03cc, {1, {0x038c }}},
- { 0x03cd, {1, {0x038e }}},
- { 0x03ce, {1, {0x038f }}},
- { 0x03d9, {1, {0x03d8 }}},
- { 0x03db, {1, {0x03da }}},
- { 0x03dd, {1, {0x03dc }}},
- { 0x03df, {1, {0x03de }}},
- { 0x03e1, {1, {0x03e0 }}},
- { 0x03e3, {1, {0x03e2 }}},
- { 0x03e5, {1, {0x03e4 }}},
- { 0x03e7, {1, {0x03e6 }}},
- { 0x03e9, {1, {0x03e8 }}},
- { 0x03eb, {1, {0x03ea }}},
- { 0x03ed, {1, {0x03ec }}},
- { 0x03ef, {1, {0x03ee }}},
- { 0x03f2, {1, {0x03f9 }}},
- { 0x03f8, {1, {0x03f7 }}},
- { 0x03fb, {1, {0x03fa }}},
- { 0x0430, {1, {0x0410 }}},
- { 0x0431, {1, {0x0411 }}},
- { 0x0432, {1, {0x0412 }}},
- { 0x0433, {1, {0x0413 }}},
- { 0x0434, {1, {0x0414 }}},
- { 0x0435, {1, {0x0415 }}},
- { 0x0436, {1, {0x0416 }}},
- { 0x0437, {1, {0x0417 }}},
- { 0x0438, {1, {0x0418 }}},
- { 0x0439, {1, {0x0419 }}},
- { 0x043a, {1, {0x041a }}},
- { 0x043b, {1, {0x041b }}},
- { 0x043c, {1, {0x041c }}},
- { 0x043d, {1, {0x041d }}},
- { 0x043e, {1, {0x041e }}},
- { 0x043f, {1, {0x041f }}},
- { 0x0440, {1, {0x0420 }}},
- { 0x0441, {1, {0x0421 }}},
- { 0x0442, {1, {0x0422 }}},
- { 0x0443, {1, {0x0423 }}},
- { 0x0444, {1, {0x0424 }}},
- { 0x0445, {1, {0x0425 }}},
- { 0x0446, {1, {0x0426 }}},
- { 0x0447, {1, {0x0427 }}},
- { 0x0448, {1, {0x0428 }}},
- { 0x0449, {1, {0x0429 }}},
- { 0x044a, {1, {0x042a }}},
- { 0x044b, {1, {0x042b }}},
- { 0x044c, {1, {0x042c }}},
- { 0x044d, {1, {0x042d }}},
- { 0x044e, {1, {0x042e }}},
- { 0x044f, {1, {0x042f }}},
- { 0x0450, {1, {0x0400 }}},
- { 0x0451, {1, {0x0401 }}},
- { 0x0452, {1, {0x0402 }}},
- { 0x0453, {1, {0x0403 }}},
- { 0x0454, {1, {0x0404 }}},
- { 0x0455, {1, {0x0405 }}},
- { 0x0456, {1, {0x0406 }}},
- { 0x0457, {1, {0x0407 }}},
- { 0x0458, {1, {0x0408 }}},
- { 0x0459, {1, {0x0409 }}},
- { 0x045a, {1, {0x040a }}},
- { 0x045b, {1, {0x040b }}},
- { 0x045c, {1, {0x040c }}},
- { 0x045d, {1, {0x040d }}},
- { 0x045e, {1, {0x040e }}},
- { 0x045f, {1, {0x040f }}},
- { 0x0461, {1, {0x0460 }}},
- { 0x0463, {1, {0x0462 }}},
- { 0x0465, {1, {0x0464 }}},
- { 0x0467, {1, {0x0466 }}},
- { 0x0469, {1, {0x0468 }}},
- { 0x046b, {1, {0x046a }}},
- { 0x046d, {1, {0x046c }}},
- { 0x046f, {1, {0x046e }}},
- { 0x0471, {1, {0x0470 }}},
- { 0x0473, {1, {0x0472 }}},
- { 0x0475, {1, {0x0474 }}},
- { 0x0477, {1, {0x0476 }}},
- { 0x0479, {1, {0x0478 }}},
- { 0x047b, {1, {0x047a }}},
- { 0x047d, {1, {0x047c }}},
- { 0x047f, {1, {0x047e }}},
- { 0x0481, {1, {0x0480 }}},
- { 0x048b, {1, {0x048a }}},
- { 0x048d, {1, {0x048c }}},
- { 0x048f, {1, {0x048e }}},
- { 0x0491, {1, {0x0490 }}},
- { 0x0493, {1, {0x0492 }}},
- { 0x0495, {1, {0x0494 }}},
- { 0x0497, {1, {0x0496 }}},
- { 0x0499, {1, {0x0498 }}},
- { 0x049b, {1, {0x049a }}},
- { 0x049d, {1, {0x049c }}},
- { 0x049f, {1, {0x049e }}},
- { 0x04a1, {1, {0x04a0 }}},
- { 0x04a3, {1, {0x04a2 }}},
- { 0x04a5, {1, {0x04a4 }}},
- { 0x04a7, {1, {0x04a6 }}},
- { 0x04a9, {1, {0x04a8 }}},
- { 0x04ab, {1, {0x04aa }}},
- { 0x04ad, {1, {0x04ac }}},
- { 0x04af, {1, {0x04ae }}},
- { 0x04b1, {1, {0x04b0 }}},
- { 0x04b3, {1, {0x04b2 }}},
- { 0x04b5, {1, {0x04b4 }}},
- { 0x04b7, {1, {0x04b6 }}},
- { 0x04b9, {1, {0x04b8 }}},
- { 0x04bb, {1, {0x04ba }}},
- { 0x04bd, {1, {0x04bc }}},
- { 0x04bf, {1, {0x04be }}},
- { 0x04c2, {1, {0x04c1 }}},
- { 0x04c4, {1, {0x04c3 }}},
- { 0x04c6, {1, {0x04c5 }}},
- { 0x04c8, {1, {0x04c7 }}},
- { 0x04ca, {1, {0x04c9 }}},
- { 0x04cc, {1, {0x04cb }}},
- { 0x04ce, {1, {0x04cd }}},
- { 0x04d1, {1, {0x04d0 }}},
- { 0x04d3, {1, {0x04d2 }}},
- { 0x04d5, {1, {0x04d4 }}},
- { 0x04d7, {1, {0x04d6 }}},
- { 0x04d9, {1, {0x04d8 }}},
- { 0x04db, {1, {0x04da }}},
- { 0x04dd, {1, {0x04dc }}},
- { 0x04df, {1, {0x04de }}},
- { 0x04e1, {1, {0x04e0 }}},
- { 0x04e3, {1, {0x04e2 }}},
- { 0x04e5, {1, {0x04e4 }}},
- { 0x04e7, {1, {0x04e6 }}},
- { 0x04e9, {1, {0x04e8 }}},
- { 0x04eb, {1, {0x04ea }}},
- { 0x04ed, {1, {0x04ec }}},
- { 0x04ef, {1, {0x04ee }}},
- { 0x04f1, {1, {0x04f0 }}},
- { 0x04f3, {1, {0x04f2 }}},
- { 0x04f5, {1, {0x04f4 }}},
- { 0x04f7, {1, {0x04f6 }}},
- { 0x04f9, {1, {0x04f8 }}},
- { 0x0501, {1, {0x0500 }}},
- { 0x0503, {1, {0x0502 }}},
- { 0x0505, {1, {0x0504 }}},
- { 0x0507, {1, {0x0506 }}},
- { 0x0509, {1, {0x0508 }}},
- { 0x050b, {1, {0x050a }}},
- { 0x050d, {1, {0x050c }}},
- { 0x050f, {1, {0x050e }}},
- { 0x0561, {1, {0x0531 }}},
- { 0x0562, {1, {0x0532 }}},
- { 0x0563, {1, {0x0533 }}},
- { 0x0564, {1, {0x0534 }}},
- { 0x0565, {1, {0x0535 }}},
- { 0x0566, {1, {0x0536 }}},
- { 0x0567, {1, {0x0537 }}},
- { 0x0568, {1, {0x0538 }}},
- { 0x0569, {1, {0x0539 }}},
- { 0x056a, {1, {0x053a }}},
- { 0x056b, {1, {0x053b }}},
- { 0x056c, {1, {0x053c }}},
- { 0x056d, {1, {0x053d }}},
- { 0x056e, {1, {0x053e }}},
- { 0x056f, {1, {0x053f }}},
- { 0x0570, {1, {0x0540 }}},
- { 0x0571, {1, {0x0541 }}},
- { 0x0572, {1, {0x0542 }}},
- { 0x0573, {1, {0x0543 }}},
- { 0x0574, {1, {0x0544 }}},
- { 0x0575, {1, {0x0545 }}},
- { 0x0576, {1, {0x0546 }}},
- { 0x0577, {1, {0x0547 }}},
- { 0x0578, {1, {0x0548 }}},
- { 0x0579, {1, {0x0549 }}},
- { 0x057a, {1, {0x054a }}},
- { 0x057b, {1, {0x054b }}},
- { 0x057c, {1, {0x054c }}},
- { 0x057d, {1, {0x054d }}},
- { 0x057e, {1, {0x054e }}},
- { 0x057f, {1, {0x054f }}},
- { 0x0580, {1, {0x0550 }}},
- { 0x0581, {1, {0x0551 }}},
- { 0x0582, {1, {0x0552 }}},
- { 0x0583, {1, {0x0553 }}},
- { 0x0584, {1, {0x0554 }}},
- { 0x0585, {1, {0x0555 }}},
- { 0x0586, {1, {0x0556 }}},
- { 0x1e01, {1, {0x1e00 }}},
- { 0x1e03, {1, {0x1e02 }}},
- { 0x1e05, {1, {0x1e04 }}},
- { 0x1e07, {1, {0x1e06 }}},
- { 0x1e09, {1, {0x1e08 }}},
- { 0x1e0b, {1, {0x1e0a }}},
- { 0x1e0d, {1, {0x1e0c }}},
- { 0x1e0f, {1, {0x1e0e }}},
- { 0x1e11, {1, {0x1e10 }}},
- { 0x1e13, {1, {0x1e12 }}},
- { 0x1e15, {1, {0x1e14 }}},
- { 0x1e17, {1, {0x1e16 }}},
- { 0x1e19, {1, {0x1e18 }}},
- { 0x1e1b, {1, {0x1e1a }}},
- { 0x1e1d, {1, {0x1e1c }}},
- { 0x1e1f, {1, {0x1e1e }}},
- { 0x1e21, {1, {0x1e20 }}},
- { 0x1e23, {1, {0x1e22 }}},
- { 0x1e25, {1, {0x1e24 }}},
- { 0x1e27, {1, {0x1e26 }}},
- { 0x1e29, {1, {0x1e28 }}},
- { 0x1e2b, {1, {0x1e2a }}},
- { 0x1e2d, {1, {0x1e2c }}},
- { 0x1e2f, {1, {0x1e2e }}},
- { 0x1e31, {1, {0x1e30 }}},
- { 0x1e33, {1, {0x1e32 }}},
- { 0x1e35, {1, {0x1e34 }}},
- { 0x1e37, {1, {0x1e36 }}},
- { 0x1e39, {1, {0x1e38 }}},
- { 0x1e3b, {1, {0x1e3a }}},
- { 0x1e3d, {1, {0x1e3c }}},
- { 0x1e3f, {1, {0x1e3e }}},
- { 0x1e41, {1, {0x1e40 }}},
- { 0x1e43, {1, {0x1e42 }}},
- { 0x1e45, {1, {0x1e44 }}},
- { 0x1e47, {1, {0x1e46 }}},
- { 0x1e49, {1, {0x1e48 }}},
- { 0x1e4b, {1, {0x1e4a }}},
- { 0x1e4d, {1, {0x1e4c }}},
- { 0x1e4f, {1, {0x1e4e }}},
- { 0x1e51, {1, {0x1e50 }}},
- { 0x1e53, {1, {0x1e52 }}},
- { 0x1e55, {1, {0x1e54 }}},
- { 0x1e57, {1, {0x1e56 }}},
- { 0x1e59, {1, {0x1e58 }}},
- { 0x1e5b, {1, {0x1e5a }}},
- { 0x1e5d, {1, {0x1e5c }}},
- { 0x1e5f, {1, {0x1e5e }}},
- { 0x1e61, {2, {0x1e9b, 0x1e60 }}},
- { 0x1e63, {1, {0x1e62 }}},
- { 0x1e65, {1, {0x1e64 }}},
- { 0x1e67, {1, {0x1e66 }}},
- { 0x1e69, {1, {0x1e68 }}},
- { 0x1e6b, {1, {0x1e6a }}},
- { 0x1e6d, {1, {0x1e6c }}},
- { 0x1e6f, {1, {0x1e6e }}},
- { 0x1e71, {1, {0x1e70 }}},
- { 0x1e73, {1, {0x1e72 }}},
- { 0x1e75, {1, {0x1e74 }}},
- { 0x1e77, {1, {0x1e76 }}},
- { 0x1e79, {1, {0x1e78 }}},
- { 0x1e7b, {1, {0x1e7a }}},
- { 0x1e7d, {1, {0x1e7c }}},
- { 0x1e7f, {1, {0x1e7e }}},
- { 0x1e81, {1, {0x1e80 }}},
- { 0x1e83, {1, {0x1e82 }}},
- { 0x1e85, {1, {0x1e84 }}},
- { 0x1e87, {1, {0x1e86 }}},
- { 0x1e89, {1, {0x1e88 }}},
- { 0x1e8b, {1, {0x1e8a }}},
- { 0x1e8d, {1, {0x1e8c }}},
- { 0x1e8f, {1, {0x1e8e }}},
- { 0x1e91, {1, {0x1e90 }}},
- { 0x1e93, {1, {0x1e92 }}},
- { 0x1e95, {1, {0x1e94 }}},
- { 0x1ea1, {1, {0x1ea0 }}},
- { 0x1ea3, {1, {0x1ea2 }}},
- { 0x1ea5, {1, {0x1ea4 }}},
- { 0x1ea7, {1, {0x1ea6 }}},
- { 0x1ea9, {1, {0x1ea8 }}},
- { 0x1eab, {1, {0x1eaa }}},
- { 0x1ead, {1, {0x1eac }}},
- { 0x1eaf, {1, {0x1eae }}},
- { 0x1eb1, {1, {0x1eb0 }}},
- { 0x1eb3, {1, {0x1eb2 }}},
- { 0x1eb5, {1, {0x1eb4 }}},
- { 0x1eb7, {1, {0x1eb6 }}},
- { 0x1eb9, {1, {0x1eb8 }}},
- { 0x1ebb, {1, {0x1eba }}},
- { 0x1ebd, {1, {0x1ebc }}},
- { 0x1ebf, {1, {0x1ebe }}},
- { 0x1ec1, {1, {0x1ec0 }}},
- { 0x1ec3, {1, {0x1ec2 }}},
- { 0x1ec5, {1, {0x1ec4 }}},
- { 0x1ec7, {1, {0x1ec6 }}},
- { 0x1ec9, {1, {0x1ec8 }}},
- { 0x1ecb, {1, {0x1eca }}},
- { 0x1ecd, {1, {0x1ecc }}},
- { 0x1ecf, {1, {0x1ece }}},
- { 0x1ed1, {1, {0x1ed0 }}},
- { 0x1ed3, {1, {0x1ed2 }}},
- { 0x1ed5, {1, {0x1ed4 }}},
- { 0x1ed7, {1, {0x1ed6 }}},
- { 0x1ed9, {1, {0x1ed8 }}},
- { 0x1edb, {1, {0x1eda }}},
- { 0x1edd, {1, {0x1edc }}},
- { 0x1edf, {1, {0x1ede }}},
- { 0x1ee1, {1, {0x1ee0 }}},
- { 0x1ee3, {1, {0x1ee2 }}},
- { 0x1ee5, {1, {0x1ee4 }}},
- { 0x1ee7, {1, {0x1ee6 }}},
- { 0x1ee9, {1, {0x1ee8 }}},
- { 0x1eeb, {1, {0x1eea }}},
- { 0x1eed, {1, {0x1eec }}},
- { 0x1eef, {1, {0x1eee }}},
- { 0x1ef1, {1, {0x1ef0 }}},
- { 0x1ef3, {1, {0x1ef2 }}},
- { 0x1ef5, {1, {0x1ef4 }}},
- { 0x1ef7, {1, {0x1ef6 }}},
- { 0x1ef9, {1, {0x1ef8 }}},
- { 0x1f00, {1, {0x1f08 }}},
- { 0x1f01, {1, {0x1f09 }}},
- { 0x1f02, {1, {0x1f0a }}},
- { 0x1f03, {1, {0x1f0b }}},
- { 0x1f04, {1, {0x1f0c }}},
- { 0x1f05, {1, {0x1f0d }}},
- { 0x1f06, {1, {0x1f0e }}},
- { 0x1f07, {1, {0x1f0f }}},
- { 0x1f10, {1, {0x1f18 }}},
- { 0x1f11, {1, {0x1f19 }}},
- { 0x1f12, {1, {0x1f1a }}},
- { 0x1f13, {1, {0x1f1b }}},
- { 0x1f14, {1, {0x1f1c }}},
- { 0x1f15, {1, {0x1f1d }}},
- { 0x1f20, {1, {0x1f28 }}},
- { 0x1f21, {1, {0x1f29 }}},
- { 0x1f22, {1, {0x1f2a }}},
- { 0x1f23, {1, {0x1f2b }}},
- { 0x1f24, {1, {0x1f2c }}},
- { 0x1f25, {1, {0x1f2d }}},
- { 0x1f26, {1, {0x1f2e }}},
- { 0x1f27, {1, {0x1f2f }}},
- { 0x1f30, {1, {0x1f38 }}},
- { 0x1f31, {1, {0x1f39 }}},
- { 0x1f32, {1, {0x1f3a }}},
- { 0x1f33, {1, {0x1f3b }}},
- { 0x1f34, {1, {0x1f3c }}},
- { 0x1f35, {1, {0x1f3d }}},
- { 0x1f36, {1, {0x1f3e }}},
- { 0x1f37, {1, {0x1f3f }}},
- { 0x1f40, {1, {0x1f48 }}},
- { 0x1f41, {1, {0x1f49 }}},
- { 0x1f42, {1, {0x1f4a }}},
- { 0x1f43, {1, {0x1f4b }}},
- { 0x1f44, {1, {0x1f4c }}},
- { 0x1f45, {1, {0x1f4d }}},
- { 0x1f51, {1, {0x1f59 }}},
- { 0x1f53, {1, {0x1f5b }}},
- { 0x1f55, {1, {0x1f5d }}},
- { 0x1f57, {1, {0x1f5f }}},
- { 0x1f60, {1, {0x1f68 }}},
- { 0x1f61, {1, {0x1f69 }}},
- { 0x1f62, {1, {0x1f6a }}},
- { 0x1f63, {1, {0x1f6b }}},
- { 0x1f64, {1, {0x1f6c }}},
- { 0x1f65, {1, {0x1f6d }}},
- { 0x1f66, {1, {0x1f6e }}},
- { 0x1f67, {1, {0x1f6f }}},
- { 0x1f70, {1, {0x1fba }}},
- { 0x1f71, {1, {0x1fbb }}},
- { 0x1f72, {1, {0x1fc8 }}},
- { 0x1f73, {1, {0x1fc9 }}},
- { 0x1f74, {1, {0x1fca }}},
- { 0x1f75, {1, {0x1fcb }}},
- { 0x1f76, {1, {0x1fda }}},
- { 0x1f77, {1, {0x1fdb }}},
- { 0x1f78, {1, {0x1ff8 }}},
- { 0x1f79, {1, {0x1ff9 }}},
- { 0x1f7a, {1, {0x1fea }}},
- { 0x1f7b, {1, {0x1feb }}},
- { 0x1f7c, {1, {0x1ffa }}},
- { 0x1f7d, {1, {0x1ffb }}},
- { 0x1fb0, {1, {0x1fb8 }}},
- { 0x1fb1, {1, {0x1fb9 }}},
- { 0x1fd0, {1, {0x1fd8 }}},
- { 0x1fd1, {1, {0x1fd9 }}},
- { 0x1fe0, {1, {0x1fe8 }}},
- { 0x1fe1, {1, {0x1fe9 }}},
- { 0x1fe5, {1, {0x1fec }}},
- { 0x2170, {1, {0x2160 }}},
- { 0x2171, {1, {0x2161 }}},
- { 0x2172, {1, {0x2162 }}},
- { 0x2173, {1, {0x2163 }}},
- { 0x2174, {1, {0x2164 }}},
- { 0x2175, {1, {0x2165 }}},
- { 0x2176, {1, {0x2166 }}},
- { 0x2177, {1, {0x2167 }}},
- { 0x2178, {1, {0x2168 }}},
- { 0x2179, {1, {0x2169 }}},
- { 0x217a, {1, {0x216a }}},
- { 0x217b, {1, {0x216b }}},
- { 0x217c, {1, {0x216c }}},
- { 0x217d, {1, {0x216d }}},
- { 0x217e, {1, {0x216e }}},
- { 0x217f, {1, {0x216f }}},
- { 0x24d0, {1, {0x24b6 }}},
- { 0x24d1, {1, {0x24b7 }}},
- { 0x24d2, {1, {0x24b8 }}},
- { 0x24d3, {1, {0x24b9 }}},
- { 0x24d4, {1, {0x24ba }}},
- { 0x24d5, {1, {0x24bb }}},
- { 0x24d6, {1, {0x24bc }}},
- { 0x24d7, {1, {0x24bd }}},
- { 0x24d8, {1, {0x24be }}},
- { 0x24d9, {1, {0x24bf }}},
- { 0x24da, {1, {0x24c0 }}},
- { 0x24db, {1, {0x24c1 }}},
- { 0x24dc, {1, {0x24c2 }}},
- { 0x24dd, {1, {0x24c3 }}},
- { 0x24de, {1, {0x24c4 }}},
- { 0x24df, {1, {0x24c5 }}},
- { 0x24e0, {1, {0x24c6 }}},
- { 0x24e1, {1, {0x24c7 }}},
- { 0x24e2, {1, {0x24c8 }}},
- { 0x24e3, {1, {0x24c9 }}},
- { 0x24e4, {1, {0x24ca }}},
- { 0x24e5, {1, {0x24cb }}},
- { 0x24e6, {1, {0x24cc }}},
- { 0x24e7, {1, {0x24cd }}},
- { 0x24e8, {1, {0x24ce }}},
- { 0x24e9, {1, {0x24cf }}},
- { 0x2c30, {1, {0x2c00 }}},
- { 0x2c31, {1, {0x2c01 }}},
- { 0x2c32, {1, {0x2c02 }}},
- { 0x2c33, {1, {0x2c03 }}},
- { 0x2c34, {1, {0x2c04 }}},
- { 0x2c35, {1, {0x2c05 }}},
- { 0x2c36, {1, {0x2c06 }}},
- { 0x2c37, {1, {0x2c07 }}},
- { 0x2c38, {1, {0x2c08 }}},
- { 0x2c39, {1, {0x2c09 }}},
- { 0x2c3a, {1, {0x2c0a }}},
- { 0x2c3b, {1, {0x2c0b }}},
- { 0x2c3c, {1, {0x2c0c }}},
- { 0x2c3d, {1, {0x2c0d }}},
- { 0x2c3e, {1, {0x2c0e }}},
- { 0x2c3f, {1, {0x2c0f }}},
- { 0x2c40, {1, {0x2c10 }}},
- { 0x2c41, {1, {0x2c11 }}},
- { 0x2c42, {1, {0x2c12 }}},
- { 0x2c43, {1, {0x2c13 }}},
- { 0x2c44, {1, {0x2c14 }}},
- { 0x2c45, {1, {0x2c15 }}},
- { 0x2c46, {1, {0x2c16 }}},
- { 0x2c47, {1, {0x2c17 }}},
- { 0x2c48, {1, {0x2c18 }}},
- { 0x2c49, {1, {0x2c19 }}},
- { 0x2c4a, {1, {0x2c1a }}},
- { 0x2c4b, {1, {0x2c1b }}},
- { 0x2c4c, {1, {0x2c1c }}},
- { 0x2c4d, {1, {0x2c1d }}},
- { 0x2c4e, {1, {0x2c1e }}},
- { 0x2c4f, {1, {0x2c1f }}},
- { 0x2c50, {1, {0x2c20 }}},
- { 0x2c51, {1, {0x2c21 }}},
- { 0x2c52, {1, {0x2c22 }}},
- { 0x2c53, {1, {0x2c23 }}},
- { 0x2c54, {1, {0x2c24 }}},
- { 0x2c55, {1, {0x2c25 }}},
- { 0x2c56, {1, {0x2c26 }}},
- { 0x2c57, {1, {0x2c27 }}},
- { 0x2c58, {1, {0x2c28 }}},
- { 0x2c59, {1, {0x2c29 }}},
- { 0x2c5a, {1, {0x2c2a }}},
- { 0x2c5b, {1, {0x2c2b }}},
- { 0x2c5c, {1, {0x2c2c }}},
- { 0x2c5d, {1, {0x2c2d }}},
- { 0x2c5e, {1, {0x2c2e }}},
- { 0x2c81, {1, {0x2c80 }}},
- { 0x2c83, {1, {0x2c82 }}},
- { 0x2c85, {1, {0x2c84 }}},
- { 0x2c87, {1, {0x2c86 }}},
- { 0x2c89, {1, {0x2c88 }}},
- { 0x2c8b, {1, {0x2c8a }}},
- { 0x2c8d, {1, {0x2c8c }}},
- { 0x2c8f, {1, {0x2c8e }}},
- { 0x2c91, {1, {0x2c90 }}},
- { 0x2c93, {1, {0x2c92 }}},
- { 0x2c95, {1, {0x2c94 }}},
- { 0x2c97, {1, {0x2c96 }}},
- { 0x2c99, {1, {0x2c98 }}},
- { 0x2c9b, {1, {0x2c9a }}},
- { 0x2c9d, {1, {0x2c9c }}},
- { 0x2c9f, {1, {0x2c9e }}},
- { 0x2ca1, {1, {0x2ca0 }}},
- { 0x2ca3, {1, {0x2ca2 }}},
- { 0x2ca5, {1, {0x2ca4 }}},
- { 0x2ca7, {1, {0x2ca6 }}},
- { 0x2ca9, {1, {0x2ca8 }}},
- { 0x2cab, {1, {0x2caa }}},
- { 0x2cad, {1, {0x2cac }}},
- { 0x2caf, {1, {0x2cae }}},
- { 0x2cb1, {1, {0x2cb0 }}},
- { 0x2cb3, {1, {0x2cb2 }}},
- { 0x2cb5, {1, {0x2cb4 }}},
- { 0x2cb7, {1, {0x2cb6 }}},
- { 0x2cb9, {1, {0x2cb8 }}},
- { 0x2cbb, {1, {0x2cba }}},
- { 0x2cbd, {1, {0x2cbc }}},
- { 0x2cbf, {1, {0x2cbe }}},
- { 0x2cc1, {1, {0x2cc0 }}},
- { 0x2cc3, {1, {0x2cc2 }}},
- { 0x2cc5, {1, {0x2cc4 }}},
- { 0x2cc7, {1, {0x2cc6 }}},
- { 0x2cc9, {1, {0x2cc8 }}},
- { 0x2ccb, {1, {0x2cca }}},
- { 0x2ccd, {1, {0x2ccc }}},
- { 0x2ccf, {1, {0x2cce }}},
- { 0x2cd1, {1, {0x2cd0 }}},
- { 0x2cd3, {1, {0x2cd2 }}},
- { 0x2cd5, {1, {0x2cd4 }}},
- { 0x2cd7, {1, {0x2cd6 }}},
- { 0x2cd9, {1, {0x2cd8 }}},
- { 0x2cdb, {1, {0x2cda }}},
- { 0x2cdd, {1, {0x2cdc }}},
- { 0x2cdf, {1, {0x2cde }}},
- { 0x2ce1, {1, {0x2ce0 }}},
- { 0x2ce3, {1, {0x2ce2 }}},
- { 0x2d00, {1, {0x10a0 }}},
- { 0x2d01, {1, {0x10a1 }}},
- { 0x2d02, {1, {0x10a2 }}},
- { 0x2d03, {1, {0x10a3 }}},
- { 0x2d04, {1, {0x10a4 }}},
- { 0x2d05, {1, {0x10a5 }}},
- { 0x2d06, {1, {0x10a6 }}},
- { 0x2d07, {1, {0x10a7 }}},
- { 0x2d08, {1, {0x10a8 }}},
- { 0x2d09, {1, {0x10a9 }}},
- { 0x2d0a, {1, {0x10aa }}},
- { 0x2d0b, {1, {0x10ab }}},
- { 0x2d0c, {1, {0x10ac }}},
- { 0x2d0d, {1, {0x10ad }}},
- { 0x2d0e, {1, {0x10ae }}},
- { 0x2d0f, {1, {0x10af }}},
- { 0x2d10, {1, {0x10b0 }}},
- { 0x2d11, {1, {0x10b1 }}},
- { 0x2d12, {1, {0x10b2 }}},
- { 0x2d13, {1, {0x10b3 }}},
- { 0x2d14, {1, {0x10b4 }}},
- { 0x2d15, {1, {0x10b5 }}},
- { 0x2d16, {1, {0x10b6 }}},
- { 0x2d17, {1, {0x10b7 }}},
- { 0x2d18, {1, {0x10b8 }}},
- { 0x2d19, {1, {0x10b9 }}},
- { 0x2d1a, {1, {0x10ba }}},
- { 0x2d1b, {1, {0x10bb }}},
- { 0x2d1c, {1, {0x10bc }}},
- { 0x2d1d, {1, {0x10bd }}},
- { 0x2d1e, {1, {0x10be }}},
- { 0x2d1f, {1, {0x10bf }}},
- { 0x2d20, {1, {0x10c0 }}},
- { 0x2d21, {1, {0x10c1 }}},
- { 0x2d22, {1, {0x10c2 }}},
- { 0x2d23, {1, {0x10c3 }}},
- { 0x2d24, {1, {0x10c4 }}},
- { 0x2d25, {1, {0x10c5 }}},
- { 0xff41, {1, {0xff21 }}},
- { 0xff42, {1, {0xff22 }}},
- { 0xff43, {1, {0xff23 }}},
- { 0xff44, {1, {0xff24 }}},
- { 0xff45, {1, {0xff25 }}},
- { 0xff46, {1, {0xff26 }}},
- { 0xff47, {1, {0xff27 }}},
- { 0xff48, {1, {0xff28 }}},
- { 0xff49, {1, {0xff29 }}},
- { 0xff4a, {1, {0xff2a }}},
- { 0xff4b, {1, {0xff2b }}},
- { 0xff4c, {1, {0xff2c }}},
- { 0xff4d, {1, {0xff2d }}},
- { 0xff4e, {1, {0xff2e }}},
- { 0xff4f, {1, {0xff2f }}},
- { 0xff50, {1, {0xff30 }}},
- { 0xff51, {1, {0xff31 }}},
- { 0xff52, {1, {0xff32 }}},
- { 0xff53, {1, {0xff33 }}},
- { 0xff54, {1, {0xff34 }}},
- { 0xff55, {1, {0xff35 }}},
- { 0xff56, {1, {0xff36 }}},
- { 0xff57, {1, {0xff37 }}},
- { 0xff58, {1, {0xff38 }}},
- { 0xff59, {1, {0xff39 }}},
- { 0xff5a, {1, {0xff3a }}},
- { 0x10428, {1, {0x10400 }}},
- { 0x10429, {1, {0x10401 }}},
- { 0x1042a, {1, {0x10402 }}},
- { 0x1042b, {1, {0x10403 }}},
- { 0x1042c, {1, {0x10404 }}},
- { 0x1042d, {1, {0x10405 }}},
- { 0x1042e, {1, {0x10406 }}},
- { 0x1042f, {1, {0x10407 }}},
- { 0x10430, {1, {0x10408 }}},
- { 0x10431, {1, {0x10409 }}},
- { 0x10432, {1, {0x1040a }}},
- { 0x10433, {1, {0x1040b }}},
- { 0x10434, {1, {0x1040c }}},
- { 0x10435, {1, {0x1040d }}},
- { 0x10436, {1, {0x1040e }}},
- { 0x10437, {1, {0x1040f }}},
- { 0x10438, {1, {0x10410 }}},
- { 0x10439, {1, {0x10411 }}},
- { 0x1043a, {1, {0x10412 }}},
- { 0x1043b, {1, {0x10413 }}},
- { 0x1043c, {1, {0x10414 }}},
- { 0x1043d, {1, {0x10415 }}},
- { 0x1043e, {1, {0x10416 }}},
- { 0x1043f, {1, {0x10417 }}},
- { 0x10440, {1, {0x10418 }}},
- { 0x10441, {1, {0x10419 }}},
- { 0x10442, {1, {0x1041a }}},
- { 0x10443, {1, {0x1041b }}},
- { 0x10444, {1, {0x1041c }}},
- { 0x10445, {1, {0x1041d }}},
- { 0x10446, {1, {0x1041e }}},
- { 0x10447, {1, {0x1041f }}},
- { 0x10448, {1, {0x10420 }}},
- { 0x10449, {1, {0x10421 }}},
- { 0x1044a, {1, {0x10422 }}},
- { 0x1044b, {1, {0x10423 }}},
- { 0x1044c, {1, {0x10424 }}},
- { 0x1044d, {1, {0x10425 }}},
- { 0x1044e, {1, {0x10426 }}},
- { 0x1044f, {1, {0x10427 }}}
-};
-
-static const CaseUnfold_11_Type CaseUnfold_11_Locale[] = {
- { 0x0069, {1, {0x0049 }}}
-};
-
-static const CaseUnfold_12_Type CaseUnfold_12[] = {
- { {0x0061, 0x02be}, {1, {0x1e9a }}},
- { {0x0066, 0x0066}, {1, {0xfb00 }}},
- { {0x0066, 0x0069}, {1, {0xfb01 }}},
- { {0x0066, 0x006c}, {1, {0xfb02 }}},
- { {0x0068, 0x0331}, {1, {0x1e96 }}},
- { {0x006a, 0x030c}, {1, {0x01f0 }}},
- { {0x0073, 0x0073}, {1, {0x00df }}},
- { {0x0073, 0x0074}, {2, {0xfb05, 0xfb06 }}},
- { {0x0074, 0x0308}, {1, {0x1e97 }}},
- { {0x0077, 0x030a}, {1, {0x1e98 }}},
- { {0x0079, 0x030a}, {1, {0x1e99 }}},
- { {0x02bc, 0x006e}, {1, {0x0149 }}},
- { {0x03ac, 0x03b9}, {1, {0x1fb4 }}},
- { {0x03ae, 0x03b9}, {1, {0x1fc4 }}},
- { {0x03b1, 0x0342}, {1, {0x1fb6 }}},
- { {0x03b1, 0x03b9}, {2, {0x1fb3, 0x1fbc }}},
- { {0x03b7, 0x0342}, {1, {0x1fc6 }}},
- { {0x03b7, 0x03b9}, {2, {0x1fc3, 0x1fcc }}},
- { {0x03b9, 0x0342}, {1, {0x1fd6 }}},
- { {0x03c1, 0x0313}, {1, {0x1fe4 }}},
- { {0x03c5, 0x0313}, {1, {0x1f50 }}},
- { {0x03c5, 0x0342}, {1, {0x1fe6 }}},
- { {0x03c9, 0x0342}, {1, {0x1ff6 }}},
- { {0x03c9, 0x03b9}, {2, {0x1ff3, 0x1ffc }}},
- { {0x03ce, 0x03b9}, {1, {0x1ff4 }}},
- { {0x0565, 0x0582}, {1, {0x0587 }}},
- { {0x0574, 0x0565}, {1, {0xfb14 }}},
- { {0x0574, 0x056b}, {1, {0xfb15 }}},
- { {0x0574, 0x056d}, {1, {0xfb17 }}},
- { {0x0574, 0x0576}, {1, {0xfb13 }}},
- { {0x057e, 0x0576}, {1, {0xfb16 }}},
- { {0x1f00, 0x03b9}, {2, {0x1f88, 0x1f80 }}},
- { {0x1f01, 0x03b9}, {2, {0x1f81, 0x1f89 }}},
- { {0x1f02, 0x03b9}, {2, {0x1f82, 0x1f8a }}},
- { {0x1f03, 0x03b9}, {2, {0x1f83, 0x1f8b }}},
- { {0x1f04, 0x03b9}, {2, {0x1f84, 0x1f8c }}},
- { {0x1f05, 0x03b9}, {2, {0x1f85, 0x1f8d }}},
- { {0x1f06, 0x03b9}, {2, {0x1f86, 0x1f8e }}},
- { {0x1f07, 0x03b9}, {2, {0x1f87, 0x1f8f }}},
- { {0x1f20, 0x03b9}, {2, {0x1f90, 0x1f98 }}},
- { {0x1f21, 0x03b9}, {2, {0x1f91, 0x1f99 }}},
- { {0x1f22, 0x03b9}, {2, {0x1f92, 0x1f9a }}},
- { {0x1f23, 0x03b9}, {2, {0x1f93, 0x1f9b }}},
- { {0x1f24, 0x03b9}, {2, {0x1f94, 0x1f9c }}},
- { {0x1f25, 0x03b9}, {2, {0x1f95, 0x1f9d }}},
- { {0x1f26, 0x03b9}, {2, {0x1f96, 0x1f9e }}},
- { {0x1f27, 0x03b9}, {2, {0x1f97, 0x1f9f }}},
- { {0x1f60, 0x03b9}, {2, {0x1fa0, 0x1fa8 }}},
- { {0x1f61, 0x03b9}, {2, {0x1fa1, 0x1fa9 }}},
- { {0x1f62, 0x03b9}, {2, {0x1fa2, 0x1faa }}},
- { {0x1f63, 0x03b9}, {2, {0x1fa3, 0x1fab }}},
- { {0x1f64, 0x03b9}, {2, {0x1fa4, 0x1fac }}},
- { {0x1f65, 0x03b9}, {2, {0x1fa5, 0x1fad }}},
- { {0x1f66, 0x03b9}, {2, {0x1fa6, 0x1fae }}},
- { {0x1f67, 0x03b9}, {2, {0x1fa7, 0x1faf }}},
- { {0x1f70, 0x03b9}, {1, {0x1fb2 }}},
- { {0x1f74, 0x03b9}, {1, {0x1fc2 }}},
- { {0x1f7c, 0x03b9}, {1, {0x1ff2 }}}
-};
-
-static const CaseUnfold_12_Type CaseUnfold_12_Locale[] = {
- { {0x0069, 0x0307}, {1, {0x0130 }}}
-};
-
-static const CaseUnfold_13_Type CaseUnfold_13[] = {
- { {0x0066, 0x0066, 0x0069}, {1, {0xfb03 }}},
- { {0x0066, 0x0066, 0x006c}, {1, {0xfb04 }}},
- { {0x03b1, 0x0342, 0x03b9}, {1, {0x1fb7 }}},
- { {0x03b7, 0x0342, 0x03b9}, {1, {0x1fc7 }}},
- { {0x03b9, 0x0308, 0x0300}, {1, {0x1fd2 }}},
- { {0x03b9, 0x0308, 0x0301}, {2, {0x0390, 0x1fd3 }}},
- { {0x03b9, 0x0308, 0x0342}, {1, {0x1fd7 }}},
- { {0x03c5, 0x0308, 0x0300}, {1, {0x1fe2 }}},
- { {0x03c5, 0x0308, 0x0301}, {2, {0x03b0, 0x1fe3 }}},
- { {0x03c5, 0x0308, 0x0342}, {1, {0x1fe7 }}},
- { {0x03c5, 0x0313, 0x0300}, {1, {0x1f52 }}},
- { {0x03c5, 0x0313, 0x0301}, {1, {0x1f54 }}},
- { {0x03c5, 0x0313, 0x0342}, {1, {0x1f56 }}},
- { {0x03c9, 0x0342, 0x03b9}, {1, {0x1ff7 }}}
-};
-
-
-static PosixBracketEntryType HashEntryData[] = {
- { (UChar* )"NEWLINE", 0, 7 },
- { (UChar* )"Alpha", 1, 5 },
- { (UChar* )"Blank", 2, 5 },
- { (UChar* )"Cntrl", 3, 5 },
- { (UChar* )"Digit", 4, 5 },
- { (UChar* )"Graph", 5, 5 },
- { (UChar* )"Lower", 6, 5 },
- { (UChar* )"Print", 7, 5 },
- { (UChar* )"Punct", 8, 5 },
- { (UChar* )"Space", 9, 5 },
- { (UChar* )"Upper", 10, 5 },
- { (UChar* )"XDigit", 11, 6 },
- { (UChar* )"Word", 12, 4 },
- { (UChar* )"Alnum", 13, 5 },
- { (UChar* )"ASCII", 14, 5 },
-
-#ifdef USE_UNICODE_PROPERTIES
- { (UChar* )"Any", 15, 3 },
- { (UChar* )"Assigned", 16, 8 },
- { (UChar* )"C", 17, 1 },
- { (UChar* )"Cc", 18, 2 },
- { (UChar* )"Cf", 19, 2 },
- { (UChar* )"Cn", 20, 2 },
- { (UChar* )"Co", 21, 2 },
- { (UChar* )"Cs", 22, 2 },
- { (UChar* )"L", 23, 1 },
- { (UChar* )"Ll", 24, 2 },
- { (UChar* )"Lm", 25, 2 },
- { (UChar* )"Lo", 26, 2 },
- { (UChar* )"Lt", 27, 2 },
- { (UChar* )"Lu", 28, 2 },
- { (UChar* )"M", 29, 1 },
- { (UChar* )"Mc", 30, 2 },
- { (UChar* )"Me", 31, 2 },
- { (UChar* )"Mn", 32, 2 },
- { (UChar* )"N", 33, 1 },
- { (UChar* )"Nd", 34, 2 },
- { (UChar* )"Nl", 35, 2 },
- { (UChar* )"No", 36, 2 },
- { (UChar* )"P", 37, 1 },
- { (UChar* )"Pc", 38, 2 },
- { (UChar* )"Pd", 39, 2 },
- { (UChar* )"Pe", 40, 2 },
- { (UChar* )"Pf", 41, 2 },
- { (UChar* )"Pi", 42, 2 },
- { (UChar* )"Po", 43, 2 },
- { (UChar* )"Ps", 44, 2 },
- { (UChar* )"S", 45, 1 },
- { (UChar* )"Sc", 46, 2 },
- { (UChar* )"Sk", 47, 2 },
- { (UChar* )"Sm", 48, 2 },
- { (UChar* )"So", 49, 2 },
- { (UChar* )"Z", 50, 1 },
- { (UChar* )"Zl", 51, 2 },
- { (UChar* )"Zp", 52, 2 },
- { (UChar* )"Zs", 53, 2 },
- { (UChar* )"Arabic", 54, 6 },
- { (UChar* )"Armenian", 55, 8 },
- { (UChar* )"Bengali", 56, 7 },
- { (UChar* )"Bopomofo", 57, 8 },
- { (UChar* )"Braille", 58, 7 },
- { (UChar* )"Buginese", 59, 8 },
- { (UChar* )"Buhid", 60, 5 },
- { (UChar* )"Canadian_Aboriginal", 61, 19 },
- { (UChar* )"Cherokee", 62, 8 },
- { (UChar* )"Common", 63, 6 },
- { (UChar* )"Coptic", 64, 6 },
- { (UChar* )"Cypriot", 65, 7 },
- { (UChar* )"Cyrillic", 66, 8 },
- { (UChar* )"Deseret", 67, 7 },
- { (UChar* )"Devanagari", 68, 10 },
- { (UChar* )"Ethiopic", 69, 8 },
- { (UChar* )"Georgian", 70, 8 },
- { (UChar* )"Glagolitic", 71, 10 },
- { (UChar* )"Gothic", 72, 6 },
- { (UChar* )"Greek", 73, 5 },
- { (UChar* )"Gujarati", 74, 8 },
- { (UChar* )"Gurmukhi", 75, 8 },
- { (UChar* )"Han", 76, 3 },
- { (UChar* )"Hangul", 77, 6 },
- { (UChar* )"Hanunoo", 78, 7 },
- { (UChar* )"Hebrew", 79, 6 },
- { (UChar* )"Hiragana", 80, 8 },
- { (UChar* )"Inherited", 81, 9 },
- { (UChar* )"Kannada", 82, 7 },
- { (UChar* )"Katakana", 83, 8 },
- { (UChar* )"Kharoshthi", 84, 10 },
- { (UChar* )"Khmer", 85, 5 },
- { (UChar* )"Lao", 86, 3 },
- { (UChar* )"Latin", 87, 5 },
- { (UChar* )"Limbu", 88, 5 },
- { (UChar* )"Linear_B", 89, 8 },
- { (UChar* )"Malayalam", 90, 9 },
- { (UChar* )"Mongolian", 91, 9 },
- { (UChar* )"Myanmar", 92, 7 },
- { (UChar* )"New_Tai_Lue", 93, 11 },
- { (UChar* )"Ogham", 94, 5 },
- { (UChar* )"Old_Italic", 95, 10 },
- { (UChar* )"Old_Persian", 96, 11 },
- { (UChar* )"Oriya", 97, 5 },
- { (UChar* )"Osmanya", 98, 7 },
- { (UChar* )"Runic", 99, 5 },
- { (UChar* )"Shavian", 100, 7 },
- { (UChar* )"Sinhala", 101, 7 },
- { (UChar* )"Syloti_Nagri", 102, 12 },
- { (UChar* )"Syriac", 103, 6 },
- { (UChar* )"Tagalog", 104, 7 },
- { (UChar* )"Tagbanwa", 105, 8 },
- { (UChar* )"Tai_Le", 106, 6 },
- { (UChar* )"Tamil", 107, 5 },
- { (UChar* )"Telugu", 108, 6 },
- { (UChar* )"Thaana", 109, 6 },
- { (UChar* )"Thai", 110, 4 },
- { (UChar* )"Tibetan", 111, 7 },
- { (UChar* )"Tifinagh", 112, 8 },
- { (UChar* )"Ugaritic", 113, 8 },
- { (UChar* )"Yi", 114, 2 },
-#endif /* USE_UNICODE_PROPERTIES */
- { (UChar* )NULL, -1, 0 }
-};
-
-#ifdef USE_UNICODE_PROPERTIES
-#define CODE_RANGES_NUM 115
-#else
-#define CODE_RANGES_NUM 15
-#endif
-
-static const OnigCodePoint* CodeRanges[CODE_RANGES_NUM];
-static int CodeRangeTableInited = 0;
-
-static void init_code_range_array() {
- THREAD_ATOMIC_START;
-
- CodeRanges[0] = CR_NEWLINE;
- CodeRanges[1] = CR_Alpha;
- CodeRanges[2] = CR_Blank;
- CodeRanges[3] = CR_Cntrl;
- CodeRanges[4] = CR_Digit;
- CodeRanges[5] = CR_Graph;
- CodeRanges[6] = CR_Lower;
- CodeRanges[7] = CR_Print;
- CodeRanges[8] = CR_Punct;
- CodeRanges[9] = CR_Space;
- CodeRanges[10] = CR_Upper;
- CodeRanges[11] = CR_XDigit;
- CodeRanges[12] = CR_Word;
- CodeRanges[13] = CR_Alnum;
- CodeRanges[14] = CR_ASCII;
-
-#ifdef USE_UNICODE_PROPERTIES
- CodeRanges[15] = CR_Any;
- CodeRanges[16] = CR_Assigned;
- CodeRanges[17] = CR_C;
- CodeRanges[18] = CR_Cc;
- CodeRanges[19] = CR_Cf;
- CodeRanges[20] = CR_Cn;
- CodeRanges[21] = CR_Co;
- CodeRanges[22] = CR_Cs;
- CodeRanges[23] = CR_L;
- CodeRanges[24] = CR_Ll;
- CodeRanges[25] = CR_Lm;
- CodeRanges[26] = CR_Lo;
- CodeRanges[27] = CR_Lt;
- CodeRanges[28] = CR_Lu;
- CodeRanges[29] = CR_M;
- CodeRanges[30] = CR_Mc;
- CodeRanges[31] = CR_Me;
- CodeRanges[32] = CR_Mn;
- CodeRanges[33] = CR_N;
- CodeRanges[34] = CR_Nd;
- CodeRanges[35] = CR_Nl;
- CodeRanges[36] = CR_No;
- CodeRanges[37] = CR_P;
- CodeRanges[38] = CR_Pc;
- CodeRanges[39] = CR_Pd;
- CodeRanges[40] = CR_Pe;
- CodeRanges[41] = CR_Pf;
- CodeRanges[42] = CR_Pi;
- CodeRanges[43] = CR_Po;
- CodeRanges[44] = CR_Ps;
- CodeRanges[45] = CR_S;
- CodeRanges[46] = CR_Sc;
- CodeRanges[47] = CR_Sk;
- CodeRanges[48] = CR_Sm;
- CodeRanges[49] = CR_So;
- CodeRanges[50] = CR_Z;
- CodeRanges[51] = CR_Zl;
- CodeRanges[52] = CR_Zp;
- CodeRanges[53] = CR_Zs;
- CodeRanges[54] = CR_Arabic;
- CodeRanges[55] = CR_Armenian;
- CodeRanges[56] = CR_Bengali;
- CodeRanges[57] = CR_Bopomofo;
- CodeRanges[58] = CR_Braille;
- CodeRanges[59] = CR_Buginese;
- CodeRanges[60] = CR_Buhid;
- CodeRanges[61] = CR_Canadian_Aboriginal;
- CodeRanges[62] = CR_Cherokee;
- CodeRanges[63] = CR_Common;
- CodeRanges[64] = CR_Coptic;
- CodeRanges[65] = CR_Cypriot;
- CodeRanges[66] = CR_Cyrillic;
- CodeRanges[67] = CR_Deseret;
- CodeRanges[68] = CR_Devanagari;
- CodeRanges[69] = CR_Ethiopic;
- CodeRanges[70] = CR_Georgian;
- CodeRanges[71] = CR_Glagolitic;
- CodeRanges[72] = CR_Gothic;
- CodeRanges[73] = CR_Greek;
- CodeRanges[74] = CR_Gujarati;
- CodeRanges[75] = CR_Gurmukhi;
- CodeRanges[76] = CR_Han;
- CodeRanges[77] = CR_Hangul;
- CodeRanges[78] = CR_Hanunoo;
- CodeRanges[79] = CR_Hebrew;
- CodeRanges[80] = CR_Hiragana;
- CodeRanges[81] = CR_Inherited;
- CodeRanges[82] = CR_Kannada;
- CodeRanges[83] = CR_Katakana;
- CodeRanges[84] = CR_Kharoshthi;
- CodeRanges[85] = CR_Khmer;
- CodeRanges[86] = CR_Lao;
- CodeRanges[87] = CR_Latin;
- CodeRanges[88] = CR_Limbu;
- CodeRanges[89] = CR_Linear_B;
- CodeRanges[90] = CR_Malayalam;
- CodeRanges[91] = CR_Mongolian;
- CodeRanges[92] = CR_Myanmar;
- CodeRanges[93] = CR_New_Tai_Lue;
- CodeRanges[94] = CR_Ogham;
- CodeRanges[95] = CR_Old_Italic;
- CodeRanges[96] = CR_Old_Persian;
- CodeRanges[97] = CR_Oriya;
- CodeRanges[98] = CR_Osmanya;
- CodeRanges[99] = CR_Runic;
- CodeRanges[100] = CR_Shavian;
- CodeRanges[101] = CR_Sinhala;
- CodeRanges[102] = CR_Syloti_Nagri;
- CodeRanges[103] = CR_Syriac;
- CodeRanges[104] = CR_Tagalog;
- CodeRanges[105] = CR_Tagbanwa;
- CodeRanges[106] = CR_Tai_Le;
- CodeRanges[107] = CR_Tamil;
- CodeRanges[108] = CR_Telugu;
- CodeRanges[109] = CR_Thaana;
- CodeRanges[110] = CR_Thai;
- CodeRanges[111] = CR_Tibetan;
- CodeRanges[112] = CR_Tifinagh;
- CodeRanges[113] = CR_Ugaritic;
- CodeRanges[114] = CR_Yi;
-#endif /* USE_UNICODE_PROPERTIES */
-
- CodeRangeTableInited = 1;
- THREAD_ATOMIC_END;
-}
-
-extern int
-onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
-{
- if (
-#ifdef USE_UNICODE_PROPERTIES
- ctype <= ONIGENC_MAX_STD_CTYPE &&
-#endif
- code < 256) {
- return ONIGENC_IS_UNICODE_ISO_8859_1_CTYPE(code, ctype);
- }
-
- if (ctype >= CODE_RANGES_NUM) {
- return ONIGENC_ERR_TYPE_BUG;
- }
-
- if (CodeRangeTableInited == 0) init_code_range_array();
-
- return onig_is_in_code_range((UChar* )CodeRanges[ctype], code);
-}
-
-
-extern int
-onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
-{
- if (ctype >= CODE_RANGES_NUM) {
- return ONIGENC_ERR_TYPE_BUG;
- }
-
- if (CodeRangeTableInited == 0) init_code_range_array();
-
- *ranges = CodeRanges[ctype];
-
- return 0;
-}
-
-extern int
-onigenc_utf16_32_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
- const OnigCodePoint* ranges[])
-{
- *sb_out = 0x00;
- return onigenc_unicode_ctype_code_range(ctype, ranges);
-}
-
-#include "ruby/st.h"
-
-#define PROPERTY_NAME_MAX_SIZE 20
-
-static st_table* NameCtypeTable;
-static int NameTableInited = 0;
-
-static int init_name_ctype_table(void)
-{
- PosixBracketEntryType *pb;
-
- THREAD_ATOMIC_START;
-
- NameCtypeTable = onig_st_init_strend_table_with_size(100);
- if (ONIG_IS_NULL(NameCtypeTable)) return ONIGERR_MEMORY;
-
- for (pb = HashEntryData; ONIG_IS_NOT_NULL(pb->name); pb++) {
- onig_st_insert_strend(NameCtypeTable, pb->name, pb->name + pb->len,
- (st_data_t )pb->ctype);
- }
-
- NameTableInited = 1;
- THREAD_ATOMIC_END;
- return 0;
-}
-
-extern int
-onigenc_unicode_property_name_to_ctype(OnigEncoding enc, UChar* name, UChar* end)
-{
- int len, ctype;
- UChar buf[PROPERTY_NAME_MAX_SIZE];
- UChar *p;
- OnigCodePoint code;
-
- p = name;
- len = 0;
- while (p < end) {
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- if (code >= 0x80)
- return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
-
- buf[len++] = (UChar )code;
- if (len >= PROPERTY_NAME_MAX_SIZE)
- return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
-
- p += enc_len(enc, p, end);
- }
-
- buf[len] = 0;
-
- if (NameTableInited == 0) init_name_ctype_table();
-
- if (onig_st_lookup_strend(NameCtypeTable, buf, buf + len,
- (void*)&ctype) == 0) {
- return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
- }
-
- return ctype;
-}
-
-
-static int
-code2_cmp(OnigCodePoint* x, OnigCodePoint* y)
-{
- if (x[0] == y[0] && x[1] == y[1]) return 0;
- return 1;
-}
-
-static int
-code2_hash(OnigCodePoint* x)
-{
- return (int )(x[0] + x[1]);
-}
-
-static const struct st_hash_type type_code2_hash = {
- code2_cmp,
- code2_hash,
-};
-
-static int
-code3_cmp(OnigCodePoint* x, OnigCodePoint* y)
-{
- if (x[0] == y[0] && x[1] == y[1] && x[2] == y[2]) return 0;
- return 1;
-}
-
-static int
-code3_hash(OnigCodePoint* x)
-{
- return (int )(x[0] + x[1] + x[2]);
-}
-
-static const struct st_hash_type type_code3_hash = {
- code3_cmp,
- code3_hash,
-};
-
-
-static st_table* FoldTable; /* fold-1, fold-2, fold-3 */
-static st_table* Unfold1Table;
-static st_table* Unfold2Table;
-static st_table* Unfold3Table;
-static int CaseFoldInited = 0;
-
-static int init_case_fold_table(void)
-{
- const CaseFold_11_Type *p;
- const CaseUnfold_11_Type *p1;
- const CaseUnfold_12_Type *p2;
- const CaseUnfold_13_Type *p3;
- int i;
-
- THREAD_ATOMIC_START;
-
- FoldTable = st_init_numtable_with_size(1200);
- if (ONIG_IS_NULL(FoldTable)) return ONIGERR_MEMORY;
- for (i = 0; i < sizeof(CaseFold)/sizeof(CaseFold_11_Type); i++) {
- p = &CaseFold[i];
- st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
- }
- for (i = 0; i < sizeof(CaseFold_Locale)/sizeof(CaseFold_11_Type); i++) {
- p = &CaseFold_Locale[i];
- st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
- }
-
- Unfold1Table = st_init_numtable_with_size(1000);
- if (ONIG_IS_NULL(Unfold1Table)) return ONIGERR_MEMORY;
-
- for (i = 0; i < sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type); i++) {
- p1 = &CaseUnfold_11[i];
- st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
- }
- for (i = 0; i < sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type);
- i++) {
- p1 = &CaseUnfold_11_Locale[i];
- st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
- }
-
- Unfold2Table = st_init_table_with_size(&type_code2_hash, 200);
- if (ONIG_IS_NULL(Unfold2Table)) return ONIGERR_MEMORY;
-
- for (i = 0; i < sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type); i++) {
- p2 = &CaseUnfold_12[i];
- st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
- }
- for (i = 0; i < sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type);
- i++) {
- p2 = &CaseUnfold_12_Locale[i];
- st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
- }
-
- Unfold3Table = st_init_table_with_size(&type_code3_hash, 30);
- if (ONIG_IS_NULL(Unfold3Table)) return ONIGERR_MEMORY;
-
- for (i = 0; i < sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type); i++) {
- p3 = &CaseUnfold_13[i];
- st_add_direct(Unfold3Table, (st_data_t )p3->from, (st_data_t )(&p3->to));
- }
-
- CaseFoldInited = 1;
- THREAD_ATOMIC_END;
- return 0;
-}
-
-extern int
-onigenc_unicode_mbc_case_fold(OnigEncoding enc,
- OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold)
-{
- CodePointList3 *to;
- OnigCodePoint code;
- int i, len, rlen;
- const UChar *p = *pp;
-
- if (CaseFoldInited == 0) init_case_fold_table();
-
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- len = enc_len(enc, p, end);
- *pp += len;
-
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
- if (code == 0x0049) {
- return ONIGENC_CODE_TO_MBC(enc, 0x0131, fold);
- }
- else if (code == 0x0130) {
- return ONIGENC_CODE_TO_MBC(enc, 0x0069, fold);
- }
- }
-#endif
-
- if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) {
- if (to->n == 1) {
- return ONIGENC_CODE_TO_MBC(enc, to->code[0], fold);
- }
-#if 0
- /* NO NEEDS TO CHECK */
- else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
-#else
- else {
-#endif
- rlen = 0;
- for (i = 0; i < to->n; i++) {
- len = ONIGENC_CODE_TO_MBC(enc, to->code[i], fold);
- fold += len;
- rlen += len;
- }
- return rlen;
- }
- }
-
- for (i = 0; i < len; i++) {
- *fold++ = *p++;
- }
- return len;
-}
-
-extern int
-onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- const CaseUnfold_11_Type* p11;
- OnigCodePoint code;
- int i, j, k, r;
-
- /* if (CaseFoldInited == 0) init_case_fold_table(); */
-
- for (i = 0; i < sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type); i++) {
- p11 = &CaseUnfold_11[i];
- for (j = 0; j < p11->to.n; j++) {
- code = p11->from;
- r = (*f)(p11->to.code[j], &code, 1, arg);
- if (r != 0) return r;
-
- code = p11->to.code[j];
- r = (*f)(p11->from, &code, 1, arg);
- if (r != 0) return r;
-
- for (k = 0; k < j; k++) {
- r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]), 1, arg);
- if (r != 0) return r;
-
- r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]), 1, arg);
- if (r != 0) return r;
- }
- }
- }
-
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
- code = 0x0131;
- r = (*f)(0x0049, &code, 1, arg);
- if (r != 0) return r;
- code = 0x0049;
- r = (*f)(0x0131, &code, 1, arg);
- if (r != 0) return r;
-
- code = 0x0130;
- r = (*f)(0x0069, &code, 1, arg);
- if (r != 0) return r;
- code = 0x0069;
- r = (*f)(0x0130, &code, 1, arg);
- if (r != 0) return r;
- }
- else {
-#endif
- for (i = 0; i < sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type);
- i++) {
- p11 = &CaseUnfold_11_Locale[i];
- for (j = 0; j < p11->to.n; j++) {
- code = p11->from;
- r = (*f)(p11->to.code[j], &code, 1, arg);
- if (r != 0) return r;
-
- code = p11->to.code[j];
- r = (*f)(p11->from, &code, 1, arg);
- if (r != 0) return r;
-
- for (k = 0; k < j; k++) {
- r = (*f)(p11->to.code[j], (OnigCodePoint* )(&p11->to.code[k]),
- 1, arg);
- if (r != 0) return r;
-
- r = (*f)(p11->to.code[k], (OnigCodePoint* )(&p11->to.code[j]),
- 1, arg);
- if (r != 0) return r;
- }
- }
- }
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- }
-#endif
-
- if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- for (i = 0; i < sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type); i++) {
- for (j = 0; j < CaseUnfold_12[i].to.n; j++) {
- r = (*f)(CaseUnfold_12[i].to.code[j],
- (OnigCodePoint* )CaseUnfold_12[i].from, 2, arg);
- if (r != 0) return r;
-
- for (k = 0; k < CaseUnfold_12[i].to.n; k++) {
- if (k == j) continue;
-
- r = (*f)(CaseUnfold_12[i].to.code[j],
- (OnigCodePoint* )(&CaseUnfold_12[i].to.code[k]), 1, arg);
- if (r != 0) return r;
- }
- }
- }
-
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) {
-#endif
- for (i = 0; i < sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type);
- i++) {
- for (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) {
- r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
- (OnigCodePoint* )CaseUnfold_12_Locale[i].from, 2, arg);
- if (r != 0) return r;
-
- for (k = 0; k < CaseUnfold_12_Locale[i].to.n; k++) {
- if (k == j) continue;
-
- r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
- (OnigCodePoint* )(&CaseUnfold_12_Locale[i].to.code[k]),
- 1, arg);
- if (r != 0) return r;
- }
- }
- }
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- }
-#endif
-
- for (i = 0; i < sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type); i++) {
- for (j = 0; j < CaseUnfold_13[i].to.n; j++) {
- r = (*f)(CaseUnfold_13[i].to.code[j],
- (OnigCodePoint* )CaseUnfold_13[i].from, 3, arg);
- if (r != 0) return r;
-
- for (k = 0; k < CaseUnfold_13[i].to.n; k++) {
- if (k == j) continue;
-
- r = (*f)(CaseUnfold_13[i].to.code[j],
- (OnigCodePoint* )(&CaseUnfold_13[i].to.code[k]), 1, arg);
- if (r != 0) return r;
- }
- }
- }
- }
-
- return 0;
-}
-
-extern int
-onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
- OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end,
- OnigCaseFoldCodeItem items[])
-{
- int n, i, j, k, len;
- OnigCodePoint code, codes[3];
- CodePointList3 *to, *z3;
- CodePointList2 *z2;
-
- if (CaseFoldInited == 0) init_case_fold_table();
-
- n = 0;
-
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- len = enc_len(enc, p, end);
-
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
- if (code == 0x0049) {
- items[0].byte_len = len;
- items[0].code_len = 1;
- items[0].code[0] = 0x0131;
- return 1;
- }
- else if (code == 0x0130) {
- items[0].byte_len = len;
- items[0].code_len = 1;
- items[0].code[0] = 0x0069;
- return 1;
- }
- else if (code == 0x0131) {
- items[0].byte_len = len;
- items[0].code_len = 1;
- items[0].code[0] = 0x0049;
- return 1;
- }
- else if (code == 0x0069) {
- items[0].byte_len = len;
- items[0].code_len = 1;
- items[0].code[0] = 0x0130;
- return 1;
- }
- }
-#endif
-
- if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0) {
- if (to->n == 1) {
- OnigCodePoint orig_code = code;
-
- items[0].byte_len = len;
- items[0].code_len = 1;
- items[0].code[0] = to->code[0];
- n++;
-
- code = to->code[0];
- if (onig_st_lookup(Unfold1Table, (st_data_t )code, (void* )&to) != 0) {
- for (i = 0; i < to->n; i++) {
- if (to->code[i] != orig_code) {
- items[n].byte_len = len;
- items[n].code_len = 1;
- items[n].code[0] = to->code[i];
- n++;
- }
- }
- }
- }
- else if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- OnigCodePoint cs[3][4];
- int fn, ncs[3];
-
- for (fn = 0; fn < to->n; fn++) {
- cs[fn][0] = to->code[fn];
- if (onig_st_lookup(Unfold1Table, (st_data_t )cs[fn][0],
- (void* )&z3) != 0) {
- for (i = 0; i < z3->n; i++) {
- cs[fn][i+1] = z3->code[i];
- }
- ncs[fn] = z3->n + 1;
- }
- else
- ncs[fn] = 1;
- }
-
- if (fn == 2) {
- for (i = 0; i < ncs[0]; i++) {
- for (j = 0; j < ncs[1]; j++) {
- items[n].byte_len = len;
- items[n].code_len = 2;
- items[n].code[0] = cs[0][i];
- items[n].code[1] = cs[1][j];
- n++;
- }
- }
-
- if (onig_st_lookup(Unfold2Table, (st_data_t )to->code,
- (void* )&z2) != 0) {
- for (i = 0; i < z2->n; i++) {
- if (z2->code[i] == code) continue;
-
- items[n].byte_len = len;
- items[n].code_len = 1;
- items[n].code[0] = z2->code[i];
- n++;
- }
- }
- }
- else {
- for (i = 0; i < ncs[0]; i++) {
- for (j = 0; j < ncs[1]; j++) {
- for (k = 0; k < ncs[2]; k++) {
- items[n].byte_len = len;
- items[n].code_len = 3;
- items[n].code[0] = cs[0][i];
- items[n].code[1] = cs[1][j];
- items[n].code[2] = cs[2][k];
- n++;
- }
- }
- }
-
- if (onig_st_lookup(Unfold3Table, (st_data_t )to->code,
- (void* )&z2) != 0) {
- for (i = 0; i < z2->n; i++) {
- if (z2->code[i] == code) continue;
-
- items[n].byte_len = len;
- items[n].code_len = 1;
- items[n].code[0] = z2->code[i];
- n++;
- }
- }
- }
-
- /* multi char folded code is not head of another folded multi char */
- flag = 0; /* DISABLE_CASE_FOLD_MULTI_CHAR(flag); */
- }
- }
- else {
- if (onig_st_lookup(Unfold1Table, (st_data_t )code, (void* )&to) != 0) {
- for (i = 0; i < to->n; i++) {
- items[n].byte_len = len;
- items[n].code_len = 1;
- items[n].code[0] = to->code[i];
- n++;
- }
- }
- }
-
-
- if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- p += len;
- if (p < end) {
- int clen;
-
- codes[0] = code;
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0
- && to->n == 1) {
- codes[1] = to->code[0];
- }
- else
- codes[1] = code;
-
- clen = enc_len(enc, p, end);
- len += clen;
- if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) {
- for (i = 0; i < z2->n; i++) {
- items[n].byte_len = len;
- items[n].code_len = 1;
- items[n].code[0] = z2->code[i];
- n++;
- }
- }
-
- p += clen;
- if (p < end) {
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- if (onig_st_lookup(FoldTable, (st_data_t )code, (void* )&to) != 0
- && to->n == 1) {
- codes[2] = to->code[0];
- }
- else
- codes[2] = code;
-
- clen = enc_len(enc, p, end);
- len += clen;
- if (onig_st_lookup(Unfold3Table, (st_data_t )codes,
- (void* )&z2) != 0) {
- for (i = 0; i < z2->n; i++) {
- items[n].byte_len = len;
- items[n].code_len = 1;
- items[n].code[0] = z2->code[i];
- n++;
- }
- }
- }
- }
- }
-
- return n;
-}
diff --git a/enc/us_ascii.c b/enc/us_ascii.c
deleted file mode 100644
index 9201679871..0000000000
--- a/enc/us_ascii.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "regenc.h"
-
-extern int
-mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc)
-{
- if (*p & 0x80)
- return ONIGENC_CONSTRUCT_MBCLEN_INVALID();
- return ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1);
-}
-
-OnigEncodingDefine(us_ascii, US_ASCII) = {
- mbc_enc_len,
- "US-ASCII",/* name */
- 1, /* max byte length */
- 1, /* min byte length */
- onigenc_is_mbc_newline_0x0a,
- onigenc_single_byte_mbc_to_code,
- onigenc_single_byte_code_to_mbclen,
- onigenc_single_byte_code_to_mbc,
- onigenc_ascii_mbc_case_fold,
- onigenc_ascii_apply_all_case_fold,
- onigenc_ascii_get_case_fold_codes_by_str,
- onigenc_minimum_property_name_to_ctype,
- onigenc_ascii_is_code_ctype,
- onigenc_not_support_get_ctype_code_range,
- onigenc_single_byte_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/enc/utf8.c b/enc/utf8.c
deleted file mode 100644
index adfb2742a5..0000000000
--- a/enc/utf8.c
+++ /dev/null
@@ -1,506 +0,0 @@
-/**********************************************************************
- utf8.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regenc.h"
-
-#define USE_INVALID_CODE_SCHEME
-
-#ifdef USE_INVALID_CODE_SCHEME
-/* virtual codepoint values for invalid encoding byte 0xfe and 0xff */
-#define INVALID_CODE_FE 0xfffffffe
-#define INVALID_CODE_FF 0xffffffff
-#define VALID_CODE_LIMIT 0x7fffffff
-#endif
-
-#define utf8_islead(c) ((UChar )((c) & 0xc0) != 0x80)
-
-static const int EncLen_UTF8[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-
-typedef enum {
- FAILURE = -2,
- ACCEPT,
- S0, S1, S2, S3,
- S4, S5, S6, S7
-} state_t;
-#define A ACCEPT
-#define F FAILURE
-static const signed char trans[][0x100] = {
- { /* S0 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 1 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 2 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 3 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 4 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 5 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 6 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 7 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* b */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* c */ F, F, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* d */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* e */ 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3,
- /* f */ 5, 6, 6, 6, 7, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S1 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* 9 */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* a */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* b */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S2 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S3 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* 9 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* a */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S4 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* 9 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* a */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* b */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S5 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 9 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* a */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* b */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S6 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* 9 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* a */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* b */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
- { /* S7 0 1 2 3 4 5 6 7 8 9 a b c d e f */
- /* 0 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 1 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 2 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 3 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 4 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 5 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 6 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 7 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* 8 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- /* 9 */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* a */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* b */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* c */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* d */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* e */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,
- /* f */ F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
- },
-};
-#undef A
-#undef F
-
-static int
-utf8_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc)
-{
- int firstbyte = *p++;
- state_t s;
- s = trans[0][firstbyte];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(1) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-1);
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(2) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-2);
- s = trans[s][*p++];
- if (s < 0) return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(3) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_UTF8[firstbyte]-3);
- s = trans[s][*p++];
- return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(4) :
- ONIGENC_CONSTRUCT_MBCLEN_INVALID();
-}
-
-static int
-utf8_is_mbc_newline(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- if (p < end) {
- if (*p == 0x0a) return 1;
-
-#ifdef USE_UNICODE_ALL_LINE_TERMINATORS
-#ifndef USE_CRNL_AS_LINE_TERMINATOR
- if (*p == 0x0d) return 1;
-#endif
- if (p + 1 < end) {
- if (*(p+1) == 0x85 && *p == 0xc2) /* U+0085 */
- return 1;
- if (p + 2 < end) {
- if ((*(p+2) == 0xa8 || *(p+2) == 0xa9)
- && *(p+1) == 0x80 && *p == 0xe2) /* U+2028, U+2029 */
- return 1;
- }
- }
-#endif
- }
-
- return 0;
-}
-
-static OnigCodePoint
-utf8_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- int c, len;
- OnigCodePoint n;
-
- len = enc_len(ONIG_ENCODING_UTF8, p, end);
- c = *p++;
- if (len > 1) {
- len--;
- n = c & ((1 << (6 - len)) - 1);
- while (len--) {
- c = *p++;
- n = (n << 6) | (c & ((1 << 6) - 1));
- }
- return n;
- }
- else {
-#ifdef USE_INVALID_CODE_SCHEME
- if (c > 0xfd) {
- return ((c == 0xfe) ? INVALID_CODE_FE : INVALID_CODE_FF);
- }
-#endif
- return (OnigCodePoint )c;
- }
-}
-
-static int
-utf8_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
-{
- if ((code & 0xffffff80) == 0) return 1;
- else if ((code & 0xfffff800) == 0) return 2;
- else if ((code & 0xffff0000) == 0) return 3;
- else if ((code & 0xffe00000) == 0) return 4;
- else if ((code & 0xfc000000) == 0) return 5;
- else if ((code & 0x80000000) == 0) return 6;
-#ifdef USE_INVALID_CODE_SCHEME
- else if (code == INVALID_CODE_FE) return 1;
- else if (code == INVALID_CODE_FF) return 1;
-#endif
- else
- return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
-}
-
-#if 0
-static int
-utf8_code_to_mbc_first(OnigCodePoint code)
-{
- if ((code & 0xffffff80) == 0)
- return code;
- else {
- if ((code & 0xfffff800) == 0)
- return ((code>>6)& 0x1f) | 0xc0;
- else if ((code & 0xffff0000) == 0)
- return ((code>>12) & 0x0f) | 0xe0;
- else if ((code & 0xffe00000) == 0)
- return ((code>>18) & 0x07) | 0xf0;
- else if ((code & 0xfc000000) == 0)
- return ((code>>24) & 0x03) | 0xf8;
- else if ((code & 0x80000000) == 0)
- return ((code>>30) & 0x01) | 0xfc;
- else {
- return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
- }
- }
-}
-#endif
-
-static int
-utf8_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
-{
-#define UTF8_TRAILS(code, shift) (UChar )((((code) >> (shift)) & 0x3f) | 0x80)
-#define UTF8_TRAIL0(code) (UChar )(((code) & 0x3f) | 0x80)
-
- if ((code & 0xffffff80) == 0) {
- *buf = (UChar )code;
- return 1;
- }
- else {
- UChar *p = buf;
-
- if ((code & 0xfffff800) == 0) {
- *p++ = (UChar )(((code>>6)& 0x1f) | 0xc0);
- }
- else if ((code & 0xffff0000) == 0) {
- *p++ = (UChar )(((code>>12) & 0x0f) | 0xe0);
- *p++ = UTF8_TRAILS(code, 6);
- }
- else if ((code & 0xffe00000) == 0) {
- *p++ = (UChar )(((code>>18) & 0x07) | 0xf0);
- *p++ = UTF8_TRAILS(code, 12);
- *p++ = UTF8_TRAILS(code, 6);
- }
- else if ((code & 0xfc000000) == 0) {
- *p++ = (UChar )(((code>>24) & 0x03) | 0xf8);
- *p++ = UTF8_TRAILS(code, 18);
- *p++ = UTF8_TRAILS(code, 12);
- *p++ = UTF8_TRAILS(code, 6);
- }
- else if ((code & 0x80000000) == 0) {
- *p++ = (UChar )(((code>>30) & 0x01) | 0xfc);
- *p++ = UTF8_TRAILS(code, 24);
- *p++ = UTF8_TRAILS(code, 18);
- *p++ = UTF8_TRAILS(code, 12);
- *p++ = UTF8_TRAILS(code, 6);
- }
-#ifdef USE_INVALID_CODE_SCHEME
- else if (code == INVALID_CODE_FE) {
- *p = 0xfe;
- return 1;
- }
- else if (code == INVALID_CODE_FF) {
- *p = 0xff;
- return 1;
- }
-#endif
- else {
- return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
- }
-
- *p++ = UTF8_TRAIL0(code);
- return p - buf;
- }
-}
-
-static int
-utf8_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp,
- const UChar* end, UChar* fold, OnigEncoding enc)
-{
- const UChar* p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
-#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
- if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
- if (*p == 0x49) {
- *fold++ = 0xc4;
- *fold = 0xb1;
- (*pp)++;
- return 2;
- }
- }
-#endif
-
- *fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1; /* return byte length of converted char to lower */
- }
- else {
- return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF8, flag,
- pp, end, fold);
- }
-}
-
-#if 0
-static int
-utf8_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
-{
- const UChar* p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
- (*pp)++;
- return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
- }
- else {
- (*pp) += enc_len(ONIG_ENCODING_UTF8, p);
-
- if (*p == 0xc3) {
- int c = *(p + 1);
- if (c >= 0x80) {
- if (c <= (UChar )0x9e) { /* upper */
- if (c == (UChar )0x97) return FALSE;
- return TRUE;
- }
- else if (c >= (UChar )0xa0 && c <= (UChar )0xbe) { /* lower */
- if (c == (UChar )'\267') return FALSE;
- return TRUE;
- }
- else if (c == (UChar )0x9f &&
- (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
- return TRUE;
- }
- }
- }
- }
-
- return FALSE;
-}
-#endif
-
-
-static int
-utf8_get_ctype_code_range(int ctype, OnigCodePoint *sb_out,
- const OnigCodePoint* ranges[], OnigEncoding enc)
-{
- *sb_out = 0x80;
- return onigenc_unicode_ctype_code_range(ctype, ranges);
-}
-
-
-static UChar*
-utf8_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
-{
- const UChar *p;
-
- if (s <= start) return (UChar* )s;
- p = s;
-
- while (!utf8_islead(*p) && p > start) p--;
- return (UChar* )p;
-}
-
-static int
-utf8_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF8,
- flag, p, end, items);
-}
-
-OnigEncodingDefine(utf8, UTF8) = {
- utf8_mbc_enc_len,
- "UTF-8", /* name */
- 6, /* max byte length */
- 1, /* min byte length */
- utf8_is_mbc_newline,
- utf8_mbc_to_code,
- utf8_code_to_mbclen,
- utf8_code_to_mbc,
- utf8_mbc_case_fold,
- onigenc_unicode_apply_all_case_fold,
- utf8_get_case_fold_codes_by_str,
- onigenc_unicode_property_name_to_ctype,
- onigenc_unicode_is_code_ctype,
- utf8_get_ctype_code_range,
- utf8_left_adjust_char_head,
- onigenc_always_true_is_allowed_reverse_match
-};
diff --git a/encoding.c b/encoding.c
deleted file mode 100644
index ea00deb9e2..0000000000
--- a/encoding.c
+++ /dev/null
@@ -1,1001 +0,0 @@
-/**********************************************************************
-
- encoding.c -
-
- $Author$
- $Date$
- created at: Thu May 24 17:23:27 JST 2007
-
- Copyright (C) 2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-#include "ruby/encoding.h"
-#include "regenc.h"
-#include <ctype.h>
-#ifdef HAVE_LANGINFO_H
-#include <langinfo.h>
-#endif
-
-static ID id_encoding, id_based_encoding;
-static VALUE rb_cEncoding;
-
-struct rb_encoding_entry {
- const char *name;
- rb_encoding *enc;
-};
-
-static struct rb_encoding_entry *enc_table;
-static int enc_table_count;
-static int enc_table_size;
-static st_table *enc_table_alias;
-
-#define ENC_UNINITIALIZED (&rb_cEncoding)
-#define enc_initialized_p(enc) ((enc)->auxiliary_data != &rb_cEncoding)
-#define ENC_FROM_ENCODING(enc) ((VALUE)(enc)->auxiliary_data)
-
-#define ENC_DUMMY FL_USER2
-#define ENC_DUMMY_P(enc) (RBASIC(enc)->flags & ENC_DUMMY)
-
-static void
-enc_mark(void *ptr)
-{
-}
-
-static VALUE
-enc_new(rb_encoding *encoding)
-{
- VALUE enc = Data_Wrap_Struct(rb_cEncoding, enc_mark, -1, encoding);
- encoding->auxiliary_data = (void *)enc;
- return enc;
-}
-
-VALUE
-rb_enc_from_encoding(rb_encoding *encoding)
-{
- if (!encoding) return Qnil;
- if (enc_initialized_p(encoding))
- return ENC_FROM_ENCODING(encoding);
- return enc_new(encoding);
-}
-
-static int
-enc_check_encoding(VALUE obj)
-{
- int index;
- if (SPECIAL_CONST_P(obj) || BUILTIN_TYPE(obj) != T_DATA ||
- RDATA(obj)->dmark != enc_mark) {
- return -1;
- }
- index = rb_enc_to_index(RDATA(obj)->data);
- if (rb_enc_from_index(index) != RDATA(obj)->data)
- return -1;
- return index;
-}
-
-int
-rb_to_encoding_index(VALUE enc)
-{
- int idx;
-
- if (NIL_P(enc)) return 0;
- idx = enc_check_encoding(enc);
- if (idx >= 0) {
- return idx;
- }
- else if (NIL_P(enc = rb_check_string_type(enc))) {
- return -1;
- }
- else {
- return rb_enc_find_index(StringValueCStr(enc));
- }
-}
-
-rb_encoding *
-rb_to_encoding(VALUE enc)
-{
- int idx;
-
- if (NIL_P(enc)) return 0;
- idx = enc_check_encoding(enc);
- if (idx >= 0) return RDATA(enc)->data;
- if (NIL_P(enc = rb_check_string_type(enc))) {
- return 0;
- }
- if ((idx = rb_enc_find_index(StringValueCStr(enc))) < 0) {
- rb_raise(rb_eArgError, "unknown encoding name - %s", RSTRING_PTR(enc));
- }
- return rb_enc_from_index(idx);
-}
-
-void
-rb_gc_mark_encodings(void)
-{
- int i;
- for (i = 0; i < enc_table_size; ++i) {
- rb_encoding *enc = enc_table[i].enc;
- if (enc && enc_initialized_p(enc)) {
- rb_gc_mark(ENC_FROM_ENCODING(enc));
- }
- }
-}
-
-static int
-enc_table_expand(int newsize)
-{
- struct rb_encoding_entry *ent;
-
- if (enc_table_size >= newsize) return newsize;
- ent = realloc(enc_table, sizeof(*enc_table) * newsize);
- if (!ent) return -1;
- memset(ent + enc_table_size, 0, sizeof(*ent)*(newsize - enc_table_size));
- enc_table = ent;
- enc_table_size = newsize;
- return newsize;
-}
-
-static int
-enc_register_at(int index, const char *name, rb_encoding *encoding)
-{
- struct rb_encoding_entry *ent = &enc_table[index];
-
- ent->name = name;
- if (!ent->enc) ent->enc = malloc(sizeof(rb_encoding));
- *ent->enc = *encoding;
- encoding = ent->enc;
- encoding->name = name;
- if (rb_cEncoding) {
- /* initialize encoding data */
- enc_new(encoding);
- }
- else {
- encoding->auxiliary_data = ENC_UNINITIALIZED;
- }
- return index;
-}
-
-static int
-enc_register(const char *name, rb_encoding *encoding)
-{
- int index = enc_table_count;
-
- if (index >= ENCODING_INLINE_MAX) index = enc_table_size;
- if ((index = enc_table_expand(index + 1)) < 0) return -1;
- enc_table_count = index;
- return enc_register_at(index - 1, name, encoding);
-}
-
-static void set_encoding_const(const char *, rb_encoding *);
-int rb_enc_registered(const char *name);
-
-int
-rb_enc_register(const char *name, rb_encoding *encoding)
-{
- int index = rb_enc_registered(name);
-
- if (index >= 0) {
- rb_encoding *oldenc = rb_enc_from_index(index);
- if (strcasecmp(name, rb_enc_name(oldenc))) {
- st_data_t key = (st_data_t)name, alias;
- st_delete(enc_table_alias, &key, &alias);
- index = enc_register(name, encoding);
- }
- else if (enc_initialized_p(oldenc) &&
- !ENC_DUMMY_P(ENC_FROM_ENCODING(oldenc))) {
- enc_register_at(index, name, encoding);
- }
- else {
- rb_raise(rb_eArgError, "encoding %s is already registered", name);
- }
- }
- else {
- index = enc_register(name, encoding);
- }
- set_encoding_const(name, rb_enc_from_index(index));
- return index;
-}
-
-static void
-enc_check_duplication(const char *name)
-{
- if (rb_enc_registered(name) >= 0) {
- rb_raise(rb_eArgError, "encoding %s is already registered", name);
- }
-}
-
-static VALUE
-set_based_encoding(int index, rb_encoding *based)
-{
- VALUE enc = rb_enc_from_encoding(enc_table[index].enc);
-
- rb_ivar_set(enc, id_based_encoding, rb_enc_from_encoding(based));
- return enc;
-}
-
-int
-rb_enc_replicate(const char *name, rb_encoding *encoding)
-{
- int index = enc_table_size;
-
- enc_check_duplication(name);
- if (enc_table_expand(index + 1) < 0) return -1;
- enc_register_at(index, name, encoding);
- set_based_encoding(index, encoding);
- return index;
-}
-
-int
-rb_define_dummy_encoding(const char *name)
-{
- int index = enc_table_size;
- rb_encoding *encoding;
- VALUE enc;
-
- enc_check_duplication(name);
- if (index < ENCODING_INLINE_MAX) index = ENCODING_INLINE_MAX;
- if (enc_table_expand(index + 1) < 0) return -1;
- encoding = rb_ascii8bit_encoding();
- enc_register_at(index, name, encoding);
- enc = set_based_encoding(index, encoding);
- FL_SET(enc, ENC_DUMMY);
- return index;
-}
-
-int
-rb_enc_dummy_p(rb_encoding *enc)
-{
- VALUE encoding = rb_enc_from_encoding(enc);
- return ENC_DUMMY_P(encoding);
-}
-
-/*
- * call-seq:
- * enc.dummy? => true or false
- *
- * Returns true for dummy encoding.
- * A dummy encoding is a encoding which character handling is not properly
- * implemented.
- * It is used for stateful encoding.
- *
- * Encoding::ISO_2022_JP.dummy? #=> true
- * Encoding::UTF_8.dummy? #=> false
- *
- */
-static VALUE
-enc_dummy_p(VALUE enc)
-{
- return rb_enc_dummy_p(rb_to_encoding(enc)) ? Qtrue : Qfalse;
-}
-
-static int
-enc_alias(const char *alias, const char *orig)
-{
- st_data_t data;
- int idx;
-
- if (!enc_table_alias) {
- enc_table_alias = st_init_strcasetable();
- }
- if ((idx = rb_enc_find_index(orig)) < 0) {
- if (!st_lookup(enc_table_alias, (st_data_t)orig, &data))
- return -1;
- idx = (int)data;
- }
- st_insert(enc_table_alias, (st_data_t)alias, (st_data_t)idx);
- return idx;
-}
-
-int
-rb_enc_alias(const char *alias, const char *orig)
-{
- enc_check_duplication(alias);
- return enc_alias(alias, orig);
-}
-
-enum {
- ENCINDEX_ASCII,
- ENCINDEX_EUC_JP,
- ENCINDEX_SJIS,
- ENCINDEX_UTF8,
- ENCINDEX_BUILTIN_MAX
-};
-
-void
-rb_enc_init(void)
-{
- enc_table_count = enc_table_expand(ENCINDEX_BUILTIN_MAX);
-#define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(ONIG_ENCODING_##enc), ONIG_ENCODING_##enc)
- ENC_REGISTER(ASCII);
- ENC_REGISTER(EUC_JP);
- ENC_REGISTER(SJIS);
- ENC_REGISTER(UTF8);
-#undef ENC_REGISTER
- enc_alias("ASCII", rb_enc_name(ONIG_ENCODING_ASCII));
- enc_alias("BINARY", rb_enc_name(ONIG_ENCODING_ASCII));
- enc_alias("eucJP", rb_enc_name(ONIG_ENCODING_EUC_JP)); /* UI-OSF Application Platform Profile for Japanese Environment Version 1.1 */
- enc_alias("SJIS", rb_enc_name(ONIG_ENCODING_SJIS));
-}
-
-rb_encoding *
-rb_enc_from_index(int index)
-{
- if (!enc_table) {
- rb_enc_init();
- }
- if (index < 0 || enc_table_size <= index) {
- return 0;
- }
- return enc_table[index].enc;
-}
-
-int
-rb_enc_registered(const char *name)
-{
- int i;
- st_data_t alias = 0;
-
- if (!name) return -1;
- if (!enc_table) {
- rb_enc_init();
- }
- for (i=0; i<enc_table_size; i++) {
- if (!enc_table[i].name) {
- if (i < ENCODING_INLINE_MAX - 1) i = ENCODING_INLINE_MAX - 1;
- continue;
- }
- if (strcasecmp(name, enc_table[i].name) == 0) {
- return i;
- }
- }
- if (!alias && enc_table_alias) {
- if (st_lookup(enc_table_alias, (st_data_t)name, &alias)) {
- return (int)alias;
- }
- }
- return -1;
-}
-
-static VALUE
-require_enc(VALUE enclib)
-{
- return rb_require_safe(enclib, rb_safe_level());
-}
-
-int
-rb_enc_find_index(const char *name)
-{
- int i = rb_enc_registered(name);
- if (i < 0) {
- VALUE enclib = rb_sprintf("enc/%s", name);
- char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib);
- while (s < e) {
- if (!ISALNUM(*s)) *s = '_';
- else if (ISUPPER(*s)) *s = tolower(*s);
- ++s;
- }
- OBJ_FREEZE(enclib);
- if (RTEST(rb_protect(require_enc, enclib, 0)))
- i = rb_enc_registered(name);
- rb_set_errinfo(Qnil);
- }
- return i;
-}
-
-rb_encoding *
-rb_enc_find(const char *name)
-{
- int idx = rb_enc_find_index(name);
- if (idx < 0) idx = 0;
- return rb_enc_from_index(idx);
-}
-
-static inline int
-enc_capable(VALUE obj)
-{
- if (IMMEDIATE_P(obj)) return Qfalse;
- switch (BUILTIN_TYPE(obj)) {
- case T_STRING:
- case T_REGEXP:
- case T_FILE:
- return Qtrue;
- case T_DATA:
- if (RDATA(obj)->dmark == enc_mark) return Qtrue;
- default:
- return Qfalse;
- }
-}
-
-static void
-enc_check_capable(VALUE x)
-{
- if (!enc_capable(x)) {
- const char *etype;
-
- if (NIL_P(x)) {
- etype = "nil";
- }
- else if (FIXNUM_P(x)) {
- etype = "Fixnum";
- }
- else if (SYMBOL_P(x)) {
- etype = "Symbol";
- }
- else if (rb_special_const_p(x)) {
- etype = RSTRING_PTR(rb_obj_as_string(x));
- }
- else {
- etype = rb_obj_classname(x);
- }
- rb_raise(rb_eTypeError, "wrong argument type %s (not encode capable)", etype);
- }
-}
-
-ID
-rb_id_encoding(void)
-{
- if (!id_encoding) {
- id_encoding = rb_intern("encoding");
- }
- return id_encoding;
-}
-
-void
-rb_enc_associate_index(VALUE obj, int idx)
-{
- enc_check_capable(obj);
- if (!ENC_CODERANGE_ASCIIONLY(obj) ||
- !rb_enc_asciicompat(rb_enc_from_index(idx))) {
- ENC_CODERANGE_CLEAR(obj);
- }
- if (idx < ENCODING_INLINE_MAX) {
- ENCODING_SET(obj, idx);
- return;
- }
- ENCODING_SET(obj, ENCODING_INLINE_MAX);
- rb_ivar_set(obj, rb_id_encoding(), INT2NUM(idx));
- return;
-}
-
-int
-rb_enc_to_index(rb_encoding *enc)
-{
- int i;
-
- if (!enc) return 0;
- for (i=0; i<enc_table_size; i++) {
- if (enc_table[i].enc == enc) {
- return i;
- }
- }
- return 0;
-}
-
-void
-rb_enc_associate(VALUE obj, rb_encoding *enc)
-{
- rb_enc_associate_index(obj, rb_enc_to_index(enc));
-}
-
-int
-rb_enc_get_index(VALUE obj)
-{
- int i;
-
- if (!enc_capable(obj)) return -1;
- i = ENCODING_GET(obj);
- if (i == ENCODING_INLINE_MAX) {
- VALUE iv;
-
- iv = rb_ivar_get(obj, rb_id_encoding());
- i = NUM2INT(iv);
- }
- return i;
-}
-
-rb_encoding*
-rb_enc_get(VALUE obj)
-{
- return rb_enc_from_index(rb_enc_get_index(obj));
-}
-
-rb_encoding*
-rb_enc_check(VALUE str1, VALUE str2)
-{
- rb_encoding *enc = rb_enc_compatible(str1, str2);
- if (!enc)
- rb_raise(rb_eArgError, "character encodings differ");
- return enc;
-}
-
-rb_encoding*
-rb_enc_compatible(VALUE str1, VALUE str2)
-{
- int idx1, idx2;
- rb_encoding *enc;
-
- idx1 = rb_enc_get_index(str1);
- idx2 = rb_enc_get_index(str2);
-
- if (idx1 == idx2) {
- return rb_enc_from_index(idx1);
- }
- if (BUILTIN_TYPE(str1) != T_STRING) {
- VALUE tmp = str1;
- int idx0 = idx1;
- str1 = str2;
- str2 = tmp;
- idx1 = idx2;
- idx2 = idx0;
- }
- if (BUILTIN_TYPE(str1) == T_STRING) {
- int cr1, cr2;
-
- cr1 = rb_enc_str_coderange(str1);
- if (BUILTIN_TYPE(str2) == T_STRING) {
- cr2 = rb_enc_str_coderange(str2);
- if (cr1 != cr2) {
- /* may need to handle ENC_CODERANGE_BROKEN */
- if (cr1 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx2);
- if (cr2 == ENC_CODERANGE_7BIT) return rb_enc_from_index(idx1);
- }
- if (cr2 == ENC_CODERANGE_7BIT) {
- if (idx1 == 0) return rb_enc_from_index(idx2);
- return rb_enc_from_index(idx1);
- }
- }
- if (cr1 == ENC_CODERANGE_7BIT &&
- rb_enc_asciicompat(enc = rb_enc_from_index(idx2)))
- return enc;
- }
- return 0;
-}
-
-void
-rb_enc_copy(VALUE obj1, VALUE obj2)
-{
- rb_enc_associate_index(obj1, rb_enc_get_index(obj2));
-}
-
-
-/*
- * call-seq:
- * obj.encoding => encoding
- *
- * Returns the Encoding object that represents the encoding of obj.
- */
-
-VALUE
-rb_obj_encoding(VALUE obj)
-{
- rb_encoding *enc = rb_enc_get(obj);
- if (!enc) {
- rb_raise(rb_eTypeError, "unknown encoding");
- }
- return rb_enc_from_encoding(enc);
-}
-
-
-char*
-rb_enc_nth(const char *p, const char *e, int nth, rb_encoding *enc)
-{
- int c;
-
- if (rb_enc_mbmaxlen(enc) == 1) {
- p += nth;
- }
- else if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
- p += nth * rb_enc_mbmaxlen(enc);
- }
- else {
- for (c=0; p<e && nth--; c++) {
- int n = rb_enc_mbclen(p, e, enc);
-
- p += n;
- }
- }
- return (char*)p;
-}
-
-long
-rb_enc_strlen(const char *p, const char *e, rb_encoding *enc)
-{
- long c;
-
- if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
- return (e - p) / rb_enc_mbminlen(enc);
- }
-
- for (c=0; p<e; c++) {
- int n = rb_enc_mbclen(p, e, enc);
-
- p += n;
- }
- return c;
-}
-
-int
-rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
-{
- int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
- n = MBCLEN_CHARFOUND(n);
- if (0 < n && n <= e-p)
- return n;
- else
- return 1;
-}
-
-int
-rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
-{
- int n;
- if (e <= p)
- return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1);
- n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
- if (e-p < n)
- return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n-(e-p));
- return n;
-}
-
-int
-rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
-{
- int c, l;
- if (e <= p)
- return -1;
- if (rb_enc_asciicompat(enc)) {
- c = (unsigned char)*p;
- if (!ISASCII(c))
- return -1;
- if (len) *len = 1;
- return c;
- }
- l = rb_enc_precise_mbclen(p, e, enc);
- if (!MBCLEN_CHARFOUND(l))
- return -1;
- c = rb_enc_codepoint(p, e, enc);
- if (!rb_enc_isascii(c, enc))
- return -1;
- if (len) *len = l;
- return c;
-}
-
-int
-rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
-{
- int r;
- if (e <= p)
- rb_raise(rb_eArgError, "empty string");
- r = rb_enc_precise_mbclen(p, e, enc);
- if (MBCLEN_CHARFOUND(r))
- return rb_enc_mbc_to_codepoint(p, e, enc);
- else
- rb_raise(rb_eArgError, "invalid mbstring sequence");
-}
-
-int
-rb_enc_codelen(int c, rb_encoding *enc)
-{
- int n = ONIGENC_CODE_TO_MBCLEN(enc,c);
- if (n == 0) {
- rb_raise(rb_eArgError, "invalid mbstring sequence");
- }
- return n;
-}
-
-int
-rb_enc_toupper(int c, rb_encoding *enc)
-{
- return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_UPPER_CASE(c):(c));
-}
-
-int
-rb_enc_tolower(int c, rb_encoding *enc)
-{
- return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_LOWER_CASE(c):(c));
-}
-
-/*
- * call-seq:
- * enc.inspect => string
- *
- * Returns a string which represents the encoding for programmers.
- *
- * Encoding::UTF_8.inspect #=> "#<Encoding:UTF-8>"
- * Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
- */
-static VALUE
-enc_inspect(VALUE self)
-{
- return rb_sprintf("#<%s:%s%s>", rb_obj_classname(self),
- rb_enc_name((rb_encoding*)DATA_PTR(self)),
- (ENC_DUMMY_P(self) ? " (dummy)" : ""));
-}
-
-/*
- * call-seq:
- * enc.name => string
- *
- * Returns the name of the encoding.
- *
- * Encoding::UTF_8.name => "UTF-8"
- */
-static VALUE
-enc_name(VALUE self)
-{
- return rb_str_new2(rb_enc_name((rb_encoding*)DATA_PTR(self)));
-}
-
-static VALUE
-enc_based_encoding(VALUE self)
-{
- return rb_attr_get(self, id_based_encoding);
-}
-
-/*
- * call-seq:
- * Encoding.list => [enc1, enc2, ...]
- *
- * Returns the list of loaded encodings.
- *
- * Encoding.list
- * => [#<Encoding:ASCII-8BIT>, #<Encoding:EUC-JP>,
- * #<Encoding:Shift_JIS>, #<Encoding:UTF-8>,
- * #<Encoding:ISO-2022-JP (dummy)>]
- *
- * Encoding.find("US-ASCII")
- * => #<Encoding:US-ASCII>
- *
- * Encoding.list
- * => [#<Encoding:ASCII-8BIT>, #<Encoding:EUC-JP>,
- * #<Encoding:Shift_JIS>, #<Encoding:UTF-8>,
- * #<Encoding:US-ASCII>, #<Encoding:ISO-2022-JP (dummy)>]
- *
- */
-static VALUE
-enc_list(VALUE klass)
-{
- VALUE ary = rb_ary_new2(enc_table_size);
- int i;
- for (i = 0; i < enc_table_size; ++i) {
- rb_encoding *enc = enc_table[i].enc;
- if (enc) {
- rb_ary_push(ary, rb_enc_from_encoding(enc));
- }
- }
- return ary;
-}
-
-/*
- * call-seq:
- * Encoding.find(string) => enc
- * Encoding.find(symbol) => enc
- *
- * Search the encoding with specified <i>name</i>.
- * <i>name</i> should be a string or symbol.
- *
- * Encoding.find("US-ASCII") => #<Encoding:US-ASCII>
- * Encoding.find(:Shift_JIS) => #<Encoding:Shift_JIS>
- *
- */
-static VALUE
-enc_find(VALUE klass, VALUE enc)
-{
- int idx;
- if (SYMBOL_P(enc)) enc = rb_id2str(SYM2ID(enc));
- idx = rb_enc_find_index(StringValueCStr(enc));
- if (idx < 0) {
- rb_raise(rb_eArgError, "unknown encoding name - %s", RSTRING_PTR(enc));
- }
- return rb_enc_from_encoding(rb_enc_from_index(idx));
-}
-
-/*
- * call-seq:
- * Encoding.compatible?(str1, str2) => enc or nil
- *
- * Checks the compatibility of two strings.
- * If they are compabible, means concatinatable,
- * returns an encoding which the concatinated string will be.
- * If they are not compatible, nil is returned.
- *
- * Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b")
- * => #<Encoding:ISO-8859-1>
- *
- * Encoding.compatible?(
- * "\xa1".force_encoding("iso-8859-1"),
- * "\xa1\xa1".force_encoding("euc-jp"))
- * => nil
- *
- */
-static VALUE
-enc_compatible_p(VALUE klass, VALUE str1, VALUE str2)
-{
- rb_encoding *enc = rb_enc_compatible(str1, str2);
- VALUE encoding = Qnil;
- if (!enc || !(encoding = rb_enc_from_encoding(enc)))
- encoding = Qnil;
- return encoding;
-}
-
-/* :nodoc: */
-static VALUE
-enc_dump(int argc, VALUE *argv, VALUE self)
-{
- rb_scan_args(argc, argv, "01", 0);
- return enc_name(self);
-}
-
-/* :nodoc: */
-static VALUE
-enc_load(VALUE klass, VALUE str)
-{
- return enc_find(klass, str);
-}
-
-rb_encoding *
-rb_ascii8bit_encoding(void)
-{
- if (!enc_table) {
- rb_enc_init();
- }
- return enc_table[0].enc;
-}
-
-rb_encoding *
-rb_utf8_encoding(void)
-{
- if (!enc_table) {
- rb_enc_init();
- }
- return enc_table[ENCINDEX_UTF8].enc;
-}
-
-static int default_external_index;
-
-rb_encoding *
-rb_default_external_encoding(void)
-{
- return rb_enc_from_index(default_external_index);
-}
-
-VALUE
-rb_enc_default_external(void)
-{
- return rb_enc_from_encoding(rb_default_external_encoding());
-}
-
-/*
- * call-seq:
- * Encoding.default_external => enc
- *
- * Returns default external encoding.
- *
- * It is initialized by the locale or -E option.
- */
-static VALUE
-get_default_external(VALUE klass)
-{
- return rb_enc_default_external();
-}
-
-void
-rb_enc_set_default_external(VALUE encoding)
-{
- default_external_index = rb_enc_to_index(rb_to_encoding(encoding));
-}
-
-/*
- * call-seq:
- * Encoding.locale_charmap => string
- *
- * Returns the locale charmap name.
- *
- * Debian GNU/Linux
- * LANG=C
- * Encoding.locale_charmap => "ANSI_X3.4-1968"
- * LANG=ja_JP.EUC-JP
- * Encoding.locale_charmap => "EUC-JP"
- *
- * SunOS 5
- * LANG=C
- * Encoding.locale_charmap => "646"
- * LANG=ja
- * Encoding.locale_charmap => "eucJP"
- *
- */
-VALUE
-rb_locale_charmap(VALUE klass)
-{
-#ifdef HAVE_LANGINFO_H
- char *codeset;
- codeset = nl_langinfo(CODESET);
- return rb_str_new2(codeset);
-#elif defined _WIN32
- return rb_sprintf("CP%d", GetACP());
-#else
- return Qnil;
-#endif
-}
-
-static void
-set_encoding_const(const char *name, rb_encoding *enc)
-{
- VALUE encoding = rb_enc_from_encoding(enc);
- char *s = (char *)name;
- int haslower = 0, valid = 0;
-
- if (ISUPPER(*s)) {
- while (*++s && (ISALNUM(*s) || *s == '_')) {
- if (ISLOWER(*s)) haslower = 1;
- }
- }
- if (!*s) {
- valid = 1;
- rb_define_const(rb_cEncoding, name, encoding);
- }
- if (!valid || haslower) {
- int len = strlen(name) + 1;
- if (!haslower) {
- while (!ISLOWER(*s) && *++s);
- if (*s) haslower = 1;
- }
- MEMCPY(s = ALLOCA_N(char, len), name, char, len);
- name = s;
- if (!valid) {
- if (ISLOWER(*s)) *s = ONIGENC_ASCII_CODE_TO_UPPER_CASE((int)*s);
- for (; *s; ++s) {
- if (!ISALNUM(*s)) *s = '_';
- }
- rb_define_const(rb_cEncoding, name, encoding);
- }
- if (haslower) {
- for (s = (char *)name; *s; ++s) {
- if (ISLOWER(*s)) *s = ONIGENC_ASCII_CODE_TO_UPPER_CASE((int)*s);
- }
- rb_define_const(rb_cEncoding, name, encoding);
- }
- }
-}
-
-static int
-set_encoding_alias(st_data_t name, st_data_t orig, st_data_t arg)
-{
- rb_encoding *enc = rb_enc_from_index((int)orig);
- set_encoding_const((const char *)name, enc);
- return ST_CONTINUE;
-}
-
-void
-Init_Encoding(void)
-{
- int i;
-
- id_based_encoding = rb_intern("#based_encoding");
-
- rb_cEncoding = rb_define_class("Encoding", rb_cObject);
- rb_undef_alloc_func(rb_cEncoding);
- rb_define_method(rb_cEncoding, "to_s", enc_name, 0);
- rb_define_method(rb_cEncoding, "inspect", enc_inspect, 0);
- rb_define_method(rb_cEncoding, "name", enc_name, 0);
- rb_define_method(rb_cEncoding, "based_encoding", enc_based_encoding, 0);
- rb_define_method(rb_cEncoding, "dummy?", enc_dummy_p, 0);
- rb_define_singleton_method(rb_cEncoding, "list", enc_list, 0);
- rb_define_singleton_method(rb_cEncoding, "find", enc_find, 1);
- rb_define_singleton_method(rb_cEncoding, "compatible?", enc_compatible_p, 2);
-
- rb_define_method(rb_cEncoding, "_dump", enc_dump, -1);
- rb_define_singleton_method(rb_cEncoding, "_load", enc_load, 1);
-
- rb_define_singleton_method(rb_cEncoding, "default_external", get_default_external, 0);
- rb_define_singleton_method(rb_cEncoding, "locale_charmap", rb_locale_charmap, 0);
-
- /* dummy for unsupported, statefull encoding */
- rb_define_dummy_encoding("ISO-2022-JP");
-
- for (i = 0; i < enc_table_size; ++i) {
- rb_encoding *enc = enc_table[i].enc;
- if (enc) set_encoding_const(rb_enc_name(enc), enc);
- }
- st_foreach(enc_table_alias, set_encoding_alias, 0);
-}
diff --git a/enum.c b/enum.c
index 4e3ff927da..df35c2fe03 100644
--- a/enum.c
+++ b/enum.c
@@ -6,45 +6,76 @@
$Date$
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "ruby/util.h"
+#include "ruby.h"
+#include "node.h"
+#include "util.h"
VALUE rb_mEnumerable;
-static ID id_each, id_eqq, id_cmp, id_next;
+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
-enum_values_pack(int argc, VALUE *argv)
+iterate_method(obj)
+ VALUE obj;
{
- if (argc == 0) return Qnil;
- if (argc == 1) return argv[0];
- return rb_ary_new4(argc, argv);
+ struct iter_method_arg *arg;
+
+ arg = (struct iter_method_arg *)obj;
+ return rb_funcall2(arg->obj, arg->mid, arg->argc, arg->argv);
}
-static VALUE
-enum_yield(int argc, VALUE *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);
+}
+
+VALUE
+rb_each(obj)
+ VALUE obj;
{
- return rb_yield(enum_values_pack(argc, argv));
+ return rb_funcall(obj, id_each, 0, 0);
}
static VALUE
-grep_i(VALUE i, VALUE *arg, int argc, VALUE *argv)
+grep_i(i, arg)
+ VALUE i, *arg;
{
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
- rb_ary_push(arg[1], enum_values_pack(argc, argv));
+ rb_ary_push(arg[1], i);
}
return Qnil;
}
static VALUE
-grep_iter_i(VALUE i, VALUE *arg, int argc, VALUE *argv)
+grep_iter_i(i, arg)
+ VALUE i, *arg;
{
if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) {
- rb_ary_push(arg[1], enum_yield(argc, argv));
+ rb_ary_push(arg[1], rb_yield(i));
}
return Qnil;
}
@@ -53,22 +84,23 @@ grep_iter_i(VALUE i, VALUE *arg, int argc, VALUE *argv)
* call-seq:
* enum.grep(pattern) => array
* enum.grep(pattern) {| obj | block } => array
- *
+ *
* Returns an array of every element in <i>enum</i> for which
* <code>Pattern === element</code>. If the optional <em>block</em> is
* supplied, each matching element is passed to it, and the block's
* result is stored in the output array.
- *
+ *
* (1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44]
* c = IO.constants
* c.grep(/SEEK/) #=> ["SEEK_END", "SEEK_SET", "SEEK_CUR"]
* res = c.grep(/SEEK/) {|v| IO.const_get(v) }
* res #=> [2, 0, 1]
- *
+ *
*/
static VALUE
-enum_grep(VALUE obj, VALUE pat)
+enum_grep(obj, pat)
+ VALUE obj, pat;
{
VALUE ary = rb_ary_new();
VALUE arg[2];
@@ -76,77 +108,106 @@ enum_grep(VALUE obj, VALUE pat)
arg[0] = pat;
arg[1] = ary;
- rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
-
+ 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(VALUE i, VALUE *arg)
+count_i(i, memop)
+ VALUE i, memop;
{
- if (rb_equal(i, arg[0])) {
- arg[1]++;
+ 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(VALUE i, long *n, int argc, VALUE *argv)
+count_iter_i(i, memop)
+ VALUE i, memop;
{
- if (RTEST(enum_yield(argc, argv))) {
- (*n)++;
+ 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> for which equals to <i>item</i>.
- * If a block is given, counts the number of elements yielding a true value.
- *
+ *
+ * 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(int argc, VALUE *argv, VALUE obj)
+enum_count(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
- if (argc == 1) {
- VALUE item, args[2];
+ VALUE memo[2]; /* [count, condition value] */
+ rb_block_call_func *func;
+ if (argc == 0) {
if (rb_block_given_p()) {
- rb_warn("given block not used");
+ func = count_iter_i;
+ }
+ else {
+ if (rb_respond_to(obj, id_size)) {
+ return rb_funcall(obj, id_size, 0, 0);
+ }
+ func = count_all_i;
}
- rb_scan_args(argc, argv, "1", &item);
- args[0] = item;
- args[1] = 0;
- rb_block_call(obj, id_each, 0, 0, count_i, (VALUE)&args);
- return INT2NUM(args[1]);
- }
- else if (argc == 0) {
- long n;
-
- RETURN_ENUMERATOR(obj, 0, 0);
- n = 0;
- rb_block_call(obj, id_each, 0, 0, count_iter_i, (VALUE)&n);
- return INT2NUM(n);
}
else {
- VALUE v;
- rb_scan_args(argc, argv, "1", &v);
- return Qnil; /* not reached */
+ 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(VALUE i, VALUE *memo, int argc, VALUE *argv)
+find_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
- if (RTEST(enum_yield(argc, argv))) {
+ if (RTEST(rb_yield(i))) {
*memo = i;
rb_iter_break();
}
@@ -157,26 +218,29 @@ find_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
* call-seq:
* enum.detect(ifnone = nil) {| obj | block } => obj or nil
* enum.find(ifnone = nil) {| obj | block } => obj or nil
- *
+ *
* Passes each entry in <i>enum</i> to <em>block</em>. Returns the
* first for which <em>block</em> is not <code>false</code>. If no
* object matches, calls <i>ifnone</i> and returns its result when it
* is specified, or returns <code>nil</code>
- *
+ *
* (1..10).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> nil
* (1..100).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> 35
- *
+ *
*/
static VALUE
-enum_find(int argc, VALUE *argv, VALUE obj)
+enum_find(argc, argv, obj)
+ int argc;
+ VALUE* argv;
+ VALUE obj;
{
VALUE memo = Qundef;
VALUE if_none;
rb_scan_args(argc, argv, "01", &if_none);
RETURN_ENUMERATOR(obj, argc, argv);
- rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)&memo);
+ rb_iterate(rb_each, obj, find_i, (VALUE)&memo);
if (memo != Qundef) {
return memo;
}
@@ -186,10 +250,31 @@ enum_find(int argc, VALUE *argv, VALUE 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_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
+find_index_iter_i(i, memop)
+ VALUE i;
+ VALUE memop;
{
- if (RTEST(enum_yield(argc, argv))) {
+ VALUE *memo = (VALUE*)memop;
+
+ if (RTEST(rb_yield(i))) {
memo[0] = UINT2NUM(memo[1]);
rb_iter_break();
}
@@ -199,36 +284,52 @@ find_index_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
/*
* call-seq:
- * enum.find_index() {| obj | block } => int
- *
- * Passes each entry in <i>enum</i> to <em>block</em>. Returns the
- * index for the first for which <em>block</em> is not <code>false</code>.
- * If no object matches, returns <code>nil</code>
- *
+ * 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(VALUE obj)
+enum_find_index(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
- VALUE memo[2];
+ VALUE memo[3]; /* [return value, current index, condition value] */
+ rb_block_call_func *func;
- RETURN_ENUMERATOR(obj, 0, 0);
- memo[0] = Qundef;
- memo[1] = 0;
- rb_block_call(obj, id_each, 0, 0, find_index_i, (VALUE)memo);
- if (memo[0] != Qundef) {
- return memo[0];
+ if (argc == 0) {
+ RETURN_ENUMERATOR(obj, 0, 0);
+ func = find_index_iter_i;
}
- return Qnil;
+ 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(VALUE i, VALUE ary, int argc, VALUE *argv)
+find_all_i(i, ary)
+ VALUE i, ary;
{
- if (RTEST(enum_yield(argc, argv))) {
+ if (RTEST(rb_yield(i))) {
rb_ary_push(ary, i);
}
return Qnil;
@@ -238,32 +339,32 @@ find_all_i(VALUE i, VALUE ary, int argc, VALUE *argv)
* call-seq:
* enum.find_all {| obj | block } => array
* enum.select {| obj | block } => array
- *
+ *
* Returns an array containing all elements of <i>enum</i> for which
* <em>block</em> is not <code>false</code> (see also
* <code>Enumerable#reject</code>).
- *
+ *
* (1..10).find_all {|i| i % 3 == 0 } #=> [3, 6, 9]
- *
+ *
*/
static VALUE
-enum_find_all(VALUE obj)
+enum_find_all(obj)
+ VALUE obj;
{
- VALUE ary;
-
- RETURN_ENUMERATOR(obj, 0, 0);
+ VALUE ary = rb_ary_new();
- ary = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, find_all_i, ary);
+ RETURN_ENUMERATOR(obj, 0, 0);
+ rb_iterate(rb_each, obj, find_all_i, ary);
return ary;
}
static VALUE
-reject_i(VALUE i, VALUE ary, int argc, VALUE *argv)
+reject_i(i, ary)
+ VALUE i, ary;
{
- if (!RTEST(enum_yield(argc, argv))) {
+ if (!RTEST(rb_yield(i))) {
rb_ary_push(ary, i);
}
return Qnil;
@@ -272,39 +373,40 @@ reject_i(VALUE i, VALUE ary, int argc, VALUE *argv)
/*
* call-seq:
* enum.reject {| obj | block } => array
- *
+ *
* Returns an array for all elements of <i>enum</i> for which
* <em>block</em> is false (see also <code>Enumerable#find_all</code>).
- *
+ *
* (1..10).reject {|i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10]
- *
+ *
*/
static VALUE
-enum_reject(VALUE obj)
+enum_reject(obj)
+ VALUE obj;
{
- VALUE ary;
-
- RETURN_ENUMERATOR(obj, 0, 0);
+ VALUE ary = rb_ary_new();
- ary = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, reject_i, ary);
+ RETURN_ENUMERATOR(obj, 0, 0);
+ rb_iterate(rb_each, obj, reject_i, ary);
return ary;
}
static VALUE
-collect_i(VALUE i, VALUE ary, int argc, VALUE *argv)
+collect_i(i, ary)
+ VALUE i, ary;
{
- rb_ary_push(ary, enum_yield(argc, argv));
+ rb_ary_push(ary, rb_yield(i));
return Qnil;
}
static VALUE
-collect_all(VALUE i, VALUE ary, int argc, VALUE *argv)
+collect_all(i, ary)
+ VALUE i, ary;
{
- rb_ary_push(ary, enum_values_pack(argc, argv));
+ rb_ary_push(ary, i);
return Qnil;
}
@@ -313,24 +415,22 @@ collect_all(VALUE i, VALUE ary, int argc, VALUE *argv)
* call-seq:
* enum.collect {| obj | block } => array
* enum.map {| obj | block } => array
- *
+ *
* Returns a new array with the results of running <em>block</em> once
* for every element in <i>enum</i>.
- *
+ *
* (1..4).collect {|i| i*i } #=> [1, 4, 9, 16]
* (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"]
- *
+ *
*/
static VALUE
-enum_collect(VALUE obj)
+enum_collect(obj)
+ VALUE obj;
{
- VALUE ary;
-
- RETURN_ENUMERATOR(obj, 0, 0);
+ VALUE ary = rb_ary_new();
- ary = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, collect_i, ary);
+ rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : collect_all, ary);
return ary;
}
@@ -339,42 +439,51 @@ enum_collect(VALUE 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(VALUE obj)
+enum_to_a(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE ary = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, collect_all, ary);
+ rb_block_call(obj, id_each, argc, argv, collect_all, ary);
return ary;
}
+static VALUE inject_i _((VALUE, VALUE));
static VALUE
-inject_i(VALUE i, VALUE p, int argc, VALUE *argv)
+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], enum_values_pack(argc, argv));
+ memo[0] = rb_yield_values(2, memo[0], i);
}
return Qnil;
}
+static VALUE inject_op_i _((VALUE, VALUE));
static VALUE
-inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
+inject_op_i(i, p)
+ VALUE i;
+ VALUE p;
{
VALUE *memo = (VALUE *)p;
if (memo[0] == Qundef) {
- memo[0] = enum_values_pack(argc, argv);
+ memo[0] = i;
}
else {
memo[0] = rb_funcall(memo[0], (ID)memo[1], 1, i);
@@ -393,7 +502,7 @@ inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
* 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.
@@ -402,7 +511,7 @@ inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
* 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>.
+ * 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.
*
@@ -410,7 +519,7 @@ inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
* then uses the first element of collection is used as the initial value
* of <i>memo</i>.
*
- * Examples:
+ * Examples:
*
* # Sum some numbers
* (5..10).reduce(:+) #=> 45
@@ -425,13 +534,16 @@ inject_op_i(VALUE i, VALUE p, int argc, VALUE *argv)
* memo.length > word.length ? memo : word
* end
* longest #=> "sheep"
- *
+ *
*/
static VALUE
-enum_inject(int argc, VALUE *argv, VALUE obj)
+enum_inject(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE memo[2];
- VALUE (*iter)(VALUE, VALUE, int, VALUE*) = inject_i;
+ rb_block_call_func *iter = inject_i;
switch (rb_scan_args(argc, argv, "02", &memo[0], &memo[1])) {
case 0:
@@ -459,9 +571,10 @@ enum_inject(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-partition_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
+partition_i(i, ary)
+ VALUE i, *ary;
{
- if (RTEST(enum_yield(argc, argv))) {
+ if (RTEST(rb_yield(i))) {
rb_ary_push(ary[0], i);
}
else {
@@ -473,17 +586,18 @@ partition_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
/*
* call-seq:
* enum.partition {| obj | block } => [ true_array, false_array ]
- *
+ *
* Returns two arrays, the first containing the elements of
* <i>enum</i> for which the block evaluates to true, the second
* containing the rest.
- *
+ *
* (1..6).partition {|i| (i&1).zero?} #=> [[2, 4, 6], [1, 3, 5]]
- *
+ *
*/
static VALUE
-enum_partition(VALUE obj)
+enum_partition(obj)
+ VALUE obj;
{
VALUE ary[2];
@@ -491,15 +605,17 @@ enum_partition(VALUE obj)
ary[0] = rb_ary_new();
ary[1] = rb_ary_new();
- rb_block_call(obj, id_each, 0, 0, partition_i, (VALUE)ary);
+ rb_iterate(rb_each, obj, partition_i, (VALUE)ary);
return rb_assoc_new(ary[0], ary[1]);
}
static VALUE
-group_by_i(VALUE i, VALUE hash, int argc, VALUE *argv)
+group_by_i(i, hash)
+ VALUE i;
+ VALUE hash;
{
- VALUE group = enum_yield(argc, argv);
+ VALUE group = rb_yield(i);
VALUE values;
values = rb_hash_aref(hash, group);
@@ -516,17 +632,18 @@ group_by_i(VALUE i, VALUE hash, int argc, VALUE *argv)
/*
* 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(VALUE obj)
+enum_group_by(obj)
+ VALUE obj;
{
VALUE hash;
@@ -539,7 +656,9 @@ enum_group_by(VALUE obj)
}
static VALUE
-first_i(VALUE i, VALUE *ary)
+first_i(i, ary)
+ VALUE i;
+ VALUE *ary;
{
if (NIL_P(ary[0])) {
ary[1] = i;
@@ -562,24 +681,26 @@ first_i(VALUE i, VALUE *ary)
* 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(int argc, VALUE *argv, VALUE obj)
+enum_first(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE n, ary[2];
-
- rb_scan_args(argc, argv, "01", &n);
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));
}
@@ -593,7 +714,7 @@ enum_first(int argc, VALUE *argv, VALUE obj)
* 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
@@ -601,24 +722,26 @@ enum_first(int argc, VALUE *argv, VALUE 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]
*/
static VALUE
-enum_sort(VALUE obj)
+enum_sort(obj)
+ VALUE obj;
{
- return rb_ary_sort(enum_to_a(obj));
+ return rb_ary_sort(enum_to_a(0, 0, obj));
}
static VALUE
-sort_by_i(VALUE i, VALUE ary, int argc, VALUE *argv)
+sort_by_i(i, ary)
+ VALUE i, ary;
{
VALUE v;
NODE *memo;
- v = enum_yield(argc, argv);
+ v = rb_yield(i);
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
}
@@ -628,10 +751,12 @@ sort_by_i(VALUE i, VALUE ary, int argc, VALUE *argv)
}
static int
-sort_by_cmp(const void *ap, const void *bp, void *data)
+sort_by_cmp(aa, bb, data)
+ NODE **aa, **bb;
+ void *data;
{
- VALUE a = (*(NODE *const *)ap)->u1.value;
- VALUE b = (*(NODE *const *)bp)->u1.value;
+ VALUE a = aa[0]->u1.value;
+ VALUE b = bb[0]->u1.value;
VALUE ary = (VALUE)data;
if (RBASIC(ary)->klass) {
@@ -643,53 +768,53 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
/*
* 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"]
- *
+ #=> ["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
@@ -697,20 +822,21 @@ sort_by_cmp(const void *ap, const void *bp, void *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"]
*/
static VALUE
-enum_sort_by(VALUE obj)
+enum_sort_by(obj)
+ VALUE obj;
{
VALUE ary;
long i;
@@ -718,31 +844,33 @@ enum_sort_by(VALUE obj)
RETURN_ENUMERATOR(obj, 0, 0);
if (TYPE(obj) == T_ARRAY) {
- ary = rb_ary_new2(RARRAY_LEN(obj));
+ ary = rb_ary_new2(RARRAY(obj)->len);
}
else {
ary = rb_ary_new();
}
RBASIC(ary)->klass = 0;
- rb_block_call(obj, id_each, 0, 0, sort_by_i, ary);
- if (RARRAY_LEN(ary) > 1) {
- ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE),
- sort_by_cmp, (void *)ary);
+ 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);
}
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
}
- for (i=0; i<RARRAY_LEN(ary); i++) {
- RARRAY_PTR(ary)[i] = RNODE(RARRAY_PTR(ary)[i])->u2.value;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ RARRAY(ary)->ptr[i] = RNODE(RARRAY(ary)->ptr[i])->u2.value;
}
RBASIC(ary)->klass = rb_cArray;
return ary;
}
static VALUE
-all_iter_i(VALUE i, VALUE *memo)
+all_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
- if (!RTEST(rb_yield(i))) {
+ if (!RTEST(i)) {
*memo = Qfalse;
rb_iter_break();
}
@@ -750,45 +878,46 @@ all_iter_i(VALUE i, VALUE *memo)
}
static VALUE
-all_i(VALUE i, VALUE *memo)
+all_iter_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
- if (!RTEST(i)) {
- *memo = Qfalse;
- rb_iter_break();
- }
- return Qnil;
+ return all_i(rb_yield(i), memo);
}
/*
* 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
- *
+ *
+ * %w{ ant bear cat}.all? {|word| word.length >= 3} #=> true
+ * %w{ ant bear cat}.all? {|word| word.length >= 4} #=> false
+ * [ nil, true, 99 ].all? #=> false
+ *
*/
static VALUE
-enum_all(VALUE obj)
+enum_all(obj)
+ VALUE obj;
{
VALUE result = Qtrue;
- rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result);
+ rb_iterate(rb_each, obj, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result);
return result;
}
static VALUE
-any_iter_i(VALUE i, VALUE *memo)
+any_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
- if (RTEST(rb_yield(i))) {
+ if (RTEST(i)) {
*memo = Qtrue;
rb_iter_break();
}
@@ -796,19 +925,17 @@ any_iter_i(VALUE i, VALUE *memo)
}
static VALUE
-any_i(VALUE i, VALUE *memo)
+any_iter_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
- if (RTEST(i)) {
- *memo = Qtrue;
- rb_iter_break();
- }
- return Qnil;
+ return any_i(rb_yield(i), memo);
}
/*
* 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
@@ -816,24 +943,27 @@ any_i(VALUE i, VALUE *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
- *
+ *
+ * %w{ ant bear cat}.any? {|word| word.length >= 3} #=> true
+ * %w{ ant bear cat}.any? {|word| word.length >= 4} #=> true
+ * [ nil, true, 99 ].any? #=> true
+ *
*/
static VALUE
-enum_any(VALUE obj)
+enum_any(obj)
+ VALUE obj;
{
VALUE result = Qfalse;
- rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result);
+ rb_iterate(rb_each, obj, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result);
return result;
}
static VALUE
-one_i(VALUE i, VALUE *memo)
+one_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
if (RTEST(i)) {
if (*memo == Qundef) {
@@ -848,7 +978,9 @@ one_i(VALUE i, VALUE *memo)
}
static VALUE
-one_iter_i(VALUE i, VALUE *memo)
+one_iter_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
return one_i(rb_yield(i), memo);
}
@@ -856,22 +988,24 @@ one_iter_i(VALUE i, VALUE *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
+ * %w{ant bear cat}.one? {|word| word.length < 4} #=> false
* [ nil, true, 99 ].one? #=> false
* [ nil, true, false ].one? #=> true
- *
+ *
*/
static VALUE
-enum_one(VALUE obj)
+enum_one(obj)
+ VALUE obj;
{
VALUE result = Qundef;
@@ -881,7 +1015,9 @@ enum_one(VALUE obj)
}
static VALUE
-none_i(VALUE i, VALUE *memo)
+none_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
if (RTEST(i)) {
*memo = Qfalse;
@@ -891,7 +1027,9 @@ none_i(VALUE i, VALUE *memo)
}
static VALUE
-none_iter_i(VALUE i, VALUE *memo)
+none_iter_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
return none_i(rb_yield(i), memo);
}
@@ -899,12 +1037,12 @@ none_iter_i(VALUE i, VALUE *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
@@ -912,7 +1050,8 @@ none_iter_i(VALUE i, VALUE *memo)
* [nil,false].none? #=> true
*/
static VALUE
-enum_none(VALUE obj)
+enum_none(obj)
+ VALUE obj;
{
VALUE result = Qtrue;
@@ -921,7 +1060,9 @@ enum_none(VALUE obj)
}
static VALUE
-min_i(VALUE i, VALUE *memo)
+min_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE cmp;
@@ -938,7 +1079,9 @@ min_i(VALUE i, VALUE *memo)
}
static VALUE
-min_ii(VALUE i, VALUE *memo)
+min_ii(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE cmp;
@@ -946,10 +1089,7 @@ min_ii(VALUE i, VALUE *memo)
*memo = i;
}
else {
- VALUE ary = memo[1];
- RARRAY_PTR(ary)[0] = i;
- RARRAY_PTR(ary)[1] = *memo;
- cmp = rb_yield(ary);
+ cmp = rb_yield_values(2, i, *memo);
if (rb_cmpint(cmp, i, *memo) < 0) {
*memo = i;
}
@@ -962,35 +1102,45 @@ min_ii(VALUE i, VALUE *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"
*/
static VALUE
-enum_min(VALUE obj)
+enum_min(obj)
+ VALUE obj;
{
- VALUE result[2];
+ VALUE result = Qundef;
- result[0] = Qundef;
- if (rb_block_given_p()) {
- result[1] = rb_ary_new3(2, Qnil, Qnil);
- rb_block_call(obj, id_each, 0, 0, min_ii, (VALUE)result);
- }
- else {
- rb_block_call(obj, id_each, 0, 0, min_i, (VALUE)result);
- }
- if (result[0] == Qundef) return Qnil;
- return result[0];
+ rb_iterate(rb_each, obj, rb_block_given_p() ? min_ii : min_i, (VALUE)&result);
+ if (result == Qundef) return Qnil;
+ return result;
}
+/*
+ * call-seq:
+ * enum.max => obj
+ * enum.max {| a,b | block } => obj
+ *
+ * Returns the object in <i>enum</i> with the maximum value. The
+ * first form assumes all objects implement <code>Comparable</code>;
+ * the second uses the block to return <em>a <=> b</em>.
+ *
+ * a = %w(albatross dog horse)
+ * a.max #=> "horse"
+ * a.max {|a,b| a.length <=> b.length } #=> "albatross"
+ */
+
static VALUE
-max_i(VALUE i, VALUE *memo)
+max_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE cmp;
@@ -1007,7 +1157,9 @@ max_i(VALUE i, VALUE *memo)
}
static VALUE
-max_ii(VALUE i, VALUE *memo)
+max_ii(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE cmp;
@@ -1015,10 +1167,7 @@ max_ii(VALUE i, VALUE *memo)
*memo = i;
}
else {
- VALUE ary = memo[1];
- RARRAY_PTR(ary)[0] = i;
- RARRAY_PTR(ary)[1] = *memo;
- cmp = rb_yield(ary);
+ cmp = rb_yield_values(2, i, *memo);
if (rb_cmpint(cmp, i, *memo) > 0) {
*memo = i;
}
@@ -1030,35 +1179,31 @@ max_ii(VALUE i, VALUE *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(VALUE obj)
+enum_max(obj)
+ VALUE obj;
{
- VALUE result[2];
+ VALUE result = Qundef;
- result[0] = Qundef;
- if (rb_block_given_p()) {
- result[1] = rb_ary_new3(2, Qnil, Qnil);
- rb_block_call(obj, id_each, 0, 0, max_ii, (VALUE)result);
- }
- else {
- rb_block_call(obj, id_each, 0, 0, max_i, (VALUE)result);
- }
- if (result[0] == Qundef) return Qnil;
- return result[0];
+ rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)&result);
+ if (result == Qundef) return Qnil;
+ return result;
}
static VALUE
-minmax_i(VALUE i, VALUE *memo)
+minmax_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
int n;
@@ -1080,7 +1225,9 @@ minmax_i(VALUE i, VALUE *memo)
}
static VALUE
-minmax_ii(VALUE i, VALUE *memo)
+minmax_ii(i, memo)
+ VALUE i;
+ VALUE *memo;
{
int n;
@@ -1091,14 +1238,14 @@ minmax_ii(VALUE i, VALUE *memo)
else {
VALUE ary = memo[2];
- RARRAY_PTR(ary)[0] = i;
- RARRAY_PTR(ary)[1] = memo[0];
+ 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_PTR(ary)[0] = i;
- RARRAY_PTR(ary)[1] = memo[1];
+ 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;
@@ -1111,19 +1258,20 @@ minmax_ii(VALUE i, VALUE *memo)
* call-seq:
* enum.minmax => [min,max]
* enum.minmax {|a,b| block } => [min,max]
- *
- * Returns two elements array which contains the mininum and the
- * maxinum value in the enumerable. The first form assumes all
+ *
+ * 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(VALUE obj)
+enum_minmax(obj)
+ VALUE obj;
{
VALUE result[3];
VALUE ary = rb_ary_new3(2, Qnil, Qnil);
@@ -1137,18 +1285,20 @@ enum_minmax(VALUE obj)
rb_block_call(obj, id_each, 0, 0, minmax_i, (VALUE)result);
}
if (result[0] != Qundef) {
- RARRAY_PTR(ary)[0] = result[0];
- RARRAY_PTR(ary)[1] = result[1];
+ RARRAY(ary)->ptr[0] = result[0];
+ RARRAY(ary)->ptr[1] = result[1];
}
return ary;
}
static VALUE
-min_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
+min_by_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE v;
- v = enum_yield(argc, argv);
+ v = rb_yield(i);
if (memo[0] == Qundef) {
memo[0] = v;
memo[1] = i;
@@ -1163,16 +1313,17 @@ min_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
/*
* 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(VALUE obj)
+enum_min_by(obj)
+ VALUE obj;
{
VALUE memo[2];
@@ -1185,11 +1336,13 @@ enum_min_by(VALUE obj)
}
static VALUE
-max_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
+max_by_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE v;
- v = enum_yield(argc, argv);
+ v = rb_yield(i);
if (memo[0] == Qundef) {
memo[0] = v;
memo[1] = i;
@@ -1204,16 +1357,17 @@ max_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
/*
* 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(VALUE obj)
+enum_max_by(obj)
+ VALUE obj;
{
VALUE memo[2];
@@ -1226,11 +1380,13 @@ enum_max_by(VALUE obj)
}
static VALUE
-minmax_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
+minmax_by_i(i, memo)
+ VALUE i;
+ VALUE *memo;
{
VALUE v;
- v = enum_yield(argc, argv);
+ v = rb_yield(i);
if (memo[0] == Qundef) {
memo[0] = v;
memo[1] = v;
@@ -1253,17 +1409,18 @@ minmax_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
/*
* call-seq:
* enum.minmax_by {| obj| block } => [min, max]
- *
+ *
* Returns two elements array array containing the objects in
- * <i>enum</i> that gives the minmum and maximum values respectively
+ * <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(VALUE obj)
+enum_minmax_by(obj)
+ VALUE obj;
{
VALUE memo[4];
@@ -1278,7 +1435,9 @@ enum_minmax_by(VALUE obj)
}
static VALUE
-member_i(VALUE item, VALUE *memo)
+member_i(item, memo)
+ VALUE item;
+ VALUE *memo;
{
if (rb_equal(item, memo[0])) {
memo[1] = Qtrue;
@@ -1291,77 +1450,107 @@ member_i(VALUE item, VALUE *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
-enum_member(VALUE obj, VALUE val)
+enum_member(obj, val)
+ VALUE obj, val;
{
VALUE memo[2];
memo[0] = val;
memo[1] = Qfalse;
- rb_block_call(obj, id_each, 0, 0, member_i, (VALUE)memo);
+ rb_iterate(rb_each, obj, member_i, (VALUE)memo);
return memo[1];
}
static VALUE
-each_with_index_i(VALUE i, VALUE memo, int argc, VALUE *argv)
+each_with_index_i(val, memo)
+ VALUE val;
+ VALUE *memo;
{
- long n = (*(VALUE *)memo)++;
-
- return rb_yield_values(2, enum_values_pack(argc, argv), INT2NUM(n));
+ rb_yield_values(2, val, INT2FIX(*memo));
+ ++*memo;
+ return Qnil;
}
/*
* call-seq:
* enum.each_with_index {|obj, i| block } -> enum
- *
+ *
* Calls <em>block</em> with two arguments, the item and its index, for
* each item in <i>enum</i>.
- *
+ *
* hash = Hash.new
* %w(cat dog wombat).each_with_index {|item, index|
* hash[item] = index
* }
* hash #=> {"cat"=>0, "wombat"=>2, "dog"=>1}
- *
+ *
*/
static VALUE
-enum_each_with_index(int argc, VALUE *argv, VALUE obj)
+enum_each_with_index(obj)
+ VALUE obj;
{
- long memo;
+ VALUE memo;
- RETURN_ENUMERATOR(obj, argc, argv);
+ RETURN_ENUMERATOR(obj, 0, 0);
memo = 0;
- rb_block_call(obj, id_each, argc, argv, each_with_index_i, (VALUE)&memo);
+ 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(VALUE val, NODE *memo, int argc, VALUE *argv)
+zip_i(val, memo)
+ VALUE val;
+ VALUE *memo;
{
- volatile VALUE result = memo->u1.value;
- volatile VALUE args = memo->u2.value;
- volatile VALUE tmp;
+ VALUE result = memo[0];
+ VALUE args = memo[1];
+ int idx = memo[2]++;
+ VALUE tmp;
int i;
- tmp = rb_ary_new2(RARRAY_LEN(args) + 1);
- rb_ary_store(tmp, 0, enum_values_pack(argc, argv));
- for (i=0; i<RARRAY_LEN(args); i++) {
- VALUE v = rb_funcall(RARRAY_PTR(args)[i], id_next, 0, 0);
- rb_ary_push(tmp, v);
+ tmp = rb_ary_new2(RARRAY(args)->len + 1);
+ rb_ary_store(tmp, 0, val);
+ for (i=0; i<RARRAY(args)->len; i++) {
+ rb_ary_push(tmp, rb_ary_entry(RARRAY(args)->ptr[i], idx));
}
- if (NIL_P(result)) {
+ if (rb_block_given_p()) {
rb_yield(tmp);
}
else {
@@ -1370,54 +1559,55 @@ zip_i(VALUE val, NODE *memo, int argc, VALUE *argv)
return Qnil;
}
-static VALUE
-zip_b(NODE *memo)
-{
- return rb_block_call(memo->u3.value, id_each, 0, 0, zip_i, (VALUE)memo);
-}
-
/*
* call-seq:
- * enum.zip(arg, ...) => enumerator
+ * enum.zip(arg, ...) => array
* enum.zip(arg, ...) {|arr| block } => nil
- *
- * Takes one element from <i>enum</i> and merges corresponding
- * elements from each <i>args</i>. This generates a sequence of
- * <em>n</em>-element arrays, where <em>n</em> is one more that the
- * count of arguments. The length of the sequence is truncated to
- * the size of the shortest argument (or <i>enum</i>). If a block
- * given, it is invoked for each output array, otherwise an array of
- * arrays is returned.
- *
+ *
+ * Converts any arguments to arrays, then merges elements of
+ * <i>enum</i> with corresponding elements from each argument. This
+ * generates a sequence of <code>enum#size</code> <em>n</em>-element
+ * arrays, where <em>n</em> is one more that the count of arguments. If
+ * the size of any argument is less than <code>enum#size</code>,
+ * <code>nil</code> values are supplied. If a block given, it is
+ * invoked for each output array, otherwise an array of arrays is
+ * returned.
+ *
* a = [ 4, 5, 6 ]
* b = [ 7, 8, 9 ]
- *
- * [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
- * [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]]
- * a.zip([1,2],[8]) #=> [[4,1,8]]
- *
+ *
+ * (1..3).zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
+ * "cat\ndog".zip([1]) #=> [["cat\n", 1], ["dog", nil]]
+ * (1..3).zip #=> [[1], [2], [3]]
+ *
*/
static VALUE
-enum_zip(int argc, VALUE *argv, VALUE obj)
+enum_zip(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
int i;
VALUE result;
- NODE *memo;
+ VALUE memo[3];
for (i=0; i<argc; i++) {
- argv[i] = rb_funcall(argv[i], rb_intern("to_enum"), 1, ID2SYM(id_each));
+ argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_a");
}
- RETURN_ENUMERATOR(obj, argc, argv);
result = rb_block_given_p() ? Qnil : rb_ary_new();
- memo = rb_node_newnode(NODE_MEMO, result, rb_ary_new4(argc, argv), obj);
- rb_rescue2(zip_b, (VALUE)memo, 0, 0, rb_eStopIteration, (VALUE)0);
+ memo[0] = result;
+ memo[1] = rb_ary_new4(argc, argv);
+ memo[2] = 0;
+ rb_iterate(rb_each, obj, zip_i, (VALUE)memo);
return result;
}
static VALUE
-take_i(VALUE i, VALUE *arg)
+take_i(i, arg)
+ VALUE i;
+ VALUE *arg;
{
if (arg[1]-- == 0) rb_iter_break();
rb_ary_push(arg[0], i);
@@ -1427,30 +1617,39 @@ take_i(VALUE i, VALUE *arg)
/*
* 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(VALUE obj, VALUE n)
+enum_take(obj, n)
+ VALUE obj;
+ VALUE n;
{
VALUE args[2];
+ long len = NUM2LONG(n);
- args[1] = NUM2LONG(n);
- args[0] = rb_ary_new2(args[1]);
+ 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(VALUE i, VALUE *ary, int argc, VALUE *argv)
+take_while_i(i, ary)
+ VALUE i;
+ VALUE *ary;
{
- if (!RTEST(enum_yield(argc, argv))) rb_iter_break();
+ if (!RTEST(rb_yield(i))) rb_iter_break();
rb_ary_push(*ary, i);
return Qnil;
}
@@ -1458,17 +1657,18 @@ take_while_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
/*
* 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 {|i| i < 3 } # => [1, 2]
- *
+ * a.take_while {|i| i < 3 } # => [1, 2]
+ *
*/
static VALUE
-enum_take_while(VALUE obj)
+enum_take_while(obj)
+ VALUE obj;
{
VALUE ary;
@@ -1479,7 +1679,9 @@ enum_take_while(VALUE obj)
}
static VALUE
-drop_i(VALUE i, VALUE *arg)
+drop_i(i, arg)
+ VALUE i;
+ VALUE *arg;
{
if (arg[1] == 0) {
rb_ary_push(arg[0], i);
@@ -1493,31 +1695,40 @@ drop_i(VALUE i, VALUE *arg)
/*
* 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(VALUE obj, VALUE n)
+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] = NUM2ULONG(n);
- args[0] = rb_ary_new2(args[1]);
+ 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(VALUE i, VALUE *args, int argc, VALUE *argv)
+drop_while_i(i, args)
+ VALUE i;
+ VALUE *args;
{
- if (!args[1] && !RTEST(enum_yield(argc, argv))) {
+ if (!args[1] && !RTEST(rb_yield(i))) {
args[1] = Qtrue;
}
if (args[1]) {
@@ -1529,18 +1740,19 @@ drop_while_i(VALUE i, VALUE *args, int argc, VALUE *argv)
/*
* 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 {|i| i < 3 } # => [3, 4, 5, 0]
- *
+ * a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
+ *
*/
static VALUE
-enum_drop_while(VALUE obj)
+enum_drop_while(obj)
+ VALUE obj;
{
VALUE args[2];
@@ -1552,43 +1764,63 @@ enum_drop_while(VALUE obj)
}
static VALUE
-cycle_i(VALUE i, VALUE ary, int argc, VALUE *argv)
+cycle_i(i, ary)
+ VALUE i;
+ VALUE ary;
{
rb_ary_push(ary, i);
- enum_yield(argc, argv);
+ rb_yield(i);
return Qnil;
}
/*
* call-seq:
* enum.cycle {|obj| block }
- *
- * Calls <i>block</i> for each element of <i>enum</i> repeatedly
- * forever. Returns nil if and only if the collection is empty.
+ * 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(VALUE obj)
+enum_cycle(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE ary;
- long i, len;
+ VALUE nv = Qnil;
+ long n, i, len;
- RETURN_ENUMERATOR(obj, 0, 0);
+ 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_LEN(ary);
+ len = RARRAY(ary)->len;
if (len == 0) return Qnil;
- for (;;) {
- for (i=0; i<len; i++) {
- rb_yield(RARRAY_PTR(ary)[i]);
- }
+ while (n < 0 || 0 < --n) {
+ for (i=0; i<len; i++) {
+ rb_yield(RARRAY(ary)->ptr[i]);
+ }
}
return Qnil; /* not reached */
}
@@ -1605,53 +1837,55 @@ enum_cycle(VALUE obj)
*/
void
-Init_Enumerable(void)
+Init_Enumerable()
{
rb_mEnumerable = rb_define_module("Enumerable");
- 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,"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, 0);
- 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, -1);
+ 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, "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, 0);
+ rb_define_method(rb_mEnumerable, "cycle", enum_cycle, -1);
id_eqq = rb_intern("===");
id_each = rb_intern("each");
id_cmp = rb_intern("<=>");
- id_next = rb_intern("next");
+ id_size = rb_intern("size");
}
diff --git a/enumerator.c b/enumerator.c
index 25c9ece24c..f95d931b62 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -12,8 +12,7 @@
************************************************/
-#include "ruby/ruby.h"
-#include "debug.h"
+#include "ruby.h"
/*
* Document-class: Enumerable::Enumerator
@@ -21,43 +20,32 @@
* A class which provides a method `each' to be used as an Enumerable
* object.
*/
-static VALUE rb_cEnumerator;
-static VALUE sym_each, sym_call;
+VALUE rb_cEnumerator;
+static VALUE sym_each;
VALUE rb_eStopIteration;
-static VALUE
-proc_call(VALUE proc, VALUE args)
-{
- if (TYPE(args) != T_ARRAY) {
- args = rb_ary_new3(1, args);
- }
- return rb_proc_call(proc, args);
-}
-
struct enumerator {
- VALUE method;
+ VALUE obj;
+ ID meth;
VALUE proc;
VALUE args;
rb_block_call_func *iter;
- VALUE fib;
- VALUE dst;
- VALUE no_next;
};
+static void enumerator_mark _((void *));
static void
-enumerator_mark(void *p)
+enumerator_mark(p)
+ void *p;
{
struct enumerator *ptr = p;
- rb_gc_mark(ptr->method);
- rb_gc_mark(ptr->proc);
+ rb_gc_mark(ptr->obj);
rb_gc_mark(ptr->args);
- rb_gc_mark(ptr->fib);
- rb_gc_mark(ptr->dst);
}
static struct enumerator *
-enumerator_ptr(VALUE obj)
+enumerator_ptr(obj)
+ VALUE obj;
{
struct enumerator *ptr;
@@ -67,19 +55,12 @@ enumerator_ptr(VALUE obj)
"wrong argument type %s (expected Enumerable::Enumerator)",
rb_obj_classname(obj));
}
- if (!ptr) {
+ if (!ptr || ptr->obj == Qundef) {
rb_raise(rb_eArgError, "uninitialized enumerator");
}
return ptr;
}
-static VALUE
-enumerator_iter_i(VALUE i, VALUE enum_obj, int argc, VALUE *argv)
-{
- struct enumerator *e = (struct enumerator *)enum_obj;
- return rb_yield(proc_call(e->proc, i));
-}
-
/*
* call-seq:
* obj.to_enum(method = :each, *args)
@@ -88,6 +69,7 @@ enumerator_iter_i(VALUE i, VALUE enum_obj, int argc, VALUE *argv)
* Returns Enumerable::Enumerator.new(self, method, *args).
*
* e.g.:
+ *
* str = "xyz"
*
* enum = str.enum_for(:each_byte)
@@ -99,7 +81,10 @@ enumerator_iter_i(VALUE i, VALUE enum_obj, int argc, VALUE *argv)
*
*/
static VALUE
-obj_to_enum(int argc, VALUE *argv, VALUE obj)
+obj_to_enum(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE meth = sym_each;
@@ -111,7 +96,9 @@ obj_to_enum(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-each_slice_i(VALUE val, VALUE *memo)
+each_slice_i(val, memo)
+ VALUE val;
+ VALUE *memo;
{
VALUE ary = memo[0];
VALUE v = Qnil;
@@ -130,8 +117,10 @@ each_slice_i(VALUE val, VALUE *memo)
/*
* call-seq:
* e.each_slice(n) {...}
+ * e.each_slice(n)
*
- * Iterates the given block for each slice of <n> elements.
+ * 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}
@@ -143,7 +132,8 @@ each_slice_i(VALUE val, VALUE *memo)
*
*/
static VALUE
-enum_each_slice(VALUE obj, VALUE n)
+enum_each_slice(obj, n)
+ VALUE obj, n;
{
long size = NUM2LONG(n);
VALUE args[2], ary;
@@ -162,7 +152,9 @@ enum_each_slice(VALUE obj, VALUE n)
}
static VALUE
-each_cons_i(VALUE val, VALUE *memo)
+each_cons_i(val, memo)
+ VALUE val;
+ VALUE *memo;
{
VALUE ary = memo[0];
VALUE v = Qnil;
@@ -181,9 +173,10 @@ each_cons_i(VALUE val, VALUE *memo)
/*
* call-seq:
* each_cons(n) {...}
+ * each_cons(n)
*
* Iterates the given block for each array of consecutive <n>
- * elements.
+ * elements. If no block is given, returns an enumerator.a
*
* e.g.:
* (1..10).each_cons(3) {|a| p a}
@@ -199,7 +192,8 @@ each_cons_i(VALUE val, VALUE *memo)
*
*/
static VALUE
-enum_each_cons(VALUE obj, VALUE n)
+enum_each_cons(obj, n)
+ VALUE obj, n;
{
long size = NUM2LONG(n);
VALUE args[2];
@@ -214,37 +208,50 @@ enum_each_cons(VALUE obj, VALUE n)
return Qnil;
}
+static VALUE enumerator_allocate _((VALUE));
static VALUE
-enumerator_allocate(VALUE klass)
+enumerator_allocate(klass)
+ VALUE klass;
{
struct enumerator *ptr;
- return Data_Make_Struct(klass, struct enumerator,
- enumerator_mark, -1, 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(VALUE v, VALUE enum_obj, int argc, VALUE *argv)
+enumerator_each_i(v, enum_obj)
+ VALUE v;
+ VALUE enum_obj;
{
- return rb_yield_values2(argc, argv);
+ return rb_yield(v);
}
static VALUE
-enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
+enumerator_init(enum_obj, obj, meth, argc, argv)
+ VALUE enum_obj;
+ VALUE obj;
+ VALUE meth;
+ int argc;
+ VALUE *argv;
{
- struct enumerator *ptr = enumerator_ptr(enum_obj);
+ struct enumerator *ptr;
- ptr->method = rb_obj_method(obj, meth);
- if (rb_block_given_p()) {
- ptr->proc = rb_block_proc();
- ptr->iter = enumerator_iter_i;
- }
- else {
- ptr->iter = enumerator_each_i;
+ 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);
- ptr->fib = 0;
- ptr->dst = Qnil;
- ptr->no_next = Qfalse;
return enum_obj;
}
@@ -257,15 +264,13 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
* 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"]
- *
+ * Use of this method is discouraged. Use Kernel#enum_for() instead.
*/
static VALUE
-enumerator_initialize(int argc, VALUE *argv, VALUE obj)
+enumerator_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE recv, meth = sym_each;
@@ -281,28 +286,34 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj)
/* :nodoc: */
static VALUE
-enumerator_init_copy(VALUE obj, VALUE orig)
+enumerator_init_copy(obj, orig)
+ VALUE obj;
+ VALUE orig;
{
struct enumerator *ptr0, *ptr1;
ptr0 = enumerator_ptr(orig);
- if (ptr0->fib) {
- /* Fibers cannot be copied */
- rb_raise(rb_eTypeError, "can't copy execution context");
+
+ Data_Get_Struct(obj, struct enumerator, ptr1);
+
+ if (!ptr1) {
+ rb_raise(rb_eArgError, "unallocated enumerator");
}
- ptr1 = enumerator_ptr(obj);
- ptr1->method = ptr0->method;
- ptr1->proc = ptr0->proc;
+ ptr1->obj = ptr0->obj;
+ ptr1->meth = ptr0->meth;
ptr1->iter = ptr0->iter;
ptr1->args = ptr0->args;
- ptr1->fib = 0;
return obj;
}
VALUE
-rb_enumeratorize(VALUE obj, VALUE meth, int argc, VALUE *argv)
+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);
}
@@ -312,11 +323,12 @@ rb_enumeratorize(VALUE obj, VALUE meth, int argc, VALUE *argv)
* enum.each {...}
*
* Iterates the given block using the object and the method specified
- * in the first place.
+ * in the first place. If no block is given, returns self.
*
*/
static VALUE
-enumerator_each(VALUE obj)
+enumerator_each(obj)
+ VALUE obj;
{
struct enumerator *e;
int argc = 0;
@@ -328,11 +340,13 @@ enumerator_each(VALUE obj)
argc = RARRAY_LEN(e->args);
argv = RARRAY_PTR(e->args);
}
- return rb_block_call(e->method, SYM2ID(sym_call), argc, argv, e->iter, (VALUE)e);
+ return rb_block_call(e->obj, e->meth, argc, argv, e->iter, (VALUE)e);
}
static VALUE
-enumerator_with_index_i(VALUE val, VALUE *memo)
+enumerator_with_index_i(val, memo)
+ VALUE val;
+ VALUE *memo;
{
val = rb_yield_values(2, val, INT2FIX(*memo));
++*memo;
@@ -342,13 +356,15 @@ enumerator_with_index_i(VALUE val, VALUE *memo)
/*
* call-seq:
* e.with_index {|(*args), idx| ... }
+ * e.with_index
*
* Iterates the given block for each elements with an index, which
- * start from 0.
+ * start from 0. If no block is given, returns an enumerator.
*
*/
static VALUE
-enumerator_with_index(VALUE obj)
+enumerator_with_index(obj)
+ VALUE obj;
{
struct enumerator *e = enumerator_ptr(obj);
VALUE memo = 0;
@@ -360,36 +376,10 @@ enumerator_with_index(VALUE obj)
argc = RARRAY_LEN(e->args);
argv = RARRAY_PTR(e->args);
}
- return rb_block_call(e->method, SYM2ID(sym_call), argc, argv,
+ return rb_block_call(e->obj, e->meth, argc, argv,
enumerator_with_index_i, (VALUE)&memo);
}
-static VALUE
-next_ii(VALUE i, VALUE obj)
-{
- rb_fiber_yield(1, &i);
- return Qnil;
-}
-
-static VALUE
-next_i(VALUE curr, VALUE obj)
-{
- struct enumerator *e = enumerator_ptr(obj);
- VALUE nil = Qnil;
-
- rb_block_call(obj, rb_intern("each"), 0, 0, next_ii, obj);
- e->no_next = Qtrue;
- return rb_fiber_yield(1, &nil);
-}
-
-static void
-next_init(VALUE obj, struct enumerator *e)
-{
- VALUE curr = rb_fiber_current();
- e->dst = curr;
- e->fib = rb_fiber_new(next_i, obj);
-}
-
/*
* call-seq:
* e.next => object
@@ -402,55 +392,43 @@ next_init(VALUE obj, struct enumerator *e)
* 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(VALUE obj)
+enumerator_next(obj)
+ VALUE obj;
{
- struct enumerator *e = enumerator_ptr(obj);
- VALUE curr, v;
- curr = rb_fiber_current();
-
- if (!e->fib || !rb_fiber_alive_p(e->fib)) {
- next_init(obj, e);
- }
-
- v = rb_fiber_resume(e->fib, 1, &curr);
- if (e->no_next) {
- e->fib = 0;
- e->dst = Qnil;
- e->no_next = Qfalse;
- rb_raise(rb_eStopIteration, "iteration reached at end");
- }
- return v;
+ rb_require("generator");
+ return rb_funcall(obj, rb_intern("next"), 0, 0);
}
/*
* call-seq:
- * e.next? => e
+ * e.rewind => e
*
* Rewinds the enumeration sequence by the next method.
*/
static VALUE
-enumerator_rewind(VALUE obj)
+enumerator_rewind(obj)
+ VALUE obj;
{
- struct enumerator *e = enumerator_ptr(obj);
-
- e->fib = 0;
- e->dst = Qnil;
- e->no_next = Qfalse;
- return obj;
+ rb_require("generator");
+ return rb_funcall(obj, rb_intern("rewind"), 0, 0);
}
void
-Init_Enumerator(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);
@@ -459,14 +437,14 @@ Init_Enumerator(void)
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"));
- sym_call = ID2SYM(rb_intern("call"));
+ sym_each = ID2SYM(rb_intern("each"));
rb_provide("enumerator.so"); /* for backward compatibility */
}
diff --git a/env.h b/env.h
new file mode 100644
index 0000000000..c50103f71e
--- /dev/null
+++ b/env.h
@@ -0,0 +1,60 @@
+/**********************************************************************
+
+ env.h -
+
+ $Author$
+ $Date$
+ created at: Mon Jul 11 11:53:03 JST 1994
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef ENV_H
+#define ENV_H
+
+extern struct FRAME {
+ VALUE self;
+ int argc;
+ ID last_func;
+ ID orig_func;
+ VALUE last_class;
+ struct FRAME *prev;
+ struct FRAME *tmp;
+ struct RNode *node;
+ int iter;
+ int flags;
+ unsigned long uniq;
+} *ruby_frame;
+
+void rb_gc_mark_frame _((struct FRAME *));
+
+#define FRAME_DMETH 1
+#define FRAME_FUNC 2
+
+extern struct SCOPE {
+ struct RBasic super;
+ ID *local_tbl;
+ VALUE *local_vars;
+ int flags;
+} *ruby_scope;
+
+#define SCOPE_ALLOCA 0
+#define SCOPE_MALLOC 1
+#define SCOPE_NOSTACK 2
+#define SCOPE_DONT_RECYCLE 4
+#define SCOPE_CLONE 8
+
+extern int ruby_in_eval;
+
+extern VALUE ruby_class;
+
+struct RVarmap {
+ struct RBasic super;
+ ID id;
+ VALUE val;
+ struct RVarmap *next;
+};
+extern struct RVarmap *ruby_dyna_vars;
+
+#endif /* ENV_H */
diff --git a/error.c b/error.c
index 25ddb344a0..a991f55e57 100644
--- a/error.c
+++ b/error.c
@@ -6,16 +6,22 @@
$Date$
created at: Mon Aug 9 16:11:34 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/st.h"
-#include "vm_core.h"
+#include "ruby.h"
+#include "env.h"
+#include "st.h"
#include <stdio.h>
+#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -23,30 +29,33 @@
#define EXIT_SUCCESS 0
#endif
-extern const char ruby_description[];
+extern const char *ruby_description;
+
+int ruby_nerrs;
static int
-err_position_0(char *buf, long len, const char *file, int line)
+err_position(buf, len)
+ char *buf;
+ long len;
{
- if (!file) {
+ ruby_set_current_source();
+ if (!ruby_sourcefile) {
return 0;
}
- else if (line == 0) {
- return snprintf(buf, len, "%s: ", file);
+ else if (ruby_sourceline == 0) {
+ return snprintf(buf, len, "%s: ", ruby_sourcefile);
}
else {
- return snprintf(buf, len, "%s:%d: ", file, line);
+ return snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
}
}
-static int
-err_position(char *buf, long len)
-{
- return err_position_0(buf, len, rb_sourcefile(), rb_sourceline());
-}
-
static void
-err_snprintf(char *buf, long len, const char *fmt, va_list args)
+err_snprintf(buf, len, fmt, args)
+ char *buf;
+ long len;
+ const char *fmt;
+ va_list args;
{
long n;
@@ -56,88 +65,57 @@ err_snprintf(char *buf, long len, const char *fmt, va_list args)
}
}
+static void err_append _((const char*));
static void
-compile_snprintf(char *buf, long len, const char *file, int line, const char *fmt, va_list args)
+err_print(fmt, args)
+ const char *fmt;
+ va_list args;
{
- long n;
+ char buf[BUFSIZ];
- n = err_position_0(buf, len, file, line);
- if (len > n) {
- vsnprintf((char*)buf+n, len-n, fmt, args);
- }
+ err_snprintf(buf, BUFSIZ, fmt, args);
+ err_append(buf);
}
-static void err_append(const char*);
-
void
-rb_compile_error(const char *file, int line, const char *fmt, ...)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_compile_error(const char *fmt, ...)
+#else
+rb_compile_error(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
va_list args;
- char buf[BUFSIZ];
- va_start(args, fmt);
- compile_snprintf(buf, BUFSIZ, file, line, fmt, args);
+ va_init_list(args, fmt);
+ err_print(fmt, args);
va_end(args);
- err_append(buf);
+ ruby_nerrs++;
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_compile_error_append(const char *fmt, ...)
+#else
+rb_compile_error_append(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
- va_start(args, fmt);
+ va_init_list(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
err_append(buf);
}
static void
-compile_warn_print(const char *file, int line, const char *fmt, va_list args)
-{
- char buf[BUFSIZ];
- int len;
-
- compile_snprintf(buf, BUFSIZ, file, line, fmt, args);
- len = strlen(buf);
- buf[len++] = '\n';
- rb_write_error2(buf, len);
-}
-
-void
-rb_compile_warn(const char *file, int line, const char *fmt, ...)
-{
- char buf[BUFSIZ];
+warn_print(fmt, args)
+ const char *fmt;
va_list args;
-
- if (NIL_P(ruby_verbose)) return;
-
- snprintf(buf, BUFSIZ, "warning: %s", fmt);
-
- va_start(args, fmt);
- compile_warn_print(file, line, buf, args);
- va_end(args);
-}
-
-/* rb_compile_warning() reports only in verbose mode */
-void
-rb_compile_warning(const char *file, int line, const char *fmt, ...)
-{
- char buf[BUFSIZ];
- va_list args;
-
- if (!RTEST(ruby_verbose)) return;
-
- snprintf(buf, BUFSIZ, "warning: %s", fmt);
-
- va_start(args, fmt);
- compile_warn_print(file, line, buf, args);
- va_end(args);
-}
-
-static void
-warn_print(const char *fmt, va_list args)
{
char buf[BUFSIZ];
int len;
@@ -149,7 +127,13 @@ warn_print(const char *fmt, va_list args)
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_warn(const char *fmt, ...)
+#else
+rb_warn(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
char buf[BUFSIZ];
va_list args;
@@ -158,14 +142,20 @@ rb_warn(const char *fmt, ...)
snprintf(buf, BUFSIZ, "warning: %s", fmt);
- va_start(args, fmt);
+ va_init_list(args, fmt);
warn_print(buf, args);
va_end(args);
}
/* rb_warning() reports only in verbose mode */
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_warning(const char *fmt, ...)
+#else
+rb_warning(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
char buf[BUFSIZ];
va_list args;
@@ -174,7 +164,7 @@ rb_warning(const char *fmt, ...)
snprintf(buf, BUFSIZ, "warning: %s", fmt);
- va_start(args, fmt);
+ va_init_list(args, fmt);
warn_print(buf, args);
va_end(args);
}
@@ -188,7 +178,8 @@ rb_warning(const char *fmt, ...)
*/
static VALUE
-rb_warn_m(VALUE self, VALUE mesg)
+rb_warn_m(self, mesg)
+ VALUE self, mesg;
{
if (!NIL_P(ruby_verbose)) {
rb_io_write(rb_stderr, mesg);
@@ -197,45 +188,28 @@ rb_warn_m(VALUE self, VALUE mesg)
return Qnil;
}
-void rb_vm_bugreport(void);
-
-static void
-report_bug(const char *file, int line, const char *fmt, va_list args)
+void
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_bug(const char *fmt, ...)
+#else
+rb_bug(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
char buf[BUFSIZ];
+ va_list args;
FILE *out = stderr;
- int len = err_position_0(buf, BUFSIZ, file, line);
+ int len = err_position(buf, BUFSIZ);
if (fwrite(buf, 1, len, out) == len ||
fwrite(buf, 1, len, (out = stdout)) == len) {
fputs("[BUG] ", out);
+ va_init_list(args, fmt);
vfprintf(out, fmt, args);
+ va_end(args);
fprintf(out, "\n%s\n\n", ruby_description);
- rb_vm_bugreport();
}
-}
-
-void
-rb_bug(const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- report_bug(rb_sourcefile(), rb_sourceline(), fmt, args);
- va_end(args);
-
- abort();
-}
-
-void
-rb_compile_bug(const char *file, int line, const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- report_bug(file, line, fmt, args);
- va_end(args);
-
abort();
}
@@ -262,13 +236,17 @@ static struct types {
{T_SYMBOL, "Symbol"}, /* :symbol */
{T_DATA, "Data"}, /* internal use: wrapped C pointers */
{T_MATCH, "MatchData"}, /* data of $~ */
+ {T_VARMAP, "Varmap"}, /* internal use: dynamic variables */
+ {T_SCOPE, "Scope"}, /* internal use: variable scope */
{T_NODE, "Node"}, /* internal use: syntax tree node */
{T_UNDEF, "undef"}, /* internal use: #undef; should not happen */
{-1, 0}
};
void
-rb_check_type(VALUE x, int t)
+rb_check_type(x, t)
+ VALUE x;
+ int t;
{
struct types *type = builtin_types;
@@ -291,7 +269,7 @@ rb_check_type(VALUE x, int t)
etype = "Symbol";
}
else if (rb_special_const_p(x)) {
- etype = RSTRING_PTR(rb_obj_as_string(x));
+ etype = RSTRING(rb_obj_as_string(x))->ptr;
}
else {
etype = rb_obj_classname(x);
@@ -301,7 +279,7 @@ rb_check_type(VALUE x, int t)
}
type++;
}
- rb_bug("unknown type 0x%x (0x%x given)", t, TYPE(x));
+ rb_bug("unknown type 0x%x", t);
}
}
@@ -318,7 +296,6 @@ VALUE rb_eRuntimeError;
VALUE rb_eTypeError;
VALUE rb_eArgError;
VALUE rb_eIndexError;
-VALUE rb_eKeyError;
VALUE rb_eRangeError;
VALUE rb_eNameError;
VALUE rb_eNoMethodError;
@@ -333,22 +310,27 @@ VALUE rb_eLoadError;
VALUE rb_eSystemCallError;
VALUE rb_mErrno;
-static VALUE eNOERROR;
VALUE
-rb_exc_new(VALUE etype, const char *ptr, long len)
+rb_exc_new(etype, ptr, len)
+ VALUE etype;
+ const char *ptr;
+ long len;
{
return rb_funcall(etype, rb_intern("new"), 1, rb_str_new(ptr, len));
}
VALUE
-rb_exc_new2(VALUE etype, const char *s)
+rb_exc_new2(etype, s)
+ VALUE etype;
+ const char *s;
{
return rb_exc_new(etype, s, strlen(s));
}
VALUE
-rb_exc_new3(VALUE etype, VALUE str)
+rb_exc_new3(etype, str)
+ VALUE etype, str;
{
StringValue(str);
return rb_funcall(etype, rb_intern("new"), 1, str);
@@ -363,7 +345,10 @@ rb_exc_new3(VALUE etype, VALUE str)
*/
static VALUE
-exc_initialize(int argc, VALUE *argv, VALUE exc)
+exc_initialize(argc, argv, exc)
+ int argc;
+ VALUE *argv;
+ VALUE exc;
{
VALUE arg;
@@ -388,7 +373,10 @@ exc_initialize(int argc, VALUE *argv, VALUE exc)
*/
static VALUE
-exc_exception(int argc, VALUE *argv, VALUE self)
+exc_exception(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE exc;
@@ -409,7 +397,8 @@ exc_exception(int argc, VALUE *argv, VALUE self)
*/
static VALUE
-exc_to_s(VALUE exc)
+exc_to_s(exc)
+ VALUE exc;
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
@@ -421,6 +410,7 @@ exc_to_s(VALUE exc)
/*
* call-seq:
* exception.message => string
+ * exception.to_str => string
*
* Returns the result of invoking <code>exception.to_s</code>.
* Normally this returns the exception's message or name. By
@@ -429,7 +419,8 @@ exc_to_s(VALUE exc)
*/
static VALUE
-exc_message(VALUE exc)
+exc_to_str(exc)
+ VALUE exc;
{
return rb_funcall(exc, rb_intern("to_s"), 0, 0);
}
@@ -442,13 +433,14 @@ exc_message(VALUE exc)
*/
static VALUE
-exc_inspect(VALUE exc)
+exc_inspect(exc)
+ VALUE exc;
{
VALUE str, klass;
klass = CLASS_OF(exc);
exc = rb_obj_as_string(exc);
- if (RSTRING_LEN(exc) == 0) {
+ if (RSTRING(exc)->len == 0) {
return rb_str_dup(rb_class_name(klass));
}
@@ -492,7 +484,8 @@ exc_inspect(VALUE exc)
*/
static VALUE
-exc_backtrace(VALUE exc)
+exc_backtrace(exc)
+ VALUE exc;
{
static ID bt;
@@ -501,10 +494,11 @@ exc_backtrace(VALUE exc)
}
VALUE
-rb_check_backtrace(VALUE bt)
+rb_check_backtrace(bt)
+ VALUE bt;
{
long i;
- static const char *err = "backtrace must be Array of String";
+ static const char err[] = "backtrace must be Array of String";
if (!NIL_P(bt)) {
int t = TYPE(bt);
@@ -513,8 +507,8 @@ rb_check_backtrace(VALUE bt)
if (t != T_ARRAY) {
rb_raise(rb_eTypeError, err);
}
- for (i=0;i<RARRAY_LEN(bt);i++) {
- if (TYPE(RARRAY_PTR(bt)[i]) != T_STRING) {
+ for (i=0;i<RARRAY(bt)->len;i++) {
+ if (TYPE(RARRAY(bt)->ptr[i]) != T_STRING) {
rb_raise(rb_eTypeError, err);
}
}
@@ -533,36 +527,14 @@ rb_check_backtrace(VALUE bt)
*/
static VALUE
-exc_set_backtrace(VALUE exc, VALUE bt)
+exc_set_backtrace(exc, bt)
+ VALUE exc;
+ VALUE bt;
{
return rb_iv_set(exc, "bt", rb_check_backtrace(bt));
}
/*
- * call-seq:
- * exc == obj => true or false
- *
- * Equality---If <i>obj</i> is not an <code>Exception</code>, returns
- * <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
- * <i>obj</i> share same class, messages, and backtrace.
- */
-
-static VALUE
-exc_equal(VALUE exc, VALUE obj)
-{
- ID id_mesg = rb_intern("mesg");
-
- if (exc == obj) return Qtrue;
- if (rb_obj_class(exc) != rb_obj_class(obj))
- return Qfalse;
- if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
- return Qfalse;
- if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
- return Qfalse;
- return Qtrue;
-}
-
-/*
* call-seq:
* SystemExit.new(status=0) => system_exit
*
@@ -570,7 +542,10 @@ exc_equal(VALUE exc, VALUE obj)
*/
static VALUE
-exit_initialize(int argc, VALUE *argv, VALUE exc)
+exit_initialize(argc, argv, exc)
+ int argc;
+ VALUE *argv;
+ VALUE exc;
{
VALUE status = INT2FIX(EXIT_SUCCESS);
if (argc > 0 && FIXNUM_P(argv[0])) {
@@ -591,7 +566,8 @@ exit_initialize(int argc, VALUE *argv, VALUE exc)
*/
static VALUE
-exit_status(VALUE exc)
+exit_status(exc)
+ VALUE exc;
{
return rb_attr_get(exc, rb_intern("status"));
}
@@ -605,7 +581,8 @@ exit_status(VALUE exc)
*/
static VALUE
-exit_success_p(VALUE exc)
+exit_success_p(exc)
+ VALUE exc;
{
VALUE status = rb_attr_get(exc, rb_intern("status"));
if (NIL_P(status)) return Qtrue;
@@ -614,13 +591,20 @@ exit_success_p(VALUE exc)
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_name_error(ID id, const char *fmt, ...)
+#else
+rb_name_error(id, fmt, va_alist)
+ ID id;
+ const char *fmt;
+ va_dcl
+#endif
{
VALUE exc, argv[2];
va_list args;
char buf[BUFSIZ];
- va_start(args, fmt);
+ va_init_list(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
@@ -640,7 +624,10 @@ rb_name_error(ID id, const char *fmt, ...)
*/
static VALUE
-name_err_initialize(int argc, VALUE *argv, VALUE self)
+name_err_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE name;
@@ -658,7 +645,8 @@ name_err_initialize(int argc, VALUE *argv, VALUE self)
*/
static VALUE
-name_err_name(VALUE self)
+name_err_name(self)
+ VALUE self;
{
return rb_attr_get(self, rb_intern("name"));
}
@@ -671,10 +659,10 @@ name_err_name(VALUE self)
*/
static VALUE
-name_err_to_s(VALUE exc)
+name_err_to_s(exc)
+ VALUE exc;
{
- VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
- VALUE str = mesg;
+ VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
@@ -696,7 +684,10 @@ name_err_to_s(VALUE exc)
*/
static VALUE
-nometh_err_initialize(int argc, VALUE *argv, VALUE self)
+nometh_err_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE args = (argc > 2) ? argv[--argc] : Qnil;
name_err_initialize(argc, argv, self);
@@ -706,14 +697,16 @@ nometh_err_initialize(int argc, VALUE *argv, VALUE self)
/* :nodoc: */
static void
-name_err_mesg_mark(VALUE *ptr)
+name_err_mesg_mark(ptr)
+ VALUE *ptr;
{
rb_gc_mark_locations(ptr, ptr+3);
}
/* :nodoc: */
static VALUE
-name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method)
+name_err_mesg_new(obj, mesg, recv, method)
+ VALUE obj, mesg, recv, method;
{
VALUE *ptr = ALLOC_N(VALUE, 3);
@@ -725,27 +718,8 @@ name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method)
/* :nodoc: */
static VALUE
-name_err_mesg_equal(VALUE obj1, VALUE obj2)
-{
- VALUE *ptr1, *ptr2;
- int i;
-
- if (obj1 == obj2) return Qtrue;
- if (rb_obj_class(obj2) != rb_cNameErrorMesg)
- return Qfalse;
-
- Data_Get_Struct(obj1, VALUE, ptr1);
- Data_Get_Struct(obj2, VALUE, ptr2);
- for (i=0; i<3; i++) {
- if (!rb_equal(ptr1[i], ptr2[i]))
- return Qfalse;
- }
- return Qtrue;
-}
-
-/* :nodoc: */
-static VALUE
-name_err_mesg_to_str(VALUE obj)
+name_err_mesg_to_str(obj)
+ VALUE obj;
{
VALUE *ptr, mesg;
Data_Get_Struct(obj, VALUE, ptr);
@@ -769,10 +743,10 @@ name_err_mesg_to_str(VALUE obj)
break;
default:
d = rb_protect(rb_inspect, obj, 0);
- if (NIL_P(d) || RSTRING_LEN(d) > 65) {
+ if (NIL_P(d) || RSTRING(d)->len > 65) {
d = rb_any_to_s(obj);
}
- desc = RSTRING_PTR(d);
+ desc = RSTRING(d)->ptr;
break;
}
if (desc && desc[0] != '#') {
@@ -791,7 +765,8 @@ name_err_mesg_to_str(VALUE obj)
/* :nodoc: */
static VALUE
-name_err_mesg_load(VALUE klass, VALUE str)
+name_err_mesg_load(klass, str)
+ VALUE klass, str;
{
return str;
}
@@ -805,17 +780,19 @@ name_err_mesg_load(VALUE klass, VALUE str)
*/
static VALUE
-nometh_err_args(VALUE self)
+nometh_err_args(self)
+ VALUE self;
{
return rb_attr_get(self, rb_intern("args"));
}
void
-rb_invalid_str(const char *str, const char *type)
+rb_invalid_str(str, type)
+ const char *str, *type;
{
VALUE s = rb_str_inspect(rb_str_new2(str));
- rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING_PTR(s));
+ rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING(s)->ptr);
}
/*
@@ -852,7 +829,9 @@ rb_invalid_str(const char *str, const char *type)
static st_table *syserr_tbl;
static VALUE
-set_syserr(int n, const char *name)
+set_syserr(n, name)
+ int n;
+ const char *name;
{
VALUE error;
@@ -868,7 +847,8 @@ set_syserr(int n, const char *name)
}
static VALUE
-get_syserr(int n)
+get_syserr(n)
+ int n;
{
VALUE error;
@@ -893,7 +873,10 @@ get_syserr(int n)
*/
static VALUE
-syserr_initialize(int argc, VALUE *argv, VALUE self)
+syserr_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
#if !defined(_WIN32) && !defined(__VMS)
char *strerror();
@@ -923,10 +906,14 @@ syserr_initialize(int argc, VALUE *argv, VALUE self)
else err = "unknown error";
if (!NIL_P(mesg)) {
VALUE str = mesg;
+ size_t len;
StringValue(str);
- mesg = rb_sprintf("%s - %.*s", err,
- (int)RSTRING_LEN(str), RSTRING_PTR(str));
+ len = strlen(err)+RSTRING(str)->len+3;
+ mesg = rb_str_new(0, len);
+ snprintf(RSTRING(mesg)->ptr, len+1, "%s - %.*s", err,
+ (int)RSTRING(str)->len, RSTRING(str)->ptr);
+ rb_str_resize(mesg, strlen(RSTRING(mesg)->ptr));
}
else {
mesg = rb_str_new2(err);
@@ -944,7 +931,8 @@ syserr_initialize(int argc, VALUE *argv, VALUE self)
*/
static VALUE
-syserr_errno(VALUE self)
+syserr_errno(self)
+ VALUE self;
{
return rb_attr_get(self, rb_intern("errno"));
}
@@ -957,22 +945,22 @@ syserr_errno(VALUE self)
* if the error numbers _self_ and _other_ are the same.
*/
+
static VALUE
-syserr_eqq(VALUE self, VALUE exc)
+syserr_eqq(self, exc)
+ VALUE self, exc;
{
VALUE num, e;
+ ID en = rb_intern("errno");
- if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) return Qfalse;
- if (self == rb_eSystemCallError) return Qtrue;
+ if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) {
+ if (!rb_respond_to(exc, en)) return Qfalse;
+ }
+ else if (self == rb_eSystemCallError) return Qtrue;
- num = rb_attr_get(exc, rb_intern("errno"));
+ num = rb_attr_get(exc, en);
if (NIL_P(num)) {
- VALUE klass = CLASS_OF(exc);
-
- while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
- klass = (VALUE)RCLASS_SUPER(klass);
- }
- num = rb_const_get(klass, rb_intern("Errno"));
+ num = rb_funcall(exc, en, 0, 0);
}
e = rb_const_get(self, rb_intern("Errno"));
if (FIXNUM_P(num) ? num == e : rb_equal(num, e))
@@ -981,18 +969,6 @@ syserr_eqq(VALUE self, VALUE exc)
}
/*
- * call-seq:
- * Errno.const_missing => SystemCallError
- *
- * Returns default SystemCallError class.
- */
-static VALUE
-errno_missing(VALUE self, VALUE id)
-{
- return eNOERROR;
-}
-
-/*
* Descendents of class <code>Exception</code> are used to communicate
* between <code>raise</code> methods and <code>rescue</code>
* statements in <code>begin/end</code> blocks. <code>Exception</code>
@@ -1003,15 +979,15 @@ errno_missing(VALUE self, VALUE id)
*/
void
-Init_Exception(void)
+Init_Exception()
{
rb_eException = rb_define_class("Exception", rb_cObject);
rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1);
rb_define_method(rb_eException, "exception", exc_exception, -1);
rb_define_method(rb_eException, "initialize", exc_initialize, -1);
- rb_define_method(rb_eException, "==", exc_equal, 1);
rb_define_method(rb_eException, "to_s", exc_to_s, 0);
- rb_define_method(rb_eException, "message", exc_message, 0);
+ rb_define_method(rb_eException, "to_str", exc_to_str, 0);
+ rb_define_method(rb_eException, "message", exc_to_str, 0);
rb_define_method(rb_eException, "inspect", exc_inspect, 0);
rb_define_method(rb_eException, "backtrace", exc_backtrace, 0);
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
@@ -1029,21 +1005,13 @@ Init_Exception(void)
rb_eTypeError = rb_define_class("TypeError", rb_eStandardError);
rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
- rb_eKeyError = rb_define_class("KeyError", rb_eIndexError);
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
-
- rb_eScriptError = rb_define_class("ScriptError", rb_eException);
- rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
- rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
- rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
-
rb_eNameError = rb_define_class("NameError", rb_eStandardError);
rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1);
rb_define_method(rb_eNameError, "name", name_err_name, 0);
rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData);
rb_define_singleton_method(rb_cNameErrorMesg, "!", name_err_mesg_new, 3);
- rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1);
rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0);
rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1);
rb_define_singleton_method(rb_cNameErrorMesg, "_load", name_err_mesg_load, 1);
@@ -1051,8 +1019,13 @@ Init_Exception(void)
rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
+ rb_eScriptError = rb_define_class("ScriptError", rb_eException);
+ rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
+ rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
+ rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
+
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
- rb_eSecurityError = rb_define_class("SecurityError", rb_eException);
+ rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
syserr_tbl = st_init_numtable();
@@ -1062,58 +1035,78 @@ Init_Exception(void)
rb_define_singleton_method(rb_eSystemCallError, "===", syserr_eqq, 1);
rb_mErrno = rb_define_module("Errno");
- rb_define_singleton_method(rb_mErrno, "const_missing", errno_missing, 1);
rb_define_global_function("warn", rb_warn_m, 1);
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_raise(VALUE exc, const char *fmt, ...)
+#else
+rb_raise(exc, fmt, va_alist)
+ VALUE exc;
+ const char *fmt;
+ va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
- va_start(args,fmt);
+ va_init_list(args,fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new2(exc, buf));
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_loaderror(const char *fmt, ...)
+#else
+rb_loaderror(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
- va_start(args, fmt);
+ va_init_list(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
rb_exc_raise(rb_exc_new2(rb_eLoadError, buf));
}
void
-rb_notimplement(void)
+rb_notimplement()
{
rb_raise(rb_eNotImpError,
"%s() function is unimplemented on this machine",
- rb_id2name(rb_frame_this_func()));
+ rb_id2name(ruby_frame->last_func));
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_fatal(const char *fmt, ...)
+#else
+rb_fatal(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
- va_start(args, fmt);
+ va_init_list(args, fmt);
vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
+ ruby_in_eval = 0;
rb_exc_fatal(rb_exc_new2(rb_eFatal, buf));
}
void
-rb_sys_fail(const char *mesg)
+rb_sys_fail(mesg)
+ const char *mesg;
{
int n = errno;
VALUE arg;
@@ -1128,45 +1121,54 @@ rb_sys_fail(const char *mesg)
}
void
+#ifdef HAVE_STDARG_PROTOTYPES
rb_sys_warning(const char *fmt, ...)
+#else
+rb_sys_warning(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
{
- char buf[BUFSIZ];
- va_list args;
- int errno_save;
-
- errno_save = errno;
-
- if (!RTEST(ruby_verbose)) return;
-
- snprintf(buf, BUFSIZ, "warning: %s", fmt);
- snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
-
- va_start(args, fmt);
- warn_print(buf, args);
- va_end(args);
- errno = errno_save;
+ char buf[BUFSIZ];
+ va_list args;
+ int errno_save;
+
+ errno_save = errno;
+
+ if (!RTEST(ruby_verbose)) return;
+
+ snprintf(buf, BUFSIZ, "warning: %s", fmt);
+ snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
+
+ va_init_list(args, fmt);
+ warn_print(buf, args);
+ va_end(args);
+ errno = errno_save;
}
void
-rb_load_fail(const char *path)
+rb_load_fail(path)
+ const char *path;
{
rb_loaderror("%s -- %s", strerror(errno), path);
}
void
-rb_error_frozen(const char *what)
+rb_error_frozen(what)
+ const char *what;
{
- rb_raise(rb_eRuntimeError, "can't modify frozen %s", what);
+ rb_raise(rb_eTypeError, "can't modify frozen %s", what);
}
void
-rb_check_frozen(VALUE obj)
+rb_check_frozen(obj)
+ VALUE obj;
{
if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
}
void
-Init_syserr(void)
+Init_syserr()
{
#ifdef EPERM
set_syserr(EPERM, "EPERM");
@@ -1534,33 +1536,27 @@ Init_syserr(void)
#ifdef EDQUOT
set_syserr(EDQUOT, "EDQUOT");
#endif
- eNOERROR = set_syserr(0, "NOERROR");
}
static void
-err_append(const char *s)
+err_append(s)
+ const char *s;
{
- rb_thread_t *th = GET_THREAD();
- VALUE err = th->errinfo;
+ extern VALUE ruby_errinfo;
- if (th->parse_in_eval) {
- if (!RTEST(err)) {
- err = rb_exc_new2(rb_eSyntaxError, s);
- th->errinfo = err;
+ if (ruby_in_eval) {
+ if (NIL_P(ruby_errinfo)) {
+ ruby_errinfo = rb_exc_new2(rb_eSyntaxError, s);
}
else {
- VALUE str = rb_obj_as_string(err);
+ VALUE str = rb_obj_as_string(ruby_errinfo);
rb_str_cat2(str, "\n");
rb_str_cat2(str, s);
- th->errinfo = rb_exc_new3(rb_eSyntaxError, str);
+ ruby_errinfo = rb_exc_new3(rb_eSyntaxError, str);
}
}
else {
- if (!RTEST(err)) {
- err = rb_exc_new2(rb_eSyntaxError, "compile error");
- th->errinfo = err;
- }
rb_write_error(s);
rb_write_error("\n");
}
diff --git a/eval.c b/eval.c
index 270d160ba0..d2a2556494 100644
--- a/eval.c
+++ b/eval.c
@@ -6,44 +6,1332 @@
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "eval_intern.h"
+#include "ruby.h"
+#include "node.h"
+#include "env.h"
+#include "util.h"
+#include "rubysig.h"
-VALUE proc_invoke(VALUE, VALUE, VALUE, VALUE);
-VALUE rb_binding_new();
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+#include <stdio.h>
+
+#include "st.h"
+#include "dln.h"
+
+#ifdef __APPLE__
+#include <crt_externs.h>
+#endif
+
+/* Make alloca work the best possible way. */
+#ifdef __GNUC__
+# ifndef atarist
+# ifndef alloca
+# define alloca __builtin_alloca
+# endif
+# endif /* atarist */
+#else
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifndef _AIX
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+void *alloca ();
+# endif
+# endif /* AIX */
+# endif /* HAVE_ALLOCA_H */
+#endif /* __GNUC__ */
+
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
+
+#ifndef HAVE_STRING_H
+char *strrchr _((const char*,const char));
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <time.h>
+
+#ifdef __BEOS__
+#include <net/socket.h>
+#endif
+
+#ifdef __MACOS__
+#include "macruby_private.h"
+#endif
+
+#ifdef __VMS
+#include "vmsruby_private.h"
+#endif
+
+#ifdef USE_CONTEXT
+
+NORETURN(static void rb_jump_context(rb_jmpbuf_t, int));
+static inline void
+rb_jump_context(env, val)
+ rb_jmpbuf_t env;
+ int val;
+{
+ env->status = val;
+ setcontext(&env->context);
+ abort(); /* ensure noreturn */
+}
+/*
+ * PRE_GETCONTEXT and POST_GETCONTEXT is a magic for getcontext, gcc,
+ * IA64 register stack and SPARC register window combination problem.
+ *
+ * Assume following code sequence.
+ *
+ * 1. set a register in the register stack/window such as r32/l0.
+ * 2. call getcontext.
+ * 3. use the register.
+ * 4. update the register for other use.
+ * 5. call setcontext indirectly (or directly).
+ *
+ * This code should be run as 1->2->3->4->5->3->4.
+ * But after second getcontext return (second 3),
+ * the register is broken (updated).
+ * It's because getcontext/setcontext doesn't preserve the content of the
+ * register stack/window.
+ *
+ * setjmp also doesn't preserve the content of the register stack/window.
+ * But it has not the problem because gcc knows setjmp may return twice.
+ * gcc detects setjmp and generates setjmp safe code.
+ *
+ * So setjmp calls before and after the getcontext call makes the code
+ * somewhat safe.
+ * It fix the problem on IA64.
+ * It is not required that setjmp is called at run time, since the problem is
+ * register usage.
+ *
+ * Since the magic setjmp is not enough for SPARC,
+ * inline asm is used to prohibit registers in register windows.
+ *
+ * Since the problem is fixed at gcc 4.0.3, the magic is applied only for
+ * prior versions of gcc.
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21957
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22127
+ */
+# define GCC_VERSION_BEFORE(major, minor, patchlevel) \
+ (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
+ ((__GNUC__ < (major)) || \
+ (__GNUC__ == (major) && __GNUC_MINOR__ < (minor)) || \
+ (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ < (patchlevel))))
+# if GCC_VERSION_BEFORE(4,0,3) && (defined(sparc) || defined(__sparc__))
+# ifdef __pic__
+/*
+ * %l7 is excluded for PIC because it is PIC register.
+ * http://lists.freebsd.org/pipermail/freebsd-sparc64/2006-January/003739.html
+ */
+# define PRE_GETCONTEXT \
+ ({ __asm__ volatile ("" : : : \
+ "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \
+ "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", \
+ "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); })
+# else
+# define PRE_GETCONTEXT \
+ ({ __asm__ volatile ("" : : : \
+ "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \
+ "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
+ "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); })
+# endif
+# define POST_GETCONTEXT PRE_GETCONTEXT
+# elif GCC_VERSION_BEFORE(4,0,3) && defined(__ia64)
+static jmp_buf function_call_may_return_twice_jmp_buf;
+int function_call_may_return_twice_false_1 = 0;
+int function_call_may_return_twice_false_2 = 0;
+# define PRE_GETCONTEXT \
+ (function_call_may_return_twice_false_1 ? \
+ setjmp(function_call_may_return_twice_jmp_buf) : \
+ 0)
+# define POST_GETCONTEXT \
+ (function_call_may_return_twice_false_2 ? \
+ setjmp(function_call_may_return_twice_jmp_buf) : \
+ 0)
+# elif defined(__FreeBSD__) && __FreeBSD__ < 7
+/*
+ * workaround for FreeBSD/i386 getcontext/setcontext bug.
+ * clear the carry flag by (0 ? ... : ...).
+ * FreeBSD PR 92110 http://www.freebsd.org/cgi/query-pr.cgi?pr=92110
+ * [ruby-dev:28263]
+ */
+static int volatile freebsd_clear_carry_flag = 0;
+# define PRE_GETCONTEXT \
+ (freebsd_clear_carry_flag ? (freebsd_clear_carry_flag = 0) : 0)
+# endif
+# ifndef PRE_GETCONTEXT
+# define PRE_GETCONTEXT 0
+# endif
+# ifndef POST_GETCONTEXT
+# 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), \
+ 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();
+# endif
+#endif
+
+#include <sys/types.h>
+#include <signal.h>
+#include <errno.h>
+
+#if defined(__VMS)
+#pragma nostandard
+#endif
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#include <sys/stat.h>
+
+VALUE rb_cProc;
+VALUE rb_cBinding;
+static VALUE proc_invoke _((VALUE,VALUE,VALUE,VALUE));
+static VALUE rb_f_binding _((VALUE));
+static void rb_f_END _((void));
+static VALUE rb_f_block_given_p _((void));
+static VALUE block_pass _((VALUE,NODE*));
+
+VALUE rb_cMethod;
+static VALUE method_call _((int, VALUE*, VALUE));
+VALUE rb_cUnboundMethod;
+static VALUE umethod_bind _((VALUE, VALUE));
+static VALUE rb_mod_define_method _((int, VALUE*, VALUE));
+NORETURN(static void rb_raise_jump _((VALUE)));
+static VALUE rb_make_exception _((int argc, VALUE *argv));
+
+static int scope_vmode;
+#define SCOPE_PUBLIC 0
+#define SCOPE_PRIVATE 1
+#define SCOPE_PROTECTED 2
+#define SCOPE_MODFUNC 5
+#define SCOPE_MASK 7
+#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:
+ 0 - strings from streams/environment/ARGV are tainted (default)
+ 1 - no dangerous operation by tainted value
+ 2 - process/file operations prohibited
+ 3 - all generated objects are tainted
+ 4 - no global (non-tainted) variable modification/no direct output
+*/
+
+static VALUE safe_getter _((void));
+static void safe_setter _((VALUE val));
+
+void
+rb_secure(level)
+ int level;
+{
+ if (level <= ruby_safe_level) {
+ if (ruby_frame->last_func) {
+ rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d",
+ rb_id2name(ruby_frame->last_func), ruby_safe_level);
+ }
+ else {
+ rb_raise(rb_eSecurityError, "Insecure operation at level %d", ruby_safe_level);
+ }
+ }
+}
+
+void
+rb_secure_update(obj)
+ VALUE obj;
+{
+ if (!OBJ_TAINTED(obj)) rb_secure(4);
+}
+
+void
+rb_check_safe_obj(x)
+ VALUE x;
+{
+ if (ruby_safe_level > 0 && OBJ_TAINTED(x)){
+ if (ruby_frame->last_func) {
+ rb_raise(rb_eSecurityError, "Insecure operation - %s",
+ rb_id2name(ruby_frame->last_func));
+ }
+ else {
+ rb_raise(rb_eSecurityError, "Insecure operation: -r");
+ }
+ }
+ rb_secure(4);
+}
-VALUE rb_f_block_given_p(void);
+void
+rb_check_safe_str(x)
+ VALUE x;
+{
+ rb_check_safe_obj(x);
+ if (TYPE(x)!= T_STRING) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
+ rb_obj_classname(x));
+ }
+}
-ID rb_frame_callee(void);
-static VALUE rb_frame_self(void);
+NORETURN(static void print_undef _((VALUE, ID)));
+static void
+print_undef(klass, id)
+ VALUE klass;
+ ID id;
+{
+ rb_name_error(id, "undefined method `%s' for %s `%s'",
+ rb_id2name(id),
+ (TYPE(klass) == T_MODULE) ? "module" : "class",
+ rb_class2name(klass));
+}
static ID removed, singleton_removed, undefined, singleton_undefined;
+
+#define CACHE_SIZE 0x800
+#define CACHE_MASK 0x7ff
+#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
+
+struct cache_entry { /* method hash table. */
+ ID mid; /* method's id */
+ ID mid0; /* method's original id */
+ VALUE klass; /* receiver's class */
+ VALUE origin; /* where method defined */
+ NODE *method;
+ int noex;
+};
+
+static struct cache_entry cache[CACHE_SIZE];
+static int ruby_running = 0;
+
+void
+rb_clear_cache()
+{
+ struct cache_entry *ent, *end;
+
+ if (!ruby_running) return;
+ ent = cache; end = ent + CACHE_SIZE;
+ while (ent < end) {
+ ent->mid = 0;
+ ent++;
+ }
+}
+
+static void
+rb_clear_cache_for_undef(klass, id)
+ VALUE klass;
+ ID id;
+{
+ struct cache_entry *ent, *end;
+
+ if (!ruby_running) return;
+ ent = cache; end = ent + CACHE_SIZE;
+ while (ent < end) {
+ if (ent->mid == id &&
+ RCLASS(ent->origin)->m_tbl == RCLASS(klass)->m_tbl) {
+ ent->mid = 0;
+ }
+ ent++;
+ }
+}
+
+static void
+rb_clear_cache_by_id(id)
+ ID id;
+{
+ struct cache_entry *ent, *end;
+
+ if (!ruby_running) return;
+ ent = cache; end = ent + CACHE_SIZE;
+ while (ent < end) {
+ if (ent->mid == id) {
+ ent->mid = 0;
+ }
+ ent++;
+ }
+}
+
+void
+rb_clear_cache_by_class(klass)
+ VALUE klass;
+{
+ struct cache_entry *ent, *end;
+
+ if (!ruby_running) return;
+ ent = cache; end = ent + CACHE_SIZE;
+ while (ent < end) {
+ if (ent->klass == klass || ent->origin == klass) {
+ ent->mid = 0;
+ }
+ ent++;
+ }
+}
+
static ID init, eqq, each, aref, aset, match, missing;
static ID added, singleton_added;
-static ID object_id, __send__, respond_to;
+static ID __id__, __send__, respond_to;
+
+#define NOEX_TAINTED 8
+#define NOEX_SAFE(n) ((n) >> 4)
+#define NOEX_WITH(n, v) ((n) | (v) << 4)
+#define NOEX_WITH_SAFE(n) NOEX_WITH(n, ruby_safe_level)
+
+void
+rb_add_method(klass, mid, node, noex)
+ VALUE klass;
+ ID mid;
+ NODE *node;
+ int noex;
+{
+ NODE *body;
+
+ if (NIL_P(klass)) klass = rb_cObject;
+ if (ruby_safe_level >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
+ rb_raise(rb_eSecurityError, "Insecure: can't define method");
+ }
+ if (!FL_TEST(klass, FL_SINGLETON) &&
+ node && nd_type(node) != NODE_ZSUPER &&
+ (mid == rb_intern("initialize" )|| mid == rb_intern("initialize_copy"))) {
+ noex = NOEX_PRIVATE | noex;
+ }
+ else if (FL_TEST(klass, FL_SINGLETON) && node && nd_type(node) == NODE_CFUNC &&
+ mid == rb_intern("allocate")) {
+ rb_warn("defining %s.allocate is deprecated; use rb_define_alloc_func()",
+ rb_class2name(rb_iv_get(klass, "__attached__")));
+ mid = ID_ALLOCATOR;
+ }
+ if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
+ rb_clear_cache_by_id(mid);
+ body = NEW_METHOD(node, NOEX_WITH_SAFE(noex));
+ st_insert(RCLASS(klass)->m_tbl, mid, (st_data_t)body);
+ if (node && mid != ID_ALLOCATOR && ruby_running) {
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(klass, "__attached__"), singleton_added, 1, ID2SYM(mid));
+ }
+ else {
+ rb_funcall(klass, added, 1, ID2SYM(mid));
+ }
+ }
+}
+
+void
+rb_define_alloc_func(klass, func)
+ VALUE klass;
+ VALUE (*func) _((VALUE));
+{
+ Check_Type(klass, T_CLASS);
+ rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0),
+ NOEX_PRIVATE);
+}
+
+void
+rb_undef_alloc_func(klass)
+ VALUE klass;
+{
+ Check_Type(klass, T_CLASS);
+ rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
+}
+
+static NODE*
+search_method(klass, id, origin)
+ VALUE klass, *origin;
+ ID id;
+{
+ st_data_t body;
+
+ if (!klass) return 0;
+ while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
+ klass = RCLASS(klass)->super;
+ if (!klass) return 0;
+ }
+
+ if (origin) *origin = klass;
+ return (NODE *)body;
+}
+
+static NODE*
+rb_get_method_body(klassp, idp, noexp)
+ VALUE *klassp;
+ ID *idp;
+ int *noexp;
+{
+ ID id = *idp;
+ VALUE klass = *klassp;
+ VALUE origin = 0;
+ NODE * volatile body;
+ struct cache_entry *ent;
+
+ if ((body = search_method(klass, id, &origin)) == 0 || !body->nd_body) {
+ /* store empty info in cache */
+ ent = cache + EXPR1(klass, id);
+ ent->klass = klass;
+ ent->origin = klass;
+ ent->mid = ent->mid0 = id;
+ ent->noex = 0;
+ ent->method = 0;
+
+ return 0;
+ }
+
+ if (ruby_running) {
+ /* store in cache */
+ ent = cache + EXPR1(klass, id);
+ ent->klass = klass;
+ ent->noex = body->nd_noex;
+ if (noexp) *noexp = body->nd_noex;
+ body = body->nd_body;
+ if (nd_type(body) == NODE_FBODY) {
+ ent->mid = id;
+ *klassp = body->nd_orig;
+ ent->origin = body->nd_orig;
+ *idp = ent->mid0 = body->nd_mid;
+ body = ent->method = body->nd_head;
+ }
+ else {
+ *klassp = origin;
+ ent->origin = origin;
+ ent->mid = ent->mid0 = id;
+ ent->method = body;
+ }
+ }
+ else {
+ if (noexp) *noexp = body->nd_noex;
+ body = body->nd_body;
+ if (nd_type(body) == NODE_FBODY) {
+ *klassp = body->nd_orig;
+ *idp = body->nd_mid;
+ body = body->nd_head;
+ }
+ else {
+ *klassp = origin;
+ }
+ }
+
+ return body;
+}
+
+NODE*
+rb_method_node(klass, id)
+ VALUE klass;
+ ID id;
+{
+ int noex;
+
+ return rb_get_method_body(&klass, &id, &noex);
+}
+
+static void
+remove_method(klass, mid)
+ VALUE klass;
+ ID mid;
+{
+ st_data_t data;
+ NODE *body = 0;
+
+ if (klass == rb_cObject) {
+ rb_secure(4);
+ }
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(klass)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't remove method");
+ }
+ if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
+ if (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 (!body || !body->nd_body) body = 0;
+ else {
+ st_delete(RCLASS(klass)->m_tbl, &mid, &data);
+ }
+ }
+ if (!body) {
+ rb_name_error(mid, "method `%s' not defined in %s",
+ rb_id2name(mid), rb_class2name(klass));
+ }
+ rb_clear_cache_for_undef(klass, mid);
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1, ID2SYM(mid));
+ }
+ else {
+ rb_funcall(klass, removed, 1, ID2SYM(mid));
+ }
+}
+
+void
+rb_remove_method(klass, name)
+ VALUE klass;
+ const char *name;
+{
+ remove_method(klass, rb_intern(name));
+}
+
+/*
+ * call-seq:
+ * remove_method(symbol) => self
+ *
+ * Removes the method identified by _symbol_ from the current
+ * class. For an example, see <code>Module.undef_method</code>.
+ */
+
+static VALUE
+rb_mod_remove_method(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ int i;
+
+ for (i=0; i<argc; i++) {
+ remove_method(mod, rb_to_id(argv[i]));
+ }
+ return mod;
+}
+
+#undef rb_disable_super
+#undef rb_enable_super
+
+void
+rb_disable_super(klass, name)
+ VALUE klass;
+ const char *name;
+{
+ /* obsolete - no use */
+}
+
+void
+rb_enable_super(klass, name)
+ VALUE klass;
+ const char *name;
+{
+ rb_warn("rb_enable_super() is obsolete");
+}
+
+static void
+rb_export_method(klass, name, noex)
+ VALUE klass;
+ ID name;
+ ID noex;
+{
+ NODE *body;
+ VALUE origin;
+
+ if (klass == rb_cObject) {
+ rb_secure(4);
+ }
+ body = search_method(klass, name, &origin);
+ if (!body && TYPE(klass) == T_MODULE) {
+ body = search_method(rb_cObject, name, &origin);
+ }
+ if (!body || !body->nd_body) {
+ print_undef(klass, name);
+ }
+ if (body->nd_noex != noex) {
+ if (klass == origin) {
+ body->nd_noex = noex;
+ }
+ else {
+ rb_add_method(klass, name, NEW_ZSUPER(), noex);
+ }
+ }
+}
+
+int
+rb_method_boundp(klass, id, ex)
+ VALUE klass;
+ ID id;
+ int ex;
+{
+ struct cache_entry *ent;
+ int noex;
+
+ /* is it in the method cache? */
+ ent = cache + EXPR1(klass, id);
+ if (ent->mid == id && ent->klass == klass) {
+ if (ex && (ent->noex & NOEX_PRIVATE))
+ return Qfalse;
+ if (!ent->method) return Qfalse;
+ return Qtrue;
+ }
+ if (rb_get_method_body(&klass, &id, &noex)) {
+ if (ex && (noex & NOEX_PRIVATE))
+ return Qfalse;
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+void
+rb_attr(klass, id, read, write, ex)
+ VALUE klass;
+ ID id;
+ int read, write, ex;
+{
+ const char *name;
+ char *buf;
+ ID attriv;
+ int noex;
+ size_t len;
+
+ if (!ex) noex = NOEX_PUBLIC;
+ else {
+ if (SCOPE_TEST(SCOPE_PRIVATE)) {
+ noex = NOEX_PRIVATE;
+ rb_warning((scope_vmode == SCOPE_MODFUNC) ?
+ "attribute accessor as module_function" :
+ "private attribute?");
+ }
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
+ else {
+ noex = NOEX_PUBLIC;
+ }
+ }
+
+ if (!rb_is_local_id(id) && !rb_is_const_id(id)) {
+ rb_name_error(id, "invalid attribute name `%s'", rb_id2name(id));
+ }
+ name = rb_id2name(id);
+ if (!name) {
+ rb_raise(rb_eArgError, "argument needs to be symbol or string");
+ }
+ len = strlen(name)+2;
+ buf = ALLOCA_N(char,len);
+ snprintf(buf, len, "@%s", name);
+ attriv = rb_intern(buf);
+ if (read) {
+ rb_add_method(klass, id, NEW_IVAR(attriv), noex);
+ }
+ if (write) {
+ rb_add_method(klass, rb_id_attrset(id), NEW_ATTRSET(attriv), noex);
+ }
+}
+
+extern int ruby_in_compile;
+
+VALUE ruby_errinfo = Qnil;
+extern NODE *ruby_eval_tree_begin;
+extern NODE *ruby_eval_tree;
+extern int ruby_nerrs;
VALUE rb_eLocalJumpError;
VALUE rb_eSysStackError;
-VALUE sysstack_error;
-static VALUE exception_error;
+extern VALUE ruby_top_self;
+
+struct FRAME *ruby_frame;
+struct SCOPE *ruby_scope;
+static struct FRAME *top_frame;
+static struct SCOPE *top_scope;
+
+static unsigned long frame_unique = 0;
+
+#define PUSH_FRAME() do { \
+ volatile struct FRAME _frame; \
+ _frame.prev = ruby_frame; \
+ _frame.tmp = 0; \
+ _frame.node = ruby_current_node; \
+ _frame.iter = ruby_iter->iter; \
+ _frame.argc = 0; \
+ _frame.flags = 0; \
+ _frame.uniq = frame_unique++; \
+ ruby_frame = &_frame
+
+#define POP_FRAME() \
+ ruby_current_node = _frame.node; \
+ ruby_frame = _frame.prev; \
+} while (0)
+
+struct BLOCK {
+ NODE *var;
+ NODE *body;
+ VALUE self;
+ struct FRAME frame;
+ struct SCOPE *scope;
+ VALUE klass;
+ NODE *cref;
+ int iter;
+ int vmode;
+ int flags;
+ int uniq;
+ struct RVarmap *dyna_vars;
+ VALUE orig_thread;
+ VALUE wrapper;
+ VALUE block_obj;
+ struct BLOCK *outer;
+ struct BLOCK *prev;
+};
-static VALUE eval(VALUE, VALUE, VALUE, const char *, int);
+#define BLOCK_D_SCOPE 1
+#define BLOCK_LAMBDA 2
+
+static struct BLOCK *ruby_block;
+static unsigned long block_unique = 1;
+
+#define PUSH_BLOCK(v,b) do { \
+ struct BLOCK _block; \
+ _block.var = (v); \
+ _block.body = (b); \
+ _block.self = self; \
+ _block.frame = *ruby_frame; \
+ _block.klass = ruby_class; \
+ _block.cref = ruby_cref; \
+ _block.frame.node = ruby_current_node;\
+ _block.scope = ruby_scope; \
+ _block.prev = ruby_block; \
+ _block.outer = ruby_block; \
+ _block.iter = ruby_iter->iter; \
+ _block.vmode = scope_vmode; \
+ _block.flags = BLOCK_D_SCOPE; \
+ _block.dyna_vars = ruby_dyna_vars; \
+ _block.wrapper = ruby_wrapper; \
+ _block.block_obj = 0; \
+ _block.uniq = (b)?block_unique++:0; \
+ if (b) { \
+ prot_tag->blkid = _block.uniq; \
+ } \
+ ruby_block = &_block
+
+#define POP_BLOCK() \
+ ruby_block = _block.prev; \
+} while (0)
+
+struct RVarmap *ruby_dyna_vars;
+#define PUSH_VARS() do { \
+ struct RVarmap * volatile _old; \
+ _old = ruby_dyna_vars; \
+ ruby_dyna_vars = 0
+
+#define POP_VARS() \
+ if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) {\
+ if (RBASIC(_old)->flags) /* unless it's already recycled */ \
+ FL_SET(_old, DVAR_DONT_RECYCLE); \
+ }\
+ ruby_dyna_vars = _old; \
+} while (0)
+
+#define DVAR_DONT_RECYCLE FL_USER2
+
+#define DMETHOD_P() (ruby_frame->flags & FRAME_DMETH)
+
+static struct RVarmap*
+new_dvar(id, value, prev)
+ ID id;
+ VALUE value;
+ struct RVarmap *prev;
+{
+ NEWOBJ(vars, struct RVarmap);
+ OBJSETUP(vars, 0, T_VARMAP);
+ vars->id = id;
+ vars->val = value;
+ vars->next = prev;
-static inline VALUE rb_yield_0(int argc, VALUE *argv);
-static VALUE rb_call(VALUE, VALUE, ID, int, const VALUE *, int);
+ return vars;
+}
+
+VALUE
+rb_dvar_defined(id)
+ ID id;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
+
+ while (vars) {
+ if (vars->id == id) return Qtrue;
+ vars = vars->next;
+ }
+ return Qfalse;
+}
+
+VALUE
+rb_dvar_curr(id)
+ ID id;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
+
+ while (vars) {
+ if (vars->id == 0) break;
+ if (vars->id == id) return Qtrue;
+ vars = vars->next;
+ }
+ return Qfalse;
+}
-#include "eval_error.c"
-#include "eval_method.c"
-#include "eval_safe.c"
-#include "eval_jump.c"
+VALUE
+rb_dvar_ref(id)
+ ID id;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
-/* initialize ruby */
+ while (vars) {
+ if (vars->id == id) {
+ return vars->val;
+ }
+ vars = vars->next;
+ }
+ return Qnil;
+}
+
+void
+rb_dvar_push(id, value)
+ ID id;
+ VALUE value;
+{
+ ruby_dyna_vars = new_dvar(id, value, ruby_dyna_vars);
+}
+
+static void
+dvar_asgn_internal(id, value, curr)
+ ID id;
+ VALUE value;
+ int curr;
+{
+ int n = 0;
+ struct RVarmap *vars = ruby_dyna_vars;
+
+ while (vars) {
+ if (curr && vars->id == 0) {
+ /* first null is a dvar header */
+ n++;
+ if (n == 2) break;
+ }
+ if (vars->id == id) {
+ vars->val = value;
+ return;
+ }
+ vars = vars->next;
+ }
+ if (!ruby_dyna_vars) {
+ ruby_dyna_vars = new_dvar(id, value, 0);
+ }
+ else {
+ vars = new_dvar(id, value, ruby_dyna_vars->next);
+ ruby_dyna_vars->next = vars;
+ }
+}
+
+static inline void
+dvar_asgn(id, value)
+ ID id;
+ VALUE value;
+{
+ dvar_asgn_internal(id, value, 0);
+}
+
+static inline void
+dvar_asgn_curr(id, value)
+ ID id;
+ VALUE value;
+{
+ dvar_asgn_internal(id, value, 1);
+}
+
+VALUE *
+rb_svar(cnt)
+ int cnt;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
+ ID id;
+
+ if (!ruby_scope->local_tbl) return NULL;
+ if (cnt >= ruby_scope->local_tbl[0]) return NULL;
+ id = ruby_scope->local_tbl[cnt+1];
+ while (vars) {
+ if (vars->id == id) return &vars->val;
+ vars = vars->next;
+ }
+ if (ruby_scope->local_vars == 0) return NULL;
+ return &ruby_scope->local_vars[cnt];
+}
+
+struct iter {
+ int iter;
+ struct iter *prev;
+};
+static struct iter *ruby_iter;
+
+#define ITER_NOT 0
+#define ITER_PRE 1
+#define ITER_CUR 2
+#define ITER_PAS 3
+
+#define PUSH_ITER(i) do { \
+ struct iter _iter; \
+ _iter.prev = ruby_iter; \
+ _iter.iter = (i); \
+ ruby_iter = &_iter
+
+#define POP_ITER() \
+ ruby_iter = _iter.prev; \
+} while (0)
+
+struct tag {
+ rb_jmpbuf_t buf;
+ struct FRAME *frame;
+ struct iter *iter;
+ VALUE tag;
+ VALUE retval;
+ struct SCOPE *scope;
+ VALUE dst;
+ struct tag *prev;
+ int blkid;
+};
+static struct tag *prot_tag;
+
+#define PUSH_TAG(ptag) do { \
+ struct tag _tag; \
+ _tag.retval = Qnil; \
+ _tag.frame = ruby_frame; \
+ _tag.iter = ruby_iter; \
+ _tag.prev = prot_tag; \
+ _tag.scope = ruby_scope; \
+ _tag.tag = ptag; \
+ _tag.dst = 0; \
+ _tag.blkid = 0; \
+ prot_tag = &_tag
+
+#define PROT_NONE Qfalse /* 0 */
+#define PROT_THREAD Qtrue /* 2 */
+#define PROT_FUNC INT2FIX(0) /* 1 */
+#define PROT_LOOP INT2FIX(1) /* 3 */
+#define PROT_LAMBDA INT2FIX(2) /* 5 */
+#define PROT_YIELD INT2FIX(3) /* 7 */
+
+#define EXEC_TAG() ruby_setjmp(((void)0), prot_tag->buf)
+
+#define JUMP_TAG(st) do { \
+ ruby_frame = prot_tag->frame; \
+ ruby_iter = prot_tag->iter; \
+ ruby_longjmp(prot_tag->buf,(st)); \
+} while (0)
+
+#define POP_TAG() \
+ prot_tag = _tag.prev; \
+} while (0)
+
+#define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq)
+
+#define TAG_RETURN 0x1
+#define TAG_BREAK 0x2
+#define TAG_NEXT 0x3
+#define TAG_RETRY 0x4
+#define TAG_REDO 0x5
+#define TAG_RAISE 0x6
+#define TAG_THROW 0x7
+#define TAG_FATAL 0x8
+#define TAG_MASK 0xf
+
+VALUE ruby_class;
+static VALUE ruby_wrapper; /* security wrapper */
+
+#define PUSH_CLASS(c) do { \
+ volatile 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_NODE(NODE_CREF,(c),0,ruby_cref)
+#define POP_CREF() ruby_cref = ruby_cref->nd_next
+
+#define PUSH_SCOPE() do { \
+ volatile int _vmode = scope_vmode; \
+ struct SCOPE * volatile _old; \
+ NEWOBJ(_scope, struct SCOPE); \
+ OBJSETUP(_scope, 0, T_SCOPE); \
+ _scope->local_tbl = 0; \
+ _scope->local_vars = 0; \
+ _scope->flags = 0; \
+ _old = ruby_scope; \
+ 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
+
+static void scope_dup _((struct SCOPE *));
+
+#define POP_SCOPE() \
+ if (ruby_scope->flags & SCOPE_DONT_RECYCLE) {\
+ if (_old) scope_dup(_old); \
+ } \
+ if (!(ruby_scope->flags & SCOPE_MALLOC)) {\
+ ruby_scope->local_vars = 0; \
+ ruby_scope->local_tbl = 0; \
+ if (!(ruby_scope->flags & SCOPE_DONT_RECYCLE) && \
+ ruby_scope != top_scope) { \
+ rb_gc_force_recycle((VALUE)ruby_scope);\
+ } \
+ } \
+ ruby_scope->flags |= SCOPE_NOSTACK; \
+ ruby_scope = _old; \
+ scope_vmode = _vmode; \
+} while (0)
+
+static VALUE rb_eval _((VALUE,NODE*));
+static VALUE eval _((VALUE,VALUE,VALUE,const char*,int));
+static NODE *compile _((VALUE, const char*, int));
+
+static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
+
+#define YIELD_LAMBDA_CALL 1
+#define YIELD_PROC_CALL 2
+#define YIELD_PUBLIC_DEF 4
+#define YIELD_FUNC_AVALUE 1
+#define YIELD_FUNC_SVALUE 2
+#define YIELD_FUNC_LAMBDA 3
+
+static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int,VALUE));
+static VALUE module_setup _((VALUE,NODE*));
+
+static VALUE massign _((VALUE,NODE*,VALUE,int));
+static void assign _((VALUE,NODE*,VALUE,int));
+
+typedef struct event_hook {
+ rb_event_hook_func_t func;
+ rb_event_t events;
+ struct event_hook *next;
+} rb_event_hook_t;
+
+static rb_event_hook_t *event_hooks;
+
+#define EXEC_EVENT_HOOK(event, node, self, id, klass) \
+ do { \
+ rb_event_hook_t *hook = event_hooks; \
+ rb_event_hook_func_t hook_func; \
+ rb_event_t events; \
+ \
+ while (hook) { \
+ hook_func = hook->func; \
+ events = hook->events; \
+ hook = hook->next; \
+ if (events & event) \
+ (*hook_func)(event, node, self, id, klass); \
+ } \
+ } while (0)
+
+static VALUE trace_func = 0;
+static int tracing = 0;
+static void call_trace_func _((rb_event_t,NODE*,VALUE,ID,VALUE));
+
+#if 0
+#define SET_CURRENT_SOURCE() (ruby_sourcefile = ruby_current_node->nd_file, \
+ ruby_sourceline = nd_line(ruby_current_node))
+#else
+#define SET_CURRENT_SOURCE() ((void)0)
+#endif
+
+void
+ruby_set_current_source()
+{
+ if (ruby_current_node) {
+ ruby_sourcefile = ruby_current_node->nd_file;
+ ruby_sourceline = nd_line(ruby_current_node);
+ }
+}
+
+static void
+#ifdef HAVE_STDARG_PROTOTYPES
+warn_printf(const char *fmt, ...)
+#else
+warn_printf(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
+{
+ char buf[BUFSIZ];
+ va_list args;
+
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+ rb_write_error(buf);
+}
+
+#define warn_print(x) rb_write_error(x)
+#define warn_print2(x,l) rb_write_error2(x,l)
+
+static void
+error_pos()
+{
+ ruby_set_current_source();
+ if (ruby_sourcefile) {
+ if (ruby_frame->last_func) {
+ warn_printf("%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
+ rb_id2name(ruby_frame->orig_func));
+ }
+ else if (ruby_sourceline == 0) {
+ warn_printf("%s", ruby_sourcefile);
+ }
+ else {
+ warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
+ }
+ }
+}
+
+VALUE rb_check_backtrace(VALUE);
+
+static VALUE
+get_backtrace(info)
+ VALUE info;
+{
+ if (NIL_P(info)) return Qnil;
+ info = rb_funcall(info, rb_intern("backtrace"), 0);
+ if (NIL_P(info)) return Qnil;
+ return rb_check_backtrace(info);
+}
+
+static void
+set_backtrace(info, bt)
+ VALUE info, bt;
+{
+ rb_funcall(info, rb_intern("set_backtrace"), 1, bt);
+}
+
+static void
+error_print()
+{
+ VALUE errat = Qnil; /* OK */
+ volatile VALUE eclass, e;
+ const char *einfo;
+ long elen;
+
+ if (NIL_P(ruby_errinfo)) return;
+
+ PUSH_TAG(PROT_NONE);
+ if (EXEC_TAG() == 0) {
+ errat = get_backtrace(ruby_errinfo);
+ }
+ else {
+ errat = Qnil;
+ }
+ if (EXEC_TAG()) goto error;
+ if (NIL_P(errat)){
+ ruby_set_current_source();
+ if (ruby_sourcefile)
+ warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
+ else
+ warn_printf("%d", ruby_sourceline);
+ }
+ else if (RARRAY(errat)->len == 0) {
+ error_pos();
+ }
+ else {
+ VALUE mesg = RARRAY(errat)->ptr[0];
+
+ if (NIL_P(mesg)) error_pos();
+ else {
+ warn_print2(RSTRING(mesg)->ptr, RSTRING(mesg)->len);
+ }
+ }
+
+ eclass = CLASS_OF(ruby_errinfo);
+ if (EXEC_TAG() == 0) {
+ e = rb_funcall(ruby_errinfo, rb_intern("message"), 0, 0);
+ StringValue(e);
+ einfo = RSTRING(e)->ptr;
+ elen = RSTRING(e)->len;
+ }
+ else {
+ einfo = "";
+ elen = 0;
+ }
+ if (EXEC_TAG()) goto error;
+ if (eclass == rb_eRuntimeError && elen == 0) {
+ warn_print(": unhandled exception\n");
+ }
+ else {
+ VALUE epath;
+
+ epath = rb_class_name(eclass);
+ if (elen == 0) {
+ warn_print(": ");
+ warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
+ warn_print("\n");
+ }
+ else {
+ char *tail = 0;
+ long len = elen;
+
+ if (RSTRING(epath)->ptr[0] == '#') epath = 0;
+ if ((tail = memchr(einfo, '\n', elen)) != 0) {
+ len = tail - einfo;
+ tail++; /* skip newline */
+ }
+ warn_print(": ");
+ warn_print2(einfo, len);
+ if (epath) {
+ warn_print(" (");
+ warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
+ warn_print(")\n");
+ }
+ if (tail && elen>len+1) {
+ warn_print2(tail, elen-len-1);
+ if (einfo[elen-1] != '\n') warn_print2("\n", 1);
+ }
+ }
+ }
+
+ 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
+#define TRACE_TAIL 5
+
+ ep = RARRAY(errat);
+ for (i=1; i<ep->len; i++) {
+ 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) {
+ warn_printf("\t ... %ld levels...\n",
+ ep->len - TRACE_HEAD - TRACE_TAIL);
+ i = ep->len - TRACE_TAIL;
+ }
+ }
+ }
+ error:
+ POP_TAG();
+}
#if defined(__APPLE__)
#define environ (*_NSGetEnviron())
@@ -52,24 +1340,45 @@ extern char **environ;
#endif
char **rb_origenviron;
-void rb_clear_trace_func(void);
-void rb_thread_stop_timer_thread(void);
+void rb_call_inits _((void));
+void Init_stack _((VALUE*));
+void Init_heap _((void));
+void Init_ext _((void));
-void rb_call_inits(void);
-void Init_stack(VALUE *);
-void Init_heap(void);
-void Init_ext(void);
-void Init_BareVM(void);
+#ifdef HAVE_NATIVETHREAD
+static rb_nativethread_t ruby_thid;
+int
+is_ruby_native_thread() {
+ return NATIVETHREAD_EQUAL(ruby_thid, NATIVETHREAD_CURRENT());
+}
+# ifdef HAVE_NATIVETHREAD_KILL
void
-ruby_init(void)
+ruby_native_thread_kill(sig)
+ int sig;
+{
+ NATIVETHREAD_KILL(ruby_thid, sig);
+}
+# endif
+#endif
+
+void
+ruby_init()
{
static int initialized = 0;
+ static struct FRAME frame;
+ static struct iter iter;
int state;
if (initialized)
return;
initialized = 1;
+#ifdef HAVE_NATIVETHREAD
+ ruby_thid = NATIVETHREAD_CURRENT();
+#endif
+
+ ruby_frame = top_frame = &frame;
+ ruby_iter = &iter;
#ifdef __MACOS__
rb_origenviron = 0;
@@ -77,59 +1386,167 @@ ruby_init(void)
rb_origenviron = environ;
#endif
- Init_stack((void *)&state);
- Init_BareVM();
+ Init_stack((void*)&state);
Init_heap();
-
- PUSH_TAG();
+ PUSH_SCOPE();
+ ruby_scope->local_vars = 0;
+ ruby_scope->local_tbl = 0;
+ top_scope = ruby_scope;
+ /* default visibility is private at toplevel */
+ SCOPE_SET(SCOPE_PRIVATE);
+
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
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;
+ rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
#ifdef __MACOS__
_macruby_init();
#elif defined(__VMS)
_vmsruby_init();
#endif
-
ruby_prog_init();
ALLOW_INTS;
}
POP_TAG();
-
if (state) {
error_print();
exit(EXIT_FAILURE);
}
+ POP_SCOPE();
+ ruby_scope = top_scope;
+ top_scope->flags &= ~SCOPE_NOSTACK;
ruby_running = 1;
}
-extern void rb_clear_trace_func(void);
+static VALUE
+eval_node(self, node)
+ VALUE self;
+ NODE *node;
+{
+ NODE *beg_tree = ruby_eval_tree_begin;
+
+ ruby_eval_tree_begin = 0;
+ if (beg_tree) {
+ rb_eval(self, beg_tree);
+ }
+
+ if (!node) return Qnil;
+ return rb_eval(self, node);
+}
+
+int ruby_in_eval;
+
+static void rb_thread_cleanup _((void));
+static void rb_thread_wait_other_threads _((void));
-void *
-ruby_options(int argc, char **argv)
+static int thread_no_ensure _((void));
+
+static VALUE exception_error;
+static VALUE sysstack_error;
+
+static int
+sysexit_status(err)
+ VALUE err;
+{
+ VALUE st = rb_iv_get(err, "status");
+ return NUM2INT(st);
+}
+
+static int
+error_handle(ex)
+ int ex;
+{
+ int status = EXIT_FAILURE;
+ rb_thread_t th = curr_thread;
+
+ if (rb_thread_set_raised(th))
+ return EXIT_FAILURE;
+ switch (ex & TAG_MASK) {
+ case 0:
+ status = EXIT_SUCCESS;
+ break;
+
+ case TAG_RETURN:
+ error_pos();
+ warn_print(": unexpected return\n");
+ break;
+ case TAG_NEXT:
+ error_pos();
+ warn_print(": unexpected next\n");
+ break;
+ case TAG_BREAK:
+ error_pos();
+ warn_print(": unexpected break\n");
+ break;
+ case TAG_REDO:
+ error_pos();
+ warn_print(": unexpected redo\n");
+ break;
+ case TAG_RETRY:
+ error_pos();
+ warn_print(": retry outside of rescue clause\n");
+ break;
+ case TAG_THROW:
+ if (prot_tag && prot_tag->frame && prot_tag->frame->node) {
+ NODE *tag = prot_tag->frame->node;
+ warn_printf("%s:%d: uncaught throw\n",
+ tag->nd_file, nd_line(tag));
+ }
+ else {
+ error_pos();
+ warn_printf(": unexpected throw\n");
+ }
+ break;
+ case TAG_RAISE:
+ case TAG_FATAL:
+ if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
+ 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();
+ }
+ break;
+ default:
+ rb_bug("Unknown longjmp status %d", ex);
+ break;
+ }
+ rb_thread_reset_raised(th);
+ return status;
+}
+
+void
+ruby_options(argc, argv)
+ int argc;
+ char **argv;
{
int state;
- void *tree = 0;
- Init_stack((void *)&state);
- PUSH_TAG();
+ Init_stack((void*)&state);
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- SAVE_ROOT_JMPBUF(GET_THREAD(), tree = ruby_process_options(argc, argv));
+ ruby_process_options(argc, argv);
}
else {
- rb_clear_trace_func();
- state = error_handle(state);
- tree = (void *)INT2FIX(state);
+ trace_func = 0;
+ tracing = 0;
+ exit(error_handle(state));
}
POP_TAG();
- return tree;
}
+void rb_exec_end_proc _((void));
+
static void
-ruby_finalize_0(void)
+ruby_finalize_0()
{
- rb_clear_trace_func();
- PUSH_TAG();
+ PUSH_TAG(PROT_NONE);
if (EXEC_TAG() == 0) {
rb_trap_exit();
}
@@ -138,56 +1555,55 @@ ruby_finalize_0(void)
}
static void
-ruby_finalize_1(void)
+ruby_finalize_1()
{
- ruby_sig_finalize();
- GET_THREAD()->errinfo = Qnil;
+ signal(SIGINT, SIG_DFL);
+ ruby_errinfo = 0;
rb_gc_call_finalizer_at_exit();
+ trace_func = 0;
+ tracing = 0;
}
void
-ruby_finalize(void)
+ruby_finalize()
{
ruby_finalize_0();
ruby_finalize_1();
}
-void rb_thread_stop_timer_thread(void);
-
int
-ruby_cleanup(int ex)
+ruby_cleanup(ex)
+ int ex;
{
int state;
volatile VALUE errs[2];
- rb_thread_t *th = GET_THREAD();
int nerr;
- errs[1] = th->errinfo;
- th->safe_level = 0;
+ errs[1] = ruby_errinfo;
+ ruby_safe_level = 0;
Init_stack((void *)&state);
ruby_finalize_0();
- errs[0] = th->errinfo;
- PUSH_TAG();
+ errs[0] = ruby_errinfo;
+ PUSH_TAG(PROT_NONE);
+ PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
- SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
+ rb_thread_cleanup();
+ rb_thread_wait_other_threads();
}
else if (ex == 0) {
ex = state;
}
- th->errinfo = errs[1];
+ POP_ITER();
+ ruby_errinfo = errs[1];
ex = error_handle(ex);
ruby_finalize_1();
POP_TAG();
- rb_thread_stop_timer_thread();
for (nerr = 0; nerr < sizeof(errs) / sizeof(errs[0]); ++nerr) {
VALUE err = errs[nerr];
if (!RTEST(err)) continue;
- /* th->errinfo contains a NODE while break'ing */
- if (TYPE(err) == T_NODE) continue;
-
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
return sysexit_status(err);
}
@@ -214,81 +1630,120 @@ ruby_cleanup(int ex)
return ex;
}
-int
-ruby_exec_node(void *n, char *file)
+static int
+ruby_exec_internal()
{
int state;
- VALUE val;
- NODE *node = n;
- rb_thread_t *th = GET_THREAD();
- if (!node) return 0;
-
- PUSH_TAG();
+ PUSH_TAG(PROT_NONE);
+ PUSH_ITER(ITER_NOT);
+ /* default visibility is private at toplevel */
+ SCOPE_SET(SCOPE_PRIVATE);
if ((state = EXEC_TAG()) == 0) {
- SAVE_ROOT_JMPBUF(th, {
- VALUE iseq = rb_iseq_new(n, rb_str_new2("<main>"),
- rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP);
- th->base_block = 0;
- val = rb_iseq_eval(iseq);
- });
+ eval_node(ruby_top_self, ruby_eval_tree);
}
+ POP_ITER();
POP_TAG();
return state;
}
void
-ruby_stop(int ex)
+ruby_stop(ex)
+ int ex;
{
exit(ruby_cleanup(ex));
}
int
-ruby_run_node(void *n)
+ruby_exec()
{
- NODE *node = (NODE *)n;
+ volatile NODE *tmp;
- switch ((VALUE)n) {
- case Qtrue: return EXIT_SUCCESS;
- case Qfalse: return EXIT_FAILURE;
+ Init_stack((void*)&tmp);
+ return ruby_exec_internal();
+}
+
+void
+ruby_run()
+{
+ int state;
+ static int ex;
+
+ if (ruby_nerrs > 0) exit(EXIT_FAILURE);
+ state = ruby_exec();
+ if (state && !ex) ex = state;
+ ruby_stop(ex);
+}
+
+static void
+compile_error(at)
+ const char *at;
+{
+ VALUE str;
+
+ ruby_nerrs = 0;
+ str = rb_str_buf_new2("compile error");
+ if (at) {
+ rb_str_buf_cat2(str, " in ");
+ rb_str_buf_cat2(str, at);
}
- if (FIXNUM_P((VALUE)n)) {
- return FIX2INT((VALUE)n);
+ rb_str_buf_cat(str, "\n", 1);
+ if (!NIL_P(ruby_errinfo)) {
+ rb_str_append(str, rb_obj_as_string(ruby_errinfo));
}
- Init_stack((void *)&n);
- return ruby_cleanup(ruby_exec_node(node, node->nd_file));
+ rb_exc_raise(rb_exc_new3(rb_eSyntaxError, str));
}
VALUE
-rb_eval_string(const char *str)
+rb_eval_string(str)
+ const char *str;
{
- return eval(rb_vm_top_self(), rb_str_new2(str), Qnil, "(eval)", 1);
+ VALUE v;
+ NODE *oldsrc = ruby_current_node;
+
+ ruby_current_node = 0;
+ ruby_sourcefile = rb_source_filename("(eval)");
+ v = eval(ruby_top_self, rb_str_new2(str), Qnil, 0, 0);
+ ruby_current_node = oldsrc;
+
+ return v;
}
VALUE
-rb_eval_string_protect(const char *str, int *state)
+rb_eval_string_protect(str, state)
+ const char *str;
+ int *state;
{
- return rb_protect((VALUE (*)(VALUE))rb_eval_string, (VALUE)str, state);
+ return rb_protect((VALUE (*)_((VALUE)))rb_eval_string, (VALUE)str, state);
}
VALUE
-rb_eval_string_wrap(const char *str, int *state)
+rb_eval_string_wrap(str, state)
+ const char *str;
+ int *state;
{
int status;
- rb_thread_t *th = GET_THREAD();
- VALUE self = th->top_self;
- VALUE wrapper = th->top_wrapper;
+ VALUE self = ruby_top_self;
+ VALUE wrapper = ruby_wrapper;
VALUE val;
- th->top_wrapper = rb_module_new();
- th->top_self = rb_obj_clone(rb_vm_top_self());
- rb_extend_object(th->top_self, th->top_wrapper);
+ PUSH_CLASS(ruby_wrapper = rb_module_new());
+ ruby_top_self = rb_obj_clone(ruby_top_self);
+ rb_extend_object(ruby_top_self, ruby_wrapper);
+ PUSH_FRAME();
+ ruby_frame->last_func = 0;
+ ruby_frame->last_class = 0;
+ ruby_frame->self = self;
+ PUSH_CREF(ruby_wrapper);
+ PUSH_SCOPE();
val = rb_eval_string_protect(str, &status);
+ ruby_top_self = self;
- th->top_self = self;
- th->top_wrapper = wrapper;
-
+ POP_SCOPE();
+ POP_FRAME();
+ POP_CLASS();
+ ruby_wrapper = wrapper;
if (state) {
*state = status;
}
@@ -298,50 +1753,224 @@ rb_eval_string_wrap(const char *str, int *state)
return val;
}
+NORETURN(static void localjump_error(const char*, VALUE, int));
+static void
+localjump_error(mesg, value, reason)
+ const char *mesg;
+ VALUE value;
+ int reason;
+{
+ VALUE exc = rb_exc_new2(rb_eLocalJumpError, mesg);
+ ID id;
+
+ rb_iv_set(exc, "@exit_value", value);
+ switch (reason) {
+ case TAG_BREAK:
+ id = rb_intern("break"); break;
+ case TAG_REDO:
+ id = rb_intern("redo"); break;
+ case TAG_RETRY:
+ id = rb_intern("retry"); break;
+ case TAG_NEXT:
+ id = rb_intern("next"); break;
+ case TAG_RETURN:
+ id = rb_intern("return"); break;
+ default:
+ id = rb_intern("noreason"); break;
+ }
+ rb_iv_set(exc, "@reason", ID2SYM(id));
+ rb_exc_raise(exc);
+}
+
+/*
+ * call_seq:
+ * local_jump_error.exit_value => obj
+ *
+ * Returns the exit value associated with this +LocalJumpError+.
+ */
+static VALUE
+localjump_xvalue(exc)
+ VALUE exc;
+{
+ return rb_iv_get(exc, "@exit_value");
+}
+
+/*
+ * call-seq:
+ * local_jump_error.reason => symbol
+ *
+ * The reason this block was terminated:
+ * :break, :redo, :retry, :next, :return, or :noreason.
+ */
+
+static VALUE
+localjump_reason(exc)
+ VALUE exc;
+{
+ return rb_iv_get(exc, "@reason");
+}
+
+NORETURN(static void jump_tag_but_local_jump _((int,VALUE)));
+static void
+jump_tag_but_local_jump(state, val)
+ int state;
+ VALUE val;
+{
+
+ if (val == Qundef) val = prot_tag->retval;
+ switch (state) {
+ case 0:
+ break;
+ case TAG_RETURN:
+ localjump_error("unexpected return", val, state);
+ break;
+ case TAG_BREAK:
+ localjump_error("unexpected break", val, state);
+ break;
+ case TAG_NEXT:
+ localjump_error("unexpected next", val, state);
+ break;
+ case TAG_REDO:
+ localjump_error("unexpected redo", Qnil, state);
+ break;
+ case TAG_RETRY:
+ localjump_error("retry outside of rescue clause", Qnil, state);
+ break;
+ default:
+ break;
+ }
+ JUMP_TAG(state);
+}
+
VALUE
-rb_eval_cmd(VALUE cmd, VALUE arg, int level)
+rb_eval_cmd(cmd, arg, level)
+ VALUE cmd, arg;
+ int level;
{
int state;
VALUE val = Qnil; /* OK */
- volatile int safe = rb_safe_level();
+ struct SCOPE *saved_scope;
+ volatile int safe = ruby_safe_level;
if (OBJ_TAINTED(cmd)) {
level = 4;
}
-
if (TYPE(cmd) != T_STRING) {
- PUSH_TAG();
- rb_set_safe_level_force(level);
+ PUSH_ITER(ITER_NOT);
+ PUSH_TAG(PROT_NONE);
+ ruby_safe_level = level;
if ((state = EXEC_TAG()) == 0) {
- val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LEN(arg),
- RARRAY_PTR(arg));
+ val = rb_funcall2(cmd, rb_intern("call"), RARRAY(arg)->len, RARRAY(arg)->ptr);
}
+ ruby_safe_level = safe;
POP_TAG();
-
- rb_set_safe_level_force(safe);
-
- if (state)
- JUMP_TAG(state);
+ POP_ITER();
+ if (state) JUMP_TAG(state);
return val;
}
- PUSH_TAG();
+ saved_scope = ruby_scope;
+ ruby_scope = top_scope;
+ PUSH_FRAME();
+ ruby_frame->last_func = 0;
+ ruby_frame->last_class = 0;
+ ruby_frame->self = ruby_top_self;
+ PUSH_CREF(ruby_wrapper ? ruby_wrapper : rb_cObject);
+
+ ruby_safe_level = level;
+
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- val = eval(rb_vm_top_self(), cmd, Qnil, 0, 0);
+ val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
+ if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
+ scope_dup(saved_scope);
+ ruby_scope = saved_scope;
+ ruby_safe_level = safe;
POP_TAG();
+ POP_FRAME();
- rb_set_safe_level_force(safe);
- if (state) vm_jump_tag_but_local_jump(state, val);
+ if (state) jump_tag_but_local_jump(state, val);
return val;
}
+#define ruby_cbase (ruby_cref->nd_clss)
+
+static VALUE
+ev_const_defined(cref, id, self)
+ NODE *cref;
+ ID id;
+ VALUE self;
+{
+ NODE *cbase = cref;
+ VALUE result;
+
+ while (cbase && cbase->nd_next) {
+ struct RClass *klass = RCLASS(cbase->nd_clss);
+
+ if (!NIL_P(klass)) {
+ if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
+ if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
+ return Qfalse;
+ }
+ return Qtrue;
+ }
+ }
+ cbase = cbase->nd_next;
+ }
+ return rb_const_defined(cref->nd_clss, id);
+}
+
+static VALUE
+ev_const_get(cref, id, self)
+ NODE *cref;
+ ID id;
+ VALUE self;
+{
+ NODE *cbase = cref;
+ VALUE result;
+
+ while (cbase && cbase->nd_next) {
+ VALUE klass = cbase->nd_clss;
+
+ if (!NIL_P(klass)) {
+ while (RCLASS(klass)->iv_tbl &&
+ st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
+ if (result == Qundef) {
+ if (!RTEST(rb_autoload_load(klass, id))) break;
+ continue;
+ }
+ return result;
+ }
+ }
+ cbase = cbase->nd_next;
+ }
+ return rb_const_get(NIL_P(cref->nd_clss) ? CLASS_OF(self): cref->nd_clss, id);
+}
+
+static VALUE
+cvar_cbase()
+{
+ NODE *cref = ruby_cref;
+
+ while (cref && cref->nd_next && (NIL_P(cref->nd_clss) || FL_TEST(cref->nd_clss, FL_SINGLETON))) {
+ cref = cref->nd_next;
+ if (!cref->nd_next) {
+ rb_warn("class variable access from toplevel singleton method");
+ }
+ }
+ if (NIL_P(cref->nd_clss)) {
+ rb_raise(rb_eTypeError, "no class variables available");
+ }
+ return cref->nd_clss;
+}
+
/*
* call-seq:
* Module.nesting => array
- *
+ *
* Returns the list of +Modules+ nested at the point of call.
- *
+ *
* module M1
* module M2
* $a = Module.nesting
@@ -352,17 +1981,17 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level)
*/
static VALUE
-rb_mod_nesting(void)
+rb_mod_nesting()
{
+ NODE *cbase = ruby_cref;
VALUE ary = rb_ary_new();
- NODE *cref = ruby_cref();
- while (cref && cref->nd_next) {
- VALUE klass = cref->nd_clss;
- if (!NIL_P(klass)) {
- rb_ary_push(ary, klass);
- }
- cref = cref->nd_next;
+ while (cbase && cbase->nd_next) {
+ if (!NIL_P(cbase->nd_clss)) rb_ary_push(ary, cbase->nd_clss);
+ cbase = cbase->nd_next;
+ }
+ if (ruby_wrapper && RARRAY(ary)->len == 0) {
+ rb_ary_push(ary, ruby_wrapper);
}
return ary;
}
@@ -370,50 +1999,41 @@ rb_mod_nesting(void)
/*
* call-seq:
* Module.constants => array
- *
+ *
* Returns an array of the names of all constants defined in the
* system. This list includes the names of all modules and classes.
- *
+ *
* p Module.constants.sort[1..5]
- *
+ *
* <em>produces:</em>
- *
+ *
* ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"]
*/
static VALUE
-rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
+rb_mod_s_constants()
{
- NODE *cref = ruby_cref();
- VALUE klass;
- VALUE cbase = 0;
+ NODE *cbase = ruby_cref;
void *data = 0;
- if (argc > 0) {
- return rb_mod_constants(argc, argv, rb_cModule);
- }
-
- while (cref) {
- klass = cref->nd_clss;
- if (!NIL_P(klass)) {
- data = rb_mod_const_at(cref->nd_clss, data);
- if (!cbase) {
- cbase = klass;
- }
+ while (cbase) {
+ if (!NIL_P(cbase->nd_clss)) {
+ data = rb_mod_const_at(cbase->nd_clss, data);
}
- cref = cref->nd_next;
+ cbase = cbase->nd_next;
}
- if (cbase) {
- data = rb_mod_const_of(cbase, data);
+ if (!NIL_P(ruby_cbase)) {
+ data = rb_mod_const_of(ruby_cbase, data);
}
return rb_const_list(data);
}
void
-rb_frozen_class_p(VALUE klass)
+rb_frozen_class_p(klass)
+ VALUE klass;
{
- char *desc = "something(?!)";
+ const char *desc = "something(?!)";
if (OBJ_FROZEN(klass)) {
if (FL_TEST(klass, FL_SINGLETON))
@@ -422,30 +2042,2188 @@ rb_frozen_class_p(VALUE klass)
switch (TYPE(klass)) {
case T_MODULE:
case T_ICLASS:
- desc = "module";
+ desc = "module"; break;
+ case T_CLASS:
+ desc = "class"; break;
+ }
+ }
+ rb_error_frozen(desc);
+ }
+}
+
+void
+rb_undef(klass, id)
+ VALUE klass;
+ ID id;
+{
+ VALUE origin;
+ NODE *body;
+
+ if (ruby_cbase == rb_cObject && klass == rb_cObject) {
+ rb_secure(4);
+ }
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(klass)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'", rb_id2name(id));
+ }
+ rb_frozen_class_p(klass);
+ if (id == __id__ || id == __send__ || id == init) {
+ rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
+ }
+ body = search_method(klass, id, &origin);
+ if (!body || !body->nd_body) {
+ const char *s0 = " class";
+ VALUE c = klass;
+
+ if (FL_TEST(c, FL_SINGLETON)) {
+ VALUE obj = rb_iv_get(klass, "__attached__");
+
+ switch (TYPE(obj)) {
+ case T_MODULE:
+ case T_CLASS:
+ c = obj;
+ s0 = "";
+ }
+ }
+ else if (TYPE(c) == T_MODULE) {
+ s0 = " module";
+ }
+ rb_name_error(id, "undefined method `%s' for%s `%s'",
+ rb_id2name(id),s0,rb_class2name(c));
+ }
+ rb_add_method(klass, id, 0, NOEX_PUBLIC);
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(klass, "__attached__"),
+ singleton_undefined, 1, ID2SYM(id));
+ }
+ else {
+ rb_funcall(klass, undefined, 1, ID2SYM(id));
+ }
+}
+
+/*
+ * call-seq:
+ * undef_method(symbol) => self
+ *
+ * Prevents the current class from responding to calls to the named
+ * method. Contrast this with <code>remove_method</code>, which deletes
+ * the method from the particular class; Ruby will still search
+ * superclasses and mixed-in modules for a possible receiver.
+ *
+ * class Parent
+ * def hello
+ * puts "In parent"
+ * end
+ * end
+ * class Child < Parent
+ * def hello
+ * puts "In child"
+ * end
+ * end
+ *
+ *
+ * c = Child.new
+ * c.hello
+ *
+ *
+ * class Child
+ * remove_method :hello # remove from child, still in parent
+ * end
+ * c.hello
+ *
+ *
+ * class Child
+ * undef_method :hello # prevent any calls to 'hello'
+ * end
+ * c.hello
+ *
+ * <em>produces:</em>
+ *
+ * In child
+ * In parent
+ * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
+ */
+
+static VALUE
+rb_mod_undef_method(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_undef(mod, rb_to_id(argv[i]));
+ }
+ return mod;
+}
+
+void
+rb_alias(klass, name, def)
+ VALUE klass;
+ ID name, def;
+{
+ VALUE origin = 0;
+ NODE *orig, *body, *node;
+ VALUE singleton = 0;
+ st_data_t data;
+
+ rb_frozen_class_p(klass);
+ if (name == def) return;
+ if (klass == rb_cObject) {
+ rb_secure(4);
+ }
+ orig = search_method(klass, def, &origin);
+ if (!orig || !orig->nd_body) {
+ if (TYPE(klass) == T_MODULE) {
+ orig = search_method(rb_cObject, def, &origin);
+ }
+ }
+ if (!orig || !orig->nd_body) {
+ print_undef(klass, def);
+ }
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ singleton = rb_iv_get(klass, "__attached__");
+ }
+ body = orig->nd_body;
+ orig->nd_cnt++;
+ if (nd_type(body) == NODE_FBODY) { /* was alias */
+ def = body->nd_mid;
+ origin = body->nd_orig;
+ body = body->nd_head;
+ }
+
+ rb_clear_cache_by_id(name);
+ if (RTEST(ruby_verbose) && st_lookup(RCLASS(klass)->m_tbl, name, &data)) {
+ node = (NODE *)data;
+ if (node->nd_cnt == 0 && node->nd_body) {
+ rb_warning("discarding old %s", rb_id2name(name));
+ }
+ }
+ st_insert(RCLASS(klass)->m_tbl, name,
+ (st_data_t)NEW_METHOD(NEW_FBODY(body, def, origin),
+ NOEX_WITH_SAFE(orig->nd_noex)));
+
+ if (!ruby_running) return;
+
+ if (singleton) {
+ rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
+ }
+ else {
+ rb_funcall(klass, added, 1, ID2SYM(name));
+ }
+}
+
+/*
+ * call-seq:
+ * alias_method(new_name, old_name) => self
+ *
+ * Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
+ * be used to retain access to methods that are overridden.
+ *
+ * module Mod
+ * alias_method :orig_exit, :exit
+ * def exit(code=0)
+ * puts "Exiting with code #{code}"
+ * orig_exit(code)
+ * end
+ * end
+ * include Mod
+ * exit(99)
+ *
+ * <em>produces:</em>
+ *
+ * Exiting with code 99
+ */
+
+static VALUE
+rb_mod_alias_method(mod, newname, oldname)
+ VALUE mod, newname, oldname;
+{
+ rb_alias(mod, rb_to_id(newname), rb_to_id(oldname));
+ return mod;
+}
+
+NODE *
+rb_copy_node_scope(node, rval)
+ NODE *node;
+ NODE *rval;
+{
+ NODE *copy = NEW_NODE(NODE_SCOPE,0,rval,node->nd_next);
+
+ if (node->nd_tbl) {
+ copy->nd_tbl = ALLOC_N(ID, node->nd_tbl[0]+1);
+ MEMCPY(copy->nd_tbl, node->nd_tbl, ID, node->nd_tbl[0]+1);
+ }
+ else {
+ copy->nd_tbl = 0;
+ }
+ return copy;
+}
+
+#ifdef C_ALLOCA
+# define TMP_PROTECT NODE * volatile tmp__protect_tmp=0
+# define TMP_ALLOC(n) \
+ (tmp__protect_tmp = NEW_NODE(NODE_ALLOCA, \
+ ALLOC_N(VALUE,n),tmp__protect_tmp,n), \
+ (void*)tmp__protect_tmp->nd_head)
+#else
+# define TMP_PROTECT typedef int foobazzz
+# define TMP_ALLOC(n) ALLOCA_N(VALUE,n)
+#endif
+
+#define SETUP_ARGS0(anode,extra) do {\
+ NODE *n = anode;\
+ if (!n) {\
+ argc = 0;\
+ argv = 0;\
+ }\
+ else if (nd_type(n) == NODE_ARRAY) {\
+ argc=anode->nd_alen;\
+ if (argc > 0) {\
+ int i;\
+ n = anode;\
+ argv = TMP_ALLOC(argc+extra);\
+ for (i=0;i<argc;i++) {\
+ argv[i] = rb_eval(self,n->nd_head);\
+ n=n->nd_next;\
+ }\
+ }\
+ else {\
+ argc = 0;\
+ argv = 0;\
+ }\
+ }\
+ else {\
+ VALUE args = rb_eval(self,n);\
+ if (TYPE(args) != T_ARRAY)\
+ args = rb_ary_to_ary(args);\
+ argc = RARRAY(args)->len;\
+ argv = TMP_ALLOC(argc+extra);\
+ MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);\
+ }\
+} while (0)
+
+#define SETUP_ARGS(anode) SETUP_ARGS0(anode,0)
+
+#define BEGIN_CALLARGS do {\
+ struct BLOCK *tmp_block = ruby_block;\
+ int tmp_iter = ruby_iter->iter;\
+ switch (tmp_iter) {\
+ case ITER_PRE:\
+ if (ruby_block) ruby_block = ruby_block->outer;\
+ case ITER_PAS:\
+ tmp_iter = ITER_NOT;\
+ }\
+ PUSH_ITER(tmp_iter)
+
+#define END_CALLARGS \
+ ruby_block = tmp_block;\
+ POP_ITER();\
+} while (0)
+
+#define MATCH_DATA *rb_svar(node->nd_cnt)
+
+static const char* is_defined _((VALUE, NODE*, char*));
+
+static const char*
+arg_defined(self, node, buf, type)
+ VALUE self;
+ NODE *node;
+ char *buf;
+ char *type;
+{
+ int argc;
+ int i;
+
+ if (!node) return type; /* no args */
+ if (nd_type(node) == NODE_ARRAY) {
+ argc=node->nd_alen;
+ if (argc > 0) {
+ for (i=0;i<argc;i++) {
+ if (!is_defined(self, node->nd_head, buf))
+ return 0;
+ node = node->nd_next;
+ }
+ }
+ }
+ else if (!is_defined(self, node, buf)) {
+ return 0;
+ }
+ return type;
+}
+
+static const char*
+is_defined(self, node, buf)
+ VALUE self;
+ NODE *node; /* OK */
+ char *buf;
+{
+ VALUE val; /* OK */
+ int state;
+
+ again:
+ if (!node) return "expression";
+ switch (nd_type(node)) {
+ case NODE_SUPER:
+ case NODE_ZSUPER:
+ if (ruby_frame->last_func == 0) return 0;
+ else if (ruby_frame->last_class == 0) return 0;
+ val = ruby_frame->last_class;
+ if (rb_method_boundp(RCLASS(val)->super, ruby_frame->orig_func, 0)) {
+ if (nd_type(node) == NODE_SUPER) {
+ return arg_defined(self, node->nd_args, buf, "super");
+ }
+ return "super";
+ }
+ break;
+
+ case NODE_VCALL:
+ case NODE_FCALL:
+ val = self;
+ goto check_bound;
+
+ case NODE_ATTRASGN:
+ val = self;
+ if (node->nd_recv == (NODE *)1) goto check_bound;
+ case NODE_CALL:
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ val = rb_eval(self, node->nd_recv);
+ }
+ POP_TAG();
+ if (state) {
+ ruby_errinfo = Qnil;
+ return 0;
+ }
+ check_bound:
+ {
+ int call = nd_type(node)==NODE_CALL;
+
+ val = CLASS_OF(val);
+ if (call) {
+ int noex;
+ ID id = node->nd_mid;
+
+ if (!rb_get_method_body(&val, &id, &noex))
+ break;
+ if ((noex & NOEX_PRIVATE))
+ break;
+ if ((noex & NOEX_PROTECTED) &&
+ !rb_obj_is_kind_of(self, rb_class_real(val)))
+ break;
+ }
+ else if (!rb_method_boundp(val, node->nd_mid, call))
break;
+ return arg_defined(self, node->nd_args, buf,
+ nd_type(node) == NODE_ATTRASGN ?
+ "assignment" : "method");
+ }
+ break;
+
+ case NODE_MATCH2:
+ case NODE_MATCH3:
+ return "method";
+
+ case NODE_YIELD:
+ if (rb_block_given_p()) {
+ return "yield";
+ }
+ break;
+
+ case NODE_SELF:
+ return "self";
+
+ case NODE_NIL:
+ return "nil";
+
+ case NODE_TRUE:
+ return "true";
+
+ case NODE_FALSE:
+ return "false";
+
+ case NODE_ATTRSET:
+ case NODE_OP_ASGN1:
+ case NODE_OP_ASGN2:
+ case NODE_OP_ASGN_OR:
+ case NODE_OP_ASGN_AND:
+ case NODE_MASGN:
+ case NODE_LASGN:
+ case NODE_DASGN:
+ case NODE_DASGN_CURR:
+ case NODE_GASGN:
+ case NODE_IASGN:
+ case NODE_CDECL:
+ case NODE_CVDECL:
+ case NODE_CVASGN:
+ return "assignment";
+
+ case NODE_LVAR:
+ return "local-variable";
+ case NODE_DVAR:
+ return "local-variable(in-block)";
+
+ case NODE_GVAR:
+ if (rb_gvar_defined(node->nd_entry)) {
+ return "global-variable";
+ }
+ break;
+
+ case NODE_IVAR:
+ if (rb_ivar_defined(self, node->nd_vid)) {
+ return "instance-variable";
+ }
+ break;
+
+ case NODE_CONST:
+ if (ev_const_defined(ruby_cref, node->nd_vid, self)) {
+ return "constant";
+ }
+ break;
+
+ case NODE_CVAR:
+ if (rb_cvar_defined(cvar_cbase(), node->nd_vid)) {
+ return "class variable";
+ }
+ break;
+
+ case NODE_COLON2:
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ val = rb_eval(self, node->nd_head);
+ }
+ POP_TAG();
+ if (state) {
+ ruby_errinfo = Qnil;
+ return 0;
+ }
+ else {
+ switch (TYPE(val)) {
case T_CLASS:
- desc = "class";
+ case T_MODULE:
+ if (rb_const_defined_from(val, node->nd_mid))
+ return "constant";
break;
+ default:
+ if (rb_method_boundp(CLASS_OF(val), node->nd_mid, 1)) {
+ return "method";
+ }
}
}
- rb_error_frozen(desc);
+ break;
+
+ case NODE_COLON3:
+ if (rb_const_defined_from(rb_cObject, node->nd_mid)) {
+ return "constant";
+ }
+ break;
+
+ case NODE_NTH_REF:
+ if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) {
+ sprintf(buf, "$%d", (int)node->nd_nth);
+ return buf;
+ }
+ break;
+
+ case NODE_BACK_REF:
+ if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) {
+ sprintf(buf, "$%c", (char)node->nd_nth);
+ return buf;
+ }
+ break;
+
+ case NODE_NEWLINE:
+ node = node->nd_next;
+ goto again;
+
+ default:
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ rb_eval(self, node);
+ }
+ POP_TAG();
+ if (!state) {
+ return "expression";
+ }
+ ruby_errinfo = Qnil;
+ break;
+ }
+ return 0;
+}
+
+static int handle_rescue _((VALUE,NODE*));
+
+static void blk_free();
+
+static VALUE
+rb_obj_is_proc(proc)
+ VALUE proc;
+{
+ if (TYPE(proc) == T_DATA && RDATA(proc)->dfree == (RUBY_DATA_FUNC)blk_free) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+void
+rb_add_event_hook(func, events)
+ rb_event_hook_func_t func;
+ rb_event_t events;
+{
+ rb_event_hook_t *hook;
+
+ hook = ALLOC(rb_event_hook_t);
+ hook->func = func;
+ hook->events = events;
+ hook->next = event_hooks;
+ event_hooks = hook;
+}
+
+int
+rb_remove_event_hook(func)
+ rb_event_hook_func_t func;
+{
+ rb_event_hook_t *prev, *hook;
+
+ prev = NULL;
+ hook = event_hooks;
+ while (hook) {
+ if (hook->func == func) {
+ if (prev) {
+ prev->next = hook->next;
+ }
+ else {
+ event_hooks = hook->next;
+ }
+ xfree(hook);
+ return 0;
+ }
+ prev = hook;
+ hook = hook->next;
}
+ return -1;
}
/*
* call-seq:
- * obj.respond_to?(symbol, include_private=false) => true or false
+ * set_trace_func(proc) => proc
+ * set_trace_func(nil) => nil
+ *
+ * Establishes _proc_ as the handler for tracing, or disables
+ * tracing if the parameter is +nil+. _proc_ takes up
+ * to six parameters: an event name, a filename, a line number, an
+ * object id, a binding, and the name of a class. _proc_ is
+ * invoked whenever an event occurs. Events are: <code>c-call</code>
+ * (call a C-language routine), <code>c-return</code> (return from a
+ * C-language routine), <code>call</code> (call a Ruby method),
+ * <code>class</code> (start a class or module definition),
+ * <code>end</code> (finish a class or module definition),
+ * <code>line</code> (execute code on a new line), <code>raise</code>
+ * (raise an exception), and <code>return</code> (return from a Ruby
+ * method). Tracing is disabled within the context of _proc_.
*
- * Returns +true+> if _obj_ responds to the given
- * method. Private methods are included in the search only if the
- * optional second parameter evaluates to +true+.
+ * class Test
+ * def test
+ * a = 1
+ * b = 2
+ * end
+ * end
+ *
+ * set_trace_func proc { |event, file, line, id, binding, classname|
+ * printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
+ * }
+ * t = Test.new
+ * t.test
+ *
+ * line prog.rb:11 false
+ * c-call prog.rb:11 new Class
+ * c-call prog.rb:11 initialize Object
+ * c-return prog.rb:11 initialize Object
+ * c-return prog.rb:11 new Class
+ * line prog.rb:12 false
+ * call prog.rb:2 test Test
+ * line prog.rb:3 test Test
+ * line prog.rb:4 test Test
+ * return prog.rb:4 test Test
*/
+
+static VALUE
+set_trace_func(obj, trace)
+ VALUE obj, trace;
+{
+ rb_event_hook_t *hook;
+
+ rb_secure(4);
+ if (NIL_P(trace)) {
+ trace_func = 0;
+ rb_remove_event_hook(call_trace_func);
+ return Qnil;
+ }
+ if (!rb_obj_is_proc(trace)) {
+ rb_raise(rb_eTypeError, "trace_func needs to be Proc");
+ }
+ trace_func = trace;
+ for (hook = event_hooks; hook; hook = hook->next) {
+ if (hook->func == call_trace_func)
+ return trace;
+ }
+ rb_add_event_hook(call_trace_func, RUBY_EVENT_ALL);
+ return trace;
+}
+
+static const char *
+get_event_name(rb_event_t event)
+{
+ switch (event) {
+ case RUBY_EVENT_LINE:
+ return "line";
+ case RUBY_EVENT_CLASS:
+ return "class";
+ case RUBY_EVENT_END:
+ return "end";
+ case RUBY_EVENT_CALL:
+ return "call";
+ case RUBY_EVENT_RETURN:
+ return "return";
+ case RUBY_EVENT_C_CALL:
+ return "c-call";
+ case RUBY_EVENT_C_RETURN:
+ return "c-return";
+ case RUBY_EVENT_RAISE:
+ return "raise";
+ default:
+ return "unknown";
+ }
+}
+
+static void
+call_trace_func(event, node, self, id, klass)
+ rb_event_t event;
+ NODE *node;
+ VALUE self;
+ ID id;
+ VALUE klass; /* OK */
+{
+ int state, raised;
+ struct FRAME *prev;
+ NODE *node_save;
+ VALUE srcfile;
+ const char *event_name;
+ rb_thread_t th = curr_thread;
+
+ if (!trace_func) return;
+ if (tracing) return;
+ if (ruby_in_compile) return;
+ if (id == ID_ALLOCATOR) return;
+
+ if (!(node_save = ruby_current_node)) {
+ node_save = NEW_NEWLINE(0);
+ }
+ tracing = 1;
+ prev = ruby_frame;
+ PUSH_FRAME();
+ *ruby_frame = *prev;
+ ruby_frame->prev = prev;
+ ruby_frame->iter = 0; /* blocks not available anyway */
+
+ if (node) {
+ ruby_current_node = node;
+ ruby_frame->node = node;
+ ruby_sourcefile = node->nd_file;
+ ruby_sourceline = nd_line(node);
+ }
+ if (klass) {
+ if (TYPE(klass) == T_ICLASS) {
+ klass = RBASIC(klass)->klass;
+ }
+ else if (FL_TEST(klass, FL_SINGLETON)) {
+ klass = rb_iv_get(klass, "__attached__");
+ }
+ }
+ PUSH_TAG(PROT_NONE);
+ raised = rb_thread_reset_raised(th);
+ if ((state = EXEC_TAG()) == 0) {
+ srcfile = rb_str_new2(ruby_sourcefile?ruby_sourcefile:"(ruby)");
+ event_name = get_event_name(event);
+ proc_invoke(trace_func, rb_ary_new3(6, rb_str_new2(event_name),
+ srcfile,
+ INT2FIX(ruby_sourceline),
+ id?ID2SYM(id):Qnil,
+ self?rb_f_binding(self):Qnil,
+ klass),
+ Qundef, 0);
+ }
+ if (raised) rb_thread_set_raised(th);
+ POP_TAG();
+ POP_FRAME();
+
+ tracing = 0;
+ ruby_current_node = node_save;
+ SET_CURRENT_SOURCE();
+ if (state) JUMP_TAG(state);
+}
+
+static VALUE
+avalue_to_svalue(v)
+ VALUE v;
+{
+ VALUE tmp, top;
+
+ tmp = rb_check_array_type(v);
+ if (NIL_P(tmp)) {
+ return v;
+ }
+ if (RARRAY(tmp)->len == 0) {
+ return Qundef;
+ }
+ if (RARRAY(tmp)->len == 1) {
+ top = rb_check_array_type(RARRAY(tmp)->ptr[0]);
+ if (NIL_P(top)) {
+ return RARRAY(tmp)->ptr[0];
+ }
+ if (RARRAY(top)->len > 1) {
+ return v;
+ }
+ return top;
+ }
+ return tmp;
+}
+
+static VALUE
+svalue_to_avalue(v)
+ VALUE v;
+{
+ VALUE tmp, top;
+
+ if (v == Qundef) return rb_ary_new2(0);
+ tmp = rb_check_array_type(v);
+ if (NIL_P(tmp)) {
+ return rb_ary_new3(1, v);
+ }
+ if (RARRAY(tmp)->len == 1) {
+ top = rb_check_array_type(RARRAY(tmp)->ptr[0]);
+ if (!NIL_P(top) && RARRAY(top)->len > 1) {
+ return tmp;
+ }
+ return rb_ary_new3(1, v);
+ }
+ return tmp;
+}
+
+static VALUE
+svalue_to_mrhs(v, lhs)
+ VALUE v;
+ NODE *lhs;
+{
+ VALUE tmp;
+
+ if (v == Qundef) return rb_ary_new2(0);
+ tmp = rb_check_array_type(v);
+ if (NIL_P(tmp)) {
+ return rb_ary_new3(1, v);
+ }
+ /* no lhs means splat lhs only */
+ if (!lhs) {
+ return rb_ary_new3(1, v);
+ }
+ return tmp;
+}
+
+static VALUE
+avalue_splat(v)
+ VALUE v;
+{
+ if (RARRAY(v)->len == 0) {
+ return Qundef;
+ }
+ if (RARRAY(v)->len == 1) {
+ return RARRAY(v)->ptr[0];
+ }
+ return v;
+}
+
+#if 1
+VALUE
+rb_Array(val)
+ VALUE val;
+{
+ VALUE tmp = rb_check_array_type(val);
+
+ if (NIL_P(tmp)) {
+ /* hack to avoid invoke Object#to_a */
+ VALUE origin;
+ ID id = rb_intern("to_a");
+
+ if (search_method(CLASS_OF(val), id, &origin) &&
+ RCLASS(origin)->m_tbl != RCLASS(rb_mKernel)->m_tbl) { /* exclude Kernel#to_a */
+ val = rb_funcall(val, id, 0);
+ if (TYPE(val) != T_ARRAY) {
+ rb_raise(rb_eTypeError, "`to_a' did not return Array");
+ }
+ return val;
+ }
+ else {
+ return rb_ary_new3(1, val);
+ }
+ }
+ return tmp;
+}
+#endif
+
+static VALUE
+splat_value(v)
+ VALUE v;
+{
+ if (NIL_P(v)) return rb_ary_new3(1, Qnil);
+ return rb_Array(v);
+}
+
+static VALUE
+class_prefix(self, cpath)
+ VALUE self;
+ NODE *cpath;
+{
+ if (!cpath) {
+ rb_bug("class path missing");
+ }
+ if (cpath->nd_head) {
+ VALUE c = rb_eval(self, cpath->nd_head);
+ switch (TYPE(c)) {
+ case T_CLASS:
+ case T_MODULE:
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s is not a class/module",
+ RSTRING(rb_obj_as_string(c))->ptr);
+ }
+ return c;
+ }
+ else if (nd_type(cpath) == NODE_COLON2) {
+ return ruby_cbase;
+ }
+ else if (ruby_wrapper) {
+ return ruby_wrapper;
+ }
+ else {
+ return rb_cObject;
+ }
+}
+
+#define return_value(v) do {\
+ if ((prot_tag->retval = (v)) == Qundef) {\
+ prot_tag->retval = Qnil;\
+ }\
+} while (0)
+
+NORETURN(static void return_jump _((VALUE)));
+NORETURN(static void break_jump _((VALUE)));
+NORETURN(static void next_jump _((VALUE)));
+NORETURN(static void unknown_node _((NODE * volatile)));
+
+static void
+unknown_node(node)
+ NODE *volatile node;
+{
+ ruby_current_node = 0;
+ if (node->flags == 0) {
+ rb_bug("terminated node (0x%lx)", node);
+ }
+ else if (BUILTIN_TYPE(node) != T_NODE) {
+ rb_bug("not a node 0x%02lx (0x%lx)", BUILTIN_TYPE(node), node);
+ }
+ else {
+ rb_bug("unknown node type %d (0x%lx)", nd_type(node), node);
+ }
+}
+
+static VALUE
+rb_eval(self, n)
+ VALUE self;
+ NODE *n;
+{
+ NODE * volatile contnode = 0;
+ NODE * volatile node = n;
+ int state;
+ volatile VALUE result = Qnil;
+ st_data_t data;
+
+#define RETURN(v) do { \
+ result = (v); \
+ goto finish; \
+} while (0)
+
+ again:
+ if (!node) RETURN(Qnil);
+
+ ruby_current_node = node;
+ switch (nd_type(node)) {
+ case NODE_BLOCK:
+ if (contnode) {
+ result = rb_eval(self, node);
+ break;
+ }
+ contnode = node->nd_next;
+ node = node->nd_head;
+ goto again;
+
+ case NODE_POSTEXE:
+ rb_f_END();
+ nd_set_type(node, NODE_NIL); /* exec just once */
+ result = Qnil;
+ break;
+
+ /* begin .. end without clauses */
+ case NODE_BEGIN:
+ node = node->nd_body;
+ goto again;
+
+ /* nodes for speed-up(default match) */
+ case NODE_MATCH:
+ result = rb_reg_match2(node->nd_lit);
+ break;
+
+ /* nodes for speed-up(literal match) */
+ case NODE_MATCH2:
+ {
+ VALUE l = rb_eval(self,node->nd_recv);
+ VALUE r = rb_eval(self,node->nd_value);
+ result = rb_reg_match(l, r);
+ }
+ break;
+
+ /* nodes for speed-up(literal match) */
+ case NODE_MATCH3:
+ {
+ VALUE r = rb_eval(self,node->nd_recv);
+ VALUE l = rb_eval(self,node->nd_value);
+ if (TYPE(l) == T_STRING) {
+ result = rb_reg_match(r, l);
+ }
+ else {
+ result = rb_funcall(l, match, 1, r);
+ }
+ }
+ break;
+
+ /* node for speed-up(top-level loop for -n/-p) */
+ case NODE_OPT_N:
+ PUSH_TAG(PROT_LOOP);
+ switch (state = EXEC_TAG()) {
+ case 0:
+ opt_n_next:
+ while (!NIL_P(rb_gets())) {
+ opt_n_redo:
+ rb_eval(self, node->nd_body);
+ }
+ break;
+
+ case TAG_REDO:
+ state = 0;
+ goto opt_n_redo;
+ case TAG_NEXT:
+ state = 0;
+ goto opt_n_next;
+ case TAG_BREAK:
+ state = 0;
+ default:
+ break;
+ }
+ POP_TAG();
+ if (state) JUMP_TAG(state);
+ RETURN(Qnil);
+
+ case NODE_SELF:
+ RETURN(self);
+
+ case NODE_NIL:
+ RETURN(Qnil);
+
+ case NODE_TRUE:
+ RETURN(Qtrue);
+
+ case NODE_FALSE:
+ RETURN(Qfalse);
+
+ case NODE_IF:
+ 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;
+
+ case NODE_WHEN:
+ while (node) {
+ NODE *tag;
+
+ if (nd_type(node) != NODE_WHEN) goto again;
+ tag = node->nd_head;
+ while (tag) {
+ EXEC_EVENT_HOOK(RUBY_EVENT_LINE, tag, self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
+ if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
+ VALUE v = rb_eval(self, tag->nd_head->nd_head);
+ long i;
+
+ if (TYPE(v) != T_ARRAY) v = rb_ary_to_ary(v);
+ for (i=0; i<RARRAY(v)->len; i++) {
+ if (RTEST(RARRAY(v)->ptr[i])) {
+ node = node->nd_body;
+ goto again;
+ }
+ }
+ tag = tag->nd_next;
+ continue;
+ }
+ if (RTEST(rb_eval(self, tag->nd_head))) {
+ node = node->nd_body;
+ goto again;
+ }
+ tag = tag->nd_next;
+ }
+ node = node->nd_next;
+ }
+ RETURN(Qnil);
+
+ case NODE_CASE:
+ {
+ VALUE val;
+
+ val = rb_eval(self, node->nd_head);
+ node = node->nd_body;
+ while (node) {
+ NODE *tag;
+
+ if (nd_type(node) != NODE_WHEN) {
+ goto again;
+ }
+ tag = node->nd_head;
+ while (tag) {
+ EXEC_EVENT_HOOK(RUBY_EVENT_LINE, tag, self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
+ if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
+ VALUE v = rb_eval(self, tag->nd_head->nd_head);
+ long i;
+
+ if (TYPE(v) != T_ARRAY) v = rb_ary_to_ary(v);
+ for (i=0; i<RARRAY(v)->len; i++) {
+ if (RTEST(rb_funcall2(RARRAY(v)->ptr[i], eqq, 1, &val))){
+ node = node->nd_body;
+ goto again;
+ }
+ }
+ tag = tag->nd_next;
+ continue;
+ }
+ if (RTEST(rb_funcall2(rb_eval(self, tag->nd_head), eqq, 1, &val))) {
+ node = node->nd_body;
+ goto again;
+ }
+ tag = tag->nd_next;
+ }
+ node = node->nd_next;
+ }
+ }
+ RETURN(Qnil);
+
+ case NODE_WHILE:
+ PUSH_TAG(PROT_LOOP);
+ result = Qnil;
+ switch (state = EXEC_TAG()) {
+ case 0:
+ if (node->nd_state && !RTEST(rb_eval(self, node->nd_cond)))
+ goto while_out;
+ do {
+ while_redo:
+ rb_eval(self, node->nd_body);
+ while_next:
+ ;
+ } while (RTEST(rb_eval(self, node->nd_cond)));
+ break;
+
+ case TAG_REDO:
+ state = 0;
+ goto while_redo;
+ case TAG_NEXT:
+ state = 0;
+ goto while_next;
+ case TAG_BREAK:
+ if (TAG_DST()) {
+ state = 0;
+ result = prot_tag->retval;
+ }
+ /* fall through */
+ default:
+ break;
+ }
+ while_out:
+ POP_TAG();
+ if (state) JUMP_TAG(state);
+ RETURN(result);
+
+ case NODE_UNTIL:
+ PUSH_TAG(PROT_LOOP);
+ result = Qnil;
+ switch (state = EXEC_TAG()) {
+ case 0:
+ if (node->nd_state && RTEST(rb_eval(self, node->nd_cond)))
+ goto until_out;
+ do {
+ until_redo:
+ rb_eval(self, node->nd_body);
+ until_next:
+ ;
+ } while (!RTEST(rb_eval(self, node->nd_cond)));
+ break;
+
+ case TAG_REDO:
+ state = 0;
+ goto until_redo;
+ case TAG_NEXT:
+ state = 0;
+ goto until_next;
+ case TAG_BREAK:
+ if (TAG_DST()) {
+ state = 0;
+ result = prot_tag->retval;
+ }
+ /* fall through */
+ default:
+ break;
+ }
+ until_out:
+ POP_TAG();
+ if (state) JUMP_TAG(state);
+ RETURN(result);
+
+ case NODE_BLOCK_PASS:
+ result = block_pass(self, node);
+ break;
+
+ case NODE_ITER:
+ case NODE_FOR:
+ {
+ PUSH_TAG(PROT_LOOP);
+ PUSH_BLOCK(node->nd_var, node->nd_body);
+
+ state = EXEC_TAG();
+ if (state == 0) {
+ iter_retry:
+ PUSH_ITER(ITER_PRE);
+ if (nd_type(node) == NODE_ITER) {
+ result = rb_eval(self, node->nd_iter);
+ }
+ else {
+ VALUE recv;
+
+ _block.flags &= ~BLOCK_D_SCOPE;
+ BEGIN_CALLARGS;
+ recv = rb_eval(self, node->nd_iter);
+ END_CALLARGS;
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
+ result = rb_call(CLASS_OF(recv),recv,each,0,0,0,self);
+ }
+ POP_ITER();
+ }
+ else if (state == TAG_BREAK && TAG_DST()) {
+ result = prot_tag->retval;
+ state = 0;
+ }
+ else if (state == TAG_RETRY) {
+ state = 0;
+ goto iter_retry;
+ }
+ POP_BLOCK();
+ POP_TAG();
+ switch (state) {
+ case 0:
+ break;
+ default:
+ JUMP_TAG(state);
+ }
+ }
+ break;
+
+ case NODE_BREAK:
+ break_jump(rb_eval(self, node->nd_stts));
+ break;
+
+ case NODE_NEXT:
+ CHECK_INTS;
+ next_jump(rb_eval(self, node->nd_stts));
+ break;
+
+ case NODE_REDO:
+ CHECK_INTS;
+ JUMP_TAG(TAG_REDO);
+ break;
+
+ case NODE_RETRY:
+ CHECK_INTS;
+ JUMP_TAG(TAG_RETRY);
+ break;
+
+ case NODE_SPLAT:
+ result = splat_value(rb_eval(self, node->nd_head));
+ break;
+
+ case NODE_TO_ARY:
+ result = rb_ary_to_ary(rb_eval(self, node->nd_head));
+ break;
+
+ case NODE_SVALUE:
+ result = avalue_splat(rb_eval(self, node->nd_head));
+ if (result == Qundef) result = Qnil;
+ break;
+
+ case NODE_YIELD:
+ if (node->nd_head) {
+ result = rb_eval(self, node->nd_head);
+ ruby_current_node = node;
+ }
+ else {
+ result = Qundef; /* no arg */
+ }
+ SET_CURRENT_SOURCE();
+ result = rb_yield_0(result, 0, 0, 0, node->nd_state);
+ break;
+
+ case NODE_RESCUE:
+ {
+ volatile VALUE e_info = ruby_errinfo;
+ volatile int rescuing = 0;
+
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ retry_entry:
+ result = rb_eval(self, node->nd_head);
+ }
+ else if (rescuing) {
+ if (rescuing < 0) {
+ /* in rescue argument, just reraise */
+ }
+ else if (state == TAG_RETRY) {
+ rescuing = state = 0;
+ ruby_errinfo = e_info;
+ goto retry_entry;
+ }
+ else if (state != TAG_RAISE) {
+ result = prot_tag->retval;
+ }
+ }
+ else if (state == TAG_RAISE) {
+ NODE *resq = node->nd_resq;
+
+ rescuing = -1;
+ while (resq) {
+ ruby_current_node = resq;
+ if (handle_rescue(self, resq)) {
+ state = 0;
+ rescuing = 1;
+ result = rb_eval(self, resq->nd_body);
+ break;
+ }
+ resq = resq->nd_head; /* next rescue */
+ }
+ }
+ else {
+ result = prot_tag->retval;
+ }
+ POP_TAG();
+ if (state != TAG_RAISE) ruby_errinfo = e_info;
+ if (state) {
+ JUMP_TAG(state);
+ }
+ /* no exception raised */
+ if (!rescuing && (node = node->nd_else)) { /* else clause given */
+ goto again;
+ }
+ }
+ break;
+
+ case NODE_ENSURE:
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ result = rb_eval(self, node->nd_head);
+ }
+ POP_TAG();
+ if (node->nd_ensr && !thread_no_ensure()) {
+ VALUE retval = prot_tag->retval; /* save retval */
+ VALUE errinfo = ruby_errinfo;
+
+ rb_eval(self, node->nd_ensr);
+ return_value(retval);
+ ruby_errinfo = errinfo;
+ }
+ if (state) JUMP_TAG(state);
+ break;
+
+ case NODE_AND:
+ result = rb_eval(self, node->nd_1st);
+ if (!RTEST(result)) break;
+ node = node->nd_2nd;
+ goto again;
+
+ case NODE_OR:
+ result = rb_eval(self, node->nd_1st);
+ if (RTEST(result)) break;
+ node = node->nd_2nd;
+ goto again;
+
+ case NODE_NOT:
+ if (RTEST(rb_eval(self, node->nd_body))) result = Qfalse;
+ else result = Qtrue;
+ break;
+
+ case NODE_DOT2:
+ case NODE_DOT3:
+ {
+ VALUE beg = rb_eval(self, node->nd_beg);
+ VALUE end = rb_eval(self, node->nd_end);
+ result = rb_range_new(beg, end, nd_type(node) == NODE_DOT3);
+ }
+ break;
+
+ case NODE_FLIP2: /* like AWK */
+ {
+ VALUE *flip = rb_svar(node->nd_cnt);
+ if (!flip) rb_bug("unexpected local variable");
+ if (!RTEST(*flip)) {
+ if (RTEST(rb_eval(self, node->nd_beg))) {
+ *flip = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue;
+ result = Qtrue;
+ }
+ else {
+ result = Qfalse;
+ }
+ }
+ else {
+ if (RTEST(rb_eval(self, node->nd_end))) {
+ *flip = Qfalse;
+ }
+ result = Qtrue;
+ }
+ }
+ break;
+
+ case NODE_FLIP3: /* like SED */
+ {
+ VALUE *flip = rb_svar(node->nd_cnt);
+ if (!flip) rb_bug("unexpected local variable");
+ if (!RTEST(*flip)) {
+ result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse;
+ *flip = result;
+ }
+ else {
+ if (RTEST(rb_eval(self, node->nd_end))) {
+ *flip = Qfalse;
+ }
+ result = Qtrue;
+ }
+ }
+ break;
+
+ case NODE_RETURN:
+ return_jump(rb_eval(self, node->nd_stts));
+ break;
+
+ case NODE_ARGSCAT:
+ {
+ VALUE args = rb_eval(self, node->nd_head);
+ result = rb_ary_concat(args, splat_value(rb_eval(self, node->nd_body)));
+ }
+ break;
+
+ case NODE_ARGSPUSH:
+ {
+ VALUE args = rb_ary_dup(rb_eval(self, node->nd_head));
+ result = rb_ary_push(args, rb_eval(self, node->nd_body));
+ }
+ break;
+
+ case NODE_ATTRASGN:
+ {
+ VALUE recv;
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ int scope;
+ TMP_PROTECT;
+
+ BEGIN_CALLARGS;
+ if (node->nd_recv == (NODE *)1) {
+ recv = self;
+ scope = 1;
+ }
+ else {
+ recv = rb_eval(self, node->nd_recv);
+ scope = 0;
+ }
+ SETUP_ARGS(node->nd_args);
+ END_CALLARGS;
+
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
+ rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope,self);
+ result = argv[argc-1];
+ }
+ break;
+
+ case NODE_CALL:
+ {
+ VALUE recv;
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
+
+ BEGIN_CALLARGS;
+ recv = rb_eval(self, node->nd_recv);
+ SETUP_ARGS(node->nd_args);
+ END_CALLARGS;
+
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
+ result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0,self);
+ }
+ break;
+
+ case NODE_FCALL:
+ {
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
+
+ BEGIN_CALLARGS;
+ SETUP_ARGS(node->nd_args);
+ END_CALLARGS;
+
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
+ result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1,self);
+ }
+ break;
+
+ case NODE_VCALL:
+ SET_CURRENT_SOURCE();
+ result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2,self);
+ break;
+
+ case NODE_SUPER:
+ case NODE_ZSUPER:
+ {
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
+
+ if (ruby_frame->last_class == 0) {
+ if (ruby_frame->last_func) {
+ rb_name_error(ruby_frame->last_func,
+ "superclass method `%s' disabled",
+ rb_id2name(ruby_frame->orig_func));
+ }
+ else {
+ rb_raise(rb_eNoMethodError, "super called outside of method");
+ }
+ }
+ if (nd_type(node) == NODE_ZSUPER) {
+ argc = ruby_frame->argc;
+ if (argc && DMETHOD_P()) {
+ if (TYPE(RBASIC(ruby_scope)->klass) != T_ARRAY ||
+ RARRAY(RBASIC(ruby_scope)->klass)->len != argc) {
+ rb_raise(rb_eRuntimeError,
+ "super: specify arguments explicitly");
+ }
+ argv = RARRAY(RBASIC(ruby_scope)->klass)->ptr;
+ }
+ else if (!ruby_scope->local_vars) {
+ argc = 0;
+ argv = 0;
+ }
+ else {
+ argv = ruby_scope->local_vars + 2;
+ }
+ }
+ else {
+ BEGIN_CALLARGS;
+ SETUP_ARGS(node->nd_args);
+ END_CALLARGS;
+ ruby_current_node = node;
+ }
+
+ SET_CURRENT_SOURCE();
+ result = rb_call_super(argc, argv);
+ }
+ break;
+
+ case NODE_SCOPE:
+ {
+ struct FRAME frame;
+ NODE *saved_cref = 0;
+
+ frame = *ruby_frame;
+ frame.tmp = ruby_frame;
+ ruby_frame = &frame;
+
+ PUSH_SCOPE();
+ PUSH_TAG(PROT_NONE);
+ if (node->nd_rval) {
+ saved_cref = ruby_cref;
+ ruby_cref = (NODE*)node->nd_rval;
+ }
+ if (node->nd_tbl) {
+ VALUE *vars = ALLOCA_N(VALUE, node->nd_tbl[0]+1);
+ *vars++ = (VALUE)node;
+ ruby_scope->local_vars = vars;
+ rb_mem_clear(ruby_scope->local_vars, node->nd_tbl[0]);
+ ruby_scope->local_tbl = node->nd_tbl;
+ }
+ else {
+ ruby_scope->local_vars = 0;
+ ruby_scope->local_tbl = 0;
+ }
+ if ((state = EXEC_TAG()) == 0) {
+ result = rb_eval(self, node->nd_next);
+ }
+ POP_TAG();
+ POP_SCOPE();
+ ruby_frame = frame.tmp;
+ if (saved_cref)
+ ruby_cref = saved_cref;
+ if (state) JUMP_TAG(state);
+ }
+ break;
+
+ case NODE_OP_ASGN1:
+ {
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ VALUE recv, val, tmp;
+ NODE *rval;
+ TMP_PROTECT;
+
+ recv = rb_eval(self, node->nd_recv);
+ rval = node->nd_args->nd_head;
+ SETUP_ARGS0(node->nd_args->nd_body, 1);
+ val = rb_funcall3(recv, aref, argc, argv);
+ switch (node->nd_mid) {
+ case 0: /* OR */
+ if (RTEST(val)) RETURN(val);
+ val = rb_eval(self, rval);
+ break;
+ case 1: /* AND */
+ if (!RTEST(val)) RETURN(val);
+ val = rb_eval(self, rval);
+ break;
+ default:
+ tmp = rb_eval(self, rval);
+ val = rb_funcall3(val, node->nd_mid, 1, &tmp);
+ }
+ argv[argc] = val;
+ rb_funcall2(recv, aset, argc+1, argv);
+ result = val;
+ }
+ break;
+
+ case NODE_OP_ASGN2:
+ {
+ ID id = node->nd_next->nd_vid;
+ VALUE recv, val, tmp;
+
+ recv = rb_eval(self, node->nd_recv);
+ val = rb_funcall3(recv, id, 0, 0);
+ switch (node->nd_next->nd_mid) {
+ case 0: /* OR */
+ if (RTEST(val)) RETURN(val);
+ val = rb_eval(self, node->nd_value);
+ break;
+ case 1: /* AND */
+ if (!RTEST(val)) RETURN(val);
+ val = rb_eval(self, node->nd_value);
+ break;
+ default:
+ tmp = rb_eval(self, node->nd_value);
+ val = rb_funcall3(val, node->nd_next->nd_mid, 1, &tmp);
+ }
+
+ rb_funcall2(recv, node->nd_next->nd_aid, 1, &val);
+ result = val;
+ }
+ break;
+
+ case NODE_OP_ASGN_AND:
+ result = rb_eval(self, node->nd_head);
+ if (!RTEST(result)) break;
+ node = node->nd_value;
+ goto again;
+
+ case NODE_OP_ASGN_OR:
+ if ((node->nd_aid && !is_defined(self, node->nd_head, 0)) ||
+ !RTEST(result = rb_eval(self, node->nd_head))) {
+ node = node->nd_value;
+ goto again;
+ }
+ break;
+
+ case NODE_MASGN:
+ result = massign(self, node, rb_eval(self, node->nd_value), 0);
+ break;
+
+ case NODE_LASGN:
+ if (ruby_scope->local_vars == 0)
+ rb_bug("unexpected local variable assignment");
+ result = rb_eval(self, node->nd_value);
+ ruby_scope->local_vars[node->nd_cnt] = result;
+ break;
+
+ case NODE_DASGN:
+ result = rb_eval(self, node->nd_value);
+ dvar_asgn(node->nd_vid, result);
+ break;
+
+ case NODE_DASGN_CURR:
+ result = rb_eval(self, node->nd_value);
+ dvar_asgn_curr(node->nd_vid, result);
+ break;
+
+ case NODE_GASGN:
+ result = rb_eval(self, node->nd_value);
+ rb_gvar_set(node->nd_entry, result);
+ break;
+
+ case NODE_IASGN:
+ result = rb_eval(self, node->nd_value);
+ rb_ivar_set(self, node->nd_vid, result);
+ break;
+
+ case NODE_CDECL:
+ result = rb_eval(self, node->nd_value);
+ if (node->nd_vid == 0) {
+ rb_const_set(class_prefix(self, node->nd_else), node->nd_else->nd_mid, result);
+ }
+ else {
+ rb_const_set(ruby_cbase, node->nd_vid, result);
+ }
+ break;
+
+ case NODE_CVDECL:
+ if (NIL_P(ruby_cbase)) {
+ rb_raise(rb_eTypeError, "no class/module to define class variable");
+ }
+ result = rb_eval(self, node->nd_value);
+ rb_cvar_set(cvar_cbase(), node->nd_vid, result, Qtrue);
+ break;
+
+ case NODE_CVASGN:
+ result = rb_eval(self, node->nd_value);
+ rb_cvar_set(cvar_cbase(), node->nd_vid, result, Qfalse);
+ break;
+
+ case NODE_LVAR:
+ if (ruby_scope->local_vars == 0) {
+ rb_bug("unexpected local variable");
+ }
+ result = ruby_scope->local_vars[node->nd_cnt];
+ break;
+
+ case NODE_DVAR:
+ result = rb_dvar_ref(node->nd_vid);
+ break;
+
+ case NODE_GVAR:
+ result = rb_gvar_get(node->nd_entry);
+ break;
+
+ case NODE_IVAR:
+ result = rb_ivar_get(self, node->nd_vid);
+ break;
+
+ case NODE_CONST:
+ result = ev_const_get(ruby_cref, node->nd_vid, self);
+ break;
+
+ case NODE_CVAR:
+ result = rb_cvar_get(cvar_cbase(), node->nd_vid);
+ break;
+
+ case NODE_BLOCK_ARG:
+ if (ruby_scope->local_vars == 0)
+ rb_bug("unexpected block argument");
+ if (rb_block_given_p()) {
+ result = rb_block_proc();
+ ruby_scope->local_vars[node->nd_cnt] = result;
+ }
+ else {
+ result = Qnil;
+ }
+ break;
+
+ case NODE_COLON2:
+ {
+ VALUE klass;
+
+ klass = rb_eval(self, node->nd_head);
+ if (rb_is_const_id(node->nd_mid)) {
+ switch (TYPE(klass)) {
+ case T_CLASS:
+ case T_MODULE:
+ result = rb_const_get_from(klass, node->nd_mid);
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s is not a class/module",
+ RSTRING(rb_obj_as_string(klass))->ptr);
+ break;
+ }
+ }
+ else {
+ result = rb_funcall(klass, node->nd_mid, 0, 0);
+ }
+ }
+ break;
+
+ case NODE_COLON3:
+ result = rb_const_get_from(rb_cObject, node->nd_mid);
+ break;
+
+ case NODE_NTH_REF:
+ result = rb_reg_nth_match(node->nd_nth, MATCH_DATA);
+ break;
+
+ case NODE_BACK_REF:
+ switch (node->nd_nth) {
+ case '&':
+ result = rb_reg_last_match(MATCH_DATA);
+ break;
+ case '`':
+ result = rb_reg_match_pre(MATCH_DATA);
+ break;
+ case '\'':
+ result = rb_reg_match_post(MATCH_DATA);
+ break;
+ case '+':
+ result = rb_reg_match_last(MATCH_DATA);
+ break;
+ default:
+ rb_bug("unexpected back-ref");
+ }
+ break;
+
+ case NODE_HASH:
+ {
+ NODE *list;
+ VALUE hash = rb_hash_new();
+ VALUE key, val;
+
+ list = node->nd_head;
+ while (list) {
+ key = rb_eval(self, list->nd_head);
+ list = list->nd_next;
+ if (list == 0)
+ rb_bug("odd number list for Hash");
+ val = rb_eval(self, list->nd_head);
+ list = list->nd_next;
+ rb_hash_aset(hash, key, val);
+ }
+ result = hash;
+ }
+ break;
+
+ case NODE_ZARRAY: /* zero length list */
+ result = rb_ary_new();
+ break;
+
+ case NODE_ARRAY:
+ {
+ VALUE ary;
+ long i;
+
+ i = node->nd_alen;
+ ary = rb_ary_new2(i);
+ for (i=0;node;node=node->nd_next) {
+ RARRAY(ary)->ptr[i++] = rb_eval(self, node->nd_head);
+ RARRAY(ary)->len = i;
+ }
+
+ result = ary;
+ }
+ break;
+
+ case NODE_STR:
+ result = rb_str_new3(node->nd_lit);
+ break;
+
+ case NODE_EVSTR:
+ result = rb_obj_as_string(rb_eval(self, node->nd_body));
+ break;
+
+ case NODE_DSTR:
+ case NODE_DXSTR:
+ case NODE_DREGX:
+ case NODE_DREGX_ONCE:
+ case NODE_DSYM:
+ {
+ VALUE str, str2;
+ NODE *list = node->nd_next;
+
+ str = rb_str_new3(node->nd_lit);
+ while (list) {
+ if (list->nd_head) {
+ switch (nd_type(list->nd_head)) {
+ case NODE_STR:
+ str2 = list->nd_head->nd_lit;
+ break;
+ default:
+ str2 = rb_eval(self, list->nd_head);
+ break;
+ }
+ rb_str_append(str, str2);
+ OBJ_INFECT(str, str2);
+ }
+ list = list->nd_next;
+ }
+ switch (nd_type(node)) {
+ case NODE_DREGX:
+ result = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
+ node->nd_cflag);
+ break;
+ case NODE_DREGX_ONCE: /* regexp expand once */
+ result = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
+ node->nd_cflag);
+ nd_set_type(node, NODE_LIT);
+ node->nd_lit = result;
+ break;
+ case NODE_LIT:
+ /* other thread may replace NODE_DREGX_ONCE to NODE_LIT */
+ goto again;
+ case NODE_DXSTR:
+ result = rb_funcall(self, '`', 1, str);
+ break;
+ case NODE_DSYM:
+ result = rb_str_intern(str);
+ break;
+ default:
+ result = str;
+ break;
+ }
+ }
+ break;
+
+ case NODE_XSTR:
+ result = rb_funcall(self, '`', 1, rb_str_new3(node->nd_lit));
+ break;
+
+ case NODE_LIT:
+ result = node->nd_lit;
+ break;
+
+ case NODE_DEFN:
+ if (node->nd_defn) {
+ NODE *body, *defn;
+ VALUE origin = 0;
+ int noex;
+
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class/module to add method");
+ }
+ if (ruby_class == rb_cObject && node->nd_mid == init) {
+ rb_warn("redefining Object#initialize may cause infinite loop");
+ }
+ if (node->nd_mid == __id__ || node->nd_mid == __send__) {
+ rb_warn("redefining `%s' may cause serious problem",
+ rb_id2name(node->nd_mid));
+ }
+ rb_frozen_class_p(ruby_class);
+ body = search_method(ruby_class, node->nd_mid, &origin);
+ if (body){
+ if (RTEST(ruby_verbose) && ruby_class == origin && body->nd_cnt == 0 && body->nd_body) {
+ rb_warning("method redefined; discarding old %s", rb_id2name(node->nd_mid));
+ }
+ }
+
+ if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) {
+ noex = NOEX_PRIVATE;
+ }
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
+ else {
+ noex = NOEX_PUBLIC;
+ }
+ if (body && origin == ruby_class && body->nd_body == 0) {
+ noex |= NOEX_NOSUPER;
+ }
+
+ defn = rb_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),
+ node->nd_mid, defn, NOEX_PUBLIC);
+ }
+ result = Qnil;
+ }
+ break;
+
+ case NODE_DEFS:
+ if (node->nd_defn) {
+ VALUE recv = rb_eval(self, node->nd_recv);
+ VALUE klass;
+ NODE *body = 0, *defn;
+
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(recv)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't define singleton method");
+ }
+ if (FIXNUM_P(recv) || SYMBOL_P(recv)) {
+ rb_raise(rb_eTypeError,
+ "can't define singleton method \"%s\" for %s",
+ rb_id2name(node->nd_mid),
+ rb_obj_classname(recv));
+ }
+
+ if (OBJ_FROZEN(recv)) rb_error_frozen("object");
+ klass = rb_singleton_class(recv);
+ if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &data)) {
+ body = (NODE *)data;
+ if (ruby_safe_level >= 4) {
+ rb_raise(rb_eSecurityError, "redefining method prohibited");
+ }
+ if (RTEST(ruby_verbose)) {
+ rb_warning("redefine %s", rb_id2name(node->nd_mid));
+ }
+ }
+ defn = rb_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;
+ }
+ break;
+
+ case NODE_UNDEF:
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class to undef method");
+ }
+ rb_undef(ruby_class, rb_to_id(rb_eval(self, node->u2.node)));
+ result = Qnil;
+ break;
+
+ case NODE_ALIAS:
+ if (NIL_P(ruby_class)) {
+ rb_raise(rb_eTypeError, "no class to make alias");
+ }
+ rb_alias(ruby_class, rb_to_id(rb_eval(self, node->u1.node)),
+ rb_to_id(rb_eval(self, node->u2.node)));
+ result = Qnil;
+ break;
+
+ case NODE_VALIAS:
+ rb_alias_variable(node->u1.id, node->u2.id);
+ result = Qnil;
+ break;
+
+ case NODE_CLASS:
+ {
+ VALUE super, klass, tmp, cbase;
+ ID cname;
+ int gen = Qfalse;
+
+ cbase = class_prefix(self, node->nd_cpath);
+ cname = node->nd_cpath->nd_mid;
+
+ if (NIL_P(ruby_cbase)) {
+ rb_raise(rb_eTypeError, "no outer class/module");
+ }
+ if (node->nd_super) {
+ super = rb_eval(self, node->nd_super);
+ rb_check_inheritable(super);
+ }
+ else {
+ super = 0;
+ }
+
+ if (rb_const_defined_at(cbase, cname)) {
+ klass = rb_const_get_at(cbase, cname);
+ if (TYPE(klass) != T_CLASS) {
+ rb_raise(rb_eTypeError, "%s is not a class",
+ rb_id2name(cname));
+ }
+ if (super) {
+ tmp = rb_class_real(RCLASS(klass)->super);
+ if (tmp != super) {
+ rb_raise(rb_eTypeError, "superclass mismatch for class %s",
+ rb_id2name(cname));
+ }
+ super = 0;
+ }
+ if (ruby_safe_level >= 4) {
+ rb_raise(rb_eSecurityError, "extending class prohibited");
+ }
+ }
+ else {
+ if (!super) super = rb_cObject;
+ klass = rb_define_class_id(cname, super);
+ rb_set_class_path(klass, cbase, rb_id2name(cname));
+ rb_const_set(cbase, cname, klass);
+ gen = Qtrue;
+ }
+ if (ruby_wrapper) {
+ rb_extend_object(klass, ruby_wrapper);
+ rb_include_module(klass, ruby_wrapper);
+ }
+ if (super && gen) {
+ rb_class_inherited(super, klass);
+ }
+ result = module_setup(klass, node);
+ }
+ break;
+
+ case NODE_MODULE:
+ {
+ VALUE module, cbase;
+ ID cname;
+
+ if (NIL_P(ruby_cbase)) {
+ rb_raise(rb_eTypeError, "no outer class/module");
+ }
+ cbase = class_prefix(self, node->nd_cpath);
+ cname = node->nd_cpath->nd_mid;
+ if (rb_const_defined_at(cbase, cname)) {
+ module = rb_const_get_at(cbase, cname);
+ if (TYPE(module) != T_MODULE) {
+ rb_raise(rb_eTypeError, "%s is not a module",
+ rb_id2name(cname));
+ }
+ if (ruby_safe_level >= 4) {
+ rb_raise(rb_eSecurityError, "extending module prohibited");
+ }
+ }
+ else {
+ module = rb_define_module_id(cname);
+ rb_set_class_path(module, cbase, rb_id2name(cname));
+ rb_const_set(cbase, cname, module);
+ }
+ if (ruby_wrapper) {
+ rb_extend_object(module, ruby_wrapper);
+ rb_include_module(module, ruby_wrapper);
+ }
+
+ result = module_setup(module, node);
+ }
+ break;
+
+ case NODE_SCLASS:
+ {
+ VALUE klass;
+
+ result = rb_eval(self, node->nd_recv);
+ if (FIXNUM_P(result) || SYMBOL_P(result)) {
+ rb_raise(rb_eTypeError, "no virtual class for %s",
+ rb_obj_classname(result));
+ }
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(result))
+ rb_raise(rb_eSecurityError, "Insecure: can't extend object");
+ klass = rb_singleton_class(result);
+
+ if (ruby_wrapper) {
+ rb_extend_object(klass, ruby_wrapper);
+ rb_include_module(klass, ruby_wrapper);
+ }
+
+ result = module_setup(klass, node);
+ }
+ break;
+
+ case NODE_DEFINED:
+ {
+ char buf[20];
+ const char *desc = is_defined(self, node->nd_head, buf);
+
+ if (desc) result = rb_str_new2(desc);
+ else result = Qnil;
+ }
+ break;
+
+ case NODE_NEWLINE:
+ EXEC_EVENT_HOOK(RUBY_EVENT_LINE, node, self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
+ node = node->nd_next;
+ goto again;
+
+ default:
+ unknown_node(node);
+ }
+ finish:
+ CHECK_INTS;
+ if (contnode) {
+ node = contnode;
+ contnode = 0;
+ goto again;
+ }
+ return result;
+}
+
+static VALUE
+module_setup(module, n)
+ VALUE module;
+ NODE *n;
+{
+ NODE * volatile node = n->nd_body;
+ int state;
+ struct FRAME frame;
+ VALUE result = Qnil; /* OK */
+ TMP_PROTECT;
+
+ frame = *ruby_frame;
+ frame.tmp = ruby_frame;
+ ruby_frame = &frame;
+
+ PUSH_CLASS(module);
+ PUSH_SCOPE();
+ PUSH_VARS();
+
+ if (node->nd_tbl) {
+ VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
+ *vars++ = (VALUE)node;
+ ruby_scope->local_vars = vars;
+ rb_mem_clear(ruby_scope->local_vars, node->nd_tbl[0]);
+ ruby_scope->local_tbl = node->nd_tbl;
+ }
+ else {
+ ruby_scope->local_vars = 0;
+ ruby_scope->local_tbl = 0;
+ }
+
+ PUSH_CREF(module);
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ EXEC_EVENT_HOOK(RUBY_EVENT_CLASS, n, ruby_cbase,
+ ruby_frame->last_func, ruby_frame->last_class);
+ result = rb_eval(ruby_cbase, node->nd_next);
+ }
+ POP_TAG();
+ POP_CREF();
+ POP_VARS();
+ POP_SCOPE();
+ POP_CLASS();
+
+ ruby_frame = frame.tmp;
+ EXEC_EVENT_HOOK(RUBY_EVENT_END, n, 0,
+ ruby_frame->last_func, ruby_frame->last_class);
+ if (state) JUMP_TAG(state);
+
+ return result;
+}
+
static NODE *basic_respond_to = 0;
int
-rb_obj_respond_to(VALUE obj, ID id, int priv)
+rb_obj_respond_to(obj, id, priv)
+ VALUE obj;
+ ID id;
+ int priv;
{
VALUE klass = CLASS_OF(obj);
@@ -456,14 +4234,15 @@ rb_obj_respond_to(VALUE obj, ID id, int priv)
VALUE args[2];
int n = 0;
args[n++] = ID2SYM(id);
- if (priv)
- args[n++] = Qtrue;
- return rb_funcall2(obj, respond_to, n, args);
+ if (priv) args[n++] = Qtrue;
+ return RTEST(rb_funcall2(obj, respond_to, n, args));
}
}
int
-rb_respond_to(VALUE obj, ID id)
+rb_respond_to(obj, id)
+ VALUE obj;
+ ID id;
{
return rb_obj_respond_to(obj, id, Qfalse);
}
@@ -471,14 +4250,17 @@ rb_respond_to(VALUE obj, ID id)
/*
* call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false
- *
+ *
* Returns +true+> if _obj_ responds to the given
* method. Private methods are included in the search only if the
* optional second parameter evaluates to +true+.
*/
static VALUE
-obj_respond_to(int argc, VALUE *argv, VALUE obj)
+obj_respond_to(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE mid, priv;
ID id;
@@ -494,11 +4276,11 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
/*
* call-seq:
* mod.method_defined?(symbol) => true or false
- *
+ *
* Returns +true+ if the named method is defined by
* _mod_ (or its included modules and, if _mod_ is a class,
* its ancestors). Public and protected methods are matched.
- *
+ *
* module A
* def method1() end
* end
@@ -509,7 +4291,7 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
* include A
* def method3() end
* end
- *
+ *
* A.method_defined? :method1 #=> true
* C.method_defined? "method1" #=> true
* C.method_defined? "method2" #=> true
@@ -518,7 +4300,8 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
*/
static VALUE
-rb_mod_method_defined(VALUE mod, VALUE mid)
+rb_mod_method_defined(mod, mid)
+ VALUE mod, mid;
{
return rb_method_boundp(mod, rb_to_id(mid), 1);
}
@@ -528,11 +4311,11 @@ rb_mod_method_defined(VALUE mod, VALUE mid)
/*
* call-seq:
* mod.public_method_defined?(symbol) => true or false
- *
+ *
* Returns +true+ if the named public method is defined by
* _mod_ (or its included modules and, if _mod_ is a class,
* its ancestors).
- *
+ *
* module A
* def method1() end
* end
@@ -544,7 +4327,7 @@ rb_mod_method_defined(VALUE mod, VALUE mid)
* include A
* def method3() end
* end
- *
+ *
* A.method_defined? :method1 #=> true
* C.public_method_defined? "method1" #=> true
* C.public_method_defined? "method2" #=> false
@@ -552,14 +4335,14 @@ rb_mod_method_defined(VALUE mod, VALUE mid)
*/
static VALUE
-rb_mod_public_method_defined(VALUE mod, VALUE mid)
+rb_mod_public_method_defined(mod, mid)
+ VALUE mod, mid;
{
ID id = rb_to_id(mid);
- NODE *method;
+ int noex;
- method = rb_method_node(mod, id);
- if (method) {
- if (VISI_CHECK(method->nd_noex, NOEX_PUBLIC))
+ if (rb_get_method_body(&mod, &id, &noex)) {
+ if (VISI_CHECK(noex, NOEX_PUBLIC))
return Qtrue;
}
return Qfalse;
@@ -568,11 +4351,11 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
/*
* call-seq:
* mod.private_method_defined?(symbol) => true or false
- *
+ *
* Returns +true+ if the named private method is defined by
* _ mod_ (or its included modules and, if _mod_ is a class,
* its ancestors).
- *
+ *
* module A
* def method1() end
* end
@@ -584,7 +4367,7 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
* include A
* def method3() end
* end
- *
+ *
* A.method_defined? :method1 #=> true
* C.private_method_defined? "method1" #=> false
* C.private_method_defined? "method2" #=> true
@@ -592,14 +4375,14 @@ rb_mod_public_method_defined(VALUE mod, VALUE mid)
*/
static VALUE
-rb_mod_private_method_defined(VALUE mod, VALUE mid)
+rb_mod_private_method_defined(mod, mid)
+ VALUE mod, mid;
{
ID id = rb_to_id(mid);
- NODE *method;
+ int noex;
- method = rb_method_node(mod, id);
- if (method) {
- if (VISI_CHECK(method->nd_noex, NOEX_PRIVATE))
+ if (rb_get_method_body(&mod, &id, &noex)) {
+ if (VISI_CHECK(noex, NOEX_PRIVATE))
return Qtrue;
}
return Qfalse;
@@ -608,11 +4391,11 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
/*
* call-seq:
* mod.protected_method_defined?(symbol) => true or false
- *
+ *
* Returns +true+ if the named protected method is defined
* by _mod_ (or its included modules and, if _mod_ is a
* class, its ancestors).
- *
+ *
* module A
* def method1() end
* end
@@ -624,7 +4407,7 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
* include A
* def method3() end
* end
- *
+ *
* A.method_defined? :method1 #=> true
* C.protected_method_defined? "method1" #=> false
* C.protected_method_defined? "method2" #=> true
@@ -632,115 +4415,257 @@ rb_mod_private_method_defined(VALUE mod, VALUE mid)
*/
static VALUE
-rb_mod_protected_method_defined(VALUE mod, VALUE mid)
+rb_mod_protected_method_defined(mod, mid)
+ VALUE mod, mid;
{
ID id = rb_to_id(mid);
- NODE *method;
+ int noex;
- method = rb_method_node(mod, id);
- if (method) {
- if (VISI_CHECK(method->nd_noex, NOEX_PROTECTED))
+ if (rb_get_method_body(&mod, &id, &noex)) {
+ if (VISI_CHECK(noex, NOEX_PROTECTED))
return Qtrue;
}
return Qfalse;
}
-NORETURN(static void rb_longjmp(int, VALUE));
-static VALUE make_backtrace(void);
+NORETURN(static VALUE terminate_process _((int, VALUE)));
+static VALUE
+terminate_process(status, mesg)
+ int status;
+ VALUE mesg;
+{
+ VALUE args[2];
+ args[0] = INT2NUM(status);
+ args[1] = mesg;
+
+ rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
+}
+
+void
+rb_exit(status)
+ int status;
+{
+ if (prot_tag) {
+ terminate_process(status, rb_str_new("exit", 4));
+ }
+ ruby_finalize();
+ exit(status);
+}
+
+
+/*
+ * call-seq:
+ * exit(integer=0)
+ * Kernel::exit(integer=0)
+ * Process::exit(integer=0)
+ *
+ * Initiates the termination of the Ruby script by raising the
+ * <code>SystemExit</code> exception. This exception may be caught. The
+ * optional parameter is used to return a status code to the invoking
+ * environment.
+ *
+ * begin
+ * exit
+ * puts "never get here"
+ * rescue SystemExit
+ * puts "rescued a SystemExit exception"
+ * end
+ * puts "after begin block"
+ *
+ * <em>produces:</em>
+ *
+ * rescued a SystemExit exception
+ * after begin block
+ *
+ * Just prior to termination, Ruby executes any <code>at_exit</code> functions
+ * (see Kernel::at_exit) and runs any object finalizers (see
+ * ObjectSpace::define_finalizer).
+ *
+ * at_exit { puts "at_exit function" }
+ * ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
+ * exit
+ *
+ * <em>produces:</em>
+ *
+ * at_exit function
+ * in finalizer
+ */
+
+VALUE
+rb_f_exit(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE status;
+ int istatus;
+
+ rb_secure(4);
+ if (rb_scan_args(argc, argv, "01", &status) == 1) {
+ switch (status) {
+ case Qtrue:
+ istatus = EXIT_SUCCESS;
+ break;
+ case Qfalse:
+ istatus = EXIT_FAILURE;
+ break;
+ default:
+ istatus = NUM2INT(status);
+#if EXIT_SUCCESS != 0
+ if (istatus == 0) istatus = EXIT_SUCCESS;
+#endif
+ break;
+ }
+ }
+ else {
+ istatus = EXIT_SUCCESS;
+ }
+ rb_exit(istatus);
+ return Qnil; /* not reached */
+}
+
+
+/*
+ * call-seq:
+ * abort
+ * Kernel::abort
+ * Process::abort
+ *
+ * Terminate execution immediately, effectively by calling
+ * <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
+ * to STDERR prior to terminating.
+ */
+
+VALUE
+rb_f_abort(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ rb_secure(4);
+ if (argc == 0) {
+ if (!NIL_P(ruby_errinfo)) {
+ error_print();
+ }
+ rb_exit(EXIT_FAILURE);
+ }
+ else {
+ VALUE mesg;
+
+ rb_scan_args(argc, argv, "1", &mesg);
+ StringValue(mesg);
+ rb_io_puts(1, &mesg, rb_stderr);
+ terminate_process(EXIT_FAILURE, mesg);
+ }
+ return Qnil; /* not reached */
+}
+
+void
+rb_iter_break()
+{
+ break_jump(Qnil);
+}
+
+NORETURN(static void rb_longjmp _((int, VALUE)));
+static VALUE make_backtrace _((void));
static void
-rb_longjmp(int tag, VALUE mesg)
+rb_longjmp(tag, mesg)
+ int tag;
+ VALUE mesg;
{
VALUE at;
- VALUE e;
- rb_thread_t *th = GET_THREAD();
- const char *file;
- int line = 0;
+ rb_thread_t th = curr_thread;
- if (thread_set_raised(th)) {
- th->errinfo = exception_error;
+ if (rb_thread_set_raised(th)) {
+ ruby_errinfo = exception_error;
JUMP_TAG(TAG_FATAL);
}
-
- if (NIL_P(mesg))
- mesg = th->errinfo;
+ if (NIL_P(mesg)) mesg = ruby_errinfo;
if (NIL_P(mesg)) {
mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
}
- file = rb_sourcefile();
- if (file) line = rb_sourceline();
- if (file && !NIL_P(mesg)) {
+ ruby_set_current_source();
+ if (ruby_sourcefile && !NIL_P(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);
}
}
if (!NIL_P(mesg)) {
- th->errinfo = mesg;
+ ruby_errinfo = mesg;
}
- if (RTEST(ruby_debug) && !NIL_P(e = th->errinfo) &&
- !rb_obj_is_kind_of(e, rb_eSystemExit)) {
+ if (RTEST(ruby_debug) && !NIL_P(ruby_errinfo)
+ && !rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
+ VALUE e = ruby_errinfo;
int status;
- PUSH_TAG();
+ PUSH_TAG(PROT_NONE);
if ((status = EXEC_TAG()) == 0) {
- RB_GC_GUARD(e) = rb_obj_as_string(e);
- if (file) {
- warn_printf("Exception `%s' at %s:%d - %s\n",
- rb_obj_classname(th->errinfo),
- file, line, RSTRING_PTR(e));
- }
- else {
- warn_printf("Exception `%s' - %s\n",
- rb_obj_classname(th->errinfo),
- RSTRING_PTR(e));
- }
+ StringValue(e);
+ warn_printf("Exception `%s' at %s:%d - %s\n",
+ rb_obj_classname(ruby_errinfo),
+ ruby_sourcefile, ruby_sourceline,
+ RSTRING(e)->ptr);
}
POP_TAG();
- if (status == TAG_FATAL && th->errinfo == exception_error) {
- th->errinfo = mesg;
+ if (status == TAG_FATAL && ruby_errinfo == exception_error) {
+ ruby_errinfo = mesg;
}
else if (status) {
- thread_reset_raised(th);
+ rb_thread_reset_raised(th);
JUMP_TAG(status);
}
}
rb_trap_restore_mask();
-
if (tag != TAG_FATAL) {
- EXEC_EVENT_HOOK(th, RUBY_EVENT_RAISE, th->cfp->self,
- 0 /* TODO: id */, 0 /* TODO: klass */);
+ EXEC_EVENT_HOOK(RUBY_EVENT_RAISE, ruby_current_node,
+ ruby_frame->self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
}
-
- thread_reset_raised(th);
+ if (!prot_tag) {
+ error_print();
+ }
+ rb_thread_raised_clear(th);
JUMP_TAG(tag);
}
void
-rb_exc_raise(VALUE mesg)
+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;
{
rb_longjmp(TAG_RAISE, mesg);
}
void
-rb_exc_fatal(VALUE mesg)
+rb_exc_fatal(mesg)
+ VALUE mesg;
{
rb_longjmp(TAG_FATAL, mesg);
}
void
-rb_interrupt(void)
+rb_interrupt()
{
static const char fmt[1] = {'\0'};
rb_raise(rb_eInterrupt, fmt);
}
-static VALUE get_errinfo(void);
-
/*
* call-seq:
* raise
@@ -749,7 +4674,7 @@ static VALUE get_errinfo(void);
* fail
* fail(string)
* fail(exception [, string [, array]])
- *
+ *
* With no arguments, raises the exception in <code>$!</code> or raises
* a <code>RuntimeError</code> if <code>$!</code> is +nil+.
* With a single +String+ argument, raises a
@@ -760,28 +4685,24 @@ static VALUE get_errinfo(void);
* message associated with the exception, and the third parameter is an
* array of callback information. Exceptions are caught by the
* +rescue+ clause of <code>begin...end</code> blocks.
- *
+ *
* raise "Failed to create socket"
* raise ArgumentError, "No parameters", caller
*/
static VALUE
-rb_f_raise(int argc, VALUE *argv)
+rb_f_raise(argc, argv)
+ int argc;
+ VALUE *argv;
{
- VALUE err;
- if (argc == 0) {
- err = get_errinfo();
- if (!NIL_P(err)) {
- argc = 1;
- argv = &err;
- }
- }
rb_raise_jump(rb_make_exception(argc, argv));
return Qnil; /* not reached */
}
-VALUE
-rb_make_exception(int argc, VALUE *argv)
+static VALUE
+rb_make_exception(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE mesg;
ID exception;
@@ -793,8 +4714,7 @@ rb_make_exception(int argc, VALUE *argv)
mesg = Qnil;
break;
case 1:
- if (NIL_P(argv[0]))
- break;
+ if (NIL_P(argv[0])) break;
if (TYPE(argv[0]) == T_STRING) {
mesg = rb_exc_new3(rb_eRuntimeError, argv[0]);
break;
@@ -819,36 +4739,39 @@ rb_make_exception(int argc, VALUE *argv)
if (argc > 0) {
if (!rb_obj_is_kind_of(mesg, rb_eException))
rb_raise(rb_eTypeError, "exception object expected");
- if (argc > 2)
+ if (argc>2)
set_backtrace(mesg, argv[2]);
}
return mesg;
}
-void
-rb_raise_jump(VALUE mesg)
+static void
+rb_raise_jump(mesg)
+ VALUE mesg;
{
- /* TODO: fix me */
+ if (ruby_frame != top_frame) {
+ PUSH_FRAME(); /* fake frame */
+ *ruby_frame = *_frame.prev->prev;
+ rb_longjmp(TAG_RAISE, mesg);
+ POP_FRAME();
+ }
rb_longjmp(TAG_RAISE, mesg);
}
void
-rb_jump_tag(int tag)
+rb_jump_tag(tag)
+ int tag;
{
JUMP_TAG(tag);
}
int
-rb_block_given_p(void)
+rb_block_given_p()
{
- rb_thread_t *th = GET_THREAD();
- if (GC_GUARDED_PTR_REF(th->cfp->lfp[0])) {
+ if (ruby_frame->iter == ITER_CUR && ruby_block)
return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return Qfalse;
}
int
@@ -861,11 +4784,11 @@ rb_iterator_p()
* call-seq:
* block_given? => true or false
* iterator? => true or false
- *
+ *
* Returns <code>true</code> if <code>yield</code> would execute a
* block in the current context. The <code>iterator?</code> form
* is mildly deprecated.
- *
+ *
* def try
* if block_given?
* yield
@@ -879,314 +4802,737 @@ rb_iterator_p()
*/
-VALUE
+static VALUE
rb_f_block_given_p()
{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
- cfp = vm_get_ruby_level_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
- if (GC_GUARDED_PTR_REF(cfp->lfp[0])) {
+ if (ruby_frame->prev && ruby_frame->prev->iter == ITER_CUR && ruby_block)
return Qtrue;
+ return Qfalse;
+}
+
+VALUE rb_eThreadError;
+
+NORETURN(static void proc_jump_error(int, VALUE));
+static void
+proc_jump_error(state, result)
+ int state;
+ VALUE result;
+{
+ char mesg[32];
+ const char *statement;
+
+ switch (state) {
+ case TAG_BREAK:
+ statement = "break"; break;
+ case TAG_RETURN:
+ statement = "return"; break;
+ case TAG_RETRY:
+ statement = "retry"; break;
+ default:
+ statement = "local-jump"; break; /* should not happen */
}
- else {
- return Qfalse;
+ snprintf(mesg, sizeof mesg, "%s from proc-closure", statement);
+ localjump_error(mesg, result, state);
+}
+
+static void
+return_jump(retval)
+ VALUE retval;
+{
+ struct tag *tt = prot_tag;
+ int yield = Qfalse;
+
+ if (retval == Qundef) retval = Qnil;
+ while (tt) {
+ if (tt->tag == PROT_YIELD) {
+ yield = Qtrue;
+ tt = tt->prev;
+ }
+ if (tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) {
+ tt->dst = (VALUE)ruby_frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_RETURN);
+ }
+ if (tt->tag == PROT_LAMBDA && !yield) {
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_RETURN);
+ }
+ if (tt->tag == PROT_THREAD) {
+ rb_raise(rb_eThreadError, "return can't jump across threads");
+ }
+ tt = tt->prev;
}
+ localjump_error("unexpected return", retval, TAG_RETURN);
}
-VALUE rb_eThreadError;
+static void
+break_jump(retval)
+ VALUE retval;
+{
+ struct tag *tt = prot_tag;
+
+ if (retval == Qundef) retval = Qnil;
+ while (tt) {
+ switch (tt->tag) {
+ case PROT_THREAD:
+ case PROT_YIELD:
+ case PROT_LOOP:
+ case PROT_LAMBDA:
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_BREAK);
+ break;
+ case PROT_FUNC:
+ tt = 0;
+ continue;
+ default:
+ break;
+ }
+ tt = tt->prev;
+ }
+ localjump_error("unexpected break", retval, TAG_BREAK);
+}
+
+static void
+next_jump(retval)
+ VALUE retval;
+{
+ struct tag *tt = prot_tag;
+
+ if (retval == Qundef) retval = Qnil;
+ while (tt) {
+ switch (tt->tag) {
+ case PROT_THREAD:
+ case PROT_YIELD:
+ case PROT_LOOP:
+ case PROT_LAMBDA:
+ case PROT_FUNC:
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_NEXT);
+ break;
+ default:
+ break;
+ }
+ tt = tt->prev;
+ }
+ localjump_error("unexpected next", retval, TAG_NEXT);
+}
void
rb_need_block()
{
if (!rb_block_given_p()) {
- vm_localjump_error("no block given", Qnil, 0);
+ localjump_error("no block given", Qnil, 0);
}
}
-static inline VALUE
-rb_yield_0(int argc, VALUE *argv)
+static VALUE
+rb_yield_0(val, self, klass, flags, avalue)
+ VALUE val, self, klass; /* OK */
+ int flags, avalue;
{
- return vm_yield(GET_THREAD(), argc, argv);
-}
+ NODE *node, *var;
+ volatile VALUE result = Qnil;
+ volatile VALUE old_cref;
+ volatile VALUE old_wrapper;
+ struct BLOCK * volatile block;
+ struct SCOPE * volatile old_scope;
+ int old_vmode;
+ struct FRAME frame;
+ NODE *cnode = ruby_current_node;
+ int lambda = flags & YIELD_LAMBDA_CALL;
+ int state;
-VALUE
-rb_yield(VALUE val)
-{
- volatile VALUE tmp = val;
- if (val == Qundef) {
- tmp = rb_yield_0(0, 0);
+ rb_need_block();
+
+ PUSH_VARS();
+ block = ruby_block;
+ frame = block->frame;
+ frame.prev = ruby_frame;
+ frame.node = cnode;
+ ruby_frame = &(frame);
+ old_cref = (VALUE)ruby_cref;
+ ruby_cref = block->cref;
+ old_wrapper = ruby_wrapper;
+ ruby_wrapper = block->wrapper;
+ old_scope = ruby_scope;
+ ruby_scope = block->scope;
+ old_vmode = scope_vmode;
+ scope_vmode = (flags & YIELD_PUBLIC_DEF) ? SCOPE_PUBLIC : block->vmode;
+ ruby_block = block->prev;
+ if (block->flags & BLOCK_D_SCOPE) {
+ /* put place holder for dynamic (in-block) local variables */
+ ruby_dyna_vars = new_dvar(0, 0, block->dyna_vars);
}
else {
- tmp = rb_yield_0(1, &val);
+ /* FOR does not introduce new scope */
+ ruby_dyna_vars = block->dyna_vars;
}
- return tmp;
+ PUSH_CLASS(klass ? klass : block->klass);
+ if (!klass) {
+ self = block->self;
+ }
+ node = block->body;
+ var = block->var;
+
+ if (var) {
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ NODE *bvar = NULL;
+ block_var:
+ if (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) {
+ 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) {
+ if (!avalue) {
+ val = svalue_to_mrhs(val, var->nd_head);
+ }
+ massign(self, var, val, lambda);
+ }
+ else {
+ int len = 0;
+ if (avalue) {
+ len = RARRAY(val)->len;
+ if (len == 0) {
+ goto zero_arg;
+ }
+ if (len == 1) {
+ val = RARRAY(val)->ptr[0];
+ }
+ else {
+ goto multi_values;
+ }
+ }
+ else if (val == Qundef) {
+ zero_arg:
+ val = Qnil;
+ multi_values:
+ {
+ ruby_current_node = 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);
+ }
+ }
+ POP_TAG();
+ if (state) goto pop_state;
+ }
+ if (!node) {
+ state = 0;
+ goto pop_state;
+ }
+ ruby_current_node = node;
+
+ PUSH_ITER(block->iter);
+ PUSH_TAG(lambda ? PROT_NONE : PROT_YIELD);
+ 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 (!avalue) {
+ val = svalue_to_avalue(val);
+ }
+ break;
+ default:
+ if (avalue) {
+ val = avalue_to_svalue(val);
+ }
+ if (val == Qundef && node->nd_state != YIELD_FUNC_SVALUE)
+ val = Qnil;
+ }
+ result = (*node->nd_cfnc)(val, node->nd_tval, self);
+ }
+ else {
+ result = rb_eval(self, node);
+ }
+ }
+ else {
+ switch (state) {
+ case TAG_REDO:
+ state = 0;
+ CHECK_INTS;
+ goto redo;
+ case TAG_NEXT:
+ if (!lambda) {
+ state = 0;
+ result = prot_tag->retval;
+ }
+ break;
+ case TAG_BREAK:
+ if (TAG_DST()) {
+ result = prot_tag->retval;
+ }
+ else {
+ lambda = Qtrue; /* just pass TAG_BREAK */
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ POP_TAG();
+ POP_ITER();
+ pop_state:
+ POP_CLASS();
+ if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
+ !FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE)) {
+ struct RVarmap *vars = ruby_dyna_vars;
+
+ if (ruby_dyna_vars->id == 0) {
+ vars = ruby_dyna_vars->next;
+ rb_gc_force_recycle((VALUE)ruby_dyna_vars);
+ while (vars && vars->id != 0 && vars != block->dyna_vars) {
+ struct RVarmap *tmp = vars->next;
+ rb_gc_force_recycle((VALUE)vars);
+ vars = tmp;
+ }
+ }
+ }
+ POP_VARS();
+ ruby_block = block;
+ ruby_frame = ruby_frame->prev;
+ ruby_cref = (NODE*)old_cref;
+ ruby_wrapper = old_wrapper;
+ if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
+ scope_dup(old_scope);
+ ruby_scope = old_scope;
+ scope_vmode = old_vmode;
+ switch (state) {
+ case 0:
+ break;
+ case TAG_BREAK:
+ if (!lambda) {
+ struct tag *tt = prot_tag;
+
+ while (tt) {
+ if (tt->tag == PROT_LOOP && tt->blkid == ruby_block->uniq) {
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = result;
+ JUMP_TAG(TAG_BREAK);
+ }
+ tt = tt->prev;
+ }
+ proc_jump_error(TAG_BREAK, result);
+ }
+ /* fall through */
+ default:
+ JUMP_TAG(state);
+ break;
+ }
+ ruby_current_node = cnode;
+ return result;
}
VALUE
+rb_yield(val)
+ VALUE val;
+{
+ return rb_yield_0(val, 0, 0, 0, Qfalse);
+}
+
+VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
rb_yield_values(int n, ...)
+#else
+rb_yield_values(n, va_alist)
+ int n;
+ va_dcl
+#endif
{
- int i;
- VALUE *argv;
va_list args;
+ VALUE ary;
if (n == 0) {
- return rb_yield_0(0, 0);
+ return rb_yield_0(Qundef, 0, 0, 0, Qfalse);
}
-
- argv = ALLOCA_N(VALUE, n);
-
+ ary = rb_ary_new2(n);
va_init_list(args, n);
- for (i=0; i<n; i++) {
- argv[i] = va_arg(args, VALUE);
+ while (n--) {
+ rb_ary_push(ary, va_arg(args, VALUE));
}
va_end(args);
-
- return rb_yield_0(n, argv);
+ return rb_yield_0(ary, 0, 0, 0, Qtrue);
}
VALUE
-rb_yield_values2(int argc, VALUE *argv)
+rb_yield_splat(values)
+ VALUE values;
{
- return rb_yield_0(argc, argv);
-}
+ int avalue = Qfalse;
-VALUE
-rb_yield_splat(VALUE values)
-{
- VALUE tmp = rb_check_array_type(values);
- volatile VALUE v;
- if (NIL_P(tmp)) {
- rb_raise(rb_eArgError, "not an array");
+ if (TYPE(values) == T_ARRAY) {
+ if (RARRAY(values)->len == 0) {
+ values = Qundef;
+ }
+ else {
+ avalue = Qtrue;
+ }
}
- v = rb_yield_0(RARRAY_LEN(tmp), RARRAY_PTR(tmp));
- return v;
+ return rb_yield_0(values, 0, 0, 0, avalue);
}
static VALUE
loop_i()
{
for (;;) {
- rb_yield_0(0, 0);
+ rb_yield_0(Qundef, 0, 0, 0, Qfalse);
+ CHECK_INTS;
}
return Qnil;
}
/*
* call-seq:
- * loop {|| block }
- *
+ * loop {|| block }
+ *
* Repeatedly executes the block.
- *
+ *
* loop do
* print "Input: "
* line = gets
* break if !line or line =~ /^qQ/
* # ...
* end
+ *
+ * StopIteration raised in the block breaks the loop.
*/
static VALUE
-rb_f_loop(void)
+rb_f_loop()
{
rb_rescue2(loop_i, (VALUE)0, 0, 0, rb_eStopIteration, (VALUE)0);
return Qnil; /* dummy */
}
-VALUE
-rb_iterate(VALUE (*it_proc) (VALUE), VALUE data1,
- VALUE (*bl_proc) (ANYARGS), VALUE data2)
+static VALUE
+massign(self, node, val, pcall)
+ VALUE self;
+ NODE *node;
+ VALUE val;
+ int pcall;
{
- int state;
- volatile VALUE retval = Qnil;
- NODE *node = NEW_IFUNC(bl_proc, data2);
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
-
- TH_PUSH_TAG(th);
- state = TH_EXEC_TAG();
- if (state == 0) {
- iter_retry:
- {
- rb_block_t *blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
- blockptr->iseq = (void *)node;
- blockptr->proc = 0;
- th->passed_block = blockptr;
+ NODE *list;
+ long i = 0, len;
+
+ len = RARRAY(val)->len;
+ list = node->nd_head;
+ for (; list && i<len; i++) {
+ assign(self, list->nd_head, RARRAY(val)->ptr[i], pcall);
+ list = list->nd_next;
+ }
+ if (pcall && list) goto arg_error;
+ if (node->nd_args) {
+ if ((long)(node->nd_args) == -1) {
+ /* no check for mere `*' */
+ }
+ else if (!list && i<len) {
+ assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), pcall);
+ }
+ else {
+ assign(self, node->nd_args, rb_ary_new2(0), pcall);
}
- retval = (*it_proc) (data1);
}
- else {
- VALUE err = th->errinfo;
- if (state == TAG_BREAK) {
- VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
- VALUE *cdfp = cfp->dfp;
+ else if (pcall && i < len) {
+ goto arg_error;
+ }
- if (cdfp == escape_dfp) {
- state = 0;
- th->state = 0;
- th->errinfo = Qnil;
- th->cfp = cfp;
- }
- else{
- /* SDR(); printf("%p, %p\n", cdfp, escape_dfp); */
- }
+ while (list) {
+ i++;
+ assign(self, list->nd_head, Qnil, pcall);
+ list = list->nd_next;
+ }
+ return val;
+
+ arg_error:
+ while (list) {
+ i++;
+ list = list->nd_next;
+ }
+ rb_raise(rb_eArgError, "wrong number of arguments (%ld for %ld)", len, i);
+}
+
+static void
+assign(self, lhs, val, pcall)
+ VALUE self;
+ NODE *lhs;
+ VALUE val;
+ int pcall;
+{
+ ruby_current_node = lhs;
+ if (val == Qundef) {
+ rb_warning("assigning void value");
+ val = Qnil;
+ }
+ switch (nd_type(lhs)) {
+ case NODE_GASGN:
+ rb_gvar_set(lhs->nd_entry, val);
+ break;
+
+ case NODE_IASGN:
+ rb_ivar_set(self, lhs->nd_vid, val);
+ break;
+
+ case NODE_LASGN:
+ if (ruby_scope->local_vars == 0)
+ rb_bug("unexpected local variable assignment");
+ ruby_scope->local_vars[lhs->nd_cnt] = val;
+ break;
+
+ case NODE_DASGN:
+ dvar_asgn(lhs->nd_vid, val);
+ break;
+
+ case NODE_DASGN_CURR:
+ dvar_asgn_curr(lhs->nd_vid, val);
+ break;
+
+ case NODE_CDECL:
+ if (lhs->nd_vid == 0) {
+ rb_const_set(class_prefix(self, lhs->nd_else), lhs->nd_else->nd_mid, val);
+ }
+ else {
+ rb_const_set(ruby_cbase, lhs->nd_vid, val);
+ }
+ break;
+
+ case NODE_CVDECL:
+ if (RTEST(ruby_verbose) && FL_TEST(ruby_cbase, FL_SINGLETON)) {
+ rb_warn("declaring singleton class variable");
}
- else if (state == TAG_RETRY) {
- VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
- VALUE *cdfp = cfp->dfp;
+ rb_cvar_set(cvar_cbase(), lhs->nd_vid, val, Qtrue);
+ break;
- if (cdfp == escape_dfp) {
- state = 0;
- th->state = 0;
- th->errinfo = Qnil;
- th->cfp = cfp;
- goto iter_retry;
+ case NODE_CVASGN:
+ rb_cvar_set(cvar_cbase(), lhs->nd_vid, val, Qfalse);
+ break;
+
+ case NODE_MASGN:
+ massign(self, lhs, svalue_to_mrhs(val, lhs->nd_head), pcall);
+ break;
+
+ case NODE_CALL:
+ case NODE_ATTRASGN:
+ {
+ VALUE recv;
+ int scope;
+ if (lhs->nd_recv == (NODE *)1) {
+ recv = self;
+ scope = 1;
+ }
+ else {
+ recv = rb_eval(self, lhs->nd_recv);
+ scope = 0;
+ }
+ if (!lhs->nd_args) {
+ /* attr set */
+ ruby_current_node = lhs;
+ SET_CURRENT_SOURCE();
+ rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, scope, self);
+ }
+ else {
+ /* array set */
+ VALUE args;
+
+ args = rb_eval(self, lhs->nd_args);
+ rb_ary_push(args, val);
+ ruby_current_node = lhs;
+ SET_CURRENT_SOURCE();
+ rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
+ RARRAY(args)->len, RARRAY(args)->ptr, scope, self);
}
}
+ break;
+
+ default:
+ rb_bug("bug in variable assignment");
+ break;
}
- TH_POP_TAG();
+}
+
+VALUE
+rb_iterate(it_proc, data1, bl_proc, data2)
+ VALUE (*it_proc) _((VALUE)), (*bl_proc)(ANYARGS);
+ VALUE data1, data2;
+{
+ int state;
+ volatile VALUE retval = Qnil;
+ NODE *node = NEW_IFUNC(bl_proc, data2);
+ VALUE self = ruby_top_self;
+
+ PUSH_TAG(PROT_LOOP);
+ PUSH_BLOCK(0, node);
+ PUSH_ITER(ITER_PRE);
+ state = EXEC_TAG();
+ if (state == 0) {
+ iter_retry:
+ retval = (*it_proc)(data1);
+ }
+ else if (state == TAG_BREAK && TAG_DST()) {
+ retval = prot_tag->retval;
+ state = 0;
+ }
+ else if (state == TAG_RETRY) {
+ state = 0;
+ goto iter_retry;
+ }
+ POP_ITER();
+ POP_BLOCK();
+ POP_TAG();
switch (state) {
case 0:
break;
default:
- TH_JUMP_TAG(th, state);
+ JUMP_TAG(state);
}
return retval;
}
-struct iter_method_arg {
- VALUE obj;
- ID mid;
- int argc;
- VALUE *argv;
-};
-
-static VALUE
-iterate_method(VALUE obj)
+static int
+handle_rescue(self, node)
+ VALUE self;
+ NODE *node;
{
- struct iter_method_arg *arg;
-
- arg = (struct iter_method_arg *)obj;
- return rb_call(CLASS_OF(arg->obj), arg->obj, arg->mid,
- arg->argc, arg->argv, NOEX_PRIVATE);
-}
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ TMP_PROTECT;
-VALUE
-rb_block_call(VALUE obj, ID mid, int argc, VALUE *argv,
- VALUE (*bl_proc) (ANYARGS), VALUE data2)
-{
- struct iter_method_arg arg;
+ if (!node->nd_args) {
+ return rb_obj_is_kind_of(ruby_errinfo, rb_eStandardError);
+ }
- arg.obj = obj;
- arg.mid = mid;
- arg.argc = argc;
- arg.argv = argv;
- return rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2);
-}
+ BEGIN_CALLARGS;
+ SETUP_ARGS(node->nd_args);
+ END_CALLARGS;
-VALUE
-rb_each(VALUE obj)
-{
- return rb_call(CLASS_OF(obj), obj, rb_intern("each"), 0, 0,
- NOEX_PRIVATE);
+ while (argc--) {
+ if (!rb_obj_is_kind_of(argv[0], rb_cModule)) {
+ rb_raise(rb_eTypeError, "class or module required for rescue clause");
+ }
+ if (RTEST(rb_funcall(*argv, eqq, 1, ruby_errinfo))) return 1;
+ argv++;
+ }
+ return 0;
}
VALUE
-rb_rescue2(VALUE (*b_proc) (ANYARGS), VALUE data1, VALUE (*r_proc) (ANYARGS),
- VALUE data2, ...)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_rescue2(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS), VALUE data2, ...)
+#else
+rb_rescue2(b_proc, data1, r_proc, data2, va_alist)
+ VALUE (*b_proc)(ANYARGS), (*r_proc)(ANYARGS);
+ VALUE data1, data2;
+ va_dcl
+#endif
{
int state;
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
volatile VALUE result;
- volatile VALUE e_info = th->errinfo;
+ volatile VALUE e_info = ruby_errinfo;
+ volatile int handle = Qfalse;
+ VALUE eclass;
va_list args;
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- retry_entry:
- result = (*b_proc) (data1);
- }
- else {
- th->cfp = cfp; /* restore */
-
- if (state == TAG_RAISE) {
- int handle = Qfalse;
- VALUE eclass;
-
- va_init_list(args, data2);
- while ((eclass = va_arg(args, VALUE)) != 0) {
- if (rb_obj_is_kind_of(th->errinfo, eclass)) {
- handle = Qtrue;
- break;
- }
+ PUSH_TAG(PROT_NONE);
+ switch (state = EXEC_TAG()) {
+ case TAG_RETRY:
+ if (!handle) break;
+ handle = Qfalse;
+ state = 0;
+ ruby_errinfo = Qnil;
+ case 0:
+ result = (*b_proc)(data1);
+ break;
+ case TAG_RAISE:
+ if (handle) break;
+ handle = Qfalse;
+ va_init_list(args, data2);
+ while ((eclass = va_arg(args, VALUE)) != 0) {
+ if (rb_obj_is_kind_of(ruby_errinfo, eclass)) {
+ handle = Qtrue;
+ break;
}
- va_end(args);
+ }
+ va_end(args);
- if (handle) {
- if (r_proc) {
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- result = (*r_proc) (data2, th->errinfo);
- }
- POP_TAG();
- if (state == TAG_RETRY) {
- state = 0;
- th->errinfo = Qnil;
- goto retry_entry;
- }
- }
- else {
- result = Qnil;
- state = 0;
- }
- if (state == 0) {
- th->errinfo = e_info;
- }
+ if (handle) {
+ state = 0;
+ if (r_proc) {
+ result = (*r_proc)(data2, ruby_errinfo);
+ }
+ else {
+ result = Qnil;
}
+ ruby_errinfo = e_info;
}
}
POP_TAG();
- if (state)
- JUMP_TAG(state);
+ if (state) JUMP_TAG(state);
return result;
}
VALUE
-rb_rescue(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS), VALUE data2)
+rb_rescue(b_proc, data1, r_proc, data2)
+ VALUE (*b_proc)(), (*r_proc)();
+ VALUE data1, data2;
{
- return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError,
- (VALUE)0);
+ return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError, (VALUE)0);
}
+static VALUE cont_protect;
+
VALUE
-rb_protect(VALUE (*proc) (VALUE), VALUE data, int *state)
+rb_protect(proc, data, state)
+ VALUE (*proc) _((VALUE));
+ VALUE data;
+ int *state;
{
VALUE result = Qnil; /* OK */
int status;
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
- struct rb_vm_trap_tag trap_tag;
- rb_jmpbuf_t org_jmpbuf;
- trap_tag.prev = th->trap_tag;
-
- PUSH_TAG();
- th->trap_tag = &trap_tag;
- MEMCPY(&org_jmpbuf, &(th)->root_jmpbuf, rb_jmpbuf_t, 1);
+ PUSH_TAG(PROT_NONE);
+ cont_protect = (VALUE)rb_node_newnode(NODE_MEMO, cont_protect, 0, 0);
if ((status = EXEC_TAG()) == 0) {
- SAVE_ROOT_JMPBUF(th, result = (*proc) (data));
+ result = (*proc)(data);
}
- MEMCPY(&(th)->root_jmpbuf, &org_jmpbuf, rb_jmpbuf_t, 1);
- th->trap_tag = trap_tag.prev;
+ cont_protect = ((NODE *)cont_protect)->u1.value;
POP_TAG();
-
if (state) {
*state = status;
}
if (status != 0) {
- th->cfp = cfp;
return Qnil;
}
@@ -1194,26 +5540,34 @@ rb_protect(VALUE (*proc) (VALUE), VALUE data, int *state)
}
VALUE
-rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE data2)
+rb_ensure(b_proc, data1, e_proc, data2)
+ VALUE (*b_proc)();
+ VALUE data1;
+ VALUE (*e_proc)();
+ VALUE data2;
{
int state;
volatile VALUE result = Qnil;
+ VALUE retval;
- PUSH_TAG();
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- result = (*b_proc) (data1);
+ result = (*b_proc)(data1);
}
POP_TAG();
- /* TODO: fix me */
- /* retval = prot_tag ? prot_tag->retval : Qnil; */ /* save retval */
- (*e_proc) (data2);
- if (state)
- JUMP_TAG(state);
+ 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;
}
VALUE
-rb_with_disable_interrupt(VALUE (*proc)(ANYARGS), VALUE data)
+rb_with_disable_interrupt(proc, data)
+ VALUE (*proc)();
+ VALUE data;
{
VALUE result = Qnil; /* OK */
int status;
@@ -1223,55 +5577,51 @@ rb_with_disable_interrupt(VALUE (*proc)(ANYARGS), VALUE data)
int thr_critical = rb_thread_critical;
rb_thread_critical = Qtrue;
- PUSH_TAG();
+ PUSH_TAG(PROT_NONE);
if ((status = EXEC_TAG()) == 0) {
- result = (*proc) (data);
+ result = (*proc)(data);
}
POP_TAG();
rb_thread_critical = thr_critical;
}
ENABLE_INTS;
- if (status)
- JUMP_TAG(status);
+ if (status) JUMP_TAG(status);
return result;
}
-static inline void
-stack_check(void)
+static void
+stack_check()
{
- static int overflowing = 0;
+ rb_thread_t th = rb_curr_thread;
- if (!overflowing && ruby_stack_check()) {
- int state;
- overflowing = 1;
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- rb_exc_raise(sysstack_error);
- }
- POP_TAG();
- overflowing = 0;
- JUMP_TAG(state);
+ if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) && ruby_stack_check()) {
+ rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
+ rb_exc_raise(sysstack_error);
}
}
+static int last_call_status;
+
+#define CSTAT_PRIV 1
+#define CSTAT_PROT 2
+#define CSTAT_VCALL 4
+#define CSTAT_SUPER 8
+
/*
* call-seq:
* obj.method_missing(symbol [, *args] ) => result
- *
+ *
* Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
* <i>symbol</i> is the symbol for the method called, and <i>args</i>
* are any arguments that were passed to it. By default, the interpreter
* raises an error when this method is called. However, it is possible
* to override the method to provide more dynamic behavior.
- * If it is decided that a particular method should not be handled, then
- * <i>super</i> should be called, so that ancestors can pick up the
- * missing method.
* The example below creates
* a class <code>Roman</code>, which responds to methods with names
* consisting of roman numerals, returning the corresponding integer
* values.
- *
+ *
* class Roman
* def romanToInt(str)
* # ...
@@ -1281,7 +5631,7 @@ stack_check(void)
* romanToInt(str)
* end
* end
- *
+ *
* r = Roman.new
* r.iv #=> 4
* r.xxiii #=> 23
@@ -1289,13 +5639,16 @@ stack_check(void)
*/
static VALUE
-rb_method_missing(int argc, const VALUE *argv, VALUE obj)
+rb_method_missing(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
ID id;
VALUE exc = rb_eNoMethodError;
- char *format = 0;
- rb_thread_t *th = GET_THREAD();
- int last_call_status = th->method_missing_reason;
+ const char *format = 0;
+ NODE *cnode = ruby_current_node;
+
if (argc == 0 || !SYMBOL_P(argv[0])) {
rb_raise(rb_eArgError, "no id given");
}
@@ -1304,35 +5657,36 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
id = SYM2ID(argv[0]);
- if (last_call_status & NOEX_PRIVATE) {
+ if (last_call_status & CSTAT_PRIV) {
format = "private method `%s' called for %s";
}
- else if (last_call_status & NOEX_PROTECTED) {
+ else if (last_call_status & CSTAT_PROT) {
format = "protected method `%s' called for %s";
}
- else if (last_call_status & NOEX_VCALL) {
+ else if (last_call_status & CSTAT_VCALL) {
format = "undefined local variable or method `%s' for %s";
exc = rb_eNameError;
}
- else if (last_call_status & NOEX_SUPER) {
- format = "super: no superclass method `%s' for %s";
+ else if (last_call_status & CSTAT_SUPER) {
+ format = "super: no superclass method `%s'";
}
if (!format) {
format = "undefined method `%s' for %s";
}
+ ruby_current_node = cnode;
{
int n = 0;
VALUE args[3];
+
args[n++] = rb_funcall(rb_const_get(exc, rb_intern("message")), '!',
3, rb_str_new2(format), obj, argv[0]);
args[n++] = argv[0];
if (exc == rb_eNoMethodError) {
- args[n++] = rb_ary_new4(argc - 1, argv + 1);
+ args[n++] = rb_ary_new4(argc-1, argv+1);
}
exc = rb_class_new_instance(n, args, exc);
-
- th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
+ ruby_frame = ruby_frame->prev; /* pop frame for "method_missing" */
rb_exc_raise(exc);
}
@@ -1340,155 +5694,489 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
}
static VALUE
-method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status)
+method_missing(obj, id, argc, argv, call_status)
+ VALUE obj;
+ ID id;
+ int argc;
+ const VALUE *argv;
+ int call_status;
{
VALUE *nargv;
- GET_THREAD()->method_missing_reason = call_status;
+
+ last_call_status = call_status;
if (id == missing) {
+ PUSH_FRAME();
rb_method_missing(argc, argv, obj);
+ POP_FRAME();
}
else if (id == ID_ALLOCATOR) {
- rb_raise(rb_eTypeError, "allocator undefined for %s",
- rb_class2name(obj));
+ rb_raise(rb_eTypeError, "allocator undefined for %s", rb_class2name(obj));
}
+ if (argc < 0) {
+ VALUE tmp;
- nargv = ALLOCA_N(VALUE, argc + 1);
+ argc = -argc-1;
+ tmp = splat_value(argv[argc]);
+ nargv = ALLOCA_N(VALUE, argc + RARRAY(tmp)->len + 1);
+ MEMCPY(nargv+1, argv, VALUE, argc);
+ MEMCPY(nargv+1+argc, RARRAY(tmp)->ptr, VALUE, RARRAY(tmp)->len);
+ argc += RARRAY(tmp)->len;
+ }
+ else {
+ nargv = ALLOCA_N(VALUE, argc+1);
+ MEMCPY(nargv+1, argv, VALUE, argc);
+ }
nargv[0] = ID2SYM(id);
- MEMCPY(nargv + 1, argv, VALUE, argc);
+ return rb_funcall2(obj, missing, argc+1, nargv);
+}
+
+static inline VALUE
+call_cfunc(func, recv, len, argc, argv)
+ VALUE (*func)();
+ VALUE recv;
+ int len, argc;
+ VALUE *argv;
+{
+ if (len >= 0 && argc != len) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
+ argc, len);
+ }
+
+ switch (len) {
+ case -2:
+ return (*func)(recv, rb_ary_new4(argc, argv));
+ break;
+ case -1:
+ return (*func)(argc, argv, recv);
+ break;
+ case 0:
+ return (*func)(recv);
+ break;
+ case 1:
+ return (*func)(recv, argv[0]);
+ break;
+ case 2:
+ return (*func)(recv, argv[0], argv[1]);
+ break;
+ case 3:
+ return (*func)(recv, argv[0], argv[1], argv[2]);
+ break;
+ case 4:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3]);
+ break;
+ case 5:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4]);
+ break;
+ case 6:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5]);
+ break;
+ case 7:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6]);
+ break;
+ case 8:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7]);
+ break;
+ case 9:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8]);
+ break;
+ case 10:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8], argv[9]);
+ break;
+ case 11:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]);
+ break;
+ case 12:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8], argv[9],
+ argv[10], argv[11]);
+ break;
+ case 13:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
+ argv[11], argv[12]);
+ break;
+ case 14:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
+ argv[11], argv[12], argv[13]);
+ break;
+ case 15:
+ return (*func)(recv, argv[0], argv[1], argv[2], argv[3], argv[4],
+ argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
+ argv[11], argv[12], argv[13], argv[14]);
+ break;
+ default:
+ rb_raise(rb_eArgError, "too many arguments (%d)", len);
+ break;
+ }
+ return Qnil; /* not reached */
+}
- return rb_funcall2(obj, missing, argc + 1, nargv);
+static VALUE
+rb_call0(klass, recv, id, oid, argc, argv, body, flags)
+ VALUE klass, recv;
+ ID id;
+ ID oid;
+ int argc; /* OK */
+ VALUE *argv; /* OK */
+ NODE * volatile body;
+ int flags;
+{
+ NODE *b2; /* OK */
+ volatile VALUE result = Qnil;
+ int itr;
+ static int tick;
+ TMP_PROTECT;
+ volatile int safe = -1;
+
+ if (NOEX_SAFE(flags) > ruby_safe_level && NOEX_SAFE(flags) > 2) {
+ rb_raise(rb_eSecurityError, "calling insecure method: %s",
+ rb_id2name(id));
+ }
+ switch (ruby_iter->iter) {
+ case ITER_PRE:
+ case ITER_PAS:
+ itr = ITER_CUR;
+ break;
+ case ITER_CUR:
+ default:
+ itr = ITER_NOT;
+ break;
+ }
+
+ if ((++tick & 0xff) == 0) {
+ CHECK_INTS; /* better than nothing */
+ stack_check();
+ rb_gc_finalize_deferred();
+ }
+ if (argc < 0) {
+ VALUE tmp;
+ VALUE *nargv;
+
+ argc = -argc-1;
+ tmp = splat_value(argv[argc]);
+ nargv = TMP_ALLOC(argc + RARRAY(tmp)->len);
+ MEMCPY(nargv, argv, VALUE, argc);
+ MEMCPY(nargv+argc, RARRAY(tmp)->ptr, VALUE, RARRAY(tmp)->len);
+ argc += RARRAY(tmp)->len;
+ argv = nargv;
+ }
+ PUSH_ITER(itr);
+ PUSH_FRAME();
+
+ ruby_frame->last_func = id;
+ ruby_frame->orig_func = oid;
+ ruby_frame->last_class = (flags & NOEX_NOSUPER)?0:klass;
+ ruby_frame->self = recv;
+ ruby_frame->argc = argc;
+ ruby_frame->flags = 0;
+
+ switch (nd_type(body)) {
+ case NODE_CFUNC:
+ {
+ int len = body->nd_argc;
+
+ if (len < -2) {
+ rb_bug("bad argc (%d) specified for `%s(%s)'",
+ len, rb_class2name(klass), rb_id2name(id));
+ }
+ if (event_hooks) {
+ int state;
+
+ EXEC_EVENT_HOOK(RUBY_EVENT_C_CALL, ruby_current_node,
+ recv, id, klass);
+ PUSH_TAG(PROT_FUNC);
+ if ((state = EXEC_TAG()) == 0) {
+ result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
+ }
+ POP_TAG();
+ ruby_current_node = ruby_frame->node;
+ EXEC_EVENT_HOOK(RUBY_EVENT_C_RETURN, ruby_current_node,
+ recv, id, klass);
+ if (state) JUMP_TAG(state);
+ }
+ else {
+ result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
+ }
+ }
+ break;
+
+ /* for attr get/set */
+ case NODE_IVAR:
+ if (argc != 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ result = rb_attr_get(recv, body->nd_vid);
+ break;
+
+ case NODE_ATTRSET:
+ if (argc != 1)
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
+ result = rb_ivar_set(recv, body->nd_vid, argv[0]);
+ break;
+
+ case NODE_ZSUPER:
+ result = rb_call_super(argc, argv);
+ break;
+
+ case NODE_DMETHOD:
+ result = method_call(argc, argv, umethod_bind(body->nd_cval, recv));
+ break;
+
+ case NODE_BMETHOD:
+ ruby_frame->flags |= FRAME_DMETH;
+ if (event_hooks) {
+ struct BLOCK *data;
+ Data_Get_Struct(body->nd_cval, struct BLOCK, data);
+ EXEC_EVENT_HOOK(RUBY_EVENT_CALL, data->body, recv, id, klass);
+ }
+ 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);
+ }
+ break;
+
+ case NODE_SCOPE:
+ {
+ int state;
+ VALUE *local_vars; /* OK */
+ NODE *saved_cref = 0;
+
+ PUSH_SCOPE();
+ if (body->nd_rval) {
+ saved_cref = ruby_cref;
+ ruby_cref = (NODE*)body->nd_rval;
+ }
+ PUSH_CLASS(ruby_cbase);
+ if (body->nd_tbl) {
+ local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
+ *local_vars++ = (VALUE)body;
+ rb_mem_clear(local_vars, body->nd_tbl[0]);
+ ruby_scope->local_tbl = body->nd_tbl;
+ ruby_scope->local_vars = local_vars;
+ }
+ else {
+ local_vars = ruby_scope->local_vars = 0;
+ ruby_scope->local_tbl = 0;
+ }
+ b2 = body = body->nd_next;
+
+ if (NOEX_SAFE(flags) > ruby_safe_level) {
+ safe = ruby_safe_level;
+ ruby_safe_level = NOEX_SAFE(flags);
+ }
+ PUSH_VARS();
+ PUSH_TAG(PROT_FUNC);
+ if ((state = EXEC_TAG()) == 0) {
+ NODE *node = 0;
+ int i, nopt = 0;
+
+ if (nd_type(body) == NODE_ARGS) {
+ node = body;
+ body = 0;
+ }
+ else if (nd_type(body) == NODE_BLOCK) {
+ node = body->nd_head;
+ body = body->nd_next;
+ }
+ if (node) {
+ if (nd_type(node) != NODE_ARGS) {
+ rb_bug("no argument-node");
+ }
+
+ i = node->nd_cnt;
+ if (i > argc) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
+ argc, i);
+ }
+ if (!node->nd_rest) {
+ NODE *optnode = node->nd_opt;
+
+ nopt = i;
+ while (optnode) {
+ nopt++;
+ optnode = optnode->nd_next;
+ }
+ if (nopt < argc) {
+ rb_raise(rb_eArgError,
+ "wrong number of arguments (%d for %d)",
+ argc, nopt);
+ }
+ }
+ if (local_vars) {
+ if (i > 0) {
+ /* +2 for $_ and $~ */
+ MEMCPY(local_vars+2, argv, VALUE, i);
+ }
+ }
+ argv += i; argc -= i;
+ if (node->nd_opt) {
+ NODE *opt = node->nd_opt;
+
+ 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 {
+ VALUE v;
+
+ if (argc > 0) {
+ v = rb_ary_new4(argc,argv);
+ i = -i - 1;
+ }
+ else {
+ v = rb_ary_new2(0);
+ }
+ assign(recv, node->nd_rest, v, 1);
+ }
+ ruby_frame->argc = i;
+ }
+ if (event_hooks) {
+ EXEC_EVENT_HOOK(RUBY_EVENT_CALL, b2, recv, id, klass);
+ }
+ result = rb_eval(recv, body);
+ }
+ else if (state == TAG_RETURN && TAG_DST()) {
+ result = prot_tag->retval;
+ state = 0;
+ }
+ POP_TAG();
+ if (event_hooks) {
+ EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, ruby_current_node, recv, id, klass);
+ }
+ POP_VARS();
+ POP_CLASS();
+ POP_SCOPE();
+ ruby_cref = saved_cref;
+ if (safe >= 0) ruby_safe_level = safe;
+ switch (state) {
+ case 0:
+ break;
+
+ case TAG_BREAK:
+ case TAG_RETURN:
+ JUMP_TAG(state);
+ break;
+
+ case TAG_RETRY:
+ if (rb_block_given_p()) JUMP_TAG(state);
+ /* fall through */
+ default:
+ jump_tag_but_local_jump(state, result);
+ break;
+ }
+ }
+ break;
+
+ default:
+ unknown_node(body);
+ break;
+ }
+ POP_FRAME();
+ POP_ITER();
+ return result;
}
static VALUE
-rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope, VALUE self)
+rb_call(klass, recv, mid, argc, argv, scope, self)
+ VALUE klass, recv;
+ ID mid;
+ int argc; /* OK */
+ const VALUE *argv; /* OK */
+ int scope;
+ VALUE self;
{
- NODE *body, *method;
- int noex;
- ID id = mid;
+ NODE *body; /* OK */
+ int noex;
+ ID id = mid;
struct cache_entry *ent;
- rb_thread_t *th = GET_THREAD();
if (!klass) {
- rb_raise(rb_eNotImpError,
- "method `%s' called on terminated object (%p)",
- rb_id2name(mid), (void *)recv);
+ rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
+ rb_id2name(mid), recv);
}
/* is it in the method cache? */
ent = cache + EXPR1(klass, mid);
-
if (ent->mid == mid && ent->klass == klass) {
if (!ent->method)
- return method_missing(recv, mid, argc, argv,
- scope == 2 ? NOEX_VCALL : 0);
- id = ent->mid0;
- noex = ent->method->nd_noex;
- klass = ent->method->nd_clss;
- body = ent->method->nd_body;
- }
- else if ((method = rb_get_method_body(klass, id, &id)) != 0) {
- noex = method->nd_noex;
- klass = method->nd_clss;
- body = method->nd_body;
+ return method_missing(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
+ klass = ent->origin;
+ id = ent->mid0;
+ noex = ent->noex;
+ body = ent->method;
}
- else {
+ else if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
if (scope == 3) {
- return method_missing(recv, mid, argc, argv, NOEX_SUPER);
+ return method_missing(recv, mid, argc, argv, CSTAT_SUPER);
}
- return method_missing(recv, mid, argc, argv,
- scope == 2 ? NOEX_VCALL : 0);
+ return method_missing(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
}
-
- if (mid != missing) {
+ if (mid != missing && scope == 0) {
/* receiver specified form for private method */
- if (UNLIKELY(noex)) {
- if (((noex & NOEX_MASK) & NOEX_PRIVATE) && scope == 0) {
- return method_missing(recv, mid, argc, argv, NOEX_PRIVATE);
- }
+ if (noex & NOEX_PRIVATE)
+ return method_missing(recv, mid, argc, argv, CSTAT_PRIV);
- /* self must be kind of a specified form for protected method */
- if (((noex & NOEX_MASK) & NOEX_PROTECTED) && scope == 0) {
- VALUE defined_class = klass;
-
- if (TYPE(defined_class) == T_ICLASS) {
- defined_class = RBASIC(defined_class)->klass;
- }
-
- if (!rb_obj_is_kind_of(self, rb_class_real(defined_class))) {
- return method_missing(recv, mid, argc, argv, NOEX_PROTECTED);
- }
- }
+ /* self must be kind of a specified form for protected method */
+ if (noex & NOEX_PROTECTED) {
+ VALUE defined_class = klass;
- if (NOEX_SAFE(noex) > th->safe_level) {
- rb_raise(rb_eSecurityError, "calling insecure method: %s", rb_id2name(mid));
+ 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)))
+ return method_missing(recv, mid, argc, argv, CSTAT_PROT);
}
}
- {
- VALUE val;
- /*
- //static int level;
- //int i;
- //for(i=0; i<level; i++){printf(" ");}
- //printf("invoke %s (%s)\n", rb_id2name(mid), ruby_node_name(nd_type(body)));
- //level++;
- //printf("%s with %d args\n", rb_id2name(mid), argc);
- */
- val = vm_call0(th, klass, recv, mid, id, argc, argv, body,
- noex & NOEX_NOSUPER);
- /*
- //level--;
- //for(i=0; i<level; i++){printf(" ");}
- //printf("done %s (%s)\n", rb_id2name(mid), ruby_node_name(nd_type(body)));
- */
- return val;
- }
-}
-
-static VALUE
-rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
-{
- return rb_call0(klass, recv, mid, argc, argv, scope, rb_frame_self());
+ return rb_call0(klass, recv, mid, id, argc, argv, body, noex);
}
VALUE
-rb_apply(VALUE recv, ID mid, VALUE args)
+rb_apply(recv, mid, args)
+ VALUE recv;
+ ID mid;
+ VALUE args;
{
int argc;
VALUE *argv;
- argc = RARRAY_LEN(args); /* Assigns LONG, but argc is INT */
+ argc = RARRAY(args)->len; /* Assigns LONG, but argc is INT */
argv = ALLOCA_N(VALUE, argc);
- MEMCPY(argv, RARRAY_PTR(args), VALUE, argc);
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv, NOEX_NOSUPER);
-}
-
-static VALUE
-send_internal(int argc, VALUE *argv, VALUE recv, int scope)
-{
- VALUE vid;
- VALUE self = RUBY_VM_PREVIOUS_CONTROL_FRAME(GET_THREAD()->cfp)->self;
-
- if (argc == 0) {
- rb_raise(rb_eArgError, "no method name given");
- }
-
- vid = *argv++; argc--;
- PASS_PASSED_BLOCK();
- return rb_call0(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope, self);
+ MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1, Qundef);
}
/*
* call-seq:
* obj.send(symbol [, args...]) => obj
- * obj.__send__(symbol [, args...]) => obj
- *
+ * obj.__send__(symbol [, args...]) => obj
+ *
* Invokes the method identified by _symbol_, passing it any
- * arguments specified. You can use <code>__send__</code> if the name
+ * arguments specified. You can use <code>\_\_send__</code> if the name
* +send+ clashes with an existing method in _obj_.
- *
+ *
* class Klass
* def hello(*args)
* "Hello " + args.join(' ')
@@ -1498,83 +6186,210 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope)
* k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
*/
-VALUE
-rb_f_send(int argc, VALUE *argv, VALUE recv)
+static VALUE
+rb_f_send(argc, argv, recv)
+ int argc;
+ VALUE *argv;
+ VALUE recv;
{
- return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
-}
+ VALUE vid;
+ if (argc == 0) rb_raise(rb_eArgError, "no method name given");
-/*
- * call-seq:
- * obj.public_send(symbol [, args...]) => obj
- *
- * Invokes the method identified by _symbol_, passing it any
- * arguments specified. Unlike send, public_send calls public
- * methods only.
- *
- * 1.public_send(:puts, "hello") # causes NoMethodError
- */
+ 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);
+ POP_ITER();
-VALUE
-rb_f_public_send(int argc, VALUE *argv, VALUE recv)
-{
- return send_internal(argc, argv, recv, NOEX_PUBLIC);
+ return vid;
}
-VALUE
-rb_funcall(VALUE recv, ID mid, int n, ...)
+static VALUE
+vafuncall(recv, mid, n, ar)
+ VALUE recv;
+ ID mid;
+ int n;
+ va_list *ar;
{
VALUE *argv;
- va_list ar;
- va_init_list(ar, n);
if (n > 0) {
long i;
argv = ALLOCA_N(VALUE, n);
- for (i = 0; i < n; i++) {
- argv[i] = va_arg(ar, VALUE);
+ for (i=0;i<n;i++) {
+ argv[i] = va_arg(*ar, VALUE);
}
- va_end(ar);
+ va_end(*ar);
}
else {
argv = 0;
}
- return rb_call(CLASS_OF(recv), recv, mid, n, argv,
- NOEX_NOSUPER | NOEX_PRIVATE);
+
+ return rb_call(CLASS_OF(recv), recv, mid, n, argv, 1, Qundef);
}
VALUE
-rb_funcall2(VALUE recv, ID mid, int argc, const VALUE *argv)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_funcall(VALUE recv, ID mid, int n, ...)
+#else
+rb_funcall(recv, mid, n, va_alist)
+ VALUE recv;
+ ID mid;
+ int n;
+ va_dcl
+#endif
{
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv,
- NOEX_NOSUPER | NOEX_PRIVATE);
+ va_list ar;
+ va_init_list(ar, n);
+
+ return vafuncall(recv, mid, n, &ar);
}
VALUE
-rb_funcall3(VALUE recv, ID mid, int argc, const VALUE *argv)
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_funcall_rescue(VALUE recv, ID mid, int n, ...)
+#else
+rb_funcall_rescue(recv, mid, n, va_alist)
+ VALUE recv;
+ ID mid;
+ int n;
+ va_dcl
+#endif
{
- return rb_call(CLASS_OF(recv), recv, mid, argc, argv, NOEX_PUBLIC);
+ VALUE result = Qnil; /* OK */
+ int status;
+ va_list ar;
+
+ va_init_list(ar, n);
+
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ result = vafuncall(recv, mid, n, &ar);
+ }
+ POP_TAG();
+ switch (status) {
+ case 0:
+ return result;
+ case TAG_RAISE:
+ return Qundef;
+ default:
+ JUMP_TAG(status);
+ }
+}
+
+VALUE
+rb_funcall2(recv, mid, argc, argv)
+ VALUE recv;
+ ID mid;
+ int argc;
+ const VALUE *argv;
+{
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1, Qundef);
+}
+
+VALUE
+rb_funcall3(recv, mid, argc, argv)
+ VALUE recv;
+ ID mid;
+ int argc;
+ const VALUE *argv;
+{
+ return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0, Qundef);
+}
+
+VALUE
+rb_call_super(argc, argv)
+ int argc;
+ const VALUE *argv;
+{
+ VALUE result, self, klass;
+
+ if (ruby_frame->last_class == 0) {
+ rb_name_error(ruby_frame->last_func, "calling `super' from `%s' is prohibited",
+ rb_id2name(ruby_frame->orig_func));
+ }
+
+ self = ruby_frame->self;
+ klass = ruby_frame->last_class;
+ if (RCLASS(klass)->super == 0) {
+ return method_missing(self, ruby_frame->orig_func, argc, argv, CSTAT_SUPER);
+ }
+
+ PUSH_ITER(ruby_iter->iter ? ITER_PRE : ITER_NOT);
+ result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3, Qundef);
+ POP_ITER();
+
+ return result;
}
static VALUE
-backtrace(int lev)
+backtrace(lev)
+ int lev;
{
- return vm_backtrace(GET_THREAD(), lev);
+ struct FRAME *frame = ruby_frame;
+ char buf[BUFSIZ];
+ VALUE ary;
+ NODE *n;
+
+ ary = rb_ary_new();
+ if (frame->last_func == ID_ALLOCATOR) {
+ frame = frame->prev;
+ }
+ if (lev < 0) {
+ ruby_set_current_source();
+ if (frame->last_func) {
+ snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
+ ruby_sourcefile, ruby_sourceline,
+ rb_id2name(frame->last_func));
+ }
+ else if (ruby_sourceline == 0) {
+ snprintf(buf, BUFSIZ, "%s", ruby_sourcefile);
+ }
+ else {
+ snprintf(buf, BUFSIZ, "%s:%d", ruby_sourcefile, ruby_sourceline);
+ }
+ rb_ary_push(ary, rb_str_new2(buf));
+ if (lev < -1) return ary;
+ }
+ else {
+ while (lev-- > 0) {
+ frame = frame->prev;
+ if (!frame) {
+ ary = Qnil;
+ break;
+ }
+ }
+ }
+ for (; frame && (n = frame->node); frame = frame->prev) {
+ if (frame->prev && frame->prev->last_func) {
+ if (frame->prev->node == n) {
+ if (frame->prev->last_func == frame->last_func) continue;
+ }
+ snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
+ n->nd_file, nd_line(n),
+ rb_id2name(frame->prev->last_func));
+ }
+ else {
+ snprintf(buf, BUFSIZ, "%s:%d", n->nd_file, nd_line(n));
+ }
+ rb_ary_push(ary, rb_str_new2(buf));
+ }
+
+ return ary;
}
/*
* call-seq:
* caller(start=1) => array
- *
+ *
* Returns the current execution stack---an array containing strings in
* the form ``<em>file:line</em>'' or ``<em>file:line: in
* `method'</em>''. The optional _start_ parameter
* determines the number of initial stack entries to omit from the
* result.
- *
+ *
* def a(skip)
* caller(skip)
* end
@@ -1591,203 +6406,221 @@ backtrace(int lev)
*/
static VALUE
-rb_f_caller(int argc, VALUE *argv)
+rb_f_caller(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE level;
int lev;
rb_scan_args(argc, argv, "01", &level);
- if (NIL_P(level))
- lev = 1;
- else
- lev = NUM2INT(level);
- if (lev < 0)
- rb_raise(rb_eArgError, "negative level (%d)", lev);
+ if (NIL_P(level)) lev = 1;
+ else lev = NUM2INT(level);
+ if (lev < 0) rb_raise(rb_eArgError, "negative level (%d)", lev);
return backtrace(lev);
}
void
-rb_backtrace(void)
+rb_backtrace()
{
long i;
VALUE ary;
ary = backtrace(-1);
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- printf("\tfrom %s\n", RSTRING_PTR(RARRAY_PTR(ary)[i]));
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ printf("\tfrom %s\n", RSTRING(RARRAY(ary)->ptr[i])->ptr);
}
}
static VALUE
-make_backtrace(void)
+make_backtrace()
{
return backtrace(-1);
}
-static ID
-frame_func_id(rb_control_frame_t *cfp)
-{
- rb_iseq_t *iseq = cfp->iseq;
- if (!iseq) {
- return cfp->method_id;
- }
- while (iseq) {
- if (RUBY_VM_IFUNC_P(iseq)) {
- return rb_intern("<ifunc>");
- }
- if (iseq->defined_method_id) {
- return iseq->defined_method_id;
- }
- if (iseq->local_iseq == iseq) {
- break;
- }
- iseq = iseq->parent_iseq;
- }
- return 0;
-}
-
ID
-rb_frame_this_func(void)
+rb_frame_last_func()
{
- return frame_func_id(GET_THREAD()->cfp);
+ return ruby_frame->last_func;
}
ID
-rb_frame_callee(void)
+rb_frame_this_func()
{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
- /* check if prev_cfp can be accessible */
- if ((void *)(th->stack + th->stack_size) == (void *)(prev_cfp)) {
- return 0;
- }
- return frame_func_id(prev_cfp);
+ return ruby_frame->orig_func;
}
-void
-rb_frame_pop(void)
+static NODE*
+compile(src, file, line)
+ VALUE src;
+ const char *file;
+ int line;
{
- rb_thread_t *th = GET_THREAD();
- th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
-}
+ NODE *node;
+ int critical;
-static VALUE
-rb_frame_self(void)
-{
- return GET_THREAD()->cfp->self;
+ ruby_nerrs = 0;
+ StringValue(src);
+ critical = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ node = rb_compile_string(file, src, line);
+ rb_thread_critical = critical;
+
+ if (ruby_nerrs == 0) return node;
+ return 0;
}
static VALUE
-eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
+eval(self, src, scope, file, line)
+ VALUE self, src, scope;
+ const char *file;
+ int line;
{
+ struct BLOCK *data = NULL;
+ volatile VALUE result = Qnil;
+ struct SCOPE * volatile old_scope;
+ struct BLOCK * volatile old_block;
+ struct RVarmap * volatile old_dyna_vars;
+ VALUE volatile old_cref;
+ int volatile old_vmode;
+ volatile VALUE old_wrapper;
+ struct FRAME frame;
+ NODE *nodesave = ruby_current_node;
+ volatile int iter = ruby_frame->iter;
+ volatile int safe = ruby_safe_level;
int state;
- VALUE result = Qundef;
- VALUE envval;
- rb_binding_t *bind = 0;
- rb_thread_t *th = GET_THREAD();
- rb_env_t *env = NULL;
- NODE *stored_cref_stack = 0;
-
- if (file == 0) {
- file = rb_sourcefile();
- line = rb_sourceline();
- }
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- rb_iseq_t *iseq;
- volatile VALUE iseqval;
-
- if (scope != Qnil) {
- if (CLASS_OF(scope) == rb_cBinding) {
- GetBindingPtr(scope, bind);
- envval = bind->env;
- stored_cref_stack = bind->cref_stack;
- }
- else {
- rb_raise(rb_eTypeError,
- "wrong argument type %s (expected Binding)",
- rb_obj_classname(scope));
- }
- GetEnvPtr(envval, env);
- th->base_block = &env->block;
- }
- else {
- rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
- th->base_block = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp);
- th->base_block->iseq = cfp->iseq; /* TODO */
+ if (!NIL_P(scope)) {
+ if (!rb_obj_is_proc(scope)) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Binding)",
+ rb_obj_classname(scope));
}
- /* make eval iseq */
- th->parse_in_eval++;
- iseqval = rb_iseq_compile(src, rb_str_new2(file), INT2FIX(line));
- th->parse_in_eval--;
- rb_vm_set_eval_stack(th, iseqval);
- th->base_block = 0;
-
- if (0) { /* for debug */
- extern VALUE ruby_iseq_disasm(VALUE);
- printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
+ Data_Get_Struct(scope, struct BLOCK, data);
+ /* PUSH BLOCK from data */
+ frame = data->frame;
+ frame.tmp = ruby_frame; /* gc protection */
+ ruby_frame = &(frame);
+ old_scope = ruby_scope;
+ ruby_scope = data->scope;
+ old_block = ruby_block;
+ ruby_block = data->prev;
+ old_dyna_vars = ruby_dyna_vars;
+ ruby_dyna_vars = data->dyna_vars;
+ old_vmode = scope_vmode;
+ scope_vmode = data->vmode;
+ old_cref = (VALUE)ruby_cref;
+ ruby_cref = data->cref;
+ old_wrapper = ruby_wrapper;
+ ruby_wrapper = data->wrapper;
+ if ((file == 0 || (line == 1 && strcmp(file, "(eval)") == 0)) && data->frame.node) {
+ file = data->frame.node->nd_file;
+ if (!file) file = "__builtin__";
+ line = nd_line(data->frame.node);
}
- /* save new env */
- GetISeqPtr(iseqval, iseq);
- if (bind && iseq->local_size > 0) {
- bind->env = vm_make_env_object(th, th->cfp);
+ self = data->self;
+ ruby_frame->iter = data->iter;
+ }
+ else {
+ if (ruby_frame->prev) {
+ ruby_frame->iter = ruby_frame->prev->iter;
}
-
- /* push tag */
- if (stored_cref_stack) {
- stored_cref_stack =
- vm_set_special_cref(th, env->block.lfp, stored_cref_stack);
+ }
+ if (file == 0) {
+ ruby_set_current_source();
+ file = ruby_sourcefile;
+ line = ruby_sourceline;
+ }
+ PUSH_CLASS(data ? data->klass : ruby_class);
+ ruby_in_eval++;
+ if (TYPE(ruby_class) == T_ICLASS) {
+ ruby_class = RBASIC(ruby_class)->klass;
+ }
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ NODE *node;
+
+ ruby_safe_level = 0;
+ result = ruby_errinfo;
+ ruby_errinfo = Qnil;
+ node = compile(src, file, line);
+ ruby_safe_level = safe;
+ if (ruby_nerrs > 0) {
+ compile_error(0);
}
-
- /* kick */
- CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
- result = vm_eval_body(th);
+ if (!NIL_P(result)) ruby_errinfo = result;
+ result = eval_node(self, node);
}
POP_TAG();
-
- if (stored_cref_stack) {
- vm_set_special_cref(th, env->block.lfp, stored_cref_stack);
+ POP_CLASS();
+ ruby_in_eval--;
+ if (!NIL_P(scope)) {
+ int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE;
+
+ ruby_wrapper = old_wrapper;
+ ruby_cref = (NODE*)old_cref;
+ ruby_frame = frame.tmp;
+ ruby_scope = old_scope;
+ ruby_block = old_block;
+ ruby_dyna_vars = old_dyna_vars;
+ data->vmode = scope_vmode; /* write back visibility mode */
+ scope_vmode = old_vmode;
+ if (dont_recycle) {
+ struct tag *tag;
+ struct RVarmap *vars;
+
+ scope_dup(ruby_scope);
+ for (tag=prot_tag; tag; tag=tag->prev) {
+ scope_dup(tag->scope);
+ }
+ for (vars = ruby_dyna_vars; vars; vars = vars->next) {
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
+ }
}
-
+ else {
+ ruby_frame->iter = iter;
+ }
+ ruby_current_node = nodesave;
+ ruby_set_current_source();
if (state) {
if (state == TAG_RAISE) {
- VALUE errinfo = th->errinfo;
if (strcmp(file, "(eval)") == 0) {
- VALUE mesg, errat;
+ VALUE mesg, errat, bt2;
- errat = get_backtrace(errinfo);
- mesg = rb_attr_get(errinfo, rb_intern("mesg"));
- if (!NIL_P(errat) && TYPE(errat) == T_ARRAY) {
+ 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)) {
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]);
}
- RARRAY_PTR(errat)[0] = RARRAY_PTR(backtrace(-2))[0];
+ RARRAY_PTR(errat)[0] = RARRAY_PTR(bt2)[0];
}
}
- rb_exc_raise(errinfo);
+ rb_exc_raise(ruby_errinfo);
}
JUMP_TAG(state);
}
+
return result;
}
/*
* call-seq:
* eval(string [, binding [, filename [,lineno]]]) => obj
- *
+ *
* Evaluates the Ruby expression(s) in <em>string</em>. If
* <em>binding</em> is given, the evaluation is performed in its
* context. The binding may be a <code>Binding</code> object or a
* <code>Proc</code> object. If the optional <em>filename</em> and
* <em>lineno</em> parameters are present, they will be used when
* reporting syntax errors.
- *
+ *
* def getBinding(str)
* return binding
* end
@@ -1796,19 +6629,21 @@ eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
* eval "str + ' Fred'", getBinding("bye") #=> "bye Fred"
*/
-VALUE
-rb_f_eval(int argc, VALUE *argv, VALUE self)
+static VALUE
+rb_f_eval(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE src, scope, vfile, vline;
- char *file = "(eval)";
+ const char *file = "(eval)";
int line = 1;
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
- if (rb_safe_level() >= 4) {
+ if (ruby_safe_level >= 4) {
StringValue(src);
if (!NIL_P(scope) && !OBJ_TAINTED(scope)) {
- rb_raise(rb_eSecurityError,
- "Insecure: can't modify trusted binding");
+ rb_raise(rb_eSecurityError, "Insecure: can't modify trusted binding");
}
}
else {
@@ -1821,138 +6656,159 @@ rb_f_eval(int argc, VALUE *argv, VALUE self)
line = NUM2INT(vline);
}
- if (!NIL_P(vfile))
- file = RSTRING_PTR(vfile);
+ if (!NIL_P(vfile)) file = RSTRING(vfile)->ptr;
+ if (NIL_P(scope) && ruby_frame->prev) {
+ struct FRAME *prev;
+ VALUE val;
+
+ prev = ruby_frame;
+ PUSH_FRAME();
+ *ruby_frame = *prev->prev;
+ ruby_frame->prev = prev;
+ val = eval(self, src, scope, file, line);
+ POP_FRAME();
+
+ return val;
+ }
return eval(self, src, scope, file, line);
}
-VALUE vm_cfp_svar_get(rb_thread_t *th, rb_control_frame_t *cfp, VALUE key);
-void vm_cfp_svar_set(rb_thread_t *th, rb_control_frame_t *cfp, VALUE key, VALUE val);
-
/* function to call func under the specified class/module context */
static VALUE
-exec_under(VALUE (*func) (VALUE), VALUE under, VALUE self, VALUE args)
+exec_under(func, under, cbase, args)
+ VALUE (*func)();
+ VALUE under, cbase;
+ void *args;
{
VALUE val = Qnil; /* OK */
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
- rb_control_frame_t *pcfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
- VALUE stored_self = pcfp->self;
- NODE *stored_cref = 0;
-
- rb_block_t block;
- rb_block_t *blockptr;
int state;
-
- /* replace environment */
- pcfp->self = self;
- if ((blockptr = GC_GUARDED_PTR_REF(*th->cfp->lfp)) != 0) {
- /* copy block info */
- /* TODO: why? */
- block = *blockptr;
- block.self = self;
- *th->cfp->lfp = GC_GUARDED_PTR(&block);
- }
-
- while (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ int mode;
+ struct FRAME *f = ruby_frame;
+
+ PUSH_CLASS(under);
+ PUSH_FRAME();
+ ruby_frame->self = f->self;
+ ruby_frame->last_func = f->last_func;
+ ruby_frame->orig_func = f->orig_func;
+ ruby_frame->last_class = f->last_class;
+ ruby_frame->argc = f->argc;
+ if (cbase) {
+ PUSH_CREF(cbase);
}
- stored_cref = (NODE *)vm_cfp_svar_get(th, cfp, 2);
- vm_cfp_svar_set(th, cfp, 2, (VALUE)vm_cref_push(th, under, NOEX_PUBLIC));
-
- PUSH_TAG();
+ mode = scope_vmode;
+ SCOPE_SET(SCOPE_PUBLIC);
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- val = (*func) (args);
+ val = (*func)(args);
}
POP_TAG();
+ if (cbase) POP_CREF();
+ SCOPE_SET(mode);
+ POP_FRAME();
+ POP_CLASS();
+ if (state) JUMP_TAG(state);
- /* restore environment */
- vm_cfp_svar_set(th, cfp, 2, (VALUE)stored_cref);
- pcfp->self = stored_self;
+ return val;
+}
- if (state) {
- JUMP_TAG(state);
+static VALUE
+eval_under_i(args)
+ VALUE *args;
+{
+ struct FRAME *f = ruby_frame;
+
+ if (f && (f = f->prev) && (f = f->prev)) {
+ ruby_frame = f;
}
- return val;
+ return eval(args[0], args[1], Qnil, (char*)args[2], (int)args[3]);
}
+/* string eval under the class/module context */
static VALUE
-yield_under_i(VALUE arg)
+eval_under(under, self, src, file, line)
+ VALUE under, self, src;
+ const char *file;
+ int line;
{
- if (arg == Qundef) {
- return rb_yield_0(0, 0);
+ VALUE args[4];
+
+ if (ruby_safe_level >= 4) {
+ StringValue(src);
}
else {
- return rb_yield_0(RARRAY_LEN(arg), RARRAY_PTR(arg));
+ SafeStringValue(src);
}
+ args[0] = self;
+ args[1] = src;
+ args[2] = (VALUE)file;
+ args[3] = (VALUE)line;
+ return exec_under(eval_under_i, under, under, args);
}
-/* block eval under the class/module context */
static VALUE
-yield_under(VALUE under, VALUE self, VALUE values)
+yield_under_i(self)
+ VALUE self;
{
- return exec_under(yield_under_i, under, self, values);
+ return rb_yield_0(self, self, ruby_class, YIELD_PUBLIC_DEF, Qfalse);
}
static VALUE
-eval_under_i(VALUE arg)
+yield_args_under_i(vinfo)
+ VALUE vinfo;
{
- VALUE *args = (VALUE *)arg;
- return eval(args[0], args[1], Qnil, (char *)args[2], (int)args[3]);
+ VALUE *info = (VALUE *)vinfo;
+
+ return rb_yield_0(info[0], info[1], ruby_class, YIELD_PUBLIC_DEF, Qtrue);
}
-/* string eval under the class/module context */
+/* block eval under the class/module context */
static VALUE
-eval_under(VALUE under, VALUE self, VALUE src, const char *file, int line)
+yield_under(under, self, args)
+ VALUE under, self, args;
{
- VALUE args[4];
-
- if (rb_safe_level() >= 4) {
- StringValue(src);
+ if (args == Qundef) {
+ return exec_under(yield_under_i, under, 0, self);
}
else {
- SafeStringValue(src);
+ VALUE info[2] = { args, self };
+
+ return exec_under(yield_args_under_i, under, 0, (VALUE)info);
}
- args[0] = self;
- args[1] = src;
- args[2] = (VALUE)file;
- args[3] = (VALUE)line;
- return exec_under(eval_under_i, under, self, (VALUE)args);
}
static VALUE
-specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
+specific_eval(argc, argv, klass, self)
+ int argc;
+ VALUE *argv;
+ VALUE klass, self;
{
if (rb_block_given_p()) {
if (argc > 0) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
- argc);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
return yield_under(klass, self, Qundef);
}
else {
- char *file = "(eval)";
- int line = 1;
+ const char *file = "(eval)";
+ int line = 1;
if (argc == 0) {
rb_raise(rb_eArgError, "block not supplied");
}
else {
- if (rb_safe_level() >= 4) {
+ if (ruby_safe_level >= 4) {
StringValue(argv[0]);
}
else {
SafeStringValue(argv[0]);
}
if (argc > 3) {
- const char *name = rb_id2name(rb_frame_callee());
- rb_raise(rb_eArgError,
- "wrong number of arguments: %s(src) or %s{..}",
- name, name);
+ rb_raise(rb_eArgError, "wrong number of arguments: %s(src) or %s{..}",
+ rb_id2name(ruby_frame->last_func),
+ rb_id2name(ruby_frame->last_func));
}
- if (argc > 2)
- line = NUM2INT(argv[2]);
+ if (argc > 2) line = NUM2INT(argv[2]);
if (argc > 1) {
file = StringValuePtr(argv[1]);
}
@@ -1965,7 +6821,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
* call-seq:
* obj.instance_eval(string [, filename [, lineno]] ) => obj
* obj.instance_eval {| | block } => obj
- *
+ *
* Evaluates a string containing Ruby source code, or the given block,
* within the context of the receiver (_obj_). In order to set the
* context, the variable +self+ is set to _obj_ while
@@ -1974,7 +6830,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
* that takes a +String+, the optional second and third
* parameters supply a filename and starting line number that are used
* when reporting compilation errors.
- *
+ *
* class Klass
* def initialize
* @secret = 99
@@ -1985,12 +6841,15 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
*/
VALUE
-rb_obj_instance_eval(int argc, VALUE *argv, VALUE self)
+rb_obj_instance_eval(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE klass;
if (SPECIAL_CONST_P(self)) {
- klass = CLASS_OF(self); //klass = Qnil;
+ klass = Qnil;
}
else {
klass = rb_singleton_class(self);
@@ -2007,17 +6866,20 @@ rb_obj_instance_eval(int argc, VALUE *argv, VALUE self)
* to _obj_ while the code is executing, giving the code access to
* _obj_'s instance variables. Arguments are passed as block parameters.
*
- * class Klass
+ * class KlassWithSecret
* def initialize
* @secret = 99
* end
* end
- * k = Klass.new
+ * k = KlassWithSecret.new
* k.instance_exec(5) {|x| @secret+x } #=> 104
*/
VALUE
-rb_obj_instance_exec(int argc, VALUE *argv, VALUE self)
+rb_obj_instance_exec(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE klass;
@@ -2034,28 +6896,31 @@ rb_obj_instance_exec(int argc, VALUE *argv, VALUE self)
* call-seq:
* mod.class_eval(string [, filename [, lineno]]) => obj
* mod.module_eval {|| block } => obj
- *
+ *
* Evaluates the string or block in the context of _mod_. This can
* be used to add methods to a class. <code>module_eval</code> returns
* the result of evaluating its argument. The optional _filename_
* and _lineno_ parameters set the text for error messages.
- *
+ *
* class Thing
* end
* a = %q{def hello() "Hello there!" end}
* Thing.module_eval(a)
* puts Thing.new.hello()
* Thing.module_eval("invalid code", "dummy", 123)
- *
+ *
* <em>produces:</em>
- *
+ *
* Hello there!
* dummy:123:in `module_eval': undefined local variable
* or method `code' for Thing:Class
*/
VALUE
-rb_mod_module_eval(int argc, VALUE *argv, VALUE mod)
+rb_mod_module_eval(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
return specific_eval(argc, argv, mod, mod);
}
@@ -2081,26 +6946,529 @@ rb_mod_module_eval(int argc, VALUE *argv, VALUE mod)
*/
VALUE
-rb_mod_module_exec(int argc, VALUE *argv, VALUE mod)
+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)));
+
+void
+rb_load(fname, wrap)
+ VALUE fname;
+ int wrap;
+{
+ VALUE tmp;
+ int state;
+ volatile int prohibit_int = rb_prohibit_interrupt;
+ volatile ID last_func;
+ volatile VALUE wrapper = ruby_wrapper;
+ volatile VALUE self = ruby_top_self;
+ NODE *volatile last_node;
+ NODE *saved_cref = ruby_cref;
+
+ if (wrap && ruby_safe_level >= 4) {
+ StringValue(fname);
+ }
+ else {
+ SafeStringValue(fname);
+ }
+ fname = rb_str_new4(fname);
+ tmp = rb_find_file(fname);
+ if (!tmp) {
+ load_failed(fname);
+ }
+ fname = tmp;
+
+ ruby_errinfo = Qnil; /* ensure */
+ PUSH_VARS();
+ PUSH_CLASS(ruby_wrapper);
+ ruby_cref = ruby_top_cref;
+ if (!wrap) {
+ rb_secure(4); /* should alter global state */
+ ruby_class = rb_cObject;
+ ruby_wrapper = 0;
+ }
+ else {
+ /* load in anonymous module as toplevel */
+ ruby_class = ruby_wrapper = rb_module_new();
+ self = rb_obj_clone(ruby_top_self);
+ rb_extend_object(self, ruby_wrapper);
+ PUSH_CREF(ruby_wrapper);
+ }
+ PUSH_ITER(ITER_NOT);
+ PUSH_FRAME();
+ ruby_frame->last_func = 0;
+ ruby_frame->last_class = 0;
+ ruby_frame->self = self;
+ PUSH_SCOPE();
+ /* default visibility is private at loading toplevel */
+ SCOPE_SET(SCOPE_PRIVATE);
+ PUSH_TAG(PROT_NONE);
+ state = EXEC_TAG();
+ last_func = ruby_frame->last_func;
+ last_node = ruby_current_node;
+ if (!ruby_current_node && ruby_sourcefile) {
+ last_node = NEW_NEWLINE(0);
+ }
+ ruby_current_node = 0;
+ if (state == 0) {
+ NODE *node;
+ volatile int critical;
+
+ DEFER_INTS;
+ ruby_in_eval++;
+ critical = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ rb_load_file(RSTRING(fname)->ptr);
+ ruby_in_eval--;
+ node = ruby_eval_tree;
+ rb_thread_critical = critical;
+ ALLOW_INTS;
+ if (ruby_nerrs == 0) {
+ eval_node(self, node);
+ }
+ }
+ ruby_frame->last_func = last_func;
+ ruby_current_node = last_node;
+ ruby_sourcefile = 0;
+ ruby_set_current_source();
+ if (ruby_scope->flags == SCOPE_ALLOCA && ruby_class == rb_cObject) {
+ if (ruby_scope->local_tbl) /* toplevel was empty */
+ free(ruby_scope->local_tbl);
+ }
+ POP_TAG();
+ rb_prohibit_interrupt = prohibit_int;
+ ruby_cref = saved_cref;
+ POP_SCOPE();
+ POP_FRAME();
+ POP_ITER();
+ POP_CLASS();
+ POP_VARS();
+ ruby_wrapper = wrapper;
+ if (ruby_nerrs > 0) {
+ ruby_nerrs = 0;
+ rb_exc_raise(ruby_errinfo);
+ }
+ if (state) jump_tag_but_local_jump(state, Qundef);
+ if (!NIL_P(ruby_errinfo)) /* exception during load */
+ rb_exc_raise(ruby_errinfo);
+}
+
+void
+rb_load_protect(fname, wrap, state)
+ VALUE fname;
+ int wrap;
+ int *state;
+{
+ int status;
+
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ rb_load(fname, wrap);
+ }
+ POP_TAG();
+ if (state) *state = status;
+}
+
+/*
+ * call-seq:
+ * load(filename, wrap=false) => true
+ *
+ * Loads and executes the Ruby
+ * program in the file _filename_. If the filename does not
+ * resolve to an absolute path, the file is searched for in the library
+ * directories listed in <code>$:</code>. If the optional _wrap_
+ * parameter is +true+, the loaded script will be executed
+ * under an anonymous module, protecting the calling program's global
+ * namespace. In no circumstance will any local variables in the loaded
+ * file be propagated to the loading environment.
+ */
+
+
+static VALUE
+rb_f_load(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE fname, wrap;
+
+ rb_scan_args(argc, argv, "11", &fname, &wrap);
+ rb_load(fname, RTEST(wrap));
+ return Qtrue;
+}
+
+VALUE ruby_dln_librefs;
+static VALUE rb_features;
+static st_table *loading_tbl;
+
+#define IS_SOEXT(e) (strcmp(e, ".so") == 0 || strcmp(e, ".o") == 0)
+#ifdef DLEXT2
+#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0 || strcmp(e, DLEXT2) == 0)
+#else
+#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0)
+#endif
+
+
+static const char *const loadable_ext[] = {
+ ".rb", DLEXT,
+#ifdef DLEXT2
+ DLEXT2,
+#endif
+ 0
+};
+
+static int rb_feature_p _((const char *, const char *, int));
+static int search_required _((VALUE, VALUE *, VALUE *));
+
+static int
+rb_feature_p(feature, ext, rb)
+ const char *feature, *ext;
+ int rb;
+{
+ VALUE v;
+ const char *f, *e;
+ long i, len, elen;
+
+ if (ext) {
+ len = ext - feature;
+ elen = strlen(ext);
+ }
+ else {
+ len = strlen(feature);
+ elen = 0;
+ }
+ for (i = 0; i < RARRAY_LEN(rb_features); ++i) {
+ v = RARRAY_PTR(rb_features)[i];
+ f = StringValuePtr(v);
+ if (RSTRING_LEN(v) < len || strncmp(f, feature, len) != 0)
+ continue;
+ if (!*(e = f + len)) {
+ if (ext) continue;
+ return 'u';
+ }
+ if (*e != '.') continue;
+ if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
+ return 's';
+ }
+ if ((rb || !ext) && (strcmp(e, ".rb") == 0)) {
+ return 'r';
+ }
+ }
+ if (loading_tbl) {
+ if (st_lookup(loading_tbl, (st_data_t)feature, 0)) {
+ if (!ext) return 'u';
+ return strcmp(ext, ".rb") ? 's' : 'r';
+ }
+ else {
+ char *buf;
+
+ if (ext && *ext) return 0;
+ buf = ALLOCA_N(char, len + DLEXT_MAXLEN + 1);
+ MEMCPY(buf, feature, char, len);
+ for (i = 0; (e = loadable_ext[i]) != 0; i++) {
+ strncpy(buf + len, e, DLEXT_MAXLEN + 1);
+ if (st_lookup(loading_tbl, (st_data_t)buf, 0)) {
+ return i ? 's' : 'r';
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+int
+rb_provided(feature)
+ const char *feature;
+{
+ const char *ext = strrchr(feature, '.');
+
+ if (ext && !strchr(ext, '/')) {
+ if (strcmp(".rb", ext) == 0) {
+ if (rb_feature_p(feature, ext, Qtrue)) return Qtrue;
+ return Qfalse;
+ }
+ else if (IS_SOEXT(ext) || IS_DLEXT(ext)) {
+ if (rb_feature_p(feature, ext, Qfalse)) return Qtrue;
+ return Qfalse;
+ }
+ }
+ if (rb_feature_p(feature, feature + strlen(feature), Qtrue))
+ return Qtrue;
+
+ return Qfalse;
+}
+
+static void
+rb_provide_feature(feature)
+ VALUE feature;
+{
+ rb_ary_push(rb_features, feature);
+}
+
+void
+rb_provide(feature)
+ const char *feature;
+{
+ rb_provide_feature(rb_str_new2(feature));
+}
+
+static char *
+load_lock(ftptr)
+ const 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;
+ }
+ do {
+ if ((rb_thread_t)th == curr_thread) return 0;
+ 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);
+ }
+ }
+}
+
+/*
+ * call-seq:
+ * require(string) => true or false
+ *
+ * Ruby tries to load the library named _string_, returning
+ * +true+ if successful. If the filename does not resolve to
+ * an absolute path, it will be searched for in the directories listed
+ * in <code>$:</code>. If the file has the extension ``.rb'', it is
+ * loaded as a source file; if the extension is ``.so'', ``.o'', or
+ * ``.dll'', or whatever the default shared library extension is on
+ * the current platform, Ruby loads the shared library as a Ruby
+ * extension. Otherwise, Ruby tries adding ``.rb'', ``.so'', and so on
+ * to the name. The name of the loaded feature is added to the array in
+ * <code>$"</code>. A feature will not be loaded if it's name already
+ * appears in <code>$"</code>. However, the file name is not converted
+ * to an absolute path, so that ``<code>require 'a';require
+ * './a'</code>'' will load <code>a.rb</code> twice.
+ *
+ * require "my-library.rb"
+ * require "db-driver"
+ */
+
+VALUE
+rb_f_require(obj, fname)
+ VALUE obj, fname;
+{
+ return rb_require_safe(fname, ruby_safe_level);
+}
+
+static int
+search_required(fname, featurep, path)
+ VALUE fname, *featurep, *path;
+{
+ VALUE tmp;
+ char *ext, *ftptr;
+ int type;
+
+ *featurep = fname;
+ *path = 0;
+ ext = strrchr(ftptr = RSTRING_PTR(fname), '.');
+ if (ext && !strchr(ext, '/')) {
+ if (strcmp(".rb", ext) == 0) {
+ if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
+ if ((*path = rb_find_file(fname)) != 0) return 'r';
+ return 0;
+ }
+ else if (IS_SOEXT(ext)) {
+ if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
+ tmp = rb_str_new(RSTRING_PTR(fname), ext-RSTRING_PTR(fname));
+ *featurep = tmp;
+#ifdef DLEXT2
+ OBJ_FREEZE(tmp);
+ if (rb_find_file_ext(&tmp, loadable_ext+1)) {
+ *featurep = tmp;
+ *path = rb_find_file(tmp);
+ return 's';
+ }
+#else
+ rb_str_cat2(tmp, DLEXT);
+ OBJ_FREEZE(tmp);
+ if ((*path = rb_find_file(tmp)) != 0) {
+ return 's';
+ }
+#endif
+ }
+ else if (IS_DLEXT(ext)) {
+ if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
+ if ((*path = rb_find_file(fname)) != 0) return 's';
+ }
+ }
+ tmp = fname;
+ type = rb_find_file_ext(&tmp, loadable_ext);
+ *featurep = tmp;
+ switch (type) {
+ case 0:
+ ftptr = RSTRING_PTR(tmp);
+ return rb_feature_p(ftptr, 0, Qfalse);
+
+ default:
+ ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
+ if (rb_feature_p(ftptr, ext, !--type)) break;
+ *path = rb_find_file(tmp);
+ }
+ return type ? 's' : 'r';
+}
+
+static void
+load_failed(fname)
+ VALUE fname;
+{
+ rb_raise(rb_eLoadError, "no such file to load -- %s", RSTRING(fname)->ptr);
+}
+
+VALUE
+rb_require_safe(fname, safe)
+ VALUE fname;
+ int safe;
+{
+ VALUE result = Qnil;
+ volatile VALUE errinfo = ruby_errinfo;
+ int state;
+ struct {
+ NODE *node;
+ ID func;
+ int vmode, safe;
+ } volatile saved;
+ char *volatile ftptr = 0;
+
+ if (OBJ_TAINTED(fname)) {
+ rb_check_safe_obj(fname);
+ }
+ StringValue(fname);
+ fname = rb_str_new4(fname);
+ saved.vmode = scope_vmode;
+ saved.node = ruby_current_node;
+ saved.func = ruby_frame->last_func;
+ saved.safe = ruby_safe_level;
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ VALUE feature, path;
+ long handle;
+ int found;
+
+ ruby_safe_level = safe;
+ found = search_required(fname, &feature, &path);
+ if (found) {
+ if (!path || !(ftptr = load_lock(RSTRING_PTR(feature)))) {
+ result = Qfalse;
+ }
+ else {
+ ruby_safe_level = 0;
+ switch (found) {
+ case 'r':
+ rb_load(path, 0);
+ break;
+
+ case 's':
+ ruby_current_node = 0;
+ ruby_sourcefile = rb_source_filename(RSTRING(path)->ptr);
+ ruby_sourceline = 0;
+ ruby_frame->last_func = 0;
+ SCOPE_SET(SCOPE_PUBLIC);
+ handle = (long)dln_load(RSTRING(path)->ptr);
+ rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
+ break;
+ }
+ rb_provide_feature(feature);
+ result = Qtrue;
+ }
+ }
+ }
+ POP_TAG();
+ ruby_current_node = saved.node;
+ ruby_set_current_source();
+ ruby_frame->last_func = saved.func;
+ SCOPE_SET(saved.vmode);
+ ruby_safe_level = saved.safe;
+ load_unlock(ftptr);
+ if (state) JUMP_TAG(state);
+ if (NIL_P(result)) {
+ load_failed(fname);
+ }
+ ruby_errinfo = errinfo;
+
+ return result;
+}
+
+VALUE
+rb_require(fname)
+ const char *fname;
+{
+ VALUE fn = rb_str_new2(fname);
+ OBJ_FREEZE(fn);
+ 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(VALUE self)
+secure_visibility(self)
+ VALUE self;
{
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
- rb_raise(rb_eSecurityError,
- "Insecure: can't change method visibility");
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(self)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't change method visibility");
}
}
static void
-set_method_visibility(VALUE self, int argc, VALUE *argv, ID ex)
+set_method_visibility(self, argc, argv, ex)
+ VALUE self;
+ int argc;
+ VALUE *argv;
+ ID ex;
{
int i;
+
secure_visibility(self);
- for (i = 0; i < argc; i++) {
+ for (i=0; i<argc; i++) {
rb_export_method(self, rb_to_id(argv[i]), ex);
}
rb_clear_cache_by_class(self);
@@ -2110,18 +7478,21 @@ set_method_visibility(VALUE self, int argc, VALUE *argv, ID ex)
* call-seq:
* public => self
* public(symbol, ...) => self
- *
+ *
* With no arguments, sets the default visibility for subsequently
* defined methods to public. With arguments, sets the named methods to
* have public visibility.
*/
static VALUE
-rb_mod_public(int argc, VALUE *argv, VALUE module)
+rb_mod_public(argc, argv, module)
+ int argc;
+ VALUE *argv;
+ VALUE module;
{
secure_visibility(module);
if (argc == 0) {
- SCOPE_SET(NOEX_PUBLIC);
+ SCOPE_SET(SCOPE_PUBLIC);
}
else {
set_method_visibility(module, argc, argv, NOEX_PUBLIC);
@@ -2133,18 +7504,21 @@ rb_mod_public(int argc, VALUE *argv, VALUE module)
* call-seq:
* protected => self
* protected(symbol, ...) => self
- *
+ *
* With no arguments, sets the default visibility for subsequently
* defined methods to protected. With arguments, sets the named methods
* to have protected visibility.
*/
static VALUE
-rb_mod_protected(int argc, VALUE *argv, VALUE module)
+rb_mod_protected(argc, argv, module)
+ int argc;
+ VALUE *argv;
+ VALUE module;
{
secure_visibility(module);
if (argc == 0) {
- SCOPE_SET(NOEX_PROTECTED);
+ SCOPE_SET(SCOPE_PROTECTED);
}
else {
set_method_visibility(module, argc, argv, NOEX_PROTECTED);
@@ -2156,11 +7530,11 @@ rb_mod_protected(int argc, VALUE *argv, VALUE module)
* call-seq:
* private => self
* private(symbol, ...) => self
- *
+ *
* With no arguments, sets the default visibility for subsequently
* defined methods to private. With arguments, sets the named methods
* to have private visibility.
- *
+ *
* module Mod
* def a() end
* def b() end
@@ -2172,11 +7546,14 @@ rb_mod_protected(int argc, VALUE *argv, VALUE module)
*/
static VALUE
-rb_mod_private(int argc, VALUE *argv, VALUE module)
+rb_mod_private(argc, argv, module)
+ int argc;
+ VALUE *argv;
+ VALUE module;
{
secure_visibility(module);
if (argc == 0) {
- SCOPE_SET(NOEX_PRIVATE);
+ SCOPE_SET(SCOPE_PRIVATE);
}
else {
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
@@ -2187,12 +7564,15 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
/*
* call-seq:
* mod.public_class_method(symbol, ...) => mod
- *
+ *
* Makes a list of existing class methods public.
*/
static VALUE
-rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
+rb_mod_public_method(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
set_method_visibility(CLASS_OF(obj), argc, argv, NOEX_PUBLIC);
return obj;
@@ -2201,10 +7581,10 @@ rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
/*
* call-seq:
* mod.private_class_method(symbol, ...) => mod
- *
+ *
* Makes existing class methods private. Often used to hide the default
* constructor <code>new</code>.
- *
+ *
* class SimpleSingleton # Not thread safe
* private_class_method :new
* def SimpleSingleton.create(*args, &block)
@@ -2215,7 +7595,10 @@ rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
*/
static VALUE
-rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
+rb_mod_private_method(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
set_method_visibility(CLASS_OF(obj), argc, argv, NOEX_PRIVATE);
return obj;
@@ -2225,20 +7608,24 @@ rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
* call-seq:
* public
* public(symbol, ...)
- *
+ *
* With no arguments, sets the default visibility for subsequently
* defined methods to public. With arguments, sets the named methods to
* have public visibility.
*/
static VALUE
-top_public(int argc, VALUE *argv)
+top_public(argc, argv)
+ int argc;
+ VALUE *argv;
{
return rb_mod_public(argc, argv, rb_cObject);
}
static VALUE
-top_private(int argc, VALUE *argv)
+top_private(argc, argv)
+ int argc;
+ VALUE *argv;
{
return rb_mod_private(argc, argv, rb_cObject);
}
@@ -2246,7 +7633,7 @@ top_private(int argc, VALUE *argv)
/*
* call-seq:
* module_function(symbol, ...) => self
- *
+ *
* Creates module functions for the named methods. These functions may
* be called with the module as a receiver, and also become available
* as instance methods to classes that mix in the module. Module
@@ -2254,7 +7641,7 @@ top_private(int argc, VALUE *argv)
* independently. The instance-method versions are made private. If
* used with no arguments, subsequently defined methods become module
* functions.
- *
+ *
* module Mod
* def one
* "This is one"
@@ -2280,11 +7667,14 @@ top_private(int argc, VALUE *argv)
*/
static VALUE
-rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
+rb_mod_modfunc(argc, argv, module)
+ int argc;
+ VALUE *argv;
+ VALUE module;
{
int i;
ID id;
- NODE *fbody;
+ NODE *body;
if (TYPE(module) != T_MODULE) {
rb_raise(rb_eTypeError, "module_function must be called for modules");
@@ -2292,33 +7682,30 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
secure_visibility(module);
if (argc == 0) {
- SCOPE_SET(NOEX_MODFUNC);
+ SCOPE_SET(SCOPE_MODFUNC);
return module;
}
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
-
- for (i = 0; i < argc; i++) {
+ for (i=0; i<argc; i++) {
VALUE m = module;
id = rb_to_id(argv[i]);
for (;;) {
- fbody = search_method(m, id, &m);
- if (fbody == 0) {
- fbody = search_method(rb_cObject, id, &m);
+ body = search_method(m, id, &m);
+ if (body == 0) {
+ body = search_method(rb_cObject, id, &m);
}
- if (fbody == 0 || fbody->nd_body == 0) {
+ if (body == 0 || body->nd_body == 0) {
rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
}
- if (nd_type(fbody->nd_body->nd_body) != NODE_ZSUPER) {
+ if (nd_type(body->nd_body) != NODE_ZSUPER) {
break; /* normal case: need not to follow 'super' link */
}
- m = RCLASS_SUPER(m);
- if (!m)
- break;
+ m = RCLASS(m)->super;
+ if (!m) break;
}
- rb_add_method(rb_singleton_class(module), id, fbody->nd_body->nd_body,
- NOEX_PUBLIC);
+ rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
}
return module;
}
@@ -2326,7 +7713,7 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
/*
* call-seq:
* append_features(mod) => mod
- *
+ *
* When this module is included in another, Ruby calls
* <code>append_features</code> in this module, passing it the
* receiving module in _mod_. Ruby's default implementation is
@@ -2336,7 +7723,8 @@ rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
*/
static VALUE
-rb_mod_append_features(VALUE module, VALUE include)
+rb_mod_append_features(module, include)
+ VALUE module, include;
{
switch (TYPE(include)) {
case T_CLASS:
@@ -2354,17 +7742,19 @@ rb_mod_append_features(VALUE module, VALUE include)
/*
* call-seq:
* include(module, ...) => self
- *
+ *
* Invokes <code>Module.append_features</code> on each parameter in turn.
*/
static VALUE
-rb_mod_include(int argc, VALUE *argv, VALUE module)
+rb_mod_include(argc, argv, module)
+ int argc;
+ VALUE *argv;
+ VALUE module;
{
int i;
- for (i = 0; i < argc; i++)
- Check_Type(argv[i], T_MODULE);
+ for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
while (argc--) {
rb_funcall(argv[argc], rb_intern("append_features"), 1, module);
rb_funcall(argv[argc], rb_intern("included"), 1, module);
@@ -2373,14 +7763,19 @@ rb_mod_include(int argc, VALUE *argv, VALUE module)
}
void
-rb_obj_call_init(VALUE obj, int argc, VALUE *argv)
+rb_obj_call_init(obj, argc, argv)
+ VALUE obj;
+ int argc;
+ VALUE *argv;
{
- PASS_PASSED_BLOCK();
+ PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
rb_funcall2(obj, init, argc, argv);
+ POP_ITER();
}
void
-rb_extend_object(VALUE obj, VALUE module)
+rb_extend_object(obj, module)
+ VALUE obj, module;
{
rb_include_module(rb_singleton_class(obj), module);
}
@@ -2388,11 +7783,11 @@ rb_extend_object(VALUE obj, VALUE module)
/*
* call-seq:
* extend_object(obj) => obj
- *
+ *
* Extends the specified object by adding this module's constants and
* methods (which are added as singleton methods). This is the callback
* method used by <code>Object#extend</code>.
- *
+ *
* module Picky
* def Picky.extend_object(o)
* if String === o
@@ -2405,15 +7800,16 @@ rb_extend_object(VALUE obj, VALUE module)
* end
* (s = Array.new).extend Picky # Call Object.extend
* (s = "quick brown fox").extend Picky
- *
+ *
* <em>produces:</em>
- *
+ *
* Picky added to Array
* Can't add Picky to a String
*/
static VALUE
-rb_mod_extend_object(VALUE mod, VALUE obj)
+rb_mod_extend_object(mod, obj)
+ VALUE mod, obj;
{
rb_extend_object(obj, mod);
return obj;
@@ -2422,22 +7818,22 @@ rb_mod_extend_object(VALUE mod, VALUE obj)
/*
* call-seq:
* obj.extend(module, ...) => obj
- *
+ *
* Adds to _obj_ the instance methods from each module given as a
* parameter.
- *
+ *
* module Mod
* def hello
* "Hello from Mod.\n"
* end
* end
- *
+ *
* class Klass
* def hello
* "Hello from Klass.\n"
* end
* end
- *
+ *
* k = Klass.new
* k.hello #=> "Hello from Klass.\n"
* k.extend(Mod) #=> #<Klass:0x401b3bc8>
@@ -2445,15 +7841,17 @@ rb_mod_extend_object(VALUE mod, VALUE obj)
*/
static VALUE
-rb_obj_extend(int argc, VALUE *argv, VALUE obj)
+rb_obj_extend(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
int i;
if (argc == 0) {
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
}
- for (i = 0; i < argc; i++)
- Check_Type(argv[i], T_MODULE);
+ for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
while (argc--) {
rb_funcall(argv[argc], rb_intern("extend_object"), 1, obj);
rb_funcall(argv[argc], rb_intern("extended"), 1, obj);
@@ -2464,22 +7862,22 @@ rb_obj_extend(int argc, VALUE *argv, VALUE obj)
/*
* call-seq:
* include(module, ...) => self
- *
+ *
* Invokes <code>Module.append_features</code>
* on each parameter in turn. Effectively adds the methods and constants
* in each module to the receiver.
*/
static VALUE
-top_include(int argc, VALUE *argv, VALUE self)
+top_include(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- rb_thread_t *th = GET_THREAD();
-
rb_secure(4);
- if (th->top_wrapper) {
- rb_warning
- ("main#include in the wrapped load is effective only in wrapper module");
- return rb_mod_include(argc, argv, th->top_wrapper);
+ if (ruby_wrapper) {
+ rb_warning("main#include in the wrapped load is effective only in wrapper module");
+ return rb_mod_include(argc, argv, ruby_wrapper);
}
return rb_mod_include(argc, argv, rb_cObject);
}
@@ -2487,185 +7885,261 @@ top_include(int argc, VALUE *argv, VALUE self)
VALUE rb_f_trace_var();
VALUE rb_f_untrace_var();
-static VALUE *
-errinfo_place(void)
+static void
+errinfo_setter(val, id, var)
+ VALUE val;
+ ID id;
+ VALUE *var;
{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
- rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th);
-
- while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp, end_cfp)) {
- if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
- if (cfp->iseq->type == ISEQ_TYPE_RESCUE) {
- return &cfp->dfp[-1];
- }
- else if (cfp->iseq->type == ISEQ_TYPE_ENSURE &&
- TYPE(cfp->dfp[-1]) != T_NODE &&
- !FIXNUM_P(cfp->dfp[-1])) {
- return &cfp->dfp[-1];
- }
- }
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ if (!NIL_P(val) && !rb_obj_is_kind_of(val, rb_eException)) {
+ rb_raise(rb_eTypeError, "assigning non-exception to $!");
}
- return 0;
+ *var = val;
}
static VALUE
-get_errinfo(void)
+errat_getter(id)
+ ID id;
{
- VALUE *ptr = errinfo_place();
- if (ptr) {
- return *ptr;
- }
- else {
- return Qnil;
- }
+ return get_backtrace(ruby_errinfo);
}
-static VALUE
-errinfo_getter(ID id)
+static void
+errat_setter(val, id, var)
+ VALUE val;
+ ID id;
+ VALUE *var;
{
- return get_errinfo();
+ if (NIL_P(ruby_errinfo)) {
+ rb_raise(rb_eArgError, "$! not set");
+ }
+ set_backtrace(ruby_errinfo, val);
}
-#if 0
-static void
-errinfo_setter(VALUE val, ID id, VALUE *var)
+/*
+ * call-seq:
+ * local_variables => array
+ *
+ * Returns the names of the current local variables.
+ *
+ * fred = 1
+ * for i in 1..10
+ * # ...
+ * end
+ * local_variables #=> ["fred", "i"]
+ */
+
+static VALUE
+rb_f_local_variables()
{
- if (!NIL_P(val) && !rb_obj_is_kind_of(val, rb_eException)) {
- rb_raise(rb_eTypeError, "assigning non-exception to $!");
- }
- else {
- VALUE *ptr = errinfo_place();
- if (ptr) {
- *ptr = val;
+ ID *tbl;
+ int n, i;
+ VALUE ary = rb_ary_new();
+ struct RVarmap *vars;
+
+ tbl = ruby_scope->local_tbl;
+ if (tbl) {
+ n = *tbl++;
+ for (i=2; i<n; i++) { /* skip first 2 ($_ and $~) */
+ if (!rb_is_local_id(tbl[i])) continue; /* skip flip states */
+ rb_ary_push(ary, rb_str_new2(rb_id2name(tbl[i])));
}
- else {
- rb_raise(rb_eRuntimeError, "errinfo_setter: not in rescue clause.");
+ }
+
+ vars = ruby_dyna_vars;
+ while (vars) {
+ if (vars->id && rb_is_local_id(vars->id)) { /* skip $_, $~ and flip states */
+ rb_ary_push(ary, rb_str_new2(rb_id2name(vars->id)));
}
+ vars = vars->next;
}
-}
-#endif
-VALUE
-rb_errinfo(void)
-{
- rb_thread_t *th = GET_THREAD();
- return th->errinfo;
+ return ary;
}
+static VALUE rb_f_catch _((VALUE,VALUE));
+NORETURN(static VALUE rb_f_throw _((int,VALUE*)));
+
+struct end_proc_data {
+ void (*func)();
+ VALUE data;
+ int safe;
+ struct end_proc_data *next;
+};
+
+static struct end_proc_data *end_procs, *ephemeral_end_procs, *tmp_end_procs;
+
void
-rb_set_errinfo(VALUE err)
+rb_set_end_proc(func, data)
+ void (*func) _((VALUE));
+ VALUE data;
{
- if (!NIL_P(err) && !rb_obj_is_kind_of(err, rb_eException)) {
- rb_raise(rb_eTypeError, "assigning non-exception to $!");
- }
- GET_THREAD()->errinfo = err;
+ struct end_proc_data *link = ALLOC(struct end_proc_data);
+ struct end_proc_data **list;
+
+ if (ruby_wrapper) list = &ephemeral_end_procs;
+ else list = &end_procs;
+ link->next = *list;
+ link->func = func;
+ link->data = data;
+ link->safe = ruby_safe_level;
+ *list = link;
}
-VALUE
-rb_rubylevel_errinfo(void)
+void
+rb_mark_end_proc()
{
- return get_errinfo();
-}
+ struct end_proc_data *link;
-static VALUE
-errat_getter(ID id)
-{
- VALUE err = get_errinfo();
- if (!NIL_P(err)) {
- return get_backtrace(err);
+ link = end_procs;
+ while (link) {
+ rb_gc_mark(link->data);
+ link = link->next;
}
- else {
- return Qnil;
+ link = ephemeral_end_procs;
+ while (link) {
+ rb_gc_mark(link->data);
+ link = link->next;
+ }
+ link = tmp_end_procs;
+ while (link) {
+ rb_gc_mark(link->data);
+ link = link->next;
}
}
+static void call_end_proc _((VALUE data));
+
static void
-errat_setter(VALUE val, ID id, VALUE *var)
+call_end_proc(data)
+ VALUE data;
{
- VALUE err = get_errinfo();
- if (NIL_P(err)) {
- rb_raise(rb_eArgError, "$! not set");
- }
- set_backtrace(err, val);
+ PUSH_ITER(ITER_NOT);
+ PUSH_FRAME();
+ ruby_frame->self = ruby_frame->prev->self;
+ ruby_frame->node = 0;
+ ruby_frame->last_func = 0;
+ ruby_frame->last_class = 0;
+ proc_invoke(data, rb_ary_new2(0), Qundef, 0);
+ POP_FRAME();
+ POP_ITER();
}
-int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
+static void
+rb_f_END()
+{
+ PUSH_FRAME();
+ ruby_frame->argc = 0;
+ ruby_frame->iter = ITER_CUR;
+ rb_set_end_proc(call_end_proc, rb_block_proc());
+ POP_FRAME();
+}
/*
* call-seq:
- * local_variables => array
- *
- * Returns the names of the current local variables.
- *
- * fred = 1
- * for i in 1..10
- * # ...
+ * at_exit { block } -> proc
+ *
+ * Converts _block_ to a +Proc+ object (and therefore
+ * binds it at the point of call) and registers it for execution when
+ * the program exits. If multiple handlers are registered, they are
+ * executed in reverse order of registration.
+ *
+ * def do_at_exit(str1)
+ * at_exit { print str1 }
* end
- * local_variables #=> ["fred", "i"]
+ * at_exit { puts "cruel world" }
+ * do_at_exit("goodbye ")
+ * exit
+ *
+ * <em>produces:</em>
+ *
+ * goodbye cruel world
*/
static VALUE
-rb_f_local_variables(void)
+rb_f_at_exit()
{
- VALUE ary = rb_ary_new();
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp =
- vm_get_ruby_level_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp));
- int i;
+ VALUE proc;
- while (1) {
- if (cfp->iseq) {
- for (i = 0; i < cfp->iseq->local_table_size; i++) {
- ID lid = cfp->iseq->local_table[i];
- if (lid) {
- const char *vname = rb_id2name(lid);
- /* should skip temporary variable */
- if (vname) {
- rb_ary_push(ary, rb_str_new2(vname));
- }
- }
- }
- }
- if (cfp->lfp != cfp->dfp) {
- /* block */
- VALUE *dfp = GC_GUARDED_PTR_REF(cfp->dfp[0]);
+ if (!rb_block_given_p()) {
+ rb_raise(rb_eArgError, "called without a block");
+ }
+ proc = rb_block_proc();
+ rb_set_end_proc(call_end_proc, proc);
+ return proc;
+}
- if (vm_collect_local_variables_in_heap(th, dfp, ary)) {
- break;
+void
+rb_exec_end_proc()
+{
+ struct end_proc_data *link, *tmp;
+ int status;
+ volatile int safe = ruby_safe_level;
+
+ while (ephemeral_end_procs) {
+ tmp_end_procs = link = ephemeral_end_procs;
+ ephemeral_end_procs = 0;
+ while (link) {
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ ruby_safe_level = link->safe;
+ (*link->func)(link->data);
}
- else {
- while (cfp->dfp != dfp) {
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
- }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
}
+ tmp = link;
+ tmp_end_procs = link = link->next;
+ free(tmp);
}
- else {
- break;
+ }
+ while (end_procs) {
+ tmp_end_procs = link = end_procs;
+ end_procs = 0;
+ while (link) {
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ ruby_safe_level = link->safe;
+ (*link->func)(link->data);
+ }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
+ }
+ tmp = link;
+ tmp_end_procs = link = link->next;
+ free(tmp);
}
}
- return ary;
+ ruby_safe_level = safe;
}
-
/*
* call-seq:
* __method__ => symbol
- * __callee__ => 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(void)
+rb_f_method_name()
{
- ID fname = rb_frame_callee();
-
- if (fname) {
- return ID2SYM(fname);
+ struct FRAME* prev = ruby_frame->prev;
+ if (prev && prev->orig_func) {
+ return ID2SYM(prev->orig_func);
}
else {
return Qnil;
@@ -2673,11 +8147,8 @@ rb_f_method_name(void)
}
void
-Init_eval(void)
+Init_eval()
{
- /* TODO: fix position */
- GET_THREAD()->vm->mark_object_ary = rb_ary_new();
-
init = rb_intern("initialize");
eqq = rb_intern("===");
each = rb_intern("each");
@@ -2693,39 +8164,48 @@ Init_eval(void)
undefined = rb_intern("method_undefined");
singleton_undefined = rb_intern("singleton_method_undefined");
- object_id = rb_intern("object_id");
+ __id__ = rb_intern("__id__");
__send__ = rb_intern("__send__");
- rb_define_virtual_variable("$@", errat_getter, errat_setter);
- rb_define_virtual_variable("$!", errinfo_getter, 0);
+ rb_global_variable((void *)&top_scope);
+ rb_global_variable((void *)&ruby_eval_tree_begin);
- rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);
+ rb_global_variable((void *)&ruby_eval_tree);
+ rb_global_variable((void *)&ruby_dyna_vars);
+
+ rb_define_virtual_variable("$@", errat_getter, errat_setter);
+ rb_define_hooked_variable("$!", &ruby_errinfo, 0, errinfo_setter);
rb_define_global_function("eval", rb_f_eval, -1);
rb_define_global_function("iterator?", rb_f_block_given_p, 0);
rb_define_global_function("block_given?", rb_f_block_given_p, 0);
+ rb_define_global_function("method_missing", rb_method_missing, -1);
rb_define_global_function("loop", rb_f_loop, 0);
rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
- respond_to = rb_intern("respond_to?");
+ respond_to = rb_intern("respond_to?");
+ rb_global_variable((void *)&basic_respond_to);
basic_respond_to = rb_method_node(rb_cObject, respond_to);
- rb_register_mark_object((VALUE)basic_respond_to);
-
+
rb_define_global_function("raise", rb_f_raise, -1);
rb_define_global_function("fail", rb_f_raise, -1);
rb_define_global_function("caller", rb_f_caller, -1);
- rb_define_global_function("global_variables", rb_f_global_variables, 0); /* in variable.c */
+ rb_define_global_function("exit", rb_f_exit, -1);
+ rb_define_global_function("abort", rb_f_abort, -1);
+
+ rb_define_global_function("at_exit", rb_f_at_exit, 0);
+
+ rb_define_global_function("catch", rb_f_catch, 1);
+ rb_define_global_function("throw", rb_f_throw, -1);
+ rb_define_global_function("global_variables", rb_f_global_variables, 0); /* 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_global_function("__callee__", rb_f_method_name, 0);
- rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);
rb_define_method(rb_mKernel, "send", rb_f_send, -1);
- rb_define_method(rb_mKernel, "public_send", rb_f_public_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);
@@ -2743,80 +8223,5403 @@ Init_eval(void)
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, "class_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");
- Init_eval_method();
+ rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1);
+ rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1);
+ rb_define_private_method(rb_cModule, "alias_method", rb_mod_alias_method, 2);
+ rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1);
rb_define_singleton_method(rb_cModule, "nesting", rb_mod_nesting, 0);
- rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1);
+ rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, 0);
- rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1);
- rb_define_singleton_method(rb_vm_top_self(), "public", top_public, -1);
- rb_define_singleton_method(rb_vm_top_self(), "private", top_private, -1);
+ rb_define_singleton_method(ruby_top_self, "include", top_include, -1);
+ rb_define_singleton_method(ruby_top_self, "public", top_public, -1);
+ rb_define_singleton_method(ruby_top_self, "private", top_private, -1);
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
- rb_define_global_function("trace_var", rb_f_trace_var, -1); /* in variable.c */
- rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
+ rb_define_global_function("trace_var", rb_f_trace_var, -1); /* in variable.c */
+ rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
+
+ rb_define_global_function("set_trace_func", set_trace_func, 1);
+ rb_global_variable(&trace_func);
rb_define_virtual_variable("$SAFE", safe_getter, safe_setter);
+}
+
+/*
+ * call-seq:
+ * mod.autoload(name, filename) => nil
+ *
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _name_ (which may be a <code>String</code> or
+ * a symbol) is accessed in the namespace of _mod_.
+ *
+ * module A
+ * end
+ * A.autoload(:B, "b")
+ * A::B.doit # autoloads "b"
+ */
+
+static VALUE
+rb_mod_autoload(mod, sym, file)
+ VALUE mod;
+ VALUE sym;
+ VALUE file;
+{
+ ID id = rb_to_id(sym);
+
+ Check_SafeStr(file);
+ rb_autoload(mod, id, RSTRING(file)->ptr);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * mod.autoload?(name) => String or nil
+ *
+ * Returns _filename_ to be loaded if _name_ is registered as
+ * +autoload+ in the namespace of _mod_.
+ *
+ * module A
+ * end
+ * A.autoload(:B, "b")
+ * A.autoload?(:B) # => "b"
+ */
+
+static VALUE
+rb_mod_autoload_p(mod, sym)
+ VALUE mod, sym;
+{
+ return rb_autoload_p(mod, rb_to_id(sym));
+}
+
+/*
+ * call-seq:
+ * autoload(module, filename) => nil
+ *
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _module_ (which may be a <code>String</code> or
+ * a symbol) is accessed.
+ *
+ * autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
+ */
+
+static VALUE
+rb_f_autoload(obj, sym, file)
+ VALUE obj;
+ VALUE sym;
+ VALUE file;
+{
+ if (NIL_P(ruby_cbase)) {
+ rb_raise(rb_eTypeError, "no class/module for autoload target");
+ }
+ return rb_mod_autoload(ruby_cbase, sym, file);
+}
+
+/*
+ * call-seq:
+ * autoload(module, filename) => nil
+ *
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _module_ (which may be a <code>String</code> or
+ * a symbol) is accessed.
+ *
+ * autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
+ */
+
+static VALUE
+rb_f_autoload_p(obj, sym)
+ VALUE obj;
+ VALUE sym;
+{
+ /* use ruby_cbase as same as rb_f_autoload. */
+ if (NIL_P(ruby_cbase)) {
+ return Qfalse;
+ }
+ return rb_mod_autoload_p(ruby_cbase, sym);
+}
+
+void
+Init_load()
+{
+ rb_define_readonly_variable("$:", &rb_load_path);
+ rb_define_readonly_variable("$-I", &rb_load_path);
+ rb_define_readonly_variable("$LOAD_PATH", &rb_load_path);
+ rb_load_path = rb_ary_new();
+
+ rb_define_readonly_variable("$\"", &rb_features);
+ rb_define_readonly_variable("$LOADED_FEATURES", &rb_features);
+ rb_features = rb_ary_new();
+
+ rb_define_global_function("load", rb_f_load, -1);
+ rb_define_global_function("require", rb_f_require, 1);
+ rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
+ rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
+ rb_define_global_function("autoload", rb_f_autoload, 2);
+ rb_define_global_function("autoload?", rb_f_autoload_p, 1);
+ rb_global_variable(&ruby_wrapper);
+
+ rb_global_variable(&ruby_dln_librefs);
+ ruby_dln_librefs = rb_ary_new();
+}
+
+static void
+scope_dup(scope)
+ struct SCOPE *scope;
+{
+ ID *tbl;
+ VALUE *vars;
+
+ scope->flags |= SCOPE_DONT_RECYCLE;
+ if (scope->flags & SCOPE_MALLOC) return;
+
+ if (scope->local_tbl) {
+ tbl = scope->local_tbl;
+ vars = ALLOC_N(VALUE, tbl[0]+1);
+ *vars++ = scope->local_vars[-1];
+ MEMCPY(vars, scope->local_vars, VALUE, tbl[0]);
+ scope->local_vars = vars;
+ scope->flags |= SCOPE_MALLOC;
+ }
+}
+
+static void
+blk_mark(data)
+ struct BLOCK *data;
+{
+ while (data) {
+ rb_gc_mark_frame(&data->frame);
+ rb_gc_mark((VALUE)data->scope);
+ rb_gc_mark((VALUE)data->var);
+ rb_gc_mark((VALUE)data->body);
+ rb_gc_mark((VALUE)data->self);
+ rb_gc_mark((VALUE)data->dyna_vars);
+ rb_gc_mark((VALUE)data->cref);
+ rb_gc_mark(data->wrapper);
+ rb_gc_mark(data->block_obj);
+ data = data->prev;
+ }
+}
+
+static void
+frame_free(frame)
+ struct FRAME *frame;
+{
+ struct FRAME *tmp;
+
+ frame = frame->prev;
+ while (frame) {
+ tmp = frame;
+ frame = frame->prev;
+ free(tmp);
+ }
+}
+
+static void
+blk_free(data)
+ struct BLOCK *data;
+{
+ void *tmp;
+
+ while (data) {
+ frame_free(&data->frame);
+ tmp = data;
+ data = data->prev;
+ free(tmp);
+ }
+}
+
+static void
+frame_dup(frame)
+ struct FRAME *frame;
+{
+ struct FRAME *tmp;
+
+ for (;;) {
+ frame->tmp = 0; /* should not preserve tmp */
+ if (!frame->prev) break;
+ tmp = ALLOC(struct FRAME);
+ *tmp = *frame->prev;
+ frame->prev = tmp;
+ frame = tmp;
+ }
+}
+
+
+static void
+blk_copy_prev(block)
+ struct BLOCK *block;
+{
+ struct BLOCK *tmp;
+ struct RVarmap* vars;
+
+ while (block->prev) {
+ tmp = ALLOC_N(struct BLOCK, 1);
+ MEMCPY(tmp, block->prev, struct BLOCK, 1);
+ scope_dup(tmp->scope);
+ frame_dup(&tmp->frame);
+
+ for (vars = tmp->dyna_vars; vars; vars = vars->next) {
+ if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
+
+ block->prev = tmp;
+ block = tmp;
+ }
+}
+
+
+static void
+blk_dup(dup, orig)
+ struct BLOCK *dup, *orig;
+{
+ MEMCPY(dup, orig, struct BLOCK, 1);
+ frame_dup(&dup->frame);
+
+ if (dup->iter) {
+ blk_copy_prev(dup);
+ }
+ else {
+ dup->prev = 0;
+ }
+}
+
+/*
+ * MISSING: documentation
+ */
+
+static VALUE
+proc_clone(self)
+ VALUE self;
+{
+ struct BLOCK *orig, *data;
+ VALUE bind;
+
+ Data_Get_Struct(self, struct BLOCK, orig);
+ bind = Data_Make_Struct(rb_obj_class(self),struct BLOCK,blk_mark,blk_free,data);
+ CLONESETUP(bind, self);
+ blk_dup(data, orig);
+
+ return bind;
+}
+
+/*
+ * MISSING: documentation
+ */
+
+#define PROC_TSHIFT (FL_USHIFT+1)
+#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
+#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
+
+static int proc_get_safe_level(VALUE);
+
+static VALUE
+proc_dup(self)
+ VALUE self;
+{
+ struct BLOCK *orig, *data;
+ VALUE bind;
+ int safe = proc_get_safe_level(self);
+
+ Data_Get_Struct(self, struct BLOCK, orig);
+ bind = Data_Make_Struct(rb_obj_class(self),struct BLOCK,blk_mark,blk_free,data);
+ blk_dup(data, orig);
+ if (safe > PROC_TMAX) safe = PROC_TMAX;
+ FL_SET(bind, (safe << PROC_TSHIFT) & PROC_TMASK);
+
+ 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
+ *
+ * Returns a +Binding+ object, describing the variable and
+ * method bindings at the point of call. This object can be used when
+ * calling +eval+ to execute the evaluated command in this
+ * environment. Also see the description of class +Binding+.
+ *
+ * def getBinding(param)
+ * return binding
+ * end
+ * b = getBinding("hello")
+ * eval("param", b) #=> "hello"
+ */
+
+static VALUE
+rb_f_binding(self)
+ VALUE self;
+{
+ struct BLOCK *data, *p;
+ struct RVarmap *vars;
+ VALUE bind;
+
+ PUSH_BLOCK(0,0);
+ bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
+ *data = *ruby_block;
+
+ data->orig_thread = rb_thread_current();
+ data->wrapper = ruby_wrapper;
+ data->iter = rb_f_block_given_p();
+ frame_dup(&data->frame);
+ if (ruby_frame->prev) {
+ data->frame.last_func = ruby_frame->prev->last_func;
+ data->frame.last_class = ruby_frame->prev->last_class;
+ data->frame.orig_func = ruby_frame->prev->orig_func;
+ }
+
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
+
+ for (p = data; p; p = p->prev) {
+ for (vars = p->dyna_vars; vars; vars = vars->next) {
+ if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
+ }
+ scope_dup(data->scope);
+ POP_BLOCK();
+
+ 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
+proc_save_safe_level(data)
+ VALUE data;
+{
+ int safe = ruby_safe_level;
+ if (safe > PROC_TMAX) safe = PROC_TMAX;
+ FL_SET(data, (safe << PROC_TSHIFT) & PROC_TMASK);
+}
+
+static int
+proc_get_safe_level(data)
+ VALUE data;
+{
+ return (RBASIC(data)->flags & PROC_TMASK) >> PROC_TSHIFT;
+}
+
+static void
+proc_set_safe_level(data)
+ VALUE data;
+{
+ ruby_safe_level = proc_get_safe_level(data);
+}
+
+static VALUE
+proc_alloc(klass, proc)
+ VALUE klass;
+ int proc;
+{
+ volatile VALUE block;
+ struct BLOCK *data, *p;
+ struct RVarmap *vars;
+
+ if (!rb_block_given_p() && !rb_f_block_given_p()) {
+ rb_raise(rb_eArgError, "tried to create Proc object without a block");
+ }
+ if (proc && !rb_block_given_p()) {
+ rb_warn("tried to create Proc object without a block");
+ }
+
+ if (!proc && ruby_block->block_obj && CLASS_OF(ruby_block->block_obj) == klass) {
+ return ruby_block->block_obj;
+ }
+ block = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
+ *data = *ruby_block;
+
+ data->orig_thread = rb_thread_current();
+ data->wrapper = ruby_wrapper;
+ data->iter = data->prev?Qtrue:Qfalse;
+ data->block_obj = block;
+ frame_dup(&data->frame);
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
+
+ for (p = data; p; p = p->prev) {
+ for (vars = p->dyna_vars; vars; vars = vars->next) {
+ if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
+ }
+ scope_dup(data->scope);
+ proc_save_safe_level(block);
+ if (proc) {
+ data->flags |= BLOCK_LAMBDA;
+ }
+ else {
+ ruby_block->block_obj = block;
+ }
+
+ return block;
+}
+
+/*
+ * call-seq:
+ * Proc.new {|...| block } => a_proc
+ * Proc.new => a_proc
+ *
+ * Creates a new <code>Proc</code> object, bound to the current
+ * context. <code>Proc::new</code> may be called without a block only
+ * within a method with an attached block, in which case that block is
+ * converted to the <code>Proc</code> object.
+ *
+ * def proc_from
+ * Proc.new
+ * end
+ * proc = proc_from { "hello" }
+ * proc.call #=> "hello"
+ */
+
+static VALUE
+proc_s_new(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE block = proc_alloc(klass, Qfalse);
+
+ rb_obj_call_init(block, argc, argv);
+ return block;
+}
+
+VALUE
+rb_block_proc()
+{
+ return proc_alloc(rb_cProc, Qfalse);
+}
+
+VALUE
+rb_f_lambda()
+{
+ rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
+ return proc_alloc(rb_cProc, Qtrue);
+}
+
+/*
+ * call-seq:
+ * proc { |...| block } => a_proc
+ * lambda { |...| block } => a_proc
+ *
+ * Equivalent to <code>Proc.new</code>, except the resulting Proc objects
+ * check the number of parameters passed when called.
+ */
+
+static VALUE
+proc_lambda()
+{
+ return proc_alloc(rb_cProc, Qtrue);
+}
+
+static int
+block_orphan(data)
+ struct BLOCK *data;
+{
+ if (data->scope->flags & SCOPE_NOSTACK) {
+ return 1;
+ }
+ if (data->orig_thread != rb_thread_current()) {
+ return 1;
+ }
+ return 0;
+}
+
+static VALUE
+proc_invoke(proc, args, self, klass)
+ VALUE proc, args; /* OK */
+ VALUE self, klass;
+{
+ struct BLOCK * volatile old_block;
+ struct BLOCK _block;
+ struct BLOCK *data;
+ volatile VALUE result = Qundef;
+ int state;
+ volatile int safe = ruby_safe_level;
+ 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();
+ }
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ pcall = (data->flags & BLOCK_LAMBDA) ? YIELD_LAMBDA_CALL : 0;
+ if (!pcall && RARRAY(args)->len == 1) {
+ avalue = Qfalse;
+ args = RARRAY(args)->ptr[0];
+ }
+
+ PUSH_VARS();
+ ruby_wrapper = data->wrapper;
+ ruby_dyna_vars = data->dyna_vars;
+ /* PUSH BLOCK from data */
+ old_block = ruby_block;
+ _block = *data;
+ _block.block_obj = bvar;
+ if (self != Qundef) _block.frame.self = self;
+ if (klass) _block.frame.last_class = klass;
+ _block.frame.argc = RARRAY(tmp)->len;
+ _block.frame.flags = ruby_frame->flags;
+ if (_block.frame.argc && DMETHOD_P()) {
+ NEWOBJ(scope, struct SCOPE);
+ OBJSETUP(scope, tmp, T_SCOPE);
+ scope->local_tbl = _block.scope->local_tbl;
+ scope->local_vars = _block.scope->local_vars;
+ scope->flags |= SCOPE_CLONE;
+ _block.scope = scope;
+ }
+ /* modify current frame */
+ ruby_block = &_block;
+ PUSH_ITER(ITER_CUR);
+ ruby_frame->iter = ITER_CUR;
+ PUSH_TAG(pcall ? PROT_LAMBDA : PROT_NONE);
+ 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);
+ }
+ else if (TAG_DST()) {
+ result = prot_tag->retval;
+ }
+ POP_TAG();
+ POP_ITER();
+ ruby_block = old_block;
+ ruby_wrapper = old_wrapper;
+ POP_VARS();
+ ruby_safe_level = safe;
+
+ switch (state) {
+ case 0:
+ break;
+ case TAG_RETRY:
+ proc_jump_error(TAG_RETRY, Qnil); /* xxx */
+ JUMP_TAG(state);
+ break;
+ case TAG_NEXT:
+ case TAG_BREAK:
+ if (!pcall && result != Qundef) {
+ proc_jump_error(state, result);
+ }
+ case TAG_RETURN:
+ if (result != Qundef) {
+ if (pcall) break;
+ return_jump(result);
+ }
+ default:
+ JUMP_TAG(state);
+ }
+ return result;
+}
+
+/* CHECKME: are the argument checking semantics correct? */
+
+/*
+ * call-seq:
+ * prc.call(params,...) => obj
+ * prc[params,...] => obj
+ *
+ * Invokes the block, setting the block's parameters to the values in
+ * <i>params</i> using something close to method calling semantics.
+ * Generates a warning if multiple values are passed to a proc that
+ * expects just one (previously this silently converted the parameters
+ * to an array).
+ *
+ * For procs created using <code>Kernel.proc</code>, generates an
+ * error if the wrong number of parameters
+ * are passed to a proc with multiple parameters. For procs created using
+ * <code>Proc.new</code>, extra parameters are silently discarded.
+ *
+ * Returns the value of the last expression evaluated in the block. See
+ * also <code>Proc#yield</code>.
+ *
+ * a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
+ * a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
+ * a_proc[9, 1, 2, 3] #=> [9, 18, 27]
+ * a_proc = Proc.new {|a,b| a}
+ * a_proc.call(1,2,3)
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
+ * from prog.rb:4:in `call'
+ * from prog.rb:5
+ */
+
+VALUE
+rb_proc_call(proc, args)
+ VALUE proc, args; /* OK */
+{
+ return proc_invoke(proc, args, Qundef, 0);
+}
+
+static VALUE bmcall _((VALUE, VALUE));
+static VALUE method_arity _((VALUE));
+
+/*
+ * call-seq:
+ * prc.arity -> fixnum
+ *
+ * Returns the number of arguments that would not be ignored. If the block
+ * is declared to take no arguments, returns 0. If the block is known
+ * to take exactly n arguments, returns n. If the block has optional
+ * arguments, return -n-1, where n is the number of mandatory
+ * arguments. A <code>proc</code> with no argument declarations
+ * is the same a block declaring <code>||</code> as its arguments.
+ *
+ * Proc.new {}.arity #=> 0
+ * Proc.new {||}.arity #=> 0
+ * Proc.new {|a|}.arity #=> 1
+ * Proc.new {|a,b|}.arity #=> 2
+ * Proc.new {|a,b,c|}.arity #=> 3
+ * Proc.new {|*a|}.arity #=> -1
+ * Proc.new {|a,*b|}.arity #=> -2
+ */
+
+static VALUE
+proc_arity(proc)
+ VALUE proc;
+{
+ struct BLOCK *data;
+ NODE *var, *list;
+ int n;
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ var = data->var;
+ if (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)) {
+ default:
+ return INT2FIX(1);
+ case NODE_MASGN:
+ list = var->nd_head;
+ n = 0;
+ while (list) {
+ n++;
+ list = list->nd_next;
+ }
+ if (var->nd_args) return INT2FIX(-n-1);
+ return INT2FIX(n);
+ }
+}
+
+/*
+ * call-seq:
+ * prc == other_proc => true or false
+ *
+ * Return <code>true</code> if <i>prc</i> is the same object as
+ * <i>other_proc</i>, or if they are both procs with the same body.
+ */
+
+static VALUE
+proc_eq(self, other)
+ VALUE self, other;
+{
+ struct BLOCK *data, *data2;
+
+ if (self == other) return Qtrue;
+ if (TYPE(other) != T_DATA) return Qfalse;
+ if (RDATA(other)->dmark != (RUBY_DATA_FUNC)blk_mark) return Qfalse;
+ if (CLASS_OF(self) != CLASS_OF(other)) return Qfalse;
+ Data_Get_Struct(self, struct BLOCK, data);
+ Data_Get_Struct(other, struct BLOCK, data2);
+ if (data->body != data2->body) return Qfalse;
+ if (data->var != data2->var) return Qfalse;
+ if (data->scope != data2->scope) return Qfalse;
+ if (data->dyna_vars != data2->dyna_vars) return Qfalse;
+ if (data->flags != data2->flags) return Qfalse;
+
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * prc.to_s => string
+ *
+ * Shows the unique identifier for this proc, along with
+ * an indication of where the proc was defined.
+ */
+
+static VALUE
+proc_to_s(self)
+ VALUE self;
+{
+ struct BLOCK *data;
+ NODE *node;
+ const 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;
+
+ Data_Get_Struct(self, struct BLOCK, data);
+ if ((node = data->frame.node) || (node = data->body)) {
+ len += strlen(node->nd_file) + 2 + (SIZEOF_LONG*CHAR_BIT-NODE_LSHIFT)/3;
+ str = rb_str_new(0, len);
+ snprintf(RSTRING(str)->ptr, len+1,
+ "#<%s:0x%.*lx@%s:%d>", cname, w, (VALUE)data->body,
+ node->nd_file, nd_line(node));
+ }
+ else {
+ str = rb_str_new(0, len);
+ snprintf(RSTRING(str)->ptr, len+1,
+ "#<%s:0x%.*lx>", cname, w, (VALUE)data->body);
+ }
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ if (OBJ_TAINTED(self)) OBJ_TAINT(str);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * prc.to_proc -> prc
+ *
+ * Part of the protocol for converting objects to <code>Proc</code>
+ * objects. Instances of class <code>Proc</code> simply return
+ * themselves.
+ */
+
+static VALUE
+proc_to_self(self)
+ VALUE self;
+{
+ return self;
+}
+
+/*
+ * call-seq:
+ * prc.binding => binding
+ *
+ * Returns the binding associated with <i>prc</i>. Note that
+ * <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
+ * <code>Binding</code> object as its second parameter.
+ *
+ * def fred(param)
+ * proc {}
+ * end
+ *
+ * b = fred(99)
+ * eval("param", b.binding) #=> 99
+ * eval("param", b) #=> 99
+ */
+
+static VALUE
+proc_binding(proc)
+ VALUE proc;
+{
+ struct BLOCK *orig, *data;
+ VALUE bind;
+
+ Data_Get_Struct(proc, struct BLOCK, orig);
+ bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
+ MEMCPY(data, orig, struct BLOCK, 1);
+ frame_dup(&data->frame);
+
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
+
+ return bind;
+}
+
+static VALUE
+block_pass(self, node)
+ VALUE self;
+ NODE *node;
+{
+ VALUE proc = rb_eval(self, node->nd_body); /* OK */
+ VALUE b;
+ struct BLOCK * volatile old_block;
+ struct BLOCK _block;
+ struct BLOCK *data;
+ volatile VALUE result = Qnil;
+ int state;
+ volatile int orphan;
+ volatile int safe = ruby_safe_level;
+
+ if (NIL_P(proc)) {
+ PUSH_ITER(ITER_NOT);
+ result = rb_eval(self, node->nd_iter);
+ POP_ITER();
+ return result;
+ }
+ if (!rb_obj_is_proc(proc)) {
+ b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
+ if (!rb_obj_is_proc(b)) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
+ rb_obj_classname(proc));
+ }
+ proc = b;
+ }
+
+ if (ruby_safe_level >= 1 && OBJ_TAINTED(proc) &&
+ ruby_safe_level > proc_get_safe_level(proc)) {
+ rb_raise(rb_eSecurityError, "Insecure: tainted block value");
+ }
+
+ if (ruby_block && ruby_block->block_obj == proc) {
+ PUSH_ITER(ITER_PAS);
+ result = rb_eval(self, node->nd_iter);
+ POP_ITER();
+ return result;
+ }
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ orphan = block_orphan(data);
- exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
- rb_ivar_set(exception_error, idThrowState, INT2FIX(TAG_FATAL));
- rb_register_mark_object(exception_error);
+ /* PUSH BLOCK from data */
+ old_block = ruby_block;
+ _block = *data;
+ _block.outer = ruby_block;
+ if (orphan) _block.uniq = block_unique++;
+ ruby_block = &_block;
+ PUSH_ITER(ITER_PRE);
+ if (ruby_frame->iter == ITER_NOT)
+ ruby_frame->iter = ITER_PRE;
+
+ PUSH_TAG(PROT_LOOP);
+ state = EXEC_TAG();
+ if (state == 0) {
+ retry:
+ proc_set_safe_level(proc);
+ if (safe > ruby_safe_level)
+ ruby_safe_level = safe;
+ result = rb_eval(self, node->nd_iter);
+ }
+ else if (state == TAG_BREAK && TAG_DST()) {
+ result = prot_tag->retval;
+ state = 0;
+ }
+ else if (state == TAG_RETRY) {
+ state = 0;
+ goto retry;
+ }
+ POP_TAG();
+ POP_ITER();
+ ruby_block = old_block;
+ ruby_safe_level = safe;
+
+ switch (state) {/* escape from orphan block */
+ case 0:
+ break;
+ case TAG_RETURN:
+ if (orphan) {
+ proc_jump_error(state, prot_tag->retval);
+ }
+ default:
+ JUMP_TAG(state);
+ }
+
+ return result;
+}
+
+struct METHOD {
+ VALUE klass, rklass;
+ VALUE recv;
+ ID id, oid;
+ int safe_level;
+ NODE *body;
+};
+
+static void
+bm_mark(data)
+ struct METHOD *data;
+{
+ rb_gc_mark(data->rklass);
+ rb_gc_mark(data->klass);
+ rb_gc_mark(data->recv);
+ rb_gc_mark((VALUE)data->body);
}
+static VALUE
+mnew(klass, obj, id, mklass)
+ VALUE klass, obj, mklass;
+ ID id;
+{
+ VALUE method;
+ NODE *body;
+ int noex;
+ struct METHOD *data;
+ VALUE rklass = klass;
+ ID oid = id;
-/* for parser */
+ again:
+ if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
+ print_undef(rklass, oid);
+ }
+
+ if (nd_type(body) == NODE_ZSUPER) {
+ klass = RCLASS(klass)->super;
+ goto again;
+ }
+
+ while (rklass != klass &&
+ (FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
+ rklass = RCLASS(rklass)->super;
+ }
+ if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass;
+ method = Data_Make_Struct(mklass, struct METHOD, bm_mark, free, data);
+ data->klass = klass;
+ data->recv = obj;
+ data->id = id;
+ data->body = body;
+ data->rklass = rklass;
+ data->oid = oid;
+ data->safe_level = NOEX_WITH_SAFE(noex);
+ OBJ_INFECT(method, klass);
+
+ return method;
+}
+
+
+/**********************************************************************
+ *
+ * Document-class : Method
+ *
+ * Method objects are created by <code>Object#method</code>, and are
+ * associated with a particular object (not just with a class). They
+ * may be used to invoke the method within the object, and as a block
+ * associated with an iterator. They may also be unbound from one
+ * object (creating an <code>UnboundMethod</code>) and bound to
+ * another.
+ *
+ * class Thing
+ * def square(n)
+ * n*n
+ * end
+ * end
+ * thing = Thing.new
+ * meth = thing.method(:square)
+ *
+ * meth.call(9) #=> 81
+ * [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
+ *
+ */
+
+/*
+ * call-seq:
+ * meth == other_meth => true or false
+ *
+ * Two method objects are equal if that are bound to the same
+ * object and contain the same body.
+ */
+
+
+static VALUE
+method_eq(method, other)
+ VALUE method, other;
+{
+ struct METHOD *m1, *m2;
+
+ if (TYPE(other) != T_DATA || RDATA(other)->dmark != (RUBY_DATA_FUNC)bm_mark)
+ return Qfalse;
+ if (CLASS_OF(method) != CLASS_OF(other))
+ return Qfalse;
+
+ Data_Get_Struct(method, struct METHOD, m1);
+ Data_Get_Struct(other, struct METHOD, m2);
+
+ if (m1->klass != m2->klass || m1->rklass != m2->rklass ||
+ m1->recv != m2->recv || m1->body != m2->body)
+ return Qfalse;
+
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * meth.unbind => unbound_method
+ *
+ * Dissociates <i>meth</i> from it's current receiver. The resulting
+ * <code>UnboundMethod</code> can subsequently be bound to a new object
+ * of the same class (see <code>UnboundMethod</code>).
+ */
+
+static VALUE
+method_unbind(obj)
+ VALUE obj;
+{
+ VALUE method;
+ struct METHOD *orig, *data;
+
+ Data_Get_Struct(obj, struct METHOD, orig);
+ method = Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, free, data);
+ data->klass = orig->klass;
+ data->recv = Qundef;
+ data->id = orig->id;
+ data->body = orig->body;
+ data->rklass = orig->rklass;
+ data->oid = orig->oid;
+ OBJ_INFECT(method, obj);
+
+ return method;
+}
+
+/*
+ * 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
+ * <code>Method</code> object (or raising <code>NameError</code>). The
+ * <code>Method</code> object acts as a closure in <i>obj</i>'s object
+ * instance, so instance variables and the value of <code>self</code>
+ * remain available.
+ *
+ * class Demo
+ * def initialize(n)
+ * @iv = n
+ * end
+ * def hello()
+ * "Hello, @iv = #{@iv}"
+ * end
+ * end
+ *
+ * k = Demo.new(99)
+ * m = k.method(:hello)
+ * m.call #=> "Hello, @iv = 99"
+ *
+ * l = Demo.new('Fred')
+ * m = l.method("hello")
+ * m.call #=> "Hello, @iv = Fred"
+ */
+
+VALUE
+rb_obj_method(obj, vid)
+ VALUE obj;
+ VALUE vid;
+{
+ return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod);
+}
+
+/*
+ * call-seq:
+ * mod.instance_method(symbol) => unbound_method
+ *
+ * Returns an +UnboundMethod+ representing the given
+ * instance method in _mod_.
+ *
+ * class Interpreter
+ * def do_a() print "there, "; end
+ * def do_d() print "Hello "; end
+ * def do_e() print "!\n"; end
+ * def do_v() print "Dave"; end
+ * Dispatcher = {
+ * ?a => instance_method(:do_a),
+ * ?d => instance_method(:do_d),
+ * ?e => instance_method(:do_e),
+ * ?v => instance_method(:do_v)
+ * }
+ * def interpret(string)
+ * string.each_byte {|b| Dispatcher[b].bind(self).call }
+ * end
+ * end
+ *
+ *
+ * interpreter = Interpreter.new
+ * interpreter.interpret('dave')
+ *
+ * <em>produces:</em>
+ *
+ * Hello there, Dave!
+ */
+
+static VALUE
+rb_mod_method(mod, vid)
+ VALUE mod;
+ VALUE vid;
+{
+ return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod);
+}
+
+/*
+ * MISSING: documentation
+ */
+
+static VALUE
+method_clone(self)
+ VALUE self;
+{
+ 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);
+ CLONESETUP(clone, self);
+ *data = *orig;
+
+ 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
+ * meth[args, ...] => obj
+ *
+ * Invokes the <i>meth</i> with the specified arguments, returning the
+ * method's return value.
+ *
+ * m = 12.method("+")
+ * m.call(3) #=> 15
+ * m.call(20) #=> 32
+ */
+
+static VALUE
+method_call(argc, argv, method)
+ int argc;
+ VALUE *argv;
+ VALUE method;
+{
+ VALUE result = Qnil; /* OK */
+ struct METHOD *data;
+ int safe;
+
+ Data_Get_Struct(method, struct METHOD, data);
+ if (data->recv == Qundef) {
+ rb_raise(rb_eTypeError, "can't call unbound method; bind first");
+ }
+ if (OBJ_TAINTED(method)) {
+ safe = NOEX_WITH(data->safe_level, 4)|NOEX_TAINTED;
+ }
+ else {
+ safe = data->safe_level;
+ }
+ PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
+ result = rb_call0(data->klass,data->recv,data->id,data->oid,argc,argv,data->body,safe);
+ POP_ITER();
+ return result;
+}
+
+/**********************************************************************
+ *
+ * Document-class: UnboundMethod
+ *
+ * Ruby supports two forms of objectified methods. Class
+ * <code>Method</code> is used to represent methods that are associated
+ * with a particular object: these method objects are bound to that
+ * object. Bound method objects for an object can be created using
+ * <code>Object#method</code>.
+ *
+ * Ruby also supports unbound methods; methods objects that are not
+ * associated with a particular object. These can be created either by
+ * calling <code>Module#instance_method</code> or by calling
+ * <code>unbind</code> on a bound method object. The result of both of
+ * these is an <code>UnboundMethod</code> object.
+ *
+ * Unbound methods can only be called after they are bound to an
+ * object. That object must be be a kind_of? the method's original
+ * class.
+ *
+ * class Square
+ * def area
+ * @side * @side
+ * end
+ * def initialize(side)
+ * @side = side
+ * end
+ * end
+ *
+ * area_un = Square.instance_method(:area)
+ *
+ * s = Square.new(12)
+ * area = area_un.bind(s)
+ * area.call #=> 144
+ *
+ * Unbound methods are a reference to the method at the time it was
+ * objectified: subsequent changes to the underlying class will not
+ * affect the unbound method.
+ *
+ * class Test
+ * def test
+ * :original
+ * end
+ * end
+ * um = Test.instance_method(:test)
+ * class Test
+ * def test
+ * :modified
+ * end
+ * end
+ * t = Test.new
+ * t.test #=> :modified
+ * um.bind(t).call #=> :original
+ *
+ */
+
+/*
+ * call-seq:
+ * umeth.bind(obj) -> method
+ *
+ * Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
+ * from which <i>umeth</i> was obtained,
+ * <code>obj.kind_of?(Klass)</code> must be true.
+ *
+ * class A
+ * def test
+ * puts "In test, class = #{self.class}"
+ * end
+ * end
+ * class B < A
+ * end
+ * class C < B
+ * end
+ *
+ *
+ * um = B.instance_method(:test)
+ * bm = um.bind(C.new)
+ * bm.call
+ * bm = um.bind(B.new)
+ * bm.call
+ * bm = um.bind(A.new)
+ * bm.call
+ *
+ * <em>produces:</em>
+ *
+ * In test, class = C
+ * In test, class = B
+ * prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
+ * from prog.rb:16
+ */
+
+static VALUE
+umethod_bind(method, recv)
+ VALUE method, recv;
+{
+ struct METHOD *data, *bound;
+ VALUE rklass = CLASS_OF(recv);
+
+ Data_Get_Struct(method, struct METHOD, data);
+ if (data->rklass != rklass) {
+ if (FL_TEST(data->rklass, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "singleton method bound for a different object");
+ }
+ if (TYPE(data->rklass) == T_MODULE) {
+ st_table *m_tbl = RCLASS(data->rklass)->m_tbl;
+ while (RCLASS(rklass)->m_tbl != m_tbl) {
+ rklass = RCLASS(rklass)->super;
+ if (!rklass) goto not_instace;
+ }
+ }
+ else if (!rb_obj_is_kind_of(recv, data->rklass)) {
+ not_instace:
+ rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
+ rb_class2name(data->rklass));
+ }
+ }
+
+ method = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,bound);
+ *bound = *data;
+ bound->recv = recv;
+ bound->rklass = rklass;
+
+ return method;
+}
+
+/*
+ * call-seq:
+ * meth.arity => fixnum
+ *
+ * Returns an indication of the number of arguments accepted by a
+ * method. Returns a nonnegative integer for methods that take a fixed
+ * number of arguments. For Ruby methods that take a variable number of
+ * arguments, returns -n-1, where n is the number of required
+ * arguments. For methods written in C, returns -1 if the call takes a
+ * variable number of arguments.
+ *
+ * class C
+ * def one; end
+ * def two(a); end
+ * def three(*a); end
+ * def four(a, b); end
+ * def five(a, b, *c); end
+ * def six(a, b, *c, &d); end
+ * end
+ * c = C.new
+ * c.method(:one).arity #=> 0
+ * c.method(:two).arity #=> 1
+ * c.method(:three).arity #=> -1
+ * c.method(:four).arity #=> 2
+ * c.method(:five).arity #=> -3
+ * c.method(:six).arity #=> -3
+ *
+ * "cat".method(:size).arity #=> 0
+ * "cat".method(:replace).arity #=> 1
+ * "cat".method(:squeeze).arity #=> -1
+ * "cat".method(:count).arity #=> -1
+ */
+
+static VALUE
+method_arity(method)
+ VALUE method;
+{
+ struct METHOD *data;
+ NODE *body;
+ int n;
+
+ Data_Get_Struct(method, struct METHOD, data);
+
+ body = data->body;
+ switch (nd_type(body)) {
+ case NODE_CFUNC:
+ if (body->nd_argc < 0) return INT2FIX(-1);
+ return INT2FIX(body->nd_argc);
+ case NODE_ZSUPER:
+ return INT2FIX(-1);
+ case NODE_ATTRSET:
+ return INT2FIX(1);
+ case NODE_IVAR:
+ return INT2FIX(0);
+ case NODE_BMETHOD:
+ return proc_arity(body->nd_cval);
+ case NODE_DMETHOD:
+ return method_arity(body->nd_cval);
+ case NODE_SCOPE:
+ body = body->nd_next; /* skip NODE_SCOPE */
+ if (nd_type(body) == NODE_BLOCK)
+ body = body->nd_head;
+ if (!body) return INT2FIX(0);
+ n = body->nd_cnt;
+ if (body->nd_opt || body->nd_rest)
+ n = -n-1;
+ return INT2FIX(n);
+ default:
+ rb_raise(rb_eArgError, "invalid node 0x%x", nd_type(body));
+ }
+}
+
+/*
+ * call-seq:
+ * meth.to_s => string
+ * meth.inspect => string
+ *
+ * Show the name of the underlying method.
+ *
+ * "cat".method(:count).inspect #=> "#<Method: String#count>"
+ */
+
+static VALUE
+method_inspect(method)
+ VALUE method;
+{
+ struct METHOD *data;
+ VALUE str;
+ const char *s;
+ const char *sharp = "#";
+
+ Data_Get_Struct(method, struct METHOD, data);
+ str = rb_str_buf_new2("#<");
+ s = rb_obj_classname(method);
+ rb_str_buf_cat2(str, s);
+ rb_str_buf_cat2(str, ": ");
+
+ if (FL_TEST(data->klass, FL_SINGLETON)) {
+ VALUE v = rb_iv_get(data->klass, "__attached__");
+
+ if (data->recv == Qundef) {
+ rb_str_buf_append(str, rb_inspect(data->klass));
+ }
+ else if (data->recv == v) {
+ rb_str_buf_append(str, rb_inspect(v));
+ sharp = ".";
+ }
+ else {
+ rb_str_buf_append(str, rb_inspect(data->recv));
+ rb_str_buf_cat2(str, "(");
+ rb_str_buf_append(str, rb_inspect(v));
+ rb_str_buf_cat2(str, ")");
+ sharp = ".";
+ }
+ }
+ else {
+ rb_str_buf_cat2(str, rb_class2name(data->rklass));
+ if (data->rklass != data->klass) {
+ rb_str_buf_cat2(str, "(");
+ rb_str_buf_cat2(str, rb_class2name(data->klass));
+ rb_str_buf_cat2(str, ")");
+ }
+ }
+ rb_str_buf_cat2(str, sharp);
+ rb_str_buf_cat2(str, rb_id2name(data->oid));
+ rb_str_buf_cat2(str, ">");
+
+ return str;
+}
+
+static VALUE
+mproc(method)
+ VALUE method;
+{
+ VALUE proc;
+
+ /* emulate ruby's method call */
+ PUSH_ITER(ITER_CUR);
+ PUSH_FRAME();
+ proc = rb_block_proc();
+ POP_FRAME();
+ POP_ITER();
+
+ return proc;
+}
+
+static VALUE
+bmcall(args, method)
+ VALUE args, method;
+{
+ volatile VALUE a;
+ VALUE ret;
+
+ a = svalue_to_avalue(args);
+ ret = method_call(RARRAY(a)->len, RARRAY(a)->ptr, method);
+ a = Qnil; /* prevent tail call */
+ return ret;
+}
+
+VALUE
+rb_proc_new(func, val)
+ VALUE (*func)(ANYARGS); /* VALUE yieldarg[, VALUE procarg] */
+ VALUE val;
+{
+ struct BLOCK *data;
+ VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ data->body->nd_state = YIELD_FUNC_LAMBDA;
+ data->flags |= BLOCK_LAMBDA;
+ return proc;
+}
+
+/*
+ * call-seq:
+ * meth.to_proc => prc
+ *
+ * Returns a <code>Proc</code> object corresponding to this method.
+ */
+
+static VALUE
+method_proc(method)
+ VALUE method;
+{
+ VALUE proc;
+ struct METHOD *mdata;
+ struct BLOCK *bdata;
+
+ proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, bmcall, method);
+ Data_Get_Struct(method, struct METHOD, mdata);
+ Data_Get_Struct(proc, struct BLOCK, bdata);
+ bdata->body->nd_file = mdata->body->nd_file;
+ nd_set_line(bdata->body, nd_line(mdata->body));
+ bdata->body->nd_state = YIELD_FUNC_SVALUE;
+
+ return proc;
+}
+
+static VALUE
+rb_obj_is_method(m)
+ VALUE m;
+{
+ if (TYPE(m) == T_DATA && RDATA(m)->dmark == (RUBY_DATA_FUNC)bm_mark) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * define_method(symbol, method) => new_method
+ * define_method(symbol) { block } => proc
+ *
+ * Defines an instance method in the receiver. The _method_
+ * parameter can be a +Proc+ or +Method+ object.
+ * If a block is specified, it is used as the method body. This block
+ * is evaluated using <code>instance_eval</code>, a point that is
+ * tricky to demonstrate because <code>define_method</code> is private.
+ * (This is why we resort to the +send+ hack in this example.)
+ *
+ * class A
+ * def fred
+ * puts "In Fred"
+ * end
+ * def create_method(name, &block)
+ * self.class.send(:define_method, name, &block)
+ * end
+ * define_method(:wilma) { puts "Charge it!" }
+ * end
+ * class B < A
+ * define_method(:barney, instance_method(:fred))
+ * end
+ * a = B.new
+ * a.barney
+ * a.wilma
+ * a.create_method(:betty) { p self }
+ * a.betty
+ *
+ * <em>produces:</em>
+ *
+ * In Fred
+ * Charge it!
+ * #<B:0x401b39e8>
+ */
+
+static VALUE
+rb_mod_define_method(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ ID id;
+ VALUE body;
+ NODE *node;
+ int noex;
+
+ if (argc == 1) {
+ id = rb_to_id(argv[0]);
+ body = proc_lambda();
+ }
+ else if (argc == 2) {
+ id = rb_to_id(argv[0]);
+ body = argv[1];
+ if (!rb_obj_is_method(body) && !rb_obj_is_proc(body)) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Method)",
+ rb_obj_classname(body));
+ }
+ }
+ else {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
+ }
+ if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
+ node = NEW_DMETHOD(method_unbind(body));
+ }
+ else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
+ struct BLOCK *block;
+
+ body = proc_clone(body);
+ Data_Get_Struct(body, struct BLOCK, block);
+ block->frame.last_func = id;
+ block->frame.orig_func = id;
+ block->frame.last_class = mod;
+ node = NEW_BMETHOD(body);
+ }
+ else {
+ /* type error */
+ rb_raise(rb_eTypeError, "wrong argument type (expected Proc/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;
+ }
+ }
+ rb_add_method(mod, id, node, noex);
+ return body;
+}
+
+/*
+ * <code>Proc</code> objects are blocks of code that have been bound to
+ * a set of local variables. Once bound, the code may be called in
+ * different contexts and still access those variables.
+ *
+ * def gen_times(factor)
+ * return Proc.new {|n| n*factor }
+ * end
+ *
+ * times3 = gen_times(3)
+ * times5 = gen_times(5)
+ *
+ * times3.call(12) #=> 36
+ * times5.call(5) #=> 25
+ * times3.call(times5.call(4)) #=> 60
+ *
+ */
+
+void
+Init_Proc()
+{
+ rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
+ rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0);
+ rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
+
+ 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);
+
+ 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")));
+ OBJ_TAINT(sysstack_error);
+ OBJ_FREEZE(sysstack_error);
+
+ rb_cProc = rb_define_class("Proc", rb_cObject);
+ rb_undef_alloc_func(rb_cProc);
+ rb_define_singleton_method(rb_cProc, "new", proc_s_new, -1);
+
+ rb_define_method(rb_cProc, "clone", proc_clone, 0);
+ rb_define_method(rb_cProc, "dup", proc_dup, 0);
+ rb_define_method(rb_cProc, "call", rb_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_eq, 1);
+ rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
+ rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
+ rb_define_method(rb_cProc, "binding", proc_binding, 0);
+
+ rb_define_global_function("proc", proc_lambda, 0);
+ rb_define_global_function("lambda", proc_lambda, 0);
+
+ rb_cMethod = rb_define_class("Method", rb_cObject);
+ rb_undef_alloc_func(rb_cMethod);
+ rb_undef_method(CLASS_OF(rb_cMethod), "new");
+ rb_define_method(rb_cMethod, "==", method_eq, 1);
+ rb_define_method(rb_cMethod, "clone", method_clone, 0);
+ rb_define_method(rb_cMethod, "call", method_call, -1);
+ rb_define_method(rb_cMethod, "[]", method_call, -1);
+ rb_define_method(rb_cMethod, "arity", method_arity, 0);
+ rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
+ rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
+ rb_define_method(rb_cMethod, "to_proc", method_proc, 0);
+ rb_define_method(rb_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);
+
+ rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject);
+ rb_undef_alloc_func(rb_cUnboundMethod);
+ rb_undef_method(CLASS_OF(rb_cUnboundMethod), "new");
+ rb_define_method(rb_cUnboundMethod, "==", method_eq, 1);
+ rb_define_method(rb_cUnboundMethod, "clone", method_clone, 0);
+ rb_define_method(rb_cUnboundMethod, "arity", method_arity, 0);
+ rb_define_method(rb_cUnboundMethod, "inspect", method_inspect, 0);
+ rb_define_method(rb_cUnboundMethod, "to_s", method_inspect, 0);
+ rb_define_method(rb_cUnboundMethod, "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);
+}
+
+/*
+ * Objects of class <code>Binding</code> encapsulate the execution
+ * context at some particular place in the code and retain this context
+ * for future use. The variables, methods, value of <code>self</code>,
+ * and possibly an iterator block that can be accessed in this context
+ * are all retained. Binding objects can be created using
+ * <code>Kernel#binding</code>, and are made available to the callback
+ * of <code>Kernel#set_trace_func</code>.
+ *
+ * These binding objects can be passed as the second argument of the
+ * <code>Kernel#eval</code> method, establishing an environment for the
+ * evaluation.
+ *
+ * class Demo
+ * def initialize(n)
+ * @secret = n
+ * end
+ * def getBinding
+ * return binding()
+ * end
+ * end
+ *
+ * k1 = Demo.new(99)
+ * b1 = k1.getBinding
+ * k2 = Demo.new(-3)
+ * b2 = k2.getBinding
+ *
+ * eval("@secret", b1) #=> 99
+ * eval("@secret", b2) #=> -3
+ * eval("@secret") #=> nil
+ *
+ * Binding objects have no class-specific methods.
+ *
+ */
+
+void
+Init_Binding()
+{
+ rb_cBinding = rb_define_class("Binding", rb_cObject);
+ rb_undef_alloc_func(rb_cBinding);
+ rb_undef_method(CLASS_OF(rb_cBinding), "new");
+ rb_define_method(rb_cBinding, "clone", proc_clone, 0);
+ rb_define_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);
+}
+
+/* Windows SEH refers data on the stack. */
+#undef SAVE_WIN32_EXCEPTION_LIST
+#if defined _WIN32 || defined __CYGWIN__
+#if defined __CYGWIN__
+typedef unsigned long DWORD;
+#endif
+
+static inline DWORD
+win32_get_exception_list()
+{
+ DWORD p;
+# if defined _MSC_VER
+# ifdef _M_IX86
+# define SAVE_WIN32_EXCEPTION_LIST
+# if _MSC_VER >= 1310
+ /* warning: unsafe assignment to fs:0 ... this is ok */
+# pragma warning(disable: 4733)
+# endif
+ __asm mov eax, fs:[0];
+ __asm mov p, eax;
+# endif
+# elif defined __GNUC__
+# ifdef __i386__
+# define SAVE_WIN32_EXCEPTION_LIST
+ __asm__("movl %%fs:0,%0" : "=r"(p));
+# endif
+# elif defined __BORLANDC__
+# define SAVE_WIN32_EXCEPTION_LIST
+ __emit__(0x64, 0xA1, 0, 0, 0, 0); /* mov eax, fs:[0] */
+ p = _EAX;
+# endif
+ return p;
+}
+
+static inline void
+win32_set_exception_list(p)
+ DWORD p;
+{
+# if defined _MSC_VER
+# ifdef _M_IX86
+ __asm mov eax, p;
+ __asm mov fs:[0], eax;
+# endif
+# elif defined __GNUC__
+# ifdef __i386__
+ __asm__("movl %0,%%fs:0" :: "r"(p));
+# endif
+# elif defined __BORLANDC__
+ _EAX = p;
+ __emit__(0x64, 0xA3, 0, 0, 0, 0); /* mov fs:[0], eax */
+# endif
+}
+
+#if !defined SAVE_WIN32_EXCEPTION_LIST && !defined _WIN32_WCE
+# error unsupported platform
+#endif
+#endif
+
+int rb_thread_pending = 0;
+
+VALUE rb_cThread;
+
+extern VALUE rb_last_status;
+
+#define WAIT_FD (1<<0)
+#define WAIT_SELECT (1<<1)
+#define WAIT_TIME (1<<2)
+#define WAIT_JOIN (1<<3)
+#define WAIT_PID (1<<4)
+
+/* +infty, for this purpose */
+#define DELAY_INFTY 1E30
+
+#if !defined HAVE_PAUSE
+# if defined _WIN32 && !defined __CYGWIN__
+# define pause() Sleep(INFINITE)
+# else
+# define pause() sleep(0x7fffffff)
+# endif
+#endif
+
+#define THREAD_TERMINATING 0x400 /* persistent flag */
+#define THREAD_NO_ENSURE 0x800 /* persistent flag */
+#define THREAD_FLAGS_MASK 0xfc00 /* 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)
+
+#define FOREACH_THREAD(x) FOREACH_THREAD_FROM(curr_thread,x)
+#define END_FOREACH(x) END_FOREACH_FROM(curr_thread,x)
+
+struct thread_status_t {
+ NODE *node;
+
+ int tracing;
+ VALUE errinfo;
+ VALUE last_status;
+ VALUE last_line;
+ VALUE last_match;
+
+ int safe;
+
+ enum rb_thread_status status;
+ int wait_for;
+ int fd;
+ fd_set readfds;
+ fd_set writefds;
+ fd_set exceptfds;
+ int select_value;
+ double delay;
+ rb_thread_t join;
+};
+
+#define THREAD_COPY_STATUS(src, dst) (void)( \
+ (dst)->node = (src)->node, \
+ \
+ (dst)->tracing = (src)->tracing, \
+ (dst)->errinfo = (src)->errinfo, \
+ (dst)->last_status = (src)->last_status, \
+ (dst)->last_line = (src)->last_line, \
+ (dst)->last_match = (src)->last_match, \
+ \
+ (dst)->safe = (src)->safe, \
+ \
+ (dst)->status = (src)->status, \
+ (dst)->wait_for = (src)->wait_for, \
+ (dst)->fd = (src)->fd, \
+ (dst)->readfds = (src)->readfds, \
+ (dst)->writefds = (src)->writefds, \
+ (dst)->exceptfds = (src)->exceptfds, \
+ (dst)->select_value = (src)->select_value, \
+ (dst)->delay = (src)->delay, \
+ (dst)->join = (src)->join, \
+ 0)
+
+int
+rb_thread_set_raised(th)
+ rb_thread_t th;
+{
+ if (th->flags & RAISED_EXCEPTION) {
+ return 1;
+ }
+ th->flags |= RAISED_EXCEPTION;
+ return 0;
+}
int
-rb_dvar_defined(ID id)
-{
- rb_thread_t *th = GET_THREAD();
- rb_iseq_t *iseq;
- if (th->base_block && (iseq = th->base_block->iseq)) {
- while (iseq->type == ISEQ_TYPE_BLOCK ||
- iseq->type == ISEQ_TYPE_RESCUE ||
- iseq->type == ISEQ_TYPE_ENSURE ||
- iseq->type == ISEQ_TYPE_EVAL) {
- int i;
-
- for (i = 0; i < iseq->local_table_size; i++) {
- if (iseq->local_table[i] == id) {
- return 1;
+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()
+{
+ return ((curr_thread->flags & THREAD_NO_ENSURE) == THREAD_NO_ENSURE);
+}
+
+static void rb_thread_ready _((rb_thread_t));
+
+static VALUE run_trap_eval _((VALUE));
+static VALUE
+run_trap_eval(arg)
+ VALUE arg;
+{
+ VALUE *p = (VALUE *)arg;
+ return rb_eval_cmd(p[0], p[1], (int)p[2]);
+}
+
+static VALUE
+rb_trap_eval(cmd, sig, safe)
+ VALUE cmd;
+ int sig, safe;
+{
+ int state;
+ VALUE val = Qnil; /* OK */
+ volatile struct thread_status_t save;
+ VALUE arg[3];
+
+ arg[0] = cmd;
+ arg[1] = rb_ary_new3(1, INT2FIX(sig));
+ arg[2] = (VALUE)safe;
+ THREAD_COPY_STATUS(curr_thread, &save);
+ rb_thread_ready(curr_thread);
+ PUSH_ITER(ITER_NOT);
+ val = rb_protect(run_trap_eval, (VALUE)&arg, &state);
+ POP_ITER();
+ THREAD_COPY_STATUS(&save, curr_thread);
+
+ if (state) {
+ rb_trap_immediate = 0;
+ rb_thread_ready(curr_thread);
+ JUMP_TAG(state);
+ }
+
+ if (curr_thread->status == THREAD_STOPPED) {
+ rb_thread_schedule();
+ }
+ errno = EINTR;
+
+ return val;
+}
+
+static const char *
+thread_status_name(status)
+ enum rb_thread_status status;
+{
+ switch (status) {
+ case THREAD_RUNNABLE:
+ return "run";
+ case THREAD_STOPPED:
+ return "sleep";
+ case THREAD_TO_KILL:
+ return "aborting";
+ case THREAD_KILLED:
+ return "dead";
+ default:
+ return "unknown";
+ }
+}
+
+/* $SAFE accessor */
+void
+rb_set_safe_level(level)
+ int level;
+{
+ if (level > ruby_safe_level) {
+ if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
+ ruby_safe_level = level;
+ curr_thread->safe = level;
+ }
+}
+
+static VALUE
+safe_getter()
+{
+ return INT2NUM(ruby_safe_level);
+}
+
+static void
+safe_setter(val)
+ VALUE val;
+{
+ int level = NUM2INT(val);
+
+ if (level < ruby_safe_level) {
+ rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d",
+ ruby_safe_level, level);
+ }
+ if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
+ ruby_safe_level = level;
+ curr_thread->safe = level;
+}
+
+/* Return the current time as a floating-point number */
+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;
+}
+
+#define STACK(addr) (th->stk_pos<(VALUE*)(addr) && (VALUE*)(addr)<th->stk_pos+th->stk_len)
+#define ADJ(addr) (void*)(STACK(addr)?(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr):(VALUE*)(addr))
+static void
+thread_mark(th)
+ rb_thread_t th;
+{
+ struct FRAME *frame;
+ struct BLOCK *block;
+
+ rb_gc_mark(th->result);
+ rb_gc_mark(th->thread);
+ if (th->join) rb_gc_mark(th->join->thread);
+
+ rb_gc_mark(th->klass);
+ rb_gc_mark(th->wrapper);
+ rb_gc_mark((VALUE)th->cref);
+
+ rb_gc_mark((VALUE)th->scope);
+ rb_gc_mark((VALUE)th->dyna_vars);
+ rb_gc_mark(th->errinfo);
+ rb_gc_mark(th->last_status);
+ rb_gc_mark(th->last_line);
+ 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;
+ if (th->status == THREAD_KILLED) return;
+ if (th->stk_len == 0) return; /* stack not active, no need to mark. */
+ if (th->stk_ptr) {
+ rb_gc_mark_locations(th->stk_ptr, th->stk_ptr+th->stk_len);
+#if defined(THINK_C) || defined(__human68k__)
+ rb_gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
+#endif
+#ifdef __ia64
+ if (th->bstr_ptr) {
+ rb_gc_mark_locations(th->bstr_ptr, th->bstr_ptr+th->bstr_len);
+ }
+#endif
+ }
+ frame = th->frame;
+ while (frame && frame != top_frame) {
+ frame = ADJ(frame);
+ rb_gc_mark_frame(frame);
+ if (frame->tmp) {
+ struct FRAME *tmp = frame->tmp;
+
+ while (tmp && tmp != top_frame) {
+ tmp = ADJ(tmp);
+ rb_gc_mark_frame(tmp);
+ tmp = tmp->prev;
+ }
+ }
+ frame = frame->prev;
+ }
+ block = th->block;
+ while (block) {
+ block = ADJ(block);
+ rb_gc_mark_frame(&block->frame);
+ block = block->prev;
+ }
+}
+
+static int
+mark_loading_thread(key, value, lev)
+ ID key;
+ VALUE value;
+ int lev;
+{
+ rb_gc_mark(((rb_thread_t)value)->thread);
+ return ST_CONTINUE;
+}
+
+void
+rb_gc_mark_threads()
+{
+ rb_thread_t th;
+
+ /* static global mark */
+ rb_gc_mark((VALUE)ruby_cref);
+
+ if (!curr_thread) return;
+ rb_gc_mark(main_thread->thread);
+ rb_gc_mark(curr_thread->thread);
+ FOREACH_THREAD_FROM(main_thread, th) {
+ switch (th->status) {
+ case THREAD_TO_KILL:
+ case THREAD_RUNNABLE:
+ break;
+ case THREAD_STOPPED:
+ if (th->wait_for) break;
+ default:
+ continue;
+ }
+ rb_gc_mark(th->thread);
+ } END_FOREACH_FROM(main_thread, th);
+ if (loading_tbl) st_foreach(loading_tbl, mark_loading_thread, 0);
+}
+
+void
+rb_gc_abort_threads()
+{
+ rb_thread_t th;
+
+ if (!main_thread)
+ return;
+
+ FOREACH_THREAD_FROM(main_thread, th) {
+ if (FL_TEST(th->thread, FL_MARK)) continue;
+ if (th->status == THREAD_STOPPED) {
+ th->status = THREAD_TO_KILL;
+ rb_gc_mark(th->thread);
+ }
+ } END_FOREACH_FROM(main_thread, th);
+}
+
+static void
+thread_free(th)
+ rb_thread_t th;
+{
+ if (th->stk_ptr) free(th->stk_ptr);
+ th->stk_ptr = 0;
+#ifdef __ia64
+ if (th->bstr_ptr) free(th->bstr_ptr);
+ th->bstr_ptr = 0;
+#endif
+ if (th->locals) st_free_table(th->locals);
+ if (th->status != THREAD_KILLED) {
+ if (th->prev) th->prev->next = th->next;
+ if (th->next) th->next->prev = th->prev;
+ }
+ if (th != main_thread) free(th);
+}
+
+static rb_thread_t
+rb_thread_check(data)
+ VALUE data;
+{
+ if (TYPE(data) != T_DATA || RDATA(data)->dmark != (RUBY_DATA_FUNC)thread_mark) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)",
+ rb_obj_classname(data));
+ }
+ return (rb_thread_t)RDATA(data)->data;
+}
+
+static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));
+
+static VALUE th_raise_exception;
+static NODE *th_raise_node;
+static VALUE th_cmd;
+static int th_sig, th_safe;
+
+#define RESTORE_NORMAL 1
+#define RESTORE_FATAL 2
+#define RESTORE_INTERRUPT 3
+#define RESTORE_TRAP 4
+#define RESTORE_RAISE 5
+#define RESTORE_SIGNAL 6
+#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;
+ int len;
+ static VALUE tval;
+
+ len = ruby_stack_length(&pos);
+ th->stk_len = 0;
+ th->stk_pos = pos;
+ if (len > th->stk_max) {
+ VALUE *ptr = realloc(th->stk_ptr, sizeof(VALUE) * len);
+ if (!ptr) rb_memerror();
+ th->stk_ptr = ptr;
+ th->stk_max = len;
+ }
+ 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);
+#endif
+#ifdef SAVE_WIN32_EXCEPTION_LIST
+ th->win32_exception_list = win32_get_exception_list();
+#endif
+
+ th->frame = ruby_frame;
+ th->scope = ruby_scope;
+ ruby_scope->flags |= SCOPE_DONT_RECYCLE;
+ th->klass = ruby_class;
+ th->wrapper = ruby_wrapper;
+ th->cref = ruby_cref;
+ th->dyna_vars = ruby_dyna_vars;
+ th->block = ruby_block;
+ th->flags &= THREAD_FLAGS_MASK;
+ th->flags |= (rb_trap_immediate<<8) | scope_vmode;
+ th->iter = ruby_iter;
+ th->tag = prot_tag;
+ th->tracing = tracing;
+ th->errinfo = ruby_errinfo;
+ th->last_status = rb_last_status;
+ tval = rb_lastline_get();
+ rb_lastline_set(th->last_line);
+ th->last_line = tval;
+ tval = rb_backref_get();
+ rb_backref_set(th->last_match);
+ th->last_match = tval;
+ th->safe = ruby_safe_level;
+
+ th->node = ruby_current_node;
+ if (ruby_sandbox_save != NULL)
+ {
+ ruby_sandbox_save(th);
+ }
+}
+
+static int
+rb_thread_switch(n)
+ int n;
+{
+ rb_trap_immediate = (curr_thread->flags&0x100)?1:0;
+ switch (n) {
+ case 0:
+ return 0;
+ case RESTORE_FATAL:
+ JUMP_TAG(TAG_FATAL);
+ break;
+ case RESTORE_INTERRUPT:
+ rb_interrupt();
+ break;
+ case RESTORE_TRAP:
+ rb_trap_eval(th_cmd, th_sig, th_safe);
+ break;
+ case RESTORE_RAISE:
+ ruby_frame->last_func = 0;
+ ruby_current_node = th_raise_node;
+ rb_raise_jump(th_raise_exception);
+ break;
+ case RESTORE_SIGNAL:
+ rb_thread_signal_raise(th_sig);
+ break;
+ case RESTORE_EXIT:
+ ruby_errinfo = th_raise_exception;
+ ruby_current_node = th_raise_node;
+ if (!rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
+ terminate_process(EXIT_FAILURE, ruby_errinfo);
+ }
+ rb_exc_raise(th_raise_exception);
+ break;
+ case RESTORE_NORMAL:
+ default:
+ break;
+ }
+ return 1;
+}
+
+#define THREAD_SAVE_CONTEXT(th) \
+ (rb_thread_switch(ruby_setjmp(rb_thread_save_context(th), (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 *)));
+
+static void
+rb_thread_restore_context_0(rb_thread_t th, int exit, void *vp)
+{
+ 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);
+ }
+ ruby_frame = th->frame;
+ ruby_scope = th->scope;
+ ruby_class = th->klass;
+ ruby_wrapper = th->wrapper;
+ ruby_cref = th->cref;
+ ruby_dyna_vars = th->dyna_vars;
+ ruby_block = th->block;
+ scope_vmode = th->flags&SCOPE_MASK;
+ ruby_iter = th->iter;
+ prot_tag = th->tag;
+ tracing = th->tracing;
+ ruby_errinfo = th->errinfo;
+ rb_last_status = th->last_status;
+ ruby_safe_level = th->safe;
+
+ ruby_current_node = th->node;
+
+#ifdef SAVE_WIN32_EXCEPTION_LIST
+ win32_set_exception_list(th->win32_exception_list);
+#endif
+ tmp = th;
+ ex = exit;
+ FLUSH_REGISTER_WINDOWS;
+ MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len);
+#ifdef __ia64
+ MEMCPY(tmp->bstr_pos, tmp->bstr_ptr, VALUE, tmp->bstr_len);
+#endif
+
+ tval = rb_lastline_get();
+ rb_lastline_set(tmp->last_line);
+ tmp->last_line = tval;
+ tval = rb_backref_get();
+ rb_backref_set(tmp->last_match);
+ tmp->last_match = tval;
+
+ 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;
+{
+ th->wait_for = 0;
+ if (th->status != THREAD_TO_KILL) {
+ th->status = THREAD_RUNNABLE;
+ }
+}
+
+static void
+rb_thread_die(th)
+ rb_thread_t th;
+{
+ th->thgroup = 0;
+ th->status = THREAD_KILLED;
+ if (th->stk_ptr) free(th->stk_ptr);
+ th->stk_ptr = 0;
+}
+
+static void
+rb_thread_remove(th)
+ rb_thread_t th;
+{
+ if (th->status == THREAD_KILLED) return;
+
+ rb_thread_ready(th);
+ rb_thread_die(th);
+ th->prev->next = th->next;
+ th->next->prev = th->prev;
+}
+
+static int
+rb_thread_dead(th)
+ rb_thread_t th;
+{
+ return th->status == THREAD_KILLED;
+}
+
+void
+rb_thread_fd_close(fd)
+ int fd;
+{
+ rb_thread_t th;
+
+ FOREACH_THREAD(th) {
+ if (((th->wait_for & WAIT_FD) && fd == th->fd) ||
+ ((th->wait_for & WAIT_SELECT) && (fd < th->fd) &&
+ (FD_ISSET(fd, &th->readfds) ||
+ FD_ISSET(fd, &th->writefds) ||
+ FD_ISSET(fd, &th->exceptfds)))) {
+ VALUE exc = rb_exc_new2(rb_eIOError, "stream closed");
+ rb_thread_raise(1, &exc, th);
+ }
+ }
+ END_FOREACH(th);
+}
+
+NORETURN(static void rb_thread_main_jump _((VALUE, int)));
+static void
+rb_thread_main_jump(err, tag)
+ VALUE err;
+ int tag;
+{
+ curr_thread = main_thread;
+ th_raise_exception = err;
+ th_raise_node = ruby_current_node;
+ rb_thread_restore_context(main_thread, tag);
+}
+
+NORETURN(static void rb_thread_deadlock _((void)));
+static void
+rb_thread_deadlock()
+{
+ char msg[21+SIZEOF_LONG*2];
+ VALUE e;
+
+ sprintf(msg, "Thread(0x%lx): deadlock", curr_thread->thread);
+ e = rb_exc_new2(rb_eFatal, msg);
+ if (curr_thread == main_thread) {
+ rb_exc_raise(e);
+ }
+ rb_thread_main_jump(e, RESTORE_RAISE);
+}
+
+static void
+copy_fds(dst, src, max)
+ fd_set *dst, *src;
+ int max;
+{
+ int n = 0;
+ int i;
+
+ for (i=0; i<=max; i++) {
+ if (FD_ISSET(i, src)) {
+ n = i;
+ FD_SET(i, dst);
+ }
+ }
+}
+
+static int
+match_fds(dst, src, max)
+ fd_set *dst, *src;
+ int max;
+{
+ int i;
+
+ for (i=0; i<=max; i++) {
+ if (FD_ISSET(i, src) && FD_ISSET(i, dst)) {
+ return Qtrue;
+ }
+ }
+ return Qfalse;
+}
+
+static int
+intersect_fds(src, dst, max)
+ fd_set *src, *dst;
+ int max;
+{
+ int i, n = 0;
+
+ for (i=0; i<=max; i++) {
+ if (FD_ISSET(i, dst)) {
+ if (FD_ISSET(i, src)) {
+ /* Wake up only one thread per fd. */
+ FD_CLR(i, src);
+ n++;
+ }
+ else {
+ FD_CLR(i, dst);
+ }
+ }
+ }
+ return n;
+}
+
+static int
+find_bad_fds(dst, src, max)
+ fd_set *dst, *src;
+ int max;
+{
+ int i, test = Qfalse;
+
+ for (i=0; i<=max; i++) {
+ if (FD_ISSET(i, src) && !FD_ISSET(i, dst)) {
+ FD_CLR(i, src);
+ test = Qtrue;
+ }
+ }
+ return test;
+}
+
+void
+rb_thread_schedule()
+{
+ rb_thread_t next; /* OK */
+ rb_thread_t th;
+ rb_thread_t curr;
+ int found = 0;
+
+ fd_set readfds;
+ fd_set writefds;
+ fd_set exceptfds;
+ struct timeval delay_tv, *delay_ptr;
+ double delay, now; /* OK */
+ int n, max;
+ int need_select = 0;
+ int select_timeout = 0;
+
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on rb_thread_schedule()");
+ }
+#endif
+ rb_thread_pending = 0;
+ rb_gc_finalize_deferred();
+ if (curr_thread == curr_thread->next
+ && curr_thread->status == THREAD_RUNNABLE)
+ return;
+
+ next = 0;
+ curr = curr_thread; /* starting thread */
+
+ while (curr->status == THREAD_KILLED) {
+ curr = curr->prev;
+ }
+
+ again:
+ max = -1;
+ FD_ZERO(&readfds);
+ FD_ZERO(&writefds);
+ FD_ZERO(&exceptfds);
+ delay = DELAY_INFTY;
+ now = -1.0;
+
+ FOREACH_THREAD_FROM(curr, th) {
+ if (!found && th->status <= THREAD_RUNNABLE) {
+ found = 1;
+ }
+ if (th->status != THREAD_STOPPED) continue;
+ if (th->wait_for & WAIT_JOIN) {
+ if (rb_thread_dead(th->join)) {
+ th->status = THREAD_RUNNABLE;
+ found = 1;
+ }
+ }
+ if (th->wait_for & WAIT_FD) {
+ FD_SET(th->fd, &readfds);
+ if (max < th->fd) max = th->fd;
+ need_select = 1;
+ }
+ if (th->wait_for & WAIT_SELECT) {
+ copy_fds(&readfds, &th->readfds, th->fd);
+ copy_fds(&writefds, &th->writefds, th->fd);
+ copy_fds(&exceptfds, &th->exceptfds, th->fd);
+ if (max < th->fd) max = th->fd;
+ need_select = 1;
+ if (th->wait_for & WAIT_TIME) {
+ select_timeout = 1;
+ }
+ th->select_value = 0;
+ }
+ if (th->wait_for & WAIT_TIME) {
+ double th_delay;
+
+ if (now < 0.0) now = timeofday();
+ th_delay = th->delay - now;
+ if (th_delay <= 0.0) {
+ th->status = THREAD_RUNNABLE;
+ found = 1;
+ }
+ else if (th_delay < delay) {
+ delay = th_delay;
+ need_select = 1;
+ }
+ else if (th->delay == DELAY_INFTY) {
+ need_select = 1;
+ }
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+
+ /* Do the select if needed */
+ if (need_select) {
+ /* Convert delay to a timeval */
+ /* If a thread is runnable, just poll */
+ if (found) {
+ delay_tv.tv_sec = 0;
+ delay_tv.tv_usec = 0;
+ delay_ptr = &delay_tv;
+ }
+ else if (delay == DELAY_INFTY) {
+ delay_ptr = 0;
+ }
+ else {
+ delay_tv.tv_sec = delay;
+ delay_tv.tv_usec = (delay - (double)delay_tv.tv_sec)*1e6;
+ delay_ptr = &delay_tv;
+ }
+
+ n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
+ if (n < 0) {
+ int e = errno;
+
+ if (rb_trap_pending) rb_trap_exec();
+ if (e == EINTR) goto again;
+#ifdef ERESTART
+ if (e == ERESTART) goto again;
+#endif
+ FOREACH_THREAD_FROM(curr, th) {
+ if (th->wait_for & WAIT_SELECT) {
+ int v = 0;
+
+ v |= find_bad_fds(&readfds, &th->readfds, th->fd);
+ v |= find_bad_fds(&writefds, &th->writefds, th->fd);
+ v |= find_bad_fds(&exceptfds, &th->exceptfds, th->fd);
+ if (v) {
+ th->select_value = n;
+ n = max;
+ }
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+ }
+ if (select_timeout && n == 0) {
+ if (now < 0.0) now = timeofday();
+ FOREACH_THREAD_FROM(curr, th) {
+ if (((th->wait_for&(WAIT_SELECT|WAIT_TIME)) == (WAIT_SELECT|WAIT_TIME)) &&
+ th->delay <= now) {
+ th->status = THREAD_RUNNABLE;
+ th->wait_for = 0;
+ th->select_value = 0;
+ found = 1;
+ intersect_fds(&readfds, &th->readfds, max);
+ intersect_fds(&writefds, &th->writefds, max);
+ intersect_fds(&exceptfds, &th->exceptfds, max);
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+ }
+ if (n > 0) {
+ now = -1.0;
+ /* Some descriptors are ready.
+ Make the corresponding threads runnable. */
+ FOREACH_THREAD_FROM(curr, th) {
+ if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) {
+ /* Wake up only one thread per fd. */
+ FD_CLR(th->fd, &readfds);
+ th->status = THREAD_RUNNABLE;
+ th->fd = 0;
+ th->wait_for = 0;
+ found = 1;
+ }
+ if ((th->wait_for&WAIT_SELECT) &&
+ (match_fds(&readfds, &th->readfds, max) ||
+ match_fds(&writefds, &th->writefds, max) ||
+ match_fds(&exceptfds, &th->exceptfds, max))) {
+ /* Wake up only one thread per fd. */
+ th->status = THREAD_RUNNABLE;
+ th->wait_for = 0;
+ n = intersect_fds(&readfds, &th->readfds, max) +
+ intersect_fds(&writefds, &th->writefds, max) +
+ intersect_fds(&exceptfds, &th->exceptfds, max);
+ th->select_value = n;
+ found = 1;
}
}
- iseq = iseq->parent_iseq;
+ END_FOREACH_FROM(curr, th);
}
+ /* The delays for some of the threads should have expired.
+ Go through the loop once more, to check the delays. */
+ if (!found && delay != DELAY_INFTY)
+ goto again;
}
- return 0;
+
+ FOREACH_THREAD_FROM(curr, th) {
+ if (th->status == THREAD_TO_KILL) {
+ next = th;
+ break;
+ }
+ if (th->status == THREAD_RUNNABLE && th->stk_ptr) {
+ if (!next || next->priority < th->priority)
+ next = th;
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+
+ if (!next) {
+ /* raise fatal error to main thread */
+ curr_thread->node = ruby_current_node;
+ if (curr->next == curr) {
+ TRAP_BEG;
+ pause();
+ TRAP_END;
+ }
+ FOREACH_THREAD_FROM(curr, th) {
+ warn_printf("deadlock 0x%lx: %s:",
+ th->thread, thread_status_name(th->status));
+ if (th->wait_for & WAIT_FD) warn_printf("F(%d)", th->fd);
+ if (th->wait_for & WAIT_SELECT) warn_printf("S");
+ if (th->wait_for & WAIT_TIME) warn_printf("T(%f)", th->delay);
+ if (th->wait_for & WAIT_JOIN)
+ warn_printf("J(0x%lx)", th->join ? th->join->thread : 0);
+ if (th->wait_for & WAIT_PID) warn_printf("P");
+ if (!th->wait_for) warn_printf("-");
+ warn_printf(" %s - %s:%d\n",
+ th==main_thread ? "(main)" : "",
+ th->node->nd_file, nd_line(th->node));
+ }
+ END_FOREACH_FROM(curr, th);
+ next = main_thread;
+ rb_thread_ready(next);
+ next->status = THREAD_TO_KILL;
+ if (!rb_thread_dead(curr_thread)) {
+ rb_thread_save_context(curr_thread);
+ }
+ rb_thread_deadlock();
+ }
+ next->wait_for = 0;
+ if (next->status == THREAD_RUNNABLE && next == curr_thread) {
+ return;
+ }
+
+ /* context switch */
+ if (curr == curr_thread) {
+ if (THREAD_SAVE_CONTEXT(curr)) {
+ return;
+ }
+ }
+
+ curr_thread = next;
+ if (next->status == THREAD_TO_KILL) {
+ if (!(next->flags & THREAD_TERMINATING)) {
+ next->flags |= THREAD_TERMINATING;
+ /* terminate; execute ensure-clause if any */
+ rb_thread_restore_context(next, RESTORE_FATAL);
+ }
+ }
+ rb_thread_restore_context(next, RESTORE_NORMAL);
+}
+
+void
+rb_thread_wait_fd(fd)
+ int fd;
+{
+ if (rb_thread_critical) return;
+ if (ruby_in_compile) return;
+ if (curr_thread == curr_thread->next) return;
+ if (curr_thread->status == THREAD_TO_KILL) return;
+
+ curr_thread->status = THREAD_STOPPED;
+ curr_thread->fd = fd;
+ curr_thread->wait_for = WAIT_FD;
+ rb_thread_schedule();
}
int
-rb_local_defined(ID id)
+rb_thread_fd_writable(fd)
+ int fd;
{
- rb_thread_t *th = GET_THREAD();
- rb_iseq_t *iseq;
+ if (rb_thread_critical) return Qtrue;
+ if (curr_thread == curr_thread->next) return Qtrue;
+ if (curr_thread->status == THREAD_TO_KILL) return Qtrue;
+ if (curr_thread->status == THREAD_KILLED) return Qtrue;
+
+ curr_thread->status = THREAD_STOPPED;
+ FD_ZERO(&curr_thread->readfds);
+ FD_ZERO(&curr_thread->writefds);
+ FD_SET(fd, &curr_thread->writefds);
+ FD_ZERO(&curr_thread->exceptfds);
+ curr_thread->fd = fd+1;
+ curr_thread->wait_for = WAIT_SELECT;
+ rb_thread_schedule();
+ return Qfalse;
+}
- if (th->base_block && th->base_block->iseq) {
- int i;
- iseq = th->base_block->iseq->local_iseq;
+void
+rb_thread_wait_for(time)
+ struct timeval time;
+{
+ double date;
- for (i=0; i<iseq->local_table_size; i++) {
- if (iseq->local_table[i] == id) {
- return 1;
+ if (rb_thread_critical ||
+ curr_thread == curr_thread->next ||
+ curr_thread->status == THREAD_TO_KILL) {
+ int n;
+ int thr_critical = rb_thread_critical;
+#ifndef linux
+ double d, limit;
+ limit = timeofday()+(double)time.tv_sec+(double)time.tv_usec*1e-6;
+#endif
+ for (;;) {
+ rb_thread_critical = Qtrue;
+ TRAP_BEG;
+ n = select(0, 0, 0, 0, &time);
+ rb_thread_critical = thr_critical;
+ TRAP_END;
+ if (n == 0) return;
+ if (n < 0) {
+ switch (errno) {
+ case EINTR:
+#ifdef ERESTART
+ case ERESTART:
+#endif
+ break;
+ default:
+ rb_sys_fail("sleep");
+ }
}
+#ifndef linux
+ d = limit - timeofday();
+
+ time.tv_sec = (int)d;
+ time.tv_usec = (int)((d - (int)d)*1e6);
+ if (time.tv_usec < 0) {
+ time.tv_usec += (long)1e6;
+ time.tv_sec -= 1;
+ }
+ if (time.tv_sec < 0) return;
+#endif
}
}
- return 0;
+
+ date = timeofday() + (double)time.tv_sec + (double)time.tv_usec*1e-6;
+ curr_thread->status = THREAD_STOPPED;
+ curr_thread->delay = date;
+ curr_thread->wait_for = WAIT_TIME;
+ rb_thread_schedule();
}
+void rb_thread_sleep_forever _((void));
+
int
-rb_parse_in_eval(void)
+rb_thread_alone()
{
- return GET_THREAD()->parse_in_eval != 0;
+ return curr_thread == curr_thread->next;
+}
+
+int
+rb_thread_select(max, read, write, except, timeout)
+ int max;
+ fd_set *read, *write, *except;
+ struct timeval *timeout;
+{
+#ifndef linux
+ double limit;
+#endif
+ int n;
+
+ if (!read && !write && !except) {
+ if (!timeout) {
+ rb_thread_sleep_forever();
+ return 0;
+ }
+ rb_thread_wait_for(*timeout);
+ return 0;
+ }
+
+#ifndef linux
+ if (timeout) {
+ limit = timeofday()+
+ (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6;
+ }
+#endif
+
+ if (rb_thread_critical ||
+ curr_thread == curr_thread->next ||
+ curr_thread->status == THREAD_TO_KILL) {
+#ifndef linux
+ struct timeval tv, *tvp = timeout;
+
+ if (timeout) {
+ tv = *timeout;
+ tvp = &tv;
+ }
+#else
+ struct timeval *const tvp = timeout;
+#endif
+ for (;;) {
+ TRAP_BEG;
+ n = select(max, read, write, except, tvp);
+ TRAP_END;
+ if (n < 0) {
+ switch (errno) {
+ case EINTR:
+#ifdef ERESTART
+ case ERESTART:
+#endif
+#ifndef linux
+ if (timeout) {
+ double d = limit - timeofday();
+
+ tv.tv_sec = (unsigned int)d;
+ tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6);
+ if (tv.tv_sec < 0) tv.tv_sec = 0;
+ if (tv.tv_usec < 0) tv.tv_usec = 0;
+ }
+#endif
+ continue;
+ default:
+ break;
+ }
+ }
+ return n;
+ }
+ }
+
+ curr_thread->status = THREAD_STOPPED;
+ if (read) curr_thread->readfds = *read;
+ else FD_ZERO(&curr_thread->readfds);
+ if (write) curr_thread->writefds = *write;
+ else FD_ZERO(&curr_thread->writefds);
+ if (except) curr_thread->exceptfds = *except;
+ else FD_ZERO(&curr_thread->exceptfds);
+ curr_thread->fd = max;
+ curr_thread->wait_for = WAIT_SELECT;
+ if (timeout) {
+ curr_thread->delay = timeofday() +
+ (double)timeout->tv_sec + (double)timeout->tv_usec*1e-6;
+ curr_thread->wait_for |= WAIT_TIME;
+ }
+ rb_thread_schedule();
+ if (read) *read = curr_thread->readfds;
+ if (write) *write = curr_thread->writefds;
+ if (except) *except = curr_thread->exceptfds;
+ 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;
+
+ if (rb_thread_critical) rb_thread_deadlock();
+ if (!rb_thread_dead(th)) {
+ if (th == curr_thread)
+ rb_raise(rb_eThreadError, "thread 0x%lx tried to join itself",
+ th->thread);
+ if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
+ rb_raise(rb_eThreadError, "Thread#join: deadlock 0x%lx - mutual join(0x%lx)",
+ curr_thread->thread, th->thread);
+ if (curr_thread->status == THREAD_TO_KILL)
+ last_status = THREAD_TO_KILL;
+ if (limit == 0) return Qfalse;
+ curr_thread->status = THREAD_STOPPED;
+ curr_thread->join = th;
+ curr_thread->wait_for = WAIT_JOIN;
+ curr_thread->delay = timeofday() + limit;
+ if (limit < DELAY_INFTY) curr_thread->wait_for |= WAIT_TIME;
+ rb_thread_schedule();
+ curr_thread->status = last_status;
+ if (!rb_thread_dead(th)) return Qfalse;
+ }
+
+ if (!NIL_P(th->errinfo) && (th->flags & RAISED_EXCEPTION)) {
+ VALUE oldbt = get_backtrace(th->errinfo);
+ VALUE errat = make_backtrace();
+ VALUE errinfo = rb_obj_dup(th->errinfo);
+
+ if (TYPE(oldbt) == T_ARRAY && RARRAY(oldbt)->len > 0) {
+ rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
+ }
+ set_backtrace(errinfo, errat);
+ rb_exc_raise(errinfo);
+ }
+
+ return Qtrue;
+}
+
+
+/*
+ * call-seq:
+ * thr.join => thr
+ * thr.join(limit) => thr
+ *
+ * The calling thread will suspend execution and run <i>thr</i>. Does not
+ * return until <i>thr</i> exits or until <i>limit</i> seconds have passed. If
+ * the time limit expires, <code>nil</code> will be returned, otherwise
+ * <i>thr</i> is returned.
+ *
+ * Any threads not joined will be killed when the main program exits. If
+ * <i>thr</i> had previously raised an exception and the
+ * <code>abort_on_exception</code> and <code>$DEBUG</code> flags are not set
+ * (so the exception has not yet been processed) it will be processed at this
+ * time.
+ *
+ * a = Thread.new { print "a"; sleep(10); print "b"; print "c" }
+ * x = Thread.new { print "x"; Thread.pass; print "y"; print "z" }
+ * x.join # Let x thread finish, a will be killed on exit.
+ *
+ * <em>produces:</em>
+ *
+ * axyz
+ *
+ * The following example illustrates the <i>limit</i> parameter.
+ *
+ * y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
+ * puts "Waiting" until y.join(0.15)
+ *
+ * <em>produces:</em>
+ *
+ * tick...
+ * Waiting
+ * tick...
+ * Waitingtick...
+ *
+ *
+ * tick...
+ */
+
+static VALUE
+rb_thread_join_m(argc, argv, thread)
+ int argc;
+ VALUE *argv;
+ VALUE thread;
+{
+ VALUE limit;
+ double delay = DELAY_INFTY;
+ rb_thread_t th = rb_thread_check(thread);
+
+ rb_scan_args(argc, argv, "01", &limit);
+ if (!NIL_P(limit)) delay = rb_num2dbl(limit);
+ if (!rb_thread_join(th, delay))
+ return Qnil;
+ return thread;
+}
+
+
+/*
+ * call-seq:
+ * Thread.current => thread
+ *
+ * Returns the currently executing thread.
+ *
+ * Thread.current #=> #<Thread:0x401bdf4c run>
+ */
+
+VALUE
+rb_thread_current()
+{
+ return curr_thread->thread;
+}
+
+
+/*
+ * call-seq:
+ * Thread.main => thread
+ *
+ * Returns the main thread for the process.
+ *
+ * Thread.main #=> #<Thread:0x401bdf4c run>
+ */
+
+VALUE
+rb_thread_main()
+{
+ return main_thread->thread;
+}
+
+
+/*
+ * call-seq:
+ * Thread.list => array
+ *
+ * Returns an array of <code>Thread</code> objects for all threads that are
+ * either runnable or stopped.
+ *
+ * Thread.new { sleep(200) }
+ * Thread.new { 1000000.times {|i| i*i } }
+ * Thread.new { Thread.stop }
+ * Thread.list.each {|t| p t}
+ *
+ * <em>produces:</em>
+ *
+ * #<Thread:0x401b3e84 sleep>
+ * #<Thread:0x401b3f38 run>
+ * #<Thread:0x401b3fb0 sleep>
+ * #<Thread:0x401bdf4c run>
+ */
+
+VALUE
+rb_thread_list()
+{
+ rb_thread_t th;
+ VALUE ary = rb_ary_new();
+
+ FOREACH_THREAD(th) {
+ switch (th->status) {
+ case THREAD_RUNNABLE:
+ case THREAD_STOPPED:
+ case THREAD_TO_KILL:
+ rb_ary_push(ary, th->thread);
+ default:
+ break;
+ }
+ }
+ END_FOREACH(th);
+
+ return ary;
+}
+
+
+/*
+ * call-seq:
+ * thr.wakeup => thr
+ *
+ * Marks <i>thr</i> as eligible for scheduling (it may still remain blocked on
+ * I/O, however). Does not invoke the scheduler (see <code>Thread#run</code>).
+ *
+ * c = Thread.new { Thread.stop; puts "hey!" }
+ * c.wakeup
+ *
+ * <em>produces:</em>
+ *
+ * hey!
+ */
+
+VALUE
+rb_thread_wakeup(thread)
+ VALUE thread;
+{
+ 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_thread_ready(th);
+
+ return thread;
+}
+
+
+/*
+ * call-seq:
+ * thr.run => thr
+ *
+ * Wakes up <i>thr</i>, making it eligible for scheduling. If not in a critical
+ * section, then invokes the scheduler.
+ *
+ * a = Thread.new { puts "a"; Thread.stop; puts "c" }
+ * Thread.pass
+ * puts "Got here"
+ * a.run
+ * a.join
+ *
+ * <em>produces:</em>
+ *
+ * a
+ * Got here
+ * c
+ */
+
+VALUE
+rb_thread_run(thread)
+ VALUE thread;
+{
+ rb_thread_wakeup(thread);
+ if (!rb_thread_critical) rb_thread_schedule();
+
+ return 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
+ *
+ * Terminates <i>thr</i> and schedules another thread to be run, returning
+ * the terminated <code>Thread</code>. If this is the main thread, or the
+ * last thread, exits the process.
+ */
+
+VALUE
+rb_thread_kill(thread)
+ VALUE 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.
+ */
+
+static VALUE
+rb_thread_kill_bang(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+ rb_kill_thread(th, THREAD_NO_ENSURE);
+ return thread;
+}
+
+/*
+ * call-seq:
+ * Thread.kill(thread) => thread
+ *
+ * Causes the given <em>thread</em> to exit (see <code>Thread::exit</code>).
+ *
+ * count = 0
+ * a = Thread.new { loop { count += 1 } }
+ * sleep(0.1) #=> 0
+ * Thread.kill(a) #=> #<Thread:0x401b3d30 dead>
+ * count #=> 93947
+ * a.alive? #=> false
+ */
+
+static VALUE
+rb_thread_s_kill(obj, th)
+ VALUE obj, th;
+{
+ return rb_thread_kill(th);
+}
+
+
+/*
+ * call-seq:
+ * Thread.exit => thread
+ *
+ * Terminates the currently running thread and schedules another thread to be
+ * run. If this thread is already marked to be killed, <code>exit</code>
+ * returns the <code>Thread</code>. If this is the main thread, or the last
+ * thread, exit the process.
+ */
+
+static VALUE
+rb_thread_exit()
+{
+ return rb_thread_kill(curr_thread->thread);
+}
+
+
+/*
+ * call-seq:
+ * Thread.pass => nil
+ *
+ * Invokes the thread scheduler to pass execution to another thread.
+ *
+ * a = Thread.new { print "a"; Thread.pass;
+ * print "b"; Thread.pass;
+ * print "c" }
+ * b = Thread.new { print "x"; Thread.pass;
+ * print "y"; Thread.pass;
+ * print "z" }
+ * a.join
+ * b.join
+ *
+ * <em>produces:</em>
+ *
+ * axbycz
+ */
+
+static VALUE
+rb_thread_pass()
+{
+ rb_thread_schedule();
+ return Qnil;
+}
+
+
+/*
+ * call-seq:
+ * Thread.stop => nil
+ *
+ * Stops execution of the current thread, putting it into a ``sleep'' state,
+ * and schedules execution of another thread. Resets the ``critical'' condition
+ * to <code>false</code>.
+ *
+ * a = Thread.new { print "a"; Thread.stop; print "c" }
+ * Thread.pass
+ * print "b"
+ * a.run
+ * a.join
+ *
+ * <em>produces:</em>
+ *
+ * abc
+ */
+
+VALUE
+rb_thread_stop()
+{
+ enum rb_thread_status last_status = THREAD_RUNNABLE;
+
+ rb_thread_critical = 0;
+ if (curr_thread == curr_thread->next) {
+ rb_raise(rb_eThreadError, "stopping only thread\n\tnote: use sleep to stop forever");
+ }
+ if (curr_thread->status == THREAD_TO_KILL)
+ last_status = THREAD_TO_KILL;
+ curr_thread->status = THREAD_STOPPED;
+ rb_thread_schedule();
+ curr_thread->status = last_status;
+
+ return Qnil;
+}
+
+struct timeval rb_time_timeval();
+
+void
+rb_thread_polling()
+{
+ if (curr_thread != curr_thread->next) {
+ curr_thread->status = THREAD_STOPPED;
+ curr_thread->delay = timeofday() + (double)0.06;
+ curr_thread->wait_for = WAIT_TIME;
+ rb_thread_schedule();
+ }
+}
+
+void
+rb_thread_sleep(sec)
+ int sec;
+{
+ if (curr_thread == curr_thread->next) {
+ TRAP_BEG;
+ sleep(sec);
+ TRAP_END;
+ return;
+ }
+ rb_thread_wait_for(rb_time_timeval(INT2FIX(sec)));
+}
+
+void
+rb_thread_sleep_forever()
+{
+ int thr_critical = rb_thread_critical;
+ if (curr_thread == curr_thread->next ||
+ curr_thread->status == THREAD_TO_KILL) {
+ rb_thread_critical = Qtrue;
+ TRAP_BEG;
+ pause();
+ rb_thread_critical = thr_critical;
+ TRAP_END;
+ return;
+ }
+
+ curr_thread->delay = DELAY_INFTY;
+ curr_thread->wait_for = WAIT_TIME;
+ curr_thread->status = THREAD_STOPPED;
+ rb_thread_schedule();
+}
+
+
+/*
+ * 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.
+ *
+ * Thread.current.priority #=> 0
+ */
+
+static VALUE
+rb_thread_priority(thread)
+ VALUE thread;
+{
+ return INT2NUM(rb_thread_check(thread)->priority);
+}
+
+
+/*
+ * call-seq:
+ * thr.priority= integer => thr
+ *
+ * Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads
+ * will run before lower-priority threads.
+ *
+ * count1 = count2 = 0
+ * a = Thread.new do
+ * loop { count1 += 1 }
+ * end
+ * a.priority = -1
+ *
+ * b = Thread.new do
+ * loop { count2 += 1 }
+ * end
+ * b.priority = -2
+ * sleep 1 #=> 1
+ * Thread.critical = 1
+ * count1 #=> 622504
+ * count2 #=> 5832
+ */
+
+static VALUE
+rb_thread_priority_set(thread, prio)
+ VALUE thread, prio;
+{
+ rb_thread_t th;
+
+ rb_secure(4);
+ th = rb_thread_check(thread);
+
+ th->priority = NUM2INT(prio);
+ rb_thread_schedule();
+ return prio;
+}
+
+
+/*
+ * call-seq:
+ * thr.safe_level => integer
+ *
+ * Returns the safe level in effect for <i>thr</i>. Setting thread-local safe
+ * levels can help when implementing sandboxes which run insecure code.
+ *
+ * thr = Thread.new { $SAFE = 3; sleep }
+ * Thread.current.safe_level #=> 0
+ * thr.safe_level #=> 3
+ */
+
+static VALUE
+rb_thread_safe_level(thread)
+ VALUE thread;
+{
+ rb_thread_t th;
+
+ th = rb_thread_check(thread);
+ if (th == curr_thread) {
+ return INT2NUM(ruby_safe_level);
+ }
+ return INT2NUM(th->safe);
+}
+
+static int ruby_thread_abort;
+static VALUE thgroup_default;
+
+
+/*
+ * call-seq:
+ * Thread.abort_on_exception => true or false
+ *
+ * Returns the status of the global ``abort on exception'' condition. The
+ * default is <code>false</code>. When set to <code>true</code>, or if the
+ * global <code>$DEBUG</code> flag is <code>true</code> (perhaps because the
+ * command line option <code>-d</code> was specified) all threads will abort
+ * (the process will <code>exit(0)</code>) if an exception is raised in any
+ * thread. See also <code>Thread::abort_on_exception=</code>.
+ */
+
+static VALUE
+rb_thread_s_abort_exc()
+{
+ return ruby_thread_abort?Qtrue:Qfalse;
+}
+
+
+/*
+ * call-seq:
+ * Thread.abort_on_exception= boolean => true or false
+ *
+ * When set to <code>true</code>, all threads will abort if an exception is
+ * raised. Returns the new state.
+ *
+ * Thread.abort_on_exception = true
+ * t1 = Thread.new do
+ * puts "In new thread"
+ * raise "Exception from thread"
+ * end
+ * sleep(1)
+ * puts "not reached"
+ *
+ * <em>produces:</em>
+ *
+ * In new thread
+ * prog.rb:4: Exception from thread (RuntimeError)
+ * from prog.rb:2:in `initialize'
+ * from prog.rb:2:in `new'
+ * from prog.rb:2
+ */
+
+static VALUE
+rb_thread_s_abort_exc_set(self, val)
+ VALUE self, val;
+{
+ rb_secure(4);
+ ruby_thread_abort = RTEST(val);
+ return val;
+}
+
+
+/*
+ * call-seq:
+ * thr.abort_on_exception => true or false
+ *
+ * Returns the status of the thread-local ``abort on exception'' condition for
+ * <i>thr</i>. The default is <code>false</code>. See also
+ * <code>Thread::abort_on_exception=</code>.
+ */
+
+static VALUE
+rb_thread_abort_exc(thread)
+ VALUE thread;
+{
+ return rb_thread_check(thread)->abort?Qtrue:Qfalse;
+}
+
+
+/*
+ * call-seq:
+ * thr.abort_on_exception= boolean => true or false
+ *
+ * When set to <code>true</code>, causes all threads (including the main
+ * program) to abort if an exception is raised in <i>thr</i>. The process will
+ * effectively <code>exit(0)</code>.
+ */
+
+static VALUE
+rb_thread_abort_exc_set(thread, val)
+ VALUE thread, val;
+{
+ rb_secure(4);
+ rb_thread_check(thread)->abort = RTEST(val);
+ return val;
+}
+
+
+/*
+ * call-seq:
+ * thr.group => thgrp or nil
+ *
+ * Returns the <code>ThreadGroup</code> which contains <i>thr</i>, or nil if
+ * the thread is not a member of any group.
+ *
+ * Thread.main.group #=> #<ThreadGroup:0x4029d914>
+ */
+
+VALUE
+rb_thread_group(thread)
+ VALUE thread;
+{
+ VALUE group = rb_thread_check(thread)->thgroup;
+ if (!group) {
+ group = Qnil;
+ }
+ return group;
+}
+
+#ifdef __ia64
+# define IA64_INIT(x) x
+#else
+# define IA64_INIT(x)
+#endif
+
+#define THREAD_ALLOC(th) do {\
+ th = ALLOC(struct rb_thread);\
+\
+ th->next = 0;\
+ th->prev = 0;\
+\
+ th->status = THREAD_RUNNABLE;\
+ th->result = 0;\
+ th->flags = 0;\
+\
+ th->stk_ptr = 0;\
+ th->stk_len = 0;\
+ th->stk_max = 0;\
+ 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);\
+ th->delay = 0.0;\
+ th->join = 0;\
+\
+ th->frame = 0;\
+ th->scope = 0;\
+ th->klass = 0;\
+ th->wrapper = 0;\
+ th->cref = ruby_cref;\
+ th->dyna_vars = ruby_dyna_vars;\
+ th->block = 0;\
+ th->iter = 0;\
+ th->tag = 0;\
+ th->tracing = 0;\
+ th->errinfo = Qnil;\
+ th->last_status = 0;\
+ th->last_line = 0;\
+ th->last_match = Qnil;\
+ th->abort = 0;\
+ th->priority = 0;\
+ 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
+rb_thread_alloc(klass)
+ VALUE klass;
+{
+ rb_thread_t th;
+ struct RVarmap *vars;
+
+ THREAD_ALLOC(th);
+ th->thread = Data_Wrap_Struct(klass, thread_mark, thread_free, th);
+
+ for (vars = th->dyna_vars; vars; vars = vars->next) {
+ if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
+ return th;
+}
+
+static int thread_init;
+
+#if defined(_THREAD_SAFE)
+static void
+catch_timer(sig)
+ int sig;
+{
+#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
+ signal(sig, catch_timer);
+#endif
+ /* cause EINTR */
+}
+
+static pthread_t time_thread;
+
+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;
+
+ req.tv_sec = 0;
+ req.tv_nsec = 10000000;
+ nanosleep(&req, &rem);
+#else
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 10000;
+ select(0, NULL, NULL, NULL, &tv);
+#endif
+ if (!rb_thread_critical) {
+ rb_thread_pending = 1;
+ if (rb_trap_immediate) {
+ pthread_kill(ruby_thid, SIGVTALRM);
+ }
+ }
+ }
+}
+
+void
+rb_thread_start_timer()
+{
+}
+
+void
+rb_thread_stop_timer()
+{
+}
+#elif defined(HAVE_SETITIMER)
+static void
+catch_timer(sig)
+ int sig;
+{
+#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
+ signal(sig, catch_timer);
+#endif
+ if (!rb_thread_critical) {
+ rb_thread_pending = 1;
+ }
+ /* cause EINTR */
+}
+
+void
+rb_thread_start_timer()
+{
+ struct itimerval tval;
+
+ if (!thread_init) return;
+ tval.it_interval.tv_sec = 0;
+ tval.it_interval.tv_usec = 10000;
+ tval.it_value = tval.it_interval;
+ setitimer(ITIMER_VIRTUAL, &tval, NULL);
+}
+
+void
+rb_thread_stop_timer()
+{
+ struct itimerval tval;
+
+ if (!thread_init) return;
+ tval.it_interval.tv_sec = 0;
+ tval.it_interval.tv_usec = 0;
+ tval.it_value = tval.it_interval;
+ setitimer(ITIMER_VIRTUAL, &tval, NULL);
+}
+#else /* !(_THREAD_SAFE || HAVE_SETITIMER) */
+int rb_thread_tick = THREAD_TICK;
+#endif
+
+static VALUE
+rb_thread_start_0(fn, arg, th)
+ VALUE (*fn)();
+ void *arg;
+ rb_thread_t th;
+{
+ volatile rb_thread_t th_save = th;
+ volatile VALUE thread = th->thread;
+ struct BLOCK *volatile saved_block = 0;
+ enum rb_thread_status status;
+ int state;
+
+ if (OBJ_FROZEN(curr_thread->thgroup)) {
+ rb_raise(rb_eThreadError,
+ "can't start a new thread (frozen ThreadGroup)");
+ }
+
+ if (!thread_init) {
+ thread_init = 1;
+#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
+#if defined(POSIX_SIGNAL)
+ posix_signal(SIGVTALRM, catch_timer);
+#else
+ signal(SIGVTALRM, catch_timer);
+#endif
+
+#ifdef _THREAD_SAFE
+ pthread_create(&time_thread, 0, thread_timer, 0);
+#else
+ rb_thread_start_timer();
+#endif
+#endif
+ }
+
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return thread;
+ }
+
+ if (ruby_block) { /* should nail down higher blocks */
+ struct BLOCK dummy;
+
+ dummy.prev = ruby_block;
+ blk_copy_prev(&dummy);
+ saved_block = ruby_block = dummy.prev;
+ }
+ scope_dup(ruby_scope);
+
+ if (!th->next) {
+ /* merge in thread list */
+ th->prev = curr_thread;
+ curr_thread->next->prev = th;
+ th->next = curr_thread->next;
+ curr_thread->next = th;
+ th->priority = curr_thread->priority;
+ th->thgroup = curr_thread->thgroup;
+ }
+
+ PUSH_TAG(PROT_THREAD);
+ if ((state = EXEC_TAG()) == 0) {
+ if (THREAD_SAVE_CONTEXT(th) == 0) {
+ curr_thread = th;
+ th->result = (*fn)(arg, th);
+ }
+ th = th_save;
+ }
+ else if (TAG_DST()) {
+ th = th_save;
+ th->result = prot_tag->retval;
+ }
+ POP_TAG();
+ status = th->status;
+
+ if (th == main_thread) ruby_stop(state);
+ rb_thread_remove(th);
+
+ if (saved_block) {
+ blk_free(saved_block);
+ }
+
+ if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) {
+ th->flags |= RAISED_EXCEPTION;
+ if (state == TAG_FATAL) {
+ /* fatal error within this thread, need to stop whole script */
+ main_thread->errinfo = ruby_errinfo;
+ rb_thread_cleanup();
+ }
+ else if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
+ if (th->safe >= 4) {
+ char buf[32];
+
+ sprintf(buf, "Insecure exit at level %d", th->safe);
+ th->errinfo = rb_exc_new2(rb_eSecurityError, buf);
+ }
+ else {
+ /* delegate exception to main_thread */
+ rb_thread_main_jump(ruby_errinfo, RESTORE_RAISE);
+ }
+ }
+ else if (th->safe < 4 && (ruby_thread_abort || th->abort || RTEST(ruby_debug))) {
+ /* exit on main_thread */
+ error_print();
+ rb_thread_main_jump(ruby_errinfo, RESTORE_EXIT);
+ }
+ else {
+ th->errinfo = ruby_errinfo;
+ }
+ }
+ rb_thread_schedule();
+ ruby_stop(0); /* last thread termination */
+ return 0; /* not reached */
+}
+
+VALUE
+rb_thread_create(fn, arg)
+ VALUE (*fn)();
+ void *arg;
+{
+ Init_stack((void *)&arg);
+ return rb_thread_start_0(fn, arg, rb_thread_alloc(rb_cThread));
+}
+
+static VALUE
+rb_thread_yield(arg, th)
+ VALUE arg;
+ rb_thread_t th;
+{
+ const ID *tbl;
+
+ scope_dup(ruby_block->scope);
+
+ tbl = ruby_scope->local_tbl;
+ if (tbl) {
+ int n = *tbl++;
+ for (tbl += 2, n -= 2; n > 0; --n) { /* skip first 2 ($_ and $~) */
+ ID id = *tbl++;
+ if (id != 0 && !rb_is_local_id(id)) /* push flip states */
+ rb_dvar_push(id, Qfalse);
+ }
+ }
+ rb_dvar_push('_', Qnil);
+ rb_dvar_push('~', Qnil);
+ ruby_block->dyna_vars = ruby_dyna_vars;
+
+ return rb_yield_0(arg, 0, 0, YIELD_LAMBDA_CALL, Qtrue);
+}
+
+/*
+ * call-seq:
+ * Thread.new([arg]*) {|args| block } => thread
+ *
+ * Creates and runs a new thread to execute the instructions given in
+ * <i>block</i>. Any arguments passed to <code>Thread::new</code> are passed
+ * into the block.
+ *
+ * x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" }
+ * a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" }
+ * x.join # Let the threads finish before
+ * a.join # main thread exits...
+ *
+ * <em>produces:</em>
+ *
+ * abxyzc
+ */
+
+static VALUE
+rb_thread_s_new(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ rb_thread_t th = rb_thread_alloc(klass);
+ volatile VALUE *pos;
+
+ pos = th->stk_pos;
+ rb_obj_call_init(th->thread, argc, argv);
+ if (th->stk_pos == 0) {
+ rb_raise(rb_eThreadError, "uninitialized thread - check `%s#initialize'",
+ rb_class2name(klass));
+ }
+
+ return th->thread;
+}
+
+
+/*
+ * call-seq:
+ * Thread.new([arg]*) {|args| block } => thread
+ *
+ * Creates and runs a new thread to execute the instructions given in
+ * <i>block</i>. Any arguments passed to <code>Thread::new</code> are passed
+ * into the block.
+ *
+ * x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" }
+ * a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" }
+ * x.join # Let the threads finish before
+ * a.join # main thread exits...
+ *
+ * <em>produces:</em>
+ *
+ * abxyzc
+ */
+
+static VALUE
+rb_thread_initialize(thread, args)
+ VALUE thread, args;
+{
+ rb_thread_t th;
+
+ if (!rb_block_given_p()) {
+ rb_raise(rb_eThreadError, "must be called with a block");
+ }
+ th = rb_thread_check(thread);
+ if (th->stk_max) {
+ NODE *node = th->node;
+ if (!node) {
+ rb_raise(rb_eThreadError, "already initialized thread");
+ }
+ rb_raise(rb_eThreadError, "already initialized thread - %s:%d",
+ node->nd_file, nd_line(node));
+ }
+ return rb_thread_start_0(rb_thread_yield, args, th);
+}
+
+
+/*
+ * call-seq:
+ * Thread.start([args]*) {|args| block } => thread
+ * Thread.fork([args]*) {|args| block } => thread
+ *
+ * Basically the same as <code>Thread::new</code>. However, if class
+ * <code>Thread</code> is subclassed, then calling <code>start</code> in that
+ * subclass will not invoke the subclass's <code>initialize</code> method.
+ */
+
+static VALUE
+rb_thread_start(klass, args)
+ VALUE klass, args;
+{
+ if (!rb_block_given_p()) {
+ rb_raise(rb_eThreadError, "must be called with a block");
+ }
+ return rb_thread_start_0(rb_thread_yield, args, rb_thread_alloc(klass));
+}
+
+
+/*
+ * call-seq:
+ * thr.value => obj
+ *
+ * Waits for <i>thr</i> to complete (via <code>Thread#join</code>) and returns
+ * its value.
+ *
+ * a = Thread.new { 2 + 2 }
+ * a.value #=> 4
+ */
+
+static VALUE
+rb_thread_value(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ while (!rb_thread_join(th, DELAY_INFTY));
+
+ return th->result;
+}
+
+
+/*
+ * call-seq:
+ * thr.status => string, false or nil
+ *
+ * Returns the status of <i>thr</i>: ``<code>sleep</code>'' if <i>thr</i> is
+ * sleeping or waiting on I/O, ``<code>run</code>'' if <i>thr</i> is executing,
+ * ``<code>aborting</code>'' if <i>thr</i> is aborting, <code>false</code> if
+ * <i>thr</i> terminated normally, and <code>nil</code> if <i>thr</i>
+ * terminated with an exception.
+ *
+ * a = Thread.new { raise("die now") }
+ * b = Thread.new { Thread.stop }
+ * c = Thread.new { Thread.exit }
+ * d = Thread.new { sleep }
+ * Thread.critical = true
+ * d.kill #=> #<Thread:0x401b3678 aborting>
+ * a.status #=> nil
+ * b.status #=> "sleep"
+ * c.status #=> false
+ * d.status #=> "aborting"
+ * Thread.current.status #=> "run"
+ */
+
+static VALUE
+rb_thread_status(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ if (rb_thread_dead(th)) {
+ if (!NIL_P(th->errinfo) && (th->flags & RAISED_EXCEPTION))
+ return Qnil;
+ return Qfalse;
+ }
+
+ return rb_str_new2(thread_status_name(th->status));
+}
+
+
+/*
+ * call-seq:
+ * thr.alive? => true or false
+ *
+ * Returns <code>true</code> if <i>thr</i> is running or sleeping.
+ *
+ * thr = Thread.new { }
+ * thr.join #=> #<Thread:0x401b3fb0 dead>
+ * Thread.current.alive? #=> true
+ * thr.alive? #=> false
+ */
+
+VALUE
+rb_thread_alive_p(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ if (rb_thread_dead(th)) return Qfalse;
+ return Qtrue;
+}
+
+
+/*
+ * call-seq:
+ * thr.stop? => true or false
+ *
+ * Returns <code>true</code> if <i>thr</i> is dead or sleeping.
+ *
+ * a = Thread.new { Thread.stop }
+ * b = Thread.current
+ * a.stop? #=> true
+ * b.stop? #=> false
+ */
+
+static VALUE
+rb_thread_stop_p(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ if (rb_thread_dead(th)) return Qtrue;
+ if (th->status == THREAD_STOPPED) return Qtrue;
+ return Qfalse;
+}
+
+static void
+rb_thread_wait_other_threads()
+{
+ rb_thread_t th;
+ int found;
+
+ /* wait other threads to terminate */
+ while (curr_thread != curr_thread->next) {
+ found = 0;
+ FOREACH_THREAD(th) {
+ if (th != curr_thread && th->status != THREAD_STOPPED) {
+ found = 1;
+ break;
+ }
+ }
+ END_FOREACH(th);
+ if (!found) return;
+ rb_thread_schedule();
+ }
+}
+
+static void
+rb_thread_cleanup()
+{
+ rb_thread_t curr, th;
+
+ curr = curr_thread;
+ while (curr->status == THREAD_KILLED) {
+ curr = curr->prev;
+ }
+
+ FOREACH_THREAD_FROM(curr, th) {
+ if (th->status != THREAD_KILLED) {
+ rb_thread_ready(th);
+ if (th != main_thread) {
+ th->thgroup = 0;
+ th->priority = 0;
+ th->status = THREAD_TO_KILL;
+ RDATA(th->thread)->dfree = NULL;
+ }
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+}
+
+int rb_thread_critical;
+
+
+/*
+ * call-seq:
+ * Thread.critical => true or false
+ *
+ * Returns the status of the global ``thread critical'' condition.
+ */
+
+static VALUE
+rb_thread_critical_get()
+{
+ return rb_thread_critical?Qtrue:Qfalse;
+}
+
+
+/*
+ * call-seq:
+ * Thread.critical= boolean => true or false
+ *
+ * Sets the status of the global ``thread critical'' condition and returns
+ * it. When set to <code>true</code>, prohibits scheduling of any existing
+ * thread. Does not block new threads from being created and run. Certain
+ * thread operations (such as stopping or killing a thread, sleeping in the
+ * current thread, and raising an exception) may cause a thread to be scheduled
+ * even when in a critical section. <code>Thread::critical</code> is not
+ * intended for daily use: it is primarily there to support folks writing
+ * threading libraries.
+ */
+
+static VALUE
+rb_thread_critical_set(obj, val)
+ VALUE obj, val;
+{
+ rb_thread_critical = RTEST(val);
+ return val;
+}
+
+void
+rb_thread_interrupt()
+{
+ rb_thread_critical = 0;
+ rb_thread_ready(main_thread);
+ if (curr_thread == main_thread) {
+ rb_interrupt();
+ }
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
+ }
+ curr_thread = main_thread;
+ rb_thread_restore_context(curr_thread, RESTORE_INTERRUPT);
+}
+
+void
+rb_thread_signal_raise(sig)
+ int sig;
+{
+ 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_thread_ready(main_thread);
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
+ }
+ th_sig = sig;
+ curr_thread = main_thread;
+ rb_thread_restore_context(curr_thread, RESTORE_SIGNAL);
+}
+
+void
+rb_thread_trap_eval(cmd, sig, safe)
+ VALUE cmd;
+ int sig, safe;
+{
+ rb_thread_critical = 0;
+ if (curr_thread == main_thread) {
+ rb_trap_eval(cmd, sig, safe);
+ return;
+ }
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
+ }
+ th_cmd = cmd;
+ th_sig = sig;
+ th_safe = safe;
+ curr_thread = main_thread;
+ rb_thread_restore_context(curr_thread, RESTORE_TRAP);
+}
+
+void
+rb_thread_signal_exit()
+{
+ VALUE args[2];
+
+ rb_thread_critical = 0;
+ if (curr_thread == main_thread) {
+ rb_thread_ready(curr_thread);
+ rb_exit(EXIT_SUCCESS);
+ }
+ args[0] = INT2NUM(EXIT_SUCCESS);
+ args[1] = rb_str_new2("exit");
+ rb_thread_ready(main_thread);
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
+ }
+ rb_thread_main_jump(rb_class_new_instance(2, args, rb_eSystemExit),
+ RESTORE_EXIT);
+}
+
+static VALUE
+rb_thread_raise(argc, argv, th)
+ int argc;
+ VALUE *argv;
+ rb_thread_t th;
+{
+ volatile rb_thread_t th_save = th;
+ VALUE exc;
+
+ if (!th->next) {
+ rb_raise(rb_eArgError, "unstarted thread");
+ }
+ if (rb_thread_dead(th)) return Qnil;
+ exc = rb_make_exception(argc, argv);
+ if (curr_thread == th) {
+ rb_raise_jump(exc);
+ }
+
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return th_save->thread;
+ }
+ }
+
+ rb_thread_ready(th);
+ curr_thread = th;
+
+ th_raise_exception = exc;
+ th_raise_node = ruby_current_node;
+ rb_thread_restore_context(curr_thread, RESTORE_RAISE);
+ return Qnil; /* not reached */
+}
+
+
+/*
+ * call-seq:
+ * thr.raise(exception)
+ *
+ * Raises an exception (see <code>Kernel::raise</code>) from <i>thr</i>. The
+ * caller does not have to be <i>thr</i>.
+ *
+ * Thread.abort_on_exception = true
+ * a = Thread.new { sleep(200) }
+ * a.raise("Gotcha")
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:3: Gotcha (RuntimeError)
+ * from prog.rb:2:in `initialize'
+ * from prog.rb:2:in `new'
+ * from prog.rb:2
+ */
+
+static VALUE
+rb_thread_raise_m(argc, argv, thread)
+ int argc;
+ VALUE *argv;
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ if (ruby_safe_level > th->safe) {
+ rb_secure(4);
+ }
+ rb_thread_raise(argc, argv, th);
+ return Qnil; /* not reached */
+}
+
+VALUE
+rb_thread_local_aref(thread, id)
+ VALUE thread;
+ ID id;
+{
+ rb_thread_t th;
+ VALUE val;
+
+ th = rb_thread_check(thread);
+ if (ruby_safe_level >= 4 && th != curr_thread) {
+ rb_raise(rb_eSecurityError, "Insecure: thread locals");
+ }
+ if (!th->locals) return Qnil;
+ if (st_lookup(th->locals, id, &val)) {
+ return val;
+ }
+ return Qnil;
+}
+
+
+/*
+ * call-seq:
+ * thr[sym] => obj or nil
+ *
+ * Attribute Reference---Returns the value of a thread-local variable, using
+ * either a symbol or a string name. If the specified variable does not exist,
+ * returns <code>nil</code>.
+ *
+ * a = Thread.new { Thread.current["name"] = "A"; Thread.stop }
+ * b = Thread.new { Thread.current[:name] = "B"; Thread.stop }
+ * c = Thread.new { Thread.current["name"] = "C"; Thread.stop }
+ * Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" }
+ *
+ * <em>produces:</em>
+ *
+ * #<Thread:0x401b3b3c sleep>: C
+ * #<Thread:0x401b3bc8 sleep>: B
+ * #<Thread:0x401b3c68 sleep>: A
+ * #<Thread:0x401bdf4c run>:
+ */
+
+static VALUE
+rb_thread_aref(thread, id)
+ VALUE thread, id;
+{
+ return rb_thread_local_aref(thread, rb_to_id(id));
+}
+
+VALUE
+rb_thread_local_aset(thread, id, val)
+ VALUE thread;
+ ID id;
+ VALUE val;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ if (ruby_safe_level >= 4 && th != curr_thread) {
+ rb_raise(rb_eSecurityError, "Insecure: can't modify thread locals");
+ }
+ if (OBJ_FROZEN(thread)) rb_error_frozen("thread locals");
+
+ if (!th->locals) {
+ th->locals = st_init_numtable();
+ }
+ if (NIL_P(val)) {
+ st_delete(th->locals, (st_data_t*)&id, 0);
+ return Qnil;
+ }
+ st_insert(th->locals, id, val);
+
+ return val;
+}
+
+
+/*
+ * call-seq:
+ * thr[sym] = obj => obj
+ *
+ * Attribute Assignment---Sets or creates the value of a thread-local variable,
+ * using either a symbol or a string. See also <code>Thread#[]</code>.
+ */
+
+static VALUE
+rb_thread_aset(thread, id, val)
+ VALUE thread, id, val;
+{
+ return rb_thread_local_aset(thread, rb_to_id(id), val);
+}
+
+
+/*
+ * call-seq:
+ * thr.key?(sym) => true or false
+ *
+ * Returns <code>true</code> if the given string (or symbol) exists as a
+ * thread-local variable.
+ *
+ * me = Thread.current
+ * me[:oliver] = "a"
+ * me.key?(:oliver) #=> true
+ * me.key?(:stanley) #=> false
+ */
+
+static VALUE
+rb_thread_key_p(thread, id)
+ VALUE thread, id;
+{
+ rb_thread_t th = rb_thread_check(thread);
+
+ if (!th->locals) return Qfalse;
+ if (st_lookup(th->locals, rb_to_id(id), 0))
+ return Qtrue;
+ return Qfalse;
+}
+
+static int
+thread_keys_i(key, value, ary)
+ ID key;
+ VALUE value, ary;
+{
+ rb_ary_push(ary, ID2SYM(key));
+ return ST_CONTINUE;
+}
+
+
+/*
+ * call-seq:
+ * thr.keys => array
+ *
+ * Returns an an array of the names of the thread-local variables (as Symbols).
+ *
+ * thr = Thread.new do
+ * Thread.current[:cat] = 'meow'
+ * Thread.current["dog"] = 'woof'
+ * end
+ * thr.join #=> #<Thread:0x401b3f10 dead>
+ * thr.keys #=> [:dog, :cat]
+ */
+
+static VALUE
+rb_thread_keys(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+ VALUE ary = rb_ary_new();
+
+ if (th->locals) {
+ st_foreach(th->locals, thread_keys_i, ary);
+ }
+ return ary;
+}
+
+/*
+ * call-seq:
+ * thr.inspect => string
+ *
+ * Dump the name, id, and status of _thr_ to a string.
+ */
+
+static VALUE
+rb_thread_inspect(thread)
+ VALUE thread;
+{
+ const char *cname = rb_obj_classname(thread);
+ rb_thread_t th = rb_thread_check(thread);
+ const char *status = thread_status_name(th->status);
+ VALUE str;
+ size_t len = strlen(cname)+7+16+9+1;
+
+ str = rb_str_new(0, len); /* 7:tags 16:addr 9:status 1:nul */
+ snprintf(RSTRING(str)->ptr, len, "#<%s:0x%lx %s>", cname, thread, status);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ OBJ_INFECT(str, thread);
+
+ return str;
+}
+
+void
+rb_thread_atfork()
+{
+ rb_thread_t th;
+
+ if (rb_thread_alone()) return;
+ FOREACH_THREAD(th) {
+ if (th != curr_thread) {
+ rb_thread_die(th);
+ }
+ }
+ END_FOREACH(th);
+ main_thread = curr_thread;
+ curr_thread->next = curr_thread;
+ curr_thread->prev = curr_thread;
+}
+
+
+/*
+ * Document-class: Continuation
+ *
+ * Continuation objects are generated by
+ * <code>Kernel#callcc</code>. They hold a return address and execution
+ * context, allowing a nonlocal return to the end of the
+ * <code>callcc</code> block from anywhere within a program.
+ * Continuations are somewhat analogous to a structured version of C's
+ * <code>setjmp/longjmp</code> (although they contain more state, so
+ * you might consider them closer to threads).
+ *
+ * For instance:
+ *
+ * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
+ * callcc{|$cc|}
+ * puts(message = arr.shift)
+ * $cc.call unless message =~ /Max/
+ *
+ * <em>produces:</em>
+ *
+ * Freddie
+ * Herbie
+ * Ron
+ * Max
+ *
+ * This (somewhat contrived) example allows the inner loop to abandon
+ * processing early:
+ *
+ * callcc {|cont|
+ * for i in 0..4
+ * print "\n#{i}: "
+ * for j in i*5...(i+1)*5
+ * cont.call() if j == 17
+ * printf "%3d", j
+ * end
+ * end
+ * }
+ * print "\n"
+ *
+ * <em>produces:</em>
+ *
+ * 0: 0 1 2 3 4
+ * 1: 5 6 7 8 9
+ * 2: 10 11 12 13 14
+ * 3: 15 16
+ */
+
+VALUE rb_cCont;
+
+/*
+ * call-seq:
+ * callcc {|cont| block } => obj
+ *
+ * Generates a <code>Continuation</code> object, which it passes to the
+ * associated block. Performing a <em>cont</em><code>.call</code> will
+ * cause the <code>callcc</code> to return (as will falling through the
+ * end of the block). The value returned by the <code>callcc</code> is
+ * the value of the block, or the value passed to
+ * <em>cont</em><code>.call</code>. See class <code>Continuation</code>
+ * for more details. Also see <code>Kernel::throw</code> for
+ * an alternative mechanism for unwinding a call stack.
+ */
+
+static VALUE
+rb_callcc(self)
+ VALUE self;
+{
+ volatile VALUE cont;
+ rb_thread_t th;
+ volatile rb_thread_t th_save;
+ struct tag *tag;
+ struct RVarmap *vars;
+
+ THREAD_ALLOC(th);
+ cont = Data_Wrap_Struct(rb_cCont, thread_mark, thread_free, th);
+
+ scope_dup(ruby_scope);
+ for (tag=prot_tag; tag; tag=tag->prev) {
+ scope_dup(tag->scope);
+ }
+ th->thread = curr_thread->thread;
+ th->thgroup = cont_protect;
+
+ for (vars = ruby_dyna_vars; vars; vars = vars->next) {
+ if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
+ th_save = th;
+ if (THREAD_SAVE_CONTEXT(th)) {
+ return th_save->result;
+ }
+ else {
+ return rb_yield(cont);
+ }
+}
+
+/*
+ * call-seq:
+ * cont.call(args, ...)
+ * cont[args, ...]
+ *
+ * Invokes the continuation. The program continues from the end of the
+ * <code>callcc</code> block. If no arguments are given, the original
+ * <code>callcc</code> returns <code>nil</code>. If one argument is
+ * given, <code>callcc</code> returns it. Otherwise, an array
+ * containing <i>args</i> is returned.
+ *
+ * callcc {|cont| cont.call } #=> nil
+ * callcc {|cont| cont.call 1 } #=> 1
+ * callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
+ */
+
+static VALUE
+rb_cont_call(argc, argv, cont)
+ int argc;
+ VALUE *argv;
+ VALUE cont;
+{
+ rb_thread_t th = rb_thread_check(cont);
+
+ if (th->thread != curr_thread->thread) {
+ rb_raise(rb_eRuntimeError, "continuation called across threads");
+ }
+ if (th->thgroup != cont_protect) {
+ rb_raise(rb_eRuntimeError, "continuation called across trap");
+ }
+ switch (argc) {
+ case 0:
+ th->result = Qnil;
+ break;
+ case 1:
+ th->result = argv[0];
+ break;
+ default:
+ th->result = rb_ary_new4(argc, argv);
+ break;
+ }
+
+ rb_thread_restore_context(th, RESTORE_NORMAL);
+ return Qnil;
+}
+
+struct thgroup {
+ int enclosed;
+ VALUE group;
+};
+
+
+/*
+ * Document-class: ThreadGroup
+ *
+ * <code>ThreadGroup</code> provides a means of keeping track of a number of
+ * threads as a group. A <code>Thread</code> can belong to only one
+ * <code>ThreadGroup</code> at a time; adding a thread to a new group will
+ * remove it from any previous group.
+ *
+ * Newly created threads belong to the same group as the thread from which they
+ * were created.
+ */
+
+static VALUE thgroup_s_alloc _((VALUE));
+static VALUE
+thgroup_s_alloc(klass)
+ VALUE klass;
+{
+ VALUE group;
+ struct thgroup *data;
+
+ group = Data_Make_Struct(klass, struct thgroup, 0, free, data);
+ data->enclosed = 0;
+ data->group = group;
+
+ return group;
+}
+
+
+/*
+ * call-seq:
+ * thgrp.list => array
+ *
+ * Returns an array of all existing <code>Thread</code> objects that belong to
+ * this group.
+ *
+ * ThreadGroup::Default.list #=> [#<Thread:0x401bdf4c run>]
+ */
+
+static VALUE
+thgroup_list(group)
+ VALUE group;
+{
+ struct thgroup *data;
+ rb_thread_t th;
+ VALUE ary;
+
+ Data_Get_Struct(group, struct thgroup, data);
+ ary = rb_ary_new();
+
+ FOREACH_THREAD(th) {
+ if (th->thgroup == data->group) {
+ rb_ary_push(ary, th->thread);
+ }
+ }
+ END_FOREACH(th);
+
+ return ary;
+}
+
+
+/*
+ * call-seq:
+ * thgrp.enclose => thgrp
+ *
+ * Prevents threads from being added to or removed from the receiving
+ * <code>ThreadGroup</code>. New threads can still be started in an enclosed
+ * <code>ThreadGroup</code>.
+ *
+ * ThreadGroup::Default.enclose #=> #<ThreadGroup:0x4029d914>
+ * thr = Thread::new { Thread.stop } #=> #<Thread:0x402a7210 sleep>
+ * tg = ThreadGroup::new #=> #<ThreadGroup:0x402752d4>
+ * tg.add thr
+ *
+ * <em>produces:</em>
+ *
+ * ThreadError: can't move from the enclosed thread group
+ */
+
+static VALUE
+thgroup_enclose(group)
+ VALUE group;
+{
+ struct thgroup *data;
+
+ Data_Get_Struct(group, struct thgroup, data);
+ data->enclosed = 1;
+
+ return group;
+}
+
+
+/*
+ * call-seq:
+ * thgrp.enclosed? => true or false
+ *
+ * Returns <code>true</code> if <em>thgrp</em> is enclosed. See also
+ * ThreadGroup#enclose.
+ */
+
+static VALUE
+thgroup_enclosed_p(group)
+ VALUE group;
+{
+ struct thgroup *data;
+
+ Data_Get_Struct(group, struct thgroup, data);
+ if (data->enclosed) return Qtrue;
+ return Qfalse;
+}
+
+
+/*
+ * call-seq:
+ * thgrp.add(thread) => thgrp
+ *
+ * Adds the given <em>thread</em> to this group, removing it from any other
+ * group to which it may have previously belonged.
+ *
+ * puts "Initial group is #{ThreadGroup::Default.list}"
+ * tg = ThreadGroup.new
+ * t1 = Thread.new { sleep }
+ * t2 = Thread.new { sleep }
+ * puts "t1 is #{t1}"
+ * puts "t2 is #{t2}"
+ * tg.add(t1)
+ * puts "Initial group now #{ThreadGroup::Default.list}"
+ * puts "tg group now #{tg.list}"
+ *
+ * <em>produces:</em>
+ *
+ * Initial group is #<Thread:0x401bdf4c>
+ * t1 is #<Thread:0x401b3c90>
+ * t2 is #<Thread:0x401b3c18>
+ * Initial group now #<Thread:0x401b3c18>#<Thread:0x401bdf4c>
+ * tg group now #<Thread:0x401b3c90>
+ */
+
+static VALUE
+thgroup_add(group, thread)
+ VALUE group, thread;
+{
+ rb_thread_t th;
+ struct thgroup *data;
+
+ rb_secure(4);
+ th = rb_thread_check(thread);
+ if (!th->next || !th->prev) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)",
+ rb_obj_classname(thread));
+ }
+
+ if (OBJ_FROZEN(group)) {
+ rb_raise(rb_eThreadError, "can't move to the frozen thread group");
+ }
+ Data_Get_Struct(group, struct thgroup, data);
+ if (data->enclosed) {
+ rb_raise(rb_eThreadError, "can't move to the enclosed thread group");
+ }
+
+ if (!th->thgroup) {
+ return Qnil;
+ }
+ if (OBJ_FROZEN(th->thgroup)) {
+ rb_raise(rb_eThreadError, "can't move from the frozen thread group");
+ }
+ Data_Get_Struct(th->thgroup, struct thgroup, data);
+ if (data->enclosed) {
+ rb_raise(rb_eThreadError, "can't move from the enclosed thread group");
+ }
+
+ th->thgroup = group;
+ return group;
+}
+
+
+/* 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.
+ *
+ * In the descriptions of the methods in this class, the parameter _sym_
+ * refers to a symbol, which is either a quoted string or a
+ * +Symbol+ (such as <code>:name</code>).
+ */
+
+void
+Init_Thread()
+{
+ 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);
+
+ rb_define_singleton_method(rb_cThread, "new", rb_thread_s_new, -1);
+ rb_define_method(rb_cThread, "initialize", rb_thread_initialize, -2);
+ rb_define_singleton_method(rb_cThread, "start", rb_thread_start, -2);
+ rb_define_singleton_method(rb_cThread, "fork", rb_thread_start, -2);
+
+ rb_define_singleton_method(rb_cThread, "stop", rb_thread_stop, 0);
+ rb_define_singleton_method(rb_cThread, "kill", rb_thread_s_kill, 1);
+ rb_define_singleton_method(rb_cThread, "exit", rb_thread_exit, 0);
+ rb_define_singleton_method(rb_cThread, "pass", rb_thread_pass, 0);
+ rb_define_singleton_method(rb_cThread, "current", rb_thread_current, 0);
+ rb_define_singleton_method(rb_cThread, "main", rb_thread_main, 0);
+ rb_define_singleton_method(rb_cThread, "list", rb_thread_list, 0);
+
+ rb_define_singleton_method(rb_cThread, "critical", rb_thread_critical_get, 0);
+ rb_define_singleton_method(rb_cThread, "critical=", rb_thread_critical_set, 1);
+
+ rb_define_singleton_method(rb_cThread, "abort_on_exception", rb_thread_s_abort_exc, 0);
+ rb_define_singleton_method(rb_cThread, "abort_on_exception=", rb_thread_s_abort_exc_set, 1);
+
+ rb_define_method(rb_cThread, "run", rb_thread_run, 0);
+ rb_define_method(rb_cThread, "wakeup", rb_thread_wakeup, 0);
+ rb_define_method(rb_cThread, "kill", rb_thread_kill, 0);
+ rb_define_method(rb_cThread, "terminate", rb_thread_kill, 0);
+ rb_define_method(rb_cThread, "exit", rb_thread_kill, 0);
+ rb_define_method(rb_cThread, "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);
+ rb_define_method(rb_cThread, "alive?", rb_thread_alive_p, 0);
+ rb_define_method(rb_cThread, "stop?", rb_thread_stop_p, 0);
+ rb_define_method(rb_cThread, "raise", rb_thread_raise_m, -1);
+
+ rb_define_method(rb_cThread, "abort_on_exception", rb_thread_abort_exc, 0);
+ rb_define_method(rb_cThread, "abort_on_exception=", rb_thread_abort_exc_set, 1);
+
+ rb_define_method(rb_cThread, "priority", rb_thread_priority, 0);
+ rb_define_method(rb_cThread, "priority=", rb_thread_priority_set, 1);
+ rb_define_method(rb_cThread, "safe_level", rb_thread_safe_level, 0);
+ rb_define_method(rb_cThread, "group", rb_thread_group, 0);
+
+ rb_define_method(rb_cThread, "[]", rb_thread_aref, 1);
+ rb_define_method(rb_cThread, "[]=", rb_thread_aset, 2);
+ rb_define_method(rb_cThread, "key?", rb_thread_key_p, 1);
+ rb_define_method(rb_cThread, "keys", rb_thread_keys, 0);
+
+ rb_define_method(rb_cThread, "inspect", rb_thread_inspect, 0);
+
+ rb_cCont = rb_define_class("Continuation", rb_cObject);
+ rb_undef_alloc_func(rb_cCont);
+ rb_undef_method(CLASS_OF(rb_cCont), "new");
+ rb_define_method(rb_cCont, "call", rb_cont_call, -1);
+ rb_define_method(rb_cCont, "[]", rb_cont_call, -1);
+ rb_define_global_function("callcc", rb_callcc, 0);
+ rb_global_variable(&cont_protect);
+
+ cThGroup = rb_define_class("ThreadGroup", rb_cObject);
+ rb_define_alloc_func(cThGroup, thgroup_s_alloc);
+ rb_define_method(cThGroup, "list", thgroup_list, 0);
+ rb_define_method(cThGroup, "enclose", thgroup_enclose, 0);
+ rb_define_method(cThGroup, "enclosed?", thgroup_enclosed_p, 0);
+ rb_define_method(cThGroup, "add", thgroup_add, 1);
+ rb_global_variable(&thgroup_default);
+ thgroup_default = rb_obj_alloc(cThGroup);
+ rb_define_const(cThGroup, "Default", thgroup_default);
+
+ /* allocate main thread */
+ main_thread = rb_thread_alloc(rb_cThread);
+ curr_thread = main_thread->prev = main_thread->next = main_thread;
+}
+
+/*
+ * call-seq:
+ * catch(symbol) {| | block } > obj
+ *
+ * +catch+ executes its block. If a +throw+ is
+ * executed, Ruby searches up its stack for a +catch+ block
+ * with a tag corresponding to the +throw+'s
+ * _symbol_. If found, that block is terminated, and
+ * +catch+ returns the value given to +throw+. If
+ * +throw+ is not called, the block terminates normally, and
+ * the value of +catch+ is the value of the last expression
+ * evaluated. +catch+ expressions may be nested, and the
+ * +throw+ call need not be in lexical scope.
+ *
+ * def routine(n)
+ * puts n
+ * throw :done if n <= 0
+ * routine(n-1)
+ * end
+ *
+ *
+ * catch(:done) { routine(3) }
+ *
+ * <em>produces:</em>
+ *
+ * 3
+ * 2
+ * 1
+ * 0
+ */
+
+static VALUE
+rb_f_catch(dmy, tag)
+ VALUE dmy, tag;
+{
+ int state;
+ VALUE val = Qnil; /* OK */
+
+ tag = ID2SYM(rb_to_id(tag));
+ PUSH_TAG(tag);
+ if ((state = EXEC_TAG()) == 0) {
+ val = rb_yield_0(tag, 0, 0, 0, Qfalse);
+ }
+ else if (state == TAG_THROW && tag == prot_tag->dst) {
+ val = prot_tag->retval;
+ state = 0;
+ }
+ POP_TAG();
+ if (state) JUMP_TAG(state);
+
+ return val;
+}
+
+static VALUE
+catch_i(tag)
+ VALUE tag;
+{
+ return rb_funcall(Qnil, rb_intern("catch"), 1, tag);
+}
+
+VALUE
+rb_catch(tag, func, data)
+ const char *tag;
+ VALUE (*func)();
+ VALUE data;
+{
+ return rb_iterate((VALUE(*)_((VALUE)))catch_i, ID2SYM(rb_intern(tag)), func, data);
+}
+
+/*
+ * call-seq:
+ * throw(symbol [, obj])
+ *
+ * Transfers control to the end of the active +catch+ block
+ * waiting for _symbol_. Raises +NameError+ if there
+ * is no +catch+ block for the symbol. The optional second
+ * parameter supplies a return value for the +catch+ block,
+ * which otherwise defaults to +nil+. For examples, see
+ * <code>Kernel::catch</code>.
+ */
+
+static VALUE
+rb_f_throw(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE tag, value;
+ struct tag *tt = prot_tag;
+
+ rb_scan_args(argc, argv, "11", &tag, &value);
+ tag = ID2SYM(rb_to_id(tag));
+
+ while (tt) {
+ if (tt->tag == tag) {
+ tt->dst = tag;
+ tt->retval = value;
+ break;
+ }
+ if (tt->tag == PROT_THREAD) {
+ rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%lx",
+ rb_id2name(SYM2ID(tag)),
+ curr_thread);
+ }
+ tt = tt->prev;
+ }
+ if (!tt) {
+ rb_name_error(SYM2ID(tag), "uncaught throw `%s'", rb_id2name(SYM2ID(tag)));
+ }
+ rb_trap_restore_mask();
+ JUMP_TAG(TAG_THROW);
+#ifndef __GNUC__
+ return Qnil; /* not reached */
+#endif
+}
+
+void
+rb_throw(tag, val)
+ const char *tag;
+ VALUE val;
+{
+ VALUE argv[2];
+
+ argv[0] = ID2SYM(rb_intern(tag));
+ argv[1] = val;
+ rb_f_throw(2, argv);
}
diff --git a/eval_error.c b/eval_error.c
deleted file mode 100644
index 94fb18029d..0000000000
--- a/eval_error.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/* -*-c-*- */
-/*
- * included by eval.c
- */
-
-const char *
-rb_sourcefile(void)
-{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
-
- if (cfp) {
- return RSTRING_PTR(cfp->iseq->filename);
- }
- else {
- return 0;
- }
-}
-
-int
-rb_sourceline(void)
-{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
-
- if (cfp) {
- return vm_get_sourceline(cfp);
- }
- else {
- return 0;
- }
-}
-
-static void
-warn_printf(const char *fmt, ...)
-{
- char buf[BUFSIZ];
- va_list args;
-
- va_init_list(args, fmt);
- vsnprintf(buf, BUFSIZ, fmt, args);
- va_end(args);
- rb_write_error(buf);
-}
-
-#define warn_print(x) rb_write_error(x)
-#define warn_print2(x,l) rb_write_error2(x,l)
-
-static void
-error_pos(void)
-{
- const char *sourcefile = rb_sourcefile();
- int sourceline = rb_sourceline();
-
- if (sourcefile) {
- if (sourceline == 0) {
- warn_printf("%s", sourcefile);
- }
- else if (rb_frame_callee()) {
- warn_printf("%s:%d:in `%s'", sourcefile, sourceline,
- rb_id2name(rb_frame_callee()));
- }
- else {
- warn_printf("%s:%d", sourcefile, sourceline);
- }
- }
-}
-
-VALUE rb_check_backtrace(VALUE);
-
-static VALUE
-get_backtrace(VALUE info)
-{
- if (NIL_P(info))
- return Qnil;
- info = rb_funcall(info, rb_intern("backtrace"), 0);
- if (NIL_P(info))
- return Qnil;
- return rb_check_backtrace(info);
-}
-
-static void
-set_backtrace(VALUE info, VALUE bt)
-{
- rb_funcall(info, rb_intern("set_backtrace"), 1, bt);
-}
-
-static void
-error_print(void)
-{
- VALUE errat = Qnil; /* OK */
- VALUE errinfo = GET_THREAD()->errinfo;
- volatile VALUE eclass, e;
- char *einfo;
- long elen;
-
- if (NIL_P(errinfo))
- return;
-
- PUSH_TAG();
- if (EXEC_TAG() == 0) {
- errat = get_backtrace(errinfo);
- }
- else {
- errat = Qnil;
- }
- if (EXEC_TAG())
- goto error;
- if (NIL_P(errat)) {
- const char *file = rb_sourcefile();
- int line = rb_sourceline();
- if (file)
- warn_printf("%s:%d", file, line);
- else
- warn_printf("%d", line);
- }
- else if (RARRAY_LEN(errat) == 0) {
- error_pos();
- }
- else {
- VALUE mesg = RARRAY_PTR(errat)[0];
-
- if (NIL_P(mesg))
- error_pos();
- else {
- warn_print2(RSTRING_PTR(mesg), RSTRING_LEN(mesg));
- }
- }
-
- eclass = CLASS_OF(errinfo);
- if (EXEC_TAG() == 0) {
- e = rb_funcall(errinfo, rb_intern("message"), 0, 0);
- StringValue(e);
- einfo = RSTRING_PTR(e);
- elen = RSTRING_LEN(e);
- }
- else {
- einfo = "";
- elen = 0;
- }
- if (EXEC_TAG())
- goto error;
- if (eclass == rb_eRuntimeError && elen == 0) {
- warn_print(": unhandled exception\n");
- }
- else {
- VALUE epath;
-
- epath = rb_class_name(eclass);
- if (elen == 0) {
- warn_print(": ");
- warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
- warn_print("\n");
- }
- else {
- char *tail = 0;
- long len = elen;
-
- if (RSTRING_PTR(epath)[0] == '#')
- epath = 0;
- if ((tail = memchr(einfo, '\n', elen)) != 0) {
- len = tail - einfo;
- tail++; /* skip newline */
- }
- warn_print(": ");
- warn_print2(einfo, len);
- if (epath) {
- warn_print(" (");
- warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath));
- warn_print(")\n");
- }
- if (tail) {
- warn_print2(tail, elen - len - 1);
- }
- }
- }
-
- if (!NIL_P(errat)) {
- long i;
- long len = RARRAY_LEN(errat);
- VALUE *ptr = RARRAY_PTR(errat);
- int skip = eclass == rb_eSysStackError;
-
-#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
-#define TRACE_HEAD 8
-#define TRACE_TAIL 5
-
- for (i = 1; i < len; i++) {
- if (TYPE(ptr[i]) == T_STRING) {
- warn_printf("\tfrom %s\n", RSTRING_PTR(ptr[i]));
- }
- if (skip && i == TRACE_HEAD && len > TRACE_MAX) {
- warn_printf("\t ... %ld levels...\n",
- len - TRACE_HEAD - TRACE_TAIL);
- i = len - TRACE_TAIL;
- }
- }
- }
- error:
- POP_TAG();
-}
-
-void
-ruby_error_print(void)
-{
- error_print();
-}
-
-void
-rb_print_undef(VALUE klass, ID id, int scope)
-{
- char *v;
-
- switch (scope) {
- default:
- case NOEX_PUBLIC: v = ""; break;
- case NOEX_PRIVATE: v = " private"; break;
- case NOEX_PROTECTED: v = " protected"; break;
- }
- rb_name_error(id, "undefined%s method `%s' for %s `%s'", v,
- rb_id2name(id),
- (TYPE(klass) == T_MODULE) ? "module" : "class",
- rb_class2name(klass));
-}
-
-static int
-sysexit_status(VALUE err)
-{
- VALUE st = rb_iv_get(err, "status");
- return NUM2INT(st);
-}
-
-static int
-error_handle(int ex)
-{
- int status = EXIT_FAILURE;
- rb_thread_t *th = GET_THREAD();
-
- if (thread_set_raised(th))
- return EXIT_FAILURE;
- switch (ex & TAG_MASK) {
- case 0:
- status = EXIT_SUCCESS;
- break;
-
- case TAG_RETURN:
- error_pos();
- warn_print(": unexpected return\n");
- break;
- case TAG_NEXT:
- error_pos();
- warn_print(": unexpected next\n");
- break;
- case TAG_BREAK:
- error_pos();
- warn_print(": unexpected break\n");
- break;
- case TAG_REDO:
- error_pos();
- warn_print(": unexpected redo\n");
- break;
- case TAG_RETRY:
- error_pos();
- warn_print(": retry outside of rescue clause\n");
- break;
- case TAG_THROW:
- /* TODO: fix me */
- error_pos();
- warn_printf(": unexpected throw\n");
- break;
- case TAG_RAISE:
- case TAG_FATAL: {
- VALUE errinfo = GET_THREAD()->errinfo;
- if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
- status = sysexit_status(errinfo);
- }
- else if (rb_obj_is_instance_of(errinfo, rb_eSignal)) {
- /* no message when exiting by signal */
- }
- else {
- error_print();
- }
- break;
- }
- default:
- rb_bug("Unknown longjmp status %d", ex);
- break;
- }
- thread_reset_raised(th);
- return status;
-}
diff --git a/eval_intern.h b/eval_intern.h
deleted file mode 100644
index 884d7c42a0..0000000000
--- a/eval_intern.h
+++ /dev/null
@@ -1,246 +0,0 @@
-
-#ifndef EVAL_INTERN_H_INCLUDED
-#define EVAL_INTERN_H_INCLUDED
-
-#define PASS_PASSED_BLOCK() \
- (GET_THREAD()->passed_block = \
- GC_GUARDED_PTR_REF((rb_block_t *)GET_THREAD()->cfp->lfp[0]))
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "ruby/util.h"
-#include "ruby/signal.h"
-#include "vm_core.h"
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif
-
-#include <stdio.h>
-#include <setjmp.h>
-
-#include "ruby/st.h"
-#include "dln.h"
-
-#ifdef __APPLE__
-#include <crt_externs.h>
-#endif
-
-/* Make alloca work the best possible way. */
-#ifdef __GNUC__
-# ifndef atarist
-# ifndef alloca
-# define alloca __builtin_alloca
-# endif
-# endif /* atarist */
-#else
-# ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
-#pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-void *alloca();
-# endif
-# endif /* AIX */
-# endif /* HAVE_ALLOCA_H */
-#endif /* __GNUC__ */
-
-#ifdef HAVE_STDARG_PROTOTYPES
-#include <stdarg.h>
-#define va_init_list(a,b) va_start(a,b)
-#else
-#include <varargs.h>
-#define va_init_list(a,b) va_start(a)
-#endif
-
-#ifndef HAVE_STRING_H
-char *strrchr(const char *, const char);
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef __BEOS__
-#include <net/socket.h>
-#endif
-
-#ifdef __MACOS__
-#include "macruby_private.h"
-#endif
-
-#ifdef __VMS
-#include "vmsruby_private.h"
-#endif
-
-#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
-
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-
-#if defined(__VMS)
-#pragma nostandard
-#endif
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-/*
- Solaris sys/select.h switches select to select_large_fdset to support larger
- file descriptors if FD_SETSIZE is larger than 1024 on 32bit environment.
- But Ruby doesn't change FD_SETSIZE because fd_set is allocated dynamically.
- So following definition is required to use select_large_fdset.
-*/
-#ifdef HAVE_SELECT_LARGE_FDSET
-#define select(n, r, w, e, t) select_large_fdset(n, r, w, e, t)
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#include <sys/stat.h>
-
-#define SAVE_ROOT_JMPBUF(th, stmt) do \
- if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
- stmt; \
- } \
- else { \
- rb_fiber_start(); \
- } while (0)
-
-#define TH_PUSH_TAG(th) do { \
- rb_thread_t * const _th = th; \
- struct rb_vm_tag _tag; \
- _tag.tag = 0; \
- _tag.prev = _th->tag; \
- _th->tag = &_tag;
-
-#define TH_POP_TAG() \
- _th->tag = _tag.prev; \
-} while (0)
-
-#define TH_POP_TAG2() \
- _th->tag = _tag.prev
-
-#define PUSH_TAG() TH_PUSH_TAG(GET_THREAD())
-#define POP_TAG() TH_POP_TAG()
-
-#define TH_EXEC_TAG() \
- (FLUSH_REGISTER_WINDOWS, ruby_setjmp(_th->tag->buf))
-
-#define EXEC_TAG() \
- TH_EXEC_TAG()
-
-#define TH_JUMP_TAG(th, st) do { \
- ruby_longjmp(th->tag->buf,(st)); \
-} while (0)
-
-#define JUMP_TAG(st) TH_JUMP_TAG(GET_THREAD(), st)
-
-#define TAG_RETURN 0x1
-#define TAG_BREAK 0x2
-#define TAG_NEXT 0x3
-#define TAG_RETRY 0x4
-#define TAG_REDO 0x5
-#define TAG_RAISE 0x6
-#define TAG_THROW 0x7
-#define TAG_FATAL 0x8
-#define TAG_MASK 0xf
-
-#define NEW_THROW_OBJECT(val, pt, st) \
- ((VALUE)NEW_NODE(NODE_LIT, (val), (pt), (st)))
-#define SET_THROWOBJ_CATCH_POINT(obj, val) \
- (RNODE((obj))->u2.value = (val))
-#define SET_THROWOBJ_STATE(obj, val) \
- (RNODE((obj))->u3.value = (val))
-
-#define GET_THROWOBJ_VAL(obj) ((VALUE)RNODE((obj))->u1.value)
-#define GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value)
-#define GET_THROWOBJ_STATE(obj) ((int)RNODE((obj))->u3.value)
-
-#define SCOPE_TEST(f) \
- (ruby_cref()->nd_visi & (f))
-
-#define SCOPE_CHECK(f) \
- (ruby_cref()->nd_visi == (f))
-
-#define SCOPE_SET(f) \
-{ \
- ruby_cref()->nd_visi = (f); \
-}
-
-#define CHECK_STACK_OVERFLOW(cfp, margin) do \
- if (((VALUE *)(cfp)->sp) + (margin) + sizeof(rb_control_frame_t) >= ((VALUE *)cfp)) { \
- rb_exc_raise(sysstack_error); \
- } \
-while (0)
-
-void rb_thread_cleanup(void);
-void rb_thread_wait_other_threads(void);
-
-int thread_set_raised(rb_thread_t *th);
-int thread_reset_raised(rb_thread_t *th);
-
-VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
-VALUE rb_make_exception(int argc, VALUE *argv);
-
-NORETURN(void rb_fiber_start(void));
-
-NORETURN(void rb_raise_jump(VALUE));
-NORETURN(void rb_print_undef(VALUE, ID, int));
-NORETURN(void vm_localjump_error(const char *, VALUE, int));
-NORETURN(void vm_jump_tag_but_local_jump(int, VALUE));
-
-NODE *vm_get_cref(rb_thread_t *th, rb_iseq_t *iseq, rb_control_frame_t *cfp);
-NODE *vm_cref_push(rb_thread_t *th, VALUE, int);
-NODE *vm_set_special_cref(rb_thread_t *th, VALUE *lfp, NODE * cref_stack);
-VALUE vm_make_jump_tag_but_local_jump(int state, VALUE val);
-
-static rb_control_frame_t *
-vm_get_ruby_level_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
-{
- while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {
- if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
- return cfp;
- }
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
- }
- return 0;
-}
-
-static inline NODE *
-ruby_cref()
-{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
- return vm_get_cref(th, cfp->iseq, cfp);
-}
-
-VALUE vm_get_cbase(rb_thread_t *th);
-VALUE rb_obj_is_proc(VALUE);
-void rb_vm_check_redefinition_opt_method(NODE *node);
-VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, rb_block_t *blockptr, VALUE filename);
-void rb_thread_terminate_all(void);
-void rb_vm_set_eval_stack(rb_thread_t *, VALUE iseq);
-VALUE rb_vm_top_self();
-
-#define ruby_cbase() vm_get_cbase(GET_THREAD())
-
-#endif /* EVAL_INTERN_H_INCLUDED */
diff --git a/eval_jump.c b/eval_jump.c
deleted file mode 100644
index 948ac635be..0000000000
--- a/eval_jump.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* -*-c-*- */
-/*
- * from eval.c
- */
-
-#include "eval_intern.h"
-
-NORETURN(static VALUE rb_f_throw _((int, VALUE *)));
-
-/*
- * call-seq:
- * throw(symbol [, obj])
- *
- * Transfers control to the end of the active +catch+ block
- * waiting for _symbol_. Raises +NameError+ if there
- * is no +catch+ block for the symbol. The optional second
- * parameter supplies a return value for the +catch+ block,
- * which otherwise defaults to +nil+. For examples, see
- * <code>Kernel::catch</code>.
- */
-
-static VALUE
-rb_f_throw(int argc, VALUE *argv)
-{
- VALUE tag, value;
- rb_thread_t *th = GET_THREAD();
- struct rb_vm_tag *tt = th->tag;
-
- rb_scan_args(argc, argv, "11", &tag, &value);
- while (tt) {
- if (tt->tag == tag) {
- tt->retval = value;
- break;
- }
- tt = tt->prev;
- }
- if (!tt) {
- VALUE desc = rb_inspect(tag);
- rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc));
- }
- rb_trap_restore_mask();
- th->errinfo = NEW_THROW_OBJECT(tag, 0, TAG_THROW);
-
- JUMP_TAG(TAG_THROW);
-#ifndef __GNUC__
- return Qnil; /* not reached */
-#endif
-}
-
-void
-rb_throw(const char *tag, VALUE val)
-{
- VALUE argv[2];
-
- argv[0] = ID2SYM(rb_intern(tag));
- argv[1] = val;
- rb_f_throw(2, argv);
-}
-
-void
-rb_throw_obj(VALUE tag, VALUE val)
-{
- VALUE argv[2];
-
- argv[0] = tag;
- argv[1] = val;
- rb_f_throw(2, argv);
-}
-
-/*
- * call-seq:
- * catch(symbol) {| | block } > obj
- *
- * +catch+ executes its block. If a +throw+ is
- * executed, Ruby searches up its stack for a +catch+ block
- * with a tag corresponding to the +throw+'s
- * _symbol_. If found, that block is terminated, and
- * +catch+ returns the value given to +throw+. If
- * +throw+ is not called, the block terminates normally, and
- * the value of +catch+ is the value of the last expression
- * evaluated. +catch+ expressions may be nested, and the
- * +throw+ call need not be in lexical scope.
- *
- * def routine(n)
- * puts n
- * throw :done if n <= 0
- * routine(n-1)
- * end
- *
- *
- * catch(:done) { routine(3) }
- *
- * <em>produces:</em>
- *
- * 3
- * 2
- * 1
- * 0
- */
-
-static VALUE
-rb_f_catch(int argc, VALUE *argv)
-{
- VALUE tag;
- int state;
- VALUE val = Qnil; /* OK */
- rb_thread_t *th = GET_THREAD();
-
- rb_scan_args(argc, argv, "01", &tag);
- if (argc == 0) {
- tag = rb_obj_alloc(rb_cObject);
- }
- PUSH_TAG();
-
- th->tag->tag = tag;
-
- if ((state = EXEC_TAG()) == 0) {
- val = rb_yield_0(1, &tag);
- }
- else if (state == TAG_THROW && RNODE(th->errinfo)->u1.value == tag) {
- val = th->tag->retval;
- th->errinfo = Qnil;
- state = 0;
- }
- POP_TAG();
- if (state)
- JUMP_TAG(state);
-
- return val;
-}
-
-static VALUE
-catch_null_i(VALUE dmy)
-{
- return rb_funcall(Qnil, rb_intern("catch"), 0, 0);
-}
-
-static VALUE
-catch_i(VALUE tag)
-{
- return rb_funcall(Qnil, rb_intern("catch"), 1, tag);
-}
-
-VALUE
-rb_catch(const char *tag, VALUE (*func)(), VALUE data)
-{
- if (!tag) {
- return rb_iterate(catch_null_i, 0, func, data);
- }
- return rb_iterate(catch_i, ID2SYM(rb_intern(tag)), func, data);
-}
-
-VALUE
-rb_catch_obj(VALUE tag, VALUE (*func)(), VALUE data)
-{
- return rb_iterate((VALUE (*)_((VALUE)))catch_i, tag, func, data);
-}
-
-
-/* exit */
-
-void
-rb_call_end_proc(VALUE data)
-{
- rb_proc_call(data, rb_ary_new());
-}
-
-/*
- * call-seq:
- * at_exit { block } -> proc
- *
- * Converts _block_ to a +Proc+ object (and therefore
- * binds it at the point of call) and registers it for execution when
- * the program exits. If multiple handlers are registered, they are
- * executed in reverse order of registration.
- *
- * def do_at_exit(str1)
- * at_exit { print str1 }
- * end
- * at_exit { puts "cruel world" }
- * do_at_exit("goodbye ")
- * exit
- *
- * <em>produces:</em>
- *
- * goodbye cruel world
- */
-
-static VALUE
-rb_f_at_exit(void)
-{
- VALUE proc;
-
- if (!rb_block_given_p()) {
- rb_raise(rb_eArgError, "called without a block");
- }
- proc = rb_block_proc();
- rb_set_end_proc(rb_call_end_proc, proc);
- return proc;
-}
-
-struct end_proc_data {
- void (*func) ();
- VALUE data;
- int safe;
- struct end_proc_data *next;
-};
-
-static struct end_proc_data *end_procs, *ephemeral_end_procs, *tmp_end_procs;
-
-void
-rb_set_end_proc(void (*func)(VALUE), VALUE data)
-{
- struct end_proc_data *link = ALLOC(struct end_proc_data);
- struct end_proc_data **list;
- rb_thread_t *th = GET_THREAD();
-
- if (th->top_wrapper) {
- list = &ephemeral_end_procs;
- }
- else {
- list = &end_procs;
- }
- link->next = *list;
- link->func = func;
- link->data = data;
- link->safe = rb_safe_level();
- *list = link;
-}
-
-void
-rb_mark_end_proc(void)
-{
- struct end_proc_data *link;
-
- link = end_procs;
- while (link) {
- rb_gc_mark(link->data);
- link = link->next;
- }
- link = ephemeral_end_procs;
- while (link) {
- rb_gc_mark(link->data);
- link = link->next;
- }
- link = tmp_end_procs;
- while (link) {
- rb_gc_mark(link->data);
- link = link->next;
- }
-}
-
-void
-rb_exec_end_proc(void)
-{
- struct end_proc_data *link, *tmp;
- int status;
- volatile int safe = rb_safe_level();
-
- while (ephemeral_end_procs) {
- tmp_end_procs = link = ephemeral_end_procs;
- ephemeral_end_procs = 0;
- while (link) {
- PUSH_TAG();
- if ((status = EXEC_TAG()) == 0) {
- rb_set_safe_level_force(link->safe);
- (*link->func) (link->data);
- }
- POP_TAG();
- if (status) {
- error_handle(status);
- }
- tmp = link;
- tmp_end_procs = link = link->next;
- free(tmp);
- }
- }
- while (end_procs) {
- tmp_end_procs = link = end_procs;
- end_procs = 0;
- while (link) {
- PUSH_TAG();
- if ((status = EXEC_TAG()) == 0) {
- rb_set_safe_level_force(link->safe);
- (*link->func) (link->data);
- }
- POP_TAG();
- if (status) {
- error_handle(status);
- }
- tmp = link;
- tmp_end_procs = link = link->next;
- free(tmp);
- }
- }
- rb_set_safe_level_force(safe);
-}
-
-void
-Init_jump(void)
-{
- rb_define_global_function("catch", rb_f_catch, -1);
- rb_define_global_function("throw", rb_f_throw, -1);
- rb_define_global_function("at_exit", rb_f_at_exit, 0);
-}
diff --git a/eval_method.c b/eval_method.c
deleted file mode 100644
index 34a65b7fa0..0000000000
--- a/eval_method.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/* -*-c-*- */
-/*
- * This file is included by eval.c
- */
-
-#define CACHE_SIZE 0x800
-#define CACHE_MASK 0x7ff
-#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
-
-struct cache_entry { /* method hash table. */
- ID mid; /* method's id */
- ID mid0; /* method's original id */
- VALUE klass; /* receiver's class */
- NODE *method;
-};
-
-static struct cache_entry cache[CACHE_SIZE];
-static int ruby_running = 0;
-
-void
-rb_clear_cache(void)
-{
- struct cache_entry *ent, *end;
-
- rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- ent->mid = 0;
- ent++;
- }
-}
-
-static void
-rb_clear_cache_for_undef(VALUE klass, ID id)
-{
- struct cache_entry *ent, *end;
-
- rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- if (ent->method && ent->method->nd_clss == klass && ent->mid == id) {
- ent->mid = 0;
- }
- ent++;
- }
-}
-
-static void
-rb_clear_cache_by_id(ID id)
-{
- struct cache_entry *ent, *end;
-
- rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- if (ent->mid == id) {
- ent->mid = 0;
- }
- ent++;
- }
-}
-
-void
-rb_clear_cache_by_class(VALUE klass)
-{
- struct cache_entry *ent, *end;
-
- rb_vm_change_state();
-
- if (!ruby_running)
- return;
- ent = cache;
- end = ent + CACHE_SIZE;
- while (ent < end) {
- if ((ent->klass == klass) ||
- (ent->method && ent->method->nd_clss == klass)) {
- ent->mid = 0;
- }
- ent++;
- }
-}
-
-void
-rb_add_method(VALUE klass, ID mid, NODE * node, int noex)
-{
- NODE *body;
-
- if (NIL_P(klass)) {
- klass = rb_cObject;
- }
- if (rb_safe_level() >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
- rb_raise(rb_eSecurityError, "Insecure: can't define method");
- }
- if (!FL_TEST(klass, FL_SINGLETON) &&
- node && nd_type(node) != NODE_ZSUPER &&
- (mid == rb_intern("initialize") || mid == rb_intern("initialize_copy"))) {
- noex = NOEX_PRIVATE | noex;
- }
- else if (FL_TEST(klass, FL_SINGLETON) && node
- && nd_type(node) == NODE_CFUNC && mid == rb_intern("allocate")) {
- rb_warn
- ("defining %s.allocate is deprecated; use rb_define_alloc_func()",
- rb_class2name(rb_iv_get(klass, "__attached__")));
- mid = ID_ALLOCATOR;
- }
- if (OBJ_FROZEN(klass)) {
- rb_error_frozen("class/module");
- }
- rb_clear_cache_by_id(mid);
-
- /*
- * NODE_METHOD (NEW_METHOD(body, klass, vis)):
- * nd_body : method body // (2) // mark
- * nd_clss : klass // (1) // mark
- * nd_noex : visibility // (3)
- *
- * NODE_FBODY (NEW_FBODY(method, alias)):
- * nd_body : method (NODE_METHOD) // (2) // mark
- * nd_oid : original id // (1)
- * nd_cnt : alias count // (3)
- */
- if (node) {
- body = NEW_FBODY(NEW_METHOD(node, klass, NOEX_WITH_SAFE(noex)), 0);
- }
- else {
- body = 0;
- }
-
- {
- /* check re-definition */
- st_data_t data;
- NODE *old_node;
-
- if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) {
- old_node = (NODE *)data;
- if (old_node) {
- if (nd_type(old_node->nd_body->nd_body) == NODE_CFUNC) {
- rb_vm_check_redefinition_opt_method(old_node);
- }
- if (RTEST(ruby_verbose) && node && old_node->nd_cnt == 0 && old_node->nd_body) {
- rb_warning("method redefined; discarding old %s", rb_id2name(mid));
- }
- }
- if (klass == rb_cObject && node && node->nd_mid == init) {
- rb_warn("redefining Object#initialize may cause infinite loop");
- }
- }
-
- if (mid == object_id || mid == __send__) {
- if (node && nd_type(node) == RUBY_VM_METHOD_NODE) {
- rb_warn("redefining `%s' may cause serious problem",
- rb_id2name(mid));
- }
- }
- }
-
- st_insert(RCLASS_M_TBL(klass), mid, (st_data_t) body);
-
- if (node && mid != ID_ALLOCATOR && ruby_running) {
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_funcall(rb_iv_get(klass, "__attached__"), singleton_added, 1,
- ID2SYM(mid));
- }
- else {
- rb_funcall(klass, added, 1, ID2SYM(mid));
- }
- }
-}
-
-void
-rb_define_alloc_func(VALUE klass, VALUE (*func) _((VALUE)))
-{
- Check_Type(klass, T_CLASS);
- rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0),
- NOEX_PRIVATE);
-}
-
-void
-rb_undef_alloc_func(VALUE klass)
-{
- Check_Type(klass, T_CLASS);
- rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
-}
-
-rb_alloc_func_t
-rb_get_alloc_func(VALUE klass)
-{
- NODE *n;
- Check_Type(klass, T_CLASS);
- n = rb_method_node(CLASS_OF(klass), ID_ALLOCATOR);
- if (!n) return 0;
- if (nd_type(n) != NODE_METHOD) return 0;
- n = n->nd_body;
- if (nd_type(n) != NODE_CFUNC) return 0;
- return (rb_alloc_func_t)n->nd_cfnc;
-}
-
-static NODE *
-search_method(VALUE klass, ID id, VALUE *klassp)
-{
- st_data_t body;
-
- if (!klass) {
- return 0;
- }
-
- while (!st_lookup(RCLASS_M_TBL(klass), id, &body)) {
- klass = RCLASS_SUPER(klass);
- if (!klass)
- return 0;
- }
-
- if (klassp) {
- *klassp = klass;
- }
-
- return (NODE *)body;
-}
-
-/*
- * search method body (NODE_METHOD)
- * with : klass and id
- * without : method cache
- *
- * if you need method node with method cache, use
- * rb_method_node()
- */
-NODE *
-rb_get_method_body(VALUE klass, ID id, ID *idp)
-{
- NODE *volatile fbody, *body;
- NODE *method;
-
- if ((fbody = search_method(klass, id, 0)) == 0 || !fbody->nd_body) {
- /* store empty info in cache */
- struct cache_entry *ent;
- ent = cache + EXPR1(klass, id);
- ent->klass = klass;
- ent->mid = ent->mid0 = id;
- ent->method = 0;
- return 0;
- }
-
- method = fbody->nd_body;
-
- if (ruby_running) {
- /* store in cache */
- struct cache_entry *ent;
- ent = cache + EXPR1(klass, id);
- ent->klass = klass;
- ent->mid = id;
- ent->mid0 = fbody->nd_oid;
- ent->method = body = method;
- }
- else {
- body = method;
- }
-
- if (idp) {
- *idp = fbody->nd_oid;
- }
-
- return body;
-}
-
-NODE *
-rb_method_node(VALUE klass, ID id)
-{
- struct cache_entry *ent;
-
- ent = cache + EXPR1(klass, id);
- if (ent->mid == id && ent->klass == klass && ent->method) {
- return ent->method;
- }
-
- return rb_get_method_body(klass, id, 0);
-}
-
-static void
-remove_method(VALUE klass, ID mid)
-{
- st_data_t data;
- NODE *body = 0;
-
- if (klass == rb_cObject) {
- rb_secure(4);
- }
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
- rb_raise(rb_eSecurityError, "Insecure: can't remove method");
- }
- if (OBJ_FROZEN(klass))
- rb_error_frozen("class/module");
- if (mid == object_id || mid == __send__ || mid == init) {
- rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
- }
- if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) {
- body = (NODE *)data;
- if (!body || !body->nd_body) body = 0;
- else {
- st_delete(RCLASS_M_TBL(klass), &mid, &data);
- }
- }
- if (!body) {
- rb_name_error(mid, "method `%s' not defined in %s",
- rb_id2name(mid), rb_class2name(klass));
- }
-
- if (nd_type(body->nd_body->nd_body) == NODE_CFUNC) {
- rb_vm_check_redefinition_opt_method(body);
- }
-
- rb_clear_cache_for_undef(klass, mid);
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1,
- ID2SYM(mid));
- }
- else {
- rb_funcall(klass, removed, 1, ID2SYM(mid));
- }
-}
-
-void
-rb_remove_method(VALUE klass, const char *name)
-{
- remove_method(klass, rb_intern(name));
-}
-
-/*
- * call-seq:
- * remove_method(symbol) => self
- *
- * Removes the method identified by _symbol_ from the current
- * class. For an example, see <code>Module.undef_method</code>.
- */
-
-static VALUE
-rb_mod_remove_method(int argc, VALUE *argv, VALUE mod)
-{
- int i;
-
- for (i = 0; i < argc; i++) {
- remove_method(mod, rb_to_id(argv[i]));
- }
- return mod;
-}
-
-#undef rb_disable_super
-#undef rb_enable_super
-
-void
-rb_disable_super(VALUE klass, const char *name)
-{
- /* obsolete - no use */
-}
-
-void
-rb_enable_super(VALUE klass, const char *name)
-{
- rb_warning("rb_enable_super() is obsolete");
-}
-
-static void
-rb_export_method(VALUE klass, ID name, ID noex)
-{
- NODE *fbody;
- VALUE origin;
-
- if (klass == rb_cObject) {
- rb_secure(4);
- }
- fbody = search_method(klass, name, &origin);
- if (!fbody && TYPE(klass) == T_MODULE) {
- fbody = search_method(rb_cObject, name, &origin);
- }
- if (!fbody || !fbody->nd_body) {
- rb_print_undef(klass, name, 0);
- }
- if (fbody->nd_body->nd_noex != noex) {
- if (klass == origin) {
- fbody->nd_body->nd_noex = noex;
- }
- else {
- rb_add_method(klass, name, NEW_ZSUPER(), noex);
- }
- }
-}
-
-int
-rb_method_boundp(VALUE klass, ID id, int ex)
-{
- NODE *method;
-
- if ((method = rb_method_node(klass, id)) != 0) {
- if (ex && (method->nd_noex & NOEX_PRIVATE)) {
- return Qfalse;
- }
- return Qtrue;
- }
- return Qfalse;
-}
-
-void
-rb_attr(VALUE klass, ID id, int read, int write, int ex)
-{
- const char *name;
- ID attriv;
- int noex;
-
- if (!ex) {
- noex = NOEX_PUBLIC;
- }
- else {
- if (SCOPE_TEST(NOEX_PRIVATE)) {
- noex = NOEX_PRIVATE;
- rb_warning((SCOPE_CHECK(NOEX_MODFUNC)) ?
- "attribute accessor as module_function" :
- "private attribute?");
- }
- else if (SCOPE_TEST(NOEX_PROTECTED)) {
- noex = NOEX_PROTECTED;
- }
- else {
- noex = NOEX_PUBLIC;
- }
- }
-
- if (!rb_is_local_id(id) && !rb_is_const_id(id)) {
- rb_name_error(id, "invalid attribute name `%s'", rb_id2name(id));
- }
- name = rb_id2name(id);
- if (!name) {
- rb_raise(rb_eArgError, "argument needs to be symbol or string");
- }
- attriv = rb_intern_str(rb_sprintf("@%s", name));
- if (read) {
- rb_add_method(klass, id, NEW_IVAR(attriv), noex);
- }
- if (write) {
- rb_add_method(klass, rb_id_attrset(id), NEW_ATTRSET(attriv), noex);
- }
-}
-
-void
-rb_undef(VALUE klass, ID id)
-{
- VALUE origin;
- NODE *body;
-
- if (ruby_cbase() == rb_cObject && klass == rb_cObject) {
- rb_secure(4);
- }
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
- rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'",
- rb_id2name(id));
- }
- rb_frozen_class_p(klass);
- if (id == object_id || id == __send__ || id == init) {
- rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
- }
- body = search_method(klass, id, &origin);
- if (!body || !body->nd_body) {
- char *s0 = " class";
- VALUE c = klass;
-
- if (FL_TEST(c, FL_SINGLETON)) {
- VALUE obj = rb_iv_get(klass, "__attached__");
-
- switch (TYPE(obj)) {
- case T_MODULE:
- case T_CLASS:
- c = obj;
- s0 = "";
- }
- }
- else if (TYPE(c) == T_MODULE) {
- s0 = " module";
- }
- rb_name_error(id, "undefined method `%s' for%s `%s'",
- rb_id2name(id), s0, rb_class2name(c));
- }
-
- rb_add_method(klass, id, 0, NOEX_PUBLIC);
-
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_funcall(rb_iv_get(klass, "__attached__"),
- singleton_undefined, 1, ID2SYM(id));
- }
- else {
- rb_funcall(klass, undefined, 1, ID2SYM(id));
- }
-}
-
-/*
- * call-seq:
- * undef_method(symbol) => self
- *
- * Prevents the current class from responding to calls to the named
- * method. Contrast this with <code>remove_method</code>, which deletes
- * the method from the particular class; Ruby will still search
- * superclasses and mixed-in modules for a possible receiver.
- *
- * class Parent
- * def hello
- * puts "In parent"
- * end
- * end
- * class Child < Parent
- * def hello
- * puts "In child"
- * end
- * end
- *
- *
- * c = Child.new
- * c.hello
- *
- *
- * class Child
- * remove_method :hello # remove from child, still in parent
- * end
- * c.hello
- *
- *
- * class Child
- * undef_method :hello # prevent any calls to 'hello'
- * end
- * c.hello
- *
- * <em>produces:</em>
- *
- * In child
- * In parent
- * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
- */
-
-static VALUE
-rb_mod_undef_method(int argc, VALUE *argv, VALUE mod)
-{
- int i;
- for (i = 0; i < argc; i++) {
- rb_undef(mod, rb_to_id(argv[i]));
- }
- return mod;
-}
-
-void
-rb_alias(VALUE klass, ID name, ID def)
-{
- NODE *orig_fbody, *node;
- VALUE singleton = 0;
- st_data_t data;
-
- rb_frozen_class_p(klass);
- if (klass == rb_cObject) {
- rb_secure(4);
- }
- orig_fbody = search_method(klass, def, 0);
- if (!orig_fbody || !orig_fbody->nd_body) {
- if (TYPE(klass) == T_MODULE) {
- orig_fbody = search_method(rb_cObject, def, 0);
- }
- }
- if (!orig_fbody || !orig_fbody->nd_body) {
- rb_print_undef(klass, def, 0);
- }
- if (FL_TEST(klass, FL_SINGLETON)) {
- singleton = rb_iv_get(klass, "__attached__");
- }
-
- orig_fbody->nd_cnt++;
-
- if (st_lookup(RCLASS_M_TBL(klass), name, &data)) {
- node = (NODE *)data;
- if (node) {
- if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) {
- rb_warning("discarding old %s", rb_id2name(name));
- }
- if (nd_type(node->nd_body->nd_body) == NODE_CFUNC) {
- rb_vm_check_redefinition_opt_method(node);
- }
- }
- }
-
- st_insert(RCLASS_M_TBL(klass), name,
- (st_data_t) NEW_FBODY(
- NEW_METHOD(orig_fbody->nd_body->nd_body,
- orig_fbody->nd_body->nd_clss,
- NOEX_WITH_SAFE(orig_fbody->nd_body->nd_noex)), def));
-
- rb_clear_cache_by_id(name);
-
- if (!ruby_running) return;
-
- if (singleton) {
- rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
- }
- else {
- rb_funcall(klass, added, 1, ID2SYM(name));
- }
-}
-
-/*
- * call-seq:
- * alias_method(new_name, old_name) => self
- *
- * Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
- * be used to retain access to methods that are overridden.
- *
- * module Mod
- * alias_method :orig_exit, :exit
- * def exit(code=0)
- * puts "Exiting with code #{code}"
- * orig_exit(code)
- * end
- * end
- * include Mod
- * exit(99)
- *
- * <em>produces:</em>
- *
- * Exiting with code 99
- */
-
-static VALUE
-rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname)
-{
- rb_alias(mod, rb_to_id(newname), rb_to_id(oldname));
- return mod;
-}
-
-static void
-Init_eval_method(void)
-{
- rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1);
- rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1);
- rb_define_private_method(rb_cModule, "alias_method", rb_mod_alias_method, 2);
-}
diff --git a/eval_safe.c b/eval_safe.c
deleted file mode 100644
index 7d0a077880..0000000000
--- a/eval_safe.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*-c-*- */
-/*
- * This file is included by eval.c
- */
-
-/* safe-level:
- 0 - strings from streams/environment/ARGV are tainted (default)
- 1 - no dangerous operation by tainted value
- 2 - process/file operations prohibited
- 3 - all generated objects are tainted
- 4 - no global (non-tainted) variable modification/no direct output
-*/
-
-#define SAFE_LEVEL_MAX 4
-
-/* $SAFE accessor */
-
-int
-rb_safe_level(void)
-{
- return GET_THREAD()->safe_level;
-}
-
-void
-rb_set_safe_level_force(int safe)
-{
- GET_THREAD()->safe_level = safe;
-}
-
-void
-rb_set_safe_level(int level)
-{
- rb_thread_t *th = GET_THREAD();
-
- if (level > th->safe_level) {
- if (level > SAFE_LEVEL_MAX) {
- level = SAFE_LEVEL_MAX;
- }
- th->safe_level = level;
- }
-}
-
-static VALUE
-safe_getter(void)
-{
- return INT2NUM(rb_safe_level());
-}
-
-static void
-safe_setter(VALUE val)
-{
- int level = NUM2INT(val);
- rb_thread_t *th = GET_THREAD();
-
- if (level < th->safe_level) {
- rb_raise(rb_eSecurityError,
- "tried to downgrade safe level from %d to %d",
- th->safe_level, level);
- }
- if (level > SAFE_LEVEL_MAX) {
- level = SAFE_LEVEL_MAX;
- }
- th->safe_level = level;
-}
-
-void
-rb_secure(int level)
-{
- if (level <= rb_safe_level()) {
- if (rb_frame_callee()) {
- rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d",
- rb_id2name(rb_frame_callee()), rb_safe_level());
- }
- else {
- rb_raise(rb_eSecurityError, "Insecure operation at level %d",
- rb_safe_level());
- }
- }
-}
-
-void
-rb_secure_update(VALUE obj)
-{
- if (!OBJ_TAINTED(obj))
- rb_secure(4);
-}
-
-void
-rb_check_safe_obj(VALUE x)
-{
- if (rb_safe_level() > 0 && OBJ_TAINTED(x)) {
- if (rb_frame_callee()) {
- rb_raise(rb_eSecurityError, "Insecure operation - %s",
- rb_id2name(rb_frame_callee()));
- }
- else {
- rb_raise(rb_eSecurityError, "Insecure operation: -r");
- }
- }
- rb_secure(4);
-}
-
-void
-rb_check_safe_str(VALUE x)
-{
- rb_check_safe_obj(x);
- if (TYPE(x) != T_STRING) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
- rb_obj_classname(x));
- }
-}
diff --git a/ext/.document b/ext/.document
index e9f791facc..ba8182593e 100644
--- a/ext/.document
+++ b/ext/.document
@@ -1,11 +1,7 @@
# Add files to this as they become documented
-bigdecimal/bigdecimal.c
-digest/digest.c
-etc/etc.c
-fcntl/fcntl.c
+enumerator/enumerator.c
iconv/iconv.c
-io/wait/wait.c
nkf/lib/kconv.rb
nkf/nkf.c
socket/socket.c
diff --git a/ext/Setup b/ext/Setup
index b0f29b9f7b..d0d6317a5e 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -10,23 +10,25 @@
#digest/sha1
#digest/sha2
#dl
+#enumerator
#etc
#fcntl
#gdbm
#iconv
#io/wait
#nkf
-#openssl
#pty
+#openssl
#racc/cparse
#readline
-#ripper
#sdbm
#socket
#stringio
#strscan
#syck
#syslog
+#tcltklib
+#thread
#tk
#win32ole
#zlib
diff --git a/ext/Setup.atheos b/ext/Setup.atheos
index 6e0b8ae5a6..6bda3a4cfb 100644
--- a/ext/Setup.atheos
+++ b/ext/Setup.atheos
@@ -17,17 +17,18 @@ gdbm
iconv
io/wait
nkf
-#openssl
pty
+#openssl
racc/parse
readline
-ripper
sdbm
socket
stringio
strscan
syck
syslog
+#tcltklib
+thread
#tk
#win32ole
zlib
diff --git a/ext/Setup.dj b/ext/Setup.dj
index 5276b125a1..4f94788886 100644
--- a/ext/Setup.dj
+++ b/ext/Setup.dj
@@ -17,17 +17,18 @@ gdbm
#iconv
#io/wait
nkf
-#openssl
#pty
+#openssl
racc/cparse
readline
-ripper
sdbm
#socket
stringio
strscan
syck
#syslog
+#tcltklib
+thread
#tk
#win32ole
zlib
diff --git a/ext/Setup.emx b/ext/Setup.emx
index fade917e92..afc5923577 100644
--- a/ext/Setup.emx
+++ b/ext/Setup.emx
@@ -17,17 +17,18 @@ fcntl
#iconv
#io/wait
nkf
-#openssl
#pty
+#openssl
racc/cparse
#readline
-#ripper
#sdbm
socket
stringio
strscan
#syck
#syslog
+#tcltklib
+thread
#tk
#win32ole
#zlib
diff --git a/ext/Setup.nt b/ext/Setup.nt
index c8574ba70a..9f8abf9b8d 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -17,17 +17,18 @@ fcntl
#iconv
#io/wait
nkf
-#openssl
#pty
+#openssl
racc/cparse
#readline
-#ripper
sdbm
socket
stringio
strscan
syck
#syslog
+#tcltklib
+thread
#tk
win32ole
#zlib
diff --git a/ext/Setup.x68 b/ext/Setup.x68
index 03f5d2d50d..0966e737e9 100644
--- a/ext/Setup.x68
+++ b/ext/Setup.x68
@@ -17,17 +17,18 @@ fcntl
#iconv
#io/wait
nkf
-#openssl
#pty
+#openssl
racc/cparse
#readline
-#ripper
#sdbm
#socket
stringio
strscan
#syck
#syslog
+#tcltklib
+thread
#tk
#win32ole
#zlib
diff --git a/ext/Win32API/.cvsignore b/ext/Win32API/.cvsignore
new file mode 100644
index 0000000000..90c83ed9b1
--- /dev/null
+++ b/ext/Win32API/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+*.log
+*.def
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
new file mode 100644
index 0000000000..a4fd0396f0
--- /dev/null
+++ b/ext/Win32API/Win32API.c
@@ -0,0 +1,215 @@
+/*
+ Win32API - Ruby Win32 API Import Facility
+*/
+
+#if !defined _MSC_VER && !defined _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <stdio.h>
+#endif
+
+#define _T_VOID 0
+#define _T_NUMBER 1
+#define _T_POINTER 2
+#define _T_INTEGER 3
+
+#include "ruby.h"
+
+typedef struct {
+ HANDLE dll;
+ HANDLE proc;
+ VALUE dllname;
+ VALUE import;
+ VALUE export;
+} Win32API;
+
+static void
+Win32API_FreeLibrary(hdll)
+ HINSTANCE hdll;
+{
+ FreeLibrary(hdll);
+}
+
+static VALUE
+Win32API_initialize(self, dllname, proc, import, export)
+ VALUE self;
+ VALUE dllname;
+ VALUE proc;
+ VALUE import;
+ VALUE export;
+{
+ HANDLE hproc;
+ HINSTANCE hdll;
+ VALUE str;
+ VALUE a_import;
+ VALUE *ptr;
+ char *s;
+ int i;
+ int len;
+ int ex = _T_VOID;
+
+ SafeStringValue(dllname);
+ SafeStringValue(proc);
+ hdll = LoadLibrary(RSTRING(dllname)->ptr);
+ if (!hdll)
+ rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr);
+ rb_iv_set(self, "__hdll__", Data_Wrap_Struct(rb_cData, 0, Win32API_FreeLibrary, (void*)hdll));
+ hproc = (HANDLE)GetProcAddress(hdll, RSTRING(proc)->ptr);
+ if (!hproc) {
+ str = rb_str_new3(proc);
+ str = rb_str_cat(str, "A", 1);
+ hproc = (HANDLE)GetProcAddress(hdll, RSTRING(str)->ptr);
+ if (!hproc)
+ rb_raise(rb_eRuntimeError, "GetProcAddress: %s or %s\n",
+ RSTRING(proc)->ptr, RSTRING(str)->ptr);
+ }
+ rb_iv_set(self, "__dll__", UINT2NUM((unsigned long)hdll));
+ rb_iv_set(self, "__dllname__", dllname);
+ rb_iv_set(self, "__proc__", UINT2NUM((unsigned long)hproc));
+
+ a_import = rb_ary_new();
+ switch (TYPE(import)) {
+ case T_NIL:
+ break;
+ case T_ARRAY:
+ ptr = RARRAY(import)->ptr;
+ for (i = 0, len = RARRAY(import)->len; i < len; i++) {
+ SafeStringValue(ptr[i]);
+ switch (*(char *)RSTRING(ptr[i])->ptr) {
+ case 'N': case 'n': case 'L': case 'l':
+ rb_ary_push(a_import, INT2FIX(_T_NUMBER));
+ break;
+ case 'P': case 'p':
+ rb_ary_push(a_import, INT2FIX(_T_POINTER));
+ break;
+ case 'I': case 'i':
+ rb_ary_push(a_import, INT2FIX(_T_INTEGER));
+ break;
+ }
+ }
+ break;
+ default:
+ SafeStringValue(import);
+ s = RSTRING(import)->ptr;
+ for (i = 0, len = RSTRING(import)->len; i < len; i++) {
+ switch (*s++) {
+ case 'N': case 'n': case 'L': case 'l':
+ rb_ary_push(a_import, INT2FIX(_T_NUMBER));
+ break;
+ case 'P': case 'p':
+ rb_ary_push(a_import, INT2FIX(_T_POINTER));
+ break;
+ case 'I': case 'i':
+ rb_ary_push(a_import, INT2FIX(_T_INTEGER));
+ break;
+ }
+ }
+ break;
+ }
+
+ if (16 < RARRAY(a_import)->len) {
+ rb_raise(rb_eRuntimeError, "too many parameters: %ld\n", RARRAY(a_import)->len);
+ }
+
+ rb_iv_set(self, "__import__", a_import);
+
+ if (NIL_P(export)) {
+ ex = _T_VOID;
+ } else {
+ SafeStringValue(export);
+ switch (*RSTRING(export)->ptr) {
+ case 'V': case 'v':
+ ex = _T_VOID;
+ break;
+ case 'N': case 'n': case 'L': case 'l':
+ ex = _T_NUMBER;
+ break;
+ case 'P': case 'p':
+ ex = _T_POINTER;
+ break;
+ case 'I': case 'i':
+ ex = _T_INTEGER;
+ break;
+ }
+ }
+ rb_iv_set(self, "__export__", INT2FIX(ex));
+
+ return Qnil;
+}
+
+#ifdef _MSC_VER
+#pragma optimize("g", off)
+#endif
+static VALUE
+Win32API_Call(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE args;
+ unsigned long ret;
+ int i;
+ struct {
+ unsigned long params[16];
+ } param;
+#define params param.params
+
+ VALUE obj_proc = rb_iv_get(obj, "__proc__");
+ VALUE obj_import = rb_iv_get(obj, "__import__");
+ VALUE obj_export = rb_iv_get(obj, "__export__");
+ FARPROC ApiFunction = (FARPROC)NUM2ULONG(obj_proc);
+ int items = rb_scan_args(argc, argv, "0*", &args);
+ int nimport = RARRAY(obj_import)->len;
+
+
+ if (items != nimport)
+ rb_raise(rb_eRuntimeError, "wrong number of parameters: expected %d, got %d",
+ nimport, items);
+
+ for (i = 0; i < nimport; i++) {
+ unsigned long lParam = 0;
+ switch (FIX2INT(rb_ary_entry(obj_import, i))) {
+ VALUE str;
+ case _T_NUMBER:
+ case _T_INTEGER:
+ default:
+ lParam = NUM2ULONG(rb_ary_entry(args, i));
+ break;
+ case _T_POINTER:
+ str = rb_ary_entry(args, i);
+ if (NIL_P(str)) {
+ lParam = 0;
+ } else if (FIXNUM_P(str)) {
+ lParam = NUM2ULONG(str);
+ } else {
+ StringValue(str);
+ rb_str_modify(str);
+ lParam = (unsigned long)StringValuePtr(str);
+ }
+ break;
+ }
+ params[i] = lParam;
+ }
+
+ ret = ApiFunction(param);
+
+ switch (FIX2INT(obj_export)) {
+ case _T_NUMBER:
+ case _T_INTEGER:
+ return INT2NUM(ret);
+ case _T_POINTER:
+ return rb_str_new2((char *)ret);
+ case _T_VOID:
+ default:
+ return INT2NUM(0);
+ }
+}
+
+void
+Init_Win32API()
+{
+ VALUE cWin32API = rb_define_class("Win32API", rb_cObject);
+ rb_define_method(cWin32API, "initialize", Win32API_initialize, 4);
+ rb_define_method(cWin32API, "call", Win32API_Call, -1);
+ rb_define_alias(cWin32API, "Call", "call");
+}
diff --git a/ext/Win32API/depend b/ext/Win32API/depend
new file mode 100644
index 0000000000..b224bb66c9
--- /dev/null
+++ b/ext/Win32API/depend
@@ -0,0 +1 @@
+Win32API.o : Win32API.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
diff --git a/ext/Win32API/extconf.rb b/ext/Win32API/extconf.rb
new file mode 100644
index 0000000000..865788556f
--- /dev/null
+++ b/ext/Win32API/extconf.rb
@@ -0,0 +1,6 @@
+require 'mkmf'
+
+dir_config("win32")
+if have_header("windows.h") and have_library("kernel32")
+ create_makefile("Win32API")
+end
diff --git a/ext/Win32API/getch.rb b/ext/Win32API/getch.rb
new file mode 100644
index 0000000000..c015bbe9bc
--- /dev/null
+++ b/ext/Win32API/getch.rb
@@ -0,0 +1,5 @@
+require 'Win32API'
+
+getch = Win32API.new("crtdll", "_getch", [], 'L')
+
+puts getch.Call.chr
diff --git a/ext/Win32API/lib/win32/registry.rb b/ext/Win32API/lib/win32/registry.rb
new file mode 100644
index 0000000000..9a2f3827b7
--- /dev/null
+++ b/ext/Win32API/lib/win32/registry.rb
@@ -0,0 +1,831 @@
+=begin
+= Win32 Registry I/F
+win32/registry is registry accessor library for Win32 platform.
+It uses Win32API to call Win32 Registry APIs.
+
+== example
+ Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
+ value = reg['foo'] # read a value
+ value = reg['foo', Win32::Registry::REG_SZ] # read a value with type
+ type, value = reg.read('foo') # read a value
+ reg['foo'] = 'bar' # write a value
+ reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type
+ reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
+
+ reg.each_value { |name, type, data| ... } # Enumerate values
+ reg.each_key { |key, wtime| ... } # Enumerate subkeys
+
+ reg.delete_value(name) # Delete a value
+ reg.delete_key(name) # Delete a subkey
+ reg.delete_key(name, true) # Delete a subkey recursively
+ end
+
+= Reference
+
+== Win32::Registry class
+
+=== including modules
+
+* Enumerable
+* Registry::Constants
+
+=== class methods
+--- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+--- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... }
+ Open the registry key ((|subkey|)) under ((|key|)).
+ ((|key|)) is Win32::Registry object of parent key.
+ You can use predefined key HKEY_* (see ((<constants>)))
+
+ ((|desired|)) and ((|opt|)) is access mask and key option.
+ For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp>)).
+
+ If block is given, the key is closed automatically.
+
+--- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+--- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... }
+ Create or open the registry key ((|subkey|)) under ((|key|)).
+ You can use predefined key HKEY_* (see ((<constants>)))
+
+ If subkey is already exists, key is opened and Registry#((<created?>))
+ method will return false.
+
+ If block is given, the key is closed automatically.
+
+--- Registry.expand_environ(str)
+ Replace (({%\w+%})) into the environment value of ((|str|)).
+ This method is used for REG_EXPAND_SZ.
+
+ For detail, see ((<ExpandEnvironmentStrings|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp>)) Win32 API.
+
+--- Registry.type2name(type)
+ Convert registry type value to readable string.
+
+--- Registry.wtime2time(wtime)
+ Convert 64-bit FILETIME integer into Time object.
+
+--- Registry.time2wtime(time)
+ Convert Time object or Integer object into 64-bit FILETIME.
+
+=== instance methods
+--- open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+ Same as (({Win32::((<Registry.open>))(self, subkey, desired, opt)}))
+
+--- create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+ Same as (({Win32::((<Registry.create>))(self, subkey, desired, opt)}))
+
+--- close
+ Close key.
+
+ After closed, most method raises error.
+
+--- read(name, *rtype)
+ Read a registry value named ((|name|)) and return array of
+ [ ((|type|)), ((|data|)) ].
+ When name is nil, the `default' value is read.
+
+ ((|type|)) is value type. (see ((<Win32::Registry::Constants module>)))
+ ((|data|)) is value data, its class is:
+ :REG_SZ, REG_EXPAND_SZ
+ String
+ :REG_MULTI_SZ
+ Array of String
+ :REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD
+ Integer
+ :REG_BINARY
+ String (contains binary data)
+
+ When ((|rtype|)) is specified, the value type must be included by
+ ((|rtype|)) array, or TypeError is raised.
+
+--- self[name, *rtype]
+ Read a registry value named ((|name|)) and return its value data.
+ The class of value is same as ((<read>)) method returns.
+
+ If the value type is REG_EXPAND_SZ, returns value data whose environment
+ variables are replaced.
+ If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD,
+ REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.
+
+ The meaning of ((|rtype|)) is same as ((<read>)) method.
+
+--- read_s(name)
+--- read_i(name)
+--- read_bin(name)
+ Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
+ registry value named ((|name|)).
+
+ If the values type does not match, TypeError is raised.
+
+--- read_s_expand(name)
+ Read a REG_SZ or REG_EXPAND_SZ registry value named ((|name|)).
+
+ If the value type is REG_EXPAND_SZ, environment variables are replaced.
+ Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.
+
+--- write(name, type, data)
+ Write ((|data|)) to a registry value named ((|name|)).
+ When name is nil, write to the `default' value.
+
+ ((|type|)) is type value. (see ((<Registry::Constants module>)))
+ Class of ((|data|)) must be same as which ((<read>))
+ method returns.
+
+--- self[name, wtype = nil] = value
+ Write ((|value|)) to a registry value named ((|name|)).
+
+ If ((|wtype|)) is specified, the value type is it.
+ Otherwise, the value type is depend on class of ((|value|)):
+ :Integer
+ REG_DWORD
+ :String
+ REG_SZ
+ :Array
+ REG_MULTI_SZ
+
+--- write_s(name, value)
+--- write_i(name, value)
+--- write_bin(name, value)
+ Write ((|value|)) to a registry value named ((|name|)).
+
+ The value type is REG_SZ(write_s), REG_DWORD(write_i), or
+ REG_BINARY(write_bin).
+
+--- each { |name, type, value| ... }
+--- each_value { |name, type, value| ... }
+ Enumerate values.
+
+--- each_key { |subkey, wtime| ... }
+ Enumerate subkeys.
+
+ ((|subkey|)) is String which contains name of subkey.
+ ((|wtime|)) is last write time as FILETIME (64-bit integer).
+ (see ((<Registry.wtime2time>)))
+
+--- delete(name)
+--- delete_value(name)
+ Delete a registry value named ((|name|)).
+ We can not delete the `default' value.
+
+--- delete_key(name, recursive = false)
+ Delete a subkey named ((|name|)) and all its values.
+
+ If ((|recursive|)) is false, the subkey must not have subkeys.
+ Otherwise, this method deletes all subkeys and values recursively.
+
+--- flush
+ Write all the attributes into the registry file.
+
+--- created?
+ Returns if key is created ((*newly*)).
+ (see ((<Registry.create>)))
+
+--- open?
+ Returns if key is not closed.
+
+--- hkey
+ Returns key handle value.
+
+--- parent
+ Win32::Registry object of parent key, or nil if predefeined key.
+
+--- keyname
+ Same as ((|subkey|)) value of ((<Registry.open>)) or
+ ((<Registry.create>)) method.
+
+--- disposition
+ Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY).
+
+--- name
+--- to_s
+ Full path of key such as (({'HKEY_CURRENT_USER\SOFTWARE\foo\bar'})).
+
+--- info
+ Returns key information as Array of:
+ :num_keys
+ The number of subkeys.
+ :max_key_length
+ Maximum length of name of subkeys.
+ :num_values
+ The number of values.
+ :max_value_name_length
+ Maximum length of name of values.
+ :max_value_length
+ Maximum length of value of values.
+ :descriptor_length
+ Length of security descriptor.
+ :wtime
+ Last write time as FILETIME(64-bit integer)
+
+ For detail, see ((<RegQueryInfoKey|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp>)) Win32 API.
+
+--- num_keys
+--- max_key_length
+--- num_values
+--- max_value_name_length
+--- max_value_length
+--- descriptor_length
+--- wtime
+ Returns an item of key information.
+
+=== constants
+--- HKEY_CLASSES_ROOT
+--- HKEY_CURRENT_USER
+--- HKEY_LOCAL_MACHINE
+--- HKEY_PERFORMANCE_DATA
+--- HKEY_CURRENT_CONFIG
+--- HKEY_DYN_DATA
+ Win32::Registry object whose key is predefined key.
+ For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp>)).
+
+== Win32::Registry::Constants module
+
+For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp>)).
+
+--- HKEY_*
+ Predefined key ((*handle*)).
+ These are Integer, not Win32::Registry.
+
+--- REG_*
+ Registry value type.
+
+--- KEY_*
+ Security access mask.
+
+--- KEY_OPTIONS_*
+ Key options.
+
+--- REG_CREATED_NEW_KEY
+--- REG_OPENED_EXISTING_KEY
+ If the key is created newly or opened existing key.
+ See also Registry#((<disposition>)) method.
+
+=end
+
+require 'Win32API'
+
+module Win32
+ class Registry
+ module Constants
+ HKEY_CLASSES_ROOT = 0x80000000
+ HKEY_CURRENT_USER = 0x80000001
+ HKEY_LOCAL_MACHINE = 0x80000002
+ HKEY_USERS = 0x80000003
+ HKEY_PERFORMANCE_DATA = 0x80000004
+ HKEY_PERFORMANCE_TEXT = 0x80000050
+ HKEY_PERFORMANCE_NLSTEXT = 0x80000060
+ HKEY_CURRENT_CONFIG = 0x80000005
+ HKEY_DYN_DATA = 0x80000006
+
+ REG_NONE = 0
+ REG_SZ = 1
+ REG_EXPAND_SZ = 2
+ REG_BINARY = 3
+ REG_DWORD = 4
+ REG_DWORD_LITTLE_ENDIAN = 4
+ REG_DWORD_BIG_ENDIAN = 5
+ REG_LINK = 6
+ REG_MULTI_SZ = 7
+ REG_RESOURCE_LIST = 8
+ REG_FULL_RESOURCE_DESCRIPTOR = 9
+ REG_RESOURCE_REQUIREMENTS_LIST = 10
+ REG_QWORD = 11
+ REG_QWORD_LITTLE_ENDIAN = 11
+
+ STANDARD_RIGHTS_READ = 0x00020000
+ STANDARD_RIGHTS_WRITE = 0x00020000
+ KEY_QUERY_VALUE = 0x0001
+ KEY_SET_VALUE = 0x0002
+ KEY_CREATE_SUB_KEY = 0x0004
+ KEY_ENUMERATE_SUB_KEYS = 0x0008
+ KEY_NOTIFY = 0x0010
+ KEY_CREATE_LINK = 0x0020
+ KEY_READ = STANDARD_RIGHTS_READ |
+ KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
+ KEY_WRITE = STANDARD_RIGHTS_WRITE |
+ KEY_SET_VALUE | KEY_CREATE_SUB_KEY
+ KEY_EXECUTE = KEY_READ
+ KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
+
+ REG_OPTION_RESERVED = 0x0000
+ REG_OPTION_NON_VOLATILE = 0x0000
+ REG_OPTION_VOLATILE = 0x0001
+ REG_OPTION_CREATE_LINK = 0x0002
+ REG_OPTION_BACKUP_RESTORE = 0x0004
+ REG_OPTION_OPEN_LINK = 0x0008
+ REG_LEGAL_OPTION = REG_OPTION_RESERVED |
+ REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
+ REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
+
+ REG_CREATED_NEW_KEY = 1
+ REG_OPENED_EXISTING_KEY = 2
+
+ REG_WHOLE_HIVE_VOLATILE = 0x0001
+ REG_REFRESH_HIVE = 0x0002
+ REG_NO_LAZY_FLUSH = 0x0004
+ REG_FORCE_RESTORE = 0x0008
+
+ MAX_KEY_LENGTH = 514
+ MAX_VALUE_LENGTH = 32768
+ end
+ include Constants
+ include Enumerable
+
+ #
+ # Error
+ #
+ class Error < ::StandardError
+ FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
+ def initialize(code)
+ @code = code
+ msg = "\0" * 1024
+ len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
+ super msg[0, len].tr("\r", '').chomp
+ end
+ attr_reader :code
+ end
+
+ #
+ # Predefined Keys
+ #
+ class PredefinedKey < Registry
+ def initialize(hkey, keyname)
+ @hkey = hkey
+ @parent = nil
+ @keyname = keyname
+ @disposition = REG_OPENED_EXISTING_KEY
+ end
+
+ # Predefined keys cannot be closed
+ def close
+ raise Error.new(5) ## ERROR_ACCESS_DENIED
+ end
+
+ # Fake class for Registry#open, Registry#create
+ def class
+ Registry
+ end
+
+ # Make all
+ Constants.constants.grep(/^HKEY_/) do |c|
+ Registry.const_set c, new(Constants.const_get(c), c)
+ end
+ end
+
+ #
+ # Win32 APIs
+ #
+ module API
+ [
+ %w/RegOpenKeyExA LPLLP L/,
+ %w/RegCreateKeyExA LPLLLLPPP L/,
+ %w/RegEnumValueA LLPPPPPP L/,
+ %w/RegEnumKeyExA LLPPLLLP L/,
+ %w/RegQueryValueExA LPLPPP L/,
+ %w/RegSetValueExA LPLLPL L/,
+ %w/RegDeleteValue LP L/,
+ %w/RegDeleteKey LP L/,
+ %w/RegFlushKey L L/,
+ %w/RegCloseKey L L/,
+ %w/RegQueryInfoKey LPPPPPPPPPPP L/,
+ ].each do |fn|
+ const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
+ end
+
+ module_function
+
+ def check(result)
+ raise Error, result, caller(2) if result != 0
+ end
+
+ def packdw(dw)
+ [dw].pack('V')
+ end
+
+ def unpackdw(dw)
+ dw += [0].pack('V')
+ dw.unpack('V')[0]
+ end
+
+ def packqw(qw)
+ [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
+ end
+
+ def unpackqw(qw)
+ qw = qw.unpack('VV')
+ (qw[1] << 32) | qw[0]
+ end
+
+ def OpenKey(hkey, name, opt, desired)
+ result = packdw(0)
+ check RegOpenKeyExA.call(hkey, name, opt, desired, result)
+ unpackdw(result)
+ end
+
+ def CreateKey(hkey, name, opt, desired)
+ result = packdw(0)
+ disp = packdw(0)
+ check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
+ 0, result, disp)
+ [ unpackdw(result), unpackdw(disp) ]
+ end
+
+ def EnumValue(hkey, index)
+ name = ' ' * Constants::MAX_KEY_LENGTH
+ size = packdw(Constants::MAX_KEY_LENGTH)
+ check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
+ name[0, unpackdw(size)]
+ end
+
+ def EnumKey(hkey, index)
+ name = ' ' * Constants::MAX_KEY_LENGTH
+ size = packdw(Constants::MAX_KEY_LENGTH)
+ wtime = ' ' * 8
+ check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
+ [ name[0, unpackdw(size)], unpackqw(wtime) ]
+ end
+
+ def QueryValue(hkey, name)
+ type = packdw(0)
+ size = packdw(0)
+ check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
+ data = ' ' * unpackdw(size)
+ check RegQueryValueExA.call(hkey, name, 0, type, data, size)
+ [ unpackdw(type), data[0, unpackdw(size)] ]
+ end
+
+ def SetValue(hkey, name, type, data, size)
+ check RegSetValueExA.call(hkey, name, 0, type, data, size)
+ end
+
+ def DeleteValue(hkey, name)
+ check RegDeleteValue.call(hkey, name)
+ end
+
+ def DeleteKey(hkey, name)
+ check RegDeleteKey.call(hkey, name)
+ end
+
+ def FlushKey(hkey)
+ check RegFlushKey.call(hkey)
+ end
+
+ def CloseKey(hkey)
+ check RegCloseKey.call(hkey)
+ end
+
+ def QueryInfoKey(hkey)
+ subkeys = packdw(0)
+ maxsubkeylen = packdw(0)
+ values = packdw(0)
+ maxvaluenamelen = packdw(0)
+ maxvaluelen = packdw(0)
+ secdescs = packdw(0)
+ wtime = ' ' * 8
+ check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
+ values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
+ [ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
+ unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
+ unpackdw(secdescs), unpackqw(wtime) ]
+ end
+ end
+
+ #
+ # utility functions
+ #
+ def self.expand_environ(str)
+ str.gsub(/%([^%]+)%/) { ENV[$1] || ENV[$1.upcase] || $& }
+ end
+
+ @@type2name = { }
+ %w[
+ REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
+ REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
+ REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
+ REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
+ ].each do |type|
+ @@type2name[Constants.const_get(type)] = type
+ end
+
+ def self.type2name(type)
+ @@type2name[type] || type.to_s
+ end
+
+ def self.wtime2time(wtime)
+ Time.at((wtime - 116444736000000000) / 10000000)
+ end
+
+ def self.time2wtime(time)
+ time.to_i * 10000000 + 116444736000000000
+ end
+
+ #
+ # constructors
+ #
+ private_class_method :new
+
+ def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+ subkey = subkey.chomp('\\')
+ newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
+ obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
+ if block_given?
+ begin
+ yield obj
+ ensure
+ obj.close
+ end
+ else
+ obj
+ end
+ end
+
+ def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+ newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
+ obj = new(newkey, hkey, subkey, disp)
+ if block_given?
+ begin
+ yield obj
+ ensure
+ obj.close
+ end
+ else
+ obj
+ end
+ end
+
+ #
+ # finalizer
+ #
+ @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
+
+ #
+ # initialize
+ #
+ def initialize(hkey, parent, keyname, disposition)
+ @hkey = hkey
+ @parent = parent
+ @keyname = keyname
+ @disposition = disposition
+ @hkeyfinal = [ hkey ]
+ ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
+ end
+ attr_reader :hkey, :parent, :keyname, :disposition
+
+ #
+ # attributes
+ #
+ def created?
+ @disposition == REG_CREATED_NEW_KEY
+ end
+
+ def open?
+ !@hkey.nil?
+ end
+
+ def name
+ parent = self
+ name = @keyname
+ while parent = parent.parent
+ name = parent.keyname + '\\' + name
+ end
+ name
+ end
+
+ def inspect
+ "\#<Win32::Registry key=#{name.inspect}>"
+ end
+
+ #
+ # marshalling
+ #
+ def _dump(depth)
+ raise TypeError, "can't dump Win32::Registry"
+ end
+
+ #
+ # open/close
+ #
+ def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
+ self.class.open(self, subkey, desired, opt, &blk)
+ end
+
+ def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
+ self.class.create(self, subkey, desired, opt, &blk)
+ end
+
+ def close
+ API.CloseKey(@hkey)
+ @hkey = @parent = @keyname = nil
+ @hkeyfinal[0] = nil
+ end
+
+ #
+ # iterator
+ #
+ def each_value
+ index = 0
+ while true
+ begin
+ subkey = API.EnumValue(@hkey, index)
+ rescue Error
+ break
+ end
+ begin
+ type, data = read(subkey)
+ rescue Error
+ next
+ end
+ yield subkey, type, data
+ index += 1
+ end
+ index
+ end
+ alias each each_value
+
+ def each_key
+ index = 0
+ while true
+ begin
+ subkey, wtime = API.EnumKey(@hkey, index)
+ rescue Error
+ break
+ end
+ yield subkey, wtime
+ index += 1
+ end
+ index
+ end
+
+ def keys
+ keys_ary = []
+ each_key { |key,| keys_ary << key }
+ keys_ary
+ end
+
+ #
+ # reader
+ #
+ def read(name, *rtype)
+ type, data = API.QueryValue(@hkey, name)
+ unless rtype.empty? or rtype.include?(type)
+ raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)"
+ end
+ case type
+ when REG_SZ, REG_EXPAND_SZ
+ [ type, data.chop ]
+ when REG_MULTI_SZ
+ [ type, data.split(/\0/) ]
+ when REG_BINARY
+ [ type, data ]
+ when REG_DWORD
+ [ type, API.unpackdw(data) ]
+ when REG_DWORD_BIG_ENDIAN
+ [ type, data.unpack('N')[0] ]
+ when REG_QWORD
+ [ type, API.unpackqw(data) ]
+ else
+ raise TypeError, "Type #{type} is not supported."
+ end
+ end
+
+ def [](name, *rtype)
+ type, data = read(name, *rtype)
+ case type
+ when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
+ data
+ when REG_EXPAND_SZ
+ Registry.expand_environ(data)
+ else
+ raise TypeError, "Type #{type} is not supported."
+ end
+ end
+
+ def read_s(name)
+ read(name, REG_SZ)[1]
+ end
+
+ def read_s_expand(name)
+ type, data = read(name, REG_SZ, REG_EXPAND_SZ)
+ if type == REG_EXPAND_SZ
+ Registry.expand_environ(data)
+ else
+ data
+ end
+ end
+
+ def read_i(name)
+ read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
+ end
+
+ def read_bin(name)
+ read(name, REG_BINARY)[1]
+ end
+
+ #
+ # writer
+ #
+ def write(name, type, data)
+ case type
+ when REG_SZ, REG_EXPAND_SZ
+ data = data.to_s + "\0"
+ when REG_MULTI_SZ
+ data = data.to_a.join("\0") + "\0\0"
+ when REG_BINARY
+ data = data.to_s
+ when REG_DWORD
+ data = API.packdw(data.to_i)
+ when REG_DWORD_BIG_ENDIAN
+ data = [data.to_i].pack('N')
+ when REG_QWORD
+ data = API.packqw(data.to_i)
+ else
+ raise TypeError, "Unsupported type #{type}"
+ end
+ API.SetValue(@hkey, name, type, data, data.length)
+ end
+
+ def []=(name, rtype, value = nil)
+ if value
+ write name, rtype, value
+ else
+ case value = rtype
+ when Integer
+ write name, REG_DWORD, value
+ when String
+ write name, REG_SZ, value
+ when Array
+ write name, REG_MULTI_SZ, value
+ else
+ raise TypeError, "Unexpected type #{value.class}"
+ end
+ end
+ value
+ end
+
+ def write_s(name, value)
+ write name, REG_SZ, value.to_s
+ end
+
+ def write_i(name, value)
+ write name, REG_DWORD, value.to_i
+ end
+
+ def write_bin(name, value)
+ write name, REG_BINARY, value.to_s
+ end
+
+ #
+ # delete
+ #
+ def delete_value(name)
+ API.DeleteValue(@hkey, name)
+ end
+ alias delete delete_value
+
+ def delete_key(name, recursive = false)
+ if recursive
+ open(name, KEY_ALL_ACCESS) do |reg|
+ reg.keys.each do |key|
+ begin
+ reg.delete_key(key, true)
+ rescue Error
+ #
+ end
+ end
+ end
+ API.DeleteKey(@hkey, name)
+ else
+ begin
+ API.EnumKey @hkey, 0
+ rescue Error
+ return API.DeleteKey(@hkey, name)
+ end
+ raise Error.new(5) ## ERROR_ACCESS_DENIED
+ end
+ end
+
+ #
+ # flush
+ #
+ def flush
+ API.FlushKey @hkey
+ end
+
+ #
+ # key information
+ #
+ def info
+ API.QueryInfoKey(@hkey)
+ end
+ %w[
+ num_keys max_key_length
+ num_values max_value_name_length max_value_length
+ descriptor_length wtime
+ ].each_with_index do |s, i|
+ eval <<-__END__
+ def #{s}
+ info[#{i}]
+ end
+ __END__
+ end
+ end
+end
diff --git a/ext/Win32API/lib/win32/resolv.rb b/ext/Win32API/lib/win32/resolv.rb
new file mode 100644
index 0000000000..92336fac28
--- /dev/null
+++ b/ext/Win32API/lib/win32/resolv.rb
@@ -0,0 +1,366 @@
+=begin
+= Win32 DNS and DHCP I/F
+
+=end
+
+require 'win32/registry'
+
+module Win32
+ module Resolv
+ API = Registry::API
+
+ def self.get_hosts_path
+ path = get_hosts_dir
+ path = File.expand_path('hosts', path)
+ File.exist?(path) ? path : nil
+ end
+
+ def self.get_resolv_info
+ search, nameserver = get_info
+ if search.empty?
+ search = nil
+ else
+ search.delete("")
+ search.uniq!
+ end
+ if nameserver.empty?
+ nameserver = nil
+ else
+ nameserver.delete("")
+ nameserver.delete("0.0.0.0")
+ nameserver.uniq!
+ end
+ [ search, nameserver ]
+ end
+
+getv = Win32API.new('kernel32.dll', 'GetVersionExA', 'P', 'L')
+info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
+getv.call(info)
+if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
+#====================================================================
+# Windows NT
+#====================================================================
+ module_eval <<-'__EOS__', __FILE__, __LINE__+1
+ TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
+
+ class << self
+ private
+ def get_hosts_dir
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
+ reg.read_s_expand('DataBasePath')
+ end
+ end
+
+ def get_info
+ search = nil
+ nameserver = []
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
+ begin
+ slist = reg.read_s('SearchList')
+ search = slist.split(/,\s*/) unless slist.empty?
+ rescue Registry::Error
+ end
+
+ if add_search = search.nil?
+ search = []
+ begin
+ nvdom = reg.read_s('NV Domain')
+ unless nvdom.empty?
+ @search = [ nvdom ]
+ if reg.read_i('UseDomainNameDevolution') != 0
+ if /^[\w\d]+\./ =~ nvdom
+ devo = $'
+ end
+ end
+ end
+ rescue Registry::Error
+ end
+ end
+
+ reg.open('Interfaces') do |reg|
+ reg.each_key do |iface,|
+ reg.open(iface) do |regif|
+ begin
+ [ 'NameServer', 'DhcpNameServer' ].each do |key|
+ ns = regif.read_s(key)
+ unless ns.empty?
+ nameserver.concat(ns.split(/[,\s]\s*/))
+ break
+ end
+ end
+ rescue Registry::Error
+ end
+
+ if add_search
+ begin
+ [ 'Domain', 'DhcpDomain' ].each do |key|
+ dom = regif.read_s(key)
+ unless dom.empty?
+ search.concat(dom.split(/,\s*/))
+ break
+ end
+ end
+ rescue Registry::Error
+ end
+ end
+ end
+ end
+ end
+ search << devo if add_search and devo
+ end
+ [ search.uniq, nameserver.uniq ]
+ end
+ end
+ __EOS__
+else
+#====================================================================
+# Windows 9x
+#====================================================================
+ module_eval <<-'__EOS__', __FILE__, __LINE__+1
+ TCPIP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\MSTCP'
+ DHCP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\DHCP'
+ WINDOWS = 'Software\Microsoft\Windows\CurrentVersion'
+
+ class << self
+ # private
+
+ def get_hosts_dir
+ Registry::HKEY_LOCAL_MACHINE.open(WINDOWS) do |reg|
+ reg.read_s_expand('SystemRoot')
+ end
+ end
+
+ def get_info
+ search = []
+ nameserver = []
+ begin
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_9X) do |reg|
+ if reg.read_s("EnableDNS") == "1"
+ domain = reg.read_s("Domain")
+ ns = reg.read_s("NameServer")
+ slist = reg.read_s("SearchList")
+ search << domain unless domain.empty?
+ search.concat(slist.split(/,\s*/))
+ nameserver.concat(ns.split(/[,\s]\s*/))
+ end
+ end
+ rescue Registry::Error
+ end
+
+ dhcpinfo = get_dhcpinfo
+ search.concat(dhcpinfo[0])
+ nameserver.concat(dhcpinfo[1])
+ [ search, nameserver ]
+ end
+
+ def get_dhcpinfo
+ macaddrs = {}
+ ipaddrs = {}
+ WsControl.get_iflist.each do |index, macaddr, *ipaddr|
+ macaddrs[macaddr] = 1
+ ipaddr.each { |ipaddr| ipaddrs[ipaddr] = 1 }
+ end
+ iflist = [ macaddrs, ipaddrs ]
+
+ search = []
+ nameserver = []
+ version = -1
+ Registry::HKEY_LOCAL_MACHINE.open(DHCP_9X) do |reg|
+ begin
+ version = API.unpackdw(reg.read_bin("Version"))
+ rescue Registry::Error
+ end
+
+ reg.each_key do |key,|
+ catch(:not_used) do
+ reg.open(key) do |regdi|
+ dom, ns = get_dhcpinfo_key(version, regdi, iflist)
+ search << dom if dom
+ nameserver.concat(ns) if ns
+ end
+ end
+ end
+ end
+ [ search, nameserver ]
+ end
+
+ def get_dhcpinfo_95(reg)
+ dhcp = reg.read_bin("DhcpInfo")
+ [
+ API.unpackdw(dhcp[4..7]),
+ API.unpackdw(dhcp[8..11]),
+ 1,
+ dhcp[45..50],
+ reg.read_bin("OptionInfo"),
+ ]
+ end
+
+ def get_dhcpinfo_98(reg)
+ [
+ API.unpackdw(reg.read_bin("DhcpIPAddress")),
+ API.unpackdw(reg.read_bin("DhcpSubnetMask")),
+ API.unpackdw(reg.read_bin("HardwareType")),
+ reg.read_bin("HardwareAddress"),
+ reg.read_bin("OptionInfo"),
+ ]
+ end
+
+ def get_dhcpinfo_key(version, reg, iflist)
+ info = case version
+ when 1
+ get_dhcpinfo_95(reg)
+ when 2
+ get_dhcpinfo_98(reg)
+ else
+ begin
+ get_dhcpinfo_98(reg)
+ rescue Registry::Error
+ get_dhcpinfo_95(reg)
+ end
+ end
+ ipaddr, netmask, hwtype, macaddr, opt = info
+ throw :not_used unless
+ ipaddr and ipaddr != 0 and
+ netmask and netmask != 0 and
+ macaddr and macaddr.size == 6 and
+ hwtype == 1 and
+ iflist[0][macaddr] and iflist[1][ipaddr]
+
+ size = opt.size
+ idx = 0
+ while idx <= size
+ opttype = opt[idx]
+ optsize = opt[idx + 1]
+ optval = opt[idx + 2, optsize]
+ case opttype
+ when 0xFF ## term
+ break
+ when 0x0F ## domain
+ domain = optval.chomp("\0")
+ when 0x06 ## dns
+ nameserver = optval.scan(/..../).collect { |addr|
+ "%d.%d.%d.%d" % addr.unpack('C4')
+ }
+ end
+ idx += optsize + 2
+ end
+ [ domain, nameserver ]
+ rescue Registry::Error
+ throw :not_used
+ end
+ end
+
+ module WsControl
+ WsControl = Win32API.new('wsock32.dll', 'WsControl', 'LLPPPP', 'L')
+ WSAGetLastError = Win32API.new('wsock32.dll', 'WSAGetLastError', 'V', 'L')
+
+ MAX_TDI_ENTITIES = 512
+ IPPROTO_TCP = 6
+ WSCTL_TCP_QUERY_INFORMATION = 0
+ INFO_CLASS_GENERIC = 0x100
+ INFO_CLASS_PROTOCOL = 0x200
+ INFO_TYPE_PROVIDER = 0x100
+ ENTITY_LIST_ID = 0
+ GENERIC_ENTITY = 0
+ CL_NL_ENTITY = 0x301
+ IF_ENTITY = 0x200
+ ENTITY_TYPE_ID = 1
+ CL_NL_IP = 0x303
+ IF_MIB = 0x202
+ IF_MIB_STATS_ID = 1
+ IP_MIB_ADDRTABLE_ENTRY_ID = 0x102
+
+ def self.wsctl(tei_entity, tei_instance,
+ toi_class, toi_type, toi_id,
+ buffsize)
+ reqinfo = [
+ ## TDIEntityID
+ tei_entity, tei_instance,
+ ## TDIObjectID
+ toi_class, toi_type, toi_id,
+ ## TCP_REQUEST_INFORMATION_EX
+ ""
+ ].pack('VVVVVa16')
+ reqsize = API.packdw(reqinfo.size)
+ buff = "\0" * buffsize
+ buffsize = API.packdw(buffsize)
+ result = WsControl.call(
+ IPPROTO_TCP,
+ WSCTL_TCP_QUERY_INFORMATION,
+ reqinfo, reqsize,
+ buff, buffsize)
+ if result != 0
+ raise RuntimeError, "WsControl failed.(#{result})"
+ end
+ [ buff, API.unpackdw(buffsize) ]
+ end
+ private_class_method :wsctl
+
+ def self.get_iflist
+ # Get TDI Entity List
+ entities, size =
+ wsctl(GENERIC_ENTITY, 0,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_LIST_ID,
+ MAX_TDI_ENTITIES * 8) # sizeof(TDIEntityID)
+ entities = entities[0, size].
+ scan(/.{8}/).
+ collect { |e| e.unpack('VV') }
+
+ # Get MIB Interface List
+ iflist = []
+ ifcount = 0
+ entities.each do |entity, instance|
+ if( (entity & IF_ENTITY)>0 )
+ ifcount += 1
+ etype, = wsctl(entity, instance,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_TYPE_ID,
+ 4)
+ if( (API.unpackdw(etype) & IF_MIB)==IF_MIB )
+ ifentry, = wsctl(entity, instance,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IF_MIB_STATS_ID,
+ 21 * 4 + 8 + 130) # sizeof(IFEntry)
+ iflist << [
+ API.unpackdw(ifentry[0,4]),
+ ifentry[20, 6]
+ ]
+ end
+ end
+ end
+
+ # Get IP Addresses
+ entities.each do |entity, instance|
+ if entity == CL_NL_ENTITY
+ etype, = wsctl(entity, instance,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_TYPE_ID,
+ 4)
+ if API.unpackdw(etype) == CL_NL_IP
+ ipentries, = wsctl(entity, instance,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IP_MIB_ADDRTABLE_ENTRY_ID,
+ 24 * (ifcount+1)) # sizeof(IPAddrEntry)
+ ipentries.scan(/.{24}/) do |ipentry|
+ ipaddr, index = ipentry.unpack('VV')
+ if ifitem = iflist.assoc(index)
+ ifitem << ipaddr
+ end
+ end
+ end
+ end
+ end
+ iflist
+ end
+ end
+ __EOS__
+end
+#====================================================================
+ end
+end
diff --git a/ext/Win32API/point.rb b/ext/Win32API/point.rb
new file mode 100644
index 0000000000..60e265f3ee
--- /dev/null
+++ b/ext/Win32API/point.rb
@@ -0,0 +1,18 @@
+require 'Win32API'
+
+getCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'V')
+
+lpPoint = " " * 8 # store two LONGs
+getCursorPos.Call(lpPoint)
+x, y = lpPoint.unpack("LL") # get the actual values
+
+print "x: ", x, "\n"
+print "y: ", y, "\n"
+
+ods = Win32API.new("kernel32", "OutputDebugString", ['P'], 'V')
+ods.Call("Hello, World\n");
+
+GetDesktopWindow = Win32API.new("user32", "GetDesktopWindow", [], 'L')
+GetActiveWindow = Win32API.new("user32", "GetActiveWindow", [], 'L')
+SendMessage = Win32API.new("user32", "SendMessage", ['L'] * 4, 'L')
+SendMessage.Call GetDesktopWindow.Call, 274, 0xf140, 0
diff --git a/ext/bigdecimal/.cvsignore b/ext/bigdecimal/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/bigdecimal/.cvsignore
+++ b/ext/bigdecimal/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index d2a351e984..636c0907d6 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -13,7 +13,7 @@
*
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -22,6 +22,7 @@
#include <float.h>
#include <math.h>
#include "math.h"
+#include "version.h"
/* #define ENABLE_NUMERIC_STRING */
@@ -585,19 +586,22 @@ BigDecimal_to_f(VALUE self)
{
ENTER(1);
Real *p;
- double d, d2;
+ double d;
S_LONG e;
+ char *buf;
GUARD_OBJ(p,GetVpValue(self,1));
if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
+ buf = ALLOCA_N(char,(unsigned int)VpNumOfChars(p,"E"));
+ VpToString(p, buf, 0, 0);
errno = 0;
- d2 = pow(10.0,(double)e);
- if((errno == ERANGE && e>0) || (d2>1.0 && (fabs(d) > (DBL_MAX / d2)))) {
+ d = strtod(buf, 0);
+ if(errno == ERANGE) {
VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion",0);
if(d>0.0) return rb_float_new(DBL_MAX);
else return rb_float_new(-DBL_MAX);
}
- return rb_float_new(d*d2);
+ return rb_float_new(d);
}
/* The coerce method provides support for Ruby type coercion. It is not
@@ -1050,7 +1054,7 @@ static VALUE
BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
{
VALUE f;
- Real *d,*rv;
+ Real *d,*rv=0;
f = BigDecimal_divremain(self,r,&d,&rv);
if(f!=(VALUE)0) return f;
return ToValue(rv);
@@ -1504,7 +1508,7 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
} else if(*psz=='+') {
fPlus = 2; psz++;
}
- while(ch=*psz++) {
+ while((ch=*psz++)!=0) {
if(ISSPACE(ch)) continue;
if(!ISDIGIT(ch)) {
if(ch=='F' || ch=='f') fmt = 1; /* F format */
@@ -1961,17 +1965,27 @@ static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
static U_LONG gnPrecLimit = 0; /* Global upper limit of the precision newly allocated */
static U_LONG gfRoundMode = VP_ROUND_HALF_UP; /* Mode for general rounding operation */
+#ifndef BASE_FIG
static U_LONG BASE_FIG = 4; /* =log10(BASE) */
static U_LONG BASE = 10000L; /* Base value(value must be 10**BASE_FIG) */
/* The value of BASE**2 + BASE must be represented */
/* within one U_LONG. */
static U_LONG HALF_BASE = 5000L;/* =BASE/2 */
-static S_LONG DBLE_FIG = 8; /* figure of double */
static U_LONG BASE1 = 1000L; /* =BASE/10 */
+#else
+#ifndef BASE
+#error BASE_FIG is defined but BASE is not
+#endif
+#define HALF_BASE (BASE/2)
+#define BASE1 (BASE/10)
+#endif
+#ifndef DBLE_FIG
+#define DBLE_FIG (DBL_DIG+1) /* figure of double */
+#endif
static Real *VpConstOne; /* constant 1.0 */
static Real *VpPt5; /* constant 0.5 */
-static U_LONG maxnr = 100; /* Maximum iterations for calcurating sqrt. */
+#define maxnr 100UL /* Maximum iterations for calcurating sqrt. */
/* used in VpSqrt() */
/* ETC */
@@ -2088,8 +2102,8 @@ VpSetRoundMode(unsigned long n)
* (to let the compiler know they may be changed in outside
* (... but not actually..)).
*/
-volatile double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
-volatile double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
+volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
+volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
static double
Zero(void)
{
@@ -2361,16 +2375,15 @@ VpNumOfChars(Real *vp,const char *pszFmt)
VP_EXPORT U_LONG
VpInit(U_LONG BaseVal)
{
- U_LONG w;
- double v;
-
/* Setup +/- Inf NaN -0 */
VpGetDoubleNaN();
VpGetDoublePosInf();
VpGetDoubleNegInf();
VpGetDoubleNegZero();
+#ifndef BASE_FIG
if(BaseVal <= 0) {
+ U_LONG w;
/* Base <= 0, then determine Base by calcuration. */
BASE = 1;
while(
@@ -2387,6 +2400,8 @@ VpInit(U_LONG BaseVal)
BASE1 = BASE / 10;
BASE_FIG = 0;
while(BaseVal /= 10) ++BASE_FIG;
+#endif
+
/* Allocates Vp constants. */
VpConstOne = VpAlloc((U_LONG)1, "1");
VpPt5 = VpAlloc((U_LONG)1, ".5");
@@ -2395,15 +2410,6 @@ VpInit(U_LONG BaseVal)
gnAlloc = 0;
#endif /* _DEBUG */
- /* Determine # of digits available in one 'double'. */
-
- v = 1.0;
- DBLE_FIG = 0;
- while(v + 1.0 > 1.0) {
- ++DBLE_FIG;
- v /= 10;
- }
-
#ifdef _DEBUG
if(gfDebug) {
printf("VpInit: BaseVal = %lu\n", BaseVal);
@@ -2506,7 +2512,7 @@ VpAlloc(U_LONG mx, const char *szVal)
psz = ALLOCA_N(char,strlen(szVal)+1);
i = 0;
ipn = 0;
- while(psz[i]=szVal[ipn]) {
+ while((psz[i]=szVal[ipn])!=0) {
if(ISDIGIT(psz[i])) ++ni;
if(psz[i]=='_') {
if(ni>0) {ipn++;continue;}
@@ -2549,7 +2555,7 @@ VpAlloc(U_LONG mx, const char *szVal)
else if(szVal[i] == '+') ++i;
/* Skip digits */
ni = 0; /* digits in mantissa */
- while(v = szVal[i]) {
+ while((v = szVal[i]) != 0) {
if(!ISDIGIT(v)) break;
++i;
++ni;
@@ -2563,7 +2569,7 @@ VpAlloc(U_LONG mx, const char *szVal)
if(szVal[i] == '.') { /* xxx. */
++i;
ipf = i;
- while(v = szVal[i]) { /* get fraction part. */
+ while((v = szVal[i]) != 0) { /* get fraction part. */
if(!ISDIGIT(v)) break;
++i;
++nf;
@@ -2581,7 +2587,7 @@ VpAlloc(U_LONG mx, const char *szVal)
ipe = i;
v = szVal[i];
if((v == '-') ||(v == '+')) ++i;
- while(v=szVal[i]) {
+ while((v=szVal[i])!=0) {
if(!ISDIGIT(v)) break;
++i;
++ne;
@@ -4318,6 +4324,7 @@ Exit:
/*
*
+ * f = 0: Round off/Truncate, 1: round up, 2:ceil, 3: floor, 4: Banker's rounding
* nf: digit position for operation.
*
*/
@@ -4338,22 +4345,15 @@ 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;
}
-
/* ix: x->fraq[ix] contains round position */
ix = nf/(int)BASE_FIG;
- if(((U_LONG)ix)>=y->Prec) return 0; /* rounding position too right(small). */
+ if(((U_LONG)ix)>=y->Prec) return 0; /* Unable to round */
ioffset = nf - ix*((int)BASE_FIG);
v = y->frac[ix];
-
/* drop digits after pointed digit */
n = BASE_FIG - ioffset - 1;
for(shifter=1,i=0;i<n;++i) shifter *= 10;
@@ -4439,7 +4439,7 @@ VpLeftRound(Real *y, int f, int nf)
if(!VpHasVal(y)) return 0; /* Unable to round */
v = y->frac[0];
nf -= VpExponent(y)*BASE_FIG;
- while(v=v/10) nf--;
+ while((v /= 10) != 0) nf--;
nf += (BASE_FIG-1);
return VpMidRound(y,f,nf);
}
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index a68a656044..0c8b98e4a3 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,2 +1,10 @@
require 'mkmf'
+
+base_fig = 0
+src = "(BASE * (BASE+1)) / BASE == (BASE+1)"
+while try_static_assert(src, nil, "-DBASE=10#{'0'*base_fig}UL")
+ base_fig += 1
+end
+$defs << "-DBASE=1#{'0'*base_fig}UL" << "-DBASE_FIG=#{base_fig}"
+
create_makefile('bigdecimal')
diff --git a/ext/continuation/continuation.c b/ext/continuation/continuation.c
deleted file mode 100644
index a1b43b5047..0000000000
--- a/ext/continuation/continuation.c
+++ /dev/null
@@ -1,8 +0,0 @@
-
-void Init_Continuation_body(void);
-
-void
-Init_continuation(void)
-{
- Init_Continuation_body();
-}
diff --git a/ext/continuation/extconf.rb b/ext/continuation/extconf.rb
deleted file mode 100644
index 17e2d056db..0000000000
--- a/ext/continuation/extconf.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'mkmf'
-create_makefile('continuation')
-
diff --git a/ext/curses/.cvsignore b/ext/curses/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/curses/.cvsignore
+++ b/ext/curses/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 615bd65c56..9c51a2127f 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -54,8 +54,8 @@
# define USE_MOUSE 1
#endif
-#define NUM2CH NUM2CHR
-#define CH2FIX CHR2FIX
+#define NUM2CH NUM2LONG
+#define CH2FIX LONG2FIX
static VALUE mCurses;
static VALUE mKey;
@@ -72,12 +72,12 @@ struct windata {
#define CHECK(c) c
-static VALUE window_attroff(VALUE obj, VALUE attrs);
-static VALUE window_attron(VALUE obj, VALUE attrs);
-static VALUE window_attrset(VALUE obj, VALUE attrs);
+static VALUE window_attroff();
+static VALUE window_attron();
+static VALUE window_attrset();
static void
-no_window(void)
+no_window()
{
rb_raise(rb_eRuntimeError, "already closed window");
}
@@ -90,7 +90,8 @@ no_window(void)
} while (0)
static void
-free_window(struct windata *winp)
+free_window(winp)
+ struct windata *winp;
{
if (winp->window && winp->window != stdscr) delwin(winp->window);
winp->window = 0;
@@ -98,7 +99,9 @@ free_window(struct windata *winp)
}
static VALUE
-prep_window(VALUE class, WINDOW *window)
+prep_window(class, window)
+ VALUE class;
+ WINDOW *window;
{
VALUE obj;
struct windata *winp;
@@ -118,7 +121,7 @@ prep_window(VALUE class, WINDOW *window)
/* def init_screen */
static VALUE
-curses_init_screen(void)
+curses_init_screen()
{
rb_secure(4);
if (rb_stdscr) return rb_stdscr;
@@ -136,7 +139,7 @@ curses_init_screen(void)
/* def close_screen */
static VALUE
-curses_close_screen(void)
+curses_close_screen()
{
#ifdef HAVE_ISENDWIN
if (!isendwin())
@@ -161,7 +164,7 @@ curses_finalize(VALUE dummy)
/* def closed? */
static VALUE
-curses_closed(void)
+curses_closed()
{
#ifdef HAVE_ISENDWIN
if (isendwin()) {
@@ -175,7 +178,8 @@ curses_closed(void)
/* def clear */
static VALUE
-curses_clear(VALUE obj)
+curses_clear(obj)
+ VALUE obj;
{
curses_stdscr();
wclear(stdscr);
@@ -184,7 +188,7 @@ curses_clear(VALUE obj)
/* def clrtoeol */
static VALUE
-curses_clrtoeol(void)
+curses_clrtoeol()
{
curses_stdscr();
clrtoeol();
@@ -193,7 +197,8 @@ curses_clrtoeol(void)
/* def refresh */
static VALUE
-curses_refresh(VALUE obj)
+curses_refresh(obj)
+ VALUE obj;
{
curses_stdscr();
refresh();
@@ -202,7 +207,8 @@ curses_refresh(VALUE obj)
/* def doupdate */
static VALUE
-curses_doupdate(VALUE obj)
+curses_doupdate(obj)
+ VALUE obj;
{
curses_stdscr();
#ifdef HAVE_DOUPDATE
@@ -215,7 +221,8 @@ curses_doupdate(VALUE obj)
/* def echo */
static VALUE
-curses_echo(VALUE obj)
+curses_echo(obj)
+ VALUE obj;
{
curses_stdscr();
echo();
@@ -224,7 +231,8 @@ curses_echo(VALUE obj)
/* def noecho */
static VALUE
-curses_noecho(VALUE obj)
+curses_noecho(obj)
+ VALUE obj;
{
curses_stdscr();
noecho();
@@ -233,7 +241,8 @@ curses_noecho(VALUE obj)
/* def raw */
static VALUE
-curses_raw(VALUE obj)
+curses_raw(obj)
+ VALUE obj;
{
curses_stdscr();
raw();
@@ -242,7 +251,8 @@ curses_raw(VALUE obj)
/* def noraw */
static VALUE
-curses_noraw(VALUE obj)
+curses_noraw(obj)
+ VALUE obj;
{
curses_stdscr();
noraw();
@@ -251,7 +261,8 @@ curses_noraw(VALUE obj)
/* def cbreak */
static VALUE
-curses_cbreak(VALUE obj)
+curses_cbreak(obj)
+ VALUE obj;
{
curses_stdscr();
cbreak();
@@ -260,7 +271,8 @@ curses_cbreak(VALUE obj)
/* def nocbreak */
static VALUE
-curses_nocbreak(VALUE obj)
+curses_nocbreak(obj)
+ VALUE obj;
{
curses_stdscr();
nocbreak();
@@ -269,7 +281,8 @@ curses_nocbreak(VALUE obj)
/* def nl */
static VALUE
-curses_nl(VALUE obj)
+curses_nl(obj)
+ VALUE obj;
{
curses_stdscr();
nl();
@@ -278,7 +291,8 @@ curses_nl(VALUE obj)
/* def nonl */
static VALUE
-curses_nonl(VALUE obj)
+curses_nonl(obj)
+ VALUE obj;
{
curses_stdscr();
nonl();
@@ -287,7 +301,8 @@ curses_nonl(VALUE obj)
/* def beep */
static VALUE
-curses_beep(VALUE obj)
+curses_beep(obj)
+ VALUE obj;
{
#ifdef HAVE_BEEP
curses_stdscr();
@@ -298,7 +313,8 @@ curses_beep(VALUE obj)
/* def flash */
static VALUE
-curses_flash(VALUE obj)
+curses_flash(obj)
+ VALUE obj;
{
#ifdef HAVE_FLASH
curses_stdscr();
@@ -309,7 +325,9 @@ curses_flash(VALUE obj)
/* def ungetch */
static VALUE
-curses_ungetch(VALUE obj, VALUE ch)
+curses_ungetch(obj, ch)
+ VALUE obj;
+ VALUE ch;
{
#ifdef HAVE_UNGETCH
curses_stdscr();
@@ -322,7 +340,10 @@ curses_ungetch(VALUE obj, VALUE ch)
/* def setpos(y, x) */
static VALUE
-curses_setpos(VALUE obj, VALUE y, VALUE x)
+curses_setpos(obj, y, x)
+ VALUE obj;
+ VALUE y;
+ VALUE x;
{
curses_stdscr();
move(NUM2INT(y), NUM2INT(x));
@@ -331,7 +352,8 @@ curses_setpos(VALUE obj, VALUE y, VALUE x)
/* def standout */
static VALUE
-curses_standout(VALUE obj)
+curses_standout(obj)
+ VALUE obj;
{
standout();
return Qnil;
@@ -339,7 +361,8 @@ curses_standout(VALUE obj)
/* def standend */
static VALUE
-curses_standend(VALUE obj)
+curses_standend(obj)
+ VALUE obj;
{
standend();
return Qnil;
@@ -347,7 +370,8 @@ curses_standend(VALUE obj)
/* def inch */
static VALUE
-curses_inch(VALUE obj)
+curses_inch(obj)
+ VALUE obj;
{
curses_stdscr();
return CH2FIX(inch());
@@ -355,7 +379,9 @@ curses_inch(VALUE obj)
/* def addch(ch) */
static VALUE
-curses_addch(VALUE obj, VALUE ch)
+curses_addch(obj, ch)
+ VALUE obj;
+ VALUE ch;
{
curses_stdscr();
addch(NUM2CH(ch));
@@ -364,7 +390,9 @@ curses_addch(VALUE obj, VALUE ch)
/* def insch(ch) */
static VALUE
-curses_insch(VALUE obj, VALUE ch)
+curses_insch(obj, ch)
+ VALUE obj;
+ VALUE ch;
{
curses_stdscr();
insch(NUM2CH(ch));
@@ -373,7 +401,9 @@ curses_insch(VALUE obj, VALUE ch)
/* def addstr(str) */
static VALUE
-curses_addstr(VALUE obj, VALUE str)
+curses_addstr(obj, str)
+ VALUE obj;
+ VALUE str;
{
curses_stdscr();
if (!NIL_P(str)) {
@@ -384,7 +414,8 @@ curses_addstr(VALUE obj, VALUE str)
/* def getch */
static VALUE
-curses_getch(VALUE obj)
+curses_getch(obj)
+ VALUE obj;
{
rb_read_check(stdin);
curses_stdscr();
@@ -393,7 +424,8 @@ curses_getch(VALUE obj)
/* def getstr */
static VALUE
-curses_getstr(VALUE obj)
+curses_getstr(obj)
+ VALUE obj;
{
char rtn[1024]; /* This should be big enough.. I hope */
@@ -408,7 +440,8 @@ curses_getstr(VALUE obj)
/* def delch */
static VALUE
-curses_delch(VALUE obj)
+curses_delch(obj)
+ VALUE obj;
{
delch();
return Qnil;
@@ -416,7 +449,8 @@ curses_delch(VALUE obj)
/* def delelteln */
static VALUE
-curses_deleteln(VALUE obj)
+curses_deleteln(obj)
+ VALUE obj;
{
#if defined(HAVE_DELETELN) || defined(deleteln)
deleteln();
@@ -426,7 +460,8 @@ curses_deleteln(VALUE obj)
/* def insertln */
static VALUE
-curses_insertln(VALUE obj)
+curses_insertln(obj)
+ VALUE obj;
{
#if defined(HAVE_INSERTLN) || defined(insertln)
insertln();
@@ -436,7 +471,9 @@ curses_insertln(VALUE obj)
/* def keyname */
static VALUE
-curses_keyname(VALUE obj, VALUE c)
+curses_keyname(obj, c)
+ VALUE obj;
+ VALUE c;
{
#ifdef HAVE_KEYNAME
const char *name;
@@ -453,13 +490,13 @@ curses_keyname(VALUE obj, VALUE c)
}
static VALUE
-curses_lines(void)
+curses_lines()
{
return INT2FIX(LINES);
}
static VALUE
-curses_cols(void)
+curses_cols()
{
return INT2FIX(COLS);
}
@@ -619,7 +656,7 @@ struct mousedata {
};
static void
-no_mevent(void)
+no_mevent()
{
rb_raise(rb_eRuntimeError, "no such mouse event");
}
@@ -731,7 +768,12 @@ window_s_allocate(VALUE class)
/* def initialize(h, w, top, left) */
static VALUE
-window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
+window_initialize(obj, h, w, top, left)
+ VALUE obj;
+ VALUE h;
+ VALUE w;
+ VALUE top;
+ VALUE left;
{
struct windata *winp;
WINDOW *window;
@@ -749,7 +791,12 @@ window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
/* def subwin(height, width, top, left) */
static VALUE
-window_subwin(VALUE obj, VALUE height, VALUE width, VALUE top, VALUE left)
+window_subwin(obj, height, width, top, left)
+ VALUE obj;
+ VALUE height;
+ VALUE width;
+ VALUE top;
+ VALUE left;
{
struct windata *winp;
WINDOW *window;
@@ -769,7 +816,8 @@ window_subwin(VALUE obj, VALUE height, VALUE width, VALUE top, VALUE left)
/* def close */
static VALUE
-window_close(VALUE obj)
+window_close(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -782,7 +830,8 @@ window_close(VALUE obj)
/* def clear */
static VALUE
-window_clear(VALUE obj)
+window_clear(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -794,7 +843,8 @@ window_clear(VALUE obj)
/* def clrtoeol */
static VALUE
-window_clrtoeol(VALUE obj)
+window_clrtoeol(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -806,7 +856,8 @@ window_clrtoeol(VALUE obj)
/* def refresh */
static VALUE
-window_refresh(VALUE obj)
+window_refresh(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -818,7 +869,8 @@ window_refresh(VALUE obj)
/* def noutrefresh */
static VALUE
-window_noutrefresh(VALUE obj)
+window_noutrefresh(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -834,7 +886,10 @@ window_noutrefresh(VALUE obj)
/* def move(y, x) */
static VALUE
-window_move(VALUE obj, VALUE y, VALUE x)
+window_move(obj, y, x)
+ VALUE obj;
+ VALUE y;
+ VALUE x;
{
struct windata *winp;
@@ -846,7 +901,10 @@ window_move(VALUE obj, VALUE y, VALUE x)
/* def setpos(y, x) */
static VALUE
-window_setpos(VALUE obj, VALUE y, VALUE x)
+window_setpos(obj, y, x)
+ VALUE obj;
+ VALUE y;
+ VALUE x;
{
struct windata *winp;
@@ -857,7 +915,8 @@ window_setpos(VALUE obj, VALUE y, VALUE x)
/* def cury */
static VALUE
-window_cury(VALUE obj)
+window_cury(obj)
+ VALUE obj;
{
struct windata *winp;
int x, y;
@@ -869,7 +928,8 @@ window_cury(VALUE obj)
/* def curx */
static VALUE
-window_curx(VALUE obj)
+window_curx(obj)
+ VALUE obj;
{
struct windata *winp;
int x, y;
@@ -881,7 +941,8 @@ window_curx(VALUE obj)
/* def maxy */
static VALUE
-window_maxy(VALUE obj)
+window_maxy(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -901,7 +962,8 @@ window_maxy(VALUE obj)
/* def maxx */
static VALUE
-window_maxx(VALUE obj)
+window_maxx(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -921,7 +983,8 @@ window_maxx(VALUE obj)
/* def begy */
static VALUE
-window_begy(VALUE obj)
+window_begy(obj)
+ VALUE obj;
{
struct windata *winp;
int x, y;
@@ -937,7 +1000,8 @@ window_begy(VALUE obj)
/* def begx */
static VALUE
-window_begx(VALUE obj)
+window_begx(obj)
+ VALUE obj;
{
struct windata *winp;
int x, y;
@@ -953,7 +1017,9 @@ window_begx(VALUE obj)
/* def box(vert, hor) */
static VALUE
-window_box(int argc, VALUE *argv, VALUE self)
+window_box(argc, argv, self)
+ int argc;
+ VALUE argv[], self;
{
struct windata *winp;
VALUE vert, hor, corn;
@@ -987,7 +1053,8 @@ window_box(int argc, VALUE *argv, VALUE self)
/* def standout */
static VALUE
-window_standout(VALUE obj)
+window_standout(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -998,7 +1065,8 @@ window_standout(VALUE obj)
/* def standend */
static VALUE
-window_standend(VALUE obj)
+window_standend(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -1009,7 +1077,8 @@ window_standend(VALUE obj)
/* def inch */
static VALUE
-window_inch(VALUE obj)
+window_inch(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -1019,7 +1088,9 @@ window_inch(VALUE obj)
/* def addch(ch) */
static VALUE
-window_addch(VALUE obj, VALUE ch)
+window_addch(obj, ch)
+ VALUE obj;
+ VALUE ch;
{
struct windata *winp;
@@ -1031,7 +1102,9 @@ window_addch(VALUE obj, VALUE ch)
/* def insch(ch) */
static VALUE
-window_insch(VALUE obj, VALUE ch)
+window_insch(obj, ch)
+ VALUE obj;
+ VALUE ch;
{
struct windata *winp;
@@ -1043,7 +1116,9 @@ window_insch(VALUE obj, VALUE ch)
/* def addstr(str) */
static VALUE
-window_addstr(VALUE obj, VALUE str)
+window_addstr(obj, str)
+ VALUE obj;
+ VALUE str;
{
if (!NIL_P(str)) {
struct windata *winp;
@@ -1056,7 +1131,9 @@ window_addstr(VALUE obj, VALUE str)
/* def <<(str) */
static VALUE
-window_addstr2(VALUE obj, VALUE str)
+window_addstr2(obj, str)
+ VALUE obj;
+ VALUE str;
{
window_addstr(obj, str);
return obj;
@@ -1064,7 +1141,8 @@ window_addstr2(VALUE obj, VALUE str)
/* def getch */
static VALUE
-window_getch(VALUE obj)
+window_getch(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -1075,7 +1153,8 @@ window_getch(VALUE obj)
/* def getstr */
static VALUE
-window_getstr(VALUE obj)
+window_getstr(obj)
+ VALUE obj;
{
struct windata *winp;
char rtn[1024]; /* This should be big enough.. I hope */
@@ -1092,7 +1171,8 @@ window_getstr(VALUE obj)
/* def delch */
static VALUE
-window_delch(VALUE obj)
+window_delch(obj)
+ VALUE obj;
{
struct windata *winp;
@@ -1103,7 +1183,8 @@ window_delch(VALUE obj)
/* def delelteln */
static VALUE
-window_deleteln(VALUE obj)
+window_deleteln(obj)
+ VALUE obj;
{
#if defined(HAVE_WDELETELN) || defined(wdeleteln)
struct windata *winp;
@@ -1116,7 +1197,8 @@ window_deleteln(VALUE obj)
/* def insertln */
static VALUE
-window_insertln(VALUE obj)
+window_insertln(obj)
+ VALUE obj;
{
#if defined(HAVE_WINSERTLN) || defined(winsertln)
struct windata *winp;
@@ -1174,7 +1256,7 @@ window_color_set(VALUE obj, VALUE col)
res = wcolor_set(winp->window, NUM2INT(col), NULL);
return (res == OK) ? Qtrue : Qfalse;
}
-#endif /* defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) */
+#endif /* USE_COLOR */
static VALUE
window_scroll(VALUE obj)
@@ -1357,7 +1439,7 @@ window_timeout(VALUE obj, VALUE delay)
/*------------------------- Initialization -------------------------*/
void
-Init_curses(void)
+Init_curses()
{
mCurses = rb_define_module("Curses");
mKey = rb_define_module_under(mCurses, "Key");
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 1b7d2d3706..0124bbbf4a 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -5,7 +5,6 @@ dir_config('ncurses')
dir_config('termcap')
make=false
-headers = []
have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM
have_library("tinfo", "tgetent") or have_library("termcap", "tgetent")
if have_header(*curses=%w"ncurses.h") and have_library("ncurses", "initscr")
diff --git a/ext/dbm/.cvsignore b/ext/dbm/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/dbm/.cvsignore
+++ b/ext/dbm/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index e89f8b1d74..0247387fdc 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -32,7 +32,7 @@ struct dbmdata {
};
static void
-closed_dbm(void)
+closed_dbm()
{
rb_raise(rb_eDBMError, "closed DBM file");
}
@@ -49,7 +49,8 @@ closed_dbm(void)
}
static void
-free_dbm(struct dbmdata *dbmp)
+free_dbm(dbmp)
+ struct dbmdata *dbmp;
{
if (dbmp) {
if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
@@ -58,7 +59,8 @@ free_dbm(struct dbmdata *dbmp)
}
static VALUE
-fdbm_close(VALUE obj)
+fdbm_close(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
@@ -70,7 +72,8 @@ fdbm_close(VALUE obj)
}
static VALUE
-fdbm_closed(VALUE obj)
+fdbm_closed(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
@@ -83,14 +86,19 @@ fdbm_closed(VALUE obj)
return Qfalse;
}
+static VALUE fdbm_alloc _((VALUE));
static VALUE
-fdbm_alloc(VALUE klass)
+fdbm_alloc(klass)
+ VALUE klass;
{
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
}
static VALUE
-fdbm_initialize(int argc, VALUE *argv, VALUE obj)
+fdbm_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE file, vmode, vflags;
DBM *dbm;
@@ -114,24 +122,24 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
if (flags & RUBY_DBM_RW_BIT) {
flags &= ~RUBY_DBM_RW_BIT;
- dbm = dbm_open(RSTRING_PTR(file), flags, mode);
+ dbm = dbm_open(RSTRING(file)->ptr, flags, mode);
}
else {
dbm = 0;
if (mode >= 0) {
- dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode);
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
}
if (!dbm) {
- dbm = dbm_open(RSTRING_PTR(file), O_RDWR, 0);
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, 0);
}
if (!dbm) {
- dbm = dbm_open(RSTRING_PTR(file), O_RDONLY, 0);
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, 0);
}
}
if (!dbm) {
if (mode == -1) return Qnil;
- rb_sys_fail(RSTRING_PTR(file));
+ rb_sys_fail(RSTRING(file)->ptr);
}
dbmp = ALLOC(struct dbmdata);
@@ -143,7 +151,10 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-fdbm_s_open(int argc, VALUE *argv, VALUE klass)
+fdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
@@ -159,15 +170,16 @@ fdbm_s_open(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
+fdbm_fetch(obj, keystr, ifnone)
+ VALUE obj, keystr, ifnone;
{
datum key, value;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
value = dbm_fetch(dbm, key);
@@ -180,13 +192,17 @@ fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
}
static VALUE
-fdbm_aref(VALUE obj, VALUE keystr)
+fdbm_aref(obj, keystr)
+ VALUE obj, keystr;
{
return fdbm_fetch(obj, keystr, Qnil);
}
static VALUE
-fdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
+fdbm_fetch_m(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE keystr, valstr, ifnone;
@@ -199,21 +215,22 @@ fdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-fdbm_index(VALUE obj, VALUE valstr)
+fdbm_index(obj, valstr)
+ VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(valstr);
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(valstr);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
GetDBM2(obj, dbmp, dbm);
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- if (val.dsize == RSTRING_LEN(valstr) &&
- memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) {
+ if (val.dsize == RSTRING(valstr)->len &&
+ memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0) {
return rb_tainted_str_new(key.dptr, key.dsize);
}
}
@@ -221,31 +238,68 @@ fdbm_index(VALUE obj, VALUE valstr)
}
static VALUE
-fdbm_select(VALUE obj)
+fdbm_indexes(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
- VALUE new = rb_ary_new();
- datum key, val;
- DBM *dbm;
- struct dbmdata *dbmp;
+ VALUE new;
+ int i;
- GetDBM2(obj, dbmp, dbm);
- for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
- VALUE assoc, v;
- val = dbm_fetch(dbm, key);
- assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
- rb_tainted_str_new(val.dptr, val.dsize));
- v = rb_yield(assoc);
- if (RTEST(v)) {
- rb_ary_push(new, assoc);
+ new = rb_ary_new2(argc);
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
+ }
+
+ return new;
+}
+
+static VALUE
+fdbm_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ if (rb_block_given_p()) {
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
}
- GetDBM2(obj, dbmp, dbm);
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ VALUE assoc, v;
+ val = dbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ v = rb_yield(assoc);
+ if (RTEST(v)) {
+ rb_ary_push(new, assoc);
+ }
+ GetDBM2(obj, dbmp, dbm);
+ }
+ }
+ else {
+ rb_warn("DBM#select(index..) is deprecated; use DBM#values_at");
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
+ }
}
return new;
}
static VALUE
-fdbm_values_at(int argc, VALUE *argv, VALUE obj)
+fdbm_values_at(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE new = rb_ary_new2(argc);
int i;
@@ -258,14 +312,16 @@ fdbm_values_at(int argc, VALUE *argv, VALUE obj)
}
static void
-fdbm_modify(VALUE obj)
+fdbm_modify(obj)
+ VALUE obj;
{
rb_secure(4);
if (OBJ_FROZEN(obj)) rb_error_frozen("DBM");
}
static VALUE
-fdbm_delete(VALUE obj, VALUE keystr)
+fdbm_delete(obj, keystr)
+ VALUE obj, keystr;
{
datum key, value;
struct dbmdata *dbmp;
@@ -274,11 +330,10 @@ fdbm_delete(VALUE obj, VALUE keystr)
fdbm_modify(obj);
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
-
value = dbm_fetch(dbm, key);
if (value.dptr == 0) {
if (rb_block_given_p()) return rb_yield(keystr);
@@ -299,7 +354,8 @@ fdbm_delete(VALUE obj, VALUE keystr)
}
static VALUE
-fdbm_shift(VALUE obj)
+fdbm_shift(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -321,7 +377,8 @@ fdbm_shift(VALUE obj)
}
static VALUE
-fdbm_delete_if(VALUE obj)
+fdbm_delete_if(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -345,23 +402,24 @@ fdbm_delete_if(VALUE obj)
GetDBM2(obj, dbmp, dbm);
}
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- keystr = RARRAY_PTR(ary)[i];
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ keystr = RARRAY(ary)->ptr[i];
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
if (dbm_delete(dbm, key)) {
rb_raise(rb_eDBMError, "dbm_delete failed");
}
}
if (status) rb_jump_tag(status);
- if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
+ if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
return obj;
}
static VALUE
-fdbm_clear(VALUE obj)
+fdbm_clear(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -381,7 +439,8 @@ fdbm_clear(VALUE obj)
}
static VALUE
-fdbm_invert(VALUE obj)
+fdbm_invert(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -399,36 +458,49 @@ fdbm_invert(VALUE obj)
return hash;
}
-static VALUE fdbm_store(VALUE,VALUE,VALUE);
+static VALUE each_pair _((VALUE));
+
+static VALUE
+each_pair(obj)
+ VALUE obj;
+{
+ return rb_funcall(obj, rb_intern("each_pair"), 0, 0);
+}
+
+static VALUE fdbm_store _((VALUE,VALUE,VALUE));
static VALUE
-update_i(VALUE pair, VALUE dbm)
+update_i(pair, dbm)
+ VALUE pair, dbm;
{
Check_Type(pair, T_ARRAY);
- if (RARRAY_LEN(pair) < 2) {
+ if (RARRAY(pair)->len < 2) {
rb_raise(rb_eArgError, "pair must be [key, value]");
}
- fdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
+ fdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
return Qnil;
}
static VALUE
-fdbm_update(VALUE obj, VALUE other)
+fdbm_update(obj, other)
+ VALUE obj, other;
{
- rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ rb_iterate(each_pair, other, update_i, obj);
return obj;
}
static VALUE
-fdbm_replace(VALUE obj, VALUE other)
+fdbm_replace(obj, other)
+ VALUE obj, other;
{
fdbm_clear(obj);
- rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ rb_iterate(each_pair, other, update_i, obj);
return obj;
}
static VALUE
-fdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
+fdbm_store(obj, keystr, valstr)
+ VALUE obj, keystr, valstr;
{
datum key, val;
struct dbmdata *dbmp;
@@ -438,11 +510,11 @@ fdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
keystr = rb_obj_as_string(keystr);
valstr = rb_obj_as_string(valstr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(valstr);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1;
@@ -458,7 +530,8 @@ fdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
}
static VALUE
-fdbm_length(VALUE obj)
+fdbm_length(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -477,7 +550,8 @@ fdbm_length(VALUE obj)
}
static VALUE
-fdbm_empty_p(VALUE obj)
+fdbm_empty_p(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -500,7 +574,8 @@ fdbm_empty_p(VALUE obj)
}
static VALUE
-fdbm_each_value(VALUE obj)
+fdbm_each_value(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -516,7 +591,8 @@ fdbm_each_value(VALUE obj)
}
static VALUE
-fdbm_each_key(VALUE obj)
+fdbm_each_key(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -531,7 +607,8 @@ fdbm_each_key(VALUE obj)
}
static VALUE
-fdbm_each_pair(VALUE obj)
+fdbm_each_pair(obj)
+ VALUE obj;
{
datum key, val;
DBM *dbm;
@@ -552,7 +629,8 @@ fdbm_each_pair(VALUE obj)
}
static VALUE
-fdbm_keys(VALUE obj)
+fdbm_keys(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -570,7 +648,8 @@ fdbm_keys(VALUE obj)
}
static VALUE
-fdbm_values(VALUE obj)
+fdbm_values(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -588,15 +667,16 @@ fdbm_values(VALUE obj)
}
static VALUE
-fdbm_has_key(VALUE obj, VALUE keystr)
+fdbm_has_key(obj, keystr)
+ VALUE obj, keystr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
val = dbm_fetch(dbm, key);
@@ -605,28 +685,30 @@ fdbm_has_key(VALUE obj, VALUE keystr)
}
static VALUE
-fdbm_has_value(VALUE obj, VALUE valstr)
+fdbm_has_value(obj, valstr)
+ VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(valstr);
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(valstr);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
GetDBM2(obj, dbmp, dbm);
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
- if (val.dsize == RSTRING_LEN(valstr) &&
- memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
+ if (val.dsize == RSTRING(valstr)->len &&
+ memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
return Qtrue;
}
return Qfalse;
}
static VALUE
-fdbm_to_a(VALUE obj)
+fdbm_to_a(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -645,7 +727,8 @@ fdbm_to_a(VALUE obj)
}
static VALUE
-fdbm_to_hash(VALUE obj)
+fdbm_to_hash(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -664,13 +747,14 @@ fdbm_to_hash(VALUE obj)
}
static VALUE
-fdbm_reject(VALUE obj)
+fdbm_reject(obj)
+ VALUE obj;
{
return rb_hash_delete_if(fdbm_to_hash(obj));
}
void
-Init_dbm(void)
+Init_dbm()
{
rb_cDBM = rb_define_class("DBM", rb_cObject);
rb_eDBMError = rb_define_class("DBMError", rb_eStandardError);
@@ -687,7 +771,9 @@ Init_dbm(void)
rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);
rb_define_method(rb_cDBM, "store", fdbm_store, 2);
rb_define_method(rb_cDBM, "index", fdbm_index, 1);
- rb_define_method(rb_cDBM, "select", fdbm_select, 0);
+ rb_define_method(rb_cDBM, "indexes", fdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "indices", fdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "select", fdbm_select, -1);
rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fdbm_length, 0);
rb_define_method(rb_cDBM, "size", fdbm_length, 0);
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 4d12264063..0074ab605b 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -36,7 +36,7 @@ def headers.db_check(db)
db_prefix ||= ""
if (have_library(db, db_prefix+"dbm_open") || have_func(db_prefix+"dbm_open")) and
- hdr = self.fetch(db, ["ndbm.h"]).find {|h| have_type("DBM", h, hsearch)}
+ 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+'>"'
diff --git a/ext/digest/.cvsignore b/ext/digest/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/digest/.cvsignore
+++ b/ext/digest/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/digest/bubblebabble/.cvsignore b/ext/digest/bubblebabble/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/digest/bubblebabble/.cvsignore
+++ b/ext/digest/bubblebabble/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 41565759bb..0b910e8c47 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -426,7 +426,7 @@ get_digest_base_metadata(VALUE klass)
VALUE obj;
rb_digest_metadata_t *algo;
- for (p = klass; p; p = RCLASS_SUPER(p)) {
+ for (p = klass; p; p = RCLASS(p)->super) {
if (rb_ivar_defined(p, id_metadata)) {
obj = rb_ivar_get(p, id_metadata);
break;
diff --git a/ext/digest/extconf.rb b/ext/digest/extconf.rb
index a20ca8d68f..cf9127ecc0 100644
--- a/ext/digest/extconf.rb
+++ b/ext/digest/extconf.rb
@@ -4,7 +4,7 @@
require "mkmf"
$INSTALLFILES = {
- "digest.h" => "$(HDRDIR)"
+ "digest.h" => "$(RUBYARCHDIR)"
}
create_makefile("digest")
diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb
deleted file mode 100644
index cdd537689c..0000000000
--- a/ext/digest/lib/digest/hmac.rb
+++ /dev/null
@@ -1,274 +0,0 @@
-# = digest/hmac.rb
-#
-# An implementation of HMAC keyed-hashing algorithm
-#
-# == Overview
-#
-# This library adds a method named hmac() to Digest classes, which
-# creates a Digest class for calculating HMAC digests.
-#
-# == Examples
-#
-# require 'digest/hmac'
-#
-# # one-liner example
-# puts Digest::HMAC.hexdigest("data", "hash key", Digest::SHA1)
-#
-# # rather longer one
-# hmac = Digest::HMAC.new("foo", Digest::RMD160)
-#
-# buf = ""
-# while stream.read(16384, buf)
-# hmac.update(buf)
-# end
-#
-# puts hmac.bubblebabble
-#
-# == License
-#
-# Copyright (c) 2006 Akinori MUSHA <knu@iDaemons.org>
-#
-# Documentation by Akinori MUSHA
-#
-# All rights reserved. You can redistribute and/or modify it under
-# the same terms as Ruby.
-#
-# $Id$
-#
-
-require 'digest'
-
-module Digest
- class HMAC < Digest::Class
- def initialize(key, digester)
- @md = digester.new
-
- block_len = @md.block_length
-
- if key.length > block_len
- key = @md.digest(key)
- end
-
- ipad = Array.new(block_len).fill(0x36)
- opad = Array.new(block_len).fill(0x5c)
-
- key.bytes.each_with_index { |c, i|
- ipad[i] ^= c
- opad[i] ^= c
- }
-
- @key = key.freeze
- @ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
- @opad = opad.inject('') { |s, c| s << c.chr }.freeze
- @md.update(@ipad)
- end
-
- def initialize_copy(other)
- @md = other.instance_eval { @md.clone }
- end
-
- def update(text)
- @md.update(text)
- self
- end
- alias << update
-
- def reset
- @md.reset
- @md.update(@ipad)
- self
- end
-
- def finish
- d = @md.digest!
- @md.update(@opad)
- @md.update(d)
- @md.digest!
- end
- private :finish
-
- def digest_length
- @md.digest_length
- end
-
- def block_length
- @md.block_length
- end
-
- def inspect
- sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 });
- end
- end
-end
-
-if $0 == __FILE__
- eval DATA.read, nil, $0, __LINE__+4
-end
-
-__END__
-
-require 'test/unit'
-
-module TM_HMAC
- def test_s_hexdigest
- cases.each { |h|
- digesters.each { |d|
- assert_equal(h[:hexdigest], Digest::HMAC.hexdigest(h[:data], h[:key], d))
- }
- }
- end
-
- def test_hexdigest
- cases.each { |h|
- digesters.each { |d|
- hmac = Digest::HMAC.new(h[:key], d)
-
- hmac.update(h[:data])
-
- assert_equal(h[:hexdigest], hmac.hexdigest)
- }
- }
- end
-
- def test_reset
- cases.each { |h|
- digesters.each { |d|
- hmac = Digest::HMAC.new(h[:key], d)
- hmac.update("test")
- hmac.reset
- hmac.update(h[:data])
-
- assert_equal(h[:hexdigest], hmac.hexdigest)
- }
- }
- end
-end
-
-class TC_HMAC_MD5 < Test::Unit::TestCase
- include TM_HMAC
-
- def digesters
- [Digest::MD5, Digest::MD5.new]
- end
-
- # Taken from RFC 2202: Test Cases for HMAC-MD5 and HMAC-SHA-1
- def cases
- [
- {
- :key => "\x0b" * 16,
- :data => "Hi There",
- :hexdigest => "9294727a3638bb1c13f48ef8158bfc9d",
- }, {
- :key => "Jefe",
- :data => "what do ya want for nothing?",
- :hexdigest => "750c783e6ab0b503eaa86e310a5db738",
- }, {
- :key => "\xaa" * 16,
- :data => "\xdd" * 50,
- :hexdigest => "56be34521d144c88dbb8c733f0e8b3f6",
- }, {
- :key => "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19",
- :data => "\xcd" * 50,
- :hexdigest => "697eaf0aca3a3aea3a75164746ffaa79",
- }, {
- :key => "\x0c" * 16,
- :data => "Test With Truncation",
- :hexdigest => "56461ef2342edc00f9bab995690efd4c",
- }, {
- :key => "\xaa" * 80,
- :data => "Test Using Larger Than Block-Size Key - Hash Key First",
- :hexdigest => "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd",
- }, {
- :key => "\xaa" * 80,
- :data => "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
- :hexdigest => "6f630fad67cda0ee1fb1f562db3aa53e",
- }
- ]
- end
-end
-
-class TC_HMAC_SHA1 < Test::Unit::TestCase
- include TM_HMAC
-
- def digesters
- [Digest::SHA1, Digest::SHA1.new]
- end
-
- # Taken from RFC 2202: Test Cases for HMAC-MD5 and HMAC-SHA-1
- def cases
- [
- {
- :key => "\x0b" * 20,
- :data => "Hi There",
- :hexdigest => "b617318655057264e28bc0b6fb378c8ef146be00",
- }, {
- :key => "Jefe",
- :data => "what do ya want for nothing?",
- :hexdigest => "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79",
- }, {
- :key => "\xaa" * 20,
- :data => "\xdd" * 50,
- :hexdigest => "125d7342b9ac11cd91a39af48aa17b4f63f175d3",
- }, {
- :key => "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19",
- :data => "\xcd" * 50,
- :hexdigest => "4c9007f4026250c6bc8414f9bf50c86c2d7235da",
- }, {
- :key => "\x0c" * 20,
- :data => "Test With Truncation",
- :hexdigest => "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04",
- }, {
- :key => "\xaa" * 80,
- :data => "Test Using Larger Than Block-Size Key - Hash Key First",
- :hexdigest => "aa4ae5e15272d00e95705637ce8a3b55ed402112",
- }, {
- :key => "\xaa" * 80,
- :data => "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
- :hexdigest => "e8e99d0f45237d786d6bbaa7965c7808bbff1a91",
- }
- ]
- end
-end
-
-class TC_HMAC_RMD160 < Test::Unit::TestCase
- include TM_HMAC
-
- def digesters
- [Digest::RMD160, Digest::RMD160.new]
- end
-
- # Taken from RFC 2286: Test Cases for HMAC-RIPEMD160 and HMAC-RIPEMD128
- def cases
- [
- {
- :key => "\x0b" * 20,
- :data => "Hi There",
- :hexdigest => "24cb4bd67d20fc1a5d2ed7732dcc39377f0a5668",
- }, {
- :key => "Jefe",
- :data => "what do ya want for nothing?",
- :hexdigest => "dda6c0213a485a9e24f4742064a7f033b43c4069",
- }, {
- :key => "\xaa" * 20,
- :data => "\xdd" * 50,
- :hexdigest => "b0b105360de759960ab4f35298e116e295d8e7c1",
- }, {
- :key => "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19",
- :data => "\xcd" * 50,
- :hexdigest => "d5ca862f4d21d5e610e18b4cf1beb97a4365ecf4",
- }, {
- :key => "\x0c" * 20,
- :data => "Test With Truncation",
- :hexdigest => "7619693978f91d90539ae786500ff3d8e0518e39",
- }, {
- :key => "\xaa" * 80,
- :data => "Test Using Larger Than Block-Size Key - Hash Key First",
- :hexdigest => "6466ca07ac5eac29e1bd523e5ada7605b791fd8b",
- }, {
- :key => "\xaa" * 80,
- :data => "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
- :hexdigest => "69ea60798d71616cce5fd0871e23754cd75d5a0a",
- }
- ]
- end
-end
diff --git a/ext/digest/lib/md5.rb b/ext/digest/lib/md5.rb
new file mode 100644
index 0000000000..c399f2de1d
--- /dev/null
+++ b/ext/digest/lib/md5.rb
@@ -0,0 +1,23 @@
+# just for compatibility; requiring "md5" is obsoleted
+#
+# $RoughId: md5.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
+# $Id$
+
+require 'digest/md5'
+
+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
+
+ def md5(*args)
+ new(*args)
+ end
+ end
+end
diff --git a/ext/digest/lib/sha1.rb b/ext/digest/lib/sha1.rb
new file mode 100644
index 0000000000..4446e12e8d
--- /dev/null
+++ b/ext/digest/lib/sha1.rb
@@ -0,0 +1,23 @@
+# just for compatibility; requiring "sha1" is obsoleted
+#
+# $RoughId: sha1.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
+# $Id$
+
+require 'digest/sha1'
+
+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
+
+ def sha1(*args)
+ new(*args)
+ end
+ end
+end
diff --git a/ext/digest/md5/.cvsignore b/ext/digest/md5/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/digest/md5/.cvsignore
+++ b/ext/digest/md5/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/digest/rmd160/.cvsignore b/ext/digest/rmd160/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/digest/rmd160/.cvsignore
+++ b/ext/digest/rmd160/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/digest/sha1/.cvsignore b/ext/digest/sha1/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/digest/sha1/.cvsignore
+++ b/ext/digest/sha1/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/digest/sha2/.cvsignore b/ext/digest/sha2/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/digest/sha2/.cvsignore
+++ b/ext/digest/sha2/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/dl/.cvsignore b/ext/dl/.cvsignore
index 6c0b25a1c5..6d884b6cec 100644
--- a/ext/dl/.cvsignore
+++ b/ext/dl/.cvsignore
@@ -2,9 +2,7 @@ Makefile
mkmf.log
dlconfig.h
dlconfig.rb
-callback.h
*.func
*.o
*~
*.def
-extconf.h
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
deleted file mode 100644
index 22e8600002..0000000000
--- a/ext/dl/cfunc.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/* -*- C -*-
- * $Id$
- */
-
-#include <ruby.h>
-#include <errno.h>
-#include "dl.h"
-
-VALUE rb_cDLCFunc;
-
-static ID id_last_error;
-
-static VALUE
-rb_dl_get_last_error(VALUE self)
-{
- return rb_thread_local_aref(rb_thread_current(), id_last_error);
-}
-
-static VALUE
-rb_dl_set_last_error(VALUE self, VALUE val)
-{
- rb_thread_local_aset(rb_thread_current(), id_last_error, val);
- return Qnil;
-}
-
-#if defined(HAVE_WINDOWS_H)
-#include <windows.h>
-static ID id_win32_last_error;
-
-static VALUE
-rb_dl_get_win32_last_error(VALUE self)
-{
- return rb_thread_local_aref(rb_thread_current(), id_win32_last_error);
-}
-
-static VALUE
-rb_dl_set_win32_last_error(VALUE self, VALUE val)
-{
- rb_thread_local_aset(rb_thread_current(), id_win32_last_error, val);
- return Qnil;
-}
-#endif
-
-
-void
-dlcfunc_free(struct cfunc_data *data)
-{
- if( data->name ){
- xfree(data->name);
- }
- xfree(data);
-}
-
-VALUE
-rb_dlcfunc_new(void (*func)(), int type, const char *name, ID calltype)
-{
- VALUE val;
- struct cfunc_data *data;
-
- rb_secure(4);
- if( func ){
- val = Data_Make_Struct(rb_cDLCFunc, struct cfunc_data, 0, dlcfunc_free, data);
- data->ptr = func;
- data->name = name ? strdup(name) : NULL;
- data->type = type;
- data->calltype = calltype;
- }
- else{
- val = Qnil;
- }
-
- return val;
-}
-
-void *
-rb_dlcfunc2ptr(VALUE val)
-{
- struct cfunc_data *data;
- void * func;
-
- if( rb_obj_is_kind_of(val, rb_cDLCFunc) ){
- Data_Get_Struct(val, struct cfunc_data, data);
- func = data->ptr;
- }
- else if( val == Qnil ){
- func = NULL;
- }
- else{
- rb_raise(rb_eTypeError, "DL::CFunc was expected");
- }
-
- return func;
-}
-
-VALUE
-rb_dlcfunc_s_allocate(VALUE klass)
-{
- VALUE obj;
- struct cfunc_data *data;
-
- obj = Data_Make_Struct(klass, struct cfunc_data, 0, dlcfunc_free, data);
- data->ptr = 0;
- data->name = 0;
- data->type = 0;
- data->calltype = CFUNC_CDECL;
-
- return obj;
-}
-
-VALUE
-rb_dlcfunc_initialize(int argc, VALUE argv[], VALUE self)
-{
- VALUE addr, name, type, calltype;
- struct cfunc_data *data;
- void *saddr;
- const char *sname;
-
- rb_scan_args(argc, argv, "13", &addr, &type, &name, &calltype);
-
- saddr = (void*)(NUM2PTR(rb_Integer(addr)));
- sname = NIL_P(name) ? NULL : StringValuePtr(name);
-
- Data_Get_Struct(self, struct cfunc_data, data);
- if( data->name ) xfree(data->name);
- data->ptr = saddr;
- data->name = sname ? strdup(sname) : 0;
- data->type = (type == Qnil) ? DLTYPE_VOID : NUM2INT(type);
- data->calltype = (calltype == Qnil) ? CFUNC_CDECL : SYM2ID(calltype);
-
- return Qnil;
-}
-
-VALUE
-rb_dlcfunc_name(VALUE self)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- return cfunc->name ? rb_tainted_str_new2(cfunc->name) : Qnil;
-}
-
-VALUE
-rb_dlcfunc_ctype(VALUE self)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- return INT2NUM(cfunc->type);
-}
-
-VALUE
-rb_dlcfunc_set_ctype(VALUE self, VALUE ctype)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- cfunc->type = NUM2INT(ctype);
- return ctype;
-}
-
-VALUE
-rb_dlcfunc_calltype(VALUE self)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- return ID2SYM(cfunc->calltype);
-}
-
-VALUE
-rb_dlcfunc_set_calltype(VALUE self, VALUE sym)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- cfunc->calltype = SYM2ID(sym);
- return sym;
-}
-
-
-VALUE
-rb_dlcfunc_ptr(VALUE self)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- return PTR2NUM(cfunc->ptr);
-}
-
-VALUE
-rb_dlcfunc_set_ptr(VALUE self, VALUE addr)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- cfunc->ptr = NUM2PTR(addr);
-
- return Qnil;
-}
-
-VALUE
-rb_dlcfunc_inspect(VALUE self)
-{
- VALUE val;
- char *str;
- int str_size;
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
-
- str_size = (cfunc->name ? strlen(cfunc->name) : 0) + 100;
- str = ruby_xmalloc(str_size);
- snprintf(str, str_size - 1,
- "#<DL::CFunc:%p ptr=%p type=%d name='%s'>",
- cfunc,
- cfunc->ptr,
- cfunc->type,
- cfunc->name ? cfunc->name : "");
- val = rb_tainted_str_new2(str);
- ruby_xfree(str);
-
- return val;
-}
-
-
-# define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args)
-# define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*f))(args)
-
-#define CALL_CASE switch( RARRAY_LEN(ary) ){ \
- CASE(0); break; \
- CASE(1); break; CASE(2); break; CASE(3); break; CASE(4); break; CASE(5); break; \
- CASE(6); break; CASE(7); break; CASE(8); break; CASE(9); break; CASE(10);break; \
- CASE(11);break; CASE(12);break; CASE(13);break; CASE(14);break; CASE(15);break; \
- CASE(16);break; CASE(17);break; CASE(18);break; CASE(19);break; CASE(20);break; \
- default: rb_raise(rb_eArgError, "too many arguments"); \
-}
-
-
-VALUE
-rb_dlcfunc_call(VALUE self, VALUE ary)
-{
- struct cfunc_data *cfunc;
- int i;
- DLSTACK_TYPE stack[DLSTACK_SIZE];
- VALUE result = Qnil;
-
- rb_secure_update(self);
-
- memset(stack, 0, sizeof(DLSTACK_TYPE) * DLSTACK_SIZE);
- Check_Type(ary, T_ARRAY);
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
-
- if( cfunc->ptr == 0 ){
- rb_raise(rb_eDLError, "can't call null-function");
- return Qnil;
- }
-
- for( i = 0; i < RARRAY_LEN(ary); i++ ){
- if( i >= DLSTACK_SIZE ){
- rb_raise(rb_eDLError, "too many arguments (stack overflow)");
- }
- stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
- }
-
- /* calltype == CFUNC_CDECL */
- if( cfunc->calltype == CFUNC_CDECL ){
- switch( cfunc->type ){
- case DLTYPE_VOID:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,void,DLSTACK_PROTO##n) = cfunc->ptr; \
- f(DLSTACK_ARGS##n(stack)); \
- result = Qnil; \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_VOIDP:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,void*,DLSTACK_PROTO##n) = cfunc->ptr; \
- void * ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = PTR2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_CHAR:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,char,DLSTACK_PROTO##n) = cfunc->ptr; \
- char ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = CHR2FIX(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_SHORT:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,short,DLSTACK_PROTO##n) = cfunc->ptr; \
- short ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = INT2NUM((int)ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_INT:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,int,DLSTACK_PROTO##n) = cfunc->ptr; \
- int ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = INT2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_LONG:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,long,DLSTACK_PROTO##n) = cfunc->ptr; \
- long ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = LONG2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
-#if HAVE_LONG_LONG /* used in ruby.h */
- case DLTYPE_LONG_LONG:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,LONG_LONG,DLSTACK_PROTO) = cfunc->ptr; \
- LONG_LONG ret; \
- ret = f(DLSTACK_ARGS(stack)); \
- result = LL2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
-#endif
- case DLTYPE_FLOAT:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,float,DLSTACK_PROTO) = cfunc->ptr; \
- float ret; \
- ret = f(DLSTACK_ARGS(stack)); \
- result = rb_float_new(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_DOUBLE:
-#define CASE(n) case n: { \
- DECL_FUNC_CDECL(f,double,DLSTACK_PROTO) = cfunc->ptr; \
- double ret; \
- ret = f(DLSTACK_ARGS(stack)); \
- result = rb_float_new(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- default:
- rb_raise(rb_eDLTypeError, "unknown type %d", cfunc->type);
- }
- }
- else if( cfunc->calltype == CFUNC_STDCALL ){
- /* calltype == CFUNC_STDCALL */
- switch( cfunc->type ){
- case DLTYPE_VOID:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,void,DLSTACK_PROTO##n) = cfunc->ptr; \
- f(DLSTACK_ARGS##n(stack)); \
- result = Qnil; \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_VOIDP:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,void*,DLSTACK_PROTO##n) = cfunc->ptr; \
- void * ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = PTR2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_CHAR:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,char,DLSTACK_PROTO##n) = cfunc->ptr; \
- char ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = CHR2FIX(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_SHORT:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,short,DLSTACK_PROTO##n) = cfunc->ptr; \
- short ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = INT2NUM((int)ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_INT:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,int,DLSTACK_PROTO##n) = cfunc->ptr; \
- int ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = INT2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_LONG:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,long,DLSTACK_PROTO##n) = cfunc->ptr; \
- long ret; \
- ret = f(DLSTACK_ARGS##n(stack)); \
- result = LONG2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
-#if HAVE_LONG_LONG /* used in ruby.h */
- case DLTYPE_LONG_LONG:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,LONG_LONG,DLSTACK_PROTO) = cfunc->ptr; \
- LONG_LONG ret; \
- ret = f(DLSTACK_ARGS(stack)); \
- result = LL2NUM(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
-#endif
- case DLTYPE_FLOAT:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,float,DLSTACK_PROTO) = cfunc->ptr; \
- float ret; \
- ret = f(DLSTACK_ARGS(stack)); \
- result = rb_float_new(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- case DLTYPE_DOUBLE:
-#define CASE(n) case n: { \
- DECL_FUNC_STDCALL(f,double,DLSTACK_PROTO) = cfunc->ptr; \
- double ret; \
- ret = f(DLSTACK_ARGS(stack)); \
- result = rb_float_new(ret); \
-}
- CALL_CASE;
-#undef CASE
- break;
- default:
- rb_raise(rb_eDLTypeError, "unknown type %d", cfunc->type);
- }
- }
- else{
- rb_raise(rb_eDLError,
-#ifndef LONG_LONG_VALUE
- "unsupported call type: %lx",
-#else
- "unsupported call type: %llx",
-#endif
- cfunc->calltype);
- }
-
- rb_dl_set_last_error(self, INT2NUM(errno));
-#if defined(HAVE_WINDOWS_H)
- rb_dl_set_win32_last_error(self, INT2NUM(GetLastError()));
-#endif
-
- return result;
-}
-
-VALUE
-rb_dlcfunc_to_i(VALUE self)
-{
- struct cfunc_data *cfunc;
-
- Data_Get_Struct(self, struct cfunc_data, cfunc);
- return PTR2NUM(cfunc->ptr);
-}
-
-void
-Init_dlcfunc()
-{
- id_last_error = rb_intern("__DL2_LAST_ERROR__");
-#if defined(HAVE_WINDOWS_H)
- id_win32_last_error = rb_intern("__DL2_WIN32_LAST_ERROR__");
-#endif
- rb_cDLCFunc = rb_define_class_under(rb_mDL, "CFunc", rb_cObject);
- rb_define_alloc_func(rb_cDLCFunc, rb_dlcfunc_s_allocate);
- rb_define_module_function(rb_cDLCFunc, "last_error", rb_dl_get_last_error, 0);
-#if defined(HAVE_WINDOWS_H)
- rb_define_module_function(rb_cDLCFunc, "win32_last_error", rb_dl_get_win32_last_error, 0);
-#endif
- rb_define_method(rb_cDLCFunc, "initialize", rb_dlcfunc_initialize, -1);
- rb_define_method(rb_cDLCFunc, "call", rb_dlcfunc_call, 1);
- rb_define_method(rb_cDLCFunc, "[]", rb_dlcfunc_call, 1);
- rb_define_method(rb_cDLCFunc, "name", rb_dlcfunc_name, 0);
- rb_define_method(rb_cDLCFunc, "ctype", rb_dlcfunc_ctype, 0);
- rb_define_method(rb_cDLCFunc, "ctype=", rb_dlcfunc_set_ctype, 1);
- rb_define_method(rb_cDLCFunc, "calltype", rb_dlcfunc_calltype, 0);
- rb_define_method(rb_cDLCFunc, "calltype=", rb_dlcfunc_set_calltype, 1);
- rb_define_method(rb_cDLCFunc, "ptr", rb_dlcfunc_ptr, 0);
- rb_define_method(rb_cDLCFunc, "ptr=", rb_dlcfunc_set_ptr, 1);
- rb_define_method(rb_cDLCFunc, "inspect", rb_dlcfunc_inspect, 0);
- rb_define_method(rb_cDLCFunc, "to_s", rb_dlcfunc_inspect, 0);
- rb_define_method(rb_cDLCFunc, "to_i", rb_dlcfunc_to_i, 0);
-}
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c
deleted file mode 100644
index aeb1852b48..0000000000
--- a/ext/dl/cptr.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/* -*- C -*-
- * $Id$
- */
-
-#include <ruby/ruby.h>
-#include <ruby/io.h>
-#include <ctype.h>
-#include "dl.h"
-
-VALUE rb_cDLCPtr;
-
-static ID id_to_ptr;
-
-static void
-dlptr_free(struct ptr_data *data)
-{
- if (data->ptr) {
- if (data->free) {
- (*(data->free))(data->ptr);
- }
- }
-}
-
-static void
-dlptr_mark(struct ptr_data *data)
-{
-}
-
-void
-dlptr_init(VALUE val)
-{
- struct ptr_data *data;
-
- Data_Get_Struct(val, struct ptr_data, data);
- OBJ_TAINT(val);
-}
-
-VALUE
-rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
-{
- struct ptr_data *data;
- VALUE val;
-
- rb_secure(4);
- val = Data_Make_Struct(klass, struct ptr_data,
- 0, dlptr_free, data);
- data->ptr = ptr;
- data->free = func;
- data->size = size;
- dlptr_init(val);
-
- return val;
-}
-
-VALUE
-rb_dlptr_new(void *ptr, long size, freefunc_t func)
-{
- return rb_dlptr_new2(rb_cDLCPtr, ptr, size, func);
-}
-
-VALUE
-rb_dlptr_malloc(long size, freefunc_t func)
-{
- void *ptr;
-
- rb_secure(4);
- ptr = ruby_xmalloc((size_t)size);
- memset(ptr,0,(size_t)size);
- return rb_dlptr_new(ptr, size, func);
-}
-
-void *
-rb_dlptr2cptr(VALUE val)
-{
- struct ptr_data *data;
- void *ptr;
-
- if (rb_obj_is_kind_of(val, rb_cDLCPtr)) {
- Data_Get_Struct(val, struct ptr_data, data);
- ptr = data->ptr;
- }
- else if (val == Qnil) {
- ptr = NULL;
- }
- else{
- rb_raise(rb_eTypeError, "DL::PtrData was expected");
- }
-
- return ptr;
-}
-
-static VALUE
-rb_dlptr_s_allocate(VALUE klass)
-{
- VALUE obj;
- struct ptr_data *data;
-
- rb_secure(4);
- obj = Data_Make_Struct(klass, struct ptr_data, dlptr_mark, dlptr_free, data);
- data->ptr = 0;
- data->size = 0;
- data->free = 0;
-
- return obj;
-}
-
-static VALUE
-rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
-{
- VALUE ptr, sym, size;
- struct ptr_data *data;
- void *p = NULL;
- freefunc_t f = NULL;
- long s = 0;
-
- switch (rb_scan_args(argc, argv, "12", &ptr, &size, &sym)) {
- case 1:
- p = (void*)(NUM2PTR(rb_Integer(ptr)));
- break;
- case 2:
- p = (void*)(NUM2PTR(rb_Integer(ptr)));
- s = NUM2LONG(size);
- break;
- case 3:
- p = (void*)(NUM2PTR(rb_Integer(ptr)));
- s = NUM2LONG(size);
- f = NIL_P(sym) ? NULL : RCFUNC_DATA(sym)->ptr;
- break;
- default:
- rb_bug("rb_dlptr_initialize");
- }
-
- if (p) {
- Data_Get_Struct(self, struct ptr_data, data);
- if (data->ptr && data->free) {
- /* Free previous memory. Use of inappropriate initialize may cause SEGV. */
- (*(data->free))(data->ptr);
- }
- data->ptr = p;
- data->size = s;
- data->free = f;
- }
-
- return Qnil;
-}
-
-static VALUE
-rb_dlptr_s_malloc(int argc, VALUE argv[], VALUE klass)
-{
- VALUE size, sym, obj;
- int s;
- freefunc_t f;
-
- switch (rb_scan_args(argc, argv, "11", &size, &sym)) {
- case 1:
- s = NUM2LONG(size);
- f = NULL;
- break;
- case 2:
- s = NUM2LONG(size);
- f = RCFUNC_DATA(sym)->ptr;
- break;
- default:
- rb_bug("rb_dlptr_s_malloc");
- }
-
- obj = rb_dlptr_malloc(s,f);
-
- return obj;
-}
-
-VALUE
-rb_dlptr_to_i(VALUE self)
-{
- struct ptr_data *data;
-
- Data_Get_Struct(self, struct ptr_data, data);
- return PTR2NUM(data->ptr);
-}
-
-VALUE
-rb_dlptr_to_value(VALUE self)
-{
- struct ptr_data *data;
- Data_Get_Struct(self, struct ptr_data, data);
- return (VALUE)(data->ptr);
-}
-
-VALUE
-rb_dlptr_ptr(VALUE self)
-{
- struct ptr_data *data;
-
- Data_Get_Struct(self, struct ptr_data, data);
- return rb_dlptr_new(*((void**)(data->ptr)),0,0);
-}
-
-VALUE
-rb_dlptr_ref(VALUE self)
-{
- struct ptr_data *data;
-
- Data_Get_Struct(self, struct ptr_data, data);
- return rb_dlptr_new(&(data->ptr),0,0);
-}
-
-VALUE
-rb_dlptr_null_p(VALUE self)
-{
- struct ptr_data *data;
-
- Data_Get_Struct(self, struct ptr_data, data);
- return data->ptr ? Qfalse : Qtrue;
-}
-
-VALUE
-rb_dlptr_free_set(VALUE self, VALUE val)
-{
- struct ptr_data *data;
- extern VALUE rb_cDLCFunc;
-
- Data_Get_Struct(self, struct ptr_data, data);
- if( rb_obj_is_kind_of(val, rb_cDLCFunc) == Qtrue ){
- data->free = RCFUNC_DATA(val)->ptr;
- }
- else{
- data->free = NUM2PTR(rb_Integer(val));
- }
-
- return Qnil;
-}
-
-VALUE
-rb_dlptr_free_get(VALUE self)
-{
- struct ptr_data *pdata;
-
- Data_Get_Struct(self, struct ptr_data, pdata);
-
- return rb_dlcfunc_new(pdata->free, DLTYPE_VOID, "free<anonymous>", CFUNC_CDECL);
-}
-
-VALUE
-rb_dlptr_to_s(int argc, VALUE argv[], VALUE self)
-{
- struct ptr_data *data;
- VALUE arg1, val;
- int len;
-
- Data_Get_Struct(self, struct ptr_data, data);
- switch (rb_scan_args(argc, argv, "01", &arg1)) {
- case 0:
- val = rb_tainted_str_new2((char*)(data->ptr));
- break;
- case 1:
- len = NUM2INT(arg1);
- val = rb_tainted_str_new((char*)(data->ptr), len);
- break;
- default:
- rb_bug("rb_dlptr_to_s");
- }
-
- return val;
-}
-
-VALUE
-rb_dlptr_to_str(int argc, VALUE argv[], VALUE self)
-{
- struct ptr_data *data;
- VALUE arg1, val;
- int len;
-
- Data_Get_Struct(self, struct ptr_data, data);
- switch (rb_scan_args(argc, argv, "01", &arg1)) {
- case 0:
- val = rb_tainted_str_new((char*)(data->ptr),data->size);
- break;
- case 1:
- len = NUM2INT(arg1);
- val = rb_tainted_str_new((char*)(data->ptr), len);
- break;
- default:
- rb_bug("rb_dlptr_to_str");
- }
-
- return val;
-}
-
-VALUE
-rb_dlptr_inspect(VALUE self)
-{
- struct ptr_data *data;
- char str[1024];
-
- Data_Get_Struct(self, struct ptr_data, data);
- snprintf(str, 1023, "#<%s:%p ptr=%p size=%ld free=%p>",
- rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
- return rb_str_new2(str);
-}
-
-VALUE
-rb_dlptr_eql(VALUE self, VALUE other)
-{
- void *ptr1, *ptr2;
- ptr1 = rb_dlptr2cptr(self);
- ptr2 = rb_dlptr2cptr(other);
-
- return ptr1 == ptr2 ? Qtrue : Qfalse;
-}
-
-VALUE
-rb_dlptr_cmp(VALUE self, VALUE other)
-{
- void *ptr1, *ptr2;
- ptr1 = rb_dlptr2cptr(self);
- ptr2 = rb_dlptr2cptr(other);
- return PTR2NUM((long)ptr1 - (long)ptr2);
-}
-
-VALUE
-rb_dlptr_plus(VALUE self, VALUE other)
-{
- void *ptr;
- long num, size;
-
- ptr = rb_dlptr2cptr(self);
- size = RPTR_DATA(self)->size;
- num = NUM2LONG(other);
- return rb_dlptr_new((char *)ptr + num, size - num, 0);
-}
-
-VALUE
-rb_dlptr_minus(VALUE self, VALUE other)
-{
- void *ptr;
- long num, size;
-
- ptr = rb_dlptr2cptr(self);
- size = RPTR_DATA(self)->size;
- num = NUM2LONG(other);
- return rb_dlptr_new((char *)ptr - num, size + num, 0);
-}
-
-VALUE
-rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
-{
- VALUE arg0, arg1;
- VALUE retval = Qnil;
- size_t offset, len;
-
- switch( rb_scan_args(argc, argv, "11", &arg0, &arg1) ){
- case 1:
- offset = NUM2ULONG(arg0);
- retval = INT2NUM(*((char*)RPTR_DATA(self)->ptr + offset));
- break;
- case 2:
- offset = NUM2ULONG(arg0);
- len = NUM2ULONG(arg1);
- retval = rb_tainted_str_new((char *)RPTR_DATA(self)->ptr + offset, len);
- break;
- default:
- rb_bug("rb_dlptr_aref()");
- }
- return retval;
-}
-
-VALUE
-rb_dlptr_aset(int argc, VALUE argv[], VALUE self)
-{
- VALUE arg0, arg1, arg2;
- VALUE retval = Qnil;
- size_t offset, len;
- void *mem;
-
- switch( rb_scan_args(argc, argv, "21", &arg0, &arg1, &arg2) ){
- case 2:
- offset = NUM2ULONG(arg0);
- ((char*)RPTR_DATA(self)->ptr)[offset] = NUM2UINT(arg1);
- retval = arg1;
- break;
- case 3:
- offset = NUM2ULONG(arg0);
- len = NUM2ULONG(arg1);
- if( TYPE(arg2) == T_STRING ){
- mem = StringValuePtr(arg2);
- }
- else if( rb_obj_is_kind_of(arg2, rb_cDLCPtr) ){
- mem = rb_dlptr2cptr(arg2);
- }
- else{
- mem = NUM2PTR(arg2);
- }
- memcpy((char *)RPTR_DATA(self)->ptr + offset, mem, len);
- retval = arg2;
- break;
- default:
- rb_bug("rb_dlptr_aset()");
- }
- return retval;
-}
-
-VALUE
-rb_dlptr_size(int argc, VALUE argv[], VALUE self)
-{
- VALUE size;
-
- if (rb_scan_args(argc, argv, "01", &size) == 0){
- return LONG2NUM(RPTR_DATA(self)->size);
- }
- else{
- RPTR_DATA(self)->size = NUM2LONG(size);
- return size;
- }
-}
-
-VALUE
-rb_dlptr_s_to_ptr(VALUE self, VALUE val)
-{
- if( rb_obj_is_kind_of(val, rb_cIO) == Qtrue ){
- rb_io_t *fptr;
- FILE *fp;
- GetOpenFile(val, fptr);
- fp = rb_io_stdio_file(fptr);
- return rb_dlptr_new(fp, 0, NULL);
- }
- else if( rb_obj_is_kind_of(val, rb_cString) == Qtrue ){
- char *ptr = StringValuePtr(val);
- return rb_dlptr_new(ptr, RSTRING_LEN(val), NULL);
- }
- else if( rb_respond_to(val, id_to_ptr) ){
- VALUE vptr = rb_funcall(val, id_to_ptr, 0);
- if( rb_obj_is_kind_of(vptr, rb_cDLCPtr) ){
- return vptr;
- }
- else{
- rb_raise(rb_eDLError, "to_ptr should return a CPtr object");
- }
- }
- else{
- return rb_dlptr_new(NUM2PTR(rb_Integer(val)), 0, NULL);
- }
-}
-
-void
-Init_dlptr()
-{
- id_to_ptr = rb_intern("to_ptr");
-
- rb_cDLCPtr = rb_define_class_under(rb_mDL, "CPtr", rb_cObject);
- rb_define_alloc_func(rb_cDLCPtr, rb_dlptr_s_allocate);
- rb_define_singleton_method(rb_cDLCPtr, "malloc", rb_dlptr_s_malloc, -1);
- rb_define_singleton_method(rb_cDLCPtr, "to_ptr", rb_dlptr_s_to_ptr, 1);
- rb_define_singleton_method(rb_cDLCPtr, "[]", rb_dlptr_s_to_ptr, 1);
- rb_define_method(rb_cDLCPtr, "initialize", rb_dlptr_initialize, -1);
- rb_define_method(rb_cDLCPtr, "free=", rb_dlptr_free_set, 1);
- rb_define_method(rb_cDLCPtr, "free", rb_dlptr_free_get, 0);
- rb_define_method(rb_cDLCPtr, "to_i", rb_dlptr_to_i, 0);
- rb_define_method(rb_cDLCPtr, "to_value", rb_dlptr_to_value, 0);
- rb_define_method(rb_cDLCPtr, "ptr", rb_dlptr_ptr, 0);
- rb_define_method(rb_cDLCPtr, "+@", rb_dlptr_ptr, 0);
- rb_define_method(rb_cDLCPtr, "ref", rb_dlptr_ref, 0);
- rb_define_method(rb_cDLCPtr, "-@", rb_dlptr_ref, 0);
- rb_define_method(rb_cDLCPtr, "null?", rb_dlptr_null_p, 0);
- rb_define_method(rb_cDLCPtr, "to_s", rb_dlptr_to_s, -1);
- rb_define_method(rb_cDLCPtr, "to_str", rb_dlptr_to_str, -1);
- rb_define_method(rb_cDLCPtr, "inspect", rb_dlptr_inspect, 0);
- rb_define_method(rb_cDLCPtr, "<=>", rb_dlptr_cmp, 1);
- rb_define_method(rb_cDLCPtr, "==", rb_dlptr_eql, 1);
- rb_define_method(rb_cDLCPtr, "eql?", rb_dlptr_eql, 1);
- rb_define_method(rb_cDLCPtr, "+", rb_dlptr_plus, 1);
- rb_define_method(rb_cDLCPtr, "-", rb_dlptr_minus, 1);
- rb_define_method(rb_cDLCPtr, "[]", rb_dlptr_aref, -1);
- rb_define_method(rb_cDLCPtr, "[]=", rb_dlptr_aset, -1);
- rb_define_method(rb_cDLCPtr, "size", rb_dlptr_size, -1);
- rb_define_method(rb_cDLCPtr, "size=", rb_dlptr_size, -1);
-
- rb_define_const(rb_mDL, "NULL", rb_dlptr_new(0, 0, 0));
-}
diff --git a/ext/dl/depend b/ext/dl/depend
index fe89a9fae3..fba3df7a3d 100644
--- a/ext/dl/depend
+++ b/ext/dl/depend
@@ -1,11 +1,46 @@
-cfunc.o: cfunc.c dl.h $(hdrdir)/ruby.h
+LDSHARED_TEST = $(LDSHARED) $(LDFLAGS) test/test.o -o test/libtest.so $(LOCAL_LIBS)
-cptr.o: cptr.c dl.h $(hdrdir)/ruby.h $(hdrdir)/io.h
+libtest.so: test/libtest.so
-handle.o: handle.c dl.h $(hdrdir)/ruby.h
+test/libtest.so: test/test.o $(srcdir)/test/libtest.def
+ $(RUBY) -rftools -e 'ARGV.each do|d|File.mkpath(File.dirname(d))end' $@
+ $(LDSHARED_TEST:dl.def=test/libtest.def)
-dl.o: dl.c dl.h callback.h $(hdrdir)/ruby.h $(hdrdir)/io.h
+test/test.o: $(srcdir)/test/test.c
+ @$(RUBY) -rftools -e 'File.mkpath(*ARGV)' test
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/test/test.c -o $@
-callback.h: $(srcdir)/mkcallback.rb dl.h
- @echo "generating callback.h"
- @$(RUBY) $(srcdir)/mkcallback.rb $(srcdir)/dl.h > $@
+test:: dl.so libtest.so force
+ $(RUBY) -I. -I$(srcdir)/lib $(srcdir)/test/test.rb
+
+force:
+
+.PHONY: force test
+
+allclean: distclean
+ @rm -f $(CLEANFILES) $(DISTCLEANFILES)
+
+$(OBJS): ./dlconfig.h
+
+sym.o: dl.h call.func
+
+dl.o: dl.h callback.func cbtable.func
+
+ptr.o: dl.h
+
+handle.o: dl.h
+
+call.func: $(srcdir)/mkcall.rb ./dlconfig.rb
+ @echo "Generating call.func"
+ @$(RUBY) $(srcdir)/mkcall.rb > $@
+
+callback.func: $(srcdir)/mkcallback.rb ./dlconfig.rb
+ @echo "Generating callback.func"
+ @$(RUBY) $(srcdir)/mkcallback.rb > $@
+
+cbtable.func: $(srcdir)/mkcbtable.rb ./dlconfig.rb
+ @echo "Generating cbtable.func"
+ @$(RUBY) $(srcdir)/mkcbtable.rb > $@
+
+debug:
+ $(MAKE) CPPFLAGS="$(CPPFLAGS) -DDEBUG"
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index e4bd4d41e9..f65247be86 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -1,5 +1,9 @@
-#include <ruby/ruby.h>
-#include <ruby/io.h>
+/*
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <rubyio.h>
#include <ctype.h>
#include "dl.h"
@@ -7,126 +11,726 @@ VALUE rb_mDL;
VALUE rb_eDLError;
VALUE rb_eDLTypeError;
-ID rbdl_id_cdecl;
-ID rbdl_id_stdcall;
+static VALUE DLFuncTable;
+static void *rb_dl_callback_table[CALLBACK_TYPES][MAX_CALLBACK];
+static ID id_call;
+
+static int
+rb_dl_scan_callback_args(long stack[], const char *proto,
+ int *argc, VALUE argv[])
+{
+ int i;
+ long *sp;
+ VALUE val;
+
+ sp = stack;
+ for (i=1; proto[i]; i++) {
+ switch (proto[i]) {
+ case 'C':
+ {
+ char v;
+ v = (char)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'H':
+ {
+ short v;
+ v = (short)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'I':
+ {
+ int v;
+ v = (int)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'L':
+ {
+ long v;
+ v = (long)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'F':
+ {
+ float v;
+ memcpy(&v, sp, sizeof(float));
+ sp += sizeof(float)/sizeof(long);
+ val = rb_float_new(v);
+ }
+ break;
+ case 'D':
+ {
+ double v;
+ memcpy(&v, sp, sizeof(double));
+ sp += sizeof(double)/sizeof(long);
+ val = rb_float_new(v);
+ }
+ break;
+ case 'P':
+ {
+ void *v;
+ memcpy(&v, sp, sizeof(void*));
+ sp++;
+ val = rb_dlptr_new(v, 0, 0);
+ }
+ break;
+ case 'S':
+ {
+ char *v;
+ memcpy(&v, sp, sizeof(void*));
+ sp++;
+ val = rb_tainted_str_new2(v);
+ }
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type `%c'", proto[i]);
+ break;
+ }
+ argv[i-1] = val;
+ }
+ *argc = (i - 1);
+
+ return (*argc);
+}
+
+#include "callback.func"
+
+static void
+init_dl_func_table(){
+#include "cbtable.func"
+}
+
+void *
+dlmalloc(size_t size)
+{
+ DEBUG_CODE2({
+ void *ptr;
+
+ printf("dlmalloc(%d)",size);
+ ptr = xmalloc(size);
+ printf(":0x%x\n",ptr);
+ return ptr;
+ },
+ {
+ return xmalloc(size);
+ });
+}
+
+void *
+dlrealloc(void *ptr, size_t size)
+{
+ DEBUG_CODE({
+ printf("dlrealloc(0x%x,%d)\n",ptr,size);
+ });
+ return xrealloc(ptr, size);
+}
+
+void
+dlfree(void *ptr)
+{
+ DEBUG_CODE({
+ printf("dlfree(0x%x)\n",ptr);
+ });
+ xfree(ptr);
+}
+
+char*
+dlstrdup(const char *str)
+{
+ char *newstr;
+
+ newstr = (char*)dlmalloc(strlen(str)+1);
+ strcpy(newstr,str);
+
+ return newstr;
+}
+
+size_t
+dlsizeof(const char *cstr)
+{
+ size_t size;
+ int i, len, n, dlen;
+ char *d;
+
+ len = strlen(cstr);
+ size = 0;
+ for (i=0; i<len; i++) {
+ n = 1;
+ if (isdigit(cstr[i+1])) {
+ dlen = 1;
+ while (isdigit(cstr[i+dlen])) { dlen ++; };
+ dlen --;
+ d = ALLOCA_N(char, dlen + 1);
+ strncpy(d, cstr + i + 1, dlen);
+ d[dlen] = '\0';
+ n = atoi(d);
+ }
+ else{
+ dlen = 0;
+ }
+
+ switch (cstr[i]) {
+ case 'I':
+ DLALIGN(0,size,INT_ALIGN);
+ case 'i':
+ size += sizeof(int) * n;
+ break;
+ case 'L':
+ DLALIGN(0,size,LONG_ALIGN);
+ case 'l':
+ size += sizeof(long) * n;
+ break;
+ case 'F':
+ DLALIGN(0,size,FLOAT_ALIGN);
+ case 'f':
+ size += sizeof(float) * n;
+ break;
+ case 'D':
+ DLALIGN(0,size,DOUBLE_ALIGN);
+ case 'd':
+ size += sizeof(double) * n;
+ break;
+ case 'C':
+ case 'c':
+ size += sizeof(char) * n;
+ break;
+ case 'H':
+ DLALIGN(0,size,SHORT_ALIGN);
+ case 'h':
+ size += sizeof(short) * n;
+ break;
+ case 'P':
+ case 'S':
+ DLALIGN(0,size,VOIDP_ALIGN);
+ case 'p':
+ case 's':
+ size += sizeof(void*) * n;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type '%c'", cstr[i]);
+ break;
+ }
+ i += dlen;
+ }
+
+ return size;
+}
+
+static float *
+c_farray(VALUE v, long *size)
+{
+ int i, len;
+ float *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(float) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FLOAT:
+ ary[i] = (float)(RFLOAT(e)->value);
+ break;
+ case T_NIL:
+ ary[i] = 0.0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static double *
+c_darray(VALUE v, long *size)
+{
+ int i, len;
+ double *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(double) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FLOAT:
+ ary[i] = (double)(RFLOAT(e)->value);
+ break;
+ case T_NIL:
+ ary[i] = 0.0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static long *
+c_larray(VALUE v, long *size)
+{
+ int i, len;
+ long *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(long) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (long)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static int *
+c_iarray(VALUE v, long *size)
+{
+ int i, len;
+ int *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(int) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (int)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static short *
+c_harray(VALUE v, long *size)
+{
+ int i, len;
+ short *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(short) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (short)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static char *
+c_carray(VALUE v, long *size)
+{
+ int i, len;
+ char *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(char) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (char)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static void *
+c_parray(VALUE v, long *size)
+{
+ int i, len;
+ void **ary;
+ VALUE e, tmp;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(void*) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ default:
+ tmp = rb_check_string_type(e);
+ if (NIL_P(tmp)) {
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ }
+ e = tmp;
+ /* fall through */
+ case T_STRING:
+ rb_check_safe_str(e);
+ {
+ char *str, *src;
+ src = RSTRING(e)->ptr;
+ str = dlstrdup(src);
+ ary[i] = (void*)str;
+ }
+ break;
+ case T_NIL:
+ ary[i] = NULL;
+ break;
+ case T_DATA:
+ if (rb_obj_is_kind_of(e, rb_cDLPtrData)) {
+ struct ptr_data *pdata;
+ Data_Get_Struct(e, struct ptr_data, pdata);
+ ary[i] = (void*)(pdata->ptr);
+ }
+ else{
+ e = rb_funcall(e, rb_intern("to_ptr"), 0);
+ if (rb_obj_is_kind_of(e, rb_cDLPtrData)) {
+ struct ptr_data *pdata;
+ Data_Get_Struct(e, struct ptr_data, pdata);
+ ary[i] = (void*)(pdata->ptr);
+ }
+ else{
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ }
+ }
+ break;
+ }
+ }
+
+ return ary;
+}
+
+void *
+rb_ary2cary(char t, VALUE v, long *size)
+{
+ int len;
+ VALUE val0;
+
+ val0 = rb_check_array_type(v);
+ if(NIL_P(val0)) {
+ rb_raise(rb_eDLTypeError, "an array is expected.");
+ }
+ v = val0;
+
+ len = RARRAY(v)->len;
+ if (len == 0) {
+ return NULL;
+ }
+
+ if (!size) {
+ size = ALLOCA_N(long,1);
+ }
+
+ val0 = rb_ary_entry(v,0);
+ switch (TYPE(val0)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ switch (t) {
+ case 'C': case 'c':
+ return (void*)c_carray(v,size);
+ case 'H': case 'h':
+ return (void*)c_harray(v,size);
+ case 'I': case 'i':
+ return (void*)c_iarray(v,size);
+ case 'L': case 'l': case 0:
+ return (void*)c_larray(v,size);
+ default:
+ rb_raise(rb_eDLTypeError, "type mismatch");
+ }
+ case T_STRING:
+ return (void*)c_parray(v,size);
+ case T_FLOAT:
+ switch (t) {
+ case 'F': case 'f':
+ return (void*)c_farray(v,size);
+ case 'D': case 'd': case 0:
+ return (void*)c_darray(v,size);
+ }
+ rb_raise(rb_eDLTypeError, "type mismatch");
+ case T_DATA:
+ if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
+ return (void*)c_parray(v,size);
+ }
+ else{
+ val0 = rb_funcall(val0, rb_intern("to_ptr"), 0);
+ if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
+ return (void*)c_parray(v,size);
+ }
+ }
+ rb_raise(rb_eDLTypeError, "type mismatch");
+ case T_NIL:
+ return (void*)c_parray(v, size);
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type");
+ }
+}
VALUE
-rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
+rb_str_to_ptr(VALUE self)
{
- rb_secure(2);
- return rb_class_new_instance(argc, argv, rb_cDLHandle);
+ 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;
}
VALUE
-rb_dl_malloc(VALUE self, VALUE size)
+rb_ary_to_ptr(int argc, VALUE argv[], VALUE self)
{
- void *ptr;
+ void *ptr;
+ VALUE t;
+ long size;
- ptr = (void*)ruby_xmalloc(NUM2INT(size));
- return PTR2NUM(ptr);
+ switch (rb_scan_args(argc, argv, "01", &t)) {
+ case 1:
+ ptr = rb_ary2cary(StringValuePtr(t)[0], self, &size);
+ break;
+ case 0:
+ ptr = rb_ary2cary(0, self, &size);
+ break;
+ }
+ if (ptr) {
+ VALUE p = rb_dlptr_new(ptr, size, dlfree);
+ OBJ_INFECT(p, self);
+ return p;
+ }
+ return Qnil;
}
VALUE
-rb_dl_realloc(VALUE self, VALUE addr, VALUE size)
+rb_io_to_ptr(VALUE self)
{
- void *ptr = NUM2PTR(addr);
+ rb_io_t *fptr;
+ FILE *fp;
+
+ GetOpenFile(self, fptr);
+ fp = fptr->f;
- ptr = (void*)ruby_xrealloc(ptr, NUM2INT(size));
- return PTR2NUM(ptr);
+ return fp ? rb_dlptr_new(fp, 0, 0) : Qnil;
}
VALUE
-rb_dl_free(VALUE self, VALUE addr)
+rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
{
- void *ptr = NUM2PTR(addr);
- ruby_xfree(ptr);
- return Qnil;
+ rb_secure(2);
+ return rb_class_new_instance(argc, argv, rb_cDLHandle);
}
VALUE
-rb_dl_ptr2value(VALUE self, VALUE addr)
+rb_dl_malloc(VALUE self, VALUE size)
{
- return (VALUE)NUM2PTR(addr);
+ rb_secure(4);
+ return rb_dlptr_malloc(DLNUM2LONG(size), dlfree);
}
VALUE
-rb_dl_value2ptr(VALUE self, VALUE val)
+rb_dl_strdup(VALUE self, VALUE str)
{
- return PTR2NUM((void*)val);
+ SafeStringValue(str);
+ return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree);
}
-#include "callback.h"
+static VALUE
+rb_dl_sizeof(VALUE self, VALUE str)
+{
+ return INT2NUM(dlsizeof(StringValuePtr(str)));
+}
+
+static VALUE
+rb_dl_callback(int argc, VALUE argv[], VALUE self)
+{
+ VALUE type, proc;
+ int rettype, entry, i;
+ char fname[127];
+
+ rb_secure(4);
+ proc = Qnil;
+ switch (rb_scan_args(argc, argv, "11", &type, &proc)) {
+ case 1:
+ if (rb_block_given_p()) {
+ proc = rb_block_proc();
+ }
+ else{
+ proc = Qnil;
+ }
+ default:
+ break;
+ }
+
+ StringValue(type);
+ switch (RSTRING(type)->ptr[0]) {
+ case '0':
+ rettype = 0x00;
+ break;
+ case 'C':
+ rettype = 0x01;
+ break;
+ case 'H':
+ rettype = 0x02;
+ break;
+ case 'I':
+ rettype = 0x03;
+ break;
+ case 'L':
+ rettype = 0x04;
+ break;
+ case 'F':
+ rettype = 0x05;
+ break;
+ case 'D':
+ rettype = 0x06;
+ break;
+ case 'P':
+ rettype = 0x07;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type `%c'", RSTRING(type)->ptr[0]);
+ }
+
+ entry = -1;
+ for (i=0; i < MAX_CALLBACK; i++) {
+ if (rb_hash_aref(DLFuncTable, rb_assoc_new(INT2NUM(rettype), INT2NUM(i))) == Qnil) {
+ entry = i;
+ break;
+ }
+ }
+ if (entry < 0) {
+ rb_raise(rb_eDLError, "too many callbacks are defined.");
+ }
+
+ rb_hash_aset(DLFuncTable,
+ rb_assoc_new(INT2NUM(rettype),INT2NUM(entry)),
+ rb_assoc_new(type,proc));
+ sprintf(fname, "rb_dl_callback_func_%d_%d", rettype, entry);
+ return rb_dlsym_new((void (*)())rb_dl_callback_table[rettype][entry],
+ fname, RSTRING(type)->ptr);
+}
+
+static VALUE
+rb_dl_remove_callback(VALUE mod, VALUE sym)
+{
+ freefunc_t f;
+ int i, j;
+
+ rb_secure(4);
+ f = rb_dlsym2csym(sym);
+ for (i=0; i < CALLBACK_TYPES; i++) {
+ for (j=0; j < MAX_CALLBACK; j++) {
+ if (rb_dl_callback_table[i][j] == f) {
+ rb_hash_aset(DLFuncTable, rb_assoc_new(INT2NUM(i),INT2NUM(j)),Qnil);
+ break;
+ }
+ }
+ }
+ return Qnil;
+}
void
Init_dl()
{
- void Init_dlhandle();
- void Init_dlcfunc();
- void Init_dlptr();
-
- rbdl_id_cdecl = rb_intern("cdecl");
- rbdl_id_stdcall = rb_intern("stdcall");
-
- rb_mDL = rb_define_module("DL");
- rb_eDLError = rb_define_class_under(rb_mDL, "DLError", rb_eStandardError);
- rb_eDLTypeError = rb_define_class_under(rb_mDL, "DLTypeError", rb_eDLError);
-
- rb_define_const(rb_mDL, "MAX_CALLBACK", INT2NUM(MAX_CALLBACK));
- rb_define_const(rb_mDL, "DLSTACK_SIZE", INT2NUM(DLSTACK_SIZE));
-
- rb_dl_init_callbacks();
-
- rb_define_const(rb_mDL, "RTLD_GLOBAL", INT2NUM(RTLD_GLOBAL));
- rb_define_const(rb_mDL, "RTLD_LAZY", INT2NUM(RTLD_LAZY));
- rb_define_const(rb_mDL, "RTLD_NOW", INT2NUM(RTLD_NOW));
-
- rb_define_const(rb_mDL, "TYPE_VOID", INT2NUM(DLTYPE_VOID));
- rb_define_const(rb_mDL, "TYPE_VOIDP", INT2NUM(DLTYPE_VOIDP));
- rb_define_const(rb_mDL, "TYPE_CHAR", INT2NUM(DLTYPE_CHAR));
- rb_define_const(rb_mDL, "TYPE_SHORT", INT2NUM(DLTYPE_SHORT));
- rb_define_const(rb_mDL, "TYPE_INT", INT2NUM(DLTYPE_INT));
- rb_define_const(rb_mDL, "TYPE_LONG", INT2NUM(DLTYPE_LONG));
-#if HAVE_LONG_LONG
- rb_define_const(rb_mDL, "TYPE_LONG_LONG", INT2NUM(DLTYPE_LONG_LONG));
-#endif
- rb_define_const(rb_mDL, "TYPE_FLOAT", INT2NUM(DLTYPE_FLOAT));
- rb_define_const(rb_mDL, "TYPE_DOUBLE", INT2NUM(DLTYPE_DOUBLE));
-
- rb_define_const(rb_mDL, "ALIGN_VOIDP", INT2NUM(ALIGN_VOIDP));
- rb_define_const(rb_mDL, "ALIGN_CHAR", INT2NUM(ALIGN_CHAR));
- rb_define_const(rb_mDL, "ALIGN_SHORT", INT2NUM(ALIGN_SHORT));
- rb_define_const(rb_mDL, "ALIGN_INT", INT2NUM(ALIGN_INT));
- rb_define_const(rb_mDL, "ALIGN_LONG", INT2NUM(ALIGN_LONG));
-#if HAVE_LONG_LONG
- rb_define_const(rb_mDL, "ALIGN_LONG_LONG", INT2NUM(ALIGN_LONG_LONG));
-#endif
- rb_define_const(rb_mDL, "ALIGN_FLOAT", INT2NUM(ALIGN_FLOAT));
- rb_define_const(rb_mDL, "ALIGN_DOUBLE",INT2NUM(ALIGN_DOUBLE));
-
- rb_define_const(rb_mDL, "SIZEOF_VOIDP", INT2NUM(sizeof(void*)));
- rb_define_const(rb_mDL, "SIZEOF_CHAR", INT2NUM(sizeof(char)));
- rb_define_const(rb_mDL, "SIZEOF_SHORT", INT2NUM(sizeof(short)));
- rb_define_const(rb_mDL, "SIZEOF_INT", INT2NUM(sizeof(int)));
- rb_define_const(rb_mDL, "SIZEOF_LONG", INT2NUM(sizeof(long)));
-#if HAVE_LONG_LONG
- rb_define_const(rb_mDL, "SIZEOF_LONG_LONG", INT2NUM(sizeof(LONG_LONG)));
-#endif
- rb_define_const(rb_mDL, "SIZEOF_FLOAT", INT2NUM(sizeof(float)));
- rb_define_const(rb_mDL, "SIZEOF_DOUBLE",INT2NUM(sizeof(double)));
-
- rb_define_module_function(rb_mDL, "dlwrap", rb_dl_value2ptr, 1);
- rb_define_module_function(rb_mDL, "dlunwrap", rb_dl_ptr2value, 1);
-
- rb_define_module_function(rb_mDL, "dlopen", rb_dl_dlopen, -1);
- rb_define_module_function(rb_mDL, "malloc", rb_dl_malloc, 1);
- rb_define_module_function(rb_mDL, "realloc", rb_dl_realloc, 2);
- rb_define_module_function(rb_mDL, "free", rb_dl_free, 1);
-
- rb_define_const(rb_mDL, "RUBY_FREE", PTR2NUM(ruby_xfree));
- rb_define_const(rb_mDL, "BUILD_RUBY_PLATFORM", rb_str_new2(RUBY_PLATFORM));
- rb_define_const(rb_mDL, "BUILD_RUBY_VERSION", rb_str_new2(RUBY_VERSION));
-
- Init_dlhandle();
- Init_dlcfunc();
- Init_dlptr();
+ void Init_dlptr();
+ void Init_dlsym();
+ void Init_dlhandle();
+
+ id_call = rb_intern("call");
+
+ rb_mDL = rb_define_module("DL");
+
+ rb_eDLError = rb_define_class_under(rb_mDL, "DLError", rb_eStandardError);
+ rb_eDLTypeError = rb_define_class_under(rb_mDL, "DLTypeError", rb_eDLError);
+
+ DLFuncTable = rb_hash_new();
+ init_dl_func_table();
+ rb_define_const(rb_mDL, "FuncTable", DLFuncTable);
+
+ rb_define_const(rb_mDL, "RTLD_GLOBAL", INT2NUM(RTLD_GLOBAL));
+ rb_define_const(rb_mDL, "RTLD_LAZY", INT2NUM(RTLD_LAZY));
+ rb_define_const(rb_mDL, "RTLD_NOW", INT2NUM(RTLD_NOW));
+
+ rb_define_const(rb_mDL, "ALIGN_INT", INT2NUM(ALIGN_INT));
+ rb_define_const(rb_mDL, "ALIGN_LONG", INT2NUM(ALIGN_LONG));
+ rb_define_const(rb_mDL, "ALIGN_FLOAT", INT2NUM(ALIGN_FLOAT));
+ rb_define_const(rb_mDL, "ALIGN_SHORT", INT2NUM(ALIGN_SHORT));
+ rb_define_const(rb_mDL, "ALIGN_DOUBLE",INT2NUM(ALIGN_DOUBLE));
+ rb_define_const(rb_mDL, "ALIGN_VOIDP", INT2NUM(ALIGN_VOIDP));
+
+ rb_define_const(rb_mDL, "MAX_ARG", INT2NUM(MAX_ARG));
+ rb_define_const(rb_mDL, "DLSTACK", rb_tainted_str_new2(DLSTACK_METHOD));
+
+ rb_define_module_function(rb_mDL, "dlopen", rb_dl_dlopen, -1);
+ rb_define_module_function(rb_mDL, "callback", rb_dl_callback, -1);
+ rb_define_module_function(rb_mDL, "define_callback", rb_dl_callback, -1);
+ rb_define_module_function(rb_mDL, "remove_callback", rb_dl_remove_callback, 1);
+ rb_define_module_function(rb_mDL, "malloc", rb_dl_malloc, 1);
+ rb_define_module_function(rb_mDL, "strdup", rb_dl_strdup, 1);
+ rb_define_module_function(rb_mDL, "sizeof", rb_dl_sizeof, 1);
+
+ Init_dlptr();
+ Init_dlsym();
+ Init_dlhandle();
+
+ rb_define_const(rb_mDL, "FREE", rb_dlsym_new(dlfree, "free", "0P"));
+
+ rb_define_method(rb_cString, "to_ptr", rb_str_to_ptr, 0);
+ rb_define_method(rb_cArray, "to_ptr", rb_ary_to_ptr, -1);
+ rb_define_method(rb_cIO, "to_ptr", rb_io_to_ptr, 0);
}
diff --git a/ext/dl/dl.def b/ext/dl/dl.def
new file mode 100644
index 0000000000..cdab4af90d
--- /dev/null
+++ b/ext/dl/dl.def
@@ -0,0 +1,59 @@
+EXPORTS
+Init_dl
+dlfree
+dlmalloc
+dlrealloc
+dlstrdup
+rb_ary_to_ptr
+rb_dl_dlopen
+rb_dl_malloc
+rb_dl_strdup
+rb_eDLError
+rb_eDLTypeError
+rb_io_to_ptr
+rb_mDL
+rb_str_to_ptr
+Init_dlhandle
+rb_cDLHandle
+rb_dlhandle_close
+rb_dlhandle_disable_close
+rb_dlhandle_enable_close
+rb_dlhandle_sym
+Init_dlptr
+rb_cDLPtrData
+rb_dlmem_each
+rb_dlptr2cptr
+rb_dlptr_malloc
+rb_dlptr_aref
+rb_dlptr_aset
+rb_dlptr_cmp
+rb_dlptr_define_data_type
+rb_dlptr_define_struct
+rb_dlptr_define_union
+rb_dlptr_eql
+rb_dlptr_free_get
+rb_dlptr_free_set
+rb_dlptr_get_data_type
+rb_dlptr_inspect
+rb_dlptr_minus
+rb_dlptr_new
+rb_dlptr_new2
+rb_dlptr_null_p
+rb_dlptr_plus
+rb_dlptr_ptr
+rb_dlptr_ref
+rb_dlptr_to_array
+rb_dlptr_to_i
+rb_dlptr_to_s
+rb_dlptr_to_str
+rb_mDLMemorySpace
+Init_dlsym
+rb_cDLSymbol
+rb_dlsym2csym
+rb_dlsym_call
+rb_dlsym_cproto
+rb_dlsym_inspect
+rb_dlsym_name
+rb_dlsym_new
+rb_dlsym_proto
+rb_dlsym_to_ptr
diff --git a/ext/dl/dl.h b/ext/dl/dl.h
index 7b8ad077ae..1faa316cf1 100644
--- a/ext/dl/dl.h
+++ b/ext/dl/dl.h
@@ -1,14 +1,12 @@
+/* -*- C -*-
+ * $Id$
+ */
+
#ifndef RUBY_DL_H
#define RUBY_DL_H
#include <ruby.h>
-
-#if !defined(FUNC_CDECL)
-# define FUNC_CDECL(x) x
-#endif
-#if !defined(FUNC_STDCALL)
-# define FUNC_STDCALL(x) x
-#endif
+#include <dlconfig.h>
#if defined(HAVE_DLFCN_H)
# include <dlfcn.h>
@@ -35,156 +33,281 @@
# endif
#endif
-#define MAX_CALLBACK 5
-#define DLSTACK_TYPE long
-#define DLSTACK_SIZE (20)
-#define DLSTACK_PROTO \
- DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,\
- DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,\
- DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,\
- DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE,DLSTACK_TYPE
-#define DLSTACK_ARGS(stack) \
- stack[0],stack[1],stack[2],stack[3],stack[4],\
- stack[5],stack[6],stack[7],stack[8],stack[9],\
- stack[10],stack[11],stack[12],stack[13],stack[14],\
- stack[15],stack[16],stack[17],stack[18],stack[19]
-
-#define DLSTACK_PROTO0
-#define DLSTACK_PROTO1 DLSTACK_TYPE
-#define DLSTACK_PROTO2 DLSTACK_PROTO1, DLSTACK_TYPE
-#define DLSTACK_PROTO3 DLSTACK_PROTO2, DLSTACK_TYPE
-#define DLSTACK_PROTO4 DLSTACK_PROTO3, DLSTACK_TYPE
-#define DLSTACK_PROTO4 DLSTACK_PROTO3, DLSTACK_TYPE
-#define DLSTACK_PROTO5 DLSTACK_PROTO4, DLSTACK_TYPE
-#define DLSTACK_PROTO6 DLSTACK_PROTO5, DLSTACK_TYPE
-#define DLSTACK_PROTO7 DLSTACK_PROTO6, DLSTACK_TYPE
-#define DLSTACK_PROTO8 DLSTACK_PROTO7, DLSTACK_TYPE
-#define DLSTACK_PROTO9 DLSTACK_PROTO8, DLSTACK_TYPE
-#define DLSTACK_PROTO10 DLSTACK_PROTO9, DLSTACK_TYPE
-#define DLSTACK_PROTO11 DLSTACK_PROTO10, DLSTACK_TYPE
-#define DLSTACK_PROTO12 DLSTACK_PROTO11, DLSTACK_TYPE
-#define DLSTACK_PROTO13 DLSTACK_PROTO12, DLSTACK_TYPE
-#define DLSTACK_PROTO14 DLSTACK_PROTO13, DLSTACK_TYPE
-#define DLSTACK_PROTO14 DLSTACK_PROTO13, DLSTACK_TYPE
-#define DLSTACK_PROTO15 DLSTACK_PROTO14, DLSTACK_TYPE
-#define DLSTACK_PROTO16 DLSTACK_PROTO15, DLSTACK_TYPE
-#define DLSTACK_PROTO17 DLSTACK_PROTO16, DLSTACK_TYPE
-#define DLSTACK_PROTO18 DLSTACK_PROTO17, DLSTACK_TYPE
-#define DLSTACK_PROTO19 DLSTACK_PROTO18, DLSTACK_TYPE
-#define DLSTACK_PROTO20 DLSTACK_PROTO19, DLSTACK_TYPE
-
-#define DLSTACK_ARGS0(stack)
-#define DLSTACK_ARGS1(stack) stack[0]
-#define DLSTACK_ARGS2(stack) DLSTACK_ARGS1(stack), stack[1]
-#define DLSTACK_ARGS3(stack) DLSTACK_ARGS2(stack), stack[2]
-#define DLSTACK_ARGS4(stack) DLSTACK_ARGS3(stack), stack[3]
-#define DLSTACK_ARGS5(stack) DLSTACK_ARGS4(stack), stack[4]
-#define DLSTACK_ARGS6(stack) DLSTACK_ARGS5(stack), stack[5]
-#define DLSTACK_ARGS7(stack) DLSTACK_ARGS6(stack), stack[6]
-#define DLSTACK_ARGS8(stack) DLSTACK_ARGS7(stack), stack[7]
-#define DLSTACK_ARGS9(stack) DLSTACK_ARGS8(stack), stack[8]
-#define DLSTACK_ARGS10(stack) DLSTACK_ARGS9(stack), stack[9]
-#define DLSTACK_ARGS11(stack) DLSTACK_ARGS10(stack), stack[10]
-#define DLSTACK_ARGS12(stack) DLSTACK_ARGS11(stack), stack[11]
-#define DLSTACK_ARGS13(stack) DLSTACK_ARGS12(stack), stack[12]
-#define DLSTACK_ARGS14(stack) DLSTACK_ARGS13(stack), stack[13]
-#define DLSTACK_ARGS15(stack) DLSTACK_ARGS14(stack), stack[14]
-#define DLSTACK_ARGS16(stack) DLSTACK_ARGS15(stack), stack[15]
-#define DLSTACK_ARGS17(stack) DLSTACK_ARGS16(stack), stack[16]
-#define DLSTACK_ARGS18(stack) DLSTACK_ARGS17(stack), stack[17]
-#define DLSTACK_ARGS19(stack) DLSTACK_ARGS18(stack), stack[18]
-#define DLSTACK_ARGS20(stack) DLSTACK_ARGS19(stack), stack[19]
+#if !defined(StringValue)
+# define StringValue(v) if(TYPE(v) != T_STRING) v = rb_str_to_str(v)
+#endif
+#if !defined(StringValuePtr)
+# define StringValuePtr(v) RSTRING((TYPE(v) == T_STRING) ? (v) : rb_str_to_str(v))->ptr
+#endif
+
+#ifdef DEBUG
+#define DEBUG_CODE(b) {printf("DEBUG:%d\n",__LINE__);b;}
+#define DEBUG_CODE2(b1,b2) {printf("DEBUG:%d\n",__LINE__);b1;}
+#else
+#define DEBUG_CODE(b)
+#define DEBUG_CODE2(b1,b2) b2
+#endif
+
+#define VOID_DLTYPE 0x00
+#define CHAR_DLTYPE 0x01
+#define SHORT_DLTYPE 0x02
+#define INT_DLTYPE 0x03
+#define LONG_DLTYPE 0x04
+#define FLOAT_DLTYPE 0x05
+#define DOUBLE_DLTYPE 0x06
+#define VOIDP_DLTYPE 0x07
+
+#define ARG_TYPE(x,i) (((x) & (0x07 << ((i)*3))) >> ((i)*3))
+#define PUSH_ARG(x,t) do{x <<= 3; x |= t;}while(0)
+#define PUSH_0(x) PUSH_ARG(x,VOID_DLTYPE)
+
+#if SIZEOF_INT == SIZEOF_LONG
+# define PUSH_I(x) PUSH_ARG(x,LONG_DLTYPE)
+# define ANY2I(x) x.l
+# define DLINT(x) (long)x
+#else
+# define PUSH_I(x) PUSH_ARG(x,INT_DLTYPE)
+# define ANY2I(x) x.i
+# define DLINT(x) (int)x
+#endif
+#define PUSH_L(x) PUSH_ARG(x,LONG_DLTYPE)
+#define ANY2L(x) x.l
+#define DLLONG(x) (long)x
+
+#if defined(WITH_TYPE_FLOAT)
+# if SIZEOF_FLOAT == SIZEOF_DOUBLE
+# define PUSH_F(x) PUSH_ARG(x,DOUBLE_DLTYPE)
+# define ANY2F(x) (x.d)
+# define DLFLOAT(x) ((double)x)
+# else
+# define PUSH_F(x) PUSH_ARG(x,FLOAT_DLTYPE)
+# define ANY2F(x) (x.f)
+# define DLFLOAT(x) ((float)x)
+# endif
+#else
+# define PUSH_F(x) PUSH_ARG(x,DOUBLE_DLTYPE)
+# define ANY2F(x) (x.d)
+# define DLFLOAT(x) ((double)x)
+#endif
+#define PUSH_D(x) PUSH_ARG(x,DOUBLE_DLTYPE)
+#define ANY2D(x) (x.d)
+#define DLDOUBLE(x) ((double)x)
+
+#if SIZEOF_INT == SIZEOF_VOIDP && SIZEOF_INT != SIZEOF_LONG
+# define PUSH_P(x) PUSH_ARG(x,INT_DLTYPE)
+# define ANY2P(x) (x.i)
+# define DLVOIDP(x) ((int)x)
+#elif SIZEOF_LONG == SIZEOF_VOIDP
+# define PUSH_P(x) PUSH_ARG(x,LONG_DLTYPE)
+# define ANY2P(x) (x.l)
+# define DLVOIDP(x) ((long)x)
+#else
+# define PUSH_P(x) PUSH_ARG(x,VOIDP_DLTYPE)
+# define ANY2P(x) (x.p)
+# define DLVOIDP(x) ((void*)p)
+#endif
+
+#if defined(WITH_TYPE_CHAR)
+# define PUSH_C(x) PUSH_ARG(x,CHAR_DLTYPE)
+# define ANY2C(x) (x.c)
+# define DLCHAR(x) ((char)x)
+#else
+# define PUSH_C(x) PUSH_I(x)
+# define ANY2C(x) ANY2I(x)
+# define DLCHAR(x) DLINT(x)
+#endif
+
+#if defined(WITH_TYPE_SHORT)
+# define PUSH_H(x) PUSH_ARG(x,SHORT_DLTYPE)
+# define ANY2H(x) (x.h)
+# define DLSHORT(x) ((short)x)
+#else
+# define PUSH_H(x) PUSH_I(x)
+# define ANY2H(x) ANY2I(x)
+# define DLSHORT(x) DLINT(x)
+#endif
+
+#define PUSH_S(x) PUSH_P(x)
+#define ANY2S(x) ANY2P(x)
+#define DLSTR(x) DLVOIDP(x)
+
+#define CBPUSH_0(x) PUSH_0(x)
+#define CBPUSH_C(x) PUSH_C(x)
+#define CBPUSH_H(x) PUSH_H(x)
+#define CBPUSH_I(x) PUSH_I(x)
+#define CBPUSH_L(x) PUSH_L(x)
+#define CBPUSH_F(x) PUSH_F(x)
+#define CBPUSH_D(x) PUSH_D(x)
+#if defined(WITH_CBTYPE_VOIDP)
+# define CBPUSH_P(x) PUSH_ARG(x,VOIDP_DLTYPE)
+#else
+# define CBPUSH_P(x) PUSH_P(x)
+#endif
+
+
+#if defined(USE_INLINE_ASM)
+# if defined(__i386__) && defined(__GNUC__)
+# define DLSTACK
+# define DLSTACK_METHOD "asm"
+# define DLSTACK_REVERSE
+# define DLSTACK_PROTO
+# define DLSTACK_ARGS
+# define DLSTACK_START(sym)
+# define DLSTACK_END(sym)
+# define DLSTACK_PUSH_C(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_H(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_I(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_L(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_P(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_F(x) asm volatile ("flds %0"::"g"(x));\
+ asm volatile ("subl $4,%esp");\
+ asm volatile ("fstps (%esp)");
+# define DLSTACK_PUSH_D(x) asm volatile ("fldl %0"::"g"(x));\
+ asm volatile ("subl $8,%esp");\
+ asm volatile ("fstpl (%esp)")
+# else
+# error --with-asm is not supported on this machine
+# endif
+#elif defined(USE_DLSTACK)
+# define DLSTACK
+# define DLSTACK_GUARD
+# define DLSTACK_METHOD "dl"
+# define DLSTACK_PROTO long,long,long,long,long,\
+ long,long,long,long,long,\
+ long,long,long,long,long
+# define DLSTACK_ARGS stack[0],stack[1],stack[2],stack[3],stack[4],\
+ stack[5],stack[6],stack[7],stack[8],stack[9],\
+ stack[10],stack[11],stack[12],stack[13],stack[14]
+# define DLSTACK_SIZE (sizeof(long)*15)
+# define DLSTACK_START(sym)
+# define DLSTACK_END(sym)
+# define DLSTACK_PUSH_C(x) {long v=(long)x; memcpy(sp,&v,sizeof(long)); sp++;}
+# define DLSTACK_PUSH_H(x) {long v=(long)x; memcpy(sp,&v,sizeof(long)); sp++;}
+# define DLSTACK_PUSH_I(x) {long v=(long)x; memcpy(sp,&v,sizeof(long)); sp++;}
+# define DLSTACK_PUSH_L(x) memcpy(sp,&x,sizeof(long)); sp++;
+# define DLSTACK_PUSH_P(x) memcpy(sp,&x,sizeof(void*)); sp++;
+# define DLSTACK_PUSH_F(x) memcpy(sp,&x,sizeof(float)); sp+=sizeof(float)/sizeof(long);
+# define DLSTACK_PUSH_D(x) memcpy(sp,&x,sizeof(double)); sp+=sizeof(double)/sizeof(long);
+#else
+# define DLSTACK_METHOD "none"
+#endif
extern VALUE rb_mDL;
+extern VALUE rb_mDLMemorySpace;
extern VALUE rb_cDLHandle;
extern VALUE rb_cDLSymbol;
+extern VALUE rb_cDLPtrData;
+extern VALUE rb_cDLStructData;
+
extern VALUE rb_eDLError;
extern VALUE rb_eDLTypeError;
+#if defined(LONG2NUM) && (SIZEOF_LONG == SIZEOF_VOIDP)
+# define DLLONG2NUM(x) LONG2NUM((long)x)
+# define DLNUM2LONG(x) (long)(NUM2LONG(x))
+#else
+# define DLLONG2NUM(x) INT2NUM((long)x)
+# define DLNUM2LONG(x) (long)(NUM2INT(x))
+#endif
+
typedef struct { char c; void *x; } s_voidp;
typedef struct { char c; short x; } s_short;
typedef struct { char c; int x; } s_int;
typedef struct { char c; long x; } s_long;
typedef struct { char c; float x; } s_float;
typedef struct { char c; double x; } s_double;
-#if HAVE_LONG_LONG
-typedef struct { char c; LONG_LONG x; } s_long_long;
-#endif
#define ALIGN_VOIDP (sizeof(s_voidp) - sizeof(void *))
#define ALIGN_SHORT (sizeof(s_short) - sizeof(short))
-#define ALIGN_CHAR (1)
#define ALIGN_INT (sizeof(s_int) - sizeof(int))
#define ALIGN_LONG (sizeof(s_long) - sizeof(long))
-#if HAVE_LONG_LONG
-#define ALIGN_LONG_LONG (sizeof(s_long_long) - sizeof(LONG_LONG))
-#endif
#define ALIGN_FLOAT (sizeof(s_float) - sizeof(float))
#define ALIGN_DOUBLE (sizeof(s_double) - sizeof(double))
+/* for compatibility */
+#define VOIDP_ALIGN ALIGN_VOIDP
+#define SHORT_ALIGN ALIGN_SHORT
+#define INT_ALIGN ALIGN_INT
+#define LONG_ALIGN ALIGN_LONG
+#define FLOAT_ALIGN ALIGN_FLOAT
+#define DOUBLE_ALIGN ALIGN_DOUBLE
+
#define DLALIGN(ptr,offset,align) {\
while( (((unsigned long)((char *)ptr + offset)) % align) != 0 ) offset++;\
}
+typedef void (*freefunc_t)(void *);
+#define DLFREEFUNC(func) ((freefunc_t)(func))
-#define DLTYPE_VOID 0
-#define DLTYPE_VOIDP 1
-#define DLTYPE_CHAR 2
-#define DLTYPE_SHORT 3
-#define DLTYPE_INT 4
-#define DLTYPE_LONG 5
-#if HAVE_LONG_LONG
-#define DLTYPE_LONG_LONG 6
-#endif
-#define DLTYPE_FLOAT 7
-#define DLTYPE_DOUBLE 8
-#define MAX_DLTYPE 9
-
-#if SIZEOF_VOIDP == SIZEOF_LONG
-# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
-# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
-#else
-/* # error --->> Ruby/DL2 requires sizeof(void*) == sizeof(long) to be compiled. <<--- */
-# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
-# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
-#endif
-
-#define BOOL2INT(x) ((x == Qtrue)?1:0)
-#define INT2BOOL(x) (x?Qtrue:Qfalse)
-
-typedef void (*freefunc_t)(void*);
+typedef union {
+ void* p;
+ char c;
+ short h;
+ int i;
+ long l;
+ float f;
+ double d;
+ char *s;
+} ANY_TYPE;
struct dl_handle {
- void *ptr;
- int open;
- int enable_close;
+ void *ptr;
+ int open;
+ int enable_close;
};
+struct sym_data {
+ void *func;
+ char *name;
+ char *type;
+ int len;
+};
-struct cfunc_data {
- void *ptr;
- char *name;
- int type;
- ID calltype;
+enum DLPTR_CTYPE {
+ DLPTR_CTYPE_UNKNOWN,
+ DLPTR_CTYPE_STRUCT,
+ DLPTR_CTYPE_UNION
};
-extern ID rbdl_id_cdecl;
-extern ID rbdl_id_stdcall;
-#define CFUNC_CDECL (rbdl_id_cdecl)
-#define CFUNC_STDCALL (rbdl_id_stdcall)
struct ptr_data {
- void *ptr;
- long size;
- freefunc_t free;
+ void *ptr; /* a pointer to the data */
+ freefunc_t free; /* free() */
+ char *stype; /* array of type specifiers */
+ int *ssize; /* size[i] = sizeof(type[i]) > 0 */
+ int slen; /* the number of type specifiers */
+ ID *ids;
+ int ids_num;
+ int ctype; /* DLPTR_CTYPE_UNKNOWN, DLPTR_CTYPE_STRUCT, DLPTR_CTYPE_UNION */
+ long size;
};
-#define RDL_HANDLE(obj) ((struct dl_handle *)(DATA_PTR(obj)))
-#define RCFUNC_DATA(obj) ((struct cfunc_data *)(DATA_PTR(obj)))
-#define RPTR_DATA(obj) ((struct ptr_data *)(DATA_PTR(obj)))
+#define RDLPTR(obj) ((struct ptr_data *)(DATA_PTR(obj)))
+#define RDLSYM(obj) ((struct sym_data *)(DATA_PTR(obj)))
+
+void dlfree(void*);
+void *dlmalloc(size_t);
+void *dlrealloc(void*,size_t);
+char *dlstrdup(const char *);
+size_t dlsizeof(const char *);
+
+void *rb_ary2cary(char t, VALUE ary, long *size);
+
+/*
+void rb_dlmem_delete(void *ptr);
+void rb_dlmem_aset(void *ptr, VALUE obj);
+VALUE rb_dlmem_aref(void *ptr);
+*/
+
+void dlptr_free(struct ptr_data *data);
+void dlptr_init(VALUE val);
-VALUE rb_dlcfunc_new(void (*func)(), int dltype, const char * name, ID calltype);
VALUE rb_dlptr_new(void *ptr, long size, freefunc_t func);
VALUE rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func);
VALUE rb_dlptr_malloc(long size, freefunc_t func);
+void *rb_dlptr2cptr(VALUE val);
-#endif
+VALUE rb_dlsym_new(void (*func)(), const char *name, const char *type);
+freefunc_t rb_dlsym2csym(VALUE val);
+
+
+#endif /* RUBY_DL_H */
diff --git a/ext/dl/doc/dl.txt b/ext/dl/doc/dl.txt
new file mode 100644
index 0000000000..893bd21d79
--- /dev/null
+++ b/ext/dl/doc/dl.txt
@@ -0,0 +1,266 @@
+=begin
+
+= Ruby/DL
+
+Ruby/DL provides an interface to the dynamic linker such as dlopen() on UNIX
+and LoadLibrary() on Windows.
+
+= Building and Installing
+
+ $ ruby extconf.rb # to create the Makefile
+ $ make # to build the library 'dl.so'
+ $ make libtest.so # to build the C library 'libtest.so' for the test script
+ $ make test # to run the test script
+ $ make install # to install the library
+ $ make clean # to remove the created files without Makefile
+ $ make distclean # to remove the all created files
+
+= Using Ruby/DL
+
+We should usually use DL::Importable module provided by "dl/import.rb".
+It has high-level functions to access library functions. We use
+DL::Importable module to extend a module as follows:
+
+ require "dl/import"
+ module LIBC
+ extend DL::Importable
+ end
+
+Now we can use methods dlload and extern in this module. We load the
+libraries using dlload, and define wrapper methods to library functions
+using extern respectively as follows:
+
+ module LIBC
+ extend DL::Importable
+ dlload "libc.so.6","libm.so.6"
+ extern "int strlen(char*)"
+ end
+ # Note that we should not include the module LIBC from some reason.
+
+We can call the library function strlen() using LIBC.strlen. If the first
+character of given function name is an uppercase, the first character of the
+defined method name becomes lowercase.
+We can also construct memory images of structures and unions using functions
+struct and union which are defined in "dl/struct.rb" as follows:
+
+ require "dl/import"
+ require "dl/struct"
+ module LIBC
+ extend DL::Importable
+ Timeval = struct [ # define timeval structure.
+ "long tv_sec",
+ "long tv_uses",
+ ]
+ end
+ val = LIBC::Timeval.malloc # allocate memory.
+
+Notice that the above example takes LIBC::Timeval.malloc to allocate memory,
+rather than LIBC::Timeval.new. It is because DL::Timeval.new is for wrapping
+an object, PtrData, which has already been created.
+
+We can define a callback using the module function "callback" as follows:
+
+ module Foo
+ extend DL::Importable
+ def my_comp(str1,str2)
+ str1 <=> str2
+ end
+ COMPARE = callback "int my_comp(char*,char*)"
+ end
+
+where Foo::COMPARE is a Symbol object which invokes the method "my_comp".
+
+DL::Importable module is very useful. However, we sometimes encounter a case
+that we must directly use low-level functions such as dlsym(). In such case,
+we would use DL module functions. They are described in next section.
+
+= DL module
+
+Module DL consists of three classes, a few module functions and constants.
+The class Symbol represents the symbol we can call. The class PtrData
+indicates a memory block such as a pointer in C. An object instantiated from
+the class Handle keeps a handle to opened library.
+
+== Constants
+
+* VERSION
+* MAJOR_VERSION
+* MINOR_VERSION
+* PATCH_VERSION
+* RTLD_GLOBAL
+* RTLD_LAZY
+* RTLD_NOW
+* MAX_ARG
+* MAX_CBARG
+* MAX_CBENT
+
+== Functions
+
+* handle = dlopen(lib){|handle| ... }
+ * is quite equal to `Handle.new(lib)'
+
+* sym = set_callback(cbtype, entry){|args| ... }
+* sym = set_callback(cbtype, entry, proc)
+ * makes entry-th pre-defined function to call the proc or given block. the
+ entry-th pre-defined function is specified by cbtype and entry. cbtype is a
+ prototype of the callback. see also the section `Type specifiers' about
+ cbtype.
+
+* sym = get_callback(cbtype, entry)
+ * returns the Proc object which is given by the above function
+ `set_callback'.
+
+* ptr = malloc(size, [free = nil])
+ * allocates the size bytes, and returns the pointer as a PtrData object ptr.
+
+* ptr = strdup(str)
+ * returns a PtrData object ptr which represents the pointer to a new string
+ which is a duplicate of the string str.
+
+* size = sizeof(type)
+ * returns the size of type. `sizeof("C") + sizeof("L")' is not equal to
+ `sizeof("CL")'. the latter is assumed to returns the enough size of the
+ structure `struct foo { char c; long l; }', but the size may not equal to
+ `sizeof(foo)' of C.
+
+== Handle class
+
+* handle = Handle.new(lib){|handle| ... }
+ * opens a library lib and returns a Handle object handle. if a block is
+ given, the handle is automatically closed as the block ends.
+
+* Handle#close
+ * closes the handle opened by the above Handle.new(lib).
+
+* sym = Handle#sym(func, prototype = "0"),
+ sym = Handle#[func, prototype = nil]
+
+ * obtains the pointer to a function called func and returns a Symbol object
+ or a DataPtr object. prototype is a string which consists of type
+ specifiers, it indicates the function's prototype. see also the section
+ `Type specifiers'.
+
+== Symbol class
+
+* sym = Symbol.new(addr, type = nil, name = nil)
+ * creates the Symbol object sym with the type type if type is not nil. addr
+ is the address where the function is allocated. If type is nil, it returns
+ a DataPtr object.
+
+* Symbol::char2type(char)
+ * takes a character char that represents a type and returns the type
+ specifier of the C language.
+
+* str = Symbol#proto()
+ * returns the function prototype.
+
+* str = Symbol#name()
+ * Returns the function name.
+
+* str = Symbol#cproto(),
+ str = Symbol#to_s()
+ * returns the prototype of the C language.
+
+* str = Symbol#inspect()
+ * returns the inspectable string.
+
+* r,rs = Symbol#call(arg1,arg2,...,argN),
+ r,rs = Symbol#[](arg1,arg2,...,argN)
+ * calls the function with parameters arg1, arg2, ..., argN. and the result
+ consists of the return value r and parameters rs. rs is an array.
+
+* ptr = Symbol#to_ptr
+ * returns the corresponding PtrData object ptr.
+
+== PtrData class
+
+* ptr = PtrData.new(addr, [size = 0, free = nil])
+ * returns the PtrData object representing the pointer which indicates the
+ address addr. GC frees the memory using the free function.
+
+* PtrData#free=(sym)
+ * If you specify a symbol object sym, GC frees the memory using the function
+ represented by sym.
+
+* sym = PtrData#free
+ * returns a symbol object sym which is used when GC frees the memory. it
+ usually configured by `PtrData#free=' or `PtrData.new'.
+
+* size = PtrData#size, PtrData#size=(size)
+ * gets and sets allocated size of the memory.
+
+* ary = PtrData#to_a(type, [size])
+ * returns an array of the type which specified with type. type must be one of
+ 'S','P','I','L','D' and 'F'.
+
+* str = PtrData#to_s([len])
+ * returns a string which length is len. if len is omitted, the end of the
+ string is '\0'.
+
+* ptr = PtrData#ptr,+@
+ * returns the pointed value as a PtrData object ptr.
+
+* ptr = PtrData#ref,-@
+ * returns the reference as a PtrData object ptr.
+
+* ptr = PtrData#+
+ * returns the PtrData object
+
+* ptr = PtrData#-
+ * returns the PtrData object
+
+* PtrData#struct!(type, *members)
+ * defines the data type to get access to a structure member with a symbol.
+ (see also PtrData#[])
+
+* PtrData#union!(type, *members)
+ * defines the data type to get access to a union member with a symbol. (see
+ also PtrData#[])
+
+* val = PtrData#[key], PtrData#[key, num = 0]
+ * if the key is a string or symbol, this method returns the value of the
+ structure/union member which has the type defined by PtrData#
+ {struct!,union!}. if the key is a integer value and this object represents
+ the pointer ptr, it returns the value of `(ptr + key).to_s(num)'
+
+* PtrData#[key,num]=val, PtrData#[key]=val
+ * if the key is a string or symbol, this method substitute the value of the
+ structure/union member with val. if the key is a integer value and val is a
+ string, this method copies num bytes of val to the memory area ptr using
+ memcpy(3).
+
+== Type specifiers
+
+the prototype consists of the following type specifiers, first element of
+prototype represents the type of return value, and remaining elements represent
+the type of each argument.
+
+ C : char
+ c : char *
+ H : short
+ h : short *
+ I : int
+ i : int *
+ L : long
+ l : long *
+ F : float
+ f : float *
+ D : double
+ d : double *
+ S : const char *
+ s : char *
+ A : const type[]
+ a : type[] (allocates new memory space)
+ P : void * (same as 'p')
+ p : void * (same as 'P')
+ 0 : void function (this must be a first character of the prototype)
+
+the cbtype consists of type specifiers 0, C, I, H, L, F, D, S and P.
+for example:
+
+ DL.callback('IPP'){|ptr1,ptr2|
+ str1 = ptr1.ptr.to_s
+ str2 = ptr2.ptr.to_s
+ str1 <=> str2
+ }
+=end
diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb
index abd8d8f781..beb15ab04c 100644
--- a/ext/dl/extconf.rb
+++ b/ext/dl/extconf.rb
@@ -1,31 +1,193 @@
require 'mkmf'
-if( RbConfig::CONFIG['CC'] =~ /gcc/ )
+begin # for the exception SystemExit
+
+$:.unshift File.dirname(__FILE__)
+require 'type'
+
+if( ARGV.include?("--help") )
+ print <<EOF
+ --help print this messages
+ --with-type-char strictly use type 'char'
+ --with-type-short strictly use type 'short'
+ --with-type-float strictly use type 'float'
+ --with-args=<max_arg>
+ --with-callback=<max_callback>
+ --enable-asm use the embedded assembler for passing arguments.
+ (this option is available for i386 machine now.)
+ --enable-dlstack use a stack emulation for constructing function call.
+EOF
+ exit(0)
+end
+
+($CPPFLAGS || $CFLAGS) << " -I."
+
+if (Config::CONFIG['CC'] =~ /gcc/) # from Win32API
$CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer"
end
-$INSTALLFILES = [
- ["dl.h", "$(HDRDIR)"],
-]
-$distcleanfiles << "callback.h"
+$with_dlstack ||= true
+$with_asm = ! $with_dlstack
+
+$with_type_int = try_cpp(<<EOF)
+#include "config.h"
+#if SIZEOF_INT == SIZEOF_LONG
+#error int not needed
+#endif
+EOF
+
+$with_type_float = try_cpp(<<EOF)
+#include "config.h"
+#if SIZEOF_FLOAT == SIZEOF_DOUBLE
+#error float not needed
+#endif
+EOF
+
+$with_type_voidp = try_cpp(<<EOF)
+#include "config.h"
+#if SIZEOF_VOIDP == SIZEOF_INT || SIZEOF_VOIDP == SIZEOF_LONG
+#error void* not needed
+#endif
+EOF
+$with_type_char = DLTYPE[CHAR][:sym]
+$with_type_short = DLTYPE[SHORT][:sym]
+$with_type_long = DLTYPE[LONG][:sym]
+$with_type_double= DLTYPE[DOUBLE][:sym]
+$with_type_int &= DLTYPE[INT][:sym]
+$with_type_float &= DLTYPE[FLOAT][:sym]
+$with_type_voidp &= DLTYPE[VOIDP][:sym]
+
+$with_type_char = enable_config("type-char", $with_type_char)
+$with_type_short = enable_config("type-short", $with_type_short)
+$with_type_float = enable_config("type-float", $with_type_float)
+
+$with_asm = enable_config("asm", $with_asm)
+$with_dlstack = enable_config("dlstack", $with_dlstack)
+
+args = with_config("args")
+max_arg = nil
+if( $with_asm || $with_dlstack )
+ $with_type_char = true
+ $with_type_short = true
+ $with_type_float = true
+ max_arg = 0
+end
+if( args )
+ max_arg = args.to_i
+ if( !max_arg )
+ print("--with-args=<max_arg>\n")
+ exit(1)
+ end
+end
+max_arg ||= 6
+
+max_callback = with_config("callback","10").to_i
+callback_types = DLTYPE.keys.length
+
+
+$dlconfig_h = <<EOF
+#define MAX_ARG #{max_arg}
+EOF
+
+def dlc_define(const)
+ $dlconfig_h << "#if !defined(#{const})\n" +
+ "# define #{const}\n" +
+ "#endif\n"
+end
+
+$dlconfig_h << "#define MAX_CALLBACK #{max_callback}\n"
+$dlconfig_h << "#define CALLBACK_TYPES #{callback_types}\n"
+if( $with_dlstack )
+ $dlconfig_h << "#define USE_DLSTACK\n"
+else
+ if( $with_asm )
+ $dlconfig_h << "#define USE_INLINE_ASM\n"
+ end
+end
+if( $with_type_char )
+ $dlconfig_h << "#define WITH_TYPE_CHAR\n"
+end
+if( $with_type_short )
+ $dlconfig_h << "#define WITH_TYPE_SHORT\n"
+end
+if( $with_type_long )
+ $dlconfig_h << "#define WITH_TYPE_LONG\n"
+end
+if( $with_type_double )
+ $dlconfig_h << "#define WITH_TYPE_DOUBLE\n"
+end
+if( $with_type_float )
+ $dlconfig_h << "#define WITH_TYPE_FLOAT\n"
+end
+if( $with_type_int )
+ $dlconfig_h << "#define WITH_TYPE_INT\n"
+end
+if( $with_type_voidp )
+ $dlconfig_h << "#define WITH_TYPE_VOIDP\n"
+end
+
+if( have_header("windows.h") )
+ have_library("kernel32")
+ have_func("GetLastError", "windows.h")
+ dlc_define("HAVE_WINDOWS_H")
+ have_windows_h = true
+end
-check = true
if( have_header("dlfcn.h") )
+ dlc_define("HAVE_DLFCN_H")
have_library("dl")
- check &&= have_func("dlopen")
- check &&= have_func("dlclose")
- check &&= have_func("dlsym")
- have_func("dlerror")
-elsif( have_header("windows.h") )
- check &&= have_func("LoadLibrary")
- check &&= have_func("FreeLibrary")
- check &&= have_func("GetProcAddress")
+ have_func("dlopen")
+ have_func("dlclose")
+ have_func("dlsym")
+ if( have_func("dlerror") )
+ dlc_define("HAVE_DLERROR")
+ end
+elsif ( have_windows_h )
+ have_func("LoadLibrary")
+ have_func("FreeLibrary")
+ have_func("GetProcAddress")
else
- check = false
+ exit(0)
end
-if check
- $defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
- create_makefile("dl")
+def File.update(file, str)
+ begin
+ open(file){|f|f.read} == str
+ rescue Errno::ENOENT
+ false
+ end or open(file, "w"){|f|f.print(str)}
+end
+
+File.update("dlconfig.h", <<EOF)
+#ifndef DLCONFIG_H
+#define DLCONFIG_H
+#{$dlconfig_h}
+#endif /* DLCONFIG_H */
+EOF
+
+File.update("dlconfig.rb", <<EOF)
+MAX_ARG = #{max_arg}
+MAX_CALLBACK = #{max_callback}
+CALLBACK_TYPES = #{callback_types}
+DLTYPE[CHAR][:sym] = #{$with_type_char}
+DLTYPE[SHORT][:sym] = #{$with_type_short}
+DLTYPE[INT][:sym] = #{$with_type_int}
+DLTYPE[LONG][:sym] = #{$with_type_long}
+DLTYPE[FLOAT][:sym] = #{$with_type_float}
+DLTYPE[DOUBLE][:sym]= #{$with_type_double}
+DLTYPE[VOIDP][:sym] = #{$with_type_voidp}
+EOF
+
+$INSTALLFILES = [
+ ["./dlconfig.h", "$(archdir)$(target_prefix)", "."],
+ ["dl.h", "$(archdir)$(target_prefix)", ""],
+]
+$cleanfiles = %w[test/test.o]
+$distcleanfiles = %w[call.func callback.func cbtable.func dlconfig.rb
+./dlconfig.h test/libtest.so test/*~ *~ mkmf.log]
+
+create_makefile('dl')
+rescue SystemExit
+ # do nothing
end
diff --git a/ext/dl/h2rb b/ext/dl/h2rb
new file mode 100644
index 0000000000..00fbd60c82
--- /dev/null
+++ b/ext/dl/h2rb
@@ -0,0 +1,500 @@
+#!/usr/bin/env ruby
+# -*- ruby -*-
+# $Id$
+
+require 'mkmf'
+require 'ftools'
+
+$recursive = false
+$force = false
+$conly = true
+$inc_path = []
+$infilename= nil
+$insert_require = true
+
+def valid_ruby_code?(code)
+ begin
+ eval("BEGIN {return true}; #{code}")
+ rescue SyntaxError
+ return false
+ end
+ return false
+end
+
+def print_usage
+ print <<EOF
+h2rb [-r] [-I <path>] [-d] [<filename>]
+EOF
+end
+
+while( ARGV[0] )
+ case( ARGV[0] )
+ when "-r"
+ ARGV.shift
+ $recursive = true
+ when "-R"
+ ARGV.shift
+ $recursive = false
+ when "-l"
+ ARGV.shift
+ $insert_require = true
+ when "-L"
+ ARGV.shift
+ $insert_require = false
+ when "-c"
+ ARGV.shift
+ $conly = true
+ when "-C"
+ ARGV.shift
+ $conly = false
+ when "-f"
+ ARGV.shift
+ $force = true
+ when "-F"
+ ARGV.shift
+ $force = false
+ when "-I"
+ ARGV.shift
+ $inc_path << ARGV.shift
+ when "-d"
+ ARGV.shift
+ $DEBUG = true
+ when "-h","--help"
+ print_usage()
+ exit 0
+ when /-.*/
+ $stderr.print("unknown option '#{ARGV[0]}'.\n")
+ print_usage()
+ exit 0
+ else
+ $infilename = ARGV.shift
+ end
+end
+
+$inc_dir = File.join(CONFIG["prefix"], "lib", "ruby",
+ CONFIG["MAJOR"] + "." + CONFIG["MINOR"],
+ "dl")
+
+class H2RBError < StandardError; end
+
+
+class H2RB
+ def initialize(inc_dir = nil, inc_path = nil, insert_require = nil)
+ @inc_path = inc_path || []
+ @inc_dir = inc_dir || '.'
+ @indent = 0
+ @parsed_files = []
+ @insert_require = insert_require || false
+ end
+
+ def find_path(file)
+ if( ! file )
+ return nil
+ end
+ if( File.exist?(file) )
+ if( file[0] == ?/ )
+ return file
+ else
+ return file
+ end
+ end
+ @inc_path.each{|path|
+ full = File.join(path, file)
+ if( File.exist?(full) )
+ return full
+ end
+ }
+ return nil
+ end
+
+ def strip_comment(line)
+ if( @commented )
+ if( e = line.index("*/") )
+ line[0..(e+1)] = ""
+ @commented = false
+ else
+ line = ""
+ end
+ else
+ if( s = line.index("/*") )
+ if( e = line.index("*/") )
+ line[s..(e+1)] = ""
+ else
+ line[s..-1] = ""
+ @commented = true
+ end
+ elsif( s = line.index("//") )
+ line[s..(-1)] = ""
+ end
+ end
+
+ line.gsub!(/\s+$/,"")
+ return line
+ end
+
+ def up_indent
+ @indent += 1
+ end
+
+ def down_indent
+ @indent -= 1
+ if( @indent < 0 )
+ raise
+ end
+ end
+
+ def indent
+ " " * @indent
+ end
+
+ def rescue_begin
+ line = "#{indent}begin"
+ up_indent
+ return line
+ end
+
+ def rescue_nameerror
+ down_indent
+ line = [
+ "#{indent}rescue NameError => e",
+ "#{indent} raise e if( $DEBUG )",
+ "#{indent}end"].join($/)
+ return line
+ end
+
+ def parse_enum(line)
+ if( line =~ /enum\s+(\S+\s+)?\{(.+)\}/ )
+ enum_name = $1
+ enum_block = $2
+ if( enum_name )
+ line = "#{indent}# -- enum #{enum_name}\n"
+ else
+ line = "#{indent}# -- enum\n"
+ end
+ enums = enum_block.split(/,/).collect{|e| e.strip}
+ i = 0
+ enums.each{|elem|
+ var,val = elem.split(/=/).collect{|e| e.strip}
+ if( val )
+ i = val.to_i
+ end
+ line += "#{indent}#{var} = #{i.to_s}\n"
+ i += 1
+ }
+ line += "#{indent}# -- end of enum"
+ return line
+ else
+ return nil
+ end
+ end
+
+ def parse_define(line)
+ case line
+ when /^#\s*define\s+(\S+)\(\)/
+ line = nil
+ when /^#\s*define\s+(\S+)\((.+)\)\s+(.+)$/
+ if( @conly )
+ line = nil
+ else
+ defname = $1
+ defargs = $2
+ defval = $3
+ if( !valid_ruby_code?(defval) )
+ defval = "nil # #{defval}"
+ end
+ if( defname[0,1] =~ /^[A-Z]$/ )
+ line = "#{indent}#{defname} = proc{|#{defargs}| #{defval}}"
+ else
+ line = [
+ "#{indent}def #{defname}(#{defargs})",
+ "#{indent} #{defval}",
+ "#{indent}end"
+ ].join("\n")
+ end
+ end
+ when /^#\s*define\s+(\S+)\((.+)\)$/
+ if( @conly )
+ line = nil
+ else
+ defname = $1
+ defargs = $2
+ defval = nil
+ if( !valid_ruby_code?(defval) )
+ defval = "nil # #{defval}"
+ end
+ if( defname[0,1] =~ /^[A-Z]$/ )
+ line = "#{indent}#{defname} = proc{|#{defargs}| #{defval}}"
+ else
+ line = [
+ "#{indent}def #{defname}(#{defargs})",
+ "#{indent} #{defval}",
+ "#{indent}end"
+ ].join("\n")
+ end
+ end
+ when /^#\s*define\s+(\S+)\s+(.+)$/
+ defname = $1
+ defval = $2
+ if( !valid_ruby_code?(defval) )
+ defval = "nil # #{defval}"
+ end
+ line = [rescue_begin, "#{indent}#{defname} = #{defval}", rescue_nameerror].join($/)
+ when /^#\s*define\s+(\S+)$/
+ defname = $1
+ line = "#{indent}#{defname} = nil"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_undef(line)
+ case line
+ when /^#\s*undef\s+([A-Z]\S+)$/
+ defname = $1
+ line = "#{indent}remove_const(:#{defname})"
+ when /^#\s*undef\s+(\S+)$/
+ defname = $1
+ line = "#{indent}#{defname} = nil"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_ifdef(line)
+ case line
+ when /^#\s*ifdef\s+(\S+)$/
+ defname = $1
+ line = [
+ rescue_begin,
+ "#{indent}if( defined?(#{defname}) && ! #{defname}.nil? )"].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_ifndef(line)
+ case line
+ when /^#\s*ifndef\s+(\S+)$/
+ defname = $1
+ line = [
+ rescue_begin,
+ "#{indent}if( ! defined?(#{defname}) || #{defname}.nil? )"].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_if(line)
+ case line
+ when /^#\s*if\s+(.+)$/
+ cond = $1
+ cond.gsub!(/defined(.+)/){ "defined?(#{$1}) && ! #{$1}.nil?" }
+ if( valid_ruby_code?(cond) )
+ line = "#{indent}if( #{cond} )"
+ else
+ line = "#{indent}if( false ) # #{cond}"
+ end
+ line = [rescue_begin, line].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_elif(line)
+ case line
+ when /^#\s*elif\s+(.+)$/
+ cond = $1
+ cond.gsub!("defined","defined?")
+ line = "#{indent}elsif( #{cond} )"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_else(line)
+ case line
+ when /^#\s*else\s*/
+ line = "#{indent}else"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_endif(line)
+ case line
+ when /^#\s*endif\s*$/
+ line = ["#{indent}end", rescue_nameerror].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_include(line)
+ if( ! @insert_require )
+ return nil
+ end
+
+ file = nil
+ case line
+ when /^#\s*include "(.+)"$/
+ file = $1
+ line = "#{indent}require '#{file}'"
+ when /^#\s*include \<(.+)\>$/
+ file = $1
+ line = "#{indent}require '#{file}'"
+ else
+ line = nil
+ end
+ if( @recursive && file && (!@parsed_files.include?(file)) )
+ parse(file, @recursive, @force, @conly)
+ end
+ return line
+ end
+
+
+ def open_files(infilename)
+ if( ! infilename )
+ return [$stdin, $stdout]
+ end
+
+ old_infilename = infilename
+ infilename = find_path(infilename)
+ if( ! infilename )
+ $stderr.print("'#{old_infilename}' was not found.\n")
+ return [nil,nil]
+ end
+
+ if( infilename )
+ if( infilename[0,1] == '/' )
+ outfilename = File.join(@inc_dir, infilename[1..-1] + ".rb")
+ else
+ outfilename = infilename + ".rb"
+ end
+ File.mkpath(File.dirname(outfilename))
+ else
+ outfilename = nil
+ end
+
+ if( infilename )
+ fin = File.open(infilename,"r")
+ else
+ fin = $stdin
+ end
+ if( outfilename )
+ if( File.exist?(outfilename) && (!@force) )
+ $stderr.print("'#{outfilename}' have already existed.\n")
+ return [fin, nil]
+ end
+ fout = File.open(outfilename,"w")
+ else
+ fout = $stdout
+ end
+
+ $stderr.print("#{infilename} -> #{outfilename}\n")
+ if( fout )
+ dir = File.dirname(outfilename)
+ if( dir[0,1] != "." && dir != "" )
+ fout.print("if( ! $LOAD_PATH.include?('#{dir}') )\n",
+ " $LOAD_PATH.push('#{dir}')\n",
+ "end\n")
+ end
+ end
+ return [fin,fout]
+ end
+
+ def parse(infilename = nil, recursive = false, force = false, conly = false)
+ @commented = false
+ @recursive = recursive
+ @force = force
+ @conly = conly
+ @parsed_files << infilename
+
+ fin,fout = open_files(infilename)
+ if( !fin )
+ return
+ end
+
+ begin
+ line_number = 0
+ pre_line = nil
+ fin.each_line{|line|
+ line_number += 1
+ line.chop!
+ if( $DEBUG )
+ $stderr.print("#{line_number}:(#{@indent}):", line, "\n")
+ end
+
+ if( pre_line )
+ line = pre_line + line
+ pre_line = nil
+ end
+
+ if( line[-1,1] == "\\" )
+ pre_line = line[0..-2]
+ next
+ end
+
+ if( eidx = line.index("enum ") )
+ pre_line = line[eidx .. -1]
+ if( i = line.index("{") && j = line.index("}") )
+ line = line[0..j]
+ pre_line = nil
+ else
+ next
+ end
+ end
+
+ line = strip_comment(line)
+ case line
+ when /^enum\s/
+ line = parse_enum(line)
+ when /^#\s*define\s/
+ line = parse_define(line)
+ when /^#\s*undef\s/
+ line = parse_undef(line)
+ when /^#\s*ifdef\s/
+ line = parse_ifdef(line)
+ up_indent
+ when /^#\s*ifndef\s/
+ line = parse_ifndef(line)
+ up_indent
+ when /^#\s*if\s/
+ line = parse_if(line)
+ up_indent
+ when /^#\s*elif\s/
+ down_indent
+ line = parse_elif(line)
+ up_indent
+ when /^#\s*else/
+ down_indent
+ line = parse_else(line)
+ up_indent
+ when /^#\s*endif/
+ down_indent
+ line = parse_endif(line)
+ when /^#\s*include\s/
+ line = parse_include(line)
+ else
+ line = nil
+ end
+ if( line && fout )
+ fout.print(line, " # #{line_number}",$/)
+ end
+ }
+ ensure
+ fin.close if fin
+ fout.close if fout
+ end
+ end
+end
+
+h2rb = H2RB.new($inc_dir, $inc_path, $insert_require)
+h2rb.parse($infilename, $recursive, $force, $conly)
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 24269dfd78..69d47caac0 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -10,7 +10,7 @@ VALUE rb_cDLHandle;
void
dlhandle_free(struct dl_handle *dlhandle)
{
- if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
+ if (dlhandle->ptr && dlhandle->open && dlhandle->enable_close) {
dlclose(dlhandle->ptr);
}
}
@@ -50,11 +50,7 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
int cflag;
const char *err;
- switch( rb_scan_args(argc, argv, "02", &lib, &flag) ){
- case 0:
- clib = NULL;
- cflag = RTLD_LAZY | RTLD_GLOBAL;
- break;
+ switch (rb_scan_args(argc, argv, "11", &lib, &flag)) {
case 1:
clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
cflag = RTLD_LAZY | RTLD_GLOBAL;
@@ -69,24 +65,24 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
ptr = dlopen(clib, cflag);
#if defined(HAVE_DLERROR)
- if( !ptr && (err = dlerror()) ){
- rb_raise(rb_eDLError, "%s", err);
+ if (!ptr && (err = dlerror())) {
+ rb_raise(rb_eRuntimeError, "%s", err);
}
#else
- if( !ptr ){
+ if (!ptr) {
err = dlerror();
- rb_raise(rb_eDLError, "%s", err);
+ rb_raise(rb_eRuntimeError, "%s", err);
}
#endif
Data_Get_Struct(self, struct dl_handle, dlhandle);
- if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
+ if (dlhandle->ptr && dlhandle->open && dlhandle->enable_close) {
dlclose(dlhandle->ptr);
}
dlhandle->ptr = ptr;
dlhandle->open = 1;
dlhandle->enable_close = 0;
- if( rb_block_given_p() ){
+ if (rb_block_given_p()) {
rb_ensure(rb_yield, self, rb_dlhandle_close, self);
}
@@ -119,109 +115,101 @@ rb_dlhandle_to_i(VALUE self)
struct dl_handle *dlhandle;
Data_Get_Struct(self, struct dl_handle, dlhandle);
- return PTR2NUM(dlhandle);
+ return DLLONG2NUM(dlhandle);
}
VALUE
-rb_dlhandle_sym(VALUE self, VALUE sym)
+rb_dlhandle_to_ptr(VALUE self)
{
- void (*func)();
- struct dl_handle *dlhandle;
- void *handle;
- const char *name;
- const char *err;
- int i;
+ struct dl_handle *dlhandle;
-#if defined(HAVE_DLERROR)
-# define CHECK_DLERROR if( err = dlerror() ){ func = 0; }
-#else
-# define CHECK_DLERROR
-#endif
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ return rb_dlptr_new(dlhandle, sizeof(dlhandle), 0);
+}
- rb_secure(2);
+VALUE
+rb_dlhandle_sym(int argc, VALUE argv[], VALUE self)
+{
+ VALUE sym, type;
+ void (*func)();
+ VALUE val;
+ struct dl_handle *dlhandle;
+ void *handle;
+ const char *name, *stype;
+ const char *err;
+
+ rb_secure(2);
+ if (rb_scan_args(argc, argv, "11", &sym, &type) == 2) {
+ SafeStringValue(type);
+ stype = StringValuePtr(type);
+ }
+ else{
+ stype = NULL;
+ }
- if( sym == Qnil ){
+ if (sym == Qnil) {
#if defined(RTLD_NEXT)
- name = RTLD_NEXT;
+ name = RTLD_NEXT;
#else
- name = NULL;
+ name = NULL;
#endif
- }
- else{
- name = StringValuePtr(sym);
- }
-
+ }
+ else{
+ SafeStringValue(sym);
+ name = StringValuePtr(sym);
+ }
- Data_Get_Struct(self, struct dl_handle, dlhandle);
- if( ! dlhandle->open ){
- rb_raise(rb_eDLError, "closed handle");
- }
- handle = dlhandle->ptr;
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ if (!dlhandle->open) {
+ rb_raise(rb_eRuntimeError, "closed handle");
+ }
+ handle = dlhandle->ptr;
- func = dlsym(handle, name);
- CHECK_DLERROR;
- if( !func ){
+ func = dlsym(handle, name);
+#if defined(HAVE_DLERROR)
+ if (!func && (err = dlerror()))
+#else
+ if (!func)
+#endif
+ {
#if defined(__CYGWIN__) || defined(WIN32) || defined(__MINGW32__)
- {
- int len = strlen(name);
- char *name_a = (char*)xmalloc(len+2);
- strcpy(name_a, name);
- name_a[len] = 'A';
- name_a[len+1] = '\0';
- func = dlsym(handle, name_a);
- xfree(name_a);
- CHECK_DLERROR;
- if( !func ){
- for( i = 0; i < 256; i += 4 ){
- int len = strlen(name);
- char *name_n = (char*)xmalloc(len+5);
- sprintf(name_n, "%s@%d%c", name, i, 0);
- func = dlsym(handle, name_n);
- xfree(name_n);
- CHECK_DLERROR;
- if( func )
- {
- break;
- }
- }
- CHECK_DLERROR;
- if( !func ){
- rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
- }
- }
- }
+ {
+ int len = strlen(name);
+ char *name_a = (char*)dlmalloc(len+2);
+ strcpy(name_a, name);
+ name_a[len] = 'A';
+ name_a[len+1] = '\0';
+ func = dlsym(handle, name_a);
+ dlfree(name_a);
+#if defined(HAVE_DLERROR)
+ if (!func && (err = dlerror()))
#else
- for( i = 0; i < 256; i += 4 ){
- int len = strlen(name);
- char *name_n = (char*)xmalloc(len+4);
- sprintf(name_n, "%s@%d", name, i);
- func = dlsym(handle, name_n);
- xfree(name_n);
- CHECK_DLERROR;
- if( func ){
- break;
- }
- }
- CHECK_DLERROR;
- if( !func ){
- rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
- }
+ if (!func)
#endif
+ {
+ rb_raise(rb_eRuntimeError, "unknown symbol \"%sA\"", name);
+ }
}
+#else
+ rb_raise(rb_eRuntimeError, "unknown symbol \"%s\"", name);
+#endif
+ }
+ val = rb_dlsym_new(func, name, stype);
- return PTR2NUM(func);
+ return val;
}
void
Init_dlhandle()
{
- rb_cDLHandle = rb_define_class_under(rb_mDL, "Handle", rb_cObject);
- rb_define_alloc_func(rb_cDLHandle, rb_dlhandle_s_allocate);
- rb_define_method(rb_cDLHandle, "initialize", rb_dlhandle_initialize, -1);
- rb_define_method(rb_cDLHandle, "to_i", rb_dlhandle_to_i, 0);
- rb_define_method(rb_cDLHandle, "close", rb_dlhandle_close, 0);
- rb_define_method(rb_cDLHandle, "sym", rb_dlhandle_sym, 1);
- rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, 1);
- rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0);
- rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0);
+ rb_cDLHandle = rb_define_class_under(rb_mDL, "Handle", rb_cObject);
+ rb_define_alloc_func(rb_cDLHandle, rb_dlhandle_s_allocate);
+ rb_define_method(rb_cDLHandle, "initialize", rb_dlhandle_initialize, -1);
+ rb_define_method(rb_cDLHandle, "to_i", rb_dlhandle_to_i, 0);
+ rb_define_method(rb_cDLHandle, "to_ptr", rb_dlhandle_to_ptr, 0);
+ rb_define_method(rb_cDLHandle, "close", rb_dlhandle_close, 0);
+ rb_define_method(rb_cDLHandle, "sym", rb_dlhandle_sym, -1);
+ rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, -1);
+ rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0);
+ rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0);
}
diff --git a/ext/dl/install.rb b/ext/dl/install.rb
new file mode 100644
index 0000000000..69b1834301
--- /dev/null
+++ b/ext/dl/install.rb
@@ -0,0 +1,49 @@
+require 'mkmf'
+require 'ftools'
+
+SO_LIBS = ["dl.so"]
+
+$ruby_version = CONFIG['MAJOR'] + "." + CONFIG['MINOR']
+$prefix = CONFIG['prefix']
+$libdir = File.join($prefix,'lib')
+$rubylibdir = File.join($libdir, 'ruby', $ruby_version)
+$arch = CONFIG['arch']
+$archdir = File.join($rubylibdir, $arch)
+
+def find(dir, match = /./)
+ Dir.chdir(dir)
+ files = []
+ Dir.new(".").each{|file|
+ if( file != "." && file != ".." )
+ case File.ftype(file)
+ when "file"
+ if( file =~ match )
+ files.push(File.join(dir,file))
+ end
+ when "directory"
+ files += find(file, match).collect{|f| File.join(dir,f)}
+ end
+ end
+ }
+ Dir.chdir("..")
+ return files
+end
+
+def install()
+ rb_files = find(File.join(".","lib"), /.rb$/)
+
+ SO_LIBS.each{|f|
+ File.makedirs($rubylibdir, "#{$archdir}")
+ File.install(f, File.join($archdir,f), 0555, true)
+ }
+
+ rb_files.each{|f|
+ origfile = f
+ instfile = File.join($rubylibdir, origfile.sub("./lib/",""))
+ instdir = File.dirname(instfile)
+ File.makedirs(instdir)
+ File.install(origfile, instfile, 0644, true)
+ }
+end
+
+install()
diff --git a/ext/dl/lib/dl/callback.rb b/ext/dl/lib/dl/callback.rb
deleted file mode 100644
index d0b2c7a819..0000000000
--- a/ext/dl/lib/dl/callback.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'dl'
-require 'thread'
-
-module DL
- SEM = Mutex.new
-
- def set_callback_internal(proc_entry, addr_entry, argc, ty, &cbp)
- if( argc < 0 )
- raise(ArgumentError, "arity should not be less than 0.")
- end
- addr = nil
- SEM.synchronize{
- ary = proc_entry[ty]
- (0...MAX_CALLBACK).each{|n|
- idx = (n * DLSTACK_SIZE) + argc
- if( ary[idx].nil? )
- ary[idx] = cbp
- addr = addr_entry[ty][idx]
- break
- end
- }
- }
- addr
- end
-
- def set_cdecl_callback(ty, argc, &cbp)
- set_callback_internal(CdeclCallbackProcs, CdeclCallbackAddrs, argc, ty, &cbp)
- end
-
- def set_stdcall_callback(ty, argc, &cbp)
- set_callback_internal(StdcallCallbackProcs, StdcallCallbackAddrs, argc, ty, &cbp)
- end
-
- def remove_callback_internal(proc_entry, addr_entry, addr, ctype = nil)
- index = nil
- if( ctype )
- addr_entry[ctype].each_with_index{|xaddr, idx|
- if( xaddr == addr )
- index = idx
- end
- }
- else
- addr_entry.each{|ty,entry|
- entry.each_with_index{|xaddr, idx|
- if( xaddr == addr )
- index = idx
- end
- }
- }
- end
- if( proc_entry[ctype][index] )
- proc_entry[ctype][index] = nil
- return true
- else
- return false
- end
- end
-
- def remove_cdecl_callback(addr, ctype = nil)
- remove_callback_internal(CdeclCallbackProcs, CdeclCallbackAddrs, addr, ctype)
- end
-
- def remove_stdcall_callback(addr, ctype = nil)
- remove_callback_internal(StdcallCallbackProcs, StdcallCallbackAddrs, addr, ctype)
- end
-
- alias set_callback set_cdecl_callback
- alias remove_callback remove_cdecl_callback
-end
diff --git a/ext/dl/lib/dl/cparser.rb b/ext/dl/lib/dl/cparser.rb
deleted file mode 100644
index c897d1b69f..0000000000
--- a/ext/dl/lib/dl/cparser.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-module DL
- module CParser
- def parse_struct_signature(signature, tymap=nil)
- if( signature.is_a?(String) )
- signature = signature.split("\s*,\s*")
- end
- mems = []
- tys = []
- signature.each{|msig|
- tks = msig.split(/\s+(\*)?/)
- ty = tks[0..-2].join(" ")
- member = tks[-1]
-
- case ty
- when /\[(\d+)\]/
- n = $1.to_i
- ty.gsub!(/\s*\[\d+\]/,"")
- ty = [ty, n]
- when /\[\]/
- ty.gsub!(/\s*\[\]/, "*")
- end
-
- case member
- when /\[(\d+)\]/
- ty = [ty, $1.to_i]
- member.gsub!(/\s*\[\d+\]/,"")
- when /\[\]/
- ty = ty + "*"
- member.gsub!(/\s*\[\]/, "")
- end
-
- mems.push(member)
- tys.push(parse_ctype(ty,tymap))
- }
- return tys, mems
- end
-
- def parse_signature(signature, tymap=nil)
- tymap ||= {}
- signature = signature.gsub(/\s+/, " ").strip
- case signature
- when /^([\d\w@\*_\s]+)\(([\d\w\*_\s\,\[\]]*)\)$/
- ret = $1
- args = $2
- ret = ret.split(/\s+/)
- args = args.split(/\s*,\s*/)
- func = ret.pop
- if( func =~ /^\*/ )
- func.gsub!(/^\*+/,"")
- ret.push("*")
- end
- ret = ret.join(" ")
- return [func, parse_ctype(ret, tymap), args.collect{|arg| parse_ctype(arg, tymap)}]
- else
- raise(RuntimeError,"can't parse the function prototype: #{proto}")
- end
- end
-
- def parse_ctype(ty, tymap=nil)
- tymap ||= {}
- case ty
- when Array
- return [parse_ctype(ty[0], tymap), ty[1]]
- when "void"
- return TYPE_VOID
- when "char"
- return TYPE_CHAR
- when "unsigned char"
- return -TYPE_CHAR
- when "short"
- return TYPE_SHORT
- when "unsigned short"
- return -TYPE_SHORT
- when "int"
- return TYPE_INT
- when "unsigned int"
- return -TYPE_INT
- when "long"
- return TYPE_LONG
- when "unsigned long"
- return -TYPE_LONG
- when "long long"
- if( defined?(TYPE_LONG_LONG) )
- return TYPE_LONG_LONG
- else
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- when "unsigned long long"
- if( defined?(TYPE_LONG_LONG) )
- return -TYPE_LONG_LONG
- else
- raise(RuntimeError, "unsupported type: #{ty}")
- end
- when "float"
- return TYPE_FLOAT
- when "double"
- return TYPE_DOUBLE
- when /\*/, /\[\s*\]/
- return TYPE_VOIDP
- else
- if( tymap[ty] )
- return parse_ctype(tymap[ty], tymap)
- else
- raise(DLError, "unknown type: #{ty}")
- end
- end
- end
- end
-end
diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb
deleted file mode 100644
index b29aebcc8b..0000000000
--- a/ext/dl/lib/dl/func.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-require 'dl'
-require 'dl/callback'
-require 'dl/stack'
-require 'dl/value'
-require 'thread'
-
-module DL
- class Function
- include DL
- include ValueUtil
-
- def initialize(cfunc, argtypes, &proc)
- @cfunc = cfunc
- @stack = Stack.new(argtypes.collect{|ty| ty.abs})
- if( @cfunc.ctype < 0 )
- @cfunc.ctype = @cfunc.ctype.abs
- @unsigned = true
- end
- if( proc )
- bind(&proc)
- end
- end
-
- def to_i()
- @cfunc.to_i
- end
-
- def call(*args, &block)
- funcs = []
- args = wrap_args(args, @stack.types, funcs, &block)
- r = @cfunc.call(@stack.pack(args))
- funcs.each{|f| f.unbind_at_call()}
- return wrap_result(r)
- end
-
- def wrap_result(r)
- case @cfunc.ctype
- when TYPE_VOIDP
- r = CPtr.new(r)
- else
- if( @unsigned )
- r = unsigned_value(r, @cfunc.ctype)
- end
- end
- r
- end
-
- def bind(&block)
- if( !block )
- raise(RuntimeError, "block must be given.")
- end
- if( @cfunc.ptr == 0 )
- cb = Proc.new{|*args|
- ary = @stack.unpack(args)
- @stack.types.each_with_index{|ty, idx|
- case ty
- when TYPE_VOIDP
- ary[idx] = CPtr.new(ary[idx])
- end
- }
- r = block.call(*ary)
- wrap_arg(r, @cfunc.ctype, [])
- }
- case @cfunc.calltype
- when :cdecl
- @cfunc.ptr = set_cdecl_callback(@cfunc.ctype, @stack.size, &cb)
- when :stdcall
- @cfunc.ptr = set_stdcall_callback(@cfunc.ctype, @stack.size, &cb)
- else
- raise(RuntimeError, "unsupported calltype: #{@cfunc.calltype}")
- end
- if( @cfunc.ptr == 0 )
- raise(RuntimeException, "can't bind C function.")
- end
- end
- end
-
- def unbind()
- if( @cfunc.ptr != 0 )
- case @cfunc.calltype
- when :cdecl
- remove_cdecl_callback(@cfunc.ptr, @cfunc.ctype)
- when :stdcall
- remove_stdcall_callback(@cfunc.ptr, @cfunc.ctype)
- else
- raise(RuntimeError, "unsupported calltype: #{@cfunc.calltype}")
- end
- @cfunc.ptr = 0
- end
- end
-
- def bind_at_call(&block)
- bind(&block)
- end
-
- def unbind_at_call()
- end
- end
-
- class TempFunction < Function
- def bind_at_call(&block)
- bind(&block)
- end
-
- def unbind_at_call()
- unbind()
- end
- end
-
- class CarriedFunction < Function
- def initialize(cfunc, argtypes, n)
- super(cfunc, argtypes)
- @carrier = []
- @index = n
- @mutex = Mutex.new
- end
-
- def create_carrier(data)
- ary = []
- userdata = [ary, data]
- @mutex.lock()
- @carrier.push(userdata)
- return dlwrap(userdata)
- end
-
- def bind_at_call(&block)
- userdata = @carrier[-1]
- userdata[0].push(block)
- bind{|*args|
- ptr = args[@index]
- if( !ptr )
- raise(RuntimeError, "The index of userdata should be lower than #{args.size}.")
- end
- userdata = dlunwrap(Integer(ptr))
- args[@index] = userdata[1]
- userdata[0][0].call(*args)
- }
- @mutex.unlock()
- end
- end
-end
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index f6fb35944d..01ee2490e8 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -1,215 +1,225 @@
+# -*- ruby -*-
+
require 'dl'
-require 'dl/func.rb'
-require 'dl/struct.rb'
-require 'dl/cparser.rb'
+require 'dl/types'
module DL
- class CompositeHandler
- def initialize(handlers)
- @handlers = handlers
- end
-
- def handlers()
- @handlers
- end
-
- def sym(symbol)
- @handlers.each{|handle|
- if( handle )
- begin
- addr = handle.sym(symbol)
- return addr
- rescue DLError
- end
- end
- }
- return nil
- end
-
- def [](symbol)
- sym(symbol)
- end
- end
-
- module Importer
- include DL
- include CParser
- extend Importer
-
- def dlload(*libs)
- handles = libs.collect{|lib|
- case lib
- when nil
- nil
- when Handle
- lib
- when Importer
- lib.handlers
- else
- begin
- DL.dlopen(lib)
- rescue DLError
- raise(DLError, "can't load #{lib}")
- end
- end
- }.flatten()
- @handler = CompositeHandler.new(handles)
- @func_map = {}
- @type_alias = {}
- end
-
- def typealias(alias_type, orig_type)
- @type_alias[alias_type] = orig_type
- end
-
- def sizeof(ty)
- case ty
- when String
- ty = parse_ctype(ty, @type_alias).abs()
- case ty
- when TYPE_CHAR
- return SIZEOF_CHAR
- when TYPE_SHORT
- return SIZEOF_SHORT
- when TYPE_INT
- return SIZEOF_INT
- when TYPE_LONG
- return SIZEOF_LONG
- when TYPE_LONG_LONG
- return SIZEOF_LONG_LON
- when TYPE_FLOAT
- return SIZEOF_FLOAT
- when TYPE_DOUBLE
- return SIZEOF_DOUBLE
- when TYPE_VOIDP
- return SIZEOF_VOIDP
- else
- raise(DLError, "unknown type: #{ty}")
- end
- when Class
- if( ty.instance_methods().include?("to_ptr") )
- return ty.size()
- end
+ module Importable
+ LIB_MAP = {}
+
+ module Internal
+ def init_types()
+ @types ||= ::DL::Types.new
end
- return CPtr[ty].size()
- end
-
- def parse_bind_options(opts)
- h = {}
- prekey = nil
- while( opt = opts.shift() )
- case opt
- when :stdcall, :cdecl
- h[:call_type] = opt
- when :carried, :temp, :temporal, :bind
- h[:callback_type] = opt
- h[:carrier] = opts.shift()
- else
- h[opt] = true
- end
+
+ def init_sym()
+ @SYM ||= {}
+ end
+
+ def [](name)
+ return @SYM[name.to_s][0]
+ end
+
+ def dlload(*libnames)
+ if( !defined?(@LIBS) )
+ @LIBS = []
+ end
+ libnames.each{|libname|
+ if( !LIB_MAP[libname] )
+ LIB_MAP[libname] = DL.dlopen(libname)
+ end
+ @LIBS.push(LIB_MAP[libname])
+ }
+ end
+ alias dllink :dlload
+
+ def parse_cproto(proto)
+ proto = proto.gsub(/\s+/, " ").strip
+ case proto
+ when /^([\d\w\*_\s]+)\(([\d\w\*_\s\,\[\]]*)\)$/
+ ret = $1
+ args = $2.strip()
+ ret = ret.split(/\s+/)
+ args = args.split(/\s*,\s*/)
+ func = ret.pop()
+ if( func =~ /^\*/ )
+ func.gsub!(/^\*+/,"")
+ ret.push("*")
+ end
+ ret = ret.join(" ")
+ return [func, ret, args]
+ else
+ raise(RuntimeError,"can't parse the function prototype: #{proto}")
+ end
end
- h
- end
- private :parse_bind_options
-
- def extern(signature, *opts)
- symname, ctype, argtype = parse_signature(signature, @type_alias)
- opt = parse_bind_options(opts)
- f = import_function(symname, ctype, argtype, opt[:call_type])
- name = symname.gsub(/@.+/,'')
- @func_map[name] = f
- # define_method(name){|*args,&block| f.call(*args,&block)}
- module_eval(<<-EOS)
- def #{name}(*args, &block)
- @func_map['#{name}'].call(*args,&block)
+
+ # example:
+ # extern "int strlen(char*)"
+ #
+ def extern(proto)
+ func,ret,args = parse_cproto(proto)
+ return import(func, ret, args)
+ end
+
+ # example:
+ # callback "int method_name(int, char*)"
+ #
+ def callback(proto)
+ func,ret,args = parse_cproto(proto)
+
+ init_types()
+ init_sym()
+
+ rty,renc,rdec = @types.encode_return_type(ret)
+ if( !rty )
+ raise(TypeError, "unsupported type: #{ret}")
end
- EOS
- module_function(name)
- f
- end
-
- def bind(signature, *opts, &blk)
- name, ctype, argtype = parse_signature(signature, @type_alias)
- h = parse_bind_options(opts)
- case h[:callback_type]
- when :bind, nil
- f = bind_function(name, ctype, argtype, h[:call_type], &blk)
- when :temp, :temporal
- f = create_temp_function(name, ctype, argtype, h[:call_type])
- when :carried
- f = create_carried_function(name, ctype, argtype, h[:call_type], h[:carrier])
- else
- raise(RuntimeError, "unknown callback type: #{h[:callback_type]}")
+ ty,enc,dec = encode_argument_types(args)
+ symty = rty + ty
+
+ module_eval("module_function :#{func}")
+ sym = module_eval([
+ "DL::callback(\"#{symty}\"){|*args|",
+ " sym,rdec,enc,dec = @SYM['#{func}']",
+ " args = enc.call(args) if enc",
+ " r,rs = #{func}(*args)",
+ " r = renc.call(r) if rdec",
+ " rs = dec.call(rs) if (dec && rs)",
+ " @retval = r",
+ " @args = rs",
+ " r",
+ "}",
+ ].join("\n"))
+
+ @SYM[func] = [sym,rdec,enc,dec]
+
+ return sym
+ end
+
+ # example:
+ # typealias("uint", "unsigned int")
+ #
+ def typealias(alias_type, ty1, enc1=nil, dec1=nil, ty2=nil, enc2=nil, dec2=nil)
+ init_types()
+ @types.typealias(alias_type, ty1, enc1, dec1,
+ ty2||ty1, enc2, dec2)
end
- @func_map[name] = f
- #define_method(name){|*args,&block| f.call(*args,&block)}
- module_eval(<<-EOS)
- def #{name}(*args,&block)
- @func_map['#{name}'].call(*args,&block)
+
+ # example:
+ # symbol "foo_value"
+ # symbol "foo_func", "IIP"
+ #
+ def symbol(name, ty = nil)
+ sym = nil
+ @LIBS.each{|lib|
+ begin
+ if( ty )
+ sym = lib[name, ty]
+ else
+ sym = lib[name]
+ end
+ rescue
+ next
+ end
+ }
+ if( !sym )
+ raise(RuntimeError, "can't find the symbol `#{name}'")
+ end
+ return sym
+ end
+
+ # example:
+ # import("get_length", "int", ["void*", "int"])
+ #
+ def import(name, rettype, argtypes = nil)
+ init_types()
+ init_sym()
+
+ rty,_,rdec = @types.encode_return_type(rettype)
+ if( !rty )
+ raise(TypeError, "unsupported type: #{rettype}")
end
- EOS
- module_function(name)
- f
- end
-
- def struct(signature)
- tys, mems = parse_struct_signature(signature, @type_alias)
- DL::CStructBuilder.create(CStruct, tys, mems)
- end
-
- def union(signature)
- tys, mems = parse_struct_signature(signature, @type_alias)
- DL::CStructBuilder.create(CUnion, tys, mems)
- end
-
- def [](name)
- @func_map[name]
- end
-
- def create_value(ty, val=nil)
- s = struct([ty + " value"])
- ptr = s.malloc()
- if( val )
- ptr.value = val
+ ty,enc,dec = encode_argument_types(argtypes)
+ symty = rty + ty
+
+ sym = symbol(name, symty)
+
+ mname = name.dup
+ if( ?A <= mname[0] && mname[0] <= ?Z )
+ mname[0,1] = mname[0,1].downcase
+ end
+ @SYM[mname] = [sym,rdec,enc,dec]
+
+ module_eval [
+ "def #{mname}(*args)",
+ " sym,rdec,enc,dec = @SYM['#{mname}']",
+ " args = enc.call(args) if enc",
+ if( $DEBUG )
+ " p \"[DL] call #{mname} with \#{args.inspect}\""
+ else
+ ""
+ end,
+ " r,rs = sym.call(*args)",
+ if( $DEBUG )
+ " p \"[DL] retval=\#{r.inspect} args=\#{rs.inspect}\""
+ else
+ ""
+ end,
+ " r = rdec.call(r) if rdec",
+ " rs = dec.call(rs) if dec",
+ " @retval = r",
+ " @args = rs",
+ " return r",
+ "end",
+ "module_function :#{mname}",
+ ].join("\n")
+
+ return sym
end
- return ptr
- end
- alias value create_value
-
- def import_value(ty, addr)
- s = struct([ty + " value"])
- ptr = s.new(addr)
- return ptr
- end
-
- def import_symbol(name)
- addr = @handler.sym(name)
- if( !addr )
- raise(DLError, "cannot find the symbol: #{name}")
+
+ def _args_
+ return @args
end
- CPtr.new(addr)
- end
- def import_function(name, ctype, argtype, call_type = nil)
- addr = @handler.sym(name)
- if( !addr )
- raise(DLError, "cannot find the function: #{name}()")
+ def _retval_
+ return @retval
+ end
+
+ def encode_argument_types(tys)
+ init_types()
+ encty = []
+ enc = nil
+ dec = nil
+ tys.each_with_index{|ty,idx|
+ ty,c1,c2 = @types.encode_argument_type(ty)
+ if( !ty )
+ raise(TypeError, "unsupported type: #{ty}")
+ end
+ encty.push(ty)
+ if( enc )
+ if( c1 )
+ conv1 = enc
+ enc = proc{|v| v = conv1.call(v); v[idx] = c1.call(v[idx]); v}
+ end
+ else
+ if( c1 )
+ enc = proc{|v| v[idx] = c1.call(v[idx]); v}
+ end
+ end
+ if( dec )
+ if( c2 )
+ conv2 = dec
+ dec = proc{|v| v = conv2.call(v); v[idx] = c2.call(v[idx]); v}
+ end
+ else
+ if( c2 )
+ dec = proc{|v| v[idx] = c2.call(v[idx]); v}
+ end
+ end
+ }
+ return [encty.join, enc, dec]
end
- Function.new(CFunc.new(addr, ctype, name, call_type || :cdecl), argtype)
- end
-
- def bind_function(name, ctype, argtype, call_type = nil, &block)
- f = Function.new(CFunc.new(0, ctype, name, call_type || :cdecl), argtype)
- f.bind(&block)
- f
- end
-
- def create_temp_function(name, ctype, argtype, call_type = nil)
- TempFunction.new(CFunc.new(0, ctype, name, call_type || :cdecl), argtype)
- end
-
- def create_carried_function(name, ctype, argtype, call_type = nil, n = 0)
- CarriedFunction.new(CFunc.new(0, ctype, name, call_type || :cdecl), argtype, n)
- end
- end
+ end # end of Internal
+ include Internal
+ end # end of Importable
end
diff --git a/ext/dl/lib/dl/pack.rb b/ext/dl/lib/dl/pack.rb
deleted file mode 100644
index ad91833b3a..0000000000
--- a/ext/dl/lib/dl/pack.rb
+++ /dev/null
@@ -1,173 +0,0 @@
-require 'dl'
-
-module DL
- module PackInfo
- if( defined?(TYPE_LONG_LONG) )
- ALIGN_MAP = {
- TYPE_VOIDP => ALIGN_VOIDP,
- TYPE_CHAR => ALIGN_CHAR,
- TYPE_SHORT => ALIGN_SHORT,
- TYPE_INT => ALIGN_INT,
- TYPE_LONG => ALIGN_LONG,
- TYPE_LONG_LONG => ALIGN_LONG_LONG,
- TYPE_FLOAT => ALIGN_FLOAT,
- TYPE_DOUBLE => ALIGN_DOUBLE,
- -TYPE_CHAR => ALIGN_CHAR,
- -TYPE_SHORT => ALIGN_SHORT,
- -TYPE_INT => ALIGN_INT,
- -TYPE_LONG => ALIGN_LONG,
- -TYPE_LONG_LONG => ALIGN_LONG_LONG,
- }
-
- PACK_MAP = {
- TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG) ? "q" : "l!"),
- TYPE_CHAR => "c",
- TYPE_SHORT => "s!",
- TYPE_INT => "i!",
- TYPE_LONG => "l!",
- TYPE_LONG_LONG => "q",
- TYPE_FLOAT => "f",
- TYPE_DOUBLE => "d",
- -TYPE_CHAR => "c",
- -TYPE_SHORT => "s!",
- -TYPE_INT => "i!",
- -TYPE_LONG => "l!",
- -TYPE_LONG_LONG => "q",
- }
-
- SIZE_MAP = {
- TYPE_VOIDP => SIZEOF_VOIDP,
- TYPE_CHAR => SIZEOF_CHAR,
- TYPE_SHORT => SIZEOF_SHORT,
- TYPE_INT => SIZEOF_INT,
- TYPE_LONG => SIZEOF_LONG,
- TYPE_LONG_LONG => SIZEOF_LONG_LONG,
- TYPE_FLOAT => SIZEOF_FLOAT,
- TYPE_DOUBLE => SIZEOF_DOUBLE,
- -TYPE_CHAR => SIZEOF_CHAR,
- -TYPE_SHORT => SIZEOF_SHORT,
- -TYPE_INT => SIZEOF_INT,
- -TYPE_LONG => SIZEOF_LONG,
- -TYPE_LONG_LONG => SIZEOF_LONG_LONG,
- }
- else
- ALIGN_MAP = {
- TYPE_VOIDP => ALIGN_VOIDP,
- TYPE_CHAR => ALIGN_CHAR,
- TYPE_SHORT => ALIGN_SHORT,
- TYPE_INT => ALIGN_INT,
- TYPE_LONG => ALIGN_LONG,
- TYPE_FLOAT => ALIGN_FLOAT,
- TYPE_DOUBLE => ALIGN_DOUBLE,
- -TYPE_CHAR => ALIGN_CHAR,
- -TYPE_SHORT => ALIGN_SHORT,
- -TYPE_INT => ALIGN_INT,
- -TYPE_LONG => ALIGN_LONG,
- }
-
- PACK_MAP = {
- TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG) ? "q" : "l!"),
- TYPE_CHAR => "c",
- TYPE_SHORT => "s!",
- TYPE_INT => "i!",
- TYPE_LONG => "l!",
- TYPE_FLOAT => "f",
- TYPE_DOUBLE => "d",
- -TYPE_CHAR => "c",
- -TYPE_SHORT => "s!",
- -TYPE_INT => "i!",
- -TYPE_LONG => "l!",
- }
-
- SIZE_MAP = {
- TYPE_VOIDP => SIZEOF_VOIDP,
- TYPE_CHAR => SIZEOF_CHAR,
- TYPE_SHORT => SIZEOF_SHORT,
- TYPE_INT => SIZEOF_INT,
- TYPE_LONG => SIZEOF_LONG,
- TYPE_FLOAT => SIZEOF_FLOAT,
- TYPE_DOUBLE => SIZEOF_DOUBLE,
- -TYPE_CHAR => SIZEOF_CHAR,
- -TYPE_SHORT => SIZEOF_SHORT,
- -TYPE_INT => SIZEOF_INT,
- -TYPE_LONG => SIZEOF_LONG,
- }
- end
-
- def align(addr, align)
- d = addr % align
- if( d == 0 )
- addr
- else
- addr + (align - d)
- end
- end
- module_function :align
- end
-
- class Packer
- include PackInfo
-
- def Packer.[](*types)
- Packer.new(types)
- end
-
- def initialize(types)
- parse_types(types)
- end
-
- def size()
- @size
- end
-
- def pack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.pack(@template)
- when SIZEOF_LONG
- ary.pack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
-
- def unpack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.join().unpack(@template)
- when SIZEOF_LONG_LONG
- ary.join().unpack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
-
- private
-
- def parse_types(types)
- @template = ""
- addr = 0
- types.each{|t|
- orig_addr = addr
- if( t.is_a?(Array) )
- addr = align(orig_addr, ALIGN_MAP[TYPE_VOIDP])
- else
- addr = align(orig_addr, ALIGN_MAP[t])
- end
- d = addr - orig_addr
- if( d > 0 )
- @template << "x#{d}"
- end
- if( t.is_a?(Array) )
- @template << (PACK_MAP[t[0]] * t[1])
- addr += (SIZE_MAP[t[0]] * t[1])
- else
- @template << PACK_MAP[t]
- addr += SIZE_MAP[t]
- end
- }
- addr = align(addr, ALIGN_MAP[TYPE_VOIDP])
- @size = addr
- end
- end
-end
diff --git a/ext/dl/lib/dl/stack.rb b/ext/dl/lib/dl/stack.rb
deleted file mode 100644
index 9daf089775..0000000000
--- a/ext/dl/lib/dl/stack.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-require 'dl'
-
-module DL
- class Stack
- def Stack.[](*types)
- Stack.new(types)
- end
-
- def initialize(types)
- parse_types(types)
- end
-
- def size()
- @size
- end
-
- def types()
- @types
- end
-
- def pack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.pack(@template).unpack('l!*')
- when SIZEOF_LONG_LONG
- ary.pack(@template).unpack('q*')
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
-
- def unpack(ary)
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- ary.pack('l!*').unpack(@template)
- when SIZEOF_LONG_LONG
- ary.pack('q*').unpack(@template)
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
-
- private
-
- def align(addr, align)
- d = addr % align
- if( d == 0 )
- addr
- else
- addr + (align - d)
- end
- end
-
-if( defined?(TYPE_LONG_LONG) )
- ALIGN_MAP = {
- TYPE_VOIDP => ALIGN_VOIDP,
- TYPE_CHAR => ALIGN_VOIDP,
- TYPE_SHORT => ALIGN_VOIDP,
- TYPE_INT => ALIGN_VOIDP,
- TYPE_LONG => ALIGN_VOIDP,
- TYPE_LONG_LONG => ALIGN_LONG_LONG,
- TYPE_FLOAT => ALIGN_FLOAT,
- TYPE_DOUBLE => ALIGN_DOUBLE,
- }
-
- PACK_MAP = {
- TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG)? "q" : "l!"),
- TYPE_CHAR => "c",
- TYPE_SHORT => "s!",
- TYPE_INT => "i!",
- TYPE_LONG => "l!",
- TYPE_LONG_LONG => "q",
- TYPE_FLOAT => "f",
- TYPE_DOUBLE => "d",
- }
-
- SIZE_MAP = {
- TYPE_VOIDP => SIZEOF_VOIDP,
- TYPE_CHAR => SIZEOF_CHAR,
- TYPE_SHORT => SIZEOF_SHORT,
- TYPE_INT => SIZEOF_INT,
- TYPE_LONG => SIZEOF_LONG,
- TYPE_LONG_LONG => SIZEOF_LONG_LONG,
- TYPE_FLOAT => SIZEOF_FLOAT,
- TYPE_DOUBLE => SIZEOF_DOUBLE,
- }
-else
- ALIGN_MAP = {
- TYPE_VOIDP => ALIGN_VOIDP,
- TYPE_CHAR => ALIGN_VOIDP,
- TYPE_SHORT => ALIGN_VOIDP,
- TYPE_INT => ALIGN_VOIDP,
- TYPE_LONG => ALIGN_VOIDP,
- TYPE_FLOAT => ALIGN_FLOAT,
- TYPE_DOUBLE => ALIGN_DOUBLE,
- }
-
- PACK_MAP = {
- TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG)? "q" : "l!"),
- TYPE_CHAR => "c",
- TYPE_SHORT => "s!",
- TYPE_INT => "i!",
- TYPE_LONG => "l!",
- TYPE_FLOAT => "f",
- TYPE_DOUBLE => "d",
- }
-
- SIZE_MAP = {
- TYPE_VOIDP => SIZEOF_VOIDP,
- TYPE_CHAR => SIZEOF_CHAR,
- TYPE_SHORT => SIZEOF_SHORT,
- TYPE_INT => SIZEOF_INT,
- TYPE_LONG => SIZEOF_LONG,
- TYPE_FLOAT => SIZEOF_FLOAT,
- TYPE_DOUBLE => SIZEOF_DOUBLE,
- }
-end
-
- def parse_types(types)
- @types = types
- @template = ""
- addr = 0
- types.each{|t|
- orig_addr = addr
- addr = align(orig_addr, ALIGN_MAP[t])
- d = addr - orig_addr
- if( d > 0 )
- @template << "x#{d}"
- end
- @template << PACK_MAP[t]
- addr += SIZE_MAP[t]
- }
- if( addr % SIZEOF_VOIDP == 0 )
- @size = addr / SIZEOF_VOIDP
- else
- @size = (addr / SIZEOF_VOIDP) + 1
- end
- end
- end
-end
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 4272b3960c..33f303fe22 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -1,213 +1,149 @@
+# -*- ruby -*-
+
require 'dl'
-require 'dl/pack.rb'
+require 'dl/import'
module DL
- class CStruct
- def CStruct.entity_class()
- CStructEntity
- end
- end
-
- class CUnion
- def CUnion.entity_class()
- CUnionEntity
- end
- end
-
- module CStructBuilder
- def create(klass, types, members)
- new_class = Class.new(klass){
- define_method(:initialize){|addr|
- @entity = klass.entity_class.new(addr, types)
- @entity.assign_names(members)
- }
- define_method(:to_ptr){ @entity }
- define_method(:to_i){ @entity.to_i }
- members.each{|name|
- define_method(name){ @entity[name] }
- define_method(name + "="){|val| @entity[name] = val }
- }
- }
- size = klass.entity_class.size(types)
- new_class.module_eval(<<-EOS)
- def new_class.size()
- #{size}
- end
- def new_class.malloc()
- addr = DL.malloc(#{size})
- new(addr)
- end
- EOS
- return new_class
- end
- module_function :create
- end
-
- class CStructEntity < CPtr
- include PackInfo
- include ValueUtil
-
- def CStructEntity.malloc(types, func = nil)
- addr = DL.malloc(CStructEntity.size(types))
- CStructEntity.new(addr, types, func)
- end
-
- def CStructEntity.size(types)
- offset = 0
- max_align = 0
- types.each_with_index{|t,i|
- orig_offset = offset
- if( t.is_a?(Array) )
- align = PackInfo::ALIGN_MAP[t[0]]
- offset = PackInfo.align(orig_offset, align)
- size = offset - orig_offset
- offset += (PackInfo::SIZE_MAP[t[0]] * t[1])
- else
- align = PackInfo::ALIGN_MAP[t]
- offset = PackInfo.align(orig_offset, align)
- size = offset - orig_offset
- offset += PackInfo::SIZE_MAP[t]
- end
- if (max_align < align)
- max_align = align
- end
- }
- offset = PackInfo.align(offset, max_align)
- offset
- end
-
- def initialize(addr, types, func = nil)
- set_ctypes(types)
- super(addr, @size, func)
- end
-
- def assign_names(members)
- @members = members
- end
-
- def set_ctypes(types)
- @ctypes = types
- @offset = []
- offset = 0
- max_align = 0
- types.each_with_index{|t,i|
- orig_offset = offset
- if( t.is_a?(Array) )
- align = ALIGN_MAP[t[0]]
- else
- align = ALIGN_MAP[t]
- end
- offset = PackInfo.align(orig_offset, align)
- size = offset - orig_offset
- @offset[i] = offset
- if( t.is_a?(Array) )
- offset += (SIZE_MAP[t[0]] * t[1])
- else
- offset += SIZE_MAP[t]
- end
- if (max_align < align)
- max_align = align
- end
- }
- offset = PackInfo.align(offset, max_align)
- @size = offset
- end
-
- def [](name)
- idx = @members.index(name)
- if( idx.nil? )
- raise(ArgumentError, "no such member: #{name}")
+ module Importable
+ module Internal
+ def define_struct(contents)
+ init_types()
+ Struct.new(@types, contents)
end
- ty = @ctypes[idx]
- if( ty.is_a?(Array) )
- r = super(@offset[idx], SIZE_MAP[ty[0]] * ty[1])
- else
- r = super(@offset[idx], SIZE_MAP[ty.abs])
- end
- packer = Packer.new([ty])
- val = packer.unpack([r])
- case ty
- when Array
- case ty[0]
- when TYPE_VOIDP
- val = val.collect{|v| CPtr.new(v)}
- end
- when TYPE_VOIDP
- val = CPtr.new(val[0])
- else
- val = val[0]
- end
- if( ty.is_a?(Integer) && (ty < 0) )
- return unsigned_value(val, ty)
- elsif( ty.is_a?(Array) && (ty[0] < 0) )
- return val.collect{|v| unsigned_value(v,ty[0])}
- else
- return val
- end
- end
+ alias struct define_struct
- def []=(name, val)
- idx = @members.index(name)
- if( idx.nil? )
- raise(ArgumentError, "no such member: #{name}")
+ def define_union(contents)
+ init_types()
+ Union.new(@types, contents)
end
- ty = @ctypes[idx]
- packer = Packer.new([ty])
- val = wrap_arg(val, ty, [])
- buff = packer.pack([val].flatten())
- super(@offset[idx], buff.size, buff)
- if( ty.is_a?(Integer) && (ty < 0) )
- return unsigned_value(val, ty)
- elsif( ty.is_a?(Array) && (ty[0] < 0) )
- return val.collect{|v| unsigned_value(v,ty[0])}
- else
- return val
+ alias union define_union
+
+ class Memory
+ def initialize(ptr, names, ty, len, enc, dec)
+ @ptr = ptr
+ @names = names
+ @ty = ty
+ @len = len
+ @enc = enc
+ @dec = dec
+
+ # define methods
+ @names.each{|name|
+ instance_eval [
+ "def #{name}",
+ " v = @ptr[\"#{name}\"]",
+ " if( @len[\"#{name}\"] )",
+ " v = v.collect{|x| @dec[\"#{name}\"] ? @dec[\"#{name}\"].call(x) : x }",
+ " else",
+ " v = @dec[\"#{name}\"].call(v) if @dec[\"#{name}\"]",
+ " end",
+ " return v",
+ "end",
+ "def #{name}=(v)",
+ " if( @len[\"#{name}\"] )",
+ " v = v.collect{|x| @enc[\"#{name}\"] ? @enc[\"#{name}\"].call(x) : x }",
+ " else",
+ " v = @enc[\"#{name}\"].call(v) if @enc[\"#{name}\"]",
+ " end",
+ " @ptr[\"#{name}\"] = v",
+ " return v",
+ "end",
+ ].join("\n")
+ }
+ end
+
+ def to_ptr
+ return @ptr
+ end
+
+ def size
+ return @ptr.size
+ end
end
- end
-
- def to_s()
- super(@size)
- end
- end
-
- class CUnionEntity < CStructEntity
- include PackInfo
-
- def CUnionEntity.malloc(types, func=nil)
- addr = DL.malloc(CUnionEntity.size(types))
- CUnionEntity.new(addr, types, func)
- end
-
- def CUnionEntity.size(types)
- size = 0
- types.each_with_index{|t,i|
- if( t.is_a?(Array) )
- tsize = PackInfo::SIZE_MAP[t[0]] * t[1]
- else
- tsize = PackInfo::SIZE_MAP[t]
- end
- if( tsize > size )
- size = tsize
- end
- }
- end
-
- def set_ctypes(types)
- @ctypes = types
- @offset = []
- @size = 0
- types.each_with_index{|t,i|
- @offset[i] = 0
- if( t.is_a?(Array) )
- size = SIZE_MAP[t[0]] * t[1]
- else
- size = SIZE_MAP[t]
- end
- if( size > @size )
- @size = size
- end
- }
- end
- end
-end
+ class Struct
+ def initialize(types, contents)
+ @names = []
+ @ty = {}
+ @len = {}
+ @enc = {}
+ @dec = {}
+ @size = 0
+ @tys = ""
+ @types = types
+ parse(contents)
+ end
+
+ def size
+ return @size
+ end
+
+ def members
+ return @names
+ end
+
+ # ptr must be a PtrData object.
+ def new(ptr)
+ ptr.struct!(@tys, *@names)
+ mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
+ return mem
+ end
+
+ def malloc(size = nil)
+ if( !size )
+ size = @size
+ end
+ ptr = DL::malloc(size)
+ return new(ptr)
+ end
+
+ def parse(contents)
+ contents.each{|elem|
+ name,ty,num,enc,dec = parse_elem(elem)
+ @names.push(name)
+ @ty[name] = ty
+ @len[name] = num
+ @enc[name] = enc
+ @dec[name] = dec
+ if( num )
+ @tys += "#{ty}#{num}"
+ else
+ @tys += ty
+ end
+ }
+ @size = DL.sizeof(@tys)
+ end
+
+ def parse_elem(elem)
+ elem.strip!
+ case elem
+ when /^([\w\d_\*]+)([\*\s]+)([\w\d_]+)$/
+ ty = ($1 + $2).strip
+ name = $3
+ num = nil;
+ when /^([\w\d_\*]+)([\*\s]+)([\w\d_]+)\[(\d+)\]$/
+ ty = ($1 + $2).strip
+ name = $3
+ num = $4.to_i
+ else
+ raise(RuntimeError, "invalid element: #{elem}")
+ end
+ ty,enc,dec = @types.encode_struct_type(ty)
+ if( !ty )
+ raise(TypeError, "unsupported type: #{ty}")
+ end
+ return [name,ty,num,enc,dec]
+ end
+ end # class Struct
+
+ class Union < Struct
+ def new
+ ptr = DL::malloc(@size)
+ ptr.union!(@tys, *@names)
+ mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
+ return mem
+ end
+ end
+ end # module Internal
+ end # module Importable
+end # module DL
diff --git a/ext/dl/lib/dl/types.rb b/ext/dl/lib/dl/types.rb
index b85ac890cd..1144917dae 100644
--- a/ext/dl/lib/dl/types.rb
+++ b/ext/dl/lib/dl/types.rb
@@ -1,40 +1,245 @@
+# -*- ruby -*-
+
+require 'dl'
+
module DL
- module Win32Types
- def included(m)
- m.module_eval{
- typealias "DWORD", "unsigned long"
- typealias "PDWORD", "unsigned long *"
- typealias "WORD", "unsigned short"
- typealias "PWORD", "unsigned short *"
- typealias "BOOL", "int"
- typealias "ATOM", "int"
- typealias "BYTE", "unsigned char"
- typealias "PBYTE", "unsigned char *"
- typealias "UINT", "unsigned int"
- typealias "ULONG", "unsigned long"
- typealias "UCHAR", "unsigned char"
- typealias "HANDLE", "unsigned long"
- typealias "PHANDLE", "void*"
- typealias "PVOID", "void*"
- typealias "LPCSTR", "char*"
- typealias "LPSTR", "char*"
- typealias "HINSTANCE", "unsigned int"
- typealias "HDC", "unsigned int"
- typealias "HWND", "unsigned int"
+ class Types
+ TYPES = [
+ # FORMAT:
+ # ["alias name",
+ # "type name", encoding_method, decoding_method, for function prototypes
+ # "type name", encoding_method, decoding_method] for structures (not implemented)
+
+ # for Windows
+ ["DWORD", "unsigned long", nil, nil,
+ "unsigned long", nil, nil],
+ ["PDWORD", "unsigned long *", nil, nil,
+ "unsigned long *", nil, nil],
+ ["WORD", "unsigned short", nil, nil,
+ "unsigned short", nil, nil],
+ ["PWORD", "unsigned int *", nil, nil,
+ "unsigned int *", nil, nil],
+ ["BYTE", "unsigned char", nil, nil,
+ "unsigned char", nil, nil],
+ ["PBYTE", "unsigned char *", nil, nil,
+ "unsigned char *", nil, nil],
+ ["BOOL", "ibool", nil, nil,
+ "ibool", nil, nil],
+ ["ATOM", "int", nil, nil,
+ "int", nil, nil],
+ ["BYTE", "unsigned char", nil, nil,
+ "unsigned char", nil, nil],
+ ["PBYTE", "unsigned char *", nil, nil,
+ "unsigned char *", nil, nil],
+ ["UINT", "unsigned int", nil, nil,
+ "unsigned int", nil, nil],
+ ["ULONG", "unsigned long", nil, nil,
+ "unsigned long", nil, nil],
+ ["UCHAR", "unsigned char", nil, nil,
+ "unsigned char", nil, nil],
+ ["HANDLE", "unsigned long", nil, nil,
+ "unsigned long", nil, nil],
+ ["PHANDLE","void*", nil, nil,
+ "void*", nil, nil],
+ ["PVOID", "void*", nil, nil,
+ "void*", nil, nil],
+ ["LPCSTR", "char*", nil, nil,
+ "char*", nil, nil],
+ ["HDC", "unsigned int", nil, nil,
+ "unsigned int", nil, nil],
+ ["HWND", "unsigned int", nil, nil,
+ "unsigned int", nil, nil],
+
+ # Others
+ ["uint", "unsigned int", nil, nil,
+ "unsigned int", nil, nil],
+ ["u_int", "unsigned int", nil, nil,
+ "unsigned int", nil, nil],
+ ["ulong", "unsigned long", nil, nil,
+ "unsigned long", nil, nil],
+ ["u_long", "unsigned long", nil, nil,
+ "unsigned long", nil, nil],
+
+ # DL::Importable primitive types
+ ["ibool",
+ "I",
+ proc{|v| v ? 1 : 0},
+ proc{|v| (v != 0) ? true : false},
+ "I",
+ proc{|v| v ? 1 : 0 },
+ proc{|v| (v != 0) ? true : false} ],
+ ["cbool",
+ "C",
+ proc{|v| v ? 1 : 0},
+ proc{|v| (v != 0) ? true : false},
+ "C",
+ proc{|v,len| v ? 1 : 0},
+ proc{|v,len| (v != 0) ? true : false}],
+ ["lbool",
+ "L",
+ proc{|v| v ? 1 : 0},
+ proc{|v| (v != 0) ? true : false},
+ "L",
+ proc{|v,len| v ? 1 : 0},
+ proc{|v,len| (v != 0) ? true : false}],
+ ["unsigned char",
+ "C",
+ proc{|v| [v].pack("C").unpack("c")[0]},
+ proc{|v| [v].pack("c").unpack("C")[0]},
+ "C",
+ proc{|v| [v].pack("C").unpack("c")[0]},
+ proc{|v| [v].pack("c").unpack("C")[0]}],
+ ["unsigned short",
+ "H",
+ proc{|v| [v].pack("S").unpack("s")[0]},
+ proc{|v| [v].pack("s").unpack("S")[0]},
+ "H",
+ proc{|v| [v].pack("S").unpack("s")[0]},
+ proc{|v| [v].pack("s").unpack("S")[0]}],
+ ["unsigned int",
+ "I",
+ proc{|v| [v].pack("I").unpack("i")[0]},
+ proc{|v| [v].pack("i").unpack("I")[0]},
+ "I",
+ proc{|v| [v].pack("I").unpack("i")[0]},
+ proc{|v| [v].pack("i").unpack("I")[0]}],
+ ["unsigned long",
+ "L",
+ proc{|v| [v].pack("L").unpack("l")[0]},
+ proc{|v| [v].pack("l").unpack("L")[0]},
+ "L",
+ proc{|v| [v].pack("L").unpack("l")[0]},
+ proc{|v| [v].pack("l").unpack("L")[0]}],
+ ["unsigned char ref",
+ "c",
+ proc{|v| [v].pack("C").unpack("c")[0]},
+ proc{|v| [v].pack("c").unpack("C")[0]},
+ nil, nil, nil],
+ ["unsigned int ref",
+ "i",
+ proc{|v| [v].pack("I").unpack("i")[0]},
+ proc{|v| [v].pack("i").unpack("I")[0]},
+ nil, nil, nil],
+ ["unsigned long ref",
+ "l",
+ proc{|v| [v].pack("L").unpack("l")[0]},
+ proc{|v| [v].pack("l").unpack("L")[0]},
+ nil, nil, nil],
+ ["char ref", "c", nil, nil,
+ nil, nil, nil],
+ ["short ref", "h", nil, nil,
+ nil, nil, nil],
+ ["int ref", "i", nil, nil,
+ nil, nil, nil],
+ ["long ref", "l", nil, nil,
+ nil, nil, nil],
+ ["float ref", "f", nil, nil,
+ nil, nil, nil],
+ ["double ref","d", nil, nil,
+ nil, nil, nil],
+ ["char", "C", nil, nil,
+ "C", nil, nil],
+ ["short", "H", nil, nil,
+ "H", nil, nil],
+ ["int", "I", nil, nil,
+ "I", nil, nil],
+ ["long", "L", nil, nil,
+ "L", nil, nil],
+ ["float", "F", nil, nil,
+ "F", nil, nil],
+ ["double", "D", nil, nil,
+ "D", nil, nil],
+ [/^char\s*\*$/,"s",nil, nil,
+ "S",nil, nil],
+ [/^const char\s*\*$/,"S",nil, nil,
+ "S",nil, nil],
+ [/^.+\*$/, "P", nil, nil,
+ "P", nil, nil],
+ [/^.+\[\]$/, "a", nil, nil,
+ "a", nil, nil],
+ ["void", "0", nil, nil,
+ nil, nil, nil],
+ ]
+
+ def initialize
+ init_types()
+ end
+
+ def typealias(ty1, ty2, enc=nil, dec=nil, ty3=nil, senc=nil, sdec=nil)
+ @TYDEFS.unshift([ty1, ty2, enc, dec, ty3, senc, sdec])
+ end
+
+ def init_types
+ @TYDEFS = TYPES.dup
+ end
+
+ def encode_argument_type(alias_type)
+ proc_encode = nil
+ proc_decode = nil
+ @TYDEFS.each{|aty,ty,enc,dec,_,_,_|
+ if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
+ alias_type = alias_type.gsub(aty,ty) if ty
+ alias_type.strip! if alias_type
+ if( proc_encode )
+ if( enc )
+ conv1 = proc_encode
+ proc_encode = proc{|v| enc.call(conv1.call(v))}
+ end
+ else
+ if( enc )
+ proc_encode = enc
+ end
+ end
+ if( proc_decode )
+ if( dec )
+ conv2 = proc_decode
+ proc_decode = proc{|v| dec.call(conv2.call(v))}
+ end
+ else
+ if( dec )
+ proc_decode = dec
+ end
+ end
+ end
}
+ return [alias_type, proc_encode, proc_decode]
end
- module_function :included
- end
-
- module BasicTypes
- def included(m)
- m.module_eval{
- typealias "uint", "unsigned int"
- typealias "u_int", "unsigned int"
- typealias "ulong", "unsigned long"
- typealias "u_long", "unsigned long"
+
+ def encode_return_type(ty)
+ ty, enc, dec = encode_argument_type(ty)
+ return [ty, enc, dec]
+ end
+
+ def encode_struct_type(alias_type)
+ proc_encode = nil
+ proc_decode = nil
+ @TYDEFS.each{|aty,_,_,_,ty,enc,dec|
+ if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
+ alias_type = alias_type.gsub(aty,ty) if ty
+ alias_type.strip! if alias_type
+ if( proc_encode )
+ if( enc )
+ conv1 = proc_encode
+ proc_encode = proc{|v| enc.call(conv1.call(v))}
+ end
+ else
+ if( enc )
+ proc_encode = enc
+ end
+ end
+ if( proc_decode )
+ if( dec )
+ conv2 = proc_decode
+ proc_decode = proc{|v| dec.call(conv2.call(v))}
+ end
+ else
+ if( dec )
+ proc_decode = dec
+ end
+ end
+ end
}
+ return [alias_type, proc_encode, proc_decode]
end
- module_function :included
- end
+ end # end of Types
end
diff --git a/ext/dl/lib/dl/value.rb b/ext/dl/lib/dl/value.rb
deleted file mode 100644
index aa7e0dd325..0000000000
--- a/ext/dl/lib/dl/value.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-require 'dl'
-
-module DL
- module ValueUtil
- def unsigned_value(val, ty)
- case ty.abs
- when TYPE_CHAR
- [val].pack("c").unpack("C")[0]
- when TYPE_SHORT
- [val].pack("s!").unpack("S!")[0]
- when TYPE_INT
- [val].pack("i!").unpack("I!")[0]
- when TYPE_LONG
- [val].pack("l!").unpack("L!")[0]
- when TYPE_LONG_LONG
- [val].pack("q!").unpack("Q!")[0]
- else
- val
- end
- end
-
- def signed_value(val, ty)
- case ty.abs
- when TYPE_CHAR
- [val].pack("C").unpack("c")[0]
- when TYPE_SHORT
- [val].pack("S!").unpack("s!")[0]
- when TYPE_INT
- [val].pack("I!").unpack("i!")[0]
- when TYPE_LONG
- [val].pack("L!").unpack("l!")[0]
- when TYPE_LONG_LONG
- [val].pack("Q!").unpack("q!")[0]
- else
- val
- end
- end
-
- def wrap_args(args, tys, funcs, &block)
- result = []
- tys ||= []
- args.each_with_index{|arg, idx|
- result.push(wrap_arg(arg, tys[idx], funcs, &block))
- }
- result
- end
-
- def wrap_arg(arg, ty, funcs, &block)
- funcs ||= []
- case arg
- when CPtr
- return arg.to_i
- when IO
- case ty
- when TYPE_VOIDP
- return CPtr[arg].to_i
- else
- return arg.to_i
- end
- when Function
- if( block )
- arg.bind_at_call(&block)
- funcs.push(arg)
- end
- return arg.to_i
- when String
- if( ty.is_a?(Array) )
- return arg.unpack('C*')
- else
- case SIZEOF_VOIDP
- when SIZEOF_LONG
- return [arg].pack("p").unpack("l!")[0]
- when SIZEOF_LONG_LONG
- return [arg].pack("p").unpack("q")[0]
- else
- raise(RuntimeError, "sizeof(void*)?")
- end
- end
- when Float, Integer
- return arg
- when Array
- if( ty.is_a?(Array) ) # used only by struct
- case ty[0]
- when TYPE_VOIDP
- return arg.collect{|v| Integer(v)}
- when TYPE_CHAR
- if( arg.is_a?(String) )
- return val.unpack('C*')
- end
- end
- return arg
- else
- return arg
- end
- else
- if( arg.respond_to?(:to_ptr) )
- return arg.to_ptr.to_i
- else
- begin
- return Integer(arg)
- rescue
- raise(ArgumentError, "unknown argument type: #{arg.class}")
- end
- end
- end
- end
- end
-end
diff --git a/ext/dl/lib/dl/win32.rb b/ext/dl/lib/dl/win32.rb
new file mode 100644
index 0000000000..0fed47c324
--- /dev/null
+++ b/ext/dl/lib/dl/win32.rb
@@ -0,0 +1,25 @@
+# -*- ruby -*-
+
+require 'dl'
+
+class Win32API
+ DLL = {}
+
+ def initialize(dllname, func, import, export = "0")
+ prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
+ handle = DLL[dllname] ||= DL::Handle.new(dllname)
+ @sym = handle.sym(func, prototype)
+ end
+
+ def call(*args)
+ import = @sym.proto.split("", 2)[1]
+ args.each_with_index do |x, i|
+ args[i] = nil if x == 0 and import[i] == ?S
+ args[i], = [x].pack("I").unpack("i") if import[i] == ?I
+ end
+ ret, = @sym.call(*args)
+ return ret || 0
+ end
+
+ alias Call call
+end
diff --git a/ext/dl/mkcall.rb b/ext/dl/mkcall.rb
new file mode 100644
index 0000000000..6a85570152
--- /dev/null
+++ b/ext/dl/mkcall.rb
@@ -0,0 +1,62 @@
+# -*- ruby -*-
+
+require 'mkmf'
+$:.unshift File.dirname(__FILE__)
+require 'type'
+require 'dlconfig'
+
+def output_arg(x,i)
+ "args[#{i}].#{DLTYPE[x][:stmem]}"
+end
+
+def output_args(types)
+ t = []
+ types[1..-1].each_with_index{|x,i| t.push(output_arg(x,i))}
+ t.join(",")
+end
+
+def output_callfunc(types)
+ t = types[0]
+ stmem = DLTYPE[t][:stmem]
+ ctypes = types2ctypes(types)
+ if( t == VOID )
+ callstm = "(*f)(#{output_args(types)})"
+ else
+ callstm = "ret.#{stmem} = (*f)(#{output_args(types)})"
+ end
+ [ "{",
+ "#{ctypes[0]} (*f)(#{ctypes[1..-1].join(',')}) = func;",
+ "#{callstm};",
+ "}"].join(" ")
+end
+
+def output_case(types)
+ num = types2num(types)
+ callfunc_stm = output_callfunc(types)
+<<EOF
+ case #{num}:
+#ifdef DEBUG
+ printf("#{callfunc_stm}\\n");
+#endif
+ #{callfunc_stm};
+ break;
+EOF
+end
+
+def rec_output(types = [VOID])
+ print output_case(types)
+ if( types.length <= MAX_ARG )
+ DLTYPE.keys.sort.each{|t|
+ if( t != VOID && DLTYPE[t][:sym] )
+ rec_output(types + [t])
+ end
+ }
+ end
+end
+
+DLTYPE.keys.sort.each{|t|
+ if( DLTYPE[t][:sym] )
+ $stderr.printf(" #{DLTYPE[t][:ctype]}\n")
+ rec_output([t])
+ end
+}
diff --git a/ext/dl/mkcallback.rb b/ext/dl/mkcallback.rb
index 21fb177f8b..c9f92e4a0d 100644
--- a/ext/dl/mkcallback.rb
+++ b/ext/dl/mkcallback.rb
@@ -1,189 +1,56 @@
-$out ||= $stdout
-$dl_h = ARGV[0] || "dl.h"
+# -*- ruby -*-
-# import DLSTACK_SIZE, DLSTACK_ARGS and so on
-File.open($dl_h){|f|
- pre = ""
- f.each{|line|
- line.chop!
- if( line[-1] == ?\ )
- line.chop!
- line.concat(" ")
- pre += line
- next
- end
- if( pre.size > 0 )
- line = pre + line
- pre = ""
- end
- case line
- when /#define\s+DLSTACK_SIZE\s+\(?(\d+)\)?/
- DLSTACK_SIZE = $1.to_i
- when /#define\s+DLSTACK_ARGS\s+(.+)/
- DLSTACK_ARGS = $1.to_i
- when /#define\s+DLTYPE_([A-Z_]+)\s+\(?(\d+)\)?/
- eval("#{$1} = #{$2}")
- when /#define\s+MAX_DLTYPE\s+\(?(\d+)\)?/
- MAX_DLTYPE = $1.to_i
- when /#define\s+MAX_CALLBACK\s+\(?(\d+)\)?/
- MAX_CALLBACK = $1.to_i
- end
- }
-}
-
-CDECL = "cdecl"
-STDCALL = "stdcall"
+require 'mkmf'
+$:.unshift File.dirname(__FILE__)
+require 'type'
+require 'dlconfig'
-CALLTYPES = [CDECL, STDCALL]
+def mkfunc(rettype, fnum, argc)
+ args = (0..(argc-1)).collect{|i| "long arg#{i}"}.join(", ")
-DLTYPE = {
- VOID => {
- :name => 'void',
- :type => 'void',
- :conv => nil,
- },
- CHAR => {
- :name => 'char',
- :type => 'char',
- :conv => 'NUM2CHR(%s)'
- },
- SHORT => {
- :name => 'short',
- :type => 'short',
- :conv => 'NUM2INT(%s)',
- },
- INT => {
- :name => 'int',
- :type => 'int',
- :conv => 'NUM2INT(%s)',
- },
- LONG => {
- :name => 'long',
- :type => 'long',
- :conv => 'NUM2LONG(%s)',
- },
- LONG_LONG => {
- :name => 'long_long',
- :type => 'LONG_LONG',
- :conv => 'NUM2LL(%s)',
- },
- FLOAT => {
- :name => 'float',
- :type => 'float',
- :conv => 'RFLOAT_VALUE(%s)',
- },
- DOUBLE => {
- :name => 'double',
- :type => 'double',
- :conv => 'RFLOAT_VALUE(%s)',
- },
- VOIDP => {
- :name => 'ptr',
- :type => 'void *',
- :conv => 'NUM2PTR(%s)',
- },
-}
+ subst_code = (0..(argc-1)).collect{|i|
+ " buff[#{i.to_s}] = arg#{i.to_s};"
+ }.join("\n")
+ ret_code =
+ if( DLTYPE[rettype][:c2rb] )
+ " return #{DLTYPE[rettype][:rb2c]['retval']};"
+ else
+ " /* no return value */"
+ end
-def func_name(ty, argc, n, calltype)
- "rb_dl_callback_#{DLTYPE[ty][:name]}_#{argc}_#{n}_#{calltype}"
+ code = [
+ "static #{DLTYPE[rettype][:ctype]}",
+ "rb_dl_callback_func_#{rettype.to_s}_#{fnum.to_s}(#{args})",
+ "{",
+ " VALUE retval, proto, proc, obj;",
+ " VALUE argv[#{argc.to_s}];",
+ " int argc;",
+ " long buff[#{argc.to_s}];",
+ "",
+ subst_code,
+ "",
+ " obj = rb_hash_aref(DLFuncTable, rb_assoc_new(INT2NUM(#{rettype.to_s}),INT2NUM(#{fnum.to_s})));",
+ " if(NIL_P(obj))",
+ " rb_raise(rb_eDLError, \"callback function does not exist in DL::FuncTable\");",
+ " Check_Type(obj, T_ARRAY);",
+ " proto = rb_ary_entry(obj, 0);",
+ " proc = rb_ary_entry(obj, 1);",
+ " Check_Type(proto, T_STRING);",
+ " if( RSTRING(proto)->len >= #{argc.to_s} )",
+ " rb_raise(rb_eArgError, \"too many arguments\");",
+ " rb_dl_scan_callback_args(buff, RSTRING(proto)->ptr, &argc, argv);",
+ " retval = rb_funcall2(proc, id_call, argc, argv);",
+ "",
+ ret_code,
+ "}",
+ ].join("\n")
+
+ return code
end
-$out << (<<EOS)
-VALUE rb_DLCdeclCallbackAddrs, rb_DLCdeclCallbackProcs;
-VALUE rb_DLStdcallCallbackAddrs, rb_DLStdcallCallbackProcs;
-/*static void *cdecl_callbacks[MAX_DLTYPE][MAX_CALLBACK];*/
-/*static void *stdcall_callbacks[MAX_DLTYPE][MAX_CALLBACK];*/
-static ID cb_call;
-EOS
-
-for calltype in CALLTYPES
- case calltype
- when CDECL
- proc_entry = "rb_DLCdeclCallbackProcs"
- when STDCALL
- proc_entry = "rb_DLStdcallCallbackProcs"
- else
- raise "unknown calltype: #{calltype}"
+DLTYPE.keys.sort.each{|t|
+ for n in 0..(MAX_CALLBACK - 1)
+ print(mkfunc(t, n, 15), "\n\n")
end
- for ty in 0..(MAX_DLTYPE-1)
- for argc in 0..(DLSTACK_SIZE-1)
- for n in 0..(MAX_CALLBACK-1)
- $out << (<<-EOS)
-
-static #{DLTYPE[ty][:type]}
-FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")})
-{
- VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""};
-#{
- (0...argc).collect{|i|
- " args[%d] = LONG2NUM(stack%d);" % [i,i]
- }.join("\n")
-}
- cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});
- ret = rb_funcall2(cb, cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
- return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
-}
-
- EOS
- end
- end
- end
-end
-
-$out << (<<EOS)
-static void
-rb_dl_init_callbacks()
-{
- cb_call = rb_intern("call");
-
- rb_DLCdeclCallbackProcs = rb_ary_new();
- rb_DLCdeclCallbackAddrs = rb_ary_new();
- rb_DLStdcallCallbackProcs = rb_ary_new();
- rb_DLStdcallCallbackAddrs = rb_ary_new();
- rb_define_const(rb_mDL, "CdeclCallbackProcs", rb_DLCdeclCallbackProcs);
- rb_define_const(rb_mDL, "CdeclCallbackAddrs", rb_DLCdeclCallbackAddrs);
- rb_define_const(rb_mDL, "StdcallCallbackProcs", rb_DLStdcallCallbackProcs);
- rb_define_const(rb_mDL, "StdcallCallbackAddrs", rb_DLStdcallCallbackAddrs);
-#{
- (0...MAX_DLTYPE).collect{|ty|
- sprintf(" rb_ary_push(rb_DLCdeclCallbackProcs, rb_ary_new3(%d,%s));",
- MAX_CALLBACK * DLSTACK_SIZE,
- (0...MAX_CALLBACK).collect{
- (0...DLSTACK_SIZE).collect{ "Qnil" }.join(",")
- }.join(","))
- }.join("\n")
-}
-#{
- (0...MAX_DLTYPE).collect{|ty|
- sprintf(" rb_ary_push(rb_DLCdeclCallbackAddrs, rb_ary_new3(%d,%s));",
- MAX_CALLBACK * DLSTACK_SIZE,
- (0...MAX_CALLBACK).collect{|i|
- (0...DLSTACK_SIZE).collect{|argc|
- "PTR2NUM(%s)" % func_name(ty,argc,i,CDECL)
- }.join(",")
- }.join(","))
- }.join("\n")
-}
-#{
- (0...MAX_DLTYPE).collect{|ty|
- sprintf(" rb_ary_push(rb_DLStdcallCallbackProcs, rb_ary_new3(%d,%s));",
- MAX_CALLBACK * DLSTACK_SIZE,
- (0...MAX_CALLBACK).collect{
- (0...DLSTACK_SIZE).collect{ "Qnil" }.join(",")
- }.join(","))
- }.join("\n")
-}
-#{
- (0...MAX_DLTYPE).collect{|ty|
- sprintf(" rb_ary_push(rb_DLStdcallCallbackAddrs, rb_ary_new3(%d,%s));",
- MAX_CALLBACK * DLSTACK_SIZE,
- (0...MAX_CALLBACK).collect{|i|
- (0...DLSTACK_SIZE).collect{|argc|
- "PTR2NUM(%s)" % func_name(ty,argc,i,STDCALL)
- }.join(",")
- }.join(","))
- }.join("\n")
-}
}
-EOS
diff --git a/ext/dl/mkcbtable.rb b/ext/dl/mkcbtable.rb
new file mode 100644
index 0000000000..165c4bdc88
--- /dev/null
+++ b/ext/dl/mkcbtable.rb
@@ -0,0 +1,18 @@
+# -*- ruby -*-
+
+require 'mkmf'
+$:.unshift File.dirname(__FILE__)
+require 'type'
+require 'dlconfig'
+
+def mktable(rettype, fnum, argc)
+ code =
+ "rb_dl_callback_table[#{rettype}][#{fnum}] = &rb_dl_callback_func_#{rettype.to_s}_#{fnum};"
+ return code
+end
+
+DLTYPE.keys.sort.each{|t|
+ for n in 0..(MAX_CALLBACK - 1)
+ print(mktable(t, n, 15), "\n")
+ end
+}
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
new file mode 100644
index 0000000000..01eb31da20
--- /dev/null
+++ b/ext/dl/ptr.c
@@ -0,0 +1,1058 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <ctype.h>
+#include "st.h"
+#include "dl.h"
+
+VALUE rb_cDLPtrData;
+VALUE rb_mDLMemorySpace;
+static st_table* st_memory_table;
+
+#ifndef T_SYMBOL
+# define T_SYMBOL T_FIXNUM
+#endif
+
+static void
+rb_dlmem_delete(void *ptr)
+{
+ rb_secure(4);
+ st_delete(st_memory_table, (st_data_t*)&ptr, NULL);
+}
+
+static void
+rb_dlmem_aset(void *ptr, VALUE obj)
+{
+ if (obj == Qnil) {
+ rb_dlmem_delete(ptr);
+ }
+ else{
+ st_insert(st_memory_table, (st_data_t)ptr, (st_data_t)obj);
+ }
+}
+
+static VALUE
+rb_dlmem_aref(void *ptr)
+{
+ VALUE val;
+
+ if(!st_lookup(st_memory_table, (st_data_t)ptr, &val)) return Qnil;
+ return val == Qundef ? Qnil : val;
+}
+
+void
+dlptr_free(struct ptr_data *data)
+{
+ if (data->ptr) {
+ DEBUG_CODE({
+ printf("dlptr_free(): removing the pointer `0x%x' from the MemorySpace\n",
+ data->ptr);
+ });
+ rb_dlmem_delete(data->ptr);
+ if (data->free) {
+ DEBUG_CODE({
+ printf("dlptr_free(): 0x%x(data->ptr:0x%x)\n",data->free,data->ptr);
+ });
+ (*(data->free))(data->ptr);
+ }
+ }
+ if (data->stype) dlfree(data->stype);
+ if (data->ssize) dlfree(data->ssize);
+ if (data->ids) dlfree(data->ids);
+}
+
+void
+dlptr_init(VALUE val)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(val, struct ptr_data, data);
+ DEBUG_CODE({
+ printf("dlptr_init(): add the pointer `0x%x' to the MemorySpace\n",
+ data->ptr);
+ });
+ rb_dlmem_aset(data->ptr, val);
+ OBJ_TAINT(val);
+}
+
+VALUE
+rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
+{
+ struct ptr_data *data;
+ VALUE val;
+
+ rb_secure(4);
+ if (ptr) {
+ val = rb_dlmem_aref(ptr);
+ if (val == Qnil) {
+ val = Data_Make_Struct(klass, struct ptr_data,
+ 0, dlptr_free, data);
+ data->ptr = ptr;
+ data->free = func;
+ data->ctype = DLPTR_CTYPE_UNKNOWN;
+ data->stype = NULL;
+ data->ssize = NULL;
+ data->slen = 0;
+ data->size = size;
+ data->ids = NULL;
+ data->ids_num = 0;
+ dlptr_init(val);
+ }
+ else{
+ if (func) {
+ Data_Get_Struct(val, struct ptr_data, data);
+ data->free = func;
+ }
+ }
+ }
+ else{
+ val = Qnil;
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlptr_new(void *ptr, long size, freefunc_t func)
+{
+ return rb_dlptr_new2(rb_cDLPtrData, ptr, size, func);
+}
+
+VALUE
+rb_dlptr_malloc(long size, freefunc_t func)
+{
+ void *ptr;
+
+ rb_secure(4);
+ ptr = dlmalloc((size_t)size);
+ memset(ptr,0,(size_t)size);
+ return rb_dlptr_new(ptr, size, func);
+}
+
+void *
+rb_dlptr2cptr(VALUE val)
+{
+ struct ptr_data *data;
+ void *ptr;
+
+ if (rb_obj_is_kind_of(val, rb_cDLPtrData)) {
+ Data_Get_Struct(val, struct ptr_data, data);
+ ptr = data->ptr;
+ }
+ else if (val == Qnil) {
+ ptr = NULL;
+ }
+ else{
+ rb_raise(rb_eTypeError, "DL::PtrData was expected");
+ }
+
+ return ptr;
+}
+
+static VALUE
+rb_dlptr_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct ptr_data *data;
+
+ rb_secure(4);
+ obj = Data_Make_Struct(klass, struct ptr_data, 0, dlptr_free, data);
+ data->ptr = 0;
+ data->free = 0;
+ data->ctype = DLPTR_CTYPE_UNKNOWN;
+ data->stype = NULL;
+ data->ssize = NULL;
+ data->slen = 0;
+ data->size = 0;
+ data->ids = NULL;
+ data->ids_num = 0;
+
+ return obj;
+}
+
+static VALUE
+rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
+{
+ VALUE ptr, sym, size;
+ struct ptr_data *data;
+ void *p = NULL;
+ freefunc_t f = NULL;
+ long s = 0;
+
+ switch (rb_scan_args(argc, argv, "12", &ptr, &size, &sym)) {
+ case 1:
+ p = (void*)(DLNUM2LONG(rb_Integer(ptr)));
+ break;
+ case 2:
+ p = (void*)(DLNUM2LONG(rb_Integer(ptr)));
+ s = DLNUM2LONG(size);
+ break;
+ case 3:
+ p = (void*)(DLNUM2LONG(rb_Integer(ptr)));
+ s = DLNUM2LONG(size);
+ f = rb_dlsym2csym(sym);
+ break;
+ default:
+ rb_bug("rb_dlptr_initialize");
+ }
+
+ if (p) {
+ Data_Get_Struct(self, struct ptr_data, data);
+ if (data->ptr && data->free) {
+ /* Free previous memory. Use of inappropriate initialize may cause SEGV. */
+ (*(data->free))(data->ptr);
+ }
+ data->ptr = p;
+ data->size = s;
+ data->free = f;
+ }
+
+ return Qnil;
+}
+
+static VALUE
+rb_dlptr_s_malloc(int argc, VALUE argv[], VALUE klass)
+{
+ VALUE size, sym, obj;
+ int s;
+ freefunc_t f = NULL;
+
+ switch (rb_scan_args(argc, argv, "11", &size, &sym)) {
+ case 1:
+ s = NUM2INT(size);
+ break;
+ case 2:
+ s = NUM2INT(size);
+ f = rb_dlsym2csym(sym);
+ break;
+ default:
+ rb_bug("rb_dlptr_s_malloc");
+ }
+
+ obj = rb_dlptr_malloc(s,f);
+
+ return obj;
+}
+
+VALUE
+rb_dlptr_to_i(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return DLLONG2NUM(data->ptr);
+}
+
+VALUE
+rb_dlptr_ptr(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return rb_dlptr_new(*((void**)(data->ptr)),0,0);
+}
+
+VALUE
+rb_dlptr_ref(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return rb_dlptr_new(&(data->ptr),0,0);
+}
+
+VALUE
+rb_dlptr_null_p(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return data->ptr ? Qfalse : Qtrue;
+}
+
+VALUE
+rb_dlptr_free_set(VALUE self, VALUE val)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+
+ data->free = DLFREEFUNC(rb_dlsym2csym(val));
+
+ return Qnil;
+}
+
+VALUE
+rb_dlptr_free_get(VALUE self)
+{
+ struct ptr_data *pdata;
+
+ Data_Get_Struct(self, struct ptr_data, pdata);
+
+ return rb_dlsym_new(pdata->free,"(free)","0P");
+}
+
+VALUE
+rb_dlptr_to_array(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ int n;
+ int i;
+ int t;
+ VALUE ary;
+ VALUE type, size;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+
+ switch (rb_scan_args(argc, argv, "11", &type, &size)) {
+ case 2:
+ t = StringValuePtr(type)[0];
+ n = NUM2INT(size);
+ break;
+ case 1:
+ t = StringValuePtr(type)[0];
+ switch (t) {
+ case 'C':
+ n = data->size;
+ break;
+ case 'H':
+ n = data->size / sizeof(short);
+ break;
+ case 'I':
+ n = data->size / sizeof(int);
+ break;
+ case 'L':
+ n = data->size / sizeof(long);
+ break;
+ case 'F':
+ n = data->size / sizeof(float);
+ break;
+ case 'D':
+ n = data->size / sizeof(double);
+ break;
+ case 'P': case 'p':
+ n = data->size / sizeof(void*);
+ break;
+ case 'S': case 's':
+ n = data->size / sizeof(char*);
+ break;
+ default:
+ n = 0;
+ }
+ break;
+ default:
+ rb_bug("rb_dlptr_to_array");
+ }
+
+ ary = rb_ary_new();
+
+ for (i=0; i < n; i++) {
+ switch (t) {
+ case 'C':
+ rb_ary_push(ary, INT2NUM(((char*)(data->ptr))[i]));
+ break;
+ case 'H':
+ rb_ary_push(ary, INT2NUM(((short*)(data->ptr))[i]));
+ break;
+ case 'I':
+ rb_ary_push(ary, INT2NUM(((int*)(data->ptr))[i]));
+ break;
+ case 'L':
+ rb_ary_push(ary, DLLONG2NUM(((long*)(data->ptr))[i]));
+ break;
+ case 'D':
+ rb_ary_push(ary, rb_float_new(((double*)(data->ptr))[i]));
+ break;
+ case 'F':
+ rb_ary_push(ary, rb_float_new(((float*)(data->ptr))[i]));
+ break;
+ case 'S':
+ {
+ char *str = ((char**)(data->ptr))[i];
+ if (str) {
+ rb_ary_push(ary, rb_tainted_str_new2(str));
+ }
+ else{
+ rb_ary_push(ary, Qnil);
+ }
+ }
+ break;
+ case 's':
+ {
+ char *str = ((char**)(data->ptr))[i];
+ if (str) {
+ rb_ary_push(ary, rb_tainted_str_new2(str));
+ xfree(str);
+ }
+ else{
+ rb_ary_push(ary, Qnil);
+ }
+ }
+ break;
+ case 'P':
+ rb_ary_push(ary, rb_dlptr_new(((void**)(data->ptr))[i],0,0));
+ break;
+ case 'p':
+ rb_ary_push(ary,
+ rb_dlptr_new(((void**)(data->ptr))[i],0,dlfree));
+ break;
+ }
+ }
+
+ return ary;
+}
+
+
+VALUE
+rb_dlptr_to_s(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ VALUE arg1, val;
+ int len;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ switch (rb_scan_args(argc, argv, "01", &arg1)) {
+ case 0:
+ val = rb_tainted_str_new2((char*)(data->ptr));
+ break;
+ case 1:
+ len = NUM2INT(arg1);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
+ break;
+ default:
+ rb_bug("rb_dlptr_to_s");
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlptr_to_str(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ VALUE arg1, val;
+ int len;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ switch (rb_scan_args(argc, argv, "01", &arg1)) {
+ case 0:
+ val = rb_tainted_str_new((char*)(data->ptr),data->size);
+ break;
+ case 1:
+ len = NUM2INT(arg1);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
+ break;
+ default:
+ rb_bug("rb_dlptr_to_str");
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlptr_inspect(VALUE self)
+{
+ struct ptr_data *data;
+ char str[1024];
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ snprintf(str, 1023, "#<%s:0x%lx ptr=0x%lx size=%ld free=0x%lx>",
+ rb_class2name(CLASS_OF(self)), data, data->ptr, data->size,
+ (long)data->free);
+ return rb_str_new2(str);
+}
+
+VALUE
+rb_dlptr_eql(VALUE self, VALUE other)
+{
+ void *ptr1, *ptr2;
+ ptr1 = rb_dlptr2cptr(self);
+ ptr2 = rb_dlptr2cptr(other);
+
+ return ptr1 == ptr2 ? Qtrue : Qfalse;
+}
+
+VALUE
+rb_dlptr_cmp(VALUE self, VALUE other)
+{
+ void *ptr1, *ptr2;
+ ptr1 = rb_dlptr2cptr(self);
+ ptr2 = rb_dlptr2cptr(other);
+ return DLLONG2NUM((long)ptr1 - (long)ptr2);
+}
+
+VALUE
+rb_dlptr_plus(VALUE self, VALUE other)
+{
+ void *ptr;
+ long num, size;
+
+ ptr = rb_dlptr2cptr(self);
+ size = RDLPTR(self)->size;
+ num = DLNUM2LONG(other);
+ return rb_dlptr_new((char *)ptr + num, size - num, 0);
+}
+
+VALUE
+rb_dlptr_minus(VALUE self, VALUE other)
+{
+ void *ptr;
+ long num, size;
+
+ ptr = rb_dlptr2cptr(self);
+ size = RDLPTR(self)->size;
+ num = DLNUM2LONG(other);
+ return rb_dlptr_new((char *)ptr - num, size + num, 0);
+}
+
+VALUE
+rb_dlptr_define_data_type(int argc, VALUE argv[], VALUE self)
+{
+ VALUE data_type, type, rest, vid;
+ struct ptr_data *data;
+ int i, t, num;
+ char *ctype;
+
+ rb_scan_args(argc, argv, "11*", &data_type, &type, &rest);
+ Data_Get_Struct(self, struct ptr_data, data);
+
+ if (argc == 1 || (argc == 2 && type == Qnil)) {
+ if (NUM2INT(data_type) == DLPTR_CTYPE_UNKNOWN) {
+ data->ctype = DLPTR_CTYPE_UNKNOWN;
+ data->slen = 0;
+ data->ids_num = 0;
+ if (data->stype) {
+ dlfree(data->stype);
+ data->stype = NULL;
+ }
+ if (data->ids) {
+ dlfree(data->ids);
+ data->ids = NULL;
+ }
+ return Qnil;
+ }
+ else{
+ rb_raise(rb_eArgError, "wrong arguments");
+ }
+ }
+
+ t = NUM2INT(data_type);
+ StringValue(type);
+ Check_Type(rest, T_ARRAY);
+ num = RARRAY(rest)->len;
+ for (i=0; i<num; i++) {
+ rb_to_id(rb_ary_entry(rest,i));
+ }
+
+ data->ctype = t;
+ data->slen = num;
+ data->ids_num = num;
+ if (data->stype) dlfree(data->stype);
+ data->stype = (char*)dlmalloc(sizeof(char) * num);
+ if (data->ssize) dlfree(data->ssize);
+ data->ssize = (int*)dlmalloc(sizeof(int) * num);
+ if (data->ids) dlfree(data->ids);
+ data->ids = (ID*)dlmalloc(sizeof(ID) * data->ids_num);
+
+ ctype = StringValuePtr(type);
+ for (i=0; i<num; i++) {
+ vid = rb_ary_entry(rest,i);
+ data->ids[i] = rb_to_id(vid);
+ data->stype[i] = *ctype;
+ ctype ++;
+ if (isdigit(*ctype)) {
+ char *p, *d;
+ for (p=ctype; isdigit(*p); p++) ;
+ d = ALLOCA_N(char, p - ctype + 1);
+ strncpy(d, ctype, p - ctype);
+ d[p - ctype] = '\0';
+ data->ssize[i] = atoi(d);
+ ctype = p;
+ }
+ else{
+ data->ssize[i] = 1;
+ }
+ }
+
+ if (*ctype) {
+ rb_raise(rb_eArgError, "too few/many arguments");
+ }
+
+ if (!data->size)
+ data->size = dlsizeof(RSTRING(type)->ptr);
+
+ return Qnil;
+}
+
+VALUE
+rb_dlptr_define_struct(int argc, VALUE argv[], VALUE self)
+{
+ VALUE *pass_argv;
+ int pass_argc, i;
+
+ pass_argc = argc + 1;
+ pass_argv = ALLOCA_N(VALUE, pass_argc);
+ pass_argv[0] = INT2FIX(DLPTR_CTYPE_STRUCT);
+ for (i=1; i<pass_argc; i++) {
+ pass_argv[i] = argv[i-1];
+ }
+ return rb_dlptr_define_data_type(pass_argc, pass_argv, self);
+}
+
+VALUE
+rb_dlptr_define_union(int argc, VALUE argv[], VALUE self)
+{
+ VALUE *pass_argv;
+ int pass_argc, i;
+
+ pass_argc = argc + 1;
+ pass_argv = ALLOCA_N(VALUE, pass_argc);
+ pass_argv[0] = INT2FIX(DLPTR_CTYPE_UNION);
+ for (i=1; i<pass_argc; i++) {
+ pass_argv[i] = argv[i-1];
+ }
+ return rb_dlptr_define_data_type(pass_argc, pass_argv, self);
+}
+
+VALUE
+rb_dlptr_get_data_type(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ if (data->stype)
+ return rb_assoc_new(INT2FIX(data->ctype),
+ rb_tainted_str_new(data->stype, data->slen));
+ else
+ return rb_assoc_new(INT2FIX(data->ctype), Qnil);
+}
+
+static VALUE
+cary2ary(void *ptr, char t, int len)
+{
+ VALUE ary;
+ VALUE elem;
+ int i;
+
+ if (len < 1)
+ return Qnil;
+
+ if (len == 1) {
+ switch (t) {
+ case 'I':
+ elem = INT2NUM(*((int*)ptr));
+ ptr = (char *)ptr + sizeof(int);
+ break;
+ case 'L':
+ elem = DLLONG2NUM(*((long*)ptr));
+ ptr = (char *)ptr + sizeof(long);
+ break;
+ case 'P':
+ case 'S':
+ elem = rb_dlptr_new(*((void**)ptr),0, 0);
+ ptr = (char *)ptr + sizeof(void*);
+ break;
+ case 'F':
+ elem = rb_float_new(*((float*)ptr));
+ ptr = (char *)ptr + sizeof(float);
+ break;
+ case 'D':
+ elem = rb_float_new(*((double*)ptr));
+ ptr = (char *)ptr + sizeof(double);
+ break;
+ case 'C':
+ elem = INT2NUM(*((char*)ptr));
+ ptr = (char *)ptr + sizeof(char);
+ break;
+ case 'H':
+ elem = INT2NUM(*((short*)ptr));
+ ptr = (char *)ptr + sizeof(short);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", t);
+ }
+ return elem;
+ }
+
+ ary = rb_ary_new();
+ for (i=0; i < len; i++) {
+ switch (t) {
+ case 'I':
+ elem = INT2NUM(*((int*)ptr));
+ ptr = (char *)ptr + sizeof(int);
+ break;
+ case 'L':
+ elem = DLLONG2NUM(*((long*)ptr));
+ ptr = (char *)ptr + sizeof(long);
+ break;
+ case 'P':
+ case 'S':
+ elem = rb_dlptr_new(*((void**)ptr), 0, 0);
+ ptr = (char *)ptr + sizeof(void*);
+ break;
+ case 'F':
+ elem = rb_float_new(*((float*)ptr));
+ ptr = (char *)ptr + sizeof(float);
+ break;
+ case 'D':
+ elem = rb_float_new(*((float*)ptr));
+ ptr = (char *)ptr + sizeof(double);
+ break;
+ case 'C':
+ elem = INT2NUM(*((char*)ptr));
+ ptr = (char *)ptr + sizeof(char);
+ break;
+ case 'H':
+ elem = INT2NUM(*((short*)ptr));
+ ptr = (char *)ptr + sizeof(short);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", t);
+ }
+ rb_ary_push(ary, elem);
+ }
+
+ return ary;
+}
+
+VALUE
+rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
+{
+ VALUE key = Qnil, num = Qnil;
+ ID id;
+ struct ptr_data *data;
+ int i;
+ int offset;
+
+ if (rb_scan_args(argc, argv, "11", &key, &num) == 1) {
+ num = INT2NUM(0);
+ }
+
+ if (TYPE(key) == T_FIXNUM || TYPE(key) == T_BIGNUM) {
+ VALUE pass[1];
+ pass[0] = num;
+ return rb_dlptr_to_str(1, pass, rb_dlptr_plus(self, key));
+ }
+ rb_to_id(key);
+ if (! (TYPE(key) == T_STRING || TYPE(key) == T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "the key must be a string or symbol");
+ }
+
+ id = rb_to_id(key);
+ Data_Get_Struct(self, struct ptr_data, data);
+ offset = 0;
+ switch (data->ctype) {
+ case DLPTR_CTYPE_STRUCT:
+ for (i=0; i < data->ids_num; i++) {
+ switch (data->stype[i]) {
+ case 'I':
+ DLALIGN(data->ptr,offset,INT_ALIGN);
+ break;
+ case 'L':
+ DLALIGN(data->ptr,offset,LONG_ALIGN);
+ break;
+ case 'P':
+ case 'S':
+ DLALIGN(data->ptr,offset,VOIDP_ALIGN);
+ break;
+ case 'F':
+ DLALIGN(data->ptr,offset,FLOAT_ALIGN);
+ break;
+ case 'D':
+ DLALIGN(data->ptr,offset,DOUBLE_ALIGN);
+ break;
+ case 'C':
+ break;
+ case 'H':
+ DLALIGN(data->ptr,offset,SHORT_ALIGN);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ if (data->ids[i] == id) {
+ return cary2ary((char *)data->ptr + offset, data->stype[i], data->ssize[i]);
+ }
+ switch (data->stype[i]) {
+ case 'I':
+ offset += sizeof(int) * data->ssize[i];
+ break;
+ case 'L':
+ offset += sizeof(long) * data->ssize[i];
+ break;
+ case 'P':
+ case 'S':
+ offset += sizeof(void*) * data->ssize[i];
+ break;
+ case 'F':
+ offset += sizeof(float) * data->ssize[i];
+ break;
+ case 'D':
+ offset += sizeof(double) * data->ssize[i];
+ break;
+ case 'C':
+ offset += sizeof(char) * data->ssize[i];
+ break;
+ case 'H':
+ offset += sizeof(short) * data->ssize[i];
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ }
+ break;
+ case DLPTR_CTYPE_UNION:
+ for (i=0; i < data->ids_num; i++) {
+ if (data->ids[i] == id) {
+ return cary2ary((char *)data->ptr + offset, data->stype[i], data->ssize[i]);
+ }
+ }
+ break;
+ } /* end of switch */
+
+ rb_raise(rb_eNameError, "undefined key `%s' for %s",
+ rb_id2name(id), rb_class2name(CLASS_OF(self)));
+
+ return Qnil;
+}
+
+static void *
+ary2cary(char t, VALUE val, long *size)
+{
+ void *ptr;
+
+ if (TYPE(val) == T_ARRAY) {
+ ptr = rb_ary2cary(t, val, size);
+ }
+ else{
+ ptr = rb_ary2cary(t, rb_ary_new3(1, val), size);
+ }
+ return ptr;
+}
+
+VALUE
+rb_dlptr_aset(int argc, VALUE argv[], VALUE self)
+{
+ VALUE key = Qnil, num = Qnil, val = Qnil;
+ ID id;
+ struct ptr_data *data;
+ int i;
+ int offset;
+ long memsize;
+ void *memimg;
+
+ rb_secure(4);
+ switch (rb_scan_args(argc, argv, "21", &key, &num, &val)) {
+ case 2:
+ val = num;
+ num = Qnil;
+ break;
+ }
+
+ if (TYPE(key) == T_FIXNUM || TYPE(key) == T_BIGNUM) {
+ void *dst, *src;
+ long len;
+
+ StringValue(val);
+ Data_Get_Struct(self, struct ptr_data, data);
+ dst = (void*)((long)(data->ptr) + DLNUM2LONG(key));
+ src = RSTRING(val)->ptr;
+ len = RSTRING(val)->len;
+ if (num == Qnil) {
+ memcpy(dst, src, len);
+ }
+ else{
+ long n = NUM2INT(num);
+ memcpy(dst, src, n < len ? n : len);
+ if (n > len) MEMZERO((char*)dst + len, char, n - len);
+ }
+ return val;
+ }
+
+ id = rb_to_id(key);
+ Data_Get_Struct(self, struct ptr_data, data);
+ switch (data->ctype) {
+ case DLPTR_CTYPE_STRUCT:
+ offset = 0;
+ for (i=0; i < data->ids_num; i++) {
+ switch (data->stype[i]) {
+ case 'I':
+ DLALIGN(data->ptr,offset,INT_ALIGN);
+ break;
+ case 'L':
+ DLALIGN(data->ptr,offset,LONG_ALIGN);
+ break;
+ case 'P':
+ case 'S':
+ DLALIGN(data->ptr,offset,VOIDP_ALIGN);
+ break;
+ case 'D':
+ DLALIGN(data->ptr,offset,DOUBLE_ALIGN);
+ break;
+ case 'F':
+ DLALIGN(data->ptr,offset,FLOAT_ALIGN);
+ break;
+ case 'C':
+ break;
+ case 'H':
+ DLALIGN(data->ptr,offset,SHORT_ALIGN);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ if (data->ids[i] == id) {
+ memimg = ary2cary(data->stype[i], val, &memsize);
+ memcpy((char *)data->ptr + offset, memimg, memsize);
+ dlfree(memimg);
+ return val;
+ }
+ switch (data->stype[i]) {
+ case 'I':
+ case 'i':
+ offset += sizeof(int) * data->ssize[i];
+ break;
+ case 'L':
+ case 'l':
+ offset += sizeof(long) * data->ssize[i];
+ break;
+ case 'P':
+ case 'p':
+ case 'S':
+ case 's':
+ offset += sizeof(void*) * data->ssize[i];
+ break;
+ case 'D':
+ case 'd':
+ offset += sizeof(double) * data->ssize[i];
+ break;
+ case 'F':
+ case 'f':
+ offset += sizeof(float) * data->ssize[i];
+ break;
+ case 'C':
+ case 'c':
+ offset += sizeof(char) * data->ssize[i];
+ break;
+ case 'H':
+ case 'h':
+ offset += sizeof(short) * data->ssize[i];
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ }
+ return val;
+ /* break; */
+ case DLPTR_CTYPE_UNION:
+ for (i=0; i < data->ids_num; i++) {
+ if (data->ids[i] == id) {
+ switch (data->stype[i]) {
+ case 'I': case 'i':
+ memsize = sizeof(int) * data->ssize[i];
+ break;
+ case 'L': case 'l':
+ memsize = sizeof(long) * data->ssize[i];
+ break;
+ case 'P': case 'p':
+ case 'S': case 's':
+ memsize = sizeof(void*) * data->ssize[i];
+ break;
+ case 'F': case 'f':
+ memsize = sizeof(float) * data->ssize[i];
+ break;
+ case 'D': case 'd':
+ memsize = sizeof(double) * data->ssize[i];
+ break;
+ case 'C': case 'c':
+ memsize = sizeof(char) * data->ssize[i];
+ break;
+ case 'H': case 'h':
+ memsize = sizeof(short) * data->ssize[i];
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ memimg = ary2cary(data->stype[i], val, NULL);
+ memcpy(data->ptr, memimg, memsize);
+ dlfree(memimg);
+ }
+ }
+ return val;
+ /* break; */
+ }
+
+ rb_raise(rb_eNameError, "undefined key `%s' for %s",
+ rb_id2name(id), rb_class2name(CLASS_OF(self)));
+
+ return Qnil;
+}
+
+VALUE
+rb_dlptr_size(int argc, VALUE argv[], VALUE self)
+{
+ VALUE size;
+
+ if (rb_scan_args(argc, argv, "01", &size) == 0){
+ return DLLONG2NUM(RDLPTR(self)->size);
+ }
+ else{
+ RDLPTR(self)->size = DLNUM2LONG(size);
+ return size;
+ }
+}
+
+static int
+dlmem_each_i(void* key, VALUE value, void* arg)
+{
+ VALUE vkey = DLLONG2NUM(key);
+ rb_yield(rb_assoc_new(vkey, value));
+ return Qnil;
+}
+
+VALUE
+rb_dlmem_each(VALUE self)
+{
+ st_foreach(st_memory_table, dlmem_each_i, 0);
+ return Qnil;
+}
+
+void
+Init_dlptr()
+{
+ rb_cDLPtrData = rb_define_class_under(rb_mDL, "PtrData", rb_cObject);
+ rb_define_alloc_func(rb_cDLPtrData, rb_dlptr_s_allocate);
+ rb_define_singleton_method(rb_cDLPtrData, "malloc", rb_dlptr_s_malloc, -1);
+ rb_define_method(rb_cDLPtrData, "initialize", rb_dlptr_initialize, -1);
+ rb_define_method(rb_cDLPtrData, "free=", rb_dlptr_free_set, 1);
+ rb_define_method(rb_cDLPtrData, "free", rb_dlptr_free_get, 0);
+ rb_define_method(rb_cDLPtrData, "to_i", rb_dlptr_to_i, 0);
+ rb_define_method(rb_cDLPtrData, "ptr", rb_dlptr_ptr, 0);
+ rb_define_method(rb_cDLPtrData, "+@", rb_dlptr_ptr, 0);
+ rb_define_method(rb_cDLPtrData, "ref", rb_dlptr_ref, 0);
+ rb_define_method(rb_cDLPtrData, "-@", rb_dlptr_ref, 0);
+ rb_define_method(rb_cDLPtrData, "null?", rb_dlptr_null_p, 0);
+ rb_define_method(rb_cDLPtrData, "to_a", rb_dlptr_to_array, -1);
+ rb_define_method(rb_cDLPtrData, "to_s", rb_dlptr_to_s, -1);
+ rb_define_method(rb_cDLPtrData, "to_str", rb_dlptr_to_str, -1);
+ rb_define_method(rb_cDLPtrData, "inspect", rb_dlptr_inspect, 0);
+ rb_define_method(rb_cDLPtrData, "<=>", rb_dlptr_cmp, 1);
+ rb_define_method(rb_cDLPtrData, "==", rb_dlptr_eql, 1);
+ rb_define_method(rb_cDLPtrData, "eql?", rb_dlptr_eql, 1);
+ rb_define_method(rb_cDLPtrData, "+", rb_dlptr_plus, 1);
+ rb_define_method(rb_cDLPtrData, "-", rb_dlptr_minus, 1);
+ rb_define_method(rb_cDLPtrData, "define_data_type",
+ rb_dlptr_define_data_type, -1);
+ rb_define_method(rb_cDLPtrData, "struct!", rb_dlptr_define_struct, -1);
+ rb_define_method(rb_cDLPtrData, "union!", rb_dlptr_define_union, -1);
+ rb_define_method(rb_cDLPtrData, "data_type", rb_dlptr_get_data_type, 0);
+ rb_define_method(rb_cDLPtrData, "[]", rb_dlptr_aref, -1);
+ rb_define_method(rb_cDLPtrData, "[]=", rb_dlptr_aset, -1);
+ rb_define_method(rb_cDLPtrData, "size", rb_dlptr_size, -1);
+ rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
+
+ rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
+ st_memory_table = st_init_numtable();
+ rb_define_const(rb_mDLMemorySpace, "MemoryTable", Qnil); /* historical */
+ rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0);
+}
diff --git a/ext/dl/sample/c++sample.C b/ext/dl/sample/c++sample.C
new file mode 100644
index 0000000000..d083d337a7
--- /dev/null
+++ b/ext/dl/sample/c++sample.C
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+class Person {
+private:
+ const char *name;
+ int age;
+
+public:
+ Person(const char *name, int age);
+ const char * get_name();
+ int get_age();
+ void set_age(int i);
+};
+
+Person::Person(const char *name, int age)
+ : name(name), age(age)
+{
+ /* empty */
+}
+
+const char *
+Person::get_name()
+{
+ return name;
+}
+
+int
+Person::get_age(){
+ return age;
+}
+
+void
+Person::set_age(int i){
+ age = i;
+}
diff --git a/ext/dl/sample/c++sample.rb b/ext/dl/sample/c++sample.rb
new file mode 100644
index 0000000000..29887df845
--- /dev/null
+++ b/ext/dl/sample/c++sample.rb
@@ -0,0 +1,60 @@
+=begin
+ This script shows how to deal with C++ classes using Ruby/DL.
+ You must build a dynamic loadable library using "c++sample.C"
+ to run this script as follows:
+ $ g++ -o libsample.so -shared c++sample.C
+=end
+
+require 'dl'
+require 'dl/import'
+require 'dl/struct'
+
+# Give a name of dynamic loadable library
+LIBNAME = ARGV[0] || "libsample.so"
+
+class Person
+ module Core
+ extend DL::Importable
+
+ dlload LIBNAME
+
+ # mangled symbol names
+ extern "void __6PersonPCci(void *, const char *, int)"
+ extern "const char *get_name__6Person(void *)"
+ extern "int get_age__6Person(void *)"
+ extern "void set_age__6Personi(void *, int)"
+
+ Data = struct [
+ "char *name",
+ "int age",
+ ]
+ end
+
+ def initialize(name, age)
+ @ptr = Core::Data.alloc
+ Core::__6PersonPCci(@ptr, name, age)
+ end
+
+ def get_name()
+ str = Core::get_name__6Person(@ptr)
+ if( str )
+ str.to_s
+ else
+ nil
+ end
+ end
+
+ def get_age()
+ Core::get_age__6Person(@ptr)
+ end
+
+ def set_age(age)
+ Core::set_age__6Personi(@ptr, age)
+ end
+end
+
+obj = Person.new("ttate", 1)
+p obj.get_name()
+p obj.get_age()
+obj.set_age(10)
+p obj.get_age()
diff --git a/ext/dl/sample/drives.rb b/ext/dl/sample/drives.rb
new file mode 100644
index 0000000000..8a590404b1
--- /dev/null
+++ b/ext/dl/sample/drives.rb
@@ -0,0 +1,70 @@
+# -*- ruby -*-
+# drives.rb -- find existing drives and show the drive type.
+
+require 'dl'
+require 'dl/import'
+
+module Kernel32
+ extend DL::Importable
+
+ dlload "kernel32"
+
+ extern "long GetLogicalDrives()"
+ extern "int GetDriveType(char*)"
+ extern "long GetDiskFreeSpace(char*, long ref, long ref, long ref, long ref)"
+end
+
+include Kernel32
+
+buff = Kernel32.getLogicalDrives()
+
+i = 0
+ds = []
+while( i < 26 )
+ mask = (1 << i)
+ if( buff & mask > 0 )
+ ds.push((65+i).chr)
+ end
+ i += 1
+end
+
+=begin
+From the cygwin's /usr/include/w32api/winbase.h:
+#define DRIVE_UNKNOWN 0
+#define DRIVE_NO_ROOT_DIR 1
+#define DRIVE_REMOVABLE 2
+#define DRIVE_FIXED 3
+#define DRIVE_REMOTE 4
+#define DRIVE_CDROM 5
+#define DRIVE_RAMDISK 6
+=end
+
+types = [
+ "unknown",
+ "no root dir",
+ "Removable",
+ "Fixed",
+ "Remote",
+ "CDROM",
+ "RAM",
+]
+print("Drive : Type (Free Space/Available Space)\n")
+ds.each{|d|
+ t = Kernel32.getDriveType(d + ":\\")
+ Kernel32.getDiskFreeSpace(d + ":\\", 0, 0, 0, 0)
+ _,sec_per_clus,byte_per_sec,free_clus,total_clus = Kernel32._args_
+ fbytes = sec_per_clus * byte_per_sec * free_clus
+ tbytes = sec_per_clus * byte_per_sec * total_clus
+ unit = "B"
+ if( fbytes > 1024 && tbytes > 1024 )
+ fbytes = fbytes / 1024
+ tbytes = tbytes / 1024
+ unit = "K"
+ end
+ if( fbytes > 1024 && tbytes > 1024 )
+ fbytes = fbytes / 1024
+ tbytes = tbytes / 1024
+ unit = "M"
+ end
+ print("#{d} : #{types[t]} (#{fbytes} #{unit}/#{tbytes} #{unit})\n")
+}
diff --git a/ext/dl/sample/getch.rb b/ext/dl/sample/getch.rb
new file mode 100644
index 0000000000..3f7261c979
--- /dev/null
+++ b/ext/dl/sample/getch.rb
@@ -0,0 +1,5 @@
+require 'dl'
+
+crtdll = DL::dlopen("crtdll")
+getch = crtdll['_getch', 'L']
+print(getch.call, "\n")
diff --git a/ext/dl/sample/libc.rb b/ext/dl/sample/libc.rb
new file mode 100644
index 0000000000..a1f6fbe543
--- /dev/null
+++ b/ext/dl/sample/libc.rb
@@ -0,0 +1,69 @@
+require "dl/import"
+require "dl/struct"
+
+module LIBC
+ extend DL::Importable
+
+ begin
+ dlload "libc.so.6"
+ rescue
+ dlload "libc.so.5"
+ end
+
+ extern "int atoi(char*)"
+ extern "ibool isdigit(int)"
+ extern "int gettimeofday(struct timeval *, struct timezone *)"
+ extern "char* strcat(char*, char*)"
+ extern "FILE* fopen(char*, char*)"
+ extern "int fclose(FILE*)"
+ extern "int fgetc(FILE*)"
+ extern "int strlen(char*)"
+ extern "void qsort(void*, int, int, void*)"
+
+ def str_qsort(ary, comp)
+ len = ary.length
+ r,rs = qsort(ary, len, DL.sizeof('P'), comp)
+ return rs[0].to_a('S', len)
+ end
+
+ Timeval = struct [
+ "long tv_sec",
+ "long tv_usec",
+ ]
+
+ Timezone = struct [
+ "int tz_minuteswest",
+ "int tz_dsttime",
+ ]
+
+ def my_compare(ptr1, ptr2)
+ ptr1.ptr.to_s <=> ptr2.ptr.to_s
+ end
+ COMPARE = callback("int my_compare(char**, char**)")
+end
+
+
+$cb1 = DL.callback('IPP'){|ptr1, ptr2|
+ str1 = ptr1.ptr.to_s
+ str2 = ptr2.ptr.to_s
+ str1 <=> str2
+}
+
+p LIBC.atoi("10")
+
+p LIBC.isdigit(?1)
+
+p LIBC.isdigit(?a)
+
+p LIBC.strcat("a", "b")
+
+ary = ["a","c","b"]
+ptr = ary.to_ptr
+LIBC.qsort(ptr, ary.length, DL.sizeof('P'), LIBC::COMPARE)
+p ptr.to_a('S', ary.length)
+
+tv = LIBC::Timeval.malloc
+tz = LIBC::Timezone.malloc
+LIBC.gettimeofday(tv, tz)
+
+p Time.at(tv.tv_sec)
diff --git a/ext/dl/sample/msgbox.rb b/ext/dl/sample/msgbox.rb
new file mode 100644
index 0000000000..091e646091
--- /dev/null
+++ b/ext/dl/sample/msgbox.rb
@@ -0,0 +1,19 @@
+# This script works on Windows.
+
+require 'dl'
+
+User32 = DL.dlopen("user32")
+Kernel32 = DL.dlopen("kernel32")
+
+MB_OK = 0
+MB_OKCANCEL = 1
+
+message_box = User32['MessageBoxA', 'ILSSI']
+r,rs = message_box.call(0, 'ok?', 'error', MB_OKCANCEL)
+
+case r
+when 1
+ print("OK!\n")
+when 2
+ print("Cancel!\n")
+end
diff --git a/ext/dl/sample/msgbox2.rb b/ext/dl/sample/msgbox2.rb
new file mode 100644
index 0000000000..e49846cc5e
--- /dev/null
+++ b/ext/dl/sample/msgbox2.rb
@@ -0,0 +1,18 @@
+# This script works on Windows.
+
+require 'dl/win32'
+
+MB_OK = 0
+MB_OKCANCEL = 1
+
+message_box = Win32API.new("user32",'MessageBoxA', 'ISSI', 'I')
+r = message_box.call(0, 'ok?', 'error', MB_OKCANCEL)
+
+case r
+when 1
+ print("OK!\n")
+when 2
+ print("Cancel!\n")
+else
+ p r
+end
diff --git a/ext/dl/sample/stream.rb b/ext/dl/sample/stream.rb
new file mode 100644
index 0000000000..179836999d
--- /dev/null
+++ b/ext/dl/sample/stream.rb
@@ -0,0 +1,87 @@
+# -*- ruby -*-
+# Display a file name and stream names of a file with those size.
+
+require 'dl'
+require 'dl/import'
+
+module NTFS
+ extend DL::Importable
+
+ dlload "kernel32.dll"
+
+ OPEN_EXISTING = 3
+ GENERIC_READ = 0x80000000
+ BACKUP_DATA = 0x00000001
+ BACKUP_ALTERNATE_DATA = 0x00000004
+ FILE_SHARE_READ = 0x00000001
+ FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
+
+ typealias "LPSECURITY_ATTRIBUTES", "void*"
+
+ extern "BOOL BackupRead(HANDLE, PBYTE, DWORD, PDWORD, BOOL, BOOL, PVOID)"
+ extern "BOOL BackupSeek(HANDLE, DWORD, DWORD, PDWORD, PDWORD, PVOID)"
+ extern "BOOL CloseHandle(HANDLE)"
+ extern "HANDLE CreateFile(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,
+ DWORD, DWORD, HANDLE)"
+
+ module_function
+
+ def streams(filename)
+ status = []
+ h = createFile(filename,GENERIC_READ,FILE_SHARE_READ,nil,
+ OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0)
+ if( h != 0 )
+ begin
+ # allocate the memory for backup data used in backupRead().
+ data = DL.malloc(DL.sizeof("L5"))
+ data.struct!("LLLLL", :id, :attrs, :size_low, :size_high, :name_size)
+
+ # allocate memories for references to long values used in backupRead().
+ context = DL.malloc(DL.sizeof("L"))
+ lval = DL.malloc(DL.sizeof("L"))
+
+ while( backupRead(h, data, data.size, lval, false, false, context) )
+ size = data[:size_low] + (data[:size_high] << (DL.sizeof("I") * 8))
+ case data[:id]
+ when BACKUP_ALTERNATE_DATA
+ stream_name = DL.malloc(data[:name_size])
+ backupRead(h, stream_name, stream_name.size,
+ lval, false, false, context)
+ name = stream_name[0, stream_name.size]
+ name.tr!("\000","")
+ if( name =~ /^:(.*?):.*$/ )
+ status.push([$1,size])
+ end
+ when BACKUP_DATA
+ status.push([nil,size])
+ else
+ raise(RuntimeError, "unknown data type #{data[:id]}.")
+ end
+ l1 = DL.malloc(DL.sizeof("L"))
+ l2 = DL.malloc(DL.sizeof("L"))
+ if( !backupSeek(h, data[:size_low], data[:size_high], l1, l2, context) )
+ break
+ end
+ end
+ ensure
+ backupRead(h, nil, 0, lval, true, false, context)
+ closeHandle(h)
+ end
+ return status
+ else
+ raise(RuntimeError, "can't open #{filename}.\n")
+ end
+ end
+end
+
+ARGV.each{|filename|
+ if( File.exist?(filename) )
+ NTFS.streams(filename).each{|name,size|
+ if( name )
+ print("#{filename}:#{name}\t#{size}bytes\n")
+ else
+ print("#{filename}\t#{size}bytes\n")
+ end
+ }
+ end
+}
diff --git a/ext/dl/sym.c b/ext/dl/sym.c
new file mode 100644
index 0000000000..933fb7f4f0
--- /dev/null
+++ b/ext/dl/sym.c
@@ -0,0 +1,993 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <errno.h>
+#include "dl.h"
+
+VALUE rb_cDLSymbol;
+
+static const char *
+char2type(int ch)
+{
+ switch (ch) {
+ case '0':
+ return "void";
+ case 'P':
+ return "void *";
+ case 'p':
+ return "void *";
+ case 'C':
+ return "char";
+ case 'c':
+ return "char *";
+ case 'H':
+ return "short";
+ case 'h':
+ return "short *";
+ case 'I':
+ return "int";
+ case 'i':
+ return "int *";
+ case 'L':
+ return "long";
+ case 'l':
+ return "long *";
+ case 'F':
+ return "double";
+ case 'f':
+ return "double *";
+ case 'D':
+ return "double";
+ case 'd':
+ return "double *";
+ case 'S':
+ return "const char *";
+ case 's':
+ return "char *";
+ case 'A':
+ return "[]";
+ case 'a':
+ return "[]"; /* ?? */
+ }
+ return NULL;
+}
+
+void
+dlsym_free(struct sym_data *data)
+{
+ if( data->name ){
+ DEBUG_CODE({
+ printf("dlsym_free(): free(data->name:%s)\n",data->name);
+ });
+ free(data->name);
+ }
+ if( data->type ){
+ DEBUG_CODE({
+ printf("dlsym_free(): free(data->type:%s)\n",data->type);
+ });
+ free(data->type);
+ }
+}
+
+VALUE
+rb_dlsym_new(void (*func)(), const char *name, const char *type)
+{
+ VALUE val;
+ struct sym_data *data;
+ const char *ptype;
+
+ rb_secure(4);
+ if( !type || !type[0] ){
+ return rb_dlptr_new((void*)func, 0, 0);
+ }
+
+ for( ptype = type; *ptype; ptype ++ ){
+ if( ! char2type(*ptype) ){
+ rb_raise(rb_eDLTypeError, "unknown type specifier '%c'", *ptype);
+ }
+ }
+
+ if( func ){
+ val = Data_Make_Struct(rb_cDLSymbol, struct sym_data, 0, dlsym_free, data);
+ data->func = func;
+ data->name = name ? strdup(name) : NULL;
+ data->type = type ? strdup(type) : NULL;
+ data->len = type ? strlen(type) : 0;
+#if !(defined(DLSTACK))
+ if( data->len - 1 > MAX_ARG ){
+ rb_raise(rb_eDLError, "maximum number of arguments is %d.", MAX_ARG);
+ }
+#endif
+ }
+ else{
+ val = Qnil;
+ }
+
+ return val;
+}
+
+freefunc_t
+rb_dlsym2csym(VALUE val)
+{
+ struct sym_data *data;
+ freefunc_t func;
+
+ if( rb_obj_is_kind_of(val, rb_cDLSymbol) ){
+ Data_Get_Struct(val, struct sym_data, data);
+ func = data->func;
+ }
+ else if( val == Qnil ){
+ func = NULL;
+ }
+ else{
+ rb_raise(rb_eTypeError, "DL::Symbol was expected");
+ }
+
+ return func;
+}
+
+VALUE
+rb_dlsym_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct sym_data *data;
+
+ obj = Data_Make_Struct(klass, struct sym_data, 0, dlsym_free, data);
+ data->func = 0;
+ data->name = 0;
+ data->type = 0;
+ data->len = 0;
+
+ return obj;
+}
+
+VALUE
+rb_dlsym_initialize(int argc, VALUE argv[], VALUE self)
+{
+ VALUE addr, name, type;
+ struct sym_data *data;
+ void *saddr;
+ const char *sname, *stype;
+
+ rb_scan_args(argc, argv, "12", &addr, &name, &type);
+
+ saddr = (void*)(DLNUM2LONG(rb_Integer(addr)));
+ if (!NIL_P(name)) StringValue(name);
+ stype = NIL_P(type) ? NULL : StringValuePtr(type);
+ sname = NIL_P(name) ? NULL : RSTRING(name)->ptr;
+
+ if( saddr ){
+ Data_Get_Struct(self, struct sym_data, data);
+ if( data->name ) free(data->name);
+ if( data->type ) free(data->type);
+ data->func = saddr;
+ data->name = sname ? strdup(sname) : 0;
+ data->type = stype ? strdup(stype) : 0;
+ data->len = stype ? strlen(stype) : 0;
+ }
+
+ return Qnil;
+}
+
+VALUE
+rb_s_dlsym_char2type(VALUE self, VALUE ch)
+{
+ const char *type;
+
+ type = char2type(StringValuePtr(ch)[0]);
+
+ if (type == NULL)
+ return Qnil;
+ else
+ return rb_str_new2(type);
+}
+
+VALUE
+rb_dlsym_name(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return sym->name ? rb_tainted_str_new2(sym->name) : Qnil;
+}
+
+VALUE
+rb_dlsym_proto(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return sym->type ? rb_tainted_str_new2(sym->type) : Qnil;
+}
+
+VALUE
+rb_dlsym_cproto(VALUE self)
+{
+ struct sym_data *sym;
+ const char *ptype, *typestr;
+ size_t len;
+ VALUE val;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+
+ ptype = sym->type;
+
+ if( ptype ){
+ typestr = char2type(*ptype++);
+ len = strlen(typestr);
+
+ val = rb_tainted_str_new(typestr, len);
+ if (typestr[len - 1] != '*')
+ rb_str_cat(val, " ", 1);
+
+ if( sym->name ){
+ rb_str_cat2(val, sym->name);
+ }
+ else{
+ rb_str_cat2(val, "(null)");
+ }
+ rb_str_cat(val, "(", 1);
+
+ while (*ptype) {
+ const char *ty = char2type(*ptype++);
+ rb_str_cat2(val, ty);
+ if (*ptype)
+ rb_str_cat(val, ", ", 2);
+ }
+
+ rb_str_cat(val, ");", 2);
+ }
+ else{
+ val = rb_tainted_str_new2("void (");
+ if( sym->name ){
+ rb_str_cat2(val, sym->name);
+ }
+ else{
+ rb_str_cat2(val, "(null)");
+ }
+ rb_str_cat2(val, ")()");
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlsym_inspect(VALUE self)
+{
+ VALUE proto;
+ VALUE val;
+ char *str;
+ int str_size;
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ proto = rb_dlsym_cproto(self);
+
+ str_size = RSTRING(proto)->len + 100;
+ str = dlmalloc(str_size);
+ snprintf(str, str_size - 1,
+ "#<DL::Symbol:0x%lx func=0x%lx '%s'>",
+ sym, sym->func, RSTRING(proto)->ptr);
+ val = rb_tainted_str_new2(str);
+ dlfree(str);
+
+ return val;
+}
+
+static int
+stack_size(struct sym_data *sym)
+{
+ int i;
+ int size;
+
+ size = 0;
+ for( i=1; i < sym->len; i++ ){
+ switch(sym->type[i]){
+ case 'C':
+ case 'H':
+ case 'I':
+ case 'L':
+ size += sizeof(long);
+ break;
+ case 'F':
+ size += sizeof(float);
+ break;
+ case 'D':
+ size += sizeof(double);
+ break;
+ case 'c':
+ case 'h':
+ case 'i':
+ case 'l':
+ case 'f':
+ case 'd':
+ case 'p':
+ case 'P':
+ case 's':
+ case 'S':
+ case 'a':
+ case 'A':
+ size += sizeof(void*);
+ break;
+ default:
+ return -(sym->type[i]);
+ }
+ }
+ return size;
+}
+
+static ID rb_dl_id_DLErrno;
+
+static VALUE
+rb_dl_get_last_error(VALUE self)
+{
+ return rb_thread_local_aref(rb_thread_current(), rb_dl_id_DLErrno);
+}
+
+static VALUE
+rb_dl_set_last_error(VALUE self, VALUE val)
+{
+ errno = NUM2INT(val);
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLErrno, val);
+ return Qnil;
+}
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+static ID rb_dl_id_DLW32Error;
+
+static VALUE
+rb_dl_win32_get_last_error(VALUE self)
+{
+ return rb_thread_local_aref(rb_thread_current(), rb_dl_id_DLW32Error);
+}
+
+static VALUE
+rb_dl_win32_set_last_error(VALUE self, VALUE val)
+{
+ SetLastError(NUM2INT(val));
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLW32Error, val);
+ return Qnil;
+}
+#endif
+
+#ifdef DLSTACK_GUARD
+# ifdef __MSVC_RUNTIME_CHECKS
+# pragma runtime_checks("s", off)
+# endif
+# if _MSC_VER >= 1300
+__declspec(noinline)
+# endif
+static int
+rb_dlsym_guardcall(char type, ANY_TYPE *ret, long *stack, void *func)
+{
+ char *volatile guard = ALLOCA_N(char, 1); /* guard stack pointer */
+ switch(type){
+ case '0':
+ {
+ void (*f)(DLSTACK_PROTO) = func;
+ f(DLSTACK_ARGS);
+ }
+ break;
+ case 'P':
+ case 'p':
+ {
+ void * (*f)(DLSTACK_PROTO) = func;
+ ret->p = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'C':
+ case 'c':
+ {
+ char (*f)(DLSTACK_PROTO) = func;
+ ret->c = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'H':
+ case 'h':
+ {
+ short (*f)(DLSTACK_PROTO) = func;
+ ret->h = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'I':
+ case 'i':
+ {
+ int (*f)(DLSTACK_PROTO) = func;
+ ret->i = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'L':
+ case 'l':
+ {
+ long (*f)(DLSTACK_PROTO) = func;
+ ret->l = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'F':
+ case 'f':
+ {
+ float (*f)(DLSTACK_PROTO) = func;
+ ret->f = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'D':
+ case 'd':
+ {
+ double (*f)(DLSTACK_PROTO) = func;
+ ret->d = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'S':
+ case 's':
+ {
+ char * (*f)(DLSTACK_PROTO) = func;
+ ret->s = f(DLSTACK_ARGS);
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+# ifdef __MSVC_RUNTIME_CHECKS
+# pragma runtime_checks("s", restore)
+# endif
+#endif /* defined(DLSTACK_GUARD) */
+
+VALUE
+rb_dlsym_call(int argc, VALUE argv[], VALUE self)
+{
+ struct sym_data *sym;
+ ANY_TYPE *args;
+ ANY_TYPE *dargs;
+ ANY_TYPE ret;
+ int *dtypes;
+ VALUE val;
+ VALUE dvals;
+ int i;
+ long ftype;
+ void *func;
+
+ rb_secure_update(self);
+ Data_Get_Struct(self, struct sym_data, sym);
+ DEBUG_CODE({
+ printf("rb_dlsym_call(): type = '%s', func = 0x%x\n", sym->type, sym->func);
+ });
+ if( (sym->len - 1) != argc ){
+ rb_raise(rb_eArgError, "%d arguments are needed", sym->len - 1);
+ }
+
+ ftype = 0;
+ dvals = Qnil;
+
+ args = ALLOC_N(ANY_TYPE, sym->len - 1);
+ dargs = ALLOC_N(ANY_TYPE, sym->len - 1);
+ dtypes = ALLOC_N(int, sym->len - 1);
+#define FREE_ARGS {xfree(args); xfree(dargs); xfree(dtypes);}
+
+ for( i = sym->len - 2; i >= 0; i-- ){
+ dtypes[i] = 0;
+
+ switch( sym->type[i+1] ){
+ case 'p':
+ dtypes[i] = 'p';
+ case 'P':
+ {
+ struct ptr_data *data;
+ VALUE pval;
+
+ if( argv[i] == Qnil ){
+ ANY2P(args[i]) = DLVOIDP(0);
+ }
+ else{
+ if( rb_obj_is_kind_of(argv[i], rb_cDLPtrData) ){
+ pval = argv[i];
+ }
+ else{
+ pval = rb_funcall(argv[i], rb_intern("to_ptr"), 0);
+ if( !rb_obj_is_kind_of(pval, rb_cDLPtrData) ){
+ rb_raise(rb_eDLTypeError, "unexpected type of argument #%d", i);
+ }
+ }
+ rb_check_safe_obj(pval);
+ Data_Get_Struct(pval, struct ptr_data, data);
+ ANY2P(args[i]) = DLVOIDP(data->ptr);
+ }
+ }
+ PUSH_P(ftype);
+ break;
+ case 'a':
+ dtypes[i] = 'a';
+ case 'A':
+ if( argv[i] == Qnil ){
+ ANY2P(args[i]) = DLVOIDP(0);
+ }
+ else{
+ ANY2P(args[i]) = DLVOIDP(rb_ary2cary(0, argv[i], NULL));
+ }
+ PUSH_P(ftype);
+ break;
+ case 'C':
+ ANY2C(args[i]) = DLCHAR(NUM2CHR(argv[i]));
+ PUSH_C(ftype);
+ break;
+ case 'c':
+ ANY2C(dargs[i]) = DLCHAR(NUM2CHR(argv[i]));
+ ANY2P(args[i]) = DLVOIDP(&(ANY2C(dargs[i])));
+ dtypes[i] = 'c';
+ PUSH_P(ftype);
+ break;
+ case 'H':
+ ANY2H(args[i]) = DLSHORT(NUM2INT(argv[i]));
+ PUSH_C(ftype);
+ break;
+ case 'h':
+ ANY2H(dargs[i]) = DLSHORT(NUM2INT(argv[i]));
+ ANY2P(args[i]) = DLVOIDP(&(ANY2H(dargs[i])));
+ dtypes[i] = 'h';
+ PUSH_P(ftype);
+ break;
+ case 'I':
+ ANY2I(args[i]) = DLINT(NUM2INT(argv[i]));
+ PUSH_I(ftype);
+ break;
+ case 'i':
+ ANY2I(dargs[i]) = DLINT(NUM2INT(argv[i]));
+ ANY2P(args[i]) = DLVOIDP(&(ANY2I(dargs[i])));
+ dtypes[i] = 'i';
+ PUSH_P(ftype);
+ break;
+ case 'L':
+ ANY2L(args[i]) = DLNUM2LONG(argv[i]);
+ PUSH_L(ftype);
+ break;
+ case 'l':
+ ANY2L(dargs[i]) = DLNUM2LONG(argv[i]);
+ ANY2P(args[i]) = DLVOIDP(&(ANY2L(dargs[i])));
+ dtypes[i] = 'l';
+ PUSH_P(ftype);
+ break;
+ case 'F':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2F(args[i]) = DLFLOAT(RFLOAT(argv[i])->value);
+ PUSH_F(ftype);
+ break;
+ case 'f':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2F(dargs[i]) = DLFLOAT(RFLOAT(argv[i])->value);
+ ANY2P(args[i]) = DLVOIDP(&(ANY2F(dargs[i])));
+ dtypes[i] = 'f';
+ PUSH_P(ftype);
+ break;
+ case 'D':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2D(args[i]) = RFLOAT(argv[i])->value;
+ PUSH_D(ftype);
+ break;
+ case 'd':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2D(dargs[i]) = RFLOAT(argv[i])->value;
+ ANY2P(args[i]) = DLVOIDP(&(ANY2D(dargs[i])));
+ dtypes[i] = 'd';
+ PUSH_P(ftype);
+ break;
+ case 'S':
+ if( argv[i] == Qnil ){
+ ANY2S(args[i]) = DLSTR(0);
+ }
+ else{
+ VALUE str = argv[i];
+ SafeStringValue(str);
+ ANY2S(args[i]) = DLSTR(RSTRING(str)->ptr);
+ }
+ PUSH_P(ftype);
+ break;
+ case 's':
+ {
+ VALUE str = argv[i];
+ SafeStringValue(str);
+ ANY2S(args[i]) = DLSTR(dlmalloc(RSTRING(str)->len + 1));
+ memcpy((char*)(ANY2S(args[i])), RSTRING(str)->ptr, RSTRING(str)->len + 1);
+ dtypes[i] = 's';
+ }
+ PUSH_P(ftype);
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError,
+ "unknown type '%c' of the return value.",
+ sym->type[i+1]);
+ }
+ }
+
+ switch( sym->type[0] ){
+ case '0':
+ PUSH_0(ftype);
+ break;
+ case 'P':
+ case 'p':
+ case 'S':
+ case 's':
+ case 'A':
+ case 'a':
+ PUSH_P(ftype);
+ break;
+ case 'C':
+ case 'c':
+ PUSH_C(ftype);
+ break;
+ case 'H':
+ case 'h':
+ PUSH_H(ftype);
+ break;
+ case 'I':
+ case 'i':
+ PUSH_I(ftype);
+ break;
+ case 'L':
+ case 'l':
+ PUSH_L(ftype);
+ break;
+ case 'F':
+ case 'f':
+ PUSH_F(ftype);
+ break;
+ case 'D':
+ case 'd':
+ PUSH_D(ftype);
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError,
+ "unknown type `%c' of the return value.",
+ sym->type[0]);
+ }
+
+ func = sym->func;
+
+#if defined(DLSTACK)
+ {
+#if defined(DLSTACK_SIZE)
+ int stk_size;
+ long stack[DLSTACK_SIZE];
+ long *sp;
+
+ sp = stack;
+ stk_size = stack_size(sym);
+ if( stk_size < 0 ){
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type '%c'.", -stk_size);
+ }
+ else if( stk_size > (int)(DLSTACK_SIZE) ){
+ FREE_ARGS;
+ rb_raise(rb_eArgError, "too many arguments.");
+ }
+#endif
+
+ DLSTACK_START(sym);
+
+#if defined(DLSTACK_REVERSE)
+ for( i = sym->len - 2; i >= 0; i-- )
+#else
+ for( i = 0; i <= sym->len -2; i++ )
+#endif
+ {
+ switch( sym->type[i+1] ){
+ case 'p':
+ case 'P':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'a':
+ case 'A':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'C':
+ DLSTACK_PUSH_C(ANY2C(args[i]));
+ break;
+ case 'c':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'H':
+ DLSTACK_PUSH_H(ANY2H(args[i]));
+ break;
+ case 'h':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'I':
+ DLSTACK_PUSH_I(ANY2I(args[i]));
+ break;
+ case 'i':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'L':
+ DLSTACK_PUSH_L(ANY2L(args[i]));
+ break;
+ case 'l':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'F':
+ DLSTACK_PUSH_F(ANY2F(args[i]));
+ break;
+ case 'f':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'D':
+ DLSTACK_PUSH_D(ANY2D(args[i]));
+ break;
+ case 'd':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'S':
+ case 's':
+ DLSTACK_PUSH_P(ANY2S(args[i]));
+ break;
+ }
+ }
+ DLSTACK_END(sym->type);
+
+#ifdef DLSTACK_GUARD
+ if(!rb_dlsym_guardcall(sym->type[0], &ret, stack, func)) {
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type `%c'", sym->type[0]);
+ }
+#else /* defined(DLSTACK_GUARD) */
+ {
+ switch( sym->type[0] ){
+ case '0':
+ {
+ void (*f)(DLSTACK_PROTO) = func;
+ f(DLSTACK_ARGS);
+ }
+ break;
+ case 'P':
+ case 'p':
+ {
+ void * (*f)(DLSTACK_PROTO) = func;
+ ret.p = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'C':
+ case 'c':
+ {
+ char (*f)(DLSTACK_PROTO) = func;
+ ret.c = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'H':
+ case 'h':
+ {
+ short (*f)(DLSTACK_PROTO) = func;
+ ret.h = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'I':
+ case 'i':
+ {
+ int (*f)(DLSTACK_PROTO) = func;
+ ret.i = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'L':
+ case 'l':
+ {
+ long (*f)(DLSTACK_PROTO) = func;
+ ret.l = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'F':
+ case 'f':
+ {
+ float (*f)(DLSTACK_PROTO) = func;
+ ret.f = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'D':
+ case 'd':
+ {
+ double (*f)(DLSTACK_PROTO) = func;
+ ret.d = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'S':
+ case 's':
+ {
+ char * (*f)(DLSTACK_PROTO) = func;
+ ret.s = f(DLSTACK_ARGS);
+ }
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type `%c'", sym->type[0]);
+ }
+ }
+#endif /* defubed(DLSTACK_GUARD) */
+
+ {
+ /*
+ * We should get the value of errno/GetLastError() before calling another functions.
+ */
+ int last_errno = errno;
+#ifdef _WIN32
+ DWORD win32_last_err = GetLastError();
+#endif
+
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLErrno, INT2NUM(last_errno));
+#ifdef _WIN32
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLW32Error, INT2NUM(win32_last_err));
+#endif
+ }
+
+ }
+#else /* defined(DLSTACK) */
+ switch(ftype){
+#include "call.func"
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unsupported function type `%s'", sym->type);
+ }
+#endif /* defined(DLSTACK) */
+
+ switch( sym->type[0] ){
+ case '0':
+ val = Qnil;
+ break;
+ case 'P':
+ val = rb_dlptr_new((void*)(ANY2P(ret)), 0, 0);
+ break;
+ case 'p':
+ val = rb_dlptr_new((void*)(ANY2P(ret)), 0, dlfree);
+ break;
+ case 'C':
+ case 'c':
+ val = CHR2FIX((char)(ANY2C(ret)));
+ break;
+ case 'H':
+ case 'h':
+ val = INT2NUM((short)(ANY2H(ret)));
+ break;
+ case 'I':
+ case 'i':
+ val = INT2NUM((int)(ANY2I(ret)));
+ break;
+ case 'L':
+ case 'l':
+ val = DLLONG2NUM((long)(ANY2L(ret)));
+ break;
+ case 'F':
+ case 'f':
+ val = rb_float_new((double)(ANY2F(ret)));
+ break;
+ case 'D':
+ case 'd':
+ val = rb_float_new((double)(ANY2D(ret)));
+ break;
+ case 'S':
+ if( ANY2S(ret) ){
+ val = rb_tainted_str_new2((char*)(ANY2S(ret)));
+ }
+ else{
+ val = Qnil;
+ }
+ break;
+ case 's':
+ if( ANY2S(ret) ){
+ val = rb_tainted_str_new2((char*)(ANY2S(ret)));
+ DEBUG_CODE({
+ printf("dlfree(%s)\n",(char*)(ANY2S(ret)));
+ });
+ dlfree((void*)(ANY2S(ret)));
+ }
+ else{
+ val = Qnil;
+ }
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type `%c'", sym->type[0]);
+ }
+
+ dvals = rb_ary_new();
+ for( i = 0; i <= sym->len - 2; i++ ){
+ if( dtypes[i] ){
+ switch( dtypes[i] ){
+ case 'c':
+ rb_ary_push(dvals, CHR2FIX(*((char*)(ANY2P(args[i])))));
+ break;
+ case 'h':
+ rb_ary_push(dvals, INT2NUM(*((short*)(ANY2P(args[i])))));
+ break;
+ case 'i':
+ rb_ary_push(dvals, INT2NUM(*((int*)(ANY2P(args[i])))));
+ break;
+ case 'l':
+ rb_ary_push(dvals, DLLONG2NUM(*((long*)(ANY2P(args[i])))));
+ break;
+ case 'f':
+ rb_ary_push(dvals, rb_float_new(*((float*)(ANY2P(args[i])))));
+ break;
+ case 'd':
+ rb_ary_push(dvals, rb_float_new(*((double*)(ANY2P(args[i])))));
+ break;
+ case 'p':
+ rb_ary_push(dvals, rb_dlptr_new((void*)(ANY2P(args[i])), 0, 0));
+ break;
+ case 'a':
+ rb_ary_push(dvals, rb_dlptr_new((void*)ANY2P(args[i]), 0, 0));
+ break;
+ case 's':
+ rb_ary_push(dvals, rb_tainted_str_new2((char*)ANY2S(args[i])));
+ DEBUG_CODE({
+ printf("dlfree(%s)\n",(char*)ANY2S(args[i]));
+ });
+ dlfree((void*)ANY2S(args[i]));
+ break;
+ default:
+ {
+ char c = dtypes[i];
+ FREE_ARGS;
+ rb_raise(rb_eRuntimeError, "unknown argument type '%c'", i, c);
+ }
+ }
+ }
+ else{
+ switch( sym->type[i+1] ){
+ case 'A':
+ dlfree((void*)ANY2P(args[i]));
+ break;
+ }
+ rb_ary_push(dvals, argv[i]);
+ }
+ }
+
+ FREE_ARGS;
+#undef FREE_ARGS
+ return rb_assoc_new(val,dvals);
+}
+
+VALUE
+rb_dlsym_to_i(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return DLLONG2NUM(sym);
+}
+
+VALUE
+rb_dlsym_to_ptr(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return rb_dlptr_new(sym->func, sizeof(freefunc_t), 0);
+}
+
+void
+Init_dlsym()
+{
+ rb_cDLSymbol = rb_define_class_under(rb_mDL, "Symbol", rb_cObject);
+ rb_define_alloc_func(rb_cDLSymbol, rb_dlsym_s_allocate);
+ rb_define_singleton_method(rb_cDLSymbol, "char2type", rb_s_dlsym_char2type, 1);
+ rb_define_method(rb_cDLSymbol, "initialize", rb_dlsym_initialize, -1);
+ rb_define_method(rb_cDLSymbol, "call", rb_dlsym_call, -1);
+ rb_define_method(rb_cDLSymbol, "[]", rb_dlsym_call, -1);
+ rb_define_method(rb_cDLSymbol, "name", rb_dlsym_name, 0);
+ rb_define_method(rb_cDLSymbol, "proto", rb_dlsym_proto, 0);
+ rb_define_method(rb_cDLSymbol, "cproto", rb_dlsym_cproto, 0);
+ rb_define_method(rb_cDLSymbol, "inspect", rb_dlsym_inspect, 0);
+ rb_define_method(rb_cDLSymbol, "to_s", rb_dlsym_cproto, 0);
+ rb_define_method(rb_cDLSymbol, "to_ptr", rb_dlsym_to_ptr, 0);
+ rb_define_method(rb_cDLSymbol, "to_i", rb_dlsym_to_i, 0);
+
+ rb_dl_id_DLErrno = rb_intern("DLErrno");
+ rb_define_singleton_method(rb_mDL, "last_error", rb_dl_get_last_error, 0);
+ rb_define_singleton_method(rb_mDL, "last_error=", rb_dl_set_last_error, 1);
+#ifdef _WIN32
+ rb_dl_id_DLW32Error = rb_intern("DLW32Error");
+ rb_define_singleton_method(rb_mDL, "win32_last_error", rb_dl_win32_get_last_error, 0);
+ rb_define_singleton_method(rb_mDL, "win32_last_error=", rb_dl_win32_set_last_error, 1);
+#endif
+}
diff --git a/ext/dl/test/libtest.def b/ext/dl/test/libtest.def
new file mode 100644
index 0000000000..8ecefc917b
--- /dev/null
+++ b/ext/dl/test/libtest.def
@@ -0,0 +1,28 @@
+EXPORTS
+test_alloc_test_struct
+test_append
+test_arylen
+test_c2i
+test_call_func1
+test_callback1
+test_close
+test_d2f
+test_f2d
+test_fill_test_struct
+test_fill_test_union
+test_gets
+test_i2c
+test_init
+test_isucc
+test_lcc
+test_lsucc
+test_open
+test_strcat
+test_strlen
+test_succ
+test_data_init
+test_data_add
+test_data_aref
+test_set_long_value
+test_get_long_value
+internal_long_value
diff --git a/ext/dl/test/test.c b/ext/dl/test/test.c
new file mode 100644
index 0000000000..7321379390
--- /dev/null
+++ b/ext/dl/test/test.c
@@ -0,0 +1,247 @@
+#include <stdio.h>
+#include <string.h>
+
+static char internal_string[] = "internal_string";
+long internal_long_value = 100;
+
+struct test_struct {
+ char c;
+ long l;
+};
+
+union test_union {
+ char c;
+ int i;
+ long l;
+ void *p;
+};
+
+struct test_data {
+ char name[1024];
+ struct test_data *next;
+};
+
+long
+test_get_long_value()
+{
+ return internal_long_value;
+};
+
+void
+test_set_long_value(long l)
+{
+ internal_long_value = l;
+};
+
+void
+test_fill_test_struct(struct test_struct *ptr, char c, long l)
+{
+ ptr->c = c;
+ ptr->l = l;
+};
+
+void
+test_fill_test_union(union test_union *ptr, long l)
+{
+ ptr->l = l;
+};
+
+struct test_struct *
+test_alloc_test_struct(char c, long l)
+{
+ struct test_struct *data;
+
+ data = (struct test_struct *)malloc(sizeof(struct test_struct));
+ data->c = c;
+ data->l = l;
+
+ return data;
+};
+
+int
+test_c2i(char c)
+{
+ return (int)c;
+};
+
+char
+test_i2c(int i)
+{
+ return (char)i;
+};
+
+long
+test_lcc(char c1, char c2)
+{
+ return (long)(c1 + c2);
+};
+
+double
+test_f2d(float f)
+{
+ double d;
+ d = f;
+ return d;
+};
+
+float
+test_d2f(double d)
+{
+ float f;
+ f = d;
+ return f;
+};
+
+int
+test_strlen(const char *str)
+{
+ return strlen(str);
+};
+
+int
+test_isucc(int i)
+{
+ return (i+1);
+};
+
+long
+test_lsucc(long l)
+{
+ return (l+1);
+};
+
+void
+test_succ(long *l)
+{
+ (*l)++;
+};
+
+char *
+test_strcat(char *str1, const char *str2)
+{
+ return strcat(str1, str2);
+};
+
+int
+test_arylen(char *ary[])
+{
+ int i;
+ for( i=0; ary[i]; i++ ){};
+ return i;
+};
+
+void
+test_append(char *ary[], int len, char *astr)
+{
+ int i;
+ int size1,size2;
+ char *str;
+
+ size2 = strlen(astr);
+
+ for( i=0; i <= len - 1; i++ ){
+ size1 = strlen(ary[i]);
+ str = (char*)malloc(size1 + size2 + 1);
+ strcpy(str, ary[i]);
+ strcat(str, astr);
+ ary[i] = str;
+ };
+};
+
+int
+test_init(int *argc, char **argv[])
+{
+ int i;
+ char s[256];
+
+ for( i=0; i < (*argc); i++ ){
+ sprintf(s, "arg%d", i);
+ if( strcmp((*argv)[i], s) != 0 ){
+ return 1;
+ }
+ }
+ return 0;
+}
+
+FILE *
+test_open(const char *filename, const char *mode)
+{
+ FILE *file;
+ file = fopen(filename,mode);
+ return file;
+};
+
+void
+test_close(FILE *file)
+{
+ fclose(file);
+};
+
+char *
+test_gets(char *s, int size, FILE *f)
+{
+ return fgets(s,size,f);
+};
+
+typedef int callback1_t(int, char *);
+#define CALLBACK_MSG "callback message"
+
+int
+test_callback1(int err, const char *msg)
+{
+ if( strcmp(msg, CALLBACK_MSG) == 0 ){
+ return 1;
+ }
+ else{
+ return 0;
+ }
+}
+
+int
+test_call_func1(callback1_t *func)
+{
+ if( func ){
+ return (*func)(0, CALLBACK_MSG);
+ }
+ else{
+ return 0;
+ }
+}
+
+struct test_data *
+test_data_init()
+{
+ struct test_data *data;
+
+ data = (struct test_data *)malloc(sizeof(struct test_data));
+ data->next = NULL;
+ memset(data->name, 0, 1024);
+
+ return data;
+};
+
+void
+test_data_add(struct test_data *list, const char *name)
+{
+ struct test_data *data;
+
+ data = (struct test_data *)malloc(sizeof(struct test_data));
+ memset(data->name, 0, 1024);
+ strncpy(data->name, name, 1024);
+ data->next = list->next;
+ list->next = data;
+};
+
+struct test_data *
+test_data_aref(struct test_data *list, int i)
+{
+ struct test_data *data;
+ int j;
+
+ for( data = list->next, j=0; data; data = data->next, j++ ){
+ if( i == j ){
+ return data;
+ };
+ };
+ return NULL;
+};
diff --git a/ext/dl/test/test.rb b/ext/dl/test/test.rb
new file mode 100644
index 0000000000..bf8dfc18e3
--- /dev/null
+++ b/ext/dl/test/test.rb
@@ -0,0 +1,306 @@
+# -*- ruby -*-
+
+require 'dl'
+require 'dl/import'
+
+$FAIL = 0
+$TOTAL = 0
+
+def assert(label, ty, *conds)
+ $TOTAL += 1
+ cond = !conds.include?(false)
+ if( cond )
+ printf("succeed in `#{label}'\n")
+ else
+ $FAIL += 1
+ case ty
+ when :may
+ printf("fail in `#{label}' ... expected\n")
+ when :must
+ printf("fail in `#{label}' ... unexpected\n")
+ when :raise
+ raise(RuntimeError, "fail in `#{label}'")
+ end
+ end
+end
+
+def debug(*xs)
+ if( $DEBUG )
+ xs.each{|x|
+ p x
+ }
+ end
+end
+
+print("DLSTACK = #{DL::DLSTACK}\n")
+print("MAX_ARG = #{DL::MAX_ARG}\n")
+print("\n")
+print("DL::FREE = #{DL::FREE.inspect}\n")
+print("\n")
+
+$LIB = nil
+if( !$LIB && File.exist?("libtest.so") )
+ $LIB = "./libtest.so"
+end
+if( !$LIB && File.exist?("test/libtest.so") )
+ $LIB = "./test/libtest.so"
+end
+
+module LIBTest
+ extend DL::Importable
+
+ dlload($LIB)
+ extern "int test_c2i(char)"
+ extern "char test_i2c(int)"
+ extern "long test_lcc(char, char)"
+ extern "double test_f2d(float)"
+ extern "float test_d2f(double)"
+ extern "int test_strlen(char*)"
+ extern "int test_isucc(int)"
+ extern "long test_lsucc(long)"
+ extern "void test_succ(long *)"
+ extern "int test_arylen(int [])"
+ extern "void test_append(char*[], int, char *)"
+end
+
+DL.dlopen($LIB){|h|
+ c2i = h["test_c2i","IC"]
+ debug c2i
+ r,rs = c2i[?a]
+ debug r,rs
+ assert("c2i", :may, r == ?a)
+ assert("extern c2i", :must, r == LIBTest.test_c2i(?a))
+
+ i2c = h["test_i2c","CI"]
+ debug i2c
+ r,rs = i2c[?a]
+ debug r,rs
+ assert("i2c", :may, r == ?a)
+ assert("exern i2c", :must, r == LIBTest.test_i2c(?a))
+
+ lcc = h["test_lcc","LCC"]
+ debug lcc
+ r,rs = lcc[1,2]
+ assert("lcc", :may, r == 3)
+ assert("extern lcc", :must, r == LIBTest.test_lcc(1,2))
+
+ f2d = h["test_f2d","DF"]
+ debug f2d
+ r,rs = f2d[20.001]
+ debug r,rs
+ assert("f2d", :may, r.to_i == 20)
+ assert("extern f2d", :must, r = LIBTest.test_f2d(20.001))
+
+ d2f = h["test_d2f","FD"]
+ debug d2f
+ r,rs = d2f[20.001]
+ debug r,rs
+ assert("d2f", :may, r.to_i == 20)
+ assert("extern d2f", :must, r == LIBTest.test_d2f(20.001))
+
+ strlen = h["test_strlen","IS"]
+ debug strlen
+ r,rs = strlen["0123456789"]
+ debug r,rs
+ assert("strlen", :must, r == 10)
+ assert("extern strlen", :must, r == LIBTest.test_strlen("0123456789"))
+
+ isucc = h["test_isucc","II"]
+ debug isucc
+ r,rs = isucc[2]
+ debug r,rs
+ assert("isucc", :must, r == 3)
+ assert("extern isucc", :must, r == LIBTest.test_isucc(2))
+
+ lsucc = h["test_lsucc","LL"]
+ debug lsucc
+ r,rs = lsucc[10000000]
+ debug r,rs
+ assert("lsucc", :must, r == 10000001)
+ assert("extern lsucc", :must, r == LIBTest.test_lsucc(10000000))
+
+ succ = h["test_succ","0l"]
+ debug succ
+ r,rs = succ[0]
+ debug r,rs
+ assert("succ", :must, rs[0] == 1)
+ l = DL.malloc(DL.sizeof("L"))
+ l.struct!("L",:lval)
+ LIBTest.test_succ(l)
+ assert("extern succ", :must, rs[0] == l[:lval])
+
+ arylen = h["test_arylen","IA"]
+ debug arylen
+ r,rs = arylen[["a","b","c","d",nil]]
+ debug r,rs
+ assert("arylen", :must, r == 4)
+
+ arylen = h["test_arylen","IP"]
+ debug arylen
+ r,rs = arylen[["a","b","c","d",nil]]
+ debug r,rs
+ assert("arylen", :must, r == 4)
+ assert("extern arylen", :must, r == LIBTest.test_arylen(["a","b","c","d",nil]))
+
+ append = h["test_append","0aIS"]
+ debug append
+ r,rs = append[["a","b","c"],3,"x"]
+ debug r,rs
+ assert("append", :must, rs[0].to_a('S',3) == ["ax","bx","cx"])
+
+ LIBTest.test_append(["a","b","c"],3,"x")
+ assert("extern append", :must, rs[0].to_a('S',3) == LIBTest._args_[0].to_a('S',3))
+
+ strcat = h["test_strcat","SsS"]
+ debug strcat
+ r,rs = strcat["abc\0","x"]
+ debug r,rs
+ assert("strcat", :must, rs[0].to_s == "abcx")
+
+ init = h["test_init","IiP"]
+ debug init
+ argc = 3
+ argv = ["arg0","arg1","arg2"].to_ptr
+ r,rs = init[argc, argv.ref]
+ assert("init", :must, r == 0)
+}
+
+
+h = DL.dlopen($LIB)
+
+sym_open = h["test_open", "PSS"]
+sym_gets = h["test_gets", "SsIP"]
+sym_close = h["test_close", "0P"]
+debug sym_open,sym_gets,sym_close
+
+line = "Hello world!\n"
+File.open("tmp.txt", "w"){|f|
+ f.print(line)
+}
+
+fp,rs = sym_open["tmp.txt", "r"]
+if( fp )
+ fp.free = sym_close
+ r,rs = sym_gets[" " * 256, 256, fp]
+ debug r,rs
+ assert("open,gets", :must, rs[0] == line)
+ ObjectSpace.define_finalizer(fp) {File.unlink("tmp.txt")}
+ fp = nil
+else
+ assert("open,gets", :must, line == nil)
+ File.unlink("tmp.txt")
+end
+
+
+callback1 = h["test_callback1"]
+debug callback1
+r,rs = h["test_call_func1", "IP"][callback1]
+debug r,rs
+assert("callback1", :must, r == 1)
+
+
+callback2 = DL.callback("LLP"){|num,ptr|
+ msg = ptr.to_s
+ if( msg == "callback message" )
+ 2
+ else
+ 0
+ end
+}
+debug callback2
+r,rs = h["test_call_func1", "IP"][callback2]
+debug r,rs
+assert("callback2", :must, r == 2)
+DL.remove_callback(callback2)
+
+ptr = DL.malloc(DL.sizeof('CL'))
+ptr.struct!("CL", :c, :l)
+ptr["c"] = 0
+ptr["l"] = 0
+r,rs = h["test_fill_test_struct","0PIL"][ptr,100,1000]
+debug r,rs
+assert("fill_test_struct", :must, ptr["c"] == 100, ptr["l"] == 1000)
+assert("fill_test_struct", :must, ptr[:c] == 100, ptr[:l] == 1000) unless (Fixnum === :-)
+
+
+r,rs = h["test_alloc_test_struct", "PIL"][100,200]
+r.free = DL::FREE
+r.struct!("CL", :c, :l)
+assert("alloc_test_struct", :must, r["c"] == 100, r["l"] == 200)
+assert("alloc_test_struct", :must, r[:c] == 100, r[:l] == 200) unless (Fixnum === :-)
+
+ptr = h["test_strlen"]
+sym1 = DL::Symbol.new(ptr,"foo","0")
+sym2 = h["test_strlen","LS"]
+assert("Symbol.new", :must, ptr == sym1.to_ptr, sym1.to_ptr == sym2.to_ptr)
+
+set_val = h["test_set_long_value","0"]
+get_val = h["test_get_long_value","L"]
+lval = get_val[][0]
+ptr = h["internal_long_value"]
+ptr.struct!("L", :l)
+assert("get value", :must, ptr["l"] == lval)
+assert("get value", :must, ptr[:l] == lval) unless (Fixnum === :-)
+ptr["l"] = 200
+lval = get_val[][0]
+assert("set value", :must, ptr["l"] == lval)
+assert("set value", :must, ptr[:l] == lval) unless (Fixnum === :-)
+
+
+data_init = h["test_data_init", "P"]
+data_add = h["test_data_add", "0PS"]
+data_aref = h["test_data_aref", "PPI"]
+r,rs = data_init[]
+ptr = r
+data_add[ptr, "name1"]
+data_add[ptr, "name2"]
+data_add[ptr, "name3"]
+
+r,rs = data_aref[ptr, 1]
+ptr = r
+ptr.struct!("C1024P", :name, :next)
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name2")
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name2") unless (Fixnum === :-)
+
+ptr = ptr["next"]
+ptr.struct!("C1024P", :name, :next)
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name1")
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name1") unless (Fixnum === :-)
+
+GC.start
+
+ptr = DL::malloc(32)
+ptr.struct!("CHIL", "c", "h", "i", "l")
+ptr["c"] = 1
+ptr["h"] = 2
+ptr["i"] = 3
+ptr["l"] = 4
+assert("struct!", :must,
+ ptr["c"] == 1 &&
+ ptr["h"] == 2 &&
+ ptr["i"] == 3 &&
+ ptr["l"] == 4)
+
+ptr = DL::malloc(DL::sizeof("IP"))
+ptr.struct!("IP", "n", "ptr")
+ptr["n"] = 10
+ptr["ptr"] = nil
+assert("struct!", :must, ptr["n"] == 10 && ptr["ptr"] == nil)
+
+ptr = DL::malloc(16)
+ptr.struct!("CICI", "c1", "i1", "c2", "i2")
+ptr["c1"] = 0xf1
+ptr["c2"] = 0xf2
+c1 = [ptr["c1"]].pack("c").unpack("C")[0]
+c2 = [ptr["c2"]].pack("c").unpack("C")[0]
+assert("struct!", :must,
+ c1 == 0xf1 &&
+ c2 == 0xf2)
+
+
+GC.start
+printf("fail/total = #{$FAIL}/#{$TOTAL}\n")
diff --git a/ext/dl/test/test_all.rb b/ext/dl/test/test_all.rb
deleted file mode 100644
index fb1f4939f9..0000000000
--- a/ext/dl/test/test_all.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'test_base'
-require 'dl/import'
-
-require 'test_dl2'
-require 'test_func'
-require 'test_import'
-
-case RUBY_PLATFORM
-when /cygwin/, /mingw32/, /mswin32/, /bccwin32/
- require 'test_win32'
-end
diff --git a/ext/dl/test/test_base.rb b/ext/dl/test/test_base.rb
deleted file mode 100644
index fc72db4e5e..0000000000
--- a/ext/dl/test/test_base.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'test/unit'
-require 'dl'
-
-case RUBY_PLATFORM
-when /cygwin/
- LIBC_SO = "cygwin1.dll"
- LIBM_SO = "cygwin1.dll"
-when /linux/
- LIBC_SO = "/lib/libc.so.6"
- LIBM_SO = "/lib/libm.so.6"
-when /mingw/, /mswin32/
- LIBC_SO = "msvcrt.dll"
- LIBM_SO = "msvcrt.dll"
-else
- LIBC_SO = ARGV[0]
- LIBM_SO = ARGV[1]
- if( !(LIBC_SO && LIBM_SO) )
- $stderr.puts("#{$0} <libc> <libm>")
- exit
- end
-end
-
-module DL
- class TestBase < Test::Unit::TestCase
- include Math
- include DL
-
- def setup
- @libc = dlopen(LIBC_SO)
- @libm = dlopen(LIBM_SO)
- end
-
- def assert_match(expected, actual, message="")
- assert(expected === actual, message)
- end
-
- def assert_positive(actual)
- assert(actual > 0)
- end
-
- def assert_zero(actual)
- assert(actual == 0)
- end
-
- def assert_negative(actual)
- assert(actual < 0)
- end
-
- def test_empty()
- end
- end
-end
diff --git a/ext/dl/test/test_dl2.rb b/ext/dl/test/test_dl2.rb
deleted file mode 100644
index 8c1f3e71b4..0000000000
--- a/ext/dl/test/test_dl2.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-require 'test_base.rb'
-require 'dl/callback'
-
-module DL
-class TestDL < TestBase
- def test_call_int()
- cfunc = CFunc.new(@libc['atoi'], TYPE_INT, 'atoi')
- x = cfunc.call(["100"].pack("p").unpack("l!*"))
- assert_equal(100, x)
-
- cfunc = CFunc.new(@libc['atoi'], TYPE_INT, 'atoi')
- x = cfunc.call(["-100"].pack("p").unpack("l!*"))
- assert_equal(-100, x)
- end
-
- def test_call_long()
- cfunc = CFunc.new(@libc['atol'], TYPE_LONG, 'atol')
- x = cfunc.call(["100"].pack("p").unpack("l!*"))
- assert_equal(100, x)
- cfunc = CFunc.new(@libc['atol'], TYPE_LONG, 'atol')
- x = cfunc.call(["-100"].pack("p").unpack("l!*"))
- assert_equal(-100, x)
- end
-
- def test_call_double()
- cfunc = CFunc.new(@libc['atof'], TYPE_DOUBLE, 'atof')
- x = cfunc.call(["0.1"].pack("p").unpack("l!*"))
- assert_match(0.09..0.11, x)
-
- cfunc = CFunc.new(@libc['atof'], TYPE_DOUBLE, 'atof')
- x = cfunc.call(["-0.1"].pack("p").unpack("l!*"))
- assert_match(-0.11 .. -0.09, x)
- end
-
- def test_sin()
- cfunc = CFunc.new(@libm['sin'], TYPE_DOUBLE, 'sin')
- x = cfunc.call([3.14/2].pack("d").unpack("l!*"))
- assert_equal(x, Math.sin(3.14/2))
-
- cfunc = CFunc.new(@libm['sin'], TYPE_DOUBLE, 'sin')
- x = cfunc.call([-3.14/2].pack("d").unpack("l!*"))
- assert_equal(Math.sin(-3.14/2), x)
- end
-
- def test_strlen()
- cfunc = CFunc.new(@libc['strlen'], TYPE_INT, 'strlen')
- x = cfunc.call(["abc"].pack("p").unpack("l!*"))
- assert_equal("abc".size, x)
- end
-
- def test_strcpy()
- buff = "xxxx"
- str = "abc"
- cfunc = CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy')
- x = cfunc.call([buff,str].pack("pp").unpack("l!*"))
- assert_equal("abc\0", buff)
- assert_equal("abc\0", CPtr.new(x).to_s(4))
-
- buff = "xxxx"
- str = "abc"
- cfunc = CFunc.new(@libc['strncpy'], TYPE_VOIDP, 'strncpy')
- x = cfunc.call([buff,str,3].pack("ppi").unpack("l!*"))
- assert_equal("abcx", buff)
- assert_equal("abcx", CPtr.new(x).to_s(4))
-
- ptr = CPtr.malloc(4)
- str = "abc"
- cfunc = CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy')
- x = cfunc.call([ptr.to_i,str].pack("lp").unpack("l!*"))
- assert_equal("abc\0", ptr[0,4])
- assert_equal("abc\0", CPtr.new(x).to_s(4))
- end
-
- def test_callback()
- buff = "foobarbaz"
- cb = set_callback(TYPE_INT,2){|x,y| CPtr.new(x)[0] <=> CPtr.new(y)[0]}
- cfunc = CFunc.new(@libc['qsort'], TYPE_VOID, 'qsort')
- cfunc.call([buff, buff.size, 1, cb].pack("pI!I!L!").unpack("l!*"))
- assert_equal('aabbfoorz', buff)
- end
-
- def test_dlwrap()
- ary = [0,1,2,4,5]
- addr = dlwrap(ary)
- ary2 = dlunwrap(addr)
- assert_equal(ary, ary2)
- end
-
- def test_cptr()
- check = Proc.new{|str,ptr|
- assert_equal(str.size(), ptr.size())
- assert_equal(str, ptr.to_s())
- assert_equal(str[0,2], ptr.to_s(2))
- assert_equal(str[0,2], ptr[0,2])
- assert_equal(str[1,2], ptr[1,2])
- assert_equal(str[1,0], ptr[1,0])
- assert_equal(str[0].ord, ptr[0])
- assert_equal(str[1].ord, ptr[1])
- }
- str = 'abc'
- ptr = CPtr[str]
- check.call(str, ptr)
- str[0] = "c"
- ptr[0] = "c".ord
- check.call(str, ptr)
- str[0,2] = "aa"
- ptr[0,2] = "aa"
- check.call(str, ptr)
- end
-end
-end # module DL
diff --git a/ext/dl/test/test_func.rb b/ext/dl/test/test_func.rb
deleted file mode 100644
index 64a32d9565..0000000000
--- a/ext/dl/test/test_func.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'test_base'
-require 'dl/func'
-
-module DL
- class TestFunc < TestBase
- def test_strcpy()
- f = Function.new(CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy'),
- [TYPE_VOIDP, TYPE_VOIDP])
- buff = "000"
- str = f.call(buff, "123")
- assert_equal("123", buff)
- assert_equal("123", str.to_s)
- end
-
- def test_isdigit()
- f = Function.new(CFunc.new(@libc['isdigit'], TYPE_INT, 'isdigit'),
- [TYPE_INT])
- r1 = f.call(?1)
- r2 = f.call(?2)
- rr = f.call(?r)
- assert_positive(r1)
- assert_positive(r2)
- assert_zero(rr)
- end
-
- def test_atof()
- f = Function.new(CFunc.new(@libc['atof'], TYPE_FLOAT, 'atof'),
- [TYPE_VOIDP])
- r = f.call("12.34")
- assert_match(12.00..13.00, r)
- end
-
- def test_strtod()
- f = Function.new(CFunc.new(@libc['strtod'], TYPE_DOUBLE, 'strtod'),
- [TYPE_VOIDP, TYPE_VOIDP])
- buff1 = "12.34"
- buff2 = " "
- r = f.call(buff1, buff2)
- assert_match(12.00..13.00, r)
- end
-
- def test_qsort1()
- cb = Function.new(CFunc.new(0, TYPE_INT, '<callback>qsort'),
- [TYPE_VOIDP, TYPE_VOIDP]){|x,y| CPtr.new(x)[0] <=> CPtr.new(y)[0]}
- qsort = Function.new(CFunc.new(@libc['qsort'], TYPE_VOID, 'qsort'),
- [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP])
- buff = "9341"
- qsort.call(buff, buff.size, 1, cb)
- assert_equal("1349", buff)
- end
-
- def test_qsort2()
- cb = TempFunction.new(CFunc.new(0, TYPE_INT, '<callback>qsort'),
- [TYPE_VOIDP, TYPE_VOIDP])
- qsort = Function.new(CFunc.new(@libc['qsort'], TYPE_VOID, 'qsort'),
- [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP])
- buff = "9341"
- qsort.call(buff, buff.size, 1, cb){|x,y| CPtr.new(x)[0] <=> CPtr.new(y)[0]}
- assert_equal("1349", buff)
- end
- end
-end
diff --git a/ext/dl/test/test_import.rb b/ext/dl/test/test_import.rb
deleted file mode 100644
index f0694637eb..0000000000
--- a/ext/dl/test/test_import.rb
+++ /dev/null
@@ -1,154 +0,0 @@
-require 'test_base'
-require 'dl/import'
-
-module DL
- module LIBC
- extend Importer
- dlload LIBC_SO, LIBM_SO
-
- typealias 'string', 'char*'
- typealias 'FILE*', 'void*'
-
- extern "void *strcpy(char*, char*)"
- extern "int isdigit(int)"
- extern "float atof(string)"
- extern "unsigned long strtoul(char*, char **, int)"
- extern "int qsort(void*, int, int, void*)"
- extern "void fprintf(FILE*, char*)"
- extern "int gettimeofday(timeval*, timezone*)" rescue nil
-
- QsortCallback = bind("void *qsort_callback(void*, void*)", :temp)
- BoundQsortCallback = bind("void *qsort_callback(void*, void*)"){|ptr1,ptr2| ptr1[0] <=> ptr2[0]}
- Timeval = struct [
- "long tv_sec",
- "long tv_usec",
- ]
- Timezone = struct [
- "int tz_minuteswest",
- "int tz_dsttime",
- ]
- MyStruct = struct [
- "short num[5]",
- "char c",
- "unsigned char buff[7]",
- ]
-
- CallCallback = bind("void call_callback(void*, void*)"){|ptr1, ptr2|
- f = Function.new(CFunc.new(ptr1.to_i, DL::TYPE_VOID, "<anonymous>"), [TYPE_VOIDP])
- f.call(ptr2)
- }
- CarriedFunction = bind("void callback_function(void*)", :carried, 0)
- end
-
- class TestImport < TestBase
- def test_malloc()
- s1 = LIBC::Timeval.malloc()
- s2 = LIBC::Timeval.malloc()
- assert_not_equal(s1.to_ptr.to_i, s2.to_ptr.to_i)
- end
-
- def test_sizeof()
- assert_equal(DL::SIZEOF_VOIDP, LIBC.sizeof("FILE*"))
- assert_equal(LIBC::MyStruct.size(), LIBC.sizeof(LIBC::MyStruct))
- end
-
- def test_unsigned_result()
- d = (2 ** 31) + 1
-
- r = LIBC.strtoul(d.to_s, 0, 0)
- assert_equal(d, r)
- end
-
- def test_io()
- if( RUBY_PLATFORM != DL::BUILD_RUBY_PLATFORM )
- return
- end
- io_in,io_out = IO.pipe()
- LIBC.fprintf(io_out, "hello")
- io_out.flush()
- io_out.close()
- str = io_in.read()
- io_in.close()
- assert_equal("hello", str)
- end
-
- def test_value()
- i = LIBC.value('int', 2)
- assert_equal(2, i.value)
-
- d = LIBC.value('double', 2.0)
- assert_equal(2.0, d.value)
-
- ary = LIBC.value('int[3]', [0,1,2])
- assert_equal([0,1,2], ary.value)
- end
-
- def test_carried_function()
- data1 = "data"
- data2 = nil
- LIBC.call_callback(LIBC::CarriedFunction, LIBC::CarriedFunction.create_carrier(data1)){|d|
- data2 = d
- }
- assert_equal(data1, data2)
- end
-
- def test_struct()
- s = LIBC::MyStruct.malloc()
- s.num = [0,1,2,3,4]
- s.c = ?a
- s.buff = "012345\377"
- assert_equal([0,1,2,3,4], s.num)
- assert_equal(?a, s.c)
- assert_equal([?0,?1,?2,?3,?4,?5,?\377], s.buff)
- end
-
- def test_gettimeofday()
- if( defined?(LIBC.gettimeofday) )
- timeval = LIBC::Timeval.malloc()
- timezone = LIBC::Timezone.malloc()
- LIBC.gettimeofday(timeval, timezone)
- cur = Time.now()
- assert(cur.to_i - 2 <= timeval.tv_sec && timeval.tv_sec <= cur.to_i)
- end
- end
-
- def test_strcpy()
- buff = "000"
- str = LIBC.strcpy(buff, "123")
- assert_equal("123", buff)
- assert_equal("123", str.to_s)
- end
-
- def test_isdigit()
- r1 = LIBC.isdigit(?1)
- r2 = LIBC.isdigit(?2)
- rr = LIBC.isdigit(?r)
- assert_positive(r1)
- assert_positive(r2)
- assert_zero(rr)
- end
-
- def test_atof()
- r = LIBC.atof("12.34")
- assert_match(12.00..13.00, r)
- end
-
- def test_strtod()
- f = Function.new(CFunc.new(@libc['strtod'], TYPE_DOUBLE, 'strtod'),
- [TYPE_VOIDP, TYPE_VOIDP])
- buff1 = "12.34"
- buff2 = " "
- r = f.call(buff1, buff2)
- assert_match(12.00..13.00, r)
- end
-
- def test_qsort()
- buff = "9341"
- LIBC.qsort(buff, buff.size, 1, LIBC::QsortCallback){|ptr1,ptr2| ptr1[0] <=> ptr2[0]}
- assert_equal("1349", buff)
- buff = "9341"
- LIBC.qsort(buff, buff.size, 1, LIBC::BoundQsortCallback)
- assert_equal("1349", buff)
- end
- end
-end
diff --git a/ext/dl/test/test_win32.rb b/ext/dl/test/test_win32.rb
deleted file mode 100644
index b2210287a1..0000000000
--- a/ext/dl/test/test_win32.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'test_base'
-require 'dl/import'
-require 'dl/types'
-
-module Win32API
- extend DL::Importer
-
- dlload "kernel32.dll"
-
- include DL::Win32Types
-
- OSVERSIONINFO = struct [
- "DWORD dwOSVersionInfoSize",
- "DWORD dwMajorVersion",
- "DWORD dwMinorVersion",
- "DWORD dwBuildNumber",
- "DWORD dwPlatformId",
- "UCHAR szCSDVersion[128]",
- ]
-
- typealias "POSVERSIONINFO", "OSVERSIONINFO*"
-
- extern "BOOL GetVersionEx(POSVERSIONINFO)", :stdcall
-
- def get_version_ex()
- ptr = OSVERSIONINFO.malloc()
- ptr.dwOSVersionInfoSize = OSVERSIONINFO.size
- ret = GetVersionEx(ptr)
- if( ret )
- ptr
- else
- nil
- end
- end
- module_function :get_version_ex
-end
-
-module DL
-class TestWin32 < TestBase
- def test_version()
- platform = Win32API.get_version_ex().dwPlatformId
- case ENV['OS']
- when 'Windows_NT'
- expect = 2
- when /Windows.+/
- expect = 1
- else
- expect = 0
- end
- assert_equal(expect, platform)
- end
-end
-end
diff --git a/ext/dl/type.rb b/ext/dl/type.rb
new file mode 100644
index 0000000000..804420c395
--- /dev/null
+++ b/ext/dl/type.rb
@@ -0,0 +1,115 @@
+# example:
+# DLTYPE[INT][:rb2c]["arg0"] => "NUM2INT(arg0)"
+# DLTYPE[DOUBLE][:c2rb]["r"] => "rb_float_new(r)"
+
+DLTYPE = {
+ VOID = 0x00 => {
+ :name => 'VOID',
+ :rb2c => nil,
+ :c2rb => nil,
+ :ctype => "void",
+ :stmem => "v",
+ :sym => true,
+ :cb => true,
+ },
+ CHAR = 0x01 => {
+ :name => 'CHAR',
+ :rb2c => proc{|x| "NUM2CHR(#{x})"},
+ :c2rb => proc{|x| "CHR2FIX(#{x})"},
+ :ctype => "char",
+ :stmem => "c",
+ :sym => false,
+ :cb => false,
+ },
+ SHORT = 0x02 => {
+ :name => 'SHORT',
+ :rb2c => proc{|x| "FIX2INT(#{x})"},
+ :c2rb => proc{|x| "INT2FIX(#{x})"},
+ :ctype => "short",
+ :stmem => "h",
+ :sym => false,
+ :cb => false,
+ },
+ INT = 0x03 => {
+ :name => 'INT',
+ :rb2c => proc{|x| "NUM2INT(#{x})"},
+ :c2rb => proc{|x| "INT2NUM(#{x})"},
+ :ctype => "int",
+ :stmem => "i",
+ :sym => true,
+ :cb => false,
+ },
+ LONG = 0x04 => {
+ :name => 'LONG',
+ :rb2c => proc{|x| "NUM2INT(#{x})"},
+ :c2rb => proc{|x| "INT2NUM(#{x})"},
+ :ctype => "long",
+ :stmem => "l",
+ :sym => true,
+ :cb => true,
+ },
+ FLOAT = 0x05 => {
+ :name => 'FLOAT',
+ :rb2c => proc{|x| "(float)(RFLOAT(#{x})->value)"},
+ :c2rb => proc{|x| "rb_float_new((double)#{x})"},
+ :ctype => "float",
+ :stmem => "f",
+ :sym => false,
+ :cb => false,
+ },
+ DOUBLE = 0x06 => {
+ :name => 'DOUBLE',
+ :rb2c => proc{|x| "RFLOAT(#{x})->value"},
+ :c2rb => proc{|x| "rb_float_new(#{x})"},
+ :ctype => "double",
+ :stmem => "d",
+ :sym => true,
+ :cb => true,
+ },
+ VOIDP = 0x07 => {
+ :name => 'VOIDP',
+ :rb2c => proc{|x| "rb_dlptr2cptr(#{x})"},
+ :c2rb => proc{|x| "rb_dlptr_new(#{x},sizeof(void*),0)"},
+ :ctype => "void *",
+ :stmem => "p",
+ :sym => true,
+ :cb => true,
+ },
+}
+
+def tpush(t, x)
+ (t << 3)|x
+end
+
+def tget(t, i)
+ (t & (0x07 << (i * 3))) >> (i * 3)
+end
+
+def types2num(types)
+ res = 0x00
+ r = types.reverse
+ r.each{|t|
+ res = tpush(res,t)
+ }
+ res
+end
+
+def num2types(num)
+ ts = []
+ i = 0
+ t = tget(num,i)
+ while( (t != VOID && i > 0) || (i == 0) )
+ ts.push(DLTYPE[t][:ctype])
+ i += 1
+ t = tget(num,i)
+ end
+ ts
+end
+
+def types2ctypes(types)
+ res = []
+ types.each{|t|
+ res.push(DLTYPE[t][:ctype])
+ }
+ res
+end
diff --git a/ext/dl/win32/extconf.rb b/ext/dl/win32/extconf.rb
deleted file mode 100644
index a72ca49c06..0000000000
--- a/ext/dl/win32/extconf.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-if compiled?('dl') and $mswin||$bccwin||$mingw||$cygwin
- create_makefile('win32')
-end
diff --git a/ext/dl/win32/lib/Win32API.rb b/ext/dl/win32/lib/Win32API.rb
deleted file mode 100644
index b642e0c8fe..0000000000
--- a/ext/dl/win32/lib/Win32API.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- ruby -*-
-# for backward compatibility
-warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use dl directly instead" if $VERBOSE
-
-require 'dl'
-
-class Win32API
- DLL = {}
- TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
-
- def initialize(dllname, func, import, export = "0")
- @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
- handle = DLL[dllname] ||= DL.dlopen(dllname)
- @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
- end
-
- def call(*args)
- import = @proto.split("")
- args.each_with_index do |x, i|
- args[i], = [x == 0 ? nil : x].pack("p").unpack("l!*") if import[i] == "S"
- args[i], = [x].pack("I").unpack("i") if import[i] == "I"
- end
- ret, = @func.call(args)
- return ret || 0
- end
-
- alias Call call
-end
diff --git a/ext/dl/win32/lib/win32/registry.rb b/ext/dl/win32/lib/win32/registry.rb
deleted file mode 100644
index 2671551a33..0000000000
--- a/ext/dl/win32/lib/win32/registry.rb
+++ /dev/null
@@ -1,831 +0,0 @@
-=begin
-= Win32 Registry I/F
-win32/registry is registry accessor library for Win32 platform.
-It uses Win32API to call Win32 Registry APIs.
-
-== example
- Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
- value = reg['foo'] # read a value
- value = reg['foo', Win32::Registry::REG_SZ] # read a value with type
- type, value = reg.read('foo') # read a value
- reg['foo'] = 'bar' # write a value
- reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type
- reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
-
- reg.each_value { |name, type, data| ... } # Enumerate values
- reg.each_key { |key, wtime| ... } # Enumerate subkeys
-
- reg.delete_value(name) # Delete a value
- reg.delete_key(name) # Delete a subkey
- reg.delete_key(name, true) # Delete a subkey recursively
- end
-
-= Reference
-
-== Win32::Registry class
-
-=== including modules
-
-* Enumerable
-* Registry::Constants
-
-=== class methods
---- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
---- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... }
- Open the registry key ((|subkey|)) under ((|key|)).
- ((|key|)) is Win32::Registry object of parent key.
- You can use predefined key HKEY_* (see ((<constants>)))
-
- ((|desired|)) and ((|opt|)) is access mask and key option.
- For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp>)).
-
- If block is given, the key is closed automatically.
-
---- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
---- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... }
- Create or open the registry key ((|subkey|)) under ((|key|)).
- You can use predefined key HKEY_* (see ((<constants>)))
-
- If subkey is already exists, key is opened and Registry#((<created?>))
- method will return false.
-
- If block is given, the key is closed automatically.
-
---- Registry.expand_environ(str)
- Replace (({%\w+%})) into the environment value of ((|str|)).
- This method is used for REG_EXPAND_SZ.
-
- For detail, see ((<ExpandEnvironmentStrings|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp>)) Win32 API.
-
---- Registry.type2name(type)
- Convert registry type value to readable string.
-
---- Registry.wtime2time(wtime)
- Convert 64-bit FILETIME integer into Time object.
-
---- Registry.time2wtime(time)
- Convert Time object or Integer object into 64-bit FILETIME.
-
-=== instance methods
---- open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
- Same as (({Win32::((<Registry.open>))(self, subkey, desired, opt)}))
-
---- create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
- Same as (({Win32::((<Registry.create>))(self, subkey, desired, opt)}))
-
---- close
- Close key.
-
- After closed, most method raises error.
-
---- read(name, *rtype)
- Read a registry value named ((|name|)) and return array of
- [ ((|type|)), ((|data|)) ].
- When name is nil, the `default' value is read.
-
- ((|type|)) is value type. (see ((<Win32::Registry::Constants module>)))
- ((|data|)) is value data, its class is:
- :REG_SZ, REG_EXPAND_SZ
- String
- :REG_MULTI_SZ
- Array of String
- :REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD
- Integer
- :REG_BINARY
- String (contains binary data)
-
- When ((|rtype|)) is specified, the value type must be included by
- ((|rtype|)) array, or TypeError is raised.
-
---- self[name, *rtype]
- Read a registry value named ((|name|)) and return its value data.
- The class of value is same as ((<read>)) method returns.
-
- If the value type is REG_EXPAND_SZ, returns value data whose environment
- variables are replaced.
- If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD,
- REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.
-
- The meaning of ((|rtype|)) is same as ((<read>)) method.
-
---- read_s(name)
---- read_i(name)
---- read_bin(name)
- Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
- registry value named ((|name|)).
-
- If the values type does not match, TypeError is raised.
-
---- read_s_expand(name)
- Read a REG_SZ or REG_EXPAND_SZ registry value named ((|name|)).
-
- If the value type is REG_EXPAND_SZ, environment variables are replaced.
- Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.
-
---- write(name, type, data)
- Write ((|data|)) to a registry value named ((|name|)).
- When name is nil, write to the `default' value.
-
- ((|type|)) is type value. (see ((<Registry::Constants module>)))
- Class of ((|data|)) must be same as which ((<read>))
- method returns.
-
---- self[name, wtype = nil] = value
- Write ((|value|)) to a registry value named ((|name|)).
-
- If ((|wtype|)) is specified, the value type is it.
- Otherwise, the value type is depend on class of ((|value|)):
- :Integer
- REG_DWORD
- :String
- REG_SZ
- :Array
- REG_MULTI_SZ
-
---- write_s(name, value)
---- write_i(name, value)
---- write_bin(name, value)
- Write ((|value|)) to a registry value named ((|name|)).
-
- The value type is REG_SZ(write_s), REG_DWORD(write_i), or
- REG_BINARY(write_bin).
-
---- each { |name, type, value| ... }
---- each_value { |name, type, value| ... }
- Enumerate values.
-
---- each_key { |subkey, wtime| ... }
- Enumerate subkeys.
-
- ((|subkey|)) is String which contains name of subkey.
- ((|wtime|)) is last write time as FILETIME (64-bit integer).
- (see ((<Registry.wtime2time>)))
-
---- delete(name)
---- delete_value(name)
- Delete a registry value named ((|name|)).
- We can not delete the `default' value.
-
---- delete_key(name, recursive = false)
- Delete a subkey named ((|name|)) and all its values.
-
- If ((|recursive|)) is false, the subkey must not have subkeys.
- Otherwise, this method deletes all subkeys and values recursively.
-
---- flush
- Write all the attributes into the registry file.
-
---- created?
- Returns if key is created ((*newly*)).
- (see ((<Registry.create>)))
-
---- open?
- Returns if key is not closed.
-
---- hkey
- Returns key handle value.
-
---- parent
- Win32::Registry object of parent key, or nil if predefeined key.
-
---- keyname
- Same as ((|subkey|)) value of ((<Registry.open>)) or
- ((<Registry.create>)) method.
-
---- disposition
- Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY).
-
---- name
---- to_s
- Full path of key such as (({'HKEY_CURRENT_USER\SOFTWARE\foo\bar'})).
-
---- info
- Returns key information as Array of:
- :num_keys
- The number of subkeys.
- :max_key_length
- Maximum length of name of subkeys.
- :num_values
- The number of values.
- :max_value_name_length
- Maximum length of name of values.
- :max_value_length
- Maximum length of value of values.
- :descriptor_length
- Length of security descriptor.
- :wtime
- Last write time as FILETIME(64-bit integer)
-
- For detail, see ((<RegQueryInfoKey|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp>)) Win32 API.
-
---- num_keys
---- max_key_length
---- num_values
---- max_value_name_length
---- max_value_length
---- descriptor_length
---- wtime
- Returns an item of key information.
-
-=== constants
---- HKEY_CLASSES_ROOT
---- HKEY_CURRENT_USER
---- HKEY_LOCAL_MACHINE
---- HKEY_PERFORMANCE_DATA
---- HKEY_CURRENT_CONFIG
---- HKEY_DYN_DATA
- Win32::Registry object whose key is predefined key.
- For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp>)).
-
-== Win32::Registry::Constants module
-
-For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp>)).
-
---- HKEY_*
- Predefined key ((*handle*)).
- These are Integer, not Win32::Registry.
-
---- REG_*
- Registry value type.
-
---- KEY_*
- Security access mask.
-
---- KEY_OPTIONS_*
- Key options.
-
---- REG_CREATED_NEW_KEY
---- REG_OPENED_EXISTING_KEY
- If the key is created newly or opened existing key.
- See also Registry#((<disposition>)) method.
-
-=end
-
-require 'Win32API'
-
-module Win32
- class Registry
- module Constants
- HKEY_CLASSES_ROOT = 0x80000000
- HKEY_CURRENT_USER = 0x80000001
- HKEY_LOCAL_MACHINE = 0x80000002
- HKEY_USERS = 0x80000003
- HKEY_PERFORMANCE_DATA = 0x80000004
- HKEY_PERFORMANCE_TEXT = 0x80000050
- HKEY_PERFORMANCE_NLSTEXT = 0x80000060
- HKEY_CURRENT_CONFIG = 0x80000005
- HKEY_DYN_DATA = 0x80000006
-
- REG_NONE = 0
- REG_SZ = 1
- REG_EXPAND_SZ = 2
- REG_BINARY = 3
- REG_DWORD = 4
- REG_DWORD_LITTLE_ENDIAN = 4
- REG_DWORD_BIG_ENDIAN = 5
- REG_LINK = 6
- REG_MULTI_SZ = 7
- REG_RESOURCE_LIST = 8
- REG_FULL_RESOURCE_DESCRIPTOR = 9
- REG_RESOURCE_REQUIREMENTS_LIST = 10
- REG_QWORD = 11
- REG_QWORD_LITTLE_ENDIAN = 11
-
- STANDARD_RIGHTS_READ = 0x00020000
- STANDARD_RIGHTS_WRITE = 0x00020000
- KEY_QUERY_VALUE = 0x0001
- KEY_SET_VALUE = 0x0002
- KEY_CREATE_SUB_KEY = 0x0004
- KEY_ENUMERATE_SUB_KEYS = 0x0008
- KEY_NOTIFY = 0x0010
- KEY_CREATE_LINK = 0x0020
- KEY_READ = STANDARD_RIGHTS_READ |
- KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
- KEY_WRITE = STANDARD_RIGHTS_WRITE |
- KEY_SET_VALUE | KEY_CREATE_SUB_KEY
- KEY_EXECUTE = KEY_READ
- KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
-
- REG_OPTION_RESERVED = 0x0000
- REG_OPTION_NON_VOLATILE = 0x0000
- REG_OPTION_VOLATILE = 0x0001
- REG_OPTION_CREATE_LINK = 0x0002
- REG_OPTION_BACKUP_RESTORE = 0x0004
- REG_OPTION_OPEN_LINK = 0x0008
- REG_LEGAL_OPTION = REG_OPTION_RESERVED |
- REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
- REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
-
- REG_CREATED_NEW_KEY = 1
- REG_OPENED_EXISTING_KEY = 2
-
- REG_WHOLE_HIVE_VOLATILE = 0x0001
- REG_REFRESH_HIVE = 0x0002
- REG_NO_LAZY_FLUSH = 0x0004
- REG_FORCE_RESTORE = 0x0008
-
- MAX_KEY_LENGTH = 514
- MAX_VALUE_LENGTH = 32768
- end
- include Constants
- include Enumerable
-
- #
- # Error
- #
- class Error < ::StandardError
- FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
- def initialize(code)
- @code = code
- msg = "\0" * 1024
- len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
- super msg[0, len].tr("\r", '').chomp
- end
- attr_reader :code
- end
-
- #
- # Predefined Keys
- #
- class PredefinedKey < Registry
- def initialize(hkey, keyname)
- @hkey = hkey
- @parent = nil
- @keyname = keyname
- @disposition = REG_OPENED_EXISTING_KEY
- end
-
- # Predefined keys cannot be closed
- def close
- raise Error.new(5) ## ERROR_ACCESS_DENIED
- end
-
- # Fake class for Registry#open, Registry#create
- def class
- Registry
- end
-
- # Make all
- Constants.constants.grep(/^HKEY_/) do |c|
- Registry.const_set c, new(Constants.const_get(c), c)
- end
- end
-
- #
- # Win32 APIs
- #
- module API
- [
- %w/RegOpenKeyExA LPLLP L/,
- %w/RegCreateKeyExA LPLLLLPPP L/,
- %w/RegEnumValueA LLPPPPPP L/,
- %w/RegEnumKeyExA LLPPLLLP L/,
- %w/RegQueryValueExA LPLPPP L/,
- %w/RegSetValueExA LPLLPL L/,
- %w/RegDeleteValue LP L/,
- %w/RegDeleteKey LP L/,
- %w/RegFlushKey L L/,
- %w/RegCloseKey L L/,
- %w/RegQueryInfoKey LPPPPPPPPPPP L/,
- ].each do |fn|
- const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
- end
-
- module_function
-
- def check(result)
- raise Error, result, caller(2) if result != 0
- end
-
- def packdw(dw)
- [dw].pack('V')
- end
-
- def unpackdw(dw)
- dw += [0].pack('V')
- dw.unpack('V')[0]
- end
-
- def packqw(qw)
- [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
- end
-
- def unpackqw(qw)
- qw = qw.unpack('VV')
- (qw[1] << 32) | qw[0]
- end
-
- def OpenKey(hkey, name, opt, desired)
- result = packdw(0)
- check RegOpenKeyExA.call(hkey, name, opt, desired, result)
- unpackdw(result)
- end
-
- def CreateKey(hkey, name, opt, desired)
- result = packdw(0)
- disp = packdw(0)
- check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
- 0, result, disp)
- [ unpackdw(result), unpackdw(disp) ]
- end
-
- def EnumValue(hkey, index)
- name = ' ' * Constants::MAX_KEY_LENGTH
- size = packdw(Constants::MAX_KEY_LENGTH)
- check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
- name[0, unpackdw(size)]
- end
-
- def EnumKey(hkey, index)
- name = ' ' * Constants::MAX_KEY_LENGTH
- size = packdw(Constants::MAX_KEY_LENGTH)
- wtime = ' ' * 8
- check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
- [ name[0, unpackdw(size)], unpackqw(wtime) ]
- end
-
- def QueryValue(hkey, name)
- type = packdw(0)
- size = packdw(0)
- check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
- data = ' ' * unpackdw(size)
- check RegQueryValueExA.call(hkey, name, 0, type, data, size)
- [ unpackdw(type), data[0, unpackdw(size)] ]
- end
-
- def SetValue(hkey, name, type, data, size)
- check RegSetValueExA.call(hkey, name, 0, type, data, size)
- end
-
- def DeleteValue(hkey, name)
- check RegDeleteValue.call(hkey, name)
- end
-
- def DeleteKey(hkey, name)
- check RegDeleteKey.call(hkey, name)
- end
-
- def FlushKey(hkey)
- check RegFlushKey.call(hkey)
- end
-
- def CloseKey(hkey)
- check RegCloseKey.call(hkey)
- end
-
- def QueryInfoKey(hkey)
- subkeys = packdw(0)
- maxsubkeylen = packdw(0)
- values = packdw(0)
- maxvaluenamelen = packdw(0)
- maxvaluelen = packdw(0)
- secdescs = packdw(0)
- wtime = ' ' * 8
- check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
- values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
- [ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
- unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
- unpackdw(secdescs), unpackqw(wtime) ]
- end
- end
-
- #
- # utility functions
- #
- def self.expand_environ(str)
- str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
- end
-
- @@type2name = { }
- %w[
- REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
- REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
- REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
- REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
- ].each do |type|
- @@type2name[Constants.const_get(type)] = type
- end
-
- def self.type2name(type)
- @@type2name[type] || type.to_s
- end
-
- def self.wtime2time(wtime)
- Time.at((wtime - 116444736000000000) / 10000000)
- end
-
- def self.time2wtime(time)
- time.to_i * 10000000 + 116444736000000000
- end
-
- #
- # constructors
- #
- private_class_method :new
-
- def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
- subkey = subkey.chomp('\\')
- newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
- obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
- if block_given?
- begin
- yield obj
- ensure
- obj.close
- end
- else
- obj
- end
- end
-
- def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
- newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
- obj = new(newkey, hkey, subkey, disp)
- if block_given?
- begin
- yield obj
- ensure
- obj.close
- end
- else
- obj
- end
- end
-
- #
- # finalizer
- #
- @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
-
- #
- # initialize
- #
- def initialize(hkey, parent, keyname, disposition)
- @hkey = hkey
- @parent = parent
- @keyname = keyname
- @disposition = disposition
- @hkeyfinal = [ hkey ]
- ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
- end
- attr_reader :hkey, :parent, :keyname, :disposition
-
- #
- # attributes
- #
- def created?
- @disposition == REG_CREATED_NEW_KEY
- end
-
- def open?
- !@hkey.nil?
- end
-
- def name
- parent = self
- name = @keyname
- while parent = parent.parent
- name = parent.keyname + '\\' + name
- end
- name
- end
-
- def inspect
- "\#<Win32::Registry key=#{name.inspect}>"
- end
-
- #
- # marshalling
- #
- def _dump(depth)
- raise TypeError, "can't dump Win32::Registry"
- end
-
- #
- # open/close
- #
- def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
- self.class.open(self, subkey, desired, opt, &blk)
- end
-
- def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
- self.class.create(self, subkey, desired, opt, &blk)
- end
-
- def close
- API.CloseKey(@hkey)
- @hkey = @parent = @keyname = nil
- @hkeyfinal[0] = nil
- end
-
- #
- # iterator
- #
- def each_value
- index = 0
- while true
- begin
- subkey = API.EnumValue(@hkey, index)
- rescue Error
- break
- end
- begin
- type, data = read(subkey)
- rescue Error
- next
- end
- yield subkey, type, data
- index += 1
- end
- index
- end
- alias each each_value
-
- def each_key
- index = 0
- while true
- begin
- subkey, wtime = API.EnumKey(@hkey, index)
- rescue Error
- break
- end
- yield subkey, wtime
- index += 1
- end
- index
- end
-
- def keys
- keys_ary = []
- each_key { |key,| keys_ary << key }
- keys_ary
- end
-
- #
- # reader
- #
- def read(name, *rtype)
- type, data = API.QueryValue(@hkey, name)
- unless rtype.empty? or rtype.include?(type)
- raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)"
- end
- case type
- when REG_SZ, REG_EXPAND_SZ
- [ type, data.chop ]
- when REG_MULTI_SZ
- [ type, data.split(/\0/) ]
- when REG_BINARY
- [ type, data ]
- when REG_DWORD
- [ type, API.unpackdw(data) ]
- when REG_DWORD_BIG_ENDIAN
- [ type, data.unpack('N')[0] ]
- when REG_QWORD
- [ type, API.unpackqw(data) ]
- else
- raise TypeError, "Type #{type} is not supported."
- end
- end
-
- def [](name, *rtype)
- type, data = read(name, *rtype)
- case type
- when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
- data
- when REG_EXPAND_SZ
- Registry.expand_environ(data)
- else
- raise TypeError, "Type #{type} is not supported."
- end
- end
-
- def read_s(name)
- read(name, REG_SZ)[1]
- end
-
- def read_s_expand(name)
- type, data = read(name, REG_SZ, REG_EXPAND_SZ)
- if type == REG_EXPAND_SZ
- Registry.expand_environ(data)
- else
- data
- end
- end
-
- def read_i(name)
- read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
- end
-
- def read_bin(name)
- read(name, REG_BINARY)[1]
- end
-
- #
- # writer
- #
- def write(name, type, data)
- case type
- when REG_SZ, REG_EXPAND_SZ
- data = data.to_s + "\0"
- when REG_MULTI_SZ
- data = data.to_a.join("\0") + "\0\0"
- when REG_BINARY
- data = data.to_s
- when REG_DWORD
- data = API.packdw(data.to_i)
- when REG_DWORD_BIG_ENDIAN
- data = [data.to_i].pack('N')
- when REG_QWORD
- data = API.packqw(data.to_i)
- else
- raise TypeError, "Unsupported type #{type}"
- end
- API.SetValue(@hkey, name, type, data, data.length)
- end
-
- def []=(name, rtype, value = nil)
- if value
- write name, rtype, value
- else
- case value = rtype
- when Integer
- write name, REG_DWORD, value
- when String
- write name, REG_SZ, value
- when Array
- write name, REG_MULTI_SZ, value
- else
- raise TypeError, "Unexpected type #{value.class}"
- end
- end
- value
- end
-
- def write_s(name, value)
- write name, REG_SZ, value.to_s
- end
-
- def write_i(name, value)
- write name, REG_DWORD, value.to_i
- end
-
- def write_bin(name, value)
- write name, REG_BINARY, value.to_s
- end
-
- #
- # delete
- #
- def delete_value(name)
- API.DeleteValue(@hkey, name)
- end
- alias delete delete_value
-
- def delete_key(name, recursive = false)
- if recursive
- open(name, KEY_ALL_ACCESS) do |reg|
- reg.keys.each do |key|
- begin
- reg.delete_key(key, true)
- rescue Error
- #
- end
- end
- end
- API.DeleteKey(@hkey, name)
- else
- begin
- API.EnumKey @hkey, 0
- rescue Error
- return API.DeleteKey(@hkey, name)
- end
- raise Error.new(5) ## ERROR_ACCESS_DENIED
- end
- end
-
- #
- # flush
- #
- def flush
- API.FlushKey @hkey
- end
-
- #
- # key information
- #
- def info
- API.QueryInfoKey(@hkey)
- end
- %w[
- num_keys max_key_length
- num_values max_value_name_length max_value_length
- descriptor_length wtime
- ].each_with_index do |s, i|
- eval <<-__END__
- def #{s}
- info[#{i}]
- end
- __END__
- end
- end
-end
diff --git a/ext/dl/win32/lib/win32/resolv.rb b/ext/dl/win32/lib/win32/resolv.rb
deleted file mode 100644
index 6534d20760..0000000000
--- a/ext/dl/win32/lib/win32/resolv.rb
+++ /dev/null
@@ -1,366 +0,0 @@
-=begin
-= Win32 DNS and DHCP I/F
-
-=end
-
-require 'win32/registry'
-
-module Win32
- module Resolv
- API = Registry::API
-
- def self.get_hosts_path
- path = get_hosts_dir
- path = File.join(path.gsub(/\\/, File::SEPARATOR), 'hosts')
- File.exist?(path) ? path : nil
- end
-
- def self.get_resolv_info
- search, nameserver = get_info
- if search.empty?
- search = nil
- else
- search.delete("")
- search.uniq!
- end
- if nameserver.empty?
- nameserver = nil
- else
- nameserver.delete("")
- nameserver.delete("0.0.0.0")
- nameserver.uniq!
- end
- [ search, nameserver ]
- end
-
-getv = Win32API.new('kernel32.dll', 'GetVersionExA', 'P', 'L')
-info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
-getv.call(info)
-if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
-#====================================================================
-# Windows NT
-#====================================================================
- module_eval <<-'__EOS__', __FILE__, __LINE__+1
- TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
-
- class << self
- private
- def get_hosts_dir
- Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
- reg.read_s_expand('DataBasePath')
- end
- end
-
- def get_info
- search = nil
- nameserver = []
- Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
- begin
- slist = reg.read_s('SearchList')
- search = slist.split(/,\s*/) unless slist.empty?
- rescue Registry::Error
- end
-
- if add_search = search.nil?
- search = []
- begin
- nvdom = reg.read_s('NV Domain')
- unless nvdom.empty?
- @search = [ nvdom ]
- if reg.read_i('UseDomainNameDevolution') != 0
- if /^[\w\d]+\./ =~ nvdom
- devo = $'
- end
- end
- end
- rescue Registry::Error
- end
- end
-
- reg.open('Interfaces') do |reg|
- reg.each_key do |iface,|
- reg.open(iface) do |regif|
- begin
- [ 'NameServer', 'DhcpNameServer' ].each do |key|
- ns = regif.read_s(key)
- unless ns.empty?
- nameserver.concat(ns.split(/[,\s]\s*/))
- break
- end
- end
- rescue Registry::Error
- end
-
- if add_search
- begin
- [ 'Domain', 'DhcpDomain' ].each do |key|
- dom = regif.read_s(key)
- unless dom.empty?
- search.concat(dom.split(/,\s*/))
- break
- end
- end
- rescue Registry::Error
- end
- end
- end
- end
- end
- search << devo if add_search and devo
- end
- [ search.uniq, nameserver.uniq ]
- end
- end
- __EOS__
-else
-#====================================================================
-# Windows 9x
-#====================================================================
- module_eval <<-'__EOS__', __FILE__, __LINE__+1
- TCPIP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\MSTCP'
- DHCP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\DHCP'
- WINDOWS = 'Software\Microsoft\Windows\CurrentVersion'
-
- class << self
- # private
-
- def get_hosts_dir
- Registry::HKEY_LOCAL_MACHINE.open(WINDOWS) do |reg|
- reg.read_s_expand('SystemRoot')
- end
- end
-
- def get_info
- search = []
- nameserver = []
- begin
- Registry::HKEY_LOCAL_MACHINE.open(TCPIP_9X) do |reg|
- if reg.read_s("EnableDNS") == "1"
- domain = reg.read_s("Domain")
- ns = reg.read_s("NameServer")
- slist = reg.read_s("SearchList")
- search << domain unless domain.empty?
- search.concat(slist.split(/,\s*/))
- nameserver.concat(ns.split(/[,\s]\s*/))
- end
- end
- rescue Registry::Error
- end
-
- dhcpinfo = get_dhcpinfo
- search.concat(dhcpinfo[0])
- nameserver.concat(dhcpinfo[1])
- [ search, nameserver ]
- end
-
- def get_dhcpinfo
- macaddrs = {}
- ipaddrs = {}
- WsControl.get_iflist.each do |index, macaddr, *ipaddr|
- macaddrs[macaddr] = 1
- ipaddr.each { |ipaddr| ipaddrs[ipaddr] = 1 }
- end
- iflist = [ macaddrs, ipaddrs ]
-
- search = []
- nameserver = []
- version = -1
- Registry::HKEY_LOCAL_MACHINE.open(DHCP_9X) do |reg|
- begin
- version = API.unpackdw(reg.read_bin("Version"))
- rescue Registry::Error
- end
-
- reg.each_key do |key,|
- catch(:not_used) do
- reg.open(key) do |regdi|
- dom, ns = get_dhcpinfo_key(version, regdi, iflist)
- search << dom if dom
- nameserver.concat(ns) if ns
- end
- end
- end
- end
- [ search, nameserver ]
- end
-
- def get_dhcpinfo_95(reg)
- dhcp = reg.read_bin("DhcpInfo")
- [
- API.unpackdw(dhcp[4..7]),
- API.unpackdw(dhcp[8..11]),
- 1,
- dhcp[45..50],
- reg.read_bin("OptionInfo"),
- ]
- end
-
- def get_dhcpinfo_98(reg)
- [
- API.unpackdw(reg.read_bin("DhcpIPAddress")),
- API.unpackdw(reg.read_bin("DhcpSubnetMask")),
- API.unpackdw(reg.read_bin("HardwareType")),
- reg.read_bin("HardwareAddress"),
- reg.read_bin("OptionInfo"),
- ]
- end
-
- def get_dhcpinfo_key(version, reg, iflist)
- info = case version
- when 1
- get_dhcpinfo_95(reg)
- when 2
- get_dhcpinfo_98(reg)
- else
- begin
- get_dhcpinfo_98(reg)
- rescue Registry::Error
- get_dhcpinfo_95(reg)
- end
- end
- ipaddr, netmask, hwtype, macaddr, opt = info
- throw :not_used unless
- ipaddr and ipaddr != 0 and
- netmask and netmask != 0 and
- macaddr and macaddr.size == 6 and
- hwtype == 1 and
- iflist[0][macaddr] and iflist[1][ipaddr]
-
- size = opt.size
- idx = 0
- while idx <= size
- opttype = opt[idx]
- optsize = opt[idx + 1]
- optval = opt[idx + 2, optsize]
- case opttype
- when 0xFF ## term
- break
- when 0x0F ## domain
- domain = optval.chomp("\0")
- when 0x06 ## dns
- nameserver = optval.scan(/..../).collect { |addr|
- "%d.%d.%d.%d" % addr.unpack('C4')
- }
- end
- idx += optsize + 2
- end
- [ domain, nameserver ]
- rescue Registry::Error
- throw :not_used
- end
- end
-
- module WsControl
- WsControl = Win32API.new('wsock32.dll', 'WsControl', 'LLPPPP', 'L')
- WSAGetLastError = Win32API.new('wsock32.dll', 'WSAGetLastError', 'V', 'L')
-
- MAX_TDI_ENTITIES = 512
- IPPROTO_TCP = 6
- WSCTL_TCP_QUERY_INFORMATION = 0
- INFO_CLASS_GENERIC = 0x100
- INFO_CLASS_PROTOCOL = 0x200
- INFO_TYPE_PROVIDER = 0x100
- ENTITY_LIST_ID = 0
- GENERIC_ENTITY = 0
- CL_NL_ENTITY = 0x301
- IF_ENTITY = 0x200
- ENTITY_TYPE_ID = 1
- CL_NL_IP = 0x303
- IF_MIB = 0x202
- IF_MIB_STATS_ID = 1
- IP_MIB_ADDRTABLE_ENTRY_ID = 0x102
-
- def self.wsctl(tei_entity, tei_instance,
- toi_class, toi_type, toi_id,
- buffsize)
- reqinfo = [
- ## TDIEntityID
- tei_entity, tei_instance,
- ## TDIObjectID
- toi_class, toi_type, toi_id,
- ## TCP_REQUEST_INFORMATION_EX
- ""
- ].pack('VVVVVa16')
- reqsize = API.packdw(reqinfo.size)
- buff = "\0" * buffsize
- buffsize = API.packdw(buffsize)
- result = WsControl.call(
- IPPROTO_TCP,
- WSCTL_TCP_QUERY_INFORMATION,
- reqinfo, reqsize,
- buff, buffsize)
- if result != 0
- raise RuntimeError, "WsControl failed.(#{result})"
- end
- [ buff, API.unpackdw(buffsize) ]
- end
- private_class_method :wsctl
-
- def self.get_iflist
- # Get TDI Entity List
- entities, size =
- wsctl(GENERIC_ENTITY, 0,
- INFO_CLASS_GENERIC,
- INFO_TYPE_PROVIDER,
- ENTITY_LIST_ID,
- MAX_TDI_ENTITIES * 8) # sizeof(TDIEntityID)
- entities = entities[0, size].
- scan(/.{8}/).
- collect { |e| e.unpack('VV') }
-
- # Get MIB Interface List
- iflist = []
- ifcount = 0
- entities.each do |entity, instance|
- if( (entity & IF_ENTITY)>0 )
- ifcount += 1
- etype, = wsctl(entity, instance,
- INFO_CLASS_GENERIC,
- INFO_TYPE_PROVIDER,
- ENTITY_TYPE_ID,
- 4)
- if( (API.unpackdw(etype) & IF_MIB)==IF_MIB )
- ifentry, = wsctl(entity, instance,
- INFO_CLASS_PROTOCOL,
- INFO_TYPE_PROVIDER,
- IF_MIB_STATS_ID,
- 21 * 4 + 8 + 130) # sizeof(IFEntry)
- iflist << [
- API.unpackdw(ifentry[0,4]),
- ifentry[20, 6]
- ]
- end
- end
- end
-
- # Get IP Addresses
- entities.each do |entity, instance|
- if entity == CL_NL_ENTITY
- etype, = wsctl(entity, instance,
- INFO_CLASS_GENERIC,
- INFO_TYPE_PROVIDER,
- ENTITY_TYPE_ID,
- 4)
- if API.unpackdw(etype) == CL_NL_IP
- ipentries, = wsctl(entity, instance,
- INFO_CLASS_PROTOCOL,
- INFO_TYPE_PROVIDER,
- IP_MIB_ADDRTABLE_ENTRY_ID,
- 24 * (ifcount+1)) # sizeof(IPAddrEntry)
- ipentries.scan(/.{24}/) do |ipentry|
- ipaddr, index = ipentry.unpack('VV')
- if ifitem = iflist.assoc(index)
- ifitem << ipaddr
- end
- end
- end
- end
- end
- iflist
- end
- end
- __EOS__
-end
-#====================================================================
- end
-end
diff --git a/ext/dl/win32/lib/win32/sspi.rb b/ext/dl/win32/lib/win32/sspi.rb
deleted file mode 100644
index ef90ae35a7..0000000000
--- a/ext/dl/win32/lib/win32/sspi.rb
+++ /dev/null
@@ -1,330 +0,0 @@
-#
-# = win32/sspi.rb
-#
-# Copyright (c) 2006-2007 Justin Bailey
-#
-# Written and maintained by Justin Bailey <jgbailey@gmail.com>.
-#
-# This program is free software. You can re-distribute and/or
-# modify this program under the same terms of ruby itself ---
-# Ruby Distribution License or GNU General Public License.
-#
-
-require 'Win32API'
-
-# Implements bindings to Win32 SSPI functions, focused on authentication to a proxy server over HTTP.
-module Win32
- module SSPI
- # Specifies how credential structure requested will be used. Only SECPKG_CRED_OUTBOUND is used
- # here.
- SECPKG_CRED_INBOUND = 0x00000001
- SECPKG_CRED_OUTBOUND = 0x00000002
- SECPKG_CRED_BOTH = 0x00000003
-
- # Format of token. NETWORK format is used here.
- SECURITY_NATIVE_DREP = 0x00000010
- SECURITY_NETWORK_DREP = 0x00000000
-
- # InitializeSecurityContext Requirement flags
- ISC_REQ_REPLAY_DETECT = 0x00000004
- ISC_REQ_SEQUENCE_DETECT = 0x00000008
- ISC_REQ_CONFIDENTIALITY = 0x00000010
- ISC_REQ_USE_SESSION_KEY = 0x00000020
- ISC_REQ_PROMPT_FOR_CREDS = 0x00000040
- ISC_REQ_CONNECTION = 0x00000800
-
- # Win32 API Functions. Uses Win32API to bind methods to constants contained in class.
- module API
- # Can be called with AcquireCredentialsHandle.call()
- AcquireCredentialsHandle = Win32API.new("secur32", "AcquireCredentialsHandle", 'ppLpppppp', 'L')
- # Can be called with InitializeSecurityContext.call()
- InitializeSecurityContext = Win32API.new("secur32", "InitializeSecurityContext", 'pppLLLpLpppp', 'L')
- # Can be called with DeleteSecurityContext.call()
- DeleteSecurityContext = Win32API.new("secur32", "DeleteSecurityContext", 'P', 'L')
- # Can be called with FreeCredentialsHandle.call()
- FreeCredentialsHandle = Win32API.new("secur32", "FreeCredentialsHandle", 'P', 'L')
- end
-
- # SecHandle struct
- class SecurityHandle
- def upper
- @struct.unpack("LL")[1]
- end
-
- def lower
- @struct.unpack("LL")[0]
- end
-
- def to_p
- @struct ||= "\0" * 8
- end
- end
-
- # Some familiar aliases for the SecHandle structure
- CredHandle = CtxtHandle = SecurityHandle
-
- # TimeStamp struct
- class TimeStamp
- attr_reader :struct
-
- def to_p
- @struct ||= "\0" * 8
- end
- end
-
- # Creates binary representaiton of a SecBufferDesc structure,
- # including the SecBuffer contained inside.
- class SecurityBuffer
-
- SECBUFFER_TOKEN = 2 # Security token
-
- TOKENBUFSIZE = 12288
- SECBUFFER_VERSION = 0
-
- def initialize(buffer = nil)
- @buffer = buffer || "\0" * TOKENBUFSIZE
- @bufferSize = @buffer.length
- @type = SECBUFFER_TOKEN
- end
-
- def bufferSize
- unpack
- @bufferSize
- end
-
- def bufferType
- unpack
- @type
- end
-
- def token
- unpack
- @buffer
- end
-
- def to_p
- # Assumption is that when to_p is called we are going to get a packed structure. Therefore,
- # set @unpacked back to nil so we know to unpack when accessors are next accessed.
- @unpacked = nil
- # Assignment of inner structure to variable is very important here. Without it,
- # will not be able to unpack changes to the structure. Alternative, nested unpacks,
- # does not work (i.e. @struct.unpack("LLP12")[2].unpack("LLP12") results in "no associated pointer")
- @sec_buffer ||= [@bufferSize, @type, @buffer].pack("LLP")
- @struct ||= [SECBUFFER_VERSION, 1, @sec_buffer].pack("LLP")
- end
-
- private
-
- # Unpacks the SecurityBufferDesc structure into member variables. We
- # only want to do this once per struct, so the struct is deleted
- # after unpacking.
- def unpack
- if ! @unpacked && @sec_buffer && @struct
- @bufferSize, @type = @sec_buffer.unpack("LL")
- @buffer = @sec_buffer.unpack("LLP#{@bufferSize}")[2]
- @struct = nil
- @sec_buffer = nil
- @unpacked = true
- end
- end
- end
-
- # SEC_WINNT_AUTH_IDENTITY structure
- class Identity
- SEC_WINNT_AUTH_IDENTITY_ANSI = 0x1
-
- attr_accessor :user, :domain, :password
-
- def initialize(user = nil, domain = nil, password = nil)
- @user = user
- @domain = domain
- @password = password
- @flags = SEC_WINNT_AUTH_IDENTITY_ANSI
- end
-
- def to_p
- [@user, @user ? @user.length : 0,
- @domain, @domain ? @domain.length : 0,
- @password, @password ? @password.length : 0,
- @flags].pack("PLPLPLL")
- end
- end
-
- # Takes a return result from an SSPI function and interprets the value.
- class SSPIResult
- # Good results
- SEC_E_OK = 0x00000000
- SEC_I_CONTINUE_NEEDED = 0x00090312
-
- # These are generally returned by InitializeSecurityContext
- SEC_E_INSUFFICIENT_MEMORY = 0x80090300
- SEC_E_INTERNAL_ERROR = 0x80090304
- SEC_E_INVALID_HANDLE = 0x80090301
- SEC_E_INVALID_TOKEN = 0x80090308
- SEC_E_LOGON_DENIED = 0x8009030C
- SEC_E_NO_AUTHENTICATING_AUTHORITY = 0x80090311
- SEC_E_NO_CREDENTIALS = 0x8009030E
- SEC_E_TARGET_UNKNOWN = 0x80090303
- SEC_E_UNSUPPORTED_FUNCTION = 0x80090302
- SEC_E_WRONG_PRINCIPAL = 0x80090322
-
- # These are generally returned by AcquireCredentialsHandle
- SEC_E_NOT_OWNER = 0x80090306
- SEC_E_SECPKG_NOT_FOUND = 0x80090305
- SEC_E_UNKNOWN_CREDENTIALS = 0x8009030D
-
- @@map = {}
- constants.each { |v| @@map[self.const_get(v.to_s)] = v }
-
- attr_reader :value
-
- def initialize(value)
- # convert to unsigned long
- value = [value].pack("L").unpack("L").first
- raise "#{value.to_s(16)} is not a recognized result" unless @@map.has_key? value
- @value = value
- end
-
- def to_s
- @@map[@value].to_s
- end
-
- def ok?
- @value == SEC_I_CONTINUE_NEEDED || @value == SEC_E_OK
- end
-
- def ==(other)
- if other.is_a?(SSPIResult)
- @value == other.value
- elsif other.is_a?(Fixnum)
- @value == @@map[other]
- else
- false
- end
- end
- end
-
- # Handles "Negotiate" type authentication. Geared towards authenticating with a proxy server over HTTP
- class NegotiateAuth
- attr_accessor :credentials, :context, :contextAttributes, :user, :domain
-
- # Default request flags for SSPI functions
- REQUEST_FLAGS = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION
-
- # NTLM tokens start with this header always. Encoding alone adds "==" and newline, so remove those
- B64_TOKEN_PREFIX = ["NTLMSSP"].pack("m").delete("=\n")
-
- # Given a connection and a request path, performs authentication as the current user and returns
- # the response from a GET request. The connnection should be a Net::HTTP object, and it should
- # have been constructed using the Net::HTTP.Proxy method, but anything that responds to "get" will work.
- # If a user and domain are given, will authenticate as the given user.
- # Returns the response received from the get method (usually Net::HTTPResponse)
- def NegotiateAuth.proxy_auth_get(http, path, user = nil, domain = nil)
- raise "http must respond to :get" unless http.respond_to?(:get)
- nego_auth = self.new user, domain
-
- resp = http.get path, { "Proxy-Authorization" => "Negotiate " + nego_auth.get_initial_token }
- if resp["Proxy-Authenticate"]
- resp = http.get path, { "Proxy-Authorization" => "Negotiate " + nego_auth.complete_authentication(resp["Proxy-Authenticate"].split(" ").last.strip) }
- end
-
- resp
- end
-
- # Creates a new instance ready for authentication as the given user in the given domain.
- # Defaults to current user and domain as defined by ENV["USERDOMAIN"] and ENV["USERNAME"] if
- # no arguments are supplied.
- def initialize(user = nil, domain = nil)
- if user.nil? && domain.nil? && ENV["USERNAME"].nil? && ENV["USERDOMAIN"].nil?
- raise "A username or domain must be supplied since they cannot be retrieved from the environment"
- end
-
- @user = user || ENV["USERNAME"]
- @domain = domain || ENV["USERDOMAIN"]
- end
-
- # Gets the initial Negotiate token. Returns it as a base64 encoded string suitable for use in HTTP. Can
- # be easily decoded, however.
- def get_initial_token
- raise "This object is no longer usable because its resources have been freed." if @cleaned_up
- get_credentials
-
- outputBuffer = SecurityBuffer.new
- @context = CtxtHandle.new
- @contextAttributes = "\0" * 4
-
- result = SSPIResult.new(API::InitializeSecurityContext.call(@credentials.to_p, nil, nil,
- REQUEST_FLAGS,0, SECURITY_NETWORK_DREP, nil, 0, @context.to_p, outputBuffer.to_p, @contextAttributes, TimeStamp.new.to_p))
-
- if result.ok? then
- return encode_token(outputBuffer.token)
- else
- raise "Error: #{result.to_s}"
- end
- end
-
- # Takes a token and gets the next token in the Negotiate authentication chain. Token can be Base64 encoded or not.
- # The token can include the "Negotiate" header and it will be stripped.
- # Does not indicate if SEC_I_CONTINUE or SEC_E_OK was returned.
- # Token returned is Base64 encoded w/ all new lines removed.
- def complete_authentication(token)
- raise "This object is no longer usable because its resources have been freed." if @cleaned_up
-
- # Nil token OK, just set it to empty string
- token = "" if token.nil?
-
- if token.include? "Negotiate"
- # If the Negotiate prefix is passed in, assume we are seeing "Negotiate <token>" and get the token.
- token = token.split(" ").last
- end
-
- if token.include? B64_TOKEN_PREFIX
- # indicates base64 encoded token
- token = token.strip.unpack("m")[0]
- end
-
- outputBuffer = SecurityBuffer.new
- result = SSPIResult.new(API::InitializeSecurityContext.call(@credentials.to_p, @context.to_p, nil,
- REQUEST_FLAGS, 0, SECURITY_NETWORK_DREP, SecurityBuffer.new(token).to_p, 0,
- @context.to_p,
- outputBuffer.to_p, @contextAttributes, TimeStamp.new.to_p))
-
- if result.ok? then
- return encode_token(outputBuffer.token)
- else
- raise "Error: #{result.to_s}"
- end
- ensure
- # need to make sure we don't clean up if we've already cleaned up.
- clean_up unless @cleaned_up
- end
-
- private
-
- def clean_up
- # free structures allocated
- @cleaned_up = true
- API::FreeCredentialsHandle.call(@credentials.to_p)
- API::DeleteSecurityContext.call(@context.to_p)
- @context = nil
- @credentials = nil
- @contextAttributes = nil
- end
-
- # Gets credentials based on user, domain or both. If both are nil, an error occurs
- def get_credentials
- @credentials = CredHandle.new
- ts = TimeStamp.new
- @identity = Identity.new @user, @domain
- result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, "Negotiate", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,
- nil, nil, @credentials.to_p, ts.to_p))
- raise "Error acquire credentials: #{result}" unless result.ok?
- end
-
- def encode_token(t)
- # encode64 will add newlines every 60 characters so we need to remove those.
- [t].pack("m").delete("\n")
- end
- end
- end
-end \ No newline at end of file
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 7c8fba3b8f..ecb9e16411 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -42,7 +42,8 @@ char *getlogin();
* Etc.getlogin -> 'guest'
*/
static VALUE
-etc_getlogin(VALUE obj)
+etc_getlogin(obj)
+ VALUE obj;
{
char *login;
@@ -61,7 +62,8 @@ etc_getlogin(VALUE obj)
#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
static VALUE
-safe_setup_str(const char *str)
+safe_setup_str(str)
+ const char *str;
{
if (str == 0) str = "";
return rb_tainted_str_new2(str);
@@ -70,7 +72,8 @@ safe_setup_str(const char *str)
#ifdef HAVE_GETPWENT
static VALUE
-setup_passwd(struct passwd *pwd)
+setup_passwd(pwd)
+ struct passwd *pwd;
{
if (pwd == 0) rb_sys_fail("/etc/passwd");
return rb_struct_new(sPasswd,
@@ -78,8 +81,8 @@ setup_passwd(struct passwd *pwd)
#ifdef HAVE_ST_PW_PASSWD
safe_setup_str(pwd->pw_passwd),
#endif
- UIDT2NUM(pwd->pw_uid),
- GIDT2NUM(pwd->pw_gid),
+ PW_UID2VAL(pwd->pw_uid),
+ PW_GID2VAL(pwd->pw_gid),
#ifdef HAVE_ST_PW_GECOS
safe_setup_str(pwd->pw_gecos),
#endif
@@ -118,7 +121,10 @@ setup_passwd(struct passwd *pwd)
* passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
*/
static VALUE
-etc_getpwuid(int argc, VALUE *argv, VALUE obj)
+etc_getpwuid(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
#if defined(HAVE_GETPWENT)
VALUE id;
@@ -127,7 +133,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &id) == 1) {
- uid = NUM2UIDT(id);
+ uid = PW_VAL2UID(id);
}
else {
uid = getuid();
@@ -149,14 +155,15 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
* passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
*/
static VALUE
-etc_getpwnam(VALUE obj, VALUE nam)
+etc_getpwnam(obj, nam)
+ VALUE obj, nam;
{
#ifdef HAVE_GETPWENT
struct passwd *pwd;
SafeStringValue(nam);
- pwd = getpwnam(RSTRING_PTR(nam));
- if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING_PTR(nam));
+ pwd = getpwnam(RSTRING(nam)->ptr);
+ if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING(nam)->ptr);
return setup_passwd(pwd);
#else
return Qnil;
@@ -166,14 +173,14 @@ etc_getpwnam(VALUE obj, VALUE nam)
#ifdef HAVE_GETPWENT
static int passwd_blocking = 0;
static VALUE
-passwd_ensure(void)
+passwd_ensure()
{
passwd_blocking = Qfalse;
return Qnil;
}
static VALUE
-passwd_iterate(void)
+passwd_iterate()
{
struct passwd *pw;
@@ -202,7 +209,8 @@ passwd_iterate(void)
*
*/
static VALUE
-etc_passwd(VALUE obj)
+etc_passwd(obj)
+ VALUE obj;
{
#ifdef HAVE_GETPWENT
struct passwd *pw;
@@ -226,7 +234,8 @@ etc_passwd(VALUE obj)
* to getpwent will return the first entry again.
*/
static VALUE
-etc_setpwent(VALUE obj)
+etc_setpwent(obj)
+ VALUE obj;
{
#ifdef HAVE_GETPWENT
setpwent();
@@ -238,7 +247,8 @@ etc_setpwent(VALUE obj)
* getpwent, and closes the file.
*/
static VALUE
-etc_endpwent(VALUE obj)
+etc_endpwent(obj)
+ VALUE obj;
{
#ifdef HAVE_GETPWENT
endpwent();
@@ -273,7 +283,8 @@ etc_endpwent(VALUE obj)
* - Passwd#shell contains the path to the login shell of the user as a String.
*/
static VALUE
-etc_getpwent(VALUE obj)
+etc_getpwent(obj)
+ VALUE obj;
{
#ifdef HAVE_GETPWENT
struct passwd *pw;
@@ -287,7 +298,8 @@ etc_getpwent(VALUE obj)
#ifdef HAVE_GETGRENT
static VALUE
-setup_group(struct group *grp)
+setup_group(grp)
+ struct group *grp;
{
VALUE mem;
char **tbl;
@@ -303,7 +315,7 @@ setup_group(struct group *grp)
#ifdef HAVE_ST_GR_PASSWD
safe_setup_str(grp->gr_passwd),
#endif
- GIDT2NUM(grp->gr_gid),
+ PW_GID2VAL(grp->gr_gid),
mem);
}
#endif
@@ -319,20 +331,15 @@ setup_group(struct group *grp)
*
*/
static VALUE
-etc_getgrgid(int argc, VALUE *argv, VALUE obj)
+etc_getgrgid(obj, id)
+ VALUE obj, id;
{
#ifdef HAVE_GETGRENT
- VALUE id;
gid_t gid;
struct group *grp;
rb_secure(4);
- if (rb_scan_args(argc, argv, "01", &id) == 1) {
- gid = NUM2GIDT(id);
- }
- else {
- gid = getgid();
- }
+ gid = PW_VAL2GID(id);
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", gid);
return setup_group(grp);
@@ -352,15 +359,16 @@ etc_getgrgid(int argc, VALUE *argv, VALUE obj)
*
*/
static VALUE
-etc_getgrnam(VALUE obj, VALUE nam)
+etc_getgrnam(obj, nam)
+ VALUE obj, nam;
{
#ifdef HAVE_GETGRENT
struct group *grp;
rb_secure(4);
SafeStringValue(nam);
- grp = getgrnam(RSTRING_PTR(nam));
- if (grp == 0) rb_raise(rb_eArgError, "can't find group for %s", RSTRING_PTR(nam));
+ grp = getgrnam(RSTRING(nam)->ptr);
+ if (grp == 0) rb_raise(rb_eArgError, "can't find group for %s", RSTRING(nam)->ptr);
return setup_group(grp);
#else
return Qnil;
@@ -370,14 +378,14 @@ etc_getgrnam(VALUE obj, VALUE nam)
#ifdef HAVE_GETGRENT
static int group_blocking = 0;
static VALUE
-group_ensure(void)
+group_ensure()
{
group_blocking = Qfalse;
return Qnil;
}
static VALUE
-group_iterate(void)
+group_iterate()
{
struct group *pw;
@@ -406,7 +414,8 @@ group_iterate(void)
*
*/
static VALUE
-etc_group(VALUE obj)
+etc_group(obj)
+ VALUE obj;
{
#ifdef HAVE_GETGRENT
struct group *grp;
@@ -430,7 +439,8 @@ etc_group(VALUE obj)
* to getgrent will return the first entry again.
*/
static VALUE
-etc_setgrent(VALUE obj)
+etc_setgrent(obj)
+ VALUE obj;
{
#ifdef HAVE_GETGRENT
setgrent();
@@ -442,7 +452,8 @@ etc_setgrent(VALUE obj)
* getgrent, and closes the file.
*/
static VALUE
-etc_endgrent(VALUE obj)
+etc_endgrent(obj)
+ VALUE obj;
{
#ifdef HAVE_GETGRENT
endgrent();
@@ -471,7 +482,8 @@ etc_endgrent(VALUE obj)
* members of the group.
*/
static VALUE
-etc_getgrent(VALUE obj)
+etc_getgrent(obj)
+ VALUE obj;
{
#ifdef HAVE_GETGRENT
struct group *gr;
@@ -491,7 +503,7 @@ static VALUE mEtc;
* Documented by mathew <meta@pobox.com>.
*/
void
-Init_etc(void)
+Init_etc()
{
mEtc = rb_define_module("Etc");
@@ -504,13 +516,14 @@ Init_etc(void)
rb_define_module_function(mEtc, "getpwent", etc_getpwent, 0);
rb_define_module_function(mEtc, "passwd", etc_passwd, 0);
- rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, -1);
+ rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, 1);
rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
rb_define_module_function(mEtc, "group", etc_group, 0);
rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
rb_define_module_function(mEtc, "endgrent", etc_endgrent, 0);
rb_define_module_function(mEtc, "getgrent", etc_getgrent, 0);
+ rb_global_variable(&sPasswd);
sPasswd = rb_struct_define("Passwd",
"name", "passwd", "uid", "gid",
#ifdef HAVE_ST_PW_GECOS
@@ -537,15 +550,12 @@ Init_etc(void)
#endif
NULL);
- rb_register_mark_object(sPasswd);
-
#ifdef HAVE_GETGRENT
+ rb_global_variable(&sGroup);
sGroup = rb_struct_define("Group", "name",
#ifdef HAVE_ST_GR_PASSWD
"passwd",
#endif
"gid", "mem", NULL);
-
- rb_register_mark_object(sGroup);
#endif
}
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 2914bfb196..dbd0672545 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -24,5 +24,20 @@ if a or b or c
have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
have_struct_member('struct group', 'gr_passwd', 'grp.h')
+ [%w"uid_t pwd.h", %w"gid_t grp.h"].each do |t, *h|
+ h.unshift("sys/types.h")
+ f = "INT2NUM"
+ if have_type(t, h)
+ if try_static_assert("sizeof(#{t}) > sizeof(long)", h)
+ f = "LL2NUM"
+ end
+ if try_static_assert("(#{t})-1 > 0", h)
+ f = "U#{f}"
+ end
+ end
+ t = t.chomp('_t').upcase
+ $defs.push("-DPW_#{t}2VAL=#{f}")
+ $defs.push("-DPW_VAL2#{t}=#{f.sub(/([A-Z]+)2(NUM)/, '\22\1')}")
+ end
create_makefile("etc")
end
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 8eca69f2ff..64746552c1 100644
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -42,6 +42,15 @@ def sysquote(x)
@quote ? x.quote : x
end
+def relative_from(path, base)
+ dir = File.join(path, "")
+ if File.expand_path(dir) == File.expand_path(dir, base)
+ path
+ else
+ File.join(base, path)
+ end
+end
+
def extract_makefile(makefile, keep = true)
m = File.read(makefile)
if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1])
@@ -60,7 +69,7 @@ def extract_makefile(makefile, keep = true)
unless installrb.empty?
config = CONFIG.dup
install_dirs(target_prefix).each {|var, val| config[var] = val}
- FileUtils.rm_f(installrb.values.collect {|f| RbConfig.expand(f, config)}, verbose: true)
+ FileUtils.rm_f(installrb.values.collect {|f| Config.expand(f, config)}, :verbose => true)
end
end
return false
@@ -118,7 +127,7 @@ def extmake(target)
makefile = "./Makefile"
ok = File.exist?(makefile)
unless $ignore
- rbconfig0 = RbConfig::CONFIG
+ rbconfig0 = Config::CONFIG
mkconfig0 = CONFIG
rbconfig = {
"hdrdir" => $hdrdir,
@@ -126,13 +135,13 @@ def extmake(target)
"topdir" => $topdir,
}
mkconfig = {
- "hdrdir" => ($hdrdir == top_srcdir) ? top_srcdir : "$(top_srcdir)/include",
+ "hdrdir" => "$(top_srcdir)",
"srcdir" => "$(top_srcdir)/ext/#{$mdir}",
"topdir" => $topdir,
}
rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup}
mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup}
- RbConfig.module_eval {
+ Config.module_eval {
remove_const(:CONFIG)
const_set(:CONFIG, rbconfig)
remove_const(:MAKEFILE_CONFIG)
@@ -174,7 +183,7 @@ def extmake(target)
ok = yield(ok) if block_given?
unless ok
open(makefile, "w") do |f|
- f.print(*dummy_makefile(CONFIG["srcdir"]))
+ f.print dummy_makefile(CONFIG["srcdir"])
end
return true
end
@@ -195,6 +204,7 @@ def extmake(target)
if $clean != true
FileUtils.rm_f([makefile, $extconf_h || "extconf.h"])
end
+ File.unlink(makefile) rescue nil
end
if $static
$extflags ||= ""
@@ -208,7 +218,7 @@ def extmake(target)
end
ensure
unless $ignore
- RbConfig.module_eval {
+ Config.module_eval {
remove_const(:CONFIG)
const_set(:CONFIG, rbconfig0)
remove_const(:MAKEFILE_CONFIG)
@@ -240,6 +250,7 @@ end
def parse_args()
$mflags = []
+ opts = nil
$optparser ||= OptionParser.new do |opts|
opts.on('-n') {$dryrun = true}
opts.on('--[no-]extension [EXTS]', Array) do |v|
@@ -278,7 +289,7 @@ def parse_args()
rescue OptionParser::InvalidOption => e
retry if /^--/ =~ e.args[0]
$optparser.warn(e)
- abort $optparser.to_s
+ abort opts.to_s
end
$destdir ||= ''
@@ -287,7 +298,7 @@ def parse_args()
$mflags.unshift(*rest) unless rest.empty?
def $mflags.set?(flag)
- grep(/\A-(?!-).*#{'%s' % flag}/i) { return true }
+ grep(/\A-(?!-).*#{flag.chr}/i) { return true }
false
end
def $mflags.defined?(var)
@@ -304,7 +315,7 @@ def parse_args()
$continue = $mflags.set?(?k)
if $extout
$extout = '$(topdir)/'+$extout
- RbConfig::CONFIG["extout"] = CONFIG["extout"] = $extout
+ Config::CONFIG["extout"] = CONFIG["extout"] = $extout
$extout_prefix = $extout ? "$(extout)$(target_prefix)/" : ""
$mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix"
end
@@ -343,20 +354,23 @@ elsif sep = config_string('BUILD_FILE_SEPARATOR')
else
$ruby = '$(topdir)/miniruby' + EXEEXT
end
-$ruby << " -I'$(topdir)' -I'$(top_srcdir)/lib'"
-$ruby << " -I'$(extout)/$(arch)' -I'$(extout)/common'" if $extout
-$ruby << " -I'$(top_srcdir)/ext' -rpurelib.rb"
-$config_h = '$(arch_hdrdir)/ruby/config.h'
-ENV["RUBYLIB"] = "-"
-ENV["RUBYOPT"] = "-rpurelib.rb"
+$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
+$config_h = '$(topdir)/config.h'
+$mflags << "ruby=#$ruby"
MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)}
# get static-link modules
$static_ext = {}
if $extstatic
- $extstatic.each do |t|
- target = t
+ $extstatic.each do |target|
target = target.downcase if /mswin32|bccwin32/ =~ RUBY_PLATFORM
$static_ext[target] = $static_ext.size
end
@@ -393,17 +407,17 @@ if $extension
exts |= $extension.select {|d| File.directory?("#{ext_prefix}/#{d}")}
else
withes, withouts = %w[--with --without].collect {|w|
- if not (w = %w[-extensions -ext].collect {|o|arg_config(w+o)}).any?
+ if not (w = %w[-extensions -ext].collect {|opt|arg_config(w+opt)}).any?
proc {false}
elsif (w = w.grep(String)).empty?
proc {true}
else
- w.collect {|o| o.split(/,/)}.flatten.method(:any?)
+ proc {|c1| w.collect {|opt| opt.split(/,/)}.flatten.any?(&c1)}
end
}
cond = proc {|ext|
cond1 = proc {|n| File.fnmatch(n, ext, File::FNM_PATHNAME)}
- withes.call(&cond1) or !withouts.call(&cond1)
+ withes.call(cond1) or !withouts.call(cond1)
}
exts |= Dir.glob("#{ext_prefix}/*/**/extconf.rb").collect {|d|
d = File.dirname(d)
@@ -415,7 +429,7 @@ else
end
if $extout
- extout = RbConfig.expand("#{$extout}", RbConfig::CONFIG.merge("topdir"=>$topdir))
+ extout = Config.expand("#{$extout}", Config::CONFIG.merge("topdir"=>$topdir))
unless $ignore
FileUtils.mkpath(extout)
end
@@ -426,7 +440,7 @@ FileUtils::makedirs('ext')
Dir::chdir('ext')
hdrdir = $hdrdir
-$hdrdir = ($top_srcdir = relative_from(srcdir, $topdir = "..")) + "/include"
+$hdrdir = $top_srcdir = relative_from(srcdir, $topdir = "..")
exts.each do |d|
extmake(d) or abort
end
@@ -487,17 +501,14 @@ unless $extlist.empty?
src = %{\
#include "ruby.h"
-#define init(func, name) { \\
- extern void func _((void)); \\
- ruby_init_ext(name, func); \\
-}
+#define init(func, name) {void func _((void)); ruby_init_ext(name, func);}
void ruby_init_ext _((const char *name, void (*init)(void)));
void Init_ext _((void))\n{\n#$extinit}
}
if !modified?(extinit.c, MTIMES) || IO.read(extinit.c) != src
- open(extinit.c, "w") {|fe| fe.print src}
+ open(extinit.c, "w") {|f| f.print src}
end
$extobjs = "ext/#{extinit.o} #{$extobjs}"
@@ -514,15 +525,15 @@ void Init_ext _((void))\n{\n#$extinit}
].map {|n, v|
"#{n}=#{v}" if v and !(v = v.strip).empty?
}.compact
- puts(*conf)
+ puts conf
$stdout.flush
$mflags.concat(conf)
else
FileUtils.rm_f(extinit.to_a)
end
rubies = []
-%w[RUBY RUBYW STATIC_RUBY].each {|n|
- r = n
+%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)
$mflags << "#{n}=#{r}"
@@ -549,7 +560,6 @@ if $nmake == ?b
vars.each {|flag| flag.sub!(/\A/, "-D")}
end
end
-$mflags.unshift("topdir=#$topdir")
system($make, *sysquote($mflags)) or exit($?.exitstatus)
#Local variables:
diff --git a/ext/fcntl/.cvsignore b/ext/fcntl/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/fcntl/.cvsignore
+++ b/ext/fcntl/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/fiber/extconf.rb b/ext/fiber/extconf.rb
deleted file mode 100644
index 904ab94a9c..0000000000
--- a/ext/fiber/extconf.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'mkmf'
-create_makefile('fiber')
-
diff --git a/ext/fiber/fiber.c b/ext/fiber/fiber.c
deleted file mode 100644
index 7c33a1f231..0000000000
--- a/ext/fiber/fiber.c
+++ /dev/null
@@ -1,8 +0,0 @@
-
-void Init_Fiber_as_Coroutine(void);
-
-void
-Init_fiber(void)
-{
- Init_Fiber_as_Coroutine();
-}
diff --git a/ext/gdbm/.cvsignore b/ext/gdbm/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/gdbm/.cvsignore
+++ b/ext/gdbm/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 7beffd2bdc..82109fda90 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -79,7 +79,8 @@ static VALUE rb_cGDBM, rb_eGDBMError, rb_eGDBMFatalError;
#define MY_BLOCK_SIZE (2048)
#define MY_FATAL_FUNC rb_gdbm_fatal
static void
-rb_gdbm_fatal(char *msg)
+rb_gdbm_fatal(msg)
+ char *msg;
{
rb_raise(rb_eGDBMFatalError, "%s", msg);
}
@@ -90,7 +91,7 @@ struct dbmdata {
};
static void
-closed_dbm(void)
+closed_dbm()
{
rb_raise(rb_eRuntimeError, "closed GDBM file");
}
@@ -107,7 +108,8 @@ closed_dbm(void)
}
static void
-free_dbm(struct dbmdata *dbmp)
+free_dbm(dbmp)
+ struct dbmdata *dbmp;
{
if (dbmp) {
if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
@@ -122,7 +124,8 @@ free_dbm(struct dbmdata *dbmp)
* Closes the associated database file.
*/
static VALUE
-fgdbm_close(VALUE obj)
+fgdbm_close(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
@@ -140,7 +143,8 @@ fgdbm_close(VALUE obj)
* Returns true if the associated database file has been closed.
*/
static VALUE
-fgdbm_closed(VALUE obj)
+fgdbm_closed(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
@@ -153,8 +157,11 @@ fgdbm_closed(VALUE obj)
return Qfalse;
}
+static VALUE fgdbm_s_alloc _((VALUE));
+
static VALUE
-fgdbm_s_alloc(VALUE klass)
+fgdbm_s_alloc(klass)
+ VALUE klass;
{
return Data_Wrap_Struct(klass, 0, free_dbm, 0);
}
@@ -183,7 +190,10 @@ fgdbm_s_alloc(VALUE klass)
* database file as a reader (cf. flag <tt>READER</tt>).
*/
static VALUE
-fgdbm_initialize(int argc, VALUE *argv, VALUE obj)
+fgdbm_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE file, vmode, vflags;
GDBM_FILE dbm;
@@ -207,31 +217,31 @@ fgdbm_initialize(int argc, VALUE *argv, VALUE obj)
if (flags & RUBY_GDBM_RW_BIT) {
flags &= ~RUBY_GDBM_RW_BIT;
- dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
- flags, mode, MY_FATAL_FUNC);
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
+ flags, mode, MY_FATAL_FUNC);
}
else {
dbm = 0;
if (mode >= 0)
- dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC);
if (!dbm)
- dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
GDBM_WRITER|flags, 0, MY_FATAL_FUNC);
if (!dbm)
- dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
GDBM_READER|flags, 0, MY_FATAL_FUNC);
}
if (!dbm) {
- if (mode == -1) return Qnil;
-
- if (gdbm_errno == GDBM_FILE_OPEN_ERROR ||
- gdbm_errno == GDBM_CANT_BE_READER ||
- gdbm_errno == GDBM_CANT_BE_WRITER)
- rb_sys_fail(RSTRING_PTR(file));
- else
- rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ if (mode == -1) return Qnil;
+
+ if (gdbm_errno == GDBM_FILE_OPEN_ERROR ||
+ gdbm_errno == GDBM_CANT_BE_READER ||
+ gdbm_errno == GDBM_CANT_BE_WRITER)
+ rb_sys_fail(RSTRING(file)->ptr);
+ else
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
dbmp = ALLOC(struct dbmdata);
@@ -263,12 +273,15 @@ fgdbm_initialize(int argc, VALUE *argv, VALUE obj)
* end
*/
static VALUE
-fgdbm_s_open(int argc, VALUE *argv, VALUE klass)
+fgdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
if (NIL_P(fgdbm_initialize(argc, argv, obj))) {
- return Qnil;
+ return Qnil;
}
if (rb_block_given_p()) {
@@ -279,7 +292,9 @@ fgdbm_s_open(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-rb_gdbm_fetch(GDBM_FILE dbm, datum key)
+rb_gdbm_fetch(dbm, key)
+ GDBM_FILE dbm;
+ datum key;
{
datum val;
VALUE str;
@@ -288,26 +303,33 @@ rb_gdbm_fetch(GDBM_FILE dbm, datum 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 (VALUE)str;
}
static VALUE
-rb_gdbm_fetch2(GDBM_FILE dbm, VALUE keystr)
+rb_gdbm_fetch2(dbm, keystr)
+ GDBM_FILE dbm;
+ VALUE keystr;
{
datum key;
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
return rb_gdbm_fetch(dbm, key);
}
static VALUE
-rb_gdbm_fetch3(VALUE obj, VALUE keystr)
+rb_gdbm_fetch3(obj, keystr)
+ VALUE obj, keystr;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -317,7 +339,8 @@ rb_gdbm_fetch3(VALUE obj, VALUE keystr)
}
static VALUE
-rb_gdbm_firstkey(GDBM_FILE dbm)
+rb_gdbm_firstkey(dbm)
+ GDBM_FILE dbm;
{
datum key;
VALUE str;
@@ -326,39 +349,51 @@ rb_gdbm_firstkey(GDBM_FILE 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;
}
static VALUE
-rb_gdbm_nextkey(GDBM_FILE dbm, VALUE keystr)
+rb_gdbm_nextkey(dbm, keystr)
+ GDBM_FILE dbm;
+ VALUE keystr;
{
datum key, key2;
VALUE str;
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
key2 = gdbm_nextkey(dbm, key);
if (key2.dptr == 0)
return Qnil;
- str = rb_str_new(key2.dptr, key2.dsize);
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = key2.dsize;
+ RSTRING(str)->aux.capa = key2.dsize;
+ RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1);
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
+
OBJ_TAINT(str);
return str;
}
static VALUE
-fgdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
+fgdbm_fetch(obj, keystr, ifnone)
+ VALUE obj, keystr, ifnone;
{
VALUE valstr;
valstr = rb_gdbm_fetch3(obj, keystr);
if (NIL_P(valstr)) {
- if (ifnone == Qnil && rb_block_given_p())
- return rb_yield(keystr);
- return ifnone;
+ if (ifnone == Qnil && rb_block_given_p())
+ return rb_yield(keystr);
+ return ifnone;
}
return valstr;
}
@@ -370,7 +405,8 @@ fgdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
* Retrieves the _value_ corresponding to _key_.
*/
static VALUE
-fgdbm_aref(VALUE obj, VALUE keystr)
+fgdbm_aref(obj, keystr)
+ VALUE obj, keystr;
{
return rb_gdbm_fetch3(obj, keystr);
}
@@ -383,7 +419,10 @@ fgdbm_aref(VALUE obj, VALUE keystr)
* associated with _key_, _default_ will be returned instead.
*/
static VALUE
-fgdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
+fgdbm_fetch_m(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE keystr, valstr, ifnone;
@@ -403,7 +442,8 @@ fgdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
* same value, the key that is found first will be returned.
*/
static VALUE
-fgdbm_index(VALUE obj, VALUE valstr)
+fgdbm_index(obj, valstr)
+ VALUE obj, valstr;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -414,17 +454,34 @@ fgdbm_index(VALUE obj, VALUE valstr)
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
- valstr2 = rb_gdbm_fetch2(dbm, keystr);
+ valstr2 = rb_gdbm_fetch2(dbm, keystr);
if (!NIL_P(valstr2) &&
- RSTRING_LEN(valstr) == RSTRING_LEN(valstr2) &&
- memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2),
- RSTRING_LEN(valstr)) == 0) {
- return keystr;
+ RSTRING(valstr)->len == RSTRING(valstr2)->len &&
+ memcmp(RSTRING(valstr)->ptr, RSTRING(valstr2)->ptr,
+ RSTRING(valstr)->len) == 0) {
+ return keystr;
}
}
return Qnil;
}
+static VALUE
+fgdbm_indexes(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new;
+ int i;
+
+ new = rb_ary_new2(argc);
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
+ }
+
+ return new;
+}
+
/*
* call-seq:
* gdbm.select { |value| block } -> array
@@ -433,23 +490,40 @@ fgdbm_index(VALUE obj, VALUE valstr)
* evaluates to true.
*/
static VALUE
-fgdbm_select(VALUE obj)
+fgdbm_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
- VALUE new = rb_ary_new();
- GDBM_FILE dbm;
- struct dbmdata *dbmp;
- VALUE keystr;
+ VALUE new = rb_ary_new2(argc);
+ int i;
- GetDBM2(obj, dbmp, dbm);
- for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
- keystr = rb_gdbm_nextkey(dbm, keystr)) {
- VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
- VALUE v = rb_yield(assoc);
+ if (rb_block_given_p()) {
+ GDBM_FILE dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr;
- if (RTEST(v)) {
- rb_ary_push(new, assoc);
- }
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
+ }
GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+ VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
+ VALUE v = rb_yield(assoc);
+
+ if (RTEST(v)) {
+ rb_ary_push(new, assoc);
+ }
+ GetDBM2(obj, dbmp, dbm);
+ }
+ }
+ else {
+ rb_warn("GDBM#select(index..) is deprecated; use GDBM#values_at");
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
+ }
}
return new;
@@ -462,7 +536,10 @@ fgdbm_select(VALUE obj)
* Returns an array of the values associated with each specified _key_.
*/
static VALUE
-fgdbm_values_at(int argc, VALUE *argv, VALUE obj)
+fgdbm_values_at(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE new = rb_ary_new2(argc);
int i;
@@ -475,14 +552,16 @@ fgdbm_values_at(int argc, VALUE *argv, VALUE obj)
}
static void
-rb_gdbm_modify(VALUE obj)
+rb_gdbm_modify(obj)
+ VALUE obj;
{
rb_secure(4);
if (OBJ_FROZEN(obj)) rb_error_frozen("GDBM");
}
static VALUE
-rb_gdbm_delete(VALUE obj, VALUE keystr)
+rb_gdbm_delete(obj, keystr)
+ VALUE obj, keystr;
{
datum key;
struct dbmdata *dbmp;
@@ -490,8 +569,8 @@ rb_gdbm_delete(VALUE obj, VALUE keystr)
rb_gdbm_modify(obj);
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
if (!gdbm_exists(dbm, key)) {
@@ -516,7 +595,8 @@ rb_gdbm_delete(VALUE obj, VALUE keystr)
* returns the corresponding _value_. Returns nil if the database is empty.
*/
static VALUE
-fgdbm_delete(VALUE obj, VALUE keystr)
+fgdbm_delete(obj, keystr)
+ VALUE obj, keystr;
{
VALUE valstr;
@@ -533,7 +613,8 @@ fgdbm_delete(VALUE obj, VALUE keystr)
* two-item array [ _key_, _value_ ]. Returns nil if the database is empty.
*/
static VALUE
-fgdbm_shift(VALUE obj)
+fgdbm_shift(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -557,7 +638,8 @@ fgdbm_shift(VALUE obj)
* Deletes every key-value pair from _gdbm_ for which _block_ evaluates to true.
*/
static VALUE
-fgdbm_delete_if(VALUE obj)
+fgdbm_delete_if(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -580,10 +662,10 @@ fgdbm_delete_if(VALUE obj)
GetDBM2(obj, dbmp, dbm);
}
- for (i = 0; i < RARRAY_LEN(ary); i++)
- rb_gdbm_delete(obj, RARRAY_PTR(ary)[i]);
+ for (i = 0; i < RARRAY(ary)->len; i++)
+ rb_gdbm_delete(obj, RARRAY(ary)->ptr[i]);
if (status) rb_jump_tag(status);
- if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
+ if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
return obj;
}
@@ -595,7 +677,8 @@ fgdbm_delete_if(VALUE obj)
* Removes all the key-value pairs within _gdbm_.
*/
static VALUE
-fgdbm_clear(VALUE obj)
+fgdbm_clear(obj)
+ VALUE obj;
{
datum key, nextkey;
struct dbmdata *dbmp;
@@ -639,7 +722,8 @@ fgdbm_clear(VALUE obj)
* as values.
*/
static VALUE
-fgdbm_invert(VALUE obj)
+fgdbm_invert(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -649,55 +733,33 @@ fgdbm_invert(VALUE obj)
GetDBM2(obj, dbmp, dbm);
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);
- rb_hash_aset(hash, valstr, keystr);
+ rb_hash_aset(hash, valstr, keystr);
}
return hash;
}
-/*
- * call-seq:
- * gdbm[key]= value -> value
- * gdbm.store(key, value) -> value
- *
- * Associates the value _value_ with the specified _key_.
- */
+static VALUE each_pair _((VALUE));
+
static VALUE
-fgdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
+each_pair(obj)
+ VALUE obj;
{
- datum key, val;
- struct dbmdata *dbmp;
- GDBM_FILE dbm;
-
- rb_gdbm_modify(obj);
- StringValue(keystr);
- StringValue(valstr);
-
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
-
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(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));
- }
-
- return valstr;
+ return rb_funcall(obj, rb_intern("each_pair"), 0, 0);
}
+static VALUE fgdbm_store _((VALUE,VALUE,VALUE));
+
static VALUE
-update_i(VALUE pair, VALUE dbm)
+update_i(pair, dbm)
+ VALUE pair, dbm;
{
Check_Type(pair, T_ARRAY);
- if (RARRAY_LEN(pair) < 2) {
- rb_raise(rb_eArgError, "pair must be [key, value]");
+ if (RARRAY(pair)->len < 2) {
+ rb_raise(rb_eArgError, "pair must be [key, value]");
}
- fgdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
+ fgdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
return Qnil;
}
@@ -710,9 +772,10 @@ update_i(VALUE pair, VALUE dbm)
* method.
*/
static VALUE
-fgdbm_update(VALUE obj, VALUE other)
+fgdbm_update(obj, other)
+ VALUE obj, other;
{
- rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ rb_iterate(each_pair, other, update_i, obj);
return obj;
}
@@ -724,22 +787,59 @@ fgdbm_update(VALUE obj, VALUE other)
* _other_ must have an each_pair method.
*/
static VALUE
-fgdbm_replace(VALUE obj, VALUE other)
+fgdbm_replace(obj, other)
+ VALUE obj, other;
{
fgdbm_clear(obj);
- rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ rb_iterate(each_pair, other, update_i, obj);
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;
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ rb_gdbm_modify(obj);
+ StringValue(keystr);
+ StringValue(valstr);
+
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
+
+ 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));
+ }
+
+ return valstr;
+}
+
+/*
+ * call-seq:
* gdbm.length -> fixnum
* gdbm.size -> fixnum
*
* Returns the number of key-value pairs in this database.
*/
static VALUE
-fgdbm_length(VALUE obj)
+fgdbm_length(obj)
+ VALUE obj;
{
datum key, nextkey;
struct dbmdata *dbmp;
@@ -752,7 +852,7 @@ fgdbm_length(VALUE obj)
for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
nextkey = gdbm_nextkey(dbm, key);
free(key.dptr);
- i++;
+ i++;
}
dbmp->di_size = i;
@@ -766,7 +866,8 @@ fgdbm_length(VALUE obj)
* Returns true if the database is empty.
*/
static VALUE
-fgdbm_empty_p(VALUE obj)
+fgdbm_empty_p(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -774,13 +875,13 @@ fgdbm_empty_p(VALUE obj)
GetDBM(obj, dbmp);
if (dbmp->di_size < 0) {
- dbm = dbmp->di_dbm;
+ dbm = dbmp->di_dbm;
- key = gdbm_firstkey(dbm);
+ key = gdbm_firstkey(dbm);
if (key.dptr) {
free(key.dptr);
return Qfalse;
- }
+ }
return Qtrue;
}
@@ -796,7 +897,8 @@ fgdbm_empty_p(VALUE obj)
* _value_ as a parameter.
*/
static VALUE
-fgdbm_each_value(VALUE obj)
+fgdbm_each_value(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -807,7 +909,7 @@ fgdbm_each_value(VALUE obj)
keystr = rb_gdbm_nextkey(dbm, keystr)) {
rb_yield(rb_gdbm_fetch2(dbm, keystr));
- GetDBM2(obj, dbmp, dbm);
+ GetDBM2(obj, dbmp, dbm);
}
return obj;
}
@@ -820,7 +922,8 @@ fgdbm_each_value(VALUE obj)
* _key_ as a parameter.
*/
static VALUE
-fgdbm_each_key(VALUE obj)
+fgdbm_each_key(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -831,7 +934,7 @@ fgdbm_each_key(VALUE obj)
keystr = rb_gdbm_nextkey(dbm, keystr)) {
rb_yield(keystr);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM2(obj, dbmp, dbm);
}
return obj;
}
@@ -844,7 +947,8 @@ fgdbm_each_key(VALUE obj)
* correspoding _value_ as a parameter.
*/
static VALUE
-fgdbm_each_pair(VALUE obj)
+fgdbm_each_pair(obj)
+ VALUE obj;
{
GDBM_FILE dbm;
struct dbmdata *dbmp;
@@ -868,7 +972,8 @@ fgdbm_each_pair(VALUE obj)
* Returns an array of all keys of this database.
*/
static VALUE
-fgdbm_keys(VALUE obj)
+fgdbm_keys(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -892,7 +997,8 @@ fgdbm_keys(VALUE obj)
* Returns an array of all values of this database.
*/
static VALUE
-fgdbm_values(VALUE obj)
+fgdbm_values(obj)
+ VALUE obj;
{
datum key, nextkey;
struct dbmdata *dbmp;
@@ -920,15 +1026,16 @@ fgdbm_values(VALUE obj)
* Returns false otherwise.
*/
static VALUE
-fgdbm_has_key(VALUE obj, VALUE keystr)
+fgdbm_has_key(obj, keystr)
+ VALUE obj, keystr;
{
datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
if (gdbm_exists(dbm, key))
@@ -945,7 +1052,8 @@ fgdbm_has_key(VALUE obj, VALUE keystr)
* Returns false otherwise.
*/
static VALUE
-fgdbm_has_value(VALUE obj, VALUE valstr)
+fgdbm_has_value(obj, valstr)
+ VALUE obj, valstr;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -956,13 +1064,13 @@ fgdbm_has_value(VALUE obj, VALUE valstr)
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
- valstr2 = rb_gdbm_fetch2(dbm, keystr);
+ valstr2 = rb_gdbm_fetch2(dbm, keystr);
if (!NIL_P(valstr2) &&
- RSTRING_LEN(valstr) == RSTRING_LEN(valstr2) &&
- memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2),
- RSTRING_LEN(valstr)) == 0) {
- return Qtrue;
+ RSTRING(valstr)->len == RSTRING(valstr2)->len &&
+ memcmp(RSTRING(valstr)->ptr, RSTRING(valstr2)->ptr,
+ RSTRING(valstr)->len) == 0) {
+ return Qtrue;
}
}
return Qfalse;
@@ -975,7 +1083,8 @@ fgdbm_has_value(VALUE obj, VALUE valstr)
* Returns an array of all key-value pairs contained in the database.
*/
static VALUE
-fgdbm_to_a(VALUE obj)
+fgdbm_to_a(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -1001,7 +1110,8 @@ fgdbm_to_a(VALUE obj)
* deletions in the database.
*/
static VALUE
-fgdbm_reorganize(VALUE obj)
+fgdbm_reorganize(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -1023,7 +1133,8 @@ fgdbm_reorganize(VALUE obj)
* to the disk have been finished.
*/
static VALUE
-fgdbm_sync(VALUE obj)
+fgdbm_sync(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -1041,7 +1152,8 @@ fgdbm_sync(VALUE obj)
* Sets the size of the internal bucket cache to _size_.
*/
static VALUE
-fgdbm_set_cachesize(VALUE obj, VALUE val)
+fgdbm_set_cachesize(obj, val)
+ VALUE obj, val;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -1066,7 +1178,8 @@ fgdbm_set_cachesize(VALUE obj, VALUE val)
* default. See also: #syncmode=
*/
static VALUE
-fgdbm_set_fastmode(VALUE obj, VALUE val)
+fgdbm_set_fastmode(obj, val)
+ VALUE obj, val;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -1097,7 +1210,8 @@ fgdbm_set_fastmode(VALUE obj, VALUE val)
* by default. See also: #fastmode=
*/
static VALUE
-fgdbm_set_syncmode(VALUE obj, VALUE val)
+fgdbm_set_syncmode(obj, val)
+ VALUE obj, val;
{
#if !defined(GDBM_SYNCMODE)
fgdbm_set_fastmode(obj, RTEST(val) ? Qfalse : Qtrue);
@@ -1126,7 +1240,8 @@ fgdbm_set_syncmode(VALUE obj, VALUE val)
* Returns a hash of all key-value pairs contained in the database.
*/
static VALUE
-fgdbm_to_hash(VALUE obj)
+fgdbm_to_hash(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
@@ -1151,13 +1266,14 @@ fgdbm_to_hash(VALUE obj)
* which _block_ evaluates to true are removed. See also: #delete_if
*/
static VALUE
-fgdbm_reject(VALUE obj)
+fgdbm_reject(obj)
+ VALUE obj;
{
return rb_hash_delete_if(fgdbm_to_hash(obj));
}
void
-Init_gdbm(void)
+Init_gdbm()
{
rb_cGDBM = rb_define_class("GDBM", rb_cObject);
rb_eGDBMError = rb_define_class("GDBMError", rb_eStandardError);
@@ -1175,7 +1291,9 @@ Init_gdbm(void)
rb_define_method(rb_cGDBM, "[]=", fgdbm_store, 2);
rb_define_method(rb_cGDBM, "store", fgdbm_store, 2);
rb_define_method(rb_cGDBM, "index", fgdbm_index, 1);
- rb_define_method(rb_cGDBM, "select", fgdbm_select, 0);
+ rb_define_method(rb_cGDBM, "indexes", fgdbm_indexes, -1);
+ rb_define_method(rb_cGDBM, "indices", fgdbm_indexes, -1);
+ rb_define_method(rb_cGDBM, "select", fgdbm_select, -1);
rb_define_method(rb_cGDBM, "values_at", fgdbm_values_at, -1);
rb_define_method(rb_cGDBM, "length", fgdbm_length, 0);
rb_define_method(rb_cGDBM, "size", fgdbm_length, 0);
diff --git a/ext/iconv/.cvsignore b/ext/iconv/.cvsignore
index 66c8f5297a..394787fced 100644
--- a/ext/iconv/.cvsignore
+++ b/ext/iconv/.cvsignore
@@ -3,4 +3,3 @@ mkmf.log
*.def
iconv.rb
config.charset
-extconf.h
diff --git a/ext/iconv/charset_alias.rb b/ext/iconv/charset_alias.rb
index d4ed9139c8..aed4644290 100644
--- a/ext/iconv/charset_alias.rb
+++ b/ext/iconv/charset_alias.rb
@@ -6,8 +6,8 @@ require 'optparse'
# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
# Fri, 30 May 2003 00:09:00 GMT'
-OS = RbConfig::CONFIG["target_os"]
-SHELL = RbConfig::CONFIG['SHELL']
+OS = Config::CONFIG["target_os"]
+SHELL = Config::CONFIG['SHELL']
class Hash::Ordered < Hash
def [](key)
diff --git a/ext/iconv/depend b/ext/iconv/depend
index ac555596ce..688ddd97b7 100644
--- a/ext/iconv/depend
+++ b/ext/iconv/depend
@@ -1,2 +1,2 @@
iconv.o: iconv.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h \
- $(hdrdir)/st.h $(hdrdir)/intern.h $(hdrdir)/encoding.h
+ $(hdrdir)/intern.h
diff --git a/ext/iconv/extconf.rb b/ext/iconv/extconf.rb
index 9632bf4db9..a9d0cfb5e6 100644
--- a/ext/iconv/extconf.rb
+++ b/ext/iconv/extconf.rb
@@ -23,8 +23,6 @@ if have_func("iconv", "iconv.h") or
end
$defs.push('-DICONV_INPTR_CONST')
end
- have_func("iconvlist", "iconv.h")
- have_func("__iconv_free_list", "iconv.h")
if conf
prefix = '$(srcdir)'
prefix = $nmake ? "{#{prefix}}" : "#{prefix}/"
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index fbbca7e3b9..d989b97df2 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -14,13 +14,12 @@
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <errno.h>
#include <iconv.h>
#include <assert.h>
-#include "ruby/st.h"
-#include "ruby/intern.h"
-#include "ruby/encoding.h"
+#include "st.h"
+#include "intern.h"
/*
* Document-class: Iconv
@@ -81,18 +80,9 @@ struct iconv_env_t
int argc;
VALUE *argv;
VALUE ret;
- int toidx;
VALUE (*append)_((VALUE, VALUE));
};
-struct rb_iconv_opt_t
-{
- VALUE transliterate;
- VALUE discard_ilseq;
-};
-
-static ID id_transliterate, id_discard_ilseq;
-
static VALUE rb_eIconvInvalidEncoding;
static VALUE rb_eIconvFailure;
static VALUE rb_eIconvIllegalSeq;
@@ -106,21 +96,20 @@ static VALUE iconv_failure_initialize _((VALUE error, VALUE mesg, VALUE success,
static VALUE iconv_failure_success _((VALUE self));
static VALUE iconv_failure_failed _((VALUE self));
-static iconv_t iconv_create _((VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx));
+static iconv_t iconv_create _((VALUE to, VALUE from));
static void iconv_dfree _((void *cd));
static VALUE iconv_free _((VALUE cd));
static VALUE iconv_try _((iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen));
static VALUE rb_str_derive _((VALUE str, const char* ptr, int len));
-static VALUE iconv_convert _((iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env));
+static VALUE iconv_convert _((iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env));
static VALUE iconv_s_allocate _((VALUE klass));
-static VALUE iconv_initialize _((int argc, VALUE *argv, VALUE self));
-static VALUE iconv_s_open _((int argc, VALUE *argv, VALUE self));
+static VALUE iconv_initialize _((VALUE self, VALUE to, VALUE from));
+static VALUE iconv_s_open _((VALUE self, VALUE to, VALUE from));
static VALUE iconv_s_convert _((struct iconv_env_t* env));
static VALUE iconv_s_iconv _((int argc, VALUE *argv, VALUE self));
static VALUE iconv_init_state _((VALUE cd));
static VALUE iconv_finish _((VALUE self));
static VALUE iconv_iconv _((int argc, VALUE *argv, VALUE self));
-static VALUE iconv_conv _((int argc, VALUE *argv, VALUE self));
static VALUE charset_map;
@@ -130,20 +119,26 @@ static VALUE charset_map;
*
* Returns the map from canonical name to system dependent name.
*/
-static VALUE charset_map_get(void)
+static VALUE charset_map_get _((void))
{
return charset_map;
}
static char *
-map_charset(VALUE *code)
+map_charset
+#ifdef HAVE_PROTOTYPES
+ (VALUE *code)
+#else /* HAVE_PROTOTYPES */
+ (code)
+ VALUE *code;
+#endif /* HAVE_PROTOTYPES */
{
VALUE val = *code;
- if (RHASH_SIZE(charset_map)) {
+ if (RHASH(charset_map)->tbl && RHASH(charset_map)->tbl->num_entries) {
VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0);
StringValuePtr(key);
- if (st_lookup(RHASH_TBL(charset_map), key, &val)) {
+ if (st_lookup(RHASH(charset_map)->tbl, key, &val)) {
*code = val;
}
}
@@ -151,15 +146,20 @@ map_charset(VALUE *code)
}
static iconv_t
-iconv_create(VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx)
+iconv_create
+#ifdef HAVE_PROTOTYPES
+ (VALUE to, VALUE from)
+#else /* HAVE_PROTOTYPES */
+ (to, from)
+ VALUE to;
+ VALUE from;
+#endif /* HAVE_PROTOTYPES */
{
const char* tocode = map_charset(&to);
const char* fromcode = map_charset(&from);
- iconv_t cd;
- *idx = rb_enc_find_index(tocode);
+ iconv_t cd = iconv_open(tocode, fromcode);
- cd = iconv_open(tocode, fromcode);
if (cd == (iconv_t)-1) {
switch (errno) {
case EMFILE:
@@ -171,41 +171,30 @@ iconv_create(VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx)
if (cd == (iconv_t)-1) {
int inval = errno == EINVAL;
const char *s = inval ? "invalid encoding " : "iconv";
- volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING_LEN(to) +
- RSTRING_LEN(from) + 8);
+ volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
+ RSTRING(from)->len + 8);
- sprintf(RSTRING_PTR(msg), "%s(\"%s\", \"%s\")",
- s, RSTRING_PTR(to), RSTRING_PTR(from));
- s = RSTRING_PTR(msg);
- rb_str_set_len(msg, strlen(s));
+ sprintf(RSTRING(msg)->ptr, "%s(\"%s\", \"%s\")",
+ s, RSTRING(to)->ptr, RSTRING(from)->ptr);
+ s = RSTRING(msg)->ptr;
+ RSTRING(msg)->len = strlen(s);
if (!inval) rb_sys_fail(s);
iconv_fail(rb_eIconvInvalidEncoding,
Qnil, rb_ary_new3(2, to, from), NULL, s);
}
}
- if (opt) {
-#ifdef ICONV_SET_TRANSLITERATE
- if (opt->transliterate != Qundef) {
- int flag = RTEST(opt->transliterate);
- if (iconvctl(cd, ICONV_SET_TRANSLITERATE, (void *)&flag))
- rb_sys_fail("ICONV_SET_TRANSLITERATE");
- }
-#endif
-#ifdef ICONV_SET_DISCARD_ILSEQ
- if (opt->discard_ilseq != Qundef) {
- int flag = RTEST(opt->discard_ilseq);
- if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&flag))
- rb_sys_fail("ICONV_SET_DISCARD_ILSEQ");
- }
-#endif
- }
-
return cd;
}
static void
-iconv_dfree(void *cd)
+iconv_dfree
+#ifdef HAVE_PROTOTYPES
+ (void *cd)
+#else /* HAVE_PROTOTYPES */
+ (cd)
+ void *cd;
+#endif /* HAVE_PROTOTYPES */
{
iconv_close(VALUE2ICONV(cd));
}
@@ -213,7 +202,13 @@ iconv_dfree(void *cd)
#define ICONV_FREE iconv_dfree
static VALUE
-iconv_free(VALUE cd)
+iconv_free
+#ifdef HAVE_PROTOTYPES
+ (VALUE cd)
+#else /* HAVE_PROTOTYPES */
+ (cd)
+ VALUE cd;
+#endif /* HAVE_PROTOTYPES */
{
if (cd && iconv_close(VALUE2ICONV(cd)) == -1)
rb_sys_fail("iconv_close");
@@ -221,7 +216,13 @@ iconv_free(VALUE cd)
}
static VALUE
-check_iconv(VALUE obj)
+check_iconv
+#ifdef HAVE_PROTOTYPES
+ (VALUE obj)
+#else /* HAVE_PROTOTYPES */
+ (obj)
+ VALUE obj;
+#endif /* HAVE_PROTOTYPES */
{
Check_Type(obj, T_DATA);
if (RDATA(obj)->dfree != ICONV_FREE) {
@@ -231,7 +232,17 @@ check_iconv(VALUE obj)
}
static VALUE
-iconv_try(iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen)
+iconv_try
+#ifdef HAVE_PROTOTYPES
+ (iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen)
+#else /* HAVE_PROTOTYPES */
+ (cd, inptr, inlen, outptr, outlen)
+ iconv_t cd;
+ const char **inptr;
+ size_t *inlen;
+ char **outptr;
+ size_t *outlen;
+#endif /* HAVE_PROTOTYPES */
{
#ifdef ICONV_INPTR_CONST
#define ICONV_INPTR_CAST
@@ -271,7 +282,13 @@ iconv_try(iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *
#define FAILED_MAXLEN 16
-static VALUE iconv_failure_initialize(VALUE error, VALUE mesg, VALUE success, VALUE failed)
+static VALUE iconv_failure_initialize
+#ifdef HAVE_PROTOTYPES
+ (VALUE error, VALUE mesg, VALUE success, VALUE failed)
+#else /* HAVE_PROTOTYPES */
+ (error, mesg, success, failed)
+ VALUE error, mesg, success, failed;
+#endif /* HAVE_PROTOTYPES */
{
rb_call_super(1, &mesg);
rb_ivar_set(error, rb_success, success);
@@ -280,14 +297,22 @@ static VALUE iconv_failure_initialize(VALUE error, VALUE mesg, VALUE success, VA
}
static VALUE
-iconv_fail(VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg)
+iconv_fail
+#ifdef HAVE_PROTOTYPES
+ (VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg)
+#else /* HAVE_PROTOTYPES */
+ (error, success, failed, env, mesg)
+ VALUE error, success, failed;
+ struct iconv_env_t *env;
+ const char *mesg;
+#endif /* HAVE_PROTOTYPES */
{
VALUE args[3];
if (mesg && *mesg) {
args[0] = rb_str_new2(mesg);
}
- else if (TYPE(failed) != T_STRING || RSTRING_LEN(failed) < FAILED_MAXLEN) {
+ else if (TYPE(failed) != T_STRING || RSTRING(failed)->len < FAILED_MAXLEN) {
args[0] = rb_inspect(failed);
}
else {
@@ -305,19 +330,29 @@ iconv_fail(VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, co
}
error = rb_class_new_instance(3, args, error);
if (!rb_block_given_p()) rb_exc_raise(error);
- rb_set_errinfo(error);
+ ruby_errinfo = error;
return rb_yield(failed);
}
static VALUE
-rb_str_derive(VALUE str, const char* ptr, int len)
+rb_str_derive
+#ifdef HAVE_PROTOTYPES
+ (VALUE str, const char* ptr, int len)
+#else /* HAVE_PROTOTYPES */
+ (str, ptr, len)
+ VALUE str;
+ const char *ptr;
+ int len;
+#endif /* HAVE_PROTOTYPES */
{
VALUE ret;
if (NIL_P(str))
return rb_str_new(ptr, len);
- if (RSTRING_PTR(str) + RSTRING_LEN(str) == ptr + len)
- ret = rb_str_substr(str, ptr - RSTRING_PTR(str), len);
+ if (RSTRING(str)->ptr == ptr && RSTRING(str)->len == len)
+ return str;
+ if (RSTRING(str)->ptr + RSTRING(str)->len == ptr + len)
+ ret = rb_str_substr(str, ptr - RSTRING(str)->ptr, len);
else
ret = rb_str_new(ptr, len);
OBJ_INFECT(ret, str);
@@ -325,7 +360,17 @@ rb_str_derive(VALUE str, const char* ptr, int len)
}
static VALUE
-iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env)
+iconv_convert
+#ifdef HAVE_PROTOTYPES
+ (iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env)
+#else /* HAVE_PROTOTYPES */
+ (cd, str, start, length, env)
+ iconv_t cd;
+ VALUE str;
+ long start;
+ long length;
+ struct iconv_env_t *env;
+#endif /* HAVE_PROTOTYPES */
{
VALUE ret = Qfalse;
VALUE error = Qfalse;
@@ -336,13 +381,10 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
char buffer[BUFSIZ];
char *outptr;
size_t outlen;
- int toidx = -1;
if (cd == (iconv_t)-1)
rb_raise(rb_eArgError, "closed iconv");
- if (env) toidx = env->toidx;
-
if (NIL_P(str)) {
/* Reset output pointer or something. */
inptr = "";
@@ -354,7 +396,7 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
unsigned int i;
rescue = iconv_fail(error, Qnil, Qnil, env, 0);
if (TYPE(rescue) == T_ARRAY) {
- str = RARRAY_LEN(rescue) > 0 ? RARRAY_PTR(rescue)[0] : Qnil;
+ str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil;
}
if (FIXNUM_P(str) && (i = FIX2INT(str)) <= 0xff) {
char c = i;
@@ -372,17 +414,12 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
int slen;
StringValue(str);
- slen = RSTRING_LEN(str);
- inptr = RSTRING_PTR(str);
-
- 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;
+ slen = RSTRING(str)->len;
+ inptr = RSTRING(str)->ptr;
+
+ inptr += start;
+ if (length < 0 || length > start + slen)
+ length = slen - start;
}
instart = inptr;
inlen = length;
@@ -405,7 +442,6 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
{
if (NIL_P(str)) {
ret = rb_str_new(buffer, outlen);
- if (toidx >= 0) rb_enc_associate_index(ret, toidx);
}
else {
if (ret) {
@@ -413,7 +449,6 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
}
else {
ret = rb_str_new(instart, tmpstart - instart);
- if (toidx >= 0) rb_enc_associate_index(ret, toidx);
OBJ_INFECT(ret, str);
}
ret = rb_str_buf_cat(ret, buffer, outlen);
@@ -433,22 +468,19 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
if (RTEST(error)) {
long len = 0;
- if (!ret) {
+ if (!ret)
ret = rb_str_derive(str, instart, inptr - instart);
- if (toidx >= 0) rb_enc_associate_index(ret, toidx);
- }
- else if (inptr > instart) {
+ else if (inptr > instart)
rb_str_cat(ret, instart, inptr - instart);
- }
str = rb_str_derive(str, inptr, inlen);
rescue = iconv_fail(error, ret, str, env, errmsg);
if (TYPE(rescue) == T_ARRAY) {
- if ((len = RARRAY_LEN(rescue)) > 0)
- rb_str_concat(ret, RARRAY_PTR(rescue)[0]);
- if (len > 1 && !NIL_P(str = RARRAY_PTR(rescue)[1])) {
+ if ((len = RARRAY(rescue)->len) > 0)
+ rb_str_concat(ret, RARRAY(rescue)->ptr[0]);
+ if (len > 1 && !NIL_P(str = RARRAY(rescue)->ptr[1])) {
StringValue(str);
- inlen = length = RSTRING_LEN(str);
- instart = inptr = RSTRING_PTR(str);
+ inlen = length = RSTRING(str)->len;
+ instart = inptr = RSTRING(str)->ptr;
continue;
}
}
@@ -459,94 +491,28 @@ iconv_convert(iconv_t cd, VALUE str, int start, int length, struct iconv_env_t*
}
} while (inlen > 0);
- if (!ret) {
+ if (!ret)
ret = rb_str_derive(str, instart, inptr - instart);
- if (toidx >= 0) rb_enc_associate_index(ret, toidx);
- }
- else if (inptr > instart) {
+ else if (inptr > instart)
rb_str_cat(ret, instart, inptr - instart);
- }
return ret;
}
static VALUE
-iconv_s_allocate(VALUE klass)
+iconv_s_allocate
+#ifdef HAVE_PROTOTYPES
+ (VALUE klass)
+#else /* HAVE_PROTOTYPES */
+ (klass)
+ VALUE klass;
+#endif /* HAVE_PROTOTYPES */
{
return Data_Wrap_Struct(klass, 0, ICONV_FREE, 0);
}
-static VALUE
-get_iconv_opt_i(VALUE i, VALUE arg)
-{
- struct rb_iconv_opt_t *opt = (struct rb_iconv_opt_t *)arg;
- VALUE name, val;
-
- (void)opt;
- i = rb_Array(i);
- name = rb_ary_entry(i, 0);
- val = rb_ary_entry(i, 1);
- do {
- if (SYMBOL_P(name)) {
- ID id = SYM2ID(name);
- if (id == id_transliterate) {
-#ifdef ICONV_SET_TRANSLITERATE
- opt->transliterate = val;
-#else
- rb_notimplement();
-#endif
- break;
- }
- if (id == id_discard_ilseq) {
-#ifdef ICONV_SET_DISCARD_ILSEQ
- opt->discard_ilseq = val;
-#else
- rb_notimplement();
-#endif
- break;
- }
- }
- else {
- const char *s = StringValueCStr(name);
- if (strcmp(s, "transliterate") == 0) {
-#ifdef ICONV_SET_TRANSLITERATE
- opt->transliterate = val;
-#else
- rb_notimplement();
-#endif
- break;
- }
- if (strcmp(s, "discard_ilseq") == 0) {
-#ifdef ICONV_SET_DISCARD_ILSEQ
- opt->discard_ilseq = val;
-#else
- rb_notimplement();
-#endif
- break;
- }
- }
- name = rb_inspect(name);
- rb_raise(rb_eArgError, "unknown option - %s", StringValueCStr(name));
- } while (0);
- return Qnil;
-}
-
-static void
-get_iconv_opt(struct rb_iconv_opt_t *opt, VALUE options)
-{
- opt->transliterate = Qundef;
- opt->discard_ilseq = Qundef;
- if (!NIL_P(options)) {
- rb_block_call(options, rb_intern("each"), 0, 0, get_iconv_opt_i, (VALUE)opt);
- }
-}
-
-#define iconv_ctl(self, func, val) (\
- iconvctl(VALUE2ICONV(check_iconv(self)), func, (void *)&(val)) ? \
- rb_sys_fail(#func) : (void)0)
-
/*
* Document-method: new
- * call-seq: Iconv.new(to, from, [options])
+ * call-seq: Iconv.new(to, from)
*
* Creates new code converter from a coding-system designated with +from+
* to another one designated with +to+.
@@ -555,7 +521,6 @@ get_iconv_opt(struct rb_iconv_opt_t *opt, VALUE options)
*
* +to+:: encoding name for destination
* +from+:: encoding name for source
- * +options+:: options for converter
*
* === Exceptions
*
@@ -564,18 +529,19 @@ get_iconv_opt(struct rb_iconv_opt_t *opt, VALUE options)
* SystemCallError:: if <tt>iconv_open(3)</tt> fails
*/
static VALUE
-iconv_initialize(int argc, VALUE *argv, VALUE self)
+iconv_initialize
+#ifdef HAVE_PROTOTYPES
+ (VALUE self, VALUE to, VALUE from)
+#else /* HAVE_PROTOTYPES */
+ (self, to, from)
+ VALUE self;
+ VALUE to;
+ VALUE from;
+#endif /* HAVE_PROTOTYPES */
{
- VALUE to, from, options;
- struct rb_iconv_opt_t opt;
- int idx;
-
- rb_scan_args(argc, argv, "21", &to, &from, &options);
- get_iconv_opt(&opt, options);
iconv_free(check_iconv(self));
DATA_PTR(self) = NULL;
- DATA_PTR(self) = (void *)ICONV2VALUE(iconv_create(to, from, &opt, &idx));
- if (idx >= 0) ENCODING_SET(self, idx);
+ DATA_PTR(self) = (void *)ICONV2VALUE(iconv_create(to, from));
return self;
}
@@ -588,19 +554,19 @@ iconv_initialize(int argc, VALUE *argv, VALUE self)
* returned from the block.
*/
static VALUE
-iconv_s_open(int argc, VALUE *argv, VALUE self)
-{
- VALUE to, from, options, cd;
- struct rb_iconv_opt_t opt;
- int idx;
-
- rb_scan_args(argc, argv, "21", &to, &from, &options);
- get_iconv_opt(&opt, options);
- cd = ICONV2VALUE(iconv_create(to, from, &opt, &idx));
+iconv_s_open
+#ifdef HAVE_PROTOTYPES
+ (VALUE self, VALUE to, VALUE from)
+#else /* HAVE_PROTOTYPES */
+ (self, to, from)
+ VALUE self;
+ VALUE to;
+ VALUE from;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE cd = ICONV2VALUE(iconv_create(to, from));
self = Data_Wrap_Struct(self, NULL, ICONV_FREE, (void *)cd);
- if (idx >= 0) ENCODING_SET(self, idx);
-
if (rb_block_given_p()) {
return rb_ensure(rb_yield, self, (VALUE(*)())iconv_finish, self);
}
@@ -610,7 +576,13 @@ iconv_s_open(int argc, VALUE *argv, VALUE self)
}
static VALUE
-iconv_s_convert(struct iconv_env_t* env)
+iconv_s_convert
+#ifdef HAVE_PROTOTYPES
+ (struct iconv_env_t* env)
+#else /* HAVE_PROTOTYPES */
+ (env)
+ struct iconv_env_t *env;
+#endif /* HAVE_PROTOTYPES */
{
VALUE last = 0;
@@ -621,7 +593,7 @@ iconv_s_convert(struct iconv_env_t* env)
if (!NIL_P(last)) {
VALUE s = iconv_convert(env->cd, Qnil, 0, 0, env);
- if (RSTRING_LEN(s))
+ if (RSTRING(s)->len)
env->append(env->ret, s);
}
@@ -647,7 +619,15 @@ iconv_s_convert(struct iconv_env_t* env)
* Exceptions thrown by Iconv.new, Iconv.open and Iconv#iconv.
*/
static VALUE
-iconv_s_iconv(int argc, VALUE *argv, VALUE self)
+iconv_s_iconv
+#ifdef HAVE_PROTOTYPES
+ (int argc, VALUE *argv, VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
{
struct iconv_env_t arg;
@@ -658,7 +638,7 @@ iconv_s_iconv(int argc, VALUE *argv, VALUE self)
arg.argv = argv + 2;
arg.append = rb_ary_push;
arg.ret = rb_ary_new2(argc);
- arg.cd = iconv_create(argv[0], argv[1], NULL, &arg.toidx);
+ arg.cd = iconv_create(argv[0], argv[1]);
return rb_ensure(iconv_s_convert, (VALUE)&arg, iconv_free, ICONV2VALUE(arg.cd));
}
@@ -671,7 +651,13 @@ iconv_s_iconv(int argc, VALUE *argv, VALUE self)
* See Iconv.iconv.
*/
static VALUE
-iconv_s_conv(VALUE self, VALUE to, VALUE from, VALUE str)
+iconv_s_conv
+#ifdef HAVE_PROTOTYPES
+ (VALUE self, VALUE to, VALUE from, VALUE str)
+#else /* HAVE_PROTOTYPES */
+ (self, to, from, str)
+ VALUE self, to, from, str;
+#endif /* HAVE_PROTOTYPES */
{
struct iconv_env_t arg;
@@ -679,93 +665,11 @@ iconv_s_conv(VALUE self, VALUE to, VALUE from, VALUE str)
arg.argv = &str;
arg.append = rb_str_append;
arg.ret = rb_str_new(0, 0);
- arg.cd = iconv_create(to, from, NULL, &arg.toidx);
+ arg.cd = iconv_create(to, from);
return rb_ensure(iconv_s_convert, (VALUE)&arg, iconv_free, ICONV2VALUE(arg.cd));
}
/*
- * Document-method: list
- * call-seq: Iconv.list {|*aliases| ... }
- *
- * Iterates each alias sets.
- */
-
-#ifdef HAVE_ICONVLIST
-struct iconv_name_list
-{
- unsigned int namescount;
- const char *const *names;
- VALUE array;
-};
-
-static VALUE
-list_iconv_i(VALUE ptr)
-{
- struct iconv_name_list *p = (struct iconv_name_list *)ptr;
- unsigned int i, namescount = p->namescount;
- const char *const *names = p->names;
- VALUE ary = rb_ary_new2(namescount);
-
- for (i = 0; i < namescount; i++) {
- rb_ary_push(ary, rb_str_new2(names[i]));
- }
- if (p->array) {
- return rb_ary_push(p->array, ary);
- }
- return rb_yield(ary);
-}
-
-static int
-list_iconv(unsigned int namescount, const char *const *names, void *data)
-{
- int *state = data;
- struct iconv_name_list list;
-
- list.namescount = namescount;
- list.names = names;
- list.array = ((VALUE *)data)[1];
- rb_protect(list_iconv_i, (VALUE)&list, state);
- return *state;
-}
-#endif
-
-static VALUE
-iconv_s_list(void)
-{
-#ifdef HAVE_ICONVLIST
- int state;
- VALUE args[2];
-
- args[1] = rb_block_given_p() ? 0 : rb_ary_new();
- iconvlist(list_iconv, args);
- state = *(int *)args;
- if (state) rb_jump_tag(state);
- if (args[1]) return args[1];
-#elif defined(HAVE___ICONV_FREE_LIST)
- char **list;
- size_t sz, i;
- VALUE ary;
-
- if (__iconv_get_list(&list, &sz)) return Qnil;
-
- ary = rb_ary_new2(sz);
- for (i = 0; i < sz; i++) {
- rb_ary_push(ary, rb_str_new2(list[i]));
- }
- __iconv_free_list(list, sz);
-
- if (!rb_block_given_p())
- return ary;
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- rb_yield(RARRAY_PTR(ary)[i]);
- }
-#else
- rb_notimplement();
-#endif
- return Qnil;
-}
-
-/*
* Document-method: close
*
* Finishes conversion.
@@ -777,23 +681,32 @@ iconv_s_list(void)
* its initial shift state.
*/
static VALUE
-iconv_init_state(VALUE cd)
+iconv_init_state
+#ifdef HAVE_PROTOTYPES
+ (VALUE cd)
+#else /* HAVE_PROTOTYPES */
+ (cd)
+ VALUE cd;
+#endif /* HAVE_PROTOTYPES */
{
return iconv_convert(VALUE2ICONV(cd), Qnil, 0, 0, NULL);
}
static VALUE
-iconv_finish(VALUE self)
+iconv_finish
+#ifdef HAVE_PROTOTYPES
+ (VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
{
VALUE cd = check_iconv(self);
- VALUE str;
if (!cd) return Qnil;
DATA_PTR(self) = NULL;
- str = rb_ensure(iconv_init_state, cd, iconv_free, cd);
- ENCODING_SET(str, ENCODING_GET(self));
- return str;
+ return rb_ensure(iconv_init_state, cd, iconv_free, cd);
}
/*
@@ -824,171 +737,34 @@ iconv_finish(VALUE self)
* See the Iconv documentation.
*/
static VALUE
-iconv_iconv(int argc, VALUE *argv, VALUE self)
+iconv_iconv
+#ifdef HAVE_PROTOTYPES
+ (int argc, VALUE *argv, VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
{
VALUE str, n1, n2;
VALUE cd = check_iconv(self);
+ long start = 0, length = 0, slen = 0;
- n1 = n2 = Qnil;
rb_scan_args(argc, argv, "12", &str, &n1, &n2);
-
- str = iconv_convert(VALUE2ICONV(cd), str,
- NIL_P(n1) ? 0 : NUM2INT(n1),
- NIL_P(n2) ? -1 : NUM2INT(n2),
- NULL);
- ENCODING_SET(str, ENCODING_GET(self));
- return str;
-}
-
-/*
- * Document-method: conv
- * call-seq: conv(str...)
- *
- * Equivalent to
- *
- * iconv(nil, str..., nil).join
- */
-static VALUE
-iconv_conv(int argc, VALUE *argv, VALUE self)
-{
- iconv_t cd = VALUE2ICONV(check_iconv(self));
- VALUE str, s;
-
- str = iconv_convert(cd, Qnil, 0, 0, NULL);
- ENCODING_SET(str, ENCODING_GET(self));
- if (argc > 0) {
- do {
- s = iconv_convert(cd, *argv++, 0, -1, NULL);
- if (RSTRING_LEN(s))
- rb_str_buf_append(str, s);
- } while (--argc);
- s = iconv_convert(cd, Qnil, 0, 0, NULL);
- if (RSTRING_LEN(s))
- rb_str_buf_append(str, s);
+ 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 str;
-}
-
-/*
- * Document-method: trivial?
- * call-seq: trivial?
- *
- * Returns trivial flag.
- */
-static VALUE
-iconv_trivialp(VALUE self)
-{
-#ifdef ICONV_TRIVIALP
- int trivial = 0;
- iconv_ctl(self, ICONV_TRIVIALP, trivial);
- if (trivial) return Qtrue;
-#else
- rb_notimplement();
-#endif
- return Qfalse;
-}
-
-/*
- * Document-method: transliterate?
- * call-seq: transliterate?
- *
- * Returns transliterate flag.
- */
-static VALUE
-iconv_get_transliterate(VALUE self)
-{
-#ifdef ICONV_GET_TRANSLITERATE
- int trans = 0;
- iconv_ctl(self, ICONV_GET_TRANSLITERATE, trans);
- if (trans) return Qtrue;
-#else
- rb_notimplement();
-#endif
- return Qfalse;
-}
-
-/*
- * Document-method: transliterate=
- * call-seq: cd.transliterate = flag
- *
- * Sets transliterate flag.
- */
-static VALUE
-iconv_set_transliterate(VALUE self, VALUE transliterate)
-{
-#ifdef ICONV_SET_TRANSLITERATE
- int trans = RTEST(transliterate);
- iconv_ctl(self, ICONV_SET_TRANSLITERATE, trans);
-#else
- rb_notimplement();
-#endif
- return self;
-}
-
-/*
- * Document-method: discard_ilseq?
- * call-seq: discard_ilseq?
- *
- * Returns discard_ilseq flag.
- */
-static VALUE
-iconv_get_discard_ilseq(VALUE self)
-{
-#ifdef ICONV_GET_DISCARD_ILSEQ
- int dis = 0;
- iconv_ctl(self, ICONV_GET_DISCARD_ILSEQ, dis);
- if (dis) return Qtrue;
-#else
- rb_notimplement();
-#endif
- return Qfalse;
-}
-
-/*
- * Document-method: discard_ilseq=
- * call-seq: cd.discard_ilseq = flag
- *
- * Sets discard_ilseq flag.
- */
-static VALUE
-iconv_set_discard_ilseq(VALUE self, VALUE discard_ilseq)
-{
-#ifdef ICONV_SET_DISCARD_ILSEQ
- int dis = RTEST(discard_ilseq);
- iconv_ctl(self, ICONV_SET_DISCARD_ILSEQ, dis);
-#else
- rb_notimplement();
-#endif
- return self;
-}
-
-/*
- * Document-method: ctlmethods
- * call-seq: Iconv.ctlmethods => array
- *
- * Returns available iconvctl() method list.
- */
-static VALUE
-iconv_s_ctlmethods(VALUE klass)
-{
- VALUE ary = rb_ary_new();
-#ifdef ICONV_TRIVIALP
- rb_ary_push(ary, ID2SYM(rb_intern("trivial?")));
-#endif
-#ifdef ICONV_GET_TRANSLITERATE
- rb_ary_push(ary, ID2SYM(rb_intern("transliterate?")));
-#endif
-#ifdef ICONV_SET_TRANSLITERATE
- rb_ary_push(ary, ID2SYM(rb_intern("transliterate=")));
-#endif
-#ifdef ICONV_GET_DISCARD_ILSEQ
- rb_ary_push(ary, ID2SYM(rb_intern("discard_ilseq?")));
-#endif
-#ifdef ICONV_SET_DISCARD_ILSEQ
- rb_ary_push(ary, ID2SYM(rb_intern("discard_ilseq=")));
-#endif
- return ary;
+ return iconv_convert(VALUE2ICONV(cd), str, start, length, NULL);
}
/*
@@ -1007,7 +783,13 @@ iconv_s_ctlmethods(VALUE klass)
* failure and the last element is string on the way.
*/
static VALUE
-iconv_failure_success(VALUE self)
+iconv_failure_success
+#ifdef HAVE_PROTOTYPES
+(VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
{
return rb_attr_get(self, rb_success);
}
@@ -1020,7 +802,13 @@ iconv_failure_success(VALUE self)
* character caused the exception.
*/
static VALUE
-iconv_failure_failed(VALUE self)
+iconv_failure_failed
+#ifdef HAVE_PROTOTYPES
+(VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
{
return rb_attr_get(self, rb_failed);
}
@@ -1032,9 +820,15 @@ iconv_failure_failed(VALUE self)
* Returns inspected string like as: #<_class_: _success_, _failed_>
*/
static VALUE
-iconv_failure_inspect(VALUE self)
-{
- char *cname = rb_class2name(CLASS_OF(self));
+iconv_failure_inspect
+#ifdef HAVE_PROTOTYPES
+ (VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ const 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);
@@ -1080,25 +874,17 @@ iconv_failure_inspect(VALUE self)
*/
void
-Init_iconv(void)
+Init_iconv _((void))
{
VALUE rb_cIconv = rb_define_class("Iconv", rb_cData);
rb_define_alloc_func(rb_cIconv, iconv_s_allocate);
- rb_define_singleton_method(rb_cIconv, "open", iconv_s_open, -1);
+ rb_define_singleton_method(rb_cIconv, "open", iconv_s_open, 2);
rb_define_singleton_method(rb_cIconv, "iconv", iconv_s_iconv, -1);
rb_define_singleton_method(rb_cIconv, "conv", iconv_s_conv, 3);
- rb_define_singleton_method(rb_cIconv, "list", iconv_s_list, 0);
- rb_define_singleton_method(rb_cIconv, "ctlmethods", iconv_s_ctlmethods, 0);
- rb_define_method(rb_cIconv, "initialize", iconv_initialize, -1);
+ rb_define_method(rb_cIconv, "initialize", iconv_initialize, 2);
rb_define_method(rb_cIconv, "close", iconv_finish, 0);
rb_define_method(rb_cIconv, "iconv", iconv_iconv, -1);
- rb_define_method(rb_cIconv, "conv", iconv_conv, -1);
- rb_define_method(rb_cIconv, "trivial?", iconv_trivialp, 0);
- rb_define_method(rb_cIconv, "transliterate?", iconv_get_transliterate, 0);
- rb_define_method(rb_cIconv, "transliterate=", iconv_set_transliterate, 1);
- rb_define_method(rb_cIconv, "discard_ilseq?", iconv_get_discard_ilseq, 0);
- rb_define_method(rb_cIconv, "discard_ilseq=", iconv_set_discard_ilseq, 1);
rb_eIconvFailure = rb_define_module_under(rb_cIconv, "Failure");
rb_define_method(rb_eIconvFailure, "initialize", iconv_failure_initialize, 3);
@@ -1119,8 +905,6 @@ Init_iconv(void)
rb_success = rb_intern("success");
rb_failed = rb_intern("failed");
- id_transliterate = rb_intern("transliterate");
- id_discard_ilseq = rb_intern("discard_ilseq");
rb_gc_register_address(&charset_map);
charset_map = rb_hash_new();
diff --git a/ext/iconv/mkwrapper.rb b/ext/iconv/mkwrapper.rb
deleted file mode 100644
index 34718507d6..0000000000
--- a/ext/iconv/mkwrapper.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-#! /usr/bin/ruby
-require 'rbconfig'
-require 'optparse'
-
-# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
-# Fri, 30 May 2003 00:09:00 GMT'
-
-HEADER = <<SRC
-require 'iconv.so'
-
-class Iconv
- case RUBY_PLATFORM
-SRC
-
-def charset_alias(config_charset, mapfile = nil)
- found = nil
- src = [HEADER]
- open(config_charset) do |input|
- input.find {|line| /^case "\$os" in/ =~ line} or return
- input.each do |line|
- case line
- when /^\s*([-\w\*]+(?:\s*\|\s*[-\w\*]+)*)(?=\))/
- (s = " when ") << $&.split('|').collect {|targ|
- targ.strip!
- tail = targ.chomp!("*") ? '' : '\z'
- head = targ.slice!(/\A\*/) ? '' : '\A'
- targ.gsub!(/\*/, '.*')
- "/#{head}#{targ}#{tail}/"
- }.join(", ")
- src << s
- found = {}
- when /^\s*echo "(?:\$\w+\.)?([-\w*]+)\s+([-\w]+)"/
- sys, can = $1, $2
- can.downcase!
- unless found[can] or (/\Aen_(?!US\z)/ =~ sys && /\ACP437\z/i =~ can)
- found[can] = true
- src << " charset_map['#{can}'] = '#{sys}'.freeze"
- end
- when /^\s*;;/
- found = nil
- end
- end
- end
- src << " end" << "end"
- if mapfile
- open(mapfile, "wb") {|f| f.puts *src}
- else
- puts *src
- end
-end
-
-(1..2) === ARGV.size or abort "usage: #{$0} config_charset [mapfile]"
-charset_alias(*ARGV)
diff --git a/ext/io/wait/.cvsignore b/ext/io/wait/.cvsignore
index 8767482975..fc802ff1c2 100644
--- a/ext/io/wait/.cvsignore
+++ b/ext/io/wait/.cvsignore
@@ -1,3 +1,2 @@
Makefile
mkmf.log
-extconf.h
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index e0a0232431..02cb54a014 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -41,96 +41,83 @@ void Init_wait _((void));
EXTERN struct timeval rb_time_interval _((VALUE time));
/*
- * call-seq:
- * io.ready? -> true, false or nil
- *
- * Returns non-nil if input available without blocking, or nil.
+=begin
+= IO wait methods.
+=end
*/
+/*
+=begin
+--- IO#ready?
+ returns non-nil if input available without blocking, or nil.
+=end
+*/
static VALUE
-io_ready_p(VALUE io)
+io_ready_p(io)
+ VALUE io;
{
rb_io_t *fptr;
+ FILE *fp;
ioctl_arg n;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- if (rb_io_read_pending(fptr)) return Qtrue;
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
- if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
+ if (!FIONREAD_POSSIBLE_P(fileno(fptr->f))) return Qfalse;
+ fp = fptr->f;
+ if (feof(fp)) return Qfalse;
+ if (rb_read_pending(fp)) return Qtrue;
+ if (ioctl(fileno(fp), FIONREAD, &n)) rb_sys_fail(0);
if (n > 0) return ioctl_arg2num(n);
return Qnil;
}
-struct wait_readable_arg {
- rb_fdset_t fds;
- struct timeval *timeout;
-};
-
-#ifdef HAVE_RB_FD_INIT
-static VALUE
-wait_readable(VALUE p)
-{
- struct wait_readable_arg *arg = (struct wait_readable_arg *)p;
- rb_fdset_t *fds = &arg->fds;
-
- return (VALUE)rb_thread_select(rb_fd_max(fds), rb_fd_ptr(fds), NULL, NULL, arg->timeout);
-}
-#endif
-
/*
- * call-seq:
- * io.wait -> IO, true, false or nil
- * io.wait(timeout) -> IO, true, false or nil
- *
- * Waits until input is available or times out and returns self or nil when
- * EOF is reached.
- */
-
+=begin
+--- IO#wait([timeout])
+ waits until input available or timed out and returns self, or nil
+ when EOF reached.
+=end
+*/
static VALUE
-io_wait(int argc, VALUE *argv, VALUE io)
+io_wait(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
rb_io_t *fptr;
- struct wait_readable_arg arg;
- int fd, i;
+ fd_set rd;
+ FILE *fp;
+ int fd;
ioctl_arg n;
VALUE timeout;
- struct timeval timerec;
+ struct timeval *tp, timerec;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_scan_args(argc, argv, "01", &timeout);
if (NIL_P(timeout)) {
- arg.timeout = 0;
+ tp = 0;
}
else {
timerec = rb_time_interval(timeout);
- arg.timeout = &timerec;
+ tp = &timerec;
}
- if (rb_io_read_pending(fptr)) return Qtrue;
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
- fd = fptr->fd;
- rb_fd_init(&arg.fds);
- rb_fd_set(fd, &arg.fds);
-#ifdef HAVE_RB_FD_INIT
- i = (int)rb_ensure(wait_readable, (VALUE)&arg,
- (VALUE (*)_((VALUE)))rb_fd_term, (VALUE)&arg.fds);
-#else
- i = rb_thread_select(fd + 1, rb_fd_ptr(&arg.fds), NULL, NULL, arg.timeout);
-#endif
- if (i < 0)
+ fp = fptr->f;
+ if (feof(fp)) return Qfalse;
+ if (rb_read_pending(fp)) return Qtrue;
+ fd = fileno(fp);
+ FD_ZERO(&rd);
+ FD_SET(fd, &rd);
+ if (rb_thread_select(fd + 1, &rd, NULL, NULL, tp) < 0)
rb_sys_fail(0);
rb_io_check_closed(fptr);
- if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
+ if (!FIONREAD_POSSIBLE_P(fileno(fptr->f))) return Qfalse;
+ if (ioctl(fileno(fp), FIONREAD, &n)) rb_sys_fail(0);
if (n > 0) return io;
return Qnil;
}
-/*
- * IO wait methods
- */
-
void
Init_wait()
{
diff --git a/ext/json/ext/generator/extconf.rb b/ext/json/ext/generator/extconf.rb
deleted file mode 100644
index 86ed7e6367..0000000000
--- a/ext/json/ext/generator/extconf.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'mkmf'
-require 'rbconfig'
-
-if CONFIG['CC'] =~ /gcc/
- #$CFLAGS += ' -Wall -ggdb'
- $CFLAGS += ' -Wall'
-end
-
-have_header 'st.h'
-create_makefile 'json/ext/generator'
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
deleted file mode 100644
index 6bc37e38cb..0000000000
--- a/ext/json/ext/generator/generator.c
+++ /dev/null
@@ -1,876 +0,0 @@
-/* vim: set cin et sw=4 ts=4: */
-
-#include "ruby.h"
-#include "ruby/st.h"
-#include "unicode.h"
-#include <string.h>
-#include <math.h>
-
-#define check_max_nesting(state, depth) do { \
- long current_nesting = 1 + depth; \
- if (state->max_nesting != 0 && current_nesting > state->max_nesting) \
- rb_raise(eNestingError, "nesting of %ld is too deep", current_nesting); \
-} while (0);
-
-static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
- mHash, mArray, mInteger, mFloat, mString, mString_Extend,
- mTrueClass, mFalseClass, mNilClass, eGeneratorError,
- eCircularDatastructure, eNestingError;
-
-static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
- i_object_nl, i_array_nl, i_check_circular, i_max_nesting,
- i_allow_nan, i_pack, i_unpack, i_create_id, i_extend;
-
-typedef struct JSON_Generator_StateStruct {
- VALUE indent;
- VALUE space;
- VALUE space_before;
- VALUE object_nl;
- VALUE array_nl;
- int check_circular;
- VALUE seen;
- VALUE memo;
- VALUE depth;
- long max_nesting;
- int flag;
- int allow_nan;
-} JSON_Generator_State;
-
-#define GET_STATE(self) \
- JSON_Generator_State *state; \
- Data_Get_Struct(self, JSON_Generator_State, state);
-
-/*
- * Document-module: JSON::Ext::Generator
- *
- * This is the JSON generator implemented as a C extension. It can be
- * configured to be used by setting
- *
- * JSON.generator = JSON::Ext::Generator
- *
- * with the method generator= in JSON.
- *
- */
-
-static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
-{
- VALUE json, buf, Vdepth;
- GET_STATE(Vstate);
- buf = state->memo;
- Vdepth = state->depth;
-
- if (key == Qundef) return ST_CONTINUE;
- if (state->flag) {
- state->flag = 0;
- rb_str_buf_cat2(buf, ",");
- if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(buf, state->object_nl);
- }
- if (RSTRING_LEN(state->object_nl)) {
- rb_str_buf_append(buf, rb_str_times(state->indent, Vdepth));
- }
- json = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 2, Vstate, Vdepth);
- Check_Type(json, T_STRING);
- rb_str_buf_append(buf, json);
- OBJ_INFECT(buf, json);
- if (RSTRING_LEN(state->space_before)) {
- rb_str_buf_append(buf, state->space_before);
- }
- rb_str_buf_cat2(buf, ":");
- if (RSTRING_LEN(state->space)) rb_str_buf_append(buf, state->space);
- json = rb_funcall(value, i_to_json, 2, Vstate, Vdepth);
- Check_Type(json, T_STRING);
- state->flag = 1;
- rb_str_buf_append(buf, json);
- OBJ_INFECT(buf, json);
- state->depth = Vdepth;
- state->memo = buf;
- return ST_CONTINUE;
-}
-
-inline static VALUE mHash_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
- long depth, len = RHASH_SIZE(self);
- VALUE result;
- GET_STATE(Vstate);
-
- depth = 1 + FIX2LONG(Vdepth);
- result = rb_str_buf_new(len);
- state->memo = result;
- state->depth = LONG2FIX(depth);
- state->flag = 0;
- rb_str_buf_cat2(result, "{");
- if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
- rb_hash_foreach(self, hash_to_json_state_i, Vstate);
- if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
- if (RSTRING_LEN(state->object_nl)) {
- rb_str_buf_append(result, rb_str_times(state->indent, Vdepth));
- }
- rb_str_buf_cat2(result, "}");
- return result;
-}
-
-static int hash_to_json_i(VALUE key, VALUE value, VALUE buf)
-{
- VALUE tmp;
-
- if (key == Qundef) return ST_CONTINUE;
- if (RSTRING_LEN(buf) > 1) rb_str_buf_cat2(buf, ",");
- tmp = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 0);
- Check_Type(tmp, T_STRING);
- rb_str_buf_append(buf, tmp);
- OBJ_INFECT(buf, tmp);
- rb_str_buf_cat2(buf, ":");
- tmp = rb_funcall(value, i_to_json, 0);
- Check_Type(tmp, T_STRING);
- rb_str_buf_append(buf, tmp);
- OBJ_INFECT(buf, tmp);
-
- return ST_CONTINUE;
-}
-
-/*
- * call-seq: to_json(state = nil, depth = 0)
- *
- * Returns a JSON string containing a JSON object, that is unparsed from
- * this Hash instance.
- * _state_ is a JSON::State object, that can also be used to configure the
- * produced JSON string output further.
- * _depth_ is used to find out nesting depth, to indent accordingly.
- */
-static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
-{
- VALUE Vstate, Vdepth, result;
- long depth;
-
- rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
- depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
- if (NIL_P(Vstate)) {
- long len = RHASH_SIZE(self);
- result = rb_str_buf_new(len);
- rb_str_buf_cat2(result, "{");
- rb_hash_foreach(self, hash_to_json_i, result);
- rb_str_buf_cat2(result, "}");
- } else {
- GET_STATE(Vstate);
- check_max_nesting(state, depth);
- if (state->check_circular) {
- VALUE self_id = rb_obj_id(self);
- if (RTEST(rb_hash_aref(state->seen, self_id))) {
- rb_raise(eCircularDatastructure,
- "circular data structures not supported!");
- }
- rb_hash_aset(state->seen, self_id, Qtrue);
- result = mHash_json_transfrom(self, Vstate, LONG2FIX(depth));
- rb_hash_delete(state->seen, self_id);
- } else {
- result = mHash_json_transfrom(self, Vstate, LONG2FIX(depth));
- }
- }
- OBJ_INFECT(result, self);
- return result;
-}
-
-inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
- long i, len = RARRAY_LEN(self);
- VALUE shift, result;
- long depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
- VALUE delim = rb_str_new2(",");
- GET_STATE(Vstate);
-
- check_max_nesting(state, depth);
- if (state->check_circular) {
- VALUE self_id = rb_obj_id(self);
- rb_hash_aset(state->seen, self_id, Qtrue);
- result = rb_str_buf_new(len);
- if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
- shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
-
- rb_str_buf_cat2(result, "[");
- OBJ_INFECT(result, self);
- rb_str_buf_append(result, state->array_nl);
- for (i = 0; i < len; i++) {
- VALUE element = RARRAY_PTR(self)[i];
- if (RTEST(rb_hash_aref(state->seen, rb_obj_id(element)))) {
- rb_raise(eCircularDatastructure,
- "circular data structures not supported!");
- }
- OBJ_INFECT(result, element);
- if (i > 0) rb_str_buf_append(result, delim);
- rb_str_buf_append(result, shift);
- element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
- Check_Type(element, T_STRING);
- rb_str_buf_append(result, element);
- }
- if (RSTRING_LEN(state->array_nl)) {
- rb_str_buf_append(result, state->array_nl);
- rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
- }
- rb_str_buf_cat2(result, "]");
- rb_hash_delete(state->seen, self_id);
- } else {
- result = rb_str_buf_new(len);
- OBJ_INFECT(result, self);
- if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
- shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
-
- rb_str_buf_cat2(result, "[");
- rb_str_buf_append(result, state->array_nl);
- for (i = 0; i < len; i++) {
- VALUE element = RARRAY_PTR(self)[i];
- OBJ_INFECT(result, element);
- if (i > 0) rb_str_buf_append(result, delim);
- rb_str_buf_append(result, shift);
- element = rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1));
- Check_Type(element, T_STRING);
- rb_str_buf_append(result, element);
- }
- rb_str_buf_append(result, state->array_nl);
- if (RSTRING_LEN(state->array_nl)) {
- rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
- }
- rb_str_buf_cat2(result, "]");
- }
- return result;
-}
-
-/*
- * call-seq: to_json(state = nil, depth = 0)
- *
- * Returns a JSON string containing a JSON array, that is unparsed from
- * this Array instance.
- * _state_ is a JSON::State object, that can also be used to configure the
- * produced JSON string output further.
- * _depth_ is used to find out nesting depth, to indent accordingly.
- */
-static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
- VALUE Vstate, Vdepth, result;
-
- rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
- if (NIL_P(Vstate)) {
- long i, len = RARRAY_LEN(self);
- result = rb_str_buf_new(2 + 2 * len);
- rb_str_buf_cat2(result, "[");
- OBJ_INFECT(result, self);
- for (i = 0; i < len; i++) {
- VALUE element = RARRAY_PTR(self)[i];
- OBJ_INFECT(result, element);
- if (i > 0) rb_str_buf_cat2(result, ",");
- element = rb_funcall(element, i_to_json, 0);
- Check_Type(element, T_STRING);
- rb_str_buf_append(result, element);
- }
- rb_str_buf_cat2(result, "]");
- } else {
- result = mArray_json_transfrom(self, Vstate, Vdepth);
- }
- OBJ_INFECT(result, self);
- return result;
-}
-
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string representation for this Integer number.
- */
-static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self)
-{
- return rb_funcall(self, i_to_s, 0);
-}
-
-/*
- * call-seq: to_json(*)
- *
- * Returns a JSON string representation for this Float number.
- */
-static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
-{
- JSON_Generator_State *state = NULL;
- VALUE Vstate, rest, tmp;
- double value = RFLOAT_VALUE(self);
- rb_scan_args(argc, argv, "01*", &Vstate, &rest);
- if (!NIL_P(Vstate)) Data_Get_Struct(Vstate, JSON_Generator_State, state);
- if (isinf(value)) {
- if (!state || state->allow_nan) {
- return rb_funcall(self, i_to_s, 0);
- } else {
- tmp = rb_funcall(self, i_to_s, 0);
- rb_raise(eGeneratorError, "%s not allowed in JSON", StringValueCStr(tmp));
- }
- } else if (isnan(value)) {
- if (!state || state->allow_nan) {
- return rb_funcall(self, i_to_s, 0);
- } else {
- tmp = rb_funcall(self, i_to_s, 0);
- rb_raise(eGeneratorError, "%s not allowed in JSON", StringValueCStr(tmp));
- }
- } else {
- return rb_funcall(self, i_to_s, 0);
- }
-}
-
-/*
- * call-seq: String.included(modul)
- *
- * Extends _modul_ with the String::Extend module.
- */
-static VALUE mString_included_s(VALUE self, VALUE modul) {
- return rb_funcall(modul, i_extend, 1, mString_Extend);
-}
-
-/*
- * call-seq: to_json(*)
- *
- * This string should be encoded with UTF-8 A call to this method
- * returns a JSON string encoded with UTF16 big endian characters as
- * \u????.
- */
-static VALUE mString_to_json(int argc, VALUE *argv, VALUE self)
-{
- VALUE result = rb_str_buf_new(RSTRING_LEN(self));
- rb_str_buf_cat2(result, "\"");
- JSON_convert_UTF8_to_JSON(result, self, strictConversion);
- rb_str_buf_cat2(result, "\"");
- return result;
-}
-
-/*
- * call-seq: to_json_raw_object()
- *
- * This method creates a raw object hash, that can be nested into
- * other data structures and will be unparsed as a raw string. This
- * method should be used, if you want to convert raw strings to JSON
- * instead of UTF-8 strings, e. g. binary data.
- */
-static VALUE mString_to_json_raw_object(VALUE self) {
- VALUE ary;
- VALUE result = rb_hash_new();
- rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self)));
- ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*"));
- rb_hash_aset(result, rb_str_new2("raw"), ary);
- return result;
-}
-
-/*
- * call-seq: to_json_raw(*args)
- *
- * This method creates a JSON text from the result of a call to
- * to_json_raw_object of this String.
- */
-static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self) {
- VALUE obj = mString_to_json_raw_object(self);
- Check_Type(obj, T_HASH);
- return mHash_to_json(argc, argv, obj);
-}
-
-/*
- * call-seq: json_create(o)
- *
- * Raw Strings are JSON Objects (the raw bytes are stored in an array for the
- * key "raw"). The Ruby String can be created by this module method.
- */
-static VALUE mString_Extend_json_create(VALUE self, VALUE o) {
- VALUE ary;
- Check_Type(o, T_HASH);
- ary = rb_hash_aref(o, rb_str_new2("raw"));
- return rb_funcall(ary, i_pack, 1, rb_str_new2("C*"));
-}
-
-/*
- * call-seq: to_json(state = nil, depth = 0)
- *
- * Returns a JSON string for true: 'true'.
- */
-static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self)
-{
- return rb_str_new2("true");
-}
-
-/*
- * call-seq: to_json(state = nil, depth = 0)
- *
- * Returns a JSON string for false: 'false'.
- */
-static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
-{
- return rb_str_new2("false");
-}
-
-/*
- * call-seq: to_json(state = nil, depth = 0)
- *
- */
-static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
-{
- return rb_str_new2("null");
-}
-
-/*
- * call-seq: to_json(*)
- *
- * Converts this object to a string (calling #to_s), converts
- * it to a JSON string, and returns the result. This is a fallback, if no
- * special method #to_json was defined for some object.
- */
-static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self)
-{
- VALUE string = rb_funcall(self, i_to_s, 0);
- Check_Type(string, T_STRING);
- return mString_to_json(argc, argv, string);
-}
-
-/*
- * Document-class: JSON::Ext::Generator::State
- *
- * This class is used to create State instances, that are use to hold data
- * while generating a JSON text from a a Ruby data structure.
- */
-
-static void State_mark(JSON_Generator_State *state)
-{
- rb_gc_mark_maybe(state->indent);
- rb_gc_mark_maybe(state->space);
- rb_gc_mark_maybe(state->space_before);
- rb_gc_mark_maybe(state->object_nl);
- rb_gc_mark_maybe(state->array_nl);
- rb_gc_mark_maybe(state->seen);
- rb_gc_mark_maybe(state->memo);
- rb_gc_mark_maybe(state->depth);
-}
-
-static JSON_Generator_State *State_allocate()
-{
- JSON_Generator_State *state = ALLOC(JSON_Generator_State);
- return state;
-}
-
-static VALUE cState_s_allocate(VALUE klass)
-{
- JSON_Generator_State *state = State_allocate();
- return Data_Wrap_Struct(klass, State_mark, -1, state);
-}
-
-/*
- * call-seq: configure(opts)
- *
- * Configure this State instance with the Hash _opts_, and return
- * itself.
- */
-static inline VALUE cState_configure(VALUE self, VALUE opts)
-{
- VALUE tmp;
- GET_STATE(self);
- tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
- if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
- if (NIL_P(tmp)) {
- rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash");
- }
- opts = tmp;
- tmp = rb_hash_aref(opts, ID2SYM(i_indent));
- if (RTEST(tmp)) {
- Check_Type(tmp, T_STRING);
- state->indent = tmp;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_space));
- if (RTEST(tmp)) {
- Check_Type(tmp, T_STRING);
- state->space = tmp;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
- if (RTEST(tmp)) {
- Check_Type(tmp, T_STRING);
- state->space_before = tmp;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
- if (RTEST(tmp)) {
- Check_Type(tmp, T_STRING);
- state->array_nl = tmp;
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
- if (RTEST(tmp)) {
- Check_Type(tmp, T_STRING);
- state->object_nl = tmp;
- }
- tmp = ID2SYM(i_check_circular);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- tmp = rb_hash_aref(opts, ID2SYM(i_check_circular));
- state->check_circular = RTEST(tmp);
- } else {
- state->check_circular = 1;
- }
- tmp = ID2SYM(i_max_nesting);
- state->max_nesting = 19;
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE max_nesting = rb_hash_aref(opts, tmp);
- if (RTEST(max_nesting)) {
- Check_Type(max_nesting, T_FIXNUM);
- state->max_nesting = FIX2LONG(max_nesting);
- } else {
- state->max_nesting = 0;
- }
- }
- tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
- state->allow_nan = RTEST(tmp);
- return self;
-}
-
-/*
- * call-seq: to_h
- *
- * Returns the configuration instance variables as a hash, that can be
- * passed to the configure method.
- */
-static VALUE cState_to_h(VALUE self)
-{
- VALUE result = rb_hash_new();
- GET_STATE(self);
- rb_hash_aset(result, ID2SYM(i_indent), state->indent);
- rb_hash_aset(result, ID2SYM(i_space), state->space);
- rb_hash_aset(result, ID2SYM(i_space_before), state->space_before);
- rb_hash_aset(result, ID2SYM(i_object_nl), state->object_nl);
- rb_hash_aset(result, ID2SYM(i_array_nl), state->array_nl);
- rb_hash_aset(result, ID2SYM(i_check_circular), state->check_circular ? Qtrue : Qfalse);
- rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
- rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
- return result;
-}
-
-
-/*
- * call-seq: new(opts = {})
- *
- * Instantiates a new State object, configured by _opts_.
- *
- * _opts_ can have the following keys:
- *
- * * *indent*: a string used to indent levels (default: ''),
- * * *space*: a string that is put after, a : or , delimiter (default: ''),
- * * *space_before*: a string that is put before a : pair delimiter (default: ''),
- * * *object_nl*: a string that is put at the end of a JSON object (default: ''),
- * * *array_nl*: a string that is put at the end of a JSON array (default: ''),
- * * *check_circular*: true if checking for circular data structures
- * should be done, false (the default) otherwise.
- * * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- * generated, otherwise an exception is thrown, if these values are
- * encountered. This options defaults to false.
- */
-static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
-{
- VALUE opts;
- GET_STATE(self);
-
- rb_scan_args(argc, argv, "01", &opts);
- state->indent = rb_str_new2("");
- state->space = rb_str_new2("");
- state->space_before = rb_str_new2("");
- state->array_nl = rb_str_new2("");
- state->object_nl = rb_str_new2("");
- if (NIL_P(opts)) {
- state->check_circular = 1;
- state->allow_nan = 0;
- state->max_nesting = 19;
- } else {
- cState_configure(self, opts);
- }
- state->seen = rb_hash_new();
- state->memo = Qnil;
- state->depth = INT2FIX(0);
- return self;
-}
-
-/*
- * call-seq: from_state(opts)
- *
- * Creates a State object from _opts_, which ought to be Hash to create a
- * new State instance configured by _opts_, something else to create an
- * unconfigured instance. If _opts_ is a State object, it is just returned.
- */
-static VALUE cState_from_state_s(VALUE self, VALUE opts)
-{
- if (rb_obj_is_kind_of(opts, self)) {
- return opts;
- } else if (rb_obj_is_kind_of(opts, rb_cHash)) {
- return rb_funcall(self, i_new, 1, opts);
- } else {
- return rb_funcall(self, i_new, 0);
- }
-}
-
-/*
- * call-seq: indent()
- *
- * This string is used to indent levels in the JSON text.
- */
-static VALUE cState_indent(VALUE self)
-{
- GET_STATE(self);
- return state->indent;
-}
-
-/*
- * call-seq: indent=(indent)
- *
- * This string is used to indent levels in the JSON text.
- */
-static VALUE cState_indent_set(VALUE self, VALUE indent)
-{
- GET_STATE(self);
- Check_Type(indent, T_STRING);
- return state->indent = indent;
-}
-
-/*
- * call-seq: space()
- *
- * This string is used to insert a space between the tokens in a JSON
- * string.
- */
-static VALUE cState_space(VALUE self)
-{
- GET_STATE(self);
- return state->space;
-}
-
-/*
- * call-seq: space=(space)
- *
- * This string is used to insert a space between the tokens in a JSON
- * string.
- */
-static VALUE cState_space_set(VALUE self, VALUE space)
-{
- GET_STATE(self);
- Check_Type(space, T_STRING);
- return state->space = space;
-}
-
-/*
- * call-seq: space_before()
- *
- * This string is used to insert a space before the ':' in JSON objects.
- */
-static VALUE cState_space_before(VALUE self)
-{
- GET_STATE(self);
- return state->space_before;
-}
-
-/*
- * call-seq: space_before=(space_before)
- *
- * This string is used to insert a space before the ':' in JSON objects.
- */
-static VALUE cState_space_before_set(VALUE self, VALUE space_before)
-{
- GET_STATE(self);
- Check_Type(space_before, T_STRING);
- return state->space_before = space_before;
-}
-
-/*
- * call-seq: object_nl()
- *
- * This string is put at the end of a line that holds a JSON object (or
- * Hash).
- */
-static VALUE cState_object_nl(VALUE self)
-{
- GET_STATE(self);
- return state->object_nl;
-}
-
-/*
- * call-seq: object_nl=(object_nl)
- *
- * This string is put at the end of a line that holds a JSON object (or
- * Hash).
- */
-static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
-{
- GET_STATE(self);
- Check_Type(object_nl, T_STRING);
- return state->object_nl = object_nl;
-}
-
-/*
- * call-seq: array_nl()
- *
- * This string is put at the end of a line that holds a JSON array.
- */
-static VALUE cState_array_nl(VALUE self)
-{
- GET_STATE(self);
- return state->array_nl;
-}
-
-/*
- * call-seq: array_nl=(array_nl)
- *
- * This string is put at the end of a line that holds a JSON array.
- */
-static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
-{
- GET_STATE(self);
- Check_Type(array_nl, T_STRING);
- return state->array_nl = array_nl;
-}
-
-/*
- * call-seq: check_circular?
- *
- * Returns true, if circular data structures should be checked,
- * otherwise returns false.
- */
-static VALUE cState_check_circular_p(VALUE self)
-{
- GET_STATE(self);
- return state->check_circular ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq: max_nesting
- *
- * This integer returns the maximum level of data structure nesting in
- * the generated JSON, max_nesting = 0 if no maximum is checked.
- */
-static VALUE cState_max_nesting(VALUE self)
-{
- GET_STATE(self);
- return LONG2FIX(state->max_nesting);
-}
-
-/*
- * call-seq: max_nesting=(depth)
- *
- * This sets the maximum level of data structure nesting in the generated JSON
- * to the integer depth, max_nesting = 0 if no maximum should be checked.
- */
-static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
-{
- GET_STATE(self);
- Check_Type(depth, T_FIXNUM);
- state->max_nesting = FIX2LONG(depth);
- return Qnil;
-}
-
-/*
- * call-seq: allow_nan?
- *
- * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
- * returns false.
- */
-static VALUE cState_allow_nan_p(VALUE self)
-{
- GET_STATE(self);
- return state->allow_nan ? Qtrue : Qfalse;
-}
-
-/*
- * call-seq: seen?(object)
- *
- * Returns _true_, if _object_ was already seen during this generating run.
- */
-static VALUE cState_seen_p(VALUE self, VALUE object)
-{
- GET_STATE(self);
- return rb_hash_aref(state->seen, rb_obj_id(object));
-}
-
-/*
- * call-seq: remember(object)
- *
- * Remember _object_, to find out if it was already encountered (if a cyclic
- * data structure is rendered).
- */
-static VALUE cState_remember(VALUE self, VALUE object)
-{
- GET_STATE(self);
- return rb_hash_aset(state->seen, rb_obj_id(object), Qtrue);
-}
-
-/*
- * call-seq: forget(object)
- *
- * Forget _object_ for this generating run.
- */
-static VALUE cState_forget(VALUE self, VALUE object)
-{
- GET_STATE(self);
- return rb_hash_delete(state->seen, rb_obj_id(object));
-}
-
-/*
- *
- */
-void Init_generator()
-{
- mJSON = rb_define_module("JSON");
- mExt = rb_define_module_under(mJSON, "Ext");
- mGenerator = rb_define_module_under(mExt, "Generator");
- eGeneratorError = rb_path2class("JSON::GeneratorError");
- eCircularDatastructure = rb_path2class("JSON::CircularDatastructure");
- eNestingError = rb_path2class("JSON::NestingError");
- cState = rb_define_class_under(mGenerator, "State", rb_cObject);
- rb_define_alloc_func(cState, cState_s_allocate);
- rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
- rb_define_method(cState, "initialize", cState_initialize, -1);
-
- rb_define_method(cState, "indent", cState_indent, 0);
- rb_define_method(cState, "indent=", cState_indent_set, 1);
- rb_define_method(cState, "space", cState_space, 0);
- rb_define_method(cState, "space=", cState_space_set, 1);
- rb_define_method(cState, "space_before", cState_space_before, 0);
- rb_define_method(cState, "space_before=", cState_space_before_set, 1);
- rb_define_method(cState, "object_nl", cState_object_nl, 0);
- rb_define_method(cState, "object_nl=", cState_object_nl_set, 1);
- rb_define_method(cState, "array_nl", cState_array_nl, 0);
- rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
- rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
- rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
- rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
- rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
- rb_define_method(cState, "seen?", cState_seen_p, 1);
- rb_define_method(cState, "remember", cState_remember, 1);
- rb_define_method(cState, "forget", cState_forget, 1);
- rb_define_method(cState, "configure", cState_configure, 1);
- rb_define_method(cState, "to_h", cState_to_h, 0);
-
- mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
- mObject = rb_define_module_under(mGeneratorMethods, "Object");
- rb_define_method(mObject, "to_json", mObject_to_json, -1);
- mHash = rb_define_module_under(mGeneratorMethods, "Hash");
- rb_define_method(mHash, "to_json", mHash_to_json, -1);
- mArray = rb_define_module_under(mGeneratorMethods, "Array");
- rb_define_method(mArray, "to_json", mArray_to_json, -1);
- mInteger = rb_define_module_under(mGeneratorMethods, "Integer");
- rb_define_method(mInteger, "to_json", mInteger_to_json, -1);
- mFloat = rb_define_module_under(mGeneratorMethods, "Float");
- rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
- mString = rb_define_module_under(mGeneratorMethods, "String");
- rb_define_singleton_method(mString, "included", mString_included_s, 1);
- rb_define_method(mString, "to_json", mString_to_json, -1);
- rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1);
- rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0);
- mString_Extend = rb_define_module_under(mString, "Extend");
- rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1);
- mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass");
- rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1);
- mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass");
- rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1);
- mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
- rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
-
- i_to_s = rb_intern("to_s");
- i_to_json = rb_intern("to_json");
- i_new = rb_intern("new");
- i_indent = rb_intern("indent");
- i_space = rb_intern("space");
- i_space_before = rb_intern("space_before");
- i_object_nl = rb_intern("object_nl");
- i_array_nl = rb_intern("array_nl");
- i_check_circular = rb_intern("check_circular");
- i_max_nesting = rb_intern("max_nesting");
- i_allow_nan = rb_intern("allow_nan");
- i_pack = rb_intern("pack");
- i_unpack = rb_intern("unpack");
- i_create_id = rb_intern("create_id");
- i_extend = rb_intern("extend");
-}
diff --git a/ext/json/ext/generator/unicode.c b/ext/json/ext/generator/unicode.c
deleted file mode 100644
index 44e1f41f98..0000000000
--- a/ext/json/ext/generator/unicode.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* vim: set cin et sw=4 ts=4: */
-
-#include "unicode.h"
-
-#define unicode_escape(buffer, character) \
- snprintf(buf, 7, "\\u%04x", (unsigned int) (character)); \
- rb_str_buf_cat(buffer, buf, 6);
-
-/*
- * Copyright 2001-2004 Unicode, Inc.
- *
- * Disclaimer
- *
- * This source code is provided as is by Unicode, Inc. No claims are
- * made as to fitness for any particular purpose. No warranties of any
- * kind are expressed or implied. The recipient agrees to determine
- * applicability of information provided. If this file has been
- * purchased on magnetic or optical media from Unicode, Inc., the
- * sole remedy for any claim will be exchange of defective media
- * within 90 days of receipt.
- *
- * Limitations on Rights to Redistribute This Code
- *
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form
- * for internal or external distribution as long as this notice
- * remains attached.
- */
-
-/*
- * Index into the table below with the first byte of a UTF-8 sequence to
- * get the number of trailing bytes that are supposed to follow it.
- * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
- * left as-is for anyone who may want to do such conversion, which was
- * allowed in earlier algorithms.
- */
-static const char trailingBytesForUTF8[256] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
-};
-
-/*
- * Magic values subtracted from a buffer value during UTF8 conversion.
- * This table contains as many values as there might be trailing bytes
- * in a UTF-8 sequence.
- */
-static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
-
-/*
- * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
- * into the first byte, depending on how many bytes follow. There are
- * as many entries in this table as there are UTF-8 sequence types.
- * (I.e., one byte sequence, two byte... etc.). Remember that sequencs
- * for *legal* UTF-8 will be 4 or fewer bytes total.
- */
-static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
-/*
- * Utility routine to tell whether a sequence of bytes is legal UTF-8.
- * This must be called with the length pre-determined by the first byte.
- * If not calling this from ConvertUTF8to*, then the length can be set by:
- * length = trailingBytesForUTF8[*source]+1;
- * and the sequence is illegal right away if there aren't that many bytes
- * available.
- * If presented with a length > 4, this returns 0. The Unicode
- * definition of UTF-8 goes up to 4-byte sequences.
- */
-
-inline static unsigned char isLegalUTF8(const UTF8 *source, int length)
-{
- UTF8 a;
- const UTF8 *srcptr = source+length;
- switch (length) {
- default: return 0;
- /* Everything else falls through when "1"... */
- case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
- case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
- case 2: if ((a = (*--srcptr)) > 0xBF) return 0;
-
- switch (*source) {
- /* no fall-through in this inner switch */
- case 0xE0: if (a < 0xA0) return 0; break;
- case 0xED: if (a > 0x9F) return 0; break;
- case 0xF0: if (a < 0x90) return 0; break;
- case 0xF4: if (a > 0x8F) return 0; break;
- default: if (a < 0x80) return 0;
- }
-
- case 1: if (*source >= 0x80 && *source < 0xC2) return 0;
- }
- if (*source > 0xF4) return 0;
- return 1;
-}
-
-void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags)
-{
- char buf[7];
- const UTF8* source = (UTF8 *) RSTRING_PTR(string);
- const UTF8* sourceEnd = source + RSTRING_LEN(string);
-
- while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "partial character in source, but hit end");
- }
- if (!isLegalUTF8(source, extraBytesToRead+1)) {
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed");
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed");
- } else {
- unicode_escape(buffer, UNI_REPLACEMENT_CHAR);
- }
- } else {
- /* normal case */
- if (ch == '"') {
- rb_str_buf_cat2(buffer, "\\\"");
- } else if (ch == '\\') {
- rb_str_buf_cat2(buffer, "\\\\");
- } else if (ch == '/') {
- rb_str_buf_cat2(buffer, "\\/");
- } else if (ch >= 0x20 && ch <= 0x7f) {
- rb_str_buf_cat(buffer, (char *) source - 1, 1);
- } else if (ch == '\n') {
- rb_str_buf_cat2(buffer, "\\n");
- } else if (ch == '\r') {
- rb_str_buf_cat2(buffer, "\\r");
- } else if (ch == '\t') {
- rb_str_buf_cat2(buffer, "\\t");
- } else if (ch == '\f') {
- rb_str_buf_cat2(buffer, "\\f");
- } else if (ch == '\b') {
- rb_str_buf_cat2(buffer, "\\b");
- } else if (ch < 0x20) {
- unicode_escape(buffer, (UTF16) ch);
- } else {
- unicode_escape(buffer, (UTF16) ch);
- }
- }
- } else if (ch > UNI_MAX_UTF16) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the start */
- rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed");
- } else {
- unicode_escape(buffer, UNI_REPLACEMENT_CHAR);
- }
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- ch -= halfBase;
- unicode_escape(buffer, (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START));
- unicode_escape(buffer, (UTF16)((ch & halfMask) + UNI_SUR_LOW_START));
- }
- }
-}
diff --git a/ext/json/ext/generator/unicode.h b/ext/json/ext/generator/unicode.h
deleted file mode 100644
index 841474bcea..0000000000
--- a/ext/json/ext/generator/unicode.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "ruby.h"
-
-#ifndef _GENERATOR_UNICODE_H_
-#define _GENERATOR_UNICODE_H_
-
-typedef enum {
- conversionOK = 0, /* conversion successful */
- sourceExhausted, /* partial character in source, but hit end */
- targetExhausted, /* insuff. room in target for conversion */
- sourceIllegal /* source sequence is illegal/malformed */
-} ConversionResult;
-
-typedef enum {
- strictConversion = 0,
- lenientConversion
-} ConversionFlags;
-
-typedef unsigned long UTF32; /* at least 32 bits */
-typedef unsigned short UTF16; /* at least 16 bits */
-typedef unsigned char UTF8; /* typically 8 bits */
-
-#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
-#define UNI_MAX_BMP (UTF32)0x0000FFFF
-#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
-#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
-#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
-
-#define UNI_SUR_HIGH_START (UTF32)0xD800
-#define UNI_SUR_HIGH_END (UTF32)0xDBFF
-#define UNI_SUR_LOW_START (UTF32)0xDC00
-#define UNI_SUR_LOW_END (UTF32)0xDFFF
-
-static const int halfShift = 10; /* used for shifting by 10 bits */
-
-static const UTF32 halfBase = 0x0010000UL;
-static const UTF32 halfMask = 0x3FFUL;
-
-void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags);
-
-#ifndef RARRAY_PTR
-#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
-#endif
-#ifndef RARRAY_LEN
-#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
-#endif
-#ifndef RSTRING_PTR
-#define RSTRING_PTR(string) RSTRING(string)->ptr
-#endif
-#ifndef RSTRING_LEN
-#define RSTRING_LEN(string) RSTRING(string)->len
-#endif
-
-#endif
diff --git a/ext/json/ext/parser/extconf.rb b/ext/json/ext/parser/extconf.rb
deleted file mode 100644
index b2e7b051a4..0000000000
--- a/ext/json/ext/parser/extconf.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'mkmf'
-require 'rbconfig'
-
-if CONFIG['CC'] =~ /gcc/
- #$CFLAGS += ' -Wall -ggdb'
- $CFLAGS += ' -Wall'
-end
-
-have_header 'st.h'
-create_makefile 'json/ext/parser'
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
deleted file mode 100644
index 5a5d6f1dc4..0000000000
--- a/ext/json/ext/parser/parser.c
+++ /dev/null
@@ -1,1752 +0,0 @@
-#line 1 "parser.rl"
-/* vim: set cin et sw=4 ts=4: */
-
-#include "ruby.h"
-#include "ruby/re.h"
-#include "ruby/st.h"
-#include "unicode.h"
-
-#define EVIL 0x666
-
-static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
-static VALUE CNaN, CInfinity, CMinusInfinity;
-
-static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
- i_chr, i_max_nesting, i_allow_nan;
-
-#define MinusInfinity "-Infinity"
-
-typedef struct JSON_ParserStruct {
- VALUE Vsource;
- char *source;
- long len;
- char *memo;
- VALUE create_id;
- int max_nesting;
- int current_nesting;
- int allow_nan;
-} JSON_Parser;
-
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
-
-#define GET_STRUCT \
- JSON_Parser *json; \
- Data_Get_Struct(self, JSON_Parser, json);
-
-#line 66 "parser.rl"
-
-
-
-#line 46 "parser.c"
-static const int JSON_object_start = 1;
-static const int JSON_object_first_final = 27;
-static const int JSON_object_error = 0;
-
-static const int JSON_object_en_main = 1;
-
-#line 99 "parser.rl"
-
-
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
- VALUE last_name = Qnil;
-
- if (json->max_nesting && json->current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is to deep", json->current_nesting);
- }
-
- *result = rb_hash_new();
-
-
-#line 68 "parser.c"
- {
- cs = JSON_object_start;
- }
-#line 113 "parser.rl"
-
-#line 74 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-case 1:
- if ( (*p) == 123 )
- goto st2;
- goto st0;
-st0:
- goto _out0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- switch( (*p) ) {
- case 13: goto st2;
- case 32: goto st2;
- case 34: goto tr2;
- case 47: goto st23;
- case 125: goto tr4;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st2;
- goto st0;
-tr2:
-#line 85 "parser.rl"
- {
- char *np = JSON_parse_string(json, p, pe, &last_name);
- if (np == NULL) goto _out3; else {p = (( np))-1;}
- }
- goto st3;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
-#line 111 "parser.c"
- switch( (*p) ) {
- case 13: goto st3;
- case 32: goto st3;
- case 47: goto st4;
- case 58: goto st8;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st3;
- goto st0;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- switch( (*p) ) {
- case 42: goto st5;
- case 47: goto st7;
- }
- goto st0;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
- if ( (*p) == 42 )
- goto st6;
- goto st5;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
- switch( (*p) ) {
- case 42: goto st6;
- case 47: goto st3;
- }
- goto st5;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
- if ( (*p) == 10 )
- goto st3;
- goto st7;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
- switch( (*p) ) {
- case 13: goto st8;
- case 32: goto st8;
- case 34: goto tr11;
- case 45: goto tr11;
- case 47: goto st19;
- case 73: goto tr11;
- case 78: goto tr11;
- case 91: goto tr11;
- case 102: goto tr11;
- case 110: goto tr11;
- case 116: goto tr11;
- case 123: goto tr11;
- }
- if ( (*p) > 10 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr11;
- } else if ( (*p) >= 9 )
- goto st8;
- goto st0;
-tr11:
-#line 74 "parser.rl"
- {
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, p, pe, &v);
- if (np == NULL) {
- goto _out9;
- } else {
- rb_hash_aset(*result, last_name, v);
- {p = (( np))-1;}
- }
- }
- goto st9;
-st9:
- if ( ++p == pe )
- goto _out9;
-case 9:
-#line 194 "parser.c"
- switch( (*p) ) {
- case 13: goto st9;
- case 32: goto st9;
- case 44: goto st10;
- case 47: goto st15;
- case 125: goto tr4;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st9;
- goto st0;
-st10:
- if ( ++p == pe )
- goto _out10;
-case 10:
- switch( (*p) ) {
- case 13: goto st10;
- case 32: goto st10;
- case 34: goto tr2;
- case 47: goto st11;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st10;
- goto st0;
-st11:
- if ( ++p == pe )
- goto _out11;
-case 11:
- switch( (*p) ) {
- case 42: goto st12;
- case 47: goto st14;
- }
- goto st0;
-st12:
- if ( ++p == pe )
- goto _out12;
-case 12:
- if ( (*p) == 42 )
- goto st13;
- goto st12;
-st13:
- if ( ++p == pe )
- goto _out13;
-case 13:
- switch( (*p) ) {
- case 42: goto st13;
- case 47: goto st10;
- }
- goto st12;
-st14:
- if ( ++p == pe )
- goto _out14;
-case 14:
- if ( (*p) == 10 )
- goto st10;
- goto st14;
-st15:
- if ( ++p == pe )
- goto _out15;
-case 15:
- switch( (*p) ) {
- case 42: goto st16;
- case 47: goto st18;
- }
- goto st0;
-st16:
- if ( ++p == pe )
- goto _out16;
-case 16:
- if ( (*p) == 42 )
- goto st17;
- goto st16;
-st17:
- if ( ++p == pe )
- goto _out17;
-case 17:
- switch( (*p) ) {
- case 42: goto st17;
- case 47: goto st9;
- }
- goto st16;
-st18:
- if ( ++p == pe )
- goto _out18;
-case 18:
- if ( (*p) == 10 )
- goto st9;
- goto st18;
-tr4:
-#line 90 "parser.rl"
- { goto _out27; }
- goto st27;
-st27:
- if ( ++p == pe )
- goto _out27;
-case 27:
-#line 290 "parser.c"
- goto st0;
-st19:
- if ( ++p == pe )
- goto _out19;
-case 19:
- switch( (*p) ) {
- case 42: goto st20;
- case 47: goto st22;
- }
- goto st0;
-st20:
- if ( ++p == pe )
- goto _out20;
-case 20:
- if ( (*p) == 42 )
- goto st21;
- goto st20;
-st21:
- if ( ++p == pe )
- goto _out21;
-case 21:
- switch( (*p) ) {
- case 42: goto st21;
- case 47: goto st8;
- }
- goto st20;
-st22:
- if ( ++p == pe )
- goto _out22;
-case 22:
- if ( (*p) == 10 )
- goto st8;
- goto st22;
-st23:
- if ( ++p == pe )
- goto _out23;
-case 23:
- switch( (*p) ) {
- case 42: goto st24;
- case 47: goto st26;
- }
- goto st0;
-st24:
- if ( ++p == pe )
- goto _out24;
-case 24:
- if ( (*p) == 42 )
- goto st25;
- goto st24;
-st25:
- if ( ++p == pe )
- goto _out25;
-case 25:
- switch( (*p) ) {
- case 42: goto st25;
- case 47: goto st2;
- }
- goto st24;
-st26:
- if ( ++p == pe )
- goto _out26;
-case 26:
- if ( (*p) == 10 )
- goto st2;
- goto st26;
- }
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
- _out8: cs = 8; goto _out;
- _out9: cs = 9; goto _out;
- _out10: cs = 10; goto _out;
- _out11: cs = 11; goto _out;
- _out12: cs = 12; goto _out;
- _out13: cs = 13; goto _out;
- _out14: cs = 14; goto _out;
- _out15: cs = 15; goto _out;
- _out16: cs = 16; goto _out;
- _out17: cs = 17; goto _out;
- _out18: cs = 18; goto _out;
- _out27: cs = 27; goto _out;
- _out19: cs = 19; goto _out;
- _out20: cs = 20; goto _out;
- _out21: cs = 21; goto _out;
- _out22: cs = 22; goto _out;
- _out23: cs = 23; goto _out;
- _out24: cs = 24; goto _out;
- _out25: cs = 25; goto _out;
- _out26: cs = 26; goto _out;
-
- _out: {}
- }
-#line 114 "parser.rl"
-
- if (cs >= JSON_object_first_final) {
- if (RTEST(json->create_id)) {
- VALUE klassname = rb_hash_aref(*result, json->create_id);
- if (!NIL_P(klassname)) {
- VALUE klass = rb_path2class(StringValueCStr(klassname));
- if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
- *result = rb_funcall(klass, i_json_create, 1, *result);
- }
- }
- }
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-#line 406 "parser.c"
-static const int JSON_value_start = 1;
-static const int JSON_value_first_final = 21;
-static const int JSON_value_error = 0;
-
-static const int JSON_value_en_main = 1;
-
-#line 212 "parser.rl"
-
-
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
-
-#line 421 "parser.c"
- {
- cs = JSON_value_start;
- }
-#line 219 "parser.rl"
-
-#line 427 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-case 1:
- switch( (*p) ) {
- case 34: goto tr0;
- case 45: goto tr2;
- case 73: goto st2;
- case 78: goto st9;
- case 91: goto tr5;
- case 102: goto st11;
- case 110: goto st15;
- case 116: goto st18;
- case 123: goto tr9;
- }
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr2;
- goto st0;
-st0:
- goto _out0;
-tr0:
-#line 160 "parser.rl"
- {
- char *np = JSON_parse_string(json, p, pe, result);
- if (np == NULL) goto _out21; else {p = (( np))-1;}
- }
- goto st21;
-tr2:
-#line 165 "parser.rl"
- {
- char *np;
- if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) {
- if (json->allow_nan) {
- *result = CMinusInfinity;
- {p = (( p + 10))-1;}
- goto _out21;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p);
- }
- }
- np = JSON_parse_float(json, p, pe, result);
- if (np != NULL) {p = (( np))-1;}
- np = JSON_parse_integer(json, p, pe, result);
- if (np != NULL) {p = (( np))-1;}
- goto _out21;
- }
- goto st21;
-tr5:
-#line 183 "parser.rl"
- {
- char *np;
- json->current_nesting += 1;
- np = JSON_parse_array(json, p, pe, result);
- json->current_nesting -= 1;
- if (np == NULL) goto _out21; else {p = (( np))-1;}
- }
- goto st21;
-tr9:
-#line 191 "parser.rl"
- {
- char *np;
- json->current_nesting += 1;
- np = JSON_parse_object(json, p, pe, result);
- json->current_nesting -= 1;
- if (np == NULL) goto _out21; else {p = (( np))-1;}
- }
- goto st21;
-tr16:
-#line 153 "parser.rl"
- {
- if (json->allow_nan) {
- *result = CInfinity;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p - 8);
- }
- }
- goto st21;
-tr18:
-#line 146 "parser.rl"
- {
- if (json->allow_nan) {
- *result = CNaN;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p - 2);
- }
- }
- goto st21;
-tr22:
-#line 140 "parser.rl"
- {
- *result = Qfalse;
- }
- goto st21;
-tr25:
-#line 137 "parser.rl"
- {
- *result = Qnil;
- }
- goto st21;
-tr28:
-#line 143 "parser.rl"
- {
- *result = Qtrue;
- }
- goto st21;
-st21:
- if ( ++p == pe )
- goto _out21;
-case 21:
-#line 199 "parser.rl"
- { goto _out21; }
-#line 541 "parser.c"
- goto st0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- if ( (*p) == 110 )
- goto st3;
- goto st0;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
- if ( (*p) == 102 )
- goto st4;
- goto st0;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- if ( (*p) == 105 )
- goto st5;
- goto st0;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
- if ( (*p) == 110 )
- goto st6;
- goto st0;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
- if ( (*p) == 105 )
- goto st7;
- goto st0;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
- if ( (*p) == 116 )
- goto st8;
- goto st0;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
- if ( (*p) == 121 )
- goto tr16;
- goto st0;
-st9:
- if ( ++p == pe )
- goto _out9;
-case 9:
- if ( (*p) == 97 )
- goto st10;
- goto st0;
-st10:
- if ( ++p == pe )
- goto _out10;
-case 10:
- if ( (*p) == 78 )
- goto tr18;
- goto st0;
-st11:
- if ( ++p == pe )
- goto _out11;
-case 11:
- if ( (*p) == 97 )
- goto st12;
- goto st0;
-st12:
- if ( ++p == pe )
- goto _out12;
-case 12:
- if ( (*p) == 108 )
- goto st13;
- goto st0;
-st13:
- if ( ++p == pe )
- goto _out13;
-case 13:
- if ( (*p) == 115 )
- goto st14;
- goto st0;
-st14:
- if ( ++p == pe )
- goto _out14;
-case 14:
- if ( (*p) == 101 )
- goto tr22;
- goto st0;
-st15:
- if ( ++p == pe )
- goto _out15;
-case 15:
- if ( (*p) == 117 )
- goto st16;
- goto st0;
-st16:
- if ( ++p == pe )
- goto _out16;
-case 16:
- if ( (*p) == 108 )
- goto st17;
- goto st0;
-st17:
- if ( ++p == pe )
- goto _out17;
-case 17:
- if ( (*p) == 108 )
- goto tr25;
- goto st0;
-st18:
- if ( ++p == pe )
- goto _out18;
-case 18:
- if ( (*p) == 114 )
- goto st19;
- goto st0;
-st19:
- if ( ++p == pe )
- goto _out19;
-case 19:
- if ( (*p) == 117 )
- goto st20;
- goto st0;
-st20:
- if ( ++p == pe )
- goto _out20;
-case 20:
- if ( (*p) == 101 )
- goto tr28;
- goto st0;
- }
- _out0: cs = 0; goto _out;
- _out21: cs = 21; goto _out;
- _out2: cs = 2; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
- _out8: cs = 8; goto _out;
- _out9: cs = 9; goto _out;
- _out10: cs = 10; goto _out;
- _out11: cs = 11; goto _out;
- _out12: cs = 12; goto _out;
- _out13: cs = 13; goto _out;
- _out14: cs = 14; goto _out;
- _out15: cs = 15; goto _out;
- _out16: cs = 16; goto _out;
- _out17: cs = 17; goto _out;
- _out18: cs = 18; goto _out;
- _out19: cs = 19; goto _out;
- _out20: cs = 20; goto _out;
-
- _out: {}
- }
-#line 220 "parser.rl"
-
- if (cs >= JSON_value_first_final) {
- return p;
- } else {
- return NULL;
- }
-}
-
-
-#line 711 "parser.c"
-static const int JSON_integer_start = 1;
-static const int JSON_integer_first_final = 5;
-static const int JSON_integer_error = 0;
-
-static const int JSON_integer_en_main = 1;
-
-#line 236 "parser.rl"
-
-
-static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
-
-#line 726 "parser.c"
- {
- cs = JSON_integer_start;
- }
-#line 243 "parser.rl"
- json->memo = p;
-
-#line 733 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-case 1:
- switch( (*p) ) {
- case 45: goto st2;
- case 48: goto st3;
- }
- if ( 49 <= (*p) && (*p) <= 57 )
- goto st4;
- goto st0;
-st0:
- goto _out0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- if ( (*p) == 48 )
- goto st3;
- if ( 49 <= (*p) && (*p) <= 57 )
- goto st4;
- goto st0;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st0;
- goto tr4;
-tr4:
-#line 233 "parser.rl"
- { goto _out5; }
- goto st5;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
-#line 773 "parser.c"
- goto st0;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st4;
- goto tr4;
- }
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out3: cs = 3; goto _out;
- _out5: cs = 5; goto _out;
- _out4: cs = 4; goto _out;
-
- _out: {}
- }
-#line 245 "parser.rl"
-
- if (cs >= JSON_integer_first_final) {
- long len = p - json->memo;
- *result = rb_Integer(rb_str_new(json->memo, len));
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-#line 803 "parser.c"
-static const int JSON_float_start = 1;
-static const int JSON_float_first_final = 10;
-static const int JSON_float_error = 0;
-
-static const int JSON_float_en_main = 1;
-
-#line 267 "parser.rl"
-
-
-static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
-
-#line 818 "parser.c"
- {
- cs = JSON_float_start;
- }
-#line 274 "parser.rl"
- json->memo = p;
-
-#line 825 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-case 1:
- switch( (*p) ) {
- case 45: goto st2;
- case 48: goto st3;
- }
- if ( 49 <= (*p) && (*p) <= 57 )
- goto st9;
- goto st0;
-st0:
- goto _out0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- if ( (*p) == 48 )
- goto st3;
- if ( 49 <= (*p) && (*p) <= 57 )
- goto st9;
- goto st0;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
- switch( (*p) ) {
- case 46: goto st4;
- case 69: goto st6;
- case 101: goto st6;
- }
- goto st0;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st5;
- goto st0;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
- switch( (*p) ) {
- case 69: goto st6;
- case 101: goto st6;
- }
- if ( (*p) > 46 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st5;
- } else if ( (*p) >= 45 )
- goto st0;
- goto tr7;
-tr7:
-#line 261 "parser.rl"
- { goto _out10; }
- goto st10;
-st10:
- if ( ++p == pe )
- goto _out10;
-case 10:
-#line 889 "parser.c"
- goto st0;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
- switch( (*p) ) {
- case 43: goto st7;
- case 45: goto st7;
- }
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st8;
- goto st0;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st8;
- goto st0;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
- switch( (*p) ) {
- case 69: goto st0;
- case 101: goto st0;
- }
- if ( (*p) > 46 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st8;
- } else if ( (*p) >= 45 )
- goto st0;
- goto tr7;
-st9:
- if ( ++p == pe )
- goto _out9;
-case 9:
- switch( (*p) ) {
- case 46: goto st4;
- case 69: goto st6;
- case 101: goto st6;
- }
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st9;
- goto st0;
- }
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out10: cs = 10; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
- _out8: cs = 8; goto _out;
- _out9: cs = 9; goto _out;
-
- _out: {}
- }
-#line 276 "parser.rl"
-
- if (cs >= JSON_float_first_final) {
- long len = p - json->memo;
- *result = rb_Float(rb_str_new(json->memo, len));
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-
-#line 962 "parser.c"
-static const int JSON_array_start = 1;
-static const int JSON_array_first_final = 17;
-static const int JSON_array_error = 0;
-
-static const int JSON_array_en_main = 1;
-
-#line 312 "parser.rl"
-
-
-static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- if (json->max_nesting && json->current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is to deep", json->current_nesting);
- }
- *result = rb_ary_new();
-
-
-#line 982 "parser.c"
- {
- cs = JSON_array_start;
- }
-#line 324 "parser.rl"
-
-#line 988 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-case 1:
- if ( (*p) == 91 )
- goto st2;
- goto st0;
-st0:
- goto _out0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- switch( (*p) ) {
- case 13: goto st2;
- case 32: goto st2;
- case 34: goto tr2;
- case 45: goto tr2;
- case 47: goto st13;
- case 73: goto tr2;
- case 78: goto tr2;
- case 91: goto tr2;
- case 93: goto tr4;
- case 102: goto tr2;
- case 110: goto tr2;
- case 116: goto tr2;
- case 123: goto tr2;
- }
- if ( (*p) > 10 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr2;
- } else if ( (*p) >= 9 )
- goto st2;
- goto st0;
-tr2:
-#line 293 "parser.rl"
- {
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, p, pe, &v);
- if (np == NULL) {
- goto _out3;
- } else {
- rb_ary_push(*result, v);
- {p = (( np))-1;}
- }
- }
- goto st3;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
-#line 1042 "parser.c"
- switch( (*p) ) {
- case 13: goto st3;
- case 32: goto st3;
- case 44: goto st4;
- case 47: goto st9;
- case 93: goto tr4;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st3;
- goto st0;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- switch( (*p) ) {
- case 13: goto st4;
- case 32: goto st4;
- case 34: goto tr2;
- case 45: goto tr2;
- case 47: goto st5;
- case 73: goto tr2;
- case 78: goto tr2;
- case 91: goto tr2;
- case 102: goto tr2;
- case 110: goto tr2;
- case 116: goto tr2;
- case 123: goto tr2;
- }
- if ( (*p) > 10 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto tr2;
- } else if ( (*p) >= 9 )
- goto st4;
- goto st0;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
- switch( (*p) ) {
- case 42: goto st6;
- case 47: goto st8;
- }
- goto st0;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
- if ( (*p) == 42 )
- goto st7;
- goto st6;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
- switch( (*p) ) {
- case 42: goto st7;
- case 47: goto st4;
- }
- goto st6;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
- if ( (*p) == 10 )
- goto st4;
- goto st8;
-st9:
- if ( ++p == pe )
- goto _out9;
-case 9:
- switch( (*p) ) {
- case 42: goto st10;
- case 47: goto st12;
- }
- goto st0;
-st10:
- if ( ++p == pe )
- goto _out10;
-case 10:
- if ( (*p) == 42 )
- goto st11;
- goto st10;
-st11:
- if ( ++p == pe )
- goto _out11;
-case 11:
- switch( (*p) ) {
- case 42: goto st11;
- case 47: goto st3;
- }
- goto st10;
-st12:
- if ( ++p == pe )
- goto _out12;
-case 12:
- if ( (*p) == 10 )
- goto st3;
- goto st12;
-tr4:
-#line 304 "parser.rl"
- { goto _out17; }
- goto st17;
-st17:
- if ( ++p == pe )
- goto _out17;
-case 17:
-#line 1149 "parser.c"
- goto st0;
-st13:
- if ( ++p == pe )
- goto _out13;
-case 13:
- switch( (*p) ) {
- case 42: goto st14;
- case 47: goto st16;
- }
- goto st0;
-st14:
- if ( ++p == pe )
- goto _out14;
-case 14:
- if ( (*p) == 42 )
- goto st15;
- goto st14;
-st15:
- if ( ++p == pe )
- goto _out15;
-case 15:
- switch( (*p) ) {
- case 42: goto st15;
- case 47: goto st2;
- }
- goto st14;
-st16:
- if ( ++p == pe )
- goto _out16;
-case 16:
- if ( (*p) == 10 )
- goto st2;
- goto st16;
- }
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
- _out8: cs = 8; goto _out;
- _out9: cs = 9; goto _out;
- _out10: cs = 10; goto _out;
- _out11: cs = 11; goto _out;
- _out12: cs = 12; goto _out;
- _out17: cs = 17; goto _out;
- _out13: cs = 13; goto _out;
- _out14: cs = 14; goto _out;
- _out15: cs = 15; goto _out;
- _out16: cs = 16; goto _out;
-
- _out: {}
- }
-#line 325 "parser.rl"
-
- if(cs >= JSON_array_first_final) {
- return p + 1;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p);
- }
-}
-
-static VALUE json_string_unescape(char *p, char *pe)
-{
- VALUE result = rb_str_buf_new(pe - p + 1);
-
- while (p < pe) {
- if (*p == '\\') {
- p++;
- if (p >= pe) return Qnil; /* raise an exception later, \ at end */
- switch (*p) {
- case '"':
- case '\\':
- rb_str_buf_cat(result, p, 1);
- p++;
- break;
- case 'b':
- rb_str_buf_cat2(result, "\b");
- p++;
- break;
- case 'f':
- rb_str_buf_cat2(result, "\f");
- p++;
- break;
- case 'n':
- rb_str_buf_cat2(result, "\n");
- p++;
- break;
- case 'r':
- rb_str_buf_cat2(result, "\r");
- p++;
- break;
- case 't':
- rb_str_buf_cat2(result, "\t");
- p++;
- break;
- case 'u':
- if (p > pe - 4) {
- return Qnil;
- } else {
- p = JSON_convert_UTF16_to_UTF8(result, p, pe, strictConversion);
- }
- break;
- default:
- rb_str_buf_cat(result, p, 1);
- p++;
- break;
- }
- } else {
- char *q = p;
- while (*q != '\\' && q < pe) q++;
- rb_str_buf_cat(result, p, q - p);
- p = q;
- }
- }
- return result;
-}
-
-
-#line 1270 "parser.c"
-static const int JSON_string_start = 1;
-static const int JSON_string_first_final = 8;
-static const int JSON_string_error = 0;
-
-static const int JSON_string_en_main = 1;
-
-#line 403 "parser.rl"
-
-
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- *result = rb_str_new("", 0);
-
-#line 1286 "parser.c"
- {
- cs = JSON_string_start;
- }
-#line 411 "parser.rl"
- json->memo = p;
-
-#line 1293 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-case 1:
- if ( (*p) == 34 )
- goto st2;
- goto st0;
-st0:
- goto _out0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- switch( (*p) ) {
- case 34: goto tr2;
- case 92: goto st3;
- }
- if ( 0 <= (*p) && (*p) <= 31 )
- goto st0;
- goto st2;
-tr2:
-#line 395 "parser.rl"
- {
- *result = json_string_unescape(json->memo + 1, p);
- if (NIL_P(*result)) goto _out8; else {p = (( p + 1))-1;}
- }
-#line 400 "parser.rl"
- { goto _out8; }
- goto st8;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
-#line 1329 "parser.c"
- goto st0;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
- if ( (*p) == 117 )
- goto st4;
- if ( 0 <= (*p) && (*p) <= 31 )
- goto st0;
- goto st2;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st5;
- } else if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto st5;
- } else
- goto st5;
- goto st0;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st6;
- } else if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto st6;
- } else
- goto st6;
- goto st0;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st7;
- } else if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto st7;
- } else
- goto st7;
- goto st0;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
- if ( (*p) < 65 ) {
- if ( 48 <= (*p) && (*p) <= 57 )
- goto st2;
- } else if ( (*p) > 70 ) {
- if ( 97 <= (*p) && (*p) <= 102 )
- goto st2;
- } else
- goto st2;
- goto st0;
- }
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out8: cs = 8; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
-
- _out: {}
- }
-#line 413 "parser.rl"
-
- if (cs >= JSON_string_first_final) {
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-
-#line 1415 "parser.c"
-static const int JSON_start = 1;
-static const int JSON_first_final = 10;
-static const int JSON_error = 0;
-
-static const int JSON_en_main = 1;
-
-#line 447 "parser.rl"
-
-
-/*
- * Document-class: JSON::Ext::Parser
- *
- * This is the JSON parser implemented as a C extension. It can be configured
- * to be used by setting
- *
- * JSON.parser = JSON::Ext::Parser
- *
- * with the method parser= in JSON.
- *
- */
-
-/*
- * call-seq: new(source, opts => {})
- *
- * Creates a new JSON::Ext::Parser instance for the string _source_.
- *
- * Creates a new JSON::Ext::Parser instance for the string _source_.
- *
- * It will be configured by the _opts_ hash. _opts_ can have the following
- * keys:
- *
- * _opts_ can have the following keys:
- * * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- * structures. Disable depth checking with :max_nesting => false|nil|0, it
- * defaults to 19.
- * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
- * false.
- * * *create_additions*: If set to false, the Parser doesn't create
- * additions even if a matchin class and create_id was found. This option
- * defaults to true.
- */
-static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
-{
- char *ptr;
- long len;
- VALUE source, opts;
- GET_STRUCT;
- rb_scan_args(argc, argv, "11", &source, &opts);
- source = StringValue(source);
- ptr = RSTRING_PTR(source);
- len = RSTRING_LEN(source);
- if (len < 2) {
- rb_raise(eParserError, "A JSON text must at least contain two octets!");
- }
- if (!NIL_P(opts)) {
- opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
- if (NIL_P(opts)) {
- rb_raise(rb_eArgError, "opts needs to be like a hash");
- } else {
- VALUE tmp = ID2SYM(i_max_nesting);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE max_nesting = rb_hash_aref(opts, tmp);
- if (RTEST(max_nesting)) {
- Check_Type(max_nesting, T_FIXNUM);
- json->max_nesting = FIX2INT(max_nesting);
- } else {
- json->max_nesting = 0;
- }
- } else {
- json->max_nesting = 19;
- }
- tmp = ID2SYM(i_allow_nan);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE allow_nan = rb_hash_aref(opts, tmp);
- json->allow_nan = RTEST(allow_nan) ? 1 : 0;
- } else {
- json->allow_nan = 0;
- }
- tmp = ID2SYM(i_create_additions);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE create_additions = rb_hash_aref(opts, tmp);
- if (RTEST(create_additions)) {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- } else {
- json->create_id = Qnil;
- }
- } else {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- }
- } else {
- json->max_nesting = 19;
- json->allow_nan = 0;
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- json->current_nesting = 0;
- /*
- Convert these?
- if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- }
- */
- json->len = len;
- json->source = ptr;
- json->Vsource = source;
- return self;
-}
-
-/*
- * call-seq: parse()
- *
- * Parses the current JSON text _source_ and returns the complete data
- * structure as a result.
- */
-static VALUE cParser_parse(VALUE self)
-{
- char *p, *pe;
- int cs = EVIL;
- VALUE result = Qnil;
- GET_STRUCT;
-
-
-#line 1545 "parser.c"
- {
- cs = JSON_start;
- }
-#line 569 "parser.rl"
- p = json->source;
- pe = p + json->len;
-
-#line 1553 "parser.c"
- {
- if ( p == pe )
- goto _out;
- switch ( cs )
- {
-st1:
- if ( ++p == pe )
- goto _out1;
-case 1:
- switch( (*p) ) {
- case 13: goto st1;
- case 32: goto st1;
- case 47: goto st2;
- case 91: goto tr3;
- case 123: goto tr4;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st1;
- goto st0;
-st0:
- goto _out0;
-st2:
- if ( ++p == pe )
- goto _out2;
-case 2:
- switch( (*p) ) {
- case 42: goto st3;
- case 47: goto st5;
- }
- goto st0;
-st3:
- if ( ++p == pe )
- goto _out3;
-case 3:
- if ( (*p) == 42 )
- goto st4;
- goto st3;
-st4:
- if ( ++p == pe )
- goto _out4;
-case 4:
- switch( (*p) ) {
- case 42: goto st4;
- case 47: goto st1;
- }
- goto st3;
-st5:
- if ( ++p == pe )
- goto _out5;
-case 5:
- if ( (*p) == 10 )
- goto st1;
- goto st5;
-tr3:
-#line 436 "parser.rl"
- {
- char *np;
- json->current_nesting = 1;
- np = JSON_parse_array(json, p, pe, &result);
- if (np == NULL) goto _out10; else {p = (( np))-1;}
- }
- goto st10;
-tr4:
-#line 429 "parser.rl"
- {
- char *np;
- json->current_nesting = 1;
- np = JSON_parse_object(json, p, pe, &result);
- if (np == NULL) goto _out10; else {p = (( np))-1;}
- }
- goto st10;
-st10:
- if ( ++p == pe )
- goto _out10;
-case 10:
-#line 1629 "parser.c"
- switch( (*p) ) {
- case 13: goto st10;
- case 32: goto st10;
- case 47: goto st6;
- }
- if ( 9 <= (*p) && (*p) <= 10 )
- goto st10;
- goto st0;
-st6:
- if ( ++p == pe )
- goto _out6;
-case 6:
- switch( (*p) ) {
- case 42: goto st7;
- case 47: goto st9;
- }
- goto st0;
-st7:
- if ( ++p == pe )
- goto _out7;
-case 7:
- if ( (*p) == 42 )
- goto st8;
- goto st7;
-st8:
- if ( ++p == pe )
- goto _out8;
-case 8:
- switch( (*p) ) {
- case 42: goto st8;
- case 47: goto st10;
- }
- goto st7;
-st9:
- if ( ++p == pe )
- goto _out9;
-case 9:
- if ( (*p) == 10 )
- goto st10;
- goto st9;
- }
- _out1: cs = 1; goto _out;
- _out0: cs = 0; goto _out;
- _out2: cs = 2; goto _out;
- _out3: cs = 3; goto _out;
- _out4: cs = 4; goto _out;
- _out5: cs = 5; goto _out;
- _out10: cs = 10; goto _out;
- _out6: cs = 6; goto _out;
- _out7: cs = 7; goto _out;
- _out8: cs = 8; goto _out;
- _out9: cs = 9; goto _out;
-
- _out: {}
- }
-#line 572 "parser.rl"
-
- if (cs >= JSON_first_final && p == pe) {
- return result;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p);
- }
-}
-
-inline static JSON_Parser *JSON_allocate()
-{
- JSON_Parser *json = ALLOC(JSON_Parser);
- MEMZERO(json, JSON_Parser, 1);
- return json;
-}
-
-static void JSON_mark(JSON_Parser *json)
-{
- rb_gc_mark_maybe(json->Vsource);
- rb_gc_mark_maybe(json->create_id);
-}
-
-static void JSON_free(JSON_Parser *json)
-{
- free(json);
-}
-
-static VALUE cJSON_parser_s_allocate(VALUE klass)
-{
- JSON_Parser *json = JSON_allocate();
- return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
-}
-
-/*
- * call-seq: source()
- *
- * Returns a copy of the current _source_ string, that was used to construct
- * this Parser.
- */
-static VALUE cParser_source(VALUE self)
-{
- GET_STRUCT;
- return rb_str_dup(json->Vsource);
-}
-
-void Init_parser()
-{
- mJSON = rb_define_module("JSON");
- mExt = rb_define_module_under(mJSON, "Ext");
- cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
- eParserError = rb_path2class("JSON::ParserError");
- eNestingError = rb_path2class("JSON::NestingError");
- rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
- rb_define_method(cParser, "initialize", cParser_initialize, -1);
- rb_define_method(cParser, "parse", cParser_parse, 0);
- rb_define_method(cParser, "source", cParser_source, 0);
-
- CNaN = rb_const_get(mJSON, rb_intern("NaN"));
- CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
-
- i_json_creatable_p = rb_intern("json_creatable?");
- i_json_create = rb_intern("json_create");
- i_create_id = rb_intern("create_id");
- i_create_additions = rb_intern("create_additions");
- i_chr = rb_intern("chr");
- i_max_nesting = rb_intern("max_nesting");
- i_allow_nan = rb_intern("allow_nan");
-}
diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
deleted file mode 100644
index 840b8e0f10..0000000000
--- a/ext/json/ext/parser/parser.rl
+++ /dev/null
@@ -1,639 +0,0 @@
-/* vim: set cin et sw=4 ts=4: */
-
-#include "ruby.h"
-#include "ruby/re.h"
-#include "ruby/st.h"
-#include "unicode.h"
-
-#define EVIL 0x666
-
-static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
-static VALUE CNaN, CInfinity, CMinusInfinity;
-
-static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
- i_chr, i_max_nesting, i_allow_nan;
-
-#define MinusInfinity "-Infinity"
-
-typedef struct JSON_ParserStruct {
- VALUE Vsource;
- char *source;
- long len;
- char *memo;
- VALUE create_id;
- int max_nesting;
- int current_nesting;
- int allow_nan;
-} JSON_Parser;
-
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
-static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
-
-#define GET_STRUCT \
- JSON_Parser *json; \
- Data_Get_Struct(self, JSON_Parser, json);
-
-%%{
- machine JSON_common;
-
- cr = '\n';
- cr_neg = [^\n];
- ws = [ \t\r\n];
- c_comment = '/*' ( any* - (any* '*/' any* ) ) '*/';
- cpp_comment = '//' cr_neg* cr;
- comment = c_comment | cpp_comment;
- ignore = ws | comment;
- name_separator = ':';
- value_separator = ',';
- Vnull = 'null';
- Vfalse = 'false';
- Vtrue = 'true';
- VNaN = 'NaN';
- VInfinity = 'Infinity';
- VMinusInfinity = '-Infinity';
- begin_value = [nft"\-[{NI] | digit;
- begin_object = '{';
- end_object = '}';
- begin_array = '[';
- end_array = ']';
- begin_string = '"';
- begin_name = begin_string;
- begin_number = digit | '-';
-}%%
-
-%%{
- machine JSON_object;
- include JSON_common;
-
- write data;
-
- action parse_value {
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, fpc, pe, &v);
- if (np == NULL) {
- fbreak;
- } else {
- rb_hash_aset(*result, last_name, v);
- fexec np;
- }
- }
-
- action parse_name {
- char *np = JSON_parse_string(json, fpc, pe, &last_name);
- if (np == NULL) fbreak; else fexec np;
- }
-
- action exit { fbreak; }
-
- a_pair = ignore* begin_name >parse_name
- ignore* name_separator ignore*
- begin_value >parse_value;
-
- main := begin_object
- (a_pair (ignore* value_separator a_pair)*)?
- ignore* end_object @exit;
-}%%
-
-static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
- VALUE last_name = Qnil;
-
- if (json->max_nesting && json->current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is to deep", json->current_nesting);
- }
-
- *result = rb_hash_new();
-
- %% write init;
- %% write exec;
-
- if (cs >= JSON_object_first_final) {
- if (RTEST(json->create_id)) {
- VALUE klassname = rb_hash_aref(*result, json->create_id);
- if (!NIL_P(klassname)) {
- VALUE klass = rb_path2class(StringValueCStr(klassname));
- if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
- *result = rb_funcall(klass, i_json_create, 1, *result);
- }
- }
- }
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-%%{
- machine JSON_value;
- include JSON_common;
-
- write data;
-
- action parse_null {
- *result = Qnil;
- }
- action parse_false {
- *result = Qfalse;
- }
- action parse_true {
- *result = Qtrue;
- }
- action parse_nan {
- if (json->allow_nan) {
- *result = CNaN;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p - 2);
- }
- }
- action parse_infinity {
- if (json->allow_nan) {
- *result = CInfinity;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p - 8);
- }
- }
- action parse_string {
- char *np = JSON_parse_string(json, fpc, pe, result);
- if (np == NULL) fbreak; else fexec np;
- }
-
- action parse_number {
- char *np;
- if(pe > fpc + 9 && !strncmp(MinusInfinity, fpc, 9)) {
- if (json->allow_nan) {
- *result = CMinusInfinity;
- fexec p + 10;
- fbreak;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p);
- }
- }
- np = JSON_parse_float(json, fpc, pe, result);
- if (np != NULL) fexec np;
- np = JSON_parse_integer(json, fpc, pe, result);
- if (np != NULL) fexec np;
- fbreak;
- }
-
- action parse_array {
- char *np;
- json->current_nesting += 1;
- np = JSON_parse_array(json, fpc, pe, result);
- json->current_nesting -= 1;
- if (np == NULL) fbreak; else fexec np;
- }
-
- action parse_object {
- char *np;
- json->current_nesting += 1;
- np = JSON_parse_object(json, fpc, pe, result);
- json->current_nesting -= 1;
- if (np == NULL) fbreak; else fexec np;
- }
-
- action exit { fbreak; }
-
-main := (
- Vnull @parse_null |
- Vfalse @parse_false |
- Vtrue @parse_true |
- VNaN @parse_nan |
- VInfinity @parse_infinity |
- begin_number >parse_number |
- begin_string >parse_string |
- begin_array >parse_array |
- begin_object >parse_object
- ) %*exit;
-}%%
-
-static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- %% write init;
- %% write exec;
-
- if (cs >= JSON_value_first_final) {
- return p;
- } else {
- return NULL;
- }
-}
-
-%%{
- machine JSON_integer;
-
- write data;
-
- action exit { fbreak; }
-
- main := '-'? ('0' | [1-9][0-9]*) (^[0-9] @exit);
-}%%
-
-static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- %% write init;
- json->memo = p;
- %% write exec;
-
- if (cs >= JSON_integer_first_final) {
- long len = p - json->memo;
- *result = rb_Integer(rb_str_new(json->memo, len));
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-%%{
- machine JSON_float;
- include JSON_common;
-
- write data;
-
- action exit { fbreak; }
-
- main := '-'? (
- (('0' | [1-9][0-9]*) '.' [0-9]+ ([Ee] [+\-]?[0-9]+)?)
- | (('0' | [1-9][0-9]*) ([Ee] [+\-]?[0-9]+))
- ) (^[0-9Ee.\-] @exit );
-}%%
-
-static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- %% write init;
- json->memo = p;
- %% write exec;
-
- if (cs >= JSON_float_first_final) {
- long len = p - json->memo;
- *result = rb_Float(rb_str_new(json->memo, len));
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-%%{
- machine JSON_array;
- include JSON_common;
-
- write data;
-
- action parse_value {
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, fpc, pe, &v);
- if (np == NULL) {
- fbreak;
- } else {
- rb_ary_push(*result, v);
- fexec np;
- }
- }
-
- action exit { fbreak; }
-
- next_element = value_separator ignore* begin_value >parse_value;
-
- main := begin_array ignore*
- ((begin_value >parse_value ignore*)
- (ignore* next_element ignore*)*)?
- end_array @exit;
-}%%
-
-static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- if (json->max_nesting && json->current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is to deep", json->current_nesting);
- }
- *result = rb_ary_new();
-
- %% write init;
- %% write exec;
-
- if(cs >= JSON_array_first_final) {
- return p + 1;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p);
- }
-}
-
-static VALUE json_string_unescape(char *p, char *pe)
-{
- VALUE result = rb_str_buf_new(pe - p + 1);
-
- while (p < pe) {
- if (*p == '\\') {
- p++;
- if (p >= pe) return Qnil; /* raise an exception later, \ at end */
- switch (*p) {
- case '"':
- case '\\':
- rb_str_buf_cat(result, p, 1);
- p++;
- break;
- case 'b':
- rb_str_buf_cat2(result, "\b");
- p++;
- break;
- case 'f':
- rb_str_buf_cat2(result, "\f");
- p++;
- break;
- case 'n':
- rb_str_buf_cat2(result, "\n");
- p++;
- break;
- case 'r':
- rb_str_buf_cat2(result, "\r");
- p++;
- break;
- case 't':
- rb_str_buf_cat2(result, "\t");
- p++;
- break;
- case 'u':
- if (p > pe - 4) {
- return Qnil;
- } else {
- p = JSON_convert_UTF16_to_UTF8(result, p, pe, strictConversion);
- }
- break;
- default:
- rb_str_buf_cat(result, p, 1);
- p++;
- break;
- }
- } else {
- char *q = p;
- while (*q != '\\' && q < pe) q++;
- rb_str_buf_cat(result, p, q - p);
- p = q;
- }
- }
- return result;
-}
-
-%%{
- machine JSON_string;
- include JSON_common;
-
- write data;
-
- action parse_string {
- *result = json_string_unescape(json->memo + 1, p);
- if (NIL_P(*result)) fbreak; else fexec p + 1;
- }
-
- action exit { fbreak; }
-
- main := '"' ((^(["\\] | 0..0x1f) | '\\'["\\/bfnrt] | '\\u'[0-9a-fA-F]{4} | '\\'^(["\\/bfnrtu]|0..0x1f))* %parse_string) '"' @exit;
-}%%
-
-static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
-{
- int cs = EVIL;
-
- *result = rb_str_new("", 0);
- %% write init;
- json->memo = p;
- %% write exec;
-
- if (cs >= JSON_string_first_final) {
- return p + 1;
- } else {
- return NULL;
- }
-}
-
-
-%%{
- machine JSON;
-
- write data;
-
- include JSON_common;
-
- action parse_object {
- char *np;
- json->current_nesting = 1;
- np = JSON_parse_object(json, fpc, pe, &result);
- if (np == NULL) fbreak; else fexec np;
- }
-
- action parse_array {
- char *np;
- json->current_nesting = 1;
- np = JSON_parse_array(json, fpc, pe, &result);
- if (np == NULL) fbreak; else fexec np;
- }
-
- main := ignore* (
- begin_object >parse_object |
- begin_array >parse_array
- ) ignore*;
-}%%
-
-/*
- * Document-class: JSON::Ext::Parser
- *
- * This is the JSON parser implemented as a C extension. It can be configured
- * to be used by setting
- *
- * JSON.parser = JSON::Ext::Parser
- *
- * with the method parser= in JSON.
- *
- */
-
-/*
- * call-seq: new(source, opts => {})
- *
- * Creates a new JSON::Ext::Parser instance for the string _source_.
- *
- * Creates a new JSON::Ext::Parser instance for the string _source_.
- *
- * It will be configured by the _opts_ hash. _opts_ can have the following
- * keys:
- *
- * _opts_ can have the following keys:
- * * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- * structures. Disable depth checking with :max_nesting => false|nil|0, it
- * defaults to 19.
- * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
- * false.
- * * *create_additions*: If set to false, the Parser doesn't create
- * additions even if a matchin class and create_id was found. This option
- * defaults to true.
- */
-static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
-{
- char *ptr;
- long len;
- VALUE source, opts;
- GET_STRUCT;
- rb_scan_args(argc, argv, "11", &source, &opts);
- source = StringValue(source);
- ptr = RSTRING_PTR(source);
- len = RSTRING_LEN(source);
- if (len < 2) {
- rb_raise(eParserError, "A JSON text must at least contain two octets!");
- }
- if (!NIL_P(opts)) {
- opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
- if (NIL_P(opts)) {
- rb_raise(rb_eArgError, "opts needs to be like a hash");
- } else {
- VALUE tmp = ID2SYM(i_max_nesting);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE max_nesting = rb_hash_aref(opts, tmp);
- if (RTEST(max_nesting)) {
- Check_Type(max_nesting, T_FIXNUM);
- json->max_nesting = FIX2INT(max_nesting);
- } else {
- json->max_nesting = 0;
- }
- } else {
- json->max_nesting = 19;
- }
- tmp = ID2SYM(i_allow_nan);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE allow_nan = rb_hash_aref(opts, tmp);
- json->allow_nan = RTEST(allow_nan) ? 1 : 0;
- } else {
- json->allow_nan = 0;
- }
- tmp = ID2SYM(i_create_additions);
- if (st_lookup(RHASH_TBL(opts), tmp, 0)) {
- VALUE create_additions = rb_hash_aref(opts, tmp);
- if (RTEST(create_additions)) {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- } else {
- json->create_id = Qnil;
- }
- } else {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- }
- } else {
- json->max_nesting = 19;
- json->allow_nan = 0;
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- json->current_nesting = 0;
- /*
- Convert these?
- if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
- rb_raise(eParserError, "Only UTF8 octet streams are supported atm!");
- }
- */
- json->len = len;
- json->source = ptr;
- json->Vsource = source;
- return self;
-}
-
-/*
- * call-seq: parse()
- *
- * Parses the current JSON text _source_ and returns the complete data
- * structure as a result.
- */
-static VALUE cParser_parse(VALUE self)
-{
- char *p, *pe;
- int cs = EVIL;
- VALUE result = Qnil;
- GET_STRUCT;
-
- %% write init;
- p = json->source;
- pe = p + json->len;
- %% write exec;
-
- if (cs >= JSON_first_final && p == pe) {
- return result;
- } else {
- rb_raise(eParserError, "unexpected token at '%s'", p);
- }
-}
-
-inline static JSON_Parser *JSON_allocate()
-{
- JSON_Parser *json = ALLOC(JSON_Parser);
- MEMZERO(json, JSON_Parser, 1);
- return json;
-}
-
-static void JSON_mark(JSON_Parser *json)
-{
- rb_gc_mark_maybe(json->Vsource);
- rb_gc_mark_maybe(json->create_id);
-}
-
-static void JSON_free(JSON_Parser *json)
-{
- free(json);
-}
-
-static VALUE cJSON_parser_s_allocate(VALUE klass)
-{
- JSON_Parser *json = JSON_allocate();
- return Data_Wrap_Struct(klass, JSON_mark, JSON_free, json);
-}
-
-/*
- * call-seq: source()
- *
- * Returns a copy of the current _source_ string, that was used to construct
- * this Parser.
- */
-static VALUE cParser_source(VALUE self)
-{
- GET_STRUCT;
- return rb_str_dup(json->Vsource);
-}
-
-void Init_parser()
-{
- mJSON = rb_define_module("JSON");
- mExt = rb_define_module_under(mJSON, "Ext");
- cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
- eParserError = rb_path2class("JSON::ParserError");
- eNestingError = rb_path2class("JSON::NestingError");
- rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
- rb_define_method(cParser, "initialize", cParser_initialize, -1);
- rb_define_method(cParser, "parse", cParser_parse, 0);
- rb_define_method(cParser, "source", cParser_source, 0);
-
- CNaN = rb_const_get(mJSON, rb_intern("NaN"));
- CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
-
- i_json_creatable_p = rb_intern("json_creatable?");
- i_json_create = rb_intern("json_create");
- i_create_id = rb_intern("create_id");
- i_create_additions = rb_intern("create_additions");
- i_chr = rb_intern("chr");
- i_max_nesting = rb_intern("max_nesting");
- i_allow_nan = rb_intern("allow_nan");
-}
diff --git a/ext/json/ext/parser/unicode.c b/ext/json/ext/parser/unicode.c
deleted file mode 100644
index 609a0e83e2..0000000000
--- a/ext/json/ext/parser/unicode.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* vim: set cin et sw=4 ts=4: */
-
-#include "unicode.h"
-
-/*
- * Copyright 2001-2004 Unicode, Inc.
- *
- * Disclaimer
- *
- * This source code is provided as is by Unicode, Inc. No claims are
- * made as to fitness for any particular purpose. No warranties of any
- * kind are expressed or implied. The recipient agrees to determine
- * applicability of information provided. If this file has been
- * purchased on magnetic or optical media from Unicode, Inc., the
- * sole remedy for any claim will be exchange of defective media
- * within 90 days of receipt.
- *
- * Limitations on Rights to Redistribute This Code
- *
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form
- * for internal or external distribution as long as this notice
- * remains attached.
- */
-
-/*
- * Index into the table below with the first byte of a UTF-8 sequence to
- * get the number of trailing bytes that are supposed to follow it.
- * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
- * left as-is for anyone who may want to do such conversion, which was
- * allowed in earlier algorithms.
- */
-static const char trailingBytesForUTF8[256] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
-};
-
-/*
- * Magic values subtracted from a buffer value during UTF8 conversion.
- * This table contains as many values as there might be trailing bytes
- * in a UTF-8 sequence.
- */
-static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
-
-/*
- * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
- * into the first byte, depending on how many bytes follow. There are
- * as many entries in this table as there are UTF-8 sequence types.
- * (I.e., one byte sequence, two byte... etc.). Remember that sequencs
- * for *legal* UTF-8 will be 4 or fewer bytes total.
- */
-static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
-char *JSON_convert_UTF16_to_UTF8 (
- VALUE buffer,
- char *source,
- char *sourceEnd,
- ConversionFlags flags)
-{
- UTF16 *tmp, *tmpPtr, *tmpEnd;
- char buf[5];
- long n = 0, i;
- char *p = source - 1;
-
- while (p < sourceEnd && p[0] == '\\' && p[1] == 'u') {
- p += 6;
- n++;
- }
- p = source + 1;
- buf[4] = 0;
- tmpPtr = tmp = ALLOC_N(UTF16, n);
- tmpEnd = tmp + n;
- for (i = 0; i < n; i++) {
- buf[0] = *p++;
- buf[1] = *p++;
- buf[2] = *p++;
- buf[3] = *p++;
- tmpPtr[i] = strtol(buf, NULL, 16);
- p += 2;
- }
-
- while (tmpPtr < tmpEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- ch = *tmpPtr++;
- /* If we have a surrogate pair, convert to UTF32 first. */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
- /* If the 16 bits following the high surrogate are in the source
- * buffer... */
- if (tmpPtr < tmpEnd) {
- UTF32 ch2 = *tmpPtr;
- /* If it's a low surrogate, convert to UTF32. */
- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
- ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
- + (ch2 - UNI_SUR_LOW_START) + halfBase;
- ++tmpPtr;
- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- free(tmp);
- rb_raise(rb_path2class("JSON::ParserError"),
- "source sequence is illegal/malformed near %s", source);
- }
- } else { /* We don't have the 16 bits following the high surrogate. */
- free(tmp);
- rb_raise(rb_path2class("JSON::ParserError"),
- "partial character in source, but hit end near %s", source);
- break;
- }
- } else if (flags == strictConversion) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- free(tmp);
- rb_raise(rb_path2class("JSON::ParserError"),
- "source sequence is illegal/malformed near %s", source);
- }
- }
- /* Figure out how many bytes the result will require */
- if (ch < (UTF32) 0x80) {
- bytesToWrite = 1;
- } else if (ch < (UTF32) 0x800) {
- bytesToWrite = 2;
- } else if (ch < (UTF32) 0x10000) {
- bytesToWrite = 3;
- } else if (ch < (UTF32) 0x110000) {
- bytesToWrite = 4;
- } else {
- bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- }
-
- buf[0] = 0;
- buf[1] = 0;
- buf[2] = 0;
- buf[3] = 0;
- p = buf + bytesToWrite;
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--p = (UTF8) (ch | firstByteMark[bytesToWrite]);
- }
- rb_str_buf_cat(buffer, p, bytesToWrite);
- }
- free(tmp);
- source += 5 + (n - 1) * 6;
- return source;
-}
diff --git a/ext/json/ext/parser/unicode.h b/ext/json/ext/parser/unicode.h
deleted file mode 100644
index 155da0ceee..0000000000
--- a/ext/json/ext/parser/unicode.h
+++ /dev/null
@@ -1,58 +0,0 @@
-
-#ifndef _PARSER_UNICODE_H_
-#define _PARSER_UNICODE_H_
-
-#include "ruby.h"
-
-typedef unsigned long UTF32; /* at least 32 bits */
-typedef unsigned short UTF16; /* at least 16 bits */
-typedef unsigned char UTF8; /* typically 8 bits */
-
-#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
-#define UNI_MAX_BMP (UTF32)0x0000FFFF
-#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
-#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
-#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
-
-#define UNI_SUR_HIGH_START (UTF32)0xD800
-#define UNI_SUR_HIGH_END (UTF32)0xDBFF
-#define UNI_SUR_LOW_START (UTF32)0xDC00
-#define UNI_SUR_LOW_END (UTF32)0xDFFF
-
-static const int halfShift = 10; /* used for shifting by 10 bits */
-
-static const UTF32 halfBase = 0x0010000UL;
-static const UTF32 halfMask = 0x3FFUL;
-
-typedef enum {
- conversionOK = 0, /* conversion successful */
- sourceExhausted, /* partial character in source, but hit end */
- targetExhausted, /* insuff. room in target for conversion */
- sourceIllegal /* source sequence is illegal/malformed */
-} ConversionResult;
-
-typedef enum {
- strictConversion = 0,
- lenientConversion
-} ConversionFlags;
-
-char *JSON_convert_UTF16_to_UTF8 (
- VALUE buffer,
- char *source,
- char *sourceEnd,
- ConversionFlags flags);
-
-#ifndef RARRAY_PTR
-#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
-#endif
-#ifndef RARRAY_LEN
-#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
-#endif
-#ifndef RSTRING_PTR
-#define RSTRING_PTR(string) RSTRING(string)->ptr
-#endif
-#ifndef RSTRING_LEN
-#define RSTRING_LEN(string) RSTRING(string)->len
-#endif
-
-#endif
diff --git a/ext/json/extconf.rb b/ext/json/extconf.rb
deleted file mode 100644
index 850798c643..0000000000
--- a/ext/json/extconf.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'mkmf'
-create_makefile('json')
-
diff --git a/ext/json/lib/json.rb b/ext/json/lib/json.rb
deleted file mode 100644
index 3b0b711550..0000000000
--- a/ext/json/lib/json.rb
+++ /dev/null
@@ -1,235 +0,0 @@
-require 'json/common'
-# = json - JSON for Ruby
-#
-# == Description
-#
-# This is a implementation of the JSON specification according to RFC 4627
-# (http://www.ietf.org/rfc/rfc4627.txt). Starting from version 1.0.0 on there
-# will be two variants available:
-#
-# * A pure ruby variant, that relies on the iconv and the stringscan
-# extensions, which are both part of the ruby standard library.
-# * The quite a bit faster C extension variant, which is in parts implemented
-# in C and comes with its own unicode conversion functions and a parser
-# generated by the ragel state machine compiler
-# (http://www.cs.queensu.ca/~thurston/ragel).
-#
-# Both variants of the JSON generator escape all non-ASCII an control
-# characters with \uXXXX escape sequences, and support UTF-16 surrogate pairs
-# in order to be able to generate the whole range of unicode code points. This
-# means that generated JSON text is encoded as UTF-8 (because ASCII is a subset
-# of UTF-8) and at the same time avoids decoding problems for receiving
-# endpoints, that don't expect UTF-8 encoded texts. On the negative side this
-# may lead to a bit longer strings than necessarry.
-#
-# All strings, that are to be encoded as JSON strings, should be UTF-8 byte
-# sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8
-# encoded, please use the to_json_raw_object method of String (which produces
-# an object, that contains a byte array) and decode the result on the receiving
-# endpoint.
-#
-# == Author
-#
-# Florian Frank <mailto:flori@ping.de>
-#
-# == License
-#
-# This software is distributed under the same license as Ruby itself, see
-# http://www.ruby-lang.org/en/LICENSE.txt.
-#
-# == Download
-#
-# The latest version of this library can be downloaded at
-#
-# * http://rubyforge.org/frs?group_id=953
-#
-# Online Documentation should be located at
-#
-# * http://json.rubyforge.org
-#
-# == Usage
-#
-# To use JSON you can
-# require 'json'
-# to load the installed variant (either the extension 'json' or the pure
-# variant 'json_pure'). If you have installed the extension variant, you can
-# pick either the extension variant or the pure variant by typing
-# require 'json/ext'
-# or
-# require 'json/pure'
-#
-# You can choose to load a set of common additions to ruby core's objects if
-# you
-# require 'json/add/core'
-#
-# After requiring this you can, e. g., serialise/deserialise Ruby ranges:
-#
-# JSON JSON(1..10) # => 1..10
-#
-# To find out how to add JSON support to other or your own classes, read the
-# Examples section below.
-#
-# To get the best compatibility to rails' JSON implementation, you can
-# require 'json/add/rails'
-#
-# Both of the additions attempt to require 'json' (like above) first, if it has
-# not been required yet.
-#
-# == Speed Comparisons
-#
-# I have created some benchmark results (see the benchmarks subdir of the
-# package) for the JSON-Parser to estimate the speed up in the C extension:
-#
-# JSON::Pure::Parser:: 28.90 calls/second
-# JSON::Ext::Parser:: 505.50 calls/second
-#
-# This is ca. <b>17.5</b> times the speed of the pure Ruby implementation.
-#
-# I have benchmarked the JSON-Generator as well. This generates a few more
-# values, because there are different modes, that also influence the achieved
-# speed:
-#
-# * JSON::Pure::Generator:
-# generate:: 35.06 calls/second
-# pretty_generate:: 34.00 calls/second
-# fast_generate:: 41.06 calls/second
-#
-# * JSON::Ext::Generator:
-# generate:: 492.11 calls/second
-# pretty_generate:: 348.85 calls/second
-# fast_generate:: 541.60 calls/second
-#
-# * Speedup Ext/Pure:
-# generate safe:: 14.0 times
-# generate pretty:: 10.3 times
-# generate fast:: 13.2 times
-#
-# The rails framework includes a generator as well, also it seems to be rather
-# slow: I measured only 23.87 calls/second which is slower than any of my pure
-# generator results. Here a comparison of the different speedups with the Rails
-# measurement as the divisor:
-#
-# * Speedup Pure/Rails:
-# generate safe:: 1.5 times
-# generate pretty:: 1.4 times
-# generate fast:: 1.7 times
-#
-# * Speedup Ext/Rails:
-# generate safe:: 20.6 times
-# generate pretty:: 14.6 times
-# generate fast:: 22.7 times
-#
-# To achieve the fastest JSON text output, you can use the
-# fast_generate/fast_unparse methods. Beware, that this will disable the
-# checking for circular Ruby data structures, which may cause JSON to go into
-# an infinite loop.
-#
-# == Examples
-#
-# To create a JSON text from a ruby data structure, you
-# can call JSON.generate (or JSON.unparse) like that:
-#
-# json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
-# # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
-#
-# To create a valid JSON text you have to make sure, that the output is
-# embedded in either a JSON array [] or a JSON object {}. The easiest way to do
-# this, is by putting your values in a Ruby Array or Hash instance.
-#
-# To get back a ruby data structure from a JSON text, you have to call
-# JSON.parse on it:
-#
-# JSON.parse json
-# # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
-#
-# Note, that the range from the original data structure is a simple
-# string now. The reason for this is, that JSON doesn't support ranges
-# or arbitrary classes. In this case the json library falls back to call
-# Object#to_json, which is the same as #to_s.to_json.
-#
-# It's possible to add JSON support serialization to arbitrary classes by
-# simply implementing a more specialized version of the #to_json method, that
-# should return a JSON object (a hash converted to JSON with #to_json) like
-# this (don't forget the *a for all the arguments):
-#
-# class Range
-# def to_json(*a)
-# {
-# 'json_class' => self.class.name, # = 'Range'
-# 'data' => [ first, last, exclude_end? ]
-# }.to_json(*a)
-# end
-# end
-#
-# The hash key 'json_class' is the class, that will be asked to deserialise the
-# JSON representation later. In this case it's 'Range', but any namespace of
-# the form 'A::B' or '::A::B' will do. All other keys are arbitrary and can be
-# used to store the necessary data to configure the object to be deserialised.
-#
-# If a the key 'json_class' is found in a JSON object, the JSON parser checks
-# if the given class responds to the json_create class method. If so, it is
-# called with the JSON object converted to a Ruby hash. So a range can
-# be deserialised by implementing Range.json_create like this:
-#
-# class Range
-# def self.json_create(o)
-# new(*o['data'])
-# end
-# end
-#
-# Now it possible to serialise/deserialise ranges as well:
-#
-# json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
-# # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
-# JSON.parse json
-# # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
-#
-# JSON.generate always creates the shortest possible string representation of a
-# ruby data structure in one line. This good for data storage or network
-# protocols, but not so good for humans to read. Fortunately there's also
-# JSON.pretty_generate (or JSON.pretty_generate) that creates a more
-# readable output:
-#
-# puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
-# [
-# 1,
-# 2,
-# {
-# "a": 3.141
-# },
-# false,
-# true,
-# null,
-# {
-# "json_class": "Range",
-# "data": [
-# 4,
-# 10,
-# false
-# ]
-# }
-# ]
-#
-# There are also the methods Kernel#j for unparse, and Kernel#jj for
-# pretty_unparse output to the console, that work analogous to Core Ruby's p
-# and the pp library's pp methods.
-#
-# The script tools/server.rb contains a small example if you want to test, how
-# receiving a JSON object from a webrick server in your browser with the
-# javasript prototype library (http://www.prototypejs.org) works.
-#
-module JSON
- require 'json/version'
-
- if VARIANT_BINARY
- require 'json/ext'
- else
- begin
- require 'json/ext'
- rescue LoadError
- require 'json/pure'
- end
- end
-
- JSON_LOADED = true
-end
diff --git a/ext/json/lib/json/Array.xpm b/ext/json/lib/json/Array.xpm
deleted file mode 100644
index 27c48011f9..0000000000
--- a/ext/json/lib/json/Array.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * Array_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" .......... ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" .......... ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/FalseClass.xpm b/ext/json/lib/json/FalseClass.xpm
deleted file mode 100644
index 25ce60832d..0000000000
--- a/ext/json/lib/json/FalseClass.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * False_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #FF0000",
-" ",
-" ",
-" ",
-" ...... ",
-" . ",
-" . ",
-" . ",
-" ...... ",
-" . ",
-" . ",
-" . ",
-" . ",
-" . ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/Hash.xpm b/ext/json/lib/json/Hash.xpm
deleted file mode 100644
index cd8f6f7b53..0000000000
--- a/ext/json/lib/json/Hash.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * Hash_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" . . ",
-" . . ",
-" . . ",
-" ......... ",
-" . . ",
-" . . ",
-" ......... ",
-" . . ",
-" . . ",
-" . . ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/Key.xpm b/ext/json/lib/json/Key.xpm
deleted file mode 100644
index 9fd7281388..0000000000
--- a/ext/json/lib/json/Key.xpm
+++ /dev/null
@@ -1,73 +0,0 @@
-/* XPM */
-static char * Key_xpm[] = {
-"16 16 54 1",
-" c None",
-". c #110007",
-"+ c #0E0900",
-"@ c #000013",
-"# c #070600",
-"$ c #F6F006",
-"% c #ECE711",
-"& c #E5EE00",
-"* c #16021E",
-"= c #120900",
-"- c #EDF12B",
-"; c #000033",
-"> c #0F0000",
-", c #FFFE03",
-"' c #E6E500",
-") c #16021B",
-"! c #F7F502",
-"~ c #000E00",
-"{ c #130000",
-"] c #FFF000",
-"^ c #FFE711",
-"/ c #140005",
-"( c #190025",
-"_ c #E9DD27",
-": c #E7DC04",
-"< c #FFEC09",
-"[ c #FFE707",
-"} c #FFDE10",
-"| c #150021",
-"1 c #160700",
-"2 c #FAF60E",
-"3 c #EFE301",
-"4 c #FEF300",
-"5 c #E7E000",
-"6 c #FFFF08",
-"7 c #0E0206",
-"8 c #040000",
-"9 c #03052E",
-"0 c #041212",
-"a c #070300",
-"b c #F2E713",
-"c c #F9DE13",
-"d c #36091E",
-"e c #00001C",
-"f c #1F0010",
-"g c #FFF500",
-"h c #DEDE00",
-"i c #050A00",
-"j c #FAF14A",
-"k c #F5F200",
-"l c #040404",
-"m c #1A0D00",
-"n c #EDE43D",
-"o c #ECE007",
-" ",
-" ",
-" .+@ ",
-" #$%&* ",
-" =-;>,') ",
-" >!~{]^/ ",
-" (_:<[}| ",
-" 1234567 ",
-" 890abcd ",
-" efghi ",
-" >jkl ",
-" mnol ",
-" >kl ",
-" ll ",
-" ",
-" "};
diff --git a/ext/json/lib/json/NilClass.xpm b/ext/json/lib/json/NilClass.xpm
deleted file mode 100644
index 3509f06c99..0000000000
--- a/ext/json/lib/json/NilClass.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * False_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" ... ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" ... ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/Numeric.xpm b/ext/json/lib/json/Numeric.xpm
deleted file mode 100644
index e071e2ee9c..0000000000
--- a/ext/json/lib/json/Numeric.xpm
+++ /dev/null
@@ -1,28 +0,0 @@
-/* XPM */
-static char * Numeric_xpm[] = {
-"16 16 9 1",
-" c None",
-". c #FF0000",
-"+ c #0000FF",
-"@ c #0023DB",
-"# c #00EA14",
-"$ c #00FF00",
-"% c #004FAF",
-"& c #0028D6",
-"* c #00F20C",
-" ",
-" ",
-" ",
-" ... +++@#$$$$ ",
-" .+ %& $$ ",
-" . + $ ",
-" . + $$ ",
-" . ++$$$$ ",
-" . + $$ ",
-" . + $ ",
-" . + $ ",
-" . + $ $$ ",
-" .....++++*$$ ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/String.xpm b/ext/json/lib/json/String.xpm
deleted file mode 100644
index f79a89cdc1..0000000000
--- a/ext/json/lib/json/String.xpm
+++ /dev/null
@@ -1,96 +0,0 @@
-/* XPM */
-static char * String_xpm[] = {
-"16 16 77 1",
-" c None",
-". c #000000",
-"+ c #040404",
-"@ c #080806",
-"# c #090606",
-"$ c #EEEAE1",
-"% c #E7E3DA",
-"& c #E0DBD1",
-"* c #D4B46F",
-"= c #0C0906",
-"- c #E3C072",
-"; c #E4C072",
-"> c #060505",
-", c #0B0A08",
-"' c #D5B264",
-") c #D3AF5A",
-"! c #080602",
-"~ c #E1B863",
-"{ c #DDB151",
-"] c #DBAE4A",
-"^ c #DDB152",
-"/ c #DDB252",
-"( c #070705",
-"_ c #0C0A07",
-": c #D3A33B",
-"< c #020201",
-"[ c #DAAA41",
-"} c #040302",
-"| c #E4D9BF",
-"1 c #0B0907",
-"2 c #030201",
-"3 c #020200",
-"4 c #C99115",
-"5 c #080704",
-"6 c #DBC8A2",
-"7 c #E7D7B4",
-"8 c #E0CD9E",
-"9 c #080601",
-"0 c #040400",
-"a c #010100",
-"b c #0B0B08",
-"c c #DCBF83",
-"d c #DCBC75",
-"e c #DEB559",
-"f c #040301",
-"g c #BC8815",
-"h c #120E07",
-"i c #060402",
-"j c #0A0804",
-"k c #D4A747",
-"l c #D6A12F",
-"m c #0E0C05",
-"n c #C8C1B0",
-"o c #1D1B15",
-"p c #D7AD51",
-"q c #070502",
-"r c #080804",
-"s c #BC953B",
-"t c #C4BDAD",
-"u c #0B0807",
-"v c #DBAC47",
-"w c #1B150A",
-"x c #B78A2C",
-"y c #D8A83C",
-"z c #D4A338",
-"A c #0F0B03",
-"B c #181105",
-"C c #C59325",
-"D c #C18E1F",
-"E c #060600",
-"F c #CC992D",
-"G c #B98B25",
-"H c #B3831F",
-"I c #C08C1C",
-"J c #060500",
-"K c #0E0C03",
-"L c #0D0A00",
-" ",
-" .+@# ",
-" .$%&*= ",
-" .-;>,')! ",
-" .~. .{]. ",
-" .^/. (_:< ",
-" .[.}|$12 ",
-" 345678}90 ",
-" a2bcdefgh ",
-" ijkl.mno ",
-" <pq. rstu ",
-" .]v. wx= ",
-" .yzABCDE ",
-" .FGHIJ ",
-" 0KL0 ",
-" "};
diff --git a/ext/json/lib/json/TrueClass.xpm b/ext/json/lib/json/TrueClass.xpm
deleted file mode 100644
index 143eef49bb..0000000000
--- a/ext/json/lib/json/TrueClass.xpm
+++ /dev/null
@@ -1,21 +0,0 @@
-/* XPM */
-static char * TrueClass_xpm[] = {
-"16 16 2 1",
-" c None",
-". c #0BF311",
-" ",
-" ",
-" ",
-" ......... ",
-" . ",
-" . ",
-" . ",
-" . ",
-" . ",
-" . ",
-" . ",
-" . ",
-" . ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/add/core.rb b/ext/json/lib/json/add/core.rb
deleted file mode 100644
index 630ed6e4b7..0000000000
--- a/ext/json/lib/json/add/core.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-# This file contains implementations of ruby core's custom objects for
-# serialisation/deserialisation.
-
-unless Object.const_defined?(:JSON) and ::JSON.const_defined?(:JSON_LOADED) and
- ::JSON::JSON_LOADED
- require 'json'
-end
-require 'date'
-
-class Time
- def self.json_create(object)
- at(*object.values_at('s', 'u'))
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name.to_s,
- 's' => tv_sec,
- 'u' => tv_usec,
- }.to_json(*args)
- end
-end
-
-class Date
- def self.json_create(object)
- civil(*object.values_at('y', 'm', 'd', 'sg'))
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name.to_s,
- 'y' => year,
- 'm' => month,
- 'd' => day,
- 'sg' => @sg,
- }.to_json(*args)
- end
-end
-
-class DateTime
- def self.json_create(object)
- args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
- of_a, of_b = object['of'].split('/')
- args << Rational(of_a.to_i, of_b.to_i)
- args << object['sg']
- civil(*args)
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name.to_s,
- 'y' => year,
- 'm' => month,
- 'd' => day,
- 'H' => hour,
- 'M' => min,
- 'S' => sec,
- 'of' => offset.to_s,
- 'sg' => @sg,
- }.to_json(*args)
- end
-end
-
-class Range
- def self.json_create(object)
- new(*object['a'])
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name.to_s,
- 'a' => [ first, last, exclude_end? ]
- }.to_json(*args)
- end
-end
-
-class Struct
- def self.json_create(object)
- new(*object['v'])
- end
-
- def to_json(*args)
- klass = self.class.name.to_s
- klass.empty? and raise JSON::JSONError, "Only named structs are supported!"
- {
- 'json_class' => klass,
- 'v' => values,
- }.to_json(*args)
- end
-end
-
-class Exception
- def self.json_create(object)
- result = new(object['m'])
- result.set_backtrace object['b']
- result
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name.to_s,
- 'm' => message,
- 'b' => backtrace,
- }.to_json(*args)
- end
-end
-
-class Regexp
- def self.json_create(object)
- new(object['s'], object['o'])
- end
-
- def to_json(*)
- {
- 'json_class' => self.class.name.to_s,
- 'o' => options,
- 's' => source,
- }.to_json
- end
-end
diff --git a/ext/json/lib/json/add/rails.rb b/ext/json/lib/json/add/rails.rb
deleted file mode 100644
index e86ed1aab9..0000000000
--- a/ext/json/lib/json/add/rails.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# This file contains implementations of rails custom objects for
-# serialisation/deserialisation.
-
-unless Object.const_defined?(:JSON) and ::JSON.const_defined?(:JSON_LOADED) and
- ::JSON::JSON_LOADED
- require 'json'
-end
-
-class Object
- def self.json_create(object)
- obj = new
- for key, value in object
- next if key == 'json_class'
- instance_variable_set "@#{key}", value
- end
- obj
- end
-
- def to_json(*a)
- result = {
- 'json_class' => self.class.name
- }
- instance_variables.inject(result) do |r, name|
- r[name[1..-1]] = instance_variable_get name
- r
- end
- result.to_json(*a)
- end
-end
-
-class Symbol
- def to_json(*a)
- to_s.to_json(*a)
- end
-end
-
-module Enumerable
- def to_json(*a)
- to_a.to_json(*a)
- end
-end
-
-# class Regexp
-# def to_json(*)
-# inspect
-# end
-# end
-#
-# The above rails definition has some problems:
-#
-# 1. { 'foo' => /bar/ }.to_json # => "{foo: /bar/}"
-# This isn't valid JSON, because the regular expression syntax is not
-# defined in RFC 4627. (And unquoted strings are disallowed there, too.)
-# Though it is valid Javascript.
-#
-# 2. { 'foo' => /bar/mix }.to_json # => "{foo: /bar/mix}"
-# This isn't even valid Javascript.
-
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
deleted file mode 100644
index 7bc5ae0656..0000000000
--- a/ext/json/lib/json/common.rb
+++ /dev/null
@@ -1,354 +0,0 @@
-require 'json/version'
-
-module JSON
- class << self
- # If _object_ is string like parse the string and return the parsed result
- # as a Ruby data structure. Otherwise generate a JSON text from the Ruby
- # data structure object and return it.
- #
- # The _opts_ argument is passed through to generate/parse respectively, see
- # generate and parse for their documentation.
- def [](object, opts = {})
- if object.respond_to? :to_str
- JSON.parse(object.to_str, opts => {})
- else
- JSON.generate(object, opts => {})
- end
- end
-
- # Returns the JSON parser class, that is used by JSON. This might be either
- # JSON::Ext::Parser or JSON::Pure::Parser.
- attr_reader :parser
-
- # Set the JSON parser class _parser_ to be used by JSON.
- def parser=(parser) # :nodoc:
- @parser = parser
- remove_const :Parser if const_defined? :Parser
- const_set :Parser, parser
- end
-
- # Return the constant located at _path_. The format of _path_ has to be
- # either ::A::B::C or A::B::C. In any case A has to be located at the top
- # level (absolute namespace path?). If there doesn't exist a constant at
- # the given path, an ArgumentError is raised.
- def deep_const_get(path) # :nodoc:
- path = path.to_s
- path.split(/::/).inject(Object) do |p, c|
- case
- when c.empty? then p
- when p.const_defined?(c) then p.const_get(c)
- else raise ArgumentError, "can't find const #{path}"
- end
- end
- end
-
- # Set the module _generator_ to be used by JSON.
- def generator=(generator) # :nodoc:
- @generator = generator
- generator_methods = generator::GeneratorMethods
- for const in generator_methods.constants
- klass = deep_const_get(const)
- modul = generator_methods.const_get(const)
- klass.class_eval do
- instance_methods(false).each do |m|
- m.to_s == 'to_json' and remove_method m
- end
- include modul
- end
- end
- self.state = generator::State
- const_set :State, self.state
- end
-
- # Returns the JSON generator modul, that is used by JSON. This might be
- # either JSON::Ext::Generator or JSON::Pure::Generator.
- attr_reader :generator
-
- # Returns the JSON generator state class, that is used by JSON. This might
- # be either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
- attr_accessor :state
-
- # This is create identifier, that is used to decide, if the _json_create_
- # hook of a class should be called. It defaults to 'json_class'.
- attr_accessor :create_id
- end
- self.create_id = 'json_class'
-
- NaN = (-1.0) ** 0.5
-
- Infinity = 1.0/0
-
- MinusInfinity = -Infinity
-
- # The base exception for JSON errors.
- class JSONError < StandardError; end
-
- # This exception is raised, if a parser error occurs.
- class ParserError < JSONError; end
-
- # This exception is raised, if the nesting of parsed datastructures is too
- # deep.
- class NestingError < ParserError; end
-
- # This exception is raised, if a generator or unparser error occurs.
- class GeneratorError < JSONError; end
- # For backwards compatibility
- UnparserError = GeneratorError
-
- # If a circular data structure is encountered while unparsing
- # this exception is raised.
- class CircularDatastructure < GeneratorError; end
-
- # This exception is raised, if the required unicode support is missing on the
- # system. Usually this means, that the iconv library is not installed.
- class MissingUnicodeSupport < JSONError; end
-
- module_function
-
- # Parse the JSON string _source_ into a Ruby data structure and return it.
- #
- # _opts_ can have the following
- # keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Disable depth checking with :max_nesting => false, it defaults
- # to 19.
- # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to false.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matchin class and create_id was found. This option
- # defaults to true.
- def parse(source, opts = {})
- JSON.parser.new(source, opts).parse
- end
-
- # Parse the JSON string _source_ into a Ruby data structure and return it.
- # The bang version of the parse method, defaults to the more dangerous values
- # for the _opts_ hash, so be sure only to parse trusted _source_ strings.
- #
- # _opts_ can have the following keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Enable depth checking with :max_nesting => anInteger. The parse!
- # methods defaults to not doing max depth checking: This can be dangerous,
- # if someone wants to fill up your stack.
- # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to true.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matchin class and create_id was found. This option
- # defaults to true.
- def parse!(source, opts = {})
- opts = {
- :max_nesting => false,
- :allow_nan => true
- }.update(opts)
- JSON.parser.new(source, opts).parse
- end
-
- # Unparse the Ruby data structure _obj_ into a single line JSON string and
- # return it. _state_ is
- # * a JSON::State object,
- # * or a Hash like object (responding to to_hash),
- # * an object convertible into a hash by a to_h method,
- # that is used as or to configure a State object.
- #
- # It defaults to a state object, that creates the shortest possible JSON text
- # in one line, checks for circular data structures and doesn't allow NaN,
- # Infinity, and -Infinity.
- #
- # A _state_ hash can have the following keys:
- # * *indent*: a string used to indent levels (default: ''),
- # * *space*: a string that is put after, a : or , delimiter (default: ''),
- # * *space_before*: a string that is put before a : pair delimiter (default: ''),
- # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
- # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
- # * *check_circular*: true if checking for circular data structures
- # should be done (the default), false otherwise.
- # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- # generated, otherwise an exception is thrown, if these values are
- # encountered. This options defaults to false.
- # * *max_nesting*: The maximum depth of nesting allowed in the data
- # structures from which JSON is to be generated. Disable depth checking
- # with :max_nesting => false, it defaults to 19.
- #
- # See also the fast_generate for the fastest creation method with the least
- # amount of sanity checks, and the pretty_generate method for some
- # defaults for a pretty output.
- def generate(obj, state = nil)
- if state
- state = State.from_state(state)
- else
- state = State.new
- end
- obj.to_json(state)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias unparse generate
- module_function :unparse
- # :startdoc:
-
- # Unparse the Ruby data structure _obj_ into a single line JSON string and
- # return it. This method disables the checks for circles in Ruby objects, and
- # also generates NaN, Infinity, and, -Infinity float values.
- #
- # *WARNING*: Be careful not to pass any Ruby data structures with circles as
- # _obj_ argument, because this will cause JSON to go into an infinite loop.
- def fast_generate(obj)
- obj.to_json(nil)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias fast_unparse fast_generate
- module_function :fast_unparse
- # :startdoc:
-
- # Unparse the Ruby data structure _obj_ into a JSON string and return it. The
- # returned string is a prettier form of the string returned by #unparse.
- #
- # The _opts_ argument can be used to configure the generator, see the
- # generate method for a more detailed explanation.
- def pretty_generate(obj, opts = nil)
- state = JSON.state.new(
- :indent => ' ',
- :space => ' ',
- :object_nl => "\n",
- :array_nl => "\n",
- :check_circular => true
- )
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state.configure(opts)
- end
- obj.to_json(state)
- end
-
- # :stopdoc:
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
- alias pretty_unparse pretty_generate
- module_function :pretty_unparse
- # :startdoc:
-
- # Load a ruby data structure from a JSON _source_ and return it. A source can
- # either be a string like object, an IO like object, or an object responding
- # to the read method. If _proc_ was given, it will be called with any nested
- # Ruby object as an argument recursively in depth first order.
- #
- # This method is part of the implementation of the load/dump interface of
- # Marshal and YAML.
- def load(source, proc = nil)
- if source.respond_to? :to_str
- source = source.to_str
- elsif source.respond_to? :to_io
- source = source.to_io.read
- else
- source = source.read
- end
- result = parse(source, :max_nesting => false, :allow_nan => true)
- recurse_proc(result, &proc) if proc
- result
- end
-
- def recurse_proc(result, &proc)
- case result
- when Array
- result.each { |x| recurse_proc x, &proc }
- proc.call result
- when Hash
- result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
- proc.call result
- else
- proc.call result
- end
- end
- private :recurse_proc
- module_function :recurse_proc
-
- alias restore load
- module_function :restore
-
- # Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
- # the result.
- #
- # If anIO (an IO like object or an object that responds to the write method)
- # was given, the resulting JSON is written to it.
- #
- # If the number of nested arrays or objects exceeds _limit_ an ArgumentError
- # exception is raised. This argument is similar (but not exactly the
- # same!) to the _limit_ argument in Marshal.dump.
- #
- # This method is part of the implementation of the load/dump interface of
- # Marshal and YAML.
- def dump(obj, anIO = nil, limit = nil)
- if anIO and limit.nil?
- anIO = anIO.to_io if anIO.respond_to?(:to_io)
- unless anIO.respond_to?(:write)
- limit = anIO
- anIO = nil
- end
- end
- limit ||= 0
- result = generate(obj, :allow_nan => true, :max_nesting => limit)
- if anIO
- anIO.write result
- anIO
- else
- result
- end
- rescue JSON::NestingError
- raise ArgumentError, "exceed depth limit"
- end
-end
-
-module ::Kernel
- # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
- # one line.
- def j(*objs)
- objs.each do |obj|
- puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
- end
- nil
- end
-
- # Ouputs _objs_ to STDOUT as JSON strings in a pretty format, with
- # indentation and over many lines.
- def jj(*objs)
- objs.each do |obj|
- puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
- end
- nil
- end
-
- # If _object_ is string like parse the string and return the parsed result as
- # a Ruby data structure. Otherwise generate a JSON text from the Ruby data
- # structure object and return it.
- #
- # The _opts_ argument is passed through to generate/parse respectively, see
- # generate and parse for their documentation.
- def JSON(object, opts = {})
- if object.respond_to? :to_str
- JSON.parse(object.to_str, opts)
- else
- JSON.generate(object, opts)
- end
- end
-end
-
-class ::Class
- # Returns true, if this class can be used to create an instance
- # from a serialised JSON string. The class has to implement a class
- # method _json_create_ that expects a hash as first parameter, which includes
- # the required data.
- def json_creatable?
- respond_to?(:json_create)
- end
-end
- # vim: set et sw=2 ts=2:
diff --git a/ext/json/lib/json/editor.rb b/ext/json/lib/json/editor.rb
deleted file mode 100644
index 9a65400622..0000000000
--- a/ext/json/lib/json/editor.rb
+++ /dev/null
@@ -1,1363 +0,0 @@
-# To use the GUI JSON editor, start the edit_json.rb executable script. It
-# requires ruby-gtk to be installed.
-
-require 'gtk2'
-require 'iconv'
-require 'json'
-require 'rbconfig'
-require 'open-uri'
-
-module JSON
- module Editor
- include Gtk
-
- # Beginning of the editor window title
- TITLE = 'JSON Editor'.freeze
-
- # Columns constants
- ICON_COL, TYPE_COL, CONTENT_COL = 0, 1, 2
-
- # JSON primitive types (Containers)
- CONTAINER_TYPES = %w[Array Hash].sort
- # All JSON primitive types
- ALL_TYPES = (%w[TrueClass FalseClass Numeric String NilClass] +
- CONTAINER_TYPES).sort
-
- # The Nodes necessary for the tree representation of a JSON document
- ALL_NODES = (ALL_TYPES + %w[Key]).sort
-
- DEFAULT_DIALOG_KEY_PRESS_HANDLER = lambda do |dialog, event|
- case event.keyval
- when Gdk::Keyval::GDK_Return
- dialog.response Dialog::RESPONSE_ACCEPT
- when Gdk::Keyval::GDK_Escape
- dialog.response Dialog::RESPONSE_REJECT
- end
- end
-
- # Returns the Gdk::Pixbuf of the icon named _name_ from the icon cache.
- def Editor.fetch_icon(name)
- @icon_cache ||= {}
- unless @icon_cache.key?(name)
- path = File.dirname(__FILE__)
- @icon_cache[name] = Gdk::Pixbuf.new(File.join(path, name + '.xpm'))
- end
- @icon_cache[name]
- end
-
- # Opens an error dialog on top of _window_ showing the error message
- # _text_.
- def Editor.error_dialog(window, text)
- dialog = MessageDialog.new(window, Dialog::MODAL,
- MessageDialog::ERROR,
- MessageDialog::BUTTONS_CLOSE, text)
- dialog.show_all
- dialog.run
- rescue TypeError
- dialog = MessageDialog.new(Editor.window, Dialog::MODAL,
- MessageDialog::ERROR,
- MessageDialog::BUTTONS_CLOSE, text)
- dialog.show_all
- dialog.run
- ensure
- dialog.destroy if dialog
- end
-
- # Opens a yes/no question dialog on top of _window_ showing the error
- # message _text_. If yes was answered _true_ is returned, otherwise
- # _false_.
- def Editor.question_dialog(window, text)
- dialog = MessageDialog.new(window, Dialog::MODAL,
- MessageDialog::QUESTION,
- MessageDialog::BUTTONS_YES_NO, text)
- dialog.show_all
- dialog.run do |response|
- return Gtk::Dialog::RESPONSE_YES === response
- end
- ensure
- dialog.destroy if dialog
- end
-
- # Convert the tree model starting from Gtk::TreeIter _iter_ into a Ruby
- # data structure and return it.
- def Editor.model2data(iter)
- return nil if iter.nil?
- case iter.type
- when 'Hash'
- hash = {}
- iter.each { |c| hash[c.content] = Editor.model2data(c.first_child) }
- hash
- when 'Array'
- array = Array.new(iter.n_children)
- iter.each_with_index { |c, i| array[i] = Editor.model2data(c) }
- array
- when 'Key'
- iter.content
- when 'String'
- iter.content
- when 'Numeric'
- content = iter.content
- if /\./.match(content)
- content.to_f
- else
- content.to_i
- end
- when 'TrueClass'
- true
- when 'FalseClass'
- false
- when 'NilClass'
- nil
- else
- fail "Unknown type found in model: #{iter.type}"
- end
- end
-
- # Convert the Ruby data structure _data_ into tree model data for Gtk and
- # returns the whole model. If the parameter _model_ wasn't given a new
- # Gtk::TreeStore is created as the model. The _parent_ parameter specifies
- # the parent node (iter, Gtk:TreeIter instance) to which the data is
- # appended, alternativeley the result of the yielded block is used as iter.
- def Editor.data2model(data, model = nil, parent = nil)
- model ||= TreeStore.new(Gdk::Pixbuf, String, String)
- iter = if block_given?
- yield model
- else
- model.append(parent)
- end
- case data
- when Hash
- iter.type = 'Hash'
- data.sort.each do |key, value|
- pair_iter = model.append(iter)
- pair_iter.type = 'Key'
- pair_iter.content = key.to_s
- Editor.data2model(value, model, pair_iter)
- end
- when Array
- iter.type = 'Array'
- data.each do |value|
- Editor.data2model(value, model, iter)
- end
- when Numeric
- iter.type = 'Numeric'
- iter.content = data.to_s
- when String, true, false, nil
- iter.type = data.class.name
- iter.content = data.nil? ? 'null' : data.to_s
- else
- iter.type = 'String'
- iter.content = data.to_s
- end
- model
- end
-
- # The Gtk::TreeIter class is reopened and some auxiliary methods are added.
- class Gtk::TreeIter
- include Enumerable
-
- # Traverse each of this Gtk::TreeIter instance's children
- # and yield to them.
- def each
- n_children.times { |i| yield nth_child(i) }
- end
-
- # Recursively traverse all nodes of this Gtk::TreeIter's subtree
- # (including self) and yield to them.
- def recursive_each(&block)
- yield self
- each do |i|
- i.recursive_each(&block)
- end
- end
-
- # Remove the subtree of this Gtk::TreeIter instance from the
- # model _model_.
- def remove_subtree(model)
- while current = first_child
- model.remove(current)
- end
- end
-
- # Returns the type of this node.
- def type
- self[TYPE_COL]
- end
-
- # Sets the type of this node to _value_. This implies setting
- # the respective icon accordingly.
- def type=(value)
- self[TYPE_COL] = value
- self[ICON_COL] = Editor.fetch_icon(value)
- end
-
- # Returns the content of this node.
- def content
- self[CONTENT_COL]
- end
-
- # Sets the content of this node to _value_.
- def content=(value)
- self[CONTENT_COL] = value
- end
- end
-
- # This module bundles some method, that can be used to create a menu. It
- # should be included into the class in question.
- module MenuExtension
- include Gtk
-
- # Creates a Menu, that includes MenuExtension. _treeview_ is the
- # Gtk::TreeView, on which it operates.
- def initialize(treeview)
- @treeview = treeview
- @menu = Menu.new
- end
-
- # Returns the Gtk::TreeView of this menu.
- attr_reader :treeview
-
- # Returns the menu.
- attr_reader :menu
-
- # Adds a Gtk::SeparatorMenuItem to this instance's #menu.
- def add_separator
- menu.append SeparatorMenuItem.new
- end
-
- # Adds a Gtk::MenuItem to this instance's #menu. _label_ is the label
- # string, _klass_ is the item type, and _callback_ is the procedure, that
- # is called if the _item_ is activated.
- def add_item(label, keyval = nil, klass = MenuItem, &callback)
- label = "#{label} (C-#{keyval.chr})" if keyval
- item = klass.new(label)
- item.signal_connect(:activate, &callback)
- if keyval
- self.signal_connect(:'key-press-event') do |item, event|
- if event.state & Gdk::Window::ModifierType::CONTROL_MASK != 0 and
- event.keyval == keyval
- callback.call item
- end
- end
- end
- menu.append item
- item
- end
-
- # This method should be implemented in subclasses to create the #menu of
- # this instance. It has to be called after an instance of this class is
- # created, to build the menu.
- def create
- raise NotImplementedError
- end
-
- def method_missing(*a, &b)
- treeview.__send__(*a, &b)
- end
- end
-
- # This class creates the popup menu, that opens when clicking onto the
- # treeview.
- class PopUpMenu
- include MenuExtension
-
- # Change the type or content of the selected node.
- def change_node(item)
- if current = selection.selected
- parent = current.parent
- old_type, old_content = current.type, current.content
- if ALL_TYPES.include?(old_type)
- @clipboard_data = Editor.model2data(current)
- type, content = ask_for_element(parent, current.type,
- current.content)
- if type
- current.type, current.content = type, content
- current.remove_subtree(model)
- toplevel.display_status("Changed a node in tree.")
- window.change
- end
- else
- toplevel.display_status(
- "Cannot change node of type #{old_type} in tree!")
- end
- end
- end
-
- # Cut the selected node and its subtree, and save it into the
- # clipboard.
- def cut_node(item)
- if current = selection.selected
- if current and current.type == 'Key'
- @clipboard_data = {
- current.content => Editor.model2data(current.first_child)
- }
- else
- @clipboard_data = Editor.model2data(current)
- end
- model.remove(current)
- window.change
- toplevel.display_status("Cut a node from tree.")
- end
- end
-
- # Copy the selected node and its subtree, and save it into the
- # clipboard.
- def copy_node(item)
- if current = selection.selected
- if current and current.type == 'Key'
- @clipboard_data = {
- current.content => Editor.model2data(current.first_child)
- }
- else
- @clipboard_data = Editor.model2data(current)
- end
- window.change
- toplevel.display_status("Copied a node from tree.")
- end
- end
-
- # Paste the data in the clipboard into the selected Array or Hash by
- # appending it.
- def paste_node_appending(item)
- if current = selection.selected
- if @clipboard_data
- case current.type
- when 'Array'
- Editor.data2model(@clipboard_data, model, current)
- expand_collapse(current)
- when 'Hash'
- if @clipboard_data.is_a? Hash
- parent = current.parent
- hash = Editor.model2data(current)
- model.remove(current)
- hash.update(@clipboard_data)
- Editor.data2model(hash, model, parent)
- if parent
- expand_collapse(parent)
- elsif @expanded
- expand_all
- end
- window.change
- else
- toplevel.display_status(
- "Cannot paste non-#{current.type} data into '#{current.type}'!")
- end
- else
- toplevel.display_status(
- "Cannot paste node below '#{current.type}'!")
- end
- else
- toplevel.display_status("Nothing to paste in clipboard!")
- end
- else
- toplevel.display_status("Append a node into the root first!")
- end
- end
-
- # Paste the data in the clipboard into the selected Array inserting it
- # before the selected element.
- def paste_node_inserting_before(item)
- if current = selection.selected
- if @clipboard_data
- parent = current.parent or return
- parent_type = parent.type
- if parent_type == 'Array'
- selected_index = parent.each_with_index do |c, i|
- break i if c == current
- end
- Editor.data2model(@clipboard_data, model, parent) do |m|
- m.insert_before(parent, current)
- end
- expand_collapse(current)
- toplevel.display_status("Inserted an element to " +
- "'#{parent_type}' before index #{selected_index}.")
- window.change
- else
- toplevel.display_status(
- "Cannot insert node below '#{parent_type}'!")
- end
- else
- toplevel.display_status("Nothing to paste in clipboard!")
- end
- else
- toplevel.display_status("Append a node into the root first!")
- end
- end
-
- # Append a new node to the selected Hash or Array.
- def append_new_node(item)
- if parent = selection.selected
- parent_type = parent.type
- case parent_type
- when 'Hash'
- key, type, content = ask_for_hash_pair(parent)
- key or return
- iter = create_node(parent, 'Key', key)
- iter = create_node(iter, type, content)
- toplevel.display_status(
- "Added a (key, value)-pair to '#{parent_type}'.")
- window.change
- when 'Array'
- type, content = ask_for_element(parent)
- type or return
- iter = create_node(parent, type, content)
- window.change
- toplevel.display_status("Appendend an element to '#{parent_type}'.")
- else
- toplevel.display_status("Cannot append to '#{parent_type}'!")
- end
- else
- type, content = ask_for_element
- type or return
- iter = create_node(nil, type, content)
- window.change
- end
- end
-
- # Insert a new node into an Array before the selected element.
- def insert_new_node(item)
- if current = selection.selected
- parent = current.parent or return
- parent_parent = parent.parent
- parent_type = parent.type
- if parent_type == 'Array'
- selected_index = parent.each_with_index do |c, i|
- break i if c == current
- end
- type, content = ask_for_element(parent)
- type or return
- iter = model.insert_before(parent, current)
- iter.type, iter.content = type, content
- toplevel.display_status("Inserted an element to " +
- "'#{parent_type}' before index #{selected_index}.")
- window.change
- else
- toplevel.display_status(
- "Cannot insert node below '#{parent_type}'!")
- end
- else
- toplevel.display_status("Append a node into the root first!")
- end
- end
-
- # Recursively collapse/expand a subtree starting from the selected node.
- def collapse_expand(item)
- if current = selection.selected
- if row_expanded?(current.path)
- collapse_row(current.path)
- else
- expand_row(current.path, true)
- end
- else
- toplevel.display_status("Append a node into the root first!")
- end
- end
-
- # Create the menu.
- def create
- add_item("Change node", ?n, &method(:change_node))
- add_separator
- add_item("Cut node", ?X, &method(:cut_node))
- add_item("Copy node", ?C, &method(:copy_node))
- add_item("Paste node (appending)", ?A, &method(:paste_node_appending))
- add_item("Paste node (inserting before)", ?I,
- &method(:paste_node_inserting_before))
- add_separator
- add_item("Append new node", ?a, &method(:append_new_node))
- add_item("Insert new node before", ?i, &method(:insert_new_node))
- add_separator
- add_item("Collapse/Expand node (recursively)", ?e,
- &method(:collapse_expand))
-
- menu.show_all
- signal_connect(:button_press_event) do |widget, event|
- if event.kind_of? Gdk::EventButton and event.button == 3
- menu.popup(nil, nil, event.button, event.time)
- end
- end
- signal_connect(:popup_menu) do
- menu.popup(nil, nil, 0, Gdk::Event::CURRENT_TIME)
- end
- end
- end
-
- # This class creates the File pulldown menu.
- class FileMenu
- include MenuExtension
-
- # Clear the model and filename, but ask to save the JSON document, if
- # unsaved changes have occured.
- def new(item)
- window.clear
- end
-
- # Open a file and load it into the editor. Ask to save the JSON document
- # first, if unsaved changes have occured.
- def open(item)
- window.file_open
- end
-
- def open_location(item)
- window.location_open
- end
-
- # Revert the current JSON document in the editor to the saved version.
- def revert(item)
- window.instance_eval do
- @filename and file_open(@filename)
- end
- end
-
- # Save the current JSON document.
- def save(item)
- window.file_save
- end
-
- # Save the current JSON document under the given filename.
- def save_as(item)
- window.file_save_as
- end
-
- # Quit the editor, after asking to save any unsaved changes first.
- def quit(item)
- window.quit
- end
-
- # Create the menu.
- def create
- title = MenuItem.new('File')
- title.submenu = menu
- add_item('New', &method(:new))
- add_item('Open', ?o, &method(:open))
- add_item('Open location', ?l, &method(:open_location))
- add_item('Revert', &method(:revert))
- add_separator
- add_item('Save', ?s, &method(:save))
- add_item('Save As', ?S, &method(:save_as))
- add_separator
- add_item('Quit', ?q, &method(:quit))
- title
- end
- end
-
- # This class creates the Edit pulldown menu.
- class EditMenu
- include MenuExtension
-
- # Copy data from model into primary clipboard.
- def copy(item)
- data = Editor.model2data(model.iter_first)
- json = JSON.pretty_generate(data, :max_nesting => false)
- c = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)
- c.text = json
- end
-
- # Copy json text from primary clipboard into model.
- def paste(item)
- c = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)
- if json = c.wait_for_text
- window.ask_save if @changed
- begin
- window.edit json
- rescue JSON::ParserError
- window.clear
- end
- end
- end
-
- # Find a string in all nodes' contents and select the found node in the
- # treeview.
- def find(item)
- @search = ask_for_find_term(@search) or return
- iter = model.get_iter('0') or return
- iter.recursive_each do |i|
- if @iter
- if @iter != i
- next
- else
- @iter = nil
- next
- end
- elsif @search.match(i[CONTENT_COL])
- set_cursor(i.path, nil, false)
- @iter = i
- break
- end
- end
- end
-
- # Repeat the last search given by #find.
- def find_again(item)
- @search or return
- iter = model.get_iter('0')
- iter.recursive_each do |i|
- if @iter
- if @iter != i
- next
- else
- @iter = nil
- next
- end
- elsif @search.match(i[CONTENT_COL])
- set_cursor(i.path, nil, false)
- @iter = i
- break
- end
- end
- end
-
- # Sort (Reverse sort) all elements of the selected array by the given
- # expression. _x_ is the element in question.
- def sort(item)
- if current = selection.selected
- if current.type == 'Array'
- parent = current.parent
- ary = Editor.model2data(current)
- order, reverse = ask_for_order
- order or return
- begin
- block = eval "lambda { |x| #{order} }"
- if reverse
- ary.sort! { |a,b| block[b] <=> block[a] }
- else
- ary.sort! { |a,b| block[a] <=> block[b] }
- end
- rescue => e
- Editor.error_dialog(self, "Failed to sort Array with #{order}: #{e}!")
- else
- Editor.data2model(ary, model, parent) do |m|
- m.insert_before(parent, current)
- end
- model.remove(current)
- expand_collapse(parent)
- window.change
- toplevel.display_status("Array has been sorted.")
- end
- else
- toplevel.display_status("Only Array nodes can be sorted!")
- end
- else
- toplevel.display_status("Select an Array to sort first!")
- end
- end
-
- # Create the menu.
- def create
- title = MenuItem.new('Edit')
- title.submenu = menu
- add_item('Copy', ?c, &method(:copy))
- add_item('Paste', ?v, &method(:paste))
- add_separator
- add_item('Find', ?f, &method(:find))
- add_item('Find Again', ?g, &method(:find_again))
- add_separator
- add_item('Sort', ?S, &method(:sort))
- title
- end
- end
-
- class OptionsMenu
- include MenuExtension
-
- # Collapse/Expand all nodes by default.
- def collapsed_nodes(item)
- if expanded
- self.expanded = false
- collapse_all
- else
- self.expanded = true
- expand_all
- end
- end
-
- # Toggle pretty saving mode on/off.
- def pretty_saving(item)
- @pretty_item.toggled
- window.change
- end
-
- attr_reader :pretty_item
-
- # Create the menu.
- def create
- title = MenuItem.new('Options')
- title.submenu = menu
- add_item('Collapsed nodes', nil, CheckMenuItem, &method(:collapsed_nodes))
- @pretty_item = add_item('Pretty saving', nil, CheckMenuItem,
- &method(:pretty_saving))
- @pretty_item.active = true
- window.unchange
- title
- end
- end
-
- # This class inherits from Gtk::TreeView, to configure it and to add a lot
- # of behaviour to it.
- class JSONTreeView < Gtk::TreeView
- include Gtk
-
- # Creates a JSONTreeView instance, the parameter _window_ is
- # a MainWindow instance and used for self delegation.
- def initialize(window)
- @window = window
- super(TreeStore.new(Gdk::Pixbuf, String, String))
- self.selection.mode = SELECTION_BROWSE
-
- @expanded = false
- self.headers_visible = false
- add_columns
- add_popup_menu
- end
-
- # Returns the MainWindow instance of this JSONTreeView.
- attr_reader :window
-
- # Returns true, if nodes are autoexpanding, false otherwise.
- attr_accessor :expanded
-
- private
-
- def add_columns
- cell = CellRendererPixbuf.new
- column = TreeViewColumn.new('Icon', cell,
- 'pixbuf' => ICON_COL
- )
- append_column(column)
-
- cell = CellRendererText.new
- column = TreeViewColumn.new('Type', cell,
- 'text' => TYPE_COL
- )
- append_column(column)
-
- cell = CellRendererText.new
- cell.editable = true
- column = TreeViewColumn.new('Content', cell,
- 'text' => CONTENT_COL
- )
- cell.signal_connect(:edited, &method(:cell_edited))
- append_column(column)
- end
-
- def unify_key(iter, key)
- return unless iter.type == 'Key'
- parent = iter.parent
- if parent.any? { |c| c != iter and c.content == key }
- old_key = key
- i = 0
- begin
- key = sprintf("%s.%d", old_key, i += 1)
- end while parent.any? { |c| c != iter and c.content == key }
- end
- iter.content = key
- end
-
- def cell_edited(cell, path, value)
- iter = model.get_iter(path)
- case iter.type
- when 'Key'
- unify_key(iter, value)
- toplevel.display_status('Key has been changed.')
- when 'FalseClass'
- value.downcase!
- if value == 'true'
- iter.type, iter.content = 'TrueClass', 'true'
- end
- when 'TrueClass'
- value.downcase!
- if value == 'false'
- iter.type, iter.content = 'FalseClass', 'false'
- end
- when 'Numeric'
- iter.content = (Integer(value) rescue Float(value) rescue 0).to_s
- when 'String'
- iter.content = value
- when 'Hash', 'Array'
- return
- else
- fail "Unknown type found in model: #{iter.type}"
- end
- window.change
- end
-
- def configure_value(value, type)
- value.editable = false
- case type
- when 'Array', 'Hash'
- value.text = ''
- when 'TrueClass'
- value.text = 'true'
- when 'FalseClass'
- value.text = 'false'
- when 'NilClass'
- value.text = 'null'
- when 'Numeric', 'String'
- value.text ||= ''
- value.editable = true
- else
- raise ArgumentError, "unknown type '#{type}' encountered"
- end
- end
-
- def add_popup_menu
- menu = PopUpMenu.new(self)
- menu.create
- end
-
- public
-
- # Create a _type_ node with content _content_, and add it to _parent_
- # in the model. If _parent_ is nil, create a new model and put it into
- # the editor treeview.
- def create_node(parent, type, content)
- iter = if parent
- model.append(parent)
- else
- new_model = Editor.data2model(nil)
- toplevel.view_new_model(new_model)
- new_model.iter_first
- end
- iter.type, iter.content = type, content
- expand_collapse(parent) if parent
- iter
- end
-
- # Ask for a hash key, value pair to be added to the Hash node _parent_.
- def ask_for_hash_pair(parent)
- key_input = type_input = value_input = nil
-
- dialog = Dialog.new("New (key, value) pair for Hash", nil, nil,
- [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
- [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
- )
- dialog.width_request = 640
-
- hbox = HBox.new(false, 5)
- hbox.pack_start(Label.new("Key:"), false)
- hbox.pack_start(key_input = Entry.new)
- key_input.text = @key || ''
- dialog.vbox.pack_start(hbox, false)
- key_input.signal_connect(:activate) do
- if parent.any? { |c| c.content == key_input.text }
- toplevel.display_status('Key already exists in Hash!')
- key_input.text = ''
- else
- toplevel.display_status('Key has been changed.')
- end
- end
-
- hbox = HBox.new(false, 5)
- hbox.pack_start(Label.new("Type:"), false)
- hbox.pack_start(type_input = ComboBox.new(true))
- ALL_TYPES.each { |t| type_input.append_text(t) }
- type_input.active = @type || 0
- dialog.vbox.pack_start(hbox, false)
-
- type_input.signal_connect(:changed) do
- value_input.editable = false
- case ALL_TYPES[type_input.active]
- when 'Array', 'Hash'
- value_input.text = ''
- when 'TrueClass'
- value_input.text = 'true'
- when 'FalseClass'
- value_input.text = 'false'
- when 'NilClass'
- value_input.text = 'null'
- else
- value_input.text = ''
- value_input.editable = true
- end
- end
-
- hbox = HBox.new(false, 5)
- hbox.pack_start(Label.new("Value:"), false)
- hbox.pack_start(value_input = Entry.new)
- value_input.width_chars = 60
- value_input.text = @value || ''
- dialog.vbox.pack_start(hbox, false)
-
- dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
- dialog.show_all
- self.focus = dialog
- dialog.run do |response|
- if response == Dialog::RESPONSE_ACCEPT
- @key = key_input.text
- type = ALL_TYPES[@type = type_input.active]
- content = value_input.text
- return @key, type, content
- end
- end
- return
- ensure
- dialog.destroy
- end
-
- # Ask for an element to be appended _parent_.
- def ask_for_element(parent = nil, default_type = nil, value_text = @content)
- type_input = value_input = nil
-
- dialog = Dialog.new(
- "New element into #{parent ? parent.type : 'root'}",
- nil, nil,
- [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
- [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
- )
- hbox = HBox.new(false, 5)
- hbox.pack_start(Label.new("Type:"), false)
- hbox.pack_start(type_input = ComboBox.new(true))
- default_active = 0
- types = parent ? ALL_TYPES : CONTAINER_TYPES
- types.each_with_index do |t, i|
- type_input.append_text(t)
- if t == default_type
- default_active = i
- end
- end
- type_input.active = default_active
- dialog.vbox.pack_start(hbox, false)
- type_input.signal_connect(:changed) do
- configure_value(value_input, types[type_input.active])
- end
-
- hbox = HBox.new(false, 5)
- hbox.pack_start(Label.new("Value:"), false)
- hbox.pack_start(value_input = Entry.new)
- value_input.width_chars = 60
- value_input.text = value_text if value_text
- configure_value(value_input, types[type_input.active])
-
- dialog.vbox.pack_start(hbox, false)
-
- dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
- dialog.show_all
- self.focus = dialog
- dialog.run do |response|
- if response == Dialog::RESPONSE_ACCEPT
- type = types[type_input.active]
- @content = case type
- when 'Numeric'
- Integer(value_input.text) rescue Float(value_input.text) rescue 0
- else
- value_input.text
- end.to_s
- return type, @content
- end
- end
- return
- ensure
- dialog.destroy if dialog
- end
-
- # Ask for an order criteria for sorting, using _x_ for the element in
- # question. Returns the order criterium, and true/false for reverse
- # sorting.
- def ask_for_order
- dialog = Dialog.new(
- "Give an order criterium for 'x'.",
- nil, nil,
- [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
- [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
- )
- hbox = HBox.new(false, 5)
-
- hbox.pack_start(Label.new("Order:"), false)
- hbox.pack_start(order_input = Entry.new)
- order_input.text = @order || 'x'
- order_input.width_chars = 60
-
- hbox.pack_start(reverse_checkbox = CheckButton.new('Reverse'), false)
-
- dialog.vbox.pack_start(hbox, false)
-
- dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
- dialog.show_all
- self.focus = dialog
- dialog.run do |response|
- if response == Dialog::RESPONSE_ACCEPT
- return @order = order_input.text, reverse_checkbox.active?
- end
- end
- return
- ensure
- dialog.destroy if dialog
- end
-
- # Ask for a find term to search for in the tree. Returns the term as a
- # string.
- def ask_for_find_term(search = nil)
- dialog = Dialog.new(
- "Find a node matching regex in tree.",
- nil, nil,
- [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
- [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
- )
- hbox = HBox.new(false, 5)
-
- hbox.pack_start(Label.new("Regex:"), false)
- hbox.pack_start(regex_input = Entry.new)
- hbox.pack_start(icase_checkbox = CheckButton.new('Icase'), false)
- regex_input.width_chars = 60
- if search
- regex_input.text = search.source
- icase_checkbox.active = search.casefold?
- end
-
- dialog.vbox.pack_start(hbox, false)
-
- dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
- dialog.show_all
- self.focus = dialog
- dialog.run do |response|
- if response == Dialog::RESPONSE_ACCEPT
- begin
- return Regexp.new(regex_input.text, icase_checkbox.active? ? Regexp::IGNORECASE : 0)
- rescue => e
- Editor.error_dialog(self, "Evaluation of regex /#{regex_input.text}/ failed: #{e}!")
- return
- end
- end
- end
- return
- ensure
- dialog.destroy if dialog
- end
-
- # Expand or collapse row pointed to by _iter_ according
- # to the #expanded attribute.
- def expand_collapse(iter)
- if expanded
- expand_row(iter.path, true)
- else
- collapse_row(iter.path)
- end
- end
- end
-
- # The editor main window
- class MainWindow < Gtk::Window
- include Gtk
-
- def initialize(encoding)
- @changed = false
- @encoding = encoding
- super(TOPLEVEL)
- display_title
- set_default_size(800, 600)
- signal_connect(:delete_event) { quit }
-
- vbox = VBox.new(false, 0)
- add(vbox)
- #vbox.border_width = 0
-
- @treeview = JSONTreeView.new(self)
- @treeview.signal_connect(:'cursor-changed') do
- display_status('')
- end
-
- menu_bar = create_menu_bar
- vbox.pack_start(menu_bar, false, false, 0)
-
- sw = ScrolledWindow.new(nil, nil)
- sw.shadow_type = SHADOW_ETCHED_IN
- sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
- vbox.pack_start(sw, true, true, 0)
- sw.add(@treeview)
-
- @status_bar = Statusbar.new
- vbox.pack_start(@status_bar, false, false, 0)
-
- @filename ||= nil
- if @filename
- data = read_data(@filename)
- view_new_model Editor.data2model(data)
- end
-
- signal_connect(:button_release_event) do |_,event|
- if event.button == 2
- c = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)
- if url = c.wait_for_text
- location_open url
- end
- false
- else
- true
- end
- end
- end
-
- # Creates the menu bar with the pulldown menus and returns it.
- def create_menu_bar
- menu_bar = MenuBar.new
- @file_menu = FileMenu.new(@treeview)
- menu_bar.append @file_menu.create
- @edit_menu = EditMenu.new(@treeview)
- menu_bar.append @edit_menu.create
- @options_menu = OptionsMenu.new(@treeview)
- menu_bar.append @options_menu.create
- menu_bar
- end
-
- # Sets editor status to changed, to indicate that the edited data
- # containts unsaved changes.
- def change
- @changed = true
- display_title
- end
-
- # Sets editor status to unchanged, to indicate that the edited data
- # doesn't containt unsaved changes.
- def unchange
- @changed = false
- display_title
- end
-
- # Puts a new model _model_ into the Gtk::TreeView to be edited.
- def view_new_model(model)
- @treeview.model = model
- @treeview.expanded = true
- @treeview.expand_all
- unchange
- end
-
- # Displays _text_ in the status bar.
- def display_status(text)
- @cid ||= nil
- @status_bar.pop(@cid) if @cid
- @cid = @status_bar.get_context_id('dummy')
- @status_bar.push(@cid, text)
- end
-
- # Opens a dialog, asking, if changes should be saved to a file.
- def ask_save
- if Editor.question_dialog(self,
- "Unsaved changes to JSON model. Save?")
- if @filename
- file_save
- else
- file_save_as
- end
- end
- end
-
- # Quit this editor, that is, leave this editor's main loop.
- def quit
- ask_save if @changed
- if Gtk.main_level > 0
- destroy
- Gtk.main_quit
- end
- nil
- end
-
- # Display the new title according to the editor's current state.
- def display_title
- title = TITLE.dup
- title << ": #@filename" if @filename
- title << " *" if @changed
- self.title = title
- end
-
- # Clear the current model, after asking to save all unsaved changes.
- def clear
- ask_save if @changed
- @filename = nil
- self.view_new_model nil
- end
-
- def check_pretty_printed(json)
- pretty = !!((nl_index = json.index("\n")) && nl_index != json.size - 1)
- @options_menu.pretty_item.active = pretty
- end
- private :check_pretty_printed
-
- # Open the data at the location _uri_, if given. Otherwise open a dialog
- # to ask for the _uri_.
- def location_open(uri = nil)
- uri = ask_for_location unless uri
- uri or return
- ask_save if @changed
- data = load_location(uri) or return
- view_new_model Editor.data2model(data)
- end
-
- # Open the file _filename_ or call the #select_file method to ask for a
- # filename.
- def file_open(filename = nil)
- filename = select_file('Open as a JSON file') unless filename
- data = load_file(filename) or return
- view_new_model Editor.data2model(data)
- end
-
- # Edit the string _json_ in the editor.
- def edit(json)
- if json.respond_to? :read
- json = json.read
- end
- data = parse_json json
- view_new_model Editor.data2model(data)
- end
-
- # Save the current file.
- def file_save
- if @filename
- store_file(@filename)
- else
- file_save_as
- end
- end
-
- # Save the current file as the filename
- def file_save_as
- filename = select_file('Save as a JSON file')
- store_file(filename)
- end
-
- # Store the current JSON document to _path_.
- def store_file(path)
- if path
- data = Editor.model2data(@treeview.model.iter_first)
- File.open(path + '.tmp', 'wb') do |output|
- data or break
- if @options_menu.pretty_item.active?
- output.puts JSON.pretty_generate(data, :max_nesting => false)
- else
- output.write JSON.generate(data, :max_nesting => false)
- end
- end
- File.rename path + '.tmp', path
- @filename = path
- toplevel.display_status("Saved data to '#@filename'.")
- unchange
- end
- rescue SystemCallError => e
- Editor.error_dialog(self, "Failed to store JSON file: #{e}!")
- end
-
- # Load the file named _filename_ into the editor as a JSON document.
- def load_file(filename)
- if filename
- if File.directory?(filename)
- Editor.error_dialog(self, "Try to select a JSON file!")
- nil
- else
- @filename = filename
- if data = read_data(filename)
- toplevel.display_status("Loaded data from '#@filename'.")
- end
- display_title
- data
- end
- end
- end
-
- # Load the data at location _uri_ into the editor as a JSON document.
- def load_location(uri)
- data = read_data(uri) or return
- @filename = nil
- toplevel.display_status("Loaded data from '#{uri}'.")
- display_title
- data
- end
-
- def parse_json(json)
- check_pretty_printed(json)
- if @encoding && !/^utf8$/i.match(@encoding)
- iconverter = Iconv.new('utf8', @encoding)
- json = iconverter.iconv(json)
- end
- JSON::parse(json, :max_nesting => false, :create_additions => false)
- end
- private :parse_json
-
- # Read a JSON document from the file named _filename_, parse it into a
- # ruby data structure, and return the data.
- def read_data(filename)
- open(filename) do |f|
- json = f.read
- return parse_json(json)
- end
- rescue => e
- Editor.error_dialog(self, "Failed to parse JSON file: #{e}!")
- return
- end
-
- # Open a file selecton dialog, displaying _message_, and return the
- # selected filename or nil, if no file was selected.
- def select_file(message)
- filename = nil
- fs = FileSelection.new(message)
- fs.set_modal(true)
- @default_dir = File.join(Dir.pwd, '') unless @default_dir
- fs.set_filename(@default_dir)
- fs.set_transient_for(self)
- fs.signal_connect(:destroy) { Gtk.main_quit }
- fs.ok_button.signal_connect(:clicked) do
- filename = fs.filename
- @default_dir = File.join(File.dirname(filename), '')
- fs.destroy
- Gtk.main_quit
- end
- fs.cancel_button.signal_connect(:clicked) do
- fs.destroy
- Gtk.main_quit
- end
- fs.show_all
- Gtk.main
- filename
- end
-
- # Ask for location URI a to load data from. Returns the URI as a string.
- def ask_for_location
- dialog = Dialog.new(
- "Load data from location...",
- nil, nil,
- [ Stock::OK, Dialog::RESPONSE_ACCEPT ],
- [ Stock::CANCEL, Dialog::RESPONSE_REJECT ]
- )
- hbox = HBox.new(false, 5)
-
- hbox.pack_start(Label.new("Location:"), false)
- hbox.pack_start(location_input = Entry.new)
- location_input.width_chars = 60
- location_input.text = @location || ''
-
- dialog.vbox.pack_start(hbox, false)
-
- dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER)
- dialog.show_all
- dialog.run do |response|
- if response == Dialog::RESPONSE_ACCEPT
- return @location = location_input.text
- end
- end
- return
- ensure
- dialog.destroy if dialog
- end
- end
-
- class << self
- # Starts a JSON Editor. If a block was given, it yields
- # to the JSON::Editor::MainWindow instance.
- def start(encoding = 'utf8') # :yield: window
- Gtk.init
- @window = Editor::MainWindow.new(encoding)
- @window.icon_list = [ Editor.fetch_icon('json') ]
- yield @window if block_given?
- @window.show_all
- Gtk.main
- end
-
- # Edit the string _json_ with encoding _encoding_ in the editor.
- def edit(json, encoding = 'utf8')
- start(encoding) do |window|
- window.edit json
- end
- end
-
- attr_reader :window
- end
- end
-end
- # vim: set et sw=2 ts=2:
diff --git a/ext/json/lib/json/ext.rb b/ext/json/lib/json/ext.rb
deleted file mode 100644
index ff4fa42329..0000000000
--- a/ext/json/lib/json/ext.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'json/common'
-
-module JSON
- # This module holds all the modules/classes that implement JSON's
- # functionality as C extensions.
- module Ext
- require 'json/ext/parser'
- require 'json/ext/generator'
- $DEBUG and warn "Using c extension for JSON."
- JSON.parser = Parser
- JSON.generator = Generator
- end
-end
diff --git a/ext/json/lib/json/json.xpm b/ext/json/lib/json/json.xpm
deleted file mode 100644
index 2cb626bb05..0000000000
--- a/ext/json/lib/json/json.xpm
+++ /dev/null
@@ -1,1499 +0,0 @@
-/* XPM */
-static char * json_xpm[] = {
-"64 64 1432 2",
-" c None",
-". c #641839",
-"+ c #CF163C",
-"@ c #D31C3B",
-"# c #E11A38",
-"$ c #5F242D",
-"% c #320C22",
-"& c #9B532D",
-"* c #F32E34",
-"= c #820F33",
-"- c #4B0F34",
-"; c #8E1237",
-"> c #944029",
-", c #961325",
-"' c #A00C24",
-") c #872C23",
-"! c #694021",
-"~ c #590D1F",
-"{ c #420528",
-"] c #D85A2D",
-"^ c #7E092B",
-"/ c #0E0925",
-"( c #0D081F",
-"_ c #0F081E",
-": c #12071F",
-"< c #360620",
-"[ c #682A21",
-"} c #673F21",
-"| c #780E21",
-"1 c #A82320",
-"2 c #8D1D1F",
-"3 c #970127",
-"4 c #0D0123",
-"5 c #0D0324",
-"6 c #3B1E28",
-"7 c #C28429",
-"8 c #0C0523",
-"9 c #0C041E",
-"0 c #0E031A",
-"a c #11031A",
-"b c #13031B",
-"c c #13031C",
-"d c #11031D",
-"e c #19051E",
-"f c #390E20",
-"g c #9C0C20",
-"h c #C00721",
-"i c #980320",
-"j c #14031E",
-"k c #CD9F32",
-"l c #C29F2E",
-"m c #0F0325",
-"n c #0D0321",
-"o c #0E0324",
-"p c #D08329",
-"q c #9D1B27",
-"r c #1C0320",
-"s c #0D011A",
-"t c #120117",
-"u c #130017",
-"v c #150018",
-"w c #160119",
-"x c #17021A",
-"y c #15021B",
-"z c #11021E",
-"A c #0F021F",
-"B c #8C1821",
-"C c #CF4522",
-"D c #831821",
-"E c #BA7033",
-"F c #EDB339",
-"G c #C89733",
-"H c #280727",
-"I c #0F051F",
-"J c #0E0420",
-"K c #591F27",
-"L c #E47129",
-"M c #612224",
-"N c #0C021D",
-"O c #120018",
-"P c #140017",
-"Q c #170017",
-"R c #190018",
-"S c #1B0019",
-"T c #1B011A",
-"U c #18011B",
-"V c #15011C",
-"W c #12031E",
-"X c #460A21",
-"Y c #A13823",
-"Z c #784323",
-"` c #5A0C21",
-" . c #BC4530",
-".. c #EB5B38",
-"+. c #CE4E3B",
-"@. c #DD9334",
-"#. c #751A27",
-"$. c #11071E",
-"%. c #0F041C",
-"&. c #1E0824",
-"*. c #955A28",
-"=. c #9A5027",
-"-. c #1E0321",
-";. c #11011A",
-">. c #140018",
-",. c #180018",
-"'. c #1F001A",
-"). c #20001B",
-"!. c #1E001A",
-"~. c #1B001A",
-"{. c #16021B",
-"]. c #16041E",
-"^. c #220622",
-"/. c #5F3525",
-"(. c #DE5724",
-"_. c #611021",
-":. c #0F0925",
-"<. c #D1892E",
-"[. c #F27036",
-"}. c #EC633B",
-"|. c #DA293C",
-"1. c #E64833",
-"2. c #912226",
-"3. c #11081C",
-"4. c #110419",
-"5. c #0F041E",
-"6. c #451425",
-"7. c #BF6F28",
-"8. c #332225",
-"9. c #0E021E",
-"0. c #13001B",
-"a. c #17001A",
-"b. c #1C001B",
-"c. c #21001C",
-"d. c #23001C",
-"e. c #21001B",
-"f. c #19021A",
-"g. c #17041E",
-"h. c #150721",
-"i. c #602424",
-"j. c #D51223",
-"k. c #540820",
-"l. c #D04D2D",
-"m. c #EA8933",
-"n. c #875637",
-"o. c #88543A",
-"p. c #E5923A",
-"q. c #891931",
-"r. c #130B25",
-"s. c #10051B",
-"t. c #110217",
-"u. c #12021A",
-"v. c #761826",
-"w. c #E2A728",
-"x. c #300224",
-"y. c #10011E",
-"z. c #16001B",
-"A. c #1B001B",
-"B. c #21001A",
-"C. c #1E0019",
-"D. c #1D0019",
-"E. c #1A011A",
-"F. c #17031C",
-"G. c #120720",
-"H. c #4E0822",
-"I. c #670721",
-"J. c #C07630",
-"K. c #F59734",
-"L. c #BE1B35",
-"M. c #0E1435",
-"N. c #522037",
-"O. c #DB8039",
-"P. c #D45933",
-"Q. c #420927",
-"R. c #0F041D",
-"S. c #140118",
-"T. c #13021D",
-"U. c #100423",
-"V. c #7B6227",
-"W. c #C04326",
-"X. c #0E0020",
-"Y. c #13001D",
-"Z. c #18001B",
-"`. c #1E001B",
-" + c #22001C",
-".+ c #22001B",
-"++ c #1B011B",
-"@+ c #16041D",
-"#+ c #130520",
-"$+ c #860521",
-"%+ c #710520",
-"&+ c #670A2A",
-"*+ c #A66431",
-"=+ c #E97536",
-"-+ c #F8833A",
-";+ c #F77A3A",
-">+ c #C45337",
-",+ c #0A1C35",
-"'+ c #993638",
-")+ c #F7863B",
-"!+ c #F49736",
-"~+ c #94462B",
-"{+ c #0E031F",
-"]+ c #130119",
-"^+ c #160018",
-"/+ c #16011B",
-"(+ c #15021F",
-"_+ c #120123",
-":+ c #A65C28",
-"<+ c #5C4D23",
-"[+ c #0F001F",
-"}+ c #14001D",
-"|+ c #1A001B",
-"1+ c #1F001B",
-"2+ c #24001D",
-"3+ c #25001D",
-"4+ c #24001C",
-"5+ c #1F001C",
-"6+ c #1A011C",
-"7+ c #16021E",
-"8+ c #3F0421",
-"9+ c #BC0522",
-"0+ c #1C041E",
-"a+ c #7F5531",
-"b+ c #E68A38",
-"c+ c #F8933E",
-"d+ c #FA7942",
-"e+ c #FB7543",
-"f+ c #FA6F41",
-"g+ c #F1793D",
-"h+ c #7D3B3A",
-"i+ c #28263B",
-"j+ c #D45441",
-"k+ c #F8A238",
-"l+ c #996B2D",
-"m+ c #0E0421",
-"n+ c #12011A",
-"o+ c #180019",
-"p+ c #17001C",
-"q+ c #12001F",
-"r+ c #4C2B2A",
-"s+ c #DB8130",
-"t+ c #540023",
-"u+ c #0F0120",
-"v+ c #16011C",
-"w+ c #22001D",
-"x+ c #25001F",
-"y+ c #26001F",
-"z+ c #25001E",
-"A+ c #24001E",
-"B+ c #1D001C",
-"C+ c #18011D",
-"D+ c #16031F",
-"E+ c #3C0522",
-"F+ c #9B0821",
-"G+ c #13041E",
-"H+ c #F6462E",
-"I+ c #E6AB37",
-"J+ c #E7A03E",
-"K+ c #FA9F44",
-"L+ c #FB8A48",
-"M+ c #FD7A4A",
-"N+ c #FD794A",
-"O+ c #FD7748",
-"P+ c #FD7E45",
-"Q+ c #FD8343",
-"R+ c #FB5D42",
-"S+ c #6E3A40",
-"T+ c #EE8A37",
-"U+ c #7E252B",
-"V+ c #100520",
-"W+ c #13011A",
-"X+ c #170019",
-"Y+ c #15001C",
-"Z+ c #0F0020",
-"`+ c #564427",
-" @ c #E0BA29",
-".@ c #5E2B25",
-"+@ c #10011F",
-"@@ c #17011C",
-"#@ c #1E001D",
-"$@ c #23001F",
-"%@ c #250020",
-"&@ c #24001F",
-"*@ c #23001E",
-"=@ c #21001E",
-"-@ c #1B001C",
-";@ c #17021D",
-">@ c #14041E",
-",@ c #AC0B25",
-"'@ c #5E1420",
-")@ c #F28635",
-"!@ c #C2733E",
-"~@ c #984C44",
-"{@ c #EA9148",
-"]@ c #FB844B",
-"^@ c #FD7E4C",
-"/@ c #FE7E4C",
-"(@ c #FE7E4B",
-"_@ c #FE7749",
-":@ c #FD7148",
-"<@ c #FB7D46",
-"[@ c #F89641",
-"}@ c #B95634",
-"|@ c #0D0927",
-"1@ c #11041D",
-"2@ c #150119",
-"3@ c #180017",
-"4@ c #16001A",
-"5@ c #13001E",
-"6@ c #110023",
-"7@ c #944C29",
-"8@ c #EE6229",
-"9@ c #3D0324",
-"0@ c #12021F",
-"a@ c #19011D",
-"b@ c #21001F",
-"c@ c #22001F",
-"d@ c #20001E",
-"e@ c #1F001D",
-"f@ c #1C001C",
-"g@ c #19011C",
-"h@ c #3D1621",
-"i@ c #B53622",
-"j@ c #31061F",
-"k@ c #841D34",
-"l@ c #F2703F",
-"m@ c #C14445",
-"n@ c #E67349",
-"o@ c #FB8E4B",
-"p@ c #FD834C",
-"q@ c #FE834D",
-"r@ c #FE834C",
-"s@ c #FE804C",
-"t@ c #FD814B",
-"u@ c #FB7D49",
-"v@ c #F79B43",
-"w@ c #AF1234",
-"x@ c #0D0625",
-"y@ c #13021C",
-"z@ c #1A0019",
-"A@ c #190019",
-"B@ c #410225",
-"C@ c #D39729",
-"D@ c #AA5927",
-"E@ c #0E0422",
-"F@ c #15021E",
-"G@ c #1A011D",
-"H@ c #1D001D",
-"I@ c #15031D",
-"J@ c #240820",
-"K@ c #A01023",
-"L@ c #670B21",
-"M@ c #3D0D33",
-"N@ c #E63C3E",
-"O@ c #EF7C45",
-"P@ c #F59048",
-"Q@ c #FB944A",
-"R@ c #FD904A",
-"S@ c #FE8E4B",
-"T@ c #FE854A",
-"U@ c #FE854B",
-"V@ c #FE884C",
-"W@ c #FC954B",
-"X@ c #F8AB45",
-"Y@ c #C37A35",
-"Z@ c #0D0425",
-"`@ c #13011B",
-" # c #170018",
-".# c #1A0018",
-"+# c #1C0019",
-"@# c #15001B",
-"## c #100120",
-"$# c #311F25",
-"%# c #E68E28",
-"&# c #7A1425",
-"*# c #130321",
-"=# c #17011E",
-"-# c #1A001D",
-";# c #19001B",
-"># c #16021C",
-",# c #130521",
-"'# c #6F3123",
-")# c #6D3022",
-"!# c #C89433",
-"~# c #EA7E3E",
-"{# c #DB2943",
-"]# c #EF7745",
-"^# c #FB8544",
-"/# c #FD9A43",
-"(# c #FE9941",
-"_# c #FE9D43",
-":# c #FEA548",
-"<# c #FEAE49",
-"[# c #FCB944",
-"}# c #CA9F35",
-"|# c #0E0225",
-"1# c #11001B",
-"2# c #160019",
-"3# c #12011B",
-"4# c #0F0220",
-"5# c #351D26",
-"6# c #D85B28",
-"7# c #6C0F26",
-"8# c #190121",
-"9# c #1B001E",
-"0# c #1A001C",
-"a# c #1D001B",
-"b# c #130220",
-"c# c #703A23",
-"d# c #713A23",
-"e# c #140327",
-"f# c #411B36",
-"g# c #C8713E",
-"h# c #7A3A3F",
-"i# c #CE2C3C",
-"j# c #E77338",
-"k# c #9C6535",
-"l# c #9C6233",
-"m# c #9C6332",
-"n# c #9C6A35",
-"o# c #C37D3C",
-"p# c #FEAC41",
-"q# c #FEC23E",
-"r# c #826330",
-"s# c #100122",
-"t# c #120019",
-"u# c #150017",
-"v# c #190017",
-"w# c #1B0018",
-"x# c #12001A",
-"y# c #10021F",
-"z# c #1A0326",
-"A# c #5F292A",
-"B# c #7B4E29",
-"C# c #3C0E25",
-"D# c #1A0020",
-"E# c #14021F",
-"F# c #723B23",
-"G# c #14001A",
-"H# c #58042A",
-"I# c #A28337",
-"J# c #C8813B",
-"K# c #B14B38",
-"L# c #761231",
-"M# c #5A132A",
-"N# c #0D0726",
-"O# c #0C0623",
-"P# c #0B0723",
-"Q# c #0B0A26",
-"R# c #321C2D",
-"S# c #C45B33",
-"T# c #FEBB33",
-"U# c #13052A",
-"V# c #13011F",
-"W# c #160017",
-"X# c #15001A",
-"Y# c #12001D",
-"Z# c #94062A",
-"`# c #630D2C",
-" $ c #85292B",
-".$ c #AA5E29",
-"+$ c #1F0123",
-"@$ c #19011F",
-"#$ c #1E001C",
-"$$ c #15031F",
-"%$ c #712122",
-"&$ c #712223",
-"*$ c #14011B",
-"=$ c #110321",
-"-$ c #AF0C2B",
-";$ c #E7D534",
-">$ c #EAC934",
-",$ c #84582D",
-"'$ c #1B0824",
-")$ c #11041E",
-"!$ c #10021B",
-"~$ c #100119",
-"{$ c #100218",
-"]$ c #0F041A",
-"^$ c #0E0720",
-"/$ c #2C1026",
-"($ c #D8A328",
-"_$ c #140322",
-":$ c #160016",
-"<$ c #14001F",
-"[$ c #120024",
-"}$ c #100128",
-"|$ c #3C032F",
-"1$ c #2C062E",
-"2$ c #29022B",
-"3$ c #A31D29",
-"4$ c #976A25",
-"5$ c #1A0321",
-"6$ c #17031E",
-"7$ c #1B021D",
-"8$ c #20001C",
-"9$ c #14041F",
-"0$ c #703422",
-"a$ c #6F3522",
-"b$ c #8D0328",
-"c$ c #920329",
-"d$ c #0F0326",
-"e$ c #100321",
-"f$ c #11021B",
-"g$ c #130117",
-"h$ c #140016",
-"i$ c #150015",
-"j$ c #140015",
-"k$ c #130116",
-"l$ c #120219",
-"m$ c #11031C",
-"n$ c #12031D",
-"o$ c #170016",
-"p$ c #160020",
-"q$ c #250029",
-"r$ c #670033",
-"s$ c #DCA238",
-"t$ c #F5C736",
-"u$ c #9A732E",
-"v$ c #110227",
-"w$ c #110324",
-"x$ c #811924",
-"y$ c #A04323",
-"z$ c #250721",
-"A$ c #1A041F",
-"B$ c #1E011D",
-"C$ c #1C011C",
-"D$ c #18031D",
-"E$ c #130721",
-"F$ c #6F3623",
-"G$ c #6B3622",
-"H$ c #1A001A",
-"I$ c #14011F",
-"J$ c #12011E",
-"K$ c #11011C",
-"L$ c #140117",
-"M$ c #170015",
-"N$ c #150016",
-"O$ c #120119",
-"P$ c #11011B",
-"Q$ c #11001A",
-"R$ c #130018",
-"S$ c #170118",
-"T$ c #170119",
-"U$ c #18021E",
-"V$ c #1A0126",
-"W$ c #6F2332",
-"X$ c #E5563B",
-"Y$ c #F1B83F",
-"Z$ c #F6CC38",
-"`$ c #9D7A2D",
-" % c #130123",
-".% c #130320",
-"+% c #2A0721",
-"@% c #B00E24",
-"#% c #7D0B23",
-"$% c #1F0522",
-"%% c #1E0220",
-"&% c #1D011E",
-"*% c #1A031E",
-"=% c #15051F",
-"-% c #241322",
-";% c #A32F23",
-">% c #670E21",
-",% c #1C001A",
-"'% c #19001A",
-")% c #180016",
-"!% c #160118",
-"~% c #140219",
-"{% c #11021C",
-"]% c #10021E",
-"^% c #0F011D",
-"/% c #170117",
-"(% c #160219",
-"_% c #17041D",
-":% c #190523",
-"<% c #8C042E",
-"[% c #B65838",
-"}% c #E9D73F",
-"|% c #EED43E",
-"1% c #D85538",
-"2% c #493129",
-"3% c #130120",
-"4% c #15021D",
-"5% c #330822",
-"6% c #8A0825",
-"7% c #3C0424",
-"8% c #1E0322",
-"9% c #1C0321",
-"0% c #180421",
-"a% c #130822",
-"b% c #AF2D24",
-"c% c #BC5623",
-"d% c #2F071F",
-"e% c #1A041C",
-"f% c #1C031C",
-"g% c #1D011C",
-"h% c #160117",
-"i% c #150419",
-"j% c #12081D",
-"k% c #0F0923",
-"l% c #A77027",
-"m% c #A60525",
-"n% c #11021A",
-"o% c #130218",
-"p% c #150319",
-"q% c #16061D",
-"r% c #180923",
-"s% c #9C1D2B",
-"t% c #A32636",
-"u% c #A66E3B",
-"v% c #4B2E3C",
-"w% c #412C36",
-"x% c #36012D",
-"y% c #140123",
-"z% c #17001E",
-"A% c #19011B",
-"B% c #1A0421",
-"C% c #340425",
-"D% c #9E0326",
-"E% c #1F0424",
-"F% c #1C0524",
-"G% c #180724",
-"H% c #A91024",
-"I% c #D55D24",
-"J% c #90071E",
-"K% c #3C051D",
-"L% c #1C021C",
-"M% c #1C011A",
-"N% c #1D001A",
-"O% c #160116",
-"P% c #150216",
-"Q% c #140217",
-"R% c #140618",
-"S% c #120D1D",
-"T% c #231925",
-"U% c #B16A2E",
-"V% c #FDAC34",
-"W% c #D58631",
-"X% c #280E2A",
-"Y% c #0D0A23",
-"Z% c #0F0920",
-"`% c #120C21",
-" & c #1F1026",
-".& c #A3352E",
-"+& c #EE9F36",
-"@& c #5D2A3C",
-"#& c #960D3C",
-"$& c #970638",
-"%& c #A00330",
-"&& c #4D0126",
-"*& c #1C001F",
-"=& c #280120",
-"-& c #290223",
-";& c #1F0425",
-">& c #260726",
-",& c #340A26",
-"'& c #850925",
-")& c #3A0823",
-"!& c #82071D",
-"~& c #5E071D",
-"{& c #18051C",
-"]& c #18021A",
-"^& c #190118",
-"/& c #160217",
-"(& c #150418",
-"_& c #130618",
-":& c #110718",
-"<& c #10081A",
-"[& c #110D1D",
-"}& c #291C24",
-"|& c #A73B2D",
-"1& c #FD6B36",
-"2& c #FD853C",
-"3& c #FD863B",
-"4& c #C24A35",
-"5& c #6B442F",
-"6& c #6D302D",
-"7& c #6E252E",
-"8& c #8E3B32",
-"9& c #DE7739",
-"0& c #F48E3F",
-"a& c #DD8D41",
-"b& c #854F3D",
-"c& c #7E2D35",
-"d& c #33082B",
-"e& c #1C0222",
-"f& c #20001F",
-"g& c #1F0222",
-"h& c #1A0524",
-"i& c #440C27",
-"j& c #BC1427",
-"k& c #20041B",
-"l& c #53061C",
-"m& c #25071B",
-"n& c #11061A",
-"o& c #130418",
-"p& c #140317",
-"q& c #150217",
-"r& c #160318",
-"s& c #12051B",
-"t& c #100C1D",
-"u& c #0E101E",
-"v& c #0C121F",
-"w& c #0C1321",
-"x& c #781725",
-"y& c #B25D2C",
-"z& c #FA6335",
-"A& c #FD633C",
-"B& c #FE6D42",
-"C& c #FE7C42",
-"D& c #FE813F",
-"E& c #FE873C",
-"F& c #FD743B",
-"G& c #FB683B",
-"H& c #FA7A3E",
-"I& c #F98242",
-"J& c #F97844",
-"K& c #F98943",
-"L& c #F79C3D",
-"M& c #A25133",
-"N& c #280B28",
-"O& c #1D021F",
-"P& c #1F011C",
-"Q& c #280321",
-"R& c #1C0724",
-"S& c #3F1C27",
-"T& c #D33C27",
-"U& c #0E061B",
-"V& c #0C091C",
-"W& c #0C0A1B",
-"X& c #0E091A",
-"Y& c #11081B",
-"Z& c #100A20",
-"`& c #0E0D23",
-" * c #551227",
-".* c #B21829",
-"+* c #C42329",
-"@* c #C62C29",
-"#* c #C55429",
-"$* c #E76F2B",
-"%* c #F14232",
-"&* c #F95E3A",
-"** c #FC6740",
-"=* c #FE6E45",
-"-* c #FE7246",
-";* c #FE7545",
-">* c #FE7744",
-",* c #FD7745",
-"'* c #FD7845",
-")* c #FD7847",
-"!* c #FD7948",
-"~* c #FD7B44",
-"{* c #FC7C3B",
-"]* c #6F3130",
-"^* c #140B24",
-"/* c #19031D",
-"(* c #1C011B",
-"_* c #5A011F",
-":* c #B70421",
-"<* c #380824",
-"[* c #3E2626",
-"}* c #9F5626",
-"|* c #13051E",
-"1* c #360A21",
-"2* c #361223",
-"3* c #371724",
-"4* c #381824",
-"5* c #3B1524",
-"6* c #3E1E26",
-"7* c #471A29",
-"8* c #DB252E",
-"9* c #ED2733",
-"0* c #EE5436",
-"a* c #F04237",
-"b* c #F33934",
-"c* c #F53D2F",
-"d* c #D7312B",
-"e* c #AF212B",
-"f* c #3A2C31",
-"g* c #F65F39",
-"h* c #FB6F41",
-"i* c #FD6D45",
-"j* c #FE7047",
-"k* c #FE7647",
-"l* c #FE7847",
-"m* c #FE7848",
-"n* c #FE7748",
-"o* c #FE7948",
-"p* c #FE7C48",
-"q* c #FE7C47",
-"r* c #FE7642",
-"s* c #FE7439",
-"t* c #6D332C",
-"u* c #100B21",
-"v* c #16031B",
-"w* c #2B001B",
-"x* c #22011F",
-"y* c #220521",
-"z* c #1B0A23",
-"A* c #421425",
-"B* c #951924",
-"C* c #381023",
-"D* c #E94028",
-"E* c #E7302B",
-"F* c #EF432D",
-"G* c #F4302E",
-"H* c #F32C30",
-"I* c #CB4432",
-"J* c #DD3235",
-"K* c #EF4B3A",
-"L* c #F0333E",
-"M* c #CC3D3F",
-"N* c #E4313C",
-"O* c #F34834",
-"P* c #D13E2C",
-"Q* c #431825",
-"R* c #0E1424",
-"S* c #3C202C",
-"T* c #F15537",
-"U* c #F97140",
-"V* c #FC6E45",
-"W* c #FE7547",
-"X* c #FE7947",
-"Y* c #FE7B48",
-"Z* c #FE7D48",
-"`* c #FE8047",
-" = c #FE7A42",
-".= c #FE7A38",
-"+= c #6D442B",
-"@= c #0F0B21",
-"#= c #15031A",
-"$= c #49001B",
-"%= c #2F001C",
-"&= c #21021E",
-"*= c #220620",
-"== c #1B0D23",
-"-= c #641625",
-";= c #951823",
-">= c #390F25",
-",= c #AC3A2A",
-"'= c #B6492E",
-")= c #ED7531",
-"!= c #F45A34",
-"~= c #F54C36",
-"{= c #C72D39",
-"]= c #DE283C",
-"^= c #F33B40",
-"/= c #F34142",
-"(= c #D0393F",
-"_= c #E72E39",
-":= c #DB3C2E",
-"<= c #461724",
-"[= c #0F0D1E",
-"}= c #140B1E",
-"|= c #341427",
-"1= c #CB4834",
-"2= c #F7743F",
-"3= c #FB7145",
-"4= c #FE7747",
-"5= c #FE7A47",
-"6= c #FF7B48",
-"7= c #FF7C48",
-"8= c #FE7F47",
-"9= c #FE8247",
-"0= c #FE8642",
-"a= c #FE8439",
-"b= c #6D442D",
-"c= c #0F0A21",
-"d= c #14031A",
-"e= c #20031D",
-"f= c #210821",
-"g= c #191024",
-"h= c #CC1C25",
-"i= c #961423",
-"j= c #2C162C",
-"k= c #BD242E",
-"l= c #EF2C31",
-"m= c #F54C34",
-"n= c #F34037",
-"o= c #F5353A",
-"p= c #F7413D",
-"q= c #F8423D",
-"r= c #F93A39",
-"s= c #F95731",
-"t= c #341425",
-"u= c #110A1D",
-"v= c #140619",
-"w= c #18051B",
-"x= c #200F26",
-"y= c #864833",
-"z= c #F8773F",
-"A= c #FC7445",
-"B= c #FF7E48",
-"C= c #FF7E49",
-"D= c #FF7D49",
-"E= c #FF7D48",
-"F= c #FE8347",
-"G= c #FE8743",
-"H= c #FE893B",
-"I= c #6E452F",
-"J= c #100E23",
-"K= c #14041A",
-"L= c #55041D",
-"M= c #540921",
-"N= c #161124",
-"O= c #CE6A25",
-"P= c #3F1129",
-"Q= c #170A29",
-"R= c #0F0F29",
-"S= c #15132B",
-"T= c #1E182D",
-"U= c #A82B3D",
-"V= c #CB6633",
-"W= c #CC6932",
-"X= c #CC3D2D",
-"Y= c #331225",
-"Z= c #0F091C",
-"`= c #120417",
-" - c #160216",
-".- c #190419",
-"+- c #210F26",
-"@- c #8C4934",
-"#- c #F97A40",
-"$- c #FC7545",
-"%- c #FF7B49",
-"&- c #FE7D46",
-"*- c #FE7E43",
-"=- c #FD7B3E",
-"-- c #FA6934",
-";- c #532328",
-">- c #130B1D",
-",- c #150519",
-"'- c #14041C",
-")- c #120920",
-"!- c #C43624",
-"~- c #A21E23",
-"{- c #F87C30",
-"]- c #C9302D",
-"^- c #300F2A",
-"/- c #591129",
-"(- c #171328",
-"_- c #171628",
-":- c #141829",
-"<- c #101A2B",
-"[- c #0F172B",
-"}- c #0F1226",
-"|- c #0E0C20",
-"1- c #100619",
-"2- c #140316",
-"3- c #19051B",
-"4- c #3C1428",
-"5- c #E04B36",
-"6- c #FA7B41",
-"7- c #FD7346",
-"8- c #FE7548",
-"9- c #FF7849",
-"0- c #FF7749",
-"a- c #FE7B47",
-"b- c #FE7945",
-"c- c #FC7740",
-"d- c #FA7E39",
-"e- c #C1432F",
-"f- c #131523",
-"g- c #130A1C",
-"h- c #420621",
-"i- c #D08423",
-"j- c #F87739",
-"k- c #C03D37",
-"l- c #962B34",
-"m- c #A14332",
-"n- c #E54B30",
-"o- c #9E3E2F",
-"p- c #7F262E",
-"q- c #922D2E",
-"r- c #9C4B2E",
-"s- c #65212C",
-"t- c #101628",
-"u- c #101022",
-"v- c #11091C",
-"w- c #130619",
-"x- c #160A1E",
-"y- c #43252C",
-"z- c #F66439",
-"A- c #FA6942",
-"B- c #FD6C47",
-"C- c #FE6E48",
-"D- c #FE6F48",
-"E- c #FE7049",
-"F- c #FE714A",
-"G- c #FE744A",
-"H- c #FE7846",
-"I- c #FD7243",
-"J- c #FC703E",
-"K- c #FA6C37",
-"L- c #81312B",
-"M- c #121123",
-"N- c #15071D",
-"O- c #16031A",
-"P- c #17021B",
-"Q- c #8F3D22",
-"R- c #F8393E",
-"S- c #E42A3D",
-"T- c #E7473B",
-"U- c #FB503B",
-"V- c #FB4F3A",
-"W- c #F95439",
-"X- c #ED4C38",
-"Y- c #F45938",
-"Z- c #FB6537",
-"`- c #EA5236",
-" ; c #CE6232",
-".; c #CD392C",
-"+; c #181425",
-"@; c #120F21",
-"#; c #130D20",
-"$; c #151225",
-"%; c #903431",
-"&; c #F8703D",
-"*; c #FB6344",
-"=; c #FD6748",
-"-; c #FE6849",
-";; c #FE6949",
-">; c #FE6A49",
-",; c #FE6C4A",
-"'; c #FE704A",
-"); c #FE734A",
-"!; c #FE7449",
-"~; c #FE7347",
-"{; c #FE7145",
-"]; c #FD6C42",
-"^; c #FD753D",
-"/; c #F36E35",
-"(; c #CB452C",
-"_; c #600D24",
-":; c #1C061F",
-"<; c #1E031F",
-"[; c #5B3821",
-"}; c #CE9822",
-"|; c #FA4341",
-"1; c #FB4341",
-"2; c #FC4541",
-"3; c #FC4542",
-"4; c #FC4143",
-"5; c #FC4D42",
-"6; c #FB5042",
-"7; c #FB5342",
-"8; c #FC5242",
-"9; c #FD4F40",
-"0; c #FD503E",
-"a; c #FB6339",
-"b; c #F45E33",
-"c; c #A12A2E",
-"d; c #401E2C",
-"e; c #452D2F",
-"f; c #F74F38",
-"g; c #FA5940",
-"h; c #FC6245",
-"i; c #FE6447",
-"j; c #FE6449",
-"k; c #FE6549",
-"l; c #FE6749",
-"m; c #FE6B49",
-"n; c #FE6D49",
-"o; c #FE6D48",
-"p; c #FE6D47",
-"q; c #FE6D45",
-"r; c #FE6C44",
-"s; c #FE6A42",
-"t; c #FE663C",
-"u; c #FC6233",
-"v; c #752129",
-"w; c #1F0922",
-"x; c #750520",
-"y; c #81061F",
-"z; c #FA3D42",
-"A; c #FB4142",
-"B; c #FD4543",
-"C; c #FD4844",
-"D; c #FD4A45",
-"E; c #FD4D45",
-"F; c #FD5045",
-"G; c #FD5345",
-"H; c #FE5346",
-"I; c #FE5445",
-"J; c #FD5444",
-"K; c #FC4F41",
-"L; c #FA513D",
-"M; c #F95339",
-"N; c #F63736",
-"O; c #F75737",
-"P; c #F95F3B",
-"Q; c #FB5840",
-"R; c #FD5F43",
-"S; c #FE6345",
-"T; c #FE6547",
-"U; c #FE6548",
-"V; c #FE6448",
-"W; c #FE6248",
-"X; c #FE6348",
-"Y; c #FE6748",
-"Z; c #FE6848",
-"`; c #FE6846",
-" > c #FE6A45",
-".> c #FE6D43",
-"+> c #FE703F",
-"@> c #FC6F36",
-"#> c #6F302B",
-"$> c #140A22",
-"%> c #FA3B42",
-"&> c #FC4243",
-"*> c #FD4744",
-"=> c #FE4A45",
-"-> c #FE4C47",
-";> c #FE4D47",
-">> c #FE5047",
-",> c #FE5347",
-"'> c #FE5447",
-")> c #FD5246",
-"!> c #FB503F",
-"~> c #FA543D",
-"{> c #9B3D3B",
-"]> c #A3433B",
-"^> c #F9683D",
-"/> c #FC6940",
-"(> c #FE6342",
-"_> c #FE6645",
-":> c #FE6646",
-"<> c #FE6147",
-"[> c #FE6048",
-"}> c #FE6148",
-"|> c #FE6746",
-"1> c #FE6A46",
-"2> c #FE6F45",
-"3> c #FE7441",
-"4> c #FC7D39",
-"5> c #6C422E",
-"6> c #0F0F23",
-"7> c #FA4142",
-"8> c #FC4643",
-"9> c #FE4D46",
-"0> c #FE4E47",
-"a> c #FE4F48",
-"b> c #FE5148",
-"c> c #FE5348",
-"d> c #FE5548",
-"e> c #FE5247",
-"f> c #FD5445",
-"g> c #FC5544",
-"h> c #F96041",
-"i> c #D33F3D",
-"j> c #392D39",
-"k> c #973C38",
-"l> c #F94E3A",
-"m> c #FD693E",
-"n> c #FE6C43",
-"o> c #FE6047",
-"p> c #FE5D47",
-"q> c #FE5E48",
-"r> c #FE6948",
-"s> c #FE6947",
-"t> c #FE6B47",
-"u> c #FE6E46",
-"v> c #FD6D43",
-"w> c #FB723D",
-"x> c #D54A33",
-"y> c #301C29",
-"z> c #FB4A42",
-"A> c #FD4B44",
-"B> c #FE4F47",
-"C> c #FE5048",
-"D> c #FE5648",
-"E> c #FE5848",
-"F> c #FE5747",
-"G> c #FE5547",
-"H> c #FC5945",
-"I> c #F95742",
-"J> c #F3543D",
-"K> c #A33336",
-"L> c #302032",
-"M> c #152433",
-"N> c #CD3E38",
-"O> c #FD5A3F",
-"P> c #FE6343",
-"Q> c #FE6446",
-"R> c #FE6247",
-"S> c #FE6A47",
-"T> c #FC6542",
-"U> c #FB6A3B",
-"V> c #FA6D34",
-"W> c #D73C2D",
-"X> c #442428",
-"Y> c #281323",
-"Z> c #FD4E42",
-"`> c #FD4D43",
-" , c #FE4D45",
-"., c #FE5248",
-"+, c #FE5947",
-"@, c #FE5C47",
-"#, c #FE5B47",
-"$, c #FE5A47",
-"%, c #FE5847",
-"&, c #FC5C45",
-"*, c #F95B43",
-"=, c #F3613F",
-"-, c #E74F37",
-";, c #8C2431",
-">, c #161E2F",
-",, c #CD4E33",
-"', c #FD503A",
-"), c #FE5D40",
-"!, c #FE6445",
-"~, c #FE6946",
-"{, c #FE6847",
-"], c #FE6747",
-"^, c #FD6644",
-"/, c #FD6241",
-"(, c #FD5B3D",
-"_, c #FE6739",
-":, c #FE6135",
-"<, c #AB4830",
-"[, c #733E2A",
-"}, c #161224",
-"|, c #FC4E42",
-"1, c #FE4D44",
-"2, c #FE4E46",
-"3, c #FE5147",
-"4, c #FE5E47",
-"5, c #FD5C46",
-"6, c #FA5B44",
-"7, c #F45441",
-"8, c #EB393A",
-"9, c #CC3433",
-"0, c #47212F",
-"a, c #59242F",
-"b, c #FC6734",
-"c, c #FC6F3A",
-"d, c #FC723E",
-"e, c #FD6540",
-"f, c #FE6442",
-"g, c #FE6643",
-"h, c #FE6944",
-"i, c #FE6546",
-"j, c #FE6444",
-"k, c #FE6143",
-"l, c #FE5E41",
-"m, c #FE613F",
-"n, c #FE683C",
-"o, c #FE7937",
-"p, c #A25030",
-"q, c #692629",
-"r, c #151122",
-"s, c #FA573F",
-"t, c #FB4D40",
-"u, c #FC4F43",
-"v, c #FE5246",
-"w, c #FF6347",
-"x, c #FE5F48",
-"y, c #F65942",
-"z, c #F0493D",
-"A, c #ED3736",
-"B, c #73262F",
-"C, c #10152C",
-"D, c #3B292F",
-"E, c #363034",
-"F, c #AC3938",
-"G, c #FC6B3B",
-"H, c #FD763C",
-"I, c #FE6D3F",
-"J, c #FE6341",
-"K, c #FE6642",
-"L, c #FE6745",
-"M, c #FE6245",
-"N, c #FE6244",
-"O, c #FE6841",
-"P, c #FF683B",
-"Q, c #EC7035",
-"R, c #D0412D",
-"S, c #3A1627",
-"T, c #CF3938",
-"U, c #F6543C",
-"V, c #FB5040",
-"W, c #FD5544",
-"X, c #FE5A48",
-"Y, c #FE5D48",
-"Z, c #FE5F47",
-"`, c #FF6147",
-" ' c #FD5C45",
-".' c #FB5B43",
-"+' c #FA5A42",
-"@' c #F76040",
-"#' c #F4623D",
-"$' c #F26D38",
-"%' c #EC4130",
-"&' c #380E2B",
-"*' c #13122C",
-"=' c #362D31",
-"-' c #353435",
-";' c #352E37",
-">' c #2D3337",
-",' c #CC5838",
-"'' c #CD6F3A",
-")' c #CE6E3D",
-"!' c #FE793F",
-"~' c #FD7541",
-"{' c #FD6243",
-"]' c #FE6545",
-"^' c #FF6543",
-"/' c #FF6240",
-"(' c #FE723B",
-"_' c #FE8034",
-":' c #442D2C",
-"<' c #311725",
-"[' c #222830",
-"}' c #B73B36",
-"|' c #F94C3D",
-"1' c #FD5543",
-"2' c #FE5B48",
-"3' c #FF5E47",
-"4' c #FE5C48",
-"5' c #FC5B44",
-"6' c #F95640",
-"7' c #C34E3D",
-"8' c #A45A3A",
-"9' c #F37438",
-"0' c #F28935",
-"a' c #AF422F",
-"b' c #240D2B",
-"c' c #88292F",
-"d' c #FA8E34",
-"e' c #FC7E38",
-"f' c #FC5939",
-"g' c #694A37",
-"h' c #693437",
-"i' c #382638",
-"j' c #142439",
-"k' c #9F483A",
-"l' c #C45E3C",
-"m' c #FD7240",
-"n' c #FF6645",
-"o' c #FF6245",
-"p' c #FF6045",
-"q' c #FF6146",
-"r' c #FF6246",
-"s' c #FF6446",
-"t' c #FF6545",
-"u' c #FE763F",
-"v' c #FE7237",
-"w' c #C65331",
-"x' c #3D272A",
-"y' c #0D1E2B",
-"z' c #683032",
-"A' c #F9453A",
-"B' c #FD5341",
-"C' c #FE5A46",
-"D' c #FF5A48",
-"E' c #FE5948",
-"F' c #FD5A47",
-"G' c #FC5D43",
-"H' c #F95B3D",
-"I' c #713F37",
-"J' c #1E2D32",
-"K' c #C44531",
-"L' c #EF7A2F",
-"M' c #6B2E2C",
-"N' c #0F0E2C",
-"O' c #F56633",
-"P' c #FA803A",
-"Q' c #FC673E",
-"R' c #FD673E",
-"S' c #FC6F3C",
-"T' c #FA6E3B",
-"U' c #C6633A",
-"V' c #A06739",
-"W' c #835638",
-"X' c #381F38",
-"Y' c #713B38",
-"Z' c #7B503C",
-"`' c #FE7741",
-" ) c #FE7344",
-".) c #FE6D46",
-"+) c #FF6946",
-"@) c #FF5E46",
-"#) c #FF5D46",
-"$) c #FF5D47",
-"%) c #FF5F48",
-"&) c #FF6248",
-"*) c #FE6941",
-"=) c #FC783C",
-"-) c #C46B35",
-";) c #892730",
-">) c #111629",
-",) c #1F2630",
-"') c #AD3939",
-")) c #FC5D41",
-"!) c #FE5946",
-"~) c #FF5848",
-"{) c #FE5549",
-"]) c #FC5E42",
-"^) c #FA673B",
-"/) c #DB7033",
-"() c #392E2B",
-"_) c #311A28",
-":) c #3C2127",
-"<) c #1D1027",
-"[) c #92102C",
-"}) c #F58336",
-"|) c #FA673E",
-"1) c #FD6642",
-"2) c #FD5A41",
-"3) c #FC6D41",
-"4) c #FC6D3F",
-"5) c #FD683E",
-"6) c #F38C39",
-"7) c #CE6535",
-"8) c #612E34",
-"9) c #1D2637",
-"0) c #71513E",
-"a) c #FF6847",
-"b) c #FF5F47",
-"c) c #FF5A46",
-"d) c #FF5847",
-"e) c #FF5748",
-"f) c #FF594A",
-"g) c #FF5E4B",
-"h) c #FE654C",
-"i) c #FE694B",
-"j) c #FE6B48",
-"k) c #FC6A43",
-"l) c #F7683E",
-"m) c #EC6E39",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" . + @ # $ % ",
-" & * = - ; > , ' ) ! ~ ",
-" { ] ^ / ( _ : < [ } | 1 2 ",
-" 3 4 5 6 7 8 9 0 a b c d e f g h i j ",
-" k l m n o p q r s t u v w x y z A B C D ",
-" E F G H I J K L M N O P Q R S T U V W X Y Z ` ",
-" ...+.@.#.$.%.&.*.=.-.;.>.,.S '.).!.~.{.].^./.(._. ",
-" :.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.!.S f.g.h.i.j.k. ",
-" l.m.n.o.p.q.r.s.t.u.J v.w.x.y.z.A.c.d.d.B.C.D.E.F.G.H.I. ",
-" J.K.L.M.N.O.P.Q.R.t S.T.U.V.W.X.Y.Z.`. +d.d..+B.'.++@+#+$+%+ ",
-" &+*+=+-+;+>+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+1+d.2+3+4+d.5+6+7+8+9+0+ ",
-" a+b+c+d+e+f+g+h+i+j+k+l+m+n+^+o+p+q+r+s+t+u+v+b.w+x+y+z+A+w+B+C+D+E+F+G+ ",
-" H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+Q ,.X+Y+Z+`+ @.@+@@@#@$@%@&@*@=@#@-@;@>@,@'@ ",
-" )@!@~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@R ,.4@5@6@7@8@9@0@a@#@b@c@=@d@e@f@g@>@h@i@j@ ",
-" k@l@m@n@o@p@q@r@s@t@u@v@w@x@y@^+R S z@A@z.q+B@C@D@E@F@G@H@#@e@#@#@f@g@I@J@K@L@ ",
-" M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@`@ #.#+#+#S A@@###$#%#&#*#=#-#f@B+B+B+f@;#>#,#'#)# ",
-" !#~#{#]#^#/#(#(#_#:#<#[#}#|#1#^+.#S +#+#z@2#3#4#5#6#7#8#9#0#A.B+B+a#A.@@b#c#d# ",
-" e#f#g#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#.#w#S R ^+x#y#z#A#B#C#D#-#A.a#`.`.b.g@E#d#F# ",
-" G#0@H#I#J#K#L#M#N#O#P#Q#R#S#T#U#V#>.W#3@v#R R X+X#Y#s#Z#`# $.$+$@$g@f@5+5+#$6+$$%$&$ ",
-" *$=$-$;$>$,$'$)$!$~${$]$^$/$($_$*$u#:$Q 3@,.X+z.<$[$}$|$1$2$3$4$5$6$7$e@8$#$G@9$0$a$ ",
-" ,.4@E#b$c$d$e$f$g$h$i$j$k$l$m$n$`@>.:$o$3@,. #a.p$q$r$s$t$u$v$w$x$y$z$A$B$#@C$D$E$F$G$ ",
-" R S H$v+I$J$K$n+L$:$o$o$M$N$L$O$P$Q$R$N$o$3@S$T$U$V$W$X$Y$Z$`$ %.%+%@%#%$%%%&%*%=%-%;%>% ",
-" E.,%~.'%Z.4@v W#o$)%)%)%Q !%~%{%]%^%Q$u u#/%(%_%:%<%[%}%|%1%2%3%4%=%5%6%7%8%9%0%a%b%c%d% ",
-" e%f%g%a#,%,%z@R 3@3@3@)%Q h%i%j%k%l%m%{+n%o%p%q%r%s%t%u%v%w%x%y%z%A%*%B%C%D%E%F%G%H%I% ",
-" J%K%L%M%N%D.S v#)%)%O%P%Q%R%S%T%U%V%W%X%Y%Z%`% &.&+&@&#&$&%&&&*&f@a##@=&-&;&>&,&'&)& ",
-" !&~&{&]&^&.#w#^&/%/&(&_&:&<&[&}&|&1&2&3&4&5&6&7&8&9&0&a&b&c&d&e&e@1+5+e@f&g&h&i&j& ",
-" k&l&m&n&o&p&q&r&i%s&3.t&u&v&w&x&y&z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&1+`.e@f&Q&R&S&T& ",
-" 0 U&V&W&X&<&Y&j%Z&`& *.*+*@*#*$*%*&***=*-*;*>*>*,*'*)*!*~*{*]*^*/*(*a#B+#@_*:*<*[*}* ",
-" |*1*2*3*4*5*6*7*8*9*0*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*E.w*d.e@x*y*z*A*B* ",
-" C*D*E*F*G*H*I*J*K*L*M*N*O*P*Q*R*S*T*U*V*W*l*X*o*o*Y*Z*`* =.=+=@=#='%$=%=e@&=*===-=;= ",
-" >=,='=)=!=~={=]=^=/=(=_=:=<=[=}=|=1=2=3=4=5=p*6=6=7=8=9=0=a=b=c=d=A@~.b.B+e=f=g=h=i= ",
-" j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z=A=5=Z*B=C=D=E=8=F=G=H=I=J=K=S$R z@'%L=M=N=O= ",
-" P=Q=R=S=T=U=V=W=X=Y=Z=`= -.-+-@-#-$-5=p*E=D=%-%-q*&-*-=---;->-,-/%3@^+'-)-!-~- ",
-" {-]-^-/-(-_-:-<-[-}-|-1-2- -3-4-5-6-7-8-n*m*9-0-9-o*a-b-c-d-e-f-g-(&h%w c h-i- ",
-" j-k-l-m-n-o-p-q-r-s-t-u-v-w-,-x-y-z-A-B-C-D-E-E-F-G-_@m*H-I-J-K-L-M-N-O-P-(+Q- ",
-" R-S-T-U-V-W-X-Y-Z-`- ;.;+;@;#;$;%;&;*;=;-;-;;;>;,;';);!;~;{;];^;/;(;_;:;<;[;}; ",
-" |;1;2;3;4;5;6;7;8;9;0;a;b;c;d;e;f;g;h;i;j;j;k;k;l;m;n;o;p;q;r;s;t;u;v;w;x;y; ",
-" z;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;k;Y;Z;`; >r;.>+>@>#>$> ",
-" %>&>*>=>->;>>>,>'>,>)>F;8;!>~>{>]>^>/>(>_>:>i;<>[>X;}>i;|>1>q;2>3>4>5>6> ",
-" 7>8>=>9>0>a>b>c>d>,>e>e>f>g>h>i>j>k>l>m>n>:>i;o>p>q>W;r>s>t>p;u>v>w>x>y> ",
-" z>A>9>0>B>C>c>D>E>F>G>G>F>H>I>J>K>L>M>N>O>P>Q>R>o>R>T;s>S>S>S>t>1>T>U>V>W>X>Y> ",
-" Z>`> ,9>B>.,D>+,@,#,$,%,$,&,*,=,-,;,>,,,',),P>!,!,_>~,t>s>{,],{,],^,/,(,_,:,<,[,}, ",
-" |,`>1,2,3,G>+,4,o>o>4,@,@,5,6,7,8,9,0,a,b,c,d,e,f,g,h, >~,|>T;T;T;i,j,k,l,m,n,o,p,q,r, ",
-" s,t,u,v,G>%,@,o>w,R>x,p>@,5,6,y,z,A,B,C,D,E,F,G,H,I,J,K,L,L,i,i;i;i;Q>S;M,N,P>O,P,Q,R,S, ",
-" T,U,V,W,%,X,Y,Z,`,[>q>@, '.'+'@'#'$'%'&'*'='-';'>',''')'!'~'{'N,i,:>_>]'M,M,Q>_>^'/'('_':'<' ",
-" ['}'|'1'$,X,2'p>3'4'2'@,5'6'7'8'9'0'a'b'c'd'e'f'g'h'i'j'k'l'd,m'g, > >n'o'p'q'r's't'.>u'v'w'x' ",
-" y'z'A'B'C'X,X,2'D'E'E'F'G'H'I'J'K'L'M'N'O'P'Q'R'S'T'U'V'W'X'Y'Z'`' ).)+)r'@)#)$)%)&)l;1>*)=)-);) ",
-" >),)')))!)X,E'X,~){)d>!)])^)/)()_):)<)[)})|)1)f,2)3)4)5)6)7)8)9)0)*--*a)b)c)d)e)f)g)h)i)j)k)l)m) ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
diff --git a/ext/json/lib/json/pure.rb b/ext/json/lib/json/pure.rb
deleted file mode 100644
index b86d905523..0000000000
--- a/ext/json/lib/json/pure.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'json/common'
-require 'json/pure/parser'
-require 'json/pure/generator'
-
-module JSON
- begin
- require 'iconv'
- # An iconv instance to convert from UTF8 to UTF16 Big Endian.
- UTF16toUTF8 = Iconv.new('utf-8', 'utf-16be') # :nodoc:
- # An iconv instance to convert from UTF16 Big Endian to UTF8.
- UTF8toUTF16 = Iconv.new('utf-16be', 'utf-8') # :nodoc:
- UTF8toUTF16.iconv('no bom')
- rescue Errno::EINVAL, Iconv::InvalidEncoding
- # Iconv doesn't support big endian utf-16. Let's try to hack this manually
- # into the converters.
- begin
- old_verbose, $VERBSOSE = $VERBOSE, nil
- # An iconv instance to convert from UTF8 to UTF16 Big Endian.
- UTF16toUTF8 = Iconv.new('utf-8', 'utf-16') # :nodoc:
- # An iconv instance to convert from UTF16 Big Endian to UTF8.
- UTF8toUTF16 = Iconv.new('utf-16', 'utf-8') # :nodoc:
- UTF8toUTF16.iconv('no bom')
- if UTF8toUTF16.iconv("\xe2\x82\xac") == "\xac\x20"
- swapper = Class.new do
- def initialize(iconv) # :nodoc:
- @iconv = iconv
- end
-
- def iconv(string) # :nodoc:
- result = @iconv.iconv(string)
- JSON.swap!(result)
- end
- end
- UTF8toUTF16 = swapper.new(UTF8toUTF16) # :nodoc:
- end
- if UTF16toUTF8.iconv("\xac\x20") == "\xe2\x82\xac"
- swapper = Class.new do
- def initialize(iconv) # :nodoc:
- @iconv = iconv
- end
-
- def iconv(string) # :nodoc:
- string = JSON.swap!(string.dup)
- @iconv.iconv(string)
- end
- end
- UTF16toUTF8 = swapper.new(UTF16toUTF8) # :nodoc:
- end
- rescue Errno::EINVAL, Iconv::InvalidEncoding
- raise MissingUnicodeSupport, "iconv doesn't seem to support UTF-8/UTF-16 conversions"
- ensure
- $VERBOSE = old_verbose
- end
- rescue LoadError
- raise MissingUnicodeSupport,
- "iconv couldn't be loaded, which is required for UTF-8/UTF-16 conversions"
- end
-
- # Swap consecutive bytes of _string_ in place.
- def self.swap!(string) # :nodoc:
- 0.upto(string.size / 2) do |i|
- break unless string[2 * i + 1]
- string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
- end
- string
- end
-
- # This module holds all the modules/classes that implement JSON's
- # functionality in pure ruby.
- module Pure
- $DEBUG and warn "Using pure library for JSON."
- JSON.parser = Parser
- JSON.generator = Generator
- end
-end
diff --git a/ext/json/lib/json/pure/generator.rb b/ext/json/lib/json/pure/generator.rb
deleted file mode 100644
index 0fe73be41a..0000000000
--- a/ext/json/lib/json/pure/generator.rb
+++ /dev/null
@@ -1,394 +0,0 @@
-module JSON
- MAP = {
- "\x0" => '\u0000',
- "\x1" => '\u0001',
- "\x2" => '\u0002',
- "\x3" => '\u0003',
- "\x4" => '\u0004',
- "\x5" => '\u0005',
- "\x6" => '\u0006',
- "\x7" => '\u0007',
- "\b" => '\b',
- "\t" => '\t',
- "\n" => '\n',
- "\xb" => '\u000b',
- "\f" => '\f',
- "\r" => '\r',
- "\xe" => '\u000e',
- "\xf" => '\u000f',
- "\x10" => '\u0010',
- "\x11" => '\u0011',
- "\x12" => '\u0012',
- "\x13" => '\u0013',
- "\x14" => '\u0014',
- "\x15" => '\u0015',
- "\x16" => '\u0016',
- "\x17" => '\u0017',
- "\x18" => '\u0018',
- "\x19" => '\u0019',
- "\x1a" => '\u001a',
- "\x1b" => '\u001b',
- "\x1c" => '\u001c',
- "\x1d" => '\u001d',
- "\x1e" => '\u001e',
- "\x1f" => '\u001f',
- '"' => '\"',
- '\\' => '\\\\',
- '/' => '\/',
- } # :nodoc:
-
- # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
- # UTF16 big endian characters as \u????, and return it.
- def utf8_to_json(string) # :nodoc:
- string = string.gsub(/["\\\/\x0-\x1f]/) { |c| MAP[c] }
- string.gsub!(/(
- (?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = JSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
- s.gsub!(/.{4}/n, '\\\\u\&')
- }
- string
- rescue Iconv::Failure => e
- raise GeneratorError, "Caught #{e.class}: #{e}"
- end
- module_function :utf8_to_json
-
- module Pure
- module Generator
- # This class is used to create State instances, that are use to hold data
- # while generating a JSON text from a a Ruby data structure.
- class State
- # Creates a State object from _opts_, which ought to be Hash to create
- # a new State instance configured by _opts_, something else to create
- # an unconfigured instance. If _opts_ is a State object, it is just
- # returned.
- def self.from_state(opts)
- case opts
- when self
- opts
- when Hash
- new(opts)
- else
- new
- end
- end
-
- # Instantiates a new State object, configured by _opts_.
- #
- # _opts_ can have the following keys:
- #
- # * *indent*: a string used to indent levels (default: ''),
- # * *space*: a string that is put after, a : or , delimiter (default: ''),
- # * *space_before*: a string that is put before a : pair delimiter (default: ''),
- # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
- # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
- # * *check_circular*: true if checking for circular data structures
- # should be done (the default), false otherwise.
- # * *check_circular*: true if checking for circular data structures
- # should be done, false (the default) otherwise.
- # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
- # generated, otherwise an exception is thrown, if these values are
- # encountered. This options defaults to false.
- def initialize(opts = {})
- @seen = {}
- @indent = ''
- @space = ''
- @space_before = ''
- @object_nl = ''
- @array_nl = ''
- @check_circular = true
- @allow_nan = false
- configure opts
- end
-
- # This string is used to indent levels in the JSON text.
- attr_accessor :indent
-
- # This string is used to insert a space between the tokens in a JSON
- # string.
- attr_accessor :space
-
- # This string is used to insert a space before the ':' in JSON objects.
- attr_accessor :space_before
-
- # This string is put at the end of a line that holds a JSON object (or
- # Hash).
- attr_accessor :object_nl
-
- # This string is put at the end of a line that holds a JSON array.
- attr_accessor :array_nl
-
- # This integer returns the maximum level of data structure nesting in
- # the generated JSON, max_nesting = 0 if no maximum is checked.
- attr_accessor :max_nesting
-
- def check_max_nesting(depth) # :nodoc:
- return if @max_nesting.zero?
- current_nesting = depth + 1
- current_nesting > @max_nesting and
- raise NestingError, "nesting of #{current_nesting} is too deep"
- end
-
- # Returns true, if circular data structures should be checked,
- # otherwise returns false.
- def check_circular?
- @check_circular
- end
-
- # Returns true if NaN, Infinity, and -Infinity should be considered as
- # valid JSON and output.
- def allow_nan?
- @allow_nan
- end
-
- # Returns _true_, if _object_ was already seen during this generating
- # run.
- def seen?(object)
- @seen.key?(object.__id__)
- end
-
- # Remember _object_, to find out if it was already encountered (if a
- # cyclic data structure is if a cyclic data structure is rendered).
- def remember(object)
- @seen[object.__id__] = true
- end
-
- # Forget _object_ for this generating run.
- def forget(object)
- @seen.delete object.__id__
- end
-
- # Configure this State instance with the Hash _opts_, and return
- # itself.
- def configure(opts)
- @indent = opts[:indent] if opts.key?(:indent)
- @space = opts[:space] if opts.key?(:space)
- @space_before = opts[:space_before] if opts.key?(:space_before)
- @object_nl = opts[:object_nl] if opts.key?(:object_nl)
- @array_nl = opts[:array_nl] if opts.key?(:array_nl)
- @check_circular = !!opts[:check_circular] if opts.key?(:check_circular)
- @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
- if !opts.key?(:max_nesting) # defaults to 19
- @max_nesting = 19
- elsif opts[:max_nesting]
- @max_nesting = opts[:max_nesting]
- else
- @max_nesting = 0
- end
- self
- end
-
- # Returns the configuration instance variables as a hash, that can be
- # passed to the configure method.
- def to_h
- result = {}
- for iv in %w[indent space space_before object_nl array_nl check_circular allow_nan max_nesting]
- result[iv.intern] = instance_variable_get("@#{iv}")
- end
- result
- end
- end
-
- module GeneratorMethods
- module Object
- # Converts this object to a string (calling #to_s), converts
- # it to a JSON string, and returns the result. This is a fallback, if no
- # special method #to_json was defined for some object.
- def to_json(*) to_s.to_json end
- end
-
- module Hash
- # Returns a JSON string containing a JSON object, that is unparsed from
- # this Hash instance.
- # _state_ is a JSON::State object, that can also be used to configure the
- # produced JSON string output further.
- # _depth_ is used to find out nesting depth, to indent accordingly.
- def to_json(state = nil, depth = 0, *)
- if state
- state = JSON.state.from_state(state)
- state.check_max_nesting(depth)
- json_check_circular(state) { json_transform(state, depth) }
- else
- json_transform(state, depth)
- end
- end
-
- private
-
- def json_check_circular(state)
- if state and state.check_circular?
- state.seen?(self) and raise JSON::CircularDatastructure,
- "circular data structures not supported!"
- state.remember self
- end
- yield
- ensure
- state and state.forget self
- end
-
- def json_shift(state, depth)
- state and not state.object_nl.empty? or return ''
- state.indent * depth
- end
-
- def json_transform(state, depth)
- delim = ','
- delim << state.object_nl if state
- result = '{'
- result << state.object_nl if state
- result << map { |key,value|
- s = json_shift(state, depth + 1)
- s << key.to_s.to_json(state, depth + 1)
- s << state.space_before if state
- s << ':'
- s << state.space if state
- s << value.to_json(state, depth + 1)
- }.join(delim)
- result << state.object_nl if state
- result << json_shift(state, depth)
- result << '}'
- result
- end
- end
-
- module Array
- # Returns a JSON string containing a JSON array, that is unparsed from
- # this Array instance.
- # _state_ is a JSON::State object, that can also be used to configure the
- # produced JSON string output further.
- # _depth_ is used to find out nesting depth, to indent accordingly.
- def to_json(state = nil, depth = 0, *)
- if state
- state = JSON.state.from_state(state)
- state.check_max_nesting(depth)
- json_check_circular(state) { json_transform(state, depth) }
- else
- json_transform(state, depth)
- end
- end
-
- private
-
- def json_check_circular(state)
- if state and state.check_circular?
- state.seen?(self) and raise JSON::CircularDatastructure,
- "circular data structures not supported!"
- state.remember self
- end
- yield
- ensure
- state and state.forget self
- end
-
- def json_shift(state, depth)
- state and not state.array_nl.empty? or return ''
- state.indent * depth
- end
-
- def json_transform(state, depth)
- delim = ','
- delim << state.array_nl if state
- result = '['
- result << state.array_nl if state
- result << map { |value|
- json_shift(state, depth + 1) << value.to_json(state, depth + 1)
- }.join(delim)
- result << state.array_nl if state
- result << json_shift(state, depth)
- result << ']'
- result
- end
- end
-
- module Integer
- # Returns a JSON string representation for this Integer number.
- def to_json(*) to_s end
- end
-
- module Float
- # Returns a JSON string representation for this Float number.
- def to_json(state = nil, *)
- case
- when infinite?
- if !state || state.allow_nan?
- to_s
- else
- raise GeneratorError, "#{self} not allowed in JSON"
- end
- when nan?
- if !state || state.allow_nan?
- to_s
- else
- raise GeneratorError, "#{self} not allowed in JSON"
- end
- else
- to_s
- end
- end
- end
-
- module String
- # This string should be encoded with UTF-8 A call to this method
- # returns a JSON string encoded with UTF16 big endian characters as
- # \u????.
- def to_json(*)
- '"' << JSON.utf8_to_json(self) << '"'
- end
-
- # Module that holds the extinding methods if, the String module is
- # included.
- module Extend
- # Raw Strings are JSON Objects (the raw bytes are stored in an array for the
- # key "raw"). The Ruby String can be created by this module method.
- def json_create(o)
- o['raw'].pack('C*')
- end
- end
-
- # Extends _modul_ with the String::Extend module.
- def self.included(modul)
- modul.extend Extend
- end
-
- # This method creates a raw object hash, that can be nested into
- # other data structures and will be unparsed as a raw string. This
- # method should be used, if you want to convert raw strings to JSON
- # instead of UTF-8 strings, e. g. binary data.
- def to_json_raw_object
- {
- JSON.create_id => self.class.name,
- 'raw' => self.unpack('C*'),
- }
- end
-
- # This method creates a JSON text from the result of
- # a call to to_json_raw_object of this String.
- def to_json_raw(*args)
- to_json_raw_object.to_json(*args)
- end
- end
-
- module TrueClass
- # Returns a JSON string for true: 'true'.
- def to_json(*) 'true' end
- end
-
- module FalseClass
- # Returns a JSON string for false: 'false'.
- def to_json(*) 'false' end
- end
-
- module NilClass
- # Returns a JSON string for nil: 'null'.
- def to_json(*) 'null' end
- end
- end
- end
- end
-end
diff --git a/ext/json/lib/json/pure/parser.rb b/ext/json/lib/json/pure/parser.rb
deleted file mode 100644
index e886ba8d2c..0000000000
--- a/ext/json/lib/json/pure/parser.rb
+++ /dev/null
@@ -1,259 +0,0 @@
-require 'strscan'
-
-module JSON
- module Pure
- # This class implements the JSON parser that is used to parse a JSON string
- # into a Ruby data structure.
- class Parser < StringScanner
- STRING = /" ((?:[^\x0-\x1f"\\] |
- \\["\\\/bfnrt] |
- \\u[0-9a-fA-F]{4} |
- \\[\x20-\xff])*)
- "/nx
- INTEGER = /(-?0|-?[1-9]\d*)/
- FLOAT = /(-?
- (?:0|[1-9]\d*)
- (?:
- \.\d+(?i:e[+-]?\d+) |
- \.\d+ |
- (?i:e[+-]?\d+)
- )
- )/x
- NAN = /NaN/
- INFINITY = /Infinity/
- MINUS_INFINITY = /-Infinity/
- OBJECT_OPEN = /\{/
- OBJECT_CLOSE = /\}/
- ARRAY_OPEN = /\[/
- ARRAY_CLOSE = /\]/
- PAIR_DELIMITER = /:/
- COLLECTION_DELIMITER = /,/
- TRUE = /true/
- FALSE = /false/
- NULL = /null/
- IGNORE = %r(
- (?:
- //[^\n\r]*[\n\r]| # line comments
- /\* # c-style comments
- (?:
- [^*/]| # normal chars
- /[^*]| # slashes that do not start a nested comment
- \*[^/]| # asterisks that do not end this comment
- /(?=\*/) # single slash before this comment's end
- )*
- \*/ # the End of this comment
- |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
- )+
- )mx
-
- UNPARSED = Object.new
-
- # Creates a new JSON::Pure::Parser instance for the string _source_.
- #
- # It will be configured by the _opts_ hash. _opts_ can have the following
- # keys:
- # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
- # structures. Disable depth checking with :max_nesting => false|nil|0,
- # it defaults to 19.
- # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
- # defiance of RFC 4627 to be parsed by the Parser. This option defaults
- # to false.
- # * *create_additions*: If set to false, the Parser doesn't create
- # additions even if a matchin class and create_id was found. This option
- # defaults to true.
- def initialize(source, opts = {})
- super
- if !opts.key?(:max_nesting) # defaults to 19
- @max_nesting = 19
- elsif opts[:max_nesting]
- @max_nesting = opts[:max_nesting]
- else
- @max_nesting = 0
- end
- @allow_nan = !!opts[:allow_nan]
- ca = true
- ca = opts[:create_additions] if opts.key?(:create_additions)
- @create_id = ca ? JSON.create_id : nil
- end
-
- alias source string
-
- # Parses the current JSON string _source_ and returns the complete data
- # structure as a result.
- def parse
- reset
- obj = nil
- until eos?
- case
- when scan(OBJECT_OPEN)
- obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
- @current_nesting = 1
- obj = parse_object
- when scan(ARRAY_OPEN)
- obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
- @current_nesting = 1
- obj = parse_array
- when skip(IGNORE)
- ;
- else
- raise ParserError, "source '#{peek(20)}' not in JSON!"
- end
- end
- obj or raise ParserError, "source did not contain any JSON!"
- obj
- end
-
- private
-
- # Unescape characters in strings.
- UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
- UNESCAPE_MAP.update({
- ?" => '"',
- ?\\ => '\\',
- ?/ => '/',
- ?b => "\b",
- ?f => "\f",
- ?n => "\n",
- ?r => "\r",
- ?t => "\t",
- ?u => nil,
- })
-
- def parse_string
- if scan(STRING)
- return '' if self[1].empty?
- self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
- if u = UNESCAPE_MAP[c[1]]
- u
- else # \uXXXX
- bytes = ''
- i = 0
- while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
- bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
- i += 1
- end
- JSON::UTF16toUTF8.iconv(bytes)
- end
- end
- else
- UNPARSED
- end
- rescue Iconv::Failure => e
- raise GeneratorError, "Caught #{e.class}: #{e}"
- end
-
- def parse_value
- case
- when scan(FLOAT)
- Float(self[1])
- when scan(INTEGER)
- Integer(self[1])
- when scan(TRUE)
- true
- when scan(FALSE)
- false
- when scan(NULL)
- nil
- when (string = parse_string) != UNPARSED
- string
- when scan(ARRAY_OPEN)
- @current_nesting += 1
- ary = parse_array
- @current_nesting -= 1
- ary
- when scan(OBJECT_OPEN)
- @current_nesting += 1
- obj = parse_object
- @current_nesting -= 1
- obj
- when @allow_nan && scan(NAN)
- NaN
- when @allow_nan && scan(INFINITY)
- Infinity
- when @allow_nan && scan(MINUS_INFINITY)
- MinusInfinity
- else
- UNPARSED
- end
- end
-
- def parse_array
- raise NestingError, "nesting of #@current_nesting is to deep" if
- @max_nesting.nonzero? && @current_nesting > @max_nesting
- result = []
- delim = false
- until eos?
- case
- when (value = parse_value) != UNPARSED
- delim = false
- result << value
- skip(IGNORE)
- if scan(COLLECTION_DELIMITER)
- delim = true
- elsif match?(ARRAY_CLOSE)
- ;
- else
- raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
- end
- when scan(ARRAY_CLOSE)
- if delim
- raise ParserError, "expected next element in array at '#{peek(20)}'!"
- end
- break
- when skip(IGNORE)
- ;
- else
- raise ParserError, "unexpected token in array at '#{peek(20)}'!"
- end
- end
- result
- end
-
- def parse_object
- raise NestingError, "nesting of #@current_nesting is to deep" if
- @max_nesting.nonzero? && @current_nesting > @max_nesting
- result = {}
- delim = false
- until eos?
- case
- when (string = parse_string) != UNPARSED
- skip(IGNORE)
- unless scan(PAIR_DELIMITER)
- raise ParserError, "expected ':' in object at '#{peek(20)}'!"
- end
- skip(IGNORE)
- unless (value = parse_value).equal? UNPARSED
- result[string] = value
- delim = false
- skip(IGNORE)
- if scan(COLLECTION_DELIMITER)
- delim = true
- elsif match?(OBJECT_CLOSE)
- ;
- else
- raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
- end
- else
- raise ParserError, "expected value in object at '#{peek(20)}'!"
- end
- when scan(OBJECT_CLOSE)
- if delim
- raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
- end
- if @create_id and klassname = result[@create_id]
- klass = JSON.deep_const_get klassname
- break unless klass and klass.json_creatable?
- result = klass.json_create(result)
- end
- break
- when skip(IGNORE)
- ;
- else
- raise ParserError, "unexpected token in object at '#{peek(20)}'!"
- end
- end
- result
- end
- end
- end
-end
diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb
deleted file mode 100644
index 3d674ac44f..0000000000
--- a/ext/json/lib/json/version.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module JSON
- # JSON version
- VERSION = '1.1.2'
- VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
- VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
- VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
- VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
- VARIANT_BINARY = false
-end
diff --git a/ext/nkf/.cvsignore b/ext/nkf/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/nkf/.cvsignore
+++ b/ext/nkf/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
index 2f22e32aad..4ffe8d984e 100644
--- a/ext/nkf/lib/kconv.rb
+++ b/ext/nkf/lib/kconv.rb
@@ -18,9 +18,9 @@ module Kconv
#
# Public Constants
#
-
+
#Constant of Encoding
-
+
# Auto-Detect
AUTO = NKF::AUTO
# ISO-2022-JP
@@ -45,10 +45,12 @@ module Kconv
UNKNOWN = NKF::UNKNOWN
#
- #
# Private Constants
#
+ # Revision of kconv.rb
+ REVISION = %q$Revision$
+
#Regexp of Encoding
# Regexp of Shift_JIS string (private constant)
@@ -81,14 +83,46 @@ module Kconv
#
# call-seq:
- # Kconv.kconv(str, to_enc, from_enc=nil)
+ # Kconv.kconv(str, out_code, in_code = Kconv::AUTO)
#
# Convert <code>str</code> to out_code.
# <code>out_code</code> and <code>in_code</code> are given as constants of Kconv.
- def kconv(str, to_enc, from_enc=nil)
- opt = ''
- opt += ' --ic=' + from_enc.to_s if from_enc
- opt += ' --oc=' + to_enc.to_s if to_enc
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want to decode them, use NKF.nkf.
+ def kconv(str, out_code, in_code = AUTO)
+ opt = '-'
+ case in_code
+ when ::NKF::JIS
+ opt << 'J'
+ when ::NKF::EUC
+ opt << 'E'
+ when ::NKF::SJIS
+ opt << 'S'
+ when ::NKF::UTF8
+ opt << 'W'
+ when ::NKF::UTF16
+ opt << 'W16'
+ end
+
+ case out_code
+ when ::NKF::JIS
+ opt << 'j'
+ when ::NKF::EUC
+ opt << 'e'
+ when ::NKF::SJIS
+ opt << 's'
+ when ::NKF::UTF8
+ opt << 'w'
+ when ::NKF::UTF16
+ opt << 'w16'
+ when ::NKF::NOCONV
+ return str
+ end
+
+ opt = '' if opt == '-'
::NKF::nkf(opt, str)
end
@@ -102,8 +136,13 @@ module Kconv
# Kconv.tojis(str) -> string
#
# Convert <code>str</code> to ISO-2022-JP
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-jxm0', str).
def tojis(str)
- kconv(str, JIS)
+ ::NKF::nkf('-jm', str)
end
module_function :tojis
@@ -111,8 +150,13 @@ module Kconv
# Kconv.toeuc(str) -> string
#
# Convert <code>str</code> to EUC-JP
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-exm0', str).
def toeuc(str)
- kconv(str, EUC)
+ ::NKF::nkf('-em', str)
end
module_function :toeuc
@@ -120,8 +164,13 @@ module Kconv
# Kconv.tosjis(str) -> string
#
# Convert <code>str</code> to Shift_JIS
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-sxm0', str).
def tosjis(str)
- kconv(str, SJIS)
+ ::NKF::nkf('-sm', str)
end
module_function :tosjis
@@ -129,8 +178,13 @@ module Kconv
# Kconv.toutf8(str) -> string
#
# Convert <code>str</code> to UTF-8
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-wxm0', str).
def toutf8(str)
- kconv(str, UTF8)
+ ::NKF::nkf('-wm', str)
end
module_function :toutf8
@@ -138,20 +192,16 @@ module Kconv
# Kconv.toutf16(str) -> string
#
# Convert <code>str</code> to UTF-16
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-w16xm0', str).
def toutf16(str)
- kconv(str, UTF16)
+ ::NKF::nkf('-w16m', str)
end
module_function :toutf16
- # call-seq:
- # Kconv.toutf32(str) -> string
- #
- # Convert <code>str</code> to UTF-32
- def toutf32(str)
- kconv(str, UTF32)
- end
- module_function :toutf32
-
#
# guess
#
@@ -159,12 +209,21 @@ module Kconv
# call-seq:
# Kconv.guess(str) -> integer
#
- # Guess input encoding by NKF.guess
+ # Guess input encoding by NKF.guess2
def guess(str)
::NKF::guess(str)
end
module_function :guess
+ # call-seq:
+ # Kconv.guess_old(str) -> integer
+ #
+ # Guess input encoding by NKF.guess1
+ def guess_old(str)
+ ::NKF::guess1(str)
+ end
+ module_function :guess_old
+
#
# isEncoding
#
@@ -206,13 +265,17 @@ end
class String
# call-seq:
- # String#kconv(to_enc, from_enc)
+ # String#kconv(out_code, in_code = Kconv::AUTO)
#
# Convert <code>self</code> to out_code.
# <code>out_code</code> and <code>in_code</code> are given as constants of Kconv.
- def kconv(to_enc, from_enc=nil)
- form_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0]
- Kconv::kconv(self, to_enc, from_enc)
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want to decode them, use NKF.nkf.
+ def kconv(out_code, in_code=Kconv::AUTO)
+ Kconv::kconv(self, out_code, in_code)
end
#
@@ -223,37 +286,56 @@ class String
# String#tojis -> string
#
# Convert <code>self</code> to ISO-2022-JP
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-jxm0', str).
def tojis; Kconv.tojis(self) end
# call-seq:
# String#toeuc -> string
#
# Convert <code>self</code> to EUC-JP
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-exm0', str).
def toeuc; Kconv.toeuc(self) end
# call-seq:
# String#tosjis -> string
#
# Convert <code>self</code> to Shift_JIS
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-sxm0', str).
def tosjis; Kconv.tosjis(self) end
# call-seq:
# String#toutf8 -> string
#
# Convert <code>self</code> to UTF-8
+ #
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-wxm0', str).
def toutf8; Kconv.toutf8(self) end
# call-seq:
# String#toutf16 -> string
#
# Convert <code>self</code> to UTF-16
- def toutf16; Kconv.toutf16(self) end
-
- # call-seq:
- # String#toutf32 -> string
#
- # Convert <code>self</code> to UTF-32
- def toutf32; Kconv.toutf32(self) end
+ # *Note*
+ # This method decode MIME encoded string and
+ # convert halfwidth katakana to fullwidth katakana.
+ # If you don't want it, use NKF.nkf('-w16xm0', str).
+ def toutf16; Kconv.toutf16(self) end
#
# is Encoding
diff --git a/ext/nkf/nkf-utf8/config.h b/ext/nkf/nkf-utf8/config.h
index 1fa74afd40..9da82c6aee 100644
--- a/ext/nkf/nkf-utf8/config.h
+++ b/ext/nkf/nkf-utf8/config.h
@@ -59,10 +59,10 @@ typedef int nkf_nfchar;
/******************************/
/* $B%G%U%)%k%H$N=PNO%3!<%IA*Br(B */
/* Select DEFAULT_CODE */
-/* #define DEFAULT_CODE_JIS */
+#define DEFAULT_CODE_JIS
/* #define DEFAULT_CODE_SJIS */
/* #define DEFAULT_CODE_EUC */
-#define DEFAULT_CODE_UTF8
+/* #define DEFAULT_CODE_UTF8 */
/******************************/
#else
#define DEFAULT_CODE_SJIS
@@ -85,7 +85,4 @@ struct normalization_pair{
};
#endif
-#define MIME_DECODE_DEFAULT 0
-#define X0201_DEFAULT 0
-
#endif /* _CONFIG_H_ */
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
index 66f01896d6..3cd1b160da 100644
--- a/ext/nkf/nkf-utf8/nkf.c
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -1,7 +1,7 @@
/** Network Kanji Filter. (PDS Version)
************************************************************************
** Copyright (C) 1987, Fujitsu LTD. (Itaru ICHIKAWA)
-** $BO"Mm@h!'(B $B!J3t!KIY;NDL8&5f=j!!%=%U%H#38&!!;T@n!!;j(B
+** $BO"Mm@h!'(B $B!J3t!KIY;NDL8&5f=j!!%=%U%H#38&!!;T@n!!;j(B
** $B!J(BE-Mail Address: ichikawa@flab.fujitsu.co.jp$B!K(B
** Copyright (C) 1996,1998
** Copyright (C) 2002
@@ -17,66 +17,85 @@
** $B%P%$%J%j$NG[I[$N:]$K$O(Bversion message$B$rJ]B8$9$k$3$H$r>r7o$H$7$^$9!#(B
** $B$3$N%W%m%0%i%`$K$D$$$F$OFC$K2?$NJ]>Z$b$7$J$$!"0-$7$+$i$:!#(B
**
-** Everyone is permitted to do anything on this program
+** Everyone is permitted to do anything on this program
** including copying, modifying, improving,
** as long as you don't try to pretend that you wrote it.
-** i.e., the above copyright notice has to appear in all copies.
+** i.e., the above copyright notice has to appear in all copies.
** Binary distribution requires original version messages.
** You don't have to ask before copying, redistribution or publishing.
** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
***********************************************************************/
/***********************************************************************
- * $B8=:_!"(Bnkf $B$O(B SorceForge $B$K$F%a%s%F%J%s%9$,B3$1$i$l$F$$$^$9!#(B
- * http://sourceforge.jp/projects/nkf/
+** UTF-8 $B%5%]!<%H$K$D$$$F(B
+** $B=>Mh$N(B nkf $B$HF~$l$+$($F$=$N$^$^;H$($k$h$&$K$J$C$F$$$^$9(B
+** nkf -e $B$J$I$H$7$F5/F0$9$k$H!"<+F0H=JL$G(B UTF-8 $B$HH=Dj$5$l$l$P!"(B
+** $B$=$N$^$^(B euc-jp $B$KJQ49$5$l$^$9(B
+**
+** $B$^$@%P%0$,$"$k2DG=@-$,9b$$$G$9!#(B
+** ($BFC$K<+F0H=JL!"%3!<%I:.:_!"%(%i!<=hM}7O(B)
+**
+** $B2?$+LdBj$r8+$D$1$?$i!"(B
+** E-Mail: furukawa@tcp-ip.or.jp
+** $B$^$G8fO"Mm$r$*4j$$$7$^$9!#(B
***********************************************************************/
/* $Id$ */
#define NKF_VERSION "2.0.8"
-#define NKF_RELEASE_DATE "2007-12-23"
-#define COPY_RIGHT \
- "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW\n" \
- "Copyright (C) 2002-2007 Kono, Furukawa, Naruse, mastodon"
-
+#define NKF_RELEASE_DATE "2007-01-28"
#include "config.h"
#include "utf8tbl.h"
-#if defined(DEFAULT_CODE_JIS)
-#elif defined(DEFAULT_CODE_SJIS)
-#elif defined(DEFAULT_CODE_EUC)
-#elif defined(DEFAULT_CODE_UTF8)
-#else
-#define DEFAULT_CODE_JIS 1
-#endif
+#define COPY_RIGHT \
+ "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW\n" \
+ "Copyright (C) 2002-2006 Kono, Furukawa, Naruse, mastodon"
-#ifndef MIME_DECODE_DEFAULT
-#define MIME_DECODE_DEFAULT STRICT_MIME
-#endif
-#ifndef X0201_DEFAULT
-#define X0201_DEFAULT TRUE
-#endif
-#if DEFAULT_NEWLINE == 0x0D0A
-#define PUT_NEWLINE(func) do {\
- func(0x0D);\
- func(0x0A);\
-} while (0)
-#define OCONV_NEWLINE(func) do {\
- func(0, 0x0D);\
- func(0, 0x0A);\
-} while (0)
-#elif DEFAULT_NEWLINE == 0x0D
-#define PUT_NEWLINE(func) func(0x0D)
-#define OCONV_NEWLINE(func) func(0, 0x0D)
-#else
-#define DEFAULT_NEWLINE 0x0A
-#define PUT_NEWLINE(func) func(0x0A)
-#define OCONV_NEWLINE(func) func(0, 0x0A)
-#endif
-#ifdef HELP_OUTPUT_STDERR
-#define HELP_OUTPUT stderr
-#else
-#define HELP_OUTPUT stdout
-#endif
+/*
+**
+**
+**
+** USAGE: nkf [flags] [file]
+**
+** Flags:
+** b Output is buffered (DEFAULT)
+** u Output is unbuffered
+**
+** t no operation
+**
+** j Output code is JIS 7 bit (DEFAULT SELECT)
+** s Output code is MS Kanji (DEFAULT SELECT)
+** e Output code is AT&T JIS (DEFAULT SELECT)
+** w Output code is AT&T JIS (DEFAULT SELECT)
+** l Output code is JIS 7bit and ISO8859-1 Latin-1
+**
+** m MIME conversion for ISO-2022-JP
+** I Convert non ISO-2022-JP charactor to GETA by Pekoe <pekoe@lair.net>
+** i_ Output sequence to designate JIS-kanji (DEFAULT_J)
+** o_ Output sequence to designate single-byte roman characters (DEFAULT_R)
+** M MIME output conversion
+**
+** r {de/en}crypt ROT13/47
+**
+** v display Version
+**
+** T Text mode output (for MS-DOS)
+**
+** x Do not convert X0201 kana into X0208
+** Z Convert X0208 alphabet to ASCII
+**
+** f60 fold option
+**
+** m MIME decode
+** B try to fix broken JIS, missing Escape
+** B[1-9] broken level
+**
+** O Output to 'nkf.out' file or last file name
+** d Delete \r in line feed
+** c Add \r in line feed
+** -- other long option
+** -- ignore following option (don't use with -O )
+**
+**/
#if (defined(__TURBOC__) || defined(_MSC_VER) || defined(LSI_C) || defined(__MINGW32__) || defined(__EMX__) || defined(__MSDOS__) || defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)) && !defined(MSDOS)
#define MSDOS
@@ -177,32 +196,45 @@ void djgpp_setbinmode(FILE *fp)
#define FALSE 0
#define TRUE 1
-/* state of output_mode and input_mode
+/* state of output_mode and input_mode
c2 0 means ASCII
- JIS_X_0201
- ISO_8859_1
- JIS_X_0208
+ X0201
+ ISO8859_1
+ X0208
EOF all termination
c1 32bit data
*/
+#define ASCII 0
+#define X0208 1
+#define X0201 2
+#define ISO8859_1 8
+#define NO_X0201 3
+#define X0212 0x2844
+#define X0213_1 0x284F
+#define X0213_2 0x2850
+
/* Input Assumption */
#define JIS_INPUT 4
#define EUC_INPUT 16
#define SJIS_INPUT 5
#define LATIN1_INPUT 6
-#define UTF8_INPUT 13
-#define UTF16_INPUT 1015
-#define UTF32_INPUT 1017
-
#define FIXED_MIME 7
#define STRICT_MIME 8
/* MIME ENCODE */
+#define ISO2022JP 9
+#define JAPANESE_EUC 10
+#define SHIFT_JIS 11
+
+#define UTF8 12
+#define UTF8_INPUT 13
+#define UTF16_INPUT 1015
+#define UTF32_INPUT 1017
/* byte order */
@@ -211,14 +243,16 @@ void djgpp_setbinmode(FILE *fp)
#define ENDIAN_2143 2143
#define ENDIAN_3412 3412
+#define WISH_TRUE 15
+
/* ASCII CODE */
#define BS 0x08
#define TAB 0x09
-#define LF 0x0a
+#define NL 0x0a
#define CR 0x0d
#define ESC 0x1b
-#define SP 0x20
+#define SPACE 0x20
#define AT 0x40
#define SSP 0xa0
#define DEL 0x7f
@@ -226,181 +260,6 @@ void djgpp_setbinmode(FILE *fp)
#define SO 0x0e
#define SSO 0x8e
#define SS3 0x8f
-#define CRLF 0x0D0A
-
-
-/* encodings */
-
-enum nkf_encodings {
- ASCII,
- ISO_8859_1,
- ISO_2022_JP,
- CP50220,
- CP50221,
- CP50222,
- ISO_2022_JP_1,
- ISO_2022_JP_3,
- SHIFT_JIS,
- WINDOWS_31J,
- CP10001,
- EUC_JP,
- CP51932,
- EUCJP_MS,
- EUCJP_ASCII,
- SHIFT_JISX0213,
- SHIFT_JIS_2004,
- EUC_JISX0213,
- EUC_JIS_2004,
- UTF_8,
- UTF_8N,
- UTF_8_BOM,
- UTF8_MAC,
- UTF_16,
- UTF_16BE,
- UTF_16BE_BOM,
- UTF_16LE,
- UTF_16LE_BOM,
- UTF_32,
- UTF_32BE,
- UTF_32BE_BOM,
- UTF_32LE,
- UTF_32LE_BOM,
- JIS_X_0201=0x1000,
- JIS_X_0208,
- JIS_X_0212,
- JIS_X_0213_1,
- JIS_X_0213_2,
- BINARY
-};
-
-nkf_char s_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
-nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
-nkf_char w_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
-nkf_char w_iconv16(nkf_char c2, nkf_char c1, nkf_char c0);
-nkf_char w_iconv32(nkf_char c2, nkf_char c1, nkf_char c0);
-void j_oconv(nkf_char c2, nkf_char c1);
-void s_oconv(nkf_char c2, nkf_char c1);
-void e_oconv(nkf_char c2, nkf_char c1);
-void w_oconv(nkf_char c2, nkf_char c1);
-void w_oconv16(nkf_char c2, nkf_char c1);
-void w_oconv32(nkf_char c2, nkf_char c1);
-
-typedef struct {
- char *name;
- nkf_char (*iconv_func)(nkf_char c2, nkf_char c1, nkf_char c0);
- void (*oconv_func)(nkf_char c2, nkf_char c1);
-} nkf_native_encoding;
-
-nkf_native_encoding NkfEncodingASCII = { "US_ASCII", e_iconv, e_oconv };
-nkf_native_encoding NkfEncodingISO_2022_JP = { "ISO-2022-JP", e_iconv, j_oconv };
-nkf_native_encoding NkfEncodingShift_JIS = { "Shift_JIS", s_iconv, s_oconv };
-nkf_native_encoding NkfEncodingEUC_JP = { "EUC-JP", e_iconv, e_oconv };
-nkf_native_encoding NkfEncodingUTF_8 = { "UTF-8", w_iconv, w_oconv };
-nkf_native_encoding NkfEncodingUTF_16 = { "UTF-16", w_iconv16, w_oconv16 };
-nkf_native_encoding NkfEncodingUTF_32 = { "UTF-32", w_iconv32, w_oconv32 };
-
-typedef struct {
- int id;
- char *name;
- nkf_native_encoding *based_encoding;
-} nkf_encoding;
-nkf_encoding nkf_encoding_table[] = {
- {ASCII, "ASCII", &NkfEncodingASCII},
- {ISO_8859_1, "ISO-8859-1", &NkfEncodingASCII},
- {ISO_2022_JP, "ISO-2022-JP", &NkfEncodingASCII},
- {CP50220, "CP50220", &NkfEncodingISO_2022_JP},
- {CP50221, "CP50221", &NkfEncodingISO_2022_JP},
- {CP50222, "CP50222", &NkfEncodingISO_2022_JP},
- {ISO_2022_JP_1, "ISO-2022-JP-1", &NkfEncodingISO_2022_JP},
- {ISO_2022_JP_3, "ISO-2022-JP-3", &NkfEncodingISO_2022_JP},
- {SHIFT_JIS, "Shift_JIS", &NkfEncodingShift_JIS},
- {WINDOWS_31J, "WINDOWS-31J", &NkfEncodingShift_JIS},
- {CP10001, "CP10001", &NkfEncodingShift_JIS},
- {EUC_JP, "EUC-JP", &NkfEncodingEUC_JP},
- {CP51932, "CP51932", &NkfEncodingEUC_JP},
- {EUCJP_MS, "eucJP-MS", &NkfEncodingEUC_JP},
- {EUCJP_ASCII, "eucJP-ASCII", &NkfEncodingEUC_JP},
- {SHIFT_JISX0213, "Shift_JISX0213", &NkfEncodingShift_JIS},
- {SHIFT_JIS_2004, "Shift_JIS-2004", &NkfEncodingShift_JIS},
- {EUC_JISX0213, "EUC-JISX0213", &NkfEncodingEUC_JP},
- {EUC_JIS_2004, "EUC-JIS-2004", &NkfEncodingEUC_JP},
- {UTF_8, "UTF-8", &NkfEncodingUTF_8},
- {UTF_8N, "UTF-8N", &NkfEncodingUTF_8},
- {UTF_8_BOM, "UTF-8-BOM", &NkfEncodingUTF_8},
- {UTF8_MAC, "UTF8-MAC", &NkfEncodingUTF_8},
- {UTF_16, "UTF-16", &NkfEncodingUTF_16},
- {UTF_16BE, "UTF-16BE", &NkfEncodingUTF_16},
- {UTF_16BE_BOM, "UTF-16BE-BOM", &NkfEncodingUTF_16},
- {UTF_16LE, "UTF-16LE", &NkfEncodingUTF_16},
- {UTF_16LE_BOM, "UTF-16LE-BOM", &NkfEncodingUTF_16},
- {UTF_32, "UTF-32", &NkfEncodingUTF_32},
- {UTF_32BE, "UTF-32BE", &NkfEncodingUTF_32},
- {UTF_32BE_BOM, "UTF-32BE-BOM", &NkfEncodingUTF_32},
- {UTF_32LE, "UTF-32LE", &NkfEncodingUTF_32},
- {UTF_32LE_BOM, "UTF-32LE-BOM", &NkfEncodingUTF_32},
- {BINARY, "BINARY", &NkfEncodingASCII},
- {-1, NULL, NULL}
-};
-#define NKF_ENCODING_TABLE_SIZE 34
-struct {
- const char *name;
- const int id;
-} encoding_name_to_id_table[] = {
- {"ASCII", ASCII},
- {"ISO-2022-JP", ISO_2022_JP},
- {"X-ISO2022JP-CP932", CP50220},
- {"CP50220", CP50220},
- {"CP50221", CP50221},
- {"CP50222", CP50222},
- {"ISO-2022-JP-1", ISO_2022_JP_1},
- {"ISO-2022-JP-3", ISO_2022_JP_3},
- {"SHIFT_JIS", SHIFT_JIS},
- {"SJIS", SHIFT_JIS},
- {"WINDOWS-31J", WINDOWS_31J},
- {"CSWINDOWS31J", WINDOWS_31J},
- {"CP932", WINDOWS_31J},
- {"MS932", WINDOWS_31J},
- {"CP10001", CP10001},
- {"EUCJP", EUC_JP},
- {"EUC-JP", EUC_JP},
- {"CP51932", CP51932},
- {"EUC-JP-MS", EUCJP_MS},
- {"EUCJP-MS", EUCJP_MS},
- {"EUCJPMS", EUCJP_MS},
- {"EUC-JP-ASCII", EUCJP_ASCII},
- {"EUCJP-ASCII", EUCJP_ASCII},
- {"SHIFT_JISX0213", SHIFT_JISX0213},
- {"SHIFT_JIS-2004", SHIFT_JIS_2004},
- {"EUC-JISX0213", EUC_JISX0213},
- {"EUC-JIS-2004", EUC_JIS_2004},
- {"UTF-8", UTF_8},
- {"UTF-8N", UTF_8N},
- {"UTF-8-BOM", UTF_8_BOM},
- {"UTF8-MAC", UTF8_MAC},
- {"UTF-8-MAC", UTF8_MAC},
- {"UTF-16", UTF_16},
- {"UTF-16BE", UTF_16BE},
- {"UTF-16BE-BOM", UTF_16BE_BOM},
- {"UTF-16LE", UTF_16LE},
- {"UTF-16LE-BOM", UTF_16LE_BOM},
- {"UTF-32", UTF_32},
- {"UTF-32BE", UTF_32BE},
- {"UTF-32BE-BOM", UTF_32BE_BOM},
- {"UTF-32LE", UTF_32LE},
- {"UTF-32LE-BOM", UTF_32LE_BOM},
- {"BINARY", BINARY},
- {NULL, -1}
-};
-#if defined(DEFAULT_CODE_JIS)
-#define DEFAULT_ENCODING ISO_2022_JP
-#elif defined(DEFAULT_CODE_SJIS)
-#define DEFAULT_ENCODING SHIFT_JIS
-#elif defined(DEFAULT_CODE_EUC)
-#define DEFAULT_ENCODING EUC_JP
-#elif defined(DEFAULT_CODE_UTF8)
-#define DEFAULT_ENCODING UTF_8
-#endif
-
#define is_alnum(c) \
(('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))
@@ -410,20 +269,16 @@ struct {
#define nkf_isoctal(c) ('0'<=c && c<='7')
#define nkf_isdigit(c) ('0'<=c && c<='9')
#define nkf_isxdigit(c) (nkf_isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c <= 'F'))
-#define nkf_isblank(c) (c == SP || c == TAB)
-#define nkf_isspace(c) (nkf_isblank(c) || c == CR || c == LF)
+#define nkf_isblank(c) (c == SPACE || c == TAB)
+#define nkf_isspace(c) (nkf_isblank(c) || c == CR || c == NL)
#define nkf_isalpha(c) (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
#define nkf_isalnum(c) (nkf_isdigit(c) || nkf_isalpha(c))
-#define nkf_isprint(c) (SP<=c && c<='~')
+#define nkf_isprint(c) (' '<=c && c<='~')
#define nkf_isgraph(c) ('!'<=c && c<='~')
#define hex2bin(c) (('0'<=c&&c<='9') ? (c-'0') : \
('A'<=c&&c<='F') ? (c-'A'+10) : \
- ('a'<=c&&c<='f') ? (c-'a'+10) : 0)
-#define bin2hex(c) ("0123456789ABCDEF"[c&15])
+ ('a'<=c&&c<='f') ? (c-'a'+10) : 0 )
#define is_eucg3(c2) (((unsigned short)c2 >> 8) == SS3)
-#define nkf_noescape_mime(c) ((c == CR) || (c == LF) || \
- ((c > SP) && (c < DEL) && (c != '?') && (c != '=') && (c != '_') \
- && (c != '(') && (c != ')') && (c != '.') && (c != 0x22)))
#define CP932_TABLE_BEGIN 0xFA
#define CP932_TABLE_END 0xFC
@@ -475,9 +330,11 @@ struct input_code{
int _file_stat;
};
-static char *input_codename = NULL; /* NULL: unestablished, "": BINARY */
-static nkf_encoding *output_encoding;
+static char *input_codename = "";
+#ifndef PERL_XS
+static const char *CopyRight = COPY_RIGHT;
+#endif
#if !defined(PERL_XS) && !defined(WIN32DLL)
static nkf_char noconvert(FILE *f);
#endif
@@ -486,18 +343,18 @@ static nkf_char kanji_convert(FILE *f);
static nkf_char h_conv(FILE *f,nkf_char c2,nkf_char c1);
static nkf_char push_hold_buf(nkf_char c2);
static void set_iconv(nkf_char f, nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_char c0));
+static nkf_char s_iconv(nkf_char c2,nkf_char c1,nkf_char c0);
static nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1);
+static nkf_char e_iconv(nkf_char c2,nkf_char c1,nkf_char c0);
#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
/* UCS Mapping
* 0: Shift_JIS, eucJP-ascii
* 1: eucJP-ms
* 2: CP932, CP51932
- * 3: CP10001
*/
-#define UCS_MAP_ASCII 0
-#define UCS_MAP_MS 1
-#define UCS_MAP_CP932 2
-#define UCS_MAP_CP10001 3
+#define UCS_MAP_ASCII 0
+#define UCS_MAP_MS 1
+#define UCS_MAP_CP932 2
static int ms_ucs_map_f = UCS_MAP_ASCII;
#endif
#ifdef UTF8_INPUT_ENABLE
@@ -515,6 +372,9 @@ static void encode_fallback_perl(nkf_char c);
static void encode_fallback_subchar(nkf_char c);
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);
@@ -526,10 +386,16 @@ static void w_status(struct input_code *, nkf_char);
static int output_bom_f = FALSE;
static int output_endian = ENDIAN_BIG;
static nkf_char e2w_conv(nkf_char c2,nkf_char c1);
+static void w_oconv(nkf_char c2,nkf_char c1);
+static void w_oconv16(nkf_char c2,nkf_char c1);
+static void w_oconv32(nkf_char c2,nkf_char c1);
#endif
+static void e_oconv(nkf_char c2,nkf_char c1);
static nkf_char e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1);
+static void s_oconv(nkf_char c2,nkf_char c1);
+static void j_oconv(nkf_char c2,nkf_char c1);
static void fold_conv(nkf_char c2,nkf_char c1);
-static void nl_conv(nkf_char c2,nkf_char c1);
+static void cr_conv(nkf_char c2,nkf_char c1);
static void z_conv(nkf_char c2,nkf_char c1);
static void rot_conv(nkf_char c2,nkf_char c1);
static void hira_conv(nkf_char c2,nkf_char c1);
@@ -569,10 +435,11 @@ static void mimeout_addchar(nkf_char c);
#ifndef PERL_XS
static void usage(void);
static void version(void);
-static void show_configuration(void);
#endif
static void options(unsigned char *c);
+#if defined(PERL_XS) || defined(WIN32DLL)
static void reinit(void);
+#endif
/* buffers */
@@ -586,7 +453,7 @@ static int hold_count = 0;
/* MIME preprocessor fifo */
#define MIME_BUF_SIZE (1024) /* 2^n ring buffer */
-#define MIME_BUF_MASK (MIME_BUF_SIZE-1)
+#define MIME_BUF_MASK (MIME_BUF_SIZE-1)
#define Fifo(n) mime_buf[(n)&MIME_BUF_MASK]
static unsigned char mime_buf[MIME_BUF_SIZE];
static unsigned int mime_top = 0;
@@ -603,14 +470,18 @@ static int rot_f = FALSE; /* rot14/43 mode */
static int hira_f = FALSE; /* hira/kata henkan */
static int input_f = FALSE; /* non fixed input code */
static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */
-static int mime_f = MIME_DECODE_DEFAULT; /* convert MIME B base64 or Q */
+static int mime_f = STRICT_MIME; /* convert MIME B base64 or Q */
static int mime_decode_f = FALSE; /* mime decode is explicitly on */
static int mimebuf_f = FALSE; /* MIME buffered input */
static int broken_f = FALSE; /* convert ESC-less broken JIS */
static int iso8859_f = FALSE; /* ISO8859 through */
static int mimeout_f = FALSE; /* base64 mode */
-static int x0201_f = X0201_DEFAULT; /* convert JIS X 0201 */
-static int iso2022jp_f = FALSE; /* replace non ISO-2022-JP with GETA */
+#if defined(MSDOS) || defined(__OS2__)
+static int x0201_f = TRUE; /* Assume JISX0201 kana */
+#else
+static int x0201_f = NO_X0201; /* Assume NO JISX0201 */
+#endif
+static int iso2022jp_f = FALSE; /* convert ISO-2022-JP */
#ifdef UNICODE_NORMALIZATION
static int nfc_f = FALSE;
@@ -658,16 +529,18 @@ static nkf_char numchar_ungetc(nkf_char c,FILE *f);
#ifdef CHECK_OPTION
static int noout_f = FALSE;
static void no_putc(nkf_char c);
-static int debug_f = FALSE;
+static nkf_char debug_f = FALSE;
static void debug(const char *str);
static nkf_char (*iconv_for_check)(nkf_char c2,nkf_char c1,nkf_char c0) = 0;
#endif
-static int guess_f = 0; /* 0: OFF, 1: ON, 2: VERBOSE */
+static int guess_f = FALSE;
#if !defined PERL_XS
static void print_guessed_code(char *filename);
#endif
static void set_input_codename(char *codename);
+static int is_inputcode_mixed = FALSE;
+static int is_inputcode_set = FALSE;
#ifdef EXEC_IO
static int exec_f = 0;
@@ -714,7 +587,7 @@ struct input_code input_code_list[] = {
{0}
};
-static int mimeout_mode = 0; /* 0, -1, 'Q', 'B', 1, 2 */
+static int mimeout_mode = 0;
static int base64_count = 0;
/* X0208 -> ASCII converter */
@@ -761,7 +634,7 @@ static nkf_char (*iconv)(nkf_char c2,nkf_char c1,nkf_char c0) = no_connection2;
static void (*o_zconv)(nkf_char c2,nkf_char c1) = no_connection;
static void (*o_fconv)(nkf_char c2,nkf_char c1) = no_connection;
-static void (*o_nlconv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_crconv)(nkf_char c2,nkf_char c1) = no_connection;
static void (*o_rot_conv)(nkf_char c2,nkf_char c1) = no_connection;
static void (*o_hira_conv)(nkf_char c2,nkf_char c1) = no_connection;
static void (*o_base64conv)(nkf_char c2,nkf_char c1) = no_connection;
@@ -796,7 +669,8 @@ static int mime_decode_mode = FALSE; /* MIME mode B base64, Q hex */
/* X0201 kana conversion table */
/* 90-9F A0-DF */
-static const unsigned char cv[]= {
+static const
+unsigned char cv[]= {
0x21,0x21,0x21,0x23,0x21,0x56,0x21,0x57,
0x21,0x22,0x21,0x26,0x25,0x72,0x25,0x21,
0x25,0x23,0x25,0x25,0x25,0x27,0x25,0x29,
@@ -818,7 +692,8 @@ static const unsigned char cv[]= {
/* X0201 kana conversion table for daguten */
/* 90-9F A0-DF */
-static const unsigned char dv[]= {
+static const
+unsigned char dv[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -839,7 +714,8 @@ static const unsigned char dv[]= {
/* X0201 kana conversion table for han-daguten */
/* 90-9F A0-DF */
-static const unsigned char ev[]= {
+static const
+unsigned char ev[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -861,7 +737,8 @@ static const unsigned char ev[]= {
/* X0208 kigou conversion table */
/* 0x8140 - 0x819e */
-static const unsigned char fv[] = {
+static const
+unsigned char fv[] = {
0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a,
0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00,
@@ -878,6 +755,7 @@ static const unsigned char fv[] = {
} ;
+#define CRLF 1
static int file_out_f = FALSE;
#ifdef OVERWRITE
@@ -888,9 +766,7 @@ static char *backup_suffix = "";
static char *get_backup_filename(const char *suffix, const char *filename);
#endif
-static int nlmode_f = 0; /* CR, LF, CRLF */
-static int input_newline = 0; /* 0: unestablished, EOF: MIXED */
-static nkf_char prev_cr = 0; /* CR or 0 */
+static int crmode_f = 0; /* CR, NL, CRLF */
#ifdef EASYWIN /*Easy Win */
static int end_check;
#endif /*Easy Win */
@@ -899,57 +775,6 @@ static int end_check;
nkf_char std_gc_buf[STD_GC_BUFSIZE];
nkf_char std_gc_ndx;
-char* nkf_strcpy(const char *str)
-{
- char* result = malloc(strlen(str) + 1);
- if (!result){
- perror(str);
- return "";
- }
- strcpy(result, str);
- return result;
-}
-
-static void nkf_str_upcase(const char *src, char *dest, size_t length)
-{
- int i = 0;
- for (; i < length && src[i]; i++) {
- dest[i] = nkf_toupper(src[i]);
- }
- dest[i] = 0;
-}
-
-static nkf_encoding *nkf_enc_from_index(int idx)
-{
- if (idx < 0 || NKF_ENCODING_TABLE_SIZE <= idx) {
- return 0;
- }
- return &nkf_encoding_table[idx];
-}
-
-static int nkf_enc_find_index(const char *name)
-{
- int i, index = -1;
- for (i = 0; encoding_name_to_id_table[i].id >= 0; i++) {
- if (strcmp(name, encoding_name_to_id_table[i].name) == 0) {
- return encoding_name_to_id_table[i].id;
- }
- }
- return index;
-}
-
-static nkf_encoding *nkf_enc_find(const char *name)
-{
- int idx = -1;
- idx = nkf_enc_find_index(name);
- if (idx < 0) return 0;
- return nkf_enc_from_index(idx);
-}
-
-#define nkf_enc_name(enc) (enc)->name
-#define nkf_enc_to_index(enc) (enc)->id
-#define nkf_enc_to_base_encoding(enc) (enc)->based_encoding
-
#ifdef WIN32DLL
#include "nkf32dll.c"
#elif defined(PERL_XS)
@@ -969,32 +794,6 @@ int main(int argc, char **argv)
for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) {
cp = (unsigned char *)*argv;
options(cp);
- if (guess_f) {
-#ifdef CHECK_OPTION
- int debug_f_back = debug_f;
-#endif
-#ifdef EXEC_IO
- int exec_f_back = exec_f;
-#endif
-#ifdef X0212_ENABLE
- int x0212_f_back = x0212_f;
-#endif
- int x0213_f_back = x0213_f;
- int guess_f_back = guess_f;
- reinit();
- guess_f = guess_f_back;
- mime_f = FALSE;
-#ifdef CHECK_OPTION
- debug_f = debug_f_back;
-#endif
-#ifdef EXEC_IO
- exec_f = exec_f_back;
-#endif
-#ifdef X0212_ENABLE
- x0212_f = x0212_f_back;
-#endif
- x0213_f = x0213_f_back;
- }
#ifdef EXEC_IO
if (exec_f){
int fds[2], pid;
@@ -1023,10 +822,12 @@ int main(int argc, char **argv)
}
#endif
}
+ if(x0201_f == WISH_TRUE)
+ x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
if (binmode_f == TRUE)
#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","wb",stdout) == NULL)
+ if (freopen("","wb",stdout) == NULL)
return (-1);
#else
setbinmode(stdout);
@@ -1055,13 +856,15 @@ int main(int argc, char **argv)
int nfiles = argc;
int is_argument_error = FALSE;
while (argc--) {
- input_codename = NULL;
- input_newline = 0;
+ is_inputcode_mixed = FALSE;
+ is_inputcode_set = FALSE;
+ input_codename = "";
#ifdef CHECK_OPTION
iconv_for_check = 0;
#endif
if ((fin = fopen((origfname = *argv++), "r")) == NULL) {
- perror(*(argv-1));
+ perror(*--argv);
+ *argv++;
is_argument_error = TRUE;
continue;
} else {
@@ -1110,7 +913,7 @@ int main(int argc, char **argv)
}
}else
#endif
- if(argc == 1) {
+ if(argc == 1 ) {
outfname = *argv++;
argc--;
} else {
@@ -1123,7 +926,7 @@ int main(int argc, char **argv)
}
if (binmode_f == TRUE) {
#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","wb",stdout) == NULL)
+ if (freopen("","wb",stdout) == NULL)
return (-1);
#else
setbinmode(stdout);
@@ -1132,11 +935,11 @@ int main(int argc, char **argv)
}
if (binmode_f == TRUE)
#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
- if (freopen("","rb",fin) == NULL)
+ if (freopen("","rb",fin) == NULL)
return (-1);
#else
setbinmode(fin);
-#endif
+#endif
setvbuffer(fin, (char *) stdibuf, IOBUF_SIZE);
if (nop_f)
noconvert(fin);
@@ -1215,12 +1018,12 @@ int main(int argc, char **argv)
return(-1);
}
#ifdef EASYWIN /*Easy Win */
- if (file_out_f == FALSE)
+ if (file_out_f == FALSE)
scanf("%d",&end_check);
- else
+ else
fclose(stdout);
#else /* for Other OS */
- if (file_out_f == TRUE)
+ if (file_out_f == TRUE)
fclose(stdout);
#endif /*Easy Win */
return (0);
@@ -1268,7 +1071,8 @@ char *get_backup_filename(const char *suffix, const char *filename)
}
#endif
-static const struct {
+static const
+struct {
const char *name;
const char *alias;
} long_option[] = {
@@ -1293,8 +1097,7 @@ static const struct {
{"hiragana","h1"},
{"katakana","h2"},
{"katakana-hiragana","h3"},
- {"guess=", ""},
- {"guess", "g1"},
+ {"guess", "g"},
{"cp932", ""},
{"no-cp932", ""},
#ifdef X0212_ENABLE
@@ -1356,9 +1159,7 @@ void options(unsigned char *cp)
unsigned char *p;
unsigned char *cp_back = NULL;
char codeset[32];
- nkf_encoding *enc;
- if (!output_encoding) output_encoding = nkf_enc_from_index(DEFAULT_ENCODING);
if (option_mode==1)
return;
while(*cp && *cp++!='-');
@@ -1371,38 +1172,36 @@ void options(unsigned char *cp)
p = 0;
switch (*cp++) {
case '-': /* literal options */
- if (!*cp || *cp == SP) { /* ignore the rest of arguments */
+ if (!*cp || *cp == SPACE) { /* ignore the rest of arguments */
option_mode = 1;
return;
}
for (i=0;i<sizeof(long_option)/sizeof(long_option[0]);i++) {
p = (unsigned char *)long_option[i].name;
for (j=0;*p && *p != '=' && *p == cp[j];p++, j++);
- if (*p == cp[j] || cp[j] == SP){
+ if (*p == cp[j] || cp[j] == ' '){
p = &cp[j] + 1;
break;
}
p = 0;
}
- if (p == 0) {
- fprintf(stderr, "unknown long option: --%s\n", cp);
- return;
- }
- while(*cp && *cp != SP && cp++);
+ if (p == 0) return;
+ while(*cp && *cp != SPACE && cp++);
if (long_option[i].alias[0]){
cp_back = cp;
cp = (unsigned char *)long_option[i].alias;
}else{
if (strcmp(long_option[i].name, "ic=") == 0){
- nkf_str_upcase((char *)p, codeset, 32);
- enc = nkf_enc_find(codeset);
- switch (nkf_enc_to_index(enc)) {
- case ISO_2022_JP:
+ 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){
input_f = JIS_INPUT;
- break;
- case CP50220:
- case CP50221:
- case CP50222:
+ }else if(strcmp(codeset, "X-ISO2022JP-CP932") == 0 ||
+ strcmp(codeset, "CP50220") == 0 ||
+ strcmp(codeset, "CP50221") == 0 ||
+ strcmp(codeset, "CP50222") == 0){
input_f = JIS_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = TRUE;
@@ -1410,24 +1209,23 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
#endif
- break;
- case ISO_2022_JP_1:
+ }else if(strcmp(codeset, "ISO-2022-JP-1") == 0){
input_f = JIS_INPUT;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
- break;
- case ISO_2022_JP_3:
+ }else if(strcmp(codeset, "ISO-2022-JP-3") == 0){
input_f = JIS_INPUT;
#ifdef X0212_ENABLE
x0212_f = TRUE;
#endif
x0213_f = TRUE;
- break;
- case SHIFT_JIS:
+ }else if(strcmp(codeset, "SHIFT_JIS") == 0){
input_f = SJIS_INPUT;
- break;
- case WINDOWS_31J:
+ }else if(strcmp(codeset, "WINDOWS-31J") == 0 ||
+ strcmp(codeset, "CSWINDOWS31J") == 0 ||
+ strcmp(codeset, "CP932") == 0 ||
+ strcmp(codeset, "MS932") == 0){
input_f = SJIS_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = TRUE;
@@ -1435,20 +1233,10 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
#endif
- break;
- case CP10001:
- input_f = SJIS_INPUT;
-#ifdef SHIFTJIS_CP932
- cp51932_f = TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP10001;
-#endif
- break;
- case EUC_JP:
+ }else if(strcmp(codeset, "EUCJP") == 0 ||
+ strcmp(codeset, "EUC-JP") == 0){
input_f = EUC_INPUT;
- break;
- case CP51932:
+ }else if(strcmp(codeset, "CP51932") == 0){
input_f = EUC_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = TRUE;
@@ -1456,8 +1244,9 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
#endif
- break;
- case EUCJP_MS:
+ }else if(strcmp(codeset, "EUC-JP-MS") == 0 ||
+ strcmp(codeset, "EUCJP-MS") == 0 ||
+ strcmp(codeset, "EUCJPMS") == 0){
input_f = EUC_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
@@ -1465,8 +1254,8 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_MS;
#endif
- break;
- case EUCJP_ASCII:
+ }else if(strcmp(codeset, "EUC-JP-ASCII") == 0 ||
+ strcmp(codeset, "EUCJP-ASCII") == 0){
input_f = EUC_INPUT;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
@@ -1474,94 +1263,88 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_ASCII;
#endif
- break;
- case SHIFT_JISX0213:
- case SHIFT_JIS_2004:
+ }else if(strcmp(codeset, "SHIFT_JISX0213") == 0 ||
+ strcmp(codeset, "SHIFT_JIS-2004") == 0){
input_f = SJIS_INPUT;
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
#endif
- break;
- case EUC_JISX0213:
- case EUC_JIS_2004:
+ }else if(strcmp(codeset, "EUC-JISX0213") == 0 ||
+ strcmp(codeset, "EUC-JIS-2004") == 0){
input_f = EUC_INPUT;
x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
cp51932_f = FALSE;
#endif
- break;
#ifdef UTF8_INPUT_ENABLE
- case UTF_8:
- case UTF_8N:
- case UTF_8_BOM:
+ }else if(strcmp(codeset, "UTF-8") == 0 ||
+ strcmp(codeset, "UTF-8N") == 0 ||
+ strcmp(codeset, "UTF-8-BOM") == 0){
input_f = UTF8_INPUT;
- break;
#ifdef UNICODE_NORMALIZATION
- case UTF8_MAC:
+ }else if(strcmp(codeset, "UTF8-MAC") == 0 ||
+ strcmp(codeset, "UTF-8-MAC") == 0){
input_f = UTF8_INPUT;
nfc_f = TRUE;
- break;
#endif
- case UTF_16:
- case UTF_16BE:
- case UTF_16BE_BOM:
+ }else if(strcmp(codeset, "UTF-16") == 0 ||
+ strcmp(codeset, "UTF-16BE") == 0 ||
+ strcmp(codeset, "UTF-16BE-BOM") == 0){
input_f = UTF16_INPUT;
input_endian = ENDIAN_BIG;
- break;
- case UTF_16LE:
- case UTF_16LE_BOM:
+ }else if(strcmp(codeset, "UTF-16LE") == 0 ||
+ strcmp(codeset, "UTF-16LE-BOM") == 0){
input_f = UTF16_INPUT;
input_endian = ENDIAN_LITTLE;
- break;
- case UTF_32:
- case UTF_32BE:
- case UTF_32BE_BOM:
+ }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;
- break;
- case UTF_32LE:
- case UTF_32LE_BOM:
+ }else if(strcmp(codeset, "UTF-32LE") == 0 ||
+ strcmp(codeset, "UTF-32LE-BOM") == 0){
input_f = UTF32_INPUT;
input_endian = ENDIAN_LITTLE;
- break;
#endif
- default:
- fprintf(stderr, "unknown input encoding: %s\n", codeset);
- break;
}
continue;
}
if (strcmp(long_option[i].name, "oc=") == 0){
x0201_f = FALSE;
- nkf_str_upcase((char *)p, codeset, 32);
- enc = nkf_enc_find(codeset);
- if (enc <= 0) continue;
- output_encoding = enc;
- switch (nkf_enc_to_index(output_encoding)) {
- case ISO_2022_JP:
+ 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){
output_conv = j_oconv;
- break;
- case CP50220:
- output_conv = j_oconv;
- x0201_f = TRUE;
+ }else if(strcmp(codeset, "X-ISO2022JP-CP932") == 0){
+ output_conv = j_oconv;
+ no_cp932ext_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp932inv_f = FALSE;
+ cp932inv_f = FALSE;
#endif
#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP932;
+ ms_ucs_map_f = UCS_MAP_CP932;
#endif
- break;
- case CP50221:
+ }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
- break;
- case ISO_2022_JP_1:
+ }else if(strcmp(codeset, "CP50221") == 0){
+ output_conv = j_oconv;
+#ifdef SHIFTJIS_CP932
+ cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ }else if(strcmp(codeset, "ISO-2022-JP-1") == 0){
output_conv = j_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
@@ -1569,8 +1352,7 @@ void options(unsigned char *cp)
#ifdef SHIFTJIS_CP932
cp932inv_f = FALSE;
#endif
- break;
- case ISO_2022_JP_3:
+ }else if(strcmp(codeset, "ISO-2022-JP-3") == 0){
output_conv = j_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
@@ -1579,26 +1361,20 @@ void options(unsigned char *cp)
#ifdef SHIFTJIS_CP932
cp932inv_f = FALSE;
#endif
- break;
- case SHIFT_JIS:
+ }else if(strcmp(codeset, "SHIFT_JIS") == 0){
output_conv = s_oconv;
- break;
- case WINDOWS_31J:
+ }else if(strcmp(codeset, "WINDOWS-31J") == 0 ||
+ strcmp(codeset, "CSWINDOWS31J") == 0 ||
+ strcmp(codeset, "CP932") == 0 ||
+ strcmp(codeset, "MS932") == 0){
output_conv = s_oconv;
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
#endif
- break;
- case CP10001:
- output_conv = s_oconv;
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = UCS_MAP_CP10001;
-#endif
- break;
- case EUC_JP:
+ }else if(strcmp(codeset, "EUCJP") == 0 ||
+ strcmp(codeset, "EUC-JP") == 0){
output_conv = e_oconv;
- break;
- case CP51932:
+ }else if(strcmp(codeset, "CP51932") == 0){
output_conv = e_oconv;
#ifdef SHIFTJIS_CP932
cp932inv_f = FALSE;
@@ -1606,8 +1382,9 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_CP932;
#endif
- break;
- case EUCJP_MS:
+ }else if(strcmp(codeset, "EUC-JP-MS") == 0 ||
+ strcmp(codeset, "EUCJP-MS") == 0 ||
+ strcmp(codeset, "EUCJPMS") == 0){
output_conv = e_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
@@ -1615,8 +1392,8 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_MS;
#endif
- break;
- case EUCJP_ASCII:
+ }else if(strcmp(codeset, "EUC-JP-ASCII") == 0 ||
+ strcmp(codeset, "EUCJP-ASCII") == 0){
output_conv = e_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
@@ -1624,17 +1401,15 @@ void options(unsigned char *cp)
#ifdef UTF8_OUTPUT_ENABLE
ms_ucs_map_f = UCS_MAP_ASCII;
#endif
- break;
- case SHIFT_JISX0213:
- case SHIFT_JIS_2004:
- output_conv = s_oconv;
- x0213_f = TRUE;
+ }else if(strcmp(codeset, "SHIFT_JISX0213") == 0 ||
+ strcmp(codeset, "SHIFT_JIS-2004") == 0){
+ output_conv = s_oconv;
+ x0213_f = TRUE;
#ifdef SHIFTJIS_CP932
- cp932inv_f = FALSE;
+ cp932inv_f = FALSE;
#endif
- break;
- case EUC_JISX0213:
- case EUC_JIS_2004:
+ }else if(strcmp(codeset, "EUC-JISX0213") == 0 ||
+ strcmp(codeset, "EUC-JIS-2004") == 0){
output_conv = e_oconv;
#ifdef X0212_ENABLE
x0212_f = TRUE;
@@ -1643,65 +1418,44 @@ void options(unsigned char *cp)
#ifdef SHIFTJIS_CP932
cp932inv_f = FALSE;
#endif
- break;
#ifdef UTF8_OUTPUT_ENABLE
- case UTF_8:
- case UTF_8N:
+ }else if(strcmp(codeset, "UTF-8") == 0){
output_conv = w_oconv;
- break;
- case UTF_8_BOM:
+ }else if(strcmp(codeset, "UTF-8N") == 0){
+ output_conv = w_oconv;
+ }else if(strcmp(codeset, "UTF-8-BOM") == 0){
output_conv = w_oconv;
output_bom_f = TRUE;
- break;
- case UTF_16BE:
+ }else if(strcmp(codeset, "UTF-16BE") == 0){
output_conv = w_oconv16;
- break;
- case UTF_16:
- case UTF_16BE_BOM:
+ }else if(strcmp(codeset, "UTF-16") == 0 ||
+ strcmp(codeset, "UTF-16BE-BOM") == 0){
output_conv = w_oconv16;
output_bom_f = TRUE;
- break;
- case UTF_16LE:
+ }else if(strcmp(codeset, "UTF-16LE") == 0){
output_conv = w_oconv16;
output_endian = ENDIAN_LITTLE;
- break;
- case UTF_16LE_BOM:
+ }else if(strcmp(codeset, "UTF-16LE-BOM") == 0){
output_conv = w_oconv16;
output_endian = ENDIAN_LITTLE;
output_bom_f = TRUE;
- break;
- case UTF_32:
- case UTF_32BE:
+ }else if(strcmp(codeset, "UTF-32") == 0 ||
+ strcmp(codeset, "UTF-32BE") == 0){
output_conv = w_oconv32;
- break;
- case UTF_32BE_BOM:
+ }else if(strcmp(codeset, "UTF-32BE-BOM") == 0){
output_conv = w_oconv32;
output_bom_f = TRUE;
- break;
- case UTF_32LE:
+ }else if(strcmp(codeset, "UTF-32LE") == 0){
output_conv = w_oconv32;
output_endian = ENDIAN_LITTLE;
- break;
- case UTF_32LE_BOM:
+ }else if(strcmp(codeset, "UTF-32LE-BOM") == 0){
output_conv = w_oconv32;
output_endian = ENDIAN_LITTLE;
output_bom_f = TRUE;
- break;
#endif
- default:
- fprintf(stderr, "unknown output encoding: %s\n", codeset);
- break;
}
continue;
}
- if (strcmp(long_option[i].name, "guess=") == 0){
- if (p[0] == '1') {
- guess_f = 2;
- } else {
- guess_f = 1;
- }
- continue;
- }
#ifdef OVERWRITE
if (strcmp(long_option[i].name, "overwrite") == 0){
file_out_f = TRUE;
@@ -1821,7 +1575,7 @@ void options(unsigned char *cp)
encode_fallback = encode_fallback_html;
continue;
}
- if (strcmp(long_option[i].name, "fb-xml") == 0){
+ if (strcmp(long_option[i].name, "fb-xml" ) == 0){
encode_fallback = encode_fallback_xml;
continue;
}
@@ -1896,8 +1650,8 @@ void options(unsigned char *cp)
case 't': /* transparent mode */
if (*cp=='1') {
/* alias of -t */
- cp++;
nop_f = TRUE;
+ *cp++;
} else if (*cp=='2') {
/*
* -t with put/get
@@ -1905,58 +1659,55 @@ void options(unsigned char *cp)
* nkf -t2MB hoge.bin | nkf -t2mB | diff -s - hoge.bin
*
*/
- cp++;
nop_f = 2;
+ *cp++;
} else
nop_f = TRUE;
continue;
case 'j': /* JIS output */
case 'n':
output_conv = j_oconv;
- output_encoding = nkf_enc_from_index(ISO_2022_JP);
continue;
case 'e': /* AT&T EUC output */
output_conv = e_oconv;
cp932inv_f = FALSE;
- output_encoding = nkf_enc_from_index(EUC_JP);
continue;
case 's': /* SJIS output */
output_conv = s_oconv;
- output_encoding = nkf_enc_from_index(SHIFT_JIS);
continue;
case 'l': /* ISO8859 Latin-1 support, no conversion */
iso8859_f = TRUE; /* Only compatible with ISO-2022-JP */
input_f = LATIN1_INPUT;
continue;
case 'i': /* Kanji IN ESC-$-@/B */
- if (*cp=='@'||*cp=='B')
+ if (*cp=='@'||*cp=='B')
kanji_intro = *cp++;
continue;
case 'o': /* ASCII IN ESC-(-J/B */
- if (*cp=='J'||*cp=='B'||*cp=='H')
+ if (*cp=='J'||*cp=='B'||*cp=='H')
ascii_intro = *cp++;
continue;
case 'h':
- /*
+ /*
bit:1 katakana->hiragana
bit:2 hiragana->katakana
*/
- if ('9'>= *cp && *cp>='0')
+ if ('9'>= *cp && *cp>='0')
hira_f |= (*cp++ -'0');
- else
+ else
hira_f |= 1;
continue;
case 'r':
rot_f = TRUE;
continue;
-#if defined(MSDOS) || defined(__OS2__)
+#if defined(MSDOS) || defined(__OS2__)
case 'T':
binmode_f = FALSE;
continue;
#endif
#ifndef PERL_XS
case 'V':
- show_configuration();
+ version();
exit(1);
break;
case 'v':
@@ -1970,22 +1721,16 @@ void options(unsigned char *cp)
output_conv = w_oconv; cp++;
if (cp[0] == '0'){
cp++;
- output_encoding = nkf_enc_from_index(UTF_8N);
} else {
output_bom_f = TRUE;
- output_encoding = nkf_enc_from_index(UTF_8_BOM);
}
} else {
- int enc_idx;
if ('1'== cp[0] && '6'==cp[1]) {
output_conv = w_oconv16; cp+=2;
- enc_idx = UTF_16;
} else if ('3'== cp[0] && '2'==cp[1]) {
output_conv = w_oconv32; cp+=2;
- enc_idx = UTF_32;
} else {
output_conv = w_oconv;
- output_encoding = nkf_enc_from_index(UTF_8);
continue;
}
if (cp[0]=='L') {
@@ -1994,21 +1739,13 @@ void options(unsigned char *cp)
} else if (cp[0] == 'B') {
cp++;
} else {
- output_encoding = nkf_enc_from_index(enc_idx);
continue;
}
if (cp[0] == '0'){
cp++;
- enc_idx = enc_idx == UTF_16
- ? (output_endian == ENDIAN_LITTLE ? UTF_16LE : UTF_16BE)
- : (output_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE);
} else {
output_bom_f = TRUE;
- enc_idx = enc_idx == UTF_16
- ? (output_endian == ENDIAN_LITTLE ? UTF_16LE_BOM : UTF_16BE_BOM)
- : (output_endian == ENDIAN_LITTLE ? UTF_32LE_BOM : UTF_32BE_BOM);
}
- output_encoding = nkf_enc_from_index(enc_idx);
}
continue;
#endif
@@ -2048,19 +1785,18 @@ void options(unsigned char *cp)
continue;
case 'S': /* MS Kanji input */
input_f = SJIS_INPUT;
+ if (x0201_f==NO_X0201) x0201_f=TRUE;
continue;
case 'Z': /* Convert X0208 alphabet to asii */
- /* alpha_f
- bit:0 Convert JIS X 0208 Alphabet to ASCII
- bit:1 Convert Kankaku to one space
- bit:2 Convert Kankaku to two spaces
- bit:3 Convert HTML Entity
- bit:4 Convert JIS X 0208 Katakana to JIS X 0201 Katakana
+ /* bit:0 Convert X0208
+ bit:1 Convert Kankaku to one space
+ bit:2 Convert Kankaku to two spaces
+ bit:3 Convert HTML Entity
*/
- while ('0'<= *cp && *cp <='9') {
- alpha_f |= 1 << (*cp++ - '0');
- }
- if (!alpha_f) alpha_f = 1;
+ if ('9'>= *cp && *cp>='0')
+ alpha_f |= 1<<(*cp++ -'0');
+ else
+ alpha_f |= TRUE;
continue;
case 'x': /* Convert X0201 kana to X0208 or X0201 Conversion */
x0201_f = FALSE; /* No X0201->X0208 conversion */
@@ -2068,14 +1804,15 @@ void options(unsigned char *cp)
ESC-(-I in JIS, EUC, MS Kanji
SI/SO in JIS, EUC, MS Kanji
SSO in EUC, JIS, not in MS Kanji
- MS Kanji (0xa0-0xdf)
+ MS Kanji (0xa0-0xdf)
output X0201
ESC-(-I in JIS (0x20-0x5f)
SSO in EUC (0xa0-0xdf)
- 0xa0-0xd in MS Kanji (0xa0-0xdf)
+ 0xa0-0xd in MS Kanji (0xa0-0xdf)
*/
continue;
- case 'X': /* Convert X0201 kana to X0208 */
+ case 'X': /* Assume X0201 kana */
+ /* Default value is NO_X0201 for EUC/MS-Kanji mix */
x0201_f = TRUE;
continue;
case 'F': /* prserve new lines */
@@ -2087,7 +1824,7 @@ void options(unsigned char *cp)
fold_len *= 10;
fold_len += *cp++ - '0';
}
- if (!(0<fold_len && fold_len<BUFSIZ))
+ if (!(0<fold_len && fold_len<BUFSIZ))
fold_len = DEFAULT_FOLD;
if (*cp=='-') {
fold_margin = 0;
@@ -2128,9 +1865,9 @@ void options(unsigned char *cp)
bit:1 allow any x on ESC-(-x or ESC-$-x
bit:2 reset to ascii on NL
*/
- if ('9'>= *cp && *cp>='0')
+ if ('9'>= *cp && *cp>='0')
broken_f |= 1<<(*cp++ -'0');
- else
+ else
broken_f |= TRUE;
continue;
#ifndef PERL_XS
@@ -2139,44 +1876,35 @@ void options(unsigned char *cp)
continue;
#endif
case 'c':/* add cr code */
- nlmode_f = CRLF;
+ crmode_f = CRLF;
continue;
case 'd':/* delete cr code */
- nlmode_f = LF;
+ crmode_f = NL;
+ continue;
+ case 'I': /* ISO-2022-JP output */
+ iso2022jp_f = TRUE;
continue;
- case 'I': /* ISO-2022-JP output */
- iso2022jp_f = TRUE;
- continue;
case 'L': /* line mode */
if (*cp=='u') { /* unix */
- nlmode_f = LF; cp++;
+ crmode_f = NL; cp++;
} else if (*cp=='m') { /* mac */
- nlmode_f = CR; cp++;
+ crmode_f = CR; cp++;
} else if (*cp=='w') { /* windows */
- nlmode_f = CRLF; cp++;
+ crmode_f = CRLF; cp++;
} else if (*cp=='0') { /* no conversion */
- nlmode_f = 0; cp++;
+ crmode_f = 0; cp++;
}
continue;
-#ifndef PERL_XS
case 'g':
- if (*cp == '1') {
- guess_f = 2;
- cp++;
- } else if (*cp == '0') {
- guess_f = 1;
- cp++;
- } else {
- guess_f = 1;
- }
- continue;
+#ifndef PERL_XS
+ guess_f = TRUE;
#endif
- case SP:
+ continue;
+ case ' ':
/* module muliple options in a string are allowed for Perl moudle */
while(*cp && *cp++!='-');
continue;
default:
- fprintf(stderr, "unknown option: -%c\n", *(cp-1));
/* bogus option but ignored */
continue;
}
@@ -2218,7 +1946,7 @@ void set_iconv(nkf_char f, nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_ch
struct input_code *p = find_inputcode_byfunc(iconv);
if (p){
set_input_codename(p->name);
- debug(p->name);
+ debug(input_codename);
}
iconv_for_check = iconv;
}
@@ -2228,26 +1956,29 @@ void set_iconv(nkf_char f, nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_ch
#define SCORE_L2 (1) /* $BBh(B2$B?e=`4A;z(B */
#define SCORE_KANA (SCORE_L2 << 1) /* $B$$$o$f$kH>3Q%+%J(B */
#define SCORE_DEPEND (SCORE_KANA << 1) /* $B5!<o0MB8J8;z(B */
-#define SCORE_CP932 (SCORE_DEPEND << 1) /* CP932 $B$K$h$kFI$_49$((B (IBM extended characters) */
-#define SCORE_X0212 (SCORE_CP932 << 1) /* JIS X 0212 */
-#define SCORE_NO_EXIST (SCORE_X0212 << 1) /* $BB8:_$7$J$$J8;z(B */
+#ifdef SHIFTJIS_CP932
+#define SCORE_CP932 (SCORE_DEPEND << 1) /* CP932 $B$K$h$kFI$_49$((B */
+#define SCORE_NO_EXIST (SCORE_CP932 << 1) /* $BB8:_$7$J$$J8;z(B */
+#else
+#define SCORE_NO_EXIST (SCORE_DEPEND << 1) /* $BB8:_$7$J$$J8;z(B */
+#endif
#define SCORE_iMIME (SCORE_NO_EXIST << 1) /* MIME $B$K$h$k;XDj(B */
#define SCORE_ERROR (SCORE_iMIME << 1) /* $B%(%i!<(B */
#define SCORE_INIT (SCORE_iMIME)
-static const char score_table_A0[] = {
+const nkf_char score_table_A0[] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND,
SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND, SCORE_NO_EXIST,
};
-static const char score_table_F0[] = {
+const nkf_char score_table_F0[] = {
SCORE_L2, SCORE_L2, SCORE_L2, SCORE_L2,
SCORE_L2, SCORE_DEPEND, SCORE_NO_EXIST, SCORE_NO_EXIST,
- SCORE_DEPEND, SCORE_DEPEND, SCORE_CP932, SCORE_CP932,
- SCORE_CP932, SCORE_NO_EXIST, SCORE_NO_EXIST, SCORE_ERROR,
+ SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND,
+ SCORE_DEPEND, SCORE_NO_EXIST, SCORE_NO_EXIST, SCORE_ERROR,
};
void set_code_score(struct input_code *ptr, nkf_char score)
@@ -2274,8 +2005,6 @@ void code_score(struct input_code *ptr)
set_code_score(ptr, SCORE_ERROR);
}else if (c2 == SSO){
set_code_score(ptr, SCORE_KANA);
- }else if (c2 == 0x8f){
- set_code_score(ptr, SCORE_X0212);
#ifdef UTF8_OUTPUT_ENABLE
}else if (!e2w_conv(c2, c1)){
set_code_score(ptr, SCORE_NO_EXIST);
@@ -2345,19 +2074,17 @@ void s_status(struct input_code *ptr, nkf_char c)
status_push_ch(ptr, c);
code_score(ptr);
status_clear(ptr);
- }else if ((0x81 <= c && c < 0xa0) || (0xe0 <= c && c <= 0xea)){
+ }else if ((0x81 <= c && c < 0xa0) || (0xe0 <= c && c <= 0xef)){
ptr->stat = 1;
status_push_ch(ptr, c);
- }else if (0xed <= c && c <= 0xee){
- ptr->stat = 3;
- status_push_ch(ptr, c);
#ifdef SHIFTJIS_CP932
- }else if (is_ibmext_in_sjis(c)){
+ }else if (cp51932_f
+ && is_ibmext_in_sjis(c)){
ptr->stat = 2;
status_push_ch(ptr, c);
#endif /* SHIFTJIS_CP932 */
#ifdef X0212_ENABLE
- }else if (0xf0 <= c && c <= 0xfc){
+ }else if (x0212_f && 0xf0 <= c && c <= 0xfc){
ptr->stat = 1;
status_push_ch(ptr, c);
#endif /* X0212_ENABLE */
@@ -2377,26 +2104,18 @@ void s_status(struct input_code *ptr, nkf_char c)
break;
case 2:
#ifdef SHIFTJIS_CP932
- if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)) {
- status_push_ch(ptr, c);
- if (s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]) == 0) {
- set_code_score(ptr, SCORE_CP932);
- status_clear(ptr);
- break;
- }
- }
-#endif /* SHIFTJIS_CP932 */
- status_disable(ptr);
- break;
- case 3:
if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)){
status_push_ch(ptr, c);
- s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]);
- set_code_score(ptr, SCORE_CP932);
- status_clear(ptr);
- }else{
- status_disable(ptr);
+ if (s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]) == 0){
+ set_code_score(ptr, SCORE_CP932);
+ status_clear(ptr);
+ break;
+ }
}
+#endif /* SHIFTJIS_CP932 */
+#ifndef X0212_ENABLE
+ status_disable(ptr);
+#endif
break;
}
}
@@ -2588,7 +2307,7 @@ nkf_char noconvert(FILE *f)
void module_connection(void)
{
- oconv = output_conv;
+ oconv = output_conv;
o_putc = std_putc;
/* replace continucation module, from output side */
@@ -2608,8 +2327,8 @@ void module_connection(void)
/* base64_count = 0; */
}
- if (nlmode_f || guess_f) {
- o_nlconv = oconv; oconv = nl_conv;
+ if (crmode_f) {
+ o_crconv = oconv; oconv = cr_conv;
}
if (rot_f) {
o_rot_conv = oconv; oconv = rot_conv;
@@ -2797,7 +2516,7 @@ void check_bom(FILE *f)
}
/*
- Conversion main loop. Code detection only.
+ Conversion main loop. Code detection only.
*/
nkf_char kanji_convert(FILE *f)
@@ -2836,9 +2555,9 @@ nkf_char kanji_convert(FILE *f)
if (!estab_f&&!mime_decode_mode) {
/* in case of not established yet */
/* It is still ambiguious */
- if (h_conv(f, c2, c1)==EOF)
+ if (h_conv(f, c2, c1)==EOF)
LAST;
- else
+ else
c2 = 0;
NEXT;
} else {
@@ -2854,7 +2573,7 @@ nkf_char kanji_convert(FILE *f)
} else
/* second byte, 7 bit code */
/* it might be kanji shitfted */
- if ((c1 == DEL) || (c1 <= SP)) {
+ if ((c1 == DEL) || (c1 <= SPACE)) {
/* ignore bogus first code */
c2 = 0;
NEXT;
@@ -2928,16 +2647,16 @@ nkf_char kanji_convert(FILE *f)
NEXT;
} else { /* estab_f==TRUE */
if (iso8859_f) {
- c2 = ISO_8859_1;
+ c2 = ISO8859_1;
c1 &= 0x7f;
SEND;
} else if (SSP<=c1 && c1<0xe0 && iconv == s_iconv) {
/* SJIS X0201 Case... */
- if (iso2022jp_f && !x0201_f) {
+ if(iso2022jp_f && x0201_f==NO_X0201) {
(*oconv)(GETA1, GETA2);
NEXT;
} else {
- c2 = JIS_X_0201;
+ c2 = X0201;
c1 &= 0x7f;
SEND;
}
@@ -2946,55 +2665,49 @@ nkf_char kanji_convert(FILE *f)
c1 = (*i_getc)(f); /* skip SSO */
code_status(c1);
if (SSP<=c1 && c1<0xe0) {
- if (iso2022jp_f && !x0201_f) {
+ if(iso2022jp_f && x0201_f==NO_X0201) {
(*oconv)(GETA1, GETA2);
NEXT;
} else {
- c2 = JIS_X_0201;
+ c2 = X0201;
c1 &= 0x7f;
SEND;
}
} else { /* bogus code, skip SSO and one byte */
NEXT;
}
- } else if (ms_ucs_map_f == UCS_MAP_CP10001 &&
- (c1 == 0xFD || c1 == 0xFE)) {
- /* CP10001 */
- c2 = JIS_X_0201;
- c1 &= 0x7f;
- SEND;
} else {
/* already established */
c2 = c1;
NEXT;
}
}
- } else if ((c1 > SP) && (c1 != DEL)) {
+ } else if ((c1 > SPACE) && (c1 != DEL)) {
/* in case of Roman characters */
- if (shift_mode) {
+ if (shift_mode) {
/* output 1 shifted byte */
if (iso8859_f) {
- c2 = ISO_8859_1;
+ c2 = ISO8859_1;
SEND;
- } else if (SP <= c1 && c1 < (0xe0&0x7f)){
+ } else if (SPACE<=c1 && c1<(0xe0&0x7f) ){
/* output 1 shifted byte */
- if (iso2022jp_f && !x0201_f) {
+ if(iso2022jp_f && x0201_f==NO_X0201) {
(*oconv)(GETA1, GETA2);
NEXT;
} else {
- c2 = JIS_X_0201;
+ c2 = X0201;
SEND;
}
} else {
/* look like bogus code */
NEXT;
}
- } else if (input_mode == JIS_X_0208 || input_mode == JIS_X_0212 ||
- input_mode == JIS_X_0213_1 || input_mode == JIS_X_0213_2) {
+ } else if (input_mode == X0208 || input_mode == X0212 ||
+ input_mode == X0213_1 || input_mode == X0213_2) {
/* in case of Kanji shifted */
c2 = c1;
NEXT;
- } else if (c1 == '=' && mime_f && !mime_decode_mode) {
+ } else if (c1 == '=' && mime_f && !mime_decode_mode ) {
/* Check MIME code */
if ((c1 = (*i_getc)(f)) == EOF) {
(*oconv)(0, '=');
@@ -3003,11 +2716,11 @@ nkf_char kanji_convert(FILE *f)
/* =? is mime conversion start sequence */
if(mime_f == STRICT_MIME) {
/* check in real detail */
- if (mime_begin_strict(f) == EOF)
+ if (mime_begin_strict(f) == EOF)
LAST;
else
NEXT;
- } else if (mime_begin(f) == EOF)
+ } else if (mime_begin(f) == EOF)
LAST;
else
NEXT;
@@ -3017,14 +2730,14 @@ nkf_char kanji_convert(FILE *f)
NEXT;
}
} else {
- /* normal ASCII code */
+ /* normal ASCII code */
SEND;
}
} else if (c1 == SI && (!is_8bit || mime_decode_mode)) {
- shift_mode = FALSE;
+ shift_mode = FALSE;
NEXT;
} else if (c1 == SO && (!is_8bit || mime_decode_mode)) {
- shift_mode = TRUE;
+ shift_mode = TRUE;
NEXT;
} else if (c1 == ESC && (!is_8bit || mime_decode_mode)) {
if ((c1 = (*i_getc)(f)) == EOF) {
@@ -3033,21 +2746,21 @@ nkf_char kanji_convert(FILE *f)
} else if (c1 == '$') {
if ((c1 = (*i_getc)(f)) == EOF) {
/*
- (*oconv)(0, ESC); don't send bogus code
+ (*oconv)(0, ESC); don't send bogus code
(*oconv)(0, '$'); */
LAST;
} else if (c1 == '@'|| c1 == 'B') {
/* This is kanji introduction */
- input_mode = JIS_X_0208;
+ input_mode = X0208;
shift_mode = FALSE;
set_input_codename("ISO-2022-JP");
#ifdef CHECK_OPTION
- debug("ISO-2022-JP");
+ debug(input_codename);
#endif
NEXT;
} else if (c1 == '(') {
if ((c1 = (*i_getc)(f)) == EOF) {
- /* don't send bogus code
+ /* don't send bogus code
(*oconv)(0, ESC);
(*oconv)(0, '$');
(*oconv)(0, '(');
@@ -3055,21 +2768,21 @@ nkf_char kanji_convert(FILE *f)
LAST;
} else if (c1 == '@'|| c1 == 'B') {
/* This is kanji introduction */
- input_mode = JIS_X_0208;
+ input_mode = X0208;
shift_mode = FALSE;
NEXT;
#ifdef X0212_ENABLE
} else if (c1 == 'D'){
- input_mode = JIS_X_0212;
+ input_mode = X0212;
shift_mode = FALSE;
NEXT;
#endif /* X0212_ENABLE */
- } else if (c1 == 0x4F){
- input_mode = JIS_X_0213_1;
+ } else if (c1 == (X0213_1&0x7F)){
+ input_mode = X0213_1;
shift_mode = FALSE;
NEXT;
- } else if (c1 == 0x50){
- input_mode = JIS_X_0213_2;
+ } else if (c1 == (X0213_2&0x7F)){
+ input_mode = X0213_2;
shift_mode = FALSE;
NEXT;
} else {
@@ -3082,7 +2795,7 @@ nkf_char kanji_convert(FILE *f)
}
} else if (broken_f&0x2) {
/* accept any ESC-(-x as broken code ... */
- input_mode = JIS_X_0208;
+ input_mode = X0208;
shift_mode = FALSE;
NEXT;
} else {
@@ -3093,14 +2806,14 @@ nkf_char kanji_convert(FILE *f)
}
} else if (c1 == '(') {
if ((c1 = (*i_getc)(f)) == EOF) {
- /* don't send bogus code
+ /* don't send bogus code
(*oconv)(0, ESC);
(*oconv)(0, '('); */
LAST;
} else {
if (c1 == 'I') {
/* This is X0201 kana introduction */
- input_mode = JIS_X_0201; shift_mode = JIS_X_0201;
+ input_mode = X0201; shift_mode = X0201;
NEXT;
} else if (c1 == 'B' || c1 == 'J' || c1 == 'H') {
/* This is X0208 kanji introduction */
@@ -3116,12 +2829,12 @@ nkf_char kanji_convert(FILE *f)
SEND;
}
}
- } else if ( c1 == 'N' || c1 == 'n'){
+ } else if ( c1 == 'N' || c1 == 'n' ){
/* SS2 */
c3 = (*i_getc)(f); /* skip SS2 */
- if ( (SP<=c3 && c3 < 0x60) || (0xa0<=c3 && c3 < 0xe0)){
+ if ( (SPACE<=c3 && c3 < 0x60) || (0xa0<=c3 && c3 < 0xe0)){
c1 = c3;
- c2 = JIS_X_0201;
+ c2 = X0201;
SEND;
}else{
(*i_ungetc)(c3, f);
@@ -3143,7 +2856,7 @@ nkf_char kanji_convert(FILE *f)
/* J-PHONE emoji */
if ((c1 = (*i_getc)(f)) == EOF) {
/*
- (*oconv)(0, ESC); don't send bogus code
+ (*oconv)(0, ESC); don't send bogus code
(*oconv)(0, '$'); */
LAST;
} else {
@@ -3156,10 +2869,10 @@ nkf_char kanji_convert(FILE *f)
C%7 : 0 1 2 3 4 5 6
NUM : 2 0 3 4 5 X 1
*/
- static const char jphone_emoji_first_table[7] = {2, 0, 3, 4, 5, 0, 1};
- c0 = (jphone_emoji_first_table[c1 % 7] << 8) - SP + 0xE000 + CLASS_UNICODE;
+ 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 (SP <= c1 && c1 <= 'z') {
+ if (SPACE <= c1 && c1 <= 'z') {
(*oconv)(0, c1 + c0);
} else break; /* c1 == SO */
}
@@ -3172,44 +2885,40 @@ nkf_char kanji_convert(FILE *f)
(*oconv)(0, ESC);
SEND;
}
- } else if (c1 == LF || c1 == CR) {
- if (broken_f&4) {
- input_mode = ASCII; set_iconv(FALSE, 0);
- SEND;
- } else if (mime_decode_f && !mime_decode_mode){
- if (c1 == LF) {
- if ((c1=(*i_getc)(f))!=EOF && c1 == SP) {
- i_ungetc(SP,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- c1 = LF;
- SEND;
- } else { /* if (c1 == CR)*/
- if ((c1=(*i_getc)(f))!=EOF) {
- if (c1==SP) {
- i_ungetc(SP,f);
- continue;
- } else if (c1 == LF && (c1=(*i_getc)(f))!=EOF && c1 == SP) {
- i_ungetc(SP,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- i_ungetc(LF,f);
- } else {
- i_ungetc(c1,f);
- }
- c1 = CR;
- SEND;
+ } else if ((c1 == NL || c1 == CR) && broken_f&4) {
+ input_mode = ASCII; set_iconv(FALSE, 0);
+ SEND;
+ } else if (c1 == NL && mime_decode_f && !mime_decode_mode ) {
+ if ((c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
+ i_ungetc(SPACE,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = NL;
+ SEND;
+ } else if (c1 == CR && mime_decode_f && !mime_decode_mode ) {
+ if ((c1=(*i_getc)(f))!=EOF) {
+ if (c1==SPACE) {
+ i_ungetc(SPACE,f);
+ continue;
+ } else if (c1 == NL && (c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
+ i_ungetc(SPACE,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
}
+ i_ungetc(NL,f);
+ } else {
+ i_ungetc(c1,f);
}
- } else if (c1 == DEL && input_mode == JIS_X_0208) {
+ c1 = CR;
+ SEND;
+ } else if (c1 == DEL && input_mode == X0208 ) {
/* CP5022x */
c2 = c1;
NEXT;
- } else
+ } else
SEND;
}
/* send: */
@@ -3236,8 +2945,8 @@ nkf_char kanji_convert(FILE *f)
break;
}
break;
- case JIS_X_0208:
- case JIS_X_0213_1:
+ case X0208:
+ case X0213_1:
if (ms_ucs_map_f &&
0x7F <= c2 && c2 <= 0x92 &&
0x21 <= c1 && c1 <= 0x7E) {
@@ -3249,11 +2958,11 @@ nkf_char kanji_convert(FILE *f)
(*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */
break;
#ifdef X0212_ENABLE
- case JIS_X_0212:
+ case X0212:
(*oconv)(PREFIX_EUCG3 | c2, c1);
break;
#endif /* X0212_ENABLE */
- case JIS_X_0213_2:
+ case X0213_2:
(*oconv)(PREFIX_EUCG3 | c2, c1);
break;
default:
@@ -3268,7 +2977,7 @@ nkf_char kanji_convert(FILE *f)
/* epilogue */
(*iconv)(EOF, 0, 0);
- if (!input_codename)
+ if (!is_inputcode_set)
{
if (is_8bit) {
struct input_code *p = input_code_list;
@@ -3278,9 +2987,6 @@ nkf_char kanji_convert(FILE *f)
++p;
}
set_input_codename(result->name);
-#ifdef CHECK_OPTION
- debug(result->name);
-#endif
}
}
return 1;
@@ -3319,12 +3025,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);
}
@@ -3349,7 +3055,7 @@ h_conv(FILE *f, nkf_char c2, nkf_char c1)
(*iconv)(0, c2, 0);
continue;
}else if (iconv == s_iconv && 0xa1 <= c2 && c2 <= 0xdf){
- (*iconv)(JIS_X_0201, c2, 0);
+ (*iconv)(X0201, c2, 0);
continue;
}
if (hold_index < hold_count){
@@ -3416,9 +3122,12 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
#if defined(SHIFTJIS_CP932) || defined(X0212_ENABLE)
nkf_char val;
#endif
- static const char shift_jisx0213_s1a3_table[5][2] ={ { 1, 8}, { 3, 4}, { 5,12}, {13,14}, {15, 0} };
+ 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 0
+ extern const unsigned short shiftjis_cp932[3][189];
+#endif
val = shiftjis_cp932[c2 - CP932_TABLE_BEGIN][c1 - 0x40];
if (val){
c2 = val >> 8;
@@ -3427,6 +3136,9 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
}
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;
@@ -3436,6 +3148,9 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
#endif /* SHIFTJIS_CP932 */
#ifdef X0212_ENABLE
if (!x0213_f && is_ibmext_in_sjis(c2)){
+#if 0
+ extern const unsigned short shiftjis_x0212[3][189];
+#endif
val = shiftjis_x0212[c2 - 0xfa][c1 - 0x40];
if (val){
if (val > 0x7FFF){
@@ -3464,7 +3179,7 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
if (0x9E < c1) c2++;
}
if (c1 < 0x9F)
- c1 = c1 - ((c1 > DEL) ? SP : 0x1F);
+ c1 = c1 - ((c1 > DEL) ? SPACE : 0x1F);
else {
c1 = c1 - 0x7E;
}
@@ -3480,9 +3195,9 @@ nkf_char s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
nkf_char s_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
{
- if (c2 == JIS_X_0201) {
+ if (c2 == X0201) {
c1 &= 0x7f;
- } else if ((c2 == EOF) || (c2 == 0) || c2 < SP) {
+ } else if ((c2 == EOF) || (c2 == 0) || c2 < SPACE) {
/* NOP */
} else if (!x0213_f && 0xF0 <= c2 && c2 <= 0xF9 && 0x40 <= c1 && c1 <= 0xFC) {
/* CP932 UDC */
@@ -3499,7 +3214,7 @@ nkf_char s_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
{
- if (c2 == JIS_X_0201) {
+ if (c2 == X0201) {
c1 &= 0x7f;
#ifdef X0212_ENABLE
}else if (c2 == 0x8f){
@@ -3528,9 +3243,9 @@ nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
}
#endif /* X0212_ENABLE */
} else if (c2 == SSO){
- c2 = JIS_X_0201;
+ c2 = X0201;
c1 &= 0x7f;
- } else if ((c2 == EOF) || (c2 == 0) || c2 < SP) {
+ } 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) {
@@ -3582,13 +3297,13 @@ 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 char w_iconv_utf8_1st_byte[] =
+ 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;
@@ -3766,24 +3481,32 @@ nkf_char w_iconv32(nkf_char c2, nkf_char c1, nkf_char c0)
nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char *p1)
{
+#if 0
+ extern const unsigned short *const utf8_to_euc_2bytes[];
+ extern const unsigned short *const utf8_to_euc_2bytes_ms[];
+ extern const unsigned short *const utf8_to_euc_2bytes_932[];
+ extern const unsigned short *const *const utf8_to_euc_3bytes[];
+ extern const unsigned short *const *const utf8_to_euc_3bytes_ms[];
+ extern const unsigned short *const *const utf8_to_euc_3bytes_932[];
+#endif
const unsigned short *const *pp;
const unsigned short *const *const *ppp;
- static const char no_best_fit_chars_table_C2[] =
+ static const int no_best_fit_chars_table_C2[] =
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 2,
0, 0, 1, 1, 0, 1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1};
- static const char no_best_fit_chars_table_C2_ms[] =
+ static const int no_best_fit_chars_table_C2_ms[] =
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0,
0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0};
- static const char no_best_fit_chars_table_932_C2[] =
+ static const int no_best_fit_chars_table_932_C2[] =
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1,
0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0};
- static const char no_best_fit_chars_table_932_C3[] =
+ static const int no_best_fit_chars_table_932_C3[] =
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -3815,27 +3538,11 @@ nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *
}
}else if(ms_ucs_map_f == UCS_MAP_MS){
if(c2 == 0xC2 && no_best_fit_chars_table_C2_ms[c1&0x3F]) return 1;
- }else if(ms_ucs_map_f == UCS_MAP_CP10001){
- switch(c2){
- case 0xC2:
- switch(c1){
- case 0xA2:
- case 0xA3:
- case 0xA5:
- case 0xA6:
- case 0xAC:
- case 0xAF:
- case 0xB8:
- return 1;
- }
- break;
- }
}
}
pp =
ms_ucs_map_f == UCS_MAP_CP932 ? utf8_to_euc_2bytes_932 :
ms_ucs_map_f == UCS_MAP_MS ? utf8_to_euc_2bytes_ms :
- ms_ucs_map_f == UCS_MAP_CP10001 ? utf8_to_euc_2bytes_mac :
utf8_to_euc_2bytes;
ret = w_iconv_common(c2, c1, pp, sizeof_utf8_to_euc_2bytes, p2, p1);
}else if(c0 < 0xF0){
@@ -3858,19 +3565,6 @@ nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *
if(c1 == 0x80 || c0 == 0x9C) return 1;
break;
}
- }else if(ms_ucs_map_f == UCS_MAP_CP10001){
- switch(c2){
- case 0xE3:
- switch(c1){
- case 0x82:
- if(c0 == 0x94) return 1;
- break;
- case 0x83:
- if(c0 == 0xBB) return 1;
- break;
- }
- break;
- }
}else{
switch(c2){
case 0xE2:
@@ -3902,7 +3596,6 @@ nkf_char unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *
ppp =
ms_ucs_map_f == UCS_MAP_CP932 ? utf8_to_euc_3bytes_932 :
ms_ucs_map_f == UCS_MAP_MS ? utf8_to_euc_3bytes_ms :
- ms_ucs_map_f == UCS_MAP_CP10001 ? utf8_to_euc_3bytes_mac :
utf8_to_euc_3bytes;
ret = w_iconv_common(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
}else return -1;
@@ -3946,7 +3639,7 @@ nkf_char w_iconv_common(nkf_char c1, nkf_char c0, const unsigned short *const *p
c2 &= 0x7f;
c2 |= PREFIX_EUCG3;
}
- if (c2 == SO) c2 = JIS_X_0201;
+ if (c2 == SO) c2 = X0201;
c1 = val & 0x7f;
if (p2) *p2 = c2;
if (p1) *p1 = c1;
@@ -3955,12 +3648,13 @@ nkf_char w_iconv_common(nkf_char c1, nkf_char c0, const unsigned short *const *p
void nkf_each_char_to_hex(void (*f)(nkf_char c2,nkf_char c1), nkf_char c)
{
+ const char *hex = "0123456789ABCDEF";
int shift = 20;
c &= VALUE_MASK;
while(shift >= 0){
if(c >= 1<<shift){
while(shift >= 0){
- (*f)(0, bin2hex(c>>shift));
+ (*f)(0, hex[(c>>shift)&0xF]);
shift -= 4;
}
}else{
@@ -4005,21 +3699,22 @@ void encode_fallback_xml(nkf_char c)
void encode_fallback_java(nkf_char c)
{
+ const char *hex = "0123456789ABCDEF";
(*oconv)(0, '\\');
c &= VALUE_MASK;
if(!is_unicode_bmp(c)){
(*oconv)(0, 'U');
(*oconv)(0, '0');
(*oconv)(0, '0');
- (*oconv)(0, bin2hex(c>>20));
- (*oconv)(0, bin2hex(c>>16));
+ (*oconv)(0, hex[(c>>20)&0xF]);
+ (*oconv)(0, hex[(c>>16)&0xF]);
}else{
(*oconv)(0, 'u');
}
- (*oconv)(0, bin2hex(c>>12));
- (*oconv)(0, bin2hex(c>> 8));
- (*oconv)(0, bin2hex(c>> 4));
- (*oconv)(0, bin2hex(c ));
+ (*oconv)(0, hex[(c>>12)&0xF]);
+ (*oconv)(0, hex[(c>> 8)&0xF]);
+ (*oconv)(0, hex[(c>> 4)&0xF]);
+ (*oconv)(0, hex[ c &0xF]);
return;
}
@@ -4044,17 +3739,15 @@ void encode_fallback_subchar(nkf_char c)
#ifdef UTF8_OUTPUT_ENABLE
nkf_char e2w_conv(nkf_char c2, nkf_char c1)
{
+#if 0
+ extern const unsigned short euc_to_utf8_1byte[];
+ extern const unsigned short *const euc_to_utf8_2bytes[];
+ extern const unsigned short *const euc_to_utf8_2bytes_ms[];
+ extern const unsigned short *const x0212_to_utf8_2bytes[];
+#endif
const unsigned short *p;
- if (c2 == JIS_X_0201) {
- if (ms_ucs_map_f == UCS_MAP_CP10001) {
- switch (c1) {
- case 0x20:
- return 0xA0;
- case 0x7D:
- return 0xA9;
- }
- }
+ if (c2 == X0201) {
p = euc_to_utf8_1byte;
#ifdef X0212_ENABLE
} else if (is_eucg3(c2)){
@@ -4071,10 +3764,7 @@ nkf_char e2w_conv(nkf_char c2, nkf_char c1)
c2 &= 0x7f;
c2 = (c2&0x7f) - 0x21;
if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
- p =
- ms_ucs_map_f == UCS_MAP_ASCII ? euc_to_utf8_2bytes[c2] :
- ms_ucs_map_f == UCS_MAP_CP10001 ? euc_to_utf8_2bytes_mac[c2] :
- euc_to_utf8_2bytes_ms[c2];
+ p = ms_ucs_map_f != UCS_MAP_ASCII ? euc_to_utf8_2bytes_ms[c2] : euc_to_utf8_2bytes[c2];
else
return 0;
}
@@ -4124,14 +3814,14 @@ void w_oconv(nkf_char c2, nkf_char c1)
}
#endif
- if (c2 == 0) {
+ if (c2 == 0) {
output_mode = ASCII;
(*o_putc)(c1);
- } else if (c2 == ISO_8859_1) {
- output_mode = UTF_8;
+ } else if (c2 == ISO8859_1) {
+ output_mode = ISO8859_1;
(*o_putc)(c1 | 0x080);
} else {
- output_mode = UTF_8;
+ output_mode = UTF8;
val = e2w_conv(c2, c1);
if (val){
w16w_conv(val, &c2, &c1, &c0);
@@ -4162,7 +3852,7 @@ void w_oconv16(nkf_char c2, nkf_char c1)
return;
}
- if (c2 == ISO_8859_1) {
+ if (c2 == ISO8859_1) {
c2 = 0;
c1 |= 0x80;
#ifdef NUMCHAR_OPTION
@@ -4227,7 +3917,7 @@ void w_oconv32(nkf_char c2, nkf_char c1)
return;
}
- if (c2 == ISO_8859_1) {
+ if (c2 == ISO8859_1) {
c1 |= 0x80;
#ifdef NUMCHAR_OPTION
} else if (c2 == 0 && is_unicode_capsule(c1)) {
@@ -4283,18 +3973,18 @@ void e_oconv(nkf_char c2, nkf_char c1)
if (c2 == EOF) {
(*o_putc)(EOF);
return;
- } else if (c2 == 0) {
+ } else if (c2 == 0) {
output_mode = ASCII;
(*o_putc)(c1);
- } else if (c2 == JIS_X_0201) {
- output_mode = EUC_JP;
+ } else if (c2 == X0201) {
+ output_mode = JAPANESE_EUC;
(*o_putc)(SSO); (*o_putc)(c1|0x80);
- } else if (c2 == ISO_8859_1) {
- output_mode = ISO_8859_1;
+ } else if (c2 == ISO8859_1) {
+ output_mode = ISO8859_1;
(*o_putc)(c1 | 0x080);
#ifdef X0212_ENABLE
} else if (is_eucg3(c2)){
- output_mode = EUC_JP;
+ output_mode = JAPANESE_EUC;
#ifdef SHIFTJIS_CP932
if (!cp932inv_f){
nkf_char s2, s1;
@@ -4322,7 +4012,7 @@ void e_oconv(nkf_char c2, nkf_char c1)
set_iconv(FALSE, 0);
return; /* too late to rescue this char */
}
- output_mode = EUC_JP;
+ output_mode = JAPANESE_EUC;
(*o_putc)(c2 | 0x080);
(*o_putc)(c1 | 0x080);
}
@@ -4379,6 +4069,9 @@ nkf_char e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
else if(nkf_isgraph(ndx)){
nkf_char val = 0;
const unsigned short *ptr;
+#if 0
+ extern const unsigned short *const x0212_shiftjis[];
+#endif
ptr = x0212_shiftjis[ndx - 0x21];
if (ptr){
val = ptr[(c1 & 0x7f) - 0x21];
@@ -4429,11 +4122,11 @@ void s_oconv(nkf_char c2, nkf_char c1)
} else if (c2 == 0) {
output_mode = ASCII;
(*o_putc)(c1);
- } else if (c2 == JIS_X_0201) {
+ } else if (c2 == X0201) {
output_mode = SHIFT_JIS;
(*o_putc)(c1|0x80);
- } else if (c2 == ISO_8859_1) {
- output_mode = ISO_8859_1;
+ } else if (c2 == ISO8859_1) {
+ output_mode = ISO8859_1;
(*o_putc)(c1 | 0x080);
#ifdef X0212_ENABLE
} else if (is_eucg3(c2)){
@@ -4454,6 +4147,9 @@ void s_oconv(nkf_char c2, nkf_char c1)
#ifdef SHIFTJIS_CP932
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;
@@ -4490,7 +4186,7 @@ void j_oconv(nkf_char c2, nkf_char c1)
}
#endif
if (c2 == EOF) {
- if (output_mode !=ASCII && output_mode!=ISO_8859_1) {
+ if (output_mode !=ASCII && output_mode!=ISO8859_1) {
(*o_putc)(ESC);
(*o_putc)('(');
(*o_putc)(ascii_intro);
@@ -4500,41 +4196,41 @@ void j_oconv(nkf_char c2, nkf_char c1)
#ifdef X0212_ENABLE
} else if (is_eucg3(c2)){
if(x0213_f){
- if(output_mode!=JIS_X_0213_2){
- output_mode = JIS_X_0213_2;
+ if(output_mode!=X0213_2){
+ output_mode = X0213_2;
(*o_putc)(ESC);
(*o_putc)('$');
(*o_putc)('(');
- (*o_putc)(0x50);
+ (*o_putc)(X0213_2&0x7F);
}
}else{
- if(output_mode!=JIS_X_0212){
- output_mode = JIS_X_0212;
+ if(output_mode!=X0212){
+ output_mode = X0212;
(*o_putc)(ESC);
(*o_putc)('$');
(*o_putc)('(');
- (*o_putc)(0x44);
+ (*o_putc)(X0212&0x7F);
}
}
(*o_putc)(c2 & 0x7f);
(*o_putc)(c1);
#endif
- } else if (c2==JIS_X_0201) {
- if (output_mode!=JIS_X_0201) {
- output_mode = JIS_X_0201;
+ } else if (c2==X0201) {
+ if (output_mode!=X0201) {
+ output_mode = X0201;
(*o_putc)(ESC);
(*o_putc)('(');
(*o_putc)('I');
}
(*o_putc)(c1);
- } else if (c2==ISO_8859_1) {
+ } else if (c2==ISO8859_1) {
/* iso8859 introduction, or 8th bit on */
- /* Can we convert in 7bit form using ESC-'-'-A ?
+ /* Can we convert in 7bit form using ESC-'-'-A ?
Is this popular? */
- output_mode = ISO_8859_1;
+ output_mode = ISO8859_1;
(*o_putc)(c1|0x80);
} else if (c2 == 0) {
- if (output_mode !=ASCII && output_mode!=ISO_8859_1) {
+ if (output_mode !=ASCII && output_mode!=ISO8859_1) {
(*o_putc)(ESC);
(*o_putc)('(');
(*o_putc)(ascii_intro);
@@ -4546,15 +4242,15 @@ void j_oconv(nkf_char c2, nkf_char c1)
? c2<0x20 || 0x92<c2 || c1<0x20 || 0x7e<c1
: c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
if(x0213_f){
- if (output_mode!=JIS_X_0213_1) {
- output_mode = JIS_X_0213_1;
+ if (output_mode!=X0213_1) {
+ output_mode = X0213_1;
(*o_putc)(ESC);
(*o_putc)('$');
(*o_putc)('(');
- (*o_putc)(0x4F);
+ (*o_putc)(X0213_1&0x7F);
}
- }else if (output_mode != JIS_X_0208) {
- output_mode = JIS_X_0208;
+ }else if (output_mode != X0208) {
+ output_mode = X0208;
(*o_putc)(ESC);
(*o_putc)('$');
(*o_putc)(kanji_intro);
@@ -4582,20 +4278,20 @@ nkf_char broken_getc(FILE *f)
return broken_buf[--broken_counter];
}
c= (*i_bgetc)(f);
- if (c=='$' && broken_last != ESC
- && (input_mode==ASCII || input_mode==JIS_X_0201)) {
+ if (c=='$' && broken_last != ESC
+ && (input_mode==ASCII || input_mode==X0201)) {
c1= (*i_bgetc)(f);
broken_last = 0;
if (c1=='@'|| c1=='B') {
- broken_buf[0]=c1; broken_buf[1]=c;
+ broken_buf[0]=c1; broken_buf[1]=c;
broken_counter=2;
return ESC;
} else {
(*i_bungetc)(c1,f);
return c;
}
- } else if (c=='(' && broken_last != ESC
- && (input_mode==JIS_X_0208 || input_mode==JIS_X_0201)) { /* ) */
+ } else if (c=='(' && broken_last != ESC
+ && (input_mode==X0208 || input_mode==X0201)) { /* ) */
c1= (*i_bgetc)(f);
broken_last = 0;
if (c1=='J'|| c1=='B') {
@@ -4619,41 +4315,48 @@ nkf_char broken_ungetc(nkf_char c, FILE *f)
return c;
}
-void nl_conv(nkf_char c2, nkf_char c1)
+static nkf_char prev_cr = 0;
+
+void cr_conv(nkf_char c2, nkf_char c1)
{
- if (guess_f && input_newline != EOF) {
- if (c2 == 0 && c1 == LF) {
- if (!input_newline) input_newline = prev_cr ? CRLF : LF;
- else if (input_newline != (prev_cr ? CRLF : LF)) input_newline = EOF;
- } else if (c2 == 0 && c1 == CR && input_newline == LF) input_newline = EOF;
- else if (!prev_cr);
- else if (!input_newline) input_newline = CR;
- else if (input_newline != CR) input_newline = EOF;
- }
- if (prev_cr || (c2 == 0 && c1 == LF)) {
+ if (prev_cr) {
prev_cr = 0;
- if (nlmode_f != LF) (*o_nlconv)(0, CR);
- if (nlmode_f != CR) (*o_nlconv)(0, LF);
+ if (! (c2==0&&c1==NL) ) {
+ cr_conv(0,'\n');
+ }
+ }
+ if (c2) {
+ (*o_crconv)(c2,c1);
+ } else if (c1=='\r') {
+ prev_cr = c1;
+ } else if (c1=='\n') {
+ if (crmode_f==CRLF) {
+ (*o_crconv)(0,'\r');
+ } else if (crmode_f==CR) {
+ (*o_crconv)(0,'\r');
+ return;
+ }
+ (*o_crconv)(0,NL);
+ } else if (c1!='\032' || crmode_f!=NL){
+ (*o_crconv)(c2,c1);
}
- if (c2 == 0 && c1 == CR) prev_cr = CR;
- else if (c2 != 0 || c1 != LF) (*o_nlconv)(c2, c1);
}
-/*
+/*
Return value of fold_conv()
- LF add newline and output char
- CR add newline and output nothing
- SP space
- 0 skip
- 1 (or else) normal output
+ \n add newline and output char
+ \r add newline and output nothing
+ ' ' space
+ 0 skip
+ 1 (or else) normal output
fold state in prev (previous character)
>0x80 Japanese (X0208/X0201)
<0x80 ASCII
- LF new line
- SP space
+ \n new line
+ ' ' space
This fold algorthm does not preserve heading space in a line.
This is the main difference from fmt.
@@ -4662,34 +4365,34 @@ void nl_conv(nkf_char c2, nkf_char c1)
#define char_size(c2,c1) (c2?2:1)
void fold_conv(nkf_char c2, nkf_char c1)
-{
+{
nkf_char prev0;
nkf_char fold_state;
- if (c1== CR && !fold_preserve_f) {
+ if (c1== '\r' && !fold_preserve_f) {
fold_state=0; /* ignore cr */
- }else if (c1== LF&&f_prev==CR && fold_preserve_f) {
- f_prev = LF;
+ }else if (c1== '\n'&&f_prev=='\r' && fold_preserve_f) {
+ f_prev = '\n';
fold_state=0; /* ignore cr */
} else if (c1== BS) {
if (f_line>0) f_line--;
fold_state = 1;
} else if (c2==EOF && f_line != 0) { /* close open last line */
- fold_state = LF;
- } else if ((c1==LF && !fold_preserve_f)
- || ((c1==CR||(c1==LF&&f_prev!=CR))
+ fold_state = '\n';
+ } else if ((c1=='\n' && !fold_preserve_f)
+ || ((c1=='\r'||(c1=='\n'&&f_prev!='\r'))
&& fold_preserve_f)) {
/* new line */
- if (fold_preserve_f) {
+ if (fold_preserve_f) {
f_prev = c1;
f_line = 0;
- fold_state = CR;
+ fold_state = '\r';
} else if ((f_prev == c1 && !fold_preserve_f)
- || (f_prev == LF && fold_preserve_f)
+ || (f_prev == '\n' && fold_preserve_f)
) { /* duplicate newline */
if (f_line) {
f_line = 0;
- fold_state = LF; /* output two newline */
+ fold_state = '\n'; /* output two newline */
} else {
f_line = 0;
fold_state = 1;
@@ -4698,41 +4401,41 @@ void fold_conv(nkf_char c2, nkf_char c1)
if (f_prev&0x80) { /* Japanese? */
f_prev = c1;
fold_state = 0; /* ignore given single newline */
- } else if (f_prev==SP) {
+ } else if (f_prev==' ') {
fold_state = 0;
} else {
f_prev = c1;
- if (++f_line<=fold_len)
- fold_state = SP;
+ if (++f_line<=fold_len)
+ fold_state = ' ';
else {
f_line = 0;
- fold_state = CR; /* fold and output nothing */
+ fold_state = '\r'; /* fold and output nothing */
}
}
}
} else if (c1=='\f') {
- f_prev = LF;
+ f_prev = '\n';
f_line = 0;
- fold_state = LF; /* output newline and clear */
- } else if ( (c2==0 && c1==SP)||
- (c2==0 && c1==TAB)||
+ fold_state = '\n'; /* output newline and clear */
+ } else if ( (c2==0 && c1==' ')||
+ (c2==0 && c1=='\t')||
(c2=='!'&& c1=='!')) {
/* X0208 kankaku or ascii space */
- if (f_prev == SP) {
+ if (f_prev == ' ') {
fold_state = 0; /* remove duplicate spaces */
} else {
- f_prev = SP;
- if (++f_line<=fold_len)
- fold_state = SP; /* output ASCII space only */
+ f_prev = ' ';
+ if (++f_line<=fold_len)
+ fold_state = ' '; /* output ASCII space only */
else {
- f_prev = SP; f_line = 0;
- fold_state = CR; /* fold and output nothing */
+ f_prev = ' '; f_line = 0;
+ fold_state = '\r'; /* fold and output nothing */
}
}
} else {
prev0 = f_prev; /* we still need this one... , but almost done */
f_prev = c1;
- if (c2 || c2==JIS_X_0201)
+ if (c2 || c2==X0201)
f_prev |= 0x80; /* this is Japanese */
f_line += char_size(c2,c1);
if (f_line<=fold_len) { /* normal case */
@@ -4740,8 +4443,8 @@ void fold_conv(nkf_char c2, nkf_char c1)
} else {
if (f_line>fold_len+fold_margin) { /* too many kinsoku suspension */
f_line = char_size(c2,c1);
- fold_state = LF; /* We can't wait, do fold now */
- } else if (c2==JIS_X_0201) {
+ fold_state = '\n'; /* We can't wait, do fold now */
+ } else if (c2==X0201) {
/* simple kinsoku rules return 1 means no folding */
if (c1==(0xde&0x7f)) fold_state = 1; /* $B!+(B*/
else if (c1==(0xdf&0x7f)) fold_state = 1; /* $B!,(B*/
@@ -4749,15 +4452,15 @@ void fold_conv(nkf_char c2, nkf_char c1)
else if (c1==(0xa3&0x7f)) fold_state = 1; /* $B!$(B*/
else if (c1==(0xa1&0x7f)) fold_state = 1; /* $B!W(B*/
else if (c1==(0xb0&0x7f)) fold_state = 1; /* - */
- else if (SP<=c1 && c1<=(0xdf&0x7f)) { /* X0201 */
+ else if (SPACE<=c1 && c1<=(0xdf&0x7f)) { /* X0201 */
f_line = 1;
- fold_state = LF;/* add one new f_line before this character */
+ fold_state = '\n';/* add one new f_line before this character */
} else {
f_line = 1;
- fold_state = LF;/* add one new f_line before this character */
+ fold_state = '\n';/* add one new f_line before this character */
}
} else if (c2==0) {
- /* kinsoku point in ASCII */
+ /* kinsoku point in ASCII */
if ( c1==')'|| /* { [ ( */
c1==']'||
c1=='}'||
@@ -4767,17 +4470,17 @@ void fold_conv(nkf_char c2, nkf_char c1)
c1=='?'||
c1=='/'||
c1==':'||
- c1==';') {
+ c1==';' ) {
fold_state = 1;
/* just after special */
} else if (!is_alnum(prev0)) {
f_line = char_size(c2,c1);
- fold_state = LF;
- } else if ((prev0==SP) || /* ignored new f_line */
- (prev0==LF)|| /* ignored new f_line */
+ fold_state = '\n';
+ } else if ((prev0==' ') || /* ignored new f_line */
+ (prev0=='\n')|| /* ignored new f_line */
(prev0&0x80)) { /* X0208 - ASCII */
f_line = char_size(c2,c1);
- fold_state = LF;/* add one new f_line before this character */
+ fold_state = '\n';/* add one new f_line before this character */
} else {
fold_state = 1; /* default no fold in ASCII */
}
@@ -4796,14 +4499,14 @@ void fold_conv(nkf_char c2, nkf_char c1)
else if (c1=='+') fold_state = 1; /* $B!+(B */
else if (c1==',') fold_state = 1; /* $B!,(B */
/* default no fold in kinsoku */
- else {
- fold_state = LF;
+ else {
+ fold_state = '\n';
f_line = char_size(c2,c1);
/* add one new f_line before this character */
}
} else {
f_line = char_size(c2,c1);
- fold_state = LF;
+ fold_state = '\n';
/* add one new f_line before this character */
}
}
@@ -4811,18 +4514,18 @@ void fold_conv(nkf_char c2, nkf_char c1)
}
/* terminator process */
switch(fold_state) {
- case LF:
- OCONV_NEWLINE((*o_fconv));
+ case '\n':
+ (*o_fconv)(0,'\n');
(*o_fconv)(c2,c1);
break;
- case 0:
+ case 0:
return;
- case CR:
- OCONV_NEWLINE((*o_fconv));
+ case '\r':
+ (*o_fconv)(0,'\n');
break;
- case TAB:
- case SP:
- (*o_fconv)(0,SP);
+ case '\t':
+ case ' ':
+ (*o_fconv)(0,' ');
break;
default:
(*o_fconv)(c2,c1);
@@ -4836,155 +4539,75 @@ void z_conv(nkf_char c2, nkf_char c1)
/* if (c2) c1 &= 0x7f; assertion */
- if (c2 == JIS_X_0201 && (c1 == 0x20 || c1 == 0x7D || c1 == 0x7E)) {
- (*o_zconv)(c2,c1);
- return;
+ if (x0201_f && z_prev2==X0201) { /* X0201 */
+ if (c1==(0xde&0x7f)) { /* $BByE@(B */
+ z_prev2=0;
+ (*o_zconv)(dv[(z_prev1-SPACE)*2],dv[(z_prev1-SPACE)*2+1]);
+ return;
+ } else if (c1==(0xdf&0x7f)&&ev[(z_prev1-SPACE)*2]) { /* $BH>ByE@(B */
+ z_prev2=0;
+ (*o_zconv)(ev[(z_prev1-SPACE)*2],ev[(z_prev1-SPACE)*2+1]);
+ return;
+ } else {
+ z_prev2=0;
+ (*o_zconv)(cv[(z_prev1-SPACE)*2],cv[(z_prev1-SPACE)*2+1]);
+ }
}
- if (x0201_f) {
- if (z_prev2 == JIS_X_0201) {
- if (c2 == JIS_X_0201) {
- if (c1 == (0xde&0x7f)) { /* $BByE@(B */
- z_prev2 = 0;
- (*o_zconv)(dv[(z_prev1-SP)*2], dv[(z_prev1-SP)*2+1]);
- return;
- } else if (c1 == (0xdf&0x7f) && ev[(z_prev1-SP)*2]) { /* $BH>ByE@(B */
- z_prev2 = 0;
- (*o_zconv)(ev[(z_prev1-SP)*2], ev[(z_prev1-SP)*2+1]);
- return;
- }
- }
- z_prev2 = 0;
- (*o_zconv)(cv[(z_prev1-SP)*2], cv[(z_prev1-SP)*2+1]);
- }
- if (c2 == JIS_X_0201) {
- if (dv[(c1-SP)*2] || ev[(c1-SP)*2]) {
- /* wait for $BByE@(B or $BH>ByE@(B */
- z_prev1 = c1;
- z_prev2 = c2;
- return;
- } else {
- (*o_zconv)(cv[(c1-SP)*2], cv[(c1-SP)*2+1]);
- return;
- }
- }
+ if (c2==EOF) {
+ (*o_zconv)(c2,c1);
+ return;
}
- if (c2 == EOF) {
- (*o_zconv)(c2, c1);
- return;
+ if (x0201_f && c2==X0201) {
+ if (dv[(c1-SPACE)*2]||ev[(c1-SPACE)*2]) {
+ /* wait for $BByE@(B or $BH>ByE@(B */
+ z_prev1 = c1; z_prev2 = c2;
+ return;
+ } else {
+ (*o_zconv)(cv[(c1-SPACE)*2],cv[(c1-SPACE)*2+1]);
+ return;
+ }
}
- if (alpha_f&1 && c2 == 0x23) {
- /* JISX0208 Alphabet */
+ /* JISX0208 Alphabet */
+ if (alpha_f && c2 == 0x23 ) {
c2 = 0;
- } else if (c2 == 0x21) {
- /* JISX0208 Kigou */
+ } else if (alpha_f && c2 == 0x21 ) {
+ /* JISX0208 Kigou */
if (0x21==c1) {
- if (alpha_f&2) {
+ if (alpha_f&0x2) {
+ c1 = ' ';
c2 = 0;
- c1 = SP;
- } else if (alpha_f&4) {
- (*o_zconv)(0, SP);
- (*o_zconv)(0, SP);
+ } else if (alpha_f&0x4) {
+ (*o_zconv)(0,' ');
+ (*o_zconv)(0,' ');
return;
- }
- } else if (alpha_f&1 && 0x20<c1 && c1<0x7f && fv[c1-0x20]) {
- c2 = 0;
+ }
+ } else if (0x20<c1 && c1<0x7f && fv[c1-0x20]) {
c1 = fv[c1-0x20];
- }
- }
-
- if (alpha_f&8 && c2 == 0) {
- /* HTML Entity */
- char *entity = 0;
- switch (c1){
- case '>': entity = "&gt;"; break;
- case '<': entity = "&lt;"; break;
- case '\"': entity = "&quot;"; break;
- case '&': entity = "&amp;"; break;
- }
- if (entity){
- while (*entity) (*o_zconv)(0, *entity++);
- return;
- }
- }
-
- if (alpha_f & 16) {
- /* JIS X 0208 Katakana to JIS X 0201 Katakana */
- if (c2 == 0x21) {
- char c = 0;
- switch (c1) {
- case 0x23:
- /* U+3002 (0x8142) Ideographic Full Stop -> U+FF61 (0xA1) Halfwidth Ideographic Full Stop */
- c = 0xA1;
- break;
- case 0x56:
- /* U+300C (0x8175) Left Corner Bracket -> U+FF62 (0xA2) Halfwidth Left Corner Bracket */
- c = 0xA2;
- break;
- case 0x57:
- /* U+300D (0x8176) Right Corner Bracket -> U+FF63 (0xA3) Halfwidth Right Corner Bracket */
- c = 0xA3;
- break;
- case 0x22:
- /* U+3001 (0x8141) Ideographic Comma -> U+FF64 (0xA4) Halfwidth Ideographic Comma */
- c = 0xA4;
- break;
- case 0x26:
- /* U+30FB (0x8145) Katakana Middle Dot -> U+FF65 (0xA5) Halfwidth Katakana Middle Dot */
- c = 0xA5;
- break;
- case 0x3C:
- /* U+30FC (0x815B) Katakana-Hiragana Prolonged Sound Mark -> U+FF70 (0xB0) Halfwidth Katakana-Hiragana Prolonged Sound Mark */
- c = 0xB0;
- break;
- case 0x2B:
- /* U+309B (0x814A) Katakana-Hiragana Voiced Sound Mark -> U+FF9E (0xDE) Halfwidth Katakana Voiced Sound Mark */
- c = 0xDE;
- break;
- case 0x2C:
- /* U+309C (0x814B) Katakana-Hiragana Semi-Voiced Sound Mark -> U+FF9F (0xDF) Halfwidth Katakana Semi-Voiced Sound Mark */
- c = 0xDF;
- break;
- }
- if (c) {
- (*o_zconv)(JIS_X_0201, c);
- return;
- }
- } else if (c2 == 0x25) {
- /* JISX0208 Katakana */
- static const int fullwidth_to_halfwidth[] =
- {
- 0x0000, 0x2700, 0x3100, 0x2800, 0x3200, 0x2900, 0x3300, 0x2A00,
- 0x3400, 0x2B00, 0x3500, 0x3600, 0x365E, 0x3700, 0x375E, 0x3800,
- 0x385E, 0x3900, 0x395E, 0x3A00, 0x3A5E, 0x3B00, 0x3B5E, 0x3C00,
- 0x3C5E, 0x3D00, 0x3D5E, 0x3E00, 0x3E5E, 0x3F00, 0x3F5E, 0x4000,
- 0x405E, 0x4100, 0x415E, 0x2F00, 0x4200, 0x425E, 0x4300, 0x435E,
- 0x4400, 0x445E, 0x4500, 0x4600, 0x4700, 0x4800, 0x4900, 0x4A00,
- 0x4A5E, 0x4A5F, 0x4B00, 0x4B5E, 0x4B5F, 0x4C00, 0x4C5E, 0x4C5F,
- 0x4D00, 0x4D5E, 0x4D5F, 0x4E00, 0x4E5E, 0x4E5F, 0x4F00, 0x5000,
- 0x5100, 0x5200, 0x5300, 0x2C00, 0x5400, 0x2D00, 0x5500, 0x2E00,
- 0x5600, 0x5700, 0x5800, 0x5900, 0x5A00, 0x5B00, 0x0000, 0x5C00,
- 0x0000, 0x0000, 0x2600, 0x5D00, 0x335E, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
- };
- if (fullwidth_to_halfwidth[c1-0x20]){
- c2 = fullwidth_to_halfwidth[c1-0x20];
- (*o_zconv)(JIS_X_0201, c2>>8);
- if (c2 & 0xFF) {
- (*o_zconv)(JIS_X_0201, c2&0xFF);
- }
- return;
- }
- }
+ c2 = 0;
+ if (alpha_f&0x8) {
+ char *entity = 0;
+ switch (c1){
+ case '>': entity = "&gt;"; break;
+ case '<': entity = "&lt;"; break;
+ case '\"': entity = "&quot;"; break;
+ case '&': entity = "&amp;"; break;
+ }
+ if (entity){
+ while (*entity) (*o_zconv)(0, *entity++);
+ return;
+ }
+ }
+ }
}
(*o_zconv)(c2,c1);
}
#define rot13(c) ( \
- ( c < 'A') ? c: \
+ ( c < 'A' ) ? c: \
(c <= 'M') ? (c + 13): \
(c <= 'Z') ? (c - 13): \
(c < 'a') ? (c): \
@@ -4994,15 +4617,15 @@ void z_conv(nkf_char c2, nkf_char c1)
)
#define rot47(c) ( \
- ( c < '!') ? c: \
- ( c <= 'O') ? (c + 47) : \
- ( c <= '~') ? (c - 47) : \
+ ( c < '!' ) ? c: \
+ ( c <= 'O' ) ? (c + 47) : \
+ ( c <= '~' ) ? (c - 47) : \
c \
)
void rot_conv(nkf_char c2, nkf_char c1)
{
- if (c2==0 || c2==JIS_X_0201 || c2==ISO_8859_1) {
+ if (c2==0 || c2==X0201 || c2==ISO8859_1) {
c1 = rot13(c1);
} else if (c2) {
c1 = rot47(c1);
@@ -5094,7 +4717,7 @@ void iso2022jp_check_conv(nkf_char c2, nkf_char c1)
/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */
-static const unsigned char *mime_pattern[] = {
+const unsigned char *mime_pattern[] = {
(const unsigned char *)"\075?EUC-JP?B?",
(const unsigned char *)"\075?SHIFT_JIS?B?",
(const unsigned char *)"\075?ISO-8859-1?Q?",
@@ -5119,16 +4742,16 @@ nkf_char (*mime_priority_func[])(nkf_char c2, nkf_char c1, nkf_char c0) = {
0,
};
-static const nkf_char mime_encode[] = {
- EUC_JP, SHIFT_JIS, ISO_8859_1, ISO_8859_1, JIS_X_0208, JIS_X_0201,
+const nkf_char mime_encode[] = {
+ JAPANESE_EUC, SHIFT_JIS,ISO8859_1, ISO8859_1, X0208, X0201,
#if defined(UTF8_INPUT_ENABLE)
- UTF_8, UTF_8,
+ UTF8, UTF8,
#endif
ASCII,
0
};
-static const nkf_char mime_encode_method[] = {
+const nkf_char mime_encode_method[] = {
'B', 'B','Q', 'B', 'B', 'Q',
#if defined(UTF8_INPUT_ENABLE)
'B', 'Q',
@@ -5177,8 +4800,8 @@ nkf_char mime_begin_strict(FILE *f)
p = mime_pattern[j];
r[0]='='; r[1]='?';
- for(i=2;p[i]>SP;i++) { /* start at =? */
- if (((r[i] = c1 = (*i_getc)(f))==EOF) || nkf_toupper(c1) != p[i]) {
+ for(i=2;p[i]>' ';i++) { /* start at =? */
+ if ( ((r[i] = c1 = (*i_getc)(f))==EOF) || nkf_toupper(c1) != p[i] ) {
/* pattern fails, try next one */
q = p;
while (mime_pattern[++j]) {
@@ -5208,7 +4831,7 @@ nkf_char mime_begin_strict(FILE *f)
if (!unbuf_f) {
/* do MIME integrity check */
return mime_integrity(f,mime_pattern[j]);
- }
+ }
}
switch_mime_getc();
mimebuf_f = TRUE;
@@ -5227,7 +4850,7 @@ nkf_char mime_ungetc_buf(nkf_char c, FILE *f)
{
if (mimebuf_f)
(*i_mungetc_buf)(c,f);
- else
+ else
Fifo(--mime_input) = (unsigned char)c;
return c;
}
@@ -5246,8 +4869,8 @@ nkf_char mime_begin(FILE *f)
for(i=2;i<MAXRECOVER;i++) { /* start at =? */
/* We accept any character type even if it is breaked by new lines */
c1 = (*i_getc)(f); Fifo(mime_last++) = (unsigned char)c1;
- if (c1==LF||c1==SP||c1==CR||
- c1=='-'||c1=='_'||is_alnum(c1)) continue;
+ if (c1=='\n'||c1==' '||c1=='\r'||
+ c1=='-'||c1=='_'||is_alnum(c1) ) continue;
if (c1=='=') {
/* Failed. But this could be another MIME preemble */
(*i_ungetc)(c1,f);
@@ -5297,70 +4920,41 @@ void no_putc(nkf_char c)
void debug(const char *str)
{
if (debug_f){
- fprintf(stderr, "%s\n", str ? str : "NULL");
+ fprintf(stderr, "%s\n", str);
}
}
#endif
void set_input_codename(char *codename)
{
- if (!input_codename) {
- input_codename = codename;
- } else if (strcmp(codename, input_codename) != 0) {
- input_codename = "";
- }
-}
-
-static char* get_guessed_code(void)
-{
- if (input_codename && !*input_codename) {
- input_codename = "BINARY";
- } else {
- struct input_code *p = find_inputcode_byfunc(iconv);
- if (!input_codename) {
- input_codename = "ASCII";
- } else if (strcmp(input_codename, "Shift_JIS") == 0) {
- if (p->score & (SCORE_DEPEND|SCORE_CP932))
- input_codename = "CP932";
- } else if (strcmp(input_codename, "EUC-JP") == 0) {
- if (p->score & (SCORE_X0212))
- input_codename = "EUCJP-MS";
- else if (p->score & (SCORE_DEPEND|SCORE_CP932))
- input_codename = "CP51932";
- } else if (strcmp(input_codename, "ISO-2022-JP") == 0) {
- if (p->score & (SCORE_KANA))
- input_codename = "CP50221";
- else if (p->score & (SCORE_DEPEND|SCORE_CP932))
- input_codename = "CP50220";
- }
+ if (guess_f &&
+ is_inputcode_set &&
+ strcmp(codename, "") != 0 &&
+ strcmp(codename, input_codename) != 0)
+ {
+ is_inputcode_mixed = TRUE;
}
- return input_codename;
+ input_codename = codename;
+ is_inputcode_set = TRUE;
}
#if !defined(PERL_XS) && !defined(WIN32DLL)
void print_guessed_code(char *filename)
{
- if (filename != NULL) printf("%s: ", filename);
- if (input_codename && !*input_codename) {
- printf("BINARY\n");
- } else {
- input_codename = get_guessed_code();
- if (guess_f == 1) {
- printf("%s\n", input_codename);
- } else {
- printf("%s%s\n",
- input_codename,
- input_newline == CR ? " (CR)" :
- input_newline == LF ? " (LF)" :
- input_newline == CRLF ? " (CRLF)" :
- input_newline == EOF ? " (MIXED NL)" :
- "");
- }
+ char *codename = "BINARY";
+ if (!is_inputcode_mixed) {
+ if (strcmp(input_codename, "") == 0) {
+ codename = "ASCII";
+ } else {
+ codename = input_codename;
+ }
}
+ if (filename != NULL) printf("%s:", filename);
+ printf("%s\n", codename);
}
#endif /*WIN32DLL*/
-#ifdef INPUT_OPTION
+#ifdef INPUT_OPTION
nkf_char hex_getc(nkf_char ch, FILE *f, nkf_char (*g)(FILE *f), nkf_char (*u)(nkf_char c, FILE *f))
{
@@ -5474,7 +5068,10 @@ nkf_char nfc_getc(FILE *f)
int i=0, j, k=1, lower, upper;
nkf_char buf[9];
const nkf_nfchar *array;
-
+#if 0
+ extern const struct normalization_pair normalization_table[];
+#endif
+
buf[i] = (*g)(f);
while (k > 0 && ((buf[i] & 0xc0) != 0x80)){
lower=0, upper=NORMALIZATION_TABLE_LENGTH-1;
@@ -5510,7 +5107,7 @@ nkf_char nfc_ungetc(nkf_char c, FILE *f)
#endif /* UNICODE_NORMALIZATION */
-nkf_char
+nkf_char
mime_getc(FILE *f)
{
nkf_char c1, c2, c3, c4, cc;
@@ -5536,15 +5133,15 @@ mime_getc(FILE *f)
if (mime_decode_mode == 'Q') {
if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
restart_mime_q:
- if (c1=='_' && mimebuf_f != FIXED_MIME) return SP;
- if (c1<=SP || DEL<=c1) {
+ if (c1=='_' && mimebuf_f != FIXED_MIME) return ' ';
+ if (c1<=' ' || DEL<=c1) {
mime_decode_mode = exit_mode; /* prepare for quit */
return c1;
}
if (c1!='=' && (c1!='?' || mimebuf_f == FIXED_MIME)) {
return c1;
}
-
+
mime_decode_mode = exit_mode; /* prepare for quit */
if ((c2 = (*i_mgetc)(f)) == EOF) return (EOF);
if (c1=='?'&&c2=='=' && mimebuf_f != FIXED_MIME) {
@@ -5558,32 +5155,32 @@ restart_mime_q:
}
while ((c1=(*i_getc)(f))!=EOF) {
switch (c1) {
- case LF:
+ case NL:
case CR:
- if (c1==LF) {
- if ((c1=(*i_getc)(f))!=EOF && (c1==SP||c1==TAB)) {
- i_ungetc(SP,f);
+ if (c1==NL) {
+ if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
+ i_ungetc(SPACE,f);
continue;
} else {
i_ungetc(c1,f);
}
- c1 = LF;
+ c1 = NL;
} else {
- if ((c1=(*i_getc)(f))!=EOF && c1 == LF) {
- if ((c1=(*i_getc)(f))!=EOF && (c1==SP||c1==TAB)) {
- i_ungetc(SP,f);
+ if ((c1=(*i_getc)(f))!=EOF && c1 == NL) {
+ if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
+ i_ungetc(SPACE,f);
continue;
} else {
i_ungetc(c1,f);
}
- i_ungetc(LF,f);
+ i_ungetc(NL,f);
} else {
i_ungetc(c1,f);
}
c1 = CR;
}
break;
- case SP:
+ case SPACE:
case TAB:
lwsp_buf[lwsp_count] = (unsigned char)c1;
if (lwsp_count++>lwsp_size){
@@ -5600,7 +5197,7 @@ restart_mime_q:
}
break;
}
- if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && lwsp_buf[lwsp_count-1] != TAB))) {
+ if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SPACE && lwsp_buf[lwsp_count-1] != TAB))) {
i_ungetc(c1,f);
for(lwsp_count--;lwsp_count>0;lwsp_count--)
i_ungetc(lwsp_buf[lwsp_count],f);
@@ -5609,8 +5206,8 @@ restart_mime_q:
free(lwsp_buf);
return c1;
}
- if (c1=='='&&c2<SP) { /* this is soft wrap */
- while((c1 = (*i_mgetc)(f)) <=SP) {
+ if (c1=='='&&c2<' ') { /* this is soft wrap */
+ while((c1 = (*i_mgetc)(f)) <=' ') {
if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
}
mime_decode_mode = 'Q'; /* still in MIME */
@@ -5622,7 +5219,7 @@ restart_mime_q:
return c1;
}
if ((c3 = (*i_mgetc)(f)) == EOF) return (EOF);
- if (c2<=SP) return c2;
+ if (c2<=' ') return c2;
mime_decode_mode = 'Q'; /* still in MIME */
return ((hex2bin(c2)<<4) + hex2bin(c3));
}
@@ -5634,26 +5231,26 @@ restart_mime_q:
/* Base64 encoding */
- /*
- MIME allows line break in the middle of
+ /*
+ MIME allows line break in the middle of
Base64, but we are very pessimistic in decoding
- in unbuf mode because MIME encoded code may broken by
+ in unbuf mode because MIME encoded code may broken by
less or editor's control sequence (such as ESC-[-K in unbuffered
mode. ignore incomplete MIME.
*/
mode = mime_decode_mode;
mime_decode_mode = exit_mode; /* prepare for quit */
- while ((c1 = (*i_mgetc)(f))<=SP) {
+ while ((c1 = (*i_mgetc)(f))<=' ') {
if (c1==EOF)
return (EOF);
}
mime_c2_retry:
- if ((c2 = (*i_mgetc)(f))<=SP) {
+ if ((c2 = (*i_mgetc)(f))<=' ') {
if (c2==EOF)
return (EOF);
if (mime_f != STRICT_MIME) goto mime_c2_retry;
- if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
return c2;
}
if ((c1 == '?') && (c2 == '=')) {
@@ -5666,35 +5263,35 @@ mime_c2_retry:
}
while ((c1=(*i_getc)(f))!=EOF) {
switch (c1) {
- case LF:
+ case NL:
case CR:
- if (c1==LF) {
- if ((c1=(*i_getc)(f))!=EOF && (c1==SP||c1==TAB)) {
- i_ungetc(SP,f);
+ if (c1==NL) {
+ if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
+ i_ungetc(SPACE,f);
continue;
} else {
i_ungetc(c1,f);
}
- c1 = LF;
+ c1 = NL;
} else {
if ((c1=(*i_getc)(f))!=EOF) {
- if (c1==SP) {
- i_ungetc(SP,f);
+ if (c1==SPACE) {
+ i_ungetc(SPACE,f);
continue;
- } else if ((c1=(*i_getc)(f))!=EOF && (c1==SP||c1==TAB)) {
- i_ungetc(SP,f);
+ } else if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
+ i_ungetc(SPACE,f);
continue;
} else {
i_ungetc(c1,f);
}
- i_ungetc(LF,f);
+ i_ungetc(NL,f);
} else {
i_ungetc(c1,f);
}
c1 = CR;
}
break;
- case SP:
+ case SPACE:
case TAB:
lwsp_buf[lwsp_count] = (unsigned char)c1;
if (lwsp_count++>lwsp_size){
@@ -5711,7 +5308,7 @@ mime_c2_retry:
}
break;
}
- if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && lwsp_buf[lwsp_count-1] != TAB))) {
+ if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SPACE && lwsp_buf[lwsp_count-1] != TAB))) {
i_ungetc(c1,f);
for(lwsp_count--;lwsp_count>0;lwsp_count--)
i_ungetc(lwsp_buf[lwsp_count],f);
@@ -5721,19 +5318,19 @@ mime_c2_retry:
return c1;
}
mime_c3_retry:
- if ((c3 = (*i_mgetc)(f))<=SP) {
+ if ((c3 = (*i_mgetc)(f))<=' ') {
if (c3==EOF)
return (EOF);
if (mime_f != STRICT_MIME) goto mime_c3_retry;
- if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
return c3;
}
mime_c4_retry:
- if ((c4 = (*i_mgetc)(f))<=SP) {
+ if ((c4 = (*i_mgetc)(f))<=' ') {
if (c4==EOF)
return (EOF);
if (mime_f != STRICT_MIME) goto mime_c4_retry;
- if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
return c4;
}
@@ -5752,7 +5349,7 @@ mime_c4_retry:
if (c3 != '=') {
Fifo(mime_last++) = (unsigned char)cc;
cc = ((t3 << 6) & 0x0c0) | (t4 & 0x3f);
- if (c4 != '=')
+ if (c4 != '=')
Fifo(mime_last++) = (unsigned char)cc;
}
} else {
@@ -5775,7 +5372,7 @@ nkf_char mime_integrity(FILE *f, const unsigned char *p)
*/
mime_input = mime_top;
mime_last = mime_top;
-
+
while(*p) Fifo(mime_input++) = *p++;
d = 0;
q = mime_input;
@@ -5787,7 +5384,7 @@ nkf_char mime_integrity(FILE *f, const unsigned char *p)
/* checked. skip header, start decode */
Fifo(mime_input++) = (unsigned char)c;
/* mime_last_input = mime_input; */
- mime_input = q;
+ mime_input = q;
switch_mime_getc();
return 1;
}
@@ -5811,15 +5408,13 @@ nkf_char base64decode(nkf_char c)
if (c > '@') {
if (c < '[') {
i = c - 'A'; /* A..Z 0-25 */
- } else if (c == '_') {
- i = '?' /* 63 */ ; /* _ 63 */
} else {
i = c - 'G' /* - 'a' + 26 */ ; /* a..z 26-51 */
}
} else if (c > '/') {
i = c - '0' + '4' /* - '0' + 52 */ ; /* 0..9 52-61 */
- } else if (c == '+' || c == '-') {
- i = '>' /* 62 */ ; /* + and - 62 */
+ } else if (c == '+') {
+ i = '>' /* 62 */ ; /* + 62 */
} else {
i = '?' /* 63 */ ; /* / 63 */
}
@@ -5833,6 +5428,8 @@ static nkf_char b64c;
#define MIMEOUT_BUF_LENGTH (60)
char mimeout_buf[MIMEOUT_BUF_LENGTH+1];
int mimeout_buf_count = 0;
+int mimeout_preserve_space = 0;
+#define itoh4(c) (c>=10?c+'A'-10:c+'0')
void open_mime(nkf_char mode)
{
@@ -5840,37 +5437,42 @@ void open_mime(nkf_char mode)
int i;
int j;
p = mime_pattern[0];
- for(i=0;mime_pattern[i];i++) {
+ for(i=0;mime_encode[i];i++) {
if (mode == mime_encode[i]) {
p = mime_pattern[i];
break;
}
}
mimeout_mode = mime_encode_method[i];
+
i = 0;
if (base64_count>45) {
if (mimeout_buf_count>0 && nkf_isblank(mimeout_buf[i])){
(*o_mputc)(mimeout_buf[i]);
i++;
}
- PUT_NEWLINE((*o_mputc));
- (*o_mputc)(SP);
+ (*o_mputc)(NL);
+ (*o_mputc)(SPACE);
base64_count = 1;
- if (mimeout_buf_count>0
- && (mimeout_buf[i]==SP || mimeout_buf[i]==TAB
- || mimeout_buf[i]==CR || mimeout_buf[i]==LF)) {
+ if (!mimeout_preserve_space && mimeout_buf_count>0
+ && (mimeout_buf[i]==SPACE || mimeout_buf[i]==TAB
+ || mimeout_buf[i]==CR || mimeout_buf[i]==NL )) {
i++;
}
}
- for (;i<mimeout_buf_count;i++) {
- if (mimeout_buf[i]==SP || mimeout_buf[i]==TAB
- || mimeout_buf[i]==CR || mimeout_buf[i]==LF) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count ++;
- } else {
- break;
+ if (!mimeout_preserve_space) {
+ for (;i<mimeout_buf_count;i++) {
+ if (mimeout_buf[i]==SPACE || mimeout_buf[i]==TAB
+ || mimeout_buf[i]==CR || mimeout_buf[i]==NL ) {
+ (*o_mputc)(mimeout_buf[i]);
+ base64_count ++;
+ } else {
+ break;
+ }
}
}
+ mimeout_preserve_space = FALSE;
+
while(*p) {
(*o_mputc)(*p++);
base64_count ++;
@@ -5908,9 +5510,9 @@ void eof_mime(void)
base64_count += 2;
break;
}
- if (mimeout_mode > 0) {
+ if (mimeout_mode) {
if (mimeout_f!=FIXED_MIME) {
- close_mime();
+ close_mime();
} else if (mimeout_mode != 'Q')
mimeout_mode = 'B';
}
@@ -5920,13 +5522,13 @@ void mimeout_addchar(nkf_char c)
{
switch(mimeout_mode) {
case 'Q':
- if (c==CR||c==LF) {
+ if (c==CR||c==NL) {
(*o_mputc)(c);
base64_count = 0;
} else if(!nkf_isalnum(c)) {
(*o_mputc)('=');
- (*o_mputc)(bin2hex(((c>>4)&0xf)));
- (*o_mputc)(bin2hex((c&0xf)));
+ (*o_mputc)(itoh4(((c>>4)&0xf)));
+ (*o_mputc)(itoh4((c&0xf)));
base64_count += 3;
} else {
(*o_mputc)(c);
@@ -5958,38 +5560,30 @@ void mimeout_addchar(nkf_char c)
}
}
-/*nkf_char mime_lastchar2, mime_lastchar1;*/
+nkf_char mime_lastchar2, mime_lastchar1;
void mime_prechar(nkf_char c2, nkf_char c1)
{
- if (mimeout_mode > 0){
- if (c2 == EOF){
- if (base64_count + mimeout_buf_count/3*4> 73){
+ if (mimeout_mode){
+ if (c2){
+ if (base64_count + mimeout_buf_count/3*4> 66){
(*o_base64conv)(EOF,0);
- OCONV_NEWLINE((*o_base64conv));
- (*o_base64conv)(0,SP);
- base64_count = 1;
+ (*o_base64conv)(0,NL);
+ (*o_base64conv)(0,SPACE);
}
- } else {
- if (base64_count + mimeout_buf_count/3*4> 66) {
- (*o_base64conv)(EOF,0);
- OCONV_NEWLINE((*o_base64conv));
- (*o_base64conv)(0,SP);
- base64_count = 1;
- mimeout_mode = -1;
+ }/*else if (mime_lastchar2){
+ if (c1 <=DEL && !nkf_isspace(c1)){
+ (*o_base64conv)(0,SPACE);
}
+ }*/
+ }/*else{
+ if (c2 && mime_lastchar2 == 0
+ && mime_lastchar1 && !nkf_isspace(mime_lastchar1)){
+ (*o_base64conv)(0,SPACE);
}
- } else if (c2) {
- if (c2 != EOF && base64_count + mimeout_buf_count/3*4> 60) {
- mimeout_mode = (output_mode==ASCII ||output_mode == ISO_8859_1) ? 'Q' : 'B';
- open_mime(output_mode);
- (*o_base64conv)(EOF,0);
- OCONV_NEWLINE((*o_base64conv));
- (*o_base64conv)(0,SP);
- base64_count = 1;
- mimeout_mode = -1;
- }
- }
+ }*/
+ mime_lastchar2 = c2;
+ mime_lastchar1 = c1;
}
void mime_putc(nkf_char c)
@@ -6000,16 +5594,16 @@ void mime_putc(nkf_char c)
if (mimeout_f == FIXED_MIME){
if (mimeout_mode == 'Q'){
if (base64_count > 71){
- if (c!=CR && c!=LF) {
+ if (c!=CR && c!=NL) {
(*o_mputc)('=');
- PUT_NEWLINE((*o_mputc));
+ (*o_mputc)(NL);
}
base64_count = 0;
}
}else{
if (base64_count > 71){
eof_mime();
- PUT_NEWLINE((*o_mputc));
+ (*o_mputc)(NL);
base64_count = 0;
}
if (c == EOF) { /* c==EOF */
@@ -6021,31 +5615,23 @@ void mime_putc(nkf_char c)
}
return;
}
-
+
/* mimeout_f != FIXED_MIME */
if (c == EOF) { /* c==EOF */
- if (mimeout_mode == -1 && mimeout_buf_count > 1) open_mime(output_mode);
j = mimeout_buf_count;
mimeout_buf_count = 0;
i = 0;
- if (mimeout_mode > 0) {
- if (!nkf_isblank(mimeout_buf[j-1])) {
- for (;i<j;i++) {
- if (nkf_isspace(mimeout_buf[i]) && base64_count < 71){
- break;
- }
- mimeout_addchar(mimeout_buf[i]);
- }
- eof_mime();
- for (;i<j;i++) {
- mimeout_addchar(mimeout_buf[i]);
- }
- } else {
- for (;i<j;i++) {
- mimeout_addchar(mimeout_buf[i]);
+ if (mimeout_mode) {
+ for (;i<j;i++) {
+ if (nkf_isspace(mimeout_buf[i]) && base64_count < 71){
+ break;
}
- eof_mime();
+ mimeout_addchar(mimeout_buf[i]);
+ }
+ eof_mime();
+ for (;i<j;i++) {
+ mimeout_addchar(mimeout_buf[i]);
}
} else {
for (;i<j;i++) {
@@ -6055,86 +5641,48 @@ void mime_putc(nkf_char c)
return;
}
- if (mimeout_buf_count > 0){
- lastchar = mimeout_buf[mimeout_buf_count - 1];
- }else{
- lastchar = -1;
- }
-
if (mimeout_mode=='Q') {
- if (c <= DEL && (output_mode==ASCII ||output_mode == ISO_8859_1)) {
- if (c == CR || c == LF) {
- close_mime();
- (*o_mputc)(c);
- base64_count = 0;
- return;
- } else if (c <= SP) {
+ if (c <= DEL && (output_mode==ASCII ||output_mode == ISO8859_1 ) ) {
+ if (c <= SPACE) {
close_mime();
- if (base64_count > 70) {
- PUT_NEWLINE((*o_mputc));
- base64_count = 0;
- }
- if (!nkf_isblank(c)) {
- (*o_mputc)(SP);
- base64_count++;
- }
- } else {
- if (base64_count > 70) {
- close_mime();
- PUT_NEWLINE((*o_mputc));
- (*o_mputc)(SP);
- base64_count = 1;
- open_mime(output_mode);
- }
- if (!nkf_noescape_mime(c)) {
- mimeout_addchar(c);
- return;
- }
- }
- (*o_mputc)(c);
- base64_count++;
+ (*o_mputc)(SPACE);
+ base64_count++;
+ }
+ (*o_mputc)(c);
+ base64_count++;
}
return;
}
- if (mimeout_mode <= 0) {
- if (c <= DEL && (output_mode==ASCII ||output_mode == ISO_8859_1)) {
+ if (mimeout_buf_count > 0){
+ lastchar = mimeout_buf[mimeout_buf_count - 1];
+ }else{
+ lastchar = -1;
+ }
+
+ if (!mimeout_mode) {
+ if (c <= DEL && (output_mode==ASCII ||output_mode == ISO8859_1)) {
if (nkf_isspace(c)) {
- int flag = 0;
- if (mimeout_mode == -1) {
- flag = 1;
- }
- if (c==CR || c==LF) {
- if (flag) {
- open_mime(output_mode);
- output_mode = 0;
- } else {
- base64_count = 0;
- }
+ if (c==CR || c==NL) {
+ base64_count=0;
}
for (i=0;i<mimeout_buf_count;i++) {
(*o_mputc)(mimeout_buf[i]);
- if (mimeout_buf[i] == CR || mimeout_buf[i] == LF){
+ if (mimeout_buf[i] == CR || mimeout_buf[i] == NL){
base64_count = 0;
}else{
base64_count++;
}
}
- if (flag) {
- eof_mime();
- base64_count = 0;
- mimeout_mode = 0;
- }
- mimeout_buf[0] = (char)c;
- mimeout_buf_count = 1;
+ mimeout_buf[0] = (char)c;
+ mimeout_buf_count = 1;
}else{
if (base64_count > 1
- && base64_count + mimeout_buf_count > 76
- && mimeout_buf[0] != CR && mimeout_buf[0] != LF){
- PUT_NEWLINE((*o_mputc));
+ && base64_count + mimeout_buf_count > 76){
+ (*o_mputc)(NL);
base64_count = 0;
if (!nkf_isspace(mimeout_buf[0])){
- (*o_mputc)(SP);
+ (*o_mputc)(SPACE);
base64_count++;
}
}
@@ -6145,33 +5693,33 @@ void mime_putc(nkf_char c)
}
return;
}else{
- if (lastchar==CR || lastchar == LF){
+ if (lastchar==CR || lastchar == NL){
for (i=0;i<mimeout_buf_count;i++) {
(*o_mputc)(mimeout_buf[i]);
}
base64_count = 0;
mimeout_buf_count = 0;
}
- if (lastchar==SP) {
+ if (lastchar==SPACE) {
for (i=0;i<mimeout_buf_count-1;i++) {
(*o_mputc)(mimeout_buf[i]);
base64_count++;
}
- mimeout_buf[0] = SP;
+ mimeout_buf[0] = SPACE;
mimeout_buf_count = 1;
}
open_mime(output_mode);
}
}else{
/* mimeout_mode == 'B', 1, 2 */
- if ( c<=DEL && (output_mode==ASCII ||output_mode == ISO_8859_1)) {
- if (lastchar == CR || lastchar == LF){
+ if ( c<=DEL && (output_mode==ASCII ||output_mode == ISO8859_1 ) ) {
+ if (lastchar == CR || lastchar == NL){
if (nkf_isblank(c)) {
for (i=0;i<mimeout_buf_count;i++) {
mimeout_addchar(mimeout_buf[i]);
}
mimeout_buf_count = 0;
- } else if (SP<c && c<DEL) {
+ } else if (SPACE<c && c<DEL) {
eof_mime();
for (i=0;i<mimeout_buf_count;i++) {
(*o_mputc)(mimeout_buf[i]);
@@ -6179,12 +5727,10 @@ void mime_putc(nkf_char c)
base64_count = 0;
mimeout_buf_count = 0;
}
- mimeout_buf[mimeout_buf_count++] = (char)c;
- return;
}
- if (c==SP || c==TAB || c==CR || c==LF) {
+ if (c==SPACE || c==TAB || c==CR || c==NL) {
for (i=0;i<mimeout_buf_count;i++) {
- if (SP<mimeout_buf[i] && mimeout_buf[i]<DEL) {
+ if (SPACE<mimeout_buf[i] && mimeout_buf[i]<DEL) {
eof_mime();
for (i=0;i<mimeout_buf_count;i++) {
(*o_mputc)(mimeout_buf[i]);
@@ -6203,8 +5749,8 @@ void mime_putc(nkf_char c)
mimeout_buf_count = 0;
}
return;
- }
- if (mimeout_buf_count>0 && SP<c && c!='=') {
+ }
+ if (mimeout_buf_count>0 && SPACE<c && c!='=') {
mimeout_buf[mimeout_buf_count++] = (char)c;
if (mimeout_buf_count>MIMEOUT_BUF_LENGTH) {
j = mimeout_buf_count;
@@ -6221,7 +5767,7 @@ void mime_putc(nkf_char c)
j = mimeout_buf_count;
mimeout_buf_count = 0;
for (i=0;i<j;i++) {
- if (mimeout_buf[i]==CR || mimeout_buf[i]==LF)
+ if (mimeout_buf[i]==CR || mimeout_buf[i]==NL)
break;
mimeout_addchar(mimeout_buf[i]);
}
@@ -6238,6 +5784,7 @@ void mime_putc(nkf_char c)
}
+#if defined(PERL_XS) || defined(WIN32DLL)
void reinit(void)
{
{
@@ -6254,13 +5801,17 @@ void reinit(void)
hira_f = FALSE;
input_f = FALSE;
alpha_f = FALSE;
- mime_f = MIME_DECODE_DEFAULT;
+ mime_f = STRICT_MIME;
mime_decode_f = FALSE;
mimebuf_f = FALSE;
broken_f = FALSE;
iso8859_f = FALSE;
mimeout_f = FALSE;
- x0201_f = X0201_DEFAULT;
+#if defined(MSDOS) || defined(__OS2__)
+ x0201_f = TRUE;
+#else
+ x0201_f = NO_X0201;
+#endif
iso2022jp_f = FALSE;
#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
ms_ucs_map_f = UCS_MAP_ASCII;
@@ -6288,7 +5839,9 @@ void reinit(void)
noout_f = FALSE;
debug_f = FALSE;
#endif
- guess_f = 0;
+ guess_f = FALSE;
+ is_inputcode_mixed = FALSE;
+ is_inputcode_set = FALSE;
#ifdef EXEC_IO
exec_f = 0;
#endif
@@ -6322,7 +5875,7 @@ void reinit(void)
oconv = DEFAULT_CONV;
o_zconv = no_connection;
o_fconv = no_connection;
- o_nlconv = no_connection;
+ o_crconv = no_connection;
o_rot_conv = no_connection;
o_hira_conv = no_connection;
o_base64conv = no_connection;
@@ -6342,9 +5895,7 @@ void reinit(void)
shift_mode = FALSE;
mime_decode_mode = FALSE;
file_out_f = FALSE;
- nlmode_f = 0;
- input_newline = 0;
- prev_cr = 0;
+ crmode_f = 0;
option_mode = 0;
broken_counter = 0;
broken_last = 0;
@@ -6352,12 +5903,12 @@ void reinit(void)
#ifdef CHECK_OPTION
iconv_for_check = 0;
#endif
- input_codename = NULL;
- output_encoding = nkf_enc_from_index(DEFAULT_ENCODING);
+ input_codename = "";
#ifdef WIN32DLL
reinitdll();
#endif /*WIN32DLL*/
}
+#endif
void no_connection(nkf_char c2, nkf_char c1)
{
@@ -6377,131 +5928,113 @@ nkf_char no_connection2(nkf_char c2, nkf_char c1, nkf_char c0)
#endif
void usage(void)
{
- fprintf(HELP_OUTPUT,"USAGE: nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]\n");
- fprintf(HELP_OUTPUT,"Flags:\n");
- fprintf(HELP_OUTPUT,"b,u Output is buffered (DEFAULT),Output is unbuffered\n");
+ fprintf(stderr,"USAGE: nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]\n");
+ fprintf(stderr,"Flags:\n");
+ fprintf(stderr,"b,u Output is buffered (DEFAULT),Output is unbuffered\n");
#ifdef DEFAULT_CODE_SJIS
- fprintf(HELP_OUTPUT,"j,s,e,w Output code is JIS 7 bit, Shift_JIS (DEFAULT), EUC-JP, UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift_JIS (DEFAULT), EUC-JP, UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_JIS
- fprintf(HELP_OUTPUT,"j,s,e,w Output code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit (DEFAULT), Shift JIS, EUC-JP, UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_EUC
- fprintf(HELP_OUTPUT,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP (DEFAULT), UTF-8N\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP (DEFAULT), UTF-8N\n");
#endif
#ifdef DEFAULT_CODE_UTF8
- fprintf(HELP_OUTPUT,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP, UTF-8N (DEFAULT)\n");
+ fprintf(stderr,"j,s,e,w Output code is JIS 7 bit, Shift JIS, EUC-JP, UTF-8N (DEFAULT)\n");
#endif
#ifdef UTF8_OUTPUT_ENABLE
- fprintf(HELP_OUTPUT," After 'w' you can add more options. -w[ 8 [0], 16 [[BL] [0]] ]\n");
+ fprintf(stderr," After 'w' you can add more options. -w[ 8 [0], 16 [[BL] [0]] ]\n");
#endif
- fprintf(HELP_OUTPUT,"J,S,E,W Input assumption is JIS 7 bit , Shift JIS, EUC-JP, UTF-8\n");
+ fprintf(stderr,"J,S,E,W Input assumption is JIS 7 bit , Shift JIS, EUC-JP, UTF-8\n");
#ifdef UTF8_INPUT_ENABLE
- fprintf(HELP_OUTPUT," After 'W' you can add more options. -W[ 8, 16 [BL] ] \n");
-#endif
- fprintf(HELP_OUTPUT,"t no conversion\n");
- fprintf(HELP_OUTPUT,"i[@B] Specify the Esc Seq for JIS X 0208-1978/83 (DEFAULT B)\n");
- fprintf(HELP_OUTPUT,"o[BJH] Specify the Esc Seq for ASCII/Roman (DEFAULT B)\n");
- fprintf(HELP_OUTPUT,"r {de/en}crypt ROT13/47\n");
- fprintf(HELP_OUTPUT,"h 1 katakana->hiragana, 2 hiragana->katakana, 3 both\n");
- fprintf(HELP_OUTPUT,"m[BQN0] MIME decode [B:base64,Q:quoted,N:non-strict,0:no decode]\n");
- fprintf(HELP_OUTPUT,"M[BQ] MIME encode [B:base64 Q:quoted]\n");
- fprintf(HELP_OUTPUT,"l ISO8859-1 (Latin-1) support\n");
- fprintf(HELP_OUTPUT,"f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n");
- fprintf(HELP_OUTPUT,"Z[0-4] Default/0: Convert JISX0208 Alphabet to ASCII\n");
- fprintf(HELP_OUTPUT," 1: Kankaku to one space 2: to two spaces 3: HTML Entity\n");
- fprintf(HELP_OUTPUT," 4: JISX0208 Katakana to JISX0201 Katakana\n");
- fprintf(HELP_OUTPUT,"X,x Assume X0201 kana in MS-Kanji, -x preserves X0201\n");
- fprintf(HELP_OUTPUT,"B[0-2] Broken input 0: missing ESC,1: any X on ESC-[($]-X,2: ASCII on NL\n");
+ fprintf(stderr," After 'W' you can add more options. -W[ 8, 16 [BL] ] \n");
+#endif
+ fprintf(stderr,"t no conversion\n");
+ fprintf(stderr,"i[@B] Specify the Esc Seq for JIS X 0208-1978/83 (DEFAULT B)\n");
+ fprintf(stderr,"o[BJH] Specify the Esc Seq for ASCII/Roman (DEFAULT B)\n");
+ fprintf(stderr,"r {de/en}crypt ROT13/47\n");
+ fprintf(stderr,"h 1 katakana->hiragana, 2 hiragana->katakana, 3 both\n");
+ fprintf(stderr,"v Show this usage. V: show version\n");
+ fprintf(stderr,"m[BQN0] MIME decode [B:base64,Q:quoted,N:non-strict,0:no decode]\n");
+ fprintf(stderr,"M[BQ] MIME encode [B:base64 Q:quoted]\n");
+ fprintf(stderr,"l ISO8859-1 (Latin-1) support\n");
+ fprintf(stderr,"f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n");
+ fprintf(stderr,"Z[0-3] Convert X0208 alphabet to ASCII\n");
+ fprintf(stderr," 1: Kankaku to 1 space 2: to 2 spaces 3: Convert to HTML Entity\n");
+ fprintf(stderr,"X,x Assume X0201 kana in MS-Kanji, -x preserves X0201\n");
+ fprintf(stderr,"B[0-2] Broken input 0: missing ESC,1: any X on ESC-[($]-X,2: ASCII on NL\n");
#ifdef MSDOS
- fprintf(HELP_OUTPUT,"T Text mode output\n");
-#endif
- fprintf(HELP_OUTPUT,"O Output to File (DEFAULT 'nkf.out')\n");
- fprintf(HELP_OUTPUT,"I Convert non ISO-2022-JP charactor to GETA\n");
- fprintf(HELP_OUTPUT,"d,c Convert line breaks -d: LF -c: CRLF\n");
- fprintf(HELP_OUTPUT,"-L[uwm] line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n");
- fprintf(HELP_OUTPUT,"v, V Show this usage. V: show configuration\n");
- fprintf(HELP_OUTPUT,"\n");
- fprintf(HELP_OUTPUT,"Long name options\n");
- fprintf(HELP_OUTPUT," --ic=<input codeset> --oc=<output codeset>\n");
- fprintf(HELP_OUTPUT," Specify the input or output codeset\n");
- fprintf(HELP_OUTPUT," --fj --unix --mac --windows\n");
- fprintf(HELP_OUTPUT," --jis --euc --sjis --utf8 --utf16 --mime --base64\n");
- fprintf(HELP_OUTPUT," Convert for the system or code\n");
- fprintf(HELP_OUTPUT," --hiragana --katakana --katakana-hiragana\n");
- fprintf(HELP_OUTPUT," To Hiragana/Katakana Conversion\n");
- fprintf(HELP_OUTPUT," --prefix= Insert escape before troublesome characters of Shift_JIS\n");
+ fprintf(stderr,"T Text mode output\n");
+#endif
+ fprintf(stderr,"O Output to File (DEFAULT 'nkf.out')\n");
+ fprintf(stderr,"I Convert non ISO-2022-JP charactor to GETA\n");
+ fprintf(stderr,"d,c Convert line breaks -d: LF -c: CRLF\n");
+ fprintf(stderr,"-L[uwm] line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n");
+ fprintf(stderr,"\n");
+ fprintf(stderr,"Long name options\n");
+ fprintf(stderr," --ic=<input codeset> --oc=<output codeset>\n");
+ fprintf(stderr," Specify the input or output codeset\n");
+ fprintf(stderr," --fj --unix --mac --windows\n");
+ fprintf(stderr," --jis --euc --sjis --utf8 --utf16 --mime --base64\n");
+ fprintf(stderr," Convert for the system or code\n");
+ fprintf(stderr," --hiragana --katakana --katakana-hiragana\n");
+ fprintf(stderr," To Hiragana/Katakana Conversion\n");
+ fprintf(stderr," --prefix= Insert escape before troublesome characters of Shift_JIS\n");
#ifdef INPUT_OPTION
- fprintf(HELP_OUTPUT," --cap-input, --url-input Convert hex after ':' or '%%'\n");
+ fprintf(stderr," --cap-input, --url-input Convert hex after ':' or '%%'\n");
#endif
#ifdef NUMCHAR_OPTION
- fprintf(HELP_OUTPUT," --numchar-input Convert Unicode Character Reference\n");
+ fprintf(stderr," --numchar-input Convert Unicode Character Reference\n");
#endif
#ifdef UTF8_INPUT_ENABLE
- fprintf(HELP_OUTPUT," --fb-{skip, html, xml, perl, java, subchar}\n");
- fprintf(HELP_OUTPUT," Specify how nkf handles unassigned characters\n");
+ fprintf(stderr," --fb-{skip, html, xml, perl, java, subchar}\n");
+ fprintf(stderr," Specify how nkf handles unassigned characters\n");
#endif
#ifdef OVERWRITE
- fprintf(HELP_OUTPUT," --in-place[=SUFFIX] --overwrite[=SUFFIX]\n");
- fprintf(HELP_OUTPUT," Overwrite original listed files by filtered result\n");
- fprintf(HELP_OUTPUT," --overwrite preserves timestamp of original files\n");
-#endif
- fprintf(HELP_OUTPUT," -g --guess Guess the input code\n");
- fprintf(HELP_OUTPUT," --help --version Show this help/the version\n");
- fprintf(HELP_OUTPUT," For more information, see also man nkf\n");
- fprintf(HELP_OUTPUT,"\n");
+ fprintf(stderr," --in-place[=SUFFIX] --overwrite[=SUFFIX]\n");
+ fprintf(stderr," Overwrite original listed files by filtered result\n");
+ fprintf(stderr," --overwrite preserves timestamp of original files\n");
+#endif
+ fprintf(stderr," -g --guess Guess the input code\n");
+ fprintf(stderr," --help --version Show this help/the version\n");
+ fprintf(stderr," For more information, see also man nkf\n");
+ fprintf(stderr,"\n");
version();
}
-void show_configuration(void)
+void version(void)
{
- fprintf(HELP_OUTPUT, "Summary of my nkf " NKF_VERSION " (" NKF_RELEASE_DATE ") configuration:\n");
- fprintf(HELP_OUTPUT, " Compile-time options:\n");
- fprintf(HELP_OUTPUT, " Default output encoding: "
-#if defined(DEFAULT_CODE_JIS)
- "ISO-2022-JP"
-#elif defined(DEFAULT_CODE_SJIS)
- "Shift_JIS"
-#elif defined(DEFAULT_CODE_EUC)
- "EUC-JP"
-#elif defined(DEFAULT_CODE_UTF8)
- "UTF-8"
-#endif
- "\n");
- fprintf(HELP_OUTPUT, " Default output newline: "
-#if DEFAULT_NEWLINE == CR
- "CR"
-#elif DEFAULT_NEWLINE == CRLF
- "CRLF"
-#else
- "LF"
+ fprintf(stderr,"Network Kanji Filter Version %s (%s) "
+#if defined(MSDOS) && !defined(__WIN32__) && !defined(__WIN16__) && !defined(__OS2__)
+ "for DOS"
#endif
- "\n");
- fprintf(HELP_OUTPUT, " Decode MIME encoded string: "
-#if MIME_DECODE_DEFAULT
- "ON"
-#else
- "OFF"
+#if defined(MSDOS) && defined(__WIN16__)
+ "for Win16"
#endif
- "\n");
- fprintf(HELP_OUTPUT, " Convert JIS X 0201 Katakana: "
-#if X0201_DEFAULT
- "ON"
-#else
- "OFF"
+#if defined(MSDOS) && defined(__WIN32__)
+ "for Win32"
#endif
- "\n");
-fprintf(HELP_OUTPUT, " --help, --version output: "
-#if HELP_OUTPUT_HELP_OUTPUT
-"HELP_OUTPUT"
-#else
-"STDOUT"
+#ifdef __OS2__
+ "for OS/2"
#endif
-"\n");
-}
-
-void version(void)
-{
- fprintf(HELP_OUTPUT,"Network Kanji Filter Version " NKF_VERSION " (" NKF_RELEASE_DATE ") \n" COPY_RIGHT "\n");
+ ,NKF_VERSION,NKF_RELEASE_DATE);
+ fprintf(stderr,"\n%s\n",CopyRight);
}
#endif /*PERL_XS*/
+
+/**
+ ** $B%Q%C%A@):n<T(B
+ ** void@merope.pleiades.or.jp (Kusakabe Youichi)
+ ** NIDE Naoyuki <nide@ics.nara-wu.ac.jp>
+ ** ohta@src.ricoh.co.jp (Junn Ohta)
+ ** inouet@strl.nhk.or.jp (Tomoyuki Inoue)
+ ** kiri@pulser.win.or.jp (Tetsuaki Kiriyama)
+ ** Kimihiko Sato <sato@sail.t.u-tokyo.ac.jp>
+ ** a_kuroe@kuroe.aoba.yokohama.jp (Akihiko Kuroe)
+ ** kono@ie.u-ryukyu.ac.jp (Shinji Kono)
+ ** GHG00637@nifty-serve.or.jp (COW)
+ **
+ **/
+
+/* end */
diff --git a/ext/nkf/nkf-utf8/utf8tbl.c b/ext/nkf/nkf-utf8/utf8tbl.c
index fb6c3b7362..e43ad553d6 100644
--- a/ext/nkf/nkf-utf8/utf8tbl.c
+++ b/ext/nkf/nkf-utf8/utf8tbl.c
@@ -201,20 +201,6 @@ const unsigned short euc_to_utf8_AC[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
};
-const unsigned short euc_to_utf8_AC_mac[] = {
- 0x2664, 0x2667, 0x2661, 0x2662, 0x2660, 0x2663, 0x2665,
- 0x2666, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x3020, 0x260E, 0x3004,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x261E, 0x261C, 0x261D, 0x261F, 0x21C6, 0x21C4, 0x21C5,
- 0, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0x2192, 0x2190, 0x2191,
- 0x2193, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,
-};
const unsigned short euc_to_utf8_AD[] = {
0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
@@ -229,20 +215,6 @@ const unsigned short euc_to_utf8_AD[] = {
0x2252, 0x2261, 0x222B, 0x222E, 0x2211, 0x221A, 0x22A5, 0x2220,
0x221F, 0x22BF, 0x2235, 0x2229, 0x222A, 0, 0x3299,
};
-const unsigned short euc_to_utf8_AD_mac[] = {
- 0x65E5, 0x6708, 0x706B, 0x6C34, 0x6728, 0x91D1, 0x571F,
- 0x796D, 0x795D, 0x81EA, 0x81F3, 0x3239, 0x547C, 0x3231, 0x8CC7,
- 0x540D, 0x3232, 0x5B66, 0x8CA1, 0x793E, 0x7279, 0x76E3, 0x4F01,
- 0x5354, 0x52B4, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0,
- 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
- 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
- 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x337B,
- 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
- 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
- 0x2252, 0x5927, 0x5C0F, 0x32A4, 0x32A5, 0x32A6, 0x32A7, 0x32A8,
- 0x533B, 0x8CA1, 0x512A, 0x52B4, 0x5370, 0x63A7, 0x79D8,
-};
const unsigned short euc_to_utf8_AE[] = {
0x3349, 0x3322, 0x334D, 0x3314, 0x3316, 0x3305, 0x3333,
0x334E, 0x3303, 0x3336, 0x3318, 0x3315, 0x3327, 0x3351, 0x334A,
@@ -2374,33 +2346,6 @@ const unsigned short *const euc_to_utf8_2bytes_ms[] = {
0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
euc_to_utf8_FC_ms, 0, 0,
};
-/* CP10001 */
-const unsigned short *const euc_to_utf8_2bytes_mac[] = {
- euc_to_utf8_A1_ms, euc_to_utf8_A2_ms, euc_to_utf8_A3,
- euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
- euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
- euc_to_utf8_AC_mac, euc_to_utf8_AD_mac, euc_to_utf8_AE, euc_to_utf8_AF,
- euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
- euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
- euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
- euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
- euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
- euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
- euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
- euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
- euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
- euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
- euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
- euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
- euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
- euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
- euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
- euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
- euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
- euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
- 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
- euc_to_utf8_FC_ms, 0, 0,
-};
#ifdef X0212_ENABLE
const unsigned short *const x0212_to_utf8_2bytes[] = {
@@ -2452,16 +2397,6 @@ const unsigned short utf8_to_euc_C2_ms[] = {
0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
};
-const unsigned short utf8_to_euc_C2_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x0220, 0xA242, 0x2171, 0x2172, 0xA270, 0x5C, 0xA243, 0x2178,
- 0x212F, 0x027D, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
- 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
- 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
-};
const unsigned short utf8_to_euc_C2_932[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2612,16 +2547,6 @@ const unsigned short utf8_to_euc_E284[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E284_mac[] = {
- 0, 0, 0, 0x216E, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2B7B, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2B7D, 0x027E, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2272, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E285[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2632,16 +2557,6 @@ const unsigned short utf8_to_euc_E285[] = {
0xF373, 0xF374, 0xF375, 0xF376, 0xF377, 0xF378, 0xF379, 0xF37A,
0xF37B, 0xF37C, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E285_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2A21, 0x2A22, 0x2A23, 0x2A24, 0x2A25, 0x2A26, 0x2A27, 0x2A28,
- 0x2A29, 0x2A2A, 0, 0, 0, 0, 0, 0,
- 0x2A35, 0x2A36, 0x2A37, 0x2A38, 0x2A39, 0x2A3A, 0x2A3B, 0x2A3C,
- 0x2A3D, 0x2A3E, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E286[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2682,16 +2597,6 @@ const unsigned short utf8_to_euc_E288_932[] = {
0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
0, 0, 0, 0, 0, 0x2266, 0, 0,
};
-const unsigned short utf8_to_euc_E288_mac[] = {
- 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
- 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2F22,
- 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
- 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2F21, 0,
- 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
- 0, 0, 0, 0, 0, 0x2266, 0, 0,
-};
const unsigned short utf8_to_euc_E289[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2712,16 +2617,6 @@ const unsigned short utf8_to_euc_E28A[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0x2D79,
};
-const unsigned short utf8_to_euc_E28A_mac[] = {
- 0, 0, 0x223E, 0x223F, 0, 0, 0x223C, 0x223D,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x225D, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0x2F23,
-};
const unsigned short utf8_to_euc_E28C[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2742,16 +2637,6 @@ const unsigned short utf8_to_euc_E291[] = {
0x2D31, 0x2D32, 0x2D33, 0x2D34, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E291_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0x2921, 0x2922, 0x2923, 0x2924, 0x2925, 0x2926, 0x2927, 0x2928,
- 0x2929, 0x292A, 0x292B, 0x292C, 0x292D, 0x292E, 0x292F, 0x2930,
- 0x2931, 0x2932, 0x2933, 0x2934, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E294[] = {
0x2821, 0x282C, 0x2822, 0x282D, 0, 0, 0, 0,
0, 0, 0, 0, 0x2823, 0, 0, 0x282E,
@@ -2882,16 +2767,6 @@ const unsigned short utf8_to_euc_E388[] = {
0, 0x2D6A, 0x2D6B, 0, 0, 0, 0, 0,
0, 0x2D6C, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E388_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2D2E, 0x2D31, 0, 0, 0, 0, 0,
- 0, 0x2D2C, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E38A[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2902,16 +2777,6 @@ const unsigned short utf8_to_euc_E38A[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E38A_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2D73, 0x2D74, 0x2D75, 0x2D76,
- 0x2D77, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E38C[] = {
0, 0, 0, 0x2D46, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0x2D4A, 0, 0,
@@ -2922,16 +2787,6 @@ const unsigned short utf8_to_euc_E38C[] = {
0, 0, 0, 0, 0, 0, 0x2D47, 0,
0, 0, 0, 0x2D4F, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E38C_mac[] = {
- 0, 0, 0, 0x2E29, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2E32, 0, 0,
- 0, 0, 0, 0, 0x2E24, 0, 0, 0,
- 0x2E2B, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2E22, 0x2E34, 0, 0, 0x2E35, 0x2E2D,
- 0, 0, 0, 0x2E37, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2E2A, 0,
- 0, 0, 0, 0x2E36, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E38D[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0x2D40, 0x2D4E, 0, 0, 0x2D43, 0, 0,
@@ -2942,16 +2797,6 @@ const unsigned short utf8_to_euc_E38D[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0x2D5F, 0x2D6F, 0x2D6E, 0x2D6D, 0,
};
-const unsigned short utf8_to_euc_E38D_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0x2E21, 0x2E2F, 0, 0, 0x2E23, 0, 0,
- 0, 0x2E2E, 0, 0, 0, 0, 0, 0x2E31,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0x2E6A, 0x2E69, 0x2E68, 0x2E67, 0,
-};
const unsigned short utf8_to_euc_E38E[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0x2D53, 0x2D54,
@@ -2962,16 +2807,6 @@ const unsigned short utf8_to_euc_E38E[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E38E_mac[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0x2B2B, 0x2B2D,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2B21, 0x2B23, 0x2B29, 0,
- 0, 0x2B27, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E38F[] = {
0, 0, 0, 0, 0x2D55, 0, 0, 0,
0, 0, 0, 0, 0, 0x2D63, 0, 0,
@@ -2982,16 +2817,6 @@ const unsigned short utf8_to_euc_E38F[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
-const unsigned short utf8_to_euc_E38F_mac[] = {
- 0, 0, 0, 0, 0x2B2E, 0, 0, 0,
- 0, 0, 0, 0, 0, 0x2B7C, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
const unsigned short utf8_to_euc_E4B8[] = {
0x306C, 0x437A, 0xB021, 0x3C37, 0xB022, 0xB023, 0, 0x4B7C,
0x3E66, 0x3B30, 0x3E65, 0x323C, 0xB024, 0x4954, 0x4D3F, 0,
@@ -6346,24 +6171,6 @@ const unsigned short *const utf8_to_euc_E2_932[] = {
0, 0, 0, 0,
0, 0, 0, 0,
};
-const unsigned short *const utf8_to_euc_E2_mac[] = {
- utf8_to_euc_E280_932, 0, 0, 0,
- utf8_to_euc_E284_mac, utf8_to_euc_E285_mac, utf8_to_euc_E286, utf8_to_euc_E287,
- utf8_to_euc_E288_mac, utf8_to_euc_E289, utf8_to_euc_E28A_mac, 0,
- utf8_to_euc_E28C, 0, 0, 0,
- 0, utf8_to_euc_E291_mac, 0, 0,
- utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296, utf8_to_euc_E297,
- utf8_to_euc_E298, utf8_to_euc_E299, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
const unsigned short *const utf8_to_euc_E3[] = {
utf8_to_euc_E380, utf8_to_euc_E381, utf8_to_euc_E382, utf8_to_euc_E383,
0, 0, 0, 0,
@@ -6400,24 +6207,6 @@ const unsigned short *const utf8_to_euc_E3_932[] = {
0, 0, 0, 0,
0, 0, 0, 0,
};
-const unsigned short *const utf8_to_euc_E3_mac[] = {
- utf8_to_euc_E380_932, utf8_to_euc_E381, utf8_to_euc_E382_932, utf8_to_euc_E383,
- 0, 0, 0, 0,
- utf8_to_euc_E388_mac, 0, utf8_to_euc_E38A_mac, 0,
- utf8_to_euc_E38C_mac, utf8_to_euc_E38D_mac, utf8_to_euc_E38E_mac, utf8_to_euc_E38F_mac,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
const unsigned short *const utf8_to_euc_E4[] = {
0, 0, 0, 0,
0, 0, 0, 0,
@@ -6652,36 +6441,6 @@ const unsigned short *const utf8_to_euc_2bytes_932[] = {
0, 0, 0, 0,
0, 0, 0, 0,
};
-const unsigned short *const utf8_to_euc_2bytes_mac[] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, utf8_to_euc_C2_mac, utf8_to_euc_C3,
- utf8_to_euc_C4, utf8_to_euc_C5, 0, utf8_to_euc_C7,
- 0, 0, 0, utf8_to_euc_CB,
- 0, 0, utf8_to_euc_CE, utf8_to_euc_CF,
- utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
const unsigned short *const *const utf8_to_euc_3bytes[] = {
0, 0, utf8_to_euc_E2, utf8_to_euc_E3,
utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
@@ -6700,12 +6459,6 @@ const unsigned short *const *const utf8_to_euc_3bytes_932[] = {
utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
0, 0, 0, utf8_to_euc_EF_ms,
};
-const unsigned short *const *const utf8_to_euc_3bytes_mac[] = {
- 0, 0, utf8_to_euc_E2_mac, utf8_to_euc_E3_mac,
- utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
- utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
- 0, 0, 0, utf8_to_euc_EF_ms,
-};
#ifdef UNICODE_NORMALIZATION
diff --git a/ext/nkf/nkf-utf8/utf8tbl.h b/ext/nkf/nkf-utf8/utf8tbl.h
index 29413d4fac..1f40f0b363 100644
--- a/ext/nkf/nkf-utf8/utf8tbl.h
+++ b/ext/nkf/nkf-utf8/utf8tbl.h
@@ -5,7 +5,6 @@
extern const unsigned short euc_to_utf8_1byte[];
extern const unsigned short *const euc_to_utf8_2bytes[];
extern const unsigned short *const euc_to_utf8_2bytes_ms[];
-extern const unsigned short *const euc_to_utf8_2bytes_mac[];
extern const unsigned short *const x0212_to_utf8_2bytes[];
#endif /* UTF8_OUTPUT_ENABLE */
@@ -13,11 +12,9 @@ extern const unsigned short *const x0212_to_utf8_2bytes[];
extern const unsigned short *const utf8_to_euc_2bytes[];
extern const unsigned short *const utf8_to_euc_2bytes_ms[];
extern const unsigned short *const utf8_to_euc_2bytes_932[];
-extern const unsigned short *const utf8_to_euc_2bytes_mac[];
extern const unsigned short *const *const utf8_to_euc_3bytes[];
extern const unsigned short *const *const utf8_to_euc_3bytes_ms[];
extern const unsigned short *const *const utf8_to_euc_3bytes_932[];
-extern const unsigned short *const *const utf8_to_euc_3bytes_mac[];
#endif /* UTF8_INPUT_ENABLE */
#ifdef UNICODE_NORMALIZATION
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 703315834e..2bb0340a64 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -10,8 +10,24 @@
#define RUBY_NKF_REVISION "$Revision$"
#define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
-#include "ruby/ruby.h"
-#include "ruby/encoding.h"
+#include "ruby.h"
+
+/* Encoding Constants */
+#define _AUTO 0
+#define _JIS 1
+#define _EUC 2
+#define _SJIS 3
+#define _BINARY 4
+#define _NOCONV 4
+#define _ASCII 5
+/* 0b011x is reserved for UTF-8 Family */
+#define _UTF8 6
+/* 0b10xx is reserved for UTF-16 Family */
+#define _UTF16 8
+/* 0b11xx is reserved for UTF-32 Family */
+#define _UTF32 12
+#define _OTHER 16
+#define _UNKNOWN _AUTO
/* Replace nkf's getchar/putchar for variable modification */
/* we never use getc, ungetc */
@@ -40,13 +56,14 @@ static int incsize;
static VALUE result;
static int
-rb_nkf_putchar(unsigned int c)
+rb_nkf_putchar(c)
+ unsigned int c;
{
if (output_ctr >= o_len) {
o_len += incsize;
rb_str_resize(result, o_len);
incsize *= 2;
- output = (unsigned char *)RSTRING_PTR(result);
+ output = (unsigned char *)RSTRING(result)->ptr;
}
output[output_ctr++] = c;
@@ -61,24 +78,8 @@ rb_nkf_putchar(unsigned int c)
#include "nkf-utf8/utf8tbl.c"
#include "nkf-utf8/nkf.c"
-rb_encoding* rb_nkf_enc_get(const char *name)
-{
- int idx = rb_enc_find_index(name);
- if (idx < 0) {
- nkf_encoding *nkf_enc = nkf_enc_find(name);
- nkf_native_encoding * nkf_base_enc = nkf_enc_to_base_encoding(nkf_enc);
- idx = rb_enc_find_index(nkf_enc_name(nkf_base_enc));
- if (idx < 0) {
- idx = rb_define_dummy_encoding(name);
- } else {
- rb_encoding *rb_enc = rb_enc_from_index(idx);
- idx = rb_enc_replicate(name, rb_enc);
- }
- }
- return rb_enc_from_index(idx);
-}
-
-int nkf_split_options(const char *arg)
+int nkf_split_options(arg)
+ const char* arg;
{
int count = 0;
char option[256];
@@ -141,62 +142,221 @@ int nkf_split_options(const char *arg)
*/
static VALUE
-rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
+rb_nkf_kconv(obj, opt, src)
+ VALUE obj, opt, src;
{
- rb_encoding *to_enc;
- const char *to_e;
- int to_encidx;
-
- reinit();
- StringValue(opt);
- nkf_split_options(RSTRING_PTR(opt));
-
- incsize = INCSIZE;
-
- input_ctr = 0;
- StringValue(src);
- input = (unsigned char *)RSTRING_PTR(src);
- i_len = RSTRING_LEN(src);
- result = rb_str_new(0, i_len*3 + 10);
-
- output_ctr = 0;
- output = (unsigned char *)RSTRING_PTR(result);
- o_len = RSTRING_LEN(result);
- *output = '\0';
+ char *opt_ptr, *opt_end;
+ volatile VALUE v;
+
+ reinit();
+ StringValue(opt);
+ opt_ptr = RSTRING(opt)->ptr;
+ opt_end = opt_ptr + RSTRING(opt)->len;
+ nkf_split_options(opt_ptr);
+
+ incsize = INCSIZE;
+
+ input_ctr = 0;
+ StringValue(src);
+ input = (unsigned char *)RSTRING(src)->ptr;
+ i_len = RSTRING(src)->len;
+ result = rb_str_new(0, i_len*3 + 10);
+ v = result;
+
+ output_ctr = 0;
+ output = (unsigned char *)RSTRING(result)->ptr;
+ o_len = RSTRING(result)->len;
+ *output = '\0';
+
+ if(x0201_f == WISH_TRUE)
+ x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
+
+ kanji_convert(NULL);
+ RSTRING(result)->ptr[output_ctr] = '\0';
+ RSTRING(result)->len = output_ctr;
+ OBJ_INFECT(result, src);
+
+ return result;
+}
- kanji_convert(NULL);
- rb_str_set_len(result, output_ctr);
- OBJ_INFECT(result, src);
- rb_enc_associate(result, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
+/*
+ * call-seq:
+ * NKF.guess1(str) -> integer
+ *
+ * Returns guessed encoding of _str_ as integer.
+ *
+ * Algorithm described in:
+ * Ken Lunde. `Understanding Japanese Information Processing'
+ * Sebastopol, CA: O'Reilly & Associates.
+ *
+ * case NKF.guess1(input)
+ * when NKF::JIS
+ * "ISO-2022-JP"
+ * when NKF::SJIS
+ * "Shift_JIS"
+ * when NKF::EUC
+ * "EUC-JP"
+ * when NKF::UNKNOWN
+ * "UNKNOWN(ASCII)"
+ * when NKF::BINARY
+ * "BINARY"
+ * end
+ */
- return result;
+static VALUE
+rb_nkf_guess1(obj, src)
+ VALUE obj, src;
+{
+ unsigned char *p;
+ unsigned char *pend;
+ int sequence_counter = 0;
+
+ StringValue(src);
+ p = (unsigned char *)RSTRING(src)->ptr;
+ pend = p + RSTRING(src)->len;
+ if (p == pend) return INT2FIX(_UNKNOWN);
+
+#define INCR do {\
+ p++;\
+ if (p==pend) return INT2FIX(_UNKNOWN);\
+ sequence_counter++;\
+ if (sequence_counter % 2 == 1 && *p != 0xa4)\
+ sequence_counter = 0;\
+ if (6 <= sequence_counter) {\
+ sequence_counter = 0;\
+ return INT2FIX(_EUC);\
+ }\
+ } while (0)
+
+ if (*p == 0xa4)
+ sequence_counter = 1;
+
+ while (p<pend) {
+ if (*p == '\033') {
+ return INT2FIX(_JIS);
+ }
+ if (*p < '\006' || *p == 0x7f || *p == 0xff) {
+ return INT2FIX(_BINARY);
+ }
+ if (0x81 <= *p && *p <= 0x8d) {
+ return INT2FIX(_SJIS);
+ }
+ if (0x8f <= *p && *p <= 0x9f) {
+ return INT2FIX(_SJIS);
+ }
+ if (*p == 0x8e) { /* SS2 */
+ INCR;
+ if ((0x40 <= *p && *p <= 0x7e) ||
+ (0x80 <= *p && *p <= 0xa0) ||
+ (0xe0 <= *p && *p <= 0xfc))
+ return INT2FIX(_SJIS);
+ }
+ else if (0xa1 <= *p && *p <= 0xdf) {
+ INCR;
+ if (0xf0 <= *p && *p <= 0xfe)
+ return INT2FIX(_EUC);
+ if (0xe0 <= *p && *p <= 0xef) {
+ while (p < pend && *p >= 0x40) {
+ if (*p >= 0x81) {
+ if (*p <= 0x8d || (0x8f <= *p && *p <= 0x9f)) {
+ return INT2FIX(_SJIS);
+ }
+ else if (0xfd <= *p && *p <= 0xfe) {
+ return INT2FIX(_EUC);
+ }
+ }
+ INCR;
+ }
+ }
+ else if (*p <= 0x9f) {
+ return INT2FIX(_SJIS);
+ }
+ }
+ else if (0xf0 <= *p && *p <= 0xfe) {
+ return INT2FIX(_EUC);
+ }
+ else if (0xe0 <= *p && *p <= 0xef) {
+ INCR;
+ if ((0x40 <= *p && *p <= 0x7e) ||
+ (0x80 <= *p && *p <= 0xa0)) {
+ return INT2FIX(_SJIS);
+ }
+ if (0xfd <= *p && *p <= 0xfe) {
+ return INT2FIX(_EUC);
+ }
+ }
+ INCR;
+ }
+ return INT2FIX(_UNKNOWN);
}
/*
* call-seq:
- * NKF.guess(str) -> encoding
- *
- * Returns guessed encoding of _str_ by nkf routine.
- *
+ * NKF.guess2(str) -> integer
+ *
+ * Returns guessed encoding of _str_ as integer by nkf routine.
+ *
+ * case NKF.guess(input)
+ * when NKF::ASCII
+ * "ASCII"
+ * when NKF::JIS
+ * "ISO-2022-JP"
+ * when NKF::SJIS
+ * "Shift_JIS"
+ * when NKF::EUC
+ * "EUC-JP"
+ * when NKF::UTF8
+ * "UTF-8"
+ * when NKF::UTF16
+ * "UTF-16"
+ * when NKF::UNKNOWN
+ * "UNKNOWN"
+ * when NKF::BINARY
+ * "BINARY"
+ * end
*/
static VALUE
-rb_nkf_guess(VALUE obj, VALUE src)
+rb_nkf_guess2(obj, src)
+ VALUE obj, src;
{
- reinit();
-
- input_ctr = 0;
- StringValue(src);
- input = (unsigned char *)RSTRING_PTR(src);
- i_len = RSTRING_LEN(src);
-
- guess_f = TRUE;
- kanji_convert( NULL );
- guess_f = FALSE;
+ int code = _BINARY;
+
+ reinit();
+
+ input_ctr = 0;
+ StringValue(src);
+ input = (unsigned char *)RSTRING(src)->ptr;
+ i_len = RSTRING(src)->len;
+
+ if(x0201_f == WISH_TRUE)
+ x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
+
+ guess_f = TRUE;
+ kanji_convert( NULL );
+ guess_f = FALSE;
+
+ if (!is_inputcode_mixed) {
+ if (strcmp(input_codename, "") == 0) {
+ code = _ASCII;
+ } else if (strcmp(input_codename, "ISO-2022-JP") == 0) {
+ code = _JIS;
+ } else if (strcmp(input_codename, "EUC-JP") == 0) {
+ code = _EUC;
+ } else if (strcmp(input_codename, "Shift_JIS") == 0) {
+ code = _SJIS;
+ } else if (strcmp(input_codename, "UTF-8") == 0) {
+ code = _UTF8;
+ } else if (strcmp(input_codename, "UTF-16") == 0) {
+ code = _UTF16;
+ } else if (strlen(input_codename) > 0) {
+ code = _UNKNOWN;
+ }
+ }
- return rb_enc_from_encoding(rb_nkf_enc_get(get_guessed_code()));
+ return INT2FIX( code );
}
@@ -205,8 +365,8 @@ rb_nkf_guess(VALUE obj, VALUE src)
*
* == Description
*
- * This is a Ruby Extension version of nkf (Network Kanji Filter).
- * It converts the first argument and returns converted result. Conversion
+ * This is a Ruby Extension version of nkf (Netowrk Kanji Filter).
+ * It converts the first argument and return converted result. Conversion
* details are specified by flags as the first argument.
*
* *Nkf* is a yet another kanji code converter among networks, hosts and terminals.
@@ -228,16 +388,16 @@ rb_nkf_guess(VALUE obj, VALUE src)
*
* Output is buffered (DEFAULT), Output is unbuffered.
*
- * === -j -s -e -w -w16 -w32
+ * === -j -s -e -w -w16
*
* Output code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
- * UTF-8N, UTF-16BE, UTF-32BE.
+ * UTF-8N, UTF-16BE.
* Without this option and compile option, ISO-2022-JP is assumed.
*
- * === -J -S -E -W -W16 -W32
+ * === -J -S -E -W -W16
*
* Input assumption is JIS 7 bit, Shift_JIS, EUC-JP,
- * UTF-8, UTF-16, UTF-32.
+ * UTF-8, UTF-16LE.
*
* ==== -J
*
@@ -420,16 +580,6 @@ rb_nkf_guess(VALUE obj, VALUE src)
*
* [UTF-16LE-BOM] UTF-16 Little Endian with BOM
*
- * [UTF-32] same as UTF-32BE
- *
- * [UTF-32BE] UTF-32 Big Endian without BOM
- *
- * [UTF-32BE-BOM] UTF-32 Big Endian with BOM
- *
- * [UTF-32LE] UTF-32 Little Endian without BOM
- *
- * [UTF-32LE-BOM] UTF-32 Little Endian with BOM
- *
* [UTF8-MAC] NKDed UTF-8, a.k.a. UTF8-NFD (input only)
*
* === --fb-{skip, html, xml, perl, java, subchar}
@@ -443,20 +593,10 @@ rb_nkf_guess(VALUE obj, VALUE src)
* nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
* 1st byte of argument is the escape character and following bytes are target characters.
*
- * === --no-cp932ext
+ * === --disable-cp932ext
*
* Handle the characters extended in CP932 as unassigned characters.
*
- * == --no-best-fit-chars
- *
- * When Unicode to Encoded byte conversion,
- * don't convert characters which is not round trip safe.
- * When Unicode to Unicode conversion,
- * with this and -x option, nkf can be used as UTF converter.
- * (In other words, without this and -x option, nkf doesn't save some characters)
- *
- * When nkf convert string which related to path, you should use this opion.
- *
* === --cap-input
*
* Decode hex encoded characters.
@@ -474,29 +614,41 @@ void
Init_nkf()
{
/* hoge */
- VALUE mNKF = rb_define_module("NKF");
+ VALUE mKconv = rb_define_module("NKF");
/* hoge */
- rb_define_module_function(mNKF, "nkf", rb_nkf_convert, 2);
- rb_define_module_function(mNKF, "guess", rb_nkf_guess, 1);
- rb_define_alias(rb_singleton_class(mNKF), "guess", "guess");
-
- rb_define_const(mNKF, "AUTO", Qnil);
- rb_define_const(mNKF, "NOCONV", Qnil);
- rb_define_const(mNKF, "UNKNOWN", Qnil);
- rb_define_const(mNKF, "BINARY", rb_enc_from_encoding(rb_nkf_enc_get("BINARY")));
- rb_define_const(mNKF, "ASCII", rb_enc_from_encoding(rb_nkf_enc_get("ASCII")));
- rb_define_const(mNKF, "JIS", rb_enc_from_encoding(rb_nkf_enc_get("ISO-2022-JP")));
- rb_define_const(mNKF, "EUC", rb_enc_from_encoding(rb_nkf_enc_get("EUC-JP")));
- rb_define_const(mNKF, "SJIS", rb_enc_from_encoding(rb_nkf_enc_get("Shift_JIS")));
- rb_define_const(mNKF, "UTF8", rb_enc_from_encoding(rb_utf8_encoding()));
- rb_define_const(mNKF, "UTF16", rb_enc_from_encoding(rb_nkf_enc_get("UTF-16")));
- rb_define_const(mNKF, "UTF32", rb_enc_from_encoding(rb_nkf_enc_get("UTF-32")));
-
+ rb_define_module_function(mKconv, "nkf", rb_nkf_kconv, 2);
+ rb_define_module_function(mKconv, "guess1", rb_nkf_guess1, 1);
+ rb_define_module_function(mKconv, "guess2", rb_nkf_guess2, 1);
+ rb_define_alias(mKconv, "guess", "guess2");
+ rb_define_alias(rb_singleton_class(mKconv), "guess", "guess2");
+
+ /* Auto-Detect */
+ rb_define_const(mKconv, "AUTO", INT2FIX(_AUTO));
+ /* ISO-2022-JP */
+ rb_define_const(mKconv, "JIS", INT2FIX(_JIS));
+ /* EUC-JP */
+ rb_define_const(mKconv, "EUC", INT2FIX(_EUC));
+ /* Shift_JIS */
+ rb_define_const(mKconv, "SJIS", INT2FIX(_SJIS));
+ /* BINARY */
+ rb_define_const(mKconv, "BINARY", INT2FIX(_BINARY));
+ /* No conversion */
+ rb_define_const(mKconv, "NOCONV", INT2FIX(_NOCONV));
+ /* ASCII */
+ rb_define_const(mKconv, "ASCII", INT2FIX(_ASCII));
+ /* UTF-8 */
+ rb_define_const(mKconv, "UTF8", INT2FIX(_UTF8));
+ /* UTF-16 */
+ rb_define_const(mKconv, "UTF16", INT2FIX(_UTF16));
+ /* UTF-32 */
+ rb_define_const(mKconv, "UTF32", INT2FIX(_UTF32));
+ /* UNKNOWN */
+ rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN));
/* Full version string of nkf */
- rb_define_const(mNKF, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
+ rb_define_const(mKconv, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
/* Version of nkf */
- rb_define_const(mNKF, "NKF_VERSION", rb_str_new2(NKF_VERSION));
+ rb_define_const(mKconv, "NKF_VERSION", rb_str_new2(NKF_VERSION));
/* Release date of nkf */
- rb_define_const(mNKF, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
+ rb_define_const(mKconv, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
}
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index 37053848ef..02e06b7149 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -19,8 +19,6 @@ require "mkmf"
dir_config("openssl")
dir_config("kerberos")
-$defs << "-DRUBY_VERSION_CODE=#{RUBY_VERSION.gsub(/\D/, '')}"
-
message "=== OpenSSL for Ruby configurator ===\n"
##
diff --git a/ext/openssl/lib/net/ftptls.rb b/ext/openssl/lib/net/ftptls.rb
new file mode 100644
index 0000000000..a21c1f6c3c
--- /dev/null
+++ b/ext/openssl/lib/net/ftptls.rb
@@ -0,0 +1,53 @@
+=begin
+= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2003 Blaz Grilc <farmer@gmx.co.uk>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Requirements
+
+= Version
+ $Id$
+
+= Notes
+ Tested on FreeBSD 5-CURRENT and 4-STABLE
+ - ruby 1.6.8 (2003-01-17) [i386-freebsd5]
+ - OpenSSL 0.9.7a Feb 19 2003
+ - ruby-openssl-0.2.0.p0
+ tested on ftp server: glftpd 1.30
+=end
+
+require 'socket'
+require 'openssl'
+require 'net/ftp'
+
+module Net
+ class FTPTLS < FTP
+ def connect(host, port=FTP_PORT)
+ @hostname = host
+ super
+ end
+
+ def login(user = "anonymous", passwd = nil, acct = nil)
+ store = OpenSSL::X509::Store.new
+ store.set_default_paths
+ ctx = OpenSSL::SSL::SSLContext.new('SSLv23')
+ ctx.cert_store = store
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ ctx.key = nil
+ ctx.cert = nil
+ voidcmd("AUTH TLS")
+ @sock = OpenSSL::SSL::SSLSocket.new(@sock, ctx)
+ @sock.connect
+ @sock.post_connection_check(@hostname)
+ super(user, passwd, acct)
+ voidcmd("PBSZ 0")
+ end
+ end
+end
diff --git a/ext/openssl/lib/net/telnets.rb b/ext/openssl/lib/net/telnets.rb
new file mode 100644
index 0000000000..2b69280432
--- /dev/null
+++ b/ext/openssl/lib/net/telnets.rb
@@ -0,0 +1,251 @@
+=begin
+= $RCSfile$ -- SSL/TLS enhancement for Net::Telnet.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+
+ 2001/11/06: Contiributed to Ruby/OpenSSL project.
+
+== class Net::Telnet
+
+This class will initiate SSL/TLS session automaticaly if the server
+sent OPT_STARTTLS. Some options are added for SSL/TLS.
+
+ host = Net::Telnet::new({
+ "Host" => "localhost",
+ "Port" => "telnets",
+ ## follows are new options.
+ 'CertFile' => "user.crt",
+ 'KeyFile' => "user.key",
+ 'CAFile' => "/some/where/certs/casert.pem",
+ 'CAPath' => "/some/where/caserts",
+ 'VerifyMode' => SSL::VERIFY_PEER,
+ 'VerifyCallback' => verify_proc
+ })
+
+Or, the new options ('Cert', 'Key' and 'CACert') are available from
+Michal Rokos's OpenSSL module.
+
+ cert_data = File.open("user.crt"){|io| io.read }
+ pkey_data = File.open("user.key"){|io| io.read }
+ cacert_data = File.open("your_ca.pem"){|io| io.read }
+ host = Net::Telnet::new({
+ "Host" => "localhost",
+ "Port" => "telnets",
+ 'Cert' => OpenSSL::X509::Certificate.new(cert_data)
+ 'Key' => OpenSSL::PKey::RSA.new(pkey_data)
+ 'CACert' => OpenSSL::X509::Certificate.new(cacert_data)
+ 'CAFile' => "/some/where/certs/casert.pem",
+ 'CAPath' => "/some/where/caserts",
+ 'VerifyMode' => SSL::VERIFY_PEER,
+ 'VerifyCallback' => verify_proc
+ })
+
+This class is expected to be a superset of usual Net::Telnet.
+=end
+
+require "net/telnet"
+require "openssl"
+
+module Net
+ class Telnet
+ attr_reader :ssl
+
+ OPT_STARTTLS = 46.chr # "\056" # "\x2e" # Start TLS
+ TLS_FOLLOWS = 1.chr # "\001" # "\x01" # FOLLOWS (for STARTTLS)
+
+ alias preprocess_orig preprocess
+
+ def ssl?; @ssl; end
+
+ def preprocess(string)
+ # combine CR+NULL into CR
+ string = string.gsub(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
+
+ # combine EOL into "\n"
+ string = string.gsub(/#{EOL}/no, "\n") unless @options["Binmode"]
+
+ string.gsub(/#{IAC}(
+ [#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
+ [#{DO}#{DONT}#{WILL}#{WONT}][#{OPT_BINARY}-#{OPT_EXOPL}]|
+ #{SB}[#{OPT_BINARY}-#{OPT_EXOPL}]
+ (#{IAC}#{IAC}|[^#{IAC}])+#{IAC}#{SE}
+ )/xno) do
+ if IAC == $1 # handle escaped IAC characters
+ IAC
+ elsif AYT == $1 # respond to "IAC AYT" (are you there)
+ self.write("nobody here but us pigeons" + EOL)
+ ''
+ elsif DO[0] == $1[0] # respond to "IAC DO x"
+ if OPT_BINARY[0] == $1[1]
+ @telnet_option["BINARY"] = true
+ self.write(IAC + WILL + OPT_BINARY)
+ elsif OPT_STARTTLS[0] == $1[1]
+ self.write(IAC + WILL + OPT_STARTTLS)
+ self.write(IAC + SB + OPT_STARTTLS + TLS_FOLLOWS + IAC + SE)
+ else
+ self.write(IAC + WONT + $1[1..1])
+ end
+ ''
+ elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x"
+ self.write(IAC + WONT + $1[1..1])
+ ''
+ elsif WILL[0] == $1[0] # respond to "IAC WILL x"
+ if OPT_BINARY[0] == $1[1]
+ self.write(IAC + DO + OPT_BINARY)
+ elsif OPT_ECHO[0] == $1[1]
+ self.write(IAC + DO + OPT_ECHO)
+ elsif OPT_SGA[0] == $1[1]
+ @telnet_option["SGA"] = true
+ self.write(IAC + DO + OPT_SGA)
+ else
+ self.write(IAC + DONT + $1[1..1])
+ end
+ ''
+ elsif WONT[0] == $1[0] # respond to "IAC WON'T x"
+ if OPT_ECHO[0] == $1[1]
+ self.write(IAC + DONT + OPT_ECHO)
+ elsif OPT_SGA[0] == $1[1]
+ @telnet_option["SGA"] = false
+ self.write(IAC + DONT + OPT_SGA)
+ else
+ self.write(IAC + DONT + $1[1..1])
+ end
+ ''
+ elsif SB[0] == $1[0] # respond to "IAC SB xxx IAC SE"
+ if OPT_STARTTLS[0] == $1[1] && TLS_FOLLOWS[0] == $2[0]
+ @sock = OpenSSL::SSL::SSLSocket.new(@sock)
+ @sock.cert = @options['Cert'] unless @sock.cert
+ @sock.key = @options['Key'] unless @sock.key
+ @sock.ca_cert = @options['CACert']
+ @sock.ca_file = @options['CAFile']
+ @sock.ca_path = @options['CAPath']
+ @sock.timeout = @options['Timeout']
+ @sock.verify_mode = @options['VerifyMode']
+ @sock.verify_callback = @options['VerifyCallback']
+ @sock.verify_depth = @options['VerifyDepth']
+ @sock.connect
+ if @options['VerifyMode'] != OpenSSL::SSL::VERIFY_NONE
+ @sock.post_connection_check(@options['Host'])
+ end
+ @ssl = true
+ end
+ ''
+ else
+ ''
+ end
+ end
+ end # preprocess
+
+ alias waitfor_org waitfor
+
+ def waitfor(options)
+ time_out = @options["Timeout"]
+ waittime = @options["Waittime"]
+
+ if options.kind_of?(Hash)
+ prompt = if options.has_key?("Match")
+ options["Match"]
+ elsif options.has_key?("Prompt")
+ options["Prompt"]
+ elsif options.has_key?("String")
+ Regexp.new( Regexp.quote(options["String"]) )
+ end
+ time_out = options["Timeout"] if options.has_key?("Timeout")
+ waittime = options["Waittime"] if options.has_key?("Waittime")
+ else
+ prompt = options
+ end
+
+ if time_out == false
+ time_out = nil
+ end
+
+ line = ''
+ buf = ''
+ @rest = '' unless @rest
+
+ until(prompt === line and not IO::select([@sock], nil, nil, waittime))
+ unless IO::select([@sock], nil, nil, time_out)
+ raise TimeoutError, "timed-out; wait for the next data"
+ end
+ begin
+ c = @rest + @sock.sysread(1024 * 1024)
+ @dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
+ if @options["Telnetmode"]
+ pos = 0
+ catch(:next){
+ while true
+ case c[pos]
+ when IAC[0]
+ case c[pos+1]
+ when DO[0], DONT[0], WILL[0], WONT[0]
+ throw :next unless c[pos+2]
+ pos += 3
+ when SB[0]
+ ret = detect_sub_negotiation(c, pos)
+ throw :next unless ret
+ pos = ret
+ when nil
+ throw :next
+ else
+ pos += 2
+ end
+ when nil
+ throw :next
+ else
+ pos += 1
+ end
+ end
+ }
+
+ buf = preprocess(c[0...pos])
+ @rest = c[pos..-1]
+ end
+ @log.print(buf) if @options.has_key?("Output_log")
+ line.concat(buf)
+ yield buf if block_given?
+ rescue EOFError # End of file reached
+ if line == ''
+ line = nil
+ yield nil if block_given?
+ end
+ break
+ end
+ end
+ line
+ end
+
+ private
+
+ def detect_sub_negotiation(data, pos)
+ return nil if data.length < pos+6 # IAC SB x param IAC SE
+ pos += 3
+ while true
+ case data[pos]
+ when IAC[0]
+ if data[pos+1] == SE[0]
+ pos += 2
+ return pos
+ else
+ pos += 2
+ end
+ when nil
+ return nil
+ else
+ pos += 1
+ end
+ end
+ end
+
+ end
+end
diff --git a/ext/openssl/lib/openssl.rb b/ext/openssl/lib/openssl.rb
index 24a9eed136..f10985ed2c 100644
--- a/ext/openssl/lib/openssl.rb
+++ b/ext/openssl/lib/openssl.rb
@@ -19,6 +19,7 @@ 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/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index 5dabcd5135..761a017487 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -57,10 +57,10 @@ module Buffering
if size == 0
if buf
buf.clear
- return buf
else
- return ""
+ buf = ""
end
+ return @eof ? nil : buf
end
until @eof
break if size && size <= @rbuffer.size
@@ -78,10 +78,10 @@ module Buffering
if maxlen == 0
if buf
buf.clear
- return buf
else
- return ""
+ buf = ""
end
+ return @eof ? nil : buf
end
if @rbuffer.empty?
begin
@@ -99,7 +99,7 @@ module Buffering
ret
end
- def gets(eol=$/, limit=nil)
+ def gets(eol=$/)
idx = @rbuffer.index(eol)
until @eof
break if idx
@@ -111,9 +111,6 @@ module Buffering
else
size = idx ? idx+eol.size : nil
end
- if limit and limit >= 0
- size = [size, limit].min
- end
consume_rbuff(size)
end
diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb
index 8d7df73b54..4810f0121b 100644
--- a/ext/openssl/lib/openssl/digest.rb
+++ b/ext/openssl/lib/openssl/digest.rb
@@ -26,6 +26,10 @@ module OpenSSL
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|
@@ -46,7 +50,10 @@ module OpenSSL
# This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
class Digest < Digest
- # add warning
+ def initialize(*args)
+ # add warning
+ super(*args)
+ end
end
end # Digest
diff --git a/ext/openssl/lib/openssl/pkcs7.rb b/ext/openssl/lib/openssl/pkcs7.rb
new file mode 100644
index 0000000000..1f88c1de5e
--- /dev/null
+++ b/ext/openssl/lib/openssl/pkcs7.rb
@@ -0,0 +1,25 @@
+=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 948c55f259..f722cb0c45 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -36,6 +36,7 @@ module OpenSSL
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
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c
index f77731ed65..724f36b8ae 100644
--- a/ext/openssl/openssl_missing.c
+++ b/ext/openssl/openssl_missing.c
@@ -22,17 +22,15 @@
#include "openssl_missing.h"
#if !defined(HAVE_HMAC_CTX_COPY)
-int
+void
HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
{
- if (!out || !in) return 0;
+ if (!out || !in) return;
memcpy(out, in, sizeof(HMAC_CTX));
- if (!EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx)
- || !EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx)
- || !EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx))
- return 0;
- return 1;
+ 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);
}
#endif /* HAVE_HMAC_CTX_COPY */
#endif /* NO_HMAC */
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
index e8c75ca42c..5a71f73c64 100644
--- a/ext/openssl/openssl_missing.h
+++ b/ext/openssl/openssl_missing.h
@@ -15,6 +15,10 @@
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
*/
@@ -56,14 +60,33 @@ extern "C" {
(char *(*)())d2i_PKCS7_RECIP_INFO, (char *)ri)
#endif
+#if !defined(HAVE_EVP_MD_CTX_INIT)
void HMAC_CTX_init(HMAC_CTX *ctx);
-int HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
+#endif
+
+#if !defined(HAVE_HMAC_CTX_COPY)
+void HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
+#endif
+
+#if !defined(HAVE_HMAC_CTX_CLEANUP)
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);
@@ -107,19 +130,54 @@ 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.h b/ext/openssl/ossl.h
index a4bc661eb1..3cc30ae2e8 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -46,7 +46,11 @@ extern "C" {
#if defined(_WIN32)
# define OSSL_NO_CONF_API 1
-# include <winsock2.h>
+# ifdef USE_WINSOCK2
+# include <winsock2.h>
+# else
+# include <winsock.h>
+# endif
#endif
#include <errno.h>
#include <openssl/err.h>
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index 83d2bf43c7..6856476261 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -151,7 +151,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
}
break;
default:
- ossl_raise(rb_eArgError, "invalid radix %d", base);
+ ossl_raise(rb_eArgError, "illegal radix %d", base);
}
return self;
}
@@ -203,7 +203,7 @@ ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
str = ossl_buf2str(buf, strlen(buf));
break;
default:
- ossl_raise(rb_eArgError, "invalid radix %d", base);
+ ossl_raise(rb_eArgError, "illegal radix %d", base);
}
return str;
@@ -515,7 +515,7 @@ BIGNUM_SELF_SHIFT(rshift);
bottom = (odd == Qtrue) ? 1 : 0; \
/* FALLTHROUGH */ \
case 2: \
- top = FIX2INT(fill); \
+ top = NUM2INT(fill); \
} \
b = NUM2INT(bits); \
if (!(result = BN_new())) { \
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index 118626fd71..879d399fe7 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -48,7 +48,7 @@ GetDigestPtr(VALUE obj)
SafeGetDigest(obj, ctx);
- md = EVP_MD_CTX_md(ctx); /*== ctx->digest*/
+ md = EVP_MD_CTX_md(ctx);
}
return md;
@@ -62,7 +62,6 @@ 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;
@@ -80,9 +79,8 @@ 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;
}
@@ -102,14 +100,9 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
VALUE type, data;
rb_scan_args(argc, argv, "11", &type, &data);
- StringValue(type);
+ md = GetDigestPtr(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);
@@ -167,147 +160,72 @@ ossl_digest_update(VALUE self, VALUE data)
return self;
}
-static void
-digest_final(EVP_MD_CTX *ctx, char **buf, int *buf_len)
-{
- EVP_MD_CTX final;
-
- if (!EVP_MD_CTX_copy(&final, ctx)) {
- ossl_raise(eDigestError, NULL);
- }
- if (!(*buf = OPENSSL_malloc(EVP_MD_CTX_size(&final)))) {
- EVP_MD_CTX_cleanup(&final);
- ossl_raise(eDigestError, "Cannot allocate mem for digest");
- }
- EVP_DigestFinal_ex(&final, *buf, buf_len);
- EVP_MD_CTX_cleanup(&final);
-}
-
/*
* call-seq:
- * digest.final -> aString
+ * digest.finish -> aString
*
*/
static VALUE
-ossl_digest_digest(VALUE self)
+ossl_digest_finish(int argc, VALUE *argv, VALUE self)
{
EVP_MD_CTX *ctx;
- char *buf;
- int buf_len;
- VALUE digest;
-
- GetDigest(self, ctx);
- digest_final(ctx, &buf, &buf_len);
- digest = ossl_buf2str(buf, buf_len);
-
- return digest;
-}
+ VALUE str;
-/*
- * call-seq:
- * digest.hexdigest -> aString
- *
- */
-static VALUE
-ossl_digest_hexdigest(VALUE self)
-{
- EVP_MD_CTX *ctx;
- char *buf, *hexbuf;
- int buf_len;
- VALUE hexdigest;
+ rb_scan_args(argc, argv, "01", &str);
GetDigest(self, ctx);
- digest_final(ctx, &buf, &buf_len);
- if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * buf_len) {
- OPENSSL_free(buf);
- ossl_raise(eDigestError, "Memory alloc error");
- }
- OPENSSL_free(buf);
- hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
-
- return hexdigest;
-}
-static VALUE
-ossl_digest_s_digest(VALUE klass, VALUE str, VALUE data)
-{
- VALUE obj = rb_class_new_instance(1, &str, klass);
-
- ossl_digest_update(obj, data);
-
- return ossl_digest_digest(obj);
-}
-
-static VALUE
-ossl_digest_s_hexdigest(VALUE klass, VALUE str, VALUE data)
-{
- VALUE obj = rb_class_new_instance(1, &str, klass);
+ 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));
+ }
- ossl_digest_update(obj, data);
+ EVP_DigestFinal_ex(ctx, RSTRING_PTR(str), NULL);
- return ossl_digest_hexdigest(obj);
+ return str;
}
/*
* call-seq:
- * digest1 == digest2 -> true | false
+ * digest.name -> string
*
*/
static VALUE
-ossl_digest_equal(VALUE self, VALUE other)
+ossl_digest_name(VALUE self)
{
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_LEN(str2) == EVP_MD_CTX_size(ctx)) {
- str1 = ossl_digest_digest(self);
- } else {
- str1 = ossl_digest_hexdigest(self);
- }
- if (RSTRING_LEN(str1) == RSTRING_LEN(str2)
- && rb_str_cmp(str1, str2) == 0) {
- return Qtrue;
- }
- return Qfalse;
+ return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
}
/*
* call-seq:
- * digest.name -> string
+ * digest.digest_size -> integer
*
+ * Returns the output size of the digest.
*/
static VALUE
-ossl_digest_name(VALUE self)
+ossl_digest_size(VALUE self)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
- return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
+ return INT2NUM(EVP_MD_CTX_size(ctx));
}
-/*
- * call-seq:
- * digest.size -> integer
- *
- * Returns the output size of the digest.
- */
static VALUE
-ossl_digest_size(VALUE self)
+ossl_digest_block_length(VALUE self)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
- return INT2NUM(EVP_MD_CTX_size(ctx));
+ return INT2NUM(EVP_MD_CTX_block_size(ctx));
}
/*
@@ -316,32 +234,26 @@ ossl_digest_size(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_cObject);
+ cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
eDigestError = rb_define_class_under(cDigest, "DigestError", eOSSLError);
rb_define_alloc_func(cDigest, ossl_digest_alloc);
- rb_define_singleton_method(cDigest, "digest", ossl_digest_s_digest, 2);
- rb_define_singleton_method(cDigest, "hexdigest", ossl_digest_s_hexdigest, 2);
-
+
rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
- rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
-
rb_define_copy_func(cDigest, ossl_digest_copy);
-
- rb_define_method(cDigest, "digest", ossl_digest_digest, 0);
- rb_define_method(cDigest, "hexdigest", ossl_digest_hexdigest, 0);
- rb_define_alias(cDigest, "inspect", "hexdigest");
- rb_define_alias(cDigest, "to_s", "hexdigest");
-
+ rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
rb_define_method(cDigest, "update", ossl_digest_update, 1);
rb_define_alias(cDigest, "<<", "update");
-
- rb_define_method(cDigest, "==", ossl_digest_equal, 1);
-
+ 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, "name", ossl_digest_name, 0);
- rb_define_method(cDigest, "size", ossl_digest_size, 0);
}
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index ba85f521f7..ef77d6c427 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -87,9 +87,7 @@ ossl_hmac_copy(VALUE self, VALUE other)
GetHMAC(self, ctx1);
SafeGetHMAC(other, ctx2);
- if (!HMAC_CTX_copy(ctx1, ctx2)) {
- ossl_raise(eHMACError, NULL);
- }
+ HMAC_CTX_copy(ctx1, ctx2);
return self;
}
@@ -115,9 +113,7 @@ hmac_final(HMAC_CTX *ctx, char **buf, int *buf_len)
{
HMAC_CTX final;
- if (!HMAC_CTX_copy(&final, ctx)) {
- ossl_raise(eHMACError, NULL);
- }
+ HMAC_CTX_copy(&final, ctx);
if (!(*buf = OPENSSL_malloc(HMAC_size(&final)))) {
HMAC_CTX_cleanup(&final);
OSSL_Debug("Allocating %d mem", HMAC_size(&final));
diff --git a/ext/openssl/ossl_pkcs5.c b/ext/openssl/ossl_pkcs5.c
index ca02a18c67..007889fc94 100644
--- a/ext/openssl/ossl_pkcs5.c
+++ b/ext/openssl/ossl_pkcs5.c
@@ -27,7 +27,7 @@ ossl_pkcs5_pbkdf2_hmac(VALUE self, VALUE pass, VALUE salt, VALUE iter, VALUE key
{
#ifdef HAVE_PKCS5_PBKDF2_HMAC
VALUE str;
- const EVP_MD md;
+ const EVP_MD *md;
int len = NUM2INT(keylen);
StringValue(pass);
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index a6924a6bb8..02c3d99ed8 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -116,9 +116,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 = FIX2INT(gen);
+ g = NUM2INT(gen);
}
- dh = dh_generate(FIX2INT(size), g);
+ dh = dh_generate(NUM2INT(size), g);
obj = dh_instance(klass, dh);
if (obj == Qfalse) {
DH_free(dh);
@@ -158,7 +158,7 @@ ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
}
else if (FIXNUM_P(arg)) {
if (!NIL_P(gen)) {
- g = FIX2INT(gen);
+ g = NUM2INT(gen);
}
if (!(dh = dh_generate(FIX2INT(arg), g))) {
ossl_raise(eDHError, NULL);
@@ -524,11 +524,9 @@ 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 95dc426366..d9c7fcbe78 100644
--- a/ext/openssl/ossl_pkey_dsa.c
+++ b/ext/openssl/ossl_pkey_dsa.c
@@ -110,7 +110,7 @@ dsa_generate(int size)
static VALUE
ossl_dsa_s_generate(VALUE klass, VALUE size)
{
- DSA *dsa = dsa_generate(FIX2INT(size)); /* err handled by dsa_instance */
+ DSA *dsa = dsa_generate(NUM2INT(size)); /* err handled by dsa_instance */
VALUE obj = dsa_instance(klass, dsa);
if (obj == Qfalse) {
@@ -477,12 +477,8 @@ 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
index c3a15e722b..210054121d 100644
--- a/ext/openssl/ossl_pkey_ec.c
+++ b/ext/openssl/ossl_pkey_ec.c
@@ -1576,10 +1576,7 @@ void Init_ossl_ec()
}
#else /* defined NO_EC */
-# warning >>> OpenSSL is compiled without EC support <<<
-
void Init_ossl_ec()
{
}
-
#endif /* NO_EC */
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index 4a690a7cb5..9ac69e7ded 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -585,11 +585,9 @@ 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 c22a7357b0..ad830fbc98 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -96,9 +96,10 @@ static VALUE
ossl_rand_bytes(VALUE self, VALUE len)
{
VALUE str;
-
- str = rb_str_new(0, FIX2INT(len));
- if (!RAND_bytes(RSTRING_PTR(str), FIX2INT(len))) {
+ int n = NUM2INT(len);
+
+ str = rb_str_new(0, n);
+ if (!RAND_bytes(RSTRING_PTR(str), n)) {
ossl_raise(eRandomError, NULL);
}
@@ -114,9 +115,10 @@ static VALUE
ossl_rand_pseudo_bytes(VALUE self, VALUE len)
{
VALUE str;
+ int n = NUM2INT(len);
- str = rb_str_new(0, FIX2INT(len));
- if (!RAND_pseudo_bytes(RSTRING_PTR(str), FIX2INT(len))) {
+ str = rb_str_new(0, n);
+ if (!RAND_pseudo_bytes(RSTRING_PTR(str), n)) {
ossl_raise(eRandomError, NULL);
}
@@ -147,9 +149,11 @@ ossl_rand_egd(VALUE self, VALUE filename)
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), FIX2INT(len))) {
+ if (!RAND_egd_bytes(RSTRING_PTR(filename), n)) {
ossl_raise(eRandomError, NULL);
}
return Qtrue;
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 7b2620e4b2..01b86fec27 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -446,6 +446,14 @@ 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)
{
@@ -779,18 +787,18 @@ ossl_sslctx_get_session_cache_stats(VALUE self)
Data_Get_Struct(self, SSL_CTX, ctx);
hash = rb_hash_new();
- rb_hash_aset(hash, rb_str_new2("cache_num"), LONG2NUM(SSL_CTX_sess_number(ctx)));
- rb_hash_aset(hash, rb_str_new2("connect"), LONG2NUM(SSL_CTX_sess_connect(ctx)));
- rb_hash_aset(hash, rb_str_new2("connect_good"), LONG2NUM(SSL_CTX_sess_connect_good(ctx)));
- rb_hash_aset(hash, rb_str_new2("connect_renegotiate"), LONG2NUM(SSL_CTX_sess_connect_renegotiate(ctx)));
- rb_hash_aset(hash, rb_str_new2("accept"), LONG2NUM(SSL_CTX_sess_accept(ctx)));
- rb_hash_aset(hash, rb_str_new2("accept_good"), LONG2NUM(SSL_CTX_sess_accept_good(ctx)));
- rb_hash_aset(hash, rb_str_new2("accept_renegotiate"), LONG2NUM(SSL_CTX_sess_accept_renegotiate(ctx)));
- rb_hash_aset(hash, rb_str_new2("cache_hits"), LONG2NUM(SSL_CTX_sess_hits(ctx)));
- rb_hash_aset(hash, rb_str_new2("cb_hits"), LONG2NUM(SSL_CTX_sess_cb_hits(ctx)));
- rb_hash_aset(hash, rb_str_new2("cache_misses"), LONG2NUM(SSL_CTX_sess_misses(ctx)));
- rb_hash_aset(hash, rb_str_new2("cache_full"), LONG2NUM(SSL_CTX_sess_cache_full(ctx)));
- rb_hash_aset(hash, rb_str_new2("timeouts"), LONG2NUM(SSL_CTX_sess_timeouts(ctx)));
+ 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;
}
@@ -1347,6 +1355,8 @@ 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.
@@ -1365,6 +1375,8 @@ Init_ossl_ssl()
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 */
@@ -1454,6 +1466,9 @@ 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_session.c b/ext/openssl/ossl_ssl_session.c
index b347f2c1b2..63c2bbb87a 100644
--- a/ext/openssl/ossl_ssl_session.c
+++ b/ext/openssl/ossl_ssl_session.c
@@ -47,7 +47,7 @@ static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1)
Data_Get_Struct(arg1, SSL, ssl);
- if ((ctx = SSL_get1_session(ssl)) == NULL)
+ if (!ssl || (ctx = SSL_get1_session(ssl)) == NULL)
ossl_raise(eSSLSession, "no session available");
} else {
BIO *in = ossl_obj2bio(arg1);
@@ -174,7 +174,7 @@ static VALUE ossl_ssl_session_get_id(VALUE self)
p = SSL_SESSION_get_id(ctx, &i);
- return rb_str_new(p, i);
+ return rb_str_new((const char *) p, i);
}
#endif
@@ -200,7 +200,7 @@ static VALUE ossl_ssl_session_to_der(VALUE self)
else if (len >= sizeof(buf))
ossl_raise(eSSLSession, "i2d_SSL_SESSION too large");
- return rb_str_new(p, len);
+ return rb_str_new((const char *) p, len);
}
/*
@@ -289,6 +289,8 @@ void Init_ossl_ssl_session(void)
#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);
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 24a6625ee4..769ce8a91a 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -458,7 +458,7 @@ ossl_x509stctx_set_error(VALUE self, VALUE err)
X509_STORE_CTX *ctx;
GetX509StCtx(self, ctx);
- X509_STORE_CTX_set_error(ctx, FIX2INT(err));
+ X509_STORE_CTX_set_error(ctx, NUM2INT(err));
return err;
}
diff --git a/ext/pty/.cvsignore b/ext/pty/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/pty/.cvsignore
+++ b/ext/pty/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb
index 87fbdc6024..5e126fe0cf 100644
--- a/ext/pty/extconf.rb
+++ b/ext/pty/extconf.rb
@@ -1,6 +1,6 @@
require 'mkmf'
-if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM
+if /mswin32|mingw|bccwin32/ !~ RUBY_PLATFORM
have_header("sys/stropts.h")
have_func("setresuid")
have_header("libutil.h")
diff --git a/ext/pty/lib/expect.rb b/ext/pty/lib/expect.rb
index aa9ab895d3..08191b05b9 100644
--- a/ext/pty/lib/expect.rb
+++ b/ext/pty/lib/expect.rb
@@ -10,7 +10,7 @@ class IO
e_pat = pat
end
while true
- if IO.select([self],nil,nil,timeout).nil? then
+ if !IO.select([self],nil,nil,timeout) or eof? then
result = nil
break
end
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 027ca7d5ae..939335242f 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -1,7 +1,4 @@
-#include "ruby/config.h"
-#ifdef RUBY_EXTCONF_H
-#include RUBY_EXTCONF_H
-#endif
+#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -25,9 +22,9 @@
#endif
#include <ctype.h>
-#include "ruby/ruby.h"
-#include "ruby/io.h"
-#include "ruby/util.h"
+#include "ruby.h"
+#include "rubyio.h"
+#include "util.h"
#include <signal.h>
#ifdef HAVE_SYS_STROPTS_H
@@ -119,7 +116,8 @@ char MasterDevice[] = "/dev/pty%s",
static VALUE eChildExited;
static VALUE
-echild_status(VALUE self)
+echild_status(self)
+ VALUE self;
{
return rb_ivar_get(self, rb_intern("status"));
}
@@ -131,22 +129,25 @@ struct pty_info {
};
static void
-raise_from_wait(char *state, struct pty_info *info)
+raise_from_wait(state, info)
+ struct pty_info *info;
+ char *state;
{
+ extern VALUE rb_last_status;
char buf[1024];
VALUE exc;
snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid);
exc = rb_exc_new2(eChildExited, buf);
- rb_iv_set(exc, "status", rb_last_status_get());
+ rb_iv_set(exc, "status", rb_last_status);
rb_funcall(info->thread, rb_intern("raise"), 1, exc);
}
static VALUE
-pty_syswait(struct pty_info *info)
+pty_syswait(info)
+ struct pty_info *info;
{
- rb_pid_t cpid;
- int status;
+ int cpid, status;
for (;;) {
cpid = rb_waitpid(info->child_pid, &status, WUNTRACED);
@@ -171,26 +172,31 @@ pty_syswait(struct pty_info *info)
}
}
-static void getDevice(int*, int*, char [DEVICELEN]);
+static void getDevice _((int*, int*, char [DEVICELEN]));
struct exec_info {
int argc;
VALUE *argv;
};
+static VALUE pty_exec _((VALUE v));
+
static VALUE
-pty_exec(VALUE v)
+pty_exec(v)
+ VALUE v;
{
struct exec_info *arg = (struct exec_info *)v;
return rb_f_exec(arg->argc, arg->argv);
}
static void
-establishShell(int argc, VALUE *argv, struct pty_info *info,
- char SlaveName[DEVICELEN])
+establishShell(argc, argv, info, SlaveName)
+ int argc;
+ VALUE *argv;
+ struct pty_info *info;
+ char SlaveName[DEVICELEN];
{
- int master,slave;
- rb_pid_t pid;
+ int i,master,slave;
char *p, tmp, *getenv();
struct passwd *pwent;
VALUE v;
@@ -198,7 +204,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
int status;
if (argc == 0) {
- const char *shellname;
+ char *shellname;
if ((p = getenv("SHELL")) != NULL) {
shellname = p;
@@ -217,13 +223,13 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
getDevice(&master, &slave, SlaveName);
info->thread = rb_thread_current();
- if ((pid = fork()) < 0) {
+ if((i = fork()) < 0) {
close(master);
close(slave);
rb_sys_fail("fork failed");
}
- if (pid == 0) { /* child */
+ if(i == 0) { /* child */
/*
* Set free from process group and controlling terminal
*/
@@ -237,9 +243,9 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
# else /* SETGRP_VOID */
if (setpgrp(0, getpid()) == -1)
rb_sys_fail("setpgrp()");
- {
- int i = open("/dev/tty", O_RDONLY);
- if (i < 0) rb_sys_fail("/dev/tty");
+ if ((i = open("/dev/tty", O_RDONLY)) < 0)
+ rb_sys_fail("/dev/tty");
+ else {
if (ioctl(i, TIOCNOTTY, (char *)0))
perror("ioctl(TIOCNOTTY)");
close(i);
@@ -283,12 +289,13 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
read(master, &tmp, 1);
close(slave);
- info->child_pid = pid;
+ info->child_pid = i;
info->fd = master;
}
static VALUE
-pty_finalize_syswait(struct pty_info *info)
+pty_finalize_syswait(info)
+ struct pty_info *info;
{
rb_thread_kill(info->thread);
rb_funcall(info->thread, rb_intern("value"), 0);
@@ -297,7 +304,9 @@ pty_finalize_syswait(struct pty_info *info)
}
static int
-get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail)
+get_device_once(master, slave, SlaveName, fail)
+ int *master, *slave, fail;
+ char SlaveName[DEVICELEN];
{
#if defined HAVE_OPENPTY
/*
@@ -320,7 +329,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail)
}
*slave = open(name, O_RDWR);
- strlcpy(SlaveName, name, sizeof SlaveName);
+ strncpy(SlaveName, name, sizeof SlaveName);
return 0;
#else /* HAVE__GETPTY */
@@ -348,7 +357,7 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail)
#endif
*master = i;
*slave = j;
- strlcpy(SlaveName, pn, sizeof SlaveName);
+ strncpy(SlaveName, pn, sizeof SlaveName);
return 0;
#if defined I_PUSH && !defined linux
}
@@ -387,17 +396,22 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int fail)
}
static void
-getDevice(int *master, int *slave, char SlaveName[DEVICELEN])
+getDevice(master, slave, slavename)
+ int *master, *slave;
+ char slavename[DEVICELEN];
{
- if (get_device_once(master, slave, SlaveName, 0)) {
+ if (get_device_once(master, slave, slavename, 0)) {
rb_gc();
- get_device_once(master, slave, SlaveName, 1);
+ get_device_once(master, slave, slavename, 1);
}
}
/* ruby function: getpty */
static VALUE
-pty_getpty(int argc, VALUE *argv, VALUE self)
+pty_getpty(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE res;
struct pty_info info;
@@ -413,17 +427,17 @@ pty_getpty(int argc, VALUE *argv, VALUE self)
establishShell(argc, argv, &info, SlaveName);
rfptr->mode = rb_io_mode_flags("r");
- rfptr->fd = info.fd;
+ rfptr->f = fdopen(info.fd, "r");
rfptr->path = strdup(SlaveName);
wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC;
- wfptr->fd = dup(info.fd);
+ wfptr->f = fdopen(dup(info.fd), "w");
wfptr->path = strdup(SlaveName);
res = rb_ary_new2(3);
rb_ary_store(res,0,(VALUE)rport);
rb_ary_store(res,1,(VALUE)wport);
- rb_ary_store(res,2,PIDT2NUM(info.child_pid));
+ rb_ary_store(res,2,INT2FIX(info.child_pid));
thinfo.thread = rb_thread_create(pty_syswait, (void*)&info);
thinfo.child_pid = info.child_pid;
@@ -438,7 +452,8 @@ pty_getpty(int argc, VALUE *argv, VALUE self)
/* ruby function: protect_signal - obsolete */
static VALUE
-pty_protect(VALUE self)
+pty_protect(self)
+ VALUE self;
{
rb_warn("PTY::protect_signal is no longer needed");
rb_yield(Qnil);
@@ -447,7 +462,8 @@ pty_protect(VALUE self)
/* ruby function: reset_signal - obsolete */
static VALUE
-pty_reset_signal(VALUE self)
+pty_reset_signal(self)
+ VALUE self;
{
rb_warn("PTY::reset_signal is no longer needed");
return self;
diff --git a/ext/purelib.rb b/ext/purelib.rb
index 10ee06176c..dbe514c34a 100644
--- a/ext/purelib.rb
+++ b/ext/purelib.rb
@@ -1,3 +1,10 @@
-if nul = $:.index("-")
+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/.cvsignore b/ext/racc/cparse/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/racc/cparse/.cvsignore
+++ b/ext/racc/cparse/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/racc/cparse/README b/ext/racc/cparse/README
deleted file mode 100644
index 80b4dce311..0000000000
--- a/ext/racc/cparse/README
+++ /dev/null
@@ -1,10 +0,0 @@
-Racc Runtime README
-===================
-
-This directory contains a runtime library of
-Racc parser generator. If you want to generate
-your own parser, you must get Racc full package.
-Get it from:
-
- http://raa.ruby-lang.org/list.rhtml?name=racc
-
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index d085158f11..18a26f670f 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -11,7 +11,8 @@
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
+#include "version.h"
/* -----------------------------------------------------------------------
Important Constants
@@ -64,6 +65,9 @@ static ID id_d_e_pop;
#ifndef LONG2NUM
# define LONG2NUM(i) INT2NUM(i)
#endif
+#if RUBY_VERSION_CODE >= 190
+# define HAVE_RB_BLOCK_CALL 1
+#endif
static ID value_to_id _((VALUE v));
static inline long num_to_long _((VALUE n));
@@ -84,7 +88,7 @@ num_to_long(VALUE n)
}
#define AREF(s, idx) \
- ((0 <= idx && idx < RARRAY_LEN(s)) ? RARRAY_PTR(s)[idx] : Qnil)
+ ((0 <= idx && idx < RARRAY(s)->len) ? RARRAY(s)->ptr[idx] : Qnil)
/* -----------------------------------------------------------------------
Parser Stack Interfaces
@@ -97,8 +101,8 @@ static VALUE
get_stack_tail(VALUE stack, long len)
{
if (len < 0) return Qnil; /* system error */
- if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
- return rb_ary_new4(len, RARRAY_PTR(stack) + RARRAY_LEN(stack) - len);
+ if (len > RARRAY(stack)->len) len = RARRAY(stack)->len;
+ return rb_ary_new4(len, RARRAY(stack)->ptr + RARRAY(stack)->len - len);
}
static void
@@ -112,10 +116,10 @@ cut_stack_tail(VALUE stack, long len)
#define STACK_INIT_LEN 64
#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
-#define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
+#define PUSH(s, i) rb_ary_store(s, RARRAY(s)->len, i)
#define POP(s) rb_ary_pop(s)
#define LAST_I(s) \
- ((RARRAY_LEN(s) > 0) ? RARRAY_PTR(s)[RARRAY_LEN(s) - 1] : Qnil)
+ ((RARRAY(s)->len > 0) ? RARRAY(s)->ptr[RARRAY(s)->len - 1] : Qnil)
#define GET_TAIL(s, len) get_stack_tail(s, len)
#define CUT_TAIL(s, len) cut_stack_tail(s, len)
@@ -325,23 +329,23 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
Check_Type(arg, T_ARRAY);
- if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
- rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
- v->action_table = assert_array (RARRAY_PTR(arg)[ 0]);
- v->action_check = assert_array (RARRAY_PTR(arg)[ 1]);
- v->action_default = assert_array (RARRAY_PTR(arg)[ 2]);
- v->action_pointer = assert_array (RARRAY_PTR(arg)[ 3]);
- v->goto_table = assert_array (RARRAY_PTR(arg)[ 4]);
- v->goto_check = assert_array (RARRAY_PTR(arg)[ 5]);
- v->goto_default = assert_array (RARRAY_PTR(arg)[ 6]);
- v->goto_pointer = assert_array (RARRAY_PTR(arg)[ 7]);
- v->nt_base = assert_integer(RARRAY_PTR(arg)[ 8]);
- v->reduce_table = assert_array (RARRAY_PTR(arg)[ 9]);
- v->token_table = assert_hash (RARRAY_PTR(arg)[10]);
- v->shift_n = assert_integer(RARRAY_PTR(arg)[11]);
- v->reduce_n = assert_integer(RARRAY_PTR(arg)[12]);
- if (RARRAY_LEN(arg) > 13) {
- v->use_result_var = RTEST(RARRAY_PTR(arg)[13]);
+ if (!(13 <= RARRAY(arg)->len && RARRAY(arg)->len <= 14))
+ rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY(arg)->len);
+ v->action_table = assert_array (RARRAY(arg)->ptr[ 0]);
+ v->action_check = assert_array (RARRAY(arg)->ptr[ 1]);
+ v->action_default = assert_array (RARRAY(arg)->ptr[ 2]);
+ v->action_pointer = assert_array (RARRAY(arg)->ptr[ 3]);
+ v->goto_table = assert_array (RARRAY(arg)->ptr[ 4]);
+ v->goto_check = assert_array (RARRAY(arg)->ptr[ 5]);
+ v->goto_default = assert_array (RARRAY(arg)->ptr[ 6]);
+ v->goto_pointer = assert_array (RARRAY(arg)->ptr[ 7]);
+ v->nt_base = assert_integer(RARRAY(arg)->ptr[ 8]);
+ v->reduce_table = assert_array (RARRAY(arg)->ptr[ 9]);
+ v->token_table = assert_hash (RARRAY(arg)->ptr[10]);
+ v->shift_n = assert_integer(RARRAY(arg)->ptr[11]);
+ v->reduce_n = assert_integer(RARRAY(arg)->ptr[12]);
+ if (RARRAY(arg)->len > 13) {
+ v->use_result_var = RTEST(RARRAY(arg)->ptr[13]);
}
else {
v->use_result_var = Qtrue;
@@ -416,12 +420,12 @@ extract_user_token(struct cparse_params *v, VALUE block_args,
v->lex_is_iterator ? "yielded" : "returned",
rb_class2name(CLASS_OF(block_args)));
}
- if (RARRAY_LEN(block_args) != 2) {
+ if (RARRAY(block_args)->len != 2) {
rb_raise(rb_eArgError,
"%s() %s wrong size of array (%ld for 2)",
v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
v->lex_is_iterator ? "yielded" : "returned",
- RARRAY_LEN(block_args));
+ RARRAY(block_args)->len);
}
*tok = AREF(block_args, 0);
*val = AREF(block_args, 1);
@@ -557,7 +561,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
accept:
if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
- v->retval = RARRAY_PTR(v->vstack)[0];
+ v->retval = RARRAY(v->vstack)->ptr[0];
v->fin = CP_FIN_ACCEPT;
return;
@@ -617,7 +621,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
error_pop:
D_puts("(err) act not found: can't handle error token; pop");
- if (RARRAY_LEN(v->state) <= 1) {
+ if (RARRAY(v->state)->len <= 1) {
v->retval = Qnil;
v->fin = CP_FIN_CANTPOP;
return;
@@ -686,9 +690,9 @@ reduce0(VALUE val, VALUE data, VALUE self)
VALUE goto_state;
Data_Get_Struct(data, struct cparse_params, v);
- reduce_len = RARRAY_PTR(v->reduce_table)[v->ruleno];
- reduce_to = RARRAY_PTR(v->reduce_table)[v->ruleno+1];
- method_id = RARRAY_PTR(v->reduce_table)[v->ruleno+2];
+ reduce_len = RARRAY(v->reduce_table)->ptr[v->ruleno];
+ reduce_to = RARRAY(v->reduce_table)->ptr[v->ruleno+1];
+ method_id = RARRAY(v->reduce_table)->ptr[v->ruleno+2];
len = NUM2LONG(reduce_len);
mid = value_to_id(method_id);
@@ -703,10 +707,10 @@ reduce0(VALUE val, VALUE data, VALUE self)
else {
if (mid != id_noreduce) {
tmp_v = GET_TAIL(v->vstack, len);
- tmp = RARRAY_PTR(tmp_v)[0];
+ tmp = RARRAY(tmp_v)->ptr[0];
}
else {
- tmp = RARRAY_PTR(v->vstack)[ RARRAY_LEN(v->vstack) - len ];
+ tmp = RARRAY(v->vstack)->ptr[ RARRAY(v->vstack)->len - len ];
}
CUT_TAIL(v->vstack, len);
if (v->debug) {
@@ -735,7 +739,7 @@ reduce0(VALUE val, VALUE data, VALUE self)
}
/* calculate transition state */
- if (RARRAY_LEN(v->state) == 0)
+ if (RARRAY(v->state)->len == 0)
rb_raise(RaccBug, "state stack unexpectedly empty");
k2 = num_to_long(LAST_I(v->state));
k1 = num_to_long(reduce_to) - v->nt_base;
diff --git a/ext/racc/cparse/extconf.rb b/ext/racc/cparse/extconf.rb
index 3710f6f7e7..dd953a7e15 100644
--- a/ext/racc/cparse/extconf.rb
+++ b/ext/racc/cparse/extconf.rb
@@ -1,5 +1,4 @@
# $Id$
require 'mkmf'
-have_func('rb_block_call', 'ruby/ruby.h')
create_makefile 'racc/cparse'
diff --git a/ext/readline/.cvsignore b/ext/readline/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/readline/.cvsignore
+++ b/ext/readline/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 169a196166..c9acaadac9 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -1,11 +1,7 @@
/* readline.c -- GNU Readline module
Copyright (C) 1997-2001 Shugo Maeda */
-#ifdef RUBY_EXTCONF_H
-#include RUBY_EXTCONF_H
-#endif
-
-#include "ruby/config.h"
+#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
@@ -20,9 +16,9 @@
#include <editline/readline.h>
#endif
-#include "ruby/ruby.h"
-#include "ruby/io.h"
-#include "ruby/signal.h"
+#include "ruby.h"
+#include "rubyio.h"
+#include "rubysig.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -46,33 +42,59 @@ static ID completion_proc, completion_case_fold;
# define rl_completion_matches completion_matches
#endif
-static int readline_event(void);
static char **readline_attempted_completion_function(const char *text,
int start, int end);
+#ifdef HAVE_RL_EVENT_HOOK
+#ifdef DOSISH
+#define BUSY_WAIT 1
+#else
+#define BUSY_WAIT 0
+#endif
+
+static int readline_event(void);
static int
readline_event()
{
+#if BUSY_WAIT
rb_thread_schedule();
+#else
+ fd_set rset;
+
+ FD_ZERO(&rset);
+ FD_SET(fileno(rl_instream), &rset);
+ rb_thread_select(fileno(rl_instream) + 1, &rset, NULL, NULL, NULL);
return 0;
+#endif
}
+#endif
static VALUE
-readline_readline(int argc, VALUE *argv, VALUE self)
+readline_readline(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE tmp, add_hist, result;
char *prompt = NULL;
char *buff;
int status;
+ rb_io_t *ofp, *ifp;
rb_secure(4);
if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
SafeStringValue(tmp);
- prompt = RSTRING_PTR(tmp);
+ prompt = RSTRING(tmp)->ptr;
}
if (!isatty(0) && errno == EBADF) rb_raise(rb_eIOError, "stdin closed");
+ Check_Type(rb_stdout, T_FILE);
+ GetOpenFile(rb_stdout, ofp);
+ rl_outstream = GetWriteFile(ofp);
+ Check_Type(rb_stdin, T_FILE);
+ GetOpenFile(rb_stdin, ifp);
+ rl_instream = GetReadFile(ifp);
buff = (char*)rb_protect((VALUE(*)_((VALUE)))readline, (VALUE)prompt,
&status);
if (status) {
@@ -102,31 +124,9 @@ readline_readline(int argc, VALUE *argv, VALUE self)
}
static VALUE
-readline_s_set_input(VALUE self, VALUE input)
-{
- rb_io_t *ifp;
-
- rb_secure(4);
- Check_Type(input, T_FILE);
- GetOpenFile(input, ifp);
- rl_instream = rb_io_stdio_file(ifp);
- return input;
-}
-
-static VALUE
-readline_s_set_output(VALUE self, VALUE output)
-{
- rb_io_t *ofp;
-
- rb_secure(4);
- Check_Type(output, T_FILE);
- GetOpenFile(output, ofp);
- rl_outstream = rb_io_stdio_file(ofp);
- return output;
-}
-
-static VALUE
-readline_s_set_completion_proc(VALUE self, VALUE proc)
+readline_s_set_completion_proc(self, proc)
+ VALUE self;
+ VALUE proc;
{
rb_secure(4);
if (!rb_respond_to(proc, rb_intern("call")))
@@ -135,28 +135,35 @@ readline_s_set_completion_proc(VALUE self, VALUE proc)
}
static VALUE
-readline_s_get_completion_proc(VALUE self)
+readline_s_get_completion_proc(self)
+ VALUE self;
{
rb_secure(4);
return rb_attr_get(mReadline, completion_proc);
}
static VALUE
-readline_s_set_completion_case_fold(VALUE self, VALUE val)
+readline_s_set_completion_case_fold(self, val)
+ VALUE self;
+ VALUE val;
{
rb_secure(4);
return rb_ivar_set(mReadline, completion_case_fold, val);
}
static VALUE
-readline_s_get_completion_case_fold(VALUE self)
+readline_s_get_completion_case_fold(self)
+ VALUE self;
{
rb_secure(4);
return rb_attr_get(mReadline, completion_case_fold);
}
static char **
-readline_attempted_completion_function(const char *text, int start, int end)
+readline_attempted_completion_function(text, start, end)
+ const char *text;
+ int start;
+ int end;
{
VALUE proc, ary, temp;
char **result;
@@ -173,14 +180,14 @@ readline_attempted_completion_function(const char *text, int start, int end)
ary = rb_funcall(proc, rb_intern("call"), 1, rb_tainted_str_new2(text));
if (TYPE(ary) != T_ARRAY)
ary = rb_Array(ary);
- matches = RARRAY_LEN(ary);
+ matches = RARRAY(ary)->len;
if (matches == 0)
return NULL;
result = ALLOC_N(char *, matches + 2);
for (i = 0; i < matches; i++) {
- temp = rb_obj_as_string(RARRAY_PTR(ary)[i]);
- result[i + 1] = ALLOC_N(char, RSTRING_LEN(temp) + 1);
- strcpy(result[i + 1], RSTRING_PTR(temp));
+ temp = rb_obj_as_string(RARRAY(ary)->ptr[i]);
+ result[i + 1] = ALLOC_N(char, RSTRING(temp)->len + 1);
+ strcpy(result[i + 1], RSTRING(temp)->ptr);
}
result[matches + 1] = NULL;
@@ -220,7 +227,8 @@ readline_attempted_completion_function(const char *text, int start, int end)
}
static VALUE
-readline_s_vi_editing_mode(VALUE self)
+readline_s_vi_editing_mode(self)
+ VALUE self;
{
#ifdef HAVE_RL_VI_EDITING_MODE
rb_secure(4);
@@ -233,7 +241,8 @@ readline_s_vi_editing_mode(VALUE self)
}
static VALUE
-readline_s_emacs_editing_mode(VALUE self)
+readline_s_emacs_editing_mode(self)
+ VALUE self;
{
#ifdef HAVE_RL_EMACS_EDITING_MODE
rb_secure(4);
@@ -246,7 +255,8 @@ readline_s_emacs_editing_mode(VALUE self)
}
static VALUE
-readline_s_set_completion_append_character(VALUE self, VALUE str)
+readline_s_set_completion_append_character(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
rb_secure(4);
@@ -255,10 +265,10 @@ readline_s_set_completion_append_character(VALUE self, VALUE str)
}
else {
SafeStringValue(str);
- if (RSTRING_LEN(str) == 0) {
+ if (RSTRING(str)->len == 0) {
rl_completion_append_character = '\0';
} else {
- rl_completion_append_character = RSTRING_PTR(str)[0];
+ rl_completion_append_character = RSTRING(str)->ptr[0];
}
}
return self;
@@ -269,7 +279,8 @@ readline_s_set_completion_append_character(VALUE self, VALUE str)
}
static VALUE
-readline_s_get_completion_append_character(VALUE self)
+readline_s_get_completion_append_character(self)
+ VALUE self;
{
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
VALUE str;
@@ -279,7 +290,7 @@ readline_s_get_completion_append_character(VALUE self)
return Qnil;
str = rb_str_new("", 1);
- RSTRING_PTR(str)[0] = rl_completion_append_character;
+ RSTRING(str)->ptr[0] = rl_completion_append_character;
return str;
#else
rb_notimplement();
@@ -288,7 +299,8 @@ readline_s_get_completion_append_character(VALUE self)
}
static VALUE
-readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
+readline_s_set_basic_word_break_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
static char *basic_word_break_characters = NULL;
@@ -297,14 +309,14 @@ readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
SafeStringValue(str);
if (basic_word_break_characters == NULL) {
basic_word_break_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
+ ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
- REALLOC_N(basic_word_break_characters, char, RSTRING_LEN(str) + 1);
+ REALLOC_N(basic_word_break_characters, char, RSTRING(str)->len + 1);
}
strncpy(basic_word_break_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- basic_word_break_characters[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ basic_word_break_characters[RSTRING(str)->len] = '\0';
rl_basic_word_break_characters = basic_word_break_characters;
return self;
#else
@@ -314,7 +326,8 @@ readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
+readline_s_get_basic_word_break_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
rb_secure(4);
@@ -328,7 +341,8 @@ readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
+readline_s_set_completer_word_break_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
static char *completer_word_break_characters = NULL;
@@ -337,14 +351,14 @@ readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
SafeStringValue(str);
if (completer_word_break_characters == NULL) {
completer_word_break_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
+ ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
- REALLOC_N(completer_word_break_characters, char, RSTRING_LEN(str) + 1);
+ REALLOC_N(completer_word_break_characters, char, RSTRING(str)->len + 1);
}
strncpy(completer_word_break_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- completer_word_break_characters[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ completer_word_break_characters[RSTRING(str)->len] = '\0';
rl_completer_word_break_characters = completer_word_break_characters;
return self;
#else
@@ -354,7 +368,8 @@ readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
+readline_s_get_completer_word_break_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
rb_secure(4);
@@ -368,7 +383,8 @@ readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_set_basic_quote_characters(VALUE self, VALUE str)
+readline_s_set_basic_quote_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
static char *basic_quote_characters = NULL;
@@ -377,14 +393,14 @@ readline_s_set_basic_quote_characters(VALUE self, VALUE str)
SafeStringValue(str);
if (basic_quote_characters == NULL) {
basic_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
+ ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
- REALLOC_N(basic_quote_characters, char, RSTRING_LEN(str) + 1);
+ REALLOC_N(basic_quote_characters, char, RSTRING(str)->len + 1);
}
strncpy(basic_quote_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- basic_quote_characters[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ basic_quote_characters[RSTRING(str)->len] = '\0';
rl_basic_quote_characters = basic_quote_characters;
return self;
@@ -395,7 +411,8 @@ readline_s_set_basic_quote_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_get_basic_quote_characters(VALUE self, VALUE str)
+readline_s_get_basic_quote_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
rb_secure(4);
@@ -409,7 +426,8 @@ readline_s_get_basic_quote_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_set_completer_quote_characters(VALUE self, VALUE str)
+readline_s_set_completer_quote_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
static char *completer_quote_characters = NULL;
@@ -418,13 +436,14 @@ readline_s_set_completer_quote_characters(VALUE self, VALUE str)
SafeStringValue(str);
if (completer_quote_characters == NULL) {
completer_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
+ ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
- REALLOC_N(completer_quote_characters, char, RSTRING_LEN(str) + 1);
+ REALLOC_N(completer_quote_characters, char, RSTRING(str)->len + 1);
}
- strncpy(completer_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
- completer_quote_characters[RSTRING_LEN(str)] = '\0';
+ strncpy(completer_quote_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ completer_quote_characters[RSTRING(str)->len] = '\0';
rl_completer_quote_characters = completer_quote_characters;
return self;
@@ -435,7 +454,8 @@ readline_s_set_completer_quote_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_get_completer_quote_characters(VALUE self, VALUE str)
+readline_s_get_completer_quote_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
rb_secure(4);
@@ -449,7 +469,8 @@ readline_s_get_completer_quote_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_set_filename_quote_characters(VALUE self, VALUE str)
+readline_s_set_filename_quote_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
static char *filename_quote_characters = NULL;
@@ -458,13 +479,14 @@ readline_s_set_filename_quote_characters(VALUE self, VALUE str)
SafeStringValue(str);
if (filename_quote_characters == NULL) {
filename_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
+ ALLOC_N(char, RSTRING(str)->len + 1);
}
else {
- REALLOC_N(filename_quote_characters, char, RSTRING_LEN(str) + 1);
+ REALLOC_N(filename_quote_characters, char, RSTRING(str)->len + 1);
}
- strncpy(filename_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
- filename_quote_characters[RSTRING_LEN(str)] = '\0';
+ strncpy(filename_quote_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ filename_quote_characters[RSTRING(str)->len] = '\0';
rl_filename_quote_characters = filename_quote_characters;
return self;
@@ -475,7 +497,8 @@ readline_s_set_filename_quote_characters(VALUE self, VALUE str)
}
static VALUE
-readline_s_get_filename_quote_characters(VALUE self, VALUE str)
+readline_s_get_filename_quote_characters(self, str)
+ VALUE self, str;
{
#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
rb_secure(4);
@@ -489,13 +512,16 @@ readline_s_get_filename_quote_characters(VALUE self, VALUE str)
}
static VALUE
-hist_to_s(VALUE self)
+hist_to_s(self)
+ VALUE self;
{
return rb_str_new2("HISTORY");
}
static VALUE
-hist_get(VALUE self, VALUE index)
+hist_get(self, index)
+ VALUE self;
+ VALUE index;
{
HIST_ENTRY *entry;
int i;
@@ -513,7 +539,10 @@ hist_get(VALUE self, VALUE index)
}
static VALUE
-hist_set(VALUE self, VALUE index, VALUE str)
+hist_set(self, index, str)
+ VALUE self;
+ VALUE index;
+ VALUE str;
{
#ifdef HAVE_REPLACE_HISTORY_ENTRY
HIST_ENTRY *entry;
@@ -525,7 +554,7 @@ hist_set(VALUE self, VALUE index, VALUE str)
if (i < 0) {
i += history_length;
}
- entry = replace_history_entry(i, RSTRING_PTR(str), NULL);
+ entry = replace_history_entry(i, RSTRING(str)->ptr, NULL);
if (entry == NULL) {
rb_raise(rb_eIndexError, "invalid index");
}
@@ -537,16 +566,21 @@ hist_set(VALUE self, VALUE index, VALUE str)
}
static VALUE
-hist_push(VALUE self, VALUE str)
+hist_push(self, str)
+ VALUE self;
+ VALUE str;
{
rb_secure(4);
SafeStringValue(str);
- add_history(RSTRING_PTR(str));
+ add_history(RSTRING(str)->ptr);
return self;
}
static VALUE
-hist_push_method(int argc, VALUE *argv, VALUE self)
+hist_push_method(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE str;
@@ -554,13 +588,14 @@ hist_push_method(int argc, VALUE *argv, VALUE self)
while (argc--) {
str = *argv++;
SafeStringValue(str);
- add_history(RSTRING_PTR(str));
+ add_history(RSTRING(str)->ptr);
}
return self;
}
static VALUE
-rb_remove_history(int index)
+rb_remove_history(index)
+ int index;
{
#ifdef HAVE_REMOVE_HISTORY
HIST_ENTRY *entry;
@@ -582,7 +617,8 @@ rb_remove_history(int index)
}
static VALUE
-hist_pop(VALUE self)
+hist_pop(self)
+ VALUE self;
{
rb_secure(4);
if (history_length > 0) {
@@ -593,7 +629,8 @@ hist_pop(VALUE self)
}
static VALUE
-hist_shift(VALUE self)
+hist_shift(self)
+ VALUE self;
{
rb_secure(4);
if (history_length > 0) {
@@ -604,7 +641,8 @@ hist_shift(VALUE self)
}
static VALUE
-hist_each(VALUE self)
+hist_each(self)
+ VALUE self;
{
HIST_ENTRY *entry;
int i;
@@ -620,21 +658,25 @@ hist_each(VALUE self)
}
static VALUE
-hist_length(VALUE self)
+hist_length(self)
+ VALUE self;
{
rb_secure(4);
return INT2NUM(history_length);
}
static VALUE
-hist_empty_p(VALUE self)
+hist_empty_p(self)
+ VALUE self;
{
rb_secure(4);
return history_length == 0 ? Qtrue : Qfalse;
}
static VALUE
-hist_delete_at(VALUE self, VALUE index)
+hist_delete_at(self, index)
+ VALUE self;
+ VALUE index;
{
int i;
@@ -649,7 +691,9 @@ hist_delete_at(VALUE self, VALUE index)
}
static VALUE
-filename_completion_proc_call(VALUE self, VALUE str)
+filename_completion_proc_call(self, str)
+ VALUE self;
+ VALUE str;
{
VALUE result;
char **matches;
@@ -664,7 +708,7 @@ filename_completion_proc_call(VALUE self, VALUE str)
free(matches[i]);
}
free(matches);
- if (RARRAY_LEN(result) >= 2)
+ if (RARRAY(result)->len >= 2)
rb_ary_shift(result);
}
else {
@@ -674,7 +718,9 @@ filename_completion_proc_call(VALUE self, VALUE str)
}
static VALUE
-username_completion_proc_call(VALUE self, VALUE str)
+username_completion_proc_call(self, str)
+ VALUE self;
+ VALUE str;
{
VALUE result;
char **matches;
@@ -689,7 +735,7 @@ username_completion_proc_call(VALUE self, VALUE str)
free(matches[i]);
}
free(matches);
- if (RARRAY_LEN(result) >= 2)
+ if (RARRAY(result)->len >= 2)
rb_ary_shift(result);
}
else {
@@ -714,10 +760,6 @@ Init_readline()
mReadline = rb_define_module("Readline");
rb_define_module_function(mReadline, "readline",
readline_readline, -1);
- rb_define_singleton_method(mReadline, "input=",
- readline_s_set_input, 1);
- rb_define_singleton_method(mReadline, "output=",
- readline_s_set_output, 1);
rb_define_singleton_method(mReadline, "completion_proc=",
readline_s_set_completion_proc, 1);
rb_define_singleton_method(mReadline, "completion_proc",
@@ -783,7 +825,8 @@ Init_readline()
#if defined HAVE_RL_LIBRARY_VERSION
rb_define_const(mReadline, "VERSION", rb_str_new2(rl_library_version));
#else
- rb_define_const(mReadline, "VERSION", rb_str_new2("2.0 or prior version"));
+ rb_define_const(mReadline, "VERSION",
+ rb_str_new2("2.0 or before version"));
#endif
rl_attempted_completion_function = readline_attempted_completion_function;
diff --git a/ext/ripper/.cvsignore b/ext/ripper/.cvsignore
deleted file mode 100644
index c9adce0b1a..0000000000
--- a/ext/ripper/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-Makefile
-mkmf.log
-eventids1.c
-eventids2table.c
-ripper.*
-ids1
-ids2
-extconf.h
diff --git a/ext/ripper/README b/ext/ripper/README
deleted file mode 100644
index 0825013ba9..0000000000
--- a/ext/ripper/README
+++ /dev/null
@@ -1,30 +0,0 @@
-Ripper README
-=============
-
- Ripper is a Ruby script parser. You can get information
- by event-based style from the parser.
-
- !! WARNING !!
-
- Ripper is still early-alpha version.
- I never assure any kind of backward compatibility.
-
-Requirements
-------------
-
- * ruby 1.9 (support CVS HEAD only)
- * bison 1.28 or later (Other yaccs do not work)
-
-Usage
------
-
- See test/ripper/* and sample/ripper/*.
-
-License
--------
-
- Ruby License.
-
- Minero Aoki
- aamine@loveruby.net
- http://i.loveruby.net
diff --git a/ext/ripper/depend b/ext/ripper/depend
deleted file mode 100644
index 120fdc58e7..0000000000
--- a/ext/ripper/depend
+++ /dev/null
@@ -1,34 +0,0 @@
-GEN = $(srcdir)/tools/generate.rb
-SRC1 = $(top_srcdir)/parse.y
-SRC2 = $(srcdir)/eventids2.c
-BISON = bison
-
-src: ripper.c eventids1.c eventids2table.c
-
-ripper.o: ripper.c lex.c eventids1.c eventids2.c eventids2table.c
-
-.y.c:
- $(BISON) -t -v -oy.tab.c $<
- sed -f $(top_srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@
- @$(RM) y.tab.c
-
-all: check
-static: check
-
-ripper.y: $(srcdir)/tools/preproc.rb $(top_srcdir)/parse.y
- $(RUBY) $(srcdir)/tools/preproc.rb $(top_srcdir)/parse.y --output=$@
-
-check: $(GEN) $(SRC1) $(SRC2)
- $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
-
-eventids1.c: $(srcdir)/tools/generate.rb $(SRC1)
- $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
-
-eventids2table.c: $(srcdir)/tools/generate.rb $(SRC2)
- $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
-
-# Entries for Ripper maintainer
-
-preproc: ripper.E
-ripper.E: ripper.c
- $(CC) -E $(CPPFLAGS) ripper.c | $(RUBY) $(srcdir)/tools/strip.rb > $@
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c
deleted file mode 100644
index 629381448a..0000000000
--- a/ext/ripper/eventids2.c
+++ /dev/null
@@ -1,277 +0,0 @@
-#define tIGNORED_NL (tLAST_TOKEN + 1)
-#define tCOMMENT (tLAST_TOKEN + 2)
-#define tEMBDOC_BEG (tLAST_TOKEN + 3)
-#define tEMBDOC (tLAST_TOKEN + 4)
-#define tEMBDOC_END (tLAST_TOKEN + 5)
-#define tSP (tLAST_TOKEN + 6)
-#define tHEREDOC_BEG (tLAST_TOKEN + 7)
-#define tHEREDOC_END (tLAST_TOKEN + 8)
-#define k__END__ (tLAST_TOKEN + 9)
-
-static ID ripper_id_backref;
-static ID ripper_id_backtick;
-static ID ripper_id_comma;
-static ID ripper_id_const;
-static ID ripper_id_cvar;
-static ID ripper_id_embexpr_beg;
-static ID ripper_id_embexpr_end;
-static ID ripper_id_embvar;
-static ID ripper_id_float;
-static ID ripper_id_gvar;
-static ID ripper_id_ident;
-static ID ripper_id_int;
-static ID ripper_id_ivar;
-static ID ripper_id_kw;
-static ID ripper_id_lbrace;
-static ID ripper_id_lbracket;
-static ID ripper_id_lparen;
-static ID ripper_id_nl;
-static ID ripper_id_op;
-static ID ripper_id_period;
-static ID ripper_id_rbrace;
-static ID ripper_id_rbracket;
-static ID ripper_id_rparen;
-static ID ripper_id_semicolon;
-static ID ripper_id_symbeg;
-static ID ripper_id_tstring_beg;
-static ID ripper_id_tstring_content;
-static ID ripper_id_tstring_end;
-static ID ripper_id_words_beg;
-static ID ripper_id_qwords_beg;
-static ID ripper_id_words_sep;
-static ID ripper_id_regexp_beg;
-static ID ripper_id_regexp_end;
-static ID ripper_id_label;
-static ID ripper_id_tlambda;
-static ID ripper_id_tlambeg;
-
-static ID ripper_id_ignored_nl;
-static ID ripper_id_comment;
-static ID ripper_id_embdoc_beg;
-static ID ripper_id_embdoc;
-static ID ripper_id_embdoc_end;
-static ID ripper_id_sp;
-static ID ripper_id_heredoc_beg;
-static ID ripper_id_heredoc_end;
-static ID ripper_id___end__;
-static ID ripper_id_CHAR;
-
-#include "eventids2table.c"
-
-static void
-ripper_init_eventids2(VALUE self)
-{
- ripper_id_backref = rb_intern("on_backref");
- ripper_id_backtick = rb_intern("on_backtick");
- ripper_id_comma = rb_intern("on_comma");
- ripper_id_const = rb_intern("on_const");
- ripper_id_cvar = rb_intern("on_cvar");
- ripper_id_embexpr_beg = rb_intern("on_embexpr_beg");
- ripper_id_embexpr_end = rb_intern("on_embexpr_end");
- ripper_id_embvar = rb_intern("on_embvar");
- ripper_id_float = rb_intern("on_float");
- ripper_id_gvar = rb_intern("on_gvar");
- ripper_id_ident = rb_intern("on_ident");
- ripper_id_int = rb_intern("on_int");
- ripper_id_ivar = rb_intern("on_ivar");
- ripper_id_kw = rb_intern("on_kw");
- ripper_id_lbrace = rb_intern("on_lbrace");
- ripper_id_lbracket = rb_intern("on_lbracket");
- ripper_id_lparen = rb_intern("on_lparen");
- ripper_id_nl = rb_intern("on_nl");
- ripper_id_op = rb_intern("on_op");
- ripper_id_period = rb_intern("on_period");
- ripper_id_rbrace = rb_intern("on_rbrace");
- ripper_id_rbracket = rb_intern("on_rbracket");
- ripper_id_rparen = rb_intern("on_rparen");
- ripper_id_semicolon = rb_intern("on_semicolon");
- ripper_id_symbeg = rb_intern("on_symbeg");
- ripper_id_tstring_beg = rb_intern("on_tstring_beg");
- ripper_id_tstring_content = rb_intern("on_tstring_content");
- ripper_id_tstring_end = rb_intern("on_tstring_end");
- ripper_id_words_beg = rb_intern("on_words_beg");
- ripper_id_qwords_beg = rb_intern("on_qwords_beg");
- ripper_id_words_sep = rb_intern("on_words_sep");
- ripper_id_regexp_beg = rb_intern("on_regexp_beg");
- ripper_id_regexp_end = rb_intern("on_regexp_end");
- ripper_id_label = rb_intern("on_label");
- ripper_id_tlambda = rb_intern("on_tlambda");
- ripper_id_tlambeg = rb_intern("on_tlambeg");
-
- ripper_id_ignored_nl = rb_intern("on_ignored_nl");
- ripper_id_comment = rb_intern("on_comment");
- ripper_id_embdoc_beg = rb_intern("on_embdoc_beg");
- ripper_id_embdoc = rb_intern("on_embdoc");
- ripper_id_embdoc_end = rb_intern("on_embdoc_end");
- ripper_id_sp = rb_intern("on_sp");
- ripper_id_heredoc_beg = rb_intern("on_heredoc_beg");
- ripper_id_heredoc_end = rb_intern("on_heredoc_end");
- ripper_id___end__ = rb_intern("on___end__");
- ripper_id_CHAR = rb_intern("on_CHAR");
-
- ripper_init_eventids2_table(self);
-}
-
-static const struct token_assoc {
- int token;
- ID *id;
-} token_to_eventid[] = {
- {' ', &ripper_id_words_sep},
- {'!', &ripper_id_op},
- {'%', &ripper_id_op},
- {'&', &ripper_id_op},
- {'*', &ripper_id_op},
- {'+', &ripper_id_op},
- {'-', &ripper_id_op},
- {'/', &ripper_id_op},
- {'<', &ripper_id_op},
- {'=', &ripper_id_op},
- {'>', &ripper_id_op},
- {'?', &ripper_id_op},
- {'^', &ripper_id_op},
- {'|', &ripper_id_op},
- {'~', &ripper_id_op},
- {':', &ripper_id_op},
- {',', &ripper_id_comma},
- {'.', &ripper_id_period},
- {';', &ripper_id_semicolon},
- {'`', &ripper_id_backtick},
- {'\n', &ripper_id_nl},
- {keyword_alias, &ripper_id_kw},
- {keyword_and, &ripper_id_kw},
- {keyword_begin, &ripper_id_kw},
- {keyword_break, &ripper_id_kw},
- {keyword_case, &ripper_id_kw},
- {keyword_class, &ripper_id_kw},
- {keyword_def, &ripper_id_kw},
- {keyword_defined, &ripper_id_kw},
- {keyword_do, &ripper_id_kw},
- {keyword_do_block, &ripper_id_kw},
- {keyword_do_cond, &ripper_id_kw},
- {keyword_else, &ripper_id_kw},
- {keyword_elsif, &ripper_id_kw},
- {keyword_end, &ripper_id_kw},
- {keyword_ensure, &ripper_id_kw},
- {keyword_false, &ripper_id_kw},
- {keyword_for, &ripper_id_kw},
- {keyword_if, &ripper_id_kw},
- {modifier_if, &ripper_id_kw},
- {keyword_in, &ripper_id_kw},
- {keyword_module, &ripper_id_kw},
- {keyword_next, &ripper_id_kw},
- {keyword_nil, &ripper_id_kw},
- {keyword_not, &ripper_id_kw},
- {keyword_or, &ripper_id_kw},
- {keyword_redo, &ripper_id_kw},
- {keyword_rescue, &ripper_id_kw},
- {modifier_rescue, &ripper_id_kw},
- {keyword_retry, &ripper_id_kw},
- {keyword_return, &ripper_id_kw},
- {keyword_self, &ripper_id_kw},
- {keyword_super, &ripper_id_kw},
- {keyword_then, &ripper_id_kw},
- {keyword_true, &ripper_id_kw},
- {keyword_undef, &ripper_id_kw},
- {keyword_unless, &ripper_id_kw},
- {modifier_unless, &ripper_id_kw},
- {keyword_until, &ripper_id_kw},
- {modifier_until, &ripper_id_kw},
- {keyword_when, &ripper_id_kw},
- {keyword_while, &ripper_id_kw},
- {modifier_while, &ripper_id_kw},
- {keyword_yield, &ripper_id_kw},
- {keyword__FILE__, &ripper_id_kw},
- {keyword__LINE__, &ripper_id_kw},
- {keyword_BEGIN, &ripper_id_kw},
- {keyword_END, &ripper_id_kw},
- {tAMPER, &ripper_id_op},
- {tANDOP, &ripper_id_op},
- {tAREF, &ripper_id_op},
- {tASET, &ripper_id_op},
- {tASSOC, &ripper_id_op},
- {tBACK_REF, &ripper_id_backref},
- {tCHAR, &ripper_id_CHAR},
- {tCMP, &ripper_id_op},
- {tCOLON2, &ripper_id_op},
- {tCOLON3, &ripper_id_op},
- {tCONSTANT, &ripper_id_const},
- {tCVAR, &ripper_id_cvar},
- {tDOT2, &ripper_id_op},
- {tDOT3, &ripper_id_op},
- {tEQ, &ripper_id_op},
- {tEQQ, &ripper_id_op},
- {tFID, &ripper_id_ident},
- {tFLOAT, &ripper_id_float},
- {tGEQ, &ripper_id_op},
- {tGVAR, &ripper_id_gvar},
- {tIDENTIFIER, &ripper_id_ident},
- {tINTEGER, &ripper_id_int},
- {tIVAR, &ripper_id_ivar},
- {tLBRACE, &ripper_id_lbrace},
- {tLBRACE_ARG, &ripper_id_lbrace},
- {'{', &ripper_id_lbrace},
- {'}', &ripper_id_rbrace},
- {tLBRACK, &ripper_id_lbracket},
- {'[', &ripper_id_lbracket},
- {']', &ripper_id_rbracket},
- {tLEQ, &ripper_id_op},
- {tLPAREN, &ripper_id_lparen},
- {tLPAREN_ARG, &ripper_id_lparen},
- {'(', &ripper_id_lparen},
- {')', &ripper_id_rparen},
- {tLSHFT, &ripper_id_op},
- {tMATCH, &ripper_id_op},
- {tNEQ, &ripper_id_op},
- {tNMATCH, &ripper_id_op},
- {tNTH_REF, &ripper_id_backref},
- {tOP_ASGN, &ripper_id_op},
- {tOROP, &ripper_id_op},
- {tPOW, &ripper_id_op},
- {tQWORDS_BEG, &ripper_id_qwords_beg},
- {tREGEXP_BEG, &ripper_id_regexp_beg},
- {tREGEXP_END, &ripper_id_regexp_end},
- {tRPAREN, &ripper_id_rparen},
- {tRSHFT, &ripper_id_op},
- {tSTAR, &ripper_id_op},
- {tSTRING_BEG, &ripper_id_tstring_beg},
- {tSTRING_CONTENT, &ripper_id_tstring_content},
- {tSTRING_DBEG, &ripper_id_embexpr_beg},
- {tSTRING_DVAR, &ripper_id_embvar},
- {tSTRING_END, &ripper_id_tstring_end},
- {tSYMBEG, &ripper_id_symbeg},
- {tUMINUS, &ripper_id_op},
- {tUMINUS_NUM, &ripper_id_op},
- {tUPLUS, &ripper_id_op},
- {tWORDS_BEG, &ripper_id_words_beg},
- {tXSTRING_BEG, &ripper_id_backtick},
- {tLABEL, &ripper_id_label},
- {tLAMBDA, &ripper_id_tlambda},
- {tLAMBEG, &ripper_id_tlambeg},
-
- /* ripper specific tokens */
- {tIGNORED_NL, &ripper_id_ignored_nl},
- {tCOMMENT, &ripper_id_comment},
- {tEMBDOC_BEG, &ripper_id_embdoc_beg},
- {tEMBDOC, &ripper_id_embdoc},
- {tEMBDOC_END, &ripper_id_embdoc_end},
- {tSP, &ripper_id_sp},
- {tHEREDOC_BEG, &ripper_id_heredoc_beg},
- {tHEREDOC_END, &ripper_id_heredoc_end},
- {k__END__, &ripper_id___end__},
- {0, NULL}
-};
-
-static ID
-ripper_token2eventid(int tok)
-{
- const struct token_assoc *a;
-
- for (a = token_to_eventid; a->id != NULL; a++) {
- if (a->token == tok)
- return *a->id;
- }
- if (tok < 256) {
- return ripper_id_CHAR;
- }
- rb_raise(rb_eRuntimeError, "[Ripper FATAL] unknown token %d", tok);
-}
diff --git a/ext/ripper/extconf.rb b/ext/ripper/extconf.rb
deleted file mode 100644
index a41a6af2d8..0000000000
--- a/ext/ripper/extconf.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-#!ruby -s
-
-require 'mkmf'
-require 'rbconfig'
-
-def main
- unless find_executable('bison')
- unless File.exist?('ripper.c') or File.exist?("#{$srcdir}/ripper.c")
- Logging.message 'missing bison; abort'
- return
- end
- end
- $objs = %w(ripper.o)
- $cleanfiles.concat %w(ripper.y ripper.c ripper.E ripper.output eventids1.c eventids2table.c)
- $defs << '-DRIPPER'
- $defs << '-DRIPPER_DEBUG' if $debug
- $VPATH << '$(topdir)' << '$(top_srcdir)'
- $INCFLAGS << ' -I$(topdir) -I$(top_srcdir)'
- create_makefile 'ripper'
-end
-
-main
diff --git a/ext/ripper/lib/ripper.rb b/ext/ripper/lib/ripper.rb
deleted file mode 100644
index cb19da334a..0000000000
--- a/ext/ripper/lib/ripper.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'ripper/core'
-require 'ripper/lexer'
-require 'ripper/filter'
-require 'ripper/sexp'
diff --git a/ext/ripper/lib/ripper/core.rb b/ext/ripper/lib/ripper/core.rb
deleted file mode 100644
index 35aa54d090..0000000000
--- a/ext/ripper/lib/ripper/core.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# $Id$
-#
-# Copyright (c) 2003-2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute and/or modify this program under the Ruby License.
-# For details of Ruby License, see ruby/COPYING.
-#
-
-require 'ripper.so'
-
-class Ripper
-
- # Parses Ruby program read from _src_.
- # _src_ must be a String or a IO or a object which has #gets method.
- def Ripper.parse(src, filename = '(ripper)', lineno = 1)
- new(src, filename, lineno).parse
- end
-
- # This array contains name of parser events.
- PARSER_EVENTS = PARSER_EVENT_TABLE.keys
-
- # This array contains name of scanner events.
- SCANNER_EVENTS = SCANNER_EVENT_TABLE.keys
-
- # This array contains name of all ripper events.
- EVENTS = PARSER_EVENTS + SCANNER_EVENTS
-
- private
-
- #
- # Parser Events
- #
-
- PARSER_EVENT_TABLE.each do |id, arity|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{id}(#{ ('a'..'z').to_a[0, arity].join(', ') })
- #{arity == 0 ? 'nil' : 'a'}
- end
- End
- end
-
- # This method is called when weak warning is produced by the parser.
- # _fmt_ and _args_ is printf style.
- def warn(fmt, *args)
- end
-
- # This method is called when strong warning is produced by the parser.
- # _fmt_ and _args_ is printf style.
- def warning(fmt, *args)
- end
-
- # This method is called when the parser found syntax error.
- def compile_error(msg)
- end
-
- #
- # Scanner Events
- #
-
- SCANNER_EVENTS.each do |id|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{id}(token)
- token
- end
- End
- end
-
-end
diff --git a/ext/ripper/lib/ripper/filter.rb b/ext/ripper/lib/ripper/filter.rb
deleted file mode 100644
index 898501b23c..0000000000
--- a/ext/ripper/lib/ripper/filter.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# $Id$
-#
-# Copyright (c) 2004,2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute and/or modify this program under the Ruby License.
-# For details of Ruby License, see ruby/COPYING.
-#
-
-require 'ripper/lexer'
-
-class Ripper
-
- # This class handles only scanner events,
- # and they are dispatched in the `right' order (same with input).
- class Filter
-
- def initialize(src, filename = '-', lineno = 1)
- @__lexer = Lexer.new(src, filename, lineno)
- @__line = nil
- @__col = nil
- end
-
- # The file name of the input.
- def filename
- @__lexer.filename
- end
-
- # The line number of the current token.
- # This value starts from 1.
- # This method is valid only in event handlers.
- def lineno
- @__line
- end
-
- # The column number of the current token.
- # This value starts from 0.
- # This method is valid only in event handlers.
- def column
- @__col
- end
-
- # Starts parsing. _init_ is a data accumulator.
- # It is passed to the next event handler (as of Enumerable#inject).
- def parse(init = nil)
- data = init
- @__lexer.lex.each do |pos, event, tok|
- @__line, @__col = *pos
- data = if respond_to?(event, true)
- then __send__(event, tok, data)
- else on_default(event, tok, data)
- end
- end
- data
- end
-
- private
-
- # This method is called when some event handler have not defined.
- # _event_ is :on_XXX, _token_ is scanned token, _data_ is a data
- # accumulator. The return value of this method is passed to the
- # next event handler (as of Enumerable#inject).
- def on_default(event, token, data)
- data
- end
-
- end
-
-end
diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb
deleted file mode 100644
index 14ef99f034..0000000000
--- a/ext/ripper/lib/ripper/lexer.rb
+++ /dev/null
@@ -1,179 +0,0 @@
-#
-# $Id$
-#
-# Copyright (c) 2004,2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute and/or modify this program under the Ruby License.
-# For details of Ruby License, see ruby/COPYING.
-#
-
-require 'ripper/core'
-
-class Ripper
-
- # Tokenizes Ruby program and returns an Array of String.
- def Ripper.tokenize(src, filename = '-', lineno = 1)
- Lexer.new(src, filename, lineno).tokenize
- end
-
- # Tokenizes Ruby program and returns an Array of Array,
- # which is formatted like [[lineno, column], type, token].
- #
- # require 'ripper'
- # require 'pp'
- #
- # p Ripper.lex("def m(a) nil end")
- # #=> [[[1, 0], :on_kw, "def"],
- # [[1, 3], :on_sp, " " ],
- # [[1, 4], :on_ident, "m" ],
- # [[1, 5], :on_lparen, "(" ],
- # [[1, 6], :on_ident, "a" ],
- # [[1, 7], :on_rparen, ")" ],
- # [[1, 8], :on_sp, " " ],
- # [[1, 9], :on_kw, "nil"],
- # [[1, 12], :on_sp, " " ],
- # [[1, 13], :on_kw, "end"]]
- #
- def Ripper.lex(src, filename = '-', lineno = 1)
- Lexer.new(src, filename, lineno).lex
- end
-
- class Lexer < ::Ripper #:nodoc: internal use only
- def tokenize
- lex().map {|pos, event, tok| tok }
- end
-
- def lex
- parse().sort_by {|pos, event, tok| pos }
- end
-
- def parse
- @buf = []
- super
- @buf
- end
-
- private
-
- SCANNER_EVENTS.each do |event|
- module_eval(<<-End, __FILE__+'/module_eval', __LINE__ + 1)
- def on_#{event}(tok)
- @buf.push [[lineno(), column()], :on_#{event}, tok]
- end
- End
- end
- end
-
- # [EXPERIMENTAL]
- # Parses +src+ and return a string which was matched to +pattern+.
- # +pattern+ should be described as Regexp.
- #
- # require 'ripper'
- #
- # p Ripper.slice('def m(a) nil end', 'ident') #=> "m"
- # p Ripper.slice('def m(a) nil end', '[ident lparen rparen]+') #=> "m(a)"
- # p Ripper.slice("<<EOS\nstring\nEOS",
- # 'heredoc_beg nl $(tstring_content*) heredoc_end', 1)
- # #=> "string\n"
- #
- def Ripper.slice(src, pattern, n = 0)
- if m = token_match(src, pattern)
- then m.string(n)
- else nil
- end
- end
-
- def Ripper.token_match(src, pattern) #:nodoc:
- TokenPattern.compile(pattern).match(src)
- end
-
- class TokenPattern #:nodoc:
-
- class Error < ::StandardError; end
- class CompileError < Error; end
- class MatchError < Error; end
-
- class << self
- alias compile new
- end
-
- def initialize(pattern)
- @source = pattern
- @re = compile(pattern)
- end
-
- def match(str)
- match_list(::Ripper.lex(str))
- end
-
- def match_list(tokens)
- if m = @re.match(map_tokens(tokens))
- then MatchData.new(tokens, m)
- else nil
- end
- end
-
- private
-
- def compile(pattern)
- if m = /[^\w\s$()\[\]{}?*+\.]/.match(pattern)
- raise CompileError, "invalid char in pattern: #{m[0].inspect}"
- end
- buf = ''
- pattern.scan(/(?:\w+|\$\(|[()\[\]\{\}?*+\.]+)/) do |tok|
- case tok
- when /\w/
- buf.concat map_token(tok)
- when '$('
- buf.concat '('
- when '('
- buf.concat '(?:'
- when /[?*\[\])\.]/
- buf.concat tok
- else
- raise 'must not happen'
- end
- end
- Regexp.compile(buf)
- rescue RegexpError => err
- raise CompileError, err.message
- end
-
- def map_tokens(tokens)
- tokens.map {|pos,type,str| map_token(type.to_s.sub(/\Aon_/,'')) }.join
- end
-
- MAP = {}
- seed = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
- SCANNER_EVENT_TABLE.each do |ev, |
- raise CompileError, "[RIPPER FATAL] too many system token" if seed.empty?
- MAP[ev.to_s.sub(/\Aon_/,'')] = seed.shift
- end
-
- def map_token(tok)
- MAP[tok] or raise CompileError, "unknown token: #{tok}"
- end
-
- class MatchData
- def initialize(tokens, match)
- @tokens = tokens
- @match = match
- end
-
- def string(n = 0)
- return nil unless @match
- match(n).join
- end
-
- private
-
- def match(n = 0)
- return [] unless @match
- @tokens[@match.begin(n)...@match.end(n)].map {|pos,type,str| str }
- end
- end
-
- end
-
-end
diff --git a/ext/ripper/lib/ripper/sexp.rb b/ext/ripper/lib/ripper/sexp.rb
deleted file mode 100644
index f2260fe8dd..0000000000
--- a/ext/ripper/lib/ripper/sexp.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-#
-# $Id$
-#
-# Copyright (c) 2004,2005 Minero Aoki
-#
-# This program is free software.
-# You can distribute and/or modify this program under the Ruby License.
-# For details of Ruby License, see ruby/COPYING.
-#
-
-require 'ripper/core'
-
-class Ripper
-
- # [EXPERIMENTAL]
- # Parses +src+ and create S-exp tree.
- # This method is for mainly developper use.
- #
- # require 'ripper'
- # require 'pp
- #
- # pp Ripper.sexp("def m(a) nil end")
- # #=> [:program,
- # [:stmts_add,
- # [:stmts_new],
- # [:def,
- # [:@ident, "m", [1, 4]],
- # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil]],
- # [:bodystmt,
- # [:stmts_add, [:stmts_new], [:var_ref, [:@kw, "nil", [1, 9]]]],
- # nil,
- # nil,
- # nil]]]]
- #
- def Ripper.sexp(src, filename = '-', lineno = 1)
- SexpBuilderPP.new(src, filename, lineno).parse
- end
-
- def Ripper.sexp_raw(src, filename = '-', lineno = 1)
- SexpBuilder.new(src, filename, lineno).parse
- end
-
- class SexpBuilderPP < ::Ripper #:nodoc:
- private
-
- PARSER_EVENT_TABLE.each do |event, arity|
- if /_new\z/ =~ event.to_s and arity == 0
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{event}
- []
- end
- End
- elsif /_add\z/ =~ event.to_s
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{event}(list, item)
- list.push item
- list
- end
- End
- else
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{event}(*args)
- [:#{event}, *args]
- end
- End
- end
- end
-
- SCANNER_EVENTS.each do |event|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{event}(tok)
- [:@#{event}, tok, [lineno(), column()]]
- end
- End
- end
- end
-
- class SexpBuilder < ::Ripper #:nodoc:
- private
-
- PARSER_EVENTS.each do |event|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{event}(*args)
- args.unshift :#{event}
- args
- end
- End
- end
-
- SCANNER_EVENTS.each do |event|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{event}(tok)
- [:@#{event}, tok, [lineno(), column()]]
- end
- End
- end
- end
-
-end
diff --git a/ext/ripper/tools/generate-param-macros.rb b/ext/ripper/tools/generate-param-macros.rb
deleted file mode 100755
index b19f6e8d5c..0000000000
--- a/ext/ripper/tools/generate-param-macros.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-off = true
-ARGF.each do |line|
- case line
- when /RIPPER_PARAMS_DECL_BEGIN/
- off = false
- when /RIPPER_PARAMS_DECL_END/
- exit
- when /ripper/
- next if off
- var = line.scan(/\w+/).last or next
- base = var.sub(/ripper_/, '')
- puts %"\#define #{base}\t\t(parser->ripper_#{base})"
- end
-end
diff --git a/ext/ripper/tools/generate.rb b/ext/ripper/tools/generate.rb
deleted file mode 100755
index 0efb997604..0000000000
--- a/ext/ripper/tools/generate.rb
+++ /dev/null
@@ -1,152 +0,0 @@
-# $Id$
-
-require 'optparse'
-
-def main
- mode = nil
- ids1src = nil
- ids2src = nil
- template = nil
- output = nil
-
- parser = @parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} --mode=MODE [--ids1src=PATH] [--ids2src=PATH] [--output=PATH]"
- parser.on('--mode=MODE', 'check, eventids1, or eventids2table.') {|m|
- mode = m
- }
- parser.on('--ids1src=PATH', 'A source file of event-IDs 1 (parse.y).') {|path|
- ids1src = path
- }
- parser.on('--ids2src=PATH', 'A source file of event-IDs 2 (eventids2.c).') {|path|
- ids2src = path
- }
- parser.on('--output=PATH', 'An output file.') {|path|
- output = path
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit true
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- usage err.message
- end
- usage 'no mode given' unless mode
- case mode
- when 'check'
- usage 'no --ids1src' unless ids1src
- usage 'no --ids2src' unless ids2src
- h = read_ids1_with_locations(ids1src)
- check_arity h
- ids2 = read_ids2(ids2src)
- common = h.keys & ids2
- unless common.empty?
- abort "event crash: #{common.join(' ')}"
- end
- exit 0
- when 'eventids1'
- usage 'no --ids1src' unless ids1src
- result = generate_eventids1(read_ids1(ids1src))
- when 'eventids2table'
- usage 'no --ids2src' unless ids2src
- result = generate_eventids2_table(read_ids2(ids2src))
- end
- if output
- File.open(output, 'w') {|f|
- f.write result
- }
- else
- puts result
- end
-end
-
-def usage(msg)
- $stderr.puts msg
- $stderr.puts @parser.help
- exit false
-end
-
-def generate_eventids1(ids)
- buf = ""
- ids.each do |id, arity|
- buf << %Q[static ID ripper_id_#{id};\n]
- end
- buf << %Q[\n]
- buf << %Q[static void\n]
- buf << %Q[ripper_init_eventids1(VALUE self)\n]
- buf << %Q[{\n]
- buf << %Q[ VALUE h;\n]
- buf << %Q[ ID id;\n]
- ids.each do |id, arity|
- buf << %Q[ ripper_id_#{id} = rb_intern("on_#{id}");\n]
- end
- buf << %Q[\n]
- buf << %Q[ h = rb_hash_new();\n]
- buf << %Q[ rb_define_const(self, "PARSER_EVENT_TABLE", h);\n]
- ids.each do |id, arity|
- buf << %Q[ id = rb_intern("#{id}");\n]
- buf << %Q[ rb_hash_aset(h, ID2SYM(id), INT2NUM(#{arity}));\n]
- end
- buf << %Q[}\n]
- buf
-end
-
-def generate_eventids2_table(ids)
- buf = ""
- buf << %Q[static void\n]
- buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
- buf << %Q[{\n]
- buf << %Q[ VALUE h = rb_hash_new();\n]
- buf << %Q[ ID id;\n]
- buf << %Q[ rb_define_const(self, "SCANNER_EVENT_TABLE", h);\n]
- ids.each do |id|
- buf << %Q[ id = rb_intern("#{id}");\n]
- buf << %Q[ rb_hash_aset(h, ID2SYM(id), INT2NUM(1));\n]
- end
- buf << %Q[}\n]
- buf
-end
-
-def read_ids1(path)
- strip_locations(read_ids1_with_locations(path))
-end
-
-def strip_locations(h)
- h.map {|event, list| [event, list.first[1]] }\
- .sort_by {|event, arity| event.to_s }
-end
-
-def check_arity(h)
- invalid = false
- h.each do |event, list|
- unless list.map {|line, arity| arity }.uniq.size == 1
- invalid = true
- locations = list.map {|line, a| "#{line}:#{a}" }.join(', ')
- $stderr.puts "arity crash [event=#{event}]: #{locations}"
- end
- end
- abort if invalid
-end
-
-def read_ids1_with_locations(path)
- h = {}
- File.open(path) {|f|
- f.each do |line|
- next if /\A\#\s*define\s+s?dispatch/ =~ line
- next if /ripper_dispatch/ =~ line
- line.scan(/dispatch(\d)\((\w+)/) do |arity, event|
- (h[event] ||= []).push [f.lineno, arity.to_i]
- end
- end
- }
- h
-end
-
-def read_ids2(path)
- File.open(path) {|f|
- return f.read.scan(/ripper_id_(\w+)/).flatten.uniq.sort
- }
-end
-
-main
diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
deleted file mode 100755
index 06397cea05..0000000000
--- a/ext/ripper/tools/preproc.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-# $Id$
-
-require 'optparse'
-
-def main
- output = nil
- parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>"
- parser.on('--output=PATH', 'An output file.') {|path|
- output = path
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit true
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- $stderr.puts err.message
- $stderr.puts parser.help
- exit false
- end
- unless ARGV.size == 1
- abort "wrong number of arguments (#{ARGV.size} for 1)"
- end
- out = ""
- File.open(ARGV[0]) {|f|
- prelude f, out
- grammar f, out
- usercode f, out
- }
- if output
- File.open(output, 'w') {|f|
- f.write out
- }
- else
- print out
- end
-end
-
-def prelude(f, out)
- while line = f.gets
- case line
- when %r</\*%%%\*/>
- out << '/*' << $/
- when %r</\*%>
- out << '*/' << $/
- when %r<%\*/>
- out << $/
- when /\A%%/
- out << '%%' << $/
- return
- when /\A%token/
- out << line.sub(/<\w+>/, '<val>')
- when /\A%type/
- out << line.sub(/<\w+>/, '<val>')
- else
- out << line
- end
- end
-end
-
-def grammar(f, out)
- while line = f.gets
- case line
- when %r</\*%%%\*/>
- out << '#if 0' << $/
- when %r</\*%c%\*/>
- out << '/*' << $/
- when %r</\*%c>
- out << '*/' << $/
- when %r</\*%>
- out << '#endif' << $/
- when %r<%\*/>
- out << $/
- when /\A%%/
- out << '%%' << $/
- return
- else
- out << line
- end
- end
-end
-
-def usercode(f, out)
- while line = f.gets
- out << line
- end
-end
-
-main
diff --git a/ext/ripper/tools/strip.rb b/ext/ripper/tools/strip.rb
deleted file mode 100755
index 99413c361d..0000000000
--- a/ext/ripper/tools/strip.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-last_is_void = false
-ARGF.each do |line|
- if line.strip.empty?
- #puts() unless last_is_void
- last_is_void = true
- elsif /\A\#/ === line
- ;
- else
- print line
- last_is_void = false
- end
-end
diff --git a/ext/sdbm/.cvsignore b/ext/sdbm/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/sdbm/.cvsignore
+++ b/ext/sdbm/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c
index 1d81778193..5b34824afc 100644
--- a/ext/sdbm/_sdbm.c
+++ b/ext/sdbm/_sdbm.c
@@ -12,7 +12,7 @@
#endif
#include "sdbm.h"
-#include "ruby/config.h"
+#include "config.h"
/*
* sdbm - ndbm work-alike hashed database library
@@ -143,7 +143,10 @@ static long masks[] = {
datum nullitem = {NULL, 0};
DBM *
-sdbm_open(register char *file, register int flags, register int mode)
+sdbm_open(file, flags, mode)
+register char *file;
+register int flags;
+register int mode;
{
register DBM *db;
register char *dirname;
@@ -172,7 +175,11 @@ sdbm_open(register char *file, register int flags, register int mode)
}
DBM *
-sdbm_prep(char *dirname, char *pagname, int flags, int mode)
+sdbm_prep(dirname, pagname, flags, mode)
+char *dirname;
+char *pagname;
+int flags;
+int mode;
{
register DBM *db;
struct stat dstat;
@@ -228,7 +235,8 @@ sdbm_prep(char *dirname, char *pagname, int flags, int mode)
}
void
-sdbm_close(register DBM *db)
+sdbm_close(db)
+register DBM *db;
{
if (db == NULL)
errno = EINVAL;
@@ -240,7 +248,9 @@ sdbm_close(register DBM *db)
}
datum
-sdbm_fetch(register DBM *db, datum key)
+sdbm_fetch(db, key)
+register DBM *db;
+datum key;
{
if (db == NULL || bad(key))
return errno = EINVAL, nullitem;
@@ -252,7 +262,9 @@ sdbm_fetch(register DBM *db, datum key)
}
int
-sdbm_delete(register DBM *db, datum key)
+sdbm_delete(db, key)
+register DBM *db;
+datum key;
{
if (db == NULL || bad(key))
return errno = EINVAL, -1;
@@ -276,7 +288,11 @@ sdbm_delete(register DBM *db, datum key)
}
int
-sdbm_store(register DBM *db, datum key, datum val, int flags)
+sdbm_store(db, key, val, flags)
+register DBM *db;
+datum key;
+datum val;
+int flags;
{
int need;
register long hash;
@@ -334,7 +350,10 @@ sdbm_store(register DBM *db, datum key, datum val, int flags)
* giving up.
*/
static int
-makroom(register DBM *db, long int hash, int need)
+makroom(db, hash, need)
+register DBM *db;
+long hash;
+int need;
{
long newp;
char twin[PBLKSIZ];
@@ -431,7 +450,8 @@ makroom(register DBM *db, long int hash, int need)
* deletions aren't taken into account. (ndbm bug)
*/
datum
-sdbm_firstkey(register DBM *db)
+sdbm_firstkey(db)
+register DBM *db;
{
if (db == NULL)
return errno = EINVAL, nullitem;
@@ -450,7 +470,8 @@ sdbm_firstkey(register DBM *db)
}
datum
-sdbm_nextkey(register DBM *db)
+sdbm_nextkey(db)
+register DBM *db;
{
if (db == NULL)
return errno = EINVAL, nullitem;
@@ -461,7 +482,9 @@ sdbm_nextkey(register DBM *db)
* all important binary trie traversal
*/
static int
-getpage(register DBM *db, register long int hash)
+getpage(db, hash)
+register DBM *db;
+register long hash;
{
register int hbit;
register long dbit;
@@ -503,7 +526,9 @@ getpage(register DBM *db, register long int hash)
}
static int
-getdbit(register DBM *db, register long int dbit)
+getdbit(db, dbit)
+register DBM *db;
+register long dbit;
{
register long c;
register long dirb;
@@ -524,7 +549,9 @@ getdbit(register DBM *db, register long int dbit)
}
static int
-setdbit(register DBM *db, register long int dbit)
+setdbit(db, dbit)
+register DBM *db;
+register long dbit;
{
register long c;
register long dirb;
@@ -558,7 +585,8 @@ setdbit(register DBM *db, register long int dbit)
* the page, try the next page in sequence
*/
static datum
-getnext(register DBM *db)
+getnext(db)
+register DBM *db;
{
datum key;
@@ -633,7 +661,9 @@ static int seepair proto((char *, int, char *, int));
*/
static int
-fitpair(char *pag, int need)
+fitpair(pag, need)
+char *pag;
+int need;
{
register int n;
register int off;
@@ -650,7 +680,10 @@ fitpair(char *pag, int need)
}
static void
-putpair(char *pag, datum key, datum val)
+putpair(pag, key, val)
+char *pag;
+datum key;
+datum val;
{
register int n;
register int off;
@@ -678,7 +711,9 @@ putpair(char *pag, datum key, datum val)
}
static datum
-getpair(char *pag, datum key)
+getpair(pag, key)
+char *pag;
+datum key;
{
register int i;
register int n;
@@ -698,7 +733,9 @@ getpair(char *pag, datum key)
#ifdef SEEDUPS
static int
-duppair(char *pag, datum key)
+duppair(pag, key)
+char *pag;
+datum key;
{
register short *ino = (short *) pag;
return GET_SHORT(ino,0) > 0 &&
@@ -707,7 +744,9 @@ duppair(char *pag, datum key)
#endif
static datum
-getnkey(char *pag, int num)
+getnkey(pag, num)
+char *pag;
+int num;
{
datum key;
register int off;
@@ -726,7 +765,9 @@ getnkey(char *pag, int num)
}
static int
-delpair(char *pag, datum key)
+delpair(pag, key)
+char *pag;
+datum key;
{
register int n;
register int i;
@@ -796,7 +837,11 @@ delpair(char *pag, datum key)
* return 0 if not found.
*/
static int
-seepair(char *pag, register int n, register char *key, register int siz)
+seepair(pag, n, key, siz)
+char *pag;
+register int n;
+register char *key;
+register int siz;
{
register int i;
register int off = PBLKSIZ;
@@ -812,7 +857,10 @@ seepair(char *pag, register int n, register char *key, register int siz)
}
static void
-splpage(char *pag, char *new, long int sbit)
+splpage(pag, new, sbit)
+char *pag;
+char *new;
+long sbit;
{
datum key;
datum val;
@@ -853,7 +901,8 @@ splpage(char *pag, char *new, long int sbit)
* this could be made more rigorous.
*/
static int
-chkpage(char *pag)
+chkpage(pag)
+char *pag;
{
register int n;
register int off;
@@ -893,7 +942,9 @@ chkpage(char *pag)
* 65587 even better.
*/
long
-sdbm_hash(register char *str, register int len)
+sdbm_hash(str, len)
+register char *str;
+register int len;
{
register unsigned long n = 0;
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 08a3ab8bf5..acadc9b26a 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -41,7 +41,8 @@ closed_sdbm()
}
static void
-free_sdbm(struct dbmdata *dbmp)
+free_sdbm(dbmp)
+ struct dbmdata *dbmp;
{
if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm);
@@ -49,7 +50,8 @@ free_sdbm(struct dbmdata *dbmp)
}
static VALUE
-fsdbm_close(VALUE obj)
+fsdbm_close(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
@@ -61,7 +63,8 @@ fsdbm_close(VALUE obj)
}
static VALUE
-fsdbm_closed(VALUE obj)
+fsdbm_closed(obj)
+ VALUE obj;
{
struct dbmdata *dbmp;
@@ -74,14 +77,19 @@ fsdbm_closed(VALUE obj)
return Qfalse;
}
+static VALUE fsdbm_alloc _((VALUE));
static VALUE
-fsdbm_alloc(VALUE klass)
+fsdbm_alloc(klass)
+ VALUE klass;
{
return Data_Wrap_Struct(klass, 0, free_sdbm, 0);
}
static VALUE
-fsdbm_initialize(int argc, VALUE *argv, VALUE obj)
+fsdbm_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE file, vmode;
DBM *dbm;
@@ -101,15 +109,15 @@ fsdbm_initialize(int argc, VALUE *argv, VALUE obj)
dbm = 0;
if (mode >= 0)
- dbm = sdbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode);
+ dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
if (!dbm)
- dbm = sdbm_open(RSTRING_PTR(file), O_RDWR, 0);
+ dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR, 0);
if (!dbm)
- dbm = sdbm_open(RSTRING_PTR(file), O_RDONLY, 0);
+ dbm = sdbm_open(RSTRING(file)->ptr, O_RDONLY, 0);
if (!dbm) {
if (mode == -1) return Qnil;
- rb_sys_fail(RSTRING_PTR(file));
+ rb_sys_fail(RSTRING(file)->ptr);
}
dbmp = ALLOC(struct dbmdata);
@@ -121,7 +129,10 @@ fsdbm_initialize(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-fsdbm_s_open(int argc, VALUE *argv, VALUE klass)
+fsdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE obj = Data_Wrap_Struct(klass, 0, free_sdbm, 0);
@@ -137,15 +148,16 @@ fsdbm_s_open(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-fsdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
+fsdbm_fetch(obj, keystr, ifnone)
+ VALUE obj, keystr, ifnone;
{
datum key, value;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
value = sdbm_fetch(dbm, key);
@@ -158,13 +170,17 @@ fsdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
}
static VALUE
-fsdbm_aref(VALUE obj, VALUE keystr)
+fsdbm_aref(obj, keystr)
+ VALUE obj, keystr;
{
return fsdbm_fetch(obj, keystr, Qnil);
}
static VALUE
-fsdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
+fsdbm_fetch_m(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE keystr, valstr, ifnone;
@@ -177,52 +193,90 @@ fsdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-fsdbm_index(VALUE obj, VALUE valstr)
+fsdbm_index(obj, valstr)
+ VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(valstr);
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(valstr);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
GetDBM2(obj, dbmp, dbm);
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
- if (val.dsize == RSTRING_LEN(valstr) &&
- memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
+ if (val.dsize == RSTRING(valstr)->len &&
+ memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
return rb_tainted_str_new(key.dptr, key.dsize);
}
return Qnil;
}
static VALUE
-fsdbm_select(VALUE obj)
+fsdbm_indexes(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
- VALUE new = rb_ary_new();
- datum key, val;
- DBM *dbm;
- struct dbmdata *dbmp;
+ VALUE new;
+ int i;
- GetDBM2(obj, dbmp, dbm);
- for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
- VALUE assoc, v;
- val = sdbm_fetch(dbm, key);
- assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
- rb_tainted_str_new(val.dptr, val.dsize));
- v = rb_yield(assoc);
- if (RTEST(v)) {
- rb_ary_push(new, assoc);
+ new = rb_ary_new2(argc);
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
+ }
+
+ return new;
+}
+
+static VALUE
+fsdbm_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ if (rb_block_given_p()) {
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
- GetDBM2(obj, dbmp, dbm);
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ VALUE assoc, v;
+ val = sdbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ v = rb_yield(assoc);
+ if (RTEST(v)) {
+ rb_ary_push(new, assoc);
+ }
+ GetDBM2(obj, dbmp, dbm);
+ }
+ }
+ else {
+ rb_warn("SDBM#select(index..) is deprecated; use SDBM#values_at");
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
+ }
}
return new;
}
static VALUE
-fsdbm_values_at(int argc, VALUE *argv, VALUE obj)
+fsdbm_values_at(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE new = rb_ary_new2(argc);
int i;
@@ -235,14 +289,16 @@ fsdbm_values_at(int argc, VALUE *argv, VALUE obj)
}
static void
-fdbm_modify(VALUE obj)
+fdbm_modify(obj)
+ VALUE obj;
{
rb_secure(4);
if (OBJ_FROZEN(obj)) rb_error_frozen("SDBM");
}
static VALUE
-fsdbm_delete(VALUE obj, VALUE keystr)
+fsdbm_delete(obj, keystr)
+ VALUE obj, keystr;
{
datum key, value;
struct dbmdata *dbmp;
@@ -251,8 +307,8 @@ fsdbm_delete(VALUE obj, VALUE keystr)
fdbm_modify(obj);
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1;
@@ -277,7 +333,8 @@ fsdbm_delete(VALUE obj, VALUE keystr)
}
static VALUE
-fsdbm_shift(VALUE obj)
+fsdbm_shift(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -300,7 +357,8 @@ fsdbm_shift(VALUE obj)
}
static VALUE
-fsdbm_delete_if(VALUE obj)
+fsdbm_delete_if(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -323,23 +381,24 @@ fsdbm_delete_if(VALUE obj)
GetDBM2(obj, dbmp, dbm);
}
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- keystr = RARRAY_PTR(ary)[i];
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ keystr = RARRAY(ary)->ptr[i];
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
if (sdbm_delete(dbm, key)) {
rb_raise(rb_eDBMError, "sdbm_delete failed");
}
}
if (status) rb_jump_tag(status);
- if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
+ if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
return obj;
}
static VALUE
-fsdbm_clear(VALUE obj)
+fsdbm_clear(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -359,7 +418,8 @@ fsdbm_clear(VALUE obj)
}
static VALUE
-fsdbm_invert(VALUE obj)
+fsdbm_invert(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -377,8 +437,49 @@ fsdbm_invert(VALUE obj)
return hash;
}
+static VALUE each_pair _((VALUE));
+
static VALUE
-fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
+each_pair(obj)
+ VALUE obj;
+{
+ return rb_funcall(obj, rb_intern("each_pair"), 0, 0);
+}
+
+static VALUE fsdbm_store _((VALUE,VALUE,VALUE));
+
+static VALUE
+update_i(pair, dbm)
+ VALUE pair, dbm;
+{
+ Check_Type(pair, T_ARRAY);
+ if (RARRAY(pair)->len < 2) {
+ rb_raise(rb_eArgError, "pair must be [key, value]");
+ }
+ fsdbm_store(dbm, RARRAY(pair)->ptr[0], RARRAY(pair)->ptr[1]);
+ return Qnil;
+}
+
+static VALUE
+fsdbm_update(obj, other)
+ VALUE obj, other;
+{
+ rb_iterate(each_pair, other, update_i, obj);
+ return obj;
+}
+
+static VALUE
+fsdbm_replace(obj, other)
+ VALUE obj, other;
+{
+ fsdbm_clear(obj);
+ rb_iterate(each_pair, other, update_i, obj);
+ return obj;
+}
+
+static VALUE
+fsdbm_store(obj, keystr, valstr)
+ VALUE obj, keystr, valstr;
{
datum key, val;
struct dbmdata *dbmp;
@@ -393,11 +494,11 @@ fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
StringValue(keystr);
StringValue(valstr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(valstr);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1;
@@ -413,33 +514,8 @@ fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
}
static VALUE
-update_i(VALUE pair, VALUE dbm)
-{
- Check_Type(pair, T_ARRAY);
- if (RARRAY_LEN(pair) < 2) {
- rb_raise(rb_eArgError, "pair must be [key, value]");
- }
- fsdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
- return Qnil;
-}
-
-static VALUE
-fsdbm_update(VALUE obj, VALUE other)
-{
- rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
- return obj;
-}
-
-static VALUE
-fsdbm_replace(VALUE obj, VALUE other)
-{
- fsdbm_clear(obj);
- rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
- return obj;
-}
-
-static VALUE
-fsdbm_length(VALUE obj)
+fsdbm_length(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -458,7 +534,8 @@ fsdbm_length(VALUE obj)
}
static VALUE
-fsdbm_empty_p(VALUE obj)
+fsdbm_empty_p(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -481,7 +558,8 @@ fsdbm_empty_p(VALUE obj)
}
static VALUE
-fsdbm_each_value(VALUE obj)
+fsdbm_each_value(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -497,7 +575,8 @@ fsdbm_each_value(VALUE obj)
}
static VALUE
-fsdbm_each_key(VALUE obj)
+fsdbm_each_key(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -512,7 +591,8 @@ fsdbm_each_key(VALUE obj)
}
static VALUE
-fsdbm_each_pair(VALUE obj)
+fsdbm_each_pair(obj)
+ VALUE obj;
{
datum key, val;
DBM *dbm;
@@ -532,7 +612,8 @@ fsdbm_each_pair(VALUE obj)
}
static VALUE
-fsdbm_keys(VALUE obj)
+fsdbm_keys(obj)
+ VALUE obj;
{
datum key;
struct dbmdata *dbmp;
@@ -549,7 +630,8 @@ fsdbm_keys(VALUE obj)
}
static VALUE
-fsdbm_values(VALUE obj)
+fsdbm_values(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -567,15 +649,16 @@ fsdbm_values(VALUE obj)
}
static VALUE
-fsdbm_has_key(VALUE obj, VALUE keystr)
+fsdbm_has_key(obj, keystr)
+ VALUE obj, keystr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(keystr);
- key.dptr = RSTRING_PTR(keystr);
- key.dsize = RSTRING_LEN(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
GetDBM2(obj, dbmp, dbm);
val = sdbm_fetch(dbm, key);
@@ -584,28 +667,30 @@ fsdbm_has_key(VALUE obj, VALUE keystr)
}
static VALUE
-fsdbm_has_value(VALUE obj, VALUE valstr)
+fsdbm_has_value(obj, valstr)
+ VALUE obj, valstr;
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
StringValue(valstr);
- val.dptr = RSTRING_PTR(valstr);
- val.dsize = RSTRING_LEN(valstr);
+ val.dptr = RSTRING(valstr)->ptr;
+ val.dsize = RSTRING(valstr)->len;
GetDBM2(obj, dbmp, dbm);
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
- if (val.dsize == RSTRING_LEN(valstr) &&
- memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
+ if (val.dsize == RSTRING(valstr)->len &&
+ memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
return Qtrue;
}
return Qfalse;
}
static VALUE
-fsdbm_to_a(VALUE obj)
+fsdbm_to_a(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -624,7 +709,8 @@ fsdbm_to_a(VALUE obj)
}
static VALUE
-fsdbm_to_hash(VALUE obj)
+fsdbm_to_hash(obj)
+ VALUE obj;
{
datum key, val;
struct dbmdata *dbmp;
@@ -643,7 +729,8 @@ fsdbm_to_hash(VALUE obj)
}
static VALUE
-fsdbm_reject(VALUE obj)
+fsdbm_reject(obj)
+ VALUE obj;
{
return rb_hash_delete_if(fsdbm_to_hash(obj));
}
@@ -666,7 +753,9 @@ Init_sdbm()
rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2);
rb_define_method(rb_cDBM, "store", fsdbm_store, 2);
rb_define_method(rb_cDBM, "index", fsdbm_index, 1);
- rb_define_method(rb_cDBM, "select", fsdbm_select, 0);
+ rb_define_method(rb_cDBM, "indexes", fsdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "indices", fsdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "select", fsdbm_select, -1);
rb_define_method(rb_cDBM, "values_at", fsdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fsdbm_length, 0);
rb_define_method(rb_cDBM, "size", fsdbm_length, 0);
diff --git a/ext/socket/.cvsignore b/ext/socket/.cvsignore
index ce98586d91..4088712231 100644
--- a/ext/socket/.cvsignore
+++ b/ext/socket/.cvsignore
@@ -1,5 +1,3 @@
Makefile
mkmf.log
*.def
-constants.h
-extconf.h
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index a22615ee00..e93adafba6 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -61,10 +61,15 @@
#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/depend b/ext/socket/depend
index 7577a6929a..cca6d4e62a 100644
--- a/ext/socket/depend
+++ b/ext/socket/depend
@@ -1,9 +1,3 @@
-socket.o: socket.c $(hdrdir)/ruby/ruby.h $(arch_hdrdir)/ruby/config.h \
- $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/io.h $(hdrdir)/ruby/signal.h \
- sockport.h constants.h
-getnameinfo.o: getnameinfo.c $(arch_hdrdir)/ruby/config.h addrinfo.h sockport.h
-getaddrinfo.o: getaddrinfo.c $(arch_hdrdir)/ruby/config.h addrinfo.h sockport.h
-
-constants.h: $(srcdir)/mkconstants.rb
- @echo "generating constants.h"
- @$(RUBY) $(srcdir)/mkconstants.rb > $@
+socket.o : socket.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/rubyio.h $(hdrdir)/rubysig.h sockport.h
+getnameinfo.o: getnameinfo.c $(topdir)/config.h addrinfo.h sockport.h
+getaddrinfo.o: getaddrinfo.c $(topdir)/config.h addrinfo.h sockport.h
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 0791714e49..8a13ddba73 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -1,14 +1,22 @@
require 'mkmf'
case RUBY_PLATFORM
-when /(ms|bcc)win32|mingw/
+when /bccwin32/
test_func = "WSACleanup"
have_library("ws2_32", "WSACleanup")
+when /mswin32|mingw/
+ test_func = "WSACleanup"
+ if with_config("winsock2")
+ have_library("ws2_32", "WSACleanup")
+ else
+ have_library("wsock32", "WSACleanup")
+ end
when /cygwin/
test_func = "socket"
when /beos/
test_func = "socket"
have_library("net", "socket")
+ have_func("closesocket")
when /i386-os2_emx/
test_func = "socket"
have_library("socket", "socket")
@@ -86,10 +94,17 @@ if have_struct_member("struct sockaddr_in", "sin_len", headers)
end
# doug's fix, NOW add -Dss_family... only if required!
-doug = proc {have_struct_member("struct sockaddr_storage", "ss_family", headers)}
-if (doug[] or
- with_cppflags($CPPFLAGS + " -Dss_family=__ss_family -Dss_len=__ss_len", &doug))
- $defs[-1] = "-DHAVE_SOCKADDR_STORAGE"
+[nil, " -Dss_family=__ss_family -Dss_len=__ss_len"].each do |flags|
+ if flags
+ cppflags = $CPPFLAGS
+ $CPPFLAGS += flags
+ end
+ if have_struct_member("struct sockaddr_storage", "ss_family", headers)
+ $defs[-1] = "-DHAVE_SOCKADDR_STORAGE"
+ break
+ elsif flags
+ $CPPFLAGS = cppflags
+ end
end
if have_struct_member("struct sockaddr", "sa_len", headers)
@@ -255,8 +270,6 @@ end
have_header("sys/un.h")
have_header("sys/uio.h")
-$distcleanfiles << "constants.h"
-
if have_func(test_func)
have_func("hsterror")
have_func("getipnodebyname") or have_func("gethostbyname2")
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index d97012a3c5..9fb4ebcb06 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -38,9 +38,9 @@
* - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag.
*/
-#include "ruby/config.h"
+#include "config.h"
#include <sys/types.h>
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__VMS)
#include <sys/param.h>
#if defined(__BEOS__)
# include <net/socket.h>
@@ -62,6 +62,11 @@
#include <resolv.h>
#endif
#include <unistd.h>
+#elif defined(__VMS )
+#include <socket.h>
+#include <inet.h>
+#include <in.h>
+#include <netdb.h>
#else
#include <winsock2.h>
#include <io.h>
@@ -198,7 +203,8 @@ if (pai->ai_flags & AI_CANONNAME) {\
const
#endif
char *
-gai_strerror(int ecode)
+gai_strerror(ecode)
+ int ecode;
{
if (ecode < 0 || ecode > EAI_MAX)
ecode = EAI_MAX;
@@ -206,7 +212,8 @@ gai_strerror(int ecode)
}
void
-freeaddrinfo(struct addrinfo *ai)
+freeaddrinfo(ai)
+ struct addrinfo *ai;
{
struct addrinfo *next;
@@ -220,7 +227,8 @@ freeaddrinfo(struct addrinfo *ai)
}
static int
-str_isnumber(const char *p)
+str_isnumber(p)
+ const char *p;
{
char *q = (char *)p;
while (*q) {
@@ -234,7 +242,10 @@ str_isnumber(const char *p)
#ifndef HAVE_INET_PTON
static int
-inet_pton(int af, const char *hostname, void *pton)
+inet_pton(af, hostname, pton)
+ int af;
+ const char *hostname;
+ void *pton;
{
struct in_addr in;
@@ -262,7 +273,10 @@ inet_pton(int af, const char *hostname, void *pton)
#endif
int
-getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
+getaddrinfo(hostname, servname, hints, res)
+ const char *hostname, *servname;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
{
struct addrinfo sentinel;
struct addrinfo *top = NULL;
@@ -428,7 +442,7 @@ getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *h
s = socket(afd->a_af, SOCK_DGRAM, 0);
if (s < 0)
continue;
-#if defined(__BEOS__)
+#if defined(HAVE_CLOSESOCKET)
closesocket(s);
#else
close(s);
@@ -529,7 +543,13 @@ getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *h
}
static int
-get_name(const char *addr, const struct afd *afd, struct addrinfo **res, char *numaddr, struct addrinfo *pai, int port0)
+get_name(addr, afd, res, numaddr, pai, port0)
+ const char *addr;
+ const struct afd *afd;
+ struct addrinfo **res;
+ char *numaddr;
+ struct addrinfo *pai;
+ int port0;
{
u_short port = port0 & 0xffff;
struct hostent *hp;
@@ -569,7 +589,12 @@ get_name(const char *addr, const struct afd *afd, struct addrinfo **res, char *n
}
static int
-get_addr(const char *hostname, int af, struct addrinfo **res, struct addrinfo *pai, int port0)
+get_addr(hostname, af, res, pai, port0)
+ const char *hostname;
+ int af;
+ struct addrinfo **res;
+ struct addrinfo *pai;
+ int port0;
{
u_short port = port0 & 0xffff;
struct addrinfo sentinel;
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index 6214359cd2..66f7e8818a 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -34,7 +34,7 @@
* but INRIA implementation returns EAI_xxx defined for getaddrinfo().
*/
-#include "ruby/config.h"
+#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#ifndef _WIN32
@@ -112,7 +112,11 @@ static struct afd {
#ifndef HAVE_INET_NTOP
static const char *
-inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
+inet_ntop(af, addr, numaddr, numaddr_len)
+ int af;
+ const void *addr;
+ char *numaddr;
+ size_t numaddr_len;
{
#ifdef HAVE_INET_NTOA
struct in_addr in;
@@ -129,7 +133,14 @@ inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
#endif
int
-getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
+getnameinfo(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 afd *afd;
struct servent *sp;
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
deleted file mode 100644
index 5212739876..0000000000
--- a/ext/socket/mkconstants.rb
+++ /dev/null
@@ -1,262 +0,0 @@
-$out ||= $stdout
-
-# workaround for NetBSD, OpenBSD and etc.
-$out.puts("#define pseudo_AF_FTIP pseudo_AF_RTIP")
-
-# skip empty lines and comment lines
-DATA.each_line do |s|
- name, value = s.scan(/\S+/)
- if name && name[0] != ?#
- $out.puts("#ifdef #{name}")
- $out.puts(" sock_define_const(\"#{name}\", #{name});")
- if value
- $out.puts("#else")
- $out.puts(" sock_define_const(\"#{name}\", #{value});")
- end
- $out.puts("#endif")
- $out.puts
- end
-end
-
-__END__
-
-SOCK_STREAM
-SOCK_DGRAM
-SOCK_RAW
-SOCK_RDM
-SOCK_SEQPACKET
-SOCK_PACKET
-
-AF_INET
-PF_INET
-AF_UNIX
-PF_UNIX
-AF_AX25
-PF_AX25
-AF_IPX
-PF_IPX
-AF_APPLETALK
-PF_APPLETALK
-AF_UNSPEC
-PF_UNSPEC
-AF_LOCAL
-PF_LOCAL
-AF_IMPLINK
-PF_IMPLINK
-AF_PUP
-PF_PUP
-AF_CHAOS
-PF_CHAOS
-AF_NS
-PF_NS
-AF_ISO
-PF_ISO
-AF_OSI
-PF_OSI
-AF_ECMA
-PF_ECMA
-AF_DATAKIT
-PF_DATAKIT
-AF_CCITT
-PF_CCITT
-AF_SNA
-PF_SNA
-AF_DEC
-PF_DEC
-AF_DLI
-PF_DLI
-AF_LAT
-PF_LAT
-AF_HYLINK
-PF_HYLINK
-AF_ROUTE
-PF_ROUTE
-AF_LINK
-PF_LINK
-AF_COIP
-PF_COIP
-AF_CNT
-PF_CNT
-AF_SIP
-PF_SIP
-AF_NDRV
-PF_NDRV
-AF_ISDN
-PF_ISDN
-AF_NATM
-PF_NATM
-AF_SYSTEM
-PF_SYSTEM
-AF_NETBIOS
-PF_NETBIOS
-AF_PPP
-PF_PPP
-AF_ATM
-PF_ATM
-AF_NETGRAPH
-PF_NETGRAPH
-AF_MAX
-PF_MAX
-
-AF_E164
-PF_XTP
-PF_RTIP
-PF_PIP
-PF_KEY
-
-MSG_OOB
-MSG_PEEK
-MSG_DONTROUTE
-MSG_EOR
-MSG_TRUNC
-MSG_CTRUNC
-MSG_WAITALL
-MSG_DONTWAIT
-MSG_EOF
-MSG_FLUSH
-MSG_HOLD
-MSG_SEND
-MSG_HAVEMORE
-MSG_RCVMORE
-MSG_COMPAT
-
-SOL_SOCKET
-SOL_IP
-SOL_IPX
-SOL_AX25
-SOL_ATALK
-SOL_TCP
-SOL_UDP
-
-IPPROTO_IP 0
-IPPROTO_ICMP 1
-IPPROTO_IGMP
-IPPROTO_GGP
-IPPROTO_TCP 6
-IPPROTO_EGP
-IPPROTO_PUP
-IPPROTO_UDP 17
-IPPROTO_IDP
-IPPROTO_HELLO
-IPPROTO_ND
-IPPROTO_TP
-IPPROTO_XTP
-IPPROTO_EON
-IPPROTO_BIP
-IPPROTO_RAW 255
-IPPROTO_MAX
-
-# Some port configuration
-IPPORT_RESERVED 1024
-IPPORT_USERRESERVED 5000
-
-# Some reserved IP v.4 addresses
-INADDR_ANY 0x00000000
-INADDR_BROADCAST 0xffffffff
-INADDR_LOOPBACK 0x7F000001
-INADDR_UNSPEC_GROUP 0xe0000000
-INADDR_ALLHOSTS_GROUP 0xe0000001
-INADDR_MAX_LOCAL_GROUP 0xe00000ff
-INADDR_NONE 0xffffffff
-
-# IP [gs]etsockopt options
-IP_OPTIONS
-IP_HDRINCL
-IP_TOS
-IP_TTL
-IP_RECVOPTS
-IP_RECVRETOPTS
-IP_RECVDSTADDR
-IP_RETOPTS
-IP_MULTICAST_IF
-IP_MULTICAST_TTL
-IP_MULTICAST_LOOP
-IP_ADD_MEMBERSHIP
-IP_DROP_MEMBERSHIP
-IP_DEFAULT_MULTICAST_TTL
-IP_DEFAULT_MULTICAST_LOOP
-IP_MAX_MEMBERSHIPS
-
-SO_DEBUG
-SO_REUSEADDR
-SO_REUSEPORT
-SO_TYPE
-SO_ERROR
-SO_DONTROUTE
-SO_BROADCAST
-SO_SNDBUF
-SO_RCVBUF
-SO_KEEPALIVE
-SO_OOBINLINE
-SO_NO_CHECK
-SO_PRIORITY
-SO_LINGER
-SO_PASSCRED
-SO_PEERCRED
-SO_RCVLOWAT
-SO_SNDLOWAT
-SO_RCVTIMEO
-SO_SNDTIMEO
-SO_ACCEPTCONN
-SO_USELOOPBACK
-SO_ACCEPTFILTER
-SO_DONTTRUNC
-SO_WANTMORE
-SO_WANTOOBFLAG
-SO_NREAD
-SO_NKE
-SO_NOSIGPIPE
-SO_SECURITY_AUTHENTICATION
-SO_SECURITY_ENCRYPTION_TRANSPORT
-SO_SECURITY_ENCRYPTION_NETWORK
-SO_BINDTODEVICE
-SO_ATTACH_FILTER
-SO_DETACH_FILTER
-SO_PEERNAME
-SO_TIMESTAMP
-
-SOPRI_INTERACTIVE
-SOPRI_NORMAL
-SOPRI_BACKGROUND
-
-IPX_TYPE
-
-TCP_NODELAY
-TCP_MAXSEG
-
-EAI_ADDRFAMILY
-EAI_AGAIN
-EAI_BADFLAGS
-EAI_FAIL
-EAI_FAMILY
-EAI_MEMORY
-EAI_NODATA
-EAI_NONAME
-EAI_SERVICE
-EAI_SOCKTYPE
-EAI_SYSTEM
-EAI_BADHINTS
-EAI_PROTOCOL
-EAI_MAX
-
-AI_PASSIVE
-AI_CANONNAME
-AI_NUMERICHOST
-AI_MASK
-AI_ALL
-AI_V4MAPPED_CFG
-AI_ADDRCONFIG
-AI_V4MAPPED
-AI_DEFAULT
-
-NI_MAXHOST
-NI_MAXSERV
-NI_NOFQDN
-NI_NUMERICHOST
-NI_NAMEREQD
-NI_NUMERICSERV
-NI_DGRAM
-
-SHUT_RD 0
-SHUT_WR 1
-SHUT_RDWR 2
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 29fa71f8ae..1dcc7160e9 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -6,14 +6,14 @@
$Date$
created at: Thu Mar 31 12:21:29 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2001 Yukihiro Matsumoto
************************************************/
-#include "ruby/ruby.h"
-#include "ruby/io.h"
-#include "ruby/signal.h"
-#include "ruby/util.h"
+#include "ruby.h"
+#include "rubyio.h"
+#include "rubysig.h"
+#include "util.h"
#include <stdio.h>
#include <sys/types.h>
@@ -30,6 +30,7 @@
# include <net/socket.h>
#else
# include <sys/socket.h>
+# define pseudo_AF_FTIP pseudo_AF_RTIP /* workaround for NetBSD and etc. */
#endif
#include <netinet/in.h>
#ifdef HAVE_NETINET_IN_SYSTM_H
@@ -73,8 +74,11 @@
#endif
#include "sockport.h"
+#if defined(__vms)
+#include <tcp.h>
+#endif
+
static int do_not_reverse_lookup = 0;
-#define FMODE_NOREVLOOKUP 0x100
VALUE rb_cBasicSocket;
VALUE rb_cIPSocket;
@@ -139,8 +143,11 @@ static int lookup_order_table[LOOKUP_ORDERS] = {
};
static int
-ruby_getaddrinfo(char *nodename, char *servname,
- struct addrinfo *hints, struct addrinfo **res)
+ruby_getaddrinfo(nodename, servname, hints, res)
+ char *nodename;
+ char *servname;
+ struct addrinfo *hints;
+ struct addrinfo **res;
{
struct addrinfo tmp_hints;
int i, af, error;
@@ -171,8 +178,11 @@ ruby_getaddrinfo(char *nodename, char *servname,
#if defined(_AIX)
static int
-ruby_getaddrinfo__aix(char *nodename, char *servname,
- struct addrinfo *hints, struct addrinfo **res)
+ruby_getaddrinfo__aix(nodename, servname, hints, res)
+ char *nodename;
+ char *servname;
+ struct addrinfo *hints;
+ struct addrinfo **res;
{
int error = getaddrinfo(nodename, servname, hints, res);
struct addrinfo *r;
@@ -224,29 +234,30 @@ ruby_getnameinfo__aix(sa, salen, host, hostlen, serv, servlen, flags)
#endif
#endif
-#ifdef __BEOS__
+#ifdef HAVE_CLOSESOCKET
#undef close
#define close closesocket
#endif
static VALUE
-init_sock(VALUE sock, int fd)
+init_sock(sock, fd)
+ VALUE sock;
+ int fd;
{
rb_io_t *fp;
MakeOpenFile(sock, fp);
- fp->fd = fd;
- fp->mode = FMODE_READWRITE|FMODE_DUPLEX;
- if (do_not_reverse_lookup) {
- fp->mode |= FMODE_NOREVLOOKUP;
- }
+ fp->f = rb_fdopen(fd, "r");
+ fp->f2 = rb_fdopen(fd, "w");
+ fp->mode = FMODE_READWRITE;
rb_io_synchronized(fp);
return sock;
}
static VALUE
-bsock_s_for_fd(VALUE klass, VALUE fd)
+bsock_s_for_fd(klass, fd)
+ VALUE klass, fd;
{
rb_io_t *fptr;
VALUE sock = init_sock(rb_obj_alloc(klass), NUM2INT(fd));
@@ -257,7 +268,10 @@ bsock_s_for_fd(VALUE klass, VALUE fd)
}
static VALUE
-bsock_shutdown(int argc, VALUE *argv, VALUE sock)
+bsock_shutdown(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
VALUE howto;
int how;
@@ -276,14 +290,15 @@ bsock_shutdown(int argc, VALUE *argv, VALUE sock)
}
}
GetOpenFile(sock, fptr);
- if (shutdown(fptr->fd, how) == -1)
+ if (shutdown(fileno(fptr->f), how) == -1)
rb_sys_fail(0);
return INT2FIX(0);
}
static VALUE
-bsock_close_read(VALUE sock)
+bsock_close_read(sock)
+ VALUE sock;
{
rb_io_t *fptr;
@@ -291,7 +306,7 @@ bsock_close_read(VALUE sock)
rb_raise(rb_eSecurityError, "Insecure: can't close socket");
}
GetOpenFile(sock, fptr);
- shutdown(fptr->fd, 0);
+ shutdown(fileno(fptr->f), 0);
if (!(fptr->mode & FMODE_WRITABLE)) {
return rb_io_close(sock);
}
@@ -301,7 +316,8 @@ bsock_close_read(VALUE sock)
}
static VALUE
-bsock_close_write(VALUE sock)
+bsock_close_write(sock)
+ VALUE sock;
{
rb_io_t *fptr;
@@ -312,7 +328,7 @@ bsock_close_write(VALUE sock)
if (!(fptr->mode & FMODE_READABLE)) {
return rb_io_close(sock);
}
- shutdown(fptr->fd, 1);
+ shutdown(fileno(fptr->f2), 1);
fptr->mode &= ~FMODE_WRITABLE;
return Qnil;
@@ -364,7 +380,8 @@ bsock_close_write(VALUE sock)
*
*/
static VALUE
-bsock_setsockopt(VALUE sock, VALUE lev, VALUE optname, VALUE val)
+bsock_setsockopt(sock, lev, optname, val)
+ VALUE sock, lev, optname, val;
{
int level, option;
rb_io_t *fptr;
@@ -390,13 +407,13 @@ bsock_setsockopt(VALUE sock, VALUE lev, VALUE optname, VALUE val)
break;
default:
StringValue(val);
- v = RSTRING_PTR(val);
- vlen = RSTRING_LEN(val);
+ v = RSTRING(val)->ptr;
+ vlen = RSTRING(val)->len;
break;
}
GetOpenFile(sock, fptr);
- if (setsockopt(fptr->fd, level, option, v, vlen) < 0)
+ if (setsockopt(fileno(fptr->f), level, option, v, vlen) < 0)
rb_sys_fail(fptr->path);
return INT2FIX(0);
@@ -443,7 +460,8 @@ bsock_setsockopt(VALUE sock, VALUE lev, VALUE optname, VALUE val)
* onoff, linger = optval.unpack "ii"
*/
static VALUE
-bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
+bsock_getsockopt(sock, lev, optname)
+ VALUE sock, lev, optname;
{
#if !defined(__BEOS__)
int level, option;
@@ -455,9 +473,10 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
option = NUM2INT(optname);
len = 256;
buf = ALLOCA_N(char,len);
+ GetOpenFile(sock, fptr);
GetOpenFile(sock, fptr);
- if (getsockopt(fptr->fd, level, option, buf, &len) < 0)
+ if (getsockopt(fileno(fptr->f), level, option, buf, &len) < 0)
rb_sys_fail(fptr->path);
return rb_str_new(buf, len);
@@ -467,37 +486,43 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
}
static VALUE
-bsock_getsockname(VALUE sock)
+bsock_getsockname(sock)
+ VALUE sock;
{
char buf[1024];
socklen_t len = sizeof buf;
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- if (getsockname(fptr->fd, (struct sockaddr*)buf, &len) < 0)
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
rb_sys_fail("getsockname(2)");
return rb_str_new(buf, len);
}
static VALUE
-bsock_getpeername(VALUE sock)
+bsock_getpeername(sock)
+ VALUE sock;
{
char buf[1024];
socklen_t len = sizeof buf;
rb_io_t *fptr;
GetOpenFile(sock, fptr);
- if (getpeername(fptr->fd, (struct sockaddr*)buf, &len) < 0)
+ if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
rb_sys_fail("getpeername(2)");
return rb_str_new(buf, len);
}
static VALUE
-bsock_send(int argc, VALUE *argv, VALUE sock)
+bsock_send(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
VALUE mesg, to;
VALUE flags;
rb_io_t *fptr;
+ FILE *f;
int fd, n;
rb_secure(4);
@@ -506,18 +531,19 @@ bsock_send(int argc, VALUE *argv, VALUE sock)
StringValue(mesg);
if (!NIL_P(to)) StringValue(to);
GetOpenFile(sock, fptr);
- fd = fptr->fd;
+ f = GetWriteFile(fptr);
+ fd = fileno(f);
rb_thread_fd_writable(fd);
retry:
if (!NIL_P(to)) {
TRAP_BEG;
- n = sendto(fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg), NUM2INT(flags),
- (struct sockaddr*)RSTRING_PTR(to), RSTRING_LEN(to));
+ n = sendto(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags),
+ (struct sockaddr*)RSTRING(to)->ptr, RSTRING(to)->len);
TRAP_END;
}
else {
TRAP_BEG;
- n = send(fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg), NUM2INT(flags));
+ n = send(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags));
TRAP_END;
}
if (n < 0) {
@@ -529,34 +555,9 @@ bsock_send(int argc, VALUE *argv, VALUE sock)
return INT2FIX(n);
}
-static VALUE
-bsock_do_not_reverse_lookup(VALUE sock)
-{
- rb_io_t *fptr;
-
- GetOpenFile(sock, fptr);
- return (fptr->mode & FMODE_NOREVLOOKUP) ? Qtrue : Qfalse;
-}
-
-static VALUE
-bsock_do_not_reverse_lookup_set(VALUE sock, VALUE state)
-{
- rb_io_t *fptr;
-
- rb_secure(4);
- GetOpenFile(sock, fptr);
- if (RTEST(state)) {
- fptr->mode |= FMODE_NOREVLOOKUP;
- }
- else {
- fptr->mode &= ~FMODE_NOREVLOOKUP;
- }
- return sock;
-}
-
-static VALUE ipaddr(struct sockaddr*, int);
+static VALUE ipaddr _((struct sockaddr*));
#ifdef HAVE_SYS_UN_H
-static VALUE unixaddr(struct sockaddr_un*, socklen_t);
+static VALUE unixaddr _((struct sockaddr_un*, socklen_t));
#endif
enum sock_recv_type {
@@ -567,7 +568,11 @@ enum sock_recv_type {
};
static VALUE
-s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
+s_recvfrom(sock, argc, argv, from)
+ VALUE sock;
+ int argc;
+ VALUE *argv;
+ enum sock_recv_type from;
{
rb_io_t *fptr;
VALUE str;
@@ -585,22 +590,20 @@ s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
buflen = NUM2INT(len);
GetOpenFile(sock, fptr);
- if (rb_io_read_pending(fptr)) {
+ if (rb_read_pending(fptr->f)) {
rb_raise(rb_eIOError, "recv for buffered IO");
}
- fd = fptr->fd;
+ fd = fileno(fptr->f);
str = rb_tainted_str_new(0, buflen);
retry:
+ rb_str_locktmp(str);
rb_thread_wait_fd(fd);
- rb_io_check_closed(fptr);
- if (RSTRING_LEN(str) != buflen) {
- rb_raise(rb_eRuntimeError, "buffer string modified");
- }
TRAP_BEG;
- slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, (struct sockaddr*)buf, &alen);
+ slen = recvfrom(fd, RSTRING(str)->ptr, buflen, flags, (struct sockaddr*)buf, &alen);
TRAP_END;
+ rb_str_unlocktmp(str);
if (slen < 0) {
if (rb_io_wait_readable(fd)) {
@@ -608,8 +611,9 @@ s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
}
rb_sys_fail("recvfrom(2)");
}
- if (slen < RSTRING_LEN(str)) {
- rb_str_set_len(str, slen);
+ if (slen < RSTRING(str)->len) {
+ RSTRING(str)->len = slen;
+ RSTRING(str)->ptr[slen] = '\0';
}
rb_obj_taint(str);
switch (from) {
@@ -621,8 +625,8 @@ s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
}
#endif
- if (alen && alen != sizeof(buf)) /* OSX doesn't return a from result for connection-oriented sockets */
- return rb_assoc_new(str, ipaddr((struct sockaddr*)buf, fptr->mode & FMODE_NOREVLOOKUP));
+ if (alen && alen != sizeof(buf)) /* OSX doesn't return a 'from' result from recvfrom for connection-oriented sockets */
+ return rb_assoc_new(str, ipaddr((struct sockaddr*)buf));
else
return rb_assoc_new(str, Qnil);
@@ -663,31 +667,32 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
#endif
GetOpenFile(sock, fptr);
- if (rb_io_read_pending(fptr)) {
+ if (rb_read_pending(fptr->f)) {
rb_raise(rb_eIOError, "recvfrom for buffered IO");
}
- fd = fptr->fd;
+ fd = fileno(fptr->f);
str = rb_tainted_str_new(0, buflen);
rb_io_check_closed(fptr);
rb_io_set_nonblock(fptr);
- slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, (struct sockaddr*)buf, &alen);
+ slen = recvfrom(fd, RSTRING(str)->ptr, buflen, flags, (struct sockaddr*)buf, &alen);
if (slen < 0) {
rb_sys_fail("recvfrom(2)");
}
- if (slen < RSTRING_LEN(str)) {
- rb_str_set_len(str, slen);
+ if (slen < RSTRING(str)->len) {
+ RSTRING(str)->len = slen;
+ RSTRING(str)->ptr[slen] = '\0';
}
rb_obj_taint(str);
switch (from) {
case RECV_RECV:
- return str;
+ return str;
case RECV_IP:
if (alen && alen != sizeof(buf)) /* connection-oriented socket may not return a from result */
- addr = ipaddr((struct sockaddr*)buf, fptr->mode & FMODE_NOREVLOOKUP);
+ addr = ipaddr((struct sockaddr*)buf);
break;
case RECV_SOCKET:
@@ -701,7 +706,10 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
}
static VALUE
-bsock_recv(int argc, VALUE *argv, VALUE sock)
+bsock_recv(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
return s_recvfrom(sock, argc, argv, RECV_RECV);
}
@@ -744,48 +752,46 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
*/
static VALUE
-bsock_recv_nonblock(int argc, VALUE *argv, VALUE sock)
+bsock_recv_nonblock(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
return s_recvfrom_nonblock(sock, argc, argv, RECV_RECV);
}
static VALUE
-bsock_do_not_rev_lookup(void)
+bsock_do_not_rev_lookup()
{
return do_not_reverse_lookup?Qtrue:Qfalse;
}
static VALUE
-bsock_do_not_rev_lookup_set(VALUE self, VALUE val)
+bsock_do_not_rev_lookup_set(self, val)
+ VALUE self, val;
{
rb_secure(4);
do_not_reverse_lookup = RTEST(val);
return val;
}
-NORETURN(static void raise_socket_error(char *, int));
static void
-raise_socket_error(char *reason, int error)
-{
-#ifdef EAI_SYSTEM
- if (error == EAI_SYSTEM) rb_sys_fail(reason);
-#endif
- rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
-}
-
-static void
-make_ipaddr0(struct sockaddr *addr, char *buf, size_t len)
+make_ipaddr0(addr, buf, len)
+ struct sockaddr *addr;
+ char *buf;
+ size_t len;
{
int error;
error = getnameinfo(addr, SA_LEN(addr), buf, len, NULL, 0, NI_NUMERICHOST);
if (error) {
- raise_socket_error("getnameinfo", error);
+ rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
}
static VALUE
-make_ipaddr(struct sockaddr *addr)
+make_ipaddr(addr)
+ struct sockaddr *addr;
{
char buf[1024];
@@ -794,7 +800,10 @@ make_ipaddr(struct sockaddr *addr)
}
static void
-make_inetaddr(long host, char *buf, size_t len)
+make_inetaddr(host, buf, len)
+ long host;
+ char *buf;
+ size_t len;
{
struct sockaddr_in sin;
@@ -806,7 +815,8 @@ make_inetaddr(long host, char *buf, size_t len)
}
static int
-str_isnumber(const char *p)
+str_isnumber(p)
+ const char *p;
{
char *ep;
@@ -820,8 +830,11 @@ str_isnumber(const char *p)
return 0;
}
-static char*
-host_str(VALUE host, char *hbuf, size_t len)
+static char *
+host_str(host, hbuf, len)
+ VALUE host;
+ char *hbuf;
+ size_t len;
{
if (NIL_P(host)) {
return NULL;
@@ -836,7 +849,7 @@ host_str(VALUE host, char *hbuf, size_t len)
char *name;
SafeStringValue(host);
- name = RSTRING_PTR(host);
+ name = RSTRING(host)->ptr;
if (!name || *name == 0 || (name[0] == '<' && strcmp(name, "<any>") == 0)) {
make_inetaddr(INADDR_ANY, hbuf, len);
}
@@ -853,8 +866,11 @@ host_str(VALUE host, char *hbuf, size_t len)
}
}
-static char*
-port_str(VALUE port, char *pbuf, size_t len)
+static char *
+port_str(port, pbuf, len)
+ VALUE port;
+ char *pbuf;
+ size_t len;
{
if (NIL_P(port)) {
return 0;
@@ -867,7 +883,7 @@ port_str(VALUE port, char *pbuf, size_t len)
char *serv;
SafeStringValue(port);
- serv = RSTRING_PTR(port);
+ serv = RSTRING(port)->ptr;
if (strlen(serv) >= len) {
rb_raise(rb_eArgError, "service name too long (%d)", strlen(serv));
}
@@ -884,7 +900,9 @@ port_str(VALUE port, char *pbuf, size_t len)
#endif
static struct addrinfo*
-sock_addrinfo(VALUE host, VALUE port, int socktype, int flags)
+sock_addrinfo(host, port, socktype, flags)
+ VALUE host, port;
+ int socktype, flags;
{
struct addrinfo hints;
struct addrinfo* res = NULL;
@@ -908,7 +926,7 @@ sock_addrinfo(VALUE host, VALUE port, int socktype, int flags)
if (hostp && hostp[strlen(hostp)-1] == '\n') {
rb_raise(rb_eSocket, "newline at the end of hostname");
}
- raise_socket_error("getaddrinfo", error);
+ rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
}
#if defined(__APPLE__) && defined(__MACH__)
@@ -932,7 +950,8 @@ sock_addrinfo(VALUE host, VALUE port, int socktype, int flags)
}
static VALUE
-ipaddr(struct sockaddr *sockaddr, int norevlookup)
+ipaddr(sockaddr)
+ struct sockaddr *sockaddr;
{
VALUE family, port, addr1, addr2;
VALUE ary;
@@ -965,9 +984,8 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
family = rb_str_new2(pbuf);
break;
}
-
addr1 = Qnil;
- if (!norevlookup) {
+ if (!do_not_reverse_lookup) {
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
NULL, 0, 0);
if (! error) {
@@ -977,7 +995,7 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
- raise_socket_error("getnameinfo", error);
+ rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
addr2 = rb_str_new2(hbuf);
if (addr1 == Qnil) {
@@ -990,7 +1008,8 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
}
static int
-ruby_socket(int domain, int type, int proto)
+ruby_socket(domain, type, proto)
+ int domain, type, proto;
{
int fd;
@@ -1005,24 +1024,27 @@ ruby_socket(int domain, int type, int proto)
}
static int
-wait_connectable0(int fd, rb_fdset_t *fds_w, rb_fdset_t *fds_e)
+wait_connectable(fd)
+ int fd;
{
int sockerr;
socklen_t sockerrlen;
+ fd_set fds_w;
+ fd_set fds_e;
for (;;) {
- rb_fd_zero(fds_w);
- rb_fd_zero(fds_e);
+ FD_ZERO(&fds_w);
+ FD_ZERO(&fds_e);
- rb_fd_set(fd, fds_w);
- rb_fd_set(fd, fds_e);
+ FD_SET(fd, &fds_w);
+ FD_SET(fd, &fds_e);
- rb_thread_select(fd+1, 0, rb_fd_ptr(fds_w), rb_fd_ptr(fds_e), 0);
+ rb_thread_select(fd+1, 0, &fds_w, &fds_e, 0);
- if (rb_fd_isset(fd, fds_w)) {
+ if (FD_ISSET(fd, &fds_w)) {
return 0;
}
- else if (rb_fd_isset(fd, fds_e)) {
+ else if (FD_ISSET(fd, &fds_e)) {
sockerrlen = sizeof(sockerr);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr,
&sockerrlen) == 0) {
@@ -1037,46 +1059,6 @@ wait_connectable0(int fd, rb_fdset_t *fds_w, rb_fdset_t *fds_e)
return 0;
}
-struct wait_connectable_arg {
- int fd;
- rb_fdset_t fds_w;
- rb_fdset_t fds_e;
-};
-
-#ifdef HAVE_RB_FD_INIT
-static VALUE
-try_wait_connectable(VALUE arg)
-{
- struct wait_connectable_arg *p = (struct wait_connectable_arg *)arg;
- return (VALUE)wait_connectable0(p->fd, &p->fds_w, &p->fds_e);
-}
-
-static VALUE
-wait_connectable_ensure(VALUE arg)
-{
- struct wait_connectable_arg *p = (struct wait_connectable_arg *)arg;
- rb_fd_term(&p->fds_w);
- rb_fd_term(&p->fds_e);
- return Qnil;
-}
-#endif
-
-static int
-wait_connectable(int fd)
-{
- struct wait_connectable_arg arg;
-
- rb_fd_init(&arg.fds_w);
- rb_fd_init(&arg.fds_e);
-#ifdef HAVE_RB_FD_INIT
- arg.fd = fd;
- return (int)rb_ensure(try_wait_connectable, (VALUE)&arg,
- wait_connectable_ensure,(VALUE)&arg);
-#else
- return wait_connectable0(fd, &arg.fds_w, &arg.fds_e);
-#endif
-}
-
#ifdef __CYGWIN__
#define WAIT_IN_PROGRESS 10
#endif
@@ -1093,7 +1075,11 @@ wait_connectable(int fd)
#endif
static int
-ruby_connect(int fd, struct sockaddr *sockaddr, int len, int socks)
+ruby_connect(fd, sockaddr, len, socks)
+ int fd;
+ struct sockaddr *sockaddr;
+ int len;
+ int socks;
{
int status;
int mode;
@@ -1214,7 +1200,8 @@ struct inetsock_arg
};
static VALUE
-inetsock_cleanup(struct inetsock_arg *arg)
+inetsock_cleanup(arg)
+ struct inetsock_arg *arg;
{
if (arg->remote.res) {
freeaddrinfo(arg->remote.res);
@@ -1231,7 +1218,8 @@ inetsock_cleanup(struct inetsock_arg *arg)
}
static VALUE
-init_inetsock_internal(struct inetsock_arg *arg)
+init_inetsock_internal(arg)
+ struct inetsock_arg *arg;
{
int type = arg->type;
struct addrinfo *res;
@@ -1300,8 +1288,9 @@ init_inetsock_internal(struct inetsock_arg *arg)
}
static VALUE
-init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
- VALUE local_host, VALUE local_serv, int type)
+init_inetsock(sock, remote_host, remote_serv, local_host, local_serv, type)
+ VALUE sock, remote_host, remote_serv, local_host, local_serv;
+ int type;
{
struct inetsock_arg arg;
arg.sock = sock;
@@ -1326,7 +1315,10 @@ init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
* end to establish the connection.
*/
static VALUE
-tcp_init(int argc, VALUE *argv, VALUE sock)
+tcp_init(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
VALUE remote_host, remote_serv;
VALUE local_host, local_serv;
@@ -1340,7 +1332,8 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
#ifdef SOCKS
static VALUE
-socks_init(VALUE sock, VALUE host, VALUE serv)
+socks_init(sock, host, serv)
+ VALUE sock, host, serv;
{
static init = 0;
@@ -1354,7 +1347,8 @@ socks_init(VALUE sock, VALUE host, VALUE serv)
#ifdef SOCKS5
static VALUE
-socks_s_close(VALUE sock)
+socks_s_close(sock)
+ VALUE sock;
{
rb_io_t *fptr;
@@ -1362,7 +1356,8 @@ socks_s_close(VALUE sock)
rb_raise(rb_eSecurityError, "Insecure: can't close socket");
}
GetOpenFile(sock, fptr);
- shutdown(fptr->fd, 2);
+ shutdown(fileno(fptr->f), 2);
+ shutdown(fileno(fptr->f2), 2);
return rb_io_close(sock);
}
#endif
@@ -1371,15 +1366,16 @@ socks_s_close(VALUE sock)
struct hostent_arg {
VALUE host;
struct addrinfo* addr;
- VALUE (*ipaddr)(struct sockaddr*, size_t);
+ VALUE (*ipaddr)_((struct sockaddr*, size_t));
};
static VALUE
-make_hostent_internal(struct hostent_arg *arg)
+make_hostent_internal(arg)
+ struct hostent_arg *arg;
{
VALUE host = arg->host;
struct addrinfo* addr = arg->addr;
- VALUE (*ipaddr)(struct sockaddr*, size_t) = arg->ipaddr;
+ VALUE (*ipaddr)_((struct sockaddr*, size_t)) = arg->ipaddr;
struct addrinfo *ai;
struct hostent *h;
@@ -1411,14 +1407,23 @@ make_hostent_internal(struct hostent_arg *arg)
rb_ary_push(ary, names);
rb_ary_push(ary, INT2NUM(addr->ai_family));
for (ai = addr; ai; ai = ai->ai_next) {
- rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));
+ /* Pushing all addresses regardless of address family is not the
+ * behaviour expected of gethostbyname(). All the addresses in struct
+ * hostent->h_addr_list must be of the same family.
+ */
+ if(ai->ai_family == addr->ai_family) {
+ rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));
+ }
}
return ary;
}
static VALUE
-make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t))
+make_hostent(host, addr, ipaddr)
+ VALUE host;
+ struct addrinfo* addr;
+ VALUE (*ipaddr)_((struct sockaddr*, size_t));
{
struct hostent_arg arg;
@@ -1429,22 +1434,27 @@ make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr
RUBY_METHOD_FUNC(freeaddrinfo), (VALUE)addr);
}
-static VALUE
-tcp_sockaddr(struct sockaddr *addr, size_t len)
+VALUE
+tcp_sockaddr(addr, len)
+ struct sockaddr *addr;
+ size_t len;
{
return make_ipaddr(addr);
}
static VALUE
-tcp_s_gethostbyname(VALUE obj, VALUE host)
+tcp_s_gethostbyname(obj, host)
+ VALUE obj, host;
{
rb_secure(3);
- return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME),
- tcp_sockaddr);
+ return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), tcp_sockaddr);
}
static VALUE
-tcp_svr_init(int argc, VALUE *argv, VALUE sock)
+tcp_svr_init(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
VALUE arg1, arg2;
@@ -1479,7 +1489,7 @@ s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen
rb_secure(3);
rb_io_set_nonblock(fptr);
- fd2 = accept(fptr->fd, (struct sockaddr*)sockaddr, len);
+ fd2 = accept(fileno(fptr->f), (struct sockaddr*)sockaddr, len);
if (fd2 < 0) {
rb_sys_fail("accept(2)");
}
@@ -1488,7 +1498,11 @@ s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen
}
static VALUE
-s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
+s_accept(klass, fd, sockaddr, len)
+ VALUE klass;
+ int fd;
+ struct sockaddr *sockaddr;
+ socklen_t *len;
{
int fd2;
int retry = 0;
@@ -1511,6 +1525,8 @@ s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
rb_gc();
retry = 1;
goto retry;
+ case EWOULDBLOCK:
+ break;
default:
if (!rb_io_wait_readable(fd)) break;
retry = 0;
@@ -1523,15 +1539,16 @@ s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
}
static VALUE
-tcp_accept(VALUE sock)
+tcp_accept(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_storage from;
socklen_t fromlen;
-
+
GetOpenFile(sock, fptr);
fromlen = sizeof(from);
- return s_accept(rb_cTCPSocket, fptr->fd,
+ return s_accept(rb_cTCPSocket, fileno(fptr->f),
(struct sockaddr*)&from, &fromlen);
}
@@ -1565,7 +1582,8 @@ tcp_accept(VALUE sock)
* * Socket#accept
*/
static VALUE
-tcp_accept_nonblock(VALUE sock)
+tcp_accept_nonblock(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_storage from;
@@ -1574,11 +1592,12 @@ tcp_accept_nonblock(VALUE sock)
GetOpenFile(sock, fptr);
fromlen = sizeof(from);
return s_accept_nonblock(rb_cTCPSocket, fptr,
- (struct sockaddr *)&from, &fromlen);
+ (struct sockaddr *)&from, &fromlen);
}
static VALUE
-tcp_sysaccept(VALUE sock)
+tcp_sysaccept(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_storage from;
@@ -1586,7 +1605,7 @@ tcp_sysaccept(VALUE sock)
GetOpenFile(sock, fptr);
fromlen = sizeof(from);
- return s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
+ return s_accept(0, fileno(fptr->f), (struct sockaddr*)&from, &fromlen);
}
#ifdef HAVE_SYS_UN_H
@@ -1596,14 +1615,18 @@ struct unixsock_arg {
};
static VALUE
-unixsock_connect_internal(struct unixsock_arg *arg)
+unixsock_connect_internal(arg)
+ struct unixsock_arg *arg;
{
- return (VALUE)ruby_connect(arg->fd, (struct sockaddr*)arg->sockaddr,
- sizeof(*arg->sockaddr), 0);
+ return (VALUE)ruby_connect(arg->fd, arg->sockaddr, sizeof(*arg->sockaddr),
+ 0);
}
static VALUE
-init_unixsock(VALUE sock, VALUE path, int server)
+init_unixsock(sock, path, server)
+ VALUE sock;
+ VALUE path;
+ int server;
{
struct sockaddr_un sockaddr;
int fd, status;
@@ -1617,11 +1640,11 @@ init_unixsock(VALUE sock, VALUE path, int server)
MEMZERO(&sockaddr, struct sockaddr_un, 1);
sockaddr.sun_family = AF_UNIX;
- if (sizeof(sockaddr.sun_path) <= RSTRING_LEN(path)) {
+ if (sizeof(sockaddr.sun_path) <= RSTRING(path)->len) {
rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)",
(int)sizeof(sockaddr.sun_path)-1);
}
- memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
+ strcpy(sockaddr.sun_path, StringValueCStr(path));
if (server) {
status = bind(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
@@ -1631,8 +1654,7 @@ init_unixsock(VALUE sock, VALUE path, int server)
struct unixsock_arg arg;
arg.sockaddr = &sockaddr;
arg.fd = fd;
- status = rb_protect((VALUE(*)(VALUE))unixsock_connect_internal,
- (VALUE)&arg, &prot);
+ status = rb_protect(unixsock_connect_internal, (VALUE)&arg, &prot);
if (prot) {
close(fd);
rb_jump_tag(prot);
@@ -1647,9 +1669,9 @@ init_unixsock(VALUE sock, VALUE path, int server)
if (server) listen(fd, 5);
init_sock(sock, fd);
+ GetOpenFile(sock, fptr);
if (server) {
- GetOpenFile(sock, fptr);
- fptr->path = strdup(RSTRING_PTR(path));
+ fptr->path = strdup(RSTRING(path)->ptr);
}
return sock;
@@ -1657,7 +1679,8 @@ init_unixsock(VALUE sock, VALUE path, int server)
#endif
static VALUE
-ip_addr(VALUE sock)
+ip_addr(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_storage addr;
@@ -1665,13 +1688,14 @@ ip_addr(VALUE sock)
GetOpenFile(sock, fptr);
- if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
- return ipaddr((struct sockaddr*)&addr, fptr->mode & FMODE_NOREVLOOKUP);
+ return ipaddr((struct sockaddr*)&addr);
}
static VALUE
-ip_peeraddr(VALUE sock)
+ip_peeraddr(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_storage addr;
@@ -1679,19 +1703,23 @@ ip_peeraddr(VALUE sock)
GetOpenFile(sock, fptr);
- if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getpeername(2)");
- return ipaddr((struct sockaddr*)&addr, fptr->mode & FMODE_NOREVLOOKUP);
+ return ipaddr((struct sockaddr*)&addr);
}
static VALUE
-ip_recvfrom(int argc, VALUE *argv, VALUE sock)
+ip_recvfrom(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
return s_recvfrom(sock, argc, argv, RECV_IP);
}
static VALUE
-ip_s_getaddress(VALUE obj, VALUE host)
+ip_s_getaddress(obj, host)
+ VALUE obj, host;
{
struct sockaddr_storage addr;
struct addrinfo *res = sock_addrinfo(host, Qnil, SOCK_STREAM, 0);
@@ -1704,7 +1732,10 @@ ip_s_getaddress(VALUE obj, VALUE host)
}
static VALUE
-udp_init(int argc, VALUE *argv, VALUE sock)
+udp_init(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
VALUE arg;
int socktype = AF_INET;
@@ -1729,7 +1760,8 @@ struct udp_arg
};
static VALUE
-udp_connect_internal(struct udp_arg *arg)
+udp_connect_internal(arg)
+ struct udp_arg *arg;
{
int fd = arg->fd;
struct addrinfo *res;
@@ -1743,7 +1775,8 @@ udp_connect_internal(struct udp_arg *arg)
}
static VALUE
-udp_connect(VALUE sock, VALUE host, VALUE port)
+udp_connect(sock, host, port)
+ VALUE sock, host, port;
{
rb_io_t *fptr;
struct udp_arg arg;
@@ -1752,7 +1785,7 @@ udp_connect(VALUE sock, VALUE host, VALUE port)
rb_secure(3);
arg.res = sock_addrinfo(host, port, SOCK_DGRAM, 0);
GetOpenFile(sock, fptr);
- arg.fd = fptr->fd;
+ arg.fd = fileno(fptr->f);
ret = rb_ensure(udp_connect_internal, (VALUE)&arg,
RUBY_METHOD_FUNC(freeaddrinfo), (VALUE)arg.res);
if (!ret) rb_sys_fail("connect(2)");
@@ -1760,7 +1793,8 @@ udp_connect(VALUE sock, VALUE host, VALUE port)
}
static VALUE
-udp_bind(VALUE sock, VALUE host, VALUE port)
+udp_bind(sock, host, port)
+ VALUE sock, host, port;
{
rb_io_t *fptr;
struct addrinfo *res0, *res;
@@ -1769,7 +1803,7 @@ udp_bind(VALUE sock, VALUE host, VALUE port)
res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0);
GetOpenFile(sock, fptr);
for (res = res0; res; res = res->ai_next) {
- if (bind(fptr->fd, res->ai_addr, res->ai_addrlen) < 0) {
+ if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) {
continue;
}
freeaddrinfo(res0);
@@ -1781,10 +1815,14 @@ udp_bind(VALUE sock, VALUE host, VALUE port)
}
static VALUE
-udp_send(int argc, VALUE *argv, VALUE sock)
+udp_send(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
VALUE mesg, flags, host, port;
rb_io_t *fptr;
+ FILE *f;
int n;
struct addrinfo *res0, *res;
@@ -1797,15 +1835,16 @@ udp_send(int argc, VALUE *argv, VALUE sock)
StringValue(mesg);
res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0);
GetOpenFile(sock, fptr);
+ f = GetWriteFile(fptr);
for (res = res0; res; res = res->ai_next) {
retry:
- n = sendto(fptr->fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg), NUM2INT(flags),
+ n = sendto(fileno(f), RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags),
res->ai_addr, res->ai_addrlen);
if (n >= 0) {
freeaddrinfo(res0);
return INT2FIX(n);
}
- if (rb_io_wait_writable(fptr->fd)) {
+ if (rb_io_wait_writable(fileno(f))) {
goto retry;
}
}
@@ -1862,12 +1901,13 @@ udp_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
#ifdef HAVE_SYS_UN_H
static VALUE
-unix_init(VALUE sock, VALUE path)
+unix_init(sock, path)
+ VALUE sock, path;
{
return init_unixsock(sock, path, 0);
}
-static char*
+static char *
unixpath(struct sockaddr_un *sockaddr, socklen_t len)
{
if (sockaddr->sun_path < (char*)sockaddr + len)
@@ -1877,7 +1917,8 @@ unixpath(struct sockaddr_un *sockaddr, socklen_t len)
}
static VALUE
-unix_path(VALUE sock)
+unix_path(sock)
+ VALUE sock;
{
rb_io_t *fptr;
@@ -1885,7 +1926,7 @@ unix_path(VALUE sock)
if (fptr->path == 0) {
struct sockaddr_un addr;
socklen_t len = sizeof(addr);
- if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail(0);
fptr->path = strdup(unixpath(&addr, len));
}
@@ -1893,13 +1934,17 @@ unix_path(VALUE sock)
}
static VALUE
-unix_svr_init(VALUE sock, VALUE path)
+unix_svr_init(sock, path)
+ VALUE sock, path;
{
return init_unixsock(sock, path, 1);
}
static VALUE
-unix_recvfrom(int argc, VALUE *argv, VALUE sock)
+unix_recvfrom(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
return s_recvfrom(sock, argc, argv, RECV_UNIX);
}
@@ -1917,7 +1962,8 @@ unix_recvfrom(int argc, VALUE *argv, VALUE sock)
#endif
static VALUE
-unix_send_io(VALUE sock, VALUE val)
+unix_send_io(sock, val)
+ VALUE sock, val;
{
#if defined(HAVE_SENDMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
int fd;
@@ -1936,7 +1982,7 @@ unix_send_io(VALUE sock, VALUE val)
if (rb_obj_is_kind_of(val, rb_cIO)) {
rb_io_t *valfptr;
GetOpenFile(val, valfptr);
- fd = valfptr->fd;
+ fd = fileno(valfptr->f);
}
else if (FIXNUM_P(val)) {
fd = FIX2INT(val);
@@ -1971,7 +2017,7 @@ unix_send_io(VALUE sock, VALUE val)
msg.msg_accrightslen = sizeof(fd);
#endif
- if (sendmsg(fptr->fd, &msg, 0) == -1)
+ if (sendmsg(fileno(fptr->f), &msg, 0) == -1)
rb_sys_fail("sendmsg(2)");
return Qnil;
@@ -1981,8 +2027,24 @@ unix_send_io(VALUE sock, VALUE val)
#endif
}
+#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
+static void
+thread_read_select(fd)
+ int fd;
+{
+ fd_set fds;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ rb_thread_select(fd+1, &fds, 0, 0, 0);
+}
+#endif
+
static VALUE
-unix_recv_io(int argc, VALUE *argv, VALUE sock)
+unix_recv_io(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
VALUE klass, mode;
@@ -2007,7 +2069,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
GetOpenFile(sock, fptr);
- rb_io_wait_readable(fptr->fd);
+ thread_read_select(fileno(fptr->f));
msg.msg_name = NULL;
msg.msg_namelen = 0;
@@ -2031,7 +2093,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
fd = -1;
#endif
- if (recvmsg(fptr->fd, &msg, 0) == -1)
+ if (recvmsg(fileno(fptr->f), &msg, 0) == -1)
rb_sys_fail("recvmsg(2)");
#if FD_PASSING_BY_MSG_CONTROL
@@ -2087,7 +2149,8 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
}
static VALUE
-unix_accept(VALUE sock)
+unix_accept(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_un from;
@@ -2095,7 +2158,7 @@ unix_accept(VALUE sock)
GetOpenFile(sock, fptr);
fromlen = sizeof(struct sockaddr_un);
- return s_accept(rb_cUNIXSocket, fptr->fd,
+ return s_accept(rb_cUNIXSocket, fileno(fptr->f),
(struct sockaddr*)&from, &fromlen);
}
@@ -2129,7 +2192,8 @@ unix_accept(VALUE sock)
* * Socket#accept
*/
static VALUE
-unix_accept_nonblock(VALUE sock)
+unix_accept_nonblock(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_un from;
@@ -2138,11 +2202,12 @@ unix_accept_nonblock(VALUE sock)
GetOpenFile(sock, fptr);
fromlen = sizeof(from);
return s_accept_nonblock(rb_cUNIXSocket, fptr,
- (struct sockaddr *)&from, &fromlen);
+ (struct sockaddr *)&from, &fromlen);
}
static VALUE
-unix_sysaccept(VALUE sock)
+unix_sysaccept(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_un from;
@@ -2150,20 +2215,21 @@ unix_sysaccept(VALUE sock)
GetOpenFile(sock, fptr);
fromlen = sizeof(struct sockaddr_un);
- return s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
+ return s_accept(0, fileno(fptr->f), (struct sockaddr*)&from, &fromlen);
}
-#ifdef HAVE_SYS_UN_H
static VALUE
-unixaddr(struct sockaddr_un *sockaddr, socklen_t len)
+unixaddr(sockaddr, len)
+ struct sockaddr_un *sockaddr;
+ socklen_t len;
{
return rb_assoc_new(rb_str_new2("AF_UNIX"),
rb_str_new2(unixpath(sockaddr, len)));
}
-#endif
static VALUE
-unix_addr(VALUE sock)
+unix_addr(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_un addr;
@@ -2171,13 +2237,14 @@ unix_addr(VALUE sock)
GetOpenFile(sock, fptr);
- if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
return unixaddr(&addr, len);
}
static VALUE
-unix_peeraddr(VALUE sock)
+unix_peeraddr(sock)
+ VALUE sock;
{
rb_io_t *fptr;
struct sockaddr_un addr;
@@ -2185,14 +2252,16 @@ unix_peeraddr(VALUE sock)
GetOpenFile(sock, fptr);
- if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getpeername(2)");
return unixaddr(&addr, len);
}
#endif
static void
-setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
+setup_domain_and_type(domain, dv, type, tv)
+ VALUE domain, type;
+ int *dv, *tv;
{
VALUE tmp;
char *ptr;
@@ -2201,7 +2270,7 @@ setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
if (!NIL_P(tmp)) {
domain = tmp;
rb_check_safe_obj(domain);
- ptr = RSTRING_PTR(domain);
+ ptr = RSTRING(domain)->ptr;
if (strcmp(ptr, "AF_INET") == 0)
*dv = AF_INET;
#ifdef AF_UNIX
@@ -2252,7 +2321,7 @@ setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
if (!NIL_P(tmp)) {
type = tmp;
rb_check_safe_obj(type);
- ptr = RSTRING_PTR(type);
+ ptr = RSTRING(type)->ptr;
if (strcmp(ptr, "SOCK_STREAM") == 0)
*tv = SOCK_STREAM;
else if (strcmp(ptr, "SOCK_DGRAM") == 0)
@@ -2282,7 +2351,8 @@ setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
}
static VALUE
-sock_initialize(VALUE sock, VALUE domain, VALUE type, VALUE protocol)
+sock_initialize(sock, domain, type, protocol)
+ VALUE sock, domain, type, protocol;
{
int fd;
int d, t;
@@ -2296,7 +2366,8 @@ sock_initialize(VALUE sock, VALUE domain, VALUE type, VALUE protocol)
}
static VALUE
-sock_s_socketpair(VALUE klass, VALUE domain, VALUE type, VALUE protocol)
+sock_s_socketpair(klass, domain, type, protocol)
+ VALUE klass, domain, type, protocol;
{
#if defined HAVE_SOCKETPAIR
int d, t, p, sp[2];
@@ -2322,7 +2393,10 @@ sock_s_socketpair(VALUE klass, VALUE domain, VALUE type, VALUE protocol)
#ifdef HAVE_SYS_UN_H
static VALUE
-unix_s_socketpair(int argc, VALUE *argv, VALUE klass)
+unix_s_socketpair(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE domain, type, protocol;
domain = INT2FIX(PF_UNIX);
@@ -2449,21 +2523,21 @@ unix_s_socketpair(int argc, VALUE *argv, VALUE klass)
* * connect function in Microsoft's Winsock functions reference
*/
static VALUE
-sock_connect(VALUE sock, VALUE addr)
+sock_connect(sock, addr)
+ VALUE sock, addr;
{
rb_io_t *fptr;
- int fd, n;
+ int fd;
StringValue(addr);
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);
- fd = fptr->fd;
- n = ruby_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr), 0);
- if (n < 0) {
+ fd = fileno(fptr->f);
+ if (ruby_connect(fd, (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len, 0) < 0) {
rb_sys_fail("connect(2)");
}
- return INT2FIX(n);
+ return INT2FIX(0);
}
/*
@@ -2505,7 +2579,8 @@ sock_connect(VALUE sock, VALUE addr)
* * Socket#connect
*/
static VALUE
-sock_connect_nonblock(VALUE sock, VALUE addr)
+sock_connect_nonblock(sock, addr)
+ VALUE sock, addr;
{
rb_io_t *fptr;
int n;
@@ -2514,7 +2589,7 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);
rb_io_set_nonblock(fptr);
- n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr));
+ n = connect(fileno(fptr->f), (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len);
if (n < 0) {
rb_sys_fail("connect(2)");
}
@@ -2602,13 +2677,14 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
* * bind function in Microsoft's Winsock functions reference
*/
static VALUE
-sock_bind(VALUE sock, VALUE addr)
+sock_bind(sock, addr)
+ VALUE sock, addr;
{
rb_io_t *fptr;
StringValue(addr);
GetOpenFile(sock, fptr);
- if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_LEN(addr)) < 0)
+ if (bind(fileno(fptr->f), (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len) < 0)
rb_sys_fail("bind(2)");
return INT2FIX(0);
@@ -2685,7 +2761,8 @@ sock_bind(VALUE sock, VALUE addr)
* * listen function in Microsoft's Winsock functions reference
*/
static VALUE
-sock_listen(VALUE sock, VALUE log)
+sock_listen(sock, log)
+ VALUE sock, log;
{
rb_io_t *fptr;
int backlog;
@@ -2693,7 +2770,7 @@ sock_listen(VALUE sock, VALUE log)
rb_secure(4);
backlog = NUM2INT(log);
GetOpenFile(sock, fptr);
- if (listen(fptr->fd, backlog) < 0)
+ if (listen(fileno(fptr->f), backlog) < 0)
rb_sys_fail("listen(2)");
return INT2FIX(0);
@@ -2805,7 +2882,10 @@ sock_listen(VALUE sock, VALUE log)
* message.
*/
static VALUE
-sock_recvfrom(int argc, VALUE *argv, VALUE sock)
+sock_recvfrom(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
{
return s_recvfrom(sock, argc, argv, RECV_SOCKET);
}
@@ -2874,8 +2954,91 @@ sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
return s_recvfrom_nonblock(sock, argc, argv, RECV_SOCKET);
}
+/*
+ * call-seq:
+ * socket.accept => [ socket, string ]
+ *
+ * Accepts an incoming connection returning an array containing a new
+ * Socket object and a string holding the +struct+ sockaddr information about
+ * the caller.
+ *
+ * === Example
+ * # In one script, start this first
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.bind( sockaddr )
+ * socket.listen( 5 )
+ * client, client_sockaddr = socket.accept
+ * puts "The client said, '#{client.readline.chomp}'"
+ * client.puts "Hello from script one!"
+ * socket.close
+ *
+ * # In another script, start this second
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.connect( sockaddr )
+ * socket.puts "Hello from script 2."
+ * puts "The server said, '#{socket.readline.chomp}'"
+ * socket.close
+ *
+ * === Unix-based Exceptions
+ * On unix-based based systems the following system exceptions may be raised if the
+ * call to _accept_ fails:
+ * * Errno::EAGAIN - O_NONBLOCK is set for the +socket+ file descriptor and no
+ * connections are parent to be accepted
+ * * Errno::EWOULDBLOCK - same as Errno::EAGAIN
+ * * Errno::EBADF - the +socket+ is not a valid file descriptor
+ * * Errno::ECONNABORTED - a connection has been aborted
+ * * Errno::EFAULT - the socket's internal address or address length parameter
+ * cannot be access or written
+ * * Errno::EINTR - the _accept_ method was interrupted by a signal that was
+ * caught before a valid connection arrived
+ * * Errno::EINVAL - the +socket+ is not accepting connections
+ * * Errno::EMFILE - OPEN_MAX file descriptors are currently open in the calling
+ * process
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOMEM - there was insufficient memory available to complete the
+ * operation
+ * * Errno::ENOSR - there was insufficient STREAMS resources available to
+ * complete the operation
+ * * Errno::ENFILE - the maximum number of file descriptors in the system are
+ * already open
+ * * Errno::ENOTSOCK - the +socket+ does not refer to a socket
+ * * Errno::EOPNOTSUPP - the socket type for the calling +socket+ does not
+ * support accept connections
+ * * Errno::EPROTO - a protocol error has occurred
+ *
+ * === Windows Exceptions
+ * On Windows systems the following system exceptions may be raised if
+ * the call to _accept_ fails:
+ * * Errno::ECONNRESET - an incoming connection was indicated, but was
+ * terminated by the remote peer prior to accepting the connection
+ * * Errno::EFAULT - the socket's internal address or address length parameter
+ * is too small or is not a valid part of the user space address
+ * * Errno::EINVAL - the _listen_ method was not invoked prior to calling _accept_
+ * * Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or
+ * the service provider is still processing a callback function
+ * * Errno::EMFILE - the queue is not empty, upong etry to _accept_ and there are
+ * no socket descriptors available
+ * * Errno::ENETDOWN - the network is down
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOTSOCK - +socket+ is not a socket
+ * * Errno::EOPNOTSUPP - +socket+ is not a type that supports connection-oriented
+ * service.
+ * * Errno::EWOULDBLOCK - +socket+ is marked as nonblocking and no connections are
+ * present to be accepted
+ *
+ * === See
+ * * accept manual pages on unix-based systems
+ * * accept function in Microsoft's Winsock functions reference
+ */
static VALUE
-sock_accept(VALUE sock)
+sock_accept(sock)
+ VALUE sock;
{
rb_io_t *fptr;
VALUE sock2;
@@ -2883,14 +3046,14 @@ sock_accept(VALUE sock)
socklen_t len = sizeof buf;
GetOpenFile(sock, fptr);
- sock2 = s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)buf,&len);
+ sock2 = s_accept(rb_cSocket,fileno(fptr->f),(struct sockaddr*)buf,&len);
return rb_assoc_new(sock2, rb_str_new(buf, len));
}
/*
* call-seq:
- * socket.accept_nonblock => [client_socket, client_sockaddr]
+ * socket.accept_nonblock => [client_socket, client_sockaddr]
*
* Accepts an incoming connection using accept(2) after
* O_NONBLOCK is set for the underlying file descriptor.
@@ -2916,7 +3079,7 @@ sock_accept(VALUE sock)
* puts "The client said, '#{client_socket.readline.chomp}'"
* client_socket.puts "Hello from script one!"
* socket.close
- *
+ *
* # In another script, start this second
* require 'socket'
* include Socket::Constants
@@ -2937,7 +3100,8 @@ sock_accept(VALUE sock)
* * Socket#accept
*/
static VALUE
-sock_accept_nonblock(VALUE sock)
+sock_accept_nonblock(sock)
+ VALUE sock;
{
rb_io_t *fptr;
VALUE sock2;
@@ -2989,7 +3153,8 @@ sock_accept_nonblock(VALUE sock)
* * Socket#accept
*/
static VALUE
-sock_sysaccept(VALUE sock)
+sock_sysaccept(sock)
+ VALUE sock;
{
rb_io_t *fptr;
VALUE sock2;
@@ -2997,14 +3162,15 @@ sock_sysaccept(VALUE sock)
socklen_t len = sizeof buf;
GetOpenFile(sock, fptr);
- sock2 = s_accept(0,fptr->fd,(struct sockaddr*)buf,&len);
+ sock2 = s_accept(0,fileno(fptr->f),(struct sockaddr*)buf,&len);
return rb_assoc_new(sock2, rb_str_new(buf, len));
}
#ifdef HAVE_GETHOSTNAME
static VALUE
-sock_gethostname(VALUE obj)
+sock_gethostname(obj)
+ VALUE obj;
{
char buf[1024];
@@ -3021,7 +3187,8 @@ sock_gethostname(VALUE obj)
#include <sys/utsname.h>
static VALUE
-sock_gethostname(VALUE obj)
+sock_gethostname(obj)
+ VALUE obj;
{
struct utsname un;
@@ -3031,7 +3198,8 @@ sock_gethostname(VALUE obj)
}
#else
static VALUE
-sock_gethostname(VALUE obj)
+sock_gethostname(obj)
+ VALUE obj;
{
rb_notimplement();
}
@@ -3039,7 +3207,8 @@ sock_gethostname(VALUE obj)
#endif
static VALUE
-make_addrinfo(struct addrinfo *res0)
+make_addrinfo(res0)
+ struct addrinfo *res0;
{
VALUE base, ary;
struct addrinfo *res;
@@ -3049,10 +3218,7 @@ make_addrinfo(struct addrinfo *res0)
}
base = rb_ary_new();
for (res = res0; res; res = res->ai_next) {
- ary = ipaddr(res->ai_addr, do_not_reverse_lookup);
- if (res->ai_canonname) {
- RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname);
- }
+ ary = ipaddr(res->ai_addr);
rb_ary_push(ary, INT2FIX(res->ai_family));
rb_ary_push(ary, INT2FIX(res->ai_socktype));
rb_ary_push(ary, INT2FIX(res->ai_protocol));
@@ -3061,8 +3227,11 @@ make_addrinfo(struct addrinfo *res0)
return base;
}
-static VALUE
-sock_sockaddr(struct sockaddr *addr, size_t len)
+/* Returns a String containing the binary value of a struct sockaddr. */
+VALUE
+sock_sockaddr(addr, len)
+ struct sockaddr *addr;
+ size_t len;
{
char *ptr;
@@ -3084,15 +3253,114 @@ sock_sockaddr(struct sockaddr *addr, size_t len)
return rb_str_new(ptr, len);
}
+/*
+ * Document-class: IPSocket
+ *
+ * IPSocket is the parent of TCPSocket and UDPSocket and implements
+ * functionality common to them.
+ *
+ * A number of APIs in IPSocket, Socket, and their descendants return an
+ * address as an array. The members of that array are:
+ * - address family: A string like "AF_INET" or "AF_INET6" if it is one of the
+ * commonly used families, the string "unknown:#" (where `#' is the address
+ * family number) if it is not one of the common ones. The strings map to
+ * the Socket::AF_* constants.
+ * - port: The port number.
+ * - name: Either the canonical name from looking the address up in the DNS, or
+ * the address in presentation format
+ * - address: The address in presentation format (a dotted decimal string for
+ * IPv4, a hex string for IPv6).
+ *
+ * The address and port can be used directly to create sockets and to bind or
+ * connect them to the address.
+ */
+
+/*
+ * Document-class: Socket
+ *
+ * Socket contains a number of generally useful singleton methods and
+ * constants, as well as offering low-level interfaces that can be used to
+ * develop socket applications using protocols other than TCP, UDP, and UNIX
+ * domain sockets.
+ */
+
+/*
+ * Document-method: gethostbyname
+ * call-seq: Socket.gethostbyname(host) => hostent
+ *
+ * Resolve +host+ and return name and address information for it, similarly to
+ * gethostbyname(3). +host+ can be a domain name or the presentation format of
+ * an address.
+ *
+ * Returns an array of information similar to that found in a +struct hostent+:
+ * - cannonical name: the cannonical name for host in the DNS, or a
+ * string representing the address
+ * - aliases: an array of aliases for the canonical name, there may be no aliases
+ * - address family: usually one of Socket::AF_INET or Socket::AF_INET6
+ * - address: a string, the binary value of the +struct sockaddr+ for this name, in
+ * the indicated address family
+ * - ...: if there are multiple addresses for this host, a series of
+ * strings/+struct sockaddr+s may follow, not all necessarily in the same
+ * address family. Note that the fact that they may not be all in the same
+ * address family is a departure from the behaviour of gethostbyname(3).
+ *
+ * Note: I believe that the fact that the multiple addresses returned are not
+ * necessarily in the same address family may be a bug, since if this function
+ * actually called gethostbyname(3), ALL the addresses returned in the trailing
+ * address list (h_addr_list from struct hostent) would be of the same address
+ * family! Examples from my system, OS X 10.3:
+ *
+ * ["localhost", [], 30, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001", "\177\000\000\001"]
+ * and
+ * ["ensemble.local", [], 30, "\376\200\000\004\000\000\000\000\002\003\223\377\376\255\010\214", "\300\250{\232" ]
+ *
+ * Similar information can be returned by Socket.getaddrinfo if called as:
+ *
+ * Socket.getaddrinfo(+host+, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
+ *
+ * == Examples
+ *
+ * Socket.gethostbyname "example.com"
+ * => ["example.com", [], 2, "\300\000\"\246"]
+ *
+ * This name has no DNS aliases, and a single IPv4 address.
+ *
+ * Socket.gethostbyname "smtp.telus.net"
+ * => ["smtp.svc.telus.net", ["smtp.telus.net"], 2, "\307\271\334\371"]
+ *
+ * This name is an an alias so the canonical name is returned, as well as the
+ * alias and a single IPv4 address.
+ *
+ * Socket.gethostbyname "localhost"
+ * => ["localhost", [], 30, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001", "\177\000\000\001"]
+ *
+ * This machine has no aliases, returns an IPv6 address, and has an additional IPv4 address.
+ *
+ * +host+ can also be an IP address in presentation format, in which case a
+ * reverse lookup is done on the address:
+ *
+ * Socket.gethostbyname("127.0.0.1")
+ * => ["localhost", [], 2, "\177\000\000\001"]
+ *
+ * Socket.gethostbyname("192.0.34.166")
+ * => ["www.example.com", [], 2, "\300\000\"\246"]
+ *
+ *
+ * == See
+ * See: Socket.getaddrinfo
+ */
static VALUE
-sock_s_gethostbyname(VALUE obj, VALUE host)
+sock_s_gethostbyname(obj, host)
+ VALUE obj, host;
{
rb_secure(3);
return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr);
}
static VALUE
-sock_s_gethostbyaddr(int argc, VALUE *argv)
+sock_s_gethostbyaddr(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE addr, type;
struct hostent *h;
@@ -3107,11 +3375,11 @@ sock_s_gethostbyaddr(int argc, VALUE *argv)
t = NUM2INT(type);
}
#ifdef INET6
- else if (RSTRING_LEN(addr) == 16) {
+ else if (RSTRING(addr)->len == 16) {
t = AF_INET6;
}
#endif
- h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_LEN(addr), t);
+ h = gethostbyaddr(RSTRING(addr)->ptr, RSTRING(addr)->len, t);
if (h == NULL) {
#ifdef HAVE_HSTRERROR
extern int h_errno;
@@ -3141,8 +3409,22 @@ sock_s_gethostbyaddr(int argc, VALUE *argv)
return ary;
}
+/*
+ * Document-method: getservbyname
+ * call-seq: Socket.getservbyname(name, proto="tcp") => port
+ *
+ * +name+ is a service name ("ftp", "telnet", ...) and proto is a protocol name
+ * ("udp", "tcp", ...). '/etc/services' (or your system's equivalent) is
+ * searched for a service for +name+ and +proto+, and the port number is
+ * returned.
+ *
+ * Note that unlike Socket.getaddrinfo, +proto+ may not be specified using the
+ * Socket::SOCK_* constants, a string must must be used.
+ */
static VALUE
-sock_s_getservbyname(int argc, VALUE *argv)
+sock_s_getservbyaname(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE service, proto;
struct servent *sp;
@@ -3158,36 +3440,135 @@ sock_s_getservbyname(int argc, VALUE *argv)
port = ntohs(sp->s_port);
}
else {
- char *s = RSTRING_PTR(service);
+ char *s = RSTRING(service)->ptr;
char *end;
port = strtoul(s, &end, 0);
if (*end != '\0') {
- rb_raise(rb_eSocket, "no such service %s/%s", s, RSTRING_PTR(proto));
+ rb_raise(rb_eSocket, "no such service %s/%s", s, RSTRING(proto)->ptr);
}
}
return INT2FIX(port);
}
-static VALUE
-sock_s_getservbyport(int argc, VALUE *argv)
-{
- VALUE port, proto;
- struct servent *sp;
+/*
+Documentation should explain the following:
- rb_scan_args(argc, argv, "11", &port, &proto);
- if (NIL_P(proto)) proto = rb_str_new2("tcp");
- StringValue(proto);
+ $ pp Socket.getaddrinfo("", 1, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
+ [["AF_INET", 1, "0.0.0.0", "0.0.0.0", 2, 1, 6]]
- sp = getservbyport(NUM2INT(port), StringValueCStr(proto));
- if (!sp) {
- rb_raise(rb_eSocket, "no such service for port %d/%s", NUM2INT(port), RSTRING_PTR(proto));
- }
- return rb_tainted_str_new2(sp->s_name);
-}
+ $ pp Socket.getaddrinfo(nil, 1, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
+ [["AF_INET6", 1, "::", "::", 30, 1, 6],
+ ["AF_INET", 1, "0.0.0.0", "0.0.0.0", 2, 1, 6]]
+
+ $ pp Socket.getaddrinfo("localhost", 1, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
+ [["AF_INET6", 1, "localhost", "::1", 30, 1, 6],
+ ["AF_INET", 1, "localhost", "127.0.0.1", 2, 1, 6]]
+
+ $ pp Socket.getaddrinfo("ensemble.local.", 1, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
+ [["AF_INET", 1, "localhost", "192.168.123.154", 2, 1, 6]]
+
+Does it?
+API suggestion: this method has too many arguments, it would be backwards compatible and easier
+to understand if limit args were accepted as :family=>..., :flags=>...
+*/
+
+/*
+ * Document-method: getaddrinfo
+ * call-seq: Socket.getaddrinfo(host, service, family=nil, socktype=nil, protocol=nil, flags=nil) => addrinfo
+ *
+ * Return address information for +host+ and +port+. The remaining arguments
+ * are hints that limit the address information returned.
+ *
+ * This method corresponds closely to the POSIX.1g getaddrinfo() definition.
+ *
+ * === Parameters
+ * - +host+ is a host name or an address string (dotted decimal for IPv4, or a hex string
+ * for IPv6) for which to return information. A nil is also allowed, its meaning
+ * depends on +flags+, see below.
+ * - +service+ is a service name ("http", "ssh", ...), or
+ * a port number (80, 22, ...), see Socket.getservbyname for more
+ * information. A nil is also allowed, meaning zero.
+ * - +family+ limits the output to a specific address family, one of the
+ * Socket::AF_* constants. Socket::AF_INET (IPv4) and Socket::AF_INET6 (IPv6)
+ * are the most commonly used families. You will usually pass either nil or
+ * Socket::AF_UNSPEC, allowing the IPv6 information to be returned first if
+ * +host+ is reachable via IPv6, and IPv4 information otherwise. The two
+ * strings "AF_INET" or "AF_INET6" are also allowed, they are converted to
+ * their respective Socket::AF_* constants.
+ * - +socktype+ limits the output to a specific type of socket, one of the
+ * Socket::SOCK_* constants. Socket::SOCK_STREAM (for TCP) and
+ * Socket::SOCK_DGRAM (for UDP) are the most commonly used socket types. If
+ * nil, then information for all types of sockets supported by +service+ will
+ * be returned. You will usually know what type of socket you intend to
+ * create, and should pass that socket type in.
+ * - +protocol+ limits the output to a specific protocol numpber, one of the
+ * Socket::IPPROTO_* constants. It is usually implied by the socket type
+ * (Socket::SOCK_STREAM => Socket::IPPROTO_TCP, ...), if you pass other than
+ * nil you already know what this is for.
+ * - +flags+ is one of the Socket::AI_* constants. They mean:
+ * - Socket::AI_PASSIVE: when set, if +host+ is nil the 'any' address will be
+ * returned, Socket::INADDR_ANY or 0 for IPv4, "0::0" or "::" for IPv6. This
+ * address is suitable for use by servers that will bind their socket and do
+ * a passive listen, thus the name of the flag. Otherwise the local or
+ * loopback address will be returned, this is "127.0.0.1" for IPv4 and "::1'
+ * for IPv6.
+ * - ...
+ *
+ *
+ * === Returns
+ *
+ * Returns an array of arrays, where each subarray contains:
+ * - address family, a string like "AF_INET" or "AF_INET6"
+ * - port number, the port number for +service+
+ * - host name, either a canonical name for +host+, or it's address in presentation
+ * format if the address could not be looked up.
+ * - host IP, the address of +host+ in presentation format
+ * - address family, as a numeric value (one of the Socket::AF_* constants).
+ * - socket type, as a numeric value (one of the Socket::SOCK_* constants).
+ * - protocol number, as a numeric value (one of the Socket::IPPROTO_* constants).
+ *
+ * The first four values are identical to what is commonly returned as an
+ * address array, see IPSocket for more information.
+ *
+ * === Examples
+ *
+ * Not all input combinations are valid, and while there are many combinations,
+ * only a few cases are common.
+ *
+ * A typical client will call getaddrinfo with the +host+ and +service+ it
+ * wants to connect to. It knows that it will attempt to connect with either
+ * TCP or UDP, and specifies +socktype+ accordingly. It loops through all
+ * returned addresses, and try to connect to them in turn:
+ *
+ * addrinfo = Socket::getaddrinfo('www.example.com', 'www', nil, Socket::SOCK_STREAM)
+ * addrinfo.each do |af, port, name, addr|
+ * begin
+ * sock = TCPSocket.new(addr, port)
+ * # ...
+ * exit 1
+ * rescue
+ * end
+ * end
+ *
+ * With UDP you don't know if connect suceeded, but if communication fails,
+ * the next address can be tried.
+ *
+ * A typical server will call getaddrinfo with a +host+ of nil, the +service+
+ * it listens to, and a +flags+ of Socket::AI_PASSIVE. It will listen for
+ * connections on the first returned address:
+ * addrinfo = Socket::getaddrinfo(nil, 'www', nil, Socket::SOCK_STREAM, nil, Socket::AI_PASSIVE)
+ * af, port, name, addr = addrinfo.first
+ * sock = TCPServer(addr, port)
+ * while( client = s.accept )
+ * # ...
+ * end
+ */
static VALUE
-sock_s_getaddrinfo(int argc, VALUE *argv)
+sock_s_getaddrinfo(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE host, port, family, socktype, protocol, flags, ret;
char hbuf[1024], pbuf[1024];
@@ -3247,7 +3628,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv)
}
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) {
- raise_socket_error("getaddrinfo", error);
+ rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
}
ret = make_addrinfo(res);
@@ -3256,7 +3637,9 @@ sock_s_getaddrinfo(int argc, VALUE *argv)
}
static VALUE
-sock_s_getnameinfo(int argc, VALUE *argv)
+sock_s_getnameinfo(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp;
char *hptr, *pptr;
@@ -3278,11 +3661,11 @@ sock_s_getnameinfo(int argc, VALUE *argv)
tmp = rb_check_string_type(sa);
if (!NIL_P(tmp)) {
sa = tmp;
- if (sizeof(ss) < RSTRING_LEN(sa)) {
+ if (sizeof(ss) < RSTRING(sa)->len) {
rb_raise(rb_eTypeError, "sockaddr length too big");
}
- memcpy(&ss, RSTRING_PTR(sa), RSTRING_LEN(sa));
- if (RSTRING_LEN(sa) != SA_LEN((struct sockaddr*)&ss)) {
+ memcpy(&ss, RSTRING(sa)->ptr, RSTRING(sa)->len);
+ if (RSTRING(sa)->len != SA_LEN((struct sockaddr*)&ss)) {
rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
}
sap = (struct sockaddr*)&ss;
@@ -3292,17 +3675,17 @@ sock_s_getnameinfo(int argc, VALUE *argv)
if (!NIL_P(tmp)) {
sa = tmp;
MEMZERO(&hints, struct addrinfo, 1);
- if (RARRAY_LEN(sa) == 3) {
- af = RARRAY_PTR(sa)[0];
- port = RARRAY_PTR(sa)[1];
- host = RARRAY_PTR(sa)[2];
+ if (RARRAY(sa)->len == 3) {
+ af = RARRAY(sa)->ptr[0];
+ port = RARRAY(sa)->ptr[1];
+ host = RARRAY(sa)->ptr[2];
}
- else if (RARRAY_LEN(sa) >= 4) {
- af = RARRAY_PTR(sa)[0];
- port = RARRAY_PTR(sa)[1];
- host = RARRAY_PTR(sa)[3];
+ else if (RARRAY(sa)->len >= 4) {
+ af = RARRAY(sa)->ptr[0];
+ port = RARRAY(sa)->ptr[1];
+ host = RARRAY(sa)->ptr[3];
if (NIL_P(host)) {
- host = RARRAY_PTR(sa)[2];
+ host = RARRAY(sa)->ptr[2];
}
else {
/*
@@ -3316,7 +3699,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
}
else {
rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given",
- RARRAY_LEN(sa));
+ RARRAY(sa)->len);
}
/* host */
if (NIL_P(host)) {
@@ -3390,15 +3773,16 @@ sock_s_getnameinfo(int argc, VALUE *argv)
error_exit_addr:
if (res) freeaddrinfo(res);
- raise_socket_error("getaddrinfo", error);
+ rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
error_exit_name:
if (res) freeaddrinfo(res);
- raise_socket_error("getnameinfo", error);
+ rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
static VALUE
-sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host)
+sock_s_pack_sockaddr_in(self, port, host)
+ VALUE self, port, host;
{
struct addrinfo *res = sock_addrinfo(host, port, 0, 0);
VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen);
@@ -3411,7 +3795,8 @@ sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host)
}
static VALUE
-sock_s_unpack_sockaddr_in(VALUE self, VALUE addr)
+sock_s_unpack_sockaddr_in(self, addr)
+ VALUE self, addr;
{
struct sockaddr_in * sockaddr;
VALUE host;
@@ -3435,7 +3820,8 @@ sock_s_unpack_sockaddr_in(VALUE self, VALUE addr)
#ifdef HAVE_SYS_UN_H
static VALUE
-sock_s_pack_sockaddr_un(VALUE self, VALUE path)
+sock_s_pack_sockaddr_un(self, path)
+ VALUE self, path;
{
struct sockaddr_un sockaddr;
char *sun_path;
@@ -3456,7 +3842,8 @@ sock_s_pack_sockaddr_un(VALUE self, VALUE path)
}
static VALUE
-sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
+sock_s_unpack_sockaddr_un(self, addr)
+ VALUE self, addr;
{
struct sockaddr_un * sockaddr;
char *sun_path;
@@ -3466,14 +3853,14 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) {
rb_raise(rb_eArgError, "not an AF_UNIX sockaddr");
}
- if (sizeof(struct sockaddr_un) < RSTRING_LEN(addr)) {
- rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d",
- RSTRING_LEN(addr), sizeof(struct sockaddr_un));
+ if (sizeof(struct sockaddr_un) < RSTRING(addr)->len) {
+ rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d",
+ RSTRING(addr)->len, sizeof(struct sockaddr_un));
}
- sun_path = unixpath(sockaddr, RSTRING_LEN(addr));
- if (sizeof(struct sockaddr_un) == RSTRING_LEN(addr) &&
+ sun_path = unixpath(sockaddr, RSTRING(addr)->len);
+ if (sizeof(struct sockaddr_un) == RSTRING(addr)->len &&
sun_path == sockaddr->sun_path &&
- sun_path + strlen(sun_path) == RSTRING_PTR(addr) + RSTRING_LEN(addr)) {
+ sun_path + strlen(sun_path) == RSTRING(addr)->ptr + RSTRING(addr)->len) {
rb_raise(rb_eArgError, "sockaddr_un.sun_path not NUL terminated");
}
path = rb_str_new2(sun_path);
@@ -3485,7 +3872,9 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
static VALUE mConst;
static void
-sock_define_const(char *name, int value)
+sock_define_const(name, value)
+ char *name;
+ int value;
{
rb_define_const(rb_cSocket, name, INT2FIX(value));
rb_define_const(mConst, name, INT2FIX(value));
@@ -3496,7 +3885,7 @@ sock_define_const(char *name, int value)
* socket implementations. It can be used to provide more operating system
* specific functionality than the protocol-specific socket classes but at the
* expense of greater complexity. In particular, the class handles addresses
- * using +struct+ sockaddr structures packed into Ruby strings, which can be
+ * using +struct sockaddr+ structures packed into Ruby strings, which can be
* a joy to manipulate.
*
* === Exception Handling
@@ -3540,21 +3929,22 @@ Init_socket()
rb_define_method(rb_cBasicSocket, "send", bsock_send, -1);
rb_define_method(rb_cBasicSocket, "recv", bsock_recv, -1);
rb_define_method(rb_cBasicSocket, "recv_nonblock", bsock_recv_nonblock, -1);
- rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup", bsock_do_not_reverse_lookup, 0);
- rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup=", bsock_do_not_reverse_lookup_set, 1);
rb_cIPSocket = rb_define_class("IPSocket", rb_cBasicSocket);
+ rb_define_global_const("IPsocket", rb_cIPSocket);
rb_define_method(rb_cIPSocket, "addr", ip_addr, 0);
rb_define_method(rb_cIPSocket, "peeraddr", ip_peeraddr, 0);
rb_define_method(rb_cIPSocket, "recvfrom", ip_recvfrom, -1);
rb_define_singleton_method(rb_cIPSocket, "getaddress", ip_s_getaddress, 1);
rb_cTCPSocket = rb_define_class("TCPSocket", rb_cIPSocket);
+ rb_define_global_const("TCPsocket", rb_cTCPSocket);
rb_define_singleton_method(rb_cTCPSocket, "gethostbyname", tcp_s_gethostbyname, 1);
rb_define_method(rb_cTCPSocket, "initialize", tcp_init, -1);
#ifdef SOCKS
rb_cSOCKSSocket = rb_define_class("SOCKSSocket", rb_cTCPSocket);
+ rb_define_global_const("SOCKSsocket", rb_cSOCKSSocket);
rb_define_method(rb_cSOCKSSocket, "initialize", socks_init, 2);
#ifdef SOCKS5
rb_define_method(rb_cSOCKSSocket, "close", socks_s_close, 0);
@@ -3562,6 +3952,7 @@ Init_socket()
#endif
rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);
+ rb_define_global_const("TCPserver", rb_cTCPServer);
rb_define_method(rb_cTCPServer, "accept", tcp_accept, 0);
rb_define_method(rb_cTCPServer, "accept_nonblock", tcp_accept_nonblock, 0);
rb_define_method(rb_cTCPServer, "sysaccept", tcp_sysaccept, 0);
@@ -3569,6 +3960,7 @@ Init_socket()
rb_define_method(rb_cTCPServer, "listen", sock_listen, 1);
rb_cUDPSocket = rb_define_class("UDPSocket", rb_cIPSocket);
+ rb_define_global_const("UDPsocket", rb_cUDPSocket);
rb_define_method(rb_cUDPSocket, "initialize", udp_init, -1);
rb_define_method(rb_cUDPSocket, "connect", udp_connect, 2);
rb_define_method(rb_cUDPSocket, "bind", udp_bind, 2);
@@ -3577,6 +3969,7 @@ Init_socket()
#ifdef HAVE_SYS_UN_H
rb_cUNIXSocket = rb_define_class("UNIXSocket", rb_cBasicSocket);
+ rb_define_global_const("UNIXsocket", rb_cUNIXSocket);
rb_define_method(rb_cUNIXSocket, "initialize", unix_init, 1);
rb_define_method(rb_cUNIXSocket, "path", unix_path, 0);
rb_define_method(rb_cUNIXSocket, "addr", unix_addr, 0);
@@ -3588,6 +3981,7 @@ Init_socket()
rb_define_singleton_method(rb_cUNIXSocket, "pair", unix_s_socketpair, -1);
rb_cUNIXServer = rb_define_class("UNIXServer", rb_cUNIXSocket);
+ rb_define_global_const("UNIXserver", rb_cUNIXServer);
rb_define_method(rb_cUNIXServer, "initialize", unix_svr_init, 1);
rb_define_method(rb_cUNIXServer, "accept", unix_accept, 0);
rb_define_method(rb_cUNIXServer, "accept_nonblock", unix_accept_nonblock, 0);
@@ -3614,8 +4008,7 @@ Init_socket()
rb_define_singleton_method(rb_cSocket, "gethostname", sock_gethostname, 0);
rb_define_singleton_method(rb_cSocket, "gethostbyname", sock_s_gethostbyname, 1);
rb_define_singleton_method(rb_cSocket, "gethostbyaddr", sock_s_gethostbyaddr, -1);
- rb_define_singleton_method(rb_cSocket, "getservbyname", sock_s_getservbyname, -1);
- rb_define_singleton_method(rb_cSocket, "getservbyport", sock_s_getservbyport, -1);
+ rb_define_singleton_method(rb_cSocket, "getservbyname", sock_s_getservbyaname, -1);
rb_define_singleton_method(rb_cSocket, "getaddrinfo", sock_s_getaddrinfo, -1);
rb_define_singleton_method(rb_cSocket, "getnameinfo", sock_s_getnameinfo, -1);
rb_define_singleton_method(rb_cSocket, "sockaddr_in", sock_s_pack_sockaddr_in, 2);
@@ -3629,9 +4022,700 @@ Init_socket()
/* constants */
mConst = rb_define_module_under(rb_cSocket, "Constants");
-#include "constants.h"
-#ifdef INET6 /* IPv6 is not supported although AF_INET6 is defined on bcc32/mingw */
+ sock_define_const("SOCK_STREAM", SOCK_STREAM);
+ sock_define_const("SOCK_DGRAM", SOCK_DGRAM);
+#ifdef SOCK_RAW
+ sock_define_const("SOCK_RAW", SOCK_RAW);
+#endif
+#ifdef SOCK_RDM
+ sock_define_const("SOCK_RDM", SOCK_RDM);
+#endif
+#ifdef SOCK_SEQPACKET
+ sock_define_const("SOCK_SEQPACKET", SOCK_SEQPACKET);
+#endif
+#ifdef SOCK_PACKET
+ sock_define_const("SOCK_PACKET", SOCK_PACKET);
+#endif
+
+ sock_define_const("AF_INET", AF_INET);
+#ifdef PF_INET
+ sock_define_const("PF_INET", PF_INET);
+#endif
+#ifdef AF_UNIX
+ sock_define_const("AF_UNIX", AF_UNIX);
+ sock_define_const("PF_UNIX", PF_UNIX);
+#endif
+#ifdef AF_AX25
+ sock_define_const("AF_AX25", AF_AX25);
+ sock_define_const("PF_AX25", PF_AX25);
+#endif
+#ifdef AF_IPX
+ sock_define_const("AF_IPX", AF_IPX);
+ sock_define_const("PF_IPX", PF_IPX);
+#endif
+#ifdef AF_APPLETALK
+ sock_define_const("AF_APPLETALK", AF_APPLETALK);
+ sock_define_const("PF_APPLETALK", PF_APPLETALK);
+#endif
+#ifdef AF_UNSPEC
+ sock_define_const("AF_UNSPEC", AF_UNSPEC);
+ sock_define_const("PF_UNSPEC", PF_UNSPEC);
+#endif
+#ifdef INET6
sock_define_const("AF_INET6", AF_INET6);
+#endif
+#ifdef INET6
sock_define_const("PF_INET6", PF_INET6);
#endif
+#ifdef AF_LOCAL
+ sock_define_const("AF_LOCAL", AF_LOCAL);
+#endif
+#ifdef PF_LOCAL
+ sock_define_const("PF_LOCAL", PF_LOCAL);
+#endif
+#ifdef AF_IMPLINK
+ sock_define_const("AF_IMPLINK", AF_IMPLINK);
+#endif
+#ifdef PF_IMPLINK
+ sock_define_const("PF_IMPLINK", PF_IMPLINK);
+#endif
+#ifdef AF_PUP
+ sock_define_const("AF_PUP", AF_PUP);
+#endif
+#ifdef PF_PUP
+ sock_define_const("PF_PUP", PF_PUP);
+#endif
+#ifdef AF_CHAOS
+ sock_define_const("AF_CHAOS", AF_CHAOS);
+#endif
+#ifdef PF_CHAOS
+ sock_define_const("PF_CHAOS", PF_CHAOS);
+#endif
+#ifdef AF_NS
+ sock_define_const("AF_NS", AF_NS);
+#endif
+#ifdef PF_NS
+ sock_define_const("PF_NS", PF_NS);
+#endif
+#ifdef AF_ISO
+ sock_define_const("AF_ISO", AF_ISO);
+#endif
+#ifdef PF_ISO
+ sock_define_const("PF_ISO", PF_ISO);
+#endif
+#ifdef AF_OSI
+ sock_define_const("AF_OSI", AF_OSI);
+#endif
+#ifdef PF_OSI
+ sock_define_const("PF_OSI", PF_OSI);
+#endif
+#ifdef AF_ECMA
+ sock_define_const("AF_ECMA", AF_ECMA);
+#endif
+#ifdef PF_ECMA
+ sock_define_const("PF_ECMA", PF_ECMA);
+#endif
+#ifdef AF_DATAKIT
+ sock_define_const("AF_DATAKIT", AF_DATAKIT);
+#endif
+#ifdef PF_DATAKIT
+ sock_define_const("PF_DATAKIT", PF_DATAKIT);
+#endif
+#ifdef AF_CCITT
+ sock_define_const("AF_CCITT", AF_CCITT);
+#endif
+#ifdef PF_CCITT
+ sock_define_const("PF_CCITT", PF_CCITT);
+#endif
+#ifdef AF_SNA
+ sock_define_const("AF_SNA", AF_SNA);
+#endif
+#ifdef PF_SNA
+ sock_define_const("PF_SNA", PF_SNA);
+#endif
+#ifdef AF_DEC
+ sock_define_const("AF_DEC", AF_DEC);
+#endif
+#ifdef PF_DEC
+ sock_define_const("PF_DEC", PF_DEC);
+#endif
+#ifdef AF_DLI
+ sock_define_const("AF_DLI", AF_DLI);
+#endif
+#ifdef PF_DLI
+ sock_define_const("PF_DLI", PF_DLI);
+#endif
+#ifdef AF_LAT
+ sock_define_const("AF_LAT", AF_LAT);
+#endif
+#ifdef PF_LAT
+ sock_define_const("PF_LAT", PF_LAT);
+#endif
+#ifdef AF_HYLINK
+ sock_define_const("AF_HYLINK", AF_HYLINK);
+#endif
+#ifdef PF_HYLINK
+ sock_define_const("PF_HYLINK", PF_HYLINK);
+#endif
+#ifdef AF_ROUTE
+ sock_define_const("AF_ROUTE", AF_ROUTE);
+#endif
+#ifdef PF_ROUTE
+ sock_define_const("PF_ROUTE", PF_ROUTE);
+#endif
+#ifdef AF_LINK
+ sock_define_const("AF_LINK", AF_LINK);
+#endif
+#ifdef PF_LINK
+ sock_define_const("PF_LINK", PF_LINK);
+#endif
+#ifdef AF_COIP
+ sock_define_const("AF_COIP", AF_COIP);
+#endif
+#ifdef PF_COIP
+ sock_define_const("PF_COIP", PF_COIP);
+#endif
+#ifdef AF_CNT
+ sock_define_const("AF_CNT", AF_CNT);
+#endif
+#ifdef PF_CNT
+ sock_define_const("PF_CNT", PF_CNT);
+#endif
+#ifdef AF_SIP
+ sock_define_const("AF_SIP", AF_SIP);
+#endif
+#ifdef PF_SIP
+ sock_define_const("PF_SIP", PF_SIP);
+#endif
+#ifdef AF_NDRV
+ sock_define_const("AF_NDRV", AF_NDRV);
+#endif
+#ifdef PF_NDRV
+ sock_define_const("PF_NDRV", PF_NDRV);
+#endif
+#ifdef AF_ISDN
+ sock_define_const("AF_ISDN", AF_ISDN);
+#endif
+#ifdef PF_ISDN
+ sock_define_const("PF_ISDN", PF_ISDN);
+#endif
+#ifdef AF_NATM
+ sock_define_const("AF_NATM", AF_NATM);
+#endif
+#ifdef PF_NATM
+ sock_define_const("PF_NATM", PF_NATM);
+#endif
+#ifdef AF_SYSTEM
+ sock_define_const("AF_SYSTEM", AF_SYSTEM);
+#endif
+#ifdef PF_SYSTEM
+ sock_define_const("PF_SYSTEM", PF_SYSTEM);
+#endif
+#ifdef AF_NETBIOS
+ sock_define_const("AF_NETBIOS", AF_NETBIOS);
+#endif
+#ifdef PF_NETBIOS
+ sock_define_const("PF_NETBIOS", PF_NETBIOS);
+#endif
+#ifdef AF_PPP
+ sock_define_const("AF_PPP", AF_PPP);
+#endif
+#ifdef PF_PPP
+ sock_define_const("PF_PPP", PF_PPP);
+#endif
+#ifdef AF_ATM
+ sock_define_const("AF_ATM", AF_ATM);
+#endif
+#ifdef PF_ATM
+ sock_define_const("PF_ATM", PF_ATM);
+#endif
+#ifdef AF_NETGRAPH
+ sock_define_const("AF_NETGRAPH", AF_NETGRAPH);
+#endif
+#ifdef PF_NETGRAPH
+ sock_define_const("PF_NETGRAPH", PF_NETGRAPH);
+#endif
+#ifdef AF_MAX
+ sock_define_const("AF_MAX", AF_MAX);
+#endif
+#ifdef PF_MAX
+ sock_define_const("PF_MAX", PF_MAX);
+#endif
+#ifdef AF_E164
+ sock_define_const("AF_E164", AF_E164);
+#endif
+#ifdef PF_XTP
+ sock_define_const("PF_XTP", PF_XTP);
+#endif
+#ifdef PF_RTIP
+ sock_define_const("PF_RTIP", PF_RTIP);
+#endif
+#ifdef PF_PIP
+ sock_define_const("PF_PIP", PF_PIP);
+#endif
+#ifdef PF_KEY
+ sock_define_const("PF_KEY", PF_KEY);
+#endif
+
+ sock_define_const("MSG_OOB", MSG_OOB);
+#ifdef MSG_PEEK
+ sock_define_const("MSG_PEEK", MSG_PEEK);
+#endif
+#ifdef MSG_DONTROUTE
+ sock_define_const("MSG_DONTROUTE", MSG_DONTROUTE);
+#endif
+#ifdef MSG_EOR
+ sock_define_const("MSG_EOR", MSG_EOR);
+#endif
+#ifdef MSG_TRUNC
+ sock_define_const("MSG_TRUNC", MSG_TRUNC);
+#endif
+#ifdef MSG_CTRUNC
+ sock_define_const("MSG_CTRUNC", MSG_CTRUNC);
+#endif
+#ifdef MSG_WAITALL
+ sock_define_const("MSG_WAITALL", MSG_WAITALL);
+#endif
+#ifdef MSG_DONTWAIT
+ sock_define_const("MSG_DONTWAIT", MSG_DONTWAIT);
+#endif
+#ifdef MSG_EOF
+ sock_define_const("MSG_EOF", MSG_EOF);
+#endif
+#ifdef MSG_FLUSH
+ sock_define_const("MSG_FLUSH", MSG_FLUSH);
+#endif
+#ifdef MSG_HOLD
+ sock_define_const("MSG_HOLD", MSG_HOLD);
+#endif
+#ifdef MSG_SEND
+ sock_define_const("MSG_SEND", MSG_SEND);
+#endif
+#ifdef MSG_HAVEMORE
+ sock_define_const("MSG_HAVEMORE", MSG_HAVEMORE);
+#endif
+#ifdef MSG_RCVMORE
+ sock_define_const("MSG_RCVMORE", MSG_RCVMORE);
+#endif
+#ifdef MSG_COMPAT
+ sock_define_const("MSG_COMPAT", MSG_COMPAT);
+#endif
+
+ sock_define_const("SOL_SOCKET", SOL_SOCKET);
+#ifdef SOL_IP
+ sock_define_const("SOL_IP", SOL_IP);
+#endif
+#ifdef SOL_IPX
+ sock_define_const("SOL_IPX", SOL_IPX);
+#endif
+#ifdef SOL_AX25
+ sock_define_const("SOL_AX25", SOL_AX25);
+#endif
+#ifdef SOL_ATALK
+ sock_define_const("SOL_ATALK", SOL_ATALK);
+#endif
+#ifdef SOL_TCP
+ sock_define_const("SOL_TCP", SOL_TCP);
+#endif
+#ifdef SOL_UDP
+ sock_define_const("SOL_UDP", SOL_UDP);
+#endif
+
+#ifdef IPPROTO_IP
+ sock_define_const("IPPROTO_IP", IPPROTO_IP);
+#else
+ sock_define_const("IPPROTO_IP", 0);
+#endif
+#ifdef IPPROTO_ICMP
+ sock_define_const("IPPROTO_ICMP", IPPROTO_ICMP);
+#else
+ sock_define_const("IPPROTO_ICMP", 1);
+#endif
+#ifdef IPPROTO_IGMP
+ sock_define_const("IPPROTO_IGMP", IPPROTO_IGMP);
+#endif
+#ifdef IPPROTO_GGP
+ sock_define_const("IPPROTO_GGP", IPPROTO_GGP);
+#endif
+#ifdef IPPROTO_TCP
+ sock_define_const("IPPROTO_TCP", IPPROTO_TCP);
+#else
+ sock_define_const("IPPROTO_TCP", 6);
+#endif
+#ifdef IPPROTO_EGP
+ sock_define_const("IPPROTO_EGP", IPPROTO_EGP);
+#endif
+#ifdef IPPROTO_PUP
+ sock_define_const("IPPROTO_PUP", IPPROTO_PUP);
+#endif
+#ifdef IPPROTO_UDP
+ sock_define_const("IPPROTO_UDP", IPPROTO_UDP);
+#else
+ sock_define_const("IPPROTO_UDP", 17);
+#endif
+#ifdef IPPROTO_IDP
+ sock_define_const("IPPROTO_IDP", IPPROTO_IDP);
+#endif
+#ifdef IPPROTO_HELLO
+ sock_define_const("IPPROTO_HELLO", IPPROTO_HELLO);
+#endif
+#ifdef IPPROTO_ND
+ sock_define_const("IPPROTO_ND", IPPROTO_ND);
+#endif
+#ifdef IPPROTO_TP
+ sock_define_const("IPPROTO_TP", IPPROTO_TP);
+#endif
+#ifdef IPPROTO_XTP
+ sock_define_const("IPPROTO_XTP", IPPROTO_XTP);
+#endif
+#ifdef IPPROTO_EON
+ sock_define_const("IPPROTO_EON", IPPROTO_EON);
+#endif
+#ifdef IPPROTO_BIP
+ sock_define_const("IPPROTO_BIP", IPPROTO_BIP);
+#endif
+/**/
+#ifdef IPPROTO_RAW
+ sock_define_const("IPPROTO_RAW", IPPROTO_RAW);
+#else
+ sock_define_const("IPPROTO_RAW", 255);
+#endif
+#ifdef IPPROTO_MAX
+ sock_define_const("IPPROTO_MAX", IPPROTO_MAX);
+#endif
+
+ /* Some port configuration */
+#ifdef IPPORT_RESERVED
+ sock_define_const("IPPORT_RESERVED", IPPORT_RESERVED);
+#else
+ sock_define_const("IPPORT_RESERVED", 1024);
+#endif
+#ifdef IPPORT_USERRESERVED
+ sock_define_const("IPPORT_USERRESERVED", IPPORT_USERRESERVED);
+#else
+ sock_define_const("IPPORT_USERRESERVED", 5000);
+#endif
+ /* Some reserved IP v.4 addresses */
+#ifdef INADDR_ANY
+ sock_define_const("INADDR_ANY", INADDR_ANY);
+#else
+ sock_define_const("INADDR_ANY", 0x00000000);
+#endif
+#ifdef INADDR_BROADCAST
+ sock_define_const("INADDR_BROADCAST", INADDR_BROADCAST);
+#else
+ sock_define_const("INADDR_BROADCAST", 0xffffffff);
+#endif
+#ifdef INADDR_LOOPBACK
+ sock_define_const("INADDR_LOOPBACK", INADDR_LOOPBACK);
+#else
+ sock_define_const("INADDR_LOOPBACK", 0x7F000001);
+#endif
+#ifdef INADDR_UNSPEC_GROUP
+ sock_define_const("INADDR_UNSPEC_GROUP", INADDR_UNSPEC_GROUP);
+#else
+ sock_define_const("INADDR_UNSPEC_GROUP", 0xe0000000);
+#endif
+#ifdef INADDR_ALLHOSTS_GROUP
+ sock_define_const("INADDR_ALLHOSTS_GROUP", INADDR_ALLHOSTS_GROUP);
+#else
+ sock_define_const("INADDR_ALLHOSTS_GROUP", 0xe0000001);
+#endif
+#ifdef INADDR_MAX_LOCAL_GROUP
+ sock_define_const("INADDR_MAX_LOCAL_GROUP", INADDR_MAX_LOCAL_GROUP);
+#else
+ sock_define_const("INADDR_MAX_LOCAL_GROUP", 0xe00000ff);
+#endif
+#ifdef INADDR_NONE
+ sock_define_const("INADDR_NONE", INADDR_NONE);
+#else
+ sock_define_const("INADDR_NONE", 0xffffffff);
+#endif
+ /* IP [gs]etsockopt options */
+#ifdef IP_OPTIONS
+ sock_define_const("IP_OPTIONS", IP_OPTIONS);
+#endif
+#ifdef IP_HDRINCL
+ sock_define_const("IP_HDRINCL", IP_HDRINCL);
+#endif
+#ifdef IP_TOS
+ sock_define_const("IP_TOS", IP_TOS);
+#endif
+#ifdef IP_TTL
+ sock_define_const("IP_TTL", IP_TTL);
+#endif
+#ifdef IP_RECVOPTS
+ sock_define_const("IP_RECVOPTS", IP_RECVOPTS);
+#endif
+#ifdef IP_RECVRETOPTS
+ sock_define_const("IP_RECVRETOPTS", IP_RECVRETOPTS);
+#endif
+#ifdef IP_RECVDSTADDR
+ sock_define_const("IP_RECVDSTADDR", IP_RECVDSTADDR);
+#endif
+#ifdef IP_RETOPTS
+ sock_define_const("IP_RETOPTS", IP_RETOPTS);
+#endif
+#ifdef IP_MULTICAST_IF
+ sock_define_const("IP_MULTICAST_IF", IP_MULTICAST_IF);
+#endif
+#ifdef IP_MULTICAST_TTL
+ sock_define_const("IP_MULTICAST_TTL", IP_MULTICAST_TTL);
+#endif
+#ifdef IP_MULTICAST_LOOP
+ sock_define_const("IP_MULTICAST_LOOP", IP_MULTICAST_LOOP);
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+ sock_define_const("IP_ADD_MEMBERSHIP", IP_ADD_MEMBERSHIP);
+#endif
+#ifdef IP_DROP_MEMBERSHIP
+ sock_define_const("IP_DROP_MEMBERSHIP", IP_DROP_MEMBERSHIP);
+#endif
+#ifdef IP_DEFAULT_MULTICAST_TTL
+ sock_define_const("IP_DEFAULT_MULTICAST_TTL", IP_DEFAULT_MULTICAST_TTL);
+#endif
+#ifdef IP_DEFAULT_MULTICAST_LOOP
+ sock_define_const("IP_DEFAULT_MULTICAST_LOOP", IP_DEFAULT_MULTICAST_LOOP);
+#endif
+#ifdef IP_MAX_MEMBERSHIPS
+ sock_define_const("IP_MAX_MEMBERSHIPS", IP_MAX_MEMBERSHIPS);
+#endif
+#ifdef SO_DEBUG
+ sock_define_const("SO_DEBUG", SO_DEBUG);
+#endif
+ sock_define_const("SO_REUSEADDR", SO_REUSEADDR);
+#ifdef SO_REUSEPORT
+ sock_define_const("SO_REUSEPORT", SO_REUSEPORT);
+#endif
+#ifdef SO_TYPE
+ sock_define_const("SO_TYPE", SO_TYPE);
+#endif
+#ifdef SO_ERROR
+ sock_define_const("SO_ERROR", SO_ERROR);
+#endif
+#ifdef SO_DONTROUTE
+ sock_define_const("SO_DONTROUTE", SO_DONTROUTE);
+#endif
+#ifdef SO_BROADCAST
+ sock_define_const("SO_BROADCAST", SO_BROADCAST);
+#endif
+#ifdef SO_SNDBUF
+ sock_define_const("SO_SNDBUF", SO_SNDBUF);
+#endif
+#ifdef SO_RCVBUF
+ sock_define_const("SO_RCVBUF", SO_RCVBUF);
+#endif
+#ifdef SO_KEEPALIVE
+ sock_define_const("SO_KEEPALIVE", SO_KEEPALIVE);
+#endif
+#ifdef SO_OOBINLINE
+ sock_define_const("SO_OOBINLINE", SO_OOBINLINE);
+#endif
+#ifdef SO_NO_CHECK
+ sock_define_const("SO_NO_CHECK", SO_NO_CHECK);
+#endif
+#ifdef SO_PRIORITY
+ sock_define_const("SO_PRIORITY", SO_PRIORITY);
+#endif
+#ifdef SO_LINGER
+ sock_define_const("SO_LINGER", SO_LINGER);
+#endif
+#ifdef SO_PASSCRED
+ sock_define_const("SO_PASSCRED", SO_PASSCRED);
+#endif
+#ifdef SO_PEERCRED
+ sock_define_const("SO_PEERCRED", SO_PEERCRED);
+#endif
+#ifdef SO_RCVLOWAT
+ sock_define_const("SO_RCVLOWAT", SO_RCVLOWAT);
+#endif
+#ifdef SO_SNDLOWAT
+ sock_define_const("SO_SNDLOWAT", SO_SNDLOWAT);
+#endif
+#ifdef SO_RCVTIMEO
+ sock_define_const("SO_RCVTIMEO", SO_RCVTIMEO);
+#endif
+#ifdef SO_SNDTIMEO
+ sock_define_const("SO_SNDTIMEO", SO_SNDTIMEO);
+#endif
+#ifdef SO_ACCEPTCONN
+ sock_define_const("SO_ACCEPTCONN", SO_ACCEPTCONN);
+#endif
+#ifdef SO_USELOOPBACK
+ sock_define_const("SO_USELOOPBACK", SO_USELOOPBACK);
+#endif
+#ifdef SO_ACCEPTFILTER
+ sock_define_const("SO_ACCEPTFILTER", SO_ACCEPTFILTER);
+#endif
+#ifdef SO_DONTTRUNC
+ sock_define_const("SO_DONTTRUNC", SO_DONTTRUNC);
+#endif
+#ifdef SO_WANTMORE
+ sock_define_const("SO_WANTMORE", SO_WANTMORE);
+#endif
+#ifdef SO_WANTOOBFLAG
+ sock_define_const("SO_WANTOOBFLAG", SO_WANTOOBFLAG);
+#endif
+#ifdef SO_NREAD
+ sock_define_const("SO_NREAD", SO_NREAD);
+#endif
+#ifdef SO_NKE
+ sock_define_const("SO_NKE", SO_NKE);
+#endif
+#ifdef SO_NOSIGPIPE
+ sock_define_const("SO_NOSIGPIPE", SO_NOSIGPIPE);
+#endif
+
+#ifdef SO_SECURITY_AUTHENTICATION
+ sock_define_const("SO_SECURITY_AUTHENTICATION", SO_SECURITY_AUTHENTICATION);
+#endif
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ sock_define_const("SO_SECURITY_ENCRYPTION_TRANSPORT", SO_SECURITY_ENCRYPTION_TRANSPORT);
+#endif
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ sock_define_const("SO_SECURITY_ENCRYPTION_NETWORK", SO_SECURITY_ENCRYPTION_NETWORK);
+#endif
+
+#ifdef SO_BINDTODEVICE
+ sock_define_const("SO_BINDTODEVICE", SO_BINDTODEVICE);
+#endif
+#ifdef SO_ATTACH_FILTER
+ sock_define_const("SO_ATTACH_FILTER", SO_ATTACH_FILTER);
+#endif
+#ifdef SO_DETACH_FILTER
+ sock_define_const("SO_DETACH_FILTER", SO_DETACH_FILTER);
+#endif
+#ifdef SO_PEERNAME
+ sock_define_const("SO_PEERNAME", SO_PEERNAME);
+#endif
+#ifdef SO_TIMESTAMP
+ sock_define_const("SO_TIMESTAMP", SO_TIMESTAMP);
+#endif
+
+#ifdef SOPRI_INTERACTIVE
+ sock_define_const("SOPRI_INTERACTIVE", SOPRI_INTERACTIVE);
+#endif
+#ifdef SOPRI_NORMAL
+ sock_define_const("SOPRI_NORMAL", SOPRI_NORMAL);
+#endif
+#ifdef SOPRI_BACKGROUND
+ sock_define_const("SOPRI_BACKGROUND", SOPRI_BACKGROUND);
+#endif
+
+#ifdef IPX_TYPE
+ sock_define_const("IPX_TYPE", IPX_TYPE);
+#endif
+
+#ifdef TCP_NODELAY
+ sock_define_const("TCP_NODELAY", TCP_NODELAY);
+#endif
+#ifdef TCP_MAXSEG
+ sock_define_const("TCP_MAXSEG", TCP_MAXSEG);
+#endif
+
+#ifdef EAI_ADDRFAMILY
+ sock_define_const("EAI_ADDRFAMILY", EAI_ADDRFAMILY);
+#endif
+#ifdef EAI_AGAIN
+ sock_define_const("EAI_AGAIN", EAI_AGAIN);
+#endif
+#ifdef EAI_BADFLAGS
+ sock_define_const("EAI_BADFLAGS", EAI_BADFLAGS);
+#endif
+#ifdef EAI_FAIL
+ sock_define_const("EAI_FAIL", EAI_FAIL);
+#endif
+#ifdef EAI_FAMILY
+ sock_define_const("EAI_FAMILY", EAI_FAMILY);
+#endif
+#ifdef EAI_MEMORY
+ sock_define_const("EAI_MEMORY", EAI_MEMORY);
+#endif
+#ifdef EAI_NODATA
+ sock_define_const("EAI_NODATA", EAI_NODATA);
+#endif
+#ifdef EAI_NONAME
+ sock_define_const("EAI_NONAME", EAI_NONAME);
+#endif
+#ifdef EAI_SERVICE
+ sock_define_const("EAI_SERVICE", EAI_SERVICE);
+#endif
+#ifdef EAI_SOCKTYPE
+ sock_define_const("EAI_SOCKTYPE", EAI_SOCKTYPE);
+#endif
+#ifdef EAI_SYSTEM
+ sock_define_const("EAI_SYSTEM", EAI_SYSTEM);
+#endif
+#ifdef EAI_BADHINTS
+ sock_define_const("EAI_BADHINTS", EAI_BADHINTS);
+#endif
+#ifdef EAI_PROTOCOL
+ sock_define_const("EAI_PROTOCOL", EAI_PROTOCOL);
+#endif
+#ifdef EAI_MAX
+ sock_define_const("EAI_MAX", EAI_MAX);
+#endif
+#ifdef AI_PASSIVE
+ sock_define_const("AI_PASSIVE", AI_PASSIVE);
+#endif
+#ifdef AI_CANONNAME
+ sock_define_const("AI_CANONNAME", AI_CANONNAME);
+#endif
+#ifdef AI_NUMERICHOST
+ sock_define_const("AI_NUMERICHOST", AI_NUMERICHOST);
+#endif
+#ifdef AI_MASK
+ sock_define_const("AI_MASK", AI_MASK);
+#endif
+#ifdef AI_ALL
+ sock_define_const("AI_ALL", AI_ALL);
+#endif
+#ifdef AI_V4MAPPED_CFG
+ sock_define_const("AI_V4MAPPED_CFG", AI_V4MAPPED_CFG);
+#endif
+#ifdef AI_ADDRCONFIG
+ sock_define_const("AI_ADDRCONFIG", AI_ADDRCONFIG);
+#endif
+#ifdef AI_V4MAPPED
+ sock_define_const("AI_V4MAPPED", AI_V4MAPPED);
+#endif
+#ifdef AI_DEFAULT
+ sock_define_const("AI_DEFAULT", AI_DEFAULT);
+#endif
+#ifdef NI_MAXHOST
+ sock_define_const("NI_MAXHOST", NI_MAXHOST);
+#endif
+#ifdef NI_MAXSERV
+ sock_define_const("NI_MAXSERV", NI_MAXSERV);
+#endif
+#ifdef NI_NOFQDN
+ sock_define_const("NI_NOFQDN", NI_NOFQDN);
+#endif
+#ifdef NI_NUMERICHOST
+ sock_define_const("NI_NUMERICHOST", NI_NUMERICHOST);
+#endif
+#ifdef NI_NAMEREQD
+ sock_define_const("NI_NAMEREQD", NI_NAMEREQD);
+#endif
+#ifdef NI_NUMERICSERV
+ sock_define_const("NI_NUMERICSERV", NI_NUMERICSERV);
+#endif
+#ifdef NI_DGRAM
+ sock_define_const("NI_DGRAM", NI_DGRAM);
+#endif
+#ifdef SHUT_RD
+ sock_define_const("SHUT_RD", SHUT_RD);
+#else
+ sock_define_const("SHUT_RD", 0);
+#endif
+#ifdef SHUT_WR
+ sock_define_const("SHUT_WR", SHUT_WR);
+#else
+ sock_define_const("SHUT_WR", 1);
+#endif
+#ifdef SHUT_RDWR
+ sock_define_const("SHUT_RDWR", SHUT_RDWR);
+#else
+ sock_define_const("SHUT_RDWR", 2);
+#endif
}
diff --git a/ext/stringio/.cvsignore b/ext/stringio/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/stringio/.cvsignore
+++ b/ext/stringio/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/stringio/depend b/ext/stringio/depend
index 338ebde529..cc9eae3f55 100644
--- a/ext/stringio/depend
+++ b/ext/stringio/depend
@@ -1,3 +1,2 @@
-stringio.o: stringio.c $(hdrdir)/ruby/ruby.h $(arch_hdrdir)/ruby/config.h \
- $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/io.h \
- $(hdrdir)/ruby/encoding.h
+stringio.o: stringio.c $(hdrdir)/ruby.h $(topdir)/config.h \
+ $(hdrdir)/defines.h $(hdrdir)/intern.h $(hdrdir)/rubyio.h
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 34e0a1dd19..537fc19a4e 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -13,13 +13,16 @@
**********************************************************************/
#include "ruby.h"
-#include "ruby/io.h"
+#include "rubyio.h"
+#include "re.h"
#if defined(HAVE_FCNTL_H) || defined(_WIN32)
#include <fcntl.h>
#elif defined(HAVE_SYS_FCNTL_H)
#include <sys/fcntl.h>
#endif
+#define STRIO_EOF FMODE_SYNC
+
struct StringIO {
VALUE string;
long pos;
@@ -28,9 +31,14 @@ struct StringIO {
int count;
};
+static struct StringIO* strio_alloc _((void));
static void strio_mark _((struct StringIO *));
static void strio_free _((struct StringIO *));
-static void strio_init(int, VALUE *, struct StringIO *);
+static struct StringIO* check_strio _((VALUE));
+static struct StringIO* get_strio _((VALUE));
+static struct StringIO* readable _((struct StringIO *));
+static struct StringIO* writable _((struct StringIO *));
+static void check_modifiable _((struct StringIO *));
#define IS_STRIO(obj) (RDATA(obj)->dmark == (RUBY_DATA_FUNC)strio_mark)
#define error_inval(msg) (errno = EINVAL, rb_sys_fail(msg))
@@ -48,7 +56,8 @@ strio_alloc()
}
static void
-strio_mark(struct StringIO *ptr)
+strio_mark(ptr)
+ struct StringIO *ptr;
{
if (ptr) {
rb_gc_mark(ptr->string);
@@ -56,7 +65,8 @@ strio_mark(struct StringIO *ptr)
}
static void
-strio_free(struct StringIO *ptr)
+strio_free(ptr)
+ struct StringIO *ptr;
{
if (--ptr->count <= 0) {
xfree(ptr);
@@ -64,7 +74,8 @@ strio_free(struct StringIO *ptr)
}
static struct StringIO*
-check_strio(VALUE self)
+check_strio(self)
+ VALUE self;
{
Check_Type(self, T_DATA);
if (!IS_STRIO(self)) {
@@ -75,7 +86,8 @@ check_strio(VALUE self)
}
static struct StringIO*
-get_strio(VALUE self)
+get_strio(self)
+ VALUE self;
{
struct StringIO *ptr = check_strio(self);
@@ -85,18 +97,6 @@ get_strio(VALUE self)
return ptr;
}
-static VALUE
-strio_substr(struct StringIO *ptr, int pos, int len)
-{
- VALUE str = ptr->string;
- rb_encoding *enc = rb_enc_get(str);
- int rlen = RSTRING_LEN(str) - pos;
-
- if (len > rlen) len = rlen;
- if (len < 0) len = 0;
- return rb_enc_str_new(RSTRING_PTR(str)+pos, len, enc);
-}
-
#define StringIO(obj) get_strio(obj)
#define CLOSED(ptr) (!((ptr)->flags & FMODE_READWRITE))
@@ -104,7 +104,8 @@ strio_substr(struct StringIO *ptr, int pos, int len)
#define WRITABLE(ptr) ((ptr)->flags & FMODE_WRITABLE)
static struct StringIO*
-readable(struct StringIO *ptr)
+readable(ptr)
+ struct StringIO *ptr;
{
if (!READABLE(ptr)) {
rb_raise(rb_eIOError, "not opened for reading");
@@ -113,7 +114,8 @@ readable(struct StringIO *ptr)
}
static struct StringIO*
-writable(struct StringIO *ptr)
+writable(ptr)
+ struct StringIO *ptr;
{
if (!WRITABLE(ptr)) {
rb_raise(rb_eIOError, "not opened for writing");
@@ -125,26 +127,97 @@ writable(struct StringIO *ptr)
}
static void
-check_modifiable(struct StringIO *ptr)
+check_modifiable(ptr)
+ struct StringIO *ptr;
{
if (OBJ_FROZEN(ptr->string)) {
rb_raise(rb_eIOError, "not modifiable string");
}
}
+static VALUE strio_s_allocate _((VALUE));
+static VALUE strio_s_open _((int, VALUE *, VALUE));
+static void strio_init _((int, VALUE *, struct StringIO *));
+static VALUE strio_initialize _((int, VALUE *, VALUE));
+static VALUE strio_finalize _((VALUE));
+static VALUE strio_self _((VALUE));
+static VALUE strio_false _((VALUE));
+static VALUE strio_nil _((VALUE));
+static VALUE strio_0 _((VALUE));
+static VALUE strio_first _((VALUE, VALUE));
+static VALUE strio_unimpl _((int, VALUE *, VALUE));
+static VALUE strio_get_string _((VALUE));
+static VALUE strio_set_string _((VALUE, VALUE));
+static VALUE strio_close _((VALUE));
+static VALUE strio_close_read _((VALUE));
+static VALUE strio_close_write _((VALUE));
+static VALUE strio_closed _((VALUE));
+static VALUE strio_closed_read _((VALUE));
+static VALUE strio_closed_write _((VALUE));
+static VALUE strio_eof _((VALUE));
+static VALUE strio_get_lineno _((VALUE));
+static VALUE strio_set_lineno _((VALUE, VALUE));
+static VALUE strio_get_pos _((VALUE));
+static VALUE strio_set_pos _((VALUE, VALUE));
+static VALUE strio_rewind _((VALUE));
+static VALUE strio_seek _((int, VALUE *, VALUE));
+static VALUE strio_get_sync _((VALUE));
+static VALUE strio_each_byte _((VALUE));
+static VALUE strio_each_char _((VALUE));
+static VALUE strio_getc _((VALUE));
+static VALUE strio_ungetc _((VALUE, VALUE));
+static VALUE strio_readchar _((VALUE));
+static VALUE strio_getline _((int, VALUE *, struct StringIO *));
+static VALUE strio_gets _((int, VALUE *, VALUE));
+static VALUE strio_readline _((int, VALUE *, VALUE));
+static VALUE strio_each _((int, VALUE *, VALUE));
+static VALUE strio_readlines _((int, VALUE *, VALUE));
+static VALUE strio_write _((VALUE, VALUE));
+static VALUE strio_putc _((VALUE, VALUE));
+static VALUE strio_read _((int, VALUE *, VALUE));
+static VALUE strio_size _((VALUE));
+static VALUE strio_truncate _((VALUE, VALUE));
+void Init_stringio _((void));
+
+/* Boyer-Moore search: copied from regex.c */
+static void bm_init_skip _((long *, const char *, long));
+static long bm_search _((const char *, long, const char *, long, const long *));
+
static VALUE
-strio_s_allocate(VALUE klass)
+strio_s_allocate(klass)
+ VALUE klass;
{
return Data_Wrap_Struct(klass, strio_mark, strio_free, 0);
}
/*
+ * call-seq: StringIO.open(string=""[, mode]) {|strio| ...}
+ *
+ * Equivalent to StringIO.new except that when it is called with a block, it
+ * yields with the new instance and closes it, and returns the result which
+ * returned from the block.
+ */
+static VALUE
+strio_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
+ if (!rb_block_given_p()) return obj;
+ return rb_ensure(rb_yield, obj, strio_finalize, obj);
+}
+
+/*
* call-seq: StringIO.new(string=""[, mode])
*
* Creates new StringIO instance from with _string_ and _mode_.
*/
static VALUE
-strio_initialize(int argc, VALUE *argv, VALUE self)
+strio_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
struct StringIO *ptr = check_strio(self);
@@ -157,7 +230,10 @@ strio_initialize(int argc, VALUE *argv, VALUE self)
}
static void
-strio_init(int argc, VALUE *argv, struct StringIO *ptr)
+strio_init(argc, argv, ptr)
+ int argc;
+ VALUE *argv;
+ struct StringIO *ptr;
{
VALUE string, mode;
int trunc = Qfalse;
@@ -196,7 +272,8 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr)
}
static VALUE
-strio_finalize(VALUE self)
+strio_finalize(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
ptr->string = Qnil;
@@ -205,25 +282,11 @@ strio_finalize(VALUE self)
}
/*
- * call-seq: StringIO.open(string=""[, mode]) {|strio| ...}
- *
- * Equivalent to StringIO.new except that when it is called with a block, it
- * yields with the new instance and closes it, and returns the result which
- * returned from the block.
- */
-static VALUE
-strio_s_open(int argc, VALUE *argv, VALUE klass)
-{
- VALUE obj = rb_class_new_instance(argc, argv, klass);
- if (!rb_block_given_p()) return obj;
- return rb_ensure(rb_yield, obj, strio_finalize, obj);
-}
-
-/*
* Returns +false+. Just for compatibility to IO.
*/
static VALUE
-strio_false(VALUE self)
+strio_false(self)
+ VALUE self;
{
StringIO(self);
return Qfalse;
@@ -233,7 +296,8 @@ strio_false(VALUE self)
* Returns +nil+. Just for compatibility to IO.
*/
static VALUE
-strio_nil(VALUE self)
+strio_nil(self)
+ VALUE self;
{
StringIO(self);
return Qnil;
@@ -243,7 +307,8 @@ strio_nil(VALUE self)
* Returns *strio* itself. Just for compatibility to IO.
*/
static VALUE
-strio_self(VALUE self)
+strio_self(self)
+ VALUE self;
{
StringIO(self);
return self;
@@ -253,7 +318,8 @@ strio_self(VALUE self)
* Returns 0. Just for compatibility to IO.
*/
static VALUE
-strio_0(VALUE self)
+strio_0(self)
+ VALUE self;
{
StringIO(self);
return INT2FIX(0);
@@ -263,7 +329,8 @@ strio_0(VALUE self)
* Returns the argument unchanged. Just for compatibility to IO.
*/
static VALUE
-strio_first(VALUE self, VALUE arg)
+strio_first(self, arg)
+ VALUE self, arg;
{
StringIO(self);
return arg;
@@ -273,7 +340,10 @@ strio_first(VALUE self, VALUE arg)
* Raises NotImplementedError.
*/
static VALUE
-strio_unimpl(int argc, VALUE *argv, VALUE self)
+strio_unimpl(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
StringIO(self);
rb_notimplement();
@@ -286,7 +356,8 @@ strio_unimpl(int argc, VALUE *argv, VALUE self)
* Returns underlying String object, the subject of IO.
*/
static VALUE
-strio_get_string(VALUE self)
+strio_get_string(self)
+ VALUE self;
{
return StringIO(self)->string;
}
@@ -298,7 +369,8 @@ strio_get_string(VALUE self)
* Changes underlying String object, the subject of IO.
*/
static VALUE
-strio_set_string(VALUE self, VALUE string)
+strio_set_string(self, string)
+ VALUE self, string;
{
struct StringIO *ptr = StringIO(self);
@@ -319,7 +391,8 @@ strio_set_string(VALUE self, VALUE string)
* operations; an +IOError+ is raised if such an attempt is made.
*/
static VALUE
-strio_close(VALUE self)
+strio_close(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
if (CLOSED(ptr)) {
@@ -337,7 +410,8 @@ strio_close(VALUE self)
* *strio* is not readable.
*/
static VALUE
-strio_close_read(VALUE self)
+strio_close_read(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
if (!READABLE(ptr)) {
@@ -355,7 +429,8 @@ strio_close_read(VALUE self)
* *strio* is not writeable.
*/
static VALUE
-strio_close_write(VALUE self)
+strio_close_write(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
if (!WRITABLE(ptr)) {
@@ -372,7 +447,8 @@ strio_close_write(VALUE self)
* Returns +true+ if *strio* is completely closed, +false+ otherwise.
*/
static VALUE
-strio_closed(VALUE self)
+strio_closed(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
if (!CLOSED(ptr)) return Qfalse;
@@ -386,7 +462,8 @@ strio_closed(VALUE self)
* Returns +true+ if *strio* is not readable, +false+ otherwise.
*/
static VALUE
-strio_closed_read(VALUE self)
+strio_closed_read(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
if (READABLE(ptr)) return Qfalse;
@@ -400,7 +477,8 @@ strio_closed_read(VALUE self)
* Returns +true+ if *strio* is not writable, +false+ otherwise.
*/
static VALUE
-strio_closed_write(VALUE self)
+strio_closed_write(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
if (WRITABLE(ptr)) return Qfalse;
@@ -416,16 +494,18 @@ strio_closed_write(VALUE self)
* opened for reading or an +IOError+ will be raised.
*/
static VALUE
-strio_eof(VALUE self)
+strio_eof(self)
+ VALUE self;
{
struct StringIO *ptr = readable(StringIO(self));
- if (ptr->pos < RSTRING_LEN(ptr->string)) return Qfalse;
+ if (ptr->pos < RSTRING(ptr->string)->len) return Qfalse;
return Qtrue;
}
/* :nodoc: */
static VALUE
-strio_copy(VALUE copy, VALUE orig)
+strio_copy(copy, orig)
+ VALUE copy, orig;
{
struct StringIO *ptr;
@@ -452,7 +532,8 @@ strio_copy(VALUE copy, VALUE orig)
* newline. See also the <code>$.</code> variable.
*/
static VALUE
-strio_get_lineno(VALUE self)
+strio_get_lineno(self)
+ VALUE self;
{
return LONG2NUM(StringIO(self)->lineno);
}
@@ -465,7 +546,8 @@ strio_get_lineno(VALUE self)
* <code>$.</code> is updated only on the next read.
*/
static VALUE
-strio_set_lineno(VALUE self, VALUE lineno)
+strio_set_lineno(self, lineno)
+ VALUE self, lineno;
{
StringIO(self)->lineno = NUM2LONG(lineno);
return lineno;
@@ -492,7 +574,10 @@ strio_set_lineno(VALUE self, VALUE lineno)
* and _mode_ (see StringIO#new).
*/
static VALUE
-strio_reopen(int argc, VALUE *argv, VALUE self)
+strio_reopen(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
if (!OBJ_TAINTED(self)) rb_secure(4);
if (argc == 1 && TYPE(*argv) != T_STRING) {
@@ -510,7 +595,8 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
* Returns the current offset (in bytes) of *strio*.
*/
static VALUE
-strio_get_pos(VALUE self)
+strio_get_pos(self)
+ VALUE self;
{
return LONG2NUM(StringIO(self)->pos);
}
@@ -522,7 +608,9 @@ strio_get_pos(VALUE self)
* Seeks to the given position (in bytes) in *strio*.
*/
static VALUE
-strio_set_pos(VALUE self, VALUE pos)
+strio_set_pos(self, pos)
+ VALUE self;
+ VALUE pos;
{
struct StringIO *ptr = StringIO(self);
long p = NUM2LONG(pos);
@@ -530,6 +618,7 @@ strio_set_pos(VALUE self, VALUE pos)
error_inval(0);
}
ptr->pos = p;
+ ptr->flags &= ~STRIO_EOF;
return pos;
}
@@ -541,11 +630,13 @@ strio_set_pos(VALUE self, VALUE pos)
* +lineno+ to zero.
*/
static VALUE
-strio_rewind(VALUE self)
+strio_rewind(self)
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
ptr->pos = 0;
ptr->lineno = 0;
+ ptr->flags &= ~STRIO_EOF;
return INT2FIX(0);
}
@@ -557,7 +648,10 @@ strio_rewind(VALUE self)
* the value of _whence_ (see IO#seek).
*/
static VALUE
-strio_seek(int argc, VALUE *argv, VALUE self)
+strio_seek(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE whence;
struct StringIO *ptr = StringIO(self);
@@ -575,7 +669,7 @@ strio_seek(int argc, VALUE *argv, VALUE self)
offset += ptr->pos;
break;
case 2:
- offset += RSTRING_LEN(ptr->string);
+ offset += RSTRING(ptr->string)->len;
break;
default:
error_inval("invalid whence");
@@ -584,6 +678,7 @@ strio_seek(int argc, VALUE *argv, VALUE self)
error_inval(0);
}
ptr->pos = offset;
+ ptr->flags &= ~STRIO_EOF;
return INT2FIX(0);
}
@@ -594,7 +689,8 @@ strio_seek(int argc, VALUE *argv, VALUE self)
* Returns +true+ always.
*/
static VALUE
-strio_get_sync(VALUE self)
+strio_get_sync(self)
+ VALUE self;
{
StringIO(self);
return Qtrue;
@@ -612,68 +708,53 @@ strio_get_sync(VALUE self)
* See IO#each_byte.
*/
static VALUE
-strio_each_byte(VALUE self)
+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++];
rb_yield(CHR2FIX(c));
}
- return Qnil;
+ return self;
}
/*
* call-seq:
- * strio.getc -> string or nil
+ * strio.getc -> fixnum or nil
*
* See IO#getc.
*/
static VALUE
-strio_getc(VALUE self)
-{
- struct StringIO *ptr = readable(StringIO(self));
- rb_encoding *enc = rb_enc_get(ptr->string);
- int len;
- char *p;
-
- if (ptr->pos >= RSTRING_LEN(ptr->string)) {
- return Qnil;
- }
- p = RSTRING_PTR(ptr->string)+ptr->pos;
- len = rb_enc_mbclen(p, RSTRING_END(ptr->string), enc);
- ptr->pos += len;
- return rb_enc_str_new(p, len, rb_enc_get(ptr->string));
-}
-
-/*
- * call-seq:
- * strio.getbyte -> fixnum or nil
- *
- * See IO#getbyte.
- */
-static VALUE
-strio_getbyte(VALUE self)
+strio_getc(self)
+ VALUE self;
{
struct StringIO *ptr = readable(StringIO(self));
int c;
- if (ptr->pos >= RSTRING_LEN(ptr->string)) {
+ if (ptr->pos >= RSTRING(ptr->string)->len) {
+ ptr->flags |= STRIO_EOF;
return Qnil;
}
- c = RSTRING_PTR(ptr->string)[ptr->pos++];
+ c = RSTRING(ptr->string)->ptr[ptr->pos++];
return CHR2FIX(c);
}
static void
-strio_extend(struct StringIO *ptr, long pos, long len)
+strio_extend(ptr, pos, len)
+ struct StringIO *ptr;
+ long pos, len;
{
long olen;
check_modifiable(ptr);
- olen = RSTRING_LEN(ptr->string);
+ olen = RSTRING(ptr->string)->len;
if (pos + len > olen) {
rb_str_resize(ptr->string, pos + len);
if (pos > olen)
- MEMZERO(RSTRING_PTR(ptr->string) + olen, char, pos - olen);
+ MEMZERO(RSTRING(ptr->string)->ptr + olen, char, pos - olen);
}
else {
rb_str_modify(ptr->string);
@@ -682,7 +763,7 @@ strio_extend(struct StringIO *ptr, long pos, long len)
/*
* call-seq:
- * strio.ungetc(string) -> nil
+ * strio.ungetc(integer) -> nil
*
* Pushes back one character (passed as a parameter) onto *strio*
* such that a subsequent buffered read will return it. Pushing back
@@ -691,37 +772,24 @@ strio_extend(struct StringIO *ptr, long pos, long len)
* In other case, there is no limitation for multiple pushbacks.
*/
static VALUE
-strio_ungetc(VALUE self, VALUE c)
+strio_ungetc(self, ch)
+ VALUE self, ch;
{
struct StringIO *ptr = readable(StringIO(self));
- long lpos, clen;
- char *p, *pend;
- rb_encoding *enc;
-
- if (NIL_P(c)) return Qnil;
- if (FIXNUM_P(c)) {
- int cc = FIX2INT(c);
- char buf[16];
-
- enc = rb_enc_get(ptr->string);
- rb_enc_mbcput(cc, buf, enc);
- c = rb_enc_str_new(buf, rb_enc_codelen(cc, enc), enc);
- }
- else {
- SafeStringValue(c);
- enc = rb_enc_check(ptr->string, c);
- }
- /* get logical position */
- lpos = 0; p = RSTRING_PTR(ptr->string); pend = p + ptr->pos - 1;
- for (;;) {
- clen = rb_enc_mbclen(p, pend, enc);
- if (p+clen >= pend) break;
- p += clen;
- lpos++;
+ int cc = NUM2INT(ch);
+ long len, pos = ptr->pos;
+
+ if (cc != EOF && pos > 0) {
+ if ((len = RSTRING(ptr->string)->len) < pos-- ||
+ (unsigned char)RSTRING(ptr->string)->ptr[pos] !=
+ (unsigned char)cc) {
+ strio_extend(ptr, pos, 1);
+ RSTRING(ptr->string)->ptr[pos] = cc;
+ OBJ_INFECT(ptr->string, self);
+ }
+ --ptr->pos;
+ ptr->flags &= ~STRIO_EOF;
}
- rb_str_update(ptr->string, lpos, ptr->pos ? 1 : 0, c);
- ptr->pos = p - RSTRING_PTR(ptr->string);
-
return Qnil;
}
@@ -732,7 +800,8 @@ strio_ungetc(VALUE self, VALUE c)
* See IO#readchar.
*/
static VALUE
-strio_readchar(VALUE self)
+strio_readchar(self)
+ VALUE self;
{
VALUE c = strio_getc(self);
if (NIL_P(c)) rb_eof_error();
@@ -741,21 +810,44 @@ strio_readchar(VALUE self)
/*
* call-seq:
- * strio.readbyte -> fixnum
+ * strio.each_char {|char| block } -> strio
*
- * See IO#readbyte.
+ * See IO#each_char.
*/
static VALUE
-strio_readbyte(VALUE self)
+strio_each_char(self)
+ VALUE self;
{
- VALUE c = strio_getbyte(self);
- if (NIL_P(c)) rb_eof_error();
- return c;
+ 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;
}
-/* Boyer-Moore search: copied from regex.c */
static void
-bm_init_skip(long *skip, const char *pat, long m)
+bm_init_skip(skip, pat, m)
+ long *skip;
+ const char *pat;
+ long m;
{
int c;
@@ -768,7 +860,12 @@ bm_init_skip(long *skip, const char *pat, long m)
}
static long
-bm_search(const char *little, long llen, const char *big, long blen, const long *skip)
+bm_search(little, llen, big, blen, skip)
+ const char *little;
+ long llen;
+ const char *big;
+ long blen;
+ const long *skip;
{
long i, j, k;
@@ -787,52 +884,38 @@ bm_search(const char *little, long llen, const char *big, long blen, const long
}
static VALUE
-strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
+strio_getline(argc, argv, ptr)
+ int argc;
+ VALUE *argv;
+ struct StringIO *ptr;
{
const char *s, *e, *p;
- long n, limit = 0;
+ long n;
VALUE str;
if (argc == 0) {
str = rb_rs;
}
else {
- VALUE lim, tmp;
-
- rb_scan_args(argc, argv, "11", &str, &lim);
- if (!NIL_P(lim)) limit = NUM2LONG(lim);
- else if (!NIL_P(str) && TYPE(str) != T_STRING) {
- tmp = rb_check_string_type(str);
- if (NIL_P(tmp)) {
- limit = NUM2LONG(str);
- if (limit == 0) return rb_str_new(0,0);
- str = rb_rs;
- }
- else {
- str = tmp;
- }
- }
- else {
- StringValue(str);
- }
+ rb_scan_args(argc, argv, "1", &str);
+ if (!NIL_P(str)) StringValue(str);
}
- if (ptr->pos >= (n = RSTRING_LEN(ptr->string))) {
+ if (ptr->pos >= (n = RSTRING(ptr->string)->len)) {
+ ptr->flags |= STRIO_EOF;
return Qnil;
}
- s = RSTRING_PTR(ptr->string);
- e = s + RSTRING_LEN(ptr->string);
+ s = RSTRING(ptr->string)->ptr;
+ e = s + RSTRING(ptr->string)->len;
s += ptr->pos;
- if (limit > 0 && s + limit < e) {
- e = s + limit;
- }
if (NIL_P(str)) {
- str = strio_substr(ptr, ptr->pos, e - s);
+ str = rb_str_substr(ptr->string, ptr->pos, e - s);
}
- else if ((n = RSTRING_LEN(str)) == 0) {
+ else if ((n = RSTRING(str)->len) == 0) {
p = s;
while (*p == '\n') {
if (++p == e) {
+ ptr->flags |= STRIO_EOF;
return Qnil;
}
}
@@ -843,19 +926,19 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
break;
}
}
- str = strio_substr(ptr, s - RSTRING_PTR(ptr->string), e - s);
+ str = rb_str_substr(ptr->string, s - RSTRING(ptr->string)->ptr, e - s);
}
else if (n == 1) {
- if ((p = memchr(s, RSTRING_PTR(str)[0], e - s)) != 0) {
+ if ((p = memchr(s, RSTRING(str)->ptr[0], e - s)) != 0) {
e = p + 1;
}
- str = strio_substr(ptr, ptr->pos, e - s);
+ str = rb_str_substr(ptr->string, ptr->pos, e - s);
}
else {
if (n < e - s) {
if (e - s < 1024) {
for (p = s; p + n <= e; ++p) {
- if (MEMCMP(p, RSTRING_PTR(str), char, n) == 0) {
+ if (MEMCMP(p, RSTRING(str)->ptr, char, n) == 0) {
e = p + n;
break;
}
@@ -863,30 +946,31 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
}
else {
long skip[1 << CHAR_BIT], pos;
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
bm_init_skip(skip, p, n);
if ((pos = bm_search(p, n, s, e - s, skip)) >= 0) {
e = s + pos + n;
}
}
}
- str = strio_substr(ptr, ptr->pos, e - s);
+ str = rb_str_substr(ptr->string, ptr->pos, e - s);
}
- ptr->pos = e - RSTRING_PTR(ptr->string);
+ ptr->pos = e - RSTRING(ptr->string)->ptr;
ptr->lineno++;
return str;
}
/*
* call-seq:
- * strio.gets(sep=$/) -> string or nil
- * strio.gets(limit) -> string or nil
- * strio.gets(sep, limit) -> string or nil
+ * strio.gets(sep_string=$/) -> string or nil
*
* See IO#gets.
*/
static VALUE
-strio_gets(int argc, VALUE *argv, VALUE self)
+strio_gets(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE str = strio_getline(argc, argv, readable(StringIO(self)));
@@ -896,37 +980,39 @@ strio_gets(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * strio.readline(sep=$/) -> string
- * strio.readline(limit) -> string or nil
- * strio.readline(sep, limit) -> string or nil
+ * strio.readline(sep_string=$/) -> string
*
* See IO#readline.
*/
static VALUE
-strio_readline(int argc, VALUE *argv, VALUE self)
+strio_readline(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- VALUE line = strio_getline(argc, argv, readable(StringIO(self)));
+ VALUE line = strio_gets(argc, argv, self);
if (NIL_P(line)) rb_eof_error();
return line;
}
/*
* call-seq:
- * strio.each(sep=$/) {|line| block } -> strio
- * strio.each(limit) {|line| block } -> strio
- * strio.each(sep, limit) {|line| block } -> strio
- * strio.each_line(sep=$/) {|line| block } -> strio
- * strio.each_line(limit) {|line| block } -> strio
- * strio.each_line(sep,limit) {|line| block } -> strio
+ * strio.each(sep_string=$/) {|line| block } -> strio
+ * strio.each_line(sep_string=$/) {|line| block } -> strio
*
* See IO#each.
*/
static VALUE
-strio_each(int argc, VALUE *argv, VALUE self)
+strio_each(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE 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);
}
@@ -935,14 +1021,15 @@ strio_each(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * strio.readlines(sep=$/) -> array
- * strio.readlines(limit) -> array
- * strio.readlines(sep,limit) -> array
+ * strio.readlines(sep_string=$/) -> array
*
* See IO#readlines.
*/
static VALUE
-strio_readlines(int argc, VALUE *argv, VALUE self)
+strio_readlines(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
struct StringIO *ptr = StringIO(self);
VALUE ary = rb_ary_new(), line;
@@ -963,27 +1050,27 @@ strio_readlines(int argc, VALUE *argv, VALUE self)
* Returns the number of bytes written. See IO#write.
*/
static VALUE
-strio_write(VALUE self, VALUE str)
+strio_write(self, str)
+ VALUE self, str;
{
struct StringIO *ptr = writable(StringIO(self));
long len, olen;
if (TYPE(str) != T_STRING)
str = rb_obj_as_string(str);
- len = RSTRING_LEN(str);
- if (len == 0) return INT2FIX(0);
+ len = RSTRING(str)->len;
+ if (!len) return INT2FIX(0);
check_modifiable(ptr);
- olen = RSTRING_LEN(ptr->string);
+ olen = RSTRING(ptr->string)->len;
if (ptr->flags & FMODE_APPEND) {
ptr->pos = olen;
}
if (ptr->pos == olen) {
- rb_str_cat(ptr->string, RSTRING_PTR(str), len);
+ rb_str_cat(ptr->string, RSTRING(str)->ptr, len);
}
else {
strio_extend(ptr, ptr->pos, len);
- memmove(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_PTR(str), len);
- OBJ_INFECT(ptr->string, str);
+ rb_str_update(ptr->string, ptr->pos, len, str);
}
OBJ_INFECT(ptr->string, self);
ptr->pos += len;
@@ -1022,19 +1109,20 @@ strio_write(VALUE self, VALUE str)
* See IO#putc.
*/
static VALUE
-strio_putc(VALUE self, VALUE ch)
+strio_putc(self, ch)
+ VALUE self, ch;
{
struct StringIO *ptr = writable(StringIO(self));
int c = NUM2CHR(ch);
long olen;
check_modifiable(ptr);
- olen = RSTRING_LEN(ptr->string);
+ olen = RSTRING(ptr->string)->len;
if (ptr->flags & FMODE_APPEND) {
ptr->pos = olen;
}
strio_extend(ptr, ptr->pos, 1);
- RSTRING_PTR(ptr->string)[ptr->pos++] = c;
+ RSTRING(ptr->string)->ptr[ptr->pos++] = c;
OBJ_INFECT(ptr->string, self);
return ch;
}
@@ -1054,7 +1142,10 @@ strio_putc(VALUE self, VALUE ch)
* See IO#read.
*/
static VALUE
-strio_read(int argc, VALUE *argv, VALUE self)
+strio_read(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
struct StringIO *ptr = readable(StringIO(self));
VALUE str = Qnil;
@@ -1071,7 +1162,12 @@ strio_read(int argc, VALUE *argv, VALUE self)
if (len < 0) {
rb_raise(rb_eArgError, "negative length %ld given", len);
}
- if (len > 0 && ptr->pos >= RSTRING_LEN(ptr->string)) {
+ if (len > 0 && ptr->pos >= RSTRING(ptr->string)->len) {
+ ptr->flags |= STRIO_EOF;
+ if (!NIL_P(str)) rb_str_resize(str, 0);
+ return Qnil;
+ }
+ else if (ptr->flags & STRIO_EOF) {
if (!NIL_P(str)) rb_str_resize(str, 0);
return Qnil;
}
@@ -1080,8 +1176,9 @@ strio_read(int argc, VALUE *argv, VALUE self)
/* fall through */
case 0:
olen = -1;
- len = RSTRING_LEN(ptr->string);
+ len = RSTRING(ptr->string)->len;
if (len <= ptr->pos) {
+ ptr->flags |= STRIO_EOF;
if (NIL_P(str)) {
str = rb_str_new(0, 0);
}
@@ -1098,21 +1195,22 @@ strio_read(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
if (NIL_P(str)) {
- str = strio_substr(ptr, ptr->pos, len);
+ str = rb_str_substr(ptr->string, ptr->pos, len);
}
else {
- long rest = RSTRING_LEN(ptr->string) - ptr->pos;
+ long rest = RSTRING(ptr->string)->len - ptr->pos;
if (len > rest) len = rest;
rb_str_resize(str, len);
- MEMCPY(RSTRING_PTR(str), RSTRING_PTR(ptr->string) + ptr->pos, char, len);
+ MEMCPY(RSTRING(str)->ptr, RSTRING(ptr->string)->ptr + ptr->pos, char, len);
}
if (NIL_P(str)) {
- str = rb_str_new(0, 0);
+ if (!(ptr->flags & STRIO_EOF)) str = rb_str_new(0, 0);
len = 0;
}
else {
- ptr->pos += len = RSTRING_LEN(str);
+ ptr->pos += len = RSTRING(str)->len;
}
+ if (olen < 0 || olen > len) ptr->flags |= STRIO_EOF;
return str;
}
@@ -1124,10 +1222,13 @@ strio_read(int argc, VALUE *argv, VALUE self)
* returning +nil+, as well as IO#sysread does.
*/
static VALUE
-strio_sysread(int argc, VALUE *argv, VALUE self)
+strio_sysread(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE val = strio_read(argc, argv, self);
- if (NIL_P(val) || RSTRING_LEN(val) == 0) {
+ if (NIL_P(val) || RSTRING(val)->len == 0) {
rb_eof_error();
}
return val;
@@ -1159,13 +1260,14 @@ strio_sysread(int argc, VALUE *argv, VALUE self)
* Returns the size of the buffer string.
*/
static VALUE
-strio_size(VALUE self)
+strio_size(self)
+ VALUE self;
{
VALUE string = StringIO(self)->string;
if (NIL_P(string)) {
rb_raise(rb_eIOError, "not opened");
}
- return ULONG2NUM(RSTRING_LEN(string));
+ return ULONG2NUM(RSTRING(string)->len);
}
/*
@@ -1176,17 +1278,18 @@ strio_size(VALUE self)
* must be opened for writing.
*/
static VALUE
-strio_truncate(VALUE self, VALUE len)
+strio_truncate(self, len)
+ VALUE self, len;
{
VALUE string = writable(StringIO(self))->string;
long l = NUM2LONG(len);
- long plen = RSTRING_LEN(string);
+ long plen = RSTRING(string)->len;
if (l < 0) {
error_inval("negative legnth");
}
rb_str_resize(string, l);
if (plen < l) {
- MEMZERO(RSTRING_PTR(string) + plen, char, l - plen);
+ MEMZERO(RSTRING(string)->ptr + plen, char, l - plen);
}
return len;
}
@@ -1233,19 +1336,22 @@ Init_stringio()
rb_define_method(StringIO, "path", strio_path, 0);
rb_define_method(StringIO, "each", strio_each, -1);
- rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
rb_define_method(StringIO, "each_line", strio_each, -1);
+ rb_define_method(StringIO, "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, "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, "getbyte", strio_getbyte, 0);
- rb_define_method(StringIO, "readbyte", strio_readbyte, 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);
rb_define_method(StringIO, "read", strio_read, -1);
rb_define_method(StringIO, "sysread", strio_sysread, -1);
- rb_define_method(StringIO, "readpartial", strio_sysread, -1);
rb_define_method(StringIO, "write", strio_write, 1);
rb_define_method(StringIO, "<<", strio_addstr, 1);
diff --git a/ext/strscan/.cvsignore b/ext/strscan/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/strscan/.cvsignore
+++ b/ext/strscan/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/strscan/depend b/ext/strscan/depend
index 76f6e0b18b..9199574c3f 100644
--- a/ext/strscan/depend
+++ b/ext/strscan/depend
@@ -1,2 +1 @@
-strscan.o: strscan.c $(hdrdir)/ruby.h $(hdrdir)/re.h $(hdrdir)/regex.h \
- $(hdrdir)/oniguruma.h $(topdir)/config.h $(hdrdir)/defines.h
+strscan.o: strscan.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index fc4a7cf4e1..b5ee20282c 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -8,9 +8,8 @@
the Ruby License. For details, see the file COPYING.
*/
-#include "ruby/ruby.h"
-#include "ruby/re.h"
-#include "ruby/encoding.h"
+#include "ruby.h"
+#include "re.h"
#define STRSCAN_VERSION "0.7.0"
@@ -42,13 +41,13 @@ struct strscanner
#define MATCHED(s) (s)->flags |= FLAG_MATCHED
#define CLEAR_MATCH_STATUS(s) (s)->flags &= ~FLAG_MATCHED
-#define S_PBEG(s) (RSTRING_PTR((s)->str))
-#define S_LEN(s) (RSTRING_LEN((s)->str))
+#define S_PBEG(s) (RSTRING((s)->str)->ptr)
+#define S_LEN(s) (RSTRING((s)->str)->len)
#define S_PEND(s) (S_PBEG(s) + S_LEN(s))
#define CURPTR(s) (S_PBEG(s) + (s)->curr)
#define S_RESTLEN(s) (S_LEN(s) - (s)->curr)
-#define EOS_P(s) ((s)->curr >= RSTRING_LEN(p->str))
+#define EOS_P(s) ((s)->curr >= RSTRING(p->str)->len)
#define GET_SCANNER(obj,var) do {\
Data_Get_Struct(obj, struct strscanner, var);\
@@ -63,7 +62,7 @@ static VALUE infect _((VALUE str, struct strscanner *p));
static VALUE extract_range _((struct strscanner *p, long beg_i, long end_i));
static VALUE extract_beg_len _((struct strscanner *p, long beg_i, long len));
-void check_strscan _((VALUE obj));
+static void check_strscan _((VALUE obj));
static void strscan_mark _((struct strscanner *p));
static void strscan_free _((struct strscanner *p));
static VALUE strscan_s_allocate _((VALUE klass));
@@ -157,7 +156,7 @@ strscan_mark(struct strscanner *p)
static void
strscan_free(struct strscanner *p)
{
- onig_region_free(&(p->regs), 0);
+ re_free_registers(&(p->regs));
free(p);
}
@@ -169,7 +168,7 @@ strscan_s_allocate(VALUE klass)
p = ALLOC(struct strscanner);
MEMZERO(p, struct strscanner, 1);
CLEAR_MATCH_STATUS(p);
- onig_region_init(&(p->regs));
+ MEMZERO(&(p->regs), struct re_registers, 1);
p->str = Qnil;
return Data_Wrap_Struct(klass, strscan_mark, strscan_free, p);
}
@@ -194,7 +193,7 @@ strscan_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
-void
+static void
check_strscan(VALUE obj)
{
if (TYPE(obj) != T_DATA || RDATA(obj)->dmark != (RUBY_DATA_FUNC)strscan_mark) {
@@ -220,13 +219,12 @@ strscan_init_copy(VALUE vself, VALUE vorig)
check_strscan(vorig);
Data_Get_Struct(vorig, struct strscanner, orig);
if (self != orig) {
- self->flags = orig->flags;
- self->str = orig->str;
- self->prev = orig->prev;
- self->curr = orig->curr;
- onig_region_copy(&self->regs, &orig->regs);
+ self->flags = orig->flags;
+ self->str = orig->str;
+ self->prev = orig->prev;
+ self->curr = orig->curr;
+ re_copy_registers(&self->regs, &orig->regs);
}
-
return vself;
}
@@ -405,17 +403,21 @@ 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 = onig_match(RREGEXP(regex)->ptr, (UChar* )CURPTR(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p), &(p->regs), ONIG_OPTION_NONE);
+ ret = re_match(RREGEXP(regex)->ptr,
+ CURPTR(p), S_RESTLEN(p),
+ 0,
+ &(p->regs));
}
else {
- ret = onig_search(RREGEXP(regex)->ptr,
- (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- &(p->regs), ONIG_OPTION_NONE);
+ ret = re_search(RREGEXP(regex)->ptr,
+ CURPTR(p), S_RESTLEN(p),
+ 0,
+ S_RESTLEN(p),
+ &(p->regs));
}
+ rb_kcode_reset_option();
if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
if (ret < 0) {
@@ -534,6 +536,7 @@ strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f)
return strscan_do_scan(self, re, RTEST(s), RTEST(f), 1);
}
+
/*
* call-seq: scan_until(pattern)
*
@@ -627,18 +630,26 @@ strscan_search_full(VALUE self, VALUE re, VALUE s, VALUE f)
return strscan_do_scan(self, re, RTEST(s), RTEST(f), 0);
}
+/* DANGEROUS; need to synchronize with regex.c */
static void
adjust_registers_to_matched(struct strscanner *p)
{
- onig_region_clear(&(p->regs));
- onig_region_set(&(p->regs), 0, 0, p->curr - p->prev);
+ if (p->regs.allocated == 0) {
+ p->regs.beg = ALLOC_N(int, RE_NREGS);
+ p->regs.end = ALLOC_N(int, RE_NREGS);
+ p->regs.allocated = RE_NREGS;
+ }
+ p->regs.num_regs = 1;
+ p->regs.beg[0] = 0;
+ p->regs.end[0] = p->curr - p->prev;
}
/*
* Scans one character and returns it.
- * This method is multibyte character sensitive.
+ * This method is multi-byte character sensitive.
+ * See also #get_byte.
*
- * s = StringScanner.new("ab")
+ * s = StringScanner.new('ab')
* s.getch # => "a"
* s.getch # => "b"
* s.getch # => nil
@@ -658,8 +669,7 @@ strscan_getch(VALUE self)
CLEAR_MATCH_STATUS(p);
if (EOS_P(p))
return Qnil;
-
- len = rb_enc_mbclen(CURPTR(p), S_PEND(p), rb_enc_get(p->str));
+ len = mbclen(*CURPTR(p));
if (p->curr + len > S_LEN(p)) {
len = S_LEN(p) - p->curr;
}
@@ -673,15 +683,14 @@ strscan_getch(VALUE self)
/*
* Scans one byte and returns it.
- * This method is not multibyte character sensitive.
- * See also: #getch.
+ * This method is NOT multi-byte character sensitive.
+ * See also #getch.
*
* s = StringScanner.new('ab')
* s.get_byte # => "a"
* s.get_byte # => "b"
* s.get_byte # => nil
*
- * $KCODE = 'EUC'
* s = StringScanner.new("\244\242")
* s.get_byte # => "\244"
* s.get_byte # => "\242"
@@ -694,9 +703,9 @@ strscan_get_byte(VALUE self)
GET_SCANNER(self, p);
CLEAR_MATCH_STATUS(p);
- if (EOS_P(p))
+ if (EOS_P(p)) {
return Qnil;
-
+ }
p->prev = p->curr;
p->curr++;
MATCHED(p);
@@ -734,13 +743,13 @@ strscan_peek(VALUE self, VALUE vlen)
long len;
GET_SCANNER(self, p);
-
len = NUM2LONG(vlen);
- if (EOS_P(p))
+ if (EOS_P(p)) {
return infect(rb_str_new("", 0), p);
-
- if (p->curr + len > S_LEN(p))
+ }
+ if (p->curr + len > S_LEN(p)) {
len = S_LEN(p) - p->curr;
+ }
return extract_beg_len(p, p->curr, len);
}
@@ -764,7 +773,7 @@ strscan_peep(VALUE self, VALUE vlen)
* s.unscan
* s.scan(/../) # => "te"
* s.scan(/\d/) # => nil
- * s.unscan # ScanError: unscan failed: previous match record not exist
+ * s.unscan # ScanError: unscan failed: previous match had failed
*/
static VALUE
strscan_unscan(VALUE self)
@@ -772,8 +781,9 @@ strscan_unscan(VALUE self)
struct strscanner *p;
GET_SCANNER(self, p);
- if (! MATCHED_P(p))
- rb_raise(ScanError, "unscan failed: previous match record not exist");
+ if (! MATCHED_P(p)) {
+ rb_raise(ScanError, "unscan failed: previous match had failed");
+ }
p->curr = p->prev;
CLEAR_MATCH_STATUS(p);
return self;
@@ -881,6 +891,7 @@ strscan_matched(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
+
return extract_range(p, p->prev + p->regs.beg[0],
p->prev + p->regs.end[0]);
}
@@ -902,6 +913,7 @@ strscan_matched_size(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
+
return INT2NUM(p->regs.end[0] - p->regs.beg[0]);
}
@@ -966,6 +978,7 @@ strscan_pre_match(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
+
return extract_range(p, 0, p->prev + p->regs.beg[0]);
}
@@ -985,6 +998,7 @@ strscan_post_match(VALUE self)
GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil;
+
return extract_range(p, p->prev + p->regs.end[0], S_LEN(p));
}
@@ -1017,6 +1031,7 @@ strscan_rest_size(VALUE self)
if (EOS_P(p)) {
return INT2FIX(0);
}
+
i = S_LEN(p) - p->curr;
return INT2FIX(i);
}
@@ -1070,7 +1085,7 @@ strscan_inspect(VALUE self)
len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld @ %s>",
rb_class2name(CLASS_OF(self)),
p->curr, S_LEN(p),
- RSTRING_PTR(b));
+ RSTRING(b)->ptr);
return infect(rb_str_new(buf, len), p);
}
a = inspect1(p);
@@ -1078,8 +1093,8 @@ strscan_inspect(VALUE self)
len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld %s @ %s>",
rb_class2name(CLASS_OF(self)),
p->curr, S_LEN(p),
- RSTRING_PTR(a),
- RSTRING_PTR(b));
+ RSTRING(a)->ptr,
+ RSTRING(b)->ptr);
return infect(rb_str_new(buf, len), p);
}
@@ -1230,7 +1245,7 @@ inspect2(struct strscanner *p)
* There are aliases to several of the methods.
*/
void
-Init_strscan()
+Init_strscan(void)
{
ID id_scanerr = rb_intern("ScanError");
VALUE tmp;
diff --git a/ext/syck/.cvsignore b/ext/syck/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/syck/.cvsignore
+++ b/ext/syck/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/syck/bytecode.c b/ext/syck/bytecode.c
index 314ef229fe..567aaf52a8 100644
--- a/ext/syck/bytecode.c
+++ b/ext/syck/bytecode.c
@@ -8,7 +8,7 @@
*
* Copyright (C) 2003 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "syck.h"
#include "gram.h"
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
index cadee64789..9c8ab8d49b 100644
--- a/ext/syck/emitter.c
+++ b/ext/syck/emitter.c
@@ -7,9 +7,9 @@
* Copyright (C) 2003 why the lucky stiff
*
* All Base64 code from Ruby's pack.c.
- * Ruby is Copyright (C) 1993-2007 Yukihiro Matsumoto
+ * Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <stdio.h>
#include <string.h>
@@ -98,7 +98,7 @@ syck_base64dec( char *s, long len )
}
}
*end = '\0';
- /*RSTRING_LEN(buf) = ptr - RSTRING_PTR(buf);*/
+ /*RSTRING(buf)->len = ptr - RSTRING(buf)->ptr;*/
return ptr;
}
@@ -106,7 +106,7 @@ syck_base64dec( char *s, long len )
* Allocate an emitter
*/
SyckEmitter *
-syck_new_emitter(void)
+syck_new_emitter()
{
SyckEmitter *e;
e = S_ALLOC( SyckEmitter );
@@ -282,7 +282,7 @@ syck_emitter_clear( SyckEmitter *e )
* Raw write to the emitter buffer.
*/
void
-syck_emitter_write( SyckEmitter *e, const char *str, long len )
+syck_emitter_write( SyckEmitter *e, char *str, long len )
{
long at;
ASSERT( str != NULL )
@@ -438,7 +438,7 @@ end_emit:
* and the implicit tag which would be assigned to this node. If a tag is
* required, write the tag.
*/
-void syck_emit_tag( SyckEmitter *e, const char *tag, const char *ignore )
+void syck_emit_tag( SyckEmitter *e, char *tag, char *ignore )
{
SyckLevel *lvl;
if ( tag == NULL ) return;
@@ -457,7 +457,7 @@ void syck_emit_tag( SyckEmitter *e, const char *tag, const char *ignore )
int skip = 4 + strlen( YAML_DOMAIN ) + 1;
syck_emitter_write( e, tag + skip, taglen - skip );
} else {
- const char *subd = tag + 4;
+ char *subd = tag + 4;
while ( *subd != ':' && *subd != '\0' ) subd++;
if ( *subd == ':' ) {
if ( subd - tag > ( strlen( YAML_DOMAIN ) + 5 ) &&
@@ -786,8 +786,8 @@ syck_emitter_escape( SyckEmitter *e, char *src, long len )
else
{
syck_emitter_write( e, "x", 1 );
- syck_emitter_write( e, (const char *)hex_table + ((src[i] & 0xF0) >> 4), 1 );
- syck_emitter_write( e, (const char *)hex_table + (src[i] & 0x0F), 1 );
+ syck_emitter_write( e, (char *)hex_table + ((src[i] & 0xF0) >> 4), 1 );
+ syck_emitter_write( e, (char *)hex_table + (src[i] & 0x0F), 1 );
}
}
else
@@ -1221,7 +1221,7 @@ syck_emitter_mark_node( SyckEmitter *e, st_data_t n )
if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
{
int idx = 0;
- const char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
+ char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
/*
* Second time hitting this object, let's give it an anchor
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
index 3ff1a4e440..56fe838fbd 100644
--- a/ext/syck/handler.c
+++ b/ext/syck/handler.c
@@ -7,7 +7,7 @@
* Copyright (C) 2003 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "syck.h"
SYMID
@@ -155,7 +155,7 @@ syck_xprivate( char *type_id, int type_len )
}
char *
-syck_taguri( const char *domain, const char *type_id, int type_len )
+syck_taguri( char *domain, char *type_id, int type_len )
{
char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
uri[0] = '\0';
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c
index df32d9194b..d356faf7d9 100644
--- a/ext/syck/implicit.c
+++ b/ext/syck/implicit.c
@@ -9,7 +9,7 @@
* Copyright (C) 2003 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "syck.h"
#define YYCTYPE char
@@ -1585,7 +1585,7 @@ yy201: ++YYCURSOR;
/* Remove ending fragment and compare types */
int
-syck_tagcmp( const char *tag1, const char *tag2 )
+syck_tagcmp( char *tag1, char *tag2 )
{
if ( tag1 == tag2 ) return 1;
if ( tag1 == NULL || tag2 == NULL ) return 0;
diff --git a/ext/syck/node.c b/ext/syck/node.c
index 99cc9c7515..28fc78c077 100644
--- a/ext/syck/node.c
+++ b/ext/syck/node.c
@@ -7,7 +7,7 @@
* Copyright (C) 2003 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "syck.h"
/*
@@ -46,7 +46,7 @@ syck_free_node( SyckNode *n )
}
SyckNode *
-syck_alloc_map(void)
+syck_alloc_map()
{
SyckNode *n;
struct SyckMap *m;
@@ -65,7 +65,7 @@ syck_alloc_map(void)
}
SyckNode *
-syck_alloc_seq(void)
+syck_alloc_seq()
{
SyckNode *n;
struct SyckSeq *s;
@@ -83,7 +83,7 @@ syck_alloc_seq(void)
}
SyckNode *
-syck_alloc_str(void)
+syck_alloc_str()
{
SyckNode *n;
struct SyckStr *s;
@@ -100,13 +100,13 @@ syck_alloc_str(void)
}
SyckNode *
-syck_new_str( const char *str, enum scalar_style style )
+syck_new_str( char *str, enum scalar_style style )
{
return syck_new_str2( str, strlen( str ), style );
}
SyckNode *
-syck_new_str2( const char *str, long len, enum scalar_style style )
+syck_new_str2( char *str, long len, enum scalar_style style )
{
SyckNode *n;
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 2e3b163e63..76e8279601 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -8,7 +8,7 @@
* Copyright (C) 2003-2005 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "syck.h"
#include <sys/types.h>
#include <time.h>
@@ -49,8 +49,8 @@ typedef struct {
/*
* symbols and constants
*/
-static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver, s_each;
-static ID s_tags, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set;
+static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver;
+static ID s_tags, s_domain, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set;
static VALUE sym_model, sym_generic, sym_input, sym_bytecode;
static VALUE sym_scalar, sym_seq, sym_map;
static VALUE sym_1quote, sym_2quote, sym_fold, sym_literal, sym_plain, sym_inline;
@@ -60,10 +60,10 @@ static VALUE oDefaultResolver, oGenericResolver;
/*
* my private collection of numerical oddities.
*/
-static double S_zero(void) { return 0.0; }
-static double S_one(void) { return 1.0; }
-static double S_inf(void) { return S_one() / S_zero(); }
-static double S_nan(void) { return S_zero() / S_zero(); }
+static double S_zero() { return 0.0; }
+static double S_one() { return 1.0; }
+static double S_inf() { return S_one() / S_zero(); }
+static double S_nan() { return S_zero() / S_zero(); }
static VALUE syck_node_transform( VALUE );
@@ -97,7 +97,8 @@ struct emitter_xtra {
* Convert YAML to bytecode
*/
VALUE
-rb_syck_compile(VALUE self, VALUE port)
+rb_syck_compile(self, port)
+ VALUE self, port;
{
SYMID oid;
int taint;
@@ -149,8 +150,8 @@ rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
if (!NIL_P(str2))
{
StringValue(str2);
- len = RSTRING_LEN(str2);
- memcpy( buf + skip, RSTRING_PTR(str2), len );
+ len = RSTRING(str2)->len;
+ memcpy( buf + skip, RSTRING(str2)->ptr, len );
}
}
len += skip;
@@ -163,14 +164,16 @@ rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
* (returns tainted? boolean)
*/
int
-syck_parser_assign_io(SyckParser *parser, VALUE *pport)
+syck_parser_assign_io(parser, pport)
+ SyckParser *parser;
+ VALUE *pport;
{
int taint = Qtrue;
VALUE tmp, port = *pport;
if (!NIL_P(tmp = rb_check_string_type(port))) {
taint = OBJ_TAINTED(port); /* original taintedness */
port = tmp;
- syck_parser_str( parser, RSTRING_PTR(port), RSTRING_LEN(port), NULL );
+ syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
}
else if (rb_respond_to(port, s_read)) {
if (rb_respond_to(port, s_binmode)) {
@@ -189,7 +192,8 @@ syck_parser_assign_io(SyckParser *parser, VALUE *pport)
* Get value in hash by key, forcing an empty hash if nil.
*/
VALUE
-syck_get_hash_aref(VALUE hsh, VALUE key)
+syck_get_hash_aref(hsh, key)
+ VALUE hsh, key;
{
VALUE val = rb_hash_aref( hsh, key );
if ( NIL_P( val ) )
@@ -204,7 +208,9 @@ syck_get_hash_aref(VALUE hsh, VALUE key)
* creating timestamps
*/
SYMID
-rb_syck_mktime(char *str, long len)
+rb_syck_mktime(str, len)
+ char *str;
+ long len;
{
VALUE time;
char *ptr = str;
@@ -313,7 +319,8 @@ rb_syck_mktime(char *str, long len)
* (see http://www.yaml.org/type/merge/)
*/
VALUE
-syck_merge_i(VALUE entry, VALUE hsh )
+syck_merge_i( entry, hsh )
+ VALUE entry, hsh;
{
VALUE tmp;
if ( !NIL_P(tmp = rb_check_convert_type(entry, T_HASH, "Hash", "to_hash")) )
@@ -328,7 +335,9 @@ syck_merge_i(VALUE entry, VALUE hsh )
* default handler for ruby.yaml.org types
*/
int
-yaml_org_handler( SyckNode *n, VALUE *ref )
+yaml_org_handler( n, ref )
+ SyckNode *n;
+ VALUE *ref;
{
char *type_id = n->type_id;
int transferred = 0;
@@ -566,7 +575,7 @@ yaml_org_handler( SyckNode *n, VALUE *ref )
VALUE dup = rb_funcall( tmph, s_dup, 0 );
tmp = rb_ary_reverse( tmp );
rb_ary_push( tmp, obj );
- rb_block_call( tmp, s_each, 0, 0, syck_merge_i, dup );
+ rb_iterate( rb_each, tmp, syck_merge_i, dup );
obj = dup;
skip_aset = 1;
}
@@ -597,7 +606,9 @@ static void syck_node_mark( SyckNode *n );
* - Converts data into native Ruby types
*/
SYMID
-rb_syck_load_handler(SyckParser *p, SyckNode *n)
+rb_syck_load_handler(p, n)
+ SyckParser *p;
+ SyckNode *n;
{
VALUE obj = Qnil;
struct parser_xtra *bonus = (struct parser_xtra *)p->bonus;
@@ -625,7 +636,7 @@ rb_syck_load_handler(SyckParser *p, SyckNode *n)
if ( bonus->taint) OBJ_TAINT( obj );
if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
- rb_hash_aset(bonus->data, INT2FIX(RHASH_SIZE(bonus->data)), obj);
+ rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
return obj;
}
@@ -633,7 +644,9 @@ rb_syck_load_handler(SyckParser *p, SyckNode *n)
* friendly errors.
*/
void
-rb_syck_err_handler(SyckParser *p, char *msg)
+rb_syck_err_handler(p, msg)
+ SyckParser *p;
+ char *msg;
{
char *endl = p->cursor;
@@ -652,7 +665,9 @@ rb_syck_err_handler(SyckParser *p, char *msg)
* provide bad anchor object to the parser.
*/
SyckNode *
-rb_syck_bad_anchor_handler(SyckParser *p, char *a)
+rb_syck_bad_anchor_handler(p, a)
+ SyckParser *p;
+ char *a;
{
VALUE anchor_name = rb_str_new2( a );
SyckNode *badanc = syck_new_map( rb_str_new2( "name" ), anchor_name );
@@ -664,7 +679,8 @@ rb_syck_bad_anchor_handler(SyckParser *p, char *a)
* data loaded based on the model requested.
*/
void
-syck_set_model(VALUE p, VALUE input, VALUE model)
+syck_set_model( p, input, model )
+ VALUE p, input, model;
{
SyckParser *parser;
Data_Get_Struct(p, SyckParser, parser);
@@ -704,7 +720,8 @@ syck_st_mark_nodes( char *key, SyckNode *n, char *arg )
* mark parser nodes
*/
static void
-syck_mark_parser(SyckParser *parser)
+syck_mark_parser(parser)
+ SyckParser *parser;
{
struct parser_xtra *bonus = (struct parser_xtra *)parser->bonus;
rb_gc_mark_maybe(parser->root);
@@ -727,7 +744,8 @@ syck_mark_parser(SyckParser *parser)
* Free the parser and any bonus attachment.
*/
void
-rb_syck_free_parser(SyckParser *p)
+rb_syck_free_parser(p)
+ SyckParser *p;
{
S_FREE( p->bonus );
syck_free_parser(p);
@@ -738,7 +756,8 @@ rb_syck_free_parser(SyckParser *p)
*/
VALUE syck_parser_s_alloc _((VALUE));
VALUE
-syck_parser_s_alloc(VALUE class)
+syck_parser_s_alloc(class)
+ VALUE class;
{
VALUE pobj;
SyckParser *parser = syck_new_parser();
@@ -757,7 +776,10 @@ syck_parser_s_alloc(VALUE class)
* YAML::Syck::Parser.initialize( resolver, options )
*/
static VALUE
-syck_parser_initialize(int argc, VALUE *argv, VALUE self)
+syck_parser_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE options;
if (rb_scan_args(argc, argv, "01", &options) == 0)
@@ -777,7 +799,8 @@ syck_parser_initialize(int argc, VALUE *argv, VALUE self)
* YAML::Syck::Parser.bufsize = Integer
*/
static VALUE
-syck_parser_bufsize_set(VALUE self, VALUE size)
+syck_parser_bufsize_set( self, size )
+ VALUE self, size;
{
SyckParser *parser;
@@ -793,7 +816,8 @@ syck_parser_bufsize_set(VALUE self, VALUE size)
* YAML::Syck::Parser.bufsize => Integer
*/
static VALUE
-syck_parser_bufsize_get(VALUE self)
+syck_parser_bufsize_get( self )
+ VALUE self;
{
SyckParser *parser;
@@ -805,7 +829,10 @@ syck_parser_bufsize_get(VALUE self)
* YAML::Syck::Parser.load( IO or String )
*/
VALUE
-syck_parser_load(int argc, VALUE *argv, VALUE self)
+syck_parser_load(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE port, proc, model, input;
SyckParser *parser;
@@ -832,7 +859,10 @@ syck_parser_load(int argc, VALUE *argv, VALUE self)
* YAML::Syck::Parser.load_documents( IO or String ) { |doc| }
*/
VALUE
-syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
+syck_parser_load_documents(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE port, proc, v, input, model;
SyckParser *parser;
@@ -873,7 +903,8 @@ syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
* YAML::Syck::Parser#set_resolver
*/
VALUE
-syck_parser_set_resolver(VALUE self, VALUE resolver)
+syck_parser_set_resolver( self, resolver )
+ VALUE self, resolver;
{
rb_ivar_set( self, s_resolver, resolver );
return self;
@@ -883,9 +914,9 @@ syck_parser_set_resolver(VALUE self, VALUE resolver)
* YAML::Syck::Resolver.initialize
*/
static VALUE
-syck_resolver_initialize(VALUE self)
+syck_resolver_initialize( self )
+ VALUE self;
{
- VALUE tags = rb_hash_new();
rb_ivar_set(self, s_tags, rb_hash_new());
return self;
}
@@ -894,7 +925,8 @@ syck_resolver_initialize(VALUE self)
* YAML::Syck::Resolver#add_type
*/
VALUE
-syck_resolver_add_type(VALUE self, VALUE taguri, VALUE cls)
+syck_resolver_add_type( self, taguri, cls )
+ VALUE self, taguri, cls;
{
VALUE tags = rb_attr_get(self, s_tags);
rb_hash_aset( tags, taguri, cls );
@@ -905,7 +937,8 @@ syck_resolver_add_type(VALUE self, VALUE taguri, VALUE cls)
* YAML::Syck::Resolver#use_types_at
*/
VALUE
-syck_resolver_use_types_at(VALUE self, VALUE hsh)
+syck_resolver_use_types_at( self, hsh )
+ VALUE self, hsh;
{
rb_ivar_set( self, s_tags, hsh );
return Qnil;
@@ -915,9 +948,9 @@ syck_resolver_use_types_at(VALUE self, VALUE hsh)
* YAML::Syck::Resolver#detect_implicit
*/
VALUE
-syck_resolver_detect_implicit(VALUE self, VALUE val)
+syck_resolver_detect_implicit( self, val )
+ VALUE self, val;
{
- char *type_id;
return rb_str_new2( "" );
}
@@ -925,7 +958,8 @@ syck_resolver_detect_implicit(VALUE self, VALUE val)
* YAML::Syck::Resolver#node_import
*/
VALUE
-syck_resolver_node_import(VALUE self, VALUE node)
+syck_resolver_node_import( self, node )
+ VALUE self, node;
{
SyckNode *n;
VALUE obj;
@@ -974,7 +1008,7 @@ syck_resolver_node_import(VALUE self, VALUE node)
VALUE dup = rb_funcall( end, s_dup, 0 );
v = rb_ary_reverse( v );
rb_ary_push( v, obj );
- rb_block_call( v, s_each, 0, 0, syck_merge_i, dup );
+ rb_iterate( rb_each, v, syck_merge_i, dup );
obj = dup;
skip_aset = 1;
}
@@ -1005,15 +1039,16 @@ syck_resolver_node_import(VALUE self, VALUE node)
* Set instance variables
*/
VALUE
-syck_set_ivars(VALUE vars, VALUE obj)
+syck_set_ivars( vars, obj )
+ VALUE vars, obj;
{
VALUE ivname = rb_ary_entry( vars, 0 );
char *ivn;
StringValue( ivname );
- ivn = S_ALLOCA_N( char, RSTRING_LEN(ivname) + 2 );
+ ivn = S_ALLOCA_N( char, RSTRING(ivname)->len + 2 );
ivn[0] = '@';
ivn[1] = '\0';
- strncat( ivn, RSTRING_PTR(ivname), RSTRING_LEN(ivname) );
+ strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len );
rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
return Qnil;
}
@@ -1022,12 +1057,13 @@ syck_set_ivars(VALUE vars, VALUE obj)
* YAML::Syck::Resolver#const_find
*/
VALUE
-syck_const_find(VALUE const_name)
+syck_const_find( const_name )
+ VALUE const_name;
{
VALUE tclass = rb_cObject;
VALUE tparts = rb_str_split( const_name, "::" );
int i = 0;
- for ( i = 0; i < RARRAY_LEN(tparts); i++ ) {
+ for ( i = 0; i < RARRAY(tparts)->len; i++ ) {
VALUE tpart = rb_to_id( rb_ary_entry( tparts, i ) );
if ( !rb_const_defined( tclass, tpart ) ) return Qnil;
tclass = rb_const_get( tclass, tpart );
@@ -1039,14 +1075,15 @@ syck_const_find(VALUE const_name)
* YAML::Syck::Resolver#transfer
*/
VALUE
-syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
+syck_resolver_transfer( self, type, val )
+ VALUE self, type, val;
{
- if (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0)
+ if (NIL_P(type) || RSTRING(StringValue(type))->len == 0)
{
type = rb_funcall( self, s_detect_implicit, 1, val );
}
- if ( ! (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) )
+ if ( ! (NIL_P(type) || RSTRING(StringValue(type))->len == 0) )
{
VALUE str_xprivate = rb_str_new2( "x-private" );
VALUE colon = rb_str_new2( ":" );
@@ -1063,7 +1100,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
VALUE subclass_parts = rb_ary_new();
VALUE parts = rb_str_split( type, ":" );
- while ( RARRAY_LEN(parts) > 1 )
+ while ( RARRAY(parts)->len > 1 )
{
VALUE partial;
rb_ary_unshift( subclass_parts, rb_ary_pop( parts ) );
@@ -1081,7 +1118,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
if ( ! NIL_P( target_class ) )
{
subclass = target_class;
- if ( RARRAY_LEN(subclass_parts) > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
+ if ( RARRAY(subclass_parts)->len > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
RTEST( rb_funcall( target_class, s_tag_subclasses, 0 ) ) )
{
VALUE subclass_v;
@@ -1140,7 +1177,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
}
else if ( !NIL_P( obj ) && rb_obj_is_instance_of( val, rb_cHash ) )
{
- rb_block_call( val, s_each, 0, 0, syck_set_ivars, obj );
+ rb_iterate( rb_each, val, syck_set_ivars, obj );
}
}
else
@@ -1170,13 +1207,14 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
* YAML::Syck::Resolver#tagurize
*/
VALUE
-syck_resolver_tagurize(VALUE self, VALUE val)
+syck_resolver_tagurize( self, val )
+ VALUE self, val;
{
VALUE tmp = rb_check_string_type(val);
if ( !NIL_P(tmp) )
{
- char *taguri = syck_type_id_to_uri( RSTRING_PTR(tmp) );
+ char *taguri = syck_type_id_to_uri( RSTRING(tmp)->ptr );
val = rb_str_new2( taguri );
S_FREE( taguri );
}
@@ -1188,7 +1226,8 @@ syck_resolver_tagurize(VALUE self, VALUE val)
* YAML::Syck::DefaultResolver#detect_implicit
*/
VALUE
-syck_defaultresolver_detect_implicit(VALUE self, VALUE val)
+syck_defaultresolver_detect_implicit( self, val )
+ VALUE self, val;
{
char *type_id;
VALUE tmp = rb_check_string_type(val);
@@ -1196,7 +1235,7 @@ syck_defaultresolver_detect_implicit(VALUE self, VALUE val)
if ( !NIL_P(tmp) )
{
val = tmp;
- type_id = syck_match_implicit( RSTRING_PTR(val), RSTRING_LEN(val) );
+ type_id = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len );
return rb_str_new2( type_id );
}
@@ -1207,7 +1246,8 @@ syck_defaultresolver_detect_implicit(VALUE self, VALUE val)
* YAML::Syck::DefaultResolver#node_import
*/
VALUE
-syck_defaultresolver_node_import(VALUE self, VALUE node)
+syck_defaultresolver_node_import( self, node )
+ VALUE self, node;
{
SyckNode *n;
VALUE obj;
@@ -1223,7 +1263,8 @@ syck_defaultresolver_node_import(VALUE self, VALUE node)
* YAML::Syck::GenericResolver#node_import
*/
VALUE
-syck_genericresolver_node_import(VALUE self, VALUE node)
+syck_genericresolver_node_import( self, node )
+ VALUE self, node;
{
SyckNode *n;
int i = 0;
@@ -1300,7 +1341,8 @@ syck_genericresolver_node_import(VALUE self, VALUE node)
* YAML::Syck::BadAlias.initialize
*/
VALUE
-syck_badalias_initialize(VALUE self, VALUE val)
+syck_badalias_initialize( self, val )
+ VALUE self, val;
{
rb_iv_set( self, "@name", val );
return self;
@@ -1310,7 +1352,8 @@ syck_badalias_initialize(VALUE self, VALUE val)
* YAML::Syck::BadAlias.<=>
*/
VALUE
-syck_badalias_cmp(VALUE alias1, VALUE alias2)
+syck_badalias_cmp( alias1, alias2 )
+ VALUE alias1, alias2;
{
VALUE str1 = rb_ivar_get( alias1, s_name );
VALUE str2 = rb_ivar_get( alias2, s_name );
@@ -1322,7 +1365,8 @@ syck_badalias_cmp(VALUE alias1, VALUE alias2)
* YAML::DomainType.initialize
*/
VALUE
-syck_domaintype_initialize(VALUE self, VALUE domain, VALUE type_id, VALUE val)
+syck_domaintype_initialize( self, domain, type_id, val )
+ VALUE self, domain, type_id, val;
{
rb_iv_set( self, "@domain", domain );
rb_iv_set( self, "@type_id", type_id );
@@ -1334,7 +1378,8 @@ syck_domaintype_initialize(VALUE self, VALUE domain, VALUE type_id, VALUE val)
* YAML::Object.initialize
*/
VALUE
-syck_yobject_initialize(VALUE self, VALUE klass, VALUE ivars)
+syck_yobject_initialize( self, klass, ivars )
+ VALUE self, klass, ivars;
{
rb_iv_set( self, "@class", klass );
rb_iv_set( self, "@ivars", ivars );
@@ -1345,7 +1390,8 @@ syck_yobject_initialize(VALUE self, VALUE klass, VALUE ivars)
* YAML::PrivateType.initialize
*/
VALUE
-syck_privatetype_initialize(VALUE self, VALUE type_id, VALUE val)
+syck_privatetype_initialize( self, type_id, val )
+ VALUE self, type_id, val;
{
rb_iv_set( self, "@type_id", type_id );
rb_iv_set( self, "@value", val );
@@ -1356,7 +1402,8 @@ syck_privatetype_initialize(VALUE self, VALUE type_id, VALUE val)
* Mark node contents.
*/
static void
-syck_node_mark(SyckNode *n)
+syck_node_mark( n )
+ SyckNode *n;
{
int i;
rb_gc_mark_maybe( n->id );
@@ -1386,7 +1433,8 @@ syck_node_mark(SyckNode *n)
* YAML::Syck::Scalar.allocate
*/
VALUE
-syck_scalar_alloc(VALUE class)
+syck_scalar_alloc( class )
+ VALUE class;
{
SyckNode *node = syck_alloc_str();
VALUE obj = Data_Wrap_Struct( class, syck_node_mark, syck_free_node, node );
@@ -1398,7 +1446,8 @@ syck_scalar_alloc(VALUE class)
* YAML::Syck::Scalar.initialize
*/
VALUE
-syck_scalar_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
+syck_scalar_initialize( self, type_id, val, style )
+ VALUE self, type_id, val, style;
{
rb_iv_set( self, "@kind", sym_scalar );
rb_funcall( self, s_type_id_set, 1, type_id );
@@ -1411,7 +1460,8 @@ syck_scalar_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
* YAML::Syck::Scalar.style=
*/
VALUE
-syck_scalar_style_set(VALUE self, VALUE style)
+syck_scalar_style_set( self, style )
+ VALUE self, style;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1449,14 +1499,15 @@ syck_scalar_style_set(VALUE self, VALUE style)
* YAML::Syck::Scalar.value=
*/
VALUE
-syck_scalar_value_set(VALUE self, VALUE val)
+syck_scalar_value_set( self, val )
+ VALUE self, val;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
StringValue( val );
- node->data.str->ptr = syck_strndup( RSTRING_PTR(val), RSTRING_LEN(val) );
- node->data.str->len = RSTRING_LEN(val);
+ node->data.str->ptr = syck_strndup( RSTRING(val)->ptr, RSTRING(val)->len );
+ node->data.str->len = RSTRING(val)->len;
node->data.str->style = scalar_none;
rb_iv_set( self, "@value", val );
@@ -1467,7 +1518,8 @@ syck_scalar_value_set(VALUE self, VALUE val)
* YAML::Syck::Seq.allocate
*/
VALUE
-syck_seq_alloc(VALUE class)
+syck_seq_alloc( class )
+ VALUE class;
{
SyckNode *node;
VALUE obj;
@@ -1481,7 +1533,8 @@ syck_seq_alloc(VALUE class)
* YAML::Syck::Seq.initialize
*/
VALUE
-syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
+syck_seq_initialize( self, type_id, val, style )
+ VALUE self, type_id, val, style;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1497,7 +1550,8 @@ syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
* YAML::Syck::Seq.value=
*/
VALUE
-syck_seq_value_set(VALUE self, VALUE val)
+syck_seq_value_set( self, val )
+ VALUE self, val;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1506,7 +1560,7 @@ syck_seq_value_set(VALUE self, VALUE val)
if ( !NIL_P( val ) ) {
int i;
syck_seq_empty( node );
- for ( i = 0; i < RARRAY_LEN( val ); i++ )
+ for ( i = 0; i < RARRAY( val )->len; i++ )
{
syck_seq_add( node, rb_ary_entry(val, i) );
}
@@ -1520,7 +1574,8 @@ syck_seq_value_set(VALUE self, VALUE val)
* YAML::Syck::Seq.add
*/
VALUE
-syck_seq_add_m(VALUE self, VALUE val)
+syck_seq_add_m( self, val )
+ VALUE self, val;
{
SyckNode *node;
VALUE emitter = rb_ivar_get( self, s_emitter );
@@ -1539,7 +1594,8 @@ syck_seq_add_m(VALUE self, VALUE val)
* YAML::Syck::Seq.style=
*/
VALUE
-syck_seq_style_set(VALUE self, VALUE style)
+syck_seq_style_set( self, style )
+ VALUE self, style;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1561,7 +1617,8 @@ syck_seq_style_set(VALUE self, VALUE style)
* YAML::Syck::Map.allocate
*/
VALUE
-syck_map_alloc(VALUE class)
+syck_map_alloc( class )
+ VALUE class;
{
SyckNode *node;
VALUE obj;
@@ -1575,7 +1632,8 @@ syck_map_alloc(VALUE class)
* YAML::Syck::Map.initialize
*/
VALUE
-syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
+syck_map_initialize( self, type_id, val, style )
+ VALUE self, type_id, val, style;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1591,7 +1649,7 @@ syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
}
keys = rb_funcall( hsh, s_keys, 0 );
- for ( i = 0; i < RARRAY_LEN(keys); i++ )
+ for ( i = 0; i < RARRAY(keys)->len; i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
@@ -1609,7 +1667,8 @@ syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
* YAML::Syck::Map.value=
*/
VALUE
-syck_map_value_set(VALUE self, VALUE val)
+syck_map_value_set( self, val )
+ VALUE self, val;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1626,7 +1685,7 @@ syck_map_value_set(VALUE self, VALUE val)
syck_map_empty( node );
keys = rb_funcall( hsh, s_keys, 0 );
- for ( i = 0; i < RARRAY_LEN(keys); i++ )
+ for ( i = 0; i < RARRAY(keys)->len; i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
@@ -1641,7 +1700,8 @@ syck_map_value_set(VALUE self, VALUE val)
* YAML::Syck::Map.add
*/
VALUE
-syck_map_add_m(VALUE self, VALUE key, VALUE val)
+syck_map_add_m( self, key, val )
+ VALUE self, key, val;
{
SyckNode *node;
VALUE emitter = rb_ivar_get( self, s_emitter );
@@ -1661,7 +1721,8 @@ syck_map_add_m(VALUE self, VALUE key, VALUE val)
* YAML::Syck::Map.style=
*/
VALUE
-syck_map_style_set(VALUE self, VALUE style)
+syck_map_style_set( self, style )
+ VALUE self, style;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1683,7 +1744,8 @@ syck_map_style_set(VALUE self, VALUE style)
* Cloning method for all node types
*/
VALUE
-syck_node_init_copy(VALUE copy, VALUE orig)
+syck_node_init_copy( copy, orig )
+ VALUE copy, orig;
{
SyckNode *copy_n;
SyckNode *orig_n;
@@ -1706,7 +1768,8 @@ syck_node_init_copy(VALUE copy, VALUE orig)
* YAML::Syck::Node#type_id=
*/
VALUE
-syck_node_type_id_set(VALUE self, VALUE type_id)
+syck_node_type_id_set( self, type_id )
+ VALUE self, type_id;
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
@@ -1715,7 +1778,7 @@ syck_node_type_id_set(VALUE self, VALUE type_id)
if ( !NIL_P( type_id ) ) {
StringValue( type_id );
- node->type_id = syck_strndup( RSTRING_PTR(type_id), RSTRING_LEN(type_id) );
+ node->type_id = syck_strndup( RSTRING(type_id)->ptr, RSTRING(type_id)->len );
}
rb_iv_set( self, "@type_id", type_id );
@@ -1726,7 +1789,8 @@ syck_node_type_id_set(VALUE self, VALUE type_id)
* YAML::Syck::Node.transform
*/
VALUE
-syck_node_transform(VALUE self)
+syck_node_transform( self )
+ VALUE self;
{
VALUE t;
SyckNode *n;
@@ -1782,7 +1846,9 @@ syck_node_transform(VALUE self)
* No one could possibly object.
*/
void
-rb_syck_emitter_handler(SyckEmitter *e, st_data_t data)
+rb_syck_emitter_handler(e, data)
+ SyckEmitter *e;
+ st_data_t data;
{
SyckNode *n;
Data_Get_Struct((VALUE)data, SyckNode, n);
@@ -1826,7 +1892,10 @@ rb_syck_emitter_handler(SyckEmitter *e, st_data_t data)
* Handle output from the emitter
*/
void
-rb_syck_output_handler(SyckEmitter * emitter, char *str, long len)
+rb_syck_output_handler( emitter, str, len )
+ SyckEmitter *emitter;
+ char *str;
+ long len;
{
struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus;
VALUE dest = bonus->port;
@@ -1842,7 +1911,8 @@ rb_syck_output_handler(SyckEmitter * emitter, char *str, long len)
* symbol table.
*/
void
-syck_out_mark(VALUE emitter, VALUE node)
+syck_out_mark( emitter, node )
+ VALUE emitter, node;
{
SyckEmitter *emitterPtr;
struct emitter_xtra *bonus;
@@ -1859,7 +1929,8 @@ syck_out_mark(VALUE emitter, VALUE node)
* Mark emitter values.
*/
static void
-syck_mark_emitter(SyckEmitter *emitter)
+syck_mark_emitter(emitter)
+ SyckEmitter *emitter;
{
struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus;
rb_gc_mark( bonus->oid );
@@ -1871,7 +1942,8 @@ syck_mark_emitter(SyckEmitter *emitter)
* Free the emitter and any bonus attachment.
*/
void
-rb_syck_free_emitter(SyckEmitter *e)
+rb_syck_free_emitter(e)
+ SyckEmitter *e;
{
S_FREE( e->bonus );
syck_free_emitter(e);
@@ -1882,7 +1954,8 @@ rb_syck_free_emitter(SyckEmitter *e)
*/
VALUE syck_emitter_s_alloc _((VALUE));
VALUE
-syck_emitter_s_alloc(VALUE class)
+syck_emitter_s_alloc(class)
+ VALUE class;
{
VALUE pobj;
SyckEmitter *emitter = syck_new_emitter();
@@ -1902,7 +1975,10 @@ syck_emitter_s_alloc(VALUE class)
* YAML::Syck::Emitter.reset( options )
*/
VALUE
-syck_emitter_reset(int argc, VALUE *argv, VALUE self)
+syck_emitter_reset( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE options, tmp;
SyckEmitter *emitter;
@@ -1944,10 +2020,12 @@ syck_emitter_reset(int argc, VALUE *argv, VALUE self)
* YAML::Syck::Emitter.emit( object_id ) { |out| ... }
*/
VALUE
-syck_emitter_emit(int argc, VALUE *argv, VALUE self)
+syck_emitter_emit( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE oid, proc;
- char *anchor_name;
SyckEmitter *emitter;
struct emitter_xtra *bonus;
SYMID symple;
@@ -1985,7 +2063,8 @@ syck_emitter_emit(int argc, VALUE *argv, VALUE self)
* YAML::Syck::Emitter#node_export
*/
VALUE
-syck_emitter_node_export(VALUE self, VALUE node)
+syck_emitter_node_export( self, node )
+ VALUE self, node;
{
return rb_funcall( node, s_to_yaml, 1, self );
}
@@ -1994,7 +2073,8 @@ syck_emitter_node_export(VALUE self, VALUE node)
* YAML::Syck::Emitter#set_resolver
*/
VALUE
-syck_emitter_set_resolver(VALUE self, VALUE resolver)
+syck_emitter_set_resolver( self, resolver )
+ VALUE self, resolver;
{
rb_ivar_set( self, s_resolver, resolver );
return self;
@@ -2004,7 +2084,8 @@ syck_emitter_set_resolver(VALUE self, VALUE resolver)
* YAML::Syck::Out::initialize
*/
VALUE
-syck_out_initialize(VALUE self, VALUE emitter)
+syck_out_initialize( self, emitter )
+ VALUE self, emitter;
{
rb_ivar_set( self, s_emitter, emitter );
return self;
@@ -2014,7 +2095,10 @@ syck_out_initialize(VALUE self, VALUE emitter)
* YAML::Syck::Out::map
*/
VALUE
-syck_out_map(int argc, VALUE *argv, VALUE self)
+syck_out_map( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE type_id, style, map;
if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) {
@@ -2030,7 +2114,10 @@ syck_out_map(int argc, VALUE *argv, VALUE self)
* YAML::Syck::Out::seq
*/
VALUE
-syck_out_seq(int argc, VALUE *argv, VALUE self)
+syck_out_seq( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE type_id, style, seq;
if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) {
@@ -2048,7 +2135,10 @@ syck_out_scalar( self, type_id, str, style )
VALUE self, type_id, str, style;
*/
VALUE
-syck_out_scalar(int argc, VALUE *argv, VALUE self)
+syck_out_scalar( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE type_id, str, style, scalar;
if (rb_scan_args(argc, argv, "21", &type_id, &str, &style) == 2) {
@@ -2105,7 +2195,6 @@ Init_syck()
s_transform = rb_intern( "transform" );
s_yaml_new = rb_intern("yaml_new");
s_yaml_initialize = rb_intern("yaml_initialize");
- s_each = rb_intern("each");
s_tags = rb_intern("@tags");
s_name = rb_intern("@name");
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index 20aaecc9f0..a83c8813c1 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -6,7 +6,7 @@
*
* Copyright (C) 2003 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <stdio.h>
#include <string.h>
@@ -32,7 +32,7 @@ syck_assert( char *file_name, unsigned line_num )
* Allocates and copies a string
*/
char *
-syck_strndup( const char *buf, long len )
+syck_strndup( char *buf, long len )
{
char *new = S_ALLOC_N( char, len + 1 );
S_MEMZERO( new, char, len + 1 );
@@ -155,7 +155,7 @@ syck_parser_set_root_on_error( SyckParser *p, SYMID roer )
* Allocate the parser
*/
SyckParser *
-syck_new_parser(void)
+syck_new_parser()
{
SyckParser *p;
p = S_ALLOC( SyckParser );
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
index f5b0cc497e..e7d07e9c0d 100644
--- a/ext/syck/syck.h
+++ b/ext/syck/syck.h
@@ -19,7 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
-#include "ruby/st.h"
+#include "st.h"
#if defined(__cplusplus)
extern "C" {
@@ -347,8 +347,8 @@ void syck_hdlr_remove_anchor( SyckParser *, char * );
SyckNode *syck_hdlr_get_anchor( SyckParser *, char * );
void syck_add_transfer( char *, SyckNode *, int );
char *syck_xprivate( char *, int );
-char *syck_taguri( const char *, const char *, int );
-int syck_tagcmp( const char *, const char * );
+char *syck_taguri( char *, char *, int );
+int syck_tagcmp( char *, char * );
int syck_add_sym( SyckParser *, char * );
int syck_lookup_sym( SyckParser *, SYMID, char ** );
int syck_try_implicit( SyckNode * );
@@ -359,19 +359,19 @@ char *syck_match_implicit( char *, size_t );
/*
* API prototypes
*/
-char *syck_strndup( const char *, long );
+char *syck_strndup( char *, long );
long syck_io_file_read( char *, SyckIoFile *, long, long );
long syck_io_str_read( char *, SyckIoStr *, long, long );
char *syck_base64enc( char *, long );
char *syck_base64dec( char *, long );
-SyckEmitter *syck_new_emitter(void);
+SyckEmitter *syck_new_emitter();
SYMID syck_emitter_mark_node( SyckEmitter *, st_data_t );
void syck_emitter_ignore_id( SyckEmitter *, SYMID );
void syck_output_handler( SyckEmitter *, SyckOutputHandler );
void syck_emitter_handler( SyckEmitter *, SyckEmitterHandler );
void syck_free_emitter( SyckEmitter * );
void syck_emitter_clear( SyckEmitter * );
-void syck_emitter_write( SyckEmitter *, const char *, long );
+void syck_emitter_write( SyckEmitter *, char *, long );
void syck_emitter_escape( SyckEmitter *, char *, long );
void syck_emitter_flush( SyckEmitter *, long );
void syck_emit( SyckEmitter *, st_data_t );
@@ -384,14 +384,14 @@ void syck_emit_seq( SyckEmitter *, char *, enum seq_style );
void syck_emit_item( SyckEmitter *, st_data_t );
void syck_emit_map( SyckEmitter *, char *, enum map_style );
void syck_emit_end( SyckEmitter * );
-void syck_emit_tag( SyckEmitter *, const char *, const char * );
+void syck_emit_tag( SyckEmitter *, char *, char * );
void syck_emit_indent( SyckEmitter * );
SyckLevel *syck_emitter_current_level( SyckEmitter * );
SyckLevel *syck_emitter_parent_level( SyckEmitter * );
void syck_emitter_pop_level( SyckEmitter * );
void syck_emitter_add_level( SyckEmitter *, int, enum syck_level_status );
void syck_emitter_reset_levels( SyckEmitter * );
-SyckParser *syck_new_parser(void);
+SyckParser *syck_new_parser();
void syck_free_parser( SyckParser * );
void syck_parser_set_root_on_error( SyckParser *, SYMID );
void syck_parser_implicit_typing( SyckParser *, int );
@@ -418,13 +418,13 @@ char *syck_yaml2byte( char * );
/*
* Allocation prototypes
*/
-SyckNode *syck_alloc_map(void);
-SyckNode *syck_alloc_seq(void);
-SyckNode *syck_alloc_str(void);
+SyckNode *syck_alloc_map();
+SyckNode *syck_alloc_seq();
+SyckNode *syck_alloc_str();
void syck_free_node( SyckNode * );
void syck_free_members( SyckNode * );
-SyckNode *syck_new_str( const char *, enum scalar_style );
-SyckNode *syck_new_str2( const char *, long, enum scalar_style );
+SyckNode *syck_new_str( char *, enum scalar_style );
+SyckNode *syck_new_str2( char *, long, enum scalar_style );
void syck_replace_str( SyckNode *, char *, enum scalar_style );
void syck_replace_str2( SyckNode *, char *, long, enum scalar_style );
void syck_str_blow_away_commas( SyckNode * );
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 0517ffc400..3c6cd1a9cf 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -8,7 +8,7 @@
*
* Copyright (C) 2003 why the lucky stiff
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include "syck.h"
#include "gram.h"
diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c
index fd5caadd85..821a3cd5b5 100644
--- a/ext/syck/yaml2byte.c
+++ b/ext/syck/yaml2byte.c
@@ -9,7 +9,7 @@
* WARNING WARNING WARNING --- THIS IS *NOT JUST* PLAYING
* ANYMORE! -- WHY HAS EMBRACED THIS AS THE REAL THING!
*/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <syck.h>
#include <assert.h>
#define YAMLBYTE_UTF8
@@ -35,7 +35,7 @@ typedef struct {
long remaining;
int printed;
} bytestring_t;
-bytestring_t *bytestring_alloc(void) {
+bytestring_t *bytestring_alloc() {
bytestring_t *ret;
/*TRACE0("bytestring_alloc()");*/
ret = S_ALLOC(bytestring_t);
diff --git a/ext/syslog/.cvsignore b/ext/syslog/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/syslog/.cvsignore
+++ b/ext/syslog/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
index 4ac645969d..ecc49318f7 100644
--- a/ext/syslog/syslog.c
+++ b/ext/syslog/syslog.c
@@ -7,8 +7,8 @@
* $Id$
*/
-#include "ruby/ruby.h"
-#include "ruby/util.h"
+#include "ruby.h"
+#include "util.h"
#include <syslog.h>
/* Syslog class */
@@ -22,6 +22,7 @@ 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");
}
@@ -32,12 +33,13 @@ static void syslog_write(int pri, int argc, VALUE *argv)
str = rb_f_sprintf(argc, argv);
- syslog(pri, "%s", RSTRING_PTR(str));
+ syslog(pri, "%s", RSTRING(str)->ptr);
}
/* Syslog module methods */
static VALUE mSyslog_close(VALUE self)
{
+ rb_secure(4);
if (!syslog_opened) {
rb_raise(rb_eRuntimeError, "syslog not opened");
}
@@ -70,7 +72,7 @@ static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
#else
Check_SafeStr(ident);
#endif
- syslog_ident = strdup(RSTRING_PTR(ident));
+ syslog_ident = strdup(RSTRING(ident)->ptr);
if (NIL_P(opt)) {
syslog_options = LOG_PID | LOG_CONS;
@@ -132,6 +134,7 @@ 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 9aed35133d..35bd4cb057 100644
--- a/ext/syslog/syslog.txt
+++ b/ext/syslog/syslog.txt
@@ -7,7 +7,10 @@ Amos Gouaux, University of Texas at Dallas
<amos+ruby@utdallas.edu>
&
Akinori MUSHA
-<knu@ruby-lang.org>
+<knu@iDaemons.org>
+
+Contact:
+ - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
** Syslog(Module)
diff --git a/ext/thread/extconf.rb b/ext/thread/extconf.rb
new file mode 100644
index 0000000000..2f984efc6d
--- /dev/null
+++ b/ext/thread/extconf.rb
@@ -0,0 +1,9 @@
+require 'mkmf'
+
+enable_config('fastthread', true) or exit
+
+if with_config('mem-pools', true)
+ $CPPFLAGS << ' -DUSE_MEM_POOLS'
+end
+
+create_makefile("thread")
diff --git a/ext/thread/lib/thread.rb b/ext/thread/lib/thread.rb
new file mode 100644
index 0000000000..6c533aba39
--- /dev/null
+++ b/ext/thread/lib/thread.rb
@@ -0,0 +1,5 @@
+unless defined? Thread
+ fail "Thread not available for this ruby interpreter"
+end
+
+require 'thread.so'
diff --git a/ext/thread/thread.c b/ext/thread/thread.c
new file mode 100644
index 0000000000..68f172220a
--- /dev/null
+++ b/ext/thread/thread.c
@@ -0,0 +1,1182 @@
+/*
+ * 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/.cvsignore b/ext/tk/.cvsignore
index 90c83ed9b1..44e7f262dc 100644
--- a/ext/tk/.cvsignore
+++ b/ext/tk/.cvsignore
@@ -1,3 +1,3 @@
Makefile
+mkmf.log
*.log
-*.def
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib
index 359b466a32..8c5d01a954 100644
--- a/ext/tk/ChangeLog.tkextlib
+++ b/ext/tk/ChangeLog.tkextlib
@@ -1,3 +1,9 @@
+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.
diff --git a/ext/tk/MANUAL_tcltklib.eng b/ext/tk/MANUAL_tcltklib.eng
index 9ef9adf26c..6fa775b7de 100644
--- a/ext/tk/MANUAL_tcltklib.eng
+++ b/ext/tk/MANUAL_tcltklib.eng
@@ -448,6 +448,10 @@ 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
@@ -458,5 +462,8 @@ 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 d291b7e807..7df42997b4 100644
--- a/ext/tk/MANUAL_tcltklib.eucj
+++ b/ext/tk/MANUAL_tcltklib.eucj
@@ -559,6 +559,9 @@ require "tcltklib" ¤¹¤ë¤È, °Ê²¼¤Î¥â¥¸¥å¡¼¥ë, ¥¯¥é¥¹¤¬ÍøÍѲÄǽ¤Ç¤¹.
: ¥¹¥ì¡¼¥Ö IP ¤Î¾ì¹ç¤Ë¤ÏÃͤÎÀßÄ꤬µö¤µ¤ì¤Ê¤¤ (̵»ë¤µ¤ì¤ë)¡¥
: ¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï°ú¿ô¤ò´Þ¤á¤Æ TclTkLib ¤ÎƱ̾¥á¥½¥Ã¥É¤ËƱ¤¸¡¥
+ encoding_table
+ : Ruby m17n ÍÑ¤Ë Ruby ¤È Tk ¤È¤Î´Ö¤Î encoding Âбþɽ¤òÊÖ¤¹¡¥
+
¥¯¥é¥¹ TkCallbackBreak < StandardError
¥¯¥é¥¹ TkCallbackContinue < StandardError
: ¤³¤ì¤é¤Ï¥¤¥Ù¥ó¥È¥³¡¼¥ë¥Ð¥Ã¥¯¤Ë¤ª¤¤¤Æ¡¤¥³¡¼¥ë¥Ð¥Ã¥¯½èÍý¤òŬÀÚ¤ËÃæ
@@ -569,5 +572,8 @@ require "tcltklib" ¤¹¤ë¤È, °Ê²¼¤Î¥â¥¸¥å¡¼¥ë, ¥¯¥é¥¹¤¬ÍøÍѲÄǽ¤Ç¤¹.
: ¥É¤òÊÖ¤¹É¬Íפ¬¤¢¤ë¡¥Ruby ¤Î¼ê³¤­¤¬ÉáÄ̤ËÃͤòÊÖ¤¹¤Î¤Ç¤Ï¡¤¤½¤ì¤¬Éá
: Ä̤ÎÌá¤êÃͤǤ¢¤ë¤Î¤«Èݤ«¤ò¶èÊ̤¬¤Ç¤­¤Ê¤¤¤¿¤á¡¤Î㳰ȯÀ¸¤òÍøÍѤ·¤¿
: ¼ÂÁõ¤ò¹Ô¤Ã¤Æ¤¤¤ë¡¥
+ : ¤¿¤À¤·¸½ºß¤Ç¤Ï¡¤¥³¡¼¥ë¥Ð¥Ã¥¯¼ê³¤­¤ò Ruby ¤Î break, next ¤Ç½ªÎ»¤¹
+ : ¤ë¤³¤È¤ÇƱÅù¤Î·ë²Ì¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡¥¤½¤ì¤æ¤¨¡¤
+ : ¤³¤ì¤é¤ÏɬÍפʤ¤¤â¤Î¤Ç¤Ï¤¢¤ë¤¬¡¤¸ß´¹À­¤Î¤¿¤á¤Ë»Ä¤·¤Æ¤¢¤ë¡¥
(eof)
diff --git a/ext/tk/README.tcltklib b/ext/tk/README.tcltklib
index e939ba1f51..8c6dd5178f 100644
--- a/ext/tk/README.tcltklib
+++ b/ext/tk/README.tcltklib
@@ -5,10 +5,14 @@ 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"
@@ -16,18 +20,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 containts 'tcl.h'
- --with-tk-include=<dir> the directry containts 'tk.h'
+ --with-tcl-include=<dir> the directry contains 'tcl.h'
+ --with-tk-include=<dir> the directry contains 'tk.h'
- --with-tcl-lib=<dir> the directry containts 'libtcl<version>.so'
- --with-tk-lib=<dir> the directry containts 'libtk<version>.so'
+ --with-tcl-lib=<dir> the directry contains 'libtcl<version>.so'
+ --with-tk-lib=<dir> the directry contains '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 containts Tcl/Tk framework;
+ --with-tcltk-framework=<dir> the directory contains 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.
@@ -46,8 +50,8 @@ some or all of the following options.
--with-X11-dir=<path>
equal to "--with-X11-include=<path>/include --with-X11-lib=<path>/lib"
- --with-X11-include=<dir> the directry contains X11 header files
- --with-X11-lib=<dir> the directry contains X11 libraries
+ --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
diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb
index 292b18a5c0..4807ea7b40 100644
--- a/ext/tk/extconf.rb
+++ b/ext/tk/extconf.rb
@@ -2,7 +2,8 @@
require 'mkmf'
-is_win32 = (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM)
+#is_win32 = (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM)
+is_win32 = (/mswin|mingw|cygwin|bccwin|wince/ =~ RUBY_PLATFORM)
#is_macosx = (/darwin/ =~ RUBY_PLATFORM)
def find_framework(tcl_hdr, tk_hdr)
@@ -39,18 +40,68 @@ unless is_win32
have_library("m", "log")
end
-dir_config("tk")
-dir_config("tcl")
-dir_config("X11")
+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]
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 find_tcl(tcllib, stubs)
- paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
+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
+
if stubs
func = "Tcl_InitStubs"
lib = "tclstub"
@@ -58,26 +109,42 @@ def find_tcl(tcllib, stubs)
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
- find_library(tcllib, func, *paths)
- elsif find_library(lib, func, *paths)
- true
+ st = find_library(tcllib, func, *paths)
else
- %w[8.6 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) or
- find_library("#{lib}#{ver}g", func, *paths) or
- find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
- find_library("tcl#{ver}g", func, *paths) or
- find_library("tcl#{ver.delete('.')}g", func, *paths)
- }
+ 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.")
end
+ st
end
-def find_tk(tklib, stubs)
- paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
+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
+
if stubs
func = "Tk_InitStubs"
lib = "tkstub"
@@ -85,24 +152,45 @@ def find_tk(tklib, stubs)
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
- find_library(tklib, func, *paths)
- elsif find_library(lib, func, *paths)
- true
+ st = find_library(tklib, func, *paths)
else
- %w[8.6 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) or
- find_library("#{lib}#{ver}g", func, *paths) or
- find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
- find_library("tk#{ver}g", func, *paths) or
- find_library("tk#{ver.delete('.')}g", func, *paths)
- }
+ 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.")
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
@@ -281,13 +369,13 @@ EOF
end
end
-if tcltk_framework ||
- (have_header("tcl.h") && have_header("tk.h") &&
- ( !use_X || find_library("X11", "XOpenDisplay",
- "/usr/X11/lib", "/usr/lib/X11",
- "/usr/X11R6/lib", "/usr/openwin/lib")) &&
- find_tcl(tcllib, stubs) &&
- find_tk(tklib, stubs))
+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) ) )
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
@@ -314,6 +402,8 @@ if tcltk_framework ||
$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}\\"]
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb
index 7b25c22063..ec718678f0 100644
--- a/ext/tk/lib/multi-tk.rb
+++ b/ext/tk/lib/multi-tk.rb
@@ -114,7 +114,14 @@ MultiTkIp_OK.freeze
class MultiTkIp
BASE_DIR = File.dirname(__FILE__)
- @@SLAVE_IP_ID = ['slave'.freeze, '0'.taint].freeze
+ 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
+ }
@@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
@@ -126,7 +133,11 @@ 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', {}.taint)
+ @@TK_CMD_TBL.instance_variable_set('@tbl', Hash.new{|hash,key|
+ fail IndexError,
+ "unknown command ID '#{key}'"
+ }.taint)
class << @@TK_CMD_TBL
allow = [
@@ -573,7 +584,11 @@ class MultiTkIp
# raise exception
begin
bt = _toUTF8(e.backtrace.join("\n"))
- bt.instance_variable_set(:@encoding, 'utf-8')
+ if MultiTkIp::WITH_ENCODING
+ bt.force_encoding('utf-8')
+ else
+ bt.instance_variable_set(:@encoding, 'utf-8')
+ end
rescue Exception
bt = e.backtrace.join("\n")
end
@@ -695,6 +710,11 @@ 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
@@ -723,13 +743,24 @@ class MultiTkIp
fail ArgumentError, "expecting a Hash object for the 2nd argument"
end
- if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
+ if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
@interp = TclTkIp.new(name, _keys2opts(keys))
- else
+ else ### Ruby 1.9 !!!!!!!!!!!
@interp_thread = Thread.new{
- Thread.current[:interp] = interp = TclTkIp.new(name, _keys2opts(keys))
+ current = Thread.current
+ current[:interp] = interp = TclTkIp.new(name, _keys2opts(keys))
#sleep
- interp.mainloop(true)
+ 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
@@ -876,22 +907,26 @@ class MultiTkIp
Thread.new{
current = Thread.current
loop {
- mtx, ret, table, script = @init_ip_env_queue.deq
- begin
+ mtx, cond, 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.unlock
+ mtx.synchronize{ cond.signal }
end
+ mtx = cond = ret = table = script = nil # clear variables for GC
}
}
def self.__init_ip_env__(table, script)
ret = []
- mtx = Mutex.new.lock
- @init_ip_env_queue.enq([mtx, ret, table, script])
- # mtx.lock
+ 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)
+ }
if ret[0].kind_of?(Exception)
raise ret[0]
else
@@ -970,9 +1005,11 @@ class MultiTkIp
private :_parse_slaveopts
def _create_slave_ip_name
- name = @@SLAVE_IP_ID.join('')
- @@SLAVE_IP_ID[1].succ!
- name.freeze
+ @@SLAVE_IP_ID.mutex.synchronize{
+ name = @@SLAVE_IP_ID.join('')
+ @@SLAVE_IP_ID[1].succ!
+ name.freeze
+ }
end
private :_create_slave_ip_name
@@ -1229,9 +1266,9 @@ class MultiTkIp
if safeip == nil
# create master-ip
- if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
+ unless WITH_RUBY_VM
@interp = TclTkIp.new(name, _keys2opts(tk_opts))
- else
+ else ### Ruby 1.9 !!!!!!!!!!!
@interp_thread = Thread.new{
Thread.current[:interp] = interp = TclTkIp.new(name, _keys2opts(tk_opts))
#sleep
@@ -1257,7 +1294,8 @@ 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 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]
@@ -1266,7 +1304,8 @@ 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 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]
@@ -1301,11 +1340,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
@@ -1383,8 +1422,13 @@ 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
+
if safe.kind_of?(Hash)
keys = safe
elsif safe.kind_of?(Integer)
@@ -1601,8 +1645,13 @@ 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
}
}
@@ -1652,11 +1701,16 @@ class MultiTkIp
id = @@TK_TABLE_LIST.size
obj = Object.new
@@TK_TABLE_LIST << obj
- obj.instance_eval <<-EOD
+ obj.instance_variable_set(:@id, id)
+ obj.instance_variable_set(:@mutex, Mutex.new)
+ obj.instance_eval{
+ def self.mutex
+ @mutex
+ end
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
@@ -2377,7 +2431,7 @@ class MultiTkIp
def mainloop(check_root = true, restart_on_dead = true)
raise SecurityError, "no permission to manipulate" unless self.manipulable?
- if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
+ if WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
return @interp_thread.value if @interp_thread
end
@@ -2789,9 +2843,10 @@ 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
@@ -3230,15 +3285,44 @@ end
# encoding convert
+class << MultiTkIp
+ def encoding_table
+ __getip.encoding_table
+ end
+end
class MultiTkIp
- def encoding
+ def encoding_table
+ @interp.encoding_table
+ end
+
+ def force_default_encoding=(mode)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.force_default_encoding = mode
+ end
+ def force_default_encoding?
raise SecurityError, "no permission to manipulate" unless self.manipulable?
- @interp.encoding
+ @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?
@@ -3255,13 +3339,30 @@ 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/tk.rb b/ext/tk/lib/tk.rb
index d079bb9ed9..c5d5b804d2 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1,6 +1,5 @@
#
# tk.rb - Tk interface module using tcltklib
-# $Date$
# by Yukihiro Matsumoto <matz@netlab.jp>
# use Shigehiro's tcltklib
@@ -10,6 +9,9 @@ require 'tkutil'
# autoload
require 'tk/autoload'
+# for Mutex
+require 'thread'
+
class TclTkIp
# backup original (without encoding) _eval and _invoke
alias _eval_without_enc _eval
@@ -37,7 +39,12 @@ module TkComm
#Tk_CMDTBL = {}
#Tk_WINDOWS = {}
- Tk_IDs = ["00000".taint, "00000".taint].freeze # [0]-cmdid, [1]-winid
+ Tk_IDs = ["00000".taint, "00000".taint] # [0]-cmdid, [1]-winid
+ Tk_IDs.instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
# for backward compatibility
Tk_CMDTBL = Object.new
@@ -218,7 +225,9 @@ module TkComm
TkCore::INTERP.tk_windows[val]?
TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val)
when /\Ai(_\d+_)?\d+\z/
- TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ TkImage::Tk_IMGTBL.mutex.synchronize{
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ }
when /\A-?\d+\.?\d*(e[-+]?\d+)?\z/
val.to_f
when /\\ /
@@ -335,6 +344,8 @@ 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
@@ -347,11 +358,20 @@ if USE_TCLs_LIST_FUNCTIONS
if sys_enc && dst_enc
dst.map!{|s| _toUTF8(s)}
ret = TkCore::INTERP._merge_tklist(*dst)
- 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')
+ 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
end
ret
else
@@ -411,46 +431,6 @@ 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 == ""
@@ -601,7 +581,9 @@ end
end
def image_obj(val)
if val =~ /^i(_\d+_)?\d+$/
- TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ TkImage::Tk_IMGTBL.mutex.synchronize{
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ }
else
val
end
@@ -783,15 +765,17 @@ end
id = "c" + TkCore::INTERP._ip_id_ + TkComm::Tk_IDs[0]
end
def _next_cmd_id
- id = _curr_cmd_id
- #Tk_IDs[0] += 1
- TkComm::Tk_IDs[0].succ!
- id
+ TkComm::Tk_IDs.mutex.synchronize{
+ 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 install_cmd(cmd)
+ def TkComm.install_cmd(cmd, local_cmdtbl=nil)
return '' if cmd == ''
begin
ns = TkCore::INTERP._invoke_without_enc('namespace', 'current')
@@ -810,6 +794,15 @@ 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
@@ -817,14 +810,30 @@ end
'rb_out' << TkCore::INTERP._ip_id_ << ' ' << id
end
end
- def uninstall_cmd(id)
+ def TkComm.uninstall_cmd(id, local_cmdtbl=nil)
#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
+ # 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
=begin
def install_win(ppath,name=nil)
@@ -856,8 +865,10 @@ end
return TkCore::INTERP.tk_windows[@path] = self
end
else
- name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
- Tk_IDs[1].succ!
+ Tk_IDs.mutex.synchronize{
+ name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
+ Tk_IDs[1].succ!
+ }
end
if !ppath or ppath == '.'
@path = '.' + name
@@ -936,7 +947,12 @@ module TkComm
def _bindinfo(what, context=nil)
if context
- tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline|
+ 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|
=begin
if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/
#[Tk_CMDTBL[$1], $2]
@@ -1077,11 +1093,16 @@ module TkComm
end
end
+
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
@@ -1102,10 +1123,9 @@ module TkCore
opts = ''
end
- if RUBY_VERSION < '1.9.0' || RUN_EVENTLOOP_ON_MAIN_THREAD ### !!!!!!!!!!!
+ if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
INTERP = TclTkIp.new(name, opts)
else
- require 'thread'
INTERP_MUTEX = Mutex.new
INTERP_ROOT_CHECK = ConditionVariable.new
INTERP_THREAD = Thread.new{
@@ -1142,7 +1162,10 @@ module TkCore
end
INTERP.instance_eval{
- @tk_cmd_tbl = {}.taint
+ # @tk_cmd_tbl = {}.taint
+ @tk_cmd_tbl = Hash.new{|hash, key|
+ fail IndexError, "unknown command ID '#{key}'"
+ }.taint
def @tk_cmd_tbl.[]=(idx,val)
if self.has_key?(idx) && Thread.current.group != ThreadGroup::Default
fail SecurityError,"cannot change the entried command"
@@ -1193,6 +1216,10 @@ 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)
@@ -1271,7 +1298,7 @@ module TkCore
}) << ' %W')
INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '',
- "bind all <#{WIDGET_DESTROY_HOOK}> {}")
+ "catch { bind all <#{WIDGET_DESTROY_HOOK}> {} }")
INTERP.add_tk_procs('rb_out', 'ns args', <<-'EOL')
if [regexp {^::} $ns] {
@@ -1378,7 +1405,11 @@ module TkCore
"\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------"
- msg.instance_variable_set(:@encoding, 'utf-8')
+ if TkCore::WITH_ENCODING
+ msg.force_encoding('utf-8')
+ else
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ end
rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" +
@@ -1434,6 +1465,13 @@ 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
@@ -1456,8 +1494,16 @@ 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
@@ -1468,9 +1514,15 @@ 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
@@ -1590,10 +1642,9 @@ module TkCore
end
def mainloop(check_root = true)
- if RUBY_VERSION < '1.9.0' ||
- TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD ### !!!!!!!!!!!
+ if !TkCore::WITH_RUBY_VM || TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
TclTkLib.mainloop(check_root)
- else
+ else ### Ruby 1.9 !!!!!
begin
TclTkLib.set_eventloop_window_mode(true)
if check_root
@@ -1619,8 +1670,8 @@ 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 RUBY_VERSION < '1.9.0' ||
- TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD ### !!!!!!!!!!!
+ if !TkCore::WITH_RUBY_VM || TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
+ ### Ruby 1.9 !!!!!!!!!!!
TclTkLib.mainloop_thread?
else
Thread.current == INTERP_THREAD
@@ -1860,6 +1911,7 @@ module TkCore
end
end
+
module Tk
include TkCore
extend Tk
@@ -1975,7 +2027,7 @@ module Tk
end
def root
- TkRoot.new
+ Tk::Root.new
end
def Tk.load_tclscript(file, enc=nil)
@@ -2091,6 +2143,27 @@ 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
@@ -2266,16 +2339,432 @@ 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
+ #attr_accessor :encoding
+ def encoding=(name)
+ self.force_default_encoding = true # for comaptibility
+ self.default_encoding = name
+ end
- alias __eval _eval
- alias __invoke _invoke
+ 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
+
+ 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
+
=begin
#### --> definition is moved to TclTkIp module
@@ -2325,17 +2814,6 @@ 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'
@@ -2392,81 +2870,43 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
module TclTkLib
class << self
- alias _encoding encoding
- alias _encoding= encoding=
- def encoding=(name)
- TkCore::INTERP.encoding = name
- end
- def encoding
- TkCore::INTERP.encoding
+ def force_default_encoding=(mode)
+ TkCore::INTERP.force_default_encoding = mode
end
- end
- end
- module Tk
- module Encoding
- extend Encoding
+ def force_default_encoding?
+ TkCore::INTERP.force_default_encoding?
+ end
- TkCommandNames = ['encoding'.freeze].freeze
+ def default_encoding=(name)
+ TkCore::INTERP.default_encoding = name
+ end
+ 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
+ def encoding_name
TkCore::INTERP.encoding
end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
- def encoding_names
- TkComm.simplelist(Tk.tk_call('encoding', 'names'))
- end
-
- def encoding_system
- Tk.tk_call('encoding', 'system')
- end
-
- def encoding_system=(enc)
- Tk.tk_call('encoding', 'system', enc)
- end
-
- 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
- alias encoding_convert_from encoding_convertfrom
-
- def encoding_convertto(str, enc=nil)
- # str must be a UTF-8 string.
- # The return value is a Tcl's internal string expression in enc.
- # To get an usual enc string, use Tk.fromUTF8(ret_val, enc).
- enc = encoding_system unless enc
- ret = TkCore::INTERP.__invoke('encoding', 'convertto', enc, str)
- ret.instance_variable_set('@encoding', 'binary')
- 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)
+ def encoding_obj
+ if Tk::WITH_ENCODING
+ Tk::Encoding.tcl2rb_encoding(TkCore::INTERP.encoding)
+ else
+ TkCore::INTERP.encoding
+ end
end
end
-
- extend Encoding
end
# estimate encoding
- if RUBY_VERSION < '1.9.0'
+ unless TkCore::WITH_ENCODING
case $KCODE
when /^e/i # EUC
Tk.encoding = 'euc-jp'
@@ -2497,89 +2937,147 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
Tk.encoding_system = 'utf-8'
end
end
- else #########################
- $TK_ENCODING ||= Encoding.default_external.name
- case $TK_ENCODING
- when 'US_ASCII'
- Tk.encoding = 'ascii'
- Tk.encoding_system = 'ascii'
- when 'BIG5'
- Tk.encoding = 'big5'
- Tk.encoding_system = 'big5'
- when 'CP1251'
- Tk.encoding = 'cp1251'
- Tk.encoding_system = 'cp1251'
- when 'EUC-JP'
- Tk.encoding = 'euc-jp'
- Tk.encoding_system = 'euc-jp'
- when 'EUC-KR'
- Tk.encoding = 'euc-kr'
- Tk.encoding_system = 'euc-kr'
- when 'EUC-TW', 'EUC-CN'
- Tk.encoding = 'euc-cn'
- Tk.encoding_system = 'euc-cn'
- #when 'GB18030'
- # Tk.encoding = 'gb12345' # ????????????
- # Tk.encoding_system = 'gb12345' # ????????????
- when 'ISO-2022-JP'
- Tk.encoding = 'iso2022-jp'
- Tk.encoding_system = 'iso2022-jp'
- when /ISO-8859-(.*)/
- Tk.encoding = 'iso8859-' << $1
- Tk.encoding_system = 'iso8859-' << $1
- #when 'KOI8', 'KOI8-U'
- # Tk.encoding = 'koi8-u' # ????????????
- # Tk.encoding_system = 'koi8-u' # ????????????
- when 'KOI8-R'
- Tk.encoding = 'koi8-r'
- Tk.encoding_system = 'koi8-r'
- when 'Shift_JIS'
- begin
- if Tk.encoding_system == 'cp932'
- Tk.encoding = 'cp932'
+
+ 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]
+
+=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.encoding = 'shiftjis'
- Tk.encoding_system = 'shiftjis'
+ tk_enc_name = DEFAULT_TK_ENCODING
+ tksys_enc_name = DEFAULT_TK_ENCODING
end
- rescue StandardError, NameError
- Tk.encoding = 'shiftjis'
- Tk.encoding_system = 'shiftjis'
+ else
+ tk_enc_name = loc_enc_obj.name
+ tksys_enc_name = loc_enc_obj.name
end
- when 'UNICODE'
- Tk.encoding = 'unicode'
- Tk.encoding_system = 'unicode'
- when 'UTF-8'
- Tk.encoding = 'utf-8'
- Tk.encoding_system = 'utf-8'
- else ###### 'ASCII-8BIT'
- if defined? DEFAULT_TK_ENCODING
- Tk.encoding_system = DEFAULT_TK_ENCODING
+ else
+ tk_enc_name = ext_enc_obj.name
+ tksys_enc_name = ext_enc_obj.name
+ end
+
+ # Tk.encoding = tk_enc_name
+ Tk.default_encoding = tk_enc_name
+ Tk.encoding_system = tksys_enc_name
+=end
+
+ 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
end
+ else
begin
- Tk.encoding = Tk.encoding_system
- rescue StandardError, NameError
- Tk.encoding = 'utf-8'
- Tk.encoding_system = 'utf-8'
+ 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
end
end
- end
-else
- # dummy methods
- class TclTkIp
- attr_accessor :encoding
+ # setup Tk.encoding
+ enc_name = nil
- alias __eval _eval
- alias __invoke _invoke
+ 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
- alias _eval_with_enc _eval
- alias _invoke_with_enc _invoke
+ 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
+ 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
+ end
+ end
+
+ Tk.default_encoding = (enc_name)? enc_name: tksys_enc_name
end
+else
+ # dummy methods
module Tk
module Encoding
extend Encoding
+ def force_default_encoding=(mode)
+ nil
+ end
+
+ def force_default_encoding?
+ nil
+ end
+
+ def default_encoding=(enc)
+ nil
+ end
+ def default_encoding
+ nil
+ end
+
def encoding=(name)
nil
end
@@ -2615,6 +3113,16 @@ 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
@@ -2737,7 +3245,15 @@ module TkTreatFont
next
else
fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ else
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ rescue
+ # ignore
+ end
+ end
end
end
next
@@ -2791,7 +3307,15 @@ module TkTreatFont
fobj = fontobj # create a new TkFont object
else
ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ 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
next
end
@@ -2843,7 +3367,15 @@ module TkTreatFont
fobj = fontobj # create a new TkFont object
else
knj = hash_kv(knj) if knj.kind_of?(Hash)
- tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ 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
next
end
@@ -2944,6 +3476,14 @@ 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
@@ -2965,6 +3505,11 @@ module TkConfigMethod
end
private :__configinfo_struct
+ def __optkey_aliases
+ {}
+ end
+ private :__optkey_aliases
+
def __numval_optkeys
[]
end
@@ -3071,7 +3616,7 @@ module TkConfigMethod
val
end
- def cget(slot)
+ def __cget_core(slot)
orig_slot = slot
slot = slot.to_s
@@ -3079,6 +3624,11 @@ 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
@@ -3147,11 +3697,41 @@ module TkConfigMethod
tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{slot}")), true)
end
end
+ private :__cget_core
- def configure(slot, value=None)
+ 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)
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
@@ -3188,6 +3768,11 @@ 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
@@ -3211,12 +3796,55 @@ 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(slot = nil)
+ def __configinfo_core(slot = nil)
if TkComm::GET_CONFIGINFO_AS_ARRAY
if (slot &&
slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
@@ -3227,6 +3855,10 @@ 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 \
@@ -3238,6 +3870,12 @@ 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]
@@ -3563,6 +4201,11 @@ 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
@@ -3587,6 +4230,10 @@ 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] \
@@ -3602,6 +4249,12 @@ 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]
@@ -3934,6 +4587,11 @@ 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
@@ -3948,6 +4606,19 @@ 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
@@ -4047,7 +4718,12 @@ class TkObject<TkKernel
begin
cget(name)
rescue
- super(id, *args)
+ if self.kind_of?(TkWindow)
+ fail NameError,
+ "unknown option '#{id}' for #{self.inspect} (deleted widget?)"
+ else
+ super(id, *args)
+ end
# fail NameError,
# "undefined local variable or method `#{name}' for #{self.to_s}",
# error_at
@@ -4102,6 +4778,15 @@ 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),
@@ -4165,6 +4850,13 @@ 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)
@@ -4197,7 +4889,33 @@ class TkWindow<TkObject
end
if keys and keys != None
- tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
+ 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
else
tk_call_without_enc(cmd, @path)
end
@@ -4205,8 +4923,12 @@ class TkWindow<TkObject
private :create_self
def inspect
- str = super
- str[0..(str.index(' '))] << '@path=' << @path.inspect << '>'
+ if @@WIDGET_INSPECT_FULL
+ super
+ else
+ str = super
+ str[0..(str.index(' '))] << '@path=' << @path.inspect << '>'
+ end
end
def exist?
@@ -4330,6 +5052,15 @@ 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)
@@ -4361,12 +5092,14 @@ 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
@@ -4609,11 +5342,13 @@ class TkWindow<TkObject
end
children.each{|path, obj|
- if defined?(@cmdtbl)
- for id in @cmdtbl
- uninstall_cmd id
+ obj.instance_eval{
+ if defined?(@cmdtbl)
+ for id in @cmdtbl
+ uninstall_cmd id
+ end
end
- end
+ }
TkCore::INTERP.tk_windows.delete(path)
}
@@ -4718,6 +5453,7 @@ class TkWindow<TkObject
bindtags(bindtags().unshift(tag))
end
end
+TkWidget = TkWindow
# freeze core modules
#TclTkLib.freeze
@@ -4730,7 +5466,7 @@ end
#Tk.freeze
module Tk
- RELEASE_DATE = '2007-12-21'.freeze
+ RELEASE_DATE = '2008-05-23'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'
diff --git a/ext/tk/lib/tk/autoload.rb b/ext/tk/lib/tk/autoload.rb
index ace0787fc2..0773f7708d 100644
--- a/ext/tk/lib/tk/autoload.rb
+++ b/ext/tk/lib/tk/autoload.rb
@@ -1,21 +1,7 @@
#
# autoload
#
-major, minor, type, type_name, patchlevel = TclTkLib.get_version
-
-######################################
-# depend on version of Tcl/Tk
-if major > 8 ||
- (major == 8 && minor > 5) ||
- (major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA)
- # Tcl/Tk 8.5 beta or later
- autoload :Ttk, 'tkextlib/tile'
- module Tk
- autoload :Tile, 'tkextlib/tile'
- end
-end
-
-######################################
+############################################
# geometry manager
module Tk
autoload :Grid, 'tk/grid'
@@ -38,12 +24,7 @@ autoload :TkPlace, 'tk/place'
def TkPlace(*args); TkPlace.configure(*args); end
-######################################
-# Ttk (Tile) support
-require 'tk/ttk_selector'
-
-
-######################################
+############################################
# classes on Tk module
module Tk
autoload :Button, 'tk/button'
@@ -66,12 +47,15 @@ module Tk
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'
@@ -97,7 +81,7 @@ module Tk
end
-######################################
+############################################
# sub-module of Tk
module Tk
autoload :Clock, 'tk/clock'
@@ -109,6 +93,7 @@ module Tk
autoload :Scrollable, 'tk/scrollable'
autoload :Wm, 'tk/wm'
+ autoload :Wm_for_General, 'tk/wm'
autoload :MacResource, 'tk/macpkg'
@@ -129,184 +114,301 @@ module Tk
end
-######################################
-# toplevel classes/modules
-autoload_list = {
- :TkBgError => 'tk/bgerror',
- :TkBindTag => 'tk/bindtag',
- :TkBindTagAll => 'tk/bindtag',
- :TkDatabaseClass => 'tk/bindtag',
+############################################
+# toplevel classes/modules (fixed)
+autoload :TkBgError, 'tk/bgerror'
+
+autoload :TkBindTag, 'tk/bindtag'
+autoload :TkBindTagAll, 'tk/bindtag'
+autoload :TkDatabaseClass, 'tk/bindtag'
+
+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 :TkcTagAccess, 'tk/canvastag'
+autoload :TkcTag, 'tk/canvastag'
+autoload :TkcTagString, 'tk/canvastag'
+autoload :TkcNamedTag, 'tk/canvastag'
+autoload :TkcTagAll, 'tk/canvastag'
+autoload :TkcTagCurrent, 'tk/canvastag'
+autoload :TkcTagGroup, 'tk/canvastag'
+
+autoload :TkClipboard, 'tk/clipboard'
+
+autoload :TkComposite, 'tk/composite'
+
+autoload :TkConsole, 'tk/console'
+
+autoload :TkDialog, 'tk/dialog'
+autoload :TkDialog2, 'tk/dialog'
+autoload :TkDialogObj, 'tk/dialog'
+autoload :TkWarning, 'tk/dialog'
+autoload :TkWarning2, 'tk/dialog'
+autoload :TkWarningObj, 'tk/dialog'
+
+autoload :TkEvent, 'tk/event'
+
+autoload :TkFont, 'tk/font'
+autoload :TkNamedFont, 'tk/font'
+
+autoload :TkImage, 'tk/image'
+autoload :TkBitmapImage, 'tk/image'
+autoload :TkPhotoImage, 'tk/image'
+
+autoload :TkItemConfigMethod, 'tk/itemconfig'
- :TkButton => 'tk/button',
+autoload :TkTreatItemFont, 'tk/itemfont'
- :TkCanvas => 'tk/canvas',
+autoload :TkKinput, 'tk/kinput'
- :TkcItem => 'tk/canvas',
- :TkcArc => 'tk/canvas',
- :TkcBitmap => 'tk/canvas',
- :TkcImage => 'tk/canvas',
- :TkcLine => 'tk/canvas',
- :TkcOval => 'tk/canvas',
- :TkcPolygon => 'tk/canvas',
- :TkcRectangle => 'tk/canvas',
- :TkcText => 'tk/canvas',
- :TkcWindow => 'tk/canvas',
+autoload :TkSystemMenu, 'tk/menu'
- :TkcTagAccess => 'tk/canvastag',
- :TkcTag => 'tk/canvastag',
- :TkcTagString => 'tk/canvastag',
- :TkcNamedTag => 'tk/canvastag',
- :TkcTagAll => 'tk/canvastag',
- :TkcTagCurrent => 'tk/canvastag',
- :TkcTagGroup => 'tk/canvastag',
+autoload :TkMenubar, 'tk/menubar'
- :TkCheckButton => 'tk/checkbutton',
- :TkCheckbutton => 'tk/checkbutton',
+autoload :TkMenuSpec, 'tk/menuspec'
- :TkClipboard => 'tk/clipboard',
+autoload :TkManageFocus, 'tk/mngfocus'
- :TkComposite => 'tk/composite',
+autoload :TkMsgCatalog, 'tk/msgcat'
+autoload :TkMsgCat, 'tk/msgcat'
- :TkConsole => 'tk/console',
+autoload :TkNamespace, 'tk/namespace'
- :TkDialog => 'tk/dialog',
- :TkDialog2 => 'tk/dialog',
- :TkDialogObj => 'tk/dialog',
- :TkWarning => 'tk/dialog',
- :TkWarning2 => 'tk/dialog',
- :TkWarningObj => 'tk/dialog',
+autoload :TkOptionDB, 'tk/optiondb'
+autoload :TkOption, 'tk/optiondb'
+autoload :TkResourceDB, 'tk/optiondb'
- :TkEntry => 'tk/entry',
+autoload :TkPackage, 'tk/package'
- :TkEvent => 'tk/event',
+autoload :TkPalette, 'tk/palette'
- :TkFont => 'tk/font',
- :TkTreatTagFont => 'tk/font',
+autoload :TkRoot, 'tk/root'
- :TkFrame => 'tk/frame',
+autoload :TkScrollbox, 'tk/scrollbox'
- :TkImage => 'tk/image',
- :TkBitmapImage => 'tk/image',
- :TkPhotoImage => 'tk/image',
+autoload :TkSelection, 'tk/selection'
- :TkItemConfigMethod => 'tk/itemconfig',
+autoload :TkTreatTagFont, 'tk/tagfont'
- :TkTreatItemFont => 'tk/itemfont',
+autoload :TkTextImage, 'tk/textimage'
+autoload :TktImage, 'tk/textimage'
- :TkKinput => 'tk/kinput',
+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'
- :TkLabel => 'tk/label',
+autoload :TkTextTag, 'tk/texttag'
+autoload :TkTextNamedTag, 'tk/texttag'
+autoload :TkTextTagSel, 'tk/texttag'
+autoload :TktTag, 'tk/texttag'
+autoload :TktNamedTag, 'tk/texttag'
+autoload :TktTagSel, 'tk/texttag'
- :TkLabelFrame => 'tk/labelframe',
- :TkLabelframe => 'tk/labelframe',
+autoload :TkTextWindow, 'tk/textwindow'
+autoload :TktWindow, 'tk/textwindow'
- :TkListbox => 'tk/listbox',
+autoload :TkAfter, 'tk/timer'
+autoload :TkTimer, 'tk/timer'
+autoload :TkRTTimer, 'tk/timer'
- :TkMacResource => 'tk/macpkg',
+autoload :TkTextWin, 'tk/txtwin_abst'
- :TkMenu => 'tk/menu',
- :TkMenuClone => 'tk/menu',
- :TkSystemMenu => 'tk/menu',
- :TkSysMenu_Help => 'tk/menu',
- :TkSysMenu_System => 'tk/menu',
- :TkSysMenu_Apple => 'tk/menu',
- :TkMenubutton => 'tk/menu',
- :TkOptionMenubutton => 'tk/menu',
+autoload :TkValidation, 'tk/validation'
+autoload :TkValidateCommand, 'tk/validation'
- :TkMenubar => 'tk/menubar',
+autoload :TkVariable, 'tk/variable'
+autoload :TkVarAccess, 'tk/variable'
- :TkMenuSpec => 'tk/menuspec',
+autoload :TkVirtualEvent, 'tk/virtevent'
+autoload :TkNamedVirtualEvent,'tk/virtevent'
- :TkMessage => 'tk/message',
+autoload :TkWinfo, 'tk/winfo'
- :TkManageFocus => 'tk/mngfocus',
+autoload :TkXIM, 'tk/xim'
- :TkMsgCatalog => 'tk/msgcat',
- :TkMsgCat => 'tk/msgcat',
- :TkNamespace => 'tk/namespace',
+############################################
+# toplevel classes/modules (switchable)
+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',
- :TkOptionDB => 'tk/optiondb',
- :TkOption => 'tk/optiondb',
- :TkResourceDB => 'tk/optiondb',
+ :TkLabel => 'tk/label',
- :TkPackage => 'tk/package',
+ :TkLabelFrame => 'tk/labelframe',
+ :TkLabelframe => 'tk/labelframe',
- :TkPalette => 'tk/palette',
+ :TkListbox => 'tk/listbox',
- :TkPanedWindow => 'tk/panedwindow',
- :TkPanedwindow => 'tk/panedwindow',
+ :TkMacResource => 'tk/macpkg',
- :TkRadioButton => 'tk/radiobutton',
- :TkRadiobutton => 'tk/radiobutton',
+ :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',
- :TkRoot => 'tk/root',
+ :TkMessage => 'tk/message',
- :TkScale => 'tk/scale',
+ :TkPanedWindow => 'tk/panedwindow',
+ :TkPanedwindow => 'tk/panedwindow',
- :TkScrollbar => 'tk/scrollbar',
- :TkXScrollbar => 'tk/scrollbar',
- :TkYScrollbar => 'tk/scrollbar',
+ :TkRadioButton => 'tk/radiobutton',
+ :TkRadiobutton => 'tk/radiobutton',
- :TkScrollbox => 'tk/scrollbox',
+ # :TkRoot => 'tk/root',
- :TkSelection => 'tk/selection',
+ :TkScale => 'tk/scale',
- :TkSpinbox => 'tk/spinbox',
+ :TkScrollbar => 'tk/scrollbar',
+ :TkXScrollbar => 'tk/scrollbar',
+ :TkYScrollbar => 'tk/scrollbar',
- :TkTreatTagFont => 'tk/tagfont',
+ :TkSpinbox => 'tk/spinbox',
- :TkText => 'tk/text',
+ :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
- :TkTextImage => 'tk/textimage',
- :TktImage => 'tk/textimage',
- :TkTextMark => 'tk/textmark',
- :TkTextNamedMark => 'tk/textmark',
- :TkTextMarkInsert => 'tk/textmark',
- :TkTextMarkCurrent => 'tk/textmark',
- :TkTextMarkAnchor => 'tk/textmark',
- :TktMark => 'tk/textmark',
- :TktNamedMark => 'tk/textmark',
- :TktMarkInsert => 'tk/textmark',
- :TktMarkCurrent => 'tk/textmark',
- :TktMarkAnchor => 'tk/textmark',
+############################################
+# methods to control default widget set
+############################################
- :TkTextTag => 'tk/texttag',
- :TkTextNamedTag => 'tk/texttag',
- :TkTextTagSel => 'tk/texttag',
- :TktTag => 'tk/texttag',
- :TktNamedTag => 'tk/texttag',
- :TktTagSel => 'tk/texttag',
+class << Tk
+ def default_widget_set
+ @current_default_widget_set
+ end
- :TkTextWindow => 'tk/textwindow',
- :TktWindow => 'tk/textwindow',
+ def default_widget_set=(target)
+ target = target.to_sym
+ return target if target == @current_default_widget_set
- :TkAfter => 'tk/timer',
- :TkTimer => 'tk/timer',
- :TkRTTimer => 'tk/timer',
+ if (cmd = @TOPLEVEL_ALIAS_SETUP_PROC[target])
+ cmd.call(target)
+ end
- :TkToplevel => 'tk/toplevel',
+ _replace_toplevel_aliases(target)
+ end
- :TkTextWin => 'tk/txtwin_abst',
+ 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
- :TkValidation => 'tk/validation',
+ ###################################
+ 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
- :TkVariable => 'tk/variable',
- :TkVarAccess => 'tk/variable',
+############################################
+# setup default widget set => :Tk
+Tk.default_widget_set = :Tk
- :TkVirtualEvent => 'tk/virtevent',
- :TkNamedVirtualEvent => 'tk/virtevent',
- :TkWinfo => 'tk/winfo',
+############################################
+# depend on the version of Tcl/Tk
+# major, minor, type, type_name, patchlevel = TclTkLib.get_version
- :TkWinDDE => 'tk/winpkg',
- :TkWinRegistry => 'tk/winpkg',
+############################################
+# 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'
- :TkXIM => 'tk/xim',
-}
-autoload_list.each{|mod, lib|
- #autoload mod, lib unless
- autoload mod, lib unless (Object.const_defined? mod) && (autoload? mod)
-}
+ require 'tk/ttk_selector'
+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 9023a08e06..88c8367a88 100644
--- a/ext/tk/lib/tk/bindtag.rb
+++ b/ext/tk/lib/tk/bindtag.rb
@@ -8,30 +8,64 @@ class TkBindTag
#BTagID_TBL = {}
BTagID_TBL = TkCore::INTERP.create_table
- Tk_BINDTAG_ID = ["btag".freeze, "00000".taint].freeze
- TkCore::INTERP.init_ip_env{ BTagID_TBL.clear }
+ (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 }
+ }
def TkBindTag.id2obj(id)
- BTagID_TBL[id]? BTagID_TBL[id]: id
+ BTagID_TBL.mutex.synchronize{
+ (BTagID_TBL[id])? BTagID_TBL[id]: id
+ }
end
+=begin
def TkBindTag.new_by_name(name, *args, &b)
- return BTagID_TBL[name] if BTagID_TBL[name]
+ BTagID_TBL.mutex.synchronize{
+ return BTagID_TBL[name] if BTagID_TBL[name]
+ }
+
self.new.instance_eval{
- BTagID_TBL.delete @id
- @id = name
- BTagID_TBL[@id] = self
+ BTagID_TBL.mutex.synchronize{
+ 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)
- # @id = Tk_BINDTAG_ID.join('')
- @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
- Tk_BINDTAG_ID[1].succ!
- BTagID_TBL[@id] = self
+ 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
+ }
bind(*args, &b) if args != []
end
@@ -63,14 +97,37 @@ end
class TkDatabaseClass<TkBindTag
+=begin
def self.new(name, *args, &b)
- return BTagID_TBL[name] if BTagID_TBL[name]
+ BTagID_TBL.mutex.synchronize{
+ return BTagID_TBL[name] if BTagID_TBL[name]
+ }
super(name, *args, &b)
end
def initialize(name, *args, &b)
@id = name
- BTagID_TBL[@id] = self
+ 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
bind(*args, &b) if args != []
end
diff --git a/ext/tk/lib/tk/button.rb b/ext/tk/lib/tk/button.rb
index 04454cc6f7..770a5785bb 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<TkLabel
+class Tk::Button<Tk::Label
TkCommandNames = ['button'.freeze].freeze
WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -26,4 +26,5 @@ class Tk::Button<TkLabel
end
end
-TkButton = Tk::Button unless Object.const_defined? :TkButton
+#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 70cace3382..36ea008a17 100644
--- a/ext/tk/lib/tk/canvas.rb
+++ b/ext/tk/lib/tk/canvas.rb
@@ -1,6 +1,5 @@
#
# tk/canvas.rb - Tk canvas classes
-# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
@@ -169,6 +168,8 @@ 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 == []
@@ -186,11 +187,17 @@ class Tk::Canvas<TkWindow
end
def delete(*args)
- if TkcItem::CItemID_TBL[self.path]
+ tbl = nil
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl = TkcItem::CItemID_TBL[self.path]
+ }
+ if tbl
args.each{|tag|
find('withtag', tag).each{|item|
if item.kind_of?(TkcItem)
- TkcItem::CItemID_TBL[self.path].delete(item.id)
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl.delete(item.id)
+ }
end
}
}
@@ -573,7 +580,8 @@ class Tk::Canvas<TkWindow
end
end
-TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas
+#TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas
+Tk.__set_toplevel_aliases__(:Tk, Tk::Canvas, :TkCanvas)
class TkcItem<TkObject
@@ -584,9 +592,12 @@ class TkcItem<TkObject
CItemTypeName = nil
CItemTypeToClass = {}
+
CItemID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ CItemID_TBL.clear }
+ TkCore::INTERP.init_ip_env{
+ CItemID_TBL.mutex.synchronize{ CItemID_TBL.clear }
+ }
def TkcItem.type2class(type)
CItemTypeToClass[type]
@@ -594,8 +605,13 @@ class TkcItem<TkObject
def TkcItem.id2obj(canvas, id)
cpath = canvas.path
- return id unless CItemID_TBL[cpath]
- CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
+ CItemID_TBL.mutex.synchronize{
+ if CItemID_TBL[cpath]
+ CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
end
########################################
@@ -628,6 +644,13 @@ 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)
@@ -661,15 +684,17 @@ class TkcItem<TkObject
########################################
def initialize(parent, *args)
- #unless parent.kind_of?(TkCanvas)
- # fail ArgumentError, "expect TkCanvas for 1st argument"
+ #unless parent.kind_of?(Tk::Canvas)
+ # fail ArgumentError, "expect Tk::Canvas for 1st argument"
#end
@parent = @c = parent
@path = parent.path
@id = create_self(*args) # an integer number as 'canvas item id'
- CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
- CItemID_TBL[@path][@id] = self
+ CItemID_TBL.mutex.synchronize{
+ 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'
@@ -690,7 +715,9 @@ class TkcItem<TkObject
def delete
@c.delete @id
- CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ CItemID_TBL.mutex.synchronize{
+ 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 a5650ee68b..49796d80b2 100644
--- a/ext/tk/lib/tk/canvastag.rb
+++ b/ext/tk/lib/tk/canvastag.rb
@@ -63,6 +63,9 @@ 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)
@@ -199,14 +202,26 @@ class TkcTag<TkObject
include TkcTagAccess
CTagID_TBL = TkCore::INTERP.create_table
- Tk_CanvasTag_ID = ['ctag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ CTagID_TBL.clear }
+ (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 }
+ }
def TkcTag.id2obj(canvas, id)
cpath = canvas.path
- return id unless CTagID_TBL[cpath]
- CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
+ CTagID_TBL.mutex.synchronize{
+ if CTagID_TBL[cpath]
+ CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(parent, mode=nil, *args)
@@ -215,11 +230,15 @@ class TkcTag<TkObject
#end
@c = parent
@cpath = parent.path
- # @path = @id = Tk_CanvasTag_ID.join('')
- @path = @id = Tk_CanvasTag_ID.join(TkCore::INTERP._ip_id_)
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- Tk_CanvasTag_ID[1].succ!
+ 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
+ }
if mode
tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
end
@@ -238,7 +257,9 @@ class TkcTag<TkObject
def delete
@c.delete @id
- CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
+ }
self
end
alias remove delete
@@ -288,23 +309,38 @@ class TkcTag<TkObject
end
class TkcTagString<TkcTag
- def self.new(parent, name, *args)
- if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name]
- return CTagID_TBL[parent.path][name]
- else
- super(parent, name, *args)
+ 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)
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
@@ -312,7 +348,11 @@ class TkcTagString<TkcTag
end
TkcNamedTag = TkcTagString
-class TkcTagAll<TkcTag
+class TkcTagAll<TkcTagString
+ def self.new(parent)
+ super(parent, 'all')
+ end
+=begin
def initialize(parent)
#unless parent.kind_of?(TkCanvas)
# fail ArgumentError, "expect TkCanvas for 1st argument"
@@ -320,12 +360,19 @@ class TkcTagAll<TkcTag
@c = parent
@cpath = parent.path
@path = @id = 'all'
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ }
end
+=end
end
-class TkcTagCurrent<TkcTag
+class TkcTagCurrent<TkcTagString
+ def self.new(parent)
+ super(parent, 'current')
+ end
+=begin
def initialize(parent)
#unless parent.kind_of?(TkCanvas)
# fail ArgumentError, "expect TkCanvas for 1st argument"
@@ -333,13 +380,21 @@ class TkcTagCurrent<TkcTag
@c = parent
@cpath = parent.path
@path = @id = 'current'
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
+ CTagID_TBL.mutex.synchronize{
+ 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].freeze
+ (Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
#def create_self(parent, *args)
def initialize(parent, *args)
#unless parent.kind_of?(TkCanvas)
@@ -347,11 +402,15 @@ class TkcGroup<TkcTag
#end
@c = parent
@cpath = parent.path
- # @path = @id = Tk_cGroup_ID.join('')
- @path = @id = Tk_cGroup_ID.join(TkCore::INTERP._ip_id_)
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- Tk_cGroup_ID[1].succ!
+ 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
+ }
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 40d502ebf7..b1186a87ed 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<TkRadioButton
+class Tk::CheckButton<Tk::RadioButton
TkCommandNames = ['checkbutton'.freeze].freeze
WidgetClassName = 'Checkbutton'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -24,5 +24,7 @@ class Tk::CheckButton<TkRadioButton
end
Tk::Checkbutton = Tk::CheckButton
-TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton
-TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton
+#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)
diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb
index d3dad4d268..883d43c3ea 100644
--- a/ext/tk/lib/tk/composite.rb
+++ b/ext/tk/lib/tk/composite.rb
@@ -34,7 +34,8 @@ module TkComposite
if klass
# WidgetClassName is a known class
- if klass <= TkFrame || klass < TkComposite
+ #if klass <= TkFrame || klass < TkComposite
+ if klass <= TkFrame || klass < Tk::Frame || klass < TkComposite
# klass is valid for the base frame
if self.class <= klass
# use my classname
@@ -50,7 +51,8 @@ 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 < TkComposite
+ if self.class < TkFrame || self.class.superclass < Tk::Frame || 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 == ''
@@ -69,7 +71,8 @@ module TkComposite
else
# no valid WidgetClassName
- if self.class < TkFrame || self.class.superclass < TkComposite
+ #if self.class < TkFrame || self.class.superclass < TkComposite
+ if self.class < TkFrame || self.class.superclass < Tk::Frame || 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 == ''
@@ -108,8 +111,12 @@ 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
@@ -174,6 +181,57 @@ 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
@@ -205,6 +263,7 @@ 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 797e514a4c..02de0b0d85 100644
--- a/ext/tk/lib/tk/encodedstr.rb
+++ b/ext/tk/lib/tk/encodedstr.rb
@@ -70,13 +70,89 @@ module Tk
# @encoding = ( enc ||
# ((self.class::Encoding)?
# self.class::Encoding : Tk.encoding_system) )
- @encoding = ( enc ||
- ((self.class::Encoding)?
+ enc ||= (self.class::Encoding)?
self.class::Encoding :
- ((Tk.encoding)? Tk.encoding : Tk.encoding_system) ) )
+ ((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
end
- attr_reader :encoding
+ 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
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 2b55a0cafb..8ce8def1e7 100644
--- a/ext/tk/lib/tk/entry.rb
+++ b/ext/tk/lib/tk/entry.rb
@@ -1,6 +1,5 @@
#
# tk/entry.rb - Tk entry classes
-# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
@@ -8,7 +7,7 @@ require 'tk/label'
require 'tk/scrollable'
require 'tk/validation'
-class Tk::Entry<TkLabel
+class Tk::Entry<Tk::Label
include X_Scrollable
include TkValidation
@@ -116,4 +115,5 @@ class Tk::Entry<TkLabel
end
end
-TkEntry = Tk::Entry unless Object.const_defined? :TkEntry
+#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 70a1e38bbe..d8aad6248b 100644
--- a/ext/tk/lib/tk/event.rb
+++ b/ext/tk/lib/tk/event.rb
@@ -39,7 +39,9 @@ module TkEvent
RESIZEREQ = 0x200000
CIRCREQ = 0x400000
- MWHEEL = 0x10000000
+ MWHEEL = KEY
+
+ STRING_DATA = 0x80000000 # special flag for 'data' field
ALL = 0xFFFFFFFF
@@ -155,7 +157,7 @@ module TkEvent
'borderwidth' => (Grp::CREATE|Grp::CONFIG),
'button' => Grp::BUTTON,
'count' => Grp::EXPOSE,
- 'data' => Grp::VIRTUAL,
+ 'data' => (Grp::VIRTUAL|Grp::STRING_DATA),
'delta' => Grp::MWHEEL,
'detail' => (Grp::FOCUS|Grp::CROSSING),
'focus' => Grp::CROSSING,
@@ -223,7 +225,8 @@ module TkEvent
rescue
next
end
- next if !val || val == '??'
+ # next if !val || val == '??'
+ next if !val || (val == '??' && (flag & Grp::STRING_DATA))
fields[key] = val
}
@@ -298,34 +301,65 @@ 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) ],
@@ -345,6 +379,24 @@ 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
@@ -357,7 +409,8 @@ 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, PROC_TBL)
+ # _setup_subst_table(KEY_TBL, LONGKEY_TBL, PROC_TBL) # if use longname-keys
#
# NOTE: The order of parameters which passed to callback procedure is
@@ -405,6 +458,7 @@ 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 ab58ac5762..62d628c132 100644
--- a/ext/tk/lib/tk/font.rb
+++ b/ext/tk/lib/tk/font.rb
@@ -11,13 +11,18 @@ class TkFont
TkCommandNames = ['font'.freeze].freeze
- Tk_FontID = ["@font".freeze, "00000".taint].freeze
+ (Tk_FontID = ["@font".freeze, "00000".taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
Tk_FontNameTBL = TkCore::INTERP.create_table
Tk_FontUseTBL = TkCore::INTERP.create_table
TkCore::INTERP.init_ip_env{
- Tk_FontNameTBL.clear
- Tk_FontUseTBL.clear
+ Tk_FontNameTBL.mutex.synchronize{ Tk_FontNameTBL.clear }
+ Tk_FontUseTBL.mutex.synchronize{ Tk_FontUseTBL.clear }
}
# option_type : default => string
@@ -31,13 +36,26 @@ 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\.*/
+ when /^8\.[0-4]/
if JAPANIZED_TK
begin
fontnames = tk_call('font', 'names')
@@ -103,6 +121,15 @@ 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
@@ -121,6 +148,7 @@ 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'
@@ -145,6 +173,9 @@ 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)
@@ -163,6 +194,14 @@ 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)
@@ -171,6 +210,9 @@ 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 == ''
@@ -181,6 +223,9 @@ 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)
@@ -234,6 +279,33 @@ 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 == ''
@@ -244,13 +316,40 @@ 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
@@ -261,13 +360,16 @@ class TkFont
def TkFont.names
case (Tk::TK_VERSION)
- when /^4\.*/
+ when /^4\..*/
r = ['fixed']
r += ['a14', 'k14'] if JAPANIZED_TK
- Tk_FontNameTBL.each_value{|obj| r.push(obj)}
- r | []
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL.each_value{|obj| r.push(obj)}
+ }
+ #r | []
+ r.uniq
- when /^8\.*/
+ when /^8\..*/
tk_split_simplelist(tk_call('font', 'names'))
end
@@ -285,10 +387,15 @@ class TkFont
end
def TkFont.get_obj(name)
+ name = name.to_s
if name =~ /^(@font[0-9]+)(|c|l|k)$/
- Tk_FontNameTBL[$1]
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL[$1]
+ }
else
- nil
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL[name]
+ }
end
end
@@ -298,7 +405,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)).
@@ -324,7 +431,7 @@ class TkFont
TkFont.new(ltn, knj).call_font_configure([path, key], *args)
- when /^8\.*/
+ when /^8\.[0-4]/
regexp = /^-#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
@@ -360,26 +467,66 @@ class TkFont
compound = []
end
if compound == []
- TkFont.new(fnt).call_font_configure([path, key], *args)
+ 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
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)
- if path
- Tk_FontUseTBL[path]
- else
- Tk_FontUseTBL.values | []
- end
+ Tk_FontUseTBL.mutex.synchronize{
+ if path
+ Tk_FontUseTBL[path]
+ else
+ # Tk_FontUseTBL.values | []
+ Tk_FontUseTBL.values.uniq
+ 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
@@ -392,15 +539,20 @@ class TkFont
private
###################################
def init_dummy_fontobj
- @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
- Tk_FontID[1].succ!
- Tk_FontNameTBL[@id] = self
+ Tk_FontID.mutex.synchronize{
+ @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
+ # @latin_desscendant = nil
+ # @kanji_desscendant = nil
+ @descendant = [nil, nil] # [latin, kanji]
case (Tk::TK_VERSION)
- when /^4\.*/
+ when /^4\..*/
@latinfont = ""
@kanjifont = ""
if JAPANIZED_TK
@@ -436,13 +588,23 @@ class TkFont
ltn = '{}' if ltn == ''
knj = '{}' if knj == ''
- # @id = Tk_FontID.join('')
- @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
- Tk_FontID[1].succ!
- Tk_FontNameTBL[@id] = self
+ 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]
- @latin_desscendant = nil
- @kanji_desscendant = nil
+ # @latinfont = @id + 'l'
+ # @kanjifont = @id + 'k'
+ # @compoundfont = @id + 'c'
+ # @fontslot = {}
if knj.kind_of?(Hash) && !keys
keys = knj
@@ -474,7 +636,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
@@ -625,9 +787,14 @@ 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
@@ -753,6 +920,7 @@ class TkFont
end
@fontslot = {'font'=>@compoundfont}
+ # @fontslot['font'] = @compoundfont
begin
tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys))
@@ -833,6 +1001,7 @@ class TkFont
end
@fontslot = {'font'=>@compoundfont}
+ # @fontslot['font'] = @compoundfont
tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
end
end
@@ -887,25 +1056,39 @@ class TkFont
keys = _symbolkey2str(args.pop).update(fontslot)
args.concat(hash_kv(keys))
- tk_call(*args)
- Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
+ 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
+ }
self
end
def used
ret = []
- Tk_FontUseTBL.each{|key,value|
+ table = nil
+ Tk_FontUseTBL.mutex.synchronize{
+ table = Tk_FontUseTBL.clone # to avoid deadlock
+ }
+ table.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
+ if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
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
+ elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
if optkey
ret.push([winobj, tagobj, optkey])
@@ -925,7 +1108,8 @@ class TkFont
ret.push([winobj, tag])
end
end
- elsif winobj.kind_of? TkMenu
+ #elsif winobj.kind_of? TkMenu
+ elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
if optkey
ret.push([winobj, tag, optkey])
else
@@ -957,6 +1141,8 @@ class TkFont
@compoundfont
end
alias font_id font
+ alias name font
+ alias to_s font
def latin_font_id
@latinfont
@@ -964,11 +1150,18 @@ 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
@@ -978,50 +1171,87 @@ 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)
- actual_core(@latinfont, nil, option)
+ 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)]
end
def latin_actual_displayof(win, option=nil)
win = '.' unless win
- actual_core(@latinfont, win, option)
+ 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)]
end
def kanji_actual(option=nil)
#if JAPANIZED_TK
- if @kanjifont != ""
+ if @kanjifont == nil
+ actual_core(@compoundfont, nil, option) # use @compoundfont
+ elsif @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 != ""
+ if @kanjifont == nil
+ actual_core(@compoundfont, nil, option) # use @compoundfont
+ elsif @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
@@ -1065,10 +1295,15 @@ 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 != ""
+ if @kanjifont == nil
+ configure_core(@compoundfont, slot, value) # use @compoundfont
+ elsif @kanjifont != ""
configure_core(@kanjifont, slot, value)
configure('size'=>configinfo('size')) # to reflect new configuration
else
@@ -1080,13 +1315,18 @@ class TkFont
def kanji_configinfo(slot=nil)
#if JAPANIZED_TK
- if @kanjifont != ""
+ if @kanjifont == nil
+ configure_core(@compoundfont, slot) # use @compoundfont
+ elsif @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
@@ -1096,12 +1336,30 @@ class TkFont
end
def latin_replace(ltn)
- latin_replace_core(ltn)
- reset_pointadjust
+ 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
+
self
end
def kanji_replace(knj)
+ return self unless @kanjifont # ignore
kanji_replace_core(knj)
reset_pointadjust
self
@@ -1119,41 +1377,215 @@ 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)
- metrics_core(@latinfont, nil, option)
+ 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
end
def latin_metrics_displayof(win, option=nil)
win = '.' unless win
- metrics_core(@latinfont, win, option)
+ 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
end
def kanji_metrics(option=nil)
- if JAPANIZED_TK
+ if @latinfont == nil
+ metrics_core(@compoundfont, nil, option) # use @compoundfont
+ elsif 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)
- if JAPANIZED_TK
- win = '.' unless win
+ win = '.' unless win
+ if @latinfont == nil
+ metrics_core(@compoundfont, win, option) # use @compoundfont
+ elsif JAPANIZED_TK
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
@@ -1166,7 +1598,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
@@ -1471,32 +1903,44 @@ module TkFont::CoreMethods
end
def delete_core_tk4x
- TkFont::Tk_FontNameTBL.delete(@id)
- TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
+ TkFont::Tk_FontNameTBL.mutex.synchronize{
+ TkFont::Tk_FontNameTBL.delete(@id)
+ }
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
+ }
end
def delete_core_tk8x
begin
- tk_call('font', 'delete', @latinfont)
+ tk_call('font', 'delete', @latinfont) if @latinfont
rescue
end
begin
- tk_call('font', 'delete', @kanjifont)
+ tk_call('font', 'delete', @kanjifont) if @kanjifont
rescue
end
begin
- tk_call('font', 'delete', @compoundfont)
+ tk_call('font', 'delete', @compoundfont) if @compoundfont
rescue
end
- TkFont::Tk_FontNameTBL.delete(@id)
- TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
+ TkFont::Tk_FontNameTBL.mutex.synchronize{
+ TkFont::Tk_FontNameTBL.delete(@id)
+ }
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ 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
- TkFont::Tk_FontUseTBL.dup.each{|w, fobj|
+ table = nil
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ table = TkFont::Tk_FontUseTBL.clone
+ }
+ table.each{|w, fobj|
if self == fobj
begin
if w.include?(';')
@@ -1504,11 +1948,14 @@ 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
+ if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont)
- elsif winobj.kind_of? TkCanvas
+ #elsif winobj.kind_of? TkCanvas
+ elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont)
- elsif winobj.kind_of? TkMenu
+ #elsif winobj.kind_of? TkMenu
+ elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
else
raise RuntimeError, "unknown widget type"
@@ -1518,7 +1965,9 @@ module TkFont::CoreMethods
tk_call(w, 'configure', '-font', @latinfont)
end
rescue
- TkFont::Tk_FontUseTBL.delete(w)
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete(w)
+ }
end
end
}
@@ -1531,7 +1980,11 @@ module TkFont::CoreMethods
create_kanjifont_tk4x(knj)
@compoundfont[1] = [@kanjifont]
@fontslot['kanjifont'] = @kanjifont
- TkFont::Tk_FontUseTBL.dup.each{|w, fobj|
+ table = nil
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ table = TkFont::Tk_FontUseTBL.clone
+ }
+ table.dup.each{|w, fobj|
if self == fobj
begin
if w.include?(';')
@@ -1539,11 +1992,14 @@ 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
+ if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont)
- elsif winobj.kind_of? TkCanvas
+ #elsif winobj.kind_of? TkCanvas
+ elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont)
- elsif winobj.kind_of? TkMenu
+ #elsif winobj.kind_of? TkMenu
+ elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
else
raise RuntimeError, "unknown widget type"
@@ -1553,7 +2009,9 @@ module TkFont::CoreMethods
tk_call(w, 'configure', '-kanjifont', @kanjifont)
end
rescue
- TkFont::Tk_FontUseTBL.delete(w)
+ Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete(w)
+ }
end
end
}
@@ -1618,8 +2076,11 @@ module TkFont::CoreMethods
rescue
latinkeys = {}
end
- if latinkeys != {}
+ 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
self
@@ -1711,6 +2172,13 @@ 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
@@ -1720,7 +2188,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
@@ -1760,3 +2228,117 @@ 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 471bb3cd00..263b160f29 100644
--- a/ext/tk/lib/tk/frame.rb
+++ b/ext/tk/lib/tk/frame.rb
@@ -127,4 +127,5 @@ class Tk::Frame<TkWindow
end
end
-TkFrame = Tk::Frame unless Object.const_defined? :TkFrame
+#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 10fdf3569b..0dfd7263a7 100644
--- a/ext/tk/lib/tk/grid.rb
+++ b/ext/tk/lib/tk/grid.rb
@@ -22,6 +22,7 @@ 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
@@ -53,6 +54,48 @@ 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)
@@ -61,12 +104,14 @@ 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)
@@ -189,10 +234,10 @@ module TkGrid
list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args)))
end
- module_function :bbox, :forget, :propagate, :info
+ module_function :anchor, :bbox, :add, :forget, :propagate, :info
module_function :remove, :size, :slaves, :location
module_function :grid, :configure, :columnconfigure, :rowconfigure
- module_function :columnconfiginfo, :rowconfiginfo
+ module_function :column, :row, :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 35e2c4e394..dffdc19644 100644
--- a/ext/tk/lib/tk/image.rb
+++ b/ext/tk/lib/tk/image.rb
@@ -10,9 +10,16 @@ class TkImage<TkObject
TkCommandNames = ['image'.freeze].freeze
Tk_IMGTBL = TkCore::INTERP.create_table
- Tk_Image_ID = ['i'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
+ (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 }
+ }
def self.new(keys=nil)
if keys.kind_of?(Hash)
@@ -27,7 +34,10 @@ class TkImage<TkObject
obj = name
else
name = _get_eval_string(name)
- obj = Tk_IMGTBL[name]
+ obj = nil
+ Tk_IMGTBL.mutex.synchronize{
+ obj = Tk_IMGTBL[name]
+ }
end
if obj
if !(keys[:without_creating] || keys['without_creating'])
@@ -43,7 +53,13 @@ class TkImage<TkObject
end
end
end
- super(keys)
+ (obj = self.allocate).instance_eval{
+ Tk_IMGTBL.mutex.synchronize{
+ initialize(keys)
+ Tk_IMGTBL[@path] = self
+ }
+ }
+ obj
end
def initialize(keys=nil)
@@ -55,19 +71,22 @@ class TkImage<TkObject
without_creating = keys.delete('without_creating')
end
unless @path
- # @path = Tk_Image_ID.join('')
- @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
- Tk_Image_ID[1].succ!
+ Tk_Image_ID.mutex.synchronize{
+ # @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.delete(@id) if @id
+ Tk_IMGTBL.mutex.synchronize{
+ Tk_IMGTBL.delete(@id) if @id
+ }
tk_call_without_enc('image', 'delete', @path)
self
end
@@ -85,8 +104,10 @@ class TkImage<TkObject
end
def TkImage.names
- Tk.tk_call_without_enc('image', 'names').split.collect!{|id|
- (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
+ Tk_IMGTBL.mutex.synchronize{
+ Tk.tk_call_without_enc('image', 'names').split.collect!{|id|
+ (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
+ }
}
end
@@ -135,7 +156,7 @@ class TkPhotoImage<TkImage
self
end
- def cget(option)
+ def cget_strict(option)
case option.to_s
when 'data', 'file'
tk_send 'cget', '-' << option.to_s
@@ -143,6 +164,23 @@ 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 a7885e74f3..9c6a98d0f8 100644
--- a/ext/tk/lib/tk/itemconfig.rb
+++ b/ext/tk/lib/tk/itemconfig.rb
@@ -8,6 +8,11 @@ require 'tk/itemfont.rb'
module TkItemConfigOptkeys
include TkUtil
+ def __item_optkey_aliases(id)
+ {}
+ end
+ private :__item_optkey_aliases
+
def __item_numval_optkeys(id)
[]
end
@@ -115,6 +120,14 @@ 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]
@@ -149,7 +162,7 @@ module TkItemConfigMethod
################################################
- def itemcget(tagOrId, option)
+ def __itemcget_core(tagOrId, option)
orig_opt = option
option = option.to_s
@@ -157,6 +170,11 @@ 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
@@ -224,11 +242,45 @@ module TkItemConfigMethod
tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
end
end
+ private :__itemcget_core
- def itemconfigure(tagOrId, slot, value=None)
+ 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)
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
@@ -265,6 +317,11 @@ 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
@@ -288,6 +345,56 @@ 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)
if TkComm::GET_CONFIGINFO_AS_ARRAY
@@ -299,6 +406,10 @@ 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 \
@@ -310,6 +421,12 @@ 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]
@@ -635,6 +752,10 @@ 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
@@ -658,7 +779,11 @@ module TkItemConfigMethod
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
- conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey)
+ 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.shift => conf }
elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
@@ -673,6 +798,12 @@ 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]
@@ -1006,6 +1137,10 @@ 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
@@ -1023,10 +1158,24 @@ module TkItemConfigMethod
private :__itemconfiginfo_core
def itemconfiginfo(tagOrId, slot = nil)
- __itemconfiginfo_core(tagOrId, slot)
+ 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
@@ -1048,6 +1197,7 @@ module TkItemConfigMethod
ret[conf[0]] = conf[-1]
end
}
+
ret
end
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
@@ -1058,4 +1208,8 @@ module TkItemConfigMethod
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 ab9e3ff6c9..4c5c917c57 100644
--- a/ext/tk/lib/tk/itemfont.rb
+++ b/ext/tk/lib/tk/itemfont.rb
@@ -94,7 +94,16 @@ module TkTreatItemFont
*(__item_config_cmd(tagid(tagOrId)) << {}))
next
else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
+ 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
end
end
next
@@ -147,7 +156,16 @@ module TkTreatItemFont
elsif Tk::JAPANIZED_TK
fobj = fontobj # create a new TkFont object
else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
+ 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
next
end
@@ -198,7 +216,16 @@ module TkTreatItemFont
elsif Tk::JAPANIZED_TK
fobj = fontobj # create a new TkFont object
else
- tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
+ 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
next
end
diff --git a/ext/tk/lib/tk/label.rb b/ext/tk/lib/tk/label.rb
index 9904953e81..80b3d778f1 100644
--- a/ext/tk/lib/tk/label.rb
+++ b/ext/tk/lib/tk/label.rb
@@ -17,4 +17,5 @@ class Tk::Label<TkWindow
#private :create_self
end
-TkLabel = Tk::Label unless Object.const_defined? :TkLabel
+#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 e1712889ce..995b5b7e72 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<TkFrame
+class Tk::LabelFrame<Tk::Frame
TkCommandNames = ['labelframe'.freeze].freeze
WidgetClassName = 'Labelframe'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -23,6 +23,7 @@ class Tk::LabelFrame<TkFrame
private :__val2ruby_optkeys
end
-Tk::Labelframe = TkLabelFrame
-TkLabelFrame = Tk::LabelFrame unless Object.const_defined? :TkLabelFrame
-TkLabelframe = Tk::Labelframe unless Object.const_defined? :TkLabelframe
+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)
diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb
index 1937fd22ef..bb039ffb0e 100644
--- a/ext/tk/lib/tk/listbox.rb
+++ b/ext/tk/lib/tk/listbox.rb
@@ -278,4 +278,5 @@ class Tk::Listbox<TkTextWin
=end
end
-TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox
+#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 3975c5255c..67b0a4bb60 100644
--- a/ext/tk/lib/tk/macpkg.rb
+++ b/ext/tk/lib/tk/macpkg.rb
@@ -22,7 +22,8 @@ end
module Tk::MacResource
end
-TkMacResource = Tk::MacResource
+#TkMacResource = Tk::MacResource
+Tk.__set_toplevel_aliases__(:Tk, Tk::MacResource, :TkMacResource)
module Tk::MacResource
extend Tk
diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb
index 1a6c1bd06a..3ae0548dd1 100644
--- a/ext/tk/lib/tk/menu.rb
+++ b/ext/tk/lib/tk/menu.rb
@@ -34,12 +34,13 @@ 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, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
class Tk::Menu<TkWindow
@@ -140,9 +141,9 @@ class Tk::Menu<TkWindow
type = keys.delete('type') if keys.has_key?('type')
if keys.empty?
- TkMenuClone.new(self, parent, type)
+ Tk::MenuClone.new(self, parent, type)
else
- TkMenuClone.new(self, parent, type, keys)
+ Tk::MenuClone.new(self, parent, type, keys)
end
end
@@ -202,6 +203,9 @@ 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
@@ -381,10 +385,11 @@ class Tk::Menu<TkWindow
=end
end
-TkMenu = Tk::Menu unless Object.const_defined? :TkMenu
+#TkMenu = Tk::Menu unless Object.const_defined? :TkMenu
+Tk.__set_toplevel_aliases__(:Tk, Tk::Menu, :TkMenu)
-class Tk::MenuClone<TkMenu
+class Tk::MenuClone<Tk::Menu
=begin
def initialize(parent, type=None)
widgetname = nil
@@ -439,10 +444,11 @@ class Tk::MenuClone<TkMenu
end
end
Tk::CloneMenu = Tk::MenuClone
-TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone
-TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu
+#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)
-module TkSystemMenu
+module Tk::SystemMenu
def initialize(parent, keys=nil)
if parent.kind_of? Hash
keys = _symbolkey2str(parent)
@@ -465,41 +471,60 @@ module TkSystemMenu
end
end
end
+TkSystemMenu = Tk::SystemMenu
-class Tk::SysMenu_Help<TkMenu
+class Tk::SysMenu_Help<Tk::Menu
# for all platform
- include TkSystemMenu
+ include Tk::SystemMenu
SYSMENU_NAME = 'help'
end
-TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help
+#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<TkMenu
+class Tk::SysMenu_System<Tk::Menu
# for Windows
- include TkSystemMenu
+ include Tk::SystemMenu
SYSMENU_NAME = 'system'
end
-TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System
+#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<TkMenu
+class Tk::SysMenu_Apple<Tk::Menu
# for Machintosh
- include TkSystemMenu
+ include Tk::SystemMenu
SYSMENU_NAME = 'apple'
end
-TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple
+#TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple
+Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Apple, :TkSysMenu_Apple)
-class Tk::Menubutton<TkLabel
+class Tk::Menubutton<Tk::Label
TkCommandNames = ['menubutton'.freeze].freeze
WidgetClassName = 'Menubutton'.freeze
WidgetClassNames[WidgetClassName] = self
def create_self(keys)
if keys and keys != None
- # tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
+ 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
else
# tk_call_without_enc('menubutton', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@@ -514,11 +539,12 @@ class Tk::Menubutton<TkLabel
end
Tk::MenuButton = Tk::Menubutton
-TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton
-TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton
+#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)
-class Tk::OptionMenubutton<TkMenubutton
+class Tk::OptionMenubutton<Tk::Menubutton
TkCommandNames = ['tk_optionMenu'.freeze].freeze
class OptionMenu<TkMenu
@@ -605,6 +631,9 @@ class Tk::OptionMenubutton<TkMenubutton
@menu.delete(index, last)
self
end
+ def xposition(index)
+ @menu.xposition(index)
+ end
def yposition(index)
@menu.yposition(index)
end
@@ -614,6 +643,9 @@ class Tk::OptionMenubutton<TkMenubutton
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
@@ -627,6 +659,9 @@ class Tk::OptionMenubutton<TkMenubutton
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
@@ -640,5 +675,7 @@ class Tk::OptionMenubutton<TkMenubutton
end
Tk::OptionMenuButton = Tk::OptionMenubutton
-TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton
-TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton
+#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)
diff --git a/ext/tk/lib/tk/menubar.rb b/ext/tk/lib/tk/menubar.rb
index 392b6fbd4e..ef9da809b9 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<TkFrame
+class TkMenubar<Tk::Frame
include TkComposite
include TkMenuSpec
diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb
index 118a4f42b1..2a2eb9ba3c 100644
--- a/ext/tk/lib/tk/menuspec.rb
+++ b/ext/tk/lib/tk/menuspec.rb
@@ -61,8 +61,12 @@ 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
@@ -150,21 +154,22 @@ module TkMenuSpec
def _use_menubar?(parent)
use_menubar = false
- if parent.kind_of?(TkRoot) || parent.kind_of?(TkToplevel)
- return true
+ if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel)
+ true
+ elsif parent.current_configinfo.has_key?('menu')
+ true
else
- begin
- parent.cget('menu')
- return true
- rescue
- end
+ false
end
- false
end
private :_use_menubar?
def _create_menu_for_menubar(parent)
- unless (mbar = parent.menu).kind_of?(TkMenu)
+ #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)
mbar = TkMenu.new(parent, :tearoff=>false)
parent.menu(mbar)
end
@@ -190,7 +195,6 @@ module TkMenuSpec
if _use_menubar?(parent)
# menubar by menu entries
-
mbar = _create_menu_for_menubar(parent)
menu_name = nil
@@ -221,6 +225,8 @@ 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 e91e057a00..946b68c704 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<TkLabel
+class Tk::Message<Tk::Label
TkCommandNames = ['message'.freeze].freeze
WidgetClassName = 'Message'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -18,4 +18,5 @@ class Tk::Message<TkLabel
private :create_self
end
-TkMessage = Tk::Message unless Object.const_defined? :TkMessage
+#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 061e43fd89..162953f425 100644
--- a/ext/tk/lib/tk/msgcat.rb
+++ b/ext/tk/lib/tk/msgcat.rb
@@ -74,7 +74,11 @@ class TkMsgCatalog < TkObject
"\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------"
- msg.instance_variable_set(:@encoding, 'utf-8')
+ if TkCore::WITH_ENCODING
+ msg.force_encoding('utf-8')
+ else
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ end
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 5bf6474c5b..20a8d65215 100644
--- a/ext/tk/lib/tk/namespace.rb
+++ b/ext/tk/lib/tk/namespace.rb
@@ -12,17 +12,24 @@ class TkNamespace < TkObject
].freeze
Tk_Namespace_ID_TBL = TkCore::INTERP.create_table
- Tk_Namespace_ID = ["ns".freeze, "00000".taint].freeze
+
+ (Tk_Namespace_ID = ["ns".freeze, "00000".taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
Tk_NsCode_RetObjID_TBL = TkCore::INTERP.create_table
TkCore::INTERP.init_ip_env{
- Tk_Namespace_ID_TBL.clear
- Tk_NsCode_RetObjID_TBL.clear
+ Tk_Namespace_ID_TBL.mutex.synchronize{ Tk_Namespace_ID_TBL.clear }
+ Tk_NsCode_RetObjID_TBL.mutex.synchronize{ Tk_NsCode_RetObjID_TBL.clear }
}
def TkNamespace.id2obj(id)
- Tk_Namespace_ID_TBL[id]? Tk_Namespace_ID_TBL[id]: id
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ Tk_Namespace_ID_TBL[id]? Tk_Namespace_ID_TBL[id]: id
+ }
end
#####################################
@@ -65,11 +72,27 @@ class TkNamespace < TkObject
def cget(slot)
if slot == :namespace || slot == 'namespace'
ns = super(slot)
- if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
- TkNamespace::Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
+ 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
+ }
else
super(slot)
end
@@ -79,9 +102,11 @@ class TkNamespace < TkObject
if slot
if slot == :namespace || slot == 'namespace'
val = super(slot)
- if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
- val = TkNamespace::Tk_Namespace_ID_TBL[val]
- end
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
+ val = TkNamespace::Tk_Namespace_ID_TBL[val]
+ end
+ }
else
val = super(slot)
end
@@ -96,19 +121,23 @@ class TkNamespace < TkObject
info = super()
if TkComm::GET_CONFIGINFO_AS_ARRAY
- 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
+ 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
+ }
}
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
val = info['namespace']
- if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
- info['namespace'] = TkNamespace::Tk_Namespace_ID_TBL[val]
- end
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
+ info['namespace'] = TkNamespace::Tk_Namespace_ID_TBL[val]
+ end
+ }
end
info
@@ -215,9 +244,11 @@ class TkNamespace < TkObject
def initialize(name = nil, parent = nil)
unless name
- # name = Tk_Namespace_ID.join('')
- name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
- Tk_Namespace_ID[1].succ!
+ Tk_Namespace_ID.mutex.synchronize{
+ # 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
@@ -252,7 +283,9 @@ class TkNamespace < TkObject
# create namespace
__tk_call('namespace', 'eval', @fullname, '')
- Tk_Namespace_ID_TBL[@fullname] = self
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ Tk_Namespace_ID_TBL[@fullname] = self
+ }
end
def self.children(*args)
@@ -260,11 +293,13 @@ class TkNamespace < TkObject
# <pattern> must be glob-style pattern
tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
# ns is fullname
- if Tk_Namespace_ID_TBL.key?(ns)
- Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
}
end
def children(pattern=None)
@@ -290,14 +325,24 @@ class TkNamespace < TkObject
def code(script = Proc.new)
if script.kind_of?(String)
cmd = proc{|*args|
- ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
+ 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
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
}
elsif script.kind_of?(Proc)
cmd = proc{|*args|
- ret = ScopeArgs.new(@fullname,*args).instance_eval(&script)
+ 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
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
@@ -319,11 +364,13 @@ class TkNamespace < TkObject
def self.current
ns = self.current_path
- if Tk_Namespace_ID_TBL.key?(ns)
- Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
end
def current_namespace
# ns_tk_call('namespace', 'current')
@@ -335,11 +382,13 @@ class TkNamespace < TkObject
def self.delete(*ns_list)
tk_call('namespace', 'delete', *ns_list)
ns_list.each{|ns|
- if ns.kind_of?(TkNamespace)
- Tk_Namespace_ID_TBL.delete(ns.path)
- else
- Tk_Namespace_ID_TBL.delete(ns.to_s)
- end
+ 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
+ }
}
end
def delete
@@ -371,7 +420,7 @@ class TkNamespace < TkObject
def self.eval(namespace, cmd = Proc.new, *args)
#tk_call('namespace', 'eval', namespace, cmd, *args)
- TkNamespace.new(namespece).eval(cmd, *args)
+ TkNamespace.new(namespace).eval(cmd, *args)
end
=begin
def eval(cmd = Proc.new, *args)
@@ -444,11 +493,13 @@ class TkNamespace < TkObject
def self.parent(namespace=None)
ns = tk_call('namespace', 'parent', namespace)
- if Tk_Namespace_ID_TBL.key?(ns)
- Tk_Namespace_ID_TBL[ns]
- else
- ns
- end
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ 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 a806f3971d..186811d37d 100644
--- a/ext/tk/lib/tk/optiondb.rb
+++ b/ext/tk/lib/tk/optiondb.rb
@@ -8,7 +8,11 @@ module TkOptionDB
extend Tk
TkCommandNames = ['option'.freeze].freeze
- CmdClassID = ['CMD_CLASS'.freeze, '00000'.taint].freeze
+ (CmdClassID = ['CMD_CLASS'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
module Priority
WidgetDefault = 20
@@ -250,8 +254,10 @@ module TkOptionDB
def __create_new_class(klass, func, safe = 4, add = false, parent = nil)
if klass.kind_of?(TkWindow)
carrier = klass.path
- klass = CmdClassID.join(TkCore::INTERP._ip_id_)
- CmdClassID[1].succ!
+ CmdClassID.mutex.synchronize{
+ klass = CmdClassID.join(TkCore::INTERP._ip_id_)
+ CmdClassID[1].succ!
+ }
parent = nil # ignore parent
else
klass = klass.to_s if klass.kind_of?(Symbol)
@@ -312,7 +318,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_variables, :kind_of?, :is_a?,
+ :instance_eval, :instance_exec, :instance_variables, :kind_of?, :is_a?,
:private_methods, :protected_methods, :public_methods ].each{|m|
alias_method(m, :__null_method)
}
@@ -362,7 +368,7 @@ module TkOptionDB
def new_proc_class_random(klass, func, safe = 4, add = false, &b)
eval_under_random_base(){
- TkOption.new_proc_class(klass, func, safe, add, self, &b)
+ TkOptionDB.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 8fab363121..220a38e524 100644
--- a/ext/tk/lib/tk/pack.rb
+++ b/ext/tk/lib/tk/pack.rb
@@ -9,6 +9,7 @@ module TkPack
TkCommandNames = ['pack'.freeze].freeze
+=begin
def configure(win, *args)
if args[-1].kind_of?(Hash)
opts = args.pop
@@ -29,6 +30,22 @@ 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/palette.rb b/ext/tk/lib/tk/palette.rb
index 2b6fdf5d90..2d08d50f6a 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.to_a.flatten if args.kind_of? Hash
+ args = args[0].to_a.flatten if args[0].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 7e818fc928..030144e677 100644
--- a/ext/tk/lib/tk/panedwindow.rb
+++ b/ext/tk/lib/tk/panedwindow.rb
@@ -76,11 +76,32 @@ class Tk::PanedWindow<TkWindow
self
end
- def panecget(win, key)
+ def panecget_strict(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)
@@ -231,5 +252,7 @@ class Tk::PanedWindow<TkWindow
end
Tk::Panedwindow = Tk::PanedWindow
-TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow
-TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow
+#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)
diff --git a/ext/tk/lib/tk/radiobutton.rb b/ext/tk/lib/tk/radiobutton.rb
index 15b29ccd26..1f864ec06b 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<TkButton
+class Tk::RadioButton<Tk::Button
TkCommandNames = ['radiobutton'.freeze].freeze
WidgetClassName = 'Radiobutton'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -65,5 +65,7 @@ class Tk::RadioButton<TkButton
end
Tk::Radiobutton = Tk::RadioButton
-TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton
-TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton
+#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)
diff --git a/ext/tk/lib/tk/root.rb b/ext/tk/lib/tk/root.rb
index a66c9fe454..7237b4c614 100644
--- a/ext/tk/lib/tk/root.rb
+++ b/ext/tk/lib/tk/root.rb
@@ -14,28 +14,7 @@ class Tk::Root<TkWindow
end
private :__methodcall_optkeys
-=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)
+ def Root.new(keys=nil, &b)
unless TkCore::INTERP.tk_windows['.']
TkCore::INTERP.tk_windows['.'] =
super(:without_creating=>true, :widgetname=>'.'){}
@@ -62,7 +41,13 @@ class Tk::Root<TkWindow
}
end
- root.instance_eval(&b) if block_given?
+ if block_given?
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ root.instance_exec(root, &b)
+ else
+ root.instance_eval(&b)
+ end
+ end
root
end
@@ -102,7 +87,7 @@ class Tk::Root<TkWindow
self.menu
end
- def TkRoot.destroy
+ def Root.destroy
TkCore::INTERP._invoke('destroy', '.')
end
end
diff --git a/ext/tk/lib/tk/scale.rb b/ext/tk/lib/tk/scale.rb
index d9e88080cf..7e758d92f4 100644
--- a/ext/tk/lib/tk/scale.rb
+++ b/ext/tk/lib/tk/scale.rb
@@ -14,9 +14,31 @@ class Tk::Scale<TkWindow
cmd = keys.delete('command')
keys['command'] = proc{|val| cmd.call(val.to_f)}
end
- #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
+ 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
else
#tk_call_without_enc('scale', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@@ -85,4 +107,5 @@ class Tk::Scale<TkWindow
end
end
-TkScale = Tk::Scale unless Object.const_defined? :TkScale
+#TkScale = Tk::Scale unless Object.const_defined? :TkScale
+Tk.__set_toplevel_aliases__(:Tk, Tk::Scale, :TkScale)
diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb
index dda7a96d87..87db46a9f9 100644
--- a/ext/tk/lib/tk/scrollbar.rb
+++ b/ext/tk/lib/tk/scrollbar.rb
@@ -19,9 +19,31 @@ class Tk::Scrollbar<TkWindow
}
if keys and keys != None
- #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
- tk_call_without_enc(self.class::TkCommandNames[0], @path,
- *hash_kv(keys, true))
+ 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
else
#tk_call_without_enc('scrollbar', @path)
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@@ -103,12 +125,33 @@ 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
+#TkScrollbar = Tk::Scrollbar unless Object.const_defined? :TkScrollbar
+Tk.__set_toplevel_aliases__(:Tk, Tk::Scrollbar, :TkScrollbar)
-class Tk::XScrollbar<TkScrollbar
+class Tk::XScrollbar<Tk::Scrollbar
def create_self(keys)
keys = {} unless keys
keys['orient'] = 'horizontal'
@@ -117,10 +160,11 @@ class Tk::XScrollbar<TkScrollbar
private :create_self
end
-TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar
+#TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar
+Tk.__set_toplevel_aliases__(:Tk, Tk::XScrollbar, :TkXScrollbar)
-class Tk::YScrollbar<TkScrollbar
+class Tk::YScrollbar<Tk::Scrollbar
def create_self(keys)
keys = {} unless keys
keys['orient'] = 'vertical'
@@ -129,4 +173,5 @@ class Tk::YScrollbar<TkScrollbar
private :create_self
end
-TkYScrollbar = Tk::YScrollbar unless Object.const_defined? :TkYScrollbar
+#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 fd04057fb6..d20742a666 100644
--- a/ext/tk/lib/tk/scrollbox.rb
+++ b/ext/tk/lib/tk/scrollbox.rb
@@ -1,16 +1,19 @@
#
# tk/scrollbox.rb - Tk Listbox with Scrollbar
# as an example of Composite Widget
-# $Date$
# by Yukihiro Matsumoto <matz@netlab.co.jp>
#
require 'tk'
require 'tk/listbox'
-class TkScrollbox<TkListbox
+class TkScrollbox<Tk::Listbox
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 157efcc2a3..34dc1904f7 100644
--- a/ext/tk/lib/tk/spinbox.rb
+++ b/ext/tk/lib/tk/spinbox.rb
@@ -1,12 +1,11 @@
#
# tk/spinbox.rb - Tk spinbox classes
-# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
#
require 'tk'
require 'tk/entry'
-class Tk::Spinbox<TkEntry
+class Tk::Spinbox<Tk::Entry
TkCommandNames = ['spinbox'.freeze].freeze
WidgetClassName = 'Spinbox'.freeze
WidgetClassNames[WidgetClassName] = self
@@ -38,6 +37,24 @@ class Tk::Spinbox<TkEntry
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)
@@ -98,4 +115,5 @@ class Tk::Spinbox<TkEntry
end
end
-TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox
+#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 352d0903f4..4ec82bed1d 100644
--- a/ext/tk/lib/tk/text.rb
+++ b/ext/tk/lib/tk/text.rb
@@ -1,6 +1,5 @@
#
# tk/text.rb - Tk text classes
-# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
require 'tk'
require 'tk/itemfont'
@@ -33,31 +32,37 @@ 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)
- itemconfigure(['tag', tagOrId], slot)
+ itemconfiginfo(['tag', tagOrId], slot)
end
def current_tag_configinfo(tagOrId, slot=nil)
- itemconfigure(['tag', tagOrId], slot)
+ current_itemconfiginfo(['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)
- itemconfigure(['window', tagOrId], slot)
+ itemconfiginfo(['window', tagOrId], slot)
end
def current_window_configinfo(tagOrId, slot=nil)
- itemconfigure(['window', tagOrId], slot)
+ current_itemconfiginfo(['window', tagOrId], slot)
end
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
class Tk::Text<TkTextWin
@@ -74,9 +79,9 @@ class Tk::Text<TkTextWin
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- TkText::IndexString.new(String.new(id) << ' + ' << mod)
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod)
else
- TkText::IndexString.new(String.new(id) << ' ' << mod)
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
end
end
@@ -85,20 +90,20 @@ class Tk::Text<TkTextWin
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- TkText::IndexString.new(String.new(id) << ' - ' << mod)
+ Tk::Text::IndexString.new(String.new(id) << ' - ' << mod)
elsif mod =~ /^\s*[-]\s+(\d.*)$/
- TkText::IndexString.new(String.new(id) << ' - -' << $1)
+ Tk::Text::IndexString.new(String.new(id) << ' - -' << $1)
else
- TkText::IndexString.new(String.new(id) << ' ' << mod)
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
end
end
def chars(mod)
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
end
end
alias char chars
@@ -107,9 +112,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display chars')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display chars')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display chars')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display chars')
end
end
alias display_char display_chars
@@ -118,9 +123,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any chars')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any chars')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any chars')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any chars')
end
end
alias any_char any_chars
@@ -129,9 +134,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' indices')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' indices')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' indices')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' indices')
end
end
@@ -139,9 +144,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display indices')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display indices')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display indices')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display indices')
end
end
@@ -149,18 +154,18 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any indices')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any indices')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any indices')
+ Tk::Text::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
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
end
end
alias line lines
@@ -169,9 +174,9 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display_lines')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display_lines')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display lines')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display lines')
end
end
alias display_line display_lines
@@ -180,43 +185,43 @@ class Tk::Text<TkTextWin
# Tk8.5 feature
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any_lines')
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any_lines')
else
- TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any lines')
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any lines')
end
end
alias any_line any_lines
def linestart
- TkText::IndexString.new(String.new(id) << ' linestart')
+ Tk::Text::IndexString.new(String.new(id) << ' linestart')
end
def lineend
- TkText::IndexString.new(String.new(id) << ' lineend')
+ Tk::Text::IndexString.new(String.new(id) << ' lineend')
end
def display_linestart
# Tk8.5 feature
- TkText::IndexString.new(String.new(id) << ' display linestart')
+ Tk::Text::IndexString.new(String.new(id) << ' display linestart')
end
def display_lineend
# Tk8.5 feature
- TkText::IndexString.new(String.new(id) << ' display lineend')
+ Tk::Text::IndexString.new(String.new(id) << ' display lineend')
end
def wordstart
- TkText::IndexString.new(String.new(id) << ' wordstart')
+ Tk::Text::IndexString.new(String.new(id) << ' wordstart')
end
def wordend
- TkText::IndexString.new(String.new(id) << ' wordend')
+ Tk::Text::IndexString.new(String.new(id) << ' wordend')
end
def display_wordstart
# Tk8.5 feature
- TkText::IndexString.new(String.new(id) << ' display wordstart')
+ Tk::Text::IndexString.new(String.new(id) << ' display wordstart')
end
def display_wordend
# Tk8.5 feature
- TkText::IndexString.new(String.new(id) << ' display wordend')
+ Tk::Text::IndexString.new(String.new(id) << ' display wordend')
end
end
@@ -251,7 +256,11 @@ class Tk::Text<TkTextWin
def self.new(*args, &block)
obj = super(*args){}
obj.init_instance_variable
- obj.instance_eval(&block) if defined? yield
+ 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
end
@@ -261,8 +270,12 @@ class Tk::Text<TkTextWin
end
def __destroy_hook__
- TkTextTag::TTagID_TBL.delete(@path)
- TkTextMark::TMarkID_TBL.delete(@path)
+ TkTextTag::TTagID_TBL.mutex.synchronize{
+ TkTextTag::TTagID_TBL.delete(@path)
+ }
+ TkTextTag::TMarkID_TBL.mutex.synchronize{
+ TkTextMark::TMarkID_TBL.delete(@path)
+ }
end
def create_self(keys)
@@ -285,16 +298,16 @@ class Tk::Text<TkTextWin
private :__strval_optkeys
def self.at(x, y)
- TkText::IndexString.at(x, y)
+ Tk::Text::IndexString.at(x, y)
end
def at(x, y)
- TkText::IndexString.at(x, y)
+ Tk::Text::IndexString.at(x, y)
end
def index(idx)
- TkText::IndexString.new(tk_send_without_enc('index',
- _get_eval_enc_str(idx)))
+ Tk::Text::IndexString.new(tk_send_without_enc('index',
+ _get_eval_enc_str(idx)))
end
def get_displaychars(*index)
@@ -396,7 +409,7 @@ class Tk::Text<TkTextWin
end
alias previous_mark mark_previous
- def image_cget(index, slot)
+ def image_cget_strict(index, slot)
case slot.to_s
when 'text', 'label', 'show', 'data', 'file'
_fromUTF8(tk_send_without_enc('image', 'cget',
@@ -408,6 +421,28 @@ 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',
@@ -713,15 +748,17 @@ class Tk::Text<TkTextWin
def tag_delete(*tags)
tk_send_without_enc('tag', 'delete',
*(tags.collect{|tag| _get_eval_enc_str(tag)}))
- if TkTextTag::TTagID_TBL[@path]
- tags.each{|tag|
- if tag.kind_of?(TkTextTag)
- TkTextTag::TTagID_TBL[@path].delete(tag.id)
- else
- TkTextTag::TTagID_TBL[@path].delete(tag)
- end
- }
- end
+ 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
+ }
self
end
alias deltag tag_delete
@@ -968,7 +1005,7 @@ class Tk::Text<TkTextWin
false, true)
r = []
while key=l.shift
- r.push [TkText::IndexString.new(key), TkText::IndexString.new(l.shift)]
+ r.push [Tk::Text::IndexString.new(key), Tk::Text::IndexString.new(l.shift)]
end
r
end
@@ -978,7 +1015,7 @@ class Tk::Text<TkTextWin
_get_eval_enc_str(tag),
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
- TkText::IndexString.new(idx)
+ Tk::Text::IndexString.new(idx)
}
end
@@ -987,7 +1024,7 @@ class Tk::Text<TkTextWin
_get_eval_enc_str(tag),
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
- TkText::IndexString.new(idx)
+ Tk::Text::IndexString.new(idx)
}
end
@@ -1183,7 +1220,7 @@ class Tk::Text<TkTextWin
end
def _ktext_length(txt)
- if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!!
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
return txt.length
end
###########################
@@ -1237,7 +1274,7 @@ class Tk::Text<TkTextWin
if ret == ""
nil
else
- TkText::IndexString.new(ret)
+ Tk::Text::IndexString.new(ret)
end
end
@@ -1272,7 +1309,7 @@ class Tk::Text<TkTextWin
if ret == ""
nil
else
- TkText::IndexString.new(ret)
+ Tk::Text::IndexString.new(ret)
end
end
@@ -1461,10 +1498,10 @@ class Tk::Text<TkTextWin
# retrieve index
idx = str.index(/ /, i)
if idx
- result.push(TkText::IndexString.new(str[i..(idx-1)]))
+ result.push(Tk::Text::IndexString.new(str[i..(idx-1)]))
i = idx + 1
else
- result.push(TkText::IndexString.new(str[i..-1]))
+ result.push(Tk::Text::IndexString.new(str[i..-1]))
break
end
end
@@ -1532,16 +1569,17 @@ class Tk::Text<TkTextWin
end
end
-TkText = Tk::Text unless Object.const_defined? :TkText
+#TkText = Tk::Text unless Object.const_defined? :TkText
+Tk.__set_toplevel_aliases__(:Tk, Tk::Text, :TkText)
#######################################
-class TkText::Peer < TkText
+class Tk::Text::Peer < Tk::Text
# Tk8.5 feature
def initialize(text, parent=nil, keys={})
- unless text.kind_of?(TkText)
- fail ArgumentError, "TkText is expected for 1st argument"
+ unless text.kind_of?(Tk::Text)
+ fail ArgumentError, "Tk::Text 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 ea2b7c6a36..fb306a9c17 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 TkText::IndexModMethods
+ include Tk::Text::IndexModMethods
def initialize(parent, index, keys)
- #unless parent.kind_of?(TkText)
- # fail ArgumentError, "expect TkText for 1st argument"
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
#end
@t = parent
if index == 'end' || index == :end
@@ -34,7 +34,7 @@ class TkTextImage<TkObject
end
def id
- TkText::IndexString.new(@id)
+ Tk::Text::IndexString.new(@id)
end
def mark
@path
@@ -52,6 +52,10 @@ 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
diff --git a/ext/tk/lib/tk/textmark.rb b/ext/tk/lib/tk/textmark.rb
index 9f7ad751e5..72c1ce1ab4 100644
--- a/ext/tk/lib/tk/textmark.rb
+++ b/ext/tk/lib/tk/textmark.rb
@@ -5,38 +5,54 @@ require 'tk'
require 'tk/text'
class TkTextMark<TkObject
- include TkText::IndexModMethods
+ include Tk::Text::IndexModMethods
TMarkID_TBL = TkCore::INTERP.create_table
- Tk_TextMark_ID = ['mark'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TMarkID_TBL.clear }
+ (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 }
+ }
def TkTextMark.id2obj(text, id)
tpath = text.path
- return id unless TMarkID_TBL[tpath]
- TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
+ TMarkID_TBL.mutex.synchronize{
+ if TMarkID_TBL[tpath]
+ TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(parent, index)
- #unless parent.kind_of?(TkText)
- # fail ArgumentError, "expect TkText for 1st argument"
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
#end
@parent = @t = parent
@tpath = parent.path
- # @path = @id = Tk_TextMark_ID.join('')
- @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_).freeze
- TMarkID_TBL[@id] = self
- TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
- TMarkID_TBL[@tpath][@id] = self
- Tk_TextMark_ID[1].succ!
+ 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
+ }
tk_call_without_enc(@t.path, 'mark', 'set', @id,
_get_eval_enc_str(index))
@t._addtag id, self
end
def id
- TkText::IndexString.new(@id)
+ Tk::Text::IndexString.new(@id)
end
def exist?
@@ -49,15 +65,15 @@ class TkTextMark<TkObject
end
=begin
- # move to TkText::IndexModMethods module
+ # move to Tk::Text::IndexModMethods module
def +(mod)
return chars(mod) if mod.kind_of?(Numeric)
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- TkText::IndexString.new(@id + ' + ' + mod)
+ Tk::Text::IndexString.new(@id + ' + ' + mod)
else
- TkText::IndexString.new(@id + ' ' + mod)
+ Tk::Text::IndexString.new(@id + ' ' + mod)
end
end
@@ -66,11 +82,11 @@ class TkTextMark<TkObject
mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
- TkText::IndexString.new(@id + ' - ' + mod)
+ Tk::Text::IndexString.new(@id + ' - ' + mod)
elsif mod =~ /^\s*[-]\s+(\d.*)$/
- TkText::IndexString.new(@id + ' - -' + $1)
+ Tk::Text::IndexString.new(@id + ' - -' + $1)
else
- TkText::IndexString.new(@id + ' ' + mod)
+ Tk::Text::IndexString.new(@id + ' ' + mod)
end
end
=end
@@ -124,27 +140,44 @@ end
TktMark = TkTextMark
class TkTextNamedMark<TkTextMark
- def self.new(parent, name, *args)
- if TMarkID_TBL[parent.path] && TMarkID_TBL[parent.path][name]
- return TMarkID_TBL[parent.path][name]
- else
- super(parent, name, *args)
- end
+ 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
+ }
end
def initialize(parent, name, index=nil)
- #unless parent.kind_of?(TkText)
- # fail ArgumentError, "expect TkText for 1st argument"
+ # dummy:: not called by 'new' method
+
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text 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
diff --git a/ext/tk/lib/tk/texttag.rb b/ext/tk/lib/tk/texttag.rb
index 731e6bebd6..b08d923ea1 100644
--- a/ext/tk/lib/tk/texttag.rb
+++ b/ext/tk/lib/tk/texttag.rb
@@ -7,17 +7,29 @@ require 'tk/tagfont'
class TkTextTag<TkObject
include TkTreatTagFont
- include TkText::IndexModMethods
+ include Tk::Text::IndexModMethods
TTagID_TBL = TkCore::INTERP.create_table
- Tk_TextTag_ID = ['tag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TTagID_TBL.clear }
+ (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 }
+ }
def TkTextTag.id2obj(text, id)
tpath = text.path
- return id unless TTagID_TBL[tpath]
- TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
+ TTagID_TBL.mutex.synchronize{
+ if TTagID_TBL[tpath]
+ TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(parent, *args)
@@ -26,12 +38,16 @@ class TkTextTag<TkObject
#end
@parent = @t = parent
@tpath = parent.path
- # @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_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
+ }
#tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
if args != []
keys = args.pop
@@ -47,7 +63,7 @@ class TkTextTag<TkObject
end
def id
- TkText::IndexString.new(@id)
+ Tk::Text::IndexString.new(@id)
end
def exist?
@@ -60,11 +76,11 @@ class TkTextTag<TkObject
end
def first
- TkText::IndexString.new(@id + '.first')
+ Tk::Text::IndexString.new(@id + '.first')
end
def last
- TkText::IndexString.new(@id + '.last')
+ Tk::Text::IndexString.new(@id + '.last')
end
def add(*indices)
@@ -83,7 +99,7 @@ class TkTextTag<TkObject
l = tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'ranges', @id))
r = []
while key=l.shift
- r.push [TkText::IndexString.new(key), TkText::IndexString.new(l.shift)]
+ r.push [Tk::Text::IndexString.new(key), Tk::Text::IndexString.new(l.shift)]
end
r
end
@@ -92,7 +108,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|
- TkText::IndexString.new(idx)
+ Tk::Text::IndexString.new(idx)
}
end
@@ -100,7 +116,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|
- TkText::IndexString.new(idx)
+ Tk::Text::IndexString.new(idx)
}
end
@@ -116,6 +132,9 @@ 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
@@ -221,7 +240,9 @@ class TkTextTag<TkObject
def destroy
tk_call_without_enc(@t.path, 'tag', 'delete', @id)
- TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
+ TTagID_TBL.mutex.synchronize{
+ TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
+ }
self
end
end
@@ -229,33 +250,48 @@ TktTag = TkTextTag
class TkTextNamedTag<TkTextTag
def self.new(parent, name, *args)
- if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
- tagobj = TTagID_TBL[parent.path][name]
- if args != []
- keys = args.pop
- if keys.kind_of?(Hash)
- tagobj.add(*args) if args != []
- tagobj.configure(keys)
- else
- args.push keys
- tagobj.add(*args)
- end
+ 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)
end
- return tagobj
- else
- super(parent, name, *args)
end
+
+ tagobj
end
def initialize(parent, name, *args)
- #unless parent.kind_of?(TkText)
- # fail ArgumentError, "expect TkText for 1st argument"
+ # dummy:: not called by 'new' method
+
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text 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
@@ -269,7 +305,7 @@ class TkTextNamedTag<TkTextTag
add(*args)
end
end
- @t._addtag id, self
+ @t._addtag @id, self
end
end
TktNamedTag = TkTextNamedTag
diff --git a/ext/tk/lib/tk/textwindow.rb b/ext/tk/lib/tk/textwindow.rb
index 6735f2585a..004422e4f3 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 TkText::IndexModMethods
+ include Tk::Text::IndexModMethods
def initialize(parent, index, keys = {})
- #unless parent.kind_of?(TkText)
- # fail ArgumentError, "expect TkText for 1st argument"
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
#end
@t = parent
if index == 'end' || index == :end
@@ -55,7 +55,7 @@ class TkTextWindow<TkObject
end
def id
- TkText::IndexString.new(_epath(@id))
+ Tk::Text::IndexString.new(_epath(@id))
end
def mark
@path
@@ -72,6 +72,9 @@ 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)
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb
index 47f2b79350..91840d0575 100644
--- a/ext/tk/lib/tk/timer.rb
+++ b/ext/tk/lib/tk/timer.rb
@@ -11,7 +11,12 @@ class TkTimer
TkCommandNames = ['after'.freeze].freeze
- Tk_CBID = ['a'.freeze, '00000'.taint].freeze
+ (Tk_CBID = ['a'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
Tk_CBTBL = {}.taint
TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
@@ -96,9 +101,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
@@ -106,7 +111,8 @@ class TkTimer
if @running == false || @proc_max == 0 || @do_loop == 0
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- @wait_var.value = 0
+ # @wait_var.value = 0
+ __at_end__
return
end
if @current_pos >= @proc_max
@@ -115,7 +121,8 @@ class TkTimer
else
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- @wait_var.value = 0
+ # @wait_var.value = 0
+ __at_end__
return
end
end
@@ -138,12 +145,16 @@ class TkTimer
end
def initialize(*args, &b)
- # @id = Tk_CBID.join('')
- @id = Tk_CBID.join(TkCore::INTERP._ip_id_)
- Tk_CBID[1].succ!
+ Tk_CBID.mutex.synchronize{
+ # @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
@@ -203,6 +214,12 @@ 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
@@ -420,7 +437,8 @@ class TkTimer
def cancel
@running = false
- @wait_var.value = 0
+ # @wait_var.value = 0
+ __at_end__
tk_call 'after', 'cancel', @after_id if @after_id
@after_id = nil
@@ -464,6 +482,21 @@ 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"
@@ -562,7 +595,8 @@ class TkRTTimer < TkTimer
if @running == false || @proc_max == 0 || @do_loop == 0
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- @wait_var.value = 0
+ # @wait_var.value = 0
+ __at_end__
return
end
if @current_pos >= @proc_max
@@ -571,7 +605,8 @@ class TkRTTimer < TkTimer
else
Tk_CBTBL.delete(@id) ;# for GC
@running = false
- @wait_var.value = 0
+ # @wait_var.value = 0
+ __at_end__
return
end
end
diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb
index 87229aaba9..bd6e8307f5 100644
--- a/ext/tk/lib/tk/toplevel.rb
+++ b/ext/tk/lib/tk/toplevel.rb
@@ -72,7 +72,7 @@ class Tk::Toplevel<TkWindow
conf_methods = _symbolkey2str(__methodcall_optkeys())
- keys.each{|k,v|
+ keys.each{|k,v| # k is a String
if conf_methods.key?(k)
wm_cmds[conf_methods[k]] = v
elsif Wm.method_defined?(k)
@@ -258,4 +258,5 @@ class Tk::Toplevel<TkWindow
end
end
-TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel
+#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
index 8960da95a2..72ed637a38 100644
--- a/ext/tk/lib/tk/ttk_selector.rb
+++ b/ext/tk/lib/tk/ttk_selector.rb
@@ -1,55 +1,76 @@
#
# ttk_selector
#
-module Ttk_Selector
- @TTK_CLASS_NAMES = {}
-
- def self.use_ttk_as_default(mode = true)
- if mode # Use Ttk widgets
- @TTK_CLASS_NAMES.each{|name, status|
- eval("::Tk#{name} = ::Tk::#{(status)? 'Tile::': '::'}#{name}",
- TOPLEVEL_BINDING)
- }
- else # Use standard Tk widagets
- @TTK_CLASS_NAMES.each{|name, status|
- eval("::Tk#{name} = ::Tk::#{name}", TOPLEVEL_BINDING)
- }
+######################################
+# 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
- end
+ }
- def self.add(name)
- @TTK_CLASS_NAMES[name] = true
- end
+ ################################################
- def self.remove(name)
- @TTK_CLASS_NAMES[name] = false
- 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
-
-#--------------------------------------------------------------------
-
-Ttk_Selector.add('Button')
-Ttk_Selector.add('Checkbutton')
-Ttk_Selector.add('Entry')
-##(ttk only) Ttk_Selector.add('Combobox')
-##(ttk only) Ttk_Selector.add('Dialog')
-Ttk_Selector.add('Frame')
-Ttk_Selector.add('Label')
-Ttk_Selector.add('Labelframe')
-##(std only) Ttk_Selector.add('Listbox')
-Ttk_Selector.add('Menubutton')
-##(ttk only) Ttk_Selector.add('Notebook')
-Ttk_Selector.add('Panedwindow')
-##(ttk only) Ttk_Selector.add('Progressbar')
-Ttk_Selector.add('Radiobutton')
-Ttk_Selector.add('Scale')
-##(ttk only) Ttk_Selector.add('Progress')
-Ttk_Selector.add('Scrollbar')
-Ttk_Selector.add('XScrollbar')
-Ttk_Selector.add('YScrollbar')
-##(ttk only) Ttk_Selector.add('Separator')
-##(ttk only) Ttk_Selector.add('SizeGrip')
-##(ttk only) Ttk_Selector.add('Square')
-##(ttk only) Ttk_Selector.add('Treeview')
-
-#--------------------------------------------------------------------
diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb
index 0c5b5c61b9..60bd433cdc 100644
--- a/ext/tk/lib/tk/validation.rb
+++ b/ext/tk/lib/tk/validation.rb
@@ -50,7 +50,8 @@ 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.join(' '))
+ keys[key] = klass.new(cmd, *args)
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
elsif TkComm._callback_entry?(keys[key])
keys[key] = klass.new(keys[key])
@@ -151,7 +152,8 @@ 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.join(' '))
+ keys[key] = klass.new(cmd, *args)
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
elsif TkComm._callback_entry?(keys[key])
keys[key] = klass.new(keys[key])
@@ -249,6 +251,24 @@ 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);
#
@@ -277,6 +297,7 @@ 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 e5cacadc1a..f738a96ee7 100644
--- a/ext/tk/lib/tk/variable.rb
+++ b/ext/tk/lib/tk/variable.rb
@@ -16,11 +16,22 @@ 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].freeze
+ (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)
#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} {
@@ -44,10 +55,10 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
def TkVariable.callback(id, name1, name2, op)
#name1,name2,op = tk_split_list(args)
#name1,name2,op = tk_split_simplelist(args)
- if TkVar_CB_TBL[id]
+ if cb_obj = TkVar_CB_TBL[id]
#_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
begin
- _get_eval_string(TkVar_CB_TBL[id].trace_callback(name2, op))
+ _get_eval_string(cb_obj.trace_callback(name2, op))
rescue SystemExit
exit(0)
rescue Interrupt
@@ -59,7 +70,11 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
"\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------"
- msg.instance_variable_set(:@encoding, 'utf-8')
+ if TkCore::WITH_ENCODING
+ msg.force_encoding('utf-8')
+ else
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ end
rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" +
@@ -267,11 +282,15 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
def initialize(val="", type=nil)
# @id = Tk_VARIABLE_ID.join('')
begin
- @id = Tk_VARIABLE_ID.join(TkCore::INTERP._ip_id_)
- Tk_VARIABLE_ID[1].succ!
+ Tk_VARIABLE_ID.mutex.synchronize{
+ @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[@id] = self
+ TkVar_ID_TBL.mutex.synchronize{
+ TkVar_ID_TBL[@id] = self
+ }
@var = @id
@elem = nil
@@ -1263,56 +1282,101 @@ 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)
- @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])
+ opts = _check_trace_opt(opts)
+ (@trace_var ||= []).unshift([opts,cmd])
+
if @trace_opts == nil
TkVar_CB_TBL[@id] = self
- @trace_opts = opts.dup
- Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
- 'rb_var ' << @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')
+ @trace_opts = opts
+ if USE_OLD_TRACE_OPTION_STYLE
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
else
- # TCL_VERSION <= 8.3
- Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
end
-=end
else
newopts = @trace_opts.dup
- #opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
- opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
- if newopts != @trace_opts
- Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts,
- 'rb_var ' << @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')
- @trace_opts.replace(newopts)
- Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var')
- else
- # TCL_VERSION <= 8.3
+ 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, 'rb_var ' << @id)
@trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var')
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ else
+ newopts |= opts
+ unless (newopts - @trace_opts).empty?
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
end
-=end
end
end
+
self
end
@@ -1321,65 +1385,54 @@ end
fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array")
end
- @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])
+
+ opts = _check_trace_opt(opts)
+
+ ((@trace_elem ||= {})[elem] ||= []).unshift([opts,cmd])
+
if @trace_opts == nil
TkVar_CB_TBL[@id] = self
- @trace_opts = opts.dup
- Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts,
- 'rb_var ' << @id)
-=begin
- if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
- # TCL_VERSION >= 8.4
+ @trace_opts = opts
+ if USE_OLD_TRACE_OPTION_STYLE
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var')
+ @id, @trace_opts, 'rb_var ' << @id)
else
- # TCL_VERSION <= 8.3
Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var')
+ @id, @trace_opts, 'rb_var ' << @id)
end
-=end
else
newopts = @trace_opts.dup
- # opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
- opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
- if newopts != @trace_opts
- Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts,
- 'rb_var ' << @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')
- @trace_opts.replace(newopts)
- Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var')
- else
- # TCL_VERSION <= 8.3
+ 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, 'rb_var ' << @id)
@trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var')
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ else
+ newopts |= opts
+ unless (newopts - @trace_opts).empty?
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
end
-=end
end
end
+
self
end
- def trace_vinfo
+ def trace_info
return [] unless @trace_var
@trace_var.dup
end
+ alias trace_vinfo trace_info
- def _trace_vinfo_for_element(elem)
+ def trace_info_for_element(elem)
if @elem
fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array")
@@ -1388,141 +1441,180 @@ end
return [] unless @trace_elem[elem]
@trace_elem[elem].dup
end
+ alias trace_vinfo_for_element trace_info_for_element
- def trace_vdelete(opts,cmd)
+ def trace_remove(opts,cmd)
return self unless @trace_var.kind_of? Array
- opts = opts.to_s
- opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+
+ opts = _check_trace_opt(opts)
+
idx = -1
- newopts = ''
- @trace_var.each_with_index{|e,i|
- if idx < 0 && e[0] == opts && e[1] == cmd
- idx = i
- next
- end
- # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
- }
+ if 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
+
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|
- # 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
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ else
+ newopts |= e[0]
+ end
}
}
- 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
+ if USE_OLD_TRACE_OPTION_STYLE
+ diff = false
+ @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
+ if diff
Tk.tk_call_without_enc('trace', 'vdelete',
- @id, @trace_opts, 'rb_var')
+ @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
end
-=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
+ 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?
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var')
- else
- # TCL_VERSION <= 8.3
- Tk.tk_call_without_enc('trace', 'variable',
- @id, @trace_opts, 'rb_var')
+ @id, @trace_opts, 'rb_var ' << @id)
end
-=end
end
end
self
end
+ alias trace_delete trace_remove
+ alias trace_vdelete trace_remove
- def trace_vdelete_for_element(elem,opts,cmd)
+ def trace_remove_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 = opts.to_s
- opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+
+ opts = _check_trace_opt(opts)
+
idx = -1
- @trace_elem[elem].each_with_index{|e,i|
- if idx < 0 && e[0] == opts && e[1] == cmd
- idx = i
- next
- end
- }
+ 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
+
if idx >= 0
@trace_elem[elem].delete_at(idx)
else
return self
end
- newopts = ''
- @trace_var.each{|e|
- # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
- }
- @trace_elem.each{|elem|
- @trace_elem[elem].each{|e|
- # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ 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)}
+ }
+ }
+ end
- 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
+ if USE_OLD_TRACE_OPTION_STYLE
+ diff = false
+ @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
+ if diff
Tk.tk_call_without_enc('trace', 'vdelete',
- @id, @trace_opts, 'rb_var')
+ @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
end
-=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
+ 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?
Tk.tk_call_without_enc('trace', 'add', 'variable',
- @id, @trace_opts, 'rb_var')
- else
- # TCL_VERSION <= 8.3
- Tk.tk_call_without_enc('trace', 'variable', @id,
- @trace_opts, 'rb_var')
+ @id, @trace_opts, 'rb_var ' << @id)
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
@@ -1532,12 +1624,23 @@ class TkVarAccess<TkVariable
return name
end
- if v = TkVar_ID_TBL[name]
- v.value = args[0] unless args.empty?
- return v
- 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
+ }
- super(name, *args)
+ v.instance_eval{ initialize(name, *args) }
+ v
end
def self.new_hash(name, *args)
@@ -1549,27 +1652,38 @@ class TkVarAccess<TkVariable
return name
end
- if v = TkVar_ID_TBL[name]
- unless v.is_hash?
- fail ArgumentError, "already exist as a scalar variable"
+ 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
+ }
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'
- self.new(name, {}) # force creating
+ v.instance_eval{ initialize(name, {}) } # force creating
else
- self.new(name, *args)
+ v.instance_eval{ initialize(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 d47e80aecd..ae31ac1f8f 100644
--- a/ext/tk/lib/tk/virtevent.rb
+++ b/ext/tk/lib/tk/virtevent.rb
@@ -9,10 +9,17 @@ class TkVirtualEvent<TkObject
TkCommandNames = ['event'.freeze].freeze
- TkVirtualEventID = ["VirtEvent".freeze, "00000".taint].freeze
+ (TkVirtualEventID = ["VirtEvent".freeze, "00000".taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
TkVirtualEventTBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TkVirtualEventTBL.clear }
+ TkCore::INTERP.init_ip_env{
+ TkVirtualEventTBL.mutex.synchronize{ TkVirtualEventTBL.clear }
+ }
class PreDefVirtEvent<self
def self.new(event, *sequences)
@@ -21,22 +28,30 @@ class TkVirtualEvent<TkObject
elsif event !~ /^<.*>$/
event = '<' + event + '>'
end
- if TkVirtualEvent::TkVirtualEventTBL.has_key?(event)
- TkVirtualEvent::TkVirtualEventTBL[event]
- else
- super(event, *sequences)
- 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
+ }
end
def initialize(event, *sequences)
@path = @id = event
- TkVirtualEvent::TkVirtualEventTBL[@id] = self
- add(*sequences)
+ _add_sequences(sequences)
end
end
def TkVirtualEvent.getobj(event)
- obj = TkVirtualEventTBL[event]
+ obj = nil
+ TkVirtualEventTBL.mutex.synchronize{
+ obj = TkVirtualEventTBL[event]
+ }
if obj
obj
else
@@ -55,19 +70,31 @@ class TkVirtualEvent<TkObject
end
def initialize(*sequences)
- # @path = @id = '<' + TkVirtualEventID.join('') + '>'
- @path = @id = '<' + TkVirtualEventID.join(TkCore::INTERP._ip_id_) + '>'
- TkVirtualEventID[1].succ!
- add(*sequences)
+ TkVirtualEventID.mutex.synchronize{
+ # @path = @id = '<' + TkVirtualEventID.join('') + '>'
+ @path = @id = '<' + TkVirtualEventID.join(TkCore::INTERP._ip_id_) + '>'
+ TkVirtualEventID[1].succ!
+ }
+ _add_sequences(sequences)
end
- def add(*sequences)
- if sequences != []
+ def _add_sequences(seq_ary)
+ unless seq_ary.empty?
tk_call_without_enc('event', 'add', "<#{@id}>",
- *(sequences.collect{|seq|
+ *(seq_ary.collect{|seq|
"<#{tk_event_sequence(seq)}>"
}) )
- TkVirtualEventTBL[@id] = self
+ end
+ self
+ end
+ private :_add_sequences
+
+ def add(*sequences)
+ if sequences != []
+ _add_sequences(sequences)
+ TkVirtualEventTBL.mutex.synchronize{
+ TkVirtualEventTBL[@id] = self
+ }
end
self
end
@@ -75,20 +102,26 @@ class TkVirtualEvent<TkObject
def delete(*sequences)
if sequences == []
tk_call_without_enc('event', 'delete', "<#{@id}>")
- TkVirtualEventTBL.delete(@id)
+ TkVirtualEventTBL.mutex.synchronize{
+ TkVirtualEventTBL.delete(@id)
+ }
else
tk_call_without_enc('event', 'delete', "<#{@id}>",
*(sequences.collect{|seq|
"<#{tk_event_sequence(seq)}>"
}) )
- TkVirtualEventTBL.delete(@id) if info == []
+ if tk_call_without_enc('event','info',"<#{@id}>").empty?
+ TkVirtualEventTBL.mutex.synchronize{
+ TkVirtualEventTBL.delete(@id)
+ }
+ end
end
self
end
def info
tk_call_without_enc('event','info',"<#{@id}>").split(/\s+/).collect!{|seq|
- l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ lst = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
case (subseq)
when /^<<[^<>]+>>$/
TkVirtualEvent.getobj(subseq[1..-2])
@@ -98,7 +131,7 @@ class TkVirtualEvent<TkObject
subseq.split('')
end
}.flatten
- (l.size == 1) ? l[0] : l
+ (lst.size == 1) ? lst[0] : lst
}
end
end
diff --git a/ext/tk/lib/tk/winpkg.rb b/ext/tk/lib/tk/winpkg.rb
index 6c168da01b..89fb391c77 100644
--- a/ext/tk/lib/tk/winpkg.rb
+++ b/ext/tk/lib/tk/winpkg.rb
@@ -9,7 +9,8 @@ require 'tk'
module Tk::WinDDE
end
-TkWinDDE = Tk::WinDDE
+#TkWinDDE = Tk::WinDDE
+Tk.__set_toplevel_aliases__(:Tk, Tk::WinDDE, :TkWinDDE)
module Tk::WinDDE
extend Tk
@@ -91,7 +92,8 @@ end
module Tk::WinRegistry
end
-TkWinRegistry = Tk::WinRegistry
+#TkWinRegistry = Tk::WinRegistry
+Tk.__set_toplevel_aliases__(:Tk, Tk::WinRegistry, :TkWinRegistry)
module Tk::WinRegistry
extend Tk
diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb
index 1f432a3848..0394296189 100644
--- a/ext/tk/lib/tk/wm.rb
+++ b/ext/tk/lib/tk/wm.rb
@@ -5,273 +5,407 @@ require 'tk'
module Tk
module Wm
- include TkComm
+ #include TkComm
+ extend TkCore
TkCommandNames = ['wm'.freeze].freeze
TOPLEVEL_METHODCALL_OPTKEYS = {}
- def aspect(*args)
+ def Wm.aspect(win, *args)
if args.length == 0
- list(tk_call_without_enc('wm', 'aspect', path))
+ list(tk_call_without_enc('wm', 'aspect', win.epath))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call('wm', 'aspect', path, *args)
- self
+ tk_call('wm', 'aspect', win.epath, *args)
+ win
end
end
+ def aspect(*args)
+ Wm.aspect(self, *args)
+ end
+ alias wm_aspect aspect
TOPLEVEL_METHODCALL_OPTKEYS['aspect'] = 'aspect'
- def attributes(slot=nil,value=None)
+ def Wm.attributes(win, slot=nil,value=TkComm::None)
if slot == nil
- lst = tk_split_list(tk_call('wm', 'attributes', path))
+ lst = tk_split_list(tk_call('wm', 'attributes', win.epath))
info = {}
while key = lst.shift
info[key[1..-1]] = lst.shift
end
info
elsif slot.kind_of? Hash
- tk_call('wm', 'attributes', path, *hash_kv(slot))
- self
- elsif value == None
- tk_call('wm', 'attributes', path, "-#{slot}")
+ tk_call('wm', 'attributes', win.epath, *hash_kv(slot))
+ win
+ elsif value == TkComm::None
+ tk_call('wm', 'attributes', win.epath, "-#{slot}")
else
- tk_call('wm', 'attributes', path, "-#{slot}", value)
- self
+ tk_call('wm', 'attributes', win.epath, "-#{slot}", value)
+ win
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 client(name=None)
- if name == None
- tk_call('wm', 'client', path)
+ def Wm.client(win, name=TkComm::None)
+ if name == TkComm::None
+ tk_call('wm', 'client', win.epath)
else
name = '' if name == nil
- tk_call('wm', 'client', path, name)
- self
+ tk_call('wm', 'client', win.epath, name)
+ win
end
end
+ def client(name=TkComm::None)
+ Wm.client(self, name)
+ end
+ alias wm_client client
TOPLEVEL_METHODCALL_OPTKEYS['client'] = 'client'
- def colormapwindows(*args)
+ def Wm.colormapwindows(win, *args)
if args.size == 0
- list(tk_call_without_enc('wm', 'colormapwindows', path))
+ list(tk_call_without_enc('wm', 'colormapwindows', win.epath))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'colormapwindows', path, *args)
- self
+ tk_call_without_enc('wm', 'colormapwindows', win.epath, *args)
+ win
end
end
+ def colormapwindows(*args)
+ Wm.colormapwindows(self, *args)
+ end
+ alias wm_colormapwindows colormapwindows
TOPLEVEL_METHODCALL_OPTKEYS['colormapwindows'] = 'colormapwindows'
- def wm_command(value=nil)
+ def Wm.command(win, value=nil)
if value
- tk_call('wm', 'command', path, value)
- self
+ tk_call('wm', 'command', epath, value)
+ win
else
- #procedure(tk_call('wm', 'command', path))
- tk_call('wm', 'command', path)
+ #procedure(tk_call('wm', 'command', epath))
+ tk_call('wm', 'command', epath)
end
end
+ def wm_command(value=nil)
+ Wm.command(self, value)
+ end
TOPLEVEL_METHODCALL_OPTKEYS['wm_command'] = 'wm_command'
- def deiconify(ex = true)
+ def Wm.deiconify(win, ex = true)
if ex
- tk_call_without_enc('wm', 'deiconify', path)
+ tk_call_without_enc('wm', 'deiconify', win.epath)
else
- self.iconify
+ Wm.iconify(win)
end
- self
+ win
end
+ def deiconify(ex = true)
+ Wm.deiconify(self, ex)
+ end
+ alias wm_deiconify deiconify
- def focusmodel(mode = nil)
+ def Wm.focusmodel(win, mode = nil)
if mode
- tk_call_without_enc('wm', 'focusmodel', path, mode)
- self
+ tk_call_without_enc('wm', 'focusmodel', win.epath, mode)
+ win
else
- tk_call_without_enc('wm', 'focusmodel', path)
+ tk_call_without_enc('wm', 'focusmodel', win.epath)
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
- tk_call_without_enc('wm', 'frame', path)
+ Wm.frame(self)
end
+ alias wm_frame frame
- def geometry(geom=nil)
+ def Wm.geometry(win, geom=nil)
if geom
- tk_call_without_enc('wm', 'geometry', path, geom)
- self
+ tk_call_without_enc('wm', 'geometry', win.epath, geom)
+ win
else
- tk_call_without_enc('wm', 'geometry', path)
+ tk_call_without_enc('wm', 'geometry', win.epath)
end
end
+ def geometry(geom=nil)
+ Wm.geometry(self, geom)
+ end
+ alias wm_geometry geometry
TOPLEVEL_METHODCALL_OPTKEYS['geometry'] = 'geometry'
- def wm_grid(*args)
+ def Wm.grid(win, *args)
if args.size == 0
- list(tk_call_without_enc('wm', 'grid', path))
+ list(tk_call_without_enc('wm', 'grid', win.epath))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'grid', path, *args)
- self
+ tk_call_without_enc('wm', 'grid', win.epath, *args)
+ win
end
end
+ def wm_grid(*args)
+ Wm.grid(self, *args)
+ end
TOPLEVEL_METHODCALL_OPTKEYS['wm_grid'] = 'wm_grid'
- def group(leader = nil)
+ def Wm.group(win, leader = nil)
if leader
- tk_call('wm', 'group', path, leader)
- self
+ tk_call('wm', 'group', win.epath, leader)
+ win
else
- window(tk_call('wm', 'group', path))
+ window(tk_call('wm', 'group', win.epath))
end
end
+ def group(leader = nil)
+ Wm.group(self, leader)
+ end
+ alias wm_group group
TOPLEVEL_METHODCALL_OPTKEYS['group'] = 'group'
- def iconbitmap(bmp=nil)
+ def Wm.iconbitmap(win, bmp=nil)
if bmp
- tk_call_without_enc('wm', 'iconbitmap', path, bmp)
- self
+ tk_call_without_enc('wm', 'iconbitmap', win.epath, bmp)
+ win
else
- image_obj(tk_call_without_enc('wm', 'iconbitmap', path))
+ image_obj(tk_call_without_enc('wm', 'iconbitmap', win.epath))
end
end
+ def iconbitmap(bmp=nil)
+ Wm.iconbitmap(self, bmp)
+ end
+ alias wm_iconbitmap iconbitmap
TOPLEVEL_METHODCALL_OPTKEYS['iconbitmap'] = 'iconbitmap'
- def iconphoto(*imgs)
+ def Wm.iconphoto(win, *imgs)
if imgs.empty?
- @wm_iconphoto = nil unless defined? @wm_iconphoto
- return @wm_iconphoto
+ win.instance_eval{
+ @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', path, *imgs)
- @wm_iconphoto = imgs
- self
+ tk_call_without_enc('wm', 'iconphoto', win.epath, *imgs)
+ win.instance_eval{ @wm_iconphoto = imgs }
+ win
+ end
+ def iconphoto(*imgs)
+ Wm.iconphoto(self, *imgs)
end
+ alias wm_iconphoto iconphoto
TOPLEVEL_METHODCALL_OPTKEYS['iconphoto'] = 'iconphoto'
- def iconphoto_default(*imgs)
+ def Wm.iconphoto_default(win, *imgs)
imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
- tk_call_without_enc('wm', 'iconphoto', path, '-default', *imgs)
- self
+ tk_call_without_enc('wm', 'iconphoto', win.epath, '-default', *imgs)
+ win
+ end
+ def iconphoto_default(*imgs)
+ Wm.iconphoto_default(self, *imgs)
end
+ alias wm_iconphoto_default iconphoto_default
- def iconify(ex = true)
+ def Wm.iconify(win, ex = true)
if ex
- tk_call_without_enc('wm', 'iconify', path)
+ tk_call_without_enc('wm', 'iconify', win.epath)
else
- self.deiconify
+ Wm.deiconify(win)
end
- self
+ win
+ end
+ def iconify(ex = true)
+ Wm.iconify(self, ex)
end
+ alias wm_iconify iconify
- def iconmask(bmp=nil)
+ def Wm.iconmask(win, bmp=nil)
if bmp
- tk_call_without_enc('wm', 'iconmask', path, bmp)
- self
+ tk_call_without_enc('wm', 'iconmask', win.epath, bmp)
+ win
else
- image_obj(tk_call_without_enc('wm', 'iconmask', path))
+ image_obj(tk_call_without_enc('wm', 'iconmask', win.epath))
end
end
+ def iconmask(bmp=nil)
+ Wm.iconmask(self, bmp)
+ end
+ alias wm_iconmask iconmask
TOPLEVEL_METHODCALL_OPTKEYS['iconmask'] = 'iconmask'
- def iconname(name=nil)
+ def Wm.iconname(win, name=nil)
if name
- tk_call('wm', 'iconname', path, name)
- self
+ tk_call('wm', 'iconname', win.epath, name)
+ win
else
- tk_call('wm', 'iconname', path)
+ tk_call('wm', 'iconname', win.epath)
end
end
+ def iconname(name=nil)
+ Wm.iconname(self, name)
+ end
+ alias wm_iconname iconname
TOPLEVEL_METHODCALL_OPTKEYS['iconname'] = 'iconname'
- def iconposition(*args)
+ def Wm.iconposition(win, *args)
if args.size == 0
- list(tk_call_without_enc('wm', 'iconposition', path))
+ list(tk_call_without_enc('wm', 'iconposition', win.epath))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'iconposition', path, *args)
- self
+ tk_call_without_enc('wm', 'iconposition', win.epath, *args)
+ win
end
end
+ def iconposition(*args)
+ Wm.iconposition(self, *args)
+ end
+ alias wm_iconposition iconposition
TOPLEVEL_METHODCALL_OPTKEYS['iconposition'] = 'iconposition'
- def iconwindow(win = nil)
- if win
- tk_call_without_enc('wm', 'iconwindow', path, win)
- self
+ def Wm.iconwindow(win, iconwin = nil)
+ if iconwin
+ tk_call_without_enc('wm', 'iconwindow', win.epath, iconwin)
+ win
else
- w = tk_call_without_enc('wm', 'iconwindow', path)
+ w = tk_call_without_enc('wm', 'iconwindow', win.epath)
(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 maxsize(*args)
+ 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)
if args.size == 0
- list(tk_call_without_enc('wm', 'maxsize', path))
+ list(tk_call_without_enc('wm', 'maxsize', win.epath))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'maxsize', path, *args)
- self
+ tk_call_without_enc('wm', 'maxsize', win.epath, *args)
+ win
end
end
+ def maxsize(*args)
+ Wm.maxsize(self, *args)
+ end
+ alias wm_maxsize maxsize
TOPLEVEL_METHODCALL_OPTKEYS['maxsize'] = 'maxsize'
- def minsize(*args)
+ def Wm.minsize(win, *args)
if args.size == 0
- list(tk_call_without_enc('wm', 'minsize', path))
+ list(tk_call_without_enc('wm', 'minsize', win.epath))
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'minsize', path, *args)
- self
+ tk_call_without_enc('wm', 'minsize', win.path, *args)
+ win
end
end
+ def minsize(*args)
+ Wm.minsize(self, *args)
+ end
+ alias wm_minsize minsize
TOPLEVEL_METHODCALL_OPTKEYS['minsize'] = 'minsize'
- def overrideredirect(mode=None)
- if mode == None
- bool(tk_call_without_enc('wm', 'overrideredirect', path))
+ def Wm.overrideredirect(win, mode=TkComm::None)
+ if mode == TkComm::None
+ bool(tk_call_without_enc('wm', 'overrideredirect', win.epath))
else
- tk_call_without_enc('wm', 'overrideredirect', path, mode)
- self
+ tk_call_without_enc('wm', 'overrideredirect', win.epath, mode)
+ win
end
end
+ def overrideredirect(mode=TkComm::None)
+ Wm.overrideredirect(self, mode)
+ end
+ alias wm_overrideredirect overrideredirect
TOPLEVEL_METHODCALL_OPTKEYS['overrideredirect'] = 'overrideredirect'
- def positionfrom(who=None)
- if who == None
- r = tk_call_without_enc('wm', 'positionfrom', path)
+ def Wm.positionfrom(win, who=TkComm::None)
+ if who == TkComm::None
+ r = tk_call_without_enc('wm', 'positionfrom', win.epath)
(r == "")? nil: r
else
- tk_call_without_enc('wm', 'positionfrom', path, who)
- self
+ tk_call_without_enc('wm', 'positionfrom', win.epath, who)
+ win
end
end
+ def positionfrom(who=TkComm::None)
+ Wm.positionfrom(self, who)
+ end
+ alias wm_positionfrom positionfrom
TOPLEVEL_METHODCALL_OPTKEYS['positionfrom'] = 'positionfrom'
- def protocol(name=nil, cmd=nil, &b)
+ def Wm.protocol(win, name=nil, cmd=nil, &b)
if cmd
- tk_call_without_enc('wm', 'protocol', path, name, cmd)
- self
+ tk_call_without_enc('wm', 'protocol', win.epath, name, cmd)
+ win
elsif b
- tk_call_without_enc('wm', 'protocol', path, name, proc(&b))
- self
+ tk_call_without_enc('wm', 'protocol', win.epath, name, proc(&b))
+ win
elsif name
- result = tk_call_without_enc('wm', 'protocol', path, name)
+ result = tk_call_without_enc('wm', 'protocol', win.epath, name)
(result == "")? nil : tk_tcl2ruby(result)
else
- tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path))
+ tk_split_simplelist(tk_call_without_enc('wm', 'protocol', win.epath))
end
end
+ def protocol(name=nil, cmd=nil, &b)
+ Wm.protocol(self, name, cmd, &b)
+ end
+ alias wm_protocol protocol
- def protocols(kv=nil)
+ def Wm.protocols(win, kv=nil)
unless kv
ret = {}
- self.protocol.each{|name|
- ret[name] = self.protocol(name)
+ Wm.protocol(win).each{|name|
+ ret[name] = Wm.protocol(win, name)
}
return ret
end
@@ -279,82 +413,140 @@ module Tk
unless kv.kind_of?(Hash)
fail ArgumentError, 'expect a hash of protocol=>command'
end
- kv.each{|k, v| self.protocol(k, v)}
- self
+ kv.each{|k, v| Wm.protocol(win, k, v)}
+ win
end
+ def protocols(kv=nil)
+ Wm.protocols(self, kv)
+ end
+ alias wm_protocols protocols
TOPLEVEL_METHODCALL_OPTKEYS['protocols'] = 'protocols'
- def resizable(*args)
+ def Wm.resizable(win, *args)
if args.length == 0
- list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)}
+ list(tk_call_without_enc('wm', 'resizable', win.epath)).map!{|e| bool(e)}
else
args = args[0] if args.length == 1 && args[0].kind_of?(Array)
- tk_call_without_enc('wm', 'resizable', path, *args)
- self
+ tk_call_without_enc('wm', 'resizable', win.epath, *args)
+ win
end
end
+ def resizable(*args)
+ Wm.resizable(self, *args)
+ end
+ alias wm_resizable resizable
TOPLEVEL_METHODCALL_OPTKEYS['resizable'] = 'resizable'
- def sizefrom(who=None)
- if who == None
- r = tk_call_without_enc('wm', 'sizefrom', path)
+ def Wm.sizefrom(win, who=TkComm::None)
+ if who == TkComm::None
+ r = tk_call_without_enc('wm', 'sizefrom', win.epath)
(r == "")? nil: r
else
- tk_call_without_enc('wm', 'sizefrom', path, who)
- self
+ tk_call_without_enc('wm', 'sizefrom', win.epath, who)
+ win
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
- list(tk_call('wm', 'stackorder', path))
+ Wm.stackorder(self)
end
+ alias wm_stackorder stackorder
- def stackorder_isabove(win)
- bool(tk_call('wm', 'stackorder', path, 'isabove', win))
+ 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)
end
+ alias stackorder_is_above stackorder_isabove
+ alias wm_stackorder_isabove stackorder_isabove
+ alias wm_stackorder_is_above stackorder_isabove
- def stackorder_isbelow(win)
- bool(tk_call('wm', 'stackorder', path, 'isbelow', win))
+ def Wm.stackorder_isbelow(win, target)
+ bool(tk_call('wm', 'stackorder', win.epath, 'isbelow', target))
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 state(st=nil)
+ def Wm.state(win, st=nil)
if st
- tk_call_without_enc('wm', 'state', path, st)
- self
+ tk_call_without_enc('wm', 'state', win.epath, st)
+ win
else
- tk_call_without_enc('wm', 'state', path)
+ tk_call_without_enc('wm', 'state', win.epath)
end
end
+ def state(st=nil)
+ Wm.state(self, st)
+ end
+ alias wm_state state
TOPLEVEL_METHODCALL_OPTKEYS['state'] = 'state'
- def title(str=nil)
+ def Wm.title(win, str=nil)
if str
- tk_call('wm', 'title', path, str)
- self
+ tk_call('wm', 'title', win.epath, str)
+ win
else
- tk_call('wm', 'title', path)
+ tk_call('wm', 'title', win.epath)
end
end
+ def title(str=nil)
+ Wm.title(self, str)
+ end
+ alias wm_title title
TOPLEVEL_METHODCALL_OPTKEYS['title'] = 'title'
- def transient(master=nil)
+ def Wm.transient(win, master=nil)
if master
- tk_call_without_enc('wm', 'transient', path, master)
- self
+ tk_call_without_enc('wm', 'transient', win.epath, master)
+ win
else
- window(tk_call_without_enc('wm', 'transient', path))
+ window(tk_call_without_enc('wm', 'transient', win.epath))
end
end
+ def transient(master=nil)
+ Wm.transient(self, master)
+ end
+ alias wm_transient transient
TOPLEVEL_METHODCALL_OPTKEYS['transient'] = 'transient'
- def withdraw(ex = true)
+ def Wm.withdraw(win, ex = true)
if ex
- tk_call_without_enc('wm', 'withdraw', path)
+ tk_call_without_enc('wm', 'withdraw', win.epath)
else
- self.deiconify
+ Wm.deiconify(win)
end
- self
+ win
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/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
index 15925cba72..cfbe274c86 100644
--- a/ext/tk/lib/tkextlib/SUPPORT_STATUS
+++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -83,7 +83,7 @@ BLT 2.4z http://sourceforge.net/projects/blt
TkTreeCtrl CVS/Hd(2005-12-02)
http://sourceforge.net/projects/tktreectrl ==> treectrl
-Tile 0.7.8
+Tile 0.8.0/8.5.1
http://sourceforge.net/projects/tktable ==> tile
diff --git a/ext/tk/lib/tkextlib/blt/bitmap.rb b/ext/tk/lib/tkextlib/blt/bitmap.rb
index 31cf8d4229..23c6d2d064 100644
--- a/ext/tk/lib/tkextlib/blt/bitmap.rb
+++ b/ext/tk/lib/tkextlib/blt/bitmap.rb
@@ -13,7 +13,16 @@ module Tk::BLT
TkCommandNames = ['::blt::bitmap'.freeze].freeze
BITMAP_ID_TBL = TkCore::INTERP.create_table
- BITMAP_ID = ['blt_bitmap_id'.freeze, '00000'.taint].freeze
+
+ (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 }
+ }
def self.data(name)
dat = tk_simple_list(tk_call('::blt::bitmap', 'data', name))
@@ -64,9 +73,13 @@ module Tk::BLT
if name
@id = name
else
- @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
- BITMAP_ID[1].succ!
- BITMAP_ID_TBL[@id] = self
+ 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
+ }
end
@path = @id
diff --git a/ext/tk/lib/tkextlib/blt/busy.rb b/ext/tk/lib/tkextlib/blt/busy.rb
index 4726e466f4..2f807fcd9c 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?(TkToplevel)
+ if win.kind_of?(Tk::Toplevel)
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 ad78a5430b..b2005b2f2b 100644
--- a/ext/tk/lib/tkextlib/blt/component.rb
+++ b/ext/tk/lib/tkextlib/blt/component.rb
@@ -85,6 +85,9 @@ 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)
@@ -118,6 +121,9 @@ 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
@@ -131,6 +137,9 @@ 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)
@@ -152,6 +161,9 @@ 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)
@@ -173,6 +185,9 @@ 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)
@@ -194,6 +209,9 @@ 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
@@ -207,6 +225,9 @@ 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
@@ -220,6 +241,9 @@ 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)
@@ -241,6 +265,9 @@ 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
@@ -254,6 +281,9 @@ 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)
@@ -273,11 +303,12 @@ 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(tagOrId, option)
+ def itemcget_strict(tagOrId, option)
ret = __itemcget(tagid(tagOrId), option)
if option == 'bindtags' || option == :bindtags
ret.collect{|tag| TkBindTag.id2obj(tag)}
@@ -285,6 +316,27 @@ 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)
@@ -321,19 +373,30 @@ module Tk::BLT
ret
end
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
#################
class Axis < TkObject
- OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint].freeze
- OBJ_TBL={}
+ (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 }
+ }
def self.id2obj(chart, id)
cpath = chart.path
- return id unless OBJ_TBL[cpath]
- OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
+ AxisID_TBL.mutex.synchronize{
+ return id unless AxisID_TBL[cpath]
+ AxisID_TBL[cpath][id]? AxisID_TBL[cpath][id]: id
+ }
end
def self.new(chart, axis=nil, keys={})
@@ -341,12 +404,48 @@ module Tk::BLT
keys = axis
axis = nil
end
- 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)
+ 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
end
def initialize(chart, axis=nil, keys={})
+ # dummy:: not called by 'new' method
+
if axis.kind_of?(Hash)
keys = axis
axis = nil
@@ -354,13 +453,15 @@ module Tk::BLT
if axis
@axis = @id = axis.to_s
else
- @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
+ 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::OBJ_TBL[@cpath][@axis] = self
+ # Axis::AxisID_TBL[@cpath][@axis] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.axis_create(@axis, keys)
@@ -379,6 +480,9 @@ 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
@@ -438,17 +542,34 @@ module Tk::BLT
#################
class Crosshairs < TkObject
- OBJ_TBL={}
+ CrosshairsID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ CrosshairsID_TBL.mutex.synchronize{ CrosshairsID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(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
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- Crosshairs::OBJ_TBL[@cpath] = self
+ # Crosshairs::CrosshairsID_TBL[@cpath] = self
@chart.crosshair_configure(keys) unless keys.empty?
@path = @id = 'crosshairs'
end
@@ -464,6 +585,9 @@ 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
@@ -500,12 +624,18 @@ module Tk::BLT
ElementTypeName = 'element'
ElementTypeToClass = { ElementTypeName=>self }
+
ElementID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ ElementID_TBL.clear }
+ TkCore::INTERP.init_ip_env{
+ ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear }
+ }
- OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint].freeze
- OBJ_TBL={}
+ (OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
def Element.type2class(type)
ElementTypeToClass[type]
@@ -513,8 +643,10 @@ module Tk::BLT
def Element.id2obj(chart, id)
cpath = chart.path
- return id unless OBJ_TBL[cpath]
- OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
+ ElementID_TBL.mutex.synchronize{
+ return id unless ElementID_TBL[cpath]
+ ElementID_TBL[cpath][id]? ElementID_TBL[cpath][id]: id
+ }
end
def self.new(chart, element=nil, keys={})
@@ -522,14 +654,49 @@ module Tk::BLT
keys = element
element = nil
end
- OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
- if element && OBJ_TBL[chart.path][element]
- return OBJ_TBL[chart.path][element]
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
end
- super(chart, element, keys)
+
+ 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
end
def initialize(chart, element=nil, keys={})
+ # dummy:: not called by 'new' method
+
if element.kind_of?(Hash)
keys = element
element = nil
@@ -537,14 +704,16 @@ module Tk::BLT
if element
@element = @id = element.to_s
else
- @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
+ 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::OBJ_TBL[@cpath][@element] = self
+ # Element::ElementID_TBL[@cpath][@element] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.element_create(@element, keys)
@@ -564,6 +733,9 @@ 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)
@@ -622,17 +794,33 @@ module Tk::BLT
#################
class GridLine < TkObject
- OBJ_TBL={}
+ GridLineID_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{
+ GridLineID_TBL.mutex.synchronize{ GridLineID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(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
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- GridLine::OBJ_TBL[@cpath] = self
+ # GridLine::GridLineID_TBL[@cpath] = self
@chart.gridline_configure(keys) unless keys.empty?
@path = @id = 'grid'
end
@@ -648,6 +836,9 @@ 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
@@ -676,18 +867,35 @@ module Tk::BLT
#################
class Legend < TkObject
- OBJ_TBL={}
+ LegendID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ LegendID_TBL.mutex.synchronize{ LegendID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(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
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- Crosshairs::OBJ_TBL[@cpath] = self
- @chart.crosshair_configure(keys) unless keys.empty?
+ # Legend::LegendID_TBL[@cpath] = self
+ @chart.legend_configure(keys) unless keys.empty?
@path = @id = 'legend'
end
@@ -702,6 +910,9 @@ 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
@@ -729,13 +940,24 @@ module Tk::BLT
#################
class Pen < TkObject
- OBJ_ID = ['blt_chart_pen'.freeze, '00000'.taint].freeze
- OBJ_TBL={}
+ (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 }
+ }
def self.id2obj(chart, id)
cpath = chart.path
- return id unless OBJ_TBL[cpath]
- OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
+ PenID_TBL.mutex.synchronize{
+ return id unless PenID_TBL[cpath]
+ PenID_TBL[cpath][id]? PenID_TBL[cpath][id]: id
+ }
end
def self.new(chart, pen=nil, keys={})
@@ -743,9 +965,43 @@ module Tk::BLT
keys = pen
pen = nil
end
- 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)
+ 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
end
def initialize(chart, pen=nil, keys={})
@@ -756,13 +1012,15 @@ module Tk::BLT
if pen
@pen = @id = pen.to_s
else
- @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
+ 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::OBJ_TBL[@cpath][@pen] = self
+ Pen::PenID_TBL[@cpath][@pen] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.pen_create(@pen, keys)
@@ -781,6 +1039,9 @@ 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
@@ -805,17 +1066,34 @@ module Tk::BLT
#################
class Postscript < TkObject
- OBJ_TBL={}
+ PostscriptID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PostscriptID_TBL.mutex.synchronize{ PostscriptID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(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
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- Postscript::OBJ_TBL[@cpath] = self
+ # Postscript::PostscriptID_TBL[@cpath] = self
@chart.postscript_configure(keys) unless keys.empty?
@path = @id = 'postscript'
end
@@ -831,6 +1109,9 @@ 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
@@ -870,7 +1151,9 @@ module Tk::BLT
MarkerTypeToClass = {}
MarkerID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ MarkerID_TBL.clear }
+ TkCore::INTERP.init_ip_env{
+ MarkerID_TBL.mutex.synchronize{ MarkerID_TBL.clear }
+ }
def Marker.type2class(type)
MarkerTypeToClass[type]
@@ -878,8 +1161,13 @@ module Tk::BLT
def Marker.id2obj(chart, id)
cpath = chart.path
- return id unless MarkerID_TBL[cpath]
- MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
+ MarkerID_TBL.mutex.synchronize{
+ if MarkerID_TBL[cpath]
+ MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
end
def self._parse_create_args(keys)
@@ -902,6 +1190,13 @@ 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)
@@ -943,10 +1238,10 @@ module Tk::BLT
@parent = @chart = chart
@cpath = chart.path
@id = id
- 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
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ }
}
obj
end
@@ -956,10 +1251,10 @@ module Tk::BLT
@cpath = parent.path
@path = @id = create_self(*args) # an integer number as 'item id'
- 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
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ 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'
@@ -977,6 +1272,9 @@ 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
@@ -1037,14 +1335,14 @@ module Tk::BLT
#################
def __destroy_hook__
- 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)
+ 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)
super()
end
@@ -1559,6 +1857,9 @@ 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)
@@ -1628,6 +1929,9 @@ 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)
@@ -1697,6 +2001,9 @@ 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)
@@ -1766,6 +2073,9 @@ 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/dragdrop.rb b/ext/tk/lib/tkextlib/blt/dragdrop.rb
index 68fb9e591a..201548504a 100644
--- a/ext/tk/lib/tkextlib/blt/dragdrop.rb
+++ b/ext/tk/lib/tkextlib/blt/dragdrop.rb
@@ -81,6 +81,24 @@ 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)
@@ -107,6 +125,24 @@ 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)
@@ -145,6 +181,24 @@ 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 586a42470c..0dba87a7cc 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 TkCanvas
+class Tk::Canvas
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 a0cf3dc036..0d9cb30185 100644
--- a/ext/tk/lib/tkextlib/blt/htext.rb
+++ b/ext/tk/lib/tkextlib/blt/htext.rb
@@ -22,6 +22,7 @@ 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 0be9d8d42a..dfa10269ed 100644
--- a/ext/tk/lib/tkextlib/blt/table.rb
+++ b/ext/tk/lib/tkextlib/blt/table.rb
@@ -29,6 +29,9 @@ module Tk::BLT
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)
+ end
def blt_table_configure(*args)
Tk::BLT::Table.configure(self, *args)
@@ -92,6 +95,9 @@ module Tk::BLT
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)
+ end
def blt_table_itemconfigure(*args)
Tk::BLT::Table.itemconfigure(self, *args)
@@ -136,12 +142,13 @@ class << Tk::BLT::Table
private :__item_pathname
alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
alias __itemconfigure itemconfigure
alias __itemconfiginfo itemconfiginfo
alias __current_itemconfiginfo current_itemconfiginfo
- private :__itemcget, :__itemconfigure
- private :__itemconfiginfo, :__current_itemconfiginfo
+ private :__itemcget, :__itemcget_strict
+ private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
def __boolval_optkeys
super() << 'propagate'
@@ -176,6 +183,9 @@ 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)
@@ -192,6 +202,9 @@ 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)
diff --git a/ext/tk/lib/tkextlib/blt/tabset.rb b/ext/tk/lib/tkextlib/blt/tabset.rb
index c26b6ee001..ca81ad8f95 100644
--- a/ext/tk/lib/tkextlib/blt/tabset.rb
+++ b/ext/tk/lib/tkextlib/blt/tabset.rb
@@ -12,14 +12,26 @@ module Tk::BLT
include TkTreatItemFont
TabID_TBL = TkCore::INTERP.create_table
- TabsetTab_ID = ['blt_tabset_tab'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TabID_TBL.clear }
+ (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 }
+ }
def self.id2obj(tabset, id)
tpath = tabset.path
- return id unless TabID_TBL[tpath]
- TabID_TBL[tpath][id]? TabID_TBL[tpath]: id
+ TabID_TBL.mutex.synchronize{
+ if TabID_TBL[tpath]
+ TabID_TBL[tpath][id]? TabID_TBL[tpath]: id
+ else
+ id
+ end
+ }
end
def self.new(parent, pos=nil, name=nil, keys={})
@@ -32,12 +44,20 @@ module Tk::BLT
keys = name
name = nil
end
-
- if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
- TabID_TBL[parent.path][name]
- else
- super(parent, pos, name, keys)
- 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
end
def initialize(parent, pos, name, keys)
@@ -45,9 +65,6 @@ 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)
@@ -58,18 +75,18 @@ module Tk::BLT
end
end
tk_call(@tpath, 'tab', 'configure', @id, keys)
- return
+ else
+ pos = 'end' unless pos
+ tk_call(@tpath, 'insert', pos, @id, keys)
end
-
else
- @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!
+ 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)
end
-
- pos = 'end' unless pos
- tk_call(@tpath, 'insert', pos, @id, keys)
end
#def bind(context, cmd=Proc.new, *args)
@@ -111,6 +128,9 @@ 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
@@ -123,7 +143,9 @@ module Tk::BLT
def delete()
@t.delete(@id)
- TabID_TBL[@tpath].delete(@id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@tpath].delete(@id)
+ }
self
end
@@ -184,7 +206,9 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
def __destroy_hook__
- Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
+ Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
+ Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
+ }
end
########################################
@@ -219,6 +243,7 @@ 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
@@ -291,11 +316,15 @@ 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[@path].delete(first.id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(first.id)
+ }
end
# middle tabs of the range are unknown
if last.kind_of?(Tk::BLT::Tabset::Tab)
- TabID_TBL[@path].delete(last.id)
+ TabID_TBL.mutex.synchronize{
+ 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 39495842b4..670265fc78 100644
--- a/ext/tk/lib/tkextlib/blt/ted.rb
+++ b/ext/tk/lib/tkextlib/blt/ted.rb
@@ -30,11 +30,14 @@ module Tk::BLT
end
private :__item_config_cmd
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
def cget(master, option)
- itemconfigure(master, slot, value)
+ itemcget(master, option)
+ end
+ def cget_strict(master, option)
+ itemcget_strict(master, option)
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 dd715c8b98..2e0863cfbe 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 < TkButton
+ class Button < Tk::Button
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 ad58999d86..da230b5925 100644
--- a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class CheckButton < TkCheckButton
+ class CheckButton < Tk::CheckButton
TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze
end
Checkbutton = CheckButton
diff --git a/ext/tk/lib/tkextlib/blt/tile/frame.rb b/ext/tk/lib/tkextlib/blt/tile/frame.rb
index 10469fd35f..5434af4b72 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 < TkFrame
+ class Frame < Tk::Frame
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 ec67babd58..f370c1403b 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 < TkLabel
+ class Label < Tk::Label
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 2316923b19..814f9a5cc4 100644
--- a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class RadioButton < TkRadioButton
+ class RadioButton < Tk::RadioButton
TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze
end
Radiobutton = RadioButton
diff --git a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
index ba3bf316f0..2ae871d518 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 < TkScrollbar
+ class Scrollbar < Tk::Scrollbar
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 6cc2c91415..76d5f86b1b 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 < TkToplevel
+ class Toplevel < Tk::Toplevel
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 07dc7ef7e8..77b85f1717 100644
--- a/ext/tk/lib/tkextlib/blt/tree.rb
+++ b/ext/tk/lib/tkextlib/blt/tree.rb
@@ -12,53 +12,77 @@ module Tk::BLT
###################################
- class Node < TkObject
+ class Node < TkObject
TreeNodeID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- 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
+ 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
id
end
- end
+ }
end
def self.new(tree, parent, keys={})
keys = _symbolkey2str(keys)
tpath = tree.path
- 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
+ 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
- super(tree, parent, keys)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
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
@@ -243,17 +267,42 @@ module Tk::BLT
class Tag < TkObject
TreeTagID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear }
- TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint].freeze
+
+ 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
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TreeTagID_TBL[tpath]
- if TreeTagID_TBL[tpath][id]
- TreeTagID_TBL[tpath][id]
- else
- self.new(tree, id)
- end
+ 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
+ }
end
def initialize(tree, tag_str = nil)
@@ -263,12 +312,15 @@ module Tk::BLT
if tag_str
@path = @id = tag_str.dup.freeze
else
- @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
- TreeTagID_TBL[@id] = self
- TreeTag_ID[1].succ!
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
+ TreeTag_ID[1].succ!
+ }
end
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
end
def id
@@ -287,7 +339,9 @@ module Tk::BLT
def forget()
tk_call(@tpath, 'tag', 'forget', @id)
- TreeTagID_TBL[@tpath].delete(@id)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath].delete(@id)
+ }
self
end
@@ -312,44 +366,63 @@ module Tk::BLT
class Notify < TkObject
NotifyID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ NotifyID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ NotifyID_TBL.mutex.synchronize{ NotifyID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless NotifyID_TBL[tpath]
- if NotifyID_TBL[tpath][id]
- NotifyID_TBL[tpath][id]
- else
- begin
- self.new([tree, id])
- rescue
- id
+ 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
end
- end
+ }
end
def self.new(tree, *args, &b)
- if tree.kind_of?(Array)
- # not create
- if obj = NotifyID_TBL[tree[0].path][tree[1]]
+ 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
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)
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
end
- def initialize(create, tree, *args, &b)
+ def initialize(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
@@ -378,7 +451,9 @@ module Tk::BLT
def delete()
tk_call(@tpath, 'notify', 'delete', @id)
- NotifyID_TBL[tpath].delete(@id)
+ NotifyID_TBL.mutex.synchronize{
+ NotifyID_TBL[@tpath].delete(@id)
+ }
self
end
@@ -395,44 +470,69 @@ module Tk::BLT
class Trace < TkObject
TraceID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TraceID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ TraceID_TBL.mutex.synchronize{ TraceID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TraceID_TBL[tpath]
- if TraceID_TBL[tpath][id]
- TraceID_TBL[tpath][id]
- else
- begin
- self.new([tree, id])
- rescue
+ 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
id
end
- end
+ }
end
def self.new(tree, *args, &b)
- if tree.kind_of?(Array)
- # not create
- if obj = TraceID_TBL[tree[0].path][tree[1]]
+ 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
return obj
- else
- return super(false, tree[0], tree[1])
end
- end
- super(true, tree, *args, &b)
+ # super(true, tree, *args, &b)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
end
- def initialize(create, tree, node, key, opts, cmd=nil, &b)
+ def initialize(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)
@@ -459,7 +559,9 @@ module Tk::BLT
def delete()
tk_call(@tpath, 'trace', 'delete', @id)
- TraceID_TBL[tpath].delete(@id)
+ TraceID_TBL.mutex.synchronize{
+ TraceID_TBL[tpath].delete(@id)
+ }
self
end
@@ -475,7 +577,12 @@ module Tk::BLT
###################################
TreeID_TBL = TkCore::INTERP.create_table
- Tree_ID = ['blt_tree'.freeze, '00000'.taint].freeze
+
+ (Tree_ID = ['blt_tree'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
def __keyonly_optkeys
{
@@ -498,7 +605,9 @@ module Tk::BLT
end
def self.id2obj(id)
- TreeID_TBL[id]? TreeID_TBL[id]: id
+ TreeID_TBL.mutex.synchronize{
+ TreeID_TBL[id]? TreeID_TBL[id]: id
+ }
end
def self.names(pat = None)
@@ -513,27 +622,45 @@ module Tk::BLT
end
def self.new(name = nil)
- return TreeID_TBL[name] if name && TreeID_TBL[name]
- super(name)
+ 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
+ }
end
def initialzie(name = nil)
if name
@path = @id = name
else
- @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
- TreeID_TBL[@id] = self
- Tree_ID[1].succ!
+ Tree_ID.mutex.synchronize{
+ @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
+ 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.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)
+ 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)
+ }
end
def tagid(tag)
@@ -592,12 +719,14 @@ module Tk::BLT
def delete(*nodes)
tk_call('::blt::tree', 'delete', *(nodes.collect{|node| tagid(node)}))
- 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
+ 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
+ }
}
self
end
@@ -728,7 +857,9 @@ module Tk::BLT
id.delete
else
tk_call(@path, 'notify', 'delete', id)
- Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
+ }
end
self
end
@@ -835,7 +966,9 @@ 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[@path].delete(tag)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@path].delete(tag)
+ }
self
end
@@ -889,7 +1022,9 @@ module Tk::BLT
def trace_delete(*args)
args = args.collect{|id| tagid(id)}
tk_call(@path, 'trace', 'delete', *args)
- args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ 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 0343d28b9c..c5a5697186 100644
--- a/ext/tk/lib/tkextlib/blt/treeview.rb
+++ b/ext/tk/lib/tkextlib/blt/treeview.rb
@@ -98,6 +98,9 @@ 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
@@ -111,6 +114,9 @@ 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
@@ -129,6 +135,14 @@ 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
@@ -170,6 +184,9 @@ 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
@@ -183,6 +200,9 @@ 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
@@ -193,8 +213,8 @@ module Tk::BLT::Treeview::ConfigMethod
current_itemconfiginfo('text', slot)
end
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
class Tk::BLT::Treeview
@@ -239,6 +259,24 @@ 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)
@@ -273,8 +311,12 @@ class Tk::BLT::Treeview
########################
def __destroy_hook__
- Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
- Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
+ 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)
+ }
end
def tagid(tag)
@@ -472,6 +514,24 @@ 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)
@@ -487,7 +547,8 @@ 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.join(' '))
+ FindExecFlagValue.new(cmd, *args)
elsif TkComm._callback_entry?(val)
FindExecFlagValue.new(val)
else
@@ -967,22 +1028,47 @@ 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
- TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
+ (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 }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- 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
+ 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
id
end
- end
+ }
end
def self.new(tree, pos, parent=nil, keys={})
@@ -994,13 +1080,21 @@ class Tk::BLT::Treeview::Node < TkObject
keys = _symbolkey2str(keys)
tpath = tree.path
- 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
+ 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
- super(tree, pos, parent, keys)
+ #super(tree, pos, parent, keys)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, pos, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
end
def initialize(tree, pos, parent, keys)
@@ -1008,11 +1102,18 @@ 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 = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
- TreeNode_ID[1].succ!
+ name = nil
+ TreeNode_ID.mutex.synchronize{
+ name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeNode_ID[1].succ!
+ }
at = keys.delete['at']
@@ -1035,9 +1136,6 @@ 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
@@ -1051,37 +1149,66 @@ 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
- TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear }
+ (TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
- def self.id2obj(tree, id)
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ def self.id2obj(tree, name)
tpath = tree.path
- 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
+ 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
id
end
- end
+ }
end
def self.new_by_name(tree, name, *ids)
- if (obj = TreeTagID_TBL[tree.path][name])
- return obj
- end
- new([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
+ }
end
def self.new(tree, *ids)
- if tree.kind_of?(Array)
- super(tree[0], tree[1], ids)
- else
- super(tree, nil, ids)
- end
+ 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
+ }
end
def initialize(tree, name, ids)
@@ -1091,13 +1218,12 @@ class Tk::BLT::Treeview::Tag < TkObject
if name
@path = @id = name
else
- @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
- TreeTag_ID[1].succ!
+ TreeTag_ID.mutex.synchronize{
+ @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 3130c1e56f..445002d7a5 100644
--- a/ext/tk/lib/tkextlib/blt/unix_dnd.rb
+++ b/ext/tk/lib/tkextlib/blt/unix_dnd.rb
@@ -30,11 +30,14 @@ module Tk::BLT
end
private :__item_config_cmd
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
def cget(win, option)
- itemconfigure(['cget', win], slot, value)
+ itemcget(['cget', win], option)
+ end
+ def cget_strict(win, option)
+ itemcget_strict(['cget', win], option)
end
def configure(win, slot, value=None)
itemconfigure(['configure', win], slot, value)
@@ -46,8 +49,11 @@ module Tk::BLT
current_itemconfiginfo(['configure', win], slot)
end
- def tokwn_cget(win, option)
- itemconfigure(['token', 'cget', win], slot, value)
+ def token_cget(win, option)
+ itemcget(['token', 'cget', win], option)
+ end
+ def token_cget_strict(win, option)
+ itemcget_strict(['token', 'cget', win], option)
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 540b6b9102..76c12a24e8 100644
--- a/ext/tk/lib/tkextlib/blt/vector.rb
+++ b/ext/tk/lib/tkextlib/blt/vector.rb
@@ -23,14 +23,17 @@ module Tk::BLT
end
def self.names(pat=None)
- 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
+ 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
+ }
}
end
@@ -53,7 +56,9 @@ module Tk::BLT
"#auto", *hash_kv(keys))
end
- TkVar_ID_TBL[@id] = self
+ TkVar_ID_TBL.mutex.synchronize{
+ TkVar_ID_TBL[@id] = self
+ }
@def_default = false
@default_val = nil
@@ -221,13 +226,21 @@ module Tk::BLT
class VectorAccess < Vector
def self.new(name)
- return TkVar_ID_TBL[name] if TkVar_ID_TBL[name]
- super(name, size=nil, keys={})
+ 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
+ }
end
def initialize(vec_name)
@id = vec_name
- TkVar_ID_TBL[@id] = self
@def_default = false
@default_val = nil
diff --git a/ext/tk/lib/tkextlib/blt/watch.rb b/ext/tk/lib/tkextlib/blt/watch.rb
index ae5e50f126..219ff78e97 100644
--- a/ext/tk/lib/tkextlib/blt/watch.rb
+++ b/ext/tk/lib/tkextlib/blt/watch.rb
@@ -13,11 +13,23 @@ module Tk::BLT
TkCommandNames = ['::blt::watch'.freeze].freeze
WATCH_ID_TBL = TkCore::INTERP.create_table
- BLT_WATCH_ID = ['blt_watch_id'.freeze, '00000'.taint].freeze
+
+ (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 }
+ }
def self.names(state = None)
- tk_split_list(tk_call('::blt::watch', 'names', state)).collect{|name|
- WATCH_ID_TBL[name] || name
+ lst = tk_split_list(tk_call('::blt::watch', 'names', state))
+ WATCH_ID_TBL.mutex.synchronize{
+ lst.collect{|name|
+ WATCH_ID_TBL[name] || name
+ }
}
end
@@ -45,13 +57,17 @@ module Tk::BLT
if name
@id = name.to_s
else
- @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
- BLT_WATCH_ID[1].succ!
+ BLT_WATCH_ID.mutex.synchronize{
+ @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
+ BLT_WATCH_ID[1].succ!
+ }
end
@path = @id
- WATCH_ID_TBL[@id] = self
+ WATCH_ID_TBL.mutex.synchronize{
+ WATCH_ID_TBL[@id] = self
+ }
tk_call('::blt::watch', 'create', @id, *hash_kv(keys))
end
@@ -130,7 +146,7 @@ module Tk::BLT
end
end
end
- def cget(key)
+ def cget_strict(key)
key = key.to_s
begin
info.assoc(key)[1]
@@ -138,5 +154,22 @@ 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 4a9d4a7948..8f3087d098 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 < TkButton
+ class Button < Tk::Button
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
index ef999239f9..8d6d212189 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?(TkButton)
+ if tagOrId.kind_of?(Tk::Button)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
@@ -40,7 +40,13 @@ class Tk::BWidget::ButtonBox
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -54,7 +60,7 @@ class Tk::BWidget::ButtonBox
name = idx[:name]
idx = name unless name.empty?
end
- if idx.kind_of?(TkButton)
+ if idx.kind_of?(Tk::Button)
idx = idx[:text]
end
number(tk_send('index', idx.to_s))
@@ -62,7 +68,13 @@ class Tk::BWidget::ButtonBox
def insert(idx, keys={}, &b)
win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/combobox.rb b/ext/tk/lib/tkextlib/bwidget/combobox.rb
index 31f71c3aaf..1c58a4ccb0 100644
--- a/ext/tk/lib/tkextlib/bwidget/combobox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/combobox.rb
@@ -25,7 +25,13 @@ class Tk::BWidget::ComboBox
def get_listbox(&b)
win = window(tk_send_without_enc('getlistbox'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb
index 2790d88d24..291ca4a962 100644
--- a/ext/tk/lib/tkextlib/bwidget/dialog.rb
+++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb
@@ -59,6 +59,13 @@ 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')
@@ -103,7 +110,7 @@ class Tk::BWidget::Dialog
name = tagOrId[:name]
return index(name) unless name.empty?
end
- if tagOrId.kind_of?(TkButton)
+ if tagOrId.kind_of?(Tk::Button)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
@@ -112,19 +119,37 @@ class Tk::BWidget::Dialog
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_buttonbox(&b)
win = window(@path + '.bbox')
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
index 224304f2ab..846e58062d 100644
--- a/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
+++ b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
@@ -34,6 +34,13 @@ 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
index aafb4aa7ff..a56890f4e3 100644
--- a/ext/tk/lib/tkextlib/bwidget/entry.rb
+++ b/ext/tk/lib/tkextlib/bwidget/entry.rb
@@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb'
module Tk
module BWidget
- class Entry < TkEntry
+ class Entry < Tk::Entry
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/label.rb b/ext/tk/lib/tkextlib/bwidget/label.rb
index ce10ecaf8b..88a504aa50 100644
--- a/ext/tk/lib/tkextlib/bwidget/label.rb
+++ b/ext/tk/lib/tkextlib/bwidget/label.rb
@@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb'
module Tk
module BWidget
- class Label < TkLabel
+ class Label < Tk::Label
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb
index 931feb9b48..95b40946a6 100644
--- a/ext/tk/lib/tkextlib/bwidget/labelentry.rb
+++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb
@@ -11,7 +11,7 @@ require 'tkextlib/bwidget/entry'
module Tk
module BWidget
- class LabelEntry < TkEntry
+ class LabelEntry < Tk::Entry
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/ext/tk/lib/tkextlib/bwidget/labelframe.rb
index f7b267eebb..dc221806e4 100644
--- a/ext/tk/lib/tkextlib/bwidget/labelframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/labelframe.rb
@@ -40,7 +40,13 @@ class Tk::BWidget::LabelFrame
end
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb
index 1267500661..093fcb6fb3 100644
--- a/ext/tk/lib/tkextlib/bwidget/listbox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb
@@ -211,14 +211,26 @@ class Tk::BWidget::ListBox::Item
include TkTreatTagFont
ListItem_TBL = TkCore::INTERP.create_table
- ListItem_ID = ['bw:item'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ ListItem_TBL.clear }
+ (ListItem_ID = ['bw:item'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ListItem_TBL.mutex.synchronize{ ListItem_TBL.clear }
+ }
def self.id2obj(lbox, id)
lpath = lbox.path
- return id unless ListItem_TBL[lpath]
- ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ ListItem_TBL.mutex.synchronize{
+ if ListItem_TBL[lpath]
+ ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(lbox, *args)
@@ -250,13 +262,17 @@ class Tk::BWidget::ListBox::Item
if keys.key?('itemname')
@path = @id = keys.delete('itemname')
else
- @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
- ListItem_ID[1].succ!
+ ListItem_ID.mutex.synchronize{
+ @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
+ ListItem_ID[1].succ!
+ }
end
- ListItem_TBL[@id] = self
- ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
- ListItem_TBL[@lpath][@id] = self
+ ListItem_TBL.mutex.synchronize{
+ ListItem_TBL[@id] = self
+ ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
+ ListItem_TBL[@lpath][@id] = self
+ }
@listbox.insert(index, @id, keys)
end
@@ -281,6 +297,9 @@ class Tk::BWidget::ListBox::Item
def cget(key)
@listbox.itemcget(@id, key)
end
+ def cget_strict(key)
+ @listbox.itemcget_strict(@id, key)
+ end
def configure(key, val=None)
@listbox.itemconfigure(@id, key, val)
diff --git a/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/ext/tk/lib/tkextlib/bwidget/mainframe.rb
index c54e878557..de66eaf81e 100644
--- a/ext/tk/lib/tkextlib/bwidget/mainframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/mainframe.rb
@@ -41,37 +41,73 @@ class Tk::BWidget::MainFrame
def add_indicator(keys={}, &b)
win = window(tk_send('addindicator', *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def add_toolbar(&b)
win = window(tk_send('addtoolbar'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_indicator(idx, &b)
win = window(tk_send('getindicator', idx))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_menu(menu_id, &b)
win = window(tk_send('getmenu', menu_id))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_toolbar(idx, &b)
win = window(tk_send('gettoolbar', idx))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
index 9c946d0630..b88461baf7 100644
--- a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
+++ b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
@@ -65,6 +65,17 @@ class Tk::BWidget::MessageDlg
end
@keys[slot]
end
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'relative'
+ slot = 'parent'
+ end
+ if winfo_exist?
+ val = super(slot)
+ @keys[slot] = val
+ end
+ @keys[slot]
+ end
def configure(slot, value=None)
if winfo_exist?
@@ -173,6 +184,9 @@ class Tk::BWidget::MessageDlg
end
def create
- num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ # return the index of the pressed button, or nil if it is destroyed
+ ret = num_or_str(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ (ret < 0)? nil: ret
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb
index 5146d4915d..423943619c 100644
--- a/ext/tk/lib/tkextlib/bwidget/notebook.rb
+++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb
@@ -89,7 +89,13 @@ class Tk::BWidget::NoteBook
def add(page, &b)
win = window(tk_send('add', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -105,7 +111,13 @@ class Tk::BWidget::NoteBook
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -115,7 +127,13 @@ class Tk::BWidget::NoteBook
def insert(index, page, keys={}, &b)
win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
index fc01284be6..fbc2c11255 100644
--- a/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
+++ b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
@@ -26,7 +26,13 @@ class Tk::BWidget::PagesManager
def add(page, &b)
win = window(tk_send('add', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -42,7 +48,13 @@ class Tk::BWidget::PagesManager
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
index 19982c6095..4d979fd523 100644
--- a/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
+++ b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
@@ -25,7 +25,13 @@ class Tk::BWidget::PanedWindow
def get_frame(idx, &b)
win = window(tk_send_without_enc('getframe', idx))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/panelframe.rb b/ext/tk/lib/tkextlib/bwidget/panelframe.rb
index 13f8817d74..84bae0768b 100644
--- a/ext/tk/lib/tkextlib/bwidget/panelframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/panelframe.rb
@@ -36,7 +36,13 @@ class Tk::BWidget::PanelFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
index fbf00f3b00..32600255d5 100644
--- a/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
+++ b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
@@ -51,4 +51,8 @@ class Tk::BWidget::ProgressDlg
def value= (val)
@keys['variable'].value = val
end
+
+ def create
+ window(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
index a3986681a5..010c960ec5 100644
--- a/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
@@ -23,7 +23,13 @@ class Tk::BWidget::ScrollableFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
index e9e53235b7..3599fd8459 100644
--- a/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
+++ b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
@@ -21,7 +21,13 @@ class Tk::BWidget::ScrolledWindow
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
index 742a84cd84..0f9014f8de 100644
--- a/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
+++ b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
@@ -10,6 +10,11 @@ require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class SelectColor < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectColor
+ end
+ class Menubutton < Tk::Menubutton
+ end
+ MenuButton = Menubutton
end
end
end
@@ -43,3 +48,26 @@ class Tk::BWidget::SelectColor
tk_call('SelectColor::setcolor', idx, color)
end
end
+
+class Tk::BWidget::SelectColor::Dialog
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def create
+ @keys['type'] = 'dialog' # 'dialog' type returns color
+ tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectColor::Menubutton
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'menubutton' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(keys)))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/ext/tk/lib/tkextlib/bwidget/selectfont.rb
index 478787602a..e53eb3b5bc 100644
--- a/ext/tk/lib/tkextlib/bwidget/selectfont.rb
+++ b/ext/tk/lib/tkextlib/bwidget/selectfont.rb
@@ -66,7 +66,7 @@ class Tk::BWidget::SelectFont::Dialog
end
def create
- @keys['type'] = 'dialog'
+ @keys['type'] = 'dialog' # 'dialog' type returns font name
tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
end
end
@@ -79,7 +79,8 @@ class Tk::BWidget::SelectFont::Toolbar
def create_self(keys)
keys = {} unless keys
keys = _symbolkey2str(keys)
- keys['type'] = 'toolbar'
- tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys))
+ keys['type'] = 'toolbar' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectFont::TkCommandNames[0],
+ @path, *hash_kv(keys)))
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb
index ca4c046e5c..48358baa5c 100644
--- a/ext/tk/lib/tkextlib/bwidget/spinbox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb
@@ -10,7 +10,7 @@ require 'tkextlib/bwidget/entry'
module Tk
module BWidget
- class SpinBox < TkEntry
+ class SpinBox < Tk::Entry
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/statusbar.rb b/ext/tk/lib/tkextlib/bwidget/statusbar.rb
index df16e4c0b7..39c678d37e 100644
--- a/ext/tk/lib/tkextlib/bwidget/statusbar.rb
+++ b/ext/tk/lib/tkextlib/bwidget/statusbar.rb
@@ -36,7 +36,13 @@ class Tk::BWidget::StatusBar
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/ext/tk/lib/tkextlib/bwidget/titleframe.rb
index f519490430..68534e66e9 100644
--- a/ext/tk/lib/tkextlib/bwidget/titleframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/titleframe.rb
@@ -21,7 +21,13 @@ class Tk::BWidget::TitleFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb
index e7178debe2..aed4512a73 100644
--- a/ext/tk/lib/tkextlib/bwidget/tree.rb
+++ b/ext/tk/lib/tkextlib/bwidget/tree.rb
@@ -263,14 +263,26 @@ class Tk::BWidget::Tree::Node
include TkTreatTagFont
TreeNode_TBL = TkCore::INTERP.create_table
- TreeNode_ID = ['bw:node'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear }
+ (TreeNode_ID = ['bw:node'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNode_TBL.mutex.synchronize{ TreeNode_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TreeNode_TBL[tpath]
- TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ TreeNode_TBL.mutex.synchronize{
+ if TreeNode_TBL[tpath]
+ TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(tree, *args)
@@ -311,13 +323,17 @@ class Tk::BWidget::Tree::Node
if keys.key?('nodename')
@path = @id = keys.delete('nodename')
else
- @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
- TreeNode_ID[1].succ!
+ TreeNode_ID.mutex.synchronize{
+ @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
+ TreeNode_ID[1].succ!
+ }
end
- TreeNode_TBL[@id] = self
- TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
- TreeNode_TBL[@tpath][@id] = self
+ TreeNode_TBL.mutex.synchronize{
+ TreeNode_TBL[@id] = self
+ TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
+ TreeNode_TBL[@tpath][@id] = self
+ }
@tree.insert(index, parent, @id, keys)
end
@@ -342,6 +358,9 @@ class Tk::BWidget::Tree::Node
def cget(key)
@tree.itemcget(@id, key)
end
+ def cget_strict(key)
+ @tree.itemcget_strict(@id, key)
+ end
def configure(key, val=None)
@tree.itemconfigure(@id, key, val)
diff --git a/ext/tk/lib/tkextlib/bwidget/widget.rb b/ext/tk/lib/tkextlib/bwidget/widget.rb
index 568e503a8b..a93364b567 100644
--- a/ext/tk/lib/tkextlib/bwidget/widget.rb
+++ b/ext/tk/lib/tkextlib/bwidget/widget.rb
@@ -29,6 +29,13 @@ module Tk::BWidget::Widget
['Widget::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
@@ -43,7 +50,13 @@ module Tk::BWidget::Widget
def self.create(klass, path, rename=None, &b)
win = window(tk_call('Widget::create', klass, path, rename))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -99,9 +112,12 @@ module Tk::BWidget::Widget
tk_call('Widget::setoption', win, option, value)
end
- def self.sub_cget(win, subwidget)
+ def self.sub_cget_strict(win, subwidget)
tk_call('Widget::subcget', win, subwidget)
end
+ def self.sub_cget(win, subwidget)
+ self.sub_cget_strict(win, subwidget)
+ end
def self.sync_options(klass, subclass, subpath, options)
tk_call('Widget::syncoptions', klass, subclass, subpath, options)
diff --git a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
index 07abf3a7bf..2b75d62eb9 100644
--- a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
+++ b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
@@ -40,16 +40,22 @@ module Tk
class ItclObject < TkObject
ITCL_CLASSNAME = ''.freeze
- ITCL_OBJ_ID = ['itclobj'.freeze, '00000'.taint].freeze
+ (ITCL_OBJ_ID = ['itclobj'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
ITCL_OBJ_TBL = {}.taint
def initialize(*args)
if (@klass = self.class::ITCL_CLASSNAME).empty?
fail RuntimeError, 'unknown itcl class (abstract class?)'
end
- @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID.mutex.synchronize{
+ @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
+ }
@path = @id
- Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
end
def self.call_proc(name, *args)
diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb
index 0626536e36..e06deb552c 100644
--- a/ext/tk/lib/tkextlib/itk/incr_tk.rb
+++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb
@@ -145,9 +145,16 @@ module Tk
private :__config_cmd
ComponentID_TBL = TkCore::INTERP.create_table
- Itk_Component_ID = ['itk:component'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear }
+ (Itk_Component_ID = ['itk:component'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ComponentID_TBL.mutex.synchronize{ ComponentID_TBL.clear }
+ }
def self.id2obj(master, id)
if master.kind_of?(TkObject)
@@ -155,8 +162,13 @@ module Tk
else
master = master.to_s
end
- return id unless ComponentID_TBL.key?(master)
- (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id
+ else
+ id
+ end
+ }
end
def self.new(master, component=nil)
@@ -171,17 +183,21 @@ module Tk
elsif component
component = component.to_s
else
- component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
- Itk_Component_ID[1].succ!
+ Itk_Component_ID.mutex.synchronize{
+ component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
+ Itk_Component_ID[1].succ!
+ }
end
- if ComponentID_TBL.key?(master)
- if ComponentID_TBL[master].key?(component)
- return ComponentID_TBL[master][component]
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ if ComponentID_TBL[master].key?(component)
+ return ComponentID_TBL[master][component]
+ end
+ else
+ ComponentID_TBL[master] = {}
end
- else
- ComponentID_TBL[master] = {}
- end
+ }
super(master, component)
end
@@ -190,7 +206,9 @@ module Tk
@master = master
@component = component
- ComponentID_TBL[@master][@component] = self
+ ComponentID_TBL.mutex.synchronize{
+ ComponentID_TBL[@master][@component] = self
+ }
begin
@widget = window(tk_call(@master, 'component', @component))
diff --git a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
index a055e07ac9..05d58c386f 100644
--- a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
@@ -47,12 +47,13 @@ class Tk::Iwidgets::Buttonbox
end
alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
alias buttonconfigure itemconfigure
alias buttonconfiginfo itemconfiginfo
alias current_buttonconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb
index 0152f8593a..8495f0e29b 100644
--- a/ext/tk/lib/tkextlib/iwidgets/calendar.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb
@@ -45,6 +45,25 @@ class Tk::Iwidgets::Calendar
class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ [?d, ?s, :date], nil ]
PROC_TBL = [ [?s, TkComm.method(:string) ], 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)
diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
index 46ca389db2..c85d356c55 100644
--- a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -47,12 +47,13 @@ class Tk::Iwidgets::Checkbox
end
alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
alias buttonconfigure itemconfigure
alias buttonconfiginfo itemconfiginfo
alias current_buttonconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
@@ -85,12 +86,24 @@ class Tk::Iwidgets::Checkbox
self
end
- def get(idx)
- simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
+ def get_tags
+ simplelist(tk_call_without_enc(@path, 'get'))
+ end
+
+ def get_objs
+ simplelist(tk_call_without_enc(@path, 'get')).collect{|id|
Tk::Itk::Component.id2obj(self, id)
}
end
+ def get(idx=nil)
+ if idx
+ bool(tk_call_without_enc(@path, 'get', index(idx)))
+ else
+ get_tags
+ end
+ end
+
def index(idx)
number(tk_call(@path, 'index', tagid(idx)))
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
index d6c668621d..8d43cc07ab 100644
--- a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
@@ -47,12 +47,13 @@ class Tk::Iwidgets::Dialogshell
end
alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
alias buttonconfigure itemconfigure
alias buttonconfiginfo itemconfiginfo
alias current_buttonconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
index 6aa933ce06..d53df216bf 100644
--- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
@@ -42,6 +42,25 @@ class Tk::Iwidgets::Entryfield
[ ?w, TkComm.method(:window) ],
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/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
index 4cc6aeecbd..d9220fecbf 100644
--- a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
@@ -30,6 +30,25 @@ class Tk::Iwidgets::Hierarchy
class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ [?n, ?s, :node], nil ]
PROC_TBL = [ [?s, TkComm.method(:string) ], 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)
@@ -57,6 +76,24 @@ class Tk::Iwidgets::Hierarchy
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)
@@ -78,6 +115,25 @@ class Tk::Iwidgets::Hierarchy
nil
]
PROC_TBL = [ [ ?s, TkComm.method(:string) ], 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)
@@ -207,7 +263,7 @@ class Tk::Iwidgets::Hierarchy
self
end
- # based on TkText widget
+ # based on Tk::Text widget
def bbox(index)
list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
diff --git a/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ext/tk/lib/tkextlib/iwidgets/menubar.rb
index dea3d34c2a..5aaefbe50d 100644
--- a/ext/tk/lib/tkextlib/iwidgets/menubar.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/menubar.rb
@@ -62,12 +62,13 @@ class Tk::Iwidgets::Menubar
end
alias menucget itemcget
+ alias menucget_strict itemcget_strict
alias menuconfigure itemconfigure
alias menuconfiginfo itemconfiginfo
alias current_menuconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
diff --git a/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
index 2bbbec7666..98ac32900c 100644
--- a/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
@@ -47,12 +47,13 @@ class Tk::Iwidgets::Messagebox
private :__item_boolval_optkeys
alias typecget itemcget
+ alias typecget_strict itemcget_strict
alias typeconfigure itemconfigure
alias typeconfiginfo itemconfiginfo
alias current_typeconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
index 0f9d713ea1..03b50633df 100644
--- a/ext/tk/lib/tkextlib/iwidgets/notebook.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
@@ -42,12 +42,13 @@ class Tk::Iwidgets::Notebook
end
alias pagecget itemcget
+ alias pagecget_strict itemcget_strict
alias pageconfigure itemconfigure
alias pageconfiginfo itemconfiginfo
alias current_pageconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
@@ -146,7 +147,12 @@ class Tk::Iwidgets::Notebook
def view(*idxs)
if idxs.size == 0
- window(tk_send_without_enc('view'))
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
else
tk_send_without_enc('view', *idxs)
self
@@ -160,8 +166,8 @@ class Tk::Iwidgets::Notebook
end
alias xview_moveto view_moveto
alias yview_moveto view_moveto
- def view_scroll(*idxs)
- view('scroll', *idxs)
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
end
alias xview_scroll view_scroll
alias yview_scroll view_scroll
diff --git a/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
index 035df0a5b8..3bf73d69fe 100644
--- a/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
@@ -42,12 +42,13 @@ class Tk::Iwidgets::Panedwindow
end
alias panecget itemcget
+ alias panecget_strict itemcget_strict
alias paneconfigure itemconfigure
alias paneconfiginfo itemconfiginfo
alias current_paneconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
diff --git a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
index 1a2821bd6a..e9d9521252 100644
--- a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -47,12 +47,13 @@ class Tk::Iwidgets::Radiobox
end
alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
alias buttonconfigure itemconfigure
alias buttonconfiginfo itemconfiginfo
alias current_buttonconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
@@ -85,10 +86,13 @@ class Tk::Iwidgets::Radiobox
self
end
- def get(idx)
- simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
- Tk::Itk::Component.id2obj(self, id)
- }
+ def get_tag
+ ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag
+ end
+ alias get get_tag
+
+ def get_obj
+ (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil
end
def index(idx)
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
index 407c8f2aad..67ad67d07e 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledcanvas
end
def method_missing(id, *args)
- if @canvas.methods.include?(id.id2name)
+ if @canvas.respond_to?(id)
@canvas.__send__(id, *args)
else
super(id, *args)
@@ -171,10 +171,16 @@ class Tk::Iwidgets::Scrolledcanvas
end
def delete(*args)
- if TkcItem::CItemID_TBL[self.path]
+ tbl = nil
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl = TkcItem::CItemID_TBL[self.path]
+ }
+ if tbl
find('withtag', *args).each{|item|
if item.kind_of?(TkcItem)
- TkcItem::CItemID_TBL[self.path].delete(item.id)
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl.delete(item.id)
+ }
end
}
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
index cd1f6f0f79..7543d557e3 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
@@ -42,7 +42,7 @@ class Tk::Iwidgets::Scrolledlistbox
end
def method_missing(id, *args)
- if @listbox.methods.include?(id.id2name)
+ if @listbox.respond_to?(id)
@listbox.__send__(id, *args)
else
super(id, *args)
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
index 12fc453e26..d6436d202a 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledtext
end
def method_missing(id, *args)
- if @text.methods.include?(id.id2name)
+ if @text.respond_to?(id)
@text.__send__(id, *args)
else
super(id, *args)
@@ -116,7 +116,7 @@ class Tk::Iwidgets::Scrolledtext
get('-displaychars', *index)
end
- def image_cget(index, slot)
+ def image_cget_strict(index, slot)
case slot.to_s
when 'text', 'label', 'show', 'data', 'file'
_fromUTF8(tk_send_without_enc('image', 'cget',
@@ -127,6 +127,27 @@ class Tk::Iwidgets::Scrolledtext
"-#{slot}")))
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.has_key?(slot.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
def image_configure(index, slot, value=None)
if slot.kind_of? Hash
@@ -322,7 +343,7 @@ class Tk::Iwidgets::Scrolledtext
def _ktext_length(txt)
- if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!!
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
return txt.length
end
###########################
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
index bb81fcca5e..bf9b5ec30a 100644
--- a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
@@ -59,7 +59,7 @@ class Tk::Iwidgets::Selectionbox
self
end
- # based on TkListbox ( and TkTextWin )
+ # based on Tk::Listbox ( and TkTextWin )
def curselection
list(tk_send_without_enc('curselection'))
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
index ab790e97a6..f772ecf8c2 100644
--- a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
@@ -49,7 +49,7 @@ class Tk::Iwidgets::Selectiondialog
self
end
- # based on TkListbox ( and TkTextWin )
+ # based on Tk::Listbox ( and TkTextWin )
def curselection
list(tk_send_without_enc('curselection'))
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
index 174b9bd506..aeee5c9038 100644
--- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
@@ -37,6 +37,25 @@ class Tk::Iwidgets::Spinner
[ ?w, TkComm.method(:window) ],
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/iwidgets/tabnotebook.rb b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
index 0d9715f87b..dbb90e5102 100644
--- a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
@@ -47,12 +47,13 @@ class Tk::Iwidgets::Tabnotebook
end
alias pagecget itemcget
+ alias pagecget_strict itemcget_strict
alias pageconfigure itemconfigure
alias pageconfiginfo itemconfiginfo
alias current_pageconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
@@ -116,6 +117,11 @@ class Tk::Iwidgets::Tabnotebook
self
end
+ def show_tab(idx)
+ @tabset.show_tab(idx)
+ self
+ end
+
def scrollcommand(cmd=Proc.new)
configure_cmd 'scrollcommand', cmd
self
@@ -147,7 +153,12 @@ class Tk::Iwidgets::Tabnotebook
def view(*index)
if index.size == 0
- window(tk_send_without_enc('view'))
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
else
tk_send_without_enc('view', *index)
self
@@ -161,8 +172,8 @@ class Tk::Iwidgets::Tabnotebook
end
alias xview_moveto view_moveto
alias yview_moveto view_moveto
- def view_scroll(*index)
- view('scroll', *index)
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
end
alias xview_scroll view_scroll
alias yview_scroll view_scroll
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
index 54e56d0514..300ba9dee0 100644
--- a/ext/tk/lib/tkextlib/iwidgets/tabset.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
@@ -42,12 +42,13 @@ class Tk::Iwidgets::Tabset
end
alias tabcget itemcget
+ alias tabcget_strict itemcget_strict
alias tabconfigure itemconfigure
alias tabconfiginfo itemconfiginfo
alias current_tabconfiginfo current_itemconfiginfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
####################################
@@ -96,4 +97,48 @@ class Tk::Iwidgets::Tabset
tk_call(@path, 'select', index(idx))
self
end
+
+ def show_tab(idx)
+ if index(idx) == 0
+ self.start = 0
+ return
+ end
+
+ reutrn unless @canvas ||= self.winfo_children[0]
+
+ delta = 1 if (delta = cget(:gap)) == 'overlap' ||
+ (delta = self.winfo_pixels(delta) + 1) <= 0
+
+ case cget(:tabpos)
+ when 's', 'n'
+ if (head = tabcget(idx, :left)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_width
+ tab_start, tab_end = @canvas .
+ find_overlapping(head, 0, head + delta, @canvas.winfo_height) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[0], bbox[2]]} . max
+
+ when 'e', 'w'
+ if (head = tabcget(idx, :top)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_height
+ tab_start, tab_end = @canvas .
+ find_overlapping(0, head, @canvas.winfo_width, head + delta) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[1], bbox[3]]} . max
+ end
+
+ if (size = tab_end - tab_start + 1) > tabs_size
+ self.start -= tab_start
+ elsif head + size > tabs_size
+ self.start -= head + size - tabs_size
+ end
+
+ self
+ end
end
diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
index 6940a9174c..7db3c2e2b7 100644
--- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
+++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
@@ -108,7 +108,7 @@ module Tk
end
end
-class TkScrollbar
+class Tk::Scrollbar
def autoscroll
# Arranges for the already existing scrollbar to be mapped
# and unmapped as needed.
diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb
index 70a45dd8e7..9014037f3d 100644
--- a/ext/tk/lib/tkextlib/tcllib/ctext.rb
+++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb
@@ -15,7 +15,7 @@ TkPackage.require('ctext')
module Tk
module Tcllib
- class CText < TkText
+ class CText < Tk::Text
PACKAGE_NAME = 'ctext'.freeze
def self.package_name
PACKAGE_NAME
diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb
index bd84488101..2244dd7a9a 100644
--- a/ext/tk/lib/tkextlib/tcllib/datefield.rb
+++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb
@@ -24,7 +24,7 @@ TkPackage.require('datefield')
module Tk
module Tcllib
- class Datefield < TkEntry
+ class Datefield < Tk::Entry
PACKAGE_NAME = 'datefield'.freeze
def self.package_name
PACKAGE_NAME
diff --git a/ext/tk/lib/tkextlib/tcllib/getstring.rb b/ext/tk/lib/tkextlib/tcllib/getstring.rb
index bf5e54e8cf..fc5d8b26d9 100644
--- a/ext/tk/lib/tkextlib/tcllib/getstring.rb
+++ b/ext/tk/lib/tkextlib/tcllib/getstring.rb
@@ -87,7 +87,7 @@ class Tk::Tcllib::GetString_Dialog
@variable.value
end
- def cget(slot)
+ def cget_strict(slot)
slot = slot.to_s
if slot == 'text'
@text
@@ -95,6 +95,9 @@ class Tk::Tcllib::GetString_Dialog
@keys[slot]
end
end
+ def cget(slot)
+ cget_strict(slot)
+ end
def configure(slot, value=None)
if slot.kind_of?(Hash)
diff --git a/ext/tk/lib/tkextlib/tcllib/ico.rb b/ext/tk/lib/tkextlib/tcllib/ico.rb
index 3beeb11a4d..8c92926a4c 100644
--- a/ext/tk/lib/tkextlib/tcllib/ico.rb
+++ b/ext/tk/lib/tkextlib/tcllib/ico.rb
@@ -94,8 +94,10 @@ class Tk::Tcllib::ICO
if keys.key?('name')
@path = keys['name'].to_s
else
- @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
- Tk_Image_ID[1].succ!
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
end
tk_call_without_enc('::ico::getIcon', file, index, '-name', @path,
'-format', 'image', *hash_kv(keys, true))
diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
index 8c9e0bd683..c4b8240c04 100644
--- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
+++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
@@ -18,7 +18,7 @@ TkPackage.require('ipentry')
module Tk
module Tcllib
- class IP_Entry < TkEntry
+ class IP_Entry < Tk::Entry
PACKAGE_NAME = 'ipentry'.freeze
def self.package_name
PACKAGE_NAME
diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb
index f5f344ceb3..06ab20f3e6 100644
--- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb
+++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb
@@ -225,7 +225,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class XYPlot < TkCanvas
+ class XYPlot < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -247,7 +247,7 @@ module Tk::Tcllib::Plotchart
@xaxis = args.shift
@yaxis = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -265,7 +265,9 @@ module Tk::Tcllib::Plotchart
private :_create_chart
def __destroy_hook__
- Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
end
def plot(series, x, y)
@@ -337,7 +339,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class PolarPlot < TkCanvas
+ class PolarPlot < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -356,7 +358,7 @@ module Tk::Tcllib::Plotchart
@radius_data = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -374,7 +376,9 @@ module Tk::Tcllib::Plotchart
private :_create_chart
def __destroy_hook__
- Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
end
def plot(series, radius, angle)
@@ -395,7 +399,7 @@ module Tk::Tcllib::Plotchart
Polarplot = PolarPlot
############################
- class IsometricPlot < TkCanvas
+ class IsometricPlot < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -430,7 +434,7 @@ module Tk::Tcllib::Plotchart
@stepsize = args.shift
end
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -475,7 +479,7 @@ module Tk::Tcllib::Plotchart
Isometricplot = IsometricPlot
############################
- class Plot3D < TkCanvas
+ class Plot3D < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -500,7 +504,7 @@ module Tk::Tcllib::Plotchart
@yaxis = args.shift
@zaxis = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -557,7 +561,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Piechart < TkCanvas
+ class Piechart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -566,7 +570,7 @@ module Tk::Tcllib::Plotchart
].freeze
def initialize(*args) # args := ([parent] [, keys])
- if args[0].kind_of?(TkCanvas)
+ if args[0].kind_of?(Tk::Canvas)
parent = args.shift
@path = parent.path
else
@@ -588,7 +592,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Barchart < TkCanvas
+ class Barchart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -626,7 +630,7 @@ module Tk::Tcllib::Plotchart
@series_size = args.shift
end
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -645,7 +649,9 @@ module Tk::Tcllib::Plotchart
private :_create_chart
def __destroy_hook__
- Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
end
def plot(series, dat, col=None)
@@ -672,7 +678,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Timechart < TkCanvas
+ class Timechart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -699,7 +705,7 @@ module Tk::Tcllib::Plotchart
@time_end = args.shift
@items = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -733,7 +739,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Gnattchart < TkCanvas
+ class Gnattchart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -772,7 +778,7 @@ module Tk::Tcllib::Plotchart
@text_width = None
end
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -834,23 +840,38 @@ module Tk::Tcllib::Plotchart
############################
class PlotSeries < TkObject
SeriesID_TBL = TkCore::INTERP.create_table
- Series_ID = ['series'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ SeriesID_TBL.clear }
+
+ (Series_ID = ['series'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TkCore::INTERP.init_ip_env{
+ SeriesID_TBL.mutex.synchronize{ SeriesID_TBL.clear }
+ }
def self.id2obj(chart, id)
path = chart.path
- return id unless SeriesID_TBL[path]
- SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ SeriesID_TBL.mutex.synchronize{
+ if SeriesID_TBL[path]
+ SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ else
+ id
+ end
+ }
end
def initialize(chart, keys=nil)
@parent = @chart_obj = chart
@ppath = @chart_obj.path
- @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
- # SeriesID_TBL[@id] = self
- SeriesID_TBL[@ppath] = {} unless SeriesID_TBL[@ppath]
- SeriesID_TBL[@ppath][@id] = self
- Series_ID[1].succ!
+ Series_ID.mutex.synchronize{
+ @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
+ Series_ID[1].succ!
+ }
+ SeriesID_TBL.mutex.synchronize{
+ SeriesID_TBL[@ppath] ||= {}
+ SeriesID_TBL[@ppath][@id] = self
+ }
dataconfig(keys) if keys.kind_of?(Hash)
end
diff --git a/ext/tk/lib/tkextlib/tcllib/swaplist.rb b/ext/tk/lib/tkextlib/tcllib/swaplist.rb
index 97de0a27c1..1c813e36da 100644
--- a/ext/tk/lib/tkextlib/tcllib/swaplist.rb
+++ b/ext/tk/lib/tkextlib/tcllib/swaplist.rb
@@ -90,7 +90,7 @@ class Tk::Tcllib::Swaplist_Dialog
end
alias selected value
- def cget(slot)
+ def cget_strict(slot)
slot = slot.to_s
if slot == 'complete_list'
@complete_list
@@ -100,6 +100,9 @@ class Tk::Tcllib::Swaplist_Dialog
@keys[slot]
end
end
+ def cget(slot)
+ cget_strict(slot)
+ end
def configure(slot, value=None)
if slot.kind_of?(Hash)
diff --git a/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb b/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
index a939a58331..d7a6c97210 100644
--- a/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
+++ b/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
@@ -70,6 +70,9 @@ module Tk::Tcllib::TablelistItemConfig
def cell_cget(tagOrId, option)
itemcget(['cell', tagOrId], option)
end
+ def cell_cget_strict(tagOrId, option)
+ itemcget_strict(['cell', tagOrId], option)
+ end
def cell_configure(tagOrId, slot, value=None)
itemconfigure(['cell', tagOrId], slot, value)
end
@@ -80,6 +83,7 @@ module Tk::Tcllib::TablelistItemConfig
current_itemconfiginfo(['cell', tagOrId], slot)
end
alias cellcget cell_cget
+ alias cellcget_strict cell_cget_strict
alias cellconfigure cell_configure
alias cellconfiginfo cell_configinfo
alias current_cellconfiginfo current_cell_configinfo
@@ -87,6 +91,9 @@ module Tk::Tcllib::TablelistItemConfig
def column_cget(tagOrId, option)
itemcget(['column', tagOrId], option)
end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
def column_configure(tagOrId, slot, value=None)
itemconfigure(['column', tagOrId], slot, value)
end
@@ -97,6 +104,7 @@ module Tk::Tcllib::TablelistItemConfig
current_itemconfiginfo(['column', tagOrId], slot)
end
alias columncget column_cget
+ alias columncget_strict column_cget_strict
alias columnconfigure column_configure
alias columnconfiginfo column_configinfo
alias current_columnconfiginfo current_column_configinfo
@@ -104,6 +112,9 @@ module Tk::Tcllib::TablelistItemConfig
def row_cget(tagOrId, option)
itemcget(['row', tagOrId], option)
end
+ def row_cget_strict(tagOrId, option)
+ itemcget_strict(['row', tagOrId], option)
+ end
def row_configure(tagOrId, slot, value=None)
itemconfigure(['row', tagOrId], slot, value)
end
@@ -114,12 +125,13 @@ module Tk::Tcllib::TablelistItemConfig
current_itemconfiginfo(['row', tagOrId], slot)
end
alias rowcget row_cget
+ alias rowcget_strict row_cget_strict
alias rowconfigure row_configure
alias rowconfiginfo row_configinfo
alias current_rowconfiginfo current_row_configinfo
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
class Tk::Tcllib::Tablelist
diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
index 92dde65ce7..b366e0198b 100644
--- a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
+++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
@@ -125,7 +125,9 @@ module Tk::Tcllib::Tkpiechart
def delete
tk_call_without_enc('::stooop::delete', @tag_key)
- CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
self
end
@@ -184,8 +186,10 @@ module Tk::Tcllib::Tkpiechart
@id = "slices(#{@tag_key})"
@tag = TkcNamedTag.new(@pie.canvas, @id)
- CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
- CItemID_TBL[@path][@id] = self
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ }
end
def tag_key
@@ -200,7 +204,9 @@ module Tk::Tcllib::Tkpiechart
def delete
tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key)
- CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
@pie._delete_slice(self)
self
end
diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb
index 7ed33b03e8..60ea012cc0 100644
--- a/ext/tk/lib/tkextlib/tile.rb
+++ b/ext/tk/lib/tkextlib/tile.rb
@@ -4,6 +4,7 @@
#
require 'tk'
+require 'tk/ttk_selector'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
@@ -17,11 +18,8 @@ require 'tkextlib/tile/setup.rb'
# TkPackage.require('tile', '0.7')
if Tk::TK_MAJOR_VERSION > 8 ||
(Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION >= 5)
- begin
- verstr = TkPackage.require('Ttk')
- rescue RuntimeError
- verstr = TkPackage.require('tile')
- end
+ TkPackage.require('tile') # for compatibility (version check of 'tile')
+ verstr = TkPackage.require('Ttk')
else
verstr = TkPackage.require('tile')
end
@@ -100,16 +98,101 @@ module Tk
end
def self.__Import_Tile_Widgets__!
+ warn 'Warning: "Tk::Tile::__Import_Tile_Widgets__!" is obsolete.' <<
+ ' To control default widget set, use "Tk.default_widget_set = :Ttk"'
Tk.tk_call('namespace', 'import', '-force', 'ttk::*')
end
- def self.load_images(imgdir, pat=TkComm::None)
- images = Hash[*TkComm.simplelist(Tk.tk_call('::tile::LoadImages',
- imgdir, pat))]
- images.keys.each{|k|
- images[k] = TkPhotoImage.new(:imagename=>images[k],
- :without_creating=>true)
+ def self.__define_LoadImages_proc_for_compatibility__!
+ # Ttk 8.5 (Tile 0.8) lost 'LoadImages' utility procedure.
+ # So, some old scripts doen't work, because those scripts use the
+ # procedure to define local styles.
+ # Of course, rewriting such Tcl/Tk scripts isn't difficult for
+ # Tcl/Tk users. However, it may be troublesome for Ruby/Tk users
+ # who use such Tcl/Tk scripts as it is.
+ # This method may help Ruby/Tk users who don't want to modify old
+ # Tcl/Tk scripts for the latest version of Ttk (Tile) extension.
+ # This method defines a comaptible 'LoadImages' procedure on the
+ # Tcl/Tk interpreter working under Ruby/Tk.
+ # Please give attention to use this method. It may conflict with
+ # some definitions on Tcl/Tk scripts.
+ klass_name = self.name
+ proc_name = 'LoadImages'
+ if Tk::Tile::USE_TTK_NAMESPACE
+ ns_list = ['::tile']
+ if Tk.info(:commands, "::ttk::#{proc_name}").empty?
+ ns_list << '::ttk'
+ end
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ ns_list = ['::ttk']
+ if Tk.info(:commands, "::tile::#{proc_name}").empty?
+ ns_list << '::tile'
+ end
+ end
+
+ ns_list.each{|ns|
+ cmd = "#{ns}::#{proc_name}"
+ unless Tk.info(:commands, cmd).empty?
+ #fail RuntimeError, "can't define '#{cmd}' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '#{cmd}' command (already exist)" if $DEBUG
+ next
+ end
+ TkNamespace.eval(ns){
+ TkCore::INTERP.add_tk_procs(proc_name, 'imgdir {patterns {*.gif}}',
+ <<-'EOS')
+ foreach pattern $patterns {
+ foreach file [glob -directory $imgdir $pattern] {
+ set img [file tail [file rootname $file]]
+ if {![info exists images($img)]} {
+ set images($img) [image create photo -file $file]
+ }
+ }
+ }
+ return [array get images]
+ EOS
+ }
}
+ end
+
+ def self.load_images(imgdir, pat=nil)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ if Tk::Tile::USE_TTK_NAMESPACE
+ cmd = '::ttk::LoadImages'
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ cmd = '::tile::LoadImages'
+ end
+ pat ||= TkComm::None
+ images = Hash[*TkComm.simplelist(Tk.tk_call(cmd, imgdir, pat))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ else ## TILE_SPEC_VERSION_ID >= 8
+ pat ||= '*.gif'
+ if pat.kind_of?(Array)
+ pat_list = pat
+ else
+ pat_list = [ pat ]
+ end
+ Dir.chdir(imgdir){
+ pat_list.each{|pat|
+ Dir.glob(pat).each{|f|
+ img = File.basename(f, '.*')
+ unless TkComm.bool(Tk.info('exists', "images(#{img})"))
+ Tk.tk_call('set', "images(#{img})",
+ Tk.tk_call('image', 'create', 'photo', '-file', f))
+ end
+ }
+ }
+ }
+ images = Hash[*TkComm.simplelist(Tk.tk_call('array', 'get', 'images'))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ end
images
end
@@ -118,12 +201,53 @@ module Tk
args.map!{|arg| TkComm._get_eval_string(arg)}.join('.')
end
- module KeyNav
- def self.enableMnemonics(w)
- Tk.tk_call('::keynav::enableMnemonics', w)
+ def self.themes(glob_ptn = nil)
+ if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::themes').empty?
+ fail RuntimeError, 'not support glob option' if glob_ptn
+ cmd = ['::tile::availableThemes']
+ else
+ glob_ptn = '*' unless glob_ptn
+ cmd = ['::ttk::themes', glob_ptn]
end
- def self.defaultButton(w)
- Tk.tk_call('::keynav::defaultButton', w)
+
+ begin
+ TkComm.simplelist(Tk.tk_call_without_enc(*cmd))
+ rescue
+ TkComm.simplelist(Tk.tk_call('lsearch', '-all', '-inline',
+ Tk::Tile::Style.theme_names,
+ glob_ptn))
+ end
+ end
+
+ def self.set_theme(theme)
+ if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::setTheme').empty?
+ cmd = '::tile::setTheme'
+ else
+ cmd = '::ttk::setTheme'
+ end
+
+ begin
+ Tk.tk_call_without_enc(cmd, theme)
+ rescue
+ Tk::Tile::Style.theme_use(theme)
+ end
+ end
+
+ module KeyNav
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ def self.enableMnemonics(w)
+ Tk.tk_call('::keynav::enableMnemonics', w)
+ end
+ def self.defaultButton(w)
+ Tk.tk_call('::keynav::defaultButton', w)
+ end
+ else # dummy
+ def self.enableMnemonics(w)
+ ""
+ end
+ def self.defaultButton(w)
+ ""
+ end
end
end
@@ -138,6 +262,12 @@ module Tk
Menu = 'TkMenuFont'
SmallCaption = 'TkSmallCaptionFont'
Icon = 'TkIconFont'
+
+ TkFont::SYSTEM_FONT_NAMES.add [
+ 'TkDefaultFont', 'TkTextFont', 'TkHeadingFont',
+ 'TkCaptionFont', 'TkTooltipFont', 'TkFixedFont',
+ 'TkMenuFont', 'TkSmallCaptionFont', 'TkIconFont'
+ ]
end
module ParseStyleLayout
@@ -176,7 +306,7 @@ module Tk
end
private :__val2ruby_optkeys
- def instate(state, script=nil, &b)
+ def ttk_instate(state, script=nil, &b)
if script
tk_send('instate', state, script)
elsif b
@@ -185,19 +315,30 @@ module Tk
bool(tk_send('instate', state))
end
end
+ alias tile_instate ttk_instate
- def state(state=nil)
+ def ttk_state(state=nil)
if state
tk_send('state', state)
else
list(tk_send('state'))
end
end
+ alias tile_state ttk_state
- def identify(x, y)
+ def ttk_identify(x, y)
ret = tk_send_without_enc('identify', x, y)
(ret.empty?)? nil: ret
end
+ alias tile_identify ttk_identify
+
+ # remove instate/state/identify method
+ # to avoid the conflict with widget options
+ if Tk.const_defined?(:USE_OBSOLETE_TILE_STATE_METHOD) && Tk::USE_OBSOLETE_TILE_STATE_METHOD
+ alias instate ttk_instate
+ alias state ttk_state
+ alias identify ttk_identify
+ end
end
######################################
@@ -223,12 +364,16 @@ module Tk
autoload :TLabelframe, 'tkextlib/tile/tlabelframe'
autoload :Labelframe, 'tkextlib/tile/tlabelframe'
+ autoload :TLabelFrame, 'tkextlib/tile/tlabelframe'
+ autoload :LabelFrame, 'tkextlib/tile/tlabelframe'
autoload :TLabel, 'tkextlib/tile/tlabel'
autoload :Label, 'tkextlib/tile/tlabel'
autoload :TMenubutton, 'tkextlib/tile/tmenubutton'
autoload :Menubutton, 'tkextlib/tile/tmenubutton'
+ autoload :TMenuButton, 'tkextlib/tile/tmenubutton'
+ autoload :MenuButton, 'tkextlib/tile/tmenubutton'
autoload :TNotebook, 'tkextlib/tile/tnotebook'
autoload :Notebook, 'tkextlib/tile/tnotebook'
@@ -262,6 +407,9 @@ module Tk
autoload :TSquare, 'tkextlib/tile/tsquare'
autoload :Square, 'tkextlib/tile/tsquare'
+ autoload :SizeGrip, 'tkextlib/tile/sizegrip'
+ autoload :Sizegrip, 'tkextlib/tile/sizegrip'
+
autoload :Treeview, 'tkextlib/tile/treeview'
autoload :Style, 'tkextlib/tile/style'
diff --git a/ext/tk/lib/tkextlib/tile/dialog.rb b/ext/tk/lib/tkextlib/tile/dialog.rb
index b10378d7de..ef2d1fe577 100644
--- a/ext/tk/lib/tkextlib/tile/dialog.rb
+++ b/ext/tk/lib/tkextlib/tile/dialog.rb
@@ -54,9 +54,21 @@ class Tk::Tile::Dialog
window(tk_call_without_enc('::ttk::dialog::clientframe', @path))
end
+ def cget_strict(slot)
+ @keys[slot.to_s]
+ end
+ def cget(slot)
+ @keys[slot.to_s]
+ end
+=begin
def cget(slot)
- @keys[slot]
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ cget_strict(slot)
+ else
+ cget_strict(slot) rescue nil
+ end
end
+=end
def configure(slot, value=None)
if slot.kind_of?(Hash)
diff --git a/ext/tk/lib/tkextlib/tile/sizegrip.rb b/ext/tk/lib/tkextlib/tile/sizegrip.rb
index ea796583b0..c5068919a4 100644
--- a/ext/tk/lib/tkextlib/tile/sizegrip.rb
+++ b/ext/tk/lib/tkextlib/tile/sizegrip.rb
@@ -9,9 +9,13 @@ module Tk
module Tile
class SizeGrip < TkWindow
end
+ Sizegrip = SizeGrip
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Sizegrip, :TkSizegrip, :TkSizeGrip)
+
+
class Tk::Tile::SizeGrip < TkWindow
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb
index b319d24d54..ca7ee99c32 100644
--- a/ext/tk/lib/tkextlib/tile/style.rb
+++ b/ext/tk/lib/tkextlib/tile/style.rb
@@ -19,9 +19,142 @@ end
class << Tk::Tile::Style
if Tk::Tile::TILE_SPEC_VERSION_ID < 8
TkCommandNames = ['style'.freeze].freeze
- else
+
+ # --- Tk::Tile::Style.__define_wrapper_proc_for_compatibility__! ---
+ # On Ttk (Tile) extension, 'style' command has imcompatible changes
+ # depend on the version of the extention. It requires modifying the
+ # Tcl/Tk scripts to define local styles. The rule for modification
+ # is a simple one. But, if users want to keep compatibility between
+ # versions of the extension, they will have to contrive to do that.
+ # It may be troublesome, especially for Ruby/Tk users.
+ # This method may help such work. This method make some definitions
+ # on the Tcl/Tk interpreter to work with different version of style
+ # command format. Please give attention to use this method. It may
+ # conflict with some definitions on Tcl/Tk scripts.
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::ttk::style').empty?
+ # fail RuntimeError,
+ # "can't define '::ttk::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]
+ }
+ }
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ else ### TILE_SPEC_VERSION_ID == 7
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::ttk::style').empty?
+ # fail RuntimeError,
+ # "can't define '::ttk::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ end
+ else ### TILE_SPEC_VERSION_ID >= 8
TkCommandNames = ['::ttk::style'.freeze].freeze
+
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::style').empty?
+ # fail RuntimeError, "can't define '::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set name [lindex $args 4]
+ set opts [lrange $args 5 end]
+ set idx [lsearch $opts -map]
+ if {$idx >= 0 && [expr $idx % 2 == 0]} {
+ # return [eval [concat [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]]
+ return [uplevel 1 [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::ttk::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::ttk::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::ttk::style $args"]
+ return [uplevel 1 ::ttk::style $args]
+ EOS
+ #########################
+ end
+ end
+
+ def __define_themes_and_setTheme_proc__!
+ TkCore::INTERP.add_tk_procs('::ttk::themes', '{ptn *}', <<-'EOS')
+ #set themes [list]
+ set themes [::ttk::style theme names]
+ foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
+ set theme [namespace tail $pkg]
+ if {[lsearch -exact $themes $theme] < 0} {
+ lappend themes $theme
+ }
+ }
+ foreach pkg [lsearch -inline -all -glob [package names] tile::theme::$ptn] {
+ set theme [namespace tail $pkg]
+ if {[lsearch -exact $themes $theme] < 0} {
+ lappend themes $theme
+ }
+ }
+ return $themes
+ EOS
+ #########################
+ TkCore::INTERP.add_tk_procs('::ttk::setTheme', 'theme', <<-'EOS')
+ variable currentTheme
+ if {[lsearch -exact [::ttk::style theme names] $theme] < 0} {
+ package require [lsearch -inline -regexp [package names] (ttk|tile)::theme::$theme]
+ }
+ ::ttk::style theme use $theme
+ set currentTheme $theme
+ EOS
end
+ private :__define_themes_and_setTheme_proc__!
def configure(style=nil, keys=nil)
if style.kind_of?(Hash)
@@ -52,11 +185,29 @@ class << Tk::Tile::Style
style = '.' unless style
if keys && keys != None
- tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
+ if keys.kind_of?(Hash)
+ tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
+ else
+ simplelist(tk_call(TkCommandNames[0], 'map', style, '-' << keys.to_s))
+ end
else
- tk_call(TkCommandNames[0], 'map', style)
+ ret = {}
+ Hash[*(simplelist(tk_call(TkCommandNames[0], 'map', style)))].each{|k, v|
+ ret[k[1..-1]] = list(v)
+ }
+ ret
end
end
+ alias map_configure map
+
+ def map_configinfo(style=nil, key=None)
+ style = '.' unless style
+ map(style, key)
+ end
+
+ def map_default_configinfo(key=None)
+ map('.', key)
+ end
def lookup(style, opt, state=None, fallback_value=None)
tk_call(TkCommandNames[0], 'lookup', style,
@@ -80,7 +231,52 @@ class << Tk::Tile::Style
end
def element_create(name, type, *args)
- tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
+ if type == 'image' || type == :image
+ element_create_image(name, *args)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
+ end
+ end
+
+ def element_create_image(name, *args)
+ fail ArgumentError, 'Must supply a base image' unless (spec = args.shift)
+ if (opts = args.shift)
+ if opts.kind_of?(Hash)
+ opts = _symbolkey2str(opts)
+ else
+ fail ArgumentError, 'bad option'
+ end
+ end
+ fail ArgumentError, 'too many arguments' unless args.empty?
+
+ if spec.kind_of?(Array)
+ # probably, command format is tile 0.8+ (Tcl/Tk8.5+) style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ else
+ fail ArgumentError, 'illegal arguments' if opts.key?('map')
+ base = spec.shift
+ opts['map'] = spec
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', base, opts)
+ end
+ else
+ # probably, command format is tile 0.7.8 or older style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ spec = [spec, *(opts.delete('map'))] if opts.key?('map')
+ end
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ end
end
def element_names()
@@ -92,16 +288,20 @@ class << Tk::Tile::Style
end
def theme_create(name, keys=nil)
+ name = name.to_s
if keys && keys != None
tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys))
else
tk_call(TkCommandNames[0], 'theme', 'create', name)
end
+ name
end
def theme_settings(name, cmd=nil, &b)
+ name = name.to_s
cmd = Proc.new(&b) if !cmd && b
tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
+ name
end
def theme_names()
@@ -109,6 +309,8 @@ class << Tk::Tile::Style
end
def theme_use(name)
+ name = name.to_s
tk_call(TkCommandNames[0], 'theme', 'use', name)
+ name
end
end
diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb
index 1142a27100..5d7db10fe9 100644
--- a/ext/tk/lib/tkextlib/tile/tbutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tbutton.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TButton < TkButton
+ class TButton < Tk::Button
end
Button = TButton
end
end
-class Tk::Tile::TButton < TkButton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Button, :TkButton)
+
+
+class Tk::Tile::TButton < Tk::Button
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
index fce799683d..172225fcec 100644
--- a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
@@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TCheckButton < TkCheckButton
+ class TCheckButton < Tk::CheckButton
end
TCheckbutton = TCheckButton
CheckButton = TCheckButton
@@ -15,7 +15,11 @@ module Tk
end
end
-class Tk::Tile::TCheckButton < TkCheckButton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Checkbutton,
+ :TkCheckbutton, :TkCheckButton)
+
+
+class Tk::Tile::TCheckButton < Tk::CheckButton
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ext/tk/lib/tkextlib/tile/tcombobox.rb
index e8e042fbd9..b64372f1c9 100644
--- a/ext/tk/lib/tkextlib/tile/tcombobox.rb
+++ b/ext/tk/lib/tkextlib/tile/tcombobox.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Combobox, :TkCombobox)
+
+
class Tk::Tile::TCombobox < Tk::Tile::TEntry
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/tentry.rb b/ext/tk/lib/tkextlib/tile/tentry.rb
index 4d57ce7756..0bea98dcd9 100644
--- a/ext/tk/lib/tkextlib/tile/tentry.rb
+++ b/ext/tk/lib/tkextlib/tile/tentry.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TEntry < TkEntry
+ class TEntry < Tk::Entry
end
Entry = TEntry
end
end
-class Tk::Tile::TEntry < TkEntry
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Entry, :TkEntry)
+
+
+class Tk::Tile::TEntry < Tk::Entry
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
@@ -24,6 +27,11 @@ class Tk::Tile::TEntry < TkEntry
WidgetClassName = 'TEntry'.freeze
WidgetClassNames[WidgetClassName] = self
+ def __optkey_aliases
+ {:vcmd=>:validatecommand, :invcmd=>:invalidcommand}
+ end
+ private :__optkey_aliases
+
def __boolval_optkeys
super() << 'exportselection'
end
diff --git a/ext/tk/lib/tkextlib/tile/tframe.rb b/ext/tk/lib/tkextlib/tile/tframe.rb
index 691c9c42af..3b5f98bb6e 100644
--- a/ext/tk/lib/tkextlib/tile/tframe.rb
+++ b/ext/tk/lib/tkextlib/tile/tframe.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TFrame < TkFrame
+ class TFrame < Tk::Frame
end
Frame = TFrame
end
end
-class Tk::Tile::TFrame < TkFrame
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Frame, :TkFrame)
+
+
+class Tk::Tile::TFrame < Tk::Frame
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tlabel.rb b/ext/tk/lib/tkextlib/tile/tlabel.rb
index 4111d1906a..7d074d3842 100644
--- a/ext/tk/lib/tkextlib/tile/tlabel.rb
+++ b/ext/tk/lib/tkextlib/tile/tlabel.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TLabel < TkLabel
+ class TLabel < Tk::Label
end
Label = TLabel
end
end
-class Tk::Tile::TLabel < TkLabel
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Label, :TkLabel)
+
+
+class Tk::Tile::TLabel < Tk::Label
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/ext/tk/lib/tkextlib/tile/tlabelframe.rb
index 8981232b25..cff66d8658 100644
--- a/ext/tk/lib/tkextlib/tile/tlabelframe.rb
+++ b/ext/tk/lib/tkextlib/tile/tlabelframe.rb
@@ -9,10 +9,16 @@ module Tk
module Tile
class TLabelframe < Tk::Tile::TFrame
end
- Labelframe = TLabelframe
+ TLabelFrame = TLabelframe
+ Labelframe = TLabelframe
+ LabelFrame = TLabelframe
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Labelframe,
+ :TkLabelframe, :TkLabelFrame)
+
+
class Tk::Tile::TLabelframe < Tk::Tile::TFrame
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ext/tk/lib/tkextlib/tile/tmenubutton.rb
index 4b81fa1c81..7c6ab28e52 100644
--- a/ext/tk/lib/tkextlib/tile/tmenubutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tmenubutton.rb
@@ -7,13 +7,19 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TMenubutton < TkMenubutton
+ class TMenubutton < Tk::Menubutton
end
- Menubutton = TMenubutton
+ TMenuButton = TMenubutton
+ Menubutton = TMenubutton
+ MenuButton = TMenubutton
end
end
-class Tk::Tile::TMenubutton < TkMenubutton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Menubutton,
+ :TkMenubutton, :TkMenuButton)
+
+
+class Tk::Tile::TMenubutton < Tk::Menubutton
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb
index a928e64b61..4d65e363da 100644
--- a/ext/tk/lib/tkextlib/tile/tnotebook.rb
+++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Notebook, :TkNotebook)
+
+
class Tk::Tile::TNotebook < TkWindow
################################
include TkItemConfigMethod
@@ -38,13 +41,35 @@ class Tk::Tile::TNotebook < TkWindow
private :__item_methodcall_optkeys
#alias tabcget itemcget
+ #alias tabcget_strict itemcget_strict
alias tabconfigure itemconfigure
alias tabconfiginfo itemconfiginfo
alias current_tabconfiginfo current_itemconfiginfo
- def tabcget(tagOrId, option)
+ def tabcget_strict(tagOrId, option)
tabconfigure(tagOrId, option)[-1]
end
+ def tabcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tabcget_strict(tagOrId, option)
+ else
+ begin
+ tabcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_tabconfiginfo(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
################################
include Tk::Tile::TileWidget
@@ -74,9 +99,9 @@ class Tk::Tile::TNotebook < TkWindow
def add(child, keys=nil)
if keys && keys != None
- tk_send_without_enc('add', _epath(child), *hash_kv(keys))
+ tk_send('add', _epath(child), *hash_kv(keys))
else
- tk_send_without_enc('add', _epath(child))
+ tk_send('add', _epath(child))
end
self
end
diff --git a/ext/tk/lib/tkextlib/tile/tpaned.rb b/ext/tk/lib/tkextlib/tile/tpaned.rb
index 2a2a25ea59..d96ff43973 100644
--- a/ext/tk/lib/tkextlib/tile/tpaned.rb
+++ b/ext/tk/lib/tkextlib/tile/tpaned.rb
@@ -13,6 +13,10 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Panedwindow,
+ :TkPanedwindow, :TkPanedWindow)
+
+
class Tk::Tile::TPaned < TkWindow
include Tk::Tile::TileWidget
@@ -32,9 +36,21 @@ class Tk::Tile::TPaned < TkWindow
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
end
- def add(win, keys)
- win = _epath(win)
- tk_send_without_enc('add', win, *hash_kv(keys))
+ def add(*args)
+ keys = args.pop
+ fail ArgumentError, "no window in arguments" unless keys
+
+ if keys && keys.kind_of?(Hash)
+ fail ArgumentError, "no window in arguments" if args == []
+ opts = hash_kv(keys)
+ else
+ args.push(keys) if keys
+ opts = []
+ end
+
+ args.each{|win|
+ tk_send_without_enc('add', _epath(win), *opts)
+ }
self
end
@@ -50,10 +66,33 @@ class Tk::Tile::TPaned < TkWindow
self
end
- def panecget(pane, slot)
+ def panecget_strict(pane, slot)
pane = _epath(pane)
tk_tcl2ruby(tk_send_without_enc('pane', pane, "-#{slot}"))
end
+ alias pane_cget_strict panecget_strict
+
+ def panecget(pane, slot)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ panecget_strict(pane, slot)
+ else
+ begin
+ panecget_strict(pane, slot)
+ rescue => e
+ begin
+ if current_paneconfiginfo(pane).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
alias pane_cget panecget
def paneconfigure(pane, key, value=nil)
diff --git a/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/ext/tk/lib/tkextlib/tile/tprogressbar.rb
index 36c1c75c23..f786d370dd 100644
--- a/ext/tk/lib/tkextlib/tile/tprogressbar.rb
+++ b/ext/tk/lib/tkextlib/tile/tprogressbar.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Progressbar, :TkProgressbar)
+
+
class Tk::Tile::TProgressbar
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ext/tk/lib/tkextlib/tile/tradiobutton.rb
index e2f614cb97..d653a6d256 100644
--- a/ext/tk/lib/tkextlib/tile/tradiobutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tradiobutton.rb
@@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TRadioButton < TkRadioButton
+ class TRadioButton < Tk::RadioButton
end
TRadiobutton = TRadioButton
RadioButton = TRadioButton
@@ -15,7 +15,11 @@ module Tk
end
end
-class Tk::Tile::TRadioButton < TkRadioButton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Radiobutton,
+ :TkRadiobutton, :TkRadioButton)
+
+
+class Tk::Tile::TRadioButton < Tk::RadioButton
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb
index 68e478896c..c978a1a07b 100644
--- a/ext/tk/lib/tkextlib/tile/treeview.rb
+++ b/ext/tk/lib/tkextlib/tile/treeview.rb
@@ -12,6 +12,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Treeview, :TkTreeview)
+
+
module Tk::Tile::TreeviewConfig
include TkItemConfigMethod
@@ -30,6 +33,12 @@ module Tk::Tile::TreeviewConfig
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 /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
begin
@@ -195,6 +204,12 @@ module Tk::Tile::TreeviewConfig
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 /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
begin
@@ -378,7 +393,7 @@ module Tk::Tile::TreeviewConfig
when :item, 'item'
['width']
when :column, 'column'
- super(id[1])
+ super(id[1]) + ['minwidth']
when :tag, 'tag'
super(id[1])
when :heading, 'heading'
@@ -410,7 +425,7 @@ module Tk::Tile::TreeviewConfig
when :item, 'item'
['open']
when :column, 'column'
- super(id[1])
+ super(id[1]) + ['stretch']
when :tag, 'tag'
super(id[1])
when :heading, 'heading'
@@ -505,17 +520,21 @@ module Tk::Tile::TreeviewConfig
end
alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
alias __itemconfigure itemconfigure
alias __itemconfiginfo itemconfiginfo
alias __current_itemconfiginfo current_itemconfiginfo
- private :__itemcget, :__itemconfigure
- private :__itemconfiginfo, :__current_itemconfiginfo
+ private :__itemcget, :__itemcget_strict
+ private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
# Treeview Item
def itemcget(tagOrId, option)
__itemcget([:item, tagOrId], option)
end
+ def itemcget_strict(tagOrId, option)
+ __itemcget_strict([:item, tagOrId], option)
+ end
def itemconfigure(tagOrId, slot, value=None)
__itemconfigure([:item, tagOrId], slot, value)
end
@@ -530,6 +549,9 @@ module Tk::Tile::TreeviewConfig
def columncget(tagOrId, option)
__itemcget([:column, tagOrId], option)
end
+ def columncget_strict(tagOrId, option)
+ __itemcget_strict([:column, tagOrId], option)
+ end
def columnconfigure(tagOrId, slot, value=None)
__itemconfigure([:column, tagOrId], slot, value)
end
@@ -540,12 +562,13 @@ module Tk::Tile::TreeviewConfig
__current_itemconfiginfo([:column, tagOrId], slot)
end
alias column_cget columncget
+ alias column_cget_strict columncget_strict
alias column_configure columnconfigure
alias column_configinfo columnconfiginfo
alias current_column_configinfo current_columnconfiginfo
# Treeview Heading
- def headingcget(tagOrId, option)
+ def headingcget_strict(tagOrId, option)
if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
begin
# On tile-0.7.{2-8}, 'state' options has no '-' at its head.
@@ -555,7 +578,28 @@ module Tk::Tile::TreeviewConfig
tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
end
else
- __itemcget([:heading, tagOrId], option)
+ __itemcget_strict([:heading, tagOrId], option)
+ end
+ end
+ def headingcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ headingcget_strict(tagOrId, option)
+ else
+ begin
+ headingcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_headingconfiginfo(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 headingconfigure(tagOrId, slot, value=None)
@@ -587,6 +631,7 @@ module Tk::Tile::TreeviewConfig
__current_itemconfiginfo([:heading, tagOrId], slot)
end
alias heading_cget headingcget
+ alias heading_cget_strict headingcget_strict
alias heading_configure headingconfigure
alias heading_configinfo headingconfiginfo
alias current_heading_configinfo current_headingconfiginfo
@@ -595,6 +640,9 @@ module Tk::Tile::TreeviewConfig
def tagcget(tagOrId, option)
__itemcget([:tag, tagOrId], option)
end
+ def tagcget_strict(tagOrId, option)
+ __itemcget_strict([:tag, tagOrId], option)
+ end
def tagconfigure(tagOrId, slot, value=None)
__itemconfigure([:tag, tagOrId], slot, value)
end
@@ -605,6 +653,7 @@ module Tk::Tile::TreeviewConfig
__current_itemconfiginfo([:tag, tagOrId], slot)
end
alias tag_cget tagcget
+ alias tag_cget_strict tagcget_strict
alias tag_configure tagconfigure
alias tag_configinfo tagconfiginfo
alias current_tag_configinfo current_tagconfiginfo
@@ -614,30 +663,43 @@ end
class Tk::Tile::Treeview::Item < TkObject
ItemID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ Tk::Tile::Treeview::Item::ItemID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
- (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
+ (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def self.assign(tree, id)
tpath = tree.path
- if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
- return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
- end
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ end
- obj = self.allocate
- obj.instance_eval{
- @parent = @t = tree
- @tpath = tpath
- @path = @id = id
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @t = tree
+ @tpath = tpath
+ @path = @id = id
+ }
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
}
- ItemID_TBL[tpath] = {} unless ItemID_TBL[tpath]
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
obj
end
@@ -666,8 +728,10 @@ class Tk::Tile::Treeview::Item < TkObject
@parent = @t = tree
@tpath = tree.path
@path = @id = _insert_item(@t, parent_item, idx, keys)
- ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
- ItemID_TBL[@tpath][@id] = self
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
+ ItemID_TBL[@tpath][@id] = self
+ }
end
def id
@id
@@ -676,6 +740,9 @@ class Tk::Tile::Treeview::Item < TkObject
def cget(option)
@t.itemcget(@id, option)
end
+ def cget_strict(option)
+ @t.itemcget_strict(@id, option)
+ end
def configure(key, value=None)
@t.itemconfigure(@id, key, value)
@@ -801,22 +868,35 @@ end
class Tk::Tile::Treeview::Root < Tk::Tile::Treeview::Item
def self.new(tree, keys = {})
tpath = tree.path
- if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
- else
- super(tree, keys)
- end
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ obj = Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ else
+ #super(tree, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
end
def initialize(tree, keys = {})
+ # dummy:: not called by 'new' method
@parent = @t = tree
@tpath = tree.path
@path = @id = ''
- unless Tk::Tile::Treeview::Item::ItemID_TBL[@tpath]
- Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] = {}
- end
- Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
end
end
@@ -826,24 +906,42 @@ class Tk::Tile::Treeview::Tag < TkObject
include TkTreatTagFont
TagID_TBL = TkCore::INTERP.create_table
- Tag_ID = ['tile_treeview_tag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ Tk::Tile::Treeview::Tag::TagID_TBL.clear }
+ (Tag_ID = ['tile_treeview_tag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::TagID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
- (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
- Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
+ (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(tree, keys=nil)
@parent = @t = tree
@tpath = tree.path
- @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
- TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
- TagID_TBL[@tpath][@id] = self
- Tag_ID[1].succ!
+ Tag_ID.mutex.synchronize{
+ @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
+ Tag_ID[1].succ!
+ }
+ TagID_TBL.mutex.synchronize{
+ TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
+ TagID_TBL[@tpath][@id] = self
+ }
if keys && keys != None
tk_call_without_enc(@tpath, 'tag', 'configure', *hash_kv(keys, true))
end
@@ -884,6 +982,9 @@ class Tk::Tile::Treeview::Tag < TkObject
def cget(option)
@t.tagcget(@id, option)
end
+ def cget_strict(option)
+ @t.tagcget_strict(@id, option)
+ end
def configure(key, value=None)
@t.tagconfigure(@id, key, value)
@@ -916,8 +1017,12 @@ class Tk::Tile::Treeview < TkWindow
WidgetClassNames[WidgetClassName] = self
def __destroy_hook__
- Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
- Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
+ }
+ Tk::Tile::Treeview::Tag::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ }
end
def self.style(*args)
diff --git a/ext/tk/lib/tkextlib/tile/tscale.rb b/ext/tk/lib/tkextlib/tile/tscale.rb
index 7ec72e3515..2c46fd9bd4 100644
--- a/ext/tk/lib/tkextlib/tile/tscale.rb
+++ b/ext/tk/lib/tkextlib/tile/tscale.rb
@@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TScale < TkScale
+ class TScale < Tk::Scale
end
Scale = TScale
@@ -17,7 +17,10 @@ module Tk
end
end
-class Tk::Tile::TScale < TkScale
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scale, :TkScale)
+
+
+class Tk::Tile::TScale < Tk::Scale
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/ext/tk/lib/tkextlib/tile/tscrollbar.rb
index 10b84e84a0..163b8f4713 100644
--- a/ext/tk/lib/tkextlib/tile/tscrollbar.rb
+++ b/ext/tk/lib/tkextlib/tile/tscrollbar.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TScrollbar < TkScrollbar
+ class TScrollbar < Tk::Scrollbar
end
Scrollbar = TScrollbar
end
end
-class Tk::Tile::TScrollbar < TkScrollbar
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scrollbar, :TkScrollbar)
+
+
+class Tk::Tile::TScrollbar < Tk::Scrollbar
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
@@ -47,3 +50,5 @@ class Tk::Tile::YScrollbar < Tk::Tile::TScrollbar
private :create_self
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::XScrollbar, :TkXScrollbar)
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::YScrollbar, :TkYScrollbar)
diff --git a/ext/tk/lib/tkextlib/tile/tseparator.rb b/ext/tk/lib/tkextlib/tile/tseparator.rb
index ca731d4e5b..30fae2c525 100644
--- a/ext/tk/lib/tkextlib/tile/tseparator.rb
+++ b/ext/tk/lib/tkextlib/tile/tseparator.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Separator, :TkSeparator)
+
+
class Tk::Tile::TSeparator < TkWindow
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tkDND/shape.rb b/ext/tk/lib/tkextlib/tkDND/shape.rb
index 570c93b0d9..d44068ed33 100644
--- a/ext/tk/lib/tkextlib/tkDND/shape.rb
+++ b/ext/tk/lib/tkextlib/tkDND/shape.rb
@@ -11,15 +11,15 @@ require 'tkextlib/setup.rb'
# call setup script
require 'tkextlib/tkDND/setup.rb'
-# TkPackage.require('shape', '0.3')
-TkPackage.require('shape')
+# TkPackage.require('Shape', '0.3')
+TkPackage.require('Shape')
module Tk
module TkDND
module Shape
extend TkCore
- PACKAGE_NAME = 'shape'.freeze
+ PACKAGE_NAME = 'Shape'.freeze
def self.package_name
PACKAGE_NAME
end
@@ -27,26 +27,28 @@ module Tk
=begin
def self.package_version
begin
- TkPackage.require('shape')
+ TkPackage.require('Shape')
rescue
''
end
end
=end
- def self.package_version
- Tk.tk_call('set', 'shape_version')
- end
- alias shape_version package_version
+ class << self
+ def package_version
+ Tk.tk_call('set', 'shape_version')
+ end
+ alias shape_version package_version
- def self.package_patchlevel
- Tk.tk_call('set', 'shape_patchlevel')
- end
- alias shape_patchlevel package_patchlevel
+ def package_patchlevel
+ Tk.tk_call('set', 'shape_patchLevel')
+ end
+ alias shape_patchlevel package_patchlevel
- def self.version
- tk_call('shape', 'version')
+ def version
+ tk_call('shape', 'version')
+ end
+ alias xshape_version version
end
- alias xshape_version version
############################
diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
index a040532eb6..9a9b2dc42c 100644
--- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
+++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
@@ -57,6 +57,24 @@ module Tk
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
_setup_subst_table(KEY_TBL, PROC_TBL);
end
diff --git a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
index 8527f61df1..d893a83cf2 100644
--- a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
+++ b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
@@ -39,7 +39,10 @@ class Tk::HTML_Widget::ClippingWindow
WidgetClassNames[WidgetClassName] = self
HtmlClip_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ HtmlClip_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ HtmlClip_TBL.mutex.synchronize{ HtmlClip_TBL.clear }
+ }
def self.new(parent, keys={})
if parent.kind_of?(Hash)
@@ -54,7 +57,9 @@ class Tk::HTML_Widget::ClippingWindow
else
ppath = ''
end
- return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+ }
widgetname = keys.delete('widgetname')
if widgetname =~ /^(.*)\.[^.]+$/
@@ -62,7 +67,9 @@ class Tk::HTML_Widget::ClippingWindow
if ppath2[0] != ?.
ppath2 = ppath + '.' + ppath2
end
- return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+ }
ppath = ppath2
end
@@ -79,7 +86,9 @@ class Tk::HTML_Widget::ClippingWindow
@parent = parent
@ppath = parent.path
@path = @id = @ppath + '.x'
- HtmlClip_TBL[@ppath] = self
+ HtmlClip_TBL.mutex.synchronize{
+ HtmlClip_TBL[@ppath] = self
+ }
end
def method_missing(m, *args, &b)
diff --git a/ext/tk/lib/tkextlib/tktable/tktable.rb b/ext/tk/lib/tkextlib/tktable/tktable.rb
index 4edaabc847..f6cf24b40f 100644
--- a/ext/tk/lib/tkextlib/tktable/tktable.rb
+++ b/ext/tk/lib/tkextlib/tktable/tktable.rb
@@ -77,6 +77,9 @@ module Tk::TkTable::ConfigMethod
def tag_cget(tagOrId, option)
itemcget(['tag', tagid(tagOrId)], option)
end
+ def tag_cget_strict(tagOrId, option)
+ itemcget_strict(['tag', tagid(tagOrId)], option)
+ end
def tag_configure(tagOrId, slot, value=None)
itemconfigure(['tag', tagid(tagOrId)], slot, value)
end
@@ -90,6 +93,9 @@ module Tk::TkTable::ConfigMethod
def window_cget(tagOrId, option)
itemcget(['window', tagid(tagOrId)], option)
end
+ def window_cget_strict(tagOrId, option)
+ itemcget_strict(['window', tagid(tagOrId)], option)
+ end
def window_configure(tagOrId, slot, value=None)
if slot == :window || slot == 'window'
value = _epath(value)
@@ -108,8 +114,8 @@ module Tk::TkTable::ConfigMethod
current_itemconfiginfo(['window', tagid(tagOrId)], slot)
end
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
#####################################################
@@ -118,23 +124,39 @@ class Tk::TkTable::CellTag
include TkTreatTagFont
CellTagID_TBL = TkCore::INTERP.create_table
- CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ CellTagID_TBL.clear }
+ (CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ CellTagID_TBL.mutex.synchronize{ CellTagID_TBL.clear }
+ }
def self.id2obj(table, id)
tpath = table.path
- return id unless CellTagID_TBL[tpath]
- CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[tpath]
+ CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys=nil)
@parent = @t = parent
@tpath - parent.path
- @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
- CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
- CellTagID_TBL[@tpath][@id] = self
- CellTag_ID[1].succ!
+ CellTag_ID.mutex.synchronize{
+ @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
+ CellTag_ID[1].succ!
+ }
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
configure(keys) if keys
end
@@ -144,7 +166,9 @@ class Tk::TkTable::CellTag
def destroy
tk_call(@tpath, 'tag', 'delete', @id)
- CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ }
self
end
alias delete destroy
@@ -176,6 +200,9 @@ class Tk::TkTable::CellTag
def cget(key)
@t.tag_cget(@id, key)
end
+ def cget_strict(key)
+ @t.tag_cget_strict(@id, key)
+ end
def configure(key, val=None)
@t.tag_configure(@id, key, val)
end
@@ -189,22 +216,35 @@ end
class Tk::TkTable::NamedCellTag < Tk::TkTable::CellTag
def self.new(parent, name, keys=nil)
- if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
- cell = CellTagID_TBL[parent.path][name]
- cell.configure(keys) if keys
- return cell
- else
- super(parent, name, keys)
- end
+ obj = nil
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
+ obj = CellTagID_TBL[parent.path][name]
+ else
+ #super(parent, name, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
end
def initialize(parent, name, keys=nil)
+ # dummy:: not called by 'new' method
@parent = @t = parent
- @tpath - parent.path
+ @tpath = parent.path
@path = @id = name
- CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
- CellTagID_TBL[@tpath][@id] = self
- configure(keys) if keys
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ configure(keys) if keys && ! keys.empty?
end
end
@@ -220,7 +260,9 @@ class Tk::TkTable
include Tk::ValidateConfigure
def __destroy_hook__
- Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ Tk::TkTable::CelTag::CellTagID_TBL.mutex.synchronize{
+ Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ }
end
def __boolval_optkeys
@@ -258,6 +300,24 @@ class Tk::TkTable
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)
@@ -291,6 +351,24 @@ class Tk::TkTable
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)
@@ -322,6 +400,24 @@ class Tk::TkTable
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)
@@ -356,6 +452,24 @@ class Tk::TkTable
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
@@ -746,15 +860,17 @@ class Tk::TkTable
end
def tagid2obj(tagid)
- if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
- if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
- Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ else
+ tagid
+ end
else
tagid
end
- else
- tagid
- end
+ }
end
def tag_cell(tag, *cells)
@@ -775,13 +891,15 @@ class Tk::TkTable
end
def tag_delete(tag)
tk_send('tag', 'delete', tagid(tag))
- if Tk::TkTable::CellTag::CellTagID_TBL[@path]
- if tag.kind_of? Tk::TkTable::CellTag
- Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
- else
- Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path]
+ if tag.kind_of? Tk::TkTable::CellTag
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
+ else
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ end
end
- end
+ }
self
end
def tag_exist?(tag)
diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb
index 665c57af0c..e051c09211 100644
--- a/ext/tk/lib/tkextlib/tktrans/tktrans.rb
+++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb
@@ -39,7 +39,7 @@ class TkWindow
end
end
-class TkRoot
+class Tk::Root
undef tktrans_set_image, tktrans_get_image
def tktrans_set_image(img)
@@ -51,7 +51,7 @@ class TkRoot
end
end
-class TkToplevel
+class Tk::Toplevel
undef tktrans_set_image, tktrans_get_image
def tktrans_set_image(img)
diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
index 12f7cffabf..e10e6e299e 100644
--- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
+++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
@@ -137,6 +137,24 @@ class Tk::TreeCtrl::NotifyEvent
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
@@ -399,6 +417,9 @@ module Tk::TreeCtrl::ConfigMethod
def column_cget(tagOrId, option)
itemcget(['column', tagOrId], option)
end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
def column_configure(tagOrId, slot, value=None)
itemconfigure(['column', tagOrId], slot, value)
end
@@ -412,6 +433,9 @@ module Tk::TreeCtrl::ConfigMethod
def column_dragcget(option)
itemcget(['column', 'drag'], option)
end
+ def column_dragcget_strict(option)
+ itemcget_strict(['column', 'drag'], option)
+ end
def column_dragconfigure(slot, value=None)
itemconfigure(['column', 'drag'], slot, value)
end
@@ -425,6 +449,9 @@ module Tk::TreeCtrl::ConfigMethod
def debug_cget(option)
itemcget('debug', option)
end
+ def debug_cget_strict(option)
+ itemcget_strict('debug', option)
+ end
def debug_configure(slot, value=None)
itemconfigure('debug', slot, value)
end
@@ -438,6 +465,9 @@ module Tk::TreeCtrl::ConfigMethod
def dragimage_cget(option)
itemcget('dragimage', option)
end
+ def dragimage_cget_strict(option)
+ itemcget_strict('dragimage', option)
+ end
def dragimage_configure(slot, value=None)
itemconfigure('dragimage', slot, value)
end
@@ -451,6 +481,9 @@ module Tk::TreeCtrl::ConfigMethod
def element_cget(tagOrId, option)
itemcget(['element', tagOrId], option)
end
+ def element_cget_strict(tagOrId, option)
+ itemcget_strict(['element', tagOrId], option)
+ end
def element_configure(tagOrId, slot, value=None)
itemconfigure(['element', tagOrId], slot, value)
end
@@ -464,6 +497,9 @@ module Tk::TreeCtrl::ConfigMethod
def item_cget(tagOrId, option)
itemcget(['item', tagOrId], option)
end
+ def item_cget_strict(tagOrId, option)
+ itemcget_strict(['item', tagOrId], option)
+ end
def item_configure(tagOrId, slot, value=None)
itemconfigure(['item', tagOrId], slot, value)
end
@@ -477,6 +513,9 @@ module Tk::TreeCtrl::ConfigMethod
def item_element_cget(item, column, elem, option)
itemcget([['item', 'element'], [item, column, elem]], option)
end
+ def item_element_cget_strict(item, column, elem, option)
+ itemcget_strict([['item', 'element'], [item, column, elem]], option)
+ end
def item_element_configure(item, column, elem, slot, value=None)
itemconfigure([['item', 'element'], [item, column, elem]], slot, value)
end
@@ -490,6 +529,9 @@ module Tk::TreeCtrl::ConfigMethod
def marquee_cget(option)
itemcget('marquee', option)
end
+ def marquee_cget_strict(option)
+ itemcget_strict('marquee', option)
+ end
def marquee_configure(slot, value=None)
itemconfigure('marquee', slot, value)
end
@@ -502,7 +544,19 @@ module Tk::TreeCtrl::ConfigMethod
def notify_cget(win, pattern, option)
pattern = "<#{pattern}>"
- itemconfigure(['notify', [win, pattern]], option)
+ # "notify" doesn't have cget subcommand.
+ current_itemconfiginfo(['notify', [win, pattern]])[option.to_s]
+ end
+ def notify_cget_strict(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ info = current_itemconfiginfo(['notify', [win, pattern]])
+ option = option.to_s
+ unless info.has_key?(option)
+ fail RuntimeError, "unknown option \"#{option}\""
+ else
+ info[option]
+ end
end
def notify_configure(win, pattern, slot, value=None)
pattern = "<#{pattern}>"
@@ -512,11 +566,17 @@ module Tk::TreeCtrl::ConfigMethod
pattern = "<#{pattern}>"
itemconfiginfo(['notify', [win, pattern]], slot)
end
- alias current_notify_configinfo notify_configinfo
+ def current_notify_configinfo(tagOrId, slot=nil)
+ pattern = "<#{pattern}>"
+ current_itemconfiginfo(['notify', [win, pattern]], slot)
+ end
def style_cget(tagOrId, option)
itemcget(['style', tagOrId], option)
end
+ def style_cget_strict(tagOrId, option)
+ itemcget_strict(['style', tagOrId], option)
+ end
def style_configure(tagOrId, slot, value=None)
itemconfigure(['style', tagOrId], slot, value)
end
@@ -527,8 +587,8 @@ module Tk::TreeCtrl::ConfigMethod
current_itemconfiginfo(['style', tagOrId], slot)
end
- private :itemcget, :itemconfigure
- private :itemconfiginfo, :current_itemconfiginfo
+ private :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
##############################################
@@ -544,10 +604,18 @@ class Tk::TreeCtrl
#########################
def __destroy_hook__
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
+ }
end
#########################
@@ -638,9 +706,11 @@ class Tk::TreeCtrl
end
def column_delete(idx)
- if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
- end
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
+ end
+ }
tk_send('column', 'delete', idx)
self
end
@@ -750,11 +820,13 @@ class Tk::TreeCtrl
end
def element_delete(*elems)
- if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
- elems.each{|elem|
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
- }
- end
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
+ elems.each{|elem|
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
+ }
+ end
+ }
tk_send('element', 'delete', *elems)
self
end
@@ -885,22 +957,25 @@ class Tk::TreeCtrl
def _erase_children(item)
item_children(item).each{|i| _erase_children(i)}
+ # table is already locked
Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].delete(item)
end
private :_erase_children
def item_delete(first, last=None)
- if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
- if first == 'all' || first == :all || last == 'all' || last == :all
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
- elsif last == None
- _erase_children(first)
- else
- self.range(first, last).each{|id|
- _erase_children(id)
- }
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
+ if first == 'all' || first == :all || last == 'all' || last == :all
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
+ elsif last == None
+ _erase_children(first)
+ else
+ self.range(first, last).each{|id|
+ _erase_children(id)
+ }
+ end
end
- end
+ }
tk_send('item', 'delete', first, last)
self
end
@@ -1520,11 +1595,13 @@ class Tk::TreeCtrl
end
def style_delete(*args)
- if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
- args.each{|sty|
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
- }
- end
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
+ args.each{|sty|
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
+ }
+ end
+ }
tk_send('style', 'delete', *args)
self
end
@@ -1608,15 +1685,29 @@ end
class Tk::TreeCtrl::Column < TkObject
TreeCtrlColumnID_TBL = TkCore::INTERP.create_table
- TreeCtrlColumnID = ['treectrl_column'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear}
+ (TreeCtrlColumnID = ['treectrl_column'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys={})
@@ -1625,17 +1716,19 @@ class Tk::TreeCtrl::Column < TkObject
keys = _symbolkey2str(keys)
- @path = @id =
- keys.delete('tag') ||
- Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.mutex.synchronize{
+ @path = @id =
+ keys.delete('tag') ||
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
+ }
keys['tag'] = @id
- unless Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath]
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
- Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
+ }
@tree.column_create(keys)
end
@@ -1651,6 +1744,9 @@ class Tk::TreeCtrl::Column < TkObject
def cget(opt)
@tree.column_cget(@tree.column_index(@id), opt)
end
+ def cget_strict(opt)
+ @tree.column_cget_strict(@tree.column_index(@id), opt)
+ end
def configure(*args)
@tree.column_configure(@tree.column_index(@id), *args)
@@ -1692,11 +1788,18 @@ end
class Tk::TreeCtrl::Element < TkObject
TreeCtrlElementID_TBL = TkCore::INTERP.create_table
- TreeCtrlElementID = ['treectrl_element'.freeze, '00000'.taint].freeze
+
+ (TreeCtrlElementID = ['treectrl_element'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
TreeCtrlElemTypeToClass = {}
TkCore::INTERP.init_ip_env{
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
+ }
}
def self.type2class(type)
@@ -1705,22 +1808,30 @@ class Tk::TreeCtrl::Element < TkObject
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, type, keys=nil)
@tree = parent
@tpath = parent.path
@type = type.to_s
- @path = @id =
- Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
- unless Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath]
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
- Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
+ Tk::TreeCtrl::Element::TreeCtrlElementID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
+ }
+
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
+ }
@tree.element_create(@id, @type, keys)
end
@@ -1736,6 +1847,9 @@ class Tk::TreeCtrl::Element < TkObject
def cget(opt)
@tree.element_cget(@id, opt)
end
+ def cget_strict(opt)
+ @tree.element_cget_strict(@id, opt)
+ end
def configure(*args)
@tree.element_configure(@id, *args)
@@ -1800,13 +1914,22 @@ end
class Tk::TreeCtrl::Item < TkObject
TreeCtrlItemID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear}
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys={})
@@ -1814,10 +1937,10 @@ class Tk::TreeCtrl::Item < TkObject
@tpath = parent.path
@path = @id = @tree.item_create(keys)
- unless Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath]
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
+ }
end
def id
@@ -1858,6 +1981,9 @@ class Tk::TreeCtrl::Item < TkObject
def cget(opt)
@tree.item_cget(@id, opt)
end
+ def cget_strict(opt)
+ @tree.item_cget_strict(@id, opt)
+ end
def configure(*args)
@tree.item_configure(@id, *args)
@@ -1891,6 +2017,9 @@ class Tk::TreeCtrl::Item < TkObject
def element_cget(opt)
@tree.item_element_cget(@id, opt)
end
+ def element_cget_strict(opt)
+ @tree.item_element_cget_strict(@id, opt)
+ end
def element_configure(*args)
@tree.item_element_configure(@id, *args)
@@ -2088,27 +2217,45 @@ end
class Tk::TreeCtrl::Style < TkObject
TreeCtrlStyleID_TBL = TkCore::INTERP.create_table
- TreeCtrlStyleID = ['treectrl_style'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear }
+ (TreeCtrlStyleID = ['treectrl_style'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys=nil)
@tree = parent
@tpath = parent.path
- @path = @id =
- Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
- unless Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath]
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
- Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
+ }
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
+ }
@tree.style_create(@id, keys)
end
@@ -2124,6 +2271,9 @@ class Tk::TreeCtrl::Style < TkObject
def cget(opt)
@tree.style_cget(@id, opt)
end
+ def cget_strict(opt)
+ @tree.style_cget_strict(@id, opt)
+ end
def configure(*args)
@tree.style_configure(@id, *args)
diff --git a/ext/tk/lib/tkextlib/version.rb b/ext/tk/lib/tkextlib/version.rb
index c7816fd4a5..434ed11a2e 100644
--- a/ext/tk/lib/tkextlib/version.rb
+++ b/ext/tk/lib/tkextlib/version.rb
@@ -2,5 +2,5 @@
# release date of tkextlib
#
module Tk
- Tkextlib_RELEASE_DATE = '2007-05-26'.freeze
+ Tkextlib_RELEASE_DATE = '2008-05-23'.freeze
end
diff --git a/ext/tk/lib/tkextlib/vu/pie.rb b/ext/tk/lib/tkextlib/vu/pie.rb
index 78f3fa54da..c1fb6857bf 100644
--- a/ext/tk/lib/tkextlib/vu/pie.rb
+++ b/ext/tk/lib/tkextlib/vu/pie.rb
@@ -116,13 +116,26 @@ end
class Tk::Vu::PieSlice
SliceID_TBL = TkCore::INTERP.create_table
- Pie_Slice_ID = ['vu:pie'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ SliceID_TBL.clear }
+
+ (Pie_Slice_ID = ['vu:pie'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ SliceID_TBL.mutex.synchronize{ SliceID_TBL.clear }
+ }
def self.id2obj(pie, id)
pie_path = pie.path
- return id unless SliceID_TBL[pie_path]
- SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[pie_path]
+ SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ else
+ id
+ end
+ }
end
def initialize(parent, *args)
@@ -131,10 +144,14 @@ class Tk::Vu::PieSlice
end
@parent = @pie = parent
@ppath = parent.path
- @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
- SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
- SliceID_TBL[@ppath][@id] = self
- Pie_Slice_ID[1].succ!
+ Pie_Slice_ID.mutex.synchronize{
+ @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
+ Pie_Slice_ID[1].succ!
+ }
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
if args[-1].kind_of?(Hash)
keys = args.unshift
@@ -160,6 +177,10 @@ class Tk::Vu::PieSlice
@pie.itemcget(@id, slot)
end
+ def cget_strict(slot)
+ @pie.itemcget_strict(@id, slot)
+ end
+
def configure(*args)
@pie.itemconfigure(@id, *args)
self
@@ -209,22 +230,48 @@ end
class Tk::Vu::NamedPieSlice
def self.new(parent, name, *args)
- if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
- return SliceID_TBL[parent.path][name]
- else
- super(parent, name, *args)
- end
+ obj = nil
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
+ obj = SliceID_TBL[parent.path][name]
+ else
+ #super(parent, name, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+ end
+ }
+ obj.instance_eval{
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ }
+
+ obj
end
def initialize(parent, name, *args)
+ # dummy:: not called by 'new' method
unless parent.kind_of?(Tk::Vu::Pie)
fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
end
@parent = @pie = parent
@ppath = parent.path
@path = @id = name.to_s
- SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
- SliceID_TBL[@ppath][@id] = self
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
if args[-1].kind_of?(Hash)
keys = args.unshift
diff --git a/ext/tk/lib/tkextlib/vu/spinbox.rb b/ext/tk/lib/tkextlib/vu/spinbox.rb
index b6499645a3..a7e40ea319 100644
--- a/ext/tk/lib/tkextlib/vu/spinbox.rb
+++ b/ext/tk/lib/tkextlib/vu/spinbox.rb
@@ -17,6 +17,6 @@ end
module Tk
module Vu
- Spinbox = TkSpinbox
+ Spinbox = Tk::Spinbox
end
end
diff --git a/ext/tk/lib/tkextlib/winico/winico.rb b/ext/tk/lib/tkextlib/winico/winico.rb
index c53a3ff48c..00316fd441 100644
--- a/ext/tk/lib/tkextlib/winico/winico.rb
+++ b/ext/tk/lib/tkextlib/winico/winico.rb
@@ -34,10 +34,15 @@ end
class Tk::Winico
WinicoID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ WinicoID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ WinicoID_TBL.mutex.synchronize{ WinicoID_TBL.clear }
+ }
def self.id2obj(id)
- (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ WinicoID_TBL.mutex.synchronize{
+ (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ }
end
def self.info
@@ -81,7 +86,9 @@ class Tk::Winico
"must be given proper information from where loading icons"
end
@path = @id
- WinicoID_TBL[@id] = self
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL[@id] = self
+ }
end
def id
@@ -96,7 +103,9 @@ class Tk::Winico
def delete
tk_call('winico', 'delete', @id)
- WinicoID_TBL.delete(@id)
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL.delete(@id)
+ }
self
end
alias destroy delete
@@ -126,15 +135,39 @@ class Tk::Winico
[ ?n, TkComm.method(:number) ],
[ ?s, TkComm.method(:string) ],
[ ?x, proc{|id|
- if Tk::Winico::WinicoID_TBL.key?(id)
- Tk::Winico::WinicoID_TBL[id]
- else
- Tk::Winico.new(nil, nil, id)
- end
+ Tk::Winico::WinicoID_TBL.mutex.synchronize{
+ if Tk::Winico::WinicoID_TBL.key?(id)
+ obj = Tk::Winico::WinicoID_TBL[id]
+ else
+ # Tk::Winico.new(nil, nil, id)
+ obj = Tk::Winico.allocate
+ obj.instance_eval{ @path = @id = id }
+ Tk::Winico::WinicoID_TBL[id] = obj
+ end
+ obj
+ }
} ],
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)
@@ -154,7 +187,8 @@ class Tk::Winico
Winico_callback._config_keys.each{|k|
if keys[k].kind_of?(Array)
cmd, *args = keys[k]
- keys[k] = Winico_callback.new(cmd, args.join(' '))
+ #keys[k] = Winico_callback.new(cmd, args.join(' '))
+ keys[k] = Winico_callback.new(cmd, *args)
# elsif keys[k].kind_of?(Proc)
elsif TkComm._callback_entry?(keys[k])
keys[k] = Winico_callback.new(keys[k])
@@ -170,7 +204,8 @@ class Tk::Winico
Winico_callback._config_keys.each{|k|
if keys[k].kind_of?(Array)
cmd, *args = keys[k]
- keys[k] = Winico_callback.new(cmd, args.join(' '))
+ #keys[k] = Winico_callback.new(cmd, args.join(' '))
+ keys[k] = Winico_callback.new(cmd, *args)
# elsif keys[k].kind_of?(Proc)
elsif TkComm._callback_entry?(keys[k])
keys[k] = Winico_callback.new(keys[k])
diff --git a/ext/tk/sample/binstr_usage.rb b/ext/tk/sample/binstr_usage.rb
index 91692856f9..be8399ba51 100644
--- a/ext/tk/sample/binstr_usage.rb
+++ b/ext/tk/sample/binstr_usage.rb
@@ -16,7 +16,7 @@ to avoid such troubles. Please see the source code of this sample. \
A Tk::BinaryString instance is used to create the image for the center button.
EOM
-ImgFile=['images','tcllogo.gif'].join(File::Separator)
+ImgFile=[File.dirname(__FILE__), 'images','tcllogo.gif'].join(File::Separator)
ph1 = TkPhotoImage.new(:file=>ImgFile)
p ph1.configinfo
@@ -28,12 +28,18 @@ ph2 = TkPhotoImage.new(:data=>b_str)
p ph2.configinfo
p ph2.data(:grayscale=>true)
-ph3 = TkPhotoImage.new()
-ph3.put(ph2.data(:grayscale=>true))
+ph3 = TkPhotoImage.new(:palette=>256)
+ph3.put(ph2.data)
+
+ph4 = TkPhotoImage.new()
+ph4.put(ph2.data(:grayscale=>true))
+
+#p [b_str.encoding, b_str.rb_encoding]
f = TkFrame.new.pack
TkButton.new(:parent=>f, :image=>ph1, :command=>proc{exit}).pack(:side=>:left)
TkButton.new(:parent=>f, :image=>ph2, :command=>proc{exit}).pack(:side=>:left)
TkButton.new(:parent=>f, :image=>ph3, :command=>proc{exit}).pack(:side=>:left)
+TkButton.new(:parent=>f, :image=>ph4, :command=>proc{exit}).pack(:side=>:left)
Tk.mainloop
diff --git a/ext/tk/sample/demos-en/anilabel.rb b/ext/tk/sample/demos-en/anilabel.rb
index f063bc53a4..0b9bc7357e 100644
--- a/ext/tk/sample/demos-en/anilabel.rb
+++ b/ext/tk/sample/demos-en/anilabel.rb
@@ -15,8 +15,10 @@ $anilabel_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($anilabel_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($anilabel_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -25,7 +27,7 @@ msg = TkLabel.new($anilabel_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($anilabel_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -43,8 +45,8 @@ TkFrame.new($anilabel_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# create frame for label demo
-f_left = TkLabelFrame.new($anilabel_demo, :text=>'Scrolling Texts')
-f_right = TkLabelFrame.new($anilabel_demo, :text=>'GIF Image')
+f_left = TkLabelFrame.new(base_frame, :text=>'Scrolling Texts')
+f_right = TkLabelFrame.new(base_frame, :text=>'GIF Image')
Tk.pack(f_left, f_right, 'side'=>'left', 'expand'=>'yes', 'fill'=>'both',
'padx'=>10, 'pady'=>10)
diff --git a/ext/tk/sample/demos-en/aniwave.rb b/ext/tk/sample/demos-en/aniwave.rb
index ebe27b875f..63a04a7b98 100644
--- a/ext/tk/sample/demos-en/aniwave.rb
+++ b/ext/tk/sample/demos-en/aniwave.rb
@@ -16,8 +16,10 @@ $aniwave_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($aniwave_demo).pack(:fill=>:both, :expand=>true)
+
# create label
-msg = TkLabel.new($aniwave_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($aniwave_demo) {
msg.pack('side'=>'top')
# create frame
-TkFrame.new($aniwave_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -58,6 +60,7 @@ class AnimatedWaveDemo
@backupCoords = []
n = 0
(-10..300).step(5){|n| @waveCoords << [n, 100]; @backupCoords << [n, 100] }
+ n = 305
@waveCoords << [n, 0]; @backupCoords << [n, 0]
@waveCoords << [n+5, 200]; @backupCoords << [n+5, 200]
@coordsLen = @waveCoords.length
@@ -112,4 +115,4 @@ class AnimatedWaveDemo
end
# Start the animation processing
-AnimatedWaveDemo.new($aniwave_demo, :left).move
+AnimatedWaveDemo.new(base_frame, :left).move
diff --git a/ext/tk/sample/demos-en/arrow.rb b/ext/tk/sample/demos-en/arrow.rb
index b62e1966eb..055cd2af3c 100644
--- a/ext/tk/sample/demos-en/arrow.rb
+++ b/ext/tk/sample/demos-en/arrow.rb
@@ -77,11 +77,19 @@ def arrowSetup(c)
'arrow'=>'both', 'arrowshape'=>v.smallTips)
TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
- TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
- TkcText.new(c, v.x1, 330,
- 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ if $tk_version =~ /^4.*/
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ else
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'Helvetica 18')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",
+ 'anchor'=>'w', 'font'=>'Helvetica 18')
+ end
v.count += 1
end
@@ -99,14 +107,16 @@ $arrow_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($arrow_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
'text'=>"This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."){
pack('side'=>'top')
}
# frame
-$arrow_buttons = TkFrame.new($arrow_demo) {|frame|
+$arrow_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -124,7 +134,7 @@ $arrow_buttons = TkFrame.new($arrow_demo) {|frame|
$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# canvas
-$arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350,
+$arrow_canvas = TkCanvas.new(base_frame, 'width'=>500, 'height'=>350,
'relief'=>'sunken', 'borderwidth'=>2)
$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
diff --git a/ext/tk/sample/demos-en/bind.rb b/ext/tk/sample/demos-en/bind.rb
index b7e7122c57..665592a2bc 100644
--- a/ext/tk/sample/demos-en/bind.rb
+++ b/ext/tk/sample/demos-en/bind.rb
@@ -19,8 +19,10 @@ $bind_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($bind_demo).pack(:fill=>:both, :expand=>true)
+
# frame
-TkFrame.new($bind_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -43,14 +45,14 @@ def tag_binding_for_bind_demo(tag, enter_style, leave_style)
end
# text
-TkText.new($bind_demo){|t|
+txt = TkText.new(base_frame){|t|
#
setgrid 'true'
- width 60
- height 24
+ #width 60
+ #height 24
font $font
wrap 'word'
- TkScrollbar.new($bind_demo) {|s|
+ TkScrollbar.new(base_frame) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
@@ -94,29 +96,32 @@ TkText.new($bind_demo){|t|
}
d1.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 'items.rb')
})
d2.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 'plot.rb')
})
d3.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 'ctext.rb')
})
d4.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 'arrow.rb')
})
d5.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 'ruler.rb')
})
d6.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 'cscroll.rb')
})
TkTextMarkInsert.new(t, '0.0')
configure('state','disabled')
}
+
+txt.width 60
+txt.height 24
diff --git a/ext/tk/sample/demos-en/bitmap.rb b/ext/tk/sample/demos-en/bitmap.rb
index 7fd551c7a5..133adb0543 100644
--- a/ext/tk/sample/demos-en/bitmap.rb
+++ b/ext/tk/sample/demos-en/bitmap.rb
@@ -21,7 +21,7 @@ def bitmapRow(w,*args)
TkFrame.new(row){|base|
pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
- TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
+ Tk::Label.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
}
end
}
@@ -40,14 +40,16 @@ $bitmap_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($bitmap_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."){
pack('side'=>'top')
}
# frame
-$bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
+$bitmap_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -65,7 +67,7 @@ $bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-TkFrame.new($bitmap_demo){|f|
+TkFrame.new(base_frame){|f|
bitmapRow(f,'error','gray25','gray50','hourglass')
bitmapRow(f,'info','question','questhead','warning')
pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
diff --git a/ext/tk/sample/demos-en/button.rb b/ext/tk/sample/demos-en/button.rb
index 6614d99c92..5c03bd499b 100644
--- a/ext/tk/sample/demos-en/button.rb
+++ b/ext/tk/sample/demos-en/button.rb
@@ -29,7 +29,7 @@ msg = TkLabel.new($button_demo) {
msg.pack('side'=>'top')
# frame
-$button_buttons = TkFrame.new($button_demo) {|frame|
+$button_buttons = Tk::Frame.new($button_demo) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
diff --git a/ext/tk/sample/demos-en/check.rb b/ext/tk/sample/demos-en/check.rb
index 971a8fea73..2951962a79 100644
--- a/ext/tk/sample/demos-en/check.rb
+++ b/ext/tk/sample/demos-en/check.rb
@@ -19,8 +19,10 @@ $check_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($check_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($check_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -34,7 +36,7 @@ brakes = TkVariable.new(0)
sober = TkVariable.new(0)
# frame
-TkFrame.new($check_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -54,7 +56,7 @@ TkFrame.new($check_demo) {|frame|
TkButton.new(frame) {
text 'See Variables'
command proc{
- showVars($check_demo,
+ showVars(base_frame,
['wipers', wipers], ['brakes', brakes], ['sober', sober])
}
}.pack('side'=>'left', 'expand'=>'yes')
@@ -63,8 +65,8 @@ TkFrame.new($check_demo) {|frame|
# checkbutton
-[ TkCheckButton.new($check_demo, 'text'=>'Wipers OK', 'variable'=>wipers),
- TkCheckButton.new($check_demo, 'text'=>'Brakes OK', 'variable'=>brakes),
- TkCheckButton.new($check_demo, 'text'=>'Driver Sober', 'variable'=>sober)
+[ TkCheckButton.new(base_frame, 'text'=>'Wipers OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'Brakes OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'Driver Sober', 'variable'=>sober)
].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
diff --git a/ext/tk/sample/demos-en/check2.rb b/ext/tk/sample/demos-en/check2.rb
index 97d61fba0c..faea748a87 100644
--- a/ext/tk/sample/demos-en/check2.rb
+++ b/ext/tk/sample/demos-en/check2.rb
@@ -15,8 +15,10 @@ $check2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($check2_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($check2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -31,7 +33,7 @@ brakes = TkVariable.new(0)
sober = TkVariable.new(0)
# frame
-TkFrame.new($check2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
@@ -59,15 +61,15 @@ TkFrame.new($check2_demo) {|frame|
# checkbutton
-TkCheckButton.new($check2_demo, :text=>'Safety Check', :variable=>safety,
+TkCheckButton.new(base_frame, :text=>'Safety Check', :variable=>safety,
:relief=>:flat, :onvalue=>'all', :offvalue=>'none',
:tristatevalue=>'partial'){
pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
}
-[ TkCheckButton.new($check2_demo, 'text'=>'Wipers OK', 'variable'=>wipers),
- TkCheckButton.new($check2_demo, 'text'=>'Brakes OK', 'variable'=>brakes),
- TkCheckButton.new($check2_demo, 'text'=>'Driver Sober', 'variable'=>sober)
+[ TkCheckButton.new(base_frame, 'text'=>'Wipers OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'Brakes OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'Driver Sober', 'variable'=>sober)
].each{|w|
w.relief('flat')
w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
diff --git a/ext/tk/sample/demos-en/clrpick.rb b/ext/tk/sample/demos-en/clrpick.rb
index 9486fde314..431439d55d 100644
--- a/ext/tk/sample/demos-en/clrpick.rb
+++ b/ext/tk/sample/demos-en/clrpick.rb
@@ -4,6 +4,8 @@
#
# widget demo prompts the user to select a color (called by 'widget')
#
+# Note: don't support ttk_wrapper. work with standard widgets only.
+#
# toplevel widget
if defined?($clrpick_demo) && $clrpick_demo
@@ -18,13 +20,18 @@ $clrpick_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($clrpick_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+#TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+Tk::Label.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"Press the buttons below to choose the foreground and background colors for the widgets in this window.").pack('side'=>'top')
# frame
-TkFrame.new($clrpick_demo) {|frame|
- TkButton.new(frame) {
+#TkFrame.new($clrpick_demo) {|frame|
+Tk::Frame.new($clrpick_demo) {|frame|
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
text 'Dismiss'
command proc{
tmppath = $clrpick_demo
@@ -33,20 +40,23 @@ TkFrame.new($clrpick_demo) {|frame|
}
}.pack('side'=>'left', 'expand'=>'yes')
- TkButton.new(frame) {
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
text 'Show Code'
command proc{showCode 'clrpick'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# button
-TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
+# TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
command(proc{setColor $clrpick_demo, b, 'background',
['background', 'highlightbackground']})
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
}
-TkButton.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
+# TkButton.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
}
diff --git a/ext/tk/sample/demos-en/colors.rb b/ext/tk/sample/demos-en/colors.rb
index 66fb0afa36..4300a660ae 100644
--- a/ext/tk/sample/demos-en/colors.rb
+++ b/ext/tk/sample/demos-en/colors.rb
@@ -20,8 +20,10 @@ $colors_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($colors_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($colors_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -30,7 +32,7 @@ msg = TkLabel.new($colors_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($colors_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -49,7 +51,7 @@ TkFrame.new($colors_demo) {|frame|
# frame
colors_lbox = nil
-TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
s = TkScrollbar.new(w)
colors_lbox = TkListbox.new(w) {
setgrid 1
@@ -62,7 +64,15 @@ TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
-colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+#colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+colors_lbox.bind('Double-1', proc{
+ begin
+ TkPalette.setPalette TkSelection.get
+ rescue => e
+ p e
+ Tk.tk_call_without_enc('destroy', '.___tk_set_palette')
+ end
+ })
ins_data = [
'gray60','gray70','gray80','gray85','gray90','gray95',
diff --git a/ext/tk/sample/demos-en/combo.rb b/ext/tk/sample/demos-en/combo.rb
new file mode 100644
index 0000000000..0907d9e8ec
--- /dev/null
+++ b/ext/tk/sample/demos-en/combo.rb
@@ -0,0 +1,96 @@
+# combo.rb --
+#
+# This demonstration script creates several combobox widgets.
+#
+# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($combo_demo) && $combo_demo
+ $combo_demo.destroy
+ $combo_demo = nil
+end
+
+$combo_demo = TkToplevel.new {|w|
+ title("Combobox Demonstration")
+ iconname("combo")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Three different combo-boxes are displayed below. \
+You can add characters to the first \
+one by pointing, clicking and typing, just as with an entry; pressing \
+Return will cause the current value to be added to the list that is \
+selectable from the drop-down list, and you can choose other values \
+by pressing the Down key, using the arrow keys to pick another one, \
+and pressing Return again. The second combo-box is fixed to a \
+particular value, and cannot be modified at all. The third one only \
+allows you to select values from its drop-down list of Australian \
+cities.
+EOL
+
+## variables
+firstValue = TkVariable.new
+secondValue = TkVariable.new
+ozCity = TkVariable.new
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame,
+ ['firstVariable', firstValue],
+ ['secondVariable', secondValue],
+ ['ozCity', ozCity])
+ }),
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'combo'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $combo_demo.destroy
+ $combo_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+australianCities = [
+ 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide', 'Brisbane',
+ 'Hobart', 'Darwin', 'Alice Springs'
+]
+
+
+secondValue.value = 'unchangable'
+ozCity.value = 'Sydney'
+
+Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
+ Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
+ b.bind('Return', '%W'){|w|
+ w.values <<= w.value unless w.values.include?(w.value)
+ }
+ }.pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
+ Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
+ Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
+ :values=>australianCities) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ :side=>:top, :pady=>5, :padx=>10)
diff --git a/ext/tk/sample/demos-en/cscroll.rb b/ext/tk/sample/demos-en/cscroll.rb
index 0838dfbe08..259ed3bd8c 100644
--- a/ext/tk/sample/demos-en/cscroll.rb
+++ b/ext/tk/sample/demos-en/cscroll.rb
@@ -19,14 +19,16 @@ $cscroll_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($cscroll_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i',
'justify'=>'left', 'text'=>"This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."){
pack('side'=>'top')
}
# frame
-$cscroll_buttons = TkFrame.new($cscroll_demo) {|frame|
+$cscroll_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -45,7 +47,7 @@ $cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
unless $tk_version =~ /^4\.[01]/
- $cscroll_grid = TkFrame.new($cscroll_demo) {
+ $cscroll_grid = TkFrame.new(base_frame) {
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
}
TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
@@ -53,7 +55,7 @@ unless $tk_version =~ /^4\.[01]/
end
# canvas
-$cscroll_canvas = TkCanvas.new($cscroll_demo,
+$cscroll_canvas = TkCanvas.new(base_frame,
'relief'=>'sunken', 'borderwidth'=>2,
'scrollregion'=>['-11c', '-11c', '50c', '20c']
) {|c|
@@ -64,7 +66,7 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo,
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
end
- TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
c.yscrollcommand(proc{|first,last| vs.set first,last})
if $tk_version =~ /^4\.[01]/
pack('side'=>'right', 'fill'=>'y')
@@ -74,7 +76,7 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo,
end
}
- TkScrollbar.new($cscroll_demo, 'orient'=>'horiz',
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
'command'=>proc{|*args| c.xview(*args)}) {|hs|
c.xscrollcommand(proc{|first,last| hs.set first,last})
if $tk_version =~ /^4\.[01]/
diff --git a/ext/tk/sample/demos-en/ctext.rb b/ext/tk/sample/demos-en/ctext.rb
index dbb5e32638..01374b0321 100644
--- a/ext/tk/sample/demos-en/ctext.rb
+++ b/ext/tk/sample/demos-en/ctext.rb
@@ -19,8 +19,10 @@ $ctext_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($ctext_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
'text'=>"This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing:
1. You can point, click, and type.
2. You can also select with button 1.
@@ -33,7 +35,7 @@ TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
}
# frame
-$ctext_buttons = TkFrame.new($ctext_demo) {|frame|
+$ctext_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -51,24 +53,33 @@ $ctext_buttons = TkFrame.new($ctext_demo) {|frame|
$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# canvas
-$ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat',
+$ctext_canvas = TkCanvas.new(base_frame, 'relief'=>'flat',
'borderwidth'=>0, 'width'=>500, 'height'=>350)
$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
# font
-textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+if $tk_version =~ /^4.*/
+ textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ textFont = 'Helvetica 24'
+end
# canvas
TkcRectangle.new($ctext_canvas, 245, 195, 255, 205,
'outline'=>'black', 'fill'=>'red')
+ctag_text_param = {
+ 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).",
+ 'width'=>440, 'anchor'=>'n', 'justify'=>'left'
+}
+if $tk_version =~ /^4.*/
+ ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ ctag_text_param['font'] = 'Helvetica 24'
+end
+
$ctag_text = TkcTag.new($ctext_canvas)
-$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200,
- 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).",
- 'width'=>440, 'anchor'=>'n',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*',
- 'kanjifont'=>'-*--24-*-jisx0208.1983-0',
- 'justify'=>'left') )
+$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, ctag_text_param))
$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y")
$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
@@ -110,9 +121,14 @@ mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color
item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50,
'outline'=>'black', 'fill'=>'red')
item.bind('1', proc{$ctag_text.configure 'anchor', 'center'})
-TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s',
- 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
- 'fill'=>'brown')
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
# Lastly, create some items that allow the text's justification to be
# changed.
@@ -123,9 +139,14 @@ color = 'SeaGreen2'
mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color
mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color
mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color
-TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s',
- 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
- 'fill'=>'brown')
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas})
$ctext_canvas.itembind('config', 'Leave',
diff --git a/ext/tk/sample/demos-en/entry1.rb b/ext/tk/sample/demos-en/entry1.rb
index 29bc693395..6f5b10fb71 100644
--- a/ext/tk/sample/demos-en/entry1.rb
+++ b/ext/tk/sample/demos-en/entry1.rb
@@ -15,8 +15,10 @@ $entry1_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($entry1_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($entry1_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -25,7 +27,7 @@ msg = TkLabel.new($entry1_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($entry1_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -42,9 +44,9 @@ TkFrame.new($entry1_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
#
-e1 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
-e2 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
-e3 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+e1 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e2 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e3 = TkEntry.new(base_frame, 'relief'=>'sunken')
[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
#
diff --git a/ext/tk/sample/demos-en/entry2.rb b/ext/tk/sample/demos-en/entry2.rb
index d4e58d7dd5..d67d04b56d 100644
--- a/ext/tk/sample/demos-en/entry2.rb
+++ b/ext/tk/sample/demos-en/entry2.rb
@@ -19,8 +19,10 @@ $entry2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($entry2_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($entry2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($entry2_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($entry2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -46,7 +48,7 @@ TkFrame.new($entry2_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-TkFrame.new($entry2_demo, 'borderwidth'=>10) {|w|
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
# entry 1
s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
e1 = TkEntry.new(w, 'relief'=>'sunken') {
diff --git a/ext/tk/sample/demos-en/entry3.rb b/ext/tk/sample/demos-en/entry3.rb
index 68f77a0d48..f7df3a5653 100644
--- a/ext/tk/sample/demos-en/entry3.rb
+++ b/ext/tk/sample/demos-en/entry3.rb
@@ -17,7 +17,9 @@ $entry3_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($entry3_demo,
+base_frame = TkFrame.new($entry3_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
Four different entries are displayed below. You can add characters \
@@ -34,7 +36,7 @@ characters (silently ignoring further ones), and displaying them as \
asterisk characters.
EOL
-TkFrame.new($entry3_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
@@ -60,23 +62,41 @@ TkFrame.new($entry3_demo){|f|
# count - Counter to control the number of times flashed
def focusAndFlash(widget, fg, bg, count=5)
return if count <= 0
- TkTimer.new(200, count,
- proc{widget.configure(:foreground=>bg, :background=>fg)},
- proc{widget.configure(:foreground=>fg, :background=>bg)}
- ).start
+ if fg && !fg.empty? && bg && !bg.empty?
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>bg, :background=>fg)},
+ proc{widget.configure(:foreground=>fg, :background=>bg)}
+ ).start
+ else
+ # TkTimer.new(150, 3){Tk.bell}.start
+ Tk.bell
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>'white',
+ :background=>'black')},
+ proc{widget.configure(:foreground=>'black',
+ :background=>'white')}
+ ).at_end{begin
+ widget.configure(:foreground=>fg,
+ :background=>bg)
+ rescue
+ # ignore
+ end}.start
+ end
widget.focus(true)
end
-l1 = TkLabelFrame.new($entry3_demo, :text=>"Integer Entry")
+l1 = TkLabelFrame.new(base_frame, :text=>"Integer Entry")
TkEntry.new(l1, :validate=>:focus,
:vcmd=>[
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
]) {|e|
- invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W']
+ fg = e.foreground
+ bg = e.background
+ invalidcommand [proc{|w| focusAndFlash(w, fg, bg)}, '%W']
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
}
-l2 = TkLabelFrame.new($entry3_demo, :text=>"Length-Constrained Entry")
+l2 = TkLabelFrame.new(base_frame, :text=>"Length-Constrained Entry")
TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
:vcmd=>[proc{|s| s.length < 10}, '%P']
).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
@@ -158,14 +178,14 @@ def validatePhoneChange(widget, vmode, idx, char)
widget.insert(idx, $phoneNumberMap[char] || char)
Tk.after_idle(proc{phoneSkipRight(widget, -1)})
return true
- # Tk.update(true) # Don't work 'update' inter validation callback.
- # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
+ # Tk.update(true) # <- Don't work 'update' inter validation callback.
+ # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
end
return false
end
-l3 = TkLabelFrame.new($entry3_demo, :text=>"US Phone-Number Entry")
+l3 = TkLabelFrame.new(base_frame, :text=>"US Phone-Number Entry")
TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
:textvariable=>entry3content,
:vcmd=>[
@@ -184,14 +204,14 @@ TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
}
-l4 = TkLabelFrame.new($entry3_demo, :text=>"Password Entry")
+l4 = TkLabelFrame.new(base_frame, :text=>"Password Entry")
TkEntry.new(l4, :validate=>:key, :show=>'*',
:vcmd=>[
proc{|s| s.length <= 8},
'%P'
]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
-TkFrame.new($entry3_demo){|f|
+TkFrame.new(base_frame){|f|
lower
TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
diff --git a/ext/tk/sample/demos-en/filebox.rb b/ext/tk/sample/demos-en/filebox.rb
index 36b19de557..676c347409 100644
--- a/ext/tk/sample/demos-en/filebox.rb
+++ b/ext/tk/sample/demos-en/filebox.rb
@@ -17,12 +17,14 @@ $filebox_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($filebox_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.").pack('side'=>'top')
# frame
-TkFrame.new($filebox_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -40,7 +42,7 @@ TkFrame.new($filebox_demo) {|frame|
# frame
['open', 'save'].each{|type|
- TkFrame.new($filebox_demo) {|f|
+ TkFrame.new(base_frame) {|f|
TkLabel.new(f, 'text'=>"Select a file to #{type}: ", 'anchor'=>'e')\
.pack('side'=>'left')
@@ -48,7 +50,7 @@ TkFrame.new($filebox_demo) {|frame|
pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
TkButton.new(f, 'text'=>'Browse ...',
- 'command'=>proc{fileDialog $filebox_demo,e,type})\
+ 'command'=>proc{fileDialog base_frame,e,type})\
.pack('side'=>'left')
}
@@ -58,7 +60,7 @@ TkFrame.new($filebox_demo) {|frame|
$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
if ($tk_platform['platform'] == 'unix')
- TkCheckButton.new($filebox_demo,
+ TkCheckButton.new(base_frame,
'text'=>'Use Motif Style Dialog',
'variable'=>$tk_strictMotif,
'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
@@ -91,7 +93,10 @@ def fileDialog(w,ent,operation)
if file != ""
ent.delete 0, 'end'
ent.insert 0, file
- ent.xview 'end'
+ # ent.xview 'end'
+ Tk.update_idletasks # need this for Tk::Tile::Entry
+ # (to find right position of 'xview').
+ ent.xview(ent.index('end'))
end
end
diff --git a/ext/tk/sample/demos-en/floor.rb b/ext/tk/sample/demos-en/floor.rb
index 53adcf96b6..7023f2a72e 100644
--- a/ext/tk/sample/demos-en/floor.rb
+++ b/ext/tk/sample/demos-en/floor.rb
@@ -1590,14 +1590,16 @@ $floor_demo = TkToplevel.new {|w|
minsize(100,100)
}
+base_frame = TkFrame.new($floor_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
pack('side'=>'top')
}
# frame
-$floor_buttons = TkFrame.new($floor_demo) {|frame|
+$floor_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -1620,17 +1622,17 @@ $floorItems = {}
# canvas
if $tk_version =~ /^4\.[01]/
- $floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken',
+ $floor_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
'highlightthickness'=>2)
$floor_canvas = TkCanvas.new($floor_canvas_frame,
'width'=>900, 'height'=>500, 'borderwidth'=>0,
'highlightthickness'=>0) {|c|
- TkScrollbar.new($floor_demo, 'orient'=>'horiz',
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
'command'=>proc{|*args| c.xview(*args)}){|hs|
c.xscrollcommand(proc{|first,last| hs.set first,last})
pack('side'=>'bottom', 'fill'=>'x')
}
- TkScrollbar.new($floor_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
c.yscrollcommand(proc{|first,last| vs.set first,last})
pack('side'=>'right', 'fill'=>'y')
}
@@ -1639,7 +1641,7 @@ if $tk_version =~ /^4\.[01]/
$floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
else
- TkFrame.new($floor_demo) {|f|
+ TkFrame.new(base_frame) {|f|
pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
diff --git a/ext/tk/sample/demos-en/floor2.rb b/ext/tk/sample/demos-en/floor2.rb
index efaf9e250d..88b07aeee4 100644
--- a/ext/tk/sample/demos-en/floor2.rb
+++ b/ext/tk/sample/demos-en/floor2.rb
@@ -1590,14 +1590,16 @@ $floor2_demo = TkToplevel.new {|w|
minsize(100,100)
}
+base_frame = TkFrame.new($floor2_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($floor2_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
pack('side'=>'top')
}
# frame
-$floor2_buttons = TkFrame.new($floor2_demo) {|frame|
+$floor2_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -1620,17 +1622,17 @@ $floorItems2 = {}
# canvas
if $tk_version =~ /^4\.[01]/
- $floor2_canvas_frame = TkFrame.new($floor2_demo,'bd'=>2,'relief'=>'sunken',
+ $floor2_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
'highlightthickness'=>2)
$floor2_canvas = TkCanvas.new($floor2_canvas_frame,
'width'=>900, 'height'=>500, 'borderwidth'=>0,
'highlightthickness'=>0) {|c|
- TkScrollbar.new($floor2_demo, 'orient'=>'horiz',
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
'command'=>proc{|*args| c.xview(*args)}){|hs|
c.xscrollcommand(proc{|first,last| hs.set first,last})
pack('side'=>'bottom', 'fill'=>'x')
}
- TkScrollbar.new($floor2_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
c.yscrollcommand(proc{|first,last| vs.set first,last})
pack('side'=>'right', 'fill'=>'y')
}
@@ -1639,7 +1641,7 @@ if $tk_version =~ /^4\.[01]/
$floor2_canvas.pack('expand'=>'yes', 'fill'=>'both')
else
- TkFrame.new($floor2_demo) {|f|
+ TkFrame.new(base_frame) {|f|
pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
diff --git a/ext/tk/sample/demos-en/form.rb b/ext/tk/sample/demos-en/form.rb
index dbb14302dc..3119752b1c 100644
--- a/ext/tk/sample/demos-en/form.rb
+++ b/ext/tk/sample/demos-en/form.rb
@@ -15,8 +15,10 @@ $form_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($form_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -25,7 +27,7 @@ msg = TkLabel.new($form_demo) {
msg.pack('side'=>'top', 'fill'=>'x')
# frame
-TkFrame.new($form_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -44,7 +46,7 @@ TkFrame.new($form_demo) {|frame|
# entry
form_data = []
(1..5).each{|i|
- f = TkFrame.new($form_demo, 'bd'=>2)
+ f = TkFrame.new(base_frame, 'bd'=>2)
e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
l = TkLabel.new(f)
e.pack('side'=>'right')
diff --git a/ext/tk/sample/demos-en/goldberg.rb b/ext/tk/sample/demos-en/goldberg.rb
index 8d3f6d14f7..c6fa37c09c 100644
--- a/ext/tk/sample/demos-en/goldberg.rb
+++ b/ext/tk/sample/demos-en/goldberg.rb
@@ -54,6 +54,8 @@ $goldberg_demo = TkToplevel.new {|w|
# positionWindow(w)
}
+base_frame = TkFrame.new($goldberg_demo).pack(:fill=>:both, :expand=>true)
+
=begin
# label
msg = TkLabel.new($goldberg_demo) {
@@ -175,7 +177,8 @@ class TkGoldberg_Demo
do_ctrl_frame
do_detail_frame
- msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ # msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ msg = Tk::Label.new(@parent, :bg=>@C['bg'], :fg=>'white') {
font 'Arial 10'
wraplength 600
justify 'left'
@@ -185,7 +188,8 @@ class TkGoldberg_Demo
frame = TkFrame.new(@parent, :bg=>@C['bg'])
- TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
text 'Dismiss'
command proc{
tmppath = $goldberg_demo
@@ -194,12 +198,14 @@ class TkGoldberg_Demo
}
}.pack('side'=>'left')
- TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
text 'See Code'
command proc{showCode 'goldberg'}
}.pack('side'=>'left', 'padx'=>5)
- @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ # @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ @show = Tk::Button.new(frame, :text=>'>>', :command=>proc{show_ctrl},
:bg=>@C['bg'], :activebackground=>@C['bg'])
@show.pack('side'=>'left')
frame.place(:in=>@canvas, :relx=>1, :rely=>0, :anchor=>:ne)
@@ -208,10 +214,11 @@ class TkGoldberg_Demo
end
def do_ctrl_frame
- @start = TkButton.new(@parent, :text=>'Start', :bd=>6,
+ @start = Tk::Button.new(@parent, :text=>'Start', :bd=>6,
:command=>proc{do_button(0)})
- @start.font(@start['font'].weight('bold'))
- font = @start['font']
+ if font = @start['font']
+ @start.font(font.weight('bold'))
+ end
@pause = TkCheckbutton.new(@parent, :text=>'Pause', :font=>font,
:command=>proc{do_button(1)}, :relief=>:raised,
@@ -1996,4 +2003,4 @@ class TkGoldberg_Demo
end
end
-TkGoldberg_Demo.new($goldberg_demo)
+TkGoldberg_Demo.new(base_frame)
diff --git a/ext/tk/sample/demos-en/hello b/ext/tk/sample/demos-en/hello
index f06eabe518..5e86ad7e3e 100644
--- a/ext/tk/sample/demos-en/hello
+++ b/ext/tk/sample/demos-en/hello
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
require 'tk'
-unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
- require 'tkencoding'
-end
+#unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
+# require 'tkencoding'
+#end
TkButton.new(nil,
'text'=>"Hello Ruby world!",
diff --git a/ext/tk/sample/demos-en/hscale.rb b/ext/tk/sample/demos-en/hscale.rb
index 14e395b61a..e660216967 100644
--- a/ext/tk/sample/demos-en/hscale.rb
+++ b/ext/tk/sample/demos-en/hscale.rb
@@ -11,8 +11,9 @@ $hscale_demo = TkToplevel.new {|w|
}
positionWindow($hscale_demo)
+base_frame = TkFrame.new($hscale_demo).pack(:fill=>:both, :expand=>true)
-msg = TkLabel.new($hscale_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '3.5i'
justify 'left'
@@ -20,7 +21,7 @@ msg = TkLabel.new($hscale_demo) {
}
msg.pack('side'=>'top')
-TkFrame.new($hscale_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc {
@@ -36,7 +37,18 @@ TkFrame.new($hscale_demo) {|frame|
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
-TkFrame.new($hscale_demo) {|frame|
+
+def setWidth(w, width)
+ width = width + 21
+ x2 = width - 30
+ if x2 < 21
+ x2 = 21
+ end
+ w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+ w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+end
+
+TkFrame.new(base_frame) {|frame|
canvas = TkCanvas.new(frame) {|c|
width 50
height 50
@@ -61,14 +73,3 @@ TkFrame.new($hscale_demo) {|frame|
}.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n')
scale.set 75
}.pack('side'=>'top', 'fill'=>'x')
-
-
-def setWidth(w, width)
- width = width + 21
- x2 = width - 30
- if x2 < 21
- x2 = 21
- end
- w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
- w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
-end
diff --git a/ext/tk/sample/demos-en/icon.rb b/ext/tk/sample/demos-en/icon.rb
index 58aca2df07..a3921d2333 100644
--- a/ext/tk/sample/demos-en/icon.rb
+++ b/ext/tk/sample/demos-en/icon.rb
@@ -19,8 +19,10 @@ $icon_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($icon_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($icon_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($icon_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($icon_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -63,16 +65,18 @@ TkBitmapImage.new('file'=>[$demo_dir,'..',
letters = TkVariable.new
# frame
-TkFrame.new($icon_demo, 'borderwidth'=>10){|w|
+TkFrame.new(base_frame, 'borderwidth'=>10){|w|
TkFrame.new(w) {|f|
- TkRadioButton.new(f){
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
bitmap '@' + [$demo_dir,'..',
'images','letters.xbm'].join(File::Separator)
variable letters
value 'full'
}.pack('side'=>'top', 'expand'=>'yes')
- TkRadioButton.new(f){
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
bitmap '@' + [$demo_dir,'..',
'images','noletter.xbm'].join(File::Separator)
variable letters
@@ -81,14 +85,16 @@ TkFrame.new($icon_demo, 'borderwidth'=>10){|w|
}.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
- TkCheckButton.new(w) {
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
image flagdown
selectimage flagup
indicatoron 0
selectcolor self['background']
}.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
- TkCheckButton.new(w) {
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
bitmap '@' + [$demo_dir,'..',
'images','letters.xbm'].join(File::Separator)
indicatoron 0
diff --git a/ext/tk/sample/demos-en/image1.rb b/ext/tk/sample/demos-en/image1.rb
index 05c9705c9c..a9072bb308 100644
--- a/ext/tk/sample/demos-en/image1.rb
+++ b/ext/tk/sample/demos-en/image1.rb
@@ -18,8 +18,10 @@ $image1_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($image1_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($image1_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -28,7 +30,7 @@ msg = TkLabel.new($image1_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($image1_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -54,7 +56,10 @@ TkPhotoImage.new('file'=>[$demo_dir,'..',
'images','earthris.gif'].join(File::Separator))
# label
-[ TkLabel.new($image1_demo, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
- TkLabel.new($image1_demo, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+#[ TkLabel.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+# TkLabel.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+#].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+[ Tk::Label.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+ Tk::Label.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
diff --git a/ext/tk/sample/demos-en/image2.rb b/ext/tk/sample/demos-en/image2.rb
index 1aff7173be..1975dd6b02 100644
--- a/ext/tk/sample/demos-en/image2.rb
+++ b/ext/tk/sample/demos-en/image2.rb
@@ -19,8 +19,10 @@ $image2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($image2_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($image2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($image2_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($image2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -53,21 +55,21 @@ $dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
$image2a = TkPhotoImage.new
#
-TkLabel.new($image2_demo, 'text'=>'Directory:')\
+TkLabel.new(base_frame, 'text'=>'Directory:')\
.pack('side'=>'top', 'anchor'=>'w')
-image2_e = TkEntry.new($image2_demo) {
+image2_e = TkEntry.new(base_frame) {
width 30
textvariable $dirName
}.pack('side'=>'top', 'anchor'=>'w')
-TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20)\
+TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20)\
.pack('side'=>'top', 'anchor'=>'w')
-TkLabel.new($image2_demo, 'text'=>'File:')\
+TkLabel.new(base_frame, 'text'=>'File:')\
.pack('side'=>'top', 'anchor'=>'w')
-TkFrame.new($image2_demo){|w|
+TkFrame.new(base_frame){|w|
s = TkScrollbar.new(w)
l = TkListbox.new(w) {
width 20
@@ -86,9 +88,9 @@ TkFrame.new($image2_demo){|w|
}.pack('side'=>'top', 'anchor'=>'w')
# image
-[ TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20),
- TkLabel.new($image2_demo, 'text'=>'Image:'),
- TkLabel.new($image2_demo, 'image'=>$image2a)
+[ TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20),
+ TkLabel.new(base_frame, 'text'=>'Image:'),
+ TkLabel.new(base_frame, 'image'=>$image2a)
].each{|w| w.pack('side'=>'top', 'anchor'=>'w')}
#
diff --git a/ext/tk/sample/demos-en/image3.rb b/ext/tk/sample/demos-en/image3.rb
index e46d3796f2..43afab7ecd 100644
--- a/ext/tk/sample/demos-en/image3.rb
+++ b/ext/tk/sample/demos-en/image3.rb
@@ -19,27 +19,29 @@ $image3_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+
#
-def loadDir(w)
+def loadDir3(w)
w.delete(0,'end')
Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
w.insert('end',File.basename(f))
}
end
-# selectAndLoadDir --
+# selectAndLoadDir3 --
# This procedure pops up a dialog to ask for a directory to load into
# the listobx and (if the user presses OK) reloads the directory
# listbox from the directory named in the demo's entry.
#
# Arguments:
# w - Name of the toplevel window of the demo.
-def selectAndLoadDir(w, lbox)
+def selectAndLoadDir3(w, lbox)
dir = Tk.chooseDirectory(:initialdir=>$dirName.value,
:parent=>w, :mustexist=>true)
if dir.length > 0
$dirName.value = dir
- loadDir(lbox)
+ loadDir3(lbox)
end
end
@@ -49,7 +51,7 @@ end
# label
-msg = TkLabel.new($image3_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -58,7 +60,7 @@ msg = TkLabel.new($image3_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($image3_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -86,11 +88,11 @@ end
$image3a = TkPhotoImage.new
#
-image3_f = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+image3_f = TkFrame.new(base_frame).pack(:fill=>:both, :expand=>true)
-image3_df = TkLabelFrame.new($image3_demo, :text=>'Directory:')
+image3_df = TkLabelFrame.new(base_frame, :text=>'Directory:')
-image3_ff = TkLabelFrame.new($image3_demo, :text=>'File:',
+image3_ff = TkLabelFrame.new(base_frame, :text=>'File:',
:padx=>'2m', :pady=>'2m')
image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
pack(:side=>:left, :fill=>:y, :expand=>true)
@@ -102,16 +104,17 @@ image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){
pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true)
- bind('Return', proc{loadDir(image3_lbx)})
+ bind('Return', proc{loadDir3(image3_lbx)})
}
TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"Select Dir.",
- :command=>proc{selectAndLoadDir(image3_ent, image3_lbx)}) {
+ :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) {
pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m')
}
-image3_if = TkLabelFrame.new($image3_demo, :text=>'Image:') {|f|
- TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+image3_if = TkLabelFrame.new(base_frame, :text=>'Image:') {|f|
+ # TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+ Tk::Label.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
}
Tk.grid(image3_df, '-',
diff --git a/ext/tk/sample/demos-en/items.rb b/ext/tk/sample/demos-en/items.rb
index 8ab7668a07..3fd44fd4f4 100644
--- a/ext/tk/sample/demos-en/items.rb
+++ b/ext/tk/sample/demos-en/items.rb
@@ -19,8 +19,10 @@ $items_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($items_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($items_demo) {
+TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -28,7 +30,7 @@ TkLabel.new($items_demo) {
}.pack('side'=>'top')
# frame
-TkFrame.new($items_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -46,7 +48,7 @@ TkFrame.new($items_demo) {|frame|
# frame
cvs = nil
-TkFrame.new($items_demo) {|cf|
+TkFrame.new(base_frame) {|cf|
# canvas
cvs = TkCanvas.new(cf) {|c|
focus
@@ -94,8 +96,13 @@ TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
-font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
-font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+if $tk_version =~ /^4.*/
+ font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+else
+ font1 = 'Helvetica 12'
+ font2 = 'Helvetica 24 bold'
+end
if TkWinfo.depth($root).to_i > 1
blue = 'DeepSkyBlue3'
red = 'red'
diff --git a/ext/tk/sample/demos-en/knightstour.rb b/ext/tk/sample/demos-en/knightstour.rb
new file mode 100644
index 0000000000..618fce5f02
--- /dev/null
+++ b/ext/tk/sample/demos-en/knightstour.rb
@@ -0,0 +1,271 @@
+# Based on the widget demo of Tcl/Tk8.5.2
+# The following is the original copyright text.
+#----------------------------------------------------------------------------
+# Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# Calculate a Knight's tour of a chessboard.
+#
+# This uses Warnsdorff's rule to calculate the next square each
+# time. This specifies that the next square should be the one that
+# has the least number of available moves.
+#
+# Using this rule it is possible to get to a position where
+# there are no squares available to move into. In this implementation
+# this occurs when the starting square is d6.
+#
+# To solve this fault an enhancement to the rule is that if we
+# have a choice of squares with an equal score, we should choose
+# the one nearest the edge of the board.
+#
+# If the call to the Edgemost function is commented out you can see
+# this occur.
+#
+# You can drag the knight to a specific square to start if you wish.
+# If you let it repeat then it will choose random start positions
+# for each new tour.
+#----------------------------------------------------------------------------
+require 'tk'
+
+class Knights_Tour
+ # Return a list of accessible squares from a given square
+ def valid_moves(square)
+ moves = []
+ [
+ [-1,-2], [-2,-1], [-2,1], [-1,2], [1,2], [2,1], [2,-1], [1,-2]
+ ].each{|col_delta, row_delta|
+ col = (square % 8) + col_delta
+ row = (square.div(8)) + row_delta
+ moves << (row * 8 + col) if row > -1 && row < 8 && col > -1 && col < 8
+ }
+ moves
+ end
+
+ # Return the number of available moves for this square
+ def check_square(square)
+ valid_moves(square).find_all{|pos| ! @visited.include?(pos)}.length
+ end
+
+ # Select the next square to move to. Returns -1 if there are no available
+ # squares remaining that we can move to.
+ def next_square(square)
+ minimum = 9
+ nxt = -1
+ valid_moves(square).each{|pos|
+ unless @visited.include?(pos)
+ cnt = check_square(pos)
+ if cnt < minimum
+ minimum = cnt
+ nxt = pos
+ elsif cnt == minimum
+ nxt = edgemost(nxt, pos)
+ end
+ end
+ }
+ nxt
+ end
+
+ # Select the square nearest the edge of the board
+ def edgemost(nxt, pos)
+ col_A = 3 - ((3.5 - nxt % 8).abs.to_i)
+ col_B = 3 - ((3.5 - pos % 8).abs.to_i)
+ row_A = 3 - ((3.5 - nxt.div(8)).abs.to_i)
+ row_B = 3 - ((3.5 - pos.div(8)).abs.to_i)
+ (col_A * row_A < col_B * row_B)? nxt : pos
+ end
+
+ # Display a square number as a standard chess square notation.
+ def _N(square)
+ '%c%d' % [(97 + square % 8), (square.div(8) + 1)]
+ end
+
+ # Perform a Knight's move and schedule the next move.
+ def move_piece(last, square)
+ @log.insert(:end, "#{@visited.length}. #{_N last} -> #{_N square}\n", '')
+ @log.see(:end)
+ @board.itemconfigure(1+last, :state=>:normal, :outline=>'black')
+ @board.itemconfigure(1+square, :state=>:normal, :outline=>'red')
+ @knight.coords(@board.coords(1+square)[0..1])
+ @visited << square
+ if (nxt = next_square(square)) != -1
+ @after_id = Tk.after(@delay.numeric){move_piece(square, nxt) rescue nil}
+ else
+ @start_btn.state :normal
+ if @visited.length == 64
+ if @initial == square
+ @log.insert :end, 'Closed tour!'
+ else
+ @log.insert :end, "Success\n", {}
+ Tk.after(@delay.numeric * 2){tour(rand(64))} if @continuous.bool
+ end
+ else
+ @log.insert :end, "FAILED!\n", {}
+ end
+ end
+ end
+
+ # Begin a new tour of the board given a random start position
+ def tour(square = nil)
+ @visited.clear
+ @log.clear
+ @start_btn.state :disabled
+ 1.upto(64){|n|
+ @board.itemconfigure(n, :state=>:disabled, :outline=>'black')
+ }
+ unless square
+ square = @board.find_closest(*(@knight.coords << 0 << 65))[0].to_i - 1
+ end
+ @initial = square
+ Tk.after_idle{ move_piece(@initial, @initial) rescue nil }
+ end
+
+ def _stop
+ Tk.after_cancel(@after_id) rescue nil
+ end
+
+ def _exit
+ _stop
+ $knightstour.destroy
+ end
+
+ def set_delay(new)
+ @delay.numeric = new.to_i
+ end
+
+ def drag_start(w, x, y)
+ w.dtag('selected')
+ w.addtag('selected', :withtag, 'current')
+ @dragging = [x, y]
+ end
+
+ def drag_motion(w, x, y)
+ return unless @dragging
+ w.move('selected', x - @dragging[0], y - @dragging[1])
+ @dragging = [x, y]
+ end
+
+ def drag_end(w, x, y)
+ square = w.find_closest(x, y, 0, 65)
+ w.coords('selected', w.coords(square)[0..1])
+ w.dtag('selected')
+ @dragging = nil
+ end
+
+ def make_SeeDismiss
+ ## See Code / Dismiss
+ frame = Ttk::Frame.new($knightstour)
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'knightstour'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $knightstour.destroy
+ $knightstour = nil
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ frame
+ end
+
+ def create_gui(parent = nil)
+ $knightstour.destroy rescue nil
+ $knightstour = Tk::Toplevel.new(parent, :title=>"Knight's tour")
+ $knightstour.withdraw
+ base_f = Ttk::Frame.new($knightstour)
+ @board = Tk::Canvas.new(base_f, :width=>240, :height=>240)
+ @log = Tk::Text.new(base_f, :width=>12, :height=>1,
+ :font=>'Arial 8', :background=>'white')
+ scr = @log.yscrollbar(Ttk::Scrollbar.new(base_f))
+
+ @visited = []
+ @delay = TkVariable.new(600)
+ @continuous = TkVariable.new(false)
+
+ tool_f = Ttk::Frame.new($knightstour)
+ label = Ttk::Label.new(tool_f, :text=>'Speed')
+ scale = Ttk::Scale.new(tool_f, :from=>8, :to=>2000, :variable=>@delay,
+ :command=>proc{|n| set_delay(n)})
+ check = Ttk::Checkbutton.new(tool_f, :text=>'Repeat',
+ :variable=>@continuous)
+ @start_btn = Ttk::Button.new(tool_f, :text=>'Start',
+ :command=>proc{tour()})
+ @exit_btn = Ttk::Button.new(tool_f, :text=>'Exit',
+ :command=>proc{_exit()})
+
+ 7.downto(0){|row|
+ 0.upto(7){|col|
+ if ((col & 1) ^ (row & 1)).zero?
+ fill = 'bisque'
+ dfill = 'bisque3'
+ else
+ fill = 'tan3'
+ dfill = 'tan4'
+ end
+ coords = [col * 30 + 4, row * 30 + 4, col * 30 + 30, row * 30 + 30]
+ @board.create(TkcRectangle, coords,
+ :fill=>fill, :disabledfill=>dfill,
+ :width=>2, :state=>:disabled)
+ }
+ }
+
+ @knight_font = TkFont.new(:size=>-24)
+ @knight = TkcText.new(@board, 0, 0, :font=>@knight_font,
+ :text=>Tk::UTF8_String.new('\u265e'),
+ :anchor=>'nw', # :tags=>'knight',
+ :fill=>'black', :activefill=>'#600000')
+ @knight.coords(@board.coords(rand(64)+1)[0..1])
+ @knight.bind('ButtonPress-1', '%W %x %y'){|w,x,y| drag_start(w,x,y)}
+ @knight.bind('Motion', '%W %x %y'){|w,x,y| drag_motion(w,x,y)}
+ @knight.bind('ButtonRelease-1', '%W %x %y'){|w,x,y| drag_end(w,x,y)}
+
+ Tk.grid(@board, @log, scr, :sticky=>'news')
+ base_f.grid_rowconfigure(0, :weight=>1)
+ base_f.grid_columnconfigure(0, :weight=>1)
+
+ Tk.grid(base_f, '-', '-', '-', '-', '-', :sticky=>'news')
+ widgets = [label, scale, check, @start_btn]
+ sg = nil
+ unless $RubyTk_WidgetDemo
+ widgets << @exit_btn
+ if Tk.windowingsystem != 'aqua'
+ #widgets.unshift(Ttk::SizeGrip.new(tool_f))
+ Ttk::SizeGrip.new(tool_f).pack(:side=>:right, :anchor=>'se')
+ end
+ end
+ Tk.pack(widgets, :side=>:right)
+ if Tk.windowingsystem == 'aqua'
+ TkPack.configure(widgets, :padx=>[4, 4], :pady=>[12, 12])
+ TkPack.configure(widgets[0], :padx=>[4, 24])
+ TkPack.configure(widgets[-1], :padx=>[16, 4])
+ end
+
+ Tk.grid(tool_f, '-', '-', '-', '-', '-', :sticky=>'ew')
+
+ if $RubyTk_WidgetDemo
+ Tk.grid(make_SeeDismiss(), '-', '-', '-', '-', '-', :sticky=>'ew')
+ end
+
+ $knightstour.grid_rowconfigure(0, :weight=>1)
+ $knightstour.grid_columnconfigure(0, :weight=>1)
+
+ $knightstour.bind('Control-F2'){TkConsole.show}
+ $knightstour.bind('Return'){@start_btn.invoke}
+ $knightstour.bind('Escape'){@exit_btn.invoke}
+ $knightstour.bind('Destroy'){ _stop }
+ $knightstour.protocol('WM_DELETE_WINDOW'){ _exit }
+
+ $knightstour.deiconify
+ $knightstour.tkwait_destroy
+ end
+
+ def initialize(parent = nil)
+ create_gui(parent)
+ end
+end
+
+Tk.root.withdraw unless $RubyTk_WidgetDemo
+Thread.new{Tk.mainloop} if __FILE__ == $0
+Knights_Tour.new
diff --git a/ext/tk/sample/demos-en/label.rb b/ext/tk/sample/demos-en/label.rb
index 55e07a5ebc..91e41e4a22 100644
--- a/ext/tk/sample/demos-en/label.rb
+++ b/ext/tk/sample/demos-en/label.rb
@@ -19,8 +19,10 @@ $label_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($label_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($label_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($label_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($label_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -47,8 +49,8 @@ TkFrame.new($label_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# label demo
-f_left = TkFrame.new($label_demo)
-f_right = TkFrame.new($label_demo)
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
'padx'=>10, 'pady'=>10, 'fill'=>'both')}
@@ -59,7 +61,8 @@ f_right = TkFrame.new($label_demo)
TkLabel.new(f_left, 'text'=>'Third label, sunken', 'relief'=>'sunken')
].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
-TkLabel.new(f_right) {
+# TkLabel.new(f_right) {
+Tk::Label.new(f_right) {
bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
borderwidth 2
relief 'sunken'
diff --git a/ext/tk/sample/demos-en/labelframe.rb b/ext/tk/sample/demos-en/labelframe.rb
index 842a4f6c04..c912ff4c52 100644
--- a/ext/tk/sample/demos-en/labelframe.rb
+++ b/ext/tk/sample/demos-en/labelframe.rb
@@ -17,8 +17,10 @@ $labelframe_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($labelframe_demo).pack(:fill=>:both, :expand=>true)
+
# Some information
-TkLabel.new($labelframe_demo,
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
Labelframes are used to group related widgets together. \
@@ -29,7 +31,7 @@ which supports a 'labelframe' widget.
EOL
# The bottom buttons
-TkFrame.new($labelframe_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
@@ -43,7 +45,7 @@ TkFrame.new($labelframe_demo){|f|
}
# Demo area
-w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both,
+w = TkFrame.new(base_frame).pack(:side=>:bottom, :fill=>:both,
:expand=>true)
# A group of radiobuttons in a labelframe
diff --git a/ext/tk/sample/demos-en/mclist.rb b/ext/tk/sample/demos-en/mclist.rb
new file mode 100644
index 0000000000..a849eba515
--- /dev/null
+++ b/ext/tk/sample/demos-en/mclist.rb
@@ -0,0 +1,117 @@
+# mclist.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget configured as a multi-column listbox.
+#
+# based on "Id: mclist.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($mclist_demo) && $mclist_demo
+ $mclist_demo.destroy
+ $mclist_demo = nil
+end
+
+$mclist_demo = TkToplevel.new {|w|
+ title("Multi-Column List")
+ iconname("mclist")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($mclist_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttk is the new Tk themed widget set. \
+One of the widgets it includes is a tree widget, \
+which can be configured to display multiple columns of informational data \
+without displaying the tree itself. \
+This is a simple way to build a listbox that has multiple columns. \
+Clicking on the heading for a column will sort the data by that column. \
+You can also change the width of the columns \
+by dragging the boundary between them.
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'mclist'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $mclist_demo.destroy
+ $mclist_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+container = Ttk::Frame.new(base_frame)
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(country capital currency),
+ :show=>:headings)
+if Tk.windowingsystem != 'aqua'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+container.pack(:fill=>:both, :expand=>true)
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
+
+## The data we're going to insert
+data = [
+ ['Argentina', 'Buenos Aires', 'ARS'],
+ ['Australia', 'Canberra', 'AUD'],
+ ['Brazil', 'Brazilia', 'BRL'],
+ ['Canada', 'Ottawa', 'CAD'],
+ ['China', 'Beijing', 'CNY'],
+ ['France', 'Paris', 'EUR'],
+ ['Germany', 'Berlin', 'EUR'],
+ ['India', 'New Delhi', 'INR'],
+ ['Italy', 'Rome', 'EUR'],
+ ['Japan', 'Tokyo', 'JPY'],
+ ['Mexico', 'Mexico City', 'MXN'],
+ ['Russia', 'Moscow', 'RUB'],
+ ['South Africa', 'Pretoria', 'ZAR'],
+ ['United Kingdom', 'London', 'GBP'],
+ ['United States', 'Washington, D.C.', 'USD'],
+]
+
+## Code to insert the data nicely
+font = Ttk::Style.lookup(tree[:style], :font)
+cols = %w(country capital currency)
+cols.zip(%w(Country Capital Currency)).each{|col, name|
+ tree.heading_configure(col, :text=>name,
+ :command=>proc{sort_by(tree, col, false)})
+ tree.column_configure(col, :width=>TkFont.measure(font, name))
+}
+
+data.each{|country, capital, currency|
+ #tree.insert('', :end, :values=>[country, capital, currency])
+ tree.insert(nil, :end, :values=>[country, capital, currency])
+ cols.zip([country, capital, currency]).each{|col, val|
+ len = TkFont.measure(font, "#{val} ")
+ if tree.column_cget(col, :width) < len
+ tree.column_configure(col, :width=>len)
+ end
+ }
+}
+
+## Code to do the sorting of the tree contents when clicked on
+def sort_by(tree, col, direction)
+ tree.children(nil).map!{|row| [tree.get(row, col), row.id]} .
+ sort(&((direction)? proc{|x, y| y <=> x}: proc{|x, y| x <=> y})) .
+ each_with_index{|info, idx| tree.move(info[1], nil, idx)}
+
+ tree.heading_configure(col, :command=>proc{sort_by(tree, col, ! direction)})
+end
diff --git a/ext/tk/sample/demos-en/menu.rb b/ext/tk/sample/demos-en/menu.rb
index 8370d2f5f0..bf6c22cb9d 100644
--- a/ext/tk/sample/demos-en/menu.rb
+++ b/ext/tk/sample/demos-en/menu.rb
@@ -15,8 +15,10 @@ $menu_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($menu_demo).pack(:fill=>:both, :expand=>true)
+
# menu frame
-$menu_frame = TkFrame.new($menu_demo, 'relief'=>'raised', 'bd'=>2)
+$menu_frame = TkFrame.new(base_frame, 'relief'=>'raised', 'bd'=>2)
$menu_frame.pack('side'=>'top', 'fill'=>'x')
begin
@@ -26,7 +28,7 @@ rescue
end
# label
-TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
if $tk_platform['platform'] == 'macintosh' ||
windowingsystem == "classic" || windowingsystem == "aqua"
text("This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse.")
@@ -36,7 +38,7 @@ TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
}.pack('side'=>'top')
# frame
-TkFrame.new($menu_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -105,7 +107,7 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
'accelerator'=>"#{modifier}+G", 'underline'=>6)
$menu_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
- TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_check|
cascade_menu.add('cascade', 'label'=>'Check buttons',
'menu'=>cascade_check, 'underline'=>0)
oil = TkVariable.new(0)
@@ -127,7 +129,7 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
invoke 3
}
- TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_radio|
cascade_menu.add('cascade', 'label'=>'Radio buttons',
'menu'=>cascade_radio, 'underline'=>0)
pointSize = TkVariable.new
diff --git a/ext/tk/sample/demos-en/menu84.rb b/ext/tk/sample/demos-en/menu84.rb
index cb616d8461..4029ce5541 100644
--- a/ext/tk/sample/demos-en/menu84.rb
+++ b/ext/tk/sample/demos-en/menu84.rb
@@ -15,6 +15,8 @@ $menu84_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($menu84_demo).pack(:fill=>:both, :expand=>true)
+
begin
windowingsystem = Tk.windowingsystem()
rescue
@@ -22,7 +24,7 @@ rescue
end
# label
-TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
if $tk_platform['platform'] == 'macintosh' ||
windowingsystem == "classic" || windowingsystem == "aqua"
text("This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse.")
@@ -33,7 +35,7 @@ TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
menustatus = TkVariable.new(" ")
-TkFrame.new($menu84_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken',
'bd'=>1, 'font'=>['Helvetica', '10'],
'anchor'=>'w').pack('side'=>'left', 'padx'=>2,
@@ -43,7 +45,7 @@ TkFrame.new($menu84_demo) {|frame|
# frame
-TkFrame.new($menu84_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
diff --git a/ext/tk/sample/demos-en/menubu.rb b/ext/tk/sample/demos-en/menubu.rb
index e2ddd07bc6..b37367e515 100644
--- a/ext/tk/sample/demos-en/menubu.rb
+++ b/ext/tk/sample/demos-en/menubu.rb
@@ -37,16 +37,18 @@ $menubu_demo = TkToplevel.new {|w|
positionWindow($menubu_demo)
+base_frame = TkFrame.new($menubu_demo).pack(:fill=>:both, :expand=>true)
+
# version check
if $tk_version.to_f < 8.0
# label
-TkLabel.new($menubu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
text("This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette.")
}.pack('side'=>'top')
# frame
-TkFrame.new($menubu_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -64,7 +66,7 @@ TkFrame.new($menubu_demo) {|frame|
else ; # Tk8.x
-body = TkFrame.new($menubu_demo)
+body = TkFrame.new(base_frame)
body.pack('expand'=>'yes', 'fill'=>'both')
below = TkMenubutton.new(body) {
@@ -159,7 +161,7 @@ center = TkFrame.new(body) {
grid('row'=>1, 'column'=>1, 'sticky'=>'news')
}
-TkFrame.new($menubu_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc {
diff --git a/ext/tk/sample/demos-en/msgbox.rb b/ext/tk/sample/demos-en/msgbox.rb
index aab1b619cf..62b1f2b985 100644
--- a/ext/tk/sample/demos-en/msgbox.rb
+++ b/ext/tk/sample/demos-en/msgbox.rb
@@ -18,12 +18,14 @@ $msgbox_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($msgbox_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box.").pack('side'=>'top')
# frame
-TkFrame.new($msgbox_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -45,8 +47,8 @@ TkFrame.new($msgbox_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-$msgbox_leftframe = TkFrame.new($msgbox_demo)
-$msgbox_rightframe = TkFrame.new($msgbox_demo)
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
'pady'=>'.5c', 'padx'=>'.5c')
$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
diff --git a/ext/tk/sample/demos-en/msgbox2.rb b/ext/tk/sample/demos-en/msgbox2.rb
new file mode 100644
index 0000000000..6fe6c778b3
--- /dev/null
+++ b/ext/tk/sample/demos-en/msgbox2.rb
@@ -0,0 +1,91 @@
+# msgbox2.rb
+#
+# This demonstration script creates message boxes of various type
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($msgbox2_demo) && $msgbox2_demo
+ $msgbox2_demo.destroy
+ $msgbox2_demo = nil
+end
+
+# demo toplevel widget
+$msgbox2_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($msgbox2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box with both of a message and a detail.").pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $msgbox2_demo
+ $msgbox2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'msgbox2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Message Box'
+ command proc{showMessageBox $msgbox2_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'Icon').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'Type').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"\"#{$msgboxType.value}\" Type MessageBox",
+ 'detail'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon. Please click one of the following button.")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"You have selected \"#{button}\"")
+end
+
diff --git a/ext/tk/sample/demos-en/paned1.rb b/ext/tk/sample/demos-en/paned1.rb
index 48ba86de02..26941b84a8 100644
--- a/ext/tk/sample/demos-en/paned1.rb
+++ b/ext/tk/sample/demos-en/paned1.rb
@@ -16,7 +16,9 @@ $paned1_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($paned1_demo,
+base_frame = TkFrame.new($paned1_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
@@ -24,7 +26,7 @@ If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doe
EOL
# The bottom buttons
-TkFrame.new($paned1_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
@@ -37,9 +39,9 @@ TkFrame.new($paned1_demo){|f|
}).pack(:side=>:left, :expand=>true)
}
-TkPanedwindow.new($paned1_demo){|f|
- pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+TkPanedwindow.new(base_frame, :orient=>:horizontal){|f|
+ add(Tk::Label.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
+ Tk::Label.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
- add(TkLabel.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
- TkLabel.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
}
diff --git a/ext/tk/sample/demos-en/paned2.rb b/ext/tk/sample/demos-en/paned2.rb
index 5911cadab6..0e62013886 100644
--- a/ext/tk/sample/demos-en/paned2.rb
+++ b/ext/tk/sample/demos-en/paned2.rb
@@ -16,7 +16,9 @@ $paned2_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($paned2_demo,
+base_frame = TkFrame.new($paned2_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
@@ -24,7 +26,7 @@ If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doe
EOL
# The bottom buttons
-TkFrame.new($paned2_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
@@ -61,7 +63,7 @@ paneList.value = [ # ruby's array --> tcl's list
]
# Create the pane itself
-TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
+TkPanedwindow.new(base_frame, :orient=>:vertical){|f|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
add(TkFrame.new(f){|paned2_top|
diff --git a/ext/tk/sample/demos-en/patch_1.1c1 b/ext/tk/sample/demos-en/patch_1.1c1
deleted file mode 100644
index d3952e71eb..0000000000
--- a/ext/tk/sample/demos-en/patch_1.1c1
+++ /dev/null
@@ -1,93 +0,0 @@
---- /usr/src/ruby-1.1c1/lib/tkcanvas.rb Tue Jul 21 18:18:02 1998
-+++ tkcanvas.rb Fri Jul 24 20:38:24 1998
-@@ -310,7 +310,7 @@
- || key == 'latinfont' || key == 'asciifont' )
- tagfont_configure(tagid(tagOrId), {key=>value})
- else
-- tk_call 'itemconfigure', tagid(tagOrId), "-#{key}", value
-+ tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
- end
- end
- end
---- /usr/src/ruby-1.1c1/lib/tkfont.rb Fri Jul 17 23:43:28 1998
-+++ tkfont.rb Fri Jul 24 17:46:22 1998
-@@ -42,7 +42,7 @@
- r | []
-
- when /^8\.*/
-- list(tk_call('font', 'names'))
-+ tk_split_simplelist(tk_call('font', 'names'))
-
- end
- end
-@@ -89,10 +89,14 @@
- if fnt == []
- TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
- else
-- compound = Hash[*list(tk_call('font', 'configure',
-- fnt))].collect{|key,value|
-- [key[1..-1], value]
-- }.assoc('compound')[1]
-+ begin
-+ compound = Hash[*list(tk_call('font', 'configure',
-+ fnt))].collect{|key,value|
-+ [key[1..-1], value]
-+ }.assoc('compound')[1]
-+ rescue
-+ compound = []
-+ end
- if compound == []
- TkFont.new(fnt, DEFAULT_KANJI_FONT_NAME) \
- .call_font_configure(path, *(args + [{}]))
-@@ -156,14 +160,19 @@
- elsif font.kind_of? Array
- finfo = {}
- finfo['family'] = font[0].to_s
-- if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/
-- if $1 == '-'
-- finfo['pixels'] = font[1].to_s
-+ if font[1]
-+ fsize = font[1].to_s
-+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
-+ if $1 == '-'
-+ finfo['pixels'] = $2
-+ else
-+ finfo['points'] = $2
-+ end
- else
-- finfo['points'] = font[1].to_s
-+ finfo['points'] = '13'
- end
- end
-- finfo[2..-1].each{|style|
-+ font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
-@@ -199,16 +208,19 @@
- elsif font.kind_of? Array
- finfo = {}
- finfo['family'] = font[0].to_s
-- if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/
-- if $1 == '-'
-- finfo['pixels'] = $2
-+ if font[1]
-+ fsize = font[1].to_s
-+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
-+ if $1 == '-'
-+ finfo['pixels'] = $2
-+ else
-+ finfo['points'] = $2
-+ end
- else
-- finfo['points'] = $2
-+ finfo['points'] = '13'
- end
-- else
-- finfo['points'] = '13'
- end
-- finfo[2..-1].each{|style|
-+ font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
diff --git a/ext/tk/sample/demos-en/pendulum.rb b/ext/tk/sample/demos-en/pendulum.rb
index a3498d67cf..5f7d361170 100644
--- a/ext/tk/sample/demos-en/pendulum.rb
+++ b/ext/tk/sample/demos-en/pendulum.rb
@@ -18,8 +18,10 @@ $pendulum_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($pendulum_demo).pack(:fill=>:both, :expand=>true)
+
# create label
-msg = TkLabel.new($pendulum_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -28,7 +30,7 @@ msg = TkLabel.new($pendulum_demo) {
msg.pack('side'=>'top')
# create frame
-TkFrame.new($pendulum_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -49,7 +51,7 @@ TkFrame.new($pendulum_demo) {|frame|
class PendulumAnimationDemo
def initialize(frame)
# Create some structural widgets
- @pane = TkPanedWindow.new(frame).pack(:fill=>:both, :expand=>true)
+ @pane = TkPanedWindow.new(frame, :orient=>:horizontal).pack(:fill=>:both, :expand=>true)
# @pane.add(@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation'))
# @pane.add(@lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space'))
@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation')
@@ -235,4 +237,4 @@ class PendulumAnimationDemo
end
# Start the animation processing
-PendulumAnimationDemo.new($pendulum_demo)
+PendulumAnimationDemo.new(base_frame)
diff --git a/ext/tk/sample/demos-en/plot.rb b/ext/tk/sample/demos-en/plot.rb
index 6d01deeef5..628c9df584 100644
--- a/ext/tk/sample/demos-en/plot.rb
+++ b/ext/tk/sample/demos-en/plot.rb
@@ -19,14 +19,16 @@ $plot_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($plot_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
'text'=>"This window displays a canvas widget containing a simple 2-dimensional plot. You can doctor the data by dragging any of the points with mouse button 1."){
pack('side'=>'top')
}
# frame
-$plot_buttons = TkFrame.new($plot_demo) {|frame|
+$plot_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -47,7 +49,7 @@ $plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
# canvas
-$plot_canvas = TkCanvas.new($plot_demo,'relief'=>'raised','width'=>450,'height'=>300)
+$plot_canvas = TkCanvas.new(base_frame,'relief'=>'raised','width'=>450,'height'=>300)
$plot_canvas.pack('side'=>'top', 'fill'=>'x')
# plot
diff --git a/ext/tk/sample/demos-en/puzzle.rb b/ext/tk/sample/demos-en/puzzle.rb
index 0885cf2975..43c61f519f 100644
--- a/ext/tk/sample/demos-en/puzzle.rb
+++ b/ext/tk/sample/demos-en/puzzle.rb
@@ -19,8 +19,10 @@ $puzzle_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($puzzle_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($puzzle_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($puzzle_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($puzzle_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -52,18 +54,27 @@ TkFrame.new($puzzle_demo) {|frame|
# scrollbar widget and using its trough color.
begin
if Tk.windowingsystem() == 'aqua'
- frameSize = 160
+ frameWidth = 168
+ frameHeight = 168
+ elsif Tk.default_widget_set == :Ttk
+ frameWidth = 148
+ frameHeight = 124
else
- frameSize = 120
+ frameWidth = 120
+ frameHeight = 120
end
rescue
- frameSize = 120
+ frameWidth = 120
+ frameHeight = 120
end
+
+# depend_on_button_width = true
+depend_on_button_width = false
-s = TkScrollbar.new($puzzle_demo)
-base = TkFrame.new($puzzle_demo) {
- width frameSize
- height frameSize
+s = TkScrollbar.new(base_frame)
+base = TkFrame.new(base_frame) {
+ width frameWidth
+ height frameHeight
borderwidth 2
relief 'sunken'
bg s['troughcolor']
@@ -87,6 +98,9 @@ order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12]
text num
highlightthickness 0
command def_puzzleswitch_proc(w, num)
+ if depend_on_button_width && (w.winfo_reqwidth * 4 > base.width)
+ base.width = w.winfo_reqwidth * 4
+ end
}.place('relx'=>$xpos[num], 'rely'=>$ypos[num],
'relwidth'=>0.25, 'relheight'=>0.25)
}
diff --git a/ext/tk/sample/demos-en/radio.rb b/ext/tk/sample/demos-en/radio.rb
index 96cdc4c54a..25cfac2134 100644
--- a/ext/tk/sample/demos-en/radio.rb
+++ b/ext/tk/sample/demos-en/radio.rb
@@ -19,8 +19,10 @@ $radio_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($radio_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($radio_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -33,7 +35,7 @@ size = TkVariable.new
color = TkVariable.new
# frame
-TkFrame.new($radio_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -52,14 +54,14 @@ TkFrame.new($radio_demo) {|frame|
TkButton.new(frame) {
text 'See Variables'
command proc{
- showVars($radio_demo, ['size', size], ['color', color])
+ showVars(base_frame, ['size', size], ['color', color])
}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-f_left = TkFrame.new($radio_demo)
-f_right = TkFrame.new($radio_demo)
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
diff --git a/ext/tk/sample/demos-en/radio2.rb b/ext/tk/sample/demos-en/radio2.rb
index 2b56ccc9b1..6c02aef0cf 100644
--- a/ext/tk/sample/demos-en/radio2.rb
+++ b/ext/tk/sample/demos-en/radio2.rb
@@ -19,8 +19,10 @@ $radio2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($radio2_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($radio2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -34,7 +36,7 @@ color = TkVariable.new
align = TkVariable.new
# frame
-TkFrame.new($radio2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -53,18 +55,18 @@ TkFrame.new($radio2_demo) {|frame|
TkButton.new(frame) {
text 'See Variables'
command proc{
- showVars($radio2_demo,
+ showVars(base_frame,
['size', size], ['color', color], ['compound', align])
}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-f_left = TkLabelFrame.new($radio2_demo, 'text'=>'Point Size',
+f_left = TkLabelFrame.new(base_frame, 'text'=>'Point Size',
'pady'=>2, 'padx'=>2)
-f_mid = TkLabelFrame.new($radio2_demo, 'text'=>'Color',
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'Color',
'pady'=>2, 'padx'=>2)
-f_right = TkLabelFrame.new($radio2_demo, 'text'=>'Alignment',
+f_right = TkLabelFrame.new(base_frame, 'text'=>'Alignment',
'pady'=>2, 'padx'=>2)
f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
@@ -90,7 +92,8 @@ f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
}.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
}
-label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+# label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
'compound'=>'left')
label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
label.height(TkWinfo.reqheight(label))
diff --git a/ext/tk/sample/demos-en/radio3.rb b/ext/tk/sample/demos-en/radio3.rb
index 70c4abb3b5..9c9d75ef4a 100644
--- a/ext/tk/sample/demos-en/radio3.rb
+++ b/ext/tk/sample/demos-en/radio3.rb
@@ -19,8 +19,10 @@ $radio3_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($radio3_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($radio3_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -34,14 +36,14 @@ color = TkVariable.new
align = TkVariable.new
# frame
-TkFrame.new($radio3_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
TkButton.new(frame, :text=>'See Variables',
:image=>$image['view'], :compound=>:left,
:command=>proc{
- showVars($radio3_demo, ['size', size],
+ showVars(base_frame, ['size', size],
['color', color], ['compound', align])
}),
TkButton.new(frame, :text=>'See Code',
@@ -61,17 +63,17 @@ TkFrame.new($radio3_demo) {|frame|
}
# frame
-f_left = TkLabelFrame.new($radio3_demo, 'text'=>'Point Size',
+f_left = TkLabelFrame.new(base_frame, 'text'=>'Point Size',
'pady'=>2, 'padx'=>2)
-f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'Color',
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'Color',
'pady'=>2, 'padx'=>2)
-f_right = TkLabelFrame.new($radio3_demo, 'text'=>'Alignment',
+f_right = TkLabelFrame.new(base_frame, 'text'=>'Alignment',
'pady'=>2, 'padx'=>2)
f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
-TkButton.new($radio3_demo, 'text'=>'Tristate',
+TkButton.new(base_frame, 'text'=>'Tristate',
'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
}
@@ -99,7 +101,8 @@ TkButton.new($radio3_demo, 'text'=>'Tristate',
}.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
}
-label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+# label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
'compound'=>'left')
label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
label.height(TkWinfo.reqheight(label))
diff --git a/ext/tk/sample/demos-en/rolodex-j b/ext/tk/sample/demos-en/rolodex-j
deleted file mode 100644
index 27e2bc9da0..0000000000
--- a/ext/tk/sample/demos-en/rolodex-j
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/usr/bin/env ruby
-#
-# rolodex --
-# ¤³¤Î¥¹¥¯¥ê¥×¥È¤Ï Tom LaStrange ¤Î rolodex ¤Î°ìÉô¤Ç¤¹¡£
-#
-# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
-# Time-stamp: "03/08/02 14:02:04 nagai"
-#
-
-require "tk"
-
-Tk.encoding = "euc-jp"
-$font = TkFont.new('k14')
-
-def show_help(topic,x=0,y=0)
- if( topic.is_a?(TkWindow) )
- w = TkWinfo.containing(x,y)
- if( w.is_a?(TkWindow) )
- if( TkWinfo.exist?(w) )
- topic = w
- end
- end
- end
-
- if( $helpTopics.include?(topic) )
- msg = $helpTopics[topic]
- else
- msg = "¤³¤Î¥È¥Ô¥Ã¥¯¤Ë¤Ä¤¤¤Æ¤Î¥Ø¥ë¥×¤Ï¤Þ¤À»ÈÍѤǤ­¤Þ¤»¤ó"
- end
- TkDialog.new("title"=>"Rolodex Help",
- "message"=>"¡Ö#{topic}¡×\n\n#{msg}",
- "font"=>$font,
- "default_button"=>0,
- "buttons"=>["OK"])
-end
-
-def fillCard
- clearAction
- $root.frame.entry[1].insert(0, "ΩÀÐ ¹§¾´")
- $root.frame.entry[2].insert(0, "923-1292 ÀÐÀ")
- $root.frame.entry[3].insert(0, "ä¸ýÄ® °°Âæ 1-1")
- $root.frame.entry[4].insert(0, "ËÌΦÀèü²Ê³Øµ»½ÑÂç³Ø±¡Âç³Ø")
- $root.frame.entry[5].insert(0,"private")
- $root.frame.entry[6].insert(0,"***-***-****")
- $root.frame.entry[7].insert(0,"***-***-****")
-end
-
-def addAction
- for i in 1..7
- STDERR.print format("%-12s %s\n",
- RolodexFrame::LABEL[i],
- $root.frame.entry[i].value)
- end
-end
-
-def clearAction
- for i in 1..7
- $root.frame.entry[i].delete(0,"end")
- end
-end
-
-def fileAction
- TkDialog.new("title"=>"File Selection",
- "message"=>"¤³¤ì¤Ï¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤Î¥À¥ß¡¼¤Ç¤¹¡£\n",
- "font"=>$font,
- "default_button"=>0,
- "buttons"=>["OK"])
- STDERR.print "dummy file name\n"
-end
-
-def deleteAction
- result = TkDialog.new("title"=>"Confirm Action",
- "message"=>"¤è¤í¤·¤¤¤Ç¤¹¤«¡©",
- "font"=>$font,
- "default_button"=>0,
- "buttons"=>["¥­¥ã¥ó¥»¥ë"])
- if( result.value == 0 )
- clearAction
- end
-end
-
-
-class RolodexFrame < TkFrame
- attr_reader :entry, :label
-
- LABEL = ["","̾Á°:","½»½ê","","","ÅÅÏÃ(¼«Âð):","ÅÅÏÃ(²ñ¼Ò):","Fax:"]
-
- def initialize(parent=nil,keys=nil)
- super(parent,keys)
- self["relief"] = "flat"
- @i = []
- @label = []
- @entry = []
- for i in 1..7
- @i[i] = TkFrame.new(self)
- @i[i].pack("side"=>"top",
- "pady"=>2,
- "anchor"=>"e")
- @label[i] = TkLabel.new(@i[i],
- "text"=>LABEL[i],
- "anchor"=>"e",
- "font" => $font)
- @entry[i] = TkEntry.new(@i[i],
- "width"=>30,
- "relief"=>"sunken",
- "font" => $font)
- @entry[i].pack("side"=>"right")
- @label[i].pack("side"=>"right")
- end
- end
-end
-
-class RolodexButtons < TkFrame
- attr_reader :clear, :add, :search, :delete
-
- def initialize(parent,keys=nil)
- super(parent,keys)
- @clear = TkButton.new(self,
- "text" => "¥¯¥ê¥¢¡¼",
- "font" => $font)
- @add = TkButton.new(self,
- "text" => "ÄɲÃ",
- "font" => $font)
- @search = TkButton.new(self,
- "text" => "¸¡º÷",
- "font" => $font)
- @delete = TkButton.new(self,
- "text" => "¾Ãµî",
- "font" => $font)
- for w in [@clear,@add,@search,@delete]
- w.pack("side"=>"left", "padx"=>2)
- end
- end
-end
-
-class RolodexMenuFrame < TkFrame
- attr_reader :file_menu, :help_menu, :file, :help
-
- def initialize(parent,keys=nil)
- super(parent,keys)
- configure("relief"=>"raised",
- "borderwidth"=>1)
-
- @file = TkMenubutton.new(self,
- "text"=> "¥Õ¥¡¥¤¥ë",
- "font"=> $font,
- "underline"=>0)
- @file_menu = TkMenu.new(@file)
- @file_menu.add("command",
- "label" => "ÆÉ¤ß¹þ¤ß ...",
- "font" => $font,
- "command" => proc{fileAction},
- "underline" => 0)
- @file_menu.add("command",
- "label" => "½ªÎ»",
- "font" => $font,
- "command" => proc{$root.destroy},
- "underline" => 0)
- @file.menu(@file_menu)
- @file.pack("side"=>"left")
-
- @help = TkMenubutton.new(self,
- "text"=> "¥Ø¥ë¥×",
- "font"=> $font,
- "underline"=>0)
- @help_menu = TkMenu.new(@help)
- @help_menu.add("command",
- "label"=> "¥³¥ó¥Æ¥­¥¹¥È¤Ë¤Ä¤¤¤Æ",
- "font" => $font,
- "command"=>proc{show_help("¥³¥ó¥Æ¥­¥¹¥È")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "¥Ø¥ë¥×¤Ë¤Ä¤¤¤Æ",
- "font" => $font,
- "command"=>proc{show_help("¥Ø¥ë¥×")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "¥¦¥£¥ó¥É¥¦¤Ë¤Ä¤¤¤Æ",
- "font" => $font,
- "command"=>proc{show_help("¥¦¥£¥ó¥É¥¦")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "¥­¡¼Áàºî¤Ë¤Ä¤¤¤Æ",
- "font" => $font,
- "command"=>proc{show_help("¥­¡¼Áàºî")},
- "underline"=>3)
- @help_menu.add("command",
- "label"=> "¥Ð¡¼¥¸¥ç¥ó¾ðÊó",
- "font" => $font,
- "command"=>proc{show_help("¥Ð¡¼¥¸¥ç¥ó¾ðÊó")},
- "underline"=>3)
- @help.menu(@help_menu)
- @help.pack("side"=>"right")
- end
-end
-
-class Rolodex < TkRoot
- attr_reader :frame, :buttons, :menu
-
- def initialize(*args)
- super(*args)
- @frame = RolodexFrame.new(self)
- @frame.pack("side"=>"top",
- "fill"=>"y",
- "anchor"=>"center")
- @buttons = RolodexButtons.new(self)
- @buttons.pack("side"=>"bottom",
- "pady"=>2,
- "anchor"=>"center")
- @menu = RolodexMenuFrame.new(self)
- @menu.pack("before"=>@frame,
- "side"=>"top",
- "fill"=>"x")
- end
-end
-
-$root = Rolodex.new
-
-$root.buttons.delete.configure("command"=>proc{deleteAction})
-$root.buttons.add.configure("command"=>proc{addAction})
-$root.buttons.clear.configure("command"=>proc{clearAction})
-$root.buttons.search.configure("command"=>proc{addAction; fillCard})
-
-$root.buttons.clear.configure("text"=> "¥¯¥ê¥¢¡¼ Ctrl+C", "font" => $font)
-$root.bind("Control-c",proc{clearAction})
-
-$root.buttons.add.configure("text"=> "Äɲà Ctrl+A", "font" => $font)
-$root.bind("Control-a",proc{addAction})
-
-$root.buttons.search.configure("text"=> "¸¡º÷ Ctrl+S", "font" => $font)
-$root.bind("Control-s",proc{addAction; fillCard})
-
-$root.buttons.delete.configure("text"=> "¾Ãµî Ctrl+D", "font" => $font)
-$root.bind("Control-d",proc{deleteAction})
-
-$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
-$root.bind("Control-f",proc{fileAction})
-
-$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
-$root.bind("Control-q",proc{$root.destroy})
-
-$root.frame.entry[1].focus
-
-$root.bind("Any-F1",
- proc{|event| show_help(event.widget, event.x_root, event.y_root)})
-$root.bind("Any-Help",
- proc{|event| show_help(event.widget, event.x_root, event.y_root)})
-
-
-$helpTopics = {}
-
-$helpTopics[$root.menu.file] = <<EOF
-¤³¤ì¤Ï¡Ö¥Õ¥¡¥¤¥ë¡×¥á¥Ë¥å¡¼¤Ç¤¹¡£¡ÖÆÉ¤ß¹þ¤ß¡×¤ä¡Ö½ªÎ»¡×¤Ê¤É¤ò
-¹Ô¤Ê¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-EOF
-
-$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
-¥Õ¥¡¥¤¥ë¤ÎÆÉ¤ß¹þ¤ß¤ò¹Ô¤Ê¤¦¤È¤­¤Ë»È¤¤¤Þ¤¹¡£
-EOF
-
-$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
-¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë¤È¤­¤Ë»È¤¤¤Þ¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[1]] = <<EOF
-̾Á°¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[2]] = <<EOF
-½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[3]] = <<EOF
-½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[4]] = <<EOF
-½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[5]] = <<EOF
-¼«Âð¤ÎÅÅÏÃÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£¸ø³«\
-¤·¤¿¤¯¤Ê¤¤¤È¤­¤Ï private ¤Èµ­Æþ¤·¤Þ¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[6]] = <<EOF
-²ñ¼Ò¤ÎÅÅÏÃÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
-EOF
-
-$helpTopics[$root.frame.entry[7]] = <<EOF
-FAXÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
-EOF
-
-$helpTopics["¥³¥ó¥Æ¥­¥¹¥È"] = <<EOF
-Ruby/Tk¤Ç¤Ïgrab¤Îµ¡¹½¤¬¤Ê¤¤¤¿¤á¤³¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï\
-¥³¥ó¥Æ¥­¥¹¥È¥Ø¥ë¥×¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
-¤·¤«¤·Æ±¤¸¤è¤¦¤Ê¸ú²Ì¤òbind¤È¥Þ¥¦¥¹¤Î°ÌÃÖ¤ÎWedget¤òÃΤë\
-¤³¤È¤ÇÆÀ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-EOF
-
-$helpTopics["¥Ø¥ë¥×"] = <<EOF
-¥Þ¥¦¥¹¤ò¥¦¥£¥ó¥É¥¦¤Ë¤¢¤ï¤»¤ÆF1¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ\
-¤½¤Î¥Ø¥ë¥×¤ò¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-EOF
-
-$helpTopics["¥¦¥£¥ó¥É¥¦"] = <<EOF
-¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¥À¥ß¡¼¤Ç¤¹¡£
-EOF
-
-$helpTopics["¥­¡¼Áàºî"] = <<EOF
-Ctrl+A: ÄɲÃ
-Ctrl+C: ¥¯¥ê¥¢¡¼
-Ctrl+D: ¾Ãµî
-Ctrl+F: ¥Õ¥¡¥¤¥ëÁªÂò
-Ctrl+Q: ½ªÎ»
-Ctrl+S: ¸¡º÷
-EOF
-
-$helpTopics["¥Ð¡¼¥¸¥ç¥ó¾ðÊó"] = <<EOF
-¥Ð¡¼¥¸¥ç¥ó¤Ï 1.0.1e ¤Ç¤¹¡£
-EOF
-
-Tk.mainloop
diff --git a/ext/tk/sample/demos-en/ruler.rb b/ext/tk/sample/demos-en/ruler.rb
index 4299d57b4f..26cd4f3b1c 100644
--- a/ext/tk/sample/demos-en/ruler.rb
+++ b/ext/tk/sample/demos-en/ruler.rb
@@ -32,14 +32,16 @@ $ruler_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true)
+
# label
-TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
'text'=>"This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."){
pack('side'=>'top')
}
# frame
-$ruler_buttons = TkFrame.new($ruler_demo) {|frame|
+$ruler_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -57,7 +59,7 @@ $ruler_buttons = TkFrame.new($ruler_demo) {|frame|
$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# canvas
-$ruler_canvas = TkCanvas.new($ruler_demo, 'width'=>'14.8c', 'height'=>'2.5c')
+$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c')
$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
#
diff --git a/ext/tk/sample/demos-en/sayings.rb b/ext/tk/sample/demos-en/sayings.rb
index cef0f4ecf4..06ec7c1e75 100644
--- a/ext/tk/sample/demos-en/sayings.rb
+++ b/ext/tk/sample/demos-en/sayings.rb
@@ -20,8 +20,10 @@ $sayings_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($sayings_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($sayings_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -30,7 +32,7 @@ msg = TkLabel.new($sayings_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($sayings_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -49,7 +51,7 @@ TkFrame.new($sayings_demo) {|frame|
# frame
sayings_lbox = nil
-TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w|
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
sv = TkScrollbar.new(w)
sh = TkScrollbar.new(w, 'orient'=>'horizontal')
sayings_lbox = TkListbox.new(w) {
diff --git a/ext/tk/sample/demos-en/search.rb b/ext/tk/sample/demos-en/search.rb
index 3d3b4aecc8..e1fc565e9d 100644
--- a/ext/tk/sample/demos-en/search.rb
+++ b/ext/tk/sample/demos-en/search.rb
@@ -79,8 +79,10 @@ $search_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($search_demo).pack(:fill=>:both, :expand=>true)
+
# frame
-$search_buttons = TkFrame.new($search_demo) {|frame|
+$search_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -98,7 +100,7 @@ $search_buttons = TkFrame.new($search_demo) {|frame|
$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-TkFrame.new($search_demo) {|f|
+TkFrame.new(base_frame) {|f|
TkLabel.new(f, 'text'=>'File name:',
'width'=>13, 'anchor'=>'w').pack('side'=>'left')
$search_fileName = TkVariable.new
@@ -115,7 +117,7 @@ TkFrame.new($search_demo) {|f|
.pack('side'=>'left', 'pady'=>5, 'padx'=>10)
}.pack('side'=>'top', 'fill'=>'x')
-TkFrame.new($search_demo) {|f|
+TkFrame.new(base_frame) {|f|
TkLabel.new(f, 'text'=>'Search string:',
'width'=>13, 'anchor'=>'w').pack('side'=>'left')
$search_searchString = TkVariable.new
@@ -133,14 +135,14 @@ TkFrame.new($search_demo) {|f|
}
}.pack('side'=>'top', 'fill'=>'x')
-$search_text = TkText.new($search_demo, 'setgrid'=>true, 'wrap'=>'word') {|t|
+$search_text = TkText.new(base_frame, 'setgrid'=>true, 'wrap'=>'word') {|t|
$search_Tag = TkTextTag.new(t)
- TkScrollbar.new($search_demo, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
t.yscrollcommand(proc{|first,last| sc.set first,last})
pack('side'=>'right', 'fill'=>'y')
}
pack('expand'=>'yes', 'fill'=>'both')
-}
+}
# Set up display styles for text highlighting.
@@ -173,8 +175,13 @@ type a string in the lower entry and type <Return> or click on \
\"Load File\". This will cause all of the instances of the string to \
be tagged with the tag \"search\", and it will arrange for the tag\'s \
display attributes to change to make all of the strings blink.")
+$search_text.insert('end', "\
+The current directory to load a file is \"#{Dir.pwd}\".\
+")
$search_text.set_insert '0.0'
$search_fileName.value = ''
$search_searchString.value = ''
+$search_text.width = 60
+$search_text.height = 20
diff --git a/ext/tk/sample/demos-en/spin.rb b/ext/tk/sample/demos-en/spin.rb
index 58616b1e02..c2a3a8949b 100644
--- a/ext/tk/sample/demos-en/spin.rb
+++ b/ext/tk/sample/demos-en/spin.rb
@@ -15,7 +15,9 @@ $spin_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($spin_demo,
+base_frame = TkFrame.new($spin_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
Three different spin-boxes are displayed below. \
@@ -34,7 +36,7 @@ this demo doesn't work. Please use later version of Tk \
which supports a 'spinbox' widget.
EOL
-TkFrame.new($spin_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
@@ -53,11 +55,11 @@ australianCities = [
]
[
- TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
+ TkSpinbox.new(base_frame, :from=>1, :to=>10, :width=>10, :validate=>:key,
:validatecommand=>[
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
]),
- TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5,
+ TkSpinbox.new(base_frame, :from=>0, :to=>3, :increment=>0.5,
:format=>'%05.2f', :width=>10),
- TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10)
+ TkSpinbox.new(base_frame, :values=>australianCities, :width=>10)
].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}
diff --git a/ext/tk/sample/demos-en/states.rb b/ext/tk/sample/demos-en/states.rb
index d38c1245af..add0e84800 100644
--- a/ext/tk/sample/demos-en/states.rb
+++ b/ext/tk/sample/demos-en/states.rb
@@ -19,8 +19,10 @@ $states_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($states_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($states_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($states_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -48,7 +50,7 @@ TkFrame.new($states_demo) {|frame|
# frame
states_lbox = nil
-TkFrame.new($states_demo, 'borderwidth'=>'.5c') {|w|
+TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w|
s = TkScrollbar.new(w)
states_lbox = TkListbox.new(w) {
setgrid 1
diff --git a/ext/tk/sample/demos-en/style.rb b/ext/tk/sample/demos-en/style.rb
index 5ed11aa459..c2fed23926 100644
--- a/ext/tk/sample/demos-en/style.rb
+++ b/ext/tk/sample/demos-en/style.rb
@@ -19,8 +19,10 @@ $style_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($style_demo).pack(:fill=>:both, :expand=>true)
+
# frame
-TkFrame.new($style_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -37,13 +39,14 @@ TkFrame.new($style_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# text
-TkText.new($style_demo){|t|
+txt = TkText.new(base_frame){|t|
#
setgrid 'true'
- width 70
- height 32
+ #width 70
+ #height 32
wrap 'word'
- TkScrollbar.new($style_demo) {|s|
+ font $font
+ TkScrollbar.new(base_frame) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
@@ -51,11 +54,20 @@ TkText.new($style_demo){|t|
pack('expand'=>'yes', 'fill'=>'both')
#
- style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
- style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+ family = 'Courier'
+
+ if $tk_version =~ /^4.*/
+ style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
+ style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
-# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+ # style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+ else
+ style_tag_bold = TkTextTag.new(t, 'font'=>[family, 12, :bold, :italic])
+ style_tag_big = TkTextTag.new(t, 'font'=>[family, 14, :bold])
+ style_tag_verybig = TkTextTag.new(t, 'font'=>['Helvetica', 24, :bold])
+ style_tag_small = TkTextTag.new(t, 'font'=>'Times 8 bold')
+ end
###
# case($tk_version)
# when /^4.*/
@@ -109,8 +121,13 @@ TkText.new($style_demo){|t|
style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
style_tag_right = TkTextTag.new(t, 'justify'=>'right')
style_tag_center = TkTextTag.new(t, 'justify'=>'center')
- style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
- style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ if $tk_version =~ /^4.*/
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ else
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>[family, 10])
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>[family, 10])
+ end
style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
'rmargin'=>'10m')
style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
@@ -132,7 +149,8 @@ available display styles are:
insert('end', " You can choose any X font, ")
insert('end', "large", style_tag_verybig)
insert('end', " or ")
- insert('end', "small.\n")
+ insert('end', "small", style_tag_small)
+ insert('end', ".\n")
insert('end', "\n2. Color.", style_tag_big)
insert('end', " You can change either the ")
insert('end', "background", style_tag_color1)
@@ -209,3 +227,5 @@ available display styles are:
}
+txt.width 70
+txt.height 32
diff --git a/ext/tk/sample/demos-en/text.rb b/ext/tk/sample/demos-en/text.rb
index 4bb4b6bc7e..3ce8cdfda8 100644
--- a/ext/tk/sample/demos-en/text.rb
+++ b/ext/tk/sample/demos-en/text.rb
@@ -19,6 +19,8 @@ $text_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($text_demo).pack(:fill=>:both, :expand=>true)
+
# version check
if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0)
undo_support = false
@@ -27,7 +29,7 @@ else
end
# frame
-TkFrame.new($text_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -44,7 +46,7 @@ TkFrame.new($text_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# text
-TkText.new($text_demo){|t|
+TkText.new(base_frame){|t|
relief 'sunken'
bd 2
setgrid 1
@@ -53,7 +55,7 @@ TkText.new($text_demo){|t|
undo true
autoseparators true
end
- TkScrollbar.new($text_demo) {|s|
+ TkScrollbar.new(base_frame) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
diff --git a/ext/tk/sample/demos-en/textpeer.rb b/ext/tk/sample/demos-en/textpeer.rb
new file mode 100644
index 0000000000..c25ce15e5c
--- /dev/null
+++ b/ext/tk/sample/demos-en/textpeer.rb
@@ -0,0 +1,76 @@
+#
+# text widget peering demo (called by 'widget')
+#
+# based on Tcl/Tk8.5.0 widget demos
+
+if defined?($textpeer_demo) && $textpeer_demo
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+end
+
+# demo toplevel widget
+$textpeer_demo = TkToplevel.new {|w|
+ title("Text Wdget Peering Demonstration")
+ iconname("textpeer")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($textpeer_demo).pack(:fill=>:both, :expand=>true)
+
+count = [0]
+
+## Define a widget that we peer from; it won't ever actually be shown though
+first = TkText.new(base_frame, :widgetname=>"text#{count[0] += 1}")
+first.insert :end,"This is a coupled pair of text widgets; they are peers to "
+first.insert :end,"each other. They have the same underlying data model, but "
+first.insert :end,"can show different locations, have different current edit "
+first.insert :end,"locations, and have different selections. You can also "
+first.insert :end,"create additional peers of any of these text widgets using "
+first.insert :end,"the Make Peer button beside the text widget to clone, and "
+first.insert :end,"delete a particular peer widget using the Delete Peer "
+first.insert :end,"button."
+
+Tk.update_idletasks ## for 'first' widget
+
+## Procedures to make and kill clones; most of this is just so that the demo
+## looks nice...
+def makeClone(count, win, txt)
+ cnt = (count[0] += 1)
+ peer = TkText::Peer.new(txt, win, :widgetname=>"text#{cnt}")
+ sbar = TkScrollbar.new(win, :widgetname=>"sb#{cnt}")
+ peer.yscrollbar sbar
+ b1 = TkButton.new(win, :widgetname=>"clone#{cnt}", :text=>'Make Peer',
+ :command=>proc{makeClone(count, win, peer)})
+ b2 = TkButton.new(win, :widgetname=>"kill#{cnt}", :text=>'Delete Peer',
+ :command=>proc{killClone(win, cnt)})
+ row = cnt * 2
+ TkGrid.configure(peer, sbar, b1, :sticky=>'nsew', :row=>row)
+ TkGrid.configure('^', '^', b2, :sticky=>'nsew', :row=>(row+=1))
+ TkGrid.configure(b1, b2, :sticky=>'new')
+ TkGrid.rowconfigure(win, b2, :weight=>1)
+end
+
+def killClone(win, cnt)
+ Tk.destroy("#{win.path}.text#{cnt}", "#{win.path}.sb#{cnt}",
+ "#{win.path}.clone#{cnt}", "#{win.path}.kill#{cnt}")
+end
+
+## Now set up the GUI
+makeClone(count, base_frame, first)
+makeClone(count, base_frame, first)
+first.destroy
+
+## See Code / Dismiss buttons
+TkFrame.new(base_frame){|f|
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'textpeer'
+ }).pack(:side=>:left, :expand=>true)
+
+ TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000)
+}
+TkGrid.columnconfigure(base_frame, 0, :weight=>1)
diff --git a/ext/tk/sample/demos-en/toolbar.rb b/ext/tk/sample/demos-en/toolbar.rb
new file mode 100644
index 0000000000..5cf863717b
--- /dev/null
+++ b/ext/tk/sample/demos-en/toolbar.rb
@@ -0,0 +1,130 @@
+# toolbar.rb --
+#
+# This demonstration script creates a toolbar that can be torn off.
+#
+# based on "Id: toolbar.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($toolbar_demo) && $toolbar_demo
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+end
+
+$toolbar_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("toolbar")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($toolbar_demo).pack(:fill=>:both, :expand=>true)
+
+if Tk.windowingsystem != 'aqua'
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i',
+ :text=>Tk::UTF8_String.new(<<EOL))
+This is a demonstration of how to do \
+a toolbar that is styled correctly \
+and which can be torn off (this feature reqrires Tcl/Tk8.5). \
+The buttons are configured to be \\u201Ctoolbar style\\u201D buttons by \
+telling them that they are to use the Toolbutton style. At the left \
+end of the toolbar is a simple marker that the cursor changes to a \
+movement icon over; drag that away from the toolbar to tear off the \
+whole toolbar into a separate toplevel widget. When the dragged-off \
+toolbar is no longer needed, just close it like any normal toplevel \
+and it will reattach to the window it was torn off from.
+EOL
+else
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i',
+ :text=>Tk::UTF8_String.new(<<EOL))
+This is a demonstration of how to do \
+a toolbar that is styled correctly. The buttons are configured to \
+be \\u201Ctoolbar style\\u201D buttons by telling them that they are \
+to use the Toolbutton style.
+EOL
+end
+
+## Set up the toolbar hull
+tbar_base = Tk::Frame.new(base_frame, # Must be a starndard Tk frame!
+ :widgetname=>'toolbar') # for window title
+sep = Ttk::Separator.new(base_frame)
+to_base = Ttk::Frame.new(tbar_base, :cursor=>'fleur')
+if Tk.windowingsystem != 'aqua'
+ to = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to2 = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to.pack(:fill=>:y, :expand=>true, :padx=>2, :side=>:left)
+ to2.pack(:fill=>:y, :expand=>true, :side=>:left)
+end
+
+contents = Ttk::Frame.new(tbar_base)
+Tk.grid(to_base, contents, :sticky=>'nsew')
+tbar_base.grid_columnconfigure(contents, :weight=>1)
+contents.grid_columnconfigure(1000, :weight=>1)
+
+if Tk.windowingsystem != 'aqua'
+ ## Bindings so that the toolbar can be torn off and reattached
+ to_base.bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to2. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ def tbar_base.tearoff(w, x, y)
+ on_win = TkWinfo.containing(x, y)
+ return unless (on_win && on_win.path =~ /^#{@path}(\.|$)/)
+ self.grid_remove
+ w.grid_remove
+ self.wm_manage
+ # self.wm_title('Toolbar') # if you don't want to use its widget name as a window title.
+ self.wm_protocol('WM_DELETE_WINDOW'){ self.untearoff(self) }
+ end
+ def tbar_base.untearoff(w)
+ self.wm_forget
+ w.grid
+ self.grid
+ end
+end
+
+## Some content for the rest of the toplevel
+text = TkText.new(base_frame, :width=>40, :height=>10)
+
+## Toolbar contents
+tb_btn = Ttk::Button.new(tbar_base, :text=>'Button', :style=>'Toolbutton',
+ :command=>proc{text.insert(:end, "Button Pressed\n")})
+tb_chk = Ttk::Checkbutton.new(tbar_base, :text=>'Check', :style=>'Toolbutton',
+ :variable=>(check = TkVariable.new),
+ :command=>proc{
+ text.insert(:end, "Check is #{check.value}\n")
+ })
+tb_mbtn = Ttk::Menubutton.new(tbar_base, :text=>'Menu')
+tb_combo = Ttk::Combobox.new(tbar_base, :value=>TkFont.families,
+ :state=>:readonly)
+tb_mbtn.menu(menu = Tk::Menu.new(tb_mbtn))
+menu.add(:command, :label=>'Just', :command=>proc{text.insert(:end, "Just\n")})
+menu.add(:command, :label=>'An', :command=>proc{text.insert(:end, "An\n")})
+menu.add(:command, :label=>'Example',
+ :command=>proc{text.insert(:end, "Example\n")})
+tb_combo.bind('<ComboboxSelected>'){ text.font.family = tb_combo.get }
+
+## Arrange contents
+Tk.grid(tb_btn, tb_chk, tb_mbtn, tb_combo,
+ :in=>contents, :padx=>2, :sticky=>'ns')
+Tk.grid(tbar_base, :sticky=>'ew')
+Tk.grid(sep, :sticky=>'ew')
+Tk.grid(msg, :sticky=>'ew')
+Tk.grid(text, :sticky=>'nsew')
+base_frame.grid_rowconfigure(text, :weight=>1)
+base_frame.grid_columnconfigure(text, :weight=>1)
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'toolbar'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ Tk.grid(frame, :sticky=>'ew')
+}
diff --git a/ext/tk/sample/demos-en/tree.rb b/ext/tk/sample/demos-en/tree.rb
new file mode 100644
index 0000000000..0c7f0e71a2
--- /dev/null
+++ b/ext/tk/sample/demos-en/tree.rb
@@ -0,0 +1,119 @@
+# tree.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget.
+#
+# based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($tree_demo) && $tree_demo
+ $tree_demo.destroy
+ $tree_demo = nil
+end
+
+$tree_demo = TkToplevel.new {|w|
+ title("Directory Browser")
+ iconname("tree")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($tree_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttk is the new Tk themed widget set. \
+One of the widgets it includes is a tree widget, \
+which allows the user to browse a hierarchical data-set such as a filesystem. \
+The tree widget not only allows for the tree part itself, \
+but it also supports an arbitrary number of additional columns \
+which can show additional data (in this case, the size of the files \
+found in your filesystem). \
+You can also change the width of the columns \
+by dragging the boundary between them.
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'tree'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $tree_demo.destroy
+ $tree_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+## Code to populate the roots of the tree (can be more than one on Windows)
+def populate_roots(tree)
+ TkComm.simplelist(Tk.tk_call('file', 'volumes')).sort.each{|dir|
+ populate_tree(tree, tree.insert(nil, :end, :text=>dir,
+ :values=>[dir, 'directory']))
+ }
+end
+
+## Code to populate a node of the tree
+def populate_tree(tree, node)
+ return if tree.get(node, :type) != 'directory'
+
+ path = tree.get(node, :fullpath)
+ tree.delete(tree.children(node))
+ Dir.glob("#{path}/*").sort.each{|f|
+ type = File.ftype(f)
+ id = tree.insert(node, :end,
+ :text=>File.basename(f), :values=>[f, type]).id
+ if type == 'directory'
+ ## Make it so that this node is openable
+ tree.insert(id, 0, :text=>'dummy')
+ tree.itemconfigure(id, :text=>File.basename(f))
+ elsif type == 'file'
+ size = File.size(f)
+ if size >= 1024*1024*1024
+ size = '%.1f GB' % (size.to_f/1024/1024/1024)
+ elsif size >= 1024*1024
+ size = '%.1f MB' % (size.to_f/1024/1024)
+ elsif size >= 1024
+ size = '%.1f KB' % (size.to_f/1024)
+ else
+ size = '%.1f bytes' % (size.to_f/1024)
+ end
+ tree.set(id, :size, size)
+ end
+ }
+
+ # Stop this code from rerunning on the current node
+ tree.set(node, :type, 'processed_directory')
+end
+
+## Create the tree and set it up
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size),
+ :displaycolumns=>['size'])
+if Tk.windowingsystem != 'aqua'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+tree.heading_configure('#0', :text=>'Directory Structure')
+tree.heading_configure('size', :text=>'File Size')
+tree.column_configure('size', :stretch=>0, :width=>70)
+populate_roots(tree)
+tree.bind('<TreeviewOpen>', '%W'){|w| populate_tree(w, w.focus_item)}
+
+## Arrange the tree and its scrollbars in the toplevel
+container = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+container.lower
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
diff --git a/ext/tk/sample/demos-en/ttkbut.rb b/ext/tk/sample/demos-en/ttkbut.rb
new file mode 100644
index 0000000000..b5780f589a
--- /dev/null
+++ b/ext/tk/sample/demos-en/ttkbut.rb
@@ -0,0 +1,139 @@
+# ttkbut.rb
+#
+# This demonstration script creates a toplevel window containing several
+# simple Ttk widgets, such as labels, labelframes, buttons, checkbuttons and
+# radiobuttons.
+#
+# based on "Id: ttkbut.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkbut_demo) && $ttkbut_demo
+ $ttkbut_demo.destroy
+ $ttkbut_demo = nil
+end
+
+$ttkbut_demo = TkToplevel.new {|w|
+ title("Simple Ttk Widgets")
+ iconname("ttkbut")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkbut_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttk is the new Tk themed widget set. This is a Ttk themed label, \
+and below are three groups of Ttk widgets in Ttk labelframes. \
+The first group are all buttons that set the current application theme \
+when pressed. The second group contains three sets of checkbuttons, \
+with a separator widget between the sets. Note that the "Enabled" \
+button controls whether all the other themed widgets in this toplevel are \
+in the disabled state. The third group has a collection of linked \
+radiobuttons.
+EOL
+
+## Add buttons for setting the theme
+buttons = Ttk::Labelframe.new(base_frame, :text=>'Buttons')
+# Ttk::Style.theme_names.each{|theme|
+# Ttk::Button.new(buttons, :text=>theme,
+# :command=>proc{Ttk::Style.theme_use theme}).pack(:pady=>2)
+# }
+Ttk.themes.each{|theme|
+ Ttk::Button.new(buttons, :text=>theme,
+ :command=>proc{Ttk.set_theme theme}).pack(:pady=>2)
+}
+
+## Helper procedure for the top checkbutton
+def setState(root, value, *excepts)
+ return if excepts.member?(root)
+
+ ## Non-Ttk widgets (e.g. the toplevel) will fail, so make it silent
+ begin
+ root.state = value
+ rescue
+ end
+
+ ## Recursively invoke on all children of this root that are in the same
+ ## toplevel widget
+ root.winfo_children.each{|w|
+ setState(w, value, *excepts) if w.winfo_toplevel == root.winfo_toplevel
+ }
+end
+
+## Set up the checkbutton group
+checks = Ttk::Labelframe.new(base_frame, :text=>'Checkbuttons')
+enabled = TkVariable.new(true)
+e = Ttk::Checkbutton.new(checks, :text=>'Enabled', :variable=>enabled,
+ :command=>proc{
+ setState($ttkbut_demo,
+ ((enabled.bool)? "!disabled" : "disabled"),
+ e)
+ })
+
+## See ttk_widget(n) for other possible state flags
+sep1 = Ttk::Separator.new(checks)
+sep2 = Ttk::Separator.new(checks)
+
+cheese = TkVariable.new
+tomato = TkVariable.new
+basil = TkVariable.new
+oregano = TkVariable.new
+
+c1 = Ttk::Checkbutton.new(checks, :text=>'Cheese', :variable=>cheese)
+c2 = Ttk::Checkbutton.new(checks, :text=>'Tomato', :variable=>tomato)
+c3 = Ttk::Checkbutton.new(checks, :text=>'Basil', :variable=>basil)
+c4 = Ttk::Checkbutton.new(checks, :text=>'Oregano', :variable=>oregano)
+
+Tk.pack(e, sep1, c1, c2, sep2, c3, c4, :fill=>:x, :pady=>2)
+
+## Set up the radiobutton group
+radios = Ttk::Labelframe.new(base_frame, :text=>'Radiobuttons')
+
+happyness = TkVariable.new
+
+r1 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Great', :value=>'great')
+r2 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Good', :value=>'good')
+r3 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Ok', :value=>'ok')
+r4 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Poor', :value=>'poor')
+r5 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Awful', :value=>'awful')
+
+Tk.pack(r1, r2, r3, r4, r5, :fill=>:x, :padx=>3, :pady=>2)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame, ['enabled', enabled],
+ ['cheese', cheese], ['tomato', tomato],
+ ['basil', basil], ['oregano', oregano],
+ ['happyness', happyness])
+ }),
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkbut'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $ttkbut_demo
+ $ttkbut_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x, :expand=>true)
+}
+
+## Arrange things neatly
+f = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+Tk.grid(buttons, checks, radios, :in=>f, :sticky=>'nwe', :pady=>2, :padx=>3)
+f.grid_columnconfigure([0, 1, 2], :weight=>1, :uniform=>:yes)
diff --git a/ext/tk/sample/demos-en/ttkmenu.rb b/ext/tk/sample/demos-en/ttkmenu.rb
new file mode 100644
index 0000000000..75ecdb09c4
--- /dev/null
+++ b/ext/tk/sample/demos-en/ttkmenu.rb
@@ -0,0 +1,85 @@
+# ttkmenu.rb --
+#
+# This demonstration script creates a toplevel window containing several Ttk
+# menubutton widgets.
+#
+# based on "Id: ttkmenu.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkmenu_demo) && $ttkmenu_demo
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+end
+
+$ttkmenu_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("ttkmenu")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($ttkmenu_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttk is the new Tk themed widget set, \
+and one widget that is available in themed form is the menubutton. \
+Below are some themed menu buttons \
+that allow you to pick the current theme in use. \
+Notice how picking a theme changes the way \
+that the menu buttons themselves look, \
+and that the central menu button is styled differently \
+(in a way that is normally suitable for toolbars). \
+However, there are no themed menus; the standard Tk menus were judged \
+to have a sufficiently good look-and-feel on all platforms, \
+especially as they are implemented as native controls in many places.
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new($ttkmenu_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkmenu'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+b1 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:above)
+b2 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:left)
+b3 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:right)
+b4 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:flush,
+ :style=>Ttk::Menubutton.style('Toolbutton'))
+b5 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:below)
+
+b1.menu(m1 = Tk::Menu.new(b1, :tearoff=>false))
+b2.menu(m2 = Tk::Menu.new(b2, :tearoff=>false))
+b3.menu(m3 = Tk::Menu.new(b3, :tearoff=>false))
+b4.menu(m4 = Tk::Menu.new(b4, :tearoff=>false))
+b5.menu(m5 = Tk::Menu.new(b5, :tearoff=>false))
+
+Ttk.themes.each{|theme|
+ m1.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m2.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m3.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m4.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m5.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+}
+
+f = Ttk::Frame.new(base_frame).pack(:fill=>:x)
+f1 = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+
+f.grid_anchor(:center)
+TkGrid('x', b1, 'x', :in=>f, :padx=>3, :pady=>2)
+TkGrid(b2, b4, b3, :in=>f, :padx=>3, :pady=>2)
+TkGrid('x', b5, 'x', :in=>f, :padx=>3, :pady=>2)
diff --git a/ext/tk/sample/demos-en/ttknote.rb b/ext/tk/sample/demos-en/ttknote.rb
new file mode 100644
index 0000000000..c2a22b447a
--- /dev/null
+++ b/ext/tk/sample/demos-en/ttknote.rb
@@ -0,0 +1,89 @@
+# ttknote.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# notebook widget.
+#
+# based on "Id: ttknote.tcl,v 1.5 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttknote_demo) && $ttknote_demo
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+end
+
+$ttknote_demo = TkToplevel.new {|w|
+ title("Ttk Notebook Widget")
+ iconname("ttknote")
+ positionWindow(w)
+}
+
+## See Code / Dismiss
+Ttk::Frame.new($ttknote_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttknote'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+base_frame = Ttk::Frame.new($ttknote_demo).pack(:fill=>:both, :expand=>true)
+
+## Make the notebook and set up Ctrl+Tab traversal
+notebook = Ttk::Notebook.new(base_frame).pack(:fill=>:both, :expand=>true,
+ :padx=>2, :pady=>3)
+notebook.enable_traversal
+
+## Popuplate the first pane
+f_msg = Ttk::Frame.new(notebook)
+msg_m = Ttk::Label.new(f_msg, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :text=><<EOL)
+Ttk is the new Tk themed widget set. \
+One of the widgets it includes is the notebook widget, \
+which provides a set of tabs that allow the selection of a group of panels, \
+each with distinct content. \
+They are a feature of many modern user interfaces. \
+Not only can the tabs be selected with the mouse, \
+but they can also be switched between using Ctrl+Tab \
+when the notebook page heading itself is selected. \
+Note that the second tab is disabled, and cannot be selected.
+EOL
+neat = TkVariable.new
+after_id = nil
+msg_b = Ttk::Button.new(f_msg, :text=>'Neat!', :underline=>0,
+ :command=>proc{
+ neat.value = 'Yeah, I know...'
+ Tk.after_cancel(after_id) if after_id
+ after_id = Tk.after(500){neat.value = ''}
+ })
+msg_b.winfo_toplevel.bind('Alt-n'){ msg_b.focus; msg_b.invoke }
+msg_l = Ttk::Label.new(f_msg, :textvariable=>neat)
+notebook.add(f_msg, :text=>'Description', :underline=>0, :padding=>2)
+Tk.grid(msg_m, '-', :sticky=>'new', :pady=>2)
+Tk.grid(msg_b, msg_l, :pady=>[2, 4])
+f_msg.grid_rowconfigure(1, :weight=>1)
+f_msg.grid_columnconfigure([0, 1], :weight=>1, :uniform=>1)
+
+## Populate the second pane. Note that the content doesn't really matter
+f_disabled = Ttk::Frame.new(notebook)
+notebook.add(f_disabled, :text=>'Disabled', :state=>:disabled)
+
+## Popuplate the third pane
+f_editor = Ttk::Frame.new(notebook)
+notebook.add(f_editor, :text=>'Text Editor', :underline=>0)
+editor_t = Tk::Text.new(f_editor, :width=>40, :height=>10, :wrap=>:char)
+if Tk.windowingsystem != 'aqua'
+ editor_s = editor_t.yscrollbar(Ttk::Scrollbar.new(f_editor))
+else
+ editor_s = editor_t.yscrollbar(Tk::Scrollbar.new(f_editor))
+end
+editor_s.pack(:side=>:right, :fill=>:y, :padx=>[0,2], :pady=>2)
+editor_t.pack(:fill=>:both, :expand=>true, :padx=>[2,0], :pady=>2)
diff --git a/ext/tk/sample/demos-en/ttkpane.rb b/ext/tk/sample/demos-en/ttkpane.rb
new file mode 100644
index 0000000000..56df613db4
--- /dev/null
+++ b/ext/tk/sample/demos-en/ttkpane.rb
@@ -0,0 +1,213 @@
+# ttkpane.rb --
+#
+# This demonstration script creates a Ttk pane with some content.
+#
+# based on "Id: ttkpane.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkpane_demo) && $ttkpane_demo
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+end
+
+$ttkpane_demo = TkToplevel.new {|w|
+ title("Themed Nested Panes")
+ iconname("ttkpane")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkpane_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+This demonstration shows off a nested set of themed paned windows. \
+Their sizes can be changed by grabbing the area \
+between each contained pane and dragging the divider.
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkpane'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+outer = Ttk::Panedwindow.new(frame, :orient=>:horizontal)
+outer.add(in_left = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+outer.add(in_right = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+in_left.add(left_top = Ttk::Labelframe.new(in_left, :text=>'Button'))
+in_left.add(left_bot = Ttk::Labelframe.new(in_left, :text=>'Clocks'))
+in_right.add(right_top = Ttk::Labelframe.new(in_right, :text=>'Progress'))
+in_right.add(right_bot = Ttk::Labelframe.new(in_right, :text=>'Text'))
+if Tk.windowingsystem == 'aqua'
+ [left_top, left_bot, right_top, right_bot].each{|w| w.padding(3) }
+end
+
+# Fill the button pane
+Ttk::Button.new(left_top, :text=>'Press Me',
+ :command=>proc{
+ Tk.messageBox(:type=>'ok', :icon=>'info', :message=>'Ouch!',
+ :detail=>'That hurt...', :parent=>base_frame,
+ :title=>'Button Pressed')
+ }).pack(:padx=>2, :pady=>5)
+
+
+zones_list = [
+ [':Europe/Berlin'],
+ [':America/Argentina/Buenos_Aires', ':America/Buenos_Aires'],
+ [':Africa/Johannesburg'],
+ [':Europe/London'],
+ [':America/Los_Angeles'],
+ [':Europe/Moscow'],
+ [':America/New_York'],
+ [':Asia/Singapore'],
+ [':Australia/Sydney'],
+ [':Asia/Tokyo'],
+]
+
+zones = []
+
+# Check tzinfo support
+if $tk_major_ver > 8 || ($tk_major_ver == 8 && $tk_minor_ver >= 5)
+ tzinfo = :tcl
+
+ # Force a pre-load of all the timezones needed; otherwise can end up
+ # poor-looking synch problems!
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ Tk.tk_call('clock', 'format', '0', '-timezone', zone)
+ rescue RuntimeError
+ # ignore
+ else
+ zones << [zone, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+else
+ begin
+ require 'tzinfo'
+ tzinfo = :tzinfo
+ rescue Exception
+ begin
+ require 'tzfile'
+ tzinfo = :tzfile
+ rescue Exception
+ tzinfo = nil
+ end
+ end
+
+ case tzinfo
+ when :tzinfo
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZInfo::Timezone.get(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ when :tzfile
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZFile.create(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ else
+ [ -7, -4, -2, -1, 0, +1, +3, +8, +9, +10 ].each{|zone|
+ zones << [zone, 'UTC%+03d00' % zone]
+ }
+ end
+end
+
+time = TkVariable.new_hash
+
+case tzinfo
+when :tcl
+ update_proc = proc{|now, tz, label|
+ time[label] = Tk.tk_call('clock', 'format', now.tv_sec,
+ '-timezone', tz, '-format', '%T')
+ }
+when :tzinfo
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.utc_to_local(now).strftime('%H:%M:%S')
+ }
+when :tzfile
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.at(now.tv_sec).strftime('%H:%M:%S')
+ }
+else
+ update_proc = proc{|now, tz, label|
+ time[label] = (now + (tz * 3600)).strftime('%H:%M:%S')
+ }
+end
+
+# Fill the clocks pane
+zones.each_with_index{|(zone, label), idx|
+ Ttk::Separator.new(left_bot).pack(:fill=>:x) if idx > 0
+ Ttk::Label.new(left_bot, :text=>label, :anchor=>'w').pack(:fill=>:x)
+ Ttk::Label.new(left_bot, :textvariable=>time.ref(label),
+ :anchor=>'w').pack(:fill=>:x)
+}
+
+# Timer start
+every = proc{
+ now = Time.now.utc
+ zones.each{|zone, label| update_proc.call(now, zone, label) }
+}
+TkRTTimer.new(1000, -1, every).start(0, every)
+
+# Fill the progress pane
+Ttk::Progressbar.new(right_top, :mode=>:indeterminate).pack(:fill=>:both, :expand=>true).start
+
+# Fill the text pane
+if Tk.windowingsystem != 'aqua'
+ # The trick with the ttk::frame makes the text widget look like it fits with
+ # the current Ttk theme despite not being a themed widget itself. It is done
+ # by styling the frame like an entry, turning off the border in the text
+ # widget, and putting the text widget in the frame with enough space to allow
+ # the surrounding border to show through (2 pixels seems to be enough).
+ f = Ttk::Frame.new(right_bot, :style=>Ttk::Entry)
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ txt.pack(:fill=>:both, :expand=>true, :in=>f, :pady=>2, :padx=>2)
+ scr = txt.yscrollbar(Ttk::Scrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ f.pack(:fill=>:both, :expand=>true)
+ outer.pack(:fill=>:both, :expand=>true)
+else
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ scr = txt.yscrollbar(TkScrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ txt.pack(:fill=>:both, :expand=>true, :in=>right_bot)
+ outer.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>[6, 10])
+end
diff --git a/ext/tk/sample/demos-en/ttkprogress.rb b/ext/tk/sample/demos-en/ttkprogress.rb
new file mode 100644
index 0000000000..3eb9a64a4a
--- /dev/null
+++ b/ext/tk/sample/demos-en/ttkprogress.rb
@@ -0,0 +1,66 @@
+# ttkprogress.rb --
+#
+# This demonstration script creates several progress bar widgets.
+#
+# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkprogress_demo) && $ttkprogress_demo
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+end
+
+$ttkprogress_demo = TkToplevel.new {|w|
+ title("Progress Bar Demonstration")
+ iconname("ttkprogress")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkprogress_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=>Tk::UTF8_String.new(<<EOL)).pack(:side=>:top, :fill=>:x)
+Below are two progress bars. \
+The top one is a \\u201Cdeterminate\\u201D progress bar, \
+which is used for showing how far through a defined task the program has got. \
+The bottom one is an \\u201Cindeterminate\\u201D progress bar, \
+which is used to show that the program is busy \
+but does not know how long for. Both are run here in self-animated mode, \
+which can be turned on and off using the buttons underneath.
+EOL
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkprogress'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+p1 = Ttk::Progressbar.new(frame, :mode=>:determinate)
+p2 = Ttk::Progressbar.new(frame, :mode=>:indeterminate)
+
+start = Ttk::Button.new(frame, :text=>'Start Progress',
+ :command=>proc{ p1.start; p2.start })
+stop = Ttk::Button.new(frame, :text=>'Stop Progress',
+ :command=>proc{ p1.stop; p2.stop })
+
+Tk.grid(p1, '-', :pady=>5, :padx=>10)
+Tk.grid(p2, '-', :pady=>5, :padx=>10)
+Tk.grid(start, stop, :padx=>10, :pady=>5)
+start.grid_configure(:sticky=>'e')
+stop.grid_configure(:sticky=>'w')
+frame.grid_columnconfigure(:all, :weight=>1)
+
diff --git a/ext/tk/sample/demos-en/twind.rb b/ext/tk/sample/demos-en/twind.rb
index 24a4bcf706..65ee712ff7 100644
--- a/ext/tk/sample/demos-en/twind.rb
+++ b/ext/tk/sample/demos-en/twind.rb
@@ -19,8 +19,10 @@ $twind_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($twind_demo).pack(:fill=>:both, :expand=>true)
+
# frame
-$twind_buttons = TkFrame.new($twind_demo) {|frame|
+$twind_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
@@ -39,13 +41,13 @@ $twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
$twind_text = nil
-TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
'relief'=>'sunken') {|f|
$twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font,
'width'=>'70', 'height'=>35, 'wrap'=>'word',
'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
TkScrollbar.new(f) {|s|
- command proc{|*args| t.yview(args)}
+ command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
}.pack('side'=>'right', 'fill'=>'y')
}.pack('expand'=>'yes', 'fill'=>'both')
@@ -206,7 +208,11 @@ def textWindPlot (t)
cursor 'top_left_arrow'
}
- font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ if $tk_version =~ /^4.*/
+ font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ else
+ font = 'Helvetica 18'
+ end
TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2)
diff --git a/ext/tk/sample/demos-en/twind2.rb b/ext/tk/sample/demos-en/twind2.rb
index c42e0999d7..43990c1151 100644
--- a/ext/tk/sample/demos-en/twind2.rb
+++ b/ext/tk/sample/demos-en/twind2.rb
@@ -15,8 +15,10 @@ $twind2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($twind2_demo).pack(:fill=>:both, :expand=>true)
+
# frame
-$twind2_buttons = TkFrame.new($twind2_demo) {|frame|
+$twind2_buttons = TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
@@ -38,7 +40,7 @@ $twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
$twind2_text = nil
-TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
'relief'=>'sunken') {|f|
$twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
# 'width'=>'70', 'height'=>35, 'wrap'=>'word',
diff --git a/ext/tk/sample/demos-en/unicodeout.rb b/ext/tk/sample/demos-en/unicodeout.rb
index 07e3bf52b5..9c230a2536 100644
--- a/ext/tk/sample/demos-en/unicodeout.rb
+++ b/ext/tk/sample/demos-en/unicodeout.rb
@@ -16,7 +16,9 @@ $unicodeout_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($unicodeout_demo,
+base_frame = TkFrame.new($unicodeout_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5.4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
This is a sample of Tk's support for languages that use non-Western \
@@ -36,7 +38,7 @@ The strings are converted to the encoded string objects \
And the Tk::UTF8_String objects are passed to the label widgets.
EOL
-TkFrame.new($unicodeout_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
@@ -49,7 +51,7 @@ TkFrame.new($unicodeout_demo){|f|
}).pack(:side=>:left, :expand=>true)
}
-wait_msg = TkLabel.new($unicodeout_demo,
+wait_msg = TkLabel.new(base_frame,
:text=>"Please wait while loading fonts...",
:font=>"Helvetica 12 italic").pack
@@ -63,8 +65,8 @@ class Unicodeout_SampleFrame < TkFrame
# @@font = 'Newspaper 12'
# @@font = '{New century schoolbook} 12'
- def initialize()
- super($unicodeout_demo)
+ def initialize(base)
+ super(base)
grid_columnconfig(1, :weight=>1)
end
@@ -79,7 +81,7 @@ class Unicodeout_SampleFrame < TkFrame
l.grid_config(:padx, '1m')
end
end
-f = Unicodeout_SampleFrame.new
+f = Unicodeout_SampleFrame.new(base_frame)
f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
# Processing when some characters are missing might take a while, so make
diff --git a/ext/tk/sample/demos-en/vscale.rb b/ext/tk/sample/demos-en/vscale.rb
index 636b85813b..b05ed12072 100644
--- a/ext/tk/sample/demos-en/vscale.rb
+++ b/ext/tk/sample/demos-en/vscale.rb
@@ -15,7 +15,9 @@ $vscale_demo = TkToplevel.new {|w|
}
positionWindow($vscale_demo)
-msg = TkLabel.new($vscale_demo) {
+base_frame = TkFrame.new($vscale_demo).pack(:fill=>:both, :expand=>true)
+
+msg = TkLabel.new(base_frame) {
font $font
wraplength '3.5i'
justify 'left'
@@ -23,7 +25,7 @@ msg = TkLabel.new($vscale_demo) {
}
msg.pack('side'=>'top', 'padx'=>'.5c')
-TkFrame.new($vscale_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc {
@@ -39,7 +41,17 @@ TkFrame.new($vscale_demo) {|frame|
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
-TkFrame.new($vscale_demo) {|frame|
+def setHeight(w, height)
+ height = height + 21
+ y2 = height - 30
+ if y2 < 21
+ y2 = 21
+ end
+ w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+ w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+end
+
+TkFrame.new(base_frame) {|frame|
borderwidth 10
canvas = TkCanvas.new(frame) {|c|
width 50
@@ -65,14 +77,3 @@ TkFrame.new($vscale_demo) {|frame|
}.pack('side'=>'left', 'anchor'=>'ne')
scale.set 75
}.pack
-
-
-def setHeight(w, height)
- height = height + 21
- y2 = height - 30
- if y2 < 21
- y2 = 21
- end
- w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
- w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
-end
diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget
index 3c50582211..9a0605d8b9 100644
--- a/ext/tk/sample/demos-en/widget
+++ b/ext/tk/sample/demos-en/widget
@@ -14,6 +14,8 @@ require 'tk'
### $DEBUG=1 ##########
+$RubyTk_WidgetDemo = true
+
#----------------------------------------------------------------
# The code below create the main window, consisting of a menu bar
# and a text widget that explains how to use the program, plus lists
@@ -21,7 +23,8 @@ require 'tk'
#----------------------------------------------------------------
# widget demo directory
-$demo_dir = File.dirname($0)
+# $demo_dir = File.dirname($0)
+$demo_dir = File.dirname(__FILE__)
# root
$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
@@ -102,14 +105,22 @@ EOD
end
#
-TkMenubar.new($root,
- [[['File', 0],
- ['About ... ', proc{aboutBox}, 0, '<F1>'],
- '---',
- ['Quit', proc{exit}, 0, 'Meta-Q']
- ]]).pack('side'=>'top', 'fill'=>'x')
+if $tk_major_ver >= 8
+ $root.add_menubar([[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]])
+else
+ TkMenubar.new($root,
+ [[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]]).pack('side'=>'top', 'fill'=>'x')
+end
$root.bind('F1', proc{aboutBox})
-$root.bind('Meta-q', proc{exit})
+$root.bind('Control-q', proc{exit})
=begin
TkFrame.new($root){|frame|
@@ -164,12 +175,17 @@ else
textFrame.pack('expand'=>'yes', 'fill'=>'both')
statusBar = TkFrame.new($root) {|f|
+ if $tk_version =~ /^4.*/
+ statusfont = '-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ else
+ statusfont = 'Helvetica 10'
+ end
$statusBarLabel = \
TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ 'font'=>statusfont) \
.pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ 'font'=>statusfont) \
.pack('side'=>'left', 'padx'=>2)
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
end
@@ -178,7 +194,11 @@ end
# section titles and demo descriptions. Also define the bindings for
# tags.
-tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+if $tk_version =~ /^4.*/
+ tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+else
+ tag_title = TkTextTag.new(txt, 'font'=>'Helvetica 18 bold')
+end
# We put some "space" characters to the left and right of each demo description
# so that the descriptions are highlighted only when the mouse cursor
@@ -247,7 +267,10 @@ the demonstration. Once the demonstration window appears, you can \
click the "See Code" button to see the Ruby/Tk code that created the \
demonstration. If you wish, you can edit the code and click the \
"Rerun Demo" button in the code window to reinvoke the demonstration \
-with the modified code.
+with the modified code. \
+Don't worry about breaking the source code. \
+Your modifications are not reflected on the original file. \
+Please try many kind of changes.
Some demo scripts require the recent version of Tk library \
(e.g. Tk8.4 or later) \
@@ -256,6 +279,20 @@ required by the demo script, the demo doesn't work. \
In such a case, please re-compile tcltklib with the later Tk library \
which supports the required functions.
+If your Tk supports Ttk (Tile) extension (included or installed), \
+please try the demo of Ttk extension (sample/tkextlib/tile/demo.rb) too.
+( Probably, Ttk extension \
+#{
+begin
+ require 'tkextlib/tile'
+ "is already installed on your environment"
+rescue
+ "is not installed on your environment yet"
+end
+}\
+. )
+Ttk extension is a standard feature of Tk8.5 or later.
+
EOT
@@ -289,6 +326,8 @@ txt.insert('end', "13. A simple user interface for viewing images. (if supported
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "14. Labelled frames (if supported)\n", tag_demo, "demo-labelframe")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "15. The simple Themed Tk widgets (require Tile/Ttk extension)\n", tag_demo, "demo-ttkbut")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Listboxes\n", tag_title)
@@ -299,6 +338,10 @@ txt.insert('end', "2. Colors: change the color scheme for the application.\n", "
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "3. A collection of famous sayings.\n", tag_demo, "demo-sayings")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. A multi-column list of contries. (require Tile/Ttk extension)\n", tag_demo, "demo-mclist")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. A directory browser tree. (require Tile/Ttk extension)\n", tag_demo, "demo-tree")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Entries and Spin-boxes\n", tag_title)
@@ -313,7 +356,9 @@ txt.insert('end',
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "4. Spin-boxes. (if supported)\n", tag_demo, "demo-spin")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "5. Simple Rolodex-like form.\n", tag_demo, "demo-form")
+txt.insert('end', "5. Combo-boxes. (require Tile/Ttk extension)\n", tag_demo, "demo-combo")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. Simple Rolodex-like form.\n", tag_demo, "demo-form")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@@ -331,6 +376,8 @@ txt.insert('end', "5. A text widget with embedded windows. (if supported)\n", ta
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "6. A search tool built with a text widget.\n", tag_demo, "demo-search")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. Peering text widgets. (if supported)\n", tag_demo, "demo-textpeer")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
txt.insert('end', "Canvases\n", tag_title)
@@ -351,31 +398,43 @@ txt.insert('end', "7. A building floor plan. (another way to create canvas items
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "8. A simple scrollable canvas.\n", tag_demo, "demo-cscroll")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. A Knight's tour of the chess board. (require Tile/Ttk extension)\n", tag_demo, "demo-knightstour")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
-txt.insert('end', "Scales\n", tag_title)
+txt.insert('end', "Scales and Progress Bars\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. Vertical scale.\n", tag_demo.id, "demo-vscale")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. Horizontal scale.\n", tag_demo.id, "demo-hscale")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Progress bar. (require Tile/Ttk extension)\n", tag_demo.id, "demo-ttkprogress")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
-txt.insert('end', "Paned Windows\n", tag_title)
+txt.insert('end', "Paned Windows and Notebooks\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. Horizontal paned window. (if supported)\n", tag_demo.id, "demo-paned1")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. Vertical paned window. (if supported)\n", tag_demo.id, "demo-paned2")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Themed nested panes. (require Tile/Ttk extension)\n", tag_demo.id, "demo-ttkpane")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Notebook widget. (require Tile/Ttk extension)\n", tag_demo.id, "demo-ttknote")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
-txt.insert('end', "Menus\n", tag_title)
+txt.insert('end', "Menus and Toolbars\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. Menus and cascades.\n", tag_demo, "demo-menu")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. Menus and cascades. (if supported)\n", tag_demo, "demo-menu84")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "3. Menubuttons\n", tag_demo, "demo-menubu")
+txt.insert('end', "3. Menubuttons.\n", tag_demo, "demo-menubu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Themed menu buttons. (require Tile/Ttk extension)\n", tag_demo, "demo-ttkmenu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. Themed toolbar. (require Tile/Ttk extension)\n", tag_demo, "demo-toolbar")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@@ -383,9 +442,11 @@ txt.insert('end', "Common Dialogs\n", tag_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. Message boxes.\n", tag_demo, "demo-msgbox")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "2. File selection dialog.\n", tag_demo, "demo-filebox")
+txt.insert('end', "2. Message boxes with detail text. (if supported)\n", tag_demo, "demo-msgbox2")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "3. Color picker.\n", tag_demo, "demo-clrpick")
+txt.insert('end', "3. File selection dialog.\n", tag_demo, "demo-filebox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Color picker.\n", tag_demo, "demo-clrpick")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@@ -441,11 +502,16 @@ def showVars1(parent, *args)
end
w = TkToplevel.new(parent) {|w|
title "Variable values"
- TkLabel.new(w) {
+ base = TkFrame.new(w).pack(:fill=>:both, :expand=>true)
+ TkLabel.new(base) {
text "Variable values:"
width 20
anchor 'center'
- font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ if $tk_version =~ /^4.*/
+ font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ else
+ font 'Helvetica 14'
+ end
}.pack('side'=>'top', 'fill'=>'x')
len = 1
args.each{|vnam,vbody|
@@ -459,7 +525,7 @@ def showVars1(parent, *args)
.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
}.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x')
}
- TkButton.new(w) {
+ TkButton.new(base) {
text "OK"
command proc{w.destroy}
}.pack('side'=>'bottom', 'pady'=>2)
@@ -474,10 +540,12 @@ def showVars2(parent, *args)
rescue
end
end
- $showVarsWin[parent.path] = TkToplevel.new(parent) {|w|
+ $showVarsWin[parent.path] = TkToplevel.new(parent) {|top|
title "Variable values"
- TkLabelFrame.new(w, :text=>"Variable values:",
+ base = TkFrame.new(top).pack(:fill=>:both, :expand=>true)
+
+ TkLabelFrame.new(base, :text=>"Variable values:",
:font=>{:family=>'Helvetica', :size=>14}){|f|
args.each{|vnam,vbody|
TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'),
@@ -489,15 +557,15 @@ def showVars2(parent, *args)
f.grid_columnconfig(1, :weight=>1)
f.grid_rowconfig(100, :weight=>1)
}
- TkButton.new(w, :text=>"OK", :width=>8, :default=>:active,
- :command=>proc{w.destroy}){|b|
- w.bind('Return', proc{b.invoke})
- w.bind('Escape', proc{b.invoke})
+ TkButton.new(base, :text=>"OK", :width=>8, :default=>:active,
+ :command=>proc{top.destroy}){|b|
+ top.bind('Return', proc{b.invoke})
+ top.bind('Escape', proc{b.invoke})
b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4])
}
- w.grid_columnconfig(0, :weight=>1)
- w.grid_rowconfig(0, :weight=>1)
+ base.grid_columnconfig(0, :weight=>1)
+ base.grid_rowconfig(0, :weight=>1)
}
end
@@ -591,8 +659,27 @@ def _null_binding
end
private :_null_binding
-def eval_samplecode(code)
- Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }.run
+def eval_samplecode(code, file=nil)
+ #eval(code)
+ #_null_binding.pseudo_toplevel_eval{ eval(code) }
+ #Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }
+ Thread.new{
+ _null_binding.pseudo_toplevel_eval{
+ begin
+ if file
+ eval(code, binding, "(eval:#{file})")
+ else
+ eval(code)
+ end
+ rescue Exception=>e
+ #p e
+ TkBgError.show(e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------")
+ end
+ }
+ }
Tk.update
end
@@ -612,7 +699,7 @@ def invoke(txt, idx)
Tk.update
# eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding)
# Tk.update
- eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join)
+ eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb')
txt.cursor(cursor)
$tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
@@ -669,20 +756,32 @@ def showCode1(demo)
if $code_window == nil || TkWinfo.exist?($code_window) == false
$code_window = TkToplevel.new(nil)
f = TkFrame.new($code_window)
+
TkButton.new(f) {
text "Dismiss"
command proc{
$code_window.destroy
$code_window = nil
}
- }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2, 'padx'=>25)
TkButton.new(f) {
text "Rerun Demo"
# command proc{eval($code_text.get('1.0','end'), _null_binding)}
- command proc{eval_samplecode($code_text.get('1.0','end'))}
- }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
-# f.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x')
- f.pack('side'=>'bottom', 'fill'=>'x')
+ command proc{eval_samplecode($code_text.get('1.0','end'), '<viewer>')}
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2)
+
+ TkLabel.new(f,'text'=>'line:').pack('side'=>'left')
+ linenum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+ TkLabel.new(f,'text'=>' pos:').pack('side'=>'left')
+ posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
+ f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x')
if $tk_version =~ /^4\.[01]/
s = TkScrollbar.new($code_window, 'orient'=>'vertical')
@@ -727,10 +826,21 @@ def showCode1(demo)
TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
}
end
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
else
$code_window.deiconify
$code_window.raise
end
+
$code_window.title("Demo code: #{file}")
$code_window.iconname(file)
# fid = open(file, 'r')
@@ -741,6 +851,9 @@ def showCode1(demo)
#$code_mark = TkTextMark.new($code_text, '1.0')
#$code_text.set_insert('1.0')
TkTextMarkInsert.new($code_text,'1.0')
+
+ $set_linenum.call($code_text)
+
fid.close
end
@@ -761,7 +874,19 @@ def showCode2(demo)
tf.grid_columnconfigure(0, :weight=>1)
bf = TkFrame.new($code_window)
-
+
+ lf = TkFrame.new(bf)
+ TkLabel.new(lf, :text=>'line:').pack(:side=>:left)
+ linenum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+ TkLabel.new(lf, :text=>' pos:').pack(:side=>:left)
+ posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
b_dis = TkButton.new(bf, :text=>'Dismiss', :default=>:active,
:command=>proc{
$code_window.destroy
@@ -774,12 +899,12 @@ def showCode2(demo)
b_run = TkButton.new(bf, :text=>'Rerun Demo',
:command=>proc{
# eval($code_text.get('1.0','end'), _null_binding)
- eval_samplecode($code_text.get('1.0','end'))
+ eval_samplecode($code_text.get('1.0','end'), '<viewer>')
},
:image=>$image['refresh'], :compound=>:left)
- TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
- bf.grid_columnconfigure(0, :weight=>1)
+ TkGrid(lf, 'x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
+ bf.grid_columnconfigure(1, :weight=>1)
TkGrid(tf, :sticky=>'news')
TkGrid(bf, :sticky=>'ew')
@@ -792,6 +917,17 @@ def showCode2(demo)
$code_window.bindinfo('Return').each{|cmd, arg|
$code_window.bind_append('Escape', cmd, arg)
}
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+ btag.bind('Configure', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
else
$code_window.deiconify
$code_window.raise
@@ -803,6 +939,9 @@ def showCode2(demo)
$code_text.delete('1.0', 'end')
$code_text.insert('1.0', fid.read)
TkTextMarkInsert.new($code_text,'1.0')
+
+ $set_linenum.call($code_text)
+
fid.close
end
@@ -896,12 +1035,13 @@ end
#
def aboutBox
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
- 'message'=>"Ruby/Tk widget demonstration Ver.1.6.0-en\n\n" +
+ 'message'=>"Ruby/Tk widget demonstration Ver.1.7.0-en\n\n" +
"based on demos of Tk8.1 -- 8.5 " +
- "( Copyright:: " +
+ "( Copyright of Tcl/Tk demos:: " +
"(c) 1996-1997 Sun Microsystems, Inc. / " +
"(c) 1997-2000 Ajuba Solutions, Inc. / " +
- "(c) 2001-2003 Donal K. Fellows )\n\n" +
+ "(c) 2001-2007 Donal K. Fellows / " +
+ "(c) 2002-2007 Daniel A. Steffen )\n\n" +
"Your Ruby & Tk Version ::\n" +
"Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}\n\n" +
"Ruby/Tk release date :: tcltklib #{TclTkLib::RELEASE_DATE}; tk #{Tk::RELEASE_DATE}")
@@ -923,7 +1063,7 @@ ARGV.each{|cmd|
end
#eval(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join,
# _null_binding)
- eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join)
+ eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join, cmd + '.rb')
}
if no_launcher
$root.withdraw # hide root window
diff --git a/ext/tk/sample/demos-jp/anilabel.rb b/ext/tk/sample/demos-jp/anilabel.rb
index c6e5c7385b..aee57f9f6a 100644
--- a/ext/tk/sample/demos-jp/anilabel.rb
+++ b/ext/tk/sample/demos-jp/anilabel.rb
@@ -17,8 +17,10 @@ $anilabel_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($anilabel_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($anilabel_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -27,7 +29,7 @@ msg = TkLabel.new($anilabel_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($anilabel_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -46,8 +48,8 @@ TkFrame.new($anilabel_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# label demo Íѥե졼¥àÀ¸À®
-f_left = TkLabelFrame.new($anilabel_demo, :text=>'Scrolling Texts')
-f_right = TkLabelFrame.new($anilabel_demo, :text=>'GIF Image')
+f_left = TkLabelFrame.new(base_frame, :text=>'Scrolling Texts')
+f_right = TkLabelFrame.new(base_frame, :text=>'GIF Image')
Tk.pack(f_left, f_right, 'side'=>'left', 'expand'=>'yes', 'fill'=>'both',
'padx'=>10, 'pady'=>10)
diff --git a/ext/tk/sample/demos-jp/aniwave.rb b/ext/tk/sample/demos-jp/aniwave.rb
index 5f94add111..8fa14f65fe 100644
--- a/ext/tk/sample/demos-jp/aniwave.rb
+++ b/ext/tk/sample/demos-jp/aniwave.rb
@@ -17,8 +17,10 @@ $aniwave_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($aniwave_demo).pack(:fill=>:both, :expand=>true)
+
# create label
-msg = TkLabel.new($aniwave_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -27,7 +29,7 @@ msg = TkLabel.new($aniwave_demo) {
msg.pack('side'=>'top')
# create frame
-TkFrame.new($aniwave_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -60,6 +62,7 @@ class AnimatedWaveDemo
@backupCoords = []
n = 0
(-10..300).step(5){|n| @waveCoords << [n, 100]; @backupCoords << [n, 100] }
+ n = 305
@waveCoords << [n, 0]; @backupCoords << [n, 0]
@waveCoords << [n+5, 200]; @backupCoords << [n+5, 200]
@coordsLen = @waveCoords.length
@@ -114,4 +117,4 @@ class AnimatedWaveDemo
end
# Start the animation processing
-AnimatedWaveDemo.new($aniwave_demo, :left).move
+AnimatedWaveDemo.new(base_frame, :left).move
diff --git a/ext/tk/sample/demos-jp/arrow.rb b/ext/tk/sample/demos-jp/arrow.rb
index 43c6eef4eb..3c49e67b09 100644
--- a/ext/tk/sample/demos-jp/arrow.rb
+++ b/ext/tk/sample/demos-jp/arrow.rb
@@ -74,11 +74,19 @@ def arrowSetup(c)
'arrow'=>'both', 'arrowshape'=>v.smallTips)
TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
- TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
- TkcText.new(c, v.x1, 330,
- 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ if $tk_version =~ /^4.*/
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ else
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'Helvetica 18')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",
+ 'anchor'=>'w', 'font'=>'Helvetica 18')
+ end
v.count += 1
end
@@ -96,14 +104,16 @@ $arrow_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($arrow_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
'text'=>"¤³¤Î widget ¤Ç¡¢¥­¥ã¥ó¥Ð¥¹¤Ç»È¤ï¤ì¤ë¥é¥¤¥ó¤Ë¤Ä¤¤¤ÆÍÍ¡¹¤ÊÉý¤äÌð°õ¤ÎƬ¤Î·Á¤ò»î¤·¤Æ¤ß¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£Àþ¤ÎÉý¤äÌð°õ¤Î·Á¤òÊѤ¨¤ë¤Ë¤Ï¡¢³ÈÂ礵¤ì¤¿Ìð°õ¤Ë¤Ä¤¤¤Æ¤¤¤ë 3¤Ä¤Î»Í³Ñ¤ò¥É¥é¥Ã¥°¤·¤Æ¤¯¤À¤µ¤¤¡£±¦Â¦¤ÎÌð°õ¤ÏÉáÄ̤ÎÂ礭¤µ¤Ç¤Î¥µ¥ó¥×¥ë¤ò¼¨¤·¤Æ¤¤¤Þ¤¹¡£²¼¤Î¥Æ¥­¥¹¥È¤Ï¥é¥¤¥ó¥¢¥¤¥Æ¥à¤ËÂФ¹¤ëÀßÄꥪ¥×¥·¥ç¥ó¤Ç¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$arrow_buttons = TkFrame.new($arrow_demo) {|frame|
+$arrow_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -122,7 +132,7 @@ $arrow_buttons = TkFrame.new($arrow_demo) {|frame|
$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# canvas ÀßÄê
-$arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350,
+$arrow_canvas = TkCanvas.new(base_frame, 'width'=>500, 'height'=>350,
'relief'=>'sunken', 'borderwidth'=>2)
$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
diff --git a/ext/tk/sample/demos-jp/bind.rb b/ext/tk/sample/demos-jp/bind.rb
index 87b39721d1..a1bcfdd2e7 100644
--- a/ext/tk/sample/demos-jp/bind.rb
+++ b/ext/tk/sample/demos-jp/bind.rb
@@ -16,8 +16,10 @@ $bind_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($bind_demo).pack(:fill=>:both, :expand=>true)
+
# frame À¸À®
-TkFrame.new($bind_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -41,14 +43,14 @@ def tag_binding_for_bind_demo(tag, enter_style, leave_style)
end
# text À¸À®
-TkText.new($bind_demo){|t|
+txt = TkText.new(base_frame){|t|
# À¸À®
setgrid 'true'
- width 60
- height 24
+ #width 60
+ #height 24
font $font
wrap 'word'
- TkScrollbar.new($bind_demo) {|s|
+ TkScrollbar.new(base_frame) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
@@ -92,29 +94,32 @@ TkText.new($bind_demo){|t|
}
d1.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 'items.rb')
})
d2.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 'plot.rb')
})
d3.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 'ctext.rb')
})
d4.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 'arrow.rb')
})
d5.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 'ruler.rb')
})
d6.bind('1',
proc{
- eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`)
+ eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 'cscroll.rb')
})
TkTextMarkInsert.new(t, '0.0')
configure('state','disabled')
}
+
+txt.width 60
+txt.height 24
diff --git a/ext/tk/sample/demos-jp/bitmap.rb b/ext/tk/sample/demos-jp/bitmap.rb
index 4594892c81..b6b0e54bbe 100644
--- a/ext/tk/sample/demos-jp/bitmap.rb
+++ b/ext/tk/sample/demos-jp/bitmap.rb
@@ -19,7 +19,7 @@ def bitmapRow(w,*args)
TkFrame.new(row){|base|
pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
- TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
+ Tk::Label.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
}
end
}
@@ -38,14 +38,16 @@ $bitmap_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($bitmap_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¡¢Tk ¤ËÁȤ߹þ¤Þ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¤¬¡¢¤½¤ì¤é¤Î̾Á°¤È¶¦¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Tcl ¤Î¥¹¥¯¥ê¥×¥ÈÃæ¤Ç¤Ï¡¢¤½¤ì¤¾¤ì¤Î̾Á°¤òÍѤ¤¤Æ»²¾È¤·¤Þ¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
+$bitmap_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -64,7 +66,7 @@ $bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame ÀßÄê
-TkFrame.new($bitmap_demo){|f|
+TkFrame.new(base_frame){|f|
bitmapRow(f,'error','gray25','gray50','hourglass')
bitmapRow(f,'info','question','questhead','warning')
pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
diff --git a/ext/tk/sample/demos-jp/button.rb b/ext/tk/sample/demos-jp/button.rb
index 7e9457f5b4..18e42008c9 100644
--- a/ext/tk/sample/demos-jp/button.rb
+++ b/ext/tk/sample/demos-jp/button.rb
@@ -2,6 +2,7 @@
#
# button widget demo (called by 'widget')
#
+#
# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
if defined?($button_demo) && $button_demo
@@ -26,7 +27,7 @@ msg = TkLabel.new($button_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-$button_buttons = TkFrame.new($button_demo) {|frame|
+$button_buttons = Tk::Frame.new($button_demo) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
diff --git a/ext/tk/sample/demos-jp/check.rb b/ext/tk/sample/demos-jp/check.rb
index 7545df80fa..b953e7f623 100644
--- a/ext/tk/sample/demos-jp/check.rb
+++ b/ext/tk/sample/demos-jp/check.rb
@@ -16,8 +16,10 @@ $check_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($check_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($check_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -31,7 +33,7 @@ brakes = TkVariable.new(0)
sober = TkVariable.new(0)
# frame À¸À®
-TkFrame.new($check_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -52,7 +54,7 @@ TkFrame.new($check_demo) {|frame|
TkButton.new(frame) {
text 'ÊÑ¿ô»²¾È'
command proc{
- showVars($check_demo,
+ showVars(base_frame,
['wipers', wipers], ['brakes', brakes], ['sober', sober])
}
}.pack('side'=>'left', 'expand'=>'yes')
@@ -61,8 +63,8 @@ TkFrame.new($check_demo) {|frame|
# checkbutton À¸À®
-[ TkCheckButton.new($check_demo, 'text'=>'¥ï¥¤¥Ñ¡¼ OK', 'variable'=>wipers),
- TkCheckButton.new($check_demo, 'text'=>'¥Ö¥ì¡¼¥­ OK', 'variable'=>brakes),
- TkCheckButton.new($check_demo, 'text'=>'±¿Å¾¼ê ÁÇÌÌ', 'variable'=>sober)
+[ TkCheckButton.new(base_frame, 'text'=>'¥ï¥¤¥Ñ¡¼ OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'¥Ö¥ì¡¼¥­ OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'±¿Å¾¼ê ÁÇÌÌ', 'variable'=>sober)
].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
diff --git a/ext/tk/sample/demos-jp/check2.rb b/ext/tk/sample/demos-jp/check2.rb
index 90c6dd736f..7f7cb9e932 100644
--- a/ext/tk/sample/demos-jp/check2.rb
+++ b/ext/tk/sample/demos-jp/check2.rb
@@ -16,8 +16,10 @@ $check2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($check2_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($check2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -32,7 +34,7 @@ brakes = TkVariable.new(0)
sober = TkVariable.new(0)
# frame À¸À®
-TkFrame.new($check2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
@@ -60,15 +62,15 @@ TkFrame.new($check2_demo) {|frame|
# checkbutton À¸À®
-TkCheckButton.new($check2_demo, :text=>'°ÂÁ´À­¸¡ºº', :variable=>safety,
+TkCheckButton.new(base_frame, :text=>'°ÂÁ´À­¸¡ºº', :variable=>safety,
:relief=>:flat, :onvalue=>'all', :offvalue=>'none',
:tristatevalue=>'partial'){
pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
}
-[ TkCheckButton.new($check2_demo, 'text'=>'¥ï¥¤¥Ñ¡¼ OK', 'variable'=>wipers),
- TkCheckButton.new($check2_demo, 'text'=>'¥Ö¥ì¡¼¥­ OK', 'variable'=>brakes),
- TkCheckButton.new($check2_demo, 'text'=>'±¿Å¾¼ê ÁÇÌÌ', 'variable'=>sober)
+[ TkCheckButton.new(base_frame, 'text'=>'¥ï¥¤¥Ñ¡¼ OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'¥Ö¥ì¡¼¥­ OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'±¿Å¾¼ê ÁÇÌÌ', 'variable'=>sober)
].each{|w|
w.relief('flat')
w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
diff --git a/ext/tk/sample/demos-jp/clrpick.rb b/ext/tk/sample/demos-jp/clrpick.rb
index d81ecebc83..ce6b99ab94 100644
--- a/ext/tk/sample/demos-jp/clrpick.rb
+++ b/ext/tk/sample/demos-jp/clrpick.rb
@@ -2,6 +2,8 @@
#
# widget demo prompts the user to select a color (called by 'widget')
#
+# Note: don't support ttk_wrapper. work with standard widgets only.
+#
# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
if defined?($clrpick_demo) && $clrpick_demo
@@ -17,12 +19,15 @@ $clrpick_demo = TkToplevel.new {|w|
}
# label À¸À®
-TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+#TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+Tk::Label.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"°Ê²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¡¢¤³¤Î¥¦¥£¥ó¥É¥¦¾å¤Ë¤¢¤ë¥¦¥£¥¸¥§¥Ã¥È¤ÎÁ°·Ê¿§¤ÈÇØ·Ê¿§¤òÁªÂò¤·¤Æ²¼¤µ¤¤¡£").pack('side'=>'top')
# frame À¸À®
-TkFrame.new($clrpick_demo) {|frame|
- TkButton.new(frame) {
+# TkFrame.new($clrpick_demo) {|frame|
+Tk::Frame.new($clrpick_demo) {|frame|
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
command proc{
@@ -32,20 +37,23 @@ TkFrame.new($clrpick_demo) {|frame|
}
}.pack('side'=>'left', 'expand'=>'yes')
- TkButton.new(frame) {
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
text '¥³¡¼¥É»²¾È'
command proc{showCode 'clrpick'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# button À¸À®
-TkButton.new($clrpick_demo, 'text'=>'ÇØ·Ê¿§¤òÀßÄê ...') {|b|
+# TkButton.new($clrpick_demo, 'text'=>'ÇØ·Ê¿§¤òÀßÄê ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'ÇØ·Ê¿§¤òÀßÄê ...') {|b|
command(proc{setColor $clrpick_demo, b, 'background',
['background', 'highlightbackground']})
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
}
-TkButton.new($clrpick_demo, 'text'=>'Á°·Ê¿§¤òÀßÄê ...') {|b|
+# TkButton.new($clrpick_demo, 'text'=>'Á°·Ê¿§¤òÀßÄê ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'Á°·Ê¿§¤òÀßÄê ...') {|b|
command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
}
diff --git a/ext/tk/sample/demos-jp/colors.rb b/ext/tk/sample/demos-jp/colors.rb
index 68b40e69f0..91817a947b 100644
--- a/ext/tk/sample/demos-jp/colors.rb
+++ b/ext/tk/sample/demos-jp/colors.rb
@@ -16,8 +16,10 @@ $colors_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($colors_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($colors_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($colors_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($colors_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -46,7 +48,7 @@ TkFrame.new($colors_demo) {|frame|
# frame À¸À®
colors_lbox = nil
-TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
s = TkScrollbar.new(w)
colors_lbox = TkListbox.new(w) {
setgrid 1
@@ -59,7 +61,15 @@ TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
-colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+#colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+colors_lbox.bind('Double-1', proc{
+ begin
+ TkPalette.setPalette TkSelection.get
+ rescue => e
+ p e
+ Tk.tk_call_without_enc('destroy', '.___tk_set_palette')
+ end
+ })
ins_data = [
'gray60','gray70','gray80','gray85','gray90','gray95',
diff --git a/ext/tk/sample/demos-jp/combo.rb b/ext/tk/sample/demos-jp/combo.rb
new file mode 100644
index 0000000000..da00d712ba
--- /dev/null
+++ b/ext/tk/sample/demos-jp/combo.rb
@@ -0,0 +1,98 @@
+# -*- coding: euc-jp -*-
+#
+# combo.rb --
+#
+# This demonstration script creates several combobox widgets.
+#
+# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($combo_demo) && $combo_demo
+ $combo_demo.destroy
+ $combo_demo = nil
+end
+
+$combo_demo = TkToplevel.new {|w|
+ title("Combobox Demonstration")
+ iconname("combo")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+°Ê²¼¤Ç¤Ï3¼ïÎà¤Î¥³¥ó¥Ü¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥\
+ºÇ½é¤Î¤â¤Î¤Ï¡¤¥¨¥ó¥È¥ê¥¦¥£¥¸¥§¥Ã¥È¤ÈƱ¤¸Íͤˡ¤\
+¥Ý¥¤¥ó¥È¤·¤¿¤ê¡¤¥¯¥ê¥Ã¥¯¤·¤¿¤ê¡¤¥¿¥¤¥×¤·¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥\
+¤Þ¤¿¡¤Return¥­¡¼¤òÆþÎϤ¹¤ì¤Ð¸½ºß¤ÎÃͤ¬¥ê¥¹¥È¤ËÄɲ䵤졤\
+¥É¥í¥Ã¥×¥À¥¦¥ó¥ê¥¹¥È¤«¤éÁªÂò¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡¥\
+¢­(²¼¸þ¤­Ìð°õ)¥­¡¼¤ò²¡¤·¤ÆÉ½¼¨¤µ¤ì¤¿¥ê¥¹¥È¤«¤é\
+Ìð°õ¥­¡¼¤Ç¾¤Î¸õÊä¤òÁª¤ó¤ÇReturn¥­¡¼¤ò²¡¤»¤Ð¡¤ÃͤòÁªÂò¤Ç¤­¤Þ¤¹¡¥\
+2ÈÖÌܤΥ³¥ó¥Ü¥Ü¥Ã¥¯¥¹¤ÏÆÃÄê¤ÎÃͤ˸ÇÄꤵ¤ì¤Æ¤ª¤ê¡¤°ìÀÚÊѹ¹¤Ç¤­¤Þ¤»¤ó¡¥\
+3ÈÖÌܤΤâ¤Î¤Ï¥ª¡¼¥¹¥È¥é¥ê¥¢¤ÎÅԻԤΥɥí¥Ã¥×¥À¥¦¥ó¥ê¥¹¥È¤«¤é\
+ÁªÂò¤¹¤ë¤³¤È¤À¤±¤¬²Äǽ¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
+EOL
+
+## variables
+firstValue = TkVariable.new
+secondValue = TkVariable.new
+ozCity = TkVariable.new
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'ÊÑ¿ô»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame,
+ ['firstVariable', firstValue],
+ ['secondVariable', secondValue],
+ ['ozCity', ozCity])
+ }),
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'combo'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $combo_demo.destroy
+ $combo_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+australianCities = [
+ '¥­¥ã¥ó¥Ù¥é', '¥·¥É¥Ë¡¼', '¥á¥ë¥Ü¥ë¥ó', '¥Ñ¡¼¥¹', '¥¢¥Ç¥ì¡¼¥É',
+ '¥Ö¥ê¥¹¥Ù¡¼¥ó', '¥Û¥Ð¡¼¥È', '¥À¡¼¥¦¥£¥ó', '¥¢¥ê¥¹ ¥¹¥×¥ê¥ó¥°¥¹'
+]
+
+
+secondValue.value = 'Êѹ¹ÉÔ²Ä'
+ozCity.value = '¥·¥É¥Ë¡¼'
+
+Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
+ Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
+ b.bind('Return', '%W'){|w|
+ w.values <<= w.value unless w.values.include?(w.value)
+ }
+ }.pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
+ Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
+ Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
+ :values=>australianCities) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ :side=>:top, :pady=>5, :padx=>10)
diff --git a/ext/tk/sample/demos-jp/cscroll.rb b/ext/tk/sample/demos-jp/cscroll.rb
index 0be26133c5..845952679a 100644
--- a/ext/tk/sample/demos-jp/cscroll.rb
+++ b/ext/tk/sample/demos-jp/cscroll.rb
@@ -16,14 +16,16 @@ $cscroll_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($cscroll_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i',
'justify'=>'left', 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ä¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2 ¤Ç¥¹¥¯¥í¡¼¥ë¤Ç¤­¤ë¥­¥ã¥ó¥Ð¥¹ widget ¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£»Í³Ñ¤Î¾å¤Ç¥Ü¥¿¥ó1 ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬É¸½à½ÐÎϤ˽ÐÎϤµ¤ì¤Þ¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$cscroll_buttons = TkFrame.new($cscroll_demo) {|frame|
+$cscroll_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -43,7 +45,7 @@ $cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame ÀßÄê
unless $tk_version =~ /^4\.[01]/
- $cscroll_grid = TkFrame.new($cscroll_demo) {
+ $cscroll_grid = TkFrame.new(base_frame) {
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
}
TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
@@ -51,7 +53,7 @@ unless $tk_version =~ /^4\.[01]/
end
# canvas ÀßÄê
-$cscroll_canvas = TkCanvas.new($cscroll_demo,
+$cscroll_canvas = TkCanvas.new(base_frame,
'relief'=>'sunken', 'borderwidth'=>2,
'scrollregion'=>['-11c', '-11c', '50c', '20c']
) {|c|
@@ -62,7 +64,7 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo,
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
end
- TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
c.yscrollcommand(proc{|first,last| vs.set first,last})
if $tk_version =~ /^4\.[01]/
pack('side'=>'right', 'fill'=>'y')
@@ -72,7 +74,7 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo,
end
}
- TkScrollbar.new($cscroll_demo, 'orient'=>'horiz',
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
'command'=>proc{|*args| c.xview(*args)}) {|hs|
c.xscrollcommand(proc{|first,last| hs.set first,last})
if $tk_version =~ /^4\.[01]/
diff --git a/ext/tk/sample/demos-jp/ctext.rb b/ext/tk/sample/demos-jp/ctext.rb
index 35d43febbc..05ca732cfd 100644
--- a/ext/tk/sample/demos-jp/ctext.rb
+++ b/ext/tk/sample/demos-jp/ctext.rb
@@ -16,8 +16,10 @@ $ctext_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($ctext_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥­¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥­¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Î¥Æ¥­¥¹¥Èʸ»úÎó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Þ¥¦¥¹¤ò»Í³Ñ¤ÎÃæ¤Ë»ý¤Ã¤Æ¤¤¤­¡¢¥¯¥ê¥Ã¥¯¤¹¤ë¤È°ÌÃÖ¤®¤áÍѤÎÅÀ¤«¤é¤ÎÁêÂаÌÃÖ¤òÊѤ¨¤¿¤ê¡¢¹Ô·¤¨¤òÊѤ¨¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤Þ¤¿°Ê²¼¤Î¤è¤¦¤ÊÊÔ½¸¤Î¤¿¤á¤Î´Êñ¤Ê¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£
1. ¥Þ¥¦¥¹¤ò»ý¤Ã¤Æ¤¤¤­¡¢¥¯¥ê¥Ã¥¯¤·¡¢ÆþÎϤǤ­¤Þ¤¹¡£
@@ -29,7 +31,7 @@ TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
}
# frame À¸À®
-$ctext_buttons = TkFrame.new($ctext_demo) {|frame|
+$ctext_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -48,24 +50,33 @@ $ctext_buttons = TkFrame.new($ctext_demo) {|frame|
$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# canvas À¸À®
-$ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat',
+$ctext_canvas = TkCanvas.new(base_frame, 'relief'=>'flat',
'borderwidth'=>0, 'width'=>500, 'height'=>350)
$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
# font ÀßÄê
-textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+if $tk_version =~ /^4.*/
+ textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ textFont = 'Helvetica 24'
+end
# canvas ÀßÄê
TkcRectangle.new($ctext_canvas, 245, 195, 255, 205,
'outline'=>'black', 'fill'=>'red')
+ctag_text_param = {
+ 'text'=>"¤³¤ì¤Ï¥­¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥­¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Îʸ»úÎó¤Ç¤¹¡£\n¾å¤Ç½Ò¤Ù¤¿¤è¤¦¤ÊÊÔ½¸¤ò²Äǽ¤È¤¹¤ë¤¿¤á¤Î¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò»Ü¤·¤Æ¤¤¤Þ¤¹¡£",
+ 'width'=>440, 'anchor'=>'n', 'justify'=>'left'
+}
+if $tk_version =~ /^4.*/
+ ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+ ctag_text_param['kanjifont'] = '-*-r-*--24-*-jisx0208.1983-0'
+else
+ ctag_text_param['font'] = 'Helvetica 24'
+end
$ctag_text = TkcTag.new($ctext_canvas)
-$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200,
- 'text'=>"¤³¤ì¤Ï¥­¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥­¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Îʸ»úÎó¤Ç¤¹¡£\n¾å¤Ç½Ò¤Ù¤¿¤è¤¦¤ÊÊÔ½¸¤ò²Äǽ¤È¤¹¤ë¤¿¤á¤Î¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò»Ü¤·¤Æ¤¤¤Þ¤¹¡£",
- 'width'=>440, 'anchor'=>'n',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*',
- 'kanjifont'=>'-*-r-*--24-*-jisx0208.1983-0',
- 'justify'=>'left') )
+$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, ctag_text_param))
$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y")
$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
@@ -107,9 +118,14 @@ mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color
item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50,
'outline'=>'black', 'fill'=>'red')
item.bind('1', proc{$ctag_text.configure 'anchor', 'center'})
-TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s',
- 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
- 'fill'=>'brown')
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
# Lastly, create some items that allow the text's justification to be
# changed.
@@ -120,9 +136,14 @@ color = 'SeaGreen2'
mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color
mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color
mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color
-TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s',
- 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
- 'fill'=>'brown')
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas})
$ctext_canvas.itembind('config', 'Leave',
diff --git a/ext/tk/sample/demos-jp/entry1.rb b/ext/tk/sample/demos-jp/entry1.rb
index d794282284..2be29c18d3 100644
--- a/ext/tk/sample/demos-jp/entry1.rb
+++ b/ext/tk/sample/demos-jp/entry1.rb
@@ -16,8 +16,10 @@ $entry1_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($entry1_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($entry1_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($entry1_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($entry1_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -44,9 +46,9 @@ TkFrame.new($entry1_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# entry À¸À®
-e1 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
-e2 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
-e3 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+e1 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e2 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e3 = TkEntry.new(base_frame, 'relief'=>'sunken')
[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
# ½é´üÃÍÁÞÆþ
diff --git a/ext/tk/sample/demos-jp/entry2.rb b/ext/tk/sample/demos-jp/entry2.rb
index 528ad6dec4..2675b5d324 100644
--- a/ext/tk/sample/demos-jp/entry2.rb
+++ b/ext/tk/sample/demos-jp/entry2.rb
@@ -16,8 +16,10 @@ $entry2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($entry2_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($entry2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($entry2_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($entry2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -44,7 +46,7 @@ TkFrame.new($entry2_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame À¸À®
-TkFrame.new($entry2_demo, 'borderwidth'=>10) {|w|
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
# entry 1
s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
e1 = TkEntry.new(w, 'relief'=>'sunken') {
diff --git a/ext/tk/sample/demos-jp/entry3.rb b/ext/tk/sample/demos-jp/entry3.rb
index 46426af6ae..6b9cd4cf37 100644
--- a/ext/tk/sample/demos-jp/entry3.rb
+++ b/ext/tk/sample/demos-jp/entry3.rb
@@ -18,7 +18,9 @@ $entry3_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($entry3_demo,
+base_frame = TkFrame.new($entry3_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
°Ê²¼¤Ë¤Ï£´¼ïÎà¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥³Æ¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤Ï¡¤\
@@ -39,7 +41,7 @@ TkLabel.new($entry3_demo,
ÆþÎϤµ¤ì¤¿Ê¸»ú¤Ï¥¢¥¹¥¿¥ê¥¹¥¯µ­¹æ¤ËÃÖ¤­´¹¤¨¤ÆÉ½¼¨¤µ¤ì¤Þ¤¹¡¥
EOL
-TkFrame.new($entry3_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
@@ -65,23 +67,41 @@ TkFrame.new($entry3_demo){|f|
# count - Counter to control the number of times flashed
def focusAndFlash(widget, fg, bg, count=5)
return if count <= 0
- TkTimer.new(100, count,
- proc{widget.configure(:foreground=>bg, :background=>fg)},
- proc{widget.configure(:foreground=>fg, :background=>bg)}
- ).start
+ if fg && !fg.empty? && bg && !bg.empty?
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>bg, :background=>fg)},
+ proc{widget.configure(:foreground=>fg, :background=>bg)}
+ ).start
+ else
+ # TkTimer.new(150, 3){Tk.bell}.start
+ Tk.bell
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>'white',
+ :background=>'black')},
+ proc{widget.configure(:foreground=>'black',
+ :background=>'white')}
+ ).at_end{begin
+ widget.configure(:foreground=>fg,
+ :background=>bg)
+ rescue
+ # ignore
+ end}.start
+ end
widget.focus(true)
end
-l1 = TkLabelFrame.new($entry3_demo, :text=>"À°¿ô¥¨¥ó¥È¥ê")
+l1 = TkLabelFrame.new(base_frame, :text=>"À°¿ô¥¨¥ó¥È¥ê")
TkEntry.new(l1, :validate=>:focus,
:vcmd=>[
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
]) {|e|
- invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W']
+ fg = e.foreground
+ bg = e.background
+ invalidcommand [proc{|w| focusAndFlash(w, fg, bg)}, '%W']
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
}
-l2 = TkLabelFrame.new($entry3_demo, :text=>"ŤµÀ©ÌóÉÕ¤­¥¨¥ó¥È¥ê")
+l2 = TkLabelFrame.new(base_frame, :text=>"ŤµÀ©ÌóÉÕ¤­¥¨¥ó¥È¥ê")
TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
:vcmd=>[proc{|s| s.length < 10}, '%P']
).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
@@ -162,15 +182,15 @@ def validatePhoneChange(widget, vmode, idx, char)
widget.delete(idx)
widget.insert(idx, $phoneNumberMap[char] || char)
Tk.after_idle(proc{phoneSkipRight(widget, -1)})
- # Tk.update(true) # Don't work 'update' inter validation callback.
- # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
+ # Tk.update(true) # <- Don't work 'update' inter validation callback.
+ # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
return true
end
return false
end
-l3 = TkLabelFrame.new($entry3_demo, :text=>"ÊÆ¹ñÅÅÏÃÈֹ楨¥ó¥È¥ê")
+l3 = TkLabelFrame.new(base_frame, :text=>"ÊÆ¹ñÅÅÏÃÈֹ楨¥ó¥È¥ê")
TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
:textvariable=>entry3content,
:vcmd=>[
@@ -189,14 +209,14 @@ TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
}
-l4 = TkLabelFrame.new($entry3_demo, :text=>"¥Ñ¥¹¥ï¡¼¥É¥¨¥ó¥È¥ê")
+l4 = TkLabelFrame.new(base_frame, :text=>"¥Ñ¥¹¥ï¡¼¥É¥¨¥ó¥È¥ê")
TkEntry.new(l4, :validate=>:key, :show=>'*',
:vcmd=>[
proc{|s| s.length <= 8},
'%P'
]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
-TkFrame.new($entry3_demo){|f|
+TkFrame.new(base_frame){|f|
lower
TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
diff --git a/ext/tk/sample/demos-jp/filebox.rb b/ext/tk/sample/demos-jp/filebox.rb
index 04b4810b3b..b8846d08a0 100644
--- a/ext/tk/sample/demos-jp/filebox.rb
+++ b/ext/tk/sample/demos-jp/filebox.rb
@@ -16,12 +16,14 @@ $filebox_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($filebox_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"¥¨¥ó¥È¥ê¤Ë¥Õ¥¡¥¤¥ë̾¤òľÀÜÆþÎϤ¹¤ë¤«¡¢\"Browse\" ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤«¤é¥Õ¥¡¥¤¥ë̾¤òÁª¤ó¤Ç²¼¤µ¤¤¡£").pack('side'=>'top')
# frame À¸À®
-TkFrame.new($filebox_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -40,7 +42,7 @@ TkFrame.new($filebox_demo) {|frame|
# frame À¸À®
['³«¤¯', 'Êݸ'].each{|type|
- TkFrame.new($filebox_demo) {|f|
+ TkFrame.new(base_frame) {|f|
TkLabel.new(f, 'text'=>"¥Õ¥¡¥¤¥ë¤ò#{type}: ", 'anchor'=>'e')\
.pack('side'=>'left')
@@ -48,7 +50,7 @@ TkFrame.new($filebox_demo) {|frame|
pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
TkButton.new(f, 'text'=>'Browse ...',
- 'command'=>proc{fileDialog $filebox_demo,e,type})\
+ 'command'=>proc{fileDialog base_frame,e,type})\
.pack('side'=>'left')
}
@@ -58,7 +60,7 @@ TkFrame.new($filebox_demo) {|frame|
$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
if ($tk_platform['platform'] == 'unix')
- TkCheckButton.new($filebox_demo,
+ TkCheckButton.new(base_frame,
'text'=>'Motif¥¹¥¿¥¤¥ë¤Î¥À¥¤¥¢¥í¥°¤òÍѤ¤¤ë',
'variable'=>$tk_strictMotif,
'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
@@ -91,7 +93,10 @@ def fileDialog(w,ent,operation)
if file != ""
ent.delete 0, 'end'
ent.insert 0, file
- ent.xview 'end'
+ # ent.xview 'end'
+ Tk.update_idletasks # need this for Tk::Tile::Entry
+ # (to find right position of 'xview').
+ ent.xview(ent.index('end'))
end
end
diff --git a/ext/tk/sample/demos-jp/floor.rb b/ext/tk/sample/demos-jp/floor.rb
index b7d07bdafa..a2ec2e9969 100644
--- a/ext/tk/sample/demos-jp/floor.rb
+++ b/ext/tk/sample/demos-jp/floor.rb
@@ -1587,14 +1587,16 @@ $floor_demo = TkToplevel.new {|w|
minsize(100,100)
}
+base_frame = TkFrame.new($floor_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥­¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òư¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$floor_buttons = TkFrame.new($floor_demo) {|frame|
+$floor_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -1618,17 +1620,17 @@ $floorItems = {}
# canvas ÀßÄê
if $tk_version =~ /^4\.[01]/
- $floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken',
+ $floor_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
'highlightthickness'=>2)
$floor_canvas = TkCanvas.new($floor_canvas_frame,
'width'=>900, 'height'=>500, 'borderwidth'=>0,
'highlightthickness'=>0) {|c|
- TkScrollbar.new($floor_demo, 'orient'=>'horiz',
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
'command'=>proc{|*args| c.xview(*args)}){|hs|
c.xscrollcommand(proc{|first,last| hs.set first,last})
pack('side'=>'bottom', 'fill'=>'x')
}
- TkScrollbar.new($floor_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
c.yscrollcommand(proc{|first,last| vs.set first,last})
pack('side'=>'right', 'fill'=>'y')
}
@@ -1637,7 +1639,7 @@ if $tk_version =~ /^4\.[01]/
$floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
else
- TkFrame.new($floor_demo) {|f|
+ TkFrame.new(base_frame) {|f|
pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
diff --git a/ext/tk/sample/demos-jp/floor2.rb b/ext/tk/sample/demos-jp/floor2.rb
index b7571a592f..d4381c5543 100644
--- a/ext/tk/sample/demos-jp/floor2.rb
+++ b/ext/tk/sample/demos-jp/floor2.rb
@@ -1587,14 +1587,16 @@ $floor2_demo = TkToplevel.new {|w|
minsize(100,100)
}
+base_frame = TkFrame.new($floor2_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($floor2_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥­¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òư¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$floor2_buttons = TkFrame.new($floor2_demo) {|frame|
+$floor2_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -1618,17 +1620,17 @@ $floorItems2 = {}
# canvas ÀßÄê
if $tk_version =~ /^4\.[01]/
- $floor2_canvas_frame = TkFrame.new($floor2_demo,'bd'=>2,'relief'=>'sunken',
+ $floor2_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
'highlightthickness'=>2)
$floor2_canvas = TkCanvas.new($floor2_canvas_frame,
'width'=>900, 'height'=>500, 'borderwidth'=>0,
'highlightthickness'=>0) {|c|
- TkScrollbar.new($floor2_demo, 'orient'=>'horiz',
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
'command'=>proc{|*args| c.xview(*args)}){|hs|
c.xscrollcommand(proc{|first,last| hs.set first,last})
pack('side'=>'bottom', 'fill'=>'x')
}
- TkScrollbar.new($floor2_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
c.yscrollcommand(proc{|first,last| vs.set first,last})
pack('side'=>'right', 'fill'=>'y')
}
@@ -1637,7 +1639,7 @@ if $tk_version =~ /^4\.[01]/
$floor2_canvas.pack('expand'=>'yes', 'fill'=>'both')
else
- TkFrame.new($floor2_demo) {|f|
+ TkFrame.new(base_frame) {|f|
pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
diff --git a/ext/tk/sample/demos-jp/form.rb b/ext/tk/sample/demos-jp/form.rb
index 637dd9a8ea..4de7056764 100644
--- a/ext/tk/sample/demos-jp/form.rb
+++ b/ext/tk/sample/demos-jp/form.rb
@@ -16,8 +16,10 @@ $form_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($form_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($form_demo) {
msg.pack('side'=>'top', 'fill'=>'x')
# frame À¸À®
-TkFrame.new($form_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -46,7 +48,7 @@ TkFrame.new($form_demo) {|frame|
# entry À¸À®
form_data = []
(1..5).each{|i|
- f = TkFrame.new($form_demo, 'bd'=>2)
+ f = TkFrame.new(base_frame, 'bd'=>2)
e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
l = TkLabel.new(f)
e.pack('side'=>'right')
diff --git a/ext/tk/sample/demos-jp/goldberg.rb b/ext/tk/sample/demos-jp/goldberg.rb
index 8bf0104c16..a81c7ec70c 100644
--- a/ext/tk/sample/demos-jp/goldberg.rb
+++ b/ext/tk/sample/demos-jp/goldberg.rb
@@ -55,6 +55,8 @@ $goldberg_demo = TkToplevel.new {|w|
# positionWindow(w)
}
+base_frame = TkFrame.new($goldberg_demo).pack(:fill=>:both, :expand=>true)
+
=begin
# label
msg = TkLabel.new($goldberg_demo) {
@@ -177,7 +179,8 @@ class TkGoldberg_Demo
do_ctrl_frame
do_detail_frame
- msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ # msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ msg = Tk::Label.new(@parent, :bg=>@C['bg'], :fg=>'white') {
font 'Arial 10'
wraplength 600
justify 'left'
@@ -187,7 +190,8 @@ class TkGoldberg_Demo
frame = TkFrame.new(@parent, :bg=>@C['bg'])
- TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
text 'ÊĤ¸¤ë'
command proc{
tmppath = $goldberg_demo
@@ -196,12 +200,14 @@ class TkGoldberg_Demo
}
}.pack('side'=>'left')
- TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
text '¥³¡¼¥É»²¾È'
command proc{showCode 'goldberg'}
}.pack('side'=>'left', 'padx'=>5)
- @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ # @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ @show = Tk::Button.new(frame, :text=>'>>', :command=>proc{show_ctrl},
:bg=>@C['bg'], :activebackground=>@C['bg'])
@show.pack('side'=>'left')
frame.place(:in=>@canvas, :relx=>1, :rely=>0, :anchor=>:ne)
@@ -210,10 +216,11 @@ class TkGoldberg_Demo
end
def do_ctrl_frame
- @start = TkButton.new(@parent, :text=>'Start', :bd=>6,
+ @start = Tk::Button.new(@parent, :text=>'Start', :bd=>6,
:command=>proc{do_button(0)})
- @start.font(@start['font'].weight('bold'))
- font = @start['font']
+ if font = @start['font']
+ @start.font(font.weight('bold'))
+ end
@pause = TkCheckbutton.new(@parent, :text=>'Pause', :font=>font,
:command=>proc{do_button(1)}, :relief=>:raised,
@@ -2001,4 +2008,4 @@ class TkGoldberg_Demo
end
end
-TkGoldberg_Demo.new($goldberg_demo)
+TkGoldberg_Demo.new(base_frame)
diff --git a/ext/tk/sample/demos-jp/hscale.rb b/ext/tk/sample/demos-jp/hscale.rb
index 690479d6d1..5615aa50bd 100644
--- a/ext/tk/sample/demos-jp/hscale.rb
+++ b/ext/tk/sample/demos-jp/hscale.rb
@@ -12,8 +12,9 @@ $hscale_demo = TkToplevel.new {|w|
}
positionWindow($hscale_demo)
+base_frame = TkFrame.new($hscale_demo).pack(:fill=>:both, :expand=>true)
-msg = TkLabel.new($hscale_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '3.5i'
justify 'left'
@@ -23,7 +24,7 @@ msg = TkLabel.new($hscale_demo) {
}
msg.pack('side'=>'top')
-TkFrame.new($hscale_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -40,7 +41,17 @@ TkFrame.new($hscale_demo) {|frame|
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
-TkFrame.new($hscale_demo) {|frame|
+def setWidth(w, width)
+ width = width + 21
+ x2 = width - 30
+ if x2 < 21
+ x2 = 21
+ end
+ w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+ w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+end
+
+TkFrame.new(base_frame) {|frame|
canvas = TkCanvas.new(frame) {|c|
width 50
height 50
@@ -65,14 +76,3 @@ TkFrame.new($hscale_demo) {|frame|
}.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n')
scale.set 75
}.pack('side'=>'top', 'fill'=>'x')
-
-
-def setWidth(w, width)
- width = width + 21
- x2 = width - 30
- if x2 < 21
- x2 = 21
- end
- w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
- w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
-end
diff --git a/ext/tk/sample/demos-jp/icon.rb b/ext/tk/sample/demos-jp/icon.rb
index 26382a57a7..a2ca6651dc 100644
--- a/ext/tk/sample/demos-jp/icon.rb
+++ b/ext/tk/sample/demos-jp/icon.rb
@@ -16,8 +16,10 @@ $icon_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($icon_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($icon_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($icon_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($icon_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -61,16 +63,18 @@ TkBitmapImage.new('file'=>[$demo_dir,'..',
letters = TkVariable.new
# frame À¸À®
-TkFrame.new($icon_demo, 'borderwidth'=>10){|w|
+TkFrame.new(base_frame, 'borderwidth'=>10){|w|
TkFrame.new(w) {|f|
- TkRadioButton.new(f){
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
bitmap '@' + [$demo_dir,'..',
'images','letters.xbm'].join(File::Separator)
variable letters
value 'full'
}.pack('side'=>'top', 'expand'=>'yes')
- TkRadioButton.new(f){
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
bitmap '@' + [$demo_dir,'..',
'images','noletter.xbm'].join(File::Separator)
variable letters
@@ -79,14 +83,16 @@ TkFrame.new($icon_demo, 'borderwidth'=>10){|w|
}.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
- TkCheckButton.new(w) {
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
image flagdown
selectimage flagup
indicatoron 0
selectcolor self['background']
}.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
- TkCheckButton.new(w) {
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
bitmap '@' + [$demo_dir,'..',
'images','letters.xbm'].join(File::Separator)
indicatoron 0
diff --git a/ext/tk/sample/demos-jp/image1.rb b/ext/tk/sample/demos-jp/image1.rb
index 3b56d240dc..d9435cc1a2 100644
--- a/ext/tk/sample/demos-jp/image1.rb
+++ b/ext/tk/sample/demos-jp/image1.rb
@@ -16,8 +16,10 @@ $image1_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($image1_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($image1_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($image1_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($image1_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -53,7 +55,10 @@ TkPhotoImage.new('file'=>[$demo_dir,'..',
'images','earthris.gif'].join(File::Separator))
# label À¸À®
-[ TkLabel.new($image1_demo, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
- TkLabel.new($image1_demo, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+#[ TkLabel.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+# TkLabel.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+#].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+[ Tk::Label.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+ Tk::Label.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
diff --git a/ext/tk/sample/demos-jp/image2.rb b/ext/tk/sample/demos-jp/image2.rb
index de627448c1..1bb2c9e9c3 100644
--- a/ext/tk/sample/demos-jp/image2.rb
+++ b/ext/tk/sample/demos-jp/image2.rb
@@ -16,8 +16,10 @@ $image2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($image2_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($image2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($image2_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($image2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -51,21 +53,21 @@ $dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
$image2a = TkPhotoImage.new
# ¥Õ¥¡¥¤¥ë̾ÆþÎÏÉô
-TkLabel.new($image2_demo, 'text'=>'¥Ç¥£¥ì¥¯¥È¥ê:')\
+TkLabel.new(base_frame, 'text'=>'¥Ç¥£¥ì¥¯¥È¥ê:')\
.pack('side'=>'top', 'anchor'=>'w')
-image2_e = TkEntry.new($image2_demo) {
+image2_e = TkEntry.new(base_frame) {
width 30
textvariable $dirName
}.pack('side'=>'top', 'anchor'=>'w')
-TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20)\
+TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20)\
.pack('side'=>'top', 'anchor'=>'w')
-TkLabel.new($image2_demo, 'text'=>'¥Õ¥¡¥¤¥ë:')\
+TkLabel.new(base_frame, 'text'=>'¥Õ¥¡¥¤¥ë:')\
.pack('side'=>'top', 'anchor'=>'w')
-TkFrame.new($image2_demo){|w|
+TkFrame.new(base_frame){|w|
s = TkScrollbar.new(w)
l = TkListbox.new(w) {
width 20
@@ -84,9 +86,10 @@ TkFrame.new($image2_demo){|w|
}.pack('side'=>'top', 'anchor'=>'w')
# image ÇÛÃÖ
-[ TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20),
- TkLabel.new($image2_demo, 'text'=>'²èÁü:'),
- TkLabel.new($image2_demo, 'image'=>$image2a)
+[ TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20),
+ TkLabel.new(base_frame, 'text'=>'²èÁü:'),
+ # TkLabel.new(base_frame, 'image'=>$image2a)
+ Tk::Label.new(base_frame, 'image'=>$image2a)
].each{|w| w.pack('side'=>'top', 'anchor'=>'w')}
# ¥á¥½¥Ã¥ÉÄêµÁ
diff --git a/ext/tk/sample/demos-jp/image3.rb b/ext/tk/sample/demos-jp/image3.rb
index 36c1823745..12b8aafd8e 100644
--- a/ext/tk/sample/demos-jp/image3.rb
+++ b/ext/tk/sample/demos-jp/image3.rb
@@ -20,6 +20,8 @@ $image3_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+
#
def loadDir3(w)
w.delete(0,'end')
@@ -50,7 +52,7 @@ end
# label
-msg = TkLabel.new($image3_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -59,7 +61,7 @@ msg = TkLabel.new($image3_demo) {
msg.pack('side'=>'top')
# frame
-TkFrame.new($image3_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -88,11 +90,11 @@ end
$image3a = TkPhotoImage.new
#
-image3_f = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+image3_f = TkFrame.new(base_frame).pack(:fill=>:both, :expand=>true)
-image3_df = TkLabelFrame.new($image3_demo, :text=>'¥Ç¥£¥ì¥¯¥È¥ê:')
+image3_df = TkLabelFrame.new(base_frame, :text=>'¥Ç¥£¥ì¥¯¥È¥ê:')
-image3_ff = TkLabelFrame.new($image3_demo, :text=>'¥Õ¥¡¥¤¥ë:',
+image3_ff = TkLabelFrame.new(base_frame, :text=>'¥Õ¥¡¥¤¥ë:',
:padx=>'2m', :pady=>'2m')
image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
pack(:side=>:left, :fill=>:y, :expand=>true)
@@ -112,8 +114,9 @@ TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"¥Ç¥£¥ì¥¯¥È¥êÁªÂò",
pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m')
}
-image3_if = TkLabelFrame.new($image3_demo, :text=>'¥¤¥á¡¼¥¸:') {|f|
- TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+image3_if = TkLabelFrame.new(base_frame, :text=>'¥¤¥á¡¼¥¸:') {|f|
+ # TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+ Tk::Label.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
}
Tk.grid(image3_df, '-',
diff --git a/ext/tk/sample/demos-jp/items.rb b/ext/tk/sample/demos-jp/items.rb
index d538fac75f..64ceeff3ec 100644
--- a/ext/tk/sample/demos-jp/items.rb
+++ b/ext/tk/sample/demos-jp/items.rb
@@ -16,8 +16,10 @@ $items_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($items_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($items_demo) {
+TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -25,7 +27,7 @@ TkLabel.new($items_demo) {
}.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($items_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -44,7 +46,7 @@ TkFrame.new($items_demo) {|frame|
# frame À¸À®
cvs = nil
-TkFrame.new($items_demo) {|cf|
+TkFrame.new(base_frame) {|cf|
# canvas À¸À®
cvs = TkCanvas.new(cf) {|c|
focus
@@ -92,8 +94,13 @@ TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
-font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
-font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+if $tk_version =~ /^4.*/
+ font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+else
+ font1 = 'Helvetica 12'
+ font2 = 'Helvetica 24 bold'
+end
if TkWinfo.depth($root).to_i > 1
blue = 'DeepSkyBlue3'
red = 'red'
diff --git a/ext/tk/sample/demos-jp/knightstour.rb b/ext/tk/sample/demos-jp/knightstour.rb
new file mode 100644
index 0000000000..d4595ea441
--- /dev/null
+++ b/ext/tk/sample/demos-jp/knightstour.rb
@@ -0,0 +1,273 @@
+# -*- coding: euc-jp -*-
+#
+# Based on the widget demo of Tcl/Tk8.5.2
+# The following is the original copyright text.
+#----------------------------------------------------------------------------
+# Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# Calculate a Knight's tour of a chessboard.
+#
+# This uses Warnsdorff's rule to calculate the next square each
+# time. This specifies that the next square should be the one that
+# has the least number of available moves.
+#
+# Using this rule it is possible to get to a position where
+# there are no squares available to move into. In this implementation
+# this occurs when the starting square is d6.
+#
+# To solve this fault an enhancement to the rule is that if we
+# have a choice of squares with an equal score, we should choose
+# the one nearest the edge of the board.
+#
+# If the call to the Edgemost function is commented out you can see
+# this occur.
+#
+# You can drag the knight to a specific square to start if you wish.
+# If you let it repeat then it will choose random start positions
+# for each new tour.
+#----------------------------------------------------------------------------
+require 'tk'
+
+class Knights_Tour
+ # Return a list of accessible squares from a given square
+ def valid_moves(square)
+ moves = []
+ [
+ [-1,-2], [-2,-1], [-2,1], [-1,2], [1,2], [2,1], [2,-1], [1,-2]
+ ].each{|col_delta, row_delta|
+ col = (square % 8) + col_delta
+ row = (square.div(8)) + row_delta
+ moves << (row * 8 + col) if row > -1 && row < 8 && col > -1 && col < 8
+ }
+ moves
+ end
+
+ # Return the number of available moves for this square
+ def check_square(square)
+ valid_moves(square).find_all{|pos| ! @visited.include?(pos)}.length
+ end
+
+ # Select the next square to move to. Returns -1 if there are no available
+ # squares remaining that we can move to.
+ def next_square(square)
+ minimum = 9
+ nxt = -1
+ valid_moves(square).each{|pos|
+ unless @visited.include?(pos)
+ cnt = check_square(pos)
+ if cnt < minimum
+ minimum = cnt
+ nxt = pos
+ elsif cnt == minimum
+ nxt = edgemost(nxt, pos)
+ end
+ end
+ }
+ nxt
+ end
+
+ # Select the square nearest the edge of the board
+ def edgemost(nxt, pos)
+ col_A = 3 - ((3.5 - nxt % 8).abs.to_i)
+ col_B = 3 - ((3.5 - pos % 8).abs.to_i)
+ row_A = 3 - ((3.5 - nxt.div(8)).abs.to_i)
+ row_B = 3 - ((3.5 - pos.div(8)).abs.to_i)
+ (col_A * row_A < col_B * row_B)? nxt : pos
+ end
+
+ # Display a square number as a standard chess square notation.
+ def _N(square)
+ '%c%d' % [(97 + square % 8), (square.div(8) + 1)]
+ end
+
+ # Perform a Knight's move and schedule the next move.
+ def move_piece(last, square)
+ @log.insert(:end, "#{@visited.length}. #{_N last} -> #{_N square}\n", '')
+ @log.see(:end)
+ @board.itemconfigure(1+last, :state=>:normal, :outline=>'black')
+ @board.itemconfigure(1+square, :state=>:normal, :outline=>'red')
+ @knight.coords(@board.coords(1+square)[0..1])
+ @visited << square
+ if (nxt = next_square(square)) != -1
+ @after_id = Tk.after(@delay.numeric){move_piece(square, nxt) rescue nil}
+ else
+ @start_btn.state :normal
+ if @visited.length == 64
+ if @initial == square
+ @log.insert :end, '¼þÍ·(closed tour)À®¸ù¡ª'
+ else
+ @log.insert :end, "À®¸ù\n", {}
+ Tk.after(@delay.numeric * 2){tour(rand(64))} if @continuous.bool
+ end
+ else
+ @log.insert :end, "¼ºÇÔ¡ª\n", {}
+ end
+ end
+ end
+
+ # Begin a new tour of the board given a random start position
+ def tour(square = nil)
+ @visited.clear
+ @log.clear
+ @start_btn.state :disabled
+ 1.upto(64){|n|
+ @board.itemconfigure(n, :state=>:disabled, :outline=>'black')
+ }
+ unless square
+ square = @board.find_closest(*(@knight.coords << 0 << 65))[0].to_i - 1
+ end
+ @initial = square
+ Tk.after_idle{ move_piece(@initial, @initial) rescue nil }
+ end
+
+ def _stop
+ Tk.after_cancel(@after_id) rescue nil
+ end
+
+ def _exit
+ _stop
+ $knightstour.destroy
+ end
+
+ def set_delay(new)
+ @delay.numeric = new.to_i
+ end
+
+ def drag_start(w, x, y)
+ w.dtag('selected')
+ w.addtag('selected', :withtag, 'current')
+ @dragging = [x, y]
+ end
+
+ def drag_motion(w, x, y)
+ return unless @dragging
+ w.move('selected', x - @dragging[0], y - @dragging[1])
+ @dragging = [x, y]
+ end
+
+ def drag_end(w, x, y)
+ square = w.find_closest(x, y, 0, 65)
+ w.coords('selected', w.coords(square)[0..1])
+ w.dtag('selected')
+ @dragging = nil
+ end
+
+ def make_SeeDismiss
+ ## See Code / Dismiss
+ frame = Ttk::Frame.new($knightstour)
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'knightstour'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $knightstour.destroy
+ $knightstour = nil
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ frame
+ end
+
+ def create_gui(parent = nil)
+ $knightstour.destroy rescue nil
+ $knightstour = Tk::Toplevel.new(parent, :title=>"Knight's tour")
+ $knightstour.withdraw
+ base_f = Ttk::Frame.new($knightstour)
+ @board = Tk::Canvas.new(base_f, :width=>240, :height=>240)
+ @log = Tk::Text.new(base_f, :width=>12, :height=>1,
+ :font=>'Arial 8', :background=>'white')
+ scr = @log.yscrollbar(Ttk::Scrollbar.new(base_f))
+
+ @visited = []
+ @delay = TkVariable.new(600)
+ @continuous = TkVariable.new(false)
+
+ tool_f = Ttk::Frame.new($knightstour)
+ label = Ttk::Label.new(tool_f, :text=>'¼Â¹Ô®ÅÙ')
+ scale = Ttk::Scale.new(tool_f, :from=>8, :to=>2000, :variable=>@delay,
+ :command=>proc{|n| set_delay(n)})
+ check = Ttk::Checkbutton.new(tool_f, :text=>'È¿Éü',
+ :variable=>@continuous)
+ @start_btn = Ttk::Button.new(tool_f, :text=>'³«»Ï',
+ :command=>proc{tour()})
+ @exit_btn = Ttk::Button.new(tool_f, :text=>'½ªÎ»',
+ :command=>proc{_exit()})
+
+ 7.downto(0){|row|
+ 0.upto(7){|col|
+ if ((col & 1) ^ (row & 1)).zero?
+ fill = 'bisque'
+ dfill = 'bisque3'
+ else
+ fill = 'tan3'
+ dfill = 'tan4'
+ end
+ coords = [col * 30 + 4, row * 30 + 4, col * 30 + 30, row * 30 + 30]
+ @board.create(TkcRectangle, coords,
+ :fill=>fill, :disabledfill=>dfill,
+ :width=>2, :state=>:disabled)
+ }
+ }
+
+ @knight_font = TkFont.new(:size=>-24)
+ @knight = TkcText.new(@board, 0, 0, :font=>@knight_font,
+ :text=>Tk::UTF8_String.new('\u265e'),
+ :anchor=>'nw', # :tags=>'knight',
+ :fill=>'black', :activefill=>'#600000')
+ @knight.coords(@board.coords(rand(64)+1)[0..1])
+ @knight.bind('ButtonPress-1', '%W %x %y'){|w,x,y| drag_start(w,x,y)}
+ @knight.bind('Motion', '%W %x %y'){|w,x,y| drag_motion(w,x,y)}
+ @knight.bind('ButtonRelease-1', '%W %x %y'){|w,x,y| drag_end(w,x,y)}
+
+ Tk.grid(@board, @log, scr, :sticky=>'news')
+ base_f.grid_rowconfigure(0, :weight=>1)
+ base_f.grid_columnconfigure(0, :weight=>1)
+
+ Tk.grid(base_f, '-', '-', '-', '-', '-', :sticky=>'news')
+ widgets = [label, scale, check, @start_btn]
+ sg = nil
+ unless $RubyTk_WidgetDemo
+ widgets << @exit_btn
+ if Tk.windowingsystem != 'aqua'
+ #widgets.unshift(Ttk::SizeGrip.new(tool_f))
+ Ttk::SizeGrip.new(tool_f).pack(:side=>:right, :anchor=>'se')
+ end
+ end
+ Tk.pack(widgets, :side=>:right)
+ if Tk.windowingsystem == 'aqua'
+ TkPack.configure(widgets, :padx=>[4, 4], :pady=>[12, 12])
+ TkPack.configure(widgets[0], :padx=>[4, 24])
+ TkPack.configure(widgets[-1], :padx=>[16, 4])
+ end
+
+ Tk.grid(tool_f, '-', '-', '-', '-', '-', :sticky=>'ew')
+
+ if $RubyTk_WidgetDemo
+ Tk.grid(make_SeeDismiss(), '-', '-', '-', '-', '-', :sticky=>'ew')
+ end
+
+ $knightstour.grid_rowconfigure(0, :weight=>1)
+ $knightstour.grid_columnconfigure(0, :weight=>1)
+
+ $knightstour.bind('Control-F2'){TkConsole.show}
+ $knightstour.bind('Return'){@start_btn.invoke}
+ $knightstour.bind('Escape'){@exit_btn.invoke}
+ $knightstour.bind('Destroy'){ _stop }
+ $knightstour.protocol('WM_DELETE_WINDOW'){ _exit }
+
+ $knightstour.deiconify
+ $knightstour.tkwait_destroy
+ end
+
+ def initialize(parent = nil)
+ create_gui(parent)
+ end
+end
+
+Tk.root.withdraw unless $RubyTk_WidgetDemo
+Thread.new{Tk.mainloop} if __FILE__ == $0
+Knights_Tour.new
diff --git a/ext/tk/sample/demos-jp/label.rb b/ext/tk/sample/demos-jp/label.rb
index a1ecc2ec80..2e6b3e7e57 100644
--- a/ext/tk/sample/demos-jp/label.rb
+++ b/ext/tk/sample/demos-jp/label.rb
@@ -16,8 +16,10 @@ $label_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($label_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($label_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($label_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($label_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -45,8 +47,8 @@ TkFrame.new($label_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# label demo Íѥե졼¥àÀ¸À®
-f_left = TkFrame.new($label_demo)
-f_right = TkFrame.new($label_demo)
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
'padx'=>10, 'pady'=>10, 'fill'=>'both')}
@@ -57,7 +59,8 @@ f_right = TkFrame.new($label_demo)
TkLabel.new(f_left, 'text'=>'3 ÈÖÌÜ¡£ÄÀ¤ó¤Ç¤¤¤Þ¤¹ ', 'relief'=>'sunken')
].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
-TkLabel.new(f_right) {
+# TkLabel.new(f_right) {
+Tk::Label.new(f_right) {
bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
borderwidth 2
relief 'sunken'
diff --git a/ext/tk/sample/demos-jp/labelframe.rb b/ext/tk/sample/demos-jp/labelframe.rb
index f16b601ffd..11b0d27308 100644
--- a/ext/tk/sample/demos-jp/labelframe.rb
+++ b/ext/tk/sample/demos-jp/labelframe.rb
@@ -19,8 +19,10 @@ $labelframe_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($labelframe_demo).pack(:fill=>:both, :expand=>true)
+
# Some information
-TkLabel.new($labelframe_demo,
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
TkLabelFrame ¥¦¥£¥¸¥§¥Ã¥È¤Ï´ØÏ¢¤¹¤ë widget
@@ -36,7 +38,7 @@ labelframe ¥¦¥£¥¸¥§¥Ã¥È¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤
EOL
# The bottom buttons
-TkFrame.new($labelframe_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
@@ -50,7 +52,7 @@ TkFrame.new($labelframe_demo){|f|
}
# Demo area
-w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both,
+w = TkFrame.new(base_frame).pack(:side=>:bottom, :fill=>:both,
:expand=>true)
# A group of radiobuttons in a labelframe
diff --git a/ext/tk/sample/demos-jp/mclist.rb b/ext/tk/sample/demos-jp/mclist.rb
new file mode 100644
index 0000000000..a7834d2668
--- /dev/null
+++ b/ext/tk/sample/demos-jp/mclist.rb
@@ -0,0 +1,121 @@
+# -*- coding: euc-jp -*-
+#
+# mclist.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget configured as a multi-column listbox.
+#
+# based on "Id: mclist.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($mclist_demo) && $mclist_demo
+ $mclist_demo.destroy
+ $mclist_demo = nil
+end
+
+$mclist_demo = TkToplevel.new {|w|
+ title("Multi-Column List")
+ iconname("mclist")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($mclist_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttk¤È¤Ï¡¤¥Æ¡¼¥Þ»ØÄê²Äǽ¤Ê¿·¤·¤¤¥¦¥£¥¸¥§¥Ã¥È½¸¹ç¤Ç¤¹¡¥\
+Ttk::Treeview¥¦¥£¥¸¥§¥Ã¥È¤Ï\
+Ttk¥¦¥£¥¸¥§¥Ã¥È¥»¥Ã¥È¤Ë´Þ¤Þ¤ì¤ë¥¦¥£¥¸¥§¥Ã¥È¤Î°ì¤Ä¤Ç¡¤\
+¤½¤ì¤¬ÊÝ»ý¤¹¤ëÌÚ¹½Â¤¤Î¥Ç¡¼¥¿¤½¤Î¤â¤Î¤Þ¤Ç¤Ïɽ¼¨¤¹¤ë¤³¤È¤Ê¤¯¡¤\
+¼¨¤·¤¿¤¤¾ðÊó¤ò¥Þ¥ë¥Á¥«¥é¥à¤Çɽ¼¨¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥
+¤³¤Î¥µ¥ó¥×¥ë¤Ï¡¤Ê£¿ô¤Î¥«¥é¥à¤ò»ý¤Ã¤¿¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤òºîÀ®¤¹¤ë´Êñ¤ÊÎã¤Ç¤¹¡¥
+³Æ¥«¥é¥à¤Î¥¿¥¤¥È¥ë(heading)¤ò¥¯¥ê¥Ã¥¯¤¹¤ì¤Ð¡¤\
+¤½¤Î¥«¥é¥à¤Î¾ðÊó¤Ë´ð¤Å¤¤¤Æ¥ê¥¹¥È¤ÎʤÙÂØ¤¨¤¬¤Ê¤µ¤ì¤ë¤Ï¤º¤Ç¤¹¡¥\
+¤Þ¤¿¡¤¥«¥é¥à¤Î¥¿¥¤¥È¥ë´Ö¤Î¶èÀÚ¤êÉôʬ¤ò¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¡¤\
+¥«¥é¥à¤ÎÉý¤òÊѹ¹¤¹¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡¥
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'mclist'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $mclist_demo.destroy
+ $mclist_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+container = Ttk::Frame.new(base_frame)
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(country capital currency),
+ :show=>:headings)
+if Tk.windowingsystem != 'aquq'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+container.pack(:fill=>:both, :expand=>true)
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
+
+## The data we're going to insert
+data = [
+ ['¥¢¥ë¥¼¥ó¥Á¥ó', '¥Ö¥¨¥Î¥¹¥¢¥¤¥ì¥¹', 'ARS'],
+ ['¥ª¡¼¥¹¥È¥é¥ê¥¢', '¥­¥ã¥ó¥Ù¥é', 'AUD'],
+ ['¥Ö¥é¥¸¥ë', '¥Ö¥é¥¸¥ê¥¢', 'BRL'],
+ ['¥«¥Ê¥À', '¥ª¥¿¥ï', 'CAD'],
+ ['Ãæ¹ñ', 'Ë̵þ', 'CNY'],
+ ['¥Õ¥é¥ó¥¹', '¥Ñ¥ê', 'EUR'],
+ ['¥É¥¤¥Ä', '¥Ù¥ë¥ê¥ó', 'EUR'],
+ ['¥¤¥ó¥É', '¥Ë¥å¡¼¥Ç¥ê¡¼', 'INR'],
+ ['¥¤¥¿¥ê¥¢', '¥í¡¼¥Þ', 'EUR'],
+ ['ÆüËÜ', 'Åìµþ', 'JPY'],
+ ['¥á¥­¥·¥³', '¥á¥­¥·¥³¥·¥Æ¥£', 'MXN'],
+ ['¥í¥·¥¢', '¥â¥¹¥¯¥ï', 'RUB'],
+ ['Æî¥¢¥Õ¥ê¥«', '¥×¥ì¥È¥ê¥¢', 'ZAR'],
+ ['±Ñ¹ñ', '¥í¥ó¥É¥ó', 'GBP'],
+ ['¥¢¥á¥ê¥«', '¥ï¥·¥ó¥È¥ó D.C.', 'USD'],
+]
+
+## Code to insert the data nicely
+font = Ttk::Style.lookup(tree[:style], :font)
+cols = %w(country capital currency)
+cols.zip(%w(¹ñ̾ ¼óÅÔ Ä̲ß)).each{|col, name|
+ tree.heading_configure(col, :text=>name,
+ :command=>proc{sort_by(tree, col, false)})
+ tree.column_configure(col, :width=>TkFont.measure(font, name))
+}
+
+data.each{|country, capital, currency|
+ #tree.insert('', :end, :values=>[country, capital, currency])
+ tree.insert(nil, :end, :values=>[country, capital, currency])
+ cols.zip([country, capital, currency]).each{|col, val|
+ len = TkFont.measure(font, "#{val} ")
+ if tree.column_cget(col, :width) < len
+ tree.column_configure(col, :width=>len)
+ end
+ }
+}
+
+## Code to do the sorting of the tree contents when clicked on
+def sort_by(tree, col, direction)
+ tree.children(nil).map!{|row| [tree.get(row, col), row.id]} .
+ sort(&((direction)? proc{|x, y| y <=> x}: proc{|x, y| x <=> y})) .
+ each_with_index{|info, idx| tree.move(info[1], nil, idx)}
+
+ tree.heading_configure(col, :command=>proc{sort_by(tree, col, ! direction)})
+end
diff --git a/ext/tk/sample/demos-jp/menu.rb b/ext/tk/sample/demos-jp/menu.rb
index 6b9e5c9e5e..c3d95176b4 100644
--- a/ext/tk/sample/demos-jp/menu.rb
+++ b/ext/tk/sample/demos-jp/menu.rb
@@ -16,8 +16,10 @@ $menu_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($menu_demo).pack(:fill=>:both, :expand=>true)
+
# menu frame À¸À®
-$menu_frame = TkFrame.new($menu_demo, 'relief'=>'raised', 'bd'=>2)
+$menu_frame = TkFrame.new(base_frame, 'relief'=>'raised', 'bd'=>2)
$menu_frame.pack('side'=>'top', 'fill'=>'x')
begin
@@ -27,7 +29,7 @@ rescue
end
# label À¸À®
-TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
if $tk_platform['platform'] == 'macintosh' ||
windowingsystem == "classic" || windowingsystem == "aqua"
text("¤³¤Î¥¦¥£¥ó¥É¥¦¤ÏÍÍ¡¹¤Ê¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Command-X ¤òÆþÎϤ¹¤ë¤È¡¢X¤¬¥³¥Þ¥ó¥É¥­¡¼µ­¹æ¤Ë³¤¤¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ê¤é¤Ð¡¢¥¢¥¯¥»¥é¥ì¡¼¥¿¤ò»È¤Ã¤¿¹àÌܵ¯Æ°¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼Í×ÁÇÃæ¡¢ºÇ¸å¤Î¤â¤Î¤Ï¡¢¤½¤Î¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤ÇÆÈΩ¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£")
@@ -37,7 +39,7 @@ TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
}.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($menu_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -108,7 +110,8 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
'accelerator'=>"#{modifier}+G", 'underline'=>6)
$menu_demo.bind("#{modifier}-g", proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"})
- TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ # TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_check|
cascade_menu.add('cascade', 'label'=>'Check buttons(¥Á¥§¥Ã¥¯¥Ü¥¿¥ó)',
'menu'=>cascade_check, 'underline'=>0)
oil = TkVariable.new(0)
@@ -130,7 +133,8 @@ TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
invoke 3
}
- TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ #TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_radio|
cascade_menu.add('cascade', 'label'=>'Radio buttons(¥é¥¸¥ª¥Ü¥¿¥ó)',
'menu'=>cascade_radio, 'underline'=>0)
pointSize = TkVariable.new
diff --git a/ext/tk/sample/demos-jp/menu84.rb b/ext/tk/sample/demos-jp/menu84.rb
index 762cfa53b8..a631bacd43 100644
--- a/ext/tk/sample/demos-jp/menu84.rb
+++ b/ext/tk/sample/demos-jp/menu84.rb
@@ -16,6 +16,8 @@ $menu84_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($menu84_demo).pack(:fill=>:both, :expand=>true)
+
begin
windowingsystem = Tk.windowingsystem()
rescue
@@ -23,7 +25,7 @@ rescue
end
# label
-TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
if $tk_platform['platform'] == 'macintosh' ||
windowingsystem == "classic" || windowingsystem == "aqua"
text("¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤ò»ý¤Ä¥á¥Ë¥å¡¼¥Ð¡¼¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤Þ¤¹¡£Command+x ('x'¤Ï¥³¥Þ¥ó¥É¥­¡¼¥·¥ó¥Ü¥ë¤Ë³¤±¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ç¤¹) ¤È¥¿¥¤¥×¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¤â¹àÌܤε¡Ç½¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ºÇ¸å¤Î¥á¥Ë¥å¡¼¤Ï¡¢¥Þ¥¦¥¹¤Ç¥¦¥£¥ó¥É¥¦¤Î³°¤Ë¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢ÆÈΩ¤·¤¿¥Ñ¥ì¥Ã¥È¤È¤Ê¤ë¤è¤¦¤ËÀÚ¤êÊü¤¹¤³¤È¤¬²Äǽ¤Ç¤¹¡£")
@@ -34,7 +36,7 @@ TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
menustatus = TkVariable.new(" ")
-TkFrame.new($menu84_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken',
'bd'=>1, 'font'=>['Helvetica', '10'],
'anchor'=>'w').pack('side'=>'left', 'padx'=>2,
@@ -44,7 +46,7 @@ TkFrame.new($menu84_demo) {|frame|
# frame
-TkFrame.new($menu84_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
diff --git a/ext/tk/sample/demos-jp/menu8x.rb b/ext/tk/sample/demos-jp/menu8x.rb
index 23efa7e790..9249f2491a 100644
--- a/ext/tk/sample/demos-jp/menu8x.rb
+++ b/ext/tk/sample/demos-jp/menu8x.rb
@@ -16,16 +16,18 @@ $menu8x_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($menu8x_demo).pack(:fill=>:both, :expand=>true)
+
# version check
if $tk_version.to_f < 8.0
# label À¸À®
-TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
text("¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¥¹¥¯¥ê¥×¥È¤Ï Tk8.0 °Ê¾å¤ÇÍøÍѤǤ­¤ëµ¡Ç½¤òÍøÍѤ·¤Æ¤¤¤ë¤¿¤á¡¢¤¢¤Ê¤¿¤Î Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} ¤Ç¤ÏÀµ¾ï¤Ë¼Â¹Ô¤Ç¤­¤Þ¤»¤ó¡£¤è¤Ã¤Æ¥Ç¥â¤Î¼Â¹Ô¤òÃæ»ß¤·¤Þ¤·¤¿¡£¤¿¤À¤·¡¢²¼¤Î¥³¡¼¥É»²¾È¥Ü¥¿¥ó¤ò²¡¤¹¤³¤È¤Ç¡¢¼Â¹Ô¤¬Ãæ»ß¤µ¤ì¤¿¥¹¥¯¥ê¥×¥È¤Î¥½¡¼¥¹¤ò»²¾È¤¹¤ë¤³¤È¤Ï²Äǽ¤Ç¤¹¡£")
}.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($menu8x_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -51,7 +53,7 @@ rescue
end
# label À¸À®
-TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
if $tk_platform['platform'] == 'macintosh' ||
windowingsystem == "classic" || windowingsystem == "aqua"
text("¤³¤Î¥¦¥£¥ó¥É¥¦¤ÏÍÍ¡¹¤Ê¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Command-X ¤òÆþÎϤ¹¤ë¤È¡¢X¤¬¥³¥Þ¥ó¥É¥­¡¼µ­¹æ¤Ë³¤¤¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ê¤é¤Ð¡¢¥¢¥¯¥»¥é¥ì¡¼¥¿¤ò»È¤Ã¤¿¹àÌܵ¯Æ°¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼Í×ÁÇÃæ¡¢ºÇ¸å¤Î¤â¤Î¤Ï¡¢¤½¤Î¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤ÇÆÈΩ¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£")
@@ -62,14 +64,14 @@ TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
# ¾õÂÖɽ¼¨¤ÎÀ¸À®
$menu8xstatus = TkVariable.new(" ")
-TkFrame.new($menu8x_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkLabel.new(frame, 'textvariable'=>$menu8xstatus, 'relief'=>'sunken',
'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\
.pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
# frame À¸À®
-TkFrame.new($menu8x_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
diff --git a/ext/tk/sample/demos-jp/menubu.rb b/ext/tk/sample/demos-jp/menubu.rb
index e73c393aa5..90dc367305 100644
--- a/ext/tk/sample/demos-jp/menubu.rb
+++ b/ext/tk/sample/demos-jp/menubu.rb
@@ -33,16 +33,18 @@ $menubu_demo = TkToplevel.new {|w|
positionWindow($menubu_demo)
+base_frame = TkFrame.new($menubu_demo).pack(:fill=>:both, :expand=>true)
+
# version check
if $tk_version.to_f < 8.0
# label À¸À®
-TkLabel.new($menubu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
text("¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¥¹¥¯¥ê¥×¥È¤Ï Tk8.0 °Ê¾å¤ÇÍøÍѤǤ­¤ëµ¡Ç½¤òÍøÍѤ·¤Æ¤¤¤ë¤¿¤á¡¢¤¢¤Ê¤¿¤Î Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} ¤Ç¤ÏÀµ¾ï¤Ë¼Â¹Ô¤Ç¤­¤Þ¤»¤ó¡£¤è¤Ã¤Æ¥Ç¥â¤Î¼Â¹Ô¤òÃæ»ß¤·¤Þ¤·¤¿¡£¤¿¤À¤·¡¢²¼¤Î¥³¡¼¥É»²¾È¥Ü¥¿¥ó¤ò²¡¤¹¤³¤È¤Ç¡¢¼Â¹Ô¤¬Ãæ»ß¤µ¤ì¤¿¥¹¥¯¥ê¥×¥È¤Î¥½¡¼¥¹¤ò»²¾È¤¹¤ë¤³¤È¤Ï²Äǽ¤Ç¤¹¡£")
}.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($menubu_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -61,7 +63,7 @@ TkFrame.new($menubu_demo) {|frame|
else ; # Tk8.x
-body = TkFrame.new($menubu_demo)
+body = TkFrame.new(base_frame)
body.pack('expand'=>'yes', 'fill'=>'both')
below = TkMenubutton.new(body) {
@@ -156,7 +158,7 @@ center = TkFrame.new(body) {
grid('row'=>1, 'column'=>1, 'sticky'=>'news')
}
-TkFrame.new($menubu_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
diff --git a/ext/tk/sample/demos-jp/msgbox.rb b/ext/tk/sample/demos-jp/msgbox.rb
index 0fe5db7dd6..88380e08bd 100644
--- a/ext/tk/sample/demos-jp/msgbox.rb
+++ b/ext/tk/sample/demos-jp/msgbox.rb
@@ -16,12 +16,14 @@ $msgbox_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($msgbox_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
- 'text'=>"ɽ¼¨¤¹¤ë¥¢¥¤¥³¥ó¤È¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Î¼ïÎà¤òÁª¤ó¤Ç²¼¤µ¤¤¡£¤½¤·¤Æ \"¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\" ¥Ü¥¿¥ó¤ò²¡¤¹¤È¡¢»ØÄꤷ¤¿¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£").pack('side'=>'top')
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"¤Þ¤ºÉ½¼¨¤¹¤ë¥¢¥¤¥³¥ó¤È¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Î¼ïÎà¤òÁª¤ó¤Ç²¼¤µ¤¤¡£¤½¤Î¸å¤Ë\"¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\"¥Ü¥¿¥ó¤ò²¡¤¹¤È¡¢»ØÄꤷ¤¿¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£").pack('side'=>'top')
# frame À¸À®
-TkFrame.new($msgbox_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -44,8 +46,8 @@ TkFrame.new($msgbox_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame À¸À®
-$msgbox_leftframe = TkFrame.new($msgbox_demo)
-$msgbox_rightframe = TkFrame.new($msgbox_demo)
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
'pady'=>'.5c', 'padx'=>'.5c')
$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
@@ -79,7 +81,7 @@ $msgboxType = TkVariable.new('ok')
def showMessageBox(w)
button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
'title'=>'Message', 'parent'=>w,
- 'message'=>"¤³¤ì¤Ï \"#{$msgboxType.value}\" ¤È¤¤¤¦¼ïÎà¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Ç¡¢\"#{$msgboxIcon.value}\" ¤Î¥¢¥¤¥³¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£")
+ 'message'=>"¤³¤ì¤Ï\"#{$msgboxType.value}\"¤È¤¤¤¦¼ïÎà¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Ç¡¢\"#{$msgboxIcon.value}\"¤Î¥¢¥¤¥³¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£")
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
'message'=>"¤¢¤Ê¤¿¤Ï \"#{button}\" ¤ò²¡¤·¤Þ¤·¤¿¤Í¡£")
diff --git a/ext/tk/sample/demos-jp/msgbox2.rb b/ext/tk/sample/demos-jp/msgbox2.rb
new file mode 100644
index 0000000000..d61f25129a
--- /dev/null
+++ b/ext/tk/sample/demos-jp/msgbox2.rb
@@ -0,0 +1,90 @@
+# -*- coding: euc-jp -*-
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($msgbox2_demo) && $msgbox2_demo
+ $msgbox2_demo.destroy
+ $msgbox2_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$msgbox2_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($msgbox2_demo).pack(:fill=>:both, :expand=>true)
+
+# label À¸À®
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"¤Þ¤ºÉ½¼¨¤¹¤ë¥¢¥¤¥³¥ó¤È¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Î¼ïÎà¤òÁª¤ó¤Ç²¼¤µ¤¤¡£¤½¤Î¸å¤Ë\"¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\"¥Ü¥¿¥ó¤ò²¡¤¹¤È¡¢»ØÄꤵ¤ì¤¿·Á¼°¤Ç¡¢¥á¥Ã¥»¡¼¥¸¤È¾ÜºÙ¥Æ¥­¥¹¥È¤È¤ò»ý¤Ã¤¿¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£").pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $msgbox2_demo
+ $msgbox2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'msgbox2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹'
+ command proc{showMessageBox $msgbox2_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'¥¢¥¤¥³¥ó').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'¼ïÎà').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"\"#{$msgboxType.value}\"¥¿¥¤¥×¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹",
+ 'detail'=>"¤³¤ì¤Ï\"#{$msgboxType.value}\"¤È¤¤¤¦¼ïÎà¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Ç¡¢\"#{$msgboxIcon.value}\"¤Î¥¢¥¤¥³¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£²¼¤Î¥Ü¥¿¥ó¤Î¤¤¤º¤ì¤«¤òÁªÂò¤·¤Æ¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"¤¢¤Ê¤¿¤Ï \"#{button}\" ¤ò²¡¤·¤Þ¤·¤¿¤Í¡£")
+end
+
diff --git a/ext/tk/sample/demos-jp/paned1.rb b/ext/tk/sample/demos-jp/paned1.rb
index 137e187417..f994e83ff1 100644
--- a/ext/tk/sample/demos-jp/paned1.rb
+++ b/ext/tk/sample/demos-jp/paned1.rb
@@ -18,7 +18,9 @@ $paned1_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($paned1_demo,
+base_frame = TkFrame.new($paned1_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
²¼¤Î¿§ÉÕ¤±¤µ¤ì¤¿Æó¤Ä¤Î¥¦¥£¥ó¥É¥¦¤Î´Ö¤Î»ÅÀÚ¤êÏȤϡ¢°ì¤Ä¤ÎÎΰè¤ò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦¤Î¤¿¤á¤Ëʬ³ä¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£º¸¥Ü¥¿¥ó¤Ç»ÅÀÚ¤ê¤òÁàºî¤¹¤ë¤È¡¢Ê¬³ä¥µ¥¤¥ºÊѹ¹¤ÎÁàºîÅÓÃæ¤Ç¤ÏºÆÉ½¼¨¤Ï¤Ê¤µ¤ì¤º¡¢³ÎÄꤵ¤»¤¿¤È¤­¤Ëɽ¼¨¤¬¹¹¿·¤µ¤ì¤Þ¤¹¡£¥Þ¥¦¥¹¤Ë¤è¤ë»ÅÀÚ¤ê¤ÎÁàºî¤ËÄɿ路¤Æ¥µ¥¤¥º¤òÊѹ¹¤·¤¿É½¼¨¤¬¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Þ¥¦¥¹¤ÎÃæ±û¥Ü¥¿¥ó¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£
@@ -29,7 +31,7 @@ TkLabel.new($paned1_demo,
EOL
# The bottom buttons
-TkFrame.new($paned1_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
@@ -42,9 +44,9 @@ TkFrame.new($paned1_demo){|f|
}).pack(:side=>:left, :expand=>true)
}
-TkPanedwindow.new($paned1_demo){|f|
- pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+TkPanedwindow.new(base_frame, :orient=>:horizontal){|f|
+ add(Tk::Label.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
+ Tk::Label.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
- add(TkLabel.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
- TkLabel.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
}
diff --git a/ext/tk/sample/demos-jp/paned2.rb b/ext/tk/sample/demos-jp/paned2.rb
index b394432b1c..cdc8253402 100644
--- a/ext/tk/sample/demos-jp/paned2.rb
+++ b/ext/tk/sample/demos-jp/paned2.rb
@@ -18,7 +18,9 @@ $paned2_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($paned2_demo,
+base_frame = TkFrame.new($paned2_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
²¼¤Î¥¹¥¯¥í¡¼¥ë¥Ð¡¼ÉÕ¤­¤Î¥¦¥£¥¸¥§¥Ã¥È¤¬ÃÖ¤«¤ì¤¿Æó¤Ä¤Î¥¦¥£¥ó¥É¥¦¤Î´Ö¤Î»ÅÀÚ¤êÏȤϡ¢°ì¤Ä¤ÎÎΰè¤ò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦¤Î¤¿¤á¤Ëʬ³ä¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£º¸¥Ü¥¿¥ó¤Ç»ÅÀÚ¤ê¤òÁàºî¤¹¤ë¤È¡¢Ê¬³ä¥µ¥¤¥ºÊѹ¹¤ÎÁàºîÅÓÃæ¤Ç¤ÏºÆÉ½¼¨¤Ï¤Ê¤µ¤ì¤º¡¢³ÎÄꤵ¤»¤¿¤È¤­¤Ëɽ¼¨¤¬¹¹¿·¤µ¤ì¤Þ¤¹¡£¥Þ¥¦¥¹¤Ë¤è¤ë»ÅÀÚ¤ê¤ÎÁàºî¤ËÄɿ路¤Æ¥µ¥¤¥º¤òÊѹ¹¤·¤¿É½¼¨¤¬¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Þ¥¦¥¹¤ÎÃæ±û¥Ü¥¿¥ó¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£
@@ -29,7 +31,7 @@ TkLabel.new($paned2_demo,
EOL
# The bottom buttons
-TkFrame.new($paned2_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
@@ -66,7 +68,7 @@ paneList.value = [ # ruby's array --> tcl's list
]
# Create the pane itself
-TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
+TkPanedwindow.new(base_frame, :orient=>:vertical){|f|
pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
add(TkFrame.new(f){|paned2_top|
diff --git a/ext/tk/sample/demos-jp/pendulum.rb b/ext/tk/sample/demos-jp/pendulum.rb
index e19b57a2d6..b115f5be2c 100644
--- a/ext/tk/sample/demos-jp/pendulum.rb
+++ b/ext/tk/sample/demos-jp/pendulum.rb
@@ -19,8 +19,10 @@ $pendulum_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($pendulum_demo).pack(:fill=>:both, :expand=>true)
+
# create label
-msg = TkLabel.new($pendulum_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -29,7 +31,7 @@ msg = TkLabel.new($pendulum_demo) {
msg.pack('side'=>'top')
# create frame
-TkFrame.new($pendulum_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -51,7 +53,7 @@ TkFrame.new($pendulum_demo) {|frame|
class PendulumAnimationDemo
def initialize(frame)
# Create some structural widgets
- @pane = TkPanedWindow.new(frame).pack(:fill=>:both, :expand=>true)
+ @pane = TkPanedWindow.new(frame, :orient=>:horizontal).pack(:fill=>:both, :expand=>true)
# @pane.add(@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation'))
# @pane.add(@lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space'))
@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation')
@@ -237,4 +239,4 @@ class PendulumAnimationDemo
end
# Start the animation processing
-PendulumAnimationDemo.new($pendulum_demo)
+PendulumAnimationDemo.new(base_frame)
diff --git a/ext/tk/sample/demos-jp/plot.rb b/ext/tk/sample/demos-jp/plot.rb
index 09a3446836..9ff71904cd 100644
--- a/ext/tk/sample/demos-jp/plot.rb
+++ b/ext/tk/sample/demos-jp/plot.rb
@@ -16,14 +16,16 @@ $plot_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($plot_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï´Êñ¤Ê2¼¡¸µ¤Î¥×¥í¥Ã¥È¤ò´Þ¤ó¤À¥­¥ã¥ó¥Ð¥¹ widget¤Ç¤¹¡£É½¼¨¤µ¤ì¤¿ÅÀ¤ò¥Þ¥¦¥¹¥Ü¥¿¥ó1¤Ç¥É¥é¥Ã¥°¤·¤Æ¥Ç¡¼¥¿¤ò¤¤¤¸¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$plot_buttons = TkFrame.new($plot_demo) {|frame|
+$plot_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -42,10 +44,14 @@ $plot_buttons = TkFrame.new($plot_demo) {|frame|
$plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# font ÀßÄê
-plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ if $tk_version =~ /^4.*/
+ plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ else
+ font = 'Helvetica 18'
+ end
# canvas ÀßÄê
-$plot_canvas = TkCanvas.new($plot_demo,'relief'=>'raised','width'=>450,'height'=>300)
+$plot_canvas = TkCanvas.new(base_frame,'relief'=>'raised','width'=>450,'height'=>300)
$plot_canvas.pack('side'=>'top', 'fill'=>'x')
# plot À¸À®
diff --git a/ext/tk/sample/demos-jp/puzzle.rb b/ext/tk/sample/demos-jp/puzzle.rb
index 6a3c8c8ef6..2febc2c55a 100644
--- a/ext/tk/sample/demos-jp/puzzle.rb
+++ b/ext/tk/sample/demos-jp/puzzle.rb
@@ -16,8 +16,10 @@ $puzzle_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($puzzle_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($puzzle_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($puzzle_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($puzzle_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -51,18 +53,27 @@ TkFrame.new($puzzle_demo) {|frame|
#
begin
if Tk.windowingsystem() == 'aqua'
- frameSize = 160
+ frameWidth = 168
+ frameHeight = 168
+ elsif Tk.default_widget_set == :Ttk
+ frameWidth = 148
+ frameHeight = 124
else
- frameSize = 120
+ frameWidth = 120
+ frameHeight = 120
end
rescue
- frameSize = 120
+ frameWidth = 120
+ frameHeight = 120
end
+
+# depend_on_button_width = true
+depend_on_button_width = false
-s = TkScrollbar.new($puzzle_demo)
-base = TkFrame.new($puzzle_demo) {
- width frameSize
- height frameSize
+s = TkScrollbar.new(base_frame)
+base = TkFrame.new(base_frame) {
+ width frameWidth
+ height frameHeight
borderwidth 2
relief 'sunken'
bg s['troughcolor']
@@ -89,6 +100,9 @@ order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12]
text num
highlightthickness 0
command def_puzzleswitch_proc(w, num)
+ if depend_on_button_width && (w.winfo_reqwidth * 4 > base.width)
+ base.width = w.winfo_reqwidth * 4
+ end
}.place('relx'=>$xpos[num], 'rely'=>$ypos[num],
'relwidth'=>0.25, 'relheight'=>0.25)
}
diff --git a/ext/tk/sample/demos-jp/radio.rb b/ext/tk/sample/demos-jp/radio.rb
index 3a11c394a3..a61ad46d9b 100644
--- a/ext/tk/sample/demos-jp/radio.rb
+++ b/ext/tk/sample/demos-jp/radio.rb
@@ -16,8 +16,10 @@ $radio_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($radio_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($radio_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -30,7 +32,7 @@ size = TkVariable.new
color = TkVariable.new
# frame À¸À®
-TkFrame.new($radio_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -50,14 +52,14 @@ TkFrame.new($radio_demo) {|frame|
TkButton.new(frame) {
text 'ÊÑ¿ô»²¾È'
command proc{
- showVars($radio_demo, ['size', size], ['color', color])
+ showVars(base_frame, ['size', size], ['color', color])
}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame À¸À®
-f_left = TkFrame.new($radio_demo)
-f_right = TkFrame.new($radio_demo)
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
diff --git a/ext/tk/sample/demos-jp/radio2.rb b/ext/tk/sample/demos-jp/radio2.rb
index b89520cdc5..cf53e3e485 100644
--- a/ext/tk/sample/demos-jp/radio2.rb
+++ b/ext/tk/sample/demos-jp/radio2.rb
@@ -21,8 +21,10 @@ $radio2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($radio2_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($radio2_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -36,7 +38,7 @@ color = TkVariable.new
align = TkVariable.new
# frame
-TkFrame.new($radio2_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -56,18 +58,18 @@ TkFrame.new($radio2_demo) {|frame|
TkButton.new(frame) {
text 'ÊÑ¿ô»²¾È'
command proc{
- showVars($radio2_demo,
+ showVars(base_frame,
['size', size], ['color', color], ['compound', align])
}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
-f_left = TkLabelFrame.new($radio2_demo, 'text'=>'ʸ»ú¥µ¥¤¥º',
+f_left = TkLabelFrame.new(base_frame, 'text'=>'ʸ»ú¥µ¥¤¥º',
'pady'=>2, 'padx'=>2)
-f_mid = TkLabelFrame.new($radio2_demo, 'text'=>'¿§',
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'¿§',
'pady'=>2, 'padx'=>2)
-f_right = TkLabelFrame.new($radio2_demo, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ',
+f_right = TkLabelFrame.new(base_frame, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ',
'pady'=>2, 'padx'=>2)
f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
@@ -93,7 +95,8 @@ f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
}.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
}
-label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
+# label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
'compound'=>'left')
label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
label.height(TkWinfo.reqheight(label))
diff --git a/ext/tk/sample/demos-jp/radio3.rb b/ext/tk/sample/demos-jp/radio3.rb
index a223a19bc2..4bbc1b31f5 100644
--- a/ext/tk/sample/demos-jp/radio3.rb
+++ b/ext/tk/sample/demos-jp/radio3.rb
@@ -21,8 +21,10 @@ $radio3_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($radio3_demo).pack(:fill=>:both, :expand=>true)
+
# label
-msg = TkLabel.new($radio3_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '5i'
justify 'left'
@@ -36,14 +38,14 @@ color = TkVariable.new
align = TkVariable.new
# frame
-TkFrame.new($radio3_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È',
:image=>$image['view'], :compound=>:left,
:command=>proc{
- showVars($radio3_demo, ['size', size],
+ showVars(base_frame, ['size', size],
['color', color], ['compound', align])
}),
TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È',
@@ -63,17 +65,17 @@ TkFrame.new($radio3_demo) {|frame|
}
# frame
-f_left = TkLabelFrame.new($radio3_demo, 'text'=>'ʸ»ú¥µ¥¤¥º',
+f_left = TkLabelFrame.new(base_frame, 'text'=>'ʸ»ú¥µ¥¤¥º',
'pady'=>2, 'padx'=>2)
-f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'¿§',
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'¿§',
'pady'=>2, 'padx'=>2)
-f_right = TkLabelFrame.new($radio3_demo, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ',
+f_right = TkLabelFrame.new(base_frame, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ',
'pady'=>2, 'padx'=>2)
f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
-TkButton.new($radio3_demo, 'text'=>'¥È¥é¥¤¥¹¥Æ¡¼¥È',
+TkButton.new(base_frame, 'text'=>'¥È¥é¥¤¥¹¥Æ¡¼¥È',
'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
}
@@ -101,7 +103,8 @@ TkButton.new($radio3_demo, 'text'=>'¥È¥é¥¤¥¹¥Æ¡¼¥È',
}.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
}
-label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
+# label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
'compound'=>'left')
label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
label.height(TkWinfo.reqheight(label))
diff --git a/ext/tk/sample/demos-jp/ruler.rb b/ext/tk/sample/demos-jp/ruler.rb
index c913e247d1..d6bc9e76d1 100644
--- a/ext/tk/sample/demos-jp/ruler.rb
+++ b/ext/tk/sample/demos-jp/ruler.rb
@@ -29,14 +29,16 @@ $ruler_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
'text'=>"¤³¤Î¥­¥ã¥ó¥Ð¥¹widget¤Ï¥ë¡¼¥é¡¼¤ÎÌÏ·¿¤Ç¤¹¡£¥ë¡¼¥é¡¼¤Î±¦¤Ë¤¢¤ë¤Î¤Ï¥¿¥Ö¥¹¥È¥Ã¥×¤Î°æ¸Í¤Ç¡¢¤³¤³¤«¤é°ú¤ÃÄ¥¤Ã¤Æ¤¯¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥¿¥Ö¥¹¥È¥Ã¥×¤òºî¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤Þ¤¿¡¢¤¹¤Ç¤Ë¤¢¤ë¥¿¥Ö¥¹¥È¥Ã¥×¤òư¤«¤¹¤³¤È¤â¤Ç¤­¤Þ¤¹¡£¥¿¥Ö¥¹¥È¥Ã¥×¤ò¾åÊý¤Þ¤¿¤Ï²¼Êý¤Ë¤«¤¹¤ì¤ÆÉ½¼¨¤µ¤ì¤ë¤Þ¤Ç¥É¥é¥Ã¥°¤¹¤ë¤È¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤òÎ¥¤·¤¿»þ¤Ë¤½¤Î¥¿¥Ö¥¹¥È¥Ã¥×¤Ï¾Ã¤¨¤Þ¤¹¡£"){
pack('side'=>'top')
}
# frame À¸À®
-$ruler_buttons = TkFrame.new($ruler_demo) {|frame|
+$ruler_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -55,7 +57,7 @@ $ruler_buttons = TkFrame.new($ruler_demo) {|frame|
$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# canvas ÀßÄê
-$ruler_canvas = TkCanvas.new($ruler_demo, 'width'=>'14.8c', 'height'=>'2.5c')
+$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c')
$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
# ÃÍÀßÄê
diff --git a/ext/tk/sample/demos-jp/sayings.rb b/ext/tk/sample/demos-jp/sayings.rb
index 24b011f5ab..aa24b3a2ad 100644
--- a/ext/tk/sample/demos-jp/sayings.rb
+++ b/ext/tk/sample/demos-jp/sayings.rb
@@ -16,8 +16,10 @@ $sayings_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($sayings_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($sayings_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($sayings_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($sayings_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -46,7 +48,7 @@ TkFrame.new($sayings_demo) {|frame|
# frame À¸À®
sayings_lbox = nil
-TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w|
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
sv = TkScrollbar.new(w)
sh = TkScrollbar.new(w, 'orient'=>'horizontal')
sayings_lbox = TkListbox.new(w) {
diff --git a/ext/tk/sample/demos-jp/search.rb b/ext/tk/sample/demos-jp/search.rb
index adb72fd809..9838ff5d19 100644
--- a/ext/tk/sample/demos-jp/search.rb
+++ b/ext/tk/sample/demos-jp/search.rb
@@ -75,8 +75,10 @@ $search_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($search_demo).pack(:fill=>:both, :expand=>true)
+
# frame À¸À®
-$search_buttons = TkFrame.new($search_demo) {|frame|
+$search_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -95,7 +97,7 @@ $search_buttons = TkFrame.new($search_demo) {|frame|
$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame À¸À®
-TkFrame.new($search_demo) {|f|
+TkFrame.new(base_frame) {|f|
TkLabel.new(f, 'text'=>'¥Õ¥¡¥¤¥ë̾:',
'width'=>13, 'anchor'=>'w').pack('side'=>'left')
$search_fileName = TkVariable.new
@@ -112,7 +114,7 @@ TkFrame.new($search_demo) {|f|
.pack('side'=>'left', 'pady'=>5, 'padx'=>10)
}.pack('side'=>'top', 'fill'=>'x')
-TkFrame.new($search_demo) {|f|
+TkFrame.new(base_frame) {|f|
TkLabel.new(f, 'text'=>'¸¡º÷ʸ»úÎó:',
'width'=>13, 'anchor'=>'w').pack('side'=>'left')
$search_searchString = TkVariable.new
@@ -130,9 +132,9 @@ TkFrame.new($search_demo) {|f|
}
}.pack('side'=>'top', 'fill'=>'x')
-$search_text = TkText.new($search_demo, 'setgrid'=>true) {|t|
+$search_text = TkText.new(base_frame, 'setgrid'=>true) {|t|
$search_Tag = TkTextTag.new(t)
- TkScrollbar.new($search_demo, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
t.yscrollcommand(proc{|first,last| sc.set first,last})
pack('side'=>'right', 'fill'=>'y')
}
@@ -169,9 +171,14 @@ $search_text.insert('1.0', "\
¥¨¥ó¥È¥ê¤Ëʸ»úÎó¤òÆþÎϤ·¡¢<¥ê¥¿¡¼¥ó> ¤ò²¡¤¹¤«¡Öȿž¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯ \
¤À¤µ¤¤¡£¤¹¤ë¤È¥Õ¥¡¥¤¥ëÃæ¤Î¡¢¸¡º÷ʸ»úÎó¤È°ìÃפ¹¤ëÉôʬ¤ËÁ´¤Æ \"search_Tag\" \
¤È¤¤¤¦¥¿¥°¤¬¤Ä¤±¤é¤ì¡¢¥¿¥°¤Îɽ¼¨Â°À­¤È¤·¤Æ¤½¤Îʸ»úÎó¤¬ÅÀÌǤ¹¤ë¤è¤¦¤Ë \
-ÀßÄꤵ¤ì¤Þ¤¹¡£")
+ÀßÄꤵ¤ì¤Þ¤¹¡£\n")
+$search_text.insert('end', "\
+¥Õ¥¡¥¤¥ëÆÉ¤ß¹þ¤ß¤Î¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤Ï \"#{Dir.pwd}\" ¤Ç¤¹¡£\
+")
$search_text.set_insert '0.0'
$search_fileName.value = ''
$search_searchString.value = ''
+$search_text.width = 60
+$search_text.height = 20
diff --git a/ext/tk/sample/demos-jp/spin.rb b/ext/tk/sample/demos-jp/spin.rb
index b8eb99c4ed..8d4e33cda0 100644
--- a/ext/tk/sample/demos-jp/spin.rb
+++ b/ext/tk/sample/demos-jp/spin.rb
@@ -17,10 +17,12 @@ $spin_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($spin_demo,
+base_frame = TkFrame.new($spin_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
-²¼¤Ë¤Ï£³¼ïÎà¤Î¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\
+²¼¤Ë¤Ï£³¼ïÎà¤Î¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤½¤ì¤¾¤ì¡¢¥Þ¥¦¥¹¤ÇÁªÂò¤·¤ÆÊ¸»ú¤òÆþÎϤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
ÊÔ½¸Áàºî¤È¤·¤Æ¤Ï¡¢Emacs ·Á¼°¤Î¿¤¯¤Ë²Ã¤¨¤Æ¡¢°ìÈÌŪ¤Ê
Motif ·Á¼°¤Î¥­¡¼Áàºî¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢
@@ -40,7 +42,7 @@ Backspace ¤È Control-h ¤È¤ÏÆþÎÏ¥«¡¼¥½¥ë¤Îº¸Â¦¤Îʸ»ú¤ò
¤òÁȤ߹ç¤ï¤»¤Æ»î¤¹¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
EOL
-TkFrame.new($spin_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
@@ -59,11 +61,11 @@ australianCities = [
]
[
- TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
+ TkSpinbox.new(base_frame, :from=>1, :to=>10, :width=>10, :validate=>:key,
:validatecommand=>[
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
]),
- TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5,
+ TkSpinbox.new(base_frame, :from=>0, :to=>3, :increment=>0.5,
:format=>'%05.2f', :width=>10),
- TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10)
+ TkSpinbox.new(base_frame, :values=>australianCities, :width=>10)
].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}
diff --git a/ext/tk/sample/demos-jp/states.rb b/ext/tk/sample/demos-jp/states.rb
index 3c58711bd1..5e242b7c38 100644
--- a/ext/tk/sample/demos-jp/states.rb
+++ b/ext/tk/sample/demos-jp/states.rb
@@ -16,8 +16,10 @@ $states_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true)
+
# label À¸À®
-msg = TkLabel.new($states_demo) {
+msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
@@ -26,7 +28,7 @@ msg = TkLabel.new($states_demo) {
msg.pack('side'=>'top')
# frame À¸À®
-TkFrame.new($states_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -46,7 +48,7 @@ TkFrame.new($states_demo) {|frame|
# frame À¸À®
states_lbox = nil
-TkFrame.new($states_demo, 'borderwidth'=>'.5c') {|w|
+TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w|
s = TkScrollbar.new(w)
states_lbox = TkListbox.new(w) {
setgrid 1
diff --git a/ext/tk/sample/demos-jp/style.rb b/ext/tk/sample/demos-jp/style.rb
index 50855a549a..66b6de0251 100644
--- a/ext/tk/sample/demos-jp/style.rb
+++ b/ext/tk/sample/demos-jp/style.rb
@@ -9,6 +9,7 @@ if defined?($style_demo) && $style_demo
$style_demo = nil
end
+
# demo ÍѤΠtoplevel widget ¤òÀ¸À®
$style_demo = TkToplevel.new {|w|
title("Text Demonstration - Display Styles")
@@ -16,8 +17,10 @@ $style_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($style_demo).pack(:fill=>:both, :expand=>true)
+
# frame À¸À®
-TkFrame.new($style_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -34,14 +37,16 @@ TkFrame.new($style_demo) {|frame|
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
# text À¸À®
-TkText.new($style_demo){|t|
+txt = TkText.new(base_frame){|t|
# À¸À®
setgrid 'true'
- width 70
- height 32
+ #width 70
+ #height 32
wrap 'word'
- TkScrollbar.new($style_demo) {|s|
+ font $font
+ TkScrollbar.new(base_frame) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
@@ -49,11 +54,20 @@ TkText.new($style_demo){|t|
pack('expand'=>'yes', 'fill'=>'both')
# ¥Æ¥­¥¹¥È¥¿¥°ÀßÄê (¥Õ¥©¥ó¥È´ØÏ¢)
- style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
- style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+ family = 'Courier'
+
+ if $tk_version =~ /^4.*/
+ style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
+ style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
-# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+ # style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+ else
+ style_tag_bold = TkTextTag.new(t, 'font'=>[family, 12, :bold, :italic])
+ style_tag_big = TkTextTag.new(t, 'font'=>[family, 14, :bold])
+ style_tag_verybig = TkTextTag.new(t, 'font'=>['Helvetica', 24, :bold])
+ style_tag_small = TkTextTag.new(t, 'font'=>'Times 8 bold')
+ end
###
# case($tk_version)
# when /^4.*/
@@ -107,8 +121,13 @@ TkText.new($style_demo){|t|
style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
style_tag_right = TkTextTag.new(t, 'justify'=>'right')
style_tag_center = TkTextTag.new(t, 'justify'=>'center')
- style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
- style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ if $tk_version =~ /^4.*/
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ else
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>[family, 10])
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>[family, 10])
+ end
style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
'rmargin'=>'10m')
style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
@@ -247,3 +266,5 @@ spacing3')
}
+txt.width 70
+txt.height 32
diff --git a/ext/tk/sample/demos-jp/text.rb b/ext/tk/sample/demos-jp/text.rb
index 25e0e64e9a..0ae480eb00 100644
--- a/ext/tk/sample/demos-jp/text.rb
+++ b/ext/tk/sample/demos-jp/text.rb
@@ -16,6 +16,8 @@ $text_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($text_demo).pack(:fill=>:both, :expand=>true)
+
# version check
if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0)
undo_support = false
@@ -24,7 +26,7 @@ else
end
# frame À¸À®
-TkFrame.new($text_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -42,13 +44,13 @@ TkFrame.new($text_demo) {|frame|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# text À¸À®
-TkText.new($text_demo){|t|
+TkText.new(base_frame){|t|
# À¸À®
relief 'sunken'
bd 2
setgrid 1
height 30
- TkScrollbar.new($text_demo) {|s|
+ TkScrollbar.new(base_frame) {|s|
pack('side'=>'right', 'fill'=>'y')
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
diff --git a/ext/tk/sample/demos-jp/textpeer.rb b/ext/tk/sample/demos-jp/textpeer.rb
new file mode 100644
index 0000000000..4967a99c92
--- /dev/null
+++ b/ext/tk/sample/demos-jp/textpeer.rb
@@ -0,0 +1,82 @@
+# -*- coding: euc-jp -*-
+#
+# text widget peering demo (called by 'widget')
+#
+# based on Tcl/Tk8.5.0 widget demos
+
+if defined?($textpeer_demo) && $textpeer_demo
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+end
+
+# demo toplevel widget
+$textpeer_demo = TkToplevel.new {|w|
+ title("Text Wdget Peering Demonstration")
+ iconname("textpeer")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($textpeer_demo).pack(:fill=>:both, :expand=>true)
+
+count = [0]
+
+## Define a widget that we peer from; it won't ever actually be shown though
+first = TkText.new(base_frame, :widgetname=>"text#{count[0] += 1}")
+first.insert :end,"¤³¤Î¥Ç¥â¤Ï°ì¤Ä¤ÎÁȤòÀ®¤·¤¿¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤ò¼¨¤·¤Þ¤¹¡£"
+first.insert :end,"¤½¤ì¤é¤Î¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤ÏÂÐÅù(¥Ô¥¢;peer)¤Î´Ø·¸¤Ë"
+first.insert :end,"¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£"
+first.insert :end,"¤½¤ì¤é¤Ï¡¢´ðÈפȤʤë¥Ç¡¼¥¿¥â¥Ç¥ë¤Ï¶¦Ä̤Τâ¤Î¤ò»ý¤Á¤Þ¤¹¤¬¡¢"
+first.insert :end,"²èÌÌɽ¼¨°ÌÃÖ¡¢ÊÔ½¸°ÌÃÖ¡¢ÁªÂòÈϰÏ(selection)¤Ë¤Ä¤¤¤Æ¤Ï"
+first.insert :end,"ÆÈΩ¤Ë»ý¤Ä¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"
+first.insert :end,"³Æ¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤ÎÏÆ¤Ë¤¢¤ë"
+first.insert :end,"¡Ö¥Ô¥¢(peer)¤ÎºîÀ®¡×¥Ü¥¿¥ó¤ò»È¤¨¤Ð¡¢"
+first.insert :end,"¿·¤¿¤Ê¥Ô¥¢¤òÄɲ乤뤳¤È¤¬²Äǽ¤Ç¤¹¡£"
+first.insert :end,"¤Þ¤¿¡Ö¥Ô¥¢(peer)¤Î¾Ãµî¡×¥Ü¥¿¥ó¤ò»È¤¨¤Ð¡¢"
+first.insert :end,"ÆÃÄê¤Î¥Ô¥¢¥¦¥£¥¸¥§¥Ã¥È¤ò¾Ãµî¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£"
+
+Tk.update_idletasks ## for 'first' widget
+
+## Procedures to make and kill clones; most of this is just so that the demo
+## looks nice...
+def makeClone(count, win, txt)
+ cnt = (count[0] += 1)
+ peer = TkText::Peer.new(txt, win, :widgetname=>"text#{cnt}")
+ sbar = TkScrollbar.new(win, :widgetname=>"sb#{cnt}")
+ peer.yscrollbar sbar
+ b1 = TkButton.new(win, :widgetname=>"clone#{cnt}",
+ :text=>'¥Ô¥¢(peer)¤ÎºîÀ®',
+ :command=>proc{makeClone(count, win, peer)})
+ b2 = TkButton.new(win, :widgetname=>"kill#{cnt}",
+ :text=>'¥Ô¥¢(peer)¤Î¾Ãµî',
+ :command=>proc{killClone(win, cnt)})
+ row = cnt * 2
+ TkGrid.configure(peer, sbar, b1, :sticky=>'nsew', :row=>row)
+ TkGrid.configure('^', '^', b2, :sticky=>'nsew', :row=>(row+=1))
+ TkGrid.configure(b1, b2, :sticky=>'new')
+ TkGrid.rowconfigure(win, b2, :weight=>1)
+end
+
+def killClone(win, cnt)
+ Tk.destroy("#{win.path}.text#{cnt}", "#{win.path}.sb#{cnt}",
+ "#{win.path}.clone#{cnt}", "#{win.path}.kill#{cnt}")
+end
+
+## Now set up the GUI
+makeClone(count, base_frame, first)
+makeClone(count, base_frame, first)
+first.destroy
+
+## See Code / Dismiss buttons
+TkFrame.new(base_frame){|f|
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'textpeer'
+ }).pack(:side=>:left, :expand=>true)
+
+ TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000)
+}
+TkGrid.columnconfigure(base_frame, 0, :weight=>1)
diff --git a/ext/tk/sample/demos-jp/toolbar.rb b/ext/tk/sample/demos-jp/toolbar.rb
new file mode 100644
index 0000000000..9cb3834c34
--- /dev/null
+++ b/ext/tk/sample/demos-jp/toolbar.rb
@@ -0,0 +1,136 @@
+# -*- coding: euc-jp -*-
+#
+# toolbar.rb --
+#
+# This demonstration script creates a toolbar that can be torn off.
+#
+# based on "Id: toolbar.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($toolbar_demo) && $toolbar_demo
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+end
+
+$toolbar_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("toolbar")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($toolbar_demo).pack(:fill=>:both, :expand=>true)
+
+if Tk.windowingsystem != 'aqua'
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><<EOL)
+¤³¤Î¥Ç¥â¤Ç¤Ï¡¤¥Ä¡¼¥ë¥Ð¡¼¤ò¤É¤Î¤è¤¦¤Ë¤·¤ÆÅ¬Àڤ˥ơ¼¥ÞÂбþ¤µ¤»¤ë¤«¡¤\
+¤Þ¤¿¡¤¤É¤Î¤è¤¦¤Ë¤·¤ÆÀÚ¤êÎ¥¤·²Äǽ¤Ë¤¹¤ë¤«¤ò¼¨¤·¤Æ¤¤¤Þ¤¹\
+¡Ê¤¿¤À¤·¡¤¥Ä¡¼¥ë¥Ð¡¼¤ÎÀÚ¤êÎ¥¤·¤Ë¤ÏTcl/Tk8.5°Ê¾å¤Îµ¡Ç½¤¬É¬ÍפǤ¹¡Ë¡¥\
+¥Ä¡¼¥ë¥Ð¡¼¤Î¥Ü¥¿¥ó¤Ï¡¤'Toolbutton'¥¹¥¿¥¤¥ë¤ò»ÈÍѤ¹¤ë¤è¤¦¤ËÌÀ¼¨¤¹¤ë¤³¤È¤Ç¡¤\
+"toolbar style"¥Ü¥¿¥ó¤È¤Ê¤ë¤è¤¦¤Ë°À­ÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡¥\
+¥Ä¡¼¥ë¥Ð¡¼¤Îº¸Ã¼¤Ë¤Ï´Êñ¤Ê¥Þ¡¼¥«¡¼¤¬ÃÖ¤«¤ì¤Æ¤¤¤Þ¤¹¡¥\
+¥Þ¡¼¥«¡¼¾å¤Ë¥Þ¥¦¥¹¥«¡¼¥½¥ë¤¬Íè¤ë¤È°Üư¥¢¥¤¥³¥ó¤Ë¥«¡¼¥½¥ë¤¬ÊѲ½¤·¤Þ¤¹¡¥\
+¤½¤³¤Ç¥Ä¡¼¥ë¥Ð¡¼¤òư¤«¤¹¤è¤¦¤Ë¥É¥é¥Ã¥°¤¹¤ë¤È¡¤\
+¥Ä¡¼¥ë¥Ð¡¼Á´ÂΤòÀÚ¤êÎ¥¤·¤ÆÆÈΩ¤·¤¿¥È¥Ã¥×¥ì¥Ù¥ë¥¦¥£¥¸¥§¥Ã¥È¤Ë\
+¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥\
+ÀÚ¤êÎ¥¤·¤¿¥Ä¡¼¥ë¥Ð¡¼¤¬ÉÔÍפȤʤä¿»þ¤Ë¤Ï¡¤\
+°ìÈÌŪ¤Ê¥È¥Ã¥×¥ì¥Ù¥ë¥¦¥£¥¸¥§¥Ã¥È¤ÈƱÍͤËñ½ã¤ËÊĤ¸¤ë¤³¤È¤Ç¡¤
+ºÆ¤Ó¸µ¤Î¥¦¥£¥ó¥É¥¦¤ËÄ¥¤êÉÕ¤±¤é¤ì¤ë¤Ç¤·¤ç¤¦¡¥
+EOL
+else
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><<EOL)
+¤³¤Î¥Ç¥â¤Ç¤Ï¡¤¥Ä¡¼¥ë¥Ð¡¼¤ò¤É¤Î¤è¤¦¤Ë¤·¤ÆÅ¬Àڤ˥ơ¼¥ÞÂбþ¤µ¤»¤ë¤«¤ò\
+¼¨¤·¤Æ¤¤¤Þ¤¹¡¥\
+¥Ä¡¼¥ë¥Ð¡¼¤Î¥Ü¥¿¥ó¤Ï¡¤'Toolbutton'¥¹¥¿¥¤¥ë¤ò»ÈÍѤ¹¤ë¤è¤¦¤ËÌÀ¼¨¤¹¤ë¤³¤È¤Ç¡¤\
+"toolbar style"¥Ü¥¿¥ó¤È¤Ê¤ë¤è¤¦¤Ë°À­ÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡¥
+EOL
+end
+
+## Set up the toolbar hull
+tbar_base = Tk::Frame.new(base_frame, # Tk ɸ½à¤Î frame ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡¥
+ :widgetname=>'toolbar') # ¥¦¥£¥ó¥É¥¦¥¿¥¤¥È¥ëʸ»úÎó¤È¤¹¤ë¤¿¤á¤Ë¡¤¥¦¥£¥¸¥§¥Ã¥È̾¤òÌÀ¼¨¤·¤Æ¤¤¤Þ¤¹¡¥
+sep = Ttk::Separator.new(base_frame)
+to_base = Ttk::Frame.new(tbar_base, :cursor=>'fleur')
+if Tk.windowingsystem != 'aqua'
+ to = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to2 = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to.pack(:fill=>:y, :expand=>true, :padx=>2, :side=>:left)
+ to2.pack(:fill=>:y, :expand=>true, :side=>:left)
+end
+
+contents = Ttk::Frame.new(tbar_base)
+Tk.grid(to_base, contents, :sticky=>'nsew')
+tbar_base.grid_columnconfigure(contents, :weight=>1)
+contents.grid_columnconfigure(1000, :weight=>1)
+
+if Tk.windowingsystem != 'aqua'
+ ## Bindings so that the toolbar can be torn off and reattached
+ to_base.bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to2. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ def tbar_base.tearoff(w, x, y)
+ on_win = TkWinfo.containing(x, y)
+ return unless (on_win && on_win.path =~ /^#{@path}(\.|$)/)
+ self.grid_remove
+ w.grid_remove
+ self.wm_manage
+ # self.wm_title('Toolbar') # ¤â¤·¥¦¥£¥¸¥§¥Ã¥È̾¤ò¥¦¥£¥ó¥É¥¦¥¿¥¤¥È¥ë¤Ë¤·¤¿¤¯¤Ê¤¤¤Ê¤é¡¤¤³¤³¤ÇÀßÄꤷ¤Æ¤¯¤À¤µ¤¤
+ self.wm_protocol('WM_DELETE_WINDOW'){ self.untearoff(self) }
+ end
+ def tbar_base.untearoff(w)
+ self.wm_forget
+ w.grid
+ self.grid
+ end
+end
+
+## Some content for the rest of the toplevel
+text = TkText.new(base_frame, :width=>40, :height=>10)
+
+## Toolbar contents
+tb_btn = Ttk::Button.new(tbar_base, :text=>'¥Ü¥¿¥ó', :style=>'Toolbutton',
+ :command=>proc{
+ text.insert(:end, "¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤Þ¤·¤¿¡¥\n")
+ })
+tb_chk = Ttk::Checkbutton.new(tbar_base, :text=>'¥Á¥§¥Ã¥¯¥Ü¥¿¥ó',
+ :style=>'Toolbutton',
+ :variable=>(check = TkVariable.new),
+ :command=>proc{
+ text.insert(:end, "¥Á¥§¥Ã¥¯¥Ü¥¿¥ó¤ÎÃͤÏ#{check.value}¤Ç¤¹¡¥\n")
+ })
+tb_mbtn = Ttk::Menubutton.new(tbar_base, :text=>'¥á¥Ë¥å¡¼')
+tb_combo = Ttk::Combobox.new(tbar_base, :value=>TkFont.families,
+ :state=>:readonly)
+tb_mbtn.menu(menu = Tk::Menu.new(tb_mbtn))
+menu.add(:command, :label=>'Just', :command=>proc{text.insert(:end, "Just\n")})
+menu.add(:command, :label=>'An', :command=>proc{text.insert(:end, "An\n")})
+menu.add(:command, :label=>'Example',
+ :command=>proc{text.insert(:end, "Example\n")})
+tb_combo.bind('<ComboboxSelected>'){ text.font.family = tb_combo.get }
+
+## Arrange contents
+Tk.grid(tb_btn, tb_chk, tb_mbtn, tb_combo,
+ :in=>contents, :padx=>2, :sticky=>'ns')
+Tk.grid(tbar_base, :sticky=>'ew')
+Tk.grid(sep, :sticky=>'ew')
+Tk.grid(msg, :sticky=>'ew')
+Tk.grid(text, :sticky=>'nsew')
+base_frame.grid_rowconfigure(text, :weight=>1)
+base_frame.grid_columnconfigure(text, :weight=>1)
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'toolbar'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ Tk.grid(frame, :sticky=>'ew')
+}
diff --git a/ext/tk/sample/demos-jp/tree.rb b/ext/tk/sample/demos-jp/tree.rb
new file mode 100644
index 0000000000..c3b4191144
--- /dev/null
+++ b/ext/tk/sample/demos-jp/tree.rb
@@ -0,0 +1,120 @@
+# -*- coding: euc-jp -*-
+#
+# tree.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget.
+#
+# based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($tree_demo) && $tree_demo
+ $tree_demo.destroy
+ $tree_demo = nil
+end
+
+$tree_demo = TkToplevel.new {|w|
+ title("Directory Browser")
+ iconname("tree")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($tree_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttk¤È¤Ï¡¤¥Æ¡¼¥Þ»ØÄê²Äǽ¤Ê¿·¤·¤¤¥¦¥£¥¸¥§¥Ã¥È½¸¹ç¤Ç¤¹¡¥\
+¤³¤Î¥µ¥ó¥×¥ë¤Ï¡¤¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î¤è¤¦¤Ê³¬ÁØÅª¤Ê¥Ç¡¼¥¿½¸¹ç¤ò\
+»²¾È¤Ç¤­¤ë¤è¤¦¤Ë¤·¤¿Ttk::Treeview¥¦¥£¥¸¥§¥Ã¥È¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡¥\
+Ttk::Treeview¥¦¥£¥¸¥§¥Ã¥È¤Ï¡¤ÌÚ¹½Â¤¼«ÂΤÎɽ¼¨¤ò²Äǽ¤Ë¤¹¤ë¤À¤±¤Ç¤Ê¤¯¡¤\
+ÄɲþðÊó(¤³¤Î¥µ¥ó¥×¥ë¤Î¾ì¹ç¤Ï¥Õ¥¡¥¤¥ë¥µ¥¤¥º)¤òɽ¼¨¤¹¤ë¤¿¤á¤Ë\
+Ǥ°Õ¤Î¸Ä¿ô¤ÎÄɲå«¥é¥à¤â°·¤¦¤³¤È¤â¤Ç¤­¤Þ¤¹¡¥\
+¤Þ¤¿¡¤¥«¥é¥à¤Î¥¿¥¤¥È¥ë´Ö¤Î¶èÀÚ¤êÉôʬ¤ò¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¡¤\
+¥«¥é¥à¤ÎÉý¤òÊѹ¹¤¹¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡¥
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'tree'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $tree_demo.destroy
+ $tree_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+## Code to populate the roots of the tree (can be more than one on Windows)
+def populate_roots(tree)
+ TkComm.simplelist(Tk.tk_call('file', 'volumes')).sort.each{|dir|
+ populate_tree(tree, tree.insert(nil, :end, :text=>dir,
+ :values=>[dir, 'directory']))
+ }
+end
+
+## Code to populate a node of the tree
+def populate_tree(tree, node)
+ return if tree.get(node, :type) != 'directory'
+
+ path = tree.get(node, :fullpath)
+ tree.delete(tree.children(node))
+ Dir.glob("#{path}/*").sort.each{|f|
+ type = File.ftype(f)
+ id = tree.insert(node, :end,
+ :text=>File.basename(f), :values=>[f, type]).id
+ if type == 'directory'
+ ## Make it so that this node is openable
+ tree.insert(id, 0, :text=>'dummy')
+ tree.itemconfigure(id, :text=>File.basename(f))
+ elsif type == 'file'
+ size = File.size(f)
+ if size >= 1024*1024*1024
+ size = '%.1f GB' % (size.to_f/1024/1024/1024)
+ elsif size >= 1024*1024
+ size = '%.1f MB' % (size.to_f/1024/1024)
+ elsif size >= 1024
+ size = '%.1f KB' % (size.to_f/1024)
+ else
+ size = '%.1f bytes' % (size.to_f/1024)
+ end
+ tree.set(id, :size, size)
+ end
+ }
+
+ # Stop this code from rerunning on the current node
+ tree.set(node, :type, 'processed_directory')
+end
+
+## Create the tree and set it up
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size),
+ :displaycolumns=>['size'])
+if Tk.windowingsystem != 'aqua'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+tree.heading_configure('#0', :text=>'Directory Structure')
+tree.heading_configure('size', :text=>'File Size')
+tree.column_configure('size', :stretch=>0, :width=>70)
+populate_roots(tree)
+tree.bind('<TreeviewOpen>', '%W'){|w| populate_tree(w, w.focus_item)}
+
+## Arrange the tree and its scrollbars in the toplevel
+container = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+container.lower
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
diff --git a/ext/tk/sample/demos-jp/ttkbut.rb b/ext/tk/sample/demos-jp/ttkbut.rb
new file mode 100644
index 0000000000..4d577120bb
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ttkbut.rb
@@ -0,0 +1,145 @@
+# -*- coding: euc-jp -*-
+#
+# ttkbut.rb
+#
+# This demonstration script creates a toplevel window containing several
+# simple Ttk widgets, such as labels, labelframes, buttons, checkbuttons and
+# radiobuttons.
+#
+# based on "Id: ttkbut.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkbut_demo) && $ttkbut_demo
+ $ttkbut_demo.destroy
+ $ttkbut_demo = nil
+end
+
+$ttkbut_demo = TkToplevel.new {|w|
+ title("Simple Ttk Widgets")
+ iconname("ttkbut")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkbut_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttk¤È¤Ï¡¤¥Æ¡¼¥Þ»ØÄê²Äǽ¤Ê¿·¤·¤¤¥¦¥£¥¸¥§¥Ã¥È½¸¹ç¤Ç¤¹¡¥\
+º£¡¤¤¢¤Ê¤¿¤¬Ìܤˤ·¤Æ¤¤¤ë¤Î¤ÏTtk¤Î¥Æ¡¼¥Þ²½¥é¥Ù¥ë¤Ç¡¤\
+²¼¤Ë¤ÏTtk¤Î¥é¥Ù¥ë¥Õ¥ì¡¼¥à¤ÎÃæ¤Ë»°¤Ä¤Î¥°¥ë¡¼¥×¤ÎTtk¥¦¥£¥¸¥§¥Ã¥È¤¬\
+ɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥
+ºÇ½é¤Î¥°¥ë¡¼¥×¤ÏÁ´¤Æ¥Ü¥¿¥ó¤Ç¤¢¤ê¡¤\
+¤½¤ì¤¾¤ì¥¯¥ê¥Ã¥¯¤¹¤ì¤Ð¸½ºß¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥Æ¡¼¥Þ¤¬ÀßÄꤵ¤ì¤Þ¤¹¡¥
+£²ÈÖÌܤΥ°¥ë¡¼¥×¤Ï»°¤Ä¤Î¥Á¥§¥Ã¥¯¥Ü¥¿¥ó½¸¹ç¤Ç¤¹¡¥\
+³Æ½¸¹ç¤Î´Ö¤Ë¤Ï¡¤¥»¥Ñ¥ì¡¼¥¿¥¦¥£¥¸¥§¥Ã¥È¤¬ÃÖ¤«¤ì¤Æ¤¤¤Þ¤¹¡¥\
+¤Ê¤ª¡ÖÍ­¸ú²½¡×¥Ü¥¿¥ó¤Ï¡¤¤³¤Î¥È¥Ã¥×¥ì¥Ù¥ë¥¦¥£¥¸¥§¥Ã¥ÈÆâ¤Î\
+¾¤Î¤¹¤Ù¤Æ¤Î¥Æ¡¼¥Þ²½¥¦¥£¥¸¥§¥Ã¥È¤Î¾õÂÖ(state)¤¬"disabled"¤«¤É¤¦¤«¤ò\
+¥³¥ó¥È¥í¡¼¥ë¤¹¤ë¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡¥
+£³ÈÖÌܤΥ°¥ë¡¼¥×¤Ï´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥é¥¸¥ª¥Ü¥¿¥ó½¸¹ç¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
+EOL
+
+## Add buttons for setting the theme
+buttons = Ttk::Labelframe.new(base_frame, :text=>'¥Ü¥¿¥ó')
+# Ttk::Style.theme_names.each{|theme|
+# Ttk::Button.new(buttons, :text=>theme,
+# :command=>proc{Ttk::Style.theme_use theme}).pack(:pady=>2)
+# }
+Ttk.themes.each{|theme|
+ Ttk::Button.new(buttons, :text=>theme,
+ :command=>proc{Ttk.set_theme theme}).pack(:pady=>2)
+}
+
+## Helper procedure for the top checkbutton
+def setState(root, value, *excepts)
+ return if excepts.member?(root)
+
+ ## Non-Ttk widgets (e.g. the toplevel) will fail, so make it silent
+ begin
+ root.state = value
+ rescue
+ end
+
+ ## Recursively invoke on all children of this root that are in the same
+ ## toplevel widget
+ root.winfo_children.each{|w|
+ setState(w, value, *excepts) if w.winfo_toplevel == root.winfo_toplevel
+ }
+end
+
+## Set up the checkbutton group
+checks = Ttk::Labelframe.new(base_frame, :text=>'¥Á¥§¥Ã¥¯¥Ü¥¿¥ó')
+enabled = TkVariable.new(true)
+e = Ttk::Checkbutton.new(checks, :text=>'Í­¸ú²½', :variable=>enabled,
+ :command=>proc{
+ setState($ttkbut_demo,
+ ((enabled.bool)? "!disabled" : "disabled"),
+ e)
+ })
+
+## See ttk_widget(n) for other possible state flags
+sep1 = Ttk::Separator.new(checks)
+sep2 = Ttk::Separator.new(checks)
+
+cheese = TkVariable.new
+tomato = TkVariable.new
+basil = TkVariable.new
+oregano = TkVariable.new
+
+c1 = Ttk::Checkbutton.new(checks, :text=>'¥Á¡¼¥º', :variable=>cheese)
+c2 = Ttk::Checkbutton.new(checks, :text=>'¥È¥Þ¥È', :variable=>tomato)
+c3 = Ttk::Checkbutton.new(checks, :text=>'¥Ð¥¸¥ë', :variable=>basil)
+c4 = Ttk::Checkbutton.new(checks, :text=>'¥ª¥ì¥¬¥Î', :variable=>oregano)
+
+Tk.pack(e, sep1, c1, c2, sep2, c3, c4, :fill=>:x, :pady=>2)
+
+## Set up the radiobutton group
+radios = Ttk::Labelframe.new(base_frame, :text=>'¥é¥¸¥ª¥Ü¥¿¥ó')
+
+happyness = TkVariable.new
+
+r1 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Great', :value=>'great')
+r2 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Good', :value=>'good')
+r3 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Ok', :value=>'ok')
+r4 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Poor', :value=>'poor')
+r5 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Awful', :value=>'awful')
+
+Tk.pack(r1, r2, r3, r4, r5, :fill=>:x, :padx=>3, :pady=>2)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'ÊÑ¿ô»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame, ['Í­¸ú²½', enabled],
+ ['¥Á¡¼¥º', cheese], ['¥È¥Þ¥È', tomato],
+ ['¥Ð¥¸¥ë', basil], ['¥ª¥ì¥¬¥Î', oregano],
+ ['¹¬Ê¡ÅÙ', happyness])
+ }),
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkbut'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $ttkbut_demo
+ $ttkbut_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x, :expand=>true)
+}
+
+## Arrange things neatly
+f = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+Tk.grid(buttons, checks, radios, :in=>f, :sticky=>'nwe', :pady=>2, :padx=>3)
+f.grid_columnconfigure([0, 1, 2], :weight=>1, :uniform=>:yes)
diff --git a/ext/tk/sample/demos-jp/ttkmenu.rb b/ext/tk/sample/demos-jp/ttkmenu.rb
new file mode 100644
index 0000000000..d349b42d11
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ttkmenu.rb
@@ -0,0 +1,91 @@
+# -*- coding: euc-jp -*-
+#
+# ttkmenu.rb --
+#
+# This demonstration script creates a toplevel window containing several Ttk
+# menubutton widgets.
+#
+# based on "Id: ttkmenu.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkmenu_demo) && $ttkmenu_demo
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+end
+
+$ttkmenu_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("ttkmenu")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($ttkmenu_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttk¤È¤Ï¡¤¥Æ¡¼¥Þ»ØÄê²Äǽ¤Ê¿·¤·¤¤¥¦¥£¥¸¥§¥Ã¥È½¸¹ç¤Ç¤¹¡¥\
+¤³¤ì¤Ë¤è¤ê¥Æ¡¼¥Þ¤ËÂбþ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¥¦¥£¥¸¥§¥Ã¥È¤Î¤Ò¤È¤Ä¤Ë\
+¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤¬¤¢¤ê¤Þ¤¹¡¥\
+°Ê²¼¤Ç¤Ï¡¤¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤¬¤¤¤¯¤Ä¤«É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥\
+¤½¤ì¤é¤ò»È¤Ã¤Æ¡¤¸½ºß»ÈÍÑÃæ¤Î¥Æ¡¼¥Þ¤òÊѹ¹¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡¥\
+¥Æ¡¼¥Þ¤ÎÁªÂò¤¬¥á¥Ë¥å¡¼¥Ü¥¿¥ó¼«¿È¤Î¸«³Ý¤±¤òÊѲ½¤µ¤»¤ëÍͻҤ䡤\
+Ãæ±û¤Î¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤À¤±¤¬°Û¤Ê¤ë¥¹¥¿¥¤¥ë\
+(¥Ä¡¼¥ë¥Ð¡¼¤Ç¤Î°ìÈÌŪ¤Êɽ¼¨¤ËŬ¤·¤¿¤â¤Î)¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ëÍͻҤË\
+ÃíÌܤ·¤Æ¤¯¤À¤µ¤¤¡¥\
+¤Ê¤ª¡¤¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤Ë¤Ä¤¤¤Æ¤Ï¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿¥¦¥£¥¸¥§¥Ã¥È¤¬¤¢¤ê¤Þ¤¹¤¬¡¤\
+¥á¥Ë¥å¡¼¤Ë¤Ä¤¤¤Æ¤Ï¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿¥¦¥£¥¸¥§¥Ã¥È¤Ï´Þ¤Þ¤ì¤Æ¤¤¤Þ¤»¤ó¡¥\
+¤½¤ÎÍýͳ¤Ï¡¤É¸½à¤ÎTk¤Î¥á¥Ë¥å¡¼¥¦¥£¥¸¥§¥Ã¥È¤¬\
+¤¹¤Ù¤Æ¤Î¥×¥é¥Ã¥È¥Û¡¼¥à¤Ç½½Ê¬¤ËÎɹ¥¤Ê¸«³Ý¤±¤ÈÁàºîÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡¤\
+ÆÃ¤Ë¡¤Â¿¤¯¤Î´Ä¶­¤Ç¤½¤Î´Ä¶­ËÜÍè¤ÎÁàºîÂηϤȤʤë¤è¤¦¤Ë¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤È\
+ȽÃǤµ¤ì¤¿¤³¤È¤Ë¤è¤ê¤Þ¤¹¡¥
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new($ttkmenu_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkmenu'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+b1 = Ttk::Menubutton.new(base_frame,:text=>'¥Æ¡¼¥Þ¤òÁªÂò',:direction=>:above)
+b2 = Ttk::Menubutton.new(base_frame,:text=>'¥Æ¡¼¥Þ¤òÁªÂò',:direction=>:left)
+b3 = Ttk::Menubutton.new(base_frame,:text=>'¥Æ¡¼¥Þ¤òÁªÂò',:direction=>:right)
+b4 = Ttk::Menubutton.new(base_frame,:text=>'¥Æ¡¼¥Þ¤òÁªÂò',:direction=>:flush,
+ :style=>Ttk::Menubutton.style('Toolbutton'))
+b5 = Ttk::Menubutton.new(base_frame,:text=>'¥Æ¡¼¥Þ¤òÁªÂò',:direction=>:below)
+
+b1.menu(m1 = Tk::Menu.new(b1, :tearoff=>false))
+b2.menu(m2 = Tk::Menu.new(b2, :tearoff=>false))
+b3.menu(m3 = Tk::Menu.new(b3, :tearoff=>false))
+b4.menu(m4 = Tk::Menu.new(b4, :tearoff=>false))
+b5.menu(m5 = Tk::Menu.new(b5, :tearoff=>false))
+
+Ttk.themes.each{|theme|
+ m1.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m2.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m3.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m4.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m5.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+}
+
+f = Ttk::Frame.new(base_frame).pack(:fill=>:x)
+f1 = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+
+f.grid_anchor(:center)
+TkGrid('x', b1, 'x', :in=>f, :padx=>3, :pady=>2)
+TkGrid(b2, b4, b3, :in=>f, :padx=>3, :pady=>2)
+TkGrid('x', b5, 'x', :in=>f, :padx=>3, :pady=>2)
diff --git a/ext/tk/sample/demos-jp/ttknote.rb b/ext/tk/sample/demos-jp/ttknote.rb
new file mode 100644
index 0000000000..09cc7960a3
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ttknote.rb
@@ -0,0 +1,97 @@
+# -*- coding: euc-jp -*-
+#
+# ttknote.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# notebook widget.
+#
+# based on "Id: ttknote.tcl,v 1.5 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttknote_demo) && $ttknote_demo
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+end
+
+$ttknote_demo = TkToplevel.new {|w|
+ title("Ttk Notebook Widget")
+ iconname("ttknote")
+ positionWindow(w)
+}
+
+## See Code / Dismiss
+Ttk::Frame.new($ttknote_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttknote'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+base_frame = Ttk::Frame.new($ttknote_demo).pack(:fill=>:both, :expand=>true)
+
+## Make the notebook and set up Ctrl+Tab traversal
+notebook = Ttk::Notebook.new(base_frame).pack(:fill=>:both, :expand=>true,
+ :padx=>2, :pady=>3)
+notebook.enable_traversal
+
+## Popuplate the first pane
+f_msg = Ttk::Frame.new(notebook)
+msg_m = Ttk::Label.new(f_msg, :font=>$font, :wraplength=>'5i',
+ :justify=>:left, :anchor=>'n', :text=><<EOL)
+Ttk¤È¤Ï¡¤¥Æ¡¼¥Þ»ØÄê²Äǽ¤Ê¿·¤·¤¤¥¦¥£¥¸¥§¥Ã¥È½¸¹ç¤Ç¤¹¡¥\
+¤½¤ÎÃæ¤Ë´Þ¤Þ¤ì¤ë¥¦¥£¥¸¥§¥Ã¥È¤Î¤Ò¤È¤Ä¤Ë¥Î¡¼¥È¥Ö¥Ã¥¯¥¦¥£¥¸¥§¥Ã¥È¤¬¤¢¤ê¤Þ¤¹¡¥\
+¥Î¡¼¥È¥Ö¥Ã¥¯¥¦¥£¥¸¥§¥Ã¥È¤Ï¡¤\
+¸ÄÊÌ¤ÎÆâÍÆ¤ò»ý¤Ã¤¿¥Ñ¥Í¥ë¤«¤é¤ÎÁªÂò¤ò²Äǽ¤Ë¤¹¤ë¤è¤¦¤Ê\
+¥¿¥Ö¤Î½¸¹ç¡Ê¥¿¥Ö¥»¥Ã¥È¡Ë¤òÄê¤á¤Þ¤¹¡¥\
+¥¿¥Ö¥»¥Ã¥È¤ÏºÇ¶á¤Î¿¤¯¤Î¥æ¡¼¥¶¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Ç¸«¤é¤ì¤ëµ¡Ç½¤Ç¤¹¡¥\
+¥¿¥Ö¤ÎÁªÂò¤Ï¡¤¥Þ¥¦¥¹¤Ë¤è¤ë¤À¤±¤Ç¤Ê¤¯¡¤\
+¥Î¡¼¥È¥Ö¥Ã¥¯¥¦¥£¥¸¥§¥Ã¥È¤Î¥Ú¡¼¥¸¤Î¸«½Ð¤·¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë»þ¤Ç¤¢¤ì¤Ð\
+Ctrl+Tab¥­¡¼¤ÎÆþÎϤˤè¤Ã¤Æ¤â¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥\
+¤³¤Î¥Ç¥â¤Ç¤Ï¡¤¸«½Ð¤·¤Ç²¼ÀþÉÕ¤­¤Îʸ»ú¤Î¥­¡¼¤ÈAlt¥­¡¼¤È¤òÁȤ߹ç¤ï¤»¤ë¤³¤È¤Ç\
+¥Ú¡¼¥¸¤òÁªÂò¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤âÀßÄꤷ¤Æ¤¤¤Þ¤¹¡¥\
+¤¿¤À¤·¡¤£²ÈÖÌܤΥ¿¥Ö¤Ï̵¸ú²½¤µ¤ì¤ÆÁªÂò¤Ç¤­¤Ê¤¤¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤Ë¤Ï\
+Ãí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡¥
+EOL
+neat = TkVariable.new
+after_id = nil
+msg_b = Ttk::Button.new(f_msg, :text=>'¤¹¤Æ¤­¤À¡ª(Neat!)', :underline=>6,
+ :command=>proc{
+ neat.value = '¤¢¤¡¡¤¤½¤Î¤È¤ª¤ê¤µ¡¥¡¥¡¥'
+ Tk.after_cancel(after_id) if after_id
+ after_id = Tk.after(500){neat.value = ''}
+ })
+msg_b.winfo_toplevel.bind('Alt-n'){ msg_b.focus; msg_b.invoke }
+msg_l = Ttk::Label.new(f_msg, :textvariable=>neat)
+notebook.add(f_msg, :text=>'ÀâÌÀ(Description)', :underline=>3, :padding=>2)
+Tk.grid(msg_m, '-', :sticky=>'new', :pady=>2)
+Tk.grid(msg_b, msg_l, :pady=>[2, 4], :padx=>20)
+msg_b.grid_configure(:sticky=>'e')
+msg_l.grid_configure(:sticky=>'w')
+f_msg.grid_rowconfigure(1, :weight=>1)
+f_msg.grid_columnconfigure([0, 1], :weight=>1, :uniform=>1)
+
+## Populate the second pane. Note that the content doesn't really matter
+f_disabled = Ttk::Frame.new(notebook)
+notebook.add(f_disabled, :text=>'̵¸ú²½¤µ¤ì¤¿¥¿¥Ö', :state=>:disabled)
+
+## Popuplate the third pane
+f_editor = Ttk::Frame.new(notebook)
+notebook.add(f_editor, :text=>'¥Æ¥­¥¹¥È¥¨¥Ç¥£¥¿(Text Editor)', :underline=>9)
+editor_t = Tk::Text.new(f_editor, :width=>40, :height=>10, :wrap=>:char)
+if Tk.windowingsystem != 'aqua'
+ editor_s = editor_t.yscrollbar(Ttk::Scrollbar.new(f_editor))
+else
+ editor_s = editor_t.yscrollbar(Tk::Scrollbar.new(f_editor))
+end
+editor_s.pack(:side=>:right, :fill=>:y, :padx=>[0,2], :pady=>2)
+editor_t.pack(:fill=>:both, :expand=>true, :padx=>[2,0], :pady=>2)
diff --git a/ext/tk/sample/demos-jp/ttkpane.rb b/ext/tk/sample/demos-jp/ttkpane.rb
new file mode 100644
index 0000000000..96670c0e5c
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ttkpane.rb
@@ -0,0 +1,216 @@
+# -*- coding: euc-jp -*-
+#
+# ttkpane.rb --
+#
+# This demonstration script creates a Ttk pane with some content.
+#
+# based on "Id: ttkpane.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkpane_demo) && $ttkpane_demo
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+end
+
+$ttkpane_demo = TkToplevel.new {|w|
+ title("Themed Nested Panes")
+ iconname("ttkpane")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkpane_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+¤³¤Î¥Ç¥â¤Ï¡¤Ëä¤á¹þ¤ß´Ø·¸¤Ë¤¢¤ë¥Æ¡¼¥ÞÉÕ¤­¥Ú¥¤¥ó¥É¥¦¥£¥ó¥É¥¦¤ò¼¨¤·¤Æ¤¤¤Þ¤¹¡¥\
+¤½¤ì¤¾¤ì¤ÎÂ礭¤µ¤Ï¡¤´Þ¤Þ¤ì¤Æ¤¤¤ë¥Ú¥¤¥ó¤Î´Ö¤Ë¤¢¤ë¥¨¥ê¥¢¤ò¤Ä¤«¤ó¤Ç\
+¶­³¦¤ò¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤ÇÊѹ¹¤Ç¤­¤Þ¤¹¡¥
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkpane'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+outer = Ttk::Panedwindow.new(frame, :orient=>:horizontal)
+outer.add(in_left = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+outer.add(in_right = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+in_left.add(left_top = Ttk::Labelframe.new(in_left, :text=>'¥Ü¥¿¥ó'))
+in_left.add(left_bot = Ttk::Labelframe.new(in_left, :text=>'»þ·×'))
+in_right.add(right_top = Ttk::Labelframe.new(in_right, :text=>'¥×¥í¥°¥ì¥¹'))
+in_right.add(right_bot = Ttk::Labelframe.new(in_right, :text=>'¥Æ¥­¥¹¥È'))
+if Tk.windowingsystem == 'aqua'
+ [left_top, left_bot, right_top, right_bot].each{|w| w.padding(3) }
+end
+
+# Fill the button pane
+Ttk::Button.new(left_top, :text=>'²¡¤·¤Æ¤Í',
+ :command=>proc{
+ Tk.messageBox(:type=>'ok', :icon=>'info',
+ :message=>'¤¤¤Æ¤Æ¡ª',
+ :detail=>'That hurt...', :parent=>base_frame,
+ :title=>'Button Pressed')
+ }).pack(:padx=>2, :pady=>5)
+
+
+zones_list = [
+ [':Europe/Berlin'],
+ [':America/Argentina/Buenos_Aires', ':America/Buenos_Aires'],
+ [':Africa/Johannesburg'],
+ [':Europe/London'],
+ [':America/Los_Angeles'],
+ [':Europe/Moscow'],
+ [':America/New_York'],
+ [':Asia/Singapore'],
+ [':Australia/Sydney'],
+ [':Asia/Tokyo'],
+]
+
+zones = []
+
+# Check tzinfo support
+if $tk_major_ver > 8 || ($tk_major_ver == 8 && $tk_minor_ver >= 5)
+ tzinfo = :tcl
+
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ # Force a pre-load of all the timezones needed; otherwise can end up
+ # poor-looking synch problems!
+ Tk.tk_call('clock', 'format', '0', '-timezone', zone)
+ rescue RuntimeError
+ # ignore
+ else
+ zones << [zone, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+else
+ begin
+ require 'tzinfo'
+ tzinfo = :tzinfo
+ rescue Exception
+ begin
+ require 'tzfile'
+ tzinfo = :tzfile
+ rescue Exception
+ tzinfo = nil
+ end
+ end
+
+ case tzinfo
+ when :tzinfo
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZInfo::Timezone.get(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ when :tzfile
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZFile.create(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ else
+ [ -7, -4, -2, -1, 0, +1, +3, +8, +9, +10 ].each{|zone|
+ zones << [zone, 'UTC%+03d00' % zone]
+ }
+ end
+end
+
+time = TkVariable.new_hash
+
+case tzinfo
+when :tcl
+ update_proc = proc{|now, tz, label|
+ time[label] = Tk.tk_call('clock', 'format', now.tv_sec,
+ '-timezone', tz, '-format', '%T')
+ }
+when :tzinfo
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.utc_to_local(now).strftime('%H:%M:%S')
+ }
+when :tzfile
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.at(now.tv_sec).strftime('%H:%M:%S')
+ }
+else
+ update_proc = proc{|now, tz, label|
+ time[label] = (now + (tz * 3600)).strftime('%H:%M:%S')
+ }
+end
+
+# Fill the clocks pane
+zones.each_with_index{|(zone, label), idx|
+ Ttk::Separator.new(left_bot).pack(:fill=>:x) if idx > 0
+ Ttk::Label.new(left_bot, :text=>label, :anchor=>'w').pack(:fill=>:x)
+ Ttk::Label.new(left_bot, :textvariable=>time.ref(label),
+ :anchor=>'w').pack(:fill=>:x)
+}
+
+# Timer start
+every = proc{
+ now = Time.now.utc
+ zones.each{|zone, label| update_proc.call(now, zone, label) }
+}
+TkRTTimer.new(1000, -1, every).start(0, every)
+
+# Fill the progress pane
+Ttk::Progressbar.new(right_top, :mode=>:indeterminate).pack(:fill=>:both, :expand=>true).start
+
+# Fill the text pane
+if Tk.windowingsystem != 'aqua'
+ # The trick with the ttk::frame makes the text widget look like it fits with
+ # the current Ttk theme despite not being a themed widget itself. It is done
+ # by styling the frame like an entry, turning off the border in the text
+ # widget, and putting the text widget in the frame with enough space to allow
+ # the surrounding border to show through (2 pixels seems to be enough).
+ f = Ttk::Frame.new(right_bot, :style=>Ttk::Entry)
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ txt.pack(:fill=>:both, :expand=>true, :in=>f, :pady=>2, :padx=>2)
+ scr = txt.yscrollbar(Ttk::Scrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ f.pack(:fill=>:both, :expand=>true)
+ outer.pack(:fill=>:both, :expand=>true)
+else
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ scr = txt.yscrollbar(TkScrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ txt.pack(:fill=>:both, :expand=>true, :in=>right_bot)
+ outer.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>[6, 10])
+end
diff --git a/ext/tk/sample/demos-jp/ttkprogress.rb b/ext/tk/sample/demos-jp/ttkprogress.rb
new file mode 100644
index 0000000000..43a9cbcd7e
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ttkprogress.rb
@@ -0,0 +1,71 @@
+# -*- coding: euc-jp -*-
+#
+# ttkprogress.rb --
+#
+# This demonstration script creates several progress bar widgets.
+#
+# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkprogress_demo) && $ttkprogress_demo
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+end
+
+$ttkprogress_demo = TkToplevel.new {|w|
+ title("Progress Bar Demonstration")
+ iconname("ttkprogress")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkprogress_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+²¼¤Ë¤¢¤ë¤Î¤ÏÆó¤Ä¤Î¥×¥í¥°¥ì¥¹¥Ð¡¼¤Ç¤¹¡¥\
+¾å¤Î¤â¤Î¤Ï"determinate"¥¿¥¤¥×¤Î¥×¥í¥°¥ì¥¹¥Ð¡¼¤Ç¡¤\
+Î㤨¤Ð¥×¥í¥°¥é¥à¤¬Í¿¤¨¤é¤ì¤¿¥¿¥¹¥¯¤ò½ªÎ»¤¹¤ë¤Þ¤Ç¤Ë¤É¤Î¤¯¤é¤¤¤«¤«¤ë¤«¤ò\
+¼¨¤¹¤È¤­¤Ê¤É¤ËÍѤ¤¤é¤ì¤Þ¤¹¡¥\
+²¼¤Î¤â¤Î¤Ï"indeterminate"¥¿¥¤¥×¤Î¥×¥í¥°¥ì¥¹¥Ð¡¼¤Ç¡¤\
+Î㤨¤Ð¥×¥í¥°¥é¥à¤¬¼Â¹ÔÃæ(busy)¤Ç¤¢¤ë¤â¤Î¤Î\
+½ªÎ»¤Þ¤Ç¤Ë¤É¤ì¤¯¤é¤¤¤«¤«¤ë¤«¤Ïʬ¤«¤é¤Ê¤¤¤È¤¤¤¦¾õÂÖ¤ò\
+¼¨¤¹¤È¤­¤Ê¤É¤ËÍѤ¤¤é¤ì¤Þ¤¹¡¥\
+¤¤¤º¤ì¤Î¥×¥í¥°¥ì¥¹¥Ð¡¼¤â¡¤¤¹¤°²¼¤Ë¤¢¤ë¥Ü¥¿¥ó¤ò»È¤¦¤³¤È¤Ç\
+¼«Æ°¥¢¥Ë¥á¡¼¥·¥ç¥ó¥â¡¼¥É¤ÎON/OFF¤òÀÚÂØ¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥
+EOL
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkprogress'}),
+ Ttk::Button.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+p1 = Ttk::Progressbar.new(frame, :mode=>:determinate)
+p2 = Ttk::Progressbar.new(frame, :mode=>:indeterminate)
+
+start = Ttk::Button.new(frame, :text=>'Start Progress',
+ :command=>proc{ p1.start; p2.start })
+stop = Ttk::Button.new(frame, :text=>'Stop Progress',
+ :command=>proc{ p1.stop; p2.stop })
+
+Tk.grid(p1, '-', :pady=>5, :padx=>10)
+Tk.grid(p2, '-', :pady=>5, :padx=>10)
+Tk.grid(start, stop, :padx=>10, :pady=>5)
+start.grid_configure(:sticky=>'e')
+stop.grid_configure(:sticky=>'w')
+frame.grid_columnconfigure(:all, :weight=>1)
+
diff --git a/ext/tk/sample/demos-jp/twind.rb b/ext/tk/sample/demos-jp/twind.rb
index 166a44cdb2..faefaefd6e 100644
--- a/ext/tk/sample/demos-jp/twind.rb
+++ b/ext/tk/sample/demos-jp/twind.rb
@@ -16,8 +16,10 @@ $twind_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($twind_demo).pack(:fill=>:both, :expand=>true)
+
# frame À¸À®
-$twind_buttons = TkFrame.new($twind_demo) {|frame|
+$twind_buttons = TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -37,7 +39,7 @@ $twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame À¸À®
$twind_text = nil
-TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
'relief'=>'sunken') {|f|
$twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font,
'width'=>'70', 'height'=>35, 'wrap'=>'word',
@@ -207,7 +209,11 @@ def textWindPlot (t)
cursor 'top_left_arrow'
}
- font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ if $tk_version =~ /^4.*/
+ font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ else
+ font = 'Helvetica 18'
+ end
TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2)
diff --git a/ext/tk/sample/demos-jp/twind2.rb b/ext/tk/sample/demos-jp/twind2.rb
index e8009cef19..2a26b28ef6 100644
--- a/ext/tk/sample/demos-jp/twind2.rb
+++ b/ext/tk/sample/demos-jp/twind2.rb
@@ -16,8 +16,10 @@ $twind2_demo = TkToplevel.new {|w|
positionWindow(w)
}
+base_frame = TkFrame.new($twind2_demo).pack(:fill=>:both, :expand=>true)
+
# frame À¸À®
-$twind2_buttons = TkFrame.new($twind2_demo) {|frame|
+$twind2_buttons = TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
@@ -39,7 +41,7 @@ $twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame À¸À®
$twind2_text = nil
-TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
'relief'=>'sunken') {|f|
$twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
# 'width'=>'70', 'height'=>35, 'wrap'=>'word',
diff --git a/ext/tk/sample/demos-jp/unicodeout.rb b/ext/tk/sample/demos-jp/unicodeout.rb
index 7ab415fe57..178077ec08 100644
--- a/ext/tk/sample/demos-jp/unicodeout.rb
+++ b/ext/tk/sample/demos-jp/unicodeout.rb
@@ -18,7 +18,9 @@ $unicodeout_demo = TkToplevel.new {|w|
positionWindow(w)
}
-TkLabel.new($unicodeout_demo,
+base_frame = TkFrame.new($unicodeout_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
:font=>$font, :wraplength=>'5.4i', :justify=>:left,
:text=><<EOL).pack(:side=>:top)
¤³¤ì¤Ï¡¤Tk¤Ë¤ª¤±¤ëÈó²¤ÊÆÊ¸»ú½¸¹ç¤òÍѤ¤¤ë¸À¸ì¤ËÂФ¹¤ë¥µ¥Ý¡¼¥È¤Ë¤Ä¤¤¤Æ¤Î\
@@ -40,7 +42,7 @@ Tcl¤Î¥¨¥¹¥±¡¼¥×ɽ¸½¤òÍѤ¤¤¿UNICODEʸ»úÎó¤Ç½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡¥\
EOL
#'
-TkFrame.new($unicodeout_demo){|f|
+TkFrame.new(base_frame){|f|
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
@@ -53,7 +55,7 @@ TkFrame.new($unicodeout_demo){|f|
}).pack(:side=>:left, :expand=>true)
}
-wait_msg = TkLabel.new($unicodeout_demo,
+wait_msg = TkLabel.new(base_frame,
:text=>"¥Õ¥©¥ó¥ÈÆÉ¤ß¹þ¤ß¤Î´°Î»¤Þ¤Ç" +
"¤·¤Ð¤é¤¯¤ªÂÔ¤Á²¼¤µ¤¤¡¥¡¥¡¥",
:font=>"Helvetica 12 italic").pack
@@ -68,8 +70,8 @@ class Unicodeout_SampleFrame < TkFrame
# @@font = 'Newspaper 12'
# @@font = '{New century schoolbook} 12'
- def initialize()
- super($unicodeout_demo)
+ def initialize(base)
+ super(base)
grid_columnconfig(1, :weight=>1)
end
@@ -84,7 +86,7 @@ class Unicodeout_SampleFrame < TkFrame
l.grid_config(:padx, '1m')
end
end
-f = Unicodeout_SampleFrame.new
+f = Unicodeout_SampleFrame.new(base_frame)
f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
# Processing when some characters are missing might take a while, so make
diff --git a/ext/tk/sample/demos-jp/vscale.rb b/ext/tk/sample/demos-jp/vscale.rb
index eb0cea250d..a1097fd77f 100644
--- a/ext/tk/sample/demos-jp/vscale.rb
+++ b/ext/tk/sample/demos-jp/vscale.rb
@@ -12,7 +12,9 @@ $vscale_demo = TkToplevel.new {|w|
}
positionWindow($vscale_demo)
-msg = TkLabel.new($vscale_demo) {
+base_frame = TkFrame.new($vscale_demo).pack(:fill=>:both, :expand=>true)
+
+msg = TkLabel.new(base_frame) {
font $font
wraplength '3.5i'
justify 'left'
@@ -23,7 +25,7 @@ msg = TkLabel.new($vscale_demo) {
}
msg.pack('side'=>'top', 'padx'=>'.5c')
-TkFrame.new($vscale_demo) {|frame|
+TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
#text 'λ²ò'
text 'ÊĤ¸¤ë'
@@ -40,7 +42,17 @@ TkFrame.new($vscale_demo) {|frame|
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
-TkFrame.new($vscale_demo) {|frame|
+def setHeight(w, height)
+ height = height + 21
+ y2 = height - 30
+ if y2 < 21
+ y2 = 21
+ end
+ w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+ w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+end
+
+TkFrame.new(base_frame) {|frame|
borderwidth 10
canvas = TkCanvas.new(frame) {|c|
width 50
@@ -66,14 +78,3 @@ TkFrame.new($vscale_demo) {|frame|
}.pack('side'=>'left', 'anchor'=>'ne')
scale.set 75
}.pack
-
-
-def setHeight(w, height)
- height = height + 21
- y2 = height - 30
- if y2 < 21
- y2 = 21
- end
- w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
- w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
-end
diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget
index 7982a6651e..8eb699e513 100644
--- a/ext/tk/sample/demos-jp/widget
+++ b/ext/tk/sample/demos-jp/widget
@@ -5,15 +5,18 @@
if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!!!
$KCODE = 'euc'
else
- $TK_ENCODING = 'EUC-JP'
+ DEFAULT_TK_ENCODING = 'EUC-JP'
end
# tk ´Ø·¸¥é¥¤¥Ö¥é¥ê¤ÎÆÉ¤ß¹þ¤ß
require 'tk'
# require 'tkafter'
+$RubyTk_WidgetDemo = true
+
# widget demo directory °ÌÃÖ¤Î³ÍÆÀ
-$demo_dir = File.dirname($0)
+# $demo_dir = File.dirname($0)
+$demo_dir = File.dirname(__FILE__)
# root ¤ÎÀ¸À®
$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
@@ -48,15 +51,14 @@ when /^8.*/
$font = TkFont.new('Helvetica -12')
$kanji_font = TkFont.new('Helvetica -12', 'Mincho -12')
TkOption.add('*kanjiFont', knjfont, 'startupFile')
- $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold')
+ $msg_kanji_font=TkFont.new('Helvetica 14 bold', 'Gothic 14 bold')
else
- $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil)
+ $font = TkFont.new('Helvetica 14', nil)
knjfont = '-*--16-*-jisx0208.1983-0'
- $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
- knjfont)
+ $kanji_font = TkFont.new('Helvetic 14', knjfont)
TkOption.add('*kanjiFont', knjfont, 'startupFile')
- $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ $msg_kanji_font=TkFont.new('Helvetica 14',
'-*--24-*-jisx0208.1983-0')
end
#######
@@ -121,14 +123,22 @@ EOD
end
# ¥á¥Ë¥å¡¼ÀßÄê
-TkMenubar.new($root,
- [[['File', 0],
- ['About ... ', proc{aboutBox}, 0, '<F1>'],
- '---',
- ['Quit', proc{exit}, 0, 'Meta-Q']
- ]]).pack('side'=>'top', 'fill'=>'x')
+if $tk_major_ver >= 8
+ $root.add_menubar([[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]])
+else
+ TkMenubar.new($root,
+ [[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]]).pack('side'=>'top', 'fill'=>'x')
+end
$root.bind('F1', proc{aboutBox})
-$root.bind('Meta-q', proc{exit})
+$root.bind('Control-q', proc{exit})
=begin
TkFrame.new($root){|frame|
@@ -185,18 +195,27 @@ else
textFrame.pack('expand'=>'yes', 'fill'=>'both')
statusBar = TkFrame.new($root) {|f|
+ if $tk_version =~ /^4.*/
+ statusfont = '-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ else
+ statusfont = 'Helvetica 10'
+ end
$statusBarLabel = \
TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ 'font'=>statusfont) \
.pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
- 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ 'font'=>statusfont) \
.pack('side'=>'left', 'padx'=>2)
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
end
# ¥Æ¥­¥¹¥È¥¿¥°ÀßÄê
-tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+if $tk_version =~ /^4.*/
+ tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+else
+ tag_title = TkTextTag.new(txt, 'font'=>'Helvetica 18 bold')
+end
#tag_kanji_title = TkTextTag.new(txt, 'kanjifont'=>$msg_kanji_font)
#tag_middle = TkTextTag.new(txt, 'kanjifont'=>$kanji_font)
tag_kanji_title = TkTextTag.new(txt, 'font'=>$msg_kanji_font)
@@ -267,14 +286,31 @@ txt.insert('end', <<"EOT")
¤ë¤¿¤á¤Ë¡¢"¥³¡¼¥É»²¾È"¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¢¤Ê¤¿¤¬\
˾¤à¤Ê¤é¡¢¤½¤Î¥³¡¼¥É¤ò½¤Àµ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£½¤Àµ¤·¤¿¥³¡¼¥É¤Ç¥Ç¥â\
¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó¤òºÆ¼Â¹Ô¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¥³¡¼¥É¤¬½ñ¤«¤ì¤¿¥¦¥£¥ó¥É¥¦¤Ë\
-¤¢¤ë"¥Ç¥âºÆ¼Â¹Ô" ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£
-
-°ìÉô¤Î¥Ç¥â¤Ç¤Ï¡¤Èæ³ÓŪºÇ¶á¤Î¥Ð¡¼¥¸¥ç¥ó¤Î Tk ¤Ç¤Ê¤±¤ì¤Ð¥µ¥Ý¡¼¥È¤·¤Æ\
-¤¤¤Ê¤¤µ¡Ç½¤ò»È¤Ã¤Æ¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹(Î㤨¤Ð Tk8.4 °Ê¾å¤Ê¤É)¡¥¤½¤Î¤¿¤á¡¤\
-¤½¤¦¤·¤¿µ¡Ç½¤ò»ý¤¿¤Ê¤¤ Tk ¥é¥¤¥Ö¥é¥ê¤ò»È¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¤¤½¤¦¤·¤¿\
-¥Ç¥â¤ÏÀµ¤·¤¯Æ°¤­¤Þ¤»¤ó¡¥¤½¤Î¤è¤¦¤Êµ¡Ç½¤¬É¬ÍפǤ¢¤ì¤Ð¡¤¤½¤ì¤ò¥µ¥Ý¡¼¥È\
-¤·¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤Ë¡¤tcltklib ¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤Ê¤ª¤·¤Æ\
-¤¯¤À¤µ¤¤¡¥
+¤¢¤ë"¥Ç¥âºÆ¼Â¹Ô" ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£\
+¥³¡¼¥É¤ò½¤Àµ¤·¤Æ¤â¥ª¥ê¥¸¥Ê¥ë¤Î¥Õ¥¡¥¤¥ë¤¬½ñ¤­´¹¤¨¤é¤ì¤ë¤³¤È¤Ï\
+¤¢¤ê¤Þ¤»¤ó¤«¤é¡¢¿´ÇÛ¤»¤º¤Ë¿§¡¹¤ÊÊѹ¹¤ò»î¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
+
+°ìÉô¤Î¥Ç¥â¤Ç¤Ï¡¢Èæ³ÓŪºÇ¶á¤Î¥Ð¡¼¥¸¥ç¥ó¤Î Tk ¤Ç¤Ê¤±¤ì¤Ð¥µ¥Ý¡¼¥È¤·¤Æ\
+¤¤¤Ê¤¤µ¡Ç½¤ò»È¤Ã¤Æ¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹(Î㤨¤Ð Tk8.4 °Ê¾å¤Ê¤É)¡£¤½¤Î¤¿¤á¡¢\
+¤½¤¦¤·¤¿µ¡Ç½¤ò»ý¤¿¤Ê¤¤ Tk ¥é¥¤¥Ö¥é¥ê¤ò»È¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¤½¤¦¤·¤¿\
+¥Ç¥â¤ÏÀµ¤·¤¯Æ°¤­¤Þ¤»¤ó¡£¤½¤Î¤è¤¦¤Êµ¡Ç½¤¬É¬ÍפǤ¢¤ì¤Ð¡¢¤½¤ì¤ò¥µ¥Ý¡¼¥È\
+¤·¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤Ë tcltklib ¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤Ê¤ª¤·¤Æ\
+¤¯¤À¤µ¤¤¡£
+
+¤â¤·¤¢¤Ê¤¿¤Î Tk ¤¬ (ºÇ½é¤«¤é´Þ¤à¤«¥¤¥ó¥¹¥È¡¼¥ë¤·¤¿¤«¤Ë¤è¤ê) \
+Ttk (Tile) ³ÈÄ¥¤òÍøÍѤǤ­¤ë¾õÂ֤Ǥ¢¤ë¤Ê¤é¡¢\
+Ttk ³ÈÄ¥¤Î¥Ç¥â (sample/tkextlib/tile/demo.rb) ¤â¤¼¤Ò»î¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
+( ¿ʬ¡¤¸½ºß¤Î¤¢¤Ê¤¿¤Î´Ä¶­¤Ë¤Ï Ttk ³ÈÄ¥¤Ï\
+#{
+begin
+ require 'tkextlib/tile'
+ "¤¹¤Ç¤ËƳÆþ¤µ¤ì¤Æ¤¤¤Þ¤¹"
+rescue
+ "¤Þ¤À¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Þ¤»¤ó"
+end
+}\
+¡£)
+Ttk ³ÈÄ¥¤Ï¡¢Tk8.5 °Ê¾å¤Ç¤Ïɸ½à¤Îµ¡Ç½¤È¤·¤ÆÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£
EOT
@@ -323,6 +359,9 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "14. ¥é¥Ù¥ëÉÕ¤­¥Õ¥ì¡¼¥à (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
tag_demo, "demo-labelframe")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "15. ¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿¥¦¥£¥¸¥§¥Ã¥È¤Î´Êñ¤ÊÎã (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo, "demo-ttkbut")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "¥ê¥¹¥È¥Ü¥Ã¥¯¥¹\n", tag_middle)
@@ -335,6 +374,12 @@ txt.insert('end', "2. ¿§: ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¤¿¤á¤ÎÇÛ¿§¤òÊѤ¨¤ë\n",
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "3. ³Ê¸À½¸\n", tag_demo, "demo-sayings")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ¹ñ¤Ë¤Ä¤¤¤Æ¤Î¥Þ¥ë¥Á¥«¥é¥à¥ê¥¹¥È (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo, "demo-mclist")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ¥Ç¥£¥ì¥¯¥È¥ê¥Ö¥é¥¦¥¶ (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo, "demo-tree")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "¥¨¥ó¥È¥ê¤È¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹\n", tag_middle)
@@ -350,7 +395,10 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "4. ¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
tag_demo, "demo-spin")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "5. ´Êñ¤Ê¥Õ¥©¡¼¥à\n", tag_demo, "demo-form")
+txt.insert('end', "5. ¥³¥ó¥Ü¥Ü¥Ã¥¯¥¹ (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo, "demo-combo")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ´Êñ¤Ê¥Õ¥©¡¼¥à\n", tag_demo, "demo-form")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@@ -372,6 +420,8 @@ txt.insert('end', "5. ¥¦¥£¥ó¥É¥¦¤òËä¤á¹þ¤ó¤À¥Æ¥­¥¹¥È (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤Î
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "6. ¸¡º÷\n", tag_demo, "demo-search")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. ¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤ÎÂÐÅù²½(peering) (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", tag_demo, "demo-textpeer")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "¥­¥ã¥ó¥Ð¥¹\n", tag_middle)
@@ -394,18 +444,23 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "8. ¥¹¥¯¥í¡¼¥ë²Äǽ¤Ê¥­¥ã¥ó¥Ð¥¹\n",
tag_demo, "demo-cscroll")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. ¥Á¥§¥¹¥Ü¡¼¥É¾å¤Îµ³»Î¤Î½ä²ó (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo, "demo-knightstour")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
-#txt.insert('end', "¥¹¥±¡¼¥ë\n", tag_middle)
-txt.insert('end', "¥¹¥±¡¼¥ë\n", tag_kanji_title)
+#txt.insert('end', "¥¹¥±¡¼¥ë¤È¥×¥í¥°¥ì¥¹¥Ð¡¼\n", tag_middle)
+txt.insert('end', "¥¹¥±¡¼¥ë¤È¥×¥í¥°¥ì¥¹¥Ð¡¼\n", tag_kanji_title)
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "1. ¿âľ\n", tag_demo.id, "demo-vscale")
+txt.insert('end', "1. ¿âľ¥¹¥±¡¼¥ë\n", tag_demo.id, "demo-vscale")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "2. ¿åÊ¿\n", tag_demo.id, "demo-hscale")
+txt.insert('end', "2. ¿åÊ¿¥¹¥±¡¼¥ë\n", tag_demo.id, "demo-hscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥×¥í¥°¥ì¥¹¥Ð¡¼ (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n", tag_demo.id, "demo-ttkprogress")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
-txt.insert('end', "¥Ú¥¤¥ó¥É¥¦¥£¥ó¥É¥¦\n", tag_kanji_title)
+txt.insert('end', "¥Ú¥¤¥ó¥É¥¦¥£¥ó¥É¥¦¤È¥Î¡¼¥È¥Ö¥Ã¥¯\n", tag_kanji_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. ¿åÊ¿Êý¸þ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
tag_demo.id, "demo-paned1")
@@ -413,10 +468,16 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "2. ¿âľÊý¸þ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
tag_demo.id, "demo-paned2")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿Ëä¤á¹þ¤ß¥Ú¥¤¥ó (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo.id, "demo-ttkpane")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ¥Î¡¼¥È¥Ö¥Ã¥¯¥¦¥£¥¸¥§¥Ã¥È (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo.id, "demo-ttknote")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
-#txt.insert('end', "¥á¥Ë¥å¡¼\n", tag_middle)
-txt.insert('end', "¥á¥Ë¥å¡¼\n", tag_kanji_title)
+#txt.insert('end', "¥á¥Ë¥å¡¼¤È¥Ä¡¼¥ë¥Ð¡¼\n", tag_middle)
+txt.insert('end', "¥á¥Ë¥å¡¼¤È¥Ä¡¼¥ë¥Ð¡¼\n", tag_kanji_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. ¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¤ò´Þ¤ó¤À¥¦¥£¥ó¥É¥¦\n",
tag_demo, "demo-menu")
@@ -430,6 +491,12 @@ txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "4. ¥á¥Ë¥å¡¼¥Ü¥¿¥ó (Tk8.x ÀìÍÑ)\n",
tag_demo, "demo-menubu")
txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿¥á¥Ë¥å¡¼¥Ü¥¿¥ó (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo.id, "demo-ttkmenu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ¥Æ¡¼¥Þ¤ËÂбþ¤·¤¿¥Ä¡¼¥ë¥Ð¡¼ (Tile/Ttk³ÈÄ¥¤Ø¤ÎÂбþ¤¬É¬Í×)\n",
+ tag_demo.id, "demo-toolbar")
+txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
#txt.insert('end', "¥À¥¤¥¢¥í¥°¥¦¥£¥ó¥É¥¦\n", tag_middle)
@@ -437,9 +504,11 @@ txt.insert('end', "¥À¥¤¥¢¥í¥°¥¦¥£¥ó¥É¥¦\n", tag_kanji_title)
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "1. ¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\n", tag_demo, "demo-msgbox")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "2. ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°\n", tag_demo, "demo-filebox")
+txt.insert('end', "2. ¾ÜºÙ¥Æ¥­¥¹¥ÈÉÕ¤­¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", tag_demo, "demo-msgbox2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°\n", tag_demo, "demo-filebox")
txt.insert('end', " \n ", tag_demospace)
-txt.insert('end', "3. ¿§ÁªÂò¥À¥¤¥¢¥í¥°\n", tag_demo, "demo-clrpick")
+txt.insert('end', "4. ¿§ÁªÂò¥À¥¤¥¢¥í¥°\n", tag_demo, "demo-clrpick")
txt.insert('end', " \n ", tag_demospace)
txt.insert('end', "\n")
@@ -488,25 +557,30 @@ def showVars1(parent, *args)
end
top = TkToplevel.new(parent) {|w|
title "Variable values"
- TkLabel.new(w) {
+ base = TkFrame.new(w).pack(:fill=>:both, :expand=>true)
+ TkLabel.new(base) {
text "ÊÑ¿ôÃÍ:"
width 20
anchor 'center'
- font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ if $tk_version =~ /^4.*/
+ font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ else
+ font 'Helvetica 14'
+ end
}.pack('side'=>'top', 'fill'=>'x')
len = 1
args.each{|vnam,vbody|
len = vnam.to_s.length if vnam.to_s.length > len
}
args.each{|vnam,vbody|
- TkFrame.new(w){|f|
+ TkFrame.new(base){|f|
#TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left')
TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left')
TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\
.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
}.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x')
}
- TkButton.new(w) {
+ TkButton.new(base) {
text "λ²ò"
command proc{w.destroy}
}.pack('side'=>'bottom', 'pady'=>2)
@@ -521,10 +595,12 @@ def showVars2(parent, *args)
rescue
end
end
- $showVarsWin[parent.path] = TkToplevel.new(parent) {|w|
+ $showVarsWin[parent.path] = TkToplevel.new(parent) {|top|
title "Variable values"
- TkLabelFrame.new(w, :text=>"ÊÑ¿ôÃÍ:",
+ base = TkFrame.new(top).pack(:fill=>:both, :expand=>true)
+
+ TkLabelFrame.new(base, :text=>"ÊÑ¿ôÃÍ:",
:font=>{:family=>'Helvetica', :size=>14}){|f|
args.each{|vnam,vbody|
TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'),
@@ -536,15 +612,15 @@ def showVars2(parent, *args)
f.grid_columnconfig(1, :weight=>1)
f.grid_rowconfig(100, :weight=>1)
}
- TkButton.new(w, :text=>"λ²ò", :width=>8, :default=>:active,
- :command=>proc{w.destroy}){|b|
- w.bind('Return', proc{b.invoke})
- w.bind('Escape', proc{b.invoke})
+ TkButton.new(base, :text=>"λ²ò", :width=>8, :default=>:active,
+ :command=>proc{top.destroy}){|b|
+ top.bind('Return', proc{b.invoke})
+ top.bind('Escape', proc{b.invoke})
b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4])
}
- w.grid_columnconfig(0, :weight=>1)
- w.grid_rowconfig(0, :weight=>1)
+ base.grid_columnconfig(0, :weight=>1)
+ base.grid_rowconfig(0, :weight=>1)
}
end
@@ -638,8 +714,27 @@ def _null_binding
end
private :_null_binding
-def eval_samplecode(code)
- Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }.run
+def eval_samplecode(code, file=nil)
+ #eval(code)
+ #_null_binding.pseudo_toplevel_eval{ eval(code) }
+ #Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }
+ Thread.new{
+ _null_binding.pseudo_toplevel_eval{
+ begin
+ if file
+ eval(code, binding, "(eval:#{file})")
+ else
+ eval(code)
+ end
+ rescue Exception=>e
+ #p e
+ TkBgError.show(e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------")
+ end
+ }
+ }
Tk.update
end
@@ -653,7 +748,7 @@ def invoke(txt, idx)
Tk.update
# eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding)
# Tk.update
- eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join)
+ eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb')
txt.cursor(cursor)
$tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
@@ -699,6 +794,7 @@ def showCode1(demo)
if $code_window == nil || TkWinfo.exist?($code_window) == false
$code_window = TkToplevel.new(nil)
f = TkFrame.new($code_window)
+
TkButton.new(f) {
#text "λ²ò"
text "ÊĤ¸¤ë"
@@ -706,14 +802,25 @@ def showCode1(demo)
$code_window.destroy
$code_window = nil
}
- }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2)
TkButton.new(f) {
text "ºÆ¼Â¹Ô"
# command proc{eval($code_text.get('1.0','end'), _null_binding)}
- command proc{eval_samplecode($code_text.get('1.0','end'))}
- }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
-# f.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x')
- f.pack('side'=>'bottom', 'fill'=>'x')
+ command proc{eval_samplecode($code_text.get('1.0','end'), '<viewer>')}
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2)
+
+ TkLabel.new(f,'text'=>'line:').pack('side'=>'left')
+ linenum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+ TkLabel.new(f,'text'=>' pos:').pack('side'=>'left')
+ posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
+ f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x')
if $tk_version =~ /^4\.[01]/
s = TkScrollbar.new($code_window, 'orient'=>'vertical')
@@ -757,10 +864,21 @@ def showCode1(demo)
TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
}
end
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
else
$code_window.deiconify
$code_window.raise
end
+
$code_window.title("Demo code: #{file}")
$code_window.iconname(file)
# fid = open(file, 'r')
@@ -771,6 +889,9 @@ def showCode1(demo)
#$code_mark = TkTextMark.new($code_text, '1.0')
#$code_text.set_insert('1.0')
TkTextMarkInsert.new($code_text,'1.0')
+
+ $set_linenum.call($code_text)
+
fid.close
end
@@ -791,7 +912,19 @@ def showCode2(demo)
tf.grid_columnconfigure(0, :weight=>1)
bf = TkFrame.new($code_window)
-
+
+ lf = TkFrame.new(bf)
+ TkLabel.new(lf, :text=>'line:').pack(:side=>:left)
+ linenum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+ TkLabel.new(lf, :text=>' pos:').pack(:side=>:left)
+ posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
#b_dis = TkButton.new(bf, :text=>'λ²ò', :default=>:active,
b_dis = TkButton.new(bf, :text=>'ÊĤ¸¤ë', :default=>:active,
:command=>proc{
@@ -805,12 +938,12 @@ def showCode2(demo)
b_run = TkButton.new(bf, :text=>'ºÆ¼Â¹Ô',
:command=>proc{
# eval($code_text.get('1.0','end'), _null_binding)
- eval_samplecode($code_text.get('1.0','end'))
+ eval_samplecode($code_text.get('1.0','end'), '<viewer>')
},
:image=>$image['refresh'], :compound=>:left)
- TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
- bf.grid_columnconfigure(0, :weight=>1)
+ TkGrid(lf, 'x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
+ bf.grid_columnconfigure(1, :weight=>1)
TkGrid(tf, :sticky=>'news')
TkGrid(bf, :sticky=>'ew')
@@ -823,6 +956,16 @@ def showCode2(demo)
$code_window.bindinfo('Return').each{|cmd, arg|
$code_window.bind_append('Escape', cmd, arg)
}
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
else
$code_window.deiconify
$code_window.raise
@@ -834,6 +977,9 @@ def showCode2(demo)
$code_text.delete('1.0', 'end')
$code_text.insert('1.0', fid.read)
TkTextMarkInsert.new($code_text,'1.0')
+
+ $set_linenum.call($code_text)
+
fid.close
end
@@ -931,12 +1077,13 @@ end
#
def aboutBox
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
- 'message'=>"Ruby/Tk ¥¦¥£¥¸¥§¥Ã¥È¥Ç¥â Ver.1.6.0-jp\n\n" +
+ 'message'=>"Ruby/Tk ¥¦¥£¥¸¥§¥Ã¥È¥Ç¥â Ver.1.7.0-jp\n\n" +
"based on demos of Tk8.1 -- 8.5 " +
- "( Copyright:: " +
+ "( Copyright of Tcl/Tk demos:: " +
"(c) 1996-1997 Sun Microsystems, Inc. / " +
"(c) 1997-2000 Ajuba Solutions, Inc. / " +
- "(c) 2001-2003 Donal K. Fellows )\n\n" +
+ "(c) 2001-2007 Donal K. Fellows / " +
+ "(c) 2002-2007 Daniel A. Steffen )\n\n" +
"Your Ruby & Tk Version ::\n" +
"Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}\n\n" +
"Ruby/Tk release date :: tcltklib #{TclTkLib::RELEASE_DATE}; tk #{Tk::RELEASE_DATE}")
@@ -958,7 +1105,7 @@ ARGV.each{|cmd|
end
#eval(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join,
# _null_binding)
- eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join)
+ eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join, cmd + '.rb')
}
if no_launcher
$root.withdraw # hide root window
diff --git a/ext/tk/sample/encstr_usage.rb b/ext/tk/sample/encstr_usage.rb
index 4285ec861c..b22c2504ac 100644
--- a/ext/tk/sample/encstr_usage.rb
+++ b/ext/tk/sample/encstr_usage.rb
@@ -11,7 +11,7 @@ t1 = TkText.new(:height=>5).pack
t2 = TkText.new(:height=>5).pack
t3 = TkText.new(:height=>5).pack
-src_str = IO.readlines('iso2022-kr.txt').join
+src_str = IO.readlines(File.join(File.dirname(__FILE__),'iso2022-kr.txt')).join
t1.insert('end',
"use neither Tk::EncodedString class nor Tk.encoding= method\n\n")
@@ -23,7 +23,8 @@ t2.insert('end',
t2.insert('end', enc_str)
Tk.encoding = 'iso2022-kr'
-t3.insert('end', "use Tk.encoding = 'iso2022-kr'\n\n")
+t3.insert('end', "use Tk.encoding = 'iso2022-kr' (Tk.force_default_encoding? == #{Tk.force_default_encoding?})\n\n")
+
t3.insert('end', src_str)
Tk.mainloop
diff --git a/ext/tk/sample/figmemo_sample.rb b/ext/tk/sample/figmemo_sample.rb
new file mode 100644
index 0000000000..1b6979d2dd
--- /dev/null
+++ b/ext/tk/sample/figmemo_sample.rb
@@ -0,0 +1,456 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+begin
+ # try to use Img extension
+ require 'tkextlib/tkimg'
+rescue Exception
+ # cannot use Img extention --> ignore
+end
+
+
+############################
+# scrolled_canvas
+class TkScrolledCanvas < TkCanvas
+ include TkComposite
+
+ def initialize_composite(keys={})
+ @h_scr = TkScrollbar.new(@frame)
+ @v_scr = TkScrollbar.new(@frame)
+
+ @canvas = TkCanvas.new(@frame)
+ @path = @canvas.path
+
+ @canvas.xscrollbar(@h_scr)
+ @canvas.yscrollbar(@v_scr)
+
+ TkGrid.rowconfigure(@frame, 0, :weight=>1, :minsize=>0)
+ TkGrid.columnconfigure(@frame, 0, :weight=>1, :minsize=>0)
+
+ @canvas.grid(:row=>0, :column=>0, :sticky=>'news')
+ @h_scr.grid(:row=>1, :column=>0, :sticky=>'ew')
+ @v_scr.grid(:row=>0, :column=>1, :sticky=>'ns')
+
+ delegate('DEFAULT', @canvas)
+ delegate('background', @canvas, @h_scr, @v_scr)
+ delegate('activebackground', @h_scr, @v_scr)
+ delegate('troughcolor', @h_scr, @v_scr)
+ delegate('repeatdelay', @h_scr, @v_scr)
+ delegate('repeatinterval', @h_scr, @v_scr)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ delegate_alias('canvasborderwidth', 'borderwidth', @canvas)
+ delegate_alias('canvasrelief', 'relief', @canvas)
+
+ delegate_alias('scrollbarborderwidth', 'borderwidth', @h_scr, @v_scr)
+ delegate_alias('scrollbarrelief', 'relief', @h_scr, @v_scr)
+
+ configure(keys) unless keys.empty?
+ end
+end
+
+############################
+class PhotoCanvas < TkScrolledCanvas
+
+USAGE = <<EOT
+--- WHAT IS ---
+You can write comments on the loaded image, and save it as a Postscipt
+file (original image file is not modified). Each comment is drawn as a
+set of an indicator circle, an arrow, and a memo text. See the following
+how to write comments.
+This can save the list of memo texts to another file. It may useful to
+search the saved Postscript file by the comments on them.
+This may not support multibyte characters (multibyte texts are broken on
+a Postscript file). It depends on features of canvas widgets of Tcl/Tk
+libraries linked your Ruby/Tk. If you use Tcl/Tk8.0-jp (Japanized Tcl/Tk),
+you can (possibly) get a Japanese Postscript file.
+
+--- BINDINGS ---
+* Button-1 : draw comments by following steps
+ 1st - Set center of a indicator circle.
+ 2nd - Set head position of an arrow.
+ 3rd - Set tail position of an arrow, and show an entry box.
+ Input a memo text and hit 'Enter' key to entry the comment.
+
+* Button-2-drag : scroll the canvas
+
+* Button-3 : when drawing, cancel current drawing
+
+* Double-Button-3 : delete the clicked comment (text, arrow, and circle)
+EOT
+
+ def initialize(*args)
+ super(*args)
+
+ self.highlightthickness = 0
+ self.selectborderwidth = 0
+
+ @photo = TkPhotoImage.new
+ @img = TkcImage.new(self, 0, 0, :image=>@photo)
+
+ width = self.width
+ height = self.height
+ @scr_region = [-width, -height, width, height]
+ self.scrollregion(@scr_region)
+ self.xview_moveto(0.25)
+ self.yview_moveto(0.25)
+
+ @col = 'red'
+ @font = 'Helvetica -12'
+
+ @memo_id_num = -1
+ @memo_id_head = 'memo_'
+ @memo_id_tag = nil
+ @overlap_d = 2
+
+ @state = TkVariable.new
+ @border = 2
+ @selectborder = 1
+ @delta = @border + @selectborder
+ @entry = TkEntry.new(self, :relief=>:ridge, :borderwidth=>@border,
+ :selectborderwidth=>@selectborder,
+ :highlightthickness=>0)
+ @entry.bind('Return'){@state.value = 0}
+
+ @mode = old_mode = 0
+
+ _state0()
+
+ bind('2', :x, :y){|x,y| scan_mark(x,y)}
+ bind('B2-Motion', :x, :y){|x,y| scan_dragto(x,y)}
+
+ bind('3'){
+ next if (old_mode = @mode) == 0
+ @items.each{|item| item.delete }
+ _state0()
+ }
+
+ bind('Double-3', :widget, :x, :y){|w, x, y|
+ next if old_mode != 0
+ x = w.canvasx(x)
+ y = w.canvasy(y)
+ tag = nil
+ w.find_overlapping(x - @overlap_d, y - @overlap_d,
+ x + @overlap_d, y + @overlap_d).find{|item|
+ ! (item.tags.find{|name|
+ if name =~ /^(#{@memo_id_head}\d+)$/
+ tag = $1
+ end
+ }.empty?)
+ }
+ w.delete(tag) if tag
+ }
+ end
+
+ #-----------------------------------
+ private
+ def _state0() # init
+ @mode = 0
+
+ @memo_id_num += 1
+ @memo_id_tag = @memo_id_head + @memo_id_num.to_s
+
+ @target = nil
+ @items = []
+ @mark = [0, 0]
+ bind_remove('Motion')
+ bind('ButtonRelease-1', proc{|x,y| _state1(x,y)}, '%x', '%y')
+ end
+
+ def _state1(x,y) # set center
+ @mode = 1
+
+ @target = TkcOval.new(self,
+ [canvasx(x), canvasy(y)], [canvasx(x), canvasy(y)],
+ :outline=>@col, :width=>3, :tags=>[@memo_id_tag])
+ @items << @target
+ @mark = [x,y]
+
+ bind('Motion', proc{|x,y| _state2(x,y)}, '%x', '%y')
+ bind('ButtonRelease-1', proc{|x,y| _state3(x,y)}, '%x', '%y')
+ end
+
+ def _state2(x,y) # create circle
+ @mode = 2
+
+ r = Integer(Math.sqrt((x-@mark[0])**2 + (y-@mark[1])**2))
+ @target.coords([canvasx(@mark[0] - r), canvasy(@mark[1] - r)],
+ [canvasx(@mark[0] + r), canvasy(@mark[1] + r)])
+ end
+
+ def _state3(x,y) # set line start
+ @mode = 3
+
+ @target = TkcLine.new(self,
+ [canvasx(x), canvasy(y)], [canvasx(x), canvasy(y)],
+ :arrow=>:first, :arrowshape=>[10, 14, 5],
+ :fill=>@col, :tags=>[@memo_id_tag])
+ @items << @target
+ @mark = [x, y]
+
+ bind('Motion', proc{|x,y| _state4(x,y)}, '%x', '%y')
+ bind('ButtonRelease-1', proc{|x,y| _state5(x,y)}, '%x', '%y')
+ end
+
+ def _state4(x,y) # create line
+ @mode = 4
+
+ @target.coords([canvasx(@mark[0]), canvasy(@mark[1])],
+ [canvasx(x), canvasy(y)])
+ end
+
+ def _state5(x,y) # set text
+ @mode = 5
+
+ if x - @mark[0] >= 0
+ justify = 'left'
+ dx = - @delta
+
+ if y - @mark[1] >= 0
+ anchor = 'nw'
+ dy = - @delta
+ else
+ anchor = 'sw'
+ dy = @delta
+ end
+ else
+ justify = 'right'
+ dx = @delta
+
+ if y - @mark[1] >= 0
+ anchor = 'ne'
+ dy = - @delta
+ else
+ anchor = 'se'
+ dy = @delta
+ end
+ end
+
+ bind_remove('Motion')
+
+ @entry.value = ''
+ @entry.configure(:justify=>justify, :font=>@font, :foreground=>@col)
+
+ ewin = TkcWindow.new(self, [canvasx(x)+dx, canvasy(y)+dy],
+ :window=>@entry, :state=>:normal, :anchor=>anchor,
+ :tags=>[@memo_id_tag])
+
+ @entry.focus
+ @entry.grab
+ @state.wait
+ @entry.grab_release
+
+ ewin.delete
+
+ @target = TkcText.new(self, [canvasx(x), canvasy(y)],
+ :anchor=>anchor, :justify=>justify,
+ :fill=>@col, :font=>@font, :text=>@entry.value,
+ :tags=>[@memo_id_tag])
+
+ _state0()
+ end
+
+ #-----------------------------------
+ public
+ def load_photo(filename)
+ @photo.configure(:file=>filename)
+ end
+
+ def modified?
+ ! ((find_withtag('all') - [@img]).empty?)
+ end
+
+ def fig_erase
+ (find_withtag('all') - [@img]).each{|item| item.delete}
+ end
+
+ def reset_region
+ width = @photo.width
+ height = @photo.height
+
+ if width > @scr_region[2]
+ @scr_region[0] = -width
+ @scr_region[2] = width
+ end
+
+ if height > @scr_region[3]
+ @scr_region[1] = -height
+ @scr_region[3] = height
+ end
+
+ self.scrollregion(@scr_region)
+ self.xview_moveto(0.25)
+ self.yview_moveto(0.25)
+ end
+
+ def get_texts
+ ret = []
+ find_withtag('all').each{|item|
+ if item.kind_of?(TkcText)
+ ret << item[:text]
+ end
+ }
+ ret
+ end
+end
+############################
+
+# define methods for menu
+def open_file(canvas, fname)
+ if canvas.modified?
+ ret = Tk.messageBox(:icon=>'warning',:type=>'okcancel',:default=>'cancel',
+ :message=>'Canvas may be modified. Realy erase? ')
+ return if ret == 'cancel'
+ end
+
+ filetypes = [
+ ['GIF Files', '.gif'],
+ ['GIF Files', [], 'GIFF'],
+ ['PPM Files', '.ppm'],
+ ['PGM Files', '.pgm']
+ ]
+
+ begin
+ if Tk::Img::package_version != ''
+ filetypes << ['JPEG Files', ['.jpg', '.jpeg']]
+ filetypes << ['PNG Files', '.png']
+ filetypes << ['PostScript Files', '.ps']
+ filetypes << ['PDF Files', '.pdf']
+ filetypes << ['Windows Bitmap Files', '.bmp']
+ filetypes << ['Windows Icon Files', '.ico']
+ filetypes << ['PCX Files', '.pcx']
+ filetypes << ['Pixmap Files', '.pixmap']
+ filetypes << ['SGI Files', '.sgi']
+ filetypes << ['Sun Raster Files', '.sun']
+ filetypes << ['TGA Files', '.tga']
+ filetypes << ['TIFF Files', '.tiff']
+ filetypes << ['XBM Files', '.xbm']
+ filetypes << ['XPM Files', '.xpm']
+ end
+ rescue
+ end
+
+ filetypes << ['ALL Files', '*']
+
+ fpath = Tk.getOpenFile(:filetypes=>filetypes)
+ return if fpath.empty?
+
+ begin
+ canvas.load_photo(fpath)
+ rescue => e
+ Tk.messageBox(:icon=>'error', :type=>'ok',
+ :message=>"Fail to read '#{fpath}'.\n#{e.message}")
+ end
+
+ canvas.fig_erase
+ canvas.reset_region
+
+ fname.value = fpath
+end
+
+# --------------------------------
+def save_memo(canvas, fname)
+ initname = fname.value
+ if initname != '-'
+ initname = File.basename(initname, File.extname(initname))
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Text Files', '.txt'],
+ ['ALL Files', '*'] ],
+ :initialfile=>initname)
+ else
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Text Files', '.txt'],
+ ['ALL Files', '*'] ])
+ end
+ return if fpath.empty?
+
+ begin
+ fid = open(fpath, 'w')
+ rescue => e
+ Tk.messageBox(:icon=>'error', :type=>'ok',
+ :message=>"Fail to open '#{fname.value}'.\n#{e.message}")
+ end
+
+ begin
+ canvas.get_texts.each{|txt|
+ fid.print(txt, "\n")
+ }
+ ensure
+ fid.close
+ end
+end
+
+# --------------------------------
+def ps_print(canvas, fname)
+ initname = fname.value
+ if initname != '-'
+ initname = File.basename(initname, File.extname(initname))
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Postscript Files', '.ps'],
+ ['ALL Files', '*'] ],
+ :initialfile=>initname)
+ else
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Postscript Files', '.ps'],
+ ['ALL Files', '*'] ])
+ end
+ return if fpath.empty?
+
+ bbox = canvas.bbox('all')
+ canvas.postscript(:file=>fpath, :x=>bbox[0], :y=>bbox[1],
+ :width=>bbox[2] - bbox[0], :height=>bbox[3] - bbox[1])
+end
+
+# --------------------------------
+def quit(canvas)
+ ret = Tk.messageBox(:icon=>'warning', :type=>'okcancel',
+ :default=>'cancel',
+ :message=>'Realy quit? ')
+ exit if ret == 'ok'
+end
+
+# --------------------------------
+# setup root
+root = TkRoot.new(:title=>'Fig Memo')
+
+# create canvas frame
+canvas = PhotoCanvas.new(root).pack(:fill=>:both, :expand=>true)
+usage_frame = TkFrame.new(root, :relief=>:ridge, :borderwidth=>2)
+hide_btn = TkButton.new(usage_frame, :text=>'hide usage',
+ :font=>{:size=>8}, :pady=>1,
+ :command=>proc{usage_frame.unpack})
+hide_btn.pack(:anchor=>'e', :padx=>5)
+usage = TkLabel.new(usage_frame, :text=>PhotoCanvas::USAGE,
+ :font=>'Helvetica 8', :justify=>:left).pack
+
+show_usage = proc{
+ usage_frame.pack(:before=>canvas, :fill=>:x, :expand=>true)
+}
+
+fname = TkVariable.new('-')
+f = TkFrame.new(root, :relief=>:sunken, :borderwidth=>1).pack(:fill=>:x)
+label = TkLabel.new(f, :textvariable=>fname,
+ :font=>{:size=>-12, :weight=>:bold},
+ :anchor=>'w').pack(:side=>:left, :fill=>:x, :padx=>10)
+
+# create menu
+mspec = [
+ [ ['File', 0],
+ ['Show Usage', proc{show_usage.call}, 5],
+ '---',
+ ['Open Image File', proc{open_file(canvas, fname)}, 0],
+ ['Save Memo Texts', proc{save_memo(canvas, fname)}, 0],
+ '---',
+ ['Save Postscript', proc{ps_print(canvas, fname)}, 5],
+ '---',
+ ['Quit', proc{quit(canvas)}, 0]
+ ]
+]
+root.add_menubar(mspec)
+
+# manage wm_protocol
+root.protocol(:WM_DELETE_WINDOW){quit(canvas)}
+
+# show usage
+show_usage.call
+
+# --------------------------------
+# start eventloop
+Tk.mainloop
diff --git a/ext/tk/sample/irbtkw.rbw b/ext/tk/sample/irbtkw.rbw
index f6a35be6ed..3fb6dde626 100644
--- a/ext/tk/sample/irbtkw.rbw
+++ b/ext/tk/sample/irbtkw.rbw
@@ -4,7 +4,7 @@
#
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
-release = '2006/11/06'
+release = '2008/03/08'
require 'tk'
begin
@@ -15,10 +15,32 @@ end
require 'irb'
+if TkCore::WITH_ENCODING
+else
+ # $KCODE setup
+ case Tk.encoding
+ when 'shiftjis', 'cp932'
+ $KCODE='SJIS'
+ when 'euc-jp'
+ $KCODE='EUC'
+ when 'utf-8', 'unicode'
+ $KCODE='UTF8'
+ else
+ # unknown
+ end
+end
+
# console setup
top = TkToplevel.new(:title=>'IRB console')
top.protocol(:WM_DELETE_WINDOW){ Tk.exit }
+case (Tk.windowingsystem)
+when 'win32'
+ fnt = ['MS Gothic', '-12']
+else
+ fnt = ['courier', '-12']
+end
+
console = TkTextIO.new(top, :mode=>:console,
:width=>80).pack(:side=>:left,
:expand=>true, :fill=>:both)
diff --git a/ext/tk/sample/tkextlib/tile/demo.rb b/ext/tk/sample/tkextlib/tile/demo.rb
index b604410da4..633a072460 100644
--- a/ext/tk/sample/tkextlib/tile/demo.rb
+++ b/ext/tk/sample/tkextlib/tile/demo.rb
@@ -20,6 +20,14 @@ def version?(ver)
TkPackage.vcompare(Tk::Tile.package_version, ver) >= 0
end
+# define Tcl/Tk procedures for compatibility
+Tk::Tile.__define_LoadImages_proc_for_compatibility__!
+Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
+
+unless Tk::Tile::Style.theme_names.include?('step')
+ Tk::Tile::Style.theme_create('step')
+end
+
Tk.load_tclscript(File.join(demodir, 'toolbutton.tcl'))
Tk.load_tclscript(File.join(demodir, 'repeater.tcl'))
@@ -55,7 +63,7 @@ $V = TkVariable.new_hash(:THEME => 'default',
:CHOICE => 2)
# Add in any available loadable themes.
-TkPackage.names.find_all{|n| n =~ /^tile::theme::/}.each{|pkg|
+TkPackage.names.find_all{|n| n =~ /^(tile|ttk)::theme::/}.each{|pkg|
name = pkg.split('::')[-1]
unless $THEMELIST.assoc(name)
$THEMELIST << [name, Tk.tk_call('string', 'totitle', name)]
@@ -66,7 +74,8 @@ TkPackage.names.find_all{|n| n =~ /^tile::theme::/}.each{|pkg|
$RUBY_THEMELIST = []
begin
load(File.join(demodir, 'themes', 'kroc.rb'), true)
-rescue
+rescue => e
+raise e
$RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', false]
else
$RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', true]
@@ -79,8 +88,8 @@ def makeThemeControl(parent)
:variable=>$V.ref(:THEME),
:command=>proc{setTheme(theme)})
b.grid(:sticky=>:ew)
- unless (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
- b.state(:disabled)
+ unless (TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
+ b.ttk_state(:disabled)
end
}
$RUBY_THEMELIST.each{|theme, name, available|
@@ -88,7 +97,7 @@ def makeThemeControl(parent)
:variable=>$V.ref(:THEME),
:command=>proc{setTheme(theme)})
b.grid(:sticky=>:ew)
- b.state(:disabled) unless available
+ b.ttk_state(:disabled) unless available
}
c
end
@@ -98,7 +107,7 @@ def makeThemeMenu(parent)
$THEMELIST.each{|theme, name|
m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
:value=>theme, :command=>proc{setTheme(theme)})
- unless (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
+ unless (TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
m.entryconfigure(:end, :state=>:disabled)
end
}
@@ -111,8 +120,10 @@ def makeThemeMenu(parent)
end
def setTheme(theme)
- if (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
- TkPackage.require("tile::theme::#{theme}")
+ if (pkg = TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
+ unless Tk::Tile::Style.theme_names.find{|n| n == theme}
+ TkPackage.require(pkg)
+ end
end
Tk::Tile::Style.theme_use(theme)
end
@@ -675,7 +686,7 @@ values = %w(list abc def ghi jkl mno pqr stu vwx yz)
combo, :values=>values, :textvariable=>$V.ref(:COMBO))
cb.pack(:side=>:top, :padx=>2, :pady=>2, :expand=>false, :fill=>:x)
if i == 1
- cb.state :readonly
+ cb.ttk_state :readonly
begin
cb.current = 3 # ignore if unsupported (tile0.4)
rescue
@@ -922,11 +933,11 @@ end
def updateStates
$states_list.each{|st|
begin
- $State[st] = $Widget.window.instate(st)
+ $State[st] = $Widget.window.ttk_instate(st)
rescue
- $states_btns[st].state('disabled')
+ $states_btns[st].ttk_state('disabled')
else
- $states_btns[st].state('!disabled')
+ $states_btns[st].ttk_state('!disabled')
end
}
end
@@ -934,9 +945,9 @@ end
def changeState(st)
if $Widget.value != ''
if $State.bool_element(st)
- $Widget.window.state(st)
+ $Widget.window.ttk_state(st)
else
- $Widget.window.state("!#{st}")
+ $Widget.window.ttk_state("!#{st}")
end
end
end
diff --git a/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl b/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl
index 19ddda7c73..4facac70d8 100644
--- a/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl
+++ b/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl
@@ -1,6 +1,6 @@
# Package index for tile demo pixmap themes.
if {[file isdirectory [file join $dir blue]]} {
- package ifneeded tile::theme::blue 0.0.1 \
+ package ifneeded tile::theme::blue 0.7 \
[list source [file join $dir blue.tcl]]
}
diff --git a/ext/tk/sample/tkextlib/tile/themes/kroc.rb b/ext/tk/sample/tkextlib/tile/themes/kroc.rb
index f67ce7a897..27006d847f 100644
--- a/ext/tk/sample/tkextlib/tile/themes/kroc.rb
+++ b/ext/tk/sample/tkextlib/tile/themes/kroc.rb
@@ -95,8 +95,35 @@ def kroc_rb_settings
#
# Elements:
#
- if TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ Tk::Tile::Style.element_create('Button.button',
+ :image,
+ [ $images['button-n'],
+ :pressed, $images['button-p'],
+ :active, $images['button-h'],
+ ], :border=>3, :sticky=>:ew)
+
+ Tk::Tile::Style.element_create('Checkbutton.indicator',
+ :image,
+ [ $images['check-nu'],
+ [:pressed, :selected],$images['check-nc'],
+ :pressed, $images['check-nu'],
+ [:active, :selected], $images['check-hc'],
+ :active, $images['check-hu'],
+ :selected, $images['check-nc'],
+ ], :sticky=>:w)
+ Tk::Tile::Style.element_create('Radiobutton.indicator',
+ :image,
+ [ $images['radio-nu'],
+ [:pressed,:selected],$images['radio-nc'],
+ :pressed, $images['radio-nu'],
+ [:active,:selected], $images['radio-hc'],
+ :active, $images['radio-hu'],
+ :selected, $images['radio-nc'],
+ ], :sticky=>:w)
+
+ elsif TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
Tk::Tile::Style.element_create('Button.button',
:image, $images['button-n'],
:map=>[
@@ -125,7 +152,6 @@ def kroc_rb_settings
], :sticky=>:w)
else # tile 0.4 or earlier
-
Tk::Tile::Style.element_create('Button.button', :pixmap,
:images=>[
:pressed, $images['button-p'],
diff --git a/ext/tk/sample/tkextlib/treectrl/demo.rb b/ext/tk/sample/tkextlib/treectrl/demo.rb
index 50ecde91f0..eed95d0e1c 100644
--- a/ext/tk/sample/tkextlib/treectrl/demo.rb
+++ b/ext/tk/sample/tkextlib/treectrl/demo.rb
@@ -9,11 +9,12 @@ $HasColumnCreate = Tk::TreeCtrl::HasColumnCreateCommand
$Version_1_1_OrLater = (TkPackage.vcompare(Tk::TreeCtrl.package_version, '1.1') >= 0)
-if Hash.instance_methods.include?('key')
- # probably ruby 1.9.x --> use Hash#key
+#if Hash.instance_methods.include?(:key)
+if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ # ruby 1.9.x --> use Hash#key
# Because Hash#index show warning "Hash#index is deprecated; use Hash#key".
else
- # probably ruby 1.8.x --> use Hash#index
+ # ruby 1.8.x --> use Hash#index
class Hash
alias key index
end
diff --git a/ext/tk/sample/tkrttimer.rb b/ext/tk/sample/tkrttimer.rb
index 531f4a8d5a..0abd4ecbd2 100644
--- a/ext/tk/sample/tkrttimer.rb
+++ b/ext/tk/sample/tkrttimer.rb
@@ -17,8 +17,17 @@ TkLabel.new(f2, :text=>'use TkRTTimer class').pack
label2 = TkLabel.new(:parent=>f2, :relief=>:raised,
:width=>10).pack(:fill=>:both)
-TkLabel.new(:text=>'Interval setting of each timer is 10 ms.',
- :padx=>10, :pady=>5).pack
+TkLabel.new(:padx=>10, :pady=>5, :justify=>'left', :text=><<EOT).pack
+Interval setting of each timer object is 10 ms.
+Each timer object counts up the value on each callback
+(the value is not the clock data).
+The count of the TkTimer object is delayed by execution
+time of callbacks and inaccuracy of interval.
+On the other hand, the count of the TkRTTimer object is
+not delayed. Its callback interval is not accurate too.
+But it can compute error correction about the time when
+a callback should start.
+EOT
# define the procedure repeated by the TkTimer object
tick = proc{|aobj| #<== TkTimer object
diff --git a/ext/tk/sample/tksleep_sample.rb b/ext/tk/sample/tksleep_sample.rb
new file mode 100644
index 0000000000..23f6eca54e
--- /dev/null
+++ b/ext/tk/sample/tksleep_sample.rb
@@ -0,0 +1,29 @@
+require 'tk'
+
+v = TkVariable.new(0)
+l = TkLabel.new(:textvariable=>v).pack(:pady=>[1, 10])
+
+a = TkButton.new(:text=>"button A :: proc{p ['AAA', v.value]}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
+a.command{p ['AAA', v.value]}
+
+TkLabel.new(:text=>'Callback of the button B returns LIFO order').pack
+b = TkButton.new(:text=>"button B :: proc{n = v.value; p ['B:start', n]; Tk.sleep(10000); p ['B:end', n]}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
+b.command{n = v.value; p ['B:start', n]; Tk.sleep(10000); p ['B:end', n]}
+
+TkLabel.new(:text=>'Callback of the button C returns FIFO order').pack
+c = TkButton.new(:text=>"button C :: proc{n = v.value; Thread.new{p ['C:start', n]; Tk.sleep(10000); p ['C:end', n]}}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
+c.command{n = v.value; Thread.new{p ['C:start', n]; Tk.sleep(10000); p ['C:end', n]}}
+
+TkLabel.new(:text=>'Callback of the button D blocks eventloop (no respond to event)').pack
+d = TkButton.new(:text=>"button D :: proc{n = v.value; p ['D:start', n]; sleep(10); p ['D:end', n]}").pack(:fill=>:x, :pady=>[1,15], :padx=>15)
+d.command{n = v.value; p ['D:start', n]; sleep(10); p ['D:end', n]}
+
+TkLabel.new(:text=>'Callback of the button E is another way to avoid eventloop blocking').pack
+e = TkButton.new(:text=>"button E :: proc{n = v.value; Thread.new{p ['D:start', n]; sleep(10); p ['D:end', n]}}").pack(:fill=>:x, :pady=>[1,15], :padx=>15)
+e.command{n = v.value; Thread.new{p ['D:start', n]; sleep(10); p ['D:end', n]}}
+
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack
+
+TkTimer.new(500, -1){v.numeric += 1}.start
+
+Tk.mainloop
diff --git a/ext/tk/sample/tktextio.rb b/ext/tk/sample/tktextio.rb
index 4573bcebdf..9f012feada 100644
--- a/ext/tk/sample/tktextio.rb
+++ b/ext/tk/sample/tktextio.rb
@@ -254,7 +254,15 @@ class TkTextIO < TkText
Tk.callback_break
end
end
- private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace, :_cb_ctrl_a
+ def _cb_ctrl_u
+ if @console_mode
+ mark_set('insert', @ins_head)
+ delete('insert', 'insert lineend')
+ Tk.callback_break
+ end
+ end
+ private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace,
+ :_cb_ctrl_a, :_cb_ctrl_u
def _setup_console_bindings
@bindtag = TkBindTag.new
@@ -328,6 +336,8 @@ class TkTextIO < TkText
@bindtag.bind('Home'){ _cb_ctrl_a }
@bindtag.bind('Control-a'){ _cb_ctrl_a }
+
+ @bindtag.bind('Control-u'){ _cb_ctrl_u }
end
private :_setup_console_bindings
diff --git a/ext/tk/sample/ttk_wrapper.rb b/ext/tk/sample/ttk_wrapper.rb
new file mode 100644
index 0000000000..1580668994
--- /dev/null
+++ b/ext/tk/sample/ttk_wrapper.rb
@@ -0,0 +1,154 @@
+#!/usr/bin/env ruby
+#
+# ttk_wrapper.rb -- use Ttk widgets as default on old Ruby/Tk scripts
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+version = '0.1.3'
+#
+##########################################################################
+# parse commandline arguments
+##########################################################################
+require 'optparse'
+opt = OptionParser.new("Usage: #{$0} [options] rubytk_script" << "\n " <<
+ "Ruby/Tk script wrapper. Use Ttk widgets as default.")
+opt.version = version
+
+OPTS = {}
+OPTS[:themedir] = []
+OPTS[:rb_theme] = []
+OPTS[:theme] = 'default'
+
+opt.on('-l', '--list', 'list available theme names'){|v| OPTS[:list] = true}
+opt.on('-t', '--theme theme', 'theme name'){|v| OPTS[:theme] = v}
+opt.on('-d', '--themedir themes_dir', 'directory of theme definitions'){|v|
+ OPTS[:themedir] << v
+}
+opt.on('-r', '--rubytheme rb_theme', 'theme definition file (ruby script)'){|v|
+ OPTS[:rb_theme] << v
+}
+opt.on('-v', '--verbose', 'print verbose messages'){|v| OPTS[:verbose] = true}
+
+opt.parse!(ARGV)
+
+
+##########################################################################
+# load Ttk (Tile) extension
+##########################################################################
+require 'tk'
+
+begin
+ require 'tkextlib/tile'
+ Tk.default_widget_set = :Ttk
+rescue LoadError
+ if OPTS[:verbose]
+ print "warning: fail to load 'Ttk' extension. use standard widgets.\n"
+ end
+end
+
+if OPTS[:verbose]
+ print "current default widget set is '#{Tk.default_widget_set}'\n"
+end
+
+
+##########################################################################
+# define Tcl/Tk procedures for compatibility.
+# those are required when want to use themes included
+# in "sample/tkextlib/tile/demo.rb".
+##########################################################################
+Tk::Tile.__define_LoadImages_proc_for_compatibility__!
+Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
+
+
+##########################################################################
+# use themes defined on the demo of Ttk (Tile) extension
+##########################################################################
+demodir = File.dirname(__FILE__)
+demo_themesdir = File.expand_path(File.join(demodir, 'tkextlib', 'tile', 'themes'))
+
+Tk::AUTO_PATH.lappend(*OPTS[:themedir]) unless OPTS[:themedir].empty?
+Tk::AUTO_PATH.lappend('.', demodir, demo_themesdir)
+
+OPTS[:themedir] << demo_themesdir
+print "theme-dirs: #{OPTS[:themedir].inspect}\n" if OPTS[:verbose]
+
+OPTS[:themedir].each{|themesdir|
+ if File.directory?(themesdir)
+ Dir.foreach(themesdir){|name|
+ next if name == '.' || name == '..'
+ path = File.join(themesdir, name)
+ Tk::AUTO_PATH.lappend(path) if File.directory?(path)
+ }
+ end
+}
+
+# This forces an update of the available packages list. It's required
+# for package names to find the themes in demos/themes/*.tcl
+Tk.ip_eval("#{TkPackage.unknown_proc} Tcl #{TkPackage.provide('Tcl')}")
+
+# load themes written in Ruby.
+themes_by_ruby = [File.join(demo_themesdir, 'kroc.rb')]
+themes_by_ruby.concat OPTS[:rb_theme]
+print "ruby-themes: #{themes_by_ruby.inspect}\n" if OPTS[:verbose]
+
+themes_by_ruby.each{|f|
+ begin
+ load(f, true)
+ rescue LoadError
+ print "fail to load \"#{f}\"\n" if OPTS[:verbose]
+ end
+}
+
+
+##########################################################################
+# ignore unsupported options of Ttk widgets
+##########################################################################
+TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__! true
+TkItemConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__! true
+
+
+##########################################################################
+# set theme of widget style
+##########################################################################
+if OPTS[:list] || OPTS[:verbose]
+ print "supported theme names: #{Tk::Tile.themes.inspect}\n"
+ exit if OPTS[:list] && ARGV.empty?
+end
+print "use theme: \"#{OPTS[:theme]}\"\n" if OPTS[:theme] && OPTS[:verbose]
+#setTheme(OPTS[:theme]) if OPTS[:theme]
+Tk::Tile.set_theme(OPTS[:theme]) if OPTS[:theme]
+
+
+##########################################################################
+# replace $0 and $RPAGRAM_NAME
+##########################################################################
+# When the expand_path of the target script is long, ruby sometimes
+# fails to set the path to $0 (the path string is trimmed).
+# The following replaces $0 and $PROGNAME to avoid such trouble.
+progname_obj = $0.dup
+$program_name = progname_obj
+
+alias $REAL_PROGRAM_NAME $0
+alias $PROGRAM_NAME $program_name
+alias $0 $program_name
+
+trace_var(:$program_name){|val|
+ unless progname_obj.object_id == val.object_id
+ progname_obj.replace(val.to_s)
+ $program_name = progname_obj
+ end
+}
+
+
+##########################################################################
+# load script
+##########################################################################
+if (path = ARGV.shift) && (script = File.expand_path(path))
+ print "load script \"#{script}\"\n" if OPTS[:verbose]
+ $0 = script
+ load(script)
+else
+ print "Error: no script is given.\n"
+ print opt.help
+ exit(1)
+end
diff --git a/ext/tk/stubs.c b/ext/tk/stubs.c
index d0aaf61f31..6d3b330f0e 100644
--- a/ext/tk/stubs.c
+++ b/ext/tk/stubs.c
@@ -1,5 +1,11 @@
+/************************************************
+
+ stubs.c - Tcl/Tk stubs support
+
+************************************************/
+
+#include "ruby.h"
#include "stubs.h"
-#include "ruby/ruby.h"
#include <tcl.h>
#include <tk.h>
@@ -86,7 +92,12 @@ static DL_HANDLE tcl_dll = (DL_HANDLE)0;
static DL_HANDLE tk_dll = (DL_HANDLE)0;
int
+#ifdef RUBY_VM
ruby_open_tcl_dll(char *appname)
+#else
+ruby_open_tcl_dll(appname)
+ char *appname;
+#endif
{
void (*p_Tcl_FindExecutable)(const char *);
int n;
@@ -168,7 +179,12 @@ ruby_open_tk_dll()
}
int
+#ifdef RUBY_VM
ruby_open_tcltk_dll(char *appname)
+#else
+ruby_open_tcltk_dll(appname)
+ char *appname;
+#endif
{
return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() );
}
@@ -187,7 +203,12 @@ tk_stubs_init_p()
Tcl_Interp *
+#ifdef RUBY_VM
ruby_tcl_create_ip_and_stubs_init(int *st)
+#else
+ruby_tcl_create_ip_and_stubs_init(st)
+ int *st;
+#endif
{
Tcl_Interp *tcl_ip;
@@ -269,7 +290,12 @@ ruby_tcl_stubs_init()
}
int
+#ifdef RUBY_VM
ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_init(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
{
Tcl_ResetResult(tcl_ip);
@@ -304,7 +330,12 @@ ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
}
int
+#ifdef RUBY_VM
ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_safeinit(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
{
Tcl_ResetResult(tcl_ip);
@@ -390,7 +421,12 @@ static int open_tcl_dll = 0;
static int call_tk_stubs_init = 0;
int
+#ifdef RUBY_VM
ruby_open_tcl_dll(char *appname)
+#else
+ruby_open_tcl_dll(appname)
+ char *appname;
+#endif
{
if (appname) {
Tcl_FindExecutable(appname);
@@ -402,7 +438,8 @@ ruby_open_tcl_dll(char *appname)
return TCLTK_STUBS_OK;
}
-int ruby_open_tk_dll()
+int
+ruby_open_tk_dll()
{
if (!open_tcl_dll) {
/* ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
@@ -412,7 +449,13 @@ int ruby_open_tk_dll()
return TCLTK_STUBS_OK;
}
-int ruby_open_tcltk_dll(char *appname)
+int
+#ifdef RUBY_VM
+ruby_open_tcltk_dll(char *appname)
+#else
+ruby_open_tcltk_dll(appname)
+ char *appname;
+#endif
{
return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() );
}
@@ -430,7 +473,12 @@ tk_stubs_init_p()
}
Tcl_Interp *
+#ifdef RUBY_VM
ruby_tcl_create_ip_and_stubs_init(int *st)
+#else
+ruby_tcl_create_ip_and_stubs_init(st)
+ int *st;
+#endif
{
Tcl_Interp *tcl_ip;
@@ -458,7 +506,12 @@ ruby_tcl_stubs_init()
}
int
+#ifdef RUBY_VM
ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_init(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
{
if (Tk_Init(tcl_ip) == TCL_ERROR)
return FAIL_Tk_Init;
@@ -474,7 +527,12 @@ ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
}
int
+#ifdef RUBY_VM
ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_safeinit(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
{
#if TCL_MAJOR_VERSION >= 8
if (Tk_SafeInit(tcl_ip) == TCL_ERROR)
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index df70e67c9d..8701cfef27 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -4,10 +4,20 @@
* Oct. 24, 1997 Y. Matsumoto
*/
-#define TCLTKLIB_RELEASE_DATE "2007-12-21"
+#define TCLTKLIB_RELEASE_DATE "2008-05-23"
-#include "ruby/ruby.h"
+#include "ruby.h"
+
+#ifdef RUBY_VM
+/* #include "ruby/ruby.h" */
#include "ruby/signal.h"
+#include "ruby/encoding.h"
+#else
+/* #include "ruby.h" */
+#include "rubysig.h"
+#include "version.h"
+#endif
+
#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
#include <stdio.h>
#ifdef HAVE_STDARG_PROTOTYPES
@@ -29,6 +39,24 @@
#define TCL_FINAL_RELEASE 2
#endif
+static struct {
+ int major;
+ int minor;
+ int patchlevel;
+ int type;
+} tcltk_version = {0, 0, 0, 0};
+
+static void
+set_tcltk_version()
+{
+ if (tcltk_version.major) return;
+
+ Tcl_GetVersion(&(tcltk_version.major),
+ &(tcltk_version.minor),
+ &(tcltk_version.patchlevel),
+ &(tcltk_version.type));
+}
+
#if TCL_MAJOR_VERSION >= 8
# ifndef CONST84
# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4 /* Tcl8.0.x -- 8.4b1 */
@@ -82,6 +110,26 @@ static void ip_finalize _((Tcl_Interp*));
static int at_exit = 0;
+#ifdef RUBY_VM
+static VALUE cRubyEncoding;
+
+/* encoding */
+static int ENCODING_INDEX_UTF8;
+static int ENCODING_INDEX_BINARY;
+#endif
+static VALUE ENCODING_NAME_UTF8;
+static VALUE ENCODING_NAME_BINARY;
+
+static VALUE create_dummy_encoding_for_tk_core _((VALUE, VALUE, VALUE));
+static VALUE create_dummy_encoding_for_tk _((VALUE, VALUE));
+static int update_encoding_table _((VALUE, VALUE, VALUE));
+static VALUE encoding_table_get_name_core _((VALUE, VALUE, VALUE));
+static VALUE encoding_table_get_obj_core _((VALUE, VALUE, VALUE));
+static VALUE encoding_table_get_name _((VALUE, VALUE));
+static VALUE encoding_table_get_obj _((VALUE, VALUE));
+static VALUE create_encoding_table _((VALUE));
+static VALUE ip_get_encoding_table _((VALUE));
+
/* for callback break & continue */
static VALUE eTkCallbackReturn;
@@ -100,6 +148,9 @@ static VALUE tcltkip_class;
static ID ID_at_enc;
static ID ID_at_interp;
+static ID ID_encoding_name;
+static ID ID_encoding_table;
+
static ID ID_stop_p;
static ID ID_alive_p;
static ID ID_kill;
@@ -120,12 +171,37 @@ static ID ID_inspect;
static VALUE ip_invoke_real _((int, VALUE*, VALUE));
static VALUE ip_invoke _((int, VALUE*, VALUE));
-
+static VALUE ip_invoke_with_position _((int, VALUE*, VALUE, Tcl_QueuePosition));
static VALUE tk_funcall _((VALUE(), int, VALUE*, VALUE));
+/* Tcl's object type */
+#if TCL_MAJOR_VERSION >= 8
+static char *Tcl_ObjTypeName_ByteArray = "bytearray";
+static Tcl_ObjType *Tcl_ObjType_ByteArray;
+
+static char *Tcl_ObjTypeName_String = "string";
+static Tcl_ObjType *Tcl_ObjType_String;
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+#define IS_TCL_BYTEARRAY(obj) ((obj)->typePtr == Tcl_ObjType_ByteArray)
+#define IS_TCL_STRING(obj) ((obj)->typePtr == Tcl_ObjType_String)
+#define IS_TCL_VALID_STRING(obj) ((obj)->bytes != (char*)NULL)
+#endif
+#endif
+
+#ifndef HAVE_RB_HASH_LOOKUP
+#define rb_hash_lookup rb_hash_aref
+#endif
+
/* safe Tcl_Eval and Tcl_GlobalEval */
static int
+#ifdef RUBY_VM
tcl_eval(Tcl_Interp *interp, const char *cmd)
+#else
+tcl_eval(interp, cmd)
+ Tcl_Interp *interp;
+ const char *cmd; /* don't have to be writable */
+#endif
{
char *buf = strdup(cmd);
int ret;
@@ -140,7 +216,13 @@ tcl_eval(Tcl_Interp *interp, const char *cmd)
#define Tcl_Eval tcl_eval
static int
+#ifdef RUBY_VM
tcl_global_eval(Tcl_Interp *interp, const char *cmd)
+#else
+tcl_global_eval(interp, cmd)
+ Tcl_Interp *interp;
+ const char *cmd; /* don't have to be writable */
+#endif
{
char *buf = strdup(cmd);
int ret;
@@ -311,13 +393,29 @@ call_queue_mark(struct call_queue *q)
static VALUE eventloop_thread;
+#ifdef RUBY_VM
+Tcl_ThreadId tk_eventloop_thread_id; /* native thread ID of Tcl interpreter */
+#endif
static VALUE eventloop_stack;
-static int window_event_mode = ~(TCL_WINDOW_EVENTS | TCL_IDLE_EVENTS);
+static int window_event_mode = ( ~ TCL_IDLE_EVENTS | TCL_WINDOW_EVENTS );
static VALUE watchdog_thread;
Tcl_Interp *current_interp;
-
+
+/* thread control strategy */
+/* multi-tk works with the following settings only ???
+ : CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1
+ : USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0
+ : DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 0
+*/
+#define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1
+#define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0
+#define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 0
+
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+static int have_rb_thread_waiting_for_value = 0;
+#endif
/*
* 'event_loop_max' is a maximum events which the eventloop processes in one
@@ -326,12 +424,21 @@ Tcl_Interp *current_interp;
* 'timer_tick' is a limit of one term of thread scheduling.
* If 'timer_tick' == 0, then not use the timer for thread scheduling.
*/
-#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
-#define DEFAULT_NO_EVENT_TICK 10/*counts*/
-#define DEFAULT_NO_EVENT_WAIT 20/*milliseconds ( 1 -- 999 ) */
-#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
-#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
-#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
+#ifdef RUBY_VM
+#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
+#define DEFAULT_NO_EVENT_TICK 10/*counts*/
+#define DEFAULT_NO_EVENT_WAIT 10/*milliseconds ( 1 -- 999 ) */
+#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
+#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
+#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
+#else /* ! RUBY_VM */
+#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
+#define DEFAULT_NO_EVENT_TICK 10/*counts*/
+#define DEFAULT_NO_EVENT_WAIT 20/*milliseconds ( 1 -- 999 ) */
+#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
+#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
+#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
+#endif
static int event_loop_max = DEFAULT_EVENT_LOOP_MAX;
static int no_event_tick = DEFAULT_NO_EVENT_TICK;
@@ -567,7 +674,7 @@ struct tcltkip {
Tcl_Namespace *default_ns; /* default namespace */
#endif
#ifdef RUBY_VM
- Tcl_ThreadId tk_thread_id; /* default namespace */
+ Tcl_ThreadId tk_thread_id; /* native thread ID of Tcl interpreter */
#endif
int has_orig_exit; /* has original 'exit' command ? */
Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */
@@ -604,9 +711,9 @@ deleted_ip(ptr)
#endif
) {
DUMP1("ip is deleted");
- return Qtrue;
+ return 1;
}
- return Qfalse;
+ return 0;
}
/* increment/decrement reference count of tcltkip */
@@ -770,6 +877,7 @@ tcltkip_init_tk(interp)
/* treat excetiopn on Tcl side */
static VALUE rbtk_pending_exception;
static int rbtk_eventloop_depth = 0;
+static int rbtk_internal_eventloop_handler = 0;
static int
@@ -779,7 +887,9 @@ pending_exception_check0()
if (!NIL_P(exc) && rb_obj_is_kind_of(exc, rb_eException)) {
DUMP1("find a pending exception");
- if (rbtk_eventloop_depth > 0) {
+ if (rbtk_eventloop_depth > 0
+ || rbtk_internal_eventloop_handler > 0
+ ) {
return 1; /* pending */
} else {
rbtk_pending_exception = Qnil;
@@ -812,7 +922,9 @@ pending_exception_check1(thr_crit_bup, ptr)
if (!NIL_P(exc) && rb_obj_is_kind_of(exc, rb_eException)) {
DUMP1("find a pending exception");
- if (rbtk_eventloop_depth > 0) {
+ if (rbtk_eventloop_depth > 0
+ || rbtk_internal_eventloop_handler > 0
+ ) {
return 1; /* pending */
} else {
rbtk_pending_exception = Qnil;
@@ -851,8 +963,10 @@ call_original_exit(ptr, state)
int thr_crit_bup;
Tcl_CmdInfo *info;
#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj *cmd_obj;
Tcl_Obj *state_obj;
#endif
+ DUMP1("original_exit is called");
if (!(ptr->has_orig_exit)) return;
@@ -870,22 +984,55 @@ call_original_exit(ptr, state)
if (info->isNativeObjectProc) {
Tcl_Obj **argv;
- // argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3); /* XXXXXXXXXX */
+#define USE_RUBY_ALLOC 0
+#if USE_RUBY_ALLOC
+ argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
+#else /* not USE_RUBY_ALLOC */
argv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * 3);
- argv[0] = Tcl_NewStringObj("exit", 4);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+#endif
+ cmd_obj = Tcl_NewStringObj("exit", 4);
+ Tcl_IncrRefCount(cmd_obj);
+
+ argv[0] = cmd_obj;
argv[1] = state_obj;
argv[2] = (Tcl_Obj *)NULL;
ptr->return_value
= (*(info->objProc))(info->objClientData, ptr->ip, 2, argv);
+ Tcl_DecrRefCount(cmd_obj);
+
+#if USE_RUBY_ALLOC
free(argv);
+#else /* not USE_RUBY_ALLOC */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+#endif
+#undef USE_RUBY_ALLOC
} else {
/* string interface */
char **argv;
- //argv = (char **)ALLOC_N(char *, 3); /* XXXXXXXXXX */
- argv = (char **)ckalloc(sizeof(char *) * 3);
+#define USE_RUBY_ALLOC 0
+#if USE_RUBY_ALLOC
+ argv = (char **)ALLOC_N(char *, 3); /* XXXXXXXXXX */
+#else /* not USE_RUBY_ALLOC */
+ argv = (char **)ckalloc(sizeof(char *) * 3);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+#endif
argv[0] = "exit";
/* argv[1] = Tcl_GetString(state_obj); */
argv[1] = Tcl_GetStringFromObj(state_obj, (int*)NULL);
@@ -894,7 +1041,21 @@ call_original_exit(ptr, state)
ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
2, (CONST84 char **)argv);
+#if USE_RUBY_ALLOC
free(argv);
+#else /* not USE_RUBY_ALLOC */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+#endif
+#undef USE_RUBY_ALLOC
}
Tcl_DecrRefCount(state_obj);
@@ -903,7 +1064,15 @@ call_original_exit(ptr, state)
{
/* string interface */
char **argv;
+#define USE_RUBY_ALLOC 0
+#if USE_RUBY_ALLOC
argv = (char **)ALLOC_N(char *, 3);
+#else /* not USE_RUBY_ALLOC */
+ argv = (char **)ckalloc(sizeof(char *) * 3);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+#endif
argv[0] = "exit";
argv[1] = RSTRING_PTR(rb_fix2str(INT2NUM(state), 10));
argv[2] = (char *)NULL;
@@ -911,9 +1080,24 @@ call_original_exit(ptr, state)
ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
2, argv);
+#if USE_RUBY_ALLOC
free(argv);
+#else /* not USE_RUBY_ALLOC */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree(argv);
+#endif
+#endif
+#endif
+#undef USE_RUBY_ALLOC
}
#endif
+ DUMP1("complete original_exit");
rb_thread_critical = thr_crit_bup;
}
@@ -954,6 +1138,25 @@ _timer_for_tcl(clientData)
/* tick_counter += event_loop_max; */
}
+#ifdef RUBY_VM
+#if USE_TOGGLE_WINDOW_MODE_FOR_IDLE
+static int
+toggle_eventloop_window_mode_for_idle()
+{
+ if (window_event_mode & TCL_IDLE_EVENTS) {
+ /* idle -> event */
+ window_event_mode |= TCL_WINDOW_EVENTS;
+ window_event_mode &= ~TCL_IDLE_EVENTS;
+ return 1;
+ } else {
+ /* event -> idle */
+ window_event_mode |= TCL_IDLE_EVENTS;
+ window_event_mode &= ~TCL_WINDOW_EVENTS;
+ return 0;
+ }
+}
+#endif
+#endif
static VALUE
set_eventloop_window_mode(self, mode)
@@ -1262,8 +1465,10 @@ ip_evloop_abort_on_exc_set(self, val)
}
static VALUE
-lib_num_of_mainwindows(self)
+lib_num_of_mainwindows_core(self, argc, argv)
VALUE self;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
{
if (tk_stubs_init_p()) {
return INT2FIX(Tk_GetNumMainWindows());
@@ -1272,7 +1477,41 @@ lib_num_of_mainwindows(self)
}
}
+static VALUE
+lib_num_of_mainwindows(self)
+ VALUE self;
+{
+#ifdef RUBY_VM /* Ruby 1.9+ !!! */
+ return tk_funcall(lib_num_of_mainwindows_core, 0, (VALUE*)NULL, self);
+#else
+ return lib_num_of_mainwindows_core(self, 0, (VALUE*)NULL);
+#endif
+}
+
+
+#ifdef RUBY_VM /* Ruby 1.9+ !!! */
+static VALUE
+call_DoOneEvent_core(flag_val)
+ VALUE flag_val;
+{
+ int flag;
+
+ flag = FIX2INT(flag_val);
+ if (Tcl_DoOneEvent(flag)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+static VALUE
+call_DoOneEvent(flag_val)
+ VALUE flag_val;
+{
+ return tk_funcall(call_DoOneEvent_core, 0, (VALUE*)NULL, flag_val);
+}
+#else /* Ruby 1.8- */
static VALUE
call_DoOneEvent(flag_val)
VALUE flag_val;
@@ -1286,6 +1525,8 @@ call_DoOneEvent(flag_val)
return Qfalse;
}
}
+#endif
+
static VALUE
eventloop_sleep(dummy)
@@ -1296,29 +1537,78 @@ eventloop_sleep(dummy)
t.tv_sec = (time_t)0;
t.tv_usec = (time_t)(no_event_wait*1000.0);
-#if 0
#ifdef HAVE_NATIVETHREAD
+#ifdef RUBY_VM
+#if 0
if (!ruby_native_thread_p()) {
rb_bug("cross-thread violation on eventloop_sleep()");
}
#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on eventloop_sleep()");
+ }
+#endif
#endif
DUMP2("eventloop_sleep: rb_thread_wait_for() at thread : %lx", rb_thread_current());
rb_thread_wait_for(t);
DUMP2("eventloop_sleep: finish at thread : %lx", rb_thread_current());
-#if 0
#ifdef HAVE_NATIVETHREAD
+#ifdef RUBY_VM
+#if 0
if (!ruby_native_thread_p()) {
rb_bug("cross-thread violation on eventloop_sleep()");
}
#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on eventloop_sleep()");
+ }
+#endif
#endif
return Qnil;
}
+#define USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 0
+
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+static int
+get_thread_alone_check_flag()
+{
+#ifdef RUBY_VM
+ return 0;
+#else
+ set_tcltk_version();
+
+ if (tcltk_version.major < 8) {
+ /* Tcl/Tk 7.x */
+ return 1;
+ } else if (tcltk_version.major == 8) {
+ if (tcltk_version.minor < 5) {
+ /* Tcl/Tk 8.0 - 8.4 */
+ return 1;
+ } else if (tcltk_version.minor == 5) {
+ if (tcltk_version.type < TCL_FINAL_RELEASE) {
+ /* Tcl/Tk 8.5a? - 8.5b? */
+ return 1;
+ } else {
+ /* Tcl/Tk 8.5.x */
+ return 0;
+ }
+ } else {
+ /* Tcl/Tk 8.6 - 8.9 ?? */
+ return 0;
+ }
+ } else {
+ /* Tcl/Tk 9+ ?? */
+ return 0;
+ }
+#endif
+}
+#endif
static int
lib_eventloop_core(check_root, update_flag, check_var, interp)
@@ -1334,7 +1624,9 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
int thr_crit_bup;
int status;
int depth = rbtk_eventloop_depth;
-
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+ int thread_alone_check_flag = 1;
+#endif
if (update_flag) DUMP1("update loop start!!");
@@ -1353,9 +1645,14 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
timer_token = (Tcl_TimerToken)NULL;
}
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+ /* version check */
+ thread_alone_check_flag = get_thread_alone_check_flag();
+#endif
+
for(;;) {
-#ifdef RUBY_VM
- if (0) {
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+ if (thread_alone_check_flag && rb_thread_alone()) {
#else
if (rb_thread_alone()) {
#endif
@@ -1365,8 +1662,8 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
if (update_flag) {
event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
} else {
- // event_flag = TCL_ALL_EVENTS;
- event_flag = TCL_FILE_EVENTS | TCL_TIMER_EVENTS | TCL_DONT_WAIT;
+ event_flag = TCL_ALL_EVENTS;
+ /* event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT; */
}
if (timer_tick == 0 && update_flag == 0) {
@@ -1393,11 +1690,19 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
if (status) {
switch (status) {
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception
= rb_exc_new2(rb_eException, "unknown exception");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
if (!NIL_P(rbtk_pending_exception)) {
if (rbtk_eventloop_depth == 0) {
@@ -1412,10 +1717,18 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
break;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL"));
} else {
+#ifdef RUBY_VM
rb_exc_raise(rb_errinfo());
+#else
+ rb_exc_raise(ruby_errinfo);
+#endif
}
}
}
@@ -1514,21 +1827,48 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
st = RTEST(rb_protect(call_DoOneEvent,
INT2FIX(event_flag & window_event_mode),
&status));
+#if USE_TOGGLE_WINDOW_MODE_FOR_IDLE
+ if (!st) {
+ if (toggle_eventloop_window_mode_for_idle()) {
+ /* idle-mode -> event-mode*/
+ tick_counter = event_loop_max;
+ } else {
+ /* event-mode -> idle-mode */
+ tick_counter = 0;
+ }
+ }
+#endif
}
#else
/* st = Tcl_DoOneEvent(event_flag); */
st = RTEST(rb_protect(call_DoOneEvent,
INT2FIX(event_flag), &status));
#endif
+
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ if (have_rb_thread_waiting_for_value) {
+ have_rb_thread_waiting_for_value = 0;
+ rb_thread_schedule();
+ }
+#endif
+
if (status) {
switch (status) {
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception
= rb_exc_new2(rb_eException,
"unknown exception");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
if (!NIL_P(rbtk_pending_exception)) {
if (rbtk_eventloop_depth == 0) {
@@ -1543,10 +1883,18 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
break;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL"));
} else {
+#ifdef RUBY_VM
rb_exc_raise(rb_errinfo());
+#else
+ rb_exc_raise(ruby_errinfo);
+#endif
}
}
}
@@ -1590,19 +1938,26 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
tick_counter += no_event_tick;
/* rb_thread_wait_for(t); */
-#if 0
+
rb_protect(eventloop_sleep, Qnil, &status);
-#endif
if (status) {
switch (status) {
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception
= rb_exc_new2(rb_eException,
"unknown exception");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
if (!NIL_P(rbtk_pending_exception)) {
if (rbtk_eventloop_depth == 0) {
@@ -1617,11 +1972,19 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
break;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rb_exc_raise(rb_exc_new2(rb_eFatal,
"FATAL"));
} else {
+#ifdef RUBY_VM
rb_exc_raise(rb_errinfo());
+#else
+ rb_exc_raise(ruby_errinfo);
+#endif
}
}
}
@@ -1630,7 +1993,8 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
} else {
DUMP2("sleep eventloop %lx", current);
DUMP2("eventloop thread is %lx", eventloop_thread);
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
if (!NIL_P(watchdog_thread) && eventloop_thread != current) {
@@ -1676,12 +2040,16 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
}
}
- DUMP1("thread scheduling");
- rb_thread_schedule();
+ DUMP1("thread scheduling");
+ rb_thread_schedule();
}
DUMP1("trap check & thread scheduling");
- if (update_flag == 0) ; // TODO: CHECK_INTS
+#ifdef RUBY_VM
+ /* if (update_flag == 0) CHECK_INTS; */ /*XXXXXXXXXXXXX TODO !!!! */
+#else
+ if (update_flag == 0) CHECK_INTS;
+#endif
}
return 1;
@@ -1728,19 +2096,35 @@ lib_eventloop_main(args)
switch (status) {
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception
= rb_exc_new2(rb_eException, "unknown exception");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
}
return Qnil;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
}
return Qnil;
}
@@ -1764,6 +2148,7 @@ lib_eventloop_ensure(args)
rb_thread_critical = ptr->thr_crit_bup;
free(ptr);
+ /* ckfree((char*)ptr); */
return Qnil;
}
@@ -1785,7 +2170,8 @@ lib_eventloop_ensure(args)
break;
}
- if (RTEST(rb_funcall(eventloop_thread, ID_alive_p, 0, 0))) {
+ /* if (RTEST(rb_funcall(eventloop_thread, ID_alive_p, 0, 0))) { */
+ if (RTEST(rb_thread_alive_p(eventloop_thread))) {
DUMP2("eventloop-enshure: wake up parent %lx", eventloop_thread);
rb_thread_wakeup(eventloop_thread);
@@ -1793,9 +2179,16 @@ lib_eventloop_ensure(args)
}
}
+#ifdef RUBY_VM
+ if (NIL_P(eventloop_thread)) {
+ tk_eventloop_thread_id = (Tcl_ThreadId) 0;
+ }
+#endif
+
rb_thread_critical = ptr->thr_crit_bup;
free(ptr);
+ /* ckfree((char*)ptr);*/
DUMP2("finish current eventloop %lx", current_evloop);
return Qnil;
@@ -1810,10 +2203,14 @@ lib_eventloop_launcher(check_root, update_flag, check_var, interp)
{
volatile VALUE parent_evloop = eventloop_thread;
struct evloop_params *args = ALLOC(struct evloop_params);
+ /* struct evloop_params *args = (struct evloop_params *)ckalloc(sizeof(struct evloop_params)); */
tcl_stubs_check();
eventloop_thread = rb_thread_current();
+#ifdef RUBY_VM
+ tk_eventloop_thread_id = Tcl_GetCurrentThread();
+#endif
if (parent_evloop == eventloop_thread) {
DUMP2("eventloop: recursive call on %lx", parent_evloop);
@@ -1964,6 +2361,9 @@ lib_watchdog_ensure(arg)
VALUE arg;
{
eventloop_thread = Qnil; /* stop eventloops */
+#ifdef RUBY_VM
+ tk_eventloop_thread_id = (Tcl_ThreadId) 0;
+#endif
return Qnil;
}
@@ -1975,6 +2375,11 @@ lib_mainloop_watchdog(argc, argv, self)
{
VALUE check_rootwidget;
+#ifdef RUBY_VM
+ rb_raise(rb_eNotImpError,
+ "eventloop_watchdog is not implemented on Ruby VM.");
+#endif
+
if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
check_rootwidget = Qtrue;
} else if (RTEST(check_rootwidget)) {
@@ -2068,11 +2473,11 @@ lib_thread_callback(argc, argv, self)
proc = rb_block_proc();
}
- //q = (struct thread_call_proc_arg *)ALLOC(struct thread_call_proc_arg);
- q = (struct thread_call_proc_arg *)ckalloc(sizeof(struct thread_call_proc_arg));
+ q = (struct thread_call_proc_arg *)ALLOC(struct thread_call_proc_arg);
+ /* q = (struct thread_call_proc_arg *)ckalloc(sizeof(struct thread_call_proc_arg)); */
q->proc = proc;
- //q->done = (int*)ALLOC(int);
- q->done = (int*)ckalloc(sizeof(int));
+ q->done = (int*)ALLOC(int);
+ /* q->done = (int*)ckalloc(sizeof(int)); */
*(q->done) = 0;
/* create call-proc thread */
@@ -2084,23 +2489,31 @@ lib_thread_callback(argc, argv, self)
foundEvent = RTEST(lib_eventloop_launcher(/* not check root-widget */0, 0,
q->done, (Tcl_Interp*)NULL));
- if (RTEST(rb_funcall(th, ID_alive_p, 0))) {
+ /* if (RTEST(rb_funcall(th, ID_alive_p, 0))) { */
+ if (RTEST(rb_thread_alive_p(th))) {
rb_funcall(th, ID_kill, 0);
ret = Qnil;
} else {
ret = rb_protect(_thread_call_proc_value, th, &status);
}
- //free(q->done);
- //free(q);
- ckfree((char*)q->done);
- ckfree((char*)q);
+ free(q->done);
+ free(q);
+ /* ckfree((char*)q->done); */
+ /* ckfree((char*)q); */
if (NIL_P(rbtk_pending_exception)) {
+#ifdef RUBY_VM
/* return rb_errinfo(); */
if (status) {
rb_exc_raise(rb_errinfo());
}
+#else
+ /* return ruby_errinfo; */
+ if (status) {
+ rb_exc_raise(ruby_errinfo);
+ }
+#endif
} else {
VALUE exc = rbtk_pending_exception;
rbtk_pending_exception = Qnil;
@@ -2218,15 +2631,20 @@ ip_set_exc_message(interp, exc)
if (NIL_P(enc)) {
encoding = (Tcl_Encoding)NULL;
} else if (TYPE(enc) == T_STRING) {
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(enc));
} else {
enc = rb_funcall(enc, ID_to_s, 0, 0);
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(enc));
}
/* to avoid a garbled error message dialog */
- // buf = ALLOC_N(char, (RSTRING_LEN(msg))+1);
- buf = ckalloc(sizeof(char)*((RSTRING_LEN(msg))+1));
+ /* buf = ALLOC_N(char, (RSTRING(msg)->len)+1);*/
+ /* memcpy(buf, RSTRING(msg)->ptr, RSTRING(msg)->len);*/
+ /* buf[RSTRING(msg)->len] = 0; */
+ buf = ALLOC_N(char, RSTRING_LEN(msg)+1);
+ /* buf = ckalloc(sizeof(char)*((RSTRING_LEN(msg))+1)); */
memcpy(buf, RSTRING_PTR(msg), RSTRING_LEN(msg));
buf[RSTRING_LEN(msg)] = 0;
@@ -2237,8 +2655,8 @@ ip_set_exc_message(interp, exc)
Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (char*)NULL);
DUMP2("error message:%s", Tcl_DStringValue(&dstr));
Tcl_DStringFree(&dstr);
- //free(buf);
- ckfree(buf);
+ free(buf);
+ /* ckfree(buf); */
#else /* TCL_VERSION <= 8.0 */
Tcl_AppendResult(interp, RSTRING_PTR(msg), (char*)NULL);
@@ -2286,12 +2704,15 @@ tcl_protect_core(interp, proc, data) /* should not raise exception */
int status = 0;
int thr_crit_bup = rb_thread_critical;
+ Tcl_ResetResult(interp);
+
rb_thread_critical = Qfalse;
ret = rb_protect(proc, data, &status);
rb_thread_critical = Qtrue;
if (status) {
char *buf;
- VALUE old_gc, type, str;
+ VALUE old_gc;
+ volatile VALUE type, str;
old_gc = rb_gc_disable();
@@ -2307,58 +2728,104 @@ tcl_protect_core(interp, proc, data) /* should not raise exception */
goto error;
error:
str = rb_str_new2("LocalJumpError: ");
+#ifdef RUBY_VM
rb_str_append(str, rb_obj_as_string(rb_errinfo()));
+#else
+ rb_str_append(str, rb_obj_as_string(ruby_errinfo));
+#endif
exc = rb_exc_new3(type, str);
break;
case TAG_RETRY:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
DUMP1("rb_protect: retry");
exc = rb_exc_new2(eTkCallbackRetry, "retry jump error");
} else {
+#ifdef RUBY_VM
exc = rb_errinfo();
+#else
+ exc = ruby_errinfo;
+#endif
}
break;
case TAG_REDO:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
DUMP1("rb_protect: redo");
exc = rb_exc_new2(eTkCallbackRedo, "redo jump error");
} else {
+#ifdef RUBY_VM
exc = rb_errinfo();
+#else
+ exc = ruby_errinfo;
+#endif
}
break;
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
exc = rb_exc_new2(rb_eException, "unknown exception");
} else {
+#ifdef RUBY_VM
exc = rb_errinfo();
+#else
+ exc = ruby_errinfo;
+#endif
}
break;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
exc = rb_exc_new2(rb_eFatal, "FATAL");
} else {
+#ifdef RUBY_VM
exc = rb_errinfo();
+#else
+ exc = ruby_errinfo;
+#endif
}
break;
case TAG_THROW:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
DUMP1("rb_protect: throw");
exc = rb_exc_new2(eTkCallbackThrow, "throw jump error");
} else {
+#ifdef RUBY_VM
exc = rb_errinfo();
+#else
+ exc = ruby_errinfo;
+#endif
}
break;
default:
buf = ALLOC_N(char, 256);
+ /* buf = ckalloc(sizeof(char) * 256); */
sprintf(buf, "unknown loncaljmp status %d", status);
exc = rb_exc_new2(rb_eException, buf);
free(buf);
+ /* ckfree(buf); */
break;
}
@@ -2455,12 +2922,18 @@ tcl_protect(interp, proc, data)
int old_trapflag = rb_trap_immediate;
int code;
-#if 0
#ifdef HAVE_NATIVETHREAD
+#ifdef RUBY_VM
+#if 0
if (!ruby_native_thread_p()) {
rb_bug("cross-thread violation on tcl_protect()");
}
#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on tcl_protect()");
+ }
+#endif
#endif
rb_trap_immediate = 0;
@@ -2523,6 +2996,7 @@ ip_ruby_eval(clientData, interp, argc, argv)
str = Tcl_GetStringFromObj(argv[1], &len);
arg = ALLOC_N(char, len + 1);
+ /* arg = ckalloc(sizeof(char) * (len + 1)); */
memcpy(arg, str, len);
arg[len] = 0;
@@ -2540,6 +3014,7 @@ ip_ruby_eval(clientData, interp, argc, argv)
#if TCL_MAJOR_VERSION >= 8
free(arg);
+ /* ckfree(arg); */
#endif
return code;
@@ -2564,6 +3039,96 @@ ip_ruby_cmd_core(arg)
return ret;
}
+#define SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 1
+
+static VALUE
+ip_ruby_cmd_receiver_const_get(name)
+ char *name;
+{
+ volatile VALUE klass = rb_cObject;
+ char *head, *tail;
+ int state;
+
+#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
+ klass = rb_eval_string_protect(name, &state);
+ if (state) {
+ return Qnil;
+ } else {
+ return klass;
+ }
+#else
+ return rb_const_get(klass, rb_intern(name));
+#endif
+
+ /* TODO!!!!!! */
+ /* support nest of classes/modules */
+
+ /* return rb_eval_string(name); */
+ /* return rb_eval_string_protect(name, &state); */
+
+#if 0 /* doesn't work!! (fail to autoload?) */
+ /* duplicate */
+ head = name = strdup(name);
+
+ /* has '::' at head ? */
+ if (*head == ':') head += 2;
+ tail = head;
+
+ /* search */
+ while(*tail) {
+ if (*tail == ':') {
+ *tail = '\0';
+ klass = rb_const_get(klass, rb_intern(head));
+ tail += 2;
+ head = tail;
+ } else {
+ tail++;
+ }
+ }
+
+ free(name);
+ return rb_const_get(klass, rb_intern(head));
+#endif
+}
+
+static VALUE
+ip_ruby_cmd_receiver_get(str)
+ char *str;
+{
+ volatile VALUE receiver;
+ volatile VALUE klass = rb_cObject;
+ int state;
+
+ if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
+ /* class | module | constant */
+#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
+ receiver = ip_ruby_cmd_receiver_const_get(str);
+#else
+ receiver = rb_protect(ip_ruby_cmd_receiver_const_get, (VALUE)str, &state);
+ if (state) return Qnil;
+#endif
+ } else if (str[0] == '$') {
+ /* global variable */
+ receiver = rb_gv_get(str);
+ } else {
+ /* global variable omitted '$' */
+ char *buf;
+ int len;
+
+ len = strlen(str);
+ buf = ALLOC_N(char, len + 2);
+ /* buf = ckalloc(sizeof(char) * (len + 2)); */
+ buf[0] = '$';
+ memcpy(buf + 1, str, len);
+ buf[len + 1] = 0;
+ receiver = rb_gv_get(buf);
+ free(buf);
+ /* ckfree(buf); */
+ }
+
+ return receiver;
+}
+
/* ruby_cmd receiver method arg ... */
static int
#if TCL_MAJOR_VERSION >= 8
@@ -2609,9 +3174,6 @@ ip_ruby_cmd(clientData, interp, argc, argv)
#endif
}
- /* allocate */
- arg = ALLOC(struct cmd_body_arg);
-
/* get arguments from Tcl objects */
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
@@ -2624,24 +3186,8 @@ ip_ruby_cmd(clientData, interp, argc, argv)
str = argv[1];
#endif
DUMP2("receiver:%s",str);
- if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
- /* class | module | constant */
- receiver = rb_const_get(rb_cObject, rb_intern(str));
- } else if (str[0] == '$') {
- /* global variable */
- receiver = rb_gv_get(str);
- } else {
- /* global variable omitted '$' */
- char *buf;
-
- len = strlen(str);
- buf = ALLOC_N(char, len + 2);
- buf[0] = '$';
- memcpy(buf + 1, str, len);
- buf[len + 1] = 0;
- receiver = rb_gv_get(buf);
- free(buf);
- }
+ /* receiver = rb_protect(ip_ruby_cmd_receiver_get, (VALUE)str, &code); */
+ receiver = ip_ruby_cmd_receiver_get(str);
if (NIL_P(receiver)) {
#if 0
rb_raise(rb_eArgError,
@@ -2652,6 +3198,7 @@ ip_ruby_cmd(clientData, interp, argc, argv)
str, "'", (char *)NULL);
rbtk_pending_exception = rb_exc_new2(rb_eArgError,
Tcl_GetStringResult(interp));
+ if (old_gc == Qfalse) rb_gc_enable();
return TCL_ERROR;
#endif
}
@@ -2666,20 +3213,36 @@ ip_ruby_cmd(clientData, interp, argc, argv)
/* get args */
args = rb_ary_new2(argc - 2);
+#ifdef RUBY_VM
+#else
+ RARRAY(args)->len = 0;
+#endif
for(i = 3; i < argc; i++) {
#if TCL_MAJOR_VERSION >= 8
str = Tcl_GetStringFromObj(argv[i], &len);
DUMP2("arg:%s",str);
+#ifdef RUBY_VM
rb_ary_push(args, rb_tainted_str_new(str, len));
+#else
+ RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len);
+#endif
#else /* TCL_MAJOR_VERSION < 8 */
DUMP2("arg:%s",argv[i]);
+#ifdef RUBY_VM
rb_ary_push(args, rb_tainted_str_new2(argv[i]));
+#else
+ RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]);
+#endif
#endif
}
if (old_gc == Qfalse) rb_gc_enable();
rb_thread_critical = thr_crit_bup;
+ /* allocate */
+ arg = ALLOC(struct cmd_body_arg);
+ /* arg = (struct cmd_body_arg *)ckalloc(sizeof(struct cmd_body_arg)); */
+
arg->receiver = receiver;
arg->method = method;
arg->args = args;
@@ -2688,6 +3251,7 @@ ip_ruby_cmd(clientData, interp, argc, argv)
code = tcl_protect(interp, ip_ruby_cmd_core, (VALUE)arg);
free(arg);
+ /* ckfree((char*)arg); */
return code;
}
@@ -2864,14 +3428,22 @@ ip_rbUpdateCommand(clientData, interp, objc, objv)
"IP is deleted");
return TCL_ERROR;
}
-#if 0
#ifdef HAVE_NATIVETHREAD
+#ifdef RUBY_VM
+#if 0
if (!ruby_native_thread_p()) {
rb_bug("cross-thread violation on ip_ruby_eval()");
}
#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on ip_ruby_eval()");
+ }
+#endif
#endif
+ Tcl_ResetResult(interp);
+
if (objc == 1) {
flags = TCL_DONT_WAIT;
@@ -3013,10 +3585,16 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
"IP is deleted");
return TCL_ERROR;
}
-#if 0
#ifdef HAVE_NATIVETHREAD
+#ifdef RUBY_VM
+#if 0
if (!ruby_native_thread_p()) {
- rb_bug("cross-thread violation on ip_ruby_eval()");
+ rb_bug("cross-thread violation on ip_rb_threadUpdateCommand()");
+ }
+#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on ip_rb_threadUpdateCommand()");
}
#endif
#endif
@@ -3034,6 +3612,8 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
DUMP1("start Ruby's 'thread_update' body");
+ Tcl_ResetResult(interp);
+
if (objc == 1) {
flags = TCL_DONT_WAIT;
@@ -3080,8 +3660,11 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
DUMP1("pass argument check");
- param = (struct th_update_param *)Tcl_Alloc(sizeof(struct th_update_param));
- Tcl_Preserve(param);
+ /* param = (struct th_update_param *)Tcl_Alloc(sizeof(struct th_update_param)); */
+ param = (struct th_update_param *)ckalloc(sizeof(struct th_update_param));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)param);
+#endif
param->thread = current_thread;
param->done = 0;
@@ -3090,11 +3673,20 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
while(!param->done) {
DUMP1("wait for complete idle proc");
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
- Tcl_Release(param);
- Tcl_Free((char *)param);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
DUMP1("finish Ruby's 'thread_update'");
return TCL_OK;
@@ -3192,14 +3784,22 @@ ip_rbVwaitCommand(clientData, interp, objc, objv)
#endif
Tcl_Preserve(interp);
-#if 0
#ifdef HAVE_NATIVETHREAD
+#ifdef RUBY_VM
+#if 0
if (!ruby_native_thread_p()) {
- rb_bug("cross-thread violation on ip_ruby_eval()");
+ rb_bug("cross-thread violation on ip_rbVwaitCommand()");
+ }
+#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on ip_rbVwaitCommand()");
}
#endif
#endif
+ Tcl_ResetResult(interp);
+
if (objc != 2) {
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "name");
@@ -3435,6 +4035,7 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
#endif
Tcl_Preserve(interp);
+ Tcl_ResetResult(interp);
if (objc != 3) {
#ifdef Tcl_WrongNumArgs
@@ -3588,6 +4189,7 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
+ /* This function works on the Tk eventloop thread only. */
if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
window = NULL;
} else {
@@ -3595,7 +4197,7 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
}
if (window == NULL) {
- Tcl_AppendResult(interp, "tkwait: ",
+ Tcl_AppendResult(interp, ": tkwait: ",
"no main-window (not Tk application?)",
(char*)NULL);
rb_thread_critical = thr_crit_bup;
@@ -3684,7 +4286,8 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
case TKWAIT_WINDOW:
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
-
+
+ /* This function works on the Tk eventloop thread only. */
if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
window = NULL;
} else {
@@ -3696,7 +4299,7 @@ ip_rbTkWaitCommand(clientData, interp, objc, objv)
#endif
if (window == NULL) {
- Tcl_AppendResult(interp, "tkwait: ",
+ Tcl_AppendResult(interp, ": tkwait: ",
"no main-window (not Tk application?)",
(char*)NULL);
rb_thread_critical = thr_crit_bup;
@@ -3789,7 +4392,7 @@ rb_threadVwaitProc(clientData, interp, name1, name2, flags)
} else {
param->done = 1;
}
- rb_thread_wakeup(param->thread);
+ if (param->done != 0) rb_thread_wakeup(param->thread);
return (char *)NULL;
}
@@ -3811,7 +4414,7 @@ rb_threadWaitVisibilityProc(clientData, eventPtr)
if (eventPtr->type == DestroyNotify) {
param->done = TKWAIT_MODE_DESTROY;
}
- rb_thread_wakeup(param->thread);
+ if (param->done != 0) rb_thread_wakeup(param->thread);
}
static void rb_threadWaitWindowProc _((ClientData, XEvent *));
@@ -3825,7 +4428,7 @@ rb_threadWaitWindowProc(clientData, eventPtr)
if (eventPtr->type == DestroyNotify) {
param->done = TKWAIT_MODE_DESTROY;
}
- rb_thread_wakeup(param->thread);
+ if (param->done != 0) rb_thread_wakeup(param->thread);
}
#if TCL_MAJOR_VERSION >= 8
@@ -3868,6 +4471,7 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
}
Tcl_Preserve(interp);
+ Tcl_ResetResult(interp);
if (objc != 2) {
#ifdef Tcl_WrongNumArgs
@@ -3902,8 +4506,11 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
- param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param));
- Tcl_Preserve(param);
+ /* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
+ param = (struct th_vwait_param *)ckalloc(sizeof(struct th_vwait_param));
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)param);
+#endif
param->thread = current_thread;
param->done = 0;
@@ -3921,8 +4528,16 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
rb_thread_critical = thr_crit_bup;
if (ret != TCL_OK) {
- Tcl_Release(param);
- Tcl_Free((char *)param);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(objv[1]);
@@ -3931,9 +4546,9 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
return TCL_ERROR;
}
- /* if (!param->done) { */
while(!param->done) {
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
thr_crit_bup = rb_thread_critical;
@@ -3945,8 +4560,16 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
rb_threadVwaitProc, (ClientData) param);
}
- Tcl_Release(param);
- Tcl_Free((char *)param);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
rb_thread_critical = thr_crit_bup;
@@ -4005,6 +4628,8 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
Tcl_Preserve(interp);
Tcl_Preserve(tkwin);
+ Tcl_ResetResult(interp);
+
if (objc != 3) {
#ifdef Tcl_WrongNumArgs
Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
@@ -4087,8 +4712,11 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
nameString = objv[2];
#endif
- param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param));
- Tcl_Preserve(param);
+ /* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
+ param = (struct th_vwait_param *)ckalloc(sizeof(struct th_vwait_param));
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)param);
+#endif
param->thread = current_thread;
param->done = 0;
@@ -4112,8 +4740,16 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
rb_thread_critical = thr_crit_bup;
if (ret != TCL_OK) {
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
Tcl_Release(param);
- Tcl_Free((char *)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(objv[2]);
@@ -4124,9 +4760,9 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
return TCL_ERROR;
}
- /* if (!param->done) { */
while(!param->done) {
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
thr_crit_bup = rb_thread_critical;
@@ -4150,21 +4786,43 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
+#if 0 /* variable 'tkwin' must keep the token of MainWindow */
if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
window = NULL;
} else {
window = Tk_NameToWindow(interp, nameString, tkwin);
}
+#else
+ if (!tk_stubs_init_p() || tkwin == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ /* Tk_NameToWindow() returns right token on non-eventloop thread */
+ Tcl_CmdInfo info;
+ if (Tcl_GetCommandInfo(interp, ".", &info)) { /* check root */
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ } else {
+ window = NULL;
+ }
+ }
+#endif
if (window == NULL) {
- Tcl_AppendResult(interp, "thread_tkwait: ",
+ Tcl_AppendResult(interp, ": thread_tkwait: ",
"no main-window (not Tk application?)",
(char*)NULL);
rb_thread_critical = thr_crit_bup;
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
Tcl_Release(param);
- Tcl_Free((char *)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(objv[2]);
@@ -4181,15 +4839,10 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
rb_thread_critical = thr_crit_bup;
- /* if (!param->done) { */
- /*
- while(!param->done) {
- rb_thread_stop();
- }
- */
while(param->done != TKWAIT_MODE_VISIBILITY) {
if (param->done == TKWAIT_MODE_DESTROY) break;
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
thr_crit_bup = rb_thread_critical;
@@ -4213,8 +4866,16 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
Tcl_Release(window);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
Tcl_Release(param);
- Tcl_Free((char *)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(objv[2]);
@@ -4239,25 +4900,47 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
+#if 0 /* variable 'tkwin' must keep the token of MainWindow */
if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
window = NULL;
} else {
window = Tk_NameToWindow(interp, nameString, tkwin);
}
+#else
+ if (!tk_stubs_init_p() || tkwin == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ /* Tk_NameToWindow() returns right token on non-eventloop thread */
+ Tcl_CmdInfo info;
+ if (Tcl_GetCommandInfo(interp, ".", &info)) { /* check root */
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ } else {
+ window = NULL;
+ }
+ }
+#endif
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(objv[2]);
#endif
if (window == NULL) {
- Tcl_AppendResult(interp, "thread_tkwait: ",
+ Tcl_AppendResult(interp, ": thread_tkwait: ",
"no main-window (not Tk application?)",
(char*)NULL);
rb_thread_critical = thr_crit_bup;
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
Tcl_Release(param);
- Tcl_Free((char *)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
Tcl_Release(tkwin);
Tcl_Release(interp);
@@ -4271,14 +4954,9 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
rb_thread_critical = thr_crit_bup;
- /* if (!param->done) { */
- /*
- while(!param->done) {
- rb_thread_stop();
- }
- */
while(param->done != TKWAIT_MODE_DESTROY) {
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
Tcl_Release(window);
@@ -4296,8 +4974,16 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
break;
} /* end of 'switch' statement */
- Tcl_Release(param);
- Tcl_Free((char *)param);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
/*
* Clear out the interpreter's result, since it may have been set
@@ -4322,7 +5008,7 @@ ip_thread_vwait(self, var)
argv[0] = cmd_str;
argv[1] = var;
- return ip_invoke_real(2, argv, self);
+ return ip_invoke_with_position(2, argv, self, TCL_QUEUE_TAIL);
}
static VALUE
@@ -4338,7 +5024,7 @@ ip_thread_tkwait(self, mode, target)
argv[1] = mode;
argv[2] = target;
- return ip_invoke_real(3, argv, self);
+ return ip_invoke_with_position(3, argv, self, TCL_QUEUE_TAIL);
}
@@ -4528,23 +5214,43 @@ ip_finalize(ip)
Tcl_CreateCommand(ip, "ruby_cmd", ip_null_proc,
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
#endif
+ /*
+ rb_thread_critical = thr_crit_bup;
+ return;
+ */
}
/* delete root widget */
-#if 0
+#if 1
DUMP1("check `destroy'");
if (Tcl_GetCommandInfo(ip, "destroy", &info)) {
- DUMP1("call `destroy'");
- Tcl_GlobalEval(ip, "destroy .");
+ DUMP1("call `destroy .'");
+ Tcl_GlobalEval(ip, "catch {destroy .}");
}
#endif
#if 1
DUMP1("destroy root widget");
if (tk_stubs_init_p() && Tk_MainWindow(ip) != (Tk_Window)NULL) {
+ /*
+ * On Ruby VM, this code piece may be not called, because
+ * Tk_MainWindow() returns NULL on a native thread except
+ * the thread which initialize Tk environment.
+ * Of course, that is a problem. But maybe not so serious.
+ * All widgets are destroyed when the Tcl interp is deleted.
+ * At then, Ruby may raise exceptions on the delete hook
+ * callbacks which registered for the deleted widgets, and
+ * may fail to clear objects which depends on the widgets.
+ * Although it is the problem, it is possibly avoidable by
+ * rescuing exceptions and the finalize hook of the interp.
+ */
+ Tk_Window win = Tk_MainWindow(ip);
+
DUMP1("call Tk_DestroyWindow");
ruby_debug = Qfalse;
ruby_verbose = Qnil;
- Tk_DestroyWindow(Tk_MainWindow(ip));
+ if (! (((Tk_FakeWin*)win)->flags & TK_ALREADY_DEAD)) {
+ Tk_DestroyWindow(win);
+ }
ruby_debug = rb_debug_bup;
ruby_verbose = rb_verbose_bup;
}
@@ -4567,7 +5273,7 @@ ip_finalize(ip)
DUMP1("cancel after callbacks");
ruby_debug = Qfalse;
ruby_verbose = Qnil;
- Tcl_GlobalEval(ip, "foreach id [after info] {after cancel $id}");
+ Tcl_GlobalEval(ip, "catch {foreach id [after info] {after cancel $id}}");
ruby_debug = rb_debug_bup;
ruby_verbose = rb_verbose_bup;
}
@@ -4602,6 +5308,7 @@ ip_free(ptr)
DUMP2("slave IP(%lx) should not be deleted",
(unsigned long)ptr->ip);
free(ptr);
+ /* ckfree((char*)ptr); */
rb_thread_critical = thr_crit_bup;
return;
}
@@ -4609,6 +5316,7 @@ ip_free(ptr)
if (ptr->ip == (Tcl_Interp*)NULL) {
DUMP1("ip_free is called for deleted IP");
free(ptr);
+ /* ckfree((char*)ptr); */
rb_thread_critical = thr_crit_bup;
return;
}
@@ -4619,6 +5327,7 @@ ip_free(ptr)
ptr->ip = (Tcl_Interp*)NULL;
free(ptr);
+ /* ckfree((char*)ptr); */
rb_thread_critical = thr_crit_bup;
}
@@ -4740,7 +5449,11 @@ ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
int i;
char **argv;
- argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1));
+ /* argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1)); */
+ argv = (char **)ckalloc(sizeof(char *) * (objc + 1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
for(i = 0; i < objc; i++) {
/* argv[i] = Tcl_GetString(objv[i]); */
@@ -4751,7 +5464,16 @@ ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
ret = (*(info.proc))(info.clientData, interp,
objc, (CONST84 char **)argv);
- Tcl_Free((char*)argv);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* Tcl_Free((char*)argv); */
+ ckfree((char*)argv);
+#endif
+#endif
}
DUMP2("namespace wrapper exit depth == %d", rbtk_eventloop_depth);
@@ -4822,15 +5544,25 @@ ip_init(argc, argv, self)
Tk_Window mainWin = (Tk_Window)NULL;
/* security check */
+#ifdef RUBY_VM
if (rb_safe_level() >= 4) {
+#else
+ if (ruby_safe_level >= 4) {
+#endif
rb_raise(rb_eSecurityError,
"Cannot create a TclTkIp object at level %d",
- rb_safe_level());
+#ifdef RUBY_VM
+ rb_safe_level()
+#else
+ ruby_safe_level
+#endif
+ );
}
/* create object */
Data_Get_Struct(self, struct tcltkip, ptr);
ptr = ALLOC(struct tcltkip);
+ /* ptr = (struct tcltkip *)ckalloc(sizeof(struct tcltkip)); */
DATA_PTR(self) = ptr;
#ifdef RUBY_VM
ptr->tk_thread_id = 0;
@@ -4943,7 +5675,8 @@ ip_init(argc, argv, self)
#endif
#ifdef RUBY_VM
- ptr->tk_thread_id = Tcl_GetCurrentThread();
+ /* set Tk thread ID */
+ ptr->tk_thread_id = Tcl_GetCurrentThread();
#endif
/* get main window */
mainWin = Tk_MainWindow(ptr->ip);
@@ -5008,7 +5741,7 @@ ip_init(argc, argv, self)
if (mainWin != (Tk_Window)NULL) {
Tk_Release((ClientData)mainWin);
}
-
+
return self;
}
@@ -5020,6 +5753,7 @@ ip_create_slave_core(interp, argc, argv)
{
struct tcltkip *master = get_ip(interp);
struct tcltkip *slave = ALLOC(struct tcltkip);
+ /* struct tcltkip *slave = (struct tcltkip *)ckalloc(sizeof(struct tcltkip)); */
VALUE safemode;
VALUE name;
int safe;
@@ -5062,6 +5796,10 @@ ip_create_slave_core(interp, argc, argv)
#endif
/* create slave-ip */
+#ifdef RUBY_VM
+ /* slave->tk_thread_id = 0; */
+ slave->tk_thread_id = master->tk_thread_id; /* == current thread */
+#endif
slave->ref_count = 0;
slave->allow_ruby_exit = 0;
slave->return_value = 0;
@@ -5350,6 +6088,12 @@ ip_allow_ruby_exit_set(self, val)
"insecure operation on a safe interpreter");
}
+ /*
+ * Because of cross-threading, the following line may fail to find
+ * the MainWindow, even if the Tcl/Tk interpreter has one or more.
+ * But it has no problem. Current implementation of both type of
+ * the "exit" command don't need maiinWin token.
+ */
mainWin = (tk_stubs_init_p())? Tk_MainWindow(ptr->ip): (Tk_Window)NULL;
if (RTEST(val)) {
@@ -5446,8 +6190,10 @@ ip_is_deleted_p(self)
}
static VALUE
-ip_has_mainwindow_p(self)
+ip_has_mainwindow_p_core(self, argc, argv)
VALUE self;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
{
struct tcltkip *ptr = get_ip(self);
@@ -5460,6 +6206,14 @@ ip_has_mainwindow_p(self)
}
}
+static VALUE
+ip_has_mainwindow_p(self)
+ VALUE self;
+{
+ return tk_funcall(ip_has_mainwindow_p_core, 0, (VALUE*)NULL, self);
+}
+
+
/*** ruby string <=> tcl object ***/
#if TCL_MAJOR_VERSION >= 8
static VALUE
@@ -5469,12 +6223,16 @@ get_str_from_obj(obj)
int len, binary = 0;
const char *s;
volatile VALUE str;
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 4)
+ int len2;
+ const char *s2;
+#endif
#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
s = Tcl_GetStringFromObj(obj, &len);
#else
-#if 0
- /* TCL_VERSION >= 8.1 */
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 3
+ /* TCL_VERSION 8.1 -- 8.3 */
if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
/* possibly binary string */
s = Tcl_GetByteArrayFromObj(obj, &len);
@@ -5483,29 +6241,30 @@ get_str_from_obj(obj)
/* possibly text string */
s = Tcl_GetStringFromObj(obj, &len);
}
-#else
-#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4
- if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
- /* possibly binary string */
- s = Tcl_GetByteArrayFromObj(obj, &len);
- binary = 1;
+#else /* TCL_VERSION >= 8.4 */
+ if (IS_TCL_BYTEARRAY(obj)) {
+ s = Tcl_GetByteArrayFromObj(obj, &len);
+ binary = 1;
} else {
- /* possibly text string */
- s = Tcl_GetStringFromObj(obj, &len);
+ s = Tcl_GetStringFromObj(obj, &len);
}
-#else /* TCL_VERSION >= 8.5 */
- /* TODO: Known BUG:
- Tcl_GetByteArrayFromObj() returns "alloc: invalid block" */
- if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
- /* possibly binary string */
- binary = 1;
- }
- s = Tcl_GetStringFromObj(obj, &len);
-#endif
+
#endif
#endif
str = s ? rb_str_new(s, len) : rb_str_new2("");
- if (binary) rb_ivar_set(str, ID_at_enc, rb_str_new2("binary"));
+ if (binary) {
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+ } else {
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_UTF8);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8);
+#endif
+ }
return str;
}
@@ -5529,6 +6288,11 @@ get_obj_from_str(str)
/* text string */
return Tcl_NewStringObj(s, RSTRING_LEN(str));
}
+#ifdef RUBY_VM
+ } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
+ /* binary string */
+ return Tcl_NewByteArrayObj(s, RSTRING_LEN(str));
+#endif
} else if (strlen(s) != RSTRING_LEN(str)) {
/* probably binary string */
return Tcl_NewByteArrayObj(s, RSTRING_LEN(str));
@@ -5583,11 +6347,12 @@ call_queue_handler(evPtr, flags)
struct call_queue *q = (struct call_queue *)evPtr;
volatile VALUE ret;
volatile VALUE q_dat;
+ volatile VALUE thread = q->thread;
struct tcltkip *ptr;
DUMP2("do_call_queue_handler : evPtr = %p", evPtr);
DUMP2("call_queue_handler thread : %lx", rb_thread_current());
- DUMP2("added by thread : %lx", q->thread);
+ DUMP2("added by thread : %lx", thread);
if (*(q->done)) {
DUMP1("processed by another event-loop");
@@ -5596,6 +6361,12 @@ call_queue_handler(evPtr, flags)
DUMP1("process it on current event-loop");
}
+ if (RTEST(rb_thread_alive_p(thread))
+ && ! RTEST(rb_funcall(thread, ID_stop_p, 0))) {
+ DUMP1("caller is not yet ready to receive the result -> pending");
+ return 0;
+ }
+
/* process it */
*(q->done) = 1;
@@ -5606,33 +6377,56 @@ call_queue_handler(evPtr, flags)
return 1;
}
+ /* incr internal handler mark */
+ rbtk_internal_eventloop_handler++;
+
/* check safe-level */
if (rb_safe_level() != q->safe_level) {
- /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
- q_dat = Data_Wrap_Struct(rb_cData,call_queue_mark,0,q);
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,-1,q); */
+ q_dat = Data_Wrap_Struct(rb_cData,call_queue_mark,-1,q);
ret = rb_funcall(rb_proc_new(callq_safelevel_handler, q_dat),
ID_call, 0);
rb_gc_force_recycle(q_dat);
+ q_dat = (VALUE)NULL;
} else {
- DUMP2("call function (for caller thread:%lx)", q->thread);
+ DUMP2("call function (for caller thread:%lx)", thread);
DUMP2("call function (current thread:%lx)", rb_thread_current());
ret = (q->func)(q->interp, q->argc, q->argv);
}
/* set result */
RARRAY_PTR(q->result)[0] = ret;
+ ret = (VALUE)NULL;
+
+ /* decr internal handler mark */
+ rbtk_internal_eventloop_handler--;
/* complete */
*(q->done) = -1;
+ /* unlink ruby objects */
+ q->argv = (VALUE*)NULL;
+ q->interp = (VALUE)NULL;
+ q->result = (VALUE)NULL;
+ q->thread = (VALUE)NULL;
+
/* back to caller */
- if (RTEST(rb_funcall(q->thread, ID_alive_p, 0, 0))) {
- DUMP2("back to caller (caller thread:%lx)", q->thread);
+ /* if (RTEST(rb_funcall(thread, ID_alive_p, 0, 0))) { */
+ if (RTEST(rb_thread_alive_p(thread))) {
+ DUMP2("back to caller (caller thread:%lx)", thread);
DUMP2(" (current thread:%lx)", rb_thread_current());
- rb_thread_run(q->thread);
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ have_rb_thread_waiting_for_value = 1;
+ rb_thread_wakeup(thread);
+#else
+ rb_thread_run(thread);
+#endif
DUMP1("finish back to caller");
+#if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE
+ rb_thread_schedule();
+#endif
} else {
- DUMP2("caller is dead (caller thread:%lx)", q->thread);
+ DUMP2("caller is dead (caller thread:%lx)", thread);
DUMP2(" (current thread:%lx)", rb_thread_current());
}
@@ -5648,32 +6442,39 @@ tk_funcall(func, argc, argv, obj)
VALUE obj;
{
struct call_queue *callq;
-#ifdef RUBY_VM
struct tcltkip *ptr;
-#endif
int *alloc_done;
int thr_crit_bup;
+ int is_tk_evloop_thread;
volatile VALUE current = rb_thread_current();
volatile VALUE ip_obj = obj;
volatile VALUE result;
volatile VALUE ret;
-
- if (!NIL_P(ip_obj) && deleted_ip(get_ip(ip_obj))) {
- return Qnil;
+ if (!NIL_P(ip_obj) && rb_obj_is_kind_of(ip_obj, tcltkip_class)) {
+ ptr = get_ip(ip_obj);
+ if (deleted_ip(ptr)) return Qnil;
+ } else {
+ ptr = (struct tcltkip *)NULL;
}
#ifdef RUBY_VM
- ptr = get_ip(ip_obj);
+ if (ptr) {
+ /* on Tcl interpreter */
+ is_tk_evloop_thread = (ptr->tk_thread_id == (Tcl_ThreadId) 0
+ || ptr->tk_thread_id == Tcl_GetCurrentThread());
+ } else {
+ /* on Tcl/Tk library */
+ is_tk_evloop_thread = (tk_eventloop_thread_id == (Tcl_ThreadId) 0
+ || tk_eventloop_thread_id == Tcl_GetCurrentThread());
+ }
+#else
+ is_tk_evloop_thread = 1;
#endif
- if (
-#ifdef RUBY_VM
- (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
- &&
-#endif
- (NIL_P(eventloop_thread) || current == eventloop_thread)
- ) {
+ if (is_tk_evloop_thread
+ && (NIL_P(eventloop_thread) || current == eventloop_thread)
+ ) {
if (NIL_P(eventloop_thread)) {
DUMP2("tk_funcall from thread:%lx but no eventloop", current);
} else {
@@ -5693,18 +6494,29 @@ tk_funcall(func, argc, argv, obj)
/* allocate memory (argv cross over thread : must be in heap) */
if (argv) {
- VALUE *temp = ALLOC_N(VALUE, argc);
+ /* VALUE *temp = ALLOC_N(VALUE, argc); */
+ VALUE *temp = (VALUE*)ckalloc(sizeof(VALUE) * argc);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)temp); /* XXXXXXXX */
+#endif
MEMCPY(temp, argv, VALUE, argc);
argv = temp;
}
/* allocate memory (keep result) */
- alloc_done = (int*)ALLOC(int);
+ /* alloc_done = (int*)ALLOC(int); */
+ alloc_done = (int*)ckalloc(sizeof(int));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
+#endif
*alloc_done = 0;
/* allocate memory (freed by Tcl_ServiceEvent) */
- callq = (struct call_queue *)Tcl_Alloc(sizeof(struct call_queue));
+ /* callq = (struct call_queue *)Tcl_Alloc(sizeof(struct call_queue)); */
+ callq = (struct call_queue *)ckalloc(sizeof(struct call_queue));
+#if 0 /* use Tcl_Preserve/Release */
Tcl_Preserve(callq);
+#endif
/* allocate result obj */
result = rb_ary_new3(1, Qnil);
@@ -5723,14 +6535,25 @@ tk_funcall(func, argc, argv, obj)
/* add the handler to Tcl event queue */
DUMP1("add handler");
#ifdef RUBY_VM
- if (ptr->tk_thread_id) {
- Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(callq->ev), TCL_QUEUE_HEAD);
+ if (ptr && ptr->tk_thread_id) {
+ /* Tcl_ThreadQueueEvent(ptr->tk_thread_id,
+ &(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_ThreadQueueEvent(ptr->tk_thread_id,
+ (Tcl_Event*)callq, TCL_QUEUE_HEAD);
Tcl_ThreadAlert(ptr->tk_thread_id);
+ } else if (tk_eventloop_thread_id) {
+ /* Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ &(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ (Tcl_Event*)callq, TCL_QUEUE_HEAD);
+ Tcl_ThreadAlert(tk_eventloop_thread_id);
} else {
- Tcl_QueueEvent(&(callq->ev), TCL_QUEUE_HEAD);
+ /* Tcl_QueueEvent(&(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
}
#else
- Tcl_QueueEvent(&(callq->ev), TCL_QUEUE_HEAD);
+ /* Tcl_QueueEvent(&(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
#endif
rb_thread_critical = thr_crit_bup;
@@ -5739,22 +6562,55 @@ tk_funcall(func, argc, argv, obj)
DUMP2("wait for handler (current thread:%lx)", current);
while(*alloc_done >= 0) {
DUMP2("*** wait for handler (current thread:%lx)", current);
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
DUMP2("*** wakeup (current thread:%lx)", current);
}
DUMP2("back from handler (current thread:%lx)", current);
/* get result & free allocated memory */
ret = RARRAY_PTR(result)[0];
- free(alloc_done);
- if (argv) free(argv);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)alloc_done); /* XXXXXXXX */
+#else
+ /* free(alloc_done); */
+ ckfree((char*)alloc_done);
+#endif
+#endif
+ /* if (argv) free(argv); */
+ if (argv) {
+ /* if argv != NULL, alloc as 'temp' */
+ int i;
+ for(i = 0; i < argc; i++) { argv[i] = (VALUE)NULL; }
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ ckfree((char*)argv);
+#endif
+#endif
+ }
+
+#if 0 /* callq is freed by Tcl_ServiceEvent */
+#if 0 /* use Tcl_Preserve/Release */
Tcl_Release(callq);
+#else
+ ckfree((char*)callq);
+#endif
+#endif
/* exception? */
if (rb_obj_is_kind_of(ret, rb_eException)) {
DUMP1("raise exception");
- rb_exc_raise(ret);
+ /* rb_exc_raise(ret); */
+ rb_exc_raise(rb_exc_new3(rb_obj_class(ret),
+ rb_funcall(ret, ID_to_s, 0, 0)));
}
DUMP1("exit tk_funcall");
@@ -5825,19 +6681,35 @@ ip_eval_real(self, cmd_str, cmd_len)
ret = rb_protect(call_tcl_eval, (VALUE)&inf, &status);
switch(status) {
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception = rb_exc_new2(rb_eException,
"unknown exception");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
}
break;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
}
}
#endif
@@ -5937,11 +6809,12 @@ eval_queue_handler(evPtr, flags)
struct eval_queue *q = (struct eval_queue *)evPtr;
volatile VALUE ret;
volatile VALUE q_dat;
+ volatile VALUE thread = q->thread;
struct tcltkip *ptr;
DUMP2("do_eval_queue_handler : evPtr = %p", evPtr);
DUMP2("eval_queue_thread : %lx", rb_thread_current());
- DUMP2("added by thread : %lx", q->thread);
+ DUMP2("added by thread : %lx", thread);
if (*(q->done)) {
DUMP1("processed by another event-loop");
@@ -5950,6 +6823,12 @@ eval_queue_handler(evPtr, flags)
DUMP1("process it on current event-loop");
}
+ if (RTEST(rb_thread_alive_p(thread))
+ && ! RTEST(rb_funcall(thread, ID_stop_p, 0))) {
+ DUMP1("caller is not yet ready to receive the result -> pending");
+ return 0;
+ }
+
/* process it */
*(q->done) = 1;
@@ -5960,38 +6839,66 @@ eval_queue_handler(evPtr, flags)
return 1;
}
+ /* incr internal handler mark */
+ rbtk_internal_eventloop_handler++;
+
/* check safe-level */
if (rb_safe_level() != q->safe_level) {
-#if 0
#ifdef HAVE_NATIVETHREAD
- if (!ruby_native_thread_p()) {
- rb_bug("cross-thread violation on eval_queue_handler()");
- }
+#ifdef RUBY_VM
+#if 0
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on eval_queue_handler()");
+ }
#endif
+#else
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on eval_queue_handler()");
+ }
#endif
- /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
- q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,0,q);
+#endif
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,-1,q); */
+ q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,-1,q);
ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat),
ID_call, 0);
rb_gc_force_recycle(q_dat);
+ q_dat = (VALUE)NULL;
} else {
ret = ip_eval_real(q->interp, q->str, q->len);
}
/* set result */
RARRAY_PTR(q->result)[0] = ret;
+ ret = (VALUE)NULL;
+
+ /* decr internal handler mark */
+ rbtk_internal_eventloop_handler--;
/* complete */
*(q->done) = -1;
+ /* unlink ruby objects */
+ q->interp = (VALUE)NULL;
+ q->result = (VALUE)NULL;
+ q->thread = (VALUE)NULL;
+
/* back to caller */
- if (RTEST(rb_funcall(q->thread, ID_alive_p, 0, 0))) {
- DUMP2("back to caller (caller thread:%lx)", q->thread);
+ /* if (RTEST(rb_funcall(thread, ID_alive_p, 0, 0))) { */
+ if (RTEST(rb_thread_alive_p(thread))) {
+ DUMP2("back to caller (caller thread:%lx)", thread);
DUMP2(" (current thread:%lx)", rb_thread_current());
- rb_thread_run(q->thread);
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ have_rb_thread_waiting_for_value = 1;
+ rb_thread_wakeup(thread);
+#else
+ rb_thread_run(thread);
+#endif
DUMP1("finish back to caller");
+#if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE
+ rb_thread_schedule();
+#endif
} else {
- DUMP2("caller is dead (caller thread:%lx)", q->thread);
+ DUMP2("caller is dead (caller thread:%lx)", thread);
DUMP2(" (current thread:%lx)", rb_thread_current());
}
@@ -6050,17 +6957,28 @@ ip_eval(self, str)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
- /* allocate memory (protected from Tcl_ServiceEvent) */
- alloc_done = (int*)ALLOC(int);
+ /* allocate memory (keep result) */
+ /* alloc_done = (int*)ALLOC(int); */
+ alloc_done = (int*)ckalloc(sizeof(int));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
+#endif
*alloc_done = 0;
- eval_str = ALLOC_N(char, RSTRING_LEN(str) + 1);
+ /* eval_str = ALLOC_N(char, RSTRING_LEN(str) + 1); */
+ eval_str = ckalloc(sizeof(char) * (RSTRING_LEN(str) + 1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)eval_str); /* XXXXXXXX */
+#endif
memcpy(eval_str, RSTRING_PTR(str), RSTRING_LEN(str));
eval_str[RSTRING_LEN(str)] = 0;
/* allocate memory (freed by Tcl_ServiceEvent) */
- evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue));
+ /* evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue)); */
+ evq = (struct eval_queue *)ckalloc(sizeof(struct eval_queue));
+#if 0 /* use Tcl_Preserve/Release */
Tcl_Preserve(evq);
+#endif
/* allocate result obj */
result = rb_ary_new3(1, Qnil);
@@ -6081,13 +6999,21 @@ ip_eval(self, str)
DUMP1("add handler");
#ifdef RUBY_VM
if (ptr->tk_thread_id) {
- Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(evq->ev), position);
+ /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(evq->ev), position); */
+ Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)evq, position);
Tcl_ThreadAlert(ptr->tk_thread_id);
+ } else if (tk_eventloop_thread_id) {
+ Tcl_ThreadQueueEvent(tk_eventloop_thread_id, (Tcl_Event*)evq, position);
+ /* Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ &(evq->ev), position); */
+ Tcl_ThreadAlert(tk_eventloop_thread_id);
} else {
- Tcl_QueueEvent(&(evq->ev), position);
+ /* Tcl_QueueEvent(&(evq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)evq, position);
}
#else
- Tcl_QueueEvent(&(evq->ev), position);
+ /* Tcl_QueueEvent(&(evq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)evq, position);
#endif
rb_thread_critical = thr_crit_bup;
@@ -6096,7 +7022,8 @@ ip_eval(self, str)
DUMP2("wait for handler (current thread:%lx)", current);
while(*alloc_done >= 0) {
DUMP2("*** wait for handler (current thread:%lx)", current);
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
DUMP2("*** wakeup (current thread:%lx)", current);
}
DUMP2("back from handler (current thread:%lx)", current);
@@ -6104,12 +7031,39 @@ ip_eval(self, str)
/* get result & free allocated memory */
ret = RARRAY_PTR(result)[0];
- free(alloc_done);
- free(eval_str);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)alloc_done); /* XXXXXXXX */
+#else
+ /* free(alloc_done); */
+ ckfree((char*)alloc_done);
+#endif
+#endif
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)eval_str, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)eval_str); /* XXXXXXXX */
+#else
+ /* free(eval_str); */
+ ckfree(eval_str);
+#endif
+#endif
+#if 0 /* evq is freed by Tcl_ServiceEvent */
+#if 0 /* use Tcl_Preserve/Release */
Tcl_Release(evq);
+#else
+ ckfree((char*)evq);
+#endif
+#endif
if (rb_obj_is_kind_of(ret, rb_eException)) {
- rb_exc_raise(ret);
+ DUMP1("raise exception");
+ /* rb_exc_raise(ret); */
+ rb_exc_raise(rb_exc_new3(rb_obj_class(ret),
+ rb_funcall(ret, ID_to_s, 0, 0)));
}
return ret;
@@ -6264,7 +7218,12 @@ lib_toUTF8_core(ip_obj, src, encodename)
if (NIL_P(encodename)) {
if (TYPE(str) == T_STRING) {
volatile VALUE enc;
+
+#ifdef RUBY_VM
+ enc = rb_funcall(rb_obj_encoding(str), ID_to_s, 0, 0);
+#else
enc = rb_attr_get(str, ID_at_enc);
+#endif
if (NIL_P(enc)) {
if (NIL_P(ip_obj)) {
encoding = (Tcl_Encoding)NULL;
@@ -6273,20 +7232,33 @@ lib_toUTF8_core(ip_obj, src, encodename)
if (NIL_P(enc)) {
encoding = (Tcl_Encoding)NULL;
} else {
- StringValue(enc);
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
- if (encoding == (Tcl_Encoding)NULL) {
+ /* StringValue(enc); */
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ if (!RSTRING_LEN(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL,
+ RSTRING_PTR(enc));
+ if (encoding == (Tcl_Encoding)NULL) {
rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
- }
+ }
+ }
}
}
} else {
StringValue(enc);
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
rb_thread_critical = thr_crit_bup;
return str;
}
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL,
+ RSTRING_PTR(enc));
if (encoding == (Tcl_Encoding)NULL) {
rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
}
@@ -6296,7 +7268,16 @@ lib_toUTF8_core(ip_obj, src, encodename)
}
} else {
StringValue(encodename);
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename));
+ if (strcmp(RSTRING_PTR(encodename), "binary") == 0) {
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(encodename));
if (encoding == (Tcl_Encoding)NULL) {
/*
rb_warning("unknown encoding name '%s'",
@@ -6312,7 +7293,8 @@ lib_toUTF8_core(ip_obj, src, encodename)
rb_thread_critical = thr_crit_bup;
return str;
}
- buf = ALLOC_N(char,RSTRING_LEN(str)+1);
+ buf = ALLOC_N(char, RSTRING_LEN(str)+1);
+ /* buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1)); */
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
buf[RSTRING_LEN(str)] = 0;
@@ -6324,15 +7306,21 @@ lib_toUTF8_core(ip_obj, src, encodename)
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
str = rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
- rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("utf-8"));
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_UTF8);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8);
if (taint_flag) OBJ_TAINT(str);
+ /*
if (encoding != (Tcl_Encoding)NULL) {
Tcl_FreeEncoding(encoding);
}
+ */
Tcl_DStringFree(&dstr);
free(buf);
+ /* ckfree(buf); */
rb_thread_critical = thr_crit_bup;
#endif
@@ -6411,9 +7399,20 @@ lib_fromUTF8_core(ip_obj, src, encodename)
if (!NIL_P(enc)) {
StringValue(enc);
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
rb_thread_critical = thr_crit_bup;
return str;
}
+#ifdef RUBY_VM
+ } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+ rb_thread_critical = thr_crit_bup;
+ return str;
+#endif
}
}
@@ -6424,13 +7423,20 @@ lib_fromUTF8_core(ip_obj, src, encodename)
if (NIL_P(enc)) {
encoding = (Tcl_Encoding)NULL;
} else {
- StringValue(enc);
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
- if (encoding == (Tcl_Encoding)NULL) {
+ /* StringValue(enc); */
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ if (!RSTRING_LEN(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL,
+ RSTRING_PTR(enc));
+ if (encoding == (Tcl_Encoding)NULL) {
rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
- } else {
- encodename = rb_obj_dup(enc);
- }
+ } else {
+ encodename = rb_obj_dup(enc);
+ }
+ }
}
}
@@ -6438,21 +7444,28 @@ lib_fromUTF8_core(ip_obj, src, encodename)
StringValue(encodename);
if (strcmp(RSTRING_PTR(encodename), "binary") == 0) {
+ Tcl_Obj *tclstr;
char *s;
int len;
StringValue(str);
- s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING_PTR(str),
- RSTRING_LEN(str)),
- &len);
+ tclstr = Tcl_NewStringObj(RSTRING_PTR(str), RSTRING_LEN(str));
+ Tcl_IncrRefCount(tclstr);
+ s = Tcl_GetByteArrayFromObj(tclstr, &len);
str = rb_tainted_str_new(s, len);
- rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary"));
+ s = (char*)NULL;
+ Tcl_DecrRefCount(tclstr);
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
rb_thread_critical = thr_crit_bup;
return str;
}
- encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename));
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(encodename));
if (encoding == (Tcl_Encoding)NULL) {
/*
rb_warning("unknown encoding name '%s'",
@@ -6471,7 +7484,8 @@ lib_fromUTF8_core(ip_obj, src, encodename)
return rb_tainted_str_new2("");
}
- buf = ALLOC_N(char,strlen(RSTRING_PTR(str))+1);
+ buf = ALLOC_N(char, RSTRING_LEN(str)+1);
+ /* buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1)); */
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
buf[RSTRING_LEN(str)] = 0;
@@ -6483,16 +7497,32 @@ lib_fromUTF8_core(ip_obj, src, encodename)
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
str = rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
+#ifdef RUBY_VM
+ if (interp) {
+ /* can access encoding_table of TclTkIp */
+ /* -> try to use encoding_table */
+ VALUE tbl = ip_get_encoding_table(ip_obj);
+ VALUE encobj = encoding_table_get_obj(tbl, encodename);
+ rb_enc_associate_index(str, rb_to_encoding_index(encobj));
+ } else {
+ /* cannot access encoding_table of TclTkIp */
+ /* -> try to find on Ruby Encoding */
+ rb_enc_associate_index(str, rb_enc_find_index(RSTRING_PTR(encodename)));
+ }
+#endif
rb_ivar_set(str, ID_at_enc, encodename);
if (taint_flag) OBJ_TAINT(str);
+ /*
if (encoding != (Tcl_Encoding)NULL) {
Tcl_FreeEncoding(encoding);
}
+ */
Tcl_DStringFree(&dstr);
free(buf);
+ /* ckfree(buf); */
rb_thread_critical = thr_crit_bup;
#endif
@@ -6550,11 +7580,19 @@ lib_UTF_backslash_core(self, str, all_bs)
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
- src_buf = ALLOC_N(char,RSTRING_LEN(str)+1);
+ /* src_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
+ src_buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)src_buf); /* XXXXXXXX */
+#endif
memcpy(src_buf, RSTRING_PTR(str), RSTRING_LEN(str));
src_buf[RSTRING_LEN(str)] = 0;
- dst_buf = ALLOC_N(char,RSTRING_LEN(str)+1);
+ /* dst_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
+ dst_buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)dst_buf); /* XXXXXXXX */
+#endif
ptr = src_buf;
while(RSTRING_LEN(str) > ptr - src_buf) {
@@ -6568,9 +7606,31 @@ lib_UTF_backslash_core(self, str, all_bs)
str = rb_str_new(dst_buf, dst_len);
if (taint_flag) OBJ_TAINT(str);
+#ifdef RUBY_VM
+ rb_enc_associate_index(str, ENCODING_INDEX_UTF8);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8);
- free(src_buf);
- free(dst_buf);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)src_buf, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)src_buf); /* XXXXXXXX */
+#else
+ /* free(src_buf); */
+ ckfree(src_buf);
+#endif
+#endif
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)dst_buf, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)dst_buf); /* XXXXXXXX */
+#else
+ /* free(dst_buf); */
+ ckfree(dst_buf);
+#endif
+#endif
rb_thread_critical = thr_crit_bup;
#endif
@@ -6661,8 +7721,11 @@ invoke_tcl_proc(arg)
#if TCL_MAJOR_VERSION >= 8
if (!inf->cmdinfo.isNativeObjectProc) {
/* string interface */
- // argv = (char **)ALLOC_N(char *, argc+1); /* XXXXXXXXXX */
+ /* argv = (char **)ALLOC_N(char *, argc+1);*/ /* XXXXXXXXXX */
argv = (char **)ckalloc(sizeof(char *)*(argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
for (i = 0; i < argc; ++i) {
argv[i] = Tcl_GetStringFromObj(inf->objv[i], &len);
}
@@ -6675,7 +7738,6 @@ invoke_tcl_proc(arg)
/* Invoke the C procedure */
#if TCL_MAJOR_VERSION >= 8
if (inf->cmdinfo.isNativeObjectProc) {
- int ret_val;
inf->ptr->return_value
= (*(inf->cmdinfo.objProc))(inf->cmdinfo.objClientData,
inf->ptr->ip, inf->objc, inf->objv);
@@ -6688,8 +7750,16 @@ invoke_tcl_proc(arg)
= (*(inf->cmdinfo.proc))(inf->cmdinfo.clientData, inf->ptr->ip,
argc, (CONST84 char **)argv);
- //free(argv);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
ckfree((char*)argv);
+#endif
+#endif
#else /* TCL_MAJOR_VERSION < 8 */
inf->ptr->return_value
@@ -6745,6 +7815,9 @@ ip_invoke_core(interp, argc, argv)
cmd = argv[0];
#endif
+ /* get the data struct */
+ ptr = get_ip(interp);
+
/* ip is deleted? */
if (deleted_ip(ptr)) {
return rb_tainted_str_new2("");
@@ -6794,15 +7867,22 @@ ip_invoke_core(interp, argc, argv)
unknown_flag = 1;
#if TCL_MAJOR_VERSION >= 8
- //unknown_objv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, objc+2);
+ /* unknown_objv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, objc+2); */
unknown_objv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc+2));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)unknown_objv); /* XXXXXXXX */
+#endif
unknown_objv[0] = Tcl_NewStringObj("::unknown", 9);
Tcl_IncrRefCount(unknown_objv[0]);
memcpy(unknown_objv + 1, objv, sizeof(Tcl_Obj *)*objc);
unknown_objv[++objc] = (Tcl_Obj*)NULL;
objv = unknown_objv;
#else
- unknown_argv = (char **)ALLOC_N(char *, argc+2);
+ /* unknown_argv = (char **)ALLOC_N(char *, argc+2); */
+ unknown_argv = (char **)ckalloc(sizeof(char *) * (argc+2));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)unknown_argv); /* XXXXXXXX */
+#endif
unknown_argv[0] = strdup("unknown");
memcpy(unknown_argv + 1, argv, sizeof(char *)*argc);
unknown_argv[++argc] = (char *)NULL;
@@ -6831,19 +7911,35 @@ ip_invoke_core(interp, argc, argv)
ret = rb_protect(invoke_tcl_proc, (VALUE)&inf, &status);
switch(status) {
case TAG_RAISE:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception = rb_exc_new2(rb_eException,
"unknown exception");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
}
break;
case TAG_FATAL:
+#ifdef RUBY_VM
if (NIL_P(rb_errinfo())) {
+#else
+ if (NIL_P(ruby_errinfo)) {
+#endif
rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL");
} else {
+#ifdef RUBY_VM
rbtk_pending_exception = rb_errinfo();
+#else
+ rbtk_pending_exception = ruby_errinfo;
+#endif
}
}
@@ -6855,8 +7951,11 @@ ip_invoke_core(interp, argc, argv)
int i;
/* string interface */
- //argv = (char **)ALLOC_N(char *, argc+1);
+ /* argv = (char **)ALLOC_N(char *, argc+1); */
argv = (char **)ckalloc(sizeof(char *) * (argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
for (i = 0; i < argc; ++i) {
argv[i] = Tcl_GetStringFromObj(objv[i], &len);
}
@@ -6885,8 +7984,16 @@ ip_invoke_core(interp, argc, argv)
ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
argc, (CONST84 char **)argv);
- //free(argv);
- ckfree(argv);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
#else /* TCL_MAJOR_VERSION < 8 */
ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
@@ -6899,10 +8006,29 @@ ip_invoke_core(interp, argc, argv)
if (unknown_flag) {
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(objv[0]);
- free(objv);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)objv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)objv); /* XXXXXXXX */
#else
+ /* free(objv); */
+ ckfree((char*)objv);
+#endif
+#endif
+#else /* TCL_MAJOR_VERSION < 8 */
free(argv[0]);
- free(argv);
+ /* ckfree(argv[0]); */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
#endif
}
@@ -6957,8 +8083,11 @@ alloc_invoke_arguments(argc, argv)
/* memory allocation */
#if TCL_MAJOR_VERSION >= 8
- //av = ALLOC_N(Tcl_Obj *, argc+1); /* XXXXXXXXXX */
+ /* av = ALLOC_N(Tcl_Obj *, argc+1);*/ /* XXXXXXXXXX */
av = (Tcl_Obj**)ckalloc(sizeof(Tcl_Obj *)*(argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)av); /* XXXXXXXX */
+#endif
for (i = 0; i < argc; ++i) {
av[i] = get_obj_from_str(argv[i]);
Tcl_IncrRefCount(av[i]);
@@ -6967,7 +8096,11 @@ alloc_invoke_arguments(argc, argv)
#else /* TCL_MAJOR_VERSION < 8 */
/* string interface */
- av = ALLOC_N(char *, argc+1);
+ /* av = ALLOC_N(char *, argc+1); */
+ av = (char**)ckalloc(sizeof(char *) * (argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)av); /* XXXXXXXX */
+#endif
for (i = 0; i < argc; ++i) {
av[i] = strdup(StringValuePtr(argv[i]));
}
@@ -6993,14 +8126,33 @@ free_invoke_arguments(argc, av)
for (i = 0; i < argc; ++i) {
#if TCL_MAJOR_VERSION >= 8
Tcl_DecrRefCount(av[i]);
+ av[i] = (Tcl_Obj*)NULL;
#else /* TCL_MAJOR_VERSION < 8 */
free(av[i]);
+ av[i] = (char*)NULL;
#endif
}
#if TCL_MAJOR_VERSION >= 8
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)av); /* XXXXXXXX */
+#else
ckfree((char*)av);
+#endif
+#endif
#else /* TCL_MAJOR_VERSION < 8 */
- free(av);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)av); /* XXXXXXXX */
+#else
+ /* free(av); */
+ ckfree((char*)av);
+#endif
+#endif
#endif
}
@@ -7064,10 +8216,12 @@ invoke_queue_handler(evPtr, flags)
struct invoke_queue *q = (struct invoke_queue *)evPtr;
volatile VALUE ret;
volatile VALUE q_dat;
+ volatile VALUE thread = q->thread;
+ struct tcltkip *ptr;
DUMP2("do_invoke_queue_handler : evPtr = %p", evPtr);
DUMP2("invoke queue_thread : %lx", rb_thread_current());
- DUMP2("added by thread : %lx", q->thread);
+ DUMP2("added by thread : %lx", thread);
if (*(q->done)) {
DUMP1("processed by another event-loop");
@@ -7076,36 +8230,71 @@ invoke_queue_handler(evPtr, flags)
DUMP1("process it on current event-loop");
}
+ if (RTEST(rb_thread_alive_p(thread))
+ && ! RTEST(rb_funcall(thread, ID_stop_p, 0))) {
+ DUMP1("caller is not yet ready to receive the result -> pending");
+ return 0;
+ }
+
/* process it */
*(q->done) = 1;
+ /* deleted ipterp ? */
+ ptr = get_ip(q->interp);
+ if (deleted_ip(ptr)) {
+ /* deleted IP --> ignore */
+ return 1;
+ }
+
+ /* incr internal handler mark */
+ rbtk_internal_eventloop_handler++;
+
/* check safe-level */
if (rb_safe_level() != q->safe_level) {
/* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
- q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,0,q);
+ q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,-1,q);
ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat),
ID_call, 0);
rb_gc_force_recycle(q_dat);
+ q_dat = (VALUE)NULL;
} else {
- DUMP2("call invoke_real (for caller thread:%lx)", q->thread);
+ DUMP2("call invoke_real (for caller thread:%lx)", thread);
DUMP2("call invoke_real (current thread:%lx)", rb_thread_current());
ret = ip_invoke_core(q->interp, q->argc, q->argv);
}
/* set result */
RARRAY_PTR(q->result)[0] = ret;
+ ret = (VALUE)NULL;
+
+ /* decr internal handler mark */
+ rbtk_internal_eventloop_handler--;
/* complete */
*(q->done) = -1;
+ /* unlink ruby objects */
+ q->interp = (VALUE)NULL;
+ q->result = (VALUE)NULL;
+ q->thread = (VALUE)NULL;
+
/* back to caller */
- if (RTEST(rb_funcall(q->thread, ID_alive_p, 0, 0))) {
- DUMP2("back to caller (caller thread:%lx)", q->thread);
+ /* if (RTEST(rb_funcall(thread, ID_alive_p, 0, 0))) { */
+ if (RTEST(rb_thread_alive_p(thread))) {
+ DUMP2("back to caller (caller thread:%lx)", thread);
DUMP2(" (current thread:%lx)", rb_thread_current());
- rb_thread_run(q->thread);
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ have_rb_thread_waiting_for_value = 1;
+ rb_thread_wakeup(thread);
+#else
+ rb_thread_run(thread);
+#endif
DUMP1("finish back to caller");
+#if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE
+ rb_thread_schedule();
+#endif
} else {
- DUMP2("caller is dead (caller thread:%lx)", q->thread);
+ DUMP2("caller is dead (caller thread:%lx)", thread);
DUMP2(" (current thread:%lx)", rb_thread_current());
}
@@ -7143,8 +8332,8 @@ ip_invoke_with_position(argc, argv, obj, position)
#ifdef RUBY_VM
ptr = get_ip(ip_obj);
-#endif
DUMP2("status: ptr->tk_thread_id %d", ptr->tk_thread_id);
+#endif
DUMP2("status: Tcl_GetCurrentThread %d", Tcl_GetCurrentThread());
DUMP2("status: eventloopt_thread %lx", eventloop_thread);
@@ -7167,6 +8356,8 @@ ip_invoke_with_position(argc, argv, obj, position)
return result;
}
+ DUMP2("invoke from thread %lx (NOT current eventloop)", current);
+
thr_crit_bup = rb_thread_critical;
rb_thread_critical = Qtrue;
@@ -7174,13 +8365,19 @@ ip_invoke_with_position(argc, argv, obj, position)
av = alloc_invoke_arguments(argc, argv);
/* allocate memory (keep result) */
- //alloc_done = (int*)ALLOC(int);
+ /* alloc_done = (int*)ALLOC(int); */
alloc_done = (int*)ckalloc(sizeof(int));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
+#endif
*alloc_done = 0;
/* allocate memory (freed by Tcl_ServiceEvent) */
+ /* ivq = (struct invoke_queue *)Tcl_Alloc(sizeof(struct invoke_queue)); */
ivq = (struct invoke_queue *)ckalloc(sizeof(struct invoke_queue));
- Tcl_Preserve(ivq);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)ivq); /* XXXXXXXX */
+#endif
/* allocate result obj */
result = rb_ary_new3(1, Qnil);
@@ -7199,13 +8396,22 @@ ip_invoke_with_position(argc, argv, obj, position)
DUMP1("add handler");
#ifdef RUBY_VM
if (ptr->tk_thread_id) {
- Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(ivq->ev), position);
+ /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(ivq->ev), position); */
+ Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)ivq, position);
Tcl_ThreadAlert(ptr->tk_thread_id);
+ } else if (tk_eventloop_thread_id) {
+ /* Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ &(ivq->ev), position); */
+ Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ (Tcl_Event*)ivq, position);
+ Tcl_ThreadAlert(tk_eventloop_thread_id);
} else {
- Tcl_QueueEvent(&(ivq->ev), position);
+ /* Tcl_QueueEvent(&(ivq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)ivq, position);
}
#else
- Tcl_QueueEvent(&(ivq->ev), position);
+ /* Tcl_QueueEvent(&(ivq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)ivq, position);
#endif
rb_thread_critical = thr_crit_bup;
@@ -7213,16 +8419,35 @@ ip_invoke_with_position(argc, argv, obj, position)
/* wait for the handler to be processed */
DUMP2("wait for handler (current thread:%lx)", current);
while(*alloc_done >= 0) {
- rb_thread_stop();
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
}
DUMP2("back from handler (current thread:%lx)", current);
/* get result & free allocated memory */
- ret = RARRAY_PTR(result)[0];
- //free(alloc_done);
+ ret = RARRAY(result)->ptr[0];
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)alloc_done); /* XXXXXXXX */
+#else
+ /* free(alloc_done); */
ckfree((char*)alloc_done);
+#endif
+#endif
+#if 0 /* ivq is freed by Tcl_ServiceEvent */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)ivq, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
Tcl_Release(ivq);
+#else
+ ckfree((char*)ivq);
+#endif
+#endif
+#endif
/* free allocated memory */
free_invoke_arguments(argc, av);
@@ -7230,9 +8455,12 @@ ip_invoke_with_position(argc, argv, obj, position)
/* exception? */
if (rb_obj_is_kind_of(ret, rb_eException)) {
DUMP1("raise exception");
- rb_exc_raise(ret);
+ /* rb_exc_raise(ret); */
+ rb_exc_raise(rb_exc_new3(rb_obj_class(ret),
+ rb_funcall(ret, ID_to_s, 0, 0)));
}
+ DUMP1("exit ip_invoke");
return ret;
}
@@ -7692,6 +8920,10 @@ lib_split_tklist_core(ip_obj, list_str)
volatile VALUE ary, elem;
int idx;
int taint_flag = OBJ_TAINTED(list_str);
+#ifdef RUBY_VM
+ int list_enc_idx;
+ volatile VALUE list_ivar_enc;
+#endif
int result;
VALUE old_gc;
@@ -7706,6 +8938,10 @@ lib_split_tklist_core(ip_obj, list_str)
}
StringValue(list_str);
+#ifdef RUBY_VM
+ list_enc_idx = rb_enc_get_index(list_str);
+ list_ivar_enc = rb_ivar_get(list_str, ID_at_enc);
+#endif
{
#if TCL_MAJOR_VERSION >= 8
@@ -7744,10 +8980,22 @@ lib_split_tklist_core(ip_obj, list_str)
for(idx = 0; idx < objc; idx++) {
elem = get_str_from_obj(objv[idx]);
+#ifdef RUBY_VM
+ if (rb_enc_get_index(elem) == ENCODING_INDEX_BINARY) {
+ rb_enc_associate_index(elem, ENCODING_INDEX_BINARY);
+ rb_ivar_set(elem, ID_at_enc, ENCODING_NAME_BINARY);
+ } else {
+ rb_enc_associate_index(elem, list_enc_idx);
+ rb_ivar_set(elem, ID_at_enc, list_ivar_enc);
+ }
+#endif
if (taint_flag) OBJ_TAINT(elem);
+ /* RARRAY(ary)->ptr[idx] = elem; */
rb_ary_push(ary, elem);
}
+ /* RARRAY(ary)->len = objc; */
+
if (old_gc == Qfalse) rb_gc_enable();
rb_thread_critical = thr_crit_bup;
@@ -7784,8 +9032,11 @@ lib_split_tklist_core(ip_obj, list_str)
elem = rb_str_new2(argv[idx]);
}
/* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
- rb_ary_push(ary, elem);
+ /* RARRAY(ary)->ptr[idx] = elem; */
+ rb_ary_push(ary, elem)
}
+ /* RARRAY(ary)->len = argc; */
+
if (old_gc == Qfalse) rb_gc_enable();
#endif
}
@@ -7833,7 +9084,11 @@ lib_merge_tklist(argc, argv, obj)
old_gc = rb_gc_disable();
/* based on Tcl/Tk's Tcl_Merge() */
- flagPtr = ALLOC_N(int, argc);
+ /* flagPtr = ALLOC_N(int, argc); */
+ flagPtr = (int *)ckalloc(sizeof(int) * argc);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)flagPtr); /* XXXXXXXXXX */
+#endif
/* pass 1 */
len = 1;
@@ -7841,7 +9096,7 @@ lib_merge_tklist(argc, argv, obj)
if (OBJ_TAINTED(argv[num])) taint_flag = 1;
dst = StringValuePtr(argv[num]);
#if TCL_MAJOR_VERSION >= 8
- len += Tcl_ScanCountedElement(dst, RSTRING_LEN(argv[num]),
+ len += Tcl_ScanCountedElement(dst, RSTRING_LEN(argv[num]),
&flagPtr[num]) + 1;
#else /* TCL_MAJOR_VERSION < 8 */
len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
@@ -7849,7 +9104,11 @@ lib_merge_tklist(argc, argv, obj)
}
/* pass 2 */
+ /* result = (char *)Tcl_Alloc(len); */
result = (char *)ckalloc(len);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)result);
+#endif
dst = result;
for(num = 0; num < argc; num++) {
#if TCL_MAJOR_VERSION >= 8
@@ -7869,12 +9128,30 @@ lib_merge_tklist(argc, argv, obj)
dst[-1] = 0;
}
- free(flagPtr);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)flagPtr, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)flagPtr);
+#else
+ /* free(flagPtr); */
+ ckfree((char*)flagPtr);
+#endif
+#endif
/* create object */
str = rb_str_new(result, dst - result - 1);
if (taint_flag) OBJ_TAINT(str);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)result, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)result); /* XXXXXXXXXXX */
+#else
+ /* Tcl_Free(result); */
ckfree(result);
+#endif
+#endif
if (old_gc == Qfalse) rb_gc_enable();
rb_thread_critical = thr_crit_bup;
@@ -7919,17 +9196,15 @@ lib_conv_listelement(self, src)
return dst;
}
-
static VALUE
lib_getversion(self)
VALUE self;
{
- int major, minor, patchlevel, type;
volatile VALUE type_name;
- Tcl_GetVersion(&major, &minor, &patchlevel, &type);
+ set_tcltk_version();
- switch(type) {
+ switch(tcltk_version.type) {
case TCL_ALPHA_RELEASE:
type_name = rb_str_new2("alpha");
break;
@@ -7943,9 +9218,10 @@ lib_getversion(self)
type_name = rb_str_new2("unknown");
}
- return rb_ary_new3(5, INT2NUM(major), INT2NUM(minor),
- INT2NUM(type), type_name,
- INT2NUM(patchlevel));
+ return rb_ary_new3(5, INT2NUM(tcltk_version.major),
+ INT2NUM(tcltk_version.minor),
+ INT2NUM(tcltk_version.type), type_name,
+ INT2NUM(tcltk_version.patchlevel));
}
@@ -7970,6 +9246,7 @@ tcltklib_compile_info()
+ strlen("unknown tcl_threads");
info = ALLOC_N(char, size);
+ /* info = ckalloc(sizeof(char) * size); */ /* SEGV */
sprintf(info, form,
TCLTKLIB_RELEASE_DATE,
@@ -8005,10 +9282,527 @@ tcltklib_compile_info()
ret = rb_obj_freeze(rb_str_new2(info));
free(info);
+ /* ckfree(info); */
return ret;
}
+
+/*###############################################*/
+
+static VALUE
+create_dummy_encoding_for_tk_core(interp, name, error_mode)
+ VALUE interp;
+ VALUE name;
+ VALUE error_mode;
+{
+ struct tcltkip *ptr = get_ip(interp);
+
+ rb_secure(4);
+
+ StringValue(name);
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+ if (Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(name)) == (Tcl_Encoding)NULL) {
+ if (RTEST(error_mode)) {
+ rb_raise(rb_eArgError, "invalid Tk encoding name '%s'",
+ RSTRING_PTR(name));
+ } else {
+ return Qnil;
+ }
+ }
+#endif
+
+#ifdef RUBY_VM
+ if (RTEST(rb_define_dummy_encoding(RSTRING_PTR(name)))) {
+ int idx = rb_enc_find_index(StringValueCStr(name));
+ return rb_enc_from_encoding(rb_enc_from_index(idx));
+ } else {
+ if (RTEST(error_mode)) {
+ rb_raise(rb_eRuntimeError, "fail to create dummy encoding for '%s'",
+ RSTRING_PTR(name));
+ } else {
+ return Qnil;
+ }
+ }
+#else
+ return name;
+#endif
+}
+static VALUE
+create_dummy_encoding_for_tk(interp, name)
+ VALUE interp;
+ VALUE name;
+{
+ return create_dummy_encoding_for_tk_core(interp, name, Qtrue);
+}
+
+
+#ifdef RUBY_VM
+static int
+update_encoding_table(table, interp, error_mode)
+ VALUE table;
+ VALUE interp;
+ VALUE error_mode;
+{
+ struct tcltkip *ptr;
+ int retry = 0;
+ int i, idx, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+ volatile VALUE encname = Qnil;
+ volatile VALUE encobj = Qnil;
+
+ /* interpreter check */
+ if (NIL_P(interp)) return 0;
+ ptr = get_ip(interp);
+ if (ptr == (struct tcltkip *) NULL) return 0;
+ if (deleted_ip(ptr)) return 0;
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list,
+ &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ /* rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names");*/
+ return 0;
+ }
+
+ /* check each encoding name */
+ for(i = 0; i < objc; i++) {
+ encname = rb_str_new2(Tcl_GetString(objv[i]));
+ if (NIL_P(rb_hash_lookup(table, encname))) {
+ /* new Tk encoding -> add to table */
+ idx = rb_enc_find_index(StringValueCStr(encname));
+ if (idx < 0) {
+ encobj = create_dummy_encoding_for_tk_core(interp,encname,error_mode);
+ } else {
+ encobj = rb_enc_from_encoding(rb_enc_from_index(idx));
+ }
+ encname = rb_obj_freeze(encname);
+ rb_hash_aset(table, encname, encobj);
+ if (!NIL_P(encobj) && NIL_P(rb_hash_lookup(table, encobj))) {
+ rb_hash_aset(table, encobj, encname);
+ }
+ retry = 1;
+ }
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ return retry;
+}
+
+static VALUE
+encoding_table_get_name_core(table, enc_arg, error_mode)
+ VALUE table;
+ VALUE enc_arg;
+ VALUE error_mode;
+{
+ volatile VALUE enc = enc_arg;
+ volatile VALUE name = Qnil;
+ volatile VALUE tmp = Qnil;
+ volatile VALUE interp = rb_ivar_get(table, ID_at_interp);
+ struct tcltkip *ptr = (struct tcltkip *) NULL;
+ int idx;
+
+ /* deleted interp ? */
+ if (!NIL_P(interp)) {
+ ptr = get_ip(interp);
+ if (deleted_ip(ptr)) {
+ ptr = (struct tcltkip *) NULL;
+ }
+ }
+
+ /* encoding argument check */
+ /* 1st: default encoding setting of interp */
+ if (ptr && NIL_P(enc)) {
+ if (rb_respond_to(interp, ID_encoding_name)) {
+ enc = rb_funcall(interp, ID_encoding_name, 0, 0);
+ }
+ }
+ /* 2nd: encoding system of Tcl/Tk */
+ if (NIL_P(enc)) {
+ enc = rb_str_new2(Tcl_GetEncodingName((Tcl_Encoding)NULL));
+ }
+ /* 3rd: Encoding.default_external */
+ if (NIL_P(enc)) {
+ enc = rb_enc_default_external();
+ }
+
+ if (RTEST(rb_obj_is_kind_of(enc, cRubyEncoding))) {
+ /* Ruby's Encoding object */
+ name = rb_hash_lookup(table, enc);
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+
+ /* is it new ? */
+ /* update check of Tk encoding names */
+ if (update_encoding_table(table, interp, error_mode)) {
+ /* add new relations to the table */
+ /* RETRY: registered Ruby encoding? */
+ name = rb_hash_lookup(table, enc);
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+ }
+ /* fail to find */
+
+ } else {
+ /* String or Symbol? */
+ name = rb_funcall(enc, ID_to_s, 0, 0);
+
+ if (!NIL_P(rb_hash_lookup(table, name))) {
+ /* find */
+ return name;
+ }
+
+ /* is it new ? */
+ idx = rb_enc_find_index(StringValueCStr(name));
+ if (idx >= 0) {
+ enc = rb_enc_from_encoding(rb_enc_from_index(idx));
+
+ /* registered Ruby encoding? */
+ tmp = rb_hash_lookup(table, enc);
+ if (!NIL_P(tmp)) {
+ /* find */
+ return tmp;
+ }
+
+ /* update check of Tk encoding names */
+ if (update_encoding_table(table, interp, error_mode)) {
+ /* add new relations to the table */
+ /* RETRY: registered Ruby encoding? */
+ tmp = rb_hash_lookup(table, enc);
+ if (!NIL_P(tmp)) {
+ /* find */
+ return tmp;
+ }
+ }
+ }
+ /* fail to find */
+ }
+
+ if (RTEST(error_mode)) {
+ enc = rb_funcall(enc_arg, ID_to_s, 0, 0);
+ rb_raise(rb_eArgError, "unsupported Tk encoding '%s'", RSTRING_PTR(enc));
+ }
+ return Qnil;
+}
+static VALUE
+encoding_table_get_obj_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ volatile VALUE obj = Qnil;
+
+ obj = rb_hash_lookup(table,
+ encoding_table_get_name_core(table, enc, error_mode));
+ if (RTEST(rb_obj_is_kind_of(obj, cRubyEncoding))) {
+ return obj;
+ } else {
+ return Qnil;
+ }
+}
+
+#else /* ! RUBY_VM */
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+static int
+update_encoding_table(table, interp, error_mode)
+ VALUE table;
+ VALUE interp;
+ VALUE error_mode;
+{
+ struct tcltkip *ptr;
+ int retry = 0;
+ int i, idx, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+ volatile VALUE encname = Qnil;
+ volatile VALUE encobj = Qnil;
+
+ /* interpreter check */
+ if (NIL_P(interp)) return 0;
+ ptr = get_ip(interp);
+ if (ptr == (struct tcltkip *) NULL) return 0;
+ if (deleted_ip(ptr)) return 0;
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list, &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ /* rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names"); */
+ return 0;
+ }
+
+ /* get encoding name and set it to table */
+ for(i = 0; i < objc; i++) {
+ encname = rb_str_new2(Tcl_GetString(objv[i]));
+ if (NIL_P(rb_hash_lookup(table, encname))) {
+ /* new Tk encoding -> add to table */
+ encname = rb_obj_freeze(encname);
+ rb_hash_aset(table, encname, encname);
+ retry = 1;
+ }
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ return retry;
+}
+
+static VALUE
+encoding_table_get_name_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ volatile VALUE name = Qnil;
+ int retry = 0;
+
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ name = rb_hash_lookup(table, enc);
+
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+
+ /* update check */
+ if (update_encoding_table(table, rb_ivar_get(table, ID_at_interp),
+ error_mode)) {
+ /* add new relations to the table */
+ /* RETRY: registered Ruby encoding? */
+ name = rb_hash_lookup(table, enc);
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+ }
+
+ if (RTEST(error_mode)) {
+ rb_raise(rb_eArgError, "unsupported Tk encoding '%s'", RSTRING_PTR(enc));
+ }
+ return Qnil;
+}
+static VALUE
+encoding_table_get_obj_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ return encoding_table_get_name_core(table, enc, error_mode);
+}
+
+#else /* Tcl/Tk 7.x or 8.0 */
+static VALUE
+encoding_table_get_name_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ return Qnil;
+}
+static VALUE
+encoding_table_get_obj_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ return Qnil;
+}
+#endif /* end of dependency for the version of Tcl/Tk */
+#endif
+
+static VALUE
+encoding_table_get_name(table, enc)
+ VALUE table;
+ VALUE enc;
+{
+ return encoding_table_get_name_core(table, enc, Qtrue);
+}
+static VALUE
+encoding_table_get_obj(table, enc)
+ VALUE table;
+ VALUE enc;
+{
+ return encoding_table_get_obj_core(table, enc, Qtrue);
+}
+
+#ifdef RUBY_VM
+static VALUE
+create_encoding_table(interp)
+ VALUE interp;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ volatile VALUE table = rb_hash_new();
+ volatile VALUE encname = Qnil;
+ volatile VALUE encobj = Qnil;
+ int i, idx, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+
+ rb_secure(4);
+
+ /* set 'binary' encoding */
+ encobj = rb_enc_from_encoding(rb_enc_from_index(ENCODING_INDEX_BINARY));
+ rb_hash_aset(table, ENCODING_NAME_BINARY, encobj);
+ rb_hash_aset(table, encobj, ENCODING_NAME_BINARY);
+
+
+ /* Tcl stub check */
+ tcl_stubs_check();
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list, &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names");
+ }
+
+ /* get encoding name and set it to table */
+ for(i = 0; i < objc; i++) {
+ int name2obj, obj2name;
+
+ name2obj = 1; obj2name = 1;
+ encname = rb_obj_freeze(rb_str_new2(Tcl_GetString(objv[i])));
+ idx = rb_enc_find_index(StringValueCStr(encname));
+ if (idx < 0) {
+ /* fail to find ruby encoding -> check known encoding */
+ if (strcmp(RSTRING_PTR(encname), "identity") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = ENCODING_INDEX_BINARY;
+
+ } else if (strcmp(RSTRING_PTR(encname), "shiftjis") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = rb_enc_find_index("Shift_JIS");
+
+ } else if (strcmp(RSTRING_PTR(encname), "unicode") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = ENCODING_INDEX_UTF8;
+
+ } else if (strcmp(RSTRING_PTR(encname), "symbol") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = rb_enc_find_index("ASCII-8BIT");
+
+ } else {
+ /* regist dummy encoding */
+ name2obj = 1; obj2name = 1;
+ }
+ }
+
+ if (idx < 0) {
+ /* unknown encoding -> create dummy */
+ encobj = create_dummy_encoding_for_tk(interp, encname);
+ } else {
+ encobj = rb_enc_from_encoding(rb_enc_from_index(idx));
+ }
+
+ if (name2obj) {
+ DUMP2("create_encoding_table: name2obj: %s", RSTRING_PTR(encname));
+ rb_hash_aset(table, encname, encobj);
+ }
+ if (obj2name) {
+ DUMP2("create_encoding_table: obj2name: %s", RSTRING_PTR(encname));
+ rb_hash_aset(table, encobj, encname);
+ }
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ rb_ivar_set(table, ID_at_interp, interp);
+ rb_ivar_set(interp, ID_encoding_table, table);
+
+ return table;
+}
+
+#else /* ! RUBY_VM */
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+static VALUE
+create_encoding_table(interp)
+ VALUE interp;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ volatile VALUE table = rb_hash_new();
+ volatile VALUE encname = Qnil;
+ int i, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+
+ rb_secure(4);
+
+ /* set 'binary' encoding */
+ rb_hash_aset(table, ENCODING_NAME_BINARY, ENCODING_NAME_BINARY);
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list, &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names");
+ }
+
+ /* get encoding name and set it to table */
+ for(i = 0; i < objc; i++) {
+ encname = rb_obj_freeze(rb_str_new2(Tcl_GetString(objv[i])));
+ rb_hash_aset(table, encname, encname);
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ rb_ivar_set(table, ID_at_interp, interp);
+ rb_ivar_set(interp, ID_encoding_table, table);
+
+ return table;
+}
+
+#else /* Tcl/Tk 7.x or 8.0 */
+static VALUE
+create_encoding_table(interp)
+ VALUE interp;
+{
+ volatile VALUE table = rb_hash_new();
+ rb_secure(4);
+ rb_ivar_set(interp, ID_encoding_table, table);
+ return table;
+}
+#endif
+#endif
+
+static VALUE
+ip_get_encoding_table(interp)
+ VALUE interp;
+{
+ volatile VALUE table = Qnil;
+
+ table = rb_ivar_get(interp, ID_encoding_table);
+
+ if (NIL_P(table)) {
+ /* initialize encoding_table */
+ table = create_encoding_table(interp);
+ rb_define_singleton_method(table, "get_name", encoding_table_get_name, 1);
+ rb_define_singleton_method(table, "get_obj", encoding_table_get_obj, 1);
+ }
+
+ return table;
+}
+
+
/*###############################################*/
/*
@@ -8047,26 +9841,29 @@ struct dummy_TkMenuRef {
char *dummy3;
};
-#if 0
+#if 0 /* was available on Tk8.0 -- Tk8.4 */
EXTERN struct dummy_TkMenuRef *TkFindMenuReferences(Tcl_Interp*, char*);
-#else
-#define MENU_HASH_KEY "tkMenus" /* based on Tk8.0 - Tk8.5b1 */
+#else /* based on Tk8.0 -- Tk8.5.0 */
+#define MENU_HASH_KEY "tkMenus"
#endif
#endif
static VALUE
-ip_make_menu_embeddable(interp, menu_path)
+ip_make_menu_embeddable_core(interp, argc, argv)
VALUE interp;
- VALUE menu_path;
+ int argc;
+ VALUE *argv;
{
#if TCL_MAJOR_VERSION >= 8
+ volatile VALUE menu_path;
struct tcltkip *ptr = get_ip(interp);
struct dummy_TkMenuRef *menuRefPtr = NULL;
XEvent event;
Tcl_HashTable *menuTablePtr;
Tcl_HashEntry *hashEntryPtr;
+ menu_path = argv[0];
StringValue(menu_path);
#if 0 /* was available on Tk8.0 -- Tk8.4 */
@@ -8104,6 +9901,7 @@ ip_make_menu_embeddable(interp, menu_path)
char *s = "normal";
/* Tcl_SetStringObj((menuRefPtr->menuPtr)->menuTypePtr, s, strlen(s));*/
(menuRefPtr->menuPtr)->menuTypePtr = Tcl_NewStringObj(s, strlen(s));
+ /* Tcl_IncrRefCount((menuRefPtr->menuPtr)->menuTypePtr); */
/* (menuRefPtr->menuPtr)->menuType = TEAROFF_MENU; */
(menuRefPtr->menuPtr)->menuType = MASTER_MENU;
}
@@ -8131,6 +9929,18 @@ ip_make_menu_embeddable(interp, menu_path)
return interp;
}
+static VALUE
+ip_make_menu_embeddable(interp, menu_path)
+ VALUE interp;
+ VALUE menu_path;
+{
+ VALUE argv[1];
+
+ argv[0] = menu_path;
+ return tk_funcall(ip_make_menu_embeddable_core, 1, argv, interp);
+}
+
+
/*###############################################*/
/*---- initialization ----*/
@@ -8152,6 +9962,22 @@ Init_tcltklib()
/* --------------------------------------------------------------- */
+#ifdef RUBY_VM
+ rb_global_variable(&cRubyEncoding);
+ cRubyEncoding = rb_const_get(rb_cObject, rb_intern("Encoding"));
+
+ ENCODING_INDEX_UTF8 = rb_enc_to_index(rb_utf8_encoding());
+ ENCODING_INDEX_BINARY = rb_enc_find_index("binary");
+#endif
+
+ rb_global_variable(&ENCODING_NAME_UTF8);
+ rb_global_variable(&ENCODING_NAME_BINARY);
+
+ ENCODING_NAME_UTF8 = rb_obj_freeze(rb_str_new2("utf-8"));
+ ENCODING_NAME_BINARY = rb_obj_freeze(rb_str_new2("binary"));
+
+ /* --------------------------------------------------------------- */
+
rb_global_variable(&eTkCallbackReturn);
rb_global_variable(&eTkCallbackBreak);
rb_global_variable(&eTkCallbackContinue);
@@ -8229,6 +10055,8 @@ Init_tcltklib()
ID_at_enc = rb_intern("@encoding");
ID_at_interp = rb_intern("@interp");
+ ID_encoding_name = rb_intern("encoding_name");
+ ID_encoding_table = rb_intern("encoding_table");
ID_stop_p = rb_intern("stop?");
ID_alive_p = rb_intern("alive?");
@@ -8262,8 +10090,10 @@ Init_tcltklib()
lib_evloop_abort_on_exc, 0);
rb_define_module_function(lib, "mainloop_abort_on_exception=",
lib_evloop_abort_on_exc_set, 1);
- rb_define_module_function(lib, "set_eventloop_window_mode",set_eventloop_window_mode,1);
- rb_define_module_function(lib, "get_eventloop_window_mode",get_eventloop_window_mode,0);
+ rb_define_module_function(lib, "set_eventloop_window_mode",
+ set_eventloop_window_mode, 1);
+ rb_define_module_function(lib, "get_eventloop_window_mode",
+ get_eventloop_window_mode, 0);
rb_define_module_function(lib, "set_eventloop_tick",set_eventloop_tick,1);
rb_define_module_function(lib, "get_eventloop_tick",get_eventloop_tick,0);
rb_define_module_function(lib, "set_no_event_wait", set_no_event_wait, 1);
@@ -8325,6 +10155,12 @@ Init_tcltklib()
/* --------------------------------------------------------------- */
+ rb_define_method(ip, "create_dummy_encoding_for_tk",
+ create_dummy_encoding_for_tk, 1);
+ rb_define_method(ip, "encoding_table", ip_get_encoding_table, 0);
+
+ /* --------------------------------------------------------------- */
+
rb_define_method(ip, "_get_variable", ip_get_variable, 2);
rb_define_method(ip, "_get_variable2", ip_get_variable2, 3);
rb_define_method(ip, "_set_variable", ip_set_variable, 3);
@@ -8384,7 +10220,11 @@ Init_tcltklib()
/* if ruby->nativethread-supprt and tcltklib->doen't,
the following will cause link-error. */
+#ifdef RUBY_VM
ruby_native_thread_p();
+#else
+ is_ruby_native_thread();
+#endif
/* --------------------------------------------------------------- */
@@ -8405,6 +10245,14 @@ Init_tcltklib()
}
/* --------------------------------------------------------------- */
+
+ /* Tcl stub check */
+ tcl_stubs_check();
+
+ Tcl_ObjType_ByteArray = Tcl_GetObjType(Tcl_ObjTypeName_ByteArray);
+ Tcl_ObjType_String = Tcl_GetObjType(Tcl_ObjTypeName_String);
+
+ /* --------------------------------------------------------------- */
}
/* eof */
diff --git a/ext/tk/tkutil/extconf.rb b/ext/tk/tkutil/extconf.rb
index 51f775619c..015bc3a45e 100644
--- a/ext/tk/tkutil/extconf.rb
+++ b/ext/tk/tkutil/extconf.rb
@@ -8,5 +8,6 @@ end
if has_tk
require 'mkmf'
have_func("rb_obj_instance_exec", "ruby.h")
+ have_func("strndup", "string.h")
create_makefile('tkutil')
end
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c
index d74f996935..00d719143b 100644
--- a/ext/tk/tkutil/tkutil.c
+++ b/ext/tk/tkutil/tkutil.c
@@ -3,16 +3,24 @@
tkutil.c -
$Author$
- $Date$
created at: Fri Nov 3 00:47:54 JST 1995
************************************************/
-#define TKUTIL_RELEASE_DATE "2006-04-06"
+#define TKUTIL_RELEASE_DATE "2008-05-23"
-#include "ruby/ruby.h"
+#include "ruby.h"
+
+#ifdef RUBY_VM /* Ruby 1.9 */
+/* #include "ruby/ruby.h" */
#include "ruby/signal.h"
#include "ruby/st.h"
+#else
+/* #include "ruby.h" */
+#include "rubysig.h"
+#include "version.h"
+#include "st.h"
+#endif
static VALUE cMethod;
@@ -26,6 +34,8 @@ static VALUE TK_None;
static VALUE cCB_SUBST;
static VALUE cSUBST_INFO;
+static VALUE ENCODING_NAME_UTF8; /* for saving GC cost */
+
static ID ID_split_tklist;
static ID ID_toUTF8;
static ID ID_fromUTF8;
@@ -383,7 +393,7 @@ ary2list(ary, enc_flag, self)
val = rb_funcall(cTclTkLib, ID_fromUTF8, 2, val, dst_enc);
rb_ivar_set(val, ID_at_enc, dst_enc);
} else {
- rb_ivar_set(val, ID_at_enc, rb_str_new2("utf-8"));
+ rb_ivar_set(val, ID_at_enc, ENCODING_NAME_UTF8);
}
return val;
} else {
@@ -476,7 +486,7 @@ ary2list2(ary, enc_flag, self)
val = rb_funcall(cTclTkLib, ID_fromUTF8, 2, val, dst_enc);
rb_ivar_set(val, ID_at_enc, dst_enc);
} else {
- rb_ivar_set(val, ID_at_enc, rb_str_new2("utf-8"));
+ rb_ivar_set(val, ID_at_enc, ENCODING_NAME_UTF8);
}
return val;
} else {
@@ -781,7 +791,11 @@ get_eval_string_core(obj, enc_flag, self)
return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self);
}
} else {
+#ifdef RUBY_VM
+ return rb_sym_to_s(obj);
+#else
return rb_str_new2(rb_id2name(SYM2ID(obj)));
+#endif
}
case T_HASH:
@@ -1059,11 +1073,13 @@ tcl2rb_num_or_str(self, value)
/*************************************/
+#define CBSUBST_TBL_MAX (256)
struct cbsubst_info {
- int size;
- char *key;
- char *type;
- ID *ivar;
+ int full_subst_length;
+ int keylen[CBSUBST_TBL_MAX];
+ unsigned char *key[CBSUBST_TBL_MAX];
+ unsigned char type[CBSUBST_TBL_MAX];
+ ID ivar[CBSUBST_TBL_MAX];
VALUE proc;
VALUE aliases;
};
@@ -1080,42 +1096,52 @@ static void
subst_free(ptr)
struct cbsubst_info *ptr;
{
+ int i;
+
if (ptr) {
- if (ptr->key != (char*)NULL) free(ptr->key);
- if (ptr->type != (char*)NULL) free(ptr->type);
- if (ptr->ivar != (ID*)NULL) free(ptr->ivar);
- free(ptr);
+ for(i = 0; i < CBSUBST_TBL_MAX; i++) {
+ if (ptr->key[i] != (unsigned char *)NULL) {
+ free(ptr->key[i]);
+ ptr->key[i] = (unsigned char *)NULL;
+ }
+ }
+ free(ptr);
}
}
-static void
-cbsubst_init()
+static struct cbsubst_info *
+allocate_cbsubst_info()
{
- struct cbsubst_info *inf;
- ID *ivar;
- volatile VALUE proc, aliases;
-
- inf = ALLOC(struct cbsubst_info);
+ struct cbsubst_info *inf;
+ volatile VALUE proc, aliases;
+ int idx;
- inf->size = 0;
+ inf = ALLOC(struct cbsubst_info);
- inf->key = ALLOC_N(char, 1);
- inf->key[0] = '\0';
+ inf->full_subst_length = 0;
- inf->type = ALLOC_N(char, 1);
- inf->type[0] = '\0';
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ inf->keylen[idx] = 0;
+ inf->key[idx] = (unsigned char *) NULL;
+ inf->type[idx] = '\0';
+ inf->ivar[idx] = (ID) 0;
+ }
- ivar = ALLOC_N(ID, 1);
- inf->ivar = ivar;
+ proc = rb_hash_new();
+ inf->proc = proc;
- proc = rb_hash_new();
- inf->proc = proc;
+ aliases = rb_hash_new();
+ inf->aliases = aliases;
- aliases = rb_hash_new();
- inf->aliases = aliases;
+ return inf;
+}
+static void
+cbsubst_init()
+{
rb_const_set(cCB_SUBST, ID_SUBST_INFO,
- Data_Wrap_Struct(cSUBST_INFO, subst_mark, subst_free, inf));
+ Data_Wrap_Struct(cSUBST_INFO, subst_mark, subst_free,
+ allocate_cbsubst_info()));
}
static VALUE
@@ -1125,24 +1151,29 @@ cbsubst_initialize(argc, argv, self)
VALUE self;
{
struct cbsubst_info *inf;
- int idx;
+ int idx, iv_idx;
Data_Get_Struct(rb_const_get(rb_obj_class(self), ID_SUBST_INFO),
struct cbsubst_info, inf);
- for(idx = 0; idx < argc; idx++) {
- rb_ivar_set(self, inf->ivar[idx], argv[idx]);
+ idx = 0;
+ for(iv_idx = 0; iv_idx < CBSUBST_TBL_MAX; iv_idx++) {
+ if ( inf->ivar[iv_idx] == (ID) 0 ) continue;
+ rb_ivar_set(self, inf->ivar[iv_idx], argv[idx++]);
+ if (idx >= argc) break;
}
return self;
}
-
static VALUE
cbsubst_ret_val(self, val)
VALUE self;
VALUE val;
{
+ /* This method may be overwritten on some sub-classes. */
+ /* This method is used for converting from ruby's callback-return-value */
+ /* to tcl's value (e.g. validation procedure of entry widget). */
return val;
}
@@ -1203,6 +1234,59 @@ cbsubst_def_attr_aliases(self, tbl)
}
static VALUE
+cbsubst_sym_to_subst(self, sym)
+ VALUE self;
+ VALUE sym;
+{
+ struct cbsubst_info *inf;
+ const char *str;
+ unsigned char *buf, *ptr;
+ int idx, len;
+ ID id;
+ volatile VALUE ret;
+
+ if (TYPE(sym) != T_SYMBOL) return sym;
+
+ Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
+ struct cbsubst_info, inf);
+
+ if (!NIL_P(ret = rb_hash_aref(inf->aliases, sym))) {
+ str = rb_id2name(SYM2ID(ret));
+ } else {
+ str = rb_id2name(SYM2ID(sym));
+ }
+
+ id = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), str)));
+
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->ivar[idx] == id) break;
+ }
+ if (idx >= CBSUBST_TBL_MAX) return sym;
+
+ ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
+
+ *(ptr++) = '%';
+
+ if (len = inf->keylen[idx]) {
+ /* longname */
+ strncpy(ptr, inf->key[idx], len);
+ ptr += len;
+ } else {
+ /* single char */
+ *(ptr++) = idx;
+ }
+
+ *(ptr++) = ' ';
+ *(ptr++) = '\0';
+
+ ret = rb_str_new2(buf);
+
+ free(buf);
+
+ return ret;
+}
+
+static VALUE
cbsubst_get_subst_arg(argc, argv, self)
int argc;
VALUE *argv;
@@ -1210,17 +1294,15 @@ cbsubst_get_subst_arg(argc, argv, self)
{
struct cbsubst_info *inf;
const char *str;
- char *buf, *ptr;
- int i, j, len;
+ unsigned char *buf, *ptr;
+ int i, idx, len;
ID id;
volatile VALUE arg_sym, ret;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf);
- buf = ALLOC_N(char, 3*argc + 1);
- ptr = buf;
- len = strlen(inf->key);
+ ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
for(i = 0; i < argc; i++) {
switch(TYPE(argv[i])) {
@@ -1242,17 +1324,25 @@ cbsubst_get_subst_arg(argc, argv, self)
id = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), str)));
- for(j = 0; j < len; j++) {
- if (inf->ivar[j] == id) break;
- }
-
- if (j >= len) {
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->ivar[idx] == id) break;
+ }
+ if (idx >= CBSUBST_TBL_MAX) {
rb_raise(rb_eArgError, "cannot find attribute :%s", str);
}
- *(ptr++) = '%';
- *(ptr++) = *(inf->key + j);
- *(ptr++) = ' ';
+ *(ptr++) = '%';
+
+ if (len = inf->keylen[idx]) {
+ /* longname */
+ strncpy(ptr, inf->key[idx], len);
+ ptr += len;
+ } else {
+ /* single char */
+ *(ptr++) = idx;
+ }
+
+ *(ptr++) = ' ';
}
*ptr = '\0';
@@ -1269,27 +1359,50 @@ cbsubst_get_subst_key(self, str)
VALUE self;
VALUE str;
{
+ struct cbsubst_info *inf;
volatile VALUE list;
volatile VALUE ret;
- int i, len;
- char *buf, *ptr;
+ VALUE keyval;
+ int i, len, keylen, idx;
+ unsigned char *buf, *ptr, *key;
list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str);
-
len = RARRAY_LEN(list);
- buf = ALLOC_N(char, len + 1);
+
+ Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
+ struct cbsubst_info, inf);
+
+ ptr = buf = ALLOC_N(unsigned char, inf->full_subst_length + len + 1);
for(i = 0; i < len; i++) {
- ptr = RSTRING_PTR(RARRAY_PTR(list)[i]);
- if (*ptr == '%' && *(ptr + 2) == '\0') {
- *(buf + i) = *(ptr + 1);
- } else {
- *(buf + i) = ' ';
- }
+ keyval = RARRAY_PTR(list)[i];
+ key = (unsigned char*)RSTRING_PTR(keyval);
+ if (*key == '%') {
+ if (*(key + 2) == '\0') {
+ /* single char */
+ *(ptr++) = *(key + 1);
+ } else {
+ /* search longname-key */
+ keylen = RSTRING_LEN(keyval) - 1;
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->keylen[idx] != keylen) continue;
+ if (inf->key[idx][0] != *(key + 1)) continue;
+ if (strncmp(inf->key[idx], key + 1, keylen)) continue;
+ break;
+ }
+ if (idx < CBSUBST_TBL_MAX) {
+ *(ptr++) = (unsigned char)idx;
+ } else {
+ *(ptr++) = ' ';
+ }
+ }
+ } else {
+ *(ptr++) = ' ';
+ }
}
- *(buf + len) = '\0';
+ *ptr = '\0';
- ret = rb_str_new2(buf);
+ ret = rb_str_new2((const char*)buf);
free(buf);
return ret;
}
@@ -1299,100 +1412,166 @@ cbsubst_get_all_subst_keys(self)
VALUE self;
{
struct cbsubst_info *inf;
- char *buf, *ptr;
- int i, len;
+ unsigned char *buf, *ptr;
+ unsigned char *keys_buf, *keys_ptr;
+ int idx, len;
volatile VALUE ret;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf);
- len = strlen(inf->key);
- buf = ALLOC_N(char, 3*len + 1);
- ptr = buf;
- for(i = 0; i < len; i++) {
- *(ptr++) = '%';
- *(ptr++) = *(inf->key + i);
- *(ptr++) = ' ';
+ ptr = buf = ALLOC_N(unsigned char, inf->full_subst_length + 1);
+ keys_ptr = keys_buf = ALLOC_N(unsigned char, CBSUBST_TBL_MAX + 1);
+
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->ivar[idx] == (ID) 0) continue;
+
+ *(keys_ptr++) = (unsigned char)idx;
+
+ *(ptr++) = '%';
+
+ if (len = inf->keylen[idx]) {
+ /* longname */
+ strncpy(ptr, inf->key[idx], len);
+ ptr += len;
+ } else {
+ /* single char */
+ *(ptr++) = (unsigned char)idx;
+ }
+
+ *(ptr++) = ' ';
}
- *(buf + 3*len) = '\0';
- ret = rb_ary_new3(2, rb_str_new2(inf->key), rb_str_new2(buf));
+ *ptr = '\0';
+ *keys_ptr = '\0';
+
+ ret = rb_ary_new3(2, rb_str_new2(keys_buf), rb_str_new2((const char*)buf));
free(buf);
+ free(keys_buf);
return ret;
}
static VALUE
-cbsubst_table_setup(self, key_inf, proc_inf)
- VALUE self;
- VALUE key_inf;
- VALUE proc_inf;
+cbsubst_table_setup(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- struct cbsubst_info *subst_inf;
- int idx;
- int len = RARRAY_LEN(key_inf);
- int real_len = 0;
- char *key = ALLOC_N(char, len + 1);
- char *type = ALLOC_N(char, len + 1);
- ID *ivar = ALLOC_N(ID, len + 1);
- volatile VALUE proc = rb_hash_new();
- volatile VALUE aliases = rb_hash_new();
- volatile VALUE inf;
-
- /* init */
- subst_inf = ALLOC(struct cbsubst_info);
- /* subst_inf->size = len; */
- subst_inf->key = key;
- subst_inf->type = type;
- subst_inf->ivar = ivar;
- subst_inf->proc = proc;
- subst_inf->aliases = aliases;
-
- /*
- * keys : array of [subst, type, ivar]
- * subst ==> char code
- * type ==> char code
- * ivar ==> symbol
- */
- for(idx = 0; idx < len; idx++) {
- inf = RARRAY_PTR(key_inf)[idx];
- if (TYPE(inf) != T_ARRAY) continue;
- *(key + real_len) = NUM2CHR(RARRAY_PTR(inf)[0]);
- *(type + real_len) = NUM2CHR(RARRAY_PTR(inf)[1]);
-
- *(ivar + real_len)
- = rb_intern(
- RSTRING_PTR(
- rb_str_cat2(rb_str_new2("@"),
- rb_id2name(SYM2ID(RARRAY_PTR(inf)[2])))
- )
- );
-
- rb_attr(self, SYM2ID(RARRAY_PTR(inf)[2]), 1, 0, Qtrue);
- real_len++;
+ volatile VALUE key_inf;
+ volatile VALUE longkey_inf;
+ volatile VALUE proc_inf;
+ VALUE inf;
+ ID id;
+ struct cbsubst_info *subst_inf;
+ int idx, len;
+ unsigned char chr;
+
+ /* accept (key_inf, proc_inf) or (key_inf, longkey_inf, procinf) */
+ if (rb_scan_args(argc, argv, "21", &key_inf, &longkey_inf, &proc_inf) == 2) {
+ proc_inf = longkey_inf;
+ longkey_inf = rb_ary_new();
+ }
+
+ /* check the number of longkeys */
+ if (RARRAY_LEN(longkey_inf) > 125 /* from 0x80 to 0xFD */) {
+ rb_raise(rb_eArgError, "too many longname-key definitions");
+ }
+
+ /* init */
+ subst_inf = allocate_cbsubst_info();
+
+ /*
+ * keys : array of [subst, type, ivar]
+ * subst ==> char code or string
+ * type ==> char code or string
+ * ivar ==> symbol
+ */
+ len = RARRAY_LEN(key_inf);
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY_PTR(key_inf)[idx];
+ if (TYPE(inf) != T_ARRAY) continue;
+
+ if (TYPE(RARRAY_PTR(inf)[0]) == T_STRING) {
+ chr = *(RSTRING_PTR(RARRAY_PTR(inf)[0]));
+ } else {
+ chr = NUM2CHR(RARRAY_PTR(inf)[0]);
}
- *(key + real_len) = '\0';
- *(type + real_len) = '\0';
- subst_inf->size = real_len;
-
- /*
- * procs : array of [type, proc]
- * type ==> char code
- * proc ==> proc/method/obj (must respond to 'call')
- */
- len = RARRAY_LEN(proc_inf);
- for(idx = 0; idx < len; idx++) {
- inf = RARRAY_PTR(proc_inf)[idx];
- if (TYPE(inf) != T_ARRAY) continue;
- rb_hash_aset(proc, RARRAY_PTR(inf)[0], RARRAY_PTR(inf)[1]);
+ if (TYPE(RARRAY_PTR(inf)[1]) == T_STRING) {
+ subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1]));
+ } else {
+ subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
}
- rb_const_set(self, ID_SUBST_INFO,
- Data_Wrap_Struct(cSUBST_INFO, subst_mark,
- subst_free, subst_inf));
+ subst_inf->full_subst_length += 3;
- return self;
+ id = SYM2ID(RARRAY_PTR(inf)[2]);
+ subst_inf->ivar[chr] = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), rb_id2name(id))));
+
+ rb_attr(self, id, 1, 0, Qtrue);
+ }
+
+
+ /*
+ * longkeys : array of [name, type, ivar]
+ * name ==> longname key string
+ * type ==> char code or string
+ * ivar ==> symbol
+ */
+ len = RARRAY_LEN(longkey_inf);
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY_PTR(longkey_inf)[idx];
+ if (TYPE(inf) != T_ARRAY) continue;
+
+ chr = (unsigned char)(0x80 + idx);
+ subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]);
+#if HAVE_STRNDUP
+ subst_inf->key[chr] = strndup(RSTRING_PTR(RARRAY_PTR(inf)[0]),
+ RSTRING_LEN(RARRAY_PTR(inf)[0]));
+#else
+ subst_inf->key[chr] = malloc(RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1);
+ if (subst_inf->key[chr]) {
+ strncpy(subst_inf->key[chr], RSTRING_PTR(RARRAY_PTR(inf)[0]),
+ RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1);
+ subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0';
+ }
+#endif
+ if (TYPE(RARRAY_PTR(inf)[1]) == T_STRING) {
+ subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1]));
+ } else {
+ subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
+ }
+
+ subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2);
+
+ id = SYM2ID(RARRAY_PTR(inf)[2]);
+ subst_inf->ivar[chr] = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), rb_id2name(id))));
+
+ rb_attr(self, id, 1, 0, Qtrue);
+ }
+
+ /*
+ * procs : array of [type, proc]
+ * type ==> char code or string
+ * proc ==> proc/method/obj (must respond to 'call')
+ */
+ len = RARRAY_LEN(proc_inf);
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY_PTR(proc_inf)[idx];
+ if (TYPE(inf) != T_ARRAY) continue;
+ rb_hash_aset(subst_inf->proc,
+ ((TYPE(RARRAY_PTR(inf)[0]) == T_STRING)?
+ INT2FIX(*(RSTRING_PTR(RARRAY_PTR(inf)[0]))) :
+ RARRAY_PTR(inf)[0]),
+ RARRAY_PTR(inf)[1]);
+ }
+
+ rb_const_set(self, ID_SUBST_INFO,
+ Data_Wrap_Struct(cSUBST_INFO, subst_mark,
+ subst_free, subst_inf));
+
+ return self;
}
static VALUE
@@ -1410,10 +1589,11 @@ cbsubst_scan_args(self, arg_key, val_ary)
{
struct cbsubst_info *inf;
int idx;
- int len = RARRAY_LEN(val_ary);
- char c;
- char *ptr;
- volatile VALUE dst = rb_ary_new2(len);
+ unsigned char *keyptr = (unsigned char*)RSTRING_PTR(arg_key);
+ int keylen = RSTRING_LEN(arg_key);
+ int vallen = RARRAY_LEN(val_ary);
+ unsigned char type_chr;
+ volatile VALUE dst = rb_ary_new2(vallen);
volatile VALUE proc;
int thr_crit_bup;
VALUE old_gc;
@@ -1426,26 +1606,25 @@ cbsubst_scan_args(self, arg_key, val_ary)
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf);
- for(idx = 0; idx < len; idx++) {
- if (idx >= RSTRING_LEN(arg_key)) {
- proc = Qnil;
- } else if (*(RSTRING_PTR(arg_key) + idx) == ' ') {
- proc = Qnil;
- } else {
- ptr = strchr(inf->key, *(RSTRING_PTR(arg_key) + idx));
- if (ptr == (char*)NULL) {
- proc = Qnil;
- } else {
- c = *(inf->type + (ptr - inf->key));
- proc = rb_hash_aref(inf->proc, INT2FIX(c));
- }
- }
-
- if (NIL_P(proc)) {
- rb_ary_push(dst, RARRAY_PTR(val_ary)[idx]);
- } else {
- rb_ary_push(dst, rb_funcall(proc, ID_call, 1, RARRAY_PTR(val_ary)[idx]));
- }
+ for(idx = 0; idx < vallen; idx++) {
+ if (idx >= keylen) {
+ proc = Qnil;
+ } else if (*(keyptr + idx) == ' ') {
+ proc = Qnil;
+ } else {
+ if (type_chr = inf->type[*(keyptr + idx)]) {
+ proc = rb_hash_aref(inf->proc, INT2FIX((int)type_chr));
+ } else {
+ proc = Qnil;
+ }
+ }
+
+ if (NIL_P(proc)) {
+ rb_ary_push(dst, RARRAY_PTR(val_ary)[idx]);
+ } else {
+ rb_ary_push(dst, rb_funcall(proc, ID_call, 1,
+ RARRAY_PTR(val_ary)[idx]));
+ }
}
if (old_gc == Qfalse) rb_gc_enable();
@@ -1486,6 +1665,7 @@ tkobj_path(self)
return rb_ivar_get(self, ID_at_path);
}
+
/*************************************/
/* release date */
const char tkutil_release_date[] = TKUTIL_RELEASE_DATE;
@@ -1528,6 +1708,8 @@ Init_tkutil()
ID_SUBST_INFO = rb_intern("SUBST_INFO");
rb_define_singleton_method(cCB_SUBST, "ret_val", cbsubst_ret_val, 1);
rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2);
+ rb_define_singleton_method(cCB_SUBST, "_sym2subst",
+ cbsubst_sym_to_subst, 1);
rb_define_singleton_method(cCB_SUBST, "subst_arg",
cbsubst_get_subst_arg, -1);
rb_define_singleton_method(cCB_SUBST, "_get_subst_key",
@@ -1535,7 +1717,7 @@ Init_tkutil()
rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys",
cbsubst_get_all_subst_keys, 0);
rb_define_singleton_method(cCB_SUBST, "_setup_subst_table",
- cbsubst_table_setup, 2);
+ cbsubst_table_setup, -1);
rb_define_singleton_method(cCB_SUBST, "_get_extra_args_tbl",
cbsubst_get_extra_args_tbl, 0);
rb_define_singleton_method(cCB_SUBST, "_define_attribute_aliases",
@@ -1610,4 +1792,8 @@ Init_tkutil()
rb_define_method(mTK, "num_or_str", tcl2rb_num_or_str, 1);
/* --------------------- */
+ rb_global_variable(&ENCODING_NAME_UTF8);
+ ENCODING_NAME_UTF8 = rb_obj_freeze(rb_str_new2("utf-8"));
+
+ /* --------------------- */
}
diff --git a/ext/win32ole/doc/win32ole.rd b/ext/win32ole/doc/win32ole.rd
new file mode 100644
index 0000000000..c563ce5d5b
--- /dev/null
+++ b/ext/win32ole/doc/win32ole.rd
@@ -0,0 +1,294 @@
+=begin
+= Win32OLE extension module
+
+== WIN32OLE
+=== Constants
+: VERSION
+ The version number of WIN32OLE.
+
+: ARGV
+ The argument of the method invoked recently.
+ This constant is used to get value of argument
+ when the argument is passed by reference.
+
+=== Class Method
+: connect(oleserver)
+ returns running OLE automation object or WIN32OLE object from moniker.
+
+: const_load(ole [,obj])
+ defines the constants of OLE automation
+ server as 'obj' class constants. If 'obj' omitted, the default
+ is WIN32OLE.
+
+: new(oleserver)
+ returns OLE Automation object.
+
+: ole_free(obj)
+ invokes Release method of Dispatch interface of WIN32OLE object.
+ This method should not be used because this method exists for debugging WIN32OLE.
+
+: ole_reference_count(obj)
+ returns reference counter of Dispatch interface.
+ This method should not be used because this method exists for debugging WIN32OLE.
+
+: ole_show_help(info [,helpcontext])
+ displays helpfile.
+ The first argument specifies WIN32OLE_TYPE object or WIN32OLE_METHOD object
+ or helpfile.
+
+=== Method
+: self[property]
+ gets property of OLE object.
+
+: self[property]=
+ sets property of OLE object.
+
+: _invoke(dispid, args, types)
+ runs the early binding method.
+ The dispid specifies Dispatch ID, args specifies the array of arguments,
+ types specifies array of the type of arguments.
+
+: each {...}
+ Iterates over each item of OLE collection which has IEnumVARIANT
+ interface.
+
+: invoke(method, args,...)
+ runs OLE method.
+
+: ole_func_methods
+ returns array of WIN32OLE_METHOD object which corresponds with function.
+
+: ole_get_methods
+ returns array of WIN32OLE_METHOD object which corresponds with get properties.
+
+: ole_method(method)
+ returns WIN32OLE_METHOD object which coreesponds with method
+ which specified by argument.
+
+: ole_method_help(method)
+ alias of ole_method.
+
+: ole_methods
+ returns WIN32OLE_METHOD object which coreesponds with method.
+
+: ole_obj_help
+ returns WIN32OLE_TYPE object.
+
+: ole_put_methods
+ returns array of WIN32OLE_METHOD object which corresponds with put properties.
+
+: setproperty(property, key, val)
+ set property of OLE object.
+ This method is used when the property has argument.
+
+ For example, in VB
+ obj.item("key") = val
+ in Win32OLE
+ obj.setproperty("item", "key", val)
+
+
+== WIN32OLE_EVENT class
+
+=== Class Method
+
+: new(ole, interface)
+ The new class method creates OLE event sink object to connect ole.
+ The ole must be WIN32OLE object, and interface is the interface
+ name of event.
+
+: message_loop
+ The message_loop class method translates and dispatches Windows
+ message.
+
+=== Method
+: on_event([event]){...}
+ defines the callback of event.
+ If event omitted, defines the callback of all events.
+
+: on_event_with_outargs([event]) {...}
+ defines the callback of event.
+ If you want modify argument in callback,
+
+== WIN32OLE_METHOD
+
+=== Class Methods
+: new(win32ole_type, method)
+ creates WIN32OLE_METHOD object.
+
+=== Methods
+: dispid
+ returns Dispatch ID.
+
+: event?
+ returns true if the method is event.
+
+: event_interface
+ returns interface name of event if the method is event.
+
+: helpcontext
+ returns help context.
+
+: helpfile
+ returns help file.
+
+: invkind
+ returns invkind.
+
+: invoke_kind
+ returns invoke kind string.
+
+: name
+ returns name of method.
+
+: offset_vtbl
+ returns the offset of Vtbl.
+
+: params
+ returns array of WIN32OLE_PARAM object.
+
+: return_type
+ returns string of return value type of method.
+
+: return_vtype
+ returns number of return value type of method.
+
+: return_type_detail
+ returns detail information of return value type of method.
+
+: size_params
+ returns the size of arguments.
+
+: size_opt_params
+ returns the size of optional arguments.
+
+: visible?
+ returns true if the method is public.
+
+== WIN32OLE_PARAM
+: default
+ returns default value.
+
+: input?
+ returns true if argument is input.
+
+: optional?
+ returns true if argument is optional.
+
+: output?
+ returns true if argument is output.
+
+: name
+ returns name.
+
+: ole_type
+ returns type of argument.
+
+: ole_type_detail
+ returns detail information of type of argument.
+
+: retval?
+ returns true if argument is return value.
+
+== WIN32OLE_TYPE
+=== Class Methods
+: new(typelibrary, class)
+ returns WIN32OLE_TYPE object.
+
+: ole_classes(typelibrary)
+ returns array of WIN32OLE_TYPE objects defined by Type Library.
+
+: progids
+ returns array of ProgID.
+
+: typelibs
+ returns array of type libraries.
+
+=== Methods
+: guid
+ returns GUID.
+
+: helpfile
+ returns helpfile.
+
+: helpcontext
+ returns helpcontext.
+
+: helpstring
+ returns help string.
+
+: major_version
+ returns major version.
+
+: minor_version
+ returns minor version.
+
+: name
+ returns name.
+
+: ole_methods
+ returns array of WIN32OLE_METHOD objects.
+
+: ole_type
+ returns type of class.
+
+: progid
+ returns ProgID if it exists. If not found, then returns nil.
+
+: src_type
+ returns source class when the OLE class is 'Alias'.
+
+: typekind
+ returns number which represents type.
+
+: variables
+ returns array of variables defined in OLE class.
+
+: visible?
+ returns true if the OLE class is public.
+
+== WIN32OLE_VARIABLE
+=== Methods
+: name
+ returns the name.
+
+: ole_type
+ returns type
+
+: ole_type_detail
+ returns detail information of type.
+
+: value
+ returns value.
+
+: variable_kind
+ returns variable kind string.
+
+: varkind
+ returns the number which represents variable kind.
+
+== WIN32OLE::VARIANT
+=== Constants
+ *VT_I4
+ *VT_R4
+ *VT_R8
+ *VT_CY
+ *VT_DATE
+ *VT_BSTR
+ *VT_USERDEFINED
+ *VT_PTR
+ *VT_DISPATCH
+ *VT_ERROR
+ *VT_BOOL
+ *VT_VARIANT
+ *VT_UNKNOWN
+ *VT_I1
+ *VT_UI1
+ *VT_UI2
+ *VT_UI4
+ *VT_INT
+ *VT_UINT
+ *VT_ARRAY
+ *VT_BYREF
+
+=end
+
diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb
index de306d0578..cee922554a 100644
--- a/ext/win32ole/extconf.rb
+++ b/ext/win32ole/extconf.rb
@@ -32,7 +32,6 @@ def create_win32ole_makefile
end
end
-
case RUBY_PLATFORM
when /mswin32/
$CFLAGS += ' /W3'
diff --git a/ext/win32ole/sample/excel1.rb b/ext/win32ole/sample/excel1.rb
index 2cad84a488..e366a52839 100644
--- a/ext/win32ole/sample/excel1.rb
+++ b/ext/win32ole/sample/excel1.rb
@@ -1,33 +1,22 @@
require 'win32ole'
+#application = WIN32OLE.new('Excel.Application.5')
application = WIN32OLE.new('Excel.Application')
application.visible = TRUE
workbook = application.Workbooks.Add();
worksheet = workbook.Worksheets(1);
-
-=begin
worksheet.Range("A1:D1").value = ["North","South","East","West"];
worksheet.Range("A2:B2").value = [5.2, 10];
-
worksheet.Range("C2").value = 8;
worksheet.Range("D2").value = 20;
-=end
-worksheet.Range("A1:B2").value = [["North","South"],
- [5.2, 10]];
-
-vals = WIN32OLE_VARIANT.new([["East","West"],
- [8, 20]],
- WIN32OLE::VARIANT::VT_ARRAY)
-worksheet.Range("C1:D2").value = vals
-
range = worksheet.Range("A1:D2");
range.Select
chart = workbook.Charts.Add;
workbook.saved = TRUE;
-sleep 0.5
+
application.ActiveWorkbook.Close(0);
application.Quit();
diff --git a/ext/win32ole/sample/excel2.rb b/ext/win32ole/sample/excel2.rb
index dbe4178051..46f459b36b 100644
--- a/ext/win32ole/sample/excel2.rb
+++ b/ext/win32ole/sample/excel2.rb
@@ -9,14 +9,14 @@ excel = WIN32OLE.new("excel.application")
# Create and rotate the chart
-excel.visible = TRUE;
+excel['Visible'] = TRUE;
excel.Workbooks.Add();
-excel.Range("a1").value = 3;
-excel.Range("a2").value = 2;
-excel.Range("a3").value = 1;
+excel.Range("a1")['Value'] = 3;
+excel.Range("a2")['Value'] = 2;
+excel.Range("a3")['Value'] = 1;
excel.Range("a1:a3").Select();
excelchart = excel.Charts.Add();
-excelchart.type = ChartTypeVal;
+excelchart['Type'] = ChartTypeVal;
i = 30
i.step(180, 10) do |rot|
diff --git a/ext/win32ole/tests/oleserver.rb b/ext/win32ole/tests/oleserver.rb
new file mode 100644
index 0000000000..bf721373e5
--- /dev/null
+++ b/ext/win32ole/tests/oleserver.rb
@@ -0,0 +1,10 @@
+require 'win32ole'
+def oletypelib_name(pat)
+ WIN32OLE_TYPE.typelibs.each do |lib|
+ return lib if pat =~ lib
+ end
+end
+module OLESERVER
+ MS_EXCEL_TYPELIB = oletypelib_name(/^Microsoft Excel .* Object Library$/)
+ MS_XML_TYPELIB = oletypelib_name(/^Microsoft XML/)
+end
diff --git a/ext/win32ole/tests/testNIL2VTEMPTY.rb b/ext/win32ole/tests/testNIL2VTEMPTY.rb
new file mode 100644
index 0000000000..555d35fbf3
--- /dev/null
+++ b/ext/win32ole/tests/testNIL2VTEMPTY.rb
@@ -0,0 +1,28 @@
+# This is test script to check that WIN32OLE should convert nil to VT_EMPTY in second try.
+# [ruby-talk:137054]
+
+require 'win32ole'
+require 'test/unit'
+
+class TestNIL2VT_EMPTY < Test::Unit::TestCase
+ def setup
+ fs = WIN32OLE.new('Scripting.FileSystemObject')
+ @path = fs.GetFolder(".").path
+ end
+ def test_openSchema
+ con = nil
+ begin
+ con = WIN32OLE.new('ADODB.Connection')
+ con.connectionString = "Provider=MSDASQL;Extended Properties="
+ con.connectionString +="\"DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=#{@path}\""
+ con.open
+ rescue
+ con = nil
+ end
+ if con
+ rs = con.openSchema(4, [nil,nil,"DUMMY", "TABLE"])
+ assert(rs)
+ end
+ end
+end
+
diff --git a/ext/win32ole/tests/testOLEMETHOD.rb b/ext/win32ole/tests/testOLEMETHOD.rb
new file mode 100644
index 0000000000..390c9999f8
--- /dev/null
+++ b/ext/win32ole/tests/testOLEMETHOD.rb
@@ -0,0 +1,92 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLEMETHOD < RUNIT::TestCase
+ include OLESERVER
+ def setup
+ @excel_app = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
+ end
+ def test_s_new
+ m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
+ assert_instance_of(WIN32OLE_METHOD, m)
+ m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
+ assert_instance_of(WIN32OLE_METHOD, m)
+ m = WIN32OLE_METHOD.new(@excel_app, 'workbookopen')
+ assert_instance_of(WIN32OLE_METHOD, m)
+ end
+ def test_name
+ m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
+ assert_equal('Quit', m.name)
+ end
+ def test_to_s
+ m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
+ assert_equal('Quit', "#{m}")
+ end
+ def test_return_type
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal('Range', m.return_type)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
+ assert_equal('BSTR', m.return_type)
+ end
+ def test_return_vtype
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal(WIN32OLE::VARIANT::VT_PTR, m.return_vtype)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
+ assert_equal(WIN32OLE::VARIANT::VT_BSTR, m.return_vtype)
+ end
+ def test_return_type_detail
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal(['PTR', 'USERDEFINED', 'Range'], m.return_type_detail)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
+ assert_equal(['BSTR'], m.return_type_detail)
+ end
+
+ def test_invoke_kind
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal('PROPERTYGET', m.invoke_kind)
+ end
+ def test_visible
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert(m.visible?)
+ m = WIN32OLE_METHOD.new(@excel_app, 'AddRef')
+ assert(!m.visible?)
+ end
+ def test_event
+ m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
+ assert(m.event?)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert(!m.event?)
+ end
+ def test_event_interface
+ m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
+ assert_equal('AppEvents', m.event_interface)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_nil(m.event_interface)
+ end
+ def test_helpstring
+ domdoc = WIN32OLE_TYPE.new(MS_XML_TYPELIB, 'DOMDocument')
+ m = WIN32OLE_METHOD.new(domdoc, 'abort')
+ assert_equal('abort an asynchronous download', m.helpstring)
+ end
+ def test_helpfile
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_match(/VBAXL.*\.(HLP|CHM)$/i, m.helpfile)
+ end
+ def test_helpcontext
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert(m.helpcontext > 0)
+ end
+ def test_offset_vtbl
+ m = WIN32OLE_METHOD.new(@excel_app, 'QueryInterface')
+ assert_equal(0, m.offset_vtbl)
+ end
+ def test_dispid
+ tobj = WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation', 'FolderItem2')
+ method = WIN32OLE_METHOD.new(tobj, 'InvokeVerb')
+ assert_equal(1610743824, method.dispid)
+ end
+end
diff --git a/ext/win32ole/tests/testOLEPARAM.rb b/ext/win32ole/tests/testOLEPARAM.rb
new file mode 100644
index 0000000000..4014fadbfc
--- /dev/null
+++ b/ext/win32ole/tests/testOLEPARAM.rb
@@ -0,0 +1,65 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLEPARAM < RUNIT::TestCase
+ include OLESERVER
+ def test_name
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ sh = classes.find {|c| c.name == 'Worksheet'}
+ saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
+ param_names = saveas.params.collect{|p| p.name}
+ assert(param_names.size > 0)
+ assert(param_names.include?('Filename'))
+ end
+ def test_to_s
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ sh = classes.find {|c| c.name == 'Worksheet'}
+ saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
+ param_names = saveas.params.collect{|p| "#{p}"}
+ assert(param_names.include?('Filename'))
+ end
+ def test_ole_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal('BSTR', f.params[0].ole_type)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal('XlSaveAsAccessMode', f.params[6].ole_type)
+ end
+ def test_ole_type_detail
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal(['BSTR'], f.params[0].ole_type_detail)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal(['USERDEFINED', 'XlSaveAsAccessMode'], f.params[6].ole_type_detail)
+ end
+ def test_input
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(f.params[0].input?)
+ end
+
+ def test_output
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(!f.params[0].output?)
+ end
+ def test_optional
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(!f.params[0].optional?)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(f.params[0].optional?)
+ end
+end
diff --git a/ext/win32ole/tests/testOLETYPE.rb b/ext/win32ole/tests/testOLETYPE.rb
new file mode 100644
index 0000000000..d4eb1146e1
--- /dev/null
+++ b/ext/win32ole/tests/testOLETYPE.rb
@@ -0,0 +1,96 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLETYPE < RUNIT::TestCase
+ include OLESERVER
+ def test_s_new
+ type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
+ assert_instance_of(WIN32OLE_TYPE, type)
+ end
+ def test_s_ole_classes
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ assert(classes.size > 0)
+ end
+ def test_s_typelibs
+ libs = WIN32OLE_TYPE.typelibs
+ assert(libs.include?(MS_EXCEL_TYPELIB))
+ assert(libs.include?(MS_XML_TYPELIB))
+ end
+ def test_s_progids
+ progids = WIN32OLE_TYPE.progids
+ assert(progids.include?('Excel.Application'))
+ end
+ def test_name
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ class_names = classes.collect{|c|
+ c.name
+ }
+ assert(class_names.include?('Application'))
+ end
+
+ def test_class_to_s
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ class_names = classes.collect{|c|
+ "#{c}"
+ }
+ assert(class_names.include?('Application'))
+ end
+
+ def test_ole_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ app = classes.find {|c| c.name == 'Application'}
+ assert_equal('Class', app.ole_type)
+ app = classes.find {|c| c.name == '_Application'}
+ assert_equal('Dispatch', app.ole_type)
+ end
+ def test_typekind
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ app = classes.find {|c| c.name == 'Application'}
+ assert_equal(5, app.typekind)
+ end
+ def test_visible
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ app = classes.find {|c| c.name == 'Application'}
+ assert(app.visible?)
+ app = classes.find {|c| c.name == 'IAppEvents'}
+ assert(!app.visible?)
+ end
+ def test_src_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
+ domnode = classes.find {|c| c.name == 'DOMNodeType'}
+ assert_equal('tagDOMNodeType', domnode.src_type)
+ end
+ def test_helpstring
+ classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
+ domdoc = classes.find {|c| c.name == 'DOMDocument'}
+ assert_equal('W3C-DOM XML Document', domdoc.helpstring)
+ end
+ def test_variables
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ xlchart = classes.find {|c| c.name == 'XlChartType'}
+ assert(xlchart.variables.size > 0)
+ end
+ def test_ole_methods
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ worksheet = classes.find {|c| c.name == 'Worksheet'}
+ assert(worksheet.ole_methods.size > 0)
+ end
+ def test_helpfile
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ worksheet = classes.find {|c| c.name == 'Worksheet'}
+ assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile)
+ end
+ def test_helpcontext
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ worksheet = classes.find {|c| c.name == 'Worksheet'}
+ assert_equal(131088, worksheet.helpcontext)
+ end
+ def test_to_s
+ type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
+ assert_equal("Application", "#{type}");
+ end
+end
diff --git a/ext/win32ole/tests/testOLEVARIABLE.rb b/ext/win32ole/tests/testOLEVARIABLE.rb
new file mode 100644
index 0000000000..b4bb0b57d9
--- /dev/null
+++ b/ext/win32ole/tests/testOLEVARIABLE.rb
@@ -0,0 +1,49 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLEVARIABLE < RUNIT::TestCase
+ include OLESERVER
+ def test_name
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var_names = chart.variables.collect {|m| m.name}
+ assert(var_names.size > 0)
+ assert(var_names.include?('xl3DColumn'))
+ end
+ def test_to_s
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var_names = chart.variables.collect {|m| "#{m}"}
+ assert(var_names.size > 0)
+ assert(var_names.include?('xl3DColumn'))
+ end
+ def test_ole_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert_equal('INT', var.ole_type)
+ end
+ def test_ole_type_detail
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert_equal(['INT'], var.ole_type_detail)
+ end
+
+ def test_value
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert_equal(-4100, var.value)
+ end
+ def test_visible
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert(var.visible?)
+ end
+end
diff --git a/ext/win32ole/tests/testVARIANT.rb b/ext/win32ole/tests/testVARIANT.rb
new file mode 100644
index 0000000000..f274778f27
--- /dev/null
+++ b/ext/win32ole/tests/testVARIANT.rb
@@ -0,0 +1,32 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+
+class TestWin32OLE_VARIANT < RUNIT::TestCase
+ include WIN32OLE::VARIANT
+ def test_variant
+ assert_equal(2, VT_I2)
+ assert_equal(3, VT_I4)
+ assert_equal(4, VT_R4)
+ assert_equal(5, VT_R8)
+ assert_equal(6, VT_CY)
+ assert_equal(7, VT_DATE)
+ assert_equal(8, VT_BSTR)
+ assert_equal(9, VT_DISPATCH)
+ assert_equal(10, VT_ERROR)
+ assert_equal(11, VT_BOOL)
+ assert_equal(12, VT_VARIANT)
+ assert_equal(13, VT_UNKNOWN)
+ assert_equal(16, VT_I1)
+ assert_equal(17, VT_UI1)
+ assert_equal(18, VT_UI2)
+ assert_equal(19, VT_UI4)
+ assert_equal(22, VT_INT)
+ assert_equal(23, VT_UINT)
+ assert_equal(0x2000, VT_ARRAY)
+ assert_equal(0x4000, VT_BYREF)
+ end
+end
+
diff --git a/ext/win32ole/tests/testWIN32OLE.rb b/ext/win32ole/tests/testWIN32OLE.rb
new file mode 100644
index 0000000000..d7f9dd2543
--- /dev/null
+++ b/ext/win32ole/tests/testWIN32OLE.rb
@@ -0,0 +1,373 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'runit/testcase'
+require 'runit/cui/testrunner'
+
+require 'win32ole'
+require 'oleserver'
+
+module EXCEL_CONST
+end
+
+module CONST1
+end
+
+module CONST2
+end
+
+module CONST3
+end
+
+class TestWin32OLE < RUNIT::TestCase
+ include OLESERVER
+ def setup
+ @excel = WIN32OLE.new("Excel.Application")
+ @excel.visible = true
+ end
+ def test_s_new
+ assert_instance_of(WIN32OLE, @excel)
+ end
+ def test_s_new_DCOM
+ rexcel = WIN32OLE.new("Excel.Application", "localhost")
+ assert_instance_of(WIN32OLE, rexcel)
+ rexcel.visible = true
+ rexcel.quit
+ end
+ def test_s_new_from_clsid
+ excel = WIN32OLE.new("{00024500-0000-0000-C000-000000000046}")
+ assert_instance_of(WIN32OLE, excel)
+ excel.quit
+ exc = assert_exception(WIN32OLERuntimeError) {
+ WIN32OLE.new("{000}")
+ }
+ assert_match(/unknown OLE server: `\{000\}'/, exc.message)
+ end
+ def test_s_connect
+ excel2 = WIN32OLE.connect('Excel.Application')
+ assert_instance_of(WIN32OLE, excel2)
+ end
+
+ def test_s_const_load
+ assert(!defined?(EXCEL_CONST::XlTop))
+ WIN32OLE.const_load(@excel, EXCEL_CONST)
+ assert_equal(-4160, EXCEL_CONST::XlTop)
+
+ assert(!defined?(CONST1::XlTop))
+ WIN32OLE.const_load(MS_EXCEL_TYPELIB, CONST1)
+ assert_equal(-4160, CONST1::XlTop)
+ end
+
+ def test_s_codepage
+ assert_equal(WIN32OLE::CP_ACP, WIN32OLE.codepage)
+ end
+
+ def test_s_codepage_set
+ WIN32OLE.codepage = WIN32OLE::CP_UTF8
+ assert_equal(WIN32OLE::CP_UTF8, WIN32OLE.codepage)
+ WIN32OLE.codepage = WIN32OLE::CP_ACP
+ end
+
+ def test_const_CP_ACP
+ assert_equal(0, WIN32OLE::CP_ACP)
+ end
+
+ def test_const_CP_OEMCP
+ assert_equal(1, WIN32OLE::CP_OEMCP)
+ end
+
+ def test_const_CP_MACCP
+ assert_equal(2, WIN32OLE::CP_MACCP)
+ end
+
+ def test_const_CP_THREAD_ACP
+ assert_equal(3, WIN32OLE::CP_THREAD_ACP)
+ end
+
+ def test_const_CP_SYMBOL
+ assert_equal(42, WIN32OLE::CP_SYMBOL)
+ end
+
+ def test_const_CP_UTF7
+ assert_equal(65000, WIN32OLE::CP_UTF7)
+ end
+
+ def test_const_CP_UTF8
+ assert_equal(65001, WIN32OLE::CP_UTF8)
+ end
+
+ def test_s_codepage_changed
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ WIN32OLE.codepage = WIN32OLE::CP_UTF8
+ sheet.range("A1").value = [0x3042].pack("U*")
+ val = sheet.range("A1").value
+ assert_equal("\343\201\202", val)
+ WIN32OLE.codepage = WIN32OLE::CP_ACP
+ val = sheet.range("A1").value
+ assert_equal("\202\240", val)
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_get_win32ole_object
+ workbooks = @excel.Workbooks;
+ assert_instance_of(WIN32OLE, workbooks)
+ end
+ def test_each
+ workbooks = @excel.Workbooks
+ assert_no_exception {
+ i = 0;
+ workbooks.each do |workbook|
+ print i += 1
+ end
+ }
+ workbooks.add
+ workbooks.add
+ i = 0
+ workbooks.each do |workbook|
+ i+=1
+ end
+ assert_equal(2, i)
+ workbooks.each do |workbook|
+ workbook.saved = true
+ end
+ end
+ def test_setproperty_bracket
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.range("A1")['Value'] = 10
+ assert_equal(10, sheet.range("A1").value)
+ sheet['Cells', 1, 2] = 10
+ assert_equal(10, sheet.range("B1").value)
+ assert_equal(10, sheet['Cells', 1, 2].value)
+ ensure
+ book.saved = true
+ end
+ end
+ def test_convert_bignum
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.range("A1").value = 999999999
+ sheet.range("A2").value = 9999999999
+ sheet.range("A3").value = "=A1*10 + 9"
+ assert_equal(9999999999, sheet.range("A2").value)
+ assert_equal(9999999999, sheet.range("A3").value)
+ sheet.range("A4").value = "2008/03/04"
+ assert_equal("2008/03/04 00:00:00", sheet.range("A4").value)
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_ole_invoke_with_named_arg
+ book = @excel.workbooks.add
+ sheets = book.worksheets
+ sheet = book.worksheets(1)
+ num = sheets.count
+ begin
+ sheets.add({'count' => 2, 'after'=>sheet})
+ assert_equal(2, sheets.count - num);
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_ole_invoke_with_named_arg_last
+ book = @excel.workbooks.add
+ sheets = book.worksheets
+ sheet = book.worksheets(1)
+ num = sheets.count
+ begin
+ sheets.add(sheet, {'count' => 2})
+ assert_equal(2, sheets.count - num);
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_setproperty
+ @excel.setproperty('Visible', false)
+ assert_equal(false, @excel.Visible)
+ @excel.setproperty('Visible', true)
+ assert_equal(true, @excel.Visible)
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.setproperty('Cells', 1, 2, 10)
+ assert_equal(10, sheet.range("B1").value)
+ ensure
+ book.saved = true
+ end
+ end
+ def test_no_exist_property
+ isok = false
+ begin
+ @excel.unknown_prop = 1
+ rescue WIN32OLERuntimeError
+ isok = true
+ end
+ assert(isok)
+
+ isok = false
+ begin
+ @excel['unknown_prop'] = 2
+ rescue WIN32OLERuntimeError
+ isok = true
+ end
+ assert(isok)
+ end
+
+ def test_setproperty_with_equal
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.range("B1").value = 10
+ assert_equal(10, sheet.range("B1").value)
+ sheet.range("C1:D1").value = [11, 12]
+ assert_equal(11, sheet.range("C1").value)
+ assert_equal(12, sheet.range("D1").value)
+ ensure
+ book.saved = true
+ end
+ end
+ def test_invoke
+ workbooks = @excel.invoke( 'workbooks' )
+ assert_instance_of(WIN32OLE, workbooks)
+ book = workbooks.invoke( 'add' )
+ assert_instance_of(WIN32OLE, book)
+ end
+ def test_ole_methods
+ methods = @excel.ole_methods
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Quit"))
+ end
+ def test_ole_func_methods
+ methods = @excel.ole_func_methods
+ assert(methods.size > 0)
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Quit"))
+ end
+ def test_ole_put_methods
+ methods = @excel.ole_put_methods
+ assert(methods.size > 0)
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Visible"))
+ end
+ def test_ole_get_methods
+ methods = @excel.ole_get_methods
+ assert(methods.size > 0)
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Visible"))
+ end
+ def test_ole_method_help
+ quit_info = @excel.ole_method_help("Quit")
+ assert_equal(0, quit_info.size_params)
+ assert_equal(0, quit_info.size_opt_params)
+
+ workbooks = @excel.Workbooks
+ add_info = workbooks.ole_method_help("Add")
+ assert_equal(1, add_info.size_params)
+ assert_equal(1, add_info.size_opt_params)
+ assert(add_info.params[0].input?)
+ assert(add_info.params[0].optional?)
+ assert_equal('VARIANT', add_info.params[0].ole_type)
+ end
+ def teardown
+ @excel.quit
+ @excel = nil
+ GC.start
+ end
+end
+
+class TestWin32OLE_WITH_MSI < RUNIT::TestCase
+ def setup
+ installer = WIN32OLE.new("WindowsInstaller.Installer")
+ @record = installer.CreateRecord(2)
+ end
+
+ # Sorry, this test fails.
+ # Win32OLE does not support this style to set property.
+ # Use Win32OLE#setproperty or Win32OLE#[]= .
+ # def test_invoke
+ # @record.invoke("StringData", 1, 'cccc')
+ # assert_equal('cccc', @record.StringData(1))
+ # end
+
+ def test_setproperty
+ @record.setproperty( "StringData", 1, 'dddd')
+ assert_equal('dddd', @record.StringData(1))
+ end
+ def test_bracket_equal_with_arg
+ @record[ "StringData", 1 ] = 'ffff'
+ assert_equal('ffff', @record.StringData(1))
+ end
+
+ def test__invoke
+ shell=WIN32OLE.new('Shell.Application')
+ assert_equal(shell.NameSpace(0).title, shell._invoke(0x60020002, [0], [WIN32OLE::VARIANT::VT_VARIANT]).title)
+ end
+end
+
+# ---------------------
+#
+# a subclass of Win32OLE
+# override new() and connect()
+class MyExcel<WIN32OLE
+ def MyExcel.new
+ super "Excel.Application"
+ end
+ def MyExcel.connect
+ super "Excel.Application"
+ end
+end
+
+class TestMyExcel < TestWin32OLE
+#
+# because we overrided new() and connect()
+# we need to change the test.
+# also, because the class will be different
+#
+ def setup
+ @excel = MyExcel.new
+ @excel.visible = true
+ end
+ def test_s_new
+ assert_instance_of(MyExcel, @excel)
+ end
+ def test_s_connect
+ excel2 = MyExcel.connect
+ assert_instance_of(MyExcel, excel2)
+ end
+#
+# const_load didn't like to be called twice,
+# and I don't know how to undefine something in Ruby yet
+# so, hide the test.
+#
+ private :test_s_const_load
+end
+
+if $0 == __FILE__
+ puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
+ if ARGV.size == 0
+ suite = RUNIT::TestSuite.new
+ suite.add_test(TestWin32OLE.suite)
+ suite.add_test(TestMyExcel.suite)
+ begin
+ installer = WIN32OLE.new("WindowsInstaller.Installer")
+ suite.add_test(TestWin32OLE_WITH_MSI.suite)
+ rescue
+ puts "Skip some test with MSI"
+ end
+ else
+ suite = RUNIT::TestSuite.new
+ ARGV.each do |testmethod|
+ suite.add_test(TestWin32OLE.new(testmethod))
+ end
+ end
+ RUNIT::CUI::TestRunner.quiet_mode = true
+ RUNIT::CUI::TestRunner.run(suite)
+end
diff --git a/test/win32ole/test_ole_methods.rb b/ext/win32ole/tests/test_ole_methods.rb
index ca1c03b010..ca1c03b010 100644
--- a/test/win32ole/test_ole_methods.rb
+++ b/ext/win32ole/tests/test_ole_methods.rb
diff --git a/ext/win32ole/tests/test_propertyputref.rb b/ext/win32ole/tests/test_propertyputref.rb
new file mode 100644
index 0000000000..befc35ca9c
--- /dev/null
+++ b/ext/win32ole/tests/test_propertyputref.rb
@@ -0,0 +1,19 @@
+require 'test/unit'
+require 'win32ole'
+
+class TestWIN32OLE_PROPERTYPUTREF < Test::Unit::TestCase
+ def setup
+ begin
+ @sapi = WIN32OLE.new('SAPI.SpVoice')
+ rescue WIN32OLERuntimeError
+ @sapi = nil
+ end
+ end
+ def test_sapi
+ if @sapi
+ new_id = @sapi.getvoices.item(2).Id
+ @sapi.voice = @sapi.getvoices.item(2)
+ assert_equal(new_id, @sapi.voice.Id)
+ end
+ end
+end
diff --git a/ext/win32ole/tests/test_win32ole_event.rb b/ext/win32ole/tests/test_win32ole_event.rb
new file mode 100644
index 0000000000..744021dfd2
--- /dev/null
+++ b/ext/win32ole/tests/test_win32ole_event.rb
@@ -0,0 +1,133 @@
+begin
+ require 'win32ole'
+rescue LoadError
+end
+require 'test/unit'
+
+if defined?(WIN32OLE_EVENT)
+ class TestWIN32OLE_EVENT < Test::Unit::TestCase
+ def create_temp_html
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
+ dummy_file = fso.GetTempName + ".html"
+ cfolder = fso.getFolder(".")
+ f = cfolder.CreateTextFile(dummy_file)
+ f.writeLine("<html><body>This is test HTML file for Win32OLE.</body></html>")
+ f.close
+ dummy_path = cfolder.path + "\\" + dummy_file
+ dummy_path
+ end
+
+ def setup
+ @ie = WIN32OLE.new("InternetExplorer.Application")
+ @ie.visible = true
+ @event = ""
+ @event2 = ""
+ @event3 = ""
+ @f = create_temp_html
+ end
+
+ def default_handler(event, *args)
+ @event += event
+ end
+
+ def test_on_event
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.on_event {|*args| default_handler(*args)}
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ GC.start
+ sleep 0.1
+ end
+ assert_match(/BeforeNavigate/, @event)
+ assert_match(/NavigateComplete/, @event)
+ end
+
+ def test_on_event2
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.on_event('BeforeNavigate') {|*args| handler1}
+ ev.on_event('BeforeNavigate') {|*args| handler2}
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ end
+ assert_equal("handler2", @event2)
+ end
+
+ def test_on_event3
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.on_event {|*args| handler1}
+ ev.on_event {|*args| handler2}
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ end
+ assert_equal("handler2", @event2)
+ end
+
+ def test_on_event4
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.on_event{|*args| handler1}
+ ev.on_event{|*args| handler2}
+ ev.on_event('NavigateComplete'){|*args| handler3(*args)}
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ end
+ assert(@event3!="")
+ assert("handler2", @event2)
+ end
+
+ def test_on_event5
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.on_event {|*args| default_handler(*args)}
+ ev.on_event('NavigateComplete'){|*args| handler3(*args)}
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ end
+ assert_match(/BeforeNavigate/, @event)
+ assert(/NavigateComplete/ !~ @event)
+ assert(@event!="")
+ end
+
+ def test_unadvise
+ ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
+ ev.on_event {|*args| default_handler(*args)}
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ end
+ assert_match(/BeforeNavigate/, @event)
+ ev.unadvise
+ @event = ""
+ @ie.navigate("file:///#{@f}")
+ while @ie.busy
+ sleep 0.1
+ end
+ assert_equal("", @event);
+ assert_raise(WIN32OLERuntimeError) {
+ ev.on_event {|*args| default_handler(*args)}
+ }
+ end
+
+ def handler1
+ @event2 = "handler1"
+ end
+
+ def handler2
+ @event2 = "handler2"
+ end
+
+ def handler3(url)
+ @event3 += url
+ end
+
+ def teardown
+ @ie.quit
+ @ie = nil
+ File.unlink(@f)
+ GC.start
+ end
+ end
+end
diff --git a/ext/win32ole/tests/test_word.rb b/ext/win32ole/tests/test_word.rb
new file mode 100644
index 0000000000..53a6c521ba
--- /dev/null
+++ b/ext/win32ole/tests/test_word.rb
@@ -0,0 +1,37 @@
+#
+# This is test for [ruby-Bugs#3237]
+#
+begin
+ require 'win32ole'
+rescue LoadError
+end
+require "test/unit"
+
+if defined?(WIN32OLE)
+ class TestWIN32OLE_WITH_WORD < Test::Unit::TestCase
+
+ def setup
+ begin
+ @obj = WIN32OLE.new('Word.Application')
+ rescue WIN32OLERuntimeError
+ @obj = nil
+ end
+ end
+
+ def test_ole_methods
+ if @obj
+ @obj.visible = true
+ @obj.wordbasic.disableAutoMacros(true)
+ assert(true)
+ end
+ end
+
+ def teardown
+ if @obj
+ @obj.quit
+ @obj = nil
+ end
+ end
+
+ end
+end
diff --git a/ext/win32ole/tests/testall.rb b/ext/win32ole/tests/testall.rb
new file mode 100644
index 0000000000..553ce88509
--- /dev/null
+++ b/ext/win32ole/tests/testall.rb
@@ -0,0 +1,16 @@
+require 'rubyunit'
+require 'win32ole'
+puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
+# RUNIT::CUI::TestRunner.quiet_mode = true
+require "testWIN32OLE"
+require "testOLETYPE"
+require "testOLEPARAM"
+require "testOLEMETHOD"
+require "testOLEVARIABLE"
+require "testVARIANT"
+require "testNIL2VTEMPTY"
+require "test_ole_methods.rb"
+require "test_propertyputref.rb"
+require "test_word.rb"
+require "test_win32ole_event.rb"
+# require "testOLEEVENT"
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 09e21b4b82..ae0066ffc9 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -16,14 +16,12 @@
modified for win32ole (ruby) by Masaki.Suketa <masaki.suketa@nifty.ne.jp>
*/
-#include "ruby/ruby.h"
-#include "ruby/st.h"
-#include <ctype.h>
+#include "ruby.h"
+#include "st.h"
#include <windows.h>
#include <ocidl.h>
#include <olectl.h>
#include <ole2.h>
-#include <stdlib.h>
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
@@ -31,6 +29,7 @@
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
+#include <objidl.h>
#define DOUT fprintf(stderr,"[%d]\n",__LINE__)
#define DOUTS(x) fprintf(stderr,"[%d]:" #x "=%s\n",__LINE__,x)
@@ -55,30 +54,6 @@
#define V_BOOL(X) V_UNION(X,boolVal)
#endif
-#ifndef V_I1REF
-#define V_I1REF(X) V_UNION(X, pcVal)
-#endif
-
-#ifndef U_UI2REF
-#define V_UI2REF(X) V_UNION(X, puiVal)
-#endif
-
-#ifndef V_INT
-#define V_INT(X) V_UNION(X, intVal)
-#endif
-
-#ifndef V_INTREF
-#define V_INTREF(X) V_UNION(X, pintVal)
-#endif
-
-#ifndef V_UINT
-#define V_UINT(X) V_UNION(X, uintVal)
-#endif
-
-#ifndef V_UINTREF
-#define V_UINTREF(X) V_UNION(X, puintVal)
-#endif
-
#define OLE_RELEASE(X) (X) ? ((X)->lpVtbl->Release(X)) : 0
#define OLE_ADDREF(X) (X) ? ((X)->lpVtbl->AddRef(X)) : 0
@@ -87,7 +62,7 @@
#define OLE_RELEASE_TYPEATTR(X, Y) ((X)->lpVtbl->ReleaseTypeAttr((X), (Y)))
#define OLE_FREE(x) {\
- if(g_ole_initialized == TRUE) {\
+ if(gOLEInitialized == Qtrue) {\
if(x) {\
OLE_RELEASE(x);\
(x) = 0;\
@@ -102,28 +77,15 @@
}\
}
-#ifdef HAVE_LONG_LONG
-#define I8_2_NUM LL2NUM
-#define UI8_2_NUM ULL2NUM
-#define NUM2I8 NUM2LL
-#define NUM2UI8 NUM2ULL
-#else
-#define I8_2_NUM INT2NUM
-#define UI8_2_NUM UINT2NUM
-#define NUM2I8 NUM2INT
-#define NUM2UI8 NUM2UINT
-#endif
-
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "1.1.2"
+#define WIN32OLE_VERSION "0.7.6"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
typedef HWND (WINAPI FNHTMLHELP)(HWND hwndCaller, LPCSTR pszFile,
UINT uCommand, DWORD dwData);
-typedef BOOL (FNENUMSYSEMCODEPAGES) (CODEPAGE_ENUMPROC, DWORD);
typedef struct {
struct IEventSinkVtbl * lpVtbl;
} IEventSink, *PEVENTSINK;
@@ -170,36 +132,34 @@ typedef struct tagIEVENTSINKOBJ {
DWORD m_cRef;
IID m_iid;
int m_event_id;
+ DWORD m_dwCookie;
+ IConnectionPoint *pConnectionPoint;
ITypeInfo *pTypeInfo;
+ int *ptr_freed;
}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
VALUE cWIN32OLE;
-VALUE cWIN32OLE_TYPELIB;
VALUE cWIN32OLE_TYPE;
VALUE cWIN32OLE_VARIABLE;
VALUE cWIN32OLE_METHOD;
VALUE cWIN32OLE_PARAM;
VALUE cWIN32OLE_EVENT;
-VALUE cWIN32OLE_VARIANT;
-VALUE eWIN32OLERuntimeError;
+VALUE eWIN32OLE_RUNTIME_ERROR;
VALUE mWIN32OLE_VARIANT;
-VALUE cWIN32OLE_PROPERTY;
static VALUE ary_ole_event;
static ID id_events;
-static BOOL g_ole_initialized = FALSE;
-static BOOL g_cp_installed = FALSE;
-static BOOL g_lcid_installed = FALSE;
+static BOOL gOLEInitialized = Qfalse;
static HINSTANCE ghhctrl = NULL;
static HINSTANCE gole32 = NULL;
static FNCOCREATEINSTANCEEX *gCoCreateInstanceEx = NULL;
static VALUE com_hash;
static IDispatchVtbl com_vtbl;
-static UINT cWIN32OLE_cp = CP_ACP;
-static LCID cWIN32OLE_lcid = LOCALE_SYSTEM_DEFAULT;
-static UINT g_cp_to_check = CP_ACP;
-static char g_lcid_to_check[8 + 1];
+static UINT cWIN32OLE_cp = CP_ACP;
static VARTYPE g_nil_to = VT_ERROR;
+static IMessageFilterVtbl message_filter;
+static IMessageFilter imessage_filter = { &message_filter };
+static IMessageFilter* previous_filter;
struct oledata {
IDispatch *pDispatch;
@@ -227,9 +187,8 @@ struct oleparamdata {
};
struct oleeventdata {
- DWORD dwCookie;
- IConnectionPoint *pConnectionPoint;
- long event_id;
+ IEVENTSINKOBJ *pEvent;
+ int freed;
};
struct oleparam {
@@ -237,283 +196,111 @@ struct oleparam {
OLECHAR** pNamedArgs;
};
-struct olevariantdata {
- VARIANT realvar;
- VARIANT var;
-};
+static VALUE folemethod_s_allocate _((VALUE));
+static VALUE olemethod_set_member _((VALUE, ITypeInfo *, ITypeInfo *, int, VALUE));
+static VALUE foletype_s_allocate _((VALUE));
+static VALUE oletype_set_member _((VALUE, ITypeInfo *, VALUE));
+static VALUE olemethod_from_typeinfo _((VALUE, ITypeInfo *, VALUE));
+static HRESULT ole_docinfo_from_type _((ITypeInfo *, BSTR *, BSTR *, DWORD *, BSTR *));
+static char *ole_wc2mb(LPWSTR);
+static VALUE ole_variant2val(VARIANT*);
+static void ole_val2variant(VALUE, VARIANT*);
+
+static HRESULT (STDMETHODCALLTYPE mf_QueryInterface)(
+ IMessageFilter __RPC_FAR * This,
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ if (MEMCMP(riid, &IID_IUnknown, GUID, 1) == 0
+ || MEMCMP(riid, &IID_IMessageFilter, GUID, 1) == 0)
+ {
+ *ppvObject = &message_filter;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+static ULONG (STDMETHODCALLTYPE mf_AddRef)(
+ IMessageFilter __RPC_FAR * This)
+{
+ return 1;
+}
+
+static ULONG (STDMETHODCALLTYPE mf_Release)(
+ IMessageFilter __RPC_FAR * This)
+{
+ return 1;
+}
-static HRESULT ( STDMETHODCALLTYPE QueryInterface )(IDispatch __RPC_FAR *, REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject);
-static ULONG ( STDMETHODCALLTYPE AddRef )(IDispatch __RPC_FAR * This);
-static ULONG ( STDMETHODCALLTYPE Release )(IDispatch __RPC_FAR * This);
-static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount )(IDispatch __RPC_FAR * This, UINT __RPC_FAR *pctinfo);
-static HRESULT ( STDMETHODCALLTYPE GetTypeInfo )(IDispatch __RPC_FAR * This, UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
-static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames )(IDispatch __RPC_FAR * This, REFIID riid, LPOLESTR __RPC_FAR *rgszNames, UINT cNames, LCID lcid, DISPID __RPC_FAR *rgDispId);
-static HRESULT ( STDMETHODCALLTYPE Invoke )( IDispatch __RPC_FAR * This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
-static IDispatch* val2dispatch(VALUE val);
-static void time2d(int hh, int mm, int ss, double *pv);
-static void d2time(double v, int *hh, int *mm, int *ss);
-static void civil2jd(int y, int m, int d, long *jd);
-static void jd2civil(long day, int *yy, int *mm, int *dd);
-static void double2time(double v, int *y, int *m, int *d, int *hh, int *mm, int *ss);
-static double time_object2date(VALUE tmobj);
-static VALUE date2time_str(double date);
-static char *ole_wc2mb(LPWSTR pw);
-static VALUE ole_hresult2msg(HRESULT hr);
-static VALUE ole_excepinfo2msg(EXCEPINFO *pExInfo);
-static void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...);
-static void ole_initialize();
-static void ole_msg_loop();
-static void ole_free(struct oledata *pole);
-static void oletype_free(struct oletypedata *poletype);
-static void olemethod_free(struct olemethoddata *polemethod);
-static void olevariable_free(struct olevariabledata *polevar);
-static void oleparam_free(struct oleparamdata *pole);
-static LPWSTR ole_mb2wc(char *pm, int len);
-static VALUE ole_wc2vstr(LPWSTR pw, BOOL isfree);
-static VALUE ole_ary_m_entry(VALUE val, long *pid);
-static void * get_ptr_of_variant(VARIANT *pvar);
-static VALUE is_all_index_under(long *pid, long *pub, long dim);
-static void ole_set_safe_array(long n, SAFEARRAY *psa, long *pid, long *pub, VALUE val, long dim, VARTYPE vt);
-static long dimension(VALUE val);
-static long ary_len_of_dim(VALUE ary, long dim);
-static HRESULT ole_val_ary2variant_ary(VALUE val, VARIANT *var, VARTYPE vt);
-static void ole_val2variant(VALUE val, VARIANT *var);
-static void ole_val2variant_ex(VALUE val, VARIANT *var, VARTYPE vt);
-static void ole_val2ptr_variant(VALUE val, VARIANT *var);
-static void ole_set_byref(VARIANT *realvar, VARIANT *var, VARTYPE vt);
-static void ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar);
-static void ole_val2variant2(VALUE val, VARIANT *var);
-static VALUE make_inspect(const char *class_name, VALUE detail);
-static VALUE default_inspect(VALUE self, const char *class_name);
-static VALUE ole_set_member(VALUE self, IDispatch *dispatch);
-static VALUE fole_s_allocate(VALUE klass);
-static VALUE create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv);
-static VALUE ary_new_dim(VALUE myary, long *pid, long *plb, long dim);
-static void ary_store_dim(VALUE myary, long *pid, long *plb, long dim, VALUE val);
-static VALUE ole_variant2val(VARIANT *pvar);
-static LONG reg_open_key(HKEY hkey, const char *name, HKEY *phkey);
-static LONG reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey);
-static VALUE reg_enum_key(HKEY hkey, DWORD i);
-static VALUE reg_get_val(HKEY hkey, const char *subkey);
-static VALUE reg_get_typelib_file_path(HKEY hkey);
-static VALUE typelib_file_from_clsid(VALUE ole);
-static VALUE typelib_file_from_typelib(VALUE ole);
-static VALUE typelib_file(VALUE ole);
-static void ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self);
-static HRESULT clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid);
-static VALUE ole_create_dcom(int argc, VALUE *argv, VALUE self);
-static VALUE ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self);
-static VALUE fole_s_connect(int argc, VALUE *argv, VALUE self);
-static VALUE fole_s_const_load(int argc, VALUE *argv, VALUE self);
-static VALUE ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes);
-static ULONG reference_count(struct oledata * pole);
-static VALUE fole_s_reference_count(VALUE self, VALUE obj);
-static VALUE fole_s_free(VALUE self, VALUE obj);
-static HWND ole_show_help(VALUE helpfile, VALUE helpcontext);
-static VALUE fole_s_show_help(int argc, VALUE *argv, VALUE self);
-static VALUE fole_s_get_code_page(VALUE self);
-static BOOL CALLBACK installed_code_page_proc(LPTSTR str);
-static BOOL code_page_installed(UINT cp);
-static VALUE fole_s_set_code_page(VALUE self, VALUE vcp);
-static VALUE fole_s_get_locale(VALUE self);
-static BOOL CALLBACK installed_lcid_proc(LPTSTR str);
-static BOOL lcid_installed(LCID lcid);
-static VALUE fole_s_set_locale(VALUE self, VALUE vlcid);
-static VALUE fole_s_create_guid(VALUE self);
-static VALUE fole_initialize(int argc, VALUE *argv, VALUE self);
-static VALUE hash2named_arg(VALUE pair, struct oleparam* pOp);
-static VALUE set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end);
-static VALUE ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket);
-static VALUE fole_invoke(int argc, VALUE *argv, VALUE self);
-static VALUE ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind);
-static VALUE fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types);
-static VALUE fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types);
-static VALUE fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types);
-static VALUE fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self);
-static VALUE fole_setproperty(int argc, VALUE *argv, VALUE self);
-static VALUE fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self);
-static VALUE ole_propertyput(VALUE self, VALUE property, VALUE value);
-static VALUE fole_free(VALUE self);
-static VALUE ole_each_sub(VALUE pEnumV);
-static VALUE ole_ienum_free(VALUE pEnumV);
-static VALUE fole_each(VALUE self);
-static VALUE fole_missing(int argc, VALUE *argv, VALUE self);
-static VALUE ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE name);
-static VALUE olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name);
-static VALUE ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask);
-static VALUE ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask);
-static HRESULT typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti);
-static VALUE ole_methods(VALUE self, int mask);
-static VALUE fole_methods(VALUE self);
-static VALUE fole_get_methods(VALUE self);
-static VALUE fole_put_methods(VALUE self);
-static VALUE fole_func_methods(VALUE self);
-static VALUE ole_type_from_itypeinfo(ITypeInfo *pTypeInfo);
-static VALUE fole_type(VALUE self);
-static VALUE make_oletypelib_obj(VALUE guid, VALUE major_version, VALUE minor_version);
-static VALUE ole_typelib_from_itypelib(ITypeLib *pTypeLib);
-static VALUE ole_typelib_from_itypeinfo(ITypeInfo *pTypeInfo);
-static VALUE fole_typelib(VALUE self);
-static VALUE fole_query_interface(VALUE self, VALUE str_iid);
-static HRESULT ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile);
-static VALUE ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
-static VALUE ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
-static VALUE ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
-static VALUE fole_method_help(VALUE self, VALUE cmdname);
-static VALUE fole_activex_initialize(VALUE self);
-static VALUE foletype_s_ole_classes(VALUE self, VALUE typelib);
-static VALUE foletype_s_typelibs(VALUE self);
-static VALUE foletype_s_progids(VALUE self);
-static VALUE foletype_s_allocate(VALUE klass);
-static VALUE oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name);
-static VALUE oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass);
-static VALUE oletypelib_set_member(VALUE self, VALUE typelib, VALUE guid, VALUE version);
-static VALUE foletypelib_s_typelibs(VALUE self);
-static VALUE make_version_str(VALUE major, VALUE minor);
-static VALUE oletypelib_search_registry2(VALUE self, VALUE args);
-static VALUE oletypelib_search_registry(VALUE self, VALUE typelib);
-static VALUE foletypelib_initialize(VALUE self, VALUE args);
-static VALUE foletypelib_guid(VALUE self);
-static VALUE foletypelib_name(VALUE self);
-static VALUE foletypelib_version(VALUE self);
-static VALUE foletypelib_major_version(VALUE self);
-static VALUE foletypelib_minor_version(VALUE self);
-static VALUE oletypelib_path(VALUE guid, VALUE version);
-static VALUE foletypelib_path(VALUE self);
-static void oletypelib2itypelib(VALUE self, ITypeLib **ppTypeLib);
-static VALUE foletypelib_visible(VALUE self);
-static VALUE foletypelib_library_name(VALUE self);
-static VALUE foletypelib_ole_types(VALUE self);
-static VALUE foletypelib_inspect(VALUE self);
-static VALUE foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass);
-static VALUE foletype_name(VALUE self);
-static VALUE ole_ole_type(ITypeInfo *pTypeInfo);
-static VALUE foletype_ole_type(VALUE self);
-static VALUE ole_type_guid(ITypeInfo *pTypeInfo);
-static VALUE foletype_guid(VALUE self);
-static VALUE ole_type_progid(ITypeInfo *pTypeInfo);
-static VALUE foletype_progid(VALUE self);
-static VALUE ole_type_visible(ITypeInfo *pTypeInfo);
-static VALUE foletype_visible(VALUE self);
-static VALUE ole_type_major_version(ITypeInfo *pTypeInfo);
-static VALUE foletype_major_version(VALUE self);
-static VALUE ole_type_minor_version(ITypeInfo *pTypeInfo);
-static VALUE foletype_minor_version(VALUE self);
-static VALUE ole_type_typekind(ITypeInfo *pTypeInfo);
-static VALUE foletype_typekind(VALUE self);
-static VALUE ole_type_helpstring(ITypeInfo *pTypeInfo);
-static VALUE foletype_helpstring(VALUE self);
-static VALUE ole_type_src_type(ITypeInfo *pTypeInfo);
-static VALUE foletype_src_type(VALUE self);
-static VALUE ole_type_helpfile(ITypeInfo *pTypeInfo);
-static VALUE foletype_helpfile(VALUE self);
-static VALUE ole_type_helpcontext(ITypeInfo *pTypeInfo);
-static VALUE foletype_helpcontext(VALUE self);
-static VALUE foletype_ole_typelib(VALUE self);
-static VALUE ole_type_impl_ole_types(ITypeInfo *pTypeInfo);
-static VALUE foletype_impl_ole_types(VALUE self);
-static VALUE foletype_inspect(VALUE self);
-static VALUE ole_variables(ITypeInfo *pTypeInfo);
-static VALUE foletype_variables(VALUE self);
-static VALUE foletype_methods(VALUE self);
-static VALUE folevariable_name(VALUE self);
-static VALUE ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index);
-static VALUE folevariable_ole_type(VALUE self);
-static VALUE ole_variable_ole_type_detail(ITypeInfo *pTypeInfo, UINT var_index);
-static VALUE folevariable_ole_type_detail(VALUE self);
-static VALUE ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index);
-static VALUE folevariable_value(VALUE self);
-static VALUE ole_variable_visible(ITypeInfo *pTypeInfo, UINT var_index);
-static VALUE folevariable_visible(VALUE self);
-static VALUE ole_variable_kind(ITypeInfo *pTypeInfo, UINT var_index);
-static VALUE folevariable_variable_kind(VALUE self);
-static VALUE ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index);
-static VALUE folevariable_varkind(VALUE self);
-static VALUE folevariable_inspect(VALUE self);
-static VALUE olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name);
-static VALUE folemethod_s_allocate(VALUE klass);
-static VALUE folemethod_initialize(VALUE self, VALUE oletype, VALUE method);
-static VALUE folemethod_name(VALUE self);
-static VALUE ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_return_type(VALUE self);
-static VALUE ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_return_vtype(VALUE self);
-static VALUE ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_return_type_detail(VALUE self);
-static VALUE ole_method_invkind(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_invkind(VALUE self);
-static VALUE folemethod_invoke_kind(VALUE self);
-static VALUE ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_visible(VALUE self);
-static VALUE ole_method_event(ITypeInfo *pTypeInfo, UINT method_index, VALUE method_name);
-static VALUE folemethod_event(VALUE self);
-static VALUE folemethod_event_interface(VALUE self);
-static VALUE ole_method_docinfo_from_type(ITypeInfo *pTypeInfo, UINT method_index, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile);
-static VALUE ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_helpstring(VALUE self);
-static VALUE ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_helpfile(VALUE self);
-static VALUE ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_helpcontext(VALUE self);
-static VALUE ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_dispid(VALUE self);
-static VALUE ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_offset_vtbl(VALUE self);
-static VALUE ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_size_params(VALUE self);
-static VALUE ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_size_opt_params(VALUE self);
-static VALUE ole_method_params(ITypeInfo *pTypeInfo, UINT method_index);
-static VALUE folemethod_params(VALUE self);
-static VALUE folemethod_inspect(VALUE self);
-static VALUE foleparam_name(VALUE self);
-static VALUE ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index);
-static VALUE foleparam_ole_type(VALUE self);
-static VALUE ole_param_ole_type_detail(ITypeInfo *pTypeInfo, UINT method_index, UINT index);
-static VALUE foleparam_ole_type_detail(VALUE self);
-static VALUE ole_param_flag_mask(ITypeInfo *pTypeInfo, UINT method_index, UINT index, USHORT mask);
-static VALUE foleparam_input(VALUE self);
-static VALUE foleparam_output(VALUE self);
-static VALUE foleparam_optional(VALUE self);
-static VALUE foleparam_retval(VALUE self);
-static VALUE ole_param_default(ITypeInfo *pTypeInfo, UINT method_index, UINT index);
-static VALUE foleparam_default(VALUE self);
-static VALUE foleparam_inspect(VALUE self);
-static long ole_search_event_at(VALUE ary, VALUE ev);
-static VALUE ole_search_event(VALUE ary, VALUE ev, BOOL *is_default);
-static void ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams);
-static HRESULT find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo);
-static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo);
-static void ole_event_free(struct oleeventdata *poleev);
-static VALUE fev_s_allocate(VALUE klass);
-static VALUE ev_advise(int argc, VALUE *argv, VALUE self);
-static VALUE fev_initialize(int argc, VALUE *argv, VALUE self);
-static VALUE fev_s_msg_loop(VALUE klass);
-static void add_event_call_back(VALUE obj, VALUE event, VALUE data);
-static VALUE ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg);
-static VALUE fev_on_event(int argc, VALUE *argv, VALUE self);
-static VALUE fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self);
-static VALUE fev_unadvise(VALUE self);
-static VALUE evs_push(VALUE ev);
-static VALUE evs_delete(long i);
-static VALUE evs_entry(long i);
-static VALUE evs_length();
-static void olevariant_free(struct olevariantdata *pvar);
-static VALUE folevariant_s_allocate(VALUE klass);
-static VALUE folevariant_s_array(VALUE klass, VALUE dims, VALUE vvt);
-static VALUE folevariant_initialize(VALUE self, VALUE args);
-static long *ary2safe_array_index(int ary_size, VALUE *ary, SAFEARRAY *psa);
-static void unlock_safe_array(SAFEARRAY *psa);
-static SAFEARRAY *get_locked_safe_array(VALUE val);
-static VALUE folevariant_ary_aref(int argc, VALUE *argv, VALUE self);
-static VOID * val2variant_ptr(VALUE val, VARIANT *var, VARTYPE vt);
-static VALUE folevariant_ary_aset(int argc, VALUE *argv, VALUE self);
-static VALUE folevariant_value(VALUE self);
-static VALUE folevariant_vartype(VALUE self);
-static VALUE folevariant_set_value(VALUE self, VALUE val);
-
+static DWORD (STDMETHODCALLTYPE mf_HandleInComingCall)(
+ IMessageFilter __RPC_FAR * pThis,
+ DWORD dwCallType, //Type of incoming call
+ HTASK threadIDCaller, //Task handle calling this task
+ DWORD dwTickCount, //Elapsed tick count
+ LPINTERFACEINFO lpInterfaceInfo //Pointer to INTERFACEINFO structure
+ )
+{
+#ifdef DEBUG_MESSAGEFILTER
+ printf("incoming %08X, %08X, %d\n", dwCallType, threadIDCaller, dwTickCount);
+ fflush(stdout);
+#endif
+ switch (dwCallType)
+ {
+ case CALLTYPE_ASYNC:
+ case CALLTYPE_TOPLEVEL_CALLPENDING:
+ case CALLTYPE_ASYNC_CALLPENDING:
+ if (rb_during_gc()) {
+ return SERVERCALL_RETRYLATER;
+ }
+ break;
+ default:
+ break;
+ }
+ if (previous_filter) {
+ return previous_filter->lpVtbl->HandleInComingCall(previous_filter,
+ dwCallType,
+ threadIDCaller,
+ dwTickCount,
+ lpInterfaceInfo);
+ }
+ return SERVERCALL_ISHANDLED;
+}
+
+static DWORD (STDMETHODCALLTYPE mf_RetryRejectedCall)(
+ IMessageFilter* pThis,
+ HTASK threadIDCallee, //Server task handle
+ DWORD dwTickCount, //Elapsed tick count
+ DWORD dwRejectType //Returned rejection message
+ )
+{
+ if (previous_filter) {
+ return previous_filter->lpVtbl->RetryRejectedCall(previous_filter,
+ threadIDCallee,
+ dwTickCount,
+ dwRejectType);
+ }
+ return 1000;
+}
+
+static DWORD (STDMETHODCALLTYPE mf_MessagePending)(
+ IMessageFilter* pThis,
+ HTASK threadIDCallee, //Called applications task handle
+ DWORD dwTickCount, //Elapsed tick count
+ DWORD dwPendingType //Call type
+ )
+{
+ if (rb_during_gc()) {
+ return PENDINGMSG_WAITNOPROCESS;
+ }
+ if (previous_filter) {
+ return previous_filter->lpVtbl->MessagePending(previous_filter,
+ threadIDCallee,
+ dwTickCount,
+ dwPendingType);
+ }
+ return PENDINGMSG_WAITNOPROCESS;
+}
+
typedef struct _Win32OLEIDispatch
{
IDispatch dispatch;
@@ -582,9 +369,7 @@ static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames )(
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
{
- /*
Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
- */
char* psz = ole_wc2mb(*rgszNames); // support only one method
*rgDispId = rb_intern(psz);
free(psz);
@@ -623,7 +408,8 @@ static /* [local] */ HRESULT ( STDMETHODCALLTYPE Invoke )(
}
static IDispatch*
-val2dispatch(VALUE val)
+val2dispatch(val)
+ VALUE val;
{
struct st_table *tbl = DATA_PTR(com_hash);
Win32OLEIDispatch* pdisp;
@@ -644,13 +430,17 @@ val2dispatch(VALUE val)
}
static void
-time2d(int hh, int mm, int ss, double *pv)
+time2d(hh, mm, ss, pv)
+ int hh, mm, ss;
+ double *pv;
{
*pv = (hh * 60.0 * 60.0 + mm * 60.0 + ss) / 86400.0;
}
static void
-d2time(double v, int *hh, int *mm, int *ss)
+d2time(v, hh, mm, ss)
+ double v;
+ int *hh, *mm, *ss;
{
double d_hh, d_mm, d_ss;
int i_hh, i_mm, i_ss;
@@ -690,7 +480,9 @@ d2time(double v, int *hh, int *mm, int *ss)
}
static void
-civil2jd(int y, int m, int d, long *jd)
+civil2jd(y, m, d, jd)
+ int y, m, d;
+ long *jd;
{
long a, b;
if (m <= 2) {
@@ -705,7 +497,9 @@ civil2jd(int y, int m, int d, long *jd)
}
static void
-jd2civil(long day, int *yy, int *mm, int *dd)
+jd2civil(day, yy, mm, dd)
+ long day;
+ int *yy, *mm, *dd;
{
long x, a, b, c, d, e;
x = (long)(((double)day - 1867216.25) / 36524.25);
@@ -726,7 +520,9 @@ jd2civil(long day, int *yy, int *mm, int *dd)
}
static void
-double2time(double v, int *y, int *m, int *d, int *hh, int *mm, int *ss)
+double2time(v, y, m, d, hh, mm, ss)
+ double v;
+ int *y, *m, *d, *hh, *mm, *ss;
{
long day;
double t;
@@ -739,7 +535,8 @@ double2time(double v, int *y, int *m, int *d, int *hh, int *mm, int *ss)
}
static double
-time_object2date(VALUE tmobj)
+time_object2date(tmobj)
+ VALUE tmobj;
{
long y, m, d, hh, mm, ss;
long day;
@@ -756,19 +553,23 @@ time_object2date(VALUE tmobj)
}
static VALUE
-date2time_str(double date)
+date2time_str(date)
+ double date;
{
int y, m, d, hh, mm, ss;
- char szTime[20];
+ char szTime[40];
double2time(date, &y, &m, &d, &hh, &mm, &ss);
sprintf(szTime,
- "%04d/%02d/%02d %02d:%02d:%02d",
+ "%4.4d/%02.2d/%02.2d %02.2d:%02.2d:%02.2d",
y, m, d, hh, mm, ss);
return rb_str_new2(szTime);
}
+static void ole_val2variant();
+
static char *
-ole_wc2mb(LPWSTR pw)
+ole_wc2mb(pw)
+ LPWSTR pw;
{
int size;
LPSTR pm;
@@ -786,7 +587,8 @@ ole_wc2mb(LPWSTR pw)
}
static VALUE
-ole_hresult2msg(HRESULT hr)
+ole_hresult2msg(hr)
+ HRESULT hr;
{
VALUE msg = Qnil;
char *p_msg = NULL;
@@ -794,13 +596,13 @@ ole_hresult2msg(HRESULT hr)
DWORD dwCount;
char strhr[100];
- sprintf(strhr, " HRESULT error code:0x%08x\n ", (unsigned)hr);
+ sprintf(strhr, " HRESULT error code:0x%08lx\n ", hr);
msg = rb_str_new2(strhr);
dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, hr, cWIN32OLE_lcid,
+ NULL, hr, LOCALE_SYSTEM_DEFAULT,
(LPTSTR)&p_msg, 0, NULL);
if (dwCount > 0) {
term = p_msg + strlen(p_msg);
@@ -818,8 +620,18 @@ ole_hresult2msg(HRESULT hr)
return msg;
}
+static void
+ole_freeexceptinfo(pExInfo)
+ EXCEPINFO *pExInfo;
+{
+ SysFreeString(pExInfo->bstrDescription);
+ SysFreeString(pExInfo->bstrSource);
+ SysFreeString(pExInfo->bstrHelpFile);
+}
+
static VALUE
-ole_excepinfo2msg(EXCEPINFO *pExInfo)
+ole_excepinfo2msg(pExInfo)
+ EXCEPINFO *pExInfo;
{
char error_code[40];
char *pSource = NULL;
@@ -856,14 +668,20 @@ ole_excepinfo2msg(EXCEPINFO *pExInfo)
}
if(pSource) free(pSource);
if(pDescription) free(pDescription);
- SysFreeString(pExInfo->bstrDescription);
- SysFreeString(pExInfo->bstrSource);
- SysFreeString(pExInfo->bstrHelpFile);
+ ole_freeexceptinfo(pExInfo);
return error_msg;
}
static void
+#ifdef HAVE_STDARG_PROTOTYPES
ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
+#else
+ole_raise(hr, exc, fmt, va_alist)
+ HRESULT hr;
+ VALUE exc;
+ const char *fmt;
+ va_dcl
+#endif
{
va_list args;
char buf[BUFSIZ];
@@ -885,7 +703,7 @@ void
ole_uninitialize()
{
OleUninitialize();
- g_ole_initialized = FALSE;
+ gOLEInitialized = Qfalse;
}
static void
@@ -893,18 +711,23 @@ ole_initialize()
{
HRESULT hr;
- if(g_ole_initialized == FALSE) {
+ if(gOLEInitialized == Qfalse) {
hr = OleInitialize(NULL);
if(FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "fail: OLE initialize");
}
- g_ole_initialized = TRUE;
+ gOLEInitialized = Qtrue;
/*
* In some situation, OleUninitialize does not work fine. ;-<
*/
/*
atexit((void (*)(void))ole_uninitialize);
*/
+ hr = CoRegisterMessageFilter(&imessage_filter, &previous_filter);
+ if(FAILED(hr)) {
+ previous_filter = NULL;
+ ole_raise(hr, rb_eRuntimeError, "fail: install OLE MessageFilter");
+ }
}
}
@@ -918,21 +741,24 @@ ole_msg_loop() {
}
static void
-ole_free(struct oledata *pole)
+ole_free(pole)
+ struct oledata *pole;
{
OLE_FREE(pole->pDispatch);
free(pole);
}
static void
-oletype_free(struct oletypedata *poletype)
+oletype_free(poletype)
+ struct oletypedata *poletype;
{
OLE_FREE(poletype->pTypeInfo);
free(poletype);
}
static void
-olemethod_free(struct olemethoddata *polemethod)
+olemethod_free(polemethod)
+ struct olemethoddata *polemethod;
{
OLE_FREE(polemethod->pTypeInfo);
OLE_FREE(polemethod->pOwnerTypeInfo);
@@ -940,21 +766,25 @@ olemethod_free(struct olemethoddata *polemethod)
}
static void
-olevariable_free(struct olevariabledata *polevar)
+olevariable_free(polevar)
+ struct olevariabledata *polevar;
{
OLE_FREE(polevar->pTypeInfo);
free(polevar);
}
static void
-oleparam_free(struct oleparamdata *pole)
+oleparam_free(pole)
+ struct oleparamdata *pole;
{
OLE_FREE(pole->pTypeInfo);
free(pole);
}
static LPWSTR
-ole_mb2wc(char *pm, int len)
+ole_mb2wc(pm, len)
+ char *pm;
+ int len;
{
int size;
LPWSTR pw;
@@ -965,7 +795,9 @@ ole_mb2wc(char *pm, int len)
}
static VALUE
-ole_wc2vstr(LPWSTR pw, BOOL isfree)
+ole_wc2vstr(pw, isfree)
+ LPWSTR pw;
+ BOOL isfree;
{
char *p = ole_wc2mb(pw);
VALUE vstr = rb_str_new2(p);
@@ -976,7 +808,9 @@ ole_wc2vstr(LPWSTR pw, BOOL isfree)
}
static VALUE
-ole_ary_m_entry(VALUE val, long *pid)
+ole_ary_m_entry(val, pid)
+ VALUE val;
+ long *pid;
{
VALUE obj = Qnil;
int i = 0;
@@ -988,230 +822,40 @@ ole_ary_m_entry(VALUE val, long *pid)
return obj;
}
-static void * get_ptr_of_variant(VARIANT *pvar)
-{
- switch(V_VT(pvar)) {
- case VT_UI1:
- return &V_UI1(pvar);
- break;
- case VT_I2:
- return &V_I2(pvar);
- break;
- case VT_UI2:
- return &V_UI2(pvar);
- break;
- case VT_I4:
- return &V_I4(pvar);
- break;
- case VT_UI4:
- return &V_UI4(pvar);
- break;
- case VT_R4:
- return &V_R4(pvar);
- break;
- case VT_R8:
- return &V_R8(pvar);
- break;
-#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
- case VT_I8:
- return &V_I8(pvar);
- break;
- case VT_UI8:
- return &V_UI8(pvar);
- break;
-#endif
- case VT_INT:
- return &V_INT(pvar);
- break;
- case VT_UINT:
- return &V_UINT(pvar);
- break;
- case VT_CY:
- return &V_CY(pvar);
- break;
- case VT_DATE:
- return &V_DATE(pvar);
- break;
- case VT_BSTR:
- return V_BSTR(pvar);
- break;
- case VT_DISPATCH:
- return V_DISPATCH(pvar);
- break;
- case VT_ERROR:
- return &V_ERROR(pvar);
- break;
- case VT_BOOL:
- return &V_BOOL(pvar);
- break;
- case VT_UNKNOWN:
- return V_UNKNOWN(pvar);
- break;
- case VT_ARRAY:
- return &V_ARRAY(pvar);
- break;
- default:
- return NULL;
- break;
- }
-}
-
-static VALUE
-is_all_index_under(long *pid, long *pub, long dim)
-{
- long i = 0;
- for (i = 0; i < dim; i++) {
- if (pid[i] > pub[i]) {
- return Qfalse;
- }
- }
- return Qtrue;
-}
-
static void
-ole_set_safe_array(long n, SAFEARRAY *psa, long *pid, long *pub, VALUE val, long dim, VARTYPE vt)
+ole_set_safe_array(n, psa, pid, pub, val, dim)
+ long n;
+ SAFEARRAY *psa;
+ long *pid;
+ long *pub;
+ VALUE val;
+ long dim;
{
VALUE val1;
- HRESULT hr = S_OK;
VARIANT var;
- VOID *p = NULL;
VariantInit(&var);
if(n < 0) return;
- if(n == dim - 1) {
+ if(n == dim) {
val1 = ole_ary_m_entry(val, pid);
- p = val2variant_ptr(val1, &var, vt);
- if (is_all_index_under(pid, pub, dim) == Qtrue) {
- if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) ||
- (V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) {
- rb_raise(eWIN32OLERuntimeError, "argument does not have IDispatch or IUnknown Interface");
- }
- hr = SafeArrayPutElement(psa, pid, p);
- }
- if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayPutElement");
- }
+ ole_val2variant(val1, &var);
+ SafeArrayPutElement(psa, pid, &var);
}
pid[n] += 1;
- if (pid[n] <= pub[n]) {
- ole_set_safe_array(dim-1, psa, pid, pub, val, dim, vt);
+ if (pid[n] < pub[n]) {
+ ole_set_safe_array(dim, psa, pid, pub, val, dim);
}
else {
pid[n] = 0;
- ole_set_safe_array(n-1, psa, pid, pub, val, dim, vt);
+ ole_set_safe_array(n-1, psa, pid, pub, val, dim);
}
}
-static long
-dimension(VALUE val) {
- long dim = 0;
- long dim1 = 0;
- long len = 0;
- long i = 0;
- if (TYPE(val) == T_ARRAY) {
- len = RARRAY_LEN(val);
- for (i = 0; i < len; i++) {
- dim1 = dimension(rb_ary_entry(val, i));
- if (dim < dim1) {
- dim = dim1;
- }
- }
- dim += 1;
- }
- return dim;
-}
-
-static long
-ary_len_of_dim(VALUE ary, long dim) {
- long ary_len = 0;
- long ary_len1 = 0;
- long len = 0;
- long i = 0;
- VALUE val;
- if (dim == 0) {
- if (TYPE(ary) == T_ARRAY) {
- ary_len = RARRAY_LEN(ary);
- }
- } else {
- if (TYPE(ary) == T_ARRAY) {
- len = RARRAY_LEN(ary);
- for (i = 0; i < len; i++) {
- val = rb_ary_entry(ary, i);
- ary_len1 = ary_len_of_dim(val, dim-1);
- if (ary_len < ary_len1) {
- ary_len = ary_len1;
- }
- }
- }
- }
- return ary_len;
-}
-
-static HRESULT
-ole_val_ary2variant_ary(VALUE val, VARIANT *var, VARTYPE vt)
-{
- long dim = 0;
- int i = 0;
- HRESULT hr = S_OK;
-
- SAFEARRAYBOUND *psab = NULL;
- SAFEARRAY *psa = NULL;
- long *pub, *pid;
-
- Check_Type(val, T_ARRAY);
-
- dim = dimension(val);
-
- psab = ALLOC_N(SAFEARRAYBOUND, dim);
- pub = ALLOC_N(long, dim);
- pid = ALLOC_N(long, dim);
-
- if(!psab || !pub || !pid) {
- if(pub) free(pub);
- if(psab) free(psab);
- if(pid) free(pid);
- rb_raise(rb_eRuntimeError, "memory allocation error");
- }
-
- for (i = 0; i < dim; i++) {
- psab[i].cElements = ary_len_of_dim(val, i);
- psab[i].lLbound = 0;
- pub[i] = psab[i].cElements - 1;
- pid[i] = 0;
- }
- /* Create and fill VARIANT array */
- if ((vt & ~VT_BYREF) == VT_ARRAY) {
- vt = (vt | VT_VARIANT);
- }
- psa = SafeArrayCreate(vt & VT_TYPEMASK, dim, psab);
- if (psa == NULL)
- hr = E_OUTOFMEMORY;
- else
- hr = SafeArrayLock(psa);
- if (SUCCEEDED(hr)) {
- ole_set_safe_array(dim-1, psa, pid, pub, val, dim, vt & VT_TYPEMASK);
- hr = SafeArrayUnlock(psa);
- }
-
- if(pub) free(pub);
- if(psab) free(psab);
- if(pid) free(pid);
-
- if (SUCCEEDED(hr)) {
- V_VT(var) = vt;
- V_ARRAY(var) = psa;
- }
- else {
- if (psa != NULL)
- SafeArrayDestroy(psa);
- }
- return hr;
-}
-
static void
-ole_val2variant(VALUE val, VARIANT *var)
+ole_val2variant(val, var)
+ VALUE val;
+ VARIANT *var;
{
struct oledata *pole;
- struct olevariantdata *pvar;
if(rb_obj_is_kind_of(val, cWIN32OLE)) {
Data_Get_Struct(val, struct oledata, pole);
OLE_ADDREF(pole->pDispatch);
@@ -1219,12 +863,6 @@ ole_val2variant(VALUE val, VARIANT *var)
V_DISPATCH(var) = pole->pDispatch;
return;
}
- if (rb_obj_is_kind_of(val, cWIN32OLE_VARIANT)) {
- Data_Get_Struct(val, struct olevariantdata, pvar);
- VariantCopy(var, &(pvar->var));
- return;
- }
-
if (rb_obj_is_kind_of(val, rb_cTime)) {
V_VT(var) = VT_DATE;
V_DATE(var) = time_object2date(val);
@@ -1232,8 +870,63 @@ ole_val2variant(VALUE val, VARIANT *var)
}
switch (TYPE(val)) {
case T_ARRAY:
- ole_val_ary2variant_ary(val, var, VT_VARIANT|VT_ARRAY);
+ {
+ VALUE val1;
+ long dim = 0;
+ int i = 0;
+
+ HRESULT hr;
+ SAFEARRAYBOUND *psab;
+ SAFEARRAY *psa;
+ long *pub, *pid;
+
+ val1 = val;
+ while(TYPE(val1) == T_ARRAY) {
+ val1 = rb_ary_entry(val1, 0);
+ dim += 1;
+ }
+ psab = ALLOC_N(SAFEARRAYBOUND, dim);
+ pub = ALLOC_N(long, dim);
+ pid = ALLOC_N(long, dim);
+
+ if(!psab || !pub || !pid) {
+ if(pub) free(pub);
+ if(psab) free(psab);
+ if(pid) free(pid);
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+ val1 = val;
+ i = 0;
+ while(TYPE(val1) == T_ARRAY) {
+ psab[i].cElements = RARRAY(val1)->len;
+ psab[i].lLbound = 0;
+ pub[i] = psab[i].cElements;
+ pid[i] = 0;
+ i ++;
+ val1 = rb_ary_entry(val1, 0);
+ }
+ /* Create and fill VARIANT array */
+ psa = SafeArrayCreate(VT_VARIANT, dim, psab);
+ if (psa == NULL)
+ hr = E_OUTOFMEMORY;
+ else
+ hr = SafeArrayLock(psa);
+ if (SUCCEEDED(hr)) {
+ ole_set_safe_array(dim-1, psa, pid, pub, val, dim-1);
+ hr = SafeArrayUnlock(psa);
+ }
+ if(pub) free(pub);
+ if(psab) free(psab);
+ if(pid) free(pid);
+
+ if (SUCCEEDED(hr)) {
+ V_VT(var) = VT_VARIANT | VT_ARRAY;
+ V_ARRAY(var) = psa;
+ }
+ else if (psa != NULL)
+ SafeArrayDestroy(psa);
break;
+ }
case T_STRING:
V_VT(var) = VT_BSTR;
V_BSTR(var) = ole_mb2wc(StringValuePtr(val), -1);
@@ -1274,290 +967,9 @@ ole_val2variant(VALUE val, VARIANT *var)
}
static void
-ole_val2variant_ex(VALUE val, VARIANT *var, VARTYPE vt)
-{
- if (val == Qnil) {
- if (vt == VT_VARIANT) {
- ole_val2variant2(val, var);
- } else {
- V_VT(var) = (vt & ~VT_BYREF);
- if (V_VT(var) == VT_DISPATCH) {
- V_DISPATCH(var) = NULL;
- } else if (V_VT(var) == VT_UNKNOWN) {
- V_UNKNOWN(var) = NULL;
- }
- }
- return;
- }
-#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
- switch(vt & ~VT_BYREF) {
- case VT_I8:
- V_VT(var) = VT_I8;
- V_I8(var) = NUM2I8 (val);
- break;
- case VT_UI8:
- V_VT(var) = VT_UI8;
- V_UI8(var) = NUM2UI8(val);
- break;
- default:
- ole_val2variant2(val, var);
- break;
- }
-#else /* (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) */
- ole_val2variant2(val, var);
-#endif
-}
-
-static void
-ole_val2ptr_variant(VALUE val, VARIANT *var)
-{
- switch (TYPE(val)) {
- case T_STRING:
- if (V_VT(var) == (VT_BSTR | VT_BYREF)) {
- *V_BSTRREF(var) = ole_mb2wc(StringValuePtr(val), -1);
- }
- break;
- case T_FIXNUM:
- switch(V_VT(var)) {
- case (VT_UI1 | VT_BYREF) :
- *V_UI1REF(var) = NUM2CHR(val);
- break;
- case (VT_I2 | VT_BYREF) :
- *V_I2REF(var) = (short)NUM2INT(val);
- break;
- case (VT_I4 | VT_BYREF) :
- *V_I4REF(var) = NUM2INT(val);
- break;
- case (VT_R4 | VT_BYREF) :
- *V_R4REF(var) = (float)NUM2INT(val);
- break;
- case (VT_R8 | VT_BYREF) :
- *V_R8REF(var) = NUM2INT(val);
- break;
- default:
- break;
- }
- break;
- case T_FLOAT:
- switch(V_VT(var)) {
- case (VT_I2 | VT_BYREF) :
- *V_I2REF(var) = (short)NUM2INT(val);
- break;
- case (VT_I4 | VT_BYREF) :
- *V_I4REF(var) = NUM2INT(val);
- break;
- case (VT_R4 | VT_BYREF) :
- *V_R4REF(var) = (float)NUM2DBL(val);
- break;
- case (VT_R8 | VT_BYREF) :
- *V_R8REF(var) = NUM2DBL(val);
- break;
- default:
- break;
- }
- break;
- case T_BIGNUM:
- if (V_VT(var) == (VT_R8 | VT_BYREF)) {
- *V_R8REF(var) = rb_big2dbl(val);
- }
- break;
- case T_TRUE:
- if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
- *V_BOOLREF(var) = VARIANT_TRUE;
- }
- break;
- case T_FALSE:
- if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
- *V_BOOLREF(var) = VARIANT_FALSE;
- }
- break;
- default:
- break;
- }
-}
-
-static void
-ole_set_byref(VARIANT *realvar, VARIANT *var, VARTYPE vt)
-{
- V_VT(var) = vt;
- if (vt == (VT_VARIANT|VT_BYREF)) {
- V_VARIANTREF(var) = realvar;
- } else {
- if (V_VT(realvar) != (vt & ~VT_BYREF)) {
- rb_raise(eWIN32OLERuntimeError, "variant type mismatch");
- }
- switch(vt & ~VT_BYREF) {
- case VT_I1:
- V_I1REF(var) = &V_I1(realvar);
- break;
- case VT_UI1:
- V_UI1REF(var) = &V_UI1(realvar);
- break;
- case VT_I2:
- V_I2REF(var) = &V_I2(realvar);
- break;
- case VT_UI2:
- V_UI2REF(var) = &V_UI2(realvar);
- break;
- case VT_I4:
- V_I4REF(var) = &V_I4(realvar);
- break;
- case VT_UI4:
- V_UI4REF(var) = &V_UI4(realvar);
- break;
- case VT_R4:
- V_R4REF(var) = &V_R4(realvar);
- break;
- case VT_R8:
- V_R8REF(var) = &V_R8(realvar);
- break;
-
-#if (_MSC_VER >= 1300)
- case VT_I8:
- V_I8REF(var) = &V_I8(realvar);
- break;
- case VT_UI8:
- V_UI8REF(var) = &V_UI8(realvar);
- break;
-#endif
- case VT_INT:
- V_INTREF(var) = &V_INT(realvar);
- break;
-
- case VT_UINT:
- V_UINTREF(var) = &V_UINT(realvar);
- break;
-
- case VT_CY:
- V_CYREF(var) = &V_CY(realvar);
- break;
- case VT_DATE:
- V_DATEREF(var) = &V_DATE(realvar);
- break;
- case VT_BSTR:
- V_BSTRREF(var) = &V_BSTR(realvar);
- break;
- case VT_DISPATCH:
- V_DISPATCHREF(var) = &V_DISPATCH(realvar);
- break;
- case VT_ERROR:
- V_ERRORREF(var) = &V_ERROR(realvar);
- break;
- case VT_BOOL:
- V_BOOLREF(var) = &V_BOOL(realvar);
- break;
- case VT_UNKNOWN:
- V_UNKNOWNREF(var) = &V_UNKNOWN(realvar);
- break;
- case VT_ARRAY:
- V_ARRAYREF(var) = &V_ARRAY(realvar);
- break;
- default:
- rb_raise(eWIN32OLERuntimeError, "unknown type specified(setting BYREF):%d", vt);
- break;
- }
- }
-}
-
-static void
-ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar)
-{
- HRESULT hr = S_OK;
-
- if (((vt & ~VT_BYREF) == (VT_ARRAY | VT_UI1)) && TYPE(val) == T_STRING) {
- long len = RSTRING_LEN(val);
- char *pdest = NULL;
- SAFEARRAY *p = NULL;
- SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, len);
- if (!psa) {
- rb_raise(rb_eRuntimeError, "fail to SafeArrayCreateVector");
- }
- hr = SafeArrayAccessData(psa, (void **)&pdest);
- if (SUCCEEDED(hr)) {
- memcpy(pdest, RSTRING_PTR(val), len);
- SafeArrayUnaccessData(psa);
- V_VT(&(pvar->realvar)) = (vt & ~VT_BYREF);
- p = V_ARRAY(&(pvar->realvar));
- if (p != NULL) {
- SafeArrayDestroy(p);
- }
- V_ARRAY(&(pvar->realvar)) = psa;
- if (vt & VT_BYREF) {
- V_VT(&(pvar->var)) = vt;
- V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
- } else {
- hr = VariantCopy(&(pvar->var), &(pvar->realvar));
- }
- } else {
- if (psa)
- SafeArrayDestroy(psa);
- }
- } else if (vt & VT_ARRAY) {
- if (val == Qnil) {
- V_VT(&(pvar->var)) = vt;
- if (vt & VT_BYREF) {
- V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
- }
- } else {
- hr = ole_val_ary2variant_ary(val, &(pvar->realvar), (vt & ~VT_BYREF));
- if (SUCCEEDED(hr)) {
- if (vt & VT_BYREF) {
- V_VT(&(pvar->var)) = vt;
- V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
- } else {
- hr = VariantCopy(&(pvar->var), &(pvar->realvar));
- }
- }
- }
-#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
- } else if ( (vt & ~VT_BYREF) == VT_I8 || (vt & ~VT_BYREF) == VT_UI8) {
- ole_val2variant_ex(val, &(pvar->realvar), (vt & ~VT_BYREF));
- ole_val2variant_ex(val, &(pvar->var), (vt & ~VT_BYREF));
- V_VT(&(pvar->var)) = vt;
- if (vt & VT_BYREF) {
- ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
- }
-#endif
- } else {
- if (val == Qnil) {
- V_VT(&(pvar->var)) = vt;
- if (vt == (VT_BYREF | VT_VARIANT)) {
- ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
- } else {
- V_VT(&(pvar->realvar)) = vt & ~VT_BYREF;
- if (vt & VT_BYREF) {
- ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
- }
- }
- } else {
- ole_val2variant_ex(val, &(pvar->realvar), (vt & ~VT_BYREF));
- if (vt == (VT_BYREF | VT_VARIANT)) {
- ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
- } else if (vt & VT_BYREF) {
- if ( (vt & ~VT_BYREF) != V_VT(&(pvar->realvar))) {
- hr = VariantChangeTypeEx(&(pvar->realvar), &(pvar->realvar),
- cWIN32OLE_lcid, 0, (VARTYPE)(vt & ~VT_BYREF));
- }
- if (SUCCEEDED(hr)) {
- ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
- }
- } else {
- if (vt == V_VT(&(pvar->realvar))) {
- hr = VariantCopy(&(pvar->var), &(pvar->realvar));
- } else {
- hr = VariantChangeTypeEx(&(pvar->var), &(pvar->realvar),
- cWIN32OLE_lcid, 0, vt);
- }
- }
- }
- }
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to change type");
- }
-}
-
-static void
-ole_val2variant2(VALUE val, VARIANT *var)
+ole_val2variant2(val, var)
+ VALUE val;
+ VARIANT *var;
{
g_nil_to = VT_EMPTY;
ole_val2variant(val, var);
@@ -1565,26 +977,9 @@ ole_val2variant2(VALUE val, VARIANT *var)
}
static VALUE
-make_inspect(const char *class_name, VALUE detail)
-{
- VALUE str;
- str = rb_str_new2("#<");
- rb_str_cat2(str, class_name);
- rb_str_cat2(str, ":");
- rb_str_concat(str, detail);
- rb_str_cat2(str, ">");
- return str;
-}
-
-static VALUE
-default_inspect(VALUE self, const char *class_name)
-{
- VALUE detail = rb_funcall(self, rb_intern("to_s"), 0);
- return make_inspect(class_name, detail);
-}
-
-static VALUE
-ole_set_member(VALUE self, IDispatch *dispatch)
+ole_set_member(self, dispatch)
+ VALUE self;
+ IDispatch * dispatch;
{
struct oledata *pole;
Data_Get_Struct(self, struct oledata, pole);
@@ -1596,9 +991,10 @@ ole_set_member(VALUE self, IDispatch *dispatch)
return self;
}
-
+static VALUE fole_s_allocate _((VALUE));
static VALUE
-fole_s_allocate(VALUE klass)
+fole_s_allocate(klass)
+ VALUE klass;
{
struct oledata *pole;
VALUE obj;
@@ -1609,7 +1005,11 @@ fole_s_allocate(VALUE klass)
}
static VALUE
-create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv)
+create_win32ole_object(klass, pDispatch, argc, argv)
+ VALUE klass;
+ IDispatch *pDispatch;
+ int argc;
+ VALUE *argv;
{
VALUE obj = fole_s_allocate(klass);
ole_set_member(obj, pDispatch);
@@ -1617,40 +1017,8 @@ create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv)
}
static VALUE
-ary_new_dim(VALUE myary, long *pid, long *plb, long dim) {
- long i;
- VALUE obj = Qnil;
- VALUE pobj = Qnil;
- long *ids = ALLOC_N(long, dim);
- if (!ids) {
- rb_raise(rb_eRuntimeError, "memory allocation error");
- }
- for(i = 0; i < dim; i++) {
- ids[i] = pid[i] - plb[i];
- }
- obj = myary;
- pobj = myary;
- for(i = 0; i < dim-1; i++) {
- obj = rb_ary_entry(pobj, ids[i]);
- if (obj == Qnil) {
- rb_ary_store(pobj, ids[i], rb_ary_new());
- }
- obj = rb_ary_entry(pobj, ids[i]);
- pobj = obj;
- }
- if (ids) free(ids);
- return obj;
-}
-
-static void
-ary_store_dim(VALUE myary, long *pid, long *plb, long dim, VALUE val) {
- long id = pid[dim - 1] - plb[dim - 1];
- VALUE obj = ary_new_dim(myary, pid, plb, dim);
- rb_ary_store(obj, id, val);
-}
-
-static VALUE
-ole_variant2val(VARIANT *pvar)
+ole_variant2val(pvar)
+ VARIANT *pvar;
{
VALUE obj = Qnil;
HRESULT hr;
@@ -1659,70 +1027,75 @@ ole_variant2val(VARIANT *pvar)
if(V_ISARRAY(pvar)) {
SAFEARRAY *psa = V_ISBYREF(pvar) ? *V_ARRAYREF(pvar) : V_ARRAY(pvar);
- UINT i = 0;
- long *pid, *plb, *pub;
+ long i;
+ long *pID, *pLB, *pUB;
VARIANT variant;
VALUE val;
- UINT dim = 0;
+ VALUE val2;
+ int dim = 0;
+
if (!psa) {
return obj;
}
dim = SafeArrayGetDim(psa);
+
VariantInit(&variant);
V_VT(&variant) = (V_VT(pvar) & ~VT_ARRAY) | VT_BYREF;
- pid = ALLOC_N(long, dim);
- plb = ALLOC_N(long, dim);
- pub = ALLOC_N(long, dim);
+ pID = ALLOC_N(long, dim);
+ pLB = ALLOC_N(long, dim);
+ pUB = ALLOC_N(long, dim);
- if(!pid || !plb || !pub) {
- if(pid) free(pid);
- if(plb) free(plb);
- if(pub) free(pub);
+ if(!pID || !pLB || !pUB) {
+ if(pID) free(pID);
+ if(pLB) free(pLB);
+ if(pUB) free(pUB);
rb_raise(rb_eRuntimeError, "memory allocation error");
}
+ obj = Qnil;
+
for(i = 0; i < dim; ++i) {
- SafeArrayGetLBound(psa, i+1, &plb[i]);
- SafeArrayGetLBound(psa, i+1, &pid[i]);
- SafeArrayGetUBound(psa, i+1, &pub[i]);
+ SafeArrayGetLBound(psa, i+1, &pLB[i]);
+ SafeArrayGetLBound(psa, i+1, &pID[i]);
+ SafeArrayGetUBound(psa, i+1, &pUB[i]);
}
+
hr = SafeArrayLock(psa);
if (SUCCEEDED(hr)) {
- obj = rb_ary_new();
- i = 0;
- while (i < dim) {
- ary_new_dim(obj, pid, plb, dim);
- hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant));
- if (SUCCEEDED(hr)) {
- val = ole_variant2val(&variant);
- ary_store_dim(obj, pid, plb, dim, val);
- }
- for (i = 0; i < dim; ++i) {
- if (++pid[i] <= pub[i])
+ val2 = rb_ary_new();
+ while (i >= 0) {
+ hr = SafeArrayPtrOfIndex(psa, pID, &V_BYREF(&variant));
+ if (FAILED(hr))
+ break;
+
+ val = ole_variant2val(&variant);
+ rb_ary_push(val2, val);
+ for (i = dim-1 ; i >= 0 ; --i) {
+ if (++pID[i] <= pUB[i])
break;
- pid[i] = plb[i];
+
+ pID[i] = pLB[i];
+ if (i > 0) {
+ if (obj == Qnil)
+ obj = rb_ary_new();
+ rb_ary_push(obj, val2);
+ val2 = rb_ary_new();
+ }
}
}
SafeArrayUnlock(psa);
}
- if(pid) free(pid);
- if(plb) free(plb);
- if(pub) free(pub);
- return obj;
+ if(pID) free(pID);
+ if(pLB) free(pLB);
+ if(pUB) free(pUB);
+ return (obj == Qnil) ? val2 : obj;
}
switch(V_VT(pvar) & ~VT_BYREF){
case VT_EMPTY:
break;
case VT_NULL:
break;
- case VT_I1:
- if(V_ISBYREF(pvar))
- obj = INT2NUM((long)*V_I1REF(pvar));
- else
- obj = INT2NUM((long)V_I1(pvar));
- break;
-
case VT_UI1:
if(V_ISBYREF(pvar))
obj = INT2NUM((long)*V_UI1REF(pvar));
@@ -1737,13 +1110,6 @@ ole_variant2val(VARIANT *pvar)
obj = INT2NUM((long)V_I2(pvar));
break;
- case VT_UI2:
- if(V_ISBYREF(pvar))
- obj = INT2NUM((long)*V_UI2REF(pvar));
- else
- obj = INT2NUM((long)V_UI2(pvar));
- break;
-
case VT_I4:
if(V_ISBYREF(pvar))
obj = INT2NUM((long)*V_I4REF(pvar));
@@ -1751,50 +1117,6 @@ ole_variant2val(VARIANT *pvar)
obj = INT2NUM((long)V_I4(pvar));
break;
- case VT_UI4:
- if(V_ISBYREF(pvar))
- obj = INT2NUM((long)*V_UI4REF(pvar));
- else
- obj = INT2NUM((long)V_UI4(pvar));
- break;
-
- case VT_INT:
- if(V_ISBYREF(pvar))
- obj = INT2NUM((long)*V_INTREF(pvar));
- else
- obj = INT2NUM((long)V_INT(pvar));
- break;
-
- case VT_UINT:
- if(V_ISBYREF(pvar))
- obj = INT2NUM((long)*V_UINTREF(pvar));
- else
- obj = INT2NUM((long)V_UINT(pvar));
- break;
-
-#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
- case VT_I8:
- if(V_ISBYREF(pvar))
-#if (_MSC_VER >= 1300)
- obj = I8_2_NUM(*V_I8REF(pvar));
-#else
- obj = Qnil;
-#endif
- else
- obj = I8_2_NUM(V_I8(pvar));
- break;
- case VT_UI8:
- if(V_ISBYREF(pvar))
-#if (_MSC_VER >= 1300)
- obj = UI8_2_NUM(*V_UI8REF(pvar));
-#else
- obj = Qnil;
-#endif
- else
- obj = UI8_2_NUM(V_UI8(pvar));
- break;
-#endif /* (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) */
-
case VT_R4:
if(V_ISBYREF(pvar))
obj = rb_float_new(*V_R4REF(pvar));
@@ -1892,7 +1214,7 @@ ole_variant2val(VARIANT *pvar)
VARIANT variant;
VariantInit(&variant);
hr = VariantChangeTypeEx(&variant, pvar,
- cWIN32OLE_lcid, 0, VT_BSTR);
+ LOCALE_SYSTEM_DEFAULT, 0, VT_BSTR);
if (SUCCEEDED(hr) && V_VT(&variant) == VT_BSTR) {
char *p = ole_wc2mb(V_BSTR(&variant));
obj = rb_str_new2(p);
@@ -1905,23 +1227,30 @@ ole_variant2val(VARIANT *pvar)
return obj;
}
-static LONG
-reg_open_key(HKEY hkey, const char *name, HKEY *phkey)
+
+static LONG reg_open_key(hkey, name, phkey)
+ HKEY hkey;
+ const char *name;
+ HKEY *phkey;
{
return RegOpenKeyEx(hkey, name, 0, KEY_READ, phkey);
}
-static LONG
-reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey)
+static LONG reg_open_vkey(hkey, key, phkey)
+ HKEY hkey;
+ VALUE key;
+ HKEY *phkey;
{
return reg_open_key(hkey, StringValuePtr(key), phkey);
}
static VALUE
-reg_enum_key(HKEY hkey, DWORD i)
+reg_enum_key(hkey, i)
+ HKEY hkey;
+ DWORD i;
{
char buf[BUFSIZ + 1];
- DWORD size_buf = sizeof(buf);
+ DWORD size_buf = sizeof(buf) - 1;
FILETIME ft;
LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf,
NULL, NULL, NULL, &ft);
@@ -1933,84 +1262,59 @@ reg_enum_key(HKEY hkey, DWORD i)
}
static VALUE
-reg_get_val(HKEY hkey, const char *subkey)
-{
- char *pbuf;
- DWORD dwtype = 0;
- LONG size = 0;
- VALUE val = Qnil;
- LONG err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, NULL, &size);
-
- if (err == ERROR_SUCCESS) {
- pbuf = ALLOC_N(char, size + 1);
- err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, pbuf, &size);
- if (err == ERROR_SUCCESS) {
- pbuf[size] = '\0';
- val = rb_str_new2(pbuf);
- }
- free(pbuf);
- }
- return val;
-}
-
-static VALUE
-reg_get_val2(HKEY hkey, const char *subkey)
+reg_get_val(hkey, subkey)
+ HKEY hkey;
+ const char *subkey;
{
- HKEY hsubkey;
- LONG err;
- VALUE val = Qnil;
- err = RegOpenKeyEx(hkey, subkey, 0, KEY_READ, &hsubkey);
+ char buf[BUFSIZ + 1];
+ LONG size_buf = sizeof(buf) - 1;
+ LONG err = RegQueryValue(hkey, subkey, buf, &size_buf);
if (err == ERROR_SUCCESS) {
- val = reg_get_val(hsubkey, NULL);
- RegCloseKey(hsubkey);
- }
- if (val == Qnil) {
- val = reg_get_val(hkey, subkey);
- }
- return val;
-}
-
-static VALUE
-reg_get_typelib_file_path(HKEY hkey)
-{
- VALUE path = Qnil;
- path = reg_get_val2(hkey, "win32");
- if (path == Qnil) {
- path = reg_get_val2(hkey, "win16");
+ buf[BUFSIZ] = '\0';
+ return rb_str_new2(buf);
}
- return path;
+ return Qnil;
}
static VALUE
-typelib_file_from_clsid(VALUE ole)
+typelib_file_from_clsid(ole)
+ VALUE ole;
{
+ OLECHAR *pbuf;
+ CLSID clsid;
+ HRESULT hr;
HKEY hroot, hclsid;
LONG err;
VALUE typelib;
- char path[MAX_PATH + 1];
+ VALUE vclsid;
+ char *pclsid = NULL;
+ pbuf = ole_mb2wc(StringValuePtr(ole), -1);
+ hr = CLSIDFromProgID(pbuf, &clsid);
+ SysFreeString(pbuf);
+ if (FAILED(hr)) {
+ return Qnil;
+ }
+ StringFromCLSID(&clsid, &pbuf);
+ vclsid = WC2VSTR(pbuf);
err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hroot);
if (err != ERROR_SUCCESS) {
return Qnil;
}
- err = reg_open_key(hroot, StringValuePtr(ole), &hclsid);
+ err = reg_open_key(hroot, StringValuePtr(vclsid), &hclsid);
if (err != ERROR_SUCCESS) {
RegCloseKey(hroot);
return Qnil;
}
- typelib = reg_get_val2(hclsid, "InprocServer32");
+ typelib = reg_get_val(hclsid, "InprocServer32");
RegCloseKey(hroot);
RegCloseKey(hclsid);
- if (typelib != Qnil) {
- ExpandEnvironmentStrings(StringValuePtr(typelib), path, sizeof(path));
- path[MAX_PATH] = '\0';
- typelib = rb_str_new2(path);
- }
return typelib;
}
static VALUE
-typelib_file_from_typelib(VALUE ole)
+typelib_file_from_typelib(ole)
+ VALUE ole;
{
HKEY htypelib, hclsid, hversion, hlang;
double fver;
@@ -2040,7 +1344,7 @@ typelib_file_from_typelib(VALUE ole)
if (ver == Qnil)
break;
err = reg_open_vkey(hclsid, ver, &hversion);
- if (err != ERROR_SUCCESS || fver > atof(StringValuePtr(ver)))
+ if (err != ERROR_SUCCESS || fver > atof(StringValuePtr(ver)))
continue;
fver = atof(StringValuePtr(ver));
typelib = reg_get_val(hversion, NULL);
@@ -2053,7 +1357,7 @@ typelib_file_from_typelib(VALUE ole)
break;
err = reg_open_vkey(hversion, lang, &hlang);
if (err == ERROR_SUCCESS) {
- if ((file = reg_get_typelib_file_path(hlang)) != Qnil)
+ if ((file = reg_get_val(hlang, "win32")) != Qnil)
found = TRUE;
RegCloseKey(hlang);
}
@@ -2068,7 +1372,8 @@ typelib_file_from_typelib(VALUE ole)
}
static VALUE
-typelib_file(VALUE ole)
+typelib_file(ole)
+ VALUE ole;
{
VALUE file = typelib_file_from_clsid(ole);
if (file != Qnil) {
@@ -2078,7 +1383,10 @@ typelib_file(VALUE ole)
}
static void
-ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self)
+ole_const_load(pTypeLib, klass, self)
+ ITypeLib *pTypeLib;
+ VALUE klass;
+ VALUE self;
{
unsigned int count;
unsigned int index;
@@ -2141,7 +1449,10 @@ ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self)
}
static HRESULT
-clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid)
+clsid_from_remote(host, com, pclsid)
+ VALUE host;
+ VALUE com;
+ CLSID *pclsid;
{
HKEY hlm;
HKEY hpid;
@@ -2163,7 +1474,7 @@ clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid)
hr = HRESULT_FROM_WIN32(err);
else {
len = sizeof(clsid);
- err = RegQueryValueEx(hpid, (LPBYTE)"", NULL, &dwtype, clsid, &len);
+ err = RegQueryValueEx(hpid, "", NULL, &dwtype, clsid, &len);
if (err == ERROR_SUCCESS && dwtype == REG_SZ) {
pbuf = ole_mb2wc(clsid, -1);
hr = CLSIDFromString(pbuf, pclsid);
@@ -2179,7 +1490,10 @@ clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid)
}
static VALUE
-ole_create_dcom(int argc, VALUE *argv, VALUE self)
+ole_create_dcom(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE ole, host, others;
HRESULT hr;
@@ -2209,7 +1523,7 @@ ole_create_dcom(int argc, VALUE *argv, VALUE self)
hr = CLSIDFromString(pbuf, &clsid);
SysFreeString(pbuf);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"unknown OLE server: `%s'",
StringValuePtr(ole));
memset(&serverinfo, 0, sizeof(COSERVERINFO));
@@ -2219,7 +1533,7 @@ ole_create_dcom(int argc, VALUE *argv, VALUE self)
hr = gCoCreateInstanceEx(&clsid, NULL, clsctx, &serverinfo, 1, &multi_qi);
SysFreeString(serverinfo.pwszName);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to create DCOM server `%s' in `%s'",
StringValuePtr(ole),
StringValuePtr(host));
@@ -2229,7 +1543,11 @@ ole_create_dcom(int argc, VALUE *argv, VALUE self)
}
static VALUE
-ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
+ole_bind_obj(moniker, argc, argv, self)
+ VALUE moniker;
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
IBindCtx *pBindCtx;
IMoniker *pMoniker;
@@ -2242,7 +1560,7 @@ ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
hr = CreateBindCtx(0, &pBindCtx);
if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to create bind context");
}
@@ -2251,7 +1569,7 @@ ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
SysFreeString(pbuf);
if(FAILED(hr)) {
OLE_RELEASE(pBindCtx);
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to parse display name of moniker `%s'",
StringValuePtr(moniker));
}
@@ -2262,7 +1580,7 @@ ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
OLE_RELEASE(pBindCtx);
if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to bind moniker `%s'",
StringValuePtr(moniker));
}
@@ -2279,7 +1597,10 @@ ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
* WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel.
*/
static VALUE
-fole_s_connect(int argc, VALUE *argv, VALUE self)
+fole_s_connect(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE svr_name;
VALUE others;
@@ -2294,7 +1615,7 @@ fole_s_connect(int argc, VALUE *argv, VALUE self)
ole_initialize();
rb_scan_args(argc, argv, "1*", &svr_name, &others);
- if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) {
+ if (ruby_safe_level > 0 && OBJ_TAINTED(svr_name)) {
rb_raise(rb_eSecurityError, "Insecure Object Connection - %s",
StringValuePtr(svr_name));
}
@@ -2312,14 +1633,14 @@ fole_s_connect(int argc, VALUE *argv, VALUE self)
hr = GetActiveObject(&clsid, 0, &pUnknown);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"OLE server `%s' not running", StringValuePtr(svr_name));
}
hr = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IDispatch,
(void **)&pDispatch);
if(FAILED(hr)) {
OLE_RELEASE(pUnknown);
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to create WIN32OLE server `%s'",
StringValuePtr(svr_name));
}
@@ -2359,7 +1680,10 @@ fole_s_connect(int argc, VALUE *argv, VALUE self)
* puts MSO::MsoLineSingle # => 1
*/
static VALUE
-fole_s_const_load(int argc, VALUE *argv, VALUE self)
+fole_s_const_load(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE ole;
VALUE klass;
@@ -2370,7 +1694,7 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
HRESULT hr;
OLECHAR *pBuf;
VALUE file;
- LCID lcid = cWIN32OLE_lcid;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
rb_secure(4);
rb_scan_args(argc, argv, "11", &ole, &klass);
@@ -2409,7 +1733,7 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib);
SysFreeString(pBuf);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
if(TYPE(klass) != T_NIL) {
ole_const_load(pTypeLib, klass, self);
}
@@ -2425,7 +1749,9 @@ fole_s_const_load(int argc, VALUE *argv, VALUE self)
}
static VALUE
-ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes)
+ole_classes_from_typelib(pTypeLib, classes)
+ ITypeLib *pTypeLib;
+ VALUE classes;
{
long count;
@@ -2457,7 +1783,8 @@ ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes)
}
static ULONG
-reference_count(struct oledata * pole)
+reference_count(pole)
+ struct oledata * pole;
{
ULONG n = 0;
if(pole->pDispatch) {
@@ -2476,7 +1803,9 @@ reference_count(struct oledata * pole)
* exists only for debugging WIN32OLE.
*/
static VALUE
-fole_s_reference_count(VALUE self, VALUE obj)
+fole_s_reference_count(self, obj)
+ VALUE self;
+ VALUE obj;
{
struct oledata * pole;
OLEData_Get_Struct(obj, pole);
@@ -2493,7 +1822,9 @@ fole_s_reference_count(VALUE self, VALUE obj)
* The return value is reference counter of OLE object.
*/
static VALUE
-fole_s_free(VALUE self, VALUE obj)
+fole_s_free(self, obj)
+ VALUE self;
+ VALUE obj;
{
ULONG n = 0;
struct oledata * pole;
@@ -2507,7 +1838,9 @@ fole_s_free(VALUE self, VALUE obj)
}
static HWND
-ole_show_help(VALUE helpfile, VALUE helpcontext)
+ole_show_help(helpfile, helpcontext)
+ VALUE helpfile;
+ VALUE helpcontext;
{
FNHTMLHELP *pfnHtmlHelp;
HWND hwnd = 0;
@@ -2539,7 +1872,10 @@ ole_show_help(VALUE helpfile, VALUE helpcontext)
* WIN32OLE.ole_show_help(typeobj)
*/
static VALUE
-fole_s_show_help(int argc, VALUE *argv, VALUE self)
+fole_s_show_help(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE target;
VALUE helpcontext;
@@ -2578,60 +1914,41 @@ fole_s_show_help(int argc, VALUE *argv, VALUE self)
* WIN32OLE.codepage # => WIN32OLE::CP_ACP
*/
static VALUE
-fole_s_get_code_page(VALUE self)
+fole_s_get_code_page(self)
+ VALUE self;
{
return INT2FIX(cWIN32OLE_cp);
}
-static BOOL CALLBACK
-installed_code_page_proc(LPTSTR str) {
- if (strtoul(str, NULL, 10) == g_cp_to_check) {
- g_cp_installed = TRUE;
- return FALSE;
- }
- return TRUE;
-}
-
-static BOOL
-code_page_installed(UINT cp)
-{
- g_cp_installed = FALSE;
- g_cp_to_check = cp;
- EnumSystemCodePages(installed_code_page_proc, CP_INSTALLED);
- return g_cp_installed;
-}
-
/*
* call-seq:
* WIN32OLE.codepage = CP
*
* Sets current codepage.
* WIN32OLE.codepage = WIN32OLE::CP_UTF8
- * WIN32OLE.codepage = 20932
*/
static VALUE
-fole_s_set_code_page(VALUE self, VALUE vcp)
+fole_s_set_code_page(self, vcp)
+ VALUE self;
+ VALUE vcp;
{
UINT cp = FIX2INT(vcp);
- if (code_page_installed(cp)) {
+ switch(cp) {
+ case CP_ACP:
+ case CP_OEMCP:
+ case CP_MACCP:
+ case CP_THREAD_ACP:
+ case CP_SYMBOL:
+ case CP_UTF7:
+ case CP_UTF8:
cWIN32OLE_cp = cp;
- } else {
- switch(cp) {
- case CP_ACP:
- case CP_OEMCP:
- case CP_MACCP:
- case CP_THREAD_ACP:
- case CP_SYMBOL:
- case CP_UTF7:
- case CP_UTF8:
- cWIN32OLE_cp = cp;
- break;
- default:
- rb_raise(eWIN32OLERuntimeError, "codepage should be WIN32OLE::CP_ACP, WIN32OLE::CP_OEMCP, WIN32OLE::CP_MACCP, WIN32OLE::CP_THREAD_ACP, WIN32OLE::CP_SYMBOL, WIN32OLE::CP_UTF7, WIN32OLE::CP_UTF8, or installed codepage.");
- break;
- }
+ break;
+ default:
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "codepage should be WIN32OLE::CP_ACP, WIN32OLE::CP_OEMCP, WIN32OLE::CP_MACCP, WIN32OLE::CP_THREAD_ACP, WIN32OLE::CP_SYMBOL, WIN32OLE::CP_UTF7, WIN32OLE::CP_UTF8");
+ break;
}
+
/*
* Should this method return old codepage?
*/
@@ -2639,131 +1956,9 @@ fole_s_set_code_page(VALUE self, VALUE vcp)
}
/*
- * call-seq:
- * WIN32OLE.locale -> locale id.
- *
- * Returns current locale id (lcid). The default locale is
- * LOCALE_SYSTEM_DEFAULT.
- *
- * lcid = WIN32OLE.locale
- */
-static VALUE
-fole_s_get_locale(VALUE self)
-{
- return INT2FIX(cWIN32OLE_lcid);
-}
-
-static BOOL
-CALLBACK installed_lcid_proc(LPTSTR str)
-{
- if (strcmp(str, g_lcid_to_check) == 0) {
- g_lcid_installed = TRUE;
- return FALSE;
- }
- return TRUE;
-}
-
-static BOOL
-lcid_installed(LCID lcid)
-{
- g_lcid_installed = FALSE;
- snprintf(g_lcid_to_check, sizeof(g_lcid_to_check), "%08lx", lcid);
- EnumSystemLocales(installed_lcid_proc, LCID_INSTALLED);
- return g_lcid_installed;
-}
-
-/*
- * call-seq:
- * WIN32OLE.locale = lcid
- *
- * Sets current locale id (lcid).
- *
- * WIN32OLE.locale = 1033 # set locale English(U.S)
- * obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
- *
- */
-static VALUE
-fole_s_set_locale(VALUE self, VALUE vlcid)
-{
- LCID lcid = FIX2INT(vlcid);
- if (lcid_installed(lcid)) {
- cWIN32OLE_lcid = lcid;
- } else {
- switch (lcid) {
- case LOCALE_SYSTEM_DEFAULT:
- case LOCALE_USER_DEFAULT:
- cWIN32OLE_lcid = lcid;
- break;
- default:
- rb_raise(eWIN32OLERuntimeError, "not installed locale: %u", (unsigned int)lcid);
- }
- }
- return Qnil;
-}
-
-/*
- * call-seq:
- * WIN32OLE.create_guid
- *
- * Creates GUID.
- * WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8}
- */
-static VALUE
-fole_s_create_guid(VALUE self)
-{
- GUID guid;
- HRESULT hr;
- OLECHAR bstr[80];
- int len = 0;
- hr = CoCreateGuid(&guid);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to create GUID");
- }
- len = StringFromGUID2(&guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
- if (len == 0) {
- rb_raise(rb_eRuntimeError, "failed to create GUID(buffer over)");
- }
- return ole_wc2vstr(bstr, FALSE);
-}
-
-/*
* Document-class: WIN32OLE
*
* <code>WIN32OLE</code> objects represent OLE Automation object in Ruby.
- *
- * By using WIN32OLE, you can access OLE server like VBScript.
- *
- * Here is sample script.
- *
- * require 'win32ole'
- *
- * excel = WIN32OLE.new('Excel.Application')
- * excel.visible = true
- * workbook = excel.Workbooks.Add();
- * worksheet = workbook.Worksheets(1);
- * worksheet.Range("A1:D1").value = ["North","South","East","West"];
- * worksheet.Range("A2:B2").value = [5.2, 10];
- * worksheet.Range("C2").value = 8;
- * worksheet.Range("D2").value = 20;
- *
- * range = worksheet.Range("A1:D2");
- * range.select
- * chart = workbook.Charts.Add;
- *
- * workbook.saved = true;
- *
- * excel.ActiveWorkbook.Close(0);
- * excel.Quit();
- *
- * Unfortunately, Win32OLE doesn't support the argument passed by
- * reference directly.
- * Instead, Win32OLE provides WIN32OLE::ARGV.
- * If you want to get the result value of argument passed by reference,
- * you can use WIN32OLE::ARGV.
- *
- * oleobj.method(arg1, arg2, refargv3)
- * puts WIN32OLE::ARGV[2] # the value of refargv3 after called oleobj.method
- *
*/
/*
@@ -2780,7 +1975,10 @@ fole_s_create_guid(VALUE self)
* WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object.
*/
static VALUE
-fole_initialize(int argc, VALUE *argv, VALUE self)
+fole_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE svr_name;
VALUE host;
@@ -2794,12 +1992,12 @@ fole_initialize(int argc, VALUE *argv, VALUE self)
rb_call_super(0, 0);
rb_scan_args(argc, argv, "11*", &svr_name, &host, &others);
- if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) {
+ if (ruby_safe_level > 0 && OBJ_TAINTED(svr_name)) {
rb_raise(rb_eSecurityError, "Insecure Object Creation - %s",
StringValuePtr(svr_name));
}
if (!NIL_P(host)) {
- if (rb_safe_level() > 0 && OBJ_TAINTED(host)) {
+ if (ruby_safe_level > 0 && OBJ_TAINTED(host)) {
rb_raise(rb_eSecurityError, "Insecure Object Creation - %s",
StringValuePtr(svr_name));
}
@@ -2814,7 +2012,7 @@ fole_initialize(int argc, VALUE *argv, VALUE self)
}
SysFreeString(pBuf);
if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"unknown OLE server: `%s'",
StringValuePtr(svr_name));
}
@@ -2823,7 +2021,7 @@ fole_initialize(int argc, VALUE *argv, VALUE self)
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
&IID_IDispatch, (void**)&pDispatch);
if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to create WIN32OLE object from `%s'",
StringValuePtr(svr_name));
}
@@ -2833,17 +2031,19 @@ fole_initialize(int argc, VALUE *argv, VALUE self)
}
static VALUE
-hash2named_arg(VALUE pair, struct oleparam* pOp)
+hash2named_arg(pair, pOp)
+ VALUE pair;
+ struct oleparam* pOp;
{
unsigned int index, i;
VALUE key, value;
index = pOp->dp.cNamedArgs;
- /*---------------------------------------------
- the data-type of key must be String or Symbol
- -----------------------------------------------*/
+ /*-------------------------------------
+ the data-type of key must be String
+ ---------------------------------------*/
key = rb_ary_entry(pair, 0);
- if(TYPE(key) != T_STRING && TYPE(key) != T_SYMBOL) {
+ if(TYPE(key) != T_STRING) {
/* clear name of dispatch parameters */
for(i = 1; i < index + 1; i++) {
SysFreeString(pOp->pNamedArgs[i]);
@@ -2853,10 +2053,7 @@ hash2named_arg(VALUE pair, struct oleparam* pOp)
VariantClear(&(pOp->dp.rgvarg[i]));
}
/* raise an exception */
- rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
- }
- if (TYPE(key) == T_SYMBOL) {
- key = rb_str_new2(rb_id2name(SYM2ID(key)));
+ Check_Type(key, T_STRING);
}
/* pNamedArgs[0] is <method name>, so "index + 1" */
@@ -2871,7 +2068,9 @@ hash2named_arg(VALUE pair, struct oleparam* pOp)
}
static VALUE
-set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end)
+set_argv(realargs, beg, end)
+ VARIANTARG* realargs;
+ unsigned int beg, end;
{
VALUE argv = rb_const_get(cWIN32OLE, rb_intern("ARGV"));
@@ -2885,9 +2084,13 @@ set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end)
}
static VALUE
-ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
+ole_invoke(argc, argv, self, wFlags)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+ USHORT wFlags;
{
- LCID lcid = cWIN32OLE_lcid;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
struct oledata *pole;
HRESULT hr;
VALUE cmd;
@@ -2908,7 +2111,6 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
unsigned int cNamedArgs;
int n;
struct oleparam op;
- struct olevariantdata *pvar;
memset(&excepinfo, 0, sizeof(EXCEPINFO));
VariantInit(&result);
@@ -2923,20 +2125,14 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
if(!pole->pDispatch) {
rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
}
- if (is_bracket) {
- DispID = DISPID_VALUE;
- argc += 1;
- rb_funcall(paramS, rb_intern("unshift"), 1, cmd);
- } else {
- wcmdname = ole_mb2wc(StringValuePtr(cmd), -1);
- hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
- &wcmdname, 1, lcid, &DispID);
- SysFreeString(wcmdname);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "unknown property or method: `%s'",
- StringValuePtr(cmd));
- }
+ wcmdname = ole_mb2wc(StringValuePtr(cmd), -1);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
+ &wcmdname, 1, lcid, &DispID);
+ SysFreeString(wcmdname);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "unknown property or method `%s'",
+ StringValuePtr(cmd));
}
/* pick up last argument of method */
@@ -2953,7 +2149,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
op.dp.cArgs = cNamedArgs + argc - 2;
op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
- rb_block_call(param, rb_intern("each"), 0, 0, hash2named_arg, (VALUE)&op);
+ rb_iterate(rb_each, param, hash2named_arg, (VALUE)&op);
pDispID = ALLOCA_N(DISPID, cNamedArgs + 1);
op.pNamedArgs[0] = ole_mb2wc(StringValuePtr(cmd), -1);
@@ -2971,7 +2167,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
for(i = 0; i < op.dp.cArgs; i++ ) {
VariantClear(&op.dp.rgvarg[i]);
}
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"failed to get named argument info: `%s'",
StringValuePtr(cmd));
}
@@ -2995,20 +2191,17 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
VariantInit(&realargs[n]);
VariantInit(&op.dp.rgvarg[n]);
param = rb_ary_entry(paramS, i-cNamedArgs);
- if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
- Data_Get_Struct(param, struct olevariantdata, pvar);
- VariantCopy(&op.dp.rgvarg[n], &(pvar->var));
- } else {
- ole_val2variant(param, &realargs[n]);
- V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF;
- V_VARIANTREF(&op.dp.rgvarg[n]) = &realargs[n];
- }
+
+ ole_val2variant(param, &realargs[n]);
+ V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF;
+ V_VARIANTREF(&op.dp.rgvarg[n]) = &realargs[n];
+
}
}
/* apparent you need to call propput, you need this */
if (wFlags & DISPATCH_PROPERTYPUT) {
if (op.dp.cArgs == 0)
- ole_raise(ResultFromScode(E_INVALIDARG), eWIN32OLERuntimeError, "argument error");
+ return ResultFromScode(E_INVALIDARG);
op.dp.cNamedArgs = 1;
op.dp.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
@@ -3018,7 +2211,6 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
&IID_NULL, lcid, wFlags, &op.dp,
&result, &excepinfo, &argErr);
-
if (FAILED(hr)) {
/* retry to call args by value */
if(op.dp.cArgs >= cNamedArgs) {
@@ -3027,6 +2219,9 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
param = rb_ary_entry(paramS, i-cNamedArgs);
ole_val2variant(param, &op.dp.rgvarg[n]);
}
+ if (hr == DISP_E_EXCEPTION) {
+ ole_freeexceptinfo(&excepinfo);
+ }
memset(&excepinfo, 0, sizeof(EXCEPINFO));
VariantInit(&result);
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
@@ -3039,19 +2234,20 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
* hResult == DISP_E_EXCEPTION. this only happens on
* functions whose DISPID > 0x8000 */
if ((hr == DISP_E_EXCEPTION || hr == DISP_E_MEMBERNOTFOUND) && DispID > 0x8000) {
+ if (hr == DISP_E_EXCEPTION) {
+ ole_freeexceptinfo(&excepinfo);
+ }
memset(&excepinfo, 0, sizeof(EXCEPINFO));
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
&IID_NULL, lcid, wFlags,
&op.dp, NULL,
&excepinfo, &argErr);
-
}
for(i = cNamedArgs; i < op.dp.cArgs; i++) {
n = op.dp.cArgs - i + cNamedArgs - 1;
VariantClear(&op.dp.rgvarg[n]);
}
}
-
if (FAILED(hr)) {
/* retry after converting nil to VT_EMPTY */
if (op.dp.cArgs > cNamedArgs) {
@@ -3060,6 +2256,9 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
param = rb_ary_entry(paramS, i-cNamedArgs);
ole_val2variant2(param, &op.dp.rgvarg[n]);
}
+ if (hr == DISP_E_EXCEPTION) {
+ ole_freeexceptinfo(&excepinfo);
+ }
memset(&excepinfo, 0, sizeof(EXCEPINFO));
VariantInit(&result);
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
@@ -3076,13 +2275,6 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
}
/* clear dispatch parameter */
if(op.dp.cArgs > cNamedArgs) {
- for(i = cNamedArgs; i < op.dp.cArgs; i++) {
- n = op.dp.cArgs - i + cNamedArgs - 1;
- param = rb_ary_entry(paramS, i-cNamedArgs);
- if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
- ole_val2variant(param, &realargs[n]);
- }
- }
set_argv(realargs, cNamedArgs, op.dp.cArgs);
}
else {
@@ -3093,9 +2285,8 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
if (FAILED(hr)) {
v = ole_excepinfo2msg(&excepinfo);
- ole_raise(hr, eWIN32OLERuntimeError, "(in OLE method `%s': )%s",
- StringValuePtr(cmd),
- StringValuePtr(v));
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "%s%s",
+ StringValuePtr(cmd), StringValuePtr(v));
}
obj = ole_variant2val(&result);
VariantClear(&result);
@@ -3116,13 +2307,21 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
*
*/
static VALUE
-fole_invoke(int argc, VALUE *argv, VALUE self)
+fole_invoke(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+ return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET);
}
static VALUE
-ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
+ole_invoke2(self, dispid, args, types, dispkind)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
+ USHORT dispkind;
{
HRESULT hr;
struct oledata *pole;
@@ -3145,7 +2344,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
VariantInit(&result);
OLEData_Get_Struct(self, pole);
- dispParams.cArgs = RARRAY_LEN(args);
+ dispParams.cArgs = RARRAY(args)->len;
dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs);
realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs);
for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--)
@@ -3176,7 +2375,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
SAFEARRAYBOUND rgsabound[1];
Check_Type(param, T_ARRAY);
rgsabound[0].lLbound = 0;
- rgsabound[0].cElements = RARRAY_LEN(param);
+ rgsabound[0].cElements = RARRAY(param)->len;
v = vt & ~(VT_ARRAY | VT_BYREF);
V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound);
V_VT(&realargs[i]) = VT_ARRAY | v;
@@ -3194,7 +2393,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
if (v != VT_VARIANT)
{
VariantChangeTypeEx(&velem, &velem,
- cWIN32OLE_lcid, 0, v);
+ LOCALE_SYSTEM_DEFAULT, 0, v);
}
switch (v)
{
@@ -3233,7 +2432,7 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
if ((vt & (~VT_BYREF)) != VT_VARIANT)
{
hr = VariantChangeTypeEx(&realargs[i], &realargs[i],
- cWIN32OLE_lcid, 0,
+ LOCALE_SYSTEM_DEFAULT, 0,
(VARTYPE)(vt & (~VT_BYREF)));
if (hr != S_OK)
{
@@ -3289,15 +2488,14 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
}
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, NUM2INT(dispid),
- &IID_NULL, cWIN32OLE_lcid,
+ &IID_NULL, LOCALE_SYSTEM_DEFAULT,
dispkind,
&dispParams, &result,
&excepinfo, &argErr);
if (FAILED(hr)) {
v = ole_excepinfo2msg(&excepinfo);
- ole_raise(hr, eWIN32OLERuntimeError, "(in OLE method `<dispatch id:%d>': )%s",
- NUM2INT(dispid),
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "_invoke %s",
StringValuePtr(v));
}
@@ -3324,7 +2522,11 @@ ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
* excel._invoke(302, [], []) # same effect as excel.Quit
*/
static VALUE
-fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types)
+fole_invoke2(self, dispid, args, types)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
{
return ole_invoke2(self, dispid, args, types, DISPATCH_METHOD);
}
@@ -3342,7 +2544,11 @@ fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types)
* puts excel._getproperty(558, [], []) # same effect as puts excel.visible
*/
static VALUE
-fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
+fole_getproperty2(self, dispid, args, types)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
{
return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYGET);
}
@@ -3360,78 +2566,59 @@ fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
* excel._setproperty(558, [true], [WIN32OLE::VARIANT::VT_BOOL]) # same effect as excel.visible = true
*/
static VALUE
-fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
+fole_setproperty2(self, dispid, args, types)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
{
return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYPUT);
}
/*
* call-seq:
- * WIN32OLE[a1, a2, ...]=val
- *
- * Sets the value to WIN32OLE object specified by a1, a2, ...
- *
- * dict = WIN32OLE.new('Scripting.Dictionary')
- * dict.add('ruby', 'RUBY')
- * dict['ruby'] = 'Ruby'
- * puts dict['ruby'] # => 'Ruby'
- *
- * Remark: You can not use this method to set the property value.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * # excel['Visible'] = true # This is error !!!
- * excel.Visible = true # You should to use this style to set the property.
- *
- */
-static VALUE
-fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self)
-{
- return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, TRUE);
-}
-
-/*
- * call-seq:
+ * WIN32OLE['property']=val
* WIN32OLE.setproperty('property', [arg1, arg2,...] val)
*
* Sets property of OLE object.
* When you want to set property with argument, you can use this method.
*
* excel = WIN32OLE.new('Excel.Application')
- * excel.Visible = true
+ * excel['Visible'] = true
* book = excel.workbooks.add
* sheet = book.worksheets(1)
* sheet.setproperty('Cells', 1, 2, 10) # => The B1 cell value is 10.
*/
static VALUE
-fole_setproperty(int argc, VALUE *argv, VALUE self)
+fole_setproperty(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, FALSE);
+ return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT);
}
/*
* call-seq:
- * WIN32OLE[a1,a2,...]
+ * WIN32OLE['property']
*
- * Returns the value of Collection specified by a1, a2,....
+ * Returns property of OLE object.
*
- * dict = WIN32OLE.new('Scripting.Dictionary')
- * dict.add('ruby', 'Ruby')
- * puts dict['ruby'] # => 'Ruby' (same as `puts dict.item('ruby')')
- *
- * Remark: You can not use this method to get the property.
* excel = WIN32OLE.new('Excel.Application')
- * # puts excel['Visible'] This is error !!!
- * puts excel.Visible # You should to use this style to get the property.
- *
+ * puts excel['Visible'] # => false
*/
static VALUE
-fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self)
+fole_getproperty(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- return ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET, TRUE);
+ return ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET);
}
static VALUE
-ole_propertyput(VALUE self, VALUE property, VALUE value)
+ole_propertyput(self, property, value)
+ VALUE self, property, value;
{
struct oledata *pole;
unsigned argErr;
@@ -3445,7 +2632,7 @@ ole_propertyput(VALUE self, VALUE property, VALUE value)
VARIANTARG propertyValue[2];
OLECHAR* pBuf[1];
VALUE v;
- LCID lcid = cWIN32OLE_lcid;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
dispParams.rgdispidNamedArgs = &dispIDParam;
dispParams.rgvarg = propertyValue;
dispParams.cNamedArgs = 1;
@@ -3465,7 +2652,7 @@ ole_propertyput(VALUE self, VALUE property, VALUE value)
pBuf[0] = NULL;
if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"unknown property or method: `%s'",
StringValuePtr(property));
}
@@ -3480,9 +2667,7 @@ ole_propertyput(VALUE self, VALUE property, VALUE value)
}
if (FAILED(hr)) {
v = ole_excepinfo2msg(&excepinfo);
- ole_raise(hr, eWIN32OLERuntimeError, "(in setting property `%s': )%s",
- StringValuePtr(property),
- StringValuePtr(v));
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, StringValuePtr(v));
}
return Qnil;
}
@@ -3497,7 +2682,8 @@ ole_propertyput(VALUE self, VALUE property, VALUE value)
*
*/
static VALUE
-fole_free(VALUE self)
+fole_free(self)
+ VALUE self;
{
struct oledata *pole;
rb_secure(4);
@@ -3508,7 +2694,8 @@ fole_free(VALUE self)
}
static VALUE
-ole_each_sub(VALUE pEnumV)
+ole_each_sub(pEnumV)
+ VALUE pEnumV;
{
VARIANT variant;
VALUE obj = Qnil;
@@ -3524,7 +2711,8 @@ ole_each_sub(VALUE pEnumV)
}
static VALUE
-ole_ienum_free(VALUE pEnumV)
+ole_ienum_free(pEnumV)
+ VALUE pEnumV;
{
IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
OLE_RELEASE(pEnum);
@@ -3546,9 +2734,10 @@ ole_ienum_free(VALUE pEnumV)
* end
*/
static VALUE
-fole_each(VALUE self)
+fole_each(self)
+ VALUE self;
{
- LCID lcid = cWIN32OLE_lcid;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
struct oledata *pole;
@@ -3575,7 +2764,7 @@ fole_each(VALUE self)
if (FAILED(hr)) {
VariantClear(&result);
- ole_raise(hr, eWIN32OLERuntimeError, "failed to get IEnum Interface");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to get IEnum Interface");
}
if (V_VT(&result) == VT_UNKNOWN)
@@ -3603,10 +2792,13 @@ fole_each(VALUE self)
* Calls WIN32OLE#invoke method.
*/
static VALUE
-fole_missing(int argc, VALUE *argv, VALUE self)
+fole_missing(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
ID id;
- const char* mname;
+ char* mname;
int n;
id = rb_to_id(argv[0]);
mname = rb_id2name(id);
@@ -3621,12 +2813,16 @@ fole_missing(int argc, VALUE *argv, VALUE self)
}
else {
argv[0] = rb_str_new2(mname);
- return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+ return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET);
}
}
static VALUE
-ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE name)
+ole_method_sub(self, pOwnerTypeInfo, pTypeInfo, name)
+ VALUE self;
+ ITypeInfo *pOwnerTypeInfo;
+ ITypeInfo *pTypeInfo;
+ VALUE name;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -3637,7 +2833,7 @@ ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALU
VALUE method = Qnil;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) {
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
@@ -3663,7 +2859,10 @@ ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALU
}
static VALUE
-olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
+olemethod_from_typeinfo(self, pTypeInfo, name)
+ VALUE self;
+ ITypeInfo *pTypeInfo;
+ VALUE name;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -3673,7 +2872,7 @@ olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
VALUE method = Qnil;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
method = ole_method_sub(self, 0, pTypeInfo, name);
if (method != Qnil) {
@@ -3694,7 +2893,11 @@ olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
}
static VALUE
-ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask)
+ole_methods_sub(pOwnerTypeInfo, pTypeInfo, methods, mask)
+ ITypeInfo *pOwnerTypeInfo;
+ ITypeInfo *pTypeInfo;
+ VALUE methods;
+ int mask;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -3705,7 +2908,7 @@ ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods,
WORD i;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
for(i = 0; i < pTypeAttr->cFuncs; i++) {
pstr = NULL;
@@ -3734,7 +2937,9 @@ ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods,
}
static VALUE
-ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
+ole_methods_from_typeinfo(pTypeInfo, mask)
+ ITypeInfo *pTypeInfo;
+ int mask;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -3744,7 +2949,7 @@ ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
VALUE methods = rb_ary_new();
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
ole_methods_sub(0, pTypeInfo, methods, mask);
@@ -3763,7 +2968,9 @@ ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
}
static HRESULT
-typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti)
+typeinfo_from_ole(pole, ppti)
+ struct oledata *pole;
+ ITypeInfo **ppti;
{
ITypeInfo *pTypeInfo;
ITypeLib *pTypeLib;
@@ -3771,7 +2978,7 @@ typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti)
VALUE type;
UINT i;
UINT count;
- LCID lcid = cWIN32OLE_lcid;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
0, lcid, &pTypeInfo);
if(FAILED(hr)) {
@@ -3804,7 +3011,9 @@ typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti)
}
static VALUE
-ole_methods(VALUE self, int mask)
+ole_methods(self,mask)
+ VALUE self;
+ int mask;
{
ITypeInfo *pTypeInfo;
HRESULT hr;
@@ -3834,7 +3043,8 @@ ole_methods(VALUE self, int mask)
*
*/
static VALUE
-fole_methods(VALUE self)
+fole_methods( self )
+ VALUE self;
{
return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
}
@@ -3850,7 +3060,8 @@ fole_methods(VALUE self)
* properties = excel.ole_get_methods
*/
static VALUE
-fole_get_methods(VALUE self)
+fole_get_methods( self )
+ VALUE self;
{
return ole_methods( self, INVOKE_PROPERTYGET);
}
@@ -3866,9 +3077,10 @@ fole_get_methods(VALUE self)
* properties = excel.ole_put_methods
*/
static VALUE
-fole_put_methods(VALUE self)
+fole_put_methods( self )
+ VALUE self;
{
- return ole_methods( self, INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF);
+ return ole_methods( self, INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
}
/*
@@ -3876,58 +3088,39 @@ fole_put_methods(VALUE self)
* WIN32OLE#ole_func_methods
*
* Returns the array of WIN32OLE_METHOD object .
- * The element of the array is property (settable) of WIN32OLE object.
+ * The element of the array is functional method of WIN32OLE object.
*
* excel = WIN32OLE.new('Excel.Application')
* properties = excel.ole_func_methods
*
*/
static VALUE
-fole_func_methods(VALUE self)
+fole_func_methods( self )
+ VALUE self;
{
return ole_methods( self, INVOKE_FUNC);
}
-static VALUE
-ole_type_from_itypeinfo(ITypeInfo *pTypeInfo)
-{
- ITypeLib *pTypeLib;
- VALUE type = Qnil;
- HRESULT hr;
- unsigned int index;
- BSTR bstr;
-
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index );
- if(FAILED(hr)) {
- return Qnil;
- }
- hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index,
- &bstr, NULL, NULL, NULL);
- OLE_RELEASE(pTypeLib);
- if (FAILED(hr)) {
- return Qnil;
- }
- type = foletype_s_allocate(cWIN32OLE_TYPE);
- oletype_set_member(type, pTypeInfo, WC2VSTR(bstr));
- return type;
-}
-
/*
* call-seq:
- * WIN32OLE#ole_type
+ * WIN32OLE#ole_obj_help
*
* Returns WIN32OLE_TYPE object.
*
* excel = WIN32OLE.new('Excel.Application')
- * tobj = excel.ole_type
+ * tobj = excel.ole_obj_help
*/
static VALUE
-fole_type(VALUE self)
+fole_obj_help( self )
+ VALUE self;
{
+ unsigned int index;
ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
HRESULT hr;
struct oledata *pole;
- LCID lcid = cWIN32OLE_lcid;
+ BSTR bstr;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
VALUE type = Qnil;
OLEData_Get_Struct(self, pole);
@@ -3936,149 +3129,30 @@ fole_type(VALUE self)
if(FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
}
- type = ole_type_from_itypeinfo(pTypeInfo);
- OLE_RELEASE(pTypeInfo);
- if (type == Qnil) {
- rb_raise(rb_eRuntimeError, "failed to create WIN32OLE_TYPE obj from ITypeInfo");
- }
- return type;
-}
-
-static VALUE
-make_oletypelib_obj(VALUE guid, VALUE major_version, VALUE minor_version)
-{
- VALUE args = rb_ary_new();
- rb_ary_push(args, guid);
- rb_ary_push(args, major_version);
- rb_ary_push(args, minor_version);
- return rb_apply(cWIN32OLE_TYPELIB, rb_intern("new"), args);
-}
-
-static VALUE
-ole_typelib_from_itypelib(ITypeLib *pTypeLib)
-{
- TLIBATTR *pTLibAttr;
- OLECHAR bstr[80];
- VALUE guid = Qnil;
- VALUE major;
- VALUE minor;
- int len = 0;
- HRESULT hr = S_OK;
- hr = pTypeLib->lpVtbl->GetLibAttr(pTypeLib, &pTLibAttr);
- if (FAILED(hr)) {
- return Qnil;
- }
- len = StringFromGUID2(&pTLibAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
- if (len > 3) {
- guid = ole_wc2vstr(bstr, FALSE);
- }
- major = INT2NUM(pTLibAttr->wMajorVerNum);
- minor = INT2NUM(pTLibAttr->wMinorVerNum);
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- if (guid == Qnil) {
- return Qnil;
- }
- return make_oletypelib_obj(guid, major, minor);
-}
-
-
-static VALUE
-ole_typelib_from_itypeinfo(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- ITypeLib *pTypeLib;
- unsigned int index;
- VALUE retval = Qnil;
-
- hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index );
if(FAILED(hr)) {
- return Qnil;
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
}
- retval = ole_typelib_from_itypelib(pTypeLib);
- OLE_RELEASE(pTypeLib);
- return retval;
-}
-
-/*
- * call-seq:
- * WIN32OLE#ole_typelib -> The WIN32OLE_TYPELIB object
- *
- * Returns the WIN32OLE_TYPELIB object. The object represents the
- * type library which contains the WIN32OLE object.
- *
- * excel = WIN32OLE.new('Excel.Application')
- * tlib = excel.ole_typelib
- * puts tlib.name # -> 'Microsoft Excel 9.0 Object Library'
- */
-static VALUE
-fole_typelib(VALUE self)
-{
- struct oledata *pole;
- HRESULT hr;
- ITypeInfo *pTypeInfo;
- LCID lcid = cWIN32OLE_lcid;
- VALUE vtlib = Qnil;
-
- OLEData_Get_Struct(self, pole);
- hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
- 0, lcid, &pTypeInfo);
- if(FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
+ hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index,
+ &bstr, NULL, NULL, NULL);
+ if (SUCCEEDED(hr)) {
+ type = foletype_s_allocate(cWIN32OLE_TYPE);
+ oletype_set_member(type, pTypeInfo, WC2VSTR(bstr));
}
- vtlib = ole_typelib_from_itypeinfo(pTypeInfo);
+ OLE_RELEASE(pTypeLib);
OLE_RELEASE(pTypeInfo);
- if (vtlib == Qnil) {
- rb_raise(rb_eRuntimeError, "failed to get type library info.");
- }
- return vtlib;
-}
-/*
- * call-seq:
- * WIN32OLE#ole_query_interface(iid) -> WIN32OLE object
- *
- * Returns WIN32OLE object for a specific dispatch or dual
- * interface specified by iid.
- *
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp
- */
-static VALUE
-fole_query_interface(VALUE self, VALUE str_iid)
-{
- HRESULT hr;
- OLECHAR *pBuf;
- IID iid;
- struct oledata *pole;
- IDispatch *pDispatch;
-
- pBuf = ole_mb2wc(StringValuePtr(str_iid), -1);
- hr = CLSIDFromString(pBuf, &iid);
- SysFreeString(pBuf);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "invalid iid: `%s'",
- StringValuePtr(str_iid));
- }
-
- OLEData_Get_Struct(self, pole);
- if(!pole->pDispatch) {
- rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
- }
-
- hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &iid,
- (void **)&pDispatch);
- if(FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError,
- "failed to get interface `%s'",
- StringValuePtr(str_iid));
- }
-
- return create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
+ return type;
}
static HRESULT
-ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile)
+ole_docinfo_from_type(pTypeInfo, name, helpstr, helpcontext, helpfile)
+ ITypeInfo *pTypeInfo;
+ BSTR *name;
+ BSTR *helpstr;
+ DWORD *helpcontext;
+ BSTR *helpfile;
{
HRESULT hr;
ITypeLib *pTypeLib;
@@ -4101,7 +3175,10 @@ ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *he
}
static VALUE
-ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
+ole_usertype2val(pTypeInfo, pTypeDesc, typedetails)
+ ITypeInfo *pTypeInfo;
+ TYPEDESC *pTypeDesc;
+ VALUE typedetails;
{
HRESULT hr;
BSTR bstr;
@@ -4125,132 +3202,146 @@ ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
return type;
}
+static VALUE ole_typedesc2val();
static VALUE
-ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
+ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails)
+ ITypeInfo *pTypeInfo;
+ TYPEDESC *pTypeDesc;
+ VALUE typedetails;
{
TYPEDESC *p = pTypeDesc;
VALUE type = rb_str_new2("");
-
- if (p->vt == VT_PTR || p->vt == VT_SAFEARRAY) {
+ while(p->vt == VT_PTR || p->vt == VT_SAFEARRAY) {
p = V_UNION1(p, lptdesc);
- type = ole_typedesc2val(pTypeInfo, p, typedetails);
+ if(strlen(StringValuePtr(type)) == 0) {
+ type = ole_typedesc2val(pTypeInfo, p, typedetails);
+ } else {
+ rb_str_cat(type, ",", 1);
+ rb_str_concat(type, ole_typedesc2val(pTypeInfo, p, typedetails));
+ }
}
return type;
}
static VALUE
-ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
+ole_typedesc2val(pTypeInfo, pTypeDesc, typedetails)
+ ITypeInfo *pTypeInfo;
+ TYPEDESC *pTypeDesc;
+ VALUE typedetails;
{
VALUE str;
- VALUE typestr = Qnil;
switch(pTypeDesc->vt) {
case VT_I2:
- typestr = rb_str_new2("I2");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I2"));
+ return rb_str_new2("I2");
case VT_I4:
- typestr = rb_str_new2("I4");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I4"));
+ return rb_str_new2("I4");
case VT_R4:
- typestr = rb_str_new2("R4");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("R4"));
+ return rb_str_new2("R4");
case VT_R8:
- typestr = rb_str_new2("R8");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("R8"));
+ return rb_str_new2("R8");
case VT_CY:
- typestr = rb_str_new2("CY");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("CY"));
+ return rb_str_new2("CY");
case VT_DATE:
- typestr = rb_str_new2("DATE");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("DATE"));
+ return rb_str_new2("DATE");
case VT_BSTR:
- typestr = rb_str_new2("BSTR");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("BSTR"));
+ return rb_str_new2("BSTR");
case VT_BOOL:
- typestr = rb_str_new2("BOOL");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("BOOL"));
+ return rb_str_new2("BOOL");
case VT_VARIANT:
- typestr = rb_str_new2("VARIANT");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("VARIANT"));
+ return rb_str_new2("VARIANT");
case VT_DECIMAL:
- typestr = rb_str_new2("DECIMAL");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("DECIMAL"));
+ return rb_str_new2("DECIMAL");
case VT_I1:
- typestr = rb_str_new2("I1");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I1"));
+ return rb_str_new2("I1");
case VT_UI1:
- typestr = rb_str_new2("UI1");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI1"));
+ return rb_str_new2("UI1");
case VT_UI2:
- typestr = rb_str_new2("UI2");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI2"));
+ return rb_str_new2("UI2");
case VT_UI4:
- typestr = rb_str_new2("UI4");
- break;
-#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI4"));
+ return rb_str_new2("UI4");
case VT_I8:
- typestr = rb_str_new2("I8");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I8"));
+ return rb_str_new2("I8");
case VT_UI8:
- typestr = rb_str_new2("UI8");
- break;
-#endif
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI8"));
+ return rb_str_new2("UI8");
case VT_INT:
- typestr = rb_str_new2("INT");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("INT"));
+ return rb_str_new2("INT");
case VT_UINT:
- typestr = rb_str_new2("UINT");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UINT"));
+ return rb_str_new2("UINT");
case VT_VOID:
- typestr = rb_str_new2("VOID");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("VOID"));
+ return rb_str_new2("VOID");
case VT_HRESULT:
- typestr = rb_str_new2("HRESULT");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("HRESULT"));
+ return rb_str_new2("HRESULT");
case VT_PTR:
- typestr = rb_str_new2("PTR");
if(typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
+ rb_ary_push(typedetails, rb_str_new2("PTR"));
return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
case VT_SAFEARRAY:
- typestr = rb_str_new2("SAFEARRAY");
if(typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
+ rb_ary_push(typedetails, rb_str_new2("SAFEARRAY"));
return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
case VT_CARRAY:
- typestr = rb_str_new2("CARRAY");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("CARRAY"));
+ return rb_str_new2("CARRAY");
case VT_USERDEFINED:
- typestr = rb_str_new2("USERDEFINED");
- if (typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("USERDEFINED"));
str = ole_usertype2val(pTypeInfo, pTypeDesc, typedetails);
if (str != Qnil) {
return str;
}
- return typestr;
+ return rb_str_new2("USERDEFINED");
case VT_UNKNOWN:
- typestr = rb_str_new2("UNKNOWN");
- break;
+ return rb_str_new2("UNKNOWN");
case VT_DISPATCH:
- typestr = rb_str_new2("DISPATCH");
- break;
- case VT_ERROR:
- typestr = rb_str_new2("ERROR");
- break;
- case VT_LPWSTR:
- typestr = rb_str_new2("LPWSTR");
- break;
- case VT_LPSTR:
- typestr = rb_str_new2("LPSTR");
- break;
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("DISPATCH"));
+ return rb_str_new2("DISPATCH");
default:
- typestr = rb_str_new2("Unknown Type ");
- rb_str_concat(typestr, rb_fix2str(INT2FIX(pTypeDesc->vt), 10));
- break;
+ str = rb_str_new2("Unknown Type ");
+ rb_str_concat(str, rb_fix2str(INT2FIX(pTypeDesc->vt), 10));
+ return str;
}
- if (typedetails != Qnil)
- rb_ary_push(typedetails, typestr);
- return typestr;
}
/*
@@ -4265,12 +3356,15 @@ ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
*
*/
static VALUE
-fole_method_help(VALUE self, VALUE cmdname)
+fole_method_help( self, cmdname )
+ VALUE self;
+ VALUE cmdname;
{
ITypeInfo *pTypeInfo;
HRESULT hr;
struct oledata *pole;
VALUE method, obj;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
Check_SafeStr(cmdname);
OLEData_Get_Struct(self, pole);
@@ -4281,7 +3375,7 @@ fole_method_help(VALUE self, VALUE cmdname)
obj = olemethod_from_typeinfo(method, pTypeInfo, cmdname);
OLE_RELEASE(pTypeInfo);
if (obj == Qnil)
- rb_raise(eWIN32OLERuntimeError, "not found %s",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found %s",
StringValuePtr(cmdname));
return obj;
}
@@ -4307,7 +3401,8 @@ fole_method_help(VALUE self, VALUE cmdname)
*
*/
static VALUE
-fole_activex_initialize(VALUE self)
+fole_activex_initialize(self)
+ VALUE self;
{
struct oledata *pole;
IPersistMemory *pPersistMemory;
@@ -4327,7 +3422,7 @@ fole_activex_initialize(VALUE self)
}
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "fail to initialize ActiveX control");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "fail to initialize ActiveX control");
}
return Qnil;
@@ -4338,20 +3433,35 @@ fole_activex_initialize(VALUE self)
* WIN32OLE_TYPE.ole_classes(typelib)
*
* Returns array of WIN32OLE_TYPE objects defined by the <i>typelib</i> type library.
- * This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead.
*/
static VALUE
-foletype_s_ole_classes(VALUE self, VALUE typelib)
+foletype_s_ole_classes(self, typelib)
+ VALUE self;
+ VALUE typelib;
{
- VALUE obj;
+ VALUE file, classes;
+ OLECHAR * pbuf;
+ ITypeLib *pTypeLib;
+ HRESULT hr;
- /*
- rb_warn("%s is obsolete; use %s instead.",
- "WIN32OLE_TYPE.ole_classes",
- "WIN32OLE_TYPELIB.new(typelib).ole_types");
- */
- obj = rb_funcall(cWIN32OLE_TYPELIB, rb_intern("new"), 1, typelib);
- return rb_funcall(obj, rb_intern("ole_types"), 0);
+ rb_secure(4);
+ classes = rb_ary_new();
+ if(TYPE(typelib) == T_STRING) {
+ file = typelib_file(typelib);
+ if (file == Qnil) {
+ file = typelib;
+ }
+ pbuf = ole_mb2wc(StringValuePtr(file), -1);
+ hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
+ SysFreeString(pbuf);
+ ole_classes_from_typelib(pTypeLib, classes);
+ OLE_RELEASE(pTypeLib);
+ } else {
+ rb_raise(rb_eTypeError, "1st argument should be TypeLib string");
+ }
+ return classes;
}
/*
@@ -4359,18 +3469,48 @@ foletype_s_ole_classes(VALUE self, VALUE typelib)
* WIN32OLE_TYPE.typelibs
*
* Returns array of type libraries.
- * This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead.
*
*/
static VALUE
-foletype_s_typelibs(VALUE self)
+foletype_s_typelibs(self)
+ VALUE self;
{
- /*
- rb_warn("%s is obsolete. use %s instead.",
- "WIN32OLE_TYPE.typelibs",
- "WIN32OLE_TYPELIB.typelibs.collect{t|t.name}");
- */
- return rb_eval_string("WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}");
+ HKEY htypelib, hclsid;
+ double fversion;
+ DWORD i, j;
+ LONG err;
+ VALUE clsid;
+ VALUE ver;
+ VALUE v = Qnil;
+ VALUE typelibs = rb_ary_new();
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return typelibs;
+ }
+ for(i = 0; ; i++) {
+ clsid = reg_enum_key(htypelib, i);
+ if (clsid == Qnil)
+ break;
+ err = reg_open_vkey(htypelib, clsid, &hclsid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ fversion = 0;
+ for(j = 0; ; j++) {
+ ver = reg_enum_key(hclsid, j);
+ if (ver == Qnil)
+ break;
+ if (fversion > atof(StringValuePtr(ver)))
+ continue;
+ fversion = atof(StringValuePtr(ver));
+ if ( (v = reg_get_val(hclsid, StringValuePtr(ver))) != Qnil ) {
+ rb_ary_push(typelibs, v);
+ }
+ }
+ RegCloseKey(hclsid);
+ }
+ RegCloseKey(htypelib);
+ return typelibs;
}
/*
@@ -4380,7 +3520,8 @@ foletype_s_typelibs(VALUE self)
* Returns array of ProgID.
*/
static VALUE
-foletype_s_progids(VALUE self)
+foletype_s_progids(self)
+ VALUE self;
{
HKEY hclsids, hclsid;
DWORD i;
@@ -4400,9 +3541,9 @@ foletype_s_progids(VALUE self)
err = reg_open_vkey(hclsids, clsid, &hclsid);
if (err != ERROR_SUCCESS)
continue;
- if ((v = reg_get_val2(hclsid, "ProgID")) != Qnil)
+ if ((v = reg_get_val(hclsid, "ProgID")) != Qnil)
rb_ary_push(progids, v);
- if ((v = reg_get_val2(hclsid, "VersionIndependentProgID")) != Qnil)
+ if ((v = reg_get_val(hclsid, "VersionIndependentProgID")) != Qnil)
rb_ary_push(progids, v);
RegCloseKey(hclsid);
}
@@ -4411,7 +3552,8 @@ foletype_s_progids(VALUE self)
}
static VALUE
-foletype_s_allocate(VALUE klass)
+foletype_s_allocate(klass)
+ VALUE klass;
{
struct oletypedata *poletype;
VALUE obj;
@@ -4422,7 +3564,10 @@ foletype_s_allocate(VALUE klass)
}
static VALUE
-oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
+oletype_set_member(self, pTypeInfo, name)
+ VALUE self;
+ ITypeInfo *pTypeInfo;
+ VALUE name;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -4433,7 +3578,10 @@ oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
}
static VALUE
-oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass)
+oleclass_from_typelib(self, pTypeLib, oleclass)
+ VALUE self;
+ ITypeLib *pTypeLib;
+ VALUE oleclass;
{
long count;
@@ -4465,519 +3613,6 @@ oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass)
}
/*
- * Document-class: WIN32OLE_TYPELIB
- *
- * <code>WIN32OLE_TYPELIB</code> objects represent OLE tyblib information.
- */
-
-
-static VALUE
-oletypelib_set_member(VALUE self, VALUE typelib, VALUE guid, VALUE version)
-{
- rb_ivar_set(self, rb_intern("name"), typelib);
- rb_ivar_set(self, rb_intern("guid"), guid);
- rb_ivar_set(self, rb_intern("version"), version);
- return self;
-}
-
-/*
- * call-seq:
- *
- * WIN32OLE_TYPELIB.typelibs
- *
- * Returns the array of WIN32OLE_TYPELIB object.
- *
- * tlibs = WIN32OLE_TYPELIB.typelibs
- *
- */
-static VALUE
-foletypelib_s_typelibs(VALUE self)
-{
- HKEY htypelib, hguid;
- DWORD i, j;
- LONG err;
- VALUE guid;
- VALUE version;
- VALUE name = Qnil;
- VALUE typelibs = rb_ary_new();
- VALUE typelib = Qnil;
-
- err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
- if(err != ERROR_SUCCESS) {
- return typelibs;
- }
- for(i = 0; ; i++) {
- guid = reg_enum_key(htypelib, i);
- if (guid == Qnil)
- break;
- err = reg_open_vkey(htypelib, guid, &hguid);
- if (err != ERROR_SUCCESS)
- continue;
- for(j = 0; ; j++) {
- version = reg_enum_key(hguid, j);
- if (version == Qnil)
- break;
- if ( (name = reg_get_val2(hguid, StringValuePtr(version))) != Qnil ) {
- typelib = rb_funcall(cWIN32OLE_TYPELIB, rb_intern("allocate"), 0);
- oletypelib_set_member(typelib, name, guid, version);
- rb_ary_push(typelibs, typelib);
- }
- }
- RegCloseKey(hguid);
- }
- RegCloseKey(htypelib);
- return typelibs;
-}
-
-static VALUE
-make_version_str(VALUE major, VALUE minor)
-{
- VALUE version_str = Qnil;
- VALUE minor_str = Qnil;
- if (major == Qnil) {
- return Qnil;
- }
- version_str = rb_String(major);
- if (minor != Qnil) {
- minor_str = rb_String(minor);
- rb_str_cat2(version_str, ".");
- rb_str_append(version_str, minor_str);
- }
- return version_str;
-}
-
-static VALUE
-oletypelib_search_registry2(VALUE self, VALUE args)
-{
- HKEY htypelib, hguid, hversion;
- double fver;
- DWORD j;
- LONG err;
- VALUE found = Qfalse;
- VALUE tlib;
- VALUE ver;
- VALUE version_str;
- VALUE version = Qnil;
- VALUE typelib = Qnil;
-
- VALUE guid = rb_ary_entry(args, 0);
- version_str = make_version_str(rb_ary_entry(args, 1), rb_ary_entry(args, 2));
-
- err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
- if(err != ERROR_SUCCESS) {
- return Qfalse;
- }
- err = reg_open_vkey(htypelib, guid, &hguid);
- if (err != ERROR_SUCCESS) {
- RegCloseKey(htypelib);
- return Qfalse;
- }
- if (version_str != Qnil) {
- err = reg_open_vkey(hguid, version_str, &hversion);
- if (err == ERROR_SUCCESS) {
- tlib = reg_get_val(hversion, NULL);
- if (tlib != Qnil) {
- typelib = tlib;
- version = version_str;
- }
- }
- RegCloseKey(hversion);
- } else {
- fver = 0.0;
- for(j = 0; ;j++) {
- ver = reg_enum_key(hguid, j);
- if (ver == Qnil)
- break;
- err = reg_open_vkey(hguid, ver, &hversion);
- if (err != ERROR_SUCCESS)
- continue;
- tlib = reg_get_val(hversion, NULL);
- if (tlib == Qnil) {
- RegCloseKey(hversion);
- continue;
- }
- if (fver < atof(StringValuePtr(ver))) {
- fver = atof(StringValuePtr(ver));
- version = ver;
- typelib = tlib;
- }
- RegCloseKey(hversion);
- }
- }
- RegCloseKey(hguid);
- RegCloseKey(htypelib);
- if (typelib != Qnil) {
- found = Qtrue;
- oletypelib_set_member(self, typelib, guid, version);
- }
- return found;
-}
-
-static VALUE
-oletypelib_search_registry(VALUE self, VALUE typelib)
-{
- HKEY htypelib, hguid, hversion;
- DWORD i, j;
- LONG err;
- VALUE found = Qfalse;
- VALUE tlib;
- VALUE guid;
- VALUE ver;
-
- err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
- if(err != ERROR_SUCCESS) {
- return Qfalse;
- }
- for(i = 0; !found; i++) {
- guid = reg_enum_key(htypelib, i);
- if (guid == Qnil)
- break;
- err = reg_open_vkey(htypelib, guid, &hguid);
- if (err != ERROR_SUCCESS)
- continue;
- for(j = 0; found == Qfalse; j++) {
- ver = reg_enum_key(hguid, j);
- if (ver == Qnil)
- break;
- err = reg_open_vkey(hguid, ver, &hversion);
- if (err != ERROR_SUCCESS)
- continue;
- tlib = reg_get_val(hversion, NULL);
- if (tlib == Qnil) {
- RegCloseKey(hversion);
- continue;
- }
- if (rb_str_cmp(typelib, tlib) == 0) {
- oletypelib_set_member(self, typelib, guid, ver);
- found = Qtrue;
- }
- RegCloseKey(hversion);
- }
- RegCloseKey(hguid);
- }
- RegCloseKey(htypelib);
- return found;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB.new(typelib [, version1, version2]) -> WIN32OLE_TYPELIB object
- *
- * Returns a new WIN32OLE_TYPELIB object.
- *
- * The first argument <i>typelib</i> specifies OLE type library name or GUID or
- * OLE library file.
- * The second argument is major version or version of the type library.
- * The third argument is minor version.
- * The second argument and third argument are optional.
- * If the first argument is type library name, then the second and third argument
- * are ignored.
- *
- * tlib1 = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * tlib2 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}')
- * tlib3 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1.3)
- * tlib4 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1, 3)
- * tlib5 = WIN32OLE_TYPELIB.new("C:\\WINNT\\SYSTEM32\\SHELL32.DLL")
- * puts tlib1.name # -> 'Microsoft Excel 9.0 Object Library'
- * puts tlib2.name # -> 'Microsoft Excel 9.0 Object Library'
- * puts tlib3.name # -> 'Microsoft Excel 9.0 Object Library'
- * puts tlib4.name # -> 'Microsoft Excel 9.0 Object Library'
- * puts tlib5.name # -> 'Microsoft Shell Controls And Automation'
- *
- */
-static VALUE
-foletypelib_initialize(VALUE self, VALUE args)
-{
- VALUE found = Qfalse;
- VALUE typelib = Qnil;
- int len = 0;
- OLECHAR * pbuf;
- ITypeLib *pTypeLib;
- VALUE retval;
- HRESULT hr = S_OK;
-
- len = RARRAY_LEN(args);
- if (len < 1 || len > 3) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
- }
-
- typelib = rb_ary_entry(args, 0);
-
- Check_SafeStr(typelib);
-
- found = oletypelib_search_registry(self, typelib);
- if (found == Qfalse) {
- found = oletypelib_search_registry2(self, args);
- }
- if (found == Qfalse) {
- pbuf = ole_mb2wc(StringValuePtr(typelib), -1);
- hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
- SysFreeString(pbuf);
- if (SUCCEEDED(hr)) {
- retval = ole_typelib_from_itypelib(pTypeLib);
- OLE_RELEASE(pTypeLib);
- if (retval != Qnil) {
- found = Qtrue;
- oletypelib_set_member(self,
- rb_ivar_get(retval, rb_intern("name")),
- rb_ivar_get(retval, rb_intern("guid")),
- rb_ivar_get(retval, rb_intern("version")));
- }
- }
- }
-
- if (found == Qfalse) {
- rb_raise(eWIN32OLERuntimeError, "not found type library `%s`",
- StringValuePtr(typelib));
- }
- return self;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#guid -> The guid string.
- *
- * Returns guid string which specifies type library.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * guid = tlib.guid # -> '{00020813-0000-0000-C000-000000000046}'
- */
-static VALUE
-foletypelib_guid(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("guid"));
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#name -> The type library name
- *
- * Returns the type library name.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * name = tlib.name # -> 'Microsoft Excel 9.0 Object Library'
- */
-static VALUE
-foletypelib_name(VALUE self)
-{
- return rb_ivar_get(self, rb_intern("name"));
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#version -> The type library version.
- *
- * Returns the type library version.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * puts tlib.version #-> 1.3
- */
-static VALUE
-foletypelib_version(VALUE self)
-{
- VALUE ver = rb_ivar_get(self, rb_intern("version"));
- return rb_Float(ver);
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#major_version -> The type library major version.
- *
- * Returns the type library major version.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * puts tlib.major_version # -> 1
- */
-static VALUE
-foletypelib_major_version(VALUE self)
-{
- VALUE ver = rb_ivar_get(self, rb_intern("version"));
- VALUE ary = rb_str_split(ver, ".");
- return rb_Integer(rb_ary_entry(ary, 0));
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#minor_version -> The type library minor version.
- *
- * Returns the type library minor version.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * puts tlib.minor_version # -> 3
- */
-static VALUE
-foletypelib_minor_version(VALUE self)
-{
- VALUE ver = rb_ivar_get(self, rb_intern("version"));
- VALUE ary = rb_str_split(ver, ".");
- return rb_Integer(rb_ary_entry(ary, 1));
-}
-
-static VALUE
-oletypelib_path(VALUE guid, VALUE version)
-{
- int k;
- LONG err;
- HKEY hkey;
- HKEY hlang;
- VALUE lang;
- VALUE path = Qnil;
-
- VALUE key = rb_str_new2("TypeLib\\");
- rb_str_concat(key, guid);
- rb_str_cat2(key, "\\");
- rb_str_concat(key, version);
-
- err = reg_open_vkey(HKEY_CLASSES_ROOT, key, &hkey);
- if (err != ERROR_SUCCESS) {
- return Qnil;
- }
- for(k = 0; path == Qnil; k++) {
- lang = reg_enum_key(hkey, k);
- if (lang == Qnil)
- break;
- err = reg_open_vkey(hkey, lang, &hlang);
- if (err == ERROR_SUCCESS) {
- path = reg_get_typelib_file_path(hlang);
- RegCloseKey(hlang);
- }
- }
- RegCloseKey(hkey);
- return path;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#path -> The type library file path.
- *
- * Returns the type library file path.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * puts tlib.path #-> 'C:\...\EXCEL9.OLB'
- */
-static VALUE
-foletypelib_path(VALUE self)
-{
- VALUE guid = rb_ivar_get(self, rb_intern("guid"));
- VALUE version = rb_ivar_get(self, rb_intern("version"));
- return oletypelib_path(guid, version);
-}
-
-static void
-oletypelib2itypelib(VALUE self, ITypeLib **ppTypeLib)
-{
- VALUE path = Qnil;
- OLECHAR *pbuf;
- HRESULT hr = S_OK;
- path = rb_funcall(self, rb_intern("path"), 0);
- if (path != Qnil) {
- pbuf = ole_mb2wc(StringValuePtr(path), -1);
- hr = LoadTypeLibEx(pbuf, REGKIND_NONE, ppTypeLib);
- SysFreeString(pbuf);
- if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx from `%s'",
- StringValuePtr(path));
- } else {
- rb_raise(eWIN32OLERuntimeError, "failed to get type library path");
- }
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#visible?
- *
- * Returns true if the type library information is not hidden.
- * If wLibFlags of TLIBATTR is 0 or LIBFLAG_FRESTRICTED or LIBFLAG_FHIDDEN,
- * the method returns false, otherwise, returns true.
- * If the method fails to access the TLIBATTR information, then
- * WIN32OLERuntimeError is raised.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * tlib.visible? # => true
- */
-static VALUE
-foletypelib_visible(VALUE self)
-{
- HRESULT hr;
- ITypeLib *pTypeLib = NULL;
- VALUE visible = Qtrue;
- TLIBATTR *pTLibAttr;
-
- oletypelib2itypelib(self, &pTypeLib);
-
- hr = pTypeLib->lpVtbl->GetLibAttr(pTypeLib, &pTLibAttr);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeLib);
- ole_raise(hr, eWIN32OLERuntimeError, "failed to get TLIBATTR information");
- }
- if ((pTLibAttr->wLibFlags == 0) ||
- (pTLibAttr->wLibFlags & LIBFLAG_FRESTRICTED) ||
- (pTLibAttr->wLibFlags & LIBFLAG_FHIDDEN)) {
- visible = Qfalse;
- }
- pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
- OLE_RELEASE(pTypeLib);
- return visible;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#library_name
- *
- * Returns library name.
- * If the method fails to access library name, WIN32OLERuntimeError is raised.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * tlib.library_name # => Excel
- */
-static VALUE
-foletypelib_library_name(VALUE self)
-{
- HRESULT hr;
- ITypeLib *pTypeLib = NULL;
- VALUE libname = Qnil;
- BSTR bstr;
-
- oletypelib2itypelib(self, &pTypeLib);
- hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1,
- &bstr, NULL, NULL, NULL);
- if (FAILED(hr)) {
- OLE_RELEASE(pTypeLib);
- ole_raise(hr, eWIN32OLERuntimeError, "failed to get library name");
- }
- OLE_RELEASE(pTypeLib);
- libname = WC2VSTR(bstr);
- return libname;
-}
-
-
-/*
- * call-seq:
- * WIN32OLE_TYPELIB#ole_types -> The array of WIN32OLE_TYPE object included the type library.
- *
- * Returns the type library file path.
- *
- * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- * classes = tlib.ole_types.collect{|k| k.name} # -> ['AddIn', 'AddIns' ...]
- */
-static VALUE
-foletypelib_ole_types(VALUE self)
-{
- ITypeLib *pTypeLib = NULL;
- VALUE classes = rb_ary_new();
- oletypelib2itypelib(self, &pTypeLib);
- ole_types_from_typelib(pTypeLib, classes);
- OLE_RELEASE(pTypeLib);
- return classes;
-}
-
-static VALUE
-foletypelib_inspect(VALUE self)
-{
- return default_inspect(self, "WIN32OLE_TYPELIB");
-}
-
-/*
* Document-class: WIN32OLE_TYPE
*
* <code>WIN32OLE_TYPE</code> objects represent OLE type libarary information.
@@ -4995,7 +3630,10 @@ foletypelib_inspect(VALUE self)
* # => WIN32OLE_TYPE object of Application class of Excel.
*/
static VALUE
-foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass)
+foletype_initialize(self, typelib, oleclass)
+ VALUE self;
+ VALUE typelib;
+ VALUE oleclass;
{
VALUE file;
OLECHAR * pbuf;
@@ -5011,11 +3649,11 @@ foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass)
pbuf = ole_mb2wc(StringValuePtr(file), -1);
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
SysFreeString(pbuf);
if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
OLE_RELEASE(pTypeLib);
- rb_raise(eWIN32OLERuntimeError, "not found `%s` in `%s`",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found `%s` in `%s`",
StringValuePtr(oleclass), StringValuePtr(typelib));
}
OLE_RELEASE(pTypeLib);
@@ -5031,13 +3669,15 @@ foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass)
* puts tobj.name # => Application
*/
static VALUE
-foletype_name(VALUE self)
+foletype_name(self)
+ VALUE self;
{
return rb_ivar_get(self, rb_intern("name"));
}
static VALUE
-ole_ole_type(ITypeInfo *pTypeInfo)
+ole_ole_type(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -5091,7 +3731,8 @@ ole_ole_type(ITypeInfo *pTypeInfo)
* puts tobj.ole_type # => Class
*/
static VALUE
-foletype_ole_type(VALUE self)
+foletype_ole_type(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5099,7 +3740,8 @@ foletype_ole_type(VALUE self)
}
static VALUE
-ole_type_guid(ITypeInfo *pTypeInfo)
+ole_type_guid(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -5126,7 +3768,8 @@ ole_type_guid(ITypeInfo *pTypeInfo)
* puts tobj.guid # => {00024500-0000-0000-C000-000000000046}
*/
static VALUE
-foletype_guid(VALUE self)
+foletype_guid(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5134,7 +3777,8 @@ foletype_guid(VALUE self)
}
static VALUE
-ole_type_progid(ITypeInfo *pTypeInfo)
+ole_type_progid(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -5144,7 +3788,7 @@ ole_type_progid(ITypeInfo *pTypeInfo)
if (FAILED(hr))
return progid;
hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf);
- if (SUCCEEDED(hr)) {
+ if (SUCCEEDED(hr)) {
progid = ole_wc2vstr(pbuf, FALSE);
CoTaskMemFree(pbuf);
}
@@ -5161,7 +3805,8 @@ ole_type_progid(ITypeInfo *pTypeInfo)
* puts tobj.progid # => Excel.Application.9
*/
static VALUE
-foletype_progid(VALUE self)
+foletype_progid(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5170,7 +3815,8 @@ foletype_progid(VALUE self)
static VALUE
-ole_type_visible(ITypeInfo *pTypeInfo)
+ole_type_visible(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -5196,7 +3842,8 @@ ole_type_visible(ITypeInfo *pTypeInfo)
* puts tobj.visible # => true
*/
static VALUE
-foletype_visible(VALUE self)
+foletype_visible(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5204,14 +3851,15 @@ foletype_visible(VALUE self)
}
static VALUE
-ole_type_major_version(ITypeInfo *pTypeInfo)
+ole_type_major_version(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
VALUE ver;
TYPEATTR *pTypeAttr;
HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
ver = INT2FIX(pTypeAttr->wMajorVerNum);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return ver;
@@ -5226,7 +3874,8 @@ ole_type_major_version(ITypeInfo *pTypeInfo)
* puts tobj.major_version # => 8
*/
static VALUE
-foletype_major_version(VALUE self)
+foletype_major_version(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5234,14 +3883,15 @@ foletype_major_version(VALUE self)
}
static VALUE
-ole_type_minor_version(ITypeInfo *pTypeInfo)
+ole_type_minor_version(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
VALUE ver;
TYPEATTR *pTypeAttr;
HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
ver = INT2FIX(pTypeAttr->wMinorVerNum);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return ver;
@@ -5256,7 +3906,8 @@ ole_type_minor_version(ITypeInfo *pTypeInfo)
* puts tobj.minor_version # => 2
*/
static VALUE
-foletype_minor_version(VALUE self)
+foletype_minor_version(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5264,14 +3915,15 @@ foletype_minor_version(VALUE self)
}
static VALUE
-ole_type_typekind(ITypeInfo *pTypeInfo)
+ole_type_typekind(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
VALUE typekind;
TYPEATTR *pTypeAttr;
HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
typekind = INT2FIX(pTypeAttr->typekind);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return typekind;
@@ -5287,7 +3939,8 @@ ole_type_typekind(ITypeInfo *pTypeInfo)
*
*/
static VALUE
-foletype_typekind(VALUE self)
+foletype_typekind(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5295,7 +3948,8 @@ foletype_typekind(VALUE self)
}
static VALUE
-ole_type_helpstring(ITypeInfo *pTypeInfo)
+ole_type_helpstring(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
BSTR bhelpstr;
@@ -5315,7 +3969,8 @@ ole_type_helpstring(ITypeInfo *pTypeInfo)
* puts tobj.helpstring # => Web Browser interface
*/
static VALUE
-foletype_helpstring(VALUE self)
+foletype_helpstring(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5323,7 +3978,8 @@ foletype_helpstring(VALUE self)
}
static VALUE
-ole_type_src_type(ITypeInfo *pTypeInfo)
+ole_type_src_type(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -5350,7 +4006,8 @@ ole_type_src_type(ITypeInfo *pTypeInfo)
*
*/
static VALUE
-foletype_src_type(VALUE self)
+foletype_src_type(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5358,7 +4015,8 @@ foletype_src_type(VALUE self)
}
static VALUE
-ole_type_helpfile(ITypeInfo *pTypeInfo)
+ole_type_helpfile(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
BSTR bhelpfile;
@@ -5379,7 +4037,8 @@ ole_type_helpfile(ITypeInfo *pTypeInfo)
*
*/
static VALUE
-foletype_helpfile(VALUE self)
+foletype_helpfile(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5387,7 +4046,8 @@ foletype_helpfile(VALUE self)
}
static VALUE
-ole_type_helpcontext(ITypeInfo *pTypeInfo)
+ole_type_helpcontext(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
DWORD helpcontext;
@@ -5407,93 +4067,17 @@ ole_type_helpcontext(ITypeInfo *pTypeInfo)
* puts tobj.helpfile # => 131185
*/
static VALUE
-foletype_helpcontext(VALUE self)
+foletype_helpcontext(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_helpcontext(ptype->pTypeInfo);
}
-/*
- * call-seq:
- * WIN32OLE_TYPE#ole_typelib
- *
- * Returns the WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE
- * object. If it is not found, then returns nil.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
- * puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library'
- */
-static VALUE
-foletype_ole_typelib(VALUE self)
-{
- struct oletypedata *ptype;
- Data_Get_Struct(self, struct oletypedata, ptype);
- return ole_typelib_from_itypeinfo(ptype->pTypeInfo);
-}
-
static VALUE
-ole_type_impl_ole_types(ITypeInfo *pTypeInfo)
-{
- HRESULT hr;
- ITypeInfo *pRefTypeInfo;
- HREFTYPE href;
- WORD i;
- VALUE type;
- TYPEATTR *pTypeAttr;
- int flags;
-
- VALUE types = rb_ary_new();
- hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
- if (FAILED(hr)) {
- return types;
- }
- for (i = 0; i < pTypeAttr->cImplTypes; i++) {
- hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
- if (FAILED(hr))
- continue;
-
- hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
- if (FAILED(hr))
- continue;
- hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
- if (FAILED(hr))
- continue;
- type = ole_type_from_itypeinfo(pRefTypeInfo);
- if (type != Qnil) {
- rb_ary_push(types, type);
- }
-
- OLE_RELEASE(pRefTypeInfo);
- }
- OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
- return types;
-}
-
-/*
- * call-seq:
- * WIN32OLE_TYPE#implemented_ole_types
- *
- * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
- * object.
- * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
- * p tobj.implemented_ole_types # => [_Worksheet, DocEvents]
- */
-static VALUE
-foletype_impl_ole_types(VALUE self)
-{
- struct oletypedata *ptype;
- Data_Get_Struct(self, struct oletypedata, ptype);
- return ole_type_impl_ole_types(ptype->pTypeInfo);
-}
-
-static VALUE
-foletype_inspect(VALUE self)
-{
- return default_inspect(self, "WIN32OLE_TYPE");
-}
-
-static VALUE
-ole_variables(ITypeInfo *pTypeInfo)
+ole_variables(pTypeInfo)
+ ITypeInfo *pTypeInfo;
{
HRESULT hr;
TYPEATTR *pTypeAttr;
@@ -5507,7 +4091,7 @@ ole_variables(ITypeInfo *pTypeInfo)
VALUE variables = rb_ary_new();
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
}
for(i = 0; i < pTypeAttr->cVars; i++) {
@@ -5557,7 +4141,8 @@ ole_variables(ITypeInfo *pTypeInfo)
*
*/
static VALUE
-foletype_variables(VALUE self)
+foletype_variables(self)
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5577,7 +4162,10 @@ foletype_variables(VALUE self)
* # => ['Activate', 'Copy', 'Delete',....]
*/
static VALUE
-foletype_methods(VALUE self)
+foletype_methods(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
@@ -5611,20 +4199,23 @@ foletype_methods(VALUE self)
*
*/
static VALUE
-folevariable_name(VALUE self)
+folevariable_name(self)
+ VALUE self;
{
return rb_ivar_get(self, rb_intern("name"));
}
static VALUE
-ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index)
+ole_variable_ole_type(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
{
VARDESC *pVarDesc;
HRESULT hr;
VALUE type;
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetVarDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetVarDesc");
type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil);
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
return type;
@@ -5651,7 +4242,8 @@ ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index)
*
*/
static VALUE
-folevariable_ole_type(VALUE self)
+folevariable_ole_type(self)
+ VALUE self;
{
struct olevariabledata *pvar;
Data_Get_Struct(self, struct olevariabledata, pvar);
@@ -5659,14 +4251,16 @@ folevariable_ole_type(VALUE self)
}
static VALUE
-ole_variable_ole_type_detail(ITypeInfo *pTypeInfo, UINT var_index)
+ole_variable_ole_type_detail(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
{
VARDESC *pVarDesc;
HRESULT hr;
VALUE type = rb_ary_new();
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetVarDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetVarDesc");
ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type);
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
return type;
@@ -5685,7 +4279,8 @@ ole_variable_ole_type_detail(ITypeInfo *pTypeInfo, UINT var_index)
*
*/
static VALUE
-folevariable_ole_type_detail(VALUE self)
+folevariable_ole_type_detail(self)
+ VALUE self;
{
struct olevariabledata *pvar;
Data_Get_Struct(self, struct olevariabledata, pvar);
@@ -5693,7 +4288,9 @@ folevariable_ole_type_detail(VALUE self)
}
static VALUE
-ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index)
+ole_variable_value(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
{
VARDESC *pVarDesc;
HRESULT hr;
@@ -5717,7 +4314,7 @@ ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index)
* tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
* variables = tobj.variables
* variables.each do |variable|
- * puts "#{variable.name} #{variable.value}"
+ * puts "#{variable.name} = #{variable.value}"
* end
*
* The result of above script is following:
@@ -5729,7 +4326,8 @@ ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index)
*
*/
static VALUE
-folevariable_value(VALUE self)
+folevariable_value(self)
+ VALUE self;
{
struct olevariabledata *pvar;
Data_Get_Struct(self, struct olevariabledata, pvar);
@@ -5737,7 +4335,9 @@ folevariable_value(VALUE self)
}
static VALUE
-ole_variable_visible(ITypeInfo *pTypeInfo, UINT var_index)
+ole_variable_visible(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
{
VARDESC *pVarDesc;
HRESULT hr;
@@ -5775,7 +4375,8 @@ ole_variable_visible(ITypeInfo *pTypeInfo, UINT var_index)
*
*/
static VALUE
-folevariable_visible(VALUE self)
+folevariable_visible(self)
+ VALUE self;
{
struct olevariabledata *pvar;
Data_Get_Struct(self, struct olevariabledata, pvar);
@@ -5783,7 +4384,9 @@ folevariable_visible(VALUE self)
}
static VALUE
-ole_variable_kind(ITypeInfo *pTypeInfo, UINT var_index)
+ole_variable_kind(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
{
VARDESC *pVarDesc;
HRESULT hr;
@@ -5831,7 +4434,8 @@ ole_variable_kind(ITypeInfo *pTypeInfo, UINT var_index)
* xlWorksheet CONSTANT
*/
static VALUE
-folevariable_variable_kind(VALUE self)
+folevariable_variable_kind(self)
+ VALUE self;
{
struct olevariabledata *pvar;
Data_Get_Struct(self, struct olevariabledata, pvar);
@@ -5839,7 +4443,9 @@ folevariable_variable_kind(VALUE self)
}
static VALUE
-ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index)
+ole_variable_varkind(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
{
VARDESC *pVarDesc;
HRESULT hr;
@@ -5871,22 +4477,14 @@ ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index)
* xlWorksheet 2
*/
static VALUE
-folevariable_varkind(VALUE self)
+folevariable_varkind(self)
+ VALUE self;
{
struct olevariabledata *pvar;
Data_Get_Struct(self, struct olevariabledata, pvar);
return ole_variable_varkind(pvar->pTypeInfo, pvar->index);
}
-static VALUE
-folevariable_inspect(VALUE self)
-{
- VALUE detail = rb_funcall(self, rb_intern("to_s"), 0);
- rb_str_cat2(detail, "=");
- rb_str_concat(detail, rb_funcall(rb_funcall(self, rb_intern("value"), 0), rb_intern("inspect"), 0));
- return make_inspect("WIN32OLE_VARIABLE", detail);
-}
-
/*
* Document-class: WIN32OLE_METHOD
*
@@ -5894,7 +4492,12 @@ folevariable_inspect(VALUE self)
*/
static VALUE
-olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name)
+olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, index, name)
+ VALUE self;
+ ITypeInfo *pTypeInfo;
+ ITypeInfo *pOwnerTypeInfo;
+ int index;
+ VALUE name;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -5908,7 +4511,8 @@ olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo
}
static VALUE
-folemethod_s_allocate(VALUE klass)
+folemethod_s_allocate(klass)
+ VALUE klass;
{
struct olemethoddata *pmethod;
VALUE obj;
@@ -5935,7 +4539,10 @@ folemethod_s_allocate(VALUE klass)
* method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
*/
static VALUE
-folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
+folemethod_initialize(self, oletype, method)
+ VALUE self;
+ VALUE oletype;
+ VALUE method;
{
struct oletypedata *ptype;
VALUE obj = Qnil;
@@ -5944,7 +4551,7 @@ folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
Data_Get_Struct(oletype, struct oletypedata, ptype);
obj = olemethod_from_typeinfo(self, ptype->pTypeInfo, method);
if (obj == Qnil) {
- rb_raise(eWIN32OLERuntimeError, "not found %s",
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "not found %s",
StringValuePtr(method));
}
}
@@ -5966,13 +4573,16 @@ folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
*
*/
static VALUE
-folemethod_name(VALUE self)
+folemethod_name(self)
+ VALUE self;
{
return rb_ivar_get(self, rb_intern("name"));
}
static VALUE
-ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_return_type(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -5980,7 +4590,7 @@ ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index)
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
@@ -5998,7 +4608,8 @@ ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index)
*
*/
static VALUE
-folemethod_return_type(VALUE self)
+folemethod_return_type(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6006,19 +4617,21 @@ folemethod_return_type(VALUE self)
}
static VALUE
-ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_return_vtype(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
- VALUE vvt;
+ VALUE vt;
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
- vvt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
+ vt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
- return vvt;
+ return vt;
}
/*
@@ -6032,7 +4645,8 @@ ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index)
*
*/
static VALUE
-folemethod_return_vtype(VALUE self)
+folemethod_return_vtype(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6040,7 +4654,9 @@ folemethod_return_vtype(VALUE self)
}
static VALUE
-ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_return_type_detail(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6066,7 +4682,8 @@ ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index)
* p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]
*/
static VALUE
-folemethod_return_type_detail(VALUE self)
+folemethod_return_type_detail(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6074,21 +4691,25 @@ folemethod_return_type_detail(VALUE self)
}
static VALUE
-ole_method_invkind(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_invkind(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
VALUE invkind;
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if(FAILED(hr))
- ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
invkind = INT2FIX(pFuncDesc->invkind);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
return invkind;
}
static VALUE
-ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_invoke_kind(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ WORD method_index;
{
VALUE type = rb_str_new2("UNKNOWN");
VALUE invkind = ole_method_invkind(pTypeInfo, method_index);
@@ -6118,7 +4739,8 @@ ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index)
*
*/
static VALUE
-folemethod_invkind(VALUE self)
+folemethod_invkind(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6137,7 +4759,8 @@ folemethod_invkind(VALUE self)
* puts method.invoke_kind # => "FUNC"
*/
static VALUE
-folemethod_invoke_kind(VALUE self)
+folemethod_invoke_kind(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6145,7 +4768,9 @@ folemethod_invoke_kind(VALUE self)
}
static VALUE
-ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_visible(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6174,7 +4799,8 @@ ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index)
* puts method.visible? # => true
*/
static VALUE
-folemethod_visible(VALUE self)
+folemethod_visible(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6182,7 +4808,10 @@ folemethod_visible(VALUE self)
}
static VALUE
-ole_method_event(ITypeInfo *pTypeInfo, UINT method_index, VALUE method_name)
+ole_method_event(pTypeInfo, method_index, method_name)
+ ITypeInfo *pTypeInfo;
+ WORD method_index;
+ VALUE method_name;
{
TYPEATTR *pTypeAttr;
HRESULT hr;
@@ -6256,7 +4885,8 @@ ole_method_event(ITypeInfo *pTypeInfo, UINT method_index, VALUE method_name)
*
*/
static VALUE
-folemethod_event(VALUE self)
+folemethod_event(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6277,7 +4907,8 @@ folemethod_event(VALUE self)
* puts method.event_interface # => WorkbookEvents
*/
static VALUE
-folemethod_event_interface(VALUE self)
+folemethod_event_interface(self)
+ VALUE self;
{
BSTR name;
struct olemethoddata *pmethod;
@@ -6292,14 +4923,14 @@ folemethod_event_interface(VALUE self)
}
static VALUE
-ole_method_docinfo_from_type(
- ITypeInfo *pTypeInfo,
- UINT method_index,
- BSTR *name,
- BSTR *helpstr,
- DWORD *helpcontext,
- BSTR *helpfile
- )
+ole_method_docinfo_from_type(pTypeInfo, method_index, name, helpstr,
+ helpcontext, helpfile)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ BSTR *name;
+ BSTR *helpstr;
+ DWORD *helpcontext;
+ BSTR *helpfile;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6314,7 +4945,9 @@ ole_method_docinfo_from_type(
}
static VALUE
-ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_helpstring(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
HRESULT hr;
BSTR bhelpstring;
@@ -6337,7 +4970,8 @@ ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index)
*
*/
static VALUE
-folemethod_helpstring(VALUE self)
+folemethod_helpstring(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6345,7 +4979,9 @@ folemethod_helpstring(VALUE self)
}
static VALUE
-ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_helpfile(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
HRESULT hr;
BSTR bhelpfile;
@@ -6367,7 +5003,8 @@ ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index)
* puts method.helpfile # => C:\...\VBAXL9.CHM
*/
static VALUE
-folemethod_helpfile(VALUE self)
+folemethod_helpfile(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6376,7 +5013,9 @@ folemethod_helpfile(VALUE self)
}
static VALUE
-ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_helpcontext(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
HRESULT hr;
DWORD helpcontext = 0;
@@ -6397,7 +5036,8 @@ ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index)
* puts method.helpcontext # => 65717
*/
static VALUE
-folemethod_helpcontext(VALUE self)
+folemethod_helpcontext(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6405,7 +5045,9 @@ folemethod_helpcontext(VALUE self)
}
static VALUE
-ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_dispid(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6428,7 +5070,8 @@ ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index)
* puts method.dispid # => 181
*/
static VALUE
-folemethod_dispid(VALUE self)
+folemethod_dispid(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6436,7 +5079,9 @@ folemethod_dispid(VALUE self)
}
static VALUE
-ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_offset_vtbl(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6459,7 +5104,8 @@ ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index)
* puts method.offset_vtbl # => 40
*/
static VALUE
-folemethod_offset_vtbl(VALUE self)
+folemethod_offset_vtbl(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6467,7 +5113,9 @@ folemethod_offset_vtbl(VALUE self)
}
static VALUE
-ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_size_params(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6491,7 +5139,8 @@ ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index)
*
*/
static VALUE
-folemethod_size_params(VALUE self)
+folemethod_size_params(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6499,7 +5148,9 @@ folemethod_size_params(VALUE self)
}
static VALUE
-ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_size_opt_params(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6522,7 +5173,8 @@ ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index)
* puts method.size_opt_params # => 4
*/
static VALUE
-folemethod_size_opt_params(VALUE self)
+folemethod_size_opt_params(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
@@ -6530,7 +5182,9 @@ folemethod_size_opt_params(VALUE self)
}
static VALUE
-ole_method_params(ITypeInfo *pTypeInfo, UINT method_index)
+ole_method_params(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6569,7 +5223,6 @@ ole_method_params(ITypeInfo *pTypeInfo, UINT method_index)
return params;
}
-
/*
* call-seq:
* WIN32OLE_METHOD#params
@@ -6583,19 +5236,14 @@ ole_method_params(ITypeInfo *pTypeInfo, UINT method_index)
* TextVisualLayout]
*/
static VALUE
-folemethod_params(VALUE self)
+folemethod_params(self)
+ VALUE self;
{
struct olemethoddata *pmethod;
Data_Get_Struct(self, struct olemethoddata, pmethod);
return ole_method_params(pmethod->pTypeInfo, pmethod->index);
}
-static VALUE
-folemethod_inspect(VALUE self)
-{
- return default_inspect(self, "WIN32OLE_METHOD");
-}
-
/*
* Document-class: WIN32OLE_PARAM
*
@@ -6614,17 +5262,21 @@ folemethod_inspect(VALUE self)
* puts param1.name # => Filename
*/
static VALUE
-foleparam_name(VALUE self)
+foleparam_name(self)
+ VALUE self;
{
return rb_ivar_get(self, rb_intern("name"));
}
static VALUE
-ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
+ole_param_ole_type(pTypeInfo, method_index, index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
- VALUE type = rb_str_new2("unknown type");
+ VALUE type = rb_str_new2("UNKNOWN");
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr))
return type;
@@ -6645,7 +5297,8 @@ ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
* puts param1.ole_type # => VARIANT
*/
static VALUE
-foleparam_ole_type(VALUE self)
+foleparam_ole_type(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6654,7 +5307,10 @@ foleparam_ole_type(VALUE self)
}
static VALUE
-ole_param_ole_type_detail(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
+ole_param_ole_type_detail(pTypeInfo, method_index, index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6679,7 +5335,8 @@ ole_param_ole_type_detail(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
* p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"]
*/
static VALUE
-foleparam_ole_type_detail(VALUE self)
+foleparam_ole_type_detail(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6688,7 +5345,11 @@ foleparam_ole_type_detail(VALUE self)
}
static VALUE
-ole_param_flag_mask(ITypeInfo *pTypeInfo, UINT method_index, UINT index, USHORT mask)
+ole_param_flag_mask(pTypeInfo, method_index, index, mask)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+ USHORT mask;
{
FUNCDESC *pFuncDesc;
HRESULT hr;
@@ -6712,7 +5373,8 @@ ole_param_flag_mask(ITypeInfo *pTypeInfo, UINT method_index, UINT index, USHORT
* param1 = method.params[0]
* puts param1.input? # => true
*/
-static VALUE foleparam_input(VALUE self)
+static VALUE foleparam_input(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6739,7 +5401,8 @@ static VALUE foleparam_input(VALUE self)
* Headers false
* Processed true
*/
-static VALUE foleparam_output(VALUE self)
+static VALUE foleparam_output(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6757,7 +5420,8 @@ static VALUE foleparam_output(VALUE self)
* param1 = method.params[0]
* puts "#{param1.name} #{param1.optional?}" # => Filename true
*/
-static VALUE foleparam_optional(VALUE self)
+static VALUE foleparam_optional(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6776,7 +5440,8 @@ static VALUE foleparam_optional(VALUE self)
* param = method.params[0]
* puts "#{param.name} #{param.retval?}" # => name true
*/
-static VALUE foleparam_retval(VALUE self)
+static VALUE foleparam_retval(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6785,7 +5450,10 @@ static VALUE foleparam_retval(VALUE self)
}
static VALUE
-ole_param_default(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
+ole_param_default(pTypeInfo, method_index, index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
{
FUNCDESC *pFuncDesc;
ELEMDESC *pElemDesc;
@@ -6836,7 +5504,8 @@ ole_param_default(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
* TextCodepage
* TextVisualLayout
*/
-static VALUE foleparam_default(VALUE self)
+static VALUE foleparam_default(self)
+ VALUE self;
{
struct oleparamdata *pparam;
Data_Get_Struct(self, struct oleparamdata, pparam);
@@ -6844,18 +5513,7 @@ static VALUE foleparam_default(VALUE self)
pparam->index);
}
-static VALUE
-foleparam_inspect(VALUE self)
-{
- VALUE detail = foleparam_name(self);
- VALUE defval = foleparam_default(self);
- if (defval != Qnil) {
- rb_str_cat2(detail, "=");
- rb_str_concat(detail, rb_funcall(defval, rb_intern("inspect"), 0));
- }
- return make_inspect("WIN32OLE_PARAM", detail);
-}
-
+
/*
* Document-class: WIN32OLE_EVENT
*
@@ -6935,7 +5593,9 @@ STDMETHODIMP EVENTSINK_GetIDsOfNames(
}
static long
-ole_search_event_at(VALUE ary, VALUE ev)
+ole_search_event_at(ary, ev)
+ VALUE ary;
+ VALUE ev;
{
VALUE event;
VALUE def_event;
@@ -6943,7 +5603,7 @@ ole_search_event_at(VALUE ary, VALUE ev)
long i, len;
long ret = -1;
def_event = Qnil;
- len = RARRAY_LEN(ary);
+ len = RARRAY(ary)->len;
for(i = 0; i < len; i++) {
event = rb_ary_entry(ary, i);
event_name = rb_ary_entry(event, 1);
@@ -6962,15 +5622,18 @@ ole_search_event_at(VALUE ary, VALUE ev)
}
static VALUE
-ole_search_event(VALUE ary, VALUE ev, BOOL *is_default)
+ole_search_event(ary, ev, is_default)
+ VALUE ary;
+ VALUE ev;
+ BOOL *is_default;
{
VALUE event;
VALUE def_event;
VALUE event_name;
- int i, len;
+ long i, len;
*is_default = FALSE;
def_event = Qnil;
- len = RARRAY_LEN(ary);
+ len = RARRAY(ary)->len;
for(i = 0; i < len; i++) {
event = rb_ary_entry(ary, i);
event_name = rb_ary_entry(event, 1);
@@ -6986,17 +5649,88 @@ ole_search_event(VALUE ary, VALUE ev, BOOL *is_default)
return def_event;
}
+static void
+val2ptr_variant(val, var)
+ VALUE val;
+ VARIANT *var;
+{
+ switch (TYPE(val)) {
+ case T_STRING:
+ if (V_VT(var) == (VT_BSTR | VT_BYREF)) {
+ *V_BSTRREF(var) = ole_mb2wc(StringValuePtr(val), -1);
+ }
+ break;
+ case T_FIXNUM:
+ switch(V_VT(var)) {
+ case (VT_UI1 | VT_BYREF) :
+ *V_UI1REF(var) = NUM2CHR(val);
+ break;
+ case (VT_I2 | VT_BYREF) :
+ *V_I2REF(var) = (short)NUM2INT(val);
+ break;
+ case (VT_I4 | VT_BYREF) :
+ *V_I4REF(var) = NUM2INT(val);
+ break;
+ case (VT_R4 | VT_BYREF) :
+ *V_R4REF(var) = (float)NUM2INT(val);
+ break;
+ case (VT_R8 | VT_BYREF) :
+ *V_R8REF(var) = NUM2INT(val);
+ break;
+ default:
+ break;
+ }
+ break;
+ case T_FLOAT:
+ switch(V_VT(var)) {
+ case (VT_I2 | VT_BYREF) :
+ *V_I2REF(var) = (short)NUM2INT(val);
+ break;
+ case (VT_I4 | VT_BYREF) :
+ *V_I4REF(var) = NUM2INT(val);
+ break;
+ case (VT_R4 | VT_BYREF) :
+ *V_R4REF(var) = (float)NUM2DBL(val);
+ break;
+ case (VT_R8 | VT_BYREF) :
+ *V_R8REF(var) = NUM2DBL(val);
+ break;
+ default:
+ break;
+ }
+ break;
+ case T_BIGNUM:
+ if (V_VT(var) == (VT_R8 | VT_BYREF)) {
+ *V_R8REF(var) = rb_big2dbl(val);
+ }
+ break;
+ case T_TRUE:
+ if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
+ *V_BOOLREF(var) = VARIANT_TRUE;
+ }
+ break;
+ case T_FALSE:
+ if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
+ *V_BOOLREF(var) = VARIANT_FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+}
static void
-ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams)
+ary2ptr_dispparams(ary, pdispparams)
+ VALUE ary;
+ DISPPARAMS *pdispparams;
{
int i;
VALUE v;
VARIANT *pvar;
- for(i = 0; i < RARRAY_LEN(ary) && (unsigned int) i < pdispparams->cArgs; i++) {
+ for(i = 0; i < RARRAY(ary)->len && (unsigned int) i < pdispparams->cArgs; i++) {
v = rb_ary_entry(ary, i);
pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
- ole_val2ptr_variant(v, pvar);
+ val2ptr_variant(v, pvar);
}
}
@@ -7023,7 +5757,8 @@ STDMETHODIMP EVENTSINK_Invoke(
PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
pTypeInfo = pEV->pTypeInfo;
- obj = evs_entry(pEV->m_event_id);
+
+ obj = rb_ary_entry(ary_ole_event, pEV->m_event_id);
if (!rb_obj_is_kind_of(obj, cWIN32OLE_EVENT)) {
return NOERROR;
}
@@ -7063,6 +5798,7 @@ STDMETHODIMP EVENTSINK_Invoke(
else {
result = rb_apply(handler, rb_intern("call"), args);
}
+
if (pvarResult) {
ole_val2variant(result, pvarResult);
}
@@ -7089,7 +5825,10 @@ EVENTSINK_Constructor() {
pEv->lpVtbl = &vtEventSink;
pEv->m_cRef = 0;
pEv->m_event_id = 0;
+ pEv->m_dwCookie = 0;
+ pEv->pConnectionPoint = NULL;
pEv->pTypeInfo = NULL;
+ pEv->ptr_freed = NULL;
return pEv;
}
@@ -7097,14 +5836,17 @@ void EVENTSINK_Destructor(
PIEVENTSINKOBJ pEVObj
) {
if(pEVObj != NULL) {
- OLE_RELEASE(pEVObj->pTypeInfo);
+ *(pEVObj->ptr_freed) = 1;
free(pEVObj);
- pEVObj = NULL;
}
}
static HRESULT
-find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo)
+find_iid(ole, pitf, piid, ppTypeInfo)
+ VALUE ole;
+ char *pitf;
+ IID *piid;
+ ITypeInfo **ppTypeInfo;
{
HRESULT hr;
IDispatch *pDispatch;
@@ -7123,7 +5865,7 @@ find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo)
char *pstr;
BOOL is_found = FALSE;
- LCID lcid = cWIN32OLE_lcid;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
OLEData_Get_Struct(ole, pole);
@@ -7215,7 +5957,10 @@ find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo)
}
static HRESULT
-find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
+find_default_source(ole, piid, ppTypeInfo)
+ VALUE ole;
+ IID *piid;
+ ITypeInfo **ppTypeInfo;
{
HRESULT hr;
IProvideClassInfo2 *pProvideClassInfo2;
@@ -7307,28 +6052,60 @@ find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
}
static void
-ole_event_free(struct oleeventdata *poleev)
+ole_event_free(poleev)
+ struct oleeventdata *poleev;
{
- OLE_FREE(poleev->pConnectionPoint);
- free(poleev);
+ ITypeInfo *pti = NULL;
+ IConnectionPoint *pcp = NULL;
+
+ if (poleev->freed == 1) {
+ /*
+ * this return create memory leak.
+ * but poleev->pEvent->pConnectionPoint shoul'd not be freed
+ * until poleev-> freed == 0.
+ */
+ return;
+ }
+ if(poleev->pEvent) {
+ pti = poleev->pEvent->pTypeInfo;
+ if(pti) OLE_RELEASE(pti);
+ pcp = poleev->pEvent->pConnectionPoint;
+ if(pcp) {
+ pcp->lpVtbl->Unadvise(pcp, poleev->pEvent->m_dwCookie);
+ OLE_RELEASE(pcp);
+ }
+ free(poleev);
+ }
}
+static VALUE fev_s_allocate _((VALUE));
static VALUE
-fev_s_allocate(VALUE klass)
+fev_s_allocate(klass)
+ VALUE klass;
{
VALUE obj;
struct oleeventdata *poleev;
obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev);
- poleev->dwCookie = 0;
- poleev->pConnectionPoint = NULL;
- poleev->event_id = 0;
+ poleev->pEvent = NULL;
return obj;
}
+/*
+ * call-seq:
+ * WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
+ *
+ * Returns OLE event object.
+ * The first argument specifies WIN32OLE object.
+ * The second argument specifies OLE event name.
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
+ */
static VALUE
-ev_advise(int argc, VALUE *argv, VALUE self)
+fev_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
-
VALUE ole, itf;
struct oledata *pole;
char *pitf;
@@ -7339,9 +6116,8 @@ ev_advise(int argc, VALUE *argv, VALUE self)
IConnectionPointContainer *pContainer;
IConnectionPoint *pConnectionPoint;
IEVENTSINKOBJ *pIEV;
- DWORD dwCookie;
+ DWORD dwCookie = 0;
struct oleeventdata *poleev;
- VALUE events = Qnil;
rb_secure(4);
rb_scan_args(argc, argv, "11", &ole, &itf);
@@ -7351,7 +6127,7 @@ ev_advise(int argc, VALUE *argv, VALUE self)
}
if(TYPE(itf) != T_NIL) {
- if (rb_safe_level() > 0 && OBJ_TAINTED(itf)) {
+ if (ruby_safe_level > 0 && OBJ_TAINTED(itf)) {
rb_raise(rb_eSecurityError, "Insecure Event Creation - %s",
StringValuePtr(itf));
}
@@ -7370,7 +6146,7 @@ ev_advise(int argc, VALUE *argv, VALUE self)
pDispatch = pole->pDispatch;
hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
&IID_IConnectionPointContainer,
- (void **)&pContainer);
+ (void**)&pContainer);
if (FAILED(hr)) {
OLE_RELEASE(pTypeInfo);
ole_raise(hr, rb_eRuntimeError,
@@ -7395,32 +6171,15 @@ ev_advise(int argc, VALUE *argv, VALUE self)
}
Data_Get_Struct(self, struct oleeventdata, poleev);
- pIEV->m_event_id
- = NUM2INT(evs_length());
- pIEV->pTypeInfo = pTypeInfo;
- poleev->dwCookie = dwCookie;
- poleev->pConnectionPoint = pConnectionPoint;
- poleev->event_id = pIEV->m_event_id;
-
- return self;
-}
-
-/*
- * call-seq:
- * WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
- *
- * Returns OLE event object.
- * The first argument specifies WIN32OLE object.
- * The second argument specifies OLE event name.
- * ie = WIN32OLE.new('InternetExplorer.Application')
- * ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
- */
-static VALUE
-fev_initialize(int argc, VALUE *argv, VALUE self)
-{
- ev_advise(argc, argv, self);
- evs_push(self);
- rb_ivar_set(self, id_events, rb_ary_new());
+ poleev->pEvent = pIEV;
+ poleev->pEvent->m_event_id
+ = NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0));
+ poleev->pEvent->pConnectionPoint = pConnectionPoint;
+ poleev->pEvent->pTypeInfo = pTypeInfo;
+ poleev->pEvent->m_dwCookie = dwCookie;
+ poleev->freed = 0;
+ poleev->pEvent->ptr_freed = &(poleev->freed);
+ rb_ary_push(ary_ole_event, self);
return self;
}
@@ -7431,7 +6190,8 @@ fev_initialize(int argc, VALUE *argv, VALUE self)
* Translates and dispatches Windows message.
*/
static VALUE
-fev_s_msg_loop(VALUE klass)
+fev_s_msg_loop(klass)
+ VALUE klass;
{
ole_msg_loop();
return Qnil;
@@ -7439,30 +6199,32 @@ fev_s_msg_loop(VALUE klass)
static void
-add_event_call_back(VALUE obj, VALUE event, VALUE data)
+add_event_call_back(obj, event, data)
+ VALUE obj;
+ VALUE event;
+ VALUE data;
{
- long at = -1;
+ long at;
VALUE events = rb_ivar_get(obj, id_events);
if (NIL_P(events) || TYPE(events) != T_ARRAY) {
events = rb_ary_new();
rb_ivar_set(obj, id_events, events);
}
at = ole_search_event_at(events, event);
- if (at >= 0) {
+ if (at > -1) {
rb_ary_delete_at(events, at);
}
rb_ary_push(events, data);
}
static VALUE
-ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg)
+ev_on_event(argc, argv, self, is_ary_arg)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+ VALUE is_ary_arg;
{
- struct oleeventdata *poleev;
VALUE event, args, data;
- Data_Get_Struct(self, struct oleeventdata, poleev);
- if (poleev->pConnectionPoint == NULL) {
- rb_raise(eWIN32OLERuntimeError, "IConnectionPoint not found. You must call advise at first.");
- }
rb_scan_args(argc, argv, "01*", &event, &args);
if(!NIL_P(event)) {
Check_SafeStr(event);
@@ -7483,7 +6245,10 @@ ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg)
* ev.on_event("NavigateComplete") {|url| puts url}
*/
static VALUE
-fev_on_event(int argc, VALUE *argv, VALUE self)
+fev_on_event(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
return ev_on_event(argc, argv, self, Qfalse);
}
@@ -7497,466 +6262,23 @@ fev_on_event(int argc, VALUE *argv, VALUE self)
* you should use this method instead of WIN32OLE_EVENT#on_event.
*/
static VALUE
-fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self)
+fev_on_event_with_outargs(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
return ev_on_event(argc, argv, self, Qtrue);
}
-static VALUE
-fev_unadvise(VALUE self)
-{
- struct oleeventdata *poleev;
- Data_Get_Struct(self, struct oleeventdata, poleev);
- if (poleev->pConnectionPoint) {
- ole_msg_loop();
- evs_delete(poleev->event_id);
- poleev->pConnectionPoint->lpVtbl->Unadvise(poleev->pConnectionPoint, poleev->dwCookie);
- OLE_RELEASE(poleev->pConnectionPoint);
- poleev->pConnectionPoint = NULL;
- }
- return Qnil;
-}
-
-static VALUE
-evs_push(VALUE ev)
-{
- return rb_ary_push(ary_ole_event, ev);
-}
-
-static VALUE
-evs_delete(long i)
-{
- rb_ary_store(ary_ole_event, i, Qnil);
- return Qnil;
-}
-
-static VALUE
-evs_entry(long i)
-{
- return rb_ary_entry(ary_ole_event, i);
-}
-
-static VALUE
-evs_length()
-{
- return rb_funcall(ary_ole_event, rb_intern("length"), 0);
-}
-
-static void
-olevariant_free(struct olevariantdata *pvar)
-{
- VariantClear(&(pvar->realvar));
- VariantClear(&(pvar->var));
- free(pvar);
-}
-
-static VALUE
-folevariant_s_allocate(VALUE klass)
-{
- struct olevariantdata *pvar;
- VALUE obj;
- ole_initialize();
- obj = Data_Make_Struct(klass,struct olevariantdata,0,olevariant_free,pvar);
- VariantInit(&(pvar->var));
- VariantInit(&(pvar->realvar));
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT.array(ary, vt)
- *
- * Returns Ruby object wrapping OLE variant whose variant type is VT_ARRAY.
- * The first argument should be Array object which specifies dimensions
- * and each size of dimensions of OLE array.
- * The second argument specifies variant type of the element of OLE array.
- *
- * The following create 2 dimensions OLE array. The first dimensions size
- * is 3, and the second is 4.
- *
- * ole_ary = WIN32OLE_VARIANT.array([3,4], VT_I4)
- * ruby_ary = ole_ary.value # => [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
- *
- */
-static VALUE
-folevariant_s_array(VALUE klass, VALUE elems, VALUE vvt)
-{
- VALUE obj = Qnil;
- VARTYPE vt;
- struct olevariantdata *pvar;
- SAFEARRAYBOUND *psab = NULL;
- SAFEARRAY *psa = NULL;
- UINT dim = 0;
- UINT i = 0;
-
- ole_initialize();
-
- vt = NUM2UINT(vvt);
- vt = (vt | VT_ARRAY);
- Check_Type(elems, T_ARRAY);
- obj = folevariant_s_allocate(klass);
-
- Data_Get_Struct(obj, struct olevariantdata, pvar);
- dim = RARRAY_LEN(elems);
-
- psab = ALLOC_N(SAFEARRAYBOUND, dim);
-
- if(!psab) {
- rb_raise(rb_eRuntimeError, "memory allocation error");
- }
-
- for (i = 0; i < dim; i++) {
- psab[i].cElements = FIX2INT(rb_ary_entry(elems, i));
- psab[i].lLbound = 0;
- }
-
- psa = SafeArrayCreate(vt & VT_TYPEMASK, dim, psab);
- if (psa == NULL) {
- if (psab) free(psab);
- rb_raise(rb_eRuntimeError, "memory allocation error(SafeArrayCreate)");
- }
-
- V_VT(&(pvar->var)) = vt;
- if (vt & VT_BYREF) {
- V_VT(&(pvar->realvar)) = (vt & ~VT_BYREF);
- V_ARRAY(&(pvar->realvar)) = psa;
- V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
- } else {
- V_ARRAY(&(pvar->var)) = psa;
- }
- if (psab) free(psab);
- return obj;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT.new(val, vartype) #=> WIN32OLE_VARIANT object.
- *
- * Returns Ruby object wrapping OLE variant.
- * The first argument specifies Ruby object to convert OLE variant variable.
- * The second argument specifies VARIANT type.
- * In some situation, you need the WIN32OLE_VARIANT object to pass OLE method
- *
- * shell = WIN32OLE.new("Shell.Application")
- * folder = shell.NameSpace("C:\\Windows")
- * item = folder.ParseName("tmp.txt")
- * # You can't use Ruby String object to call FolderItem.InvokeVerb.
- * # Instead, you have to use WIN32OLE_VARIANT object to call the method.
- * shortcut = WIN32OLE_VARIANT.new("Create Shortcut(\&S)")
- * item.invokeVerb(shortcut)
- *
- */
-static VALUE
-folevariant_initialize(VALUE self, VALUE args)
-{
- int len = 0;
- VARIANT var;
- VALUE val;
- VALUE vvt;
- VARTYPE vt;
- struct olevariantdata *pvar;
-
- len = RARRAY_LEN(args);
- if (len < 1 || len > 3) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
- }
- VariantInit(&var);
- val = rb_ary_entry(args, 0);
- Data_Get_Struct(self, struct olevariantdata, pvar);
- if (len == 1) {
- ole_val2variant(val, &(pvar->var));
- } else {
- vvt = rb_ary_entry(args, 1);
- vt = NUM2INT(vvt);
- ole_val2olevariantdata(val, vt, pvar);
- }
- vt = V_VT(&pvar->var);
- return self;
-}
-
-static SAFEARRAY *
-get_locked_safe_array(VALUE val)
-{
- struct olevariantdata *pvar;
- SAFEARRAY *psa = NULL;
- HRESULT hr;
- Data_Get_Struct(val, struct olevariantdata, pvar);
- if (!(V_VT(&(pvar->var)) & VT_ARRAY)) {
- rb_raise(rb_eTypeError, "variant type is not VT_ARRAY.");
- }
- psa = V_ISBYREF(&(pvar->var)) ? *V_ARRAYREF(&(pvar->var)) : V_ARRAY(&(pvar->var));
- if (psa == NULL) {
- return psa;
- }
- hr = SafeArrayLock(psa);
- if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayLock");
- }
- return psa;
-}
-
-static long *
-ary2safe_array_index(int ary_size, VALUE *ary, SAFEARRAY *psa)
-{
- long dim;
- long *pid;
- long i;
- dim = SafeArrayGetDim(psa);
- if (dim != ary_size) {
- rb_raise(rb_eArgError, "unmatch number of indices");
- }
- pid = ALLOC_N(long, dim);
- if (pid == NULL) {
- rb_raise(rb_eRuntimeError, "failed to allocate memory for indices");
- }
- for (i = 0; i < dim; i++) {
- pid[i] = NUM2INT(ary[i]);
- }
- return pid;
-}
-
-static void
-unlock_safe_array(SAFEARRAY *psa)
-{
- HRESULT hr;
- hr = SafeArrayUnlock(psa);
- if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayUnlock");
- }
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT[i,j,...] #=> element of OLE array.
- *
- * Returns the element of WIN32OLE_VARIANT object(OLE array).
- * This method is available only when the variant type of
- * WIN32OLE_VARIANT object is VT_ARRAY.
- *
- * REMARK:
- * The all indicies should be 0 or natural number and
- * lower than or equal to max indicies.
- * (This point is different with Ruby Array indicies.)
- *
- * obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]])
- * p obj[0,0] # => 1
- * p obj[1,0] # => 4
- * p obj[2,0] # => WIN32OLERuntimeError
- * p obj[0, -1] # => WIN32OLERuntimeError
- *
- */
-static VALUE
-folevariant_ary_aref(int argc, VALUE *argv, VALUE self)
-{
- struct olevariantdata *pvar;
- SAFEARRAY *psa;
- VALUE val = Qnil;
- VARIANT variant;
- long *pid;
- HRESULT hr;
-
- Data_Get_Struct(self, struct olevariantdata, pvar);
- if (!V_ISARRAY(&(pvar->var))) {
- rb_raise(eWIN32OLERuntimeError,
- "`[]' is not available for this variant type object");
- }
- psa = get_locked_safe_array(self);
- if (psa == NULL) {
- return val;
- }
-
- pid = ary2safe_array_index(argc, argv, psa);
-
- VariantInit(&variant);
- V_VT(&variant) = (V_VT(&(pvar->var)) & ~VT_ARRAY) | VT_BYREF;
- hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant));
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to SafeArrayPtrOfIndex");
- }
- val = ole_variant2val(&variant);
-
- unlock_safe_array(psa);
- if (pid) free(pid);
- return val;
-}
-
-static VOID *
-val2variant_ptr(VALUE val, VARIANT *var, VARTYPE vt)
-{
- VOID *p = NULL;
- HRESULT hr = S_OK;
- ole_val2variant_ex(val, var, vt);
- if ((vt & ~VT_BYREF) == VT_VARIANT) {
- p = var;
- } else {
- if ( (vt & ~VT_BYREF) != V_VT(var)) {
- hr = VariantChangeTypeEx(var, var,
- cWIN32OLE_lcid, 0, (VARTYPE)(vt & ~VT_BYREF));
- if (FAILED(hr)) {
- ole_raise(hr, rb_eRuntimeError, "failed to change type");
- }
- }
- p = get_ptr_of_variant(var);
- }
- if (p == NULL) {
- rb_raise(rb_eRuntimeError, "failed to get pointer of variant");
- }
- return p;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT[i,j,...] = val #=> set the element of OLE array
- *
- * Set the element of WIN32OLE_VARIANT object(OLE array) to val.
- * This method is available only when the variant type of
- * WIN32OLE_VARIANT object is VT_ARRAY.
- *
- * REMARK:
- * The all indicies should be 0 or natural number and
- * lower than or equal to max indicies.
- * (This point is different with Ruby Array indicies.)
- *
- * obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]])
- * obj[0,0] = 7
- * obj[1,0] = 8
- * p obj.value # => [[7,2,3], [8,5,6]]
- * obj[2,0] = 9 # => WIN32OLERuntimeError
- * obj[0, -1] = 9 # => WIN32OLERuntimeError
- *
- */
-static VALUE
-folevariant_ary_aset(int argc, VALUE *argv, VALUE self)
-{
- struct olevariantdata *pvar;
- SAFEARRAY *psa;
- VARIANT var;
- VARTYPE vt;
- long *pid;
- HRESULT hr;
- VOID *p = NULL;
-
- Data_Get_Struct(self, struct olevariantdata, pvar);
- if (!V_ISARRAY(&(pvar->var))) {
- rb_raise(eWIN32OLERuntimeError,
- "`[]' is not available for this variant type object");
- }
- psa = get_locked_safe_array(self);
- if (psa == NULL) {
- rb_raise(rb_eRuntimeError, "failed to get SafeArray pointer");
- }
-
- pid = ary2safe_array_index(argc-1, argv, psa);
-
- VariantInit(&var);
- vt = (V_VT(&(pvar->var)) & ~VT_ARRAY);
- p = val2variant_ptr(argv[argc-1], &var, vt);
- if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) ||
- (V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) {
- rb_raise(eWIN32OLERuntimeError, "argument does not have IDispatch or IUnknown Interface");
- }
- hr = SafeArrayPutElement(psa, pid, p);
- if (FAILED(hr)) {
- ole_raise(hr, eWIN32OLERuntimeError, "failed to SafeArrayPutElement");
- }
-
- unlock_safe_array(psa);
- if (pid) free(pid);
- return argv[argc-1];
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT.value #=> Ruby object.
- *
- * Returns Ruby object value from OLE variant.
- * obj = WIN32OLE_VARIANT.new(1, WIN32OLE::VARIANT::VT_BSTR)
- * obj.value # => "1" (not Fixnum object, but String object "1")
- *
- */
-static VALUE
-folevariant_value(VALUE self)
-{
- struct olevariantdata *pvar;
- VALUE val = Qnil;
- VARTYPE vt;
- int dim;
- SAFEARRAY *psa;
- Data_Get_Struct(self, struct olevariantdata, pvar);
-
- val = ole_variant2val(&(pvar->var));
- vt = V_VT(&(pvar->var));
-
- if ((vt & ~VT_BYREF) == (VT_UI1|VT_ARRAY)) {
- if (vt & VT_BYREF) {
- psa = *V_ARRAYREF(&(pvar->var));
- } else {
- psa = V_ARRAY(&(pvar->var));
- }
- if (!psa) {
- return val;
- }
- dim = SafeArrayGetDim(psa);
- if (dim == 1) {
- val = rb_funcall(val, rb_intern("pack"), 1, rb_str_new2("C*"));
- }
- }
- return val;
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT.vartype #=> OLE variant type.
- *
- * Returns OLE variant type.
- * obj = WIN32OLE_VARIANT.new("string")
- * obj.vartype # => WIN32OLE::VARIANT::VT_BSTR
- *
- */
-static VALUE
-folevariant_vartype(VALUE self)
-{
- struct olevariantdata *pvar;
- Data_Get_Struct(self, struct olevariantdata, pvar);
- return INT2FIX(V_VT(&pvar->var));
-}
-
-/*
- * call-seq:
- * WIN32OLE_VARIANT.value = val #=> set WIN32OLE_VARIANT value to val.
- *
- * Sets variant value to val. If the val type does not match variant value
- * type(vartype), then val is changed to match variant value type(vartype)
- * before setting val.
- * Thie method is not available when vartype is VT_ARRAY(except VT_UI1|VT_ARRAY).
- * If the vartype is VT_UI1|VT_ARRAY, the val should be String object.
- *
- * obj = WIN32OLE_VARIANT.new(1) # obj.vartype is WIN32OLE::VARIANT::VT_I4
- * obj.value = 3.2 # 3.2 is changed to 3 when setting value.
- * p obj.value # => 3
- */
-static VALUE
-folevariant_set_value(VALUE self, VALUE val)
-{
- struct olevariantdata *pvar;
- VARTYPE vt;
- Data_Get_Struct(self, struct olevariantdata, pvar);
- vt = V_VT(&(pvar->var));
- if (V_ISARRAY(&(pvar->var)) && ((vt & ~VT_BYREF) != (VT_UI1|VT_ARRAY) || TYPE(val) != T_STRING)) {
- rb_raise(eWIN32OLERuntimeError,
- "`value=' is not available for this variant type object");
- }
- ole_val2olevariantdata(val, vt, pvar);
- return Qnil;
-}
void
Init_win32ole()
{
+ rb_global_variable(&ary_ole_event);
ary_ole_event = rb_ary_new();
- rb_register_mark_object(ary_ole_event);
id_events = rb_intern("events");
+ rb_global_variable(&com_hash);
com_vtbl.QueryInterface = QueryInterface;
com_vtbl.AddRef = AddRef;
com_vtbl.Release = Release;
@@ -7964,8 +6286,15 @@ Init_win32ole()
com_vtbl.GetTypeInfo = GetTypeInfo;
com_vtbl.GetIDsOfNames = GetIDsOfNames;
com_vtbl.Invoke = Invoke;
+
+ message_filter.QueryInterface = mf_QueryInterface;
+ message_filter.AddRef = mf_AddRef;
+ message_filter.Release = mf_Release;
+ message_filter.HandleInComingCall = mf_HandleInComingCall;
+ message_filter.RetryRejectedCall = mf_RetryRejectedCall;
+ message_filter.MessagePending = mf_MessagePending;
+
com_hash = Data_Wrap_Struct(rb_cData, rb_mark_hash, st_free_table, st_init_numtable());
- rb_register_mark_object(com_hash);
cWIN32OLE = rb_define_class("WIN32OLE", rb_cObject);
@@ -7981,18 +6310,16 @@ Init_win32ole()
rb_define_singleton_method(cWIN32OLE, "ole_show_help", fole_s_show_help, -1);
rb_define_singleton_method(cWIN32OLE, "codepage", fole_s_get_code_page, 0);
rb_define_singleton_method(cWIN32OLE, "codepage=", fole_s_set_code_page, 1);
- rb_define_singleton_method(cWIN32OLE, "locale", fole_s_get_locale, 0);
- rb_define_singleton_method(cWIN32OLE, "locale=", fole_s_set_locale, 1);
- rb_define_singleton_method(cWIN32OLE, "create_guid", fole_s_create_guid, 0);
+
rb_define_method(cWIN32OLE, "invoke", fole_invoke, -1);
- rb_define_method(cWIN32OLE, "[]", fole_getproperty_with_bracket, -1);
+ rb_define_method(cWIN32OLE, "[]", fole_getproperty, -1);
rb_define_method(cWIN32OLE, "_invoke", fole_invoke2, 3);
rb_define_method(cWIN32OLE, "_getproperty", fole_getproperty2, 3);
rb_define_method(cWIN32OLE, "_setproperty", fole_setproperty2, 3);
/* support propput method that takes an argument */
- rb_define_method(cWIN32OLE, "[]=", fole_setproperty_with_bracket, -1);
+ rb_define_method(cWIN32OLE, "[]=", fole_setproperty, -1);
rb_define_method(cWIN32OLE, "ole_free", fole_free, 0);
@@ -8009,29 +6336,20 @@ Init_win32ole()
rb_define_method(cWIN32OLE, "ole_method", fole_method_help, 1);
rb_define_alias(cWIN32OLE, "ole_method_help", "ole_method");
+ rb_define_method(cWIN32OLE, "ole_obj_help", fole_obj_help, 0);
rb_define_method(cWIN32OLE, "ole_activex_initialize", fole_activex_initialize, 0);
- rb_define_method(cWIN32OLE, "ole_type", fole_type, 0);
- rb_define_alias(cWIN32OLE, "ole_obj_help", "ole_type");
- rb_define_method(cWIN32OLE, "ole_typelib", fole_typelib, 0);
- rb_define_method(cWIN32OLE, "ole_query_interface", fole_query_interface, 1);
rb_define_const(cWIN32OLE, "VERSION", rb_str_new2(WIN32OLE_VERSION));
rb_define_const(cWIN32OLE, "ARGV", rb_ary_new());
-
- rb_define_const(cWIN32OLE, "CP_ACP", INT2FIX(CP_ACP));
- rb_define_const(cWIN32OLE, "CP_OEMCP", INT2FIX(CP_OEMCP));
- rb_define_const(cWIN32OLE, "CP_MACCP", INT2FIX(CP_MACCP));
- rb_define_const(cWIN32OLE, "CP_THREAD_ACP", INT2FIX(CP_THREAD_ACP));
- rb_define_const(cWIN32OLE, "CP_SYMBOL", INT2FIX(CP_SYMBOL));
- rb_define_const(cWIN32OLE, "CP_UTF7", INT2FIX(CP_UTF7));
- rb_define_const(cWIN32OLE, "CP_UTF8", INT2FIX(CP_UTF8));
-
- rb_define_const(cWIN32OLE, "LOCALE_SYSTEM_DEFAULT", INT2FIX(LOCALE_SYSTEM_DEFAULT));
- rb_define_const(cWIN32OLE, "LOCALE_USER_DEFAULT", INT2FIX(LOCALE_USER_DEFAULT));
+ rb_define_const(cWIN32OLE, "CP_ACP" ,INT2FIX(CP_ACP));
+ rb_define_const(cWIN32OLE, "CP_OEMCP" ,INT2FIX(CP_OEMCP));
+ rb_define_const(cWIN32OLE, "CP_MACCP" ,INT2FIX(CP_MACCP));
+ rb_define_const(cWIN32OLE, "CP_THREAD_ACP",INT2FIX(CP_THREAD_ACP));
+ rb_define_const(cWIN32OLE, "CP_SYMBOL" ,INT2FIX(CP_SYMBOL));
+ rb_define_const(cWIN32OLE, "CP_UTF7" ,INT2FIX(CP_UTF7));
+ rb_define_const(cWIN32OLE, "CP_UTF8" ,INT2FIX(CP_UTF8));
mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT");
- rb_define_const(mWIN32OLE_VARIANT, "VT_EMPTY", INT2FIX(VT_EMPTY));
- rb_define_const(mWIN32OLE_VARIANT, "VT_NULL", INT2FIX(VT_NULL));
rb_define_const(mWIN32OLE_VARIANT, "VT_I2", INT2FIX(VT_I2));
rb_define_const(mWIN32OLE_VARIANT, "VT_I4", INT2FIX(VT_I4));
rb_define_const(mWIN32OLE_VARIANT, "VT_R4", INT2FIX(VT_R4));
@@ -8050,30 +6368,10 @@ Init_win32ole()
rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", INT2FIX(VT_UI1));
rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", INT2FIX(VT_UI2));
rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", INT2FIX(VT_UI4));
-#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
- rb_define_const(mWIN32OLE_VARIANT, "VT_I8", INT2FIX(VT_I8));
- rb_define_const(mWIN32OLE_VARIANT, "VT_UI8", INT2FIX(VT_UI8));
-#endif
rb_define_const(mWIN32OLE_VARIANT, "VT_INT", INT2FIX(VT_INT));
rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", INT2FIX(VT_UINT));
rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", INT2FIX(VT_ARRAY));
rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", INT2FIX(VT_BYREF));
-
- cWIN32OLE_TYPELIB = rb_define_class("WIN32OLE_TYPELIB", rb_cObject);
- rb_define_singleton_method(cWIN32OLE_TYPELIB, "typelibs", foletypelib_s_typelibs, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "initialize", foletypelib_initialize, -2);
- rb_define_method(cWIN32OLE_TYPELIB, "guid", foletypelib_guid, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "name", foletypelib_name, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "version", foletypelib_version, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "major_version", foletypelib_major_version, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "minor_version", foletypelib_minor_version, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "path", foletypelib_path, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "ole_types", foletypelib_ole_types, 0);
- rb_define_alias(cWIN32OLE_TYPELIB, "ole_classes", "ole_types");
- rb_define_method(cWIN32OLE_TYPELIB, "visible?", foletypelib_visible, 0);
- rb_define_method(cWIN32OLE_TYPELIB, "library_name", foletypelib_library_name, 0);
- rb_define_alias(cWIN32OLE_TYPELIB, "to_s", "name");
- rb_define_method(cWIN32OLE_TYPELIB, "inspect", foletypelib_inspect, 0);
cWIN32OLE_TYPE = rb_define_class("WIN32OLE_TYPE", rb_cObject);
rb_define_singleton_method(cWIN32OLE_TYPE, "ole_classes", foletype_s_ole_classes, 1);
@@ -8087,6 +6385,7 @@ Init_win32ole()
rb_define_method(cWIN32OLE_TYPE, "progid", foletype_progid, 0);
rb_define_method(cWIN32OLE_TYPE, "visible?", foletype_visible, 0);
rb_define_alias(cWIN32OLE_TYPE, "to_s", "name");
+
rb_define_method(cWIN32OLE_TYPE, "major_version", foletype_major_version, 0);
rb_define_method(cWIN32OLE_TYPE, "minor_version", foletype_minor_version, 0);
rb_define_method(cWIN32OLE_TYPE, "typekind", foletype_typekind, 0);
@@ -8095,10 +6394,7 @@ Init_win32ole()
rb_define_method(cWIN32OLE_TYPE, "helpfile", foletype_helpfile, 0);
rb_define_method(cWIN32OLE_TYPE, "helpcontext", foletype_helpcontext, 0);
rb_define_method(cWIN32OLE_TYPE, "variables", foletype_variables, 0);
- rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, 0);
- rb_define_method(cWIN32OLE_TYPE, "ole_typelib", foletype_ole_typelib, 0);
- rb_define_method(cWIN32OLE_TYPE, "implemented_ole_types", foletype_impl_ole_types, 0);
- rb_define_method(cWIN32OLE_TYPE, "inspect", foletype_inspect, 0);
+ rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, -1);
cWIN32OLE_VARIABLE = rb_define_class("WIN32OLE_VARIABLE", rb_cObject);
rb_define_method(cWIN32OLE_VARIABLE, "name", folevariable_name, 0);
@@ -8108,12 +6404,12 @@ Init_win32ole()
rb_define_method(cWIN32OLE_VARIABLE, "visible?", folevariable_visible, 0);
rb_define_method(cWIN32OLE_VARIABLE, "variable_kind", folevariable_variable_kind, 0);
rb_define_method(cWIN32OLE_VARIABLE, "varkind", folevariable_varkind, 0);
- rb_define_method(cWIN32OLE_VARIABLE, "inspect", folevariable_inspect, 0);
rb_define_alias(cWIN32OLE_VARIABLE, "to_s", "name");
cWIN32OLE_METHOD = rb_define_class("WIN32OLE_METHOD", rb_cObject);
rb_define_alloc_func(cWIN32OLE_METHOD, folemethod_s_allocate);
rb_define_method(cWIN32OLE_METHOD, "initialize", folemethod_initialize, 2);
+
rb_define_method(cWIN32OLE_METHOD, "name", folemethod_name, 0);
rb_define_method(cWIN32OLE_METHOD, "return_type", folemethod_return_type, 0);
rb_define_method(cWIN32OLE_METHOD, "return_vtype", folemethod_return_vtype, 0);
@@ -8132,7 +6428,6 @@ Init_win32ole()
rb_define_method(cWIN32OLE_METHOD, "size_opt_params", folemethod_size_opt_params, 0);
rb_define_method(cWIN32OLE_METHOD, "params", folemethod_params, 0);
rb_define_alias(cWIN32OLE_METHOD, "to_s", "name");
- rb_define_method(cWIN32OLE_METHOD, "inspect", folemethod_inspect, 0);
cWIN32OLE_PARAM = rb_define_class("WIN32OLE_PARAM", rb_cObject);
rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0);
@@ -8144,29 +6439,14 @@ Init_win32ole()
rb_define_method(cWIN32OLE_PARAM, "retval?", foleparam_retval, 0);
rb_define_method(cWIN32OLE_PARAM, "default", foleparam_default, 0);
rb_define_alias(cWIN32OLE_PARAM, "to_s", "name");
- rb_define_method(cWIN32OLE_PARAM, "inspect", foleparam_inspect, 0);
cWIN32OLE_EVENT = rb_define_class("WIN32OLE_EVENT", rb_cObject);
- rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0);
+
rb_define_alloc_func(cWIN32OLE_EVENT, fev_s_allocate);
rb_define_method(cWIN32OLE_EVENT, "initialize", fev_initialize, -1);
+ rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0);
+
rb_define_method(cWIN32OLE_EVENT, "on_event", fev_on_event, -1);
rb_define_method(cWIN32OLE_EVENT, "on_event_with_outargs", fev_on_event_with_outargs, -1);
- rb_define_method(cWIN32OLE_EVENT, "unadvise", fev_unadvise, 0);
-
- cWIN32OLE_VARIANT = rb_define_class("WIN32OLE_VARIANT", rb_cObject);
- rb_define_alloc_func(cWIN32OLE_VARIANT, folevariant_s_allocate);
- rb_define_singleton_method(cWIN32OLE_VARIANT, "array", folevariant_s_array, 2);
- rb_define_method(cWIN32OLE_VARIANT, "initialize", folevariant_initialize, -2);
- rb_define_method(cWIN32OLE_VARIANT, "value", folevariant_value, 0);
- rb_define_method(cWIN32OLE_VARIANT, "value=", folevariant_set_value, 1);
- rb_define_method(cWIN32OLE_VARIANT, "vartype", folevariant_vartype, 0);
- rb_define_method(cWIN32OLE_VARIANT, "[]", folevariant_ary_aref, -1);
- rb_define_method(cWIN32OLE_VARIANT, "[]=", folevariant_ary_aset, -1);
- rb_define_const(cWIN32OLE_VARIANT, "Empty", rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, INT2FIX(VT_EMPTY)));
- rb_define_const(cWIN32OLE_VARIANT, "Null", rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, INT2FIX(VT_NULL)));
- rb_define_const(cWIN32OLE_VARIANT, "Nothing", rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, INT2FIX(VT_DISPATCH)));
-
- eWIN32OLERuntimeError = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError);
-
+ eWIN32OLE_RUNTIME_ERROR = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError);
}
diff --git a/ext/zlib/.cvsignore b/ext/zlib/.cvsignore
index 814345ece8..4088712231 100644
--- a/ext/zlib/.cvsignore
+++ b/ext/zlib/.cvsignore
@@ -1,4 +1,3 @@
Makefile
mkmf.log
*.def
-extconf.h
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index b4e76af3c6..53b971b189 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -10,7 +10,7 @@ require 'rbconfig'
dir_config 'zlib'
-if %w'z libz zlib zdll'.find {|z| have_library(z, 'deflateReset')} and
+if %w'z libz zlib1 zlib zdll'.find {|z| have_library(z, 'deflateReset')} and
have_header('zlib.h') then
defines = []
@@ -22,7 +22,7 @@ if %w'z libz zlib zdll'.find {|z| have_library(z, 'deflateReset')} and
os_code = 'AMIGA'
when /\Aos2[\-_]emx\z/ then
os_code = 'OS2'
- when 'mswin32', 'mingw32', 'bccwin32' then
+ when /mswin|mingw|bccwin/ then
# NOTE: cygwin should be regarded as Unix.
os_code = 'WIN32'
else
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 4002b75a5c..306e267856 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -31,7 +31,7 @@
/*--------- Prototypes --------*/
-static NORETURN(void raise_zlib_error _((int, const char*)));
+static NORETURN(void raise_zlib_error _((int, const char *)));
static VALUE rb_zlib_version _((VALUE));
static VALUE do_checksum _((int, VALUE*, uLong (*) _((uLong, const Bytef*, uInt))));
static VALUE rb_zlib_adler32 _((int, VALUE*, VALUE));
@@ -43,14 +43,14 @@ static void finalizer_warn _((const char*));
struct zstream;
struct zstream_funcs;
-static void zstream_init _((struct zstream*, const struct zstream_funcs*));
+static void zstream_init _((struct zstream*, const struct zstream_funcs *));
static void zstream_expand_buffer _((struct zstream*));
static void zstream_expand_buffer_into _((struct zstream*, int));
-static void zstream_append_buffer _((struct zstream*, const Bytef*, int));
+static void zstream_append_buffer _((struct zstream*, const char*, int));
static VALUE zstream_detach_buffer _((struct zstream*));
static VALUE zstream_shift_buffer _((struct zstream*, int));
static void zstream_buffer_ungetc _((struct zstream*, int));
-static void zstream_append_input _((struct zstream*, const Bytef*, unsigned int));
+static void zstream_append_input _((struct zstream*, const char*, unsigned int));
static void zstream_discard_input _((struct zstream*, unsigned int));
static void zstream_reset_input _((struct zstream*));
static void zstream_passthrough_input _((struct zstream*));
@@ -111,8 +111,6 @@ static VALUE gzfile_new _((VALUE, const struct zstream_funcs*, void (*) _((struc
static void gzfile_reset _((struct gzfile*));
static void gzfile_close _((struct gzfile*, int));
static void gzfile_write_raw _((struct gzfile*));
-static VALUE gzfile_read_raw_partial _((VALUE));
-static VALUE gzfile_read_raw_rescue _((VALUE));
static VALUE gzfile_read_raw _((struct gzfile*));
static int gzfile_read_raw_ensure _((struct gzfile*, int));
static char *gzfile_read_raw_until_zero _((struct gzfile*, long));
@@ -197,7 +195,9 @@ static VALUE cZError, cStreamEnd, cNeedDict;
static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError;
static void
-raise_zlib_error(int err, const char *msg)
+raise_zlib_error(err, msg)
+ int err;
+ const char *msg;
{
VALUE exc;
@@ -245,7 +245,8 @@ raise_zlib_error(int err, const char *msg)
/*--- Warning (in finalizer) ---*/
static void
-finalizer_warn(const char *msg)
+finalizer_warn(msg)
+ const char *msg;
{
fprintf(stderr, "zlib(finalizer): %s\n", msg);
}
@@ -257,7 +258,8 @@ finalizer_warn(const char *msg)
* Returns the string which represents the version of zlib library.
*/
static VALUE
-rb_zlib_version(VALUE klass)
+rb_zlib_version(klass)
+ VALUE klass;
{
VALUE str;
@@ -270,7 +272,7 @@ static VALUE
do_checksum(argc, argv, func)
int argc;
VALUE *argv;
- uLong (*func) _((uLong, const Bytef*, uInt));
+ uLong (*func) _((uLong, const Bytef *, uInt));
{
VALUE str, vsum;
unsigned long sum;
@@ -292,7 +294,7 @@ do_checksum(argc, argv, func)
}
else {
StringValue(str);
- sum = func(sum, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str));
+ sum = func(sum, RSTRING(str)->ptr, RSTRING(str)->len);
}
return rb_uint2inum(sum);
}
@@ -307,7 +309,10 @@ do_checksum(argc, argv, func)
* FIXME: expression.
*/
static VALUE
-rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
+rb_zlib_adler32(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
return do_checksum(argc, argv, adler32);
}
@@ -322,7 +327,10 @@ rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
* FIXME: expression.
*/
static VALUE
-rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
+rb_zlib_crc32(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
return do_checksum(argc, argv, crc32);
}
@@ -331,7 +339,8 @@ rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
* Returns the table for calculating CRC checksum as an array.
*/
static VALUE
-rb_zlib_crc_table(VALUE obj)
+rb_zlib_crc_table(obj)
+ VALUE obj;
{
const unsigned long *crctbl;
VALUE dst;
@@ -390,19 +399,24 @@ static const struct zstream_funcs inflate_funcs = {
static voidpf
-zlib_mem_alloc(voidpf opaque, uInt items, uInt size)
+zlib_mem_alloc(opaque, items, size)
+ voidpf opaque;
+ uInt items, size;
{
return xmalloc(items * size);
}
static void
-zlib_mem_free(voidpf opaque, voidpf address)
+zlib_mem_free(opaque, address)
+ voidpf opaque, address;
{
free(address);
}
static void
-zstream_init(struct zstream *z, const struct zstream_funcs *func)
+zstream_init(z, func)
+ struct zstream *z;
+ const struct zstream_funcs *func;
{
z->flags = 0;
z->buf = Qnil;
@@ -423,7 +437,8 @@ zstream_init(struct zstream *z, const struct zstream_funcs *func)
#define zstream_init_inflate(z) zstream_init((z), &inflate_funcs)
static void
-zstream_expand_buffer(struct zstream *z)
+zstream_expand_buffer(z)
+ struct zstream *z;
{
long inc;
@@ -432,13 +447,13 @@ zstream_expand_buffer(struct zstream *z)
rb_str_buf_new makes a zero-length string. */
z->buf = rb_str_new(0, ZSTREAM_INITIAL_BUFSIZE);
z->buf_filled = 0;
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
+ z->stream.next_out = RSTRING(z->buf)->ptr;
z->stream.avail_out = ZSTREAM_INITIAL_BUFSIZE;
RBASIC(z->buf)->klass = 0;
return;
}
- if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ if (RSTRING(z->buf)->len - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
/* to keep other threads from freezing */
z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
}
@@ -451,42 +466,47 @@ zstream_expand_buffer(struct zstream *z)
z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
}
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
}
static void
-zstream_expand_buffer_into(struct zstream *z, int size)
+zstream_expand_buffer_into(z, size)
+ struct zstream *z;
+ int size;
{
if (NIL_P(z->buf)) {
/* I uses rb_str_new here not rb_str_buf_new because
rb_str_buf_new makes a zero-length string. */
z->buf = rb_str_new(0, size);
z->buf_filled = 0;
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
+ z->stream.next_out = RSTRING(z->buf)->ptr;
z->stream.avail_out = size;
RBASIC(z->buf)->klass = 0;
}
else if (z->stream.avail_out != size) {
rb_str_resize(z->buf, z->buf_filled + size);
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
z->stream.avail_out = size;
}
}
static void
-zstream_append_buffer(struct zstream *z, const Bytef *src, int len)
+zstream_append_buffer(z, src, len)
+ struct zstream *z;
+ const char *src;
+ int len;
{
if (NIL_P(z->buf)) {
z->buf = rb_str_buf_new(len);
- rb_str_buf_cat(z->buf, (const char*)src, len);
+ rb_str_buf_cat(z->buf, src, len);
z->buf_filled = len;
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
+ z->stream.next_out = RSTRING(z->buf)->ptr;
z->stream.avail_out = 0;
RBASIC(z->buf)->klass = 0;
return;
}
- if (RSTRING_LEN(z->buf) < z->buf_filled + len) {
+ if (RSTRING(z->buf)->len < z->buf_filled + len) {
rb_str_resize(z->buf, z->buf_filled + len);
z->stream.avail_out = 0;
}
@@ -498,16 +518,17 @@ zstream_append_buffer(struct zstream *z, const Bytef *src, int len)
z->stream.avail_out = 0;
}
}
- memcpy(RSTRING_PTR(z->buf) + z->buf_filled, src, len);
+ memcpy(RSTRING(z->buf)->ptr + z->buf_filled, src, len);
z->buf_filled += len;
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
}
#define zstream_append_buffer2(z,v) \
- zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v))
+ zstream_append_buffer((z),RSTRING(v)->ptr,RSTRING(v)->len)
static VALUE
-zstream_detach_buffer(struct zstream *z)
+zstream_detach_buffer(z)
+ struct zstream *z;
{
VALUE dst;
@@ -528,7 +549,9 @@ zstream_detach_buffer(struct zstream *z)
}
static VALUE
-zstream_shift_buffer(struct zstream *z, int len)
+zstream_shift_buffer(z, len)
+ struct zstream *z;
+ int len;
{
VALUE dst;
@@ -539,10 +562,10 @@ zstream_shift_buffer(struct zstream *z, int len)
dst = rb_str_substr(z->buf, 0, len);
RBASIC(dst)->klass = rb_cString;
z->buf_filled -= len;
- memmove(RSTRING_PTR(z->buf), RSTRING_PTR(z->buf) + len,
+ memmove(RSTRING(z->buf)->ptr, RSTRING(z->buf)->ptr + len,
z->buf_filled);
- z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
- z->stream.avail_out = RSTRING_LEN(z->buf) - z->buf_filled;
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
+ z->stream.avail_out = RSTRING(z->buf)->len - z->buf_filled;
if (z->stream.avail_out > ZSTREAM_AVAIL_OUT_STEP_MAX) {
z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
}
@@ -551,14 +574,16 @@ zstream_shift_buffer(struct zstream *z, int len)
}
static void
-zstream_buffer_ungetc(struct zstream *z, int c)
+zstream_buffer_ungetc(z, c)
+ struct zstream *z;
+ int c;
{
- if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) {
+ if (NIL_P(z->buf) || RSTRING(z->buf)->len - z->buf_filled == 0) {
zstream_expand_buffer(z);
}
- memmove(RSTRING_PTR(z->buf) + 1, RSTRING_PTR(z->buf), z->buf_filled);
- RSTRING_PTR(z->buf)[0] = (char)c;
+ memmove(RSTRING(z->buf)->ptr + 1, RSTRING(z->buf)->ptr, z->buf_filled);
+ RSTRING(z->buf)->ptr[0] = (char)c;
z->buf_filled++;
if (z->stream.avail_out > 0) {
z->stream.next_out++;
@@ -567,44 +592,51 @@ zstream_buffer_ungetc(struct zstream *z, int c)
}
static void
-zstream_append_input(struct zstream *z, const Bytef *src, unsigned int len)
+zstream_append_input(z, src, len)
+ struct zstream *z;
+ const char *src;
+ unsigned int len;
{
if (len <= 0) return;
if (NIL_P(z->input)) {
z->input = rb_str_buf_new(len);
- rb_str_buf_cat(z->input, (const char*)src, len);
+ rb_str_buf_cat(z->input, src, len);
RBASIC(z->input)->klass = 0;
}
else {
- rb_str_buf_cat(z->input, (const char*)src, len);
+ rb_str_buf_cat(z->input, src, len);
}
}
#define zstream_append_input2(z,v)\
- zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v))
+ zstream_append_input((z), RSTRING(v)->ptr, RSTRING(v)->len)
static void
-zstream_discard_input(struct zstream *z, unsigned int len)
+zstream_discard_input(z, len)
+ struct zstream *z;
+ unsigned int len;
{
- if (NIL_P(z->input) || RSTRING_LEN(z->input) <= len) {
+ if (NIL_P(z->input) || RSTRING(z->input)->len <= len) {
z->input = Qnil;
}
else {
- memmove(RSTRING_PTR(z->input), RSTRING_PTR(z->input) + len,
- RSTRING_LEN(z->input) - len);
- rb_str_resize(z->input, RSTRING_LEN(z->input) - len);
+ memmove(RSTRING(z->input)->ptr, RSTRING(z->input)->ptr + len,
+ RSTRING(z->input)->len - len);
+ rb_str_resize(z->input, RSTRING(z->input)->len - len);
}
}
static void
-zstream_reset_input(struct zstream *z)
+zstream_reset_input(z)
+ struct zstream *z;
{
z->input = Qnil;
}
static void
-zstream_passthrough_input(struct zstream *z)
+zstream_passthrough_input(z)
+ struct zstream *z;
{
if (!NIL_P(z->input)) {
zstream_append_buffer2(z, z->input);
@@ -613,7 +645,8 @@ zstream_passthrough_input(struct zstream *z)
}
static VALUE
-zstream_detach_input(struct zstream *z)
+zstream_detach_input(z)
+ struct zstream *z;
{
VALUE dst;
@@ -625,12 +658,12 @@ zstream_detach_input(struct zstream *z)
RBASIC(dst)->klass = rb_cString;
}
z->input = Qnil;
- RBASIC(dst)->klass = rb_cString;
return dst;
}
static void
-zstream_reset(struct zstream *z)
+zstream_reset(z)
+ struct zstream *z;
{
int err;
@@ -647,7 +680,8 @@ zstream_reset(struct zstream *z)
}
static VALUE
-zstream_end(struct zstream *z)
+zstream_end(z)
+ struct zstream *z;
{
int err;
@@ -670,20 +704,24 @@ zstream_end(struct zstream *z)
}
static void
-zstream_run(struct zstream *z, Bytef *src, uInt len, int flush)
+zstream_run(z, src, len, flush)
+ struct zstream *z;
+ Bytef *src;
+ uInt len;
+ int flush;
{
uInt n;
int err;
volatile VALUE guard;
if (NIL_P(z->input) && len == 0) {
- z->stream.next_in = (Bytef*)"";
+ z->stream.next_in = "";
z->stream.avail_in = 0;
}
else {
zstream_append_input(z, src, len);
- z->stream.next_in = (Bytef*)RSTRING_PTR(z->input);
- z->stream.avail_in = RSTRING_LEN(z->input);
+ z->stream.next_in = RSTRING(z->input)->ptr;
+ z->stream.avail_in = RSTRING(z->input)->len;
/* keep reference to `z->input' so as not to be garbage collected
after zstream_reset_input() and prevent `z->stream.next_in'
from dangling. */
@@ -732,24 +770,27 @@ zstream_run(struct zstream *z, Bytef *src, uInt len, int flush)
}
static VALUE
-zstream_sync(struct zstream *z, Bytef *src, uInt len)
+zstream_sync(z, src, len)
+ struct zstream *z;
+ Bytef *src;
+ uInt len;
{
VALUE rest;
int err;
if (!NIL_P(z->input)) {
- z->stream.next_in = (Bytef*)RSTRING_PTR(z->input);
- z->stream.avail_in = RSTRING_LEN(z->input);
+ z->stream.next_in = RSTRING(z->input)->ptr;
+ z->stream.avail_in = RSTRING(z->input)->len;
err = inflateSync(&z->stream);
if (err == Z_OK) {
zstream_discard_input(z,
- RSTRING_LEN(z->input) - z->stream.avail_in);
+ RSTRING(z->input)->len - z->stream.avail_in);
zstream_append_input(z, src, len);
return Qtrue;
}
zstream_reset_input(z);
if (err != Z_DATA_ERROR) {
- rest = rb_str_new((char*)z->stream.next_in, z->stream.avail_in);
+ rest = rb_str_new(z->stream.next_in, z->stream.avail_in);
raise_zlib_error(err, z->stream.msg);
}
}
@@ -764,21 +805,23 @@ zstream_sync(struct zstream *z, Bytef *src, uInt len)
return Qtrue;
}
if (err != Z_DATA_ERROR) {
- rest = rb_str_new((char*)z->stream.next_in, z->stream.avail_in);
+ rest = rb_str_new(z->stream.next_in, z->stream.avail_in);
raise_zlib_error(err, z->stream.msg);
}
return Qfalse;
}
static void
-zstream_mark(struct zstream *z)
+zstream_mark(z)
+ struct zstream *z;
{
rb_gc_mark(z->buf);
rb_gc_mark(z->input);
}
static void
-zstream_finalize(struct zstream *z)
+zstream_finalize(z)
+ struct zstream *z;
{
int err = z->func->end(&z->stream);
if (err == Z_STREAM_ERROR)
@@ -788,7 +831,8 @@ zstream_finalize(struct zstream *z)
}
static void
-zstream_free(struct zstream *z)
+zstream_free(z)
+ struct zstream *z;
{
if (ZSTREAM_IS_READY(z)) {
zstream_finalize(z);
@@ -797,7 +841,9 @@ zstream_free(struct zstream *z)
}
static VALUE
-zstream_new(VALUE klass, const struct zstream_funcs *funcs)
+zstream_new(klass, funcs)
+ VALUE klass;
+ const struct zstream_funcs *funcs;
{
VALUE obj;
struct zstream *z;
@@ -812,7 +858,8 @@ zstream_new(VALUE klass, const struct zstream_funcs *funcs)
#define zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs)
static struct zstream *
-get_zstream(VALUE obj)
+get_zstream(obj)
+ VALUE obj;
{
struct zstream *z;
@@ -892,7 +939,8 @@ get_zstream(VALUE obj)
* exception.
*/
static VALUE
-rb_zstream_end(VALUE obj)
+rb_zstream_end(obj)
+ VALUE obj;
{
zstream_end(get_zstream(obj));
return Qnil;
@@ -903,7 +951,8 @@ rb_zstream_end(VALUE obj)
* are discarded.
*/
static VALUE
-rb_zstream_reset(VALUE obj)
+rb_zstream_reset(obj)
+ VALUE obj;
{
zstream_reset(get_zstream(obj));
return Qnil;
@@ -914,12 +963,13 @@ rb_zstream_reset(VALUE obj)
* Zlib::Inflate#finish for details of this behavior.
*/
static VALUE
-rb_zstream_finish(VALUE obj)
+rb_zstream_finish(obj)
+ VALUE obj;
{
struct zstream *z = get_zstream(obj);
VALUE dst;
- zstream_run(z, (Bytef*)"", 0, Z_FINISH);
+ zstream_run(z, "", 0, Z_FINISH);
dst = zstream_detach_buffer(z);
OBJ_INFECT(dst, obj);
@@ -930,7 +980,8 @@ rb_zstream_finish(VALUE obj)
* Flushes input buffer and returns all data in that buffer.
*/
static VALUE
-rb_zstream_flush_next_in(VALUE obj)
+rb_zstream_flush_next_in(obj)
+ VALUE obj;
{
struct zstream *z;
VALUE dst;
@@ -945,7 +996,8 @@ rb_zstream_flush_next_in(VALUE obj)
* Flushes output buffer and returns all data in that buffer.
*/
static VALUE
-rb_zstream_flush_next_out(VALUE obj)
+rb_zstream_flush_next_out(obj)
+ VALUE obj;
{
struct zstream *z;
VALUE dst;
@@ -961,7 +1013,8 @@ rb_zstream_flush_next_out(VALUE obj)
* space is allocated automatically, this method returns 0 normally.
*/
static VALUE
-rb_zstream_avail_out(VALUE obj)
+rb_zstream_avail_out(obj)
+ VALUE obj;
{
struct zstream *z;
Data_Get_Struct(obj, struct zstream, z);
@@ -975,7 +1028,8 @@ rb_zstream_avail_out(VALUE obj)
* method.
*/
static VALUE
-rb_zstream_set_avail_out(VALUE obj, VALUE size)
+rb_zstream_set_avail_out(obj, size)
+ VALUE obj, size;
{
struct zstream *z = get_zstream(obj);
@@ -988,18 +1042,20 @@ rb_zstream_set_avail_out(VALUE obj, VALUE size)
* Returns bytes of data in the input buffer. Normally, returns 0.
*/
static VALUE
-rb_zstream_avail_in(VALUE obj)
+rb_zstream_avail_in(obj)
+ VALUE obj;
{
struct zstream *z;
Data_Get_Struct(obj, struct zstream, z);
- return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING_LEN(z->input)));
+ return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING(z->input)->len));
}
/*
* Returns the total bytes of the input data to the stream. FIXME
*/
static VALUE
-rb_zstream_total_in(VALUE obj)
+rb_zstream_total_in(obj)
+ VALUE obj;
{
return rb_uint2inum(get_zstream(obj)->stream.total_in);
}
@@ -1008,7 +1064,8 @@ rb_zstream_total_in(VALUE obj)
* Returns the total bytes of the output data from the stream. FIXME
*/
static VALUE
-rb_zstream_total_out(VALUE obj)
+rb_zstream_total_out(obj)
+ VALUE obj;
{
return rb_uint2inum(get_zstream(obj)->stream.total_out);
}
@@ -1019,7 +1076,8 @@ rb_zstream_total_out(VALUE obj)
* <tt>Zlib::UNKNOWN</tt>.
*/
static VALUE
-rb_zstream_data_type(VALUE obj)
+rb_zstream_data_type(obj)
+ VALUE obj;
{
return INT2FIX(get_zstream(obj)->stream.data_type);
}
@@ -1028,7 +1086,8 @@ rb_zstream_data_type(VALUE obj)
* Returns the adler-32 checksum.
*/
static VALUE
-rb_zstream_adler(VALUE obj)
+rb_zstream_adler(obj)
+ VALUE obj;
{
return rb_uint2inum(get_zstream(obj)->stream.adler);
}
@@ -1037,7 +1096,8 @@ rb_zstream_adler(VALUE obj)
* Returns true if the stream is finished.
*/
static VALUE
-rb_zstream_finished_p(VALUE obj)
+rb_zstream_finished_p(obj)
+ VALUE obj;
{
return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse;
}
@@ -1046,7 +1106,8 @@ rb_zstream_finished_p(VALUE obj)
* Returns true if the stream is closed.
*/
static VALUE
-rb_zstream_closed_p(VALUE obj)
+rb_zstream_closed_p(obj)
+ VALUE obj;
{
struct zstream *z;
Data_Get_Struct(obj, struct zstream, z);
@@ -1075,7 +1136,8 @@ rb_zstream_closed_p(VALUE obj)
static VALUE
-rb_deflate_s_allocate(VALUE klass)
+rb_deflate_s_allocate(klass)
+ VALUE klass;
{
return zstream_deflate_new(klass);
}
@@ -1090,7 +1152,10 @@ rb_deflate_s_allocate(VALUE klass)
* TODO: document better!
*/
static VALUE
-rb_deflate_initialize(int argc, VALUE *argv, VALUE obj)
+rb_deflate_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct zstream *z;
VALUE level, wbits, memlevel, strategy;
@@ -1114,28 +1179,35 @@ rb_deflate_initialize(int argc, VALUE *argv, VALUE obj)
* Duplicates the deflate stream.
*/
static VALUE
-rb_deflate_init_copy(VALUE self, VALUE orig)
+rb_deflate_init_copy(self, orig)
+ VALUE self, orig;
{
- struct zstream *z1 = get_zstream(self);
- struct zstream *z2 = get_zstream(orig);
+ struct zstream *z1, *z2;
int err;
+ Data_Get_Struct(self, struct zstream, z1);
+ z2 = get_zstream(orig);
+
err = deflateCopy(&z1->stream, &z2->stream);
if (err != Z_OK) {
raise_zlib_error(err, 0);
}
+ z1->input = NIL_P(z2->input) ? Qnil : rb_str_dup(z2->input);
+ z1->buf = NIL_P(z2->buf) ? Qnil : rb_str_dup(z2->buf);
+ z1->buf_filled = z2->buf_filled;
z1->flags = z2->flags;
return self;
}
static VALUE
-deflate_run(VALUE args)
+deflate_run(args)
+ VALUE args;
{
- struct zstream *z = (struct zstream*)((VALUE*)args)[0];
- VALUE src = ((VALUE*)args)[1];
+ struct zstream *z = (struct zstream *)((VALUE *)args)[0];
+ VALUE src = ((VALUE *)args)[1];
- zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_FINISH);
+ zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_FINISH);
return zstream_detach_buffer(z);
}
@@ -1160,7 +1232,10 @@ deflate_run(VALUE args)
*
*/
static VALUE
-rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
+rb_deflate_s_deflate(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
struct zstream z;
VALUE src, level, dst, args[2];
@@ -1186,15 +1261,18 @@ rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
}
static void
-do_deflate(struct zstream *z, VALUE src, int flush)
+do_deflate(z, src, flush)
+ struct zstream *z;
+ VALUE src;
+ int flush;
{
if (NIL_P(src)) {
- zstream_run(z, (Bytef*)"", 0, Z_FINISH);
+ zstream_run(z, "", 0, Z_FINISH);
return;
}
StringValue(src);
- if (flush != Z_NO_FLUSH || RSTRING_LEN(src) > 0) { /* prevent BUF_ERROR */
- zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), flush);
+ if (flush != Z_NO_FLUSH || RSTRING(src)->len > 0) { /* prevent BUF_ERROR */
+ zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, flush);
}
}
@@ -1213,7 +1291,10 @@ do_deflate(struct zstream *z, VALUE src, int flush)
* TODO: document better!
*/
static VALUE
-rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
+rb_deflate_deflate(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct zstream *z = get_zstream(obj);
VALUE src, flush, dst;
@@ -1235,7 +1316,8 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
* preserved in output buffer.
*/
static VALUE
-rb_deflate_addstr(VALUE obj, VALUE src)
+rb_deflate_addstr(obj, src)
+ VALUE obj, src;
{
OBJ_INFECT(obj, src);
do_deflate(get_zstream(obj), src, Z_NO_FLUSH);
@@ -1252,7 +1334,10 @@ rb_deflate_addstr(VALUE obj, VALUE src)
* TODO: document better!
*/
static VALUE
-rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
+rb_deflate_flush(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct zstream *z = get_zstream(obj);
VALUE v_flush, dst;
@@ -1261,7 +1346,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
rb_scan_args(argc, argv, "01", &v_flush);
flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
- zstream_run(z, (Bytef*)"", 0, flush);
+ zstream_run(z, "", 0, flush);
}
dst = zstream_detach_buffer(z);
@@ -1279,7 +1364,8 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
* TODO: document better!
*/
static VALUE
-rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
+rb_deflate_params(obj, v_level, v_strategy)
+ VALUE obj, v_level, v_strategy;
{
struct zstream *z = get_zstream(obj);
int level, strategy;
@@ -1311,7 +1397,8 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
* TODO: document better!
*/
static VALUE
-rb_deflate_set_dictionary(VALUE obj, VALUE dic)
+rb_deflate_set_dictionary(obj, dic)
+ VALUE obj, dic;
{
struct zstream *z = get_zstream(obj);
VALUE src = dic;
@@ -1320,7 +1407,7 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
OBJ_INFECT(obj, dic);
StringValue(src);
err = deflateSetDictionary(&z->stream,
- (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src));
+ RSTRING(src)->ptr, RSTRING(src)->len);
if (err != Z_OK) {
raise_zlib_error(err, z->stream.msg);
}
@@ -1342,7 +1429,8 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
static VALUE
-rb_inflate_s_allocate(VALUE klass)
+rb_inflate_s_allocate(klass)
+ VALUE klass;
{
return zstream_inflate_new(klass);
}
@@ -1356,7 +1444,10 @@ rb_inflate_s_allocate(VALUE klass)
* TODO: document better!
*/
static VALUE
-rb_inflate_initialize(int argc, VALUE *argv, VALUE obj)
+rb_inflate_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct zstream *z;
VALUE wbits;
@@ -1375,13 +1466,14 @@ rb_inflate_initialize(int argc, VALUE *argv, VALUE obj)
}
static VALUE
-inflate_run(VALUE args)
+inflate_run(args)
+ VALUE args;
{
- struct zstream *z = (struct zstream*)((VALUE*)args)[0];
- VALUE src = ((VALUE*)args)[1];
+ struct zstream *z = (struct zstream *)((VALUE *)args)[0];
+ VALUE src = ((VALUE *)args)[1];
- zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_SYNC_FLUSH);
- zstream_run(z, (Bytef*)"", 0, Z_FINISH); /* for checking errors */
+ zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
+ zstream_run(z, "", 0, Z_FINISH); /* for checking errors */
return zstream_detach_buffer(z);
}
@@ -1403,7 +1495,8 @@ inflate_run(VALUE args)
*
*/
static VALUE
-rb_inflate_s_inflate(VALUE obj, VALUE src)
+rb_inflate_s_inflate(obj, src)
+ VALUE obj, src;
{
struct zstream z;
VALUE dst, args[2];
@@ -1426,15 +1519,17 @@ rb_inflate_s_inflate(VALUE obj, VALUE src)
}
static void
-do_inflate(struct zstream *z, VALUE src)
+do_inflate(z, src)
+ struct zstream *z;
+ VALUE src;
{
if (NIL_P(src)) {
- zstream_run(z, (Bytef*)"", 0, Z_FINISH);
+ zstream_run(z, "", 0, Z_FINISH);
return;
}
StringValue(src);
- if (RSTRING_LEN(src) > 0) { /* prevent Z_BUF_ERROR */
- zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_SYNC_FLUSH);
+ if (RSTRING(src)->len > 0) { /* prevent Z_BUF_ERROR */
+ zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
}
}
@@ -1453,7 +1548,8 @@ do_inflate(struct zstream *z, VALUE src)
* TODO: document better!
*/
static VALUE
-rb_inflate_inflate(VALUE obj, VALUE src)
+rb_inflate_inflate(obj, src)
+ VALUE obj, src;
{
struct zstream *z = get_zstream(obj);
VALUE dst;
@@ -1490,7 +1586,8 @@ rb_inflate_inflate(VALUE obj, VALUE src)
* preserved in output buffer.
*/
static VALUE
-rb_inflate_addstr(VALUE obj, VALUE src)
+rb_inflate_addstr(obj, src)
+ VALUE obj, src;
{
struct zstream *z = get_zstream(obj);
@@ -1521,13 +1618,14 @@ rb_inflate_addstr(VALUE obj, VALUE src)
* following data of full flush point is preserved in the buffer.
*/
static VALUE
-rb_inflate_sync(VALUE obj, VALUE src)
+rb_inflate_sync(obj, src)
+ VALUE obj, src;
{
struct zstream *z = get_zstream(obj);
OBJ_INFECT(obj, src);
StringValue(src);
- return zstream_sync(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src));
+ return zstream_sync(z, RSTRING(src)->ptr, RSTRING(src)->len);
}
/*
@@ -1538,7 +1636,8 @@ rb_inflate_sync(VALUE obj, VALUE src)
* <tt>:)</tt>
*/
static VALUE
-rb_inflate_sync_point_p(VALUE obj)
+rb_inflate_sync_point_p(obj)
+ VALUE obj;
{
struct zstream *z = get_zstream(obj);
int err;
@@ -1560,7 +1659,8 @@ rb_inflate_sync_point_p(VALUE obj)
* TODO: document better!
*/
static VALUE
-rb_inflate_set_dictionary(VALUE obj, VALUE dic)
+rb_inflate_set_dictionary(obj, dic)
+ VALUE obj, dic;
{
struct zstream *z = get_zstream(obj);
VALUE src = dic;
@@ -1569,7 +1669,7 @@ rb_inflate_set_dictionary(VALUE obj, VALUE dic)
OBJ_INFECT(obj, dic);
StringValue(src);
err = inflateSetDictionary(&z->stream,
- (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src));
+ RSTRING(src)->ptr, RSTRING(src)->len);
if (err != Z_OK) {
raise_zlib_error(err, z->stream.msg);
}
@@ -1623,7 +1723,7 @@ rb_inflate_set_dictionary(VALUE obj, VALUE dic)
#define OS_CODE OS_UNIX
#endif
-static ID id_write, id_read, id_readpartial, id_flush, id_seek, id_close;
+static ID id_write, id_read, id_flush, id_seek, id_close;
static VALUE cGzError, cNoFooter, cCRCError, cLengthError;
@@ -1655,7 +1755,8 @@ struct gzfile {
static void
-gzfile_mark(struct gzfile *gz)
+gzfile_mark(gz)
+ struct gzfile *gz;
{
rb_gc_mark(gz->io);
rb_gc_mark(gz->orig_name);
@@ -1664,7 +1765,8 @@ gzfile_mark(struct gzfile *gz)
}
static void
-gzfile_free(struct gzfile *gz)
+gzfile_free(gz)
+ struct gzfile *gz;
{
struct zstream *z = &gz->z;
@@ -1706,7 +1808,8 @@ gzfile_new(klass, funcs, endfunc)
#define gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end)
static void
-gzfile_reset(struct gzfile *gz)
+gzfile_reset(gz)
+ struct gzfile *gz;
{
zstream_reset(&gz->z);
gz->crc = crc32(0, Z_NULL, 0);
@@ -1715,7 +1818,9 @@ gzfile_reset(struct gzfile *gz)
}
static void
-gzfile_close(struct gzfile *gz, int closeflag)
+gzfile_close(gz, closeflag)
+ struct gzfile *gz;
+ int closeflag;
{
VALUE io = gz->io;
@@ -1729,7 +1834,8 @@ gzfile_close(struct gzfile *gz, int closeflag)
}
static void
-gzfile_write_raw(struct gzfile *gz)
+gzfile_write_raw(gz)
+ struct gzfile *gz;
{
VALUE str;
@@ -1744,44 +1850,26 @@ gzfile_write_raw(struct gzfile *gz)
}
static VALUE
-gzfile_read_raw_partial(VALUE arg)
+gzfile_read_raw(gz)
+ struct gzfile *gz;
{
- struct gzfile *gz = (struct gzfile*)arg;
VALUE str;
- str = rb_funcall(gz->io, id_readpartial, 1, INT2FIX(GZFILE_READ_SIZE));
- Check_Type(str, T_STRING);
- return str;
-}
-
-static VALUE
-gzfile_read_raw_rescue(VALUE arg)
-{
- struct gzfile *gz = (struct gzfile*)arg;
- VALUE str = Qnil;
- if (rb_obj_is_kind_of(rb_errinfo(), rb_eNoMethodError)) {
- str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
- if (!NIL_P(str)) {
- Check_Type(str, T_STRING);
- }
+ str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
+ if (!NIL_P(str)) {
+ Check_Type(str, T_STRING);
}
- return str; /* return nil when EOFError */
-}
-
-static VALUE
-gzfile_read_raw(struct gzfile *gz)
-{
- return rb_rescue2(gzfile_read_raw_partial, (VALUE)gz,
- gzfile_read_raw_rescue, (VALUE)gz,
- rb_eEOFError, rb_eNoMethodError, (VALUE)0);
+ return str;
}
static int
-gzfile_read_raw_ensure(struct gzfile *gz, int size)
+gzfile_read_raw_ensure(gz, size)
+ struct gzfile *gz;
+ int size;
{
VALUE str;
- while (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size) {
+ while (NIL_P(gz->z.input) || RSTRING(gz->z.input)->len < size) {
str = gzfile_read_raw(gz);
if (NIL_P(str)) return Qfalse;
zstream_append_input2(&gz->z, str);
@@ -1790,27 +1878,30 @@ gzfile_read_raw_ensure(struct gzfile *gz, int size)
}
static char *
-gzfile_read_raw_until_zero(struct gzfile *gz, long offset)
+gzfile_read_raw_until_zero(gz, offset)
+ struct gzfile *gz;
+ long offset;
{
VALUE str;
char *p;
for (;;) {
- p = memchr(RSTRING_PTR(gz->z.input) + offset, '\0',
- RSTRING_LEN(gz->z.input) - offset);
+ p = memchr(RSTRING(gz->z.input)->ptr + offset, '\0',
+ RSTRING(gz->z.input)->len - offset);
if (p) break;
str = gzfile_read_raw(gz);
if (NIL_P(str)) {
rb_raise(cGzError, "unexpected end of file");
}
- offset = RSTRING_LEN(gz->z.input);
+ offset = RSTRING(gz->z.input)->len;
zstream_append_input2(&gz->z, str);
}
return p;
}
static unsigned int
-gzfile_get16(const unsigned char *src)
+gzfile_get16(src)
+ const unsigned char *src;
{
unsigned int n;
n = *(src++) & 0xff;
@@ -1819,7 +1910,8 @@ gzfile_get16(const unsigned char *src)
}
static unsigned long
-gzfile_get32(const unsigned char *src)
+gzfile_get32(src)
+ const unsigned char *src;
{
unsigned long n;
n = *(src++) & 0xff;
@@ -1830,7 +1922,9 @@ gzfile_get32(const unsigned char *src)
}
static void
-gzfile_set32(unsigned long n, unsigned char *dst)
+gzfile_set32(n, dst)
+ unsigned long n;
+ unsigned char *dst;
{
*(dst++) = n & 0xff;
*(dst++) = (n >> 8) & 0xff;
@@ -1839,9 +1933,10 @@ gzfile_set32(unsigned long n, unsigned char *dst)
}
static void
-gzfile_make_header(struct gzfile *gz)
+gzfile_make_header(gz)
+ struct gzfile *gz;
{
- Bytef buf[10]; /* the size of gzip header */
+ unsigned char buf[10]; /* the size of gzip header */
unsigned char flags = 0, extraflags = 0;
if (!NIL_P(gz->orig_name)) {
@@ -1872,20 +1967,21 @@ gzfile_make_header(struct gzfile *gz)
if (!NIL_P(gz->orig_name)) {
zstream_append_buffer2(&gz->z, gz->orig_name);
- zstream_append_buffer(&gz->z, (Bytef*)"\0", 1);
+ zstream_append_buffer(&gz->z, "\0", 1);
}
if (!NIL_P(gz->comment)) {
zstream_append_buffer2(&gz->z, gz->comment);
- zstream_append_buffer(&gz->z, (Bytef*)"\0", 1);
+ zstream_append_buffer(&gz->z, "\0", 1);
}
gz->z.flags |= GZFILE_FLAG_HEADER_FINISHED;
}
static void
-gzfile_make_footer(struct gzfile *gz)
+gzfile_make_footer(gz)
+ struct gzfile *gz;
{
- Bytef buf[8]; /* 8 is the size of gzip footer */
+ unsigned char buf[8]; /* 8 is the size of gzip footer */
gzfile_set32(gz->crc, buf);
gzfile_set32(gz->z.stream.total_in, &buf[4]);
@@ -1894,7 +1990,8 @@ gzfile_make_footer(struct gzfile *gz)
}
static void
-gzfile_read_header(struct gzfile *gz)
+gzfile_read_header(gz)
+ struct gzfile *gz;
{
const unsigned char *head;
long len;
@@ -1904,7 +2001,7 @@ gzfile_read_header(struct gzfile *gz)
rb_raise(cGzError, "not in gzip format");
}
- head = (unsigned char*)RSTRING_PTR(gz->z.input);
+ head = RSTRING(gz->z.input)->ptr;
if (head[0] != GZ_MAGIC1 || head[1] != GZ_MAGIC2) {
rb_raise(cGzError, "not in gzip format");
@@ -1942,7 +2039,7 @@ gzfile_read_header(struct gzfile *gz)
if (!gzfile_read_raw_ensure(gz, 2)) {
rb_raise(cGzError, "unexpected end of file");
}
- len = gzfile_get16((Bytef*)RSTRING_PTR(gz->z.input));
+ len = gzfile_get16(RSTRING(gz->z.input)->ptr);
if (!gzfile_read_raw_ensure(gz, 2 + len)) {
rb_raise(cGzError, "unexpected end of file");
}
@@ -1950,26 +2047,27 @@ gzfile_read_header(struct gzfile *gz)
}
if (flags & GZ_FLAG_ORIG_NAME) {
p = gzfile_read_raw_until_zero(gz, 0);
- len = p - RSTRING_PTR(gz->z.input);
- gz->orig_name = rb_str_new(RSTRING_PTR(gz->z.input), len);
+ len = p - RSTRING(gz->z.input)->ptr;
+ gz->orig_name = rb_str_new(RSTRING(gz->z.input)->ptr, len);
OBJ_TAINT(gz->orig_name); /* for safe */
zstream_discard_input(&gz->z, len + 1);
}
if (flags & GZ_FLAG_COMMENT) {
p = gzfile_read_raw_until_zero(gz, 0);
- len = p - RSTRING_PTR(gz->z.input);
- gz->comment = rb_str_new(RSTRING_PTR(gz->z.input), len);
+ len = p - RSTRING(gz->z.input)->ptr;
+ gz->comment = rb_str_new(RSTRING(gz->z.input)->ptr, len);
OBJ_TAINT(gz->comment); /* for safe */
zstream_discard_input(&gz->z, len + 1);
}
- if (gz->z.input != Qnil && RSTRING_LEN(gz->z.input) > 0) {
+ if (gz->z.input != Qnil && RSTRING(gz->z.input)->len > 0) {
zstream_run(&gz->z, 0, 0, Z_SYNC_FLUSH);
}
}
static void
-gzfile_check_footer(struct gzfile *gz)
+gzfile_check_footer(gz)
+ struct gzfile *gz;
{
unsigned long crc, length;
@@ -1979,8 +2077,8 @@ gzfile_check_footer(struct gzfile *gz)
rb_raise(cNoFooter, "footer is not found");
}
- crc = gzfile_get32((Bytef*)RSTRING_PTR(gz->z.input));
- length = gzfile_get32((Bytef*)RSTRING_PTR(gz->z.input) + 4);
+ crc = gzfile_get32(RSTRING(gz->z.input)->ptr);
+ length = gzfile_get32(RSTRING(gz->z.input)->ptr + 4);
gz->z.stream.total_in += 8; /* to rewind correctly */
zstream_discard_input(&gz->z, 8);
@@ -1994,7 +2092,10 @@ gzfile_check_footer(struct gzfile *gz)
}
static void
-gzfile_write(struct gzfile *gz, Bytef *str, uInt len)
+gzfile_write(gz, str, len)
+ struct gzfile *gz;
+ Bytef *str;
+ uInt len;
{
if (!(gz->z.flags & GZFILE_FLAG_HEADER_FINISHED)) {
gzfile_make_header(gz);
@@ -2009,7 +2110,8 @@ gzfile_write(struct gzfile *gz, Bytef *str, uInt len)
}
static long
-gzfile_read_more(struct gzfile *gz)
+gzfile_read_more(gz)
+ struct gzfile *gz;
{
volatile VALUE str;
@@ -2021,8 +2123,8 @@ gzfile_read_more(struct gzfile *gz)
}
break;
}
- if (RSTRING_LEN(str) > 0) { /* prevent Z_BUF_ERROR */
- zstream_run(&gz->z, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str),
+ if (RSTRING(str)->len > 0) { /* prevent Z_BUF_ERROR */
+ zstream_run(&gz->z, RSTRING(str)->ptr, RSTRING(str)->len,
Z_SYNC_FLUSH);
}
if (gz->z.buf_filled > 0) break;
@@ -2031,20 +2133,24 @@ gzfile_read_more(struct gzfile *gz)
}
static void
-gzfile_calc_crc(struct gzfile *gz, VALUE str)
+gzfile_calc_crc(gz, str)
+ struct gzfile *gz;
+ VALUE str;
{
- if (RSTRING_LEN(str) <= gz->ungetc) {
- gz->ungetc -= RSTRING_LEN(str);
+ if (RSTRING(str)->len <= gz->ungetc) {
+ gz->ungetc -= RSTRING(str)->len;
}
else {
- gz->crc = crc32(gz->crc, (Bytef*)RSTRING_PTR(str) + gz->ungetc,
- RSTRING_LEN(str) - gz->ungetc);
+ gz->crc = crc32(gz->crc, RSTRING(str)->ptr + gz->ungetc,
+ RSTRING(str)->len - gz->ungetc);
gz->ungetc = 0;
}
}
static VALUE
-gzfile_read(struct gzfile *gz, int len)
+gzfile_read(gz, len)
+ struct gzfile *gz;
+ int len;
{
VALUE dst;
@@ -2070,52 +2176,8 @@ gzfile_read(struct gzfile *gz, int len)
}
static VALUE
-gzfile_readpartial(struct gzfile *gz, int len, VALUE outbuf)
-{
- VALUE dst;
-
- if (len < 0)
- rb_raise(rb_eArgError, "negative length %d given", len);
-
- if (!NIL_P(outbuf))
- OBJ_TAINT(outbuf);
-
- if (len == 0) {
- if (NIL_P(outbuf))
- return rb_str_new(0, 0);
- else {
- rb_str_resize(outbuf, 0);
- return outbuf;
- }
- }
- while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled == 0) {
- gzfile_read_more(gz);
- }
- if (GZFILE_IS_FINISHED(gz)) {
- if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
- gzfile_check_footer(gz);
- }
- if (!NIL_P(outbuf))
- rb_str_resize(outbuf, 0);
- rb_raise(rb_eEOFError, "end of file reached");
- }
-
- dst = zstream_shift_buffer(&gz->z, len);
- gzfile_calc_crc(gz, dst);
-
- if (NIL_P(outbuf)) {
- OBJ_TAINT(dst); /* for safe */
- return dst;
- }
- else {
- rb_str_resize(outbuf, RSTRING_LEN(dst));
- memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
- return outbuf;
- }
-}
-
-static VALUE
-gzfile_read_all(struct gzfile *gz)
+gzfile_read_all(gz)
+ struct gzfile *gz;
{
VALUE dst;
@@ -2137,14 +2199,17 @@ gzfile_read_all(struct gzfile *gz)
}
static void
-gzfile_ungetc(struct gzfile *gz, int c)
+gzfile_ungetc(gz, c)
+ struct gzfile *gz;
+ int c;
{
zstream_buffer_ungetc(&gz->z, c);
gz->ungetc++;
}
static VALUE
-gzfile_writer_end_run(VALUE arg)
+gzfile_writer_end_run(arg)
+ VALUE arg;
{
struct gzfile *gz = (struct gzfile *)arg;
@@ -2152,7 +2217,7 @@ gzfile_writer_end_run(VALUE arg)
gzfile_make_header(gz);
}
- zstream_run(&gz->z, (Bytef*)"", 0, Z_FINISH);
+ zstream_run(&gz->z, "", 0, Z_FINISH);
gzfile_make_footer(gz);
gzfile_write_raw(gz);
@@ -2160,7 +2225,8 @@ gzfile_writer_end_run(VALUE arg)
}
static void
-gzfile_writer_end(struct gzfile *gz)
+gzfile_writer_end(gz)
+ struct gzfile *gz;
{
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
@@ -2169,7 +2235,8 @@ gzfile_writer_end(struct gzfile *gz)
}
static VALUE
-gzfile_reader_end_run(VALUE arg)
+gzfile_reader_end_run(arg)
+ VALUE arg;
{
struct gzfile *gz = (struct gzfile *)arg;
@@ -2182,7 +2249,8 @@ gzfile_reader_end_run(VALUE arg)
}
static void
-gzfile_reader_end(struct gzfile *gz)
+gzfile_reader_end(gz)
+ struct gzfile *gz;
{
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
@@ -2191,13 +2259,14 @@ gzfile_reader_end(struct gzfile *gz)
}
static void
-gzfile_reader_rewind(struct gzfile *gz)
+gzfile_reader_rewind(gz)
+ struct gzfile *gz;
{
long n;
n = gz->z.stream.total_in;
if (!NIL_P(gz->z.input)) {
- n += RSTRING_LEN(gz->z.input);
+ n += RSTRING(gz->z.input)->len;
}
rb_funcall(gz->io, id_seek, 2, rb_int2inum(-n), INT2FIX(1));
@@ -2205,7 +2274,8 @@ gzfile_reader_rewind(struct gzfile *gz)
}
static VALUE
-gzfile_reader_get_unused(struct gzfile *gz)
+gzfile_reader_get_unused(gz)
+ struct gzfile *gz;
{
VALUE str;
@@ -2222,7 +2292,8 @@ gzfile_reader_get_unused(struct gzfile *gz)
}
static struct gzfile *
-get_gzfile(VALUE obj)
+get_gzfile(obj)
+ VALUE obj;
{
struct gzfile *gz;
@@ -2248,7 +2319,8 @@ get_gzfile(VALUE obj)
static VALUE
-gzfile_ensure_close(VALUE obj)
+gzfile_ensure_close(obj)
+ VALUE obj;
{
struct gzfile *gz;
@@ -2263,7 +2335,10 @@ gzfile_ensure_close(VALUE obj)
* See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
*/
static VALUE
-rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
+rb_gzfile_s_wrap(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE obj = rb_class_new_instance(argc, argv, klass);
@@ -2279,7 +2354,11 @@ rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
* See Zlib::GzipReader#open and Zlib::GzipWriter#open.
*/
static VALUE
-gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
+gzfile_s_open(argc, argv, klass, mode)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+ const char *mode;
{
VALUE io, filename;
@@ -2287,8 +2366,8 @@ gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
}
filename = argv[0];
- FilePathValue(filename);
- io = rb_file_open(RSTRING_PTR(filename), mode);
+ SafeStringValue(filename);
+ io = rb_file_open(RSTRING(filename)->ptr, mode);
argv[0] = io;
return rb_gzfile_s_wrap(argc, argv, klass);
@@ -2298,7 +2377,8 @@ gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
* Same as IO.
*/
static VALUE
-rb_gzfile_to_io(VALUE obj)
+rb_gzfile_to_io(obj)
+ VALUE obj;
{
return get_gzfile(obj)->io;
}
@@ -2307,7 +2387,8 @@ rb_gzfile_to_io(VALUE obj)
* Returns CRC value of the uncompressed data.
*/
static VALUE
-rb_gzfile_crc(VALUE obj)
+rb_gzfile_crc(obj)
+ VALUE obj;
{
return rb_uint2inum(get_gzfile(obj)->crc);
}
@@ -2316,7 +2397,8 @@ rb_gzfile_crc(VALUE obj)
* Returns last modification time recorded in the gzip file header.
*/
static VALUE
-rb_gzfile_mtime(VALUE obj)
+rb_gzfile_mtime(obj)
+ VALUE obj;
{
return rb_time_new(get_gzfile(obj)->mtime, (time_t)0);
}
@@ -2325,7 +2407,8 @@ rb_gzfile_mtime(VALUE obj)
* Returns compression level.
*/
static VALUE
-rb_gzfile_level(VALUE obj)
+rb_gzfile_level(obj)
+ VALUE obj;
{
return INT2FIX(get_gzfile(obj)->level);
}
@@ -2334,7 +2417,8 @@ rb_gzfile_level(VALUE obj)
* Returns OS code number recorded in the gzip file header.
*/
static VALUE
-rb_gzfile_os_code(VALUE obj)
+rb_gzfile_os_code(obj)
+ VALUE obj;
{
return INT2FIX(get_gzfile(obj)->os_code);
}
@@ -2344,7 +2428,8 @@ rb_gzfile_os_code(VALUE obj)
* original filename is not present.
*/
static VALUE
-rb_gzfile_orig_name(VALUE obj)
+rb_gzfile_orig_name(obj)
+ VALUE obj;
{
VALUE str = get_gzfile(obj)->orig_name;
if (!NIL_P(str)) {
@@ -2359,7 +2444,8 @@ rb_gzfile_orig_name(VALUE obj)
* is not present.
*/
static VALUE
-rb_gzfile_comment(VALUE obj)
+rb_gzfile_comment(obj)
+ VALUE obj;
{
VALUE str = get_gzfile(obj)->comment;
if (!NIL_P(str)) {
@@ -2373,7 +2459,8 @@ rb_gzfile_comment(VALUE obj)
* ???
*/
static VALUE
-rb_gzfile_lineno(VALUE obj)
+rb_gzfile_lineno(obj)
+ VALUE obj;
{
return INT2NUM(get_gzfile(obj)->lineno);
}
@@ -2382,7 +2469,8 @@ rb_gzfile_lineno(VALUE obj)
* ???
*/
static VALUE
-rb_gzfile_set_lineno(VALUE obj, VALUE lineno)
+rb_gzfile_set_lineno(obj, lineno)
+ VALUE obj, lineno;
{
struct gzfile *gz = get_gzfile(obj);
gz->lineno = NUM2INT(lineno);
@@ -2393,7 +2481,8 @@ rb_gzfile_set_lineno(VALUE obj, VALUE lineno)
* ???
*/
static VALUE
-rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
+rb_gzfile_set_mtime(obj, mtime)
+ VALUE obj, mtime;
{
struct gzfile *gz = get_gzfile(obj);
VALUE val;
@@ -2402,7 +2491,7 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
rb_raise(cGzError, "header is already written");
}
- if (FIXNUM_P(time)) {
+ if (FIXNUM_P(mtime)) {
gz->mtime = FIX2INT(mtime);
}
else {
@@ -2416,7 +2505,8 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
* ???
*/
static VALUE
-rb_gzfile_set_orig_name(VALUE obj, VALUE str)
+rb_gzfile_set_orig_name(obj, str)
+ VALUE obj, str;
{
struct gzfile *gz = get_gzfile(obj);
VALUE s;
@@ -2426,9 +2516,9 @@ rb_gzfile_set_orig_name(VALUE obj, VALUE str)
rb_raise(cGzError, "header is already written");
}
s = rb_str_dup(rb_str_to_str(str));
- p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s));
+ p = memchr(RSTRING(s)->ptr, '\0', RSTRING(s)->len);
if (p) {
- rb_str_resize(s, p - RSTRING_PTR(s));
+ rb_str_resize(s, p - RSTRING(s)->ptr);
}
gz->orig_name = s;
return str;
@@ -2438,7 +2528,8 @@ rb_gzfile_set_orig_name(VALUE obj, VALUE str)
* ???
*/
static VALUE
-rb_gzfile_set_comment(VALUE obj, VALUE str)
+rb_gzfile_set_comment(obj, str)
+ VALUE obj, str;
{
struct gzfile *gz = get_gzfile(obj);
VALUE s;
@@ -2448,9 +2539,9 @@ rb_gzfile_set_comment(VALUE obj, VALUE str)
rb_raise(cGzError, "header is already written");
}
s = rb_str_dup(rb_str_to_str(str));
- p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s));
+ p = memchr(RSTRING(s)->ptr, '\0', RSTRING(s)->len);
if (p) {
- rb_str_resize(s, p - RSTRING_PTR(s));
+ rb_str_resize(s, p - RSTRING(s)->ptr);
}
gz->comment = s;
return str;
@@ -2461,7 +2552,8 @@ rb_gzfile_set_comment(VALUE obj, VALUE str)
* associated IO object. Returns the associated IO object.
*/
static VALUE
-rb_gzfile_close(VALUE obj)
+rb_gzfile_close(obj)
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
VALUE io;
@@ -2477,7 +2569,8 @@ rb_gzfile_close(VALUE obj)
* object.
*/
static VALUE
-rb_gzfile_finish(VALUE obj)
+rb_gzfile_finish(obj)
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
VALUE io;
@@ -2491,7 +2584,8 @@ rb_gzfile_finish(VALUE obj)
* Same as IO.
*/
static VALUE
-rb_gzfile_closed_p(VALUE obj)
+rb_gzfile_closed_p(obj)
+ VALUE obj;
{
struct gzfile *gz;
Data_Get_Struct(obj, struct gzfile, gz);
@@ -2502,7 +2596,8 @@ rb_gzfile_closed_p(VALUE obj)
* ???
*/
static VALUE
-rb_gzfile_eof_p(VALUE obj)
+rb_gzfile_eof_p(obj)
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
return GZFILE_IS_FINISHED(gz) ? Qtrue : Qfalse;
@@ -2512,7 +2607,8 @@ rb_gzfile_eof_p(VALUE obj)
* Same as IO.
*/
static VALUE
-rb_gzfile_sync(VALUE obj)
+rb_gzfile_sync(obj)
+ VALUE obj;
{
return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse;
}
@@ -2525,7 +2621,8 @@ rb_gzfile_sync(VALUE obj)
* decreases sharply.
*/
static VALUE
-rb_gzfile_set_sync(VALUE obj, VALUE mode)
+rb_gzfile_set_sync(obj, mode)
+ VALUE obj, mode;
{
struct gzfile *gz = get_gzfile(obj);
@@ -2542,7 +2639,8 @@ rb_gzfile_set_sync(VALUE obj, VALUE mode)
* ???
*/
static VALUE
-rb_gzfile_total_in(VALUE obj)
+rb_gzfile_total_in(obj)
+ VALUE obj;
{
return rb_uint2inum(get_gzfile(obj)->z.stream.total_in);
}
@@ -2551,7 +2649,8 @@ rb_gzfile_total_in(VALUE obj)
* ???
*/
static VALUE
-rb_gzfile_total_out(VALUE obj)
+rb_gzfile_total_out(obj)
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
return rb_uint2inum(gz->z.stream.total_out - gz->z.buf_filled);
@@ -2588,7 +2687,8 @@ rb_gzfile_total_out(VALUE obj)
*/
static VALUE
-rb_gzwriter_s_allocate(VALUE klass)
+rb_gzwriter_s_allocate(klass)
+ VALUE klass;
{
return gzfile_writer_new(klass);
}
@@ -2601,7 +2701,10 @@ rb_gzwriter_s_allocate(VALUE klass)
* this method are found in Zlib::GzipWriter.new and Zlib::GzipWriter#wrap.
*/
static VALUE
-rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
+rb_gzwriter_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
return gzfile_s_open(argc, argv, klass, "wb");
}
@@ -2615,7 +2718,10 @@ rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
* +write+ method that behaves same as write method in IO class.
*/
static VALUE
-rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
+rb_gzwriter_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct gzfile *gz;
VALUE io, level, strategy;
@@ -2645,7 +2751,10 @@ rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
* +flush+ is omitted. It is no use giving flush <tt>Zlib::NO_FLUSH</tt>.
*/
static VALUE
-rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
+rb_gzwriter_flush(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
VALUE v_flush;
@@ -2655,7 +2764,7 @@ rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
- zstream_run(&gz->z, (Bytef*)"", 0, flush);
+ zstream_run(&gz->z, "", 0, flush);
}
gzfile_write_raw(gz);
@@ -2669,27 +2778,29 @@ rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
* Same as IO.
*/
static VALUE
-rb_gzwriter_write(VALUE obj, VALUE str)
+rb_gzwriter_write(obj, str)
+ VALUE obj, str;
{
struct gzfile *gz = get_gzfile(obj);
if (TYPE(str) != T_STRING) {
str = rb_obj_as_string(str);
}
- gzfile_write(gz, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str));
- return INT2FIX(RSTRING_LEN(str));
+ gzfile_write(gz, RSTRING(str)->ptr, RSTRING(str)->len);
+ return INT2FIX(RSTRING(str)->len);
}
/*
* Same as IO.
*/
static VALUE
-rb_gzwriter_putc(VALUE obj, VALUE ch)
+rb_gzwriter_putc(obj, ch)
+ VALUE obj, ch;
{
struct gzfile *gz = get_gzfile(obj);
char c = NUM2CHR(ch);
- gzfile_write(gz, (Bytef*)&c, 1);
+ gzfile_write(gz, &c, 1);
return ch;
}
@@ -2775,7 +2886,8 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
*/
static VALUE
-rb_gzreader_s_allocate(VALUE klass)
+rb_gzreader_s_allocate(klass)
+ VALUE klass;
{
return gzfile_reader_new(klass);
}
@@ -2788,7 +2900,10 @@ rb_gzreader_s_allocate(VALUE klass)
* are in Zlib::GzipReader.new and ZLib::GzipReader.wrap.
*/
static VALUE
-rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
+rb_gzreader_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
return gzfile_s_open(argc, argv, klass, "rb");
}
@@ -2804,7 +2919,8 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
* exception.
*/
static VALUE
-rb_gzreader_initialize(VALUE obj, VALUE io)
+rb_gzreader_initialize(obj, io)
+ VALUE obj, io;
{
struct gzfile *gz;
int err;
@@ -2828,7 +2944,8 @@ rb_gzreader_initialize(VALUE obj, VALUE io)
* object. The associated IO object needs to respond to the +seek+ method.
*/
static VALUE
-rb_gzreader_rewind(VALUE obj)
+rb_gzreader_rewind(obj)
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
gzfile_reader_rewind(gz);
@@ -2840,7 +2957,8 @@ rb_gzreader_rewind(VALUE obj)
* +nil+ if the whole gzip file is not parsed yet.
*/
static VALUE
-rb_gzreader_unused(VALUE obj)
+rb_gzreader_unused(obj)
+ VALUE obj;
{
struct gzfile *gz;
Data_Get_Struct(obj, struct gzfile, gz);
@@ -2851,7 +2969,10 @@ rb_gzreader_unused(VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
+rb_gzreader_read(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
VALUE vlen;
@@ -2870,45 +2991,18 @@ rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
}
/*
- * call-seq:
- * gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
- *
- * Reads at most <i>maxlen</i> bytes from the gziped stream but
- * it blocks only if <em>gzipreader</em> has no data immediately available.
- * If the optional <i>outbuf</i> argument is present,
- * it must reference a String, which will receive the data.
- * It raises <code>EOFError</code> on end of file.
- */
-static VALUE
-rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj)
-{
- struct gzfile *gz = get_gzfile(obj);
- VALUE vlen, outbuf;
- int len;
-
- rb_scan_args(argc, argv, "11", &vlen, &outbuf);
-
- len = NUM2INT(vlen);
- if (len < 0) {
- rb_raise(rb_eArgError, "negative length %d given", len);
- }
- if (!NIL_P(outbuf))
- Check_Type(outbuf, T_STRING);
- return gzfile_readpartial(gz, len, outbuf);
-}
-
-/*
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_getc(VALUE obj)
+rb_gzreader_getc(obj)
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
VALUE dst;
dst = gzfile_read(gz, 1);
if (!NIL_P(dst)) {
- dst = INT2FIX((unsigned int)(RSTRING_PTR(dst)[0]) & 0xff);
+ dst = INT2FIX((unsigned int)(RSTRING(dst)->ptr[0]) & 0xff);
}
return dst;
}
@@ -2917,7 +3011,8 @@ rb_gzreader_getc(VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_readchar(VALUE obj)
+rb_gzreader_readchar(obj)
+ VALUE obj;
{
VALUE dst;
dst = rb_gzreader_getc(obj);
@@ -2931,7 +3026,8 @@ rb_gzreader_readchar(VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_each_byte(VALUE obj)
+rb_gzreader_each_byte(obj)
+ VALUE obj;
{
VALUE c;
while (!NIL_P(c = rb_gzreader_getc(obj))) {
@@ -2944,7 +3040,8 @@ rb_gzreader_each_byte(VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_ungetc(VALUE obj, VALUE ch)
+rb_gzreader_ungetc(obj, ch)
+ VALUE obj, ch;
{
struct gzfile *gz = get_gzfile(obj);
gzfile_ungetc(gz, NUM2CHR(ch));
@@ -2952,7 +3049,8 @@ rb_gzreader_ungetc(VALUE obj, VALUE ch)
}
static void
-gzreader_skip_linebreaks(struct gzfile *gz)
+gzreader_skip_linebreaks(gz)
+ struct gzfile *gz;
{
VALUE str;
char *p;
@@ -2963,7 +3061,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
gzfile_read_more(gz);
}
n = 0;
- p = RSTRING_PTR(gz->z.buf);
+ p = RSTRING(gz->z.buf)->ptr;
while (n++, *(p++) == '\n') {
if (n >= gz->z.buf_filled) {
@@ -2974,7 +3072,7 @@ gzreader_skip_linebreaks(struct gzfile *gz)
gzfile_read_more(gz);
}
n = 0;
- p = RSTRING_PTR(gz->z.buf);
+ p = RSTRING(gz->z.buf)->ptr;
}
}
@@ -2983,20 +3081,25 @@ gzreader_skip_linebreaks(struct gzfile *gz)
}
static void
-rscheck(const char *rsptr, long rslen, VALUE rs)
+rscheck(rsptr, rslen, rs)
+ char *rsptr;
+ long rslen;
+ VALUE rs;
{
- if (RSTRING_PTR(rs) != rsptr && RSTRING_LEN(rs) != rslen)
+ if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
rb_raise(rb_eRuntimeError, "rs modified");
}
static VALUE
-gzreader_gets(int argc, VALUE *argv, VALUE obj)
+gzreader_gets(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct gzfile *gz = get_gzfile(obj);
volatile VALUE rs;
VALUE dst;
- const char *rsptr;
- char *p, *res;
+ char *rsptr, *p, *res;
long rslen, n;
int rspara;
@@ -3012,17 +3115,19 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
if (NIL_P(rs)) {
dst = gzfile_read_all(gz);
- if (RSTRING_LEN(dst) != 0) gz->lineno++;
+ if (RSTRING(dst)->len != 0) gz->lineno++;
+ else
+ return Qnil;
return dst;
}
- if (RSTRING_LEN(rs) == 0) {
+ if (RSTRING(rs)->len == 0) {
rsptr = "\n\n";
rslen = 2;
rspara = 1;
} else {
- rsptr = RSTRING_PTR(rs);
- rslen = RSTRING_LEN(rs);
+ rsptr = RSTRING(rs)->ptr;
+ rslen = RSTRING(rs)->len;
rspara = 0;
}
@@ -3038,13 +3143,13 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
gzfile_read_more(gz);
}
- p = RSTRING_PTR(gz->z.buf);
+ p = RSTRING(gz->z.buf)->ptr;
n = rslen;
for (;;) {
if (n > gz->z.buf_filled) {
if (ZSTREAM_IS_FINISHED(&gz->z)) break;
gzfile_read_more(gz);
- p = RSTRING_PTR(gz->z.buf) + n - rslen;
+ p = RSTRING(gz->z.buf)->ptr + n - rslen;
}
if (!rspara) rscheck(rsptr, rslen, rs);
res = memchr(p, rsptr[0], (gz->z.buf_filled - n + 1));
@@ -3071,7 +3176,10 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
+rb_gzreader_gets(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE dst;
dst = gzreader_gets(argc, argv, obj);
@@ -3085,7 +3193,10 @@ rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
+rb_gzreader_readline(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE dst;
dst = rb_gzreader_gets(argc, argv, obj);
@@ -3099,7 +3210,10 @@ rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
+rb_gzreader_each(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE str;
while (!NIL_P(str = gzreader_gets(argc, argv, obj))) {
@@ -3112,7 +3226,10 @@ rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
* See Zlib::GzipReader documentation for a description.
*/
static VALUE
-rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
+rb_gzreader_readlines(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE str, dst;
dst = rb_ary_new();
@@ -3259,7 +3376,7 @@ void Init_zlib()
rb_define_singleton_method(cDeflate, "deflate", rb_deflate_s_deflate, -1);
rb_define_alloc_func(cDeflate, rb_deflate_s_allocate);
rb_define_method(cDeflate, "initialize", rb_deflate_initialize, -1);
- rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 0);
+ rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 1);
rb_define_method(cDeflate, "deflate", rb_deflate_deflate, -1);
rb_define_method(cDeflate, "<<", rb_deflate_addstr, 1);
rb_define_method(cDeflate, "flush", rb_deflate_flush, -1);
@@ -3298,7 +3415,6 @@ void Init_zlib()
#if GZIP_SUPPORT
id_write = rb_intern("write");
id_read = rb_intern("read");
- id_readpartial = rb_intern("readpartial");
id_flush = rb_intern("flush");
id_seek = rb_intern("seek");
id_close = rb_intern("close");
@@ -3357,7 +3473,6 @@ void Init_zlib()
rb_define_method(cGzipReader, "rewind", rb_gzreader_rewind, 0);
rb_define_method(cGzipReader, "unused", rb_gzreader_unused, 0);
rb_define_method(cGzipReader, "read", rb_gzreader_read, -1);
- rb_define_method(cGzipReader, "readpartial", rb_gzreader_readpartial, -1);
rb_define_method(cGzipReader, "getc", rb_gzreader_getc, 0);
rb_define_method(cGzipReader, "readchar", rb_gzreader_readchar, 0);
rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
diff --git a/file.c b/file.c
index c9cf386c0d..ca80795817 100644
--- a/file.c
+++ b/file.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 15 12:24:34 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -15,11 +15,15 @@
#ifdef _WIN32
#include "missing/file.h"
#endif
+#ifdef __CYGWIN__
+#include <windows.h>
+#include <sys/cygwin.h>
+#endif
-#include "ruby/ruby.h"
-#include "ruby/io.h"
-#include "ruby/signal.h"
-#include "ruby/util.h"
+#include "ruby.h"
+#include "rubyio.h"
+#include "rubysig.h"
+#include "util.h"
#include "dln.h"
#ifdef HAVE_UNISTD_H
@@ -29,7 +33,7 @@
#ifdef HAVE_SYS_FILE_H
# include <sys/file.h>
#else
-int flock(int, int);
+int flock _((int, int));
#endif
#ifdef HAVE_SYS_PARAM_H
@@ -39,10 +43,10 @@ int flock(int, int);
# define MAXPATHLEN 1024
#endif
-#include <ctype.h>
-
#include <time.h>
+VALUE rb_time_new _((time_t, time_t));
+
#ifdef HAVE_UTIME_H
#include <utime.h>
#elif defined HAVE_SYS_UTIME_H
@@ -53,6 +57,10 @@ int flock(int, int);
#include <pwd.h>
#endif
+#ifndef HAVE_STRING_H
+char *strrchr _((const char*,const char));
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
@@ -63,6 +71,9 @@ int flock(int, int);
#if !defined HAVE_LSTAT && !defined lstat
#define lstat stat
#endif
+#if !HAVE_FSEEKO && !defined(fseeko)
+# define fseeko fseek
+#endif
#ifdef __BEOS__ /* should not change ID if -1 */
static int
@@ -95,58 +106,24 @@ VALUE rb_cFile;
VALUE rb_mFileTest;
VALUE rb_cStat;
-static VALUE
-rb_get_path_check(VALUE obj, int check)
-{
- VALUE tmp;
- static ID to_path;
-
- if (check) rb_check_safe_obj(obj);
- tmp = rb_check_string_type(obj);
- if (!NIL_P(tmp)) goto exit;
-
- if (!to_path) {
- to_path = rb_intern("to_path");
- }
- if (rb_respond_to(obj, to_path)) {
- tmp = rb_funcall(obj, to_path, 0, 0);
- }
- else {
- tmp = obj;
- }
- exit:
- StringValueCStr(tmp);
- if (check && obj != tmp) {
- rb_check_safe_obj(tmp);
- }
- return rb_str_new4(tmp);
-}
-
-VALUE
-rb_get_path_no_checksafe(VALUE obj)
-{
- return rb_get_path_check(obj, 0);
-}
-
-VALUE
-rb_get_path(VALUE obj)
-{
- return rb_get_path_check(obj, 1);
-}
-
+static long apply2files _((void (*)(const char *, void *), VALUE, void *));
static long
-apply2files(void (*func)(const char *, void *), VALUE vargs, void *arg)
+apply2files(func, vargs, arg)
+ void (*func)_((const char *, void *));
+ VALUE vargs;
+ void *arg;
{
long i;
- volatile VALUE path;
+ VALUE path;
+ struct RArray *args = RARRAY(vargs);
- rb_secure(4);
- for (i=0; i<RARRAY_LEN(vargs); i++) {
- path = rb_get_path(RARRAY_PTR(vargs)[i]);
+ for (i=0; i<args->len; i++) {
+ path = args->ptr[i];
+ SafeStringValue(path);
(*func)(StringValueCStr(path), arg);
}
- return RARRAY_LEN(vargs);
+ return args->len;
}
/*
@@ -162,7 +139,8 @@ apply2files(void (*func)(const char *, void *), VALUE vargs, void *arg)
*/
static VALUE
-rb_file_path(VALUE obj)
+rb_file_path(obj)
+ VALUE obj;
{
rb_io_t *fptr;
@@ -173,7 +151,9 @@ rb_file_path(VALUE obj)
}
static VALUE
-stat_new_0(VALUE klass, struct stat *st)
+stat_new_0(klass, st)
+ VALUE klass;
+ struct stat *st;
{
struct stat *nst = 0;
@@ -185,13 +165,15 @@ stat_new_0(VALUE klass, struct stat *st)
}
static VALUE
-stat_new(struct stat *st)
+stat_new(st)
+ struct stat *st;
{
return stat_new_0(rb_cStat, st);
}
static struct stat*
-get_stat(VALUE self)
+get_stat(self)
+ VALUE self;
{
struct stat* st;
Data_Get_Struct(self, struct stat, st);
@@ -199,8 +181,6 @@ get_stat(VALUE self)
return st;
}
-static struct timespec stat_mtimespec(struct stat *st);
-
/*
* call-seq:
* stat <=> other_stat => -1, 0, 1
@@ -215,22 +195,36 @@ static struct timespec stat_mtimespec(struct stat *st);
*/
static VALUE
-rb_stat_cmp(VALUE self, VALUE other)
+rb_stat_cmp(self, other)
+ VALUE self, other;
{
if (rb_obj_is_kind_of(other, rb_obj_class(self))) {
- struct timespec ts1 = stat_mtimespec(get_stat(self));
- struct timespec ts2 = stat_mtimespec(get_stat(other));
- if (ts1.tv_sec == ts2.tv_sec) {
- if (ts1.tv_nsec == ts2.tv_nsec) return INT2FIX(0);
- if (ts1.tv_nsec < ts2.tv_nsec) return INT2FIX(-1);
- return INT2FIX(1);
- }
- if (ts1.tv_sec < ts2.tv_sec) return INT2FIX(-1);
- return INT2FIX(1);
+ time_t t1 = get_stat(self)->st_mtime;
+ time_t t2 = get_stat(other)->st_mtime;
+ if (t1 == t2)
+ return INT2FIX(0);
+ else if (t1 < t2)
+ return INT2FIX(-1);
+ else
+ return INT2FIX(1);
}
return Qnil;
}
+static VALUE rb_stat_dev _((VALUE));
+static VALUE rb_stat_ino _((VALUE));
+static VALUE rb_stat_mode _((VALUE));
+static VALUE rb_stat_nlink _((VALUE));
+static VALUE rb_stat_uid _((VALUE));
+static VALUE rb_stat_gid _((VALUE));
+static VALUE rb_stat_rdev _((VALUE));
+static VALUE rb_stat_size _((VALUE));
+static VALUE rb_stat_blksize _((VALUE));
+static VALUE rb_stat_blocks _((VALUE));
+static VALUE rb_stat_atime _((VALUE));
+static VALUE rb_stat_mtime _((VALUE));
+static VALUE rb_stat_ctime _((VALUE));
+
/*
* call-seq:
* stat.dev => fixnum
@@ -242,7 +236,8 @@ rb_stat_cmp(VALUE self, VALUE other)
*/
static VALUE
-rb_stat_dev(VALUE self)
+rb_stat_dev(self)
+ VALUE self;
{
return INT2NUM(get_stat(self)->st_dev);
}
@@ -259,7 +254,8 @@ rb_stat_dev(VALUE self)
*/
static VALUE
-rb_stat_dev_major(VALUE self)
+rb_stat_dev_major(self)
+ VALUE self;
{
#if defined(major)
long dev = get_stat(self)->st_dev;
@@ -281,7 +277,8 @@ rb_stat_dev_major(VALUE self)
*/
static VALUE
-rb_stat_dev_minor(VALUE self)
+rb_stat_dev_minor(self)
+ VALUE self;
{
#if defined(minor)
long dev = get_stat(self)->st_dev;
@@ -303,7 +300,8 @@ rb_stat_dev_minor(VALUE self)
*/
static VALUE
-rb_stat_ino(VALUE self)
+rb_stat_ino(self)
+ VALUE self;
{
#ifdef HUGE_ST_INO
return ULL2NUM(get_stat(self)->st_ino);
@@ -326,7 +324,8 @@ rb_stat_ino(VALUE self)
*/
static VALUE
-rb_stat_mode(VALUE self)
+rb_stat_mode(self)
+ VALUE self;
{
#ifdef __BORLANDC__
return UINT2NUM((unsigned short)(get_stat(self)->st_mode));
@@ -348,7 +347,8 @@ rb_stat_mode(VALUE self)
*/
static VALUE
-rb_stat_nlink(VALUE self)
+rb_stat_nlink(self)
+ VALUE self;
{
return UINT2NUM(get_stat(self)->st_nlink);
}
@@ -365,9 +365,10 @@ rb_stat_nlink(VALUE self)
*/
static VALUE
-rb_stat_uid(VALUE self)
+rb_stat_uid(self)
+ VALUE self;
{
- return UIDT2NUM(get_stat(self)->st_uid);
+ return UINT2NUM(get_stat(self)->st_uid);
}
/*
@@ -381,9 +382,10 @@ rb_stat_uid(VALUE self)
*/
static VALUE
-rb_stat_gid(VALUE self)
+rb_stat_gid(self)
+ VALUE self;
{
- return GIDT2NUM(get_stat(self)->st_gid);
+ return UINT2NUM(get_stat(self)->st_gid);
}
@@ -400,7 +402,8 @@ rb_stat_gid(VALUE self)
*/
static VALUE
-rb_stat_rdev(VALUE self)
+rb_stat_rdev(self)
+ VALUE self;
{
#ifdef HAVE_ST_RDEV
return ULONG2NUM(get_stat(self)->st_rdev);
@@ -421,7 +424,8 @@ rb_stat_rdev(VALUE self)
*/
static VALUE
-rb_stat_rdev_major(VALUE self)
+rb_stat_rdev_major(self)
+ VALUE self;
{
#if defined(HAVE_ST_RDEV) && defined(major)
long rdev = get_stat(self)->st_rdev;
@@ -443,7 +447,8 @@ rb_stat_rdev_major(VALUE self)
*/
static VALUE
-rb_stat_rdev_minor(VALUE self)
+rb_stat_rdev_minor(self)
+ VALUE self;
{
#if defined(HAVE_ST_RDEV) && defined(minor)
long rdev = get_stat(self)->st_rdev;
@@ -463,7 +468,8 @@ rb_stat_rdev_minor(VALUE self)
*/
static VALUE
-rb_stat_size(VALUE self)
+rb_stat_size(self)
+ VALUE self;
{
return OFFT2NUM(get_stat(self)->st_size);
}
@@ -480,7 +486,8 @@ rb_stat_size(VALUE self)
*/
static VALUE
-rb_stat_blksize(VALUE self)
+rb_stat_blksize(self)
+ VALUE self;
{
#ifdef HAVE_ST_BLKSIZE
return ULONG2NUM(get_stat(self)->st_blksize);
@@ -501,7 +508,8 @@ rb_stat_blksize(VALUE self)
*/
static VALUE
-rb_stat_blocks(VALUE self)
+rb_stat_blocks(self)
+ VALUE self;
{
#ifdef HAVE_ST_BLOCKS
return ULONG2NUM(get_stat(self)->st_blocks);
@@ -510,77 +518,6 @@ rb_stat_blocks(VALUE self)
#endif
}
-static struct timespec
-stat_atimespec(struct stat *st)
-{
- struct timespec ts;
- ts.tv_sec = st->st_atime;
-#if defined(HAVE_STRUCT_STAT_ST_ATIM)
- ts.tv_nsec = st->st_atim.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
- ts.tv_nsec = st->st_atimespec.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC)
- ts.tv_nsec = st->st_atimensec;
-#else
- ts.tv_nsec = 0;
-#endif
- return ts;
-}
-
-static VALUE
-stat_atime(struct stat *st)
-{
- struct timespec ts = stat_atimespec(st);
- return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
-}
-
-static struct timespec
-stat_mtimespec(struct stat *st)
-{
- struct timespec ts;
- ts.tv_sec = st->st_mtime;
-#if defined(HAVE_STRUCT_STAT_ST_MTIM)
- ts.tv_nsec = st->st_mtim.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
- ts.tv_nsec = st->st_mtimespec.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
- ts.tv_nsec = st->st_mtimensec;
-#else
- ts.tv_nsec = 0;
-#endif
- return ts;
-}
-
-static VALUE
-stat_mtime(struct stat *st)
-{
- struct timespec ts = stat_mtimespec(st);
- return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
-}
-
-static struct timespec
-stat_ctimespec(struct stat *st)
-{
- struct timespec ts;
- ts.tv_sec = st->st_ctime;
-#if defined(HAVE_STRUCT_STAT_ST_CTIM)
- ts.tv_nsec = st->st_ctim.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_CTIMESPEC)
- ts.tv_nsec = st->st_ctimespec.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_CTIMENSEC)
- ts.tv_nsec = st->st_ctimensec;
-#else
- ts.tv_nsec = 0;
-#endif
- return ts;
-}
-
-static VALUE
-stat_ctime(struct stat *st)
-{
- struct timespec ts = stat_ctimespec(st);
- return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
-}
/*
* call-seq:
@@ -594,9 +531,10 @@ stat_ctime(struct stat *st)
*/
static VALUE
-rb_stat_atime(VALUE self)
+rb_stat_atime(self)
+ VALUE self;
{
- return stat_atime(get_stat(self));
+ return rb_time_new(get_stat(self)->st_atime, 0);
}
/*
@@ -610,9 +548,10 @@ rb_stat_atime(VALUE self)
*/
static VALUE
-rb_stat_mtime(VALUE self)
+rb_stat_mtime(self)
+ VALUE self;
{
- return stat_mtime(get_stat(self));
+ return rb_time_new(get_stat(self)->st_mtime, 0);
}
/*
@@ -628,9 +567,10 @@ rb_stat_mtime(VALUE self)
*/
static VALUE
-rb_stat_ctime(VALUE self)
+rb_stat_ctime(self)
+ VALUE self;
{
- return stat_ctime(get_stat(self));
+ return rb_time_new(get_stat(self)->st_ctime, 0);
}
/*
@@ -648,13 +588,14 @@ rb_stat_ctime(VALUE self)
*/
static VALUE
-rb_stat_inspect(VALUE self)
+rb_stat_inspect(self)
+ VALUE self;
{
VALUE str;
int i;
static const struct {
const char *name;
- VALUE (*func)(VALUE);
+ VALUE (*func)_((VALUE));
} member[] = {
{"dev", rb_stat_dev},
{"ino", rb_stat_ino},
@@ -707,25 +648,29 @@ rb_stat_inspect(VALUE self)
}
static int
-rb_stat(VALUE file, struct stat *st)
+rb_stat(file, st)
+ VALUE file;
+ struct stat *st;
{
VALUE tmp;
- rb_secure(2);
tmp = rb_check_convert_type(file, T_FILE, "IO", "to_io");
if (!NIL_P(tmp)) {
rb_io_t *fptr;
+ rb_secure(2);
GetOpenFile(tmp, fptr);
- return fstat(fptr->fd, st);
+ return fstat(fileno(fptr->f), st);
}
- FilePathValue(file);
+ SafeStringValue(file);
return stat(StringValueCStr(file), st);
}
#ifdef _WIN32
static HANDLE
-w32_io_info(VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
+w32_io_info(file, st)
+ VALUE *file;
+ BY_HANDLE_FILE_INFORMATION *st;
{
VALUE tmp;
HANDLE f, ret = 0;
@@ -735,11 +680,11 @@ w32_io_info(VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
rb_io_t *fptr;
GetOpenFile(tmp, fptr);
- f = (HANDLE)rb_w32_get_osfhandle(fptr->fd);
+ f = (HANDLE)rb_w32_get_osfhandle(fileno(fptr->f));
if (f == (HANDLE)-1) return INVALID_HANDLE_VALUE;
}
else {
- FilePathValue(*file);
+ SafeStringValue(*file);
f = CreateFile(StringValueCStr(*file), 0,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
rb_w32_iswin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -767,12 +712,12 @@ w32_io_info(VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
*/
static VALUE
-rb_file_s_stat(VALUE klass, VALUE fname)
+rb_file_s_stat(klass, fname)
+ VALUE klass, fname;
{
struct stat st;
- rb_secure(4);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (rb_stat(fname, &st) < 0) {
rb_sys_fail(StringValueCStr(fname));
}
@@ -795,13 +740,14 @@ rb_file_s_stat(VALUE klass, VALUE fname)
*/
static VALUE
-rb_io_stat(VALUE obj)
+rb_io_stat(obj)
+ VALUE obj;
{
rb_io_t *fptr;
struct stat st;
GetOpenFile(obj, fptr);
- if (fstat(fptr->fd, &st) == -1) {
+ if (fstat(fileno(fptr->f), &st) == -1) {
rb_sys_fail(fptr->path);
}
return stat_new(&st);
@@ -822,15 +768,15 @@ rb_io_stat(VALUE obj)
*/
static VALUE
-rb_file_s_lstat(VALUE klass, VALUE fname)
+rb_file_s_lstat(klass, fname)
+ VALUE klass, fname;
{
#ifdef HAVE_LSTAT
struct stat st;
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (lstat(StringValueCStr(fname), &st) == -1) {
- rb_sys_fail(RSTRING_PTR(fname));
+ rb_sys_fail(RSTRING(fname)->ptr);
}
return stat_new(&st);
#else
@@ -854,7 +800,8 @@ rb_file_s_lstat(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_lstat(VALUE obj)
+rb_file_lstat(obj)
+ VALUE obj;
{
#ifdef HAVE_LSTAT
rb_io_t *fptr;
@@ -874,7 +821,8 @@ rb_file_lstat(VALUE obj)
#ifndef HAVE_GROUP_MEMBER
static int
-group_member(GETGROUPS_T gid)
+group_member(gid)
+ GETGROUPS_T gid;
{
#ifndef _WIN32
if (getgid() == gid || getegid() == gid)
@@ -913,11 +861,13 @@ group_member(GETGROUPS_T gid)
#ifndef HAVE_EACCESS
int
-eaccess(const char *path, int mode)
+eaccess(path, mode)
+ const char *path;
+ int mode;
{
#ifdef USE_GETEUID
struct stat st;
- rb_uid_t euid;
+ int euid;
if (stat(path, &st) < 0) return -1;
@@ -945,8 +895,8 @@ eaccess(const char *path, int mode)
return -1;
#else
-# if _MSC_VER >= 1400
- mode &= 6;
+# if defined(_MSC_VER) || defined(__MINGW32__)
+ mode &= ~1;
# endif
return access(path, mode);
#endif
@@ -966,30 +916,6 @@ eaccess(const char *path, int mode)
/*
- * File.directory?(file_name) => true or false
- * File.directory?(file_name) => true or false
- *
- * Returns <code>true</code> if the named file is a directory,
- * <code>false</code> otherwise.
- *
- * File.directory?(".")
- */
-
-/*
- * Document-method: exist?
- *
- * call-seq:
- * Dir.exist?(file_name) => true or false
- * Dir.exists?(file_name) => true or false
- *
- * Returns <code>true</code> if the named file is a directory,
- * <code>false</code> otherwise.
- *
- */
-
-/*
- * Document-method: directory?
- *
* call-seq:
* File.directory?(file_name) => true or false
*
@@ -999,8 +925,9 @@ eaccess(const char *path, int mode)
* File.directory?(".")
*/
-VALUE
-rb_file_directory_p(VALUE obj, VALUE fname)
+static VALUE
+test_d(obj, fname)
+ VALUE obj, fname;
{
#ifndef S_ISDIR
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
@@ -1013,7 +940,6 @@ rb_file_directory_p(VALUE obj, VALUE fname)
return Qfalse;
}
-
/*
* call-seq:
* File.pipe?(file_name) => true or false
@@ -1022,7 +948,8 @@ rb_file_directory_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_pipe_p(VALUE obj, VALUE fname)
+test_p(obj, fname)
+ VALUE obj, fname;
{
#ifdef S_IFIFO
# ifndef S_ISFIFO
@@ -1046,11 +973,20 @@ rb_file_pipe_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_symlink_p(VALUE obj, VALUE fname)
+test_l(obj, fname)
+ VALUE obj, fname;
{
#ifndef S_ISLNK
# ifdef _S_ISLNK
# define S_ISLNK(m) _S_ISLNK(m)
+# elif defined __BORLANDC__
+# ifdef _S_IFLNK
+# define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == _S_IFLNK)
+# else
+# ifdef S_IFLNK
+# define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == S_IFLNK)
+# endif
+# endif
# else
# ifdef _S_IFLNK
# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
@@ -1065,8 +1001,7 @@ rb_file_symlink_p(VALUE obj, VALUE fname)
#ifdef S_ISLNK
struct stat st;
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (lstat(StringValueCStr(fname), &st) < 0) return Qfalse;
if (S_ISLNK(st.st_mode)) return Qtrue;
#endif
@@ -1082,11 +1017,20 @@ rb_file_symlink_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_socket_p(VALUE obj, VALUE fname)
+test_S(obj, fname)
+ VALUE obj, fname;
{
#ifndef S_ISSOCK
# ifdef _S_ISSOCK
# define S_ISSOCK(m) _S_ISSOCK(m)
+# elif defined __BORLANDC__
+# ifdef _S_IFSOCK
+# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == _S_IFSOCK)
+# else
+# ifdef S_IFSOCK
+# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == S_IFSOCK)
+# endif
+# endif
# else
# ifdef _S_IFSOCK
# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
@@ -1116,7 +1060,8 @@ rb_file_socket_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_blockdev_p(VALUE obj, VALUE fname)
+test_b(obj, fname)
+ VALUE obj, fname;
{
#ifndef S_ISBLK
# ifdef S_IFBLK
@@ -1143,7 +1088,8 @@ rb_file_blockdev_p(VALUE obj, VALUE fname)
* Returns <code>true</code> if the named file is a character device.
*/
static VALUE
-rb_file_chardev_p(VALUE obj, VALUE fname)
+test_c(obj, fname)
+ VALUE obj, fname;
{
#ifndef S_ISCHR
# define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
@@ -1161,13 +1107,14 @@ rb_file_chardev_p(VALUE obj, VALUE fname)
/*
* call-seq:
* File.exist?(file_name) => true or false
- * File.exists?(file_name) => true or false
+ * File.exists?(file_name) => true or false (obsolete)
*
* Return <code>true</code> if the named file exists.
*/
static VALUE
-rb_file_exist_p(VALUE obj, VALUE fname)
+test_e(obj, fname)
+ VALUE obj, fname;
{
struct stat st;
@@ -1184,10 +1131,10 @@ rb_file_exist_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_readable_p(VALUE obj, VALUE fname)
+test_r(obj, fname)
+ VALUE obj, fname;
{
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (eaccess(StringValueCStr(fname), R_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -1201,49 +1148,14 @@ rb_file_readable_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_readable_real_p(VALUE obj, VALUE fname)
+test_R(obj, fname)
+ VALUE obj, fname;
{
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (access(StringValueCStr(fname), R_OK) < 0) return Qfalse;
return Qtrue;
}
-#ifndef S_IRUGO
-# define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
-#endif
-
-#ifndef S_IWUGO
-# define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
-#endif
-
-/*
- * call-seq:
- * File.world_readable?(file_name) => fixnum or nil
- *
- * If <i>file_name</i> is readable by others, returns an integer
- * representing the file permission bits of <i>file_name</i>. Returns
- * <code>nil</code> otherwise. The meaning of the bits is platform
- * dependent; on Unix systems, see <code>stat(2)</code>.
- *
- * File.world_readable?("/etc/passwd") # => 420
- * m = File.world_readable?("/etc/passwd")
- * sprintf("%o", m) # => "644"
- */
-
-static VALUE
-rb_file_world_readable_p(VALUE obj, VALUE fname)
-{
-#ifdef S_IROTH
- struct stat st;
-
- if (rb_stat(fname, &st) < 0) return Qnil;
- if ((st.st_mode & (S_IROTH)) == S_IROTH) {
- return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
- }
-#endif
- return Qnil;
-}
/*
* call-seq:
@@ -1254,10 +1166,10 @@ rb_file_world_readable_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_writable_p(VALUE obj, VALUE fname)
+test_w(obj, fname)
+ VALUE obj, fname;
{
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (eaccess(StringValueCStr(fname), W_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -1271,44 +1183,16 @@ rb_file_writable_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_writable_real_p(VALUE obj, VALUE fname)
+test_W(obj, fname)
+ VALUE obj, fname;
{
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (access(StringValueCStr(fname), W_OK) < 0) return Qfalse;
return Qtrue;
}
/*
* call-seq:
- * File.world_writable?(file_name) => fixnum or nil
- *
- * If <i>file_name</i> is writable by others, returns an integer
- * representing the file permission bits of <i>file_name</i>. Returns
- * <code>nil</code> otherwise. The meaning of the bits is platform
- * dependent; on Unix systems, see <code>stat(2)</code>.
- *
- * File.world_writable?("/tmp") #=> 511
- * m = File.world_writable?("/tmp")
- * sprintf("%o", m) #=> "777"
- */
-
-static VALUE
-rb_file_world_writable_p(VALUE obj, VALUE fname)
-{
-#ifdef S_IWOTH
- struct stat st;
-
- if (rb_stat(fname, &st) < 0) return Qfalse;
- if ((st.st_mode & (S_IWOTH)) == S_IWOTH) {
- return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
- }
-#endif
- return Qnil;
-}
-
-/*
- * call-seq:
* File.executable?(file_name) => true or false
*
* Returns <code>true</code> if the named file is executable by the effective
@@ -1316,10 +1200,10 @@ rb_file_world_writable_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_executable_p(VALUE obj, VALUE fname)
+test_x(obj, fname)
+ VALUE obj, fname;
{
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (eaccess(StringValueCStr(fname), X_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -1333,10 +1217,10 @@ rb_file_executable_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_executable_real_p(VALUE obj, VALUE fname)
+test_X(obj, fname)
+ VALUE obj, fname;
{
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (access(StringValueCStr(fname), X_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -1354,7 +1238,8 @@ rb_file_executable_real_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_file_p(VALUE obj, VALUE fname)
+test_f(obj, fname)
+ VALUE obj, fname;
{
struct stat st;
@@ -1372,7 +1257,8 @@ rb_file_file_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_zero_p(VALUE obj, VALUE fname)
+test_z(obj, fname)
+ VALUE obj, fname;
{
struct stat st;
@@ -1390,7 +1276,8 @@ rb_file_zero_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_size_p(VALUE obj, VALUE fname)
+test_s(obj, fname)
+ VALUE obj, fname;
{
struct stat st;
@@ -1409,7 +1296,8 @@ rb_file_size_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_owned_p(VALUE obj, VALUE fname)
+test_owned(obj, fname)
+ VALUE obj, fname;
{
struct stat st;
@@ -1419,7 +1307,8 @@ rb_file_owned_p(VALUE obj, VALUE fname)
}
static VALUE
-rb_file_rowned_p(VALUE obj, VALUE fname)
+test_rowned(obj, fname)
+ VALUE obj, fname;
{
struct stat st;
@@ -1438,7 +1327,8 @@ rb_file_rowned_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_grpowned_p(VALUE obj, VALUE fname)
+test_grpowned(obj, fname)
+ VALUE obj, fname;
{
#ifndef _WIN32
struct stat st;
@@ -1451,12 +1341,13 @@ rb_file_grpowned_p(VALUE obj, VALUE fname)
#if defined(S_ISUID) || defined(S_ISGID) || defined(S_ISVTX)
static VALUE
-check3rdbyte(VALUE fname, int mode)
+check3rdbyte(fname, mode)
+ VALUE fname;
+ int mode;
{
struct stat st;
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (stat(StringValueCStr(fname), &st) < 0) return Qfalse;
if (st.st_mode & mode) return Qtrue;
return Qfalse;
@@ -1471,7 +1362,8 @@ check3rdbyte(VALUE fname, int mode)
*/
static VALUE
-rb_file_suid_p(VALUE obj, VALUE fname)
+test_suid(obj, fname)
+ VALUE obj, fname;
{
#ifdef S_ISUID
return check3rdbyte(fname, S_ISUID);
@@ -1488,7 +1380,8 @@ rb_file_suid_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_sgid_p(VALUE obj, VALUE fname)
+test_sgid(obj, fname)
+ VALUE obj, fname;
{
#ifdef S_ISGID
return check3rdbyte(fname, S_ISGID);
@@ -1505,7 +1398,8 @@ rb_file_sgid_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_sticky_p(VALUE obj, VALUE fname)
+test_sticky(obj, fname)
+ VALUE obj, fname;
{
#ifdef S_ISVTX
return check3rdbyte(fname, S_ISVTX);
@@ -1532,7 +1426,8 @@ rb_file_sticky_p(VALUE obj, VALUE fname)
*/
static VALUE
-rb_file_identical_p(VALUE obj, VALUE fname1, VALUE fname2)
+test_identical(obj, fname1, fname2)
+ VALUE obj, fname1, fname2;
{
#ifndef DOSISH
struct stat st1, st2;
@@ -1563,16 +1458,16 @@ rb_file_identical_p(VALUE obj, VALUE fname1, VALUE fname2)
if (!f1 || !f2) return Qfalse;
if (rb_w32_iswin95()) return Qfalse;
#else
- FilePathValue(fname1);
+ SafeStringValue(fname1);
fname1 = rb_str_new4(fname1);
- FilePathValue(fname2);
- if (access(RSTRING_PTR(fname1), 0)) return Qfalse;
- if (access(RSTRING_PTR(fname2), 0)) return Qfalse;
+ SafeStringValue(fname2);
+ if (access(RSTRING(fname1)->ptr, 0)) return Qfalse;
+ if (access(RSTRING(fname2)->ptr, 0)) return Qfalse;
#endif
fname1 = rb_file_expand_path(fname1, Qnil);
fname2 = rb_file_expand_path(fname2, Qnil);
- if (RSTRING_LEN(fname1) != RSTRING_LEN(fname2)) return Qfalse;
- if (rb_memcicmp(RSTRING_PTR(fname1), RSTRING_PTR(fname2), RSTRING_LEN(fname1)))
+ if (RSTRING(fname1)->len != RSTRING(fname2)->len) return Qfalse;
+ if (rb_memcicmp(RSTRING(fname1)->ptr, RSTRING(fname2)->ptr, RSTRING(fname1)->len))
return Qfalse;
#endif
return Qtrue;
@@ -1586,7 +1481,8 @@ rb_file_identical_p(VALUE obj, VALUE fname1, VALUE fname2)
*/
static VALUE
-rb_file_s_size(VALUE klass, VALUE fname)
+rb_file_s_size(klass, fname)
+ VALUE klass, fname;
{
struct stat st;
@@ -1596,7 +1492,8 @@ rb_file_s_size(VALUE klass, VALUE fname)
}
static VALUE
-rb_file_ftype(const struct stat *st)
+rb_file_ftype(st)
+ struct stat *st;
{
const char *t;
@@ -1652,14 +1549,14 @@ rb_file_ftype(const struct stat *st)
*/
static VALUE
-rb_file_s_ftype(VALUE klass, VALUE fname)
+rb_file_s_ftype(klass, fname)
+ VALUE klass, fname;
{
struct stat st;
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (lstat(StringValueCStr(fname), &st) == -1) {
- rb_sys_fail(RSTRING_PTR(fname));
+ rb_sys_fail(RSTRING(fname)->ptr);
}
return rb_file_ftype(&st);
@@ -1676,13 +1573,14 @@ rb_file_s_ftype(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_s_atime(VALUE klass, VALUE fname)
+rb_file_s_atime(klass, fname)
+ VALUE klass, fname;
{
struct stat st;
if (rb_stat(fname, &st) < 0)
rb_sys_fail(StringValueCStr(fname));
- return stat_atime(&st);
+ return rb_time_new(st.st_atime, 0);
}
/*
@@ -1697,16 +1595,17 @@ rb_file_s_atime(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_atime(VALUE obj)
+rb_file_atime(obj)
+ VALUE obj;
{
rb_io_t *fptr;
struct stat st;
GetOpenFile(obj, fptr);
- if (fstat(fptr->fd, &st) == -1) {
+ if (fstat(fileno(fptr->f), &st) == -1) {
rb_sys_fail(fptr->path);
}
- return stat_atime(&st);
+ return rb_time_new(st.st_atime, 0);
}
/*
@@ -1720,13 +1619,14 @@ rb_file_atime(VALUE obj)
*/
static VALUE
-rb_file_s_mtime(VALUE klass, VALUE fname)
+rb_file_s_mtime(klass, fname)
+ VALUE klass, fname;
{
struct stat st;
if (rb_stat(fname, &st) < 0)
- rb_sys_fail(RSTRING_PTR(fname));
- return stat_mtime(&st);
+ rb_sys_fail(RSTRING(fname)->ptr);
+ return rb_time_new(st.st_mtime, 0);
}
/*
@@ -1740,16 +1640,17 @@ rb_file_s_mtime(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_mtime(VALUE obj)
+rb_file_mtime(obj)
+ VALUE obj;
{
rb_io_t *fptr;
struct stat st;
GetOpenFile(obj, fptr);
- if (fstat(fptr->fd, &st) == -1) {
+ if (fstat(fileno(fptr->f), &st) == -1) {
rb_sys_fail(fptr->path);
}
- return stat_mtime(&st);
+ return rb_time_new(st.st_mtime, 0);
}
/*
@@ -1765,13 +1666,14 @@ rb_file_mtime(VALUE obj)
*/
static VALUE
-rb_file_s_ctime(VALUE klass, VALUE fname)
+rb_file_s_ctime(klass, fname)
+ VALUE klass, fname;
{
struct stat st;
if (rb_stat(fname, &st) < 0)
- rb_sys_fail(RSTRING_PTR(fname));
- return stat_ctime(&st);
+ rb_sys_fail(RSTRING(fname)->ptr);
+ return rb_time_new(st.st_ctime, 0);
}
/*
@@ -1786,20 +1688,24 @@ rb_file_s_ctime(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_ctime(VALUE obj)
+rb_file_ctime(obj)
+ VALUE obj;
{
rb_io_t *fptr;
struct stat st;
GetOpenFile(obj, fptr);
- if (fstat(fptr->fd, &st) == -1) {
+ if (fstat(fileno(fptr->f), &st) == -1) {
rb_sys_fail(fptr->path);
}
- return stat_ctime(&st);
+ return rb_time_new(st.st_ctime, 0);
}
+static void chmod_internal _((const char *, void *));
static void
-chmod_internal(const char *path, void *mode)
+chmod_internal(path, mode)
+ const char *path;
+ void *mode;
{
if (chmod(path, *(int *)mode) < 0)
rb_sys_fail(path);
@@ -1819,7 +1725,9 @@ chmod_internal(const char *path, void *mode)
*/
static VALUE
-rb_file_s_chmod(int argc, VALUE *argv)
+rb_file_s_chmod(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE vmode;
VALUE rest;
@@ -1848,7 +1756,8 @@ rb_file_s_chmod(int argc, VALUE *argv)
*/
static VALUE
-rb_file_chmod(VALUE obj, VALUE vmode)
+rb_file_chmod(obj, vmode)
+ VALUE obj, vmode;
{
rb_io_t *fptr;
int mode;
@@ -1858,7 +1767,7 @@ rb_file_chmod(VALUE obj, VALUE vmode)
GetOpenFile(obj, fptr);
#ifdef HAVE_FCHMOD
- if (fchmod(fptr->fd, mode) == -1)
+ if (fchmod(fileno(fptr->f), mode) == -1)
rb_sys_fail(fptr->path);
#else
if (!fptr->path) return Qnil;
@@ -1870,10 +1779,13 @@ rb_file_chmod(VALUE obj, VALUE vmode)
}
#if defined(HAVE_LCHMOD)
+static void lchmod_internal _((const char *, void *));
static void
-lchmod_internal(const char *path, void *mode)
+lchmod_internal(path, mode)
+ const char *path;
+ void *mode;
{
- if (lchmod(path, (int)mode) < 0)
+ if (lchmod(path, (int)(VALUE)mode) < 0)
rb_sys_fail(path);
}
@@ -1888,7 +1800,9 @@ lchmod_internal(const char *path, void *mode)
*/
static VALUE
-rb_file_s_lchmod(int argc, VALUE *argv)
+rb_file_s_lchmod(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE vmode;
VALUE rest;
@@ -1903,7 +1817,9 @@ rb_file_s_lchmod(int argc, VALUE *argv)
}
#else
static VALUE
-rb_file_s_lchmod(int argc, VALUE *argv)
+rb_file_s_lchmod(argc, argv)
+ int argc;
+ VALUE *argv;
{
rb_notimplement();
return Qnil; /* not reached */
@@ -1911,14 +1827,16 @@ rb_file_s_lchmod(int argc, VALUE *argv)
#endif
struct chown_args {
- rb_uid_t owner;
- rb_gid_t group;
+ int owner, group;
};
+static void chown_internal _((const char *, void *));
static void
-chown_internal(const char *path, void *arg)
+chown_internal(path, argp)
+ const char *path;
+ void *argp;
{
- struct chown_args *args = arg;
+ struct chown_args *args = (struct chown_args *)argp;
if (chown(path, args->owner, args->group) < 0)
rb_sys_fail(path);
}
@@ -1939,7 +1857,9 @@ chown_internal(const char *path, void *arg)
*/
static VALUE
-rb_file_s_chown(int argc, VALUE *argv)
+rb_file_s_chown(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE o, g, rest;
struct chown_args arg;
@@ -1951,13 +1871,13 @@ rb_file_s_chown(int argc, VALUE *argv)
arg.owner = -1;
}
else {
- arg.owner = NUM2UIDT(o);
+ arg.owner = NUM2INT(o);
}
if (NIL_P(g)) {
arg.group = -1;
}
else {
- arg.group = NUM2GIDT(g);
+ arg.group = NUM2INT(g);
}
n = apply2files(chown_internal, rest, &arg);
@@ -1980,7 +1900,8 @@ rb_file_s_chown(int argc, VALUE *argv)
*/
static VALUE
-rb_file_chown(VALUE obj, VALUE owner, VALUE group)
+rb_file_chown(obj, owner, group)
+ VALUE obj, owner, group;
{
rb_io_t *fptr;
int o, g;
@@ -1994,7 +1915,7 @@ rb_file_chown(VALUE obj, VALUE owner, VALUE group)
if (chown(fptr->path, o, g) == -1)
rb_sys_fail(fptr->path);
#else
- if (fchown(fptr->fd, o, g) == -1)
+ if (fchown(fileno(fptr->f), o, g) == -1)
rb_sys_fail(fptr->path);
#endif
@@ -2002,10 +1923,13 @@ rb_file_chown(VALUE obj, VALUE owner, VALUE group)
}
#if defined(HAVE_LCHOWN) && !defined(__CHECKER__)
+static void lchown_internal _((const char *, void *));
static void
-lchown_internal(const char *path, void *arg)
+lchown_internal(path, argp)
+ const char *path;
+ void *argp;
{
- struct chown_args *args = arg;
+ struct chown_args *args = (struct chown_args *)argp;
if (lchown(path, args->owner, args->group) < 0)
rb_sys_fail(path);
}
@@ -2023,7 +1947,9 @@ lchown_internal(const char *path, void *arg)
*/
static VALUE
-rb_file_s_lchown(int argc, VALUE *argv)
+rb_file_s_lchown(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE o, g, rest;
struct chown_args arg;
@@ -2035,13 +1961,13 @@ rb_file_s_lchown(int argc, VALUE *argv)
arg.owner = -1;
}
else {
- arg.owner = NUM2UIDT(o);
+ arg.owner = NUM2INT(o);
}
if (NIL_P(g)) {
arg.group = -1;
}
else {
- arg.group = NUM2GIDT(g);
+ arg.group = NUM2INT(g);
}
n = apply2files(lchown_internal, rest, &arg);
@@ -2049,50 +1975,61 @@ rb_file_s_lchown(int argc, VALUE *argv)
}
#else
static VALUE
-rb_file_s_lchown(int argc, VALUE *argv)
+rb_file_s_lchown(argc, argv)
+ int argc;
+ VALUE *argv;
{
rb_notimplement();
}
#endif
-struct timespec rb_time_timespec(VALUE time);
+struct timeval rb_time_timeval();
-#if defined(HAVE_UTIMES)
+static void utime_internal _((const char *, void *));
-static void
-utime_internal(const char *path, void *arg)
-{
- struct timespec *tsp = arg;
- struct timeval tvbuf[2], *tvp = arg;
-
-#ifdef HAVE_UTIMENSAT
- static int try_utimensat = 1;
-
- if (try_utimensat) {
- struct timespec *tsp = arg;
- if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
- if (errno == ENOSYS) {
- try_utimensat = 0;
- goto no_utimensat;
- }
- rb_sys_fail(path);
- }
- return;
- }
-no_utimensat:
-#endif
+#if defined(HAVE_UTIMES) && !defined(__CHECKER__)
- if (tsp) {
- tvbuf[0].tv_sec = tsp[0].tv_sec;
- tvbuf[0].tv_usec = tsp[0].tv_nsec / 1000;
- tvbuf[1].tv_sec = tsp[1].tv_sec;
- tvbuf[1].tv_usec = tsp[1].tv_nsec / 1000;
- tvp = tvbuf;
- }
+static void
+utime_internal(path, arg)
+ const char *path;
+ void *arg;
+{
+ struct timeval *tvp = arg;
if (utimes(path, tvp) < 0)
rb_sys_fail(path);
}
+/*
+ * call-seq:
+ * File.utime(atime, mtime, file_name,...) => integer
+ *
+ * Sets the access and modification times of each
+ * named file to the first two arguments. Returns
+ * the number of file names in the argument list.
+ */
+
+static VALUE
+rb_file_s_utime(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE atime, mtime, rest;
+ struct timeval tvs[2], *tvp = NULL;
+ long n;
+
+ rb_secure(2);
+ rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
+
+ if (!NIL_P(atime) || !NIL_P(mtime)) {
+ tvp = tvs;
+ tvp[0] = rb_time_timeval(atime);
+ tvp[1] = rb_time_timeval(mtime);
+ }
+
+ n = apply2files(utime_internal, rest, tvp);
+ return LONG2FIX(n);
+}
+
#else
#if !defined HAVE_UTIME_H && !defined HAVE_SYS_UTIME_H
@@ -2103,60 +2040,52 @@ struct utimbuf {
#endif
static void
-utime_internal(const char *path, void *arg)
+utime_internal(path, arg)
+ const char *path;
+ void *arg;
{
- struct timespec *tsp = arg;
- struct utimbuf utbuf, *utp = NULL;
- if (tsp) {
- utbuf.actime = tsp[0].tv_sec;
- utbuf.modtime = tsp[1].tv_sec;
- utp = &utbuf;
- }
+ struct utimbuf *utp = arg;
if (utime(path, utp) < 0)
rb_sys_fail(path);
}
-#endif
-
-/*
- * call-seq:
- * File.utime(atime, mtime, file_name,...) => integer
- *
- * Sets the access and modification times of each
- * named file to the first two arguments. Returns
- * the number of file names in the argument list.
- */
-
static VALUE
-rb_file_s_utime(int argc, VALUE *argv)
+rb_file_s_utime(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE atime, mtime, rest;
- struct timespec tss[2], *tsp = NULL;
long n;
+ struct timeval tv;
+ struct utimbuf utbuf, *utp = NULL;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
if (!NIL_P(atime) || !NIL_P(mtime)) {
- tsp = tss;
- tsp[0] = rb_time_timespec(atime);
- tsp[1] = rb_time_timespec(mtime);
+ utp = &utbuf;
+ tv = rb_time_timeval(atime);
+ utp->actime = tv.tv_sec;
+ tv = rb_time_timeval(mtime);
+ utp->modtime = tv.tv_sec;
}
- n = apply2files(utime_internal, rest, tsp);
+ n = apply2files(utime_internal, rest, utp);
return LONG2FIX(n);
}
+#endif
-NORETURN(static void sys_fail2(VALUE,VALUE));
+NORETURN(static void sys_fail2 _((VALUE,VALUE)));
static void
-sys_fail2(VALUE s1, VALUE s2)
+sys_fail2(s1, s2)
+ VALUE s1, s2;
{
char *buf;
int len;
- len = RSTRING_LEN(s1) + RSTRING_LEN(s2) + 5;
+ len = RSTRING(s1)->len + RSTRING(s2)->len + 5;
buf = ALLOCA_N(char, len);
- snprintf(buf, len, "(%s, %s)", RSTRING_PTR(s1), RSTRING_PTR(s2));
+ snprintf(buf, len, "%s or %s", RSTRING(s1)->ptr, RSTRING(s2)->ptr);
rb_sys_fail(buf);
}
@@ -2173,12 +2102,12 @@ sys_fail2(VALUE s1, VALUE s2)
*/
static VALUE
-rb_file_s_link(VALUE klass, VALUE from, VALUE to)
+rb_file_s_link(klass, from, to)
+ VALUE klass, from, to;
{
#ifdef HAVE_LINK
- rb_secure(2);
- FilePathValue(from);
- FilePathValue(to);
+ SafeStringValue(from);
+ SafeStringValue(to);
if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
sys_fail2(from, to);
@@ -2203,12 +2132,12 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
*/
static VALUE
-rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
+rb_file_s_symlink(klass, from, to)
+ VALUE klass, from, to;
{
#ifdef HAVE_SYMLINK
- rb_secure(2);
- FilePathValue(from);
- FilePathValue(to);
+ SafeStringValue(from);
+ SafeStringValue(to);
if (symlink(StringValueCStr(from), StringValueCStr(to)) < 0) {
sys_fail2(from, to);
@@ -2232,7 +2161,8 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
*/
static VALUE
-rb_file_s_readlink(VALUE klass, VALUE path)
+rb_file_s_readlink(klass, path)
+ VALUE klass, path;
{
#ifdef HAVE_READLINK
char *buf;
@@ -2240,10 +2170,9 @@ rb_file_s_readlink(VALUE klass, VALUE path)
int rv;
VALUE v;
- rb_secure(2);
- FilePathValue(path);
+ SafeStringValue(path);
buf = xmalloc(size);
- while ((rv = readlink(RSTRING_PTR(path), buf, size)) == size
+ while ((rv = readlink(RSTRING(path)->ptr, buf, size)) == size
#ifdef _AIX
|| (rv < 0 && errno == ERANGE) /* quirky behavior of GPFS */
#endif
@@ -2253,7 +2182,7 @@ rb_file_s_readlink(VALUE klass, VALUE path)
}
if (rv < 0) {
free(buf);
- rb_sys_fail(RSTRING_PTR(path));
+ rb_sys_fail(RSTRING(path)->ptr);
}
v = rb_tainted_str_new(buf, rv);
free(buf);
@@ -2265,8 +2194,11 @@ rb_file_s_readlink(VALUE klass, VALUE path)
#endif
}
+static void unlink_internal _((const char *, void *));
static void
-unlink_internal(const char *path, void *arg)
+unlink_internal(path, arg)
+ const char *path;
+ void *arg;
{
if (unlink(path) < 0)
rb_sys_fail(path);
@@ -2283,7 +2215,8 @@ unlink_internal(const char *path, void *arg)
*/
static VALUE
-rb_file_s_unlink(VALUE klass, VALUE args)
+rb_file_s_unlink(klass, args)
+ VALUE klass, args;
{
long n;
@@ -2303,13 +2236,13 @@ rb_file_s_unlink(VALUE klass, VALUE args)
*/
static VALUE
-rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
+rb_file_s_rename(klass, from, to)
+ VALUE klass, from, to;
{
const char *src, *dst;
+ SafeStringValue(from);
+ SafeStringValue(to);
- rb_secure(2);
- FilePathValue(from);
- FilePathValue(to);
src = StringValueCStr(from);
dst = StringValueCStr(to);
#if defined __CYGWIN__
@@ -2350,7 +2283,9 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
*/
static VALUE
-rb_file_s_umask(int argc, VALUE *argv)
+rb_file_s_umask(argc, argv)
+ int argc;
+ VALUE *argv;
{
int omask = 0;
@@ -2368,29 +2303,45 @@ rb_file_s_umask(int argc, VALUE *argv)
return INT2FIX(omask);
}
-#if defined DOSISH
+#ifdef __CYGWIN__
+#undef DOSISH
+#endif
+#if defined __CYGWIN__ || defined DOSISH
#define DOSISH_UNC
+#define DOSISH_DRIVE_LETTER
#define isdirsep(x) ((x) == '/' || (x) == '\\')
#else
#define isdirsep(x) ((x) == '/')
#endif
+
+#if defined _WIN32 || defined __CYGWIN__
+#define USE_NTFS 1
+#else
+#define USE_NTFS 0
+#endif
+
+#ifdef DOSISH_DRIVE_LETTER
+#include <ctype.h>
+#endif
+
+#if USE_NTFS
+#define istrailinggabage(x) ((x) == '.' || (x) == ' ')
+#else
+#define istrailinggabage(x) 0
+#endif
+
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
# if defined(DJGPP)
-# define CharNext(p) ((p) + mblen(p, RUBY_MBCHAR_MAXSIZE))
+# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
# else
# define CharNext(p) ((p) + 1)
# endif
#endif
-#ifdef __CYGWIN__
-#undef DOSISH
-#define DOSISH_UNC
-#define DOSISH_DRIVE_LETTER
-#endif
-
#ifdef DOSISH_DRIVE_LETTER
static inline int
-has_drive_letter(const char *buf)
+has_drive_letter(buf)
+ const char *buf;
{
if (ISALPHA(buf[0]) && buf[1] == ':') {
return 1;
@@ -2401,7 +2352,8 @@ has_drive_letter(const char *buf)
}
static char*
-getcwdofdrv(int drv)
+getcwdofdrv(drv)
+ int drv;
{
char drive[4];
char *drvcwd, *oldcwd;
@@ -2429,7 +2381,8 @@ getcwdofdrv(int drv)
#endif
static inline char *
-skiproot(const char *path)
+skiproot(path)
+ const char *path;
{
#ifdef DOSISH_DRIVE_LETTER
if (has_drive_letter(path)) path += 2;
@@ -2440,7 +2393,8 @@ skiproot(const char *path)
#define nextdirsep rb_path_next
char *
-rb_path_next(const char *s)
+rb_path_next(s)
+ const char *s;
{
while (*s && !isdirsep(*s)) {
s = CharNext(s);
@@ -2454,7 +2408,8 @@ rb_path_next(const char *s)
#define skipprefix(path) (path)
#endif
char *
-rb_path_skip_prefix(const char *path)
+rb_path_skip_prefix(path)
+ const char *path;
{
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
#ifdef DOSISH_UNC
@@ -2476,7 +2431,8 @@ rb_path_skip_prefix(const char *path)
#define strrdirsep rb_path_last_separator
char *
-rb_path_last_separator(const char *path)
+rb_path_last_separator(path)
+ const char *path;
{
char *last = NULL;
while (*path) {
@@ -2494,7 +2450,8 @@ rb_path_last_separator(const char *path)
}
static char *
-chompdirsep(const char *path)
+chompdirsep(path)
+ const char *path;
{
while (*path) {
if (isdirsep(*path)) {
@@ -2510,49 +2467,76 @@ chompdirsep(const char *path)
}
char *
-rb_path_end(const char *path)
+rb_path_end(path)
+ const char *path;
{
if (isdirsep(*path)) path++;
return chompdirsep(path);
}
+#if USE_NTFS
+static char *
+ntfs_tail(const char *path)
+{
+ while (*path == '.') path++;
+ while (*path && *path != ':') {
+ if (istrailinggabage(*path)) {
+ const char *last = path++;
+ while (istrailinggabage(*path)) path++;
+ if (!*path || *path == ':') return (char *)last;
+ }
+ else if (isdirsep(*path)) {
+ const char *last = path++;
+ while (isdirsep(*path)) path++;
+ if (!*path) return (char *)last;
+ if (*path == ':') path++;
+ }
+ else {
+ path = CharNext(path);
+ }
+ }
+ return (char *)path;
+}
+#endif
+
#define BUFCHECK(cond) do {\
long bdiff = p - buf;\
- while (cond) {\
- buflen *= 2;\
+ if (cond) {\
+ do {buflen *= 2;} while (cond);\
+ rb_str_resize(result, buflen);\
+ buf = RSTRING_PTR(result);\
+ p = buf + bdiff;\
+ pend = buf + buflen;\
}\
- rb_str_resize(result, buflen);\
- buf = RSTRING_PTR(result);\
- p = buf + bdiff;\
- pend = buf + buflen;\
} while (0)
#define BUFINIT() (\
- p = buf = RSTRING_PTR(result),\
- buflen = RSTRING_LEN(result),\
+ p = buf = RSTRING(result)->ptr,\
+ buflen = RSTRING(result)->len,\
pend = p + buflen)
#if !defined(TOLOWER)
#define TOLOWER(c) (ISUPPER(c) ? tolower(c) : (c))
#endif
-static int is_absolute_path(const char*);
+static int is_absolute_path _((const char*));
static VALUE
-file_expand_path(VALUE fname, VALUE dname, VALUE result)
+file_expand_path(fname, dname, result)
+ VALUE fname, dname, result;
{
- char *s, *buf, *b, *p, *pend, *root;
+ const char *s, *b;
+ char *buf, *p, *pend, *root;
long buflen, dirlen;
int tainted;
- FilePathValue(fname);
s = StringValuePtr(fname);
BUFINIT();
tainted = OBJ_TAINTED(fname);
if (s[0] == '~') {
if (isdirsep(s[1]) || s[1] == '\0') {
- char *dir = getenv("HOME");
+ const char *dir = getenv("HOME");
if (!dir) {
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `%s'", s);
@@ -2683,15 +2667,21 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
case '.':
if (*(s+1) == '\0' || isdirsep(*(s+1))) {
/* We must go back to the parent */
+ char *n;
*p = '\0';
- if (!(b = strrdirsep(root))) {
+ if (!(n = strrdirsep(root))) {
*p = '/';
}
else {
- p = b;
+ p = n;
}
b = ++s;
}
+#if USE_NTFS
+ else {
+ do *++s; while (istrailinggabage(*s));
+ }
+#endif
break;
case '/':
#if defined DOSISH || defined __CYGWIN__
@@ -2704,6 +2694,19 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
break;
}
}
+#if USE_NTFS
+ else {
+ --s;
+ case ' ': {
+ const char *e = s;
+ while (istrailinggabage(*s)) s++;
+ if (!*s) {
+ s = e;
+ goto endpath;
+ }
+ }
+ }
+#endif
break;
case '/':
#if defined DOSISH || defined __CYGWIN__
@@ -2726,19 +2729,82 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
}
if (s > b) {
+#if USE_NTFS
+ endpath:
+ if (s > b + 6 && strncasecmp(s - 6, ":$DATA", 6) == 0) {
+ /* alias of stream */
+ /* get rid of a bug of x64 VC++ */
+ if (*(s-7) == ':') s -= 7; /* prime */
+ else if (memchr(b, ':', s - 6 - b)) s -= 6; /* alternative */
+ }
+#endif
BUFCHECK(bdiff + (s-b) >= buflen);
memcpy(++p, b, s-b);
p += s-b;
}
if (p == skiproot(buf) - 1) p++;
+#if USE_NTFS
+ *p = '\0';
+ if ((s = strrdirsep(b = buf)) != 0 && !strpbrk(s, "*?")) {
+ size_t len;
+ WIN32_FIND_DATA wfd;
+#ifdef __CYGWIN__
+ int lnk_added = 0, is_symlink = 0;
+ struct stat st;
+ char w32buf[MAXPATHLEN];
+ p = (char *)s;
+ if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
+ is_symlink = 1;
+ *p = '\0';
+ }
+ if (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
+ b = w32buf;
+ }
+ if (is_symlink && b == w32buf) {
+ *p = '\\';
+ strlcat(w32buf, p, sizeof(w32buf));
+ len = strlen(p);
+ if (len > 4 && strcasecmp(p + len - 4, ".lnk") != 0) {
+ lnk_added = 1;
+ strlcat(w32buf, ".lnk", sizeof(w32buf));
+ }
+ }
+ *p = '/';
+#endif
+ HANDLE h = FindFirstFile(b, &wfd);
+ if (h != INVALID_HANDLE_VALUE) {
+ FindClose(h);
+ len = strlen(wfd.cFileName);
+#ifdef __CYGWIN__
+ if (lnk_added && len > 4 &&
+ strcasecmp(wfd.cFileName + len - 4, ".lnk") == 0) {
+ wfd.cFileName[len -= 4] = '\0';
+ }
+#else
+ p = (char *)s;
+#endif
+ ++p;
+ BUFCHECK(bdiff + len >= buflen);
+ memcpy(p, wfd.cFileName, len + 1);
+ p += len;
+ }
+#ifdef __CYGWIN__
+ else {
+ p += strlen(p);
+ }
+#endif
+ }
+#endif
+
if (tainted) OBJ_TAINT(result);
rb_str_set_len(result, p - buf);
return result;
}
VALUE
-rb_file_expand_path(VALUE fname, VALUE dname)
+rb_file_expand_path(fname, dname)
+ VALUE fname, dname;
{
return file_expand_path(fname, dname, rb_str_new(0, MAXPATHLEN + 2));
}
@@ -2761,7 +2827,9 @@ rb_file_expand_path(VALUE fname, VALUE dname)
*/
VALUE
-rb_file_s_expand_path(int argc, VALUE *argv)
+rb_file_s_expand_path(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE fname, dname;
@@ -2774,22 +2842,31 @@ rb_file_s_expand_path(int argc, VALUE *argv)
}
static int
-rmext(const char *p, const char *e)
+rmext(p, l1, e)
+ const char *p, *e;
+ int l1;
{
- int l1, l2;
+ int l2;
if (!e) return 0;
- l1 = chompdirsep(p) - p;
l2 = strlen(e);
if (l2 == 2 && e[1] == '*') {
- e = strrchr(p, *e);
- if (!e) return 0;
+ unsigned char c = *e;
+ e = p + l1;
+ do {
+ if (e <= p) return 0;
+ } while (*--e != c);
return e - p;
}
if (l1 < l2) return l1;
- if (strncmp(p+l1-l2, e, l2) == 0) {
+#if CASEFOLD_FILESYSTEM
+#define fncomp strncasecmp
+#else
+#define fncomp strncmp
+#endif
+ if (fncomp(p+l1-l2, e, l2) == 0) {
return l1-l2;
}
return 0;
@@ -2810,20 +2887,22 @@ rmext(const char *p, const char *e)
*/
static VALUE
-rb_file_s_basename(int argc, VALUE *argv)
+rb_file_s_basename(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE fname, fext, basename;
- char *name, *p;
+ const char *name, *p;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
- char *root;
+ const char *root;
#endif
- int f;
+ int f, n;
if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
StringValue(fext);
}
- FilePathStringValue(fname);
- if (RSTRING_LEN(fname) == 0 || !*(name = RSTRING_PTR(fname)))
+ StringValue(fname);
+ if (RSTRING(fname)->len == 0 || !*(name = RSTRING(fname)->ptr))
return fname;
name = skipprefix(name);
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
@@ -2851,18 +2930,22 @@ rb_file_s_basename(int argc, VALUE *argv)
#endif
#endif
}
- else if (!(p = strrdirsep(name))) {
- if (NIL_P(fext) || !(f = rmext(name, StringValueCStr(fext)))) {
- f = chompdirsep(name) - name;
- if (f == RSTRING_LEN(fname)) return fname;
- }
- p = name;
- }
else {
- while (isdirsep(*p)) p++; /* skip last / */
- if (NIL_P(fext) || !(f = rmext(p, StringValueCStr(fext)))) {
- f = chompdirsep(p) - p;
+ if (!(p = strrdirsep(name))) {
+ p = name;
+ }
+ else {
+ while (isdirsep(*p)) p++; /* skip last / */
+ }
+#if USE_NTFS
+ n = ntfs_tail(p) - p;
+#else
+ n = chompdirsep(p) - p;
+#endif
+ if (NIL_P(fext) || !(f = rmext(p, n, StringValueCStr(fext)))) {
+ f = n;
}
+ if (f == RSTRING_LEN(fname)) return fname;
}
basename = rb_str_new(p, f);
OBJ_INFECT(basename, fname);
@@ -2882,12 +2965,12 @@ rb_file_s_basename(int argc, VALUE *argv)
*/
static VALUE
-rb_file_s_dirname(VALUE klass, VALUE fname)
+rb_file_s_dirname(klass, fname)
+ VALUE klass, fname;
{
const char *name, *root, *p;
VALUE dirname;
- FilePathStringValue(fname);
name = StringValueCStr(fname);
root = skiproot(name);
#ifdef DOSISH_UNC
@@ -2935,46 +3018,56 @@ rb_file_s_dirname(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_s_extname(VALUE klass, VALUE fname)
+rb_file_s_extname(klass, fname)
+ VALUE klass, fname;
{
- char *name, *p, *e;
+ const char *name, *p, *e;
VALUE extname;
- FilePathStringValue(fname);
name = StringValueCStr(fname);
p = strrdirsep(name); /* get the last path component */
if (!p)
- p = name;
+ p = name;
else
- p++;
-
- e = strrchr(p, '.'); /* get the last dot of the last component */
- if (!e || e == p || !e[1]) /* no dot, or the only dot is first or end? */
- return rb_str_new2("");
- extname = rb_str_new(e, chompdirsep(e) - e); /* keep the dot, too! */
+ name = ++p;
+
+ e = 0;
+ while (*p) {
+ if (*p == '.' || istrailinggabage(*p)) {
+#if USE_NTFS
+ const char *last = p++, *dot = last;
+ while (istrailinggabage(*p)) {
+ if (*p == '.') dot = p;
+ p++;
+ }
+ if (!*p || *p == ':') {
+ p = last;
+ break;
+ }
+ if (*last == '.') e = dot;
+ continue;
+#else
+ e = p; /* get the last dot of the last component */
+#endif
+ }
+#if USE_NTFS
+ else if (*p == ':') {
+ break;
+ }
+#endif
+ else if (isdirsep(*p))
+ break;
+ p = CharNext(p);
+ }
+ if (!e || e == name || e+1 == p) /* no dot, or the only dot is first or end? */
+ return rb_str_new(0, 0);
+ extname = rb_str_new(e, p - e); /* keep the dot, too! */
OBJ_INFECT(extname, fname);
return extname;
}
/*
* call-seq:
- * File.path(path) -> string
- *
- * Returns the string representation of the path
- *
- * File.path("/dev/null") #=> "/dev/null"
- * File.path(Pathname.new("/tmp")) #=> "/tmp"
- *
- */
-
-static VALUE
-rb_file_s_path(VALUE klass, VALUE fname)
-{
- return rb_get_path(fname);
-}
-
-/*
- * call-seq:
* File.split(file_name) => array
*
* Splits the given string into a directory and a file component and
@@ -2985,78 +3078,86 @@ rb_file_s_path(VALUE klass, VALUE fname)
*/
static VALUE
-rb_file_s_split(VALUE klass, VALUE path)
+rb_file_s_split(klass, path)
+ VALUE klass, path;
{
- FilePathStringValue(path); /* get rid of converting twice */
+ StringValue(path); /* get rid of converting twice */
return rb_assoc_new(rb_file_s_dirname(Qnil, path), rb_file_s_basename(1,&path));
}
static VALUE separator;
-static VALUE rb_file_join(VALUE ary, VALUE sep);
+static VALUE rb_file_join _((VALUE ary, VALUE sep));
static VALUE
-file_inspect_join(VALUE ary, VALUE argp, int recur)
+file_inspect_join(ary, arg)
+ VALUE ary;
+ VALUE *arg;
{
- VALUE *arg = (VALUE *)argp;
- if (recur) return rb_str_new2("[...]");
return rb_file_join(arg[0], arg[1]);
}
static VALUE
-rb_file_join(VALUE ary, VALUE sep)
+rb_file_join(ary, sep)
+ VALUE ary, sep;
{
long len, i;
+ int taint = 0;
VALUE result, tmp;
- char *name, *tail;
+ const char *name, *tail;
- if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
+ if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
+ if (OBJ_TAINTED(ary)) taint = 1;
+ if (OBJ_TAINTED(sep)) taint = 1;
len = 1;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- if (TYPE(RARRAY_PTR(ary)[i]) == T_STRING) {
- len += RSTRING_LEN(RARRAY_PTR(ary)[i]);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ if (TYPE(RARRAY(ary)->ptr[i]) == T_STRING) {
+ len += RSTRING(RARRAY(ary)->ptr[i])->len;
}
else {
len += 10;
}
}
- if (!NIL_P(sep)) {
- StringValue(sep);
- len += RSTRING_LEN(sep) * RARRAY_LEN(ary) - 1;
+ if (!NIL_P(sep) && TYPE(sep) == T_STRING) {
+ len += RSTRING(sep)->len * RARRAY(ary)->len - 1;
}
result = rb_str_buf_new(len);
- OBJ_INFECT(result, ary);
- for (i=0; i<RARRAY_LEN(ary); i++) {
- tmp = RARRAY_PTR(ary)[i];
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ tmp = RARRAY(ary)->ptr[i];
switch (TYPE(tmp)) {
case T_STRING:
break;
case T_ARRAY:
- {
+ if (rb_inspecting_p(tmp)) {
+ tmp = rb_str_new2("[...]");
+ }
+ else {
VALUE args[2];
args[0] = tmp;
args[1] = sep;
- tmp = rb_exec_recursive(file_inspect_join, ary, (VALUE)args);
+ tmp = rb_protect_inspect(file_inspect_join, ary, (VALUE)args);
}
break;
default:
- FilePathStringValue(tmp);
+ StringValueCStr(tmp);
}
name = StringValueCStr(result);
if (i > 0 && !NIL_P(sep)) {
tail = chompdirsep(name);
- if (RSTRING_PTR(tmp) && isdirsep(RSTRING_PTR(tmp)[0])) {
- rb_str_set_len(result, tail - name);
+ if (RSTRING(tmp)->ptr && isdirsep(RSTRING(tmp)->ptr[0])) {
+ RSTRING(result)->len = tail - name;
}
else if (!*tail) {
rb_str_buf_append(result, sep);
}
}
rb_str_buf_append(result, tmp);
+ if (OBJ_TAINTED(tmp)) taint = 1;
}
+ if (taint) OBJ_TAINT(result);
return result;
}
@@ -3072,7 +3173,8 @@ rb_file_join(VALUE ary, VALUE sep)
*/
static VALUE
-rb_file_s_join(VALUE klass, VALUE args)
+rb_file_s_join(klass, args)
+ VALUE klass, args;
{
return rb_file_join(args, separator);
}
@@ -3093,16 +3195,18 @@ rb_file_s_join(VALUE klass, VALUE args)
*/
static VALUE
-rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
+rb_file_s_truncate(klass, path, len)
+ VALUE klass, path, len;
{
off_t pos;
rb_secure(2);
pos = NUM2OFFT(len);
- FilePathValue(path);
+ SafeStringValue(path);
+
#ifdef HAVE_TRUNCATE
if (truncate(StringValueCStr(path), pos) < 0)
- rb_sys_fail(RSTRING_PTR(path));
+ rb_sys_fail(RSTRING(path)->ptr);
#else
# ifdef HAVE_CHSIZE
{
@@ -3110,16 +3214,16 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
# ifdef _WIN32
if ((tmpfd = open(StringValueCStr(path), O_RDWR)) < 0) {
- rb_sys_fail(RSTRING_PTR(path));
+ rb_sys_fail(RSTRING(path)->ptr);
}
# else
if ((tmpfd = open(StringValueCStr(path), 0)) < 0) {
- rb_sys_fail(RSTRING_PTR(path));
+ rb_sys_fail(RSTRING(path)->ptr);
}
# endif
if (chsize(tmpfd, pos) < 0) {
close(tmpfd);
- rb_sys_fail(RSTRING_PTR(path));
+ rb_sys_fail(RSTRING(path)->ptr);
}
close(tmpfd);
}
@@ -3145,9 +3249,11 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
*/
static VALUE
-rb_file_truncate(VALUE obj, VALUE len)
+rb_file_truncate(obj, len)
+ VALUE obj, len;
{
rb_io_t *fptr;
+ FILE *f;
off_t pos;
rb_secure(2);
@@ -3156,13 +3262,15 @@ rb_file_truncate(VALUE obj, VALUE len)
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
}
- rb_io_flush(obj);
-#ifdef HAVE_TRUNCATE
- if (ftruncate(fptr->fd, pos) < 0)
+ f = GetWriteFile(fptr);
+ fflush(f);
+ fseeko(f, (off_t)0, SEEK_CUR);
+#ifdef HAVE_FTRUNCATE
+ if (ftruncate(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
#else
# ifdef HAVE_CHSIZE
- if (chsize(fptr->fd, pos) < 0)
+ if (chsize(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
# else
rb_notimplement();
@@ -3187,24 +3295,54 @@ rb_file_truncate(VALUE obj, VALUE len)
#ifdef __CYGWIN__
#include <winerror.h>
extern unsigned long __attribute__((stdcall)) GetLastError(void);
-#endif
-static VALUE
-rb_thread_flock(void *data)
+static int
+cygwin_flock(int fd, int op)
{
-#ifdef __CYGWIN__
int old_errno = errno;
-#endif
- int *op = data, ret = flock(op[0], op[1]);
-
-#ifdef __CYGWIN__
+ int ret = flock(fd, op);
if (GetLastError() == ERROR_NOT_LOCKED) {
ret = 0;
errno = old_errno;
}
+ return ret;
+}
+# define flock(fd, op) cygwin_flock(fd, op)
+#endif
+
+static int
+rb_thread_flock(fd, op, fptr)
+ int fd, op;
+ rb_io_t *fptr;
+{
+ if (rb_thread_alone() || (op & LOCK_NB)) {
+ int ret;
+ TRAP_BEG;
+ ret = flock(fd, op);
+ TRAP_END;
+ return ret;
+ }
+ op |= LOCK_NB;
+ while (flock(fd, op) < 0) {
+ switch (errno) {
+ case EAGAIN:
+ case EACCES:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
#endif
- return (VALUE)ret;
+ rb_thread_polling(); /* busy wait */
+ rb_io_check_closed(fptr);
+ continue;
+ default:
+ return -1;
+ }
+ }
+ return 0;
}
+#ifdef __CYGWIN__
+# undef flock
+#endif
+#define flock(fd, op) rb_thread_flock(fd, op, fptr)
/*
* call-seq:
@@ -3236,40 +3374,37 @@ rb_thread_flock(void *data)
*/
static VALUE
-rb_file_flock(VALUE obj, VALUE operation)
+rb_file_flock(obj, operation)
+ VALUE obj;
+ VALUE operation;
{
#ifndef __CHECKER__
rb_io_t *fptr;
- int op[2];
+ int op;
rb_secure(2);
- op[1] = NUM2INT(operation);
+ op = NUM2INT(operation);
GetOpenFile(obj, fptr);
- op[0] = fptr->fd;
if (fptr->mode & FMODE_WRITABLE) {
- rb_io_flush(obj);
+ fflush(GetWriteFile(fptr));
}
- while ((int)rb_thread_blocking_region(rb_thread_flock, op, RB_UBF_DFL, 0) < 0) {
+ retry:
+ if (flock(fileno(fptr->f), op) < 0) {
switch (errno) {
case EAGAIN:
case EACCES:
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- rb_thread_polling();
- rb_io_check_closed(fptr);
- continue;
-
+ return Qfalse;
case EINTR:
#if defined(ERESTART)
case ERESTART:
#endif
- break;
-
- default:
- rb_sys_fail(fptr->path);
+ goto retry;
}
+ rb_sys_fail(fptr->path);
}
#endif
return INT2FIX(0);
@@ -3277,18 +3412,19 @@ rb_file_flock(VALUE obj, VALUE operation)
#undef flock
static void
-test_check(int n, int argc, VALUE *argv)
+test_check(n, argc, argv)
+ int n, argc;
+ VALUE *argv;
{
int i;
- rb_secure(2);
n+=1;
if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, n);
for (i=1; i<n; i++) {
switch (TYPE(argv[i])) {
case T_STRING:
default:
- FilePathValue(argv[i]);
+ SafeStringValue(argv[i]);
break;
case T_FILE:
break;
@@ -3358,82 +3494,89 @@ test_check(int n, int argc, VALUE *argv)
*/
static VALUE
-rb_f_test(int argc, VALUE *argv)
+rb_f_test(argc, argv)
+ int argc;
+ VALUE *argv;
{
int cmd;
if (argc == 0) rb_raise(rb_eArgError, "wrong number of arguments");
+#if 0 /* 1.7 behavior? */
+ if (argc == 1) {
+ return RTEST(argv[0]) ? Qtrue : Qfalse;
+ }
+#endif
cmd = NUM2CHR(argv[0]);
- if (cmd == 0) goto unknown;
+ if (cmd == 0) return Qfalse;
if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) {
CHECK(1);
switch (cmd) {
case 'b':
- return rb_file_blockdev_p(0, argv[1]);
+ return test_b(0, argv[1]);
case 'c':
- return rb_file_chardev_p(0, argv[1]);
+ return test_c(0, argv[1]);
case 'd':
- return rb_file_directory_p(0, argv[1]);
+ return test_d(0, argv[1]);
case 'a':
case 'e':
- return rb_file_exist_p(0, argv[1]);
+ return test_e(0, argv[1]);
case 'f':
- return rb_file_file_p(0, argv[1]);
+ return test_f(0, argv[1]);
case 'g':
- return rb_file_sgid_p(0, argv[1]);
+ return test_sgid(0, argv[1]);
case 'G':
- return rb_file_grpowned_p(0, argv[1]);
+ return test_grpowned(0, argv[1]);
case 'k':
- return rb_file_sticky_p(0, argv[1]);
+ return test_sticky(0, argv[1]);
case 'l':
- return rb_file_symlink_p(0, argv[1]);
+ return test_l(0, argv[1]);
case 'o':
- return rb_file_owned_p(0, argv[1]);
+ return test_owned(0, argv[1]);
case 'O':
- return rb_file_rowned_p(0, argv[1]);
+ return test_rowned(0, argv[1]);
case 'p':
- return rb_file_pipe_p(0, argv[1]);
+ return test_p(0, argv[1]);
case 'r':
- return rb_file_readable_p(0, argv[1]);
+ return test_r(0, argv[1]);
case 'R':
- return rb_file_readable_real_p(0, argv[1]);
+ return test_R(0, argv[1]);
case 's':
- return rb_file_size_p(0, argv[1]);
+ return test_s(0, argv[1]);
case 'S':
- return rb_file_socket_p(0, argv[1]);
+ return test_S(0, argv[1]);
case 'u':
- return rb_file_suid_p(0, argv[1]);
+ return test_suid(0, argv[1]);
case 'w':
- return rb_file_writable_p(0, argv[1]);
+ return test_w(0, argv[1]);
case 'W':
- return rb_file_world_writable_p(0, argv[1]);
+ return test_W(0, argv[1]);
case 'x':
- return rb_file_executable_p(0, argv[1]);
+ return test_x(0, argv[1]);
case 'X':
- return rb_file_executable_real_p(0, argv[1]);
+ return test_X(0, argv[1]);
case 'z':
- return rb_file_zero_p(0, argv[1]);
+ return test_z(0, argv[1]);
}
}
@@ -3442,22 +3585,22 @@ rb_f_test(int argc, VALUE *argv)
CHECK(1);
if (rb_stat(argv[1], &st) == -1) {
- rb_sys_fail(RSTRING_PTR(argv[1]));
+ rb_sys_fail(RSTRING(argv[1])->ptr);
}
switch (cmd) {
case 'A':
- return stat_atime(&st);
+ return rb_time_new(st.st_atime, 0);
case 'M':
- return stat_mtime(&st);
+ return rb_time_new(st.st_mtime, 0);
case 'C':
- return stat_ctime(&st);
+ return rb_time_new(st.st_ctime, 0);
}
}
if (cmd == '-') {
CHECK(2);
- return rb_file_identical_p(0, argv[1], argv[2]);
+ return test_identical(0, argv[1], argv[2]);
}
if (strchr("=<>", cmd)) {
@@ -3481,14 +3624,8 @@ rb_f_test(int argc, VALUE *argv)
return Qfalse;
}
}
- unknown:
/* unknown command */
- if (ISPRINT(cmd)) {
- rb_raise(rb_eArgError, "unknown command ?%c", cmd);
- }
- else {
- rb_raise(rb_eArgError, "unknown command ?\\x%02X", cmd);
- }
+ rb_raise(rb_eArgError, "unknown command ?%c", cmd);
return Qnil; /* not reached */
}
@@ -3508,8 +3645,10 @@ rb_f_test(int argc, VALUE *argv)
* meaningful on all systems. See also <code>Kernel#test</code>.
*/
+static VALUE rb_stat_s_alloc _((VALUE));
static VALUE
-rb_stat_s_alloc(VALUE klass)
+rb_stat_s_alloc(klass)
+ VALUE klass;
{
return stat_new_0(klass, 0);
}
@@ -3524,14 +3663,15 @@ rb_stat_s_alloc(VALUE klass)
*/
static VALUE
-rb_stat_init(VALUE obj, VALUE fname)
+rb_stat_init(obj, fname)
+ VALUE obj, fname;
{
struct stat st, *nst;
- rb_secure(2);
- FilePathValue(fname);
+ SafeStringValue(fname);
+
if (stat(StringValueCStr(fname), &st) == -1) {
- rb_sys_fail(RSTRING_PTR(fname));
+ rb_sys_fail(RSTRING(fname)->ptr);
}
if (DATA_PTR(obj)) {
free(DATA_PTR(obj));
@@ -3546,7 +3686,8 @@ rb_stat_init(VALUE obj, VALUE fname)
/* :nodoc: */
static VALUE
-rb_stat_init_copy(VALUE copy, VALUE orig)
+rb_stat_init_copy(copy, orig)
+ VALUE copy, orig;
{
struct stat *nst;
@@ -3584,7 +3725,8 @@ rb_stat_init_copy(VALUE copy, VALUE orig)
*/
static VALUE
-rb_stat_ftype(VALUE obj)
+rb_stat_ftype(obj)
+ VALUE obj;
{
return rb_file_ftype(get_stat(obj));
}
@@ -3601,7 +3743,8 @@ rb_stat_ftype(VALUE obj)
*/
static VALUE
-rb_stat_d(VALUE obj)
+rb_stat_d(obj)
+ VALUE obj;
{
if (S_ISDIR(get_stat(obj)->st_mode)) return Qtrue;
return Qfalse;
@@ -3616,7 +3759,8 @@ rb_stat_d(VALUE obj)
*/
static VALUE
-rb_stat_p(VALUE obj)
+rb_stat_p(obj)
+ VALUE obj;
{
#ifdef S_IFIFO
if (S_ISFIFO(get_stat(obj)->st_mode)) return Qtrue;
@@ -3643,7 +3787,8 @@ rb_stat_p(VALUE obj)
*/
static VALUE
-rb_stat_l(VALUE obj)
+rb_stat_l(obj)
+ VALUE obj;
{
#ifdef S_ISLNK
if (S_ISLNK(get_stat(obj)->st_mode)) return Qtrue;
@@ -3664,7 +3809,8 @@ rb_stat_l(VALUE obj)
*/
static VALUE
-rb_stat_S(VALUE obj)
+rb_stat_S(obj)
+ VALUE obj;
{
#ifdef S_ISSOCK
if (S_ISSOCK(get_stat(obj)->st_mode)) return Qtrue;
@@ -3687,7 +3833,8 @@ rb_stat_S(VALUE obj)
*/
static VALUE
-rb_stat_b(VALUE obj)
+rb_stat_b(obj)
+ VALUE obj;
{
#ifdef S_ISBLK
if (S_ISBLK(get_stat(obj)->st_mode)) return Qtrue;
@@ -3709,7 +3856,8 @@ rb_stat_b(VALUE obj)
*/
static VALUE
-rb_stat_c(VALUE obj)
+rb_stat_c(obj)
+ VALUE obj;
{
if (S_ISCHR(get_stat(obj)->st_mode)) return Qtrue;
@@ -3729,14 +3877,16 @@ rb_stat_c(VALUE obj)
*/
static VALUE
-rb_stat_owned(VALUE obj)
+rb_stat_owned(obj)
+ VALUE obj;
{
if (get_stat(obj)->st_uid == geteuid()) return Qtrue;
return Qfalse;
}
static VALUE
-rb_stat_rowned(VALUE obj)
+rb_stat_rowned(obj)
+ VALUE obj;
{
if (get_stat(obj)->st_uid == getuid()) return Qtrue;
return Qfalse;
@@ -3755,7 +3905,8 @@ rb_stat_rowned(VALUE obj)
*/
static VALUE
-rb_stat_grpowned(VALUE obj)
+rb_stat_grpowned(obj)
+ VALUE obj;
{
#ifndef _WIN32
if (group_member(get_stat(obj)->st_gid)) return Qtrue;
@@ -3775,7 +3926,8 @@ rb_stat_grpowned(VALUE obj)
*/
static VALUE
-rb_stat_r(VALUE obj)
+rb_stat_r(obj)
+ VALUE obj;
{
struct stat *st = get_stat(obj);
@@ -3810,7 +3962,8 @@ rb_stat_r(VALUE obj)
*/
static VALUE
-rb_stat_R(VALUE obj)
+rb_stat_R(obj)
+ VALUE obj;
{
struct stat *st = get_stat(obj);
@@ -3832,32 +3985,6 @@ rb_stat_R(VALUE obj)
}
/*
- * call-seq:
- * stat.world_readable? => fixnum or nil
- *
- * If <i>stat</i> is readable by others, returns an integer
- * representing the file permission bits of <i>stat</i>. Returns
- * <code>nil</code> otherwise. The meaning of the bits is platform
- * dependent; on Unix systems, see <code>stat(2)</code>.
- *
- * m = File.stat("/etc/passwd").world_readable? # => 420
- * sprintf("%o", m) # => "644"
- */
-
-static VALUE
-rb_stat_wr(VALUE obj)
-{
-#ifdef S_IROTH
- if ((get_stat(obj)->st_mode & (S_IROTH)) == S_IROTH) {
- return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
- }
- else {
- return Qnil;
- }
-#endif
-}
-
-/*
* call-seq:
* stat.writable? -> true or false
*
@@ -3869,7 +3996,8 @@ rb_stat_wr(VALUE obj)
*/
static VALUE
-rb_stat_w(VALUE obj)
+rb_stat_w(obj)
+ VALUE obj;
{
struct stat *st = get_stat(obj);
@@ -3902,7 +4030,8 @@ rb_stat_w(VALUE obj)
*/
static VALUE
-rb_stat_W(VALUE obj)
+rb_stat_W(obj)
+ VALUE obj;
{
struct stat *st = get_stat(obj);
@@ -3924,32 +4053,6 @@ rb_stat_W(VALUE obj)
}
/*
- * call-seq:
- * stat.world_writable? => fixnum or nil
- *
- * If <i>stat</i> is writable by others, returns an integer
- * representing the file permission bits of <i>stat</i>. Returns
- * <code>nil</code> otherwise. The meaning of the bits is platform
- * dependent; on Unix systems, see <code>stat(2)</code>.
- *
- * m = File.stat("/tmp").world_writable? # => 511
- * sprintf("%o", m) # => "777"
- */
-
-static VALUE
-rb_stat_ww(VALUE obj)
-{
-#ifdef S_IROTH
- if ((get_stat(obj)->st_mode & (S_IWOTH)) == S_IWOTH) {
- return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
- }
- else {
- return Qnil;
- }
-#endif
-}
-
-/*
* call-seq:
* stat.executable? => true or false
*
@@ -3963,7 +4066,8 @@ rb_stat_ww(VALUE obj)
*/
static VALUE
-rb_stat_x(VALUE obj)
+rb_stat_x(obj)
+ VALUE obj;
{
struct stat *st = get_stat(obj);
@@ -3996,7 +4100,8 @@ rb_stat_x(VALUE obj)
static VALUE
-rb_stat_X(VALUE obj)
+rb_stat_X(obj)
+ VALUE obj;
{
struct stat *st = get_stat(obj);
@@ -4031,7 +4136,8 @@ rb_stat_X(VALUE obj)
*/
static VALUE
-rb_stat_f(VALUE obj)
+rb_stat_f(obj)
+ VALUE obj;
{
if (S_ISREG(get_stat(obj)->st_mode)) return Qtrue;
return Qfalse;
@@ -4049,7 +4155,8 @@ rb_stat_f(VALUE obj)
*/
static VALUE
-rb_stat_z(VALUE obj)
+rb_stat_z(obj)
+ VALUE obj;
{
if (get_stat(obj)->st_size == 0) return Qtrue;
return Qfalse;
@@ -4067,7 +4174,8 @@ rb_stat_z(VALUE obj)
*/
static VALUE
-rb_stat_s(VALUE obj)
+rb_stat_s(obj)
+ VALUE obj;
{
off_t size = get_stat(obj)->st_size;
@@ -4087,7 +4195,8 @@ rb_stat_s(VALUE obj)
*/
static VALUE
-rb_stat_suid(VALUE obj)
+rb_stat_suid(obj)
+ VALUE obj;
{
#ifdef S_ISUID
if (get_stat(obj)->st_mode & S_ISUID) return Qtrue;
@@ -4108,7 +4217,8 @@ rb_stat_suid(VALUE obj)
*/
static VALUE
-rb_stat_sgid(VALUE obj)
+rb_stat_sgid(obj)
+ VALUE obj;
{
#ifdef S_ISGID
if (get_stat(obj)->st_mode & S_ISGID) return Qtrue;
@@ -4129,7 +4239,8 @@ rb_stat_sgid(VALUE obj)
*/
static VALUE
-rb_stat_sticky(VALUE obj)
+rb_stat_sticky(obj)
+ VALUE obj;
{
#ifdef S_ISVTX
if (get_stat(obj)->st_mode & S_ISVTX) return Qtrue;
@@ -4140,13 +4251,16 @@ rb_stat_sticky(VALUE obj)
VALUE rb_mFConst;
void
-rb_file_const(const char *name, VALUE value)
+rb_file_const(name, value)
+ const char *name;
+ VALUE value;
{
rb_define_const(rb_mFConst, name, value);
}
static int
-is_absolute_path(const char *path)
+is_absolute_path(path)
+ const char *path;
{
#ifdef DOSISH_DRIVE_LETTER
if (has_drive_letter(path) && isdirsep(path[2])) return 1;
@@ -4170,10 +4284,12 @@ is_absolute_path(const char *path)
#if ENABLE_PATH_CHECK
static int
-path_check_0(VALUE path, int execpath)
+path_check_0(fpath, execpath)
+ VALUE fpath;
+ int execpath;
{
struct stat st;
- char *p0 = StringValueCStr(path);
+ const char *p0 = StringValueCStr(fpath);
char *p = 0, *s;
if (!is_absolute_path(p0)) {
@@ -4185,7 +4301,7 @@ path_check_0(VALUE path, int execpath)
rb_str_cat2(newpath, "/");
rb_str_cat2(newpath, p0);
- p0 = RSTRING_PTR(path = newpath);
+ p0 = RSTRING(fpath = newpath)->ptr;
}
for (;;) {
#ifndef S_IWOTH
@@ -4195,7 +4311,7 @@ path_check_0(VALUE path, int execpath)
#ifdef S_ISVTX
&& !(p && execpath && (st.st_mode & S_ISVTX))
#endif
- && !access(p0, W_OK)) {
+ ) {
rb_warn("Insecure world writable dir %s in %sPATH, mode 0%o",
p0, (execpath ? "" : "LOAD_"), st.st_mode);
if (p) *p = '/';
@@ -4211,7 +4327,8 @@ path_check_0(VALUE path, int execpath)
#endif
static int
-fpath_check(const char *path)
+fpath_check(path)
+ const char *path;
{
#if ENABLE_PATH_CHECK
return path_check_0(rb_str_new2(path), Qfalse);
@@ -4221,7 +4338,8 @@ fpath_check(const char *path)
}
int
-rb_path_check(const char *path)
+rb_path_check(path)
+ const char *path;
{
#if ENABLE_PATH_CHECK
const char *p0, *p, *pend;
@@ -4249,7 +4367,8 @@ rb_path_check(const char *path)
#if defined(__MACOS__) || defined(riscos)
static int
-is_macos_native_path(const char *path)
+is_macos_native_path(path)
+ const char *path;
{
if (strchr(path, ':')) return 1;
return 0;
@@ -4257,18 +4376,27 @@ is_macos_native_path(const char *path)
#endif
static int
-file_load_ok(const char *path)
+file_load_ok(file)
+ const char *file;
{
- return eaccess(path, R_OK) == 0;
+ FILE *f;
+
+ if (!file) return 0;
+ f = fopen(file, "r");
+ if (f == NULL) return 0;
+ fclose(f);
+ return 1;
}
extern VALUE rb_load_path;
int
-rb_find_file_ext(VALUE *filep, const char *const *ext)
+rb_find_file_ext(filep, ext)
+ VALUE *filep;
+ const char * const *ext;
{
- char *path, *found;
- char *f = RSTRING_PTR(*filep);
+ const char *path, *found;
+ const char *f = RSTRING(*filep)->ptr;
VALUE fname;
long i, j;
@@ -4298,19 +4426,19 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
if (!rb_load_path) return 0;
Check_Type(rb_load_path, T_ARRAY);
- for (j=0; ext[j]; j++) {
- fname = rb_str_dup(*filep);
- rb_str_cat2(fname, ext[j]);
- OBJ_FREEZE(fname);
- for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
- VALUE str = RARRAY_PTR(rb_load_path)[i];
+ for (i=0;i<RARRAY(rb_load_path)->len;i++) {
+ VALUE str = RARRAY(rb_load_path)->ptr[i];
- FilePathValue(str);
- if (RSTRING_LEN(str) == 0) continue;
- path = RSTRING_PTR(str);
+ SafeStringValue(str);
+ if (RSTRING(str)->len == 0) continue;
+ path = RSTRING(str)->ptr;
+ for (j=0; ext[j]; j++) {
+ fname = rb_str_dup(*filep);
+ rb_str_cat2(fname, ext[j]);
+ OBJ_FREEZE(fname);
found = dln_find_file(StringValueCStr(fname), path);
if (found && file_load_ok(found)) {
- *filep = rb_str_new2(found);
+ *filep = fname;
return j+1;
}
}
@@ -4319,11 +4447,12 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
}
VALUE
-rb_find_file(VALUE path)
+rb_find_file(path)
+ VALUE path;
{
VALUE tmp;
- char *f = StringValueCStr(path);
- char *lpath;
+ const char *f = StringValueCStr(path);
+ const char *lpath;
if (f[0] == '~') {
path = rb_file_expand_path(path, Qnil);
@@ -4359,19 +4488,19 @@ rb_find_file(VALUE path)
Check_Type(rb_load_path, T_ARRAY);
tmp = rb_ary_new();
- for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
- VALUE str = RARRAY_PTR(rb_load_path)[i];
- FilePathValue(str);
- if (RSTRING_LEN(str) > 0) {
+ for (i=0;i<RARRAY(rb_load_path)->len;i++) {
+ VALUE str = RARRAY(rb_load_path)->ptr[i];
+ SafeStringValue(str);
+ if (RSTRING(str)->len > 0) {
rb_ary_push(tmp, str);
}
}
tmp = rb_ary_join(tmp, rb_str_new2(PATH_SEP));
- if (RSTRING_LEN(tmp) == 0) {
+ if (RSTRING(tmp)->len == 0) {
lpath = 0;
}
else {
- lpath = RSTRING_PTR(tmp);
+ lpath = RSTRING(tmp)->ptr;
}
}
else {
@@ -4396,7 +4525,10 @@ rb_find_file(VALUE path)
}
static void
-define_filetest_function(const char *name, VALUE (*func)(ANYARGS), int argc)
+define_filetest_function(name, func, argc)
+ const char *name;
+ VALUE (*func)();
+ int argc;
{
rb_define_module_function(rb_mFileTest, name, func, argc);
rb_define_singleton_method(rb_cFile, name, func, argc);
@@ -4436,41 +4568,39 @@ define_filetest_function(const char *name, VALUE (*func)(ANYARGS), int argc)
*/
void
-Init_File(void)
+Init_File()
{
rb_mFileTest = rb_define_module("FileTest");
rb_cFile = rb_define_class("File", rb_cIO);
- define_filetest_function("directory?", rb_file_directory_p, 1);
- define_filetest_function("exist?", rb_file_exist_p, 1);
- define_filetest_function("exists?", rb_file_exist_p, 1);
- define_filetest_function("readable?", rb_file_readable_p, 1);
- define_filetest_function("readable_real?", rb_file_readable_real_p, 1);
- define_filetest_function("world_readable?", rb_file_world_readable_p, 1);
- define_filetest_function("writable?", rb_file_writable_p, 1);
- define_filetest_function("writable_real?", rb_file_writable_real_p, 1);
- define_filetest_function("world_writable?", rb_file_world_writable_p, 1);
- define_filetest_function("executable?", rb_file_executable_p, 1);
- define_filetest_function("executable_real?", rb_file_executable_real_p, 1);
- define_filetest_function("file?", rb_file_file_p, 1);
- define_filetest_function("zero?", rb_file_zero_p, 1);
- define_filetest_function("size?", rb_file_size_p, 1);
+ define_filetest_function("directory?", test_d, 1);
+ define_filetest_function("exist?", test_e, 1);
+ define_filetest_function("exists?", test_e, 1); /* temporary */
+ define_filetest_function("readable?", test_r, 1);
+ define_filetest_function("readable_real?", test_R, 1);
+ define_filetest_function("writable?", test_w, 1);
+ define_filetest_function("writable_real?", test_W, 1);
+ define_filetest_function("executable?", test_x, 1);
+ define_filetest_function("executable_real?", test_X, 1);
+ define_filetest_function("file?", test_f, 1);
+ define_filetest_function("zero?", test_z, 1);
+ define_filetest_function("size?", test_s, 1);
define_filetest_function("size", rb_file_s_size, 1);
- define_filetest_function("owned?", rb_file_owned_p, 1);
- define_filetest_function("grpowned?", rb_file_grpowned_p, 1);
+ define_filetest_function("owned?", test_owned, 1);
+ define_filetest_function("grpowned?", test_grpowned, 1);
- define_filetest_function("pipe?", rb_file_pipe_p, 1);
- define_filetest_function("symlink?", rb_file_symlink_p, 1);
- define_filetest_function("socket?", rb_file_socket_p, 1);
+ define_filetest_function("pipe?", test_p, 1);
+ define_filetest_function("symlink?", test_l, 1);
+ define_filetest_function("socket?", test_S, 1);
- define_filetest_function("blockdev?", rb_file_blockdev_p, 1);
- define_filetest_function("chardev?", rb_file_chardev_p, 1);
+ define_filetest_function("blockdev?", test_b, 1);
+ define_filetest_function("chardev?", test_c, 1);
- define_filetest_function("setuid?", rb_file_suid_p, 1);
- define_filetest_function("setgid?", rb_file_sgid_p, 1);
- define_filetest_function("sticky?", rb_file_sticky_p, 1);
+ define_filetest_function("setuid?", test_suid, 1);
+ define_filetest_function("setgid?", test_sgid, 1);
+ define_filetest_function("sticky?", test_sticky, 1);
- define_filetest_function("identical?", rb_file_identical_p, 2);
+ define_filetest_function("identical?", test_identical, 2);
rb_define_singleton_method(rb_cFile, "stat", rb_file_s_stat, 1);
rb_define_singleton_method(rb_cFile, "lstat", rb_file_s_lstat, 1);
@@ -4499,7 +4629,6 @@ Init_File(void)
rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1);
rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 1);
rb_define_singleton_method(rb_cFile, "extname", rb_file_s_extname, 1);
- rb_define_singleton_method(rb_cFile, "path", rb_file_s_path, 1);
separator = rb_obj_freeze(rb_str_new2("/"));
rb_define_const(rb_cFile, "Separator", separator);
@@ -4535,7 +4664,6 @@ Init_File(void)
rb_file_const("LOCK_NB", INT2FIX(LOCK_NB));
rb_define_method(rb_cFile, "path", rb_file_path, 0);
- rb_define_method(rb_cFile, "to_path", rb_file_path, 0);
rb_define_global_function("test", rb_f_test, -1);
rb_cStat = rb_define_class_under(rb_cFile, "Stat", rb_cObject);
@@ -4572,10 +4700,8 @@ Init_File(void)
rb_define_method(rb_cStat, "directory?", rb_stat_d, 0);
rb_define_method(rb_cStat, "readable?", rb_stat_r, 0);
rb_define_method(rb_cStat, "readable_real?", rb_stat_R, 0);
- rb_define_method(rb_cStat, "world_readable?", rb_stat_wr, 0);
rb_define_method(rb_cStat, "writable?", rb_stat_w, 0);
rb_define_method(rb_cStat, "writable_real?", rb_stat_W, 0);
- rb_define_method(rb_cStat, "world_writable?", rb_stat_ww, 0);
rb_define_method(rb_cStat, "executable?", rb_stat_x, 0);
rb_define_method(rb_cStat, "executable_real?", rb_stat_X, 0);
rb_define_method(rb_cStat, "file?", rb_stat_f, 0);
diff --git a/gc.c b/gc.c
index 3a71af2926..b41df745a5 100644
--- a/gc.c
+++ b/gc.c
@@ -6,20 +6,18 @@
$Date$
created at: Tue Oct 5 09:44:46 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/signal.h"
-#include "ruby/st.h"
-#include "ruby/node.h"
-#include "ruby/re.h"
-#include "ruby/io.h"
-#include "vm_core.h"
-#include "gc.h"
+#include "ruby.h"
+#include "rubysig.h"
+#include "st.h"
+#include "node.h"
+#include "env.h"
+#include "re.h"
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>
@@ -36,23 +34,13 @@
#include <windows.h>
#endif
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-# include <valgrind/memcheck.h>
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE(p, n)
-# endif
-# ifndef VALGRIND_MAKE_MEM_UNDEFINED
-# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE(p, n)
-# endif
-#else
-# define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */
-# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) /* empty */
-#endif
+void re_free_registers _((struct re_registers*));
+void rb_io_fptr_finalize _((struct rb_io_t*));
-int rb_io_fptr_finalize(struct rb_io_t*);
-
-#if !defined(setjmp) && defined(HAVE__SETJMP)
-#define setjmp(env) _setjmp(env)
+#define rb_setjmp(env) RUBY_SETJMP(env)
+#define rb_jmp_buf rb_jmpbuf_t
+#ifdef __CYGWIN__
+int _setjmp(), _longjmp();
#endif
/* Make alloca work the best possible way. */
@@ -66,9 +54,7 @@ int rb_io_fptr_finalize(struct rb_io_t*);
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# else
-# ifdef _AIX
- #pragma alloca
-# else
+# ifndef _AIX
# ifndef alloca /* predefined by HP cc +Olibcalls */
void *alloca ();
# endif
@@ -86,116 +72,28 @@ void *alloca ();
static unsigned long malloc_increase = 0;
static unsigned long malloc_limit = GC_MALLOC_LIMIT;
+static void run_final();
static VALUE nomem_error;
-
-static int dont_gc;
-static int during_gc;
-static int need_call_final = 0;
-static st_table *finalizer_table = 0;
-
-#define MARK_STACK_MAX 1024
-static VALUE mark_stack[MARK_STACK_MAX];
-static VALUE *mark_stack_ptr;
-static int mark_stack_overflow;
-
-int ruby_gc_debug_indent = 0;
-
-#undef GC_DEBUG
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
-#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
-#endif
-
-typedef struct RVALUE {
- union {
- struct {
- VALUE flags; /* always 0 for freed obj */
- struct RVALUE *next;
- } free;
- struct RBasic basic;
- struct RObject object;
- struct RClass klass;
- struct RFloat flonum;
- struct RString string;
- struct RArray array;
- struct RRegexp regexp;
- struct RHash hash;
- struct RData data;
- struct RStruct rstruct;
- struct RBignum bignum;
- struct RFile file;
- struct RNode node;
- struct RMatch match;
- } as;
-#ifdef GC_DEBUG
- char *file;
- int line;
-#endif
-} RVALUE;
-
-#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
-#pragma pack(pop)
-#endif
-
-static RVALUE *freelist = 0;
-static RVALUE *deferred_final_list = 0;
-
-#define HEAPS_INCREMENT 10
-static struct heaps_slot {
- void *membase;
- RVALUE *slot;
- int limit;
-} *heaps;
-static int heaps_length = 0;
-static int heaps_used = 0;
-
-#define HEAP_MIN_SLOTS 10000
-static int heap_slots = HEAP_MIN_SLOTS;
-
-#define FREE_MIN 4096
-
-static RVALUE *himem, *lomem;
-
-extern st_table *rb_class_tbl;
-VALUE *rb_gc_stack_start = 0;
-#ifdef __ia64
-VALUE *rb_gc_register_stack_start = 0;
-#endif
+static void garbage_collect();
int ruby_gc_stress = 0;
-
-#ifdef DJGPP
-/* set stack size (http://www.delorie.com/djgpp/v2faq/faq15_9.html) */
-unsigned int _stklen = 0x180000; /* 1.5 kB */
-#endif
-
-#if defined(DJGPP) || defined(_WIN32_WCE)
-size_t rb_gc_stack_maxsize = 65535*sizeof(VALUE);
-#else
-size_t rb_gc_stack_maxsize = 655300*sizeof(VALUE);
-#endif
-
-
-
-static void run_final(VALUE obj);
-static int garbage_collect(void);
+NORETURN(void rb_exc_jump _((VALUE)));
void
-rb_global_variable(VALUE *var)
+rb_memerror()
{
- rb_gc_register_address(var);
-}
+ rb_thread_t th = rb_curr_thread;
-void
-rb_memerror(void)
-{
- static int recurse = 0;
- if (!nomem_error || (recurse > 0 && rb_safe_level() < 4)) {
+ if (!nomem_error ||
+ (rb_thread_raised_p(th, RAISED_NOMEMORY) && rb_safe_level() < 4)) {
fprintf(stderr, "[FATAL] failed to allocate memory\n");
exit(1);
}
- recurse++;
+ if (rb_thread_raised_p(th, RAISED_NOMEMORY)) {
+ rb_exc_jump(nomem_error);
+ }
+ rb_thread_raised_set(th, RAISED_NOMEMORY);
rb_exc_raise(nomem_error);
}
@@ -207,7 +105,8 @@ rb_memerror(void)
*/
static VALUE
-gc_stress_get(VALUE self)
+gc_stress_get(self)
+ VALUE self;
{
return ruby_gc_stress ? Qtrue : Qfalse;
}
@@ -225,7 +124,8 @@ gc_stress_get(VALUE self)
*/
static VALUE
-gc_stress_set(VALUE self, VALUE bool)
+gc_stress_set(self, bool)
+ VALUE self, bool;
{
rb_secure(2);
ruby_gc_stress = RTEST(bool);
@@ -233,7 +133,8 @@ gc_stress_set(VALUE self, VALUE bool)
}
void *
-ruby_xmalloc(size_t size)
+ruby_xmalloc(size)
+ long size;
{
void *mem;
@@ -241,87 +142,75 @@ ruby_xmalloc(size_t size)
rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
}
if (size == 0) size = 1;
- malloc_increase += size;
- if (ruby_gc_stress || malloc_increase > malloc_limit) {
+ if (ruby_gc_stress || (malloc_increase+size) > malloc_limit) {
garbage_collect();
}
RUBY_CRITICAL(mem = malloc(size));
if (!mem) {
- if (garbage_collect()) {
- RUBY_CRITICAL(mem = malloc(size));
- }
+ garbage_collect();
+ RUBY_CRITICAL(mem = malloc(size));
if (!mem) {
rb_memerror();
}
}
+ malloc_increase += size;
return mem;
}
void *
-ruby_xmalloc2(size_t n, size_t size)
-{
- long len = size * n;
- if (n != 0 && size != len / n) {
- rb_raise(rb_eArgError, "malloc: possible integer overflow");
- }
- return ruby_xmalloc(len);
-}
-
-void *
-ruby_xcalloc(size_t n, size_t size)
+ruby_xcalloc(n, size)
+ long n, size;
{
void *mem;
- mem = ruby_xmalloc2(n, size);
+ mem = xmalloc(n * size);
memset(mem, 0, n * size);
return mem;
}
void *
-ruby_xrealloc(void *ptr, size_t size)
+ruby_xrealloc(ptr, size)
+ void *ptr;
+ long size;
{
void *mem;
if (size < 0) {
rb_raise(rb_eArgError, "negative re-allocation size");
}
- if (!ptr) return ruby_xmalloc(size);
+ if (!ptr) return xmalloc(size);
if (size == 0) size = 1;
- malloc_increase += size;
if (ruby_gc_stress) garbage_collect();
RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
- if (garbage_collect()) {
- RUBY_CRITICAL(mem = realloc(ptr, size));
- }
+ garbage_collect();
+ RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
rb_memerror();
}
}
+ malloc_increase += size;
return mem;
}
-void *
-ruby_xrealloc2(void *ptr, size_t n, size_t size)
-{
- size_t len = size * n;
- if (n != 0 && size != len / n) {
- rb_raise(rb_eArgError, "realloc: possible integer overflow");
- }
- return ruby_xrealloc(ptr, len);
-}
-
void
-ruby_xfree(void *x)
+ruby_xfree(x)
+ void *x;
{
if (x)
RUBY_CRITICAL(free(x));
}
+extern int ruby_in_compile;
+static int dont_gc;
+static int during_gc;
+static int need_call_final = 0;
+static st_table *finalizer_table = 0;
+
/*
* call-seq:
@@ -337,7 +226,7 @@ ruby_xfree(void *x)
*/
VALUE
-rb_gc_enable(void)
+rb_gc_enable()
{
int old = dont_gc;
@@ -358,7 +247,7 @@ rb_gc_enable(void)
*/
VALUE
-rb_gc_disable(void)
+rb_gc_disable()
{
int old = dont_gc;
@@ -374,7 +263,8 @@ static struct gc_list {
} *global_List = 0;
void
-rb_gc_register_address(VALUE *addr)
+rb_gc_register_address(addr)
+ VALUE *addr;
{
struct gc_list *tmp;
@@ -385,14 +275,8 @@ rb_gc_register_address(VALUE *addr)
}
void
-rb_register_mark_object(VALUE obj)
-{
- VALUE ary = GET_THREAD()->vm->mark_object_ary;
- rb_ary_push(ary, obj);
-}
-
-void
-rb_gc_unregister_address(VALUE *addr)
+rb_gc_unregister_address(addr)
+ VALUE *addr;
{
struct gc_list *tmp = global_List;
@@ -413,8 +297,73 @@ rb_gc_unregister_address(VALUE *addr)
}
}
+#undef GC_DEBUG
+
+void
+rb_global_variable(var)
+ VALUE *var;
+{
+ rb_gc_register_address(var);
+}
+
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
+#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
+#endif
+
+typedef struct RVALUE {
+ union {
+ struct {
+ unsigned long flags; /* always 0 for freed obj */
+ struct RVALUE *next;
+ } free;
+ struct RBasic basic;
+ struct RObject object;
+ struct RClass klass;
+ struct RFloat flonum;
+ struct RString string;
+ struct RArray array;
+ struct RRegexp regexp;
+ struct RHash hash;
+ struct RData data;
+ struct RStruct rstruct;
+ struct RBignum bignum;
+ struct RFile file;
+ struct RNode node;
+ struct RMatch match;
+ struct RVarmap varmap;
+ struct SCOPE scope;
+ } as;
+#ifdef GC_DEBUG
+ char *file;
+ int line;
+#endif
+} RVALUE;
+
+#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CYGWIN__)
+#pragma pack(pop)
+#endif
+
+static RVALUE *freelist = 0;
+static RVALUE *deferred_final_list = 0;
+
+#define HEAPS_INCREMENT 10
+static struct heaps_slot {
+ void *membase;
+ RVALUE *slot;
+ int limit;
+} *heaps;
+static int heaps_length = 0;
+static int heaps_used = 0;
+
+#define HEAP_MIN_SLOTS 10000
+static int heap_slots = HEAP_MIN_SLOTS;
+
+#define FREE_MIN 4096
+
+static RVALUE *himem, *lomem;
+
static void
-add_heap(void)
+add_heap()
{
RVALUE *p, *pend;
@@ -445,13 +394,13 @@ add_heap(void)
heap_slots = HEAP_MIN_SLOTS;
continue;
}
- heaps[heaps_used].membase = p;
- if ((VALUE)p % sizeof(RVALUE) == 0)
- heap_slots += 1;
- else
- p = (RVALUE*)((VALUE)p + sizeof(RVALUE) - ((VALUE)p % sizeof(RVALUE)));
- heaps[heaps_used].slot = p;
- heaps[heaps_used].limit = heap_slots;
+ heaps[heaps_used].membase = p;
+ if ((VALUE)p % sizeof(RVALUE) == 0)
+ heap_slots += 1;
+ else
+ p = (RVALUE*)((VALUE)p + sizeof(RVALUE) - ((VALUE)p % sizeof(RVALUE)));
+ heaps[heaps_used].slot = p;
+ heaps[heaps_used].limit = heap_slots;
break;
}
pend = p + heap_slots;
@@ -459,6 +408,7 @@ add_heap(void)
if (himem < pend) himem = pend;
heaps_used++;
heap_slots *= 1.8;
+ if (heap_slots <= 0) heap_slots = HEAP_MIN_SLOTS;
while (p < pend) {
p->as.free.flags = 0;
@@ -469,91 +419,38 @@ add_heap(void)
}
#define RANY(o) ((RVALUE*)(o))
-static VALUE
-rb_newobj_from_heap(void)
+int
+rb_during_gc()
+{
+ return during_gc;
+}
+
+VALUE
+rb_newobj()
{
VALUE obj;
- if (ruby_gc_stress || !freelist) {
- if(!garbage_collect()) {
- rb_memerror();
- }
- }
+ if (during_gc)
+ rb_bug("object allocation during garbage collection phase");
+
+ if (ruby_gc_stress || !freelist) garbage_collect();
obj = (VALUE)freelist;
freelist = freelist->as.free.next;
-
MEMZERO((void*)obj, RVALUE, 1);
#ifdef GC_DEBUG
- RANY(obj)->file = rb_sourcefile();
- RANY(obj)->line = rb_sourceline();
+ RANY(obj)->file = ruby_sourcefile;
+ RANY(obj)->line = ruby_sourceline;
#endif
return obj;
}
-#if USE_VALUE_CACHE
-static VALUE
-rb_fill_value_cache(rb_thread_t *th)
-{
- int i;
- VALUE rv;
-
- /* LOCK */
- for (i=0; i<RUBY_VM_VALUE_CACHE_SIZE; i++) {
- VALUE v = rb_newobj_from_heap();
-
- th->value_cache[i] = v;
- RBASIC(v)->flags = FL_MARK;
- }
- th->value_cache_ptr = &th->value_cache[0];
- rv = rb_newobj_from_heap();
- /* UNLOCK */
- return rv;
-}
-#endif
-
VALUE
-rb_newobj(void)
-{
-#if USE_VALUE_CACHE
- rb_thread_t *th = GET_THREAD();
- VALUE v = *th->value_cache_ptr;
-
- if (v) {
- RBASIC(v)->flags = 0;
- th->value_cache_ptr++;
- }
- else {
- v = rb_fill_value_cache(th);
- }
-
-#if defined(GC_DEBUG)
- printf("cache index: %d, v: %p, th: %p\n",
- th->value_cache_ptr - th->value_cache, v, th);
-#endif
- return v;
-#else
- return rb_newobj_from_heap();
-#endif
-}
-
-NODE*
-rb_node_newnode(enum node_type type, VALUE a0, VALUE a1, VALUE a2)
-{
- NODE *n = (NODE*)rb_newobj();
-
- n->flags |= T_NODE;
- nd_set_type(n, type);
-
- n->u1.value = a0;
- n->u2.value = a1;
- n->u3.value = a2;
-
- return n;
-}
-
-VALUE
-rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
+rb_data_object_alloc(klass, datap, dmark, dfree)
+ VALUE klass;
+ void *datap;
+ RUBY_DATA_FUNC dmark;
+ RUBY_DATA_FUNC dfree;
{
NEWOBJ(data, struct RData);
if (klass) Check_Type(klass, T_CLASS);
@@ -565,25 +462,56 @@ rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_F
return (VALUE)data;
}
+extern st_table *rb_class_tbl;
+VALUE *rb_gc_stack_start = 0;
#ifdef __ia64
-#define SET_STACK_END (SET_MACHINE_STACK_END(&th->machine_stack_end), th->machine_register_stack_end = rb_ia64_bsp())
-#else
-#define SET_STACK_END SET_MACHINE_STACK_END(&th->machine_stack_end)
+VALUE *rb_gc_register_stack_start = 0;
#endif
-#define STACK_START (th->machine_stack_start)
-#define STACK_END (th->machine_stack_end)
-#define STACK_LEVEL_MAX (th->machine_stack_maxsize/sizeof(VALUE))
+#ifdef DJGPP
+/* set stack size (http://www.delorie.com/djgpp/v2faq/faq15_9.html) */
+unsigned int _stklen = 0x180000; /* 1.5 kB */
+#endif
-#if defined(sparc) || defined(__sparc__)
-# define STACK_LENGTH (STACK_START - STACK_END + 0x80)
-#elif STACK_GROW_DIRECTION < 0
-# define STACK_LENGTH (STACK_START - STACK_END)
+#if defined(DJGPP) || defined(_WIN32_WCE)
+static unsigned int STACK_LEVEL_MAX = 65535;
+#elif defined(__human68k__)
+unsigned int _stacksize = 262144;
+# define STACK_LEVEL_MAX (_stacksize - 4096)
+# undef HAVE_GETRLIMIT
+#elif defined(HAVE_GETRLIMIT) || defined(_WIN32)
+static unsigned int STACK_LEVEL_MAX = 655300;
+#else
+# define STACK_LEVEL_MAX 655300
+#endif
+
+#ifdef C_ALLOCA
+# define SET_STACK_END VALUE stack_end; alloca(0);
+# define STACK_END (&stack_end)
+#else
+# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS) && !defined(__ia64)
+# if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
+__attribute__ ((noinline))
+# endif
+static void
+stack_end_address(VALUE **stack_end_p)
+{
+ VALUE stack_end;
+ *stack_end_p = &stack_end;
+}
+# define SET_STACK_END VALUE *stack_end; stack_end_address(&stack_end)
+# else
+# define SET_STACK_END VALUE *stack_end = alloca(1)
+# endif
+# define STACK_END (stack_end)
+#endif
+#if STACK_GROW_DIRECTION < 0
+# define STACK_LENGTH (rb_gc_stack_start - STACK_END)
#elif STACK_GROW_DIRECTION > 0
-# define STACK_LENGTH (STACK_END - STACK_START + 1)
+# define STACK_LENGTH (STACK_END - rb_gc_stack_start + 1)
#else
-# define STACK_LENGTH ((STACK_END < STACK_START) ? STACK_START - STACK_END\
- : STACK_END - STACK_START + 1)
+# define STACK_LENGTH ((STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END\
+ : STACK_END - rb_gc_stack_start + 1)
#endif
#if STACK_GROW_DIRECTION > 0
# define STACK_UPPER(x, a, b) a
@@ -592,13 +520,13 @@ rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_F
#else
static int grow_direction;
static int
-stack_grow_direction(VALUE *addr)
+stack_grow_direction(addr)
+ VALUE *addr;
{
- rb_thread_t *th = GET_THREAD();
- SET_STACK_END;
+ SET_STACK_END;
- if (STACK_END > addr) return grow_direction = 1;
- return grow_direction = -1;
+ if (STACK_END > addr) return grow_direction = 1;
+ return grow_direction = -1;
}
# define stack_growup_p(x) ((grow_direction ? grow_direction : stack_grow_direction(x)) > 0)
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
@@ -606,33 +534,36 @@ stack_grow_direction(VALUE *addr)
#define GC_WATER_MARK 512
+#define CHECK_STACK(ret) do {\
+ SET_STACK_END;\
+ (ret) = (STACK_LENGTH > STACK_LEVEL_MAX + GC_WATER_MARK);\
+} while (0)
+
int
-ruby_stack_length(VALUE **p)
+ruby_stack_length(p)
+ VALUE **p;
{
- rb_thread_t *th = GET_THREAD();
- SET_STACK_END;
- if (p) *p = STACK_UPPER(STACK_END, STACK_START, STACK_END);
- return STACK_LENGTH;
+ SET_STACK_END;
+ if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END);
+ return STACK_LENGTH;
}
int
-ruby_stack_check(void)
+ruby_stack_check()
{
int ret;
- rb_thread_t *th = GET_THREAD();
- SET_STACK_END;
- ret = STACK_LENGTH > STACK_LEVEL_MAX + GC_WATER_MARK;
-#ifdef __ia64
- if (!ret) {
- ret = (VALUE*)rb_ia64_bsp() - th->machine_register_stack_start >
- th->machine_register_stack_maxsize/sizeof(VALUE) + GC_WATER_MARK;
- }
-#endif
+
+ CHECK_STACK(ret);
return ret;
}
+#define MARK_STACK_MAX 1024
+static VALUE mark_stack[MARK_STACK_MAX];
+static VALUE *mark_stack_ptr;
+static int mark_stack_overflow;
+
static void
-init_mark_stack(void)
+init_mark_stack()
{
mark_stack_overflow = 0;
mark_stack_ptr = mark_stack;
@@ -643,14 +574,14 @@ init_mark_stack(void)
static st_table *source_filenames;
char *
-rb_source_filename(const char *f)
+rb_source_filename(f)
+ const char *f;
{
st_data_t name;
if (!st_lookup(source_filenames, (st_data_t)f, &name)) {
long len = strlen(f) + 1;
char *ptr = ALLOC_N(char, len + 1);
-
name = (st_data_t)ptr;
*ptr++ = 0;
MEMCPY(ptr, f, char, len);
@@ -660,8 +591,9 @@ rb_source_filename(const char *f)
return (char *)name + 1;
}
-void
-rb_mark_source_filename(char *f)
+static void
+mark_source_filename(f)
+ char *f;
{
if (f) {
f[-1] = 1;
@@ -669,7 +601,8 @@ rb_mark_source_filename(char *f)
}
static int
-sweep_source_filename(char *key, char *value)
+sweep_source_filename(key, value)
+ char *key, *value;
{
if (*value) {
*value = 0;
@@ -681,11 +614,11 @@ sweep_source_filename(char *key, char *value)
}
}
-static void gc_mark(VALUE ptr, int lev);
-static void gc_mark_children(VALUE ptr, int lev);
+static void gc_mark _((VALUE ptr, int lev));
+static void gc_mark_children _((VALUE ptr, int lev));
static void
-gc_mark_all(void)
+gc_mark_all()
{
RVALUE *p, *pend;
int i;
@@ -704,23 +637,24 @@ gc_mark_all(void)
}
static void
-gc_mark_rest(void)
+gc_mark_rest()
{
VALUE tmp_arry[MARK_STACK_MAX];
VALUE *p;
p = (mark_stack_ptr - mark_stack) + tmp_arry;
- MEMCPY(tmp_arry, mark_stack, VALUE, p - tmp_arry);
+ MEMCPY(tmp_arry, mark_stack, VALUE, MARK_STACK_MAX);
init_mark_stack();
- while (p != tmp_arry) {
+ while(p != tmp_arry){
p--;
gc_mark_children(*p, 0);
}
}
static inline int
-is_pointer_to_heap(void *ptr)
+is_pointer_to_heap(ptr)
+ void *ptr;
{
register RVALUE *p = RANY(ptr);
register RVALUE *heap_org;
@@ -739,12 +673,13 @@ is_pointer_to_heap(void *ptr)
}
static void
-mark_locations_array(register VALUE *x, register long n)
+mark_locations_array(x, n)
+ register VALUE *x;
+ register long n;
{
VALUE v;
while (n--) {
v = *x;
- VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v));
if (is_pointer_to_heap((void *)v)) {
gc_mark(v, 0);
}
@@ -753,7 +688,8 @@ mark_locations_array(register VALUE *x, register long n)
}
void
-rb_gc_mark_locations(VALUE *start, VALUE *end)
+rb_gc_mark_locations(start, end)
+ VALUE *start, *end;
{
long n;
@@ -762,47 +698,36 @@ rb_gc_mark_locations(VALUE *start, VALUE *end)
}
static int
-mark_entry(ID key, VALUE value, int lev)
+mark_entry(key, value, lev)
+ ID key;
+ VALUE value;
+ int lev;
{
gc_mark(value, lev);
return ST_CONTINUE;
}
static void
-mark_tbl(st_table *tbl, int lev)
+mark_tbl(tbl, lev)
+ st_table *tbl;
+ int lev;
{
if (!tbl) return;
st_foreach(tbl, mark_entry, lev);
}
void
-rb_mark_tbl(st_table *tbl)
+rb_mark_tbl(tbl)
+ st_table *tbl;
{
mark_tbl(tbl, 0);
}
static int
-mark_key(VALUE key, VALUE value, int lev)
-{
- gc_mark(key, lev);
- return ST_CONTINUE;
-}
-
-static void
-mark_set(st_table *tbl, int lev)
-{
- if (!tbl) return;
- st_foreach(tbl, mark_key, lev);
-}
-
-void
-rb_mark_set(st_table *tbl)
-{
- mark_set(tbl, 0);
-}
-
-static int
-mark_keyvalue(VALUE key, VALUE value, int lev)
+mark_keyvalue(key, value, lev)
+ VALUE key;
+ VALUE value;
+ int lev;
{
gc_mark(key, lev);
gc_mark(value, lev);
@@ -810,20 +735,24 @@ mark_keyvalue(VALUE key, VALUE value, int lev)
}
static void
-mark_hash(st_table *tbl, int lev)
+mark_hash(tbl, lev)
+ st_table *tbl;
+ int lev;
{
if (!tbl) return;
st_foreach(tbl, mark_keyvalue, lev);
}
void
-rb_mark_hash(st_table *tbl)
+rb_mark_hash(tbl)
+ st_table *tbl;
{
mark_hash(tbl, 0);
}
void
-rb_gc_mark_maybe(VALUE obj)
+rb_gc_mark_maybe(obj)
+ VALUE obj;
{
if (is_pointer_to_heap((void *)obj)) {
gc_mark(obj, 0);
@@ -833,7 +762,9 @@ rb_gc_mark_maybe(VALUE obj)
#define GC_LEVEL_MAX 250
static void
-gc_mark(VALUE ptr, int lev)
+gc_mark(ptr, lev)
+ VALUE ptr;
+ int lev;
{
register RVALUE *obj;
@@ -847,7 +778,7 @@ gc_mark(VALUE ptr, int lev)
if (!mark_stack_overflow) {
if (mark_stack_ptr - mark_stack < MARK_STACK_MAX) {
*mark_stack_ptr = ptr;
- mark_stack_ptr++;
+ mark_stack_ptr++;
}
else {
mark_stack_overflow = 1;
@@ -859,13 +790,16 @@ gc_mark(VALUE ptr, int lev)
}
void
-rb_gc_mark(VALUE ptr)
+rb_gc_mark(ptr)
+ VALUE ptr;
{
gc_mark(ptr, 0);
}
static void
-gc_mark_children(VALUE ptr, int lev)
+gc_mark_children(ptr, lev)
+ VALUE ptr;
+ int lev;
{
register RVALUE *obj = RANY(ptr);
@@ -890,42 +824,40 @@ gc_mark_children(VALUE ptr, int lev)
break;
case T_NODE:
- rb_mark_source_filename(obj->as.node.nd_file);
+ mark_source_filename(obj->as.node.nd_file);
switch (nd_type(obj)) {
case NODE_IF: /* 1,2,3 */
case NODE_FOR:
case NODE_ITER:
+ case NODE_CREF:
case NODE_WHEN:
case NODE_MASGN:
case NODE_RESCUE:
case NODE_RESBODY:
case NODE_CLASS:
- case NODE_BLOCK_PASS:
gc_mark((VALUE)obj->as.node.u2.node, lev);
/* fall through */
case NODE_BLOCK: /* 1,3 */
- case NODE_OPTBLOCK:
case NODE_ARRAY:
case NODE_DSTR:
case NODE_DXSTR:
case NODE_DREGX:
case NODE_DREGX_ONCE:
+ case NODE_FBODY:
case NODE_ENSURE:
case NODE_CALL:
case NODE_DEFS:
case NODE_OP_ASGN1:
- case NODE_ARGS:
gc_mark((VALUE)obj->as.node.u1.node, lev);
/* fall through */
case NODE_SUPER: /* 3 */
case NODE_FCALL:
case NODE_DEFN:
- case NODE_ARGS_AUX:
+ case NODE_NEWLINE:
ptr = (VALUE)obj->as.node.u3.node;
goto again;
- case NODE_METHOD: /* 1,2 */
- case NODE_WHILE:
+ case NODE_WHILE: /* 1,2 */
case NODE_UNTIL:
case NODE_AND:
case NODE_OR:
@@ -942,22 +874,22 @@ gc_mark_children(VALUE ptr, int lev)
case NODE_MODULE:
case NODE_ALIAS:
case NODE_VALIAS:
- case NODE_ARGSCAT:
+ case NODE_ARGS:
gc_mark((VALUE)obj->as.node.u1.node, lev);
/* fall through */
- case NODE_FBODY: /* 2 */
+ case NODE_METHOD: /* 2 */
+ case NODE_NOT:
case NODE_GASGN:
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_IASGN:
- case NODE_IASGN2:
+ case NODE_CVDECL:
case NODE_CVASGN:
case NODE_COLON3:
case NODE_OPT_N:
case NODE_EVSTR:
case NODE_UNDEF:
- case NODE_POSTEXE:
ptr = (VALUE)obj->as.node.u2.node;
goto again;
@@ -974,12 +906,13 @@ gc_mark_children(VALUE ptr, int lev)
case NODE_COLON2:
case NODE_SPLAT:
case NODE_TO_ARY:
+ case NODE_SVALUE:
ptr = (VALUE)obj->as.node.u1.node;
goto again;
case NODE_SCOPE: /* 2,3 */
+ case NODE_BLOCK_PASS:
case NODE_CDECL:
- case NODE_OPT_ARG:
gc_mark((VALUE)obj->as.node.u3.node, lev);
ptr = (VALUE)obj->as.node.u2.node;
goto again;
@@ -1001,9 +934,9 @@ gc_mark_children(VALUE ptr, int lev)
case NODE_NIL:
case NODE_TRUE:
case NODE_FALSE:
- case NODE_ERRINFO:
case NODE_ATTRSET:
case NODE_BLOCK_ARG:
+ case NODE_POSTEXE:
break;
case NODE_ALLOCA:
mark_locations_array((VALUE*)obj->as.node.u1.value,
@@ -1030,9 +963,9 @@ gc_mark_children(VALUE ptr, int lev)
case T_ICLASS:
case T_CLASS:
case T_MODULE:
- mark_tbl(RCLASS_M_TBL(obj), lev);
- mark_tbl(RCLASS_IV_TBL(obj), lev);
- ptr = RCLASS_SUPER(obj);
+ mark_tbl(obj->as.klass.m_tbl, lev);
+ mark_tbl(obj->as.klass.iv_tbl, lev);
+ ptr = obj->as.klass.super;
goto again;
case T_ARRAY:
@@ -1041,8 +974,9 @@ gc_mark_children(VALUE ptr, int lev)
goto again;
}
else {
- long i, len = RARRAY_LEN(obj);
- VALUE *ptr = RARRAY_PTR(obj);
+ long i, len = obj->as.array.len;
+ VALUE *ptr = obj->as.array.ptr;
+
for (i=0; i < len; i++) {
gc_mark(*ptr++, lev);
}
@@ -1050,14 +984,14 @@ gc_mark_children(VALUE ptr, int lev)
break;
case T_HASH:
- mark_hash(obj->as.hash.ntbl, lev);
+ mark_hash(obj->as.hash.tbl, lev);
ptr = obj->as.hash.ifnone;
goto again;
case T_STRING:
#define STR_ASSOC FL_USER3 /* copied from string.c */
- if (FL_TEST(obj, RSTRING_NOEMBED) && FL_ANY(obj, ELTS_SHARED|STR_ASSOC)) {
- ptr = obj->as.string.as.heap.aux.shared;
+ if (FL_TEST(obj, ELTS_SHARED|STR_ASSOC)) {
+ ptr = obj->as.string.aux.shared;
goto again;
}
break;
@@ -1067,71 +1001,67 @@ gc_mark_children(VALUE ptr, int lev)
break;
case T_OBJECT:
- {
- long i, len = ROBJECT_LEN(obj);
- VALUE *ptr = ROBJECT_PTR(obj);
- for (i = 0; i < len; i++) {
- gc_mark(*ptr++, lev);
- }
- }
+ mark_tbl(obj->as.object.iv_tbl, lev);
break;
case T_FILE:
- if (obj->as.file.fptr)
- gc_mark(obj->as.file.fptr->tied_io_for_writing, lev);
- break;
-
case T_REGEXP:
case T_FLOAT:
case T_BIGNUM:
- case T_BLOCK:
+ case T_BLKTAG:
break;
case T_MATCH:
- gc_mark(obj->as.match.regexp, lev);
if (obj->as.match.str) {
ptr = obj->as.match.str;
goto again;
}
break;
- case T_STRUCT:
- {
- long len = RSTRUCT_LEN(obj);
- VALUE *ptr = RSTRUCT_PTR(obj);
+ case T_VARMAP:
+ gc_mark(obj->as.varmap.val, lev);
+ ptr = (VALUE)obj->as.varmap.next;
+ goto again;
- while (len--) {
- gc_mark(*ptr++, lev);
+ case T_SCOPE:
+ if (obj->as.scope.local_vars && (obj->as.scope.flags & SCOPE_MALLOC)) {
+ int n = obj->as.scope.local_tbl[0]+1;
+ VALUE *vars = &obj->as.scope.local_vars[-1];
+
+ while (n--) {
+ gc_mark(*vars++, lev);
}
}
break;
- case T_VALUES:
+ case T_STRUCT:
{
- rb_gc_mark(RVALUES(obj)->v1);
- rb_gc_mark(RVALUES(obj)->v2);
- ptr = RVALUES(obj)->v3;
- goto again;
+ long len = obj->as.rstruct.len;
+ VALUE *ptr = obj->as.rstruct.ptr;
+
+ while (len--) {
+ gc_mark(*ptr++, lev);
+ }
}
break;
default:
- rb_bug("rb_gc_mark(): unknown data type 0x%lx(%p) %s",
+ rb_bug("rb_gc_mark(): unknown data type 0x%lx(0x%lx) %s",
obj->as.basic.flags & T_MASK, obj,
is_pointer_to_heap(obj) ? "corrupted object" : "non object");
}
}
-static void obj_free(VALUE);
+static void obj_free _((VALUE));
static void
-finalize_list(RVALUE *p)
+finalize_list(p)
+ RVALUE *p;
{
while (p) {
RVALUE *tmp = p->as.free.next;
run_final((VALUE)p);
if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
- VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
p->as.free.flags = 0;
p->as.free.next = freelist;
freelist = p;
@@ -1141,7 +1071,7 @@ finalize_list(RVALUE *p)
}
static void
-free_unused_heaps(void)
+free_unused_heaps()
{
int i, j;
@@ -1162,7 +1092,7 @@ free_unused_heaps(void)
void rb_gc_abort_threads(void);
static void
-gc_sweep(void)
+gc_sweep()
{
RVALUE *p, *pend, *final_list;
int freed = 0;
@@ -1177,6 +1107,20 @@ gc_sweep(void)
if (free_min < FREE_MIN)
free_min = FREE_MIN;
+ if (ruby_in_compile && ruby_parser_stack_on_heap()) {
+ /* should not reclaim nodes during compilation
+ if yacc's semantic stack is not allocated on machine stack */
+ for (i = 0; i < heaps_used; i++) {
+ p = heaps[i].slot; pend = p + heaps[i].limit;
+ while (p < pend) {
+ if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
+ gc_mark((VALUE)p, 0);
+ p++;
+ }
+ }
+ }
+
+ mark_source_filename(ruby_sourcefile);
if (source_filenames) {
st_foreach(source_filenames, sweep_source_filename, 0);
}
@@ -1201,7 +1145,6 @@ gc_sweep(void)
final_list = p;
}
else {
- VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
p->as.free.flags = 0;
p->as.free.next = freelist;
freelist = p;
@@ -1223,7 +1166,7 @@ gc_sweep(void)
heaps[i].limit = 0;
for (pp = final_list; pp != final; pp = pp->as.free.next) {
- p->as.free.flags |= FL_SINGLETON; /* freeing page mark */
+ pp->as.free.flags |= FL_SINGLETON; /* freeing page mark */
}
freelist = free; /* cancel this page from freelist */
}
@@ -1244,22 +1187,24 @@ gc_sweep(void)
/* clear finalization list */
if (final_list) {
deferred_final_list = final_list;
+ rb_thread_pending = 1;
return;
}
free_unused_heaps();
}
void
-rb_gc_force_recycle(VALUE p)
+rb_gc_force_recycle(p)
+ VALUE p;
{
- VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
RANY(p)->as.free.flags = 0;
RANY(p)->as.free.next = freelist;
freelist = RANY(p);
}
static void
-obj_free(VALUE obj)
+obj_free(obj)
+ VALUE obj;
{
switch (RANY(obj)->as.basic.flags & T_MASK) {
case T_NIL:
@@ -1276,37 +1221,36 @@ obj_free(VALUE obj)
switch (RANY(obj)->as.basic.flags & T_MASK) {
case T_OBJECT:
- if (!(RANY(obj)->as.basic.flags & ROBJECT_EMBED) &&
- RANY(obj)->as.object.as.heap.ptr) {
- RUBY_CRITICAL(free(RANY(obj)->as.object.as.heap.ptr));
+ if (RANY(obj)->as.object.iv_tbl) {
+ st_free_table(RANY(obj)->as.object.iv_tbl);
}
break;
case T_MODULE:
case T_CLASS:
rb_clear_cache_by_class((VALUE)obj);
- st_free_table(RCLASS_M_TBL(obj));
- if (RCLASS_IV_TBL(obj)) {
- st_free_table(RCLASS_IV_TBL(obj));
- }
- if (RCLASS_IV_INDEX_TBL(obj)) {
- st_free_table(RCLASS_IV_INDEX_TBL(obj));
+ st_free_table(RANY(obj)->as.klass.m_tbl);
+ if (RANY(obj)->as.object.iv_tbl) {
+ st_free_table(RANY(obj)->as.object.iv_tbl);
}
- RUBY_CRITICAL(free(RANY(obj)->as.klass.ptr));
break;
case T_STRING:
- rb_str_free(obj);
+ if (RANY(obj)->as.string.ptr && !FL_TEST(obj, ELTS_SHARED)) {
+ RUBY_CRITICAL(free(RANY(obj)->as.string.ptr));
+ }
break;
case T_ARRAY:
- rb_ary_free(obj);
+ if (RANY(obj)->as.array.ptr && !FL_TEST(obj, ELTS_SHARED)) {
+ RUBY_CRITICAL(free(RANY(obj)->as.array.ptr));
+ }
break;
case T_HASH:
- if (RANY(obj)->as.hash.ntbl) {
- st_free_table(RANY(obj)->as.hash.ntbl);
+ if (RANY(obj)->as.hash.tbl) {
+ st_free_table(RANY(obj)->as.hash.tbl);
}
break;
case T_REGEXP:
if (RANY(obj)->as.regexp.ptr) {
- onig_free(RANY(obj)->as.regexp.ptr);
+ re_free_pattern(RANY(obj)->as.regexp.ptr);
}
if (RANY(obj)->as.regexp.str) {
RUBY_CRITICAL(free(RANY(obj)->as.regexp.str));
@@ -1324,13 +1268,14 @@ obj_free(VALUE obj)
break;
case T_MATCH:
if (RANY(obj)->as.match.regs) {
- onig_region_free(RANY(obj)->as.match.regs, 0);
+ re_free_registers(RANY(obj)->as.match.regs);
RUBY_CRITICAL(free(RANY(obj)->as.match.regs));
}
break;
case T_FILE:
if (RANY(obj)->as.file.fptr) {
rb_io_fptr_finalize(RANY(obj)->as.file.fptr);
+ RUBY_CRITICAL(free(RANY(obj)->as.file.fptr));
}
break;
case T_ICLASS:
@@ -1338,14 +1283,13 @@ obj_free(VALUE obj)
break;
case T_FLOAT:
- case T_BLOCK:
- break;
- case T_VALUES:
+ case T_VARMAP:
+ case T_BLKTAG:
break;
case T_BIGNUM:
- if (!(RBASIC(obj)->flags & RBIGNUM_EMBED_FLAG) && RBIGNUM_DIGITS(obj)) {
- RUBY_CRITICAL(free(RBIGNUM_DIGITS(obj)));
+ if (RANY(obj)->as.bignum.digits) {
+ RUBY_CRITICAL(free(RANY(obj)->as.bignum.digits));
}
break;
case T_NODE:
@@ -1361,21 +1305,40 @@ obj_free(VALUE obj)
}
return; /* no need to free iv_tbl */
+ case T_SCOPE:
+ if (RANY(obj)->as.scope.local_vars &&
+ RANY(obj)->as.scope.flags != SCOPE_ALLOCA) {
+ VALUE *vars = RANY(obj)->as.scope.local_vars-1;
+ if (!(RANY(obj)->as.scope.flags & SCOPE_CLONE) && vars[0] == 0)
+ RUBY_CRITICAL(free(RANY(obj)->as.scope.local_tbl));
+ if (RANY(obj)->as.scope.flags & SCOPE_MALLOC)
+ RUBY_CRITICAL(free(vars));
+ }
+ break;
+
case T_STRUCT:
- if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 &&
- RANY(obj)->as.rstruct.as.heap.ptr) {
- RUBY_CRITICAL(free(RANY(obj)->as.rstruct.as.heap.ptr));
+ if (RANY(obj)->as.rstruct.ptr) {
+ RUBY_CRITICAL(free(RANY(obj)->as.rstruct.ptr));
}
break;
default:
- rb_bug("gc_sweep(): unknown data type 0x%lx(%p)",
- RANY(obj)->as.basic.flags & T_MASK, (void*)obj);
+ rb_bug("gc_sweep(): unknown data type 0x%lx(0x%lx)",
+ RANY(obj)->as.basic.flags & T_MASK, obj);
}
}
+void
+rb_gc_mark_frame(frame)
+ struct FRAME *frame;
+{
+ gc_mark((VALUE)frame->node, 0);
+}
+
#ifdef __GNUC__
#if defined(__human68k__) || defined(DJGPP)
+#undef rb_setjmp
+#undef rb_jmp_buf
#if defined(__human68k__)
typedef unsigned long rb_jmp_buf[8];
__asm__ (".even\n\
@@ -1384,9 +1347,6 @@ _rb_setjmp:\n\
movem.l d3-d7/a3-a5,(a0)\n\
moveq.l #0,d0\n\
rts");
-#ifdef setjmp
-#undef setjmp
-#endif
#else
#if defined(DJGPP)
typedef unsigned long rb_jmp_buf[6];
@@ -1407,93 +1367,76 @@ _rb_setjmp:\n\
#endif
#endif
int rb_setjmp (rb_jmp_buf);
-#define jmp_buf rb_jmp_buf
-#define setjmp rb_setjmp
#endif /* __human68k__ or DJGPP */
#endif /* __GNUC__ */
-#define GC_NOTIFY 0
-
-void rb_vm_mark(void *ptr);
-
static void
-mark_current_machine_context(rb_thread_t *th)
+garbage_collect()
{
+ struct gc_list *list;
+ struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */
jmp_buf save_regs_gc_mark;
- VALUE *stack_start, *stack_end;
-
SET_STACK_END;
-#if STACK_GROW_DIRECTION < 0
- stack_start = th->machine_stack_end;
- stack_end = th->machine_stack_start;
-#elif STACK_GROW_DIRECTION > 0
- stack_start = th->machine_stack_start;
- stack_end = th->machine_stack_end + 1;
-#else
- if (th->machine_stack_end < th->machine_stack_start) {
- stack_start = th->machine_stack_end;
- stack_end = th->machine_stack_start;
- }
- else {
- stack_start = th->machine_stack_start;
- stack_end = th->machine_stack_end + 1;
- }
-#endif
-
- FLUSH_REGISTER_WINDOWS;
- /* This assumes that all registers are saved into the jmp_buf (and stack) */
- setjmp(save_regs_gc_mark);
- mark_locations_array((VALUE*)save_regs_gc_mark,
- sizeof(save_regs_gc_mark) / sizeof(VALUE));
-
- mark_locations_array(stack_start, stack_end - stack_start);
-#ifdef __ia64
- mark_locations_array(th->machine_register_stack_start,
- th->machine_register_stack_end - th->machine_register_stack_start);
-#endif
-#if defined(__human68k__) || defined(__mc68000__)
- mark_locations_array((VALUE*)((char*)STACK_END + 2),
- (STACK_START - STACK_END));
-#endif
-}
-
-void rb_gc_mark_encodings(void);
-
-static int
-garbage_collect(void)
-{
- struct gc_list *list;
- rb_thread_t *th = GET_THREAD();
-
- if (GC_NOTIFY) printf("start garbage_collect()\n");
- if (!heaps) {
- return Qfalse;
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on rb_gc()");
}
-
+#endif
if (dont_gc || during_gc) {
if (!freelist) {
add_heap();
}
- return Qtrue;
+ return;
}
+ if (during_gc) return;
during_gc++;
- SET_STACK_END;
-
init_mark_stack();
- th->vm->self ? rb_gc_mark(th->vm->self) : rb_vm_mark(th->vm);
+ gc_mark((VALUE)ruby_current_node, 0);
+ /* mark frame stack */
+ for (frame = ruby_frame; frame; frame = frame->prev) {
+ rb_gc_mark_frame(frame);
+ if (frame->tmp) {
+ struct FRAME *tmp = frame->tmp;
+ while (tmp) {
+ rb_gc_mark_frame(tmp);
+ tmp = tmp->prev;
+ }
+ }
+ }
+ gc_mark((VALUE)ruby_scope, 0);
+ gc_mark((VALUE)ruby_dyna_vars, 0);
if (finalizer_table) {
mark_tbl(finalizer_table, 0);
}
- mark_current_machine_context(th);
-
+ FLUSH_REGISTER_WINDOWS;
+ /* This assumes that all registers are saved into the jmp_buf (and stack) */
+ rb_setjmp(save_regs_gc_mark);
+ mark_locations_array((VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *));
+#if STACK_GROW_DIRECTION < 0
+ rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
+#elif STACK_GROW_DIRECTION > 0
+ rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END + 1);
+#else
+ if ((VALUE*)STACK_END < rb_gc_stack_start)
+ rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
+ else
+ rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END + 1);
+#endif
+#ifdef __ia64
+ /* mark backing store (flushed register window on the stack) */
+ /* the basic idea from guile GC code */
+ rb_gc_mark_locations(rb_gc_register_stack_start, (VALUE*)rb_ia64_bsp());
+#endif
+#if defined(__human68k__) || defined(__mc68000__)
+ rb_gc_mark_locations((VALUE*)((char*)STACK_END + 2),
+ (VALUE*)((char*)rb_gc_stack_start + 2));
+#endif
rb_gc_mark_threads();
- rb_gc_mark_symbols();
- rb_gc_mark_encodings();
/* mark protected global variables */
for (list = global_List; list; list = list->next) {
@@ -1511,49 +1454,23 @@ garbage_collect(void)
rb_gc_mark_parser();
/* gc_mark objects whose marking are not completed*/
- while (!MARK_STACK_EMPTY) {
- if (mark_stack_overflow) {
- gc_mark_all();
- }
- else {
- gc_mark_rest();
+ do {
+ while (!MARK_STACK_EMPTY) {
+ if (mark_stack_overflow){
+ gc_mark_all();
+ }
+ else {
+ gc_mark_rest();
+ }
}
- }
+ rb_gc_abort_threads();
+ } while (!MARK_STACK_EMPTY);
gc_sweep();
- if (GC_NOTIFY) printf("end garbage_collect()\n");
- return Qtrue;
-}
-
-int
-rb_garbage_collect(void)
-{
- return garbage_collect();
}
void
-rb_gc_mark_machine_stack(rb_thread_t *th)
-{
-#if STACK_GROW_DIRECTION < 0
- rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start);
-#elif STACK_GROW_DIRECTION > 0
- rb_gc_mark_locations(th->machine_stack_start, th->machine_stack_end);
-#else
- if (th->machine_stack_start < th->machine_stack_end) {
- rb_gc_mark_locations(th->machine_stack_start, th->machine_stack_end);
- }
- else {
- rb_gc_mark_locations(th->machine_stack_end, th->machine_stack_start);
- }
-#endif
-#ifdef __ia64
- rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end);
-#endif
-}
-
-
-void
-rb_gc(void)
+rb_gc()
{
garbage_collect();
rb_gc_finalize_deferred();
@@ -1570,20 +1487,24 @@ rb_gc(void)
*/
VALUE
-rb_gc_start(void)
+rb_gc_start()
{
rb_gc();
return Qnil;
}
void
-ruby_set_stack_size(size_t size)
+ruby_set_stack_size(size)
+ size_t size;
{
- rb_gc_stack_maxsize = size;
+#ifndef STACK_LEVEL_MAX
+ STACK_LEVEL_MAX = size / sizeof(VALUE);
+#endif
}
void
-Init_stack(VALUE *addr)
+Init_stack(addr)
+ VALUE *addr;
{
#ifdef __ia64
if (rb_gc_register_stack_start == 0) {
@@ -1620,7 +1541,7 @@ Init_stack(VALUE *addr)
rb_gc_stack_start = STACK_END_ADDRESS;
}
#else
- if (!addr) addr = (VALUE *)&addr;
+ if (!addr) addr = (void *)&addr;
STACK_UPPER(&addr, addr, ++addr);
if (rb_gc_stack_start) {
if (STACK_UPPER(&addr,
@@ -1639,7 +1560,7 @@ Init_stack(VALUE *addr)
unsigned int space = rlim.rlim_cur/5;
if (space > 1024*1024) space = 1024*1024;
- rb_gc_stack_maxsize = rlim.rlim_cur - space;
+ STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
}
}
#endif
@@ -1665,14 +1586,14 @@ void ruby_init_stack(VALUE *addr
#endif
#ifdef HAVE_GETRLIMIT
{
- struct rlimit rlim;
+ struct rlimit rlim;
- if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
- unsigned int space = rlim.rlim_cur/5;
+ if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
+ unsigned int space = rlim.rlim_cur/5;
- if (space > 1024*1024) space = 1024*1024;
- rb_gc_stack_maxsize = rlim.rlim_cur - space;
- }
+ if (space > 1024*1024) space = 1024*1024;
+ STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
+ }
}
#elif defined _WIN32
{
@@ -1684,7 +1605,7 @@ void ruby_init_stack(VALUE *addr
size = (char *)mi.BaseAddress - (char *)mi.AllocationBase;
space = size / 5;
if (space > 1024*1024) space = 1024*1024;
- rb_gc_stack_maxsize = size - space;
+ STACK_LEVEL_MAX = (size - space) / sizeof(VALUE);
}
}
#endif
@@ -1722,7 +1643,7 @@ void ruby_init_stack(VALUE *addr
*/
void
-Init_heap(void)
+Init_heap()
{
if (!rb_gc_stack_start) {
Init_stack(0);
@@ -1731,10 +1652,12 @@ Init_heap(void)
}
static VALUE
-os_obj_of(VALUE of)
+os_obj_of(of)
+ VALUE of;
{
int i;
int n = 0;
+ volatile VALUE v;
for (i = 0; i < heaps_used; i++) {
RVALUE *p, *pend;
@@ -1745,15 +1668,17 @@ os_obj_of(VALUE of)
switch (BUILTIN_TYPE(p)) {
case T_NONE:
case T_ICLASS:
+ case T_VARMAP:
+ case T_SCOPE:
case T_NODE:
- case T_VALUES:
continue;
case T_CLASS:
if (FL_TEST(p, FL_SINGLETON)) continue;
default:
if (!p->as.basic.klass) continue;
- if (!of || rb_obj_is_kind_of((VALUE)p, of)) {
- rb_yield((VALUE)p);
+ v = (VALUE)p;
+ if (!of || rb_obj_is_kind_of(v, of)) {
+ rb_yield(v);
n++;
}
}
@@ -1798,14 +1723,21 @@ os_obj_of(VALUE of)
*/
static VALUE
-os_each_obj(int argc, VALUE *argv)
+os_each_obj(argc, argv, os)
+ int argc;
+ VALUE *argv;
+ VALUE os;
{
VALUE of;
rb_secure(4);
- if (rb_scan_args(argc, argv, "01", &of) == 0) {
+ if (argc == 0) {
of = 0;
}
+ else {
+ rb_scan_args(argc, argv, "01", &of);
+ }
+ RETURN_ENUMERATOR(os, 1, &of);
return os_obj_of(of);
}
@@ -1815,7 +1747,8 @@ static VALUE finalizers;
*/
static VALUE
-add_final(VALUE os, VALUE block)
+add_final(os, block)
+ VALUE os, block;
{
rb_warn("ObjectSpace::add_finalizer is deprecated; use define_finalizer");
if (!rb_respond_to(block, rb_intern("call"))) {
@@ -1830,7 +1763,8 @@ add_final(VALUE os, VALUE block)
* deprecated
*/
static VALUE
-rm_final(VALUE os, VALUE block)
+rm_final(os, block)
+ VALUE os, block;
{
rb_warn("ObjectSpace::remove_finalizer is deprecated; use undefine_finalizer");
rb_ary_delete(finalizers, block);
@@ -1841,7 +1775,7 @@ rm_final(VALUE os, VALUE block)
* deprecated
*/
static VALUE
-finals(void)
+finals()
{
rb_warn("ObjectSpace::finalizers is deprecated");
return finalizers;
@@ -1852,7 +1786,8 @@ finals(void)
*/
static VALUE
-call_final(VALUE os, VALUE obj)
+call_final(os, obj)
+ VALUE os, obj;
{
rb_warn("ObjectSpace::call_finalizer is deprecated; use define_finalizer");
need_call_final = 1;
@@ -1869,7 +1804,8 @@ call_final(VALUE os, VALUE obj)
*/
static VALUE
-undefine_final(VALUE os, VALUE obj)
+undefine_final(os, obj)
+ VALUE os, obj;
{
if (finalizer_table) {
st_delete(finalizer_table, (st_data_t*)&obj, 0);
@@ -1887,7 +1823,10 @@ undefine_final(VALUE os, VALUE obj)
*/
static VALUE
-define_final(int argc, VALUE *argv, VALUE os)
+define_final(argc, argv, os)
+ int argc;
+ VALUE *argv;
+ VALUE os;
{
VALUE obj, block, table;
@@ -1902,7 +1841,7 @@ define_final(int argc, VALUE *argv, VALUE os)
need_call_final = 1;
FL_SET(obj, FL_FINALIZE);
- block = rb_ary_new3(2, INT2FIX(rb_safe_level()), block);
+ block = rb_ary_new3(2, INT2FIX(ruby_safe_level), block);
if (!finalizer_table) {
finalizer_table = st_init_numtable();
@@ -1917,7 +1856,8 @@ define_final(int argc, VALUE *argv, VALUE os)
}
void
-rb_gc_copy_finalizer(VALUE dest, VALUE obj)
+rb_gc_copy_finalizer(dest, obj)
+ VALUE dest, obj;
{
VALUE table;
@@ -1926,19 +1866,20 @@ rb_gc_copy_finalizer(VALUE dest, VALUE obj)
if (st_lookup(finalizer_table, obj, &table)) {
st_insert(finalizer_table, dest, table);
}
- FL_SET(dest, FL_FINALIZE);
+ RBASIC(dest)->flags |= FL_FINALIZE;
}
static VALUE
-run_single_final(VALUE arg)
+run_single_final(args)
+ VALUE *args;
{
- VALUE *args = (VALUE *)arg;
rb_eval_cmd(args[0], args[1], (int)args[2]);
return Qnil;
}
static void
-run_final(VALUE obj)
+run_final(obj)
+ VALUE obj;
{
long i;
int status, critical_save = rb_thread_critical;
@@ -1947,50 +1888,42 @@ run_final(VALUE obj)
objid = rb_obj_id(obj); /* make obj into id */
rb_thread_critical = Qtrue;
args[1] = 0;
- if (RARRAY_LEN(finalizers) > 0) {
- args[1] = rb_obj_freeze(rb_ary_new3(1, objid));
- }
- args[2] = (VALUE)rb_safe_level();
- for (i=0; i<RARRAY_LEN(finalizers); i++) {
- args[0] = RARRAY_PTR(finalizers)[i];
- rb_protect(run_single_final, (VALUE)args, &status);
+ args[2] = (VALUE)ruby_safe_level;
+ for (i=0; i<RARRAY(finalizers)->len; i++) {
+ args[0] = RARRAY(finalizers)->ptr[i];
+ if (!args[1]) args[1] = rb_ary_new3(1, objid);
+ rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
}
if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
- if (!args[1] && RARRAY_LEN(table) > 0) {
- args[1] = rb_obj_freeze(rb_ary_new3(1, objid));
- }
- for (i=0; i<RARRAY_LEN(table); i++) {
- VALUE final = RARRAY_PTR(table)[i];
- args[0] = RARRAY_PTR(final)[1];
- args[2] = FIX2INT(RARRAY_PTR(final)[0]);
- rb_protect(run_single_final, (VALUE)args, &status);
+ for (i=0; i<RARRAY(table)->len; i++) {
+ VALUE final = RARRAY(table)->ptr[i];
+ args[0] = RARRAY(final)->ptr[1];
+ if (!args[1]) args[1] = rb_ary_new3(1, objid);
+ args[2] = FIX2INT(RARRAY(final)->ptr[0]);
+ rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
}
}
rb_thread_critical = critical_save;
}
void
-rb_gc_finalize_deferred(void)
+rb_gc_finalize_deferred()
{
RVALUE *p = deferred_final_list;
- during_gc++;
deferred_final_list = 0;
if (p) {
finalize_list(p);
+ free_unused_heaps();
}
- free_unused_heaps();
- during_gc = 0;
}
void
-rb_gc_call_finalizer_at_exit(void)
+rb_gc_call_finalizer_at_exit()
{
RVALUE *p, *pend;
int i;
- /* finalizers are part of garbage collection */
- during_gc++;
/* run finalizers */
if (need_call_final) {
p = deferred_final_list;
@@ -2013,8 +1946,7 @@ rb_gc_call_finalizer_at_exit(void)
p = heaps[i].slot; pend = p + heaps[i].limit;
while (p < pend) {
if (BUILTIN_TYPE(p) == T_DATA &&
- DATA_PTR(p) && RANY(p)->as.data.dfree &&
- RANY(p)->as.basic.klass != rb_cThread) {
+ DATA_PTR(p) && RANY(p)->as.data.dfree) {
p->as.free.flags = 0;
if ((long)RANY(p)->as.data.dfree == -1) {
RUBY_CRITICAL(free(DATA_PTR(p)));
@@ -2022,18 +1954,14 @@ rb_gc_call_finalizer_at_exit(void)
else if (RANY(p)->as.data.dfree) {
(*RANY(p)->as.data.dfree)(DATA_PTR(p));
}
- VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
}
else if (BUILTIN_TYPE(p) == T_FILE) {
- if (rb_io_fptr_finalize(RANY(p)->as.file.fptr)) {
- p->as.free.flags = 0;
- VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
- }
+ p->as.free.flags = 0;
+ rb_io_fptr_finalize(RANY(p)->as.file.fptr);
}
p++;
}
}
- during_gc = 0;
}
/*
@@ -2050,20 +1978,14 @@ rb_gc_call_finalizer_at_exit(void)
*/
static VALUE
-id2ref(VALUE obj, VALUE objid)
+id2ref(obj, objid)
+ VALUE obj, objid;
{
-#if SIZEOF_LONG == SIZEOF_VOIDP
-#define NUM2PTR(x) NUM2ULONG(x)
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-#define NUM2PTR(x) NUM2ULL(x)
-#endif
- VALUE ptr;
- void *p0;
+ unsigned long ptr, p0;
+ int type;
rb_secure(4);
- ptr = NUM2PTR(objid);
- p0 = (void *)ptr;
-
+ p0 = ptr = NUM2ULONG(objid);
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
if (ptr == Qnil) return Qnil;
@@ -2073,16 +1995,16 @@ id2ref(VALUE obj, VALUE objid)
if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
ID symid = ptr / sizeof(RVALUE);
if (rb_id2name(symid) == 0)
- rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
- return ID2SYM(symid);
+ rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
+ return ID2SYM(symid);
}
- if (!is_pointer_to_heap((void *)ptr) ||
- BUILTIN_TYPE(ptr) >= T_VALUES || BUILTIN_TYPE(ptr) == T_ICLASS) {
- rb_raise(rb_eRangeError, "%p is not id value", p0);
+ if (!is_pointer_to_heap((void *)ptr)||
+ (type = BUILTIN_TYPE(ptr)) >= T_BLKTAG || type == T_ICLASS) {
+ rb_raise(rb_eRangeError, "0x%lx is not id value", p0);
}
if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) {
- rb_raise(rb_eRangeError, "%p is recycled object", p0);
+ rb_raise(rb_eRangeError, "0x%lx is recycled object", p0);
}
return (VALUE)ptr;
}
@@ -2094,7 +2016,7 @@ id2ref(VALUE obj, VALUE objid)
* call-seq:
* obj.__id__ => fixnum
* obj.object_id => fixnum
- *
+ *
* Returns an integer identifier for <i>obj</i>. The same number will
* be returned on all calls to <code>id</code> for a given object, and
* no two active objects will share an id.
@@ -2106,7 +2028,7 @@ id2ref(VALUE obj, VALUE objid)
/*
* call-seq:
* obj.hash => fixnum
- *
+ *
* Generates a <code>Fixnum</code> hash value for this object. This
* function must have the property that <code>a.eql?(b)</code> implies
* <code>a.hash == b.hash</code>. The hash value is used by class
@@ -2149,102 +2071,9 @@ rb_obj_id(VALUE obj)
return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
}
if (SPECIAL_CONST_P(obj)) {
- return LONG2NUM((SIGNED_VALUE)obj);
+ return LONG2NUM((long)obj);
}
- return (VALUE)((SIGNED_VALUE)obj|FIXNUM_FLAG);
-}
-
-/*
- * call-seq:
- * ObjectSpace.count_objects([result_hash]) -> hash
- *
- * Counts objects for each type.
- *
- * It returns a hash as:
- * {:TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, ...}
- *
- * If the optional argument, result_hash, is given,
- * it is overwritten and returned.
- * This is intended to avoid probe effect.
- *
- * The contents of the returned hash is implementation defined.
- * It may be changed in future.
- *
- * This method is not expected to work except C Ruby.
- *
- */
-
-static VALUE
-count_objects(int argc, VALUE *argv, VALUE os)
-{
- long counts[T_MASK+1];
- long freed = 0;
- long total = 0;
- int i;
- VALUE hash;
-
- if (rb_scan_args(argc, argv, "01", &hash) == 1) {
- if (TYPE(hash) != T_HASH)
- rb_raise(rb_eTypeError, "non-hash given");
- }
-
- for (i = 0; i <= T_MASK; i++) {
- counts[i] = 0;
- }
-
- for (i = 0; i < heaps_used; i++) {
- RVALUE *p, *pend;
-
- p = heaps[i].slot; pend = p + heaps[i].limit;
- for (;p < pend; p++) {
- if (p->as.basic.flags) {
- counts[BUILTIN_TYPE(p)]++;
- }
- else {
- freed++;
- }
- }
- total += heaps[i].limit;
- }
-
- if (hash == Qnil)
- hash = rb_hash_new();
- rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), LONG2NUM(total));
- rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), LONG2NUM(freed));
- for (i = 0; i <= T_MASK; i++) {
- VALUE type;
- switch (i) {
- case T_NONE: type = ID2SYM(rb_intern("T_NONE")); break;
- case T_NIL: type = ID2SYM(rb_intern("T_NIL")); break;
- case T_OBJECT: type = ID2SYM(rb_intern("T_OBJECT")); break;
- case T_CLASS: type = ID2SYM(rb_intern("T_CLASS")); break;
- case T_ICLASS: type = ID2SYM(rb_intern("T_ICLASS")); break;
- case T_MODULE: type = ID2SYM(rb_intern("T_MODULE")); break;
- case T_FLOAT: type = ID2SYM(rb_intern("T_FLOAT")); break;
- case T_STRING: type = ID2SYM(rb_intern("T_STRING")); break;
- case T_REGEXP: type = ID2SYM(rb_intern("T_REGEXP")); break;
- case T_ARRAY: type = ID2SYM(rb_intern("T_ARRAY")); break;
- case T_FIXNUM: type = ID2SYM(rb_intern("T_FIXNUM")); break;
- case T_HASH: type = ID2SYM(rb_intern("T_HASH")); break;
- case T_STRUCT: type = ID2SYM(rb_intern("T_STRUCT")); break;
- case T_BIGNUM: type = ID2SYM(rb_intern("T_BIGNUM")); break;
- case T_FILE: type = ID2SYM(rb_intern("T_FILE")); break;
- case T_TRUE: type = ID2SYM(rb_intern("T_TRUE")); break;
- case T_FALSE: type = ID2SYM(rb_intern("T_FALSE")); break;
- case T_DATA: type = ID2SYM(rb_intern("T_DATA")); break;
- case T_MATCH: type = ID2SYM(rb_intern("T_MATCH")); break;
- case T_SYMBOL: type = ID2SYM(rb_intern("T_SYMBOL")); break;
- case T_VALUES: type = ID2SYM(rb_intern("T_VALUES")); break;
- case T_BLOCK: type = ID2SYM(rb_intern("T_BLOCK")); break;
- case T_UNDEF: type = ID2SYM(rb_intern("T_UNDEF")); break;
- case T_NODE: type = ID2SYM(rb_intern("T_NODE")); break;
- default: type = INT2NUM(i); break;
- }
- if (counts[i])
- rb_hash_aset(hash, type, LONG2NUM(counts[i]));
- }
-
- return hash;
+ return (VALUE)((long)obj|FIXNUM_FLAG);
}
/*
@@ -2254,7 +2083,7 @@ count_objects(int argc, VALUE *argv, VALUE os)
*/
void
-Init_GC(void)
+Init_GC()
{
VALUE rb_mObSpace;
@@ -2287,11 +2116,12 @@ Init_GC(void)
source_filenames = st_init_strtable();
rb_global_variable(&nomem_error);
- nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory");
+ nomem_error = rb_exc_new3(rb_eNoMemError,
+ rb_obj_freeze(rb_str_new2("failed to allocate memory")));
+ OBJ_TAINT(nomem_error);
+ OBJ_FREEZE(nomem_error);
rb_define_method(rb_mKernel, "hash", rb_obj_id, 0);
rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
rb_define_method(rb_mKernel, "object_id", rb_obj_id, 0);
-
- rb_define_module_function(rb_mObSpace, "count_objects", count_objects, -1);
}
diff --git a/gc.h b/gc.h
deleted file mode 100644
index fe2e07ded0..0000000000
--- a/gc.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-#ifndef RUBY_GC_H
-#define RUBY_GC_H 1
-
-#if defined(__i386) && defined(__GNUC__)
-#define SET_MACHINE_STACK_END(p) __asm__("mov %%esp, %0" : "=r" (*p))
-#else
-NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
-#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
-#define USE_CONSERVATIVE_STACK_END
-#endif
-
-/* for GC debug */
-
-#ifndef RUBY_MARK_FREE_DEBUG
-#define RUBY_MARK_FREE_DEBUG 0
-#endif
-
-#if RUBY_MARK_FREE_DEBUG
-extern int ruby_gc_debug_indent;
-
-static void
-rb_gc_debug_indent(void)
-{
- printf("%*s", ruby_gc_debug_indent, "");
-}
-
-static void
-rb_gc_debug_body(char *mode, char *msg, int st, void *ptr)
-{
- if (st == 0) {
- ruby_gc_debug_indent--;
- }
- rb_gc_debug_indent();
- printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
-
- if (st) {
- ruby_gc_debug_indent++;
- }
-
- fflush(stdout);
-}
-
-#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr)
-#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr)
-#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr)
-#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr)
-#define RUBY_GC_INFO rb_gc_debug_indent(); printf
-
-#else
-#define RUBY_MARK_ENTER(msg)
-#define RUBY_MARK_LEAVE(msg)
-#define RUBY_FREE_ENTER(msg)
-#define RUBY_FREE_LEAVE(msg)
-#define RUBY_GC_INFO if(0)printf
-#endif
-
-#define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
-#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
-#endif /* RUBY_GC_H */
-
diff --git a/gem_prelude.rb b/gem_prelude.rb
deleted file mode 100644
index 63f979ccab..0000000000
--- a/gem_prelude.rb
+++ /dev/null
@@ -1,201 +0,0 @@
-# empty gem_prelude.rb
-#
-# p Gem::Enable
-
-if defined?(Gem::Enable) && Gem::Enable
-#t = Time.now
-
-module Kernel
-
- def gem(gem_name, *version_requirements)
- Gem.push_gem_version_on_load_path(gem_name, *version_requirements)
- end
-
-end
-
-module Gem
-
- ConfigMap = {
- :sitedir => RbConfig::CONFIG["sitedir"],
- :ruby_version => RbConfig::CONFIG["ruby_version"],
- :libdir => RbConfig::CONFIG["libdir"],
- :sitelibdir => RbConfig::CONFIG["sitelibdir"],
- :arch => RbConfig::CONFIG["arch"],
- :bindir => RbConfig::CONFIG["bindir"],
- :EXEEXT => RbConfig::CONFIG["EXEEXT"],
- :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
- :ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
- }
-
- class << self
-
- def default_dir
- if defined? RUBY_FRAMEWORK_VERSION
- return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
- else
- File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
- end
- end
-
- def dir
- @gem_home ||= nil
- set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
- @gem_home
- end
-
- def path
- @gem_path ||= nil
- unless @gem_path
- paths = [ENV['GEM_PATH']]
- paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
- set_paths(paths.compact.join(File::PATH_SEPARATOR))
- end
- @gem_path
- end
-
- # Set the Gem home directory (as reported by +dir+).
- def set_home(home)
- @gem_home = home
- ensure_gem_subdirectories(@gem_home)
- end
-
- def set_paths(gpaths)
- if gpaths
- @gem_path = gpaths.split(File::PATH_SEPARATOR)
- @gem_path << Gem.dir
- else
- @gem_path = [Gem.dir]
- end
- @gem_path.uniq!
- @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
- end
-
- def ensure_gem_subdirectories(path)
- end
-
- end
-
- module QuickLoader
-
- class << self
- def load_full_rubygems_library
- class << Gem
- Gem.methods(false).each do |method_name|
- undef_method method_name
- end
- end
-
- Kernel.send :undef_method, :gem
-
- $".delete File.join(Gem::ConfigMap[:libdir], 'ruby',
- Gem::ConfigMap[:ruby_version], 'rubygems.rb')
-
- require 'rubygems'
- end
- end
-
- GemPaths = {}
- GemVersions = {}
-
- def push_gem_version_on_load_path(gem_name, *version_requirements)
- if version_requirements.empty?
- unless GemPaths.has_key?(gem_name)
- raise LoadError.new("Could not find RubyGem #{gem_name} (>= 0)\n")
- end
- # highest version gems already active
- return false
- else
- if version_requirements.length > 1
- QuickLoader.load_full_rubygems_library
- return gem(gem_name, *version_requirements)
- end
- requirement, version = version_requirements[0].split
- requirement.strip!
- if requirement == ">" || requirement == ">="
- if (GemVersions[gem_name] <=> Gem.calculate_integers_for_gem_version(version)) >= 0
- return false
- end
- elsif requirement == "~>"
- loaded_version = GemVersions[gem_name]
- required_version = Gem.calculate_integers_for_gem_version(version)
- if loaded_version && (loaded_version[0] == required_version[0])
- return false
- end
- end
- QuickLoader.load_full_rubygems_library
- gem(gem_name, *version_requirements)
- end
- end
-
- def calculate_integers_for_gem_version(gem_version)
- numbers = gem_version.split(".").collect {|n| n.to_i}
- numbers.pop while numbers.last == 0
- numbers << 0 if numbers.empty?
- numbers
- end
-
- def push_all_highest_version_gems_on_load_path
- Gem.path.each do |path|
- gems_directory = File.join(path, "gems")
- if File.exist?(gems_directory)
- Dir.entries(gems_directory).each do |gem_directory_name|
- next if gem_directory_name == "." || gem_directory_name == ".."
- dash = gem_directory_name.rindex("-")
- next if dash.nil?
- gem_name = gem_directory_name[0...dash]
- current_version = GemVersions[gem_name]
- new_version = calculate_integers_for_gem_version(gem_directory_name[dash+1..-1])
- if current_version
- if (current_version <=> new_version) == -1
- GemVersions[gem_name] = new_version
- GemPaths[gem_name] = File.join(gems_directory, gem_directory_name)
- end
- else
- GemVersions[gem_name] = new_version
- GemPaths[gem_name] = File.join(gems_directory, gem_directory_name)
- end
- end
- end
- end
- require_paths = []
- GemPaths.values.each do |path|
- if File.exist?(File.join(path, ".require_paths"))
- require_paths.concat(File.read(File.join(path, ".require_paths")).split.map {|require_path| File.join(path, require_path)})
- else
- require_paths << File.join(path, "bin") if File.exist?(File.join(path, "bin"))
- require_paths << File.join(path, "lib") if File.exist?(File.join(path, "lib"))
- end
- end
-
- # gem directories must come after -I and ENV['RUBYLIB']
- $:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths
- end
-
- def const_missing(constant)
- QuickLoader.load_full_rubygems_library
- Gem.const_get(constant)
- end
-
- def method_missing(method, *args, &block)
- QuickLoader.load_full_rubygems_library
- super unless Gem.respond_to?(method)
- Gem.send(method, *args, &block)
- end
- end
-
- extend QuickLoader
-
-end
-
-begin
- Gem.push_all_highest_version_gems_on_load_path
- $" << File.join(Gem::ConfigMap[:libdir], "ruby",
- Gem::ConfigMap[:ruby_version], "rubygems.rb")
-rescue Exception => e
- puts "Error loading gem paths on load path in gem_prelude"
- puts e
- puts e.backtrace.join("\n")
-end
-
-#puts "Gem load in #{Time.now - t} seconds"
-end # Gem::Enable
diff --git a/golf_prelude.rb b/golf_prelude.rb
deleted file mode 100644
index a4b2753095..0000000000
--- a/golf_prelude.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class Object
- def method_missing m, *a, &b
- r = /^#{m}/
- t = (methods + private_methods).sort.find{|e|r=~e}
- t ? __send__(t, *a, &b) : super
- end
-
- def h(a='H', b='w', c='!')
- puts "#{a}ello, #{b}orld#{c}"
- end
-end
diff --git a/goruby.c b/goruby.c
deleted file mode 100644
index d16ea11d5e..0000000000
--- a/goruby.c
+++ /dev/null
@@ -1,3 +0,0 @@
-void Init_golf(void);
-#define RUBY_MAIN_INIT() Init_golf()
-#include "main.c"
diff --git a/hash.c b/hash.c
index 56b2bef935..3f269becb5 100644
--- a/hash.c
+++ b/hash.c
@@ -6,28 +6,37 @@
$Date$
created at: Mon Nov 22 18:51:18 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/st.h"
-#include "ruby/util.h"
-#include "ruby/signal.h"
+#include "ruby.h"
+#include "st.h"
+#include "util.h"
+#include "rubysig.h"
#ifdef __APPLE__
#include <crt_externs.h>
#endif
-static VALUE rb_hash_s_try_convert(VALUE, VALUE);
-
#define HASH_DELETED FL_USER1
#define HASH_PROC_DEFAULT FL_USER2
+static void
+rb_hash_modify(hash)
+ VALUE hash;
+{
+ if (!RHASH(hash)->tbl) rb_raise(rb_eTypeError, "uninitialized Hash");
+ if (OBJ_FROZEN(hash)) rb_error_frozen("hash");
+ if (!OBJ_TAINTED(hash) && rb_safe_level() >= 4)
+ rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
+}
+
VALUE
-rb_hash_freeze(VALUE hash)
+rb_hash_freeze(hash)
+ VALUE hash;
{
return rb_obj_freeze(hash);
}
@@ -35,16 +44,18 @@ rb_hash_freeze(VALUE hash)
VALUE rb_cHash;
static VALUE envtbl;
-static ID id_hash, id_yield, id_default;
+static ID id_hash, id_call, id_default;
static VALUE
-eql(VALUE *args)
+eql(args)
+ VALUE *args;
{
return (VALUE)rb_eql(args[0], args[1]);
}
static int
-rb_any_cmp(VALUE a, VALUE b)
+rb_any_cmp(a, b)
+ VALUE a, b;
{
VALUE args[2];
@@ -67,24 +78,27 @@ rb_any_cmp(VALUE a, VALUE b)
}
VALUE
-rb_hash(VALUE obj)
+rb_hash(obj)
+ VALUE obj;
{
return rb_funcall(obj, id_hash, 0);
}
static int
-rb_any_hash(VALUE a)
+rb_any_hash(a)
+ VALUE a;
{
VALUE hval;
+ int hnum;
switch (TYPE(a)) {
case T_FIXNUM:
case T_SYMBOL:
- return (int)a;
+ hnum = (int)a;
break;
case T_STRING:
- return rb_str_hash(a);
+ hnum = rb_str_hash(a);
break;
default:
@@ -92,11 +106,13 @@ rb_any_hash(VALUE a)
if (!FIXNUM_P(hval)) {
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
}
- return (int)FIX2LONG(hval);
+ hnum = (int)FIX2LONG(hval);
}
+ hnum <<= 1;
+ return RSHIFT(hnum, 1);
}
-static const struct st_hash_type objhash = {
+static struct st_hash_type objhash = {
rb_any_cmp,
rb_any_hash,
};
@@ -110,7 +126,9 @@ struct foreach_safe_arg {
};
static int
-foreach_safe_i(st_data_t key, st_data_t value, struct foreach_safe_arg *arg)
+foreach_safe_i(key, value, arg)
+ st_data_t key, value;
+ struct foreach_safe_arg *arg;
{
int status;
@@ -123,7 +141,10 @@ foreach_safe_i(st_data_t key, st_data_t value, struct foreach_safe_arg *arg)
}
void
-st_foreach_safe(st_table *table, int (*func)(ANYARGS), st_data_t a)
+st_foreach_safe(table, func, a)
+ st_table *table;
+ int (*func)();
+ st_data_t a;
{
struct foreach_safe_arg arg;
@@ -144,37 +165,40 @@ struct hash_foreach_arg {
};
static int
-hash_foreach_iter(VALUE key, VALUE value, struct hash_foreach_arg *arg)
+hash_foreach_iter(key, value, arg)
+ VALUE key, value;
+ struct hash_foreach_arg *arg;
{
int status;
st_table *tbl;
- tbl = RHASH(arg->hash)->ntbl;
+ tbl = RHASH(arg->hash)->tbl;
if (key == Qundef) return ST_CONTINUE;
status = (*arg->func)(key, value, arg->arg);
- if (RHASH(arg->hash)->ntbl != tbl) {
+ if (RHASH(arg->hash)->tbl != tbl) {
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
}
switch (status) {
case ST_DELETE:
- st_delete_safe(tbl, (st_data_t*)&key, 0, Qundef);
+ st_delete_safe(tbl, (st_data_t*)&key, 0, Qundef);
FL_SET(arg->hash, HASH_DELETED);
case ST_CONTINUE:
- break;
+ break;
case ST_STOP:
- return ST_STOP;
+ return ST_STOP;
}
return ST_CHECK;
}
static VALUE
-hash_foreach_ensure(VALUE hash)
+hash_foreach_ensure(hash)
+ VALUE hash;
{
RHASH(hash)->iter_lev--;
if (RHASH(hash)->iter_lev == 0) {
if (FL_TEST(hash, HASH_DELETED)) {
- st_cleanup_safe(RHASH(hash)->ntbl, Qundef);
+ st_cleanup_safe(RHASH(hash)->tbl, Qundef);
FL_UNSET(hash, HASH_DELETED);
}
}
@@ -182,21 +206,23 @@ hash_foreach_ensure(VALUE hash)
}
static VALUE
-hash_foreach_call(struct hash_foreach_arg *arg)
+hash_foreach_call(arg)
+ struct hash_foreach_arg *arg;
{
- if (st_foreach(RHASH(arg->hash)->ntbl, hash_foreach_iter, (st_data_t)arg)) {
+ if (st_foreach(RHASH(arg->hash)->tbl, hash_foreach_iter, (st_data_t)arg)) {
rb_raise(rb_eRuntimeError, "hash modified during iteration");
}
return Qnil;
}
void
-rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
+rb_hash_foreach(hash, func, farg)
+ VALUE hash;
+ int (*func)();
+ VALUE farg;
{
struct hash_foreach_arg arg;
- if (!RHASH(hash)->ntbl)
- return;
RHASH(hash)->iter_lev++;
arg.hash = hash;
arg.func = (rb_foreach_func *)func;
@@ -204,8 +230,11 @@ rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
}
+static VALUE hash_alloc0 _((VALUE));
+static VALUE hash_alloc _((VALUE));
static VALUE
-hash_alloc(VALUE klass)
+hash_alloc0(klass)
+ VALUE klass;
{
NEWOBJ(hash, struct RHash);
OBJSETUP(hash, klass, T_HASH);
@@ -215,34 +244,21 @@ hash_alloc(VALUE klass)
return (VALUE)hash;
}
-VALUE
-rb_hash_new(void)
+static VALUE
+hash_alloc(klass)
+ VALUE klass;
{
- return hash_alloc(rb_cHash);
-}
+ VALUE hash = hash_alloc0(klass);
-static void
-rb_hash_modify_check(VALUE hash)
-{
- if (OBJ_FROZEN(hash)) rb_error_frozen("hash");
- if (!OBJ_TAINTED(hash) && rb_safe_level() >= 4)
- rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
-}
+ RHASH(hash)->tbl = st_init_table(&objhash);
-struct st_table *
-rb_hash_tbl(VALUE hash)
-{
- if (!RHASH(hash)->ntbl) {
- RHASH(hash)->ntbl = st_init_table(&objhash);
- }
- return RHASH(hash)->ntbl;
+ return hash;
}
-static void
-rb_hash_modify(VALUE hash)
+VALUE
+rb_hash_new()
{
- rb_hash_modify_check(hash);
- rb_hash_tbl(hash);
+ return hash_alloc(rb_cHash);
}
/*
@@ -281,7 +297,10 @@ rb_hash_modify(VALUE hash)
*/
static VALUE
-rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
+rb_hash_initialize(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
{
VALUE ifnone;
@@ -315,18 +334,19 @@ rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
*/
static VALUE
-rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
+rb_hash_s_create(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE hash, tmp;
int i;
if (argc == 1) {
- tmp = rb_hash_s_try_convert(Qnil, argv[0]);
+ tmp = rb_check_convert_type(argv[0], T_HASH, "Hash", "to_hash");
if (!NIL_P(tmp)) {
- hash = hash_alloc(klass);
- if (RHASH(argv[0])->ntbl) {
- RHASH(hash)->ntbl = st_copy(RHASH(argv[0])->ntbl);
- }
+ hash = hash_alloc0(klass);
+ RHASH(hash)->tbl = st_copy(RHASH(tmp)->tbl);
return hash;
}
@@ -358,30 +378,16 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-to_hash(VALUE hash)
+to_hash(hash)
+ VALUE hash;
{
return rb_convert_type(hash, T_HASH, "Hash", "to_hash");
}
-/*
- * call-seq:
- * Hash.try_convert(obj) -> hash or nil
- *
- * Try to convert <i>obj</i> into a hash, using to_hash method.
- * Returns converted hash or nil if <i>obj</i> cannot be converted
- * for any reason.
- *
- * Hash.try_convert({1=>2}) # => {1=>2}
- * Hash.try_convert("1=>2") # => nil
- */
-static VALUE
-rb_hash_s_try_convert(VALUE dummy, VALUE hash)
-{
- return rb_check_convert_type(hash, T_HASH, "Hash", "to_hash");
-}
-
static int
-rb_hash_rehash_i(VALUE key, VALUE value, st_table *tbl)
+rb_hash_rehash_i(key, value, tbl)
+ VALUE key, value;
+ st_table *tbl;
{
if (key != Qundef) st_insert(tbl, key, value);
return ST_CONTINUE;
@@ -395,7 +401,7 @@ rb_hash_rehash_i(VALUE key, VALUE value, st_table *tbl)
* values of key objects have changed since they were inserted, this
* method will reindex <i>hsh</i>. If <code>Hash#rehash</code> is
* called while an iterator is traversing the hash, an
- * <code>RuntimeError</code> will be raised in the iterator.
+ * <code>IndexError</code> will be raised in the iterator.
*
* a = [ "a", "b" ]
* c = [ "c", "d" ]
@@ -408,20 +414,16 @@ rb_hash_rehash_i(VALUE key, VALUE value, st_table *tbl)
*/
static VALUE
-rb_hash_rehash(VALUE hash)
+rb_hash_rehash(hash)
+ VALUE hash;
{
st_table *tbl;
- if (RHASH(hash)->iter_lev > 0) {
- rb_raise(rb_eRuntimeError, "rehash during iteration");
- }
- rb_hash_modify_check(hash);
- if (!RHASH(hash)->ntbl)
- return hash;
- tbl = st_init_table_with_size(RHASH(hash)->ntbl->type, RHASH(hash)->ntbl->num_entries);
+ rb_hash_modify(hash);
+ tbl = st_init_table_with_size(&objhash, RHASH(hash)->tbl->num_entries);
rb_hash_foreach(hash, rb_hash_rehash_i, (st_data_t)tbl);
- st_free_table(RHASH(hash)->ntbl);
- RHASH(hash)->ntbl = tbl;
+ st_free_table(RHASH(hash)->tbl);
+ RHASH(hash)->tbl = tbl;
return hash;
}
@@ -441,22 +443,24 @@ rb_hash_rehash(VALUE hash)
*/
VALUE
-rb_hash_aref(VALUE hash, VALUE key)
+rb_hash_aref(hash, key)
+ VALUE hash, key;
{
VALUE val;
- if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
+ if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
return rb_funcall(hash, id_default, 1, key);
}
return val;
}
VALUE
-rb_hash_lookup(VALUE hash, VALUE key)
+rb_hash_lookup(hash, key)
+ VALUE hash, key;
{
VALUE val;
- if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
+ if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
return Qnil; /* without Hash#default */
}
return val;
@@ -469,7 +473,7 @@ rb_hash_lookup(VALUE hash, VALUE key)
*
* Returns a value from the hash for the given key. If the key can't be
* found, there are several options: With no other arguments, it will
- * raise an <code>KeyError</code> exception; if <i>default</i> is
+ * raise an <code>IndexError</code> exception; if <i>default</i> is
* given, then that will be returned; if the optional code block is
* specified, then that will be run and its result returned.
*
@@ -486,13 +490,16 @@ rb_hash_lookup(VALUE hash, VALUE key)
*
* <em>produces:</em>
*
- * prog.rb:2:in `fetch': key not found (KeyError)
+ * prog.rb:2:in `fetch': key not found (IndexError)
* from prog.rb:2
*
*/
static VALUE
-rb_hash_fetch(int argc, VALUE *argv, VALUE hash)
+rb_hash_fetch(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
{
VALUE key, if_none;
VALUE val;
@@ -504,10 +511,10 @@ rb_hash_fetch(int argc, VALUE *argv, VALUE hash)
if (block_given && argc == 2) {
rb_warn("block supersedes default value argument");
}
- if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
+ if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
if (block_given) return rb_yield(key);
if (argc == 1) {
- rb_raise(rb_eKeyError, "key not found");
+ rb_raise(rb_eIndexError, "key not found");
}
return if_none;
}
@@ -531,19 +538,22 @@ rb_hash_fetch(int argc, VALUE *argv, VALUE hash)
* h.default(2) #=> "cat"
*
* h = Hash.new {|h,k| h[k] = k.to_i*10} #=> {}
- * h.default #=> 0
+ * h.default #=> nil
* h.default(2) #=> 20
*/
static VALUE
-rb_hash_default(int argc, VALUE *argv, VALUE hash)
+rb_hash_default(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
{
VALUE key;
rb_scan_args(argc, argv, "01", &key);
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
if (argc == 0) return Qnil;
- return rb_funcall(RHASH(hash)->ifnone, id_yield, 2, hash, key);
+ return rb_funcall(RHASH(hash)->ifnone, id_call, 2, hash, key);
}
return RHASH(hash)->ifnone;
}
@@ -569,7 +579,8 @@ rb_hash_default(int argc, VALUE *argv, VALUE hash)
*/
static VALUE
-rb_hash_set_default(VALUE hash, VALUE ifnone)
+rb_hash_set_default(hash, ifnone)
+ VALUE hash, ifnone;
{
rb_hash_modify(hash);
RHASH(hash)->ifnone = ifnone;
@@ -593,7 +604,8 @@ rb_hash_set_default(VALUE hash, VALUE ifnone)
static VALUE
-rb_hash_default_proc(VALUE hash)
+rb_hash_default_proc(hash)
+ VALUE hash;
{
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
return RHASH(hash)->ifnone;
@@ -602,7 +614,9 @@ rb_hash_default_proc(VALUE hash)
}
static int
-key_i(VALUE key, VALUE value, VALUE *args)
+index_i(key, value, args)
+ VALUE key, value;
+ VALUE *args;
{
if (rb_equal(value, args[0])) {
args[1] = key;
@@ -611,55 +625,75 @@ key_i(VALUE key, VALUE value, VALUE *args)
return ST_CONTINUE;
}
+static VALUE
+rb_hash_delete_key(hash, key)
+ VALUE hash, key;
+{
+ st_data_t ktmp = (st_data_t)key, val;
+
+ if (RHASH(hash)->iter_lev > 0) {
+ if (st_delete_safe(RHASH(hash)->tbl, &ktmp, &val, Qundef)) {
+ FL_SET(hash, HASH_DELETED);
+ return (VALUE)val;
+ }
+ }
+ else if (st_delete(RHASH(hash)->tbl, &ktmp, &val))
+ return (VALUE)val;
+ return Qundef;
+}
+
/*
* call-seq:
- * hsh.key(value) => key
+ * hsh.index(value) => key
*
* Returns the key for a given value. If not found, returns <code>nil</code>.
*
* h = { "a" => 100, "b" => 200 }
- * h.key(200) #=> "b"
- * h.key(999) #=> nil
+ * h.index(200) #=> "b"
+ * h.index(999) #=> nil
*
*/
static VALUE
-rb_hash_key(VALUE hash, VALUE value)
+rb_hash_index(hash, value)
+ VALUE hash, value;
{
VALUE args[2];
args[0] = value;
args[1] = Qnil;
- rb_hash_foreach(hash, key_i, (st_data_t)args);
+ rb_hash_foreach(hash, index_i, (st_data_t)args);
return args[1];
}
-/* :nodoc: */
-static VALUE
-rb_hash_index(VALUE hash, VALUE value)
-{
- rb_warn("Hash#index is deprecated; use Hash#key");
- return rb_hash_key(hash, value);
-}
+/*
+ * call-seq:
+ * hsh.indexes(key, ...) => array
+ * hsh.indices(key, ...) => array
+ *
+ * Deprecated in favor of <code>Hash#select</code>.
+ *
+ */
static VALUE
-rb_hash_delete_key(VALUE hash, VALUE key)
+rb_hash_indexes(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
{
- st_data_t ktmp = (st_data_t)key, val;
+ VALUE indexes;
+ int i;
- if (!RHASH(hash)->ntbl)
- return Qundef;
- if (RHASH(hash)->iter_lev > 0) {
- if (st_delete_safe(RHASH(hash)->ntbl, &ktmp, &val, Qundef)) {
- FL_SET(hash, HASH_DELETED);
- return (VALUE)val;
- }
+ rb_warn("Hash#%s is deprecated; use Hash#values_at",
+ rb_id2name(rb_frame_last_func()));
+ indexes = rb_ary_new2(argc);
+ for (i=0; i<argc; i++) {
+ RARRAY(indexes)->ptr[i] = rb_hash_aref(hash, argv[i]);
+ RARRAY(indexes)->len++;
}
- else if (st_delete(RHASH(hash)->ntbl, &ktmp, &val))
- return (VALUE)val;
- return Qundef;
+ return indexes;
}
/*
@@ -668,10 +702,9 @@ rb_hash_delete_key(VALUE hash, VALUE key)
* hsh.delete(key) {| key | block } => value
*
* Deletes and returns a key-value pair from <i>hsh</i> whose key is
- * equal to <i>key</i>. If the key is not found, returns the
- * <em>default value</em>. If the optional code block is given and the
- * key is not found, pass in the key and return the result of
- * <i>block</i>.
+ * equal to <i>key</i>. If the key is not found, returns <code>nil</code>.
+ * If the optional code block is given and the key is not found,
+ * pass in the key and return the result of <i>block</i>.
*
* h = { "a" => 100, "b" => 200 }
* h.delete("a") #=> 100
@@ -681,7 +714,8 @@ rb_hash_delete_key(VALUE hash, VALUE key)
*/
VALUE
-rb_hash_delete(VALUE hash, VALUE key)
+rb_hash_delete(hash, key)
+ VALUE hash, key;
{
VALUE val;
@@ -700,7 +734,9 @@ struct shift_var {
};
static int
-shift_i(VALUE key, VALUE value, struct shift_var *var)
+shift_i(key, value, var)
+ VALUE key, value;
+ struct shift_var *var;
{
if (key == Qundef) return ST_CONTINUE;
if (var->key != Qundef) return ST_STOP;
@@ -710,7 +746,9 @@ shift_i(VALUE key, VALUE value, struct shift_var *var)
}
static int
-shift_i_safe(VALUE key, VALUE value, struct shift_var *var)
+shift_i_safe(key, value, var)
+ VALUE key, value;
+ struct shift_var *var;
{
if (key == Qundef) return ST_CONTINUE;
var->key = key;
@@ -732,23 +770,31 @@ shift_i_safe(VALUE key, VALUE value, struct shift_var *var)
*/
static VALUE
-rb_hash_shift(VALUE hash)
+rb_hash_shift(hash)
+ VALUE hash;
{
struct shift_var var;
rb_hash_modify(hash);
var.key = Qundef;
- rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i,
- (st_data_t)&var);
+ if (RHASH(hash)->iter_lev > 0) {
+ rb_hash_foreach(hash, shift_i_safe, (st_data_t)&var);
+ if (var.key != Qundef) {
+ st_data_t key = var.key;
+ if (st_delete_safe(RHASH(hash)->tbl, &key, 0, Qundef)) {
+ FL_SET(hash, HASH_DELETED);
+ }
+ }
+ }
+ else {
+ rb_hash_foreach(hash, shift_i, (st_data_t)&var);
+ }
if (var.key != Qundef) {
- if (RHASH(hash)->iter_lev > 0) {
- rb_hash_delete_key(hash, var.key);
- }
return rb_assoc_new(var.key, var.val);
}
else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
- return rb_funcall(RHASH(hash)->ifnone, id_yield, 2, hash, Qnil);
+ return rb_funcall(RHASH(hash)->ifnone, id_call, 2, hash, Qnil);
}
else {
return RHASH(hash)->ifnone;
@@ -756,7 +802,8 @@ rb_hash_shift(VALUE hash)
}
static int
-delete_if_i(VALUE key, VALUE value, VALUE hash)
+delete_if_i(key, value, hash)
+ VALUE key, value, hash;
{
if (key == Qundef) return ST_CONTINUE;
if (RTEST(rb_yield_values(2, key, value))) {
@@ -778,8 +825,10 @@ delete_if_i(VALUE key, VALUE value, VALUE hash)
*/
VALUE
-rb_hash_delete_if(VALUE hash)
+rb_hash_delete_if(hash)
+ VALUE hash;
{
+ RETURN_ENUMERATOR(hash, 0, 0);
rb_hash_modify(hash);
rb_hash_foreach(hash, delete_if_i, hash);
return hash;
@@ -794,14 +843,15 @@ rb_hash_delete_if(VALUE hash)
*/
VALUE
-rb_hash_reject_bang(VALUE hash)
+rb_hash_reject_bang(hash)
+ VALUE hash;
{
int n;
- if (!RHASH(hash)->ntbl)
- return Qnil;
- n = RHASH(hash)->ntbl->num_entries;
+
+ RETURN_ENUMERATOR(hash, 0, 0);
+ n = RHASH(hash)->tbl->num_entries;
rb_hash_delete_if(hash);
- if (n == RHASH(hash)->ntbl->num_entries) return Qnil;
+ if (n == RHASH(hash)->tbl->num_entries) return Qnil;
return hash;
}
@@ -816,11 +866,22 @@ rb_hash_reject_bang(VALUE hash)
*/
static VALUE
-rb_hash_reject(VALUE hash)
+rb_hash_reject(hash)
+ VALUE hash;
{
return rb_hash_delete_if(rb_obj_dup(hash));
}
+static int
+select_i(key, value, result)
+ VALUE key, value, result;
+{
+ if (key == Qundef) return ST_CONTINUE;
+ if (RTEST(rb_yield_values(2, key, value)))
+ rb_ary_push(result, rb_assoc_new(key, value));
+ return ST_CONTINUE;
+}
+
/*
* call-seq:
* hsh.values_at(key, ...) => array
@@ -830,12 +891,15 @@ rb_hash_reject(VALUE hash)
*
* h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
* h.values_at("cow", "cat") #=> ["bovine", "feline"]
-*/
+ */
VALUE
-rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
+rb_hash_values_at(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
{
- VALUE result = rb_ary_new2(argc);
+ VALUE result = rb_ary_new();
long i;
for (i=0; i<argc; i++) {
@@ -844,39 +908,34 @@ rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
return result;
}
-static int
-select_i(VALUE key, VALUE value, VALUE result)
-{
- if (key == Qundef) return ST_CONTINUE;
- if (RTEST(rb_yield_values(2, key, value)))
- rb_hash_aset(result, key, value);
- return ST_CONTINUE;
-}
-
/*
* call-seq:
- * hsh.select {|key, value| block} => a_hash
+ * hsh.select {|key, value| block} => array
*
- * Returns a new hash consisting of entries which the block returns true.
+ * Returns a new array consisting of <code>[key,value]</code>
+ * pairs for which the block returns true.
+ * Also see <code>Hash.values_at</code>.
*
* h = { "a" => 100, "b" => 200, "c" => 300 }
- * h.select {|k,v| k > "a"} #=> {"b" => 200, "c" => 300}
- * h.select {|k,v| v < 200} #=> {"a" => 100}
+ * h.select {|k,v| k > "a"} #=> [["b", 200], ["c", 300]]
+ * h.select {|k,v| v < 200} #=> [["a", 100]]
*/
VALUE
-rb_hash_select(VALUE hash)
+rb_hash_select(hash)
+ VALUE hash;
{
VALUE result;
RETURN_ENUMERATOR(hash, 0, 0);
- result = rb_hash_new();
+ result = rb_ary_new();
rb_hash_foreach(hash, select_i, result);
return result;
}
static int
-clear_i(VALUE key, VALUE value, VALUE dummy)
+clear_i(key, value, dummy)
+ VALUE key, value, dummy;
{
return ST_DELETE;
}
@@ -893,16 +952,12 @@ clear_i(VALUE key, VALUE value, VALUE dummy)
*/
static VALUE
-rb_hash_clear(VALUE hash)
+rb_hash_clear(hash)
+ VALUE hash;
{
- rb_hash_modify_check(hash);
- if (!RHASH(hash)->ntbl)
- return hash;
- if (RHASH(hash)->ntbl->num_entries > 0) {
- if (RHASH(hash)->iter_lev > 0)
- rb_hash_foreach(hash, clear_i, 0);
- else
- st_clear(RHASH(hash)->ntbl);
+ rb_hash_modify(hash);
+ if (RHASH(hash)->tbl->num_entries > 0) {
+ rb_hash_foreach(hash, clear_i, 0);
}
return hash;
@@ -927,20 +982,22 @@ rb_hash_clear(VALUE hash)
*/
VALUE
-rb_hash_aset(VALUE hash, VALUE key, VALUE val)
+rb_hash_aset(hash, key, val)
+ VALUE hash, key, val;
{
rb_hash_modify(hash);
- if (TYPE(key) != T_STRING || st_lookup(RHASH(hash)->ntbl, key, 0)) {
- st_insert(RHASH(hash)->ntbl, key, val);
+ if (TYPE(key) != T_STRING || st_lookup(RHASH(hash)->tbl, key, 0)) {
+ st_insert(RHASH(hash)->tbl, key, val);
}
else {
- st_add_direct(RHASH(hash)->ntbl, rb_str_new4(key), val);
+ st_add_direct(RHASH(hash)->tbl, rb_str_new4(key), val);
}
return val;
}
static int
-replace_i(VALUE key, VALUE val, VALUE hash)
+replace_i(key, val, hash)
+ VALUE key, val, hash;
{
if (key != Qundef) {
rb_hash_aset(hash, key, val);
@@ -962,7 +1019,8 @@ replace_i(VALUE key, VALUE val, VALUE hash)
*/
static VALUE
-rb_hash_replace(VALUE hash, VALUE hash2)
+rb_hash_replace(hash, hash2)
+ VALUE hash, hash2;
{
hash2 = to_hash(hash2);
if (hash == hash2) return hash;
@@ -993,11 +1051,10 @@ rb_hash_replace(VALUE hash, VALUE hash2)
*/
static VALUE
-rb_hash_size(VALUE hash)
+rb_hash_size(hash)
+ VALUE hash;
{
- if (!RHASH(hash)->ntbl)
- return INT2FIX(0);
- return INT2FIX(RHASH(hash)->ntbl->num_entries);
+ return INT2FIX(RHASH(hash)->tbl->num_entries);
}
@@ -1012,13 +1069,17 @@ rb_hash_size(VALUE hash)
*/
static VALUE
-rb_hash_empty_p(VALUE hash)
+rb_hash_empty_p(hash)
+ VALUE hash;
{
- return RHASH_EMPTY_P(hash) ? Qtrue : Qfalse;
+ if (RHASH(hash)->tbl->num_entries == 0)
+ return Qtrue;
+ return Qfalse;
}
static int
-each_value_i(VALUE key, VALUE value)
+each_value_i(key, value)
+ VALUE key, value;
{
if (key == Qundef) return ST_CONTINUE;
rb_yield(value);
@@ -1042,7 +1103,8 @@ each_value_i(VALUE key, VALUE value)
*/
static VALUE
-rb_hash_each_value(VALUE hash)
+rb_hash_each_value(hash)
+ VALUE hash;
{
RETURN_ENUMERATOR(hash, 0, 0);
rb_hash_foreach(hash, each_value_i, 0);
@@ -1050,7 +1112,8 @@ rb_hash_each_value(VALUE hash)
}
static int
-each_key_i(VALUE key, VALUE value)
+each_key_i(key, value)
+ VALUE key, value;
{
if (key == Qundef) return ST_CONTINUE;
rb_yield(key);
@@ -1073,7 +1136,8 @@ each_key_i(VALUE key, VALUE value)
* b
*/
static VALUE
-rb_hash_each_key(VALUE hash)
+rb_hash_each_key(hash)
+ VALUE hash;
{
RETURN_ENUMERATOR(hash, 0, 0);
rb_hash_foreach(hash, each_key_i, 0);
@@ -1081,7 +1145,43 @@ rb_hash_each_key(VALUE hash)
}
static int
-each_pair_i(VALUE key, VALUE value)
+each_pair_i(key, value)
+ VALUE key, value;
+{
+ if (key == Qundef) return ST_CONTINUE;
+ rb_yield_values(2, key, value);
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * hsh.each_pair {| key_value_array | block } -> hsh
+ *
+ * Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
+ * and value as parameters.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.each_pair {|key, value| puts "#{key} is #{value}" }
+ *
+ * <em>produces:</em>
+ *
+ * a is 100
+ * b is 200
+ *
+ */
+
+static VALUE
+rb_hash_each_pair(hash)
+ VALUE hash;
+{
+ RETURN_ENUMERATOR(hash, 0, 0);
+ rb_hash_foreach(hash, each_pair_i, 0);
+ return hash;
+}
+
+static int
+each_i(key, value)
+ VALUE key, value;
{
if (key == Qundef) return ST_CONTINUE;
rb_yield(rb_assoc_new(key, value));
@@ -1091,10 +1191,12 @@ each_pair_i(VALUE key, VALUE value)
/*
* call-seq:
* hsh.each {| key, value | block } -> hsh
- * hsh.each_pair {| key, value | block } -> hsh
*
- * Calls <i>block</i> once for each key in <i>hsh</i>, passing the key-value
- * pair as parameters.
+ * Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
+ * and value to the block as a two-element array. Because of the assignment
+ * semantics of block parameters, these elements will be split out if the
+ * block has two formal parameters. Also see <code>Hash.each_pair</code>, which
+ * will be marginally more efficient for blocks with two parameters.
*
* h = { "a" => 100, "b" => 200 }
* h.each {|key, value| puts "#{key} is #{value}" }
@@ -1107,15 +1209,17 @@ each_pair_i(VALUE key, VALUE value)
*/
static VALUE
-rb_hash_each_pair(VALUE hash)
+rb_hash_each(hash)
+ VALUE hash;
{
RETURN_ENUMERATOR(hash, 0, 0);
- rb_hash_foreach(hash, each_pair_i, 0);
+ rb_hash_foreach(hash, each_i, 0);
return hash;
}
static int
-to_a_i(VALUE key, VALUE value, VALUE ary)
+to_a_i(key, value, ary)
+ VALUE key, value, ary;
{
if (key == Qundef) return ST_CONTINUE;
rb_ary_push(ary, rb_assoc_new(key, value));
@@ -1134,7 +1238,8 @@ to_a_i(VALUE key, VALUE value, VALUE ary)
*/
static VALUE
-rb_hash_to_a(VALUE hash)
+rb_hash_to_a(hash)
+ VALUE hash;
{
VALUE ary;
@@ -1145,13 +1250,38 @@ rb_hash_to_a(VALUE hash)
return ary;
}
+/*
+ * call-seq:
+ * hsh.sort => array
+ * hsh.sort {| a, b | block } => array
+ *
+ * Converts <i>hsh</i> to a nested array of <code>[</code> <i>key,
+ * value</i> <code>]</code> arrays and sorts it, using
+ * <code>Array#sort</code>.
+ *
+ * h = { "a" => 20, "b" => 30, "c" => 10 }
+ * h.sort #=> [["a", 20], ["b", 30], ["c", 10]]
+ * h.sort {|a,b| a[1]<=>b[1]} #=> [["c", 10], ["a", 20], ["b", 30]]
+ *
+ */
+
+static VALUE
+rb_hash_sort(hash)
+ VALUE hash;
+{
+ VALUE entries = rb_hash_to_a(hash);
+ rb_ary_sort_bang(entries);
+ return entries;
+}
+
static int
-inspect_i(VALUE key, VALUE value, VALUE str)
+inspect_i(key, value, str)
+ VALUE key, value, str;
{
VALUE str2;
if (key == Qundef) return ST_CONTINUE;
- if (RSTRING_LEN(str) > 1) {
+ if (RSTRING(str)->len > 1) {
rb_str_cat2(str, ", ");
}
str2 = rb_inspect(key);
@@ -1166,11 +1296,11 @@ inspect_i(VALUE key, VALUE value, VALUE str)
}
static VALUE
-inspect_hash(VALUE hash, VALUE dummy, int recur)
+inspect_hash(hash)
+ VALUE hash;
{
VALUE str;
- if (recur) return rb_str_new2("{...}");
str = rb_str_buf_new2("{");
rb_hash_foreach(hash, inspect_i, str);
rb_str_buf_cat2(str, "}");
@@ -1181,21 +1311,47 @@ inspect_hash(VALUE hash, VALUE dummy, int recur)
/*
* call-seq:
- * hsh.to_s => string
* hsh.inspect => string
*
* Return the contents of this hash as a string.
+ */
+
+static VALUE
+rb_hash_inspect(hash)
+ VALUE hash;
+{
+ if (RHASH(hash)->tbl == 0 || RHASH(hash)->tbl->num_entries == 0)
+ return rb_str_new2("{}");
+ if (rb_inspecting_p(hash)) return rb_str_new2("{...}");
+ return rb_protect_inspect(inspect_hash, hash, 0);
+}
+
+static VALUE
+to_s_hash(hash)
+ VALUE hash;
+{
+ return rb_ary_to_s(rb_hash_to_a(hash));
+}
+
+/*
+ * call-seq:
+ * hsh.to_s => string
+ *
+ * Converts <i>hsh</i> to a string by converting the hash to an array
+ * of <code>[</code> <i>key, value</i> <code>]</code> pairs and then
+ * converting that array to a string using <code>Array#join</code> with
+ * the default separator.
*
* h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
- * h.to_s #=> "{\"a\"=>100, \"c\"=>300, \"d\"=>400}"
+ * h.to_s #=> "a100c300d400"
*/
static VALUE
-rb_hash_inspect(VALUE hash)
+rb_hash_to_s(hash)
+ VALUE hash;
{
- if (RHASH_EMPTY_P(hash))
- return rb_str_new2("{}");
- return rb_exec_recursive(inspect_hash, hash, 0);
+ if (rb_inspecting_p(hash)) return rb_str_new2("{...}");
+ return rb_protect_inspect(to_s_hash, hash, 0);
}
/*
@@ -1206,13 +1362,15 @@ rb_hash_inspect(VALUE hash)
*/
static VALUE
-rb_hash_to_hash(VALUE hash)
+rb_hash_to_hash(hash)
+ VALUE hash;
{
return hash;
}
static int
-keys_i(VALUE key, VALUE value, VALUE ary)
+keys_i(key, value, ary)
+ VALUE key, value, ary;
{
if (key == Qundef) return ST_CONTINUE;
rb_ary_push(ary, key);
@@ -1232,7 +1390,8 @@ keys_i(VALUE key, VALUE value, VALUE ary)
*/
static VALUE
-rb_hash_keys(VALUE hash)
+rb_hash_keys(hash)
+ VALUE hash;
{
VALUE ary;
@@ -1243,7 +1402,8 @@ rb_hash_keys(VALUE hash)
}
static int
-values_i(VALUE key, VALUE value, VALUE ary)
+values_i(key, value, ary)
+ VALUE key, value, ary;
{
if (key == Qundef) return ST_CONTINUE;
rb_ary_push(ary, value);
@@ -1263,7 +1423,8 @@ values_i(VALUE key, VALUE value, VALUE ary)
*/
static VALUE
-rb_hash_values(VALUE hash)
+rb_hash_values(hash)
+ VALUE hash;
{
VALUE ary;
@@ -1289,18 +1450,19 @@ rb_hash_values(VALUE hash)
*/
static VALUE
-rb_hash_has_key(VALUE hash, VALUE key)
+rb_hash_has_key(hash, key)
+ VALUE hash;
+ VALUE key;
{
- if (!RHASH(hash)->ntbl)
- return Qfalse;
- if (st_lookup(RHASH(hash)->ntbl, key, 0)) {
+ if (st_lookup(RHASH(hash)->tbl, key, 0)) {
return Qtrue;
}
return Qfalse;
}
static int
-rb_hash_search_value(VALUE key, VALUE value, VALUE *data)
+rb_hash_search_value(key, value, data)
+ VALUE key, value, *data;
{
if (key == Qundef) return ST_CONTINUE;
if (rb_equal(value, data[1])) {
@@ -1324,7 +1486,9 @@ rb_hash_search_value(VALUE key, VALUE value, VALUE *data)
*/
static VALUE
-rb_hash_has_value(VALUE hash, VALUE val)
+rb_hash_has_value(hash, val)
+ VALUE hash;
+ VALUE val;
{
VALUE data[2];
@@ -1335,13 +1499,16 @@ rb_hash_has_value(VALUE hash, VALUE val)
}
struct equal_data {
- VALUE result;
+ int result;
st_table *tbl;
int eql;
};
static int
-eql_i(VALUE key, VALUE val1, struct equal_data *data)
+eql_i(key, val1, data)
+ VALUE key;
+ VALUE val1;
+ struct equal_data *data;
{
VALUE val2;
@@ -1357,8 +1524,12 @@ eql_i(VALUE key, VALUE val1, struct equal_data *data)
return ST_CONTINUE;
}
+static VALUE recursive_eql _((VALUE, VALUE, int));
static VALUE
-recursive_eql(VALUE hash, VALUE dt, int recur)
+recursive_eql(hash, dt, recur)
+ VALUE hash;
+ VALUE dt;
+ int recur;
{
struct equal_data *data;
@@ -1371,7 +1542,9 @@ recursive_eql(VALUE hash, VALUE dt, int recur)
}
static VALUE
-hash_equal(VALUE hash1, VALUE hash2, int eql)
+hash_equal(hash1, hash2, eql)
+ VALUE hash1, hash2;
+ int eql; /* compare default value if true */
{
struct equal_data data;
@@ -1380,22 +1553,17 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
if (!rb_respond_to(hash2, rb_intern("to_hash"))) {
return Qfalse;
}
- if (eql)
- return rb_eql(hash2, hash1);
- else
- return rb_equal(hash2, hash1);
+ return rb_equal(hash2, hash1);
}
- if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2))
- return Qfalse;
- if (!RHASH(hash1)->ntbl || !RHASH(hash2)->ntbl)
- return Qtrue;
-#if 0
- if (!(rb_equal(RHASH(hash1)->ifnone, RHASH(hash2)->ifnone) &&
- FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT)))
+ if (RHASH(hash1)->tbl->num_entries != RHASH(hash2)->tbl->num_entries)
return Qfalse;
-#endif
+ if (eql) {
+ if (!(rb_equal(RHASH(hash1)->ifnone, RHASH(hash2)->ifnone) &&
+ FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT)))
+ return Qfalse;
+ }
- data.tbl = RHASH(hash2)->ntbl;
+ data.tbl = RHASH(hash2)->tbl;
data.eql = eql;
return rb_exec_recursive(recursive_eql, hash1, (VALUE)&data);
}
@@ -1420,46 +1588,37 @@ hash_equal(VALUE hash1, VALUE hash2, int eql)
*/
static VALUE
-rb_hash_equal(VALUE hash1, VALUE hash2)
+rb_hash_equal(hash1, hash2)
+ VALUE hash1, hash2;
{
return hash_equal(hash1, hash2, Qfalse);
}
-/*
- * call-seq:
- * hash.eql?(other) -> true or false
- *
- * Returns <code>true</code> if <i>hash</i> and <i>other</i> are
- * both hashes with the same content.
- */
-
-static VALUE
-rb_hash_eql(VALUE hash1, VALUE hash2)
-{
- return hash_equal(hash1, hash2, Qtrue);
-}
-
static int
-hash_i(VALUE key, VALUE val, int *hval)
+hash_i(key, val, hval)
+ VALUE key;
+ VALUE val;
+ int *hval;
{
if (key == Qundef) return ST_CONTINUE;
*hval ^= rb_hash(key);
- *hval *= 137;
*hval ^= rb_hash(val);
return ST_CONTINUE;
}
+static VALUE recursive_hash _((VALUE, VALUE, int));
static VALUE
-recursive_hash(VALUE hash, VALUE dummy, int recur)
+recursive_hash(hash, dummy, recur)
+ VALUE hash;
+ VALUE dummy;
+ int recur;
{
int hval;
if (recur) {
return LONG2FIX(0);
}
- if (!RHASH(hash)->ntbl)
- return LONG2FIX(0);
- hval = RHASH(hash)->ntbl->num_entries;
+ hval = RHASH(hash)->tbl->num_entries;
rb_hash_foreach(hash, hash_i, (st_data_t)&hval);
return INT2FIX(hval);
}
@@ -1473,13 +1632,32 @@ recursive_hash(VALUE hash, VALUE dummy, int recur)
*/
static VALUE
-rb_hash_hash(VALUE hash)
+rb_hash_hash(hash)
+ VALUE hash;
{
return rb_exec_recursive(recursive_hash, hash, 0);
}
+
+/*
+ * call-seq:
+ * hash.eql?(other) -> true or false
+ *
+ * Returns <code>true</code> if <i>hash</i> and <i>other</i> are
+ * both hashes with the same content.
+ */
+
+static VALUE
+rb_hash_eql(hash1, hash2)
+ VALUE hash1, hash2;
+{
+ return hash_equal(hash1, hash2, Qtrue);
+}
+
static int
-rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
+rb_hash_invert_i(key, value, hash)
+ VALUE key, value;
+ VALUE hash;
{
if (key == Qundef) return ST_CONTINUE;
rb_hash_aset(hash, value, key);
@@ -1499,7 +1677,8 @@ rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
*/
static VALUE
-rb_hash_invert(VALUE hash)
+rb_hash_invert(hash)
+ VALUE hash;
{
VALUE h = rb_hash_new();
@@ -1508,7 +1687,9 @@ rb_hash_invert(VALUE hash)
}
static int
-rb_hash_update_i(VALUE key, VALUE value, VALUE hash)
+rb_hash_update_i(key, value, hash)
+ VALUE key, value;
+ VALUE hash;
{
if (key == Qundef) return ST_CONTINUE;
rb_hash_aset(hash, key, value);
@@ -1516,7 +1697,9 @@ rb_hash_update_i(VALUE key, VALUE value, VALUE hash)
}
static int
-rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
+rb_hash_update_block_i(key, value, hash)
+ VALUE key, value;
+ VALUE hash;
{
if (key == Qundef) return ST_CONTINUE;
if (rb_hash_has_key(hash, key)) {
@@ -1536,18 +1719,22 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
* Adds the contents of <i>other_hash</i> to <i>hsh</i>. If no
* block is specified entries with duplicate keys are overwritten
* with the values from <i>other_hash</i>, otherwise the value
- * of each duplicate key is detemined by calling the block with
+ * of each duplicate key is determined by calling the block with
* the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
*
* h1 = { "a" => 100, "b" => 200 }
* h2 = { "b" => 254, "c" => 300 }
* h1.merge!(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ *
+ * h1 = { "a" => 100, "b" => 200 }
+ * h2 = { "b" => 254, "c" => 300 }
* h1.merge!(h2) { |key, v1, v2| v1 }
* #=> {"a"=>100, "b"=>200, "c"=>300}
*/
static VALUE
-rb_hash_update(VALUE hash1, VALUE hash2)
+rb_hash_update(hash1, hash2)
+ VALUE hash1, hash2;
{
hash2 = to_hash(hash2);
if (rb_block_given_p()) {
@@ -1576,158 +1763,12 @@ rb_hash_update(VALUE hash1, VALUE hash2)
*/
static VALUE
-rb_hash_merge(VALUE hash1, VALUE hash2)
+rb_hash_merge(hash1, hash2)
+ VALUE hash1, hash2;
{
return rb_hash_update(rb_obj_dup(hash1), hash2);
}
-static int
-assoc_i(VALUE key, VALUE val, VALUE *args)
-{
- if (key == Qundef) return ST_CONTINUE;
- if (RTEST(rb_equal(args[0], key))) {
- args[1] = rb_assoc_new(key, val);
- return ST_STOP;
- }
- return ST_CONTINUE;
-}
-
-/*
- * call-seq:
- * hash.assoc(obj) -> an_array or nil
- *
- * Searches through the hash comparing _obj_ with the key using <code>==</code>.
- * Returns the key-value pair (two elements array) or +nil+
- * if no match is found. See <code>Array#assoc</code>.
- *
- * h = {"colors" => ["red", "blue", "green"],
- * "letters" => ["a", "b", "c" ]}
- * h.assoc("letters") #=> ["letters", ["a", "b", "c"]]
- * h.assoc("foo") #=> nil
- */
-
-VALUE
-rb_hash_assoc(VALUE hash, VALUE obj)
-{
- VALUE args[2];
-
- args[0] = obj;
- args[1] = Qnil;
- rb_hash_foreach(hash, assoc_i, (st_data_t)args);
- return args[1];
-}
-
-static int
-rassoc_i(VALUE key, VALUE val, VALUE *args)
-{
- if (key == Qundef) return ST_CONTINUE;
- if (RTEST(rb_equal(args[0], val))) {
- args[1] = rb_assoc_new(key, val);
- return ST_STOP;
- }
- return ST_CONTINUE;
-}
-
-/*
- * call-seq:
- * hash.rassoc(key) -> an_array or nil
- *
- * Searches through the hash comparing _obj_ with the value using <code>==</code>.
- * Returns the first key-value pair (two elements array) that matches. See
- * also <code>Array#rassoc</code>.
- *
- * a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
- * a.rassoc("two") #=> [2, "two"]
- * a.rassoc("four") #=> nil
- */
-
-VALUE
-rb_hash_rassoc(VALUE hash, VALUE obj)
-{
- VALUE args[2];
-
- args[0] = obj;
- args[1] = Qnil;
- rb_hash_foreach(hash, rassoc_i, (st_data_t)args);
- return args[1];
-}
-
-/*
- * call-seq:
- * hash.flatten -> an_array
- * hash.flatten(level) -> an_array
- *
- * Returns a new array that is a one-dimensional flattening of this
- * hash. That is, for every key or value that is an array, extract
- * its elements into the new array. Unlike Array#flatten, this
- * method does not flatten recursively by default. If the optional
- * <i>level</i> argument determins the level of recursion to flatten.
- *
- * a = {1=> "one", 2 => [2,"two"], 3 => "three"}
- * a.flatten # => [1, "one", 2, [2, "two"], 3, "three"]
- * a.flatten(2) # => [1, "one", 2, 2, "two", 3, "three"]
- */
-
-static VALUE
-rb_hash_flatten(int argc, VALUE *argv, VALUE hash)
-{
- VALUE ary;
-
- ary = rb_hash_to_a(hash);
- rb_funcall2(ary, rb_intern("flatten!"), argc, argv);
- return ary;
-}
-
-static const struct st_hash_type identhash = {
- st_numcmp,
- st_numhash,
-};
-
-/*
- * call-seq:
- * hsh.compare_by_identity => hsh
- *
- * Makes <i>hsh</i> to compare its keys by their identity, i.e. it
- * will consider exact same objects as same keys.
- *
- * h1 = { "a" => 100, "b" => 200, :c => "c" }
- * h1["a"] #=> 100
- * h1.compare_by_identity
- * h1.compare_by_identity? #=> true
- * h1["a"] #=> nil # different objects.
- * h1[:c] #=> "c" # same symbols are all same.
- *
- */
-
-static VALUE
-rb_hash_compare_by_id(VALUE hash)
-{
- rb_hash_modify(hash);
- RHASH(hash)->ntbl->type = &identhash;
- rb_hash_rehash(hash);
- return hash;
-}
-
-/*
- * call-seq:
- * hsh.compare_by_identity? => true or false
- *
- * Returns <code>true</code> if <i>hsh</i> will compare its keys by
- * their identity. Also see <code>Hash#compare_by_identity</code>.
- *
- */
-
-static VALUE
-rb_hash_compare_by_id_p(VALUE hash)
-{
- if (!RHASH(hash)->ntbl)
- return Qfalse;
- if (RHASH(hash)->ntbl->type == &identhash) {
- return Qtrue;
- }
- return Qfalse;
-}
-
static int path_tainted = -1;
static char **origenviron;
@@ -1749,7 +1790,9 @@ extern char **environ;
#endif
static VALUE
-env_str_new(const char *ptr, long len)
+env_str_new(ptr, len)
+ const char *ptr;
+ long len;
{
VALUE str = rb_tainted_str_new(ptr, len);
@@ -1758,21 +1801,23 @@ env_str_new(const char *ptr, long len)
}
static VALUE
-env_str_new2(const char *ptr)
+env_str_new2(ptr)
+ const char *ptr;
{
if (!ptr) return Qnil;
return env_str_new(ptr, strlen(ptr));
}
static VALUE
-env_delete(VALUE obj, VALUE name)
+env_delete(obj, name)
+ VALUE obj, name;
{
char *nam, *val;
rb_secure(4);
SafeStringValue(name);
- nam = RSTRING_PTR(name);
- if (strlen(nam) != RSTRING_LEN(name)) {
+ nam = RSTRING(name)->ptr;
+ if (strlen(nam) != RSTRING(name)->len) {
rb_raise(rb_eArgError, "bad environment variable name");
}
val = getenv(nam);
@@ -1794,7 +1839,8 @@ env_delete(VALUE obj, VALUE name)
}
static VALUE
-env_delete_m(VALUE obj, VALUE name)
+env_delete_m(obj, name)
+ VALUE obj, name;
{
VALUE val;
@@ -1804,14 +1850,15 @@ env_delete_m(VALUE obj, VALUE name)
}
static VALUE
-rb_f_getenv(VALUE obj, VALUE name)
+rb_f_getenv(obj, name)
+ VALUE obj, name;
{
char *nam, *env;
rb_secure(4);
SafeStringValue(name);
- nam = RSTRING_PTR(name);
- if (strlen(nam) != RSTRING_LEN(name)) {
+ nam = RSTRING(name)->ptr;
+ if (strlen(nam) != RSTRING(name)->len) {
rb_raise(rb_eArgError, "bad environment variable name");
}
env = getenv(nam);
@@ -1833,7 +1880,9 @@ rb_f_getenv(VALUE obj, VALUE name)
}
static VALUE
-env_fetch(int argc, VALUE *argv)
+env_fetch(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE key, if_none;
long block_given;
@@ -1846,15 +1895,15 @@ env_fetch(int argc, VALUE *argv)
rb_warn("block supersedes default value argument");
}
SafeStringValue(key);
- nam = RSTRING_PTR(key);
- if (strlen(nam) != RSTRING_LEN(key)) {
+ nam = RSTRING(key)->ptr;
+ if (strlen(nam) != RSTRING(key)->len) {
rb_raise(rb_eArgError, "bad environment variable name");
}
env = getenv(nam);
if (!env) {
if (block_given) return rb_yield(key);
if (argc == 1) {
- rb_raise(rb_eKeyError, "key not found");
+ rb_raise(rb_eIndexError, "key not found");
}
return if_none;
}
@@ -1868,13 +1917,14 @@ env_fetch(int argc, VALUE *argv)
}
static void
-path_tainted_p(char *path)
+path_tainted_p(path)
+ char *path;
{
path_tainted = rb_path_check(path)?0:1;
}
int
-rb_env_path_tainted(void)
+rb_env_path_tainted()
{
if (path_tainted < 0) {
path_tainted_p(getenv(PATH_ENV));
@@ -1884,7 +1934,8 @@ rb_env_path_tainted(void)
#if !defined(_WIN32) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
static int
-envix(const char *nam)
+envix(nam)
+ const char *nam;
{
register int i, len = strlen(nam);
char **env;
@@ -1906,7 +1957,9 @@ envix(const char *nam)
#endif
void
-ruby_setenv(const char *name, const char *value)
+ruby_setenv(name, value)
+ const char *name;
+ const char *value;
{
#if defined(_WIN32)
/* The sane way to deal with the environment.
@@ -1986,13 +2039,15 @@ ruby_setenv(const char *name, const char *value)
}
void
-ruby_unsetenv(const char *name)
+ruby_unsetenv(name)
+ const char *name;
{
ruby_setenv(name, 0);
}
static VALUE
-env_aset(VALUE obj, VALUE nm, VALUE val)
+env_aset(obj, nm, val)
+ VALUE obj, nm, val;
{
char *name, *value;
@@ -2001,15 +2056,17 @@ env_aset(VALUE obj, VALUE nm, VALUE val)
}
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "cannot assign nil; use Hash#delete instead");
+ env_delete(obj, nm);
+ return Qnil;
}
+
StringValue(nm);
StringValue(val);
- name = RSTRING_PTR(nm);
- value = RSTRING_PTR(val);
- if (strlen(name) != RSTRING_LEN(nm))
+ name = RSTRING(nm)->ptr;
+ value = RSTRING(val)->ptr;
+ if (strlen(name) != RSTRING(nm)->len)
rb_raise(rb_eArgError, "bad environment variable name");
- if (strlen(value) != RSTRING_LEN(val))
+ if (strlen(value) != RSTRING(val)->len)
rb_raise(rb_eArgError, "bad environment variable value");
ruby_setenv(name, value);
@@ -2031,7 +2088,7 @@ env_aset(VALUE obj, VALUE nm, VALUE val)
}
static VALUE
-env_keys(void)
+env_keys()
{
char **env;
VALUE ary;
@@ -2051,22 +2108,22 @@ env_keys(void)
}
static VALUE
-env_each_key(VALUE ehash)
+env_each_key(ehash)
+ VALUE ehash;
{
VALUE keys;
long i;
RETURN_ENUMERATOR(ehash, 0, 0);
- rb_secure(4);
- keys = env_keys();
- for (i=0; i<RARRAY_LEN(keys); i++) {
- rb_yield(RARRAY_PTR(keys)[i]);
+ keys = env_keys(); /* rb_secure(4); */
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ rb_yield(RARRAY(keys)->ptr[i]);
}
return ehash;
}
static VALUE
-env_values(void)
+env_values()
{
VALUE ary;
char **env;
@@ -2086,29 +2143,29 @@ env_values(void)
}
static VALUE
-env_each_value(VALUE ehash)
+env_each_value(ehash)
+ VALUE ehash;
{
- VALUE values = env_values();
+ VALUE values;
long i;
RETURN_ENUMERATOR(ehash, 0, 0);
- rb_secure(4);
- values = env_values();
- for (i=0; i<RARRAY_LEN(values); i++) {
- rb_yield(RARRAY_PTR(values)[i]);
+ values = env_values(); /* rb_secure(4); */
+ for (i=0; i<RARRAY(values)->len; i++) {
+ rb_yield(RARRAY(values)->ptr[i]);
}
return ehash;
}
static VALUE
-env_each_pair(VALUE ehash)
+env_each_i(ehash, values)
+ VALUE ehash;
+ int values;
{
char **env;
VALUE ary;
long i;
- RETURN_ENUMERATOR(ehash, 0, 0);
-
rb_secure(4);
ary = rb_ary_new();
env = GET_ENVIRON(environ);
@@ -2122,27 +2179,49 @@ env_each_pair(VALUE ehash)
}
FREE_ENVIRON(environ);
- for (i=0; i<RARRAY_LEN(ary); i+=2) {
- rb_yield(rb_assoc_new(RARRAY_PTR(ary)[i], RARRAY_PTR(ary)[i+1]));
+ for (i=0; i<RARRAY(ary)->len; i+=2) {
+ if (values) {
+ rb_yield_values(2, RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1]);
+ }
+ else {
+ rb_yield(rb_assoc_new(RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1]));
+ }
}
return ehash;
}
static VALUE
-env_reject_bang(void)
+env_each(ehash)
+ VALUE ehash;
+{
+ RETURN_ENUMERATOR(ehash, 0, 0);
+ return env_each_i(ehash, Qfalse);
+}
+
+static VALUE
+env_each_pair(ehash)
+ VALUE ehash;
+{
+ RETURN_ENUMERATOR(ehash, 0, 0);
+ return env_each_i(ehash, Qtrue);
+}
+
+static VALUE
+env_reject_bang(ehash)
+ VALUE ehash;
{
volatile VALUE keys;
long i;
int del = 0;
- rb_secure(4);
- keys = env_keys();
- for (i=0; i<RARRAY_LEN(keys); i++) {
- VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]);
+ RETURN_ENUMERATOR(ehash, 0, 0);
+ keys = env_keys(); /* rb_secure(4); */
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
if (!NIL_P(val)) {
- if (RTEST(rb_yield_values(2, RARRAY_PTR(keys)[i], val))) {
- FL_UNSET(RARRAY_PTR(keys)[i], FL_TAINT);
- env_delete(Qnil, RARRAY_PTR(keys)[i]);
+ if (RTEST(rb_yield_values(2, RARRAY(keys)->ptr[i], val))) {
+ FL_UNSET(RARRAY(keys)->ptr[i], FL_TAINT);
+ env_delete(Qnil, RARRAY(keys)->ptr[i]);
del++;
}
}
@@ -2152,14 +2231,18 @@ env_reject_bang(void)
}
static VALUE
-env_delete_if(void)
+env_delete_if(ehash)
+ VALUE ehash;
{
- env_reject_bang();
+ RETURN_ENUMERATOR(ehash, 0, 0);
+ env_reject_bang(ehash);
return envtbl;
}
static VALUE
-env_values_at(int argc, VALUE *argv)
+env_values_at(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE result;
long i;
@@ -2173,14 +2256,15 @@ env_values_at(int argc, VALUE *argv)
}
static VALUE
-env_select(VALUE ehash)
+env_select(ehash)
+ VALUE ehash;
{
VALUE result;
char **env;
RETURN_ENUMERATOR(ehash, 0, 0);
rb_secure(4);
- result = rb_hash_new();
+ result = rb_ary_new();
env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
@@ -2188,7 +2272,7 @@ env_select(VALUE ehash)
VALUE k = env_str_new(*env, s-*env);
VALUE v = env_str_new2(s+1);
if (RTEST(rb_yield_values(2, k, v))) {
- rb_hash_aset(result, k, v);
+ rb_ary_push(result, rb_assoc_new(k, v));
}
}
env++;
@@ -2199,30 +2283,29 @@ env_select(VALUE ehash)
}
static VALUE
-env_clear(void)
+env_clear()
{
volatile VALUE keys;
long i;
- rb_secure(4);
- keys = env_keys();
- for (i=0; i<RARRAY_LEN(keys); i++) {
- VALUE val = rb_f_getenv(Qnil, RARRAY_PTR(keys)[i]);
+ keys = env_keys(); /* rb_secure(4); */
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
if (!NIL_P(val)) {
- env_delete(Qnil, RARRAY_PTR(keys)[i]);
+ env_delete(Qnil, RARRAY(keys)->ptr[i]);
}
}
return envtbl;
}
static VALUE
-env_to_s(void)
+env_to_s()
{
return rb_str_new2("ENV");
}
static VALUE
-env_inspect(void)
+env_inspect()
{
char **env;
VALUE str, i;
@@ -2253,7 +2336,7 @@ env_inspect(void)
}
static VALUE
-env_to_a(void)
+env_to_a()
{
char **env;
VALUE ary;
@@ -2274,13 +2357,13 @@ env_to_a(void)
}
static VALUE
-env_none(void)
+env_none()
{
return Qnil;
}
static VALUE
-env_size(void)
+env_size()
{
int i;
char **env;
@@ -2294,7 +2377,7 @@ env_size(void)
}
static VALUE
-env_empty_p(void)
+env_empty_p()
{
char **env;
@@ -2309,46 +2392,34 @@ env_empty_p(void)
}
static VALUE
-env_has_key(VALUE env, VALUE key)
+env_has_key(env, key)
+ VALUE env, key;
{
char *s;
rb_secure(4);
s = StringValuePtr(key);
- if (strlen(s) != RSTRING_LEN(key))
+ if (strlen(s) != RSTRING(key)->len)
rb_raise(rb_eArgError, "bad environment variable name");
if (getenv(s)) return Qtrue;
return Qfalse;
}
static VALUE
-env_assoc(VALUE env, VALUE key)
-{
- char *s, *e;
-
- rb_secure(4);
- s = StringValuePtr(key);
- if (strlen(s) != RSTRING_LEN(key))
- rb_raise(rb_eArgError, "bad environment variable name");
- e = getenv(s);
- if (e) return rb_assoc_new(key, rb_tainted_str_new2(e));
- return Qnil;
-}
-
-static VALUE
-env_has_value(VALUE dmy, VALUE obj)
+env_has_value(dmy, value)
+ VALUE dmy, value;
{
char **env;
rb_secure(4);
- obj = rb_check_string_type(obj);
- if (NIL_P(obj)) return Qnil;
+ value = rb_check_string_type(value);
+ if (NIL_P(value)) return Qfalse;
env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s++) {
long len = strlen(s);
- if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
+ if (RSTRING(value)->len == len && strncmp(s, RSTRING(value)->ptr, len) == 0) {
FREE_ENVIRON(environ);
return Qtrue;
}
@@ -2360,21 +2431,23 @@ env_has_value(VALUE dmy, VALUE obj)
}
static VALUE
-env_rassoc(VALUE dmy, VALUE obj)
+env_index(dmy, value)
+ VALUE dmy, value;
{
char **env;
+ VALUE str;
rb_secure(4);
- obj = rb_check_string_type(obj);
- if (NIL_P(obj)) return Qnil;
+ StringValue(value);
env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s++) {
long len = strlen(s);
- if (RSTRING_LEN(obj) == len && strncmp(s, RSTRING_PTR(obj), len) == 0) {
+ if (RSTRING(value)->len == len && strncmp(s, RSTRING(value)->ptr, len) == 0) {
+ str = env_str_new(*env, s-*env-1);
FREE_ENVIRON(environ);
- return rb_assoc_new(rb_tainted_str_new(*env, s-*env-1), obj);
+ return str;
}
}
env++;
@@ -2384,39 +2457,32 @@ env_rassoc(VALUE dmy, VALUE obj)
}
static VALUE
-env_key(VALUE dmy, VALUE value)
+env_indexes(argc, argv)
+ int argc;
+ VALUE *argv;
{
- char **env;
- VALUE str;
+ int i;
+ VALUE indexes = rb_ary_new2(argc);
+ rb_warn("ENV.%s is deprecated; use ENV.values_at",
+ rb_id2name(rb_frame_last_func()));
rb_secure(4);
- StringValue(value);
- env = GET_ENVIRON(environ);
- while (*env) {
- char *s = strchr(*env, '=');
- if (s++) {
- long len = strlen(s);
- if (RSTRING_LEN(value) == len && strncmp(s, RSTRING_PTR(value), len) == 0) {
- str = env_str_new(*env, s-*env-1);
- FREE_ENVIRON(environ);
- return str;
- }
+ for (i=0;i<argc;i++) {
+ VALUE tmp = rb_check_string_type(argv[i]);
+ if (NIL_P(tmp)) {
+ RARRAY(indexes)->ptr[i] = Qnil;
}
- env++;
+ else {
+ RARRAY(indexes)->ptr[i] = env_str_new2(getenv(RSTRING(tmp)->ptr));
+ }
+ RARRAY(indexes)->len = i+1;
}
- FREE_ENVIRON(environ);
- return Qnil;
-}
-static VALUE
-env_index(VALUE dmy, VALUE value)
-{
- rb_warn("ENV.index is deprecated; use ENV.key");
- return env_key(dmy, value);
+ return indexes;
}
static VALUE
-env_to_hash(void)
+env_to_hash()
{
char **env;
VALUE hash;
@@ -2437,13 +2503,13 @@ env_to_hash(void)
}
static VALUE
-env_reject(void)
+env_reject()
{
return rb_hash_delete_if(env_to_hash());
}
static VALUE
-env_shift(void)
+env_shift()
{
char **env;
@@ -2453,7 +2519,7 @@ env_shift(void)
char *s = strchr(*env, '=');
if (s) {
VALUE key = env_str_new(*env, s-*env);
- VALUE val = env_str_new2(getenv(RSTRING_PTR(key)));
+ VALUE val = env_str_new2(getenv(RSTRING(key)->ptr));
env_delete(Qnil, key);
return rb_assoc_new(key, val);
}
@@ -2463,13 +2529,14 @@ env_shift(void)
}
static VALUE
-env_invert(void)
+env_invert()
{
return rb_hash_invert(env_to_hash());
}
static int
-env_replace_i(VALUE key, VALUE val, VALUE keys)
+env_replace_i(key, val, keys)
+ VALUE key, val, keys;
{
if (key != Qundef) {
env_aset(Qnil, key, val);
@@ -2481,25 +2548,26 @@ env_replace_i(VALUE key, VALUE val, VALUE keys)
}
static VALUE
-env_replace(VALUE env, VALUE hash)
+env_replace(env, hash)
+ VALUE env, hash;
{
volatile VALUE keys;
long i;
- rb_secure(4);
- keys = env_keys();
+ keys = env_keys(); /* rb_secure(4); */
if (env == hash) return env;
hash = to_hash(hash);
rb_hash_foreach(hash, env_replace_i, keys);
- for (i=0; i<RARRAY_LEN(keys); i++) {
- env_delete(env, RARRAY_PTR(keys)[i]);
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ env_delete(env, RARRAY(keys)->ptr[i]);
}
return env;
}
static int
-env_update_i(VALUE key, VALUE val)
+env_update_i(key, val)
+ VALUE key, val;
{
if (key != Qundef) {
if (rb_block_given_p()) {
@@ -2511,7 +2579,8 @@ env_update_i(VALUE key, VALUE val)
}
static VALUE
-env_update(VALUE env, VALUE hash)
+env_update(env, hash)
+ VALUE env, hash;
{
rb_secure(4);
if (env == hash) return env;
@@ -2531,13 +2600,45 @@ env_update(VALUE env, VALUE hash)
* keys that do not exist in the hash. By default, that value is
* <code>nil</code>.
*
+ * <code>Hash</code> uses <code>key.eql?</code> to test keys for equality.
+ * If you need to use instances of your own classes as keys in a <code>Hash</code>,
+ * it is recommended that you define both the <code>eql?</code> and <code>hash</code>
+ * methods. The <code>hash</code> method must have the property that
+ * <code>a.eql?(b)</code> implies <code>a.hash == b.hash</code>.
+ *
+ * class MyClass
+ * attr_reader :str
+ * def initialize(str)
+ * @str = str
+ * end
+ * def eql?(o)
+ * o.is_a?(MyClass) && str == o.str
+ * end
+ * def hash
+ * @str.hash
+ * end
+ * end
+ *
+ * a = MyClass.new("some string")
+ * b = MyClass.new("some string")
+ * a.eql? b #=> true
+ *
+ * h = {}
+ *
+ * h[a] = 1
+ * h[a] #=> 1
+ * h[b] #=> 1
+ *
+ * h[b] = 2
+ * h[a] #=> 2
+ * h[b] #=> 2
*/
void
-Init_Hash(void)
+Init_Hash()
{
id_hash = rb_intern("hash");
- id_yield = rb_intern("yield");
+ id_call = rb_intern("call");
id_default = rb_intern("default");
rb_cHash = rb_define_class("Hash", rb_cObject);
@@ -2546,14 +2647,13 @@ Init_Hash(void)
rb_define_alloc_func(rb_cHash, hash_alloc);
rb_define_singleton_method(rb_cHash, "[]", rb_hash_s_create, -1);
- rb_define_singleton_method(rb_cHash, "try_convert", rb_hash_s_try_convert, 1);
rb_define_method(rb_cHash,"initialize", rb_hash_initialize, -1);
rb_define_method(rb_cHash,"initialize_copy", rb_hash_replace, 1);
rb_define_method(rb_cHash,"rehash", rb_hash_rehash, 0);
rb_define_method(rb_cHash,"to_hash", rb_hash_to_hash, 0);
rb_define_method(rb_cHash,"to_a", rb_hash_to_a, 0);
- rb_define_method(rb_cHash,"to_s", rb_hash_inspect, 0);
+ rb_define_method(rb_cHash,"to_s", rb_hash_to_s, 0);
rb_define_method(rb_cHash,"inspect", rb_hash_inspect, 0);
rb_define_method(rb_cHash,"==", rb_hash_equal, 1);
@@ -2566,16 +2666,18 @@ Init_Hash(void)
rb_define_method(rb_cHash,"default", rb_hash_default, -1);
rb_define_method(rb_cHash,"default=", rb_hash_set_default, 1);
rb_define_method(rb_cHash,"default_proc", rb_hash_default_proc, 0);
- rb_define_method(rb_cHash,"key", rb_hash_key, 1);
rb_define_method(rb_cHash,"index", rb_hash_index, 1);
+ rb_define_method(rb_cHash,"indexes", rb_hash_indexes, -1);
+ rb_define_method(rb_cHash,"indices", rb_hash_indexes, -1);
rb_define_method(rb_cHash,"size", rb_hash_size, 0);
rb_define_method(rb_cHash,"length", rb_hash_size, 0);
rb_define_method(rb_cHash,"empty?", rb_hash_empty_p, 0);
+ rb_define_method(rb_cHash,"each", rb_hash_each, 0);
rb_define_method(rb_cHash,"each_value", rb_hash_each_value, 0);
rb_define_method(rb_cHash,"each_key", rb_hash_each_key, 0);
rb_define_method(rb_cHash,"each_pair", rb_hash_each_pair, 0);
- rb_define_method(rb_cHash,"each", rb_hash_each_pair, 0);
+ rb_define_method(rb_cHash,"sort", rb_hash_sort, 0);
rb_define_method(rb_cHash,"keys", rb_hash_keys, 0);
rb_define_method(rb_cHash,"values", rb_hash_values, 0);
@@ -2593,9 +2695,6 @@ Init_Hash(void)
rb_define_method(rb_cHash,"replace", rb_hash_replace, 1);
rb_define_method(rb_cHash,"merge!", rb_hash_update, 1);
rb_define_method(rb_cHash,"merge", rb_hash_merge, 1);
- rb_define_method(rb_cHash, "assoc", rb_hash_assoc, 1);
- rb_define_method(rb_cHash, "rassoc", rb_hash_rassoc, 1);
- rb_define_method(rb_cHash, "flatten", rb_hash_flatten, -1);
rb_define_method(rb_cHash,"include?", rb_hash_has_key, 1);
rb_define_method(rb_cHash,"member?", rb_hash_has_key, 1);
@@ -2604,9 +2703,6 @@ Init_Hash(void)
rb_define_method(rb_cHash,"key?", rb_hash_has_key, 1);
rb_define_method(rb_cHash,"value?", rb_hash_has_value, 1);
- rb_define_method(rb_cHash,"compare_by_identity", rb_hash_compare_by_id, 0);
- rb_define_method(rb_cHash,"compare_by_identity?", rb_hash_compare_by_id_p, 0);
-
#ifndef __MACOS__ /* environment variables nothing on MacOS. */
origenviron = environ;
envtbl = rb_obj_alloc(rb_cObject);
@@ -2616,7 +2712,7 @@ Init_Hash(void)
rb_define_singleton_method(envtbl,"fetch", env_fetch, -1);
rb_define_singleton_method(envtbl,"[]=", env_aset, 2);
rb_define_singleton_method(envtbl,"store", env_aset, 2);
- rb_define_singleton_method(envtbl,"each", env_each_pair, 0);
+ rb_define_singleton_method(envtbl,"each", env_each, 0);
rb_define_singleton_method(envtbl,"each_pair", env_each_pair, 0);
rb_define_singleton_method(envtbl,"each_key", env_each_key, 0);
rb_define_singleton_method(envtbl,"each_value", env_each_value, 0);
@@ -2634,8 +2730,9 @@ Init_Hash(void)
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);
rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
- rb_define_singleton_method(envtbl,"key", env_key, 1);
rb_define_singleton_method(envtbl,"index", env_index, 1);
+ rb_define_singleton_method(envtbl,"indexes", env_indexes, -1);
+ rb_define_singleton_method(envtbl,"indices", env_indexes, -1);
rb_define_singleton_method(envtbl,"size", env_size, 0);
rb_define_singleton_method(envtbl,"length", env_size, 0);
rb_define_singleton_method(envtbl,"empty?", env_empty_p, 0);
@@ -2649,8 +2746,6 @@ Init_Hash(void)
rb_define_singleton_method(envtbl,"key?", env_has_key, 1);
rb_define_singleton_method(envtbl,"value?", env_has_value, 1);
rb_define_singleton_method(envtbl,"to_hash", env_to_hash, 0);
- rb_define_singleton_method(envtbl,"assoc", env_assoc, 1);
- rb_define_singleton_method(envtbl,"rassoc", env_rassoc, 1);
rb_define_global_const("ENV", envtbl);
#else /* __MACOS__ */
diff --git a/ia64.s b/ia64.s
index 92415b4e97..ba5241daf2 100644
--- a/ia64.s
+++ b/ia64.s
@@ -6,15 +6,6 @@
// void rb_ia64_flushrs(void) { __builtin_ia64_flushrs(); }
// void *rb_ia64_bsp(void) { return __builtin_ia64_bsp(); }
//
-// Note that rb_ia64_flushrs and rb_ia64_bsp works in its own stack frame.
-// It's because BSP is updated by br.call/brl.call (not alloc instruction).
-// So rb_ia64_flushrs flushes stack frames including caller's one.
-// rb_ia64_bsp returns the address next to caller's register stack frame.
-//
-// See also
-// Intel Itanium Architecture Software Developer's Manual
-// Volume 2: System Architecture.
-//
.file "ia64.c"
.text
.align 16
diff --git a/id.c b/id.c
deleted file mode 100644
index 7e56c47581..0000000000
--- a/id.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/**********************************************************************
-
- id.c -
-
- $Author$
- $Date$
- created at: Thu Jul 12 04:37:51 2007
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-
-#define extern
-#include "id.h"
-#undef extern
-
-void
-Init_id(void)
-{
- /* Symbols */
- symIFUNC = ID2SYM(rb_intern("<IFUNC>"));
- symCFUNC = ID2SYM(rb_intern("<CFUNC>"));
-
- /* IDs */
- idPLUS = rb_intern("+");
- idMINUS = rb_intern("-");
- idMULT = rb_intern("*");
- idDIV = rb_intern("/");
- idMOD = rb_intern("%");
- idLT = rb_intern("<");
- idLTLT = rb_intern("<<");
- idLE = rb_intern("<=");
- idGT = rb_intern(">");
- idGE = rb_intern(">=");
- idEq = rb_intern("==");
- idEqq = rb_intern("===");
- idBackquote = rb_intern("`");
- idEqTilde = rb_intern("=~");
- idNot = rb_intern("!");
- idNeq = rb_intern("!=");
-
- idAREF = rb_intern("[]");
- idASET = rb_intern("[]=");
-
- idEach = rb_intern("each");
- idTimes = rb_intern("times");
- idLength = rb_intern("length");
- idLambda = rb_intern("lambda");
- idIntern = rb_intern("intern");
- idGets = rb_intern("gets");
- idSucc = rb_intern("succ");
- idEnd = rb_intern("end");
- idRangeEachLT = rb_intern("Range#each#LT");
- idRangeEachLE = rb_intern("Range#each#LE");
- idArrayEach = rb_intern("Array#each");
- idMethodMissing = rb_intern("method_missing");
-
- idThrowState = rb_intern("#__ThrowState__");
-
- idBitblt = rb_intern("bitblt");
- idAnswer = rb_intern("the_answer_to_life_the_universe_and_everything");
-
- idSend = rb_intern("send");
- id__send__ = rb_intern("__send__");
-}
diff --git a/id.h b/id.h
deleted file mode 100644
index c1e6c9dade..0000000000
--- a/id.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**********************************************************************
-
- id.h -
-
- $Author: ko1 $
- $Date: $
- created at: Thu Jul 12 04:38:07 2007
-
- Copyright (C) 2007 Koichi Sasada
-
-**********************************************************************/
-
-extern VALUE symIFUNC;
-extern VALUE symCFUNC;
-
-extern ID idPLUS;
-extern ID idMINUS;
-extern ID idMULT;
-extern ID idDIV;
-extern ID idMOD;
-extern ID idLT;
-extern ID idLTLT;
-extern ID idLE;
-extern ID idGT;
-extern ID idGE;
-extern ID idEq;
-extern ID idEqq;
-extern ID idNeq;
-extern ID idNot;
-extern ID idBackquote;
-extern ID idEqTilde;
-extern ID idThrowState;
-extern ID idAREF;
-extern ID idASET;
-extern ID idIntern;
-extern ID idMethodMissing;
-extern ID idLength;
-extern ID idGets;
-extern ID idSucc;
-extern ID idEach;
-extern ID idLambda;
-extern ID idRangeEachLT;
-extern ID idRangeEachLE;
-extern ID idArrayEach;
-extern ID idTimes;
-extern ID idEnd;
-extern ID idBitblt;
-extern ID idAnswer;
-extern ID idSend;
-extern ID id__send__;
-
-
diff --git a/include/ruby.h b/include/ruby.h
deleted file mode 100644
index b1fb46c897..0000000000
--- a/include/ruby.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <ruby/ruby.h>
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
deleted file mode 100644
index bd9dd0c334..0000000000
--- a/include/ruby/defines.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/************************************************
-
- defines.h -
-
- $Author$
- $Date$
- created at: Wed May 18 00:21:44 JST 1994
-
-************************************************/
-
-#ifndef RUBY_DEFINES_H
-#define RUBY_DEFINES_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#define RUBY
-
-#include <stdlib.h>
-#ifdef __cplusplus
-# ifndef HAVE_PROTOTYPES
-# define HAVE_PROTOTYPES 1
-# endif
-# ifndef HAVE_STDARG_PROTOTYPES
-# define HAVE_STDARG_PROTOTYPES 1
-# endif
-#endif
-
-#undef _
-#ifdef HAVE_PROTOTYPES
-# define _(args) args
-#else
-# define _(args) ()
-#endif
-
-#undef __
-#ifdef HAVE_STDARG_PROTOTYPES
-# define __(args) args
-#else
-# define __(args) ()
-#endif
-
-#ifdef __cplusplus
-#define ANYARGS ...
-#else
-#define ANYARGS
-#endif
-
-#define xmalloc ruby_xmalloc
-#define xmalloc2 ruby_xmalloc2
-#define xcalloc ruby_xcalloc
-#define xrealloc ruby_xrealloc
-#define xrealloc2 ruby_xrealloc2
-#define xfree ruby_xfree
-
-void *xmalloc(size_t);
-void *xmalloc2(size_t,size_t);
-void *xcalloc(size_t,size_t);
-void *xrealloc(void*,size_t);
-void *xrealloc2(void*,size_t,size_t);
-void xfree(void*);
-
-#define STRINGIZE(expr) STRINGIZE0(expr)
-#ifndef STRINGIZE0
-#define STRINGIZE0(expr) #expr
-#endif
-
-#if SIZEOF_LONG_LONG > 0
-# define LONG_LONG long long
-#elif SIZEOF___INT64 > 0
-# define HAVE_LONG_LONG 1
-# define LONG_LONG __int64
-# undef SIZEOF_LONG_LONG
-# define SIZEOF_LONG_LONG SIZEOF___INT64
-#endif
-
-#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
-# define BDIGIT unsigned int
-# define SIZEOF_BDIGITS SIZEOF_INT
-# define BDIGIT_DBL unsigned LONG_LONG
-# define BDIGIT_DBL_SIGNED LONG_LONG
-#elif SIZEOF_INT*2 <= SIZEOF_LONG
-# define BDIGIT unsigned int
-# define SIZEOF_BDIGITS SIZEOF_INT
-# define BDIGIT_DBL unsigned long
-# define BDIGIT_DBL_SIGNED long
-#elif SIZEOF_SHORT*2 <= SIZEOF_LONG
-# define BDIGIT unsigned short
-# define SIZEOF_BDIGITS SIZEOF_SHORT
-# define BDIGIT_DBL unsigned long
-# define BDIGIT_DBL_SIGNED long
-#else
-# define BDIGIT unsigned short
-# define SIZEOF_BDIGITS (SIZEOF_LONG/2)
-# define BDIGIT_DBL unsigned long
-# define BDIGIT_DBL_SIGNED long
-#endif
-
-#ifdef __CYGWIN__
-#undef _WIN32
-#endif
-
-#if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__)
-#define DOSISH 1
-#ifndef _WIN32_WCE
-# define DOSISH_DRIVE_LETTER
-#endif
-#endif
-
-#ifdef __NeXT__
-/* NextStep, OpenStep, Rhapsody */
-#ifndef S_IRUSR
-#define S_IRUSR 0000400 /* read permission, owner */
-#endif
-#ifndef S_IRGRP
-#define S_IRGRP 0000040 /* read permission, group */
-#endif
-#ifndef S_IROTH
-#define S_IROTH 0000004 /* read permission, other */
-#endif
-#ifndef S_IWUSR
-#define S_IWUSR 0000200 /* write permission, owner */
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 0000020 /* write permission, group */
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 0000002 /* write permission, other */
-#endif
-#ifndef S_IXUSR
-#define S_IXUSR 0000100 /* execute/search permission, owner */
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0000010 /* execute/search permission, group */
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0000001 /* execute/search permission, other */
-#endif
-#ifndef S_IRWXU
-#define S_IRWXU 0000700 /* read, write, execute permissions, owner */
-#endif
-#ifndef S_IRWXG
-#define S_IRWXG 0000070 /* read, write, execute permissions, group */
-#endif
-#ifndef S_IRWXO
-#define S_IRWXO 0000007 /* read, write, execute permissions, other */
-#endif
-#ifndef S_ISBLK
-#define S_ISBLK(mode) (((mode) & (0170000)) == (0060000))
-#endif
-#ifndef S_ISCHR
-#define S_ISCHR(mode) (((mode) & (0170000)) == (0020000))
-#endif
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode) & (0170000)) == (0040000))
-#endif
-#ifndef S_ISFIFO
-#define S_ISFIFO(mode) (((mode) & (0170000)) == (0010000))
-#endif
-#ifndef S_ISREG
-#define S_ISREG(mode) (((mode) & (0170000)) == (0100000))
-#endif
-/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
- result in a different endian. Instead trust __BIG_ENDIAN__ and
- __LITTLE_ENDIAN__ which are set correctly by -arch. */
-#undef WORDS_BIGENDIAN
-#ifdef __BIG_ENDIAN__
-#define WORDS_BIGENDIAN
-#endif
-#ifndef __APPLE__
-/* NextStep, OpenStep (but not Rhapsody) */
-#ifndef GETPGRP_VOID
-#define GETPGRP_VOID 1
-#endif
-#ifndef WNOHANG
-#define WNOHANG 01
-#endif
-#ifndef WUNTRACED
-#define WUNTRACED 02
-#endif
-#ifndef X_OK
-#define X_OK 1
-#endif
-#endif /* __APPLE__ */
-#endif /* NeXT */
-
-#ifdef _WIN32
-#include "ruby/win32.h"
-#endif
-
-#if defined(__VMS)
-#include "vms/vms.h"
-#endif
-
-#if defined(__BEOS__)
-#include <net/socket.h> /* intern.h needs fd_set definition */
-#endif
-
-#ifdef RUBY_EXPORT
-#undef RUBY_EXTERN
-#endif
-
-#ifndef RUBY_EXTERN
-#define RUBY_EXTERN extern
-#endif
-
-#ifndef EXTERN
-#define EXTERN RUBY_EXTERN /* deprecated */
-#endif
-
-#ifndef RUBY_MBCHAR_MAXSIZE
-#define RUBY_MBCHAR_MAXSIZE INT_MAX
- /* MB_CUR_MAX will not work well in C locale */
-#endif
-
-#if defined(sparc) || defined(__sparc__)
-static inline void
-flush_register_windows(void)
-{
- asm
-#ifdef __GNUC__
- volatile
-#endif
-# if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
- ("flushw")
-# else
- ("ta 0x03")
-# endif /* trap always to flush register windows if we are on a Sparc system */
- ;
-}
-# define FLUSH_REGISTER_WINDOWS flush_register_windows()
-#elif defined(__ia64)
-void *rb_ia64_bsp(void);
-void rb_ia64_flushrs(void);
-# define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
-#else
-# define FLUSH_REGISTER_WINDOWS ((void)0)
-#endif
-
-#if defined(DOSISH)
-#define PATH_SEP ";"
-#elif defined(riscos)
-#define PATH_SEP ","
-#else
-#define PATH_SEP ":"
-#endif
-#define PATH_SEP_CHAR PATH_SEP[0]
-
-#if defined(__human68k__)
-#define PATH_ENV "path"
-#else
-#define PATH_ENV "PATH"
-#endif
-
-#if defined(DOSISH) && !defined(__human68k__) && !defined(__EMX__)
-#define ENV_IGNORECASE
-#endif
-
-#ifndef DLEXT_MAXLEN
-#define DLEXT_MAXLEN 4
-#endif
-
-#ifndef RUBY_PLATFORM
-#define RUBY_PLATFORM "unknown-unknown"
-#endif
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_DEFINES_H */
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
deleted file mode 100644
index 1b1e3d7c59..0000000000
--- a/include/ruby/encoding.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/**********************************************************************
-
- encoding.h -
-
- $Author: matz $
- $Date: 2007-05-24 11:49:41 +0900 (Thu, 24 May 2007) $
- created at: Thu May 24 11:49:41 JST 2007
-
- Copyright (C) 2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_ENCODING_H
-#define RUBY_ENCODING_H 1
-
-#include "ruby/oniguruma.h"
-
-#define ENCODING_INLINE_MAX 1023
-#define ENCODING_SHIFT (FL_USHIFT+10)
-#define ENCODING_MASK (ENCODING_INLINE_MAX<<ENCODING_SHIFT)
-#define ENCODING_SET(obj,i) do {\
- RBASIC(obj)->flags &= ~ENCODING_MASK;\
- RBASIC(obj)->flags |= i << ENCODING_SHIFT;\
-} while (0)
-#define ENCODING_GET(obj) ((RBASIC(obj)->flags & ENCODING_MASK)>>ENCODING_SHIFT)
-
-#define ENC_CODERANGE_MASK (FL_USER8|FL_USER9)
-#define ENC_CODERANGE_UNKNOWN 0
-#define ENC_CODERANGE_7BIT FL_USER8
-#define ENC_CODERANGE_VALID FL_USER9
-#define ENC_CODERANGE_BROKEN (FL_USER8|FL_USER9)
-#define ENC_CODERANGE(obj) (RBASIC(obj)->flags & ENC_CODERANGE_MASK)
-#define ENC_CODERANGE_ASCIIONLY(obj) (ENC_CODERANGE(obj) == ENC_CODERANGE_7BIT)
-#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \
- (RBASIC(obj)->flags & ~ENC_CODERANGE_MASK) | (cr))
-#define ENC_CODERANGE_CLEAR(obj) ENC_CODERANGE_SET(obj,0)
-
-
-typedef OnigEncodingType rb_encoding;
-
-int rb_enc_replicate(const char *, rb_encoding *);
-int rb_define_dummy_encoding(const char *);
-int rb_enc_dummy_p(rb_encoding *);
-int rb_enc_to_index(rb_encoding*);
-int rb_enc_get_index(VALUE obj);
-int rb_enc_find_index(const char *name);
-int rb_to_encoding_index(VALUE);
-rb_encoding* rb_to_encoding(VALUE);
-rb_encoding* rb_enc_get(VALUE);
-rb_encoding* rb_enc_compatible(VALUE,VALUE);
-rb_encoding* rb_enc_check(VALUE,VALUE);
-void rb_enc_associate_index(VALUE, int);
-void rb_enc_associate(VALUE, rb_encoding*);
-void rb_enc_copy(VALUE, VALUE);
-
-VALUE rb_enc_str_new(const char*, long len, rb_encoding*);
-long rb_enc_strlen(const char*, const char*, rb_encoding*);
-char* rb_enc_nth(const char*, const char*, int, rb_encoding*);
-VALUE rb_obj_encoding(VALUE);
-
-/* index -> rb_encoding */
-rb_encoding* rb_enc_from_index(int idx);
-
-/* name -> rb_encoding */
-rb_encoding * rb_enc_find(const char *name);
-
-/* encoding -> name */
-#define rb_enc_name(enc) (enc)->name
-
-/* encoding -> minlen/maxlen */
-#define rb_enc_mbminlen(enc) (enc)->min_enc_len
-#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
-
-/* -> mbclen (no error notification: 0 < ret <= e-p, no exception) */
-int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
-
-/* -> chlen, invalid or needmore */
-int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
-#define MBCLEN_CHARFOUND(ret) ONIGENC_MBCLEN_CHARFOUND(ret)
-#define MBCLEN_INVALID(ret) ONIGENC_MBCLEN_INVALID(ret)
-#define MBCLEN_NEEDMORE(ret) ONIGENC_MBCLEN_NEEDMORE(ret)
-
-/* -> 0x00..0x7f, -1 */
-int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
-
-/* -> code or raise exception */
-int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
-#define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE(enc,(UChar*)(p),(UChar*)(e))
-
-/* -> codelen or raise exception */
-int rb_enc_codelen(int code, rb_encoding *enc);
-
-/* code,ptr,encoding -> write buf */
-#define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC(enc,c,(UChar*)(buf))
-
-/* ptr, ptr, encoding -> prev_char */
-#define rb_enc_prev_char(s,p,enc) (char *)onigenc_get_prev_char_head(enc,(UChar*)(s),(UChar*)(p))
-/* ptr, ptr, encoding -> next_char */
-#define rb_enc_left_char_head(s,p,enc) (char *)onigenc_get_left_adjust_char_head(enc,(UChar*)(s),(UChar*)(p))
-#define rb_enc_right_char_head(s,p,enc) (char *)onigenc_get_right_adjust_char_head(enc,(UChar*)(s),(UChar*)(p))
-
-#define rb_enc_isctype(c,t,enc) ONIGENC_IS_CODE_CTYPE(enc,c,t)
-#define rb_enc_isascii(c,enc) ONIGENC_IS_CODE_ASCII(c)
-#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA(enc,c)
-#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER(enc,c)
-#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER(enc,c)
-#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM(enc,c)
-#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT(enc,c)
-#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE(enc,c)
-#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT(enc,c)
-
-#define rb_enc_asciicompat(enc) (rb_enc_mbminlen(enc)==1)
-
-int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
-int rb_enc_toupper(int c, rb_encoding *enc);
-int rb_enc_tolower(int c, rb_encoding *enc);
-ID rb_intern3(const char*, long, rb_encoding*);
-ID rb_interned_id_p(const char *, long, rb_encoding *);
-int rb_enc_symname_p(const char*, rb_encoding*);
-int rb_enc_str_coderange(VALUE);
-int rb_enc_str_asciionly_p(VALUE);
-#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
-VALUE rb_enc_from_encoding(rb_encoding *enc);
-rb_encoding *rb_ascii8bit_encoding(void);
-rb_encoding *rb_utf8_encoding(void);
-rb_encoding *rb_default_external_encoding(void);
-VALUE rb_enc_default_external(void);
-void rb_enc_set_default_external(VALUE encoding);
-VALUE rb_locale_charmap(VALUE klass);
-
-#endif /* RUBY_ENCODING_H */
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
deleted file mode 100644
index eaacc96052..0000000000
--- a/include/ruby/intern.h
+++ /dev/null
@@ -1,638 +0,0 @@
-/**********************************************************************
-
- intern.h -
-
- $Author$
- $Date$
- created at: Thu Jun 10 14:22:17 JST 1993
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
- Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
- Copyright (C) 2000 Information-technology Promotion Agency, Japan
-
-**********************************************************************/
-
-#ifndef RUBY_INTERN_H
-#define RUBY_INTERN_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#ifdef HAVE_STDARG_PROTOTYPES
-# include <stdarg.h>
-#else
-# include <varargs.h>
-#endif
-#include <ruby/st.h>
-
-/*
- * Functions and variables that are used by more than one source file of
- * the kernel.
- */
-
-#define ID_ALLOCATOR 1
-
-/* array.c */
-void rb_mem_clear(register VALUE*, register long);
-VALUE rb_assoc_new(VALUE, VALUE);
-VALUE rb_check_array_type(VALUE);
-VALUE rb_ary_new(void);
-VALUE rb_ary_new2(long);
-VALUE rb_ary_new3(long,...);
-VALUE rb_ary_new4(long, const VALUE *);
-void rb_ary_free(VALUE);
-VALUE rb_ary_freeze(VALUE);
-VALUE rb_ary_aref(int, VALUE*, VALUE);
-VALUE rb_ary_subseq(VALUE, long, long);
-void rb_ary_store(VALUE, long, VALUE);
-VALUE rb_ary_dup(VALUE);
-VALUE rb_ary_to_ary(VALUE);
-VALUE rb_ary_to_s(VALUE);
-VALUE rb_ary_push(VALUE, VALUE);
-VALUE rb_ary_pop(VALUE);
-VALUE rb_ary_shift(VALUE);
-VALUE rb_ary_unshift(VALUE, VALUE);
-VALUE rb_ary_entry(VALUE, long);
-VALUE rb_ary_each(VALUE);
-VALUE rb_ary_join(VALUE, VALUE);
-VALUE rb_ary_print_on(VALUE, VALUE);
-VALUE rb_ary_reverse(VALUE);
-VALUE rb_ary_sort(VALUE);
-VALUE rb_ary_sort_bang(VALUE);
-VALUE rb_ary_delete(VALUE, VALUE);
-VALUE rb_ary_delete_at(VALUE, long);
-VALUE rb_ary_clear(VALUE);
-VALUE rb_ary_plus(VALUE, VALUE);
-VALUE rb_ary_concat(VALUE, VALUE);
-VALUE rb_ary_assoc(VALUE, VALUE);
-VALUE rb_ary_rassoc(VALUE, VALUE);
-VALUE rb_ary_includes(VALUE, VALUE);
-VALUE rb_ary_cmp(VALUE, VALUE);
-VALUE rb_ary_replace(VALUE copy, VALUE orig);
-VALUE rb_get_values_at(VALUE, long, int, VALUE*, VALUE(*)(VALUE,long));
-/* bignum.c */
-VALUE rb_big_clone(VALUE);
-void rb_big_2comp(VALUE);
-VALUE rb_big_norm(VALUE);
-void rb_big_resize(VALUE big, long len);
-VALUE rb_uint2big(VALUE);
-VALUE rb_int2big(SIGNED_VALUE);
-VALUE rb_uint2inum(VALUE);
-VALUE rb_int2inum(SIGNED_VALUE);
-VALUE rb_cstr_to_inum(const char*, int, int);
-VALUE rb_str_to_inum(VALUE, int, int);
-VALUE rb_cstr2inum(const char*, int);
-VALUE rb_str2inum(VALUE, int);
-VALUE rb_big2str(VALUE, int);
-VALUE rb_big2str0(VALUE, int, int);
-SIGNED_VALUE rb_big2long(VALUE);
-#define rb_big2int(x) rb_big2long(x)
-VALUE rb_big2ulong(VALUE);
-#define rb_big2uint(x) rb_big2ulong(x)
-#if HAVE_LONG_LONG
-VALUE rb_ll2inum(LONG_LONG);
-VALUE rb_ull2inum(unsigned LONG_LONG);
-LONG_LONG rb_big2ll(VALUE);
-unsigned LONG_LONG rb_big2ull(VALUE);
-#endif /* HAVE_LONG_LONG */
-void rb_quad_pack(char*,VALUE);
-VALUE rb_quad_unpack(const char*,int);
-int rb_uv_to_utf8(char[6],unsigned long);
-VALUE rb_dbl2big(double);
-double rb_big2dbl(VALUE);
-VALUE rb_big_cmp(VALUE, VALUE);
-VALUE rb_big_eq(VALUE, VALUE);
-VALUE rb_big_plus(VALUE, VALUE);
-VALUE rb_big_minus(VALUE, VALUE);
-VALUE rb_big_mul(VALUE, VALUE);
-VALUE rb_big_div(VALUE, VALUE);
-VALUE rb_big_modulo(VALUE, VALUE);
-VALUE rb_big_divmod(VALUE, VALUE);
-VALUE rb_big_pow(VALUE, VALUE);
-VALUE rb_big_and(VALUE, VALUE);
-VALUE rb_big_or(VALUE, VALUE);
-VALUE rb_big_xor(VALUE, VALUE);
-VALUE rb_big_lshift(VALUE, VALUE);
-VALUE rb_big_rshift(VALUE, VALUE);
-/* class.c */
-VALUE rb_class_boot(VALUE);
-VALUE rb_class_new(VALUE);
-VALUE rb_mod_init_copy(VALUE, VALUE);
-VALUE rb_class_init_copy(VALUE, VALUE);
-VALUE rb_singleton_class_clone(VALUE);
-void rb_singleton_class_attached(VALUE,VALUE);
-VALUE rb_make_metaclass(VALUE, VALUE);
-void rb_check_inheritable(VALUE);
-VALUE rb_class_inherited(VALUE, VALUE);
-VALUE rb_define_class_id(ID, VALUE);
-VALUE rb_module_new(void);
-VALUE rb_define_module_id(ID);
-VALUE rb_mod_included_modules(VALUE);
-VALUE rb_mod_include_p(VALUE, VALUE);
-VALUE rb_mod_ancestors(VALUE);
-VALUE rb_class_instance_methods(int, VALUE*, VALUE);
-VALUE rb_class_public_instance_methods(int, VALUE*, VALUE);
-VALUE rb_class_protected_instance_methods(int, VALUE*, VALUE);
-VALUE rb_class_private_instance_methods(int, VALUE*, VALUE);
-VALUE rb_obj_singleton_methods(int, VALUE*, VALUE);
-void rb_define_method_id(VALUE, ID, VALUE (*)(ANYARGS), int);
-void rb_frozen_class_p(VALUE);
-void rb_undef(VALUE, ID);
-void rb_define_protected_method(VALUE, const char*, VALUE (*)(ANYARGS), int);
-void rb_define_private_method(VALUE, const char*, VALUE (*)(ANYARGS), int);
-void rb_define_singleton_method(VALUE, const char*, VALUE(*)(ANYARGS), int);
-VALUE rb_singleton_class(VALUE);
-/* compar.c */
-int rb_cmpint(VALUE, VALUE, VALUE);
-NORETURN(void rb_cmperr(VALUE, VALUE));
-/* cont.c */
-VALUE rb_fiber_new(VALUE (*)(ANYARGS), VALUE);
-VALUE rb_fiber_resume(VALUE fib, int argc, VALUE *args);
-VALUE rb_fiber_yield(int argc, VALUE *args);
-VALUE rb_fiber_current(void);
-VALUE rb_fiber_alive_p(VALUE);
-/* enum.c */
-/* enumerator.c */
-VALUE rb_enumeratorize(VALUE, VALUE, int, VALUE *);
-#define RETURN_ENUMERATOR(obj, argc, argv) do { \
- if (!rb_block_given_p()) \
- return rb_enumeratorize(obj, ID2SYM(rb_frame_this_func()), \
- argc, argv); \
- } while (0)
-/* error.c */
-VALUE rb_exc_new(VALUE, const char*, long);
-VALUE rb_exc_new2(VALUE, const char*);
-VALUE rb_exc_new3(VALUE, VALUE);
-PRINTF_ARGS(NORETURN(void rb_loaderror(const char*, ...)), 1, 2);
-PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3);
-NORETURN(void rb_invalid_str(const char*, const char*));
-PRINTF_ARGS(void rb_compile_error(const char*, int, const char*, ...), 3, 4);
-PRINTF_ARGS(void rb_compile_error_append(const char*, ...), 1, 2);
-NORETURN(void rb_load_fail(const char*));
-NORETURN(void rb_error_frozen(const char*));
-void rb_check_frozen(VALUE);
-/* eval.c */
-int rb_sourceline(void);
-const char *rb_sourcefile(void);
-
-#if defined(NFDBITS) && defined(HAVE_RB_FD_INIT)
-typedef struct {
- int maxfd;
- fd_set *fdset;
-} rb_fdset_t;
-
-void rb_fd_init(volatile rb_fdset_t *);
-void rb_fd_term(rb_fdset_t *);
-void rb_fd_zero(rb_fdset_t *);
-void rb_fd_set(int, rb_fdset_t *);
-void rb_fd_clr(int, rb_fdset_t *);
-int rb_fd_isset(int, const rb_fdset_t *);
-void rb_fd_copy(rb_fdset_t *, const fd_set *, int);
-int rb_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
-
-#define rb_fd_ptr(f) ((f)->fdset)
-#define rb_fd_max(f) ((f)->maxfd)
-
-#else
-
-typedef fd_set rb_fdset_t;
-#define rb_fd_zero(f) FD_ZERO(f)
-#define rb_fd_set(n, f) FD_SET(n, f)
-#define rb_fd_clr(n, f) FD_CLR(n, f)
-#define rb_fd_isset(n, f) FD_ISSET(n, f)
-#define rb_fd_copy(d, s, n) (*(d) = *(s))
-#define rb_fd_ptr(f) (f)
-#define rb_fd_init(f) FD_ZERO(f)
-#define rb_fd_term(f) (f)
-#define rb_fd_max(f) FD_SETSIZE
-#define rb_fd_select(n, rfds, wfds, efds, timeout) select(n, rfds, wfds, efds, timeout)
-
-#endif
-
-NORETURN(void rb_exc_raise(VALUE));
-NORETURN(void rb_exc_fatal(VALUE));
-VALUE rb_f_exit(int,VALUE*);
-VALUE rb_f_abort(int,VALUE*);
-void rb_remove_method(VALUE, const char*);
-#define rb_disable_super(klass, name) ((void)0)
-#define rb_enable_super(klass, name) ((void)0)
-#define HAVE_RB_DEFINE_ALLOC_FUNC 1
-typedef VALUE (*rb_alloc_func_t)(VALUE);
-void rb_define_alloc_func(VALUE, rb_alloc_func_t);
-void rb_undef_alloc_func(VALUE);
-rb_alloc_func_t rb_get_alloc_func(VALUE);
-void rb_clear_cache(void);
-void rb_clear_cache_by_class(VALUE);
-void rb_alias(VALUE, ID, ID);
-void rb_attr(VALUE,ID,int,int,int);
-int rb_method_boundp(VALUE, ID, int);
-VALUE rb_eval_cmd(VALUE, VALUE, int);
-int rb_obj_respond_to(VALUE, ID, int);
-int rb_respond_to(VALUE, ID);
-void rb_interrupt(void);
-VALUE rb_apply(VALUE, ID, VALUE);
-void rb_backtrace(void);
-ID rb_frame_this_func(void);
-VALUE rb_obj_instance_eval(int, VALUE*, VALUE);
-VALUE rb_mod_module_eval(int, VALUE*, VALUE);
-void rb_load(VALUE, int);
-void rb_load_protect(VALUE, int, int*);
-NORETURN(void rb_jump_tag(int));
-int rb_provided(const char*);
-void rb_provide(const char*);
-VALUE rb_f_require(VALUE, VALUE);
-VALUE rb_require_safe(VALUE, int);
-void rb_obj_call_init(VALUE, int, VALUE*);
-VALUE rb_class_new_instance(int, VALUE*, VALUE);
-VALUE rb_block_proc(void);
-VALUE rb_f_lambda(void);
-VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
-VALUE rb_proc_call(VALUE, VALUE);
-int rb_proc_arity(VALUE);
-VALUE rb_binding_new(void);
-VALUE rb_obj_method(VALUE, VALUE);
-VALUE rb_method_call(int, VALUE*, VALUE);
-int rb_mod_method_arity(VALUE, ID);
-int rb_obj_method_arity(VALUE, ID);
-VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*);
-void rb_set_end_proc(void (*)(VALUE), VALUE);
-void rb_mark_end_proc(void);
-void rb_exec_end_proc(void);
-void Init_jump(void);
-void ruby_finalize(void);
-NORETURN(void ruby_stop(int));
-int ruby_cleanup(int);
-void rb_gc_mark_threads(void);
-void rb_thread_schedule(void);
-void rb_thread_wait_fd(int);
-int rb_thread_fd_writable(int);
-void rb_thread_fd_close(int);
-int rb_thread_alone(void);
-void rb_thread_polling(void);
-void rb_thread_sleep(int);
-void rb_thread_sleep_forever(void);
-VALUE rb_thread_stop(void);
-VALUE rb_thread_wakeup(VALUE);
-VALUE rb_thread_run(VALUE);
-VALUE rb_thread_kill(VALUE);
-VALUE rb_thread_create(VALUE (*)(ANYARGS), void*);
-void rb_thread_signal_raise(void *, int);
-void rb_thread_signal_exit(void *);
-int rb_thread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-void rb_thread_wait_for(struct timeval);
-VALUE rb_thread_current(void);
-VALUE rb_thread_main(void);
-VALUE rb_thread_local_aref(VALUE, ID);
-VALUE rb_thread_local_aset(VALUE, ID, VALUE);
-void rb_thread_atfork(void);
-VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE);
-/* file.c */
-VALUE rb_file_s_expand_path(int, VALUE *);
-VALUE rb_file_expand_path(VALUE, VALUE);
-void rb_file_const(const char*, VALUE);
-int rb_find_file_ext(VALUE*, const char* const*);
-VALUE rb_find_file(VALUE);
-char *rb_path_next(const char *);
-char *rb_path_skip_prefix(const char *);
-char *rb_path_last_separator(const char *);
-char *rb_path_end(const char *);
-VALUE rb_file_directory_p(VALUE,VALUE);
-/* gc.c */
-void ruby_set_stack_size(size_t);
-NORETURN(void rb_memerror(void));
-int ruby_stack_check(void);
-int ruby_stack_length(VALUE**);
-char *rb_source_filename(const char*);
-void rb_gc_mark_locations(VALUE*, VALUE*);
-void rb_mark_tbl(struct st_table*);
-void rb_mark_set(struct st_table*);
-void rb_mark_hash(struct st_table*);
-void rb_gc_mark_maybe(VALUE);
-void rb_gc_mark(VALUE);
-void rb_gc_force_recycle(VALUE);
-void rb_gc(void);
-void rb_gc_copy_finalizer(VALUE,VALUE);
-void rb_gc_finalize_deferred(void);
-void rb_gc_call_finalizer_at_exit(void);
-VALUE rb_gc_enable(void);
-VALUE rb_gc_disable(void);
-VALUE rb_gc_start(void);
-/* hash.c */
-void st_foreach_safe(struct st_table *, int (*)(ANYARGS), st_data_t);
-void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
-VALUE rb_hash(VALUE);
-VALUE rb_hash_new(void);
-VALUE rb_hash_freeze(VALUE);
-VALUE rb_hash_aref(VALUE, VALUE);
-VALUE rb_hash_lookup(VALUE, VALUE);
-VALUE rb_hash_aset(VALUE, VALUE, VALUE);
-VALUE rb_hash_delete_if(VALUE);
-VALUE rb_hash_delete(VALUE,VALUE);
-struct st_table *rb_hash_tbl(VALUE);
-int rb_path_check(const char*);
-int rb_env_path_tainted(void);
-/* io.c */
-#define rb_defout rb_stdout
-RUBY_EXTERN VALUE rb_fs;
-RUBY_EXTERN VALUE rb_output_fs;
-RUBY_EXTERN VALUE rb_rs;
-RUBY_EXTERN VALUE rb_default_rs;
-RUBY_EXTERN VALUE rb_output_rs;
-VALUE rb_io_write(VALUE, VALUE);
-VALUE rb_io_gets(VALUE);
-VALUE rb_io_getbyte(VALUE);
-VALUE rb_io_ungetc(VALUE, VALUE);
-VALUE rb_io_close(VALUE);
-VALUE rb_io_flush(VALUE);
-VALUE rb_io_eof(VALUE);
-VALUE rb_io_binmode(VALUE);
-VALUE rb_io_addstr(VALUE, VALUE);
-VALUE rb_io_printf(int, VALUE*, VALUE);
-VALUE rb_io_print(int, VALUE*, VALUE);
-VALUE rb_io_puts(int, VALUE*, VALUE);
-VALUE rb_io_fdopen(int, int, const char*);
-VALUE rb_file_open(const char*, const char*);
-VALUE rb_gets(void);
-void rb_write_error(const char*);
-void rb_write_error2(const char*, long);
-/* marshal.c */
-VALUE rb_marshal_dump(VALUE, VALUE);
-VALUE rb_marshal_load(VALUE);
-void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE), VALUE (*loader)(VALUE, VALUE));
-/* numeric.c */
-void rb_num_zerodiv(void);
-VALUE rb_num_coerce_bin(VALUE, VALUE);
-VALUE rb_num_coerce_cmp(VALUE, VALUE);
-VALUE rb_num_coerce_relop(VALUE, VALUE);
-VALUE rb_float_new(double);
-VALUE rb_num2fix(VALUE);
-VALUE rb_fix2str(VALUE, int);
-VALUE rb_dbl_cmp(double, double);
-/* object.c */
-int rb_eql(VALUE, VALUE);
-VALUE rb_any_to_s(VALUE);
-VALUE rb_inspect(VALUE);
-VALUE rb_obj_is_instance_of(VALUE, VALUE);
-VALUE rb_obj_is_kind_of(VALUE, VALUE);
-VALUE rb_obj_alloc(VALUE);
-VALUE rb_obj_clone(VALUE);
-VALUE rb_obj_dup(VALUE);
-VALUE rb_obj_init_copy(VALUE,VALUE);
-VALUE rb_obj_taint(VALUE);
-VALUE rb_obj_tainted(VALUE);
-VALUE rb_obj_untaint(VALUE);
-VALUE rb_obj_freeze(VALUE);
-VALUE rb_obj_frozen_p(VALUE);
-VALUE rb_obj_id(VALUE);
-VALUE rb_obj_class(VALUE);
-VALUE rb_class_real(VALUE);
-VALUE rb_class_inherited_p(VALUE, VALUE);
-VALUE rb_convert_type(VALUE,int,const char*,const char*);
-VALUE rb_check_convert_type(VALUE,int,const char*,const char*);
-VALUE rb_check_to_integer(VALUE, const char *);
-VALUE rb_to_int(VALUE);
-VALUE rb_Integer(VALUE);
-VALUE rb_Float(VALUE);
-VALUE rb_String(VALUE);
-VALUE rb_Array(VALUE);
-double rb_cstr_to_dbl(const char*, int);
-double rb_str_to_dbl(VALUE, int);
-/* parse.y */
-RUBY_EXTERN int ruby_sourceline;
-RUBY_EXTERN char *ruby_sourcefile;
-ID rb_id_attrset(ID);
-void rb_gc_mark_parser(void);
-int rb_is_const_id(ID);
-int rb_is_instance_id(ID);
-int rb_is_class_id(ID);
-int rb_is_local_id(ID);
-int rb_is_junk_id(ID);
-int rb_symname_p(const char*);
-int rb_sym_interned_p(VALUE);
-void rb_gc_mark_symbols(void);
-VALUE rb_backref_get(void);
-void rb_backref_set(VALUE);
-VALUE rb_lastline_get(void);
-void rb_lastline_set(VALUE);
-VALUE rb_sym_all_symbols(void);
-/* process.c */
-void rb_last_status_set(int status, rb_pid_t pid);
-VALUE rb_last_status_get(void);
-struct rb_exec_arg {
- int argc;
- VALUE *argv;
- const char *prog;
-};
-int rb_proc_exec_n(int, VALUE*, const char*);
-int rb_proc_exec(const char*);
-VALUE rb_check_argv(int, VALUE*);
-int rb_exec(const struct rb_exec_arg*);
-rb_pid_t rb_fork(int*, int (*)(void*), void*);
-VALUE rb_f_exec(int,VALUE*);
-rb_pid_t rb_waitpid(rb_pid_t pid, int *status, int flags);
-void rb_syswait(rb_pid_t pid);
-rb_pid_t rb_spawn(int, VALUE*);
-VALUE rb_proc_times(VALUE);
-VALUE rb_detach_process(rb_pid_t pid);
-/* range.c */
-VALUE rb_range_new(VALUE, VALUE, int);
-VALUE rb_range_beg_len(VALUE, long*, long*, long, int);
-/* random.c */
-unsigned long rb_genrand_int32(void);
-double rb_genrand_real(void);
-/* re.c */
-#define rb_memcmp memcmp
-int rb_memcicmp(const void*,const void*,long);
-long rb_memsearch(const void*,long,const void*,long);
-VALUE rb_reg_nth_defined(int, VALUE);
-VALUE rb_reg_nth_match(int, VALUE);
-VALUE rb_reg_last_match(VALUE);
-VALUE rb_reg_match_pre(VALUE);
-VALUE rb_reg_match_post(VALUE);
-VALUE rb_reg_match_last(VALUE);
-VALUE rb_reg_new(VALUE, int);
-VALUE rb_reg_match(VALUE, VALUE);
-VALUE rb_reg_match2(VALUE);
-int rb_reg_options(VALUE);
-void rb_set_kcode(const char*);
-const char* rb_get_kcode(void);
-/* ruby.c */
-RUBY_EXTERN VALUE rb_argv;
-RUBY_EXTERN VALUE rb_argv0;
-void *rb_load_file(const char*);
-void ruby_script(const char*);
-void ruby_prog_init(void);
-void ruby_set_argv(int, char**);
-void *ruby_process_options(int, char**);
-void ruby_init_loadpath(void);
-void ruby_incpush(const char*);
-/* signal.c */
-VALUE rb_f_kill(int, VALUE*);
-void rb_gc_mark_trap_list(void);
-#ifdef POSIX_SIGNAL
-#define posix_signal ruby_posix_signal
-RETSIGTYPE (*posix_signal(int, RETSIGTYPE (*)(int)))(int);
-#endif
-void ruby_sig_finalize(void);
-void rb_trap_exit(void);
-void rb_trap_exec(void);
-const char *ruby_signal_name(int);
-void ruby_default_signal(int);
-/* sprintf.c */
-VALUE rb_f_sprintf(int, const VALUE*);
-PRINTF_ARGS(VALUE rb_sprintf(const char*, ...), 1, 2);
-VALUE rb_vsprintf(const char*, va_list);
-VALUE rb_str_format(int, const VALUE *, VALUE);
-/* string.c */
-VALUE rb_str_new(const char*, long);
-VALUE rb_str_new2(const char*);
-VALUE rb_str_new3(VALUE);
-VALUE rb_str_new4(VALUE);
-VALUE rb_str_new5(VALUE, const char*, long);
-VALUE rb_tainted_str_new(const char*, long);
-VALUE rb_tainted_str_new2(const char*);
-VALUE rb_str_buf_new(long);
-VALUE rb_str_buf_new2(const char*);
-void rb_str_free(VALUE);
-VALUE rb_str_buf_append(VALUE, VALUE);
-VALUE rb_str_buf_cat(VALUE, const char*, long);
-VALUE rb_str_buf_cat2(VALUE, const char*);
-VALUE rb_obj_as_string(VALUE);
-VALUE rb_check_string_type(VALUE);
-VALUE rb_str_dup(VALUE);
-VALUE rb_str_locktmp(VALUE);
-VALUE rb_str_unlocktmp(VALUE);
-VALUE rb_str_dup_frozen(VALUE);
-VALUE rb_str_plus(VALUE, VALUE);
-VALUE rb_str_times(VALUE, VALUE);
-int rb_str_sublen(VALUE, int);
-VALUE rb_str_substr(VALUE, long, long);
-VALUE rb_str_subseq(VALUE, long, long);
-void rb_str_modify(VALUE);
-VALUE rb_str_freeze(VALUE);
-void rb_str_set_len(VALUE, long);
-VALUE rb_str_resize(VALUE, long);
-VALUE rb_str_cat(VALUE, const char*, long);
-VALUE rb_str_cat2(VALUE, const char*);
-VALUE rb_str_append(VALUE, VALUE);
-VALUE rb_str_concat(VALUE, VALUE);
-int rb_memhash(const void *ptr, long len);
-int rb_str_hash(VALUE);
-int rb_str_comparable(VALUE, VALUE);
-int rb_str_cmp(VALUE, VALUE);
-VALUE rb_str_equal(VALUE str1, VALUE str2);
-void rb_str_update(VALUE, long, long, VALUE);
-VALUE rb_str_inspect(VALUE);
-VALUE rb_str_dump(VALUE);
-VALUE rb_str_split(VALUE, const char*);
-void rb_str_associate(VALUE, VALUE);
-VALUE rb_str_associated(VALUE);
-void rb_str_setter(VALUE, ID, VALUE*);
-VALUE rb_str_intern(VALUE);
-VALUE rb_sym_to_s(VALUE);
-VALUE rb_str_length(VALUE);
-/* struct.c */
-VALUE rb_struct_new(VALUE, ...);
-VALUE rb_struct_define(const char*, ...);
-VALUE rb_struct_alloc(VALUE, VALUE);
-VALUE rb_struct_initialize(VALUE, VALUE);
-VALUE rb_struct_aref(VALUE, VALUE);
-VALUE rb_struct_aset(VALUE, VALUE, VALUE);
-VALUE rb_struct_getmember(VALUE, ID);
-VALUE rb_struct_iv_get(VALUE, const char*);
-VALUE rb_struct_s_members(VALUE);
-VALUE rb_struct_members(VALUE);
-VALUE rb_struct_alloc_noinit(VALUE);
-VALUE rb_struct_define_without_accessor(char *, VALUE, rb_alloc_func_t, ...);
-/* thread.c */
-typedef void rb_unblock_function_t(void *);
-typedef VALUE rb_blocking_function_t(void *);
-VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
- rb_unblock_function_t *ubf, void *data2);
-#define RB_UBF_DFL ((rb_unblock_function_t *)-1)
-VALUE rb_mutex_new(void);
-VALUE rb_mutex_locked_p(VALUE mutex);
-VALUE rb_mutex_try_lock(VALUE mutex);
-VALUE rb_mutex_lock(VALUE mutex);
-VALUE rb_mutex_unlock(VALUE mutex);
-VALUE rb_mutex_sleep(VALUE self, VALUE timeout);
-VALUE rb_mutex_synchronize(VALUE self);
-VALUE rb_barrier_new(void);
-VALUE rb_barrier_wait(VALUE self);
-VALUE rb_barrier_release(VALUE self);
-/* time.c */
-VALUE rb_time_new(time_t, long);
-VALUE rb_time_nano_new(time_t, long);
-/* variable.c */
-VALUE rb_mod_name(VALUE);
-VALUE rb_class_path(VALUE);
-void rb_set_class_path(VALUE, VALUE, const char*);
-VALUE rb_path2class(const char*);
-void rb_name_class(VALUE, ID);
-VALUE rb_class_name(VALUE);
-void rb_autoload(VALUE, ID, const char*);
-VALUE rb_autoload_load(VALUE, ID);
-VALUE rb_autoload_p(VALUE, ID);
-void rb_gc_mark_global_tbl(void);
-VALUE rb_f_trace_var(int, VALUE*);
-VALUE rb_f_untrace_var(int, VALUE*);
-VALUE rb_f_global_variables(void);
-void rb_alias_variable(ID, ID);
-struct st_table* rb_generic_ivar_table(VALUE);
-void rb_copy_generic_ivar(VALUE,VALUE);
-void rb_mark_generic_ivar(VALUE);
-void rb_mark_generic_ivar_tbl(void);
-void rb_free_generic_ivar(VALUE);
-VALUE rb_ivar_get(VALUE, ID);
-VALUE rb_ivar_set(VALUE, ID, VALUE);
-VALUE rb_ivar_defined(VALUE, ID);
-void rb_ivar_foreach(VALUE, int (*)(ANYARGS), st_data_t);
-VALUE rb_iv_set(VALUE, const char*, VALUE);
-VALUE rb_iv_get(VALUE, const char*);
-VALUE rb_attr_get(VALUE, ID);
-VALUE rb_obj_instance_variables(VALUE);
-VALUE rb_obj_remove_instance_variable(VALUE, VALUE);
-void *rb_mod_const_at(VALUE, void*);
-void *rb_mod_const_of(VALUE, void*);
-VALUE rb_const_list(void*);
-VALUE rb_mod_constants(int, VALUE *, VALUE);
-VALUE rb_mod_remove_const(VALUE, VALUE);
-int rb_const_defined(VALUE, ID);
-int rb_const_defined_at(VALUE, ID);
-int rb_const_defined_from(VALUE, ID);
-VALUE rb_const_get(VALUE, ID);
-VALUE rb_const_get_at(VALUE, ID);
-VALUE rb_const_get_from(VALUE, ID);
-void rb_const_set(VALUE, ID, VALUE);
-VALUE rb_mod_const_missing(VALUE,VALUE);
-VALUE rb_cvar_defined(VALUE, ID);
-void rb_cvar_set(VALUE, ID, VALUE);
-VALUE rb_cvar_get(VALUE, ID);
-void rb_cv_set(VALUE, const char*, VALUE);
-VALUE rb_cv_get(VALUE, const char*);
-void rb_define_class_variable(VALUE, const char*, VALUE);
-VALUE rb_mod_class_variables(VALUE);
-VALUE rb_mod_remove_cvar(VALUE, VALUE);
-/* version.c */
-void ruby_show_version(void);
-void ruby_show_copyright(void);
-
-ID rb_frame_callee(void);
-VALUE rb_str_succ(VALUE);
-VALUE rb_time_succ(VALUE);
-void Init_stack(VALUE*);
-void rb_frame_pop(void);
-int rb_frame_method_id_and_class(ID *idp, VALUE *klassp);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_INTERN_H */
diff --git a/include/ruby/io.h b/include/ruby/io.h
deleted file mode 100644
index 1e605ea8ca..0000000000
--- a/include/ruby/io.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/**********************************************************************
-
- rubyio.h -
-
- $Author$
- $Date$
- created at: Fri Nov 12 16:47:09 JST 1993
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_IO_H
-#define RUBY_IO_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include "ruby/encoding.h"
-
-#if defined(HAVE_STDIO_EXT_H)
-#include <stdio_ext.h>
-#endif
-
-typedef struct rb_io_t {
- int fd; /* file descriptor */
- FILE *stdio_file; /* stdio ptr for read/write if available */
- int mode; /* mode flags */
- rb_pid_t pid; /* child's pid (for pipes) */
- int lineno; /* number of lines read */
- char *path; /* pathname for file */
- void (*finalize)(struct rb_io_t*,int); /* finalize proc */
- long refcnt;
- char *wbuf; /* wbuf_off + wbuf_len <= wbuf_capa */
- int wbuf_off;
- int wbuf_len;
- int wbuf_capa;
- char *rbuf; /* rbuf_off + rbuf_len <= rbuf_capa */
- int rbuf_off;
- int rbuf_len;
- int rbuf_capa;
- VALUE tied_io_for_writing;
- rb_encoding *enc;
- rb_encoding *enc2;
-} rb_io_t;
-
-#define HAVE_RB_IO_T 1
-
-#define FMODE_READABLE 1
-#define FMODE_WRITABLE 2
-#define FMODE_READWRITE 3
-#define FMODE_APPEND 64
-#define FMODE_CREATE 128
-#define FMODE_BINMODE 4
-#define FMODE_SYNC 8
-#define FMODE_TTY 16
-#define FMODE_DUPLEX 32
-#define FMODE_WSPLIT 0x200
-#define FMODE_WSPLIT_INITIALIZED 0x400
-
-#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
-
-#define MakeOpenFile(obj, fp) do {\
- if (RFILE(obj)->fptr) {\
- rb_io_close(obj);\
- free(RFILE(obj)->fptr);\
- RFILE(obj)->fptr = 0;\
- }\
- fp = 0;\
- fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
- fp->fd = -1;\
- fp->stdio_file = NULL;\
- fp->mode = 0;\
- fp->pid = 0;\
- fp->lineno = 0;\
- fp->path = NULL;\
- fp->finalize = 0;\
- fp->refcnt = 1;\
- fp->wbuf = NULL;\
- fp->wbuf_off = 0;\
- fp->wbuf_len = 0;\
- fp->wbuf_capa = 0;\
- fp->rbuf = NULL;\
- fp->rbuf_off = 0;\
- fp->rbuf_len = 0;\
- fp->rbuf_capa = 0;\
- fp->tied_io_for_writing = 0;\
- fp->enc = 0;\
- fp->enc2 = 0;\
-} while (0)
-
-FILE *rb_io_stdio_file(rb_io_t *fptr);
-
-FILE *rb_fopen(const char*, const char*);
-FILE *rb_fdopen(int, const char*);
-int rb_io_mode_flags(const char*);
-int rb_io_modenum_flags(int);
-void rb_io_check_writable(rb_io_t*);
-void rb_io_check_readable(rb_io_t*);
-int rb_io_fptr_finalize(rb_io_t*);
-void rb_io_synchronized(rb_io_t*);
-void rb_io_check_initialized(rb_io_t*);
-void rb_io_check_closed(rb_io_t*);
-int rb_io_wait_readable(int);
-int rb_io_wait_writable(int);
-void rb_io_set_nonblock(rb_io_t *fptr);
-
-VALUE rb_io_taint_check(VALUE);
-NORETURN(void rb_eof_error(void));
-
-void rb_io_read_check(rb_io_t*);
-int rb_io_read_pending(rb_io_t*);
-void rb_read_check(FILE*);
-
-DEPRECATED(int rb_getc(FILE*));
-DEPRECATED(long rb_io_fread(char *, long, FILE *));
-DEPRECATED(long rb_io_fwrite(const char *, long, FILE *));
-DEPRECATED(int rb_read_pending(FILE*));
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_IO_H */
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
deleted file mode 100644
index 05002daea8..0000000000
--- a/include/ruby/missing.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/************************************************
-
- missing.h - prototype for *.c in ./missing, and
- for missing timeval struct
-
- $Author$
- $Date$
- created at: Sat May 11 23:46:03 JST 2002
-
-************************************************/
-
-#ifndef RUBY_MISSING_H
-#define RUBY_MISSING_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#if defined(HAVE_SYS_TIME_H)
-# include <sys/time.h>
-#elif !defined(_WIN32)
-# define time_t long
-struct timeval {
- time_t tv_sec; /* seconds */
- long tv_usec; /* microseconds */
-};
-#endif
-#if defined(HAVE_SYS_TYPES_H)
-# include <sys/types.h>
-#endif
-
-#if !defined(HAVE_STRUCT_TIMESPEC)
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* nanoseconds */
-};
-#endif
-
-#ifndef HAVE_ACOSH
-extern double acosh(double);
-extern double asinh(double);
-extern double atanh(double);
-#endif
-
-#ifndef HAVE_CRYPT
-extern char *crypt(const char *, const char *);
-#endif
-
-#ifndef HAVE_DUP2
-extern int dup2(int, int);
-#endif
-
-#ifndef HAVE_EACCESS
-extern int eaccess(const char*, int);
-#endif
-
-#ifndef HAVE_FINITE
-extern int finite(double);
-#endif
-
-#ifndef HAVE_FLOCK
-extern int flock(int, int);
-#endif
-
-/*
-#ifndef HAVE_FREXP
-extern double frexp(double, int *);
-#endif
-*/
-
-#ifndef HAVE_HYPOT
-extern double hypot(double, double);
-#endif
-
-#ifndef HAVE_ERF
-extern double erf(double);
-extern double erfc(double);
-#endif
-
-#ifndef isinf
-# ifndef HAVE_ISINF
-# if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
-# define isinf(x) (!finite(x) && !isnan(x))
-# else
-extern int isinf(double);
-# endif
-# endif
-#endif
-
-#ifndef HAVE_ISNAN
-extern int isnan(double);
-#endif
-
-/*
-#ifndef HAVE_MEMCMP
-extern int memcmp(const void *, const void *, size_t);
-#endif
-*/
-
-#ifndef HAVE_MEMMOVE
-extern void *memmove(void *, const void *, size_t);
-#endif
-
-/*
-#ifndef HAVE_MODF
-extern double modf(double, double *);
-#endif
-*/
-
-#ifndef HAVE_STRCASECMP
-extern int strcasecmp(const char *, const char *);
-#endif
-
-#ifndef HAVE_STRNCASECMP
-extern int strncasecmp(const char *, const char *, size_t);
-#endif
-
-#ifndef HAVE_STRCHR
-extern char *strchr(const char *, int);
-extern char *strrchr(const char *, int);
-#endif
-
-#ifndef HAVE_STRERROR
-extern char *strerror(int);
-#endif
-
-#ifndef HAVE_STRFTIME
-extern size_t strftime(char *, size_t, const char *, const struct tm *);
-#endif
-
-#ifndef HAVE_STRSTR
-extern char *strstr(const char *, const char *);
-#endif
-
-/*
-#ifndef HAVE_STRTOL
-extern long strtol(const char *, char **, int);
-#endif
-*/
-
-#ifndef HAVE_STRTOUL
-extern unsigned long strtoul(const char *, char **, int);
-#endif
-
-#ifndef HAVE_VSNPRINTF
-# include <stdarg.h>
-extern int snprintf(char *, size_t n, char const *, ...);
-extern int vsnprintf(char *, size_t n, char const *, va_list);
-#endif
-
-#ifndef HAVE_STRLCPY
-extern size_t strlcpy(char *, const char*, size_t);
-#endif
-
-#ifndef HAVE_STRLCAT
-extern size_t strlcat(char *, const char*, size_t);
-#endif
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_MISSING_H */
diff --git a/include/ruby/node.h b/include/ruby/node.h
deleted file mode 100644
index b93d72596d..0000000000
--- a/include/ruby/node.h
+++ /dev/null
@@ -1,509 +0,0 @@
-/**********************************************************************
-
- node.h -
-
- $Author$
- $Date$
- created at: Fri May 28 15:14:02 JST 1993
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_NODE_H
-#define RUBY_NODE_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-enum node_type {
- NODE_METHOD,
-#define NODE_METHOD NODE_METHOD
- NODE_FBODY,
-#define NODE_FBODY NODE_FBODY
- NODE_CFUNC,
-#define NODE_CFUNC NODE_CFUNC
- NODE_SCOPE,
-#define NODE_SCOPE NODE_SCOPE
- NODE_BLOCK,
-#define NODE_BLOCK NODE_BLOCK
- NODE_IF,
-#define NODE_IF NODE_IF
- NODE_CASE,
-#define NODE_CASE NODE_CASE
- NODE_WHEN,
-#define NODE_WHEN NODE_WHEN
- NODE_OPT_N,
-#define NODE_OPT_N NODE_OPT_N
- NODE_WHILE,
-#define NODE_WHILE NODE_WHILE
- NODE_UNTIL,
-#define NODE_UNTIL NODE_UNTIL
- NODE_ITER,
-#define NODE_ITER NODE_ITER
- NODE_FOR,
-#define NODE_FOR NODE_FOR
- NODE_BREAK,
-#define NODE_BREAK NODE_BREAK
- NODE_NEXT,
-#define NODE_NEXT NODE_NEXT
- NODE_REDO,
-#define NODE_REDO NODE_REDO
- NODE_RETRY,
-#define NODE_RETRY NODE_RETRY
- NODE_BEGIN,
-#define NODE_BEGIN NODE_BEGIN
- NODE_RESCUE,
-#define NODE_RESCUE NODE_RESCUE
- NODE_RESBODY,
-#define NODE_RESBODY NODE_RESBODY
- NODE_ENSURE,
-#define NODE_ENSURE NODE_ENSURE
- NODE_AND,
-#define NODE_AND NODE_AND
- NODE_OR,
-#define NODE_OR NODE_OR
- NODE_MASGN,
-#define NODE_MASGN NODE_MASGN
- NODE_LASGN,
-#define NODE_LASGN NODE_LASGN
- NODE_DASGN,
-#define NODE_DASGN NODE_DASGN
- NODE_DASGN_CURR,
-#define NODE_DASGN_CURR NODE_DASGN_CURR
- NODE_GASGN,
-#define NODE_GASGN NODE_GASGN
- NODE_IASGN,
-#define NODE_IASGN NODE_IASGN
- NODE_IASGN2,
-#define NODE_IASGN2 NODE_IASGN2
- NODE_CDECL,
-#define NODE_CDECL NODE_CDECL
- NODE_CVASGN,
-#define NODE_CVASGN NODE_CVASGN
- NODE_CVDECL,
-#define NODE_CVDECL NODE_CVDECL
- NODE_OP_ASGN1,
-#define NODE_OP_ASGN1 NODE_OP_ASGN1
- NODE_OP_ASGN2,
-#define NODE_OP_ASGN2 NODE_OP_ASGN2
- NODE_OP_ASGN_AND,
-#define NODE_OP_ASGN_AND NODE_OP_ASGN_AND
- NODE_OP_ASGN_OR,
-#define NODE_OP_ASGN_OR NODE_OP_ASGN_OR
- NODE_CALL,
-#define NODE_CALL NODE_CALL
- NODE_FCALL,
-#define NODE_FCALL NODE_FCALL
- NODE_VCALL,
-#define NODE_VCALL NODE_VCALL
- NODE_SUPER,
-#define NODE_SUPER NODE_SUPER
- NODE_ZSUPER,
-#define NODE_ZSUPER NODE_ZSUPER
- NODE_ARRAY,
-#define NODE_ARRAY NODE_ARRAY
- NODE_ZARRAY,
-#define NODE_ZARRAY NODE_ZARRAY
- NODE_VALUES,
-#define NODE_VALUES NODE_VALUES
- NODE_HASH,
-#define NODE_HASH NODE_HASH
- NODE_RETURN,
-#define NODE_RETURN NODE_RETURN
- NODE_YIELD,
-#define NODE_YIELD NODE_YIELD
- NODE_LVAR,
-#define NODE_LVAR NODE_LVAR
- NODE_DVAR,
-#define NODE_DVAR NODE_DVAR
- NODE_GVAR,
-#define NODE_GVAR NODE_GVAR
- NODE_IVAR,
-#define NODE_IVAR NODE_IVAR
- NODE_CONST,
-#define NODE_CONST NODE_CONST
- NODE_CVAR,
-#define NODE_CVAR NODE_CVAR
- NODE_NTH_REF,
-#define NODE_NTH_REF NODE_NTH_REF
- NODE_BACK_REF,
-#define NODE_BACK_REF NODE_BACK_REF
- NODE_MATCH,
-#define NODE_MATCH NODE_MATCH
- NODE_MATCH2,
-#define NODE_MATCH2 NODE_MATCH2
- NODE_MATCH3,
-#define NODE_MATCH3 NODE_MATCH3
- NODE_LIT,
-#define NODE_LIT NODE_LIT
- NODE_STR,
-#define NODE_STR NODE_STR
- NODE_DSTR,
-#define NODE_DSTR NODE_DSTR
- NODE_XSTR,
-#define NODE_XSTR NODE_XSTR
- NODE_DXSTR,
-#define NODE_DXSTR NODE_DXSTR
- NODE_EVSTR,
-#define NODE_EVSTR NODE_EVSTR
- NODE_DREGX,
-#define NODE_DREGX NODE_DREGX
- NODE_DREGX_ONCE,
-#define NODE_DREGX_ONCE NODE_DREGX_ONCE
- NODE_ARGS,
-#define NODE_ARGS NODE_ARGS
- NODE_ARGS_AUX,
-#define NODE_ARGS_AUX NODE_ARGS_AUX
- NODE_OPT_ARG,
-#define NODE_OPT_ARG NODE_OPT_ARG
- NODE_POSTARG,
-#define NODE_POSTARG NODE_POSTARG
- NODE_ARGSCAT,
-#define NODE_ARGSCAT NODE_ARGSCAT
- NODE_ARGSPUSH,
-#define NODE_ARGSPUSH NODE_ARGSPUSH
- NODE_SPLAT,
-#define NODE_SPLAT NODE_SPLAT
- NODE_TO_ARY,
-#define NODE_TO_ARY NODE_TO_ARY
- NODE_BLOCK_ARG,
-#define NODE_BLOCK_ARG NODE_BLOCK_ARG
- NODE_BLOCK_PASS,
-#define NODE_BLOCK_PASS NODE_BLOCK_PASS
- NODE_DEFN,
-#define NODE_DEFN NODE_DEFN
- NODE_DEFS,
-#define NODE_DEFS NODE_DEFS
- NODE_ALIAS,
-#define NODE_ALIAS NODE_ALIAS
- NODE_VALIAS,
-#define NODE_VALIAS NODE_VALIAS
- NODE_UNDEF,
-#define NODE_UNDEF NODE_UNDEF
- NODE_CLASS,
-#define NODE_CLASS NODE_CLASS
- NODE_MODULE,
-#define NODE_MODULE NODE_MODULE
- NODE_SCLASS,
-#define NODE_SCLASS NODE_SCLASS
- NODE_COLON2,
-#define NODE_COLON2 NODE_COLON2
- NODE_COLON3,
-#define NODE_COLON3 NODE_COLON3
- NODE_DOT2,
-#define NODE_DOT2 NODE_DOT2
- NODE_DOT3,
-#define NODE_DOT3 NODE_DOT3
- NODE_FLIP2,
-#define NODE_FLIP2 NODE_FLIP2
- NODE_FLIP3,
-#define NODE_FLIP3 NODE_FLIP3
- NODE_ATTRSET,
-#define NODE_ATTRSET NODE_ATTRSET
- NODE_SELF,
-#define NODE_SELF NODE_SELF
- NODE_NIL,
-#define NODE_NIL NODE_NIL
- NODE_TRUE,
-#define NODE_TRUE NODE_TRUE
- NODE_FALSE,
-#define NODE_FALSE NODE_FALSE
- NODE_ERRINFO,
-#define NODE_ERRINFO NODE_ERRINFO
- NODE_DEFINED,
-#define NODE_DEFINED NODE_DEFINED
- NODE_POSTEXE,
-#define NODE_POSTEXE NODE_POSTEXE
- NODE_ALLOCA,
-#define NODE_ALLOCA NODE_ALLOCA
- NODE_BMETHOD,
-#define NODE_BMETHOD NODE_BMETHOD
- NODE_MEMO,
-#define NODE_MEMO NODE_MEMO
- NODE_IFUNC,
-#define NODE_IFUNC NODE_IFUNC
- NODE_DSYM,
-#define NODE_DSYM NODE_DSYM
- NODE_ATTRASGN,
-#define NODE_ATTRASGN NODE_ATTRASGN
- NODE_PRELUDE,
-#define NODE_PRELUDE NODE_PRELUDE
- NODE_LAMBDA,
-#define NODE_LAMBDA NODE_LAMBDA
- NODE_OPTBLOCK,
-#define NODE_OPTBLOCK NODE_OPTBLOCK
- NODE_LAST
-#define NODE_LAST NODE_LAST
-};
-
-typedef struct RNode {
- unsigned long flags;
- char *nd_file;
- union {
- struct RNode *node;
- ID id;
- VALUE value;
- VALUE (*cfunc)(ANYARGS);
- ID *tbl;
- } u1;
- union {
- struct RNode *node;
- ID id;
- long argc;
- VALUE value;
- } u2;
- union {
- struct RNode *node;
- ID id;
- long state;
- struct global_entry *entry;
- long cnt;
- VALUE value;
- } u3;
-} NODE;
-
-#define RNODE(obj) (R_CAST(RNode)(obj))
-
-/* 0..4:T_TYPES, 5:FL_MARK, 6:reserved, 7:NODE_NEWLINE */
-#define NODE_NEWLINE (((VALUE)1)<<7)
-
-#define NODE_TYPESHIFT 8
-#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
-
-#define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
-#define nd_set_type(n,t) \
- RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|(((t)<<NODE_TYPESHIFT)&NODE_TYPEMASK))
-
-#define NODE_LSHIFT (NODE_TYPESHIFT+7)
-#define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
-#define nd_line(n) ((VALUE)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
-#define nd_set_line(n,l) \
- RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
-
-#define nd_head u1.node
-#define nd_alen u2.argc
-#define nd_next u3.node
-
-#define nd_cond u1.node
-#define nd_body u2.node
-#define nd_else u3.node
-
-#define nd_orig u3.value
-
-#define nd_resq u2.node
-#define nd_ensr u3.node
-
-#define nd_1st u1.node
-#define nd_2nd u2.node
-
-#define nd_stts u1.node
-
-#define nd_entry u3.entry
-#define nd_vid u1.id
-#define nd_cflag u2.id
-#define nd_cval u3.value
-
-#define nd_oid u1.id
-#define nd_cnt u3.cnt
-#define nd_tbl u1.tbl
-
-#define nd_var u1.node
-#define nd_iter u3.node
-
-#define nd_value u2.node
-#define nd_aid u3.id
-
-#define nd_lit u1.value
-
-#define nd_frml u2.argc
-#define nd_rest u1.id
-#define nd_opt u1.node
-#define nd_pid u1.id
-#define nd_plen u2.argc
-
-#define nd_recv u1.node
-#define nd_mid u2.id
-#define nd_args u3.node
-
-#define nd_noex u3.id
-#define nd_defn u3.node
-
-#define nd_cfnc u1.cfunc
-#define nd_argc u2.argc
-
-#define nd_cpath u1.node
-#define nd_super u3.node
-
-#define nd_modl u1.id
-#define nd_clss u1.value
-
-#define nd_beg u1.node
-#define nd_end u2.node
-#define nd_state u3.state
-#define nd_rval u2.value
-
-#define nd_nth u2.argc
-
-#define nd_tag u1.id
-#define nd_tval u2.value
-
-#define nd_visi u2.argc
-
-#define NEW_NODE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
-
-#define NEW_METHOD(n,x,v) NEW_NODE(NODE_METHOD,x,n,v)
-#define NEW_FBODY(n,i) NEW_NODE(NODE_FBODY,i,n,0)
-#define NEW_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d))
-#define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d))
-#define NEW_CFUNC(f,c) NEW_NODE(NODE_CFUNC,f,c,0)
-#define NEW_IFUNC(f,c) NEW_NODE(NODE_IFUNC,f,c,0)
-#define NEW_SCOPE(a,b) NEW_NODE(NODE_SCOPE,local_tbl(),b,a)
-#define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
-#define NEW_IF(c,t,e) NEW_NODE(NODE_IF,c,t,e)
-#define NEW_UNLESS(c,t,e) NEW_IF(c,e,t)
-#define NEW_CASE(h,b) NEW_NODE(NODE_CASE,h,b,0)
-#define NEW_WHEN(c,t,e) NEW_NODE(NODE_WHEN,c,t,e)
-#define NEW_OPT_N(b) NEW_NODE(NODE_OPT_N,0,b,0)
-#define NEW_WHILE(c,b,n) NEW_NODE(NODE_WHILE,c,b,n)
-#define NEW_UNTIL(c,b,n) NEW_NODE(NODE_UNTIL,c,b,n)
-#define NEW_FOR(v,i,b) NEW_NODE(NODE_FOR,v,b,i)
-#define NEW_ITER(a,b) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b),0)
-#define NEW_LAMBDA(a) NEW_NODE(NODE_LAMBDA,a,0,0)
-#define NEW_BREAK(s) NEW_NODE(NODE_BREAK,s,0,0)
-#define NEW_NEXT(s) NEW_NODE(NODE_NEXT,s,0,0)
-#define NEW_REDO() NEW_NODE(NODE_REDO,0,0,0)
-#define NEW_RETRY() NEW_NODE(NODE_RETRY,0,0,0)
-#define NEW_BEGIN(b) NEW_NODE(NODE_BEGIN,0,b,0)
-#define NEW_RESCUE(b,res,e) NEW_NODE(NODE_RESCUE,b,res,e)
-#define NEW_RESBODY(a,ex,n) NEW_NODE(NODE_RESBODY,n,ex,a)
-#define NEW_ENSURE(b,en) NEW_NODE(NODE_ENSURE,b,0,en)
-#define NEW_RETURN(s) NEW_NODE(NODE_RETURN,s,0,0)
-#define NEW_YIELD(a,s) NEW_NODE(NODE_YIELD,a,0,s)
-#define NEW_LIST(a) NEW_ARRAY(a)
-#define NEW_ARRAY(a) NEW_NODE(NODE_ARRAY,a,1,0)
-#define NEW_ZARRAY() NEW_NODE(NODE_ZARRAY,0,0,0)
-#define NEW_HASH(a) NEW_NODE(NODE_HASH,a,0,0)
-#define NEW_MASGN(l,r) NEW_NODE(NODE_MASGN,l,0,r)
-#define NEW_GASGN(v,val) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v))
-#define NEW_LASGN(v,val) NEW_NODE(NODE_LASGN,v,val,0)
-#define NEW_DASGN(v,val) NEW_NODE(NODE_DASGN,v,val,0)
-#define NEW_DASGN_CURR(v,val) NEW_NODE(NODE_DASGN_CURR,v,val,0)
-#define NEW_IASGN(v,val) NEW_NODE(NODE_IASGN,v,val,0)
-#define NEW_IASGN2(v,val) NEW_NODE(NODE_IASGN2,v,val,0)
-#define NEW_CDECL(v,val,path) NEW_NODE(NODE_CDECL,v,val,path)
-#define NEW_CVASGN(v,val) NEW_NODE(NODE_CVASGN,v,val,0)
-#define NEW_CVDECL(v,val) NEW_NODE(NODE_CVDECL,v,val,0)
-#define NEW_OP_ASGN1(p,id,a) NEW_NODE(NODE_OP_ASGN1,p,id,a)
-#define NEW_OP_ASGN2(r,i,o,val) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o))
-#define NEW_OP_ASGN22(i,o) NEW_NODE(NODE_OP_ASGN2,i,o,rb_id_attrset(i))
-#define NEW_OP_ASGN_OR(i,val) NEW_NODE(NODE_OP_ASGN_OR,i,val,0)
-#define NEW_OP_ASGN_AND(i,val) NEW_NODE(NODE_OP_ASGN_AND,i,val,0)
-#define NEW_GVAR(v) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v))
-#define NEW_LVAR(v) NEW_NODE(NODE_LVAR,v,0,0)
-#define NEW_DVAR(v) NEW_NODE(NODE_DVAR,v,0,0)
-#define NEW_IVAR(v) NEW_NODE(NODE_IVAR,v,0,0)
-#define NEW_CONST(v) NEW_NODE(NODE_CONST,v,0,0)
-#define NEW_CVAR(v) NEW_NODE(NODE_CVAR,v,0,0)
-#define NEW_NTH_REF(n) NEW_NODE(NODE_NTH_REF,0,n,0)
-#define NEW_BACK_REF(n) NEW_NODE(NODE_BACK_REF,0,n,0)
-#define NEW_MATCH(c) NEW_NODE(NODE_MATCH,c,0,0)
-#define NEW_MATCH2(n1,n2) NEW_NODE(NODE_MATCH2,n1,n2,0)
-#define NEW_MATCH3(r,n2) NEW_NODE(NODE_MATCH3,r,n2,0)
-#define NEW_LIT(l) NEW_NODE(NODE_LIT,l,0,0)
-#define NEW_STR(s) NEW_NODE(NODE_STR,s,0,0)
-#define NEW_DSTR(s) NEW_NODE(NODE_DSTR,s,1,0)
-#define NEW_XSTR(s) NEW_NODE(NODE_XSTR,s,0,0)
-#define NEW_DXSTR(s) NEW_NODE(NODE_DXSTR,s,0,0)
-#define NEW_DSYM(s) NEW_NODE(NODE_DSYM,s,0,0)
-#define NEW_EVSTR(n) NEW_NODE(NODE_EVSTR,0,(n),0)
-#define NEW_CALL(r,m,a) NEW_NODE(NODE_CALL,r,m,a)
-#define NEW_FCALL(m,a) NEW_NODE(NODE_FCALL,0,m,a)
-#define NEW_VCALL(m) NEW_NODE(NODE_VCALL,0,m,0)
-#define NEW_SUPER(a) NEW_NODE(NODE_SUPER,0,0,a)
-#define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
-#define NEW_ARGS(m,o) NEW_NODE(NODE_ARGS,o,m,0)
-#define NEW_ARGS_AUX(r,b) NEW_NODE(NODE_ARGS_AUX,r,b,0)
-#define NEW_OPT_ARG(i,v) NEW_NODE(NODE_OPT_ARG,i,v,0)
-#define NEW_POSTARG(i,v) NEW_NODE(NODE_POSTARG,i,v,0)
-#define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
-#define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
-#define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
-#define NEW_TO_ARY(a) NEW_NODE(NODE_TO_ARY,a,0,0)
-#define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
-#define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
-#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
-#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0)
-#define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0)
-#define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b),(s))
-#define NEW_SCLASS(r,b) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b),0)
-#define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b),0)
-#define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
-#define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
-#define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
-#define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
-#define NEW_ATTRSET(a) NEW_NODE(NODE_ATTRSET,a,0,0)
-#define NEW_SELF() NEW_NODE(NODE_SELF,0,0,0)
-#define NEW_NIL() NEW_NODE(NODE_NIL,0,0,0)
-#define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0)
-#define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0)
-#define NEW_ERRINFO() NEW_NODE(NODE_ERRINFO,0,0,0)
-#define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0)
-#define NEW_PREEXE(b) NEW_SCOPE(b)
-#define NEW_POSTEXE(b) NEW_NODE(NODE_POSTEXE,0,b,0)
-#define NEW_BMETHOD(b) NEW_NODE(NODE_BMETHOD,0,0,b)
-#define NEW_ATTRASGN(r,m,a) NEW_NODE(NODE_ATTRASGN,r,m,a)
-#define NEW_PRELUDE(p,b) NEW_NODE(NODE_PRELUDE,p,b,0)
-#define NEW_OPTBLOCK(a) NEW_NODE(NODE_OPTBLOCK,a,0,0)
-
-#define NOEX_PUBLIC 0x00
-#define NOEX_NOSUPER 0x01
-#define NOEX_PRIVATE 0x02
-#define NOEX_PROTECTED 0x04
-#define NOEX_MASK 0x06 /* 1110 */
-
-#define NOEX_UNDEF NOEX_NOSUPER
-
-#define NOEX_MODFUNC 0x10
-#define NOEX_SUPER 0x20
-#define NOEX_VCALL 0x40
-
-#define NOEX_SAFE(n) (((n) >> 8) & 0x0F)
-#define NOEX_WITH(n, s) ((s << 8) | n)
-#define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level())
-
-VALUE rb_parser_new(void);
-VALUE rb_parser_end_seen_p(VALUE);
-VALUE rb_parser_encoding(VALUE);
-
-NODE *rb_parser_compile_cstr(volatile VALUE, const char*, const char*, int, int);
-NODE *rb_parser_compile_string(volatile VALUE, const char*, VALUE, int);
-NODE *rb_parser_compile_file(volatile VALUE, const char*, VALUE, int);
-
-NODE *rb_compile_cstr(const char*, const char*, int, int);
-NODE *rb_compile_string(const char*, VALUE, int);
-NODE *rb_compile_file(const char*, VALUE, int);
-
-void rb_add_method(VALUE, ID, NODE *, int);
-NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
-
-NODE* rb_method_node(VALUE klass, ID id);
-int rb_node_arity(NODE* node);
-
-struct global_entry *rb_global_entry(ID);
-VALUE rb_gvar_get(struct global_entry *);
-VALUE rb_gvar_set(struct global_entry *, VALUE);
-VALUE rb_gvar_defined(struct global_entry *);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_NODE_H */
diff --git a/include/ruby/oniguruma.h b/include/ruby/oniguruma.h
deleted file mode 100644
index 0cf2e0c6e4..0000000000
--- a/include/ruby/oniguruma.h
+++ /dev/null
@@ -1,846 +0,0 @@
-#ifndef ONIGURUMA_H
-#define ONIGURUMA_H
-/**********************************************************************
- oniguruma.h - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#define ONIGURUMA
-#define ONIGURUMA_VERSION_MAJOR 5
-#define ONIGURUMA_VERSION_MINOR 9
-#define ONIGURUMA_VERSION_TEENY 0
-
-#ifdef __cplusplus
-# ifndef HAVE_PROTOTYPES
-# define HAVE_PROTOTYPES 1
-# endif
-# ifndef HAVE_STDARG_PROTOTYPES
-# define HAVE_STDARG_PROTOTYPES 1
-# endif
-#endif
-
-/* escape Mac OS X/Xcode 2.4/gcc 4.0.1 problem */
-#if defined(__APPLE__) && defined(__GNUC__) && __GNUC__ >= 4
-# ifndef HAVE_STDARG_PROTOTYPES
-# define HAVE_STDARG_PROTOTYPES 1
-# endif
-#endif
-
-#ifndef P_
-#if defined(__STDC__) || defined(_WIN32)
-# define P_(args) args
-#else
-# define P_(args) ()
-#endif
-#endif
-
-#ifndef PV_
-#ifdef HAVE_STDARG_PROTOTYPES
-# define PV_(args) args
-#else
-# define PV_(args) ()
-#endif
-#endif
-
-#ifndef ONIG_EXTERN
-#ifdef RUBY_EXTERN
-#define ONIG_EXTERN RUBY_EXTERN
-#else
-#if defined(_WIN32) && !defined(__GNUC__)
-#if defined(EXPORT) || defined(RUBY_EXPORT)
-#define ONIG_EXTERN extern __declspec(dllexport)
-#else
-#define ONIG_EXTERN extern __declspec(dllimport)
-#endif
-#endif
-#endif
-#endif
-
-#ifndef ONIG_EXTERN
-#define ONIG_EXTERN extern
-#endif
-
-/* PART: character encoding */
-
-#ifndef ONIG_ESCAPE_UCHAR_COLLISION
-#define UChar OnigUChar
-#endif
-
-typedef unsigned char OnigUChar;
-typedef unsigned long OnigCodePoint;
-typedef unsigned int OnigDistance;
-
-#define ONIG_INFINITE_DISTANCE ~((OnigDistance )0)
-
-/* case fold flag */
-typedef unsigned int OnigCaseFoldType;
-
-ONIG_EXTERN OnigCaseFoldType OnigDefaultCaseFoldFlag;
-
-/* #define ONIGENC_CASE_FOLD_HIRAGANA_KATAKANA (1<<1) */
-/* #define ONIGENC_CASE_FOLD_KATAKANA_WIDTH (1<<2) */
-#define ONIGENC_CASE_FOLD_TURKISH_AZERI (1<<20)
-#define INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR (1<<30)
-
-#define ONIGENC_CASE_FOLD_MIN INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR
-#define ONIGENC_CASE_FOLD_DEFAULT OnigDefaultCaseFoldFlag
-
-
-#define ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN 3
-#define ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM 13
-/* 13 => Unicode:0x1ffc */
-
-/* code range */
-#define ONIGENC_CODE_RANGE_NUM(range) ((int )range[0])
-#define ONIGENC_CODE_RANGE_FROM(range,i) range[((i)*2) + 1]
-#define ONIGENC_CODE_RANGE_TO(range,i) range[((i)*2) + 2]
-
-typedef struct {
- int byte_len; /* argument(original) character(s) byte length */
- int code_len; /* number of code */
- OnigCodePoint code[ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN];
-} OnigCaseFoldCodeItem;
-
-typedef struct {
- OnigCodePoint esc;
- OnigCodePoint anychar;
- OnigCodePoint anytime;
- OnigCodePoint zero_or_one_time;
- OnigCodePoint one_or_more_time;
- OnigCodePoint anychar_anytime;
-} OnigMetaCharTableType;
-
-typedef int (*OnigApplyAllCaseFoldFunc)(OnigCodePoint from, OnigCodePoint* to, int to_len, void* arg);
-
-typedef struct OnigEncodingTypeST {
- int (*precise_mbc_enc_len)(const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc);
- const char* name;
- int max_enc_len;
- int min_enc_len;
- int (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
- OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
- int (*code_to_mbclen)(OnigCodePoint code, struct OnigEncodingTypeST* enc);
- int (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf, struct OnigEncodingTypeST* enc);
- int (*mbc_case_fold)(OnigCaseFoldType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, struct OnigEncodingTypeST* enc);
- int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, struct OnigEncodingTypeST* enc);
- int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[], struct OnigEncodingTypeST* enc);
- int (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);
- int (*is_code_ctype)(OnigCodePoint code, unsigned int ctype, struct OnigEncodingTypeST* enc);
- int (*get_ctype_code_range)(int ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], struct OnigEncodingTypeST* enc);
- OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p, struct OnigEncodingTypeST* enc);
- int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
- void *auxiliary_data;
-} OnigEncodingType;
-
-typedef OnigEncodingType* OnigEncoding;
-
-ONIG_EXTERN OnigEncodingType OnigEncodingASCII;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_1;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_2;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_3;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_4;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_5;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_6;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_7;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_8;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_9;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_10;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_11;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_13;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_14;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_15;
-ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_16;
-ONIG_EXTERN OnigEncodingType OnigEncodingUTF8;
-ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_BE;
-ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_LE;
-ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_BE;
-ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_LE;
-ONIG_EXTERN OnigEncodingType OnigEncodingEUC_JP;
-ONIG_EXTERN OnigEncodingType OnigEncodingEUC_TW;
-ONIG_EXTERN OnigEncodingType OnigEncodingEUC_KR;
-ONIG_EXTERN OnigEncodingType OnigEncodingEUC_CN;
-ONIG_EXTERN OnigEncodingType OnigEncodingSJIS;
-ONIG_EXTERN OnigEncodingType OnigEncodingKOI8;
-ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R;
-ONIG_EXTERN OnigEncodingType OnigEncodingCP1251;
-ONIG_EXTERN OnigEncodingType OnigEncodingBIG5;
-ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
-
-#define ONIG_ENCODING_ASCII (&OnigEncodingASCII)
-#define ONIG_ENCODING_ISO_8859_1 (&OnigEncodingISO_8859_1)
-#define ONIG_ENCODING_ISO_8859_2 (&OnigEncodingISO_8859_2)
-#define ONIG_ENCODING_ISO_8859_3 (&OnigEncodingISO_8859_3)
-#define ONIG_ENCODING_ISO_8859_4 (&OnigEncodingISO_8859_4)
-#define ONIG_ENCODING_ISO_8859_5 (&OnigEncodingISO_8859_5)
-#define ONIG_ENCODING_ISO_8859_6 (&OnigEncodingISO_8859_6)
-#define ONIG_ENCODING_ISO_8859_7 (&OnigEncodingISO_8859_7)
-#define ONIG_ENCODING_ISO_8859_8 (&OnigEncodingISO_8859_8)
-#define ONIG_ENCODING_ISO_8859_9 (&OnigEncodingISO_8859_9)
-#define ONIG_ENCODING_ISO_8859_10 (&OnigEncodingISO_8859_10)
-#define ONIG_ENCODING_ISO_8859_11 (&OnigEncodingISO_8859_11)
-#define ONIG_ENCODING_ISO_8859_13 (&OnigEncodingISO_8859_13)
-#define ONIG_ENCODING_ISO_8859_14 (&OnigEncodingISO_8859_14)
-#define ONIG_ENCODING_ISO_8859_15 (&OnigEncodingISO_8859_15)
-#define ONIG_ENCODING_ISO_8859_16 (&OnigEncodingISO_8859_16)
-#define ONIG_ENCODING_UTF8 (&OnigEncodingUTF8)
-#define ONIG_ENCODING_UTF16_BE (&OnigEncodingUTF16_BE)
-#define ONIG_ENCODING_UTF16_LE (&OnigEncodingUTF16_LE)
-#define ONIG_ENCODING_UTF32_BE (&OnigEncodingUTF32_BE)
-#define ONIG_ENCODING_UTF32_LE (&OnigEncodingUTF32_LE)
-#define ONIG_ENCODING_EUC_JP (&OnigEncodingEUC_JP)
-#define ONIG_ENCODING_EUC_TW (&OnigEncodingEUC_TW)
-#define ONIG_ENCODING_EUC_KR (&OnigEncodingEUC_KR)
-#define ONIG_ENCODING_EUC_CN (&OnigEncodingEUC_CN)
-#define ONIG_ENCODING_SJIS (&OnigEncodingSJIS)
-#define ONIG_ENCODING_KOI8 (&OnigEncodingKOI8)
-#define ONIG_ENCODING_KOI8_R (&OnigEncodingKOI8_R)
-#define ONIG_ENCODING_CP1251 (&OnigEncodingCP1251)
-#define ONIG_ENCODING_BIG5 (&OnigEncodingBIG5)
-#define ONIG_ENCODING_GB18030 (&OnigEncodingGB18030)
-
-#define ONIG_ENCODING_UNDEF ((OnigEncoding )0)
-
-
-/* work size */
-#define ONIGENC_CODE_TO_MBC_MAXLEN 7
-#define ONIGENC_MBC_CASE_FOLD_MAXLEN 18
-/* 18: 6(max-byte) * 3(case-fold chars) */
-
-/* character types */
-#define ONIGENC_CTYPE_NEWLINE 0
-#define ONIGENC_CTYPE_ALPHA 1
-#define ONIGENC_CTYPE_BLANK 2
-#define ONIGENC_CTYPE_CNTRL 3
-#define ONIGENC_CTYPE_DIGIT 4
-#define ONIGENC_CTYPE_GRAPH 5
-#define ONIGENC_CTYPE_LOWER 6
-#define ONIGENC_CTYPE_PRINT 7
-#define ONIGENC_CTYPE_PUNCT 8
-#define ONIGENC_CTYPE_SPACE 9
-#define ONIGENC_CTYPE_UPPER 10
-#define ONIGENC_CTYPE_XDIGIT 11
-#define ONIGENC_CTYPE_WORD 12
-#define ONIGENC_CTYPE_ALNUM 13 /* alpha || digit */
-#define ONIGENC_CTYPE_ASCII 14
-#define ONIGENC_MAX_STD_CTYPE ONIGENC_CTYPE_ASCII
-
-
-#define enc_len(enc,p,e) ONIGENC_MBC_ENC_LEN(enc, p, e)
-
-#define ONIGENC_IS_UNDEF(enc) ((enc) == ONIG_ENCODING_UNDEF)
-#define ONIGENC_IS_SINGLEBYTE(enc) (ONIGENC_MBC_MAXLEN(enc) == 1)
-#define ONIGENC_IS_MBC_HEAD(enc,p,e) (ONIGENC_MBC_ENC_LEN(enc,p,e) != 1)
-#define ONIGENC_IS_MBC_ASCII(p) (*(p) < 128)
-#define ONIGENC_IS_CODE_ASCII(code) ((code) < 128)
-#define ONIGENC_IS_MBC_WORD(enc,s,end) \
- ONIGENC_IS_CODE_WORD(enc,ONIGENC_MBC_TO_CODE(enc,s,end))
-
-
-#define ONIGENC_NAME(enc) ((enc)->name)
-
-#define ONIGENC_MBC_CASE_FOLD(enc,flag,pp,end,buf) \
- (enc)->mbc_case_fold(flag,(const OnigUChar** )pp,end,buf,enc)
-#define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
- (enc)->is_allowed_reverse_match(s,end,enc)
-#define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \
- (enc)->left_adjust_char_head(start, s, enc)
-#define ONIGENC_APPLY_ALL_CASE_FOLD(enc,case_fold_flag,f,arg) \
- (enc)->apply_all_case_fold(case_fold_flag,f,arg,enc)
-#define ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc,case_fold_flag,p,end,acs) \
- (enc)->get_case_fold_codes_by_str(case_fold_flag,p,end,acs,enc)
-#define ONIGENC_STEP_BACK(enc,start,s,n) \
- onigenc_step_back((enc),(start),(s),(n))
-
-
-#define ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) (n)
-#define ONIGENC_CONSTRUCT_MBCLEN_INVALID() (-1)
-#define ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n) (-1-(n))
-
-static inline int onigenc_mbclen_charfound(int r) { return 0 < r ? r : 0; }
-static inline int onigenc_mbclen_needmore(int r) { return r < -1 ? -1 - r : 0; }
-#define ONIGENC_MBCLEN_CHARFOUND(r) onigenc_mbclen_charfound(r)
-#define ONIGENC_MBCLEN_INVALID(r) ((r) == -1)
-#define ONIGENC_MBCLEN_NEEDMORE(r) onigenc_mbclen_needmore(r)
-
-#define ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e) (enc)->precise_mbc_enc_len(p,e,enc)
-
-static inline int onigenc_mbclen_recover(const OnigUChar* p,const OnigUChar* e, struct OnigEncodingTypeST* enc)
-{
- int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc,p,e);
- int r;
- if (ONIGENC_MBCLEN_INVALID(ret))
- return 1;
- else if ((r = ONIGENC_MBCLEN_NEEDMORE(ret)))
- return e-p+r;
- else
- return ONIGENC_MBCLEN_CHARFOUND(ret);
-}
-
-#define ONIGENC_MBC_ENC_LEN(enc,p,e) onigenc_mbclen_recover(p,e,enc)
-#define ONIGENC_MBC_MAXLEN(enc) ((enc)->max_enc_len)
-#define ONIGENC_MBC_MAXLEN_DIST(enc) ONIGENC_MBC_MAXLEN(enc)
-#define ONIGENC_MBC_MINLEN(enc) ((enc)->min_enc_len)
-#define ONIGENC_IS_MBC_NEWLINE(enc,p,end) (enc)->is_mbc_newline((p),(end),enc)
-#define ONIGENC_MBC_TO_CODE(enc,p,end) (enc)->mbc_to_code((p),(end),enc)
-#define ONIGENC_CODE_TO_MBCLEN(enc,code) (enc)->code_to_mbclen(code,enc)
-#define ONIGENC_CODE_TO_MBC(enc,code,buf) (enc)->code_to_mbc(code,buf,enc)
-#define ONIGENC_PROPERTY_NAME_TO_CTYPE(enc,p,end) \
- (enc)->property_name_to_ctype(enc,p,end)
-
-#define ONIGENC_IS_CODE_CTYPE(enc,code,ctype) (enc)->is_code_ctype(code,ctype,enc)
-
-#define ONIGENC_IS_CODE_NEWLINE(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_NEWLINE)
-#define ONIGENC_IS_CODE_GRAPH(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_GRAPH)
-#define ONIGENC_IS_CODE_PRINT(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PRINT)
-#define ONIGENC_IS_CODE_ALNUM(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALNUM)
-#define ONIGENC_IS_CODE_ALPHA(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALPHA)
-#define ONIGENC_IS_CODE_LOWER(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_LOWER)
-#define ONIGENC_IS_CODE_UPPER(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_UPPER)
-#define ONIGENC_IS_CODE_CNTRL(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_CNTRL)
-#define ONIGENC_IS_CODE_PUNCT(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PUNCT)
-#define ONIGENC_IS_CODE_SPACE(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_SPACE)
-#define ONIGENC_IS_CODE_BLANK(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_BLANK)
-#define ONIGENC_IS_CODE_DIGIT(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_DIGIT)
-#define ONIGENC_IS_CODE_XDIGIT(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_XDIGIT)
-#define ONIGENC_IS_CODE_WORD(enc,code) \
- ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_WORD)
-
-#define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbout,ranges) \
- (enc)->get_ctype_code_range(ctype,sbout,ranges,enc)
-
-ONIG_EXTERN
-OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n));
-
-
-/* encoding API */
-ONIG_EXTERN
-int onigenc_init P_((void));
-ONIG_EXTERN
-int onigenc_set_default_encoding P_((OnigEncoding enc));
-ONIG_EXTERN
-OnigEncoding onigenc_get_default_encoding P_((void));
-ONIG_EXTERN
-void onigenc_set_default_caseconv_table P_((const OnigUChar* table));
-ONIG_EXTERN
-OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar** prev));
-ONIG_EXTERN
-OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
-ONIG_EXTERN
-OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
-ONIG_EXTERN
-OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
-ONIG_EXTERN
-int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
-ONIG_EXTERN
-int onigenc_strlen_null P_((OnigEncoding enc, const OnigUChar* p));
-ONIG_EXTERN
-int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));
-
-
-
-/* PART: regular expression */
-
-/* config parameters */
-#define ONIG_NREGION 10
-#define ONIG_MAX_BACKREF_NUM 1000
-#define ONIG_MAX_REPEAT_NUM 100000
-#define ONIG_MAX_MULTI_BYTE_RANGES_NUM 10000
-/* constants */
-#define ONIG_MAX_ERROR_MESSAGE_LEN 90
-
-typedef unsigned int OnigOptionType;
-
-#define ONIG_OPTION_DEFAULT ONIG_OPTION_NONE
-
-/* options */
-#define ONIG_OPTION_NONE 0U
-#define ONIG_OPTION_IGNORECASE 1U
-#define ONIG_OPTION_EXTEND (ONIG_OPTION_IGNORECASE << 1)
-#define ONIG_OPTION_MULTILINE (ONIG_OPTION_EXTEND << 1)
-#define ONIG_OPTION_SINGLELINE (ONIG_OPTION_MULTILINE << 1)
-#define ONIG_OPTION_FIND_LONGEST (ONIG_OPTION_SINGLELINE << 1)
-#define ONIG_OPTION_FIND_NOT_EMPTY (ONIG_OPTION_FIND_LONGEST << 1)
-#define ONIG_OPTION_NEGATE_SINGLELINE (ONIG_OPTION_FIND_NOT_EMPTY << 1)
-#define ONIG_OPTION_DONT_CAPTURE_GROUP (ONIG_OPTION_NEGATE_SINGLELINE << 1)
-#define ONIG_OPTION_CAPTURE_GROUP (ONIG_OPTION_DONT_CAPTURE_GROUP << 1)
-/* options (search time) */
-#define ONIG_OPTION_NOTBOL (ONIG_OPTION_CAPTURE_GROUP << 1)
-#define ONIG_OPTION_NOTEOL (ONIG_OPTION_NOTBOL << 1)
-#define ONIG_OPTION_POSIX_REGION (ONIG_OPTION_NOTEOL << 1)
-#define ONIG_OPTION_MAXBIT ONIG_OPTION_POSIX_REGION /* limit */
-
-#define ONIG_OPTION_ON(options,regopt) ((options) |= (regopt))
-#define ONIG_OPTION_OFF(options,regopt) ((options) &= ~(regopt))
-#define ONIG_IS_OPTION_ON(options,option) ((options) & (option))
-
-/* syntax */
-typedef struct {
- unsigned int op;
- unsigned int op2;
- unsigned int behavior;
- OnigOptionType options; /* default option */
- OnigMetaCharTableType meta_char_table;
-} OnigSyntaxType;
-
-ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl_NG;
-ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
-
-/* predefined syntaxes (see regsyntax.c) */
-#define ONIG_SYNTAX_ASIS (&OnigSyntaxASIS)
-#define ONIG_SYNTAX_POSIX_BASIC (&OnigSyntaxPosixBasic)
-#define ONIG_SYNTAX_POSIX_EXTENDED (&OnigSyntaxPosixExtended)
-#define ONIG_SYNTAX_EMACS (&OnigSyntaxEmacs)
-#define ONIG_SYNTAX_GREP (&OnigSyntaxGrep)
-#define ONIG_SYNTAX_GNU_REGEX (&OnigSyntaxGnuRegex)
-#define ONIG_SYNTAX_JAVA (&OnigSyntaxJava)
-#define ONIG_SYNTAX_PERL (&OnigSyntaxPerl)
-#define ONIG_SYNTAX_PERL_NG (&OnigSyntaxPerl_NG)
-#define ONIG_SYNTAX_RUBY (&OnigSyntaxRuby)
-
-/* default syntax */
-ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax;
-#define ONIG_SYNTAX_DEFAULT OnigDefaultSyntax
-
-/* syntax (operators) */
-#define ONIG_SYN_OP_VARIABLE_META_CHARACTERS (1U<<0)
-#define ONIG_SYN_OP_DOT_ANYCHAR (1U<<1) /* . */
-#define ONIG_SYN_OP_ASTERISK_ZERO_INF (1U<<2) /* * */
-#define ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF (1U<<3)
-#define ONIG_SYN_OP_PLUS_ONE_INF (1U<<4) /* + */
-#define ONIG_SYN_OP_ESC_PLUS_ONE_INF (1U<<5)
-#define ONIG_SYN_OP_QMARK_ZERO_ONE (1U<<6) /* ? */
-#define ONIG_SYN_OP_ESC_QMARK_ZERO_ONE (1U<<7)
-#define ONIG_SYN_OP_BRACE_INTERVAL (1U<<8) /* {lower,upper} */
-#define ONIG_SYN_OP_ESC_BRACE_INTERVAL (1U<<9) /* \{lower,upper\} */
-#define ONIG_SYN_OP_VBAR_ALT (1U<<10) /* | */
-#define ONIG_SYN_OP_ESC_VBAR_ALT (1U<<11) /* \| */
-#define ONIG_SYN_OP_LPAREN_SUBEXP (1U<<12) /* (...) */
-#define ONIG_SYN_OP_ESC_LPAREN_SUBEXP (1U<<13) /* \(...\) */
-#define ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR (1U<<14) /* \A, \Z, \z */
-#define ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR (1U<<15) /* \G */
-#define ONIG_SYN_OP_DECIMAL_BACKREF (1U<<16) /* \num */
-#define ONIG_SYN_OP_BRACKET_CC (1U<<17) /* [...] */
-#define ONIG_SYN_OP_ESC_W_WORD (1U<<18) /* \w, \W */
-#define ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END (1U<<19) /* \<. \> */
-#define ONIG_SYN_OP_ESC_B_WORD_BOUND (1U<<20) /* \b, \B */
-#define ONIG_SYN_OP_ESC_S_WHITE_SPACE (1U<<21) /* \s, \S */
-#define ONIG_SYN_OP_ESC_D_DIGIT (1U<<22) /* \d, \D */
-#define ONIG_SYN_OP_LINE_ANCHOR (1U<<23) /* ^, $ */
-#define ONIG_SYN_OP_POSIX_BRACKET (1U<<24) /* [:xxxx:] */
-#define ONIG_SYN_OP_QMARK_NON_GREEDY (1U<<25) /* ??,*?,+?,{n,m}? */
-#define ONIG_SYN_OP_ESC_CONTROL_CHARS (1U<<26) /* \n,\r,\t,\a ... */
-#define ONIG_SYN_OP_ESC_C_CONTROL (1U<<27) /* \cx */
-#define ONIG_SYN_OP_ESC_OCTAL3 (1U<<28) /* \OOO */
-#define ONIG_SYN_OP_ESC_X_HEX2 (1U<<29) /* \xHH */
-#define ONIG_SYN_OP_ESC_X_BRACE_HEX8 (1U<<30) /* \x{7HHHHHHH} */
-
-#define ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE (1U<<0) /* \Q...\E */
-#define ONIG_SYN_OP2_QMARK_GROUP_EFFECT (1U<<1) /* (?...) */
-#define ONIG_SYN_OP2_OPTION_PERL (1U<<2) /* (?imsx),(?-imsx) */
-#define ONIG_SYN_OP2_OPTION_RUBY (1U<<3) /* (?imx), (?-imx) */
-#define ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT (1U<<4) /* ?+,*+,++ */
-#define ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL (1U<<5) /* {n,m}+ */
-#define ONIG_SYN_OP2_CCLASS_SET_OP (1U<<6) /* [...&&..[..]..] */
-#define ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP (1U<<7) /* (?<name>...) */
-#define ONIG_SYN_OP2_ESC_K_NAMED_BACKREF (1U<<8) /* \k<name> */
-#define ONIG_SYN_OP2_ESC_G_SUBEXP_CALL (1U<<9) /* \g<name>, \g<n> */
-#define ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY (1U<<10) /* (?@..),(?@<x>..) */
-#define ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL (1U<<11) /* \C-x */
-#define ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META (1U<<12) /* \M-x */
-#define ONIG_SYN_OP2_ESC_V_VTAB (1U<<13) /* \v as VTAB */
-#define ONIG_SYN_OP2_ESC_U_HEX4 (1U<<14) /* \uHHHH */
-#define ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR (1U<<15) /* \`, \' */
-#define ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY (1U<<16) /* \p{...}, \P{...} */
-#define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1U<<17) /* \p{^..}, \P{^..} */
-/* #define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS (1U<<18) */
-#define ONIG_SYN_OP2_ESC_H_XDIGIT (1U<<19) /* \h, \H */
-#define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE (1U<<20) /* \ */
-
-/* syntax (behavior) */
-#define ONIG_SYN_CONTEXT_INDEP_ANCHORS (1U<<31) /* not implemented */
-#define ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS (1U<<0) /* ?, *, +, {n,m} */
-#define ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS (1U<<1) /* error or ignore */
-#define ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP (1U<<2) /* ...)... */
-#define ONIG_SYN_ALLOW_INVALID_INTERVAL (1U<<3) /* {??? */
-#define ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV (1U<<4) /* {,n} => {0,n} */
-#define ONIG_SYN_STRICT_CHECK_BACKREF (1U<<5) /* /(\1)/,/\1()/ ..*/
-#define ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND (1U<<6) /* (?<=a|bc) */
-#define ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP (1U<<7) /* see doc/RE */
-#define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME (1U<<8) /* (?<x>)(?<x>) */
-#define ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY (1U<<9) /* a{n}?=(?:a{n})? */
-
-/* syntax (behavior) in char class [...] */
-#define ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC (1U<<20) /* [^...] */
-#define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC (1U<<21) /* [..\w..] etc.. */
-#define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC (1U<<22)
-#define ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC (1U<<23) /* [0-9-a]=[0-9\-a] */
-/* syntax (behavior) warning */
-#define ONIG_SYN_WARN_CC_OP_NOT_ESCAPED (1U<<24) /* [,-,] */
-#define ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT (1U<<25) /* (?:a*)+ */
-
-/* meta character specifiers (onig_set_meta_char()) */
-#define ONIG_META_CHAR_ESCAPE 0
-#define ONIG_META_CHAR_ANYCHAR 1
-#define ONIG_META_CHAR_ANYTIME 2
-#define ONIG_META_CHAR_ZERO_OR_ONE_TIME 3
-#define ONIG_META_CHAR_ONE_OR_MORE_TIME 4
-#define ONIG_META_CHAR_ANYCHAR_ANYTIME 5
-
-#define ONIG_INEFFECTIVE_META_CHAR 0
-
-/* error codes */
-#define ONIG_IS_PATTERN_ERROR(ecode) ((ecode) <= -100 && (ecode) > -1000)
-/* normal return */
-#define ONIG_NORMAL 0
-#define ONIG_MISMATCH -1
-#define ONIG_NO_SUPPORT_CONFIG -2
-
-/* internal error */
-#define ONIGERR_MEMORY -5
-#define ONIGERR_TYPE_BUG -6
-#define ONIGERR_PARSER_BUG -11
-#define ONIGERR_STACK_BUG -12
-#define ONIGERR_UNDEFINED_BYTECODE -13
-#define ONIGERR_UNEXPECTED_BYTECODE -14
-#define ONIGERR_MATCH_STACK_LIMIT_OVER -15
-#define ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED -21
-#define ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR -22
-/* general error */
-#define ONIGERR_INVALID_ARGUMENT -30
-/* syntax error */
-#define ONIGERR_END_PATTERN_AT_LEFT_BRACE -100
-#define ONIGERR_END_PATTERN_AT_LEFT_BRACKET -101
-#define ONIGERR_EMPTY_CHAR_CLASS -102
-#define ONIGERR_PREMATURE_END_OF_CHAR_CLASS -103
-#define ONIGERR_END_PATTERN_AT_ESCAPE -104
-#define ONIGERR_END_PATTERN_AT_META -105
-#define ONIGERR_END_PATTERN_AT_CONTROL -106
-#define ONIGERR_META_CODE_SYNTAX -108
-#define ONIGERR_CONTROL_CODE_SYNTAX -109
-#define ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE -110
-#define ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE -111
-#define ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS -112
-#define ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED -113
-#define ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID -114
-#define ONIGERR_NESTED_REPEAT_OPERATOR -115
-#define ONIGERR_UNMATCHED_CLOSE_PARENTHESIS -116
-#define ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS -117
-#define ONIGERR_END_PATTERN_IN_GROUP -118
-#define ONIGERR_UNDEFINED_GROUP_OPTION -119
-#define ONIGERR_INVALID_POSIX_BRACKET_TYPE -121
-#define ONIGERR_INVALID_LOOK_BEHIND_PATTERN -122
-#define ONIGERR_INVALID_REPEAT_RANGE_PATTERN -123
-/* values error (syntax error) */
-#define ONIGERR_TOO_BIG_NUMBER -200
-#define ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE -201
-#define ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE -202
-#define ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS -203
-#define ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE -204
-#define ONIGERR_TOO_MANY_MULTI_BYTE_RANGES -205
-#define ONIGERR_TOO_SHORT_MULTI_BYTE_STRING -206
-#define ONIGERR_TOO_BIG_BACKREF_NUMBER -207
-#define ONIGERR_INVALID_BACKREF -208
-#define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED -209
-#define ONIGERR_TOO_LONG_WIDE_CHAR_VALUE -212
-#define ONIGERR_EMPTY_GROUP_NAME -214
-#define ONIGERR_INVALID_GROUP_NAME -215
-#define ONIGERR_INVALID_CHAR_IN_GROUP_NAME -216
-#define ONIGERR_UNDEFINED_NAME_REFERENCE -217
-#define ONIGERR_UNDEFINED_GROUP_REFERENCE -218
-#define ONIGERR_MULTIPLEX_DEFINED_NAME -219
-#define ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL -220
-#define ONIGERR_NEVER_ENDING_RECURSION -221
-#define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222
-#define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223
-#define ONIGERR_INVALID_WIDE_CHAR_VALUE -400
-#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401
-#define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION -402
-#define ONIGERR_INVALID_COMBINATION_OF_OPTIONS -403
-
-/* errors related to thread */
-#define ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT -1001
-
-
-/* must be smaller than BIT_STATUS_BITS_NUM (unsigned int * 8) */
-#define ONIG_MAX_CAPTURE_HISTORY_GROUP 31
-#define ONIG_IS_CAPTURE_HISTORY_GROUP(r, i) \
- ((i) <= ONIG_MAX_CAPTURE_HISTORY_GROUP && (r)->list && (r)->list[i])
-
-typedef struct OnigCaptureTreeNodeStruct {
- int group; /* group number */
- int beg;
- int end;
- int allocated;
- int num_childs;
- struct OnigCaptureTreeNodeStruct** childs;
-} OnigCaptureTreeNode;
-
-/* match result region type */
-struct re_registers {
- int allocated;
- int num_regs;
- int* beg;
- int* end;
- /* extended */
- OnigCaptureTreeNode* history_root; /* capture history tree root */
-};
-
-/* capture tree traverse */
-#define ONIG_TRAVERSE_CALLBACK_AT_FIRST 1
-#define ONIG_TRAVERSE_CALLBACK_AT_LAST 2
-#define ONIG_TRAVERSE_CALLBACK_AT_BOTH \
- ( ONIG_TRAVERSE_CALLBACK_AT_FIRST | ONIG_TRAVERSE_CALLBACK_AT_LAST )
-
-
-#define ONIG_REGION_NOTPOS -1
-
-typedef struct re_registers OnigRegion;
-
-typedef struct {
- OnigEncoding enc;
- OnigUChar* par;
- OnigUChar* par_end;
-} OnigErrorInfo;
-
-typedef struct {
- int lower;
- int upper;
-} OnigRepeatRange;
-
-typedef void (*OnigWarnFunc) P_((const char* s));
-extern void onig_null_warn P_((const char* s));
-#define ONIG_NULL_WARN onig_null_warn
-
-#define ONIG_CHAR_TABLE_SIZE 256
-
-/* regex_t state */
-#define ONIG_STATE_NORMAL 0
-#define ONIG_STATE_SEARCHING 1
-#define ONIG_STATE_COMPILING -1
-#define ONIG_STATE_MODIFY -2
-
-#define ONIG_STATE(reg) \
- ((reg)->state > 0 ? ONIG_STATE_SEARCHING : (reg)->state)
-
-typedef struct re_pattern_buffer {
- /* common members of BBuf(bytes-buffer) */
- unsigned char* p; /* compiled pattern */
- unsigned int used; /* used space for p */
- unsigned int alloc; /* allocated space for p */
-
- int state; /* normal, searching, compiling */
- int num_mem; /* used memory(...) num counted from 1 */
- int num_repeat; /* OP_REPEAT/OP_REPEAT_NG id-counter */
- int num_null_check; /* OP_NULL_CHECK_START/END id counter */
- int num_comb_exp_check; /* combination explosion check */
- int num_call; /* number of subexp call */
- unsigned int capture_history; /* (?@...) flag (1-31) */
- unsigned int bt_mem_start; /* need backtrack flag */
- unsigned int bt_mem_end; /* need backtrack flag */
- int stack_pop_level;
- int repeat_range_alloc;
- OnigRepeatRange* repeat_range;
-
- OnigEncoding enc;
- OnigOptionType options;
- OnigSyntaxType* syntax;
- OnigCaseFoldType case_fold_flag;
- void* name_table;
-
- /* optimization info (string search, char-map and anchors) */
- int optimize; /* optimize flag */
- int threshold_len; /* search str-length for apply optimize */
- int anchor; /* BEGIN_BUF, BEGIN_POS, (SEMI_)END_BUF */
- OnigDistance anchor_dmin; /* (SEMI_)END_BUF anchor distance */
- OnigDistance anchor_dmax; /* (SEMI_)END_BUF anchor distance */
- int sub_anchor; /* start-anchor for exact or map */
- unsigned char *exact;
- unsigned char *exact_end;
- unsigned char map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */
- int *int_map; /* BM skip for exact_len > 255 */
- int *int_map_backward; /* BM skip for backward search */
- OnigDistance dmin; /* min-distance of exact or map */
- OnigDistance dmax; /* max-distance of exact or map */
-
- /* regex_t link chain */
- struct re_pattern_buffer* chain; /* escape compile-conflict */
-} OnigRegexType;
-
-typedef OnigRegexType* OnigRegex;
-
-#ifndef ONIG_ESCAPE_REGEX_T_COLLISION
- typedef OnigRegexType regex_t;
-#endif
-
-
-typedef struct {
- int num_of_elements;
- OnigEncoding pattern_enc;
- OnigEncoding target_enc;
- OnigSyntaxType* syntax;
- OnigOptionType option;
- OnigCaseFoldType case_fold_flag;
-} OnigCompileInfo;
-
-/* Oniguruma Native API */
-ONIG_EXTERN
-int onig_init P_((void));
-ONIG_EXTERN
-int onig_error_code_to_str PV_((OnigUChar* s, int err_code, ...));
-ONIG_EXTERN
-void onig_set_warn_func P_((OnigWarnFunc f));
-ONIG_EXTERN
-void onig_set_verb_warn_func P_((OnigWarnFunc f));
-ONIG_EXTERN
-int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
-ONIG_EXTERN
-int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
-ONIG_EXTERN
-void onig_free P_((OnigRegex));
-ONIG_EXTERN
-int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
-ONIG_EXTERN
-int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
-ONIG_EXTERN
-int onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));
-ONIG_EXTERN
-int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option));
-ONIG_EXTERN
-OnigRegion* onig_region_new P_((void));
-ONIG_EXTERN
-void onig_region_init P_((OnigRegion* region));
-ONIG_EXTERN
-void onig_region_free P_((OnigRegion* region, int free_self));
-ONIG_EXTERN
-void onig_region_copy P_((OnigRegion* to, OnigRegion* from));
-ONIG_EXTERN
-void onig_region_clear P_((OnigRegion* region));
-ONIG_EXTERN
-int onig_region_resize P_((OnigRegion* region, int n));
-ONIG_EXTERN
-int onig_region_set P_((OnigRegion* region, int at, int beg, int end));
-ONIG_EXTERN
-int onig_name_to_group_numbers P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, int** nums));
-ONIG_EXTERN
-int onig_name_to_backref_number P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, OnigRegion *region));
-ONIG_EXTERN
-int onig_foreach_name P_((OnigRegex reg, int (*func)(const OnigUChar*, const OnigUChar*,int,int*,OnigRegex,void*), void* arg));
-ONIG_EXTERN
-int onig_number_of_names P_((OnigRegex reg));
-ONIG_EXTERN
-int onig_number_of_captures P_((OnigRegex reg));
-ONIG_EXTERN
-int onig_number_of_capture_histories P_((OnigRegex reg));
-ONIG_EXTERN
-OnigCaptureTreeNode* onig_get_capture_tree P_((OnigRegion* region));
-ONIG_EXTERN
-int onig_capture_tree_traverse P_((OnigRegion* region, int at, int(*callback_func)(int,int,int,int,int,void*), void* arg));
-ONIG_EXTERN
-int onig_noname_group_capture_is_active P_((OnigRegex reg));
-ONIG_EXTERN
-OnigEncoding onig_get_encoding P_((OnigRegex reg));
-ONIG_EXTERN
-OnigOptionType onig_get_options P_((OnigRegex reg));
-ONIG_EXTERN
-OnigCaseFoldType onig_get_case_fold_flag P_((OnigRegex reg));
-ONIG_EXTERN
-OnigSyntaxType* onig_get_syntax P_((OnigRegex reg));
-ONIG_EXTERN
-int onig_set_default_syntax P_((OnigSyntaxType* syntax));
-ONIG_EXTERN
-void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));
-ONIG_EXTERN
-unsigned int onig_get_syntax_op P_((OnigSyntaxType* syntax));
-ONIG_EXTERN
-unsigned int onig_get_syntax_op2 P_((OnigSyntaxType* syntax));
-ONIG_EXTERN
-unsigned int onig_get_syntax_behavior P_((OnigSyntaxType* syntax));
-ONIG_EXTERN
-OnigOptionType onig_get_syntax_options P_((OnigSyntaxType* syntax));
-ONIG_EXTERN
-void onig_set_syntax_op P_((OnigSyntaxType* syntax, unsigned int op));
-ONIG_EXTERN
-void onig_set_syntax_op2 P_((OnigSyntaxType* syntax, unsigned int op2));
-ONIG_EXTERN
-void onig_set_syntax_behavior P_((OnigSyntaxType* syntax, unsigned int behavior));
-ONIG_EXTERN
-void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options));
-ONIG_EXTERN
-int onig_set_meta_char P_((OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code));
-ONIG_EXTERN
-void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from));
-ONIG_EXTERN
-OnigCaseFoldType onig_get_default_case_fold_flag P_((void));
-ONIG_EXTERN
-int onig_set_default_case_fold_flag P_((OnigCaseFoldType case_fold_flag));
-ONIG_EXTERN
-unsigned int onig_get_match_stack_limit_size P_((void));
-ONIG_EXTERN
-int onig_set_match_stack_limit_size P_((unsigned int size));
-ONIG_EXTERN
-int onig_end P_((void));
-ONIG_EXTERN
-const char* onig_version P_((void));
-ONIG_EXTERN
-const char* onig_copyright P_((void));
-
-#ifdef __cplusplus
-#if 0
-{ /* satisfy cc-mode */
-#endif
-}
-#endif
-
-#endif /* ONIGURUMA_H */
diff --git a/include/ruby/re.h b/include/ruby/re.h
deleted file mode 100644
index 3b8c6c5d74..0000000000
--- a/include/ruby/re.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**********************************************************************
-
- re.h -
-
- $Author$
- $Date$
- created at: Thu Sep 30 14:18:32 JST 1993
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_RE_H
-#define RUBY_RE_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-
-#include "ruby/regex.h"
-
-typedef struct re_pattern_buffer Regexp;
-
-struct RMatch {
- struct RBasic basic;
- VALUE str;
- struct re_registers *regs;
- VALUE regexp; /* RRegexp */
-};
-
-#define RMATCH(obj) (R_CAST(RMatch)(obj))
-
-VALUE rb_reg_regcomp(VALUE);
-int rb_reg_search(VALUE, VALUE, int, int);
-VALUE rb_reg_regsub(VALUE, VALUE, struct re_registers *, VALUE);
-int rb_reg_adjust_startpos(VALUE, VALUE, int, int);
-void rb_match_busy(VALUE);
-VALUE rb_reg_quote(VALUE);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_RE_H */
diff --git a/include/ruby/regex.h b/include/ruby/regex.h
deleted file mode 100644
index d0a670f283..0000000000
--- a/include/ruby/regex.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
-
- regex.h -
-
- $Author$
- $Date$
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef ONIGURUMA_REGEX_H
-#define ONIGURUMA_REGEX_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#ifdef RUBY
-#include "ruby/oniguruma.h"
-#else
-#include "oniguruma.h"
-#endif
-
-#ifndef ONIG_RUBY_M17N
-
-ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding;
-
-#define mbclen(p,e,enc) rb_enc_mbclen((p),(e),(enc))
-
-#endif /* ifndef ONIG_RUBY_M17N */
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* ONIGURUMA_REGEX_H */
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
deleted file mode 100644
index 90402afeec..0000000000
--- a/include/ruby/ruby.h
+++ /dev/null
@@ -1,985 +0,0 @@
-/**********************************************************************
-
- ruby.h -
-
- $Author$
- created at: Thu Jun 10 14:26:32 JST 1993
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
- Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
- Copyright (C) 2000 Information-technology Promotion Agency, Japan
-
-**********************************************************************/
-
-#ifndef RUBY_H
-#define RUBY_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#include "ruby/config.h"
-#ifdef RUBY_EXTCONF_H
-#include RUBY_EXTCONF_H
-#endif
-
-#define NORETURN_STYLE_NEW 1
-#ifndef NORETURN
-# define NORETURN(x) x
-#endif
-#ifndef DEPRECATED
-# define DEPRECATED(x) x
-#endif
-#ifndef NOINLINE
-# define NOINLINE(x) x
-#endif
-
-#ifdef __GNUC__
-#define PRINTF_ARGS(decl, string_index, first_to_check) \
- decl __attribute__((format(printf, string_index, first_to_check)))
-#else
-#define PRINTF_ARGS(decl, string_index, first_to_check) decl
-#endif
-
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-
-#ifdef HAVE_INTRINSICS_H
-# include <intrinsics.h>
-#endif
-
-#include <stddef.h>
-#include <stdio.h>
-
-#include "defines.h"
-
-/* need to include <ctype.h> to use these macros */
-#ifndef ISPRINT
-#define ISASCII(c) isascii((int)(unsigned char)(c))
-#undef ISPRINT
-#define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
-#define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
-#define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c)))
-#define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c)))
-#define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c)))
-#define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c)))
-#define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c)))
-#define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
-#endif
-
-#if defined(HAVE_ALLOCA_H)
-#include <alloca.h>
-#else
-# ifdef _AIX
-#pragma alloca
-# endif
-#endif
-
-#if defined(__VMS)
-# pragma builtins
-# define alloca __alloca
-#endif
-
-#if SIZEOF_LONG == SIZEOF_VOIDP
-typedef unsigned long VALUE;
-typedef unsigned long ID;
-# define SIGNED_VALUE long
-# define SIZEOF_VALUE SIZEOF_LONG
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-typedef unsigned LONG_LONG VALUE;
-typedef unsigned LONG_LONG ID;
-# define SIGNED_VALUE LONG_LONG
-# define LONG_LONG_VALUE 1
-# define SIZEOF_VALUE SIZEOF_LONG_LONG
-#else
-# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
-#endif
-
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# ifndef LONG_MAX
-# ifdef HAVE_LIMITS_H
-# include <limits.h>
-# else
- /* assuming 32bit(2's compliment) long */
-# define LONG_MAX 2147483647
-# endif
-# endif
-# ifndef LONG_MIN
-# define LONG_MIN (-LONG_MAX-1)
-# endif
-# ifndef CHAR_BIT
-# define CHAR_BIT 8
-# endif
-#endif
-
-#ifdef HAVE_LONG_LONG
-# ifndef LLONG_MAX
-# ifdef LONG_LONG_MAX
-# define LLONG_MAX LONG_LONG_MAX
-# else
-# ifdef _I64_MAX
-# define LLONG_MAX _I64_MAX
-# else
- /* assuming 64bit(2's complement) long long */
-# define LLONG_MAX 9223372036854775807LL
-# endif
-# endif
-# endif
-# ifndef LLONG_MIN
-# ifdef LONG_LONG_MIN
-# define LLONG_MIN LONG_LONG_MIN
-# else
-# ifdef _I64_MIN
-# define LLONG_MIN _I64_MIN
-# else
-# define LLONG_MIN (-LLONG_MAX-1)
-# endif
-# endif
-# endif
-#endif
-
-#define FIXNUM_MAX (LONG_MAX>>1)
-#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
-
-#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
-#define LONG2FIX(i) INT2FIX(i)
-#define rb_fix_new(v) INT2FIX(v)
-VALUE rb_int2inum(SIGNED_VALUE);
-#define INT2NUM(v) rb_int2inum(v)
-#define LONG2NUM(v) INT2NUM(v)
-#define rb_int_new(v) rb_int2inum(v)
-VALUE rb_uint2inum(VALUE);
-#define UINT2NUM(v) rb_uint2inum(v)
-#define ULONG2NUM(v) UINT2NUM(v)
-#define rb_uint_new(v) rb_uint2inum(v)
-
-#ifdef HAVE_LONG_LONG
-VALUE rb_ll2inum(LONG_LONG);
-#define LL2NUM(v) rb_ll2inum(v)
-VALUE rb_ull2inum(unsigned LONG_LONG);
-#define ULL2NUM(v) rb_ull2inum(v)
-#endif
-
-#if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
-# define OFFT2NUM(v) LL2NUM(v)
-#elif SIZEOF_OFF_T == SIZEOF_LONG
-# define OFFT2NUM(v) LONG2NUM(v)
-#else
-# define OFFT2NUM(v) INT2NUM(v)
-#endif
-
-#ifndef PIDT2NUM
-#define PIDT2NUM(v) LONG2NUM(v)
-#endif
-#ifndef NUM2PIDT
-#define NUM2PIDT(v) NUM2LONG(v)
-#endif
-#ifndef UIDT2NUM
-#define UIDT2NUM(v) LONG2NUM(v)
-#endif
-#ifndef NUM2UIDT
-#define NUM2UIDT(v) NUM2LONG(v)
-#endif
-#ifndef GIDT2NUM
-#define GIDT2NUM(v) LONG2NUM(v)
-#endif
-#ifndef NUM2GIDT
-#define NUM2GIDT(v) NUM2LONG(v)
-#endif
-
-#define FIX2LONG(x) RSHIFT((SIGNED_VALUE)x,1)
-#define FIX2ULONG(x) ((((VALUE)(x))>>1)&LONG_MAX)
-#define FIXNUM_P(f) (((SIGNED_VALUE)(f))&FIXNUM_FLAG)
-#define POSFIXABLE(f) ((f) <= FIXNUM_MAX)
-#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
-#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
-
-#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
-
-#define SYMBOL_P(x) (((VALUE)(x)&~(~(VALUE)0<<RUBY_SPECIAL_SHIFT))==SYMBOL_FLAG)
-#define ID2SYM(x) (((VALUE)(x)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG)
-#define SYM2ID(x) RSHIFT((unsigned long)x,RUBY_SPECIAL_SHIFT)
-
-/* special contants - i.e. non-zero and non-fixnum constants */
-enum ruby_special_consts {
- RUBY_Qfalse = 0,
- RUBY_Qtrue = 2,
- RUBY_Qnil = 4,
- RUBY_Qundef = 6,
-
- RUBY_IMMEDIATE_MASK = 0x03,
- RUBY_FIXNUM_FLAG = 0x01,
- RUBY_SYMBOL_FLAG = 0x0e,
- RUBY_SPECIAL_SHIFT = 8,
-};
-
-#define Qfalse ((VALUE)RUBY_Qfalse)
-#define Qtrue ((VALUE)RUBY_Qtrue)
-#define Qnil ((VALUE)RUBY_Qnil)
-#define Qundef ((VALUE)RUBY_Qundef) /* undefined value for placeholder */
-#define IMMEDIATE_MASK RUBY_IMMEDIATE_MASK
-#define FIXNUM_FLAG RUBY_FIXNUM_FLAG
-#define SYMBOL_FLAG RUBY_SYMBOL_FLAG
-
-#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
-#define NIL_P(v) ((VALUE)(v) == Qnil)
-
-#define CLASS_OF(v) rb_class_of((VALUE)(v))
-
-enum ruby_value_type {
- RUBY_T_NONE = 0x00,
-#define T_NONE RUBY_T_NONE
-
- RUBY_T_NIL = 0x01,
-#define T_NIL RUBY_T_NIL
- RUBY_T_OBJECT = 0x02,
-#define T_OBJECT RUBY_T_OBJECT
- RUBY_T_CLASS = 0x03,
-#define T_CLASS RUBY_T_CLASS
- RUBY_T_ICLASS = 0x04,
-#define T_ICLASS RUBY_T_ICLASS
- RUBY_T_MODULE = 0x05,
-#define T_MODULE RUBY_T_MODULE
- RUBY_T_FLOAT = 0x06,
-#define T_FLOAT RUBY_T_FLOAT
- RUBY_T_STRING = 0x07,
-#define T_STRING RUBY_T_STRING
- RUBY_T_REGEXP = 0x08,
-#define T_REGEXP RUBY_T_REGEXP
- RUBY_T_ARRAY = 0x09,
-#define T_ARRAY RUBY_T_ARRAY
- RUBY_T_FIXNUM = 0x0a,
-#define T_FIXNUM RUBY_T_FIXNUM
- RUBY_T_HASH = 0x0b,
-#define T_HASH RUBY_T_HASH
- RUBY_T_STRUCT = 0x0c,
-#define T_STRUCT RUBY_T_STRUCT
- RUBY_T_BIGNUM = 0x0d,
-#define T_BIGNUM RUBY_T_BIGNUM
- RUBY_T_FILE = 0x0e,
-#define T_FILE RUBY_T_FILE
-
- RUBY_T_TRUE = 0x10,
-#define T_TRUE RUBY_T_TRUE
- RUBY_T_FALSE = 0x11,
-#define T_FALSE RUBY_T_FALSE
- RUBY_T_DATA = 0x12,
-#define T_DATA RUBY_T_DATA
- RUBY_T_MATCH = 0x13,
-#define T_MATCH RUBY_T_MATCH
- RUBY_T_SYMBOL = 0x14,
-#define T_SYMBOL RUBY_T_SYMBOL
-
- RUBY_T_VALUES = 0x1a,
-#define T_VALUES RUBY_T_VALUES
- RUBY_T_BLOCK = 0x1b,
-#define T_BLOCK RUBY_T_BLOCK
- RUBY_T_UNDEF = 0x1c,
-#define T_UNDEF RUBY_T_UNDEF
- RUBY_T_NODE = 0x1f,
-#define T_NODE RUBY_T_NODE
-
- RUBY_T_MASK = 0x1f,
-#define T_MASK RUBY_T_MASK
-};
-
-#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
-
-#define TYPE(x) rb_type((VALUE)(x))
-
-#define RB_GC_GUARD(v) (*(volatile VALUE *)&(v))
-
-void rb_check_type(VALUE,int);
-#define Check_Type(v,t) rb_check_type((VALUE)(v),t)
-
-VALUE rb_str_to_str(VALUE);
-VALUE rb_string_value(volatile VALUE*);
-char *rb_string_value_ptr(volatile VALUE*);
-char *rb_string_value_cstr(volatile VALUE*);
-
-#define StringValue(v) rb_string_value(&(v))
-#define StringValuePtr(v) rb_string_value_ptr(&(v))
-#define StringValueCStr(v) rb_string_value_cstr(&(v))
-
-void rb_check_safe_obj(VALUE);
-void rb_check_safe_str(VALUE);
-#define SafeStringValue(v) do {\
- StringValue(v);\
- rb_check_safe_obj(v);\
-} while (0)
-/* obsolete macro - use SafeStringValue(v) */
-#define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
-
-VALUE rb_get_path(VALUE);
-#define FilePathValue(v) ((v) = rb_get_path(v))
-
-VALUE rb_get_path_no_checksafe(VALUE);
-#define FilePathStringValue(v) ((v) = rb_get_path_no_checksafe(v))
-
-void rb_secure(int);
-int rb_safe_level(void);
-void rb_set_safe_level(int);
-void rb_set_safe_level_force(int);
-void rb_secure_update(VALUE);
-
-VALUE rb_errinfo(void);
-void rb_set_errinfo(VALUE);
-
-SIGNED_VALUE rb_num2long(VALUE);
-VALUE rb_num2ulong(VALUE);
-#define NUM2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
-#define NUM2ULONG(x) rb_num2ulong((VALUE)x)
-#if SIZEOF_INT < SIZEOF_LONG
-long rb_num2int(VALUE);
-#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):rb_num2int((VALUE)x))
-long rb_fix2int(VALUE);
-#define FIX2INT(x) rb_fix2int((VALUE)x)
-unsigned long rb_num2uint(VALUE);
-#define NUM2UINT(x) rb_num2uint(x)
-unsigned long rb_fix2uint(VALUE);
-#define FIX2UINT(x) rb_fix2uint(x)
-#else
-#define NUM2INT(x) ((int)NUM2LONG(x))
-#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
-#define FIX2INT(x) ((int)FIX2LONG(x))
-#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
-#endif
-
-#ifdef HAVE_LONG_LONG
-LONG_LONG rb_num2ll(VALUE);
-unsigned LONG_LONG rb_num2ull(VALUE);
-# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
-# define NUM2ULL(x) rb_num2ull((VALUE)x)
-#endif
-
-#if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T > SIZEOF_LONG
-# define NUM2OFFT(x) ((off_t)NUM2LL(x))
-#else
-# define NUM2OFFT(x) NUM2LONG(x)
-#endif
-
-double rb_num2dbl(VALUE);
-#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
-
-/* obsolete API - use StringValue() */
-char *rb_str2cstr(VALUE,long*);
-/* obsolete API - use StringValuePtr() */
-#define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
-
-#define NUM2CHR(x) (((TYPE(x) == T_STRING)&&(RSTRING_LEN(x)>=1))?\
- RSTRING_PTR(x)[0]:(char)(NUM2INT(x)&0xff))
-#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
-
-VALUE rb_newobj(void);
-#define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
-#define OBJSETUP(obj,c,t) do {\
- RBASIC(obj)->flags = (t);\
- RBASIC(obj)->klass = (c);\
- if (rb_safe_level() >= 3) FL_SET(obj, FL_TAINT);\
-} while (0)
-#define CLONESETUP(clone,obj) do {\
- OBJSETUP(clone,rb_singleton_class_clone((VALUE)obj),RBASIC(obj)->flags);\
- rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\
- if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)clone,(VALUE)obj);\
-} while (0)
-#define DUPSETUP(dup,obj) do {\
- OBJSETUP(dup,rb_obj_class(obj),(RBASIC(obj)->flags)&(T_MASK|FL_EXIVAR|FL_TAINT));\
- if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)dup,(VALUE)obj);\
-} while (0)
-
-struct RBasic {
- VALUE flags;
- VALUE klass;
-};
-
-#define ROBJECT_EMBED_LEN_MAX 3
-struct RObject {
- struct RBasic basic;
- union {
- struct {
- long len;
- VALUE *ptr;
- } heap;
- VALUE ary[ROBJECT_EMBED_LEN_MAX];
- } as;
-};
-#define ROBJECT_EMBED FL_USER1
-#define ROBJECT_LEN(o) \
- ((RBASIC(o)->flags & ROBJECT_EMBED) ? \
- ROBJECT_EMBED_LEN_MAX : \
- ROBJECT(o)->as.heap.len)
-#define ROBJECT_PTR(o) \
- ((RBASIC(o)->flags & ROBJECT_EMBED) ? \
- ROBJECT(o)->as.ary : \
- ROBJECT(o)->as.heap.ptr)
-
-struct RValues {
- struct RBasic basic;
- VALUE v1;
- VALUE v2;
- VALUE v3;
-};
-
-typedef struct {
- VALUE super;
- struct st_table *iv_tbl;
-} rb_classext_t;
-
-struct RClass {
- struct RBasic basic;
- rb_classext_t *ptr;
- struct st_table *m_tbl;
- struct st_table *iv_index_tbl;
-};
-#define RCLASS_IV_TBL(c) (RCLASS(c)->ptr->iv_tbl)
-#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
-#define RCLASS_SUPER(c) (RCLASS(c)->ptr->super)
-#define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
-#define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m)
-#define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
-#define RMODULE_SUPER(m) RCLASS_SUPER(m)
-
-struct RFloat {
- struct RBasic basic;
- double float_value;
-};
-#define RFLOAT_VALUE(v) (RFLOAT(v)->float_value)
-#define DOUBLE2NUM(dbl) rb_float_new(dbl)
-
-#define ELTS_SHARED FL_USER2
-
-#define RSTRING_EMBED_LEN_MAX ((sizeof(VALUE)*3)/sizeof(char)-1)
-struct RString {
- struct RBasic basic;
- union {
- struct {
- long len;
- char *ptr;
- union {
- long capa;
- VALUE shared;
- } aux;
- } heap;
- char ary[RSTRING_EMBED_LEN_MAX];
- } as;
-};
-#define RSTRING_NOEMBED FL_USER1
-#define RSTRING_EMBED_LEN_MASK (FL_USER2|FL_USER3|FL_USER4|FL_USER5|FL_USER6)
-#define RSTRING_EMBED_LEN_SHIFT (FL_USHIFT+2)
-#define RSTRING_LEN(str) \
- (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
- (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
- (RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT)) : \
- RSTRING(str)->as.heap.len)
-#define RSTRING_PTR(str) \
- (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
- RSTRING(str)->as.ary : \
- RSTRING(str)->as.heap.ptr)
-#define RSTRING_END(str) (RSTRING_PTR(str)+RSTRING_LEN(str))
-
-struct RArray {
- struct RBasic basic;
- long len;
- union {
- long capa;
- VALUE shared;
- } aux;
- VALUE *ptr;
-};
-#define RARRAY_LEN(a) RARRAY(a)->len
-#define RARRAY_PTR(a) RARRAY(a)->ptr
-
-struct RRegexp {
- struct RBasic basic;
- struct re_pattern_buffer *ptr;
- long len;
- char *str;
-};
-
-struct RHash {
- struct RBasic basic;
- struct st_table *ntbl; /* possibly 0 */
- int iter_lev;
- VALUE ifnone;
-};
-/* RHASH_TBL allocates st_table if not available. */
-#define RHASH_TBL(h) rb_hash_tbl(h)
-#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
-#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
-#define RHASH_SIZE(h) (RHASH(h)->ntbl ? RHASH(h)->ntbl->num_entries : 0)
-#define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
-
-struct RFile {
- struct RBasic basic;
- struct rb_io_t *fptr;
-};
-
-struct RData {
- struct RBasic basic;
- void (*dmark)(void*);
- void (*dfree)(void*);
- void *data;
-};
-
-#define DATA_PTR(dta) (RDATA(dta)->data)
-
-/*
-#define RUBY_DATA_FUNC(func) ((void (*)(void*))func)
-*/
-typedef void (*RUBY_DATA_FUNC)(void*);
-
-VALUE rb_data_object_alloc(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
-
-#define Data_Wrap_Struct(klass,mark,free,sval)\
- rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)
-
-#define Data_Make_Struct(klass,type,mark,free,sval) (\
- sval = ALLOC(type),\
- memset(sval, 0, sizeof(type)),\
- Data_Wrap_Struct(klass,mark,free,sval)\
-)
-
-#define Data_Get_Struct(obj,type,sval) do {\
- Check_Type(obj, T_DATA); \
- sval = (type*)DATA_PTR(obj);\
-} while (0)
-
-#define RSTRUCT_EMBED_LEN_MAX 3
-struct RStruct {
- struct RBasic basic;
- union {
- struct {
- long len;
- VALUE *ptr;
- } heap;
- VALUE ary[RSTRUCT_EMBED_LEN_MAX];
- } as;
-};
-#define RSTRUCT_EMBED_LEN_MASK (FL_USER2|FL_USER1)
-#define RSTRUCT_EMBED_LEN_SHIFT (FL_USHIFT+1)
-#define RSTRUCT_LEN(st) \
- ((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \
- (long)((RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & \
- (RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT)) : \
- RSTRUCT(st)->as.heap.len)
-#define RSTRUCT_PTR(st) \
- ((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \
- RSTRUCT(st)->as.ary : \
- RSTRUCT(st)->as.heap.ptr)
-
-#define RBIGNUM_EMBED_LEN_MAX ((sizeof(VALUE)*3)/sizeof(BDIGIT))
-struct RBignum {
- struct RBasic basic;
- union {
- struct {
- long len;
- BDIGIT *digits;
- } heap;
- BDIGIT ary[RBIGNUM_EMBED_LEN_MAX];
- } as;
-};
-#define RBIGNUM_SIGN_BIT FL_USER1
-/* sign: positive:1, negative:0 */
-#define RBIGNUM_SIGN(b) ((RBASIC(b)->flags & RBIGNUM_SIGN_BIT) != 0)
-#define RBIGNUM_SET_SIGN(b,sign) \
- ((sign) ? (RBASIC(b)->flags |= RBIGNUM_SIGN_BIT) \
- : (RBASIC(b)->flags &= ~RBIGNUM_SIGN_BIT))
-#define RBIGNUM_POSITIVE_P(b) RBIGNUM_SIGN(b)
-#define RBIGNUM_NEGATIVE_P(b) (!RBIGNUM_SIGN(b))
-
-#define RBIGNUM_EMBED_FLAG FL_USER2
-#define RBIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
-#define RBIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+3)
-#define RBIGNUM_LEN(b) \
- ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
- (long)((RBASIC(b)->flags >> RBIGNUM_EMBED_LEN_SHIFT) & \
- (RBIGNUM_EMBED_LEN_MASK >> RBIGNUM_EMBED_LEN_SHIFT)) : \
- RBIGNUM(b)->as.heap.len)
-#define RBIGNUM_DIGITS(b) \
- ((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
- RBIGNUM(b)->as.ary : \
- RBIGNUM(b)->as.heap.digits)
-
-#define R_CAST(st) (struct st*)
-#define RBASIC(obj) (R_CAST(RBasic)(obj))
-#define ROBJECT(obj) (R_CAST(RObject)(obj))
-#define RCLASS(obj) (R_CAST(RClass)(obj))
-#define RMODULE(obj) RCLASS(obj)
-#define RFLOAT(obj) (R_CAST(RFloat)(obj))
-#define RSTRING(obj) (R_CAST(RString)(obj))
-#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
-#define RARRAY(obj) (R_CAST(RArray)(obj))
-#define RHASH(obj) (R_CAST(RHash)(obj))
-#define RDATA(obj) (R_CAST(RData)(obj))
-#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
-#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
-#define RFILE(obj) (R_CAST(RFile)(obj))
-#define RVALUES(obj) (R_CAST(RValues)(obj))
-
-#define FL_SINGLETON FL_USER0
-#define FL_MARK (((VALUE)1)<<5)
-#define FL_RESERVED (((VALUE)1)<<6) /* will be used in the future GC */
-#define FL_FINALIZE (((VALUE)1)<<7)
-#define FL_TAINT (((VALUE)1)<<8)
-#define FL_EXIVAR (((VALUE)1)<<9)
-#define FL_FREEZE (((VALUE)1)<<10)
-
-#define FL_USHIFT 11
-
-#define FL_USER0 (((VALUE)1)<<(FL_USHIFT+0))
-#define FL_USER1 (((VALUE)1)<<(FL_USHIFT+1))
-#define FL_USER2 (((VALUE)1)<<(FL_USHIFT+2))
-#define FL_USER3 (((VALUE)1)<<(FL_USHIFT+3))
-#define FL_USER4 (((VALUE)1)<<(FL_USHIFT+4))
-#define FL_USER5 (((VALUE)1)<<(FL_USHIFT+5))
-#define FL_USER6 (((VALUE)1)<<(FL_USHIFT+6))
-#define FL_USER7 (((VALUE)1)<<(FL_USHIFT+7))
-#define FL_USER8 (((VALUE)1)<<(FL_USHIFT+8))
-#define FL_USER9 (((VALUE)1)<<(FL_USHIFT+9))
-#define FL_USER10 (((VALUE)1)<<(FL_USHIFT+10))
-#define FL_USER11 (((VALUE)1)<<(FL_USHIFT+11))
-#define FL_USER12 (((VALUE)1)<<(FL_USHIFT+12))
-#define FL_USER13 (((VALUE)1)<<(FL_USHIFT+13))
-#define FL_USER14 (((VALUE)1)<<(FL_USHIFT+14))
-#define FL_USER15 (((VALUE)1)<<(FL_USHIFT+15))
-#define FL_USER16 (((VALUE)1)<<(FL_USHIFT+16))
-#define FL_USER17 (((VALUE)1)<<(FL_USHIFT+17))
-#define FL_USER18 (((VALUE)1)<<(FL_USHIFT+18))
-#define FL_USER19 (((VALUE)1)<<(FL_USHIFT+19))
-#define FL_USER20 (((VALUE)1)<<(FL_USHIFT+20))
-
-#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
-
-#define FL_ABLE(x) (!SPECIAL_CONST_P(x) && BUILTIN_TYPE(x) != T_NODE)
-#define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
-#define FL_ANY(x,f) FL_TEST(x,f)
-#define FL_ALL(x,f) (FL_TEST(x,f) == (f))
-#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
-#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
-#define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
-
-#define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
-#define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
-#define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
-
-#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
-#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
-
-#define ALLOC_N(type,n) (type*)xmalloc2((n),sizeof(type))
-#define ALLOC(type) (type*)xmalloc(sizeof(type))
-#define REALLOC_N(var,type,n) (var)=(type*)xrealloc2((char*)(var),(n),sizeof(type))
-
-#define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
-
-#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
-#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
-#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
-#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
-
-void rb_obj_infect(VALUE,VALUE);
-
-typedef int ruby_glob_func(const char*,VALUE);
-void rb_glob(const char*,void(*)(const char*,VALUE),VALUE);
-int ruby_glob(const char*,int,ruby_glob_func*,VALUE);
-int ruby_brace_expand(const char*,int,ruby_glob_func*,VALUE);
-int ruby_brace_glob(const char*,int,ruby_glob_func*,VALUE);
-
-VALUE rb_define_class(const char*,VALUE);
-VALUE rb_define_module(const char*);
-VALUE rb_define_class_under(VALUE, const char*, VALUE);
-VALUE rb_define_module_under(VALUE, const char*);
-
-void rb_include_module(VALUE,VALUE);
-void rb_extend_object(VALUE,VALUE);
-
-void rb_define_variable(const char*,VALUE*);
-void rb_define_virtual_variable(const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS));
-void rb_define_hooked_variable(const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS));
-void rb_define_readonly_variable(const char*,VALUE*);
-void rb_define_const(VALUE,const char*,VALUE);
-void rb_define_global_const(const char*,VALUE);
-
-#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
-void rb_define_method(VALUE,const char*,VALUE(*)(ANYARGS),int);
-void rb_define_module_function(VALUE,const char*,VALUE(*)(ANYARGS),int);
-void rb_define_global_function(const char*,VALUE(*)(ANYARGS),int);
-
-void rb_undef_method(VALUE,const char*);
-void rb_define_alias(VALUE,const char*,const char*);
-void rb_define_attr(VALUE,const char*,int,int);
-
-void rb_global_variable(VALUE*);
-void rb_register_mark_object(VALUE);
-void rb_gc_register_address(VALUE*);
-void rb_gc_unregister_address(VALUE*);
-
-ID rb_intern(const char*);
-ID rb_intern2(const char*, long);
-ID rb_intern_str(VALUE str);
-const char *rb_id2name(ID);
-ID rb_to_id(VALUE);
-VALUE rb_id2str(ID);
-
-char *rb_class2name(VALUE);
-char *rb_obj_classname(VALUE);
-
-void rb_p(VALUE);
-
-VALUE rb_eval_string(const char*);
-VALUE rb_eval_string_protect(const char*, int*);
-VALUE rb_eval_string_wrap(const char*, int*);
-VALUE rb_funcall(VALUE, ID, int, ...);
-VALUE rb_funcall2(VALUE, ID, int, const VALUE*);
-VALUE rb_funcall3(VALUE, ID, int, const VALUE*);
-int rb_scan_args(int, const VALUE*, const char*, ...);
-VALUE rb_call_super(int, const VALUE*);
-
-VALUE rb_gv_set(const char*, VALUE);
-VALUE rb_gv_get(const char*);
-VALUE rb_iv_get(VALUE, const char*);
-VALUE rb_iv_set(VALUE, const char*, VALUE);
-
-VALUE rb_equal(VALUE,VALUE);
-
-RUBY_EXTERN VALUE ruby_verbose, ruby_debug;
-
-PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3);
-PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2);
-PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
-NORETURN(void rb_sys_fail(const char*));
-NORETURN(void rb_iter_break(void));
-NORETURN(void rb_exit(int));
-NORETURN(void rb_notimplement(void));
-
-/* reports if `-w' specified */
-PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2);
-PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
-PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
-/* reports always */
-PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
-PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
-
-typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);
-
-VALUE rb_each(VALUE);
-VALUE rb_yield(VALUE);
-VALUE rb_yield_values(int n, ...);
-VALUE rb_yield_values2(int n, VALUE *argv);
-VALUE rb_yield_splat(VALUE);
-int rb_block_given_p(void);
-void rb_need_block(void);
-VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_block_call(VALUE,ID,int,VALUE*,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...);
-VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);
-NORETURN(void rb_throw(const char*,VALUE));
-NORETURN(void rb_throw_obj(VALUE,VALUE));
-
-VALUE rb_require(const char*);
-
-#ifdef __ia64
-void ruby_init_stack(VALUE*, void*);
-#define RUBY_INIT_STACK \
- VALUE variable_in_this_stack_frame; \
- ruby_init_stack(&variable_in_this_stack_frame, rb_ia64_bsp());
-#else
-void ruby_init_stack(VALUE*);
-#define RUBY_INIT_STACK \
- VALUE variable_in_this_stack_frame; \
- ruby_init_stack(&variable_in_this_stack_frame);
-#endif
-void ruby_init(void);
-void *ruby_options(int, char**);
-int ruby_run_node(void *);
-
-RUBY_EXTERN VALUE rb_mKernel;
-RUBY_EXTERN VALUE rb_mComparable;
-RUBY_EXTERN VALUE rb_mEnumerable;
-RUBY_EXTERN VALUE rb_mPrecision;
-RUBY_EXTERN VALUE rb_mErrno;
-RUBY_EXTERN VALUE rb_mFileTest;
-RUBY_EXTERN VALUE rb_mGC;
-RUBY_EXTERN VALUE rb_mMath;
-RUBY_EXTERN VALUE rb_mProcess;
-
-RUBY_EXTERN VALUE rb_cBasicObject;
-RUBY_EXTERN VALUE rb_cObject;
-RUBY_EXTERN VALUE rb_cArray;
-RUBY_EXTERN VALUE rb_cBignum;
-RUBY_EXTERN VALUE rb_cBinding;
-RUBY_EXTERN VALUE rb_cClass;
-RUBY_EXTERN VALUE rb_cCont;
-RUBY_EXTERN VALUE rb_cDir;
-RUBY_EXTERN VALUE rb_cData;
-RUBY_EXTERN VALUE rb_cFalseClass;
-RUBY_EXTERN VALUE rb_cFile;
-RUBY_EXTERN VALUE rb_cFixnum;
-RUBY_EXTERN VALUE rb_cFloat;
-RUBY_EXTERN VALUE rb_cHash;
-RUBY_EXTERN VALUE rb_cInteger;
-RUBY_EXTERN VALUE rb_cIO;
-RUBY_EXTERN VALUE rb_cMatch;
-RUBY_EXTERN VALUE rb_cMethod;
-RUBY_EXTERN VALUE rb_cModule;
-RUBY_EXTERN VALUE rb_cNameErrorMesg;
-RUBY_EXTERN VALUE rb_cNilClass;
-RUBY_EXTERN VALUE rb_cNumeric;
-RUBY_EXTERN VALUE rb_cProc;
-RUBY_EXTERN VALUE rb_cRange;
-RUBY_EXTERN VALUE rb_cRegexp;
-RUBY_EXTERN VALUE rb_cStat;
-RUBY_EXTERN VALUE rb_cString;
-RUBY_EXTERN VALUE rb_cStruct;
-RUBY_EXTERN VALUE rb_cSymbol;
-RUBY_EXTERN VALUE rb_cThread;
-RUBY_EXTERN VALUE rb_cTime;
-RUBY_EXTERN VALUE rb_cTrueClass;
-RUBY_EXTERN VALUE rb_cUnboundMethod;
-RUBY_EXTERN VALUE rb_cISeq;
-RUBY_EXTERN VALUE rb_cVM;
-RUBY_EXTERN VALUE rb_cEnv;
-
-RUBY_EXTERN VALUE rb_eException;
-RUBY_EXTERN VALUE rb_eStandardError;
-RUBY_EXTERN VALUE rb_eSystemExit;
-RUBY_EXTERN VALUE rb_eInterrupt;
-RUBY_EXTERN VALUE rb_eSignal;
-RUBY_EXTERN VALUE rb_eFatal;
-RUBY_EXTERN VALUE rb_eArgError;
-RUBY_EXTERN VALUE rb_eEOFError;
-RUBY_EXTERN VALUE rb_eIndexError;
-RUBY_EXTERN VALUE rb_eStopIteration;
-RUBY_EXTERN VALUE rb_eKeyError;
-RUBY_EXTERN VALUE rb_eRangeError;
-RUBY_EXTERN VALUE rb_eIOError;
-RUBY_EXTERN VALUE rb_eRuntimeError;
-RUBY_EXTERN VALUE rb_eSecurityError;
-RUBY_EXTERN VALUE rb_eSystemCallError;
-RUBY_EXTERN VALUE rb_eThreadError;
-RUBY_EXTERN VALUE rb_eTypeError;
-RUBY_EXTERN VALUE rb_eZeroDivError;
-RUBY_EXTERN VALUE rb_eNotImpError;
-RUBY_EXTERN VALUE rb_eNoMemError;
-RUBY_EXTERN VALUE rb_eNoMethodError;
-RUBY_EXTERN VALUE rb_eFloatDomainError;
-RUBY_EXTERN VALUE rb_eLocalJumpError;
-RUBY_EXTERN VALUE rb_eSysStackError;
-RUBY_EXTERN VALUE rb_eRegexpError;
-
-RUBY_EXTERN VALUE rb_eScriptError;
-RUBY_EXTERN VALUE rb_eNameError;
-RUBY_EXTERN VALUE rb_eSyntaxError;
-RUBY_EXTERN VALUE rb_eLoadError;
-
-RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
-
-static inline VALUE
-rb_class_of(VALUE obj)
-{
- if (IMMEDIATE_P(obj)) {
- if (FIXNUM_P(obj)) return rb_cFixnum;
- if (obj == Qtrue) return rb_cTrueClass;
- if (SYMBOL_P(obj)) return rb_cSymbol;
- }
- else if (!RTEST(obj)) {
- if (obj == Qnil) return rb_cNilClass;
- if (obj == Qfalse) return rb_cFalseClass;
- }
- return RBASIC(obj)->klass;
-}
-
-static inline int
-rb_type(VALUE obj)
-{
- if (IMMEDIATE_P(obj)) {
- if (FIXNUM_P(obj)) return T_FIXNUM;
- if (obj == Qtrue) return T_TRUE;
- if (SYMBOL_P(obj)) return T_SYMBOL;
- if (obj == Qundef) return T_UNDEF;
- }
- else if (!RTEST(obj)) {
- if (obj == Qnil) return T_NIL;
- if (obj == Qfalse) return T_FALSE;
- }
- return BUILTIN_TYPE(obj);
-}
-
-static inline int
-rb_special_const_p(VALUE obj)
-{
- if (SPECIAL_CONST_P(obj)) return Qtrue;
- return Qfalse;
-}
-
-#include "ruby/missing.h"
-#include "ruby/intern.h"
-
-#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
-/* hook for external modules */
-static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
-#endif
-
-#if (defined(__APPLE__) || defined(__NeXT__)) && defined(__MACH__)
-/* to link startup code with ObjC support */
-#define RUBY_GLOBAL_SETUP static void objcdummyfunction(void) {objc_msgSend();}
-#else
-#define RUBY_GLOBAL_SETUP
-#endif
-
-void ruby_sysinit(int *, char ***);
-
-#define RUBY_VM 1 /* YARV */
-#define HAVE_NATIVETHREAD
-int ruby_native_thread_p(void);
-
-#define RUBY_EVENT_NONE 0x00
-#define RUBY_EVENT_LINE 0x01
-#define RUBY_EVENT_CLASS 0x02
-#define RUBY_EVENT_END 0x04
-#define RUBY_EVENT_CALL 0x08
-#define RUBY_EVENT_RETURN 0x10
-#define RUBY_EVENT_C_CALL 0x20
-#define RUBY_EVENT_C_RETURN 0x40
-#define RUBY_EVENT_RAISE 0x80
-#define RUBY_EVENT_ALL 0xff
-#define RUBY_EVENT_VM 0x100
-#define RUBY_EVENT_SWITCH 0x200
-
-typedef unsigned int rb_event_flag_t;
-typedef void (*rb_event_hook_func_t)(rb_event_flag_t, VALUE data, VALUE, ID, VALUE klass);
-
-typedef struct rb_event_hook_struct {
- rb_event_flag_t flag;
- rb_event_hook_func_t func;
- VALUE data;
- struct rb_event_hook_struct *next;
-} rb_event_hook_t;
-
-void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events,
- VALUE data);
-int rb_remove_event_hook(rb_event_hook_func_t func);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_H */
diff --git a/include/ruby/signal.h b/include/ruby/signal.h
deleted file mode 100644
index 23db123d92..0000000000
--- a/include/ruby/signal.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/**********************************************************************
-
- rubysig.h -
-
- $Author$
- $Date$
- created at: Wed Aug 16 01:15:38 JST 1995
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBYSIG_H
-#define RUBYSIG_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#include <errno.h>
-
-#ifdef _WIN32
-typedef LONG rb_atomic_t;
-
-# define ATOMIC_TEST(var) InterlockedExchange(&(var), 0)
-# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
-# define ATOMIC_INC(var) InterlockedIncrement(&(var))
-# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
-
-/* Windows doesn't allow interrupt while system calls */
-# define TRAP_BEG do {\
- rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1)
-
-# define TRAP_END\
- ATOMIC_SET(rb_trap_immediate, trap_immediate);\
-} while (0)
-
-# define RUBY_CRITICAL(statements) do {\
- rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 0);\
- statements;\
- ATOMIC_SET(rb_trap_immediate, trap_immediate);\
-} while (0)
-#else
-typedef int rb_atomic_t;
-
-# define ATOMIC_TEST(var) ((var) ? ((var) = 0, 1) : 0)
-# define ATOMIC_SET(var, val) ((var) = (val))
-# define ATOMIC_INC(var) (++(var))
-# define ATOMIC_DEC(var) (--(var))
-
-# define TRAP_BEG do {\
- int trap_immediate = rb_trap_immediate;\
- rb_trap_immediate = 1
-
-# define TRAP_END \
- rb_trap_immediate = trap_immediate;\
-} while (0)
-
-# define RUBY_CRITICAL(statements) do {\
- int trap_immediate = rb_trap_immediate;\
- rb_trap_immediate = 0;\
- statements;\
- rb_trap_immediate = trap_immediate;\
-} while (0)
-#endif
-RUBY_EXTERN rb_atomic_t rb_trap_immediate;
-
-RUBY_EXTERN int rb_prohibit_interrupt;
-#define DEFER_INTS (rb_prohibit_interrupt++)
-#define ALLOW_INTS do {\
- rb_prohibit_interrupt--;\
-} while (0)
-#define ENABLE_INTS (rb_prohibit_interrupt--)
-
-VALUE rb_with_disable_interrupt(VALUE(*)(ANYARGS),VALUE);
-
-RUBY_EXTERN rb_atomic_t rb_trap_pending;
-void rb_trap_restore_mask(void);
-
-RUBY_EXTERN int rb_thread_critical;
-void rb_thread_schedule(void);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBYSIG_H */
diff --git a/include/ruby/st.h b/include/ruby/st.h
deleted file mode 100644
index 4adf48fde4..0000000000
--- a/include/ruby/st.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
-
-/* @(#) st.h 5.1 89/12/14 */
-
-#ifndef RUBY_ST_H
-#define RUBY_ST_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#if SIZEOF_LONG == SIZEOF_VOIDP
-typedef unsigned long st_data_t;
-#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-typedef unsigned LONG_LONG st_data_t;
-#else
-# error ---->> st.c requires sizeof(void*) == sizeof(long) to be compiled. <<----
-#endif
-#define ST_DATA_T_DEFINED
-
-#ifndef CHAR_BIT
-# ifdef HAVE_LIMITS_H
-# include <limits.h>
-# else
-# define CHAR_BIT 8
-# endif
-#endif
-#ifndef _
-# define _(args) args
-#endif
-#ifndef ANYARGS
-# ifdef __cplusplus
-# define ANYARGS ...
-# else
-# define ANYARGS
-# endif
-#endif
-
-typedef struct st_table st_table;
-
-typedef int st_compare_func(st_data_t, st_data_t);
-typedef int st_hash_func(st_data_t);
-
-struct st_hash_type {
- int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
- int (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
-};
-
-typedef st_data_t st_index_t;
-#define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT)
-
-struct st_table {
- const struct st_hash_type *type;
- st_index_t num_bins;
- unsigned int entries_packed : 1;
- st_index_t num_entries : ST_INDEX_BITS - 1;
- struct st_table_entry **bins;
- struct st_table_entry *head;
-};
-
-#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
-
-enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
-
-st_table *st_init_table(const struct st_hash_type *);
-st_table *st_init_table_with_size(const struct st_hash_type *, int);
-st_table *st_init_numtable(void);
-st_table *st_init_numtable_with_size(int);
-st_table *st_init_strtable(void);
-st_table *st_init_strtable_with_size(int);
-st_table *st_init_strcasetable(void);
-st_table *st_init_strcasetable_with_size(int);
-int st_delete(st_table *, st_data_t *, st_data_t *);
-int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
-int st_insert(st_table *, st_data_t, st_data_t);
-int st_lookup(st_table *, st_data_t, st_data_t *);
-int st_get_key(st_table *, st_data_t, st_data_t *);
-int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
-int st_reverse_foreach(st_table *, int (*)(ANYARGS), st_data_t);
-void st_add_direct(st_table *, st_data_t, st_data_t);
-void st_free_table(st_table *);
-void st_cleanup_safe(st_table *, st_data_t);
-void st_clear(st_table *);
-st_table *st_copy(st_table *);
-int st_numcmp(st_data_t, st_data_t);
-int st_numhash(st_data_t);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_ST_H */
diff --git a/include/ruby/util.h b/include/ruby/util.h
deleted file mode 100644
index f9ce983269..0000000000
--- a/include/ruby/util.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**********************************************************************
-
- util.h -
-
- $Author$
- $Date$
- created at: Thu Mar 9 11:55:53 JST 1995
-
- Copyright (C) 1993-2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_UTIL_H
-#define RUBY_UTIL_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-#ifndef _
-#ifdef __cplusplus
-# ifndef HAVE_PROTOTYPES
-# define HAVE_PROTOTYPES 1
-# endif
-# ifndef HAVE_STDARG_PROTOTYPES
-# define HAVE_STDARG_PROTOTYPES 1
-# endif
-#endif
-#ifdef HAVE_PROTOTYPES
-# define _(args) args
-#else
-# define _(args) ()
-#endif
-#ifdef HAVE_STDARG_PROTOTYPES
-# define __(args) args
-#else
-# define __(args) ()
-#endif
-#endif
-
-#define scan_oct ruby_scan_oct
-unsigned long ruby_scan_oct(const char *, int, int *);
-#define scan_hex ruby_scan_hex
-unsigned long ruby_scan_hex(const char *, int, int *);
-
-#if defined(MSDOS) || defined(__CYGWIN32__) || defined(_WIN32)
-void ruby_add_suffix(VALUE str, const char *suffix);
-#endif
-
-void ruby_qsort(void *, const int, const int,
- int (*)(const void *, const void *, void *), void *);
-
-void ruby_setenv(const char *, const char *);
-void ruby_unsetenv(const char *);
-#undef setenv
-#undef unsetenv
-#define setenv(name,val) ruby_setenv(name,val)
-#define unsetenv(name,val) ruby_unsetenv(name);
-
-char *ruby_strdup(const char *);
-#undef strdup
-#define strdup(s) ruby_strdup(s)
-
-char *ruby_getcwd(void);
-#define my_getcwd() ruby_getcwd()
-
-double ruby_strtod(const char *, char **);
-#undef strtod
-#define strtod(s,e) ruby_strtod(s,e)
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_UTIL_H */
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
deleted file mode 100644
index 79e3396892..0000000000
--- a/include/ruby/win32.h
+++ /dev/null
@@ -1,565 +0,0 @@
-#ifndef RUBY_WIN32_H
-#define RUBY_WIN32_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
-/*
- * Copyright (c) 1993, Intergraph Corporation
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the perl README file.
- *
- */
-
-//
-// Definitions for NT port of Perl
-//
-
-
-//
-// Ok now we can include the normal include files.
-//
-
-// #include <stdarg.h> conflict with varargs.h?
-#if !defined(WSAAPI)
-#include <winsock2.h>
-#endif
-
-#define NT 1 /* deprecated */
-
-#ifdef _WIN32_WCE
-#undef CharNext
-#define CharNext CharNextA
-#endif
-
-//
-// We're not using Microsoft's "extensions" to C for
-// Structured Exception Handling (SEH) so we can nuke these
-//
-#undef try
-#undef except
-#undef finally
-#undef leave
-
-#if defined(__cplusplus)
-extern "C++" {
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <direct.h>
-#include <process.h>
-#include <time.h>
-#include <math.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#ifdef HAVE_SYS_UTIME_H
-# include <sys/utime.h>
-#else
-# include <utime.h>
-#endif
-#include <io.h>
-#include <malloc.h>
-#ifdef __MINGW32__
-# include <stdint.h>
-#else
-# if !defined(_INTPTR_T_DEFINED)
-# ifdef _WIN64
-typedef __int64 intptr_t;
-# else
-typedef int intptr_t;
-# endif
-# define _INTPTR_T_DEFINED
-# endif
-# if !defined(_UINTPTR_T_DEFINED)
-# ifdef _WIN64
-typedef unsigned __int64 uintptr_t;
-# else
-typedef unsigned int uintptr_t;
-# endif
-# define _UINTPTR_T_DEFINED
-# endif
-#endif
-
-#if defined(__cplusplus)
-}
-#endif
-
-#ifdef _M_IX86
-# define WIN95 1
-#else
-# undef WIN95
-#endif
-
-#ifdef WIN95
-extern DWORD rb_w32_osid(void);
-#define rb_w32_iswinnt() (rb_w32_osid() == VER_PLATFORM_WIN32_NT)
-#define rb_w32_iswin95() (rb_w32_osid() == VER_PLATFORM_WIN32_WINDOWS)
-#else
-#define rb_w32_iswinnt() TRUE
-#define rb_w32_iswin95() FALSE
-#endif
-
-#define WNOHANG -1
-
-#undef getc
-#undef putc
-#undef fgetc
-#undef fputc
-#undef getchar
-#undef putchar
-#undef fgetchar
-#undef fputchar
-#undef utime
-#undef lseek
-#undef fstat
-#define getc(_stream) rb_w32_getc(_stream)
-#define getchar() rb_w32_getc(stdin)
-#define putc(_c, _stream) rb_w32_putc(_c, _stream)
-#define putchar(_c) rb_w32_putc(_c, stdout)
-#ifdef RUBY_EXPORT
-#define fgetc(_stream) getc(_stream)
-#define fputc(_c, _stream) putc(_c, _stream)
-#define fgetchar() getchar()
-#define fputchar(_c) putchar(_c)
-#define utime(_p, _t) rb_w32_utime(_p, _t)
-#define lseek(_f, _o, _w) _lseeki64(_f, _o, _w)
-
-#define pipe(p) _pipe(p, 2048L, O_BINARY)
-#define close(h) rb_w32_close(h)
-#define fclose(f) rb_w32_fclose(f)
-#define read(f, b, s) rb_w32_read(f, b, s)
-#define write(f, b, s) rb_w32_write(f, b, s)
-#define getpid() rb_w32_getpid()
-#define sleep(x) rb_w32_Sleep((x)*1000)
-#define Sleep(msec) (void)rb_w32_Sleep(msec)
-#define fstat(fd,st) _fstati64(fd,st)
-#ifdef __BORLANDC__
-#define creat(p, m) _creat(p, m)
-#define eof() _eof()
-#define filelength(h) _filelength(h)
-#define mktemp(t) _mktemp(t)
-#define tell(h) _tell(h)
-#define _open _sopen
-#define sopen _sopen
-#define _fstati64(fd,st) rb_w32_fstati64(fd,st)
-#undef fopen
-#define fopen(p, m) rb_w32_fopen(p, m)
-#undef fdopen
-#define fdopen(h, m) rb_w32_fdopen(h, m)
-#undef fsopen
-#define fsopen(p, m, sh) rb_w32_fsopen(p, m, sh)
-#endif
-
-#undef execv
-#define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv)
-#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
-#undef isatty
-#define isatty(h) rb_w32_isatty(h)
-#endif
-
-#undef mkdir
-#define mkdir(p, m) rb_w32_mkdir(p, m)
-#undef rmdir
-#define rmdir(p) rb_w32_rmdir(p)
-#undef unlink
-#define unlink(p) rb_w32_unlink(p)
-#endif
-
-#if SIZEOF_OFF_T == 8
-#define off_t __int64
-#define stat stati64
-#if defined(__BORLANDC__)
-#define stati64(path, st) rb_w32_stati64(path, st)
-#elif !defined(_MSC_VER) || _MSC_VER < 1400
-#define stati64 _stati64
-#define _stati64(path, st) rb_w32_stati64(path, st)
-#else
-#define stati64 _stat64
-#define _stat64(path, st) rb_w32_stati64(path, st)
-#endif
-#else
-#define stat(path,st) rb_w32_stat(path,st)
-#define fstat(fd,st) rb_w32_fstat(fd,st)
-extern int rb_w32_stat(const char *, struct stat *);
-extern int rb_w32_fstat(int, struct stat *);
-#endif
-
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-#define fsync _commit
-
-#ifdef __MINGW32__
-struct timezone {
- int tz_minuteswest;
- int tz_dsttime;
-};
-#undef isascii
-#define isascii __isascii
-#endif
-#define NtInitialize ruby_sysinit
-extern int rb_w32_cmdvector(const char *, char ***);
-extern rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *);
-extern int flock(int fd, int oper);
-extern int rb_w32_is_socket(int);
-extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
-extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
-extern int WSAAPI rb_w32_connect(int, const struct sockaddr *, int);
-extern void rb_w32_fdset(int, fd_set*);
-extern void rb_w32_fdclr(int, fd_set*);
-extern int rb_w32_fdisset(int, fd_set*);
-extern int WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-extern int WSAAPI rb_w32_getpeername(int, struct sockaddr *, int *);
-extern int WSAAPI rb_w32_getsockname(int, struct sockaddr *, int *);
-extern int WSAAPI rb_w32_getsockopt(int, int, int, char *, int *);
-extern int WSAAPI rb_w32_ioctlsocket(int, long, u_long *);
-extern int WSAAPI rb_w32_listen(int, int);
-extern int WSAAPI rb_w32_recv(int, char *, int, int);
-extern int WSAAPI rb_w32_recvfrom(int, char *, int, int, struct sockaddr *, int *);
-extern int WSAAPI rb_w32_send(int, const char *, int, int);
-extern int WSAAPI rb_w32_sendto(int, const char *, int, int, const struct sockaddr *, int);
-extern int WSAAPI rb_w32_setsockopt(int, int, int, const char *, int);
-extern int WSAAPI rb_w32_shutdown(int, int);
-extern int WSAAPI rb_w32_socket(int, int, int);
-extern SOCKET rb_w32_get_osfhandle(int);
-extern struct hostent *WSAAPI rb_w32_gethostbyaddr(const char *, int, int);
-extern struct hostent *WSAAPI rb_w32_gethostbyname(const char *);
-extern int WSAAPI rb_w32_gethostname(char *, int);
-extern struct protoent *WSAAPI rb_w32_getprotobyname(const char *);
-extern struct protoent *WSAAPI rb_w32_getprotobynumber(int);
-extern struct servent *WSAAPI rb_w32_getservbyname(const char *, const char *);
-extern struct servent *WSAAPI rb_w32_getservbyport(int, const char *);
-extern int rb_w32_socketpair(int, int, int, int *);
-extern char * rb_w32_getcwd(char *, int);
-extern char * rb_w32_getenv(const char *);
-extern int rb_w32_rename(const char *, const char *);
-extern char **rb_w32_get_environ(void);
-extern void rb_w32_free_environ(char **);
-
-#define vsnprintf(s,n,f,l) rb_w32_vsnprintf(s,n,f,l)
-#define snprintf rb_w32_snprintf
-extern int rb_w32_vsnprintf(char *, size_t, const char *, va_list);
-extern int rb_w32_snprintf(char *, size_t, const char *, ...);
-
-extern int chown(const char *, int, int);
-extern int link(const char *, const char *);
-extern int gettimeofday(struct timeval *, struct timezone *);
-extern rb_pid_t waitpid (rb_pid_t, int *, int);
-extern int rb_w32_argv_size(char *const *);
-extern char *rb_w32_join_argv(char *, char *const *);
-extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
-extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
-extern int kill(int, int);
-extern int fcntl(int, int, ...);
-extern rb_pid_t rb_w32_getpid(void);
-#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
-extern int rb_w32_isatty(int);
-#endif
-extern int rb_w32_mkdir(const char *, int);
-extern int rb_w32_rmdir(const char *);
-extern int rb_w32_unlink(const char *);
-extern int rb_w32_stati64(const char *, struct stati64 *);
-
-#ifdef __BORLANDC__
-extern int rb_w32_fstati64(int, struct stati64 *);
-extern off_t _lseeki64(int, off_t, int);
-extern FILE *rb_w32_fopen(const char *, const char *);
-extern FILE *rb_w32_fdopen(int, const char *);
-extern FILE *rb_w32_fsopen(const char *, const char *, int);
-#endif
-
-#include <float.h>
-#if !defined __MINGW32__ || defined __NO_ISOCEXT
-#ifndef isnan
-#define isnan(x) _isnan(x)
-#endif
-#ifndef finite
-#define finite(x) _finite(x)
-#endif
-#ifndef copysign
-#define copysign(a, b) _copysign(a, b)
-#endif
-#ifndef scalb
-#define scalb(a, b) _scalb(a, b)
-#endif
-#endif
-
-#if !defined S_IFIFO && defined _S_IFIFO
-#define S_IFIFO _S_IFIFO
-#endif
-
-#if 0 && defined __BORLANDC__
-#undef S_ISDIR
-#undef S_ISFIFO
-#undef S_ISBLK
-#undef S_ISCHR
-#undef S_ISREG
-#define S_ISDIR(m) (((unsigned short)(m) & S_IFMT) == S_IFDIR)
-#define S_ISFIFO(m) (((unsigned short)(m) & S_IFMT) == S_IFIFO)
-#define S_ISBLK(m) (((unsigned short)(m) & S_IFMT) == S_IFBLK)
-#define S_ISCHR(m) (((unsigned short)(m) & S_IFMT) == S_IFCHR)
-#define S_ISREG(m) (((unsigned short)(m) & S_IFMT) == S_IFREG)
-#endif
-
-#if !defined S_IRUSR && !defined __MINGW32__
-#define S_IRUSR 0400
-#endif
-#ifndef S_IRGRP
-#define S_IRGRP 0040
-#endif
-#ifndef S_IROTH
-#define S_IROTH 0004
-#endif
-
-#if !defined S_IWUSR && !defined __MINGW32__
-#define S_IWUSR 0200
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 0020
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 0002
-#endif
-
-#if !defined S_IXUSR && !defined __MINGW32__
-#define S_IXUSR 0100
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0010
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0001
-#endif
-
-//
-// define this so we can do inplace editing
-//
-
-#define SUFFIX
-extern int truncate(const char *path, off_t length);
-extern int ftruncate(int fd, off_t length);
-extern int fseeko(FILE *stream, off_t offset, int whence);
-extern off_t ftello(FILE *stream);
-
-//
-// stubs
-//
-extern int ioctl (int, int, ...);
-extern rb_uid_t getuid (void);
-extern rb_uid_t geteuid (void);
-extern rb_gid_t getgid (void);
-extern rb_gid_t getegid (void);
-extern int setuid (rb_uid_t);
-extern int setgid (rb_gid_t);
-
-extern char *rb_w32_strerror(int);
-
-#ifdef RUBY_EXPORT
-#define strerror(e) rb_w32_strerror(e)
-#endif
-
-#define PIPE_BUF 1024
-
-#define LOCK_SH 1
-#define LOCK_EX 2
-#define LOCK_NB 4
-#define LOCK_UN 8
-
-
-#ifndef SIGINT
-#define SIGINT 2
-#endif
-#ifndef SIGKILL
-#define SIGKILL 9
-#endif
-
-
-/* #undef va_start */
-/* #undef va_end */
-
-/* winsock error map */
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#define EINPROGRESS WSAEINPROGRESS
-#define EALREADY WSAEALREADY
-#define ENOTSOCK WSAENOTSOCK
-#define EDESTADDRREQ WSAEDESTADDRREQ
-#define EMSGSIZE WSAEMSGSIZE
-#define EPROTOTYPE WSAEPROTOTYPE
-#define ENOPROTOOPT WSAENOPROTOOPT
-#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
-#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
-#define EOPNOTSUPP WSAEOPNOTSUPP
-#define EPFNOSUPPORT WSAEPFNOSUPPORT
-#define EAFNOSUPPORT WSAEAFNOSUPPORT
-#define EADDRINUSE WSAEADDRINUSE
-#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
-#define ENETDOWN WSAENETDOWN
-#define ENETUNREACH WSAENETUNREACH
-#define ENETRESET WSAENETRESET
-#define ECONNABORTED WSAECONNABORTED
-#define ECONNRESET WSAECONNRESET
-#define ENOBUFS WSAENOBUFS
-#define EISCONN WSAEISCONN
-#define ENOTCONN WSAENOTCONN
-#define ESHUTDOWN WSAESHUTDOWN
-#define ETOOMANYREFS WSAETOOMANYREFS
-#define ETIMEDOUT WSAETIMEDOUT
-#define ECONNREFUSED WSAECONNREFUSED
-#define ELOOP WSAELOOP
-/*#define ENAMETOOLONG WSAENAMETOOLONG*/
-#define EHOSTDOWN WSAEHOSTDOWN
-#define EHOSTUNREACH WSAEHOSTUNREACH
-/*#define ENOTEMPTY WSAENOTEMPTY*/
-#define EPROCLIM WSAEPROCLIM
-#define EUSERS WSAEUSERS
-#define EDQUOT WSAEDQUOT
-#define ESTALE WSAESTALE
-#define EREMOTE WSAEREMOTE
-
-#define F_SETFL 1
-#define O_NONBLOCK 1
-
-#undef FD_SET
-#define FD_SET(f, s) rb_w32_fdset(f, s)
-
-#undef FD_CLR
-#define FD_CLR(f, s) rb_w32_fdclr(f, s)
-
-#undef FD_ISSET
-#define FD_ISSET(f, s) rb_w32_fdisset(f, s)
-
-#ifdef RUBY_EXPORT
-#undef accept
-#define accept(s, a, l) rb_w32_accept(s, a, l)
-
-#undef bind
-#define bind(s, a, l) rb_w32_bind(s, a, l)
-
-#undef connect
-#define connect(s, a, l) rb_w32_connect(s, a, l)
-
-#undef select
-#define select(n, r, w, e, t) rb_w32_select(n, r, w, e, t)
-
-#undef getpeername
-#define getpeername(s, a, l) rb_w32_getpeername(s, a, l)
-
-#undef getsockname
-#define getsockname(s, a, l) rb_w32_getsockname(s, a, l)
-
-#undef getsockopt
-#define getsockopt(s, v, n, o, l) rb_w32_getsockopt(s, v, n, o, l)
-
-#undef ioctlsocket
-#define ioctlsocket(s, c, a) rb_w32_ioctlsocket(s, c, a)
-
-#undef listen
-#define listen(s, b) rb_w32_listen(s, b)
-
-#undef recv
-#define recv(s, b, l, f) rb_w32_recv(s, b, l, f)
-
-#undef recvfrom
-#define recvfrom(s, b, l, f, fr, frl) rb_w32_recvfrom(s, b, l, f, fr, frl)
-
-#undef send
-#define send(s, b, l, f) rb_w32_send(s, b, l, f)
-
-#undef sendto
-#define sendto(s, b, l, f, t, tl) rb_w32_sendto(s, b, l, f, t, tl)
-
-#undef setsockopt
-#define setsockopt(s, v, n, o, l) rb_w32_setsockopt(s, v, n, o, l)
-
-#undef shutdown
-#define shutdown(s, h) rb_w32_shutdown(s, h)
-
-#undef socket
-#define socket(s, t, p) rb_w32_socket(s, t, p)
-
-#undef gethostbyaddr
-#define gethostbyaddr(a, l, t) rb_w32_gethostbyaddr(a, l, t)
-
-#undef gethostbyname
-#define gethostbyname(n) rb_w32_gethostbyname(n)
-
-#undef gethostname
-#define gethostname(n, l) rb_w32_gethostname(n, l)
-
-#undef getprotobyname
-#define getprotobyname(n) rb_w32_getprotobyname(n)
-
-#undef getprotobynumber
-#define getprotobynumber(n) rb_w32_getprotobynumber(n)
-
-#undef getservbyname
-#define getservbyname(n, p) rb_w32_getservbyname(n, p)
-
-#undef getservbyport
-#define getservbyport(p, pr) rb_w32_getservbyport(p, pr)
-
-#undef socketpair
-#define socketpair(a, t, p, s) rb_w32_socketpair(a, t, p, s)
-
-#undef get_osfhandle
-#define get_osfhandle(h) rb_w32_get_osfhandle(h)
-
-#undef getcwd
-#define getcwd(b, s) rb_w32_getcwd(b, s)
-
-#undef getenv
-#define getenv(n) rb_w32_getenv(n)
-
-#undef rename
-#define rename(o, n) rb_w32_rename(o, n)
-
-#undef times
-#define times(t) rb_w32_times(t)
-#endif
-
-struct tms {
- long tms_utime;
- long tms_stime;
- long tms_cutime;
- long tms_cstime;
-};
-
-int rb_w32_times(struct tms *);
-
-/* thread stuff */
-HANDLE GetCurrentThreadHandle(void);
-int rb_w32_sleep(unsigned long msec);
-int rb_w32_putc(int, FILE*);
-int rb_w32_getc(FILE*);
-int rb_w32_close(int);
-int rb_w32_fclose(FILE*);
-size_t rb_w32_read(int, void *, size_t);
-size_t rb_w32_write(int, const void *, size_t);
-int rb_w32_utime(const char *, const struct utimbuf *);
-int WINAPI rb_w32_Sleep(unsigned long msec);
-
-/*
-== ***CAUTION***
-Since this function is very dangerous, ((*NEVER*))
-* lock any HANDLEs(i.e. Mutex, Semaphore, CriticalSection and so on) or,
-* use anything like TRAP_BEG...TRAP_END block structure,
-in asynchronous_func_t.
-*/
-typedef uintptr_t (*asynchronous_func_t)(uintptr_t self, int argc, uintptr_t* argv);
-uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc, uintptr_t* argv, uintptr_t intrval);
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
-
-#endif /* RUBY_WIN32_H */
diff --git a/include/rubyio.h b/include/rubyio.h
deleted file mode 100644
index f385058c44..0000000000
--- a/include/rubyio.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <ruby/io.h>
diff --git a/include/rubysig.h b/include/rubysig.h
deleted file mode 100644
index cc8cdb2f6d..0000000000
--- a/include/rubysig.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <ruby/signal.h>
diff --git a/inits.c b/inits.c
index 04a67731e5..947bbbe242 100644
--- a/inits.c
+++ b/inits.c
@@ -6,70 +6,60 @@
$Date$
created at: Tue Dec 28 16:01:58 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
-void Init_Array(void);
-void Init_Bignum(void);
-void Init_Binding(void);
-void Init_Comparable(void);
-void Init_transcode(void);
-void Init_Dir(void);
-void Init_Enumerable(void);
-void Init_Enumerator(void);
-void Init_Exception(void);
-void Init_syserr(void);
-void Init_eval(void);
-void Init_load(void);
-void Init_Proc(void);
-void Init_File(void);
-void Init_GC(void);
-void Init_Hash(void);
-void Init_IO(void);
-void Init_Math(void);
-void Init_marshal(void);
-void Init_Numeric(void);
-void Init_Object(void);
-void Init_pack(void);
-void Init_Precision(void);
-void Init_sym(void);
-void Init_id(void);
-void Init_process(void);
-void Init_Random(void);
-void Init_Range(void);
-void Init_Regexp(void);
-void Init_signal(void);
-void Init_String(void);
-void Init_Struct(void);
-void Init_Time(void);
-void Init_var_tables(void);
-void Init_version(void);
-void Init_ISeq(void);
-void Init_VM(void);
-void Init_Thread(void);
-void Init_Cont(void);
-void Init_top_self(void);
-void Init_Encoding(void);
+void Init_Array _((void));
+void Init_Bignum _((void));
+void Init_Binding _((void));
+void Init_Comparable _((void));
+void Init_Dir _((void));
+void Init_Enumerable _((void));
+void Init_Enumerator _((void));
+void Init_Exception _((void));
+void Init_syserr _((void));
+void Init_eval _((void));
+void Init_load _((void));
+void Init_Proc _((void));
+void Init_Thread _((void));
+void Init_File _((void));
+void Init_GC _((void));
+void Init_Hash _((void));
+void Init_IO _((void));
+void Init_Math _((void));
+void Init_marshal _((void));
+void Init_Numeric _((void));
+void Init_Object _((void));
+void Init_pack _((void));
+void Init_Precision _((void));
+void Init_sym _((void));
+void Init_process _((void));
+void Init_Random _((void));
+void Init_Range _((void));
+void Init_Regexp _((void));
+void Init_signal _((void));
+void Init_String _((void));
+void Init_Struct _((void));
+void Init_Time _((void));
+void Init_var_tables _((void));
+void Init_version _((void));
void
rb_call_inits()
{
Init_sym();
- Init_id();
Init_var_tables();
Init_Object();
- Init_top_self();
- Init_Encoding();
Init_Comparable();
Init_Enumerable();
Init_Precision();
+ Init_eval();
Init_String();
Init_Exception();
- Init_eval();
- Init_jump();
+ Init_Thread();
Init_Numeric();
Init_Bignum();
Init_syserr();
@@ -78,8 +68,6 @@ rb_call_inits()
Init_Struct();
Init_Regexp();
Init_pack();
- Init_transcode();
- Init_marshal();
Init_Range();
Init_IO();
Init_Dir();
@@ -93,9 +81,6 @@ rb_call_inits()
Init_Math();
Init_GC();
Init_Enumerator();
- Init_VM();
- Init_ISeq();
- Init_Thread();
- Init_Cont();
+ Init_marshal();
Init_version();
}
diff --git a/insnhelper.h b/insnhelper.h
deleted file mode 100644
index 574c5e00b4..0000000000
--- a/insnhelper.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/**********************************************************************
-
- insnhelper.h - helper macros to implement each instructions
-
- $Author$
- $Date$
- created at: 04/01/01 15:50:34 JST
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#ifndef _INSNHELPER_H_INCLUDED_
-#define _INSNHELPER_H_INCLUDED_
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "eval_intern.h"
-#include "vm_core.h"
-#include "vm.h"
-
-/**********************************************************/
-/* deal with stack */
-/**********************************************************/
-
-#define PUSH(x) (SET_SV(x), INC_SP(1))
-#define TOPN(n) (*(GET_SP()-(n)-1))
-#define POPN(n) (DEC_SP(n))
-#define POP() (DEC_SP(1))
-#define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
-
-#define GET_TOS() (tos) /* dummy */
-
-/**********************************************************/
-/* deal with registers */
-/**********************************************************/
-
-#define REG_CFP (reg_cfp)
-#define REG_PC (REG_CFP->pc)
-#define REG_SP (REG_CFP->sp)
-#define REG_LFP (REG_CFP->lfp)
-#define REG_DFP (REG_CFP->dfp)
-
-#define RESTORE_REGS() do { \
- REG_CFP = th->cfp; \
-} while (0)
-
-#define REG_A reg_a
-#define REG_B reg_b
-
-#ifdef COLLECT_USAGE_ANALYSIS
-#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) \
- (USAGE_ANALYSIS_REGISTER(a, b), (v))
-#else
-#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) (v)
-#endif
-
-/* PC */
-#define GET_PC() (USAGE_ANALYSIS_REGISTER_HELPER(0, 0, REG_PC))
-#define SET_PC(x) (REG_PC = (USAGE_ANALYSIS_REGISTER_HELPER(0, 1, x)))
-#define GET_CURRENT_INSN() (*GET_PC())
-#define GET_OPERAND(n) (GET_PC()[(n)])
-#define ADD_PC(n) (SET_PC(REG_PC + (n)))
-
-#define GET_PC_COUNT() (REG_PC - GET_ISEQ()->iseq_encoded)
-#define JUMP(dst) (REG_PC += (dst))
-
-/* FP */
-#define GET_CFP() (USAGE_ANALYSIS_REGISTER_HELPER(2, 0, REG_CFP))
-#define GET_LFP() (USAGE_ANALYSIS_REGISTER_HELPER(3, 0, REG_LFP))
-#define SET_LFP(x) (REG_LFP = (USAGE_ANALYSIS_REGISTER_HELPER(3, 1, (x))))
-#define GET_DFP() (USAGE_ANALYSIS_REGISTER_HELPER(4, 0, REG_DFP))
-#define SET_DFP(x) (REG_DFP = (USAGE_ANALYSIS_REGISTER_HELPER(4, 1, (x))))
-
-/* SP */
-#define GET_SP() (USAGE_ANALYSIS_REGISTER_HELPER(1, 0, REG_SP))
-#define SET_SP(x) (REG_SP = (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
-#define INC_SP(x) (REG_SP += (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
-#define DEC_SP(x) (REG_SP -= (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
-#define SET_SV(x) (*GET_SP() = (x))
- /* set current stack value as x */
-
-#define GET_SP_COUNT() (REG_SP - th->stack)
-
-/* instruction sequence C struct */
-#define GET_ISEQ() (GET_CFP()->iseq)
-
-/**********************************************************/
-/* deal with variables */
-/**********************************************************/
-
-#define GET_PREV_DFP(dfp) ((VALUE *)((dfp)[0] & ~0x03))
-
-#define GET_GLOBAL(entry) rb_gvar_get((struct global_entry*)entry)
-#define SET_GLOBAL(entry, val) rb_gvar_set((struct global_entry*)entry, val)
-
-#define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 1))
-
-/**********************************************************/
-/* deal with values */
-/**********************************************************/
-
-#define GET_SELF() (USAGE_ANALYSIS_REGISTER_HELPER(5, 0, GET_CFP()->self))
-
-/**********************************************************/
-/* deal with control flow 2: method/iterator */
-/**********************************************************/
-
-#define COPY_CREF(c1, c2) do { \
- NODE *__tmp_c2 = (c2); \
- c1->nd_clss = __tmp_c2->nd_clss; \
- c1->nd_visi = __tmp_c2->nd_visi; \
- c1->nd_next = __tmp_c2->nd_next; \
-} while (0)
-
-#define CALL_METHOD(num, blockptr, flag, id, mn, recv, klass) do { \
- VALUE v = vm_call_method(th, GET_CFP(), num, blockptr, flag, id, mn, recv, klass); \
- if (v == Qundef) { \
- RESTORE_REGS(); \
- NEXT_INSN(); \
- } \
- else { \
- val = v; \
- } \
-} while (0)
-
-#define GET_BLOCK_PTR() \
- ((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0])))
-
-/**********************************************************/
-/* deal with control flow 3: exception */
-/**********************************************************/
-
-
-/**********************************************************/
-/* others */
-/**********************************************************/
-
-/* optimize insn */
-#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
-#define BASIC_OP_UNREDEFINED_P(op) ((ruby_vm_redefined_flag & (op)) == 0)
-#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
-
-#define CALL_SIMPLE_METHOD(num, id, recv) do { \
- VALUE klass = CLASS_OF(recv); \
- CALL_METHOD(num, 0, 0, id, rb_method_node(klass, id), recv, CLASS_OF(recv)); \
-} while (0)
-
-#endif /* _INSNHELPER_H_INCLUDED_ */
diff --git a/insns.def b/insns.def
deleted file mode 100644
index e0d997b834..0000000000
--- a/insns.def
+++ /dev/null
@@ -1,2086 +0,0 @@
-/** ##skip -*- mode:c; style:ruby -*-
- insns.def - YARV instruction definitions
-
- $Author: $
- $Date: $
- created at: 04/01/01 01:17:55 JST
-
- Copyright (C) 2004-2007 Koichi Sasada
-*/
-
-/** ##skip
- instruction comment
- @c: category
- @e: english description
- @j: japanese description
-
- instruction form:
- DEFINE_INSN
- instrunction_name
- (instruction_operands, ..)
- (pop_values, ..)
- (return value)
- {
- .. // insn body
- }
-
- */
-
-
-/**
- @c nop
- @e nop
- @j nop
- */
-DEFINE_INSN
-nop
-()
-()
-()
-{
- /* none */
-}
-
-/**********************************************************/
-/* deal with variables */
-/**********************************************************/
-
-/**
- @c variable
- @e get local variable value (which is pointed by idx).
- @j idx ‚ÅŽw’肳‚ꂽƒ[ƒJƒ‹•Ï”‚ðƒXƒ^ƒbƒN‚É’u‚­B
- */
-DEFINE_INSN
-getlocal
-(lindex_t idx)
-()
-(VALUE val)
-{
- val = *(GET_LFP() - idx);
-}
-
-/**
- @c variable
- @e set local variable value (which is pointed by idx) as val.
- @j idx ‚ÅŽw’肳‚ꂽƒ[ƒJƒ‹•Ï”‚ð val ‚ÉÝ’è‚·‚éB
- */
-DEFINE_INSN
-setlocal
-(lindex_t idx)
-(VALUE val)
-()
-{
- (*(GET_LFP() - idx)) = val;
-}
-
-/**
- @c variable
- @e get special local variable ($~, $_, ..) value.
- @j “ÁŽê‚ȃ[ƒJƒ‹•Ï”i$~, $_, ...j‚Ì’l‚𓾂éB
- */
-DEFINE_INSN
-getspecial
-(VALUE key, rb_num_t type)
-()
-(VALUE val)
-{
- val = vm_getspecial(th, GET_LFP(), key, type);
-}
-
-/**
- @c variable
- @e set special local variable ($~, $_, ...) value as obj.
- @j “Á•ʂȃ[ƒJƒ‹•Ï”i$~, $_, ...j‚Ì’l‚ð‚ðÝ’è‚·‚éB
- */
-DEFINE_INSN
-setspecial
-(VALUE key)
-(VALUE obj)
-()
-{
- lfp_svar_set(th, GET_LFP(), key, obj);
-}
-
-/**
- @c variable
- @e get block local variable(which is pointed by idx and level).
- level means nest level of block, and specify how above this variable.
- @j level, idx ‚ÅŽw’肳‚ꂽƒuƒƒbƒNƒ[ƒJƒ‹•Ï”‚Ì’l‚ðƒXƒ^ƒbƒN‚É’u‚­B
- level ‚̓uƒƒbƒN‚̃lƒXƒgƒŒƒxƒ‹‚ÅA‰½’iã‚©‚ðŽ¦‚·B
- */
-DEFINE_INSN
-getdynamic
-(dindex_t idx, rb_num_t level)
-()
-(VALUE val)
-{
- int i;
- VALUE *dfp2 = GET_DFP();
- for (i = 0; i < level; i++) {
- dfp2 = GET_PREV_DFP(dfp2);
- }
- val = *(dfp2 - idx);
-}
-
-/**
- @c variable
- @e set block local variable(which is pointed by 'idx') as val.
- level means nest level of block, and specify how above this variable.
- @j level, idx ‚ÅŽw’肳‚ꂽƒuƒƒbƒNƒ[ƒJƒ‹•Ï”‚Ì’l‚ð val ‚É‚·‚éB
- level ‚̓uƒƒbƒN‚̃lƒXƒgƒŒƒxƒ‹‚ÅA‰½’iã‚©‚ðŽ¦‚·B
- */
-DEFINE_INSN
-setdynamic
-(dindex_t idx, rb_num_t level)
-(VALUE val)
-()
-{
- int i;
- VALUE *dfp2 = GET_DFP();
- for (i = 0; i < level; i++) {
- dfp2 = GET_PREV_DFP(dfp2);
- }
- *(dfp2 - idx) = val;
-}
-
-/**
- @c variable
- @e get instance variable id of obj.
- if is_local is not 0, search as class local variable.
- @j self ‚̃Cƒ“ƒXƒ^ƒ“ƒX•Ï” id ‚Ì’l‚𓾂éB
- */
-DEFINE_INSN
-getinstancevariable
-(ID id)
-()
-(VALUE val)
-{
- val = rb_ivar_get(GET_SELF(), id);
-}
-
-/**
- @c variable
- @e set instance variable id of obj as val.
- if is_local is not 0, search as class local variable.
- @j self ‚̃Cƒ“ƒXƒ^ƒ“ƒX•Ï” id ‚ð val ‚É‚·‚éB
- */
-DEFINE_INSN
-setinstancevariable
-(ID id)
-(VALUE val)
-()
-{
- rb_ivar_set(GET_SELF(), id, val);
-}
-
-/**
- @c variable
- @e get class variable id of klass as val.
- @j Œ»Ý‚̃XƒR[ƒv‚̃Nƒ‰ƒX•Ï” id ‚Ì’l‚𓾂éB
- */
-DEFINE_INSN
-getclassvariable
-(ID id)
-()
-(VALUE val)
-{
- val = rb_cvar_get(vm_get_cvar_base(th, GET_ISEQ()), id);
-}
-
-/**
- @c variable
- @e set class variable id of klass as val.
- @j klass ‚̃Nƒ‰ƒX•Ï” id ‚ð val ‚É‚·‚éB
- */
-DEFINE_INSN
-setclassvariable
-(ID id)
-(VALUE val)
-()
-{
- rb_cvar_set(vm_get_cvar_base(th, GET_ISEQ()), id, val);
-}
-
-/**
- @c variable
- @e
- get constant variable id. if klass is Qnil, constant
- are searched in current scope. if klass is Qfalse, constant as
- top level constant. otherwise, get constant under klass
- class or module.
- @j ’è” id ‚Ì’l‚𓾂éB
- klass ‚ª Qnil ‚È‚çA‚»‚̃XƒR[ƒv‚Å“¾‚ç‚ê‚é’蔂̒l‚𓾂éB
- Qfalse ‚È‚çAƒgƒbƒvƒŒƒxƒ‹ƒXƒR[ƒv‚𓾂éB
- ‚»‚êˆÈŠO‚È‚çAklass ƒNƒ‰ƒX‚̉º‚̒蔂𓾂éB
- */
-DEFINE_INSN
-getconstant
-(ID id)
-(VALUE klass)
-(VALUE val)
-{
- val = vm_get_ev_const(th, GET_ISEQ(), klass, id, 0);
-}
-
-/**
- @c variable
- @e
- set constant variable id. if klass is Qfalse, constant
- is able to access in this scope. if klass is Qnil, set
- top level constant. otherwise, set constant under klass
- class or module.
-
- @j ’è” id ‚Ì’l‚ð val ‚É‚·‚éB
- klass ‚ª Qfalse ‚È‚çA‚»‚̃XƒR[ƒv‚Å“¾‚ç‚ê‚é’è” id ‚Ì’l‚ðÝ’è‚·‚éB
- Qnil ‚È‚çAƒgƒbƒvƒŒƒxƒ‹ƒXƒR[ƒv‚Ì’l‚ðÝ’è‚·‚éB
- ‚»‚êˆÈŠO‚È‚çAklass ƒNƒ‰ƒX‚̉º‚̒蔂ðÝ’è‚·‚éB
- */
-DEFINE_INSN
-setconstant
-(ID id)
-(VALUE val, VALUE klass)
-()
-{
- if (klass == Qnil) {
- klass = vm_get_cbase(th);
- }
- if (NIL_P(klass)) {
- rb_raise(rb_eTypeError, "no class/module to define constant");
- }
-
- switch (TYPE(klass)) {
- case T_CLASS:
- case T_MODULE:
- break;
- default: {
- volatile VALUE tmp = rb_obj_as_string(klass);
- rb_raise(rb_eTypeError, "%s is not a class/module",
- RSTRING_PTR(tmp));
- }
- }
-
- rb_const_set(klass, id, val);
- INC_VM_STATE_VERSION();
-}
-
-/**
- @c variable
- @e get global variable id.
- @j ƒOƒ[ƒoƒ‹•Ï” id ‚Ì’l‚𓾂éB
- */
-DEFINE_INSN
-getglobal
-(GENTRY entry)
-()
-(VALUE val)
-{
- val = GET_GLOBAL(entry);
-}
-
-/**
- @c variable
- @e set global variable id as val.
- @j ƒOƒ[ƒoƒ‹•Ï” id ‚Ì’l‚ðÝ’è‚·‚éB
- */
-DEFINE_INSN
-setglobal
-(GENTRY entry)
-(VALUE val)
-()
-{
- SET_GLOBAL(entry, val);
-}
-
-
-/**********************************************************/
-/* deal with values */
-/**********************************************************/
-
-/**
- @c put
- @e put nil to stack.
- @j ƒXƒ^ƒbƒN‚É nil ‚ðƒvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-putnil
-()
-()
-(VALUE val)
-{
- val = Qnil;
-}
-
-/**
- @c put
- @e put self.
- @j ƒXƒ^ƒbƒN‚É self ‚ðƒvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-putself
-()
-()
-(VALUE val)
-{
- val = GET_SELF();
-}
-
-/**
- @c put
- @e put some object.
- i.e. Fixnum, true, false, nil, and so on.
- @j ƒIƒuƒWƒFƒNƒg val ‚ðƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- i.e. Fixnum, true, false, nil, and so on.
- */
-DEFINE_INSN
-putobject
-(VALUE val)
-()
-(VALUE val)
-{
- /* */
-}
-
-/**
- @c put
- @e put string val. string will be copied.
- @j •¶Žš—ñ‚ð‚ðƒRƒs[‚µ‚ăXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-putstring
-(VALUE str)
-()
-(VALUE val)
-{
- val = rb_str_new3(str);
-}
-
-/**
- @c put
- @e put concatenate strings
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚Ì•¶Žš—ñ‚ð n ŒÂ˜AŒ‹‚µCŒ‹‰Ê‚ðƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-concatstrings
-(rb_num_t num)
-(...)
-(VALUE val) // inc += 1 - num;
-{
- int i;
- VALUE v;
-
- val = rb_str_new(0, 0);
- for (i = num - 1; i >= 0; i--) {
- v = TOPN(i);
- rb_str_append(val, v);
- }
- POPN(num);
-}
-
-/**
- @c put
- @e to_str
- @j to_str ‚ÌŒ‹‰Ê‚ðƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-tostring
-()
-(VALUE val)
-(VALUE val)
-{
- val = rb_obj_as_string(val);
-}
-
-/**
- @c put
- @e to Regexp
- @j •¶Žš—ñ str ‚ð³‹K•\Œ»‚ɃRƒ“ƒpƒCƒ‹‚µ‚ăXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- ƒRƒ“ƒpƒCƒ‹ŽžCopt ‚ð³‹K•\Œ»‚̃IƒvƒVƒ‡ƒ“‚Æ‚·‚éB
- */
-DEFINE_INSN
-toregexp
-(rb_num_t opt)
-(VALUE str)
-(VALUE val)
-{
- volatile VALUE tmp = str; /* for GC */
- val = rb_reg_new(str, opt);
-}
-
-/**
- @c put
- @e put new array.
- @j V‚µ‚¢”z—ñ‚ðƒXƒ^ƒbƒNã‚Ì num ŒÂ‚Ì’l‚ʼnŠú‰»‚µ‚ͬ‚µƒvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-newarray
-(rb_num_t num)
-(...)
-(VALUE val) // inc += 1 - num;
-{
- val = rb_ary_new4((long)num, STACK_ADDR_FROM_TOP(num));
- POPN(num);
-}
-
-/**
- @c put
- @e dup array
- @j ”z—ñ ary ‚ð dup ‚µ‚ăXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-duparray
-(VALUE ary)
-()
-(VALUE val)
-{
- val = rb_ary_dup(ary);
-}
-
-/**
- @c put
- @e expand array to num objects.
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚̃IƒuƒWƒFƒNƒg‚ª”z—ñ‚Å‚ ‚ê‚ÎA‚»‚ê‚ð“WŠJ‚·‚éB
- ”z—ñƒIƒuƒWƒFƒNƒg‚Ì—v‘f”‚ª numˆÈ‰º‚È‚ç‚ÎA‘ã‚í‚è‚É nil ‚ðÏ‚ÞBnumˆÈã‚È‚çA
- numˆÈã‚Ì—v‘f‚ÍØ‚èŽÌ‚Ä‚éB
- ”z—ñƒIƒuƒWƒFƒNƒg‚łȂ¯‚ê‚ÎAnum - 1 ŒÂ‚Ì nil ‚ðÏ‚ÞB
- ‚à‚µ flag ‚ª^‚È‚çAŽc‚è—v‘f‚Ì”z—ñ‚ðÏ‚Þ
- flag: 0x01 - ÅŒã‚ð”z—ñ‚É
- flag: 0x02 - postarg —p
- flag: 0x04 - reverse?
- */
-DEFINE_INSN
-expandarray
-(rb_num_t num, rb_num_t flag)
-(..., VALUE ary)
-(...) // inc += flag == 0x02 ? num : ((num > 0) ? num - 1 + (flag ? 1 : 0) : num + 1 - (flag ? 1 : 0));
-{
- vm_expandarray(GET_CFP(), ary, num, flag);
-}
-
-/**
- @c put
- @e concat two arrays
- @j “ñ‚‚̔z—ñ ary1, ary2 ‚ð˜AŒ‹‚µƒXƒ^ƒbƒN‚ÖƒvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-concatarray
-()
-(VALUE ary1, VALUE ary2st)
-(VALUE ary)
-{
- VALUE ary2 = ary2st;
- VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
- VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
-
- if (NIL_P(tmp1)) {
- tmp1 = rb_ary_new3(1, ary1);
- }
-
- if (NIL_P(tmp2)) {
- tmp2 = rb_ary_new3(1, ary2);
- }
-
- if (tmp1 == ary1) {
- tmp1 = rb_ary_dup(ary1);
- }
- ary = rb_ary_concat(tmp1, tmp2);
-}
-
-/**
- @c put
- @e splat array
- @j ”z—ñ ary ‚ɑ΂µ‚Ä to_a ‚ðŒÄ‚Ño‚·B
- */
-DEFINE_INSN
-splatarray
-(VALUE flag)
-(VALUE ary)
-(VALUE obj)
-{
- VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a");
- if (NIL_P(tmp)) {
- tmp = rb_ary_new3(1, ary);
- }
- obj = tmp;
-}
-
-/**
- @c put
- @e check value is included in ary
- @j ”z—ñ ary ‚É—v‘f obj ‚ª“ü‚Á‚Ä‚¢‚é‚©‚Ç‚¤‚©ƒ`ƒFƒbƒNBcase/when ‚Å—˜—p‚·‚éB
- */
-DEFINE_INSN
-checkincludearray
-(VALUE flag)
-(VALUE obj, VALUE ary)
-(VALUE obj, VALUE result)
-{
- int i;
- result = Qfalse;
-
- if (TYPE(ary) != T_ARRAY) {
- ary = rb_Array(ary);
- }
-
- if (flag == Qtrue) {
- /* NODE_CASE */
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- /* TODO: fix me (use another method dispatch) */
- if (RTEST(rb_funcall2(RARRAY_PTR(ary)[i], idEqq, 1, &obj))) {
- result = Qtrue;
- break;
- }
- }
- }
- else {
- obj = Qfalse;
- /* NODE_WHEN */
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- if (RTEST(RARRAY_PTR(ary)[i])) {
- obj = result = Qtrue;
- break;
- }
- }
- }
-}
-
-/**
- @c put
- @e put new Hash.
- @j V‚µ‚¢ƒnƒbƒVƒ…‚ðƒXƒ^ƒbƒNƒgƒbƒv‚Ì n ŒÂ‚ð‰Šú’l‚Æ‚µ‚ͬ‚·‚éB
- n ‚̓L[‚Æ’l‚̃yƒA‚Ȃ̂Š2 ‚Ì”{”‚łȂ¯‚ê‚΂Ȃç‚È‚¢B
- */
-DEFINE_INSN
-newhash
-(rb_num_t num)
-(...)
-(VALUE val) // inc += 1 - num;
-{
- int i;
- VALUE k, v;
- val = rb_hash_new();
-
- for (i = num; i > 0; i -= 2) {
- v = TOPN(i - 2);
- k = TOPN(i - 1);
- rb_hash_aset(val, k, v);
- }
- POPN(num);
-}
-
-/**
- @c put
- @e put new Range object.(Range.new(low, high, flag))
- @j Range.new(low, high, flag) ‚̂悤‚ȃIƒuƒWƒFƒNƒg‚𶬂µƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-newrange
-(rb_num_t flag)
-(VALUE low, VALUE high)
-(VALUE val)
-{
- val = rb_range_new(low, high, flag);
-}
-
-/**********************************************************/
-/* deal with stack operation */
-/**********************************************************/
-
-/**
- @c stack
- @e pop from stack.
- @j ƒXƒ^ƒbƒN‚©‚çˆê‚ƒ|ƒbƒv‚·‚éB
- */
-DEFINE_INSN
-pop
-()
-(VALUE val)
-()
-{
- val = val;
- /* none */
-}
-
-/**
- @c stack
- @e duplicate stack top.
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚ðƒRƒs[‚µ‚ăXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-dup
-()
-(VALUE val)
-(VALUE val1, VALUE val2)
-{
- val1 = val2 = val;
-}
-
-/**
- @c stack
- @e duplicate stack top n elements
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚Ì n ŒÂ‚ðƒRƒs[‚µ‚ăXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-dupn
-(rb_num_t n)
-(...)
-(...) // inc += n;
-{
- int i;
- VALUE *sp = STACK_ADDR_FROM_TOP(n);
- for (i = 0; i < n; i++) {
- GET_SP()[i] = sp[i];
- }
- INC_SP(n);
-}
-
-
-/**
- @c stack
- @e swap top 2 vals
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚Ì 2 ‚‚̒l‚ðŒðŠ·‚·‚éB
- */
-DEFINE_INSN
-swap
-()
-(VALUE val, VALUE obj)
-(VALUE obj, VALUE val)
-{
- /* none */
-}
-
-/**
- @c stack
- @e for stack caching.
- @j ƒXƒ^ƒbƒNƒLƒƒƒbƒVƒ“ƒO‚Ìó‘Ô‚ð’²®‚·‚邽‚߂ɕK—v‚È–½—ßB
- */
-DEFINE_INSN
-reput
-()
-(..., VALUE val)
-(VALUE val) // inc += 0;
-{
- /* none */
-}
-
-/**
- @c stack
- @e get nth stack value from stack top
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚©‚ç n ŒÂ–Ú‚ðƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚éB
- */
-DEFINE_INSN
-topn
-(rb_num_t n)
-(...)
-(VALUE val) // inc += 1;
-{
- val = TOPN(n);
-}
-
-/**
- @c stack
- @e set Nth stack entry to stack top
- @j ƒXƒ^ƒbƒNƒgƒbƒv‚Ì’l‚ð n ŒÂ–ڂ̃Xƒ^ƒbƒN‚ɃRƒs[
- */
-DEFINE_INSN
-setn
-(rb_num_t n)
-(..., VALUE val)
-(VALUE val) // inc += 0
-{
- TOPN(n-1) = val;
-}
-
-/**
- @c stack
- @e empt current stack
- @j current stack ‚ð‹ó‚É‚·‚éB
- */
-DEFINE_INSN
-emptstack
-()
-(...)
-(...) // inc = 0; depth = 0;
-{
- SET_SP(GET_CFP()->bp);
-}
-
-
-/**********************************************************/
-/* deal with setting */
-/**********************************************************/
-
-/**
- @c setting
- @e define (singleton) method id as body
- @j i“ÁˆÙjƒƒ\ƒbƒh id ‚ð body ‚Æ‚µ‚Ä’è‹`‚·‚éB
- */
-DEFINE_INSN
-definemethod
-(ID id, ISEQ body, rb_num_t is_singleton)
-(VALUE obj)
-()
-{
- vm_define_method(th, obj, id, body, is_singleton,
- get_cref(GET_ISEQ(), GET_LFP()));
-}
-
-/**
- @c setting
- @e make alias (if v_p is Qtrue, make valias)
- @j alias ‚ðì‚éB‚à‚µ v_p ‚ª Qtrue ‚È‚çAvalias (global variable) ‚ðì‚éB
- */
-DEFINE_INSN
-alias
-(VALUE v_p)
-(VALUE sym1, VALUE sym2)
-()
-{
- VALUE klass;
-
- if (v_p == Qtrue) {
- rb_alias_variable(SYM2ID(sym1), SYM2ID(sym2));
- }
- else {
- klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
- rb_alias(klass, SYM2ID(sym1), SYM2ID(sym2));
- }
-}
-
-/**
- @c setting
- @e undef
- @j undef ‚ðs‚¤B
- */
-DEFINE_INSN
-undef
-()
-(VALUE sym)
-()
-{
- VALUE klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
- rb_undef(klass, SYM2ID(sym));
- INC_VM_STATE_VERSION();
-}
-
-/**
- @c setting
- @e defined?
- @j defined? ‚ðs‚¤B
- */
-DEFINE_INSN
-defined
-(rb_num_t type, VALUE obj, VALUE needstr)
-(VALUE v)
-(VALUE val)
-{
- VALUE klass;
- char *expr_type = 0;
- val = Qnil;
-
- switch (type) {
- case DEFINED_IVAR:
- if (rb_ivar_defined(GET_SELF(), SYM2ID(obj))) {
- expr_type = "instance-variable";
- }
- break;
- case DEFINED_IVAR2:
- klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
- break;
- case DEFINED_GVAR:
- if (rb_gvar_defined((struct global_entry *)(obj & ~1))) {
- expr_type = "global-variable";
- }
- break;
- case DEFINED_CVAR:
- klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
- if (rb_cvar_defined(klass, SYM2ID(obj))) {
- expr_type = "class variable";
- }
- break;
- case DEFINED_CONST:
- klass = v;
- if (vm_get_ev_const(th, GET_ISEQ(), klass, SYM2ID(obj), 1)) {
- expr_type = "constant";
- }
- break;
- case DEFINED_FUNC:
- klass = CLASS_OF(v);
- if (rb_method_boundp(klass, SYM2ID(obj), 0)) {
- expr_type = "method";
- }
- break;
- case DEFINED_METHOD:{
- VALUE klass = CLASS_OF(v);
- NODE *method = (NODE *) rb_method_node(klass, SYM2ID(obj));
-
- if (method) {
- if (!(method->nd_noex & NOEX_PRIVATE)) {
- if (!((method->nd_noex & NOEX_PROTECTED) &&
- !rb_obj_is_kind_of(GET_SELF(),
- rb_class_real(klass)))) {
- expr_type = "method";
- }
- }
- }
- break;
- }
- case DEFINED_YIELD:
- if (GET_BLOCK_PTR()) {
- expr_type = "yield";
- }
- break;
- case DEFINED_ZSUPER:{
- rb_iseq_t *ip = GET_ISEQ();
- while (ip) {
- if (ip->defined_method_id) {
- break;
- }
- ip = ip->parent_iseq;
- }
- if (ip) {
- VALUE klass = vm_search_normal_superclass(ip->klass, GET_SELF());
- if (rb_method_boundp(klass, ip->defined_method_id, 0)) {
- expr_type = "super";
- }
- }
- break;
- }
- case DEFINED_REF:{
- val = vm_getspecial(th, GET_LFP(), Qfalse, FIX2INT(obj));
- if (val != Qnil) {
- expr_type = "global-variable";
- }
- break;
- }
- default:
- rb_bug("unimplemented defined? type (VM)");
- break;
- }
- if (expr_type != 0) {
- if (needstr != Qfalse) {
- val = rb_str_new2(expr_type);
- }
- else {
- val = Qtrue;
- }
- }
-}
-
-/**
- @c setting
- @e END{}
- @j END{} ‚ɑΉž‚·‚邽‚߂ɃuƒƒbƒN‚ð“o˜^‚·‚éB
- */
-DEFINE_INSN
-postexe
-(ISEQ blockiseq)
-()
-()
-{
- rb_block_t *blockptr;
- VALUE proc;
- extern void rb_call_end_proc(VALUE data);
-
- blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(GET_CFP());
- blockptr->iseq = blockiseq;
- blockptr->proc = 0;
-
- proc = vm_make_proc(th, GET_CFP(), blockptr);
- rb_set_end_proc(rb_call_end_proc, proc);
-}
-
-/**
- @c setting
- @e trace
- @j trace —p‚Ì–½—ßB
- */
-DEFINE_INSN
-trace
-(rb_num_t nf)
-()
-()
-{
- rb_event_flag_t flag = nf;
- EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
-}
-
-/**********************************************************/
-/* deal with control flow 1: class/module */
-/**********************************************************/
-
-/**
- @c class/module
- @e
- enter class definition scope. if super is Qfalse, and clsas
- "klass" is defined, it's redefine. otherwise, define "klass" class.
- @j ƒNƒ‰ƒX’è‹`ƒXƒR[ƒv‚ÖˆÚs‚·‚éB
- ‚à‚µ super ‚ª Qfalse ‚Å klassƒNƒ‰ƒX‚ª’è‹`‚³‚ê‚Ä‚¢‚ê‚ÎÄ’è‹`‚Å‚ ‚éB
- ‚»‚¤‚łȂ¯‚ê‚ÎAklass ƒNƒ‰ƒX‚ð’è‹`‚·‚éB
- */
-DEFINE_INSN
-defineclass
-(ID id, ISEQ class_iseq, rb_num_t define_type)
-(VALUE cbase, VALUE super)
-(VALUE val)
-{
- VALUE klass;
-
- switch ((int)define_type) {
- case 0:
- /* val is dummy. classdef returns class scope value */
-
- if (super == Qnil) {
- super = rb_cObject;
- }
-
- if (cbase == Qnil) {
- cbase = vm_get_cbase(th);
- }
-
- /* find klass */
- if (rb_const_defined_at(cbase, id)) {
- /* already exist */
- klass = rb_const_get_at(cbase, id);
- if (TYPE(klass) != T_CLASS) {
- rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
- }
-
- if (super != rb_cObject) {
- VALUE tmp;
- tmp = rb_class_real(RCLASS_SUPER(klass));
-
- if (tmp != super) {
- rb_raise(rb_eTypeError, "superclass mismatch for class %s",
- rb_id2name(id));
- }
- }
- }
- else {
- /* new class declaration */
- klass = rb_define_class_id(id, super);
- rb_set_class_path(klass, cbase, rb_id2name(id));
- rb_const_set(cbase, id, klass);
- rb_class_inherited(super, klass);
- }
- break;
- case 1:
- /* val is dummy. classdef returns class scope value */
- /* super is dummy */
- klass = rb_singleton_class(cbase);
- break;
- case 2:
- /* val is dummy. classdef returns class scope value */
- /* super is dummy */
- if (cbase == Qnil) {
- cbase = vm_get_cbase(th);
- }
-
- /* find klass */
- if (rb_const_defined_at(cbase, id)) {
- klass = rb_const_get_at(cbase, id);
- /* already exist */
- if (TYPE(klass) != T_MODULE) {
- rb_raise(rb_eTypeError, "%s is not a module", rb_id2name(id));
- }
- }
- else {
- /* new module declaration */
- klass = rb_define_module_id(id);
- rb_set_class_path(klass, cbase, rb_id2name(id));
- rb_const_set(cbase, id, klass);
- }
- break;
- default:
- rb_bug("unknown defineclass type: %d", (int)define_type);
- }
-
- COPY_CREF(class_iseq->cref_stack, vm_cref_push(th, klass, NOEX_PUBLIC));
-
- /* enter scope */
- vm_push_frame(th, class_iseq,
- FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
- class_iseq->iseq_encoded, GET_SP(), 0,
- class_iseq->local_size);
- RESTORE_REGS();
-
- INC_VM_STATE_VERSION();
- NEXT_INSN();
-}
-
-
-/**********************************************************/
-/* deal with control flow 2: method/iterator */
-/**********************************************************/
-
-/**
- @c method/iterator
- @e obj.send(id, args..) # args.size => num
- @j ƒƒ\ƒbƒhŒÄ‚Ño‚µ‚ðs‚¤B
- obj.send(id, args..) # args.size => num
- flag & VM_CALL_ARGS_SPLAT_BIT != 0 -> splat last arg
- flag & VM_CALL_ARGS_BLOCKARG_BIT != 0 -> Proc as Block
- flag & VM_CALL_FCALL_BIT != 0 -> FCALL ( func() )
- flag & VM_CALL_VCALL_BIT != 0 -> VCALL ( func )
- ...
- */
-DEFINE_INSN
-send
-(ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, IC ic)
-(...)
-(VALUE val) // inc += - (op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
-{
- NODE *mn;
- VALUE recv, klass;
- rb_block_t *blockptr = 0;
- rb_num_t num = caller_setup_args(th, GET_CFP(), op_flag, op_argc,
- (rb_iseq_t *)blockiseq, &blockptr);
- rb_num_t flag = op_flag;
- ID id = op_id;
-
- /* get receiver */
- recv = (flag & VM_CALL_FCALL_BIT) ? GET_SELF() : TOPN(num);
- klass = CLASS_OF(recv);
- mn = vm_method_search(id, klass, ic);
-
- /* send/funcall optimization */
- if (flag & VM_CALL_SEND_BIT) {
- vm_send_optimize(GET_CFP(), &mn, &flag, &num, &id, klass);
- }
-
- CALL_METHOD(num, blockptr, flag, id, mn, recv, klass);
-}
-
-/**
- @c method/iterator
- @e super(args) # args.size => num
- @j super ‚ðŽÀs‚·‚éB
- super(args) # args.size => num
- flag “™ƒIƒyƒ‰ƒ“ƒh‚̈Ӗ¡‚Í send ‚Æ“¯‚¶B
- */
-DEFINE_INSN
-invokesuper
-(rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag)
-(...)
-(VALUE val) // inc += - op_argc;
-{
- rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? GET_BLOCK_PTR() : 0;
- int num = caller_setup_args(th, GET_CFP(), op_flag, op_argc, blockiseq, &blockptr);
- VALUE recv, klass;
- NODE *mn;
- ID id;
- const VALUE flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
-
- recv = GET_SELF();
- vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
- mn = rb_method_node(klass, id);
-
- CALL_METHOD(num, blockptr, flag, id, mn, recv, klass);
-}
-
-/**
- @c method/iterator
- @e yield(args) # args.size => num, flag shows expand argument or not
- @j yield ‚ðŽÀs‚·‚éB
- yield(args) # args.size => num
- */
-DEFINE_INSN
-invokeblock
-(rb_num_t num, rb_num_t flag)
-(...)
-(VALUE val) // inc += 1 - num;
-{
- val = vm_invoke_block(th, GET_CFP(), num, flag);
- if (val == Qundef) {
- RESTORE_REGS();
- NEXT_INSN();
- }
-}
-
-/**
- @c method/iterator
- @e return from this scope.
- @j ‚±‚̃XƒR[ƒv‚©‚甲‚¯‚éB
- */
-DEFINE_INSN
-leave
-()
-(VALUE val)
-(VALUE val)
-{
- if (OPT_CHECKED_RUN) {
- if (reg_cfp->sp != reg_cfp->bp) {
- rb_bug("Stack consistency error (sp: %d, bp: %d)",
- VM_SP_CNT(th, reg_cfp->sp), VM_SP_CNT(th, reg_cfp->bp));
- }
- }
-
- RUBY_VM_CHECK_INTS();
- vm_pop_frame(th);
- RESTORE_REGS();
-}
-
-/**
- @c method/iterator
- @e return from this vm loop
- @j VM loop ‚©‚甲‚¯‚éB
- */
-DEFINE_INSN
-finish
-()
-(VALUE val)
-(VALUE val)
-{
-#if OPT_CALL_THREADED_CODE
- rb_bug("unused instruction on OPT_CALL_THREADED_CODE");
-#else
- th->cfp++;
- return val;
-#endif
-}
-
-/**********************************************************/
-/* deal with control flow 3: exception */
-/**********************************************************/
-
-/**
- @c exception
- @e longjump
- @j ‘åˆæƒWƒƒƒ“ƒv‚ðs‚¤B
- */
-DEFINE_INSN
-throw
-(rb_num_t throw_state)
-(VALUE throwobj)
-(VALUE val)
-{
- RUBY_VM_CHECK_INTS();
- val = vm_throw(th, GET_CFP(), throw_state, throwobj);
- THROW_EXCEPTION(val);
- /* unreachable */
-}
-
-/**********************************************************/
-/* deal with control flow 4: local jump */
-/**********************************************************/
-
-/**
- @c jump
- @e set PC to (PC + dst).
- @j PC ‚ð (PC + dst) ‚É‚·‚éB
- */
-DEFINE_INSN
-jump
-(OFFSET dst)
-()
-()
-{
- RUBY_VM_CHECK_INTS();
- JUMP(dst);
-}
-
-/**
- @c jump
- @e if val is not false or nil, set PC to (PC + dst).
- @j ‚à‚µ val ‚ª false ‚© nil ‚łȂ¯‚ê‚ÎAPC ‚ð (PC + dst) ‚É‚·‚éB
- */
-DEFINE_INSN
-branchif
-(OFFSET dst)
-(VALUE val)
-()
-{
- if (RTEST(val)) {
- RUBY_VM_CHECK_INTS();
- JUMP(dst);
- }
-}
-
-/**
- @c jump
- @e if val is false or nil, set PC to (PC + dst).
- @j ‚à‚µ val ‚ª false ‚© nil ‚È‚ç‚ÎAPC ‚ð (PC + dst) ‚É‚·‚éB
- */
-DEFINE_INSN
-branchunless
-(OFFSET dst)
-(VALUE val)
-()
-{
- if (!RTEST(val)) {
- RUBY_VM_CHECK_INTS();
- JUMP(dst);
- }
-}
-
-
-/**********************************************************/
-/* for optimize */
-/**********************************************************/
-
-/**
- @c optimize
- @e inline cache
- @j ƒCƒ“ƒ‰ƒCƒ“ƒLƒƒƒbƒVƒ…‚ª—LŒø‚È‚çA’l‚ðƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚µ‚Ä dst ‚ÖƒWƒƒƒ“ƒv‚·‚éB
- */
-DEFINE_INSN
-getinlinecache
-(IC ic, OFFSET dst)
-()
-(VALUE val)
-{
- if (ic->ic_vmstat == GET_VM_STATE_VERSION()) {
- val = ic->ic_value;
- JUMP(dst);
- }
- else {
- /* none */
- val = Qnil;
- }
-}
-
-/**
- @c optimize
- @e inline cache (once)
- @j once ‚ðŽÀŒ»‚·‚éB
- */
-DEFINE_INSN
-onceinlinecache
-(IC ic, OFFSET dst)
-()
-(VALUE val)
-{
- if (ic->ic_vmstat) {
- val = ic->ic_value;
- JUMP(dst);
- }
- else {
- /* none */
- val = Qnil;
- }
-}
-
-/**
- @c optimize
- @e set inline cache
- @j ƒCƒ“ƒ‰ƒCƒ“ƒLƒƒƒbƒVƒ…‚Ì’l‚ðÝ’è‚·‚éB
- */
-DEFINE_INSN
-setinlinecache
-(OFFSET dst)
-(VALUE val)
-(VALUE val)
-{
- IC ic = GET_CONST_INLINE_CACHE(dst);
-
- ic->ic_value = val;
- ic->ic_vmstat = GET_VM_STATE_VERSION();
-}
-
-/**
- @c optimize
- @e case dispatcher
- @j case •¶‚ÅA‰Â”\‚È‚ç•\ˆø‚«‚ŃWƒƒƒ“ƒv‚·‚éB
- */
-DEFINE_INSN
-opt_case_dispatch
-(CDHASH hash, OFFSET else_offset)
-(..., VALUE key)
-() // inc += -1;
-{
- if (0) {
- /* TODO: if some === method is overrided */
- }
- else {
- VALUE val;
- if (st_lookup(RHASH_TBL(hash), key, &val)) {
- JUMP(FIX2INT(val));
- }
- else {
- JUMP(else_offset);
- }
- }
-}
-
-/**
- @c optimize
- @e check environment
- @j «—ˆ‚ÌŠg’£—pB
- */
-DEFINE_INSN
-opt_checkenv
-()
-()
-()
-{
- if (GET_CFP()->bp != GET_DFP() + 1) {
- VALUE *new_dfp = GET_CFP()->bp - 1;
- /* TODO: copy env and clean stack at creating env? */
- *new_dfp = *GET_DFP();
- SET_DFP(new_dfp);
- }
-}
-
-
-/** simple functions */
-
-/**
- @c optimize
- @e optimized X+Y.
- @j Å“K‰»‚³‚ꂽ X+YB
- */
-DEFINE_INSN
-opt_plus
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (0) {
-
- }
-#if 1
- else if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
- /* fixnum + fixnum */
-#ifndef LONG_LONG_VALUE
- val = (recv + (obj & (~1)));
- if ((~(recv ^ obj) & (recv ^ val)) &
- ((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
- val = rb_big_plus(rb_int2big(FIX2LONG(recv)),
- rb_int2big(FIX2LONG(obj)));
- }
-#else
- long a, b, c;
- a = FIX2LONG(recv);
- b = FIX2LONG(obj);
- c = a + b;
- if (FIXABLE(c)) {
- val = LONG2FIX(c);
- }
- else {
- val = rb_big_plus(rb_int2big(a), rb_int2big(b));
- }
-#endif
- }
-#endif
-
- else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
- if (0) {
- }
-#if 1
- else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
- HEAP_CLASS_OF(obj) == rb_cFloat &&
- BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
- val = DOUBLE2NUM(RFLOAT_VALUE(recv) + RFLOAT_VALUE(obj));
- }
-#endif
-
-#if 1
- else if (HEAP_CLASS_OF(recv) == rb_cString &&
- HEAP_CLASS_OF(obj) == rb_cString &&
- BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
- val = rb_str_plus(recv, obj);
- }
-#endif
-#if 1
- else if (HEAP_CLASS_OF(recv) == rb_cArray &&
- BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
- val = rb_ary_plus(recv, obj);
- }
-#endif
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idPLUS, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X-Y.
- @j Å“K‰»‚³‚ꂽ X-YB
- */
-DEFINE_INSN
-opt_minus
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_MINUS)) {
- long a, b, c;
-
- a = FIX2LONG(recv);
- b = FIX2LONG(obj);
- c = a - b;
-
- if (FIXABLE(c)) {
- val = LONG2FIX(c);
- }
- else {
- val = rb_big_minus(rb_int2big(a), rb_int2big(b));
- }
- }
- else {
- /* other */
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idMINUS, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X*Y.
- @j Å“K‰»‚³‚ꂽ X*YB
- */
-DEFINE_INSN
-opt_mult
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_MULT)) {
- long a, b, c;
-
- a = FIX2LONG(recv);
- if (a == 0) {
- val = recv;
- }
- else {
- b = FIX2LONG(obj);
- c = a * b;
-
- if (FIXABLE(c) && c / a == b) {
- val = LONG2FIX(c);
- }
- else {
- val = rb_big_mul(rb_int2big(a), rb_int2big(b));
- }
- }
- }
- else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
- if (0) {
- }
-#if 1
- else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
- HEAP_CLASS_OF(obj) == rb_cFloat &&
- BASIC_OP_UNREDEFINED_P(BOP_MULT)) {
- val = DOUBLE2NUM(RFLOAT_VALUE(recv) * RFLOAT_VALUE(obj));
- }
-#endif
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idMULT, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X/Y.
- @j Å“K‰»‚³‚ꂽ X/YB
- */
-DEFINE_INSN
-opt_div
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_DIV)) {
- long x, y, div;
-
- x = FIX2LONG(recv);
- y = FIX2LONG(obj);
- {
- /* copied from numeric.c#fixdivmod */
- long mod;
- if (y == 0)
- rb_num_zerodiv();
- if (y < 0) {
- if (x < 0)
- div = -x / -y;
- else
- div = -(x / -y);
- }
- else {
- if (x < 0)
- div = -(-x / y);
- else
- div = x / y;
- }
- mod = x - div * y;
- if ((mod < 0 && y > 0) || (mod > 0 && y < 0)) {
- mod += y;
- div -= 1;
- }
- }
- val = LONG2NUM(div);
- }
- else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
- if (0) {
- }
-#if 1
- else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
- HEAP_CLASS_OF(obj) == rb_cFloat &&
- BASIC_OP_UNREDEFINED_P(BOP_DIV)) {
- val = DOUBLE2NUM(RFLOAT_VALUE(recv) / RFLOAT_VALUE(obj));
- }
-#endif
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idDIV, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X%Y.
- @j Å“K‰»‚³‚ꂽ X%YB
- */
-DEFINE_INSN
-opt_mod
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_MOD)) {
- long x, y, mod;
-
- x = FIX2LONG(recv);
- y = FIX2LONG(obj);
- {
- /* copied from numeric.c#fixdivmod */
- long div;
-
- if (y == 0)
- rb_num_zerodiv();
- if (y < 0) {
- if (x < 0)
- div = -x / -y;
- else
- div = -(x / -y);
- }
- else {
- if (x < 0)
- div = -(-x / y);
- else
- div = x / y;
- }
- mod = x - div * y;
- if ((mod < 0 && y > 0) || (mod > 0 && y < 0)) {
- mod += y;
- div -= 1;
- }
- }
- val = LONG2FIX(mod);
- }
- else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
- if (0) {
- }
- else if (HEAP_CLASS_OF(recv) == rb_cFloat &&
- HEAP_CLASS_OF(obj) == rb_cFloat &&
- BASIC_OP_UNREDEFINED_P(BOP_MOD)) {
- double x = RFLOAT_VALUE(recv);
- double y = RFLOAT_VALUE(obj);
- double div, mod;
-
- {
- double z;
-
- modf(x / y, &z);
- mod = x - z * y;
- }
-
- div = (x - mod) / y;
- if (y * mod < 0) {
- mod += y;
- div -= 1.0;
- }
- val = DOUBLE2NUM(mod);
- }
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idMOD, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X==Y.
- @j Å“K‰»‚³‚ꂽ X==YB
- */
-DEFINE_INSN
-opt_eq
-(IC ic)
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- val = opt_eq_func(recv, obj, ic);
-
- if (val == Qundef) {
- /* other */
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idEq, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X!=Y.
- @j Å“K‰»‚³‚ꂽ X!=YB
- */
-DEFINE_INSN
-opt_neq
-(IC ic1, IC ic2)
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- extern VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
- NODE *mn = vm_method_search(idNeq, CLASS_OF(recv), ic1);
- val = Qundef;
-
- if (check_cfunc(mn, rb_obj_not_equal)) {
- val = opt_eq_func(recv, obj, ic2);
-
- if (val != Qundef) {
- val = RTEST(val) ? Qfalse : Qtrue;
- }
- }
-
- if (val == Qundef) {
- /* other */
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idNeq, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X<Y.
- @j Å“K‰»‚³‚ꂽ X<YB
- */
-DEFINE_INSN
-opt_lt
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_LT)) {
- long a = FIX2LONG(recv), b = FIX2LONG(obj);
-
- if (a < b) {
- val = Qtrue;
- }
- else {
- val = Qfalse;
- }
- }
- else {
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idLT, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X<=Y.
- @j Å“K‰»‚³‚ꂽ X<=YB
- */
-DEFINE_INSN
-opt_le
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_LE)) {
- long a = FIX2LONG(recv), b = FIX2LONG(obj);
-
- if (a <= b) {
- val = Qtrue;
- }
- else {
- val = Qfalse;
- }
- }
- else {
- /* other */
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idLE, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X>Y.
- @j Å“K‰»‚³‚ꂽ X>YB
- */
-DEFINE_INSN
-opt_gt
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_GT)) {
- long a = FIX2LONG(recv), b = FIX2LONG(obj);
-
- if (a > b) {
- val = Qtrue;
- }
- else {
- val = Qfalse;
- }
- }
- else {
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idGT, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized X>=Y.
- @j Å“K‰»‚³‚ꂽ X>=YB
- */
-DEFINE_INSN
-opt_ge
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (FIXNUM_2_P(recv, obj) &&
- BASIC_OP_UNREDEFINED_P(BOP_GE)) {
- long a = FIX2LONG(recv), b = FIX2LONG(obj);
-
- if (a >= b) {
- val = Qtrue;
- }
- else {
- val = Qfalse;
- }
- }
- else {
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idGE, recv);
- }
-}
-
-/**
- @c optimize
- @e <<
- @j Å“K‰»‚³‚ꂽ X<<YB
- */
-DEFINE_INSN
-opt_ltlt
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (!SPECIAL_CONST_P(recv)) {
- if (0) {
- }
- else if (HEAP_CLASS_OF(recv) == rb_cString &&
- BASIC_OP_UNREDEFINED_P(BOP_LTLT)) {
- val = rb_str_concat(recv, obj);
- }
- else if (HEAP_CLASS_OF(recv) == rb_cArray &&
- BASIC_OP_UNREDEFINED_P(BOP_LTLT)) {
- val = rb_ary_push(recv, obj);
- }
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idLTLT, recv);
- }
-}
-
-/**
- @c optimize
- @e []
- @j Å“K‰»‚³‚ꂽ recv[obj]B
- */
-DEFINE_INSN
-opt_aref
-()
-(VALUE recv, VALUE obj)
-(VALUE val)
-{
- if (!SPECIAL_CONST_P(recv) && BASIC_OP_UNREDEFINED_P(BOP_AREF)) {
- if (HEAP_CLASS_OF(recv) == rb_cArray && FIXNUM_P(obj)) {
- val = rb_ary_entry(recv, FIX2LONG(obj));
- }
- else if (HEAP_CLASS_OF(recv) == rb_cHash) {
- val = rb_hash_aref(recv, obj);
- }
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- CALL_SIMPLE_METHOD(1, idAREF, recv);
- }
-}
-
-/**
- @c optimize
- @e recv[obj] = set
- @j Å“K‰»‚³‚ꂽ recv[obj] = setB
- */
-DEFINE_INSN
-opt_aset
-()
-(VALUE recv, VALUE obj, VALUE set)
-(VALUE val)
-{
- if (!SPECIAL_CONST_P(recv) &&
- BASIC_OP_UNREDEFINED_P(BOP_ASET)) {
- if (HEAP_CLASS_OF(recv) == rb_cArray && FIXNUM_P(obj)) {
- rb_ary_store(recv, FIX2LONG(obj), set);
- val = set;
- }
- else if (HEAP_CLASS_OF(recv) == rb_cHash) {
- rb_hash_aset(recv, obj, set);
- val = set;
- }
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- PUSH(obj);
- PUSH(set);
- CALL_SIMPLE_METHOD(2, idASET, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized length
- @j Å“K‰»‚³‚ꂽ recv.length()B
- */
-DEFINE_INSN
-opt_length
-()
-(VALUE recv)
-(VALUE val)
-{
- if (!SPECIAL_CONST_P(recv) &&
- BASIC_OP_UNREDEFINED_P(BOP_LENGTH)) {
- if (HEAP_CLASS_OF(recv) == rb_cString) {
- val = rb_str_length(recv);
- }
- else if (HEAP_CLASS_OF(recv) == rb_cArray) {
- val = LONG2NUM(RARRAY_LEN(recv));
- }
- else if (HEAP_CLASS_OF(recv) == rb_cHash) {
- val = INT2FIX(RHASH_SIZE(recv));
- }
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- CALL_SIMPLE_METHOD(0, idLength, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized succ
- @j Å“K‰»‚³‚ꂽ recv.succ()B
- */
-DEFINE_INSN
-opt_succ
-()
-(VALUE recv)
-(VALUE val)
-{
- if (SPECIAL_CONST_P(recv)) {
- if (FIXNUM_P(recv) &&
- BASIC_OP_UNREDEFINED_P(BOP_SUCC)) {
- const VALUE obj = INT2FIX(1);
- /* fixnum + INT2FIX(1) */
- val = (recv + (obj & (~1)));
- if ((~(recv ^ obj) & (recv ^ val)) & ((unsigned long)LONG_MAX + 1)) {
- val = rb_big_plus(rb_int2big(FIX2LONG(recv)),
- rb_int2big(FIX2LONG(obj)));
- }
- }
- else {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- else {
- if (HEAP_CLASS_OF(recv) == rb_cString &&
- BASIC_OP_UNREDEFINED_P(BOP_SUCC)) {
- val = rb_str_succ(recv);
- }
- else if (HEAP_CLASS_OF(recv) == rb_cTime &&
- BASIC_OP_UNREDEFINED_P(BOP_SUCC)) {
- val = rb_time_succ(recv);
- }
- else
- {
- goto INSN_LABEL(normal_dispatch);
- }
- }
- if (0) {
- INSN_LABEL(normal_dispatch):
- PUSH(recv);
- CALL_SIMPLE_METHOD(0, idSucc, recv);
- }
-}
-
-/**
- @c optimize
- @e optimized not
- @j Å“K‰»‚³‚ꂽ recv.!()B
- */
-DEFINE_INSN
-opt_not
-(IC ic)
-(VALUE recv)
-(VALUE val)
-{
- extern VALUE rb_obj_not(VALUE obj);
- NODE *mn = vm_method_search(idNot, CLASS_OF(recv), ic);
-
- if (check_cfunc(mn, rb_obj_not)) {
- val = RTEST(recv) ? Qfalse : Qtrue;
- }
- else {
- PUSH(recv);
- CALL_SIMPLE_METHOD(0, idNot, recv);
- }
-}
-
-
-/**
- @c optimize
- @e optimized regexp match
- @j Å“K‰»‚³‚ꂽ³‹K•\Œ»ƒ}ƒbƒ`B
- */
-DEFINE_INSN
-opt_regexpmatch1
-(VALUE r)
-(VALUE obj)
-(VALUE val)
-{
- val = rb_reg_match(r, obj);
-}
-
-/**
- @c optimize
- @e optimized regexp match 2
- @j Å“K‰»‚³‚ꂽ³‹K•\Œ»ƒ}ƒbƒ` 2
- */
-DEFINE_INSN
-opt_regexpmatch2
-()
-(VALUE obj2, VALUE obj1)
-(VALUE val)
-{
- if (TYPE(obj2) == T_STRING) {
- val = rb_reg_match(obj1, obj2);
- }
- else {
- val = rb_funcall(obj2, idEqTilde, 1, obj1);
- }
-}
-
-/**
- @c optimize
- @e call native compiled method
- @j ƒlƒCƒeƒBƒuƒRƒ“ƒpƒCƒ‹‚µ‚½ƒƒ\ƒbƒh‚ð‹N“®B
- */
-DEFINE_INSN
-opt_call_c_function
-(rb_insn_func_t funcptr)
-()
-()
-{
- reg_cfp = (funcptr)(th, reg_cfp);
-
- if (reg_cfp == 0) {
- VALUE err = th->errinfo;
- th->errinfo = Qnil;
- THROW_EXCEPTION(err);
- }
-
- RESTORE_REGS();
- NEXT_INSN();
-}
-
-/**
- @c joke
- @e BLT
- @j BLT
- */
-DEFINE_INSN
-bitblt
-()
-()
-(VALUE ret)
-{
- ret = rb_str_new2("a bit of bacon, lettuce and tomato");
-}
-
-/**
- @c joke
- @e The Answer to Life, the Universe, and Everything
- @j l¶A‰F’ˆA‚·‚ׂĂ̓š‚¦B
- */
-DEFINE_INSN
-answer
-()
-()
-(VALUE ret)
-{
- ret = INT2FIX(42);
-}
-
diff --git a/instruby.rb b/instruby.rb
index 4c3ee35d02..2903a7c739 100755
--- a/instruby.rb
+++ b/instruby.rb
@@ -14,7 +14,7 @@ require 'tempfile'
STDOUT.sync = true
File.umask(0)
-def parse_args()
+def parse_args(argv = ARGV)
$mantype = 'doc'
$destdir = nil
$extout = nil
@@ -24,6 +24,12 @@ def parse_args()
$installed_list = nil
$dryrun = false
$rdocdir = nil
+ $data_mode = 0644
+ $prog_mode = 0755
+ $dir_mode = nil
+ $script_mode = nil
+ $cmdtype = ('bat' if File::ALT_SEPARATOR == '\\')
+ mflags = []
opt = OptionParser.new
opt.on('-n') {$dryrun = true}
opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
@@ -37,23 +43,48 @@ def parse_args()
$mflags.concat(v)
end
opt.on('-i', '--install=TYPE',
- [:local, :bin, :lib, :man, :ext, :"ext-arch", :"ext-comm", :rdoc]) do |ins|
+ [:local, :bin, :"bin-arch", :"bin-comm", :lib, :man, :ext, :"ext-arch", :"ext-comm", :rdoc]) do |ins|
$install << ins
end
+ opt.on('--data-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
+ $data_mode = mode
+ end
+ opt.on('--prog-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
+ $prog_mode = mode
+ end
+ opt.on('--dir-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
+ $dir_mode = mode
+ end
+ opt.on('--script-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
+ $script_mode = mode
+ end
opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
-
- opt.parse! rescue abort [$!.message, opt].join("\n")
+ opt.on('--cmd-type=TYPE', %w[bat cmd plain]) {|cmd| $cmdtype = (cmd unless cmd == 'plain')}
+
+ opt.order!(argv) do |v|
+ case v
+ when /\AINSTALL[-_]([-\w]+)=(.*)/
+ argv.unshift("--#{$1.tr('_', '-')}=#{$2}")
+ when /\A\w[-\w+]*=\z/
+ mflags << v
+ when /\A\w[-\w+]*\z/
+ $install << v.intern
+ else
+ raise OptionParser::InvalidArgument, v
+ end
+ end rescue abort [$!.message, opt].join("\n")
$make, *rest = Shellwords.shellwords($make)
$mflags.unshift(*rest) unless rest.empty?
+ $mflags.unshift(*mflags)
def $mflags.set?(flag)
- grep(/\A-(?!-).*#{'%s' % flag}/i) { return true }
+ grep(/\A-(?!-).*#{flag.chr}/i) { return true }
false
end
def $mflags.defined?(var)
- grep(/\A#{var}=(.*)/) {return $1}
+ grep(/\A#{var}=(.*)/) {return block_given? ? yield($1) : $1}
false
end
@@ -77,6 +108,9 @@ def parse_args()
end
$rdocdir ||= $mflags.defined?('RDOCOUT')
+
+ $dir_mode ||= $prog_mode | 0700
+ $script_mode ||= $prog_mode
end
parse_args()
@@ -119,12 +153,13 @@ def makedirs(dirs)
File.directory?(realdir)
end
end.compact!
- super(dirs, :mode => 0755) unless dirs.empty?
+ super(dirs, :mode => $dir_mode) unless dirs.empty?
end
def install_recursive(srcdir, dest, options = {})
- noinst = options[:no_install]
- glob = options[:glob] || "*"
+ opts = options.clone
+ noinst = opts.delete(:no_install)
+ glob = opts.delete(:glob) || "*"
subpath = srcdir.size..-1
Dir.glob("#{srcdir}/**/#{glob}") do |src|
case base = File.basename(src)
@@ -143,16 +178,21 @@ def install_recursive(srcdir, dest, options = {})
makedirs(d)
else
makedirs(File.dirname(d))
- install src, d
+ install src, d, opts
end
end
end
-def open_for_install(path, mode, &block)
+def open_for_install(path, mode)
+ data = open(realpath = with_destdir(path), "rb") {|f| f.read} rescue nil
+ newdata = yield
unless $dryrun
- open(with_destdir(path), mode, &block)
+ unless newdata == data
+ open(realpath, "wb", mode) {|f| f.write newdata}
+ end
+ File.chmod(mode, realpath)
end
- $installed_list.puts path if /^w/ =~ mode and $installed_list
+ $installed_list.puts path if $installed_list
end
def with_destdir(dir)
@@ -169,8 +209,6 @@ rubyw_install_name = CONFIG["rubyw_install_name"]
version = CONFIG["ruby_version"]
bindir = CONFIG["bindir"]
libdir = CONFIG["libdir"]
-archhdrdir = rubyhdrdir = CONFIG["rubyhdrdir"]
-archhdrdir += "/" + CONFIG["arch"]
rubylibdir = CONFIG["rubylibdir"]
archlibdir = CONFIG["archdir"]
sitelibdir = CONFIG["sitelibdir"]
@@ -184,24 +222,25 @@ dll = CONFIG["LIBRUBY_SO"]
lib = CONFIG["LIBRUBY"]
arc = CONFIG["LIBRUBY_A"]
-install?(:local, :arch, :bin) do
+install?(:local, :arch, :bin, :'bin-arch') do
puts "installing binary commands"
makedirs [bindir, libdir, archlibdir]
- install ruby_install_name+exeext, bindir, :mode => 0755
+ install ruby_install_name+exeext, bindir, :mode => $prog_mode
if rubyw_install_name and !rubyw_install_name.empty?
- install rubyw_install_name+exeext, bindir, :mode => 0755
+ install rubyw_install_name+exeext, bindir, :mode => $prog_mode
end
if enable_shared and dll != lib
- install dll, bindir, :mode => 0755
+ install dll, bindir, :mode => $prog_mode
end
- install lib, libdir, :mode => 0755 unless lib == arc
- install arc, libdir, :mode => 0644
- install "rbconfig.rb", archlibdir, :mode => 0644
+ install lib, libdir, :mode => $prog_mode unless lib == arc
+ install arc, libdir, :mode => $data_mode
+ install "config.h", archlibdir, :mode => $data_mode
+ install "rbconfig.rb", archlibdir, :mode => $data_mode
if CONFIG["ARCHFILE"]
for file in CONFIG["ARCHFILE"].split
- install file, archlibdir, :mode => 0644
+ install file, archlibdir, :mode => $data_mode
end
end
@@ -216,19 +255,16 @@ if $extout
extout = "#$extout"
install?(:ext, :arch, :'ext-arch') do
puts "installing extension objects"
- makedirs [archlibdir, sitearchlibdir, vendorarchlibdir, archhdrdir]
+ makedirs [archlibdir, sitearchlibdir, vendorarchlibdir]
if noinst = CONFIG["no_install_files"] and noinst.empty?
noinst = nil
end
- install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst)
- install_recursive("#{extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h")
+ install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode)
end
install?(:ext, :comm, :'ext-comm') do
puts "installing extension scripts"
- hdrdir = rubyhdrdir + "/ruby"
- makedirs [rubylibdir, sitelibdir, vendorlibdir, hdrdir]
- install_recursive("#{extout}/common", rubylibdir)
- install_recursive("#{extout}/include/ruby", hdrdir, :glob => "*.h")
+ makedirs [rubylibdir, sitelibdir, vendorlibdir]
+ install_recursive("#{extout}/common", rubylibdir, :mode => $data_mode)
end
end
@@ -236,14 +272,14 @@ install?(:rdoc) do
if $rdocdir
puts "installing rdoc"
- ridatadir = File.join(CONFIG['datadir'], 'ri/$(MAJOR).$(MINOR).$(TEENY)/system')
+ ridatadir = File.join(CONFIG['datadir'], 'ri/$(MAJOR).$(MINOR)/system')
Config.expand(ridatadir)
makedirs [ridatadir]
- install_recursive($rdocdir, ridatadir)
+ install_recursive($rdocdir, ridatadir, :mode => $data_mode)
end
end
-install?(:local, :comm, :bin) do
+install?(:local, :comm, :bin, :'bin-comm') do
puts "installing command scripts"
Dir.chdir srcdir
@@ -251,39 +287,33 @@ install?(:local, :comm, :bin) do
ruby_shebang = File.join(bindir, ruby_install_name)
if File::ALT_SEPARATOR
- ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
+ ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
end
for src in Dir["bin/*"]
next unless File.file?(src)
next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
name = ruby_install_name.sub(/ruby/, File.basename(src))
- dest = File.join(bindir, name)
-
- install src, dest, :mode => 0755
-
- next if $dryrun
shebang = ''
body = ''
- open_for_install(dest, "r+") { |f|
+ open(src, "rb") do |f|
shebang = f.gets
body = f.read
-
- if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
- f.rewind
- f.print shebang, body
- f.truncate(f.pos)
- end
- }
-
- if ruby_bin_dosish
- batfile = File.join(bindir, name + ".bat")
- open_for_install(batfile, "wb") {|b|
- b.print((<<EOH+shebang+body+<<EOF).gsub(/\r?\n/, "\r\n"))
+ end
+ shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
+ shebang.sub!(/\r$/, '')
+ body.gsub!(/\r$/, '')
+
+ cmd = File.join(bindir, name)
+ cmd << ".#{$cmdtype}" if $cmdtype
+ open_for_install(cmd, $script_mode) do
+ case $cmdtype
+ when "bat"
+ "#{<<EOH}#{shebang}#{body}#{<<EOF}".gsub(/$/, "\r")
@echo off
@if not "%~d0" == "~d0" goto WinNT
-#{ruby_bin_dosish} -x "#{batfile}" %1 %2 %3 %4 %5 %6 %7 %8 %9
+#{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9
@goto endofruby
:WinNT
"%~dp0#{ruby_install_name}" -x "%~f0" %*
@@ -292,7 +322,14 @@ EOH
__END__
:endofruby
EOF
- }
+ when "cmd"
+ "#{<<EOH}#{shebang}#{body}"
+@"%~dp0#{ruby_install_name}" -x "%~f0" %*
+@exit /b %ERRORLEVEL%
+EOH
+ else
+ shebang + body
+ end
end
end
end
@@ -306,7 +343,7 @@ install?(:local, :comm, :lib) do
for f in Dir["lib/**/*{.rb,help-message}"]
dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
makedirs dir
- install f, dir, :mode => 0644
+ install f, dir, :mode => $data_mode
end
end
@@ -314,13 +351,16 @@ install?(:local, :arch, :lib) do
puts "installing headers"
Dir.chdir(srcdir)
- makedirs [rubyhdrdir]
- noinst = []
- unless RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
- noinst << "win32.h"
+ makedirs [archlibdir]
+ for f in Dir["*.h"]
+ install f, archlibdir, :mode => $data_mode
+ end
+
+ if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
+ win32libdir = File.join(archlibdir, "win32")
+ makedirs win32libdir
+ install "win32/win32.h", win32libdir, :mode => $data_mode
end
- noinst = nil if noinst.empty?
- install_recursive("include", rubyhdrdir, :no_install => noinst, :glob => "*.h")
end
install?(:local, :comm, :man) do
@@ -336,7 +376,7 @@ install?(:local, :comm, :man) do
makedirs destdir
if $mantype == "doc"
- install mdoc, destfile, :mode => 0644
+ install mdoc, destfile, :mode => $data_mode
else
require 'mdoc2man.rb'
@@ -348,15 +388,17 @@ install?(:local, :comm, :man) do
w.close
- install w.path, destfile, :mode => 0644
+ install w.path, destfile, :mode => $data_mode
end
end
end
-$install.concat ARGV.collect {|n| n.intern}
$install << :local << :ext if $install.empty?
$install.each do |inst|
- $install_procs[inst].each do |block|
+ if !(procs = $install_procs[inst]) || procs.empty?
+ next warn("unknown install target - #{inst}")
+ end
+ procs.each do |block|
dir = Dir.pwd
begin
block.call
diff --git a/intern.h b/intern.h
new file mode 100644
index 0000000000..7e72dd5537
--- /dev/null
+++ b/intern.h
@@ -0,0 +1,530 @@
+/**********************************************************************
+
+ intern.h -
+
+ $Author$
+ $Date$
+ created at: Thu Jun 10 14:22:17 JST 1993
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+ Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ Copyright (C) 2000 Information-technology Promotion Agency, Japan
+
+**********************************************************************/
+
+/*
+ * Functions and variables that are used by more than one source file of
+ * the kernel.
+ */
+
+#define ID_ALLOCATOR 1
+
+/* array.c */
+void rb_mem_clear _((register VALUE*, register long));
+VALUE rb_assoc_new _((VALUE, VALUE));
+VALUE rb_check_array_type _((VALUE));
+VALUE rb_ary_new _((void));
+VALUE rb_ary_new2 _((long));
+VALUE rb_ary_new3 __((long,...));
+VALUE rb_ary_new4 _((long, const VALUE *));
+VALUE rb_ary_freeze _((VALUE));
+VALUE rb_ary_aref _((int, VALUE*, VALUE));
+void rb_ary_store _((VALUE, long, VALUE));
+VALUE rb_ary_dup _((VALUE));
+VALUE rb_ary_to_ary _((VALUE));
+VALUE rb_ary_to_s _((VALUE));
+VALUE rb_ary_push _((VALUE, VALUE));
+VALUE rb_ary_pop _((VALUE));
+VALUE rb_ary_shift _((VALUE));
+VALUE rb_ary_unshift _((VALUE, VALUE));
+VALUE rb_ary_entry _((VALUE, long));
+VALUE rb_ary_each _((VALUE));
+VALUE rb_ary_join _((VALUE, VALUE));
+VALUE rb_ary_print_on _((VALUE, VALUE));
+VALUE rb_ary_reverse _((VALUE));
+VALUE rb_ary_sort _((VALUE));
+VALUE rb_ary_sort_bang _((VALUE));
+VALUE rb_ary_delete _((VALUE, VALUE));
+VALUE rb_ary_delete_at _((VALUE, long));
+VALUE rb_ary_clear _((VALUE));
+VALUE rb_ary_plus _((VALUE, VALUE));
+VALUE rb_ary_concat _((VALUE, VALUE));
+VALUE rb_ary_assoc _((VALUE, VALUE));
+VALUE rb_ary_rassoc _((VALUE, VALUE));
+VALUE rb_ary_includes _((VALUE, VALUE));
+VALUE rb_ary_cmp _((VALUE, VALUE));
+VALUE rb_protect_inspect _((VALUE(*)(ANYARGS),VALUE,VALUE));
+VALUE rb_inspecting_p _((VALUE));
+VALUE rb_check_array_value _((VALUE));
+VALUE rb_values_at _((VALUE, long, int, VALUE*, VALUE(*) _((VALUE,long))));
+/* bignum.c */
+VALUE rb_big_clone _((VALUE));
+void rb_big_2comp _((VALUE));
+VALUE rb_big_norm _((VALUE));
+VALUE rb_uint2big _((unsigned long));
+VALUE rb_int2big _((long));
+VALUE rb_uint2inum _((unsigned long));
+VALUE rb_int2inum _((long));
+VALUE rb_cstr_to_inum _((const char*, int, int));
+VALUE rb_str_to_inum _((VALUE, int, int));
+VALUE rb_cstr2inum _((const char*, int));
+VALUE rb_str2inum _((VALUE, int));
+VALUE rb_big2str _((VALUE, int));
+VALUE rb_big2str0 _((VALUE, int, int));
+long rb_big2long _((VALUE));
+#define rb_big2int(x) rb_big2long(x)
+unsigned long rb_big2ulong _((VALUE));
+#define rb_big2uint(x) rb_big2ulong(x)
+#if HAVE_LONG_LONG
+VALUE rb_ll2inum _((LONG_LONG));
+VALUE rb_ull2inum _((unsigned LONG_LONG));
+LONG_LONG rb_big2ll _((VALUE));
+unsigned LONG_LONG rb_big2ull _((VALUE));
+#endif /* HAVE_LONG_LONG */
+void rb_quad_pack _((char*,VALUE));
+VALUE rb_quad_unpack _((const char*,int));
+VALUE rb_dbl2big _((double));
+double rb_big2dbl _((VALUE));
+VALUE rb_big_plus _((VALUE, VALUE));
+VALUE rb_big_minus _((VALUE, VALUE));
+VALUE rb_big_mul _((VALUE, VALUE));
+VALUE rb_big_divmod _((VALUE, VALUE));
+VALUE rb_big_pow _((VALUE, VALUE));
+VALUE rb_big_and _((VALUE, VALUE));
+VALUE rb_big_or _((VALUE, VALUE));
+VALUE rb_big_xor _((VALUE, VALUE));
+VALUE rb_big_lshift _((VALUE, VALUE));
+VALUE rb_big_rand _((VALUE, double*));
+/* class.c */
+VALUE rb_class_boot _((VALUE));
+VALUE rb_class_new _((VALUE));
+VALUE rb_mod_init_copy _((VALUE, VALUE));
+VALUE rb_class_init_copy _((VALUE, VALUE));
+VALUE rb_singleton_class_clone _((VALUE));
+void rb_singleton_class_attached _((VALUE,VALUE));
+VALUE rb_make_metaclass _((VALUE, VALUE));
+void rb_check_inheritable _((VALUE));
+VALUE rb_class_inherited _((VALUE, VALUE));
+VALUE rb_define_class_id _((ID, VALUE));
+VALUE rb_module_new _((void));
+VALUE rb_define_module_id _((ID));
+VALUE rb_mod_included_modules _((VALUE));
+VALUE rb_mod_include_p _((VALUE, VALUE));
+VALUE rb_mod_ancestors _((VALUE));
+VALUE rb_class_instance_methods _((int, VALUE*, VALUE));
+VALUE rb_class_public_instance_methods _((int, VALUE*, VALUE));
+VALUE rb_class_protected_instance_methods _((int, VALUE*, VALUE));
+VALUE rb_big_rshift(VALUE, VALUE);
+VALUE rb_class_private_instance_methods _((int, VALUE*, VALUE));
+VALUE rb_obj_singleton_methods _((int, VALUE*, VALUE));
+void rb_define_method_id _((VALUE, ID, VALUE (*)(ANYARGS), int));
+void rb_frozen_class_p _((VALUE));
+void rb_undef _((VALUE, ID));
+void rb_define_protected_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
+void rb_define_private_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
+void rb_define_singleton_method _((VALUE, const char*, VALUE(*)(ANYARGS), int));
+VALUE rb_singleton_class _((VALUE));
+/* compar.c */
+int rb_cmpint _((VALUE, VALUE, VALUE));
+NORETURN(void rb_cmperr _((VALUE, VALUE)));
+/* enum.c */
+VALUE rb_block_call _((VALUE, ID, int, VALUE*, VALUE (*)(ANYARGS), VALUE));
+/* enumerator.c */
+VALUE rb_enumeratorize _((VALUE, VALUE, int, VALUE *));
+#define RETURN_ENUMERATOR(obj, argc, argv) do { \
+ if (!rb_block_given_p()) \
+ return rb_enumeratorize(obj, ID2SYM(rb_frame_this_func()), \
+ argc, argv); \
+ } while (0)
+/* error.c */
+RUBY_EXTERN int ruby_nerrs;
+VALUE rb_exc_new _((VALUE, const char*, long));
+VALUE rb_exc_new2 _((VALUE, const char*));
+VALUE rb_exc_new3 _((VALUE, VALUE));
+NORETURN(void rb_loaderror __((const char*, ...)));
+NORETURN(void rb_name_error __((ID, const char*, ...)));
+NORETURN(void rb_invalid_str _((const char*, const char*)));
+void rb_compile_error __((const char*, ...));
+void rb_compile_error_append __((const char*, ...));
+NORETURN(void rb_load_fail _((const char*)));
+NORETURN(void rb_error_frozen _((const char*)));
+void rb_check_frozen _((VALUE));
+/* eval.c */
+RUBY_EXTERN struct RNode *ruby_current_node;
+void ruby_set_current_source _((void));
+NORETURN(void rb_exc_raise _((VALUE)));
+NORETURN(void rb_exc_fatal _((VALUE)));
+VALUE rb_f_exit _((int,VALUE*));
+VALUE rb_f_abort _((int,VALUE*));
+void rb_remove_method _((VALUE, const char*));
+#define rb_disable_super(klass, name) ((void)0)
+#define rb_enable_super(klass, name) ((void)0)
+#define HAVE_RB_DEFINE_ALLOC_FUNC 1
+void rb_define_alloc_func _((VALUE, VALUE (*)(VALUE)));
+void rb_undef_alloc_func _((VALUE));
+void rb_clear_cache _((void));
+void rb_clear_cache_by_class _((VALUE));
+void rb_alias _((VALUE, ID, ID));
+void rb_attr _((VALUE,ID,int,int,int));
+int rb_method_boundp _((VALUE, ID, int));
+VALUE rb_dvar_defined _((ID));
+VALUE rb_dvar_curr _((ID));
+VALUE rb_dvar_ref _((ID));
+void rb_dvar_asgn _((ID, VALUE));
+void rb_dvar_push _((ID, VALUE));
+VALUE *rb_svar _((int));
+VALUE rb_eval_cmd _((VALUE, VALUE, int));
+int rb_obj_respond_to _((VALUE, ID, int));
+int rb_respond_to _((VALUE, ID));
+void rb_interrupt _((void));
+VALUE rb_apply _((VALUE, ID, VALUE));
+void rb_backtrace _((void));
+ID rb_frame_last_func _((void));
+ID rb_frame_this_func _((void));
+VALUE rb_obj_instance_eval _((int, VALUE*, VALUE));
+VALUE rb_mod_module_eval _((int, VALUE*, VALUE));
+void rb_load _((VALUE, int));
+void rb_load_protect _((VALUE, int, int*));
+NORETURN(void rb_jump_tag _((int)));
+int rb_provided _((const char*));
+void rb_provide _((const char*));
+VALUE rb_f_require _((VALUE, VALUE));
+VALUE rb_require_safe _((VALUE, int));
+void rb_obj_call_init _((VALUE, int, VALUE*));
+VALUE rb_class_new_instance _((int, VALUE*, VALUE));
+VALUE rb_block_proc _((void));
+VALUE rb_block_dup _((VALUE, VALUE, VALUE));
+VALUE rb_method_dup _((VALUE, VALUE, VALUE));
+VALUE rb_f_lambda _((void));
+VALUE rb_proc_call _((VALUE, VALUE));
+VALUE rb_obj_method _((VALUE, VALUE));
+VALUE rb_protect _((VALUE (*)(VALUE), VALUE, int*));
+void rb_set_end_proc _((void (*)(VALUE), VALUE));
+void rb_mark_end_proc _((void));
+void rb_exec_end_proc _((void));
+void ruby_finalize _((void));
+NORETURN(void ruby_stop _((int)));
+int ruby_cleanup _((int));
+int ruby_exec _((void));
+void rb_gc_mark_threads _((void));
+void rb_thread_start_timer _((void));
+void rb_thread_stop_timer _((void));
+void rb_thread_schedule _((void));
+void rb_thread_wait_fd _((int));
+int rb_thread_fd_writable _((int));
+void rb_thread_fd_close _((int));
+int rb_thread_alone _((void));
+void rb_thread_polling _((void));
+void rb_thread_sleep _((int));
+void rb_thread_sleep_forever _((void));
+VALUE rb_thread_stop _((void));
+VALUE rb_thread_wakeup _((VALUE));
+VALUE rb_thread_wakeup_alive _((VALUE));
+VALUE rb_thread_run _((VALUE));
+VALUE rb_thread_kill _((VALUE));
+VALUE rb_thread_alive_p _((VALUE));
+VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
+void rb_thread_interrupt _((void));
+void rb_thread_trap_eval _((VALUE, int, int));
+void rb_thread_signal_raise _((int));
+void rb_thread_signal_exit _((void));
+int rb_thread_select _((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+void rb_thread_wait_for _((struct timeval));
+VALUE rb_thread_current _((void));
+VALUE rb_thread_main _((void));
+VALUE rb_thread_local_aref _((VALUE, ID));
+VALUE rb_thread_local_aset _((VALUE, ID, VALUE));
+void rb_thread_atfork _((void));
+VALUE rb_exec_recursive _((VALUE(*)(VALUE, VALUE, int),VALUE,VALUE));
+VALUE rb_funcall_rescue __((VALUE, ID, int, ...));
+/* file.c */
+VALUE rb_file_s_expand_path _((int, VALUE *));
+VALUE rb_file_expand_path _((VALUE, VALUE));
+void rb_file_const _((const char*, VALUE));
+int rb_find_file_ext _((VALUE*, const char* const*));
+VALUE rb_find_file _((VALUE));
+char *rb_path_next _((const char *));
+char *rb_path_skip_prefix _((const char *));
+char *rb_path_last_separator _((const char *));
+char *rb_path_end _((const char *));
+VALUE rb_file_directory_p _((VALUE,VALUE));
+/* gc.c */
+NORETURN(void rb_memerror __((void)));
+int ruby_stack_check _((void));
+int ruby_stack_length _((VALUE**));
+int rb_during_gc _((void));
+char *rb_source_filename _((const char*));
+void rb_gc_mark_locations _((VALUE*, VALUE*));
+void rb_mark_tbl _((struct st_table*));
+void rb_mark_hash _((struct st_table*));
+void rb_gc_mark_maybe _((VALUE));
+void rb_gc_mark _((VALUE));
+void rb_gc_force_recycle _((VALUE));
+void rb_gc _((void));
+void rb_gc_copy_finalizer _((VALUE,VALUE));
+void rb_gc_finalize_deferred _((void));
+void rb_gc_call_finalizer_at_exit _((void));
+VALUE rb_gc_enable _((void));
+VALUE rb_gc_disable _((void));
+VALUE rb_gc_start _((void));
+/* hash.c */
+void st_foreach_safe _((struct st_table *, int (*)(ANYARGS), unsigned long));
+void rb_hash_foreach _((VALUE, int (*)(ANYARGS), VALUE));
+VALUE rb_hash _((VALUE));
+VALUE rb_hash_new _((void));
+VALUE rb_hash_freeze _((VALUE));
+VALUE rb_hash_aref _((VALUE, VALUE));
+VALUE rb_hash_lookup _((VALUE, VALUE));
+VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
+VALUE rb_hash_delete_if _((VALUE));
+VALUE rb_hash_delete _((VALUE,VALUE));
+int rb_path_check _((const char*));
+int rb_env_path_tainted _((void));
+/* io.c */
+#define rb_defout rb_stdout
+RUBY_EXTERN VALUE rb_fs;
+RUBY_EXTERN VALUE rb_output_fs;
+RUBY_EXTERN VALUE rb_rs;
+RUBY_EXTERN VALUE rb_default_rs;
+RUBY_EXTERN VALUE rb_output_rs;
+VALUE rb_io_write _((VALUE, VALUE));
+VALUE rb_io_gets _((VALUE));
+VALUE rb_io_getc _((VALUE));
+VALUE rb_io_ungetc _((VALUE, VALUE));
+VALUE rb_io_close _((VALUE));
+VALUE rb_io_eof _((VALUE));
+VALUE rb_io_binmode _((VALUE));
+VALUE rb_io_addstr _((VALUE, VALUE));
+VALUE rb_io_printf _((int, VALUE*, VALUE));
+VALUE rb_io_print _((int, VALUE*, VALUE));
+VALUE rb_io_puts _((int, VALUE*, VALUE));
+VALUE rb_file_open _((const char*, const char*));
+VALUE rb_gets _((void));
+void rb_write_error _((const char*));
+void rb_write_error2 _((const char*, long));
+/* marshal.c */
+VALUE rb_marshal_dump _((VALUE, VALUE));
+VALUE rb_marshal_load _((VALUE));
+/* numeric.c */
+void rb_num_zerodiv _((void));
+VALUE rb_num_coerce_bin _((VALUE, VALUE));
+VALUE rb_num_coerce_cmp _((VALUE, VALUE));
+VALUE rb_num_coerce_relop _((VALUE, VALUE));
+VALUE rb_float_new _((double));
+VALUE rb_num2fix _((VALUE));
+VALUE rb_fix2str _((VALUE, int));
+VALUE rb_dbl_cmp _((double, double));
+/* object.c */
+int rb_eql _((VALUE, VALUE));
+VALUE rb_any_to_s _((VALUE));
+VALUE rb_inspect _((VALUE));
+VALUE rb_obj_is_instance_of _((VALUE, VALUE));
+VALUE rb_obj_is_kind_of _((VALUE, VALUE));
+VALUE rb_obj_alloc _((VALUE));
+VALUE rb_obj_clone _((VALUE));
+VALUE rb_obj_dup _((VALUE));
+VALUE rb_obj_init_copy _((VALUE,VALUE));
+VALUE rb_obj_taint _((VALUE));
+VALUE rb_obj_tainted _((VALUE));
+VALUE rb_obj_untaint _((VALUE));
+VALUE rb_obj_freeze _((VALUE));
+VALUE rb_obj_id _((VALUE));
+VALUE rb_obj_class _((VALUE));
+VALUE rb_class_real _((VALUE));
+VALUE rb_class_inherited_p _((VALUE, VALUE));
+VALUE rb_convert_type _((VALUE,int,const char*,const char*));
+VALUE rb_check_convert_type _((VALUE,int,const char*,const char*));
+VALUE rb_check_to_integer _((VALUE, const char *));
+VALUE rb_to_int _((VALUE));
+VALUE rb_Integer _((VALUE));
+VALUE rb_Float _((VALUE));
+VALUE rb_String _((VALUE));
+VALUE rb_Array _((VALUE));
+double rb_cstr_to_dbl _((const char*, int));
+double rb_str_to_dbl _((VALUE, int));
+/* parse.y */
+RUBY_EXTERN int ruby_sourceline;
+RUBY_EXTERN char *ruby_sourcefile;
+int ruby_yyparse _((void));
+ID rb_id_attrset _((ID));
+void rb_parser_append_print _((void));
+void rb_parser_while_loop _((int, int));
+int ruby_parser_stack_on_heap _((void));
+void rb_gc_mark_parser _((void));
+int rb_is_const_id _((ID));
+int rb_is_instance_id _((ID));
+int rb_is_class_id _((ID));
+int rb_is_local_id _((ID));
+int rb_is_junk_id _((ID));
+int rb_symname_p _((const char*));
+int rb_sym_interned_p _((VALUE));
+VALUE rb_backref_get _((void));
+void rb_backref_set _((VALUE));
+VALUE rb_lastline_get _((void));
+void rb_lastline_set _((VALUE));
+VALUE rb_sym_all_symbols _((void));
+/* process.c */
+int rb_proc_exec _((const char*));
+VALUE rb_f_exec _((int,VALUE*));
+int rb_waitpid _((int,int*,int));
+void rb_syswait _((int));
+VALUE rb_proc_times _((VALUE));
+VALUE rb_detach_process _((int));
+/* range.c */
+VALUE rb_range_new _((VALUE, VALUE, int));
+VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
+VALUE rb_length_by_each _((VALUE));
+/* random.c */
+unsigned long rb_genrand_int32(void);
+double rb_genrand_real(void);
+/* re.c */
+int rb_memcmp _((const void*,const void*,long));
+int rb_memcicmp _((const void*,const void*,long));
+long rb_memsearch _((const void*,long,const void*,long));
+VALUE rb_reg_nth_defined _((int, VALUE));
+VALUE rb_reg_nth_match _((int, VALUE));
+VALUE rb_reg_last_match _((VALUE));
+VALUE rb_reg_match_pre _((VALUE));
+VALUE rb_reg_match_post _((VALUE));
+VALUE rb_reg_match_last _((VALUE));
+VALUE rb_reg_new _((const char*, long, int));
+VALUE rb_reg_match _((VALUE, VALUE));
+VALUE rb_reg_match2 _((VALUE));
+int rb_reg_options _((VALUE));
+void rb_set_kcode _((const char*));
+const char* rb_get_kcode _((void));
+void rb_kcode_set_option _((VALUE));
+void rb_kcode_reset_option _((void));
+/* ruby.c */
+RUBY_EXTERN VALUE rb_argv;
+RUBY_EXTERN VALUE rb_argv0;
+void rb_load_file _((const char*));
+void ruby_script _((const char*));
+void ruby_prog_init _((void));
+void ruby_set_argv _((int, char**));
+void ruby_process_options _((int, char**));
+void ruby_load_script _((void));
+void ruby_init_loadpath _((void));
+void ruby_incpush _((const char*));
+/* signal.c */
+VALUE rb_f_kill _((int, VALUE*));
+void rb_gc_mark_trap_list _((void));
+#ifdef POSIX_SIGNAL
+#define posix_signal ruby_posix_signal
+void posix_signal _((int, RETSIGTYPE (*)(int)));
+#endif
+void rb_trap_exit _((void));
+void rb_trap_exec _((void));
+const char *ruby_signal_name _((int));
+void ruby_default_signal _((int));
+/* sprintf.c */
+VALUE rb_f_sprintf _((int, VALUE*));
+VALUE rb_str_format _((int, VALUE*, VALUE));
+/* string.c */
+VALUE rb_str_new _((const char*, long));
+VALUE rb_str_new2 _((const char*));
+VALUE rb_str_new3 _((VALUE));
+VALUE rb_str_new4 _((VALUE));
+VALUE rb_str_new5 _((VALUE, const char*, long));
+VALUE rb_tainted_str_new _((const char*, long));
+VALUE rb_tainted_str_new2 _((const char*));
+VALUE rb_str_buf_new _((long));
+VALUE rb_str_buf_new2 _((const char*));
+VALUE rb_str_tmp_new _((long));
+VALUE rb_str_buf_append _((VALUE, VALUE));
+VALUE rb_str_buf_cat _((VALUE, const char*, long));
+VALUE rb_str_buf_cat2 _((VALUE, const char*));
+VALUE rb_obj_as_string _((VALUE));
+VALUE rb_check_string_type _((VALUE));
+VALUE rb_str_dup _((VALUE));
+VALUE rb_str_locktmp _((VALUE));
+VALUE rb_str_unlocktmp _((VALUE));
+VALUE rb_str_dup_frozen _((VALUE));
+VALUE rb_str_plus _((VALUE, VALUE));
+VALUE rb_str_times _((VALUE, VALUE));
+VALUE rb_str_substr _((VALUE, long, long));
+void rb_str_modify _((VALUE));
+VALUE rb_str_freeze _((VALUE));
+void rb_str_set_len _((VALUE, long));
+VALUE rb_str_resize _((VALUE, long));
+VALUE rb_str_cat _((VALUE, const char*, long));
+VALUE rb_str_cat2 _((VALUE, const char*));
+VALUE rb_str_append _((VALUE, VALUE));
+VALUE rb_str_concat _((VALUE, VALUE));
+int rb_str_hash _((VALUE));
+int rb_str_cmp _((VALUE, VALUE));
+VALUE rb_str_upto _((VALUE, VALUE, int));
+void rb_str_update _((VALUE, long, long, VALUE));
+VALUE rb_str_inspect _((VALUE));
+VALUE rb_str_dump _((VALUE));
+VALUE rb_str_split _((VALUE, const char*));
+void rb_str_associate _((VALUE, VALUE));
+VALUE rb_str_associated _((VALUE));
+void rb_str_setter _((VALUE, ID, VALUE*));
+VALUE rb_str_intern _((VALUE));
+/* struct.c */
+VALUE rb_struct_new __((VALUE, ...));
+VALUE rb_struct_define __((const char*, ...));
+VALUE rb_struct_alloc _((VALUE, VALUE));
+VALUE rb_struct_aref _((VALUE, VALUE));
+VALUE rb_struct_aset _((VALUE, VALUE, VALUE));
+VALUE rb_struct_getmember _((VALUE, ID));
+VALUE rb_struct_iv_get _((VALUE, const char*));
+VALUE rb_struct_s_members _((VALUE));
+VALUE rb_struct_members _((VALUE));
+/* time.c */
+VALUE rb_time_new _((time_t, time_t));
+/* variable.c */
+VALUE rb_mod_name _((VALUE));
+VALUE rb_class_path _((VALUE));
+void rb_set_class_path _((VALUE, VALUE, const char*));
+VALUE rb_path2class _((const char*));
+void rb_name_class _((VALUE, ID));
+VALUE rb_class_name _((VALUE));
+void rb_autoload _((VALUE, ID, const char*));
+VALUE rb_autoload_load _((VALUE, ID));
+VALUE rb_autoload_p _((VALUE, ID));
+void rb_gc_mark_global_tbl _((void));
+VALUE rb_f_trace_var _((int, VALUE*));
+VALUE rb_f_untrace_var _((int, VALUE*));
+VALUE rb_f_global_variables _((void));
+void rb_alias_variable _((ID, ID));
+struct st_table* rb_generic_ivar_table _((VALUE));
+void rb_copy_generic_ivar _((VALUE,VALUE));
+void rb_mark_generic_ivar _((VALUE));
+void rb_mark_generic_ivar_tbl _((void));
+void rb_free_generic_ivar _((VALUE));
+VALUE rb_ivar_get _((VALUE, ID));
+VALUE rb_ivar_set _((VALUE, ID, VALUE));
+VALUE rb_ivar_defined _((VALUE, ID));
+VALUE rb_iv_set _((VALUE, const char*, VALUE));
+VALUE rb_iv_get _((VALUE, const char*));
+VALUE rb_attr_get _((VALUE, ID));
+VALUE rb_obj_instance_variables _((VALUE));
+VALUE rb_obj_remove_instance_variable _((VALUE, VALUE));
+void *rb_mod_const_at _((VALUE, void*));
+void *rb_mod_const_of _((VALUE, void*));
+VALUE rb_const_list _((void*));
+VALUE rb_mod_constants _((VALUE));
+VALUE rb_mod_remove_const _((VALUE, VALUE));
+int rb_const_defined _((VALUE, ID));
+int rb_const_defined_at _((VALUE, ID));
+int rb_const_defined_from _((VALUE, ID));
+VALUE rb_const_get _((VALUE, ID));
+VALUE rb_const_get_at _((VALUE, ID));
+VALUE rb_const_get_from _((VALUE, ID));
+void rb_const_set _((VALUE, ID, VALUE));
+VALUE rb_mod_constants _((VALUE));
+VALUE rb_mod_const_missing _((VALUE,VALUE));
+VALUE rb_cvar_defined _((VALUE, ID));
+#define RB_CVAR_SET_4ARGS 1
+void rb_cvar_set _((VALUE, ID, VALUE, int));
+VALUE rb_cvar_get _((VALUE, ID));
+void rb_cv_set _((VALUE, const char*, VALUE));
+VALUE rb_cv_get _((VALUE, const char*));
+void rb_define_class_variable _((VALUE, const char*, VALUE));
+VALUE rb_mod_class_variables _((VALUE));
+VALUE rb_mod_remove_cvar _((VALUE, VALUE));
+/* version.c */
+void ruby_show_version _((void));
+void ruby_show_copyright _((void));
diff --git a/io.c b/io.c
index 7c5ee6f205..7663733d1e 100644
--- a/io.c
+++ b/io.c
@@ -6,30 +6,24 @@
$Date$
created at: Fri Oct 15 18:08:59 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/io.h"
-#include "ruby/signal.h"
-#include <ctype.h>
-#include <errno.h>
-
-#if defined(DOSISH) || defined(__CYGWIN__)
-#include <io.h>
+#if defined(__VMS)
+#define _XOPEN_SOURCE
+#define _POSIX_C_SOURCE 2
#endif
-#include <sys/types.h>
-#if !defined(_WIN32) && !defined(__DJGPP__)
-# if defined(__BEOS__)
-# include <net/socket.h>
-# else
-# include <sys/socket.h>
-# endif
-#endif
+#include "ruby.h"
+#include "rubyio.h"
+#include "rubysig.h"
+#include "env.h"
+#include "re.h"
+#include <ctype.h>
+#include <errno.h>
#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__) || defined(__BEOS__)
# define NO_SAFE_RENAME
@@ -56,10 +50,19 @@
#elif defined(HAVE_SYS_FCNTL_H)
#include <sys/fcntl.h>
#endif
+#ifdef __CYGWIN__
+#include <io.h>
+#endif
#if !HAVE_OFF_T && !defined(off_t)
# define off_t long
#endif
+#if !HAVE_FSEEKO && !defined(fseeko)
+# define fseeko fseek
+#endif
+#if !HAVE_FTELLO && !defined(ftello)
+# define ftello ftell
+#endif
#include <sys/stat.h>
@@ -73,16 +76,16 @@
#endif
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#ifdef HAVE_SYSCALL_H
#include <syscall.h>
#elif defined HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
#endif
-extern void Init_File(void);
+#include <unistd.h>
+#endif
+
+extern void Init_File _((void));
#ifdef __BEOS__
# ifndef NOFILE
@@ -91,7 +94,7 @@ extern void Init_File(void);
#include <net/socket.h>
#endif
-#include "ruby/util.h"
+#include "util.h"
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
@@ -124,11 +127,11 @@ VALUE rb_default_rs;
static VALUE argf;
-static ID id_write, id_read, id_getc, id_flush, id_encode;
+static ID id_write, id_read, id_getc;
extern char *ruby_inplace_mode;
-struct timeval rb_time_interval(VALUE);
+struct timeval rb_time_interval _((VALUE));
static VALUE filename, current_file;
static int gets_lineno;
@@ -137,79 +140,80 @@ static VALUE lineno = INT2FIX(0);
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
# ifdef _IO_fpos_t
-# define STDIO_READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr != (fp)->_IO_read_end)
+# define READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr != (fp)->_IO_read_end)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->_IO_read_end - (fp)->_IO_read_ptr)
+# define READ_DATA_PENDING_PTR(fp) ((fp)->_IO_read_ptr)
# else
-# define STDIO_READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
+# define READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->_egptr - (fp)->_gptr)
+# define READ_DATA_PENDING_PTR(fp) ((fp)->_gptr)
# endif
+#elif defined(_LP64) && (defined(__sun__) || defined(__sun))
+typedef struct _FILE64 {
+ unsigned char *_ptr; /* next character from/to here in buffer */
+ unsigned char *_base; /* the buffer */
+ unsigned char *_end; /* the end of the buffer */
+ ssize_t _cnt; /* number of available characters in buffer */
+ int _file; /* UNIX System file descriptor */
+ unsigned int _flag; /* the state of the stream */
+ char __fill[80]; /* filler to bring size to 128 bytes */
+} FILE64;
+# define READ_DATA_PENDING(fp) (((FILE64*)(fp))->_cnt > 0)
+# define READ_DATA_PENDING_COUNT(fp) (((FILE64*)(fp))->_cnt)
+# define READ_DATA_PENDING_PTR(fp) ((char *)((FILE64*)(fp))->_ptr)
#elif defined(FILE_COUNT)
-# define STDIO_READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
+# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_COUNT)
#elif defined(FILE_READEND)
-# define STDIO_READ_DATA_PENDING(fp) ((fp)->FILE_READPTR < (fp)->FILE_READEND)
+# define READ_DATA_PENDING(fp) ((fp)->FILE_READPTR < (fp)->FILE_READEND)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_READEND - (fp)->FILE_READPTR)
#elif defined(__BEOS__)
-# define STDIO_READ_DATA_PENDING(fp) (fp->_state._eof == 0)
+# define READ_DATA_PENDING(fp) (fp->_state._eof == 0)
#elif defined(__VMS)
-# define STDIO_READ_DATA_PENDING(fp) (((unsigned int)(*(fp))->_cnt) > 0)
+# define READ_DATA_PENDING_COUNT(fp) ((unsigned int)(*(fp))->_cnt)
+# define READ_DATA_PENDING(fp) (((unsigned int)(*(fp))->_cnt) > 0)
+# define READ_DATA_BUFFERED(fp) 0
+#elif defined(__DragonFly__)
+/* FILE is an incomplete struct type since DragonFly BSD 1.4.0 */
+# define READ_DATA_PENDING(fp) (((struct __FILE_public *)(fp))->_r > 0)
+# define READ_DATA_PENDING_COUNT(fp) (((struct __FILE_public *)(fp))->_r)
#else
-# define STDIO_READ_DATA_PENDING(fp) (!feof(fp))
+/* requires systems own version of the ReadDataPending() */
+extern int ReadDataPending();
+# define READ_DATA_PENDING(fp) (!feof(fp))
+# define READ_DATA_BUFFERED(fp) 0
#endif
-
-#if defined(__VMS)
-#define fopen(file_spec, mode) fopen(file_spec, mode, "rfm=stmlf")
-#define open(file_spec, flags, mode) open(file_spec, flags, mode, "rfm=stmlf")
+#ifndef READ_DATA_BUFFERED
+# define READ_DATA_BUFFERED(fp) READ_DATA_PENDING(fp)
#endif
-#define GetWriteIO(io) rb_io_get_write_io(io)
+#ifndef READ_DATA_PENDING_PTR
+# ifdef FILE_READPTR
+# define READ_DATA_PENDING_PTR(fp) ((char *)(fp)->FILE_READPTR)
+# endif
+#endif
-#define READ_DATA_PENDING(fptr) ((fptr)->rbuf_len)
-#define READ_DATA_PENDING_COUNT(fptr) ((fptr)->rbuf_len)
-#define READ_DATA_PENDING_PTR(fptr) ((fptr)->rbuf+(fptr)->rbuf_off)
-#define READ_DATA_BUFFERED(fptr) READ_DATA_PENDING(fptr)
+#if defined __DJGPP__
+# undef READ_DATA_PENDING_COUNT
+# undef READ_DATA_PENDING_PTR
+#endif
-#define READ_CHECK(fptr) do {\
- if (!READ_DATA_PENDING(fptr)) {\
- rb_thread_wait_fd((fptr)->fd);\
- rb_io_check_closed(fptr);\
+#define READ_CHECK(fp) do {\
+ if (!READ_DATA_PENDING(fp)) {\
+ rb_thread_wait_fd(fileno(fp));\
+ rb_io_check_closed(fptr);\
}\
} while(0)
-#ifndef S_ISSOCK
-# ifdef _S_ISSOCK
-# define S_ISSOCK(m) _S_ISSOCK(m)
-# else
-# ifdef _S_IFSOCK
-# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
-# else
-# ifdef S_IFSOCK
-# define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
-# endif
-# endif
-# endif
-#endif
-
-#if defined(_WIN32)
-#define is_socket(fd, path) rb_w32_is_socket(fd)
-#elif !defined(S_ISSOCK)
-#define is_socket(fd, path) 0
-#define shutdown(a,b) 0
-#else
-static int
-is_socket(int fd, const char *path)
-{
- struct stat sbuf;
- if (fstat(fd, &sbuf) < 0)
- rb_sys_fail(path);
- return S_ISSOCK(sbuf.st_mode);
-}
-#endif
-
void
-rb_eof_error(void)
+rb_eof_error()
{
rb_raise(rb_eEOFError, "end of file reached");
}
VALUE
-rb_io_taint_check(VALUE io)
+rb_io_taint_check(io)
+ VALUE io;
{
if (!OBJ_TAINTED(io) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
@@ -218,7 +222,8 @@ rb_io_taint_check(VALUE io)
}
void
-rb_io_check_initialized(rb_io_t *fptr)
+rb_io_check_initialized(fptr)
+ rb_io_t *fptr;
{
if (!fptr) {
rb_raise(rb_eIOError, "uninitialized stream");
@@ -226,108 +231,30 @@ rb_io_check_initialized(rb_io_t *fptr)
}
void
-rb_io_check_closed(rb_io_t *fptr)
+rb_io_check_closed(fptr)
+ rb_io_t *fptr;
{
rb_io_check_initialized(fptr);
- if (fptr->fd < 0) {
+ if (!fptr->f && !fptr->f2) {
rb_raise(rb_eIOError, "closed stream");
}
}
-static int io_fflush(rb_io_t *);
-
-static VALUE
-rb_io_get_io(VALUE io)
-{
- return rb_convert_type(io, T_FILE, "IO", "to_io");
-}
-
-static VALUE
-rb_io_check_io(VALUE io)
-{
- return rb_check_convert_type(io, T_FILE, "IO", "to_io");
-}
-
-VALUE
-rb_io_get_write_io(VALUE io)
-{
- VALUE write_io;
- write_io = RFILE(io)->fptr->tied_io_for_writing;
- if (write_io) {
- return write_io;
- }
- return io;
-}
-
-/*
- * call-seq:
- * IO.try_convert(obj) -> io or nil
- *
- * Try to convert <i>obj</i> into an IO, using to_io method.
- * Returns converted IO or nil if <i>obj</i> cannot be converted
- * for any reason.
- *
- * IO.try_convert(STDOUT) # => STDOUT
- * IO.try_convert("STDOUT") # => nil
- */
-static VALUE
-rb_io_s_try_convert(VALUE dummy, VALUE io)
-{
- return rb_io_check_io(io);
-}
-
-static void
-io_unread(rb_io_t *fptr)
-{
- off_t r;
- rb_io_check_closed(fptr);
- if (fptr->rbuf_len == 0 || fptr->mode & FMODE_DUPLEX)
- return;
- /* xxx: target position may be negative if buffer is filled by ungetc */
- r = lseek(fptr->fd, -fptr->rbuf_len, SEEK_CUR);
- if (r < 0) {
- if (errno == ESPIPE)
- fptr->mode |= FMODE_DUPLEX;
- return;
- }
- fptr->rbuf_off = 0;
- fptr->rbuf_len = 0;
- return;
-}
-
-static void
-io_ungetc(VALUE str, rb_io_t *fptr)
-{
- int len = RSTRING_LEN(str);
-
- if (fptr->rbuf == NULL) {
- fptr->rbuf_off = 0;
- fptr->rbuf_len = 0;
- if (len > 8192)
- fptr->rbuf_capa = len;
- else
- fptr->rbuf_capa = 8192;
- fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
- }
- if (fptr->rbuf_off < len) {
- rb_raise(rb_eIOError, "ungetc failed");
- }
- fptr->rbuf_off-=len;
- fptr->rbuf_len+=len;
- MEMMOVE(fptr->rbuf+fptr->rbuf_off, RSTRING_PTR(str), char, len);
-}
+static void io_fflush _((FILE *, rb_io_t *));
static rb_io_t *
-flush_before_seek(rb_io_t *fptr)
+flush_before_seek(fptr)
+ rb_io_t *fptr;
{
- io_fflush(fptr);
- io_unread(fptr);
+ if (fptr->mode & FMODE_WBUF) {
+ io_fflush(GetWriteFile(fptr), fptr);
+ }
errno = 0;
return fptr;
}
-#define io_seek(fptr, ofs, whence) lseek(flush_before_seek(fptr)->fd, ofs, whence)
-#define io_tell(fptr) lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR)
+#define io_seek(fptr, ofs, whence) fseeko(flush_before_seek(fptr)->f, ofs, whence)
+#define io_tell(fptr) ftello(flush_before_seek(fptr)->f)
#ifndef SEEK_CUR
# define SEEK_SET 0
@@ -338,83 +265,59 @@ flush_before_seek(rb_io_t *fptr)
#define FMODE_SYNCWRITE (FMODE_SYNC|FMODE_WRITABLE)
void
-rb_io_check_readable(rb_io_t *fptr)
+rb_io_check_readable(fptr)
+ rb_io_t *fptr;
{
rb_io_check_closed(fptr);
if (!(fptr->mode & FMODE_READABLE)) {
rb_raise(rb_eIOError, "not opened for reading");
}
- if (fptr->wbuf_len) {
- io_fflush(fptr);
+#ifdef NEED_IO_SEEK_BETWEEN_RW
+ if (((fptr->mode & FMODE_WBUF) ||
+ (fptr->mode & (FMODE_SYNCWRITE|FMODE_RBUF)) == FMODE_SYNCWRITE) &&
+ !feof(fptr->f) &&
+ !fptr->f2) {
+ io_seek(fptr, 0, SEEK_CUR);
}
- if (!fptr->enc && fptr->fd == 0) {
- fptr->enc = rb_default_external_encoding();
- }
-}
-
-static rb_encoding*
-io_read_encoding(rb_io_t *fptr)
-{
- if (fptr->enc) {
- return fptr->enc;
- }
- return (fptr->mode & FMODE_BINMODE)
- ? rb_ascii8bit_encoding()
- : rb_default_external_encoding();
-}
-
-static rb_encoding*
-io_input_encoding(rb_io_t *fptr)
-{
- if (fptr->enc2) {
- return fptr->enc2;
- }
- return io_read_encoding(fptr);
+#endif
+ fptr->mode |= FMODE_RBUF;
}
void
-rb_io_check_writable(rb_io_t *fptr)
+rb_io_check_writable(fptr)
+ rb_io_t *fptr;
{
rb_io_check_closed(fptr);
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
}
- if (fptr->rbuf_len) {
- io_unread(fptr);
+ if ((fptr->mode & FMODE_RBUF) && !feof(fptr->f) && !fptr->f2) {
+ io_seek(fptr, 0, SEEK_CUR);
+ }
+ if (!fptr->f2) {
+ fptr->mode &= ~FMODE_RBUF;
}
}
int
-rb_read_pending(FILE *fp)
-{
- return STDIO_READ_DATA_PENDING(fp);
-}
-
-int
-rb_io_read_pending(rb_io_t *fptr)
+rb_read_pending(fp)
+ FILE *fp;
{
- return READ_DATA_PENDING(fptr);
+ return READ_DATA_PENDING(fp);
}
void
-rb_read_check(FILE *fp)
+rb_read_check(fp)
+ FILE *fp;
{
- if (!STDIO_READ_DATA_PENDING(fp)) {
+ if (!READ_DATA_PENDING(fp)) {
rb_thread_wait_fd(fileno(fp));
}
}
-void
-rb_io_read_check(rb_io_t *fptr)
-{
- if (!READ_DATA_PENDING(fptr)) {
- rb_thread_wait_fd(fptr->fd);
- }
- return;
-}
-
static int
-ruby_dup(int orig)
+ruby_dup(orig)
+ int orig;
{
int fd;
@@ -431,8 +334,10 @@ ruby_dup(int orig)
return fd;
}
+static VALUE io_alloc _((VALUE));
static VALUE
-io_alloc(VALUE klass)
+io_alloc(klass)
+ VALUE klass;
{
NEWOBJ(io, struct RFile);
OBJSETUP(io, klass, T_FILE);
@@ -442,130 +347,32 @@ io_alloc(VALUE klass)
return (VALUE)io;
}
-#ifndef S_ISREG
-# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
-#endif
-
-static int
-wsplit_p(rb_io_t *fptr)
-{
- int r;
- if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) {
- struct stat buf;
- if (fstat(fptr->fd, &buf) == 0 &&
- !S_ISREG(buf.st_mode)
-#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
- && (r = fcntl(fptr->fd, F_GETFL)) != -1 &&
- !(r & O_NONBLOCK)
-#endif
- ) {
- fptr->mode |= FMODE_WSPLIT;
- }
- fptr->mode |= FMODE_WSPLIT_INITIALIZED;
- }
- return fptr->mode & FMODE_WSPLIT;
-}
-
-struct io_internal_struct {
- int fd;
- void *buf;
- size_t capa;
- int is_read;
-};
-
-static VALUE
-internal_io_func(void *ptr)
-{
- struct io_internal_struct *iis = (struct io_internal_struct*)ptr;
- if (iis->is_read) {
- return read(iis->fd, iis->buf, iis->capa);
- }
- else {
- return write(iis->fd, iis->buf, iis->capa);
- }
-}
-
-static int
-rb_read_internal(int fd, void *buf, size_t count)
-{
- struct io_internal_struct iis;
- iis.fd = fd;
- iis.buf = buf;
- iis.capa = count;
- iis.is_read = 1;
-
- return rb_thread_blocking_region(internal_io_func, &iis, RB_UBF_DFL, 0);
-}
-
-static int
-rb_write_internal(int fd, void *buf, size_t count)
-{
- struct io_internal_struct iis;
- iis.fd = fd;
- iis.buf = buf;
- iis.capa = count;
- iis.is_read = 0;
-
- return rb_thread_blocking_region(internal_io_func, &iis, RB_UBF_DFL, 0);
-}
-
-static int
-io_fflush(rb_io_t *fptr)
+static void
+io_fflush(f, fptr)
+ FILE *f;
+ rb_io_t *fptr;
{
- int r, l;
- int wbuf_off, wbuf_len;
+ int n;
- rb_io_check_closed(fptr);
- if (fptr->wbuf_len == 0)
- return 0;
- if (!rb_thread_fd_writable(fptr->fd)) {
+ if (!rb_thread_fd_writable(fileno(f))) {
rb_io_check_closed(fptr);
}
- retry:
- if (fptr->wbuf_len == 0)
- return 0;
- wbuf_off = fptr->wbuf_off;
- wbuf_len = fptr->wbuf_len;
- l = fptr->wbuf_len;
- if (PIPE_BUF < l &&
- !rb_thread_critical &&
- !rb_thread_alone() &&
- wsplit_p(fptr)) {
- l = PIPE_BUF;
- }
- r = rb_write_internal(fptr->fd, fptr->wbuf+fptr->wbuf_off, l);
- /* xxx: signal handler may modify wbuf */
- if (r == fptr->wbuf_len) {
- fptr->wbuf_off = 0;
- fptr->wbuf_len = 0;
- return 0;
- }
- if (0 <= r) {
- fptr->wbuf_off = (wbuf_off += r);
- fptr->wbuf_len = (wbuf_len -= r);
- errno = EAGAIN;
- }
- if (rb_io_wait_writable(fptr->fd)) {
- rb_io_check_closed(fptr);
- goto retry;
+ for (;;) {
+ TRAP_BEG;
+ n = fflush(f);
+ TRAP_END;
+ if (n != EOF) break;
+ if (!rb_io_wait_writable(fileno(f)))
+ rb_sys_fail(fptr->path);
}
- return -1;
+ fptr->mode &= ~FMODE_WBUF;
}
-#ifdef HAVE_RB_FD_INIT
-static VALUE
-wait_readable(VALUE p)
-{
- rb_fdset_t *rfds = (rb_fdset_t *)p;
-
- return rb_thread_select(rb_fd_max(rfds), rb_fd_ptr(rfds), NULL, NULL, NULL);
-}
-#endif
-
int
-rb_io_wait_readable(int f)
+rb_io_wait_readable(f)
+ int f;
{
- rb_fdset_t rfds;
+ fd_set rfds;
switch (errno) {
case EINTR:
@@ -579,14 +386,9 @@ rb_io_wait_readable(int f)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- rb_fd_init(&rfds);
- rb_fd_set(f, &rfds);
-#ifdef HAVE_RB_FD_INIT
- rb_ensure(wait_readable, (VALUE)&rfds,
- (VALUE (*)(VALUE))rb_fd_term, (VALUE)&rfds);
-#else
+ FD_ZERO(&rfds);
+ FD_SET(f, &rfds);
rb_thread_select(f + 1, &rfds, NULL, NULL, NULL);
-#endif
return Qtrue;
default:
@@ -594,20 +396,11 @@ rb_io_wait_readable(int f)
}
}
-#ifdef HAVE_RB_FD_INIT
-static VALUE
-wait_writable(VALUE p)
-{
- rb_fdset_t *wfds = (rb_fdset_t *)p;
-
- return rb_thread_select(rb_fd_max(wfds), NULL, rb_fd_ptr(wfds), NULL, NULL);
-}
-#endif
-
int
-rb_io_wait_writable(int f)
+rb_io_wait_writable(f)
+ int f;
{
- rb_fdset_t wfds;
+ fd_set wfds;
switch (errno) {
case EINTR:
@@ -621,14 +414,9 @@ rb_io_wait_writable(int f)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- rb_fd_init(&wfds);
- rb_fd_set(f, &wfds);
-#ifdef HAVE_RB_FD_INIT
- rb_ensure(wait_writable, (VALUE)&wfds,
- (VALUE (*)(VALUE))rb_fd_term, (VALUE)&wfds);
-#else
+ FD_ZERO(&wfds);
+ FD_SET(f, &wfds);
rb_thread_select(f + 1, NULL, &wfds, NULL, NULL);
-#endif
return Qtrue;
default:
@@ -636,60 +424,48 @@ rb_io_wait_writable(int f)
}
}
+#ifndef S_ISREG
+# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
+#endif
+
+static int
+wsplit_p(rb_io_t *fptr)
+{
+ FILE *f = GetWriteFile(fptr);
+#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
+ int r;
+#endif
+
+ if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) {
+ struct stat buf;
+ if (fstat(fileno(f), &buf) == 0 &&
+ !S_ISREG(buf.st_mode)
+#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
+ && (r = fcntl(fileno(f), F_GETFL)) != -1 &&
+ !(r & O_NONBLOCK)
+#endif
+ ) {
+ fptr->mode |= FMODE_WSPLIT;
+ }
+ fptr->mode |= FMODE_WSPLIT_INITIALIZED;
+ }
+ return fptr->mode & FMODE_WSPLIT;
+}
+
/* writing functions */
static long
-io_fwrite(VALUE str, rb_io_t *fptr)
+io_fwrite(str, fptr)
+ VALUE str;
+ rb_io_t *fptr;
{
long len, n, r, l, offset = 0;
+ FILE *f = GetWriteFile(fptr);
- /*
- * If an external encoding was specified and it differs from
- * the strings encoding then we must transcode before writing.
- * We must also transcode if two encodings were specified
- */
- if (fptr->enc) {
- /* transcode str before output */
- /* the methods in transcode.c are static, so call indirectly */
- /* Can't use encode! because puts writes a frozen newline */
- if (fptr->enc2) {
- str = rb_funcall(str, id_encode, 2,
- rb_enc_from_encoding(fptr->enc2),
- rb_enc_from_encoding(fptr->enc));
- }
- else {
- str = rb_funcall(str, id_encode, 1,
- rb_enc_from_encoding(fptr->enc));
- }
- }
-
- len = RSTRING_LEN(str);
+ len = RSTRING(str)->len;
if ((n = len) <= 0) return n;
- if (fptr->wbuf == NULL && !(fptr->mode & FMODE_SYNC)) {
- fptr->wbuf_off = 0;
- fptr->wbuf_len = 0;
- fptr->wbuf_capa = 8192;
- fptr->wbuf = ALLOC_N(char, fptr->wbuf_capa);
- }
- if ((fptr->mode & FMODE_SYNC) ||
- (fptr->wbuf && fptr->wbuf_capa <= fptr->wbuf_len + len) ||
- ((fptr->mode & FMODE_TTY) && memchr(RSTRING_PTR(str)+offset, '\n', len))) {
- /* xxx: use writev to avoid double write if available */
- if (fptr->wbuf_len && fptr->wbuf_len+len <= fptr->wbuf_capa) {
- if (fptr->wbuf_capa < fptr->wbuf_off+fptr->wbuf_len+len) {
- MEMMOVE(fptr->wbuf, fptr->wbuf+fptr->wbuf_off, char, fptr->wbuf_len);
- fptr->wbuf_off = 0;
- }
- MEMMOVE(fptr->wbuf+fptr->wbuf_off+fptr->wbuf_len, RSTRING_PTR(str)+offset, char, len);
- fptr->wbuf_len += len;
- n = 0;
- }
- if (io_fflush(fptr) < 0)
- return -1L;
- if (n == 0)
- return len;
- /* avoid context switch between "a" and "\n" in STDERR.puts "a".
- [ruby-dev:25080] */
- if (fptr->stdio_file != stderr && !rb_thread_fd_writable(fptr->fd)) {
+ if (fptr->mode & FMODE_SYNC) {
+ io_fflush(f, fptr);
+ if (!rb_thread_fd_writable(fileno(f))) {
rb_io_check_closed(fptr);
}
retry:
@@ -700,39 +476,70 @@ io_fwrite(VALUE str, rb_io_t *fptr)
wsplit_p(fptr)) {
l = PIPE_BUF;
}
- r = rb_write_internal(fptr->fd, RSTRING_PTR(str)+offset, l);
- /* xxx: signal handler may modify given string. */
+ TRAP_BEG;
+ r = write(fileno(f), RSTRING(str)->ptr+offset, l);
+ TRAP_END;
if (r == n) return len;
if (0 <= r) {
offset += r;
n -= r;
errno = EAGAIN;
}
- if (rb_io_wait_writable(fptr->fd)) {
+ if (rb_io_wait_writable(fileno(f))) {
rb_io_check_closed(fptr);
- if (offset < RSTRING_LEN(str))
+ if (offset < RSTRING(str)->len)
goto retry;
}
return -1L;
}
-
- if (fptr->wbuf_off) {
- if (fptr->wbuf_len)
- MEMMOVE(fptr->wbuf, fptr->wbuf+fptr->wbuf_off, char, fptr->wbuf_len);
- fptr->wbuf_off = 0;
+#if defined(__human68k__) || defined(__vms)
+ do {
+ if (fputc(RSTRING(str)->ptr[offset++], f) == EOF) {
+ if (ferror(f)) return -1L;
+ break;
+ }
+ } while (--n > 0);
+#else
+ while (errno = 0, offset += (r = fwrite(RSTRING(str)->ptr+offset, 1, n, f)), (n -= r) > 0) {
+ if (ferror(f)
+#if defined __BORLANDC__
+ || errno
+#endif
+ ) {
+#ifdef __hpux
+ if (!errno) errno = EAGAIN;
+#elif defined(_WIN32) && !defined(__BORLANDC__)
+ /* workaround for MSVCRT's bug */
+ if (!errno) {
+ if (GetLastError() == ERROR_NO_DATA)
+ errno = EPIPE;
+ else
+ errno = EBADF;
+ }
+#endif
+ if (rb_io_wait_writable(fileno(f))) {
+ rb_io_check_closed(fptr);
+ clearerr(f);
+ if (offset < RSTRING(str)->len)
+ continue;
+ }
+ return -1L;
+ }
}
- MEMMOVE(fptr->wbuf+fptr->wbuf_off+fptr->wbuf_len, RSTRING_PTR(str)+offset, char, len);
- fptr->wbuf_len += len;
- return len;
+#endif
+ return len - n;
}
long
-rb_io_fwrite(const char *ptr, long len, FILE *f)
+rb_io_fwrite(ptr, len, f)
+ const char *ptr;
+ long len;
+ FILE *f;
{
rb_io_t of;
- of.fd = fileno(f);
- of.stdio_file = f;
+ of.f = f;
+ of.f2 = NULL;
of.mode = FMODE_WRITABLE;
of.path = NULL;
return io_fwrite(rb_str_new(ptr, len), &of);
@@ -741,50 +548,53 @@ rb_io_fwrite(const char *ptr, long len, FILE *f)
/*
* call-seq:
* ios.write(string) => integer
- *
+ *
* Writes the given string to <em>ios</em>. The stream must be opened
* for writing. If the argument is not a string, it will be converted
* to a string using <code>to_s</code>. Returns the number of bytes
* written.
- *
+ *
* count = $stdout.write( "This is a test\n" )
* puts "That was #{count} bytes of data"
- *
+ *
* <em>produces:</em>
- *
+ *
* This is a test
* That was 15 bytes of data
*/
static VALUE
-io_write(VALUE io, VALUE str)
+io_write(io, str)
+ VALUE io, str;
{
rb_io_t *fptr;
long n;
- VALUE tmp;
rb_secure(4);
- io = GetWriteIO(io);
- str = rb_obj_as_string(str);
- tmp = rb_io_check_io(io);
- if (NIL_P(tmp)) {
+ if (TYPE(str) != T_STRING)
+ str = rb_obj_as_string(str);
+
+ if (TYPE(io) != T_FILE) {
/* port is not IO, call write method for it. */
return rb_funcall(io, id_write, 1, str);
}
- io = tmp;
- if (RSTRING_LEN(str) == 0) return INT2FIX(0);
+ if (RSTRING(str)->len == 0) return INT2FIX(0);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
n = io_fwrite(str, fptr);
if (n == -1L) rb_sys_fail(fptr->path);
+ if (!(fptr->mode & FMODE_SYNC)) {
+ fptr->mode |= FMODE_WBUF;
+ }
return LONG2FIX(n);
}
VALUE
-rb_io_write(VALUE io, VALUE str)
+rb_io_write(io, str)
+ VALUE io, str;
{
return rb_funcall(io, id_write, 1, str);
}
@@ -792,21 +602,21 @@ rb_io_write(VALUE io, VALUE str)
/*
* call-seq:
* ios << obj => ios
- *
+ *
* String Output---Writes <i>obj</i> to <em>ios</em>.
* <i>obj</i> will be converted to a string using
* <code>to_s</code>.
- *
+ *
* $stdout << "Hello " << "world!\n"
- *
+ *
* <em>produces:</em>
- *
+ *
* Hello world!
*/
-
VALUE
-rb_io_addstr(VALUE io, VALUE str)
+rb_io_addstr(io, str)
+ VALUE io, str;
{
rb_io_write(io, str);
return io;
@@ -815,37 +625,31 @@ rb_io_addstr(VALUE io, VALUE str)
/*
* call-seq:
* ios.flush => ios
- *
+ *
* Flushes any buffered data within <em>ios</em> to the underlying
* operating system (note that this is Ruby internal buffering only;
* the OS may buffer the data as well).
- *
+ *
* $stdout.print "no newline"
* $stdout.flush
- *
+ *
* <em>produces:</em>
- *
+ *
* no newline
*/
-VALUE
-rb_io_flush(VALUE io)
+static VALUE
+rb_io_flush(io)
+ VALUE io;
{
rb_io_t *fptr;
+ FILE *f;
- if (TYPE(io) != T_FILE) {
- return rb_funcall(io, id_flush, 0);
- }
-
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
+ rb_io_check_writable(fptr);
+ f = GetWriteFile(fptr);
- if (fptr->mode & FMODE_WRITABLE) {
- io_fflush(fptr);
- }
- if (fptr->mode & FMODE_READABLE) {
- io_unread(fptr);
- }
+ io_fflush(f, fptr);
return io;
}
@@ -854,9 +658,9 @@ rb_io_flush(VALUE io)
* call-seq:
* ios.pos => integer
* ios.tell => integer
- *
+ *
* Returns the current offset (in bytes) of <em>ios</em>.
- *
+ *
* f = File.new("testfile")
* f.pos #=> 0
* f.gets #=> "This is line one\n"
@@ -864,7 +668,8 @@ rb_io_flush(VALUE io)
*/
static VALUE
-rb_io_tell(VALUE io)
+rb_io_tell(io)
+ VALUE io;
{
rb_io_t *fptr;
off_t pos;
@@ -876,7 +681,9 @@ rb_io_tell(VALUE io)
}
static VALUE
-rb_io_seek(VALUE io, VALUE offset, int whence)
+rb_io_seek(io, offset, whence)
+ VALUE io, offset;
+ int whence;
{
rb_io_t *fptr;
off_t pos;
@@ -885,6 +692,7 @@ rb_io_seek(VALUE io, VALUE offset, int whence)
GetOpenFile(io, fptr);
pos = io_seek(fptr, pos, whence);
if (pos < 0 && errno) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
return INT2FIX(0);
}
@@ -892,26 +700,29 @@ rb_io_seek(VALUE io, VALUE offset, int whence)
/*
* call-seq:
* ios.seek(amount, whence=SEEK_SET) -> 0
- *
+ *
* Seeks to a given offset <i>anInteger</i> in the stream according to
* the value of <i>whence</i>:
*
* IO::SEEK_CUR | Seeks to _amount_ plus current position
* --------------+----------------------------------------------------
- * IO::SEEK_END | Seeks to _amount_ plus end of stream (you probably
+ * IO::SEEK_END | Seeks to _amount_ plus end of stream (you probably
* | want a negative value for _amount_)
* --------------+----------------------------------------------------
* IO::SEEK_SET | Seeks to the absolute location given by _amount_
*
* Example:
- *
+ *
* f = File.new("testfile")
* f.seek(-13, IO::SEEK_END) #=> 0
* f.readline #=> "And so on...\n"
*/
static VALUE
-rb_io_seek_m(int argc, VALUE *argv, VALUE io)
+rb_io_seek_m(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
VALUE offset, ptrname;
int whence = SEEK_SET;
@@ -926,16 +737,17 @@ rb_io_seek_m(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* ios.pos = integer => integer
- *
+ *
* Seeks to the given position (in bytes) in <em>ios</em>.
- *
+ *
* f = File.new("testfile")
* f.pos = 17
* f.gets #=> "This is line two\n"
*/
static VALUE
-rb_io_set_pos(VALUE io, VALUE offset)
+rb_io_set_pos(io, offset)
+ VALUE io, offset;
{
rb_io_t *fptr;
off_t pos;
@@ -943,7 +755,8 @@ rb_io_set_pos(VALUE io, VALUE offset)
pos = NUM2OFFT(offset);
GetOpenFile(io, fptr);
pos = io_seek(fptr, pos, SEEK_SET);
- if (pos < 0) rb_sys_fail(fptr->path);
+ if (pos != 0) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
return OFFT2NUM(pos);
}
@@ -951,10 +764,10 @@ rb_io_set_pos(VALUE io, VALUE offset)
/*
* call-seq:
* ios.rewind => 0
- *
+ *
* Positions <em>ios</em> to the beginning of input, resetting
* <code>lineno</code> to zero.
- *
+ *
* f = File.new("testfile")
* f.readline #=> "This is line one\n"
* f.rewind #=> 0
@@ -963,12 +776,14 @@ rb_io_set_pos(VALUE io, VALUE offset)
*/
static VALUE
-rb_io_rewind(VALUE io)
+rb_io_rewind(io)
+ VALUE io;
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
- if (io_seek(fptr, 0L, 0) < 0) rb_sys_fail(fptr->path);
+ if (io_seek(fptr, 0L, 0) != 0) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
if (io == current_file) {
gets_lineno -= fptr->lineno;
}
@@ -977,35 +792,6 @@ rb_io_rewind(VALUE io)
return INT2FIX(0);
}
-static int
-io_fillbuf(rb_io_t *fptr)
-{
- int r;
-
- if (fptr->rbuf == NULL) {
- fptr->rbuf_off = 0;
- fptr->rbuf_len = 0;
- fptr->rbuf_capa = 8192;
- fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
- }
- if (fptr->rbuf_len == 0) {
- retry:
- {
- r = rb_read_internal(fptr->fd, fptr->rbuf, fptr->rbuf_capa);
- }
- if (r < 0) {
- if (rb_io_wait_readable(fptr->fd))
- goto retry;
- rb_sys_fail(fptr->path);
- }
- fptr->rbuf_off = 0;
- fptr->rbuf_len = r;
- if (r == 0)
- return -1; /* EOF */
- }
- return 0;
-}
-
/*
* call-seq:
* ios.eof => true or false
@@ -1039,40 +825,51 @@ io_fillbuf(rb_io_t *fptr)
*/
VALUE
-rb_io_eof(VALUE io)
+rb_io_eof(io)
+ VALUE io;
{
rb_io_t *fptr;
+ int ch;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- if (READ_DATA_PENDING(fptr)) return Qfalse;
- READ_CHECK(fptr);
- if (io_fillbuf(fptr) < 0) {
- return Qtrue;
+ if (feof(fptr->f)) return Qtrue;
+ if (READ_DATA_PENDING(fptr->f)) return Qfalse;
+ READ_CHECK(fptr->f);
+ clearerr(fptr->f);
+ TRAP_BEG;
+ ch = getc(fptr->f);
+ TRAP_END;
+
+ if (ch != EOF) {
+ ungetc(ch, fptr->f);
+ return Qfalse;
}
- return Qfalse;
+ rb_io_check_closed(fptr);
+ clearerr(fptr->f);
+ return Qtrue;
}
/*
* call-seq:
* ios.sync => true or false
- *
+ *
* Returns the current ``sync mode'' of <em>ios</em>. When sync mode is
* true, all output is immediately flushed to the underlying operating
* system and is not buffered by Ruby internally. See also
* <code>IO#fsync</code>.
- *
+ *
* f = File.new("testfile")
* f.sync #=> false
*/
static VALUE
-rb_io_sync(VALUE io)
+rb_io_sync(io)
+ VALUE io;
{
rb_io_t *fptr;
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
return (fptr->mode & FMODE_SYNC) ? Qtrue : Qfalse;
}
@@ -1080,24 +877,24 @@ rb_io_sync(VALUE io)
/*
* call-seq:
* ios.sync = boolean => boolean
- *
+ *
* Sets the ``sync mode'' to <code>true</code> or <code>false</code>.
* When sync mode is true, all output is immediately flushed to the
* underlying operating system and is not buffered internally. Returns
* the new state. See also <code>IO#fsync</code>.
- *
+ *
* f = File.new("testfile")
* f.sync = true
- *
+ *
* <em>(produces no output)</em>
*/
static VALUE
-rb_io_set_sync(VALUE io, VALUE mode)
+rb_io_set_sync(io, mode)
+ VALUE io, mode;
{
rb_io_t *fptr;
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
if (RTEST(mode)) {
fptr->mode |= FMODE_SYNC;
@@ -1111,7 +908,7 @@ rb_io_set_sync(VALUE io, VALUE mode)
/*
* call-seq:
* ios.fsync => 0 or nil
- *
+ *
* Immediately writes all buffered data in <em>ios</em> to disk.
* Returns <code>nil</code> if the underlying operating system does not
* support <em>fsync(2)</em>. Note that <code>fsync</code> differs from
@@ -1121,16 +918,18 @@ rb_io_set_sync(VALUE io, VALUE mode)
*/
static VALUE
-rb_io_fsync(VALUE io)
+rb_io_fsync(io)
+ VALUE io;
{
#ifdef HAVE_FSYNC
rb_io_t *fptr;
+ FILE *f;
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
+ f = GetWriteFile(fptr);
- io_fflush(fptr);
- if (fsync(fptr->fd) < 0)
+ io_fflush(f, fptr);
+ if (fsync(fileno(f)) < 0)
rb_sys_fail(fptr->path);
return INT2FIX(0);
#else
@@ -1143,48 +942,49 @@ rb_io_fsync(VALUE io)
* call-seq:
* ios.fileno => fixnum
* ios.to_i => fixnum
- *
+ *
* Returns an integer representing the numeric file descriptor for
* <em>ios</em>.
- *
+ *
* $stdin.fileno #=> 0
* $stdout.fileno #=> 1
*/
static VALUE
-rb_io_fileno(VALUE io)
+rb_io_fileno(io)
+ VALUE io;
{
rb_io_t *fptr;
int fd;
GetOpenFile(io, fptr);
- fd = fptr->fd;
+ fd = fileno(fptr->f);
return INT2FIX(fd);
}
-
/*
* call-seq:
* ios.pid => fixnum
- *
+ *
* Returns the process ID of a child process associated with
* <em>ios</em>. This will be set by <code>IO::popen</code>.
- *
+ *
* pipe = IO.popen("-")
* if pipe
* $stderr.puts "In parent, child pid is #{pipe.pid}"
* else
* $stderr.puts "In child, pid is #{$$}"
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* In child, pid is 26209
* In parent, child pid is 26209
*/
static VALUE
-rb_io_pid(VALUE io)
+rb_io_pid(io)
+ VALUE io;
{
rb_io_t *fptr;
@@ -1194,7 +994,6 @@ rb_io_pid(VALUE io)
return INT2FIX(fptr->pid);
}
-
/*
* call-seq:
* ios.inspect => string
@@ -1203,137 +1002,165 @@ rb_io_pid(VALUE io)
*/
static VALUE
-rb_io_inspect(VALUE obj)
+rb_io_inspect(obj)
+ VALUE obj;
{
rb_io_t *fptr;
- char *cname;
- const char *st = "";
+ char *buf;
+ const char *cname, *st = "";
+ long len;
fptr = RFILE(rb_io_taint_check(obj))->fptr;
if (!fptr || !fptr->path) return rb_any_to_s(obj);
cname = rb_obj_classname(obj);
- if (fptr->fd < 0) {
+ len = strlen(cname) + strlen(fptr->path) + 5;
+ if (!(fptr->f || fptr->f2)) {
st = " (closed)";
+ len += 9;
}
- return rb_sprintf("#<%s:%s%s>", cname, fptr->path, st);
+ buf = ALLOCA_N(char, len);
+ snprintf(buf, len, "#<%s:%s%s>", cname, fptr->path, st);
+ return rb_str_new2(buf);
}
/*
* call-seq:
* ios.to_io -> ios
- *
+ *
* Returns <em>ios</em>.
*/
static VALUE
-rb_io_to_io(VALUE io)
+rb_io_to_io(io)
+ VALUE io;
{
return io;
}
/* reading functions */
static long
-read_buffered_data(char *ptr, long len, rb_io_t *fptr)
+read_buffered_data(ptr, len, f)
+ char *ptr;
+ long len;
+ FILE *f;
{
long n;
- n = READ_DATA_PENDING_COUNT(fptr);
+#ifdef READ_DATA_PENDING_COUNT
+ n = READ_DATA_PENDING_COUNT(f);
if (n <= 0) return 0;
if (n > len) n = len;
- MEMMOVE(ptr, fptr->rbuf+fptr->rbuf_off, char, n);
- fptr->rbuf_off += n;
- fptr->rbuf_len -= n;
+ return fread(ptr, 1, n, f);
+#else
+ int c;
+
+ for (n = 0; n < len && READ_DATA_PENDING(f) && (c = getc(f)) != EOF; ++n) {
+ *ptr++ = c;
+ }
return n;
+#endif
}
static long
-io_fread(VALUE str, long offset, rb_io_t *fptr)
+io_fread(ptr, len, fptr)
+ char *ptr;
+ long len;
+ rb_io_t *fptr;
{
- long len = RSTRING_LEN(str) - offset;
long n = len;
int c;
+ int saved_errno;
while (n > 0) {
- c = read_buffered_data(RSTRING_PTR(str)+offset, n, fptr);
- if (c > 0) {
- offset += c;
- if ((n -= c) <= 0) break;
- }
- rb_thread_wait_fd(fptr->fd);
- rb_io_check_closed(fptr);
- if (io_fillbuf(fptr) < 0) {
+ c = read_buffered_data(ptr, n, fptr->f);
+ if (c < 0) goto eof;
+ if (c > 0) {
+ ptr += c;
+ if ((n -= c) <= 0) break;
+ }
+ rb_thread_wait_fd(fileno(fptr->f));
+ rb_io_check_closed(fptr);
+ clearerr(fptr->f);
+ TRAP_BEG;
+ c = getc(fptr->f);
+ TRAP_END;
+ if (c == EOF) {
+ eof:
+ if (ferror(fptr->f)) {
+ switch (errno) {
+ case EINTR:
+#if defined(ERESTART)
+ case ERESTART:
+#endif
+ clearerr(fptr->f);
+ continue;
+ case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ if (len > n) {
+ clearerr(fptr->f);
+ }
+ saved_errno = errno;
+ rb_warning("nonblocking IO#read is obsolete; use IO#readpartial or IO#sysread");
+ errno = saved_errno;
+ }
+ if (len == n) return 0;
+ }
break;
}
+ *ptr++ = c;
+ n--;
}
return len - n;
}
long
-rb_io_fread(char *ptr, long len, FILE *f)
+rb_io_fread(ptr, len, f)
+ char *ptr;
+ long len;
+ FILE *f;
{
rb_io_t of;
- VALUE str;
- long n;
- of.fd = fileno(f);
- of.stdio_file = f;
- of.mode = FMODE_READABLE;
- str = rb_str_new(ptr, len);
- n = io_fread(str, 0, &of);
- MEMCPY(ptr, RSTRING_PTR(str), char, n);
- return n;
+ of.f = f;
+ of.f2 = NULL;
+ return io_fread(ptr, len, &of);
}
#define SMALLBUF 100
static long
-remain_size(rb_io_t *fptr)
+remain_size(fptr)
+ rb_io_t *fptr;
{
struct stat st;
- off_t siz = READ_DATA_PENDING_COUNT(fptr);
+ off_t siz = BUFSIZ;
off_t pos;
- if (fstat(fptr->fd, &st) == 0 && S_ISREG(st.st_mode)
+ if (feof(fptr->f)) return 0;
+ if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)
#ifdef __BEOS__
&& (st.st_dev > 3)
#endif
)
{
- io_fflush(fptr);
- pos = lseek(fptr->fd, 0, SEEK_CUR);
+ pos = io_tell(fptr);
if (st.st_size >= pos && pos >= 0) {
- siz += st.st_size - pos + 1;
+ siz = st.st_size - pos + 1;
if (siz > LONG_MAX) {
rb_raise(rb_eIOError, "file too big for single read");
}
}
}
- else {
- siz += BUFSIZ;
- }
return (long)siz;
}
static VALUE
-io_enc_str(VALUE str, rb_io_t *fptr)
-{
- OBJ_TAINT(str);
- if (fptr->enc2) {
- /* two encodings, so transcode from enc2 to enc */
- /* the methods in transcode.c are static, so call indirectly */
- str = rb_funcall(str, id_encode, 2,
- rb_enc_from_encoding(fptr->enc),
- rb_enc_from_encoding(fptr->enc2));
- }
- else {
- /* just one encoding, so associate it with the string */
- rb_enc_associate(str, io_read_encoding(fptr));
- }
- return str;
-}
-
-static VALUE
-read_all(rb_io_t *fptr, long siz, VALUE str)
+read_all(fptr, siz, str)
+ rb_io_t *fptr;
+ long siz;
+ VALUE str;
{
long bytes = 0;
long n;
@@ -1346,10 +1173,15 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
rb_str_resize(str, siz);
}
for (;;) {
- READ_CHECK(fptr);
- n = io_fread(str, bytes, fptr);
+ rb_str_locktmp(str);
+ READ_CHECK(fptr->f);
+ n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr);
+ rb_str_unlocktmp(str);
if (n == 0 && bytes == 0) {
- break;
+ if (!fptr->f) break;
+ if (feof(fptr->f)) break;
+ if (!ferror(fptr->f)) break;
+ rb_sys_fail(fptr->path);
}
bytes += n;
if (bytes < siz) break;
@@ -1357,15 +1189,16 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
rb_str_resize(str, siz);
}
if (bytes != siz) rb_str_resize(str, bytes);
- return io_enc_str(str, fptr);
+ OBJ_TAINT(str);
+
+ return str;
}
-void
-rb_io_set_nonblock(rb_io_t *fptr)
+void rb_io_set_nonblock(rb_io_t *fptr)
{
int flags;
#ifdef F_GETFL
- flags = fcntl(fptr->fd, F_GETFL);
+ flags = fcntl(fileno(fptr->f), F_GETFL);
if (flags == -1) {
rb_sys_fail(fptr->path);
}
@@ -1374,10 +1207,26 @@ rb_io_set_nonblock(rb_io_t *fptr)
#endif
if ((flags & O_NONBLOCK) == 0) {
flags |= O_NONBLOCK;
- if (fcntl(fptr->fd, F_SETFL, flags) == -1) {
+ if (fcntl(fileno(fptr->f), F_SETFL, flags) == -1) {
rb_sys_fail(fptr->path);
}
}
+ if (fptr->f2) {
+#ifdef F_GETFL
+ flags = fcntl(fileno(fptr->f2), F_GETFL);
+ if (flags == -1) {
+ rb_sys_fail(fptr->path);
+ }
+#else
+ flags = 0;
+#endif
+ if ((flags & O_NONBLOCK) == 0) {
+ flags |= O_NONBLOCK;
+ if (fcntl(fileno(fptr->f2), F_SETFL, flags) == -1) {
+ rb_sys_fail(fptr->path);
+ }
+ }
+ }
}
static VALUE
@@ -1390,15 +1239,15 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
rb_scan_args(argc, argv, "11", &length, &str);
if ((len = NUM2LONG(length)) < 0) {
- rb_raise(rb_eArgError, "negative length %ld given", len);
+ rb_raise(rb_eArgError, "negative length %ld given", len);
}
if (NIL_P(str)) {
- str = rb_str_new(0, len);
+ str = rb_str_new(0, len);
}
else {
- StringValue(str);
- rb_str_modify(str);
+ StringValue(str);
+ rb_str_modify(str);
rb_str_resize(str, len);
}
OBJ_TAINT(str);
@@ -1407,27 +1256,30 @@ io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
rb_io_check_readable(fptr);
if (len == 0)
- return str;
+ return str;
- if (!nonblock)
- READ_CHECK(fptr);
- if (RSTRING_LEN(str) != len) {
+ if (!nonblock) {
+ READ_CHECK(fptr->f);
+ }
+ if (RSTRING(str)->len != len) {
modified:
- rb_raise(rb_eRuntimeError, "buffer string modified");
+ rb_raise(rb_eRuntimeError, "buffer string modified");
}
- n = read_buffered_data(RSTRING_PTR(str), len, fptr);
+ n = read_buffered_data(RSTRING(str)->ptr, len, fptr->f);
if (n <= 0) {
again:
- if (RSTRING_LEN(str) != len) goto modified;
+ if (RSTRING(str)->len != len) goto modified;
if (nonblock) {
rb_io_set_nonblock(fptr);
- n = rb_read_internal(fptr->fd, RSTRING_PTR(str), len);
+ n = read(fileno(fptr->f), RSTRING(str)->ptr, len);
}
else {
- n = rb_read_internal(fptr->fd, RSTRING_PTR(str), len);
- }
+ TRAP_BEG;
+ n = read(fileno(fptr->f), RSTRING(str)->ptr, len);
+ TRAP_END;
+ }
if (n < 0) {
- if (!nonblock && rb_io_wait_readable(fptr->fd))
+ if (!nonblock && rb_io_wait_readable(fileno(fptr->f)))
goto again;
rb_sys_fail(fptr->path);
}
@@ -1558,28 +1410,26 @@ io_read_nonblock(int argc, VALUE *argv, VALUE io)
* The result may also be smaller than string.length (partial write).
* The caller should care such errors and partial write.
*
- * If the write buffer is not empty, it is flushed at first.
- *
*/
static VALUE
rb_io_write_nonblock(VALUE io, VALUE str)
{
rb_io_t *fptr;
+ FILE *f;
long n;
rb_secure(4);
if (TYPE(str) != T_STRING)
str = rb_obj_as_string(str);
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
- io_fflush(fptr);
+ f = GetWriteFile(fptr);
rb_io_set_nonblock(fptr);
- n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
+ n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len);
if (n == -1) rb_sys_fail(fptr->path);
@@ -1602,14 +1452,15 @@ rb_io_write_nonblock(VALUE io, VALUE str)
* <code><i>ios</i>.read(nil)</code> returns <code>""</code>.
* <code><i>ios</i>.read(<i>positive-integer</i>)</code> returns nil.
*
- * <code><i>ios</i>.read(0)</code> returns <code>""</code>.
- *
* f = File.new("testfile")
* f.read(16) #=> "This is line one"
*/
static VALUE
-io_read(int argc, VALUE *argv, VALUE io)
+io_read(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
rb_io_t *fptr;
long n, len;
@@ -1629,7 +1480,7 @@ io_read(int argc, VALUE *argv, VALUE io)
}
if (NIL_P(str)) {
- str = rb_str_new(0, len);
+ str = rb_tainted_str_new(0, len);
}
else {
StringValue(str);
@@ -1639,68 +1490,69 @@ io_read(int argc, VALUE *argv, VALUE io)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
+ if (feof(fptr->f)) return Qnil;
if (len == 0) return str;
- READ_CHECK(fptr);
- if (RSTRING_LEN(str) != len) {
+ rb_str_locktmp(str);
+ READ_CHECK(fptr->f);
+ if (RSTRING(str)->len != len) {
rb_raise(rb_eRuntimeError, "buffer string modified");
}
- n = io_fread(str, 0, fptr);
+ n = io_fread(RSTRING(str)->ptr, len, fptr);
+ rb_str_unlocktmp(str);
if (n == 0) {
- if (fptr->fd < 0) return Qnil;
- rb_str_resize(str, 0);
- return Qnil;
+ if (!fptr->f) return Qnil;
+ if (feof(fptr->f)) {
+ rb_str_resize(str, 0);
+ return Qnil;
+ }
+ if (len > 0) rb_sys_fail(fptr->path);
}
rb_str_resize(str, n);
+ RSTRING(str)->len = n;
+ RSTRING(str)->ptr[n] = '\0';
+ OBJ_TAINT(str);
return str;
}
-static void
-rscheck(const char *rsptr, long rslen, VALUE rs)
-{
- if (!rs) return;
- if (RSTRING_PTR(rs) != rsptr && RSTRING_LEN(rs) != rslen)
- rb_raise(rb_eRuntimeError, "rs modified");
-}
-
static int
-appendline(rb_io_t *fptr, int delim, const char *rsptr, int rslen, VALUE *strp, long *lp)
+appendline(fptr, delim, strp)
+ rb_io_t *fptr;
+ int delim;
+ VALUE *strp;
{
+ FILE *f = fptr->f;
VALUE str = *strp;
int c = EOF;
- long limit = *lp;
-
- if (rsptr == 0)
- rslen = 1;
+#ifndef READ_DATA_PENDING_PTR
+ char buf[8192];
+ char *bp = buf, *bpe = buf + sizeof buf - 3;
+ int update = Qfalse;
+#endif
do {
- long pending = READ_DATA_PENDING_COUNT(fptr);
+#ifdef READ_DATA_PENDING_PTR
+ long pending = READ_DATA_PENDING_COUNT(f);
if (pending > 0) {
- const char *p = READ_DATA_PENDING_PTR(fptr);
- const char *e;
+ const char *p = READ_DATA_PENDING_PTR(f);
+ const char *e = memchr(p, delim, pending);
long last = 0, len = (c != EOF);
-
- if (limit > 0 && pending > limit) pending = limit;
- again:
- e = memchr(p, delim, pending);
if (e) pending = e - p + 1;
len += pending;
if (!NIL_P(str)) {
- last = RSTRING_LEN(str);
+ last = RSTRING(str)->len;
rb_str_resize(str, last + len);
}
else {
*strp = str = rb_str_buf_new(len);
- rb_str_set_len(str, len);
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = '\0';
}
if (c != EOF) {
- RSTRING_PTR(str)[last++] = c;
+ RSTRING(str)->ptr[last++] = c;
}
- read_buffered_data(RSTRING_PTR(str) + last, pending, fptr); /* must not fail */
- limit -= pending;
- *lp = limit;
- if (limit == 0) return RSTRING_PTR(str)[RSTRING_LEN(str)-1];
+ fread(RSTRING(str)->ptr + last, 1, pending, f); /* must not fail */
if (e) return delim;
}
else if (c != EOF) {
@@ -1710,18 +1562,51 @@ appendline(rb_io_t *fptr, int delim, const char *rsptr, int rslen, VALUE *strp,
}
else {
*strp = str = rb_str_buf_new(1);
- rb_str_resize(str, 1);
- RSTRING_PTR(str)[0] = c;
+ RSTRING(str)->ptr[RSTRING(str)->len++] = c;
}
}
- rb_thread_wait_fd(fptr->fd);
+ rb_thread_wait_fd(fileno(f));
rb_io_check_closed(fptr);
- if (io_fillbuf(fptr) < 0) {
- *lp = limit;
+#else
+ READ_CHECK(f);
+#endif
+ clearerr(f);
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+ if (c == EOF) {
+ if (ferror(f)) {
+ clearerr(f);
+ if (!rb_io_wait_readable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ continue;
+ }
+#ifdef READ_DATA_PENDING_PTR
return c;
+#endif
+ }
+#ifndef READ_DATA_PENDING_PTR
+ if (c == EOF || (*bp++ = c) == delim || bp == bpe) {
+ int cnt = bp - buf;
+
+ if (cnt > 0) {
+ if (!NIL_P(str))
+ rb_str_cat(str, buf, cnt);
+ else
+ *strp = str = rb_str_new(buf, cnt);
+ }
+ if (c == EOF) {
+ if (update)
+ return (int)RSTRING(str)->ptr[RSTRING(str)->len-1];
+ return c;
+ }
+ bp = buf;
}
+ update = Qtrue;
+#endif
} while (c != delim);
+#ifdef READ_DATA_PENDING_PTR
{
char ch = c;
if (!NIL_P(str)) {
@@ -1731,121 +1616,97 @@ appendline(rb_io_t *fptr, int delim, const char *rsptr, int rslen, VALUE *strp,
*strp = str = rb_str_new(&ch, 1);
}
}
+#endif
return c;
}
static inline int
-swallow(rb_io_t *fptr, int term)
+swallow(fptr, term)
+ rb_io_t *fptr;
+ int term;
{
+ FILE *f = fptr->f;
+ int c;
+
do {
+#ifdef READ_DATA_PENDING_PTR
long cnt;
- while ((cnt = READ_DATA_PENDING_COUNT(fptr)) > 0) {
+ while ((cnt = READ_DATA_PENDING_COUNT(f)) > 0) {
char buf[1024];
- const char *p = READ_DATA_PENDING_PTR(fptr);
+ const char *p = READ_DATA_PENDING_PTR(f);
int i;
if (cnt > sizeof buf) cnt = sizeof buf;
if (*p != term) return Qtrue;
i = cnt;
while (--i && *++p == term);
- if (!read_buffered_data(buf, cnt - i, fptr)) /* must not fail */
+ if (!fread(buf, 1, cnt - i, f)) /* must not fail */
rb_sys_fail(fptr->path);
}
- rb_thread_wait_fd(fptr->fd);
+ rb_thread_wait_fd(fileno(f));
rb_io_check_closed(fptr);
- } while (io_fillbuf(fptr) == 0);
+#else
+ READ_CHECK(f);
+#endif
+ clearerr(f);
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+ if (c != term) {
+ ungetc(c, f);
+ return Qtrue;
+ }
+ } while (c != EOF);
return Qfalse;
}
static VALUE
-rb_io_getline_fast(rb_io_t *fptr, unsigned char delim, long limit)
+rb_io_getline_fast(fptr, delim)
+ rb_io_t *fptr;
+ unsigned char delim;
{
VALUE str = Qnil;
- int c, nolimit = 0;
+ int c;
- for (;;) {
- c = appendline(fptr, delim, 0, 0, &str, &limit);
- if (c == EOF || c == delim) break;
- if (limit == 0) {
- nolimit = 1;
- break;
- }
- }
+ while ((c = appendline(fptr, delim, &str)) != EOF && c != delim);
if (!NIL_P(str)) {
- str = io_enc_str(str, fptr);
- if (!nolimit) {
- fptr->lineno++;
- lineno = INT2FIX(fptr->lineno);
- }
+ fptr->lineno++;
+ lineno = INT2FIX(fptr->lineno);
+ OBJ_TAINT(str);
}
+
return str;
}
-static void
-prepare_getline_args(int argc, VALUE *argv, VALUE *rsp, long *limit, VALUE io)
+static int
+rscheck(rsptr, rslen, rs)
+ const char *rsptr;
+ long rslen;
+ VALUE rs;
{
- VALUE lim, rs;
- rb_io_t *fptr;
-
- if (argc == 0) {
- rs = rb_rs;
- lim = Qnil;
- }
- else {
- rb_scan_args(argc, argv, "11", &rs, &lim);
- if (NIL_P(lim) && !NIL_P(rs) && TYPE(rs) != T_STRING) {
- VALUE tmp = rb_check_string_type(rs);
-
- if (NIL_P(tmp)) {
- lim = rs;
- rs = rb_rs;
- }
- else {
- rs = tmp;
- }
- }
- }
- GetOpenFile(io, fptr);
- if (!NIL_P(rs)) {
- rb_encoding *enc_rs = rb_enc_get(rs);
- rb_encoding *enc_io = io_read_encoding(fptr);
-
- if (enc_io != enc_rs &&
- (rb_enc_str_coderange(rs) != ENC_CODERANGE_7BIT ||
- !rb_enc_asciicompat(enc_io))) {
- rb_raise(rb_eArgError, "IO and RS encodings differ");
- }
- if (fptr->enc2) {
- rs = rb_funcall(rs, id_encode, 2,
- rb_enc_from_encoding(fptr->enc2),
- rb_enc_from_encoding(fptr->enc));
- }
- }
- *rsp = rs;
- *limit = NIL_P(lim) ? -1L : NUM2LONG(lim);
+ if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
+ rb_raise(rb_eRuntimeError, "rs modified");
+ return 1;
}
+static VALUE rb_io_getline(VALUE rs, VALUE io);
+
static VALUE
-rb_io_getline_1(VALUE rs, long limit, VALUE io)
+rb_io_getline(rs, io)
+ VALUE rs, io;
{
VALUE str = Qnil;
rb_io_t *fptr;
- int nolimit = 0;
- rb_encoding *enc;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- enc = io_input_encoding(fptr);
if (NIL_P(rs)) {
str = read_all(fptr, 0, Qnil);
- if (RSTRING_LEN(str) == 0) return Qnil;
- }
- else if (limit == 0) {
- return rb_enc_str_new(0, 0, io_read_encoding(fptr));
+ if (RSTRING(str)->len == 0) return Qnil;
}
else if (rs == rb_default_rs) {
- return rb_io_getline_fast(fptr, '\n', limit);
+ return rb_io_getline_fast(fptr, '\n');
}
else {
int c, newline;
@@ -1853,39 +1714,25 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
long rslen;
int rspara = 0;
- rslen = RSTRING_LEN(rs);
+ rslen = RSTRING(rs)->len;
if (rslen == 0) {
rsptr = "\n\n";
rslen = 2;
rspara = 1;
swallow(fptr, '\n');
- rs = 0;
}
else if (rslen == 1) {
- return rb_io_getline_fast(fptr, (unsigned char)RSTRING_PTR(rs)[0], limit);
+ return rb_io_getline_fast(fptr, (unsigned char)RSTRING(rs)->ptr[0]);
}
else {
- rsptr = RSTRING_PTR(rs);
+ rsptr = RSTRING(rs)->ptr;
}
newline = rsptr[rslen - 1];
- while ((c = appendline(fptr, newline, rsptr, rslen, &str, &limit)) != EOF) {
- if (c == newline) {
- const char *s, *p, *pp;
-
- if (RSTRING_LEN(str) < rslen) continue;
- s = RSTRING_PTR(str);
- p = s + RSTRING_LEN(str) - rslen;
- pp = rb_enc_left_char_head(s, p, enc);
- if (pp != p) continue;
- if (!rspara) rscheck(rsptr, rslen, rs);
- if (memcmp(p, rsptr, rslen) == 0) break;
- }
- if (limit == 0) {
- nolimit = 1;
- break;
- }
- }
+ while ((c = appendline(fptr, newline, &str)) != EOF &&
+ (c != newline || RSTRING(str)->len < rslen ||
+ ((rspara || rscheck(rsptr,rslen,rs)) && 0) ||
+ memcmp(RSTRING(str)->ptr+RSTRING(str)->len-rslen,rsptr,rslen)));
if (rspara) {
if (c != EOF) {
@@ -1895,63 +1742,58 @@ rb_io_getline_1(VALUE rs, long limit, VALUE io)
}
if (!NIL_P(str)) {
- str = io_enc_str(str, fptr);
- if (!nolimit) {
- fptr->lineno++;
- lineno = INT2FIX(fptr->lineno);
- }
+ fptr->lineno++;
+ lineno = INT2FIX(fptr->lineno);
+ OBJ_TAINT(str);
}
return str;
}
-static VALUE
-rb_io_getline(int argc, VALUE *argv, VALUE io)
-{
- VALUE rs;
- long limit;
-
- prepare_getline_args(argc, argv, &rs, &limit, io);
- return rb_io_getline_1(rs, limit, io);
-}
-
VALUE
-rb_io_gets(VALUE io)
+rb_io_gets(io)
+ VALUE io;
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- return rb_io_getline_fast(fptr, '\n', 0);
+ return rb_io_getline_fast(fptr, '\n');
}
/*
* call-seq:
- * ios.gets(sep=$/) => string or nil
- * ios.gets(limit) => string or nil
- * ios.gets(sep, limit) => string or nil
- *
+ * ios.gets(sep_string=$/) => string or nil
+ *
* Reads the next ``line'' from the I/O stream; lines are separated by
- * <i>sep</i>. A separator of <code>nil</code> reads the entire
+ * <i>sep_string</i>. A separator of <code>nil</code> reads the entire
* contents, and a zero-length separator reads the input a paragraph at
* a time (two successive newlines in the input separate paragraphs).
* The stream must be opened for reading or an <code>IOError</code>
* will be raised. The line read in will be returned and also assigned
* to <code>$_</code>. Returns <code>nil</code> if called at end of
- * file. If the first argument is an integer, or optional second
- * argument is given, the returning string would not be longer than the
- * given value.
- *
+ * file.
+ *
* File.new("testfile").gets #=> "This is line one\n"
* $_ #=> "This is line one\n"
*/
static VALUE
-rb_io_gets_m(int argc, VALUE *argv, VALUE io)
+rb_io_gets_m(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
- VALUE str;
+ VALUE rs, str;
- str = rb_io_getline(argc, argv, io);
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ if (!NIL_P(rs)) StringValue(rs);
+ }
+ str = rb_io_getline(rs, io);
rb_lastline_set(str);
return str;
@@ -1960,14 +1802,14 @@ rb_io_gets_m(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* ios.lineno => integer
- *
+ *
* Returns the current line number in <em>ios</em>. The stream must be
* opened for reading. <code>lineno</code> counts the number of times
* <code>gets</code> is called, rather than the number of newlines
* encountered. The two values will differ if <code>gets</code> is
* called with a separator other than newline. See also the
* <code>$.</code> variable.
- *
+ *
* f = File.new("testfile")
* f.lineno #=> 0
* f.gets #=> "This is line one\n"
@@ -1977,7 +1819,8 @@ rb_io_gets_m(int argc, VALUE *argv, VALUE io)
*/
static VALUE
-rb_io_lineno(VALUE io)
+rb_io_lineno(io)
+ VALUE io;
{
rb_io_t *fptr;
@@ -1989,10 +1832,10 @@ rb_io_lineno(VALUE io)
/*
* call-seq:
* ios.lineno = integer => integer
- *
+ *
* Manually sets the current line number to the given value.
* <code>$.</code> is updated only on the next read.
- *
+ *
* f = File.new("testfile")
* f.gets #=> "This is line one\n"
* $. #=> 1
@@ -2004,7 +1847,8 @@ rb_io_lineno(VALUE io)
*/
static VALUE
-rb_io_set_lineno(VALUE io, VALUE lineno)
+rb_io_set_lineno(io, lineno)
+ VALUE io, lineno;
{
rb_io_t *fptr;
@@ -2015,14 +1859,18 @@ rb_io_set_lineno(VALUE io, VALUE lineno)
}
static void
-lineno_setter(VALUE val, ID id, VALUE *var)
+lineno_setter(val, id, var)
+ VALUE val;
+ ID id;
+ VALUE *var;
{
gets_lineno = NUM2INT(val);
*var = INT2FIX(gets_lineno);
}
static VALUE
-argf_set_lineno(VALUE argf, VALUE val)
+argf_set_lineno(argf, val)
+ VALUE argf, val;
{
gets_lineno = NUM2INT(val);
lineno = INT2FIX(gets_lineno);
@@ -2030,23 +1878,24 @@ argf_set_lineno(VALUE argf, VALUE val)
}
static VALUE
-argf_lineno(void)
+argf_lineno()
{
return lineno;
}
/*
* call-seq:
- * ios.readline(sep=$/) => string
- * ios.readline(limit) => string
- * ios.readline(sep, limit) => string
- *
+ * ios.readline(sep_string=$/) => string
+ *
* Reads a line as with <code>IO#gets</code>, but raises an
* <code>EOFError</code> on end of file.
*/
static VALUE
-rb_io_readline(int argc, VALUE *argv, VALUE io)
+rb_io_readline(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
VALUE line = rb_io_gets_m(argc, argv, io);
@@ -2058,31 +1907,37 @@ rb_io_readline(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * ios.readlines(sep=$/) => array
- * ios.readlines(limit) => array
- * ios.readlines(sep, limit) => array
- *
+ * ios.readlines(sep_string=$/) => array
+ *
* Reads all of the lines in <em>ios</em>, and returns them in
- * <i>anArray</i>. Lines are separated by the optional <i>sep</i>. If
- * <i>sep</i> is <code>nil</code>, the rest of the stream is returned
- * as a single record. If the first argument is an integer, or
- * optional second argument is given, the returning string would not be
- * longer than the given value. The stream must be opened for reading
- * or an <code>IOError</code> will be raised.
- *
+ * <i>anArray</i>. Lines are separated by the optional
+ * <i>sep_string</i>. If <i>sep_string</i> is <code>nil</code>, the
+ * rest of the stream is returned as a single record.
+ * The stream must be opened for reading or an
+ * <code>IOError</code> will be raised.
+ *
* f = File.new("testfile")
* f.readlines[0] #=> "This is line one\n"
*/
static VALUE
-rb_io_readlines(int argc, VALUE *argv, VALUE io)
+rb_io_readlines(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
- VALUE line, ary, rs;
- long limit;
+ VALUE line, ary;
+ VALUE rs;
- prepare_getline_args(argc, argv, &rs, &limit, io);
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ if (!NIL_P(rs)) StringValue(rs);
+ }
ary = rb_ary_new();
- while (!NIL_P(line = rb_io_getline_1(rs, limit, io))) {
+ while (!NIL_P(line = rb_io_getline(rs, io))) {
rb_ary_push(ary, line);
}
return ary;
@@ -2090,22 +1945,18 @@ rb_io_readlines(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * ios.each(sep=$/) {|line| block } => ios
- * ios.each(limit) {|line| block } => ios
- * ios.each(sep,limit) {|line| block } => ios
- * ios.each_line(sep=$/) {|line| block } => ios
- * ios.each_line(limit) {|line| block } => ios
- * ios.each_line(sep,limit) {|line| block } => ios
- *
+ * ios.each(sep_string=$/) {|line| block } => ios
+ * ios.each_line(sep_string=$/) {|line| block } => ios
+ *
* Executes the block for every line in <em>ios</em>, where lines are
- * separated by <i>sep</i>. <em>ios</em> must be opened for
+ * separated by <i>sep_string</i>. <em>ios</em> must be opened for
* reading or an <code>IOError</code> will be raised.
- *
+ *
* f = File.new("testfile")
* f.each {|line| puts "#{f.lineno}: #{line}" }
- *
+ *
* <em>produces:</em>
- *
+ *
* 1: This is line one
* 2: This is line two
* 3: This is line three
@@ -2113,14 +1964,23 @@ rb_io_readlines(int argc, VALUE *argv, VALUE io)
*/
static VALUE
-rb_io_each_line(int argc, VALUE *argv, VALUE io)
+rb_io_each_line(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
- VALUE str, rs;
- long limit;
+ VALUE str;
+ VALUE rs;
RETURN_ENUMERATOR(io, argc, argv);
- prepare_getline_args(argc, argv, &rs, &limit, io);
- while (!NIL_P(str = rb_io_getline_1(rs, limit, io))) {
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ if (!NIL_P(rs)) StringValue(rs);
+ }
+ while (!NIL_P(str = rb_io_getline(rs, io))) {
rb_yield(str);
}
return io;
@@ -2129,11 +1989,11 @@ rb_io_each_line(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* ios.each_byte {|byte| block } => ios
- *
+ *
* Calls the given block once for each byte (0..255) in <em>ios</em>,
* passing the byte as an argument. The stream must be opened for
* reading or an <code>IOError</code> will be raised.
- *
+ *
* f = File.new("testfile")
* checksum = 0
* f.each_byte {|x| checksum ^= x } #=> #<File:testfile>
@@ -2141,129 +2001,183 @@ rb_io_each_line(int argc, VALUE *argv, VALUE io)
*/
static VALUE
-rb_io_each_byte(VALUE io)
+rb_io_each_byte(io)
+ VALUE io;
{
rb_io_t *fptr;
- char *p, *e;
+ FILE *f;
+ int c;
RETURN_ENUMERATOR(io, 0, 0);
GetOpenFile(io, fptr);
for (;;) {
- p = fptr->rbuf+fptr->rbuf_off;
- e = p + fptr->rbuf_len;
- while (p < e) {
- fptr->rbuf_off++;
- fptr->rbuf_len--;
- rb_yield(INT2FIX(*p & 0xff));
- p++;
- }
rb_io_check_readable(fptr);
- READ_CHECK(fptr);
- if (io_fillbuf(fptr) < 0) {
+ f = fptr->f;
+ READ_CHECK(f);
+ clearerr(f);
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+ if (c == EOF) {
+ if (ferror(f)) {
+ clearerr(f);
+ if (!rb_io_wait_readable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ continue;
+ }
break;
}
+ rb_yield(INT2FIX(c & 0xff));
}
+ if (ferror(f)) rb_sys_fail(fptr->path);
return io;
}
+VALUE rb_io_getc _((VALUE));
+
/*
* call-seq:
- * str.lines(sep=$/) => anEnumerator
- * str.lines(limit) => anEnumerator
- * str.lines(sep, limit) => anEnumerator
- *
- * Returns an enumerator that gives each line in the string.
- *
- * "foo\nbar\n".lines.to_a #=> ["foo\n", "bar\n"]
- * "foo\nb ar".lines.sort #=> ["b ar", "foo\n"]
+ * ios.each_char {|c| block } => ios
+ *
+ * Calls the given block once for each character in <em>ios</em>,
+ * passing the character as an argument. The stream must be opened for
+ * reading or an <code>IOError</code> will be raised. Multibyte
+ * characters are dealt with according to $KCODE.
+ *
+ * f = File.new("testfile")
+ * f.each_char {|c| print c, ' ' } #=> #<File:testfile>
*/
static VALUE
-rb_io_lines(int argc, VALUE *argv, VALUE str)
+rb_io_each_char(io)
+ VALUE io;
{
- return rb_enumeratorize(str, ID2SYM(rb_intern("each_line")), argc, argv);
+ VALUE ch;
+
+ RETURN_ENUMERATOR(io, 0, 0);
+
+ while (!NIL_P(ch = rb_io_getc(io))) {
+ unsigned char c;
+ int n;
+ VALUE str;
+
+ c= FIX2INT(ch);
+ n = mbclen(c);
+ str = rb_tainted_str_new((const char *)&c, 1);
+
+ while (--n > 0) {
+ if (NIL_P(ch = rb_io_getc(io))) {
+ rb_yield(str);
+ return io;
+ }
+ c = FIX2INT(ch);
+ rb_str_cat(str, (const char *)&c, 1);
+ }
+ rb_yield(str);
+ }
+ return io;
}
/*
* call-seq:
- * str.bytes => anEnumerator
- *
- * Returns an enumerator that gives each byte in the string.
+ * ios.lines(sep=$/) => anEnumerator
+ * ios.lines(limit) => anEnumerator
+ * ios.lines(sep, limit) => anEnumerator
+ *
+ * Returns an enumerator that gives each line in <em>ios</em>.
+ * The stream must be opened for reading or an <code>IOError</code>
+ * will be raised.
+ *
+ * f = File.new("testfile")
+ * f.lines.to_a #=> ["foo\n", "bar\n"]
+ * f.rewind
+ * f.lines.sort #=> ["bar\n", "foo\n"]
+ */
+
+static VALUE
+rb_io_lines(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
+{
+ return rb_enumeratorize(io, ID2SYM(rb_intern("each_line")), argc, argv);
+}
+
+/*
+ * call-seq:
+ * ios.bytes => anEnumerator
+ *
+ * Returns an enumerator that gives each byte (0..255) in <em>ios</em>.
+ * The stream must be opened for reading or an <code>IOError</code>
+ * will be raised.
*
- * "hello".bytes.to_a #=> [104, 101, 108, 108, 111]
+ * f = File.new("testfile")
+ * f.bytes.to_a #=> [104, 101, 108, 108, 111]
+ * f.rewind
+ * f.bytes.sort #=> [101, 104, 108, 108, 111]
*/
static VALUE
-rb_io_bytes(VALUE str)
+rb_io_bytes(io)
+ VALUE io;
{
- return rb_enumeratorize(str, ID2SYM(rb_intern("each_byte")), 0, 0);
+ return rb_enumeratorize(io, ID2SYM(rb_intern("each_byte")), 0, 0);
}
/*
* call-seq:
* ios.getc => fixnum or nil
*
- * Reads a one-character string from <em>ios</em>. Returns
+ * Gets the next 8-bit byte (0..255) from <em>ios</em>. Returns
* <code>nil</code> if called at end of file.
*
* f = File.new("testfile")
- * f.getc #=> "8"
- * f.getc #=> "1"
+ * f.getc #=> 84
+ * f.getc #=> 104
*/
-static VALUE
-rb_io_getc(VALUE io)
+VALUE
+rb_io_getc(io)
+ VALUE io;
{
rb_io_t *fptr;
- int r, n;
- VALUE str;
- rb_encoding *enc;
+ FILE *f;
+ int c;
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
+ f = fptr->f;
+
+ retry:
+ READ_CHECK(f);
+ clearerr(f);
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
- enc = io_input_encoding(fptr);
- READ_CHECK(fptr);
- if (io_fillbuf(fptr) < 0) {
+ if (c == EOF) {
+ if (ferror(f)) {
+ clearerr(f);
+ if (!rb_io_wait_readable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ goto retry;
+ }
return Qnil;
}
- r = rb_enc_precise_mbclen(fptr->rbuf+fptr->rbuf_off, fptr->rbuf+fptr->rbuf_off+fptr->rbuf_len, enc);
- if ((n = MBCLEN_CHARFOUND(r)) != 0 && n <= fptr->rbuf_len) {
- str = rb_str_new(fptr->rbuf+fptr->rbuf_off, n);
- fptr->rbuf_off += n;
- fptr->rbuf_len -= n;
- }
- else if (MBCLEN_NEEDMORE(r)) {
- str = rb_str_new(fptr->rbuf+fptr->rbuf_off, fptr->rbuf_len);
- fptr->rbuf_len = 0;
-getc_needmore:
- if (io_fillbuf(fptr) != -1) {
- rb_str_cat(str, fptr->rbuf+fptr->rbuf_off, 1);
- fptr->rbuf_off++;
- fptr->rbuf_len--;
- r = rb_enc_precise_mbclen(RSTRING_PTR(str), RSTRING_PTR(str)+RSTRING_LEN(str), enc);
- if (MBCLEN_NEEDMORE(r)) {
- goto getc_needmore;
- }
- }
- }
- else {
- str = rb_str_new(fptr->rbuf+fptr->rbuf_off, 1);
- fptr->rbuf_off++;
- fptr->rbuf_len--;
- }
- return io_enc_str(str, fptr);
+ return INT2FIX(c & 0xff);
}
int
-rb_getc(FILE *f)
+rb_getc(f)
+ FILE *f;
{
int c;
- if (!STDIO_READ_DATA_PENDING(f)) {
+ if (!READ_DATA_PENDING(f)) {
rb_thread_wait_fd(fileno(f));
}
+ clearerr(f);
TRAP_BEG;
c = getc(f);
TRAP_END;
@@ -2273,76 +2187,17 @@ rb_getc(FILE *f)
/*
* call-seq:
- * ios.readchar => string
- *
- * Reads a one-character string from <em>ios</em>. Raises an
- * <code>EOFError</code> on end of file.
- *
- * f = File.new("testfile")
- * f.readchar #=> "8"
- * f.readchar #=> "1"
- */
-
-static VALUE
-rb_io_readchar(VALUE io)
-{
- VALUE c = rb_io_getc(io);
-
- if (NIL_P(c)) {
- rb_eof_error();
- }
- return c;
-}
-
-/*
- * call-seq:
- * ios.getbyte => fixnum or nil
- *
- * Gets the next 8-bit byte (0..255) from <em>ios</em>. Returns
- * <code>nil</code> if called at end of file.
- *
- * f = File.new("testfile")
- * f.getbyte #=> 84
- * f.getbyte #=> 104
- */
-
-VALUE
-rb_io_getbyte(VALUE io)
-{
- rb_io_t *fptr;
- int c;
-
- GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
- READ_CHECK(fptr);
- if (fptr->fd == 0 && (fptr->mode & FMODE_TTY) && TYPE(rb_stdout) == T_FILE) {
- rb_io_t *ofp;
- GetOpenFile(rb_stdout, ofp);
- if (ofp->mode & FMODE_TTY) {
- rb_io_flush(rb_stdout);
- }
- }
- if (io_fillbuf(fptr) < 0) {
- return Qnil;
- }
- fptr->rbuf_off++;
- fptr->rbuf_len--;
- c = (unsigned char)fptr->rbuf[fptr->rbuf_off-1];
- return INT2FIX(c & 0xff);
-}
-
-/*
- * call-seq:
- * ios.readbyte => fixnum
- *
+ * ios.readchar => fixnum
+ *
* Reads a character as with <code>IO#getc</code>, but raises an
* <code>EOFError</code> on end of file.
*/
static VALUE
-rb_io_readbyte(VALUE io)
+rb_io_readchar(io)
+ VALUE io;
{
- VALUE c = rb_io_getbyte(io);
+ VALUE c = rb_io_getc(io);
if (NIL_P(c)) {
rb_eof_error();
@@ -2352,41 +2207,35 @@ rb_io_readbyte(VALUE io)
/*
* call-seq:
- * ios.ungetc(string) => nil
- *
+ * ios.ungetc(integer) => nil
+ *
* Pushes back one character (passed as a parameter) onto <em>ios</em>,
* such that a subsequent buffered read will return it. Only one character
* may be pushed back before a subsequent read operation (that is,
* you will be able to read only the last of several characters that have been pushed
* back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
- *
+ *
* f = File.new("testfile") #=> #<File:testfile>
- * c = f.getc #=> "8"
+ * c = f.getc #=> 84
* f.ungetc(c) #=> nil
- * f.getc #=> "8"
+ * f.getc #=> 84
*/
VALUE
-rb_io_ungetc(VALUE io, VALUE c)
+rb_io_ungetc(io, c)
+ VALUE io, c;
{
- rb_encoding *enc;
rb_io_t *fptr;
+ int cc = NUM2INT(c);
GetOpenFile(io, fptr);
+ if (!(fptr->mode & FMODE_RBUF))
+ rb_raise(rb_eIOError, "unread stream");
rb_io_check_readable(fptr);
- if (NIL_P(c)) return Qnil;
- enc = io_read_encoding(fptr);
- if (FIXNUM_P(c)) {
- int cc = FIX2INT(c);
- char buf[16];
- rb_enc_mbcput(cc, buf, enc);
- c = rb_str_new(buf, rb_enc_codelen(cc, enc));
- }
- else {
- SafeStringValue(c);
+ if (ungetc(cc, fptr->f) == EOF && cc != EOF) {
+ rb_raise(rb_eIOError, "ungetc failed");
}
- io_ungetc(c, fptr);
return Qnil;
}
@@ -2394,153 +2243,75 @@ rb_io_ungetc(VALUE io, VALUE c)
* call-seq:
* ios.isatty => true or false
* ios.tty? => true or false
- *
+ *
* Returns <code>true</code> if <em>ios</em> is associated with a
* terminal device (tty), <code>false</code> otherwise.
- *
+ *
* File.new("testfile").isatty #=> false
* File.new("/dev/tty").isatty #=> true
*/
static VALUE
-rb_io_isatty(VALUE io)
+rb_io_isatty(io)
+ VALUE io;
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
- if (isatty(fptr->fd) == 0)
+ if (isatty(fileno(fptr->f)) == 0)
return Qfalse;
return Qtrue;
}
-/*
- * call-seq:
- * ios.close_on_exec? => true or false
- *
- * Returns <code>true</code> if <em>ios</em> will be closed on exec.
- *
- * f = open("/dev/null")
- * f.close_on_exec? #=> false
- * f.close_on_exec = true
- * f.close_on_exec? #=> true
- * f.close_on_exec = false
- * f.close_on_exec? #=> false
- */
-
-static VALUE
-rb_io_close_on_exec_p(VALUE io)
-{
-#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
+static void
+fptr_finalize(fptr, noraise)
rb_io_t *fptr;
- VALUE write_io;
- int fd, ret;
-
- write_io = GetWriteIO(io);
- if (io != write_io) {
- GetOpenFile(write_io, fptr);
- if (fptr && 0 <= (fd = fptr->fd)) {
- if ((ret = fcntl(fd, F_GETFD)) == -1) rb_sys_fail(fptr->path);
- if (!(ret & FD_CLOEXEC)) return Qfalse;
- }
- }
-
- GetOpenFile(io, fptr);
- if (fptr && 0 <= (fd = fptr->fd)) {
- if ((ret = fcntl(fd, F_GETFD)) == -1) rb_sys_fail(fptr->path);
- if (!(ret & FD_CLOEXEC)) return Qfalse;
- }
- return Qtrue;
-#else
- rb_notimplement();
- return Qnil; /* not reached */
-#endif
-}
-
-/*
- * call-seq:
- * ios.close_on_exec = bool => true or false
- *
- * Sets a close-on-exec flag.
- *
- * f = open("/dev/null")
- * f.close_on_exec = true
- * system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory
- * f.closed? #=> false
- */
-
-static VALUE
-rb_io_set_close_on_exec(VALUE io, VALUE arg)
+ int noraise;
{
-#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
- int flag = RTEST(arg) ? FD_CLOEXEC : 0;
- rb_io_t *fptr;
- VALUE write_io;
- int fd, ret;
-
- write_io = GetWriteIO(io);
- if (io != write_io) {
- GetOpenFile(write_io, fptr);
- if (fptr && 0 <= (fd = fptr->fd)) {
- if ((ret = fcntl(fptr->fd, F_GETFD)) == -1) rb_sys_fail(fptr->path);
- if ((ret & FD_CLOEXEC) != flag) {
- ret = (ret & ~FD_CLOEXEC) | flag;
- ret = fcntl(fd, F_SETFD, ret);
- if (ret == -1) rb_sys_fail(fptr->path);
- }
- }
-
- }
-
- GetOpenFile(io, fptr);
- if (fptr && 0 <= (fd = fptr->fd)) {
- if ((ret = fcntl(fd, F_GETFD)) == -1) rb_sys_fail(fptr->path);
- if ((ret & FD_CLOEXEC) != flag) {
- ret = (ret & ~FD_CLOEXEC) | flag;
- ret = fcntl(fd, F_SETFD, ret);
- if (ret == -1) rb_sys_fail(fptr->path);
- }
- }
-#else
- rb_notimplement();
-#endif
- return Qnil;
-}
+ int n1 = 0, n2 = 0, f1, f2 = -1;
-#define FMODE_PREP (1<<16)
-#define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
-#define PREP_STDIO_NAME(f) ((f)->path)
-
-static void
-fptr_finalize(rb_io_t *fptr, int noraise)
-{
- if (fptr->wbuf_len) {
- io_fflush(fptr);
- }
- if (IS_PREP_STDIO(fptr) ||
- fptr->fd <= 2) {
- return;
- }
- if (fptr->stdio_file) {
- if (fclose(fptr->stdio_file) < 0 && !noraise) {
- /* fptr->stdio_file is deallocated anyway */
- fptr->stdio_file = 0;
- fptr->fd = -1;
- rb_sys_fail(fptr->path);
- }
+ errno = 0;
+ if (fptr->f2) {
+ f2 = fileno(fptr->f2);
+ while (n2 = 0, fflush(fptr->f2) < 0) {
+ n2 = errno;
+ if (!rb_io_wait_writable(f2)) {
+ break;
+ }
+ if (!fptr->f2) break;
+ }
+ if (fclose(fptr->f2) < 0 && n2 == 0) {
+ n2 = errno;
+ }
+ fptr->f2 = 0;
+ }
+ if (fptr->f) {
+ f1 = fileno(fptr->f);
+ if ((f2 == -1) && (fptr->mode & FMODE_WBUF)) {
+ while (n1 = 0, fflush(fptr->f) < 0) {
+ n1 = errno;
+ if (!rb_io_wait_writable(f1)) break;
+ if (!fptr->f) break;
+ }
+ }
+ if (fclose(fptr->f) < 0 && n1 == 0) {
+ n1 = errno;
+ }
+ fptr->f = 0;
+ if (n1 == EBADF && f1 == f2) {
+ n1 = 0;
+ }
}
- else if (0 <= fptr->fd) {
- if (close(fptr->fd) < 0 && !noraise) {
- /* fptr->fd is still not closed */
- rb_sys_fail(fptr->path);
- }
+ if (!noraise && (n1 || n2)) {
+ errno = (n1 ? n1 : n2);
+ rb_sys_fail(fptr->path);
}
- fptr->fd = -1;
- fptr->stdio_file = 0;
- fptr->mode &= ~(FMODE_READABLE|FMODE_WRITABLE);
}
static void
-rb_io_fptr_cleanup(rb_io_t *fptr, int noraise)
+rb_io_fptr_cleanup(fptr, noraise)
+ rb_io_t *fptr;
+ int noraise;
{
if (fptr->finalize) {
(*fptr->finalize)(fptr, noraise);
@@ -2550,52 +2321,41 @@ rb_io_fptr_cleanup(rb_io_t *fptr, int noraise)
}
}
-int
-rb_io_fptr_finalize(rb_io_t *fptr)
+void
+rb_io_fptr_finalize(fptr)
+ rb_io_t *fptr;
{
- if (!fptr) return 0;
- if (fptr->refcnt <= 0 || --fptr->refcnt) return 0;
+ if (!fptr) return;
if (fptr->path) {
free(fptr->path);
- fptr->path = 0;
- }
- if (0 <= fptr->fd)
- rb_io_fptr_cleanup(fptr, Qtrue);
- if (fptr->rbuf) {
- free(fptr->rbuf);
- fptr->rbuf = 0;
- }
- if (fptr->wbuf) {
- free(fptr->wbuf);
- fptr->wbuf = 0;
}
- free(fptr);
- return 1;
+ if (!fptr->f && !fptr->f2) return;
+ if (fileno(fptr->f) < 3) return;
+
+ rb_io_fptr_cleanup(fptr, Qtrue);
}
VALUE
-rb_io_close(VALUE io)
+rb_io_close(io)
+ VALUE io;
{
rb_io_t *fptr;
- int fd;
- VALUE write_io;
- rb_io_t *write_fptr;
-
- write_io = GetWriteIO(io);
- if (io != write_io) {
- write_fptr = RFILE(write_io)->fptr;
- if (write_fptr && 0 <= write_fptr->fd) {
- rb_io_fptr_cleanup(write_fptr, Qtrue);
- }
- }
+ int fd, fd2;
fptr = RFILE(io)->fptr;
if (!fptr) return Qnil;
- if (fptr->fd < 0) return Qnil;
+ if (fptr->f2) {
+ fd2 = fileno(fptr->f2);
+ }
+ else {
+ if (!fptr->f) return Qnil;
+ fd2 = -1;
+ }
- fd = fptr->fd;
+ fd = fileno(fptr->f);
rb_io_fptr_cleanup(fptr, Qfalse);
rb_thread_fd_close(fd);
+ if (fd2 >= 0) rb_thread_fd_close(fd2);
if (fptr->pid) {
rb_syswait(fptr->pid);
@@ -2608,7 +2368,7 @@ rb_io_close(VALUE io)
/*
* call-seq:
* ios.close => nil
- *
+ *
* Closes <em>ios</em> and flushes any pending writes to the operating
* system. The stream is unavailable for any further data operations;
* an <code>IOError</code> is raised if such an attempt is made. I/O
@@ -2620,7 +2380,8 @@ rb_io_close(VALUE io)
*/
static VALUE
-rb_io_close_m(VALUE io)
+rb_io_close_m(io)
+ VALUE io;
{
if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) {
rb_raise(rb_eSecurityError, "Insecure: can't close");
@@ -2631,13 +2392,15 @@ rb_io_close_m(VALUE io)
}
static VALUE
-io_call_close(VALUE io)
+io_call_close(io)
+ VALUE io;
{
return rb_funcall(io, rb_intern("close"), 0, 0);
}
static VALUE
-io_close(VALUE io)
+io_close(io)
+ VALUE io;
{
return rb_rescue(io_call_close, io, 0, 0);
}
@@ -2645,11 +2408,11 @@ io_close(VALUE io)
/*
* call-seq:
* ios.closed? => true or false
- *
+ *
* Returns <code>true</code> if <em>ios</em> is completely closed (for
* duplex streams, both reader and writer), <code>false</code>
* otherwise.
- *
+ *
* f = File.new("testfile")
* f.close #=> nil
* f.closed? #=> true
@@ -2660,141 +2423,123 @@ io_close(VALUE io)
* f.closed? #=> true
*/
-
static VALUE
-rb_io_closed(VALUE io)
+rb_io_closed(io)
+ VALUE io;
{
rb_io_t *fptr;
- VALUE write_io;
- rb_io_t *write_fptr;
-
- write_io = GetWriteIO(io);
- if (io != write_io) {
- write_fptr = RFILE(write_io)->fptr;
- if (write_fptr && 0 <= write_fptr->fd) {
- return Qfalse;
- }
- }
fptr = RFILE(io)->fptr;
rb_io_check_initialized(fptr);
- return 0 <= fptr->fd ? Qfalse : Qtrue;
+ return (fptr->f || fptr->f2)?Qfalse:Qtrue;
}
/*
* call-seq:
* ios.close_read => nil
- *
+ *
* Closes the read end of a duplex I/O stream (i.e., one that contains
* both a read and a write stream, such as a pipe). Will raise an
* <code>IOError</code> if the stream is not duplexed.
- *
+ *
* f = IO.popen("/bin/sh","r+")
* f.close_read
* f.readlines
- *
+ *
* <em>produces:</em>
- *
+ *
* prog.rb:3:in `readlines': not opened for reading (IOError)
* from prog.rb:3
*/
static VALUE
-rb_io_close_read(VALUE io)
+rb_io_close_read(io)
+ VALUE io;
{
rb_io_t *fptr;
- VALUE write_io;
+ int n;
if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) {
rb_raise(rb_eSecurityError, "Insecure: can't close");
}
GetOpenFile(io, fptr);
- if (is_socket(fptr->fd, fptr->path)) {
-#ifndef SHUT_RD
-# define SHUT_RD 0
-#endif
- if (shutdown(fptr->fd, SHUT_RD) < 0)
- rb_sys_fail(fptr->path);
- fptr->mode &= ~FMODE_READABLE;
- if (!(fptr->mode & FMODE_WRITABLE))
- return rb_io_close(io);
- return Qnil;
+ if (fptr->f2 == 0 && (fptr->mode & FMODE_WRITABLE)) {
+ rb_raise(rb_eIOError, "closing non-duplex IO for reading");
}
-
- write_io = GetWriteIO(io);
- if (io != write_io) {
- fptr_finalize(fptr, Qfalse);
- return Qnil;
+ if (fptr->f2 == 0) {
+ return rb_io_close(io);
}
+ n = fclose(fptr->f);
+ fptr->mode &= ~FMODE_READABLE;
+ fptr->f = fptr->f2;
+ fptr->f2 = 0;
+ if (n != 0) rb_sys_fail(fptr->path);
- if (fptr->mode & FMODE_WRITABLE) {
- rb_raise(rb_eIOError, "closing non-duplex IO for reading");
- }
- return rb_io_close(io);
+ return Qnil;
}
/*
* call-seq:
* ios.close_write => nil
- *
+ *
* Closes the write end of a duplex I/O stream (i.e., one that contains
* both a read and a write stream, such as a pipe). Will raise an
* <code>IOError</code> if the stream is not duplexed.
- *
+ *
* f = IO.popen("/bin/sh","r+")
* f.close_write
* f.print "nowhere"
- *
+ *
* <em>produces:</em>
- *
+ *
* prog.rb:3:in `write': not opened for writing (IOError)
* from prog.rb:3:in `print'
* from prog.rb:3
*/
static VALUE
-rb_io_close_write(VALUE io)
+rb_io_close_write(io)
+ VALUE io;
{
rb_io_t *fptr;
+ int n;
if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) {
rb_raise(rb_eSecurityError, "Insecure: can't close");
}
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
- if (is_socket(fptr->fd, fptr->path)) {
-#ifndef SHUT_WR
-# define SHUT_WR 1
-#endif
- if (shutdown(fptr->fd, SHUT_WR) < 0)
- rb_sys_fail(fptr->path);
- fptr->mode &= ~FMODE_WRITABLE;
- if (!(fptr->mode & FMODE_READABLE))
- return rb_io_close(io);
- return Qnil;
- }
-
- if (fptr->mode & FMODE_READABLE) {
+ if (fptr->f2 == 0 && (fptr->mode & FMODE_READABLE)) {
rb_raise(rb_eIOError, "closing non-duplex IO for writing");
}
- return rb_io_close(io);
+ if (fptr->f2 == 0) {
+ return rb_io_close(io);
+ }
+ n = fclose(fptr->f2);
+ fptr->f2 = 0;
+ fptr->mode &= ~FMODE_WRITABLE;
+ if (n != 0) rb_sys_fail(fptr->path);
+
+ return Qnil;
}
/*
* call-seq:
* ios.sysseek(offset, whence=SEEK_SET) => integer
- *
+ *
* Seeks to a given <i>offset</i> in the stream according to the value
* of <i>whence</i> (see <code>IO#seek</code> for values of
* <i>whence</i>). Returns the new offset into the file.
- *
+ *
* f = File.new("testfile")
* f.sysseek(-13, IO::SEEK_END) #=> 53
* f.sysread(10) #=> "And so on."
*/
static VALUE
-rb_io_sysseek(int argc, VALUE *argv, VALUE io)
+rb_io_sysseek(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
VALUE offset, ptrname;
int whence = SEEK_SET;
@@ -2806,14 +2551,15 @@ rb_io_sysseek(int argc, VALUE *argv, VALUE io)
}
pos = NUM2OFFT(offset);
GetOpenFile(io, fptr);
- if ((fptr->mode & FMODE_READABLE) && READ_DATA_BUFFERED(fptr)) {
+ if ((fptr->mode & FMODE_READABLE) && READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "sysseek for buffered IO");
}
- if ((fptr->mode & FMODE_WRITABLE) && fptr->wbuf_len) {
+ if ((fptr->mode & FMODE_WRITABLE) && (fptr->mode & FMODE_WBUF)) {
rb_warn("sysseek for buffered IO");
}
- pos = lseek(fptr->fd, pos, whence);
+ pos = lseek(fileno(fptr->f), pos, whence);
if (pos == -1) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
return OFFT2NUM(pos);
}
@@ -2821,38 +2567,40 @@ rb_io_sysseek(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* ios.syswrite(string) => integer
- *
+ *
* Writes the given string to <em>ios</em> using a low-level write.
* Returns the number of bytes written. Do not mix with other methods
* that write to <em>ios</em> or you may get unpredictable results.
* Raises <code>SystemCallError</code> on error.
- *
+ *
* f = File.new("out", "w")
* f.syswrite("ABCDEF") #=> 6
*/
static VALUE
-rb_io_syswrite(VALUE io, VALUE str)
+rb_io_syswrite(io, str)
+ VALUE io, str;
{
rb_io_t *fptr;
+ FILE *f;
long n;
rb_secure(4);
if (TYPE(str) != T_STRING)
str = rb_obj_as_string(str);
- io = GetWriteIO(io);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
+ f = GetWriteFile(fptr);
- if (fptr->wbuf_len) {
+ if (fptr->mode & FMODE_WBUF) {
rb_warn("syswrite for buffered IO");
}
- if (!rb_thread_fd_writable(fptr->fd)) {
+ if (!rb_thread_fd_writable(fileno(f))) {
rb_io_check_closed(fptr);
}
TRAP_BEG;
- n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
+ n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len);
TRAP_END;
if (n == -1) rb_sys_fail(fptr->path);
@@ -2862,22 +2610,23 @@ rb_io_syswrite(VALUE io, VALUE str)
/*
* call-seq:
- * ios.sysread(integer[, outbuf]) => string
- *
+ * ios.sysread(integer ) => string
+ *
* Reads <i>integer</i> bytes from <em>ios</em> using a low-level
* read and returns them as a string. Do not mix with other methods
* that read from <em>ios</em> or you may get unpredictable results.
- * If the optional <i>outbuf</i> argument is present, it must reference
- * a String, which will receive the data.
* Raises <code>SystemCallError</code> on error and
* <code>EOFError</code> at end of file.
- *
+ *
* f = File.new("testfile")
* f.sysread(16) #=> "This is line one"
*/
static VALUE
-rb_io_sysread(int argc, VALUE *argv, VALUE io)
+rb_io_sysread(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
VALUE len, str;
rb_io_t *fptr;
@@ -2899,79 +2648,73 @@ rb_io_sysread(int argc, VALUE *argv, VALUE io)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- if (READ_DATA_BUFFERED(fptr)) {
+ if (READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "sysread for buffered IO");
}
+ rb_str_locktmp(str);
- n = fptr->fd;
- rb_thread_wait_fd(fptr->fd);
+ n = fileno(fptr->f);
+ rb_thread_wait_fd(fileno(fptr->f));
rb_io_check_closed(fptr);
- if (RSTRING_LEN(str) != ilen) {
+ if (RSTRING(str)->len != ilen) {
rb_raise(rb_eRuntimeError, "buffer string modified");
}
+ TRAP_BEG;
+ n = read(fileno(fptr->f), RSTRING(str)->ptr, ilen);
+ TRAP_END;
- n = rb_read_internal(fptr->fd, RSTRING_PTR(str), ilen);
-
+ rb_str_unlocktmp(str);
if (n == -1) {
rb_sys_fail(fptr->path);
}
- rb_str_set_len(str, n);
+ rb_str_resize(str, n);
if (n == 0 && ilen > 0) {
rb_eof_error();
}
- rb_str_resize(str, n);
+ RSTRING(str)->len = n;
+ RSTRING(str)->ptr[n] = '\0';
OBJ_TAINT(str);
return str;
}
-VALUE
-rb_io_binmode(VALUE io)
-{
- rb_io_t *fptr;
-
- GetOpenFile(io, fptr);
- if (!(fptr->mode & FMODE_BINMODE) && READ_DATA_BUFFERED(fptr)) {
- rb_raise(rb_eIOError, "buffer already filled with text-mode content");
- }
-#if defined(_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__)
- if (0 <= fptr->fd && setmode(fptr->fd, O_BINARY) == -1)
- rb_sys_fail(fptr->path);
-
-#endif
- fptr->mode |= FMODE_BINMODE;
- fptr->enc = rb_ascii8bit_encoding();
- return io;
-}
-
/*
* call-seq:
* ios.binmode => ios
- *
+ *
* Puts <em>ios</em> into binary mode. This is useful only in
* MS-DOS/Windows environments. Once a stream is in binary mode, it
* cannot be reset to nonbinary mode.
*/
-static VALUE
-rb_io_binmode_m(VALUE io)
+VALUE
+rb_io_binmode(io)
+ VALUE io;
{
#if defined(_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__)
- VALUE write_io;
-#endif
+ rb_io_t *fptr;
- rb_io_binmode(io);
+ GetOpenFile(io, fptr);
+#ifdef __human68k__
+ if (fptr->f)
+ fmode(fptr->f, _IOBIN);
+ if (fptr->f2)
+ fmode(fptr->f2, _IOBIN);
+#else
+ if (fptr->f && setmode(fileno(fptr->f), O_BINARY) == -1)
+ rb_sys_fail(fptr->path);
+ if (fptr->f2 && setmode(fileno(fptr->f2), O_BINARY) == -1)
+ rb_sys_fail(fptr->path);
+#endif
-#if defined(_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__)
- write_io = GetWriteIO(io);
- if (write_io != io)
- rb_io_binmode(write_io);
+ fptr->mode |= FMODE_BINMODE;
#endif
return io;
}
-static const char*
-rb_io_flags_mode(int flags)
+const char*
+rb_io_flags_mode(flags)
+ int flags;
{
#ifdef O_BINARY
# define MODE_BINMODE(a,b) ((flags & FMODE_BINMODE) ? (b) : (a))
@@ -2995,12 +2738,13 @@ rb_io_flags_mode(int flags)
}
return MODE_BINMODE("r+", "rb+");
}
- rb_raise(rb_eArgError, "invalid access modenum %o", flags);
+ rb_raise(rb_eArgError, "illegal access modenum %o", flags);
return NULL; /* not reached */
}
int
-rb_io_mode_flags(const char *mode)
+rb_io_mode_flags(mode)
+ const char *mode;
{
int flags = 0;
const char *m = mode;
@@ -3017,29 +2761,33 @@ rb_io_mode_flags(const char *mode)
break;
default:
error:
- rb_raise(rb_eArgError, "invalid access mode %s", mode);
+ rb_raise(rb_eArgError, "illegal access mode %s", mode);
}
while (*m) {
switch (*m++) {
- case 'b':
+ case 'b':
flags |= FMODE_BINMODE;
break;
- case '+':
+ case '+':
flags |= FMODE_READWRITE;
break;
- default:
+ case ':':
+ /* forward compatibility */
+ rb_warning("encoding options not supported in 1.8: %s", mode);
+ goto end;
+ default:
goto error;
- case ':':
- return flags;
}
}
+ end:
return flags;
}
int
-rb_io_modenum_flags(int mode)
+rb_io_modenum_flags(mode)
+ int mode;
{
int flags = 0;
@@ -3071,7 +2819,8 @@ rb_io_modenum_flags(int mode)
}
static int
-rb_io_mode_modenum(const char *mode)
+rb_io_mode_modenum(mode)
+ const char *mode;
{
int flags = 0;
const char *m = mode;
@@ -3088,33 +2837,37 @@ rb_io_mode_modenum(const char *mode)
break;
default:
error:
- rb_raise(rb_eArgError, "invalid access mode %s", mode);
+ rb_raise(rb_eArgError, "illegal access mode %s", mode);
}
while (*m) {
switch (*m++) {
- case 'b':
+ case 'b':
#ifdef O_BINARY
flags |= O_BINARY;
#endif
break;
- case '+':
+ case '+':
flags = (flags & ~O_ACCMODE) | O_RDWR;
break;
- default:
+ case ':':
+ /* forward compatibility */
+ rb_warning("encoding options not supported in 1.8: %s", mode);
+ goto end;
+ default:
goto error;
- case ':':
- return flags;
}
}
+ end:
return flags;
}
#define MODENUM_MAX 4
static const char*
-rb_io_modenum_mode(int flags)
+rb_io_modenum_mode(flags)
+ int flags;
{
#ifdef O_BINARY
# define MODE_BINARY(a,b) ((flags & O_BINARY) ? (b) : (a))
@@ -3135,88 +2888,23 @@ rb_io_modenum_mode(int flags)
case O_RDWR:
return MODE_BINARY("r+", "rb+");
}
- rb_raise(rb_eArgError, "invalid access modenum %o", flags);
+ rb_raise(rb_eArgError, "illegal access modenum %o", flags);
return NULL; /* not reached */
}
-static void
-mode_enc(rb_io_t *fptr, const char *estr)
-{
- const char *p0, *p1;
- char *enc2name;
- int idx, idx2;
-
- p0 = strrchr(estr, ':');
- if (!p0) p1 = estr;
- else p1 = p0 + 1;
- idx = rb_enc_find_index(p1);
- if (idx >= 0) {
- fptr->enc = rb_enc_from_index(idx);
- }
- else {
- rb_warn("Unsupported encoding %s ignored", p1);
- }
-
- if (p0) {
- enc2name = ALLOCA_N(char, p0-estr+1);
- strncpy(enc2name, estr, p0-estr);
- enc2name[p0-estr] = '\0';
- idx2=rb_enc_find_index(enc2name);
- if (idx2 == idx) {
- rb_warn("Ignoring internal encoding %s: it is identical to external encoding %s",
- enc2name, p1);
- }
- else if (idx2 >= 0) {
- fptr->enc2 = rb_enc_from_index(idx2);
- }
- else {
- rb_warn("Unsupported encoding %s ignored", enc2name);
- }
- }
-}
-
-void
-rb_io_mode_enc(rb_io_t *fptr, const char *mode)
-{
- const char *p = strchr(mode, ':');
- if (p) {
- mode_enc(fptr, p+1);
- }
-}
-
-struct sysopen_struct {
+static int
+rb_sysopen(fname, flags, mode)
char *fname;
- int flag;
+ int flags;
unsigned int mode;
-};
-
-static VALUE
-sysopen_func(void *ptr)
-{
- struct sysopen_struct *data = ptr;
- return (VALUE)open(data->fname, data->flag, data->mode);
-}
-
-static int
-rb_sysopen_internal(char *fname, int flags, unsigned int mode)
-{
- struct sysopen_struct data;
- data.fname = fname;
- data.flag = flags;
- data.mode = mode;
- return (int)rb_thread_blocking_region(sysopen_func, &data, RB_UBF_DFL, 0);
-}
-
-static int
-rb_sysopen(char *fname, int flags, unsigned int mode)
{
int fd;
- fd = rb_sysopen_internal(fname, flags, mode);
+ fd = open(fname, flags, mode);
if (fd < 0) {
if (errno == EMFILE || errno == ENFILE) {
rb_gc();
- fd = rb_sysopen_internal(fname, flags, mode);
+ fd = open(fname, flags, mode);
}
if (fd < 0) {
rb_sys_fail(fname);
@@ -3226,7 +2914,9 @@ rb_sysopen(char *fname, int flags, unsigned int mode)
}
FILE *
-rb_fopen(const char *fname, const char *mode)
+rb_fopen(fname, mode)
+ const char *fname;
+ const char *mode;
{
FILE *file;
@@ -3245,13 +2935,15 @@ rb_fopen(const char *fname, const char *mode)
rb_warn("setvbuf() can't be honoured for %s", fname);
#endif
#ifdef __human68k__
- setmode(fileno(file), O_TEXT);
+ fmode(file, _IOTEXT);
#endif
return file;
}
FILE *
-rb_fdopen(int fd, const char *mode)
+rb_fdopen(fd, mode)
+ int fd;
+ const char *mode;
{
FILE *file;
@@ -3260,11 +2952,11 @@ rb_fdopen(int fd, const char *mode)
#endif
file = fdopen(fd, mode);
if (!file) {
- if (
#if defined(sun)
- errno == 0 ||
+ if (errno == 0 || errno == EMFILE || errno == ENFILE) {
+#else
+ if (errno == EMFILE || errno == ENFILE) {
#endif
- errno == EMFILE || errno == ENFILE) {
rb_gc();
#if defined(sun)
errno = 0;
@@ -3274,14 +2966,14 @@ rb_fdopen(int fd, const char *mode)
if (!file) {
#ifdef _WIN32
if (errno == 0) errno = EINVAL;
-#elif defined(sun)
+#endif
+#if defined(sun)
if (errno == 0) errno = EMFILE;
#endif
rb_sys_fail(0);
}
}
- /* xxx: should be _IONBF? A buffer in FILE may have trouble. */
#ifdef USE_SETVBUF
if (setvbuf(file, NULL, _IOFBF, 0) != 0)
rb_warn("setvbuf() can't be honoured (fd=%d)", fd);
@@ -3289,63 +2981,67 @@ rb_fdopen(int fd, const char *mode)
return file;
}
-static void
-io_check_tty(rb_io_t *fptr)
-{
- if (isatty(fptr->fd))
- fptr->mode |= FMODE_TTY|FMODE_DUPLEX;
-}
-
static VALUE
-rb_file_open_internal(VALUE io, const char *fname, const char *mode)
+rb_file_open_internal(io, fname, mode)
+ VALUE io;
+ const char *fname, *mode;
{
rb_io_t *fptr;
MakeOpenFile(io, fptr);
+
fptr->mode = rb_io_mode_flags(mode);
- rb_io_mode_enc(fptr, mode);
fptr->path = strdup(fname);
- fptr->fd = rb_sysopen(fptr->path, rb_io_mode_modenum(rb_io_flags_mode(fptr->mode)), 0666);
- io_check_tty(fptr);
+ fptr->f = rb_fopen(fptr->path, rb_io_flags_mode(fptr->mode));
return io;
}
VALUE
-rb_file_open(const char *fname, const char *mode)
+rb_file_open(fname, mode)
+ const char *fname, *mode;
{
return rb_file_open_internal(io_alloc(rb_cFile), fname, mode);
}
static VALUE
-rb_file_sysopen_internal(VALUE io, const char *fname, int flags, int mode)
+rb_file_sysopen_internal(io, fname, flags, mode)
+ VALUE io;
+ char *fname;
+ int flags, mode;
{
rb_io_t *fptr;
+ int fd;
+ const char *m;
MakeOpenFile(io, fptr);
fptr->path = strdup(fname);
+ m = rb_io_modenum_mode(flags);
fptr->mode = rb_io_modenum_flags(flags);
- fptr->fd = rb_sysopen(fptr->path, flags, mode);
- io_check_tty(fptr);
+ fd = rb_sysopen(fptr->path, flags, mode);
+ fptr->f = rb_fdopen(fd, m);
return io;
}
VALUE
-rb_file_sysopen(const char *fname, int flags, int mode)
+rb_file_sysopen(fname, flags, mode)
+ const char *fname;
+ int flags, mode;
{
return rb_file_sysopen_internal(io_alloc(rb_cFile), fname, flags, mode);
}
-#if defined(__CYGWIN__) || !defined(HAVE_FORK)
+#if defined (_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__VMS)
static struct pipe_list {
rb_io_t *fptr;
struct pipe_list *next;
} *pipe_list;
static void
-pipe_add_fptr(rb_io_t *fptr)
+pipe_add_fptr(fptr)
+ rb_io_t *fptr;
{
struct pipe_list *list;
@@ -3356,7 +3052,8 @@ pipe_add_fptr(rb_io_t *fptr)
}
static void
-pipe_del_fptr(rb_io_t *fptr)
+pipe_del_fptr(fptr)
+ rb_io_t *fptr;
{
struct pipe_list *list = pipe_list;
struct pipe_list *tmp;
@@ -3379,7 +3076,7 @@ pipe_del_fptr(rb_io_t *fptr)
}
static void
-pipe_atexit(void)
+pipe_atexit _((void))
{
struct pipe_list *list = pipe_list;
struct pipe_list *tmp;
@@ -3391,20 +3088,27 @@ pipe_atexit(void)
}
}
+static void pipe_finalize _((rb_io_t *fptr,int));
+
static void
-pipe_finalize(rb_io_t *fptr, int noraise)
+pipe_finalize(fptr, noraise)
+ rb_io_t *fptr;
+ int noraise;
{
-#if !defined(HAVE_FORK) && !defined(_WIN32)
+#if !defined (__CYGWIN__) && !defined(_WIN32)
+ extern VALUE rb_last_status;
int status;
- if (fptr->stdio_file) {
- status = pclose(fptr->stdio_file);
+ if (fptr->f) {
+ status = pclose(fptr->f);
}
- fptr->fd = -1;
- fptr->stdio_file = 0;
+ if (fptr->f2) {
+ status = pclose(fptr->f2);
+ }
+ fptr->f = fptr->f2 = 0;
#if defined DJGPP
status <<= 8;
#endif
- rb_last_status_set(status, fptr->pid);
+ rb_last_status = INT2FIX(status);
#else
fptr_finalize(fptr, noraise);
#endif
@@ -3413,312 +3117,248 @@ pipe_finalize(rb_io_t *fptr, int noraise)
#endif
void
-rb_io_synchronized(rb_io_t *fptr)
+rb_io_synchronized(fptr)
+ rb_io_t *fptr;
{
- rb_io_check_initialized(fptr);
fptr->mode |= FMODE_SYNC;
}
void
-rb_io_unbuffered(rb_io_t *fptr)
+rb_io_unbuffered(fptr)
+ rb_io_t *fptr;
{
rb_io_synchronized(fptr);
}
-#ifdef HAVE_FORK
-struct popen_arg {
- struct rb_exec_arg exec;
- int modef;
- int pair[2];
- int write_pair[2];
-};
-
-static void
-popen_redirect(struct popen_arg *p)
-{
- if ((p->modef & FMODE_READABLE) && (p->modef & FMODE_WRITABLE)) {
- close(p->write_pair[1]);
- if (p->write_pair[0] != 0) {
- dup2(p->write_pair[0], 0);
- close(p->write_pair[0]);
- }
- close(p->pair[0]);
- if (p->pair[1] != 1) {
- dup2(p->pair[1], 1);
- close(p->pair[1]);
- }
- }
- else if (p->modef & FMODE_READABLE) {
- close(p->pair[0]);
- if (p->pair[1] != 1) {
- dup2(p->pair[1], 1);
- close(p->pair[1]);
- }
- }
- else {
- close(p->pair[1]);
- if (p->pair[0] != 0) {
- dup2(p->pair[0], 0);
- close(p->pair[0]);
- }
- }
-}
-
-static int
-popen_exec(void *pp)
-{
- struct popen_arg *p = (struct popen_arg*)pp;
- int fd;
-
- rb_thread_atfork();
- popen_redirect(p);
- for (fd = 3; fd < NOFILE; fd++) {
-#ifdef FD_CLOEXEC
- if (fcntl(fd, F_GETFD) & FD_CLOEXEC) continue;
-#endif
- close(fd);
- }
- return rb_exec(&p->exec);
-}
-#endif
+static VALUE pipe_open(VALUE pstr, const char *pname, const char *mode);
static VALUE
-pipe_open(const char *cmd, int argc, VALUE *argv, const char *mode)
+pipe_open(pstr, pname, mode)
+ VALUE pstr;
+ const char *pname, *mode;
{
int modef = rb_io_mode_flags(mode);
- int pid = 0;
rb_io_t *fptr;
- VALUE port;
- rb_io_t *write_fptr;
- VALUE write_port;
-#if defined(HAVE_FORK)
- int status;
- struct popen_arg arg;
-#elif defined(_WIN32)
- int openmode = rb_io_mode_modenum(mode);
- const char *exename = NULL;
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
+ FILE *f;
+#else
+ int pid;
+#ifdef _WIN32
+ FILE *fpr, *fpw;
+#else
+ int pr[2], pw[2];
#endif
- FILE *fp = 0;
- int fd = -1;
- int write_fd = -1;
-
-#if defined(HAVE_FORK)
- arg.modef = modef;
- arg.pair[0] = arg.pair[1] = -1;
- arg.write_pair[0] = arg.write_pair[1] = -1;
- switch (modef & (FMODE_READABLE|FMODE_WRITABLE)) {
- case FMODE_READABLE|FMODE_WRITABLE:
- if (pipe(arg.write_pair) < 0)
- rb_sys_fail(cmd);
- if (pipe(arg.pair) < 0) {
- int e = errno;
- close(arg.write_pair[0]);
- close(arg.write_pair[1]);
- errno = e;
- rb_sys_fail(cmd);
- }
- break;
- case FMODE_READABLE:
- if (pipe(arg.pair) < 0)
- rb_sys_fail(cmd);
- break;
- case FMODE_WRITABLE:
- if (pipe(arg.pair) < 0)
- rb_sys_fail(cmd);
- break;
- default:
- rb_sys_fail(cmd);
- }
- if (cmd) {
- arg.exec.argc = argc;
- arg.exec.argv = argv;
- arg.exec.prog = cmd;
- pid = rb_fork(&status, popen_exec, &arg);
+#endif
+ volatile int doexec;
+
+ if (!pname) pname = StringValueCStr(pstr);
+ doexec = (strcmp("-", pname) != 0);
+
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS) || defined(_WIN32)
+ if (!doexec) {
+ rb_raise(rb_eNotImpError,
+ "fork() function is unimplemented on this machine");
}
+#endif
+
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
+ f = popen(pname, mode);
+
+ if (!f) rb_sys_fail(pname);
else {
- fflush(stdin); /* is it really needed? */
- rb_io_flush(rb_stdout);
- rb_io_flush(rb_stderr);
- pid = rb_fork(&status, 0, 0);
- if (pid == 0) { /* child */
- popen_redirect(&arg);
- rb_io_synchronized(RFILE(orig_stdout)->fptr);
- rb_io_synchronized(RFILE(orig_stderr)->fptr);
- return Qnil;
+ VALUE port = io_alloc(rb_cIO);
+
+ MakeOpenFile(port, fptr);
+ fptr->finalize = pipe_finalize;
+ fptr->mode = modef;
+
+ pipe_add_fptr(fptr);
+ if (modef & FMODE_READABLE) fptr->f = f;
+ if (modef & FMODE_WRITABLE) {
+ if (fptr->f) fptr->f2 = f;
+ else fptr->f = f;
+ rb_io_synchronized(fptr);
}
+ return (VALUE)port;
}
-
- /* parent */
- if (pid == -1) {
- int e = errno;
- close(arg.pair[0]);
- close(arg.pair[1]);
- if ((modef & (FMODE_READABLE|FMODE_WRITABLE)) == (FMODE_READABLE|FMODE_WRITABLE)) {
- close(arg.write_pair[0]);
- close(arg.write_pair[1]);
- }
- errno = e;
- rb_sys_fail(cmd);
- }
- if ((modef & FMODE_READABLE) && (modef & FMODE_WRITABLE)) {
- close(arg.pair[1]);
- fd = arg.pair[0];
- close(arg.write_pair[0]);
- write_fd = arg.write_pair[1];
- }
- else if (modef & FMODE_READABLE) {
- close(arg.pair[1]);
- fd = arg.pair[0];
+#else
+#ifdef _WIN32
+retry:
+ pid = pipe_exec(pname, rb_io_mode_modenum(mode), &fpr, &fpw);
+ if (pid == -1) { /* exec failed */
+ if (errno == EAGAIN) {
+ rb_thread_sleep(1);
+ goto retry;
+ }
+ rb_sys_fail(pname);
}
else {
- close(arg.pair[0]);
- fd = arg.pair[1];
- }
-#elif defined(_WIN32)
- if (argc) {
- char **args = ALLOCA_N(char *, argc+1);
- int i;
+ VALUE port = io_alloc(rb_cIO);
- for (i = 0; i < argc; ++i) {
- args[i] = RSTRING_PTR(argv[i]);
+ MakeOpenFile(port, fptr);
+ fptr->mode = modef;
+ fptr->mode |= FMODE_SYNC;
+ fptr->pid = pid;
+
+ if (modef & FMODE_READABLE) {
+ fptr->f = fpr;
}
- args[i] = NULL;
- exename = cmd;
- cmd = rb_w32_join_argv(ALLOCA_N(char, rb_w32_argv_size(args)), args);
- }
- while ((pid = rb_w32_pipe_exec(cmd, exename, openmode, &fd, &write_fd)) == -1) {
- /* exec failed */
- switch (errno) {
- case EAGAIN:
-#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- rb_thread_sleep(1);
- break;
- default:
- rb_sys_fail(cmd);
- break;
+ if (modef & FMODE_WRITABLE) {
+ if (fptr->f) fptr->f2 = fpw;
+ else fptr->f = fpw;
}
+ fptr->finalize = pipe_finalize;
+ pipe_add_fptr(fptr);
+ return (VALUE)port;
}
#else
- if (argc) {
- prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
- cmd = StringValueCStr(prog);
+ if (((modef & FMODE_READABLE) && pipe(pr) == -1) ||
+ ((modef & FMODE_WRITABLE) && pipe(pw) == -1))
+ rb_sys_fail(pname);
+
+ if (!doexec) {
+ fflush(stdin); /* is it really needed? */
+ fflush(stdout);
+ fflush(stderr);
}
- fp = popen(cmd, mode);
- if (!fp) rb_sys_fail(RSTRING_PTR(prog));
- fd = fileno(fp);
-#endif
- port = io_alloc(rb_cIO);
- MakeOpenFile(port, fptr);
- fptr->fd = fd;
- fptr->stdio_file = fp;
- fptr->mode = modef | FMODE_SYNC|FMODE_DUPLEX;
- rb_io_mode_enc(fptr, mode);
- fptr->pid = pid;
-
- if (0 <= write_fd) {
- write_port = io_alloc(rb_cIO);
- MakeOpenFile(write_port, write_fptr);
- write_fptr->fd = write_fd;
- write_fptr->mode = (modef & ~FMODE_READABLE)| FMODE_SYNC|FMODE_DUPLEX;
- fptr->mode &= ~FMODE_WRITABLE;
- fptr->tied_io_for_writing = write_port;
- rb_ivar_set(port, rb_intern("@tied_io_for_writing"), write_port);
- }
-
-#if defined (__CYGWIN__) || !defined(HAVE_FORK)
- fptr->finalize = pipe_finalize;
- pipe_add_fptr(fptr);
-#endif
- return port;
-}
+ retry:
+ switch ((pid = fork())) {
+ case 0: /* child */
+ if (modef & FMODE_READABLE) {
+ close(pr[0]);
+ if (pr[1] != 1) {
+ dup2(pr[1], 1);
+ close(pr[1]);
+ }
+ }
+ if (modef & FMODE_WRITABLE) {
+ close(pw[1]);
+ if (pw[0] != 0) {
+ dup2(pw[0], 0);
+ close(pw[0]);
+ }
+ }
-static VALUE
-pipe_open_v(int argc, VALUE *argv, const char *mode)
-{
- VALUE prog = rb_check_argv(argc, argv);
- const char *cmd;
+ if (doexec) {
+ int fd;
- if (!RB_GC_GUARD(prog)) prog = argv[0];
- cmd = RSTRING_PTR(prog);
- return pipe_open(cmd, argc, argv, mode);
-}
+ for (fd = 3; fd < NOFILE; fd++)
+ close(fd);
+ rb_proc_exec(pname);
+ fprintf(stderr, "%s:%d: command not found: %s\n",
+ ruby_sourcefile, ruby_sourceline, pname);
+ _exit(127);
+ }
+ rb_io_synchronized(RFILE(orig_stdout)->fptr);
+ rb_io_synchronized(RFILE(orig_stderr)->fptr);
+ return Qnil;
-static VALUE
-pipe_open_s(VALUE prog, const char *mode)
-{
- const char *cmd = (rb_check_argv(1, &prog), RSTRING_PTR(prog));
+ case -1: /* fork failed */
+ if (errno == EAGAIN) {
+ rb_thread_sleep(1);
+ goto retry;
+ }
+ else {
+ int e = errno;
+ if ((modef & FMODE_READABLE)) {
+ close(pr[0]);
+ close(pr[1]);
+ }
+ if ((modef & FMODE_WRITABLE)) {
+ close(pw[0]);
+ close(pw[1]);
+ }
+ errno = e;
+ rb_sys_fail(pname);
+ }
+ break;
- if (strcmp("-", cmd) == 0) {
-#if !defined(HAVE_FORK)
- rb_raise(rb_eNotImpError,
- "fork() function is unimplemented on this machine");
+ default: /* parent */
+ if (pid < 0) rb_sys_fail(pname);
+ else {
+ VALUE port = io_alloc(rb_cIO);
+
+ MakeOpenFile(port, fptr);
+ fptr->mode = modef;
+ fptr->mode |= FMODE_SYNC;
+ fptr->pid = pid;
+
+ if (modef & FMODE_READABLE) {
+ close(pr[1]);
+ fptr->f = rb_fdopen(pr[0], "r");
+ }
+ if (modef & FMODE_WRITABLE) {
+ FILE *f = rb_fdopen(pw[1], "w");
+
+ close(pw[0]);
+ if (fptr->f) fptr->f2 = f;
+ else fptr->f = f;
+ }
+#if defined (__CYGWIN__)
+ fptr->finalize = pipe_finalize;
+ pipe_add_fptr(fptr);
#endif
- cmd = 0;
+ return port;
+ }
}
- return pipe_open(cmd, 0, &prog, mode);
+#endif
+#endif
}
/*
* call-seq:
- * IO.popen(cmd, mode="r") => io
- * IO.popen(cmd, mode="r") {|io| block } => obj
- *
- * Runs the specified command as a subprocess; the subprocess's
+ * IO.popen(cmd_string, mode="r" ) => io
+ * IO.popen(cmd_string, mode="r" ) {|io| block } => obj
+ *
+ * Runs the specified command string as a subprocess; the subprocess's
* standard input and output will be connected to the returned
- * <code>IO</code> object. If _cmd_ is a +String+
+ * <code>IO</code> object. If <i>cmd_string</i> starts with a
* ``<code>-</code>'', then a new instance of Ruby is started as the
- * subprocess. If <i>cmd</i> is an +Array+ of +String+, then it will
- * be used as the subprocess's +argv+ bypassing a shell. The default
- * mode for the new file object is ``r'', but <i>mode</i> may be set
- * to any of the modes listed in the description for class IO.
- *
- * Raises exceptions which <code>IO::pipe</code> and
- * <code>Kernel::system</code> raise.
- *
+ * subprocess. The default mode for the new file object is ``r'', but
+ * <i>mode</i> may be set to any of the modes listed in the description
+ * for class IO.
+ *
* If a block is given, Ruby will run the command as a child connected
* to Ruby with a pipe. Ruby's end of the pipe will be passed as a
* parameter to the block.
* At the end of block, Ruby close the pipe and sets <code>$?</code>.
* In this case <code>IO::popen</code> returns
* the value of the block.
- *
- * If a block is given with a _cmd_ of ``<code>-</code>'',
+ *
+ * If a block is given with a <i>cmd_string</i> of ``<code>-</code>'',
* the block will be run in two separate processes: once in the parent,
* and once in a child. The parent process will be passed the pipe
* object as a parameter to the block, the child version of the block
* will be passed <code>nil</code>, and the child's standard in and
* standard out will be connected to the parent through the pipe. Not
* available on all platforms.
- *
+ *
* f = IO.popen("uname")
* p f.readlines
* puts "Parent is #{Process.pid}"
- * IO.popen("date") { |f| puts f.gets }
+ * IO.popen ("date") { |f| puts f.gets }
* IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f}"}
* p $?
- * IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f|
- * f.puts "bar"; f.close_write; puts f.gets
- * }
- *
+ *
* <em>produces:</em>
- *
+ *
* ["Linux\n"]
* Parent is 26166
* Wed Apr 9 08:53:52 CDT 2003
* 26169 is here, f is
* 26166 is here, f is #<IO:0x401b3d44>
* #<Process::Status: pid=26166,exited(0)>
- * <foo>bar;zot;
*/
static VALUE
-rb_io_s_popen(int argc, VALUE *argv, VALUE klass)
+rb_io_s_popen(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
const char *mode;
- VALUE pname, pmode, port, tmp;
+ VALUE pname, pmode, port;
if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) {
mode = "r";
@@ -3727,26 +3367,16 @@ rb_io_s_popen(int argc, VALUE *argv, VALUE klass)
mode = rb_io_modenum_mode(FIX2INT(pmode));
}
else {
- mode = StringValuePtr(pmode);
- }
- tmp = rb_check_array_type(pname);
- if (!NIL_P(tmp)) {
- long len = RARRAY_LEN(tmp);
- VALUE *args = ALLOCA_N(VALUE, len);
-
- MEMCPY(args, RARRAY_PTR(tmp), VALUE, len);
- port = pipe_open_v(len, args, mode);
- }
- else {
- SafeStringValue(pname);
- port = pipe_open_s(pname, mode);
+ mode = rb_io_flags_mode(rb_io_mode_flags(StringValueCStr(pmode)));
}
+ SafeStringValue(pname);
+ port = pipe_open(pname, 0, mode);
if (NIL_P(port)) {
/* child */
if (rb_block_given_p()) {
rb_yield(Qnil);
- rb_io_flush(rb_stdout);
- rb_io_flush(rb_stderr);
+ fflush(stdout);
+ fflush(stderr);
_exit(0);
}
return Qnil;
@@ -3759,31 +3389,35 @@ rb_io_s_popen(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-rb_open_file(int argc, VALUE *argv, VALUE io)
+rb_open_file(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
VALUE fname, vmode, perm;
- const char *mode;
- int flags, fmode;
+ const char *path, *mode;
+ int flags;
+ unsigned int fmode;
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
- FilePathValue(fname);
+ SafeStringValue(fname);
+ path = StringValueCStr(fname);
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
if (FIXNUM_P(vmode)) {
flags = FIX2INT(vmode);
}
else {
SafeStringValue(vmode);
- flags = rb_io_mode_modenum(RSTRING_PTR(vmode));
+ flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
}
- fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
+ fmode = NIL_P(perm) ? 0666 : NUM2UINT(perm);
- rb_file_sysopen_internal(io, RSTRING_PTR(fname), flags, fmode);
+ rb_file_sysopen_internal(io, path, flags, fmode);
}
else {
-
- mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
- rb_file_open_internal(io, RSTRING_PTR(fname), mode);
+ mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode);
+ rb_file_open_internal(io, path, mode);
}
return io;
}
@@ -3792,17 +3426,20 @@ rb_open_file(int argc, VALUE *argv, VALUE io)
* call-seq:
* IO.open(fd, mode_string="r" ) => io
* IO.open(fd, mode_string="r" ) {|io| block } => obj
- *
+ *
* With no associated block, <code>open</code> is a synonym for
* <code>IO::new</code>. If the optional code block is given, it will
* be passed <i>io</i> as an argument, and the IO object will
* automatically be closed when the block terminates. In this instance,
* <code>IO::open</code> returns the value of the block.
- *
+ *
*/
static VALUE
-rb_io_s_open(int argc, VALUE *argv, VALUE klass)
+rb_io_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE io = rb_class_new_instance(argc, argv, klass);
@@ -3816,35 +3453,38 @@ rb_io_s_open(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
* IO.sysopen(path, [mode, [perm]]) => fixnum
- *
+ *
* Opens the given path, returning the underlying file descriptor as a
* <code>Fixnum</code>.
- *
+ *
* IO.sysopen("testfile") #=> 3
- *
+ *
*/
static VALUE
-rb_io_s_sysopen(int argc, VALUE *argv)
+rb_io_s_sysopen(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE fname, vmode, perm;
- int flags, fmode, fd;
+ int flags, fd;
+ unsigned int fmode;
char *path;
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
- FilePathValue(fname);
+ SafeStringValue(fname);
if (NIL_P(vmode)) flags = O_RDONLY;
else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
else {
SafeStringValue(vmode);
- flags = rb_io_mode_modenum(RSTRING_PTR(vmode));
+ flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
}
if (NIL_P(perm)) fmode = 0666;
- else fmode = NUM2INT(perm);
+ else fmode = NUM2UINT(perm);
- RB_GC_GUARD(fname) = rb_str_new4(fname);
- path = RSTRING_PTR(fname);
+ path = ALLOCA_N(char, strlen(RSTRING(fname)->ptr)+1);
+ strcpy(path, RSTRING(fname)->ptr);
fd = rb_sysopen(path, flags, fmode);
return INT2NUM(fd);
}
@@ -3853,40 +3493,21 @@ rb_io_s_sysopen(int argc, VALUE *argv)
* call-seq:
* open(path [, mode [, perm]] ) => io or nil
* open(path [, mode [, perm]] ) {|io| block } => obj
- *
+ *
* Creates an <code>IO</code> object connected to the given stream,
* file, or subprocess.
- *
+ *
* If <i>path</i> does not start with a pipe character
* (``<code>|</code>''), treat it as the name of a file to open using
- * the specified mode (defaulting to ``<code>r</code>''). The mode is
- * either a string or an integer. If it is an integer, it must be
- * bitwise-or of open(2) flags, such as File::RDWR or File::EXCL.
- * If it is a string, it is either "mode", "mode:encoding", or
- * "mode:encoding:encoding". "mode" is one of the following:
- *
- * r: read (default)
- * w: write
- * a: append
- *
- * The mode can be followed by "b" (means binary-mode), or "+"
- * (means both reading and writing allowed) or both. If one
- * encoding is specified, read string will be tagged by the
- * encoding in reading, and output string will be converted
- * to the specified encoding in writing. If two encoding names
- * are specified, the read string is converted from the former
- * encoding to the latter encoding then tagged with the latter
- * in read mode, and in write mode, the output string will be
- * converted from the latter to the former before writing.
- *
- * If a file is being created, its initial permissions may be
- * set using the integer third parameter.
- *
+ * the specified mode (defaulting to ``<code>r</code>''). (See the table
+ * of valid modes on page 331.) If a file is being created, its initial
+ * permissions may be set using the integer third parameter.
+ *
* If a block is specified, it will be invoked with the
* <code>File</code> object as a parameter, and the file will be
* automatically closed when the block terminates. The call
* returns the value of the block.
- *
+ *
* If <i>path</i> starts with a pipe character, a subprocess is
* created, connected to the caller by a pair of pipes. The returned
* <code>IO</code> object may be used to write to the standard input
@@ -3902,27 +3523,27 @@ rb_io_s_sysopen(int argc, VALUE *argv)
* will be connected to the child's <code>$stdin</code> and
* <code>$stdout</code>. The subprocess will be terminated at the end
* of the block.
- *
+ *
* open("testfile") do |f|
* print f.gets
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* This is line one
- *
+ *
* Open a subprocess and read its output:
- *
+ *
* cmd = open("|date")
* print cmd.gets
* cmd.close
- *
+ *
* <em>produces:</em>
- *
+ *
* Wed Apr 9 08:56:31 CDT 2003
- *
+ *
* Open a subprocess running the same Ruby program:
- *
+ *
* f = open("|-", "w+")
* if f == nil
* puts "in Child"
@@ -3930,13 +3551,13 @@ rb_io_s_sysopen(int argc, VALUE *argv)
* else
* puts "Got: #{f.gets}"
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* Got: in Child
- *
+ *
* Open a subprocess using a block to receive the I/O object:
- *
+ *
* open("|-") do |f|
* if f == nil
* puts "in Child"
@@ -3944,56 +3565,36 @@ rb_io_s_sysopen(int argc, VALUE *argv)
* puts "Got: #{f.gets}"
* end
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* Got: in Child
*/
static VALUE
-rb_f_open(int argc, VALUE *argv)
+rb_f_open(argc, argv)
+ int argc;
+ VALUE *argv;
{
- ID to_open;
- int redirect = Qfalse;
-
if (argc >= 1) {
- to_open = rb_intern("to_open");
- if (rb_respond_to(argv[0], to_open)) {
- redirect = Qtrue;
- }
- else {
- VALUE tmp = argv[0];
- FilePathValue(tmp);
- if (NIL_P(tmp)) {
- redirect = Qtrue;
- }
- else {
- char *str = StringValuePtr(tmp);
- if (str && str[0] == '|') {
- argv[0] = rb_str_new(str+1, RSTRING_LEN(tmp)-1);
- OBJ_INFECT(argv[0], tmp);
- return rb_io_s_popen(argc, argv, rb_cIO);
- }
- }
- }
- }
- if (redirect) {
- VALUE io = rb_funcall2(argv[0], to_open, argc-1, argv+1);
+ char *str = StringValuePtr(argv[0]);
- if (rb_block_given_p()) {
- return rb_ensure(rb_yield, io, io_close, io);
+ if (str[0] == '|') {
+ VALUE tmp = rb_str_new(str+1, RSTRING(argv[0])->len-1);
+ OBJ_INFECT(tmp, argv[0]);
+ argv[0] = tmp;
+ return rb_io_s_popen(argc, argv, rb_cIO);
}
- return io;
}
return rb_io_s_open(argc, argv, rb_cFile);
}
static VALUE
-rb_io_open(const char *fname, const char *mode)
+rb_io_open(fname, mode)
+ char *fname, *mode;
{
if (fname[0] == '|') {
- VALUE cmd = rb_str_new2(fname+1);
- return pipe_open_s(cmd, mode);
+ return pipe_open(0, fname+1, mode);
}
else {
return rb_file_open(fname, mode);
@@ -4001,9 +3602,40 @@ rb_io_open(const char *fname, const char *mode)
}
static VALUE
-io_reopen(VALUE io, VALUE nfile)
+rb_io_get_io(io)
+ VALUE io;
+{
+ return rb_convert_type(io, T_FILE, "IO", "to_io");
+}
+
+static VALUE
+rb_io_check_io(io)
+ VALUE io;
+{
+ return rb_check_convert_type(io, T_FILE, "IO", "to_io");
+}
+
+static const char*
+rb_io_mode_string(fptr)
+ rb_io_t *fptr;
+{
+ switch (fptr->mode & FMODE_READWRITE) {
+ case FMODE_READABLE:
+ default:
+ return "r";
+ case FMODE_WRITABLE:
+ return "w";
+ case FMODE_READWRITE:
+ return "r+";
+ }
+}
+
+static VALUE
+io_reopen(io, nfile)
+ VALUE io, nfile;
{
rb_io_t *fptr, *orig;
+ const char *mode;
int fd, fd2;
off_t pos = 0;
@@ -4015,29 +3647,21 @@ io_reopen(VALUE io, VALUE nfile)
GetOpenFile(nfile, orig);
if (fptr == orig) return io;
-#if !defined __CYGWIN__
- if (IS_PREP_STDIO(fptr)) {
- if (((fptr->mode & FMODE_READWRITE) & (orig->mode & FMODE_READWRITE)) !=
- (fptr->mode & FMODE_READWRITE)) {
- rb_raise(rb_eArgError,
- "%s can't change access mode from \"%s\" to \"%s\"",
- PREP_STDIO_NAME(fptr), rb_io_flags_mode(fptr->mode),
- rb_io_flags_mode(orig->mode));
- }
- }
-#endif
if (orig->mode & FMODE_READABLE) {
pos = io_tell(orig);
}
- if (orig->mode & FMODE_WRITABLE) {
- io_fflush(orig);
+ if (orig->f2) {
+ io_fflush(orig->f2, orig);
+ }
+ else if (orig->mode & FMODE_WRITABLE) {
+ io_fflush(orig->f, orig);
}
if (fptr->mode & FMODE_WRITABLE) {
- io_fflush(fptr);
+ io_fflush(GetWriteFile(fptr), fptr);
}
/* copy rb_io_t structure */
- fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);
+ fptr->mode = orig->mode;
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (fptr->path) free(fptr->path);
@@ -4045,37 +3669,54 @@ io_reopen(VALUE io, VALUE nfile)
else fptr->path = 0;
fptr->finalize = orig->finalize;
- fd = fptr->fd;
- fd2 = orig->fd;
+ mode = rb_io_mode_string(fptr);
+ fd = fileno(fptr->f);
+ fd2 = fileno(orig->f);
if (fd != fd2) {
-#if !defined __CYGWIN__
- if (IS_PREP_STDIO(fptr)) {
+ if (fptr->f == stdin || fptr->f == stdout || fptr->f == stderr) {
+ clearerr(fptr->f);
/* need to keep stdio objects */
if (dup2(fd2, fd) < 0)
rb_sys_fail(orig->path);
}
else {
-#endif
- if (fptr->stdio_file)
- fclose(fptr->stdio_file);
- else
- close(fptr->fd);
- fptr->stdio_file = 0;
- fptr->fd = -1;
+ FILE *f2 = fptr->f2;
+ int m = fptr->mode;
+ fclose(fptr->f);
+ fptr->f = f2;
+ fptr->f2 = NULL;
+ fptr->mode &= (m & FMODE_READABLE) ? ~FMODE_READABLE : ~FMODE_WRITABLE;
if (dup2(fd2, fd) < 0)
rb_sys_fail(orig->path);
- fptr->fd = fd;
-#if !defined __CYGWIN__
+ if (f2) {
+ fptr->f = rb_fdopen(fd, "r");
+ fptr->f2 = f2;
+ }
+ else {
+ fptr->f = rb_fdopen(fd, mode);
+ }
+ fptr->mode = m;
}
-#endif
rb_thread_fd_close(fd);
if ((orig->mode & FMODE_READABLE) && pos >= 0) {
- if (io_seek(fptr, pos, SEEK_SET) < 0) {
- rb_sys_fail(fptr->path);
- }
- if (io_seek(orig, pos, SEEK_SET) < 0) {
+ io_seek(fptr, pos, SEEK_SET);
+ io_seek(orig, pos, SEEK_SET);
+ }
+ }
+
+ if (fptr->f2 && fd != fileno(fptr->f2)) {
+ fd = fileno(fptr->f2);
+ if (!orig->f2) {
+ fclose(fptr->f2);
+ rb_thread_fd_close(fd);
+ fptr->f2 = 0;
+ }
+ else if (fd != (fd2 = fileno(orig->f2))) {
+ fclose(fptr->f2);
+ rb_thread_fd_close(fd);
+ if (dup2(fd2, fd) < 0)
rb_sys_fail(orig->path);
- }
+ fptr->f2 = rb_fdopen(fd, "w");
}
}
@@ -4089,13 +3730,13 @@ io_reopen(VALUE io, VALUE nfile)
/*
* call-seq:
- * ios.reopen(other_IO) => ios
+ * ios.reopen(other_IO) => ios
* ios.reopen(path, mode_str) => ios
- *
+ *
* Reassociates <em>ios</em> with the I/O stream given in
* <i>other_IO</i> or to a new stream opened on <i>path</i>. This may
* dynamically change the actual class of this stream.
- *
+ *
* f1 = File.new("testfile")
* f2 = File.new("testfile")
* f2.readlines[0] #=> "This is line one\n"
@@ -4104,7 +3745,10 @@ io_reopen(VALUE io, VALUE nfile)
*/
static VALUE
-rb_io_reopen(int argc, VALUE *argv, VALUE file)
+rb_io_reopen(argc, argv, file)
+ int argc;
+ VALUE *argv;
+ VALUE file;
{
VALUE fname, nmode;
const char *mode;
@@ -4118,7 +3762,7 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
}
}
- FilePathValue(fname);
+ SafeStringValue(fname);
rb_io_taint_check(file);
fptr = RFILE(file)->fptr;
if (!fptr) {
@@ -4127,17 +3771,7 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
}
if (!NIL_P(nmode)) {
- int flags = rb_io_mode_flags(StringValuePtr(nmode));
- if (IS_PREP_STDIO(fptr) &&
- ((fptr->mode & FMODE_READWRITE) & (flags & FMODE_READWRITE)) !=
- (fptr->mode & FMODE_READWRITE)) {
- rb_raise(rb_eArgError,
- "%s can't change access mode from \"%s\" to \"%s\"",
- PREP_STDIO_NAME(fptr), rb_io_flags_mode(fptr->mode),
- rb_io_flags_mode(flags));
- }
- fptr->mode = flags;
- rb_io_mode_enc(fptr, StringValueCStr(nmode));
+ fptr->mode = rb_io_mode_flags(StringValueCStr(nmode));
}
if (fptr->path) {
@@ -4145,33 +3779,29 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
fptr->path = 0;
}
- fptr->path = strdup(RSTRING_PTR(fname));
+ fptr->path = strdup(StringValueCStr(fname));
mode = rb_io_flags_mode(fptr->mode);
- if (fptr->fd < 0) {
- fptr->fd = rb_sysopen(fptr->path, rb_io_mode_modenum(mode), 0666);
- fptr->stdio_file = 0;
+ if (!fptr->f) {
+ fptr->f = rb_fopen(fptr->path, mode);
+ if (fptr->f2) {
+ fclose(fptr->f2);
+ fptr->f2 = 0;
+ }
return file;
}
- if (fptr->mode & FMODE_WRITABLE) {
- io_fflush(fptr);
+ if (freopen(fptr->path, mode, fptr->f) == 0) {
+ rb_sys_fail(fptr->path);
}
-
- if (fptr->stdio_file) {
- if (freopen(RSTRING_PTR(fname), mode, fptr->stdio_file) == 0) {
- rb_sys_fail(fptr->path);
- }
- fptr->fd = fileno(fptr->stdio_file);
#ifdef USE_SETVBUF
- if (setvbuf(fptr->stdio_file, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fname));
+ if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0)
+ rb_warn("setvbuf() can't be honoured for %s", fptr->path);
#endif
- }
- else {
- if (close(fptr->fd) < 0)
- rb_sys_fail(fptr->path);
- fptr->fd = -1;
- fptr->fd = rb_sysopen(fptr->path, rb_io_mode_modenum(mode), 0666);
+
+ if (fptr->f2) {
+ if (freopen(fptr->path, "w", fptr->f2) == 0) {
+ rb_sys_fail(fptr->path);
+ }
}
return file;
@@ -4179,54 +3809,78 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
/* :nodoc: */
static VALUE
-rb_io_init_copy(VALUE dest, VALUE io)
+rb_io_init_copy(dest, io)
+ VALUE dest, io;
{
rb_io_t *fptr, *orig;
int fd;
- VALUE write_io;
+ const char *mode;
io = rb_io_get_io(io);
if (dest == io) return dest;
GetOpenFile(io, orig);
MakeOpenFile(dest, fptr);
- rb_io_flush(io);
+ if (orig->f2) {
+ io_fflush(orig->f2, orig);
+ fseeko(orig->f, 0L, SEEK_CUR);
+ }
+ else if (orig->mode & FMODE_WRITABLE) {
+ io_fflush(orig->f, orig);
+ }
+ else {
+ fseeko(orig->f, 0L, SEEK_CUR);
+ }
/* copy rb_io_t structure */
- fptr->mode = orig->mode & ~FMODE_PREP;
+ fptr->mode = orig->mode;
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (orig->path) fptr->path = strdup(orig->path);
fptr->finalize = orig->finalize;
- fd = ruby_dup(orig->fd);
- fptr->fd = fd;
- io_seek(fptr, io_tell(orig), SEEK_SET);
+ switch (fptr->mode & FMODE_READWRITE) {
+ case FMODE_READABLE:
+ default:
+ mode = "r"; break;
+ case FMODE_WRITABLE:
+ mode = "w"; break;
+ case FMODE_READWRITE:
+ if (orig->f2) mode = "r";
+ else mode = "r+";
+ break;
+ }
+ fd = ruby_dup(fileno(orig->f));
+ fptr->f = rb_fdopen(fd, mode);
+ fseeko(fptr->f, ftello(orig->f), SEEK_SET);
+ if (orig->f2) {
+ if (fileno(orig->f) != fileno(orig->f2)) {
+ fd = ruby_dup(fileno(orig->f2));
+ }
+ fptr->f2 = rb_fdopen(fd, "w");
+ fseeko(fptr->f2, ftello(orig->f2), SEEK_SET);
+ }
if (fptr->mode & FMODE_BINMODE) {
rb_io_binmode(dest);
}
- write_io = GetWriteIO(io);
- if (io != write_io) {
- write_io = rb_obj_dup(write_io);
- fptr->tied_io_for_writing = write_io;
- rb_ivar_set(dest, rb_intern("@tied_io_for_writing"), write_io);
- }
-
return dest;
}
/*
* call-seq:
* ios.printf(format_string [, obj, ...] ) => nil
- *
+ *
* Formats and writes to <em>ios</em>, converting parameters under
* control of the format string. See <code>Kernel#sprintf</code>
* for details.
*/
VALUE
-rb_io_printf(int argc, VALUE *argv, VALUE out)
+rb_io_printf(argc, argv, out)
+ int argc;
+ VALUE argv[];
+ VALUE out;
{
rb_io_write(out, rb_f_sprintf(argc, argv));
return Qnil;
@@ -4236,7 +3890,7 @@ rb_io_printf(int argc, VALUE *argv, VALUE out)
* call-seq:
* printf(io, string [, obj ... ] ) => nil
* printf(string [, obj ... ] ) => nil
- *
+ *
* Equivalent to:
* io.write(sprintf(string, obj, ...)
* or
@@ -4244,7 +3898,9 @@ rb_io_printf(int argc, VALUE *argv, VALUE out)
*/
static VALUE
-rb_f_printf(int argc, VALUE *argv)
+rb_f_printf(argc, argv)
+ int argc;
+ VALUE argv[];
{
VALUE out;
@@ -4266,7 +3922,7 @@ rb_f_printf(int argc, VALUE *argv)
* call-seq:
* ios.print() => nil
* ios.print(obj, ...) => nil
- *
+ *
* Writes the given object(s) to <em>ios</em>. The stream must be
* opened for writing. If the output record separator (<code>$\\</code>)
* is not <code>nil</code>, it will be appended to the output. If no
@@ -4274,16 +3930,19 @@ rb_f_printf(int argc, VALUE *argv)
* strings will be converted by calling their <code>to_s</code> method.
* With no argument, prints the contents of the variable <code>$_</code>.
* Returns <code>nil</code>.
- *
+ *
* $stdout.print("This is ", 100, " percent.\n")
- *
+ *
* <em>produces:</em>
- *
+ *
* This is 100 percent.
*/
VALUE
-rb_io_print(int argc, VALUE *argv, VALUE out)
+rb_io_print(argc, argv, out)
+ int argc;
+ VALUE *argv;
+ VALUE out;
{
int i;
VALUE line;
@@ -4295,12 +3954,19 @@ rb_io_print(int argc, VALUE *argv, VALUE out)
argv = &line;
}
for (i=0; i<argc; i++) {
- rb_io_write(out, argv[i]);
- if (!NIL_P(rb_output_fs)) {
+ if (!NIL_P(rb_output_fs) && i>0) {
rb_io_write(out, rb_output_fs);
}
+ switch (TYPE(argv[i])) {
+ case T_NIL:
+ rb_io_write(out, rb_str_new2("nil"));
+ break;
+ default:
+ rb_io_write(out, argv[i]);
+ break;
+ }
}
- if (argc > 0 && !NIL_P(rb_output_rs)) {
+ if (!NIL_P(rb_output_rs)) {
rb_io_write(out, rb_output_rs);
}
@@ -4310,7 +3976,7 @@ rb_io_print(int argc, VALUE *argv, VALUE out)
/*
* call-seq:
* print(obj, ...) => nil
- *
+ *
* Prints each object in turn to <code>$stdout</code>. If the output
* field separator (<code>$,</code>) is not +nil+, its
* contents will appear between each field. If the output record
@@ -4318,20 +3984,22 @@ rb_io_print(int argc, VALUE *argv, VALUE out)
* appended to the output. If no arguments are given, prints
* <code>$_</code>. Objects that aren't strings will be converted by
* calling their <code>to_s</code> method.
- *
+ *
* print "cat", [1,2,3], 99, "\n"
* $, = ", "
* $\ = "\n"
* print "cat", [1,2,3], 99
- *
+ *
* <em>produces:</em>
- *
+ *
* cat12399
* cat, 1, 2, 3, 99
*/
static VALUE
-rb_f_print(int argc, VALUE *argv)
+rb_f_print(argc, argv)
+ int argc;
+ VALUE *argv;
{
rb_io_print(argc, argv, rb_stdout);
return Qnil;
@@ -4340,21 +4008,22 @@ rb_f_print(int argc, VALUE *argv)
/*
* call-seq:
* ios.putc(obj) => obj
- *
+ *
* If <i>obj</i> is <code>Numeric</code>, write the character whose
* code is <i>obj</i>, otherwise write the first character of the
* string representation of <i>obj</i> to <em>ios</em>.
- *
+ *
* $stdout.putc "A"
* $stdout.putc 65
- *
+ *
* <em>produces:</em>
- *
+ *
* AA
*/
static VALUE
-rb_io_putc(VALUE io, VALUE ch)
+rb_io_putc(io, ch)
+ VALUE io, ch;
{
char c = NUM2CHR(ch);
@@ -4365,27 +4034,29 @@ rb_io_putc(VALUE io, VALUE ch)
/*
* call-seq:
* putc(int) => int
- *
+ *
* Equivalent to:
*
* $stdout.putc(int)
*/
static VALUE
-rb_f_putc(VALUE recv, VALUE ch)
+rb_f_putc(recv, ch)
+ VALUE recv, ch;
{
return rb_io_putc(rb_stdout, ch);
}
static VALUE
-io_puts_ary(VALUE ary, VALUE out, int recur)
+io_puts_ary(ary, out)
+ VALUE ary, out;
{
VALUE tmp;
long i;
- for (i=0; i<RARRAY_LEN(ary); i++) {
- tmp = RARRAY_PTR(ary)[i];
- if (recur) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ tmp = RARRAY(ary)->ptr[i];
+ if (rb_inspecting_p(tmp)) {
tmp = rb_str_new2("[...]");
}
rb_io_puts(1, &tmp, out);
@@ -4396,17 +4067,17 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
/*
* call-seq:
* ios.puts(obj, ...) => nil
- *
+ *
* Writes the given objects to <em>ios</em> as with
* <code>IO#print</code>. Writes a record separator (typically a
* newline) after any that do not already end with a newline sequence.
* If called with an array argument, writes each element on a new line.
* If called without arguments, outputs a single record separator.
- *
+ *
* $stdout.puts("this", "is", "a", "test")
- *
+ *
* <em>produces:</em>
- *
+ *
* this
* is
* a
@@ -4414,7 +4085,10 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
*/
VALUE
-rb_io_puts(int argc, VALUE *argv, VALUE out)
+rb_io_puts(argc, argv, out)
+ int argc;
+ VALUE *argv;
+ VALUE out;
{
int i;
VALUE line;
@@ -4425,15 +4099,20 @@ rb_io_puts(int argc, VALUE *argv, VALUE out)
return Qnil;
}
for (i=0; i<argc; i++) {
- line = rb_check_array_type(argv[i]);
- if (!NIL_P(line)) {
- rb_exec_recursive(io_puts_ary, line, out);
- continue;
+ if (NIL_P(argv[i])) {
+ line = rb_str_new2("nil");
+ }
+ else {
+ line = rb_check_array_type(argv[i]);
+ if (!NIL_P(line)) {
+ rb_protect_inspect(io_puts_ary, line, out);
+ continue;
+ }
+ line = rb_obj_as_string(argv[i]);
}
- line = rb_obj_as_string(argv[i]);
rb_io_write(out, line);
- if (RSTRING_LEN(line) == 0 ||
- RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') {
+ if (RSTRING(line)->len == 0 ||
+ RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
rb_io_write(out, rb_default_rs);
}
}
@@ -4444,21 +4123,24 @@ rb_io_puts(int argc, VALUE *argv, VALUE out)
/*
* call-seq:
* puts(obj, ...) => nil
- *
- * Equivalent to
+ *
+ * Equivalent to
*
* $stdout.puts(obj, ...)
*/
static VALUE
-rb_f_puts(int argc, VALUE *argv)
+rb_f_puts(argc, argv)
+ int argc;
+ VALUE *argv;
{
rb_io_puts(argc, argv, rb_stdout);
return Qnil;
}
void
-rb_p(VALUE obj) /* for debug print within C code */
+rb_p(obj) /* for debug print within C code */
+ VALUE obj;
{
rb_io_write(rb_stdout, rb_obj_as_string(rb_inspect(obj)));
rb_io_write(rb_stdout, rb_default_rs);
@@ -4466,69 +4148,65 @@ rb_p(VALUE obj) /* for debug print within C code */
/*
* call-seq:
- * p(obj) => obj
- * p(obj1, obj2, ...) => [obj, ...]
- * p() => nil
- *
+ * p(obj, ...) => nil
+ *
* For each object, directly writes
* _obj_.+inspect+ followed by the current output
* record separator to the program's standard output.
- *
+ *
* S = Struct.new(:name, :state)
* s = S['dave', 'TX']
* p s
- *
+ *
* <em>produces:</em>
- *
+ *
* #<S name="dave", state="TX">
*/
static VALUE
-rb_f_p(int argc, VALUE *argv, VALUE self)
+rb_f_p(argc, argv)
+ int argc;
+ VALUE *argv;
{
int i;
- VALUE ret = Qnil;
for (i=0; i<argc; i++) {
rb_p(argv[i]);
}
- if (argc == 1) {
- ret = argv[0];
- }
- else if (argc > 1) {
- ret = rb_ary_new4(argc, argv);
- }
if (TYPE(rb_stdout) == T_FILE) {
rb_io_flush(rb_stdout);
}
- return ret;
+ return Qnil;
}
/*
* call-seq:
* obj.display(port=$>) => nil
- *
+ *
* Prints <i>obj</i> on the given port (default <code>$></code>).
* Equivalent to:
- *
+ *
* def display(port=$>)
* port.write self
* end
- *
+ *
* For example:
- *
+ *
* 1.display
* "cat".display
* [ 4, 5, 6 ].display
* puts
- *
+ *
* <em>produces:</em>
- *
+ *
* 1cat456
*/
static VALUE
-rb_obj_display(int argc, VALUE *argv, VALUE self)
+rb_obj_display(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE out;
@@ -4542,24 +4220,25 @@ rb_obj_display(int argc, VALUE *argv, VALUE self)
}
void
-rb_write_error2(const char *mesg, long len)
+rb_write_error2(mesg, len)
+ const char *mesg;
+ long len;
{
- if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
- fwrite(mesg, sizeof(char), len, stderr);
- }
- else {
- rb_io_write(rb_stderr, rb_str_new(mesg, len));
- }
+ rb_io_write(rb_stderr, rb_str_new(mesg, len));
}
void
-rb_write_error(const char *mesg)
+rb_write_error(mesg)
+ const char *mesg;
{
rb_write_error2(mesg, strlen(mesg));
}
static void
-must_respond_to(ID mid, VALUE val, ID id)
+must_respond_to(mid, val, id)
+ ID mid;
+ VALUE val;
+ ID id;
{
if (!rb_respond_to(val, mid)) {
rb_raise(rb_eTypeError, "%s must have %s method, %s given",
@@ -4569,148 +4248,129 @@ must_respond_to(ID mid, VALUE val, ID id)
}
static void
-stdout_setter(VALUE val, ID id, VALUE *variable)
+stdout_setter(val, id, variable)
+ VALUE val;
+ ID id;
+ VALUE *variable;
{
must_respond_to(id_write, val, id);
*variable = val;
}
+static void
+defout_setter(val, id, variable)
+ VALUE val;
+ ID id;
+ VALUE *variable;
+{
+ stdout_setter(val, id, variable);
+ rb_warn("$defout is obsolete; use $stdout instead");
+}
+
+static void
+deferr_setter(val, id, variable)
+ VALUE val;
+ ID id;
+ VALUE *variable;
+{
+ stdout_setter(val, id, variable);
+ rb_warn("$deferr is obsolete; use $stderr instead");
+}
+
static VALUE
-prep_io(int fd, int mode, VALUE klass, const char *path)
+prep_stdio(f, mode, klass)
+ FILE *f;
+ int mode;
+ VALUE klass;
{
rb_io_t *fp;
VALUE io = io_alloc(klass);
MakeOpenFile(io, fp);
- fp->fd = fd;
#ifdef __CYGWIN__
- if (!isatty(fd)) {
+ if (!isatty(fileno(f))) {
mode |= O_BINARY;
- setmode(fd, O_BINARY);
+ setmode(fileno(f), O_BINARY);
}
#endif
+ fp->f = f;
fp->mode = mode;
- io_check_tty(fp);
- if (path) fp->path = strdup(path);
return io;
}
-VALUE
-rb_io_fdopen(int fd, int mode, const char *path)
-{
- VALUE klass = rb_cIO;
-
- if (path && strcmp(path, "-")) klass = rb_cFile;
- return prep_io(fd, rb_io_modenum_flags(mode), klass, path);
-}
-
-static VALUE
-prep_stdio(FILE *f, int mode, VALUE klass, const char *path)
+static void
+prep_path(io, path)
+ VALUE io;
+ char *path;
{
rb_io_t *fptr;
- VALUE io = prep_io(fileno(f), mode|FMODE_PREP, klass, path);
GetOpenFile(io, fptr);
- fptr->stdio_file = f;
-
- return io;
-}
-
-FILE *rb_io_stdio_file(rb_io_t *fptr)
-{
- if (!fptr->stdio_file) {
- fptr->stdio_file = rb_fdopen(fptr->fd, rb_io_flags_mode(fptr->mode));
- }
- return fptr->stdio_file;
+ if (fptr->path) rb_bug("illegal prep_path() call");
+ fptr->path = strdup(path);
}
/*
* call-seq:
* IO.new(fd, mode) => io
- *
+ *
* Returns a new <code>IO</code> object (a stream) for the given
- * <code>IO</code> object or integer file descriptor and mode
- * string. See also <code>IO#fileno</code> and
- * <code>IO::for_fd</code>.
- *
- * puts IO.new($stdout).fileno # => 1
- *
+ * integer file descriptor and mode string. See also
+ * <code>IO#fileno</code> and <code>IO::for_fd</code>.
+ *
* a = IO.new(2,"w") # '2' is standard error
* $stderr.puts "Hello"
* a.puts "World"
- *
+ *
* <em>produces:</em>
- *
+ *
* Hello
* World
*/
static VALUE
-rb_io_initialize(int argc, VALUE *argv, VALUE io)
+rb_io_initialize(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
- VALUE fnum, mode, orig;
- rb_io_t *fp, *ofp = NULL;
- int fd, fmode, flags = O_RDONLY;
+ VALUE fnum, mode;
+ rb_io_t *fp;
+ int fd, flags;
rb_secure(4);
rb_scan_args(argc, argv, "11", &fnum, &mode);
+ fd = NUM2INT(fnum);
if (argc == 2) {
if (FIXNUM_P(mode)) {
flags = FIX2LONG(mode);
}
else {
SafeStringValue(mode);
- flags = rb_io_mode_modenum(RSTRING_PTR(mode));
+ flags = rb_io_mode_modenum(StringValueCStr(mode));
}
}
- orig = rb_io_check_io(fnum);
- if (NIL_P(orig)) {
- fd = NUM2INT(fnum);
- if (argc != 2) {
+ else {
#if defined(HAVE_FCNTL) && defined(F_GETFL)
- flags = fcntl(fd, F_GETFL);
- if (flags == -1) rb_sys_fail(0);
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1) rb_sys_fail(0);
+#else
+ flags = O_RDONLY;
#endif
- }
- MakeOpenFile(io, fp);
- fp->fd = fd;
- fp->mode = rb_io_modenum_flags(flags);
- io_check_tty(fp);
- }
- else if (RFILE(io)->fptr) {
- rb_raise(rb_eRuntimeError, "reinitializing IO");
- }
- else {
- GetOpenFile(orig, ofp);
- if (ofp->refcnt == LONG_MAX) {
- VALUE s = rb_inspect(orig);
- rb_raise(rb_eIOError, "too many shared IO for %s", StringValuePtr(s));
- }
- if (argc == 2) {
- fmode = rb_io_modenum_flags(flags);
- if ((ofp->mode ^ fmode) & (FMODE_READWRITE|FMODE_BINMODE)) {
- if (FIXNUM_P(mode)) {
- rb_raise(rb_eArgError, "incompatible mode 0%o", flags);
- }
- else {
- rb_raise(rb_eArgError, "incompatible mode \"%s\"", RSTRING_PTR(mode));
- }
- }
- }
- ofp->refcnt++;
- RFILE(io)->fptr = ofp;
}
+ MakeOpenFile(io, fp);
+ fp->mode = rb_io_modenum_flags(flags);
+ fp->f = rb_fdopen(fd, rb_io_modenum_mode(flags));
return io;
}
-
/*
* call-seq:
* File.new(filename, mode="r") => file
* File.new(filename [, mode [, perm]]) => file
- *
+ *
* Opens the file named by _filename_ according to
* _mode_ (default is ``r'') and returns a new
@@ -4728,7 +4388,10 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
*/
static VALUE
-rb_file_initialize(int argc, VALUE *argv, VALUE io)
+rb_file_initialize(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
if (RFILE(io)->fptr) {
rb_raise(rb_eRuntimeError, "reinitializing File");
@@ -4749,26 +4412,29 @@ rb_file_initialize(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* IO.new(fd, mode_string) => io
- *
+ *
* Returns a new <code>IO</code> object (a stream) for the given
* integer file descriptor and mode string. See also
* <code>IO#fileno</code> and <code>IO::for_fd</code>.
- *
+ *
* a = IO.new(2,"w") # '2' is standard error
* $stderr.puts "Hello"
* a.puts "World"
- *
+ *
* <em>produces:</em>
- *
+ *
* Hello
* World
*/
static VALUE
-rb_io_s_new(int argc, VALUE *argv, VALUE klass)
+rb_io_s_new(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
if (rb_block_given_p()) {
- char *cname = rb_class2name(klass);
+ const char *cname = rb_class2name(klass);
rb_warn("%s::new() does not take block; use %s::open() instead",
cname, cname);
@@ -4776,34 +4442,35 @@ rb_io_s_new(int argc, VALUE *argv, VALUE klass)
return rb_class_new_instance(argc, argv, klass);
}
-
/*
* call-seq:
* IO.for_fd(fd, mode) => io
- *
+ *
* Synonym for <code>IO::new</code>.
- *
+ *
*/
static VALUE
-rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass)
+rb_io_s_for_fd(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE io = rb_obj_alloc(klass);
rb_io_initialize(argc, argv, io);
return io;
}
-static int argf_binmode = 0;
-static rb_encoding *argf_enc, *argf_enc2;
+static int binmode = 0;
static VALUE
argf_forward(int argc, VALUE *argv)
{
- return rb_funcall3(current_file, rb_frame_this_func(), argc, argv);
+ return rb_funcall3(current_file, ruby_frame->last_func, argc, argv);
}
#define ARGF_FORWARD(argc, argv) do {\
- if (current_file == rb_stdin && TYPE(current_file) != T_FILE)\
+ if (TYPE(current_file) != T_FILE)\
return argf_forward(argc, argv);\
} while (0)
#define NEXT_ARGF_FORWARD(argc, argv) do {\
@@ -4812,13 +4479,17 @@ argf_forward(int argc, VALUE *argv)
} while (0)
static void
-argf_close(VALUE file)
+argf_close(file)
+ VALUE file;
{
- rb_funcall3(file, rb_intern("close"), 0, 0);
+ if (TYPE(file) == T_FILE)
+ rb_io_close(file);
+ else
+ rb_funcall3(file, rb_intern("close"), 0, 0);
}
static int
-next_argv(void)
+next_argv()
{
extern VALUE rb_argv;
char *fn;
@@ -4832,7 +4503,7 @@ next_argv(void)
}
if (init_p == 0) {
- if (RARRAY_LEN(rb_argv) > 0) {
+ if (RARRAY(rb_argv)->len > 0) {
next_p = 1;
}
else {
@@ -4845,9 +4516,9 @@ next_argv(void)
if (next_p == 1) {
next_p = 0;
retry:
- if (RARRAY_LEN(rb_argv) > 0) {
+ if (RARRAY(rb_argv)->len > 0) {
filename = rb_ary_shift(rb_argv);
- fn = StringValuePtr(filename);
+ fn = StringValueCStr(filename);
if (strlen(fn) == 1 && fn[0] == '-') {
current_file = rb_stdin;
if (ruby_inplace_mode) {
@@ -4856,7 +4527,7 @@ next_argv(void)
}
}
else {
- int fr = rb_sysopen(fn, O_RDONLY, 0);
+ FILE *fr = rb_fopen(fn, "r");
if (ruby_inplace_mode) {
struct stat st;
@@ -4864,12 +4535,12 @@ next_argv(void)
struct stat st2;
#endif
VALUE str;
- int fw;
+ FILE *fw;
if (TYPE(rb_stdout) == T_FILE && rb_stdout != orig_stdout) {
rb_io_close(rb_stdout);
}
- fstat(fr, &st);
+ fstat(fileno(fr), &st);
if (*ruby_inplace_mode) {
str = rb_str_new2(fn);
#ifdef NO_LONG_FNAME
@@ -4878,15 +4549,15 @@ next_argv(void)
rb_str_cat2(str, ruby_inplace_mode);
#endif
#ifdef NO_SAFE_RENAME
- (void)close(fr);
- (void)unlink(RSTRING_PTR(str));
- (void)rename(fn, RSTRING_PTR(str));
- fr = rb_sysopen(RSTRING_PTR(str), O_RDONLY, 0);
+ (void)fclose(fr);
+ (void)unlink(RSTRING(str)->ptr);
+ (void)rename(fn, RSTRING(str)->ptr);
+ fr = rb_fopen(RSTRING(str)->ptr, "r");
#else
- if (rename(fn, RSTRING_PTR(str)) < 0) {
+ if (rename(fn, RSTRING(str)->ptr) < 0) {
rb_warn("Can't rename %s to %s: %s, skipping file",
- fn, RSTRING_PTR(str), strerror(errno));
- close(fr);
+ fn, RSTRING(str)->ptr, strerror(errno));
+ fclose(fr);
goto retry;
}
#endif
@@ -4898,36 +4569,31 @@ next_argv(void)
if (unlink(fn) < 0) {
rb_warn("Can't remove %s: %s, skipping file",
fn, strerror(errno));
- close(fr);
+ fclose(fr);
goto retry;
}
#endif
}
- fw = rb_sysopen(fn, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+ fw = rb_fopen(fn, "w");
#ifndef NO_SAFE_RENAME
- fstat(fw, &st2);
+ fstat(fileno(fw), &st2);
#ifdef HAVE_FCHMOD
- fchmod(fw, st.st_mode);
+ fchmod(fileno(fw), st.st_mode);
#else
chmod(fn, st.st_mode);
#endif
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
- fchown(fw, st.st_uid, st.st_gid);
+ fchown(fileno(fw), st.st_uid, st.st_gid);
}
#endif
- rb_stdout = prep_io(fw, FMODE_WRITABLE, rb_cFile, fn);
+ rb_stdout = prep_stdio(fw, FMODE_WRITABLE, rb_cFile);
+ prep_path(rb_stdout, fn);
if (stdout_binmode) rb_io_binmode(rb_stdout);
}
- current_file = prep_io(fr, FMODE_READABLE, rb_cFile, fn);
- }
- if (argf_binmode) rb_io_binmode(current_file);
- if (argf_enc) {
- rb_io_t *fptr;
-
- GetOpenFile(current_file, fptr);
- fptr->enc = argf_enc;
- fptr->enc2 = argf_enc2;
+ current_file = prep_stdio(fr, FMODE_READABLE, rb_cFile);
+ prep_path(current_file, fn);
}
+ if (binmode) rb_io_binmode(current_file);
}
else {
next_p = 1;
@@ -4946,27 +4612,33 @@ next_argv(void)
}
static VALUE
-argf_getline(int argc, VALUE *argv)
+argf_getline(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE line;
retry:
if (!next_argv()) return Qnil;
- if (current_file == rb_stdin && TYPE(current_file) != T_FILE) {
- line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
+ if (argc == 0 && rb_rs == rb_default_rs) {
+ line = rb_io_gets(current_file);
}
else {
- if (argc == 0 && rb_rs == rb_default_rs) {
- line = rb_io_gets(current_file);
+ VALUE rs;
+
+ if (argc == 0) {
+ rs = rb_rs;
}
else {
- line = rb_io_getline(argc, argv, current_file);
- }
- if (NIL_P(line) && next_p != -1) {
- argf_close(current_file);
- next_p = 1;
- goto retry;
+ rb_scan_args(argc, argv, "1", &rs);
+ if (!NIL_P(rs)) StringValue(rs);
}
+ line = rb_io_getline(rs, current_file);
+ }
+ if (NIL_P(line) && next_p != -1) {
+ argf_close(current_file);
+ next_p = 1;
+ goto retry;
}
if (!NIL_P(line)) {
gets_lineno++;
@@ -4977,49 +4649,53 @@ argf_getline(int argc, VALUE *argv)
/*
* call-seq:
- * gets(sep=$/) => string or nil
- * gets(limit) => string or nil
- * gets(sep,limit) => string or nil
- *
+ * gets(separator=$/) => string or nil
+ *
* Returns (and assigns to <code>$_</code>) the next line from the list
- * of files in +ARGV+ (or <code>$*</code>), or from standard input if
- * no files are present on the command line. Returns +nil+ at end of
- * file. The optional argument specifies the record separator. The
- * separator is included with the contents of each record. A separator
- * of +nil+ reads the entire contents, and a zero-length separator
- * reads the input one paragraph at a time, where paragraphs are
- * divided by two consecutive newlines. If the first argument is an
- * integer, or optional second argument is given, the returning string
- * would not be longer than the given value. If multiple filenames are
- * present in +ARGV+, +gets(nil)+ will read the contents one file at a
- * time.
- *
+ * of files in +ARGV+ (or <code>$*</code>), or from standard
+ * input if no files are present on the command line. Returns
+ * +nil+ at end of file. The optional argument specifies the
+ * record separator. The separator is included with the contents of
+ * each record. A separator of +nil+ reads the entire
+ * contents, and a zero-length separator reads the input one paragraph
+ * at a time, where paragraphs are divided by two consecutive newlines.
+ * If multiple filenames are present in +ARGV+,
+ * +gets(nil)+ will read the contents one file at a time.
+ *
* ARGV << "testfile"
* print while gets
- *
+ *
* <em>produces:</em>
- *
+ *
* This is line one
* This is line two
* This is line three
* And so on...
- *
+ *
* The style of programming using <code>$_</code> as an implicit
* parameter is gradually losing favor in the Ruby community.
*/
static VALUE
-rb_f_gets(int argc, VALUE *argv)
+rb_f_gets(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE line;
- line = argf_getline(argc, argv);
+ if (!next_argv()) return Qnil;
+ if (TYPE(current_file) != T_FILE) {
+ line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
+ }
+ else {
+ line = argf_getline(argc, argv);
+ }
rb_lastline_set(line);
return line;
}
VALUE
-rb_gets(void)
+rb_gets()
{
VALUE line;
@@ -5031,7 +4707,7 @@ rb_gets(void)
if (!next_argv()) return Qnil;
line = rb_io_gets(current_file);
if (NIL_P(line) && next_p != -1) {
- rb_io_close(current_file);
+ argf_close(current_file);
next_p = 1;
goto retry;
}
@@ -5046,16 +4722,16 @@ rb_gets(void)
/*
* call-seq:
- * readline(sep=$/) => string
- * readline(limit) => string
- * readline(sep, limit) => string
- *
+ * readline(separator=$/) => string
+ *
* Equivalent to <code>Kernel::gets</code>, except
* +readline+ raises +EOFError+ at end of file.
*/
static VALUE
-rb_f_readline(int argc, VALUE *argv)
+rb_f_readline(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE line;
@@ -5070,20 +4746,35 @@ rb_f_readline(int argc, VALUE *argv)
}
/*
+ * obsolete
+ */
+
+static VALUE
+rb_f_getc()
+{
+ rb_warn("getc is obsolete; use STDIN.getc instead");
+ if (TYPE(rb_stdin) != T_FILE) {
+ return rb_funcall3(rb_stdin, rb_intern("getc"), 0, 0);
+ }
+ return rb_io_getc(rb_stdin);
+}
+
+/*
* call-seq:
- * readlines(sep=$/) => array
- * readlines(limit) => array
- * readlines(sep,limit) => array
- *
+ * readlines(separator=$/) => array
+ *
* Returns an array containing the lines returned by calling
- * <code>Kernel.gets(<i>sep</i>)</code> until the end of file.
+ * <code>Kernel.gets(<i>separator</i>)</code> until the end of file.
*/
static VALUE
-rb_f_readlines(int argc, VALUE *argv)
+rb_f_readlines(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE line, ary;
+ NEXT_ARGF_FORWARD(argc, argv);
ary = rb_ary_new();
while (!NIL_P(line = argf_getline(argc, argv))) {
rb_ary_push(ary, line);
@@ -5095,11 +4786,11 @@ rb_f_readlines(int argc, VALUE *argv)
/*
* call-seq:
* `cmd` => string
- *
+ *
* Returns the standard output of running _cmd_ in a subshell.
* The built-in syntax <code>%x{...}</code> uses
* this method. Sets <code>$?</code> to the process status.
- *
+ *
* `date` #=> "Wed Apr 9 08:56:30 CDT 2003\n"
* `ls testdir`.split[1] #=> "main.rb"
* `echo oops && exit 99` #=> "oops\n"
@@ -5107,14 +4798,15 @@ rb_f_readlines(int argc, VALUE *argv)
*/
static VALUE
-rb_f_backquote(VALUE obj, VALUE str)
+rb_f_backquote(obj, str)
+ VALUE obj, str;
{
volatile VALUE port;
VALUE result;
rb_io_t *fptr;
SafeStringValue(str);
- port = pipe_open_s(str, "r");
+ port = pipe_open(str, 0, "r");
if (NIL_P(port)) return rb_str_new(0,0);
GetOpenFile(port, fptr);
@@ -5128,66 +4820,93 @@ rb_f_backquote(VALUE obj, VALUE str)
#include <sys/select.h>
#endif
+/*
+ * call-seq:
+ * IO.select(read_array
+ * [, write_array
+ * [, error_array
+ * [, timeout]]] ) => array or nil
+ *
+ * See <code>Kernel#select</code>.
+ */
+
static VALUE
-select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fdset_t *fds)
+rb_f_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
- VALUE res, list;
+ VALUE read, write, except, timeout, res, list;
+ fd_set rset, wset, eset, pset;
fd_set *rp, *wp, *ep;
+ struct timeval *tp, timerec;
rb_io_t *fptr;
long i;
int max = 0, n;
int interrupt_flag = 0;
int pending = 0;
- struct timeval timerec;
+ rb_scan_args(argc, argv, "13", &read, &write, &except, &timeout);
+ if (NIL_P(timeout)) {
+ tp = 0;
+ }
+ else {
+ timerec = rb_time_interval(timeout);
+ tp = &timerec;
+ }
+
+ FD_ZERO(&pset);
if (!NIL_P(read)) {
Check_Type(read, T_ARRAY);
- for (i=0; i<RARRAY_LEN(read); i++) {
- GetOpenFile(rb_io_get_io(RARRAY_PTR(read)[i]), fptr);
- rb_fd_set(fptr->fd, &fds[0]);
- if (READ_DATA_PENDING(fptr)) { /* check for buffered data */
+ rp = &rset;
+ FD_ZERO(rp);
+ for (i=0; i<RARRAY(read)->len; i++) {
+ GetOpenFile(rb_io_get_io(RARRAY(read)->ptr[i]), fptr);
+ FD_SET(fileno(fptr->f), rp);
+ if (READ_DATA_PENDING(fptr->f)) { /* check for buffered data */
pending++;
- rb_fd_set(fptr->fd, &fds[3]);
+ FD_SET(fileno(fptr->f), &pset);
}
- if (max < fptr->fd) max = fptr->fd;
+ if (max < fileno(fptr->f)) max = fileno(fptr->f);
}
if (pending) { /* no blocking if there's buffered data */
timerec.tv_sec = timerec.tv_usec = 0;
tp = &timerec;
}
- rp = rb_fd_ptr(&fds[0]);
}
else
rp = 0;
if (!NIL_P(write)) {
Check_Type(write, T_ARRAY);
- for (i=0; i<RARRAY_LEN(write); i++) {
- VALUE write_io = GetWriteIO(rb_io_get_io(RARRAY_PTR(write)[i]));
- GetOpenFile(write_io, fptr);
- rb_fd_set(fptr->fd, &fds[1]);
- if (max < fptr->fd) max = fptr->fd;
+ wp = &wset;
+ FD_ZERO(wp);
+ for (i=0; i<RARRAY(write)->len; i++) {
+ GetOpenFile(rb_io_get_io(RARRAY(write)->ptr[i]), fptr);
+ FD_SET(fileno(fptr->f), wp);
+ if (max < fileno(fptr->f)) max = fileno(fptr->f);
+ if (fptr->f2) {
+ FD_SET(fileno(fptr->f2), wp);
+ if (max < fileno(fptr->f2)) max = fileno(fptr->f2);
+ }
}
- wp = rb_fd_ptr(&fds[1]);
}
else
wp = 0;
if (!NIL_P(except)) {
Check_Type(except, T_ARRAY);
- for (i=0; i<RARRAY_LEN(except); i++) {
- VALUE io = rb_io_get_io(RARRAY_PTR(except)[i]);
- VALUE write_io = GetWriteIO(io);
- GetOpenFile(io, fptr);
- rb_fd_set(fptr->fd, &fds[2]);
- if (max < fptr->fd) max = fptr->fd;
- if (io != write_io) {
- GetOpenFile(write_io, fptr);
- rb_fd_set(fptr->fd, &fds[2]);
- if (max < fptr->fd) max = fptr->fd;
- }
+ ep = &eset;
+ FD_ZERO(ep);
+ for (i=0; i<RARRAY(except)->len; i++) {
+ GetOpenFile(rb_io_get_io(RARRAY(except)->ptr[i]), fptr);
+ FD_SET(fileno(fptr->f), ep);
+ if (max < fileno(fptr->f)) max = fileno(fptr->f);
+ if (fptr->f2) {
+ FD_SET(fileno(fptr->f2), ep);
+ if (max < fileno(fptr->f2)) max = fileno(fptr->f2);
+ }
}
- ep = rb_fd_ptr(&fds[2]);
}
else {
ep = 0;
@@ -5208,47 +4927,39 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd
if (interrupt_flag == 0) {
if (rp) {
- list = RARRAY_PTR(res)[0];
- for (i=0; i< RARRAY_LEN(read); i++) {
- VALUE obj = rb_ary_entry(read, i);
- VALUE io = rb_io_get_io(obj);
- GetOpenFile(io, fptr);
- if (rb_fd_isset(fptr->fd, &fds[0]) ||
- rb_fd_isset(fptr->fd, &fds[3])) {
- rb_ary_push(list, obj);
+ list = RARRAY(res)->ptr[0];
+ for (i=0; i< RARRAY(read)->len; i++) {
+ GetOpenFile(rb_io_get_io(RARRAY(read)->ptr[i]), fptr);
+ if (FD_ISSET(fileno(fptr->f), rp)
+ || FD_ISSET(fileno(fptr->f), &pset)) {
+ rb_ary_push(list, rb_ary_entry(read, i));
}
}
}
if (wp) {
- list = RARRAY_PTR(res)[1];
- for (i=0; i< RARRAY_LEN(write); i++) {
- VALUE obj = rb_ary_entry(write, i);
- VALUE io = rb_io_get_io(obj);
- VALUE write_io = GetWriteIO(io);
- GetOpenFile(write_io, fptr);
- if (rb_fd_isset(fptr->fd, &fds[1])) {
- rb_ary_push(list, obj);
+ list = RARRAY(res)->ptr[1];
+ for (i=0; i< RARRAY(write)->len; i++) {
+ GetOpenFile(rb_io_get_io(RARRAY(write)->ptr[i]), fptr);
+ if (FD_ISSET(fileno(fptr->f), wp)) {
+ rb_ary_push(list, rb_ary_entry(write, i));
+ }
+ else if (fptr->f2 && FD_ISSET(fileno(fptr->f2), wp)) {
+ rb_ary_push(list, rb_ary_entry(write, i));
}
}
}
if (ep) {
- list = RARRAY_PTR(res)[2];
- for (i=0; i< RARRAY_LEN(except); i++) {
- VALUE obj = rb_ary_entry(write, i);
- VALUE io = rb_io_get_io(obj);
- VALUE write_io = GetWriteIO(io);
- GetOpenFile(io, fptr);
- if (rb_fd_isset(fptr->fd, &fds[2])) {
- rb_ary_push(list, obj);
+ list = RARRAY(res)->ptr[2];
+ for (i=0; i< RARRAY(except)->len; i++) {
+ GetOpenFile(rb_io_get_io(RARRAY(except)->ptr[i]), fptr);
+ if (FD_ISSET(fileno(fptr->f), ep)) {
+ rb_ary_push(list, rb_ary_entry(except, i));
+ }
+ else if (fptr->f2 && FD_ISSET(fileno(fptr->f2), ep)) {
+ rb_ary_push(list, rb_ary_entry(except, i));
}
- else if (io != write_io) {
- GetOpenFile(write_io, fptr);
- if (rb_fd_isset(fptr->fd, &fds[2])) {
- rb_ary_push(list, obj);
- }
- }
}
}
}
@@ -5256,75 +4967,11 @@ select_internal(VALUE read, VALUE write, VALUE except, struct timeval *tp, rb_fd
return res; /* returns an empty array on interrupt */
}
-struct select_args {
- VALUE read, write, except;
- struct timeval *timeout;
- rb_fdset_t fdsets[4];
-};
-
-#ifdef HAVE_RB_FD_INIT
-static VALUE
-select_call(VALUE arg)
-{
- struct select_args *p = (struct select_args *)arg;
-
- return select_internal(p->read, p->write, p->except, p->timeout, p->fdsets);
-}
-
-static VALUE
-select_end(VALUE arg)
-{
- struct select_args *p = (struct select_args *)arg;
- int i;
-
- for (i = 0; i < sizeof(p->fdsets) / sizeof(p->fdsets[0]); ++i)
- rb_fd_term(&p->fdsets[i]);
- return Qnil;
-}
-#endif
-
-/*
- * call-seq:
- * IO.select(read_array
- * [, write_array
- * [, error_array
- * [, timeout]]] ) => array or nil
- *
- * See <code>Kernel#select</code>.
- */
-
-static VALUE
-rb_f_select(int argc, VALUE *argv, VALUE obj)
-{
- VALUE timeout;
- struct select_args args;
- struct timeval timerec;
- int i;
-
- rb_scan_args(argc, argv, "13", &args.read, &args.write, &args.except, &timeout);
- if (NIL_P(timeout)) {
- args.timeout = 0;
- }
- else {
- timerec = rb_time_interval(timeout);
- args.timeout = &timerec;
- }
-
- for (i = 0; i < sizeof(args.fdsets) / sizeof(args.fdsets[0]); ++i)
- rb_fd_init(&args.fdsets[i]);
-
-#ifdef HAVE_RB_FD_INIT
- return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args);
-#else
- return select_internal(args.read, args.write, args.except,
- args.timeout, args.fdsets);
-#endif
-
-}
-
#if !defined(MSDOS) && !defined(__human68k__)
static int
-io_cntl(int fd, int cmd, long narg, int io_p)
+io_cntl(fd, cmd, narg, io_p)
+ int fd, cmd, io_p;
+ long narg;
{
int retval;
@@ -5349,7 +4996,9 @@ io_cntl(int fd, int cmd, long narg, int io_p)
#endif
static VALUE
-rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
+rb_io_ctl(io, req, arg, io_p)
+ VALUE io, req, arg;
+ int io_p;
{
#if !defined(MSDOS) && !defined(__human68k__)
int cmd = NUM2ULONG(req);
@@ -5389,23 +5038,28 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
#endif
rb_str_modify(arg);
- if (len <= RSTRING_LEN(arg)) {
- len = RSTRING_LEN(arg);
+ if (len <= RSTRING(arg)->len) {
+ len = RSTRING(arg)->len;
}
- if (RSTRING_LEN(arg) < len) {
+ if (RSTRING(arg)->len < len) {
rb_str_resize(arg, len+1);
}
- RSTRING_PTR(arg)[len] = 17; /* a little sanity check here */
- narg = (long)RSTRING_PTR(arg);
+ RSTRING(arg)->ptr[len] = 17; /* a little sanity check here */
+ narg = (long)RSTRING(arg)->ptr;
}
}
GetOpenFile(io, fptr);
- retval = io_cntl(fptr->fd, cmd, narg, io_p);
+ retval = io_cntl(fileno(fptr->f), cmd, narg, io_p);
if (retval < 0) rb_sys_fail(fptr->path);
- if (TYPE(arg) == T_STRING && RSTRING_PTR(arg)[len] != 17) {
+ if (TYPE(arg) == T_STRING && RSTRING(arg)->ptr[len] != 17) {
rb_raise(rb_eArgError, "return value overflowed string");
}
+ if (fptr->f2 && fileno(fptr->f) != fileno(fptr->f2)) {
+ /* call on f2 too; ignore result */
+ io_cntl(fileno(fptr->f2), cmd, narg, io_p);
+ }
+
if (!io_p && cmd == F_SETFL) {
if (narg & O_NONBLOCK) {
fptr->mode |= FMODE_WSPLIT_INITIALIZED;
@@ -5423,11 +5077,10 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
#endif
}
-
/*
* call-seq:
* ios.ioctl(integer_cmd, arg) => integer
- *
+ *
* Provides a mechanism for issuing low-level commands to control or
* query I/O devices. Arguments and results are platform dependent. If
* <i>arg</i> is a number, its value is passed directly. If it is a
@@ -5437,7 +5090,10 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
*/
static VALUE
-rb_io_ioctl(int argc, VALUE *argv, VALUE io)
+rb_io_ioctl(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
VALUE req, arg;
@@ -5448,7 +5104,7 @@ rb_io_ioctl(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* ios.fcntl(integer_cmd, arg) => integer
- *
+ *
* Provides a mechanism for issuing low-level commands to control or
* query file-oriented I/O streams. Arguments and results are platform
* dependent. If <i>arg</i> is a number, its value is passed
@@ -5459,7 +5115,10 @@ rb_io_ioctl(int argc, VALUE *argv, VALUE io)
*/
static VALUE
-rb_io_fcntl(int argc, VALUE *argv, VALUE io)
+rb_io_fcntl(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
#ifdef HAVE_FCNTL
VALUE req, arg;
@@ -5475,7 +5134,7 @@ rb_io_fcntl(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
* syscall(fixnum [, args...]) => integer
- *
+ *
* Calls the operating system function identified by _fixnum_,
* passing in the arguments, which must be either +String+
* objects, or +Integer+ objects that ultimately fit within
@@ -5483,16 +5142,18 @@ rb_io_fcntl(int argc, VALUE *argv, VALUE io)
* on the Atari-ST). The function identified by _fixnum_ is system
* dependent. On some Unix systems, the numbers may be obtained from a
* header file called <code>syscall.h</code>.
- *
+ *
* syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box
- *
+ *
* <em>produces:</em>
- *
+ *
* hello
*/
static VALUE
-rb_f_syscall(int argc, VALUE *argv)
+rb_f_syscall(argc, argv)
+ int argc;
+ VALUE *argv;
{
#if defined(HAVE_SYSCALL) && !defined(__CHECKER__)
#ifdef atarist
@@ -5521,7 +5182,7 @@ rb_f_syscall(int argc, VALUE *argv)
if (!NIL_P(v)) {
StringValue(v);
rb_str_modify(v);
- arg[i] = (unsigned long)RSTRING_PTR(v);
+ arg[i] = (unsigned long)StringValueCStr(v);
}
else {
arg[i] = (unsigned long)NUM2LONG(*argv);
@@ -5592,58 +5253,32 @@ rb_f_syscall(int argc, VALUE *argv)
#endif
}
+static VALUE io_new_instance _((VALUE));
static VALUE
-io_new_instance(VALUE args)
+io_new_instance(args)
+ VALUE args;
{
return rb_class_new_instance(2, (VALUE*)args+1, *(VALUE*)args);
}
-static void
-io_encoding_set(rb_io_t *fptr, int argc, VALUE v1, VALUE v2)
-{
- if (argc == 2) {
- fptr->enc2 = rb_to_encoding(v1);
- fptr->enc = rb_to_encoding(v2);
- }
- else if (argc == 1) {
- VALUE tmp = rb_check_string_type(v1);
- if (!NIL_P(tmp)) {
- mode_enc(fptr, StringValueCStr(tmp));
- }
- else {
- fptr->enc = rb_to_encoding(v1);
- }
- }
-}
-
/*
* call-seq:
- * IO.pipe -> array
- * IO.pipe(encoding) -> array
- * IO.pipe(encoding1, encoding2) -> array
- *
+ * IO.pipe -> array
+ *
* Creates a pair of pipe endpoints (connected to each other) and
* returns them as a two-element array of <code>IO</code> objects:
* <code>[</code> <i>read_file</i>, <i>write_file</i> <code>]</code>. Not
* available on all platforms.
- *
- * If an optional argument is specified, read string from pipe is tagged
- * with the encoding specified. If encoding is a comma separated two
- * encoding names "A:B", the read string is converted from encoding A
- * (external encoding) to encoding B (internal encoding), then tagged
- * with B. If two optional arguments are specified, those must be
- * encoding objects, and the first one is the external encoding, and the
- * second one is the internal encoding.
- *
+ *
* In the example below, the two processes close the ends of the pipe
* that they are not using. This is not just a cosmetic nicety. The
* read end of a pipe will not generate an end of file condition if
* there are any writers with the pipe still open. In the case of the
* parent process, the <code>rd.read</code> will never return if it
* does not first issue a <code>wr.close</code>.
- *
+ *
* rd, wr = IO.pipe
- *
+ *
* if fork
* wr.close
* puts "Parent got: <#{rd.read}>"
@@ -5655,26 +5290,26 @@ io_encoding_set(rb_io_t *fptr, int argc, VALUE v1, VALUE v2)
* wr.write "Hi Dad"
* wr.close
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* Sending message to parent
* Parent got: <Hi Dad>
*/
static VALUE
-rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
+rb_io_s_pipe(klass)
+ VALUE klass;
{
-#ifdef __human68k__
- rb_notimplement();
- return Qnil; /* not reached */
-#else
+#ifndef __human68k__
int pipes[2], state;
- VALUE r, w, args[3], v1, v2;
- rb_io_t *fptr;
+ VALUE r, w, args[3];
- rb_scan_args(argc, argv, "02", &v1, &v2);
+#ifdef _WIN32
+ if (_pipe(pipes, 1024, O_BINARY) == -1)
+#else
if (pipe(pipes) == -1)
+#endif
rb_sys_fail(0);
args[0] = klass;
@@ -5686,8 +5321,6 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
close(pipes[1]);
rb_jump_tag(state);
}
- GetOpenFile(r, fptr);
- io_encoding_set(fptr, argc, v1, v2);
args[1] = INT2NUM(pipes[1]);
args[2] = INT2FIX(O_WRONLY);
w = rb_protect(io_new_instance, (VALUE)args, &state);
@@ -5699,82 +5332,25 @@ rb_io_s_pipe(int argc, VALUE *argv, VALUE klass)
rb_io_synchronized(RFILE(w)->fptr);
return rb_assoc_new(r, w);
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
#endif
}
struct foreach_arg {
int argc;
- VALUE *argv;
+ VALUE sep;
VALUE io;
};
-static void
-open_key_args(int argc, VALUE *argv, struct foreach_arg *arg)
-{
- VALUE opt, v;
- static VALUE encoding, mode, open_args;
-
- FilePathValue(argv[0]);
- arg->argc = argc > 1 ? 1 : 0;
- arg->argv = argv + 1;
- if (argc == 1) {
- no_key:
- arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r");
- return;
- }
- opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
- if (NIL_P(opt)) goto no_key;
- if (argc > 2) arg->argc = 1;
- else arg->argc = 0;
- if (!encoding) {
- ID id;
-
- id = rb_intern("encoding");
- encoding = ID2SYM(id);
- id = rb_intern("mode");
- mode = ID2SYM(id);
- id = rb_intern("open_args");
- open_args = ID2SYM(id);
- }
- v = rb_hash_aref(opt, open_args);
- if (!NIL_P(v)) {
- VALUE args;
-
- v = rb_convert_type(v, T_ARRAY, "Array", "to_ary");
- args = rb_ary_new2(RARRAY_LEN(v)+1);
- rb_ary_push(args, argv[0]);
- rb_ary_concat(args, v);
- MEMCPY(RARRAY_PTR(args)+1, RARRAY_PTR(v), VALUE, RARRAY_LEN(v));
-
- arg->io = rb_f_open(RARRAY_LEN(args), RARRAY_PTR(args));
- return;
- }
- v = rb_hash_aref(opt, mode);
- if (!NIL_P(v)) {
- VALUE args[2];
-
- args[0] = argv[0];
- args[1] = v;
- arg->io = rb_f_open(2, args);
- return;
- }
- v = rb_hash_aref(opt, encoding);
- if (!NIL_P(v)) {
- rb_io_t *fptr;
-
- arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r");
- GetOpenFile(arg->io, fptr);
- fptr->enc = rb_to_encoding(v);
- return;
- }
-}
-
static VALUE
-io_s_foreach(struct foreach_arg *arg)
+io_s_foreach(arg)
+ struct foreach_arg *arg;
{
VALUE str;
- while (!NIL_P(str = rb_io_gets_m(arg->argc, arg->argv, arg->io))) {
+ while (!NIL_P(str = rb_io_getline(arg->sep, arg->io))) {
rb_yield(str);
}
return Qnil;
@@ -5782,227 +5358,127 @@ io_s_foreach(struct foreach_arg *arg)
/*
* call-seq:
- * IO.foreach(name, sep=$/) {|line| block } => nil
- * IO.foreach(name, limit) {|line| block } => nil
- * IO.foreach(name, sep, limit) {|line| block } => nil
- *
+ * IO.foreach(name, sep_string=$/) {|line| block } => nil
+ *
* Executes the block for every line in the named I/O port, where lines
- * are separated by <em>sep</em>.
- *
+ * are separated by <em>sep_string</em>.
+ *
* IO.foreach("testfile") {|x| print "GOT ", x }
- *
+ *
* <em>produces:</em>
- *
+ *
* GOT This is line one
* GOT This is line two
* GOT This is line three
* GOT And so on...
- *
- * If the last argument is a hash, it's the keyword argument to open.
- * See <code>IO.read</code> for detail.
- *
- */
+ */
static VALUE
-rb_io_s_foreach(int argc, VALUE *argv, VALUE self)
+rb_io_s_foreach(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
+ VALUE fname;
struct foreach_arg arg;
- rb_scan_args(argc, argv, "13", NULL, NULL, NULL, NULL);
+ rb_scan_args(argc, argv, "11", &fname, &arg.sep);
RETURN_ENUMERATOR(self, argc, argv);
- open_key_args(argc, argv, &arg);
+ SafeStringValue(fname);
+
+ if (argc == 1) {
+ arg.sep = rb_default_rs;
+ }
+ else if (!NIL_P(arg.sep)) {
+ StringValue(arg.sep);
+ }
+ arg.io = rb_io_open(StringValueCStr(fname), "r");
if (NIL_P(arg.io)) return Qnil;
+
return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io);
}
static VALUE
-io_s_readlines(struct foreach_arg *arg)
+io_s_readlines(arg)
+ struct foreach_arg *arg;
{
- return rb_io_readlines(arg->argc, arg->argv, arg->io);
+ return rb_io_readlines(arg->argc, &arg->sep, arg->io);
}
/*
* call-seq:
- * IO.readlines(name, sep=$/) => array
- * IO.readlines(name, limit) => array
- * IO.readlines(name, sep, limit) => array
- *
+ * IO.readlines(name, sep_string=$/) => array
+ *
* Reads the entire file specified by <i>name</i> as individual
* lines, and returns those lines in an array. Lines are separated by
- * <i>sep</i>.
- *
+ * <i>sep_string</i>.
+ *
* a = IO.readlines("testfile")
* a[0] #=> "This is line one\n"
- *
- * If the last argument is a hash, it's the keyword argument to open.
- * See <code>IO.read</code> for detail.
- *
+ *
*/
static VALUE
-rb_io_s_readlines(int argc, VALUE *argv, VALUE io)
+rb_io_s_readlines(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
+ VALUE fname;
struct foreach_arg arg;
- rb_scan_args(argc, argv, "13", NULL, NULL, NULL, NULL);
- open_key_args(argc, argv, &arg);
+ rb_scan_args(argc, argv, "11", &fname, &arg.sep);
+ SafeStringValue(fname);
+
+ arg.argc = argc - 1;
+ arg.io = rb_io_open(StringValueCStr(fname), "r");
if (NIL_P(arg.io)) return Qnil;
return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io);
}
static VALUE
-io_s_read(struct foreach_arg *arg)
+io_s_read(arg)
+ struct foreach_arg *arg;
{
- return io_read(arg->argc, arg->argv, arg->io);
+ return io_read(arg->argc, &arg->sep, arg->io);
}
/*
* call-seq:
* IO.read(name, [length [, offset]] ) => string
- * IO.read(name, [length [, offset]], opt) => string
- *
+ *
* Opens the file, optionally seeks to the given offset, then returns
* <i>length</i> bytes (defaulting to the rest of the file).
* <code>read</code> ensures the file is closed before returning.
- *
- * If the last argument is a hash, it specifies option for internal
- * open(). The key would be the following. They are all exclusive,
- *
- * encoding: string or encoding
- *
- * specifies encoding of the read string. encoding will be ignored
- * if length is specified.
- *
- * mode: string
- *
- * specifies mode argument for open(). it should start with "r"
- * otherwise it would cause error.
- *
- * open_args: array of strings
- *
- * specifies arguments for open() as an array.
- *
+ *
* IO.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
* IO.read("testfile", 20) #=> "This is line one\nThi"
* IO.read("testfile", 20, 10) #=> "ne one\nThis is line "
*/
static VALUE
-rb_io_s_read(int argc, VALUE *argv, VALUE io)
+rb_io_s_read(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
- VALUE offset;
+ VALUE fname, offset;
struct foreach_arg arg;
- rb_scan_args(argc, argv, "13", NULL, NULL, &offset, NULL);
- open_key_args(argc, argv, &arg);
+ rb_scan_args(argc, argv, "12", &fname, &arg.sep, &offset);
+ SafeStringValue(fname);
+
+ arg.argc = argc ? 1 : 0;
+ arg.io = rb_io_open(StringValueCStr(fname), "r");
if (NIL_P(arg.io)) return Qnil;
if (!NIL_P(offset)) {
- rb_io_binmode(arg.io);
rb_io_seek(arg.io, offset, SEEK_SET);
- if (arg.argc == 2) arg.argc = 1;
}
return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io);
}
-
-/*
- * call-seq:
- * io.external_encoding => encoding
- *
- * Returns the Encoding object that represents the encoding of the file.
- * If io is write mode and no encoding is specified, returns <code>nil</code>.
- */
-
-static VALUE
-rb_io_external_encoding(VALUE io)
-{
- rb_io_t *fptr;
-
- GetOpenFile(io, fptr);
- if (fptr->enc2) {
- return rb_enc_from_encoding(fptr->enc2);
- }
- if (!fptr->enc && fptr->fd == 0) {
- fptr->enc = rb_default_external_encoding();
- }
- if (fptr->mode & FMODE_WRITABLE) {
- if (fptr->enc)
- return rb_enc_from_encoding(fptr->enc);
- return Qnil;
- }
- return rb_enc_from_encoding(io_read_encoding(fptr));
-}
-
-/*
- * call-seq:
- * io.internal_encoding => encoding
- *
- * Returns the Encoding of the internal string if conversion is
- * specified. Otherwise returns nil.
- */
-
-static VALUE
-rb_io_internal_encoding(VALUE io)
-{
- rb_io_t *fptr;
-
- GetOpenFile(io, fptr);
- if (!fptr->enc2) return Qnil;
- return rb_enc_from_encoding(io_read_encoding(fptr));
-}
-
-/*
- * call-seq:
- * io.set_encoding(enc) => io
- * io.set_encoding(enc1, enc2) => io
- *
- * If single argument is specified, read string from pipe is tagged
- * with the encoding specified. If encoding is a comma separated two
- * encoding names "A:B", the read string is converted from encoding A
- * (external encoding) to encoding B (internal encoding), then tagged
- * with B. If two arguments are specified, those must be encoding
- * objects, and the first one is the external encoding, and the
- * second one is the internal encoding.
- */
-
-static VALUE
-rb_io_set_encoding(int argc, VALUE *argv, VALUE io)
-{
- rb_io_t *fptr;
- VALUE v1, v2;
-
- rb_scan_args(argc, argv, "11", &v1, &v2);
- GetOpenFile(io, fptr);
- io_encoding_set(fptr, argc, v1, v2);
- return io;
-}
-
-static VALUE
-argf_external_encoding(void)
-{
- return rb_io_external_encoding(current_file);
-}
-
-static VALUE
-argf_internal_encoding(void)
-{
- return rb_io_internal_encoding(current_file);
-}
-
static VALUE
-argf_set_encoding(int argc, VALUE *argv, VALUE io)
-{
- rb_io_t *fptr;
-
- rb_io_set_encoding(argc, argv, current_file);
- GetOpenFile(io, fptr);
- argf_enc = fptr->enc;
- argf_enc2 = fptr->enc2;
- return io;
-}
-
-static VALUE
-argf_tell(void)
+argf_tell()
{
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to tell");
@@ -6012,7 +5488,10 @@ argf_tell(void)
}
static VALUE
-argf_seek_m(int argc, VALUE *argv, VALUE self)
+argf_seek_m(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to seek");
@@ -6022,7 +5501,8 @@ argf_seek_m(int argc, VALUE *argv, VALUE self)
}
static VALUE
-argf_set_pos(VALUE self, VALUE offset)
+argf_set_pos(self, offset)
+ VALUE self, offset;
{
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to set position");
@@ -6032,7 +5512,7 @@ argf_set_pos(VALUE self, VALUE offset)
}
static VALUE
-argf_rewind(void)
+argf_rewind()
{
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to rewind");
@@ -6042,7 +5522,7 @@ argf_rewind(void)
}
static VALUE
-argf_fileno(void)
+argf_fileno()
{
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream");
@@ -6052,7 +5532,7 @@ argf_fileno(void)
}
static VALUE
-argf_to_io(void)
+argf_to_io()
{
next_argv();
ARGF_FORWARD(0, 0);
@@ -6060,7 +5540,7 @@ argf_to_io(void)
}
static VALUE
-argf_eof(void)
+argf_eof()
{
if (current_file) {
if (init_p == 0) return Qtrue;
@@ -6073,7 +5553,9 @@ argf_eof(void)
}
static VALUE
-argf_read(int argc, VALUE *argv)
+argf_read(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE tmp, str, length;
long len = 0;
@@ -6092,7 +5574,7 @@ argf_read(int argc, VALUE *argv)
if (!next_argv()) {
return str;
}
- if (current_file == rb_stdin && TYPE(current_file) != T_FILE) {
+ if (TYPE(current_file) != T_FILE) {
tmp = argf_forward(argc, argv);
}
else {
@@ -6108,8 +5590,8 @@ argf_read(int argc, VALUE *argv)
}
}
else if (argc >= 1) {
- if (RSTRING_LEN(str) < len) {
- len -= RSTRING_LEN(str);
+ if (RSTRING(str)->len < len) {
+ len -= RSTRING(str)->len;
argv[0] = INT2NUM(len);
goto retry;
}
@@ -6117,179 +5599,131 @@ argf_read(int argc, VALUE *argv)
return str;
}
-struct argf_call_arg {
- int argc;
- VALUE *argv;
-};
-
-static VALUE
-argf_forward_call(VALUE arg)
-{
- struct argf_call_arg *p = (struct argf_call_arg *)arg;
- argf_forward(p->argc, p->argv);
- return Qnil;
-}
-
static VALUE
-argf_readpartial(int argc, VALUE *argv)
+argf_getc()
{
- VALUE tmp, str, length;
-
- rb_scan_args(argc, argv, "11", &length, &str);
- if (!NIL_P(str)) {
- StringValue(str);
- argv[1] = str;
- }
-
- if (!next_argv()) {
- rb_str_resize(str, 0);
- rb_eof_error();
- }
- if (current_file == rb_stdin && TYPE(current_file) != T_FILE) {
- struct argf_call_arg arg;
- arg.argc = argc;
- arg.argv = argv;
- tmp = rb_rescue2(argf_forward_call, (VALUE)&arg,
- RUBY_METHOD_FUNC(0), Qnil, rb_eEOFError, (VALUE)0);
- }
- else {
- tmp = io_getpartial(argc, argv, current_file, 0);
- }
- if (NIL_P(tmp)) {
- if (next_p == -1) {
- rb_eof_error();
- }
- argf_close(current_file);
- next_p = 1;
- if (RARRAY_LEN(rb_argv) == 0)
- rb_eof_error();
- if (NIL_P(str))
- str = rb_str_new(NULL, 0);
- return str;
- }
- return tmp;
-}
-
-static VALUE
-argf_getc(void)
-{
- VALUE ch;
+ VALUE byte;
retry:
if (!next_argv()) return Qnil;
- if (current_file == rb_stdin && TYPE(current_file) != T_FILE) {
- ch = rb_funcall3(current_file, rb_intern("getc"), 0, 0);
+ if (TYPE(current_file) != T_FILE) {
+ byte = rb_funcall3(current_file, rb_intern("getc"), 0, 0);
}
else {
- ch = rb_io_getc(current_file);
+ byte = rb_io_getc(current_file);
}
- if (NIL_P(ch) && next_p != -1) {
+ if (NIL_P(byte) && next_p != -1) {
argf_close(current_file);
next_p = 1;
goto retry;
}
- return ch;
+ return byte;
}
static VALUE
-argf_getbyte(void)
+argf_readchar()
{
- VALUE ch;
+ VALUE c;
- retry:
- if (!next_argv()) return Qnil;
- if (TYPE(current_file) != T_FILE) {
- ch = rb_funcall3(current_file, rb_intern("getbyte"), 0, 0);
- }
- else {
- ch = rb_io_getbyte(current_file);
- }
- if (NIL_P(ch) && next_p != -1) {
- argf_close(current_file);
- next_p = 1;
- goto retry;
+ NEXT_ARGF_FORWARD(0, 0);
+ c = argf_getc();
+ if (NIL_P(c)) {
+ rb_eof_error();
}
-
- return ch;
+ return c;
}
static VALUE
-argf_readchar(void)
+argf_each_line(argc, argv, argf)
+ int argc;
+ VALUE *argv;
+ VALUE argf;
{
- VALUE ch;
+ VALUE str;
- retry:
+ RETURN_ENUMERATOR(argf, argc, argv);
if (!next_argv()) return Qnil;
if (TYPE(current_file) != T_FILE) {
- ch = rb_funcall3(current_file, rb_intern("getc"), 0, 0);
- }
- else {
- ch = rb_io_getc(current_file);
+ for (;;) {
+ if (!next_argv()) return argf;
+ rb_iterate(rb_each, current_file, rb_yield, 0);
+ next_p = 1;
+ }
}
- if (NIL_P(ch) && next_p != -1) {
- argf_close(current_file);
- next_p = 1;
- goto retry;
+ while (!NIL_P(str = argf_getline(argc, argv))) {
+ rb_yield(str);
}
-
- return ch;
+ return argf;
}
static VALUE
-argf_readbyte(void)
+argf_each_byte(argf)
+ VALUE argf;
{
- VALUE c;
+ VALUE byte;
- NEXT_ARGF_FORWARD(0, 0);
- c = argf_getbyte();
- if (NIL_P(c)) {
- rb_eof_error();
+ RETURN_ENUMERATOR(argf, 0, 0);
+ while (!NIL_P(byte = argf_getc())) {
+ rb_yield(byte);
}
- return c;
+ return argf;
}
static VALUE
-argf_each_line(int argc, VALUE *argv, VALUE self)
+argf_each_char(argf)
+ VALUE argf;
{
- RETURN_ENUMERATOR(self, argc, argv);
- for (;;) {
- if (!next_argv()) return Qnil;
- rb_block_call(current_file, rb_intern("each_line"), 0, 0, rb_yield, 0);
- next_p = 1;
- }
- return self;
-}
+ VALUE ch;
-static VALUE
-argf_each_byte(VALUE self)
-{
- RETURN_ENUMERATOR(self, 0, 0);
- for (;;) {
- if (!next_argv()) return Qnil;
- rb_block_call(current_file, rb_intern("each_byte"), 0, 0, rb_yield, 0);
- next_p = 1;
+ RETURN_ENUMERATOR(argf, 0, 0);
+
+ while (!NIL_P(ch = argf_getc())) {
+ unsigned char c;
+ int n;
+ VALUE str, file;
+
+ first_char:
+ c = FIX2INT(ch);
+ n = mbclen(c);
+ str = rb_tainted_str_new((const char *)&c, 1);
+ file = current_file;
+
+ while (--n > 0) {
+ if (NIL_P(ch = argf_getc())) {
+ rb_yield(str);
+ return argf;
+ }
+ if (current_file != file) {
+ rb_yield(str);
+ goto first_char;
+ }
+ c = FIX2INT(ch);
+ rb_str_cat(str, (const char *)&c, 1);
+ }
+ rb_yield(str);
}
+ return argf;
}
static VALUE
-argf_filename(void)
+argf_filename()
{
next_argv();
return filename;
}
static VALUE
-argf_file(void)
+argf_file()
{
next_argv();
return current_file;
}
static VALUE
-argf_binmode_m(void)
+argf_binmode()
{
- argf_binmode = 1;
+ binmode = 1;
next_argv();
ARGF_FORWARD(0, 0);
rb_io_binmode(current_file);
@@ -6297,7 +5731,7 @@ argf_binmode_m(void)
}
static VALUE
-argf_skip(void)
+argf_skip()
{
if (next_p != -1) {
argf_close(current_file);
@@ -6307,7 +5741,7 @@ argf_skip(void)
}
static VALUE
-argf_close_m(void)
+argf_close_m()
{
next_argv();
argf_close(current_file);
@@ -6319,7 +5753,7 @@ argf_close_m(void)
}
static VALUE
-argf_closed(void)
+argf_closed()
{
next_argv();
ARGF_FORWARD(0, 0);
@@ -6327,20 +5761,21 @@ argf_closed(void)
}
static VALUE
-argf_to_s(void)
+argf_to_s()
{
return rb_str_new2("ARGF");
}
static VALUE
-opt_i_get(void)
+opt_i_get()
{
if (!ruby_inplace_mode) return Qnil;
return rb_str_new2(ruby_inplace_mode);
}
static void
-opt_i_set(VALUE val)
+opt_i_set(val)
+ VALUE val;
{
if (!RTEST(val)) {
if (ruby_inplace_mode) free(ruby_inplace_mode);
@@ -6350,45 +5785,45 @@ opt_i_set(VALUE val)
StringValue(val);
if (ruby_inplace_mode) free(ruby_inplace_mode);
ruby_inplace_mode = 0;
- ruby_inplace_mode = strdup(RSTRING_PTR(val));
+ ruby_inplace_mode = strdup(StringValueCStr(val));
}
/*
* Class <code>IO</code> is the basis for all input and output in Ruby.
* An I/O stream may be <em>duplexed</em> (that is, bidirectional), and
* so may use more than one native operating system stream.
- *
+ *
* Many of the examples in this section use class <code>File</code>,
* the only standard subclass of <code>IO</code>. The two classes are
* closely associated.
- *
+ *
* As used in this section, <em>portname</em> may take any of the
* following forms.
- *
+ *
* * A plain string represents a filename suitable for the underlying
* operating system.
- *
+ *
* * A string starting with ``<code>|</code>'' indicates a subprocess.
* The remainder of the string following the ``<code>|</code>'' is
* invoked as a process with appropriate input/output channels
* connected to it.
- *
+ *
* * A string equal to ``<code>|-</code>'' will create another Ruby
* instance as a subprocess.
- *
+ *
* Ruby will convert pathnames between different operating system
* conventions if possible. For instance, on a Windows system the
* filename ``<code>/gumby/ruby/test.rb</code>'' will be opened as
* ``<code>\gumby\ruby\test.rb</code>''. When specifying a
* Windows-style filename in a Ruby string, remember to escape the
* backslashes:
- *
+ *
* "c:\\gumby\\ruby\\test.rb"
- *
+ *
* Our examples here will use the Unix-style forward slashes;
* <code>File::SEPARATOR</code> can be used to get the
* platform-specific separator character.
- *
+ *
* I/O ports may be opened in any one of several different modes, which
* are shown in this section as <em>mode</em>. The mode may
* either be a Fixnum or a String. If numeric, it should be
@@ -6405,7 +5840,7 @@ opt_i_set(VALUE val)
* -----+--------------------------------------------------------
* "r+" | Read-write, starts at beginning of file.
* -----+--------------------------------------------------------
- * "w" | Write-only, truncates existing file
+ * "w" | Write-only, truncates existing file
* | to zero length or creates a new file for writing.
* -----+--------------------------------------------------------
* "w+" | Read-write, truncates existing file to zero length
@@ -6415,10 +5850,10 @@ opt_i_set(VALUE val)
* | otherwise creates a new file for writing.
* -----+--------------------------------------------------------
* "a+" | Read-write, starts at end of file if file exists,
- * | otherwise creates a new file for reading and
+ * | otherwise creates a new file for reading and
* | writing.
* -----+--------------------------------------------------------
- * "b" | (DOS/Windows only) Binary file mode (may appear with
+ * "b" | (DOS/Windows only) Binary file mode (may appear with
* | any of the key letters listed above).
*
*
@@ -6430,9 +5865,9 @@ opt_i_set(VALUE val)
*/
void
-Init_IO(void)
+Init_IO()
{
-#ifdef __CYGWIN__
+#ifdef __CYGWIN__
#include <sys/cygwin.h>
static struct __cygwin_perfile pf[] =
{
@@ -6451,8 +5886,6 @@ Init_IO(void)
id_write = rb_intern("write");
id_read = rb_intern("read");
id_getc = rb_intern("getc");
- id_flush = rb_intern("flush");
- id_encode = rb_intern("encode");
rb_define_global_function("syscall", rb_f_syscall, -1);
@@ -6463,6 +5896,7 @@ Init_IO(void)
rb_define_global_function("puts", rb_f_puts, -1);
rb_define_global_function("gets", rb_f_gets, -1);
rb_define_global_function("readline", rb_f_readline, -1);
+ rb_define_global_function("getc", rb_f_getc, 0);
rb_define_global_function("select", rb_f_select, -1);
rb_define_global_function("readlines", rb_f_readlines, -1);
@@ -6485,8 +5919,7 @@ Init_IO(void)
rb_define_singleton_method(rb_cIO, "readlines", rb_io_s_readlines, -1);
rb_define_singleton_method(rb_cIO, "read", rb_io_s_read, -1);
rb_define_singleton_method(rb_cIO, "select", rb_f_select, -1);
- rb_define_singleton_method(rb_cIO, "pipe", rb_io_s_pipe, -1);
- rb_define_singleton_method(rb_cIO, "try_convert", rb_io_s_try_convert, 1);
+ rb_define_singleton_method(rb_cIO, "pipe", rb_io_s_pipe, 0);
rb_define_method(rb_cIO, "initialize", rb_io_initialize, -1);
@@ -6515,8 +5948,10 @@ Init_IO(void)
rb_define_method(rb_cIO, "each", rb_io_each_line, -1);
rb_define_method(rb_cIO, "each_line", rb_io_each_line, -1);
rb_define_method(rb_cIO, "each_byte", rb_io_each_byte, 0);
+ rb_define_method(rb_cIO, "each_char", rb_io_each_char, 0);
rb_define_method(rb_cIO, "lines", rb_io_lines, -1);
rb_define_method(rb_cIO, "bytes", rb_io_bytes, 0);
+ rb_define_method(rb_cIO, "chars", rb_io_each_char, 0);
rb_define_method(rb_cIO, "syswrite", rb_io_syswrite, 1);
rb_define_method(rb_cIO, "sysread", rb_io_sysread, -1);
@@ -6542,9 +5977,9 @@ Init_IO(void)
rb_define_method(rb_cIO, "gets", rb_io_gets_m, -1);
rb_define_method(rb_cIO, "readline", rb_io_readline, -1);
rb_define_method(rb_cIO, "getc", rb_io_getc, 0);
- rb_define_method(rb_cIO, "getbyte", rb_io_getbyte, 0);
+ rb_define_method(rb_cIO, "getbyte", rb_io_getc, 0);
rb_define_method(rb_cIO, "readchar", rb_io_readchar, 0);
- rb_define_method(rb_cIO, "readbyte", rb_io_readbyte, 0);
+ rb_define_method(rb_cIO, "readbyte", rb_io_readchar, 0);
rb_define_method(rb_cIO, "ungetc",rb_io_ungetc, 1);
rb_define_method(rb_cIO, "<<", rb_io_addstr, 1);
rb_define_method(rb_cIO, "flush", rb_io_flush, 0);
@@ -6559,9 +5994,6 @@ Init_IO(void)
rb_define_method(rb_cIO, "eof", rb_io_eof, 0);
rb_define_method(rb_cIO, "eof?", rb_io_eof, 0);
- rb_define_method(rb_cIO, "close_on_exec?", rb_io_close_on_exec_p, 0);
- rb_define_method(rb_cIO, "close_on_exec=", rb_io_set_close_on_exec, 1);
-
rb_define_method(rb_cIO, "close", rb_io_close_m, 0);
rb_define_method(rb_cIO, "closed?", rb_io_closed, 0);
rb_define_method(rb_cIO, "close_read", rb_io_close_read, 0);
@@ -6569,7 +6001,7 @@ Init_IO(void)
rb_define_method(rb_cIO, "isatty", rb_io_isatty, 0);
rb_define_method(rb_cIO, "tty?", rb_io_isatty, 0);
- rb_define_method(rb_cIO, "binmode", rb_io_binmode_m, 0);
+ rb_define_method(rb_cIO, "binmode", rb_io_binmode, 0);
rb_define_method(rb_cIO, "sysseek", rb_io_sysseek, -1);
rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1);
@@ -6577,20 +6009,20 @@ Init_IO(void)
rb_define_method(rb_cIO, "pid", rb_io_pid, 0);
rb_define_method(rb_cIO, "inspect", rb_io_inspect, 0);
- rb_define_method(rb_cIO, "external_encoding", rb_io_external_encoding, 0);
- rb_define_method(rb_cIO, "internal_encoding", rb_io_internal_encoding, 0);
- rb_define_method(rb_cIO, "set_encoding", rb_io_set_encoding, -1);
-
rb_define_variable("$stdin", &rb_stdin);
- rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, "<STDIN>");
+ rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
- rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO, "<STDOUT>");
+ rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO);
rb_define_hooked_variable("$stderr", &rb_stderr, 0, stdout_setter);
- rb_stderr = prep_stdio(stderr, FMODE_WRITABLE|FMODE_SYNC, rb_cIO, "<STDERR>");
+ rb_stderr = prep_stdio(stderr, FMODE_WRITABLE, rb_cIO);
rb_define_hooked_variable("$>", &rb_stdout, 0, stdout_setter);
orig_stdout = rb_stdout;
rb_deferr = orig_stderr = rb_stderr;
+ /* variables to be removed in 1.8.1 */
+ rb_define_hooked_variable("$defout", &rb_stdout, 0, defout_setter);
+ rb_define_hooked_variable("$deferr", &rb_stderr, 0, deferr_setter);
+
/* constants to hold original stdin/stdout/stderr */
rb_define_global_const("STDIN", rb_stdin);
rb_define_global_const("STDOUT", rb_stdout);
@@ -6609,17 +6041,20 @@ Init_IO(void)
rb_define_singleton_method(argf, "each", argf_each_line, -1);
rb_define_singleton_method(argf, "each_line", argf_each_line, -1);
rb_define_singleton_method(argf, "each_byte", argf_each_byte, 0);
+ rb_define_singleton_method(argf, "each_char", argf_each_char, 0);
+ rb_define_singleton_method(argf, "lines", argf_each_line, -1);
+ rb_define_singleton_method(argf, "bytes", argf_each_byte, 0);
+ rb_define_singleton_method(argf, "chars", argf_each_char, 0);
rb_define_singleton_method(argf, "read", argf_read, -1);
- rb_define_singleton_method(argf, "readpartial", argf_readpartial, -1);
rb_define_singleton_method(argf, "readlines", rb_f_readlines, -1);
rb_define_singleton_method(argf, "to_a", rb_f_readlines, -1);
rb_define_singleton_method(argf, "gets", rb_f_gets, -1);
rb_define_singleton_method(argf, "readline", rb_f_readline, -1);
rb_define_singleton_method(argf, "getc", argf_getc, 0);
- rb_define_singleton_method(argf, "getbyte", argf_getbyte, 0);
+ rb_define_singleton_method(argf, "getbyte", argf_getc, 0);
rb_define_singleton_method(argf, "readchar", argf_readchar, 0);
- rb_define_singleton_method(argf, "readbyte", argf_readbyte, 0);
+ rb_define_singleton_method(argf, "readbyte", argf_readchar, 0);
rb_define_singleton_method(argf, "tell", argf_tell, 0);
rb_define_singleton_method(argf, "seek", argf_seek_m, -1);
rb_define_singleton_method(argf, "rewind", argf_rewind, 0);
@@ -6627,7 +6062,7 @@ Init_IO(void)
rb_define_singleton_method(argf, "pos=", argf_set_pos, 1);
rb_define_singleton_method(argf, "eof", argf_eof, 0);
rb_define_singleton_method(argf, "eof?", argf_eof, 0);
- rb_define_singleton_method(argf, "binmode", argf_binmode_m, 0);
+ rb_define_singleton_method(argf, "binmode", argf_binmode, 0);
rb_define_singleton_method(argf, "filename", argf_filename, 0);
rb_define_singleton_method(argf, "path", argf_filename, 0);
@@ -6639,10 +6074,6 @@ Init_IO(void)
rb_define_singleton_method(argf, "lineno", argf_lineno, 0);
rb_define_singleton_method(argf, "lineno=", argf_set_lineno, 1);
- rb_define_singleton_method(argf, "external_encoding", argf_external_encoding, 0);
- rb_define_singleton_method(argf, "internal_encoding", argf_internal_encoding, 0);
- rb_define_singleton_method(argf, "set_encoding", argf_set_encoding, -1);
-
rb_global_variable(&current_file);
rb_define_readonly_variable("$FILENAME", &filename);
filename = rb_str_new2("-");
@@ -6676,8 +6107,6 @@ Init_IO(void)
#endif
#ifdef O_BINARY
rb_file_const("BINARY", INT2FIX(O_BINARY));
-#else
- rb_file_const("BINARY", INT2FIX(0));
#endif
#ifdef O_SYNC
rb_file_const("SYNC", INT2FIX(O_SYNC));
diff --git a/iseq.c b/iseq.c
deleted file mode 100644
index 4ad664eced..0000000000
--- a/iseq.c
+++ /dev/null
@@ -1,1298 +0,0 @@
-/**********************************************************************
-
- iseq.c -
-
- $Author$
- $Date$
- created at: 2006-07-11(Tue) 09:00:03 +0900
-
- Copyright (C) 2006 Koichi Sasada
-
-**********************************************************************/
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-
-/* #define MARK_FREE_DEBUG 1 */
-#include "gc.h"
-#include "vm_core.h"
-
-#include "insns.inc"
-#include "insns_info.inc"
-
-/* compile.c */
-void iseq_compile(VALUE self, NODE *node);
-int iseq_translate_threaded_code(rb_iseq_t *iseq);
-
-VALUE rb_cISeq;
-
-static void
-compile_data_free(struct iseq_compile_data *compile_data)
-{
- if (compile_data) {
- struct iseq_compile_data_storage *cur, *next;
- cur = compile_data->storage_head;
- while (cur) {
- next = cur->next;
- ruby_xfree(cur);
- cur = next;
- }
- ruby_xfree(compile_data);
- }
-}
-
-static void
-iseq_free(void *ptr)
-{
- rb_iseq_t *iseq;
- RUBY_FREE_ENTER("iseq");
-
- if (ptr) {
- iseq = ptr;
- /* It's possible that strings are freed
- * GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name),
- * RSTRING_PTR(iseq->filename));
- */
- if (iseq->iseq != iseq->iseq_encoded) {
- RUBY_FREE_UNLESS_NULL(iseq->iseq_encoded);
- }
-
- RUBY_FREE_UNLESS_NULL(iseq->iseq);
- RUBY_FREE_UNLESS_NULL(iseq->insn_info_table);
- RUBY_FREE_UNLESS_NULL(iseq->local_table);
- RUBY_FREE_UNLESS_NULL(iseq->catch_table);
- RUBY_FREE_UNLESS_NULL(iseq->arg_opt_table);
- compile_data_free(iseq->compile_data);
- ruby_xfree(ptr);
- }
- RUBY_FREE_LEAVE("iseq");
-}
-
-static void
-iseq_mark(void *ptr)
-{
- rb_iseq_t *iseq;
- RUBY_MARK_ENTER("iseq");
-
- if (ptr) {
- iseq = ptr;
- RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->filename));
- RUBY_MARK_UNLESS_NULL(iseq->mark_ary);
- RUBY_MARK_UNLESS_NULL(iseq->name);
- RUBY_MARK_UNLESS_NULL(iseq->filename);
- RUBY_MARK_UNLESS_NULL((VALUE)iseq->cref_stack);
- RUBY_MARK_UNLESS_NULL(iseq->klass);
-/* RUBY_MARK_UNLESS_NULL((VALUE)iseq->node); */
-/* RUBY_MARK_UNLESS_NULL(iseq->cached_special_block); */
-
- if (iseq->compile_data != 0) {
- RUBY_MARK_UNLESS_NULL(iseq->compile_data->mark_ary);
- RUBY_MARK_UNLESS_NULL(iseq->compile_data->err_info);
- RUBY_MARK_UNLESS_NULL(iseq->compile_data->catch_table_ary);
- }
- }
- RUBY_MARK_LEAVE("iseq");
-}
-
-static VALUE
-iseq_alloc(VALUE klass)
-{
- VALUE volatile obj;
- rb_iseq_t *iseq;
-
- obj = Data_Make_Struct(klass, rb_iseq_t, iseq_mark, iseq_free, iseq);
- MEMZERO(iseq, rb_iseq_t, 1);
- return obj;
-}
-
-static void
-set_relation(rb_iseq_t *iseq, const VALUE parent)
-{
- const int type = iseq->type;
- rb_thread_t *th = GET_THREAD();
-
- /* set class nest stack */
- if (type == ISEQ_TYPE_TOP) {
- /* toplevel is private */
- iseq->cref_stack = NEW_BLOCK(th->top_wrapper ? th->top_wrapper : rb_cObject);
- iseq->cref_stack->nd_file = 0;
- iseq->cref_stack->nd_visi = NOEX_PRIVATE;
- }
- else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
- iseq->cref_stack = NEW_BLOCK(0); /* place holder */
- iseq->cref_stack->nd_file = 0;
- }
- else if (RTEST(parent)) {
- rb_iseq_t *piseq;
- GetISeqPtr(parent, piseq);
- iseq->cref_stack = piseq->cref_stack;
- }
-
- if (type == ISEQ_TYPE_TOP ||
- type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
- iseq->local_iseq = iseq;
- }
- else if (RTEST(parent)) {
- rb_iseq_t *piseq;
- GetISeqPtr(parent, piseq);
- iseq->local_iseq = piseq->local_iseq;
- }
-
- if (RTEST(parent)) {
- rb_iseq_t *piseq;
- GetISeqPtr(parent, piseq);
- iseq->parent_iseq = piseq;
- }
-}
-
-static VALUE
-prepare_iseq_build(rb_iseq_t *iseq,
- VALUE name, VALUE filename,
- VALUE parent, VALUE type, VALUE block_opt,
- const rb_compile_option_t *option)
-{
- OBJ_FREEZE(name);
- OBJ_FREEZE(filename);
-
- iseq->name = name;
- iseq->filename = filename;
- iseq->defined_method_id = 0;
- iseq->mark_ary = rb_ary_new();
- RBASIC(iseq->mark_ary)->klass = 0;
-
- iseq->type = type;
- iseq->arg_rest = -1;
- iseq->arg_block = -1;
- iseq->klass = 0;
-
- /*
- * iseq->special_block_builder = GC_GUARDED_PTR_REF(block_opt);
- * iseq->cached_special_block_builder = 0;
- * iseq->cached_special_block = 0;
- */
-
- iseq->compile_data = ALLOC(struct iseq_compile_data);
- MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
- iseq->compile_data->mark_ary = rb_ary_new();
- RBASIC(iseq->compile_data->mark_ary)->klass = 0;
-
- iseq->compile_data->storage_head = iseq->compile_data->storage_current =
- (struct iseq_compile_data_storage *)
- ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
- sizeof(struct iseq_compile_data_storage));
-
- iseq->compile_data->catch_table_ary = rb_ary_new();
- iseq->compile_data->storage_head->pos = 0;
- iseq->compile_data->storage_head->next = 0;
- iseq->compile_data->storage_head->size =
- INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
- iseq->compile_data->storage_head->buff =
- (char *)(&iseq->compile_data->storage_head->buff + 1);
- iseq->compile_data->option = option;
-
- set_relation(iseq, parent);
-
- return Qtrue;
-}
-
-static VALUE
-cleanup_iseq_build(rb_iseq_t *iseq)
-{
- struct iseq_compile_data *data = iseq->compile_data;
- VALUE err = data->err_info;
- iseq->compile_data = 0;
- compile_data_free(data);
-
- if (RTEST(err)) {
- rb_funcall2(err, rb_intern("set_backtrace"), 1, &iseq->filename);
- rb_exc_raise(err);
- }
- return Qtrue;
-}
-
-static rb_compile_option_t COMPILE_OPTION_DEFAULT = {
- OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */
- OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */
- OPT_TAILCALL_OPTIMIZATION, /* int tailcall_optimization */
- OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */
- OPT_OPERANDS_UNIFICATION, /* int operands_unification; */
- OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */
- OPT_STACK_CACHING, /* int stack_caching; */
- OPT_TRACE_INSTRUCTION, /* int trace_instruction */
-};
-static const rb_compile_option_t COMPILE_OPTION_FALSE;
-
-static void
-make_compile_option(rb_compile_option_t *option, VALUE opt)
-{
- if (opt == Qnil) {
- *option = COMPILE_OPTION_DEFAULT;
- }
- else if (opt == Qfalse) {
- *option = COMPILE_OPTION_FALSE;
- }
- else if (opt == Qtrue) {
- memset(option, 1, sizeof(rb_compile_option_t));
- }
- else if (CLASS_OF(opt) == rb_cHash) {
- *option = COMPILE_OPTION_DEFAULT;
-
-#define SET_COMPILE_OPTION(o, h, mem) \
- { VALUE flag = rb_hash_aref(h, ID2SYM(rb_intern(#mem))); \
- if (flag == Qtrue) { o->mem = 1; } \
- else if (flag == Qfalse) { o->mem = 0; } \
- }
- SET_COMPILE_OPTION(option, opt, inline_const_cache);
- SET_COMPILE_OPTION(option, opt, peephole_optimization);
- SET_COMPILE_OPTION(option, opt, tailcall_optimization);
- SET_COMPILE_OPTION(option, opt, specialized_instruction);
- SET_COMPILE_OPTION(option, opt, operands_unification);
- SET_COMPILE_OPTION(option, opt, instructions_unification);
- SET_COMPILE_OPTION(option, opt, stack_caching);
- SET_COMPILE_OPTION(option, opt, trace_instruction);
-#undef SET_COMPILE_OPTION
- }
- else {
- rb_raise(rb_eTypeError, "Compile option must be Hash/true/false/nil");
- }
-}
-
-static VALUE
-make_compile_option_value(rb_compile_option_t *option)
-{
- VALUE opt = rb_hash_new();
-#define SET_COMPILE_OPTION(o, h, mem) \
- rb_hash_aset(h, ID2SYM(rb_intern(#mem)), o->mem ? Qtrue : Qfalse)
- {
- SET_COMPILE_OPTION(option, opt, inline_const_cache);
- SET_COMPILE_OPTION(option, opt, peephole_optimization);
- SET_COMPILE_OPTION(option, opt, tailcall_optimization);
- SET_COMPILE_OPTION(option, opt, specialized_instruction);
- SET_COMPILE_OPTION(option, opt, operands_unification);
- SET_COMPILE_OPTION(option, opt, instructions_unification);
- SET_COMPILE_OPTION(option, opt, stack_caching);
- }
-#undef SET_COMPILE_OPTION
- return opt;
-}
-
-VALUE
-rb_iseq_new(NODE *node, VALUE name, VALUE filename,
- VALUE parent, VALUE type)
-{
- return rb_iseq_new_with_opt(node, name, filename, parent, type,
- &COMPILE_OPTION_DEFAULT);
-}
-
-static VALUE
-rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename,
- VALUE parent, VALUE type, VALUE bopt,
- const rb_compile_option_t *option)
-{
- rb_iseq_t *iseq;
- VALUE self = iseq_alloc(rb_cISeq);
-
- GetISeqPtr(self, iseq);
- iseq->self = self;
-
- prepare_iseq_build(iseq, name, filename, parent, type, bopt, option);
- iseq_compile(self, node);
- cleanup_iseq_build(iseq);
- return self;
-}
-
-VALUE
-rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE filename,
- VALUE parent, VALUE type,
- const rb_compile_option_t *option)
-{
- return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
- Qfalse, option);
-}
-
-VALUE
-rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE filename,
- VALUE parent, VALUE type, VALUE bopt)
-{
- return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
- bopt, &COMPILE_OPTION_DEFAULT);
-}
-
-VALUE iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
- VALUE exception, VALUE body);
-
-#define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary")
-#define CHECK_STRING(v) rb_convert_type(v, T_STRING, "String", "to_str")
-#define CHECK_SYMBOL(v) rb_convert_type(v, T_SYMBOL, "Symbol", "to_sym")
-#define CHECK_INTEGER(v) (NUM2LONG(v), v)
-VALUE
-iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
-{
- VALUE iseqval = iseq_alloc(rb_cISeq);
-
- VALUE magic, version1, version2, format_type, misc;
- VALUE name, filename, line;
- VALUE type, body, locals, args, exception;
-
- VALUE iseq_type;
- struct st_table *type_map = 0;
- rb_iseq_t *iseq;
- rb_compile_option_t option;
-
- /* [magic, major_version, minor_version, format_type, misc,
- * name, filename, line,
- * type, locals, args, exception_table, body]
- */
-
- data = CHECK_ARRAY(data);
-
- magic = CHECK_STRING(rb_ary_entry(data, 0));
- version1 = CHECK_INTEGER(rb_ary_entry(data, 1));
- version2 = CHECK_INTEGER(rb_ary_entry(data, 2));
- format_type = CHECK_INTEGER(rb_ary_entry(data, 3));
- misc = rb_ary_entry(data, 4); /* TODO */
-
- name = CHECK_STRING(rb_ary_entry(data, 5));
- filename = CHECK_STRING(rb_ary_entry(data, 6));
- line = CHECK_ARRAY(rb_ary_entry(data, 7));
-
- type = CHECK_SYMBOL(rb_ary_entry(data, 8));
- locals = CHECK_ARRAY(rb_ary_entry(data, 9));
-
- args = rb_ary_entry(data, 10);
- if (FIXNUM_P(args) || (args = CHECK_ARRAY(args))) {
- /* */
- }
-
- exception = CHECK_ARRAY(rb_ary_entry(data, 11));
- body = CHECK_ARRAY(rb_ary_entry(data, 12));
-
- GetISeqPtr(iseqval, iseq);
- iseq->self = iseqval;
-
- if (type_map == 0) {
- type_map = st_init_numtable();
- st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP);
- st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD);
- st_insert(type_map, ID2SYM(rb_intern("block")), ISEQ_TYPE_BLOCK);
- st_insert(type_map, ID2SYM(rb_intern("class")), ISEQ_TYPE_CLASS);
- st_insert(type_map, ID2SYM(rb_intern("rescue")), ISEQ_TYPE_RESCUE);
- st_insert(type_map, ID2SYM(rb_intern("ensure")), ISEQ_TYPE_ENSURE);
- st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL);
- }
-
- if (st_lookup(type_map, type, &iseq_type) == 0) {
- const char *typename = rb_id2name(type);
- if (typename)
- rb_raise(rb_eTypeError, "unsupport type: :%s", typename);
- else
- rb_raise(rb_eTypeError, "unsupport type: %p", (void *)type);
- }
-
- if (parent == Qnil) {
- parent = 0;
- }
-
- make_compile_option(&option, opt);
- prepare_iseq_build(iseq, name, filename,
- parent, iseq_type, 0, &option);
-
- iseq_build_from_ary(iseq, locals, args, exception, body);
-
- cleanup_iseq_build(iseq);
- return iseqval;
-}
-
-static VALUE
-iseq_s_load(int argc, VALUE *argv, VALUE self)
-{
- VALUE data, opt=Qnil;
- rb_scan_args(argc, argv, "11", &data, &opt);
-
- return iseq_load(self, data, 0, opt);
-}
-
-static NODE *
-compile_string(VALUE str, VALUE file, VALUE line)
-{
- VALUE parser = rb_parser_new();
- NODE *node = rb_parser_compile_string(parser, StringValueCStr(file),
- str, NUM2INT(line));
-
- if (!node) {
- rb_exc_raise(GET_THREAD()->errinfo); /* TODO: check err */
- }
- return node;
-}
-
-VALUE
-rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE line, VALUE opt)
-{
- rb_compile_option_t option;
- NODE *node = compile_string(src, file, line);
- rb_thread_t *th = GET_THREAD();
- make_compile_option(&option, opt);
-
- if (th->base_block) {
- return rb_iseq_new_with_opt(node, th->base_block->iseq->name,
- file, th->base_block->iseq->self,
- ISEQ_TYPE_EVAL, &option);
- }
- else {
- return rb_iseq_new_with_opt(node, rb_str_new2("<compiled>"), file, Qfalse,
- ISEQ_TYPE_TOP, &option);
- }
-}
-
-VALUE
-rb_iseq_compile(VALUE src, VALUE file, VALUE line)
-{
- return rb_iseq_compile_with_option(src, file, line, Qnil);
-}
-
-static VALUE
-iseq_s_compile(int argc, VALUE *argv, VALUE self)
-{
- VALUE src, file = Qnil, line = INT2FIX(1), opt = Qnil;
-
- rb_secure(1);
-
- rb_scan_args(argc, argv, "13", &src, &file, &line, &opt);
- file = file == Qnil ? rb_str_new2("<compiled>") : file;
- line = line == Qnil ? INT2FIX(1) : line;
-
- return rb_iseq_compile_with_option(src, file, line, opt);
-}
-
-static VALUE
-iseq_s_compile_file(int argc, VALUE *argv, VALUE self)
-{
- VALUE file, line = INT2FIX(1), opt = Qnil;
- VALUE parser;
- VALUE f;
- NODE *node;
- const char *fname;
- rb_compile_option_t option;
-
- rb_secure(1);
- rb_scan_args(argc, argv, "11", &file, &opt);
- fname = StringValueCStr(file);
-
- f = rb_file_open(fname, "r");
-
- parser = rb_parser_new();
- node = rb_parser_compile_file(parser, fname, f, NUM2INT(line));
- make_compile_option(&option, opt);
- return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file, Qfalse,
- ISEQ_TYPE_TOP, &option);
-}
-
-static VALUE
-iseq_s_compile_option_set(VALUE self, VALUE opt)
-{
- rb_compile_option_t option;
- rb_secure(1);
- make_compile_option(&option, opt);
- COMPILE_OPTION_DEFAULT = option;
- return opt;
-}
-
-static VALUE
-iseq_s_compile_option_get(VALUE self)
-{
- return make_compile_option_value(&COMPILE_OPTION_DEFAULT);
-}
-
-static rb_iseq_t *
-iseq_check(VALUE val)
-{
- rb_iseq_t *iseq;
- GetISeqPtr(val, iseq);
- if (!iseq->name) {
- rb_raise(rb_eTypeError, "uninitialized InstructionSequence");
- }
- return iseq;
-}
-
-static VALUE
-iseq_eval(VALUE self)
-{
- rb_secure(1);
- return rb_iseq_eval(self);
-}
-
-static VALUE
-iseq_inspect(VALUE self)
-{
- char buff[0x100];
- rb_iseq_t *iseq = iseq_check(self);
-
- snprintf(buff, sizeof(buff), "<ISeq:%s@%s>",
- RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->filename));
-
- return rb_str_new2(buff);
-}
-
-VALUE iseq_data_to_ary(rb_iseq_t *iseq);
-
-static VALUE
-iseq_to_a(VALUE self)
-{
- rb_iseq_t *iseq = iseq_check(self);
- rb_secure(1);
- return iseq_data_to_ary(iseq);
-}
-
-/* TODO: search algorithm is brute force.
- this should be binary search or so. */
-
-static struct iseq_insn_info_entry *
-get_insn_info(const rb_iseq_t *iseq, const unsigned long pos)
-{
- unsigned long i, size = iseq->insn_info_size;
- struct iseq_insn_info_entry *table = iseq->insn_info_table;
-
- for (i = 0; i < size; i++) {
- if (table[i].position == pos) {
- return &table[i];
- }
- }
-
- return 0;
-}
-
-static unsigned short
-find_line_no(rb_iseq_t *iseq, unsigned long pos)
-{
- struct iseq_insn_info_entry *entry = get_insn_info(iseq, pos);
- if (entry) {
- return entry->line_no;
- }
- else {
- return 0;
- }
-}
-
-static unsigned short
-find_prev_line_no(rb_iseq_t *iseqdat, unsigned long pos)
-{
- unsigned long i, size = iseqdat->insn_info_size;
- struct iseq_insn_info_entry *iiary = iseqdat->insn_info_table;
-
- for (i = 0; i < size; i++) {
- if (iiary[i].position == pos) {
- if (i > 0) {
- return iiary[i - 1].line_no;
- }
- else {
- return 0;
- }
- }
- }
-
- return 0;
-}
-
-static VALUE
-insn_operand_intern(rb_iseq_t *iseq,
- int insn, int op_no, VALUE op,
- int len, int pos, VALUE *pnop, VALUE child)
-{
- char *types = insn_op_types(insn);
- char type = types[op_no];
- VALUE ret;
- char buff[0x100];
-
- switch (type) {
- case TS_OFFSET: /* LONG */
- snprintf(buff, sizeof(buff), "%ld", pos + len + op);
- ret = rb_str_new2(buff);
- break;
-
- case TS_NUM: /* ULONG */
- snprintf(buff, sizeof(buff), "%lu", op);
- ret = rb_str_new2(buff);
- break;
-
- case TS_LINDEX:
- {
- rb_iseq_t *ip = iseq->local_iseq;
- int lidx = ip->local_size - op;
- const char *name = rb_id2name(ip->local_table[lidx]);
-
- if (name) {
- ret = rb_str_new2(name);
- }
- else {
- ret = rb_str_new2("*");
- }
- break;
- }
- case TS_DINDEX:{
- if (insn == BIN(getdynamic) || insn == BIN(setdynamic)) {
- rb_iseq_t *ip = iseq;
- int level = *pnop, i;
- const char *name;
- for (i = 0; i < level; i++) {
- ip = ip->parent_iseq;
- }
- name = rb_id2name(ip->local_table[ip->local_size - op]);
-
- if (!name) {
- name = "*";
- }
- ret = rb_str_new2(name);
- }
- else {
- ret = rb_inspect(INT2FIX(op));
- }
- break;
- }
- case TS_ID: /* ID (symbol) */
- op = ID2SYM(op);
- case TS_VALUE: /* VALUE */
- ret = rb_inspect(op);
- if (CLASS_OF(op) == rb_cISeq) {
- rb_ary_push(child, op);
- }
- break;
-
- case TS_ISEQ: /* iseq */
- {
- rb_iseq_t *iseq = (rb_iseq_t *)op;
- if (iseq) {
- ret = iseq->name;
- if (child) {
- rb_ary_push(child, iseq->self);
- }
- }
- else {
- ret = rb_str_new2("nil");
- }
- break;
- }
- case TS_GENTRY:
- {
- struct global_entry *entry = (struct global_entry *)op;
- ret = rb_str_dup(rb_id2str(entry->id));
- }
- break;
-
- case TS_IC:
- ret = rb_str_new2("<ic>");
- break;
-
- case TS_CDHASH:
- ret = rb_str_new2("<cdhash>");
- break;
-
- case TS_FUNCPTR:
- ret = rb_str_new2("<funcptr>");
- break;
-
- default:
- rb_bug("ruby_iseq_disasm: unknown operand type: %c", type);
- }
- return ret;
-}
-
-/**
- * Disassemble a instruction
- * Iseq -> Iseq inspect object
- */
-VALUE
-ruby_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
- rb_iseq_t *iseqdat, VALUE child)
-{
- int insn = iseq[pos];
- int len = insn_len(insn);
- int i, j;
- char *types = insn_op_types(insn);
- VALUE str = rb_str_new(0, 0);
- char buff[0x100];
- char insn_name_buff[0x100];
-
- strcpy(insn_name_buff, insn_name(insn));
- if (0) {
- for (i = 0; insn_name_buff[i]; i++) {
- if (insn_name_buff[i] == '_') {
- insn_name_buff[i] = 0;
- }
- }
- }
-
- snprintf(buff, sizeof(buff), "%04d %-16s ", pos, insn_name_buff);
- rb_str_cat2(str, buff);
-
- for (j = 0; types[j]; j++) {
- char *types = insn_op_types(insn);
- VALUE opstr = insn_operand_intern(iseqdat, insn, j, iseq[pos + j + 1],
- len, pos, &iseq[pos + j + 2],
- child);
- rb_str_concat(str, opstr);
-
- if (types[j + 1]) {
- rb_str_cat2(str, ", ");
- }
- }
-
- if (1) {
- int line_no = find_line_no(iseqdat, pos);
- int prev = find_prev_line_no(iseqdat, pos);
- if (line_no && line_no != prev) {
- snprintf(buff, sizeof(buff), "%-70s(%4d)", RSTRING_PTR(str),
- line_no);
- str = rb_str_new2(buff);
- }
- }
- else {
- /* for debug */
- struct iseq_insn_info_entry *entry = get_insn_info(iseqdat, pos);
- snprintf(buff, sizeof(buff), "%-60s(line: %d, sp: %d)",
- RSTRING_PTR(str), entry->line_no, entry->sp);
- str = rb_str_new2(buff);
- }
-
- if (ret) {
- rb_str_cat2(str, "\n");
- rb_str_concat(ret, str);
- }
- else {
- printf("%s\n", RSTRING_PTR(str));
- }
- return len;
-}
-
-static char *
-catch_type(int type)
-{
- switch (type) {
- case CATCH_TYPE_RESCUE:
- return "rescue";
- case CATCH_TYPE_ENSURE:
- return "ensure";
- case CATCH_TYPE_RETRY:
- return "retry";
- case CATCH_TYPE_BREAK:
- return "break";
- case CATCH_TYPE_REDO:
- return "redo";
- case CATCH_TYPE_NEXT:
- return "next";
- default:
- rb_bug("unknown catch type (%d)", type);
- return 0;
- }
-}
-
-VALUE
-ruby_iseq_disasm(VALUE self)
-{
- rb_iseq_t *iseqdat = iseq_check(self);
- VALUE *iseq;
- VALUE str = rb_str_new(0, 0);
- VALUE child = rb_ary_new();
- unsigned long size;
- int i;
- ID *tbl;
- char buff[0x200];
- enum {header_minlen = 72};
-
- rb_secure(1);
-
- iseq = iseqdat->iseq;
- size = iseqdat->iseq_size;
-
- rb_str_cat2(str, "== disasm: ");
-
- rb_str_concat(str, iseq_inspect(iseqdat->self));
- if ((i = RSTRING_LEN(str)) < header_minlen) {
- rb_str_resize(str, header_minlen);
- memset(RSTRING_PTR(str) + i, '=', header_minlen - i);
- }
- rb_str_cat2(str, "\n");
-
- /* show catch table information */
- if (iseqdat->catch_table_size != 0) {
- rb_str_cat2(str, "== catch table\n");
- }
- for (i = 0; i < iseqdat->catch_table_size; i++) {
- struct iseq_catch_table_entry *entry = &iseqdat->catch_table[i];
- sprintf(buff,
- "| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
- catch_type((int)entry->type), (int)entry->start,
- (int)entry->end, (int)entry->sp, (int)entry->cont);
- rb_str_cat2(str, buff);
- if (entry->iseq) {
- rb_str_concat(str, ruby_iseq_disasm(entry->iseq));
- }
- }
- if (iseqdat->catch_table_size != 0) {
- rb_str_cat2(str, "|-------------------------------------"
- "-----------------------------------\n");
- }
-
- /* show local table information */
- tbl = iseqdat->local_table;
-
- if (tbl) {
- snprintf(buff, sizeof(buff),
- "local table (size: %d, argc: %d "
- "[opts: %d, rest: %d, post: %d, block: %d] s%d)\n",
- iseqdat->local_size, iseqdat->argc,
- iseqdat->arg_opts, iseqdat->arg_rest,
- iseqdat->arg_post_len, iseqdat->arg_block,
- iseqdat->arg_simple);
- rb_str_cat2(str, buff);
-
- for (i = 0; i < iseqdat->local_table_size; i++) {
- const char *name = rb_id2name(tbl[i]);
- char info[0x100];
- char argi[0x100] = "";
- char opti[0x100] = "";
-
- if (iseqdat->arg_opts) {
- int argc = iseqdat->argc;
- int opts = iseqdat->arg_opts;
- if (i >= argc && i < argc + opts - 1) {
- snprintf(opti, sizeof(opti), "Opt=%ld",
- iseqdat->arg_opt_table[i - argc]);
- }
- }
-
- snprintf(argi, sizeof(argi), "%s%s%s%s%s", /* arg, opts, rest, post block */
- iseqdat->argc > i ? "Arg" : "",
- opti,
- iseqdat->arg_rest == i ? "Rest" : "",
- (iseqdat->arg_post_start <= i &&
- i < iseqdat->arg_post_start + iseqdat->arg_post_len) ? "Post" : "",
- iseqdat->arg_block == i ? "Block" : "");
-
- snprintf(info, sizeof(info), "%s%s%s%s", name ? name : "?",
- *argi ? "<" : "", argi, *argi ? ">" : "");
-
- snprintf(buff, sizeof(buff), "[%2d] %-11s",
- iseqdat->local_size - i, info);
-
- rb_str_cat2(str, buff);
- }
- rb_str_cat2(str, "\n");
- }
-
- /* show each line */
- for (i = 0; i < size;) {
- i += ruby_iseq_disasm_insn(str, iseq, i, iseqdat, child);
- }
-
- for (i = 0; i < RARRAY_LEN(child); i++) {
- VALUE isv = rb_ary_entry(child, i);
- rb_str_concat(str, ruby_iseq_disasm(isv));
- }
-
- return str;
-}
-
-static VALUE
-iseq_s_disasm(VALUE klass, VALUE body)
-{
- extern NODE *rb_method_body(VALUE body);
- NODE *node;
- VALUE ret = Qnil;
-
- rb_secure(1);
-
- if ((node = rb_method_body(body)) != 0) {
- if (nd_type(node) == RUBY_VM_METHOD_NODE) {
- VALUE iseqval = (VALUE)node->nd_body;
- ret = ruby_iseq_disasm(iseqval);
- }
- }
-
- return ret;
-}
-
-const char *
-ruby_node_name(int node)
-{
- switch (node) {
-#include "node_name.inc"
- default:
- rb_bug("unknown node (%d)", node);
- return 0;
- }
-}
-
-#define DECL_SYMBOL(name) \
- static VALUE sym_##name
-
-#define INIT_SYMBOL(name) \
- sym_##name = ID2SYM(rb_intern(#name))
-
-static VALUE
-register_label(struct st_table *table, int idx)
-{
- VALUE sym;
- char buff[0x20];
-
- snprintf(buff, 0x20, "label_%u", idx);
- sym = ID2SYM(rb_intern(buff));
- st_insert(table, idx, sym);
- return sym;
-}
-
-static VALUE
-exception_type2symbol(VALUE type)
-{
- ID id;
- switch(type) {
- case CATCH_TYPE_RESCUE: id = rb_intern("rescue"); break;
- case CATCH_TYPE_ENSURE: id = rb_intern("ensure"); break;
- case CATCH_TYPE_RETRY: id = rb_intern("retry"); break;
- case CATCH_TYPE_BREAK: id = rb_intern("break"); break;
- case CATCH_TYPE_REDO: id = rb_intern("redo"); break;
- case CATCH_TYPE_NEXT: id = rb_intern("next"); break;
- default:
- rb_bug("...");
- }
- return ID2SYM(id);
-}
-
-static int
-cdhash_each(VALUE key, VALUE value, VALUE ary)
-{
- rb_ary_push(ary, key);
- rb_ary_push(ary, value);
- return ST_CONTINUE;
-}
-
-VALUE
-iseq_data_to_ary(rb_iseq_t *iseq)
-{
- int i, pos, line = 0;
- VALUE *seq;
-
- VALUE val = rb_ary_new();
- VALUE type; /* Symbol */
- VALUE locals = rb_ary_new();
- VALUE args = rb_ary_new();
- VALUE body = rb_ary_new(); /* [[:insn1, ...], ...] */
- VALUE nbody;
- VALUE exception = rb_ary_new(); /* [[....]] */
- VALUE misc = rb_hash_new();
-
- static VALUE insn_syms[VM_INSTRUCTION_SIZE];
- struct st_table *labels_table = st_init_numtable();
-
- DECL_SYMBOL(top);
- DECL_SYMBOL(method);
- DECL_SYMBOL(block);
- DECL_SYMBOL(class);
- DECL_SYMBOL(rescue);
- DECL_SYMBOL(ensure);
- DECL_SYMBOL(eval);
-
- if (sym_top == 0) {
- int i;
- for (i=0; i<VM_INSTRUCTION_SIZE; i++) {
- insn_syms[i] = ID2SYM(rb_intern(insn_name(i)));
- }
- INIT_SYMBOL(top);
- INIT_SYMBOL(method);
- INIT_SYMBOL(block);
- INIT_SYMBOL(class);
- INIT_SYMBOL(rescue);
- INIT_SYMBOL(ensure);
- INIT_SYMBOL(eval);
- }
-
- /* type */
- switch(iseq->type) {
- case ISEQ_TYPE_TOP: type = sym_top; break;
- case ISEQ_TYPE_METHOD: type = sym_method; break;
- case ISEQ_TYPE_BLOCK: type = sym_block; break;
- case ISEQ_TYPE_CLASS: type = sym_class; break;
- case ISEQ_TYPE_RESCUE: type = sym_rescue; break;
- case ISEQ_TYPE_ENSURE: type = sym_ensure; break;
- case ISEQ_TYPE_EVAL: type = sym_eval; break;
- default: rb_bug("unsupported iseq type");
- };
-
- /* locals */
- for (i=0; i<iseq->local_table_size; i++) {
- ID lid = iseq->local_table[i];
- if (lid) {
- if (rb_id2str(lid)) rb_ary_push(locals, ID2SYM(lid));
- }
- else {
- rb_ary_push(locals, ID2SYM(rb_intern("#arg_rest")));
- }
- }
-
- /* args */
- {
- /*
- * [argc, # argc
- * [label1, label2, ...] # opts
- * rest index,
- * post_len
- * post_start
- * block index,
- * simple,
- * ]
- */
- VALUE arg_opt_labels = rb_ary_new();
- int j;
-
- for (j=0; j<iseq->arg_opts; j++) {
- rb_ary_push(arg_opt_labels,
- register_label(labels_table, iseq->arg_opt_table[j]));
- }
-
- /* commit */
- if (iseq->arg_simple == 1) {
- args = INT2FIX(iseq->argc);
- }
- else {
- rb_ary_push(args, INT2FIX(iseq->argc));
- rb_ary_push(args, arg_opt_labels);
- rb_ary_push(args, INT2FIX(iseq->arg_post_len));
- rb_ary_push(args, INT2FIX(iseq->arg_post_start));
- rb_ary_push(args, INT2FIX(iseq->arg_rest));
- rb_ary_push(args, INT2FIX(iseq->arg_block));
- rb_ary_push(args, INT2FIX(iseq->arg_simple));
- }
- }
-
- /* body */
- for (seq = iseq->iseq; seq < iseq->iseq + iseq->iseq_size; ) {
- VALUE insn = *seq++;
- int j, len = insn_len(insn);
- VALUE *nseq = seq + len - 1;
- VALUE ary = rb_ary_new2(len);
-
- rb_ary_push(ary, insn_syms[insn]);
- for (j=0; j<len-1; j++, seq++) {
- switch (insn_op_type(insn, j)) {
- case TS_OFFSET: {
- unsigned int idx = nseq - iseq->iseq + *seq;
- rb_ary_push(ary, register_label(labels_table, idx));
- break;
- }
- case TS_LINDEX:
- case TS_DINDEX:
- case TS_NUM:
- rb_ary_push(ary, INT2FIX(*seq));
- break;
- case TS_VALUE:
- rb_ary_push(ary, *seq);
- break;
- case TS_ISEQ:
- {
- rb_iseq_t *iseq = (rb_iseq_t *)*seq;
- if (iseq) {
- VALUE val = iseq_data_to_ary(iseq);
- rb_ary_push(ary, val);
- }
- else {
- rb_ary_push(ary, Qnil);
- }
- }
- break;
- case TS_GENTRY:
- {
- struct global_entry *entry = (struct global_entry *)*seq;
- rb_ary_push(ary, ID2SYM(entry->id));
- }
- break;
- case TS_IC:
- rb_ary_push(ary, Qnil);
- break;
- case TS_ID:
- rb_ary_push(ary, ID2SYM(*seq));
- break;
- case TS_CDHASH:
- {
- VALUE hash = *seq;
- VALUE val = rb_ary_new();
- int i;
-
- rb_hash_foreach(hash, cdhash_each, val);
-
- for (i=0; i<RARRAY_LEN(val); i+=2) {
- VALUE pos = FIX2INT(rb_ary_entry(val, i+1));
- unsigned int idx = nseq - iseq->iseq + pos;
-
- rb_ary_store(val, i+1,
- register_label(labels_table, idx));
- }
- rb_ary_push(ary, val);
- }
- break;
- default:
- rb_bug("unknown operand: %c", insn_op_type(insn, j));
- }
- }
- rb_ary_push(body, ary);
- }
-
- nbody = body;
-
- /* exception */
- for (i=0; i<iseq->catch_table_size; i++) {
- VALUE ary = rb_ary_new();
- struct iseq_catch_table_entry *entry = &iseq->catch_table[i];
- rb_ary_push(ary, exception_type2symbol(entry->type));
- if (entry->iseq) {
- rb_iseq_t *eiseq;
- GetISeqPtr(entry->iseq, eiseq);
- rb_ary_push(ary, iseq_data_to_ary(eiseq));
- }
- else {
- rb_ary_push(ary, Qnil);
- }
- rb_ary_push(ary, register_label(labels_table, entry->start));
- rb_ary_push(ary, register_label(labels_table, entry->end));
- rb_ary_push(ary, register_label(labels_table, entry->cont));
- rb_ary_push(ary, INT2FIX(entry->sp));
- rb_ary_push(exception, ary);
- }
-
- /* make body with labels and insert line number */
- body = rb_ary_new();
-
- for (i=0, pos=0; i<RARRAY_LEN(nbody); i++) {
- VALUE ary = RARRAY_PTR(nbody)[i];
- VALUE label;
-
- if (st_lookup(labels_table, pos, &label)) {
- rb_ary_push(body, label);
- }
-
- if (iseq->insn_info_table[i].line_no != line) {
- line = iseq->insn_info_table[i].line_no;
- rb_ary_push(body, INT2FIX(line));
- }
-
- rb_ary_push(body, ary);
- pos += RARRAY_LEN(ary);
- }
-
- st_free_table(labels_table);
-
- rb_hash_aset(misc, ID2SYM(rb_intern("arg_size")), INT2FIX(iseq->arg_size));
- rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->local_size));
- rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->stack_max));
-
- /*
- * [:magic, :major_version, :minor_version, :format_type, :misc,
- * :name, :filename, :type, :locals, :args,
- * :catch_table, :bytecode]
- */
- rb_ary_push(val, rb_str_new2("YARVInstructionSequence/SimpleDataFormat"));
- rb_ary_push(val, INT2FIX(1));
- rb_ary_push(val, INT2FIX(1));
- rb_ary_push(val, INT2FIX(1));
- rb_ary_push(val, misc);
- rb_ary_push(val, iseq->name);
- rb_ary_push(val, iseq->filename);
- rb_ary_push(val, type);
- rb_ary_push(val, locals);
- rb_ary_push(val, args);
- rb_ary_push(val, exception);
- rb_ary_push(val, body);
- return val;
-}
-
-struct st_table *
-insn_make_insn_table(void)
-{
- struct st_table *table;
- int i;
- table = st_init_numtable();
-
- for (i=0; i<VM_INSTRUCTION_SIZE; i++) {
- st_insert(table, ID2SYM(rb_intern(insn_name(i))), i);
- }
-
- return table;
-}
-
-/* ruby2cext */
-
-VALUE
-rb_iseq_build_for_ruby2cext(
- const rb_iseq_t *iseq_template,
- const rb_insn_func_t *func,
- const struct iseq_insn_info_entry *insn_info_table,
- const char **local_table,
- const VALUE *arg_opt_table,
- const struct iseq_catch_table_entry *catch_table,
- const char *name,
- const char *filename)
-{
- int i;
- VALUE iseqval = iseq_alloc(rb_cISeq);
- rb_iseq_t *iseq;
- GetISeqPtr(iseqval, iseq);
-
- /* copy iseq */
- *iseq = *iseq_template;
- iseq->name = rb_str_new2(name);
- iseq->filename = rb_str_new2(filename);
- iseq->mark_ary = rb_ary_new();
- iseq->self = iseqval;
-
- iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size);
-
- for (i=0; i<iseq->iseq_size; i+=2) {
- iseq->iseq[i] = BIN(opt_call_c_function);
- iseq->iseq[i+1] = (VALUE)func;
- }
-
- iseq_translate_threaded_code(iseq);
-
-#define ALLOC_AND_COPY(dst, src, type, size) do { \
- if (size) { \
- (dst) = ALLOC_N(type, (size)); \
- MEMCPY((dst), (src), type, (size)); \
- } \
-} while (0)
-
- ALLOC_AND_COPY(iseq->insn_info_table, insn_info_table,
- struct iseq_insn_info_entry, iseq->insn_info_size);
-
- ALLOC_AND_COPY(iseq->catch_table, catch_table,
- struct iseq_catch_table_entry, iseq->catch_table_size);
-
- ALLOC_AND_COPY(iseq->arg_opt_table, arg_opt_table,
- VALUE, iseq->arg_opts);
-
- set_relation(iseq, 0);
-
- return iseqval;
-}
-
-void
-Init_ISeq(void)
-{
- /* declare ::VM::InstructionSequence */
- rb_cISeq = rb_define_class_under(rb_cVM, "InstructionSequence", rb_cObject);
- rb_define_alloc_func(rb_cISeq, iseq_alloc);
- rb_define_method(rb_cISeq, "inspect", iseq_inspect, 0);
- rb_define_method(rb_cISeq, "disasm", ruby_iseq_disasm, 0);
- rb_define_method(rb_cISeq, "disassemble", ruby_iseq_disasm, 0);
- rb_define_method(rb_cISeq, "to_a", iseq_to_a, 0);
- rb_define_method(rb_cISeq, "eval", iseq_eval, 0);
-
- /* disable this feature because there is no verifier. */
- /* rb_define_singleton_method(rb_cISeq, "load", iseq_s_load, -1); */
-
- rb_define_singleton_method(rb_cISeq, "compile", iseq_s_compile, -1);
- rb_define_singleton_method(rb_cISeq, "new", iseq_s_compile, -1);
- rb_define_singleton_method(rb_cISeq, "compile_file", iseq_s_compile_file, -1);
- rb_define_singleton_method(rb_cISeq, "compile_option", iseq_s_compile_option_get, 0);
- rb_define_singleton_method(rb_cISeq, "compile_option=", iseq_s_compile_option_set, 1);
- rb_define_singleton_method(rb_cISeq, "disasm", iseq_s_disasm, 1);
- rb_define_singleton_method(rb_cISeq, "disassemble", iseq_s_disasm, 1);
-}
-
diff --git a/keywords b/keywords
index 76cd2437a9..6eed5e1f4d 100644
--- a/keywords
+++ b/keywords
@@ -1,51 +1,42 @@
-%{
-struct kwtable {char *name; int id[2]; enum lex_state_e state;};
-const struct kwtable *rb_reserved_word(const char *, unsigned int);
-#ifndef RIPPER
-%}
-
-struct kwtable;
+struct kwtable {const char *name; int id[2]; enum lex_state state;};
%%
-__ENCODING__, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END
-__LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END
-__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END
-BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END
-END, {keyword_END, keyword_END}, EXPR_END
-alias, {keyword_alias, keyword_alias}, EXPR_FNAME
-and, {keyword_and, keyword_and}, EXPR_VALUE
-begin, {keyword_begin, keyword_begin}, EXPR_BEG
-break, {keyword_break, keyword_break}, EXPR_MID
-case, {keyword_case, keyword_case}, EXPR_VALUE
-class, {keyword_class, keyword_class}, EXPR_CLASS
-def, {keyword_def, keyword_def}, EXPR_FNAME
-defined?, {keyword_defined, keyword_defined}, EXPR_ARG
-do, {keyword_do, keyword_do}, EXPR_BEG
-else, {keyword_else, keyword_else}, EXPR_BEG
-elsif, {keyword_elsif, keyword_elsif}, EXPR_VALUE
-end, {keyword_end, keyword_end}, EXPR_END
-ensure, {keyword_ensure, keyword_ensure}, EXPR_BEG
-false, {keyword_false, keyword_false}, EXPR_END
-for, {keyword_for, keyword_for}, EXPR_VALUE
-if, {keyword_if, modifier_if}, EXPR_VALUE
-in, {keyword_in, keyword_in}, EXPR_VALUE
-module, {keyword_module, keyword_module}, EXPR_VALUE
-next, {keyword_next, keyword_next}, EXPR_MID
-nil, {keyword_nil, keyword_nil}, EXPR_END
-not, {keyword_not, keyword_not}, EXPR_VALUE
-or, {keyword_or, keyword_or}, EXPR_VALUE
-redo, {keyword_redo, keyword_redo}, EXPR_END
-rescue, {keyword_rescue, modifier_rescue}, EXPR_MID
-retry, {keyword_retry, keyword_retry}, EXPR_END
-return, {keyword_return, keyword_return}, EXPR_MID
-self, {keyword_self, keyword_self}, EXPR_END
-super, {keyword_super, keyword_super}, EXPR_ARG
-then, {keyword_then, keyword_then}, EXPR_BEG
-true, {keyword_true, keyword_true}, EXPR_END
-undef, {keyword_undef, keyword_undef}, EXPR_FNAME
-unless, {keyword_unless, modifier_unless}, EXPR_VALUE
-until, {keyword_until, modifier_until}, EXPR_VALUE
-when, {keyword_when, keyword_when}, EXPR_VALUE
-while, {keyword_while, modifier_while}, EXPR_VALUE
-yield, {keyword_yield, keyword_yield}, EXPR_ARG
-%%
-#endif
+__LINE__, {k__LINE__, k__LINE__}, EXPR_END
+__FILE__, {k__FILE__, k__FILE__}, EXPR_END
+BEGIN, {klBEGIN, klBEGIN}, EXPR_END
+END, {klEND, klEND}, EXPR_END
+alias, {kALIAS, kALIAS}, EXPR_FNAME
+and, {kAND, kAND}, EXPR_BEG
+begin, {kBEGIN, kBEGIN}, EXPR_BEG
+break, {kBREAK, kBREAK}, EXPR_MID
+case, {kCASE, kCASE}, EXPR_BEG
+class, {kCLASS, kCLASS}, EXPR_CLASS
+def, {kDEF, kDEF}, EXPR_FNAME
+defined?, {kDEFINED, kDEFINED}, EXPR_ARG
+do, {kDO, kDO}, EXPR_BEG
+else, {kELSE, kELSE}, EXPR_BEG
+elsif, {kELSIF, kELSIF}, EXPR_BEG
+end, {kEND, kEND}, EXPR_END
+ensure, {kENSURE, kENSURE}, EXPR_BEG
+false, {kFALSE, kFALSE}, EXPR_END
+for, {kFOR, kFOR}, EXPR_BEG
+if, {kIF, kIF_MOD}, EXPR_BEG
+in, {kIN, kIN}, EXPR_BEG
+module, {kMODULE, kMODULE}, EXPR_BEG
+next, {kNEXT, kNEXT}, EXPR_MID
+nil, {kNIL, kNIL}, EXPR_END
+not, {kNOT, kNOT}, EXPR_BEG
+or, {kOR, kOR}, EXPR_BEG
+redo, {kREDO, kREDO}, EXPR_END
+rescue, {kRESCUE, kRESCUE_MOD}, EXPR_MID
+retry, {kRETRY, kRETRY}, EXPR_END
+return, {kRETURN, kRETURN}, EXPR_MID
+self, {kSELF, kSELF}, EXPR_END
+super, {kSUPER, kSUPER}, EXPR_ARG
+then, {kTHEN, kTHEN}, EXPR_BEG
+true, {kTRUE, kTRUE}, EXPR_END
+undef, {kUNDEF, kUNDEF}, EXPR_FNAME
+unless, {kUNLESS, kUNLESS_MOD}, EXPR_BEG
+until, {kUNTIL, kUNTIL_MOD}, EXPR_BEG
+when, {kWHEN, kWHEN}, EXPR_BEG
+while, {kWHILE, kWHILE_MOD}, EXPR_BEG
+yield, {kYIELD, kYIELD}, EXPR_ARG
diff --git a/lex.c b/lex.c
new file mode 100644
index 0000000000..a15309d502
--- /dev/null
+++ b/lex.c
@@ -0,0 +1,136 @@
+/* C code produced by gperf version 2.7.2 */
+/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' ./keywords */
+struct kwtable {const char *name; int id[2]; enum lex_state state;};
+
+#define TOTAL_KEYWORDS 40
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 8
+#define MIN_HASH_VALUE 6
+#define MAX_HASH_VALUE 55
+/* maximum key range = 50, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+hash (str, len)
+ register const char *str;
+ register unsigned int len;
+{
+ static unsigned char asso_values[] =
+ {
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 11, 56, 56, 36, 56, 1, 37,
+ 31, 1, 56, 56, 56, 56, 29, 56, 1, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 1, 56, 32, 1, 2,
+ 1, 1, 4, 23, 56, 17, 56, 20, 9, 2,
+ 9, 26, 14, 56, 5, 1, 1, 16, 56, 21,
+ 20, 9, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56
+ };
+ register int hval = len;
+
+ switch (hval)
+ {
+ default:
+ case 3:
+ hval += asso_values[(unsigned char)str[2]];
+ case 2:
+ case 1:
+ hval += asso_values[(unsigned char)str[0]];
+ break;
+ }
+ return hval + asso_values[(unsigned char)str[len - 1]];
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+struct kwtable *
+rb_reserved_word (str, len)
+ register const char *str;
+ register unsigned int len;
+{
+ static struct kwtable wordlist[] =
+ {
+ {""}, {""}, {""}, {""}, {""}, {""},
+ {"end", {kEND, kEND}, EXPR_END},
+ {"else", {kELSE, kELSE}, EXPR_BEG},
+ {"case", {kCASE, kCASE}, EXPR_BEG},
+ {"ensure", {kENSURE, kENSURE}, EXPR_BEG},
+ {"module", {kMODULE, kMODULE}, EXPR_BEG},
+ {"elsif", {kELSIF, kELSIF}, EXPR_BEG},
+ {"def", {kDEF, kDEF}, EXPR_FNAME},
+ {"rescue", {kRESCUE, kRESCUE_MOD}, EXPR_MID},
+ {"not", {kNOT, kNOT}, EXPR_BEG},
+ {"then", {kTHEN, kTHEN}, EXPR_BEG},
+ {"yield", {kYIELD, kYIELD}, EXPR_ARG},
+ {"for", {kFOR, kFOR}, EXPR_BEG},
+ {"self", {kSELF, kSELF}, EXPR_END},
+ {"false", {kFALSE, kFALSE}, EXPR_END},
+ {"retry", {kRETRY, kRETRY}, EXPR_END},
+ {"return", {kRETURN, kRETURN}, EXPR_MID},
+ {"true", {kTRUE, kTRUE}, EXPR_END},
+ {"if", {kIF, kIF_MOD}, EXPR_BEG},
+ {"defined?", {kDEFINED, kDEFINED}, EXPR_ARG},
+ {"super", {kSUPER, kSUPER}, EXPR_ARG},
+ {"undef", {kUNDEF, kUNDEF}, EXPR_FNAME},
+ {"break", {kBREAK, kBREAK}, EXPR_MID},
+ {"in", {kIN, kIN}, EXPR_BEG},
+ {"do", {kDO, kDO}, EXPR_BEG},
+ {"nil", {kNIL, kNIL}, EXPR_END},
+ {"until", {kUNTIL, kUNTIL_MOD}, EXPR_BEG},
+ {"unless", {kUNLESS, kUNLESS_MOD}, EXPR_BEG},
+ {"or", {kOR, kOR}, EXPR_BEG},
+ {"next", {kNEXT, kNEXT}, EXPR_MID},
+ {"when", {kWHEN, kWHEN}, EXPR_BEG},
+ {"redo", {kREDO, kREDO}, EXPR_END},
+ {"and", {kAND, kAND}, EXPR_BEG},
+ {"begin", {kBEGIN, kBEGIN}, EXPR_BEG},
+ {"__LINE__", {k__LINE__, k__LINE__}, EXPR_END},
+ {"class", {kCLASS, kCLASS}, EXPR_CLASS},
+ {"__FILE__", {k__FILE__, k__FILE__}, EXPR_END},
+ {"END", {klEND, klEND}, EXPR_END},
+ {"BEGIN", {klBEGIN, klBEGIN}, EXPR_END},
+ {"while", {kWHILE, kWHILE_MOD}, EXPR_BEG},
+ {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+ {""},
+ {"alias", {kALIAS, kALIAS}, EXPR_FNAME}
+ };
+
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register int key = hash (str, len);
+
+ if (key <= MAX_HASH_VALUE && key >= 0)
+ {
+ register const char *s = wordlist[key].name;
+
+ if (*str == *s && !strcmp (str + 1, s + 1))
+ return &wordlist[key];
+ }
+ }
+ return 0;
+}
diff --git a/lex.c.blt b/lex.c.blt
deleted file mode 100644
index 1b6c31e964..0000000000
--- a/lex.c.blt
+++ /dev/null
@@ -1,214 +0,0 @@
-/* C code produced by gperf version 3.0.2 */
-/* Command-line: gperf --output-file=lex.c.tmp -C -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' keywords */
-
-#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
- && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
- && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
- && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
- && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
- && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
- && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
- && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
- && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
- && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
- && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
- && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
- && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
- && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
- && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
- && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
- && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
- && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
- && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
- && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
- && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
- && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
- && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
-/* The character set is not based on ISO-646. */
-error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
-#endif
-
-#line 1 "keywords"
-
-struct kwtable {char *name; int id[2]; enum lex_state_e state;};
-const struct kwtable *rb_reserved_word(const char *, unsigned int);
-#ifndef RIPPER
-#line 7 "keywords"
-struct kwtable;
-
-#define TOTAL_KEYWORDS 41
-#define MIN_WORD_LENGTH 2
-#define MAX_WORD_LENGTH 12
-#define MIN_HASH_VALUE 8
-#define MAX_HASH_VALUE 50
-/* maximum key range = 43, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (str, len)
- register const char *str;
- register unsigned int len;
-{
- static const unsigned char asso_values[] =
- {
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 26, 51, 51, 14, 51, 16, 8,
- 11, 13, 51, 51, 51, 51, 10, 51, 13, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 11, 51, 13, 1, 26,
- 4, 1, 8, 28, 51, 23, 51, 1, 1, 27,
- 5, 19, 21, 51, 8, 3, 3, 11, 51, 21,
- 24, 16, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51
- };
- register int hval = len;
-
- switch (hval)
- {
- default:
- hval += asso_values[(unsigned char)str[2]];
- /*FALLTHROUGH*/
- case 2:
- case 1:
- hval += asso_values[(unsigned char)str[0]];
- break;
- }
- return hval + asso_values[(unsigned char)str[len - 1]];
-}
-
-#ifdef __GNUC__
-__inline
-#endif
-const struct kwtable *
-rb_reserved_word (str, len)
- register const char *str;
- register unsigned int len;
-{
- static const struct kwtable wordlist[] =
- {
- {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-#line 17 "keywords"
- {"break", {keyword_break, keyword_break}, EXPR_MID},
-#line 23 "keywords"
- {"else", {keyword_else, keyword_else}, EXPR_BEG},
-#line 33 "keywords"
- {"nil", {keyword_nil, keyword_nil}, EXPR_END},
-#line 26 "keywords"
- {"ensure", {keyword_ensure, keyword_ensure}, EXPR_BEG},
-#line 25 "keywords"
- {"end", {keyword_end, keyword_end}, EXPR_END},
-#line 42 "keywords"
- {"then", {keyword_then, keyword_then}, EXPR_BEG},
-#line 34 "keywords"
- {"not", {keyword_not, keyword_not}, EXPR_VALUE},
-#line 27 "keywords"
- {"false", {keyword_false, keyword_false}, EXPR_END},
-#line 40 "keywords"
- {"self", {keyword_self, keyword_self}, EXPR_END},
-#line 24 "keywords"
- {"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE},
-#line 37 "keywords"
- {"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID},
-#line 43 "keywords"
- {"true", {keyword_true, keyword_true}, EXPR_END},
-#line 46 "keywords"
- {"until", {keyword_until, modifier_until}, EXPR_VALUE},
-#line 45 "keywords"
- {"unless", {keyword_unless, modifier_unless}, EXPR_VALUE},
-#line 39 "keywords"
- {"return", {keyword_return, keyword_return}, EXPR_MID},
-#line 20 "keywords"
- {"def", {keyword_def, keyword_def}, EXPR_FNAME},
-#line 15 "keywords"
- {"and", {keyword_and, keyword_and}, EXPR_VALUE},
-#line 22 "keywords"
- {"do", {keyword_do, keyword_do}, EXPR_BEG},
-#line 49 "keywords"
- {"yield", {keyword_yield, keyword_yield}, EXPR_ARG},
-#line 28 "keywords"
- {"for", {keyword_for, keyword_for}, EXPR_VALUE},
-#line 44 "keywords"
- {"undef", {keyword_undef, keyword_undef}, EXPR_FNAME},
-#line 35 "keywords"
- {"or", {keyword_or, keyword_or}, EXPR_VALUE},
-#line 30 "keywords"
- {"in", {keyword_in, keyword_in}, EXPR_VALUE},
-#line 47 "keywords"
- {"when", {keyword_when, keyword_when}, EXPR_VALUE},
-#line 38 "keywords"
- {"retry", {keyword_retry, keyword_retry}, EXPR_END},
-#line 29 "keywords"
- {"if", {keyword_if, modifier_if}, EXPR_VALUE},
-#line 18 "keywords"
- {"case", {keyword_case, keyword_case}, EXPR_VALUE},
-#line 36 "keywords"
- {"redo", {keyword_redo, keyword_redo}, EXPR_END},
-#line 32 "keywords"
- {"next", {keyword_next, keyword_next}, EXPR_MID},
-#line 41 "keywords"
- {"super", {keyword_super, keyword_super}, EXPR_ARG},
-#line 31 "keywords"
- {"module", {keyword_module, keyword_module}, EXPR_VALUE},
-#line 16 "keywords"
- {"begin", {keyword_begin, keyword_begin}, EXPR_BEG},
-#line 10 "keywords"
- {"__LINE__", {keyword__LINE__, keyword__LINE__}, EXPR_END},
-#line 11 "keywords"
- {"__FILE__", {keyword__FILE__, keyword__FILE__}, EXPR_END},
-#line 9 "keywords"
- {"__ENCODING__", {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
-#line 13 "keywords"
- {"END", {keyword_END, keyword_END}, EXPR_END},
-#line 14 "keywords"
- {"alias", {keyword_alias, keyword_alias}, EXPR_FNAME},
-#line 12 "keywords"
- {"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
-#line 21 "keywords"
- {"defined?", {keyword_defined, keyword_defined}, EXPR_ARG},
-#line 19 "keywords"
- {"class", {keyword_class, keyword_class}, EXPR_CLASS},
- {""}, {""},
-#line 48 "keywords"
- {"while", {keyword_while, modifier_while}, EXPR_VALUE}
- };
-
- if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
- {
- register int key = hash (str, len);
-
- if (key <= MAX_HASH_VALUE && key >= 0)
- {
- register const char *s = wordlist[key].name;
-
- if (*str == *s && !strcmp (str + 1, s + 1))
- return &wordlist[key];
- }
- }
- return 0;
-}
-#line 50 "keywords"
-
-#endif
diff --git a/lex.c.src b/lex.c.src
deleted file mode 100644
index 76cd2437a9..0000000000
--- a/lex.c.src
+++ /dev/null
@@ -1,51 +0,0 @@
-%{
-struct kwtable {char *name; int id[2]; enum lex_state_e state;};
-const struct kwtable *rb_reserved_word(const char *, unsigned int);
-#ifndef RIPPER
-%}
-
-struct kwtable;
-%%
-__ENCODING__, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END
-__LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END
-__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END
-BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END
-END, {keyword_END, keyword_END}, EXPR_END
-alias, {keyword_alias, keyword_alias}, EXPR_FNAME
-and, {keyword_and, keyword_and}, EXPR_VALUE
-begin, {keyword_begin, keyword_begin}, EXPR_BEG
-break, {keyword_break, keyword_break}, EXPR_MID
-case, {keyword_case, keyword_case}, EXPR_VALUE
-class, {keyword_class, keyword_class}, EXPR_CLASS
-def, {keyword_def, keyword_def}, EXPR_FNAME
-defined?, {keyword_defined, keyword_defined}, EXPR_ARG
-do, {keyword_do, keyword_do}, EXPR_BEG
-else, {keyword_else, keyword_else}, EXPR_BEG
-elsif, {keyword_elsif, keyword_elsif}, EXPR_VALUE
-end, {keyword_end, keyword_end}, EXPR_END
-ensure, {keyword_ensure, keyword_ensure}, EXPR_BEG
-false, {keyword_false, keyword_false}, EXPR_END
-for, {keyword_for, keyword_for}, EXPR_VALUE
-if, {keyword_if, modifier_if}, EXPR_VALUE
-in, {keyword_in, keyword_in}, EXPR_VALUE
-module, {keyword_module, keyword_module}, EXPR_VALUE
-next, {keyword_next, keyword_next}, EXPR_MID
-nil, {keyword_nil, keyword_nil}, EXPR_END
-not, {keyword_not, keyword_not}, EXPR_VALUE
-or, {keyword_or, keyword_or}, EXPR_VALUE
-redo, {keyword_redo, keyword_redo}, EXPR_END
-rescue, {keyword_rescue, modifier_rescue}, EXPR_MID
-retry, {keyword_retry, keyword_retry}, EXPR_END
-return, {keyword_return, keyword_return}, EXPR_MID
-self, {keyword_self, keyword_self}, EXPR_END
-super, {keyword_super, keyword_super}, EXPR_ARG
-then, {keyword_then, keyword_then}, EXPR_BEG
-true, {keyword_true, keyword_true}, EXPR_END
-undef, {keyword_undef, keyword_undef}, EXPR_FNAME
-unless, {keyword_unless, modifier_unless}, EXPR_VALUE
-until, {keyword_until, modifier_until}, EXPR_VALUE
-when, {keyword_when, keyword_when}, EXPR_VALUE
-while, {keyword_while, modifier_while}, EXPR_VALUE
-yield, {keyword_yield, keyword_yield}, EXPR_ARG
-%%
-#endif
diff --git a/lib/.document b/lib/.document
index a7582bf102..2159be8360 100644
--- a/lib/.document
+++ b/lib/.document
@@ -14,6 +14,7 @@ base64.rb
benchmark.rb
cgi
cgi.rb
+cgi-lib.rb
complex.rb
csv.rb
date
@@ -23,6 +24,7 @@ debug.rb
delegate.rb
drb
drb.rb
+e2mmap.rb
erb.rb
eregex.rb
fileutils.rb
@@ -79,8 +81,7 @@ set.rb
shell
shell.rb
shellwords.rb
-# TODO: YARV cause error. why ...?
-# singleton.rb
+singleton.rb
soap
sync.rb
tempfile.rb
diff --git a/lib/Env.rb b/lib/Env.rb
new file mode 100644
index 0000000000..452a28659e
--- /dev/null
+++ b/lib/Env.rb
@@ -0,0 +1,18 @@
+# Env.rb -- imports environment variables as global variables, Perlish ;(
+# Usage:
+#
+# require 'Env'
+# p $USER
+# $USER = "matz"
+# p ENV["USER"]
+
+require 'importenv'
+
+if __FILE__ == $0
+ p $TERM
+ $TERM = nil
+ p $TERM
+ p ENV["TERM"]
+ $TERM = "foo"
+ p ENV["TERM"]
+end
diff --git a/lib/README b/lib/README
index a1dbeb780f..fa2bbd9635 100644
--- a/lib/README
+++ b/lib/README
@@ -1,26 +1,36 @@
English.rb lets Perl'ish global variables have English names
+Env.rb loads importenv.rb
README this file
+base64.rb encodes/decodes base64 (obsolete)
benchmark.rb a benchmark utility
+cgi-lib.rb simple CGI support library (old style)
cgi.rb CGI support library
cgi/session.rb CGI session class
complex.rb complex number support
csv.rb CSV parser/generator
date.rb date object
date/format.rb date parsing and formatting
+date2.rb date object (obsolete; use date)
debug.rb ruby debugger
delegate.rb delegates messages to other object
drb.rb distributed Ruby
e2mmap.rb exception utilities
erb.rb tiny eRuby library
+eregex.rb extended regular expression (just a proof of concept)
fileutils.rb file utilities
finalize.rb adds finalizer to the object
find.rb traverses directory tree
forwardable.rb explicit delegation library
+ftools.rb file tools
getoptlong.rb GNU getoptlong compatible
+getopts.rb parses command line options (use getoptlong)
gserver.rb general TCP server
+importenv.rb imports environment variables as global variables
ipaddr.rb defines the IPAddr class
irb.rb interactive ruby
+jcode.rb Japanese text handling (replace String methods)
logger.rb simple logging utility
+mailread.rb reads mail headers
mathn.rb extended math operation
matrix.rb matrix calculation library
mkmf.rb Makefile maker
@@ -38,8 +48,10 @@ open-uri.rb easy-to-use network interface using URI and Net
open3.rb opens subprocess connection stdin/stdout/stderr
optparse.rb command line option analysis
ostruct.rb python style object
+parsearg.rb argument parser using getopts
parsedate.rb parses date string (obsolete)
pathname.rb Object-Oriented Pathname Class
+ping.rb checks whether host is up, using TCP echo.
pp.rb pretty print objects
prettyprint.rb pretty printing algorithm
profile.rb runs ruby profiler
@@ -47,15 +59,18 @@ profiler.rb ruby profiler module
pstore.rb persistent object strage using marshal
racc/parser.rb racc (Ruby yACC) runtime
rational.rb rational number support
-rdoc source-code documentation tool
+rdoc source-code documentation tool
+readbytes.rb define IO#readbytes
resolv-replace.rb replace Socket DNS by resolve.rb
resolv.rb DNS resolver in Ruby
rexml an XML parser for Ruby, in Ruby
+rubyunit.rb original Ruby Unit testing framework
scanf.rb scanf for Ruby
set.rb defines the Set class
shell.rb runs commands and does pipeline operations like shell
shellwords.rb split into words like shell
singleton.rb singleton design pattern library
+soap SOAP 1.1 implementation
sync.rb 2 phase lock
tempfile.rb temporary file with automatic removal
test/unit Ruby Unit Testing Framework
@@ -75,5 +90,7 @@ uri/ldap.rb ldap scheme support
uri/mailto.rb mailto scheme support
weakref.rb weak reference class
webrick.rb WEB server toolkit
+wsdl WSDL 1.1 implementation
xmlrpc XML-RPC implementation
+xsd XML Schema Datatypes implementation
yaml.rb YAML implementation
diff --git a/lib/base64.rb b/lib/base64.rb
new file mode 100644
index 0000000000..8628d611b2
--- /dev/null
+++ b/lib/base64.rb
@@ -0,0 +1,133 @@
+#
+# = base64.rb: methods for base64-encoding and -decoding stings
+#
+# Author:: Yukihiro Matsumoto
+# Documentation:: Dave Thomas and Gavin Sinclair
+#
+# Until Ruby 1.8.1, these methods were defined at the top-level. Now
+# they are in the Base64 module but included in the top-level, where
+# their usage is deprecated.
+#
+# See Base64 for documentation.
+#
+
+require "kconv"
+
+
+# The Base64 module provides for the encoding (#encode64) and decoding
+# (#decode64) of binary data using a Base64 representation.
+#
+# The following particular features are also provided:
+# - encode into lines of a given length (#b64encode)
+# - decode the special format specified in RFC2047 for the
+# representation of email headers (decode_b)
+#
+# == Example
+#
+# A simple encoding and decoding.
+#
+# require "base64"
+#
+# enc = Base64.encode64('Send reinforcements')
+# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
+# plain = Base64.decode64(enc)
+# # -> "Send reinforcements"
+#
+# The purpose of using base64 to encode data is that it translates any
+# binary data into purely printable characters. It is specified in
+# RFC 2045 (http://www.faqs.org/rfcs/rfc2045.html).
+
+module Base64
+ module_function
+
+ # Returns the Base64-decoded version of +str+.
+ #
+ # require 'base64'
+ # str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
+ # 'lzIGxpbmUgdHdvClRoaXMgaXMgbGlu' +
+ # 'ZSB0aHJlZQpBbmQgc28gb24uLi4K'
+ # puts Base64.decode64(str)
+ #
+ # <i>Generates:</i>
+ #
+ # This is line one
+ # This is line two
+ # This is line three
+ # And so on...
+
+ def decode64(str)
+ str.unpack("m")[0]
+ end
+
+
+ # Decodes text formatted using a subset of RFC2047 (the one used for
+ # mime-encoding mail headers).
+ #
+ # Only supports an encoding type of 'b' (base 64), and only supports
+ # the character sets ISO-2022-JP and SHIFT_JIS (so the only two
+ # encoded word sequences recognized are <tt>=?ISO-2022-JP?B?...=</tt> and
+ # <tt>=?SHIFT_JIS?B?...=</tt>). Recognition of these sequences is case
+ # insensitive.
+
+ def decode_b(str)
+ str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
+ decode64($1)
+ }
+ str = Kconv::toeuc(str)
+ str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
+ decode64($1)
+ }
+ str = Kconv::toeuc(str)
+ str.gsub!(/\n/, ' ')
+ str.gsub!(/\0/, '')
+ str
+ end
+
+ # Returns the Base64-encoded version of +str+.
+ #
+ # require 'base64'
+ # Base64.b64encode("Now is the time for all good coders\nto learn Ruby")
+ #
+ # <i>Generates:</i>
+ #
+ # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
+ # UnVieQ==
+
+ def encode64(bin)
+ [bin].pack("m")
+ end
+
+ # _Prints_ the Base64 encoded version of +bin+ (a +String+) in lines of
+ # +len+ (default 60) characters.
+ #
+ # require 'base64'
+ # data = "Now is the time for all good coders\nto learn Ruby"
+ # Base64.b64encode(data)
+ #
+ # <i>Generates:</i>
+ #
+ # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
+ # UnVieQ==
+
+ def b64encode(bin, len = 60)
+ encode64(bin).scan(/.{1,#{len}}/) do
+ print $&, "\n"
+ end
+ end
+
+
+ module Deprecated # :nodoc:
+ include Base64
+
+ for m in Base64.private_instance_methods(false)
+ module_eval %{
+ def #{m}(*args)
+ warn("\#{caller(1)[0]}: #{m} is deprecated; use Base64.#{m} instead")
+ super
+ end
+ }
+ end
+ end
+end
+
+include Base64::Deprecated
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index c7c3935131..a54700a1c2 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -304,7 +304,10 @@ module Benchmark
# Returns the elapsed real time used to execute the given block.
#
def realtime(&blk) # :yield:
- Benchmark::measure(&blk).real
+ r0 = Time.now
+ yield
+ r1 = Time.now
+ r1.to_f - r0.to_f
end
@@ -330,7 +333,7 @@ module Benchmark
# Registers the given label and block pair in the job list.
#
def item(label = "", &blk) # :yield:
- raise ArgmentError, "no block" unless block_given?
+ raise ArgumentError, "no block" unless block_given?
label += ' '
w = label.length
@width = w if @width < w
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
new file mode 100644
index 0000000000..d6b60d66cc
--- /dev/null
+++ b/lib/cgi-lib.rb
@@ -0,0 +1,272 @@
+warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: cgi-lib is deprecated after Ruby 1.8.1; use cgi instead"
+
+=begin
+
+= simple CGI support library
+
+= example
+
+== get form values
+
+ require "cgi-lib.rb"
+ query = CGI.new
+ query['field'] # <== value of 'field'
+ query.keys # <== array of fields
+
+and query has Hash class methods
+
+
+== get cookie values
+
+ require "cgi-lib.rb"
+ query = CGI.new
+ query.cookie['name'] # <== cookie value of 'name'
+ query.cookie.keys # <== all cookie names
+
+and query.cookie has Hash class methods
+
+
+== print HTTP header and HTML string to $>
+
+ require "cgi-lib.rb"
+ CGI::print{
+ CGI::tag("HTML"){
+ CGI::tag("HEAD"){ CGI::tag("TITLE"){"TITLE"} } +
+ CGI::tag("BODY"){
+ CGI::tag("FORM", {"ACTION"=>"test.rb", "METHOD"=>"POST"}){
+ CGI::tag("INPUT", {"TYPE"=>"submit", "VALUE"=>"submit"})
+ } +
+ CGI::tag("HR")
+ }
+ }
+ }
+
+
+== make raw cookie string
+
+ require "cgi-lib.rb"
+ cookie1 = CGI::cookie({'name' => 'name',
+ 'value' => 'value',
+ 'path' => 'path', # optional
+ 'domain' => 'domain', # optional
+ 'expires' => Time.now, # optional
+ 'secure' => true # optional
+ })
+
+ CGI::print("Content-Type: text/html", cookie1, cookie2){ "string" }
+
+
+== print HTTP header and string to $>
+
+ require "cgi-lib.rb"
+ CGI::print{ "string" }
+ # == CGI::print("Content-Type: text/html"){ "string" }
+ CGI::print("Content-Type: text/html", cookie1, cookie2){ "string" }
+
+
+=== NPH (no-parse-header) mode
+
+ require "cgi-lib.rb"
+ CGI::print("nph"){ "string" }
+ # == CGI::print("nph", "Content-Type: text/html"){ "string" }
+ CGI::print("nph", "Content-Type: text/html", cookie1, cookie2){ "string" }
+
+
+== make HTML tag string
+
+ require "cgi-lib.rb"
+ CGI::tag("element", {"attribute_name"=>"attribute_value"}){"content"}
+
+
+== make HTTP header string
+
+ require "cgi-lib.rb"
+ CGI::header # == CGI::header("Content-Type: text/html")
+ CGI::header("Content-Type: text/html", cookie1, cookie2)
+
+
+=== NPH (no-parse-header) mode
+
+ CGI::header("nph") # == CGI::header("nph", "Content-Type: text/html")
+ CGI::header("nph", "Content-Type: text/html", cookie1, cookie2)
+
+
+== escape url encode
+
+ require "cgi-lib.rb"
+ url_encoded_string = CGI::escape("string")
+
+
+== unescape url encoded
+
+ require "cgi-lib.rb"
+ string = CGI::unescape("url encoded string")
+
+
+== escape HTML &"<>
+
+ require "cgi-lib.rb"
+ CGI::escapeHTML("string")
+
+
+=end
+
+require "delegate"
+
+class CGI < SimpleDelegator
+
+ CR = "\015"
+ LF = "\012"
+ EOL = CR + LF
+
+ RFC822_DAYS = %w[ Sun Mon Tue Wed Thu Fri Sat ]
+ RFC822_MONTHS = %w[ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ]
+
+ # make rfc1123 date string
+ def CGI::rfc1123_date(time)
+ t = time.clone.gmtime
+ return format("%s, %.2d %s %d %.2d:%.2d:%.2d GMT",
+ RFC822_DAYS[t.wday], t.day, RFC822_MONTHS[t.month-1], t.year,
+ t.hour, t.min, t.sec)
+ end
+
+ # escape url encode
+ def CGI::escape(str)
+ str.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
+ end
+
+ # unescape url encoded
+ def CGI::unescape(str)
+ str.gsub(/\+/, ' ').gsub(/%([0-9a-fA-F]{2})/){ [$1.hex].pack("c") }
+ end
+
+ # escape HTML
+ def CGI::escapeHTML(str)
+ str.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
+ end
+
+ # offline mode. read name=value pairs on standard input.
+ def read_from_cmdline
+ require "shellwords.rb"
+ words = Shellwords.shellwords(
+ if not ARGV.empty?
+ ARGV.join(' ')
+ else
+ STDERR.print "(offline mode: enter name=value pairs on standard input)\n" if STDIN.tty?
+ readlines.join(' ').gsub(/\n/, '')
+ end.gsub(/\\=/, '%3D').gsub(/\\&/, '%26'))
+
+ if words.find{|x| x =~ /=/} then words.join('&') else words.join('+') end
+ end
+
+ def initialize(input = $stdin)
+
+ @inputs = {}
+ @cookie = {}
+
+ case ENV['REQUEST_METHOD']
+ when "GET"
+ ENV['QUERY_STRING'] or ""
+ when "POST"
+ input.read(Integer(ENV['CONTENT_LENGTH'])) or ""
+ else
+ read_from_cmdline
+ end.split(/[&;]/).each do |x|
+ key, val = x.split(/=/,2).collect{|x|CGI::unescape(x)}
+ if @inputs.include?(key)
+ @inputs[key] += "\0" + (val or "")
+ else
+ @inputs[key] = (val or "")
+ end
+ end
+
+ super(@inputs)
+
+ if ENV.has_key?('HTTP_COOKIE') or ENV.has_key?('COOKIE')
+ (ENV['HTTP_COOKIE'] or ENV['COOKIE']).split(/; /).each do |x|
+ key, val = x.split(/=/,2)
+ key = CGI::unescape(key)
+ val = val.split(/&/).collect{|x|CGI::unescape(x)}.join("\0")
+ if @cookie.include?(key)
+ @cookie[key] += "\0" + val
+ else
+ @cookie[key] = val
+ end
+ end
+ end
+ end
+
+ attr("inputs")
+ attr("cookie")
+
+ # make HTML tag string
+ def CGI::tag(element, attributes = {})
+ "<" + escapeHTML(element) + attributes.collect{|name, value|
+ " " + escapeHTML(name) + '="' + escapeHTML(value) + '"'
+ }.to_s + ">" +
+ (iterator? ? yield.to_s + "</" + escapeHTML(element) + ">" : "")
+ end
+
+ # make raw cookie string
+ def CGI::cookie(options)
+ "Set-Cookie: " + options['name'] + '=' + escape(options['value']) +
+ (options['domain'] ? '; domain=' + options['domain'] : '') +
+ (options['path'] ? '; path=' + options['path'] : '') +
+ (options['expires'] ? '; expires=' + rfc1123_date(options['expires']) : '') +
+ (options['secure'] ? '; secure' : '')
+ end
+
+ # make HTTP header string
+ def CGI::header(*options)
+ if defined?(MOD_RUBY)
+ options.each{|option|
+ option.sub(/(.*?): (.*)/){
+ Apache::request.headers_out[$1] = $2
+ }
+ }
+ Apache::request.send_http_header
+ ''
+ else
+ if options.delete("nph") or (ENV['SERVER_SOFTWARE'] =~ /IIS/)
+ [(ENV['SERVER_PROTOCOL'] or "HTTP/1.0") + " 200 OK",
+ "Date: " + rfc1123_date(Time.now),
+ "Server: " + (ENV['SERVER_SOFTWARE'] or ""),
+ "Connection: close"] +
+ (options.empty? ? ["Content-Type: text/html"] : options)
+ else
+ options.empty? ? ["Content-Type: text/html"] : options
+ end.join(EOL) + EOL + EOL
+ end
+ end
+
+ # print HTTP header and string to $>
+ def CGI::print(*options)
+ $>.print CGI::header(*options) + yield.to_s
+ end
+
+ # print message to $>
+ def CGI::message(message, title = "", header = ["Content-Type: text/html"])
+ if message.kind_of?(Hash)
+ title = message['title']
+ header = message['header']
+ message = message['body']
+ end
+ CGI::print(*header){
+ CGI::tag("HTML"){
+ CGI::tag("HEAD"){ CGI.tag("TITLE"){ title } } +
+ CGI::tag("BODY"){ message }
+ }
+ }
+ true
+ end
+
+ # print error message to $> and exit
+ def CGI::error
+ CGI::message({'title'=>'ERROR', 'body'=>
+ CGI::tag("PRE"){
+ "ERROR: " + CGI::tag("STRONG"){ escapeHTML($!.to_s) } + "\n" + escapeHTML($@.join("\n"))
+ }
+ })
+ exit
+ end
+end
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 963b6b1fc3..5279439a08 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -339,8 +339,8 @@ class CGI
# url_encoded_string = CGI::escape("'Stop!' said Fred")
# # => "%27Stop%21%27+said+Fred"
def CGI::escape(string)
- string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
- '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
+ string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
+ '%' + $1.unpack('H2' * $1.size).join('%').upcase
end.tr(' ', '+')
end
@@ -349,9 +349,8 @@ class CGI
# string = CGI::unescape("%27Stop%21%27+said+Fred")
# # => "'Stop!' said Fred"
def CGI::unescape(string)
- enc = string.encoding
- string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/) do
- [$1.delete('%')].pack('H*').force_encoding(enc)
+ string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do
+ [$1.delete('%')].pack('H*')
end
end
@@ -360,7 +359,7 @@ class CGI
# CGI::escapeHTML('Usage: foo "bar" <baz>')
# # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
def CGI::escapeHTML(string)
- string.gsub(/&/, '&amp;').gsub(/\"/, '&quot;').gsub(/>/, '&gt;').gsub(/</, '&lt;')
+ string.gsub(/&/n, '&amp;').gsub(/\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;')
end
@@ -368,37 +367,39 @@ class CGI
# CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
# # => "Usage: foo \"bar\" <baz>"
def CGI::unescapeHTML(string)
- enc = string.encoding
- string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/) do
+ string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/n) do
match = $1.dup
case match
when 'amp' then '&'
when 'quot' then '"'
when 'gt' then '>'
when 'lt' then '<'
- when /\A#0*(\d+)\z/ then
+ when /\A#0*(\d+)\z/n then
if Integer($1) < 256
- Integer($1).chr.force_encoding(enc)
+ Integer($1).chr
else
- "&##{$1};"
+ if Integer($1) < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
+ [Integer($1)].pack("U")
+ else
+ "&##{$1};"
+ end
end
- when /\A#x([0-9a-f]+)\z/i then
+ when /\A#x([0-9a-f]+)\z/ni then
if $1.hex < 256
- $1.hex.chr.force_encoding(enc)
+ $1.hex.chr
else
- "&#x#{$1};"
+ if $1.hex < 65536 and ($KCODE[0] == ?u or $KCODE[0] == ?U)
+ [$1.hex].pack("U")
+ else
+ "&#x#{$1};"
+ end
end
else
"&#{match};"
end
end
end
- def CGI::escape_html(str)
- escapeHTML(str)
- end
- def CGI::unescape_html(str)
- unescapeHTML(str)
- end
+
# Escape only the tags of certain HTML elements in +string+.
#
@@ -444,12 +445,7 @@ class CGI
string
end
end
- def CGI::escape_element(str)
- escapeElement(str)
- end
- def CGI::unescape_element(str)
- unescapeElement(str)
- end
+
# Format a +Time+ object as a String using the format specified by RFC 1123.
#
@@ -713,13 +709,13 @@ class CGI
require "nkf"
case options["charset"]
when /iso-2022-jp/ni
- content = NKF::nkf('-j -m0 -x', content)
+ content = NKF::nkf('-m0 -x -j', content)
options["language"] = "ja" unless options.has_key?("language")
when /euc-jp/ni
- content = NKF::nkf('-e -m0 -x', content)
+ content = NKF::nkf('-m0 -x -e', content)
options["language"] = "ja" unless options.has_key?("language")
when /shift_jis/ni
- content = NKF::nkf('-s -m0 -x', content)
+ content = NKF::nkf('-m0 -x -s', content)
options["language"] = "ja" unless options.has_key?("language")
end
end
@@ -796,11 +792,16 @@ class CGI
#
# These keywords correspond to attributes of the cookie object.
def initialize(name = "", *value)
- options = if name.kind_of?(String)
- { "name" => name, "value" => value }
- else
- name
- end
+ if name.kind_of?(String)
+ @name = name
+ @value = value
+ %r|^(.*/)|.match(ENV["SCRIPT_NAME"])
+ @path = ($1 or "")
+ @secure = false
+ return super(@value)
+ end
+
+ options = name
unless options.has_key?("name")
raise ArgumentError, "`name' required"
end
@@ -884,7 +885,7 @@ class CGI
if cookies.has_key?(name)
values = cookies[name].value + values
end
- cookies[name] = Cookie::new({ "name" => name, "value" => values })
+ cookies[name] = Cookie::new(name, *values)
end
cookies
@@ -957,11 +958,11 @@ class CGI
end
# Get the cookies as a hash of cookie-name=>Cookie pairs.
- attr_accessor :cookies
+ attr_accessor("cookies")
# Get the parameters as a hash of name=>values pairs, where
# values is an Array.
- attr_reader :params
+ attr("params")
# Set all the parameters.
def params=(hash)
@@ -972,7 +973,7 @@ class CGI
def read_multipart(boundary, content_length)
params = Hash.new([])
boundary = "--" + boundary
- quoted_boundary = Regexp.quote(boundary)
+ quoted_boundary = Regexp.quote(boundary, "n")
buf = ""
bufsize = 10 * 1024
boundary_end=""
@@ -990,9 +991,22 @@ class CGI
loop do
head = nil
- body = MorphingBody.new
+ if 10240 < content_length
+ require "tempfile"
+ body = Tempfile.new("CGI")
+ else
+ begin
+ require "stringio"
+ body = StringIO.new
+ rescue LoadError
+ require "tempfile"
+ body = Tempfile.new("CGI")
+ end
+ end
+ body.binmode if defined? body.binmode
until head and /#{quoted_boundary}(?:#{EOL}|--)/n.match(buf)
+
if (not head) and /#{EOL}#{EOL}/n.match(buf)
buf = buf.sub(/\A((?:.|\n)*?#{EOL})#{EOL}/n) do
head = $1.dup
@@ -1029,7 +1043,7 @@ class CGI
body.rewind
- /Content-Disposition:.* filename=(?:"((?:\\.|[^\"\s])*)"|([^;\s]*))/ni.match(head)
+ /Content-Disposition:.* filename=(?:"((?:\\.|[^\"])*)"|([^;\s]*))/ni.match(head)
filename = ($1 or $2 or "")
if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and
/Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and
@@ -1047,7 +1061,7 @@ class CGI
end
/Content-Disposition:.* name="?([^\";\s]*)"?/ni.match(head)
- name = ($1 || "").dup
+ name = $1.dup
if params.has_key?(name)
params[name].push(body)
@@ -1088,59 +1102,6 @@ class CGI
end
private :read_from_cmdline
- # A wrapper class to use a StringIO object as the body and switch
- # to a TempFile when the passed threshold is passed.
- class MorphingBody
- begin
- require "stringio"
- @@small_buffer = lambda{StringIO.new}
- rescue LoadError
- require "tempfile"
- @@small_buffer = lambda{
- n = Tempfile.new("CGI")
- n.binmode
- n
- }
- end
-
- def initialize(morph_threshold = 10240)
- @threshold = morph_threshold
- @body = @@small_buffer.call
- @cur_size = 0
- @morph_check = true
- end
-
- def print(data)
- if @morph_check && (@cur_size + data.size > @threshold)
- convert_body
- end
- @body.print data
- end
- def rewind
- @body.rewind
- end
- def path
- @body.path
- end
-
- # returns the true body object.
- def extract
- @body
- end
-
- private
- def convert_body
- new_body = TempFile.new("CGI")
- new_body.binmode if defined? @body.binmode
- new_body.binmode if defined? new_body.binmode
-
- @body.rewind
- new_body.print @body.read
- @body = new_body
- @morph_check = false
- end
- end
-
# Initialize the data from the query.
#
# Handles multipart forms (in particular, forms that involve file uploads).
@@ -1302,7 +1263,7 @@ class CGI
else
'="' + CGI::escapeHTML(value) + '"'
end
- }.join + ">"
+ }.to_s + ">"
END
s.sub!(/\Z/, " +") << append if append
s
@@ -1525,7 +1486,7 @@ class CGI
value[value.size - 1]
end
end
- }.join
+ }.to_s
end
@@ -1605,7 +1566,7 @@ class CGI
if @output_hidden
body += @output_hidden.collect{|k,v|
"<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
- }.join
+ }.to_s
end
super(attributes){body}
end
@@ -1903,7 +1864,7 @@ class CGI
}
end
end
- }.join
+ }.to_s
}
end
@@ -1980,7 +1941,7 @@ class CGI
value[value.size - 1]
end
end
- }.join
+ }.to_s
end
# Generate a reset button Input element, as a String.
@@ -2310,15 +2271,15 @@ class CGI
Apache.request.setup_cgi_env
end
- (class << self; self; end).class_eval do
- const_set(:CGI_PARAMS, [1])
- const_set(:CGI_COOKIES, [2])
- end
-
extend QueryExtension
@multipart = false
-
- initialize_query() # set @params, @cookies
+ if defined?(CGI_PARAMS)
+ warn "do not use CGI_PARAMS and CGI_COOKIES"
+ @params = CGI_PARAMS.dup
+ @cookies = CGI_COOKIES.dup
+ else
+ initialize_query() # set @params, @cookies
+ end
@output_cookies = nil
@output_hidden = nil
diff --git a/lib/cgi/.document b/lib/cgi/.document
index 4153f97aa5..107f2f317c 100644
--- a/lib/cgi/.document
+++ b/lib/cgi/.document
@@ -1 +1,2 @@
-session.rb \ No newline at end of file
+session.rb
+
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index c693e06df2..a6e999bc34 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -230,7 +230,7 @@ class CGI
# session_path:: the path for which this session applies. Defaults
# to the directory of the CGI script.
#
- # +option+ is also passed on to the session storage class initialiser; see
+ # +option+ is also passed on to the session storage class initializer; see
# the documentation for each session storage class for the options
# they support.
#
@@ -357,7 +357,7 @@ class CGI
# characters; automatically generated session ids observe
# this requirement.
#
- # +option+ is a hash of options for the initialiser. The
+ # +option+ is a hash of options for the initializer. The
# following options are recognised:
#
# tmpdir:: the directory to use for storing the FileStore
@@ -365,7 +365,7 @@ class CGI
# on Unix systems).
# prefix:: the prefix to add to the session id when generating
# the filename for this session's FileStore file.
- # Defaults to "cgi_sid_".
+ # Defaults to the empty string.
# suffix:: the prefix to add to the session id when generating
# the filename for this session's FileStore file.
# Defaults to the empty string.
@@ -374,7 +374,7 @@ class CGI
# not exist, or opened if it does.
def initialize(session, option={})
dir = option['tmpdir'] || Dir::tmpdir
- prefix = option['prefix'] || 'cgi_sid_'
+ prefix = option['prefix'] || ''
suffix = option['suffix'] || ''
id = session.session_id
require 'digest/md5'
@@ -494,42 +494,5 @@ class CGI
GLOBAL_HASH_TABLE.delete(@session_id)
end
end
-
- # Dummy session storage class.
- #
- # Implements session storage place holder. No actual storage
- # will be done.
- class NullStore
- # Create a new NullStore instance.
- #
- # +session+ is the session this instance is associated with.
- # +option+ is a list of initialisation options. None are
- # currently recognised.
- def initialize(session, option=nil)
- end
-
- # Restore (empty) session state.
- def restore
- {}
- end
-
- # Update session state.
- #
- # A no-op.
- def update
- end
-
- # Close session storage.
- #
- # A no-op.
- def close
- end
-
- # Delete the session state.
- #
- # A no-op.
- def delete
- end
- end
end
end
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index 9a16a66b15..3d204d5dc0 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -30,7 +30,7 @@ class CGI
# characters; automatically generated session ids observe
# this requirement.
#
- # +option+ is a hash of options for the initialiser. The
+ # +option+ is a hash of options for the initializer. The
# following options are recognised:
#
# tmpdir:: the directory to use for storing the PStore
@@ -70,7 +70,7 @@ class CGI
def restore
unless @hash
@p.transaction do
- @hash = @p['hash'] || {}
+ @hash = @p['hash'] || {}
end
end
@hash
diff --git a/lib/complex.rb b/lib/complex.rb
index 6b086661af..fbf50ffece 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -90,9 +90,6 @@ end
def Complex(a, b = 0)
if b == 0 and (a.kind_of?(Complex) or defined? Complex::Unify)
a
- elsif a.scalar? and b.scalar?
- # Don't delete for -0.0
- Complex.new(a, b)
else
Complex.new( a.real-b.imag, a.imag+b.real )
end
@@ -105,10 +102,8 @@ class Complex < Numeric
@RCS_ID='-$Id: complex.rb,v 1.3 1998/07/08 10:05:28 keiju Exp keiju $-'
undef step
-
- def scalar?
- false
- end
+ undef div, divmod
+ undef floor, truncate, ceil, round
def Complex.generic?(other) # :nodoc:
other.kind_of?(Integer) or
@@ -201,6 +196,10 @@ class Complex < Numeric
end
end
+ def quo(other)
+ Complex(@real.quo(1), @image.quo(1)) / other
+ end
+
#
# Raise this complex number to the given (real or complex) power.
#
@@ -312,8 +311,13 @@ class Complex < Numeric
Complex(@real, -@image)
end
alias conj conjugate
-
- undef <=>
+
+ #
+ # Compares the absolute values of the two numbers.
+ #
+ def <=> (other)
+ self.abs <=> other.abs
+ end
#
# Test for numerical equality (<tt>a == a + 0<i>i</i></tt>).
@@ -403,16 +407,42 @@ class Complex < Numeric
I = Complex(0,1)
# The real part of a complex number.
- attr_reader :real
+ attr :real
# The imaginary part of a complex number.
- attr_reader :image
+ attr :image
alias imag image
end
+class Integer
+ unless defined?(1.numerator)
+ def numerator() self end
+ def denominator() 1 end
+ def gcd(other)
+ min = self.abs
+ max = other.abs
+ while min > 0
+ tmp = min
+ min = max % min
+ max = tmp
+ end
+ max
+ end
+
+ def lcm(other)
+ if self.zero? or other.zero?
+ 0
+ else
+ (self.div(self.gcd(other)) * other).abs
+ end
+ end
+
+ end
+
+end
module Math
alias sqrt! sqrt
diff --git a/lib/csv.rb b/lib/csv.rb
index b12142e50a..f6c12fa285 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -1,1896 +1,992 @@
-#!/usr/local/bin/ruby -w
-
-# = csv.rb -- CSV Reading and Writing
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-#
-# See CSV for documentation.
-#
-# == Description
-#
-# Welcome to the new and improved CSV.
-#
-# This version of the CSV library began its life as FasterCSV. FasterCSV was
-# intended as a replacement to Ruby's then standard CSV library. It was
-# designed to address concerns users of that library had and it had three
-# primary goals:
-#
-# 1. Be significantly faster than CSV while remaining a pure Ruby library.
-# 2. Use a smaller and easier to maintain code base. (FasterCSV eventually
-# grew larger, was also but considerably richer in features. The parsing
-# core remains quite small.)
-# 3. Improve on the CSV interface.
-#
-# Obviously, the last one is subjective. I did try to defer to the original
-# interface whenever I didn't have a compelling reason to change it though, so
-# hopefully this won't be too radically different.
-#
-# We must have met our goals because FasterCSV was renamed to CSV and replaced
-# the original library.
-#
-# == What's Different From the Old CSV?
-#
-# I'm sure I'll miss something, but I'll try to mention most of the major
-# differences I am aware of, to help others quickly get up to speed:
-#
-# === CSV Parsing
-#
-# * This library has a stricter parser and will throw MalformedCSVErrors on
-# problematic data.
-# * This library has a less liberal idea of a line ending than CSV. What you
-# set as the <tt>:row_sep</tt> is law. It can auto-detect your line endings
-# though.
-# * The old library returned empty lines as <tt>[nil]</tt>. This library calls
-# them <tt>[]</tt>.
-# * This library has a much faster parser.
-#
-# === Interface
-#
-# * CSV now uses Hash-style parameters to set options.
-# * CSV no longer has generate_row() or parse_row().
-# * The old CSV's Reader and Writer classes have been dropped.
-# * CSV::open() is now more like Ruby's open().
-# * CSV objects now support most standard IO methods.
-# * CSV now has a new() method used to wrap objects like String and IO for
-# reading and writing.
-# * CSV::generate() is different from the old method.
-# * CSV no longer supports partial reads. It works line-by-line.
-# * CSV no longer allows the instance methods to override the separators for
-# performance reasons. They must be set in the constructor.
-#
-# If you use this library and find yourself missing any functionality I have
-# trimmed, please {let me know}[mailto:james@grayproductions.net].
-#
-# == Documentation
-#
-# See CSV for documentation.
-#
-# == What is CSV, really?
-#
-# CSV maintains a pretty strict definition of CSV taken directly from
-# {the RFC}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
-# place and that is to make using this library easier. CSV will parse all valid
-# CSV.
-#
-# What you don't want to do is feed CSV invalid data. Because of the way the
-# CSV format works, it's common for a parser to need to read until the end of
-# the file to be sure a field is invalid. This eats a lot of time and memory.
-#
-# Luckily, when working with invalid CSV, Ruby's built-in methods will almost
-# always be superior in every way. For example, parsing non-quoted fields is as
-# easy as:
-#
-# data.split(",")
-#
-# == Questions and/or Comments
-#
-# Feel free to email {James Edward Gray II}[mailto:james@grayproductions.net]
-# with any questions.
-
-require "forwardable"
-require "English"
-require "enumerator"
-require "date"
-require "stringio"
-
-#
-# This class provides a complete interface to CSV files and data. It offers
-# tools to enable you to read and write to and from Strings or IO objects, as
-# needed.
-#
-# == Reading
-#
-# === From a File
-#
-# ==== A Line at a Time
-#
-# CSV.foreach("path/to/file.csv") do |row|
-# # use row here...
-# end
-#
-# ==== All at Once
-#
-# arr_of_arrs = CSV.read("path/to/file.csv")
-#
-# === From a String
-#
-# ==== A Line at a Time
-#
-# CSV.parse("CSV,data,String") do |row|
-# # use row here...
-# end
-#
-# ==== All at Once
-#
-# arr_of_arrs = CSV.parse("CSV,data,String")
-#
-# == Writing
-#
-# === To a File
-#
-# CSV.open("path/to/file.csv", "w") do |csv|
-# csv << ["row", "of", "CSV", "data"]
-# csv << ["another", "row"]
-# # ...
-# end
-#
-# === To a String
-#
-# csv_string = CSV.generate do |csv|
-# csv << ["row", "of", "CSV", "data"]
-# csv << ["another", "row"]
-# # ...
-# end
-#
-# == Convert a Single Line
-#
-# csv_string = ["CSV", "data"].to_csv # to CSV
-# csv_array = "CSV,String".parse_csv # from CSV
-#
-# == Shortcut Interface
-#
-# CSV { |csv_out| csv_out << %w{my data here} } # to $stdout
-# CSV(csv = "") { |csv_str| csv_str << %w{my data here} } # to a String
-# CSV($stderr) { |csv_err| csv_err << %w{my data here} } # to $stderr
-#
-class CSV
- # The version of the installed library.
- VERSION = "2.0.0".freeze
+# CSV -- module for generating/parsing CSV data.
+# Copyright (C) 2000-2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
- #
- # A CSV::Row is part Array and part Hash. It retains an order for the fields
- # and allows duplicates just as an Array would, but also allows you to access
- # fields by name just as you could if they were in a Hash.
- #
- # All rows returned by CSV will be constructed from this class, if header row
- # processing is activated.
- #
- class Row
- #
- # Construct a new CSV::Row from +headers+ and +fields+, which are expected
- # to be Arrays. If one Array is shorter than the other, it will be padded
- # with +nil+ objects.
- #
- # The optional +header_row+ parameter can be set to +true+ to indicate, via
- # CSV::Row.header_row?() and CSV::Row.field_row?(), that this is a header
- # row. Otherwise, the row is assumes to be a field row.
- #
- # A CSV::Row object supports the following Array methods through delegation:
- #
- # * empty?()
- # * length()
- # * size()
- #
- def initialize(headers, fields, header_row = false)
- @header_row = header_row
-
- # handle extra headers or fields
- larger, smaller, transform = headers.size > fields.size ?
- [headers, fields, :to_a] :
- [fields, headers, :reverse]
- @row = Array.new
- larger.each_with_index do |e, i|
- @row << [e, smaller[i]].send(transform)
- end
+# $Id$
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+class CSV
+ class IllegalFormatError < RuntimeError; end
+
+ # deprecated
+ class Cell < String
+ def initialize(data = "", is_null = false)
+ super(is_null ? "" : data)
+ end
+
+ def data
+ to_s
+ end
+ end
+
+ # deprecated
+ class Row < Array
+ end
+
+ # Open a CSV formatted file for reading or writing.
+ #
+ # For reading.
+ #
+ # EXAMPLE 1
+ # CSV.open('csvfile.csv', 'r') do |row|
+ # p row
+ # end
+ #
+ # EXAMPLE 2
+ # reader = CSV.open('csvfile.csv', 'r')
+ # row1 = reader.shift
+ # row2 = reader.shift
+ # if row2.empty?
+ # p 'row2 not find.'
+ # end
+ # reader.close
+ #
+ # ARGS
+ # filename: filename to parse.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # reader instance. To get parse result, see CSV::Reader#each.
+ #
+ #
+ # For writing.
+ #
+ # EXAMPLE 1
+ # CSV.open('csvfile.csv', 'w') do |writer|
+ # writer << ['r1c1', 'r1c2']
+ # writer << ['r2c1', 'r2c2']
+ # writer << [nil, nil]
+ # end
+ #
+ # EXAMPLE 2
+ # writer = CSV.open('csvfile.csv', 'w')
+ # writer << ['r1c1', 'r1c2'] << ['r2c1', 'r2c2'] << [nil, nil]
+ # writer.close
+ #
+ # ARGS
+ # filename: filename to generate.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # writer instance. See CSV::Writer#<< and CSV::Writer#add_row to know how
+ # to generate CSV string.
+ #
+ def CSV.open(path, mode, fs = nil, rs = nil, &block)
+ if mode == 'r' or mode == 'rb'
+ open_reader(path, mode, fs, rs, &block)
+ elsif mode == 'w' or mode == 'wb'
+ open_writer(path, mode, fs, rs, &block)
+ else
+ raise ArgumentError.new("'mode' must be 'r', 'rb', 'w', or 'wb'")
end
-
- # Internal data format used to compare equality.
- attr_reader :row
- protected :row
+ end
- ### Array Delegation ###
+ def CSV.foreach(path, rs = nil, &block)
+ open_reader(path, 'r', ',', rs, &block)
+ end
- extend Forwardable
- def_delegators :@row, :empty?, :length, :size
-
- # Returns +true+ if this is a header row.
- def header_row?
- @header_row
- end
-
- # Returns +true+ if this is a field row.
- def field_row?
- not header_row?
- end
-
- # Returns the headers of this row.
- def headers
- @row.map { |pair| pair.first }
+ def CSV.read(path, length = nil, offset = nil)
+ CSV.parse(IO.read(path, length, offset))
+ end
+
+ def CSV.readlines(path, rs = nil)
+ reader = open_reader(path, 'r', ',', rs)
+ begin
+ reader.collect { |row| row }
+ ensure
+ reader.close
end
-
- #
- # :call-seq:
- # field( header )
- # field( header, offset )
- # field( index )
- #
- # This method will fetch the field value by +header+ or +index+. If a field
- # is not found, +nil+ is returned.
- #
- # When provided, +offset+ ensures that a header match occurrs on or later
- # than the +offset+ index. You can use this to find duplicate headers,
- # without resorting to hard-coding exact indices.
- #
- def field(header_or_index, minimum_index = 0)
- # locate the pair
- finder = header_or_index.is_a?(Integer) ? :[] : :assoc
- pair = @row[minimum_index..-1].send(finder, header_or_index)
+ end
+
+ def CSV.generate(path, fs = nil, rs = nil, &block)
+ open_writer(path, 'w', fs, rs, &block)
+ end
- # return the field if we have a pair
- pair.nil? ? nil : pair.last
+ # Parse lines from given string or stream. Return rows as an Array of Arrays.
+ def CSV.parse(str_or_readable, fs = nil, rs = nil, &block)
+ if File.exist?(str_or_readable)
+ STDERR.puts("CSV.parse(filename) is deprecated." +
+ " Use CSV.open(filename, 'r') instead.")
+ return open_reader(str_or_readable, 'r', fs, rs, &block)
end
- alias_method :[], :field
-
- #
- # :call-seq:
- # []=( header, value )
- # []=( header, offset, value )
- # []=( index, value )
- #
- # Looks up the field by the semantics described in CSV::Row.field() and
- # assigns the +value+.
- #
- # Assigning past the end of the row with an index will set all pairs between
- # to <tt>[nil, nil]</tt>. Assigning to an unused header appends the new
- # pair.
- #
- def []=(*args)
- value = args.pop
-
- if args.first.is_a? Integer
- if @row[args.first].nil? # extending past the end with index
- @row[args.first] = [nil, value]
- @row.map! { |pair| pair.nil? ? [nil, nil] : pair }
- else # normal index assignment
- @row[args.first][1] = value
- end
- else
- index = index(*args)
- if index.nil? # appending a field
- self << [args.first, value]
- else # normal header assignment
- @row[index][1] = value
- end
+ if block
+ CSV::Reader.parse(str_or_readable, fs, rs) do |row|
+ yield(row)
end
+ nil
+ else
+ CSV::Reader.create(str_or_readable, fs, rs).collect { |row| row }
end
-
- #
- # :call-seq:
- # <<( field )
- # <<( header_and_field_array )
- # <<( header_and_field_hash )
- #
- # If a two-element Array is provided, it is assumed to be a header and field
- # and the pair is appended. A Hash works the same way with the key being
- # the header and the value being the field. Anything else is assumed to be
- # a lone field which is appended with a +nil+ header.
- #
- # This method returns the row for chaining.
- #
- def <<(arg)
- if arg.is_a?(Array) and arg.size == 2 # appending a header and name
- @row << arg
- elsif arg.is_a?(Hash) # append header and name pairs
- arg.each { |pair| @row << pair }
- else # append field value
- @row << [nil, arg]
- end
-
- self # for chaining
+ end
+
+ # Parse a line from given string. Bear in mind it parses ONE LINE. Rest of
+ # the string is ignored for example "a,b\r\nc,d" => ['a', 'b'] and the
+ # second line 'c,d' is ignored.
+ #
+ # If you don't know whether a target string to parse is exactly 1 line or
+ # not, use CSV.parse_row instead of this method.
+ def CSV.parse_line(src, fs = nil, rs = nil)
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
end
-
- #
- # A shortcut for appending multiple fields. Equivalent to:
- #
- # args.each { |arg| csv_row << arg }
- #
- # This method returns the row for chaining.
- #
- def push(*args)
- args.each { |arg| self << arg }
-
- self # for chaining
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
end
-
- #
- # :call-seq:
- # delete( header )
- # delete( header, offset )
- # delete( index )
- #
- # Used to remove a pair from the row by +header+ or +index+. The pair is
- # located as described in CSV::Row.field(). The deleted pair is returned,
- # or +nil+ if a pair could not be found.
- #
- def delete(header_or_index, minimum_index = 0)
- if header_or_index.is_a? Integer # by index
- @row.delete_at(header_or_index)
- else # by header
- @row.delete_at(index(header_or_index, minimum_index))
+ idx = 0
+ res_type = :DT_COLSEP
+ row = []
+ begin
+ while res_type == :DT_COLSEP
+ res_type, idx, cell = parse_body(src, idx, fs, rs)
+ row << cell
end
+ rescue IllegalFormatError
+ return []
end
-
- #
- # The provided +block+ is passed a header and field for each pair in the row
- # and expected to return +true+ or +false+, depending on whether the pair
- # should be deleted.
- #
- # This method returns the row for chaining.
- #
- def delete_if(&block)
- @row.delete_if(&block)
-
- self # for chaining
- end
-
- #
- # This method accepts any number of arguments which can be headers, indices,
- # Ranges of either, or two-element Arrays containing a header and offset.
- # Each argument will be replaced with a field lookup as described in
- # CSV::Row.field().
- #
- # If called with no arguments, all fields are returned.
- #
- def fields(*headers_and_or_indices)
- if headers_and_or_indices.empty? # return all fields--no arguments
- @row.map { |pair| pair.last }
- else # or work like values_at()
- headers_and_or_indices.inject(Array.new) do |all, h_or_i|
- all + if h_or_i.is_a? Range
- index_begin = h_or_i.begin.is_a?(Integer) ? h_or_i.begin :
- index(h_or_i.begin)
- index_end = h_or_i.end.is_a?(Integer) ? h_or_i.end :
- index(h_or_i.end)
- new_range = h_or_i.exclude_end? ? (index_begin...index_end) :
- (index_begin..index_end)
- fields.values_at(new_range)
- else
- [field(*Array(h_or_i))]
+ row
+ end
+
+ # Create a line from cells. each cell is stringified by to_s.
+ def CSV.generate_line(row, fs = nil, rs = nil)
+ if row.size == 0
+ return ''
+ end
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ res_type = :DT_COLSEP
+ result_str = ''
+ idx = 0
+ while true
+ generate_body(row[idx], result_str, fs, rs)
+ idx += 1
+ if (idx == row.size)
+ break
+ end
+ generate_separator(:DT_COLSEP, result_str, fs, rs)
+ end
+ result_str
+ end
+
+ # Parse a line from string. Consider using CSV.parse_line instead.
+ # To parse lines in CSV string, see EXAMPLE below.
+ #
+ # EXAMPLE
+ # src = "a,b\r\nc,d\r\ne,f"
+ # idx = 0
+ # begin
+ # parsed = []
+ # parsed_cells, idx = CSV.parse_row(src, idx, parsed)
+ # puts "Parsed #{ parsed_cells } cells."
+ # p parsed
+ # end while parsed_cells > 0
+ #
+ # ARGS
+ # src: a CSV data to be parsed. Must respond '[](idx)'.
+ # src[](idx) must return a char. (Not a string such as 'a', but 97).
+ # src[](idx_out_of_bounds) must return nil. A String satisfies this
+ # requirement.
+ # idx: index of parsing location of 'src'. 0 origin.
+ # out_dev: buffer for parsed cells. Must respond '<<(aString)'.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # parsed_cells: num of parsed cells.
+ # idx: index of next parsing location of 'src'.
+ #
+ def CSV.parse_row(src, idx, out_dev, fs = nil, rs = nil)
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ idx_backup = idx
+ parsed_cells = 0
+ res_type = :DT_COLSEP
+ begin
+ while res_type != :DT_ROWSEP
+ res_type, idx, cell = parse_body(src, idx, fs, rs)
+ if res_type == :DT_EOS
+ if idx == idx_backup #((parsed_cells == 0) and cell.nil?)
+ return 0, 0
end
+ res_type = :DT_ROWSEP
end
- end
- end
- alias_method :values_at, :fields
-
- #
- # :call-seq:
- # index( header )
- # index( header, offset )
- #
- # This method will return the index of a field with the provided +header+.
- # The +offset+ can be used to locate duplicate header names, as described in
- # CSV::Row.field().
- #
- def index(header, minimum_index = 0)
- # find the pair
- index = headers[minimum_index..-1].index(header)
- # return the index at the right offset, if we found one
- index.nil? ? nil : index + minimum_index
- end
-
- # Returns +true+ if +name+ is a header for this row, and +false+ otherwise.
- def header?(name)
- headers.include? name
- end
- alias_method :include?, :header?
-
- #
- # Returns +true+ if +data+ matches a field in this row, and +false+
- # otherwise.
- #
- def field?(data)
- fields.include? data
- end
-
- include Enumerable
-
- #
- # Yields each pair of the row as header and field tuples (much like
- # iterating over a Hash).
- #
- # Support for Enumerable.
- #
- # This method returns the row for chaining.
- #
- def each(&block)
- @row.each(&block)
-
- self # for chaining
- end
-
- #
- # Returns +true+ if this row contains the same headers and fields in the
- # same order as +other+.
- #
- def ==(other)
- @row == other.row
- end
-
- #
- # Collapses the row into a simple Hash. Be warning that this discards field
- # order and clobbers duplicate fields.
- #
- def to_hash
- # flatten just one level of the internal Array
- Hash[*@row.inject(Array.new) { |ary, pair| ary.push(*pair) }]
- end
-
- #
- # Returns the row as a CSV String. Headers are not used. Equivalent to:
- #
- # csv_row.fields.to_csv( options )
- #
- def to_csv(options = Hash.new)
- fields.to_csv(options)
+ parsed_cells += 1
+ out_dev << cell
+ end
+ rescue IllegalFormatError
+ return 0, 0
+ end
+ return parsed_cells, idx
+ end
+
+ # Convert a line from cells data to string. Consider using CSV.generate_line
+ # instead. To generate multi-row CSV string, see EXAMPLE below.
+ #
+ # EXAMPLE
+ # row1 = ['a', 'b']
+ # row2 = ['c', 'd']
+ # row3 = ['e', 'f']
+ # src = [row1, row2, row3]
+ # buf = ''
+ # src.each do |row|
+ # parsed_cells = CSV.generate_row(row, 2, buf)
+ # puts "Created #{ parsed_cells } cells."
+ # end
+ # p buf
+ #
+ # ARGS
+ # src: an Array of String to be converted to CSV string. Must respond to
+ # 'size' and '[](idx)'. src[idx] must return String.
+ # cells: num of cells in a line.
+ # out_dev: buffer for generated CSV string. Must respond to '<<(string)'.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # parsed_cells: num of converted cells.
+ #
+ def CSV.generate_row(src, cells, out_dev, fs = nil, rs = nil)
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ src_size = src.size
+ if (src_size == 0)
+ if cells == 0
+ generate_separator(:DT_ROWSEP, out_dev, fs, rs)
+ end
+ return 0
+ end
+ res_type = :DT_COLSEP
+ parsed_cells = 0
+ generate_body(src[parsed_cells], out_dev, fs, rs)
+ parsed_cells += 1
+ while ((parsed_cells < cells) and (parsed_cells != src_size))
+ generate_separator(:DT_COLSEP, out_dev, fs, rs)
+ generate_body(src[parsed_cells], out_dev, fs, rs)
+ parsed_cells += 1
+ end
+ if (parsed_cells == cells)
+ generate_separator(:DT_ROWSEP, out_dev, fs, rs)
+ else
+ generate_separator(:DT_COLSEP, out_dev, fs, rs)
end
- alias_method :to_s, :to_csv
+ parsed_cells
end
- #
- # A CSV::Table is a two-dimensional data structure for representing CSV
- # documents. Tables allow you to work with the data by row or column,
- # manipulate the data, and even convert the results back to CSV, if needed.
- #
- # All tables returned by CSV will be constructed from this class, if header
- # row processing is activated.
- #
- class Table
- #
- # Construct a new CSV::Table from +array_of_rows+, which are expected
- # to be CSV::Row objects. All rows are assumed to have the same headers.
- #
- # A CSV::Table object supports the following Array methods through
- # delegation:
- #
- # * empty?()
- # * length()
- # * size()
- #
- def initialize(array_of_rows)
- @table = array_of_rows
- @mode = :col_or_row
- end
-
- # The current access mode for indexing and iteration.
- attr_reader :mode
-
- # Internal data format used to compare equality.
- attr_reader :table
- protected :table
-
- ### Array Delegation ###
+ # Private class methods.
+ class << self
+ private
- extend Forwardable
- def_delegators :@table, :empty?, :length, :size
-
- #
- # Returns a duplicate table object, in column mode. This is handy for
- # chaining in a single call without changing the table mode, but be aware
- # that this method can consume a fair amount of memory for bigger data sets.
- #
- # This method returns the duplicate table for chaining. Don't chain
- # destructive methods (like []=()) this way though, since you are working
- # with a duplicate.
- #
- def by_col
- self.class.new(@table.dup).by_col!
- end
-
- #
- # Switches the mode of this table to column mode. All calls to indexing and
- # iteration methods will work with columns until the mode is changed again.
- #
- # This method returns the table and is safe to chain.
- #
- def by_col!
- @mode = :col
-
- self
- end
-
- #
- # Returns a duplicate table object, in mixed mode. This is handy for
- # chaining in a single call without changing the table mode, but be aware
- # that this method can consume a fair amount of memory for bigger data sets.
- #
- # This method returns the duplicate table for chaining. Don't chain
- # destructive methods (like []=()) this way though, since you are working
- # with a duplicate.
- #
- def by_col_or_row
- self.class.new(@table.dup).by_col_or_row!
- end
-
- #
- # Switches the mode of this table to mixed mode. All calls to indexing and
- # iteration methods will use the default intelligent indexing system until
- # the mode is changed again. In mixed mode an index is assumed to be a row
- # reference while anything else is assumed to be column access by headers.
- #
- # This method returns the table and is safe to chain.
- #
- def by_col_or_row!
- @mode = :col_or_row
-
- self
- end
-
- #
- # Returns a duplicate table object, in row mode. This is handy for chaining
- # in a single call without changing the table mode, but be aware that this
- # method can consume a fair amount of memory for bigger data sets.
- #
- # This method returns the duplicate table for chaining. Don't chain
- # destructive methods (like []=()) this way though, since you are working
- # with a duplicate.
- #
- def by_row
- self.class.new(@table.dup).by_row!
- end
-
- #
- # Switches the mode of this table to row mode. All calls to indexing and
- # iteration methods will work with rows until the mode is changed again.
- #
- # This method returns the table and is safe to chain.
- #
- def by_row!
- @mode = :row
-
- self
- end
-
- #
- # Returns the headers for the first row of this table (assumed to match all
- # other rows). An empty Array is returned for empty tables.
- #
- def headers
- if @table.empty?
- Array.new
+ def open_reader(path, mode, fs, rs, &block)
+ file = File.open(path, mode)
+ if block
+ begin
+ CSV::Reader.parse(file, fs, rs) do |row|
+ yield(row)
+ end
+ ensure
+ file.close
+ end
+ nil
else
- @table.first.headers
- end
- end
-
- #
- # In the default mixed mode, this method returns rows for index access and
- # columns for header access. You can force the index association by first
- # calling by_col!() or by_row!().
- #
- # Columns are returned as an Array of values. Altering that Array has no
- # effect on the table.
- #
- def [](index_or_header)
- if @mode == :row or # by index
- (@mode == :col_or_row and index_or_header.is_a? Integer)
- @table[index_or_header]
- else # by header
- @table.map { |row| row[index_or_header] }
+ reader = CSV::Reader.create(file, fs, rs)
+ reader.close_on_terminate
+ reader
end
end
-
- #
- # In the default mixed mode, this method assigns rows for index access and
- # columns for header access. You can force the index association by first
- # calling by_col!() or by_row!().
- #
- # Rows may be set to an Array of values (which will inherit the table's
- # headers()) or a CSV::Row.
- #
- # Columns may be set to a single value, which is copied to each row of the
- # column, or an Array of values. Arrays of values are assigned to rows top
- # to bottom in row major order. Excess values are ignored and if the Array
- # does not have a value for each row the extra rows will receive a +nil+.
- #
- # Assigning to an existing column or row clobbers the data. Assigning to
- # new columns creates them at the right end of the table.
- #
- def []=(index_or_header, value)
- if @mode == :row or # by index
- (@mode == :col_or_row and index_or_header.is_a? Integer)
- if value.is_a? Array
- @table[index_or_header] = Row.new(headers, value)
- else
- @table[index_or_header] = value
+
+ def open_writer(path, mode, fs, rs, &block)
+ file = File.open(path, mode)
+ if block
+ begin
+ CSV::Writer.generate(file, fs, rs) do |writer|
+ yield(writer)
+ end
+ ensure
+ file.close
end
- else # set column
- if value.is_a? Array # multiple values
- @table.each_with_index do |row, i|
- if row.header_row?
- row[index_or_header] = index_or_header
- else
- row[index_or_header] = value[i]
+ nil
+ else
+ writer = CSV::Writer.create(file, fs, rs)
+ writer.close_on_terminate
+ writer
+ end
+ end
+
+ def parse_body(src, idx, fs, rs)
+ fs_str = fs
+ fs_size = fs_str.size
+ rs_str = rs || "\n"
+ rs_size = rs_str.size
+ fs_idx = rs_idx = 0
+ cell = Cell.new
+ state = :ST_START
+ quoted = cr = false
+ c = nil
+ last_idx = idx
+ while c = src[idx]
+ unless quoted
+ fschar = (c == fs_str[fs_idx])
+ rschar = (c == rs_str[rs_idx])
+ # simple 1 char backtrack
+ if !fschar and c == fs_str[0]
+ fs_idx = 0
+ fschar = true
+ if state == :ST_START
+ state = :ST_DATA
+ elsif state == :ST_QUOTE
+ raise IllegalFormatError
end
end
- else # repeated value
- @table.each do |row|
- if row.header_row?
- row[index_or_header] = index_or_header
+ if !rschar and c == rs_str[0]
+ rs_idx = 0
+ rschar = true
+ if state == :ST_START
+ state = :ST_DATA
+ elsif state == :ST_QUOTE
+ raise IllegalFormatError
+ end
+ end
+ end
+ if c == ?"
+ fs_idx = rs_idx = 0
+ if cr
+ raise IllegalFormatError
+ end
+ cell << src[last_idx, (idx - last_idx)]
+ last_idx = idx
+ if state == :ST_DATA
+ if quoted
+ last_idx += 1
+ quoted = false
+ state = :ST_QUOTE
else
- row[index_or_header] = value
+ raise IllegalFormatError
+ end
+ elsif state == :ST_QUOTE
+ cell << c.chr
+ last_idx += 1
+ quoted = true
+ state = :ST_DATA
+ else # :ST_START
+ quoted = true
+ last_idx += 1
+ state = :ST_DATA
+ end
+ elsif fschar or rschar
+ if fschar
+ fs_idx += 1
+ end
+ if rschar
+ rs_idx += 1
+ end
+ sep = nil
+ if fs_idx == fs_size
+ if state == :ST_START and rs_idx > 0 and fs_idx < rs_idx
+ state = :ST_DATA
+ end
+ cell << src[last_idx, (idx - last_idx - (fs_size - 1))]
+ last_idx = idx
+ fs_idx = rs_idx = 0
+ if cr
+ raise IllegalFormatError
+ end
+ sep = :DT_COLSEP
+ elsif rs_idx == rs_size
+ if state == :ST_START and fs_idx > 0 and rs_idx < fs_idx
+ state = :ST_DATA
+ end
+ if !(rs.nil? and cr)
+ cell << src[last_idx, (idx - last_idx - (rs_size - 1))]
+ last_idx = idx
end
+ fs_idx = rs_idx = 0
+ sep = :DT_ROWSEP
+ end
+ if sep
+ if state == :ST_DATA
+ return sep, idx + 1, cell;
+ elsif state == :ST_QUOTE
+ return sep, idx + 1, cell;
+ else # :ST_START
+ return sep, idx + 1, nil
+ end
+ end
+ elsif rs.nil? and c == ?\r
+ # special \r treatment for backward compatibility
+ fs_idx = rs_idx = 0
+ if cr
+ raise IllegalFormatError
+ end
+ cell << src[last_idx, (idx - last_idx)]
+ last_idx = idx
+ if quoted
+ state = :ST_DATA
+ else
+ cr = true
+ end
+ else
+ fs_idx = rs_idx = 0
+ if state == :ST_DATA or state == :ST_START
+ if cr
+ raise IllegalFormatError
+ end
+ state = :ST_DATA
+ else # :ST_QUOTE
+ raise IllegalFormatError
end
end
+ idx += 1
end
- end
-
- #
- # The mixed mode default is to treat a list of indices as row access,
- # returning the rows indicated. Anything else is considered columnar
- # access. For columnar access, the return set has an Array for each row
- # with the values indicated by the headers in each Array. You can force
- # column or row mode using by_col!() or by_row!().
- #
- # You cannot mix column and row access.
- #
- def values_at(*indices_or_headers)
- if @mode == :row or # by indices
- ( @mode == :col_or_row and indices_or_headers.all? do |index|
- index.is_a?(Integer) or
- ( index.is_a?(Range) and
- index.first.is_a?(Integer) and
- index.last.is_a?(Integer) )
- end )
- @table.values_at(*indices_or_headers)
- else # by headers
- @table.map { |row| row.values_at(*indices_or_headers) }
- end
- end
-
- #
- # Adds a new row to the bottom end of this table. You can provide an Array,
- # which will be converted to a CSV::Row (inheriting the table's headers()),
- # or a CSV::Row.
- #
- # This method returns the table for chaining.
- #
- def <<(row_or_array)
- if row_or_array.is_a? Array # append Array
- @table << Row.new(headers, row_or_array)
- else # append Row
- @table << row_or_array
- end
-
- self # for chaining
- end
-
- #
- # A shortcut for appending multiple rows. Equivalent to:
- #
- # rows.each { |row| self << row }
- #
- # This method returns the table for chaining.
- #
- def push(*rows)
- rows.each { |row| self << row }
-
- self # for chaining
- end
-
- #
- # Removes and returns the indicated column or row. In the default mixed
- # mode indices refer to rows and everything else is assumed to be a column
- # header. Use by_col!() or by_row!() to force the lookup.
- #
- def delete(index_or_header)
- if @mode == :row or # by index
- (@mode == :col_or_row and index_or_header.is_a? Integer)
- @table.delete_at(index_or_header)
- else # by header
- @table.map { |row| row.delete(index_or_header).last }
- end
- end
-
- #
- # Removes any column or row for which the block returns +true+. In the
- # default mixed mode or row mode, iteration is the standard row major
- # walking of rows. In column mode, interation will +yield+ two element
- # tuples containing the column name and an Array of values for that column.
- #
- # This method returns the table for chaining.
- #
- def delete_if(&block)
- if @mode == :row or @mode == :col_or_row # by index
- @table.delete_if(&block)
- else # by header
- to_delete = Array.new
- headers.each_with_index do |header, i|
- to_delete << header if block[[header, self[header]]]
+ if state == :ST_START
+ if fs_idx > 0 or rs_idx > 0
+ state = :ST_DATA
+ else
+ return :DT_EOS, idx, nil
end
- to_delete.map { |header| delete(header) }
+ elsif quoted
+ raise IllegalFormatError
+ elsif cr
+ raise IllegalFormatError
end
-
- self # for chaining
+ cell << src[last_idx, (idx - last_idx)]
+ last_idx = idx
+ return :DT_EOS, idx, cell
end
-
- include Enumerable
-
- #
- # In the default mixed mode or row mode, iteration is the standard row major
- # walking of rows. In column mode, interation will +yield+ two element
- # tuples containing the column name and an Array of values for that column.
- #
- # This method returns the table for chaining.
- #
- def each(&block)
- if @mode == :col
- headers.each { |header| block[[header, self[header]]] }
+
+ def generate_body(cell, out_dev, fs, rs)
+ if cell.nil?
+ # empty
else
- @table.each(&block)
- end
-
- self # for chaining
- end
-
- # Returns +true+ if all rows of this table ==() +other+'s rows.
- def ==(other)
- @table == other.table
- end
-
- #
- # Returns the table as an Array of Arrays. Headers will be the first row,
- # then all of the field rows will follow.
- #
- def to_a
- @table.inject([headers]) do |array, row|
- if row.header_row?
- array
+ cell = cell.to_s
+ row_data = cell.dup
+ if (row_data.gsub!('"', '""') or
+ row_data.index(fs) or
+ (rs and row_data.index(rs)) or
+ (/[\r\n]/ =~ row_data) or
+ (cell.empty?))
+ out_dev << '"' << row_data << '"'
else
- array + [row.fields]
+ out_dev << row_data
end
end
end
- #
- # Returns the table as a complete CSV String. Headers will be listed first,
- # then all of the field rows.
- #
- def to_csv(options = Hash.new)
- @table.inject([headers.to_csv(options)]) do |rows, row|
- if row.header_row?
- rows
- else
- rows + [row.fields.to_csv(options)]
- end
- end.join
+ def generate_separator(type, out_dev, fs, rs)
+ case type
+ when :DT_COLSEP
+ out_dev << fs
+ when :DT_ROWSEP
+ out_dev << (rs || "\n")
+ end
end
- alias_method :to_s, :to_csv
end
- # The error thrown when the parser encounters illegal CSV formatting.
- class MalformedCSVError < RuntimeError; end
-
- #
- # A FieldInfo Struct contains details about a field's position in the data
- # source it was read from. CSV will pass this Struct to some blocks that make
- # decisions based on field structure. See CSV.convert_fields() for an
- # example.
- #
- # <b><tt>index</tt></b>:: The zero-based index of the field in its row.
- # <b><tt>line</tt></b>:: The line of the data source this row is from.
- # <b><tt>header</tt></b>:: The header for the column, when available.
- #
- FieldInfo = Struct.new(:index, :line, :header)
-
- # A Regexp used to find and convert some common Date formats.
- DateMatcher = / \A(?: (\w+,?\s+)?\w+\s+\d{1,2},?\s+\d{2,4} |
- \d{4}-\d{2}-\d{2} )\z /x
- # A Regexp used to find and convert some common DateTime formats.
- DateTimeMatcher =
- / \A(?: (\w+,?\s+)?\w+\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2},?\s+\d{2,4} |
- \d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2} )\z /x
- #
- # This Hash holds the built-in converters of CSV that can be accessed by name.
- # You can select Converters with CSV.convert() or through the +options+ Hash
- # passed to CSV::new().
- #
- # <b><tt>:integer</tt></b>:: Converts any field Integer() accepts.
- # <b><tt>:float</tt></b>:: Converts any field Float() accepts.
- # <b><tt>:numeric</tt></b>:: A combination of <tt>:integer</tt>
- # and <tt>:float</tt>.
- # <b><tt>:date</tt></b>:: Converts any field Date::parse() accepts.
- # <b><tt>:date_time</tt></b>:: Converts any field DateTime::parse() accepts.
- # <b><tt>:all</tt></b>:: All built-in converters. A combination of
- # <tt>:date_time</tt> and <tt>:numeric</tt>.
- #
- # This Hash is intetionally left unfrozen and users should feel free to add
- # values to it that can be accessed by all CSV objects.
- #
- # To add a combo field, the value should be an Array of names. Combo fields
- # can be nested with other combo fields.
- #
- Converters = { :integer => lambda { |f| Integer(f) rescue f },
- :float => lambda { |f| Float(f) rescue f },
- :numeric => [:integer, :float],
- :date => lambda { |f|
- f =~ DateMatcher ? (Date.parse(f) rescue f) : f
- },
- :date_time => lambda { |f|
- f =~ DateTimeMatcher ? (DateTime.parse(f) rescue f) : f
- },
- :all => [:date_time, :numeric] }
- #
- # This Hash holds the built-in header converters of CSV that can be accessed
- # by name. You can select HeaderConverters with CSV.header_convert() or
- # through the +options+ Hash passed to CSV::new().
- #
- # <b><tt>:downcase</tt></b>:: Calls downcase() on the header String.
- # <b><tt>:symbol</tt></b>:: The header String is downcased, spaces are
- # replaced with underscores, non-word characters
- # are dropped, and finally to_sym() is called.
- #
- # This Hash is intetionally left unfrozen and users should feel free to add
- # values to it that can be accessed by all CSV objects.
- #
- # To add a combo field, the value should be an Array of names. Combo fields
- # can be nested with other combo fields.
- #
- HeaderConverters = {
- :downcase => lambda { |h| h.downcase },
- :symbol => lambda { |h|
- h.downcase.tr(" ", "_").delete("^a-z0-9_").to_sym
- }
- }
-
- #
- # The options used when no overrides are given by calling code. They are:
- #
- # <b><tt>:col_sep</tt></b>:: <tt>","</tt>
- # <b><tt>:row_sep</tt></b>:: <tt>:auto</tt>
- # <b><tt>:quote_char</tt></b>:: <tt>'"'</tt>
- # <b><tt>:converters</tt></b>:: +nil+
- # <b><tt>:unconverted_fields</tt></b>:: +nil+
- # <b><tt>:headers</tt></b>:: +false+
- # <b><tt>:return_headers</tt></b>:: +false+
- # <b><tt>:header_converters</tt></b>:: +nil+
- # <b><tt>:skip_blanks</tt></b>:: +false+
- # <b><tt>:force_quotes</tt></b>:: +false+
- #
- DEFAULT_OPTIONS = { :col_sep => ",",
- :row_sep => :auto,
- :quote_char => '"',
- :converters => nil,
- :unconverted_fields => nil,
- :headers => false,
- :return_headers => false,
- :header_converters => nil,
- :skip_blanks => false,
- :force_quotes => false }.freeze
-
- #
- # This method allows you to serialize an Array of Ruby objects to a String or
- # File of CSV data. This is not as powerful as Marshal or YAML, but perhaps
- # useful for spreadsheet and database interaction.
- #
- # Out of the box, this method is intended to work with simple data objects or
- # Structs. It will serialize a list of instance variables and/or
- # Struct.members().
- #
- # If you need need more complicated serialization, you can control the process
- # by adding methods to the class to be serialized.
- #
- # A class method csv_meta() is responsible for returning the first row of the
- # document (as an Array). This row is considered to be a Hash of the form
- # key_1,value_1,key_2,value_2,... CSV::load() expects to find a class key
- # with a value of the stringified class name and CSV::dump() will create this,
- # if you do not define this method. This method is only called on the first
- # object of the Array.
- #
- # The next method you can provide is an instance method called csv_headers().
- # This method is expected to return the second line of the document (again as
- # an Array), which is to be used to give each column a header. By default,
- # CSV::load() will set an instance variable if the field header starts with an
- # @ character or call send() passing the header as the method name and
- # the field value as an argument. This method is only called on the first
- # object of the Array.
- #
- # Finally, you can provide an instance method called csv_dump(), which will
- # be passed the headers. This should return an Array of fields that can be
- # serialized for this object. This method is called once for every object in
- # the Array.
- #
- # The +io+ parameter can be used to serialize to a File, and +options+ can be
- # anything CSV::new() accepts.
- #
- def self.dump(ary_of_objs, io = "", options = Hash.new)
- obj_template = ary_of_objs.first
-
- csv = new(io, options)
-
- # write meta information
- begin
- csv << obj_template.class.csv_meta
- rescue NoMethodError
- csv << [:class, obj_template.class]
- end
+ # CSV formatted string/stream reader.
+ #
+ # EXAMPLE
+ # read CSV lines untill the first column is 'stop'.
+ #
+ # CSV::Reader.parse(File.open('bigdata', 'rb')) do |row|
+ # p row
+ # break if !row[0].is_null && row[0].data == 'stop'
+ # end
+ #
+ class Reader
+ include Enumerable
- # write headers
- begin
- headers = obj_template.csv_headers
- rescue NoMethodError
- headers = obj_template.instance_variables.sort
- if obj_template.class.ancestors.find { |cls| cls.to_s =~ /\AStruct\b/ }
- headers += obj_template.members.map { |mem| "#{mem}=" }.sort
- end
- end
- csv << headers
-
- # serialize each object
- ary_of_objs.each do |obj|
- begin
- csv << obj.csv_dump(headers)
- rescue NoMethodError
- csv << headers.map do |var|
- if var[0] == ?@
- obj.instance_variable_get(var)
- else
- obj[var[0..-2]]
- end
+ # Parse CSV data and get lines. Given block is called for each parsed row.
+ # Block value is always nil. Rows are not cached for performance reason.
+ def Reader.parse(str_or_readable, fs = ',', rs = nil, &block)
+ reader = Reader.create(str_or_readable, fs, rs)
+ if block
+ reader.each do |row|
+ yield(row)
end
+ reader.close
+ nil
+ else
+ reader
end
end
-
- if io.is_a? String
- csv.string
- else
- csv.close
+
+ # Returns reader instance.
+ def Reader.create(str_or_readable, fs = ',', rs = nil)
+ case str_or_readable
+ when IO
+ IOReader.new(str_or_readable, fs, rs)
+ when String
+ StringReader.new(str_or_readable, fs, rs)
+ else
+ IOReader.new(str_or_readable, fs, rs)
+ end
end
- end
-
- #
- # :call-seq:
- # filter( options = Hash.new ) { |row| ... }
- # filter( input, options = Hash.new ) { |row| ... }
- # filter( input, output, options = Hash.new ) { |row| ... }
- #
- # This method is a convenience for building Unix-like filters for CSV data.
- # Each row is yielded to the provided block which can alter it as needed.
- # After the block returns, the row is appended to +output+ altered or not.
- #
- # The +input+ and +output+ arguments can be anything CSV::new() accepts
- # (generally String or IO objects). If not given, they default to
- # <tt>ARGF</tt> and <tt>$stdout</tt>.
- #
- # The +options+ parameter is also filtered down to CSV::new() after some
- # clever key parsing. Any key beginning with <tt>:in_</tt> or
- # <tt>:input_</tt> will have that leading identifier stripped and will only
- # be used in the +options+ Hash for the +input+ object. Keys starting with
- # <tt>:out_</tt> or <tt>:output_</tt> affect only +output+. All other keys
- # are assigned to both objects.
- #
- # The <tt>:output_row_sep</tt> +option+ defaults to
- # <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>).
- #
- def self.filter(*args)
- # parse options for input, output, or both
- in_options, out_options = Hash.new, {:row_sep => $INPUT_RECORD_SEPARATOR}
- if args.last.is_a? Hash
- args.pop.each do |key, value|
- case key.to_s
- when /\Ain(?:put)?_(.+)\Z/
- in_options[$1.to_sym] = value
- when /\Aout(?:put)?_(.+)\Z/
- out_options[$1.to_sym] = value
- else
- in_options[key] = value
- out_options[key] = value
+
+ def each
+ while true
+ row = []
+ parsed_cells = get_row(row)
+ if parsed_cells == 0
+ break
end
+ yield(row)
end
+ nil
end
- # build input and output wrappers
- input = new(args.shift || ARGF, in_options)
- output = new(args.shift || $stdout, out_options)
-
- # read, yield, write
- input.each do |row|
- yield row
- output << row
- end
- end
-
- #
- # This method is intended as the primary interface for reading CSV files. You
- # pass a +path+ and any +options+ you wish to set for the read. Each row of
- # file will be passed to the provided +block+ in turn.
- #
- # The +options+ parameter can be anything CSV::new() understands.
- #
- def self.foreach(path, options = Hash.new, &block)
- open(path, options) do |csv|
- csv.each(&block)
+
+ def shift
+ row = []
+ parsed_cells = get_row(row)
+ row
end
- end
- #
- # :call-seq:
- # generate( str, options = Hash.new ) { |csv| ... }
- # generate( options = Hash.new ) { |csv| ... }
- #
- # This method wraps a String you provide, or an empty default String, in a
- # CSV object which is passed to the provided block. You can use the block to
- # append CSV rows to the String and when the block exits, the final String
- # will be returned.
- #
- # Note that a passed String *is* modfied by this method. Call dup() before
- # passing if you need a new String.
- #
- # The +options+ parameter can be anthing CSV::new() understands.
- #
- def self.generate(*args)
- # add a default empty String, if none was given
- if args.first.is_a? String
- io = StringIO.new(args.shift)
- io.seek(0, IO::SEEK_END)
- args.unshift(io)
- else
- args.unshift("")
+ def close
+ terminate
end
- csv = new(*args) # wrap
- yield csv # yield for appending
- csv.string # return final String
- end
- #
- # This method is a shortcut for converting a single row (Array) into a CSV
- # String.
- #
- # The +options+ parameter can be anthing CSV::new() understands.
- #
- # The <tt>:row_sep</tt> +option+ defaults to <tt>$INPUT_RECORD_SEPARATOR</tt>
- # (<tt>$/</tt>) when calling this method.
- #
- def self.generate_line(row, options = Hash.new)
- options = {:row_sep => $INPUT_RECORD_SEPARATOR}.merge(options)
- (new("", options) << row).string
- end
-
- #
- # This method will return a CSV instance, just like CSV::new(), but the
- # instance will be cached and returned for all future calls to this method for
- # the same +data+ object (tested by Object#object_id()) with the same
- # +options+.
- #
- # If a block is given, the instance is passed to the block and the return
- # value becomes the return value of the block.
- #
- def self.instance(data = $stdout, options = Hash.new)
- # create a _signature_ for this method call, data object and options
- sig = [data.object_id] +
- options.values_at(*DEFAULT_OPTIONS.keys.sort_by { |sym| sym.to_s })
-
- # fetch or create the instance for this signature
- @@instances ||= Hash.new
- instance = (@@instances[sig] ||= new(data, options))
+ private
- if block_given?
- yield instance # run block, if given, returning result
- else
- instance # or return the instance
+ def initialize(dev)
+ raise RuntimeError.new('Do not instanciate this class directly.')
end
- end
-
- #
- # This method is the reading counterpart to CSV::dump(). See that method for
- # a detailed description of the process.
- #
- # You can customize loading by adding a class method called csv_load() which
- # will be passed a Hash of meta information, an Array of headers, and an Array
- # of fields for the object the method is expected to return.
- #
- # Remember that all fields will be Strings after this load. If you need
- # something else, use +options+ to setup converters or provide a custom
- # csv_load() implementation.
- #
- def self.load(io_or_str, options = Hash.new)
- csv = new(io_or_str, options)
-
- # load meta information
- meta = Hash[*csv.shift]
- cls = meta["class"].split("::").inject(Object) do |c, const|
- c.const_get(const)
+
+ def get_row(row)
+ raise NotImplementedError.new('Method get_row must be defined in a derived class.')
end
-
- # load headers
- headers = csv.shift
-
- # unserialize each object stored in the file
- results = csv.inject(Array.new) do |all, row|
- begin
- obj = cls.csv_load(meta, headers, row)
- rescue NoMethodError
- obj = cls.allocate
- headers.zip(row) do |name, value|
- if name[0] == ?@
- obj.instance_variable_set(name, value)
- else
- obj.send(name, value)
- end
- end
- end
- all << obj
+
+ def terminate
+ # Define if needed.
end
-
- csv.close unless io_or_str.is_a? String
-
- results
end
- #
- # :call-seq:
- # open( filename, mode="r", options = Hash.new ) { |csv| ... }
- # open( filename, mode="r", options = Hash.new )
- #
- # This method opens an IO object, and wraps that with CSV. This is intended
- # as the primary interface for writing a CSV file.
- #
- # You may pass any +args+ Ruby's open() understands followed by an optional
- # Hash containing any +options+ CSV::new() understands.
- #
- # This method works like Ruby's open() call, in that it will pass a CSV object
- # to a provided block and close it when the block termminates, or it will
- # return the CSV object when no block is provided. (*Note*: This is different
- # from the Ruby 1.8 CSV library which passed rows to the block. Use
- # CSV::foreach() for that behavior.)
- #
- # An opened CSV object will delegate to many IO methods, for convenience. You
- # may call:
- #
- # * binmode()
- # * close()
- # * close_read()
- # * close_write()
- # * closed?()
- # * eof()
- # * eof?()
- # * fcntl()
- # * fileno()
- # * flush()
- # * fsync()
- # * ioctl()
- # * isatty()
- # * pid()
- # * pos()
- # * reopen()
- # * seek()
- # * stat()
- # * sync()
- # * sync=()
- # * tell()
- # * to_i()
- # * to_io()
- # * tty?()
- #
- def self.open(*args)
- # find the +options+ Hash
- options = if args.last.is_a? Hash then args.pop else Hash.new end
- # wrap a File opened with the remaining +args+
- csv = new(File.open(*args), options)
-
- # handle blocks like Ruby's open(), not like the CSV library
- if block_given?
- begin
- yield csv
- ensure
- csv.close
+
+ class StringReader < Reader
+ def initialize(string, fs = ',', rs = nil)
+ @fs = fs
+ @rs = rs
+ @dev = string
+ @idx = 0
+ if @dev[0, 3] == "\xef\xbb\xbf"
+ @idx += 3
end
- else
- csv
end
- end
-
- #
- # :call-seq:
- # parse( str, options = Hash.new ) { |row| ... }
- # parse( str, options = Hash.new )
- #
- # This method can be used to easily parse CSV out of a String. You may either
- # provide a +block+ which will be called with each row of the String in turn,
- # or just use the returned Array of Arrays (when no +block+ is given).
- #
- # You pass your +str+ to read from, and an optional +options+ Hash containing
- # anything CSV::new() understands.
- #
- def self.parse(*args, &block)
- csv = new(*args)
- if block.nil? # slurp contents, if no block is given
- begin
- csv.read
- ensure
- csv.close
+
+ private
+
+ def get_row(row)
+ parsed_cells, next_idx = CSV.parse_row(@dev, @idx, row, @fs, @rs)
+ if parsed_cells == 0 and next_idx == 0 and @idx != @dev.size
+ raise IllegalFormatError.new
end
- else # or pass each row to a provided block
- csv.each(&block)
- end
- end
-
- #
- # This method is a shortcut for converting a single line of a CSV String into
- # a into an Array. Note that if +line+ contains multiple rows, anything
- # beyond the first row is ignored.
- #
- # The +options+ parameter can be anthing CSV::new() understands.
- #
- def self.parse_line(line, options = Hash.new)
- new(line, options).shift
- end
-
- #
- # Use to slurp a CSV file into an Array of Arrays. Pass the +path+ to the
- # file and any +options+ CSV::new() understands.
- #
- def self.read(path, options = Hash.new)
- open(path, options) { |csv| csv.read }
- end
-
- # Alias for CSV::read().
- def self.readlines(*args)
- read(*args)
- end
-
- #
- # A shortcut for:
- #
- # CSV.read( path, { :headers => true,
- # :converters => :numeric,
- # :header_converters => :symbol }.merge(options) )
- #
- def self.table(path, options = Hash.new)
- read( path, { :headers => true,
- :converters => :numeric,
- :header_converters => :symbol }.merge(options) )
- end
-
- #
- # This constructor will wrap either a String or IO object passed in +data+ for
- # reading and/or writing. In addition to the CSV instance methods, several IO
- # methods are delegated. (See CSV::open() for a complete list.) If you pass
- # a String for +data+, you can later retrieve it (after writing to it, for
- # example) with CSV.string().
- #
- # Note that a wrapped String will be positioned at at the beginning (for
- # reading). If you want it at the end (for writing), use CSV::generate().
- # If you want any other positioning, pass a preset StringIO object instead.
- #
- # You may set any reading and/or writing preferences in the +options+ Hash.
- # Available options are:
- #
- # <b><tt>:col_sep</tt></b>:: The String placed between each field.
- # <b><tt>:row_sep</tt></b>:: The String appended to the end of each
- # row. This can be set to the special
- # <tt>:auto</tt> setting, which requests
- # that CSV automatically discover this
- # from the data. Auto-discovery reads
- # ahead in the data looking for the next
- # <tt>"\r\n"</tt>, <tt>"\n"</tt>, or
- # <tt>"\r"</tt> sequence. A sequence
- # will be selected even if it occurs in
- # a quoted field, assuming that you
- # would have the same line endings
- # there. If none of those sequences is
- # found, +data+ is <tt>ARGF</tt>,
- # <tt>STDIN</tt>, <tt>STDOUT</tt>, or
- # <tt>STDERR</tt>, or the stream is only
- # available for output, the default
- # <tt>$INPUT_RECORD_SEPARATOR</tt>
- # (<tt>$/</tt>) is used. Obviously,
- # discovery takes a little time. Set
- # manually if speed is important.
- # <b><tt>:quote_char</tt></b>:: The character used to quote fields.
- # This has to be a single character
- # String. This is useful for
- # application that incorrectly use
- # <tt>'</tt> as the quote character
- # instead of the correct <tt>"</tt>.
- # CSV will always consider a double
- # sequence this character to be an
- # escaped quote.
- # <b><tt>:converters</tt></b>:: An Array of names from the Converters
- # Hash and/or lambdas that handle custom
- # conversion. A single converter
- # doesn't have to be in an Array.
- # <b><tt>:unconverted_fields</tt></b>:: If set to +true+, an
- # unconverted_fields() method will be
- # added to all returned rows (Array or
- # CSV::Row) that will return the fields
- # as they were before convertion. Note
- # that <tt>:headers</tt> supplied by
- # Array or String were not fields of the
- # document and thus will have an empty
- # Array attached.
- # <b><tt>:headers</tt></b>:: If set to <tt>:first_row</tt> or
- # +true+, the initial row of the CSV
- # file will be treated as a row of
- # headers. If set to an Array, the
- # contents will be used as the headers.
- # If set to a String, the String is run
- # through a call of CSV::parse_line() to
- # produce an Array of headers. This
- # setting causes CSV.shift() to return
- # rows as CSV::Row objects instead of
- # Arrays and CSV.read() to return
- # CSV::Table objects instead of an Array
- # of Arrays.
- # <b><tt>:return_headers</tt></b>:: When +false+, header rows are silently
- # swallowed. If set to +true+, header
- # rows are returned in a CSV::Row object
- # with identical headers and
- # fields (save that the fields do not go
- # through the converters).
- # <b><tt>:header_converters</tt></b>:: Identical in functionality to
- # <tt>:converters</tt> save that the
- # conversions are only made to header
- # rows.
- # <b><tt>:skip_blanks</tt></b>:: When set to a +true+ value, CSV will
- # skip over any rows with no content.
- # <b><tt>:force_quotes</tt></b>:: When set to a +true+ value, CSV will
- # quote all CSV fields it creates.
- #
- # See CSV::DEFAULT_OPTIONS for the default settings.
- #
- # Options cannot be overriden in the instance methods for performance reasons,
- # so be sure to set what you want here.
- #
- def initialize(data, options = Hash.new)
- # build the options for this read/write
- options = DEFAULT_OPTIONS.merge(options)
-
- # create the IO object we will read from
- @io = if data.is_a? String then StringIO.new(data) else data end
-
- init_separators(options)
- init_parsers(options)
- init_converters(options)
- init_headers(options)
-
- unless options.empty?
- raise ArgumentError, "Unknown options: #{options.keys.join(', ')}."
+ @idx = next_idx
+ parsed_cells
end
-
- # track our own lineno since IO gets confused about line-ends is CSV fields
- @lineno = 0
- end
-
- #
- # The line number of the last row read from this file. Fields with nested
- # line-end characters will not affect this count.
- #
- attr_reader :lineno
-
- ### IO and StringIO Delegation ###
-
- extend Forwardable
- def_delegators :@io, :binmode, :close, :close_read, :close_write, :closed?,
- :eof, :eof?, :fcntl, :fileno, :flush, :fsync, :ioctl,
- :isatty, :pid, :pos, :reopen, :seek, :stat, :string,
- :sync, :sync=, :tell, :to_i, :to_io, :tty?
-
- # Rewinds the underlying IO object and resets CSV's lineno() counter.
- def rewind
- @headers = nil
- @lineno = 0
-
- @io.rewind
end
- ### End Delegation ###
-
- #
- # The primary write method for wrapped Strings and IOs, +row+ (an Array or
- # CSV::Row) is converted to CSV and appended to the data source. When a
- # CSV::Row is passed, only the row's fields() are appended to the output.
- #
- # The data source must be open for writing.
- #
- def <<(row)
- # handle CSV::Row objects and Hashes
- row = case row
- when self.class::Row then row.fields
- when Hash then @headers.map { |header| row[header] }
- else row
+
+ class IOReader < Reader
+ def initialize(io, fs = ',', rs = nil)
+ @io = io
+ @fs = fs
+ @rs = rs
+ @dev = CSV::IOBuf.new(@io)
+ @idx = 0
+ if @dev[0] == 0xef and @dev[1] == 0xbb and @dev[2] == 0xbf
+ @idx += 3
+ end
+ @close_on_terminate = false
end
- @headers = row if header_row?
- @lineno += 1
+ # Tell this reader to close the IO when terminated (Triggered by invoking
+ # CSV::IOReader#close).
+ def close_on_terminate
+ @close_on_terminate = true
+ end
- @io << row.map(&@quote).join(@col_sep) + @row_sep # quote and separate
-
- self # for chaining
- end
- alias_method :add_row, :<<
- alias_method :puts, :<<
-
- #
- # :call-seq:
- # convert( name )
- # convert { |field| ... }
- # convert { |field, field_info| ... }
- #
- # You can use this method to install a CSV::Converters built-in, or provide a
- # block that handles a custom conversion.
- #
- # If you provide a block that takes one argument, it will be passed the field
- # and is expected to return the converted value or the field itself. If your
- # block takes two arguments, it will also be passed a FieldInfo Struct,
- # containing details about the field. Again, the block should return a
- # converted field or the field itself.
- #
- def convert(name = nil, &converter)
- add_converter(:converters, self.class::Converters, name, &converter)
- end
+ private
- #
- # :call-seq:
- # header_convert( name )
- # header_convert { |field| ... }
- # header_convert { |field, field_info| ... }
- #
- # Identical to CSV.convert(), but for header rows.
- #
- # Note that this method must be called before header rows are read to have any
- # effect.
- #
- def header_convert(name = nil, &converter)
- add_converter( :header_converters,
- self.class::HeaderConverters,
- name,
- &converter )
- end
-
- include Enumerable
-
- #
- # Yields each row of the data source in turn.
- #
- # Support for Enumerable.
- #
- # The data source must be open for reading.
- #
- def each
- while row = shift
- yield row
- end
- end
-
- #
- # Slurps the remaining rows and returns an Array of Arrays.
- #
- # The data source must be open for reading.
- #
- def read
- rows = to_a
- if @use_headers
- Table.new(rows)
- else
- rows
- end
- end
- alias_method :readlines, :read
-
- # Returns +true+ if the next row read will be a header row.
- def header_row?
- @use_headers and @headers.nil?
- end
-
- #
- # The primary read method for wrapped Strings and IOs, a single row is pulled
- # from the data source, parsed and returned as an Array of fields (if header
- # rows are not used) or a CSV::Row (when header rows are used).
- #
- # The data source must be open for reading.
- #
- def shift
- #########################################################################
- ### This method is purposefully kept a bit long as simple conditional ###
- ### checks are faster than numerous (expensive) method calls. ###
- #########################################################################
-
- # handle headers not based on document content
- if header_row? and @return_headers and
- [Array, String].include? @use_headers.class
- if @unconverted_fields
- return add_unconverted_fields(parse_headers, Array.new)
- else
- return parse_headers
+ def get_row(row)
+ parsed_cells, next_idx = CSV.parse_row(@dev, @idx, row, @fs, @rs)
+ if parsed_cells == 0 and next_idx == 0 and !@dev.is_eos?
+ raise IllegalFormatError.new
end
+ dropped = @dev.drop(next_idx)
+ @idx = next_idx - dropped
+ parsed_cells
end
-
- # begin with a blank line, so we can always add to it
- line = ""
- #
- # it can take multiple calls to <tt>@io.gets()</tt> to get a full line,
- # because of \r and/or \n characters embedded in quoted fields
- #
- loop do
- # add another read to the line
- line += @io.gets(@row_sep) rescue return nil
- # copy the line so we can chop it up in parsing
- parse = line.dup
- parse.sub!(@parsers[:line_end], "")
-
- #
- # I believe a blank line should be an <tt>Array.new</tt>, not Ruby 1.8
- # CSV's <tt>[nil]</tt>
- #
- if parse.empty?
- @lineno += 1
- if @skip_blanks
- line = ""
- next
- elsif @unconverted_fields
- return add_unconverted_fields(Array.new, Array.new)
- elsif @use_headers
- return self.class::Row.new(Array.new, Array.new)
- else
- return Array.new
- end
+ def terminate
+ if @close_on_terminate
+ @io.close
end
- #
- # shave leading empty fields if needed, because the main parser chokes
- # on these
- #
- csv = if parse.sub!(@parsers[:leading_fields], "")
- [nil] * ($&.length / @col_sep.length)
- else
- Array.new
+ if @dev
+ @dev.close
end
- #
- # then parse the main fields with a hyper-tuned Regexp from
- # Mastering Regular Expressions, Second Edition
- #
- parse.gsub!(@parsers[:csv_row]) do
- csv << if $1.nil? # we found an unquoted field
- if $2.empty? # switch empty unquoted fields to +nil+...
- nil # for Ruby 1.8 CSV compatibility
- else
- # I decided to take a strict approach to CSV parsing...
- if $2.count("\r\n").zero? # verify correctness of field...
- $2
- else
- # or throw an Exception
- raise MalformedCSVError, "Unquoted fields do not allow " +
- "\\r or \\n (line #{lineno + 1})."
- end
- end
- else # we found a quoted field...
- $1.gsub(@quote_char * 2, @quote_char) # unescape contents
- end
- "" # gsub!'s replacement, clear the field
+ end
+ end
+
+
+ # CSV formatted string/stream writer.
+ #
+ # EXAMPLE
+ # Write rows to 'csvout' file.
+ #
+ # outfile = File.open('csvout', 'wb')
+ # CSV::Writer.generate(outfile) do |csv|
+ # csv << ['c1', nil, '', '"', "\r\n", 'c2']
+ # ...
+ # end
+ #
+ # outfile.close
+ #
+ class Writer
+ # Given block is called with the writer instance. str_or_writable must
+ # handle '<<(string)'.
+ def Writer.generate(str_or_writable, fs = ',', rs = nil, &block)
+ writer = Writer.create(str_or_writable, fs, rs)
+ if block
+ yield(writer)
+ writer.close
+ nil
+ else
+ writer
end
+ end
- # if parse is empty?(), we found all the fields on the line...
- if parse.empty?
- @lineno += 1
+ # str_or_writable must handle '<<(string)'.
+ def Writer.create(str_or_writable, fs = ',', rs = nil)
+ BasicWriter.new(str_or_writable, fs, rs)
+ end
- # save fields unconverted fields, if needed...
- unconverted = csv.dup if @unconverted_fields
+ # dump CSV stream to the device. argument must be an Array of String.
+ def <<(row)
+ CSV.generate_row(row, row.size, @dev, @fs, @rs)
+ self
+ end
+ alias add_row <<
- # convert fields, if needed...
- csv = convert_fields(csv) unless @use_headers or @converters.empty?
- # parse out header rows and handle CSV::Row conversions...
- csv = parse_headers(csv) if @use_headers
+ def close
+ terminate
+ end
- # inject unconverted fields and accessor, if requested...
- if @unconverted_fields and not csv.respond_to? :unconverted_fields
- add_unconverted_fields(csv, unconverted)
- end
+ private
- # return the results
- break csv
- end
- # if we're not empty?() but at eof?(), a quoted field wasn't closed...
- if @io.eof?
- raise MalformedCSVError, "Unclosed quoted field on line #{lineno + 1}."
- end
- # otherwise, we need to loop and pull some more data to complete the row
+ def initialize(dev)
+ raise RuntimeError.new('Do not instanciate this class directly.')
+ end
+
+ def terminate
+ # Define if needed.
end
end
- alias_method :gets, :shift
- alias_method :readline, :shift
-
- private
-
- #
- # Stores the indicated separators for later use.
- #
- # If auto-discovery was requested for <tt>@row_sep</tt>, this method will read
- # ahead in the <tt>@io</tt> and try to find one. +ARGF+, +STDIN+, +STDOUT+,
- # +STDERR+ and any stream open for output only with a default
- # <tt>@row_sep</tt> of <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>).
- #
- # This method also establishes the quoting rules used for CSV output.
- #
- def init_separators(options)
- # store the selected separators
- @col_sep = options.delete(:col_sep)
- @row_sep = options.delete(:row_sep)
- @quote_char = options.delete(:quote_char)
- if @quote_char.length != 1
- raise ArgumentError, ":quote_char has to be a single character String"
+
+ class BasicWriter < Writer
+ def initialize(str_or_writable, fs = ',', rs = nil)
+ @fs = fs
+ @rs = rs
+ @dev = str_or_writable
+ @close_on_terminate = false
end
-
- # automatically discover row separator when requested
- if @row_sep == :auto
- if [ARGF, STDIN, STDOUT, STDERR].include?(@io) or
- (defined?(Zlib) and @io.class == Zlib::GzipWriter)
- @row_sep = $INPUT_RECORD_SEPARATOR
- else
- begin
- saved_pos = @io.pos # remember where we were
- while @row_sep == :auto
- #
- # if we run out of data, it's probably a single line
- # (use a sensible default)
- #
- if @io.eof?
- @row_sep = $INPUT_RECORD_SEPARATOR
- break
- end
-
- # read ahead a bit
- sample = @io.read(1024)
- sample += @io.read(1) if sample[-1..-1] == "\r" and not @io.eof?
-
- # try to find a standard separator
- if sample =~ /\r\n?|\n/
- @row_sep = $&
- break
- end
+
+ # Tell this writer to close the IO when terminated (Triggered by invoking
+ # CSV::BasicWriter#close).
+ def close_on_terminate
+ @close_on_terminate = true
+ end
+
+ private
+
+ def terminate
+ if @close_on_terminate
+ @dev.close
+ end
+ end
+ end
+
+private
+
+ # Buffered stream.
+ #
+ # EXAMPLE 1 -- an IO.
+ # class MyBuf < StreamBuf
+ # # Do initialize myself before a super class. Super class might call my
+ # # method 'read'. (Could be awful for C++ user. :-)
+ # def initialize(s)
+ # @s = s
+ # super()
+ # end
+ #
+ # # define my own 'read' method.
+ # # CAUTION: Returning nil means EnfOfStream.
+ # def read(size)
+ # @s.read(size)
+ # end
+ #
+ # # release buffers. in Ruby which has GC, you do not have to call this...
+ # def terminate
+ # @s = nil
+ # super()
+ # end
+ # end
+ #
+ # buf = MyBuf.new(STDIN)
+ # my_str = ''
+ # p buf[0, 0] # => '' (null string)
+ # p buf[0] # => 97 (char code of 'a')
+ # p buf[0, 1] # => 'a'
+ # my_str = buf[0, 5]
+ # p my_str # => 'abcde' (5 chars)
+ # p buf[0, 6] # => "abcde\n" (6 chars)
+ # p buf[0, 7] # => "abcde\n" (6 chars)
+ # p buf.drop(3) # => 3 (dropped chars)
+ # p buf.get(0, 2) # => 'de' (2 chars)
+ # p buf.is_eos? # => false (is not EOS here)
+ # p buf.drop(5) # => 3 (dropped chars)
+ # p buf.is_eos? # => true (is EOS here)
+ # p buf[0] # => nil (is EOS here)
+ #
+ # EXAMPLE 2 -- String.
+ # This is a conceptual example. No pros with this.
+ #
+ # class StrBuf < StreamBuf
+ # def initialize(s)
+ # @str = s
+ # @idx = 0
+ # super()
+ # end
+ #
+ # def read(size)
+ # str = @str[@idx, size]
+ # @idx += str.size
+ # str
+ # end
+ # end
+ #
+ class StreamBuf
+ # get a char or a partial string from the stream.
+ # idx: index of a string to specify a start point of a string to get.
+ # unlike String instance, idx < 0 returns nil.
+ # n: size of a string to get.
+ # returns char at idx if n == nil.
+ # returns a partial string, from idx to (idx + n) if n != nil. at EOF,
+ # the string size could not equal to arg n.
+ def [](idx, n = nil)
+ if idx < 0
+ return nil
+ end
+ if (idx_is_eos?(idx))
+ if n and (@offset + idx == buf_size(@cur_buf))
+ # Like a String, 'abc'[4, 1] returns nil and
+ # 'abc'[3, 1] returns '' not nil.
+ return ''
+ else
+ return nil
+ end
+ end
+ my_buf = @cur_buf
+ my_offset = @offset
+ next_idx = idx
+ while (my_offset + next_idx >= buf_size(my_buf))
+ if (my_buf == @buf_tail_idx)
+ unless add_buf
+ break
end
- # tricky seek() clone to work around GzipReader's lack of seek()
- @io.rewind
- # reset back to the remembered position
- while saved_pos > 1024 # avoid loading a lot of data into memory
- @io.read(1024)
- saved_pos -= 1024
+ end
+ next_idx = my_offset + next_idx - buf_size(my_buf)
+ my_buf += 1
+ my_offset = 0
+ end
+ loc = my_offset + next_idx
+ if !n
+ return @buf_list[my_buf][loc] # Fixnum of char code.
+ elsif (loc + n - 1 < buf_size(my_buf))
+ return @buf_list[my_buf][loc, n] # String.
+ else # should do loop insted of (tail) recursive call...
+ res = @buf_list[my_buf][loc, BufSize]
+ size_added = buf_size(my_buf) - loc
+ if size_added > 0
+ idx += size_added
+ n -= size_added
+ ret = self[idx, n]
+ if ret
+ res << ret
end
- @io.read(saved_pos) if saved_pos.nonzero?
- rescue IOError # stream not opened for reading
- @row_sep = $INPUT_RECORD_SEPARATOR
end
- end
- end
-
- # establish quoting rules
- do_quote = lambda do |field|
- @quote_char +
- String(field).gsub(@quote_char, @quote_char * 2) +
- @quote_char
- end
- @quote = if options.delete(:force_quotes)
- do_quote
- else
- lambda do |field|
- if field.nil? # represent +nil+ fields as empty unquoted fields
- ""
- else
- field = String(field) # Stringify fields
- # represent empty fields as empty quoted fields
- if field.empty? or
- field.count("\r\n#{@col_sep}#{@quote_char}").nonzero?
- do_quote.call(field)
+ return res
+ end
+ end
+ alias get []
+
+ # drop a string from the stream.
+ # returns dropped size. at EOF, dropped size might not equals to arg n.
+ # Once you drop the head of the stream, access to the dropped part via []
+ # or get returns nil.
+ def drop(n)
+ if is_eos?
+ return 0
+ end
+ size_dropped = 0
+ while (n > 0)
+ if !@is_eos or (@cur_buf != @buf_tail_idx)
+ if (@offset + n < buf_size(@cur_buf))
+ size_dropped += n
+ @offset += n
+ n = 0
else
- field # unquoted field
+ size = buf_size(@cur_buf) - @offset
+ size_dropped += size
+ n -= size
+ @offset = 0
+ unless rel_buf
+ unless add_buf
+ break
+ end
+ @cur_buf = @buf_tail_idx
+ end
end
end
end
+ size_dropped
end
- end
- # Pre-compiles parsers and stores them by name for access during reads.
- def init_parsers(options)
- # store the parser behaviors
- @skip_blanks = options.delete(:skip_blanks)
-
- # prebuild Regexps for faster parsing
- esc_col_sep = Regexp.escape(@col_sep)
- esc_row_sep = Regexp.escape(@row_sep)
- esc_quote = Regexp.escape(@quote_char)
- @parsers = {
- :leading_fields =>
- /\A(?:#{esc_col_sep})+/, # for empty leading fields
- :csv_row =>
- ### The Primary Parser ###
- / \G(?:^|#{esc_col_sep}) # anchor the match
- (?: #{esc_quote}( (?>[^#{esc_quote}]*) # find quoted fields
- (?> #{esc_quote*2}
- [^#{esc_quote}]* )* )#{esc_quote}
- | # ... or ...
- ([^#{esc_quote}#{esc_col_sep}]*) # unquoted fields
- )/x,
- ### End Primary Parser ###
- :line_end =>
- /#{esc_row_sep}\z/ # safer than chomp!()
- }
- end
-
- #
- # Loads any converters requested during construction.
- #
- # If +field_name+ is set <tt>:converters</tt> (the default) field converters
- # are set. When +field_name+ is <tt>:header_converters</tt> header converters
- # are added instead.
- #
- # The <tt>:unconverted_fields</tt> option is also actived for
- # <tt>:converters</tt> calls, if requested.
- #
- def init_converters(options, field_name = :converters)
- if field_name == :converters
- @unconverted_fields = options.delete(:unconverted_fields)
+ def is_eos?
+ return idx_is_eos?(0)
end
-
- instance_variable_set("@#{field_name}", Array.new)
-
- # find the correct method to add the coverters
- convert = method(field_name.to_s.sub(/ers\Z/, ""))
-
- # load converters
- unless options[field_name].nil?
- # allow a single converter not wrapped in an Array
- unless options[field_name].is_a? Array
- options[field_name] = [options[field_name]]
- end
- # load each converter...
- options[field_name].each do |converter|
- if converter.is_a? Proc # custom code block
- convert.call(&converter)
- else # by name
- convert.call(converter)
- end
- end
+
+ # WARN: Do not instantiate this class directly. Define your own class
+ # which derives this class and define 'read' instance method.
+ def initialize
+ @buf_list = []
+ @cur_buf = @buf_tail_idx = -1
+ @offset = 0
+ @is_eos = false
+ add_buf
+ @cur_buf = @buf_tail_idx
end
-
- options.delete(field_name)
- end
- # Stores header row settings and loads header converters, if needed.
- def init_headers(options)
- @use_headers = options.delete(:headers)
- @return_headers = options.delete(:return_headers)
+ protected
- # headers must be delayed until shift(), in case they need a row of content
- @headers = nil
-
- init_converters(options, :header_converters)
- end
+ def terminate
+ while (rel_buf); end
+ end
- #
- # The actual work method for adding converters, used by both CSV.convert() and
- # CSV.header_convert().
- #
- # This method requires the +var_name+ of the instance variable to place the
- # converters in, the +const+ Hash to lookup named converters in, and the
- # normal parameters of the CSV.convert() and CSV.header_convert() methods.
- #
- def add_converter(var_name, const, name = nil, &converter)
- if name.nil? # custom converter
- instance_variable_get("@#{var_name}") << converter
- else # named converter
- combo = const[name]
- case combo
- when Array # combo converter
- combo.each do |converter_name|
- add_converter(var_name, const, converter_name)
- end
- else # individual named converter
- instance_variable_get("@#{var_name}") << combo
- end
+ # protected method 'read' must be defined in derived classes.
+ # CAUTION: Returning a string which size is not equal to 'size' means
+ # EnfOfStream. When it is not at EOS, you must block the callee, try to
+ # read and return the sized string.
+ def read(size) # raise EOFError
+ raise NotImplementedError.new('Method read must be defined in a derived class.')
end
- end
- #
- # Processes +fields+ with <tt>@converters</tt>, or <tt>@header_converters</tt>
- # if +headers+ is passed as +true+, returning the converted field set. Any
- # converter that changes the field into something other than a String halts
- # the pipeline of conversion for that field. This is primarily an efficiency
- # shortcut.
- #
- def convert_fields(fields, headers = false)
- # see if we are converting headers or fields
- converters = headers ? @header_converters : @converters
-
- converted = Array.new
- fields.each_with_index do |field, index|
- converters.each do |converter|
- field = if converter.arity == 1 # straight field converter
- converter[field]
- else # FieldInfo converter
- header = @use_headers && !headers ? @headers[index] : nil
- converter[field, FieldInfo.new(index, lineno, header)]
- end
- break unless field.is_a? String # short-curcuit pipeline for speed
+ private
+
+ def buf_size(idx)
+ @buf_list[idx].size
+ end
+
+ def add_buf
+ if @is_eos
+ return false
+ end
+ begin
+ str_read = read(BufSize)
+ rescue EOFError
+ str_read = nil
+ rescue
+ terminate
+ raise
+ end
+ if str_read.nil?
+ @is_eos = true
+ @buf_list.push('')
+ @buf_tail_idx += 1
+ false
+ else
+ @buf_list.push(str_read)
+ @buf_tail_idx += 1
+ true
end
- converted << field # final state of each field, converted or original
end
- converted
- end
- #
- # This methods is used to turn a finished +row+ into a CSV::Row. Header rows
- # are also dealt with here, either by returning a CSV::Row with identical
- # headers and fields (save that the fields do not go through the converters)
- # or by reading past them to return a field row. Headers are also saved in
- # <tt>@headers</tt> for use in future rows.
- #
- # When +nil+, +row+ is assumed to be a header row not based on an actual row
- # of the stream.
- #
- def parse_headers(row = nil)
- if @headers.nil? # header row
- @headers = case @use_headers # save headers
- when Array then @use_headers # Array of headers
- when String then self.class.parse_line(@use_headers) # CSV header String
- else row # first row headers
+ def rel_buf
+ if (@cur_buf < 0)
+ return false
end
-
- # prepare converted and unconverted copies
- row = @headers if row.nil?
- @headers = convert_fields(@headers, true)
-
- if @return_headers # return headers
- return self.class::Row.new(@headers, row, true)
- elsif not [Array, String].include? @use_headers.class # skip to field row
- return shift
+ @buf_list[@cur_buf] = nil
+ if (@cur_buf == @buf_tail_idx)
+ @cur_buf = -1
+ return false
+ else
+ @cur_buf += 1
+ return true
end
end
-
- self.class::Row.new(@headers, convert_fields(row)) # field row
- end
- #
- # Thiw methods injects an instance variable <tt>unconverted_fields</tt> into
- # +row+ and an accessor method for it called unconverted_fields(). The
- # variable is set to the contents of +fields+.
- #
- def add_unconverted_fields(row, fields)
- class << row
- attr_reader :unconverted_fields
+ def idx_is_eos?(idx)
+ (@is_eos and ((@cur_buf < 0) or (@cur_buf == @buf_tail_idx)))
end
- row.instance_eval { @unconverted_fields = fields }
- row
+
+ BufSize = 1024 * 8
end
-end
-# Another name for CSV::instance().
-def CSV(*args, &block)
- CSV.instance(*args, &block)
-end
+ # Buffered IO.
+ #
+ # EXAMPLE
+ # # File 'bigdata' could be a giga-byte size one!
+ # buf = CSV::IOBuf.new(File.open('bigdata', 'rb'))
+ # CSV::Reader.new(buf).each do |row|
+ # p row
+ # break if row[0].data == 'admin'
+ # end
+ #
+ class IOBuf < StreamBuf
+ def initialize(s)
+ @s = s
+ super()
+ end
+
+ def close
+ terminate
+ end
-class Array
- # Equivalent to <tt>CSV::generate_line(self, options)</tt>.
- def to_csv(options = Hash.new)
- CSV.generate_line(self, options)
- end
-end
+ private
-class String
- # Equivalent to <tt>CSV::parse_line(self, options)</tt>.
- def parse_csv(options = Hash.new)
- CSV.parse_line(self, options)
+ def read(size)
+ @s.read(size)
+ end
+
+ def terminate
+ super()
+ end
end
end
diff --git a/lib/date.rb b/lib/date.rb
index d2359bf3ba..90a4a01ca3 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1,12 +1,12 @@
#
# date.rb - date and time library
#
-# Author: Tadayoshi Funaba 1998-2007
+# Author: Tadayoshi Funaba 1998-2008
#
# Documentation: William Webber <william@williamwebber.com>
#
#--
-# $Id: date.rb,v 2.33 2007-12-22 14:41:34+09 tadf Exp $
+# $Id: date.rb,v 2.37 2008-01-17 20:16:31+09 tadf Exp $
#++
#
# == Overview
@@ -275,8 +275,8 @@ class Date
def <=> (other)
case other
- when Infinity; d <=> other.d
- when Numeric; d
+ when Infinity; return d <=> other.d
+ when Numeric; return d
else
begin
l, r = other.coerce(self)
@@ -313,382 +313,250 @@ class Date
# Gregorian calendar.
GREGORIAN = -Infinity.new
- UNIXEPOCH = 2440588 # 1970-01-01 :nodoc:
+ HALF_DAYS_IN_DAY = Rational(1, 2) # :nodoc:
+ HOURS_IN_DAY = Rational(1, 24) # :nodoc:
+ MINUTES_IN_DAY = Rational(1, 1440) # :nodoc:
+ SECONDS_IN_DAY = Rational(1, 86400) # :nodoc:
+ MILLISECONDS_IN_DAY = Rational(1, 86400*10**3) # :nodoc:
+ NANOSECONDS_IN_DAY = Rational(1, 86400*10**9) # :nodoc:
+ MILLISECONDS_IN_SECOND = Rational(1, 10**3) # :nodoc:
+ NANOSECONDS_IN_SECOND = Rational(1, 10**9) # :nodoc:
+
+ MJD_EPOCH_IN_AJD = Rational(4800001, 2) # 1858-11-17 # :nodoc:
+ UNIX_EPOCH_IN_AJD = Rational(4881175, 2) # 1970-01-01 # :nodoc:
+ MJD_EPOCH_IN_CJD = 2400001 # :nodoc:
+ UNIX_EPOCH_IN_CJD = 2440588 # :nodoc:
+ LD_EPOCH_IN_CJD = 2299160 # :nodoc:
+
+ # Does a given Julian Day Number fall inside the old-style (Julian)
+ # calendar?
+ #
+ # +jd+ is the Julian Day Number in question. +sg+ may be Date::GREGORIAN,
+ # in which case the answer is false; it may be Date::JULIAN, in which case
+ # the answer is true; or it may a number representing the Day of
+ # Calendar Reform. Date::ENGLAND and Date::ITALY are two possible such
+ # days.
+
+ def self.julian? (jd, sg)
+ case sg
+ when Numeric
+ jd < sg
+ else
+ if $VERBOSE
+ warn("#{caller.shift.sub(/:in .*/, '')}: " \
+"warning: do not use non-numerical object as julian day number anymore")
+ end
+ not sg
+ end
+ end
- t = Module.new do
+ # Does a given Julian Day Number fall inside the new-style (Gregorian)
+ # calendar?
+ #
+ # The reverse of self.os? See the documentation for that method for
+ # more details.
+ def self.gregorian? (jd, sg) !julian?(jd, sg) end
+
+ def self.fix_style(jd, sg) # :nodoc:
+ if julian?(jd, sg)
+ then JULIAN
+ else GREGORIAN end
+ end
- private
+ private_class_method :fix_style
- def find_fdoy(y, sg) # :nodoc:
- j = nil
- 1.upto(31) do |d|
- break if j = _valid_civil?(y, 1, d, sg)
- end
- j
- end
+ # Convert an Ordinal Date to a Julian Day Number.
+ #
+ # +y+ and +d+ are the year and day-of-year to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Julian Day Number.
+ def self.ordinal_to_jd(y, d, sg=GREGORIAN)
+ civil_to_jd(y, 1, d, sg)
+ end
- def find_ldoy(y, sg) # :nodoc:
- j = nil
- 31.downto(1) do |d|
- break if j = _valid_civil?(y, 12, d, sg)
- end
- j
- end
+ # Convert a Julian Day Number to an Ordinal Date.
+ #
+ # +jd+ is the Julian Day Number to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Ordinal Date as
+ # [year, day_of_year]
+ def self.jd_to_ordinal(jd, sg=GREGORIAN)
+ y = jd_to_civil(jd, sg)[0]
+ doy = jd - civil_to_jd(y - 1, 12, 31, fix_style(jd, sg))
+ return y, doy
+ end
- def find_fdom(y, m, sg) # :nodoc:
- j = nil
- 1.upto(31) do |d|
- break if j = _valid_civil?(y, m, d, sg)
- end
- j
+ # Convert a Civil Date to a Julian Day Number.
+ # +y+, +m+, and +d+ are the year, month, and day of the
+ # month. +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Julian Day Number.
+ def self.civil_to_jd(y, m, d, sg=GREGORIAN)
+ if m <= 2
+ y -= 1
+ m += 12
end
-
- def find_ldom(y, m, sg) # :nodoc:
- j = nil
- 31.downto(1) do |d|
- break if j = _valid_civil?(y, m, d, sg)
- end
- j
+ a = (y / 100.0).floor
+ b = 2 - a + (a / 4.0).floor
+ jd = (365.25 * (y + 4716)).floor +
+ (30.6001 * (m + 1)).floor +
+ d + b - 1524
+ if julian?(jd, sg)
+ jd -= b
end
+ jd
+ end
- # Convert an Ordinal Date to a Julian Day Number.
- #
- # +y+ and +d+ are the year and day-of-year to convert.
- # +sg+ specifies the Day of Calendar Reform.
- #
- # Returns the corresponding Julian Day Number.
- def ordinal_to_jd(y, d, sg=GREGORIAN) # :nodoc:
- find_fdoy(y, sg) + d - 1
+ # Convert a Julian Day Number to a Civil Date. +jd+ is
+ # the Julian Day Number. +sg+ specifies the Day of
+ # Calendar Reform.
+ #
+ # Returns the corresponding [year, month, day_of_month]
+ # as a three-element array.
+ def self.jd_to_civil(jd, sg=GREGORIAN)
+ if julian?(jd, sg)
+ a = jd
+ else
+ x = ((jd - 1867216.25) / 36524.25).floor
+ a = jd + 1 + x - (x / 4.0).floor
end
-
- # Convert a Julian Day Number to an Ordinal Date.
- #
- # +jd+ is the Julian Day Number to convert.
- # +sg+ specifies the Day of Calendar Reform.
- #
- # Returns the corresponding Ordinal Date as
- # [year, day_of_year]
- def jd_to_ordinal(jd, sg=GREGORIAN) # :nodoc:
- y = jd_to_civil(jd, sg)[0]
- j = find_fdoy(y, sg)
- doy = jd - j + 1
- return y, doy
+ b = a + 1524
+ c = ((b - 122.1) / 365.25).floor
+ d = (365.25 * c).floor
+ e = ((b - d) / 30.6001).floor
+ dom = b - d - (30.6001 * e).floor
+ if e <= 13
+ m = e - 1
+ y = c - 4716
+ else
+ m = e - 13
+ y = c - 4715
end
+ return y, m, dom
+ end
- # Convert a Civil Date to a Julian Day Number.
- # +y+, +m+, and +d+ are the year, month, and day of the
- # month. +sg+ specifies the Day of Calendar Reform.
- #
- # Returns the corresponding Julian Day Number.
- def civil_to_jd(y, m, d, sg=GREGORIAN) # :nodoc:
- if m <= 2
- y -= 1
- m += 12
- end
- a = (y / 100.0).floor
- b = 2 - a + (a / 4.0).floor
- jd = (365.25 * (y + 4716)).floor +
- (30.6001 * (m + 1)).floor +
- d + b - 1524
- if jd < sg
- jd -= b
- end
- jd
- end
+ # Convert a Commercial Date to a Julian Day Number.
+ #
+ # +y+, +w+, and +d+ are the (commercial) year, week of the year,
+ # and day of the week of the Commercial Date to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.commercial_to_jd(y, w, d, ns=GREGORIAN)
+ jd = civil_to_jd(y, 1, 4, ns)
+ (jd - (((jd - 1) + 1) % 7)) +
+ 7 * (w - 1) +
+ (d - 1)
+ end
- # Convert a Julian Day Number to a Civil Date. +jd+ is
- # the Julian Day Number. +sg+ specifies the Day of
- # Calendar Reform.
- #
- # Returns the corresponding [year, month, day_of_month]
- # as a three-element array.
- def jd_to_civil(jd, sg=GREGORIAN) # :nodoc:
- if jd < sg
- a = jd
- else
- x = ((jd - 1867216.25) / 36524.25).floor
- a = jd + 1 + x - (x / 4.0).floor
- end
- b = a + 1524
- c = ((b - 122.1) / 365.25).floor
- d = (365.25 * c).floor
- e = ((b - d) / 30.6001).floor
- dom = b - d - (30.6001 * e).floor
- if e <= 13
- m = e - 1
- y = c - 4716
- else
- m = e - 13
- y = c - 4715
- end
- return y, m, dom
- end
+ # Convert a Julian Day Number to a Commercial Date
+ #
+ # +jd+ is the Julian Day Number to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Commercial Date as
+ # [commercial_year, week_of_year, day_of_week]
+ def self.jd_to_commercial(jd, sg=GREGORIAN)
+ ns = fix_style(jd, sg)
+ a = jd_to_civil(jd - 3, ns)[0]
+ y = if jd >= commercial_to_jd(a + 1, 1, 1, ns) then a + 1 else a end
+ w = 1 + ((jd - commercial_to_jd(y, 1, 1, ns)) / 7).floor
+ d = (jd + 1) % 7
+ d = 7 if d == 0
+ return y, w, d
+ end
- # Convert a Commercial Date to a Julian Day Number.
- #
- # +y+, +w+, and +d+ are the (commercial) year, week of the year,
- # and day of the week of the Commercial Date to convert.
- # +sg+ specifies the Day of Calendar Reform.
- def commercial_to_jd(y, w, d, sg=GREGORIAN) # :nodoc:
- j = find_fdoy(y, sg) + 3
- (j - (((j - 1) + 1) % 7)) +
- 7 * (w - 1) +
- (d - 1)
- end
+ def self.weeknum_to_jd(y, w, d, f=0, ns=GREGORIAN) # :nodoc:
+ a = civil_to_jd(y, 1, 1, ns) + 6
+ (a - ((a - f) + 1) % 7 - 7) + 7 * w + d
+ end
- # Convert a Julian Day Number to a Commercial Date
- #
- # +jd+ is the Julian Day Number to convert.
- # +sg+ specifies the Day of Calendar Reform.
- #
- # Returns the corresponding Commercial Date as
- # [commercial_year, week_of_year, day_of_week]
- def jd_to_commercial(jd, sg=GREGORIAN) # :nodoc:
- a = jd_to_civil(jd - 3, sg)[0]
- y = if jd >= commercial_to_jd(a + 1, 1, 1, sg) then a + 1 else a end
- w = 1 + ((jd - commercial_to_jd(y, 1, 1, sg)) / 7).floor
- d = (jd + 1) % 7
- d = 7 if d == 0
- return y, w, d
- end
+ def self.jd_to_weeknum(jd, f=0, sg=GREGORIAN) # :nodoc:
+ ns = fix_style(jd, sg)
+ y, m, d = jd_to_civil(jd, ns)
+ a = civil_to_jd(y, 1, 1, ns) + 6
+ w, d = (jd - (a - ((a - f) + 1) % 7) + 7).divmod(7)
+ return y, w, d
+ end
- def weeknum_to_jd(y, w, d, f=0, sg=GREGORIAN) # :nodoc:
- a = find_fdoy(y, sg) + 6
- (a - ((a - f) + 1) % 7 - 7) + 7 * w + d
- end
+ private_class_method :weeknum_to_jd, :jd_to_weeknum
- def jd_to_weeknum(jd, f=0, sg=GREGORIAN) # :nodoc:
- y, m, d = jd_to_civil(jd, sg)
- a = find_fdoy(y, sg) + 6
- w, d = (jd - (a - ((a - f) + 1) % 7) + 7).divmod(7)
- return y, w, d
- end
+ # Convert an Astronomical Julian Day Number to a (civil) Julian
+ # Day Number.
+ #
+ # +ajd+ is the Astronomical Julian Day Number to convert.
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ #
+ # Returns the (civil) Julian Day Number as [day_number,
+ # fraction] where +fraction+ is always 1/2.
+ def self.ajd_to_jd(ajd, of=0) (ajd + of + HALF_DAYS_IN_DAY).divmod(1) end
- def nth_kday_to_jd(y, m, n, k, sg=GREGORIAN) # :nodoc:
- j = if n > 0
- find_fdom(y, m, sg) - 1
- else
- find_ldom(y, m, sg) + 7
- end
- (j - (((j - k) + 1) % 7)) + 7 * n
- end
+ # Convert a (civil) Julian Day Number to an Astronomical Julian
+ # Day Number.
+ #
+ # +jd+ is the Julian Day Number to convert, and +fr+ is a
+ # fractional day.
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ #
+ # Returns the Astronomical Julian Day Number as a single
+ # numeric value.
+ def self.jd_to_ajd(jd, fr, of=0) jd + fr - of - HALF_DAYS_IN_DAY end
- def jd_to_nth_kday(jd, sg=GREGORIAN) # :nodoc:
- y, m, d = jd_to_civil(jd, sg)
- j = find_fdom(y, m, sg)
- return y, m, ((jd - j) / 7).floor + 1, jd_to_wday(jd)
- end
+ # Convert a fractional day +fr+ to [hours, minutes, seconds,
+ # fraction_of_a_second]
+ def self.day_fraction_to_time(fr)
+ ss, fr = fr.divmod(SECONDS_IN_DAY) # 4p
+ h, ss = ss.divmod(3600)
+ min, s = ss.divmod(60)
+ return h, min, s, fr
+ end
- # Convert an Astronomical Julian Day Number to a (civil) Julian
- # Day Number.
- #
- # +ajd+ is the Astronomical Julian Day Number to convert.
- # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
- #
- # Returns the (civil) Julian Day Number as [day_number,
- # fraction] where +fraction+ is always 1/2.
- def ajd_to_jd(ajd, of=0) (ajd + of + 1.to_r/2).divmod(1) end # :nodoc:
-
- # Convert a (civil) Julian Day Number to an Astronomical Julian
- # Day Number.
- #
- # +jd+ is the Julian Day Number to convert, and +fr+ is a
- # fractional day.
- # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
- #
- # Returns the Astronomical Julian Day Number as a single
- # numeric value.
- def jd_to_ajd(jd, fr, of=0) jd + fr - of - 1.to_r/2 end # :nodoc:
-
- # Convert a fractional day +fr+ to [hours, minutes, seconds,
- # fraction_of_a_second]
- def day_fraction_to_time(fr) # :nodoc:
- h, fr = fr.divmod(1.to_r/24)
- min, fr = fr.divmod(1.to_r/1440)
- s, fr = fr.divmod(1.to_r/86400)
- return h, min, s, fr * 86400
- end
+ # Convert an +h+ hour, +min+ minutes, +s+ seconds period
+ # to a fractional day.
+ begin
+ Rational(Rational(1, 2), 2) # a challenge
- # Convert an +h+ hour, +min+ minutes, +s+ seconds period
- # to a fractional day.
- def time_to_day_fraction(h, min, s) # :nodoc:
- h.to_r/24 + min.to_r/1440 + s.to_r/86400
+ def self.time_to_day_fraction(h, min, s)
+ Rational(h * 3600 + min * 60 + s, 86400) # 4p
end
-
- # Convert an Astronomical Modified Julian Day Number to an
- # Astronomical Julian Day Number.
- def amjd_to_ajd(amjd) amjd + 4800001.to_r/2 end # :nodoc:
-
- # Convert an Astronomical Julian Day Number to an
- # Astronomical Modified Julian Day Number.
- def ajd_to_amjd(ajd) ajd - 4800001.to_r/2 end # :nodoc:
-
- # Convert a Modified Julian Day Number to a Julian
- # Day Number.
- def mjd_to_jd(mjd) mjd + 2400001 end # :nodoc:
-
- # Convert a Julian Day Number to a Modified Julian Day
- # Number.
- def jd_to_mjd(jd) jd - 2400001 end # :nodoc:
-
- # Convert a count of the number of days since the adoption
- # of the Gregorian Calendar (in Italy) to a Julian Day Number.
- def ld_to_jd(ld) ld + 2299160 end # :nodoc:
-
- # Convert a Julian Day Number to the number of days since
- # the adoption of the Gregorian Calendar (in Italy).
- def jd_to_ld(jd) jd - 2299160 end # :nodoc:
-
- # Convert a Julian Day Number to the day of the week.
- #
- # Sunday is day-of-week 0; Saturday is day-of-week 6.
- def jd_to_wday(jd) (jd + 1) % 7 end # :nodoc:
-
- # Is +jd+ a valid Julian Day Number?
- #
- # If it is, returns it. In fact, any value is treated as a valid
- # Julian Day Number.
- def _valid_jd? (jd, sg=GREGORIAN) jd end # :nodoc:
-
- # Do the year +y+ and day-of-year +d+ make a valid Ordinal Date?
- # Returns the corresponding Julian Day Number if they do, or
- # nil if they don't.
- #
- # +d+ can be a negative number, in which case it counts backwards
- # from the end of the year (-1 being the last day of the year).
- # No year wraparound is performed, however, so valid values of
- # +d+ are -365 .. -1, 1 .. 365 on a non-leap-year,
- # -366 .. -1, 1 .. 366 on a leap year.
- # A date falling in the period skipped in the Day of Calendar Reform
- # adjustment is not valid.
- #
- # +sg+ specifies the Day of Calendar Reform.
- def _valid_ordinal? (y, d, sg=GREGORIAN) # :nodoc:
- if d < 0
- j = find_ldoy(y, sg)
- ny, nd = jd_to_ordinal(j + d + 1, sg)
- return unless ny == y
- d = nd
- end
- jd = ordinal_to_jd(y, d, sg)
- return unless [y, d] == jd_to_ordinal(jd, sg)
- jd
+ rescue
+ def self.time_to_day_fraction(h, min, s)
+ if Integer === h && Integer === min && Integer === s
+ Rational(h * 3600 + min * 60 + s, 86400) # 4p
+ else
+ (h * 3600 + min * 60 + s).to_r/86400 # 4p
+ end
end
+ end
- # Do year +y+, month +m+, and day-of-month +d+ make a
- # valid Civil Date? Returns the corresponding Julian
- # Day Number if they do, nil if they don't.
- #
- # +m+ and +d+ can be negative, in which case they count
- # backwards from the end of the year and the end of the
- # month respectively. No wraparound is performed, however,
- # and invalid values cause an ArgumentError to be raised.
- # A date falling in the period skipped in the Day of Calendar
- # Reform adjustment is not valid.
- #
- # +sg+ specifies the Day of Calendar Reform.
- def _valid_civil? (y, m, d, sg=GREGORIAN) # :nodoc:
- if m < 0
- m += 13
- end
- if d < 0
- j = find_ldom(y, m, sg)
- ny, nm, nd = jd_to_civil(j + d + 1, sg)
- return unless [ny, nm] == [y, m]
- d = nd
- end
- jd = civil_to_jd(y, m, d, sg)
- return unless [y, m, d] == jd_to_civil(jd, sg)
- jd
- end
+ # Convert an Astronomical Modified Julian Day Number to an
+ # Astronomical Julian Day Number.
+ def self.amjd_to_ajd(amjd) amjd + MJD_EPOCH_IN_AJD end
- # Do year +y+, week-of-year +w+, and day-of-week +d+ make a
- # valid Commercial Date? Returns the corresponding Julian
- # Day Number if they do, nil if they don't.
- #
- # Monday is day-of-week 1; Sunday is day-of-week 7.
- #
- # +w+ and +d+ can be negative, in which case they count
- # backwards from the end of the year and the end of the
- # week respectively. No wraparound is performed, however,
- # and invalid values cause an ArgumentError to be raised.
- # A date falling in the period skipped in the Day of Calendar
- # Reform adjustment is not valid.
- #
- # +sg+ specifies the Day of Calendar Reform.
- def _valid_commercial? (y, w, d, sg=GREGORIAN) # :nodoc:
- if d < 0
- d += 8
- end
- if w < 0
- ny, nw, nd =
- jd_to_commercial(commercial_to_jd(y + 1, 1, 1, sg) + w * 7, sg)
- return unless ny == y
- w = nw
- end
- jd = commercial_to_jd(y, w, d, sg)
- return unless [y, w, d] == jd_to_commercial(jd, sg)
- jd
- end
+ # Convert an Astronomical Julian Day Number to an
+ # Astronomical Modified Julian Day Number.
+ def self.ajd_to_amjd(ajd) ajd - MJD_EPOCH_IN_AJD end
- def _valid_weeknum? (y, w, d, f, sg=GREGORIAN) # :nodoc:
- if d < 0
- d += 7
- end
- if w < 0
- ny, nw, nd, nf =
- jd_to_weeknum(weeknum_to_jd(y + 1, 1, f, f, sg) + w * 7, f, sg)
- return unless ny == y
- w = nw
- end
- jd = weeknum_to_jd(y, w, d, f, sg)
- return unless [y, w, d] == jd_to_weeknum(jd, f, sg)
- jd
- end
+ # Convert a Modified Julian Day Number to a Julian
+ # Day Number.
+ def self.mjd_to_jd(mjd) mjd + MJD_EPOCH_IN_CJD end
- def _valid_nth_kday? (y, m, n, k, sg=GREGORIAN) # :nodoc:
- if k < 0
- k += 7
- end
- if n < 0
- ny, nm = (y * 12 + m).divmod(12)
- nm, = (nm + 1) .divmod(1)
- ny, nm, nn, nk =
- jd_to_nth_kday(nth_kday_to_jd(ny, nm, 1, k, sg) + n * 7, sg)
- return unless [ny, nm] == [y, m]
- n = nn
- end
- jd = nth_kday_to_jd(y, m, n, k, sg)
- return unless [y, m, n, k] == jd_to_nth_kday(jd, sg)
- jd
- end
+ # Convert a Julian Day Number to a Modified Julian Day
+ # Number.
+ def self.jd_to_mjd(jd) jd - MJD_EPOCH_IN_CJD end
- # Do hour +h+, minute +min+, and second +s+ constitute a valid time?
- #
- # If they do, returns their value as a fraction of a day. If not,
- # returns nil.
- #
- # The 24-hour clock is used. Negative values of +h+, +min+, and
- # +sec+ are treating as counting backwards from the end of the
- # next larger unit (e.g. a +min+ of -2 is treated as 58). No
- # wraparound is performed.
- def _valid_time? (h, min, s) # :nodoc:
- h += 24 if h < 0
- min += 60 if min < 0
- s += 60 if s < 0
- return unless ((0..23) === h &&
- (0..59) === min &&
- (0..59) === s) ||
- (24 == h &&
- 0 == min &&
- 0 == s)
- time_to_day_fraction(h, min, s)
- end
+ # Convert a count of the number of days since the adoption
+ # of the Gregorian Calendar (in Italy) to a Julian Day Number.
+ def self.ld_to_jd(ld) ld + LD_EPOCH_IN_CJD end
- end
+ # Convert a Julian Day Number to the number of days since
+ # the adoption of the Gregorian Calendar (in Italy).
+ def self.jd_to_ld(jd) jd - LD_EPOCH_IN_CJD end
- extend t
- include t
+ # Convert a Julian Day Number to the day of the week.
+ #
+ # Sunday is day-of-week 0; Saturday is day-of-week 6.
+ def self.jd_to_wday(jd) (jd + 1) % 7 end
# Is a year a leap year in the Julian calendar?
#
@@ -704,49 +572,148 @@ class Date
class << self; alias_method :leap?, :gregorian_leap? end
class << self; alias_method :new!, :new end
- def self.valid_jd? (jd, sg=ITALY)
- !!_valid_jd?(jd, sg)
- end
+ # Is +jd+ a valid Julian Day Number?
+ #
+ # If it is, returns it. In fact, any value is treated as a valid
+ # Julian Day Number.
+ def self.valid_jd? (jd, sg=ITALY) jd end
+ # Do the year +y+ and day-of-year +d+ make a valid Ordinal Date?
+ # Returns the corresponding Julian Day Number if they do, or
+ # nil if they don't.
+ #
+ # +d+ can be a negative number, in which case it counts backwards
+ # from the end of the year (-1 being the last day of the year).
+ # No year wraparound is performed, however, so valid values of
+ # +d+ are -365 .. -1, 1 .. 365 on a non-leap-year,
+ # -366 .. -1, 1 .. 366 on a leap year.
+ # A date falling in the period skipped in the Day of Calendar Reform
+ # adjustment is not valid.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
def self.valid_ordinal? (y, d, sg=ITALY)
- !!_valid_ordinal?(y, d, sg)
+ if d < 0
+ ny, = (y + 1).divmod(1)
+ jd = ordinal_to_jd(ny, d + 1, sg)
+ ns = fix_style(jd, sg)
+ return unless [y] == jd_to_ordinal(jd, sg)[0..0]
+ return unless [ny, 1] == jd_to_ordinal(jd - d, ns)
+ else
+ jd = ordinal_to_jd(y, d, sg)
+ return unless [y, d] == jd_to_ordinal(jd, sg)
+ end
+ jd
end
+ # Do year +y+, month +m+, and day-of-month +d+ make a
+ # valid Civil Date? Returns the corresponding Julian
+ # Day Number if they do, nil if they don't.
+ #
+ # +m+ and +d+ can be negative, in which case they count
+ # backwards from the end of the year and the end of the
+ # month respectively. No wraparound is performed, however,
+ # and invalid values cause an ArgumentError to be raised.
+ # A date falling in the period skipped in the Day of Calendar
+ # Reform adjustment is not valid.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
def self.valid_civil? (y, m, d, sg=ITALY)
- !!_valid_civil?(y, m, d, sg)
+ if m < 0
+ m += 13
+ end
+ if d < 0
+ ny, nm = (y * 12 + m).divmod(12)
+ nm, = (nm + 1).divmod(1)
+ jd = civil_to_jd(ny, nm, d + 1, sg)
+ ns = fix_style(jd, sg)
+ return unless [y, m] == jd_to_civil(jd, sg)[0..1]
+ return unless [ny, nm, 1] == jd_to_civil(jd - d, ns)
+ else
+ jd = civil_to_jd(y, m, d, sg)
+ return unless [y, m, d] == jd_to_civil(jd, sg)
+ end
+ jd
end
class << self; alias_method :valid_date?, :valid_civil? end
+ # Do year +y+, week-of-year +w+, and day-of-week +d+ make a
+ # valid Commercial Date? Returns the corresponding Julian
+ # Day Number if they do, nil if they don't.
+ #
+ # Monday is day-of-week 1; Sunday is day-of-week 7.
+ #
+ # +w+ and +d+ can be negative, in which case they count
+ # backwards from the end of the year and the end of the
+ # week respectively. No wraparound is performed, however,
+ # and invalid values cause an ArgumentError to be raised.
+ # A date falling in the period skipped in the Day of Calendar
+ # Reform adjustment is not valid.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
def self.valid_commercial? (y, w, d, sg=ITALY)
- !!_valid_commercial?(y, w, d, sg)
+ if d < 0
+ d += 8
+ end
+ if w < 0
+ ny, nw, nd =
+ jd_to_commercial(commercial_to_jd(y + 1, 1, 1) + w * 7)
+ return unless ny == y
+ w = nw
+ end
+ jd = commercial_to_jd(y, w, d)
+ return unless gregorian?(jd, sg)
+ return unless [y, w, d] == jd_to_commercial(jd)
+ jd
end
def self.valid_weeknum? (y, w, d, f, sg=ITALY) # :nodoc:
- !!_valid_weeknum?(y, w, d, f, sg)
+ if d < 0
+ d += 7
+ end
+ if w < 0
+ ny, nw, nd, nf =
+ jd_to_weeknum(weeknum_to_jd(y + 1, 1, f, f) + w * 7, f)
+ return unless ny == y
+ w = nw
+ end
+ jd = weeknum_to_jd(y, w, d, f)
+ return unless gregorian?(jd, sg)
+ return unless [y, w, d] == jd_to_weeknum(jd, f)
+ jd
end
private_class_method :valid_weeknum?
- def self.valid_nth_kday? (y, m, n, k, sg=ITALY) # :nodoc:
- !!_valid_nth_kday?(y, m, n, k, sg)
- end
-
- private_class_method :valid_nth_kday?
-
- def self.valid_time? (h, min, s) # :nodoc:
- !!_valid_time?(h, min, s)
+ # Do hour +h+, minute +min+, and second +s+ constitute a valid time?
+ #
+ # If they do, returns their value as a fraction of a day. If not,
+ # returns nil.
+ #
+ # The 24-hour clock is used. Negative values of +h+, +min+, and
+ # +sec+ are treating as counting backwards from the end of the
+ # next larger unit (e.g. a +min+ of -2 is treated as 58). No
+ # wraparound is performed.
+ def self.valid_time? (h, min, s)
+ h += 24 if h < 0
+ min += 60 if min < 0
+ s += 60 if s < 0
+ return unless ((0...24) === h &&
+ (0...60) === min &&
+ (0...60) === s) ||
+ (24 == h &&
+ 0 == min &&
+ 0 == s)
+ time_to_day_fraction(h, min, s)
end
- private_class_method :valid_time?
-
# Create a new Date object from a Julian Day Number.
#
# +jd+ is the Julian Day Number; if not specified, it defaults to
# 0.
# +sg+ specifies the Day of Calendar Reform.
def self.jd(jd=0, sg=ITALY)
- jd = _valid_jd?(jd, sg)
+ jd = valid_jd?(jd, sg)
new!(jd_to_ajd(jd, 0, 0), 0, sg)
end
@@ -761,7 +728,7 @@ class Date
#
# +sg+ specifies the Day of Calendar Reform.
def self.ordinal(y=-4712, d=1, sg=ITALY)
- unless jd = _valid_ordinal?(y, d, sg)
+ unless jd = valid_ordinal?(y, d, sg)
raise ArgumentError, 'invalid date'
end
new!(jd_to_ajd(jd, 0, 0), 0, sg)
@@ -781,7 +748,7 @@ class Date
#
# +sg+ specifies the Day of Calendar Reform.
def self.civil(y=-4712, m=1, d=1, sg=ITALY)
- unless jd = _valid_civil?(y, m, d, sg)
+ unless jd = valid_civil?(y, m, d, sg)
raise ArgumentError, 'invalid date'
end
new!(jd_to_ajd(jd, 0, 0), 0, sg)
@@ -799,19 +766,19 @@ class Date
# week respectively. No wraparound is performed, however,
# and invalid values cause an ArgumentError to be raised.
#
- # +y+ defaults to -4712, +w+ to 1, and +d+ to 1; this is
- # Julian Day Number day 0.
+ # +y+ defaults to 1582, +w+ to 41, and +d+ to 5, the Day of
+ # Calendar Reform for Italy and the Catholic countries.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.commercial(y=-4712, w=1, d=1, sg=ITALY)
- unless jd = _valid_commercial?(y, w, d, sg)
+ def self.commercial(y=1582, w=41, d=5, sg=ITALY)
+ unless jd = valid_commercial?(y, w, d, sg)
raise ArgumentError, 'invalid date'
end
new!(jd_to_ajd(jd, 0, 0), 0, sg)
end
- def self.weeknum(y=-4712, w=0, d=1, f=0, sg=ITALY)
- unless jd = _valid_weeknum?(y, w, d, f, sg)
+ def self.weeknum(y=1582, w=41, d=5, f=0, sg=ITALY) # :nodoc:
+ unless jd = valid_weeknum?(y, w, d, f, sg)
raise ArgumentError, 'invalid date'
end
new!(jd_to_ajd(jd, 0, 0), 0, sg)
@@ -819,15 +786,6 @@ class Date
private_class_method :weeknum
- def self.nth_kday(y=-4712, m=1, n=1, k=1, sg=ITALY)
- unless jd = _valid_nth_kday?(y, m, n, k, sg)
- raise ArgumentError, 'invalid date'
- end
- new!(jd_to_ajd(jd, 0, 0), 0, sg)
- end
-
- private_class_method :nth_kday
-
def self.rewrite_frags(elem) # :nodoc:
elem ||= {}
if seconds = elem[:seconds]
@@ -835,7 +793,7 @@ class Date
h, fr = fr.divmod(3600)
min, fr = fr.divmod(60)
s, fr = fr.divmod(1)
- elem[:jd] = UNIXEPOCH + d
+ elem[:jd] = UNIX_EPOCH_IN_CJD + d
elem[:hour] = h
elem[:min] = min
elem[:sec] = s
@@ -928,21 +886,21 @@ class Date
catch :jd do
a = elem.values_at(:jd)
if a.all?
- if jd = _valid_jd?(*(a << sg))
+ if jd = valid_jd?(*(a << sg))
throw :jd, jd
end
end
a = elem.values_at(:year, :yday)
if a.all?
- if jd = _valid_ordinal?(*(a << sg))
+ if jd = valid_ordinal?(*(a << sg))
throw :jd, jd
end
end
a = elem.values_at(:year, :mon, :mday)
if a.all?
- if jd = _valid_civil?(*(a << sg))
+ if jd = valid_civil?(*(a << sg))
throw :jd, jd
end
end
@@ -952,7 +910,7 @@ class Date
a[2] = elem[:wday].nonzero? || 7
end
if a.all?
- if jd = _valid_commercial?(*(a << sg))
+ if jd = valid_commercial?(*(a << sg))
throw :jd, jd
end
end
@@ -962,7 +920,7 @@ class Date
a[2] = elem[:cwday] % 7
end
if a.all?
- if jd = _valid_weeknum?(*(a << 0 << sg))
+ if jd = valid_weeknum?(*(a << 0 << sg))
throw :jd, jd
end
end
@@ -975,7 +933,7 @@ class Date
a[2] = (elem[:cwday] - 1) % 7
end
if a.all?
- if jd = _valid_weeknum?(*(a << 1 << sg))
+ if jd = valid_weeknum?(*(a << 1 << sg))
throw :jd, jd
end
end
@@ -986,7 +944,7 @@ class Date
def self.valid_time_frags? (elem) # :nodoc:
h, min, s = elem.values_at(:hour, :min, :sec)
- _valid_time?(h, min, s)
+ valid_time?(h, min, s)
end
private_class_method :valid_time_frags?
@@ -1037,40 +995,8 @@ class Date
# Day Number day 0.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.parse(str='-4712-01-01', hints={}, sg=ITALY)
- elem = _parse(str, hints)
- new_by_frags(elem, sg)
- end
-
- def self.iso8601(str='-4712-01-01', sg=ITALY) # :nodoc:
- elem = _iso8601(str)
- new_by_frags(elem, sg)
- end
-
- def self.rfc3339(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
- elem = _rfc3339(str)
- new_by_frags(elem, sg)
- end
-
- def self.xmlschema(str='-4712-01-01', sg=ITALY) # :nodoc:
- elem = _xmlschema(str)
- new_by_frags(elem, sg)
- end
-
- def self.rfc2822(str='Mon, 1 Jan -4712 00:00:00 +0000', sg=ITALY) # :nodoc:
- elem = _rfc2822(str)
- new_by_frags(elem, sg)
- end
-
- class << self; alias_method :rfc822, :rfc2822 end
-
- def self.httpdate(str='Mon, 01 Jan -4712 00:00:00 GMT', sg=ITALY) # :nodoc:
- elem = _httpdate(str)
- new_by_frags(elem, sg)
- end
-
- def self.jisx0301(str='-4712-01-01', sg=ITALY) # :nodoc:
- elem = _jisx0301(str)
+ def self.parse(str='-4712-01-01', comp=false, sg=ITALY)
+ elem = _parse(str, comp)
new_by_frags(elem, sg)
end
@@ -1117,36 +1043,36 @@ class Date
def ajd() @ajd end
# Get the date as an Astronomical Modified Julian Day Number.
- def amjd() ajd_to_amjd(@ajd) end
+ def amjd() self.class.ajd_to_amjd(@ajd) end
once :amjd
# Get the date as a Julian Day Number.
- def jd() ajd_to_jd(@ajd, @of)[0] end
+ def jd() self.class.ajd_to_jd(@ajd, @of)[0] end
# Get any fractional day part of the date.
- def day_fraction() ajd_to_jd(@ajd, @of)[1] end
+ def day_fraction() self.class.ajd_to_jd(@ajd, @of)[1] end
# Get the date as a Modified Julian Day Number.
- def mjd() jd_to_mjd(jd) end
+ def mjd() self.class.jd_to_mjd(jd) end
# Get the date as the number of days since the Day of Calendar
# Reform (in Italy and the Catholic countries).
- def ld() jd_to_ld(jd) end
+ def ld() self.class.jd_to_ld(jd) end
once :jd, :day_fraction, :mjd, :ld
# Get the date as a Civil Date, [year, month, day_of_month]
- def civil() jd_to_civil(jd, @sg) end # :nodoc:
+ def civil() self.class.jd_to_civil(jd, @sg) end # :nodoc:
# Get the date as an Ordinal Date, [year, day_of_year]
- def ordinal() jd_to_ordinal(jd, @sg) end # :nodoc:
+ def ordinal() self.class.jd_to_ordinal(jd, @sg) end # :nodoc:
# Get the date as a Commercial Date, [year, week_of_year, day_of_week]
- def commercial() jd_to_commercial(jd, @sg) end # :nodoc:
+ def commercial() self.class.jd_to_commercial(jd, @sg) end # :nodoc:
- def weeknum0() jd_to_weeknum(jd, 0, @sg) end # :nodoc:
- def weeknum1() jd_to_weeknum(jd, 1, @sg) end # :nodoc:
+ def weeknum0() self.class.__send__(:jd_to_weeknum, jd, 0, @sg) end # :nodoc:
+ def weeknum1() self.class.__send__(:jd_to_weeknum, jd, 1, @sg) end # :nodoc:
once :civil, :ordinal, :commercial, :weeknum0, :weeknum1
private :civil, :ordinal, :commercial, :weeknum0, :weeknum1
@@ -1177,7 +1103,7 @@ class Date
# Get the time of this date as [hours, minutes, seconds,
# fraction_of_a_second]
- def time() day_fraction_to_time(day_fraction) end # :nodoc:
+ def time() self.class.day_fraction_to_time(day_fraction) end # :nodoc:
once :time
private :time
@@ -1191,10 +1117,18 @@ class Date
# Get the second of this date.
def sec() time[2] end
- # Get the fraction-of-a-second of this date.
+ # Get the fraction-of-a-second of this date. The unit is in days.
+ # I do NOT recommend you to use this method.
def sec_fraction() time[3] end
+=begin
+ alias_method :minute, :min
+ alias_method :second, :sec
+ alias_method :second_fraction, :sec_fraction
+=end
+
private :hour, :min, :sec, :sec_fraction
+# :minute, :second, :second_fraction
def zone() strftime('%:z') end
@@ -1213,7 +1147,7 @@ class Date
# Get the week day of this date. Sunday is day-of-week 0;
# Saturday is day-of-week 6.
- def wday() jd_to_wday(jd) end
+ def wday() self.class.jd_to_wday(jd) end
once :wday
@@ -1223,23 +1157,17 @@ class Date
define_method(n.downcase + '?'){mon == i}
end
end
-=end
DAYNAMES.each_with_index do |n, i|
define_method(n.downcase + '?'){wday == i}
end
-
- def nth_kday? (n, k)
- k == wday && jd === nth_kday_to_jd(year, mon, n, k, start)
- end
-
- private :nth_kday?
+=end
# Is the current date old-style (Julian Calendar)?
- def julian? () jd < @sg end
+ def julian? () self.class.julian?(jd, @sg) end
# Is the current date new-style (Gregorian Calendar)?
- def gregorian? () !julian? end
+ def gregorian? () self.class.gregorian?(jd, @sg) end
once :julian?, :gregorian?
@@ -1253,8 +1181,8 @@ class Date
# Is this a leap year?
def leap?
- jd_to_civil(civil_to_jd(year, 3, 1, fix_style) - 1,
- fix_style)[-1] == 29
+ self.class.jd_to_civil(self.class.civil_to_jd(year, 3, 1, fix_style) - 1,
+ fix_style)[-1] == 29
end
once :leap?
@@ -1285,7 +1213,7 @@ class Date
def new_offset(of=0)
if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
+ of = Rational(zone_to_diff(of) || 0, 86400)
end
self.class.new!(@ajd, of, @sg)
end
@@ -1358,7 +1286,9 @@ class Date
end
def next_day(n=1) self + n end
- def prev_day(n=1) self - n end
+# def prev_day(n=1) self - n end
+
+ private :next_day
# Return a new Date one day after this one.
def next() next_day end
@@ -1375,7 +1305,7 @@ class Date
y, m = (year * 12 + (mon - 1) + n).divmod(12)
m, = (m + 1) .divmod(1)
d = mday
- d -= 1 until jd2 = _valid_civil?(y, m, d, @sg)
+ d -= 1 until jd2 = self.class.valid_civil?(y, m, d, fix_style)
self + (jd2 - jd)
end
@@ -1387,13 +1317,15 @@ class Date
# of the returned Date will be the last day of the target month.
def << (n) self >> -n end
+=begin
def next_month(n=1) self >> n end
def prev_month(n=1) self << n end
def next_year(n=1) self >> n * 12 end
def prev_year(n=1) self << n * 12 end
+=end
- require 'enumerator'
+# require 'enumerator'
# Step the current date forward +step+ days at a
# time (or backward, if +step+ is negative) until
@@ -1405,9 +1337,11 @@ class Date
raise ArgumentError, "step can't be 0"
end
=end
+=begin
unless block_given?
return to_enum(:step, limit, step)
end
+=end
da = self
op = %w(- <= >=)[step <=> 0]
while da.__send__(op, limit)
@@ -1443,13 +1377,25 @@ class Date
# Return the date as a human-readable string.
#
# The format used is YYYY-MM-DD.
- def to_s() strftime end
+ def to_s() format('%.4d-%02d-%02d', year, mon, mday) end # 4p
# Dump to Marshal format.
- def marshal_dump() [@ajd, @of, @sg] end
-
- # Load from Marshall format.
- def marshal_load(a) @ajd, @of, @sg, = a end
+ def _dump(limit) Marshal.dump([@ajd, @of, @sg], -1) end
+
+# def self._load(str) new!(*Marshal.load(str)) end
+
+ # Load from Marshal format.
+ def self._load(str)
+ a = Marshal.load(str)
+ if a.size == 2
+ ajd, sg = a
+ of = 0
+ ajd -= 1.to_r/2
+ else
+ ajd, of, sg = a
+ end
+ new!(ajd, of, sg)
+ end
end
@@ -1483,7 +1429,8 @@ end
# === sec_fraction()
#
# Get the fraction of a second of the time. This is returned as
-# a +Rational+.
+# a +Rational+. The unit is in days.
+# I do NOT recommend you to use this method.
#
# === zone()
#
@@ -1517,12 +1464,12 @@ class DateTime < Date
#
# All day/time values default to 0.
def self.jd(jd=0, h=0, min=0, s=0, of=0, sg=ITALY)
- unless (jd = _valid_jd?(jd, sg)) &&
- (fr = _valid_time?(h, min, s))
+ unless (jd = valid_jd?(jd, sg)) &&
+ (fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
+ of = Rational(zone_to_diff(of) || 0, 86400)
end
new!(jd_to_ajd(jd, fr, of), of, sg)
end
@@ -1542,12 +1489,12 @@ class DateTime < Date
# +y+ defaults to -4712, and +d+ to 1; this is Julian Day Number
# day 0. The time values default to 0.
def self.ordinal(y=-4712, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
- unless (jd = _valid_ordinal?(y, d, sg)) &&
- (fr = _valid_time?(h, min, s))
+ unless (jd = valid_ordinal?(y, d, sg)) &&
+ (fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
+ of = Rational(zone_to_diff(of) || 0, 86400)
end
new!(jd_to_ajd(jd, fr, of), of, sg)
end
@@ -1567,12 +1514,12 @@ class DateTime < Date
# +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is Julian Day
# Number day 0. The time values default to 0.
def self.civil(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
- unless (jd = _valid_civil?(y, m, d, sg)) &&
- (fr = _valid_time?(h, min, s))
+ unless (jd = valid_civil?(y, m, d, sg)) &&
+ (fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
+ of = Rational(zone_to_diff(of) || 0, 86400)
end
new!(jd_to_ajd(jd, fr, of), of, sg)
end
@@ -1591,46 +1538,33 @@ class DateTime < Date
# +of+ is the offset from UTC as a fraction of a day (defaults to 0).
# +sg+ specifies the Day of Calendar Reform.
#
- # +y+ defaults to -4712, +w+ to 1, and +d+ to 1; this is
- # Julian Day Number day 0.
+ # +y+ defaults to 1582, +w+ to 41, and +d+ to 5; this is the Day of
+ # Calendar Reform for Italy and the Catholic countries.
# The time values default to 0.
- def self.commercial(y=-4712, w=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
- unless (jd = _valid_commercial?(y, w, d, sg)) &&
- (fr = _valid_time?(h, min, s))
+ def self.commercial(y=1582, w=41, d=5, h=0, min=0, s=0, of=0, sg=ITALY)
+ unless (jd = valid_commercial?(y, w, d, sg)) &&
+ (fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
+ of = Rational(zone_to_diff(of) || 0, 86400)
end
new!(jd_to_ajd(jd, fr, of), of, sg)
end
- def self.weeknum(y=-4712, w=0, d=1, f=0, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
- unless (jd = _valid_weeknum?(y, w, d, f, sg)) &&
- (fr = _valid_time?(h, min, s))
+ def self.weeknum(y=1582, w=41, d=5, f=0, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
+ unless (jd = valid_weeknum?(y, w, d, f, sg)) &&
+ (fr = valid_time?(h, min, s))
raise ArgumentError, 'invalid date'
end
if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
+ of = Rational(zone_to_diff(of) || 0, 86400)
end
new!(jd_to_ajd(jd, fr, of), of, sg)
end
private_class_method :weeknum
- def self.nth_kday(y=-4712, m=1, n=1, k=1, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
- unless (jd = _valid_nth_kday?(y, m, n, k, sg)) &&
- (fr = _valid_time?(h, min, s))
- raise ArgumentError, 'invalid date'
- end
- if String === of
- of = (zone_to_diff(of) || 0).to_r/86400
- end
- new!(jd_to_ajd(jd, fr, of), of, sg)
- end
-
- private_class_method :nth_kday
-
def self.new_by_frags(elem, sg) # :nodoc:
elem = rewrite_frags(elem)
elem = complete_frags(elem)
@@ -1638,10 +1572,8 @@ class DateTime < Date
(fr = valid_time_frags?(elem))
raise ArgumentError, 'invalid date'
end
- sf = (elem[:sec_fraction] || 0)
- fr += sf/86400
- of = (elem[:offset] || 0)
- of = of.to_r/86400
+ fr += (elem[:sec_fraction] || 0) / 86400
+ of = Rational(elem[:offset] || 0, 86400)
new!(jd_to_ajd(jd, fr, of), of, sg)
end
@@ -1681,82 +1613,59 @@ class DateTime < Date
# Day Number day 0.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.parse(str='-4712-01-01T00:00:00+00:00', hints={}, sg=ITALY)
- elem = _parse(str, hints)
- new_by_frags(elem, sg)
- end
-
- def self.iso8601(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
- elem = _iso8601(str)
- new_by_frags(elem, sg)
- end
-
- def self.rfc3339(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
- elem = _rfc3339(str)
- new_by_frags(elem, sg)
- end
-
- def self.xmlschema(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
- elem = _xmlschema(str)
- new_by_frags(elem, sg)
- end
-
- def self.rfc2822(str='Mon, 1 Jan -4712 00:00:00 +0000', sg=ITALY) # :nodoc:
- elem = _rfc2822(str)
+ def self.parse(str='-4712-01-01T00:00:00+00:00', comp=false, sg=ITALY)
+ elem = _parse(str, comp)
new_by_frags(elem, sg)
end
- class << self; alias_method :rfc822, :rfc2822 end
-
- def self.httpdate(str='Mon, 01 Jan -4712 00:00:00 GMT', sg=ITALY) # :nodoc:
- elem = _httpdate(str)
- new_by_frags(elem, sg)
- end
+ public :hour, :min, :sec, :sec_fraction, :zone, :offset, :new_offset
+# :minute, :second, :second_fraction
- def self.jisx0301(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
- elem = _jisx0301(str)
- new_by_frags(elem, sg)
+ def to_s # 4p
+ format('%.4d-%02d-%02dT%02d:%02d:%02d%s',
+ year, mon, mday, hour, min, sec, zone)
end
- public :hour, :min, :sec, :sec_fraction, :zone, :offset, :new_offset
-
end
class Time
- def to_time() getlocal end
+# def to_time() getlocal end
def to_date
- jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::ITALY)
- Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY)
+ jd = Date.civil_to_jd(year, mon, mday, Date::ITALY)
+ Date.new!(Date.jd_to_ajd(jd, 0, 0), 0, Date::ITALY)
end
def to_datetime
- jd = DateTime.__send__(:civil_to_jd, year, mon, mday, DateTime::ITALY)
- fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec, 59].min) +
- nsec.to_r/86400_000_000_000
- of = utc_offset.to_r/86400
- DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
- of, DateTime::ITALY)
+ jd = DateTime.civil_to_jd(year, mon, mday, DateTime::ITALY)
+ fr = DateTime.time_to_day_fraction(hour, min, [sec, 59].min) +
+ Rational(usec, 86400_000_000)
+ of = Rational(utc_offset, 86400)
+ DateTime.new!(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY)
end
+ private :to_date, :to_datetime
+
end
class Date
+=begin
def to_time() Time.local(year, mon, mday) end
def to_date() self end
- def to_datetime() DateTime.new!(jd_to_ajd(jd, 0, 0), @of, @sg) end
+ def to_datetime() DateTime.new!(self.class.jd_to_ajd(jd, 0, 0), @of, @sg) end
+=end
# Create a new Date object representing today.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.today(sg=ITALY) Time.now.to_date .new_start(sg) end
+ def self.today(sg=ITALY) Time.now.__send__(:to_date) .new_start(sg) end
# Create a new DateTime object representing the current time.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.now (sg=ITALY) Time.now.to_datetime.new_start(sg) end
+ def self.now (sg=ITALY) Time.now.__send__(:to_datetime).new_start(sg) end
private_class_method :now
@@ -1764,19 +1673,95 @@ end
class DateTime < Date
+=begin
def to_time
d = new_offset(0)
d.instance_eval do
- Time.utc(year, mon, mday, hour, min, sec +
- sec_fraction)
+ Time.utc(year, mon, mday, hour, min, sec,
+ (sec_fraction * 86400000000).to_i)
end.
getlocal
end
- def to_date() Date.new!(jd_to_ajd(jd, 0, 0), 0, @sg) end
+ def to_date() Date.new!(self.class.jd_to_ajd(jd, 0, 0), 0, @sg) end
def to_datetime() self end
+=end
private_class_method :today
public_class_method :now
end
+
+class Date
+
+ class << self
+
+ def deprecated_class_method_alias(old, new) # :nodoc:
+ module_eval <<-"end;"
+ class << self
+ def #{old}(*args, &block)
+ if $VERBOSE
+ warn("\#{caller.shift.sub(/:in .*/, '')}: " \
+ "warning: \#{self}::#{old} is deprecated; " \
+ "use \#{self}::#{new}")
+ end
+ #{new}(*args, &block)
+ end
+ end
+ end;
+ end
+
+ private :deprecated_class_method_alias
+
+ def deprecated_alias(old, new) # :nodoc:
+ module_eval <<-"end;"
+ def #{old}(*args, &block)
+ if $VERBOSE
+ warn("\#{caller.shift.sub(/:in .*/, '')}: " \
+ "warning: \#{self.class}\##{old} is deprecated; " \
+ "use \#{self.class}\##{new}")
+ end
+ #{new}(*args, &block)
+ end
+ end;
+ end
+
+ private :deprecated_alias
+
+ end
+
+ [ %w(os? julian?),
+ %w(ns? gregorian?),
+ %w(exist1? valid_jd?),
+ %w(exist2? valid_ordinal?),
+ %w(exist3? valid_date?),
+ %w(exist? valid_date?),
+ %w(existw? valid_commercial?),
+ %w(new0 new!),
+ %w(new1 jd),
+ %w(new2 ordinal),
+ %w(new3 new),
+ %w(neww commercial)
+ ].each do |old, new|
+ deprecated_class_method_alias(old, new)
+ end
+
+ [ %w(os? julian?),
+ %w(ns? gregorian?),
+ %w(sg start),
+ %w(newsg new_start),
+ %w(of offset),
+ %w(newof new_offset)
+ ].each do |old, new|
+ deprecated_alias(old, new)
+ end
+
+ private :of, :newof
+
+end
+
+class DateTime < Date
+
+ public :of, :newof
+
+end
diff --git a/lib/date/format.rb b/lib/date/format.rb
index 47cb9cae19..f89c1344a9 100644
--- a/lib/date/format.rb
+++ b/lib/date/format.rb
@@ -1,5 +1,5 @@
-# format.rb: Written by Tadayoshi Funaba 1999-2007
-# $Id: format.rb,v 2.40 2007-09-09 08:28:03+09 tadf Exp $
+# format.rb: Written by Tadayoshi Funaba 1999-2008
+# $Id: format.rb,v 2.43 2008-01-17 20:16:31+09 tadf Exp $
require 'rational'
@@ -257,25 +257,23 @@ class Date
when 'j'; emit_n(yday, 3, f)
when 'k'; emit_a(hour, 2, f)
when 'L'
- emit_n((sec_fraction / (1.to_r/(10**3))).round, 3, f)
+ emit_n((sec_fraction / MILLISECONDS_IN_DAY).floor, 3, f)
when 'l'; emit_a((hour % 12).nonzero? || 12, 2, f)
when 'M', 'OM'; emit_n(min, 2, f)
when 'm', 'Om'; emit_n(mon, 2, f)
when 'N'
- emit_n((sec_fraction / (1.to_r/(10**9))).round, 9, f)
+ emit_n((sec_fraction / NANOSECONDS_IN_DAY).floor, 9, f)
when 'n'; "\n"
when 'P'; emit_ad(strftime('%p').downcase, 0, f)
when 'p'; emit_au(if hour < 12 then 'AM' else 'PM' end, 0, f)
when 'Q'
- d = ajd - jd_to_ajd(self.class::UNIXEPOCH, 0)
- s = (d * 86400*10**3).to_i
+ s = ((ajd - UNIX_EPOCH_IN_AJD) / MILLISECONDS_IN_DAY).round
emit_sn(s, 1, f)
when 'R'; emit_a(strftime('%H:%M'), 0, f)
when 'r'; emit_a(strftime('%I:%M:%S %p'), 0, f)
when 'S', 'OS'; emit_n(sec, 2, f)
when 's'
- d = ajd - jd_to_ajd(self.class::UNIXEPOCH, 0)
- s = (d * 86400).to_i
+ s = ((ajd - UNIX_EPOCH_IN_AJD) / SECONDS_IN_DAY).round
emit_sn(s, 1, f)
when 'T'
if m == '%T'
@@ -299,9 +297,9 @@ class Date
t = $1.size
sign = if offset < 0 then -1 else +1 end
fr = offset.abs
- hh, fr = fr.divmod(1.to_r/24)
- mm, fr = fr.divmod(1.to_r/1440)
- ss, fr = fr.divmod(1.to_r/86400)
+ ss = fr.div(SECONDS_IN_DAY) # 4p
+ hh, ss = ss.divmod(3600)
+ mm, ss = ss.divmod(60)
if t == 3
if ss.nonzero? then t = 2
elsif mm.nonzero? then t = 1
@@ -328,6 +326,21 @@ class Date
([emit_z(sign * hh, 2, f)] + tail).join(sep)
when '%'; emit_a('%', 0, f)
when '+'; emit_a(strftime('%a %b %e %H:%M:%S %Z %Y'), 0, f)
+ when '1'
+ if $VERBOSE
+ warn("warning: strftime: %1 is deprecated; forget this")
+ end
+ emit_n(jd, 1, f)
+ when '2'
+ if $VERBOSE
+ warn("warning: strftime: %2 is deprecated; use '%Y-%j'")
+ end
+ emit_a(strftime('%Y-%j'), 0, f)
+ when '3'
+ if $VERBOSE
+ warn("warning: strftime: %3 is deprecated; use '%F'")
+ end
+ emit_a(strftime('%F'), 0, f)
else
a
end
@@ -340,18 +353,15 @@ class Date
alias_method :ctime, :asctime
+=begin
def iso8601() strftime('%F') end
def rfc3339() iso8601 end
- def xmlschema() iso8601 end # :nodoc:
-
def rfc2822() strftime('%a, %-d %b %Y %T %z') end
alias_method :rfc822, :rfc2822
- def httpdate() new_offset(0).strftime('%a, %d %b %Y %T GMT') end # :nodoc:
-
def jisx0301
if jd < 2405160
iso8601
@@ -370,14 +380,13 @@ class Date
end
end
-=begin
def beat(n=0)
- i, f = (new_offset(1.to_r/24).day_fraction * 1000).divmod(1)
+ i, f = (new_offset(HOURS_IN_DAY).day_fraction * 1000).divmod(1)
('@%03d' % i) +
if n < 1
''
else
- '.%0*d' % [n, (f / (1.to_r/(10**n))).round]
+ '.%0*d' % [n, (f / Rational(1, 10**n)).round]
end
end
=end
@@ -456,8 +465,8 @@ class Date
then /\A([-+]?\d{1,3})/
else /\A([-+]?\d{1,})/
end, '')
-# val = $1.to_i.to_r / (10**3)
- val = $1.to_i.to_r / (10**$1.size)
+# val = Rational($1.to_i, 10**3)
+ val = Rational($1.to_i, 10**$1.size)
e.sec_fraction = val
when 'M', 'OM'
return unless str.sub!(/\A(\d{1,2})/, '')
@@ -474,8 +483,8 @@ class Date
then /\A([-+]?\d{1,9})/
else /\A([-+]?\d{1,})/
end, '')
-# val = $1.to_i.to_r / (10**9)
- val = $1.to_i.to_r / (10**$1.size)
+# val = Rational($1.to_i, 10**9)
+ val = Rational($1.to_i, 10**$1.size)
e.sec_fraction = val
when 'n', 't'
return unless _strptime_i(str, "\s", e)
@@ -484,7 +493,7 @@ class Date
e._merid = if $1.downcase == 'a' then 0 else 12 end
when 'Q'
return unless str.sub!(/\A(-?\d{1,})/, '')
- val = $1.to_i.to_r / 10**3
+ val = Rational($1.to_i, 10**3)
e.seconds = val
when 'R'
return unless _strptime_i(str, '%H:%M', e)
@@ -553,6 +562,23 @@ class Date
return unless str.sub!(/\A%/, '')
when '+'
return unless _strptime_i(str, '%a %b %e %H:%M:%S %Z %Y', e)
+ when '1'
+ if $VERBOSE
+ warn("warning: strptime: %1 is deprecated; forget this")
+ end
+ return unless str.sub!(/\A(\d+)/, '')
+ val = $1.to_i
+ e.jd = val
+ when '2'
+ if $VERBOSE
+ warn("warning: strptime: %2 is deprecated; use '%Y-%j'")
+ end
+ return unless _strptime_i(str, '%Y-%j', e)
+ when '3'
+ if $VERBOSE
+ warn("warning: strptime: %3 is deprecated; use '%F'")
+ end
+ return unless _strptime_i(str, '%F', e)
else
return unless str.sub!(Regexp.new('\\A' + Regexp.quote(a)), '')
end
@@ -723,7 +749,7 @@ class Date
e.hour = $1.to_i
e.min = $2.to_i if $2
e.sec = $3.to_i if $3
- e.sec_fraction = $4.to_i.to_r / (10**$4.size) if $4
+ e.sec_fraction = Rational($4.to_i, 10**$4.size) if $4
if $5
e.hour %= 12
@@ -738,9 +764,9 @@ class Date
=begin
def self._parse_beat(str, e) # :nodoc:
if str.sub!(/@\s*(\d+)(?:[,.](\d*))?/, ' ')
- beat = $1.to_i.to_r
- beat += $2.to_i.to_r / (10**$2.size) if $2
- secs = beat.to_r / 1000
+ beat = Rational($1.to_i)
+ beat += Rational($2.to_i, 10**$2.size) if $2
+ secs = Rational(beat, 1000)
h, min, s, fr = self.day_fraction_to_time(secs)
e.hour = h
e.min = min
@@ -823,9 +849,6 @@ class Date
str.sub!(/\b-(\d{3})\b/n, ' ')
e.yday = $1.to_i
true
- elsif e._date && str.sub!(/('?[-+]?\d+)-('?-?\d+)/n, ' ')
- s3e(e, nil, $1, $2)
- true
end
end
@@ -840,11 +863,6 @@ class Date
e.mon = $3.to_i
e.mday = $4.to_i
true
- elsif e._jis && str.sub!(/(\d+)\.(\d+)\.(\d+)/in, ' ')
- e.year = $1.to_i + 1988
- e.mon = $2.to_i
- e.mday = $3.to_i
- true
end
end
@@ -860,54 +878,17 @@ class Date
end
end
- def self._parse_sla_jp(str, e) # :nodoc:
- if str.sub!(%r|('?-?\d+)/\s*('?\d+)(?:\D\s*('?-?\d+))?|n, ' ') # '
- s3e(e, $1, $2, $3)
- true
- end
- end
-
- def self._parse_sla_eu(str, e) # :nodoc:
- if str.sub!(%r|('?-?\d+)/\s*('?\d+)(?:\D\s*('?-?\d+))?|n, ' ') # '
- s3e(e, $3, $2, $1)
- true
- end
- end
-
- def self._parse_sla_us(str, e) # :nodoc:
+ def self._parse_sla(str, e) # :nodoc:
if str.sub!(%r|('?-?\d+)/\s*('?\d+)(?:\D\s*('?-?\d+))?|n, ' ') # '
s3e(e, $3, $1, $2)
true
end
end
- def self._parse_dot_jp(str, e) # :nodoc:
+ def self._parse_dot(str, e) # :nodoc:
if str.sub!(%r|('?-?\d+)\.\s*('?\d+)\.\s*('?-?\d+)|n, ' ') # '
s3e(e, $1, $2, $3)
true
- elsif e._date && str.sub!(%r|('?-?\d+)\.\s*('?\d+)|n, ' ') # '
- s3e(e, nil, $1, $2)
- true
- end
- end
-
- def self._parse_dot_eu(str, e) # :nodoc:
- if str.sub!(%r|('?-?\d+)\.\s*('?\d+)\.\s*('?-?\d+)|n, ' ') # '
- s3e(e, $3, $2, $1)
- true
- elsif e._date && str.sub!(%r|('?-?\d+)\.\s*('?\d+)|n, ' ') # '
- s3e(e, nil, $2, $1)
- true
- end
- end
-
- def self._parse_dot_us(str, e) # :nodoc:
- if str.sub!(%r|('?-?\d+)\.\s*('?\d+)\.\s*('?-?\d+)|n, ' ') # '
- s3e(e, $3, $1, $2)
- true
- elsif e._date && str.sub!(%r|('?-?\d+)\.\s*('?\d+)|n, ' ') # '
- s3e(e, nil, $1, $2)
- true
end
end
@@ -958,24 +939,15 @@ class Date
if $3.nil? && $4
e.sec = $2[-2, 2].to_i
else
- if e._time
- e.hour = $2[ 0, 2].to_i
- else
- e.mday = $2[ 0, 2].to_i
- end
+ e.mday = $2[ 0, 2].to_i
end
when 4
if $3.nil? && $4
e.sec = $2[-2, 2].to_i
e.min = $2[-4, 2].to_i
else
- if e._time
- e.hour = $2[ 0, 2].to_i
- e.min = $2[ 2, 2].to_i
- else
- e.mon = $2[ 0, 2].to_i
- e.mday = $2[ 2, 2].to_i
- end
+ e.mon = $2[ 0, 2].to_i
+ e.mday = $2[ 2, 2].to_i
end
when 6
if $3.nil? && $4
@@ -983,15 +955,9 @@ class Date
e.min = $2[-4, 2].to_i
e.hour = $2[-6, 2].to_i
else
- if e._time || e._ofx
- e.hour = $2[ 0, 2].to_i
- e.min = $2[ 2, 2].to_i
- e.sec = $2[ 4, 2].to_i
- else
- e.year = ($1 + $2[ 0, 2]).to_i
- e.mon = $2[ 2, 2].to_i
- e.mday = $2[ 4, 2].to_i
- end
+ e.year = ($1 + $2[ 0, 2]).to_i
+ e.mon = $2[ 2, 2].to_i
+ e.mday = $2[ 4, 2].to_i
end
when 8, 10, 12, 14
if $3.nil? && $4
@@ -1063,7 +1029,7 @@ class Date
end
end
if $4
- e.sec_fraction = $4.to_i.to_r / (10**$4.size)
+ e.sec_fraction = Rational($4.to_i, 10**$4.size)
end
if $5
e.zone = $5
@@ -1082,116 +1048,33 @@ class Date
private_class_method :_parse_day, :_parse_time, # :_parse_beat,
:_parse_eu, :_parse_us, :_parse_iso, :_parse_iso2,
- :_parse_jis, :_parse_vms,
- :_parse_sla_jp, :_parse_sla_eu, :_parse_sla_us,
- :_parse_dot_jp, :_parse_dot_eu, :_parse_dot_us,
+ :_parse_jis, :_parse_vms, :_parse_sla, :_parse_dot,
:_parse_year, :_parse_mon, :_parse_mday, :_parse_ddd
- def self._parse(str, hints={})
+ def self._parse(str, comp=false)
str = str.dup
e = Format::Bag.new
- e._comp = true
-
- unless Hash === hints
- e._comp = hints
- else
- hints.each do |k, v|
- case k
- when :comp, :complete
- e._comp = v
- when :style, :endian, :endianness, :order
- v = {
- :jp => :jp,
- :eu => :eu,
- :us => :us,
- :big => :jp,
- :little => :eu,
- :middle => :us,
- :ymd => :jp,
- :dmy => :eu,
- :mdy => :us
- }[v]
- e._style = v
- when :date
- e._date = v
- when :time
- e._time = v
- when :jis
- e._jis = v
- when :ofx
- e._ofx = v
- else
- raise ArgumentError, 'unknown hint'
- end
- end
- end
+ e._comp = comp
str.gsub!(/[^-+',.\/:@[:alnum:]\[\]\x80-\xff]+/n, ' ')
- case e._style
- when :jp
- _parse_time(str, e) # || _parse_beat(str, e)
- _parse_eu(str, e) ||
- _parse_us(str, e) ||
- _parse_iso(str, e) ||
- _parse_jis(str, e) ||
- _parse_vms(str, e) ||
- _parse_sla_jp(str, e) ||
- _parse_dot_jp(str, e) ||
- _parse_iso2(str, e) ||
- _parse_year(str, e) ||
- _parse_mon(str, e) ||
- _parse_mday(str, e) ||
- _parse_ddd(str, e)
- _parse_day(str, e)
- when :eu
- _parse_time(str, e) # || _parse_beat(str, e)
- _parse_eu(str, e) ||
- _parse_iso(str, e) ||
- _parse_jis(str, e) ||
- _parse_vms(str, e) ||
- _parse_sla_eu(str, e) ||
- _parse_dot_eu(str, e) ||
- _parse_iso2(str, e) ||
- _parse_year(str, e) ||
- _parse_mon(str, e) ||
- _parse_mday(str, e) ||
- _parse_ddd(str, e) ||
- _parse_us(str, e)
- _parse_day(str, e)
- when :us
- _parse_time(str, e) # || _parse_beat(str, e)
- _parse_eu(str, e) ||
- _parse_us(str, e) ||
- _parse_iso(str, e) ||
- _parse_jis(str, e) ||
- _parse_vms(str, e) ||
- _parse_sla_us(str, e) ||
- _parse_dot_us(str, e) ||
- _parse_iso2(str, e) ||
- _parse_year(str, e) ||
- _parse_mon(str, e) ||
- _parse_mday(str, e) ||
- _parse_ddd(str, e)
- _parse_day(str, e)
- else
- _parse_time(str, e) # || _parse_beat(str, e)
- _parse_eu(str, e) ||
- _parse_us(str, e) ||
- _parse_iso(str, e) ||
- _parse_jis(str, e) ||
- _parse_vms(str, e) ||
- _parse_sla_jp(str, e) ||
- _parse_dot_jp(str, e) ||
- _parse_iso2(str, e) ||
- _parse_year(str, e) ||
- _parse_mon(str, e) ||
- _parse_mday(str, e) ||
- _parse_ddd(str, e)
- _parse_day(str, e)
- end
+ _parse_time(str, e) # || _parse_beat(str, e)
+ _parse_day(str, e)
+
+ _parse_eu(str, e) ||
+ _parse_us(str, e) ||
+ _parse_iso(str, e) ||
+ _parse_jis(str, e) ||
+ _parse_vms(str, e) ||
+ _parse_sla(str, e) ||
+ _parse_dot(str, e) ||
+ _parse_iso2(str, e) ||
+ _parse_year(str, e) ||
+ _parse_mon(str, e) ||
+ _parse_mday(str, e) ||
+ _parse_ddd(str, e)
if str.sub!(/\b(bc\b|bce\b|b\.c\.|b\.c\.e\.)/in, ' ')
if e.year
@@ -1234,154 +1117,40 @@ class Date
e.to_hash
end
- def self._iso8601(str) # :nodoc:
- if /\A\s*(([-+]?\d{2,}|-)-\d{2}-\d{2}|
- ([-+]?\d{2,})?-\d{3}|
- (\d{2}|\d{4})?-w\d{2}-\d|
- -w-\d)
- (t
- \d{2}:\d{2}(:\d{2}([,.]\d+)?)?
- (z|[-+]\d{2}(:?\d{2})?)?)?\s*\z/inx =~ str
- _parse(str)
- elsif /\A\s*(([-+]?(\d{2}|\d{4})|--)\d{2}\d{2}|
- ([-+]?(\d{2}|\d{4}))?\d{3}|-\d{3}|
- (\d{2}|\d{4})?w\d{2}\d)
- (t?
- \d{2}\d{2}(\d{2}([,.]\d+)?)?
- (z|[-+]\d{2}(\d{2})?)?)?\s*\z/inx =~ str
- _parse(str)
- elsif /\A\s*(\d{2}:\d{2}(:\d{2}([,.]\d+)?)?
- (z|[-+]\d{2}(:?\d{2})?)?)?\s*\z/inx =~ str
- _parse(str)
- elsif /\A\s*(\d{2}\d{2}(\d{2}([,.]\d+)?)?
- (z|[-+]\d{2}(\d{2})?)?)?\s*\z/inx =~ str
- _parse(str)
- end
- end
-
- def self._rfc3339(str) # :nodoc:
- if /\A\s*-?\d{4}-\d{2}-\d{2} # allow minus, anyway
- (t|\s)
- \d{2}:\d{2}:\d{2}(\.\d+)?
- (z|[-+]\d{2}:\d{2})\s*\z/inx =~ str
- _parse(str)
- end
- end
-
- def self._xmlschema(str) # :nodoc:
- if /\A\s*-?\d{4}-\d{2}-\d{2}
- (t
- \d{2}:\d{2}:\d{2}(?:\.\d+)?)?
- (z|[-+]\d{2}:\d{2})?\s*\z/inx =~ str
- if $1.nil? && $2
- str = str.sub(/(z|[-+]\d{2}:\d{2})/in, 'T00:00:00\1')
- end
- _parse(str)
- elsif /\A\s*\d{2}:\d{2}:\d{2}(\.\d+)?
- (z|[-+]\d{2}:\d{2})?\s*\z/inx =~ str
- _parse(str)
- end
- end
-
- def self._rfc2822(str) # :nodoc:
- if /\A\s*(?:(?:#{Format::ABBR_DAYS.keys.join('|')})\s*,\s+)?
- \d{1,2}\s+
- (?:#{Format::ABBR_MONTHS.keys.join('|')})\s+
- -?(\d{2,})\s+ # allow minus, anyway
- \d{2}:\d{2}(:\d{2})?\s*
- (?:[-+]\d{4}|ut|gmt|e[sd]t|c[sd]t|m[sd]t|p[sd]t|[a-ik-z])\s*\z/inox =~ str
- e = _parse(str, :comp=>false)
- if $1.size < 4
- if e[:year] < 50
- e[:year] += 2000
- elsif e[:year] < 1000
- e[:year] += 1900
- end
- end
- e
- end
- end
-
- class << self; alias_method :_rfc822, :_rfc2822 end
-
- def self._httpdate(str) # :nodoc:
- if /\A\s*(#{Format::ABBR_DAYS.keys.join('|')})\s*,\s+
- \d{2}\s+
- (#{Format::ABBR_MONTHS.keys.join('|')})\s+
- -?\d{4}\s+ # allow minus, anyway
- \d{2}:\d{2}:\d{2}\s+
- gmt\s*\z/inox =~ str
- _rfc2822(str)
- elsif /\A\s*(#{Format::DAYS.keys.join('|')})\s*,\s+
- \d{2}\s*-\s*
- (#{Format::ABBR_MONTHS.keys.join('|')})\s*-\s*
- \d{2}\s+
- \d{2}:\d{2}:\d{2}\s+
- gmt\s*\z/inox =~ str
- _parse(str)
- elsif /\A\s*(#{Format::ABBR_DAYS.keys.join('|')})\s+
- (#{Format::ABBR_MONTHS.keys.join('|')})\s+
- \d{1,2}\s+
- \d{2}:\d{2}:\d{2}\s+
- \d{4}\s*\z/inox =~ str
- _parse(str)
- end
- end
-
- def self._jisx0301(str) # :nodoc:
- if /\A\s*[mtsh]?\d{2}\.\d{2}\.\d{2}
- (t
- (\d{2}:\d{2}(:\d{2}([,.]\d*)?)?
- (z|[-+]\d{2}(:?\d{2})?)?)?)?\s*\z/inx =~ str
- _parse(str, :jis=>true)
+ def self.zone_to_diff(zone) # :nodoc:
+ zone = zone.downcase
+ if zone.sub!(/\s+(standard|daylight)\s+time\z/, '')
+ dst = $1 == 'daylight'
else
- _iso8601(str)
+ dst = zone.sub!(/\s+dst\z/, '')
end
- end
-
- t = Module.new do
-
- private
-
- def zone_to_diff(zone) # :nodoc:
- zone = zone.downcase
- if zone.sub!(/\s+(standard|daylight)\s+time\z/, '')
- dst = $1 == 'daylight'
+ if Format::ZONES.include?(zone)
+ offset = Format::ZONES[zone]
+ offset += 3600 if dst
+ elsif zone.sub!(/\A(?:gmt|utc?)?([-+])/, '')
+ sign = $1
+ if zone.include?(':')
+ hour, min, sec, = zone.split(':')
+ elsif zone.include?(',') || zone.include?('.')
+ hour, fr, = zone.split(/[,.]/)
+ min = Rational(fr.to_i, 10**fr.size) * 60
else
- dst = zone.sub!(/\s+dst\z/, '')
- end
- if Format::ZONES.include?(zone)
- offset = Format::ZONES[zone]
- offset += 3600 if dst
- elsif zone.sub!(/\A(?:gmt|utc?)?([-+])/, '')
- sign = $1
- if zone.include?(':')
- hour, min, sec, = zone.split(':')
- elsif zone.include?(',') || zone.include?('.')
- hour, fr, = zone.split(/[,.]/)
- min = fr.to_i.to_r / (10**fr.size) * 60
+ case zone.size
+ when 3
+ hour = zone[0,1]
+ min = zone[1,2]
else
- case zone.size
- when 3
- hour = zone[0,1]
- min = zone[1,2]
- else
- hour = zone[0,2]
- min = zone[2,2]
- sec = zone[4,2]
- end
+ hour = zone[0,2]
+ min = zone[2,2]
+ sec = zone[4,2]
end
- offset = hour.to_i * 3600 + min.to_i * 60 + sec.to_i
- offset *= -1 if sign == '-'
end
- offset
+ offset = hour.to_i * 3600 + min.to_i * 60 + sec.to_i
+ offset *= -1 if sign == '-'
end
-
+ offset
end
- extend t
- include t
-
end
class DateTime < Date
@@ -1394,12 +1163,13 @@ class DateTime < Date
super(str, fmt)
end
+=begin
def iso8601_timediv(n) # :nodoc:
strftime('T%T' +
if n < 1
''
else
- '.%0*d' % [n, (sec_fraction / (1.to_r/(10**n))).round]
+ '.%0*d' % [n, (sec_fraction / SECONDS_IN_DAY / (10**n)).round]
end +
'%:z')
end
@@ -1412,10 +1182,9 @@ class DateTime < Date
def rfc3339(n=0) iso8601(n) end
- def xmlschema(n=0) iso8601(n) end # :nodoc:
-
def jisx0301(n=0)
super() + iso8601_timediv(n)
end
+=end
end
diff --git a/lib/date2.rb b/lib/date2.rb
new file mode 100644
index 0000000000..f7da78f650
--- /dev/null
+++ b/lib/date2.rb
@@ -0,0 +1,5 @@
+# date2 was overridden by date.
+# To be precise, date was overridden by date2,
+# and date2 was renamed to date.
+
+require 'date'
diff --git a/lib/debug.rb b/lib/debug.rb
index 1b5f2a2bb6..9ae119f8fb 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -19,6 +19,45 @@ end
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
class DEBUGGER__
+class Mutex
+ def initialize
+ @locker = nil
+ @waiting = []
+ @locked = false;
+ end
+
+ def locked?
+ @locked
+ end
+
+ def lock
+ return if Thread.critical
+ return if @locker == Thread.current
+ while (Thread.critical = true; @locked)
+ @waiting.push Thread.current
+ Thread.stop
+ end
+ @locked = true
+ @locker = Thread.current
+ Thread.critical = false
+ self
+ end
+
+ def unlock
+ return if Thread.critical
+ return unless @locked
+ unless @locker == Thread.current
+ raise RuntimeError, "unlocked by other"
+ end
+ Thread.critical = true
+ t = @waiting.shift
+ @locked = false
+ @locker = nil
+ Thread.critical = false
+ t.run if t
+ self
+ end
+end
MUTEX = Mutex.new
class Context
@@ -79,14 +118,13 @@ class Context
end
def check_suspend
- while MUTEX.synchronize {
- if @suspend_next
- DEBUGGER__.waiting.push Thread.current
- @suspend_next = false
- true
- end
- }
+ return if Thread.critical
+ while (Thread.critical = true; @suspend_next)
+ DEBUGGER__.waiting.push Thread.current
+ @suspend_next = false
+ Thread.stop
end
+ Thread.critical = false
end
def trace?
@@ -752,12 +790,13 @@ class << DEBUGGER__
end
def set_trace( arg )
- MUTEX.synchronize do
- make_thread_list
- for th, in @thread_list
- context(th).set_trace arg
- end
+ saved_crit = Thread.critical
+ Thread.critical = true
+ make_thread_list
+ for th, in @thread_list
+ context(th).set_trace arg
end
+ Thread.critical = saved_crit
arg
end
@@ -766,29 +805,31 @@ class << DEBUGGER__
end
def suspend
- MUTEX.synchronize do
- make_thread_list
- for th, in @thread_list
- next if th == Thread.current
- context(th).set_suspend
- end
- end
+ saved_crit = Thread.critical
+ Thread.critical = true
+ make_thread_list
+ for th, in @thread_list
+ next if th == Thread.current
+ context(th).set_suspend
+ end
+ Thread.critical = saved_crit
# Schedule other threads to suspend as soon as possible.
- Thread.pass
+ Thread.pass unless Thread.critical
end
def resume
- MUTEX.synchronize do
- make_thread_list
- for th, in @thread_list
- next if th == Thread.current
- context(th).clear_suspend
- end
- waiting.each do |th|
- th.run
- end
- waiting.clear
- end
+ saved_crit = Thread.critical
+ Thread.critical = true
+ make_thread_list
+ for th, in @thread_list
+ next if th == Thread.current
+ context(th).clear_suspend
+ end
+ waiting.each do |th|
+ th.run
+ end
+ waiting.clear
+ Thread.critical = saved_crit
# Schedule other threads to restart as soon as possible.
Thread.pass
end
@@ -903,7 +944,4 @@ stdout.printf "Emacs support available.\n\n"
set_trace_func proc { |event, file, line, id, binding, klass, *rest|
DEBUGGER__.context.trace_func event, file, line, id, binding, klass
}
-VM::InstructionSequence.compile_option = {
- trace_instruction: true
-}
end
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 8501ed1064..bd2b5e4813 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -95,15 +95,15 @@
# class SimpleDelegator < Delegator
# def initialize(obj)
# super # pass obj to Delegator constructor, required
-# @delegate_sd_obj = obj # store obj for future use
+# @_sd_obj = obj # store obj for future use
# end
#
# def __getobj__
-# @delegate_sd_obj # return object we are delegating to, required
+# @_sd_obj # return object we are delegating to, required
# end
#
# def __setobj__(obj)
-# @delegate_sd_obj = obj # change delegation object, a feature we're providing
+# @_sd_obj = obj # change delegation object, a feature we're providing
# end
#
# # ...
@@ -115,99 +115,76 @@
# implementation, see SimpleDelegator.
#
class Delegator
- preserved = [:__id__, :object_id, :__send__, :public_send, :respond_to?, :send]
- instance_methods.each do |m|
- next if preserved.include?(m)
- undef_method m
- end
+ IgnoreBacktracePat = %r"\A#{Regexp.quote(__FILE__)}:\d+:in `"
- module MethodDelegation
- #
- # Pass in the _obj_ to delegate method calls to. All methods supported by
- # _obj_ will be delegated to.
- #
- def initialize(obj)
- __setobj__(obj)
+ #
+ # Pass in the _obj_ to delegate method calls to. All methods supported by
+ # _obj_ will be delegated to.
+ #
+ def initialize(obj)
+ preserved = ::Kernel.public_instance_methods(false)
+ preserved -= ["to_s","to_a","inspect","==","=~","==="]
+ for t in self.class.ancestors
+ preserved |= t.public_instance_methods(false)
+ preserved |= t.private_instance_methods(false)
+ preserved |= t.protected_instance_methods(false)
+ break if t == Delegator
end
-
- # Handles the magic of delegation through \_\_getobj\_\_.
- def method_missing(m, *args, &block)
+ preserved << "singleton_method_added"
+ for method in obj.methods
+ next if preserved.include? method
begin
- target = self.__getobj__
- unless target.respond_to?(m)
- super(m, *args, &block)
- else
- target.__send__(m, *args, &block)
- end
- rescue Exception
- $@.delete_if{|s| /^#{__FILE__}:\d+:in `method_missing'$/ =~ s} #`
- ::Kernel::raise
+ eval <<-EOS, nil, __FILE__, __LINE__+1
+ def self.#{method}(*args, &block)
+ begin
+ __getobj__.__send__(:#{method}, *args, &block)
+ ensure
+ $@.delete_if{|s|IgnoreBacktracePat=~s} if $@
+ end
+ end
+ EOS
+ rescue SyntaxError
+ raise NameError, "invalid identifier %s" % method, caller(4)
end
end
+ end
+ alias initialize_methods initialize
- #
- # Checks for a method provided by this the delegate object by fowarding the
- # call through \_\_getobj\_\_.
- #
- def respond_to?(m)
- return true if super
- return self.__getobj__.respond_to?(m)
- end
-
- #
- # Returns true if two objects are considered same.
- #
- def ==(obj)
- return true if obj.equal?(self)
- self.__getobj__ == obj
- end
-
- #
- # Returns true only if two objects are identical.
- #
- def equal?(obj)
- self.object_id == obj.object_id
- end
-
- #
- # This method must be overridden by subclasses and should return the object
- # method calls are being delegated to.
- #
- def __getobj__
- raise NotImplementedError, "need to define `__getobj__'"
+ # Handles the magic of delegation through \_\_getobj\_\_.
+ def method_missing(m, *args)
+ target = self.__getobj__
+ unless target.respond_to?(m)
+ super(m, *args)
end
+ target.__send__(m, *args)
+ end
- #
- # This method must be overridden by subclasses and change the object delegate
- # to _obj_.
- #
- def __setobj__(obj)
- raise NotImplementedError, "need to define `__setobj__'"
- end
+ #
+ # Checks for a method provided by this the delegate object by fowarding the
+ # call through \_\_getobj\_\_.
+ #
+ def respond_to?(m, include_private = false)
+ return true if super
+ return self.__getobj__.respond_to?(m, include_private)
+ end
- # Serialization support for the object returned by \_\_getobj\_\_.
- def marshal_dump
- __getobj__
- end
- # Reinitializes delegation from a serialized object.
- def marshal_load(obj)
- __setobj__(obj)
- end
+ #
+ # This method must be overridden by subclasses and should return the object
+ # method calls are being delegated to.
+ #
+ def __getobj__
+ raise NotImplementedError, "need to define `__getobj__'"
+ end
- # Clone support for the object returned by \_\_getobj\_\_.
- def clone
- new = super
- new.__setobj__(__getobj__.clone)
- new
- end
- # Duplication support for the object returned by \_\_getobj\_\_.
- def dup
- new = super
- new.__setobj__(__getobj__.dup)
- new
- end
+ # Serialization support for the object returned by \_\_getobj\_\_.
+ def marshal_dump
+ __getobj__
+ end
+ # Reinitializes delegation from a serialized object.
+ def marshal_load(obj)
+ initialize_methods(obj)
+ __setobj__(obj)
end
- include MethodDelegation
end
#
@@ -217,9 +194,16 @@ end
# \_\_setobj\_\_ .
#
class SimpleDelegator<Delegator
+
+ # Pass in the _obj_ you would like to delegate method calls to.
+ def initialize(obj)
+ super
+ @_sd_obj = obj
+ end
+
# Returns the current object method calls are being delegated to.
def __getobj__
- @delegate_sd_obj
+ @_sd_obj
end
#
@@ -238,7 +222,20 @@ class SimpleDelegator<Delegator
#
def __setobj__(obj)
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
- @delegate_sd_obj = obj
+ @_sd_obj = obj
+ end
+
+ # Clone support for the object returned by \_\_getobj\_\_.
+ def clone
+ new = super
+ new.__setobj__(__getobj__.clone)
+ new
+ end
+ # Duplication support for the object returned by \_\_getobj\_\_.
+ def dup
+ new = super
+ new.__setobj__(__getobj__.clone)
+ new
end
end
@@ -253,7 +250,7 @@ SimpleDelegater = SimpleDelegator
# your class.
#
# class MyClass < DelegateClass( ClassToDelegateTo ) # Step 1
-# def initiaize
+# def initialize
# super(obj_of_ClassToDelegateTo) # Step 2
# end
# end
@@ -261,19 +258,38 @@ SimpleDelegater = SimpleDelegator
def DelegateClass(superclass)
klass = Class.new
methods = superclass.public_instance_methods(true)
- methods -= [
- :__id__, :object_id, :__send__, :public_send, :respond_to?, :send,
- :==, :equal?, :initialize, :method_missing, :__getobj__, :__setobj__,
- :clone, :dup, :marshal_dump, :marshal_load,
- ]
+ methods -= ::Kernel.public_instance_methods(false)
+ methods |= ["to_s","to_a","inspect","==","=~","==="]
klass.module_eval {
- include Delegator::MethodDelegation
+ def initialize(obj) # :nodoc:
+ @_dc_obj = obj
+ end
+ def method_missing(m, *args) # :nodoc:
+ unless @_dc_obj.respond_to?(m)
+ super(m, *args)
+ end
+ @_dc_obj.__send__(m, *args)
+ end
+ def respond_to?(m, include_private = false) # :nodoc:
+ return true if super
+ return @_dc_obj.respond_to?(m, include_private)
+ end
def __getobj__ # :nodoc:
- @delegate_dc_obj
+ @_dc_obj
end
def __setobj__(obj) # :nodoc:
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
- @delegate_dc_obj = obj
+ @_dc_obj = obj
+ end
+ def clone # :nodoc:
+ new = super
+ new.__setobj__(__getobj__.clone)
+ new
+ end
+ def dup # :nodoc:
+ new = super
+ new.__setobj__(__getobj__.clone)
+ new
end
}
for method in methods
@@ -281,9 +297,9 @@ def DelegateClass(superclass)
klass.module_eval <<-EOS, __FILE__, __LINE__+1
def #{method}(*args, &block)
begin
- @delegate_dc_obj.__send__(:#{method}, *args, &block)
- rescue
- raise $!, $@[2..-1]
+ @_dc_obj.__send__(:#{method}, *args, &block)
+ ensure
+ $@.delete_if{|s| ::Delegator::IgnoreBacktracePat =~ s} if $@
end
end
EOS
@@ -307,23 +323,15 @@ if __FILE__ == $0
p ary.class
ary.push 25
p ary
- ary.push 42
- ary.each {|x| p x}
foo = Object.new
def foo.test
25
end
- def foo.iter
- yield self
- end
def foo.error
raise 'this is OK'
end
foo2 = SimpleDelegator.new(foo)
- p foo2
- foo2.instance_eval{print "foo\n"}
p foo.test == foo2.test # => true
- p foo2.iter{[55,true]} # => true
foo2.error # raise error!
end
diff --git a/lib/drb/extserv.rb b/lib/drb/extserv.rb
index af52250518..7da8130c2b 100644
--- a/lib/drb/extserv.rb
+++ b/lib/drb/extserv.rb
@@ -4,21 +4,16 @@
=end
require 'drb/drb'
-require 'monitor'
module DRb
class ExtServ
- include MonitorMixin
include DRbUndumped
def initialize(there, name, server=nil)
- super()
@server = server || DRb::primary_server
@name = name
ro = DRbObject.new(nil, there)
- synchronize do
- @invoker = ro.regist(name, DRbObject.new(self, @server.uri))
- end
+ @invoker = ro.regist(name, DRbObject.new(self, @server.uri))
end
attr_reader :server
@@ -27,13 +22,11 @@ module DRb
end
def stop_service
- synchronize do
- @invoker.unregist(@name)
- server = @server
- @server = nil
- server.stop_service
- true
- end
+ @invoker.unregist(@name)
+ server = @server
+ @server = nil
+ server.stop_service
+ true
end
def alive?
diff --git a/lib/drb/invokemethod.rb b/lib/drb/invokemethod.rb
index 7da8ace88d..412b2ab9b5 100644
--- a/lib/drb/invokemethod.rb
+++ b/lib/drb/invokemethod.rb
@@ -20,6 +20,8 @@ module DRb
end
if jump_error
case jump_error.reason
+ when :retry
+ retry
when :break
break(jump_error.exit_value)
else
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb
index 7d935b4c1f..3e2604af5d 100644
--- a/lib/e2mmap.rb
+++ b/lib/e2mmap.rb
@@ -48,6 +48,8 @@
# Foo.Fail ExistingExceptionClass, arg...
#
#
+fail "Use Ruby 1.1" if VERSION < "1.1"
+
module Exception2MessageMapper
@RCS_ID='-$Id: e2mmap.rb,v 1.10 1999/02/17 12:33:17 keiju Exp keiju $-'
@@ -55,9 +57,15 @@ module Exception2MessageMapper
def E2MM.extend_object(cl)
super
- cl.bind(self) unless cl < E2MM
+ cl.bind(self) unless cl == E2MM
end
+ # backward compatibility
+ def E2MM.extend_to(b)
+ c = eval("self", b)
+ c.extend(self)
+ end
+
def bind(cl)
self.module_eval %[
def Raise(err = nil, *rest)
@@ -80,6 +88,20 @@ module Exception2MessageMapper
end
alias Fail Raise
+ # backward compatibility
+ alias fail! fail
+ def fail(err = nil, *rest)
+ begin
+ E2MM.Fail(self, err, *rest)
+ rescue E2MM::ErrNotRegisteredException
+ super
+ end
+ end
+ class << self
+ public :fail
+ end
+
+
# def_e2message(c, m)
# c: exception
# m: message_form
@@ -137,11 +159,12 @@ module Exception2MessageMapper
#
def E2MM.Raise(klass = E2MM, err = nil, *rest)
if form = e2mm_message(klass, err)
- b = $@.nil? ? caller(1) : $@
+ $! = err.new(sprintf(form, *rest))
+ $@ = caller(1) if $@.nil?
#p $@
#p __FILE__
- b.shift if b[0] =~ /^#{Regexp.quote(__FILE__)}:/
- raise err, sprintf(form, *rest), b
+ $@.shift if $@[0] =~ /^#{Regexp.quote(__FILE__)}:/
+ raise
else
E2MM.Fail E2MM, ErrNotRegisteredException, err.inspect
end
diff --git a/lib/erb.rb b/lib/erb.rb
index 02c96db83d..f1661f98cb 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -240,7 +240,7 @@ class ERB
# Returns revision information for the erb.rb module.
def self.version
- "erb.rb [2.0.4 #{ERB::Revision.split[1]}]"
+ "erb.rb [2.1.0 #{ERB::Revision.split[1]}]"
end
end
@@ -254,11 +254,13 @@ class ERB
end
attr_reader :value
alias :to_s :value
+
+ def empty?
+ @value.empty?
+ end
end
class Scanner # :nodoc:
- SplitRegexp = /(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>)|(\n)/
-
@scanner_map = {}
def self.regist_scanner(klass, trim_mode, percent)
@scanner_map[[trim_mode, percent]] = klass
@@ -283,8 +285,6 @@ class ERB
end
class TrimScanner < Scanner # :nodoc:
- TrimSplitRegexp = /(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>\n)|(%>)|(\n)/
-
def initialize(src, trim_mode, percent)
super
@trim_mode = trim_mode
@@ -304,13 +304,11 @@ class ERB
def scan(&block)
@stag = nil
if @percent
- @src.each_line do |line|
+ @src.each do |line|
percent_line(line, &block)
end
else
- @src.each_line do |line|
- @scan_line.call(line, &block)
- end
+ @scan_line.call(@src, &block)
end
nil
end
@@ -329,57 +327,66 @@ class ERB
end
def scan_line(line)
- line.split(SplitRegexp).each do |token|
- next if token.empty?
- yield(token)
+ line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
+ tokens.each do |token|
+ next if token.empty?
+ yield(token)
+ end
end
end
def trim_line1(line)
- line.split(TrimSplitRegexp).each do |token|
- next if token.empty?
- if token == "%>\n"
- yield('%>')
- yield(:cr)
- break
- end
- yield(token)
+ line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
+ tokens.each do |token|
+ next if token.empty?
+ if token == "%>\n"
+ yield('%>')
+ yield(:cr)
+ else
+ yield(token)
+ end
+ end
end
end
def trim_line2(line)
head = nil
- line.split(TrimSplitRegexp).each do |token|
- next if token.empty?
- head = token unless head
- if token == "%>\n"
- yield('%>')
- if is_erb_stag?(head)
- yield(:cr)
- else
- yield("\n")
- end
- break
- end
- yield(token)
+ line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
+ tokens.each do |token|
+ next if token.empty?
+ head = token unless head
+ if token == "%>\n"
+ yield('%>')
+ if is_erb_stag?(head)
+ yield(:cr)
+ else
+ yield("\n")
+ end
+ head = nil
+ else
+ yield(token)
+ head = nil if token == "\n"
+ end
+ end
end
end
- ExplicitTrimRegexp = /(^[ \t]*<%-)|(-%>\n?\z)|(<%-)|(-%>)|(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>)|(\n)/
def explicit_trim_line(line)
- line.split(ExplicitTrimRegexp).each do |token|
- next if token.empty?
- if @stag.nil? && /[ \t]*<%-/ =~ token
- yield('<%')
- elsif @stag && /-%>\n/ =~ token
- yield('%>')
- yield(:cr)
- elsif @stag && token == '-%>'
- yield('%>')
- else
- yield(token)
- end
- end
+ line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%=|<%#|<%|-%>\n|-%>|%>|\z)/m) do |tokens|
+ tokens.each do |token|
+ next if token.empty?
+ if @stag.nil? && /[ \t]*<%-/ =~ token
+ yield('<%')
+ elsif @stag && token == "-%>\n"
+ yield('%>')
+ yield(:cr)
+ elsif @stag && token == '-%>'
+ yield('%>')
+ else
+ yield(token)
+ end
+ end
+ end
end
ERB_STAG = %w(<%= <%# <%)
@@ -392,11 +399,11 @@ class ERB
class SimpleScanner < Scanner # :nodoc:
def scan
- @src.each_line do |line|
- line.split(SplitRegexp).each do |token|
- next if token.empty?
- yield(token)
- end
+ @src.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
+ tokens.each do |token|
+ next if token.empty?
+ yield(token)
+ end
end
end
end
@@ -407,43 +414,47 @@ class ERB
require 'strscan'
class SimpleScanner2 < Scanner # :nodoc:
def scan
- stag_reg = /(.*?)(<%%|<%=|<%#|<%|\n|\z)/
- etag_reg = /(.*?)(%%>|%>|\n|\z)/
+ stag_reg = /(.*?)(<%%|<%=|<%#|<%|\z)/m
+ etag_reg = /(.*?)(%%>|%>|\z)/m
scanner = StringScanner.new(@src)
while ! scanner.eos?
scanner.scan(@stag ? etag_reg : stag_reg)
- text = scanner[1]
- elem = scanner[2]
- yield(text) unless text.empty?
- yield(elem) unless elem.empty?
+ yield(scanner[1])
+ yield(scanner[2])
end
end
end
Scanner.regist_scanner(SimpleScanner2, nil, false)
class PercentScanner < Scanner # :nodoc:
- def scan
- new_line = true
- stag_reg = /(.*?)(<%%|<%=|<%#|<%|\n|\z)/
- etag_reg = /(.*?)(%%>|%>|\n|\z)/
+ def scan(&blk)
+ stag_reg = /(.*?)(^%%|^%|<%%|<%=|<%#|<%|\z)/m
+ etag_reg = /(.*?)(%%>|%>|\z)/m
scanner = StringScanner.new(@src)
while ! scanner.eos?
- if new_line && @stag.nil?
- if scanner.scan(/%%/)
- yield('%')
- new_line = false
- next
- elsif scanner.scan(/%/)
- yield(PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp))
- next
- end
- end
scanner.scan(@stag ? etag_reg : stag_reg)
- text = scanner[1]
+ yield(scanner[1])
+
elem = scanner[2]
- yield(text) unless text.empty?
- yield(elem) unless elem.empty?
- new_line = (elem == "\n")
+ if elem == '%%'
+ yield('%')
+ inline_scan(scanner.scan(/.*?(\n|\z)/), &blk)
+ elsif elem == '%'
+ yield(PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp))
+ else
+ yield(elem)
+ end
+ end
+ end
+
+ def inline_scan(line)
+ stag_reg = /(.*?)(<%%|<%=|<%#|<%|\z)/m
+ etag_reg = /(.*?)(%%>|%>|\z)/m
+ scanner = StringScanner.new(line)
+ while ! scanner.eos?
+ scanner.scan(@stag ? etag_reg : stag_reg)
+ yield(scanner[1])
+ yield(scanner[2])
end
end
end
@@ -451,31 +462,21 @@ class ERB
class ExplicitScanner < Scanner # :nodoc:
def scan
- new_line = true
- stag_reg = /(.*?)(<%%|<%=|<%#|<%-|<%|\n|\z)/
- etag_reg = /(.*?)(%%>|-%>|%>|\n|\z)/
+ stag_reg = /(.*?)(^[ \t]*<%-|<%%|<%=|<%#|<%-|<%|\z)/m
+ etag_reg = /(.*?)(%%>|-%>|%>|\z)/m
scanner = StringScanner.new(@src)
while ! scanner.eos?
- if new_line && @stag.nil? && scanner.scan(/[ \t]*<%-/)
- yield('<%')
- new_line = false
- next
- end
scanner.scan(@stag ? etag_reg : stag_reg)
- text = scanner[1]
+ yield(scanner[1])
+
elem = scanner[2]
- new_line = (elem == "\n")
- yield(text) unless text.empty?
- if elem == '-%>'
+ if /[ \t]*<%-/ =~ elem
+ yield('<%')
+ elsif elem == '-%>'
yield('%>')
- if scanner.scan(/(\n|\z)/)
- yield(:cr)
- new_line = true
- end
- elsif elem == '<%-'
- yield('<%')
+ yield(:cr) if scanner.scan(/(\n|\z)/)
else
- yield(elem) unless elem.empty?
+ yield(elem)
end
end
end
@@ -516,16 +517,27 @@ class ERB
end
end
+ def content_dump(s)
+ n = s.count("\n")
+ if n > 0
+ s.dump + "\n" * n
+ else
+ s.dump
+ end
+ end
+
def compile(s)
out = Buffer.new(self)
content = ''
scanner = make_scanner(s)
scanner.scan do |token|
+ next if token.nil?
+ next if token == ''
if scanner.stag.nil?
case token
when PercentLine
- out.push("#{@put_cmd} #{content.dump}") if content.size > 0
+ out.push("#{@put_cmd} #{content_dump(content)}") if content.size > 0
content = ''
out.push(token.to_s)
out.cr
@@ -533,12 +545,11 @@ class ERB
out.cr
when '<%', '<%=', '<%#'
scanner.stag = token
- out.push("#{@put_cmd} #{content.dump}") if content.size > 0
+ out.push("#{@put_cmd} #{content_dump(content)}") if content.size > 0
content = ''
when "\n"
content << "\n"
- out.push("#{@put_cmd} #{content.dump}")
- out.cr
+ out.push("#{@put_cmd} #{content_dump(content)}")
content = ''
when '<%%'
content << '<%'
@@ -560,7 +571,7 @@ class ERB
when '<%='
out.push("#{@insert_cmd}((#{content}).to_s)")
when '<%#'
- # out.push("# #{content.dump}")
+ # out.push("# #{content_dump(content)}")
end
scanner.stag = nil
content = ''
@@ -571,7 +582,7 @@ class ERB
end
end
end
- out.push("#{@put_cmd} #{content.dump}") if content.size > 0
+ out.push("#{@put_cmd} #{content_dump(content)}") if content.size > 0
out.close
out.script
end
@@ -658,7 +669,7 @@ class ERB
#
# def build
# b = binding
- # # create and run templates, filling member data variebles
+ # # create and run templates, filling member data variables
# ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), 0, "", "@product").result b
# <%= PRODUCT[:name] %>
# <%= PRODUCT[:desc] %>
@@ -734,29 +745,58 @@ class ERB
#
def result(b=TOPLEVEL_BINDING)
if @safe_level
- th = Thread.start {
+ proc {
$SAFE = @safe_level
eval(@src, b, (@filename || '(erb)'), 1)
- }
- return th.value
+ }.call
else
- return eval(@src, b, (@filename || '(erb)'), 1)
+ eval(@src, b, (@filename || '(erb)'), 1)
end
end
- def def_method(mod, methodname, fname='(ERB)') # :nodoc:
+ # Define _methodname_ as instance method of _mod_ from compiled ruby source.
+ #
+ # example:
+ # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
+ # erb = ERB.new(File.read(filename))
+ # erb.def_method(MyClass, 'render(arg1, arg2)', filename)
+ # print MyClass.new.render('foo', 123)
+ def def_method(mod, methodname, fname='(ERB)')
mod.module_eval("def #{methodname}\n" + self.src + "\nend\n", fname, 0)
end
- def def_module(methodname='erb') # :nodoc:
+ # Create unnamed module, define _methodname_ as instance method of it, and return it.
+ #
+ # example:
+ # filename = 'example.rhtml' # 'arg1' and 'arg2' are used in example.rhtml
+ # erb = ERB.new(File.read(filename))
+ # erb.filename = filename
+ # MyModule = erb.def_module('render(arg1, arg2)')
+ # class MyClass
+ # include MyModule
+ # end
+ def def_module(methodname='erb')
mod = Module.new
- def_method(mod, methodname)
+ def_method(mod, methodname, @filename || '(ERB)')
mod
end
- def def_class(superklass=Object, methodname='result') # :nodoc:
+ # Define unnamed class which has _methodname_ as instance method, and return it.
+ #
+ # example:
+ # class MyClass_
+ # def initialize(arg1, arg2)
+ # @arg1 = arg1; @arg2 = arg2
+ # end
+ # end
+ # filename = 'example.rhtml' # @arg1 and @arg2 are used in example.rhtml
+ # erb = ERB.new(File.read(filename))
+ # erb.filename = filename
+ # MyClass = erb.def_class(MyClass_, 'render()')
+ # print MyClass.new('foo', 123).render()
+ def def_class(superklass=Object, methodname='result')
cls = Class.new(superklass)
- def_method(cls, methodname)
+ def_method(cls, methodname, @filename || '(ERB)')
cls
end
end
@@ -810,15 +850,45 @@ end
#--
# ERB::DefMethod
class ERB
- module DefMethod # :nodoc:
+ # Utility module to define eRuby script as instance method.
+ #
+ # === Example
+ #
+ # example.rhtml:
+ # <% for item in @items %>
+ # <b><%= item %></b>
+ # <% end %>
+ #
+ # example.rb:
+ # require 'erb'
+ # class MyClass
+ # extend ERB::DefMethod
+ # def_erb_method('render()', 'example.rhtml')
+ # def initialize(items)
+ # @items = items
+ # end
+ # end
+ # print MyClass.new([10,20,30]).render()
+ #
+ # result:
+ #
+ # <b>10</b>
+ #
+ # <b>20</b>
+ #
+ # <b>30</b>
+ #
+ module DefMethod
public
- def def_erb_method(methodname, erb)
- if erb.kind_of? String
- fname = erb
- File.open(fname) {|f| erb = ERB.new(f.read) }
- erb.def_method(self, methodname, fname)
+ # define _methodname_ as instance method of current module, using ERB object or eRuby file
+ def def_erb_method(methodname, erb_or_fname)
+ if erb_or_fname.kind_of? String
+ fname = erb_or_fname
+ erb = ERB.new(File.read(fname))
+ erb.def_method(self, methodname, fname)
else
- erb.def_method(self, methodname)
+ erb = erb_or_fname
+ erb.def_method(self, methodname, erb.filename || '(ERB)')
end
end
module_function :def_erb_method
diff --git a/lib/eregex.rb b/lib/eregex.rb
new file mode 100644
index 0000000000..cc7a7f6f46
--- /dev/null
+++ b/lib/eregex.rb
@@ -0,0 +1,37 @@
+# this is just a proof of concept toy.
+
+class RegOr
+ def initialize(re1, re2)
+ @re1 = re1
+ @re2 = re2
+ end
+
+ def =~ (str)
+ @re1 =~ str or @re2 =~ str
+ end
+end
+
+class RegAnd
+ def initialize(re1, re2)
+ @re1 = re1
+ @re2 = re2
+ end
+
+ def =~ (str)
+ @re1 =~ str and @re2 =~ str
+ end
+end
+
+class Regexp
+ def |(other)
+ RegOr.new(self, other)
+ end
+ def &(other)
+ RegAnd.new(self, other)
+ end
+end
+
+if __FILE__ == $0
+ p "abc" =~ /b/|/c/
+ p "abc" =~ /b/&/c/
+end
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 6152c3d306..3fdb6cbfe6 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1,7 +1,7 @@
#
# = fileutils.rb
#
-# Copyright (c) 2000-2007 Minero Aoki
+# Copyright (c) 2000-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
@@ -212,11 +212,11 @@ module FileUtils
stack.push path
path = File.dirname(path)
end
- stack.reverse_each do |dir|
+ stack.reverse_each do |path|
begin
- fu_mkdir dir, options[:mode]
+ fu_mkdir path, options[:mode]
rescue SystemCallError => err
- raise unless File.directory?(dir)
+ raise unless File.directory?(path)
end
end
end
@@ -418,6 +418,7 @@ module FileUtils
fu_check_options options, OPT_TABLE['cp_r']
fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
+ options[:dereference_root] = true unless options.key?(:dereference_root)
fu_each_src_dest(src, dest) do |s, d|
copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination]
end
@@ -685,7 +686,7 @@ module FileUtils
end
# is a directory.
parent_st = File.stat(File.dirname(fullpath))
- unless parent_st.world_writable?
+ unless fu_world_writable?(parent_st)
remove_entry path, force
return
end
@@ -723,6 +724,11 @@ module FileUtils
end
module_function :remove_entry_secure
+ def fu_world_writable?(st)
+ (st.mode & 0002) != 0
+ end
+ private_module_function :fu_world_writable?
+
def fu_have_symlink? #:nodoc
File.symlink nil, nil
rescue NotImplementedError
@@ -1097,7 +1103,7 @@ module FileUtils
def path
if @path
- File.path(@path)
+ @path.to_str
else
join(@prefix, @rel)
end
@@ -1224,9 +1230,6 @@ module FileUtils
when file?
copy_file dest
when directory?
- if !File.exist?(dest) and /^#{Regexp.quote(path)}/ =~ File.dirname(dest)
- raise ArgumentError, "cannot copy directory %s to itself %s" % [path, dest]
- end
begin
Dir.mkdir dest
rescue
@@ -1375,14 +1378,14 @@ module FileUtils
end
def join(dir, base)
- return File.path(dir) if not base or base == '.'
- return File.path(base) if not dir or dir == '.'
+ return dir.to_str if not base or base == '.'
+ return base.to_str if not dir or dir == '.'
File.join(dir, base)
end
end # class Entry_
def fu_list(arg) #:nodoc:
- [arg].flatten.map {|path| File.path(path) }
+ [arg].flatten.map {|path| path.to_str }
end
private_module_function :fu_list
@@ -1395,17 +1398,17 @@ module FileUtils
private_module_function :fu_each_src_dest
def fu_each_src_dest0(src, dest) #:nodoc:
- if tmp = Array.try_convert(src)
- tmp.each do |s|
- s = File.path(s)
+ if src.is_a?(Array)
+ src.each do |s|
+ s = s.to_str
yield s, File.join(dest, File.basename(s))
end
else
- src = File.path(src)
+ src = src.to_str
if File.directory?(dest)
yield src, File.join(dest, File.basename(src))
else
- yield src, File.path(dest)
+ yield src, dest.to_str
end
end
end
@@ -1439,8 +1442,8 @@ module FileUtils
private_module_function :fu_check_options
def fu_update_option(args, new) #:nodoc:
- if tmp = Hash.try_convert(args.last)
- args[-1] = tmp.dup.update(new)
+ if args.last.is_a?(Hash)
+ args[-1] = args.last.dup.update(new)
else
args.push new
end
@@ -1506,8 +1509,8 @@ module FileUtils
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
end
- METHODS = singleton_methods() - [:private_module_function,
- :commands, :options, :have_option?, :options_of, :collect_method]
+ METHODS = singleton_methods() - %w( private_module_function
+ commands options have_option? options_of collect_method )
#
# This module has all methods of FileUtils module, but it outputs messages
diff --git a/lib/finalize.rb b/lib/finalize.rb
new file mode 100644
index 0000000000..9b6b302cac
--- /dev/null
+++ b/lib/finalize.rb
@@ -0,0 +1,193 @@
+#--
+# finalizer.rb -
+# $Release Version: 0.3$
+# $Revision: 1.4 $
+# $Date: 1998/02/27 05:34:33 $
+# by Keiju ISHITSUKA
+#++
+#
+# Usage:
+#
+# add dependency R_method(obj, dependant)
+# add(obj, dependant, method = :finalize, *opt)
+# add_dependency(obj, dependant, method = :finalize, *opt)
+#
+# delete dependency R_method(obj, dependant)
+# delete(obj_or_id, dependant, method = :finalize)
+# delete_dependency(obj_or_id, dependant, method = :finalize)
+#
+# delete dependency R_*(obj, dependant)
+# delete_all_dependency(obj_or_id, dependant)
+#
+# delete dependency R_method(*, dependant)
+# delete_by_dependant(dependant, method = :finalize)
+#
+# delete dependency R_*(*, dependant)
+# delete_all_by_dependant(dependant)
+#
+# delete all dependency R_*(*, *)
+# delete_all
+#
+# finalize the dependant connected by dependency R_method(obj, dependtant).
+# finalize(obj_or_id, dependant, method = :finalize)
+# finalize_dependency(obj_or_id, dependant, method = :finalize)
+#
+# finalize all dependants connected by dependency R_*(obj, dependtant).
+# finalize_all_dependency(obj_or_id, dependant)
+#
+# finalize the dependant connected by dependency R_method(*, dependtant).
+# finalize_by_dependant(dependant, method = :finalize)
+#
+# finalize all dependants connected by dependency R_*(*, dependant).
+# finalize_all_by_dependant(dependant)
+#
+# finalize all dependency registered to the Finalizer.
+# finalize_all
+#
+# stop invoking Finalizer on GC.
+# safe{..}
+#
+
+module Finalizer
+ RCS_ID='-$Id: finalize.rb,v 1.4 1998/02/27 05:34:33 keiju Exp keiju $-'
+
+ class <<self
+ # @dependency: {id => [[dependant, method, *opt], ...], ...}
+
+ # add dependency R_method(obj, dependant)
+ def add_dependency(obj, dependant, method = :finalize, *opt)
+ ObjectSpace.call_finalizer(obj)
+ method = method.intern unless method.kind_of?(Integer)
+ assoc = [dependant, method].concat(opt)
+ if dep = @dependency[obj.object_id]
+ dep.push assoc
+ else
+ @dependency[obj.object_id] = [assoc]
+ end
+ end
+ alias add add_dependency
+
+ # delete dependency R_method(obj, dependant)
+ def delete_dependency(id, dependant, method = :finalize)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assoc in @dependency[id]
+ assoc.delete_if do
+ |d, m, *o|
+ d == dependant && m == method
+ end
+ @dependency.delete(id) if assoc.empty?
+ end
+ end
+ alias delete delete_dependency
+
+ # delete dependency R_*(obj, dependant)
+ def delete_all_dependency(id, dependant)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assoc in @dependency[id]
+ assoc.delete_if do
+ |d, m, *o|
+ d == dependant
+ end
+ @dependency.delete(id) if assoc.empty?
+ end
+ end
+
+ # delete dependency R_method(*, dependant)
+ def delete_by_dependant(dependant, method = :finalize)
+ method = method.intern unless method.kind_of?(Integer)
+ for id in @dependency.keys
+ delete(id, dependant, method)
+ end
+ end
+
+ # delete dependency R_*(*, dependant)
+ def delete_all_by_dependant(dependant)
+ for id in @dependency.keys
+ delete_all_dependency(id, dependant)
+ end
+ end
+
+ # finalize the depandant connected by dependency R_method(obj, dependtant)
+ def finalize_dependency(id, dependant, method = :finalize)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assocs in @dependency[id]
+ assocs.delete_if do
+ |d, m, *o|
+ d.send(m, id, *o) if ret = d == dependant && m == method
+ ret
+ end
+ @dependency.delete(id) if assoc.empty?
+ end
+ end
+ alias finalize finalize_dependency
+
+ # finalize all dependants connected by dependency R_*(obj, dependtant)
+ def finalize_all_dependency(id, dependant)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assoc in @dependency[id]
+ assoc.delete_if do
+ |d, m, *o|
+ d.send(m, id, *o) if ret = d == dependant
+ end
+ @dependency.delete(id) if assoc.empty?
+ end
+ end
+
+ # finalize the dependant connected by dependency R_method(*, dependtant)
+ def finalize_by_dependant(dependant, method = :finalize)
+ method = method.intern unless method.kind_of?(Integer)
+ for id in @dependency.keys
+ finalize(id, dependant, method)
+ end
+ end
+
+ # finalize all dependants connected by dependency R_*(*, dependtant)
+ def finalize_all_by_dependant(dependant)
+ for id in @dependency.keys
+ finalize_all_dependency(id, dependant)
+ end
+ end
+
+ # finalize all dependants registered to the Finalizer.
+ def finalize_all
+ for id, assocs in @dependency
+ for dependant, method, *opt in assocs
+ dependant.send(method, id, *opt)
+ end
+ assocs.clear
+ end
+ end
+
+ # method to call finalize_* safely.
+ def safe
+ old_status = Thread.critical
+ Thread.critical = true
+ ObjectSpace.remove_finalizer(@proc)
+ begin
+ yield
+ ensure
+ ObjectSpace.add_finalizer(@proc)
+ Thread.critical = old_status
+ end
+ end
+
+ private
+
+ # registering function to ObjectSpace#add_finalizer
+ def final_of(id)
+ if assocs = @dependency.delete(id)
+ for dependant, method, *opt in assocs
+ dependant.send(method, id, *opt)
+ end
+ end
+ end
+
+ end
+ @dependency = Hash.new
+ @proc = proc{|id| final_of(id)}
+ ObjectSpace.add_finalizer(@proc)
+end
diff --git a/lib/find.rb b/lib/find.rb
index 06ac9e2c0c..0d22dd62d6 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -33,7 +33,7 @@ module Find
# See the +Find+ module documentation for an example.
#
def find(*paths) # :yield: path
- paths.collect!{|d| raise Errno::ENOENT unless File.exist?(d); d.dup}
+ paths.collect!{|d| d.dup}
while file = paths.shift
catch(:prune) do
yield file.dup.taint
@@ -57,7 +57,7 @@ module Find
d.close
end
end
- rescue Errno::ENOENT, Errno::EACCES
+ rescue Errno::ENOENT, Errno::EACCES
end
end
end
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 1889f44109..cc6e4ee418 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -1,18 +1,17 @@
+# = forwardable - Support for the Delegation Pattern
#
-# forwardable.rb -
-# $Release Version: 1.1$
-# $Revision$
-# $Date$
-# by Keiju ISHITSUKA(keiju@ishitsuka.com)
-# original definition by delegator.rb
-# Revised by Daniel J. Berger with suggestions from Florian Gross.
+# $Release Version: 1.1$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
-# Documentation by James Edward Gray II and Gavin Sinclair
+# Documentation by James Edward Gray II and Gavin Sinclair
#
# == Introduction
#
# This library allows you delegate method calls to an object, on a method by
-# method basis.
+# method basis. You can use Forwardable to setup this delegation at the class
+# level, or SingleForwardable to handle it at the object level.
#
# == Notes
#
@@ -39,7 +38,7 @@
# @q = [ ] # prepare delegate object
# end
#
-# # setup prefered interface, enq() and deq()...
+# # setup preferred interface, enq() and deq()...
# def_delegator :@q, :push, :enq
# def_delegator :@q, :shift, :deq
#
@@ -71,10 +70,10 @@
# Ruby
# nil
#
-# Forwardable can be used to setup delegation at the object level as well.
+# === SingleForwardable
#
# printer = String.new
-# printer.extend Forwardable # prepare object for delegation
+# printer.extend SingleForwardable # prepare object for delegation
# printer.def_delegator "STDOUT", "puts" # add delegation for STDOUT.puts()
# printer.puts "Howdy!"
#
@@ -104,31 +103,15 @@
# # extend Forwardable, but we did that above
# def_delegators :@records, :size, :<<, :map
# end
-# f = Foo.new
-# f.printf ...
-# f.gets
-# f.content_at(1)
#
# Also see the example at forwardable.rb.
-
+#
module Forwardable
- FORWARDABLE_VERSION = "1.0.0"
-
- # Takes a hash as its argument. The key is a symbol or an array of
- # symbols. These symbols correspond to method names. The value is
- # the accessor to which the methods will be delegated.
- #
- # :call-seq:
- # delegate method => accessor
- # delegate [method, method, ...] => accessor
- #
- def delegate(hash)
- hash.each{ |methods, accessor|
- methods = methods.to_s unless methods.respond_to?(:each)
- methods.each{ |method|
- def_instance_delegator(accessor, method)
- }
- }
+
+ @debug = nil
+ class<<self
+ # force Forwardable to show up in stack backtraces of delegated methods
+ attr_accessor :debug
end
#
@@ -142,12 +125,12 @@ module Forwardable
# def_delegator :@records, :<<
# def_delegator :@records, :map
#
+ # See the examples at Forwardable and forwardable.rb.
+ #
def def_instance_delegators(accessor, *methods)
- methods.delete("__send__")
- methods.delete("__id__")
- methods.each{ |method|
+ for method in methods
def_instance_delegator(accessor, method)
- }
+ end
end
#
@@ -155,24 +138,81 @@ module Forwardable
# the method of the same name in _obj_). If _new_name_ is
# provided, it is used as the name for the delegate method.
#
+ # See the examples at Forwardable and forwardable.rb.
+ #
def def_instance_delegator(accessor, method, ali = method)
- str = %Q{
+ accessor = accessor.id2name if accessor.kind_of?(Integer)
+ method = method.id2name if method.kind_of?(Integer)
+ ali = ali.id2name if ali.kind_of?(Integer)
+
+ module_eval(<<-EOS, "(__FORWARDABLE__)", 1)
def #{ali}(*args, &block)
- #{accessor}.send(:#{method}, *args, &block)
+ begin
+ #{accessor}.__send__(:#{method}, *args, &block)
+ rescue Exception
+ $@.delete_if{|s| /^\\(__FORWARDABLE__\\):/ =~ s} unless Forwardable::debug
+ Kernel::raise
+ end
end
- }
-
- # If it's not a class or module, it's an instance
- begin
- module_eval(str)
- rescue
- instance_eval(str)
- end
+ EOS
end
alias def_delegators def_instance_delegators
alias def_delegator def_instance_delegator
end
-# compatibility
-SingleForwardable = Forwardable
+#
+# The SingleForwardable module provides delegation of specified
+# methods to a designated object, using the methods #def_delegator
+# and #def_delegators. This module is similar to Forwardable, but it works on
+# objects themselves, instead of their defining classes.
+#
+# Also see the example at forwardable.rb.
+#
+module SingleForwardable
+ #
+ # Shortcut for defining multiple delegator methods, but with no
+ # provision for using a different name. The following two code
+ # samples have the same effect:
+ #
+ # single_forwardable.def_delegators :@records, :size, :<<, :map
+ #
+ # single_forwardable.def_delegator :@records, :size
+ # single_forwardable.def_delegator :@records, :<<
+ # single_forwardable.def_delegator :@records, :map
+ #
+ # See the example at forwardable.rb.
+ #
+ def def_singleton_delegators(accessor, *methods)
+ for method in methods
+ def_singleton_delegator(accessor, method)
+ end
+ end
+
+ #
+ # Defines a method _method_ which delegates to _obj_ (i.e. it calls
+ # the method of the same name in _obj_). If _new_name_ is
+ # provided, it is used as the name for the delegate method.
+ #
+ # See the example at forwardable.rb.
+ #
+ def def_singleton_delegator(accessor, method, ali = method)
+ accessor = accessor.id2name if accessor.kind_of?(Integer)
+ method = method.id2name if method.kind_of?(Integer)
+ ali = ali.id2name if ali.kind_of?(Integer)
+
+ instance_eval(<<-EOS, "(__FORWARDABLE__)", 1)
+ def #{ali}(*args, &block)
+ begin
+ #{accessor}.__send__(:#{method}, *args,&block)
+ rescue Exception
+ $@.delete_if{|s| /^\\(__FORWARDABLE__\\):/ =~ s} unless Forwardable::debug
+ Kernel::raise
+ end
+ end
+ EOS
+ end
+
+ alias def_delegators def_singleton_delegators
+ alias def_delegator def_singleton_delegator
+end
diff --git a/lib/ftools.rb b/lib/ftools.rb
new file mode 100644
index 0000000000..5f082331fb
--- /dev/null
+++ b/lib/ftools.rb
@@ -0,0 +1,261 @@
+#
+# = ftools.rb: Extra tools for the File class
+#
+# Author:: WATANABE, Hirofumi
+# Documentation:: Zachary Landau
+#
+# This library can be distributed under the terms of the Ruby license.
+# You can freely distribute/modify this library.
+#
+# It is included in the Ruby standard library.
+#
+# == Description
+#
+# ftools adds several (class, not instance) methods to the File class, for
+# copying, moving, deleting, installing, and comparing files, as well as
+# creating a directory path. See the File class for details.
+#
+# FileUtils contains all or nearly all the same functionality and more, and
+# is a recommended option over ftools
+#
+# When you
+#
+# require 'ftools'
+#
+# then the File class aquires some utility methods for copying, moving, and
+# deleting files, and more.
+#
+# See the method descriptions below, and consider using FileUtils as it is
+# more comprehensive.
+#
+class File
+end
+
+class << File
+
+ BUFSIZE = 8 * 1024
+
+ #
+ # If +to+ is a valid directory, +from+ will be appended to +to+, adding
+ # and escaping backslashes as necessary. Otherwise, +to+ will be returned.
+ # Useful for appending +from+ to +to+ only if the filename was not specified
+ # in +to+.
+ #
+ def catname(from, to)
+ if directory? to
+ join to.sub(%r([/\\]$), ''), basename(from)
+ else
+ to
+ end
+ end
+
+ #
+ # Copies a file +from+ to +to+. If +to+ is a directory, copies +from+
+ # to <tt>to/from</tt>.
+ #
+ def syscopy(from, to)
+ to = catname(from, to)
+
+ fmode = stat(from).mode
+ tpath = to
+ not_exist = !exist?(tpath)
+
+ from = open(from, "rb")
+ to = open(to, "wb")
+
+ begin
+ while true
+ to.syswrite from.sysread(BUFSIZE)
+ end
+ rescue EOFError
+ ret = true
+ rescue
+ ret = false
+ ensure
+ to.close
+ from.close
+ end
+ chmod(fmode, tpath) if not_exist
+ ret
+ end
+
+ #
+ # Copies a file +from+ to +to+ using #syscopy. If +to+ is a directory,
+ # copies +from+ to <tt>to/from</tt>. If +verbose+ is true, <tt>from -> to</tt>
+ # is printed.
+ #
+ def copy(from, to, verbose = false)
+ $stderr.print from, " -> ", catname(from, to), "\n" if verbose
+ syscopy from, to
+ end
+
+ alias cp copy
+
+ #
+ # Moves a file +from+ to +to+ using #syscopy. If +to+ is a directory,
+ # copies from +from+ to <tt>to/from</tt>. If +verbose+ is true, <tt>from ->
+ # to</tt> is printed.
+ #
+ def move(from, to, verbose = false)
+ to = catname(from, to)
+ $stderr.print from, " -> ", to, "\n" if verbose
+
+ if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and file? to
+ unlink to
+ end
+ fstat = stat(from)
+ begin
+ rename from, to
+ rescue
+ begin
+ symlink readlink(from), to and unlink from
+ rescue
+ from_stat = stat(from)
+ syscopy from, to and unlink from
+ utime(from_stat.atime, from_stat.mtime, to)
+ begin
+ chown(fstat.uid, fstat.gid, to)
+ rescue
+ end
+ end
+ end
+ end
+
+ alias mv move
+
+ #
+ # Returns +true+ if and only if the contents of files +from+ and +to+ are
+ # identical. If +verbose+ is +true+, <tt>from <=> to</tt> is printed.
+ #
+ def compare(from, to, verbose = false)
+ $stderr.print from, " <=> ", to, "\n" if verbose
+
+ return false if stat(from).size != stat(to).size
+
+ from = open(from, "rb")
+ to = open(to, "rb")
+
+ ret = false
+ fr = tr = ''
+
+ begin
+ while fr == tr
+ fr = from.read(BUFSIZE)
+ if fr
+ tr = to.read(fr.size)
+ else
+ ret = to.read(BUFSIZE)
+ ret = !ret || ret.length == 0
+ break
+ end
+ end
+ rescue
+ ret = false
+ ensure
+ to.close
+ from.close
+ end
+ ret
+ end
+
+ alias cmp compare
+
+ #
+ # Removes a list of files. Each parameter should be the name of the file to
+ # delete. If the last parameter isn't a String, verbose mode will be enabled.
+ # Returns the number of files deleted.
+ #
+ def safe_unlink(*files)
+ verbose = if files[-1].is_a? String then false else files.pop end
+ files.each do |file|
+ begin
+ unlink file
+ $stderr.print "removing ", file, "\n" if verbose
+ rescue Errno::EACCES # for Windows
+ continue if symlink? file
+ begin
+ mode = stat(file).mode
+ o_chmod mode | 0200, file
+ unlink file
+ $stderr.print "removing ", file, "\n" if verbose
+ rescue
+ o_chmod mode, file rescue nil
+ end
+ rescue
+ end
+ end
+ end
+
+ alias rm_f safe_unlink
+
+ #
+ # Creates a directory and all its parent directories.
+ # For example,
+ #
+ # File.makedirs '/usr/lib/ruby'
+ #
+ # causes the following directories to be made, if they do not exist.
+ # * /usr
+ # * /usr/lib
+ # * /usr/lib/ruby
+ #
+ # You can pass several directories, each as a parameter. If the last
+ # parameter isn't a String, verbose mode will be enabled.
+ #
+ def makedirs(*dirs)
+ verbose = if dirs[-1].is_a? String then false else dirs.pop end
+ mode = 0755
+ for dir in dirs
+ parent = dirname(dir)
+ next if parent == dir or directory? dir
+ makedirs parent unless directory? parent
+ $stderr.print "mkdir ", dir, "\n" if verbose
+ if basename(dir) != ""
+ begin
+ Dir.mkdir dir, mode
+ rescue SystemCallError
+ raise unless directory? dir
+ end
+ end
+ end
+ end
+
+ alias mkpath makedirs
+
+ alias o_chmod chmod
+
+ vsave, $VERBOSE = $VERBOSE, false
+
+ #
+ # Changes permission bits on +files+ to the bit pattern represented
+ # by +mode+. If the last parameter isn't a String, verbose mode will
+ # be enabled.
+ #
+ # File.chmod 0755, 'somecommand'
+ # File.chmod 0644, 'my.rb', 'your.rb', true
+ #
+ def chmod(mode, *files)
+ verbose = if files[-1].is_a? String then false else files.pop end
+ $stderr.printf "chmod %04o %s\n", mode, files.join(" ") if verbose
+ o_chmod mode, *files
+ end
+ $VERBOSE = vsave
+
+ #
+ # If +src+ is not the same as +dest+, copies it and changes the permission
+ # mode to +mode+. If +dest+ is a directory, destination is <tt>dest/src</tt>.
+ # If +mode+ is not set, default is used. If +verbose+ is set to true, the
+ # name of each file copied will be printed.
+ #
+ def install(from, to, mode = nil, verbose = false)
+ to = catname(from, to)
+ unless exist? to and cmp from, to
+ safe_unlink to if exist? to
+ cp from, to, verbose
+ chmod mode, to, verbose if mode
+ end
+ end
+
+end
+
+# vi:set sw=2:
diff --git a/lib/generator.rb b/lib/generator.rb
index 9924ce3b0c..dbdd0f40a9 100644
--- a/lib/generator.rb
+++ b/lib/generator.rb
@@ -28,6 +28,9 @@
# Generator converts an internal iterator (i.e. an Enumerable object)
# to an external iterator.
#
+# Note that it is not very fast since it is implemented using
+# continuations, which are currently slow.
+#
# == Example
#
# require 'generator'
@@ -65,105 +68,137 @@ class Generator
# itself, and expected to call the +yield+ method for each element.
def initialize(enum = nil, &block)
if enum
- @block = proc{|g| enum.each{|value| g.yield value}}
+ @block = proc { |g|
+ enum.each { |x| g.yield x }
+ }
else
@block = block
end
+
@index = 0
@queue = []
- @main_thread = nil
- @loop_thread.kill if defined?(@loop_thread)
- @loop_thread = Thread.new do
- Thread.stop
- begin
- @block.call(self)
- rescue
- @main_thread.raise $!
- ensure
- @main_thread.wakeup
- end
+ @cont_next = @cont_yield = @cont_endp = nil
+
+ if @cont_next = callcc { |c| c }
+ @block.call(self)
+
+ @cont_endp.call(nil) if @cont_endp
end
- Thread.pass until @loop_thread.stop?
+
self
end
# Yields an element to the generator.
def yield(value)
- if Thread.current != @loop_thread
- raise "should be called in Generator.new{|g| ... }"
- end
- Thread.critical = true
- begin
+ if @cont_yield = callcc { |c| c }
@queue << value
- @main_thread.wakeup
- Thread.stop
- ensure
- Thread.critical = false
+ @cont_next.call(nil)
end
+
self
end
# Returns true if the generator has reached the end.
- def end?
- if @queue.empty?
- if @main_thread
- raise "should not be called in Generator.new{|g| ... }"
- end
- Thread.critical = true
- begin
- @main_thread = Thread.current
- @loop_thread.wakeup
- Thread.stop
- rescue ThreadError
- # ignore
- ensure
- @main_thread = nil
- Thread.critical = false
- end
+ def end?()
+ if @cont_endp = callcc { |c| c }
+ @cont_yield.nil? && @queue.empty?
+ else
+ @queue.empty?
end
- @queue.empty?
end
# Returns true if the generator has not reached the end yet.
- def next?
+ def next?()
!end?
end
# Returns the current index (position) counting from zero.
- def index
+ def index()
@index
end
# Returns the current index (position) counting from zero.
- def pos
+ def pos()
@index
end
# Returns the element at the current position and moves forward.
- def next
- raise EOFError.new("no more elements available") if end?
+ def next()
+ if end?
+ raise EOFError, "no more elements available"
+ end
+
+ if @cont_next = callcc { |c| c }
+ @cont_yield.call(nil) if @cont_yield
+ end
+
@index += 1
+
@queue.shift
end
# Returns the element at the current position.
- def current
- raise EOFError.new("no more elements available") if end?
+ def current()
+ if @queue.empty?
+ raise EOFError, "no more elements available"
+ end
+
@queue.first
end
# Rewinds the generator.
- def rewind
+ def rewind()
initialize(nil, &@block) if @index.nonzero?
+
self
end
# Rewinds the generator and enumerates the elements.
def each
rewind
+
until end?
yield self.next
end
+
+ self
+ end
+end
+
+class Enumerable::Enumerator
+ def __generator
+ @generator ||= Generator.new(self)
+ end
+ private :__generator
+
+ # 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: This feature internally uses Generator, which uses callcc
+ # to stop and resume enumeration to fetch each value. Use with care
+ # and be aware of the performance loss.
+ def next
+ g = __generator
+ return g.next unless g.end?
+
+ g.rewind
+ raise StopIteration, 'iteration reached at end'
+ end
+
+ # call-seq:
+ # e.rewind => e
+ #
+ # Rewinds the enumeration sequence by the next method.
+ def rewind
+ __generator.rewind
self
end
end
@@ -246,8 +281,6 @@ end
__END__
-__END__
-
require 'test/unit'
class TC_Generator < Test::Unit::TestCase
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index ba9ca3742a..4d004419b1 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -76,7 +76,7 @@
# end
#
# dir = ARGV.shift
-#
+#
# Dir.chdir(dir)
# for i in (1..repetitions)
# print "Hello"
@@ -111,7 +111,7 @@ class GetoptLong
# Error types.
#
class Error < StandardError; end
- class AmbiguousOption < Error; end
+ class AmbigousOption < Error; end
class NeedlessArgument < Error; end
class MissingArgument < Error; end
class InvalidOption < Error; end
@@ -289,8 +289,14 @@ class GetoptLong
@canonical_names.clear
@argument_flags.clear
- arguments.each do |*arg|
- arg = arg.first # TODO: YARV Hack
+ arguments.each do |arg|
+ #
+ # Each argument must be an Array.
+ #
+ if !arg.is_a?(Array)
+ raise ArgumentError, "the option list contains non-Array argument"
+ end
+
#
# Find an argument flag and it set to `argument_flag'.
#
@@ -303,7 +309,6 @@ class GetoptLong
argument_flag = i
end
end
-
raise ArgumentError, "no argument-flag" if argument_flag == nil
canonical_name = nil
@@ -383,7 +388,7 @@ class GetoptLong
end
#
- # Set an error (a protected method).
+ # Set an error (protected).
#
def set_error(type, message)
$deferr.print("#{$0}: #{message}\n") if !@quiet
@@ -492,16 +497,16 @@ class GetoptLong
# The option `option_name' is not registered in `@canonical_names'.
# It may be an abbreviated.
#
- matches = []
+ match_count = 0
@canonical_names.each_key do |key|
if key.index(pattern) == 0
option_name = key
- matches << key
+ match_count += 1
end
end
- if 2 <= matches.length
- set_error(AmbiguousOption, "option `#{argument}' is ambiguous between #{matches.join(', ')}")
- elsif matches.length == 0
+ if 2 <= match_count
+ set_error(AmbigousOption, "option `#{argument}' is ambiguous")
+ elsif match_count == 0
set_error(InvalidOption, "unrecognized option `#{argument}'")
end
end
@@ -570,7 +575,7 @@ class GetoptLong
# 1003.2 specifies the format of this message.
#
if ENV.include?('POSIXLY_CORRECT')
- set_error(InvalidOption, "invalid option -- #{ch}")
+ set_error(InvalidOption, "illegal option -- #{ch}")
else
set_error(InvalidOption, "invalid option -- #{ch}")
end
diff --git a/lib/getopts.rb b/lib/getopts.rb
new file mode 100644
index 0000000000..7124269351
--- /dev/null
+++ b/lib/getopts.rb
@@ -0,0 +1,127 @@
+#
+# getopts.rb -
+# $Release Version: $
+# $Revision$
+# $Date$
+# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
+#
+# --
+# this is obsolete; use getoptlong
+#
+# 2000-03-21
+# modified by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+#
+# 2002-03-05
+# rewritten by Akinori MUSHA <knu@ruby-lang.org>
+#
+
+warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: getopts is deprecated after Ruby 1.8.1; use optparse instead" if caller[0] and $VERBOSE
+
+$RCS_ID=%q$Header$
+
+# getopts is obsolete. Use GetoptLong.
+
+def getopts(single_options, *options)
+ boolopts = {}
+ valopts = {}
+
+ #
+ # set defaults
+ #
+ single_options.scan(/.:?/) do |opt|
+ if opt.size == 1
+ boolopts[opt] = false
+ else
+ valopts[opt[0, 1]] = nil
+ end
+ end if single_options
+
+ options.each do |arg|
+ opt, val = arg.split(':', 2)
+
+ if val
+ valopts[opt] = val.empty? ? nil : val
+ else
+ boolopts[opt] = false
+ end
+ end
+
+ #
+ # scan
+ #
+ c = 0
+ argv = ARGV
+
+ while arg = argv.shift
+ case arg
+ when /\A--(.*)/
+ if $1.empty? # xinit -- -bpp 24
+ break
+ end
+
+ opt, val = $1.split('=', 2)
+
+ if opt.size == 1
+ argv.unshift arg
+ return nil
+ elsif valopts.key? opt # imclean --src +trash
+ valopts[opt] = val || argv.shift or return nil
+ elsif boolopts.key? opt # ruby --verbose
+ boolopts[opt] = true
+ else
+ argv.unshift arg
+ return nil
+ end
+
+ c += 1
+ when /\A-(.+)/
+ opts = $1
+
+ until opts.empty?
+ opt = opts.slice!(0, 1)
+
+ if valopts.key? opt
+ val = opts
+
+ if val.empty? # ruby -e 'p $:'
+ valopts[opt] = argv.shift or return nil
+ else # cc -ohello ...
+ valopts[opt] = val
+ end
+
+ c += 1
+ break
+ elsif boolopts.key? opt
+ boolopts[opt] = true # ruby -h
+ c += 1
+ else
+ argv.unshift arg
+ return nil
+ end
+ end
+ else
+ argv.unshift arg
+ break
+ end
+ end
+
+ #
+ # set
+ #
+ $OPT = {}
+
+ boolopts.each do |opt, val|
+ $OPT[opt] = val
+
+ sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
+ eval "$OPT_#{sopt} = val"
+ end
+ valopts.each do |opt, val|
+ $OPT[opt] = val
+
+ sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
+ eval "$OPT_#{sopt} = val"
+ end
+
+ c
+end
diff --git a/lib/importenv.rb b/lib/importenv.rb
new file mode 100644
index 0000000000..8e1ba33b1d
--- /dev/null
+++ b/lib/importenv.rb
@@ -0,0 +1,33 @@
+# importenv.rb -- imports environment variables as global variables, Perlish ;(
+#
+# Usage:
+#
+# require 'importenv'
+# p $USER
+# $USER = "matz"
+# p ENV["USER"]
+
+warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: importenv is deprecated after Ruby 1.8.1 (no replacement)"
+
+for k,v in ENV
+ next unless /^[a-zA-Z][_a-zA-Z0-9]*/ =~ k
+ eval <<EOS
+ $#{k} = v
+ trace_var "$#{k}", proc{|v|
+ ENV[%q!#{k}!] = v
+ $#{k} = v
+ if v == nil
+ untrace_var "$#{k}"
+ end
+ }
+EOS
+end
+
+if __FILE__ == $0
+ p $TERM
+ $TERM = nil
+ p $TERM
+ p ENV["TERM"]
+ $TERM = "foo"
+ p ENV["TERM"]
+end
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index d69339a7c8..fe963e406c 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -9,8 +9,12 @@
#
# $Id$
#
+# Contact:
+# - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
+#
# TODO:
# - scope_id support
+#
require 'socket'
unless Socket.const_defined? "AF_INET6"
@@ -84,7 +88,7 @@ class IPAddr
IN6FORMAT = (["%.4x"] * 8).join(':')
# Returns the address family of this IP address.
- attr_reader :family
+ attr :family
# Creates a new ipaddr containing the given network byte ordered
# string form of an IP address.
@@ -479,7 +483,7 @@ class IPAddr
if prefixlen
mask!(prefixlen)
else
- @mask_addr = (family == Socket::AF_INET) ? IN4MASK : IN6MASK
+ @mask_addr = (@family == Socket::AF_INET) ? IN4MASK : IN6MASK
end
end
diff --git a/lib/irb.rb b/lib/irb.rb
index 4c7a56da0d..7580e39d43 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -85,7 +85,7 @@ module IRB
end
#
- # irb interpreter main routine
+ # irb interpriter main routine
#
class Irb
def initialize(workspace = nil, input_method = nil, output_method = nil)
@@ -149,10 +149,15 @@ module IRB
line.untaint
@context.evaluate(line, line_no)
output_value if @context.echo?
- rescue StandardError, ScriptError, Abort
- $! = RuntimeError.new("unknown exception raised") unless $!
- print $!.class, ": ", $!, "\n"
- if $@[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && $!.class.to_s !~ /^IRB/
+ exc = nil
+ rescue Interrupt => exc
+ rescue SystemExit, SignalException
+ raise
+ rescue Exception => exc
+ end
+ if exc
+ print exc.class, ": ", exc, "\n"
+ if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/
irb_bug = true
else
irb_bug = false
@@ -161,7 +166,7 @@ module IRB
messages = []
lasts = []
levels = 0
- for m in $@
+ for m in exc.backtrace
m = @context.workspace.filter_backtrace(m) unless irb_bug
if m
if messages.size < @context.back_trace_limit
@@ -183,8 +188,7 @@ module IRB
print "Maybe IRB bug!!\n" if irb_bug
end
if $SAFE > 2
- warn "Error: irb does not work for $SAFE level higher than 2"
- exit 1
+ abort "Error: irb does not work for $SAFE level higher than 2"
end
end
end
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 501f96c70a..000658e2a3 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -9,8 +9,6 @@
require "readline"
-X=1
-
module IRB
module InputCompletor
@@ -47,7 +45,7 @@ module IRB
receiver = $1
message = Regexp.quote($2)
- candidates = Regexp.instance_methods.collect{|m| m.to_s}
+ candidates = Regexp.instance_methods(true)
select_message(receiver, message, candidates)
when /^([^\]]*\])\.([^.]*)$/
@@ -55,7 +53,7 @@ module IRB
receiver = $1
message = Regexp.quote($2)
- candidates = Array.instance_methods.collect{|m| m.to_s}
+ candidates = Array.instance_methods(true)
select_message(receiver, message, candidates)
when /^([^\}]*\})\.([^.]*)$/
@@ -63,8 +61,7 @@ module IRB
receiver = $1
message = Regexp.quote($2)
- candidates = Proc.instance_methods.collect{|m| m.to_s}
- candidates |= Hash.instance_methods.collect{|m| m.to_s}
+ candidates = Proc.instance_methods(true) | Hash.instance_methods(true)
select_message(receiver, message, candidates)
when /^(:[^:.]*)$/
@@ -80,7 +77,7 @@ module IRB
when /^::([A-Z][^:\.\(]*)$/
# Absolute Constant or class methods
receiver = $1
- candidates = Object.constants.collect{|m| m.to_s}
+ candidates = Object.constants
candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
when /^(((::)?[A-Z][^:.\(]*)+)::?([^:.]*)$/
@@ -88,8 +85,7 @@ module IRB
receiver = $1
message = Regexp.quote($4)
begin
- candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
- candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
+ candidates = eval("#{receiver}.constants | #{receiver}.methods", bind)
rescue Exception
candidates = []
end
@@ -100,7 +96,7 @@ module IRB
receiver = $1
message = Regexp.quote($2)
- candidates = Symbol.instance_methods.collect{|m| m.to_s}
+ candidates = Symbol.instance_methods(true)
select_message(receiver, message, candidates)
when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
@@ -109,7 +105,7 @@ module IRB
message = Regexp.quote($5)
begin
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
+ candidates = eval(receiver, bind).methods
rescue Exception
candidates = []
end
@@ -121,15 +117,14 @@ module IRB
message = Regexp.quote($2)
begin
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
+ candidates = eval(receiver, bind).methods
rescue Exception
candidates = []
end
select_message(receiver, message, candidates)
when /^(\$[^.]*)$/
- regmessage = Regexp.new(Regexp.quote($1))
- candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
+ candidates = global_variables.grep(Regexp.new(Regexp.quote($1)))
# when /^(\$?(\.?[^.]+)+)\.([^.]*)$/
when /^((\.?[^.]+)+)\.([^.]*)$/
@@ -137,17 +132,17 @@ module IRB
receiver = $1
message = Regexp.quote($3)
- gv = eval("global_variables", bind).collect{|m| m.to_s}
- lv = eval("local_variables", bind).collect{|m| m.to_s}
- cv = eval("self.class.constants", bind).collect{|m| m.to_s}
+ gv = eval("global_variables", bind)
+ lv = eval("local_variables", bind)
+ cv = eval("self.class.constants", bind)
if (gv | lv | cv).include?(receiver)
# foo.func and foo is local var.
- candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
+ candidates = eval("#{receiver}.methods", bind)
elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver
# Foo::Bar.func
begin
- candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
+ candidates = eval("#{receiver}.methods", bind)
rescue Exception
candidates = []
end
@@ -162,7 +157,7 @@ module IRB
end
next if name != "IRB::Context" and
/^(IRB|SLex|RubyLex|RubyToken)/ =~ name
- candidates.concat m.instance_methods(false).collect{|m| m.to_s}
+ candidates.concat m.instance_methods(false)
}
candidates.sort!
candidates.uniq!
@@ -175,11 +170,11 @@ module IRB
receiver = ""
message = Regexp.quote($1)
- candidates = String.instance_methods(true).collect{|m| m.to_s}
+ candidates = String.instance_methods(true)
select_message(receiver, message, candidates)
else
- candidates = eval("methods | private_methods | local_variables | self.class.constants", bind).collect{|m| m.to_s}
+ candidates = eval("methods | private_methods | local_variables | self.class.constants", bind)
(candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
end
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 8994f2f8d2..508721c11d 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -112,7 +112,7 @@ module IRB
end
end
- # aliases = [commans_alias, flag], ...
+ # aliases = [commands_alias, flag], ...
def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
case cmd_class
when Symbol
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
index f091999bd1..4921de6ec9 100644
--- a/lib/irb/help.rb
+++ b/lib/irb/help.rb
@@ -1,5 +1,5 @@
#
-# irb/help.rb - print usase module
+# irb/help.rb - print usage module
# $Release Version: 0.9.5$
# $Revision$
# $Date$
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 3b455ec582..db22ca639b 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -140,6 +140,8 @@ module IRB
when /^-I(.+)?/
opt = $1 || ARGV.shift
load_path.concat(opt.split(File::PATH_SEPARATOR)) if opt
+ when /^-K(.)/
+ $KCODE = $1
when "--inspect"
@CONF[:INSPECT_MODE] = true
when "--noinspect"
@@ -204,7 +206,7 @@ module IRB
begin
load rc_file
rescue LoadError, Errno::ENOENT
- rescue # StandardError, ScriptError
+ rescue
print "load error: #{rc_file}\n"
print $!.class, ": ", $!, "\n"
for err in $@[0, $@.size - 2]
@@ -231,7 +233,7 @@ module IRB
# enumerate possible rc-file base name generators
def IRB.rc_file_generators
if irbrc = ENV["IRBRC"]
- yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
+ yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
end
if home = ENV["HOME"]
yield proc{|rc| home+"/.irb#{rc}"}
@@ -248,7 +250,7 @@ module IRB
for m in @CONF[:LOAD_MODULES]
begin
require m
- rescue # StandardError, ScriptError
+ rescue
print $@[0], ":", $!.class, ": ", $!, "\n"
end
end
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index a0fa359d3a..bfb90fa59a 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -94,10 +94,8 @@ module IRB
end
def gets
- Readline.input = STDIN
- Readline.output = STDOUT
if l = readline(@prompt, false)
- HISTORY.push(l) if !l.empty?
+ HISTORY.push(l) if !l.empty?
@line[@line_no += 1] = l + "\n"
else
@eof = true
diff --git a/lib/irb/notifier.rb b/lib/irb/notifier.rb
index c8e66fa859..0f79bc5a8d 100644
--- a/lib/irb/notifier.rb
+++ b/lib/irb/notifier.rb
@@ -1,5 +1,5 @@
#
-# notifier.rb - optput methods used by irb
+# notifier.rb - output methods used by irb
# $Release Version: 0.9.5$
# $Revision$
# $Date$
diff --git a/lib/irb/output-method.rb b/lib/irb/output-method.rb
index b8bd7fab81..b9a3a8851e 100644
--- a/lib/irb/output-method.rb
+++ b/lib/irb/output-method.rb
@@ -36,15 +36,30 @@ module IRB
end
# %
- # <flag> [#0- +]
- # <minimum field width> (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
- # <precision>.(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
- # #<length modifier>(hh|h|l|ll|L|q|j|z|t)
- # <conversion specifier>[diouxXeEfgGcsb%]
+ # <¥Õ¥é¥°> [#0- +]
+ # <ºÇ¾®¥Õ¥£¡¼¥ë¥ÉÉý> (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
+ # <ÀºÅÙ>.(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
+ # #<Ťµ½¤ÀµÊ¸»ú>(hh|h|l|ll|L|q|j|z|t)
+ # <ÊÑ´¹½¤ÀµÊ¸»ú>[diouxXeEfgGcsb%]
def parse_printf_format(format, opts)
return format, opts if $1.size % 2 == 1
end
+ def foo(format)
+ pos = 0
+ inspects = []
+ format.scan(/%[#0\-+ ]?(\*(?=[^0-9])|\*[1-9][0-9]*\$|[1-9][0-9]*(?=[^0-9]))?(\.(\*(?=[^0-9])|\*[1-9][0-9]*\$|[1-9][0-9]*(?=[^0-9])))?(([1-9][0-9]*\$)*)([diouxXeEfgGcsb%])/) {|f, p, pp, pos, new_pos, c|
+ puts [f, p, pp, pos, new_pos, c].join("!")
+ pos = new_pos if new_pos
+ if c == "I"
+ inspects.push pos.to_i
+ (f||"")+(p||"")+(pp||"")+(pos||"")+"s"
+ else
+ $&
+ end
+ }
+ end
+
def puts(*objs)
for obj in objs
print(*obj)
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 561028fb6c..313a809ccd 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -1,5 +1,5 @@
#
-# irb/ruby-lex.rb - ruby lexcal analizer
+# irb/ruby-lex.rb - ruby lexcal analyzer
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -104,7 +104,6 @@ class RubyLex
@rests.push nil unless buf_input
end
c = @rests.shift
- return if c == nil
if @here_header
@here_readed.push c
else
@@ -235,6 +234,7 @@ class RubyLex
unless l = lex
throw :TERM_INPUT if @line == ''
else
+ #p l
@line.concat l
if @ltype or @continue or @indent > 0
next
@@ -1054,12 +1054,6 @@ class RubyLex
break
elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
subtype = true
- elsif ch == '\\' and @ltype == "'" #'
- case ch = getc
- when "\\", "\n", "'"
- else
- ungetc
- end
elsif ch == '\\' #'
read_escape
end
diff --git a/lib/irb/ruby-token.rb b/lib/irb/ruby-token.rb
index 0a297d28fa..525d4df14c 100644
--- a/lib/irb/ruby-token.rb
+++ b/lib/irb/ruby-token.rb
@@ -29,7 +29,9 @@ module RubyToken
@line_no = line_no
@char_no = char_no
end
- attr :seek, :line_no, :char_no
+ attr :seek
+ attr :line_no
+ attr :char_no
end
class TkNode < Token
@@ -56,7 +58,7 @@ module RubyToken
end
class TkOp < Token
- attr_accessor :name
+ attr :name, true
end
class TkOPASGN < TkOp
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
index 866bf30a5c..f7e3a3b2b2 100644
--- a/lib/irb/slex.rb
+++ b/lib/irb/slex.rb
@@ -1,5 +1,5 @@
#
-# irb/slex.rb - symple lex analizer
+# irb/slex.rb - simple lex analyzer
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -245,6 +245,8 @@ module IRB
end
end
+SLex=IRB::SLex
+
if $0 == __FILE__
# Tracer.on
case $1
diff --git a/lib/jcode.rb b/lib/jcode.rb
new file mode 100644
index 0000000000..78422f296f
--- /dev/null
+++ b/lib/jcode.rb
@@ -0,0 +1,220 @@
+# jcode.rb - ruby code to handle japanese (EUC/SJIS) string
+
+if $VERBOSE && $KCODE == "NONE"
+ warn "Warning: $KCODE is NONE."
+end
+
+$vsave, $VERBOSE = $VERBOSE, false
+class String
+ warn "feel free for some warnings:\n" if $VERBOSE
+
+ def _regex_quote(str)
+ str.gsub(/(\\[\[\]\-\\])|\\(.)|([\[\]\\])/) do
+ $1 || $2 || '\\' + $3
+ end
+ end
+ private :_regex_quote
+
+ PATTERN_SJIS = '[\x81-\x9f\xe0-\xef][\x40-\x7e\x80-\xfc]'
+ PATTERN_EUC = '[\xa1-\xfe][\xa1-\xfe]'
+ PATTERN_UTF8 = '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]'
+
+ RE_SJIS = Regexp.new(PATTERN_SJIS, 0, 'n')
+ RE_EUC = Regexp.new(PATTERN_EUC, 0, 'n')
+ RE_UTF8 = Regexp.new(PATTERN_UTF8, 0, 'n')
+
+ SUCC = {}
+ SUCC['s'] = Hash.new(1)
+ for i in 0 .. 0x3f
+ SUCC['s'][i.chr] = 0x40 - i
+ end
+ SUCC['s']["\x7e"] = 0x80 - 0x7e
+ SUCC['s']["\xfd"] = 0x100 - 0xfd
+ SUCC['s']["\xfe"] = 0x100 - 0xfe
+ SUCC['s']["\xff"] = 0x100 - 0xff
+ SUCC['e'] = Hash.new(1)
+ for i in 0 .. 0xa0
+ SUCC['e'][i.chr] = 0xa1 - i
+ end
+ SUCC['e']["\xfe"] = 2
+ SUCC['u'] = Hash.new(1)
+ for i in 0 .. 0x7f
+ SUCC['u'][i.chr] = 0x80 - i
+ end
+ SUCC['u']["\xbf"] = 0x100 - 0xbf
+
+ def mbchar?
+ case $KCODE[0]
+ when ?s, ?S
+ self =~ RE_SJIS
+ when ?e, ?E
+ self =~ RE_EUC
+ when ?u, ?U
+ self =~ RE_UTF8
+ else
+ nil
+ end
+ end
+
+ def end_regexp
+ case $KCODE[0]
+ when ?s, ?S
+ /#{PATTERN_SJIS}$/on
+ when ?e, ?E
+ /#{PATTERN_EUC}$/on
+ when ?u, ?U
+ /#{PATTERN_UTF8}$/on
+ else
+ /.$/on
+ end
+ end
+
+ alias original_succ! succ!
+ private :original_succ!
+
+ alias original_succ succ
+ private :original_succ
+
+ def succ!
+ reg = end_regexp
+ if $KCODE != 'NONE' && self =~ reg
+ succ_table = SUCC[$KCODE[0,1].downcase]
+ begin
+ self[-1] += succ_table[self[-1]]
+ self[-2] += 1 if self[-1] == 0
+ end while self !~ reg
+ self
+ else
+ original_succ!
+ end
+ end
+
+ def succ
+ str = self.dup
+ str.succ! or str
+ end
+
+ private
+
+ def _expand_ch str
+ a = []
+ str.scan(/(?:\\(.)|([^\\]))-(?:\\(.)|([^\\]))|(?:\\(.)|(.))/m) do
+ from = $1 || $2
+ to = $3 || $4
+ one = $5 || $6
+ if one
+ a.push one
+ elsif from.length != to.length
+ next
+ elsif from.length == 1
+ from[0].upto(to[0]) { |c| a.push c.chr }
+ else
+ from.upto(to) { |c| a.push c }
+ end
+ end
+ a
+ end
+
+ def expand_ch_hash from, to
+ h = {}
+ afrom = _expand_ch(from)
+ ato = _expand_ch(to)
+ afrom.each_with_index do |x,i| h[x] = ato[i] || ato[-1] end
+ h
+ end
+
+ HashCache = {}
+ TrPatternCache = {}
+ DeletePatternCache = {}
+ SqueezePatternCache = {}
+
+ public
+
+ def tr!(from, to)
+ return nil if from == ""
+ return self.delete!(from) if to == ""
+
+ pattern = TrPatternCache[from] ||= /[#{_regex_quote(from)}]/
+ if from[0] == ?^
+ last = /.$/.match(to)[0]
+ self.gsub!(pattern, last)
+ else
+ h = HashCache[from + "1-0" + to] ||= expand_ch_hash(from, to)
+ self.gsub!(pattern) do |c| h[c] end
+ end
+ end
+
+ def tr(from, to)
+ (str = self.dup).tr!(from, to) or str
+ end
+
+ def delete!(del)
+ return nil if del == ""
+ self.gsub!(DeletePatternCache[del] ||= /[#{_regex_quote(del)}]+/, '')
+ end
+
+ def delete(del)
+ (str = self.dup).delete!(del) or str
+ end
+
+ def squeeze!(del=nil)
+ return nil if del == ""
+ pattern =
+ if del
+ SqueezePatternCache[del] ||= /([#{_regex_quote(del)}])\1+/
+ else
+ /(.|\n)\1+/
+ end
+ self.gsub!(pattern, '\1')
+ end
+
+ def squeeze(del=nil)
+ (str = self.dup).squeeze!(del) or str
+ end
+
+ def tr_s!(from, to)
+ return self.delete!(from) if to.length == 0
+
+ pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1*/
+ if from[0] == ?^
+ last = /.$/.match(to)[0]
+ self.gsub!(pattern, last)
+ else
+ h = HashCache[from + "1-0" + to] ||= expand_ch_hash(from, to)
+ self.gsub!(pattern) do h[$1] end
+ end
+ end
+
+ def tr_s(from, to)
+ (str = self.dup).tr_s!(from,to) or str
+ end
+
+ def chop!
+ self.gsub!(/(?:.|\r?\n)\z/, '')
+ end
+
+ def chop
+ (str = self.dup).chop! or str
+ end
+
+ def jlength
+ self.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
+ end
+ alias jsize jlength
+
+ def jcount(str)
+ self.delete("^#{str}").jlength
+ end
+
+ def each_char
+ if block_given?
+ scan(/./m) do |x|
+ yield x
+ end
+ else
+ scan(/./m)
+ end
+ end
+
+end
+$VERBOSE = $vsave
diff --git a/lib/logger.rb b/lib/logger.rb
index cff881ff48..9030fa1d0d 100644
--- a/lib/logger.rb
+++ b/lib/logger.rb
@@ -1,10 +1,8 @@
-# logger.rb - saimple logging utility
+# logger.rb - simple logging utility
# Copyright (C) 2000-2003, 2005 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
require 'monitor'
-# = logger.rb
-#
# Simple logging utility.
#
# Author:: NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
@@ -14,11 +12,6 @@ require 'monitor'
# license; either the dual license version in 2003, or any later version.
# Revision:: $Id$
#
-# See Logger for documentation.
-#
-
-
-#
# == Description
#
# The Logger class provides a simple but sophisticated logging utility that
@@ -150,14 +143,14 @@ require 'monitor'
# 2. Log4r (somewhat) compatible interface.
#
# logger.level = Logger::INFO
-#
+#
# DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
#
#
# == Format
#
-# Log messages are rendered in the output stream in a certain format by
-# default. The default format and a sample are shown below:
+# Log messages are rendered in the output stream in a certain format. The
+# default format and a sample are shown below:
#
# Log format:
# SeverityID, [Date Time mSec #pid] SeverityLabel -- ProgName: message
@@ -170,12 +163,8 @@ require 'monitor'
# logger.datetime_format = "%Y-%m-%d %H:%M:%S"
# # e.g. "2004-01-03 00:54:26"
#
-# You may change the overall format with Logger#formatter= method.
-#
-# logger.formatter = proc { |severity, datetime, progname, msg|
-# "#{datetime}: #{msg}\n"
-# }
-# # e.g. "Thu Sep 22 08:51:08 GMT+9:00 2005: hello world"
+# There is currently no supported way to change the overall format, but you may
+# have some luck hacking the Format constant.
#
@@ -636,8 +625,8 @@ private
class Application
include Logger::Severity
- # Name of the application given at initialize.
attr_reader :appname
+ attr_reader :logdev
#
# == Synopsis
@@ -676,21 +665,9 @@ private
status
end
- # Logger for this application. See the class Logger for an explanation.
- def logger
- @log
- end
-
- #
- # Sets the logger for this application. See the class Logger for an explanation.
- #
- def logger=(logger)
- @log = logger
- end
-
#
- # Sets the log device for this application. See <tt>Logger.new</tt> for an explanation
- # of the arguments.
+ # Sets the log device for this application. See the class Logger for an
+ # explanation of the arguments.
#
def set_log(logdev, shift_age = 0, shift_size = 1024000)
@log = Logger.new(logdev, shift_age, shift_size)
diff --git a/lib/mailread.rb b/lib/mailread.rb
new file mode 100644
index 0000000000..08b33c92a4
--- /dev/null
+++ b/lib/mailread.rb
@@ -0,0 +1,62 @@
+# The Mail class represents an internet mail message (as per RFC822, RFC2822)
+# with headers and a body.
+class Mail
+
+ # Create a new Mail where +f+ is either a stream which responds to gets(),
+ # or a path to a file. If +f+ is a path it will be opened.
+ #
+ # The whole message is read so it can be made available through the #header,
+ # #[] and #body methods.
+ #
+ # The "From " line is ignored if the mail is in mbox format.
+ def initialize(f)
+ unless defined? f.gets
+ f = open(f, "r")
+ opened = true
+ end
+
+ @header = {}
+ @body = []
+ begin
+ while line = f.gets()
+ line.chop!
+ next if /^From /=~line # skip From-line
+ break if /^$/=~line # end of header
+
+ if /^(\S+?):\s*(.*)/=~line
+ (attr = $1).capitalize!
+ @header[attr] = $2
+ elsif attr
+ line.sub!(/^\s*/, '')
+ @header[attr] += "\n" + line
+ end
+ end
+
+ return unless line
+
+ while line = f.gets()
+ break if /^From /=~line
+ @body.push(line)
+ end
+ ensure
+ f.close if opened
+ end
+ end
+
+ # Return the headers as a Hash.
+ def header
+ return @header
+ end
+
+ # Return the message body as an Array of lines
+ def body
+ return @body
+ end
+
+ # Return the header corresponding to +field+.
+ #
+ # Matching is case-insensitive.
+ def [](field)
+ @header[field.capitalize]
+ end
+end
diff --git a/lib/mathn.rb b/lib/mathn.rb
index 84c0b4704d..a5a121c6c6 100644
--- a/lib/mathn.rb
+++ b/lib/mathn.rb
@@ -16,6 +16,24 @@ require "matrix.rb"
class Integer
+ def gcd2(int)
+ a = self.abs
+ b = int.abs
+ a, b = b, a if a < b
+
+ pd_a = a.prime_division
+ pd_b = b.prime_division
+
+ gcd = 1
+ for pair in pd_a
+ as = pd_b.assoc(pair[0])
+ if as
+ gcd *= as[0] ** [as[1], pair[1]].min
+ end
+ end
+ return gcd
+ end
+
def Integer.from_prime_division(pd)
value = 1
for prime, index in pd
@@ -50,54 +68,34 @@ end
class Prime
include Enumerable
- # These are included as class variables to cache them for later uses. If memory
- # usage is a problem, they can be put in Prime#initialize as instance variables.
- # There must be no primes between @@primes[-1] and @@next_to_check.
- @@primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]
- # @@next_to_check % 6 must be 1.
- @@next_to_check = 103 # @@primes[-1] - @@primes[-1] % 6 + 7
- @@ulticheck_index = 3 # @@primes.index(@@primes.reverse.find {|n|
- # n < Math.sqrt(@@next_to_check) })
- @@ulticheck_next_squared = 121 # @@primes[@@ulticheck_index + 1] ** 2
-
- class << self
- # Return the prime cache.
- def cache
- return @@primes
- end
- alias primes cache
- alias primes_so_far cache
- end
-
def initialize
- @index = -1
- end
-
- # Return primes given by this instance so far.
- def primes
- return @@primes[0, @index + 1]
+ @seed = 1
+ @primes = []
+ @counts = []
end
- alias primes_so_far primes
def succ
- @index += 1
- while @index >= @@primes.length
- # Only check for prime factors up to the square root of the potential primes,
- # but without the performance hit of an actual square root calculation.
- if @@next_to_check + 4 > @@ulticheck_next_squared
- @@ulticheck_index += 1
- @@ulticheck_next_squared = @@primes.at(@@ulticheck_index + 1) ** 2
+ i = -1
+ size = @primes.size
+ while i < size
+ if i == -1
+ @seed += 1
+ i += 1
+ else
+ while @seed > @counts[i]
+ @counts[i] += @primes[i]
+ end
+ if @seed != @counts[i]
+ i += 1
+ else
+ i = -1
+ end
end
- # Only check numbers congruent to one and five, modulo six. All others
- # are divisible by two or three. This also allows us to skip checking against
- # two and three.
- @@primes.push @@next_to_check if @@primes[2..@@ulticheck_index].find {|prime| @@next_to_check % prime == 0 }.nil?
- @@next_to_check += 4
- @@primes.push @@next_to_check if @@primes[2..@@ulticheck_index].find {|prime| @@next_to_check % prime == 0 }.nil?
- @@next_to_check += 2
end
- return @@primes[@index]
+ @primes.push @seed
+ @counts.push @seed + @seed
+ return @seed
end
alias next succ
@@ -109,19 +107,16 @@ class Prime
end
class Fixnum
- remove_method :/
alias / quo
end
class Bignum
- remove_method :/
alias / quo
end
class Rational
Unify = true
- remove_method :inspect
def inspect
format "%s/%s", numerator.inspect, denominator.inspect
end
@@ -235,7 +230,6 @@ class Rational
end
module Math
- remove_method(:sqrt)
def sqrt(a)
if a.kind_of?(Complex)
abs = sqrt(a.real*a.real + a.image*a.image)
diff --git a/lib/matrix.rb b/lib/matrix.rb
index bbb1144e10..470db19b05 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -1,9 +1,9 @@
#!/usr/local/bin/ruby
#--
# matrix.rb -
-# $Release Version: 1.0$
-# $Revision: 1.13 $
-# $Date: 2001/12/09 14:22:23 $
+# $Release Version: 1.0$
+# $Revision: 1.11 $
+# $Date: 1999/10/06 11:01:53 $
# Original Version from Smalltalk-80 version
# on July 23, 1985 at 8:37:17 am
# by Keiju ISHITSUKA
@@ -105,7 +105,7 @@ end
# * <tt> #inspect </tt>
#
class Matrix
- @RCS_ID='-$Id: matrix.rb,v 1.13 2001/12/09 14:22:23 keiju Exp keiju $-'
+ @RCS_ID='-$Id: matrix.rb,v 1.11 1999/10/06 11:01:53 keiju Exp keiju $-'
# extend Exception2MessageMapper
include ExceptionForMatrix
@@ -265,15 +265,6 @@ class Matrix
def [](i, j)
@rows[i][j]
end
- alias element []
- alias component []
-
- def []=(i, j, v)
- @rows[i][j] = v
- end
- alias set_element []=
- alias set_component []=
- private :[]=, :set_element, :set_component
#
# Returns the number of rows.
@@ -329,7 +320,7 @@ class Matrix
#
# Returns a matrix that is the result of iteration of the given block over all
# elements of the matrix.
- # Matrix[ [1,2], [3,4] ].collect { |e| e**2 }
+ # Matrix[ [1,2], [3,4] ].collect { |i| i**2 }
# => 1 4
# 9 16
#
@@ -617,7 +608,7 @@ class Matrix
for i in 0 .. size
next if i == k
- q = a[i][k].quo(akk)
+ q = a[i][k] / akk
a[i][k] = 0
(k + 1).upto(size) do
@@ -632,11 +623,11 @@ class Matrix
(k + 1).upto(size) do
|j|
- a[k][j] = a[k][j].quo(akk)
+ a[k][j] /= akk
end
0.upto(size) do
|j|
- @rows[k][j] = @rows[k][j].quo(akk)
+ @rows[k][j] /= akk
end
end
self
@@ -683,13 +674,9 @@ class Matrix
#
# Returns the determinant of the matrix. If the matrix is not square, the
- # result is 0. This method's algorism is Gaussian elimination method
- # and using Numeric#quo(). Beware that using Float values, with their
- # usual lack of precision, can affect the value returned by this method. Use
- # Rational values or Matrix#det_e instead if this is important to you.
- #
+ # result is 0.
# Matrix[[7,6], [3,9]].determinant
- # => 63.0
+ # => 63
#
def determinant
return 0 unless square?
@@ -711,7 +698,7 @@ class Matrix
end
(k + 1).upto(size) do
|i|
- q = a[i][k].quo(akk)
+ q = a[i][k] / akk
(k + 1).upto(size) do
|j|
a[i][j] -= a[k][j] * q
@@ -722,56 +709,11 @@ class Matrix
det
end
alias det determinant
-
- #
- # Returns the determinant of the matrix. If the matrix is not square, the
- # result is 0. This method's algorism is Gaussian elimination method.
- # This method uses Euclidean algorism. If all elements are integer,
- # really exact value. But, if an element is a float, can't return
- # exact value.
- #
- # Matrix[[7,6], [3,9]].determinant
- # => 63
- #
- def determinant_e
- return 0 unless square?
-
- size = row_size - 1
- a = to_a
-
- det = 1
- k = 0
- begin
- if a[k][k].zero?
- i = k
- begin
- return 0 if (i += 1) > size
- end while a[i][k].zero?
- a[i], a[k] = a[k], a[i]
- det *= -1
- end
- (k + 1).upto(size) do |i|
- q = a[i][k].quo(a[k][k])
- k.upto(size) do |j|
- a[i][j] -= a[k][j] * q
- end
- unless a[i][k].zero?
- a[i], a[k] = a[k], a[i]
- det *= -1
- redo
- end
- end
- det *= a[k][k]
- end while (k += 1) <= size
- det
- end
- alias det_e determinant_e
-
- #
- # Returns the rank of the matrix. Beware that using Float values,
- # probably return faild value. Use Rational values or Matrix#rank_e
- # for getting exact result.
+
#
+ # Returns the rank of the matrix. Beware that using Float values, with their
+ # usual lack of precision, can affect the value returned by this method. Use
+ # Rational values instead if this is important to you.
# Matrix[[7,6], [3,9]].rank
# => 2
#
@@ -822,7 +764,7 @@ class Matrix
end
(k + 1).upto(a_row_size - 1) do
|i|
- q = a[i][k].quo(akk)
+ q = a[i][k] / akk
(k + 1).upto(a_column_size - 1) do
|j|
a[i][j] -= a[k][j] * q
@@ -834,41 +776,6 @@ class Matrix
end
#
- # Returns the rank of the matrix. This method uses Euclidean
- # algorism. If all elements are integer, really exact value. But, if
- # an element is a float, can't return exact value.
- #
- # Matrix[[7,6], [3,9]].rank
- # => 2
- #
- def rank_e
- a = to_a
- a_column_size = column_size
- a_row_size = row_size
- pi = 0
- (0 ... a_column_size).each do |j|
- if i = (pi ... a_row_size).find{|i0| !a[i0][j].zero?}
- if i != pi
- a[pi], a[i] = a[i], a[pi]
- end
- (pi + 1 ... a_row_size).each do |k|
- q = a[k][j].quo(a[pi][j])
- (pi ... a_column_size).each do |j0|
- a[k][j0] -= q * a[pi][j0]
- end
- if k > pi && !a[k][j].zero?
- a[k], a[pi] = a[pi], a[k]
- redo
- end
- end
- pi += 1
- end
- end
- pi
- end
-
-
- #
# Returns the trace (sum of diagonal elements) of the matrix.
# Matrix[[7,6], [3,9]].trace
# => 16
@@ -943,18 +850,6 @@ class Matrix
@rows.collect{|row| row.collect{|e| e}}
end
- def elements_to_f
- collect{|e| e.to_f}
- end
-
- def elements_to_i
- collect{|e| e.to_i}
- end
-
- def elements_to_r
- collect{|e| e.to_r}
- end
-
#--
# PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -1033,10 +928,10 @@ class Matrix
when Vector
Scalar.Raise WrongArgType, other.class, "Numeric or Scalar or Matrix"
when Matrix
- self * other.inverse
+ self * _M.inverse
else
x, y = other.coerce(self)
- x.quo(y)
+ x / y
end
end
@@ -1145,15 +1040,6 @@ class Vector
def [](i)
@elements[i]
end
- alias element []
- alias component []
-
- def []=(i, v)
- @elements[i]= v
- end
- alias set_element []=
- alias set_component []=
- private :[]=, :set_element, :set_component
#
# Returns the number of elements in the vector.
@@ -1356,25 +1242,13 @@ class Vector
@elements.dup
end
- def elements_to_f
- collect{|e| e.to_f}
- end
-
- def elements_to_i
- collect{|e| e.to_i}
- end
-
- def elements_to_r
- collect{|e| e.to_r}
- end
-
#
# FIXME: describe Vector#coerce.
#
def coerce(other)
case other
when Numeric
- return Matrix::Scalar.new(other), self
+ return Scalar.new(other), self
else
raise TypeError, "#{self.class} can't be coerced into #{other.class}"
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 853f2f4da8..a532b5c0a8 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -5,7 +5,7 @@ require 'rbconfig'
require 'fileutils'
require 'shellwords'
-CONFIG = RbConfig::MAKEFILE_CONFIG
+CONFIG = Config::MAKEFILE_CONFIG
ORIG_LIBPATH = ENV['LIB']
CXX_EXT = %w[cc cxx cpp]
@@ -66,6 +66,8 @@ $beos = /beos/ =~ RUBY_PLATFORM
$solaris = /solaris/ =~ RUBY_PLATFORM
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
+# :stopdoc:
+
def config_string(key, config = CONFIG)
s = config[key] and !s.empty? and block_given? ? yield(s) : s
end
@@ -74,15 +76,6 @@ def dir_re(dir)
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
end
-def relative_from(path, base)
- dir = File.join(path, "")
- if File.expand_path(dir) == File.expand_path(dir, base)
- path
- else
- File.join(base, path)
- end
-end
-
INSTALL_DIRS = [
[dir_re('commondir'), "$(RUBYCOMMONDIR)"],
[dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
@@ -92,46 +85,40 @@ INSTALL_DIRS = [
[dir_re('sitelibdir'), "$(RUBYLIBDIR)"],
[dir_re('vendorlibdir'), "$(RUBYLIBDIR)"],
[dir_re('sitearchdir'), "$(RUBYARCHDIR)"],
+ [dir_re('bindir'), "$(BINDIR)"],
[dir_re('vendorarchdir'), "$(RUBYARCHDIR)"],
- [dir_re('rubyhdrdir'), "$(RUBYHDRDIR)"],
- [dir_re('sitehdrdir'), "$(SITEHDRDIR)"],
- [dir_re('vendorhdrdir'), "$(VENDORHDRDIR)"],
]
def install_dirs(target_prefix = nil)
if $extout
dirs = [
+ ['BINDIR', '$(extout)/bin'],
['RUBYCOMMONDIR', '$(extout)/common'],
['RUBYLIBDIR', '$(RUBYCOMMONDIR)$(target_prefix)'],
['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'],
- ['HDRDIR', '$(extout)/include/ruby$(target_prefix)'],
- ['ARCHHDRDIR', '$(extout)/include/$(arch)/ruby$(target_prefix)'],
['extout', "#$extout"],
['extout_prefix', "#$extout_prefix"],
]
elsif $extmk
dirs = [
+ ['BINDIR', '$(bindir)'],
['RUBYCOMMONDIR', '$(rubylibdir)'],
['RUBYLIBDIR', '$(rubylibdir)$(target_prefix)'],
['RUBYARCHDIR', '$(archdir)$(target_prefix)'],
- ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
- ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
]
elsif $configure_args.has_key?('--vendor')
dirs = [
+ ['BINDIR', '$(bindir)'],
['RUBYCOMMONDIR', '$(vendordir)$(target_prefix)'],
['RUBYLIBDIR', '$(vendorlibdir)$(target_prefix)'],
['RUBYARCHDIR', '$(vendorarchdir)$(target_prefix)'],
- ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
- ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
]
else
dirs = [
+ ['BINDIR', '$(bindir)'],
['RUBYCOMMONDIR', '$(sitedir)$(target_prefix)'],
['RUBYLIBDIR', '$(sitelibdir)$(target_prefix)'],
['RUBYARCHDIR', '$(sitearchdir)$(target_prefix)'],
- ['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
- ['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
]
end
dirs << ['target_prefix', (target_prefix ? "/#{target_prefix}" : "")]
@@ -140,49 +127,49 @@ end
def map_dir(dir, map = nil)
map ||= INSTALL_DIRS
- map.inject(dir) {|d, (orig, new)| d.gsub(orig, new)}
+ map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)}
end
topdir = File.dirname(libdir = File.dirname(__FILE__))
extdir = File.expand_path("ext", topdir)
-path = File.expand_path($0)
-$extmk = path[0, topdir.size+1] == topdir+"/" && %r"\A(ext|enc|tool)\z" =~ File.dirname(path[topdir.size+1..-1])
-if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
+$extmk = File.expand_path($0)[0, extdir.size+1] == extdir+"/"
+if not $extmk and File.exist?(($hdrdir = Config::CONFIG["archdir"]) + "/ruby.h")
$topdir = $hdrdir
- $top_srcdir = $hdrdir
- $arch_hdrdir = $hdrdir + "/$(arch)"
-elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir) + "/include") + "/ruby.h") and
- File.exist?("#{CONFIG["EXTOUT"]}/include/#{CONFIG["arch"]}/ruby/config.h")
- $topdir ||= RbConfig::CONFIG["topdir"]
- $arch_hdrdir = "$(extout)/include/$(arch)"
+elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir)) + "/ruby.h") and
+ File.exist?(($topdir ||= Config::CONFIG["topdir"]) + "/config.h")
else
abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h"
end
OUTFLAG = CONFIG['OUTFLAG']
-COUTFLAG = CONFIG['COUTFLAG']
CPPOUTFILE = CONFIG['CPPOUTFILE']
-CONFTEST_C = "conftest.c".freeze
+CONFTEST_C = "conftest.c"
class String
+ # Wraps a string in escaped quotes if it contains whitespace.
def quote
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
end
+
+ # Generates a string used as cpp macro name.
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_", "_")
end
end
class Array
+ # Wraps all strings in escaped quotes if they contain whitespace.
def quote
map {|s| s.quote}
end
end
def rm_f(*files)
- FileUtils.rm_f(Dir[*files])
+ FileUtils.rm_f(Dir[files.join("\0")])
end
+# Returns time stamp of the +target+ file if it exists and is newer
+# than or equal to all of +times+.
def modified?(target, times)
(t = File.mtime(target)) rescue return nil
Array === times or times = [times]
@@ -205,6 +192,12 @@ def merge_libs(*libs)
end
end
+# This is a custom logging module. It generates an mkmf.log file when you
+# run your extconf.rb script. This can be useful for debugging unexpected
+# failures.
+#
+# This module and its associated methods are meant for internal use only.
+#
module Logging
@log = nil
@logfile = 'mkmf.log'
@@ -262,6 +255,12 @@ module Logging
end
def xsystem command
+ varpat = /\$\((\w+)\)|\$\{(\w+)\}/
+ if varpat =~ command
+ vars = Hash.new {|h, k| h[k] = ''; ENV[k]}
+ command = command.dup
+ nil while command.gsub!(varpat) {vars[$1||$2]}
+ end
Logging::open do
puts command.quote
system(command)
@@ -311,35 +310,29 @@ ensure
end
def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
- conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote,
- 'src' => CONFTEST_C,
- 'arch_hdrdir' => "#$arch_hdrdir",
- 'top_srcdir' => $top_srcdir.quote,
- 'INCFLAGS' => "#$INCFLAGS",
- 'CPPFLAGS' => "#$CPPFLAGS",
- 'CFLAGS' => "#$CFLAGS",
- 'ARCH_FLAG' => "#$ARCH_FLAG",
- 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
- 'LIBPATH' => libpathflag(libpath),
- 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
- 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
- RbConfig::expand(TRY_LINK.dup, conf)
+ conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote,
+ 'src' => CONFTEST_C,
+ 'INCFLAGS' => $INCFLAGS,
+ 'CPPFLAGS' => $CPPFLAGS,
+ 'CFLAGS' => "#$CFLAGS",
+ 'ARCH_FLAG' => "#$ARCH_FLAG",
+ 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
+ 'LIBPATH' => libpathflag(libpath),
+ 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
+ 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
+ Config::expand(TRY_LINK.dup, conf)
end
def cc_command(opt="")
- conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
- 'arch_hdrdir' => "#$arch_hdrdir",
- 'top_srcdir' => $top_srcdir.quote)
- RbConfig::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
- conf)
+ conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
+ Config::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
+ conf)
end
def cpp_command(outfile, opt="")
- conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
- 'arch_hdrdir' => "#$arch_hdrdir",
- 'top_srcdir' => $top_srcdir.quote)
- RbConfig::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
- conf)
+ conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
+ Config::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
+ conf)
end
def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
@@ -519,6 +512,7 @@ ensure
log_src(src)
end
+# This is used internally by the have_macro? method.
def macro_defined?(macro, src, opt = "", &b)
src = src.sub(/[^\n]\z/, "\\&\n")
try_compile(src + <<"SRC", opt, &b)
@@ -542,13 +536,14 @@ end
def install_files(mfile, ifiles, map = nil, srcprefix = nil)
ifiles or return
+ ifiles.empty? and return
srcprefix ||= '$(srcdir)'
- RbConfig::expand(srcdir = srcprefix.dup)
+ Config::expand(srcdir = srcprefix.dup)
dirs = []
path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]}
ifiles.each do |files, dir, prefix|
dir = map_dir(dir, map)
- prefix = %r|\A#{Regexp.quote(prefix)}/?| if prefix
+ prefix &&= %r|\A#{Regexp.quote(prefix)}/?|
if /\A\.\// =~ files
# install files which are in current working directory.
files = files[2..-1]
@@ -559,9 +554,12 @@ def install_files(mfile, ifiles, map = nil, srcprefix = nil)
len = srcdir.size
end
f = nil
- Dir.glob(files) do |fx|
- f = fx
+ Dir.glob(files) do |f|
f[0..len] = "" if len
+ case File.basename(f)
+ when *$NONINSTALLFILES
+ next
+ end
d = File.dirname(f)
d.sub!(prefix, "") if prefix
d = (d.empty? || d == ".") ? dir : File.join(dir, d)
@@ -582,7 +580,7 @@ def install_rb(mfile, dest, srcdir = nil)
install_files(mfile, [["lib/**/*.rb", dest, "lib"]], nil, srcdir)
end
-def append_library(libs, lib)
+def append_library(libs, lib) # :no-doc:
format(LIBARG, lib) + " " + libs
end
@@ -593,8 +591,13 @@ def message(*s)
end
end
+# This emits a string to stdout that allows users to see the results of the
+# various have* and find* methods as they are tested.
+#
+# Internal use only.
+#
def checking_for(m, fmt = nil)
- f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim #'
+ f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
m = "checking #{/\Acheck/ =~ f ? '' : 'for '}#{m}... "
message "%s", m
a = r = nil
@@ -622,6 +625,8 @@ def checking_message(target, place = nil, opt = nil)
end
end
+# :startdoc:
+
# Returns whether or not +macro+ is defined either in the common header
# files or within any +headers+ you provide.
#
@@ -641,7 +646,7 @@ end
# If +headers+ are provided, it will include those header files as the
# header files it looks in when searching for +func+.
#
-# Real name of the library to be linked can be altered by
+# The real name of the library to be linked can be altered by
# '--with-FOOlib' configuration option.
#
def have_library(lib, func = nil, headers = nil, &b)
@@ -780,12 +785,10 @@ end
# (in addition to the common header files).
#
# If found, a macro is passed as a preprocessor constant to the compiler using
-# the type name and the member name, in uppercase, prepended with 'HAVE_'.
+# the member name, in uppercase, prepended with 'HAVE_ST_'.
#
# For example, if have_struct_member('struct foo', 'bar') returned true, then the
-# HAVE_STRUCT_FOO_BAR preprocessor macro would be passed to the compiler.
-#
-# HAVE_ST_BAR is also defined for backward compatibility.
+# HAVE_ST_BAR preprocessor macro would be passed to the compiler.
#
def have_struct_member(type, member, headers = nil, &b)
checking_for checking_message("#{type}.#{member}", headers) do
@@ -796,8 +799,7 @@ def have_struct_member(type, member, headers = nil, &b)
int main() { return 0; }
int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
SRC
- $defs.push(format("-DHAVE_%s_%s", type.tr_cpp, member.tr_cpp))
- $defs.push(format("-DHAVE_ST_%s", member.tr_cpp)) # backward compatibility
+ $defs.push(format("-DHAVE_ST_%s", member.tr_cpp))
true
else
false
@@ -921,6 +923,10 @@ def check_sizeof(type, headers = nil, &b)
end
end
+# :stopdoc:
+
+# Used internally by the what_type? method to determine if +type+ is a scalar
+# pointer.
def scalar_ptr_type?(type, member = nil, headers = nil, &b)
try_compile(<<"SRC", &b) # pointer
#{COMMON_HEADERS}
@@ -932,6 +938,8 @@ int t() {return (int)(1-*(conftestval#{member ? ".#{member}" : ""}));}
SRC
end
+# Used internally by the what_type? method to determine if +type+ is a scalar
+# pointer.
def scalar_type?(type, member = nil, headers = nil, &b)
try_compile(<<"SRC", &b) # pointer
#{COMMON_HEADERS}
@@ -975,6 +983,10 @@ def what_type?(type, member = nil, headers = nil, &b)
end
end
+# This method is used internally by the find_executable method.
+#
+# Internal use only.
+#
def find_executable0(bin, path = nil)
ext = config_string('EXEEXT')
if File.expand_path(bin) == bin
@@ -995,32 +1007,54 @@ def find_executable0(bin, path = nil)
nil
end
+# :startdoc:
+
+# Searches for the executable +bin+ on +path+. The default path is your
+# PATH environment variable. If that isn't defined, it will resort to
+# searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
+#
+# If found, it will return the full path, including the executable name,
+# of where it was found.
+#
+# Note that this method does not actually affect the generated Makefile.
+#
def find_executable(bin, path = nil)
checking_for checking_message(bin, path) do
find_executable0(bin, path)
end
end
-def arg_config(config, default=nil, &block)
- $arg_config << [config, default]
- defaults = []
- if default
- defaults << default
- elsif !block
- defaults << nil
- end
+# :stopdoc:
+
+def arg_config(config, *defaults, &block)
+ $arg_config << [config, *defaults]
+ defaults << nil if !block and defaults.empty?
$configure_args.fetch(config.tr('_', '-'), *defaults, &block)
end
-def with_config(config, default=nil)
+# :startdoc:
+
+# Tests for the presence of a --with-<tt>config</tt> or --without-<tt>config</tt>
+# option. Returns true if the with option is given, false if the without
+# option is given, and the default value otherwise.
+#
+# This can be useful for adding custom definitions, such as debug information.
+#
+# Example:
+#
+# if with_config("debug")
+# $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+# end
+#
+def with_config(config, *defaults)
config = config.sub(/^--with[-_]/, '')
val = arg_config("--with-"+config) do
if arg_config("--without-"+config)
false
elsif block_given?
- yield(config, default)
+ yield(config, *defaults)
else
- break default
+ break *defaults
end
end
case val
@@ -1033,30 +1067,68 @@ def with_config(config, default=nil)
end
end
-def enable_config(config, default=nil)
+# Tests for the presence of an --enable-<tt>config</tt> or
+# --disable-<tt>config</tt> option. Returns true if the enable option is given,
+# false if the disable option is given, and the default value otherwise.
+#
+# This can be useful for adding custom definitions, such as debug information.
+#
+# Example:
+#
+# if enable_config("debug")
+# $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+# end
+#
+def enable_config(config, *defaults)
if arg_config("--enable-"+config)
true
elsif arg_config("--disable-"+config)
false
elsif block_given?
- yield(config, default)
+ yield(config, *defaults)
else
- return default
+ return *defaults
end
end
+# Generates a header file consisting of the various macro definitions generated
+# by other methods such as have_func and have_header. These are then wrapped in
+# a custom #ifndef based on the +header+ file name, which defaults to
+# 'extconf.h'.
+#
+# For example:
+#
+# # extconf.rb
+# require 'mkmf'
+# have_func('realpath')
+# have_header('sys/utime.h')
+# create_header
+# create_makefile('foo')
+#
+# The above script would generate the following extconf.h file:
+#
+# #ifndef EXTCONF_H
+# #define EXTCONF_H
+# #define HAVE_REALPATH 1
+# #define HAVE_SYS_UTIME_H 1
+# #endif
+#
+# Given that the create_header method generates a file based on definitions
+# set earlier in your extconf.rb file, you will probably want to make this
+# one of the last methods you call in your script.
+#
def create_header(header = "extconf.h")
message "creating %s\n", header
- sym = header.tr("a-z./\055", "A-Z___")
+ sym = header.tr("a-z./\055", "A-Z___")
hdr = ["#ifndef #{sym}\n#define #{sym}\n"]
- for line in $defs
- case line
- when /^-D([^=]+)(?:=(.*))?/
+ for line in $defs
+ case line
+ when /^-D([^=]+)(?:=(.*))?/
hdr << "#define #$1 #{$2 ? Shellwords.shellwords($2)[0] : 1}\n"
- when /^-U(.*)/
+ when /^-U(.*)/
hdr << "#undef #$1\n"
- end
- end
+ end
+ end
hdr << "#endif\n"
hdr = hdr.join
unless (IO.read(header) == hdr rescue false)
@@ -1091,11 +1163,11 @@ def dir_config(target, idefault=nil, ldefault=nil)
idirs = idir ? Array === idir ? idir : idir.split(File::PATH_SEPARATOR) : []
if defaults
- idirs.concat(defaults.collect {|d| d + "/include"})
+ idirs.concat(defaults.collect {|dir| dir + "/include"})
idir = ([idir] + idirs).compact.join(File::PATH_SEPARATOR)
end
unless idirs.empty?
- idirs.collect! {|d| "-I" + d}
+ idirs.collect! {|dir| "-I" + dir}
idirs -= Shellwords.shellwords($CPPFLAGS)
unless idirs.empty?
$CPPFLAGS = (idirs.quote << $CPPFLAGS).join(" ")
@@ -1104,7 +1176,7 @@ def dir_config(target, idefault=nil, ldefault=nil)
ldirs = ldir ? Array === ldir ? ldir : ldir.split(File::PATH_SEPARATOR) : []
if defaults
- ldirs.concat(defaults.collect {|d| d + "/lib"})
+ ldirs.concat(defaults.collect {|dir| dir + "/lib"})
ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
end
$LIBPATH = ldirs | $LIBPATH
@@ -1112,6 +1184,10 @@ def dir_config(target, idefault=nil, ldefault=nil)
[idir, ldir]
end
+# :stopdoc:
+
+# Handles meta information about installed libraries. Uses your platform's
+# pkg-config program if it has one.
def pkg_config(pkg)
if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
# iff package specific config command is given
@@ -1149,24 +1225,27 @@ def with_destdir(dir)
/\A\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir
end
+# Converts forward slashes to backslashes. Aimed at MS Windows.
+#
+# Internal use only.
+#
def winsep(s)
s.tr('/', '\\')
end
def configuration(srcdir)
mk = []
- vpath = $VPATH.dup
+ vpath = %w[$(srcdir) $(topdir) $(hdrdir)]
if !CROSS_COMPILING
case CONFIG['build_os']
when 'cygwin'
if CONFIG['target_os'] != 'cygwin'
- vpath = vpath.map {|p| p.sub(/.*/, '$(shell cygpath -u \&)')}
+ vpath.each {|p| p.sub!(/.*/, '$(shell cygpath -u \&)')}
end
when 'msdosdjgpp', 'mingw32'
CONFIG['PATH_SEPARATOR'] = ';'
end
end
- CONFIG["hdrdir"] ||= $hdrdir
mk << %{
SHELL = /bin/sh
@@ -1178,8 +1257,7 @@ end
}
srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {CONFIG[$1||$2]}.quote}
topdir = #{($extmk ? CONFIG["topdir"] : $topdir).quote}
-hdrdir = #{CONFIG["hdrdir"].quote}
-arch_hdrdir = #{$arch_hdrdir}
+hdrdir = #{$extmk ? CONFIG["hdrdir"].quote : '$(topdir)'}
VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
}
if $extmk
@@ -1194,8 +1272,7 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
end
CONFIG.each do |key, var|
next if /^abs_/ =~ key
- next if /^(?:src|top|hdr)dir$/ =~ key
- next unless /dir$/ =~ key
+ next unless /^(?:src|top|hdr|(.*))dir$/ =~ key and $1
mk << "#{key} = #{with_destdir(var)}\n"
end
if !$extmk and !$configure_args.has_key?('--ruby') and
@@ -1207,13 +1284,10 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
extconf_h = $extconf_h ? "-DRUBY_EXTCONF_H=\\\"$(RUBY_EXTCONF_H)\\\" " : $defs.join(" ")<<" "
mk << %{
CC = #{CONFIG['CC']}
-CXX = #{CONFIG['CXX']}
LIBRUBY = #{CONFIG['LIBRUBY']}
LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
-OUTFLAG = #{OUTFLAG}
-COUTFLAG = #{COUTFLAG}
RUBY_EXTCONF_H = #{$extconf_h}
CFLAGS = #{$static ? '' : CONFIG['CCDLFLAGS']} #$CFLAGS #$ARCH_FLAG
@@ -1226,7 +1300,6 @@ dldflags = #{$DLDFLAGS}
archflag = #{$ARCH_FLAG}
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
LDSHARED = #{CONFIG['LDSHARED']}
-LDSHAREDXX = #{config_string('LDSHAREDXX') || '$(LDSHARED)'}
AR = #{CONFIG['AR']}
EXEEXT = #{CONFIG['EXEEXT']}
@@ -1234,7 +1307,7 @@ RUBY_INSTALL_NAME = #{CONFIG['RUBY_INSTALL_NAME']}
RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
arch = #{CONFIG['arch']}
sitearch = #{CONFIG['sitearch']}
-ruby_version = #{RbConfig::CONFIG['ruby_version']}
+ruby_version = #{Config::CONFIG['ruby_version']}
ruby = #{$ruby}
RUBY = $(ruby#{sep})
RM = #{config_string('RM') || '$(RUBY) -run -e rm -- -f'}
@@ -1246,7 +1319,7 @@ COPY = #{config_string('CP') || '@$(RUBY) -run -e cp -- -v'}
#### End of system configuration section. ####
-preload = #{defined?($preload) && $preload ? $preload.join(' ') : ''}
+preload = #{$preload ? $preload.join(' ') : ''}
}
if $nmake == ?b
mk.each do |x|
@@ -1269,58 +1342,7 @@ all install static install-so install-rb: Makefile
RULES
end
-
-def depend_rules(depend)
- suffixes = []
- depout = []
- cont = implicit = nil
- impconv = proc do
- COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]}
- implicit = nil
- end
- ruleconv = proc do |line|
- if implicit
- if /\A\t/ =~ line
- implicit[1] << line
- next
- else
- impconv[]
- end
- end
- if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line)
- suffixes << m[1] << m[2]
- implicit = [[m[1], m[2]], [m.post_match]]
- next
- elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line
- line.gsub!(%r"(?<=\s)(?![./\\])([^$(){}+=:\s,]+)(?=\s|\z)", &RULE_SUBST.method(:%))
- end
- depout << line
- end
- depend.each_line do |line|
- line.gsub!(/\.o\b/, ".#{$OBJEXT}")
- line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h) if $config_h
- line.gsub!(%r"\$\(hdrdir\)/(?!ruby(?![^:;/\s]))(?=[-\w]+\.h)", '\&ruby/')
- if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line
- (cont ||= []) << line
- next
- elsif cont
- line = (cont << line).join
- cont = nil
- end
- ruleconv.call(line)
- end
- if cont
- ruleconv.call(cont.join)
- elsif implicit
- impconv.call
- end
- unless suffixes.empty?
- depout.unshift(".SUFFIXES: ." + suffixes.uniq.join(" .") + "\n\n")
- end
- depout.unshift("$(OBJS): $(RUBY_EXTCONF_H)\n\n") if $extconf_h
- depout.flatten!
- depout
-end
+# :startdoc:
# Generates the Makefile for your extension, passing along any options and
# preprocessor constants that you may have generated through other methods.
@@ -1370,6 +1392,10 @@ end
# instead of copying files around manually, because some third party
# libraries may depend on the +target_prefix+ being set properly.
#
+# The +srcprefix+ argument can be used to override the default source
+# directory, i.e. the current directory . It is included as part of the VPATH
+# and added to the list of INCFLAGS.
+#
def create_makefile(target, srcprefix = nil)
$target = target
libpath = $DEFLIBPATH|$LIBPATH
@@ -1390,7 +1416,7 @@ def create_makefile(target, srcprefix = nil)
end
srcprefix ||= '$(srcdir)'
- RbConfig::expand(srcdir = srcprefix.dup)
+ Config::expand(srcdir = srcprefix.dup)
if not $objs
$objs = []
@@ -1400,7 +1426,7 @@ def create_makefile(target, srcprefix = nil)
$objs.push(obj) unless $objs.index(obj)
end
elsif !(srcs = $srcs)
- srcs = $objs.collect {|o| o.sub(/\.o\z/, '.c')}
+ srcs = $objs.collect {|obj| obj.sub(/\.o\z/, '.c')}
end
$srcs = srcs
for i in $objs
@@ -1414,7 +1440,7 @@ def create_makefile(target, srcprefix = nil)
if File.exist?(File.join(srcdir, target + '.def'))
deffile = "$(srcdir)/$(TARGET).def"
unless EXPORT_PREFIX.empty?
- makedef = %{-pe "$_.sub!(/^(?=\\w)/,'#{EXPORT_PREFIX}') unless 1../^EXPORTS$/i"}
+ makedef = %{-pe "sub!(/^(?=\\w)/,'#{EXPORT_PREFIX}') unless 1../^EXPORTS$/i"}
end
else
makedef = %{-e "puts 'EXPORTS', '#{EXPORT_PREFIX}Init_$(TARGET)'"}
@@ -1427,16 +1453,12 @@ def create_makefile(target, srcprefix = nil)
end
origdef ||= ''
- if $extmk and not $extconf_h
- create_header
- end
-
libpath = libpathflag(libpath)
dllib = target ? "$(TARGET).#{CONFIG['DLEXT']}" : ""
staticlib = target ? "$(TARGET).#$LIBEXT" : ""
mfile = open("Makefile", "wb")
- mfile.print(*configuration(srcprefix))
+ mfile.print configuration(srcprefix)
mfile.print "
libpath = #{($DEFLIBPATH|$LIBPATH).join(" ")}
LIBPATH = #{libpath}
@@ -1457,8 +1479,7 @@ DLLIB = #{dllib}
EXTSTATIC = #{$static || ""}
STATIC_LIB = #{staticlib unless $static.nil?}
#{!$extout && defined?($installed_list) ? "INSTALLED_LIST = #{$installed_list}\n" : ""}
-" #"
- # TODO: fixme
+"
install_dirs.each {|d| mfile.print("%-14s= %s\n" % d) if /^[[:upper:]]/ =~ d[0]}
n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET).'
mfile.print "
@@ -1508,7 +1529,7 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
dirs << dir
mfile.print "pre-install-rb#{sfx}: #{dir}\n"
end
- for f in files
+ files.each do |f|
dest = "#{dir}/#{File.basename(f)}"
mfile.print("install-rb#{sfx}: #{dest}\n")
mfile.print("#{dest}: #{f} #{dir}\n\t$(#{$extout ? 'COPY' : 'INSTALL_DATA'}) ")
@@ -1529,7 +1550,7 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
end
end
dirs.unshift(sodir) if target and !dirs.include?(sodir)
- dirs.each {|d| mfile.print "#{d}:\n\t$(MAKEDIRS) $@\n"}
+ dirs.each {|dir| mfile.print "#{dir}:\n\t$(MAKEDIRS) $@\n"}
mfile.print <<-SITEINSTALL
@@ -1558,18 +1579,14 @@ site-install-rb: install-rb
end
end
- sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if s != "/"} || ""
mfile.print "$(RUBYARCHDIR)/" if $extout
mfile.print "$(DLLIB): ", (makedef ? "$(DEFFILE) " : ""), "$(OBJS)\n"
- mfile.print "\t@-$(RM) $(@#{sep})\n"
+ mfile.print "\t@-$(RM) $@\n"
mfile.print "\t@-$(MAKEDIRS) $(@D)\n" if $extout
link_so = LINK_SO.gsub(/^/, "\t")
- if srcs.any?(&%r"\.(?:#{CXX_EXT.join('|')})\z".method(:===))
- link_so = link_so.sub(/\bLDSHARED\b/, '\&XX')
- end
mfile.print link_so, "\n\n"
unless $static.nil?
- mfile.print "$(STATIC_LIB): $(OBJS)\n\t@-$(RM) $(@#{sep})\n\t"
+ mfile.print "$(STATIC_LIB): $(OBJS)\n\t"
mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS)"
config_string('RANLIB') do |ranlib|
mfile.print "\n\t@-#{ranlib} $(DLLIB) 2> /dev/null || true"
@@ -1583,14 +1600,63 @@ site-install-rb: install-rb
depend = File.join(srcdir, "depend")
if File.exist?(depend)
- mfile.print("###\n", *depend_rules(File.read(depend)))
+ suffixes = []
+ depout = []
+ open(depend, "r") do |dfile|
+ mfile.printf "###\n"
+ cont = implicit = nil
+ impconv = proc do
+ COMPILE_RULES.each {|rule| depout << (rule % implicit[0]) << implicit[1]}
+ implicit = nil
+ end
+ ruleconv = proc do |line|
+ if implicit
+ if /\A\t/ =~ line
+ implicit[1] << line
+ next
+ else
+ impconv[]
+ end
+ end
+ if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line)
+ suffixes << m[1] << m[2]
+ implicit = [[m[1], m[2]], [m.post_match]]
+ next
+ elsif RULE_SUBST and /\A(?!\s*\w+\s*=)[$\w][^#]*:/ =~ line
+ line.gsub!(%r"(\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)") {$1 + RULE_SUBST % $2}
+ end
+ depout << line
+ end
+ while line = dfile.gets()
+ line.gsub!(/\.o\b/, ".#{$OBJEXT}")
+ line.gsub!(/\$\((?:hdr|top)dir\)\/config.h/, $config_h) if $config_h
+ if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line
+ (cont ||= []) << line
+ next
+ elsif cont
+ line = (cont << line).join
+ cont = nil
+ end
+ ruleconv.call(line)
+ end
+ if cont
+ ruleconv.call(cont.join)
+ elsif implicit
+ impconv.call
+ end
+ end
+ unless suffixes.empty?
+ mfile.print ".SUFFIXES: .", suffixes.uniq.join(" ."), "\n\n"
+ end
+ mfile.print "$(OBJS): $(RUBY_EXTCONF_H)\n\n" if $extconf_h
+ mfile.print depout
else
headers = %w[ruby.h defines.h]
if RULE_SUBST
- headers.each {|h| h.sub!(/.*/, &RULE_SUBST.method(:%))}
+ headers.each {|h| h.sub!(/.*/) {|*m| RULE_SUBST % m}}
end
headers << $config_h if $config_h
- headers << '$(RUBY_EXTCONF_H)' if $extconf_h
+ headers << "$(RUBY_EXTCONF_H)" if $extconf_h
mfile.print "$(OBJS): ", headers.join(' '), "\n"
end
@@ -1599,6 +1665,8 @@ ensure
mfile.close if mfile
end
+# :stopdoc:
+
def init_mkmf(config = CONFIG)
$makefile_created = false
$arg_config = []
@@ -1609,7 +1677,7 @@ def init_mkmf(config = CONFIG)
$ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup
$LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", config["LDFLAGS"])).dup
- $INCFLAGS = "-I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)"
+ $INCFLAGS = "-I$(topdir) -I$(hdrdir) -I$(srcdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
$LIBEXT = config['LIBEXT'].dup
$OBJEXT = config["OBJEXT"].dup
@@ -1620,13 +1688,13 @@ def init_mkmf(config = CONFIG)
$DEFLIBPATH = $extmk ? ["$(topdir)"] : CROSS_COMPILING ? [] : ["$(libdir)"]
$DEFLIBPATH.unshift(".")
$LIBPATH = []
- $INSTALLFILES = nil
- $VPATH = %w[$(srcdir) $(arch_hdrdir)/ruby $(hdrdir)/ruby]
+ $INSTALLFILES = []
+ $NONINSTALLFILES = [/~\z/, /\A#.*#\z/, /\A\.#/, /\.bak\z/i, /\.orig\z/, /\.rej\z/, /\.l[ao]\z/, /\.o\z/]
$objs = nil
$srcs = nil
$libs = ""
- if $enable_shared or RbConfig.expand(config["LIBRUBY"].dup) != RbConfig.expand(config["LIBRUBY_A"].dup)
+ if $enable_shared or Config.expand(config["LIBRUBY"].dup) != Config.expand(config["LIBRUBY_A"].dup)
$LIBRUBYARG = config['LIBRUBYARG']
end
@@ -1651,6 +1719,11 @@ details. You may need configuration options.
Provided configuration options:
MESSAGE
+# Returns whether or not the Makefile was successfully generated. If not,
+# the script will abort with an error message.
+#
+# Internal use only.
+#
def mkmf_failed(path)
unless $makefile_created or File.exist?("Makefile")
opts = $arg_config.collect {|t, n| "\t#{t}#{n ? "=#{n}" : ""}\n"}
@@ -1658,6 +1731,8 @@ def mkmf_failed(path)
end
end
+# :startdoc:
+
init_mkmf
$make = with_config("make-prog", ENV["MAKE"] || "make")
@@ -1670,20 +1745,20 @@ when $bccwin
$nmake = ?b if /Borland/i =~ `#{make} -h`
end
-RbConfig::CONFIG["srcdir"] = CONFIG["srcdir"] =
+Config::CONFIG["srcdir"] = CONFIG["srcdir"] =
$srcdir = arg_config("--srcdir", File.dirname($0))
$configure_args["--topsrcdir"] ||= $srcdir
if $curdir = arg_config("--curdir")
- RbConfig.expand(curdir = $curdir.dup)
+ Config.expand(curdir = $curdir.dup)
else
curdir = $curdir = "."
end
-unless File.expand_path(RbConfig::CONFIG["topdir"]) == File.expand_path(curdir)
+unless File.expand_path(Config::CONFIG["topdir"]) == File.expand_path(curdir)
CONFIG["topdir"] = $curdir
- RbConfig::CONFIG["topdir"] = curdir
+ Config::CONFIG["topdir"] = curdir
end
$configure_args["--topdir"] ||= $curdir
-$ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"]))
+$ruby = arg_config("--ruby", File.join(Config::CONFIG["bindir"], CONFIG["ruby_install_name"]))
split = Shellwords.method(:shellwords).to_proc
@@ -1696,15 +1771,15 @@ config_string('COMMON_MACROS') do |s|
end
end
config_string('COMMON_HEADERS') do |s|
- Shellwords.shellwords(s).each {|w| hdr << "#include <#{w}>"}
+ Shellwords.shellwords(s).each {|s| hdr << "#include <#{s}>"}
end
COMMON_HEADERS = hdr.join("\n")
COMMON_LIBS = config_string('COMMON_LIBS', &split) || []
COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
RULE_SUBST = config_string('RULE_SUBST')
-COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<'
-COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<'
+COMPILE_C = config_string('COMPILE_C') || '$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<'
+COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<'
TRY_LINK = config_string('TRY_LINK') ||
"$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
@@ -1719,7 +1794,7 @@ LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
RPATHFLAG = config_string('RPATHFLAG') || ''
LIBARG = config_string('LIBARG') || '-l%s'
-sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if sep != "/"} || ""
+sep = config_string('BUILD_FILE_SEPARATOR') {|sep| ":/=#{sep}" if sep != "/"} || ""
CLEANINGS = "
clean:
@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep})
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 31234819b8..4c146c8086 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -41,14 +41,13 @@ reads a line from ARGF and push it to buf, then call
empty_cond.signal.
=end
-
-require 'thread'
+
#
# Adds monitor functionality to an arbitrary object by mixing the module with
# +include+. For example:
#
-# require 'monitor'
+# require 'monitor.rb'
#
# buf = []
# buf.extend(MonitorMixin)
@@ -87,71 +86,122 @@ module MonitorMixin
class ConditionVariable
class Timeout < Exception; end
+ # Create a new timer with the argument timeout, and add the
+ # current thread to the list of waiters. Then the thread is
+ # stopped. It will be resumed when a corresponding #signal
+ # occurs.
def wait(timeout = nil)
- if timeout
- raise NotImplementedError, "timeout is not implemented yet"
- end
- @monitor.send(:mon_check_owner)
- count = @monitor.send(:mon_exit_for_cond)
+ @monitor.instance_eval {mon_check_owner()}
+ timer = create_timer(timeout)
+
+ Thread.critical = true
+ count = @monitor.instance_eval {mon_exit_for_cond()}
+ @waiters.push(Thread.current)
+
begin
- @cond.wait(@monitor.instance_variable_get("@mon_mutex"))
+ Thread.stop
return true
+ rescue Timeout
+ return false
ensure
- @monitor.send(:mon_enter_for_cond, count)
+ Thread.critical = true
+ begin
+ if timer && timer.alive?
+ Thread.kill(timer)
+ end
+ if @waiters.include?(Thread.current) # interrupted?
+ @waiters.delete(Thread.current)
+ end
+ @monitor.instance_eval {mon_enter_for_cond(count)}
+ ensure
+ Thread.critical = false
+ end
end
end
+
+ # call #wait while the supplied block returns +true+.
def wait_while
while yield
wait
end
end
+ # call #wait until the supplied block returns +true+.
def wait_until
until yield
wait
end
end
+ # Wake up and run the next waiter
def signal
- @monitor.send(:mon_check_owner)
- @cond.signal
+ @monitor.instance_eval {mon_check_owner()}
+ Thread.critical = true
+ t = @waiters.shift
+ t.wakeup if t
+ Thread.critical = false
+ Thread.pass
end
+ # Wake up all the waiters.
def broadcast
- @monitor.send(:mon_check_owner)
- @cond.broadcast
+ @monitor.instance_eval {mon_check_owner()}
+ Thread.critical = true
+ for t in @waiters
+ t.wakeup
+ end
+ @waiters.clear
+ Thread.critical = false
+ Thread.pass
end
def count_waiters
- raise NotImplementedError
+ return @waiters.length
end
private
def initialize(monitor)
@monitor = monitor
- @cond = ::ConditionVariable.new
+ @waiters = []
+ end
+
+ def create_timer(timeout)
+ if timeout
+ waiter = Thread.current
+ return Thread.start {
+ Thread.pass
+ sleep(timeout)
+ Thread.critical = true
+ waiter.raise(Timeout.new)
+ }
+ else
+ return nil
+ end
end
end
def self.extend_object(obj)
super(obj)
- obj.send(:mon_initialize)
+ obj.instance_eval {mon_initialize()}
end
#
# Attempts to enter exclusive section. Returns +false+ if lock fails.
#
def mon_try_enter
- if @mon_owner != Thread.current
- unless @mon_mutex.try_lock
- return false
- end
+ result = false
+ Thread.critical = true
+ if @mon_owner.nil?
@mon_owner = Thread.current
end
- @mon_count += 1
- return true
+ if @mon_owner == Thread.current
+ @mon_count += 1
+ result = true
+ end
+ Thread.critical = false
+ return result
end
# For backward compatibility
alias try_mon_enter mon_try_enter
@@ -160,11 +210,11 @@ module MonitorMixin
# Enters exclusive section.
#
def mon_enter
- if @mon_owner != Thread.current
- @mon_mutex.lock
- @mon_owner = Thread.current
- end
+ Thread.critical = true
+ mon_acquire(@mon_entering_queue)
@mon_count += 1
+ ensure
+ Thread.critical = false
end
#
@@ -172,11 +222,13 @@ module MonitorMixin
#
def mon_exit
mon_check_owner
- @mon_count -=1
+ Thread.critical = true
+ @mon_count -= 1
if @mon_count == 0
- @mon_owner = nil
- @mon_mutex.unlock
+ mon_release
end
+ Thread.critical = false
+ Thread.pass
end
#
@@ -196,6 +248,9 @@ module MonitorMixin
#
# FIXME: This isn't documented in Nutshell.
+ #
+ # Create a new condition variable for this monitor.
+ # This facilitates control of the monitor with #signal and #wait.
#
def new_cond
return ConditionVariable.new(self)
@@ -208,31 +263,63 @@ module MonitorMixin
mon_initialize
end
+ # called by initialize method to set defaults for instance variables.
def mon_initialize
@mon_owner = nil
@mon_count = 0
- @mon_mutex = Mutex.new
+ @mon_entering_queue = []
+ @mon_waiting_queue = []
end
+ # Throw a ThreadError exception if the current thread
+ # does't own the monitor
def mon_check_owner
if @mon_owner != Thread.current
raise ThreadError, "current thread not owner"
end
end
- def mon_enter_for_cond(count)
+ def mon_acquire(queue)
+ while @mon_owner && @mon_owner != Thread.current
+ queue.push(Thread.current)
+ Thread.stop
+ Thread.critical = true
+ end
@mon_owner = Thread.current
+ end
+
+ def mon_release
+ @mon_owner = nil
+ t = @mon_waiting_queue.shift
+ t = @mon_entering_queue.shift unless t
+ t.wakeup if t
+ end
+
+ def mon_enter_for_cond(count)
+ mon_acquire(@mon_waiting_queue)
@mon_count = count
end
def mon_exit_for_cond
count = @mon_count
- @mon_owner = nil
@mon_count = 0
return count
+ ensure
+ mon_release
end
end
+# Monitors provide means of mutual exclusion for Thread programming.
+# A critical region is created by means of the synchronize method,
+# which takes a block.
+# The condition variables (created with #new_cond) may be used
+# to control the execution of a monitor with #signal and #wait.
+#
+# the Monitor class wraps MonitorMixin, and provides aliases
+# alias try_enter try_mon_enter
+# alias enter mon_enter
+# alias exit mon_exit
+# to access its methods more concisely.
class Monitor
include MonitorMixin
alias try_enter try_mon_enter
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index f776767324..8e0d42bc8d 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -1,4 +1,4 @@
-#
+#--
# mutex_m.rb -
# $Release Version: 3.0$
# $Revision: 1.7 $
@@ -7,24 +7,26 @@
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
# modified by matz
# patched by akira yamada
+#++
#
-# --
-# Usage:
-# require "mutex_m.rb"
-# obj = Object.new
-# obj.extend Mutex_m
-# ...
-# extended object can be handled like Mutex
-# or
-# class Foo
-# include Mutex_m
-# ...
-# end
-# obj = Foo.new
-# this obj can be handled like Mutex
+# == Usage
#
-
-require 'thread'
+# Extend an object and use it like a Mutex object:
+#
+# require "mutex_m.rb"
+# obj = Object.new
+# obj.extend Mutex_m
+# # ...
+#
+# Or, include Mutex_m in a class to have its instances behave like a Mutex
+# object:
+#
+# class Foo
+# include Mutex_m
+# # ...
+# end
+#
+# obj = Foo.new
module Mutex_m
def Mutex_m.define_aliases(cl)
@@ -59,30 +61,58 @@ module Mutex_m
end
# locking
- def mu_synchronize(&block)
- @_mutex.synchronize(&block)
+ def mu_synchronize
+ begin
+ mu_lock
+ yield
+ ensure
+ mu_unlock
+ end
end
def mu_locked?
- @_mutex.locked?
+ @mu_locked
end
def mu_try_lock
- @_mutex.try_lock
+ result = false
+ Thread.critical = true
+ unless @mu_locked
+ @mu_locked = true
+ result = true
+ end
+ Thread.critical = false
+ result
end
def mu_lock
- @_mutex.lock
+ while (Thread.critical = true; @mu_locked)
+ @mu_waiting.push Thread.current
+ Thread.stop
+ end
+ @mu_locked = true
+ Thread.critical = false
+ self
end
def mu_unlock
- @_mutex.unlock
+ return unless @mu_locked
+ Thread.critical = true
+ wait = @mu_waiting
+ @mu_waiting = []
+ @mu_locked = false
+ Thread.critical = false
+ for w in wait
+ w.run
+ end
+ self
end
private
def mu_initialize
- @_mutex = Mutex.new
+ @mu_waiting = []
+ @mu_locked = false;
end
def initialize(*args)
diff --git a/lib/net/.document b/lib/net/.document
deleted file mode 100644
index 6332bb9e7e..0000000000
--- a/lib/net/.document
+++ /dev/null
@@ -1,8 +0,0 @@
-ftp.rb
-http.rb
-https.rb
-imap.rb
-pop.rb
-smtp.rb
-smtps.rb
-telnet.rb
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 2167a52895..ca2c00a790 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -79,7 +79,7 @@ module Net
# :startdoc:
# When +true+, transfers are performed in binary mode. Default: +true+.
- attr_reader :binary
+ attr_accessor :binary
# When +true+, the connection is in passive mode. Default: +false+.
attr_accessor :passive
@@ -128,7 +128,7 @@ module Net
#
def initialize(host = nil, user = nil, passwd = nil, acct = nil)
super()
- @binary = false
+ @binary = true
@passive = false
@debug_mode = false
@resume = false
@@ -140,24 +140,6 @@ module Net
end
end
- def binary=(newmode)
- if newmode != @binary
- @binary = newmode
- @binary ? voidcmd("TYPE I") : voidcmd("TYPE A")
- end
- end
-
- def with_binary(newmode)
- oldmode = binary
- self.binary = newmode
- begin
- yield
- ensure
- self.binary = oldmode
- end
- end
- private :with_binary
-
# Obsolete
def return_code
$stderr.puts("warning: Net::FTP#return_code is obsolete and do nothing")
@@ -296,12 +278,9 @@ module Net
def sendport(host, port)
af = (@sock.peeraddr)[0]
if af == "AF_INET"
- hbytes = host.split(".")
- pbytes = [port / 256, port % 256]
- bytes = hbytes + pbytes
- cmd = "PORT " + bytes.join(",")
+ cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
elsif af == "AF_INET6"
- cmd = "EPRT |2|" + host + "|" + sprintf("%d", port) + "|"
+ cmd = sprintf("EPRT |2|%s|%d|", host, port)
else
raise FTPProtoError, host
end
@@ -409,7 +388,6 @@ module Net
raise FTPReplyError, resp
end
@welcome = resp
- self.binary = true
end
#
@@ -420,16 +398,15 @@ module Net
#
def retrbinary(cmd, blocksize, rest_offset = nil) # :yield: data
synchronize do
- with_binary(true) do
- conn = transfercmd(cmd, rest_offset)
- loop do
- data = conn.read(blocksize)
- break if data == nil
- yield(data)
- end
- conn.close
- voidresp
- end
+ voidcmd("TYPE I")
+ conn = transfercmd(cmd, rest_offset)
+ loop do
+ data = conn.read(blocksize)
+ break if data == nil
+ yield(data)
+ end
+ conn.close
+ voidresp
end
end
@@ -441,21 +418,20 @@ module Net
#
def retrlines(cmd) # :yield: line
synchronize do
- with_binary(false) do
- conn = transfercmd(cmd)
- loop do
- line = conn.gets
- break if line == nil
- if line[-2, 2] == CRLF
- line = line[0 .. -3]
- elsif line[-1] == ?\n
- line = line[0 .. -2]
- end
- yield(line)
- end
- conn.close
- voidresp
- end
+ voidcmd("TYPE A")
+ conn = transfercmd(cmd)
+ loop do
+ line = conn.gets
+ break if line == nil
+ if line[-2, 2] == CRLF
+ line = line[0 .. -3]
+ elsif line[-1] == ?\n
+ line = line[0 .. -2]
+ end
+ yield(line)
+ end
+ conn.close
+ voidresp
end
end
@@ -470,25 +446,17 @@ module Net
file.seek(rest_offset, IO::SEEK_SET)
end
synchronize do
- with_binary(true) do
- conn = transfercmd(cmd, rest_offset)
- loop do
- buf = file.read(blocksize)
- break if buf == nil
- conn.write(buf)
- yield(buf) if block
- end
- conn.close
- voidresp
- end
+ voidcmd("TYPE I")
+ conn = transfercmd(cmd, rest_offset)
+ loop do
+ buf = file.read(blocksize)
+ break if buf == nil
+ conn.write(buf)
+ yield(buf) if block
+ end
+ conn.close
+ voidresp
end
- rescue Errno::EPIPE
- # EPIPE, in this case, means that the data connection was unexpectedly
- # terminated. Rather than just raising EPIPE to the caller, check the
- # response on the control connection. If getresp doesn't raise a more
- # appropriate exception, re-raise the original exception.
- getresp
- raise
end
#
@@ -499,86 +467,61 @@ module Net
#
def storlines(cmd, file, &block) # :yield: line
synchronize do
- with_binary(false) do
- conn = transfercmd(cmd)
- loop do
- buf = file.gets
- break if buf == nil
- if buf[-2, 2] != CRLF
- buf = buf.chomp + CRLF
- end
- conn.write(buf)
- yield(buf) if block
- end
- conn.close
- voidresp
- end
+ voidcmd("TYPE A")
+ conn = transfercmd(cmd)
+ loop do
+ buf = file.gets
+ break if buf == nil
+ if buf[-2, 2] != CRLF
+ buf = buf.chomp + CRLF
+ end
+ conn.write(buf)
+ yield(buf) if block
+ end
+ conn.close
+ voidresp
end
- rescue Errno::EPIPE
- # EPIPE, in this case, means that the data connection was unexpectedly
- # terminated. Rather than just raising EPIPE to the caller, check the
- # response on the control connection. If getresp doesn't raise a more
- # appropriate exception, re-raise the original exception.
- getresp
- raise
end
#
# Retrieves +remotefile+ in binary mode, storing the result in +localfile+.
- # If +localfile+ is nil, returns retrieved data.
# If a block is supplied, it is passed the retrieved data in +blocksize+
# chunks.
#
def getbinaryfile(remotefile, localfile = File.basename(remotefile),
- blocksize = DEFAULT_BLOCKSIZE) # :yield: data
- result = nil
- if localfile
- if @resume
- rest_offset = File.size?(localfile)
- f = open(localfile, "a")
- else
- rest_offset = nil
- f = open(localfile, "w")
- end
- elsif !block_given?
- result = ""
+ blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
+ if @resume
+ rest_offset = File.size?(localfile)
+ f = open(localfile, "a")
+ else
+ rest_offset = nil
+ f = open(localfile, "w")
end
begin
- f.binmode if localfile
+ f.binmode
retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
- f.write(data) if localfile
- yield(data) if block_given?
- result.concat(data) if result
+ f.write(data)
+ yield(data) if block
end
- return result
ensure
- f.close if localfile
+ f.close
end
end
#
# Retrieves +remotefile+ in ASCII (text) mode, storing the result in
- # +localfile+.
- # If +localfile+ is nil, returns retrieved data.
- # If a block is supplied, it is passed the retrieved data one
+ # +localfile+. If a block is supplied, it is passed the retrieved data one
# line at a time.
#
- def gettextfile(remotefile, localfile = File.basename(remotefile)) # :yield: line
- result = nil
- if localfile
- f = open(localfile, "w")
- elsif !block_given?
- result = ""
- end
+ def gettextfile(remotefile, localfile = File.basename(remotefile), &block) # :yield: line
+ f = open(localfile, "w")
begin
retrlines("RETR " + remotefile) do |line|
- f.puts(line) if localfile
- yield(line) if block_given?
- result.concat(line + "\n") if result
+ f.puts(line)
+ yield(line) if block
end
- return result
ensure
- f.close if localfile
+ f.close
end
end
@@ -588,10 +531,10 @@ module Net
#
def get(remotefile, localfile = File.basename(remotefile),
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
- if @binary
- getbinaryfile(remotefile, localfile, blocksize, &block)
- else
+ unless @binary
gettextfile(remotefile, localfile, &block)
+ else
+ getbinaryfile(remotefile, localfile, blocksize, &block)
end
end
@@ -640,10 +583,10 @@ module Net
#
def put(localfile, remotefile = File.basename(localfile),
blocksize = DEFAULT_BLOCKSIZE, &block)
- if @binary
- putbinaryfile(localfile, remotefile, blocksize, &block)
- else
+ unless @binary
puttextfile(localfile, remotefile, &block)
+ else
+ putbinaryfile(localfile, remotefile, blocksize, &block)
end
end
@@ -739,13 +682,12 @@ module Net
# Returns the size of the given (remote) filename.
#
def size(filename)
- with_binary(true) do
- resp = sendcmd("SIZE " + filename)
- if resp[0, 3] != "213"
- raise FTPReplyError, resp
- end
- return resp[3..-1].strip.to_i
+ voidcmd("TYPE I")
+ resp = sendcmd("SIZE " + filename)
+ if resp[0, 3] != "213"
+ raise FTPReplyError, resp
end
+ return resp[3..-1].strip.to_i
end
MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ # :nodoc:
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 06b176b3c6..7dd1f24d4c 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1,8 +1,8 @@
#
# = net/http.rb
#
-# Copyright (c) 1999-2007 Yukihiro Matsumoto
-# Copyright (c) 1999-2007 Minero Aoki
+# Copyright (c) 1999-2006 Yukihiro Matsumoto
+# Copyright (c) 1999-2006 Minero Aoki
# Copyright (c) 2001 GOTOU Yuuzou
#
# Written and maintained by Minero Aoki <aamine@loveruby.net>.
@@ -86,20 +86,19 @@ module Net #:nodoc:
#
# #1: Simple POST
# res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
- # {'q' => 'ruby', 'max' => '50'})
+ # {'q'=>'ruby', 'max'=>'50'})
# puts res.body
#
# #2: POST with basic authentication
# res = Net::HTTP.post_form(URI.parse('http://jack:pass@www.example.com/todo.cgi'),
- # {'from' => '2005-01-01',
- # 'to' => '2005-03-31'})
+ # {'from'=>'2005-01-01', 'to'=>'2005-03-31'})
# puts res.body
#
# #3: Detailed control
# url = URI.parse('http://www.example.com/todo.cgi')
# req = Net::HTTP::Post.new(url.path)
# req.basic_auth 'jack', 'pass'
- # req.set_form_data({'from' => '2005-01-01', 'to' => '2005-03-31'}, ';')
+ # req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'}, ';')
# res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
# case res
# when Net::HTTPSuccess, Net::HTTPRedirection
@@ -107,11 +106,6 @@ module Net #:nodoc:
# else
# res.error!
# end
- #
- # #4: Multiple values
- # res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
- # {'q' => ['ruby', 'perl'], 'max' => '50'})
- # puts res.body
#
# === Accessing via Proxy
#
@@ -287,13 +281,6 @@ module Net #:nodoc:
Revision = %q$Revision$.split[1]
HTTPVersion = '1.1'
@newimpl = true
- begin
- require 'zlib'
- require 'stringio' #for our purposes (unpacking gzip) lump these together
- HAVE_ZLIB=true
- rescue LoadError
- HAVE_ZLIB=false
- end
# :startdoc:
# Turns on net/http 1.2 (ruby 1.8) features.
@@ -474,7 +461,7 @@ module Net #:nodoc:
@address = address
@port = (port || HTTP.default_port)
@curr_http_version = HTTPVersion
- @no_keepalive_server = false
+ @seems_1_0_server = false
@close_on_empty_response = false
@socket = nil
@started = false
@@ -483,9 +470,6 @@ module Net #:nodoc:
@debug_output = nil
@use_ssl = false
@ssl_context = nil
- @enable_post_connection_check = true
- @compression = nil
- @sspi_enabled = false
end
def inspect
@@ -576,14 +560,10 @@ module Net #:nodoc:
s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
D "opened"
if use_ssl?
- ssl_parameters = Hash.new
- SSL_ATTRIBUTES.each do |name|
- if value = instance_variable_get("@#{name}")
- ssl_parameters[name] = value
- end
+ unless @ssl_context.verify_mode
+ warn "warning: peer certificate won't be verified in this SSL session"
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
- @ssl_context = OpenSSL::SSL::SSLContext.new
- @ssl_context.set_params(ssl_parameters)
s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
s.sync_close = true
end
@@ -753,18 +733,7 @@ module Net #:nodoc:
public
# Gets data from +path+ on the connected-to host.
- # +initheader+ must be a Hash like { 'Accept' => '*/*', ... },
- # and it defaults to an empty hash.
- # If +initheader+ doesn't have the key 'accept-encoding', then
- # a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used,
- # so that gzip compression is used in preference to deflate
- # compression, which is used in preference to no compression.
- # Ruby doesn't have libraries to support the compress (Lempel-Ziv)
- # compression, so that is not supported. The intent of this is
- # to reduce bandwidth by default. If this routine sets up
- # compression, then it does the decompression also, removing
- # the header as well to prevent confusion. Otherwise
- # it leaves the body as it found it.
+ # +header+ must be a Hash like { 'Accept' => '*/*', ... }.
#
# In version 1.1 (ruby 1.6), this method returns a pair of objects,
# a Net::HTTPResponse object and the entity body string.
@@ -798,33 +767,10 @@ module Net #:nodoc:
# end
# }
#
- def get(path, initheader = {}, dest = nil, &block) # :yield: +body_segment+
+ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+
res = nil
- if HAVE_ZLIB
- unless initheader.keys.any?{|k| k.downcase == "accept-encoding"}
- initheader["accept-encoding"] = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
- @compression = true
- end
- end
request(Get.new(path, initheader)) {|r|
- if r.key?("content-encoding") and @compression
- @compression = nil # Clear it till next set.
- the_body = r.read_body dest, &block
- case r["content-encoding"]
- when "gzip"
- r.body= Zlib::GzipReader.new(StringIO.new(the_body)).read
- r.delete("content-encoding")
- when "deflate"
- r.body= Zlib::Inflate.inflate(the_body);
- r.delete("content-encoding")
- when "identity"
- ; # nothing needed
- else
- ; # Don't do anything dramatic, unless we need to later
- end
- else
- r.read_body dest, &block
- end
+ r.read_body dest, &block
res = r
}
unless @newimpl
@@ -1092,34 +1038,34 @@ module Net #:nodoc:
}
end
if proxy_user()
- req.proxy_basic_auth proxy_user(), proxy_pass() unless use_ssl?
- end
- req.set_body_internal body
- res = transport_request(req, &block)
- if sspi_auth?(res)
- sspi_auth(req)
- res = transport_request(req, &block)
+ unless use_ssl?
+ req.proxy_basic_auth proxy_user(), proxy_pass()
+ end
end
- res
- end
-
- private
- def transport_request(req)
+ req.set_body_internal body
begin_transport req
- req.exec @socket, @curr_http_version, edit_path(req.path)
- begin
- res = HTTPResponse.read_new(@socket)
- end while res.kind_of?(HTTPContinue)
- res.reading_body(@socket, req.response_body_permitted?) {
- yield res if block_given?
- }
+ req.exec @socket, @curr_http_version, edit_path(req.path)
+ begin
+ res = HTTPResponse.read_new(@socket)
+ end while res.kind_of?(HTTPContinue)
+ res.reading_body(@socket, req.response_body_permitted?) {
+ yield res if block_given?
+ }
end_transport req, res
+
res
end
+ private
+
def begin_transport(req)
- connect if @socket.closed?
+ if @socket.closed?
+ connect
+ end
+ if @seems_1_0_server
+ req['connection'] ||= 'close'
+ end
if not req.response_body_permitted? and @close_on_empty_response
req['connection'] ||= 'close'
end
@@ -1128,13 +1074,15 @@ module Net #:nodoc:
def end_transport(req, res)
@curr_http_version = res.http_version
- if @socket.closed?
- D 'Conn socket closed'
- elsif not res.body and @close_on_empty_response
+ if not res.body and @close_on_empty_response
D 'Conn close'
@socket.close
elsif keep_alive?(req, res)
D 'Conn keep-alive'
+ if @socket.closed?
+ D 'Conn (but seems 1.0 server)'
+ @seems_1_0_server = true
+ end
else
D 'Conn close'
@socket.close
@@ -1142,40 +1090,13 @@ module Net #:nodoc:
end
def keep_alive?(req, res)
- return false if req.connection_close?
- if @curr_http_version <= '1.0'
- res.connection_keep_alive?
- else # HTTP/1.1 or later
- not res.connection_close?
- end
- end
-
- def sspi_auth?(res)
- return false unless @sspi_enabled
- if res.kind_of?(HTTPProxyAuthenticationRequired) and
- proxy? and res["Proxy-Authenticate"].include?("Negotiate")
- begin
- require 'win32/sspi'
- true
- rescue LoadError
- false
- end
- else
- false
- end
- end
-
- def sspi_auth(req)
- n = Win32::SSPI::NegotiateAuth.new
- req["Proxy-Authorization"] = "Negotiate #{n.get_initial_token}"
- # Some versions of ISA will close the connection if this isn't present.
- req["Connection"] = "Keep-Alive"
- req["Proxy-Connection"] = "Keep-Alive"
- res = transport_request(req)
- authphrase = res["Proxy-Authenticate"] or return res
- req["Proxy-Authorization"] = "Negotiate #{n.complete_authentication(authphrase)}"
- rescue => err
- raise HTTPAuthenticationError.new('HTTP authentication failed', err)
+ return false if /close/i =~ req['connection'].to_s
+ return false if @seems_1_0_server
+ return true if /keep-alive/i =~ res['connection'].to_s
+ return false if /close/i =~ res['connection'].to_s
+ return true if /keep-alive/i =~ res['proxy-connection'].to_s
+ return false if /close/i =~ res['proxy-connection'].to_s
+ (@curr_http_version == '1.1')
end
#
@@ -1502,24 +1423,13 @@ module Net #:nodoc:
#
# This method also set Content-Type: header field to
# application/x-www-form-urlencoded.
- #
- # Example:
- # http.form_data = {"q" => "ruby", "lang" => "en"}
- # http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"}
- # http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')
- #
def set_form_data(params, sep = '&')
- self.body = params.map {|k, v| encode_kvpair(k, v) }.flatten.join(sep)
+ self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
self.content_type = 'application/x-www-form-urlencoded'
end
alias form_data= set_form_data
- def encode_kvpair(k, vs)
- Array(vs).map {|v| "#{urlencode(k)}=#{urlencode(v.to_s)}" }
- end
- private :encode_kvpair
-
def urlencode(str)
str.gsub(/[^a-zA-Z0-9_\.\-]/n) {|s| sprintf('%%%02x', s[0]) }
end
@@ -1540,24 +1450,6 @@ module Net #:nodoc:
end
private :basic_encode
- def connection_close?
- tokens(@header['connection']).include?('close') or
- tokens(@header['proxy-connection']).include?('close')
- end
-
- def connection_keep_alive?
- tokens(@header['connection']).include?('keep-alive') or
- tokens(@header['proxy-connection']).include?('keep-alive')
- end
-
- def tokens(vals)
- return [] unless vals
- vals.map {|v| v.split(',') }.flatten\
- .reject {|str| str.strip.empty? }\
- .map {|tok| tok.strip.downcase }
- end
- private :tokens
-
end
@@ -1575,12 +1467,10 @@ module Net #:nodoc:
@method = m
@request_has_body = reqbody
@response_has_body = resbody
- raise ArgumentError, "no HTTP request path given" unless path
raise ArgumentError, "HTTP request path is empty" if path.empty?
@path = path
initialize_http_header initheader
self['Accept'] ||= '*/*'
- self['User-Agent'] ||= 'Ruby'
@body = nil
@body_stream = nil
end
@@ -2308,12 +2198,6 @@ module Net #:nodoc:
read_body()
end
- # Because it may be necessary to modify the body, Eg, decompression
- # this method facilitates that.
- def body=(value)
- @body = value
- end
-
alias entity body #:nodoc: obsolete
private
diff --git a/lib/net/https.rb b/lib/net/https.rb
index 8a9245ea0e..7847c3ffea 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -65,11 +65,11 @@ It can be replaced by the following code:
: key, key=((|key|))
Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
- (This method is appeared in Michal Rokos's OpenSSL extention.)
+ (This method is appeared in Michal Rokos's OpenSSL extension.)
: cert, cert=((|cert|))
Sets an OpenSSL::X509::Certificate object as client certificate
- (This method is appeared in Michal Rokos's OpenSSL extention).
+ (This method is appeared in Michal Rokos's OpenSSL extension).
: ca_file, ca_file=((|path|))
Sets path of a CA certification file in PEM format.
@@ -102,35 +102,72 @@ require 'net/http'
require 'openssl'
module Net
+
class HTTP
remove_method :use_ssl?
def use_ssl?
@use_ssl
end
+ # For backward compatibility.
+ alias use_ssl use_ssl?
+
# Turn on/off SSL.
# This flag must be set before starting session.
# If you change use_ssl value after session started,
# a Net::HTTP object raises IOError.
def use_ssl=(flag)
flag = (flag ? true : false)
- if started? and @use_ssl != flag
- raise IOError, "use_ssl value changed, but session already started"
+ raise IOError, "use_ssl value changed, but session already started" \
+ if started? and @use_ssl != flag
+ if flag and not @ssl_context
+ @ssl_context = OpenSSL::SSL::SSLContext.new
end
@use_ssl = flag
end
- SSL_ATTRIBUTES = %w(
- ssl_version key cert ca_file ca_path cert_store ciphers
- verify_mode verify_callback verify_depth ssl_timeout
- )
- attr_accessor *SSL_ATTRIBUTES
+ def self.ssl_context_accessor(name)
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def #{name}
+ return nil unless @ssl_context
+ @ssl_context.#{name}
+ end
+
+ def #{name}=(val)
+ @ssl_context ||= OpenSSL::SSL::SSLContext.new
+ @ssl_context.#{name} = val
+ end
+ End
+ end
+
+ ssl_context_accessor :key
+ ssl_context_accessor :cert
+ ssl_context_accessor :ca_file
+ ssl_context_accessor :ca_path
+ ssl_context_accessor :verify_mode
+ ssl_context_accessor :verify_callback
+ ssl_context_accessor :verify_depth
+ ssl_context_accessor :cert_store
+
+ def ssl_timeout
+ return nil unless @ssl_context
+ @ssl_context.timeout
+ end
+
+ def ssl_timeout=(sec)
+ raise ArgumentError, 'Net::HTTP#ssl_timeout= called but use_ssl=false' \
+ unless use_ssl?
+ @ssl_context ||= OpenSSL::SSL::SSLContext.new
+ @ssl_context.timeout = sec
+ end
+
+ # For backward compatibility
+ alias timeout= ssl_timeout=
def peer_cert
- if not use_ssl? or not @socket
- return nil
- end
+ return nil if not use_ssl? or not @socket
@socket.io.peer_cert
end
end
+
end
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 394f0d9890..6162ffa0d0 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -16,9 +16,8 @@
require "socket"
require "monitor"
require "digest/md5"
-require "strscan"
begin
- require "openssl/ssl"
+ require "openssl"
rescue LoadError
end
@@ -274,10 +273,8 @@ module Net
# is the type of authentication this authenticator supports
# (for instance, "LOGIN"). The +authenticator+ is an object
# which defines a process() method to handle authentication with
- # the server. See Net::IMAP::LoginAuthenticator,
- # Net::IMAP::CramMD5Authenticator, and Net::IMAP::DigestMD5Authenticator
- # for examples.
- #
+ # the server. See Net::IMAP::LoginAuthenticator and
+ # Net::IMAP::CramMD5Authenticator for examples.
#
# If +auth_type+ refers to an existing authenticator, it will be
# replaced by the new one.
@@ -287,9 +284,11 @@ module Net
# Disconnects from the server.
def disconnect
- if SSL::SSLSocket === @sock
+ begin
+ # try to call SSL::SSLSocket#io.
@sock.io.shutdown
- else
+ rescue NoMethodError
+ # @sock is not an SSL::SSLSocket.
@sock.shutdown
end
@receiver_thread.join
@@ -329,21 +328,6 @@ module Net
send_command("LOGOUT")
end
- # Sends a STARTTLS command to start TLS session.
- def starttls(options = {}, verify = true)
- send_command("STARTTLS") do |resp|
- if resp.kind_of?(TaggedResponse) && resp.name == "OK"
- begin
- # for backward compatibility
- certs = options.to_str
- options = create_ssl_params(certs, verify)
- rescue NoMethodError
- end
- start_tls_session(options)
- end
- end
- end
-
# Sends an AUTHENTICATE command to authenticate the client.
# The +auth_type+ parameter is a string that represents
# the authentication mechanism to be used. Currently Net::IMAP
@@ -850,49 +834,39 @@ module Net
if x > 0
base64.concat("=" * (4 - x))
end
- base64.unpack("m")[0].unpack("n*").pack("U*")
+ u16tou8(base64.unpack("m")[0])
end
- }.force_encoding("UTF-8")
+ }
end
# Encode a string from UTF-8 format to modified UTF-7.
def self.encode_utf7(s)
- return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { |x|
+ return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/n) { |x|
if $1
"&-"
else
- base64 = [x.unpack("U*").pack("n*")].pack("m")
+ base64 = [u8tou16(x)].pack("m")
"&" + base64.delete("=\n").tr("/", ",") + "-"
end
- }.force_encoding("ASCII-8BIT")
+ }
end
private
CRLF = "\r\n" # :nodoc:
PORT = 143 # :nodoc:
- SSL_PORT = 993 # :nodoc:
@@debug = false
@@authenticators = {}
- # call-seq:
- # Net::IMAP.new(host, options = {})
- #
# Creates a new Net::IMAP object and connects it to the specified
- # +host+.
- #
- # +options+ is an option hash, each key of which is a symbol.
- #
- # The available options are:
- #
- # port:: port number (default value is 143 for imap, or 993 for imaps)
- # ssl:: if options[:ssl] is true, then an attempt will be made
- # to use SSL (now TLS) to connect to the server. For this to work
- # OpenSSL [OSSL] and the Ruby OpenSSL [RSSL] extensions need to
- # be installed.
- # if options[:ssl] is a hash, it's passed to
- # OpenSSL::SSL::SSLContext#set_params as parameters.
+ # +port+ (143 by default) on the named +host+. If +usessl+ is true,
+ # then an attempt will
+ # be made to use SSL (now TLS) to connect to the server. For this
+ # to work OpenSSL [OSSL] and the Ruby OpenSSL [RSSL]
+ # extensions need to be installed. The +certs+ parameter indicates
+ # the path or file containing the CA cert of the server, and the
+ # +verify+ parameter is for the OpenSSL verification callback.
#
# The most common errors are:
#
@@ -904,36 +878,39 @@ module Net
# SocketError:: hostname not known or other socket error.
# Net::IMAP::ByeResponseError:: we connected to the host, but they
# immediately said goodbye to us.
- def initialize(host, port_or_options = {},
- usessl = false, certs = nil, verify = true)
+ def initialize(host, port = PORT, usessl = false, certs = nil, verify = false)
super()
@host = host
- begin
- options = port_or_options.to_hash
- rescue NoMethodError
- # for backward compatibility
- options = {}
- options[:port] = port_or_options
- if usessl
- options[:ssl] = create_ssl_params(certs, verify)
- end
- end
- @port = options[:port] || (options[:ssl] ? SSL_PORT : PORT)
+ @port = port
@tag_prefix = "RUBY"
@tagno = 0
@parser = ResponseParser.new
- @sock = TCPSocket.open(@host, @port)
- if options[:ssl]
- start_tls_session(options[:ssl])
+ @sock = TCPSocket.open(host, port)
+ if usessl
+ unless defined?(OpenSSL)
+ raise "SSL extension not installed"
+ end
@usessl = true
+
+ # verify the server.
+ context = SSLContext::new()
+ context.ca_file = certs if certs && FileTest::file?(certs)
+ context.ca_path = certs if certs && FileTest::directory?(certs)
+ context.verify_mode = VERIFY_PEER if verify
+ if defined?(VerifyCallbackProc)
+ context.verify_callback = VerifyCallbackProc
+ end
+ @sock = SSLSocket.new(@sock, context)
+ @sock.connect # start ssl session.
+ @sock.post_connection_check(@host) if verify
else
@usessl = false
end
@responses = Hash.new([].freeze)
@tagged_responses = {}
@response_handlers = []
- @tagged_response_arrival = new_cond
- @continuation_request_arrival = new_cond
+ @response_arrival = new_cond
+ @continuation_request = nil
@logout_command_tag = nil
@debug_output_bol = true
@@ -964,7 +941,7 @@ module Net
case resp
when TaggedResponse
@tagged_responses[resp.tag] = resp
- @tagged_response_arrival.broadcast
+ @response_arrival.broadcast
if resp.tag == @logout_command_tag
return
end
@@ -979,7 +956,8 @@ module Net
raise ByeResponseError, resp.raw_data
end
when ContinuationRequest
- @continuation_request_arrival.signal
+ @continuation_request = resp
+ @response_arrival.broadcast
end
@response_handlers.each do |handler|
handler.call(resp)
@@ -991,10 +969,14 @@ module Net
end
end
- def get_tagged_response(tag, cmd)
+ def get_tagged_response(tag)
until @tagged_responses.key?(tag)
- @tagged_response_arrival.wait
+ @response_arrival.wait
end
+ return pick_up_tagged_response(tag)
+ end
+
+ def pick_up_tagged_response(tag)
resp = @tagged_responses.delete(tag)
case resp.name
when /\A(?:NO)\z/ni
@@ -1035,7 +1017,7 @@ module Net
def send_command(cmd, *args, &block)
synchronize do
- tag = generate_tag
+ tag = Thread.current[:net_imap_tag] = generate_tag
put_string(tag + " " + cmd)
args.each do |i|
put_string(" ")
@@ -1049,7 +1031,7 @@ module Net
add_response_handler(block)
end
begin
- return get_tagged_response(tag, cmd)
+ return get_tagged_response(tag)
ensure
if block
remove_response_handler(block)
@@ -1118,7 +1100,15 @@ module Net
def send_literal(str)
put_string("{" + str.length.to_s + "}" + CRLF)
- @continuation_request_arrival.wait
+ while @continuation_request.nil? &&
+ !@tagged_responses.key?(Thread.current[:net_imap_tag])
+ @response_arrival.wait
+ end
+ if @continuation_request.nil?
+ pick_up_tagged_response(Thread.current[:net_imap_tag])
+ raise ResponseError.new("expected continuation request")
+ end
+ @continuation_request = nil
put_string(str)
end
@@ -1234,47 +1224,124 @@ module Net
end
end
- def create_ssl_params(certs = nil, verify = true)
- params = {}
- if certs
- if File.file?(certs)
- params[:ca_file] = certs
- elsif File.directory?(certs)
- params[:ca_path] = certs
+ def self.u16tou8(s)
+ len = s.length
+ if len < 2
+ return ""
+ end
+ buf = ""
+ i = 0
+ while i < len
+ c = s[i] << 8 | s[i + 1]
+ i += 2
+ if c == 0xfeff
+ next
+ elsif c < 0x0080
+ buf.concat(c)
+ elsif c < 0x0800
+ b2 = c & 0x003f
+ b1 = c >> 6
+ buf.concat(b1 | 0xc0)
+ buf.concat(b2 | 0x80)
+ elsif c >= 0xdc00 && c < 0xe000
+ raise DataFormatError, "invalid surrogate detected"
+ elsif c >= 0xd800 && c < 0xdc00
+ if i + 2 > len
+ raise DataFormatError, "invalid surrogate detected"
+ end
+ low = s[i] << 8 | s[i + 1]
+ i += 2
+ if low < 0xdc00 || low > 0xdfff
+ raise DataFormatError, "invalid surrogate detected"
+ end
+ c = (((c & 0x03ff)) << 10 | (low & 0x03ff)) + 0x10000
+ b4 = c & 0x003f
+ b3 = (c >> 6) & 0x003f
+ b2 = (c >> 12) & 0x003f
+ b1 = c >> 18;
+ buf.concat(b1 | 0xf0)
+ buf.concat(b2 | 0x80)
+ buf.concat(b3 | 0x80)
+ buf.concat(b4 | 0x80)
+ else # 0x0800-0xffff
+ b3 = c & 0x003f
+ b2 = (c >> 6) & 0x003f
+ b1 = c >> 12
+ buf.concat(b1 | 0xe0)
+ buf.concat(b2 | 0x80)
+ buf.concat(b3 | 0x80)
+ end
+ end
+ return buf
+ end
+ private_class_method :u16tou8
+
+ def self.u8tou16(s)
+ len = s.length
+ buf = ""
+ i = 0
+ while i < len
+ c = s[i]
+ if (c & 0x80) == 0
+ buf.concat(0x00)
+ buf.concat(c)
+ i += 1
+ elsif (c & 0xe0) == 0xc0 &&
+ len >= 2 &&
+ (s[i + 1] & 0xc0) == 0x80
+ if c == 0xc0 || c == 0xc1
+ raise DataFormatError, format("non-shortest UTF-8 sequence (%02x)", c)
+ end
+ u = ((c & 0x1f) << 6) | (s[i + 1] & 0x3f)
+ buf.concat(u >> 8)
+ buf.concat(u & 0x00ff)
+ i += 2
+ elsif (c & 0xf0) == 0xe0 &&
+ i + 2 < len &&
+ (s[i + 1] & 0xc0) == 0x80 &&
+ (s[i + 2] & 0xc0) == 0x80
+ if c == 0xe0 && s[i + 1] < 0xa0
+ raise DataFormatError, format("non-shortest UTF-8 sequence (%02x)", c)
+ end
+ u = ((c & 0x0f) << 12) | ((s[i + 1] & 0x3f) << 6) | (s[i + 2] & 0x3f)
+ # surrogate chars
+ if u >= 0xd800 && u <= 0xdfff
+ raise DataFormatError, format("none-UTF-16 char detected (%04x)", u)
+ end
+ buf.concat(u >> 8)
+ buf.concat(u & 0x00ff)
+ i += 3
+ elsif (c & 0xf8) == 0xf0 &&
+ i + 3 < len &&
+ (s[i + 1] & 0xc0) == 0x80 &&
+ (s[i + 2] & 0xc0) == 0x80 &&
+ (s[i + 3] & 0xc0) == 0x80
+ if c == 0xf0 && s[i + 1] < 0x90
+ raise DataFormatError, format("non-shortest UTF-8 sequence (%02x)", c)
+ end
+ u = ((c & 0x07) << 18) | ((s[i + 1] & 0x3f) << 12) |
+ ((s[i + 2] & 0x3f) << 6) | (s[i + 3] & 0x3f)
+ if u < 0x10000
+ buf.concat(u >> 8)
+ buf.concat(u & 0x00ff)
+ elsif u < 0x110000
+ high = ((u - 0x10000) >> 10) | 0xd800
+ low = (u & 0x03ff) | 0xdc00
+ buf.concat(high >> 8)
+ buf.concat(high & 0x00ff)
+ buf.concat(low >> 8)
+ buf.concat(low & 0x00ff)
+ else
+ raise DataFormatError, format("none-UTF-16 char detected (%04x)", u)
+ end
+ i += 4
+ else
+ raise DataFormatError, format("illegal UTF-8 sequence (%02x)", c)
end
end
- if verify
- params[:verify_mode] = VERIFY_PEER
- else
- params[:verify_mode] = VERIFY_NONE
- end
- return params
- end
-
- def start_tls_session(params = {})
- unless defined?(OpenSSL)
- raise "SSL extension not installed"
- end
- if @sock.kind_of?(OpenSSL::SSL::SSLSocket)
- raise RuntimeError, "already using SSL"
- end
- begin
- params = params.to_hash
- rescue NoMethodError
- params = {}
- end
- context = SSLContext.new
- context.set_params(params)
- if defined?(VerifyCallbackProc)
- context.verify_callback = VerifyCallbackProc
- end
- @sock = SSLSocket.new(@sock, context)
- @sock.sync_close = true
- @sock.connect
- if context.verify_mode != VERIFY_NONE
- @sock.post_connection_check(@host)
- end
+ return buf
end
+ private_class_method :u8tou16
class RawData # :nodoc:
def send_data(imap)
@@ -3040,7 +3107,7 @@ module Net
parse_error("unknown token - %s", $&.dump)
end
else
- parse_error("invalid @lex_state - %s", @lex_state.inspect)
+ parse_error("illegal @lex_state - %s", @lex_state.inspect)
end
end
@@ -3084,22 +3151,6 @@ module Net
end
add_authenticator "LOGIN", LoginAuthenticator
- # Authenticator for the "PLAIN" authentication type. See
- # #authenticate().
- class PlainAuthenticator
- def process(data)
- return "\0#{@user}\0#{@password}"
- end
-
- private
-
- def initialize(user, password)
- @user = user
- @password = password
- end
- end
- add_authenticator "PLAIN", PlainAuthenticator
-
# Authenticator for the "CRAM-MD5" authentication type. See
# #authenticate().
class CramMD5Authenticator
@@ -3134,106 +3185,6 @@ module Net
end
add_authenticator "CRAM-MD5", CramMD5Authenticator
- # Authenticator for the "DIGEST-MD5" authentication type. See
- # #authenticate().
- class DigestMD5Authenticator
- def process(challenge)
- case @stage
- when STAGE_ONE
- @stage = STAGE_TWO
- sparams = {}
- c = StringScanner.new(challenge)
- while c.scan(/(?:\s*,)?\s*(\w+)=("(?:[^\\"]+|\\.)*"|[^,]+)\s*/)
- k, v = c[1], c[2]
- if v =~ /^"(.*)"$/
- v = $1
- if v =~ /,/
- v = v.split(',')
- end
- end
- sparams[k] = v
- end
-
- raise DataFormatError, "Bad Challenge: '#{challenge}'" unless c.rest.size == 0
- raise Error, "Server does not support auth (qop = #{sparams['qop'].join(',')})" unless sparams['qop'].include?("auth")
-
- response = {
- :nonce => sparams['nonce'],
- :username => @user,
- :realm => sparams['realm'],
- :cnonce => Digest::MD5.hexdigest("%.15f:%.15f:%d" % [Time.now.to_f, rand, Process.pid.to_s]),
- :'digest-uri' => 'imap/' + sparams['realm'],
- :qop => 'auth',
- :maxbuf => 65535,
- :nc => "%08d" % nc(sparams['nonce']),
- :charset => sparams['charset'],
- }
-
- response[:authzid] = @authname unless @authname.nil?
-
- # now, the real thing
- a0 = Digest::MD5.digest( [ response.values_at(:username, :realm), @password ].join(':') )
-
- a1 = [ a0, response.values_at(:nonce,:cnonce) ].join(':')
- a1 << ':' + response[:authzid] unless response[:authzid].nil?
-
- a2 = "AUTHENTICATE:" + response[:'digest-uri']
- a2 << ":00000000000000000000000000000000" if response[:qop] and response[:qop] =~ /^auth-(?:conf|int)$/
-
- response[:response] = Digest::MD5.hexdigest(
- [
- Digest::MD5.hexdigest(a1),
- response.values_at(:nonce, :nc, :cnonce, :qop),
- Digest::MD5.hexdigest(a2)
- ].join(':')
- )
-
- return response.keys.map { |k| qdval(k.to_s, response[k]) }.join(',')
- when STAGE_TWO
- @stage = nil
- # if at the second stage, return an empty string
- if challenge =~ /rspauth=/
- return ''
- else
- raise ResponseParseError, challenge
- end
- else
- raise ResponseParseError, challenge
- end
- end
-
- def initialize(user, password, authname = nil)
- @user, @password, @authname = user, password, authname
- @nc, @stage = {}, STAGE_ONE
- end
-
- private
-
- STAGE_ONE = :stage_one
- STAGE_TWO = :stage_two
-
- def nc(nonce)
- if @nc.has_key? nonce
- @nc[nonce] = @nc[nonce] + 1
- else
- @nc[nonce] = 1
- end
- return @nc[nonce]
- end
-
- # some reponses needs quoting
- def qdval(k, v)
- return if k.nil? or v.nil?
- if %w"username authzid realm nonce cnonce digest-uri qop".include? k
- v.gsub!(/([\\"])/, "\\\1")
- return '%s="%s"' % [k, v]
- else
- return '%s=%s' % [k, v]
- end
- end
- end
- add_authenticator "DIGEST-MD5", DigestMD5Authenticator
-
# Superclass of IMAP errors.
class Error < StandardError
end
@@ -3347,8 +3298,9 @@ EOF
usage
exit(1)
end
+ $port ||= $ssl ? 993 : 143
- imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
+ imap = Net::IMAP.new($host, $port, $ssl)
begin
password = get_password
imap.authenticate($auth, $user, password)
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index cbe5630271..82cc9a747b 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -13,7 +13,7 @@
# Ruby Distribute License.
#
# NOTE: You can find Japanese version of this document at:
-# http://www.ruby-lang.org/ja/man/index.cgi?cmd=view;name=net%2Fpop.rb
+# http://www.ruby-lang.org/ja/man/html/net_pop.html
#
# $Id$
#
@@ -577,6 +577,8 @@ module Net
def do_finish
@mails = nil
+ @n_mails = nil
+ @n_bytes = nil
@command.quit if @command
ensure
@started = false
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 0d489cdbc8..dc23c14dfa 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -2,8 +2,8 @@
# = net/protocol.rb
#
#--
-# Copyright (c) 1999-2004 Yukihiro Matsumoto
-# Copyright (c) 1999-2004 Minero Aoki
+# Copyright (c) 1999-2005 Yukihiro Matsumoto
+# Copyright (c) 1999-2005 Minero Aoki
#
# written and maintained by Minero Aoki <aamine@loveruby.net>
#
@@ -202,6 +202,16 @@ module Net # :nodoc:
class InternetMessageIO < BufferedIO #:nodoc: internal use only
+ def InternetMessageIO.old_open(addr, port,
+ open_timeout = nil, read_timeout = nil, debug_output = nil)
+ debug_output << "opening connection to #{addr}...\n" if debug_output
+ s = timeout(open_timeout) { TCPsocket.new(addr, port) }
+ io = new(s)
+ io.read_timeout = read_timeout
+ io.debug_output = debug_output
+ io
+ end
+
def initialize(io)
super
@wbuf = nil
@@ -307,8 +317,8 @@ module Net # :nodoc:
yield
end
else # generic reader
- src.each do |str|
- buf << str
+ src.each do |s|
+ buf << s
yield if buf.size > 1024
end
yield unless buf.empty?
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 8f81ae8450..7c9d9388ef 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -12,7 +12,7 @@
# modify this program under the same terms as Ruby itself.
#
# NOTE: You can find Japanese version of this document at:
-# http://www.ruby-lang.org/ja/man/index.cgi?cmd=view;name=net%2Fsmtp.rb
+# http://www.ruby-lang.org/ja/man/html/net_smtp.html
#
# $Id$
#
@@ -837,7 +837,7 @@ module Net
def rcptto(to_addr)
if $SAFE > 0
- raise SecurityError, 'tainted to_addr' if to.tainted?
+ raise SecurityError, 'tainted to_addr' if to_addr.tainted?
end
getok("RCPT TO:<#{to_addr}>")
end
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index dfbe932dcd..73471c3327 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -438,9 +438,6 @@ module Net
# combine EOL into "\n"
string = string.gsub(/#{EOL}/no, "\n") unless @options["Binmode"]
- # remove NULL
- string = string.gsub(/#{NULL}/no, '') unless @options["Binmode"]
-
string.gsub(/#{IAC}(
[#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
[#{DO}#{DONT}#{WILL}#{WONT}]
@@ -523,10 +520,15 @@ module Net
# value specified when this instance was created will be
# used, or, failing that, the default value of 0 seconds,
# which means not to wait for more input.
+ # FailEOF:: if true, when the remote end closes the connection then an
+ # EOFError will be raised. Otherwise, defaults to the old
+ # behaviour that the function will return whatever data
+ # has been received already, or nil if nothing was received.
#
def waitfor(options) # :yield: recvdata
time_out = @options["Timeout"]
waittime = @options["Waittime"]
+ fail_eof = @options["FailEOF"]
if options.kind_of?(Hash)
prompt = if options.has_key?("Match")
@@ -538,6 +540,7 @@ module Net
end
time_out = options["Timeout"] if options.has_key?("Timeout")
waittime = options["Waittime"] if options.has_key?("Waittime")
+ fail_eof = options["FailEOF"] if options.has_key?("FailEOF")
else
prompt = options
end
@@ -562,7 +565,8 @@ module Net
Integer(c.rindex(/#{IAC}#{SB}/no))
buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
- elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
+ elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no) ||
+ c.rindex(/\r\z/no)
buf = preprocess(c[0 ... pt])
rest = c[pt .. -1]
else
@@ -574,14 +578,21 @@ module Net
#
# We cannot use preprocess() on this data, because that
# method makes some Telnetmode-specific assumptions.
- buf = c
- buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
+ buf = rest + c
rest = ''
+ unless @options["Binmode"]
+ if pt = buf.rindex(/\r\z/no)
+ buf = buf[0 ... pt]
+ rest = buf[pt .. -1]
+ end
+ buf.gsub!(/#{EOL}/no, "\n")
+ end
end
@log.print(buf) if @options.has_key?("Output_log")
line += buf
yield buf if block_given?
rescue EOFError # End of file reached
+ raise if fail_eof
if line == ''
line = nil
yield nil if block_given?
diff --git a/lib/observer.rb b/lib/observer.rb
index 472a154395..64c7d81351 100644
--- a/lib/observer.rb
+++ b/lib/observer.rb
@@ -118,15 +118,14 @@ module Observable
#
# Add +observer+ as an observer on this object. +observer+ will now receive
- # notifications. The second optional argument specifies a method to notify
- # updates, of which default value is +update+.
+ # notifications.
#
- def add_observer(observer, func=:update)
- @observer_peers = {} unless defined? @observer_peers
- unless observer.respond_to? func
- raise NoMethodError, "observer does not respond to `#{func.to_s}'"
+ def add_observer(observer)
+ @observer_peers = [] unless defined? @observer_peers
+ unless observer.respond_to? :update
+ raise NoMethodError, "observer needs to respond to `update'"
end
- @observer_peers[observer] = func
+ @observer_peers.push observer
end
#
@@ -182,9 +181,9 @@ module Observable
def notify_observers(*arg)
if defined? @observer_state and @observer_state
if defined? @observer_peers
- @observer_peers.each { |k, v|
- k.send v, *arg
- }
+ for i in @observer_peers.dup
+ i.update(*arg)
+ end
end
@observer_state = false
end
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index a981f58eda..54b42f336f 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -5,9 +5,6 @@ require 'time'
module Kernel
private
alias open_uri_original_open open # :nodoc:
- class << self
- alias open_uri_original_open open # :nodoc:
- end
# makes possible to open various resources including URIs.
# If the first argument respond to `open' method,
@@ -94,15 +91,9 @@ end
module OpenURI
Options = {
:proxy => true,
- :proxy_http_basic_authentication => true,
:progress_proc => true,
:content_length_proc => true,
:http_basic_authentication => true,
- :read_timeout => true,
- :ssl_ca_cert => nil,
- :ssl_verify_mode => nil,
- :ftp_active_mode => false,
- :redirect => true,
}
def OpenURI.check_options(options) # :nodoc:
@@ -151,40 +142,16 @@ module OpenURI
end
def OpenURI.open_loop(uri, options) # :nodoc:
- proxy_opts = []
- proxy_opts << :proxy_http_basic_authentication if options.include? :proxy_http_basic_authentication
- proxy_opts << :proxy if options.include? :proxy
- proxy_opts.compact!
- if 1 < proxy_opts.length
- raise ArgumentError, "multiple proxy options specified"
- end
- case proxy_opts.first
- when :proxy_http_basic_authentication
- opt_proxy, proxy_user, proxy_pass = options.fetch(:proxy_http_basic_authentication)
- proxy_user = proxy_user.to_str
- proxy_pass = proxy_pass.to_str
- if opt_proxy == true
- raise ArgumentError.new("Invalid authenticated proxy option: #{options[:proxy_http_basic_authentication].inspect}")
- end
- when :proxy
- opt_proxy = options.fetch(:proxy)
- proxy_user = nil
- proxy_pass = nil
- when nil
- opt_proxy = true
- proxy_user = nil
- proxy_pass = nil
- end
- case opt_proxy
+ case opt_proxy = options.fetch(:proxy, true)
when true
- find_proxy = lambda {|u| pxy = u.find_proxy; pxy ? [pxy, nil, nil] : nil}
+ find_proxy = lambda {|u| u.find_proxy}
when nil, false
find_proxy = lambda {|u| nil}
when String
opt_proxy = URI.parse(opt_proxy)
- find_proxy = lambda {|u| [opt_proxy, proxy_user, proxy_pass]}
+ find_proxy = lambda {|u| opt_proxy}
when URI::Generic
- find_proxy = lambda {|u| [opt_proxy, proxy_user, proxy_pass]}
+ find_proxy = lambda {|u| opt_proxy}
else
raise ArgumentError.new("Invalid proxy option: #{opt_proxy}")
end
@@ -203,9 +170,6 @@ module OpenURI
# URI. It is converted to absolute URI using uri as a base URI.
redirect = uri + redirect
end
- if !options.fetch(:redirect, true)
- raise HTTPRedirect.new(buf.io.status.join(' '), buf.io, redirect)
- end
unless OpenURI.redirectable?(uri, redirect)
raise "redirection forbidden: #{uri} -> #{redirect}"
end
@@ -229,9 +193,6 @@ module OpenURI
def OpenURI.redirectable?(uri1, uri2) # :nodoc:
# This test is intended to forbid a redirection from http://... to
# file:///etc/passwd.
- # https to http redirect is also forbidden intentionally.
- # It avoids sending secure cookie or referer by non-secure HTTP protocol.
- # (RFC 2109 4.3.1, RFC 2965 3.3, RFC 2616 15.1.3)
# However this is ad hoc. It should be extensible/configurable.
uri1.scheme.downcase == uri2.scheme.downcase ||
(/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)
@@ -239,8 +200,7 @@ module OpenURI
def OpenURI.open_http(buf, target, proxy, options) # :nodoc:
if proxy
- proxy_uri, proxy_user, proxy_pass = proxy
- raise "Non-HTTP proxy URI: #{proxy_uri}" if proxy_uri.class != URI::HTTP
+ raise "Non-HTTP proxy URI: #{proxy}" if proxy.class != URI::HTTP
end
if target.userinfo && "1.9.0" <= RUBY_VERSION
@@ -248,53 +208,35 @@ module OpenURI
raise ArgumentError, "userinfo not supported. [RFC3986]"
end
- header = {}
- options.each {|k, v| header[k] = v if String === k }
-
require 'net/http'
klass = Net::HTTP
if URI::HTTP === target
# HTTP or HTTPS
if proxy
- if proxy_user && proxy_pass
- klass = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_user, proxy_pass)
- else
- klass = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port)
- end
+ klass = Net::HTTP::Proxy(proxy.host, proxy.port)
end
target_host = target.host
target_port = target.port
request_uri = target.request_uri
else
# FTP over HTTP proxy
- target_host = proxy_uri.host
- target_port = proxy_uri.port
+ target_host = proxy.host
+ target_port = proxy.port
request_uri = target.to_s
- if proxy_user && proxy_pass
- header["Proxy-Authorization"] = 'Basic ' + ["#{proxy_user}:#{proxy_pass}"].pack('m').delete("\r\n")
- end
end
http = klass.new(target_host, target_port)
if target.class == URI::HTTPS
require 'net/https'
http.use_ssl = true
- http.verify_mode = options[:ssl_verify_mode] || OpenSSL::SSL::VERIFY_PEER
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
store = OpenSSL::X509::Store.new
- if options[:ssl_ca_cert]
- if File.directory? options[:ssl_ca_cert]
- store.add_path options[:ssl_ca_cert]
- else
- store.add_file options[:ssl_ca_cert]
- end
- else
- store.set_default_paths
- end
+ store.set_default_paths
http.cert_store = store
end
- if options.include? :read_timeout
- http.read_timeout = options[:read_timeout]
- end
+
+ header = {}
+ options.each {|k, v| header[k] = v if String === k }
resp = nil
http.start {
@@ -344,14 +286,6 @@ module OpenURI
attr_reader :io
end
- class HTTPRedirect < HTTPError
- def initialize(message, io, uri)
- super(message, io)
- @uri = uri
- end
- attr_reader :uri
- end
-
class Buffer # :nodoc:
def initialize
@io = StringIO.new
@@ -367,14 +301,14 @@ module OpenURI
require 'tempfile'
io = Tempfile.new('open-uri')
io.binmode
- Meta.init io, @io if Meta === @io
+ Meta.init io, @io if @io.respond_to? :meta
io << @io.string
@io = io
end
end
def io
- Meta.init @io unless Meta === @io
+ Meta.init @io unless @io.respond_to? :meta
@io
end
end
@@ -526,21 +460,6 @@ module OpenURI
# When false or nil is given, the environment variables are ignored and
# connection will be made to a server directly.
#
- # [:proxy_http_basic_authentication]
- # Synopsis:
- # :proxy_http_basic_authentication => ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"]
- # :proxy_http_basic_authentication => [URI.parse("http://proxy.foo.com:8000/"), "proxy-user", "proxy-password"]
- #
- # If :proxy option is specified, the value should be an Array with 3 elements.
- # It should contain a proxy URI, a proxy user name and a proxy password.
- # The proxy URI should be a String, an URI or nil.
- # The proxy user name and password should be a String.
- #
- # If nil is given for the proxy URI, this option is just ignored.
- #
- # If :proxy and :proxy_http_basic_authentication is specified,
- # ArgumentError is raised.
- #
# [:http_basic_authentication]
# Synopsis:
# :http_basic_authentication=>[user, password]
@@ -592,47 +511,9 @@ module OpenURI
# pbar.set s if pbar
# }) {|f| ... }
#
- # [:read_timeout]
- # Synopsis:
- # :read_timeout=>nil (no timeout)
- # :read_timeout=>10 (10 second)
- #
- # :read_timeout option specifies a timeout of read for http connections.
- #
- # [:ssl_ca_cert]
- # Synopsis:
- # :ssl_ca_cert=>filename
- #
- # :ssl_ca_cert is used to specify CA certificate for SSL.
- # If it is given, default certificates are not used.
- #
- # [:ssl_verify_mode]
- # Synopsis:
- # :ssl_verify_mode=>mode
- #
- # :ssl_verify_mode is used to specify openssl verify mode.
- #
# OpenURI::OpenRead#open returns an IO like object if block is not given.
# Otherwise it yields the IO object and return the value of the block.
# The IO object is extended with OpenURI::Meta.
- #
- # [:ftp_active_mode]
- # Synopsis:
- # :ftp_active_mode=>bool
- #
- # :ftp_active_mode=>true is used to make ftp active mode.
- # Note that the active mode is default in Ruby 1.8 or prior.
- # Ruby 1.9 uses passive mode by default.
- #
- # [:redirect]
- # Synopsis:
- # :redirect=>bool
- #
- # :redirect=>false is used to disable HTTP redirects at all.
- # OpenURI::HTTPRedirect exception raised on redirection.
- # It is true by default.
- # The true means redirectoins between http and ftp is permitted.
- #
def open(*rest, &block)
OpenURI.open_uri(self, *rest, &block)
end
@@ -769,7 +650,6 @@ module URI
# The access sequence is defined by RFC 1738
ftp = Net::FTP.open(self.host)
- ftp.passive = true if !options[:ftp_active_mode]
# todo: extract user/passwd from .netrc.
user = 'anonymous'
passwd = nil
diff --git a/lib/optparse.rb b/lib/optparse.rb
index d33ad536e2..389a815ffc 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -221,7 +221,7 @@ class OptionParser
def complete(key, icase = false, pat = nil)
pat ||= Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'),
icase)
- canon, sw, cn = nil
+ canon, sw, k, v, cn = nil
candidates = []
each do |k, *v|
(if Regexp === k
@@ -321,10 +321,10 @@ class OptionParser
# argument pattern. Yields when the pattern doesn't match substring.
#
def parse_arg(arg)
- pattern or return nil, [arg]
+ pattern or return nil, arg
unless m = pattern.match(arg)
yield(InvalidArgument, arg)
- return arg, []
+ return arg, nil
end
if String === m
m = [s = m]
@@ -345,11 +345,11 @@ class OptionParser
# conversion. Yields at semi-error condition instead of raising an
# exception.
#
- def conv_arg(arg, val = [])
+ def conv_arg(arg, val = nil)
if conv
val = conv.call(*val)
else
- val = proc {|v| v}.call(*val)
+ val = proc {|val| val}.call(*val)
end
return arg, block, val
end
@@ -368,7 +368,7 @@ class OptionParser
# +indent+:: Prefix string indents all summarized lines.
#
def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
- sopts, lopts = [], [], nil
+ sopts, lopts, s = [], [], nil
@short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short
@long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long
return if sopts.empty? and lopts.empty? # completely hidden
@@ -384,9 +384,9 @@ class OptionParser
end
left[0] << arg if arg
- mlen = left.collect {|ss| ss.length}.max.to_i
+ mlen = left.collect {|s| s.length}.max.to_i
while mlen > width and l = left.shift
- mlen = left.collect {|ss| ss.length}.max.to_i if l.length == mlen
+ mlen = left.collect {|s| s.length}.max.to_i if l.length == mlen
yield(indent + l)
end
@@ -406,7 +406,7 @@ class OptionParser
to
end
- def match_nonswitch?(str) # :nodoc:
+ def match_nonswitch?(str) # :nodoc:
@pattern =~ str unless @short or @long
end
@@ -451,7 +451,7 @@ class OptionParser
raise MissingArgument if argv.empty?
arg = argv.shift
end
- conv_arg(*parse_arg(arg, &method(:raise)))
+ conv_arg(*parse_arg(arg) {|*exc| raise(*exc)})
end
end
@@ -555,6 +555,7 @@ class OptionParser
# +nlopts+:: Negated long style options list.
#
def update(sw, sopts, lopts, nsw = nil, nlopts = nil)
+ o = nil
sopts.each {|o| @short[o] = sw} if sopts
lopts.each {|o| @long[o] = sw} if lopts
nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
@@ -662,10 +663,9 @@ class OptionParser
# Completion for hash key.
#
def match(key)
- *values = fetch(key) {
+ return key, *fetch(key) {
raise AmbiguousArgument, catch(:ambiguous) {return complete(key)}
}
- return key, *values
end
end
@@ -826,7 +826,7 @@ class OptionParser
#
# Directs to reject specified class argument.
#
- # +t+:: Argument class speficier, any object including Class.
+ # +t+:: Argument class specifier, any object including Class.
#
# reject(t)
#
@@ -1037,13 +1037,13 @@ class OptionParser
# "-x[OPTIONAL]"
# "-x"
# There is also a special form which matches character range (not full
- # set of regural expression):
+ # set of regular expression):
# "-[a-z]MANDATORY"
# "-[a-z][OPTIONAL]"
# "-[a-z]"
#
# [Argument style and description:]
- # Instead of specifying mandatory or optional orguments directly in the
+ # Instead of specifying mandatory or optional arguments directly in the
# switch parameter, this separate parameter can be used.
# "=MANDATORY"
# "=[OPTIONAL]"
@@ -1062,6 +1062,7 @@ class OptionParser
default_style = Switch::NoArgument
default_pattern = nil
klass = nil
+ o = nil
n, q, a = nil
opts.each do |o|
@@ -1095,7 +1096,7 @@ class OptionParser
else
raise ArgumentError, "argument pattern given twice"
end
- o.each {|pat, *v| pattern[pat] = v.fetch(0) {pat}}
+ o.each {|(o, *v)| pattern[o] = v.fetch(0) {o}}
when Module
raise ArgumentError, "unsupported argument type: #{o}"
when *ArgumentStyle.keys
@@ -1243,8 +1244,8 @@ class OptionParser
end
def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
- opt, arg, val, rest = nil
- nonopt ||= proc {|a| throw :terminate, a}
+ opt, arg, sw, val, rest = nil
+ nonopt ||= proc {|arg| throw :terminate, arg}
argv.unshift(arg) if arg = catch(:terminate) {
while arg = argv.shift
case arg
@@ -1298,8 +1299,7 @@ class OptionParser
# non-option argument
else
catch(:prune) do
- visit(:each_option) do |sw0|
- sw = sw0
+ visit(:each_option) do |sw|
sw.block.call(arg) if Switch === sw and sw.match_nonswitch?(arg)
end
nonopt.call(arg)
@@ -1330,7 +1330,8 @@ class OptionParser
#
def permute!(argv = default_argv)
nonopts = []
- order!(argv, &nonopts.method(:<<))
+ arg = nil
+ order!(argv) {|arg| nonopts << arg}
argv[0, 0] = nonopts
argv
end
@@ -1407,6 +1408,7 @@ class OptionParser
# +block+.
#
def visit(id, *args, &block)
+ el = nil
@stack.reverse_each do |el|
el.send(id, *args, &block)
end
@@ -1439,7 +1441,7 @@ class OptionParser
search(typ, opt) {|sw| return [sw, opt]} # exact match or...
end
raise AmbiguousOption, catch(:ambiguous) {
- visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}
+ visit(:complete, typ, opt, icase, *pat) {|opt, *sw| return sw}
raise InvalidOption, opt
}
end
@@ -1474,6 +1476,7 @@ class OptionParser
#
def environment(env = File.basename($0, '.*'))
env = ENV[env] || ENV[env.upcase] or return
+ require 'shellwords'
parse(*Shellwords.shellwords(env))
end
@@ -1558,7 +1561,7 @@ class OptionParser
#
accept(Array) do |s,|
if s
- s = s.split(',').collect {|ss| ss unless ss.empty?}
+ s = s.split(',').collect {|s| s unless s.empty?}
end
s
end
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index f3ed01524b..6af5bbdac0 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -70,10 +70,9 @@ class OpenStruct
def new_ostruct_member(name)
name = name.to_sym
unless self.respond_to?(name)
- class << self; self; end.class_eval do
- define_method(name) { @table[name] }
- define_method(:"#{name}=") { |x| @table[name] = x }
- end
+ meta = class << self; self; end
+ meta.send(:define_method, name) { @table[name] }
+ meta.send(:define_method, :"#{name}=") { |x| @table[name] = x }
end
end
diff --git a/lib/parsearg.rb b/lib/parsearg.rb
new file mode 100644
index 0000000000..cab2dba789
--- /dev/null
+++ b/lib/parsearg.rb
@@ -0,0 +1,87 @@
+#
+# parsearg.rb - parse arguments
+# $Release Version: $
+# $Revision$
+# $Date$
+# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
+#
+# --
+#
+#
+#
+
+warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: parsearg is deprecated after Ruby 1.8.1; use optparse instead"
+
+$RCS_ID=%q$Header$
+
+require "getopts"
+
+def printUsageAndExit()
+ if $USAGE
+ eval($USAGE)
+ end
+ exit()
+end
+
+def setParenthesis(ex, opt, c)
+ if opt != ""
+ ex = sprintf("%s$OPT_%s%s", ex, opt, c)
+ else
+ ex = sprintf("%s%s", ex, c)
+ end
+ return ex
+end
+
+def setOrAnd(ex, opt, c)
+ if opt != ""
+ ex = sprintf("%s$OPT_%s %s%s ", ex, opt, c, c)
+ else
+ ex = sprintf("%s %s%s ", ex, c, c)
+ end
+ return ex
+end
+
+def setExpression(ex, opt, op)
+ if !op
+ ex = sprintf("%s$OPT_%s", ex, opt)
+ return ex
+ end
+ case op.chr
+ when "(", ")"
+ ex = setParenthesis(ex, opt, op.chr)
+ when "|", "&"
+ ex = setOrAnd(ex, opt, op.chr)
+ else
+ return nil
+ end
+ return ex
+end
+
+# parseArgs is obsolete. Use OptionParser instead.
+
+def parseArgs(argc, nopt, single_opts, *opts)
+ if (noOptions = getopts(single_opts, *opts)) == nil
+ printUsageAndExit()
+ end
+ if nopt
+ ex = nil
+ pos = 0
+ for o in nopt.split(/[()|&]/)
+ pos += o.length
+ ex = setExpression(ex, o, nopt[pos])
+ pos += 1
+ end
+ begin
+ if !eval(ex)
+ printUsageAndExit()
+ end
+ rescue
+ print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
+ exit!(-1)
+ end
+ end
+ if ARGV.length < argc
+ printUsageAndExit()
+ end
+ return noOptions
+end
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
new file mode 100644
index 0000000000..b52a79ba47
--- /dev/null
+++ b/lib/parsedate.rb
@@ -0,0 +1,53 @@
+#
+# = parsedate.rb: Parses dates
+#
+# Author:: Tadayoshi Funaba
+# Documentation:: Konrad Meyer
+#
+# ParseDate munches on a date and turns it into an array of values.
+#
+
+#
+# ParseDate converts a date into an array of values.
+# For example:
+#
+# require 'parsedate'
+#
+# ParseDate.parsedate "Tuesday, July 6th, 2007, 18:35:20 UTC"
+# # => [2007, 7, 6, 18, 35, 20, "UTC", 2]
+#
+# The order is of the form [year, month, day of month, hour, minute, second,
+# timezone, day of the week].
+
+require 'date/format'
+
+module ParseDate
+ #
+ # Parse a string representation of a date into values.
+ # For example:
+ #
+ # require 'parsedate'
+ #
+ # ParseDate.parsedate "Tuesday, July 5th, 2007, 18:35:20 UTC"
+ # # => [2007, 7, 5, 18, 35, 20, "UTC", 2]
+ #
+ # The order is of the form [year, month, day of month, hour, minute,
+ # second, timezone, day of week].
+ #
+ # ParseDate.parsedate can also take a second argument, +comp+, which
+ # is a boolean telling the method to compensate for dates with years
+ # expressed as two digits. Example:
+ #
+ # require 'parsedate'
+ #
+ # ParseDate.parsedate "Mon Dec 25 00 06:53:24 UTC", true
+ # # => [2000, 12, 25, 6, 53, 24, "UTC", 1]
+ #
+ def parsedate(str, comp=false)
+ Date._parse(str, comp).
+ values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
+ end
+
+ module_function :parsedate
+
+end
diff --git a/lib/ping.rb b/lib/ping.rb
new file mode 100644
index 0000000000..c2966b619c
--- /dev/null
+++ b/lib/ping.rb
@@ -0,0 +1,64 @@
+#
+# = ping.rb: Check a host for upness
+#
+# Author:: Yukihiro Matsumoto
+# Documentation:: Konrad Meyer
+#
+# Performs the function of the basic network testing tool, ping.
+# See: Ping.
+#
+
+require 'timeout'
+require "socket"
+
+#
+# Ping contains routines to test for the reachability of remote hosts.
+# Currently the only routine implemented is pingecho().
+#
+# Ping.pingecho uses a TCP echo (not an ICMP echo) to determine if the
+# remote host is reachable. This is usually adequate to tell that a remote
+# host is available to telnet, ftp, or ssh to.
+#
+# Warning: Ping.pingecho may block for a long time if DNS resolution is
+# slow. Requiring 'resolv-replace' allows non-blocking name resolution.
+#
+# Usage:
+#
+# require 'ping'
+#
+# puts "'jimmy' is alive and kicking" if Ping.pingecho('jimmy', 10)
+#
+module Ping
+
+ #
+ # Return true if we can open a connection to the hostname or IP address
+ # +host+ on port +service+ (which defaults to the "echo" port) waiting up
+ # to +timeout+ seconds.
+ #
+ # Example:
+ #
+ # require 'ping'
+ #
+ # Ping.pingecho "google.com", 10, 80
+ #
+ def pingecho(host, timeout=5, service="echo")
+ begin
+ timeout(timeout) do
+ s = TCPSocket.new(host, service)
+ s.close
+ end
+ rescue Errno::ECONNREFUSED
+ return true
+ rescue Timeout::Error, StandardError
+ return false
+ end
+ return true
+ end
+ module_function :pingecho
+end
+
+if $0 == __FILE__
+ host = ARGV[0]
+ host ||= "localhost"
+ printf("%s alive? - %s\n", host, Ping::pingecho(host, 5))
+end
diff --git a/lib/pp.rb b/lib/pp.rb
index ec896b3ce5..14fe62ee95 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -105,55 +105,41 @@ class PP < PrettyPrint
end
module PPMethods
- def guard_inspect_key
- if Thread.current[:__recursive_key__] == nil
- Thread.current[:__recursive_key__] = {}
- end
+ InspectKey = :__inspect_key__
- if Thread.current[:__recursive_key__][:inspect] == nil
- Thread.current[:__recursive_key__][:inspect] = {}
+ def guard_inspect_key
+ if Thread.current[InspectKey] == nil
+ Thread.current[InspectKey] = []
end
- save = Thread.current[:__recursive_key__][:inspect]
+ save = Thread.current[InspectKey]
begin
- Thread.current[:__recursive_key__][:inspect] = {}
+ Thread.current[InspectKey] = []
yield
ensure
- Thread.current[:__recursive_key__][:inspect] = save
+ Thread.current[InspectKey] = save
end
end
- def check_inspect_key(id)
- Thread.current[:__recursive_key__] &&
- Thread.current[:__recursive_key__][:inspect] &&
- Thread.current[:__recursive_key__][:inspect].include?(id)
- end
- def push_inspect_key(id)
- Thread.current[:__recursive_key__][:inspect][id] = true
- end
- def pop_inspect_key(id)
- Thread.current[:__recursive_key__][:inspect].delete id
- end
-
# Adds +obj+ to the pretty printing buffer
# using Object#pretty_print or Object#pretty_print_cycle.
#
# Object#pretty_print_cycle is used when +obj+ is already
# printed, a.k.a the object reference chain has a cycle.
def pp(obj)
- id = obj.object_id
-
- if check_inspect_key(id)
+ id = obj.__id__
+
+ if Thread.current[InspectKey].include? id
group {obj.pretty_print_cycle self}
return
end
begin
- push_inspect_key(id)
+ Thread.current[InspectKey] << id
group {obj.pretty_print self}
ensure
- pop_inspect_key(id) unless PP.sharing_detection
+ Thread.current[InspectKey].pop unless PP.sharing_detection
end
end
@@ -164,23 +150,9 @@ class PP < PrettyPrint
group(1, '#<' + obj.class.name, '>', &block)
end
- if 0x100000000.class == Bignum
- # 32bit
- PointerMask = 0xffffffff
- else
- # 64bit
- PointerMask = 0xffffffffffffffff
- end
-
- case Object.new.inspect
- when /\A\#<Object:0x([0-9a-f]+)>\z/
- PointerFormat = "%0#{$1.length}x"
- else
- PointerFormat = "%x"
- end
-
def object_address_group(obj, &block)
- id = PointerFormat % (obj.object_id * 2 & PointerMask)
+ id = "%x" % (obj.__id__ * 2)
+ id.sub!(/\Af(?=[[:xdigit:]]{2}+\z)/, '') if id.sub!(/\A\.\./, '')
group(1, "\#<#{obj.class}:0x#{id}", '>', &block)
end
@@ -210,7 +182,7 @@ class PP < PrettyPrint
#
# q.seplist([1,2,3]) {|v| xxx v }
#
- # q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v }
+ # q.seplist([1,2,3], lambda { comma_breakable }, :each) {|v| xxx v }
#
# xxx 1
# q.comma_breakable
@@ -351,11 +323,7 @@ end
class << ENV
def pretty_print(q)
- h = {}
- ENV.keys.sort.each {|k|
- h[k] = ENV[k]
- }
- q.pp_hash h
+ q.pp_hash self
end
end
@@ -473,24 +441,10 @@ end
class MatchData
def pretty_print(q)
- nc = []
- self.regexp.named_captures.each {|name, indexes|
- indexes.each {|i| nc[i] = name }
- }
q.object_group(self) {
q.breakable
- q.seplist(0...self.size, lambda { q.breakable }) {|i|
- if i == 0
- q.pp self[i]
- else
- if nc[i]
- q.text nc[i]
- else
- q.pp i
- end
- q.text ':'
- q.pp self[i]
- end
+ q.seplist(1..self.size, lambda { q.breakable }) {|i|
+ q.pp self[i-1]
}
}
end
diff --git a/lib/profile.rb b/lib/profile.rb
index 19275a3fd2..104cb205b9 100644
--- a/lib/profile.rb
+++ b/lib/profile.rb
@@ -1,9 +1,5 @@
require 'profiler'
-VM::InstructionSequence.compile_option = {
- :trace_instruction => true,
- :specialized_instruction => false
-}
END {
Profiler__::print_profile(STDERR)
}
diff --git a/lib/profiler.rb b/lib/profiler.rb
index 1067106be4..9762fa1181 100644
--- a/lib/profiler.rb
+++ b/lib/profiler.rb
@@ -34,7 +34,7 @@ module_function
total = Process.times[0] - @@start
if total == 0 then total = 0.01 end
data = @@map.values
- data = data.sort_by{|x| x[2]}
+ data.sort!{|a,b| b[2] <=> a[2]}
sum = 0
f.printf " %% cumulative self self total\n"
f.printf " time seconds seconds calls ms/call ms/call name\n"
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 6df64474ab..ab495d9ed7 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -11,14 +11,14 @@ require "fileutils"
require "digest/md5"
#
-# PStore implements a file based persistance mechanism based on a Hash. User
+# PStore implements a file based persistence mechanism based on a Hash. User
# code can store hierarchies of Ruby objects (values) into the data store file
# by name (keys). An object hierarchy may be just a single object. User code
# may later read values back from the data store or even update data, as needed.
#
# The transactional behavior ensures that any changes succeed or fail together.
# This can be used to ensure that the data store is not left in a transitory
-# state, where some values were upated but others were not.
+# state, where some values were updated but others were not.
#
# Behind the scenes, Ruby objects are stored to the data store file with
# Marshal. That carries the usual limitations. Proc objects cannot be
diff --git a/lib/rake.rb b/lib/rake.rb
deleted file mode 100755
index b5924a1211..0000000000
--- a/lib/rake.rb
+++ /dev/null
@@ -1,2240 +0,0 @@
-#!/usr/bin/env ruby
-
-#--
-
-# Copyright (c) 2003, 2004, 2005, 2006, 2007 Jim Weirich
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-#++
-#
-# = Rake -- Ruby Make
-#
-# This is the main file for the Rake application. Normally it is referenced
-# as a library via a require statement, but it can be distributed
-# independently as an application.
-
-RAKEVERSION = '0.8.0'
-
-require 'rbconfig'
-require 'getoptlong'
-require 'fileutils'
-require 'singleton'
-require 'thread'
-require 'ostruct'
-
-######################################################################
-# Rake extensions to Module.
-#
-class Module
- # Check for an existing method in the current class before extending. IF
- # the method already exists, then a warning is printed and the extension is
- # not added. Otherwise the block is yielded and any definitions in the
- # block will take effect.
- #
- # Usage:
- #
- # class String
- # rake_extension("xyz") do
- # def xyz
- # ...
- # end
- # end
- # end
- #
- def rake_extension(method)
- if instance_methods.include?(method.to_s) || instance_methods.include?(method.to_sym)
- $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists"
- else
- yield
- end
- end
-end # module Module
-
-
-######################################################################
-# User defined methods to be added to String.
-#
-class String
- rake_extension("ext") do
- # Replace the file extension with +newext+. If there is no extenson on
- # the string, append the new extension to the end. If the new extension
- # is not given, or is the empty string, remove any existing extension.
- #
- # +ext+ is a user added method for the String class.
- def ext(newext='')
- return self.dup if ['.', '..'].include? self
- if newext != ''
- newext = (newext =~ /^\./) ? newext : ("." + newext)
- end
- dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
- end
- end
-
- rake_extension("pathmap") do
- # Explode a path into individual components. Used by +pathmap+.
- def pathmap_explode
- head, tail = File.split(self)
- return [self] if head == self
- return [tail] if head == '.' || tail == '/'
- return [head, tail] if head == '/'
- return head.pathmap_explode + [tail]
- end
- protected :pathmap_explode
-
- # Extract a partial path from the path. Include +n+ directories from the
- # front end (left hand side) if +n+ is positive. Include |+n+|
- # directories from the back end (right hand side) if +n+ is negative.
- def pathmap_partial(n)
- dirs = File.dirname(self).pathmap_explode
- partial_dirs =
- if n > 0
- dirs[0...n]
- elsif n < 0
- dirs.reverse[0...-n].reverse
- else
- "."
- end
- File.join(partial_dirs)
- end
- protected :pathmap_partial
-
- # Preform the pathmap replacement operations on the given path. The
- # patterns take the form 'pat1,rep1;pat2,rep2...'.
- def pathmap_replace(patterns, &block)
- result = self
- patterns.split(';').each do |pair|
- pattern, replacement = pair.split(',')
- pattern = Regexp.new(pattern)
- if replacement == '*' && block_given?
- result = result.sub(pattern, &block)
- elsif replacement
- result = result.sub(pattern, replacement)
- else
- result = result.sub(pattern, '')
- end
- end
- result
- end
- protected :pathmap_replace
-
- # Map the path according to the given specification. The specification
- # controls the details of the mapping. The following special patterns are
- # recognized:
- #
- # * <b>%p</b> -- The complete path.
- # * <b>%f</b> -- The base file name of the path, with its file extension,
- # but without any directories.
- # * <b>%n</b> -- The file name of the path without its file extension.
- # * <b>%d</b> -- The directory list of the path.
- # * <b>%x</b> -- The file extension of the path. An empty string if there
- # is no extension.
- # * <b>%X</b> -- Everything *but* the file extension.
- # * <b>%s</b> -- The alternate file separater if defined, otherwise use
- # the standard file separator.
- # * <b>%%</b> -- A percent sign.
- #
- # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the
- # number is positive, only return (up to) +n+ directories in the path,
- # starting from the left hand side. If +n+ is negative, return (up to)
- # |+n+| directories from the right hand side of the path.
- #
- # Examples:
- #
- # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
- # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
- #
- # Also the %d, %p, $f, $n, %x, and %X operators can take a
- # pattern/replacement argument to perform simple string substititions on a
- # particular part of the path. The pattern and replacement are speparated
- # by a comma and are enclosed by curly braces. The replacement spec comes
- # after the % character but before the operator letter. (e.g.
- # "%{old,new}d"). Muliple replacement specs should be separated by
- # semi-colons (e.g. "%{old,new;src,bin}d").
- #
- # Regular expressions may be used for the pattern, and back refs may be
- # used in the replacement text. Curly braces, commas and semi-colons are
- # excluded from both the pattern and replacement text (let's keep parsing
- # reasonable).
- #
- # For example:
- #
- # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
- #
- # returns:
- #
- # "bin/org/onestepback/proj/A.class"
- #
- # If the replacement text is '*', then a block may be provided to perform
- # some arbitrary calculation for the replacement.
- #
- # For example:
- #
- # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext|
- # ext.downcase
- # }
- #
- # Returns:
- #
- # "/path/to/file.txt"
- #
- def pathmap(spec=nil, &block)
- return self if spec.nil?
- result = ''
- spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
- case frag
- when '%f'
- result << File.basename(self)
- when '%n'
- result << File.basename(self).ext
- when '%d'
- result << File.dirname(self)
- when '%x'
- result << $1 if self =~ /[^\/](\.[^.]+)$/
- when '%X'
- if self =~ /^(.*[^\/])(\.[^.]+)$/
- result << $1
- else
- result << self
- end
- when '%p'
- result << self
- when '%s'
- result << (File::ALT_SEPARATOR || File::SEPARATOR)
- when '%-'
- # do nothing
- when '%%'
- result << "%"
- when /%(-?\d+)d/
- result << pathmap_partial($1.to_i)
- when /^%\{([^}]*)\}(\d*[dpfnxX])/
- patterns, operator = $1, $2
- result << pathmap('%' + operator).pathmap_replace(patterns, &block)
- when /^%/
- fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
- else
- result << frag
- end
- end
- result
- end
- end
-end # class String
-
-##############################################################################
-module Rake
-
- # --------------------------------------------------------------------------
- # Rake module singleton methods.
- #
- class << self
- # Current Rake Application
- def application
- @application ||= Rake::Application.new
- end
-
- # Set the current Rake application object.
- def application=(app)
- @application = app
- end
-
- # Return the original directory where the Rake application was started.
- def original_dir
- application.original_dir
- end
-
- end
-
- # ##########################################################################
- # Mixin for creating easily cloned objects.
- #
- module Cloneable
- # Clone an object by making a new object and setting all the instance
- # variables to the same values.
- def clone
- sibling = self.class.new
- instance_variables.each do |ivar|
- value = self.instance_variable_get(ivar)
- new_value = value.clone rescue value
- sibling.instance_variable_set(ivar, new_value)
- end
- sibling
- end
- alias dup clone
- end
-
- ####################################################################
- # TaskAguments manage the arguments passed to a task.
- #
- class TaskArguments
- include Enumerable
-
- attr_reader :names
-
- def initialize(names, values, parent=nil)
- @names = names
- @parent = parent
- @hash = {}
- names.each_with_index { |name, i|
- @hash[name.to_sym] = values[i]
- }
- end
-
- # Create a new argument scope using the prerequisite argument
- # names.
- def new_scope(names)
- values = names.collect { |n| self[n] }
- self.class.new(names, values, self)
- end
-
- # Find an argument value by name or index.
- def [](index)
- lookup(index.to_sym)
- end
-
- def each(&block)
- @hash.each(&block)
- end
-
- def method_missing(sym, *args, &block)
- lookup(sym.to_sym)
- end
-
- def to_hash
- @hash
- end
-
- def to_s
- @hash.inspect
- end
-
- def inspect
- to_s
- end
-
- protected
-
- def lookup(name)
- if @hash.has_key?(name)
- @hash[name]
- elsif ENV.has_key?(name.to_s)
- ENV[name.to_s]
- elsif ENV.has_key?(name.to_s.upcase)
- ENV[name.to_s.upcase]
- elsif @parent
- @parent.lookup(name)
- end
- end
- end
-
- ####################################################################
- # InvocationChain tracks the chain of task invocations to detect
- # circular dependencies.
- class InvocationChain
- def initialize(value, tail)
- @value = value
- @tail = tail
- end
-
- def member?(obj)
- @value == obj || @tail.member?(obj)
- end
-
- def append(value)
- if member?(value)
- fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}"
- end
- self.class.new(value, self)
- end
-
- def to_s
- "#{prefix}#{@value}"
- end
-
- def self.append(value, chain)
- chain.append(value)
- end
-
- private
-
- def prefix
- "#{@tail.to_s} => "
- end
-
- class EmptyInvocationChain
- def member?(obj)
- false
- end
- def append(value)
- InvocationChain.new(value, self)
- end
- def to_s
- "TOP"
- end
- end
-
- EMPTY = EmptyInvocationChain.new
-
- end # class InvocationChain
-
-end # module Rake
-
-module Rake
-
- # #########################################################################
- # A Task is the basic unit of work in a Rakefile. Tasks have associated
- # actions (possibly more than one) and a list of prerequisites. When
- # invoked, a task will first ensure that all of its prerequisites have an
- # opportunity to run and then it will execute its own actions.
- #
- # Tasks are not usually created directly using the new method, but rather
- # use the +file+ and +task+ convenience methods.
- #
- class Task
- # List of prerequisites for a task.
- attr_reader :prerequisites
-
- # Application owning this task.
- attr_accessor :application
-
- # Comment for this task. Restricted to a single line of no more than 50
- # characters.
- attr_reader :comment
-
- # Full text of the (possibly multi-line) comment.
- attr_reader :full_comment
-
- # Array of nested namespaces names used for task lookup by this task.
- attr_reader :scope
-
- # Return task name
- def to_s
- name
- end
-
- def inspect
- "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>"
- end
-
- # List of sources for task.
- attr_writer :sources
- def sources
- @sources ||= []
- end
-
- # First source from a rule (nil if no sources)
- def source
- @sources.first if defined?(@sources)
- end
-
- # Create a task named +task_name+ with no actions or prerequisites. Use
- # +enhance+ to add actions and prerequisites.
- def initialize(task_name, app)
- @name = task_name.to_s
- @prerequisites = FileList[]
- @actions = []
- @already_invoked = false
- @full_comment = nil
- @comment = nil
- @lock = Mutex.new
- @application = app
- @scope = app.current_scope
- @arg_names = nil
- end
-
- # Enhance a task with prerequisites or actions. Returns self.
- def enhance(deps=nil, &block)
- @prerequisites |= deps if deps
- @actions << block if block_given?
- self
- end
-
- # Name of the task, including any namespace qualifiers.
- def name
- @name.to_s
- end
-
- # Name of task with argument list description.
- def name_with_args # :nodoc:
- if arg_description
- "#{name}#{arg_description}"
- else
- name
- end
- end
-
- # Argument description (nil if none).
- def arg_description # :nodoc:
- @arg_names ? "[#{(arg_names || []).join(',')}]" : nil
- end
-
- # Name of arguments for this task.
- def arg_names
- @arg_names || []
- end
-
- # Invoke the task if it is needed. Prerequites are invoked first.
- def invoke(*args)
- task_args = TaskArguments.new(arg_names, args)
- invoke_with_call_chain(task_args, InvocationChain::EMPTY)
- end
-
- # Same as invoke, but explicitly pass a call chain to detect
- # circular dependencies.
- def invoke_with_call_chain(task_args, invocation_chain)
- new_chain = InvocationChain.append(self, invocation_chain)
- @lock.synchronize do
- if application.options.trace
- puts "** Invoke #{name} #{format_trace_flags}"
- end
- return if @already_invoked
- @already_invoked = true
- invoke_prerequisites(task_args, new_chain)
- execute(task_args) if needed?
- end
- end
- protected :invoke_with_call_chain
-
- # Invoke all the prerequisites of a task.
- def invoke_prerequisites(task_args, invocation_chain)
- @prerequisites.each { |n|
- prereq = application[n, @scope]
- prereq_args = task_args.new_scope(prereq.arg_names)
- prereq.invoke_with_call_chain(prereq_args, invocation_chain)
- }
- end
-
- # Format the trace flags for display.
- def format_trace_flags
- flags = []
- flags << "first_time" unless @already_invoked
- flags << "not_needed" unless needed?
- flags.empty? ? "" : "(" + flags.join(", ") + ")"
- end
- private :format_trace_flags
-
- # Execute the actions associated with this task.
- def execute(args)
- if application.options.dryrun
- puts "** Execute (dry run) #{name}"
- return
- end
- if application.options.trace
- puts "** Execute #{name}"
- end
- application.enhance_with_matching_rule(name) if @actions.empty?
- @actions.each do |act|
- case act.arity
- when 1
- act.call(self)
- else
- act.call(self, args)
- end
- end
- end
-
- # Is this task needed?
- def needed?
- true
- end
-
- # Timestamp for this task. Basic tasks return the current time for their
- # time stamp. Other tasks can be more sophisticated.
- def timestamp
- @prerequisites.collect { |p| application[p].timestamp }.max || Time.now
- end
-
- # Add a description to the task. The description can consist of an option
- # argument list (enclosed brackets) and an optional comment.
- def add_description(description)
- return if ! description
- comment = description.strip
- add_comment(comment) if comment && ! comment.empty?
- end
-
- # Writing to the comment attribute is the same as adding a description.
- def comment=(description)
- add_description(description)
- end
-
- # Add a comment to the task. If a comment alread exists, separate
- # the new comment with " / ".
- def add_comment(comment)
- if @full_comment
- @full_comment << " / "
- else
- @full_comment = ''
- end
- @full_comment << comment
- if @full_comment =~ /\A([^.]+?\.)( |$)/
- @comment = $1
- else
- @comment = @full_comment
- end
- end
- private :add_comment
-
- # Set the names of the arguments for this task. +args+ should be
- # an array of symbols, one for each argument name.
- def set_arg_names(args)
- @arg_names = args.map { |a| a.to_sym }
- end
-
- # Return a string describing the internal state of a task. Useful for
- # debugging.
- def investigation
- result = "------------------------------\n"
- result << "Investigating #{name}\n"
- result << "class: #{self.class}\n"
- result << "task needed: #{needed?}\n"
- result << "timestamp: #{timestamp}\n"
- result << "pre-requisites: \n"
- prereqs = @prerequisites.collect {|name| application[name]}
- prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
- prereqs.each do |p|
- result << "--#{p.name} (#{p.timestamp})\n"
- end
- latest_prereq = @prerequisites.collect{|n| application[n].timestamp}.max
- result << "latest-prerequisite time: #{latest_prereq}\n"
- result << "................................\n\n"
- return result
- end
-
- # ----------------------------------------------------------------
- # Rake Module Methods
- #
- class << self
-
- # Clear the task list. This cause rake to immediately forget all the
- # tasks that have been assigned. (Normally used in the unit tests.)
- def clear
- Rake.application.clear
- end
-
- # List of all defined tasks.
- def tasks
- Rake.application.tasks
- end
-
- # Return a task with the given name. If the task is not currently
- # known, try to synthesize one from the defined rules. If no rules are
- # found, but an existing file matches the task name, assume it is a file
- # task with no dependencies or actions.
- def [](task_name)
- Rake.application[task_name]
- end
-
- # TRUE if the task name is already defined.
- def task_defined?(task_name)
- Rake.application.lookup(task_name) != nil
- end
-
- # Define a task given +args+ and an option block. If a rule with the
- # given name already exists, the prerequisites and actions are added to
- # the existing task. Returns the defined task.
- def define_task(*args, &block)
- Rake.application.define_task(self, *args, &block)
- end
-
- # Define a rule for synthesizing tasks.
- def create_rule(*args, &block)
- Rake.application.create_rule(*args, &block)
- end
-
- # Apply the scope to the task name according to the rules for
- # this kind of task. Generic tasks will accept the scope as
- # part of the name.
- def scope_name(scope, task_name)
- (scope + [task_name]).join(':')
- end
-
- end # class << Rake::Task
- end # class Rake::Task
-
-
- # #########################################################################
- # A FileTask is a task that includes time based dependencies. If any of a
- # FileTask's prerequisites have a timestamp that is later than the file
- # represented by this task, then the file must be rebuilt (using the
- # supplied actions).
- #
- class FileTask < Task
-
- # Is this file task needed? Yes if it doesn't exist, or if its time stamp
- # is out of date.
- def needed?
- return true unless File.exist?(name)
- return true if out_of_date?(timestamp)
- false
- end
-
- # Time stamp for file task.
- def timestamp
- if File.exist?(name)
- File.mtime(name.to_s)
- else
- Rake::EARLY
- end
- end
-
- private
-
- # Are there any prerequisites with a later time than the given time stamp?
- def out_of_date?(stamp)
- @prerequisites.any? { |n| application[n].timestamp > stamp}
- end
-
- # ----------------------------------------------------------------
- # Task class methods.
- #
- class << self
- # Apply the scope to the task name according to the rules for this kind
- # of task. File based tasks ignore the scope when creating the name.
- def scope_name(scope, task_name)
- task_name
- end
- end
- end # class Rake::FileTask
-
- # #########################################################################
- # A FileCreationTask is a file task that when used as a dependency will be
- # needed if and only if the file has not been created. Once created, it is
- # not re-triggered if any of its dependencies are newer, nor does trigger
- # any rebuilds of tasks that depend on it whenever it is updated.
- #
- class FileCreationTask < FileTask
- # Is this file task needed? Yes if it doesn't exist.
- def needed?
- ! File.exist?(name)
- end
-
- # Time stamp for file creation task. This time stamp is earlier
- # than any other time stamp.
- def timestamp
- Rake::EARLY
- end
- end
-
- # #########################################################################
- # Same as a regular task, but the immediate prerequisites are done in
- # parallel using Ruby threads.
- #
- class MultiTask < Task
- def invoke_prerequisites(args, invocation_chain)
- threads = @prerequisites.collect { |p|
- Thread.new(p) { |r| application[r].invoke_with_call_chain(args, invocation_chain) }
- }
- threads.each { |t| t.join }
- end
- end
-end # module Rake
-
-# ###########################################################################
-# Task Definition Functions ...
-
-# Declare a basic task.
-#
-# Example:
-# task :clobber => [:clean] do
-# rm_rf "html"
-# end
-#
-def task(*args, &block)
- Rake::Task.define_task(*args, &block)
-end
-
-
-# Declare a file task.
-#
-# Example:
-# file "config.cfg" => ["config.template"] do
-# open("config.cfg", "w") do |outfile|
-# open("config.template") do |infile|
-# while line = infile.gets
-# outfile.puts line
-# end
-# end
-# end
-# end
-#
-def file(args, &block)
- Rake::FileTask.define_task(args, &block)
-end
-
-# Declare a file creation task.
-# (Mainly used for the directory command).
-def file_create(args, &block)
- Rake::FileCreationTask.define_task(args, &block)
-end
-
-# Declare a set of files tasks to create the given directories on demand.
-#
-# Example:
-# directory "testdata/doc"
-#
-def directory(dir)
- Rake.each_dir_parent(dir) do |d|
- file_create d do |t|
- mkdir_p t.name if ! File.exist?(t.name)
- end
- end
-end
-
-# Declare a task that performs its prerequisites in parallel. Multitasks does
-# *not* guarantee that its prerequisites will execute in any given order
-# (which is obvious when you think about it)
-#
-# Example:
-# multitask :deploy => [:deploy_gem, :deploy_rdoc]
-#
-def multitask(args, &block)
- Rake::MultiTask.define_task(args, &block)
-end
-
-# Create a new rake namespace and use it for evaluating the given block.
-# Returns a NameSpace object that can be used to lookup tasks defined in the
-# namespace.
-#
-# E.g.
-#
-# ns = namespace "nested" do
-# task :run
-# end
-# task_run = ns[:run] # find :run in the given namespace.
-#
-def namespace(name=nil, &block)
- Rake.application.in_namespace(name, &block)
-end
-
-# Declare a rule for auto-tasks.
-#
-# Example:
-# rule '.o' => '.c' do |t|
-# sh %{cc -o #{t.name} #{t.source}}
-# end
-#
-def rule(*args, &block)
- Rake::Task.create_rule(*args, &block)
-end
-
-# Describe the next rake task.
-#
-# Example:
-# desc "Run the Unit Tests"
-# task :test => [:build]
-# runtests
-# end
-#
-def desc(description)
- Rake.application.last_description = description
-end
-
-# Import the partial Rakefiles +fn+. Imported files are loaded _after_ the
-# current file is completely loaded. This allows the import statement to
-# appear anywhere in the importing file, and yet allowing the imported files
-# to depend on objects defined in the importing file.
-#
-# A common use of the import statement is to include files containing
-# dependency declarations.
-#
-# See also the --rakelibdir command line option.
-#
-# Example:
-# import ".depend", "my_rules"
-#
-def import(*fns)
- fns.each do |fn|
- Rake.application.add_import(fn)
- end
-end
-
-# ###########################################################################
-# This a FileUtils extension that defines several additional commands to be
-# added to the FileUtils utility functions.
-#
-module FileUtils
- RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
-
- OPT_TABLE['sh'] = %w(noop verbose)
- OPT_TABLE['ruby'] = %w(noop verbose)
-
- # Run the system command +cmd+. If multiple arguments are given the command
- # is not run with the shell (same semantics as Kernel::exec and
- # Kernel::system).
- #
- # Example:
- # sh %{ls -ltr}
- #
- # sh 'ls', 'file with spaces'
- #
- # # check exit status after command runs
- # sh %{grep pattern file} do |ok, res|
- # if ! ok
- # puts "pattern not found (status = #{res.exitstatus})"
- # end
- # end
- #
- def sh(*cmd, &block)
- options = (Hash === cmd.last) ? cmd.pop : {}
- unless block_given?
- show_command = cmd.join(" ")
- show_command = show_command[0,42] + "..."
- # TODO code application logic heref show_command.length > 45
- block = lambda { |ok, status|
- ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
- }
- end
- rake_check_options options, :noop, :verbose
- rake_output_message cmd.join(" ") if options[:verbose]
- unless options[:noop]
- res = system(*cmd)
- block.call(res, $?)
- end
- end
-
- # Run a Ruby interpreter with the given arguments.
- #
- # Example:
- # ruby %{-pe '$_.upcase!' <README}
- #
- def ruby(*args,&block)
- options = (Hash === args.last) ? args.pop : {}
- if args.length > 1 then
- sh(*([RUBY] + args + [options]), &block)
- else
- sh("#{RUBY} #{args.first}", options, &block)
- end
- end
-
- LN_SUPPORTED = [true]
-
- # Attempt to do a normal file link, but fall back to a copy if the link
- # fails.
- def safe_ln(*args)
- unless LN_SUPPORTED[0]
- cp(*args)
- else
- begin
- ln(*args)
- rescue StandardError, NotImplementedError => ex
- LN_SUPPORTED[0] = false
- cp(*args)
- end
- end
- end
-
- # Split a file path into individual directory names.
- #
- # Example:
- # split_all("a/b/c") => ['a', 'b', 'c']
- #
- def split_all(path)
- head, tail = File.split(path)
- return [tail] if head == '.' || tail == '/'
- return [head, tail] if head == '/'
- return split_all(head) + [tail]
- end
-end
-
-# ###########################################################################
-# RakeFileUtils provides a custom version of the FileUtils methods that
-# respond to the <tt>verbose</tt> and <tt>nowrite</tt> commands.
-#
-module RakeFileUtils
- include FileUtils
-
- class << self
- attr_accessor :verbose_flag, :nowrite_flag
- end
- RakeFileUtils.verbose_flag = true
- RakeFileUtils.nowrite_flag = false
-
- $fileutils_verbose = true
- $fileutils_nowrite = false
-
- FileUtils::OPT_TABLE.each do |name, opts|
- default_options = []
- if opts.include?('verbose')
- default_options << ':verbose => RakeFileUtils.verbose_flag'
- end
- if opts.include?('noop')
- default_options << ':noop => RakeFileUtils.nowrite_flag'
- end
-
- next if default_options.empty?
- module_eval(<<-EOS, __FILE__, __LINE__ + 1)
- def #{name}( *args, &block )
- super(
- *rake_merge_option(args,
- #{default_options.join(', ')}
- ), &block)
- end
- EOS
- end
-
- # Get/set the verbose flag controlling output from the FileUtils utilities.
- # If verbose is true, then the utility method is echoed to standard output.
- #
- # Examples:
- # verbose # return the current value of the verbose flag
- # verbose(v) # set the verbose flag to _v_.
- # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_.
- # # Return to the original value when code is done.
- def verbose(value=nil)
- oldvalue = RakeFileUtils.verbose_flag
- RakeFileUtils.verbose_flag = value unless value.nil?
- if block_given?
- begin
- yield
- ensure
- RakeFileUtils.verbose_flag = oldvalue
- end
- end
- RakeFileUtils.verbose_flag
- end
-
- # Get/set the nowrite flag controlling output from the FileUtils utilities.
- # If verbose is true, then the utility method is echoed to standard output.
- #
- # Examples:
- # nowrite # return the current value of the nowrite flag
- # nowrite(v) # set the nowrite flag to _v_.
- # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_.
- # # Return to the original value when code is done.
- def nowrite(value=nil)
- oldvalue = RakeFileUtils.nowrite_flag
- RakeFileUtils.nowrite_flag = value unless value.nil?
- if block_given?
- begin
- yield
- ensure
- RakeFileUtils.nowrite_flag = oldvalue
- end
- end
- oldvalue
- end
-
- # Use this function to prevent protentially destructive ruby code from
- # running when the :nowrite flag is set.
- #
- # Example:
- #
- # when_writing("Building Project") do
- # project.build
- # end
- #
- # The following code will build the project under normal conditions. If the
- # nowrite(true) flag is set, then the example will print:
- # DRYRUN: Building Project
- # instead of actually building the project.
- #
- def when_writing(msg=nil)
- if RakeFileUtils.nowrite_flag
- puts "DRYRUN: #{msg}" if msg
- else
- yield
- end
- end
-
- # Merge the given options with the default values.
- def rake_merge_option(args, defaults)
- if Hash === args.last
- defaults.update(args.last)
- args.pop
- end
- args.push defaults
- args
- end
- private :rake_merge_option
-
- # Send the message to the default rake output (which is $stderr).
- def rake_output_message(message)
- $stderr.puts(message)
- end
- private :rake_output_message
-
- # Check that the options do not contain options not listed in +optdecl+. An
- # ArgumentError exception is thrown if non-declared options are found.
- def rake_check_options(options, *optdecl)
- h = options.dup
- optdecl.each do |name|
- h.delete name
- end
- raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
- end
- private :rake_check_options
-
- extend self
-end
-
-# ###########################################################################
-# Include the FileUtils file manipulation functions in the top level module,
-# but mark them private so that they don't unintentionally define methods on
-# other objects.
-
-include RakeFileUtils
-private(*FileUtils.instance_methods(false))
-private(*RakeFileUtils.instance_methods(false))
-
-######################################################################
-module Rake
-
- class RuleRecursionOverflowError < StandardError
- def initialize(*args)
- super
- @targets = []
- end
-
- def add_target(target)
- @targets << target
- end
-
- def message
- super + ": [" + @targets.reverse.join(' => ') + "]"
- end
- end
-
- # #########################################################################
- # A FileList is essentially an array with a few helper methods defined to
- # make file manipulation a bit easier.
- #
- # FileLists are lazy. When given a list of glob patterns for possible files
- # to be included in the file list, instead of searching the file structures
- # to find the files, a FileList holds the pattern for latter use.
- #
- # This allows us to define a number of FileList to match any number of
- # files, but only search out the actual files when then FileList itself is
- # actually used. The key is that the first time an element of the
- # FileList/Array is requested, the pending patterns are resolved into a real
- # list of file names.
- #
- class FileList
-
- include Cloneable
-
- # == Method Delegation
- #
- # The lazy evaluation magic of FileLists happens by implementing all the
- # array specific methods to call +resolve+ before delegating the heavy
- # lifting to an embedded array object (@items).
- #
- # In addition, there are two kinds of delegation calls. The regular kind
- # delegates to the @items array and returns the result directly. Well,
- # almost directly. It checks if the returned value is the @items object
- # itself, and if so will return the FileList object instead.
- #
- # The second kind of delegation call is used in methods that normally
- # return a new Array object. We want to capture the return value of these
- # methods and wrap them in a new FileList object. We enumerate these
- # methods in the +SPECIAL_RETURN+ list below.
-
- # List of array methods (that are not in +Object+) that need to be
- # delegated.
- ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map { |n| n.to_s }
-
- # List of additional methods that must be delegated.
- MUST_DEFINE = %w[to_a inspect]
-
- # List of methods that should not be delegated here (we define special
- # versions of them explicitly below).
- MUST_NOT_DEFINE = %w[to_a to_ary partition *]
-
- # List of delegated methods that return new array values which need
- # wrapping.
- SPECIAL_RETURN = %w[
- map collect sort sort_by select find_all reject grep
- compact flatten uniq values_at
- + - & |
- ]
-
- DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq
-
- # Now do the delegation.
- DELEGATING_METHODS.each_with_index do |sym, i|
- if SPECIAL_RETURN.include?(sym)
- ln = __LINE__+1
- class_eval %{
- def #{sym}(*args, &block)
- resolve
- result = @items.send(:#{sym}, *args, &block)
- FileList.new.import(result)
- end
- }, __FILE__, ln
- else
- ln = __LINE__+1
- class_eval %{
- def #{sym}(*args, &block)
- resolve
- result = @items.send(:#{sym}, *args, &block)
- result.object_id == @items.object_id ? self : result
- end
- }, __FILE__, ln
- end
- end
-
- # Create a file list from the globbable patterns given. If you wish to
- # perform multiple includes or excludes at object build time, use the
- # "yield self" pattern.
- #
- # Example:
- # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb')
- #
- # pkg_files = FileList.new('lib/**/*') do |fl|
- # fl.exclude(/\bCVS\b/)
- # end
- #
- def initialize(*patterns)
- @pending_add = []
- @pending = false
- @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
- @exclude_procs = DEFAULT_IGNORE_PROCS.dup
- @exclude_re = nil
- @items = []
- patterns.each { |pattern| include(pattern) }
- yield self if block_given?
- end
-
- # Add file names defined by glob patterns to the file list. If an array
- # is given, add each element of the array.
- #
- # Example:
- # file_list.include("*.java", "*.cfg")
- # file_list.include %w( math.c lib.h *.o )
- #
- def include(*filenames)
- # TODO: check for pending
- filenames.each do |fn|
- if fn.respond_to? :to_ary
- include(*fn.to_ary)
- else
- @pending_add << fn
- end
- end
- @pending = true
- self
- end
- alias :add :include
-
- # Register a list of file name patterns that should be excluded from the
- # list. Patterns may be regular expressions, glob patterns or regular
- # strings. In addition, a block given to exclude will remove entries that
- # return true when given to the block.
- #
- # Note that glob patterns are expanded against the file system. If a file
- # is explicitly added to a file list, but does not exist in the file
- # system, then an glob pattern in the exclude list will not exclude the
- # file.
- #
- # Examples:
- # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c']
- # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c']
- #
- # If "a.c" is a file, then ...
- # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c']
- #
- # If "a.c" is not a file, then ...
- # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c']
- #
- def exclude(*patterns, &block)
- patterns.each do |pat|
- @exclude_patterns << pat
- end
- if block_given?
- @exclude_procs << block
- end
- resolve_exclude if ! @pending
- self
- end
-
-
- # Clear all the exclude patterns so that we exclude nothing.
- def clear_exclude
- @exclude_patterns = []
- @exclude_procs = []
- calculate_exclude_regexp if ! @pending
- self
- end
-
- # Define equality.
- def ==(array)
- to_ary == array
- end
-
- # Return the internal array object.
- def to_a
- resolve
- @items
- end
-
- # Return the internal array object.
- def to_ary
- to_a
- end
-
- # Lie about our class.
- def is_a?(klass)
- klass == Array || super(klass)
- end
- alias kind_of? is_a?
-
- # Redefine * to return either a string or a new file list.
- def *(other)
- result = @items * other
- case result
- when Array
- FileList.new.import(result)
- else
- result
- end
- end
-
- # Resolve all the pending adds now.
- def resolve
- if @pending
- @pending = false
- @pending_add.each do |fn| resolve_add(fn) end
- @pending_add = []
- resolve_exclude
- end
- self
- end
-
- def calculate_exclude_regexp
- ignores = []
- @exclude_patterns.each do |pat|
- case pat
- when Regexp
- ignores << pat
- when /[*?]/
- Dir[pat].each do |p| ignores << p end
- else
- ignores << Regexp.quote(pat)
- end
- end
- if ignores.empty?
- @exclude_re = /^$/
- else
- re_str = ignores.collect { |p| "(" + p.to_s + ")" }.join("|")
- @exclude_re = Regexp.new(re_str)
- end
- end
-
- def resolve_add(fn)
- case fn
- when %r{[*?\[\{]}
- add_matching(fn)
- else
- self << fn
- end
- end
- private :resolve_add
-
- def resolve_exclude
- calculate_exclude_regexp
- reject! { |fn| exclude?(fn) }
- self
- end
- private :resolve_exclude
-
- # Return a new FileList with the results of running +sub+ against each
- # element of the oringal list.
- #
- # Example:
- # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']
- #
- def sub(pat, rep)
- inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) }
- end
-
- # Return a new FileList with the results of running +gsub+ against each
- # element of the original list.
- #
- # Example:
- # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\")
- # => ['lib\\test\\file', 'x\\y']
- #
- def gsub(pat, rep)
- inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) }
- end
-
- # Same as +sub+ except that the oringal file list is modified.
- def sub!(pat, rep)
- each_with_index { |fn, i| self[i] = fn.sub(pat,rep) }
- self
- end
-
- # Same as +gsub+ except that the original file list is modified.
- def gsub!(pat, rep)
- each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) }
- self
- end
-
- # Apply the pathmap spec to each of the included file names, returning a
- # new file list with the modified paths. (See String#pathmap for
- # details.)
- def pathmap(spec=nil)
- collect { |fn| fn.pathmap(spec) }
- end
-
- # Return a new array with <tt>String#ext</tt> method applied to each
- # member of the array.
- #
- # This method is a shortcut for:
- #
- # array.collect { |item| item.ext(newext) }
- #
- # +ext+ is a user added method for the Array class.
- def ext(newext='')
- collect { |fn| fn.ext(newext) }
- end
-
-
- # Grep each of the files in the filelist using the given pattern. If a
- # block is given, call the block on each matching line, passing the file
- # name, line number, and the matching line of text. If no block is given,
- # a standard emac style file:linenumber:line message will be printed to
- # standard out.
- def egrep(pattern)
- each do |fn|
- open(fn) do |inf|
- count = 0
- inf.each do |line|
- count += 1
- if pattern.match(line)
- if block_given?
- yield fn, count, line
- else
- puts "#{fn}:#{count}:#{line}"
- end
- end
- end
- end
- end
- end
-
- # Return a new file list that only contains file names from the current
- # file list that exist on the file system.
- def existing
- select { |fn| File.exist?(fn) }
- end
-
- # Modify the current file list so that it contains only file name that
- # exist on the file system.
- def existing!
- resolve
- @items = @items.select { |fn| File.exist?(fn) }
- self
- end
-
- # FileList version of partition. Needed because the nested arrays should
- # be FileLists in this version.
- def partition(&block) # :nodoc:
- resolve
- result = @items.partition(&block)
- [
- FileList.new.import(result[0]),
- FileList.new.import(result[1]),
- ]
- end
-
- # Convert a FileList to a string by joining all elements with a space.
- def to_s
- resolve
- self.join(' ')
- end
-
- # Add matching glob patterns.
- def add_matching(pattern)
- Dir[pattern].each do |fn|
- self << fn unless exclude?(fn)
- end
- end
- private :add_matching
-
- # Should the given file name be excluded?
- def exclude?(fn)
- calculate_exclude_regexp unless @exclude_re
- fn =~ @exclude_re || @exclude_procs.any? { |p| p.call(fn) }
- end
-
- DEFAULT_IGNORE_PATTERNS = [
- /(^|[\/\\])CVS([\/\\]|$)/,
- /(^|[\/\\])\.svn([\/\\]|$)/,
- /\.bak$/,
- /~$/
- ]
- DEFAULT_IGNORE_PROCS = [
- proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) }
- ]
-# @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup
-
- def import(array)
- @items = array
- self
- end
-
- class << self
- # Create a new file list including the files listed. Similar to:
- #
- # FileList.new(*args)
- def [](*args)
- new(*args)
- end
- end
- end # FileList
-end
-
-module Rake
- class << self
-
- # Yield each file or directory component.
- def each_dir_parent(dir)
- old_length = nil
- while dir != '.' && dir.length != old_length
- yield(dir)
- old_length = dir.length
- dir = File.dirname(dir)
- end
- end
- end
-end # module Rake
-
-# Alias FileList to be available at the top level.
-FileList = Rake::FileList
-
-# ###########################################################################
-module Rake
-
- # Default Rakefile loader used by +import+.
- class DefaultLoader
- def load(fn)
- Kernel.load(File.expand_path(fn))
- end
- end
-
- # EarlyTime is a fake timestamp that occurs _before_ any other time value.
- class EarlyTime
- include Comparable
- include Singleton
-
- def <=>(other)
- -1
- end
-
- def to_s
- "<EARLY TIME>"
- end
- end
-
- EARLY = EarlyTime.instance
-end # module Rake
-
-# ###########################################################################
-# Extensions to time to allow comparisons with an early time class.
-#
-class Time
- alias rake_original_time_compare :<=>
- def <=>(other)
- if Rake::EarlyTime === other
- - other.<=>(self)
- else
- rake_original_time_compare(other)
- end
- end
-end # class Time
-
-module Rake
-
- ####################################################################
- # The NameSpace class will lookup task names in the the scope
- # defined by a +namespace+ command.
- #
- class NameSpace
-
- # Create a namespace lookup object using the given task manager
- # and the list of scopes.
- def initialize(task_manager, scope_list)
- @task_manager = task_manager
- @scope = scope_list.dup
- end
-
- # Lookup a task named +name+ in the namespace.
- def [](name)
- @task_manager.lookup(name, @scope)
- end
-
- # Return the list of tasks defined in this namespace.
- def tasks
- @task_manager.tasks
- end
- end # NameSpace
-
-
- ####################################################################
- # The TaskManager module is a mixin for managing tasks.
- module TaskManager
- # Track the last comment made in the Rakefile.
- attr_accessor :last_description
- alias :last_comment :last_description # Backwards compatibility
-
- def initialize
- super
- @tasks = Hash.new
- @rules = Array.new
- @scope = Array.new
- @last_description = nil
- end
-
- def create_rule(*args, &block)
- pattern, arg_names, deps = resolve_args(args)
- pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
- @rules << [pattern, deps, block]
- end
-
- def define_task(task_class, *args, &block)
- task_name, arg_names, deps = resolve_args(args)
- task_name = task_class.scope_name(@scope, task_name)
- deps = [deps] unless deps.respond_to?(:to_ary)
- deps = deps.collect {|d| d.to_s }
- task = intern(task_class, task_name)
- task.set_arg_names(arg_names) unless arg_names.empty?
- task.add_description(@last_description)
- @last_description = nil
- task.enhance(deps, &block)
- task
- end
-
- # Lookup a task. Return an existing task if found, otherwise
- # create a task of the current type.
- def intern(task_class, task_name)
- @tasks[task_name.to_s] ||= task_class.new(task_name, self)
- end
-
- # Find a matching task for +task_name+.
- def [](task_name, scopes=nil)
- task_name = task_name.to_s
- self.lookup(task_name, scopes) or
- enhance_with_matching_rule(task_name) or
- synthesize_file_task(task_name) or
- fail "Don't know how to build task '#{task_name}'"
- end
-
- def synthesize_file_task(task_name)
- return nil unless File.exist?(task_name)
- define_task(Rake::FileTask, task_name)
- end
-
- # Resolve the arguments for a task/rule. Returns a triplet of
- # [task_name, arg_name_list, prerequisites].
- def resolve_args(args)
- task_name = args.shift
- arg_names = args #.map { |a| a.to_sym }
- needs = []
- if task_name.is_a?(Hash)
- hash = task_name
- task_name = hash.keys[0]
- needs = hash[task_name]
- end
- if arg_names.last.is_a?(Hash)
- hash = arg_names.pop
- needs = hash[:needs]
- fail "Unrecognized keys in task hash: #{hash.keys.inspect}" if hash.size > 1
- end
- needs = [needs] unless needs.respond_to?(:to_ary)
- [task_name, arg_names, needs]
- end
-
- # If a rule can be found that matches the task name, enhance the
- # task with the prerequisites and actions from the rule. Set the
- # source attribute of the task appropriately for the rule. Return
- # the enhanced task or nil of no rule was found.
- def enhance_with_matching_rule(task_name, level=0)
- fail Rake::RuleRecursionOverflowError,
- "Rule Recursion Too Deep" if level >= 16
- @rules.each do |pattern, extensions, block|
- if md = pattern.match(task_name)
- task = attempt_rule(task_name, extensions, block, level)
- return task if task
- end
- end
- nil
- rescue Rake::RuleRecursionOverflowError => ex
- ex.add_target(task_name)
- fail ex
- end
-
- # List of all defined tasks in this application.
- def tasks
- @tasks.values.sort_by { |t| t.name }
- end
-
- # Clear all tasks in this application.
- def clear
- @tasks.clear
- @rules.clear
- end
-
- # Lookup a task, using scope and the scope hints in the task name.
- # This method performs straight lookups without trying to
- # synthesize file tasks or rules. Special scope names (e.g. '^')
- # are recognized. If no scope argument is supplied, use the
- # current scope. Return nil if the task cannot be found.
- def lookup(task_name, initial_scope=nil)
- initial_scope ||= @scope
- task_name = task_name.to_s
- if task_name =~ /^rake:/
- scopes = []
- task_name = task_name.sub(/^rake:/, '')
- elsif task_name =~ /^(\^+)/
- scopes = initial_scope[0, initial_scope.size - $1.size]
- task_name = task_name.sub(/^(\^+)/, '')
- else
- scopes = initial_scope
- end
- lookup_in_scope(task_name, scopes)
- end
-
- # Lookup the task name
- def lookup_in_scope(name, scope)
- n = scope.size
- while n >= 0
- tn = (scope[0,n] + [name]).join(':')
- task = @tasks[tn]
- return task if task
- n -= 1
- end
- nil
- end
- private :lookup_in_scope
-
- # Return the list of scope names currently active in the task
- # manager.
- def current_scope
- @scope.dup
- end
-
- # Evaluate the block in a nested namespace named +name+. Create
- # an anonymous namespace if +name+ is nil.
- def in_namespace(name)
- name ||= generate_name
- @scope.push(name)
- ns = NameSpace.new(self, @scope)
- yield(ns)
- ns
- ensure
- @scope.pop
- end
-
- private
-
- # Generate an anonymous namespace name.
- def generate_name
- @seed ||= 0
- @seed += 1
- "_anon_#{@seed}"
- end
-
- # Attempt to create a rule given the list of prerequisites.
- def attempt_rule(task_name, extensions, block, level)
- sources = make_sources(task_name, extensions)
- prereqs = sources.collect { |source|
- if File.exist?(source) || Rake::Task.task_defined?(source)
- source
- elsif parent = enhance_with_matching_rule(sources.first, level+1)
- parent.name
- else
- return nil
- end
- }
- task = FileTask.define_task({task_name => prereqs}, &block)
- task.sources = prereqs
- task
- end
-
- # Make a list of sources from the list of file name extensions /
- # translation procs.
- def make_sources(task_name, extensions)
- extensions.collect { |ext|
- case ext
- when /%/
- task_name.pathmap(ext)
- when %r{/}
- ext
- when /^\./
- task_name.ext(ext)
- when String
- ext
- when Proc
- if ext.arity == 1
- ext.call(task_name)
- else
- ext.call
- end
- else
- fail "Don't know how to handle rule dependent: #{ext.inspect}"
- end
- }.flatten
- end
-
- end # TaskManager
-
- ######################################################################
- # Rake main application object. When invoking +rake+ from the
- # command line, a Rake::Application object is created and run.
- #
- class Application
- include TaskManager
-
- # The name of the application (typically 'rake')
- attr_reader :name
-
- # The original directory where rake was invoked.
- attr_reader :original_dir
-
- # Name of the actual rakefile used.
- attr_reader :rakefile
-
- # List of the top level task names (task names from the command line).
- attr_reader :top_level_tasks
-
- DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze
-
- OPTIONS = [ # :nodoc:
- ['--classic-namespace', '-C', GetoptLong::NO_ARGUMENT,
- "Put Task and FileTask in the top level namespace"],
- ['--describe', '-D', GetoptLong::OPTIONAL_ARGUMENT,
- "Describe the tasks (matching optional PATTERN), then exit."],
- ['--rakefile', '-f', GetoptLong::OPTIONAL_ARGUMENT,
- "Use FILE as the rakefile."],
- ['--help', '-h', '-H', GetoptLong::NO_ARGUMENT,
- "Display this help message."],
- ['--libdir', '-I', GetoptLong::REQUIRED_ARGUMENT,
- "Include LIBDIR in the search path for required modules."],
- ['--dry-run', '-n', GetoptLong::NO_ARGUMENT,
- "Do a dry run without executing actions."],
- ['--nosearch', '-N', GetoptLong::NO_ARGUMENT,
- "Do not search parent directories for the Rakefile."],
- ['--prereqs', '-P', GetoptLong::NO_ARGUMENT,
- "Display the tasks and dependencies, then exit."],
- ['--quiet', '-q', GetoptLong::NO_ARGUMENT,
- "Do not log messages to standard output."],
- ['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
- "Require MODULE before executing rakefile."],
- ['--rakelibdir', '-R', GetoptLong::REQUIRED_ARGUMENT,
- "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')"],
- ['--silent', '-s', GetoptLong::NO_ARGUMENT,
- "Like --quiet, but also suppresses the 'in directory' announcement."],
- ['--tasks', '-T', GetoptLong::OPTIONAL_ARGUMENT,
- "Display the tasks (matching optional PATTERN) with descriptions, then exit."],
- ['--trace', '-t', GetoptLong::NO_ARGUMENT,
- "Turn on invoke/execute tracing, enable full backtrace."],
- ['--verbose', '-v', GetoptLong::NO_ARGUMENT,
- "Log message to standard output (default)."],
- ['--version', '-V', GetoptLong::NO_ARGUMENT,
- "Display the program version."],
- ]
-
- # Initialize a Rake::Application object.
- def initialize
- super
- @name = 'rake'
- @rakefiles = DEFAULT_RAKEFILES.dup
- @rakefile = nil
- @pending_imports = []
- @imported = []
- @loaders = {}
- @default_loader = Rake::DefaultLoader.new
- @original_dir = Dir.pwd
- @top_level_tasks = []
- add_loader('rf', DefaultLoader.new)
- add_loader('rake', DefaultLoader.new)
- end
-
- # Run the Rake application. The run method performs the following three steps:
- #
- # * Initialize the command line options (+init+).
- # * Define the tasks (+load_rakefile+).
- # * Run the top level tasks (+run_tasks+).
- #
- # If you wish to build a custom rake command, you should call +init+ on your
- # application. The define any tasks. Finally, call +top_level+ to run your top
- # level tasks.
- def run
- standard_exception_handling do
- init
- load_rakefile
- top_level
- end
- end
-
- # Initialize the command line parameters and app name.
- def init(app_name='rake')
- standard_exception_handling do
- @name = app_name
- handle_options
- collect_tasks
- end
- end
-
- # Find the rakefile and then load it and any pending imports.
- def load_rakefile
- standard_exception_handling do
- raw_load_rakefile
- end
- end
-
- # Run the top level tasks of a Rake application.
- def top_level
- standard_exception_handling do
- if options.show_tasks
- display_tasks_and_comments
- elsif options.show_prereqs
- display_prerequisites
- else
- top_level_tasks.each { |task_name| invoke_task(task_name) }
- end
- end
- end
-
- # Add a loader to handle imported files ending in the extension
- # +ext+.
- def add_loader(ext, loader)
- ext = ".#{ext}" unless ext =~ /^\./
- @loaders[ext] = loader
- end
-
- # Application options from the command line
- def options
- @options ||= OpenStruct.new
- end
-
- # private ----------------------------------------------------------------
-
- def invoke_task(task_string)
- name, args = parse_task_string(task_string)
- t = self[name]
- t.invoke(*args)
- end
-
- def parse_task_string(string)
- if string =~ /^([^\[]+)(\[(.*)\])$/
- name = $1
- args = $3.split(/\s*,\s*/)
- else
- name = string
- args = []
- end
- [name, args]
- end
-
- # Provide standard execption handling for the given block.
- def standard_exception_handling
- begin
- yield
- rescue SystemExit => ex
- # Exit silently with current status
- exit(ex.status)
- rescue SystemExit, GetoptLong::InvalidOption => ex
- # Exit silently
- exit(1)
- rescue Exception => ex
- # Exit with error message
- $stderr.puts "rake aborted!"
- $stderr.puts ex.message
- if options.trace
- $stderr.puts ex.backtrace.join("\n")
- else
- $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
- $stderr.puts "(See full trace by running task with --trace)"
- end
- exit(1)
- end
- end
-
- # True if one of the files in RAKEFILES is in the current directory.
- # If a match is found, it is copied into @rakefile.
- def have_rakefile
- @rakefiles.each do |fn|
- if File.exist?(fn) || fn == ''
- @rakefile = fn
- return true
- end
- end
- return false
- end
-
- # Display the rake command line help.
- def help
- puts "rake [-f rakefile] {options} targets..."
- puts
- puts "Options are ..."
- puts
- OPTIONS.sort.each do |long, short, mode, desc|
- if mode == GetoptLong::REQUIRED_ARGUMENT
- if desc =~ /\b([A-Z]{2,})\b/
- long = long + "=#{$1}"
- end
- end
- printf " %-20s (%s)\n", long, short
- printf " %s\n", desc
- end
- end
-
- # Display the tasks and dependencies.
- def display_tasks_and_comments
- displayable_tasks = tasks.select { |t|
- t.comment && t.name =~ options.show_task_pattern
- }
- if options.full_description
- displayable_tasks.each do |t|
- puts "rake #{t.name_with_args}"
- t.full_comment.split("\n").each do |line|
- puts " #{line}"
- end
- puts
- end
- else
- width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
- max_column = 80 - name.size - width - 7
- displayable_tasks.each do |t|
- printf "#{name} %-#{width}s # %s\n",
- t.name_with_args, truncate(t.comment, max_column)
- end
- end
- end
-
- def truncate(string, width)
- if string.length <= width
- string
- else
- string[0, width-3] + "..."
- end
- end
-
- # Display the tasks and prerequisites
- def display_prerequisites
- tasks.each do |t|
- puts "rake #{t.name}"
- t.prerequisites.each { |pre| puts " #{pre}" }
- end
- end
-
- # Return a list of the command line options supported by the
- # program.
- def command_line_options
- OPTIONS.collect { |lst| lst[0..-2] }
- end
-
- # Do the option defined by +opt+ and +value+.
- def do_option(opt, value)
- case opt
- when '--describe'
- options.show_tasks = true
- options.show_task_pattern = Regexp.new(value || '.')
- options.full_description = true
- when '--dry-run'
- verbose(true)
- nowrite(true)
- options.dryrun = true
- options.trace = true
- when '--help'
- help
- exit
- when '--libdir'
- $:.push(value)
- when '--nosearch'
- options.nosearch = true
- when '--prereqs'
- options.show_prereqs = true
- when '--quiet'
- verbose(false)
- when '--rakefile'
- @rakefiles.clear
- @rakefiles << value
- when '--rakelibdir'
- options.rakelib = value.split(':')
- when '--require'
- begin
- require value
- rescue LoadError => ex
- begin
- rake_require value
- rescue LoadError => ex2
- raise ex
- end
- end
- when '--silent'
- verbose(false)
- options.silent = true
- when '--tasks'
- options.show_tasks = true
- options.show_task_pattern = Regexp.new(value || '.')
- options.full_description = false
- when '--trace'
- options.trace = true
- verbose(true)
- when '--verbose'
- verbose(true)
- when '--version'
- puts "rake, version #{RAKEVERSION}"
- exit
- when '--classic-namespace'
- require 'rake/classic_namespace'
- options.classic_namespace = true
- end
- end
-
- # Read and handle the command line options.
- def handle_options
- options.rakelib = ['rakelib']
-
- opts = GetoptLong.new(*command_line_options)
- opts.each { |opt, value| do_option(opt, value) }
-
- # If class namespaces are requested, set the global options
- # according to the values in the options structure.
- if options.classic_namespace
- $show_tasks = options.show_tasks
- $show_prereqs = options.show_prereqs
- $trace = options.trace
- $dryrun = options.dryrun
- $silent = options.silent
- end
- rescue NoMethodError => ex
- raise GetoptLong::InvalidOption, "While parsing options, error = #{ex.class}:#{ex.message}"
- end
-
- # Similar to the regular Ruby +require+ command, but will check
- # for .rake files in addition to .rb files.
- def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
- return false if loaded.include?(file_name)
- paths.each do |path|
- fn = file_name + ".rake"
- full_path = File.join(path, fn)
- if File.exist?(full_path)
- load full_path
- loaded << fn
- return true
- end
- end
- fail LoadError, "Can't find #{file_name}"
- end
-
- def raw_load_rakefile # :nodoc:
- here = Dir.pwd
- while ! have_rakefile
- Dir.chdir("..")
- if Dir.pwd == here || options.nosearch
- fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
- end
- here = Dir.pwd
- end
- puts "(in #{Dir.pwd})" unless options.silent
- $rakefile = @rakefile
- load File.expand_path(@rakefile) if @rakefile != ''
- options.rakelib.each do |rlib|
- Dir["#{rlib}/*.rake"].each do |name| add_import name end
- end
- load_imports
- end
-
- # Collect the list of tasks on the command line. If no tasks are
- # given, return a list containing only the default task.
- # Environmental assignments are processed at this time as well.
- def collect_tasks
- @top_level_tasks = []
- ARGV.each do |arg|
- if arg =~ /^(\w+)=(.*)$/
- ENV[$1] = $2
- else
- @top_level_tasks << arg
- end
- end
- @top_level_tasks.push("default") if @top_level_tasks.size == 0
- end
-
- # Add a file to the list of files to be imported.
- def add_import(fn)
- @pending_imports << fn
- end
-
- # Load the pending list of imported files.
- def load_imports
- while fn = @pending_imports.shift
- next if @imported.member?(fn)
- if fn_task = lookup(fn)
- fn_task.invoke
- end
- ext = File.extname(fn)
- loader = @loaders[ext] || @default_loader
- loader.load(fn)
- @imported << fn
- end
- end
-
- # Warn about deprecated use of top level constant names.
- def const_warning(const_name)
- @const_warning ||= false
- if ! @const_warning
- $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } +
- %{found at: #{rakefile_location}} # '
- $stderr.puts %{ Use --classic-namespace on rake command}
- $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile}
- end
- @const_warning = true
- end
-
- def rakefile_location
- begin
- fail
- rescue RuntimeError => ex
- ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
- end
- end
- end
-end
-
-
-class Module
- # Rename the original handler to make it available.
- alias :rake_original_const_missing :const_missing
-
- # Check for deprecated uses of top level (i.e. in Object) uses of
- # Rake class names. If someone tries to reference the constant
- # name, display a warning and return the proper object. Using the
- # --classic-namespace command line option will define these
- # constants in Object and avoid this handler.
- def const_missing(const_name)
- case const_name
- when :Task
- Rake.application.const_warning(const_name)
- Rake::Task
- when :FileTask
- Rake.application.const_warning(const_name)
- Rake::FileTask
- when :FileCreationTask
- Rake.application.const_warning(const_name)
- Rake::FileCreationTask
- when :RakeApp
- Rake.application.const_warning(const_name)
- Rake::Application
- else
- rake_original_const_missing(const_name)
- end
- end
-end
diff --git a/lib/rake/classic_namespace.rb b/lib/rake/classic_namespace.rb
deleted file mode 100644
index feb7569966..0000000000
--- a/lib/rake/classic_namespace.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# The following classes used to be in the top level namespace.
-# Loading this file enables compatibility with older Rakefile that
-# referenced Task from the top level.
-
-Task = Rake::Task
-FileTask = Rake::FileTask
-FileCreationTask = Rake::FileCreationTask
-RakeApp = Rake::Application
diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb
deleted file mode 100644
index 4ee2c5ac95..0000000000
--- a/lib/rake/clean.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env ruby
-
-# The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
-# two rake tasks (:clean and :clobber).
-#
-# [:clean] Clean up the project by deleting scratch files and backup
-# files. Add files to the CLEAN file list to have the :clean
-# target handle them.
-#
-# [:clobber] Clobber all generated and non-source files in a project.
-# The task depends on :clean, so all the clean files will
-# be deleted as well as files in the CLOBBER file list.
-# The intent of this task is to return a project to its
-# pristine, just unpacked state.
-
-require 'rake'
-
-CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
-CLEAN.clear_exclude.exclude { |fn|
- fn.pathmap("%f") == 'core' && File.directory?(fn)
-}
-
-desc "Remove any temporary products."
-task :clean do
- CLEAN.each { |fn| rm_r fn rescue nil }
-end
-
-CLOBBER = Rake::FileList.new
-
-desc "Remove any generated file."
-task :clobber => [:clean] do
- CLOBBER.each { |fn| rm_r fn rescue nil }
-end
diff --git a/lib/rake/gempackagetask.rb b/lib/rake/gempackagetask.rb
deleted file mode 100644
index a4e5cd1907..0000000000
--- a/lib/rake/gempackagetask.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env ruby
-
-# Define a package task library to aid in the definition of GEM
-# packages.
-
-require 'rubygems'
-require 'rake'
-require 'rake/packagetask'
-require 'rubygems/user_interaction'
-require 'rubygems/builder'
-
-begin
- Gem.manage_gems
-rescue NoMethodError => ex
- # Using rubygems prior to 0.6.1
-end
-
-module Rake
-
- # Create a package based upon a Gem spec. Gem packages, as well as
- # zip files and tar/gzipped packages can be produced by this task.
- #
- # In addition to the Rake targets generated by PackageTask, a
- # GemPackageTask will also generate the following tasks:
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
- # Create a Ruby GEM package with the given name and version.
- #
- # Example using a Ruby GEM spec:
- #
- # require 'rubygems'
- #
- # spec = Gem::Specification.new do |s|
- # s.platform = Gem::Platform::RUBY
- # s.summary = "Ruby based make-like utility."
- # s.name = 'rake'
- # s.version = PKG_VERSION
- # s.requirements << 'none'
- # s.require_path = 'lib'
- # s.autorequire = 'rake'
- # s.files = PKG_FILES
- # s.description = <<EOF
- # Rake is a Make-like program implemented in Ruby. Tasks
- # and dependencies are specified in standard Ruby syntax.
- # EOF
- # end
- #
- # Rake::GemPackageTask.new(spec) do |pkg|
- # pkg.need_zip = true
- # pkg.need_tar = true
- # end
- #
- class GemPackageTask < PackageTask
- # Ruby GEM spec containing the metadata for this package. The
- # name, version and package_files are automatically determined
- # from the GEM spec and don't need to be explicitly provided.
- attr_accessor :gem_spec
-
- # Create a GEM Package task library. Automatically define the gem
- # if a block is given. If no block is supplied, then +define+
- # needs to be called to define the task.
- def initialize(gem_spec)
- init(gem_spec)
- yield self if block_given?
- define if block_given?
- end
-
- # Initialization tasks without the "yield self" or define
- # operations.
- def init(gem)
- super(gem.name, gem.version)
- @gem_spec = gem
- @package_files += gem_spec.files if gem_spec.files
- end
-
- # Create the Rake tasks and actions specified by this
- # GemPackageTask. (+define+ is automatically called if a block is
- # given to +new+).
- def define
- super
- task :package => [:gem]
- desc "Build the gem file #{gem_file}"
- task :gem => ["#{package_dir}/#{gem_file}"]
- file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
- when_writing("Creating GEM") {
- Gem::Builder.new(gem_spec).build
- verbose(true) {
- mv gem_file, "#{package_dir}/#{gem_file}"
- }
- }
- end
- end
-
- def gem_file
- if @gem_spec.platform == Gem::Platform::RUBY
- "#{package_name}.gem"
- else
- "#{package_name}-#{@gem_spec.platform}.gem"
- end
- end
-
- end
-end
diff --git a/lib/rake/loaders/makefile.rb b/lib/rake/loaders/makefile.rb
deleted file mode 100644
index f66eb3b35f..0000000000
--- a/lib/rake/loaders/makefile.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env ruby
-
-module Rake
-
- # Makefile loader to be used with the import file loader.
- class MakefileLoader
-
- # Load the makefile dependencies in +fn+.
- def load(fn)
- buffer = ''
- open(fn) do |mf|
- mf.each do |line|
- next if line =~ /^\s*#/
- buffer << line
- if buffer =~ /\\$/
- buffer.sub!(/\\\n/, ' ')
- state = :append
- else
- process_line(buffer)
- buffer = ''
- end
- end
- end
- process_line(buffer) if buffer != ''
- end
-
- private
-
- # Process one logical line of makefile data.
- def process_line(line)
- file_task, args = line.split(':')
- return if args.nil?
- dependents = args.split
- file file_task => dependents
- end
- end
-
- # Install the handler
- Rake.application.add_loader('mf', MakefileLoader.new)
-end
diff --git a/lib/rake/packagetask.rb b/lib/rake/packagetask.rb
deleted file mode 100644
index 71b66a6481..0000000000
--- a/lib/rake/packagetask.rb
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/env ruby
-
-# Define a package task libarary to aid in the definition of
-# redistributable package files.
-
-require 'rake'
-require 'rake/tasklib'
-
-module Rake
-
- # Create a packaging task that will package the project into
- # distributable files (e.g zip archive or tar files).
- #
- # The PackageTask will create the following targets:
- #
- # [<b>:package</b>]
- # Create all the requested package files.
- #
- # [<b>:clobber_package</b>]
- # Delete all the package files. This target is automatically
- # added to the main clobber target.
- #
- # [<b>:repackage</b>]
- # Rebuild the package files from scratch, even if they are not out
- # of date.
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tgz"</b>]
- # Create a gzipped tar package (if <em>need_tar</em> is true).
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.gz"</b>]
- # Create a gzipped tar package (if <em>need_tar_gz</em> is true).
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.tar.bz2"</b>]
- # Create a bzip2'd tar package (if <em>need_tar_bz2</em> is true).
- #
- # [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.zip"</b>]
- # Create a zip package archive (if <em>need_zip</em> is true).
- #
- # Example:
- #
- # Rake::PackageTask.new("rake", "1.2.3") do |p|
- # p.need_tar = true
- # p.package_files.include("lib/**/*.rb")
- # end
- #
- class PackageTask < TaskLib
- # Name of the package (from the GEM Spec).
- attr_accessor :name
-
- # Version of the package (e.g. '1.3.2').
- attr_accessor :version
-
- # Directory used to store the package files (default is 'pkg').
- attr_accessor :package_dir
-
- # True if a gzipped tar file (tgz) should be produced (default is false).
- attr_accessor :need_tar
-
- # True if a gzipped tar file (tar.gz) should be produced (default is false).
- attr_accessor :need_tar_gz
-
- # True if a bzip2'd tar file (tar.bz2) should be produced (default is false).
- attr_accessor :need_tar_bz2
-
- # True if a zip file should be produced (default is false)
- attr_accessor :need_zip
-
- # List of files to be included in the package.
- attr_accessor :package_files
-
- # Tar command for gzipped or bzip2ed archives. The default is 'tar'.
- attr_accessor :tar_command
-
- # Zip command for zipped archives. The default is 'zip'.
- attr_accessor :zip_command
-
- # Create a Package Task with the given name and version.
- def initialize(name=nil, version=nil)
- init(name, version)
- yield self if block_given?
- define unless name.nil?
- end
-
- # Initialization that bypasses the "yield self" and "define" step.
- def init(name, version)
- @name = name
- @version = version
- @package_files = Rake::FileList.new
- @package_dir = 'pkg'
- @need_tar = false
- @need_tar_gz = false
- @need_tar_bz2 = false
- @need_zip = false
- @tar_command = 'tar'
- @zip_command = 'zip'
- end
-
- # Create the tasks defined by this task library.
- def define
- fail "Version required (or :noversion)" if @version.nil?
- @version = nil if :noversion == @version
-
- desc "Build all the packages"
- task :package
-
- desc "Force a rebuild of the package files"
- task :repackage => [:clobber_package, :package]
-
- desc "Remove package products"
- task :clobber_package do
- rm_r package_dir rescue nil
- end
-
- task :clobber => [:clobber_package]
-
- [
- [need_tar, tgz_file, "z"],
- [need_tar_gz, tar_gz_file, "z"],
- [need_tar_bz2, tar_bz2_file, "j"]
- ].each do |(need, file, flag)|
- if need
- task :package => ["#{package_dir}/#{file}"]
- file "#{package_dir}/#{file}" => [package_dir_path] + package_files do
- chdir(package_dir) do
- sh %{#{@tar_command} #{flag}cvf #{file} #{package_name}}
- end
- end
- end
- end
-
- if need_zip
- task :package => ["#{package_dir}/#{zip_file}"]
- file "#{package_dir}/#{zip_file}" => [package_dir_path] + package_files do
- chdir(package_dir) do
- sh %{#{@zip_command} -r #{zip_file} #{package_name}}
- end
- end
- end
-
- directory package_dir
-
- file package_dir_path => @package_files do
- mkdir_p package_dir rescue nil
- @package_files.each do |fn|
- f = File.join(package_dir_path, fn)
- fdir = File.dirname(f)
- mkdir_p(fdir) if !File.exist?(fdir)
- if File.directory?(fn)
- mkdir_p(f)
- else
- rm_f f
- safe_ln(fn, f)
- end
- end
- end
- self
- end
-
- def package_name
- @version ? "#{@name}-#{@version}" : @name
- end
-
- def package_dir_path
- "#{package_dir}/#{package_name}"
- end
-
- def tgz_file
- "#{package_name}.tgz"
- end
-
- def tar_gz_file
- "#{package_name}.tar.gz"
- end
-
- def tar_bz2_file
- "#{package_name}.tar.bz2"
- end
-
- def zip_file
- "#{package_name}.zip"
- end
- end
-
-end
diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb
deleted file mode 100644
index 8d7dad3c94..0000000000
--- a/lib/rake/rake_test_loader.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env ruby
-
-# Load the test files from the command line.
-
-ARGV.each { |f| load f unless f =~ /^-/ }
diff --git a/lib/rake/rdoctask.rb b/lib/rake/rdoctask.rb
deleted file mode 100644
index 54adc6feb5..0000000000
--- a/lib/rake/rdoctask.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'rake'
-require 'rake/tasklib'
-
-module Rake
-
- # Create a documentation task that will generate the RDoc files for
- # a project.
- #
- # The RDocTask will create the following targets:
- #
- # [<b><em>rdoc</em></b>]
- # Main task for this RDOC task.
- #
- # [<b>:clobber_<em>rdoc</em></b>]
- # Delete all the rdoc files. This target is automatically
- # added to the main clobber target.
- #
- # [<b>:re<em>rdoc</em></b>]
- # Rebuild the rdoc files from scratch, even if they are not out
- # of date.
- #
- # Simple Example:
- #
- # Rake::RDocTask.new do |rd|
- # rd.main = "README.rdoc"
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
- # end
- #
- # You may wish to give the task a different name, such as if you are
- # generating two sets of documentation. For instance, if you want to have a
- # development set of documentation including private methods:
- #
- # Rake::RDocTask.new(:rdoc_dev) do |rd|
- # rd.main = "README.doc"
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
- # rd.options << "--all"
- # end
- #
- # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
- # :re<em>rdoc_dev</em>.
- #
- class RDocTask < TaskLib
- # Name of the main, top level task. (default is :rdoc)
- attr_accessor :name
-
- # Name of directory to receive the html output files. (default is "html")
- attr_accessor :rdoc_dir
-
- # Title of RDoc documentation. (default is none)
- attr_accessor :title
-
- # Name of file to be used as the main, top level file of the
- # RDoc. (default is none)
- attr_accessor :main
-
- # Name of template to be used by rdoc. (default is 'html')
- attr_accessor :template
-
- # List of files to be included in the rdoc generation. (default is [])
- attr_accessor :rdoc_files
-
- # List of options to be passed rdoc. (default is [])
- attr_accessor :options
-
- # Run the rdoc process as an external shell (default is false)
- attr_accessor :external
-
- # Create an RDoc task named <em>rdoc</em>. Default task name is +rdoc+.
- def initialize(name=:rdoc) # :yield: self
- @name = name
- @rdoc_files = Rake::FileList.new
- @rdoc_dir = 'html'
- @main = nil
- @title = nil
- @template = 'html'
- @external = false
- @options = []
- yield self if block_given?
- define
- end
-
- # Create the tasks defined by this task lib.
- def define
- if name.to_s != "rdoc"
- desc "Build the RDOC HTML Files"
- end
-
- desc "Build the #{name} HTML Files"
- task name
-
- desc "Force a rebuild of the RDOC files"
- task paste("re", name) => [paste("clobber_", name), name]
-
- desc "Remove rdoc products"
- task paste("clobber_", name) do
- rm_r rdoc_dir rescue nil
- end
-
- task :clobber => [paste("clobber_", name)]
-
- directory @rdoc_dir
- task name => [rdoc_target]
- file rdoc_target => @rdoc_files + [$rakefile] do
- rm_r @rdoc_dir rescue nil
- args = option_list + @rdoc_files
- if @external
- argstring = args.join(' ')
- sh %{ruby -Ivendor vender/rd #{argstring}}
- else
- require 'rdoc/rdoc'
- RDoc::RDoc.new.document(args)
- end
- end
- self
- end
-
- def option_list
- result = @options.dup
- result << "-o" << @rdoc_dir
- result << "--main" << quote(main) if main
- result << "--title" << quote(title) if title
- result << "-T" << quote(template) if template
- result
- end
-
- def quote(str)
- if @external
- "'#{str}'"
- else
- str
- end
- end
-
- def option_string
- option_list.join(' ')
- end
-
- private
-
- def rdoc_target
- "#{rdoc_dir}/index.html"
- end
-
- end
-end
diff --git a/lib/rake/ruby182_test_unit_fix.rb b/lib/rake/ruby182_test_unit_fix.rb
deleted file mode 100755
index f02c7879eb..0000000000
--- a/lib/rake/ruby182_test_unit_fix.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-module Test
- module Unit
- module Collector
- class Dir
- undef collect_file
- def collect_file(name, suites, already_gathered)
- # loadpath = $:.dup
- dir = File.dirname(File.expand_path(name))
- $:.unshift(dir) unless $:.first == dir
- if(@req)
- @req.require(name)
- else
- require(name)
- end
- find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
- ensure
- # $:.replace(loadpath)
- $:.delete_at $:.rindex(dir)
- end
- end
- end
- end
-end
diff --git a/lib/rake/runtest.rb b/lib/rake/runtest.rb
deleted file mode 100644
index 3f1d205201..0000000000
--- a/lib/rake/runtest.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'test/unit/assertions'
-
-module Rake
- include Test::Unit::Assertions
-
- def run_tests(pattern='test/test*.rb', log_enabled=false)
- Dir["#{pattern}"].each { |fn|
- puts fn if log_enabled
- begin
- load fn
- rescue Exception => ex
- puts "Error in #{fn}: #{ex.message}"
- puts ex.backtrace
- assert false
- end
- }
- end
-
- extend self
-end
diff --git a/lib/rake/tasklib.rb b/lib/rake/tasklib.rb
deleted file mode 100644
index 465a58a0c7..0000000000
--- a/lib/rake/tasklib.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'rake'
-
-module Rake
-
- # Base class for Task Libraries.
- class TaskLib
-
- include Cloneable
-
- # Make a symbol by pasting two strings together.
- def paste(a,b)
- (a.to_s + b.to_s).intern
- end
- end
-
-end
diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb
deleted file mode 100644
index 79154e422b..0000000000
--- a/lib/rake/testtask.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/env ruby
-
-# Define a task library for running unit tests.
-
-require 'rake'
-require 'rake/tasklib'
-
-module Rake
-
- # Create a task that runs a set of tests.
- #
- # Example:
- #
- # Rake::TestTask.new do |t|
- # t.libs << "test"
- # t.test_files = FileList['test/test*.rb']
- # t.verbose = true
- # end
- #
- # If rake is invoked with a "TEST=filename" command line option,
- # then the list of test files will be overridden to include only the
- # filename specified on the command line. This provides an easy way
- # to run just one test.
- #
- # If rake is invoked with a "TESTOPTS=options" command line option,
- # then the given options are passed to the test process after a
- # '--'. This allows Test::Unit options to be passed to the test
- # suite.
- #
- # Examples:
- #
- # rake test # run tests normally
- # rake test TEST=just_one_file.rb # run just one test file.
- # rake test TESTOPTS="-v" # run in verbose mode
- # rake test TESTOPTS="--runner=fox" # use the fox test runner
- #
- class TestTask < TaskLib
-
- # Name of test task. (default is :test)
- attr_accessor :name
-
- # List of directories to added to $LOAD_PATH before running the
- # tests. (default is 'lib')
- attr_accessor :libs
-
- # True if verbose test output desired. (default is false)
- attr_accessor :verbose
-
- # Test options passed to the test suite. An explicit
- # TESTOPTS=opts on the command line will override this. (default
- # is NONE)
- attr_accessor :options
-
- # Request that the tests be run with the warning flag set.
- # E.g. warning=true implies "ruby -w" used to run the tests.
- attr_accessor :warning
-
- # Glob pattern to match test files. (default is 'test/test*.rb')
- attr_accessor :pattern
-
- # Style of test loader to use. Options are:
- #
- # * :rake -- Rake provided test loading script (default).
- # * :testrb -- Ruby provided test loading script.
- # * :direct -- Load tests using command line loader.
- #
- attr_accessor :loader
-
- # Array of commandline options to pass to ruby when running test loader.
- attr_accessor :ruby_opts
-
- # Explicitly define the list of test files to be included in a
- # test. +list+ is expected to be an array of file names (a
- # FileList is acceptable). If both +pattern+ and +test_files+ are
- # used, then the list of test files is the union of the two.
- def test_files=(list)
- @test_files = list
- end
-
- # Create a testing task.
- def initialize(name=:test)
- @name = name
- @libs = ["lib"]
- @pattern = nil
- @options = nil
- @test_files = nil
- @verbose = false
- @warning = false
- @loader = :rake
- @ruby_opts = []
- yield self if block_given?
- @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
- define
- end
-
- # Create the tasks defined by this task lib.
- def define
- lib_path = @libs.join(File::PATH_SEPARATOR)
- desc "Run tests" + (@name==:test ? "" : " for #{@name}")
- task @name do
- run_code = ''
- RakeFileUtils.verbose(@verbose) do
- run_code =
- case @loader
- when :direct
- "-e 'ARGV.each{|f| load f}'"
- when :testrb
- "-S testrb #{fix}"
- when :rake
- rake_loader
- end
- @ruby_opts.unshift( "-I#{lib_path}" )
- @ruby_opts.unshift( "-w" ) if @warning
- ruby @ruby_opts.join(" ") +
- " \"#{run_code}\" " +
- file_list.collect { |fn| "\"#{fn}\"" }.join(' ') +
- " #{option_list}"
- end
- end
- self
- end
-
- def option_list # :nodoc:
- ENV['TESTOPTS'] || @options || ""
- end
-
- def file_list # :nodoc:
- if ENV['TEST']
- FileList[ ENV['TEST'] ]
- else
- result = []
- result += @test_files.to_a if @test_files
- result += FileList[ @pattern ].to_a if @pattern
- FileList[result]
- end
- end
-
- def fix # :nodoc:
- case RUBY_VERSION
- when '1.8.2'
- find_file 'rake/ruby182_test_unit_fix'
- else
- nil
- end || ''
- end
-
- def rake_loader # :nodoc:
- find_file('rake/rake_test_loader') or
- fail "unable to find rake test loader"
- end
-
- def find_file(fn) # :nodoc:
- $LOAD_PATH.each do |path|
- file_path = File.join(path, "#{fn}.rb")
- return file_path if File.exist? file_path
- end
- nil
- end
-
- end
-end
diff --git a/lib/rational.rb b/lib/rational.rb
index 73e8cef8e9..69a3b76bf1 100644
--- a/lib/rational.rb
+++ b/lib/rational.rb
@@ -17,6 +17,7 @@
# See Rational for full documentation.
#
+
#
# Creates a Rational number (i.e. a fraction). +a+ and +b+ should be Integers:
#
@@ -239,6 +240,10 @@ class Rational < Numeric
end
end
+ def div(other)
+ (self / other).floor
+ end
+
#
# Returns the remainder when this value is divided by +other+.
#
@@ -250,7 +255,7 @@ class Rational < Numeric
# r % 0.26 # -> 0.19
#
def % (other)
- value = (self / other).to_i
+ value = (self / other).floor
return self - other * value
end
@@ -262,7 +267,7 @@ class Rational < Numeric
# r.divmod Rational(1,2) # -> [3, Rational(1,4)]
#
def divmod(other)
- value = (self / other).to_i
+ value = (self / other).floor
return value, self - other * value
end
@@ -271,7 +276,7 @@ class Rational < Numeric
#
def abs
if @numerator > 0
- Rational.new!(@numerator, @denominator)
+ self
else
Rational.new!(-@numerator, @denominator)
end
@@ -339,22 +344,50 @@ class Rational < Numeric
# Converts the rational to an Integer. Not the _nearest_ integer, the
# truncated integer. Study the following example carefully:
# Rational(+7,4).to_i # -> 1
- # Rational(-7,4).to_i # -> -2
+ # Rational(-7,4).to_i # -> -1
# (-1.75).to_i # -> -1
#
# In other words:
# Rational(-7,4) == -1.75 # -> true
- # Rational(-7,4).to_i == (-1.75).to_i # false
+ # Rational(-7,4).to_i == (-1.75).to_i # -> true
#
- def to_i
- Integer(@numerator.div(@denominator))
+
+
+ def floor()
+ @numerator.div(@denominator)
+ end
+
+ def ceil()
+ -((-@numerator).div(@denominator))
+ end
+
+ def truncate()
+ if @numerator < 0
+ return -((-@numerator).div(@denominator))
+ end
+ @numerator.div(@denominator)
+ end
+
+ alias_method :to_i, :truncate
+
+ def round()
+ if @numerator < 0
+ num = -@numerator
+ num = num * 2 + @denominator
+ den = @denominator * 2
+ -(num.div(den))
+ else
+ num = @numerator * 2 + @denominator
+ den = @denominator * 2
+ num.div(den)
+ end
end
#
# Converts the rational to a Float.
#
def to_f
- @numerator.quof(@denominator)
+ @numerator.to_f/@denominator.to_f
end
#
@@ -445,6 +478,10 @@ class Integer
max
end
+ #
+ # Returns the <em>lowest common multiple</em> (LCM) of the two arguments
+ # (+self+ and +other+).
+ #
# Examples:
# 6.lcm 7 # -> 42
# 6.lcm 9 # -> 18
@@ -456,7 +493,7 @@ class Integer
(self.div(self.gcd(other)) * other).abs
end
end
-
+
#
# Returns the GCD _and_ the LCM (see #gcd and #lcm) of the two arguments
# (+self+ and +other+). This is more efficient than calculating them
@@ -476,11 +513,11 @@ class Integer
end
class Fixnum
- alias quof quo
- undef quo
- # If Rational is defined, returns a Rational number instead of a Fixnum.
+ remove_method :quo
+
+ # If Rational is defined, returns a Rational number instead of a Float.
def quo(other)
- Rational.new!(self,1) / other
+ Rational.new!(self, 1) / other
end
alias rdiv quo
@@ -489,26 +526,18 @@ class Fixnum
if other >= 0
self.power!(other)
else
- Rational.new!(self,1)**other
+ Rational.new!(self, 1)**other
end
end
- unless defined? 1.power!
- alias power! **
- alias ** rpower
- end
end
class Bignum
- unless defined? Complex
- alias power! **
- end
+ remove_method :quo
- alias quof quo
- undef quo
- # If Rational is defined, returns a Rational number instead of a Bignum.
+ # If Rational is defined, returns a Rational number instead of a Float.
def quo(other)
- Rational.new!(self,1) / other
+ Rational.new!(self, 1) / other
end
alias rdiv quo
@@ -521,7 +550,15 @@ class Bignum
end
end
- unless defined? Complex
+end
+
+unless defined? 1.power!
+ class Fixnum
+ alias power! **
+ alias ** rpower
+ end
+ class Bignum
+ alias power! **
alias ** rpower
end
end
diff --git a/lib/rbconfig/datadir.rb b/lib/rbconfig/datadir.rb
deleted file mode 100644
index 5b8f07754a..0000000000
--- a/lib/rbconfig/datadir.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-
-module Config
-
- # Only define datadir if it doesn't already exist.
- unless Config.respond_to?(:datadir)
-
- # Return the path to the data directory associated with the given
- # package name. Normally this is just
- # "#{Config::CONFIG['datadir']}/#{package_name}", but may be
- # modified by packages like RubyGems to handle versioned data
- # directories.
- def Config.datadir(package_name)
- File.join(CONFIG['datadir'], package_name)
- end
-
- end
-end
diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb
index d75670de72..d6c4f1bdb9 100644
--- a/lib/rdoc/code_objects.rb
+++ b/lib/rdoc/code_objects.rb
@@ -126,7 +126,6 @@ module RDoc
@title = title
@@sequence.succ!
@sequence = @@sequence.dup
- @comment = nil
set_comment(comment)
end
@@ -236,7 +235,7 @@ module RDoc
end
def add_method(a_method)
- puts "Adding #@visibility method #{a_method.name} to #@name" if $DEBUG_RDOC
+ puts "Adding #@visibility method #{a_method.name} to #@name" if $DEBUG
a_method.visibility = @visibility
add_to(@method_list, a_method)
end
@@ -280,10 +279,10 @@ module RDoc
def add_class_or_module(collection, class_type, name, superclass=nil)
cls = collection[name]
if cls
- puts "Reusing class/module #{name}" if $DEBUG_RDOC
+ puts "Reusing class/module #{name}" if $DEBUG
else
cls = class_type.new(name, superclass)
- puts "Adding class/module #{name} to #@name" if $DEBUG_RDOC
+ puts "Adding class/module #{name} to #@name" if $DEBUG
# collection[name] = cls if @document_self && !@done_documenting
collection[name] = cls if !@done_documenting
cls.parent = self
@@ -386,8 +385,8 @@ module RDoc
module_name = modules.shift
result = find_module_named(module_name)
if result
- modules.each do |name|
- result = result.find_module_named(name)
+ modules.each do |module_name|
+ result = result.find_module_named(module_name)
break unless result
end
end
@@ -497,7 +496,7 @@ module RDoc
def add_class_or_module(collection, class_type, name, superclass)
cls = collection[name]
if cls
- puts "Reusing class/module #{name}" if $DEBUG_RDOC
+ puts "Reusing class/module #{name}" if $DEBUG
else
if class_type == NormalModule
all = @@all_modules
@@ -509,7 +508,7 @@ module RDoc
cls = class_type.new(name, superclass)
all[name] = cls unless @done_documenting
end
- puts "Adding class/module #{name} to #@name" if $DEBUG_RDOC
+ puts "Adding class/module #{name} to #@name" if $DEBUG
collection[name] = cls unless @done_documenting
cls.parent = self
end
diff --git a/lib/rdoc/diagram.rb b/lib/rdoc/diagram.rb
index 849d686b4f..9fdc49c02e 100644
--- a/lib/rdoc/diagram.rb
+++ b/lib/rdoc/diagram.rb
@@ -37,7 +37,7 @@ module RDoc
@info = info
@options = options
@counter = 0
- FileUtils.mkdir_p(DOT_PATH)
+ File.makedirs(DOT_PATH)
@diagram_cache = {}
end
@@ -140,8 +140,8 @@ module RDoc
graph << m
unless mod.includes.empty?
- mod.includes.each do |inc|
- m_full_name = find_full_name(inc.name, mod)
+ mod.includes.each do |m|
+ m_full_name = find_full_name(m.name, mod)
if @local_names.include?(m_full_name)
@global_graph << DOT::DOTEdge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
'to' => "#{mod.full_name.gsub( /:/,'_' )}",
diff --git a/lib/rdoc/generators/html_generator.rb b/lib/rdoc/generators/html_generator.rb
index 4348703c30..1f9b808e8d 100644
--- a/lib/rdoc/generators/html_generator.rb
+++ b/lib/rdoc/generators/html_generator.rb
@@ -34,7 +34,7 @@
# HTML is generated using the Template class.
#
-require 'fileutils'
+require 'ftools'
require 'rdoc/options'
require 'rdoc/template'
@@ -1025,7 +1025,7 @@ module Generators
def create_source_code_file(code_body)
meth_path = @html_class.path.sub(/\.html$/, '.src')
- FileUtils.mkdir_p(meth_path)
+ File.makedirs(meth_path)
file_path = File.join(meth_path, @seq) + ".html"
template = TemplatePage.new(RDoc::Page::SRC_PAGE)
@@ -1235,8 +1235,7 @@ module Generators
# directory structure
def gen_sub_directories
- FileUtils.mkdir_p(FILE_DIR)
- FileUtils.mkdir_p(CLASS_DIR)
+ File.makedirs(FILE_DIR, CLASS_DIR)
rescue
$stderr.puts $!.message
exit 1
@@ -1290,7 +1289,7 @@ module Generators
list.each do |item|
if item.document_self
op_file = item.path
- FileUtils.mkdir_p(File.dirname(op_file))
+ File.makedirs(File.dirname(op_file))
File.open(op_file, "w") { |file| item.write_on(file) }
end
end
diff --git a/lib/rdoc/generators/ri_generator.rb b/lib/rdoc/generators/ri_generator.rb
index bf22bc8dba..c7d0bbd8f0 100644
--- a/lib/rdoc/generators/ri_generator.rb
+++ b/lib/rdoc/generators/ri_generator.rb
@@ -34,6 +34,8 @@
# HTML is generated using the Template class.
#
+require 'ftools'
+
require 'rdoc/options'
require 'rdoc/template'
require 'rdoc/markup/simple_markup'
diff --git a/lib/rdoc/generators/xml_generator.rb b/lib/rdoc/generators/xml_generator.rb
index 561a9ad694..8c1a76d62b 100644
--- a/lib/rdoc/generators/xml_generator.rb
+++ b/lib/rdoc/generators/xml_generator.rb
@@ -1,4 +1,6 @@
+require 'ftools'
+
require 'rdoc/options'
require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'
diff --git a/lib/rdoc/markup/simple_markup/inline.rb b/lib/rdoc/markup/simple_markup/inline.rb
index 120d347be6..d54fe1e667 100644
--- a/lib/rdoc/markup/simple_markup/inline.rb
+++ b/lib/rdoc/markup/simple_markup/inline.rb
@@ -246,17 +246,17 @@ module SM
def flow(str)
@str = str
- puts("Before flow, str='#{@str.dump}'") if $DEBUG_RDOC
+ puts("Before flow, str='#{@str.dump}'") if $DEBUG
mask_protected_sequences
@attrs = AttrSpan.new(@str.length)
- puts("After protecting, str='#{@str.dump}'") if $DEBUG_RDOC
+ puts("After protecting, str='#{@str.dump}'") if $DEBUG
convert_attrs(@str, @attrs)
convert_html(@str, @attrs)
convert_specials(str, @attrs)
unmask_protected_sequences
- puts("After flow, str='#{@str.dump}'") if $DEBUG_RDOC
+ puts("After flow, str='#{@str.dump}'") if $DEBUG
return split_into_flow
end
@@ -284,7 +284,7 @@ module SM
def split_into_flow
- display_attributes if $DEBUG_RDOC
+ display_attributes if $DEBUG
res = []
current_attr = 0
@@ -295,7 +295,7 @@ module SM
# skip leading invisible text
i = 0
- i += 1 while i < str_len and @str[i] == "\0"
+ i += 1 while i < str_len and @str[i].zero?
start_pos = i
# then scan the string, chunking it on attribute changes
@@ -321,7 +321,7 @@ module SM
# move on, skipping any invisible characters
begin
i += 1
- end while i < str_len and @str[i] == "\0"
+ end while i < str_len and @str[i].zero?
end
# tidy up trailing text
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 259fef487b..7e35abdb0b 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -375,7 +375,14 @@ class Options
@css = nil
@webcvs = nil
- @charset = 'iso-8859-1'
+ @charset = case $KCODE
+ when /^S/i
+ 'Shift_JIS'
+ when /^E/i
+ 'EUC-JP'
+ else
+ 'iso-8859-1'
+ end
accessors = []
@@ -386,7 +393,7 @@ class Options
case opt
when "--all" then @show_all = true
when "--charset" then @charset = arg
- when "--debug" then $DEBUG_RDOC = true
+ when "--debug" then $DEBUG = true
when "--exclude" then @exclude << Regexp.new(arg)
when "--inline-source" then @inline_source = true
when "--line-numbers" then @include_line_numbers = true
@@ -537,7 +544,7 @@ class Options
# so we'll bypass the test under Windows
def check_diagram
- return if RUBY_PLATFORM =~ /win/
+ return if RUBY_PLATFORM =~ /mswin|cygwin|mingw|bccwin/
ok = false
ver = nil
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
index 98f4b3f02e..7eefa29706 100644
--- a/lib/rdoc/parsers/parse_c.rb
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -117,10 +117,10 @@ module RDoc
# method in the HTML output. This method must be in the same source file
# as the rb_define_method.
#
- # C classes can be diagramed (see /tc/dl/ruby/ruby/error.c), and RDoc
+ # C classes can be diagrammed (see /tc/dl/ruby/ruby/error.c), and RDoc
# integrates C and Ruby source into one tree
#
- # The comment blocks may include special direcives:
+ # The comment blocks may include special directives:
#
# [Document-class: <i>name</i>]
# This comment block is documentation for the given class. Use this
@@ -131,10 +131,10 @@ module RDoc
# automatically find the method from it's declaration
#
# [call-seq: <i>text up to an empty line</i>]
- # Because C source doesn't give descripive names to Ruby-level parameters,
+ # Because C source doesn't give descriptive names to Ruby-level parameters,
# you need to document the calling sequence explicitly
#
- # In additon, RDoc assumes by default that the C method implementing a
+ # In addition, RDoc assumes by default that the C method implementing a
# Ruby function is in the same source file as the rb_define_method call.
# If this isn't the case, add the comment
#
@@ -166,12 +166,11 @@ module RDoc
class C_Parser
- attr_writer :progress
+ attr_accessor :progress
extend ParserFactory
parse_files_matching(/\.(?:([CcHh])\1?|c([+xp])\2|y)\z/)
- @@enclosure_classes = {}
@@known_bodies = {}
# prepare to parse a C file
@@ -234,7 +233,7 @@ module RDoc
parent_name = @known_classes[parent] || parent
if in_module
- enclosure = @classes[in_module] || @@enclosure_classes[in_module]
+ enclosure = @classes[in_module]
unless enclosure
if enclosure = @known_classes[in_module]
handle_class_module(in_module, (/^rb_m/ =~ in_module ? "module" : "class"),
@@ -262,7 +261,6 @@ module RDoc
find_class_comment(cm.full_name, cm)
@classes[var_name] = cm
- @@enclosure_classes[var_name] = cm
@known_classes[var_name] = cm.full_name
end
@@ -295,7 +293,7 @@ module RDoc
def find_class_comment(class_name, class_meth)
comment = nil
if @body =~ %r{((?>/\*.*?\*/\s+))
- (static\s+)?void\s+Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)\)}xmi
+ (static\s+)?void\s+Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)}xmi
comment = $1
elsif @body =~ %r{Document-(class|module):\s#{class_name}\s*?\n((?>.*?\*/))}m
comment = $2
@@ -628,7 +626,7 @@ module RDoc
def find_body(meth_name, meth_obj, body, quiet = false)
case body
when %r{((?>/\*.*?\*/\s*))(?:static\s+)?VALUE\s+#{meth_name}
- \s*(\([^)]*\))\s*\{.*?^\}}xm
+ \s*(\(.*?\)).*?^}xm
comment, params = $1, $2
body_text = $&
diff --git a/lib/rdoc/parsers/parse_f95.rb b/lib/rdoc/parsers/parse_f95.rb
index f3f6d76103..f1a1ae4d4b 100644
--- a/lib/rdoc/parsers/parse_f95.rb
+++ b/lib/rdoc/parsers/parse_f95.rb
@@ -201,7 +201,7 @@ module RDoc
@progress = $stderr unless options.quiet
end
- # devine code constructs
+ # define code constructs
def scan
# remove private comment
@@ -1065,7 +1065,7 @@ module RDoc
#
# If "all" argument is true, information of all arguments are returned.
# If "modified_params" is true, list of arguments are decorated,
- # for exameple, optional arguments are parenthetic as "[arg]".
+ # for example, optional arguments are parenthetic as "[arg]".
#
def find_arguments(args, text, all=nil, indent=nil, modified_params=nil)
return unless args || all
@@ -1143,8 +1143,8 @@ EOF
#
# Comments just after module or subprogram, or arguments are
- # returnd. If "COMMENTS_ARE_UPPER" is true, comments just before
- # modules or subprograms are returnd
+ # returned. If "COMMENTS_ARE_UPPER" is true, comments just before
+ # modules or subprograms are returned
#
def find_comments text
return "" unless text
diff --git a/lib/rdoc/parsers/parse_rb.rb b/lib/rdoc/parsers/parse_rb.rb
index 04fac7dcd7..750c483c15 100644
--- a/lib/rdoc/parsers/parse_rb.rb
+++ b/lib/rdoc/parsers/parse_rb.rb
@@ -23,7 +23,7 @@ require "rdoc/markup/simple_markup/preprocess"
require "rdoc/parsers/parserfactory"
-$TOKEN_DEBUG = $DEBUG_RDOC
+$TOKEN_DEBUG = $DEBUG
# Definitions of all tokens involved in the lexical analysis
@@ -38,7 +38,7 @@ module RubyToken
class Token
NO_TEXT = "??".freeze
- attr_accessor :text
+ attr :text
def initialize(line_no, char_no)
@line_no = line_no
@@ -53,7 +53,7 @@ module RubyToken
self
end
- attr_reader :line_no, :char_no
+ attr_reader :line_no, :char_no, :text
end
class TkNode < Token
@@ -115,7 +115,7 @@ module RubyToken
when String, Symbol
source = token.kind_of?(String) ? TkReading2Token : TkSymbol2Token
if (tk = source[token]).nil?
- fail TkReading2TokenNoKey, token
+ IRB.fail TkReading2TokenNoKey, token
end
tk = Token(tk[0], value)
else
@@ -270,7 +270,7 @@ module RubyToken
def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
token_n = token_n.id2name unless token_n.kind_of?(String)
if RubyToken.const_defined?(token_n)
- fail AlreadyDefinedToken, token_n
+ IRB.fail AlreadyDefinedToken, token_n
end
token_c = Class.new super_token
@@ -279,7 +279,7 @@ module RubyToken
if reading
if TkReading2Token[reading]
- fail TkReading2TokenDuplicateError, token_n, reading
+ IRB.fail TkReading2TokenDuplicateError, token_n, reading
end
if opts.empty?
TkReading2Token[reading] = [token_c]
@@ -466,10 +466,11 @@ class RubyLex
@exception_on_syntax_error = true
end
- attr_accessor :skip_space
- attr_accessor :read_auto_clean_up
- attr_accessor :exception_on_syntax_error
- attr_reader :indent
+ attr :skip_space, true
+ attr :read_auto_clean_up, true
+ attr :exception_on_syntax_error, true
+
+ attr :indent
# io functions
def line_no
@@ -544,7 +545,7 @@ class RubyLex
get_read
end
# throw :eof unless tk
- p tk if $DEBUG_RDOC
+ p tk if $DEBUG
tk
end
@@ -586,7 +587,7 @@ class RubyLex
}
def lex_init()
- @OP = IRB::SLex.new
+ @OP = SLex.new
@OP.def_rules("\0", "\004", "\032") do |chars, io|
Token(TkEND_OF_SCRIPT).set_text(chars)
end
@@ -1127,7 +1128,7 @@ class RubyLex
elsif ch =~ /\W/
lt = "\""
else
- fail SyntaxError, "unknown type of %string ('#{ch}')"
+ RubyLex.fail SyntaxError, "unknown type of %string ('#{ch}')"
end
# if ch !~ /\W/
# ungetc
@@ -1476,12 +1477,8 @@ module RDoc
if tk.kind_of?(TkSYMBEG)
set_token_position(tk.line_no, tk.char_no)
tk1 = get_tk
- if tk1.kind_of?(TkId) || tk1.kind_of?(TkOp) || tk1.kind_of?(TkSTRING)
- if tk1.respond_to?(:name)
- tk = Token(TkSYMBOL).set_text(":" + tk1.name)
- else
- tk = Token(TkSYMBOL).set_text(":" + tk1.text)
- end
+ if tk1.kind_of?(TkId) || tk1.kind_of?(TkOp)
+ tk = Token(TkSYMBOL).set_text(":" + tk1.name)
# remove the identifier we just read (we're about to
# replace it with a symbol)
@token_listeners.each do |obj|
@@ -1549,10 +1546,15 @@ module RDoc
tk = get_tk
while tk.kind_of?(TkCOMMENT)
- if first_line && tk.text[0,2] == "#!"
+ if first_line && /\A#!/ =~ tk.text
+ skip_tkspace
+ tk = get_tk
+ elsif first_line && /\A#\s*-\*-/ =~ tk.text
+ first_line = false
skip_tkspace
tk = get_tk
else
+ first_line = false
res << tk.text << "\n"
tk = get_tk
if tk.kind_of? TkNL
@@ -1560,7 +1562,6 @@ module RDoc
tk = get_tk
end
end
- first_line = false
end
unget_tk(tk)
res
@@ -1666,21 +1667,21 @@ module RDoc
when TkUNTIL, TkWHILE
nest += 1
puts "FOUND #{tk.class} in #{container.name}, nest = #{nest}, " +
- "line #{tk.line_no}" if $DEBUG_RDOC
+ "line #{tk.line_no}" if $DEBUG
skip_optional_do_after_expression
# 'for' is trickier
when TkFOR
nest += 1
puts "FOUND #{tk.class} in #{container.name}, nest = #{nest}, " +
- "line #{tk.line_no}" if $DEBUG_RDOC
+ "line #{tk.line_no}" if $DEBUG
skip_for_variable
skip_optional_do_after_expression
when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN
nest += 1
puts "Found #{tk.class} in #{container.name}, nest = #{nest}, " +
- "line #{tk.line_no}" if $DEBUG_RDOC
+ "line #{tk.line_no}" if $DEBUG
when TkIDENTIFIER
if nest == 1 and current_method.nil?
@@ -1710,8 +1711,8 @@ module RDoc
when TkEND
nest -= 1
- puts "Found 'end' in #{container.name}, nest = #{nest}, line #{tk.line_no}" if $DEBUG_RDOC
- puts "Method = #{current_method.name}" if $DEBUG_RDOC and current_method
+ puts "Found 'end' in #{container.name}, nest = #{nest}, line #{tk.line_no}" if $DEBUG
+ puts "Method = #{current_method.name}" if $DEBUG and current_method
if nest == 0
read_documentation_modifiers(container, CLASS_MODIFIERS)
container.ongoing_visibility = save_visibility
@@ -1846,7 +1847,7 @@ module RDoc
loop do
puts("Param: #{tk}, #{@scanner.continue} " +
- "#{@scanner.lex_state} #{nest}") if $DEBUG_RDOC
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
case tk
when TkSEMICOLON
@@ -1934,8 +1935,9 @@ module RDoc
meth.singleton = true
else
unget_tk dot
- back_tk.reverse_each do |token|
- unget_tk token
+ back_tk.reverse_each do
+ |tk|
+ unget_tk tk
end
name = name_t.name
@@ -2042,7 +2044,7 @@ module RDoc
loop do
puts("Param: #{tk.inspect}, #{@scanner.continue} " +
- "#{@scanner.lex_state} #{nest}") if $DEBUG_RDOC
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
case tk
when TkSEMICOLON
break
@@ -2098,7 +2100,7 @@ module RDoc
loop do
puts("\nWhile: #{tk}, #{@scanner.continue} " +
- "#{@scanner.lex_state} #{nest}") if $DEBUG_RDOC
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
case tk
when TkSEMICOLON
break
@@ -2169,7 +2171,7 @@ module RDoc
loop do
puts("Call param: #{tk}, #{@scanner.continue} " +
- "#{@scanner.lex_state} #{nest}") if $DEBUG_RDOC
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
case tk
when TkSEMICOLON
break
@@ -2251,7 +2253,7 @@ module RDoc
def read_directive(allowed)
tk = get_tk
- puts "directive: #{tk.inspect}" if $DEBUG_RDOC
+ puts "directive: #{tk.inspect}" if $DEBUG
result = nil
if tk.kind_of?(TkCOMMENT)
if tk.text =~ /\s*:?(\w+):\s*(.*)/
@@ -2336,7 +2338,7 @@ module RDoc
when "section"
context.set_current_section(param, comment)
- comment.clear
+ comment.replace("") # 1.8 doesn't support #clear
break
else
warn "Unrecognized directive '#{directive}'"
@@ -2560,7 +2562,7 @@ module RDoc
break
when TkCOMMA
else
- warn("unexpected token: '#{tk2.inspect}'") if $DEBUG_RDOC
+ warn("unexpected token: '#{tk2.inspect}'") if $DEBUG
break
end
end
@@ -2598,7 +2600,7 @@ module RDoc
when TkSTRING
eval @read[-1]
else
- warn("Expected symbol or string, got #{tk.inspect}") if $DEBUG_RDOC
+ warn("Expected symbol or string, got #{tk.inspect}") if $DEBUG
nil
end
end
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index 51038a1652..91f5611196 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -15,7 +15,7 @@ require 'rdoc/options'
require 'rdoc/diagram'
require 'find'
-require 'fileutils'
+require 'ftools'
require 'time'
# We put rdoc stuff in the RDoc module to avoid namespace
@@ -125,7 +125,7 @@ module RDoc
last = (Time.parse(created) unless force rescue nil)
end
else
- FileUtils.mkdir_p(op_dir)
+ File.makedirs(op_dir)
end
last
end
@@ -220,11 +220,6 @@ module RDoc
$stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
content = File.open(fn, "r") {|f| f.read}
- if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
- if enc = Encoding.find($1)
- content.force_encoding(enc)
- end
- end
top_level = TopLevel.new(fn)
parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
diff --git a/lib/rdoc/ri/ri_display.rb b/lib/rdoc/ri/ri_display.rb
index 8e5d07ee6c..67962fc2c1 100644
--- a/lib/rdoc/ri/ri_display.rb
+++ b/lib/rdoc/ri/ri_display.rb
@@ -236,7 +236,6 @@ class DefaultDisplay
@formatter.break_to_newline
end
end
-
######################################################################
def display_flow(flow)
diff --git a/lib/rdoc/ri/ri_paths.rb b/lib/rdoc/ri/ri_paths.rb
index 6f581510ed..9768f12b7d 100644
--- a/lib/rdoc/ri/ri_paths.rb
+++ b/lib/rdoc/ri/ri_paths.rb
@@ -26,9 +26,9 @@ module RI
DOC_DIR = "doc/rdoc"
- version = RbConfig::CONFIG['ruby_version']
+ version = Config::CONFIG['ruby_version']
- base = File.join(RbConfig::CONFIG['datadir'], "ri", version)
+ base = File.join(Config::CONFIG['datadir'], "ri", version)
SYSDIR = File.join(base, "system")
SITEDIR = File.join(base, "site")
homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
@@ -42,30 +42,34 @@ module RI
# This is the search path for 'ri'
PATH = [ SYSDIR, SITEDIR, HOMEDIR ].find_all {|p| p && File.directory?(p)}
- require 'rubygems'
+ begin
+ require 'rubygems'
- # HACK dup'd from Gem.latest_partials and friends
- all_paths = []
+ # HACK dup'd from Gem.latest_partials and friends
+ all_paths = []
- all_paths = Gem.path.map do |dir|
- Dir[File.join(dir, 'doc', '*', 'ri')]
- end.flatten
+ all_paths = Gem.path.map do |dir|
+ Dir[File.join(dir, 'doc', '*', 'ri')]
+ end.flatten
- ri_paths = {}
+ ri_paths = {}
- all_paths.each do |dir|
- base = File.basename File.dirname(dir)
- if base =~ /(.*)-((\d+\.)*\d+)/ then
- name, version = $1, $2
- ver = Gem::Version.new version
- if ri_paths[name].nil? or ver > ri_paths[name][0] then
- ri_paths[name] = [ver, dir]
+ all_paths.each do |dir|
+ base = File.basename File.dirname(dir)
+ if base =~ /(.*)-((\d+\.)*\d+)/ then
+ name, version = $1, $2
+ ver = Gem::Version.new version
+ if ri_paths[name].nil? or ver > ri_paths[name][0] then
+ ri_paths[name] = [ver, dir]
+ end
end
end
- end
- GEMDIRS = ri_paths.map { |k,v| v.last }.sort
- GEMDIRS.each { |dir| RI::Paths::PATH << dir }
+ GEMDIRS = ri_paths.map { |k,v| v.last }.sort
+ GEMDIRS.each { |dir| RI::Paths::PATH << dir }
+ rescue LoadError
+ GEMDIRS = nil
+ end
# Returns the selected documentation directories as an Array, or PATH if no
# overriding directories were given.
diff --git a/lib/rdoc/ri/ri_writer.rb b/lib/rdoc/ri/ri_writer.rb
index 032558ed1c..78c68e8409 100644
--- a/lib/rdoc/ri/ri_writer.rb
+++ b/lib/rdoc/ri/ri_writer.rb
@@ -13,7 +13,7 @@ module RI
# by %xx)
def RiWriter.internal_to_external(name)
- name.gsub(/\W/) { "%%%02x" % $&[0].ord }
+ name.gsub(/\W/) { sprintf("%%%02x", $&[0]) }
end
# And the reverse operation
diff --git a/lib/readbytes.rb b/lib/readbytes.rb
new file mode 100644
index 0000000000..ebb5fc0bd4
--- /dev/null
+++ b/lib/readbytes.rb
@@ -0,0 +1,41 @@
+# TruncatedDataError is raised when IO#readbytes fails to read enough data.
+
+class TruncatedDataError<IOError
+ def initialize(mesg, data) # :nodoc:
+ @data = data
+ super(mesg)
+ end
+
+ # The read portion of an IO#readbytes attempt.
+ attr_reader :data
+end
+
+class IO
+ # Reads exactly +n+ bytes.
+ #
+ # If the data read is nil an EOFError is raised.
+ #
+ # If the data read is too short a TruncatedDataError is raised and the read
+ # data is obtainable via its #data method.
+ def readbytes(n)
+ str = read(n)
+ if str == nil
+ raise EOFError, "End of file reached"
+ end
+ if str.size < n
+ raise TruncatedDataError.new("data truncated", str)
+ end
+ str
+ end
+end
+
+if __FILE__ == $0
+ begin
+ loop do
+ print STDIN.readbytes(6)
+ end
+ rescue TruncatedDataError
+ p $!.data
+ raise
+ end
+end
diff --git a/lib/resolv-replace.rb b/lib/resolv-replace.rb
index 5d15b4577c..63d58cea27 100644
--- a/lib/resolv-replace.rb
+++ b/lib/resolv-replace.rb
@@ -23,7 +23,8 @@ end
class UDPSocket
alias original_resolv_bind bind
def bind(host, port)
- original_resolv_bind(IPSocket.getaddress(host), port)
+ host = IPSocket.getaddress(host) if host != ""
+ original_resolv_bind(host, port)
end
alias original_resolv_connect connect
diff --git a/lib/resolv.rb b/lib/resolv.rb
index deceeaba30..1c03f0c003 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -3,6 +3,11 @@ require 'fcntl'
require 'timeout'
require 'thread'
+begin
+ require 'securerandom'
+rescue LoadError
+end
+
# Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can
# handle multiple DNS requests concurrently without blocking. The ruby
# interpreter.
@@ -28,7 +33,6 @@ require 'thread'
#
# * NIS is not supported.
# * /etc/nsswitch.conf is not supported.
-# * IPv6 is not supported.
class Resolv
@@ -161,7 +165,7 @@ class Resolv
# DNS::Hosts is a hostname resolver that uses the system hosts file.
class Hosts
- if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
+ if /mswin32|mingw|bccwin/ =~ RUBY_PLATFORM
require 'win32/resolv'
DefaultFileName = Win32::Resolv.get_hosts_path
else
@@ -253,7 +257,7 @@ class Resolv
end
##
- # Iterates over all hostnames for +address+ retrived from the hosts file.
+ # Iterates over all hostnames for +address+ retrieved from the hosts file.
def each_name(address, &proc)
lazy_initialize
@@ -286,7 +290,7 @@ class Resolv
UDPSize = 512
##
- # Group of DNS resolver threads
+ # Group of DNS resolver threads (obsolete)
DNSThreadGroup = ThreadGroup.new
@@ -331,13 +335,6 @@ class Resolv
@mutex.synchronize {
unless @initialized
@config.lazy_initialize
-
- if nameserver = @config.single?
- @requester = Requester::ConnectedUDP.new(nameserver)
- else
- @requester = Requester::UnconnectedUDP.new
- end
-
@initialized = true
end
}
@@ -350,8 +347,6 @@ class Resolv
def close
@mutex.synchronize {
if @initialized
- @requester.close if @requester
- @requester = nil
@initialized = false
end
}
@@ -389,6 +384,7 @@ class Resolv
def each_address(name)
each_resource(name, Resource::IN::A) {|resource| yield resource.address}
+ each_resource(name, Resource::IN::AAAA) {|resource| yield resource.address}
end
##
@@ -445,7 +441,6 @@ class Resolv
# * Resolv::DNS::Resource::IN::A
# * Resolv::DNS::Resource::IN::AAAA
# * Resolv::DNS::Resource::IN::ANY
- # * Resolv::DNS::Resource::IN::ANY
# * Resolv::DNS::Resource::IN::CNAME
# * Resolv::DNS::Resource::IN::HINFO
# * Resolv::DNS::Resource::IN::MINFO
@@ -480,7 +475,7 @@ class Resolv
def each_resource(name, typeclass, &proc)
lazy_initialize
- q = Queue.new
+ requester = make_requester
senders = {}
begin
@config.resolv(name) {|candidate, tout, nameserver|
@@ -489,11 +484,9 @@ class Resolv
msg.add_question(candidate, typeclass)
unless sender = senders[[candidate, nameserver]]
sender = senders[[candidate, nameserver]] =
- @requester.sender(msg, candidate, q, nameserver)
+ requester.sender(msg, candidate, nameserver)
end
- sender.send
- reply = reply_name = nil
- timeout(tout, ResolvTimeout) { reply, reply_name = q.pop }
+ reply, reply_name = requester.request(sender, tout)
case reply.rcode
when RCode::NoError
extract_resources(reply, reply_name, typeclass, &proc)
@@ -505,7 +498,15 @@ class Resolv
end
}
ensure
- @requester.delete(q)
+ requester.close
+ end
+ end
+
+ def make_requester # :nodoc:
+ if nameserver = @config.single?
+ Requester::ConnectedUDP.new(nameserver)
+ else
+ Requester::UnconnectedUDP.new
end
end
@@ -540,45 +541,106 @@ class Resolv
}
end
+ if defined? SecureRandom
+ def self.random(arg) # :nodoc:
+ begin
+ SecureRandom.random_number(arg)
+ rescue NotImplementedError
+ rand(arg)
+ end
+ end
+ else
+ def self.random(arg) # :nodoc:
+ rand(arg)
+ end
+ end
+
+
+ def self.rangerand(range) # :nodoc:
+ base = range.begin
+ len = range.end - range.begin
+ if !range.exclude_end?
+ len += 1
+ end
+ base + random(len)
+ end
+
+ RequestID = {}
+ RequestIDMutex = Mutex.new
+
+ def self.allocate_request_id(host, port) # :nodoc:
+ id = nil
+ RequestIDMutex.synchronize {
+ h = (RequestID[[host, port]] ||= {})
+ begin
+ id = rangerand(0x0000..0xffff)
+ end while h[id]
+ h[id] = true
+ }
+ id
+ end
+
+ def self.free_request_id(host, port, id) # :nodoc:
+ RequestIDMutex.synchronize {
+ key = [host, port]
+ if h = RequestID[key]
+ h.delete id
+ if h.empty?
+ RequestID.delete key
+ end
+ end
+ }
+ end
+
+ def self.bind_random_port(udpsock) # :nodoc:
+ begin
+ port = rangerand(1024..65535)
+ udpsock.bind("", port)
+ rescue Errno::EADDRINUSE
+ retry
+ end
+ end
+
class Requester # :nodoc:
def initialize
@senders = {}
+ @sock = nil
end
- def close
- thread, sock, @thread, @sock = @thread, @sock
- begin
- if thread
- thread.kill
- thread.join
+ def request(sender, tout)
+ timelimit = Time.now + tout
+ sender.send
+ while (now = Time.now) < timelimit
+ timeout = timelimit - now
+ if !IO.select([@sock], nil, nil, timeout)
+ raise ResolvTimeout
+ end
+ reply, from = recv_reply
+ begin
+ msg = Message.decode(reply)
+ rescue DecodeError
+ next # broken DNS message ignored
+ end
+ if s = @senders[[from,msg.id]]
+ break
+ else
+ # unexpected DNS message ignored
end
- ensure
- sock.close if sock
end
+ return msg, s.data
end
- def delete(arg)
- case arg
- when Sender
- @senders.delete_if {|k, s| s == arg }
- when Queue
- @senders.delete_if {|k, s| s.queue == arg }
- else
- raise ArgumentError.new("neither Sender or Queue: #{arg}")
- end
+ def close
+ sock = @sock
+ @sock = nil
+ sock.close if sock
end
class Sender # :nodoc:
- def initialize(msg, data, sock, queue)
+ def initialize(msg, data, sock)
@msg = msg
@data = data
@sock = sock
- @queue = queue
- end
- attr_reader :queue
-
- def recv(msg)
- @queue.push([msg, @data])
end
end
@@ -586,45 +648,38 @@ class Resolv
def initialize
super()
@sock = UDPSocket.new
- @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
- @id = {}
- @id.default = -1
- @thread = Thread.new {
- DNSThreadGroup.add Thread.current
- loop {
- reply, from = @sock.recvfrom(UDPSize)
- msg = begin
- Message.decode(reply)
- rescue DecodeError
- STDERR.print("DNS message decoding error: #{reply.inspect}\n")
- next
- end
- if s = @senders[[[from[3],from[1]],msg.id]]
- s.recv msg
- else
- #STDERR.print("non-handled DNS message: #{msg.inspect} from #{from.inspect}\n")
- end
- }
- }
+ @sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
+ DNS.bind_random_port(@sock)
end
- def sender(msg, data, queue, host, port=Port)
+ def recv_reply
+ reply, from = @sock.recvfrom(UDPSize)
+ return reply, [from[3],from[1]]
+ end
+
+ def sender(msg, data, host, port=Port)
service = [host, port]
- id = Thread.exclusive {
- @id[service] = (@id[service] + 1) & 0xffff
- }
+ id = DNS.allocate_request_id(host, port)
request = msg.encode
request[0,2] = [id].pack('n')
return @senders[[service, id]] =
- Sender.new(request, data, @sock, host, port, queue)
+ Sender.new(request, data, @sock, host, port)
+ end
+
+ def close
+ super
+ @senders.each_key {|service, id|
+ DNS.free_request_id(service[0], service[1], id)
+ }
end
class Sender < Requester::Sender # :nodoc:
- def initialize(msg, data, sock, host, port, queue)
- super(msg, data, sock, queue)
+ def initialize(msg, data, sock, host, port)
+ super(msg, data, sock)
@host = host
@port = port
end
+ attr_reader :data
def send
@sock.send(@msg, 0, @host, @port)
@@ -638,42 +693,38 @@ class Resolv
@host = host
@port = port
@sock = UDPSocket.new(host.index(':') ? Socket::AF_INET6 : Socket::AF_INET)
+ DNS.bind_random_port(@sock)
@sock.connect(host, port)
- @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
- @id = -1
- @thread = Thread.new {
- DNSThreadGroup.add Thread.current
- loop {
- reply = @sock.recv(UDPSize)
- msg = begin
- Message.decode(reply)
- rescue DecodeError
- STDERR.print("DNS message decoding error: #{reply.inspect}")
- next
- end
- if s = @senders[msg.id]
- s.recv msg
- else
- #STDERR.print("non-handled DNS message: #{msg.inspect}")
- end
- }
- }
+ @sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
+ end
+
+ def recv_reply
+ reply = @sock.recv(UDPSize)
+ return reply, nil
end
- def sender(msg, data, queue, host=@host, port=@port)
+ def sender(msg, data, host=@host, port=@port)
unless host == @host && port == @port
raise RequestError.new("host/port don't match: #{host}:#{port}")
end
- id = Thread.exclusive { @id = (@id + 1) & 0xffff }
+ id = DNS.allocate_request_id(@host, @port)
request = msg.encode
request[0,2] = [id].pack('n')
- return @senders[id] = Sender.new(request, data, @sock, queue)
+ return @senders[[nil,id]] = Sender.new(request, data, @sock)
+ end
+
+ def close
+ super
+ @senders.each_key {|from, id|
+ DNS.free_request_id(@host, @port, id)
+ }
end
class Sender < Requester::Sender # :nodoc:
def send
@sock.send(@msg, 0)
end
+ attr_reader :data
end
end
@@ -682,39 +733,25 @@ class Resolv
super()
@host = host
@port = port
- @sock = TCPSocket.new
- @sock.connect(host, port)
- @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
- @id = -1
+ @sock = TCPSocket.new(@host, @port)
+ @sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
@senders = {}
- @thread = Thread.new {
- DNSThreadGroup.add Thread.current
- loop {
- len = @sock.read(2).unpack('n')
- reply = @sock.read(len)
- msg = begin
- Message.decode(reply)
- rescue DecodeError
- STDERR.print("DNS message decoding error: #{reply.inspect}")
- next
- end
- if s = @senders[msg.id]
- s.push msg
- else
- #STDERR.print("non-handled DNS message: #{msg.inspect}")
- end
- }
- }
end
- def sender(msg, data, queue, host=@host, port=@port)
+ def recv_reply
+ len = @sock.read(2).unpack('n')[0]
+ reply = @sock.read(len)
+ return reply, nil
+ end
+
+ def sender(msg, data, host=@host, port=@port)
unless host == @host && port == @port
raise RequestError.new("host/port don't match: #{host}:#{port}")
end
- id = Thread.exclusive { @id = (@id + 1) & 0xffff }
+ id = DNS.allocate_request_id(@host, @port)
request = msg.encode
request[0,2] = [request.length, id].pack('nn')
- return @senders[id] = Sender.new(request, data, @sock, queue)
+ return @senders[[nil,id]] = Sender.new(request, data, @sock)
end
class Sender < Requester::Sender # :nodoc:
@@ -722,6 +759,14 @@ class Resolv
@sock.print(@msg)
@sock.flush
end
+ attr_reader :data
+ end
+
+ def close
+ super
+ @senders.each_key {|from,id|
+ DNS.free_request_id(@host, @port, id)
+ }
end
end
@@ -778,6 +823,7 @@ class Resolv
config_hash = Config.parse_resolv_conf(filename)
else
if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
+ require 'win32/resolv'
search, nameserver = Win32::Resolv.get_resolv_info
config_hash = {}
config_hash[:nameserver] = nameserver if nameserver
@@ -1032,7 +1078,7 @@ class Resolv
def ==(other) # :nodoc:
return false unless Name === other
- return @labels == other.to_a && @absolute == other.absolute?
+ return @labels.join == other.to_a.join && @absolute == other.absolute?
end
alias eql? == # :nodoc:
@@ -1262,7 +1308,7 @@ class Resolv
end
def put_label(d)
- self.put_string(d.string)
+ self.put_string(d.to_s)
end
end
@@ -1330,7 +1376,6 @@ class Resolv
def get_unpack(template)
len = 0
template.each_byte {|byte|
- byte = "%c" % byte
case byte
when ?c, ?C
len += 1
@@ -1349,7 +1394,7 @@ class Resolv
end
def get_string
- len = @data[@index].ord
+ len = @data[@index]
raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len
d = @data[@index + 1, len]
@index += 1 + len
@@ -1372,7 +1417,7 @@ class Resolv
limit = @index if !limit || @index < limit
d = []
while true
- case @data[@index].ord
+ case @data[@index]
when 0
@index += 1
return d
@@ -1407,9 +1452,7 @@ class Resolv
name = self.get_name
type, klass, ttl = self.get_unpack('nnN')
typeclass = Resource.get_class(type, klass)
- res = self.get_length16 { typeclass.decode_rdata self }
- res.instance_variable_set :@ttl, ttl
- return name, ttl, res
+ return name, ttl, self.get_length16 {typeclass.decode_rdata(self)}
end
end
end
@@ -1448,16 +1491,10 @@ class Resolv
end
def ==(other) # :nodoc:
- return false unless self.class == other.class
- s_ivars = self.instance_variables
- s_ivars.sort!
- s_ivars.delete "@ttl"
- o_ivars = other.instance_variables
- o_ivars.sort!
- o_ivars.delete "@ttl"
- return s_ivars == o_ivars &&
- s_ivars.collect {|name| self.instance_variable_get name} ==
- o_ivars.collect {|name| other.instance_variable_get name}
+ return self.class == other.class &&
+ self.instance_variables == other.instance_variables &&
+ self.instance_variables.collect {|name| self.instance_eval name} ==
+ other.instance_variables.collect {|name| other.instance_eval name}
end
def eql?(other) # :nodoc:
@@ -1466,10 +1503,8 @@ class Resolv
def hash # :nodoc:
h = 0
- vars = self.instance_variables
- vars.delete "@ttl"
- vars.each {|name|
- h ^= self.instance_variable_get(name).hash
+ self.instance_variables.each {|name|
+ h ^= self.instance_eval("#{name}.hash")
}
return h
end
@@ -2026,7 +2061,7 @@ class Resolv
end
##
- # A String reperesentation of this IPv4 address.
+ # A String representation of this IPv4 address.
##
# The raw IPv4 address as a String.
@@ -2191,7 +2226,7 @@ class Resolv
def to_name
return DNS::Name.new(
- @address.unpack("H32")[0].split(//).reverse + ['ip6', 'int'])
+ @address.unpack("H32")[0].split(//).reverse + ['ip6', 'arpa'])
end
def ==(other) # :nodoc:
diff --git a/lib/rexml/attlistdecl.rb b/lib/rexml/attlistdecl.rb
index d4b5c38af6..ef4721b5ce 100644
--- a/lib/rexml/attlistdecl.rb
+++ b/lib/rexml/attlistdecl.rb
@@ -44,7 +44,7 @@ module REXML
@pairs.keys.include? key
end
- # Itterate over the key/value pairs:
+ # Iterate over the key/value pairs:
# attlist_decl.each { |attribute_name, attribute_value| ... }
def each(&block)
@pairs.each(&block)
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
index f09aa2bc1c..54aa691ad8 100644
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -147,7 +147,7 @@ module REXML
# A controversial point is whether Document should always write the XML
# declaration (<?xml version='1.0'?>) whether or not one is given by the
# user (or source document). REXML does not write one if one was not
- # specified, because it adds unneccessary bandwidth to applications such
+ # specified, because it adds unnecessary bandwidth to applications such
# as XML-RPC.
#
# See also the classes in the rexml/formatters package for the proper way
@@ -179,7 +179,7 @@ module REXML
# unable to parse proper XML, we have to provide a hack to generate XML
# that IE's limited abilities can handle. This hack inserts a space
# before the /> on empty tags. Defaults to false
- def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
+ def write( output=$stdout, indent=-1, trans=false, ie_hack=false )
if xml_decl.encoding != "UTF-8" && !output.kind_of?(Output)
output = Output.new( output, xml_decl.encoding )
end
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
index 345e1734e5..3db87c6126 100644
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -360,7 +360,7 @@ module REXML
# Iterates through the children, yielding for each Element that
# has a particular text set.
# text::
- # the text to search for. If nil, or not supplied, will itterate
+ # the text to search for. If nil, or not supplied, will iterate
# over all +Element+ children that contain at least one +Text+ node.
# max::
# (optional) causes this method to return after yielding
@@ -989,7 +989,7 @@ module REXML
end
alias :size :length
- # Itterates over the attributes of an Element. Yields actual Attribute
+ # Iterates over the attributes of an Element. Yields actual Attribute
# nodes, not String values.
#
# doc = Document.new '<a x="1" y="2"/>'
@@ -1006,14 +1006,14 @@ module REXML
end
end
- # Itterates over each attribute of an Element, yielding the expanded name
+ # Iterates over each attribute of an Element, yielding the expanded name
# and value as a pair of Strings.
#
# doc = Document.new '<a x="1" y="2"/>'
# doc.root.attributes.each {|name, value| p name+" => "+value }
def each
each_attribute do |attr|
- yield [attr.expanded_name, attr.value]
+ yield attr.expanded_name, attr.value
end
end
diff --git a/lib/rexml/formatters/pretty.rb b/lib/rexml/formatters/pretty.rb
index 22b6d857cd..d21175d34a 100644
--- a/lib/rexml/formatters/pretty.rb
+++ b/lib/rexml/formatters/pretty.rb
@@ -125,7 +125,7 @@ module REXML
end
def wrap(string, width)
- # Recursivly wrap string at width.
+ # Recursively wrap string at width.
return string if string.length <= width
place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
return string[0,place] + "\n" + wrap(string[place+1..-1], width)
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
index 8293e9c5ac..fefc9ef940 100644
--- a/lib/rexml/functions.rb
+++ b/lib/rexml/functions.rb
@@ -235,7 +235,7 @@ module REXML
# from string then we ignore the second &
# subsequent mappings
#
- # if a charactcer maps to nil then we delete it
+ # if a character maps to nil then we delete it
# in the output. This happens if the from
# string is longer than the to string
#
diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb
index 435242dc31..8af1697e51 100644
--- a/lib/rexml/rexml.rb
+++ b/lib/rexml/rexml.rb
@@ -13,6 +13,7 @@
# Author:: Sean Russell <serATgermaneHYPHENsoftwareDOTcom>
# Version:: 3.1.7.2
# Date:: 2007/275
+# Revision:: $Revision$
#
# This API documentation can be downloaded from the REXML home page, or can
# be accessed online[http://www.germane-software.com/software/rexml_doc]
@@ -21,9 +22,9 @@
# or can be accessed
# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
module REXML
- COPYRIGHT = "Copyright © 2001-2007 Sean Russell <ser@germane-software.com>"
- DATE = "2007/275"
+ COPYRIGHT = "Copyright \xC2\xA9 2001-2006 Sean Russell <ser@germane-software.com>"
VERSION = "3.1.7.2"
+ DATE = "2007/275"
REVISION = "$Revision$".gsub(/\$Revision:|\$/,'').strip
Copyright = COPYRIGHT
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
index e05460fea1..ce7a2c98b0 100644
--- a/lib/rexml/source.rb
+++ b/lib/rexml/source.rb
@@ -7,14 +7,13 @@ module REXML
# @param arg Either a String, or an IO
# @return a Source, or nil if a bad argument was given
def SourceFactory::create_from(arg)
- if arg.respond_to? :read and
- arg.respond_to? :readline and
- arg.respond_to? :nil? and
- arg.respond_to? :eof?
+ if arg.kind_of? String
+ Source.new(arg)
+ elsif arg.respond_to? :read and
+ arg.respond_to? :readline and
+ arg.respond_to? :nil? and
+ arg.respond_to? :eof?
IOSource.new(arg)
- elsif arg.respond_to? :to_str
- require 'stringio'
- IOSource.new(StringIO.new(arg))
elsif arg.kind_of? Source
arg
else
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
index 9804aa710b..2bc00429b3 100644
--- a/lib/rexml/text.rb
+++ b/lib/rexml/text.rb
@@ -189,7 +189,7 @@ module REXML
end
def wrap(string, width, addnewline=false)
- # Recursivly wrap string at width.
+ # Recursively wrap string at width.
return string if string.length <= width
place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
if addnewline then
diff --git a/lib/rexml/xpath.rb b/lib/rexml/xpath.rb
index 939399e283..e8813efd3e 100644
--- a/lib/rexml/xpath.rb
+++ b/lib/rexml/xpath.rb
@@ -30,7 +30,7 @@ module REXML
parser.parse(path, element).flatten[0]
end
- # Itterates over nodes that match the given path, calling the supplied
+ # Iterates over nodes that match the given path, calling the supplied
# block with the match.
# element::
# The context element
diff --git a/lib/rinda/.document b/lib/rinda/.document
deleted file mode 100644
index 598977af68..0000000000
--- a/lib/rinda/.document
+++ /dev/null
@@ -1,3 +0,0 @@
-rinda.rb
-ring.rb
-tuplespace.rb
diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb
index 5b2d412451..1fad92dbc7 100644
--- a/lib/rinda/ring.rb
+++ b/lib/rinda/ring.rb
@@ -19,7 +19,7 @@ module Rinda
# 1. A RingServer begins listening on the broadcast UDP address.
# 2. A RingFinger sends a UDP packet containing the DRb URI where it will
# listen for a reply.
- # 3. The RingServer recieves the UDP packet and connects back to the
+ # 3. The RingServer receives the UDP packet and connects back to the
# provided DRb URI with the DRb service.
class RingServer
@@ -80,7 +80,7 @@ module Rinda
# address of the local TupleSpace.
def do_reply
- tuple = @ts.take([:lookup_ring, DRbObject])
+ tuple = @ts.take([:lookup_ring, nil])
Thread.new { tuple[1].call(@ts) rescue nil}
rescue
end
@@ -119,7 +119,7 @@ module Rinda
end
##
- # Contains all discoverd TupleSpaces except for the primary.
+ # Contains all discovered TupleSpaces except for the primary.
def self.to_a
finger.to_a
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index 73e79bb401..b0409dde3b 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -2,6 +2,8 @@ require 'monitor'
require 'thread'
require 'drb/drb'
require 'rinda/rinda'
+require 'enumerator'
+require 'forwardable'
module Rinda
@@ -286,45 +288,70 @@ module Rinda
# of Tuplespace.
class TupleBag
+ class TupleBin
+ extend Forwardable
+ def_delegators '@bin', :find_all, :delete_if, :each, :empty?
+
+ def initialize
+ @bin = []
+ end
+
+ def add(tuple)
+ @bin.push(tuple)
+ end
+
+ def delete(tuple)
+ idx = @bin.rindex(tuple)
+ @bin.delete_at(idx) if idx
+ end
+
+ def find(&blk)
+ @bin.reverse_each do |x|
+ return x if yield(x)
+ end
+ nil
+ end
+ end
def initialize # :nodoc:
@hash = {}
+ @enum = Enumerable::Enumerator.new(self, :each_entry)
end
##
# +true+ if the TupleBag to see if it has any expired entries.
def has_expires?
- @hash.each do |k, v|
- v.each do |tuple|
- return true if tuple.expires
- end
+ @enum.find do |tuple|
+ tuple.expires
end
- false
end
##
- # Add +ary+ to the TupleBag.
+ # Add +tuple+ to the TupleBag.
- def push(ary)
- size = ary.size
- @hash[size] ||= []
- @hash[size].push(ary)
+ def push(tuple)
+ key = bin_key(tuple)
+ @hash[key] ||= TupleBin.new
+ @hash[key].add(tuple)
end
##
- # Removes +ary+ from the TupleBag.
+ # Removes +tuple+ from the TupleBag.
- def delete(ary)
- size = ary.size
- @hash.fetch(size, []).delete(ary)
+ def delete(tuple)
+ key = bin_key(tuple)
+ bin = @hash[key]
+ return nil unless bin
+ bin.delete(tuple)
+ @hash.delete(key) if bin.empty?
+ tuple
end
##
# Finds all live tuples that match +template+.
-
def find_all(template)
- @hash.fetch(template.size, []).find_all do |tuple|
+ bin_for_find(template).find_all do |tuple|
tuple.alive? && template.match(tuple)
end
end
@@ -333,7 +360,7 @@ module Rinda
# Finds a live tuple that matches +template+.
def find(template)
- @hash.fetch(template.size, []).find do |tuple|
+ bin_for_find(template).find do |tuple|
tuple.alive? && template.match(tuple)
end
end
@@ -343,7 +370,7 @@ module Rinda
# +tuple+ and are alive.
def find_all_template(tuple)
- @hash.fetch(tuple.size, []).find_all do |template|
+ @enum.find_all do |template|
template.alive? && template.match(tuple)
end
end
@@ -354,20 +381,39 @@ module Rinda
def delete_unless_alive
deleted = []
- @hash.keys.each do |size|
- ary = []
- @hash[size].each do |tuple|
+ @hash.each do |key, bin|
+ bin.delete_if do |tuple|
if tuple.alive?
- ary.push(tuple)
+ false
else
deleted.push(tuple)
+ true
end
end
- @hash[size] = ary
end
deleted
end
+ private
+ def each_entry(&blk)
+ @hash.each do |k, v|
+ v.each(&blk)
+ end
+ end
+
+ def bin_key(tuple)
+ head = tuple[0]
+ if head.class == Symbol
+ return head
+ else
+ false
+ end
+ end
+
+ def bin_for_find(template)
+ key = bin_key(template)
+ key ? @hash.fetch(key, []) : @enum
+ end
end
##
@@ -403,8 +449,7 @@ module Rinda
# Adds +tuple+
def write(tuple, sec=nil)
- entry = TupleEntry.new(tuple, sec)
- start_keeper
+ entry = create_entry(tuple, sec)
synchronize do
if entry.expired?
@read_waiter.find_all_template(entry).each do |template|
@@ -414,6 +459,7 @@ module Rinda
notify_event('delete', entry.value)
else
@bag.push(entry)
+ start_keeper if entry.expires
@read_waiter.find_all_template(entry).each do |template|
template.read(tuple)
end
@@ -439,7 +485,6 @@ module Rinda
def move(port, tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
- start_keeper
synchronize do
entry = @bag.find(template)
if entry
@@ -452,6 +497,7 @@ module Rinda
begin
@take_waiter.push(template)
+ start_keeper if template.expires
while true
raise RequestCanceledError if template.canceled?
raise RequestExpiredError if template.expired?
@@ -476,7 +522,6 @@ module Rinda
def read(tuple, sec=nil)
template = WaitTemplateEntry.new(self, tuple, sec)
yield(template) if block_given?
- start_keeper
synchronize do
entry = @bag.find(template)
return entry.value if entry
@@ -484,6 +529,7 @@ module Rinda
begin
@read_waiter.push(template)
+ start_keeper if template.expires
template.wait
raise RequestCanceledError if template.canceled?
raise RequestExpiredError if template.expired?
@@ -529,6 +575,10 @@ module Rinda
private
+ def create_entry(tuple, sec)
+ TupleEntry.new(tuple, sec)
+ end
+
##
# Removes dead tuples.
@@ -566,9 +616,12 @@ module Rinda
def start_keeper
return if @keeper && @keeper.alive?
@keeper = Thread.new do
- while need_keeper?
- keep_clean
+ while true
sleep(@period)
+ synchronize do
+ break unless need_keeper?
+ keep_clean
+ end
end
end
end
diff --git a/lib/rss/atom.rb b/lib/rss/atom.rb
index 10282a8743..7cba934feb 100644
--- a/lib/rss/atom.rb
+++ b/lib/rss/atom.rb
@@ -1,3 +1,4 @@
+require 'base64'
require 'rss/parser'
module RSS
diff --git a/lib/rss/maker.rb b/lib/rss/maker.rb
index 666dfa872d..bcba1aaff3 100644
--- a/lib/rss/maker.rb
+++ b/lib/rss/maker.rb
@@ -8,15 +8,15 @@ module RSS
def make(version, &block)
m = maker(version)
raise UnsupportedMakerVersionError.new(version) if m.nil?
- m.make(&block)
+ m[:maker].make(m[:version], &block)
end
def maker(version)
MAKERS[version]
end
- def add_maker(version, maker)
- MAKERS[version] = maker
+ def add_maker(version, normalized_version, maker)
+ MAKERS[version] = {:maker => maker, :version => normalized_version}
end
def versions
@@ -24,7 +24,7 @@ module RSS
end
def makers
- MAKERS.values.uniq
+ MAKERS.values.collect {|info| info[:maker]}.uniq
end
end
end
diff --git a/lib/rss/maker/0.9.rb b/lib/rss/maker/0.9.rb
index c83597dfd5..72b14dc977 100644
--- a/lib/rss/maker/0.9.rb
+++ b/lib/rss/maker/0.9.rb
@@ -7,7 +7,7 @@ module RSS
class RSS09 < RSSBase
- def initialize(feed_version="0.91")
+ def initialize(feed_version="0.92")
super
@feed_type = "rss"
end
@@ -258,23 +258,27 @@ module RSS
def to_feed(rss)
item = Rss::Channel::Item.new
set = setup_values(item)
- if set or title {|t| t.have_required_values?}
+ _not_set_required_variables = not_set_required_variables
+ if _not_set_required_variables.empty?
rss.items << item
set_parent(item, rss.channel)
setup_other_elements(rss, item)
elsif variable_is_set?
- raise NotSetError.new("maker.items", not_set_required_variables)
+ raise NotSetError.new("maker.items", _not_set_required_variables)
end
end
private
def required_variable_names
- %w(link)
+ []
end
def not_set_required_variables
vars = super
- vars << "title" unless title {|t| t.have_required_values?}
+ if @maker.feed_version == "0.91"
+ vars << "title" unless title {|t| t.have_required_values?}
+ vars << "link" unless link {|l| l.have_required_values?}
+ end
vars
end
@@ -454,8 +458,10 @@ module RSS
end
end
- add_maker("0.9", RSS09)
- add_maker("0.91", RSS09)
- add_maker("rss0.91", RSS09)
+ add_maker("0.9", "0.92", RSS09)
+ add_maker("0.91", "0.91", RSS09)
+ add_maker("0.92", "0.92", RSS09)
+ add_maker("rss0.91", "0.91", RSS09)
+ add_maker("rss0.92", "0.92", RSS09)
end
end
diff --git a/lib/rss/maker/1.0.rb b/lib/rss/maker/1.0.rb
index c4af6e9b2e..a1e2594f70 100644
--- a/lib/rss/maker/1.0.rb
+++ b/lib/rss/maker/1.0.rb
@@ -7,8 +7,8 @@ module RSS
class RSS10 < RSSBase
- def initialize
- super("1.0")
+ def initialize(feed_version="1.0")
+ super
@feed_type = "rss"
end
@@ -428,7 +428,7 @@ module RSS
end
end
- add_maker("1.0", RSS10)
- add_maker("rss1.0", RSS10)
+ add_maker("1.0", "1.0", RSS10)
+ add_maker("rss1.0", "1.0", RSS10)
end
end
diff --git a/lib/rss/maker/2.0.rb b/lib/rss/maker/2.0.rb
index 9149c0e24b..67d68126ac 100644
--- a/lib/rss/maker/2.0.rb
+++ b/lib/rss/maker/2.0.rb
@@ -93,7 +93,16 @@ module RSS
class Item < RSS09::Items::Item
private
def required_variable_names
- %w(title description)
+ []
+ end
+
+ def not_set_required_variables
+ vars = super
+ if !title {|t| t.have_required_values?} and
+ !description {|d| d.have_required_values?}
+ vars << "title or description"
+ end
+ vars
end
def variables
@@ -208,7 +217,7 @@ module RSS
end
end
- add_maker("2.0", RSS20)
- add_maker("rss2.0", RSS20)
+ add_maker("2.0", "2.0", RSS20)
+ add_maker("rss2.0", "2.0", RSS20)
end
end
diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb
index fdb8946efc..56bf04657e 100644
--- a/lib/rss/maker/base.rb
+++ b/lib/rss/maker/base.rb
@@ -357,8 +357,8 @@ module RSS
class RSSBase < Base
class << self
- def make(&block)
- new.make(&block)
+ def make(version, &block)
+ new(version).make(&block)
end
end
diff --git a/lib/rss/maker/entry.rb b/lib/rss/maker/entry.rb
index be648832c3..edaa31ec06 100644
--- a/lib/rss/maker/entry.rb
+++ b/lib/rss/maker/entry.rb
@@ -5,8 +5,8 @@ module RSS
module Maker
module Atom
class Entry < RSSBase
- def initialize
- super("1.0")
+ def initialize(feed_version="1.0")
+ super
@feed_type = "atom"
@feed_subtype = "entry"
end
@@ -157,7 +157,7 @@ module RSS
end
end
- add_maker("atom:entry", Atom::Entry)
- add_maker("atom1.0:entry", Atom::Entry)
+ add_maker("atom:entry", "1.0", Atom::Entry)
+ add_maker("atom1.0:entry", "1.0", Atom::Entry)
end
end
diff --git a/lib/rss/maker/feed.rb b/lib/rss/maker/feed.rb
index 95ae735c6b..3a30ad4287 100644
--- a/lib/rss/maker/feed.rb
+++ b/lib/rss/maker/feed.rb
@@ -4,8 +4,8 @@ module RSS
module Maker
module Atom
class Feed < RSSBase
- def initialize
- super("1.0")
+ def initialize(feed_version="1.0")
+ super
@feed_type = "atom"
@feed_subtype = "feed"
end
@@ -421,9 +421,9 @@ module RSS
end
end
- add_maker("atom", Atom::Feed)
- add_maker("atom:feed", Atom::Feed)
- add_maker("atom1.0", Atom::Feed)
- add_maker("atom1.0:feed", Atom::Feed)
+ add_maker("atom", "1.0", Atom::Feed)
+ add_maker("atom:feed", "1.0", Atom::Feed)
+ add_maker("atom1.0", "1.0", Atom::Feed)
+ add_maker("atom1.0:feed", "1.0", Atom::Feed)
end
end
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index 7f5f57a1ea..9e4919223c 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -8,6 +8,10 @@ module RSS
class NotWellFormedError < Error
attr_reader :line, :element
+
+ # Create a new NotWellFormedError for an error at +line+
+ # in +element+. If a block is given the return value of
+ # the block ends up in the error message.
def initialize(line=nil, element=nil)
message = "This is not well formed XML"
if element or line
@@ -22,15 +26,16 @@ module RSS
class XMLParserNotFound < Error
def initialize
- super("available XML parser does not found in " <<
+ super("available XML parser was not found in " <<
"#{AVAILABLE_PARSER_LIBRARIES.inspect}.")
end
end
class NotValidXMLParser < Error
def initialize(parser)
- super("#{parser} is not available XML parser. " <<
- "available XML parser is " <<
+ super("#{parser} is not an available XML parser. " <<
+ "Available XML parser"<<
+ (AVAILABLE_PARSERS.size > 1 ? "s are ": " is ") <<
"#{AVAILABLE_PARSERS.inspect}.")
end
end
@@ -56,6 +61,8 @@ module RSS
@@default_parser || AVAILABLE_PARSERS.first
end
+ # Set @@default_parser to new_value if it is one of the
+ # available parsers. Else raise NotValidXMLParser error.
def default_parser=(new_value)
if AVAILABLE_PARSERS.include?(new_value)
@@default_parser = new_value
@@ -83,6 +90,10 @@ module RSS
end
private
+
+ # Try to get the XML associated with +rss+.
+ # Return +rss+ if it already looks like XML, or treat it as a URI,
+ # or a file to get the XML,
def normalize_rss(rss)
return rss if maybe_xml?(rss)
@@ -97,10 +108,13 @@ module RSS
end
end
+ # maybe_xml? tests if source is a string that looks like XML.
def maybe_xml?(source)
source.is_a?(String) and /</ =~ source
end
+ # Attempt to convert rss to a URI, but just return it if
+ # there's a ::URI::Error
def to_uri(rss)
return rss if rss.is_a?(::URI::Generic)
@@ -164,6 +178,7 @@ module RSS
@@registered_uris = {}
@@class_names = {}
+ # return the setter for the uri, tag_name pair, or nil.
def setter(uri, tag_name)
_getter = getter(uri, tag_name)
if _getter
@@ -177,34 +192,38 @@ module RSS
(@@accessor_bases[uri] || {})[tag_name]
end
+ # return the tag_names for setters associated with uri
def available_tags(uri)
- begin
- @@accessor_bases[uri].keys
- rescue NameError
- []
- end
+ (@@accessor_bases[uri] || {}).keys
end
+ # register uri against this name.
def register_uri(uri, name)
@@registered_uris[name] ||= {}
@@registered_uris[name][uri] = nil
end
+ # test if this uri is registered against this name
def uri_registered?(uri, name)
@@registered_uris[name].has_key?(uri)
end
+ # record class_name for the supplied uri and tag_name
def install_class_name(uri, tag_name, class_name)
@@class_names[uri] ||= {}
@@class_names[uri][tag_name] = class_name
end
+ # retrieve class_name for the supplied uri and tag_name
+ # If it doesn't exist, capitalize the tag_name
def class_name(uri, tag_name)
- begin
- @@class_names[uri][tag_name]
- rescue NameError
- tag_name[0,1].upcase + tag_name[1..-1]
+ name = (@@class_names[uri] || {})[tag_name]
+ return name if name
+
+ tag_name = tag_name.gsub(/[_\-]([a-z]?)/) do
+ $1.upcase
end
+ tag_name[0, 1].upcase + tag_name[1..-1]
end
def install_get_text_element(uri, name, accessor_base)
@@ -217,6 +236,7 @@ module RSS
end
private
+ # set the accessor for the uri, tag_name pair
def install_accessor_base(uri, tag_name, accessor_base)
@@accessor_bases[uri] ||= {}
@@accessor_bases[uri][tag_name] = accessor_base.chomp("=")
@@ -262,6 +282,7 @@ module RSS
@last_xml_element = nil
end
+ # set instance vars for version, encoding, standalone
def xmldecl(version, encoding, standalone)
@version, @encoding, @standalone = version, encoding, standalone
end
@@ -354,6 +375,9 @@ module RSS
end
CONTENT_PATTERN = /\s*([^=]+)=(["'])([^\2]+?)\2/
+ # Extract the first name="value" pair from content.
+ # Works with single quotes according to the constant
+ # CONTENT_PATTERN. Return a Hash.
def parse_pi_content(content)
params = {}
content.scan(CONTENT_PATTERN) do |name, quote, value|
@@ -366,8 +390,8 @@ module RSS
class_name = self.class.class_name(_ns(ns, prefix), local)
current_class = @last_element.class
if class_name and
- (current_class.const_defined?(class_name, false) or
- current_class.constants.include?(class_name.to_sym))
+ (current_class.const_defined?(class_name) or
+ current_class.constants.include?(class_name))
next_class = current_class.const_get(class_name)
start_have_something_element(local, prefix, attrs, ns, next_class)
else
@@ -422,12 +446,14 @@ module RSS
end
def start_have_something_element(tag_name, prefix, attrs, ns, klass)
-
check_ns(tag_name, prefix, ns, klass.required_uri)
+ attributes = collect_attributes(tag_name, prefix, attrs, ns, klass)
+ @proc_stack.push(setup_next_element(tag_name, klass, attributes))
+ end
+ def collect_attributes(tag_name, prefix, attrs, ns, klass)
attributes = {}
klass.get_attributes.each do |a_name, a_uri, required, element_name|
-
if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
a_uri = [a_uri]
end
@@ -456,14 +482,18 @@ module RSS
attributes[a_name] = val
end
+ attributes
+ end
+ def setup_next_element(tag_name, klass, attributes)
previous = @last_element
next_element = klass.new(@do_validate, attributes)
previous.set_next_element(tag_name, next_element)
@last_element = next_element
@last_element.parent = previous if klass.need_parent?
@xml_child_mode = @last_element.have_xml_content?
- pr = Proc.new do |text, tags|
+
+ Proc.new do |text, tags|
p(@last_element.class) if DEBUG
if @xml_child_mode
@last_element.content = @xml_element.to_s
@@ -474,7 +504,7 @@ module RSS
else
if klass.have_content?
if @last_element.need_base64_encode?
- text = text.lstrip.unpack("m").first
+ text = Base64.decode64(text.lstrip)
end
@last_element.content = text
end
@@ -484,9 +514,7 @@ module RSS
end
@last_element = previous
end
- @proc_stack.push(pr)
end
-
end
unless const_defined? :AVAILABLE_PARSER_LIBRARIES
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index 32741b03d1..5aa4a2cedd 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -45,7 +45,6 @@ class Time
end
end
-
require "English"
require "rss/utils"
require "rss/converter"
@@ -53,7 +52,7 @@ require "rss/xml-stylesheet"
module RSS
- VERSION = "0.2.2"
+ VERSION = "0.2.4"
URI = "http://purl.org/rss/1.0/"
@@ -1201,7 +1200,7 @@ EOC
__send__(self.class.xml_getter).to_s
else
_content = content
- _content = [_content].pack("m").delete("\n") if need_base64_encode?
+ _content = Base64.encode64(_content) if need_base64_encode?
h(_content)
end
end
diff --git a/lib/rss/utils.rb b/lib/rss/utils.rb
index a24fc173d6..0e4001e1f3 100644
--- a/lib/rss/utils.rb
+++ b/lib/rss/utils.rb
@@ -1,6 +1,8 @@
module RSS
module Utils
module_function
+
+ # Convert a name_with_underscores to CamelCase.
def to_class_name(name)
name.split(/[_\-]/).collect do |part|
"#{part[0, 1].upcase}#{part[1..-1]}"
@@ -14,11 +16,14 @@ module RSS
[file, line]
end
+ # escape '&', '"', '<' and '>' for use in HTML.
def html_escape(s)
s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end
alias h html_escape
+ # If +value+ is an instance of class +klass+, return it, else
+ # create a new instance of +klass+ with value +value+.
def new_with_value_if_need(klass, value)
if value.is_a?(klass)
value
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
deleted file mode 100644
index e25e05a3b8..0000000000
--- a/lib/rubygems.rb
+++ /dev/null
@@ -1,567 +0,0 @@
-# -*- ruby -*-
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/rubygems_version'
-require 'rubygems/defaults'
-require 'thread'
-
-module Gem
- class LoadError < ::LoadError
- attr_accessor :name, :version_requirement
- end
-end
-
-module Kernel
-
- # Adds a Ruby Gem to the $LOAD_PATH. Before a Gem is loaded, its
- # required Gems are loaded. If the version information is omitted,
- # the highest version Gem of the supplied name is loaded. If a Gem
- # is not found that meets the version requirement and/or a required
- # Gem is not found, a Gem::LoadError is raised. More information on
- # version requirements can be found in the Gem::Version
- # documentation.
- #
- # The +gem+ directive should be executed *before* any require
- # statements (otherwise rubygems might select a conflicting library
- # version).
- #
- # You can define the environment variable GEM_SKIP as a way to not
- # load specified gems. You might do this to test out changes that
- # haven't been installed yet. Example:
- #
- # GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
- #
- # gem:: [String or Gem::Dependency] The gem name or dependency
- # instance.
- #
- # version_requirement:: [default=">= 0"] The version
- # requirement.
- #
- # return:: [Boolean] true if the Gem is loaded, otherwise false.
- #
- # raises:: [Gem::LoadError] if Gem cannot be found, is listed in
- # GEM_SKIP, or version requirement not met.
- #
- def gem(gem_name, *version_requirements)
- active_gem_with_options(gem_name, version_requirements)
- end
-
- # Return the file name (string) and line number (integer) of the caller of
- # the caller of this method.
- def location_of_caller
- file, lineno = caller[1].split(':')
- lineno = lineno.to_i
- [file, lineno]
- end
- private :location_of_caller
-
- def active_gem_with_options(gem_name, version_requirements, options={})
- skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
- raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
- Gem.activate(gem_name, options[:auto_require], *version_requirements)
- end
- private :active_gem_with_options
-end
-
-# Main module to hold all RubyGem classes/modules.
-#
-module Gem
-
- ConfigMap = {} unless defined?(ConfigMap)
- require 'rbconfig'
- RbConfig = Config unless defined? ::RbConfig
- ConfigMap.merge!(
- :BASERUBY => RbConfig::CONFIG["BASERUBY"],
- :EXEEXT => RbConfig::CONFIG["EXEEXT"],
- :RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
- :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
- :arch => RbConfig::CONFIG["arch"],
- :bindir => RbConfig::CONFIG["bindir"],
- :libdir => RbConfig::CONFIG["libdir"],
- :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
- :ruby_version => RbConfig::CONFIG["ruby_version"],
- :sitedir => RbConfig::CONFIG["sitedir"],
- :sitelibdir => RbConfig::CONFIG["sitelibdir"]
- )
-
- MUTEX = Mutex.new
-
- RubyGemsPackageVersion = RubyGemsVersion
-
- DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
-
- @@source_index = nil
- @@win_platform = nil
-
- @configuration = nil
- @loaded_specs = {}
- @platforms = nil
- @ruby = nil
- @sources = []
-
- # Reset the +dir+ and +path+ values. The next time +dir+ or +path+
- # is requested, the values will be calculated from scratch. This is
- # mainly used by the unit tests to provide test isolation.
- #
- def self.clear_paths
- @gem_home = nil
- @gem_path = nil
- @@source_index = nil
- MUTEX.synchronize do
- @searcher = nil
- end
- end
-
- # The version of the Marshal format for your Ruby.
- def self.marshal_version
- "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
- end
-
- ##
- # The directory prefix this RubyGems was installed at.
-
- def self.prefix
- prefix = File.dirname File.expand_path(__FILE__)
- if prefix == ConfigMap[:sitelibdir] then
- nil
- else
- File.dirname prefix
- end
- end
-
- # Returns an Cache of specifications that are in the Gem.path
- #
- # return:: [Gem::SourceIndex] Index of installed Gem::Specifications
- #
- def self.source_index
- @@source_index ||= SourceIndex.from_installed_gems
- end
-
- ##
- # An Array of Regexps that match windows ruby platforms.
-
- WIN_PATTERNS = [
- /bccwin/i,
- /cygwin/i,
- /djgpp/i,
- /mingw/i,
- /mswin/i,
- /wince/i,
- ]
-
- ##
- # Is this a windows platform?
-
- def self.win_platform?
- if @@win_platform.nil? then
- @@win_platform = !!WIN_PATTERNS.find { |r| RUBY_PLATFORM =~ r }
- end
-
- @@win_platform
- end
-
- class << self
-
- attr_reader :loaded_specs
-
- # Quietly ensure the named Gem directory contains all the proper
- # subdirectories. If we can't create a directory due to a permission
- # problem, then we will silently continue.
- def ensure_gem_subdirectories(gemdir)
- require 'fileutils'
-
- Gem::DIRECTORIES.each do |filename|
- fn = File.join gemdir, filename
- FileUtils.mkdir_p fn rescue nil unless File.exist? fn
- end
- end
-
- def platforms
- @platforms ||= [Gem::Platform::RUBY, Gem::Platform.local]
- end
-
- # Returns an Array of sources to fetch remote gems from. If the sources
- # list is empty, attempts to load the "sources" gem, then uses
- # default_sources if it is not installed.
- def sources
- if @sources.empty? then
- begin
- gem 'sources', '> 0.0.1'
- require 'sources'
- rescue LoadError
- @sources = default_sources
- end
- end
-
- @sources
- end
-
-
- # Provide an alias for the old name.
- alias cache source_index
-
- # The directory path where Gems are to be installed.
- #
- # return:: [String] The directory path
- #
- def dir
- @gem_home ||= nil
- set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
- @gem_home
- end
-
- # The directory path where executables are to be installed.
- #
- def bindir(install_dir=Gem.dir)
- return File.join(install_dir, 'bin') unless
- install_dir.to_s == Gem.default_dir
-
- if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
- '/usr/bin'
- else # generic install
- ConfigMap[:bindir]
- end
- end
-
- # List of directory paths to search for Gems.
- #
- # return:: [List<String>] List of directory paths.
- #
- def path
- @gem_path ||= nil
- unless @gem_path
- paths = [ENV['GEM_PATH']]
- paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
- set_paths(paths.compact.join(File::PATH_SEPARATOR))
- end
- @gem_path
- end
-
- # The home directory for the user.
- def user_home
- @user_home ||= find_home
- end
-
- # Return the path to standard location of the users .gemrc file.
- def config_file
- File.join(Gem.user_home, '.gemrc')
- end
-
- # The standard configuration object for gems.
- def configuration
- return @configuration if @configuration
- require 'rubygems/config_file'
- @configuration = Gem::ConfigFile.new []
- end
-
- # Use the given configuration object (which implements the
- # ConfigFile protocol) as the standard configuration object.
- def configuration=(config)
- @configuration = config
- end
-
- # Return the path the the data directory specified by the gem
- # name. If the package is not available as a gem, return nil.
- def datadir(gem_name)
- spec = @loaded_specs[gem_name]
- return nil if spec.nil?
- File.join(spec.full_gem_path, 'data', gem_name)
- end
-
- # Return the searcher object to search for matching gems.
- def searcher
- MUTEX.synchronize do
- @searcher ||= Gem::GemPathSearcher.new
- end
- end
-
- # Return the Ruby command to use to execute the Ruby interpreter.
- def ruby
- if @ruby.nil? then
- @ruby = File.join(ConfigMap[:bindir],
- ConfigMap[:ruby_install_name])
- @ruby << ConfigMap[:EXEEXT]
- end
-
- @ruby
- end
-
- # Activate a gem (i.e. add it to the Ruby load path). The gem
- # must satisfy all the specified version constraints. If
- # +autorequire+ is true, then automatically require the specified
- # autorequire file in the gem spec.
- #
- # Returns true if the gem is loaded by this call, false if it is
- # already loaded, or an exception otherwise.
- #
- def activate(gem, autorequire, *version_requirements)
- if version_requirements.empty? then
- version_requirements = Gem::Requirement.default
- end
-
- unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
- gem = Gem::Dependency.new(gem, version_requirements)
- end
-
- matches = Gem.source_index.find_name(gem.name, gem.version_requirements)
- report_activate_error(gem) if matches.empty?
-
- if @loaded_specs[gem.name]
- # This gem is already loaded. If the currently loaded gem is
- # not in the list of candidate gems, then we have a version
- # conflict.
- existing_spec = @loaded_specs[gem.name]
- if ! matches.any? { |spec| spec.version == existing_spec.version }
- fail Gem::Exception, "can't activate #{gem}, already activated #{existing_spec.full_name}]"
- end
- return false
- end
-
- # new load
- spec = matches.last
- if spec.loaded?
- return false unless autorequire
- result = spec.autorequire ? require(spec.autorequire) : false
- return result || false
- end
-
- spec.loaded = true
- @loaded_specs[spec.name] = spec
-
- # Load dependent gems first
- spec.dependencies.each do |dep_gem|
- activate(dep_gem, autorequire)
- end
-
- # bin directory must come before library directories
- spec.require_paths.unshift spec.bindir if spec.bindir
-
- require_paths = spec.require_paths.map do |path|
- File.join spec.full_gem_path, path
- end
-
- sitelibdir = ConfigMap[:sitelibdir]
- sitelibdir_index = $LOAD_PATH.index sitelibdir
-
- if sitelibdir_index then
- # gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(sitelibdir_index, *require_paths)
- else
- # we are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*require_paths)
- end
-
- # Now autorequire
- if autorequire && spec.autorequire then # DEPRECATED
- Array(spec.autorequire).each do |a_lib|
- require a_lib
- end
- end
-
- return true
- end
-
- # Report a load error during activation. The message of load
- # error depends on whether it was a version mismatch or if there
- # are not gems of any version by the requested name.
- def report_activate_error(gem)
- matches = Gem.source_index.find_name(gem.name)
-
- if matches.empty? then
- error = Gem::LoadError.new(
- "Could not find RubyGem #{gem.name} (#{gem.version_requirements})\n")
- else
- error = Gem::LoadError.new(
- "RubyGem version error: " +
- "#{gem.name}(#{matches.first.version} not #{gem.version_requirements})\n")
- end
-
- error.name = gem.name
- error.version_requirement = gem.version_requirements
- raise error
- end
- private :report_activate_error
-
- # Use the +home+ and (optional) +paths+ values for +dir+ and +path+.
- # Used mainly by the unit tests to provide environment isolation.
- #
- def use_paths(home, paths=[])
- clear_paths
- set_home(home) if home
- set_paths(paths.join(File::PATH_SEPARATOR)) if paths
- end
-
- # Return a list of all possible load paths for all versions for
- # all gems in the Gem installation.
- #
- def all_load_paths
- result = []
- Gem.path.each do |gemdir|
- each_load_path(all_partials(gemdir)) do |load_path|
- result << load_path
- end
- end
- result
- end
-
- # Return a list of all possible load paths for the latest version
- # for all gems in the Gem installation.
- def latest_load_paths
- result = []
- Gem.path.each do |gemdir|
- each_load_path(latest_partials(gemdir)) do |load_path|
- result << load_path
- end
- end
- result
- end
-
- def required_location(gemname, libfile, *version_constraints)
- version_constraints = Gem::Requirement.default if version_constraints.empty?
- matches = Gem.source_index.find_name(gemname, version_constraints)
- return nil if matches.empty?
- spec = matches.last
- spec.require_paths.each do |path|
- result = File.join(spec.full_gem_path, path, libfile)
- return result if File.exist?(result)
- end
- nil
- end
-
- def suffixes
- ['', '.rb', '.rbw', '.so', '.bundle', '.dll', '.sl', '.jar']
- end
-
- def suffix_pattern
- @suffix_pattern ||= "{#{suffixes.join(',')}}"
- end
-
- # manage_gems is useless and deprecated. Don't call it anymore. This
- # will warn in two releases.
- def manage_gems
- # do nothing
- end
-
- private
-
- # Return all the partial paths in the given +gemdir+.
- def all_partials(gemdir)
- Dir[File.join(gemdir, 'gems/*')]
- end
-
- # Return only the latest partial paths in the given +gemdir+.
- def latest_partials(gemdir)
- latest = {}
- all_partials(gemdir).each do |gp|
- base = File.basename(gp)
- if base =~ /(.*)-((\d+\.)*\d+)/ then
- name, version = $1, $2
- ver = Gem::Version.new(version)
- if latest[name].nil? || ver > latest[name][0]
- latest[name] = [ver, gp]
- end
- end
- end
- latest.collect { |k,v| v[1] }
- end
-
- # Expand each partial gem path with each of the required paths
- # specified in the Gem spec. Each expanded path is yielded.
- def each_load_path(partials)
- partials.each do |gp|
- base = File.basename(gp)
- specfn = File.join(dir, "specifications", base + ".gemspec")
- if File.exist?(specfn)
- spec = eval(File.read(specfn))
- spec.require_paths.each do |rp|
- yield(File.join(gp, rp))
- end
- else
- filename = File.join(gp, 'lib')
- yield(filename) if File.exist?(filename)
- end
- end
- end
-
- # Set the Gem home directory (as reported by +dir+).
- def set_home(home)
- @gem_home = home
- ensure_gem_subdirectories(@gem_home)
- end
-
- # Set the Gem search path (as reported by +path+).
- def set_paths(gpaths)
- if gpaths
- @gem_path = gpaths.split(File::PATH_SEPARATOR)
- @gem_path << Gem.dir
- else
- @gem_path = [Gem.dir]
- end
- @gem_path.uniq!
- @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
- end
-
- # Some comments from the ruby-talk list regarding finding the home
- # directory:
- #
- # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
- # to be depending on HOME in those code samples. I propose that
- # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
- # least on Win32).
- #
- def find_home
- ['HOME', 'USERPROFILE'].each do |homekey|
- return ENV[homekey] if ENV[homekey]
- end
- if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
- return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
- end
- begin
- File.expand_path("~")
- rescue StandardError => ex
- if File::ALT_SEPARATOR
- "C:/"
- else
- "/"
- end
- end
- end
-
- end
-
-end
-
-# Modify the non-gem version of datadir to handle gem package names.
-
-require 'rbconfig/datadir'
-module Config # :nodoc:
- class << self
- alias gem_original_datadir datadir
-
- # Return the path to the data directory associated with the named
- # package. If the package is loaded as a gem, return the gem
- # specific data directory. Otherwise return a path to the share
- # area as define by "#{ConfigMap[:datadir]}/#{package_name}".
- def datadir(package_name)
- Gem.datadir(package_name) || Config.gem_original_datadir(package_name)
- end
- end
-end
-
-require 'rubygems/exceptions'
-require 'rubygems/version'
-require 'rubygems/requirement'
-require 'rubygems/dependency'
-require 'rubygems/gem_path_searcher' # Needed for Kernel#gem
-require 'rubygems/source_index' # Needed for Kernel#gem
-require 'rubygems/platform'
-require 'rubygems/builder' # HACK: Needed for rake's package task.
-
-if RUBY_VERSION < '1.9' then
- require 'rubygems/custom_require'
-end
-
diff --git a/lib/rubygems/builder.rb b/lib/rubygems/builder.rb
deleted file mode 100644
index f7f07e86bf..0000000000
--- a/lib/rubygems/builder.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-module Gem
-
- ##
- # The Builder class processes RubyGem specification files
- # to produce a .gem file.
- #
- class Builder
-
- include UserInteraction
- ##
- # Constructs a builder instance for the provided specification
- #
- # spec:: [Gem::Specification] The specification instance
- #
- def initialize(spec)
- require "yaml"
- require "rubygems/package"
- require "rubygems/security"
-
- @spec = spec
- end
-
- ##
- # Builds the gem from the specification. Returns the name of the file
- # written.
- #
- def build
- @spec.mark_version
- @spec.validate
- @signer = sign
- write_package
- say success
- @spec.file_name
- end
-
- def success
- <<-EOM
- Successfully built RubyGem
- Name: #{@spec.name}
- Version: #{@spec.version}
- File: #{@spec.full_name+'.gem'}
-EOM
- end
-
- private
-
- def sign
- # if the signing key was specified, then load the file, and swap
- # to the public key (TODO: we should probably just omit the
- # signing key in favor of the signing certificate, but that's for
- # the future, also the signature algorithm should be configurable)
- signer = nil
- if @spec.respond_to?(:signing_key) && @spec.signing_key
- signer = Gem::Security::Signer.new(@spec.signing_key, @spec.cert_chain)
- @spec.signing_key = nil
- @spec.cert_chain = signer.cert_chain.map { |cert| cert.to_s }
- end
- signer
- end
-
- def write_package
- Package.open(@spec.file_name, "w", @signer) do |pkg|
- pkg.metadata = @spec.to_yaml
- @spec.files.each do |file|
- next if File.directory? file
- pkg.add_file_simple(file, File.stat(@spec.file_name).mode & 0777,
- File.size(file)) do |os|
- os.write File.open(file, "rb"){|f|f.read}
- end
- end
- end
- end
- end
-end
-
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
deleted file mode 100644
index 66855c7c6a..0000000000
--- a/lib/rubygems/command.rb
+++ /dev/null
@@ -1,406 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'optparse'
-
-require 'rubygems/user_interaction'
-
-module Gem
-
- # Base class for all Gem commands. When creating a new gem command, define
- # #arguments, #defaults_str, #description and #usage (as appropriate).
- class Command
-
- include UserInteraction
-
- # The name of the command.
- attr_reader :command
-
- # The options for the command.
- attr_reader :options
-
- # The default options for the command.
- attr_accessor :defaults
-
- # The name of the command for command-line invocation.
- attr_accessor :program_name
-
- # A short description of the command.
- attr_accessor :summary
-
- # Initializes a generic gem command named +command+. +summary+ is a short
- # description displayed in `gem help commands`. +defaults+ are the
- # default options. Defaults should be mirrored in #defaults_str, unless
- # there are none.
- #
- # Use add_option to add command-line switches.
- def initialize(command, summary=nil, defaults={})
- @command = command
- @summary = summary
- @program_name = "gem #{command}"
- @defaults = defaults
- @options = defaults.dup
- @option_groups = Hash.new { |h,k| h[k] = [] }
- @parser = nil
- @when_invoked = nil
- end
-
- # True if +long+ begins with the characters from +short+.
- def begins?(long, short)
- return false if short.nil?
- long[0, short.length] == short
- end
-
- # Override to provide command handling.
- def execute
- fail "Generic command has no actions"
- end
-
- # Get all gem names from the command line.
- def get_all_gem_names
- args = options[:args]
-
- if args.nil? or args.empty? then
- raise Gem::CommandLineError,
- "Please specify at least one gem name (e.g. gem build GEMNAME)"
- end
-
- gem_names = args.select { |arg| arg !~ /^-/ }
- end
-
- # Get the single gem name from the command line. Fail if there is no gem
- # name or if there is more than one gem name given.
- def get_one_gem_name
- args = options[:args]
-
- if args.nil? or args.empty? then
- raise Gem::CommandLineError,
- "Please specify a gem name on the command line (e.g. gem build GEMNAME)"
- end
-
- if args.size > 1 then
- raise Gem::CommandLineError,
- "Too many gem names (#{args.join(', ')}); please specify only one"
- end
-
- args.first
- end
-
- # Get a single optional argument from the command line. If more than one
- # argument is given, return only the first. Return nil if none are given.
- def get_one_optional_argument
- args = options[:args] || []
- args.first
- end
-
- # Override to provide details of the arguments a command takes.
- # It should return a left-justified string, one argument per line.
- def arguments
- ""
- end
-
- # Override to display the default values of the command
- # options. (similar to +arguments+, but displays the default
- # values).
- def defaults_str
- ""
- end
-
- # Override to display a longer description of what this command does.
- def description
- nil
- end
-
- # Override to display the usage for an individual gem command.
- def usage
- program_name
- end
-
- # Display the help message for the command.
- def show_help
- parser.program_name = usage
- say parser
- end
-
- # Invoke the command with the given list of arguments.
- def invoke(*args)
- handle_options(args)
- if options[:help]
- show_help
- elsif @when_invoked
- @when_invoked.call(options)
- else
- execute
- end
- end
-
- # Call the given block when invoked.
- #
- # Normal command invocations just executes the +execute+ method of
- # the command. Specifying an invocation block allows the test
- # methods to override the normal action of a command to determine
- # that it has been invoked correctly.
- def when_invoked(&block)
- @when_invoked = block
- end
-
- # Add a command-line option and handler to the command.
- #
- # See OptionParser#make_switch for an explanation of +opts+.
- #
- # +handler+ will be called with two values, the value of the argument and
- # the options hash.
- def add_option(*opts, &handler) # :yields: value, options
- group_name = Symbol === opts.first ? opts.shift : :options
-
- @option_groups[group_name] << [opts, handler]
- end
-
- # Remove previously defined command-line argument +name+.
- def remove_option(name)
- @option_groups.each do |_, option_list|
- option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } }
- end
- end
-
- # Merge a set of command options with the set of default options
- # (without modifying the default option hash).
- def merge_options(new_options)
- @options = @defaults.clone
- new_options.each do |k,v| @options[k] = v end
- end
-
- # True if the command handles the given argument list.
- def handles?(args)
- begin
- parser.parse!(args.dup)
- return true
- rescue
- return false
- end
- end
-
- # Handle the given list of arguments by parsing them and recording
- # the results.
- def handle_options(args)
- args = add_extra_args(args)
- @options = @defaults.clone
- parser.parse!(args)
- @options[:args] = args
- end
-
- def add_extra_args(args)
- result = []
- s_extra = Command.specific_extra_args(@command)
- extra = Command.extra_args + s_extra
- while ! extra.empty?
- ex = []
- ex << extra.shift
- ex << extra.shift if extra.first.to_s =~ /^[^-]/
- result << ex if handles?(ex)
- end
- result.flatten!
- result.concat(args)
- result
- end
-
- private
-
- # Create on demand parser.
- def parser
- create_option_parser if @parser.nil?
- @parser
- end
-
- def create_option_parser
- @parser = OptionParser.new
-
- @parser.separator("")
- regular_options = @option_groups.delete :options
-
- configure_options "", regular_options
-
- @option_groups.sort_by { |n,_| n.to_s }.each do |group_name, option_list|
- configure_options group_name, option_list
- end
-
- configure_options "Common", Command.common_options
-
- @parser.separator("")
- unless arguments.empty?
- @parser.separator(" Arguments:")
- arguments.split(/\n/).each do |arg_desc|
- @parser.separator(" #{arg_desc}")
- end
- @parser.separator("")
- end
-
- @parser.separator(" Summary:")
- wrap(@summary, 80 - 4).split("\n").each do |line|
- @parser.separator(" #{line.strip}")
- end
-
- if description then
- formatted = description.split("\n\n").map do |chunk|
- wrap(chunk, 80 - 4)
- end.join("\n")
-
- @parser.separator ""
- @parser.separator " Description:"
- formatted.split("\n").each do |line|
- @parser.separator " #{line.rstrip}"
- end
- end
-
- unless defaults_str.empty?
- @parser.separator("")
- @parser.separator(" Defaults:")
- defaults_str.split(/\n/).each do |line|
- @parser.separator(" #{line}")
- end
- end
- end
-
- def configure_options(header, option_list)
- return if option_list.nil? or option_list.empty?
-
- header = header.to_s.empty? ? '' : "#{header} "
- @parser.separator " #{header}Options:"
-
- option_list.each do |args, handler|
- dashes = args.select { |arg| arg =~ /^-/ }
- @parser.on(*args) do |value|
- handler.call(value, @options)
- end
- end
-
- @parser.separator ''
- end
-
- # Wraps +text+ to +width+
- def wrap(text, width)
- text.gsub(/(.{1,#{width}})( +|$\n?)|(.{1,#{width}})/, "\\1\\3\n")
- end
-
- ##################################################################
- # Class methods for Command.
- class << self
- def common_options
- @common_options ||= []
- end
-
- def add_common_option(*args, &handler)
- Gem::Command.common_options << [args, handler]
- end
-
- def extra_args
- @extra_args ||= []
- end
-
- def extra_args=(value)
- case value
- when Array
- @extra_args = value
- when String
- @extra_args = value.split
- end
- end
-
- # Return an array of extra arguments for the command. The extra
- # arguments come from the gem configuration file read at program
- # startup.
- def specific_extra_args(cmd)
- specific_extra_args_hash[cmd]
- end
-
- # Add a list of extra arguments for the given command. +args+
- # may be an array or a string to be split on white space.
- def add_specific_extra_args(cmd,args)
- args = args.split(/\s+/) if args.kind_of? String
- specific_extra_args_hash[cmd] = args
- end
-
- # Accessor for the specific extra args hash (self initializing).
- def specific_extra_args_hash
- @specific_extra_args_hash ||= Hash.new do |h,k|
- h[k] = Array.new
- end
- end
- end
-
- # ----------------------------------------------------------------
- # Add the options common to all commands.
-
- add_common_option('-h', '--help',
- 'Get help on this command') do
- |value, options|
- options[:help] = true
- end
-
- add_common_option('-V', '--[no-]verbose',
- 'Set the verbose level of output') do |value, options|
- # Set us to "really verbose" so the progess meter works
- if Gem.configuration.verbose and value then
- Gem.configuration.verbose = 1
- else
- Gem.configuration.verbose = value
- end
- end
-
- add_common_option('-q', '--quiet', 'Silence commands') do |value, options|
- Gem.configuration.verbose = false
- end
-
- # Backtrace and config-file are added so they show up in the help
- # commands. Both options are actually handled before the other
- # options get parsed.
-
- add_common_option('--config-file FILE',
- "Use this config file instead of default") do
- end
-
- add_common_option('--backtrace',
- 'Show stack backtrace on errors') do
- end
-
- add_common_option('--debug',
- 'Turn on Ruby debugging') do
- end
-
- # :stopdoc:
- HELP = %{
- RubyGems is a sophisticated package manager for Ruby. This is a
- basic help message containing pointers to more information.
-
- Usage:
- gem -h/--help
- gem -v/--version
- gem command [arguments...] [options...]
-
- Examples:
- gem install rake
- gem list --local
- gem build package.gemspec
- gem help install
-
- Further help:
- gem help commands list all 'gem' commands
- gem help examples show some examples of usage
- gem help platforms show information about platforms
- gem help <COMMAND> show help on COMMAND
- (e.g. 'gem help install')
- Further information:
- http://rubygems.rubyforge.org
- }.gsub(/^ /, "")
-
- # :startdoc:
-
- end # class
-
- # This is where Commands will be placed in the namespace
- module Commands; end
-
-end
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
deleted file mode 100644
index a80c821c5c..0000000000
--- a/lib/rubygems/command_manager.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'timeout'
-require 'rubygems/command'
-require 'rubygems/user_interaction'
-
-module Gem
-
- ####################################################################
- # The command manager registers and installs all the individual
- # sub-commands supported by the gem command.
- class CommandManager
- include UserInteraction
-
- # Return the authoratative instance of the command manager.
- def self.instance
- @command_manager ||= CommandManager.new
- end
-
- # Register all the subcommands supported by the gem command.
- def initialize
- @commands = {}
- register_command :build
- register_command :cert
- register_command :check
- register_command :cleanup
- register_command :contents
- register_command :dependency
- register_command :environment
- register_command :fetch
- register_command :generate_index
- register_command :help
- register_command :install
- register_command :list
- register_command :lock
- register_command :mirror
- register_command :outdated
- register_command :pristine
- register_command :query
- register_command :rdoc
- register_command :search
- register_command :server
- register_command :sources
- register_command :specification
- register_command :uninstall
- register_command :unpack
- register_command :update
- register_command :which
- end
-
- # Register the command object.
- def register_command(command_obj)
- @commands[command_obj] = false
- end
-
- # Return the registered command from the command name.
- def [](command_name)
- command_name = command_name.intern
- return nil if @commands[command_name].nil?
- @commands[command_name] ||= load_and_instantiate(command_name)
- end
-
- # Return a list of all command names (as strings).
- def command_names
- @commands.keys.collect {|key| key.to_s}.sort
- end
-
- # Run the config specificed by +args+.
- def run(args)
- process_args(args)
- rescue StandardError, Timeout::Error => ex
- alert_error "While executing gem ... (#{ex.class})\n #{ex.to_s}"
- ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
- Gem.configuration.backtrace
- terminate_interaction(1)
- rescue Interrupt
- alert_error "Interrupted"
- terminate_interaction(1)
- end
-
- def process_args(args)
- args = args.to_str.split(/\s+/) if args.respond_to?(:to_str)
- if args.size == 0
- say Gem::Command::HELP
- terminate_interaction(1)
- end
- case args[0]
- when '-h', '--help'
- say Gem::Command::HELP
- terminate_interaction(0)
- when '-v', '--version'
- say Gem::RubyGemsPackageVersion
- terminate_interaction(0)
- when /^-/
- alert_error "Invalid option: #{args[0]}. See 'gem --help'."
- terminate_interaction(1)
- else
- cmd_name = args.shift.downcase
- cmd = find_command(cmd_name)
- cmd.invoke(*args)
- end
- end
-
- def find_command(cmd_name)
- possibilities = find_command_possibilities(cmd_name)
- if possibilities.size > 1
- raise "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
- end
- if possibilities.size < 1
- raise "Unknown command #{cmd_name}"
- end
-
- self[possibilities.first]
- end
-
- def find_command_possibilities(cmd_name)
- len = cmd_name.length
- self.command_names.select { |n| cmd_name == n[0,len] }
- end
-
- private
- def load_and_instantiate(command_name)
- command_name = command_name.to_s
- retried = false
-
- begin
- const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase }
- Gem::Commands.const_get("#{const_name}Command").new
- rescue NameError
- if retried then
- raise
- else
- retried = true
- require "rubygems/commands/#{command_name}_command"
- retry
- end
- end
- end
- end
-end
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
deleted file mode 100644
index e1f0122c6c..0000000000
--- a/lib/rubygems/commands/build_command.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/builder'
-
-class Gem::Commands::BuildCommand < Gem::Command
-
- def initialize
- super('build', 'Build a gem from a gemspec')
- end
-
- def arguments # :nodoc:
- "GEMSPEC_FILE gemspec file name to build a gem for"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMSPEC_FILE"
- end
-
- def execute
- gemspec = get_one_gem_name
- if File.exist?(gemspec)
- specs = load_gemspecs(gemspec)
- specs.each do |spec|
- Gem::Builder.new(spec).build
- end
- else
- alert_error "Gemspec file not found: #{gemspec}"
- end
- end
-
- def load_gemspecs(filename)
- if yaml?(filename)
- result = []
- open(filename) do |f|
- begin
- while not f.eof? and spec = Gem::Specification.from_yaml(f)
- result << spec
- end
- rescue Gem::EndOfYAMLException => e
- # OK
- end
- end
- else
- result = [Gem::Specification.load(filename)]
- end
- result
- end
-
- def yaml?(filename)
- line = open(filename) { |f| line = f.gets }
- result = line =~ %r{!ruby/object:Gem::Specification}
- result
- end
-end
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
deleted file mode 100644
index 2c32099254..0000000000
--- a/lib/rubygems/commands/cert_command.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/security'
-
-class Gem::Commands::CertCommand < Gem::Command
-
- def initialize
- super 'cert', 'Manage RubyGems certificates and signing settings'
-
- add_option('-a', '--add CERT',
- 'Add a trusted certificate.') do |value, options|
- cert = OpenSSL::X509::Certificate.new(File.read(value))
- Gem::Security.add_trusted_cert(cert)
- say "Added '#{cert.subject.to_s}'"
- end
-
- add_option('-l', '--list',
- 'List trusted certificates.') do |value, options|
- glob_str = File::join(Gem::Security::OPT[:trust_dir], '*.pem')
- Dir::glob(glob_str) do |path|
- begin
- cert = OpenSSL::X509::Certificate.new(File.read(path))
- # this could proably be formatted more gracefully
- say cert.subject.to_s
- rescue OpenSSL::X509::CertificateError
- next
- end
- end
- end
-
- add_option('-r', '--remove STRING',
- 'Remove trusted certificates containing',
- 'STRING.') do |value, options|
- trust_dir = Gem::Security::OPT[:trust_dir]
- glob_str = File::join(trust_dir, '*.pem')
-
- Dir::glob(glob_str) do |path|
- begin
- cert = OpenSSL::X509::Certificate.new(File.read(path))
- if cert.subject.to_s.downcase.index(value)
- say "Removed '#{cert.subject.to_s}'"
- File.unlink(path)
- end
- rescue OpenSSL::X509::CertificateError
- next
- end
- end
- end
-
- add_option('-b', '--build EMAIL_ADDR',
- 'Build private key and self-signed',
- 'certificate for EMAIL_ADDR.') do |value, options|
- vals = Gem::Security.build_self_signed_cert(value)
- File.chmod 0600, vals[:key_path]
- say "Public Cert: #{vals[:cert_path]}"
- say "Private Key: #{vals[:key_path]}"
- say "Don't forget to move the key file to somewhere private..."
- end
-
- add_option('-C', '--certificate CERT',
- 'Certificate for --sign command.') do |value, options|
- cert = OpenSSL::X509::Certificate.new(File.read(value))
- Gem::Security::OPT[:issuer_cert] = cert
- end
-
- add_option('-K', '--private-key KEY',
- 'Private key for --sign command.') do |value, options|
- key = OpenSSL::PKey::RSA.new(File.read(value))
- Gem::Security::OPT[:issuer_key] = key
- end
-
- add_option('-s', '--sign NEWCERT',
- 'Sign a certificate with my key and',
- 'certificate.') do |value, options|
- cert = OpenSSL::X509::Certificate.new(File.read(value))
- my_cert = Gem::Security::OPT[:issuer_cert]
- my_key = Gem::Security::OPT[:issuer_key]
- cert = Gem::Security.sign_cert(cert, my_key, my_cert)
- File.open(value, 'wb') { |file| file.write(cert.to_pem) }
- end
- end
-
- def execute
- end
-
-end
-
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
deleted file mode 100644
index ca5e14b12d..0000000000
--- a/lib/rubygems/commands/check_command.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/version_option'
-require 'rubygems/validator'
-
-class Gem::Commands::CheckCommand < Gem::Command
-
- include Gem::VersionOption
-
- def initialize
- super 'check', 'Check installed gems',
- :verify => false, :alien => false
-
- add_option( '--verify FILE',
- 'Verify gem file against its internal',
- 'checksum') do |value, options|
- options[:verify] = value
- end
-
- add_option('-a', '--alien', "Report 'unmanaged' or rogue files in the",
- "gem repository") do |value, options|
- options[:alien] = true
- end
-
- add_option('-t', '--test', "Run unit tests for gem") do |value, options|
- options[:test] = true
- end
-
- add_version_option 'run tests for'
- end
-
- def execute
- if options[:test]
- version = options[:version] || Gem::Requirement.default
- gem_spec = Gem::SourceIndex.from_installed_gems.search(get_one_gem_name, version).first
- Gem::Validator.new.unit_test(gem_spec)
- end
-
- if options[:alien]
- say "Performing the 'alien' operation"
- Gem::Validator.new.alien.each do |key, val|
- if(val.size > 0)
- say "#{key} has #{val.size} problems"
- val.each do |error_entry|
- say "\t#{error_entry.path}:"
- say "\t#{error_entry.problem}"
- say
- end
- else
- say "#{key} is error-free"
- end
- say
- end
- end
-
- if options[:verify]
- gem_name = options[:verify]
- unless gem_name
- alert_error "Must specify a .gem file with --verify NAME"
- return
- end
- unless File.exist?(gem_name)
- alert_error "Unknown file: #{gem_name}."
- return
- end
- say "Verifying gem: '#{gem_name}'"
- begin
- Gem::Validator.new.verify_gem_file(gem_name)
- rescue Exception => e
- alert_error "#{gem_name} is invalid."
- end
- end
- end
-
-end
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
deleted file mode 100644
index f6deac9829..0000000000
--- a/lib/rubygems/commands/cleanup_command.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/source_index'
-require 'rubygems/dependency_list'
-
-module Gem
- module Commands
- class CleanupCommand < Command
- def initialize
- super(
- 'cleanup',
- 'Clean up old versions of installed gems in the local repository',
- {
- :force => false,
- :test => false,
- :install_dir => Gem.dir
- })
- add_option('-d', '--dryrun', "") do |value, options|
- options[:dryrun] = true
- end
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to cleanup"
- end
-
- def defaults_str # :nodoc:
- "--no-dryrun"
- end
-
- def usage # :nodoc:
- "#{program_name} [GEMNAME ...]"
- end
-
- def execute
- say "Cleaning up installed gems..."
- srcindex = Gem::SourceIndex.from_installed_gems
- primary_gems = {}
-
- srcindex.each do |name, spec|
- if primary_gems[spec.name].nil? or primary_gems[spec.name].version < spec.version
- primary_gems[spec.name] = spec
- end
- end
-
- gems_to_cleanup = []
-
- unless options[:args].empty? then
- options[:args].each do |gem_name|
- specs = Gem.cache.search(/^#{gem_name}$/i)
- specs.each do |spec|
- gems_to_cleanup << spec
- end
- end
- else
- srcindex.each do |name, spec|
- gems_to_cleanup << spec
- end
- end
-
- gems_to_cleanup = gems_to_cleanup.select { |spec|
- primary_gems[spec.name].version != spec.version
- }
-
- uninstall_command = Gem::CommandManager.instance['uninstall']
- deplist = DependencyList.new
- gems_to_cleanup.uniq.each do |spec| deplist.add(spec) end
-
- deplist.dependency_order.each do |spec|
- if options[:dryrun] then
- say "Dry Run Mode: Would uninstall #{spec.full_name}"
- else
- say "Attempting uninstall on #{spec.full_name}"
-
- options[:args] = [spec.name]
- options[:version] = "= #{spec.version}"
- options[:executables] = true
-
- uninstall_command.merge_options(options)
-
- begin
- uninstall_command.execute
- rescue Gem::DependencyRemovalException => ex
- say "Unable to uninstall #{spec.full_name} ... continuing with remaining gems"
- end
- end
- end
-
- say "Clean Up Complete"
- end
- end
-
- end
-end
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
deleted file mode 100644
index 5060403fd8..0000000000
--- a/lib/rubygems/commands/contents_command.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/version_option'
-
-class Gem::Commands::ContentsCommand < Gem::Command
-
- include Gem::VersionOption
-
- def initialize
- super 'contents', 'Display the contents of the installed gems',
- :specdirs => [], :lib_only => false
-
- add_version_option
-
- add_option('-s', '--spec-dir a,b,c', Array,
- "Search for gems under specific paths") do |spec_dirs, options|
- options[:specdirs] = spec_dirs
- end
-
- add_option('-l', '--[no-]lib-only',
- "Only return files in the Gem's lib_dirs") do |lib_only, options|
- options[:lib_only] = lib_only
- end
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to list contents for"
- end
-
- def defaults_str # :nodoc:
- "--no-lib-only"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME"
- end
-
- def execute
- version = options[:version] || Gem::Requirement.default
- gem = get_one_gem_name
-
- s = options[:specdirs].map do |i|
- [i, File.join(i, "specifications")]
- end.flatten
-
- path_kind = if s.empty? then
- s = Gem::SourceIndex.installed_spec_directories
- "default gem paths"
- else
- "specified path"
- end
-
- si = Gem::SourceIndex.from_gems_in(*s)
-
- gem_spec = si.search(/\A#{gem}\z/, version).last
-
- unless gem_spec then
- say "Unable to find gem '#{gem}' in #{path_kind}"
-
- if Gem.configuration.verbose then
- say "\nDirectories searched:"
- s.each { |dir| say dir }
- end
-
- terminate_interaction
- end
-
- files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
- files.each do |f|
- say File.join(gem_spec.full_gem_path, f)
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
deleted file mode 100644
index 1a43505d7c..0000000000
--- a/lib/rubygems/commands/dependency_command.rb
+++ /dev/null
@@ -1,150 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/local_remote_options'
-require 'rubygems/version_option'
-require 'rubygems/source_info_cache'
-
-class Gem::Commands::DependencyCommand < Gem::Command
-
- include Gem::LocalRemoteOptions
- include Gem::VersionOption
-
- def initialize
- super 'dependency',
- 'Show the dependencies of an installed gem',
- :version => Gem::Requirement.default, :domain => :local
-
- add_version_option
- add_platform_option
-
- add_option('-R', '--[no-]reverse-dependencies',
- 'Include reverse dependencies in the output') do
- |value, options|
- options[:reverse_dependencies] = value
- end
-
- add_option('-p', '--pipe',
- "Pipe Format (name --version ver)") do |value, options|
- options[:pipe_format] = value
- end
-
- add_local_remote_options
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to show dependencies for"
- end
-
- def defaults_str # :nodoc:
- "--local --version '#{Gem::Requirement.default}' --no-reverse-dependencies"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME"
- end
-
- def execute
- options[:args] << '.' if options[:args].empty?
- specs = {}
-
- source_indexes = []
-
- if local? then
- source_indexes << Gem::SourceIndex.from_installed_gems
- end
-
- if remote? then
- Gem::SourceInfoCache.cache_data.map do |_, sice|
- source_indexes << sice.source_index
- end
- end
-
- options[:args].each do |name|
- new_specs = nil
- source_indexes.each do |source_index|
- new_specs = find_gems(name, source_index)
- end
-
- say "No match found for #{name} (#{options[:version]})" if
- new_specs.empty?
-
- specs = specs.merge new_specs
- end
-
- terminate_interaction 1 if specs.empty?
-
- reverse = Hash.new { |h, k| h[k] = [] }
-
- if options[:reverse_dependencies] then
- specs.values.each do |source_index, spec|
- reverse[spec.full_name] = find_reverse_dependencies spec, source_index
- end
- end
-
- if options[:pipe_format] then
- specs.values.sort_by { |_, spec| spec }.each do |_, spec|
- unless spec.dependencies.empty?
- spec.dependencies.each do |dep|
- say "#{dep.name} --version '#{dep.version_requirements}'"
- end
- end
- end
- else
- response = ''
-
- specs.values.sort_by { |_, spec| spec }.each do |_, spec|
- response << print_dependencies(spec)
- unless reverse[spec.full_name].empty? then
- response << " Used by\n"
- reverse[spec.full_name].each do |sp, dep|
- response << " #{sp} (#{dep})\n"
- end
- end
- response << "\n"
- end
-
- say response
- end
- end
-
- def print_dependencies(spec, level = 0)
- response = ''
- response << ' ' * level + "Gem #{spec.full_name}\n"
- unless spec.dependencies.empty? then
- spec.dependencies.each do |dep|
- response << ' ' * level + " #{dep}\n"
- end
- end
- response
- end
-
- # Retuns list of [specification, dep] that are satisfied by spec.
- def find_reverse_dependencies(spec, source_index)
- result = []
-
- source_index.each do |name, sp|
- sp.dependencies.each do |dep|
- dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
-
- if spec.name == dep.name and
- dep.version_requirements.satisfied_by?(spec.version) then
- result << [sp.full_name, dep]
- end
- end
- end
-
- result
- end
-
- def find_gems(name, source_index)
- specs = {}
-
- spec_list = source_index.search name, options[:version]
-
- spec_list.each do |spec|
- specs[spec.full_name] = [source_index, spec]
- end
-
- specs
- end
-end
-
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
deleted file mode 100644
index 337d74893b..0000000000
--- a/lib/rubygems/commands/environment_command.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'rubygems/command'
-
-class Gem::Commands::EnvironmentCommand < Gem::Command
-
- def initialize
- super 'environment', 'Display information about the RubyGems environment'
- end
-
- def arguments # :nodoc:
- args = <<-EOF
- packageversion display the package version
- gemdir display the path where gems are installed
- gempath display path used to search for gems
- version display the gem format version
- remotesources display the remote gem servers
- <omitted> display everything
- EOF
- return args.gsub(/^\s+/, '')
- end
-
- def usage # :nodoc:
- "#{program_name} [arg]"
- end
-
- def execute
- out = ''
- arg = options[:args][0]
- if begins?("packageversion", arg) then
- out << Gem::RubyGemsPackageVersion
- elsif begins?("version", arg) then
- out << Gem::RubyGemsVersion
- elsif begins?("gemdir", arg) then
- out << Gem.dir
- elsif begins?("gempath", arg) then
- out << Gem.path.join("\n")
- elsif begins?("remotesources", arg) then
- out << Gem.sources.join("\n")
- elsif arg then
- fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
- else
- out = "RubyGems Environment:\n"
-
- out << " - RUBYGEMS VERSION: #{Gem::RubyGemsVersion} (#{Gem::RubyGemsPackageVersion})\n"
-
- out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
- out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
- out << ") [#{RUBY_PLATFORM}]\n"
-
- out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
-
- out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
-
- out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
-
- out << " - RUBYGEMS PLATFORMS:\n"
- Gem.platforms.each do |platform|
- out << " - #{platform}\n"
- end
-
- out << " - GEM PATHS:\n"
- Gem.path.each do |p|
- out << " - #{p}\n"
- end
-
- out << " - GEM CONFIGURATION:\n"
- Gem.configuration.each do |name, value|
- out << " - #{name.inspect} => #{value.inspect}\n"
- end
-
- out << " - REMOTE SOURCES:\n"
- Gem.sources.each do |s|
- out << " - #{s}\n"
- end
- end
- say out
- true
- end
-
-end
-
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
deleted file mode 100644
index 7db365eba0..0000000000
--- a/lib/rubygems/commands/fetch_command.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/local_remote_options'
-require 'rubygems/version_option'
-require 'rubygems/source_info_cache'
-
-class Gem::Commands::FetchCommand < Gem::Command
-
- include Gem::LocalRemoteOptions
- include Gem::VersionOption
-
- def initialize
- super 'fetch', 'Download a gem and place it in the current directory'
-
- add_bulk_threshold_option
- add_proxy_option
- add_source_option
-
- add_version_option
- add_platform_option
- end
-
- def arguments # :nodoc:
- 'GEMNAME name of gem to download'
- end
-
- def defaults_str # :nodoc:
- "--version '#{Gem::Requirement.default}'"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME [GEMNAME ...]"
- end
-
- def execute
- version = options[:version] || Gem::Requirement.default
-
- gem_names = get_all_gem_names
-
- gem_names.each do |gem_name|
- dep = Gem::Dependency.new gem_name, version
- specs_and_sources = Gem::SourceInfoCache.search_with_source dep, true
-
- specs_and_sources.sort_by { |spec,| spec.version }
-
- spec, source_uri = specs_and_sources.last
-
- gem_file = "#{spec.full_name}.gem"
-
- gem_path = File.join source_uri, 'gems', gem_file
-
- gem = Gem::RemoteFetcher.fetcher.fetch_path gem_path
-
- File.open gem_file, 'wb' do |fp|
- fp.write gem
- end
-
- say "Downloaded #{gem_file}"
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
deleted file mode 100644
index 1bd87569ed..0000000000
--- a/lib/rubygems/commands/generate_index_command.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/indexer'
-
-class Gem::Commands::GenerateIndexCommand < Gem::Command
-
- def initialize
- super 'generate_index',
- 'Generates the index files for a gem server directory',
- :directory => '.'
-
- add_option '-d', '--directory=DIRNAME',
- 'repository base dir containing gems subdir' do |dir, options|
- options[:directory] = File.expand_path dir
- end
- end
-
- def defaults_str # :nodoc:
- "--directory ."
- end
-
- def description # :nodoc:
- <<-EOF
-The generate_index command creates a set of indexes for serving gems
-statically. The command expects a 'gems' directory under the path given to
-the --directory option. When done, it will generate a set of files like this:
-
- gems/ # .gem files you want to index
- quick/index
- quick/index.rz # quick index manifest
- quick/<gemname>.gemspec.rz # legacy YAML quick index file
- quick/Marshal.<version>/<gemname>.gemspec.rz # Marshal quick index file
- Marshal.<version>
- Marshal.<version>.Z # Marshal full index
- yaml
- yaml.Z # legacy YAML full index
-
-The .Z and .rz extension files are compressed with the inflate algorithm. The
-Marshal version number comes from ruby's Marshal::MAJOR_VERSION and
-Marshal::MINOR_VERSION constants. It is used to ensure compatibility. The
-yaml indexes exist for legacy RubyGems clients and fallback in case of Marshal
-version changes.
- EOF
- end
-
- def execute
- if not File.exist?(options[:directory]) or
- not File.directory?(options[:directory]) then
- alert_error "unknown directory name #{directory}."
- terminate_interaction 1
- else
- indexer = Gem::Indexer.new options[:directory]
- indexer.generate_index
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
deleted file mode 100644
index 05ea3f7a71..0000000000
--- a/lib/rubygems/commands/help_command.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-require 'rubygems/command'
-
-class Gem::Commands::HelpCommand < Gem::Command
-
- # :stopdoc:
- EXAMPLES = <<-EOF
-Some examples of 'gem' usage.
-
-* Install 'rake', either from local directory or remote server:
-
- gem install rake
-
-* Install 'rake', only from remote server:
-
- gem install rake --remote
-
-* Install 'rake' from remote server, and run unit tests,
- and generate RDocs:
-
- gem install --remote rake --test --rdoc --ri
-
-* Install 'rake', but only version 0.3.1, even if dependencies
- are not met, and into a specific directory:
-
- gem install rake --version 0.3.1 --force --install-dir $HOME/.gems
-
-* List local gems whose name begins with 'D':
-
- gem list D
-
-* List local and remote gems whose name contains 'log':
-
- gem search log --both
-
-* List only remote gems whose name contains 'log':
-
- gem search log --remote
-
-* Uninstall 'rake':
-
- gem uninstall rake
-
-* Create a gem:
-
- See http://rubygems.rubyforge.org/wiki/wiki.pl?CreateAGemInTenMinutes
-
-* See information about RubyGems:
-
- gem environment
-
-* Update all gems on your system:
-
- gem update
- EOF
-
- PLATFORMS = <<-'EOF'
-RubyGems platforms are composed of three parts, a CPU, an OS, and a
-version. These values are taken from values in rbconfig.rb. You can view
-your current platform by running `gem environment`.
-
-RubyGems matches platforms as follows:
-
- * The CPU must match exactly, unless one of the platforms has
- "universal" as the CPU.
- * The OS must match exactly.
- * The versions must match exactly unless one of the versions is nil.
-
-For commands that install, uninstall and list gems, you can override what
-RubyGems thinks your platform is with the --platform option. The platform
-you pass must match "#{cpu}-#{os}" or "#{cpu}-#{os}-#{version}". On mswin
-platforms, the version is the compiler version, not the OS version. (Ruby
-compiled with VC6 uses "60" as the compiler version, VC8 uses "80".)
-
-Example platforms:
-
- x86-freebsd # Any FreeBSD version on an x86 CPU
- universal-darwin-8 # Darwin 8 only gems that run on any CPU
- x86-mswin32-80 # Windows gems compiled with VC8
-
-When building platform gems, set the platform in the gem specification to
-Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
-platform.
- EOF
- # :startdoc:
-
- def initialize
- super 'help', "Provide help on the 'gem' command"
- end
-
- def arguments # :nodoc:
- args = <<-EOF
- commands List all 'gem' commands
- examples Show examples of 'gem' usage
- <command> Show specific help for <command>
- EOF
- return args.gsub(/^\s+/, '')
- end
-
- def usage # :nodoc:
- "#{program_name} ARGUMENT"
- end
-
- def execute
- command_manager = Gem::CommandManager.instance
- arg = options[:args][0]
-
- if begins? "commands", arg then
- out = []
- out << "GEM commands are:"
- out << nil
-
- margin_width = 4
-
- desc_width = command_manager.command_names.map { |n| n.size }.max + 4
-
- summary_width = 80 - margin_width - desc_width
- wrap_indent = ' ' * (margin_width + desc_width)
- format = "#{' ' * margin_width}%-#{desc_width}s%s"
-
- command_manager.command_names.each do |cmd_name|
- summary = command_manager[cmd_name].summary
- summary = wrap(summary, summary_width).split "\n"
- out << sprintf(format, cmd_name, summary.shift)
- until summary.empty? do
- out << "#{wrap_indent}#{summary.shift}"
- end
- end
-
- out << nil
- out << "For help on a particular command, use 'gem help COMMAND'."
- out << nil
- out << "Commands may be abbreviated, so long as they are unambiguous."
- out << "e.g. 'gem i rake' is short for 'gem install rake'."
-
- say out.join("\n")
-
- elsif begins? "options", arg then
- say Gem::Command::HELP
-
- elsif begins? "examples", arg then
- say EXAMPLES
-
- elsif begins? "platforms", arg then
- say PLATFORMS
-
- elsif options[:help] then
- command = command_manager[options[:help]]
- if command
- # help with provided command
- command.invoke("--help")
- else
- alert_error "Unknown command #{options[:help]}. Try 'gem help commands'"
- end
-
- elsif arg then
- possibilities = command_manager.find_command_possibilities(arg.downcase)
- if possibilities.size == 1
- command = command_manager[possibilities.first]
- command.invoke("--help")
- elsif possibilities.size > 1
- alert_warning "Ambiguous command #{arg} (#{possibilities.join(', ')})"
- else
- alert_warning "Unknown command #{arg}. Try gem help commands"
- end
-
- else
- say Gem::Command::HELP
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
deleted file mode 100644
index aa9f480c2a..0000000000
--- a/lib/rubygems/commands/install_command.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/doc_manager'
-require 'rubygems/install_update_options'
-require 'rubygems/dependency_installer'
-require 'rubygems/local_remote_options'
-require 'rubygems/validator'
-require 'rubygems/version_option'
-
-class Gem::Commands::InstallCommand < Gem::Command
-
- include Gem::VersionOption
- include Gem::LocalRemoteOptions
- include Gem::InstallUpdateOptions
-
- def initialize
- defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
- :generate_rdoc => true,
- :generate_ri => true,
- :install_dir => Gem.dir,
- :format_executable => false,
- :test => false,
- :version => Gem::Requirement.default,
- })
-
- super 'install', 'Install a gem into the local repository', defaults
-
- add_install_update_options
- add_local_remote_options
- add_platform_option
- add_version_option
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to install"
- end
-
- def defaults_str # :nodoc:
- "--both --version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \
- "--no-test --install-dir #{Gem.dir}"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags"
- end
-
- def execute
- if options[:include_dependencies] then
- alert "`gem install -y` is now default and will be removed"
- alert "use --ignore-dependencies to install only the gems you list"
- end
-
- installed_gems = []
-
- ENV['GEM_PATH'] = options[:install_dir] # HACK what does this do?
-
- install_options = {
- :env_shebang => options[:env_shebang],
- :domain => options[:domain],
- :force => options[:force],
- :format_executable => options[:format_executable],
- :ignore_dependencies => options[:ignore_dependencies],
- :install_dir => options[:install_dir],
- :security_policy => options[:security_policy],
- :wrappers => options[:wrappers],
- }
-
- get_all_gem_names.each do |gem_name|
- begin
- inst = Gem::DependencyInstaller.new gem_name, options[:version],
- install_options
- inst.install
-
- inst.installed_gems.each do |spec|
- say "Successfully installed #{spec.full_name}"
- end
-
- installed_gems.push(*inst.installed_gems)
- rescue Gem::InstallError => e
- alert_error "Error installing #{gem_name}:\n\t#{e.message}"
- rescue Gem::GemNotFoundException => e
- alert_error e.message
-# rescue => e
-# # TODO: Fix this handle to allow the error to propagate to
-# # the top level handler. Examine the other errors as
-# # well. This implementation here looks suspicious to me --
-# # JimWeirich (4/Jan/05)
-# alert_error "Error installing gem #{gem_name}: #{e.message}"
-# return
- end
- end
-
- unless installed_gems.empty? then
- gems = installed_gems.length == 1 ? 'gem' : 'gems'
- say "#{installed_gems.length} #{gems} installed"
- end
-
- # NOTE: *All* of the RI documents must be generated first.
- # For some reason, RI docs cannot be generated after any RDoc
- # documents are generated.
-
- if options[:generate_ri] then
- installed_gems.each do |gem|
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
- end
- end
-
- if options[:generate_rdoc] then
- installed_gems.each do |gem|
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
- end
- end
-
- if options[:test] then
- installed_gems.each do |spec|
- gem_spec = Gem::SourceIndex.from_installed_gems.search(spec.name, spec.version.version).first
- result = Gem::Validator.new.unit_test(gem_spec)
- if result and not result.passed?
- unless ask_yes_no("...keep Gem?", true) then
- Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall
- end
- end
- end
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
deleted file mode 100644
index e179ff57ee..0000000000
--- a/lib/rubygems/commands/list_command.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/commands/query_command'
-
-module Gem
- module Commands
- class ListCommand < QueryCommand
-
- def initialize
- super(
- 'list',
- 'Display all gems whose name starts with STRING'
- )
- remove_option('--name-matches')
- end
-
- def arguments # :nodoc:
- "STRING start of gem name to look for"
- end
-
- def defaults_str # :nodoc:
- "--local --no-details"
- end
-
- def usage # :nodoc:
- "#{program_name} [STRING]"
- end
-
- def execute
- string = get_one_optional_argument || ''
- options[:name] = /^#{string}/i
- super
- end
- end
- end
-end
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
deleted file mode 100644
index 3a3dcc0c6b..0000000000
--- a/lib/rubygems/commands/lock_command.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-require 'rubygems/command'
-
-class Gem::Commands::LockCommand < Gem::Command
-
- def initialize
- super 'lock', 'Generate a lockdown list of gems',
- :strict => false
-
- add_option '-s', '--[no-]strict',
- 'fail if unable to satisfy a dependency' do |strict, options|
- options[:strict] = strict
- end
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to lock\nVERSION version of gem to lock"
- end
-
- def defaults_str # :nodoc:
- "--no-strict"
- end
-
- def description # :nodoc:
- <<-EOF
-The lock command will generate a list of +gem+ statements that will lock down
-the versions for the gem given in the command line. It will specify exact
-versions in the requirements list to ensure that the gems loaded will always
-be consistent. A full recursive search of all effected gems will be
-generated.
-
-Example:
-
- gemlock rails-1.0.0 > lockdown.rb
-
-will produce in lockdown.rb:
-
- require "rubygems"
- gem 'rails', '= 1.0.0'
- gem 'rake', '= 0.7.0.1'
- gem 'activesupport', '= 1.2.5'
- gem 'activerecord', '= 1.13.2'
- gem 'actionpack', '= 1.11.2'
- gem 'actionmailer', '= 1.1.5'
- gem 'actionwebservice', '= 1.0.0'
-
-Just load lockdown.rb from your application to ensure that the current
-versions are loaded. Make sure that lockdown.rb is loaded *before* any
-other require statements.
-
-Notice that rails 1.0.0 only requires that rake 0.6.2 or better be used.
-Rake-0.7.0.1 is the most recent version installed that satisfies that, so we
-lock it down to the exact version.
- EOF
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME-VERSION [GEMNAME-VERSION ...]"
- end
-
- def complain(message)
- if options.strict then
- raise message
- else
- say "# #{message}"
- end
- end
-
- def execute
- say 'require "rubygems"'
-
- locked = {}
-
- pending = options[:args]
-
- until pending.empty? do
- full_name = pending.shift
-
- spec = Gem::SourceIndex.load_specification spec_path(full_name)
-
- say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name]
- locked[spec.name] = true
-
- spec.dependencies.each do |dep|
- next if locked[dep.name]
- candidates = Gem.source_index.search dep.name, dep.requirement_list
-
- if candidates.empty? then
- complain "Unable to satisfy '#{dep}' from currently installed gems."
- else
- pending << candidates.last.full_name
- end
- end
- end
- end
-
- def spec_path(gem_full_name)
- File.join Gem.path, "specifications", "#{gem_full_name }.gemspec"
- end
-
-end
-
diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb
deleted file mode 100644
index fc4f086ad3..0000000000
--- a/lib/rubygems/commands/mirror_command.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-require 'yaml'
-require 'zlib'
-
-require 'rubygems/command'
-require 'rubygems/gem_open_uri'
-
-class Gem::Commands::MirrorCommand < Gem::Command
-
- def initialize
- super 'mirror', 'Mirror a gem repository'
- end
-
- def description # :nodoc:
- <<-EOF
-The mirror command uses the ~/.gemmirrorrc config file to mirror remote gem
-repositories to a local path. The config file is a YAML document that looks
-like this:
-
- ---
- - from: http://gems.example.com # source repository URI
- to: /path/to/mirror # destination directory
-
-Multiple sources and destinations may be specified.
- EOF
- end
-
- def execute
- config_file = File.join Gem.user_home, '.gemmirrorrc'
-
- raise "Config file #{config_file} not found" unless File.exist? config_file
-
- mirrors = YAML.load_file config_file
-
- raise "Invalid config file #{config_file}" unless mirrors.respond_to? :each
-
- mirrors.each do |mir|
- raise "mirror missing 'from' field" unless mir.has_key? 'from'
- raise "mirror missing 'to' field" unless mir.has_key? 'to'
-
- get_from = mir['from']
- save_to = File.expand_path mir['to']
-
- raise "Directory not found: #{save_to}" unless File.exist? save_to
- raise "Not a directory: #{save_to}" unless File.directory? save_to
-
- gems_dir = File.join save_to, "gems"
-
- if File.exist? gems_dir then
- raise "Not a directory: #{gems_dir}" unless File.directory? gems_dir
- else
- Dir.mkdir gems_dir
- end
-
- sourceindex_data = ''
-
- say "fetching: #{get_from}/Marshal.#{Gem.marshal_version}.Z"
-
- get_from = URI.parse get_from
-
- if get_from.scheme.nil? then
- get_from = get_from.to_s
- elsif get_from.scheme == 'file' then
- # check if specified URI contains a drive letter (file:/D:/Temp)
- get_from = get_from.to_s
- get_from = if get_from =~ /^file:.*[a-z]:/i then
- get_from[6..-1]
- else
- get_from[5..-1]
- end
- end
-
- open File.join(get_from.to_s, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
- sourceindex_data = Zlib::Inflate.inflate y.read
- open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
- out.write sourceindex_data
- end
- end
-
- sourceindex = Marshal.load(sourceindex_data)
-
- progress = ui.progress_reporter sourceindex.size,
- "Fetching #{sourceindex.size} gems"
- sourceindex.each do |fullname, gem|
- gem_file = "#{fullname}.gem"
- gem_dest = File.join gems_dir, gem_file
-
- unless File.exist? gem_dest then
- begin
- open "#{get_from}/gems/#{gem_file}", "rb" do |g|
- contents = g.read
- open gem_dest, "wb" do |out|
- out.write contents
- end
- end
- rescue
- old_gf = gem_file
- gem_file = gem_file.downcase
- retry if old_gf != gem_file
- alert_error $!
- end
- end
-
- progress.updated gem_file
- end
-
- progress.done
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
deleted file mode 100644
index 9c0062019b..0000000000
--- a/lib/rubygems/commands/outdated_command.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/local_remote_options'
-require 'rubygems/source_info_cache'
-require 'rubygems/version_option'
-
-class Gem::Commands::OutdatedCommand < Gem::Command
-
- include Gem::LocalRemoteOptions
- include Gem::VersionOption
-
- def initialize
- super 'outdated', 'Display all gems that need updates'
-
- add_local_remote_options
- add_platform_option
- end
-
- def execute
- locals = Gem::SourceIndex.from_installed_gems
-
- locals.outdated.sort.each do |name|
- local = locals.search(/^#{name}$/).last
- remotes = Gem::SourceInfoCache.search_with_source(/^#{name}$/, true)
- remote = remotes.last.first
- say "#{local.name} (#{local.version} < #{remote.version})"
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
deleted file mode 100644
index 2900e7e739..0000000000
--- a/lib/rubygems/commands/pristine_command.rb
+++ /dev/null
@@ -1,133 +0,0 @@
-require 'fileutils'
-require 'rubygems/command'
-require 'rubygems/format'
-require 'rubygems/installer'
-require 'rubygems/version_option'
-
-class Gem::Commands::PristineCommand < Gem::Command
-
- include Gem::VersionOption
-
- def initialize
- super 'pristine',
- 'Restores installed gems to pristine condition from files located in the gem cache',
- :version => Gem::Requirement.default
-
- add_option('--all',
- 'Restore all installed gems to pristine',
- 'condition') do |value, options|
- options[:all] = value
- end
-
- add_version_option('restore to', 'pristine condition')
- end
-
- def arguments # :nodoc:
- "GEMNAME gem to restore to pristine condition (unless --all)"
- end
-
- def defaults_str # :nodoc:
- "--all"
- end
-
- def description # :nodoc:
- <<-EOF
-The pristine command compares the installed gems with the contents of the
-cached gem and restores any files that don't match the cached gem's copy.
-
-If you have made modifications to your installed gems, the pristine command
-will revert them. After all the gem's files have been checked all bin stubs
-for the gem are regenerated.
-
-If the cached gem cannot be found, you will need to use `gem install` to
-revert the gem.
- EOF
- end
-
- def usage # :nodoc:
- "#{program_name} [args]"
- end
-
- def execute
- gem_name = nil
-
- specs = if options[:all] then
- Gem::SourceIndex.from_installed_gems.map do |name, spec|
- spec
- end
- else
- gem_name = get_one_gem_name
- Gem::SourceIndex.from_installed_gems.search(gem_name,
- options[:version])
- end
-
- if specs.empty? then
- raise Gem::Exception,
- "Failed to find gem #{gem_name} #{options[:version]}"
- end
-
- install_dir = Gem.dir # TODO use installer option
-
- raise Gem::FilePermissionError.new(install_dir) unless
- File.writable?(install_dir)
-
- say "Restoring gem(s) to pristine condition..."
-
- specs.each do |spec|
- gem = Dir[File.join(Gem.dir, 'cache', "#{spec.full_name}.gem")].first
-
- if gem.nil? then
- alert_error "Cached gem for #{spec.full_name} not found, use `gem install` to restore"
- next
- end
-
- # TODO use installer options
- installer = Gem::Installer.new gem, :wrappers => true
-
- gem_file = File.join install_dir, "cache", "#{spec.full_name}.gem"
-
- security_policy = nil # TODO use installer option
-
- format = Gem::Format.from_file_by_path gem_file, security_policy
-
- target_directory = File.join(install_dir, "gems", format.spec.full_name)
- target_directory.untaint
-
- pristine_files = format.file_entries.collect { |data| data[0]["path"] }
- file_map = {}
-
- format.file_entries.each do |entry, file_data|
- file_map[entry["path"]] = file_data
- end
-
- Dir.chdir target_directory do
- deployed_files = Dir.glob(File.join("**", "*")) +
- Dir.glob(File.join("**", ".*"))
-
- pristine_files = pristine_files.map { |f| File.expand_path f }
- deployed_files = deployed_files.map { |f| File.expand_path f }
-
- to_redeploy = (pristine_files - deployed_files)
- to_redeploy = to_redeploy.map { |path| path.untaint}
-
- if to_redeploy.length > 0 then
- say "Restoring #{to_redeploy.length} file#{to_redeploy.length == 1 ? "" : "s"} to #{spec.full_name}..."
-
- to_redeploy.each do |path|
- say " #{path}"
- FileUtils.mkdir_p File.dirname(path)
- File.open(path, "wb") do |out|
- out.write file_map[path]
- end
- end
- else
- say "#{spec.full_name} is in pristine condition"
- end
- end
-
- installer.generate_bin
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
deleted file mode 100644
index 4f957625ee..0000000000
--- a/lib/rubygems/commands/query_command.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/local_remote_options'
-require 'rubygems/source_info_cache'
-
-class Gem::Commands::QueryCommand < Gem::Command
-
- include Gem::LocalRemoteOptions
-
- def initialize(name = 'query',
- summary = 'Query gem information in local or remote repositories')
- super name, summary,
- :name => /.*/, :domain => :local, :details => false, :versions => true
-
- add_option('-n', '--name-matches REGEXP',
- 'Name of gem(s) to query on matches the',
- 'provided REGEXP') do |value, options|
- options[:name] = /#{value}/i
- end
-
- add_option('-d', '--[no-]details',
- 'Display detailed information of gem(s)') do |value, options|
- options[:details] = value
- end
-
- add_option( '--[no-]versions',
- 'Display only gem names') do |value, options|
- options[:versions] = value
- options[:details] = false unless value
- end
-
- add_local_remote_options
- end
-
- def defaults_str # :nodoc:
- "--local --name-matches '.*' --no-details --versions"
- end
-
- def execute
- name = options[:name]
-
- if local? then
- say
- say "*** LOCAL GEMS ***"
- say
- output_query_results Gem.cache.search(name)
- end
-
- if remote? then
- say
- say "*** REMOTE GEMS ***"
- say
- output_query_results Gem::SourceInfoCache.search(name)
- end
- end
-
- private
-
- def output_query_results(gemspecs)
- output = []
- gem_list_with_version = {}
-
- gemspecs.flatten.each do |gemspec|
- gem_list_with_version[gemspec.name] ||= []
- gem_list_with_version[gemspec.name] << gemspec
- end
-
- gem_list_with_version = gem_list_with_version.sort_by do |name, spec|
- name.downcase
- end
-
- gem_list_with_version.each do |gem_name, list_of_matching|
- list_of_matching = list_of_matching.sort_by { |x| x.version.to_ints }.reverse
- seen_versions = {}
-
- list_of_matching.delete_if do |item|
- if seen_versions[item.version] then
- true
- else
- seen_versions[item.version] = true
- false
- end
- end
-
- entry = gem_name.dup
-
- if options[:versions] then
- versions = list_of_matching.map { |s| s.version }.uniq
- entry << " (#{versions.join ', '})"
- end
-
- entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
- options[:details]
- output << entry
- end
-
- say output.join(options[:details] ? "\n\n" : "\n")
- end
-
- ##
- # Used for wrapping and indenting text
- #
- def format_text(text, wrap, indent=0)
- result = []
- work = text.dup
-
- while work.length > wrap
- if work =~ /^(.{0,#{wrap}})[ \n]/o then
- result << $1
- work.slice!(0, $&.length)
- else
- result << work.slice!(0, wrap)
- end
- end
-
- result << work if work.length.nonzero?
- result.join("\n").gsub(/^/, " " * indent)
- end
-
-end
-
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
deleted file mode 100644
index f2e677c115..0000000000
--- a/lib/rubygems/commands/rdoc_command.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/version_option'
-require 'rubygems/doc_manager'
-
-module Gem
- module Commands
- class RdocCommand < Command
- include VersionOption
-
- def initialize
- super('rdoc',
- 'Generates RDoc for pre-installed gems',
- {
- :version => Gem::Requirement.default,
- :include_rdoc => true,
- :include_ri => true,
- })
- add_option('--all',
- 'Generate RDoc/RI documentation for all',
- 'installed gems') do |value, options|
- options[:all] = value
- end
- add_option('--[no-]rdoc',
- 'Include RDoc generated documents') do
- |value, options|
- options[:include_rdoc] = value
- end
- add_option('--[no-]ri',
- 'Include RI generated documents'
- ) do |value, options|
- options[:include_ri] = value
- end
- add_version_option
- end
-
- def arguments # :nodoc:
- "GEMNAME gem to generate documentation for (unless --all)"
- end
-
- def defaults_str # :nodoc:
- "--version '#{Gem::Requirement.default}' --rdoc --ri"
- end
-
- def usage # :nodoc:
- "#{program_name} [args]"
- end
-
- def execute
- if options[:all]
- specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec|
- spec
- }
- else
- gem_name = get_one_gem_name
- specs = Gem::SourceIndex.from_installed_gems.search(
- gem_name, options[:version])
- end
-
- if specs.empty?
- fail "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
- end
- if options[:include_ri]
- specs.each do |spec|
- Gem::DocManager.new(spec).generate_ri
- end
- end
- if options[:include_rdoc]
- specs.each do |spec|
- Gem::DocManager.new(spec).generate_rdoc
- end
- end
-
- true
- end
- end
-
- end
-end
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
deleted file mode 100644
index 96da19c0f7..0000000000
--- a/lib/rubygems/commands/search_command.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/commands/query_command'
-
-module Gem
- module Commands
-
- class SearchCommand < QueryCommand
-
- def initialize
- super(
- 'search',
- 'Display all gems whose name contains STRING'
- )
- remove_option('--name-matches')
- end
-
- def arguments # :nodoc:
- "STRING fragment of gem name to search for"
- end
-
- def defaults_str # :nodoc:
- "--local --no-details"
- end
-
- def usage # :nodoc:
- "#{program_name} [STRING]"
- end
-
- def execute
- string = get_one_optional_argument
- options[:name] = /#{string}/i
- super
- end
- end
-
- end
-end
diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb
deleted file mode 100644
index 992ae1c8f8..0000000000
--- a/lib/rubygems/commands/server_command.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/server'
-
-class Gem::Commands::ServerCommand < Gem::Command
-
- def initialize
- super 'server', 'Documentation and gem repository HTTP server',
- :port => 8808, :gemdir => Gem.dir, :daemon => false
-
- add_option '-p', '--port=PORT', Integer,
- 'port to listen on' do |port, options|
- options[:port] = port
- end
-
- add_option '-d', '--dir=GEMDIR',
- 'directory from which to serve gems' do |gemdir, options|
- options[:gemdir] = File.expand_path gemdir
- end
-
- add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
- options[:daemon] = daemon
- end
- end
-
- def defaults_str # :nodoc:
- "--port 8808 --dir #{Gem.dir} --no-daemon"
- end
-
- def description # :nodoc:
- <<-EOF
-The server command starts up a web server that hosts the RDoc for your
-installed gems and can operate as a server for installation of gems on other
-machines.
-
-The cache files for installed gems must exist to use the server as a source
-for gem installation.
-
-To install gems from a running server, use `gem install GEMNAME --source
-http://gem_server_host:8808`
- EOF
- end
-
- def execute
- Gem::Server.run options
- end
-
-end
-
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
deleted file mode 100644
index a0977f90dc..0000000000
--- a/lib/rubygems/commands/sources_command.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/remote_fetcher'
-require 'rubygems/source_info_cache'
-require 'rubygems/source_info_cache_entry'
-
-class Gem::Commands::SourcesCommand < Gem::Command
-
- def initialize
- super 'sources',
- 'Manage the sources and cache file RubyGems uses to search for gems'
-
- add_option '-a', '--add SOURCE_URI', 'Add source' do |value, options|
- options[:add] = value
- end
-
- add_option '-l', '--list', 'List sources' do |value, options|
- options[:list] = value
- end
-
- add_option '-r', '--remove SOURCE_URI', 'Remove source' do |value, options|
- options[:remove] = value
- end
-
- add_option '-u', '--update', 'Update source cache' do |value, options|
- options[:update] = value
- end
-
- add_option '-c', '--clear-all',
- 'Remove all sources (clear the cache)' do |value, options|
- options[:clear_all] = value
- end
- end
-
- def defaults_str
- '--list'
- end
-
- def execute
- options[:list] = !(options[:add] || options[:remove] || options[:clear_all] || options[:update])
-
- if options[:clear_all] then
- remove_cache_file("user", Gem::SourceInfoCache.user_cache_file)
- remove_cache_file("system", Gem::SourceInfoCache.system_cache_file)
- end
-
- if options[:add] then
- source_uri = options[:add]
-
- sice = Gem::SourceInfoCacheEntry.new nil, nil
- begin
- sice.refresh source_uri
-
- Gem::SourceInfoCache.cache_data[source_uri] = sice
- Gem::SourceInfoCache.cache.update
- Gem::SourceInfoCache.cache.flush
-
- Gem.sources << source_uri
- Gem.configuration.write
-
- say "#{source_uri} added to sources"
- rescue URI::Error, ArgumentError
- say "#{source_uri} is not a URI"
- rescue Gem::RemoteFetcher::FetchError => e
- say "Error fetching #{source_uri}:\n\t#{e.message}"
- end
- end
-
- if options[:update] then
- Gem::SourceInfoCache.cache.refresh
- Gem::SourceInfoCache.cache.flush
-
- say "source cache successfully updated"
- end
-
- if options[:remove] then
- source_uri = options[:remove]
-
- unless Gem.sources.include? source_uri then
- say "source #{source_uri} not present in cache"
- else
- Gem::SourceInfoCache.cache_data.delete source_uri
- Gem::SourceInfoCache.cache.update
- Gem::SourceInfoCache.cache.flush
- Gem.sources.delete source_uri
- Gem.configuration.write
-
- say "#{source_uri} removed from sources"
- end
- end
-
- if options[:list] then
- say "*** CURRENT SOURCES ***"
- say
-
- Gem.sources.each do |source|
- say source
- end
- end
- end
-
- private
-
- def remove_cache_file(desc, fn)
- FileUtils.rm_rf fn rescue nil
- if ! File.exist?(fn)
- say "*** Removed #{desc} source cache ***"
- elsif ! File.writable?(fn)
- say "*** Unable to remove #{desc} source cache (write protected) ***"
- else
- say "*** Unable to remove #{desc} source cache ***"
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
deleted file mode 100644
index 1ab2ad9260..0000000000
--- a/lib/rubygems/commands/specification_command.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require 'yaml'
-require 'rubygems/command'
-require 'rubygems/local_remote_options'
-require 'rubygems/version_option'
-require 'rubygems/source_info_cache'
-
-class Gem::Commands::SpecificationCommand < Gem::Command
-
- include Gem::LocalRemoteOptions
- include Gem::VersionOption
-
- def initialize
- super 'specification', 'Display gem specification (in yaml)',
- :domain => :local, :version => Gem::Requirement.default
-
- add_version_option('examine')
- add_platform_option
-
- add_option('--all', 'Output specifications for all versions of',
- 'the gem') do |value, options|
- options[:all] = true
- end
-
- add_local_remote_options
- end
-
- def arguments # :nodoc:
- "GEMFILE name of gem to show the gemspec for"
- end
-
- def defaults_str # :nodoc:
- "--local --version '#{Gem::Requirement.default}'"
- end
-
- def usage # :nodoc:
- "#{program_name} [GEMFILE]"
- end
-
- def execute
- specs = []
- gem = get_one_gem_name
-
- if local? then
- source_index = Gem::SourceIndex.from_installed_gems
- specs.push(*source_index.search(/\A#{gem}\z/, options[:version]))
- end
-
- if remote? then
- alert_warning "Remote information is not complete\n\n"
-
- Gem::SourceInfoCache.cache_data.each do |_,sice|
- specs.push(*sice.source_index.search(gem, options[:version]))
- end
- end
-
- if specs.empty? then
- alert_error "Unknown gem '#{gem}'"
- terminate_interaction 1
- end
-
- output = lambda { |s| say s.to_yaml; say "\n" }
-
- if options[:all] then
- specs.each(&output)
- else
- spec = specs.sort_by { |s| s.version }.last
- output[spec]
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
deleted file mode 100644
index 7d2908836c..0000000000
--- a/lib/rubygems/commands/uninstall_command.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/version_option'
-require 'rubygems/uninstaller'
-
-module Gem
- module Commands
- class UninstallCommand < Command
-
- include VersionOption
-
- def initialize
- super 'uninstall', 'Uninstall gems from the local repository',
- :version => Gem::Requirement.default
-
- add_option('-a', '--[no-]all',
- 'Uninstall all matching versions'
- ) do |value, options|
- options[:all] = value
- end
-
- add_option('-i', '--[no-]ignore-dependencies',
- 'Ignore dependency requirements while',
- 'uninstalling') do |value, options|
- options[:ignore] = value
- end
-
- add_option('-x', '--[no-]executables',
- 'Uninstall applicable executables without',
- 'confirmation') do |value, options|
- options[:executables] = value
- end
-
- add_version_option
- add_platform_option
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to uninstall"
- end
-
- def defaults_str # :nodoc:
- "--version '#{Gem::Requirement.default}' --no-force"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME [GEMNAME ...]"
- end
-
- def execute
- get_all_gem_names.each do |gem_name|
- Gem::Uninstaller.new(gem_name, options).uninstall
- end
- end
- end
- end
-end
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
deleted file mode 100644
index 23ebabc21a..0000000000
--- a/lib/rubygems/commands/unpack_command.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-require 'fileutils'
-require 'rubygems/command'
-require 'rubygems/installer'
-require 'rubygems/version_option'
-
-class Gem::Commands::UnpackCommand < Gem::Command
-
- include Gem::VersionOption
-
- def initialize
- super 'unpack', 'Unpack an installed gem to the current directory',
- :version => Gem::Requirement.default,
- :target => Dir.pwd
-
- add_option('--target', 'target directory for unpacking') do |value, options|
- options[:target] = value
- end
-
- add_version_option
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to unpack"
- end
-
- def defaults_str # :nodoc:
- "--version '#{Gem::Requirement.default}'"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME"
- end
-
- #--
- # TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
- # this, so that it works for uninstall as well. (And check other commands
- # at the same time.)
- def execute
- gemname = get_one_gem_name
- path = get_path(gemname, options[:version])
- if path then
- basename = File.basename(path).sub(/\.gem$/, '')
- target_dir = File.expand_path File.join(options[:target], basename)
- FileUtils.mkdir_p target_dir
- Gem::Installer.new(path).unpack target_dir
- say "Unpacked gem: '#{target_dir}'"
- else
- alert_error "Gem '#{gemname}' not installed."
- end
- end
-
- # Return the full path to the cached gem file matching the given
- # name and version requirement. Returns 'nil' if no match.
- #
- # Example:
- #
- # get_path('rake', '> 0.4') # -> '/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem'
- # get_path('rake', '< 0.1') # -> nil
- # get_path('rak') # -> nil (exact name required)
- #--
- # TODO: This should be refactored so that it's a general service. I don't
- # think any of our existing classes are the right place though. Just maybe
- # 'Cache'?
- #
- # TODO: It just uses Gem.dir for now. What's an easy way to get the list of
- # source directories?
- def get_path(gemname, version_req)
- return gemname if gemname =~ /\.gem$/i
- specs = Gem::SourceIndex.from_installed_gems.search(/\A#{gemname}\z/, version_req)
- selected = specs.sort_by { |s| s.version }.last
- return nil if selected.nil?
- # We expect to find (basename).gem in the 'cache' directory.
- # Furthermore, the name match must be exact (ignoring case).
- if gemname =~ /^#{selected.name}$/i
- filename = selected.full_name + '.gem'
- return File.join(Gem.dir, 'cache', filename)
- else
- return nil
- end
- end
-
-end
-
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
deleted file mode 100644
index 7a11ec9554..0000000000
--- a/lib/rubygems/commands/update_command.rb
+++ /dev/null
@@ -1,155 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/install_update_options'
-require 'rubygems/local_remote_options'
-require 'rubygems/source_info_cache'
-require 'rubygems/version_option'
-
-class Gem::Commands::UpdateCommand < Gem::Command
-
- include Gem::InstallUpdateOptions
- include Gem::LocalRemoteOptions
- include Gem::VersionOption
-
- def initialize
- super 'update',
- 'Update the named gems (or all installed gems) in the local repository',
- :generate_rdoc => true,
- :generate_ri => true,
- :force => false,
- :test => false,
- :install_dir => Gem.dir
-
- add_install_update_options
-
- add_option('--system',
- 'Update the RubyGems system software') do |value, options|
- options[:system] = value
- end
-
- add_local_remote_options
-
- add_platform_option
- end
-
- def arguments # :nodoc:
- "GEMNAME name of gem to update"
- end
-
- def defaults_str # :nodoc:
- "--rdoc --ri --no-force --no-test --install-dir #{Gem.dir}"
- end
-
- def usage # :nodoc:
- "#{program_name} GEMNAME [GEMNAME ...]"
- end
-
- def execute
- if options[:system] then
- say "Updating RubyGems..."
-
- unless options[:args].empty? then
- fail "No gem names are allowed with the --system option"
- end
-
- options[:args] = ["rubygems-update"]
- else
- say "Updating installed gems..."
- end
-
- hig = highest_installed_gems = {}
-
- Gem::SourceIndex.from_installed_gems.each do |name, spec|
- if hig[spec.name].nil? or hig[spec.name].version < spec.version then
- hig[spec.name] = spec
- end
- end
-
- remote_gemspecs = Gem::SourceInfoCache.search(//)
-
- gems_to_update = if options[:args].empty? then
- which_to_update(highest_installed_gems, remote_gemspecs)
- else
- options[:args]
- end
-
- options[:domain] = :remote # install from remote source
-
- # HACK use the real API
- install_command = Gem::CommandManager.instance['install']
-
- gems_to_update.uniq.sort.each do |name|
- say "Attempting remote update of #{name}"
- options[:args] = [name]
- options[:ignore_dependencies] = true # HACK skip seen gems instead
- install_command.merge_options(options)
- install_command.execute
- end
-
- if gems_to_update.include? "rubygems-update" then
- latest_ruby_gem = remote_gemspecs.select do |s|
- s.name == 'rubygems-update'
- end
-
- latest_ruby_gem = latest_ruby_gem.sort_by { |s| s.version }.last
-
- say "Updating version of RubyGems to #{latest_ruby_gem.version}"
- installed = do_rubygems_update latest_ruby_gem.version
-
- say "RubyGems system software updated" if installed
- else
- updated = gems_to_update.uniq.sort.collect { |g| g.to_s }
-
- if updated.empty? then
- say "Nothing to update"
- else
- say "Gems updated: #{updated.join ', '}"
- end
- end
- end
-
- def do_rubygems_update(version)
- args = []
- args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
- args << '--no-rdoc' unless options[:generate_rdoc]
- args << '--no-ri' unless options[:generate_ri]
-
- update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
-
- success = false
-
- Dir.chdir update_dir do
- say "Installing RubyGems #{version}"
- setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
-
- # Make sure old rubygems isn't loaded
- if Gem.win_platform? then
- system "set RUBYOPT= & #{setup_cmd}"
- else
- system "RUBYOPT=\"\" #{setup_cmd}"
- end
- end
- end
-
- def which_to_update(highest_installed_gems, remote_gemspecs)
- result = []
-
- highest_installed_gems.each do |l_name, l_spec|
- matching_gems = remote_gemspecs.select do |spec|
- spec.name == l_name and Gem.platforms.any? do |platform|
- platform == spec.platform
- end
- end
-
- highest_remote_gem = matching_gems.sort_by { |spec| spec.version }.last
-
- if highest_remote_gem and
- l_spec.version < highest_remote_gem.version then
- result << l_name
- end
- end
-
- result
- end
-
-end
-
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
deleted file mode 100644
index b42244ce7d..0000000000
--- a/lib/rubygems/commands/which_command.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'rubygems/command'
-require 'rubygems/gem_path_searcher'
-
-class Gem::Commands::WhichCommand < Gem::Command
-
- EXT = %w[.rb .rbw .so .dll] # HACK
-
- def initialize
- super 'which', 'Find the location of a library',
- :search_gems_first => false, :show_all => false
-
- add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options|
- options[:show_all] = show_all
- end
-
- add_option '-g', '--[no-]gems-first',
- 'search gems before non-gems' do |gems_first, options|
- options[:search_gems_first] = gems_first
- end
- end
-
- def arguments # :nodoc:
- "FILE name of file to find"
- end
-
- def defaults_str # :nodoc:
- "--no-gems-first --no-all"
- end
-
- def usage # :nodoc:
- "#{program_name} FILE [FILE ...]"
- end
-
- def execute
- searcher = Gem::GemPathSearcher.new
-
- options[:args].each do |arg|
- dirs = $LOAD_PATH
- spec = searcher.find arg
-
- if spec then
- if options[:search_gems_first] then
- dirs = gem_paths(spec) + $LOAD_PATH
- else
- dirs = $LOAD_PATH + gem_paths(spec)
- end
-
- say "(checking gem #{spec.full_name} for #{arg})" if
- Gem.configuration.verbose
- end
-
- paths = find_paths arg, dirs
-
- if paths.empty? then
- say "Can't find #{arg}"
- else
- say paths
- end
- end
- end
-
- def find_paths(package_name, dirs)
- result = []
-
- dirs.each do |dir|
- EXT.each do |ext|
- full_path = File.join dir, "#{package_name}#{ext}"
- if File.exist? full_path then
- result << full_path
- return result unless options[:show_all]
- end
- end
- end
-
- result
- end
-
- def gem_paths(spec)
- spec.require_paths.collect { |d| File.join spec.full_gem_path, d }
- end
-
- def usage # :nodoc:
- "#{program_name} FILE [...]"
- end
-
-end
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
deleted file mode 100644
index 5bca0bd14e..0000000000
--- a/lib/rubygems/config_file.rb
+++ /dev/null
@@ -1,224 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'yaml'
-require 'rubygems'
-
-# Store the gem command options specified in the configuration file. The
-# config file object acts much like a hash.
-
-class Gem::ConfigFile
-
- DEFAULT_BACKTRACE = false
- DEFAULT_BENCHMARK = false
- DEFAULT_BULK_THRESHOLD = 1000
- DEFAULT_VERBOSITY = true
- DEFAULT_UPDATE_SOURCES = true
-
- # List of arguments supplied to the config file object.
- attr_reader :args
-
- # True if we print backtraces on errors.
- attr_writer :backtrace
-
- # True if we are benchmarking this run.
- attr_accessor :benchmark
-
- # Bulk threshold value. If the number of missing gems are above
- # this threshold value, then a bulk download technique is used.
- attr_accessor :bulk_threshold
-
- # Verbose level of output:
- # * false -- No output
- # * true -- Normal output
- # * :loud -- Extra output
- attr_accessor :verbose
-
- # True if we want to update the SourceInfoCache every time, false otherwise
- attr_accessor :update_sources
-
- # Create the config file object. +args+ is the list of arguments
- # from the command line.
- #
- # The following command line options are handled early here rather
- # than later at the time most command options are processed.
- #
- # * --config-file and --config-file==NAME -- Obviously these need
- # to be handled by the ConfigFile object to ensure we get the
- # right config file.
- #
- # * --backtrace -- Backtrace needs to be turned on early so that
- # errors before normal option parsing can be properly handled.
- #
- # * --debug -- Enable Ruby level debug messages. Handled early
- # for the same reason as --backtrace.
- #
- def initialize(arg_list)
- @config_file_name = nil
- need_config_file_name = false
-
- arg_list = arg_list.map do |arg|
- if need_config_file_name then
- @config_file_name = arg
- nil
- elsif arg =~ /^--config-file=(.*)/ then
- @config_file_name = $1
- nil
- elsif arg =~ /^--config-file$/ then
- need_config_file_name = true
- nil
- else
- arg
- end
- end.compact
-
- @backtrace = DEFAULT_BACKTRACE
- @benchmark = DEFAULT_BENCHMARK
- @bulk_threshold = DEFAULT_BULK_THRESHOLD
- @verbose = DEFAULT_VERBOSITY
- @update_sources = DEFAULT_UPDATE_SOURCES
-
- begin
- # HACK $SAFE ok?
- @hash = open(config_file_name.dup.untaint) {|f| YAML.load(f) }
- rescue ArgumentError
- warn "Failed to load #{config_file_name}"
- rescue Errno::ENOENT
- # Ignore missing config file error.
- rescue Errno::EACCES
- warn "Failed to load #{config_file_name} due to permissions problem."
- end
-
- @hash ||= {}
-
- # HACK these override command-line args, which is bad
- @backtrace = @hash[:backtrace] if @hash.key? :backtrace
- @benchmark = @hash[:benchmark] if @hash.key? :benchmark
- @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
- Gem.sources.replace @hash[:sources] if @hash.key? :sources
- @verbose = @hash[:verbose] if @hash.key? :verbose
- @update_sources = @hash[:update_sources] if @hash.key? :update_sources
-
- handle_arguments arg_list
- end
-
- # True if the backtrace option has been specified, or debug is on.
- def backtrace
- @backtrace or $DEBUG
- end
-
- # The name of the configuration file.
- def config_file_name
- @config_file_name || Gem.config_file
- end
-
- # Delegates to @hash
- def each(&block)
- hash = @hash.dup
- hash.delete :update_sources
- hash.delete :verbose
- hash.delete :benchmark
- hash.delete :backtrace
- hash.delete :bulk_threshold
-
- yield :update_sources, @update_sources
- yield :verbose, @verbose
- yield :benchmark, @benchmark
- yield :backtrace, @backtrace
- yield :bulk_threshold, @bulk_threshold
-
- yield 'config_file_name', @config_file_name if @config_file_name
-
- hash.each(&block)
- end
-
- # Handle the command arguments.
- def handle_arguments(arg_list)
- @args = []
-
- arg_list.each do |arg|
- case arg
- when /^--(backtrace|traceback)$/ then
- @backtrace = true
- when /^--bench(mark)?$/ then
- @benchmark = true
- when /^--debug$/ then
- $DEBUG = true
- else
- @args << arg
- end
- end
- end
-
- # Really verbose mode gives you extra output.
- def really_verbose
- case verbose
- when true, false, nil then false
- else true
- end
- end
-
- # to_yaml only overwrites things you can't override on the command line.
- def to_yaml # :nodoc:
- yaml_hash = {}
- yaml_hash[:backtrace] = @hash.key?(:backtrace) ? @hash[:backtrace] :
- DEFAULT_BACKTRACE
- yaml_hash[:benchmark] = @hash.key?(:benchmark) ? @hash[:benchmark] :
- DEFAULT_BENCHMARK
- yaml_hash[:bulk_threshold] = @hash.key?(:bulk_threshold) ?
- @hash[:bulk_threshold] : DEFAULT_BULK_THRESHOLD
- yaml_hash[:sources] = Gem.sources
- yaml_hash[:update_sources] = @hash.key?(:update_sources) ?
- @hash[:update_sources] : DEFAULT_UPDATE_SOURCES
- yaml_hash[:verbose] = @hash.key?(:verbose) ? @hash[:verbose] :
- DEFAULT_VERBOSITY
-
- keys = yaml_hash.keys.map { |key| key.to_s }
- keys << 'debug'
- re = Regexp.union(*keys)
-
- @hash.each do |key, value|
- key = key.to_s
- next if key =~ re
- yaml_hash[key.to_s] = value
- end
-
- yaml_hash.to_yaml
- end
-
- # Writes out this config file, replacing its source.
- def write
- File.open config_file_name, 'w' do |fp|
- fp.write self.to_yaml
- end
- end
-
- # Return the configuration information for +key+.
- def [](key)
- @hash[key.to_s]
- end
-
- # Set configuration option +key+ to +value+.
- def []=(key, value)
- @hash[key.to_s] = value
- end
-
- def ==(other) # :nodoc:
- self.class === other and
- @backtrace == other.backtrace and
- @benchmark == other.benchmark and
- @bulk_threshold == other.bulk_threshold and
- @verbose == other.verbose and
- @update_sources == other.update_sources and
- @hash == other.hash
- end
-
- protected
-
- attr_reader :hash
-
-end
-
diff --git a/lib/rubygems/custom_require.rb b/lib/rubygems/custom_require.rb
deleted file mode 100755
index 598ec3ef98..0000000000
--- a/lib/rubygems/custom_require.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-module Kernel
- alias gem_original_require require # :nodoc:
-
- #
- # We replace Ruby's require with our own, which is capable of
- # loading gems on demand.
- #
- # When you call <tt>require 'x'</tt>, this is what happens:
- # * If the file can be loaded from the existing Ruby loadpath, it
- # is.
- # * Otherwise, installed gems are searched for a file that matches.
- # If it's found in gem 'y', that gem is activated (added to the
- # loadpath).
- #
- # The normal <tt>require</tt> functionality of returning false if
- # that file has already been loaded is preserved.
- #
- def require(path) # :nodoc:
- gem_original_require path
- rescue LoadError => load_error
- if load_error.message =~ /\A[Nn]o such file to load -- #{Regexp.escape path}\z/ and
- spec = Gem.searcher.find(path) then
- Gem.activate(spec.name, false, "= #{spec.version}")
- gem_original_require path
- else
- raise load_error
- end
- end
-end # module Kernel
-
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
deleted file mode 100644
index 3a6229511b..0000000000
--- a/lib/rubygems/defaults.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-module Gem
-
- # An Array of the default sources that come with RubyGems.
- def self.default_sources
- %w[http://gems.rubyforge.org]
- end
-
- # Default home directory path to be used if an alternate value is not
- # specified in the environment.
- def self.default_dir
- if defined? RUBY_FRAMEWORK_VERSION then
- File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
- ConfigMap[:ruby_version]
- else
- File.join ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version]
- end
- end
-
- # Default gem path.
- def self.default_path
- default_dir
- end
-
- # Deduce Ruby's --program-prefix and --program-suffix from its install name.
- def self.default_exec_format
- baseruby = ConfigMap[:BASERUBY] || 'ruby'
- ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
- end
-
- # The default directory for binaries
- def self.default_bindir
- Config::CONFIG['bindir']
- end
-
- # The default system-wide source info cache directory.
- def self.default_system_source_cache_dir
- File.join Gem.dir, 'source_cache'
- end
-
- # The default user-specific source info cache directory.
- def self.default_user_source_cache_dir
- File.join Gem.user_home, '.gem', 'source_cache'
- end
-
-end
-
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
deleted file mode 100644
index be731d564e..0000000000
--- a/lib/rubygems/dependency.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-##
-# The Dependency class holds a Gem name and a Gem::Requirement
-class Gem::Dependency
-
- attr_accessor :name
-
- attr_writer :version_requirements
-
- def <=>(other)
- [@name] <=> [other.name]
- end
-
- ##
- # Constructs the dependency
- #
- # name:: [String] name of the Gem
- # version_requirements:: [String Array] version requirement (e.g. ["> 1.2"])
- #
- def initialize(name, version_requirements)
- @name = name
- @version_requirements = Gem::Requirement.create version_requirements
- @version_requirement = nil # Avoid warnings.
- end
-
- def version_requirements
- normalize if defined? @version_requirement and @version_requirement
- @version_requirements
- end
-
- def requirement_list
- version_requirements.as_list
- end
-
- alias requirements_list requirement_list
-
- def normalize
- ver = @version_requirement.instance_eval { @version }
- @version_requirements = Gem::Requirement.new([ver])
- @version_requirement = nil
- end
-
- def to_s # :nodoc:
- "#{name} (#{version_requirements})"
- end
-
- def ==(other) # :nodoc:
- self.class === other &&
- self.name == other.name &&
- self.version_requirements == other.version_requirements
- end
-
- def hash
- name.hash + version_requirements.hash
- end
-
-end
-
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
deleted file mode 100644
index ec8a50d912..0000000000
--- a/lib/rubygems/dependency_installer.rb
+++ /dev/null
@@ -1,243 +0,0 @@
-require 'rubygems'
-require 'rubygems/dependency_list'
-require 'rubygems/installer'
-require 'rubygems/source_info_cache'
-require 'rubygems/user_interaction'
-
-class Gem::DependencyInstaller
-
- include Gem::UserInteraction
-
- attr_reader :gems_to_install
- attr_reader :installed_gems
-
- DEFAULT_OPTIONS = {
- :env_shebang => false,
- :domain => :both, # HACK dup
- :force => false,
- :format_executable => false, # HACK dup
- :ignore_dependencies => false,
- :security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
- :wrappers => true
- }
-
- ##
- # Creates a new installer instance that will install +gem_name+ using
- # version requirement +version+ and +options+.
- #
- # Options are:
- # :env_shebang:: See Gem::Installer::new.
- # :domain:: :local, :remote, or :both. :local only searches gems in the
- # current directory. :remote searches only gems in Gem::sources.
- # :both searches both.
- # :force:: See Gem::Installer#install.
- # :format_executable:: See Gem::Installer#initialize.
- # :ignore_dependencies: Don't install any dependencies.
- # :install_dir: See Gem::Installer#install.
- # :security_policy: See Gem::Installer::new and Gem::Security.
- # :wrappers: See Gem::Installer::new
- def initialize(gem_name, version = nil, options = {})
- options = DEFAULT_OPTIONS.merge options
- @env_shebang = options[:env_shebang]
- @domain = options[:domain]
- @force = options[:force]
- @format_executable = options[:format_executable]
- @ignore_dependencies = options[:ignore_dependencies]
- @install_dir = options[:install_dir] || Gem.dir
- @security_policy = options[:security_policy]
- @wrappers = options[:wrappers]
-
- @installed_gems = []
-
- spec_and_source = nil
-
- glob = if File::ALT_SEPARATOR then
- gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
- else
- gem_name
- end
-
- local_gems = Dir["#{glob}*"].sort.reverse
-
- unless local_gems.empty? then
- local_gems.each do |gem_file|
- next unless gem_file =~ /gem$/
- begin
- spec = Gem::Format.from_file_by_path(gem_file).spec
- spec_and_source = [spec, gem_file]
- break
- rescue SystemCallError, Gem::Package::FormatError
- end
- end
- end
-
- if spec_and_source.nil? then
- version ||= Gem::Requirement.default
- @dep = Gem::Dependency.new gem_name, version
- spec_and_sources = find_gems_with_sources(@dep).reverse
-
- spec_and_source = spec_and_sources.find do |spec, source|
- Gem::Platform.match spec.platform
- end
- end
-
- if spec_and_source.nil? then
- raise Gem::GemNotFoundException,
- "could not find #{gem_name} locally or in a repository"
- end
-
- @specs_and_sources = [spec_and_source]
-
- gather_dependencies
- end
-
- ##
- # Returns a list of pairs of gemspecs and source_uris that match
- # Gem::Dependency +dep+ from both local (Dir.pwd) and remote (Gem.sources)
- # sources. Gems are sorted with newer gems prefered over older gems, and
- # local gems prefered over remote gems.
- def find_gems_with_sources(dep)
- gems_and_sources = []
-
- if @domain == :both or @domain == :local then
- Dir[File.join(Dir.pwd, "#{dep.name}-[0-9]*.gem")].each do |gem_file|
- spec = Gem::Format.from_file_by_path(gem_file).spec
- gems_and_sources << [spec, gem_file] if spec.name == dep.name
- end
- end
-
- if @domain == :both or @domain == :remote then
- gems_and_sources.push(*Gem::SourceInfoCache.search_with_source(dep, true))
- end
-
- gems_and_sources.sort_by do |gem, source|
- [gem, source !~ /^http:\/\// ? 1 : 0] # local gems win
- end
- end
-
- ##
- # Moves the gem +spec+ from +source_uri+ to the cache dir unless it is
- # already there. If the source_uri is local the gem cache dir copy is
- # always replaced.
- def download(spec, source_uri)
- gem_file_name = "#{spec.full_name}.gem"
- local_gem_path = File.join @install_dir, 'cache', gem_file_name
-
- Gem.ensure_gem_subdirectories @install_dir
-
- source_uri = URI.parse source_uri unless URI::Generic === source_uri
- scheme = source_uri.scheme
-
- # URI.parse gets confused by MS Windows paths with forward slashes.
- scheme = nil if scheme =~ /^[a-z]$/i
-
- case scheme
- when 'http' then
- unless File.exist? local_gem_path then
- begin
- say "Downloading gem #{gem_file_name}" if
- Gem.configuration.really_verbose
-
- remote_gem_path = source_uri + "gems/#{gem_file_name}"
-
- gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
- rescue Gem::RemoteFetcher::FetchError
- raise if spec.original_platform == spec.platform
-
- alternate_name = "#{spec.name}-#{spec.version}-#{spec.original_platform}.gem"
-
- say "Failed, downloading gem #{alternate_name}" if
- Gem.configuration.really_verbose
-
- remote_gem_path = source_uri + "gems/#{alternate_name}"
-
- gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
- end
-
- File.open local_gem_path, 'wb' do |fp|
- fp.write gem
- end
- end
- when nil, 'file' then # TODO test for local overriding cache
- begin
- FileUtils.cp source_uri.to_s, local_gem_path
- rescue Errno::EACCES
- local_gem_path = source_uri.to_s
- end
-
- say "Using local gem #{local_gem_path}" if
- Gem.configuration.really_verbose
- else
- raise Gem::InstallError, "unsupported URI scheme #{source_uri.scheme}"
- end
-
- local_gem_path
- end
-
- ##
- # Gathers all dependencies necessary for the installation from local and
- # remote sources unless the ignore_dependencies was given.
- def gather_dependencies
- specs = @specs_and_sources.map { |spec,_| spec }
-
- dependency_list = Gem::DependencyList.new
- dependency_list.add(*specs)
-
- unless @ignore_dependencies then
- to_do = specs.dup
- seen = {}
-
- until to_do.empty? do
- spec = to_do.shift
- next if spec.nil? or seen[spec.name]
- seen[spec.name] = true
-
- spec.dependencies.each do |dep|
- results = find_gems_with_sources(dep).reverse # local gems first
-
- results.each do |dep_spec, source_uri|
- next if seen[dep_spec.name]
- @specs_and_sources << [dep_spec, source_uri]
- dependency_list.add dep_spec
- to_do.push dep_spec
- end
- end
- end
- end
-
- @gems_to_install = dependency_list.dependency_order.reverse
- end
-
- ##
- # Installs the gem and all its dependencies.
- def install
- spec_dir = File.join @install_dir, 'specifications'
- source_index = Gem::SourceIndex.from_gems_in spec_dir
-
- @gems_to_install.each do |spec|
- last = spec == @gems_to_install.last
- # HACK is this test for full_name acceptable?
- next if source_index.any? { |n,_| n == spec.full_name } and not last
-
- say "Installing gem #{spec.full_name}" if Gem.configuration.really_verbose
-
- _, source_uri = @specs_and_sources.assoc spec
- local_gem_path = download spec, source_uri
-
- inst = Gem::Installer.new local_gem_path,
- :env_shebang => @env_shebang,
- :force => @force,
- :format_executable => @format_executable,
- :ignore_dependencies => @ignore_dependencies,
- :install_dir => @install_dir,
- :security_policy => @security_policy,
- :wrappers => @wrappers
-
- spec = inst.install
-
- @installed_gems << spec
- end
- end
-
-end
-
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
deleted file mode 100644
index 81aa65bfb2..0000000000
--- a/lib/rubygems/dependency_list.rb
+++ /dev/null
@@ -1,165 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'tsort'
-
-class Gem::DependencyList
-
- include TSort
-
- def self.from_source_index(src_index)
- deps = new
-
- src_index.each do |full_name, spec|
- deps.add spec
- end
-
- deps
- end
-
- def initialize
- @specs = []
- end
-
- # Adds +gemspecs+ to the dependency list.
- def add(*gemspecs)
- @specs.push(*gemspecs)
- end
-
- # Return a list of the specifications in the dependency list,
- # sorted in order so that no spec in the list depends on a gem
- # earlier in the list.
- #
- # This is useful when removing gems from a set of installed gems.
- # By removing them in the returned order, you don't get into as
- # many dependency issues.
- #
- # If there are circular dependencies (yuck!), then gems will be
- # returned in order until only the circular dependents and anything
- # they reference are left. Then arbitrary gemspecs will be returned
- # until the circular dependency is broken, after which gems will be
- # returned in dependency order again.
- def dependency_order
- sorted = strongly_connected_components.flatten
-
- result = []
- seen = {}
-
- sorted.each do |spec|
- if index = seen[spec.name] then
- if result[index].version < spec.version then
- result[index] = spec
- end
- else
- seen[spec.name] = result.length
- result << spec
- end
- end
-
- result.reverse
- end
-
- def find_name(full_name)
- @specs.find { |spec| spec.full_name == full_name }
- end
-
- # Are all the dependencies in the list satisfied?
- def ok?
- @specs.all? do |spec|
- spec.dependencies.all? do |dep|
- @specs.find { |s| s.satisfies_requirement? dep }
- end
- end
- end
-
- # Is is ok to remove a gem from the dependency list?
- #
- # If removing the gemspec creates breaks a currently ok dependency,
- # then it is NOT ok to remove the gem.
- def ok_to_remove?(full_name)
- gem_to_remove = find_name full_name
-
- siblings = @specs.find_all { |s|
- s.name == gem_to_remove.name &&
- s.full_name != gem_to_remove.full_name
- }
-
- deps = []
-
- @specs.each do |spec|
- spec.dependencies.each do |dep|
- deps << dep if gem_to_remove.satisfies_requirement?(dep)
- end
- end
-
- deps.all? { |dep|
- siblings.any? { |s|
- s.satisfies_requirement? dep
- }
- }
- end
-
- def remove_by_name(full_name)
- @specs.delete_if { |spec| spec.full_name == full_name }
- end
-
- # Return a hash of predecessors. <tt>result[spec]</tt> is an
- # Array of gemspecs that have a dependency satisfied by the named
- # spec.
- def spec_predecessors
- result = Hash.new { |h,k| h[k] = [] }
-
- specs = @specs.sort.reverse
-
- specs.each do |spec|
- specs.each do |other|
- next if spec == other
-
- other.dependencies.each do |dep|
- if spec.satisfies_requirement? dep then
- result[spec] << other
- end
- end
- end
- end
-
- result
- end
-
- def tsort_each_node(&block)
- @specs.each(&block)
- end
-
- def tsort_each_child(node, &block)
- specs = @specs.sort.reverse
-
- node.dependencies.each do |dep|
- specs.each do |spec|
- if spec.satisfies_requirement? dep then
- begin
- yield spec
- rescue TSort::Cyclic
- end
- break
- end
- end
- end
- end
-
- private
-
- # Count the number of gemspecs in the list +specs+ that are not in
- # +ignored+.
- def active_count(specs, ignored)
- result = 0
- specs.each do |spec|
- result += 1 unless ignored[spec.full_name]
- end
- result
- end
-
-end
-
diff --git a/lib/rubygems/digest/digest_adapter.rb b/lib/rubygems/digest/digest_adapter.rb
deleted file mode 100755
index d5a00b059d..0000000000
--- a/lib/rubygems/digest/digest_adapter.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-module Gem
-
- # There is an incompatibility between the way Ruby 1.8.5 and 1.8.6
- # handles digests. This DigestAdapter will take a pre-1.8.6 digest
- # and adapt it to the 1.8.6 API.
- #
- # Note that only the digest and hexdigest methods are adapted,
- # since these are the only functions used by Gems.
- #
- class DigestAdapter
-
- # Initialize a digest adapter.
- def initialize(digest_class)
- @digest_class = digest_class
- end
-
- # Return a new digester. Since we are only implementing the stateless
- # methods, we will return ourself as the instance.
- def new
- self
- end
-
- # Return the digest of +string+ as a hex string.
- def hexdigest(string)
- @digest_class.new(string).hexdigest
- end
-
- # Return the digest of +string+ as a binary string.
- def digest(string)
- @digest_class.new(string).digest
- end
- end
-end \ No newline at end of file
diff --git a/lib/rubygems/digest/md5.rb b/lib/rubygems/digest/md5.rb
deleted file mode 100755
index f924579c08..0000000000
--- a/lib/rubygems/digest/md5.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'digest/md5'
-
-# :stopdoc:
-module Gem
- if RUBY_VERSION >= '1.8.6'
- MD5 = Digest::MD5
- else
- require 'rubygems/digest/digest_adapter'
- MD5 = DigestAdapter.new(Digest::MD5)
- def MD5.md5(string)
- self.hexdigest(string)
- end
- end
-end
-# :startdoc:
-
diff --git a/lib/rubygems/digest/sha1.rb b/lib/rubygems/digest/sha1.rb
deleted file mode 100755
index 2a6245dcd9..0000000000
--- a/lib/rubygems/digest/sha1.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'digest/sha1'
-
-module Gem
- if RUBY_VERSION >= '1.8.6'
- SHA1 = Digest::SHA1
- else
- require 'rubygems/digest/digest_adapter'
- SHA1 = DigestAdapter.new(Digest::SHA1)
- end
-end \ No newline at end of file
diff --git a/lib/rubygems/digest/sha2.rb b/lib/rubygems/digest/sha2.rb
deleted file mode 100755
index 7bef16aed2..0000000000
--- a/lib/rubygems/digest/sha2.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'digest/sha2'
-
-module Gem
- if RUBY_VERSION >= '1.8.6'
- SHA256 = Digest::SHA256
- else
- require 'rubygems/digest/digest_adapter'
- SHA256 = DigestAdapter.new(Digest::SHA256)
- end
-end
diff --git a/lib/rubygems/doc_manager.rb b/lib/rubygems/doc_manager.rb
deleted file mode 100644
index 8d9b4a7b23..0000000000
--- a/lib/rubygems/doc_manager.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'fileutils'
-
-module Gem
-
- class DocManager
-
- include UserInteraction
-
- # Create a document manager for the given gem spec.
- #
- # spec:: The Gem::Specification object representing the gem.
- # rdoc_args:: Optional arguments for RDoc (template etc.) as a String.
- #
- def initialize(spec, rdoc_args="")
- @spec = spec
- @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
- @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
- end
-
- # Is the RDoc documentation installed?
- def rdoc_installed?
- return File.exist?(File.join(@doc_dir, "rdoc"))
- end
-
- # Generate the RI documents for this gem spec.
- #
- # Note that if both RI and RDoc documents are generated from the
- # same process, the RI docs should be done first (a likely bug in
- # RDoc will cause RI docs generation to fail if run after RDoc).
- def generate_ri
- if @spec.has_rdoc then
- load_rdoc
- install_ri # RDoc bug, ri goes first
- end
-
- FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
- end
-
- # Generate the RDoc documents for this gem spec.
- #
- # Note that if both RI and RDoc documents are generated from the
- # same process, the RI docs should be done first (a likely bug in
- # RDoc will cause RI docs generation to fail if run after RDoc).
- def generate_rdoc
- if @spec.has_rdoc then
- load_rdoc
- install_rdoc
- end
-
- FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
- end
-
- # Load the RDoc documentation generator library.
- def load_rdoc
- if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
- raise Gem::FilePermissionError.new(@doc_dir)
- end
-
- FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
-
- begin
- require 'rdoc/rdoc'
- rescue LoadError => e
- raise Gem::DocumentError,
- "ERROR: RDoc documentation generator not installed!"
- end
- end
-
- def install_rdoc
- rdoc_dir = File.join @doc_dir, 'rdoc'
-
- FileUtils.rm_rf rdoc_dir
-
- say "Installing RDoc documentation for #{@spec.full_name}..."
- run_rdoc '--op', rdoc_dir
- end
-
- def install_ri
- ri_dir = File.join @doc_dir, 'ri'
-
- FileUtils.rm_rf ri_dir
-
- say "Installing ri documentation for #{@spec.full_name}..."
- run_rdoc '--ri', '--op', ri_dir
- end
-
- def run_rdoc(*args)
- args << @spec.rdoc_options
- args << DocManager.configured_args
- args << '--quiet'
- args << @spec.require_paths.clone
- args << @spec.extra_rdoc_files
- args.flatten!
-
- r = RDoc::RDoc.new
-
- old_pwd = Dir.pwd
- Dir.chdir(@spec.full_gem_path)
- begin
- r.document args
- rescue Errno::EACCES => e
- dirname = File.dirname e.message.split("-")[1].strip
- raise Gem::FilePermissionError.new(dirname)
- rescue RuntimeError => ex
- alert_error "While generating documentation for #{@spec.full_name}"
- ui.errs.puts "... MESSAGE: #{ex}"
- ui.errs.puts "... RDOC args: #{args.join(' ')}"
- ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
- Gem.configuration.backtrace
- ui.errs.puts "(continuing with the rest of the installation)"
- ensure
- Dir.chdir(old_pwd)
- end
- end
-
- def uninstall_doc
- raise Gem::FilePermissionError.new(@spec.installation_path) unless
- File.writable? @spec.installation_path
-
- original_name = [
- @spec.name, @spec.version, @spec.original_platform].join '-'
-
- doc_dir = File.join @spec.installation_path, 'doc', @spec.full_name
- unless File.directory? doc_dir then
- doc_dir = File.join @spec.installation_path, 'doc', original_name
- end
-
- FileUtils.rm_rf doc_dir
-
- ri_dir = File.join @spec.installation_path, 'ri', @spec.full_name
-
- unless File.directory? ri_dir then
- ri_dir = File.join @spec.installation_path, 'ri', original_name
- end
-
- FileUtils.rm_rf ri_dir
- end
-
- class << self
- def configured_args
- @configured_args ||= []
- end
-
- def configured_args=(args)
- case args
- when Array
- @configured_args = args
- when String
- @configured_args = args.split
- end
- end
- end
-
- end
-end
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
deleted file mode 100644
index 294dad5748..0000000000
--- a/lib/rubygems/exceptions.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require 'rubygems'
-
-##
-# Base exception class for RubyGems. All exception raised by RubyGems are a
-# subclass of this one.
-class Gem::Exception < RuntimeError; end
-
-class Gem::CommandLineError < Gem::Exception; end
-
-class Gem::DependencyError < Gem::Exception; end
-
-class Gem::DependencyRemovalException < Gem::Exception; end
-
-class Gem::DocumentError < Gem::Exception; end
-
-##
-# Potentially raised when a specification is validated.
-class Gem::EndOfYAMLException < Gem::Exception; end
-
-##
-# Signals that a file permission error is preventing the user from
-# installing in the requested directories.
-class Gem::FilePermissionError < Gem::Exception
- def initialize(path)
- super("You don't have write permissions into the #{path} directory.")
- end
-end
-
-##
-# Used to raise parsing and loading errors
-class Gem::FormatException < Gem::Exception
- attr_accessor :file_path
-end
-
-class Gem::GemNotFoundException < Gem::Exception; end
-
-class Gem::InstallError < Gem::Exception; end
-
-##
-# Potentially raised when a specification is validated.
-class Gem::InvalidSpecificationException < Gem::Exception; end
-
-class Gem::OperationNotSupportedError < Gem::Exception; end
-
-##
-# Signals that a remote operation cannot be conducted, probably due to not
-# being connected (or just not finding host).
-#--
-# TODO: create a method that tests connection to the preferred gems server.
-# All code dealing with remote operations will want this. Failure in that
-# method should raise this error.
-class Gem::RemoteError < Gem::Exception; end
-
-class Gem::RemoteInstallationCancelled < Gem::Exception; end
-
-class Gem::RemoteInstallationSkipped < Gem::Exception; end
-
-##
-# Represents an error communicating via HTTP.
-class Gem::RemoteSourceException < Gem::Exception; end
-
-class Gem::VerificationError < Gem::Exception; end
-
diff --git a/lib/rubygems/ext.rb b/lib/rubygems/ext.rb
deleted file mode 100644
index 97ee762a4a..0000000000
--- a/lib/rubygems/ext.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-##
-# Classes for building C extensions live here.
-
-module Gem::Ext; end
-
-require 'rubygems/ext/builder'
-require 'rubygems/ext/configure_builder'
-require 'rubygems/ext/ext_conf_builder'
-require 'rubygems/ext/rake_builder'
-
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
deleted file mode 100644
index 576951a566..0000000000
--- a/lib/rubygems/ext/builder.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/ext'
-
-class Gem::Ext::Builder
-
- def self.class_name
- name =~ /Ext::(.*)Builder/
- $1.downcase
- end
-
- def self.make(dest_path, results)
- unless File.exist? 'Makefile' then
- raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
- end
-
- mf = File.read('Makefile')
- mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
- mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
-
- File.open('Makefile', 'wb') {|f| f.print mf}
-
- make_program = ENV['make']
- unless make_program then
- make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
- end
-
- ['', ' install'].each do |target|
- cmd = "#{make_program}#{target}"
- results << cmd
- results << `#{cmd} #{redirector}`
-
- raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
- $?.exitstatus.zero?
- end
- end
-
- def self.redirector
- '2>&1'
- end
-
- def self.run(command, results)
- results << command
- results << `#{command} #{redirector}`
-
- unless $?.exitstatus.zero? then
- raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"
- end
- end
-
-end
-
diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb
deleted file mode 100644
index 1cde6915a7..0000000000
--- a/lib/rubygems/ext/configure_builder.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/ext/builder'
-
-class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
-
- def self.build(extension, directory, dest_path, results)
- unless File.exist?('Makefile') then
- cmd = "sh ./configure --prefix=#{dest_path}"
-
- run cmd, results
- end
-
- make dest_path, results
-
- results
- end
-
-end
-
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
deleted file mode 100644
index cbe0e80821..0000000000
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/ext/builder'
-
-class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
-
- def self.build(extension, directory, dest_path, results)
- cmd = "#{Gem.ruby} #{File.basename extension}"
- cmd << " #{ARGV.join ' '}" unless ARGV.empty?
-
- run cmd, results
-
- make dest_path, results
-
- results
- end
-
-end
-
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
deleted file mode 100644
index 3772f6a00f..0000000000
--- a/lib/rubygems/ext/rake_builder.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/ext/builder'
-
-class Gem::Ext::RakeBuilder < Gem::Ext::Builder
-
- def self.build(extension, directory, dest_path, results)
- if File.basename(extension) =~ /mkrf_conf/i then
- cmd = "#{Gem.ruby} #{File.basename extension}"
- cmd << " #{ARGV.join " "}" unless ARGV.empty?
- run cmd, results
- end
-
- cmd = ENV['rake'] || 'rake'
- cmd << " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
-
- run cmd, results
-
- results
- end
-
-end
-
diff --git a/lib/rubygems/format.rb b/lib/rubygems/format.rb
deleted file mode 100644
index 378a93018c..0000000000
--- a/lib/rubygems/format.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'fileutils'
-
-require 'rubygems/package'
-
-module Gem
-
- ##
- # The format class knows the guts of the RubyGem .gem file format
- # and provides the capability to read gem files
- #
- class Format
- attr_accessor :spec, :file_entries, :gem_path
- extend Gem::UserInteraction
-
- ##
- # Constructs an instance of a Format object, representing the gem's
- # data structure.
- #
- # gem:: [String] The file name of the gem
- #
- def initialize(gem_path)
- @gem_path = gem_path
- end
-
- ##
- # Reads the named gem file and returns a Format object, representing
- # the data from the gem file
- #
- # file_path:: [String] Path to the gem file
- #
- def self.from_file_by_path(file_path, security_policy = nil)
- format = nil
-
- unless File.exist?(file_path)
- raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
- end
-
- # check for old version gem
- if File.read(file_path, 20).include?("MD5SUM =")
- #alert_warning "Gem #{file_path} is in old format."
- require 'rubygems/old_format'
- format = OldFormat.from_file_by_path(file_path)
- else
- begin
- f = File.open(file_path, 'rb')
- format = from_io(f, file_path, security_policy)
- ensure
- f.close unless f.closed?
- end
- end
-
- return format
- end
-
- ##
- # Reads a gem from an io stream and returns a Format object, representing
- # the data from the gem file
- #
- # io:: [IO] Stream from which to read the gem
- #
- def self.from_io(io, gem_path="(io)", security_policy = nil)
- format = self.new(gem_path)
- Package.open_from_io(io, 'r', security_policy) do |pkg|
- format.spec = pkg.metadata
- format.file_entries = []
- pkg.each do |entry|
- format.file_entries << [{"size" => entry.size, "mode" => entry.mode,
- "path" => entry.full_name}, entry.read]
- end
- end
- format
- end
-
- end
-end
diff --git a/lib/rubygems/gem_open_uri.rb b/lib/rubygems/gem_open_uri.rb
deleted file mode 100644
index 597930dc50..0000000000
--- a/lib/rubygems/gem_open_uri.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env ruby
-
-if RUBY_VERSION > '1.9' then
- require 'open-uri'
-else
- require 'rubygems/open-uri'
-end
diff --git a/lib/rubygems/gem_openssl.rb b/lib/rubygems/gem_openssl.rb
deleted file mode 100644
index 17e7d0f2bf..0000000000
--- a/lib/rubygems/gem_openssl.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-# Some system might not have OpenSSL installed, therefore the core
-# library file openssl might not be available. We localize testing
-# for the presence of OpenSSL in this file.
-
-module Gem
- class << self
- # Is SSL (used by the signing commands) available on this
- # platform?
- def ssl_available?
- require 'rubygems/gem_openssl'
- @ssl_available
- end
-
- # Set the value of the ssl_avilable flag.
- attr_writer :ssl_available
-
- # Ensure that SSL is available. Throw an exception if it is not.
- def ensure_ssl_available
- unless ssl_available?
- fail Gem::Exception, "SSL is not installed on this system"
- end
- end
- end
-end
-
-begin
- require 'openssl'
-
- # Reference a constant defined in the .rb portion of ssl (just to
- # make sure that part is loaded too).
-
- dummy = OpenSSL::Digest::SHA1
-
- Gem.ssl_available = true
-
- class OpenSSL::X509::Certificate # :nodoc:
- # Check the validity of this certificate.
- def check_validity(issuer_cert = nil, time = Time.now)
- ret = if @not_before && @not_before > time
- [false, :expired, "not valid before '#@not_before'"]
- elsif @not_after && @not_after < time
- [false, :expired, "not valid after '#@not_after'"]
- elsif issuer_cert && !verify(issuer_cert.public_key)
- [false, :issuer, "#{issuer_cert.subject} is not issuer"]
- else
- [true, :ok, 'Valid certificate']
- end
-
- # return hash
- { :is_valid => ret[0], :error => ret[1], :desc => ret[2] }
- end
- end
-
-rescue LoadError, StandardError
- Gem.ssl_available = false
-end
-
-module Gem::SSL
-
- # We make our own versions of the constants here. This allows us
- # to reference the constants, even though some systems might not
- # have SSL installed in the Ruby core package.
- #
- # These constants are only used during load time. At runtime, any
- # method that makes a direct reference to SSL software must be
- # protected with a Gem.ensure_ssl_available call.
- #
- if Gem.ssl_available? then
- PKEY_RSA = OpenSSL::PKey::RSA
- DIGEST_SHA1 = OpenSSL::Digest::SHA1
- else
- PKEY_RSA = :rsa
- DIGEST_SHA1 = :sha1
- end
-
-end
-
diff --git a/lib/rubygems/gem_path_searcher.rb b/lib/rubygems/gem_path_searcher.rb
deleted file mode 100644
index dadad66289..0000000000
--- a/lib/rubygems/gem_path_searcher.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-#
-# GemPathSearcher has the capability to find loadable files inside
-# gems. It generates data up front to speed up searches later.
-#
-class Gem::GemPathSearcher
-
- #
- # Initialise the data we need to make searches later.
- #
- def initialize
- # We want a record of all the installed gemspecs, in the order
- # we wish to examine them.
- @gemspecs = init_gemspecs
- # Map gem spec to glob of full require_path directories.
- # Preparing this information may speed up searches later.
- @lib_dirs = {}
- @gemspecs.each do |spec|
- @lib_dirs[spec.object_id] = lib_dirs_for(spec)
- end
- end
-
- #
- # Look in all the installed gems until a matching _path_ is found.
- # Return the _gemspec_ of the gem where it was found. If no match
- # is found, return nil.
- #
- # The gems are searched in alphabetical order, and in reverse
- # version order.
- #
- # For example:
- #
- # find('log4r') # -> (log4r-1.1 spec)
- # find('log4r.rb') # -> (log4r-1.1 spec)
- # find('rake/rdoctask') # -> (rake-0.4.12 spec)
- # find('foobarbaz') # -> nil
- #
- # Matching paths can have various suffixes ('.rb', '.so', and
- # others), which may or may not already be attached to _file_.
- # This method doesn't care about the full filename that matches;
- # only that there is a match.
- #
- def find(path)
- @gemspecs.each do |spec|
- return spec if matching_file(spec, path)
- end
- nil
- end
-
- private
-
- # Attempts to find a matching path using the require_paths of the
- # given _spec_.
- #
- # Some of the intermediate results are cached in @lib_dirs for
- # speed.
- def matching_file(spec, path) # :doc:
- glob = File.join @lib_dirs[spec.object_id], "#{path}#{Gem.suffix_pattern}"
- return true unless Dir[glob].select { |f| File.file?(f.untaint) }.empty?
- end
-
- # Return a list of all installed gemspecs, sorted by alphabetical
- # order and in reverse version order.
- def init_gemspecs
- Gem.source_index.map { |_, spec| spec }.sort { |a,b|
- (a.name <=> b.name).nonzero? || (b.version <=> a.version)
- }
- end
-
- # Returns library directories glob for a gemspec. For example,
- # '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
- def lib_dirs_for(spec)
- "#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}"
- end
-
-end
-
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
deleted file mode 100644
index 5f91398b5b..0000000000
--- a/lib/rubygems/gem_runner.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/command_manager'
-require 'rubygems/config_file'
-require 'rubygems/doc_manager'
-
-module Gem
-
- ####################################################################
- # Run an instance of the gem program.
- #
- class GemRunner
-
- def initialize(options={})
- @command_manager_class = options[:command_manager] || Gem::CommandManager
- @config_file_class = options[:config_file] || Gem::ConfigFile
- @doc_manager_class = options[:doc_manager] || Gem::DocManager
- end
-
- # Run the gem command with the following arguments.
- def run(args)
- start_time = Time.now
- do_configuration(args)
- cmd = @command_manager_class.instance
- cmd.command_names.each do |command_name|
- config_args = Gem.configuration[command_name]
- config_args = case config_args
- when String
- config_args.split ' '
- else
- Array(config_args)
- end
- Command.add_specific_extra_args command_name, config_args
- end
- cmd.run(Gem.configuration.args)
- end_time = Time.now
- if Gem.configuration.benchmark
- printf "\nExecution time: %0.2f seconds.\n", end_time-start_time
- puts "Press Enter to finish"
- STDIN.gets
- end
- end
-
- private
-
- def do_configuration(args)
- Gem.configuration = @config_file_class.new(args)
- Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
- Gem::Command.extra_args = Gem.configuration[:gem]
- @doc_manager_class.configured_args = Gem.configuration[:rdoc]
- end
-
- end # class
-end # module
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
deleted file mode 100644
index 272cee3fd3..0000000000
--- a/lib/rubygems/indexer.rb
+++ /dev/null
@@ -1,163 +0,0 @@
-require 'fileutils'
-require 'tmpdir'
-
-require 'rubygems'
-require 'rubygems/format'
-
-begin
- require 'builder/xchar'
-rescue LoadError
-end
-
-##
-# Top level class for building the gem repository index.
-class Gem::Indexer
-
- include Gem::UserInteraction
-
- ##
- # Index install location
-
- attr_reader :dest_directory
-
- ##
- # Index build directory
-
- attr_reader :directory
-
- # Create an indexer that will index the gems in +directory+.
- def initialize(directory)
- unless ''.respond_to? :to_xs then
- fail "Gem::Indexer requires that the XML Builder library be installed:" \
- "\n\tgem install builder"
- end
-
- @dest_directory = directory
- @directory = File.join Dir.tmpdir, "gem_generate_index_#{$$}"
-
- marshal_name = "Marshal.#{Gem.marshal_version}"
-
- @master_index = Gem::Indexer::MasterIndexBuilder.new "yaml", @directory
- @marshal_index = Gem::Indexer::MarshalIndexBuilder.new marshal_name, @directory
- @quick_index = Gem::Indexer::QuickIndexBuilder.new "index", @directory
- end
-
- # Build the index.
- def build_index
- @master_index.build do
- @quick_index.build do
- @marshal_index.build do
- progress = ui.progress_reporter gem_file_list.size,
- "Generating index for #{gem_file_list.size} gems in #{@dest_directory}",
- "Loaded all gems"
-
- gem_file_list.each do |gemfile|
- if File.size(gemfile.to_s) == 0 then
- alert_warning "Skipping zero-length gem: #{gemfile}"
- next
- end
-
- begin
- spec = Gem::Format.from_file_by_path(gemfile).spec
-
- unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
- alert_warning "Skipping misnamed gem: #{gemfile} => #{spec.full_name} (#{spec.original_name})"
- next
- end
-
- abbreviate spec
- sanitize spec
-
- @master_index.add spec
- @quick_index.add spec
- @marshal_index.add spec
-
- progress.updated spec.original_name
-
- rescue SignalException => e
- alert_error "Recieved signal, exiting"
- raise
- rescue Exception => e
- alert_error "Unable to process #{gemfile}\n#{e.message} (#{e.class})\n\t#{e.backtrace.join "\n\t"}"
- end
- end
-
- progress.done
-
- say "Generating master indexes (this may take a while)"
- end
- end
- end
- end
-
- def install_index
- verbose = Gem.configuration.really_verbose
-
- say "Moving index into production dir #{@dest_directory}" if verbose
-
- files = @master_index.files + @quick_index.files + @marshal_index.files
-
- files.each do |file|
- relative_name = file[/\A#{Regexp.escape @directory}.(.*)/, 1]
- dest_name = File.join @dest_directory, relative_name
-
- FileUtils.rm_rf dest_name, :verbose => verbose
- FileUtils.mv file, @dest_directory, :verbose => verbose
- end
- end
-
- def generate_index
- FileUtils.rm_rf @directory
- FileUtils.mkdir_p @directory, :mode => 0700
-
- build_index
- install_index
- rescue SignalException
- ensure
- FileUtils.rm_rf @directory
- end
-
- # List of gem file names to index.
- def gem_file_list
- Dir.glob(File.join(@dest_directory, "gems", "*.gem"))
- end
-
- # Abbreviate the spec for downloading. Abbreviated specs are only
- # used for searching, downloading and related activities and do not
- # need deployment specific information (e.g. list of files). So we
- # abbreviate the spec, making it much smaller for quicker downloads.
- def abbreviate(spec)
- spec.files = []
- spec.test_files = []
- spec.rdoc_options = []
- spec.extra_rdoc_files = []
- spec.cert_chain = []
- spec
- end
-
- # Sanitize the descriptive fields in the spec. Sometimes non-ASCII
- # characters will garble the site index. Non-ASCII characters will
- # be replaced by their XML entity equivalent.
- def sanitize(spec)
- spec.summary = sanitize_string(spec.summary)
- spec.description = sanitize_string(spec.description)
- spec.post_install_message = sanitize_string(spec.post_install_message)
- spec.authors = spec.authors.collect { |a| sanitize_string(a) }
- spec
- end
-
- # Sanitize a single string.
- def sanitize_string(string)
- # HACK the #to_s is in here because RSpec has an Array of Arrays of
- # Strings for authors. Need a way to disallow bad values on gempsec
- # generation. (Probably won't happen.)
- string ? string.to_s.to_xs : string
- end
-
-end
-
-require 'rubygems/indexer/abstract_index_builder'
-require 'rubygems/indexer/master_index_builder'
-require 'rubygems/indexer/quick_index_builder'
-require 'rubygems/indexer/marshal_index_builder'
-
diff --git a/lib/rubygems/indexer/abstract_index_builder.rb b/lib/rubygems/indexer/abstract_index_builder.rb
deleted file mode 100644
index f25f21707b..0000000000
--- a/lib/rubygems/indexer/abstract_index_builder.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'zlib'
-
-require 'rubygems/indexer'
-
-# Abstract base class for building gem indicies. Uses the template pattern
-# with subclass specialization in the +begin_index+, +end_index+ and +cleanup+
-# methods.
-class Gem::Indexer::AbstractIndexBuilder
-
- # Directory to put index files in
- attr_reader :directory
-
- # File name of the generated index
- attr_reader :filename
-
- # List of written files/directories to move into production
- attr_reader :files
-
- def initialize(filename, directory)
- @filename = filename
- @directory = directory
- @files = []
- end
-
- # Build a Gem index. Yields to block to handle the details of the
- # actual building. Calls +begin_index+, +end_index+ and +cleanup+ at
- # appropriate times to customize basic operations.
- def build
- FileUtils.mkdir_p @directory unless File.exist? @directory
- raise "not a directory: #{@directory}" unless File.directory? @directory
-
- file_path = File.join @directory, @filename
-
- @files << file_path
-
- File.open file_path, "wb" do |file|
- @file = file
- start_index
- yield
- end_index
- end
- cleanup
- ensure
- @file = nil
- end
-
- # Compress the given file.
- def compress(filename, ext="rz")
- zipped = zip(File.open(filename, 'rb'){ |fp| fp.read })
- File.open "#{filename}.#{ext}", "wb" do |file|
- file.write zipped
- end
- end
-
- # Called immediately before the yield in build. The index file is open and
- # available as @file.
- def start_index
- end
-
- # Called immediately after the yield in build. The index file is still open
- # and available as @file.
- def end_index
- end
-
- # Called from within builder after the index file has been closed.
- def cleanup
- end
-
- # Return an uncompressed version of a compressed string.
- def unzip(string)
- Zlib::Inflate.inflate(string)
- end
-
- # Return a compressed version of the given string.
- def zip(string)
- Zlib::Deflate.deflate(string)
- end
-
-end
-
diff --git a/lib/rubygems/indexer/marshal_index_builder.rb b/lib/rubygems/indexer/marshal_index_builder.rb
deleted file mode 100644
index e1a4d9f9b8..0000000000
--- a/lib/rubygems/indexer/marshal_index_builder.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'rubygems/indexer'
-
-# Construct the master Gem index file.
-class Gem::Indexer::MarshalIndexBuilder < Gem::Indexer::MasterIndexBuilder
- def end_index
- gems = {}
- index = Gem::SourceIndex.new
-
- @index.each do |name, gemspec|
- gems[gemspec.original_name] = gemspec
- end
-
- index.instance_variable_get(:@gems).replace gems
-
- @file.write index.dump
- end
-end
diff --git a/lib/rubygems/indexer/master_index_builder.rb b/lib/rubygems/indexer/master_index_builder.rb
deleted file mode 100644
index dbe02370a9..0000000000
--- a/lib/rubygems/indexer/master_index_builder.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'rubygems/indexer'
-
-# Construct the master Gem index file.
-class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
-
- def start_index
- super
- @index = Gem::SourceIndex.new
- end
-
- def end_index
- super
- @file.puts "--- !ruby/object:#{@index.class}"
- @file.puts "gems:"
-
- gems = @index.sort_by { |name, gemspec| gemspec.sort_obj }
- gems.each do |name, gemspec|
- yaml = gemspec.to_yaml.gsub(/^/, ' ')
- yaml = yaml.sub(/\A ---/, '') # there's a needed extra ' ' here
- @file.print " #{gemspec.original_name}:"
- @file.puts yaml
- end
- end
-
- def cleanup
- super
-
- index_file_name = File.join @directory, @filename
-
- compress index_file_name, "Z"
- compressed_file_name = "#{index_file_name}.Z"
-
- paranoid index_file_name, compressed_file_name
-
- @files << compressed_file_name
- end
-
- def add(spec)
- @index.add_spec(spec)
- end
-
- private
-
- def paranoid(fn, compressed_fn)
- data = File.open(fn, 'rb') do |fp| fp.read end
- compressed_data = File.open(compressed_fn, 'rb') do |fp| fp.read end
-
- if data != unzip(compressed_data) then
- fail "Compressed file #{compressed_fn} does not match uncompressed file #{fn}"
- end
- end
-
-end
diff --git a/lib/rubygems/indexer/quick_index_builder.rb b/lib/rubygems/indexer/quick_index_builder.rb
deleted file mode 100644
index 23c7ca696b..0000000000
--- a/lib/rubygems/indexer/quick_index_builder.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'rubygems/indexer'
-
-# Construct a quick index file and all of the individual specs to support
-# incremental loading.
-class Gem::Indexer::QuickIndexBuilder < Gem::Indexer::AbstractIndexBuilder
-
- def initialize(filename, directory)
- directory = File.join directory, 'quick'
-
- super filename, directory
- end
-
- def cleanup
- super
-
- quick_index_file = File.join(@directory, @filename)
- compress quick_index_file
-
- # the complete quick index is in a directory, so move it as a whole
- @files.delete quick_index_file
- @files << @directory
- end
-
- def add(spec)
- @file.puts spec.original_name
- add_yaml(spec)
- add_marshal(spec)
- end
-
- def add_yaml(spec)
- fn = File.join @directory, "#{spec.original_name}.gemspec.rz"
- zipped = zip spec.to_yaml
- File.open fn, "wb" do |gsfile| gsfile.write zipped end
- end
-
- def add_marshal(spec)
- # HACK why does this not work in #initialize?
- FileUtils.mkdir_p File.join(@directory, "Marshal.#{Gem.marshal_version}")
-
- fn = File.join @directory, "Marshal.#{Gem.marshal_version}",
- "#{spec.original_name}.gemspec.rz"
-
- zipped = zip Marshal.dump(spec)
- File.open fn, "wb" do |gsfile| gsfile.write zipped end
- end
-
-end
-
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
deleted file mode 100644
index b93e21551c..0000000000
--- a/lib/rubygems/install_update_options.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-require 'rubygems/security'
-
-##
-# Mixin methods for install and update options for Gem::Commands
-module Gem::InstallUpdateOptions
-
- # Add the install/update options to the option parser.
- def add_install_update_options
- OptionParser.accept Gem::Security::Policy do |value|
- value = Gem::Security::Policies[value]
- raise OptionParser::InvalidArgument, value if value.nil?
- value
- end
-
- add_option(:"Install/Update", '-i', '--install-dir DIR',
- 'Gem repository directory to get installed',
- 'gems') do |value, options|
- options[:install_dir] = File.expand_path(value)
- end
-
- add_option(:"Install/Update", '-d', '--[no-]rdoc',
- 'Generate RDoc documentation for the gem on',
- 'install') do |value, options|
- options[:generate_rdoc] = value
- end
-
- add_option(:"Install/Update", '--[no-]ri',
- 'Generate RI documentation for the gem on',
- 'install') do |value, options|
- options[:generate_ri] = value
- end
-
- add_option(:"Install/Update", '-E', '--env-shebang',
- "Rewrite the shebang line on installed",
- "scripts to use /usr/bin/env") do |value, options|
- options[:env_shebang] = value
- end
-
- add_option(:"Install/Update", '-f', '--[no-]force',
- 'Force gem to install, bypassing dependency',
- 'checks') do |value, options|
- options[:force] = value
- end
-
- add_option(:"Install/Update", '-t', '--[no-]test',
- 'Run unit tests prior to installation') do |value, options|
- options[:test] = value
- end
-
- add_option(:"Install/Update", '-w', '--[no-]wrappers',
- 'Use bin wrappers for executables',
- 'Not available on dosish platforms') do |value, options|
- options[:wrappers] = value
- end
-
- add_option(:"Install/Update", '-P', '--trust-policy POLICY',
- Gem::Security::Policy,
- 'Specify gem trust policy') do |value, options|
- options[:security_policy] = value
- end
-
- add_option(:"Install/Update", '--ignore-dependencies',
- 'Do not install any required dependent gems') do |value, options|
- options[:ignore_dependencies] = value
- end
-
- add_option(:"Install/Update", '-y', '--include-dependencies',
- 'Unconditionally install the required',
- 'dependent gems') do |value, options|
- options[:include_dependencies] = value
- end
-
- add_option(:"Install/Update", '--[no-]format-executable',
- 'Make installed executable names match ruby.',
- 'If ruby is ruby18, foo_exec will be',
- 'foo_exec18') do |value, options|
- options[:format_executable] = value
- end
- end
-
- # Default options for the gem install command.
- def install_update_defaults_str
- '--rdoc --no-force --no-test --wrappers'
- end
-
-end
-
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
deleted file mode 100644
index e652ac9c6d..0000000000
--- a/lib/rubygems/installer.rb
+++ /dev/null
@@ -1,476 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'fileutils'
-require 'pathname'
-require 'rbconfig'
-
-require 'rubygems/format'
-require 'rubygems/ext'
-require 'rubygems/require_paths_builder'
-
-##
-# The installer class processes RubyGem .gem files and installs the
-# files contained in the .gem into the Gem.path.
-#
-# Gem::Installer does the work of putting files in all the right places on the
-# filesystem including unpacking the gem into its gem dir, installing the
-# gemspec in the specifications dir, storing the cached gem in the cache dir,
-# and installing either wrappers or symlinks for executables.
-class Gem::Installer
-
- ##
- # Raised when there is an error while building extensions.
- #
- class ExtensionBuildError < Gem::InstallError; end
-
- include Gem::UserInteraction
-
- include Gem::RequirePathsBuilder
-
- class << self
-
- attr_writer :exec_format
-
- # Defaults to use Ruby's program prefix and suffix.
- def exec_format
- @exec_format ||= Gem.default_exec_format
- end
-
- end
-
- ##
- # Constructs an Installer instance that will install the gem located at
- # +gem+. +options+ is a Hash with the following keys:
- #
- # :env_shebang:: Use /usr/bin/env in bin wrappers.
- # :force:: Overrides all version checks and security policy checks, except
- # for a signed-gems-only policy.
- # :ignore_dependencies:: Don't raise if a dependency is missing.
- # :install_dir:: The directory to install the gem into.
- # :format_executable:: Format the executable the same as the ruby executable.
- # If your ruby is ruby18, foo_exec will be installed as
- # foo_exec18.
- # :security_policy:: Use the specified security policy. See Gem::Security
- # :wrappers:: Install wrappers if true, symlinks if false.
- def initialize(gem, options={})
- @gem = gem
-
- options = {
- :force => false,
- :install_dir => Gem.dir,
- :exec_format => false,
- }.merge options
-
- @env_shebang = options[:env_shebang]
- @force = options[:force]
- gem_home = options[:install_dir]
- @gem_home = Pathname.new(gem_home).expand_path
- @ignore_dependencies = options[:ignore_dependencies]
- @format_executable = options[:format_executable]
- @security_policy = options[:security_policy]
- @wrappers = options[:wrappers]
-
- begin
- @format = Gem::Format.from_file_by_path @gem, @security_policy
- rescue Gem::Package::FormatError
- raise Gem::InstallError, "invalid gem format for #{@gem}"
- end
-
- @spec = @format.spec
-
- @gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint
- end
-
- ##
- # Installs the gem and returns a loaded Gem::Specification for the installed
- # gem.
- #
- # The gem will be installed with the following structure:
- #
- # @gem_home/
- # cache/<gem-version>.gem #=> a cached copy of the installed gem
- # gems/<gem-version>/... #=> extracted files
- # specifications/<gem-version>.gemspec #=> the Gem::Specification
- def install
- # If we're forcing the install then disable security unless the security
- # policy says that we only install singed gems.
- @security_policy = nil if @force and @security_policy and
- not @security_policy.only_signed
-
- unless @force then
- if rrv = @spec.required_ruby_version then
- unless rrv.satisfied_by? Gem::Version.new(RUBY_VERSION) then
- raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}"
- end
- end
-
- if rrgv = @spec.required_rubygems_version then
- unless rrgv.satisfied_by? Gem::Version.new(Gem::RubyGemsVersion) then
- raise Gem::InstallError,
- "#{@spec.name} requires RubyGems version #{rrgv}"
- end
- end
-
- unless @ignore_dependencies then
- @spec.dependencies.each do |dep_gem|
- ensure_dependency @spec, dep_gem
- end
- end
- end
-
- FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
- raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
-
- Gem.ensure_gem_subdirectories @gem_home
-
- FileUtils.mkdir_p @gem_dir
-
- extract_files
- generate_bin
- build_extensions
- write_spec
-
- write_require_paths_file_if_needed
-
- # HACK remove? Isn't this done in multiple places?
- cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
- unless File.exist? cached_gem then
- FileUtils.cp @gem, File.join(@gem_home, "cache")
- end
-
- say @spec.post_install_message unless @spec.post_install_message.nil?
-
- @spec.loaded_from = File.join(@gem_home, 'specifications',
- "#{@spec.full_name}.gemspec")
-
- return @spec
- rescue Zlib::GzipFile::Error
- raise Gem::InstallError, "gzip error installing #{@gem}"
- end
-
- ##
- # Ensure that the dependency is satisfied by the current installation of
- # gem. If it is not an exception is raised.
- #
- # spec :: Gem::Specification
- # dependency :: Gem::Dependency
- def ensure_dependency(spec, dependency)
- unless installation_satisfies_dependency? dependency then
- raise Gem::InstallError, "#{spec.name} requires #{dependency}"
- end
-
- true
- end
-
- ##
- # True if the current installed gems satisfy the given dependency.
- #
- # dependency :: Gem::Dependency
- def installation_satisfies_dependency?(dependency)
- current_index = Gem::SourceIndex.from_installed_gems
- current_index.find_name(dependency.name, dependency.version_requirements).size > 0
- end
-
- ##
- # Unpacks the gem into the given directory.
- #
- def unpack(directory)
- @gem_dir = directory
- @format = Gem::Format.from_file_by_path @gem, @security_policy
- extract_files
- end
-
- ##
- # Writes the .gemspec specification (in Ruby) to the supplied
- # spec_path.
- #
- # spec:: [Gem::Specification] The Gem specification to output
- # spec_path:: [String] The location (path) to write the gemspec to
- #
- def write_spec
- rubycode = @spec.to_ruby
-
- file_name = File.join @gem_home, 'specifications',
- "#{@spec.full_name}.gemspec"
- file_name.untaint
-
- File.open(file_name, "w") do |file|
- file.puts rubycode
- end
- end
-
- ##
- # Creates windows .bat files for easy running of commands
- #
- def generate_windows_script(bindir, filename)
- if Gem.win_platform? then
- script_name = filename + ".bat"
- script_path = File.join bindir, File.basename(script_name)
- File.open script_path, 'w' do |file|
- file.puts windows_stub_script(bindir, filename)
- end
-
- say script_path if Gem.configuration.really_verbose
- end
- end
-
- def generate_bin
- return if @spec.executables.nil? or @spec.executables.empty?
-
- # If the user has asked for the gem to be installed in a directory that is
- # the system gem directory, then use the system bin directory, else create
- # (or use) a new bin dir under the gem_home.
- bindir = Gem.bindir @gem_home
-
- Dir.mkdir bindir unless File.exist? bindir
- raise Gem::FilePermissionError.new(bindir) unless File.writable? bindir
-
- @spec.executables.each do |filename|
- filename.untaint
- bin_path = File.expand_path File.join(@gem_dir, @spec.bindir, filename)
- mode = File.stat(bin_path).mode | 0111
- File.chmod mode, bin_path
-
- if @wrappers then
- generate_bin_script filename, bindir
- else
- generate_bin_symlink filename, bindir
- end
- end
- end
-
- ##
- # Creates the scripts to run the applications in the gem.
- #--
- # The Windows script is generated in addition to the regular one due to a
- # bug or misfeature in the Windows shell's pipe. See
- # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/193379
- #
- def generate_bin_script(filename, bindir)
- bin_script_path = File.join bindir, formatted_program_filename(filename)
-
- exec_path = File.join @gem_dir, @spec.bindir, filename
-
- # HACK some gems don't have #! in their executables, restore 2008/06
- #if File.read(exec_path, 2) == '#!' then
- File.open bin_script_path, 'w', 0755 do |file|
- file.print app_script_text(filename)
- end
-
- say bin_script_path if Gem.configuration.really_verbose
-
- generate_windows_script bindir, filename
- #else
- # FileUtils.rm_f bin_script_path
- # FileUtils.cp exec_path, bin_script_path,
- # :verbose => Gem.configuration.really_verbose
- #end
- end
-
- ##
- # Creates the symlinks to run the applications in the gem. Moves
- # the symlink if the gem being installed has a newer version.
- #
- def generate_bin_symlink(filename, bindir)
- if Gem.win_platform? then
- alert_warning "Unable to use symlinks on Windows, installing wrapper"
- generate_bin_script filename, bindir
- return
- end
-
- src = File.join @gem_dir, 'bin', filename
- dst = File.join bindir, formatted_program_filename(filename)
-
- if File.exist? dst then
- if File.symlink? dst then
- link = File.readlink(dst).split File::SEPARATOR
- cur_version = Gem::Version.create(link[-3].sub(/^.*-/, ''))
- return if @spec.version < cur_version
- end
- File.unlink dst
- end
-
- FileUtils.symlink src, dst, :verbose => Gem.configuration.really_verbose
- end
-
- ##
- # Generates a #! line for +bin_file_name+'s wrapper copying arguments if
- # necessary.
- def shebang(bin_file_name)
- if @env_shebang then
- "#!/usr/bin/env ruby"
- else
- path = File.join @gem_dir, @spec.bindir, bin_file_name
-
- File.open(path, "rb") do |file|
- first_line = file.gets
- if first_line =~ /^#!/ then
- # Preserve extra words on shebang line, like "-w". Thanks RPA.
- shebang = first_line.sub(/\A\#!.*?ruby\S*/, "#!#{Gem.ruby}")
- else
- # Create a plain shebang line.
- shebang = "#!#{Gem.ruby}"
- end
-
- shebang.strip # Avoid nasty ^M issues.
- end
- end
- end
-
- # Return the text for an application file.
- def app_script_text(bin_file_name)
- <<-TEXT
-#{shebang bin_file_name}
-#
-# This file was generated by RubyGems.
-#
-# The application '#{@spec.name}' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = "#{Gem::Requirement.default}"
-
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
- version = $1
- ARGV.shift
-end
-
-gem '#{@spec.name}', version
-load '#{bin_file_name}'
-TEXT
- end
-
- # return the stub script text used to launch the true ruby script
- def windows_stub_script(bindir, bin_file_name)
- <<-TEXT
-@ECHO OFF
-IF NOT "%~f0" == "~f0" GOTO :WinNT
-@"#{Gem.ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
-GOTO :EOF
-:WinNT
-"%~dp0ruby.exe" "%~dpn0" %*
-TEXT
- end
-
- # Builds extensions. Valid types of extensions are extconf.rb files,
- # configure scripts and rakefiles or mkrf_conf files.
- def build_extensions
- return if @spec.extensions.empty?
- say "Building native extensions. This could take a while..."
- start_dir = Dir.pwd
- dest_path = File.join @gem_dir, @spec.require_paths.first
- ran_rake = false # only run rake once
-
- @spec.extensions.each do |extension|
- break if ran_rake
- results = []
-
- builder = case extension
- when /extconf/ then
- Gem::Ext::ExtConfBuilder
- when /configure/ then
- Gem::Ext::ConfigureBuilder
- when /rakefile/i, /mkrf_conf/i then
- ran_rake = true
- Gem::Ext::RakeBuilder
- else
- results = ["No builder for extension '#{extension}'"]
- nil
- end
-
- begin
- Dir.chdir File.join(@gem_dir, File.dirname(extension))
- results = builder.build(extension, @gem_dir, dest_path, results)
-
- say results.join("\n") if Gem.configuration.really_verbose
-
- rescue => ex
- results = results.join "\n"
-
- File.open('gem_make.out', 'wb') { |f| f.puts results }
-
- message = <<-EOF
-ERROR: Failed to build gem native extension.
-
-#{results}
-
-Gem files will remain installed in #{@gem_dir} for inspection.
-Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
- EOF
-
- raise ExtensionBuildError, message
- ensure
- Dir.chdir start_dir
- end
- end
- end
-
- ##
- # Reads the file index and extracts each file into the gem directory.
- #
- # Ensures that files can't be installed outside the gem directory.
- def extract_files
- expand_and_validate_gem_dir
-
- raise ArgumentError, "format required to extract from" if @format.nil?
-
- @format.file_entries.each do |entry, file_data|
- path = entry['path'].untaint
-
- if path =~ /\A\// then # for extra sanity
- raise Gem::InstallError,
- "attempt to install file into #{entry['path'].inspect}"
- end
-
- path = File.expand_path File.join(@gem_dir, path)
-
- if path !~ /\A#{Regexp.escape @gem_dir}/ then
- msg = "attempt to install file into %p under %p" %
- [entry['path'], @gem_dir]
- raise Gem::InstallError, msg
- end
-
- FileUtils.mkdir_p File.dirname(path)
-
- File.open(path, "wb") do |out|
- out.write file_data
- end
-
- say path if Gem.configuration.really_verbose
- end
- end
-
- # Prefix and suffix the program filename the same as ruby.
- def formatted_program_filename(filename)
- if @format_executable then
- self.class.exec_format % File.basename(filename)
- else
- filename
- end
- end
-
- private
-
- # HACK Pathname is broken on windows.
- def absolute_path? pathname
- pathname.absolute? or (Gem.win_platform? and pathname.to_s =~ /\A[a-z]:/i)
- end
-
- def expand_and_validate_gem_dir
- @gem_dir = Pathname.new(@gem_dir).expand_path
-
- unless absolute_path?(@gem_dir) then # HACK is this possible after #expand_path?
- raise ArgumentError, "install directory %p not absolute" % @gem_dir
- end
-
- @gem_dir = @gem_dir.to_s
- end
-
-end
-
diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb
deleted file mode 100644
index 1a5410bef7..0000000000
--- a/lib/rubygems/local_remote_options.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-# Mixin methods for local and remote Gem::Command options.
-module Gem::LocalRemoteOptions
-
- # Allows OptionParser to handle HTTP URIs.
- def accept_uri_http
- OptionParser.accept URI::HTTP do |value|
- begin
- value = URI.parse value
- rescue URI::InvalidURIError
- raise OptionParser::InvalidArgument, value
- end
-
- raise OptionParser::InvalidArgument, value unless value.scheme == 'http'
-
- value
- end
- end
-
- # Add local/remote options to the command line parser.
- def add_local_remote_options
- add_option(:"Local/Remote", '-l', '--local',
- 'Restrict operations to the LOCAL domain') do |value, options|
- options[:domain] = :local
- end
-
- add_option(:"Local/Remote", '-r', '--remote',
- 'Restrict operations to the REMOTE domain') do |value, options|
- options[:domain] = :remote
- end
-
- add_option(:"Local/Remote", '-b', '--both',
- 'Allow LOCAL and REMOTE operations') do |value, options|
- options[:domain] = :both
- end
-
- add_bulk_threshold_option
- add_source_option
- add_proxy_option
- add_update_sources_option
- end
-
- # Add the --bulk-threshold option
- def add_bulk_threshold_option
- add_option(:"Local/Remote", '-B', '--bulk-threshold COUNT',
- "Threshold for switching to bulk",
- "synchronization (default #{Gem.configuration.bulk_threshold})") do
- |value, options|
- Gem.configuration.bulk_threshold = value.to_i
- end
- end
-
- # Add the --http-proxy option
- def add_proxy_option
- accept_uri_http
-
- add_option(:"Local/Remote", '-p', '--[no-]http-proxy [URL]', URI::HTTP,
- 'Use HTTP proxy for remote operations') do |value, options|
- options[:http_proxy] = (value == false) ? :no_proxy : value
- Gem.configuration[:http_proxy] = options[:http_proxy]
- end
- end
-
- # Add the --source option
- def add_source_option
- accept_uri_http
-
- add_option(:"Local/Remote", '--source URL', URI::HTTP,
- 'Use URL as the remote source for gems') do |value, options|
- if options[:added_source] then
- Gem.sources << value
- else
- options[:added_source] = true
- Gem.sources.replace [value]
- end
- end
- end
-
- # Add the --source option
- def add_update_sources_option
-
- add_option(:"Local/Remote", '-u', '--[no-]update-sources',
- 'Update local source cache') do |value, options|
- Gem.configuration.update_sources = value
- end
- end
-
- # Is local fetching enabled?
- def local?
- options[:domain] == :local || options[:domain] == :both
- end
-
- # Is remote fetching enabled?
- def remote?
- options[:domain] == :remote || options[:domain] == :both
- end
-
-end
-
diff --git a/lib/rubygems/old_format.rb b/lib/rubygems/old_format.rb
deleted file mode 100644
index ef5d621f52..0000000000
--- a/lib/rubygems/old_format.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'fileutils'
-require 'yaml'
-require 'zlib'
-
-module Gem
-
- ##
- # The format class knows the guts of the RubyGem .gem file format
- # and provides the capability to read gem files
- #
- class OldFormat
- attr_accessor :spec, :file_entries, :gem_path
-
- ##
- # Constructs an instance of a Format object, representing the gem's
- # data structure.
- #
- # gem:: [String] The file name of the gem
- #
- def initialize(gem_path)
- @gem_path = gem_path
- end
-
- ##
- # Reads the named gem file and returns a Format object, representing
- # the data from the gem file
- #
- # file_path:: [String] Path to the gem file
- #
- def self.from_file_by_path(file_path)
- unless File.exist?(file_path)
- raise Gem::Exception, "Cannot load gem file [#{file_path}]"
- end
- File.open(file_path, 'rb') do |file|
- from_io(file, file_path)
- end
- end
-
- ##
- # Reads a gem from an io stream and returns a Format object, representing
- # the data from the gem file
- #
- # io:: [IO] Stream from which to read the gem
- #
- def self.from_io(io, gem_path="(io)")
- format = self.new(gem_path)
- skip_ruby(io)
- format.spec = read_spec(io)
- format.file_entries = []
- read_files_from_gem(io) do |entry, file_data|
- format.file_entries << [entry, file_data]
- end
- format
- end
-
- private
- ##
- # Skips the Ruby self-install header. After calling this method, the
- # IO index will be set after the Ruby code.
- #
- # file:: [IO] The IO to process (skip the Ruby code)
- #
- def self.skip_ruby(file)
- end_seen = false
- loop {
- line = file.gets
- if(line == nil || line.chomp == "__END__") then
- end_seen = true
- break
- end
- }
- if(end_seen == false) then
- raise Gem::Exception.new("Failed to find end of ruby script while reading gem")
- end
- end
-
- ##
- # Reads the specification YAML from the supplied IO and constructs
- # a Gem::Specification from it. After calling this method, the
- # IO index will be set after the specification header.
- #
- # file:: [IO] The IO to process
- #
- def self.read_spec(file)
- yaml = ''
- begin
- read_until_dashes(file) do |line|
- yaml << line
- end
- Specification.from_yaml(yaml)
- rescue YAML::Error => e
- raise Gem::Exception.new("Failed to parse gem specification out of gem file")
- rescue ArgumentError => e
- raise Gem::Exception.new("Failed to parse gem specification out of gem file")
- end
- end
-
- ##
- # Reads lines from the supplied IO until a end-of-yaml (---) is
- # reached
- #
- # file:: [IO] The IO to process
- # block:: [String] The read line
- #
- def self.read_until_dashes(file)
- while((line = file.gets) && line.chomp.strip != "---") do
- yield line
- end
- end
-
-
- ##
- # Reads the embedded file data from a gem file, yielding an entry
- # containing metadata about the file and the file contents themselves
- # for each file that's archived in the gem.
- # NOTE: Many of these methods should be extracted into some kind of
- # Gem file read/writer
- #
- # gem_file:: [IO] The IO to process
- #
- def self.read_files_from_gem(gem_file)
- errstr = "Error reading files from gem"
- header_yaml = ''
- begin
- self.read_until_dashes(gem_file) do |line|
- header_yaml << line
- end
- header = YAML.load(header_yaml)
- raise Gem::Exception.new(errstr) unless header
- header.each do |entry|
- file_data = ''
- self.read_until_dashes(gem_file) do |line|
- file_data << line
- end
- yield [entry, Zlib::Inflate.inflate(file_data.strip.unpack("m")[0])]
- end
- rescue Exception,Zlib::DataError => e
- raise Gem::Exception.new(errstr)
- end
- end
- end
-end
diff --git a/lib/rubygems/open-uri.rb b/lib/rubygems/open-uri.rb
deleted file mode 100644
index ffc8e48571..0000000000
--- a/lib/rubygems/open-uri.rb
+++ /dev/null
@@ -1,773 +0,0 @@
-require 'uri'
-require 'stringio'
-require 'time'
-
-# :stopdoc:
-module Kernel
- private
- alias rubygems_open_uri_original_open open # :nodoc:
-
- # makes possible to open various resources including URIs.
- # If the first argument respond to `open' method,
- # the method is called with the rest arguments.
- #
- # If the first argument is a string which begins with xxx://,
- # it is parsed by URI.parse. If the parsed object respond to `open' method,
- # the method is called with the rest arguments.
- #
- # Otherwise original open is called.
- #
- # Since open-uri.rb provides URI::HTTP#open, URI::HTTPS#open and
- # URI::FTP#open,
- # Kernel[#.]open can accepts such URIs and strings which begins with
- # http://, https:// and ftp://.
- # In these case, the opened file object is extended by OpenURI::Meta.
- def open(name, *rest, &block) # :doc:
- if name.respond_to?(:open)
- name.open(*rest, &block)
- elsif name.respond_to?(:to_str) &&
- %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name &&
- (uri = URI.parse(name)).respond_to?(:open)
- uri.open(*rest, &block)
- else
- rubygems_open_uri_original_open(name, *rest, &block)
- end
- end
- module_function :open
-end
-
-# OpenURI is an easy-to-use wrapper for net/http, net/https and net/ftp.
-#
-#== Example
-#
-# It is possible to open http/https/ftp URL as usual like opening a file:
-#
-# open("http://www.ruby-lang.org/") {|f|
-# f.each_line {|line| p line}
-# }
-#
-# The opened file has several methods for meta information as follows since
-# it is extended by OpenURI::Meta.
-#
-# open("http://www.ruby-lang.org/en") {|f|
-# f.each_line {|line| p line}
-# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
-# p f.content_type # "text/html"
-# p f.charset # "iso-8859-1"
-# p f.content_encoding # []
-# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
-# }
-#
-# Additional header fields can be specified by an optional hash argument.
-#
-# open("http://www.ruby-lang.org/en/",
-# "User-Agent" => "Ruby/#{RUBY_VERSION}",
-# "From" => "foo@bar.invalid",
-# "Referer" => "http://www.ruby-lang.org/") {|f|
-# # ...
-# }
-#
-# The environment variables such as http_proxy, https_proxy and ftp_proxy
-# are in effect by default. :proxy => nil disables proxy.
-#
-# open("http://www.ruby-lang.org/en/raa.html", :proxy => nil) {|f|
-# # ...
-# }
-#
-# URI objects can be opened in a similar way.
-#
-# uri = URI.parse("http://www.ruby-lang.org/en/")
-# uri.open {|f|
-# # ...
-# }
-#
-# URI objects can be read directly. The returned string is also extended by
-# OpenURI::Meta.
-#
-# str = uri.read
-# p str.base_uri
-#
-# Author:: Tanaka Akira <akr@m17n.org>
-
-module OpenURI
- Options = {
- :proxy => true,
- :proxy_http_basic_authentication => true,
- :progress_proc => true,
- :content_length_proc => true,
- :http_basic_authentication => true,
- :read_timeout => true,
- :ssl_ca_cert => nil,
- :ssl_verify_mode => nil,
- }
-
- def OpenURI.check_options(options) # :nodoc:
- options.each {|k, v|
- next unless Symbol === k
- unless Options.include? k
- raise ArgumentError, "unrecognized option: #{k}"
- end
- }
- end
-
- def OpenURI.scan_open_optional_arguments(*rest) # :nodoc:
- if !rest.empty? && (String === rest.first || Integer === rest.first)
- mode = rest.shift
- if !rest.empty? && Integer === rest.first
- perm = rest.shift
- end
- end
- return mode, perm, rest
- end
-
- def OpenURI.open_uri(name, *rest) # :nodoc:
- uri = URI::Generic === name ? name : URI.parse(name)
- mode, perm, rest = OpenURI.scan_open_optional_arguments(*rest)
- options = rest.shift if !rest.empty? && Hash === rest.first
- raise ArgumentError.new("extra arguments") if !rest.empty?
- options ||= {}
- OpenURI.check_options(options)
-
- unless mode == nil ||
- mode == 'r' || mode == 'rb' ||
- mode == File::RDONLY
- raise ArgumentError.new("invalid access mode #{mode} (#{uri.class} resource is read only.)")
- end
-
- io = open_loop(uri, options)
- if block_given?
- begin
- yield io
- ensure
- io.close
- end
- else
- io
- end
- end
-
- def OpenURI.open_loop(uri, options) # :nodoc:
- proxy_opts = []
- proxy_opts << :proxy_http_basic_authentication if options.include? :proxy_http_basic_authentication
- proxy_opts << :proxy if options.include? :proxy
- proxy_opts.compact!
- if 1 < proxy_opts.length
- raise ArgumentError, "multiple proxy options specified"
- end
- case proxy_opts.first
- when :proxy_http_basic_authentication
- opt_proxy, proxy_user, proxy_pass = options.fetch(:proxy_http_basic_authentication)
- proxy_user = proxy_user.to_str
- proxy_pass = proxy_pass.to_str
- if opt_proxy == true
- raise ArgumentError.new("Invalid authenticated proxy option: #{options[:proxy_http_basic_authentication].inspect}")
- end
- when :proxy
- opt_proxy = options.fetch(:proxy)
- proxy_user = nil
- proxy_pass = nil
- when nil
- opt_proxy = true
- proxy_user = nil
- proxy_pass = nil
- end
- case opt_proxy
- when true
- find_proxy = lambda {|u| pxy = u.find_proxy; pxy ? [pxy, nil, nil] : nil}
- when nil, false
- find_proxy = lambda {|u| nil}
- when String
- opt_proxy = URI.parse(opt_proxy)
- find_proxy = lambda {|u| [opt_proxy, proxy_user, proxy_pass]}
- when URI::Generic
- find_proxy = lambda {|u| [opt_proxy, proxy_user, proxy_pass]}
- else
- raise ArgumentError.new("Invalid proxy option: #{opt_proxy}")
- end
-
- uri_set = {}
- buf = nil
- while true
- redirect = catch(:open_uri_redirect) {
- buf = Buffer.new
- uri.buffer_open(buf, find_proxy.call(uri), options)
- nil
- }
- if redirect
- if redirect.relative?
- # Although it violates RFC2616, Location: field may have relative
- # URI. It is converted to absolute URI using uri as a base URI.
- redirect = uri + redirect
- end
- unless OpenURI.redirectable?(uri, redirect)
- raise "redirection forbidden: #{uri} -> #{redirect}"
- end
- if options.include? :http_basic_authentication
- # send authentication only for the URI directly specified.
- options = options.dup
- options.delete :http_basic_authentication
- end
- uri = redirect
- raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
- uri_set[uri.to_s] = true
- else
- break
- end
- end
- io = buf.io
- io.base_uri = uri
- io
- end
-
- def OpenURI.redirectable?(uri1, uri2) # :nodoc:
- # This test is intended to forbid a redirection from http://... to
- # file:///etc/passwd.
- # However this is ad hoc. It should be extensible/configurable.
- uri1.scheme.downcase == uri2.scheme.downcase ||
- (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)
- end
-
- def OpenURI.open_http(buf, target, proxy, options) # :nodoc:
- if proxy
- proxy_uri, proxy_user, proxy_pass = proxy
- raise "Non-HTTP proxy URI: #{proxy_uri}" if proxy_uri.class != URI::HTTP
- end
-
- if target.userinfo && "1.9.0" <= RUBY_VERSION
- # don't raise for 1.8 because compatibility.
- raise ArgumentError, "userinfo not supported. [RFC3986]"
- end
-
- header = {}
- options.each {|k, v| header[k] = v if String === k }
-
- require 'net/http'
- klass = Net::HTTP
- if URI::HTTP === target
- # HTTP or HTTPS
- if proxy
- if proxy_user && proxy_pass
- klass = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_user, proxy_pass)
- else
- klass = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port)
- end
- end
- target_host = target.host
- target_port = target.port
- request_uri = target.request_uri
- else
- # FTP over HTTP proxy
- target_host = proxy_uri.host
- target_port = proxy_uri.port
- request_uri = target.to_s
- if proxy_user && proxy_pass
- header["Proxy-Authorization"] = 'Basic ' + ["#{proxy_user}:#{proxy_pass}"].pack('m').delete("\r\n")
- end
- end
-
- http = klass.new(target_host, target_port)
- if target.class == URI::HTTPS
- require 'net/https'
- http.use_ssl = true
- http.verify_mode = options[:ssl_verify_mode] || OpenSSL::SSL::VERIFY_PEER
- store = OpenSSL::X509::Store.new
- if options[:ssl_ca_cert]
- if File.directory? options[:ssl_ca_cert]
- store.add_path options[:ssl_ca_cert]
- else
- store.add_file options[:ssl_ca_cert]
- end
- else
- store.set_default_paths
- end
- store.set_default_paths
- http.cert_store = store
- end
- if options.include? :read_timeout
- http.read_timeout = options[:read_timeout]
- end
-
- resp = nil
- http.start {
- if target.class == URI::HTTPS
- # xxx: information hiding violation
- sock = http.instance_variable_get(:@socket)
- if sock.respond_to?(:io)
- sock = sock.io # 1.9
- else
- sock = sock.instance_variable_get(:@socket) # 1.8
- end
- sock.post_connection_check(target_host)
- end
- req = Net::HTTP::Get.new(request_uri, header)
- if options.include? :http_basic_authentication
- user, pass = options[:http_basic_authentication]
- req.basic_auth user, pass
- end
- http.request(req) {|response|
- resp = response
- if options[:content_length_proc] && Net::HTTPSuccess === resp
- if resp.key?('Content-Length')
- options[:content_length_proc].call(resp['Content-Length'].to_i)
- else
- options[:content_length_proc].call(nil)
- end
- end
- resp.read_body {|str|
- buf << str
- if options[:progress_proc] && Net::HTTPSuccess === resp
- options[:progress_proc].call(buf.size)
- end
- }
- }
- }
- io = buf.io
- io.rewind
- io.status = [resp.code, resp.message]
- resp.each {|name,value| buf.io.meta_add_field name, value }
- case resp
- when Net::HTTPSuccess
- when Net::HTTPMovedPermanently, # 301
- Net::HTTPFound, # 302
- Net::HTTPSeeOther, # 303
- Net::HTTPTemporaryRedirect # 307
- throw :open_uri_redirect, URI.parse(resp['location'])
- else
- raise OpenURI::HTTPError.new(io.status.join(' '), io)
- end
- end
-
- class HTTPError < StandardError
- def initialize(message, io)
- super(message)
- @io = io
- end
- attr_reader :io
- end
-
- class Buffer # :nodoc:
- def initialize
- @io = StringIO.new
- @size = 0
- end
- attr_reader :size
-
- StringMax = 10240
- def <<(str)
- @io << str
- @size += str.length
- if StringIO === @io && StringMax < @size
- require 'tempfile'
- io = Tempfile.new('open-uri')
- io.binmode
- Meta.init io, @io if @io.respond_to? :meta
- io << @io.string
- @io = io
- end
- end
-
- def io
- Meta.init @io unless @io.respond_to? :meta
- @io
- end
- end
-
- # Mixin for holding meta-information.
- module Meta
- def Meta.init(obj, src=nil) # :nodoc:
- obj.extend Meta
- obj.instance_eval {
- @base_uri = nil
- @meta = {}
- }
- if src
- obj.status = src.status
- obj.base_uri = src.base_uri
- src.meta.each {|name, value|
- obj.meta_add_field(name, value)
- }
- end
- end
-
- # returns an Array which consists status code and message.
- attr_accessor :status
-
- # returns a URI which is base of relative URIs in the data.
- # It may differ from the URI supplied by a user because redirection.
- attr_accessor :base_uri
-
- # returns a Hash which represents header fields.
- # The Hash keys are downcased for canonicalization.
- attr_reader :meta
-
- def meta_add_field(name, value) # :nodoc:
- @meta[name.downcase] = value
- end
-
- # returns a Time which represents Last-Modified field.
- def last_modified
- if v = @meta['last-modified']
- Time.httpdate(v)
- else
- nil
- end
- end
-
- RE_LWS = /[\r\n\t ]+/n
- RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n
- RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n
- RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n
-
- def content_type_parse # :nodoc:
- v = @meta['content-type']
- # The last (?:;#{RE_LWS}?)? matches extra ";" which violates RFC2045.
- if v && %r{\A#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?/(#{RE_TOKEN})#{RE_LWS}?(#{RE_PARAMETERS})(?:;#{RE_LWS}?)?\z}no =~ v
- type = $1.downcase
- subtype = $2.downcase
- parameters = []
- $3.scan(/;#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?=#{RE_LWS}?(?:(#{RE_TOKEN})|(#{RE_QUOTED_STRING}))/no) {|att, val, qval|
- val = qval.gsub(/[\r\n\t !#-\[\]-~\x80-\xff]+|(\\[\x00-\x7f])/) { $1 ? $1[1,1] : $& } if qval
- parameters << [att.downcase, val]
- }
- ["#{type}/#{subtype}", *parameters]
- else
- nil
- end
- end
-
- # returns "type/subtype" which is MIME Content-Type.
- # It is downcased for canonicalization.
- # Content-Type parameters are stripped.
- def content_type
- type, *parameters = content_type_parse
- type || 'application/octet-stream'
- end
-
- # returns a charset parameter in Content-Type field.
- # It is downcased for canonicalization.
- #
- # If charset parameter is not given but a block is given,
- # the block is called and its result is returned.
- # It can be used to guess charset.
- #
- # If charset parameter and block is not given,
- # nil is returned except text type in HTTP.
- # In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
- def charset
- type, *parameters = content_type_parse
- if pair = parameters.assoc('charset')
- pair.last.downcase
- elsif block_given?
- yield
- elsif type && %r{\Atext/} =~ type &&
- @base_uri && /\Ahttp\z/i =~ @base_uri.scheme
- "iso-8859-1" # RFC2616 3.7.1
- else
- nil
- end
- end
-
- # returns a list of encodings in Content-Encoding field
- # as an Array of String.
- # The encodings are downcased for canonicalization.
- def content_encoding
- v = @meta['content-encoding']
- if v && %r{\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ v
- v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}
- else
- []
- end
- end
- end
-
- # Mixin for HTTP and FTP URIs.
- module OpenRead
- # OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP.
- #
- # OpenURI::OpenRead#open takes optional 3 arguments as:
- # OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }]
- #
- # `mode', `perm' is same as Kernel#open.
- #
- # However, `mode' must be read mode because OpenURI::OpenRead#open doesn't
- # support write mode (yet).
- # Also `perm' is just ignored because it is meaningful only for file
- # creation.
- #
- # `options' must be a hash.
- #
- # Each pairs which key is a string in the hash specify a extra header
- # field for HTTP.
- # I.e. it is ignored for FTP without HTTP proxy.
- #
- # The hash may include other options which key is a symbol:
- #
- # [:proxy]
- # Synopsis:
- # :proxy => "http://proxy.foo.com:8000/"
- # :proxy => URI.parse("http://proxy.foo.com:8000/")
- # :proxy => true
- # :proxy => false
- # :proxy => nil
- #
- # If :proxy option is specified, the value should be String, URI,
- # boolean or nil.
- # When String or URI is given, it is treated as proxy URI.
- # When true is given or the option itself is not specified,
- # environment variable `scheme_proxy' is examined.
- # `scheme' is replaced by `http', `https' or `ftp'.
- # When false or nil is given, the environment variables are ignored and
- # connection will be made to a server directly.
- #
- # [:proxy_http_basic_authentication]
- # Synopsis:
- # :proxy_http_basic_authentication => ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"]
- # :proxy_http_basic_authentication => [URI.parse("http://proxy.foo.com:8000/"), "proxy-user", "proxy-password"]
- #
- # If :proxy option is specified, the value should be an Array with 3 elements.
- # It should contain a proxy URI, a proxy user name and a proxy password.
- # The proxy URI should be a String, an URI or nil.
- # The proxy user name and password should be a String.
- #
- # If nil is given for the proxy URI, this option is just ignored.
- #
- # If :proxy and :proxy_http_basic_authentication is specified,
- # ArgumentError is raised.
- #
- # [:http_basic_authentication]
- # Synopsis:
- # :http_basic_authentication=>[user, password]
- #
- # If :http_basic_authentication is specified,
- # the value should be an array which contains 2 strings:
- # username and password.
- # It is used for HTTP Basic authentication defined by RFC 2617.
- #
- # [:content_length_proc]
- # Synopsis:
- # :content_length_proc => lambda {|content_length| ... }
- #
- # If :content_length_proc option is specified, the option value procedure
- # is called before actual transfer is started.
- # It takes one argument which is expected content length in bytes.
- #
- # If two or more transfer is done by HTTP redirection, the procedure
- # is called only one for a last transfer.
- #
- # When expected content length is unknown, the procedure is called with
- # nil.
- # It is happen when HTTP response has no Content-Length header.
- #
- # [:progress_proc]
- # Synopsis:
- # :progress_proc => lambda {|size| ...}
- #
- # If :progress_proc option is specified, the proc is called with one
- # argument each time when `open' gets content fragment from network.
- # The argument `size' `size' is a accumulated transfered size in bytes.
- #
- # If two or more transfer is done by HTTP redirection, the procedure
- # is called only one for a last transfer.
- #
- # :progress_proc and :content_length_proc are intended to be used for
- # progress bar.
- # For example, it can be implemented as follows using Ruby/ProgressBar.
- #
- # pbar = nil
- # open("http://...",
- # :content_length_proc => lambda {|t|
- # if t && 0 < t
- # pbar = ProgressBar.new("...", t)
- # pbar.file_transfer_mode
- # end
- # },
- # :progress_proc => lambda {|s|
- # pbar.set s if pbar
- # }) {|f| ... }
- #
- # [:read_timeout]
- # Synopsis:
- # :read_timeout=>nil (no timeout)
- # :read_timeout=>10 (10 second)
- #
- # :read_timeout option specifies a timeout of read for http connections.
- #
- # [:ssl_ca_cert]
- # Synopsis:
- # :ssl_ca_cert=>filename
- #
- # :ssl_ca_cert is used to specify CA certificate for SSL.
- # If it is given, default certificates are not used.
- #
- # [:ssl_verify_mode]
- # Synopsis:
- # :ssl_verify_mode=>mode
- #
- # :ssl_verify_mode is used to specify openssl verify mode.
- #
- # OpenURI::OpenRead#open returns an IO like object if block is not given.
- # Otherwise it yields the IO object and return the value of the block.
- # The IO object is extended with OpenURI::Meta.
- def open(*rest, &block)
- OpenURI.open_uri(self, *rest, &block)
- end
-
- # OpenURI::OpenRead#read([options]) reads a content referenced by self and
- # returns the content as string.
- # The string is extended with OpenURI::Meta.
- # The argument `options' is same as OpenURI::OpenRead#open.
- def read(options={})
- self.open(options) {|f|
- str = f.read
- Meta.init str, f
- str
- }
- end
- end
-end
-
-module URI
- class Generic
- # returns a proxy URI.
- # The proxy URI is obtained from environment variables such as http_proxy,
- # ftp_proxy, no_proxy, etc.
- # If there is no proper proxy, nil is returned.
- #
- # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
- # are examined too.
- #
- # But http_proxy and HTTP_PROXY is treated specially under CGI environment.
- # It's because HTTP_PROXY may be set by Proxy: header.
- # So HTTP_PROXY is not used.
- # http_proxy is not used too if the variable is case insensitive.
- # CGI_HTTP_PROXY can be used instead.
- def find_proxy
- name = self.scheme.downcase + '_proxy'
- proxy_uri = nil
- if name == 'http_proxy' && ENV.include?('REQUEST_METHOD') # CGI?
- # HTTP_PROXY conflicts with *_proxy for proxy settings and
- # HTTP_* for header information in CGI.
- # So it should be careful to use it.
- pairs = ENV.reject {|k, v| /\Ahttp_proxy\z/i !~ k }
- case pairs.length
- when 0 # no proxy setting anyway.
- proxy_uri = nil
- when 1
- k, v = pairs.shift
- if k == 'http_proxy' && ENV[k.upcase] == nil
- # http_proxy is safe to use because ENV is case sensitive.
- proxy_uri = ENV[name]
- else
- proxy_uri = nil
- end
- else # http_proxy is safe to use because ENV is case sensitive.
- proxy_uri = ENV[name]
- end
- if !proxy_uri
- # Use CGI_HTTP_PROXY. cf. libwww-perl.
- proxy_uri = ENV["CGI_#{name.upcase}"]
- end
- elsif name == 'http_proxy'
- unless proxy_uri = ENV[name]
- if proxy_uri = ENV[name.upcase]
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.'
- end
- end
- else
- proxy_uri = ENV[name] || ENV[name.upcase]
- end
-
- if proxy_uri && self.host
- require 'socket'
- begin
- addr = IPSocket.getaddress(self.host)
- proxy_uri = nil if /\A127\.|\A::1\z/ =~ addr
- rescue SocketError
- end
- end
-
- if proxy_uri
- proxy_uri = URI.parse(proxy_uri)
- name = 'no_proxy'
- if no_proxy = ENV[name] || ENV[name.upcase]
- no_proxy.scan(/([^:,]*)(?::(\d+))?/) {|host, port|
- if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host &&
- (!port || self.port == port.to_i)
- proxy_uri = nil
- break
- end
- }
- end
- proxy_uri
- else
- nil
- end
- end
- end
-
- class HTTP
- def buffer_open(buf, proxy, options) # :nodoc:
- OpenURI.open_http(buf, self, proxy, options)
- end
-
- include OpenURI::OpenRead
- end
-
- class FTP
- def buffer_open(buf, proxy, options) # :nodoc:
- if proxy
- OpenURI.open_http(buf, self, proxy, options)
- return
- end
- require 'net/ftp'
-
- directories = self.path.split(%r{/}, -1)
- directories.shift if directories[0] == '' # strip a field before leading slash
- directories.each {|d|
- d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
- }
- unless filename = directories.pop
- raise ArgumentError, "no filename: #{self.inspect}"
- end
- directories.each {|d|
- if /[\r\n]/ =~ d
- raise ArgumentError, "invalid directory: #{d.inspect}"
- end
- }
- if /[\r\n]/ =~ filename
- raise ArgumentError, "invalid filename: #{filename.inspect}"
- end
- typecode = self.typecode
- if typecode && /\A[aid]\z/ !~ typecode
- raise ArgumentError, "invalid typecode: #{typecode.inspect}"
- end
-
- # The access sequence is defined by RFC 1738
- ftp = Net::FTP.open(self.host)
- # todo: extract user/passwd from .netrc.
- user = 'anonymous'
- passwd = nil
- user, passwd = self.userinfo.split(/:/) if self.userinfo
- ftp.login(user, passwd)
- directories.each {|cwd|
- ftp.voidcmd("CWD #{cwd}")
- }
- if typecode
- # xxx: typecode D is not handled.
- ftp.voidcmd("TYPE #{typecode.upcase}")
- end
- if options[:content_length_proc]
- options[:content_length_proc].call(ftp.size(filename))
- end
- ftp.retrbinary("RETR #{filename}", 4096) { |str|
- buf << str
- options[:progress_proc].call(buf.size) if options[:progress_proc]
- }
- ftp.close
- buf.io.rewind
- end
-
- include OpenURI::OpenRead
- end
-end
-# :startdoc:
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
deleted file mode 100644
index ee136b6267..0000000000
--- a/lib/rubygems/package.rb
+++ /dev/null
@@ -1,852 +0,0 @@
-#++
-# Copyright (C) 2004 Mauricio Julio Fernández Pradier
-# See LICENSE.txt for additional licensing information.
-#--
-
-require 'fileutils'
-require 'find'
-require 'stringio'
-require 'yaml'
-require 'zlib'
-
-require 'rubygems/digest/md5'
-require 'rubygems/security'
-require 'rubygems/specification'
-
-# Wrapper for FileUtils meant to provide logging and additional operations if
-# needed.
-class Gem::FileOperations
-
- def initialize(logger = nil)
- @logger = logger
- end
-
- def method_missing(meth, *args, &block)
- case
- when FileUtils.respond_to?(meth)
- @logger.log "#{meth}: #{args}" if @logger
- FileUtils.send meth, *args, &block
- when Gem::FileOperations.respond_to?(meth)
- @logger.log "#{meth}: #{args}" if @logger
- Gem::FileOperations.send meth, *args, &block
- else
- super
- end
- end
-
-end
-
-module Gem::Package
-
- class Error < StandardError; end
- class NonSeekableIO < Error; end
- class ClosedIO < Error; end
- class BadCheckSum < Error; end
- class TooLongFileName < Error; end
- class FormatError < Error; end
-
- module FSyncDir
- private
- def fsync_dir(dirname)
- # make sure this hits the disc
- begin
- dir = open(dirname, "r")
- dir.fsync
- rescue # ignore IOError if it's an unpatched (old) Ruby
- ensure
- dir.close if dir rescue nil
- end
- end
- end
-
- class TarHeader
- FIELDS = [:name, :mode, :uid, :gid, :size, :mtime, :checksum, :typeflag,
- :linkname, :magic, :version, :uname, :gname, :devmajor,
- :devminor, :prefix]
- FIELDS.each {|x| attr_reader x}
-
- def self.new_from_stream(stream)
- data = stream.read(512)
- fields = data.unpack("A100" + # record name
- "A8A8A8" + # mode, uid, gid
- "A12A12" + # size, mtime
- "A8A" + # checksum, typeflag
- "A100" + # linkname
- "A6A2" + # magic, version
- "A32" + # uname
- "A32" + # gname
- "A8A8" + # devmajor, devminor
- "A155") # prefix
- name = fields.shift
- mode = fields.shift.oct
- uid = fields.shift.oct
- gid = fields.shift.oct
- size = fields.shift.oct
- mtime = fields.shift.oct
- checksum = fields.shift.oct
- typeflag = fields.shift
- linkname = fields.shift
- magic = fields.shift
- version = fields.shift.oct
- uname = fields.shift
- gname = fields.shift
- devmajor = fields.shift.oct
- devminor = fields.shift.oct
- prefix = fields.shift
-
- empty = (data == "\0" * 512)
-
- new(:name=>name, :mode=>mode, :uid=>uid, :gid=>gid, :size=>size,
- :mtime=>mtime, :checksum=>checksum, :typeflag=>typeflag,
- :magic=>magic, :version=>version, :uname=>uname, :gname=>gname,
- :devmajor=>devmajor, :devminor=>devminor, :prefix=>prefix,
- :empty => empty )
- end
-
- def initialize(vals)
- unless vals[:name] && vals[:size] && vals[:prefix] && vals[:mode]
- raise ArgumentError, ":name, :size, :prefix and :mode required"
- end
- vals[:uid] ||= 0
- vals[:gid] ||= 0
- vals[:mtime] ||= 0
- vals[:checksum] ||= ""
- vals[:typeflag] ||= "0"
- vals[:magic] ||= "ustar"
- vals[:version] ||= "00"
- vals[:uname] ||= "wheel"
- vals[:gname] ||= "wheel"
- vals[:devmajor] ||= 0
- vals[:devminor] ||= 0
- FIELDS.each {|x| instance_variable_set "@#{x.to_s}", vals[x]}
- @empty = vals[:empty]
- end
-
- def empty?
- @empty
- end
-
- def to_s
- update_checksum
- header(checksum)
- end
-
- def update_checksum
- h = header(" " * 8)
- @checksum = oct(calculate_checksum(h), 6)
- end
-
- private
- def oct(num, len)
- "%0#{len}o" % num
- end
-
- def calculate_checksum(hdr)
- #hdr.split('').map { |c| c[0] }.inject { |a, b| a + b } # HACK rubinius
- hdr.unpack("C*").inject{|a,b| a+b}
- end
-
- def header(chksum)
- # struct tarfile_entry_posix {
- # char name[100]; # ASCII + (Z unless filled)
- # char mode[8]; # 0 padded, octal, null
- # char uid[8]; # ditto
- # char gid[8]; # ditto
- # char size[12]; # 0 padded, octal, null
- # char mtime[12]; # 0 padded, octal, null
- # char checksum[8]; # 0 padded, octal, null, space
- # char typeflag[1]; # file: "0" dir: "5"
- # char linkname[100]; # ASCII + (Z unless filled)
- # char magic[6]; # "ustar\0"
- # char version[2]; # "00"
- # char uname[32]; # ASCIIZ
- # char gname[32]; # ASCIIZ
- # char devmajor[8]; # 0 padded, octal, null
- # char devminor[8]; # o padded, octal, null
- # char prefix[155]; # ASCII + (Z unless filled)
- # };
- arr = [name, oct(mode, 7), oct(uid, 7), oct(gid, 7), oct(size, 11),
- oct(mtime, 11), chksum, " ", typeflag, linkname, magic, version,
- uname, gname, oct(devmajor, 7), oct(devminor, 7), prefix]
- str = arr.pack("a100a8a8a8a12a12" + # name, mode, uid, gid, size, mtime
- "a7aaa100a6a2" + # chksum, typeflag, linkname, magic, version
- "a32a32a8a8a155") # uname, gname, devmajor, devminor, prefix
- str + "\0" * ((512 - str.size) % 512)
- end
- end
-
- class TarWriter
- class FileOverflow < StandardError; end
- class BlockNeeded < StandardError; end
-
- class BoundedStream
- attr_reader :limit, :written
- def initialize(io, limit)
- @io = io
- @limit = limit
- @written = 0
- end
-
- def write(data)
- if data.size + @written > @limit
- raise FileOverflow,
- "You tried to feed more data than fits in the file."
- end
- @io.write data
- @written += data.size
- data.size
- end
- end
-
- class RestrictedStream
- def initialize(anIO)
- @io = anIO
- end
-
- def write(data)
- @io.write data
- end
- end
-
- def self.new(anIO)
- writer = super(anIO)
- return writer unless block_given?
- begin
- yield writer
- ensure
- writer.close
- end
- nil
- end
-
- def initialize(anIO)
- @io = anIO
- @closed = false
- end
-
- def add_file_simple(name, mode, size)
- raise BlockNeeded unless block_given?
- raise ClosedIO if @closed
- name, prefix = split_name(name)
- header = TarHeader.new(:name => name, :mode => mode,
- :size => size, :prefix => prefix).to_s
- @io.write header
- os = BoundedStream.new(@io, size)
- yield os
- #FIXME: what if an exception is raised in the block?
- min_padding = size - os.written
- @io.write("\0" * min_padding)
- remainder = (512 - (size % 512)) % 512
- @io.write("\0" * remainder)
- end
-
- def add_file(name, mode)
- raise BlockNeeded unless block_given?
- raise ClosedIO if @closed
- raise NonSeekableIO unless @io.respond_to? :pos=
- name, prefix = split_name(name)
- init_pos = @io.pos
- @io.write "\0" * 512 # placeholder for the header
- yield RestrictedStream.new(@io)
- #FIXME: what if an exception is raised in the block?
- #FIXME: what if an exception is raised in the block?
- size = @io.pos - init_pos - 512
- remainder = (512 - (size % 512)) % 512
- @io.write("\0" * remainder)
- final_pos = @io.pos
- @io.pos = init_pos
- header = TarHeader.new(:name => name, :mode => mode,
- :size => size, :prefix => prefix).to_s
- @io.write header
- @io.pos = final_pos
- end
-
- def mkdir(name, mode)
- raise ClosedIO if @closed
- name, prefix = split_name(name)
- header = TarHeader.new(:name => name, :mode => mode, :typeflag => "5",
- :size => 0, :prefix => prefix).to_s
- @io.write header
- nil
- end
-
- def flush
- raise ClosedIO if @closed
- @io.flush if @io.respond_to? :flush
- end
-
- def close
- #raise ClosedIO if @closed
- return if @closed
- @io.write "\0" * 1024
- @closed = true
- end
-
- private
- def split_name name
- raise TooLongFileName if name.size > 256
- if name.size <= 100
- prefix = ""
- else
- parts = name.split(/\//)
- newname = parts.pop
- nxt = ""
- loop do
- nxt = parts.pop
- break if newname.size + 1 + nxt.size > 100
- newname = nxt + "/" + newname
- end
- prefix = (parts + [nxt]).join "/"
- name = newname
- raise TooLongFileName if name.size > 100 || prefix.size > 155
- end
- return name, prefix
- end
- end
-
- class TarReader
-
- include Gem::Package
-
- class UnexpectedEOF < StandardError; end
-
- module InvalidEntry
- def read(len=nil); raise ClosedIO; end
- def getc; raise ClosedIO; end
- def rewind; raise ClosedIO; end
- end
-
- class Entry
- TarHeader::FIELDS.each{|x| attr_reader x}
-
- def initialize(header, anIO)
- @io = anIO
- @name = header.name
- @mode = header.mode
- @uid = header.uid
- @gid = header.gid
- @size = header.size
- @mtime = header.mtime
- @checksum = header.checksum
- @typeflag = header.typeflag
- @linkname = header.linkname
- @magic = header.magic
- @version = header.version
- @uname = header.uname
- @gname = header.gname
- @devmajor = header.devmajor
- @devminor = header.devminor
- @prefix = header.prefix
- @read = 0
- @orig_pos = @io.pos
- end
-
- def read(len = nil)
- return nil if @read >= @size
- len ||= @size - @read
- max_read = [len, @size - @read].min
- ret = @io.read(max_read)
- @read += ret.size
- ret
- end
-
- def getc
- return nil if @read >= @size
- ret = @io.getc
- @read += 1 if ret
- ret
- end
-
- def is_directory?
- @typeflag == "5"
- end
-
- def is_file?
- @typeflag == "0"
- end
-
- def eof?
- @read >= @size
- end
-
- def pos
- @read
- end
-
- def rewind
- raise NonSeekableIO unless @io.respond_to? :pos=
- @io.pos = @orig_pos
- @read = 0
- end
-
- alias_method :is_directory, :is_directory?
- alias_method :is_file, :is_file?
-
- def bytes_read
- @read
- end
-
- def full_name
- if @prefix != ""
- File.join(@prefix, @name)
- else
- @name
- end
- end
-
- def close
- invalidate
- end
-
- private
- def invalidate
- extend InvalidEntry
- end
- end
-
- def self.new(anIO)
- reader = super(anIO)
- return reader unless block_given?
- begin
- yield reader
- ensure
- reader.close
- end
- nil
- end
-
- def initialize(anIO)
- @io = anIO
- @init_pos = anIO.pos
- end
-
- def each(&block)
- each_entry(&block)
- end
-
- # do not call this during a #each or #each_entry iteration
- def rewind
- if @init_pos == 0
- raise NonSeekableIO unless @io.respond_to? :rewind
- @io.rewind
- else
- raise NonSeekableIO unless @io.respond_to? :pos=
- @io.pos = @init_pos
- end
- end
-
- def each_entry
- loop do
- return if @io.eof?
- header = TarHeader.new_from_stream(@io)
- return if header.empty?
- entry = Entry.new header, @io
- size = entry.size
- yield entry
- skip = (512 - (size % 512)) % 512
- if @io.respond_to? :seek
- # avoid reading...
- @io.seek(size - entry.bytes_read, IO::SEEK_CUR)
- else
- pending = size - entry.bytes_read
- while pending > 0
- bread = @io.read([pending, 4096].min).size
- raise UnexpectedEOF if @io.eof?
- pending -= bread
- end
- end
- @io.read(skip) # discard trailing zeros
- # make sure nobody can use #read, #getc or #rewind anymore
- entry.close
- end
- end
-
- def close
- end
-
- end
-
- class TarInput
-
- include FSyncDir
- include Enumerable
-
- attr_reader :metadata
-
- class << self; private :new end
-
- def initialize(io, security_policy = nil)
- @io = io
- @tarreader = TarReader.new(@io)
- has_meta = false
- data_sig, meta_sig, data_dgst, meta_dgst = nil, nil, nil, nil
- dgst_algo = security_policy ? Gem::Security::OPT[:dgst_algo] : nil
-
- @tarreader.each do |entry|
- case entry.full_name
- when "metadata"
- @metadata = load_gemspec(entry.read)
- has_meta = true
- break
- when "metadata.gz"
- begin
- # if we have a security_policy, then pre-read the metadata file
- # and calculate it's digest
- sio = nil
- if security_policy
- Gem.ensure_ssl_available
- sio = StringIO.new(entry.read)
- meta_dgst = dgst_algo.digest(sio.string)
- sio.rewind
- end
-
- gzis = Zlib::GzipReader.new(sio || entry)
- # YAML wants an instance of IO
- @metadata = load_gemspec(gzis)
- has_meta = true
- ensure
- gzis.close unless gzis.nil?
- end
- when 'metadata.gz.sig'
- meta_sig = entry.read
- when 'data.tar.gz.sig'
- data_sig = entry.read
- when 'data.tar.gz'
- if security_policy
- Gem.ensure_ssl_available
- data_dgst = dgst_algo.digest(entry.read)
- end
- end
- end
-
- if security_policy then
- Gem.ensure_ssl_available
-
- # map trust policy from string to actual class (or a serialized YAML
- # file, if that exists)
- if String === security_policy then
- if Gem::Security::Policy.key? security_policy then
- # load one of the pre-defined security policies
- security_policy = Gem::Security::Policy[security_policy]
- elsif File.exist? security_policy then
- # FIXME: this doesn't work yet
- security_policy = YAML.load File.read(security_policy)
- else
- raise Gem::Exception, "Unknown trust policy '#{security_policy}'"
- end
- end
-
- if data_sig && data_dgst && meta_sig && meta_dgst then
- # the user has a trust policy, and we have a signed gem
- # file, so use the trust policy to verify the gem signature
-
- begin
- security_policy.verify_gem(data_sig, data_dgst, @metadata.cert_chain)
- rescue Exception => e
- raise "Couldn't verify data signature: #{e}"
- end
-
- begin
- security_policy.verify_gem(meta_sig, meta_dgst, @metadata.cert_chain)
- rescue Exception => e
- raise "Couldn't verify metadata signature: #{e}"
- end
- elsif security_policy.only_signed
- raise Gem::Exception, "Unsigned gem"
- else
- # FIXME: should display warning here (trust policy, but
- # either unsigned or badly signed gem file)
- end
- end
-
- @tarreader.rewind
- @fileops = Gem::FileOperations.new
- raise FormatError, "No metadata found!" unless has_meta
- end
-
- # Attempt to YAML-load a gemspec from the given _io_ parameter. Return
- # nil if it fails.
- def load_gemspec(io)
- Gem::Specification.from_yaml(io)
- rescue Gem::Exception
- nil
- end
-
- def self.open(filename, security_policy = nil, &block)
- open_from_io(File.open(filename, "rb"), security_policy, &block)
- end
-
- def self.open_from_io(io, security_policy = nil, &block)
- raise "Want a block" unless block_given?
- begin
- is = new(io, security_policy)
- yield is
- ensure
- is.close if is
- end
- end
-
- def each(&block)
- @tarreader.each do |entry|
- next unless entry.full_name == "data.tar.gz"
- is = zipped_stream(entry)
- begin
- TarReader.new(is) do |inner|
- inner.each(&block)
- end
- ensure
- is.close if is
- end
- end
- @tarreader.rewind
- end
-
- # Return an IO stream for the zipped entry.
- #
- # NOTE: Originally this method used two approaches, Return a GZipReader
- # directly, or read the GZipReader into a string and return a StringIO on
- # the string. The string IO approach was used for versions of ZLib before
- # 1.2.1 to avoid buffer errors on windows machines. Then we found that
- # errors happened with 1.2.1 as well, so we changed the condition. Then
- # we discovered errors occurred with versions as late as 1.2.3. At this
- # point (after some benchmarking to show we weren't seriously crippling
- # the unpacking speed) we threw our hands in the air and declared that
- # this method would use the String IO approach on all platforms at all
- # times. And that's the way it is.
- def zipped_stream(entry)
- # This is Jamis Buck's ZLib workaround. The original code is
- # commented out while we evaluate this patch.
- entry.read(10) # skip the gzip header
- zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
- is = StringIO.new(zis.inflate(entry.read))
- # zis = Zlib::GzipReader.new entry
- # dis = zis.read
- # is = StringIO.new(dis)
- ensure
- zis.finish if zis
- end
-
- def extract_entry(destdir, entry, expected_md5sum = nil)
- if entry.is_directory?
- dest = File.join(destdir, entry.full_name)
- if file_class.dir? dest
- @fileops.chmod entry.mode, dest, :verbose=>false
- else
- @fileops.mkdir_p(dest, :mode => entry.mode, :verbose=>false)
- end
- fsync_dir dest
- fsync_dir File.join(dest, "..")
- return
- end
- # it's a file
- md5 = Digest::MD5.new if expected_md5sum
- destdir = File.join(destdir, File.dirname(entry.full_name))
- @fileops.mkdir_p(destdir, :mode => 0755, :verbose=>false)
- destfile = File.join(destdir, File.basename(entry.full_name))
- @fileops.chmod(0600, destfile, :verbose=>false) rescue nil # Errno::ENOENT
- file_class.open(destfile, "wb", entry.mode) do |os|
- loop do
- data = entry.read(4096)
- break unless data
- md5 << data if expected_md5sum
- os.write(data)
- end
- os.fsync
- end
- @fileops.chmod(entry.mode, destfile, :verbose=>false)
- fsync_dir File.dirname(destfile)
- fsync_dir File.join(File.dirname(destfile), "..")
- if expected_md5sum && expected_md5sum != md5.hexdigest
- raise BadCheckSum
- end
- end
-
- def close
- @io.close
- @tarreader.close
- end
-
- private
-
- def file_class
- File
- end
- end
-
- class TarOutput
-
- class << self; private :new end
-
- def initialize(io)
- @io = io
- @external = TarWriter.new @io
- end
-
- def external_handle
- @external
- end
-
- def self.open(filename, signer = nil, &block)
- io = File.open(filename, "wb")
- open_from_io(io, signer, &block)
- nil
- end
-
- def self.open_from_io(io, signer = nil, &block)
- outputter = new(io)
- metadata = nil
- set_meta = lambda{|x| metadata = x}
- raise "Want a block" unless block_given?
- begin
- data_sig, meta_sig = nil, nil
-
- outputter.external_handle.add_file("data.tar.gz", 0644) do |inner|
- begin
- sio = signer ? StringIO.new : nil
- os = Zlib::GzipWriter.new(sio || inner)
-
- TarWriter.new(os) do |inner_tar_stream|
- klass = class << inner_tar_stream; self end
- klass.send(:define_method, :metadata=, &set_meta)
- block.call inner_tar_stream
- end
- ensure
- os.flush
- os.finish
- #os.close
-
- # if we have a signing key, then sign the data
- # digest and return the signature
- data_sig = nil
- if signer
- dgst_algo = Gem::Security::OPT[:dgst_algo]
- dig = dgst_algo.digest(sio.string)
- data_sig = signer.sign(dig)
- inner.write(sio.string)
- end
- end
- end
-
- # if we have a data signature, then write it to the gem too
- if data_sig
- sig_file = 'data.tar.gz.sig'
- outputter.external_handle.add_file(sig_file, 0644) do |os|
- os.write(data_sig)
- end
- end
-
- outputter.external_handle.add_file("metadata.gz", 0644) do |os|
- begin
- sio = signer ? StringIO.new : nil
- gzos = Zlib::GzipWriter.new(sio || os)
- gzos.write metadata
- ensure
- gzos.flush
- gzos.finish
-
- # if we have a signing key, then sign the metadata
- # digest and return the signature
- if signer
- dgst_algo = Gem::Security::OPT[:dgst_algo]
- dig = dgst_algo.digest(sio.string)
- meta_sig = signer.sign(dig)
- os.write(sio.string)
- end
- end
- end
-
- # if we have a metadata signature, then write to the gem as
- # well
- if meta_sig
- sig_file = 'metadata.gz.sig'
- outputter.external_handle.add_file(sig_file, 0644) do |os|
- os.write(meta_sig)
- end
- end
-
- ensure
- outputter.close
- end
- nil
- end
-
- def close
- @external.close
- @io.close
- end
-
- end
-
- #FIXME: refactor the following 2 methods
-
- def self.open(dest, mode = "r", signer = nil, &block)
- raise "Block needed" unless block_given?
-
- case mode
- when "r"
- security_policy = signer
- TarInput.open(dest, security_policy, &block)
- when "w"
- TarOutput.open(dest, signer, &block)
- else
- raise "Unknown Package open mode"
- end
- end
-
- def self.open_from_io(io, mode = "r", signer = nil, &block)
- raise "Block needed" unless block_given?
-
- case mode
- when "r"
- security_policy = signer
- TarInput.open_from_io(io, security_policy, &block)
- when "w"
- TarOutput.open_from_io(io, signer, &block)
- else
- raise "Unknown Package open mode"
- end
- end
-
- def self.pack(src, destname, signer = nil)
- TarOutput.open(destname, signer) do |outp|
- dir_class.chdir(src) do
- outp.metadata = (file_class.read("RPA/metadata") rescue nil)
- find_class.find('.') do |entry|
- case
- when file_class.file?(entry)
- entry.sub!(%r{\./}, "")
- next if entry =~ /\ARPA\//
- stat = File.stat(entry)
- outp.add_file_simple(entry, stat.mode, stat.size) do |os|
- file_class.open(entry, "rb") do |f|
- os.write(f.read(4096)) until f.eof?
- end
- end
- when file_class.dir?(entry)
- entry.sub!(%r{\./}, "")
- next if entry == "RPA"
- outp.mkdir(entry, file_class.stat(entry).mode)
- else
- raise "Don't know how to pack this yet!"
- end
- end
- end
- end
- end
-
- class << self
- def file_class
- File
- end
-
- def dir_class
- Dir
- end
-
- def find_class # HACK kill me
- Find
- end
- end
-
-end
-
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
deleted file mode 100644
index 7abc15ef94..0000000000
--- a/lib/rubygems/platform.rb
+++ /dev/null
@@ -1,181 +0,0 @@
-require 'rubygems'
-
-# Available list of platforms for targeting Gem installations.
-#
-class Gem::Platform
-
- @local = nil
-
- attr_accessor :cpu
-
- attr_accessor :os
-
- attr_accessor :version
-
- DEPRECATED_CONSTS = [
- :DARWIN,
- :LINUX_586,
- :MSWIN32,
- :PPC_DARWIN,
- :WIN32,
- :X86_LINUX
- ]
-
- def self.const_missing(name) # TODO remove six months from 2007/12
- if DEPRECATED_CONSTS.include? name then
- raise NameError, "#{name} has been removed, use CURRENT instead"
- else
- super
- end
- end
-
- def self.local
- arch = Gem::ConfigMap[:arch]
- arch = "#{arch}_60" if arch =~ /mswin32$/
- @local ||= new(arch)
- end
-
- def self.match(platform)
- Gem.platforms.any? do |local_platform|
- platform.nil? or local_platform == platform or
- (local_platform != Gem::Platform::RUBY and local_platform =~ platform)
- end
- end
-
- def self.new(arch) # :nodoc:
- case arch
- when Gem::Platform::CURRENT then
- Gem::Platform.local
- when Gem::Platform::RUBY, nil, '' then
- Gem::Platform::RUBY
- else
- super
- end
- end
-
- def initialize(arch)
- case arch
- when Array then
- @cpu, @os, @version = arch
- when String then
- arch = arch.split '-'
-
- if arch.length > 2 and arch.last !~ /\d/ then # reassemble x86-linux-gnu
- extra = arch.pop
- arch.last << "-#{extra}"
- end
-
- cpu = arch.shift
-
- @cpu = case cpu
- when /i\d86/ then 'x86'
- else cpu
- end
-
- if arch.length == 2 and arch.last =~ /^\d+$/ then # for command-line
- @os, @version = arch
- return
- end
-
- os, = arch
- @cpu, os = nil, cpu if os.nil? # legacy jruby
-
- @os, @version = case os
- when /aix(\d+)/ then [ 'aix', $1 ]
- when /cygwin/ then [ 'cygwin', nil ]
- when /darwin(\d+)?/ then [ 'darwin', $1 ]
- when /freebsd(\d+)/ then [ 'freebsd', $1 ]
- when /hpux(\d+)/ then [ 'hpux', $1 ]
- when /^java$/, /^jruby$/ then [ 'java', nil ]
- when /^java([\d.]*)/ then [ 'java', $1 ]
- when /linux/ then [ 'linux', $1 ]
- when /mingw32/ then [ 'mingw32', nil ]
- when /(mswin\d+)(\_(\d+))?/ then
- os, version = $1, $3
- @cpu = 'x86' if @cpu.nil? and os =~ /32$/
- [os, version]
- when /netbsdelf/ then [ 'netbsdelf', nil ]
- when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1 ]
- when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
- # test
- when /^(\w+_platform)(\d+)/ then [ $1, $2 ]
- else [ 'unknown', nil ]
- end
- when Gem::Platform then
- @cpu = arch.cpu
- @os = arch.os
- @version = arch.version
- else
- raise ArgumentError, "invalid argument #{arch.inspect}"
- end
- end
-
- def inspect
- "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a]
- end
-
- def to_a
- [@cpu, @os, @version]
- end
-
- def to_s
- to_a.compact.join '-'
- end
-
- def ==(other)
- self.class === other and
- @cpu == other.cpu and @os == other.os and @version == other.version
- end
-
- def ===(other)
- return nil unless Gem::Platform === other
-
- # cpu
- (@cpu == 'universal' or other.cpu == 'universal' or @cpu == other.cpu) and
-
- # os
- @os == other.os and
-
- # version
- (@version.nil? or other.version.nil? or @version == other.version)
- end
-
- def =~(other)
- case other
- when Gem::Platform then # nop
- when String then
- # This data is from http://gems.rubyforge.org/gems/yaml on 19 Aug 2007
- other = case other
- when /^i686-darwin(\d)/ then ['x86', 'darwin', $1]
- when /^i\d86-linux/ then ['x86', 'linux', nil]
- when 'java', 'jruby' then [nil, 'java', nil]
- when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2]
- when 'powerpc-darwin' then ['powerpc', 'darwin', nil]
- when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1]
- when /sparc-solaris2.8/ then ['sparc', 'solaris', '2.8']
- when /universal-darwin(\d)/ then ['universal', 'darwin', $1]
- else other
- end
-
- other = Gem::Platform.new other
- else
- return nil
- end
-
- self === other
- end
-
- ##
- # A pure-ruby gem that may use Gem::Specification#extensions to build
- # binary files.
-
- RUBY = 'ruby'
-
- ##
- # A platform-specific gem that is built for the packaging ruby's platform.
- # This will be replaced with Gem::Platform::local.
-
- CURRENT = 'current'
-
-end
-
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
deleted file mode 100644
index cb22e1f1b1..0000000000
--- a/lib/rubygems/remote_fetcher.rb
+++ /dev/null
@@ -1,168 +0,0 @@
-require 'net/http'
-require 'uri'
-
-require 'rubygems'
-require 'rubygems/gem_open_uri'
-
-##
-# RemoteFetcher handles the details of fetching gems and gem information from
-# a remote source.
-
-class Gem::RemoteFetcher
-
- class FetchError < Gem::Exception; end
-
- @fetcher = nil
-
- # Cached RemoteFetcher instance.
- def self.fetcher
- @fetcher ||= self.new Gem.configuration[:http_proxy]
- end
-
- # Initialize a remote fetcher using the source URI and possible proxy
- # information.
- #
- # +proxy+
- # * [String]: explicit specification of proxy; overrides any environment
- # variable setting
- # * nil: respect environment variables (HTTP_PROXY, HTTP_PROXY_USER,
- # HTTP_PROXY_PASS)
- # * <tt>:no_proxy</tt>: ignore environment variables and _don't_ use a proxy
- def initialize(proxy)
- @proxy_uri =
- case proxy
- when :no_proxy then nil
- when nil then get_proxy_from_env
- when URI::HTTP then proxy
- else URI.parse(proxy)
- end
- end
-
- # Downloads +uri+.
- def fetch_path(uri)
- open_uri_or_path(uri) do |input|
- input.read
- end
- rescue Timeout::Error
- raise FetchError, "timed out fetching #{uri}"
- rescue IOError, SocketError, SystemCallError => e
- raise FetchError, "#{e.class}: #{e} reading #{uri}"
- rescue OpenURI::HTTPError => e
- body = e.io.readlines.join "\n\t"
- message = "#{e.class}: #{e} reading #{uri}\n\t#{body}"
- raise FetchError, message
- end
-
- # Returns the size of +uri+ in bytes.
- def fetch_size(uri)
- return File.size(get_file_uri_path(uri)) if file_uri? uri
-
- uri = URI.parse uri unless URI::Generic === uri
-
- raise ArgumentError, 'uri is not an HTTP URI' unless URI::HTTP === uri
-
- http = connect_to uri.host, uri.port
-
- request = Net::HTTP::Head.new uri.request_uri
-
- request.basic_auth unescape(uri.user), unescape(uri.password) unless
- uri.user.nil? or uri.user.empty?
-
- resp = http.request request
-
- if resp.code !~ /^2/ then
- raise Gem::RemoteSourceException,
- "HTTP Response #{resp.code} fetching #{uri}"
- end
-
- if resp['content-length'] then
- return resp['content-length'].to_i
- else
- resp = http.get uri.request_uri
- return resp.body.size
- end
-
- rescue SocketError, SystemCallError, Timeout::Error => e
- raise FetchError, "#{e.message} (#{e.class})\n\tgetting size of #{uri}"
- end
-
- private
-
- def escape(str)
- return unless str
- URI.escape(str)
- end
-
- def unescape(str)
- return unless str
- URI.unescape(str)
- end
-
- # Returns an HTTP proxy URI if one is set in the environment variables.
- def get_proxy_from_env
- env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
-
- return nil if env_proxy.nil? or env_proxy.empty?
-
- uri = URI.parse env_proxy
-
- if uri and uri.user.nil? and uri.password.nil? then
- # Probably we have http_proxy_* variables?
- uri.user = escape(ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER'])
- uri.password = escape(ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS'])
- end
-
- uri
- end
-
- # Normalize the URI by adding "http://" if it is missing.
- def normalize_uri(uri)
- (uri =~ /^(https?|ftp|file):/) ? uri : "http://#{uri}"
- end
-
- # Connect to the source host/port, using a proxy if needed.
- def connect_to(host, port)
- if @proxy_uri
- Net::HTTP::Proxy(@proxy_uri.host, @proxy_uri.port, unescape(@proxy_uri.user), unescape(@proxy_uri.password)).new(host, port)
- else
- Net::HTTP.new(host, port)
- end
- end
-
- # Read the data from the (source based) URI, but if it is a file:// URI,
- # read from the filesystem instead.
- def open_uri_or_path(uri, &block)
- if file_uri?(uri)
- open(get_file_uri_path(uri), &block)
- else
- connection_options = {
- "User-Agent" => "RubyGems/#{Gem::RubyGemsVersion} #{Gem::Platform.local}"
- }
-
- if @proxy_uri
- http_proxy_url = "#{@proxy_uri.scheme}://#{@proxy_uri.host}:#{@proxy_uri.port}"
- connection_options[:proxy_http_basic_authentication] = [http_proxy_url, unescape(@proxy_uri.user)||'', unescape(@proxy_uri.password)||'']
- end
-
- uri = URI.parse uri unless URI::Generic === uri
- unless uri.nil? || uri.user.nil? || uri.user.empty? then
- connection_options[:http_basic_authentication] =
- [unescape(uri.user), unescape(uri.password)]
- end
-
- open(uri, connection_options, &block)
- end
- end
-
- # Checks if the provided string is a file:// URI.
- def file_uri?(uri)
- uri =~ %r{\Afile://}
- end
-
- # Given a file:// URI, returns its local path.
- def get_file_uri_path(uri)
- uri.sub(%r{\Afile://}, '')
- end
-
-end
-
diff --git a/lib/rubygems/require_paths_builder.rb b/lib/rubygems/require_paths_builder.rb
deleted file mode 100644
index fe4f593bf4..0000000000
--- a/lib/rubygems/require_paths_builder.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Gem
- module RequirePathsBuilder
- def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
- return if spec.require_paths == ["lib"] && (spec.bindir.nil? || spec.bindir == "bin")
- file_name = File.join(gem_home, 'gems', "#{@spec.full_name}", ".require_paths")
- file_name.untaint
- File.open(file_name, "w") do |file|
- spec.require_paths.each do |path|
- file.puts path
- end
- file.puts spec.bindir if spec.bindir
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
deleted file mode 100644
index 4dfba4fa61..0000000000
--- a/lib/rubygems/requirement.rb
+++ /dev/null
@@ -1,157 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/version'
-
-##
-# Requirement version includes a prefaced comparator in addition
-# to a version number.
-#
-# A Requirement object can actually contain multiple, er,
-# requirements, as in (> 1.2, < 2.0).
-class Gem::Requirement
-
- include Comparable
-
- OPS = {
- "=" => lambda { |v, r| v == r },
- "!=" => lambda { |v, r| v != r },
- ">" => lambda { |v, r| v > r },
- "<" => lambda { |v, r| v < r },
- ">=" => lambda { |v, r| v >= r },
- "<=" => lambda { |v, r| v <= r },
- "~>" => lambda { |v, r| v >= r && v < r.bump }
- }
-
- OP_RE = /#{OPS.keys.map{ |k| Regexp.quote k }.join '|'}/o
-
- ##
- # Factory method to create a Gem::Requirement object. Input may be a
- # Version, a String, or nil. Intended to simplify client code.
- #
- # If the input is "weird", the default version requirement is returned.
- #
- def self.create(input)
- case input
- when Gem::Requirement then
- input
- when Gem::Version, Array then
- new input
- else
- if input.respond_to? :to_str then
- self.new [input.to_str]
- else
- self.default
- end
- end
- end
-
- ##
- # A default "version requirement" can surely _only_ be '>= 0'.
- #--
- # This comment once said:
- #
- # "A default "version requirement" can surely _only_ be '> 0'."
- def self.default
- self.new ['>= 0']
- end
-
- ##
- # Constructs a Requirement from +requirements+ which can be a String, a
- # Gem::Version, or an Array of those. See parse for details on the
- # formatting of requirement strings.
- def initialize(requirements)
- @requirements = case requirements
- when Array then
- requirements.map do |requirement|
- parse(requirement)
- end
- else
- [parse(requirements)]
- end
- @version = nil # Avoid warnings.
- end
-
- # Marshal raw requirements, rather than the full object
- def marshal_dump
- [@requirements]
- end
-
- # Load custom marshal format
- def marshal_load(array)
- @requirements = array[0]
- @version = nil
- end
-
- def to_s # :nodoc:
- as_list.join(", ")
- end
-
- def as_list
- normalize
- @requirements.collect { |req|
- "#{req[0]} #{req[1]}"
- }
- end
-
- def normalize
- return if not defined? @version or @version.nil?
- @requirements = [parse(@version)]
- @nums = nil
- @version = nil
- @op = nil
- end
-
- ##
- # Is the requirement satifised by +version+.
- #
- # version:: [Gem::Version] the version to compare against
- # return:: [Boolean] true if this requirement is satisfied by
- # the version, otherwise false
- #
- def satisfied_by?(version)
- normalize
- @requirements.all? { |op, rv| satisfy?(op, version, rv) }
- end
-
- ##
- # Is "version op required_version" satisfied?
- #
- def satisfy?(op, version, required_version)
- OPS[op].call(version, required_version)
- end
-
- ##
- # Parse the version requirement obj returning the operator and version.
- #
- # The requirement can be a String or a Gem::Version. A String can be an
- # operator (<, <=, =, =>, >, !=, ~>), a version number, or both, operator
- # first.
- def parse(obj)
- case obj
- when /^\s*(#{OP_RE})\s*([0-9.]+)\s*$/o then
- [$1, Gem::Version.new($2)]
- when /^\s*([0-9.]+)\s*$/ then
- ['=', Gem::Version.new($1)]
- when /^\s*(#{OP_RE})\s*$/o then
- [$1, Gem::Version.new('0')]
- when Gem::Version then
- ['=', obj]
- else
- fail ArgumentError, "Illformed requirement [#{obj.inspect}]"
- end
- end
-
- def <=>(other)
- to_s <=> other.to_s
- end
-
- def hash # :nodoc:
- to_s.hash
- end
-
-end
-
diff --git a/lib/rubygems/rubygems_version.rb b/lib/rubygems/rubygems_version.rb
deleted file mode 100644
index 146e2cfee4..0000000000
--- a/lib/rubygems/rubygems_version.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# DO NOT EDIT
-# This file is auto-generated by build scripts.
-# See: rake update_version
-module Gem
- RubyGemsVersion = '1.0.1'
-end
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
deleted file mode 100644
index 415e98ffc0..0000000000
--- a/lib/rubygems/security.rb
+++ /dev/null
@@ -1,785 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems/gem_openssl'
-
-# = Signed Gems README
-#
-# == Table of Contents
-# * Overview
-# * Walkthrough
-# * Command-Line Options
-# * OpenSSL Reference
-# * Bugs/TODO
-# * About the Author
-#
-# == Overview
-#
-# Gem::Security implements cryptographic signatures in RubyGems. The section
-# below is a step-by-step guide to using signed gems and generating your own.
-#
-# == Walkthrough
-#
-# In order to start signing your gems, you'll need to build a private key and
-# a self-signed certificate. Here's how:
-#
-# # build a private key and certificate for gemmaster@example.com
-# $ gem cert --build gemmaster@example.com
-#
-# This could take anywhere from 5 seconds to 10 minutes, depending on the
-# speed of your computer (public key algorithms aren't exactly the speediest
-# crypto algorithms in the world). When it's finished, you'll see the files
-# "gem-private_key.pem" and "gem-public_cert.pem" in the current directory.
-#
-# First things first: take the "gem-private_key.pem" file and move it
-# somewhere private, preferably a directory only you have access to, a floppy
-# (yuck!), a CD-ROM, or something comparably secure. Keep your private key
-# hidden; if it's compromised, someone can sign packages as you (note: PKI has
-# ways of mitigating the risk of stolen keys; more on that later).
-#
-# Now, let's sign an existing gem. I'll be using my Imlib2-Ruby bindings, but
-# you can use whatever gem you'd like. Open up your existing gemspec file and
-# add the following lines:
-#
-# # signing key and certificate chain
-# s.signing_key = '/mnt/floppy/gem-private_key.pem'
-# s.cert_chain = ['gem-public_cert.pem']
-#
-# (Be sure to replace "/mnt/floppy" with the ultra-secret path to your private
-# key).
-#
-# After that, go ahead and build your gem as usual. Congratulations, you've
-# just built your first signed gem! If you peek inside your gem file, you'll
-# see a couple of new files have been added:
-#
-# $ tar tf tar tf Imlib2-Ruby-0.5.0.gem
-# data.tar.gz
-# data.tar.gz.sig
-# metadata.gz
-# metadata.gz.sig
-#
-# Now let's verify the signature. Go ahead and install the gem, but add the
-# following options: "-P HighSecurity", like this:
-#
-# # install the gem with using the security policy "HighSecurity"
-# $ sudo gem install Imlib2-Ruby-0.5.0.gem -P HighSecurity
-#
-# The -P option sets your security policy -- we'll talk about that in just a
-# minute. Eh, what's this?
-#
-# Attempting local installation of 'Imlib2-Ruby-0.5.0.gem'
-# ERROR: Error installing gem Imlib2-Ruby-0.5.0.gem[.gem]: Couldn't
-# verify data signature: Untrusted Signing Chain Root: cert =
-# '/CN=gemmaster/DC=example/DC=com', error = 'path
-# "/root/.rubygems/trust/cert-15dbb43a6edf6a70a85d4e784e2e45312cff7030.pem"
-# does not exist'
-#
-# The culprit here is the security policy. RubyGems has several different
-# security policies. Let's take a short break and go over the security
-# policies. Here's a list of the available security policies, and a brief
-# description of each one:
-#
-# * NoSecurity - Well, no security at all. Signed packages are treated like
-# unsigned packages.
-# * LowSecurity - Pretty much no security. If a package is signed then
-# RubyGems will make sure the signature matches the signing
-# certificate, and that the signing certificate hasn't expired, but
-# that's it. A malicious user could easily circumvent this kind of
-# security.
-# * MediumSecurity - Better than LowSecurity and NoSecurity, but still
-# fallible. Package contents are verified against the signing
-# certificate, and the signing certificate is checked for validity,
-# and checked against the rest of the certificate chain (if you don't
-# know what a certificate chain is, stay tuned, we'll get to that).
-# The biggest improvement over LowSecurity is that MediumSecurity
-# won't install packages that are signed by untrusted sources.
-# Unfortunately, MediumSecurity still isn't totally secure -- a
-# malicious user can still unpack the gem, strip the signatures, and
-# distribute the gem unsigned.
-# * HighSecurity - Here's the bugger that got us into this mess.
-# The HighSecurity policy is identical to the MediumSecurity policy,
-# except that it does not allow unsigned gems. A malicious user
-# doesn't have a whole lot of options here; he can't modify the
-# package contents without invalidating the signature, and he can't
-# modify or remove signature or the signing certificate chain, or
-# RubyGems will simply refuse to install the package. Oh well, maybe
-# he'll have better luck causing problems for CPAN users instead :).
-#
-# So, the reason RubyGems refused to install our shiny new signed gem was
-# because it was from an untrusted source. Well, my code is infallible
-# (hah!), so I'm going to add myself as a trusted source.
-#
-# Here's how:
-#
-# # add trusted certificate
-# gem cert --add gem-public_cert.pem
-#
-# I've added my public certificate as a trusted source. Now I can install
-# packages signed my private key without any hassle. Let's try the install
-# command above again:
-#
-# # install the gem with using the HighSecurity policy (and this time
-# # without any shenanigans)
-# $ sudo gem install Imlib2-Ruby-0.5.0.gem -P HighSecurity
-#
-# This time RubyGems should accept your signed package and begin installing.
-# While you're waiting for RubyGems to work it's magic, have a look at some of
-# the other security commands:
-#
-# Usage: gem cert [options]
-#
-# Options:
-# -a, --add CERT Add a trusted certificate.
-# -l, --list List trusted certificates.
-# -r, --remove STRING Remove trusted certificates containing STRING.
-# -b, --build EMAIL_ADDR Build private key and self-signed certificate
-# for EMAIL_ADDR.
-# -C, --certificate CERT Certificate for --sign command.
-# -K, --private-key KEY Private key for --sign command.
-# -s, --sign NEWCERT Sign a certificate with my key and certificate.
-#
-# (By the way, you can pull up this list any time you'd like by typing "gem
-# cert --help")
-#
-# Hmm. We've already covered the "--build" option, and the "--add", "--list",
-# and "--remove" commands seem fairly straightforward; they allow you to add,
-# list, and remove the certificates in your trusted certificate list. But
-# what's with this "--sign" option?
-#
-# To answer that question, let's take a look at "certificate chains", a
-# concept I mentioned earlier. There are a couple of problems with
-# self-signed certificates: first of all, self-signed certificates don't offer
-# a whole lot of security. Sure, the certificate says Yukihiro Matsumoto, but
-# how do I know it was actually generated and signed by matz himself unless he
-# gave me the certificate in person?
-#
-# The second problem is scalability. Sure, if there are 50 gem authors, then
-# I have 50 trusted certificates, no problem. What if there are 500 gem
-# authors? 1000? Having to constantly add new trusted certificates is a
-# pain, and it actually makes the trust system less secure by encouraging
-# RubyGems users to blindly trust new certificates.
-#
-# Here's where certificate chains come in. A certificate chain establishes an
-# arbitrarily long chain of trust between an issuing certificate and a child
-# certificate. So instead of trusting certificates on a per-developer basis,
-# we use the PKI concept of certificate chains to build a logical hierarchy of
-# trust. Here's a hypothetical example of a trust hierarchy based (roughly)
-# on geography:
-#
-#
-# --------------------------
-# | rubygems@rubyforge.org |
-# --------------------------
-# |
-# -----------------------------------
-# | |
-# ---------------------------- -----------------------------
-# | seattle.rb@zenspider.com | | dcrubyists@richkilmer.com |
-# ---------------------------- -----------------------------
-# | | | |
-# --------------- ---------------- ----------- --------------
-# | alf@seattle | | bob@portland | | pabs@dc | | tomcope@dc |
-# --------------- ---------------- ----------- --------------
-#
-#
-# Now, rather than having 4 trusted certificates (one for alf@seattle,
-# bob@portland, pabs@dc, and tomecope@dc), a user could actually get by with 1
-# certificate: the "rubygems@rubyforge.org" certificate. Here's how it works:
-#
-# I install "Alf2000-Ruby-0.1.0.gem", a package signed by "alf@seattle". I've
-# never heard of "alf@seattle", but his certificate has a valid signature from
-# the "seattle.rb@zenspider.com" certificate, which in turn has a valid
-# signature from the "rubygems@rubyforge.org" certificate. Voila! At this
-# point, it's much more reasonable for me to trust a package signed by
-# "alf@seattle", because I can establish a chain to "rubygems@rubyforge.org",
-# which I do trust.
-#
-# And the "--sign" option allows all this to happen. A developer creates
-# their build certificate with the "--build" option, then has their
-# certificate signed by taking it with them to their next regional Ruby meetup
-# (in our hypothetical example), and it's signed there by the person holding
-# the regional RubyGems signing certificate, which is signed at the next
-# RubyConf by the holder of the top-level RubyGems certificate. At each point
-# the issuer runs the same command:
-#
-# # sign a certificate with the specified key and certificate
-# # (note that this modifies client_cert.pem!)
-# $ gem cert -K /mnt/floppy/issuer-priv_key.pem -C issuer-pub_cert.pem
-# --sign client_cert.pem
-#
-# Then the holder of issued certificate (in this case, our buddy
-# "alf@seattle"), can start using this signed certificate to sign RubyGems.
-# By the way, in order to let everyone else know about his new fancy signed
-# certificate, "alf@seattle" would change his gemspec file to look like this:
-#
-# # signing key (still kept in an undisclosed location!)
-# s.signing_key = '/mnt/floppy/alf-private_key.pem'
-#
-# # certificate chain (includes the issuer certificate now too)
-# s.cert_chain = ['/home/alf/doc/seattlerb-public_cert.pem',
-# '/home/alf/doc/alf_at_seattle-public_cert.pem']
-#
-# Obviously, this RubyGems trust infrastructure doesn't exist yet. Also, in
-# the "real world" issuers actually generate the child certificate from a
-# certificate request, rather than sign an existing certificate. And our
-# hypothetical infrastructure is missing a certificate revocation system.
-# These are that can be fixed in the future...
-#
-# I'm sure your new signed gem has finished installing by now (unless you're
-# installing rails and all it's dependencies, that is ;D). At this point you
-# should know how to do all of these new and interesting things:
-#
-# * build a gem signing key and certificate
-# * modify your existing gems to support signing
-# * adjust your security policy
-# * modify your trusted certificate list
-# * sign a certificate
-#
-# If you've got any questions, feel free to contact me at the email address
-# below. The next couple of sections
-#
-#
-# == Command-Line Options
-#
-# Here's a brief summary of the certificate-related command line options:
-#
-# gem install
-# -P, --trust-policy POLICY Specify gem trust policy.
-#
-# gem cert
-# -a, --add CERT Add a trusted certificate.
-# -l, --list List trusted certificates.
-# -r, --remove STRING Remove trusted certificates containing
-# STRING.
-# -b, --build EMAIL_ADDR Build private key and self-signed
-# certificate for EMAIL_ADDR.
-# -C, --certificate CERT Certificate for --sign command.
-# -K, --private-key KEY Private key for --sign command.
-# -s, --sign NEWCERT Sign a certificate with my key and
-# certificate.
-#
-# A more detailed description of each options is available in the walkthrough
-# above.
-#
-#
-# == OpenSSL Reference
-#
-# The .pem files generated by --build and --sign are just basic OpenSSL PEM
-# files. Here's a couple of useful commands for manipulating them:
-#
-# # convert a PEM format X509 certificate into DER format:
-# # (note: Windows .cer files are X509 certificates in DER format)
-# $ openssl x509 -in input.pem -outform der -out output.der
-#
-# # print out the certificate in a human-readable format:
-# $ openssl x509 -in input.pem -noout -text
-#
-# And you can do the same thing with the private key file as well:
-#
-# # convert a PEM format RSA key into DER format:
-# $ openssl rsa -in input_key.pem -outform der -out output_key.der
-#
-# # print out the key in a human readable format:
-# $ openssl rsa -in input_key.pem -noout -text
-#
-# == Bugs/TODO
-#
-# * There's no way to define a system-wide trust list.
-# * custom security policies (from a YAML file, etc)
-# * Simple method to generate a signed certificate request
-# * Support for OCSP, SCVP, CRLs, or some other form of cert
-# status check (list is in order of preference)
-# * Support for encrypted private keys
-# * Some sort of semi-formal trust hierarchy (see long-winded explanation
-# above)
-# * Path discovery (for gem certificate chains that don't have a self-signed
-# root) -- by the way, since we don't have this, THE ROOT OF THE CERTIFICATE
-# CHAIN MUST BE SELF SIGNED if Policy#verify_root is true (and it is for the
-# MediumSecurity and HighSecurity policies)
-# * Better explanation of X509 naming (ie, we don't have to use email
-# addresses)
-# * Possible alternate signing mechanisms (eg, via PGP). this could be done
-# pretty easily by adding a :signing_type attribute to the gemspec, then add
-# the necessary support in other places
-# * Honor AIA field (see note about OCSP above)
-# * Maybe honor restriction extensions?
-# * Might be better to store the certificate chain as a PKCS#7 or PKCS#12
-# file, instead of an array embedded in the metadata. ideas?
-# * Possibly embed signature and key algorithms into metadata (right now
-# they're assumed to be the same as what's set in Gem::Security::OPT)
-#
-# == About the Author
-#
-# Paul Duncan <pabs@pablotron.org>
-# http://pablotron.org/
-
-module Gem::Security
-
- class Exception < Gem::Exception; end
-
- #
- # default options for most of the methods below
- #
- OPT = {
- # private key options
- :key_algo => Gem::SSL::PKEY_RSA,
- :key_size => 2048,
-
- # public cert options
- :cert_age => 365 * 24 * 3600, # 1 year
- :dgst_algo => Gem::SSL::DIGEST_SHA1,
-
- # x509 certificate extensions
- :cert_exts => {
- 'basicConstraints' => 'CA:FALSE',
- 'subjectKeyIdentifier' => 'hash',
- 'keyUsage' => 'keyEncipherment,dataEncipherment,digitalSignature',
- },
-
- # save the key and cert to a file in build_self_signed_cert()?
- :save_key => true,
- :save_cert => true,
-
- # if you define either of these, then they'll be used instead of
- # the output_fmt macro below
- :save_key_path => nil,
- :save_cert_path => nil,
-
- # output name format for self-signed certs
- :output_fmt => 'gem-%s.pem',
- :munge_re => Regexp.new(/[^a-z0-9_.-]+/),
-
- # output directory for trusted certificate checksums
- :trust_dir => File::join(Gem.user_home, '.gem', 'trust'),
-
- # default permissions for trust directory and certs
- :perms => {
- :trust_dir => 0700,
- :trusted_cert => 0600,
- :signing_cert => 0600,
- :signing_key => 0600,
- },
- }
-
- #
- # A Gem::Security::Policy object encapsulates the settings for verifying
- # signed gem files. This is the base class. You can either declare an
- # instance of this or use one of the preset security policies below.
- #
- class Policy
- attr_accessor :verify_data, :verify_signer, :verify_chain,
- :verify_root, :only_trusted, :only_signed
-
- #
- # Create a new Gem::Security::Policy object with the given mode and
- # options.
- #
- def initialize(policy = {}, opt = {})
- # set options
- @opt = Gem::Security::OPT.merge(opt)
-
- # build policy
- policy.each_pair do |key, val|
- case key
- when :verify_data then @verify_data = val
- when :verify_signer then @verify_signer = val
- when :verify_chain then @verify_chain = val
- when :verify_root then @verify_root = val
- when :only_trusted then @only_trusted = val
- when :only_signed then @only_signed = val
- end
- end
- end
-
- #
- # Get the path to the file for this cert.
- #
- def self.trusted_cert_path(cert, opt = {})
- opt = Gem::Security::OPT.merge(opt)
-
- # get digest algorithm, calculate checksum of root.subject
- algo = opt[:dgst_algo]
- dgst = algo.hexdigest(cert.subject.to_s)
-
- # build path to trusted cert file
- name = "cert-#{dgst}.pem"
-
- # join and return path components
- File::join(opt[:trust_dir], name)
- end
-
- #
- # Verify that the gem data with the given signature and signing chain
- # matched this security policy at the specified time.
- #
- def verify_gem(signature, data, chain, time = Time.now)
- Gem.ensure_ssl_available
- cert_class = OpenSSL::X509::Certificate
- exc = Gem::Security::Exception
- chain ||= []
-
- chain = chain.map{ |str| cert_class.new(str) }
- signer, ch_len = chain[-1], chain.size
-
- # make sure signature is valid
- if @verify_data
- # get digest algorithm (TODO: this should be configurable)
- dgst = @opt[:dgst_algo]
-
- # verify the data signature (this is the most important part, so don't
- # screw it up :D)
- v = signer.public_key.verify(dgst.new, signature, data)
- raise exc, "Invalid Gem Signature" unless v
-
- # make sure the signer is valid
- if @verify_signer
- # make sure the signing cert is valid right now
- v = signer.check_validity(nil, time)
- raise exc, "Invalid Signature: #{v[:desc]}" unless v[:is_valid]
- end
- end
-
- # make sure the certificate chain is valid
- if @verify_chain
- # iterate down over the chain and verify each certificate against it's
- # issuer
- (ch_len - 1).downto(1) do |i|
- issuer, cert = chain[i - 1, 2]
- v = cert.check_validity(issuer, time)
- raise exc, "%s: cert = '%s', error = '%s'" % [
- 'Invalid Signing Chain', cert.subject, v[:desc]
- ] unless v[:is_valid]
- end
-
- # verify root of chain
- if @verify_root
- # make sure root is self-signed
- root = chain[0]
- raise exc, "%s: %s (subject = '%s', issuer = '%s')" % [
- 'Invalid Signing Chain Root',
- 'Subject does not match Issuer for Gem Signing Chain',
- root.subject.to_s,
- root.issuer.to_s,
- ] unless root.issuer.to_s == root.subject.to_s
-
- # make sure root is valid
- v = root.check_validity(root, time)
- raise exc, "%s: cert = '%s', error = '%s'" % [
- 'Invalid Signing Chain Root', root.subject, v[:desc]
- ] unless v[:is_valid]
-
- # verify that the chain root is trusted
- if @only_trusted
- # get digest algorithm, calculate checksum of root.subject
- algo = @opt[:dgst_algo]
- path = Gem::Security::Policy.trusted_cert_path(root, @opt)
-
- # check to make sure trusted path exists
- raise exc, "%s: cert = '%s', error = '%s'" % [
- 'Untrusted Signing Chain Root',
- root.subject.to_s,
- "path \"#{path}\" does not exist",
- ] unless File.exist?(path)
-
- # load calculate digest from saved cert file
- save_cert = OpenSSL::X509::Certificate.new(File.read(path))
- save_dgst = algo.digest(save_cert.public_key.to_s)
-
- # create digest of public key
- pkey_str = root.public_key.to_s
- cert_dgst = algo.digest(pkey_str)
-
- # now compare the two digests, raise exception
- # if they don't match
- raise exc, "%s: %s (saved = '%s', root = '%s')" % [
- 'Invalid Signing Chain Root',
- "Saved checksum doesn't match root checksum",
- save_dgst, cert_dgst,
- ] unless save_dgst == cert_dgst
- end
- end
-
- # return the signing chain
- chain.map { |cert| cert.subject }
- end
- end
- end
-
- #
- # No security policy: all package signature checks are disabled.
- #
- NoSecurity = Policy.new(
- :verify_data => false,
- :verify_signer => false,
- :verify_chain => false,
- :verify_root => false,
- :only_trusted => false,
- :only_signed => false
- )
-
- #
- # AlmostNo security policy: only verify that the signing certificate is the
- # one that actually signed the data. Make no attempt to verify the signing
- # certificate chain.
- #
- # This policy is basically useless. better than nothing, but can still be
- # easily spoofed, and is not recommended.
- #
- AlmostNoSecurity = Policy.new(
- :verify_data => true,
- :verify_signer => false,
- :verify_chain => false,
- :verify_root => false,
- :only_trusted => false,
- :only_signed => false
- )
-
- #
- # Low security policy: only verify that the signing certificate is actually
- # the gem signer, and that the signing certificate is valid.
- #
- # This policy is better than nothing, but can still be easily spoofed, and
- # is not recommended.
- #
- LowSecurity = Policy.new(
- :verify_data => true,
- :verify_signer => true,
- :verify_chain => false,
- :verify_root => false,
- :only_trusted => false,
- :only_signed => false
- )
-
- #
- # Medium security policy: verify the signing certificate, verify the signing
- # certificate chain all the way to the root certificate, and only trust root
- # certificates that we have explicity allowed trust for.
- #
- # This security policy is reasonable, but it allows unsigned packages, so a
- # malicious person could simply delete the package signature and pass the
- # gem off as unsigned.
- #
- MediumSecurity = Policy.new(
- :verify_data => true,
- :verify_signer => true,
- :verify_chain => true,
- :verify_root => true,
- :only_trusted => true,
- :only_signed => false
- )
-
- #
- # High security policy: only allow signed gems to be installed, verify the
- # signing certificate, verify the signing certificate chain all the way to
- # the root certificate, and only trust root certificates that we have
- # explicity allowed trust for.
- #
- # This security policy is significantly more difficult to bypass, and offers
- # a reasonable guarantee that the contents of the gem have not been altered.
- #
- HighSecurity = Policy.new(
- :verify_data => true,
- :verify_signer => true,
- :verify_chain => true,
- :verify_root => true,
- :only_trusted => true,
- :only_signed => true
- )
-
- #
- # Hash of configured security policies
- #
- Policies = {
- 'NoSecurity' => NoSecurity,
- 'AlmostNoSecurity' => AlmostNoSecurity,
- 'LowSecurity' => LowSecurity,
- 'MediumSecurity' => MediumSecurity,
- 'HighSecurity' => HighSecurity,
- }
-
- #
- # Sign the cert cert with @signing_key and @signing_cert, using the digest
- # algorithm opt[:dgst_algo]. Returns the newly signed certificate.
- #
- def self.sign_cert(cert, signing_key, signing_cert, opt = {})
- opt = OPT.merge(opt)
-
- # set up issuer information
- cert.issuer = signing_cert.subject
- cert.sign(signing_key, opt[:dgst_algo].new)
-
- cert
- end
-
- #
- # Make sure the trust directory exists. If it does exist, make sure it's
- # actually a directory. If not, then create it with the appropriate
- # permissions.
- #
- def self.verify_trust_dir(path, perms)
- # if the directory exists, then make sure it is in fact a directory. if
- # it doesn't exist, then create it with the appropriate permissions
- if File.exist?(path)
- # verify that the trust directory is actually a directory
- unless File.directory?(path)
- err = "trust directory #{path} isn't a directory"
- raise Gem::Security::Exception, err
- end
- else
- # trust directory doesn't exist, so create it with permissions
- FileUtils.mkdir_p(path)
- FileUtils.chmod(perms, path)
- end
- end
-
- #
- # Build a certificate from the given DN and private key.
- #
- def self.build_cert(name, key, opt = {})
- Gem.ensure_ssl_available
- opt = OPT.merge(opt)
-
- # create new cert
- ret = OpenSSL::X509::Certificate.new
-
- # populate cert attributes
- ret.version = 2
- ret.serial = 0
- ret.public_key = key.public_key
- ret.not_before = Time.now
- ret.not_after = Time.now + opt[:cert_age]
- ret.subject = name
-
- # add certificate extensions
- ef = OpenSSL::X509::ExtensionFactory.new(nil, ret)
- ret.extensions = opt[:cert_exts].map { |k, v| ef.create_extension(k, v) }
-
- # sign cert
- i_key, i_cert = opt[:issuer_key] || key, opt[:issuer_cert] || ret
- ret = sign_cert(ret, i_key, i_cert, opt)
-
- # return cert
- ret
- end
-
- #
- # Build a self-signed certificate for the given email address.
- #
- def self.build_self_signed_cert(email_addr, opt = {})
- Gem.ensure_ssl_available
- opt = OPT.merge(opt)
- path = { :key => nil, :cert => nil }
-
- # split email address up
- cn, dcs = email_addr.split('@')
- dcs = dcs.split('.')
-
- # munge email CN and DCs
- cn = cn.gsub(opt[:munge_re], '_')
- dcs = dcs.map { |dc| dc.gsub(opt[:munge_re], '_') }
-
- # create DN
- name = "CN=#{cn}/" << dcs.map { |dc| "DC=#{dc}" }.join('/')
- name = OpenSSL::X509::Name::parse(name)
-
- # build private key
- key = opt[:key_algo].new(opt[:key_size])
-
- # method name pretty much says it all :)
- verify_trust_dir(opt[:trust_dir], opt[:perms][:trust_dir])
-
- # if we're saving the key, then write it out
- if opt[:save_key]
- path[:key] = opt[:save_key_path] || (opt[:output_fmt] % 'private_key')
- File.open(path[:key], 'wb') do |file|
- file.chmod(opt[:perms][:signing_key])
- file.write(key.to_pem)
- end
- end
-
- # build self-signed public cert from key
- cert = build_cert(name, key, opt)
-
- # if we're saving the cert, then write it out
- if opt[:save_cert]
- path[:cert] = opt[:save_cert_path] || (opt[:output_fmt] % 'public_cert')
- File.open(path[:cert], 'wb') do |file|
- file.chmod(opt[:perms][:signing_cert])
- file.write(cert.to_pem)
- end
- end
-
- # return key, cert, and paths (if applicable)
- { :key => key, :cert => cert,
- :key_path => path[:key], :cert_path => path[:cert] }
- end
-
- #
- # Add certificate to trusted cert list.
- #
- # Note: At the moment these are stored in OPT[:trust_dir], although that
- # directory may change in the future.
- #
- def self.add_trusted_cert(cert, opt = {})
- opt = OPT.merge(opt)
-
- # get destination path
- path = Gem::Security::Policy.trusted_cert_path(cert, opt)
-
- # verify trust directory (can't write to nowhere, you know)
- verify_trust_dir(opt[:trust_dir], opt[:perms][:trust_dir])
-
- # write cert to output file
- File.open(path, 'wb') do |file|
- file.chmod(opt[:perms][:trusted_cert])
- file.write(cert.to_pem)
- end
-
- # return nil
- nil
- end
-
- #
- # Basic OpenSSL-based package signing class.
- #
- class Signer
- attr_accessor :key, :cert_chain
-
- def initialize(key, cert_chain)
- Gem.ensure_ssl_available
- @algo = Gem::Security::OPT[:dgst_algo]
- @key, @cert_chain = key, cert_chain
-
- # check key, if it's a file, and if it's key, leave it alone
- if @key && !@key.kind_of?(OpenSSL::PKey::PKey)
- @key = OpenSSL::PKey::RSA.new(File.read(@key))
- end
-
- # check cert chain, if it's a file, load it, if it's cert data, convert
- # it into a cert object, and if it's a cert object, leave it alone
- if @cert_chain
- @cert_chain = @cert_chain.map do |cert|
- # check cert, if it's a file, load it, if it's cert data, convert it
- # into a cert object, and if it's a cert object, leave it alone
- if cert && !cert.kind_of?(OpenSSL::X509::Certificate)
- cert = File.read(cert) if File::exist?(cert)
- cert = OpenSSL::X509::Certificate.new(cert)
- end
- cert
- end
- end
- end
-
- #
- # Sign data with given digest algorithm
- #
- def sign(data)
- @key.sign(@algo.new, data)
- end
-
- end
-end
-
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
deleted file mode 100644
index ed957dd38a..0000000000
--- a/lib/rubygems/server.rb
+++ /dev/null
@@ -1,519 +0,0 @@
-require 'webrick'
-require 'rdoc/template'
-require 'yaml'
-require 'zlib'
-
-require 'rubygems'
-
-##
-# Gem::Server and allows users to serve gems for consumption by
-# `gem --remote-install`.
-#
-# gem_server starts an HTTP server on the given port and serves the folowing:
-# * "/" - Browsing of gem spec files for installed gems
-# * "/Marshal" - Full SourceIndex dump of metadata for installed gems
-# * "/yaml" - YAML dump of metadata for installed gems - deprecated
-# * "/gems" - Direct access to download the installable gems
-#
-# == Usage
-#
-# gem server [-p portnum] [-d gem_path]
-#
-# port_num:: The TCP port the HTTP server will bind to
-# gem_path::
-# Root gem directory containing both "cache" and "specifications"
-# subdirectories.
-class Gem::Server
-
- include Gem::UserInteraction
-
- DOC_TEMPLATE = <<-WEBPAGE
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>RubyGems Documentation Index</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link rel="stylesheet" href="gem-server-rdoc-style.css" type="text/css" media="screen" />
-</head>
-<body>
- <div id="fileHeader">
- <h1>RubyGems Documentation Index</h1>
- </div>
- <!-- banner header -->
-
-<div id="bodyContent">
- <div id="contextContent">
- <div id="description">
- <h1>Summary</h1>
-<p>There are %gem_count% gems installed:</p>
-<p>
-START:specs
-IFNOT:is_last
-<a href="#%name%">%name%</a>,
-ENDIF:is_last
-IF:is_last
-<a href="#%name%">%name%</a>.
-ENDIF:is_last
-END:specs
-<h1>Gems</h1>
-
-<dl>
-START:specs
-<dt>
-IF:first_name_entry
- <a name="%name%"></a>
-ENDIF:first_name_entry
-<b>%name% %version%</b>
-IF:rdoc_installed
- <a href="%doc_path%">[rdoc]</a>
-ENDIF:rdoc_installed
-IFNOT:rdoc_installed
- <span title="rdoc not installed">[rdoc]</span>
-ENDIF:rdoc_installed
-IF:homepage
-<a href="%homepage%" title="%homepage%">[www]</a>
-ENDIF:homepage
-IFNOT:homepage
-<span title="no homepage available">[www]</span>
-ENDIF:homepage
-IF:has_deps
- - depends on
-START:dependencies
-IFNOT:is_last
-<a href="#%name%" title="%version%">%name%</a>,
-ENDIF:is_last
-IF:is_last
-<a href="#%name%" title="%version%">%name%</a>.
-ENDIF:is_last
-END:dependencies
-ENDIF:has_deps
-</dt>
-<dd>
-%summary%
-IF:executables
- <br/>
-
-IF:only_one_executable
- Executable is
-ENDIF:only_one_executable
-
-IFNOT:only_one_executable
- Executables are
-ENDIF:only_one_executable
-
-START:executables
-IFNOT:is_last
- <span class="context-item-name">%executable%</span>,
-ENDIF:is_last
-IF:is_last
- <span class="context-item-name">%executable%</span>.
-ENDIF:is_last
-END:executables
-ENDIF:executables
-<br/>
-<br/>
-</dd>
-END:specs
-</dl>
-
- </div>
- </div>
- </div>
-<div id="validator-badges">
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
-</div>
-</body>
-</html>
- WEBPAGE
-
- # CSS is copy & paste from rdoc-style.css, RDoc V1.0.1 - 20041108
- RDOC_CSS = <<-RDOCCSS
-body {
- font-family: Verdana,Arial,Helvetica,sans-serif;
- font-size: 90%;
- margin: 0;
- margin-left: 40px;
- padding: 0;
- background: white;
-}
-
-h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
-h1 { font-size: 150%; }
-h2,h3,h4 { margin-top: 1em; }
-
-a { background: #eef; color: #039; text-decoration: none; }
-a:hover { background: #039; color: #eef; }
-
-/* Override the base stylesheets Anchor inside a table cell */
-td > a {
- background: transparent;
- color: #039;
- text-decoration: none;
-}
-
-/* and inside a section title */
-.section-title > a {
- background: transparent;
- color: #eee;
- text-decoration: none;
-}
-
-/* === Structural elements =================================== */
-
-div#index {
- margin: 0;
- margin-left: -40px;
- padding: 0;
- font-size: 90%;
-}
-
-
-div#index a {
- margin-left: 0.7em;
-}
-
-div#index .section-bar {
- margin-left: 0px;
- padding-left: 0.7em;
- background: #ccc;
- font-size: small;
-}
-
-
-div#classHeader, div#fileHeader {
- width: auto;
- color: white;
- padding: 0.5em 1.5em 0.5em 1.5em;
- margin: 0;
- margin-left: -40px;
- border-bottom: 3px solid #006;
-}
-
-div#classHeader a, div#fileHeader a {
- background: inherit;
- color: white;
-}
-
-div#classHeader td, div#fileHeader td {
- background: inherit;
- color: white;
-}
-
-
-div#fileHeader {
- background: #057;
-}
-
-div#classHeader {
- background: #048;
-}
-
-
-.class-name-in-header {
- font-size: 180%;
- font-weight: bold;
-}
-
-
-div#bodyContent {
- padding: 0 1.5em 0 1.5em;
-}
-
-div#description {
- padding: 0.5em 1.5em;
- background: #efefef;
- border: 1px dotted #999;
-}
-
-div#description h1,h2,h3,h4,h5,h6 {
- color: #125;;
- background: transparent;
-}
-
-div#validator-badges {
- text-align: center;
-}
-div#validator-badges img { border: 0; }
-
-div#copyright {
- color: #333;
- background: #efefef;
- font: 0.75em sans-serif;
- margin-top: 5em;
- margin-bottom: 0;
- padding: 0.5em 2em;
-}
-
-
-/* === Classes =================================== */
-
-table.header-table {
- color: white;
- font-size: small;
-}
-
-.type-note {
- font-size: small;
- color: #DEDEDE;
-}
-
-.xxsection-bar {
- background: #eee;
- color: #333;
- padding: 3px;
-}
-
-.section-bar {
- color: #333;
- border-bottom: 1px solid #999;
- margin-left: -20px;
-}
-
-
-.section-title {
- background: #79a;
- color: #eee;
- padding: 3px;
- margin-top: 2em;
- margin-left: -30px;
- border: 1px solid #999;
-}
-
-.top-aligned-row { vertical-align: top }
-.bottom-aligned-row { vertical-align: bottom }
-
-/* --- Context section classes ----------------------- */
-
-.context-row { }
-.context-item-name { font-family: monospace; font-weight: bold; color: black; }
-.context-item-value { font-size: small; color: #448; }
-.context-item-desc { color: #333; padding-left: 2em; }
-
-/* --- Method classes -------------------------- */
-.method-detail {
- background: #efefef;
- padding: 0;
- margin-top: 0.5em;
- margin-bottom: 1em;
- border: 1px dotted #ccc;
-}
-.method-heading {
- color: black;
- background: #ccc;
- border-bottom: 1px solid #666;
- padding: 0.2em 0.5em 0 0.5em;
-}
-.method-signature { color: black; background: inherit; }
-.method-name { font-weight: bold; }
-.method-args { font-style: italic; }
-.method-description { padding: 0 0.5em 0 0.5em; }
-
-/* --- Source code sections -------------------- */
-
-a.source-toggle { font-size: 90%; }
-div.method-source-code {
- background: #262626;
- color: #ffdead;
- margin: 1em;
- padding: 0.5em;
- border: 1px dashed #999;
- overflow: hidden;
-}
-
-div.method-source-code pre { color: #ffdead; overflow: hidden; }
-
-/* --- Ruby keyword styles --------------------- */
-
-.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
-
-.ruby-constant { color: #7fffd4; background: transparent; }
-.ruby-keyword { color: #00ffff; background: transparent; }
-.ruby-ivar { color: #eedd82; background: transparent; }
-.ruby-operator { color: #00ffee; background: transparent; }
-.ruby-identifier { color: #ffdead; background: transparent; }
-.ruby-node { color: #ffa07a; background: transparent; }
-.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
-.ruby-regexp { color: #ffa07a; background: transparent; }
-.ruby-value { color: #7fffd4; background: transparent; }
- RDOCCSS
-
- def self.run(options)
- new(options[:gemdir], options[:port], options[:daemon]).run
- end
-
- def initialize(gemdir, port, daemon)
- Socket.do_not_reverse_lookup = true
-
- @gemdir = gemdir
- @port = port
- @daemon = daemon
- logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
- @server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
-
- @spec_dir = File.join @gemdir, "specifications"
- @source_index = Gem::SourceIndex.from_gems_in @spec_dir
- end
-
- def quick(req, res)
- res['content-type'] = 'text/plain'
- res['date'] = File.stat(@spec_dir).mtime
-
- case req.request_uri.request_uri
- when '/quick/index' then
- res.body << @source_index.map { |name,_| name }.join("\n")
- when '/quick/index.rz' then
- index = @source_index.map { |name,_| name }.join("\n")
- res.body << Zlib::Deflate.deflate(index)
- when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
- dep = Gem::Dependency.new $2, $3
- specs = @source_index.search dep
-
- selector = [$2, $3, $4].map { |s| s.inspect }.join ' '
-
- platform = if $4 then
- Gem::Platform.new $4.sub(/^-/, '')
- else
- Gem::Platform::RUBY
- end
-
- specs = specs.select { |s| s.platform == platform }
-
- if specs.empty? then
- res.status = 404
- res.body = "No gems found matching #{selector}"
- elsif specs.length > 1 then
- res.status = 500
- res.body = "Multiple gems found matching #{selector}"
- elsif $1 then # marshal quickindex instead of YAML
- res.body << Zlib::Deflate.deflate(Marshal.dump(specs.first))
- else # deprecated YAML format
- res.body << Zlib::Deflate.deflate(specs.first.to_yaml)
- end
- else
- res.status = 404
- res.body = "#{req.request_uri} not found"
- end
- end
-
- def run
- @server.listen nil, @port
-
- say "Starting gem server on http://localhost:#{@port}/"
-
- WEBrick::Daemon.start if @daemon
-
- @server.mount_proc("/yaml") do |req, res|
- res['content-type'] = 'text/plain'
- res['date'] = File.stat(@spec_dir).mtime
- if req.request_method == 'HEAD' then
- res['content-length'] = @source_index.to_yaml.length
- else
- res.body << @source_index.to_yaml
- end
- end
-
- @server.mount_proc("/Marshal") do |req, res|
- res['content-type'] = 'text/plain'
- res['date'] = File.stat(@spec_dir).mtime
- if req.request_method == 'HEAD' then
- res['content-length'] = Marshal.dump(@source_index).length
- else
- res.body << Marshal.dump(@source_index)
- end
- end
-
- @server.mount_proc("/quick/", &method(:quick))
-
- @server.mount_proc("/gem-server-rdoc-style.css") do |req, res|
- res['content-type'] = 'text/css'
- res['date'] = File.stat(@spec_dir).mtime
- res.body << RDOC_CSS
- end
-
- @server.mount_proc("/") do |req, res|
- specs = []
- total_file_count = 0
-
- @source_index.each do |path, spec|
- total_file_count += spec.files.size
- deps = spec.dependencies.collect { |dep|
- { "name" => dep.name,
- "version" => dep.version_requirements.to_s, }
- }
- deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
- deps.last["is_last"] = true unless deps.empty?
-
- # executables
- executables = spec.executables.sort.collect { |exec| {"executable" => exec} }
- executables = nil if executables.empty?
- executables.last["is_last"] = true if executables
-
- specs << {
- "authors" => spec.authors.sort.join(", "),
- "date" => spec.date.to_s,
- "dependencies" => deps,
- "doc_path" => ('/doc_root/' + spec.full_name + '/rdoc/index.html'),
- "executables" => executables,
- "only_one_executable" => (executables && executables.size==1),
- "full_name" => spec.full_name,
- "has_deps" => !deps.empty?,
- "homepage" => spec.homepage,
- "name" => spec.name,
- "rdoc_installed" => Gem::DocManager.new(spec).rdoc_installed?,
- "summary" => spec.summary,
- "version" => spec.version.to_s,
- }
- end
-
- specs << {
- "authors" => "Chad Fowler, Rich Kilmer, Jim Weirich, Eric Hodel and others",
- "dependencies" => [],
- "doc_path" => "/doc_root/rubygems-#{Gem::RubyGemsVersion}/rdoc/index.html",
- "executables" => [{"executable" => 'gem', "is_last" => true}],
- "only_one_executable" => true,
- "full_name" => "rubygems-#{Gem::RubyGemsVersion}",
- "has_deps" => false,
- "homepage" => "http://rubygems.org/",
- "name" => 'rubygems',
- "rdoc_installed" => true,
- "summary" => "RubyGems itself",
- "version" => Gem::RubyGemsVersion,
- }
-
- specs = specs.sort_by { |spec| [spec["name"].downcase, spec["version"]] }
- specs.last["is_last"] = true
-
- # tag all specs with first_name_entry
- last_spec = nil
- specs.each do |spec|
- is_first = last_spec.nil? || (last_spec["name"].downcase != spec["name"].downcase)
- spec["first_name_entry"] = is_first
- last_spec = spec
- end
-
- # create page from template
- template = TemplatePage.new(DOC_TEMPLATE)
- res['content-type'] = 'text/html'
- template.write_html_on res.body,
- "gem_count" => specs.size.to_s, "specs" => specs,
- "total_file_count" => total_file_count.to_s
- end
-
- paths = { "/gems" => "/cache/", "/doc_root" => "/doc/" }
- paths.each do |mount_point, mount_dir|
- @server.mount(mount_point, WEBrick::HTTPServlet::FileHandler,
- File.join(@gemdir, mount_dir), true)
- end
-
- trap("INT") { @server.shutdown; exit! }
- trap("TERM") { @server.shutdown; exit! }
-
- @server.start
- end
-
-end
-
diff --git a/lib/rubygems/source_index.rb b/lib/rubygems/source_index.rb
deleted file mode 100644
index 2df28d9561..0000000000
--- a/lib/rubygems/source_index.rb
+++ /dev/null
@@ -1,443 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-require 'rubygems/user_interaction'
-require 'rubygems/specification'
-
-module Gem
-
- # The SourceIndex object indexes all the gems available from a
- # particular source (e.g. a list of gem directories, or a remote
- # source). A SourceIndex maps a gem full name to a gem
- # specification.
- #
- # NOTE:: The class used to be named Cache, but that became
- # confusing when cached source fetchers where introduced. The
- # constant Gem::Cache is an alias for this class to allow old
- # YAMLized source index objects to load properly.
- #
- class SourceIndex
-
- include Enumerable
-
- include Gem::UserInteraction
-
- # Class Methods. -------------------------------------------------
- class << self
- include Gem::UserInteraction
-
- # Factory method to construct a source index instance for a given
- # path.
- #
- # deprecated::
- # If supplied, from_installed_gems will act just like
- # +from_gems_in+. This argument is deprecated and is provided
- # just for backwards compatibility, and should not generally
- # be used.
- #
- # return::
- # SourceIndex instance
- #
- def from_installed_gems(*deprecated)
- if deprecated.empty?
- from_gems_in(*installed_spec_directories)
- else
- from_gems_in(*deprecated)
- end
- end
-
- # Return a list of directories in the current gem path that
- # contain specifications.
- #
- # return::
- # List of directory paths (all ending in "../specifications").
- #
- def installed_spec_directories
- Gem.path.collect { |dir| File.join(dir, "specifications") }
- end
-
- # Factory method to construct a source index instance for a
- # given path.
- #
- # spec_dirs::
- # List of directories to search for specifications. Each
- # directory should have a "specifications" subdirectory
- # containing the gem specifications.
- #
- # return::
- # SourceIndex instance
- #
- def from_gems_in(*spec_dirs)
- self.new.load_gems_in(*spec_dirs)
- end
-
- # Load a specification from a file (eval'd Ruby code)
- #
- # file_name:: [String] The .gemspec file
- # return:: Specification instance or nil if an error occurs
- #
- def load_specification(file_name)
- begin
- spec_code = File.read(file_name).untaint
- gemspec = eval spec_code, binding, file_name
- if gemspec.is_a?(Gem::Specification)
- gemspec.loaded_from = file_name
- return gemspec
- end
- alert_warning "File '#{file_name}' does not evaluate to a gem specification"
- rescue SyntaxError => e
- alert_warning e
- alert_warning spec_code
- rescue Exception => e
- alert_warning(e.inspect.to_s + "\n" + spec_code)
- alert_warning "Invalid .gemspec format in '#{file_name}'"
- end
- return nil
- end
-
- end
-
- # Instance Methods -----------------------------------------------
-
- # Constructs a source index instance from the provided
- # specifications
- #
- # specifications::
- # [Hash] hash of [Gem name, Gem::Specification] pairs
- #
- def initialize(specifications={})
- @gems = specifications
- end
-
- # Reconstruct the source index from the list of source
- # directories.
- def load_gems_in(*spec_dirs)
- @gems.clear
- specs = Dir.glob File.join("{#{spec_dirs.join(',')}}", "*.gemspec")
- specs.each do |file_name|
- gemspec = self.class.load_specification(file_name.untaint)
- add_spec(gemspec) if gemspec
- end
- self
- end
-
- # Returns a Hash of name => Specification of the latest versions of each
- # gem in this index.
- def latest_specs
- result, latest = Hash.new { |h,k| h[k] = [] }, {}
-
- self.each do |_, spec| # SourceIndex is not a hash, so we're stuck with each
- name = spec.name
- curr_ver = spec.version
- prev_ver = latest[name]
-
- next unless prev_ver.nil? or curr_ver >= prev_ver
-
- if prev_ver.nil? or curr_ver > prev_ver then
- result[name].clear
- latest[name] = curr_ver
- end
-
- result[name] << spec
- end
-
- result.values.flatten
- end
-
- # Add a gem specification to the source index.
- def add_spec(gem_spec)
- @gems[gem_spec.full_name] = gem_spec
- end
-
- # Remove a gem specification named +full_name+.
- def remove_spec(full_name)
- @gems.delete(full_name)
- end
-
- # Iterate over the specifications in the source index.
- def each(&block) # :yields: gem.full_name, gem
- @gems.each(&block)
- end
-
- # The gem specification given a full gem spec name.
- def specification(full_name)
- @gems[full_name]
- end
-
- # The signature for the source index. Changes in the signature
- # indicate a change in the index.
- def index_signature
- require 'rubygems/digest/sha2'
-
- Gem::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
- end
-
- # The signature for the given gem specification.
- def gem_signature(gem_full_name)
- require 'rubygems/digest/sha2'
-
- Gem::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
- end
-
- def size
- @gems.size
- end
- alias length size
-
- # Find a gem by an exact match on the short name.
- def find_name(gem_name, version_requirement = Gem::Requirement.default)
- search(/^#{gem_name}$/, version_requirement)
- end
-
- # Search for a gem by Gem::Dependency +gem_pattern+. If +only_platform+
- # is true, only gems matching Gem::Platform.local will be returned. An
- # Array of matching Gem::Specification objects is returned.
- #
- # For backwards compatibility, a String or Regexp pattern may be passed as
- # +gem_pattern+, and a Gem::Requirement for +platform_only+. This
- # behavior is deprecated and will be removed.
- def search(gem_pattern, platform_only = false)
- version_requirement = nil
- only_platform = false
-
- case gem_pattern # TODO warn after 2008/03, remove three months after
- when Regexp then
- version_requirement = platform_only || Gem::Requirement.default
- when Gem::Dependency then
- only_platform = platform_only
- version_requirement = gem_pattern.version_requirements
- gem_pattern = if gem_pattern.name.empty? then
- //
- else
- /^#{Regexp.escape gem_pattern.name}$/
- end
- else
- version_requirement = platform_only || Gem::Requirement.default
- gem_pattern = /#{gem_pattern}/i
- end
-
- unless Gem::Requirement === version_requirement then
- version_requirement = Gem::Requirement.create version_requirement
- end
-
- specs = @gems.values.select do |spec|
- spec.name =~ gem_pattern and
- version_requirement.satisfied_by? spec.version
- end
-
- if only_platform then
- specs = specs.select do |spec|
- Gem::Platform.match spec.platform
- end
- end
-
- specs.sort_by { |s| s.sort_obj }
- end
-
- # Refresh the source index from the local file system.
- #
- # return:: Returns a pointer to itself.
- #
- def refresh!
- load_gems_in(self.class.installed_spec_directories)
- end
-
- # Returns an Array of Gem::Specifications that are not up to date.
- #
- def outdated
- dep = Gem::Dependency.new '', Gem::Requirement.default
-
- remotes = Gem::SourceInfoCache.search dep, true
-
- outdateds = []
-
- latest_specs.each do |local|
- name = local.name
- remote = remotes.select { |spec| spec.name == name }.
- sort_by { |spec| spec.version.to_ints }.
- last
- outdateds << name if remote and local.version < remote.version
- end
-
- outdateds
- end
-
- def update(source_uri)
- use_incremental = false
-
- begin
- gem_names = fetch_quick_index source_uri
- remove_extra gem_names
- missing_gems = find_missing gem_names
-
- return false if missing_gems.size.zero?
-
- say "missing #{missing_gems.size} gems" if
- missing_gems.size > 0 and Gem.configuration.really_verbose
-
- use_incremental = missing_gems.size <= Gem.configuration.bulk_threshold
- rescue Gem::OperationNotSupportedError => ex
- alert_error "Falling back to bulk fetch: #{ex.message}" if
- Gem.configuration.really_verbose
- use_incremental = false
- end
-
- if use_incremental then
- update_with_missing(source_uri, missing_gems)
- else
- new_index = fetch_bulk_index(source_uri)
- @gems.replace(new_index.gems)
- end
-
- true
- end
-
- def ==(other) # :nodoc:
- self.class === other and @gems == other.gems
- end
-
- def dump
- Marshal.dump(self)
- end
-
- protected
-
- attr_reader :gems
-
- private
-
- def fetcher
- require 'rubygems/remote_fetcher'
-
- Gem::RemoteFetcher.fetcher
- end
-
- def fetch_index_from(source_uri)
- @fetch_error = nil
-
- indexes = %W[
- Marshal.#{Gem.marshal_version}.Z
- Marshal.#{Gem.marshal_version}
- yaml.Z
- yaml
- ]
-
- indexes.each do |name|
- spec_data = nil
- begin
- spec_data = fetcher.fetch_path("#{source_uri}/#{name}")
- spec_data = unzip(spec_data) if name =~ /\.Z$/
- if name =~ /Marshal/ then
- return Marshal.load(spec_data)
- else
- return YAML.load(spec_data)
- end
- rescue => e
- if Gem.configuration.really_verbose then
- alert_error "Unable to fetch #{name}: #{e.message}"
- end
- @fetch_error = e
- end
- end
- nil
- end
-
- def fetch_bulk_index(source_uri)
- say "Bulk updating Gem source index for: #{source_uri}"
-
- index = fetch_index_from(source_uri)
- if index.nil? then
- raise Gem::RemoteSourceException,
- "Error fetching remote gem cache: #{@fetch_error}"
- end
- @fetch_error = nil
- index
- end
-
- # Get the quick index needed for incremental updates.
- def fetch_quick_index(source_uri)
- zipped_index = fetcher.fetch_path source_uri + '/quick/index.rz'
- unzip(zipped_index).split("\n")
- rescue ::Exception => ex
- raise Gem::OperationNotSupportedError,
- "No quick index found: " + ex.message
- end
-
- # Make a list of full names for all the missing gemspecs.
- def find_missing(spec_names)
- spec_names.find_all { |full_name|
- specification(full_name).nil?
- }
- end
-
- def remove_extra(spec_names)
- dictionary = spec_names.inject({}) { |h, k| h[k] = true; h }
- each do |name, spec|
- remove_spec name unless dictionary.include? name
- end
- end
-
- # Unzip the given string.
- def unzip(string)
- require 'zlib'
- Zlib::Inflate.inflate(string)
- end
-
- # Tries to fetch Marshal representation first, then YAML
- def fetch_single_spec(source_uri, spec_name)
- @fetch_error = nil
- begin
- marshal_uri = source_uri + "/quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz"
- zipped = fetcher.fetch_path marshal_uri
- return Marshal.load(unzip(zipped))
- rescue => ex
- @fetch_error = ex
- if Gem.configuration.really_verbose then
- say "unable to fetch marshal gemspec #{marshal_uri}: #{ex.class} - #{ex}"
- end
- end
-
- begin
- yaml_uri = source_uri + "/quick/#{spec_name}.gemspec.rz"
- zipped = fetcher.fetch_path yaml_uri
- return YAML.load(unzip(zipped))
- rescue => ex
- @fetch_error = ex
- if Gem.configuration.really_verbose then
- say "unable to fetch YAML gemspec #{yaml_uri}: #{ex.class} - #{ex}"
- end
- end
- nil
- end
-
- # Update the cached source index with the missing names.
- def update_with_missing(source_uri, missing_names)
- progress = ui.progress_reporter(missing_names.size,
- "Updating metadata for #{missing_names.size} gems from #{source_uri}")
- missing_names.each do |spec_name|
- gemspec = fetch_single_spec(source_uri, spec_name)
- if gemspec.nil? then
- ui.say "Failed to download spec #{spec_name} from #{source_uri}:\n" \
- "\t#{@fetch_error.message}"
- else
- add_spec gemspec
- progress.updated spec_name
- end
- @fetch_error = nil
- end
- progress.done
- progress.count
- end
-
- end
-
- # Cache is an alias for SourceIndex to allow older YAMLized source
- # index objects to load properly.
- Cache = SourceIndex
-
-end
-
diff --git a/lib/rubygems/source_info_cache.rb b/lib/rubygems/source_info_cache.rb
deleted file mode 100644
index c84868a5f5..0000000000
--- a/lib/rubygems/source_info_cache.rb
+++ /dev/null
@@ -1,232 +0,0 @@
-require 'fileutils'
-
-require 'rubygems'
-require 'rubygems/source_info_cache_entry'
-require 'rubygems/user_interaction'
-
-# SourceInfoCache stores a copy of the gem index for each gem source.
-#
-# There are two possible cache locations, the system cache and the user cache:
-# * The system cache is prefered if it is writable or can be created.
-# * The user cache is used otherwise
-#
-# Once a cache is selected, it will be used for all operations.
-# SourceInfoCache will not switch between cache files dynamically.
-#
-# Cache data is a Hash mapping a source URI to a SourceInfoCacheEntry.
-#
-#--
-# To keep things straight, this is how the cache objects all fit together:
-#
-# Gem::SourceInfoCache
-# @cache_data = {
-# source_uri => Gem::SourceInfoCacheEntry
-# @size => source index size
-# @source_index => Gem::SourceIndex
-# ...
-# }
-#
-class Gem::SourceInfoCache
-
- include Gem::UserInteraction
-
- @cache = nil
- @system_cache_file = nil
- @user_cache_file = nil
-
- def self.cache
- return @cache if @cache
- @cache = new
- @cache.refresh if Gem.configuration.update_sources
- @cache
- end
-
- def self.cache_data
- cache.cache_data
- end
-
- # Search all source indexes for +pattern+.
- def self.search(pattern, platform_only = false)
- cache.search pattern, platform_only
- end
-
- # Search all source indexes for +pattern+. Only returns gems matching
- # Gem.platforms when +only_platform+ is true. See #search_with_source.
- def self.search_with_source(pattern, only_platform = false)
- cache.search_with_source(pattern, only_platform)
- end
-
- def initialize # :nodoc:
- @cache_data = nil
- @cache_file = nil
- @dirty = false
- end
-
- # The most recent cache data.
- def cache_data
- return @cache_data if @cache_data
- cache_file # HACK writable check
-
- begin
- # Marshal loads 30-40% faster from a String, and 2MB on 20061116 is small
- data = File.open cache_file, 'rb' do |fp| fp.read end
- @cache_data = Marshal.load data
-
- @cache_data.each do |url, sice|
- next unless sice.is_a?(Hash)
- update
- cache = sice['cache']
- size = sice['size']
- if cache.is_a?(Gem::SourceIndex) and size.is_a?(Numeric) then
- new_sice = Gem::SourceInfoCacheEntry.new cache, size
- @cache_data[url] = new_sice
- else # irreperable, force refetch.
- reset_cache_for(url)
- end
- end
- @cache_data
- rescue => e
- if Gem.configuration.really_verbose then
- say "Exception during cache_data handling: #{ex.class} - #{ex}"
- say "Cache file was: #{cache_file}"
- say "\t#{e.backtrace.join "\n\t"}"
- end
- reset_cache_data
- end
- end
-
- def reset_cache_for(url)
- say "Reseting cache for #{url}" if Gem.configuration.really_verbose
-
- sice = Gem::SourceInfoCacheEntry.new Gem::SourceIndex.new, 0
- sice.refresh url # HACK may be unnecessary, see ::cache and #refresh
-
- @cache_data[url] = sice
- @cache_data
- end
-
- def reset_cache_data
- @cache_data = {}
- end
-
- # The name of the cache file to be read
- def cache_file
- return @cache_file if @cache_file
- @cache_file = (try_file(system_cache_file) or
- try_file(user_cache_file) or
- raise "unable to locate a writable cache file")
- end
-
- # Write the cache to a local file (if it is dirty).
- def flush
- write_cache if @dirty
- @dirty = false
- end
-
- # Refreshes each source in the cache from its repository.
- def refresh
- Gem.sources.each do |source_uri|
- cache_entry = cache_data[source_uri]
- if cache_entry.nil? then
- cache_entry = Gem::SourceInfoCacheEntry.new nil, 0
- cache_data[source_uri] = cache_entry
- end
-
- update if cache_entry.refresh source_uri
- end
-
- flush
- end
-
- # Searches all source indexes for +pattern+.
- def search(pattern, platform_only = false)
- cache_data.map do |source_uri, sic_entry|
- next unless Gem.sources.include? source_uri
- sic_entry.source_index.search pattern, platform_only
- end.flatten.compact
- end
-
- # Searches all source indexes for +pattern+. If +only_platform+ is true,
- # only gems matching Gem.platforms will be selected. Returns an Array of
- # pairs containing the Gem::Specification found and the source_uri it was
- # found at.
- def search_with_source(pattern, only_platform = false)
- results = []
-
- cache_data.map do |source_uri, sic_entry|
- next unless Gem.sources.include? source_uri
-
- sic_entry.source_index.search(pattern, only_platform).each do |spec|
- results << [spec, source_uri]
- end
- end
-
- results
- end
-
- # Mark the cache as updated (i.e. dirty).
- def update
- @dirty = true
- end
-
- # The name of the system cache file.
- def system_cache_file
- self.class.system_cache_file
- end
-
- # The name of the system cache file. (class method)
- def self.system_cache_file
- @system_cache_file ||= Gem.default_system_source_cache_dir
- end
-
- # The name of the user cache file.
- def user_cache_file
- self.class.user_cache_file
- end
-
- # The name of the user cache file. (class method)
- def self.user_cache_file
- @user_cache_file ||=
- ENV['GEMCACHE'] || Gem.default_user_source_cache_dir
- end
-
- # Write data to the proper cache.
- def write_cache
- open cache_file, "wb" do |f|
- f.write Marshal.dump(cache_data)
- end
- end
-
- # Set the source info cache data directly. This is mainly used for unit
- # testing when we don't want to read a file system to grab the cached source
- # index information. The +hash+ should map a source URL into a
- # SourceInfoCacheEntry.
- def set_cache_data(hash)
- @cache_data = hash
- update
- end
-
- private
-
- # Determine if +fn+ is a candidate for a cache file. Return fn if
- # it is. Return nil if it is not.
- def try_file(fn)
- return fn if File.writable?(fn)
- return nil if File.exist?(fn)
- dir = File.dirname(fn)
- unless File.exist? dir then
- begin
- FileUtils.mkdir_p(dir)
- rescue RuntimeError, SystemCallError
- return nil
- end
- end
- if File.writable?(dir)
- File.open(fn, "wb") { |f| f << Marshal.dump({}) }
- return fn
- end
- nil
- end
-
-end
-
diff --git a/lib/rubygems/source_info_cache_entry.rb b/lib/rubygems/source_info_cache_entry.rb
deleted file mode 100644
index 02e03ca9db..0000000000
--- a/lib/rubygems/source_info_cache_entry.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'rubygems'
-require 'rubygems/source_index'
-require 'rubygems/remote_fetcher'
-
-##
-# Entrys held by a SourceInfoCache.
-
-class Gem::SourceInfoCacheEntry
-
- # The source index for this cache entry.
- attr_reader :source_index
-
- # The size of the of the source entry. Used to determine if the
- # source index has changed.
- attr_reader :size
-
- # Create a cache entry.
- def initialize(si, size)
- @source_index = si || Gem::SourceIndex.new({})
- @size = size
- end
-
- def refresh(source_uri)
- begin
- marshal_uri = URI.join source_uri.to_s, "Marshal.#{Gem.marshal_version}"
- remote_size = Gem::RemoteFetcher.fetcher.fetch_size marshal_uri
- rescue Gem::RemoteSourceException
- yaml_uri = URI.join source_uri.to_s, 'yaml'
- remote_size = Gem::RemoteFetcher.fetcher.fetch_size yaml_uri
- end
-
- return false if @size == remote_size # TODO Use index_signature instead of size?
- updated = @source_index.update source_uri
- @size = remote_size
-
- updated
- end
-
- def ==(other) # :nodoc:
- self.class === other and
- @size == other.size and
- @source_index == other.source_index
- end
-
-end
-
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
deleted file mode 100644
index 6338e73a1d..0000000000
--- a/lib/rubygems/specification.rb
+++ /dev/null
@@ -1,973 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-require 'rubygems/version'
-require 'rubygems/platform'
-
-# :stopdoc:
-# Time::today has been deprecated in 0.9.5 and will be removed.
-if RUBY_VERSION < '1.9' then
- def Time.today
- t = Time.now
- t - ((t.to_i + t.gmt_offset) % 86400)
- end unless defined? Time.today
-end
-# :startdoc:
-
-module Gem
-
- # == Gem::Specification
- #
- # The Specification class contains the metadata for a Gem. Typically
- # defined in a .gemspec file or a Rakefile, and looks like this:
- #
- # spec = Gem::Specification.new do |s|
- # s.name = 'rfoo'
- # s.version = '1.0'
- # s.summary = 'Example gem specification'
- # ...
- # end
- #
- # There are many <em>gemspec attributes</em>, and the best place to learn
- # about them in the "Gemspec Reference" linked from the RubyGems wiki.
- #
- class Specification
-
- # Allows deinstallation of gems with legacy platforms.
- attr_accessor :original_platform # :nodoc:
-
- # ------------------------- Specification version contstants.
-
- # The the version number of a specification that does not specify one
- # (i.e. RubyGems 0.7 or earlier).
- NONEXISTENT_SPECIFICATION_VERSION = -1
-
- # The specification version applied to any new Specification instances
- # created. This should be bumped whenever something in the spec format
- # changes.
- CURRENT_SPECIFICATION_VERSION = 2
-
- # An informal list of changes to the specification. The highest-valued
- # key should be equal to the CURRENT_SPECIFICATION_VERSION.
- SPECIFICATION_VERSION_HISTORY = {
- -1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'],
- 1 => [
- 'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"',
- '"test_file=x" is a shortcut for "test_files=[x]"'
- ],
- 2 => [
- 'Added "required_rubygems_version"',
- 'Now forward-compatible with future versions',
- ],
- }
-
- # :stopdoc:
- MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16 }
-
- now = Time.at(Time.now.to_i)
- TODAY = now - ((now.to_i + now.gmt_offset) % 86400)
- # :startdoc:
-
- # ------------------------- Class variables.
-
- # List of Specification instances.
- @@list = []
-
- # Optional block used to gather newly defined instances.
- @@gather = nil
-
- # List of attribute names: [:name, :version, ...]
- @@required_attributes = []
-
- # List of _all_ attributes and default values: [[:name, nil], [:bindir, 'bin'], ...]
- @@attributes = []
-
- @@nil_attributes = []
- @@non_nil_attributes = [:@original_platform]
-
- # List of array attributes
- @@array_attributes = []
-
- # Map of attribute names to default values.
- @@default_value = {}
-
- # ------------------------- Convenience class methods.
-
- def self.attribute_names
- @@attributes.map { |name, default| name }
- end
-
- def self.attribute_defaults
- @@attributes.dup
- end
-
- def self.default_value(name)
- @@default_value[name]
- end
-
- def self.required_attributes
- @@required_attributes.dup
- end
-
- def self.required_attribute?(name)
- @@required_attributes.include? name.to_sym
- end
-
- def self.array_attributes
- @@array_attributes.dup
- end
-
- # ------------------------- Infrastructure class methods.
-
- # A list of Specification instances that have been defined in this Ruby instance.
- def self.list
- @@list
- end
-
- # Used to specify the name and default value of a specification
- # attribute. The side effects are:
- # * the name and default value are added to the @@attributes list
- # and @@default_value map
- # * a standard _writer_ method (<tt>attribute=</tt>) is created
- # * a non-standard _reader method (<tt>attribute</tt>) is created
- #
- # The reader method behaves like this:
- # def attribute
- # @attribute ||= (copy of default value)
- # end
- #
- # This allows lazy initialization of attributes to their default
- # values.
- #
- def self.attribute(name, default=nil)
- ivar_name = "@#{name}".intern
- if default.nil? then
- @@nil_attributes << ivar_name
- else
- @@non_nil_attributes << [ivar_name, default]
- end
-
- @@attributes << [name, default]
- @@default_value[name] = default
- attr_accessor(name)
- end
-
- # Same as :attribute, but ensures that values assigned to the
- # attribute are array values by applying :to_a to the value.
- def self.array_attribute(name)
- @@non_nil_attributes << ["@#{name}".intern, []]
-
- @@array_attributes << name
- @@attributes << [name, []]
- @@default_value[name] = []
- code = %{
- def #{name}
- @#{name} ||= []
- end
- def #{name}=(value)
- @#{name} = Array(value)
- end
- }
-
- module_eval code, __FILE__, __LINE__ - 9
- end
-
- # Same as attribute above, but also records this attribute as mandatory.
- def self.required_attribute(*args)
- @@required_attributes << args.first
- attribute(*args)
- end
-
- # Sometimes we don't want the world to use a setter method for a particular attribute.
- # +read_only+ makes it private so we can still use it internally.
- def self.read_only(*names)
- names.each do |name|
- private "#{name}="
- end
- end
-
- # Shortcut for creating several attributes at once (each with a default value of
- # +nil+).
- def self.attributes(*args)
- args.each do |arg|
- attribute(arg, nil)
- end
- end
-
- # Some attributes require special behaviour when they are accessed. This allows for
- # that.
- def self.overwrite_accessor(name, &block)
- remove_method name
- define_method(name, &block)
- end
-
- # Defines a _singular_ version of an existing _plural_ attribute
- # (i.e. one whose value is expected to be an array). This means
- # just creating a helper method that takes a single value and
- # appends it to the array. These are created for convenience, so
- # that in a spec, one can write
- #
- # s.require_path = 'mylib'
- #
- # instead of
- #
- # s.require_paths = ['mylib']
- #
- # That above convenience is available courtesy of
- #
- # attribute_alias_singular :require_path, :require_paths
- #
- def self.attribute_alias_singular(singular, plural)
- define_method("#{singular}=") { |val|
- send("#{plural}=", [val])
- }
- define_method("#{singular}") {
- val = send("#{plural}")
- val.nil? ? nil : val.first
- }
- end
-
- # Dump only crucial instance variables.
- #
- # MAINTAIN ORDER!
- def _dump(limit) # :nodoc:
- Marshal.dump [
- @rubygems_version,
- @specification_version,
- @name,
- @version,
- (Time === @date ? @date : (require 'time'; Time.parse(@date.to_s))),
- @summary,
- @required_ruby_version,
- @required_rubygems_version,
- @original_platform,
- @dependencies,
- @rubyforge_project,
- @email,
- @authors,
- @description,
- @homepage,
- @has_rdoc,
- @new_platform,
- ]
- end
-
- # Load custom marshal format, re-initializing defaults as needed
- def self._load(str)
- array = Marshal.load str
-
- spec = Gem::Specification.new
- spec.instance_variable_set :@specification_version, array[1]
-
- current_version = CURRENT_SPECIFICATION_VERSION
-
- field_count = MARSHAL_FIELDS[spec.specification_version]
-
- if field_count.nil? or array.size < field_count then
- raise TypeError, "invalid Gem::Specification format #{array.inspect}"
- end
-
- spec.instance_variable_set :@rubygems_version, array[0]
- # spec version
- spec.instance_variable_set :@name, array[2]
- spec.instance_variable_set :@version, array[3]
- spec.instance_variable_set :@date, array[4]
- spec.instance_variable_set :@summary, array[5]
- spec.instance_variable_set :@required_ruby_version, array[6]
- spec.instance_variable_set :@required_rubygems_version, array[7]
- spec.instance_variable_set :@original_platform, array[8]
- spec.instance_variable_set :@dependencies, array[9]
- spec.instance_variable_set :@rubyforge_project, array[10]
- spec.instance_variable_set :@email, array[11]
- spec.instance_variable_set :@authors, array[12]
- spec.instance_variable_set :@description, array[13]
- spec.instance_variable_set :@homepage, array[14]
- spec.instance_variable_set :@has_rdoc, array[15]
- spec.instance_variable_set :@new_platform, array[16]
- spec.instance_variable_set :@platform, array[16].to_s
- spec.instance_variable_set :@loaded, false
-
- spec
- end
-
- # REQUIRED gemspec attributes ------------------------------------
-
- required_attribute :rubygems_version, Gem::RubyGemsVersion
- required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
- required_attribute :name
- required_attribute :version
- required_attribute :date, TODAY
- required_attribute :summary
- required_attribute :require_paths, ['lib']
-
- # OPTIONAL gemspec attributes ------------------------------------
-
- attributes :email, :homepage, :rubyforge_project, :description
- attributes :autorequire, :default_executable
-
- attribute :bindir, 'bin'
- attribute :has_rdoc, false
- attribute :required_ruby_version, Gem::Requirement.default
- attribute :required_rubygems_version, Gem::Requirement.default
- attribute :platform, Gem::Platform::RUBY
-
- attribute :signing_key, nil
- attribute :cert_chain, []
- attribute :post_install_message, nil
-
- array_attribute :authors
- array_attribute :files
- array_attribute :test_files
- array_attribute :rdoc_options
- array_attribute :extra_rdoc_files
- array_attribute :executables
-
- # Array of extensions to build. See Gem::Installer#build_extensions for
- # valid values.
-
- array_attribute :extensions
- array_attribute :requirements
- array_attribute :dependencies
-
- read_only :dependencies
-
- # ALIASED gemspec attributes -------------------------------------
-
- attribute_alias_singular :executable, :executables
- attribute_alias_singular :author, :authors
- attribute_alias_singular :require_path, :require_paths
- attribute_alias_singular :test_file, :test_files
-
- # DEPRECATED gemspec attributes ----------------------------------
-
- def test_suite_file
- warn 'test_suite_file deprecated, use test_files'
- test_files.first
- end
-
- def test_suite_file=(val)
- warn 'test_suite_file= deprecated, use test_files='
- @test_files = [] unless defined? @test_files
- @test_files << val
- end
-
- # true when this gemspec has been loaded from a specifications directory.
- # This attribute is not persisted.
-
- attr_writer :loaded
-
- # Path this gemspec was loaded from. This attribute is not persisted.
- attr_accessor :loaded_from
-
- # Special accessor behaviours (overwriting default) --------------
-
- overwrite_accessor :version= do |version|
- @version = Version.create(version)
- end
-
- overwrite_accessor :platform do
- @new_platform
- end
-
- overwrite_accessor :platform= do |platform|
- if @original_platform.nil? or
- @original_platform == Gem::Platform::RUBY then
- @original_platform = platform
- end
-
- case platform
- when Gem::Platform::CURRENT then
- @new_platform = Gem::Platform.local
- @original_platform = @new_platform.to_s
-
- when Gem::Platform then
- @new_platform = platform
-
- # legacy constants
- when nil, Gem::Platform::RUBY then
- @new_platform = Gem::Platform::RUBY
- when 'mswin32' then # was Gem::Platform::WIN32
- @new_platform = Gem::Platform.new 'x86-mswin32'
- when 'i586-linux' then # was Gem::Platform::LINUX_586
- @new_platform = Gem::Platform.new 'x86-linux'
- when 'powerpc-darwin' then # was Gem::Platform::DARWIN
- @new_platform = Gem::Platform.new 'ppc-darwin'
- else
- @new_platform = Gem::Platform.new platform
- end
-
- @platform = @new_platform.to_s
-
- @new_platform
- end
-
- overwrite_accessor :required_ruby_version= do |value|
- @required_ruby_version = Gem::Requirement.create(value)
- end
-
- overwrite_accessor :required_rubygems_version= do |value|
- @required_rubygems_version = Gem::Requirement.create(value)
- end
-
- overwrite_accessor :date= do |date|
- # We want to end up with a Time object with one-day resolution.
- # This is the cleanest, most-readable, faster-than-using-Date
- # way to do it.
- case date
- when String then
- @date = if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
- Time.local($1.to_i, $2.to_i, $3.to_i)
- else
- require 'time'
- Time.parse date
- end
- when Time then
- @date = Time.local(date.year, date.month, date.day)
- when Date then
- @date = Time.local(date.year, date.month, date.day)
- else
- @date = TODAY
- end
- end
-
- overwrite_accessor :date do
- self.date = nil if @date.nil? # HACK Sets the default value for date
- @date
- end
-
- overwrite_accessor :summary= do |str|
- @summary = if str then
- str.strip.
- gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
- gsub(/\n[ \t]*/, " ")
- end
- end
-
- overwrite_accessor :description= do |str|
- @description = if str then
- str.strip.
- gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
- gsub(/\n[ \t]*/, " ")
- end
- end
-
- overwrite_accessor :default_executable do
- begin
- if defined? @default_executable and @default_executable
- result = @default_executable
- elsif @executables and @executables.size == 1
- result = Array(@executables).first
- else
- result = nil
- end
- result
- rescue
- nil
- end
- end
-
- def add_bindir(executables)
- if not defined? @executables || @executables.nil?
- return nil
- end
-
- if defined? @bindir and @bindir then
- Array(@executables).map {|e| File.join(@bindir, e) }
- else
- @executables
- end
- rescue
- return nil
- end
-
- overwrite_accessor :files do
- result = []
- result.push(*@files) if defined?(@files)
- result.push(*@test_files) if defined?(@test_files)
- result.push(*(add_bindir(@executables)))
- result.push(*@extra_rdoc_files) if defined?(@extra_rdoc_files)
- result.push(*@extensions) if defined?(@extensions)
- result.uniq.compact
- end
-
- # Files in the Gem under one of the require_paths
- def lib_files
- @files.select do |file|
- require_paths.any? do |path|
- file.index(path) == 0
- end
- end
- end
-
- overwrite_accessor :test_files do
- # Handle the possibility that we have @test_suite_file but not
- # @test_files. This will happen when an old gem is loaded via
- # YAML.
- if defined? @test_suite_file then
- @test_files = [@test_suite_file].flatten
- @test_suite_file = nil
- end
- if defined? @test_files and @test_files then
- @test_files
- else
- @test_files = []
- end
- end
-
- # Predicates -----------------------------------------------------
-
- def loaded?; @loaded ? true : false ; end
- def has_rdoc?; has_rdoc ? true : false ; end
- def has_unit_tests?; not test_files.empty?; end
- alias has_test_suite? has_unit_tests? # (deprecated)
-
- # Constructors ---------------------------------------------------
-
- # Specification constructor. Assigns the default values to the
- # attributes, adds this spec to the list of loaded specs (see
- # Specification.list), and yields itself for further initialization.
- #
- def initialize
- @new_platform = nil
- assign_defaults
- @loaded = false
- @loaded_from = nil
- @@list << self
-
- yield self if block_given?
-
- @@gather.call(self) if @@gather
- end
-
- # Each attribute has a default value (possibly nil). Here, we
- # initialize all attributes to their default value. This is
- # done through the accessor methods, so special behaviours will
- # be honored. Furthermore, we take a _copy_ of the default so
- # each specification instance has its own empty arrays, etc.
- def assign_defaults
- @@nil_attributes.each do |name|
- instance_variable_set name, nil
- end
-
- @@non_nil_attributes.each do |name, default|
- value = case default
- when Time, Numeric, Symbol, true, false, nil then default
- else default.dup
- end
-
- instance_variable_set name, value
- end
-
- # HACK
- instance_variable_set :@new_platform, Gem::Platform::RUBY
- end
-
- # Special loader for YAML files. When a Specification object is
- # loaded from a YAML file, it bypasses the normal Ruby object
- # initialization routine (#initialize). This method makes up for
- # that and deals with gems of different ages.
- #
- # 'input' can be anything that YAML.load() accepts: String or IO.
- #
- def self.from_yaml(input)
- input = normalize_yaml_input input
- spec = YAML.load input
-
- if spec && spec.class == FalseClass then
- raise Gem::EndOfYAMLException
- end
-
- unless Gem::Specification === spec then
- raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
- end
-
- unless (spec.instance_variables.include? '@specification_version' or
- spec.instance_variables.include? :@specification_version) and
- spec.instance_variable_get :@specification_version
- spec.instance_variable_set :@specification_version,
- NONEXISTENT_SPECIFICATION_VERSION
- end
-
- spec
- end
-
- def self.load(filename)
- gemspec = nil
- fail "NESTED Specification.load calls not allowed!" if @@gather
- @@gather = proc { |gs| gemspec = gs }
- data = File.read(filename)
- eval(data)
- gemspec
- ensure
- @@gather = nil
- end
-
- # Make sure the yaml specification is properly formatted with dashes.
- def self.normalize_yaml_input(input)
- result = input.respond_to?(:read) ? input.read : input
- result = "--- " + result unless result =~ /^--- /
- result
- end
-
- # Instance methods -----------------------------------------------
-
- # Sets the rubygems_version to Gem::RubyGemsVersion.
- #
- def mark_version
- @rubygems_version = RubyGemsVersion
- end
-
- # Ignore unknown attributes if the
- def method_missing(sym, *a, &b) # :nodoc:
- if @specification_version > CURRENT_SPECIFICATION_VERSION and
- sym.to_s =~ /=$/ then
- warn "ignoring #{sym} loading #{full_name}" if $DEBUG
- else
- super
- end
- end
-
- # Adds a dependency to this Gem. For example,
- #
- # spec.add_dependency('jabber4r', '> 0.1', '<= 0.5')
- #
- # gem:: [String or Gem::Dependency] The Gem name/dependency.
- # requirements:: [default=">= 0"] The version requirements.
- #
- def add_dependency(gem, *requirements)
- requirements = if requirements.empty? then
- Gem::Requirement.default
- else
- requirements.flatten
- end
-
- unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
- gem = Dependency.new(gem, requirements)
- end
-
- dependencies << gem
- end
-
- # Returns the full name (name-version) of this Gem. Platform information
- # is included (name-version-platform) if it is specified (and not the
- # default Ruby platform).
- #
- def full_name
- if platform == Gem::Platform::RUBY or platform.nil? then
- "#{@name}-#{@version}"
- else
- "#{@name}-#{@version}-#{platform}"
- end
- end
-
- # Returns the full name (name-version) of this gemspec using the original
- # platform.
- #
- def original_name # :nodoc:
- if platform == Gem::Platform::RUBY or platform.nil? then
- "#{@name}-#{@version}"
- else
- "#{@name}-#{@version}-#{@original_platform}"
- end
- end
-
- # The full path to the gem (install path + full name).
- #
- # return:: [String] the full gem path
- #
- def full_gem_path
- path = File.join installation_path, 'gems', full_name
- return path if File.directory? path
- File.join installation_path, 'gems', original_name
- end
-
- # The default (generated) file name of the gem.
- def file_name
- full_name + ".gem"
- end
-
- # The root directory that the gem was installed into.
- #
- # return:: [String] the installation path
- #
- def installation_path
- (File.dirname(@loaded_from).split(File::SEPARATOR)[0..-2]).
- join(File::SEPARATOR)
- end
-
- # Checks if this Specification meets the requirement of the supplied
- # dependency.
- #
- # dependency:: [Gem::Dependency] the dependency to check
- # return:: [Boolean] true if dependency is met, otherwise false
- #
- def satisfies_requirement?(dependency)
- return @name == dependency.name &&
- dependency.version_requirements.satisfied_by?(@version)
- end
-
- # Comparison methods ---------------------------------------------
-
- def sort_obj
- [@name, @version.to_ints, @new_platform == Gem::Platform::RUBY ? -1 : 1]
- end
-
- def <=>(other) # :nodoc:
- sort_obj <=> other.sort_obj
- end
-
- # Tests specs for equality (across all attributes).
- def ==(other) # :nodoc:
- self.class === other && same_attributes?(other)
- end
-
- alias eql? == # :nodoc:
-
- def same_attributes?(other)
- @@attributes.each do |name, default|
- return false unless self.send(name) == other.send(name)
- end
- true
- end
- private :same_attributes?
-
- def hash # :nodoc:
- @@attributes.inject(0) { |hash_code, (name, default_value)|
- n = self.send(name).hash
- hash_code + n
- }
- end
-
- # Export methods (YAML and Ruby code) ----------------------------
-
- def to_yaml(opts = {}) # :nodoc:
- mark_version
-
- attributes = @@attributes.map { |name,| name.to_s }.sort
- attributes = attributes - %w[name version platform]
-
- yaml = YAML.quick_emit object_id, opts do |out|
- out.map taguri, to_yaml_style do |map|
- map.add 'name', @name
- map.add 'version', @version
- platform = case @original_platform
- when nil, '' then
- 'ruby'
- when String then
- @original_platform
- else
- @original_platform.to_s
- end
- map.add 'platform', platform
-
- attributes.each do |name|
- map.add name, instance_variable_get("@#{name}")
- end
- end
- end
- end
-
- def yaml_initialize(tag, vals) # :nodoc:
- vals.each do |ivar, val|
- instance_variable_set "@#{ivar}", val
- end
-
- @original_platform = @platform # for backwards compatibility
- self.platform = Gem::Platform.new @platform
- end
-
- # Returns a Ruby code representation of this specification, such that it
- # can be eval'ed and reconstruct the same specification later. Attributes
- # that still have their default values are omitted.
- def to_ruby
- mark_version
- result = []
- result << "Gem::Specification.new do |s|"
-
- result << " s.name = #{ruby_code name}"
- result << " s.version = #{ruby_code version}"
- unless platform.nil? or platform == Gem::Platform::RUBY then
- result << " s.platform = #{ruby_code original_platform}"
- end
- result << ""
- result << " s.specification_version = #{specification_version} if s.respond_to? :specification_version="
- result << ""
- result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
-
- handled = [
- :dependencies,
- :name,
- :platform,
- :required_rubygems_version,
- :specification_version,
- :version,
- ]
-
- attributes = @@attributes.sort_by { |attr_name,| attr_name.to_s }
-
- attributes.each do |attr_name, default|
- next if handled.include? attr_name
- current_value = self.send(attr_name)
- if current_value != default or
- self.class.required_attribute? attr_name then
- result << " s.#{attr_name} = #{ruby_code current_value}"
- end
- end
-
- result << "" unless dependencies.empty?
-
- dependencies.each do |dep|
- version_reqs_param = dep.requirements_list.inspect
- result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
- end
-
- result << "end"
- result << ""
-
- result.join "\n"
- end
-
- # Validation and normalization methods ---------------------------
-
- # Checks that the specification contains all required fields, and
- # does a very basic sanity check.
- #
- # Raises InvalidSpecificationException if the spec does not pass
- # the checks..
- def validate
- extend Gem::UserInteraction
-
- normalize
-
- if rubygems_version != RubyGemsVersion then
- raise Gem::InvalidSpecificationException,
- "expected RubyGems version #{RubyGemsVersion}, was #{rubygems_version}"
- end
-
- @@required_attributes.each do |symbol|
- unless self.send symbol then
- raise Gem::InvalidSpecificationException,
- "missing value for attribute #{symbol}"
- end
- end
-
- if require_paths.empty? then
- raise Gem::InvalidSpecificationException,
- "specification must have at least one require_path"
- end
-
- case platform
- when Gem::Platform, Platform::RUBY then # ok
- else
- raise Gem::InvalidSpecificationException,
- "invalid platform #{platform.inspect}, see Gem::Platform"
- end
-
- unless Array === authors and
- authors.all? { |author| String === author } then
- raise Gem::InvalidSpecificationException,
- 'authors must be Array of Strings'
- end
-
- # Warnings
-
- %w[author email homepage rubyforge_project summary].each do |attribute|
- value = self.send attribute
- alert_warning "no #{attribute} specified" if value.nil? or value.empty?
- end
-
- alert_warning "RDoc will not be generated (has_rdoc == false)" unless
- has_rdoc
-
- alert_warning "deprecated autorequire specified" if autorequire
-
- executables.each do |executable|
- executable_path = File.join bindir, executable
- shebang = File.read(executable_path, 2) == '#!'
-
- alert_warning "#{executable_path} is missing #! line" unless shebang
- end
-
- true
- end
-
- # Normalize the list of files so that:
- # * All file lists have redundancies removed.
- # * Files referenced in the extra_rdoc_files are included in the
- # package file list.
- #
- # Also, the summary and description are converted to a normal
- # format.
- def normalize
- if defined? @extra_rdoc_files and @extra_rdoc_files then
- @extra_rdoc_files.uniq!
- @files ||= []
- @files.concat(@extra_rdoc_files)
- end
- @files.uniq! if @files
- end
-
- # Dependency methods ---------------------------------------------
-
- # Return a list of all gems that have a dependency on this
- # gemspec. The list is structured with entries that conform to:
- #
- # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
- #
- # return:: [Array] [[dependent_gem, dependency, [list_of_satisfiers]]]
- #
- def dependent_gems
- out = []
- Gem.source_index.each do |name,gem|
- gem.dependencies.each do |dep|
- if self.satisfies_requirement?(dep) then
- sats = []
- find_all_satisfiers(dep) do |sat|
- sats << sat
- end
- out << [gem, dep, sats]
- end
- end
- end
- out
- end
-
- def to_s
- "#<Gem::Specification name=#{@name} version=#{@version}>"
- end
-
- private
-
- def find_all_satisfiers(dep)
- Gem.source_index.each do |name,gem|
- if(gem.satisfies_requirement?(dep)) then
- yield gem
- end
- end
- end
-
- # Return a string containing a Ruby code representation of the
- # given object.
- def ruby_code(obj)
- case obj
- when String then '%q{' + obj + '}'
- when Array then obj.inspect
- when Gem::Version then obj.to_s.inspect
- when Date then '%q{' + obj.strftime('%Y-%m-%d') + '}'
- when Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
- when Numeric then obj.inspect
- when true, false, nil then obj.inspect
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
- when Gem::Requirement then "Gem::Requirement.new(#{obj.to_s.inspect})"
- else raise Exception, "ruby_code case not handled: #{obj.class}"
- end
- end
-
- end
-
-end
-
diff --git a/lib/rubygems/timer.rb b/lib/rubygems/timer.rb
deleted file mode 100755
index 06250f26b5..0000000000
--- a/lib/rubygems/timer.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# This file defines a $log variable for logging, and a time() method for recording timing
-# information.
-#
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-
-$log = Object.new
-def $log.debug(str)
- STDERR.puts str
-end
-
-def time(msg, width=25)
- t = Time.now
- return_value = yield
- elapsed = Time.now.to_f - t.to_f
- elapsed = sprintf("%3.3f", elapsed)
- $log.debug "#{msg.ljust(width)}: #{elapsed}s"
- return_value
-end
-
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
deleted file mode 100644
index 268c0b3b83..0000000000
--- a/lib/rubygems/uninstaller.rb
+++ /dev/null
@@ -1,183 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'fileutils'
-require 'rubygems'
-require 'rubygems/dependency_list'
-require 'rubygems/doc_manager'
-require 'rubygems/user_interaction'
-
-##
-# An Uninstaller.
-#
-class Gem::Uninstaller
-
- include Gem::UserInteraction
-
- ##
- # Constructs an Uninstaller instance
- #
- # gem:: [String] The Gem name to uninstall
- #
- def initialize(gem, options)
- @gem = gem
- @version = options[:version] || Gem::Requirement.default
- @force_executables = options[:executables]
- @force_all = options[:all]
- @force_ignore = options[:ignore]
- end
-
- ##
- # Performs the uninstall of the Gem. This removes the spec, the
- # Gem directory, and the cached .gem file,
- #
- def uninstall
- list = Gem.source_index.search(/^#{@gem}$/, @version)
-
- if list.empty? then
- raise Gem::InstallError, "Unknown gem #{@gem}-#{@version}"
- elsif list.size > 1 && @force_all
- remove_all(list.dup)
- remove_executables(list.last)
- elsif list.size > 1
- say
- gem_names = list.collect {|gem| gem.full_name} + ["All versions"]
- gem_name, index =
- choose_from_list("Select gem to uninstall:", gem_names)
- if index == list.size
- remove_all(list.dup)
- remove_executables(list.last)
- elsif index >= 0 && index < list.size
- to_remove = list[index]
- remove(to_remove, list)
- remove_executables(to_remove)
- else
- say "Error: must enter a number [1-#{list.size+1}]"
- end
- else
- remove(list[0], list.dup)
- remove_executables(list.last)
- end
- end
-
- ##
- # Remove executables and batch files (windows only) for the gem as
- # it is being installed
- #
- # gemspec::[Specification] the gem whose executables need to be removed.
- #
- def remove_executables(gemspec)
- return if gemspec.nil?
- if(gemspec.executables.size > 0)
- raise Gem::FilePermissionError.new(Gem.bindir) unless
- File.writable?(Gem.bindir)
- list = Gem.source_index.search(gemspec.name).delete_if { |spec|
- spec.version == gemspec.version
- }
- executables = gemspec.executables.clone
- list.each do |spec|
- spec.executables.each do |exe_name|
- executables.delete(exe_name)
- end
- end
- return if executables.size == 0
- answer = @force_executables || ask_yes_no(
- "Remove executables and scripts for\n" +
- "'#{gemspec.executables.join(", ")}' in addition to the gem?",
- true) # " # appease ruby-mode - don't ask
- unless answer
- say "Executables and scripts will remain installed."
- return
- else
- gemspec.executables.each do |exe_name|
- say "Removing #{exe_name}"
- File.unlink File.join(Gem.bindir, exe_name) rescue nil
- File.unlink File.join(Gem.bindir, exe_name + ".bat") rescue nil
- end
- end
- end
- end
-
- #
- # list:: the list of all gems to remove
- #
- # Warning: this method modifies the +list+ parameter. Once it has
- # uninstalled a gem, it is removed from that list.
- #
- def remove_all(list)
- list.dup.each { |gem| remove(gem, list) }
- end
-
- #
- # spec:: the spec of the gem to be uninstalled
- # list:: the list of all such gems
- #
- # Warning: this method modifies the +list+ parameter. Once it has
- # uninstalled a gem, it is removed from that list.
- #
- def remove(spec, list)
- unless ok_to_remove? spec then
- raise Gem::DependencyRemovalException,
- "Uninstallation aborted due to dependent gem(s)"
- end
-
- raise Gem::FilePermissionError, spec.installation_path unless
- File.writable?(spec.installation_path)
-
- FileUtils.rm_rf spec.full_gem_path
-
- original_platform_name = [
- spec.name, spec.version, spec.original_platform].join '-'
-
- spec_dir = File.join spec.installation_path, 'specifications'
- gemspec = File.join spec_dir, "#{spec.full_name}.gemspec"
-
- unless File.exist? gemspec then
- gemspec = File.join spec_dir, "#{original_platform_name}.gemspec"
- end
-
- FileUtils.rm_rf gemspec
-
- cache_dir = File.join spec.installation_path, 'cache'
- gem = File.join cache_dir, "#{spec.full_name}.gem"
-
- unless File.exist? gem then
- gem = File.join cache_dir, "#{original_platform_name}.gem"
- end
-
- FileUtils.rm_rf gem
-
- Gem::DocManager.new(spec).uninstall_doc
-
- say "Successfully uninstalled #{spec.full_name}"
-
- list.delete spec
- end
-
- def ok_to_remove?(spec)
- return true if @force_ignore
-
- srcindex = Gem::SourceIndex.from_installed_gems
- deplist = Gem::DependencyList.from_source_index srcindex
- deplist.ok_to_remove?(spec.full_name) || ask_if_ok(spec)
- end
-
- def ask_if_ok(spec)
- msg = ['']
- msg << 'You have requested to uninstall the gem:'
- msg << "\t#{spec.full_name}"
- spec.dependent_gems.each do |gem,dep,satlist|
- msg <<
- ("#{gem.name}-#{gem.version} depends on " +
- "[#{dep.name} (#{dep.version_requirements})]")
- end
- msg << 'If you remove this gems, one or more dependencies will not be met.'
- msg << 'Continue with Uninstall?'
- return ask_yes_no(msg.join("\n"), true)
- end
-
-end
-
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
deleted file mode 100644
index 7ff03eaadf..0000000000
--- a/lib/rubygems/user_interaction.rb
+++ /dev/null
@@ -1,291 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-module Gem
-
- ####################################################################
- # Module that defines the default UserInteraction. Any class
- # including this module will have access to the +ui+ method that
- # returns the default UI.
- module DefaultUserInteraction
-
- # Return the default UI.
- def ui
- DefaultUserInteraction.ui
- end
-
- # Set the default UI. If the default UI is never explicity set, a
- # simple console based UserInteraction will be used automatically.
- def ui=(new_ui)
- DefaultUserInteraction.ui = new_ui
- end
-
- def use_ui(new_ui, &block)
- DefaultUserInteraction.use_ui(new_ui, &block)
- end
-
- # The default UI is a class variable of the singleton class for
- # this module.
-
- @ui = nil
-
- class << self
- def ui
- @ui ||= Gem::ConsoleUI.new
- end
- def ui=(new_ui)
- @ui = new_ui
- end
- def use_ui(new_ui)
- old_ui = @ui
- @ui = new_ui
- yield
- ensure
- @ui = old_ui
- end
- end
- end
-
- ####################################################################
- # Make the default UI accessable without the "ui." prefix. Classes
- # including this module may use the interaction methods on the
- # default UI directly. Classes may also reference the +ui+ and
- # <tt>ui=</tt> methods.
- #
- # Example:
- #
- # class X
- # include Gem::UserInteraction
- #
- # def get_answer
- # n = ask("What is the meaning of life?")
- # end
- # end
- module UserInteraction
- include DefaultUserInteraction
- [
- :choose_from_list, :ask, :ask_yes_no, :say, :alert, :alert_warning,
- :alert_error, :terminate_interaction!, :terminate_interaction
- ].each do |methname|
- class_eval %{
- def #{methname}(*args)
- ui.#{methname}(*args)
- end
- }
- end
- end
-
- ####################################################################
- # StreamUI implements a simple stream based user interface.
- class StreamUI
-
- attr_reader :ins, :outs, :errs
-
- def initialize(in_stream, out_stream, err_stream=STDERR)
- @ins = in_stream
- @outs = out_stream
- @errs = err_stream
- end
-
- # Choose from a list of options. +question+ is a prompt displayed
- # above the list. +list+ is a list of option strings. Returns
- # the pair [option_name, option_index].
- def choose_from_list(question, list)
- @outs.puts question
- list.each_with_index do |item, index|
- @outs.puts " #{index+1}. #{item}"
- end
- @outs.print "> "
- @outs.flush
-
- result = @ins.gets
-
- return nil, nil unless result
-
- result = result.strip.to_i - 1
- return list[result], result
- end
-
- # Ask a question. Returns a true for yes, false for no. If not
- # connected to a tty, raises an exception if default is nil,
- # otherwise returns default.
- def ask_yes_no(question, default=nil)
- if not @ins.tty? then
- if default.nil? then
- raise(
- Gem::OperationNotSupportedError,
- "Not connected to a tty and no default specified")
- else
- return default
- end
- end
- qstr = case default
- when nil
- 'yn'
- when true
- 'Yn'
- else
- 'yN'
- end
- result = nil
- while result.nil?
- result = ask("#{question} [#{qstr}]")
- result = case result
- when /^[Yy].*/
- true
- when /^[Nn].*/
- false
- when /^$/
- default
- else
- nil
- end
- end
- return result
- end
-
- # Ask a question. Returns an answer if connected to a tty, nil
- # otherwise.
- def ask(question)
- return nil if not @ins.tty?
- @outs.print(question + " ")
- @outs.flush
- result = @ins.gets
- result.chomp! if result
- result
- end
-
- # Display a statement.
- def say(statement="")
- @outs.puts statement
- end
-
- # Display an informational alert.
- def alert(statement, question=nil)
- @outs.puts "INFO: #{statement}"
- return ask(question) if question
- end
-
- # Display a warning in a location expected to get error messages.
- def alert_warning(statement, question=nil)
- @errs.puts "WARNING: #{statement}"
- ask(question) if question
- end
-
- # Display an error message in a location expected to get error
- # messages.
- def alert_error(statement, question=nil)
- @errs.puts "ERROR: #{statement}"
- ask(question) if question
- end
-
- # Terminate the application immediately without running any exit
- # handlers.
- def terminate_interaction!(status=-1)
- exit!(status)
- end
-
- # Terminate the appliation normally, running any exit handlers
- # that might have been defined.
- def terminate_interaction(status=0)
- exit(status)
- end
-
- # Return a progress reporter object
- def progress_reporter(*args)
- case Gem.configuration.verbose
- when nil, false
- SilentProgressReporter.new(@outs, *args)
- when true
- SimpleProgressReporter.new(@outs, *args)
- else
- VerboseProgressReporter.new(@outs, *args)
- end
- end
-
- class SilentProgressReporter
- attr_reader :count
-
- def initialize(out_stream, size, initial_message, terminal_message = nil)
- end
-
- def updated(message)
- end
-
- def done
- end
- end
-
- class SimpleProgressReporter
- include DefaultUserInteraction
-
- attr_reader :count
-
- def initialize(out_stream, size, initial_message,
- terminal_message = "complete")
- @out = out_stream
- @total = size
- @count = 0
- @terminal_message = terminal_message
-
- @out.puts initial_message
- end
-
- def updated(message)
- @count += 1
- @out.print "."
- @out.flush
- end
-
- def done
- @out.puts "\n#{@terminal_message}"
- end
- end
-
- class VerboseProgressReporter
- include DefaultUserInteraction
-
- attr_reader :count
-
- def initialize(out_stream, size, initial_message,
- terminal_message = 'complete')
- @out = out_stream
- @total = size
- @count = 0
- @terminal_message = terminal_message
-
- @out.puts initial_message
- end
-
- def updated(message)
- @count += 1
- @out.puts "#{@count}/#{@total}: #{message}"
- end
-
- def done
- @out.puts @terminal_message
- end
- end
- end
-
- ####################################################################
- # Subclass of StreamUI that instantiates the user interaction using
- # standard in, out and error.
- class ConsoleUI < StreamUI
- def initialize
- super(STDIN, STDOUT, STDERR)
- end
- end
-
- ####################################################################
- # SilentUI is a UI choice that is absolutely silent.
- class SilentUI
- def method_missing(sym, *args, &block)
- self
- end
- end
-end
-
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
deleted file mode 100755
index 41c457c3cf..0000000000
--- a/lib/rubygems/validator.rb
+++ /dev/null
@@ -1,186 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'find'
-
-require 'rubygems/digest/md5'
-require 'rubygems/format'
-require 'rubygems/installer'
-
-module Gem
-
- ##
- # Validator performs various gem file and gem database validation
- class Validator
- include UserInteraction
-
- ##
- # Given a gem file's contents, validates against its own MD5 checksum
- # gem_data:: [String] Contents of the gem file
- def verify_gem(gem_data)
- raise VerificationError, 'empty gem file' if gem_data.size == 0
-
- unless gem_data =~ /MD5SUM/ then
- return # Don't worry about it...this sucks. Need to fix MD5 stuff for
- # new format
- # FIXME
- end
-
- sum_data = gem_data.gsub(/MD5SUM = "([a-z0-9]+)"/,
- "MD5SUM = \"#{"F" * 32}\"")
-
- unless Gem::MD5.hexdigest(sum_data) == $1.to_s then
- raise VerificationError, 'invalid checksum for gem file'
- end
- end
-
- ##
- # Given the path to a gem file, validates against its own MD5 checksum
- #
- # gem_path:: [String] Path to gem file
- def verify_gem_file(gem_path)
- File.open gem_path, 'rb' do |file|
- gem_data = file.read
- verify_gem gem_data
- end
- rescue Errno::ENOENT
- raise Gem::VerificationError.new("missing gem file #{gem_path}")
- end
-
- private
- def find_files_for_gem(gem_directory)
- installed_files = []
- Find.find(gem_directory) {|file_name|
- fn = file_name.slice((gem_directory.size)..(file_name.size-1)).sub(/^\//, "")
- if(!(fn =~ /CVS/ || File.directory?(fn) || fn == "")) then
- installed_files << fn
- end
-
- }
- installed_files
- end
-
-
- public
- ErrorData = Struct.new(:path, :problem)
-
- ##
- # Checks the gem directory for the following potential
- # inconsistencies/problems:
- # * Checksum gem itself
- # * For each file in each gem, check consistency of installed versions
- # * Check for files that aren't part of the gem but are in the gems directory
- # * 1 cache - 1 spec - 1 directory.
- #
- # returns a hash of ErrorData objects, keyed on the problem gem's name.
- def alien
- errors = {}
- Gem::SourceIndex.from_installed_gems.each do |gem_name, gem_spec|
- errors[gem_name] ||= []
- gem_path = File.join(Gem.dir, "cache", gem_spec.full_name) + ".gem"
- spec_path = File.join(Gem.dir, "specifications", gem_spec.full_name) + ".gemspec"
- gem_directory = File.join(Gem.dir, "gems", gem_spec.full_name)
- installed_files = find_files_for_gem(gem_directory)
-
- if(!File.exist?(spec_path)) then
- errors[gem_name] << ErrorData.new(spec_path, "Spec file doesn't exist for installed gem")
- end
-
- begin
- verify_gem_file(gem_path)
- File.open(gem_path, 'rb') do |file|
- format = Gem::Format.from_file_by_path(gem_path)
- format.file_entries.each do |entry, data|
- # Found this file. Delete it from list
- installed_files.delete remove_leading_dot_dir(entry['path'])
-
- next unless data # HACK `gem check -a mkrf`
-
- File.open(File.join(gem_directory, entry['path']), 'rb') do |f|
- unless Gem::MD5.hexdigest(f.read).to_s ==
- Gem::MD5.hexdigest(data).to_s then
- errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
- end
- end
- end
- end
- rescue VerificationError => e
- errors[gem_name] << ErrorData.new(gem_path, e.message)
- end
- # Clean out directories that weren't explicitly included in the gemspec
- # FIXME: This still allows arbitrary incorrect directories.
- installed_files.delete_if {|potential_directory|
- File.directory?(File.join(gem_directory, potential_directory))
- }
- if(installed_files.size > 0) then
- errors[gem_name] << ErrorData.new(gem_path, "Unmanaged files in gem: #{installed_files.inspect}")
- end
- end
- errors
- end
-
- class TestRunner
- def initialize(suite, ui)
- @suite = suite
- @ui = ui
- end
-
- def self.run(suite, ui)
- require 'test/unit/ui/testrunnermediator'
- return new(suite, ui).start
- end
-
- def start
- @mediator = Test::Unit::UI::TestRunnerMediator.new(@suite)
- @mediator.add_listener(Test::Unit::TestResult::FAULT, &method(:add_fault))
- return @mediator.run_suite
- end
-
- def add_fault(fault)
- if Gem.configuration.verbose then
- @ui.say fault.long_display
- end
- end
- end
-
- autoload :TestRunner, 'test/unit/ui/testrunnerutilities'
-
- ##
- # Runs unit tests for a given gem specification
- def unit_test(gem_spec)
- start_dir = Dir.pwd
- Dir.chdir(gem_spec.full_gem_path)
- $: << File.join(Gem.dir, "gems", gem_spec.full_name)
- # XXX: why do we need this gem_spec when we've already got 'spec'?
- test_files = gem_spec.test_files
- if test_files.empty?
- say "There are no unit tests to run for #{gem_spec.full_name}"
- require 'test/unit/ui/console/testrunner'
- return Test::Unit::TestResult.new
- end
- gem gem_spec.name, "= #{gem_spec.version.version}"
- test_files.each do |f| require f end
- suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")
- ObjectSpace.each_object(Class) do |klass|
- suite << klass.suite if (klass < Test::Unit::TestCase)
- end
- result = TestRunner.run(suite, ui())
- unless result.passed?
- alert_error(result.to_s)
- #unless ask_yes_no(result.to_s + "...keep Gem?", true) then
- #Gem::Uninstaller.new(gem_spec.name, gem_spec.version.version).uninstall
- #end
- end
- result
- ensure
- Dir.chdir(start_dir)
- end
-
- def remove_leading_dot_dir(path)
- path.sub(/^\.\//, "")
- end
- end
-end
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
deleted file mode 100644
index 87a1bc72ed..0000000000
--- a/lib/rubygems/version.rb
+++ /dev/null
@@ -1,165 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-##
-# The Version class processes string versions into comparable values
-class Gem::Version
-
- include Comparable
-
- attr_reader :ints
-
- attr_reader :version
-
- ##
- # Checks if version string is valid format
- #
- # str:: [String] the version string
- # return:: [Boolean] true if the string format is correct, otherwise false
- #
- def self.correct?(version)
- case version
- when Integer, /\A\s*(\d+(\.\d+)*)*\s*\z/ then true
- else false
- end
- end
-
- ##
- # Factory method to create a Version object. Input may be a Version or a
- # String. Intended to simplify client code.
- #
- # ver1 = Version.create('1.3.17') # -> (Version object)
- # ver2 = Version.create(ver1) # -> (ver1)
- # ver3 = Version.create(nil) # -> nil
- #
- def self.create(input)
- if input.respond_to? :version then
- input
- elsif input.nil? then
- nil
- else
- new input
- end
- end
-
- ##
- # Constructs a version from the supplied string
- #
- # version:: [String] The version string. Format is digit.digit...
- #
- def initialize(version)
- raise ArgumentError, "Malformed version number string #{version}" unless
- self.class.correct?(version)
-
- self.version = version
- end
-
- def inspect # :nodoc:
- "#<#{self.class} #{@version.inspect}>"
- end
-
- # Dump only the raw version string, not the complete object
- def marshal_dump
- [@version]
- end
-
- # Load custom marshal format
- def marshal_load(array)
- self.version = array[0]
- end
-
- # Strip ignored trailing zeros.
- def normalize
- @ints = build_array_from_version_string
-
- return if @ints.length == 1
-
- @ints.pop while @ints.last == 0
-
- @ints = [0] if @ints.empty?
- end
-
- ##
- # Returns the text representation of the version
- #
- # return:: [String] version as string
- #
- def to_s
- @version
- end
-
- ##
- # Convert version to integer array
- #
- # return:: [Array] list of integers
- #
- def to_ints
- normalize unless @ints
- @ints
- end
-
- def to_yaml_properties
- ['@version']
- end
-
- def version=(version)
- @version = version.to_s.strip
- normalize
- end
-
- def yaml_initialize(tag, values)
- self.version = values['version']
- end
-
- ##
- # Compares two versions
- #
- # other:: [Version or .ints] other version to compare to
- # return:: [Fixnum] -1, 0, 1
- #
- def <=>(other)
- return 1 unless other
- @ints <=> other.ints
- end
-
- alias eql? == # :nodoc:
-
- def hash # :nodoc:
- to_ints.inject { |hash_code, n| hash_code + n }
- end
-
- # Return a new version object where the next to the last revision
- # number is one greater. (e.g. 5.3.1 => 5.4)
- def bump
- ints = build_array_from_version_string
- ints.pop if ints.size > 1
- ints[-1] += 1
- self.class.new(ints.join("."))
- end
-
- def build_array_from_version_string
- @version.to_s.scan(/\d+/).map { |s| s.to_i }
- end
- private :build_array_from_version_string
-
- #:stopdoc:
-
- require 'rubygems/requirement'
-
- # Gem::Requirement's original definition is nested in Version.
- # Although an inappropriate place, current gems specs reference the nested
- # class name explicitly. To remain compatible with old software loading
- # gemspecs, we leave a copy of original definition in Version, but define an
- # alias Gem::Requirement for use everywhere else.
-
- Requirement = ::Gem::Requirement
-
- # :startdoc:
-
-end
-
diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb
deleted file mode 100644
index 54f85188df..0000000000
--- a/lib/rubygems/version_option.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-
-# Mixin methods for --version and --platform Gem::Command options.
-module Gem::VersionOption
-
- # Add the --platform option to the option parser.
- def add_platform_option(task = command, *wrap)
- OptionParser.accept Gem::Platform do |value|
- if value == Gem::Platform::RUBY then
- value
- else
- Gem::Platform.new value
- end
- end
-
- add_option('--platform PLATFORM', Gem::Platform,
- "Specify the platform of gem to #{task}", *wrap) do
- |value, options|
- unless options[:added_platform] then
- Gem.platforms.clear
- Gem.platforms << Gem::Platform::RUBY
- options[:added_platform] = true
- end
-
- Gem.platforms << value unless Gem.platforms.include? value
- end
- end
-
- # Add the --version option to the option parser.
- def add_version_option(task = command, *wrap)
- OptionParser.accept Gem::Requirement do |value|
- Gem::Requirement.new value
- end
-
- add_option('-v', '--version VERSION', Gem::Requirement,
- "Specify version of gem to #{task}", *wrap) do
- |value, options|
- options[:version] = value
- end
- end
-
-end
-
diff --git a/lib/rubyunit.rb b/lib/rubyunit.rb
new file mode 100644
index 0000000000..1aca37864f
--- /dev/null
+++ b/lib/rubyunit.rb
@@ -0,0 +1,6 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'runit/testcase'
+require 'test/unit'
diff --git a/lib/runit/assert.rb b/lib/runit/assert.rb
new file mode 100644
index 0000000000..c752b19a25
--- /dev/null
+++ b/lib/runit/assert.rb
@@ -0,0 +1,73 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'test/unit/assertions'
+require 'runit/error'
+
+module RUNIT
+ module Assert
+ include Test::Unit::Assertions
+
+ def setup_assert
+ end
+
+ def assert_no_exception(*args, &block)
+ assert_nothing_raised(*args, &block)
+ end
+
+ # To deal with the fact that RubyUnit does not check that the
+ # regular expression is, indeed, a regular expression, if it is
+ # not, we do our own assertion using the same semantics as
+ # RubyUnit
+ def assert_match(actual_string, expected_re, message="")
+ _wrap_assertion {
+ full_message = build_message(message, "Expected <?> to match <?>", actual_string, expected_re)
+ assert_block(full_message) {
+ expected_re =~ actual_string
+ }
+ Regexp.last_match
+ }
+ end
+
+ def assert_not_nil(actual, message="")
+ assert(!actual.nil?, message)
+ end
+
+ def assert_not_match(actual_string, expected_re, message="")
+ assert_no_match(expected_re, actual_string, message)
+ end
+
+ def assert_matches(*args)
+ assert_match(*args)
+ end
+
+ def assert_fail(message="")
+ flunk(message)
+ end
+
+ def assert_equal_float(expected, actual, delta, message="")
+ assert_in_delta(expected, actual, delta, message)
+ end
+
+ def assert_send(object, method, *args)
+ super([object, method, *args])
+ end
+
+ def assert_exception(exception, message="", &block)
+ assert_raises(exception, message, &block)
+ end
+
+ def assert_respond_to(method, object, message="")
+ if (called_internally?)
+ super
+ else
+ super(object, method, message)
+ end
+ end
+
+ def called_internally?
+ /assertions\.rb/.match(caller[1])
+ end
+ end
+end
diff --git a/lib/runit/cui/testrunner.rb b/lib/runit/cui/testrunner.rb
new file mode 100644
index 0000000000..d521ec16ad
--- /dev/null
+++ b/lib/runit/cui/testrunner.rb
@@ -0,0 +1,51 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'test/unit/ui/console/testrunner'
+require 'runit/testresult'
+
+module RUNIT
+ module CUI
+ class TestRunner < Test::Unit::UI::Console::TestRunner
+ @@quiet_mode = false
+
+ def self.run(suite)
+ self.new().run(suite)
+ end
+
+ def initialize
+ super nil
+ end
+
+ def run(suite, quiet_mode=@@quiet_mode)
+ @suite = suite
+ def @suite.suite
+ self
+ end
+ @output_level = (quiet_mode ? Test::Unit::UI::PROGRESS_ONLY : Test::Unit::UI::VERBOSE)
+ start
+ end
+
+ def create_mediator(suite)
+ mediator = Test::Unit::UI::TestRunnerMediator.new(suite)
+ class << mediator
+ attr_writer :result_delegate
+ def create_result
+ return @result_delegate.create_result
+ end
+ end
+ mediator.result_delegate = self
+ return mediator
+ end
+
+ def create_result
+ return RUNIT::TestResult.new
+ end
+
+ def self.quiet_mode=(boolean)
+ @@quiet_mode = boolean
+ end
+ end
+ end
+end
diff --git a/lib/runit/error.rb b/lib/runit/error.rb
new file mode 100644
index 0000000000..4a727fb02b
--- /dev/null
+++ b/lib/runit/error.rb
@@ -0,0 +1,9 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'test/unit/assertionfailederror.rb'
+
+module RUNIT
+ AssertionFailedError = Test::Unit::AssertionFailedError
+end
diff --git a/lib/runit/testcase.rb b/lib/runit/testcase.rb
new file mode 100644
index 0000000000..4576cb8644
--- /dev/null
+++ b/lib/runit/testcase.rb
@@ -0,0 +1,45 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'runit/testresult'
+require 'runit/testsuite'
+require 'runit/assert'
+require 'runit/error'
+require 'test/unit/testcase'
+
+module RUNIT
+ class TestCase < Test::Unit::TestCase
+ include RUNIT::Assert
+
+ def self.suite
+ method_names = instance_methods(true)
+ tests = method_names.delete_if { |method_name| method_name !~ /^test/ }
+ suite = TestSuite.new(name)
+ tests.each {
+ |test|
+ catch(:invalid_test) {
+ suite << new(test, name)
+ }
+ }
+ return suite
+ end
+
+ def initialize(test_name, suite_name=self.class.name)
+ super(test_name)
+ end
+
+ def assert_equals(*args)
+ assert_equal(*args)
+ end
+
+ def name
+ super.sub(/^(.*?)\((.*)\)$/, '\2#\1')
+ end
+
+ def run(result, &progress_block)
+ progress_block = proc {} unless (block_given?)
+ super(result, &progress_block)
+ end
+ end
+end
diff --git a/lib/runit/testresult.rb b/lib/runit/testresult.rb
new file mode 100644
index 0000000000..7f70778171
--- /dev/null
+++ b/lib/runit/testresult.rb
@@ -0,0 +1,44 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'test/unit/testresult'
+
+module RUNIT
+ class TestResult < Test::Unit::TestResult
+ attr_reader(:errors, :failures)
+ def succeed?
+ return passed?
+ end
+ def failure_size
+ return failure_count
+ end
+ def run_asserts
+ return assertion_count
+ end
+ def error_size
+ return error_count
+ end
+ def run_tests
+ return run_count
+ end
+ def add_failure(failure)
+ def failure.at
+ return location
+ end
+ def failure.err
+ return message
+ end
+ super(failure)
+ end
+ def add_error(error)
+ def error.at
+ return location
+ end
+ def error.err
+ return exception
+ end
+ super(error)
+ end
+ end
+end
diff --git a/lib/runit/testsuite.rb b/lib/runit/testsuite.rb
new file mode 100644
index 0000000000..63baf65707
--- /dev/null
+++ b/lib/runit/testsuite.rb
@@ -0,0 +1,26 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'test/unit/testsuite'
+
+module RUNIT
+ class TestSuite < Test::Unit::TestSuite
+ def add_test(*args)
+ add(*args)
+ end
+
+ def add(*args)
+ self.<<(*args)
+ end
+
+ def count_test_cases
+ return size
+ end
+
+ def run(result, &progress_block)
+ progress_block = proc {} unless (block_given?)
+ super(result, &progress_block)
+ end
+ end
+end
diff --git a/lib/runit/topublic.rb b/lib/runit/topublic.rb
new file mode 100644
index 0000000000..566f0dd35c
--- /dev/null
+++ b/lib/runit/topublic.rb
@@ -0,0 +1,8 @@
+# Author:: Nathaniel Talbott.
+# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+module RUNIT
+ module ToPublic
+ end
+end
diff --git a/lib/scanf.rb b/lib/scanf.rb
index 87b7e98eeb..2972bf9d60 100644
--- a/lib/scanf.rb
+++ b/lib/scanf.rb
@@ -1,6 +1,5 @@
# scanf for Ruby
#
-# $Release Version: 1.1.2 $
# $Revision$
# $Id$
# $Author$
@@ -467,11 +466,11 @@ module Scanf
end
def letter
- @spec_string[/%\*?\d*([a-z\[])/, 1]
+ /%\*?\d*([a-z\[])/.match(@spec_string).to_a[1]
end
def width
- w = @spec_string[/%\*?(\d+)/, 1]
+ w = /%\*?(\d+)/.match(@spec_string).to_a[1]
w && w.to_i
end
@@ -542,8 +541,7 @@ module Scanf
@string_left = str
@matched_count = 0
- @specs.each_with_index do |spec,i|
- @i=i
+ @specs.each_with_index do |spec,@i|
@last_spec_tried = spec
@last_match_tried = spec.match(@string_left)
break unless @last_match_tried
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 50431c86b0..3fd63e535f 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -119,13 +119,13 @@ module SecureRandom
hex = n.to_s(16)
hex = '0' + hex if (hex.length & 1) == 1
bin = [hex].pack("H*")
- mask = bin[0].ord
+ mask = bin[0]
mask |= mask >> 1
mask |= mask >> 2
mask |= mask >> 4
begin
rnd = SecureRandom.random_bytes(bin.length)
- rnd[0] = (rnd[0].ord & mask).chr
+ rnd[0] = (rnd[0] & mask).chr
end until rnd < bin
rnd.unpack("H*")[0].hex
else
diff --git a/lib/set.rb b/lib/set.rb
index 12e9486ca3..164aa429d9 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -2,7 +2,7 @@
#--
# set.rb - defines the Set class
#++
-# Copyright (c) 2002 Akinori MUSHA <knu@iDaemons.org>
+# Copyright (c) 2002-2008 Akinori MUSHA <knu@iDaemons.org>
#
# Documentation by Akinori MUSHA and Gavin Sinclair.
#
@@ -28,13 +28,14 @@
# This is a hybrid of Array's intuitive inter-operation facilities and
# Hash's fast lookup.
#
+# Several methods accept any Enumerable object (implementing +each+)
+# for greater flexibility: new, replace, merge, subtract, |, &, -, ^.
+#
# The equality of each couple of elements is determined according to
# Object#eql? and Object#hash, since Set uses Hash as storage.
#
-# Set is easy to use with Enumerable objects (implementing +each+).
-# Most of the initializer methods and binary operators accept generic
-# Enumerable objects besides sets and arrays. An Enumerable object
-# can be converted to Set using the +to_set+ method.
+# Finally, if you are using class Set, you can also use Enumerable#to_set
+# for convenience.
#
# == Example
#
@@ -47,6 +48,10 @@
# s1.subset? s2 # -> false
# s2.subset? s1 # -> true
#
+# == Contact
+#
+# - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
+#
class Set
include Enumerable
@@ -77,24 +82,6 @@ class Set
@hash = orig.instance_eval{@hash}.dup
end
- def freeze # :nodoc:
- super
- @hash.freeze
- self
- end
-
- def taint # :nodoc:
- super
- @hash.taint
- self
- end
-
- def untaint # :nodoc:
- super
- @hash.untaint
- self
- end
-
# Returns the number of elements.
def size
@hash.size
@@ -118,6 +105,7 @@ class Set
if enum.class == self.class
@hash.replace(enum.instance_eval { @hash })
else
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
clear
enum.each { |o| add(o) }
end
@@ -200,14 +188,16 @@ class Set
end
# Calls the given block once for each element in the set, passing
- # the element as parameter.
+ # the element as parameter. Returns an enumerator if no block is
+ # given.
def each
+ block_given? or return enum_for(__method__)
@hash.each_key { |o| yield(o) }
self
end
# Adds the given object to the set and returns self. Use +merge+ to
- # add many elements at once.
+ # add several elements at once.
def add(o)
@hash[o] = true
self
@@ -225,7 +215,7 @@ class Set
end
# Deletes the given object from the set and returns self. Use +subtract+ to
- # delete many items at once.
+ # delete several items at once.
def delete(o)
@hash.delete(o)
self
@@ -244,7 +234,7 @@ class Set
# Deletes every element of the set for which block evaluates to
# true, and returns self.
def delete_if
- @hash.delete_if { |o,| yield(o) }
+ to_a.each { |o| @hash.delete(o) if yield(o) }
self
end
@@ -270,6 +260,7 @@ class Set
if enum.is_a?(Set)
@hash.update(enum.instance_eval { @hash })
else
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
enum.each { |o| add(o) }
end
@@ -279,6 +270,7 @@ class Set
# Deletes every element that appears in the given enumerable object
# and returns self.
def subtract(enum)
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
enum.each { |o| delete(o) }
self
end
@@ -286,6 +278,7 @@ class Set
# Returns a new set built by merging the set and the elements of the
# given enumerable object.
def |(enum)
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
dup.merge(enum)
end
alias + | ##
@@ -294,6 +287,7 @@ class Set
# Returns a new set built by duplicating the set, removing every
# element that appears in the given enumerable object.
def -(enum)
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
dup.subtract(enum)
end
alias difference - ##
@@ -301,6 +295,7 @@ class Set
# Returns a new set containing elements common to the set and the
# given enumerable object.
def &(enum)
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
n = self.class.new
enum.each { |o| n.add(o) if include?(o) }
n
@@ -311,6 +306,7 @@ class Set
# and the given enumerable object. (set ^ enum) is equivalent to
# ((set | enum) - (set & enum)).
def ^(enum)
+ enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
n = Set.new(enum)
each { |o| if n.include?(o) then n.delete(o) else n.add(o) end }
n
@@ -496,7 +492,7 @@ class SortedSet < Set
def delete_if
n = @hash.size
- @hash.delete_if { |o,| yield(o) }
+ super
@keys = nil if @hash.size != n
self
end
@@ -507,7 +503,9 @@ class SortedSet < Set
end
def each
+ block_given? or return enum_for(__method__)
to_a.each { |o| yield(o) }
+ self
end
def to_a
@@ -584,6 +582,7 @@ end
# end
#
# def replace(enum)
+# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
# clear
# enum.each { |o| add(o) }
#
@@ -591,6 +590,7 @@ end
# end
#
# def merge(enum)
+# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
# enum.each { |o| add(o) }
#
# self
@@ -657,11 +657,12 @@ class TC_Set < Test::Unit::TestCase
Set.new([])
Set.new([1,2])
Set.new('a'..'c')
+ Set.new('XYZ')
}
- assert_raises(NoMethodError) {
+ assert_raises(ArgumentError) {
Set.new(false)
}
- assert_raises(NoMethodError) {
+ assert_raises(ArgumentError) {
Set.new(1)
}
assert_raises(ArgumentError) {
@@ -921,9 +922,11 @@ class TC_Set < Test::Unit::TestCase
ary = [1,3,5,7,10,20]
set = Set.new(ary)
- assert_raises(LocalJumpError) {
- set.each
- }
+ ret = set.each { |o| }
+ assert_same(set, ret)
+
+ e = set.each
+ assert_instance_of(Enumerable::Enumerator, e)
assert_nothing_raised {
set.each { |o|
@@ -1168,11 +1171,33 @@ class TC_SortedSet < Test::Unit::TestCase
assert_equal([-10,-8,-6,-4,-2], s.to_a)
prev = nil
- s.each { |o| assert(prev < o) if prev; prev = o }
+ ret = s.each { |o| assert(prev < o) if prev; prev = o }
assert_not_nil(prev)
+ assert_same(s, ret)
s = SortedSet.new([2,1,3]) { |o| o * -2 }
assert_equal([-6,-4,-2], s.to_a)
+
+ s = SortedSet.new(['one', 'two', 'three', 'four'])
+ a = []
+ ret = s.delete_if { |o| a << o; o.start_with?('t') }
+ assert_same(s, ret)
+ assert_equal(['four', 'one'], s.to_a)
+ assert_equal(['four', 'one', 'three', 'two'], a)
+
+ s = SortedSet.new(['one', 'two', 'three', 'four'])
+ a = []
+ ret = s.reject! { |o| a << o; o.start_with?('t') }
+ assert_same(s, ret)
+ assert_equal(['four', 'one'], s.to_a)
+ assert_equal(['four', 'one', 'three', 'two'], a)
+
+ s = SortedSet.new(['one', 'two', 'three', 'four'])
+ a = []
+ ret = s.reject! { |o| a << o; false }
+ assert_same(nil, ret)
+ assert_equal(['four', 'one', 'three', 'two'], s.to_a)
+ assert_equal(['four', 'one', 'three', 'two'], a)
end
end
diff --git a/lib/shell.rb b/lib/shell.rb
index b18d8e3cae..039f849ef5 100644
--- a/lib/shell.rb
+++ b/lib/shell.rb
@@ -1,9 +1,9 @@
#
# shell.rb -
-# $Release Version: 0.7 $
-# $Revision: 1.9 $
-# $Date: 2002/03/04 12:01:10 $
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# $Release Version: 0.6.0 $
+# $Revision: 1.8 $
+# $Date: 2001/03/19 09:01:11 $
+# by Keiju ISHITSUKA(Nippon Rational Inc.)
#
# --
#
@@ -11,17 +11,14 @@
#
require "e2mmap"
-
-require "thread" unless defined?(Mutex)
-
-require "forwardable"
+require "thread"
require "shell/error"
require "shell/command-processor"
require "shell/process-controller"
class Shell
- @RCS_ID='-$Id: shell.rb,v 1.9 2002/03/04 12:01:10 keiju Exp keiju $-'
+ @RCS_ID='-$Id: shell.rb,v 1.8 2001/03/19 09:01:11 keiju Exp keiju $-'
include Error
extend Exception2MessageMapper
@@ -33,14 +30,10 @@ class Shell
@debug = false
@verbose = true
- @debug_display_process_id = false
- @debug_display_thread_id = true
- @debug_output_mutex = Mutex.new
-
class << Shell
- extend Forwardable
-
- attr_accessor :cascade, :debug, :verbose
+ attr :cascade, true
+ attr :debug, true
+ attr :verbose, true
# alias cascade? cascade
alias debug? debug
@@ -53,7 +46,9 @@ class Shell
end
def cd(path)
- new(path)
+ sh = new
+ sh.cd path
+ sh
end
def default_system_path
@@ -79,19 +74,12 @@ class Shell
def default_record_separator=(rs)
@default_record_separator = rs
end
-
- # os resource mutecs
- mutex_methods = ["unlock", "lock", "locked?", "synchronize", "try_lock", "exclusive_unlock"]
- for m in mutex_methods
- def_delegator("@debug_output_mutex", m, "debug_output_"+m.to_s)
- end
-
end
- def initialize(pwd = Dir.pwd, umask = nil)
- @cwd = File.expand_path(pwd)
+ def initialize
+ @cwd = Dir.pwd
@dir_stack = []
- @umask = umask
+ @umask = nil
@system_path = Shell.default_system_path
@record_separator = Shell.default_record_separator
@@ -110,8 +98,11 @@ class Shell
rehash
end
- attr_accessor :umask, :record_separator
- attr_accessor :verbose, :debug
+ attr :umask, true
+ attr :record_separator, true
+
+ attr :verbose, true
+ attr :debug, true
def debug=(val)
@debug = val
@@ -140,58 +131,49 @@ class Shell
# Shell#mkdir
# Shell#rmdir
- attr_reader :cwd
+ attr :cwd
alias dir cwd
alias getwd cwd
alias pwd cwd
- attr_reader :dir_stack
+ attr :dir_stack
alias dirs dir_stack
# If called as iterator, it restores the current directory when the
# block ends.
- def chdir(path = nil, verbose = @verbose)
- check_point
-
+ def chdir(path = nil)
if iterator?
- notify("chdir(with block) #{path}") if verbose
cwd_old = @cwd
begin
- chdir(path, nil)
+ chdir(path)
yield
ensure
- chdir(cwd_old, nil)
+ chdir(cwd_old)
end
else
- notify("chdir #{path}") if verbose
path = "~" unless path
@cwd = expand_path(path)
notify "current dir: #{@cwd}"
rehash
- Void.new(self)
+ self
end
end
alias cd chdir
- def pushdir(path = nil, verbose = @verbose)
- check_point
-
+ def pushdir(path = nil)
if iterator?
- notify("pushdir(with block) #{path}") if verbose
- pushdir(path, nil)
+ pushdir(path)
begin
yield
ensure
popdir
end
elsif path
- notify("pushdir #{path}") if verbose
@dir_stack.push @cwd
- chdir(path, nil)
+ chdir path
notify "dir stack: [#{@dir_stack.join ', '}]"
self
else
- notify("pushdir") if verbose
if pop = @dir_stack.pop
@dir_stack.push @cwd
chdir pop
@@ -201,14 +183,10 @@ class Shell
Shell.Fail DirStackEmpty
end
end
- Void.new(self)
end
alias pushd pushdir
def popdir
- check_point
-
- notify("popdir")
if pop = @dir_stack.pop
chdir pop
notify "dir stack: [#{@dir_stack.join ', '}]"
@@ -216,10 +194,10 @@ class Shell
else
Shell.Fail DirStackEmpty
end
- Void.new(self)
end
alias popd popdir
+
#
# process management
#
@@ -264,35 +242,25 @@ class Shell
end
def self.notify(*opts, &block)
- Shell::debug_output_synchronize do
- if opts[-1].kind_of?(String)
- yorn = verbose?
- else
- yorn = opts.pop
- end
- return unless yorn
-
- if @debug_display_thread_id
- if @debug_display_process_id
- prefix = "shell(##{Process.pid}:#{Thread.current.to_s.sub("Thread", "Th")}): "
- else
- prefix = "shell(#{Thread.current.to_s.sub("Thread", "Th")}): "
- end
+ Thread.exclusive do
+ if opts[-1].kind_of?(String)
+ yorn = verbose?
+ else
+ yorn = opts.pop
+ end
+ return unless yorn
+
+ _head = true
+ print opts.collect{|mes|
+ mes = mes.dup
+ yield mes if iterator?
+ if _head
+ _head = false
+ "shell: " + mes
else
- prefix = "shell: "
+ " " + mes
end
- _head = true
- STDERR.print opts.collect{|mes|
- mes = mes.dup
- yield mes if iterator?
- if _head
- _head = false
-# "shell" " + mes
- prefix + mes
- else
- " "* prefix.size + mes
- end
- }.join("\n")+"\n"
+ }.join("\n")+"\n"
end
end
diff --git a/lib/shell/builtin-command.rb b/lib/shell/builtin-command.rb
index cfdbc046aa..db1adfa48b 100644
--- a/lib/shell/builtin-command.rb
+++ b/lib/shell/builtin-command.rb
@@ -1,9 +1,9 @@
#
# shell/builtin-command.rb -
-# $Release Version: 0.7 $
+# $Release Version: 0.6.0 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
@@ -22,16 +22,6 @@ class Shell
end
end
- class Void < BuiltInCommand
- def initialize(sh, *opts)
- super sh
- end
-
- def each(rs = nil)
- # do nothing
- end
- end
-
class Echo < BuiltInCommand
def initialize(sh, *strings)
super sh
@@ -68,17 +58,20 @@ class Shell
super sh
@pattern = pattern
+ Thread.critical = true
+ back = Dir.pwd
+ begin
+ Dir.chdir @shell.cwd
+ @files = Dir[pattern]
+ ensure
+ Dir.chdir back
+ Thread.critical = false
+ end
end
def each(rs = nil)
- if @pattern[0] == ?/
- @files = Dir[@pattern]
- else
- prefix = @shell.pwd+"/"
- @files = Dir[prefix+@pattern].collect{|p| p.sub(prefix, "")}
- end
rs = @shell.record_separator unless rs
- for f in @files
+ for f in @files
yield f+rs
end
end
diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb
index f5e8713c34..ecf6c7d5eb 100644
--- a/lib/shell/command-processor.rb
+++ b/lib/shell/command-processor.rb
@@ -1,9 +1,9 @@
#
# shell/command-controller.rb -
-# $Release Version: 0.7 $
+# $Release Version: 0.6.0 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nippon Rational Inc.)
#
# --
#
@@ -11,6 +11,7 @@
#
require "e2mmap"
+require "ftools"
require "thread"
require "shell/error"
@@ -25,13 +26,7 @@ class Shell
#
# initialize of Shell and related classes.
#
- m = [:initialize, :expand_path]
- if Object.methods.first.kind_of?(String)
- NoDelegateMethods = m.collect{|m| m.id2name}
- else
- NoDelegateMethods = m
- end
-
+ NoDelegateMethods = ["initialize", "expand_path"]
def self.initialize
install_builtin_commands
@@ -116,20 +111,13 @@ class Shell
# Dir#open (when path is directory)
# mode has an effect only when path is a file
#
- def open(path, mode = nil, perm = 0666, &b)
+ def open(path, mode)
path = expand_path(path)
if File.directory?(path)
- Dir.open(path, &b)
+ Dir.open(path)
else
- if @shell.umask
- f = File.open(path, mode, perm)
- File.chmod(perm & ~@shell.umask, path)
- if block_given?
- f.each &b
- end
- f
- else
- f = File.open(path, mode, perm, &b)
+ effect_umask do
+ File.open(path, mode)
end
end
end
@@ -142,15 +130,12 @@ class Shell
# File#unlink (when path is file)
#
def unlink(path)
- @shell.check_point
-
path = expand_path(path)
if File.directory?(path)
Dir.unlink(path)
else
IO.unlink(path)
end
- Void.new(@shell)
end
#
@@ -170,7 +155,6 @@ class Shell
# sh[:exists?, "foo"]
# sh["exists?", "foo"]
#
- alias top_level_test test
def test(command, file1, file2=nil)
file1 = expand_path(file1)
file2 = expand_path(file2) if file2
@@ -178,11 +162,7 @@ class Shell
case command
when Integer
- if file2
- top_level_test(command, file1, file2)
- else
- top_level_test(command, file1)
- end
+ top_level_test(command, file1, file2)
when String
if command.size == 1
if file2
@@ -214,23 +194,9 @@ class Shell
# same as Dir.mkdir()
#
def mkdir(*path)
- @shell.check_point
- notify("mkdir #{path.join(' ')}")
-
- perm = nil
- if path.last.kind_of?(Integer)
- perm = path.pop
- end
for dir in path
- d = expand_path(dir)
- if perm
- Dir.mkdir(d, perm)
- else
- Dir.mkdir(d)
- end
- File.chmod(d, 0666 & ~@shell.umask) if @shell.umask
+ Dir.mkdir(expand_path(dir))
end
- Void.new(@shell)
end
#
@@ -239,13 +205,9 @@ class Shell
# same as Dir.rmdir()
#
def rmdir(*path)
- @shell.check_point
- notify("rmdir #{path.join(' ')}")
-
for dir in path
Dir.rmdir(expand_path(dir))
end
- Void.new(@shell)
end
#
@@ -337,17 +299,35 @@ class Shell
# %pwd, %cwd -> @pwd
def notify(*opts, &block)
- Shell.notify(*opts) {|mes|
- yield mes if iterator?
+ Thread.exclusive do
+ Shell.notify(*opts) {|mes|
+ yield mes if iterator?
- mes.gsub!("%pwd", "#{@cwd}")
- mes.gsub!("%cwd", "#{@cwd}")
- }
+ mes.gsub!("%pwd", "#{@cwd}")
+ mes.gsub!("%cwd", "#{@cwd}")
+ }
+ end
end
#
# private functions
#
+ def effect_umask
+ if @shell.umask
+ Thread.critical = true
+ save = File.umask
+ begin
+ yield
+ ensure
+ File.umask save
+ Thread.critical = false
+ end
+ else
+ yield
+ end
+ end
+ private :effect_umask
+
def find_system_command(command)
return command if /^\// =~ command
case path = @system_commands[command]
@@ -363,7 +343,7 @@ class Shell
for p in @shell.system_path
path = join(p, command)
- if FileTest.exist?(path)
+ if FileTest.exists?(path)
@system_commands[command] = path
return path
end
@@ -474,7 +454,7 @@ class Shell
end]
Shell.notify "Define #{meth}(#{arg_str})", Shell.debug?
Shell.notify("Definition of #{meth}: ", d,
- Shell.debug.kind_of?(Integer) && Shell.debug > 1)
+ Shell.debug.kind_of?(Integer) && Shell.debug > 1)
eval d
end
end
@@ -588,6 +568,24 @@ class Shell
def_builtin_commands(FileTest,
FileTest.singleton_methods(false).collect{|m| [m, ["FILENAME"]]})
+ # method related ftools
+ normal_delegation_ftools_methods = [
+ ["syscopy", ["FILENAME_FROM", "FILENAME_TO"]],
+ ["copy", ["FILENAME_FROM", "FILENAME_TO"]],
+ ["move", ["FILENAME_FROM", "FILENAME_TO"]],
+ ["compare", ["FILENAME_FROM", "FILENAME_TO"]],
+ ["safe_unlink", ["*FILENAMES"]],
+ ["makedirs", ["*FILENAMES"]],
+ # ["chmod", ["mode", "*FILENAMES"]],
+ ["install", ["FILENAME_FROM", "FILENAME_TO", "mode"]],
+ ]
+ def_builtin_commands(File,
+ normal_delegation_ftools_methods)
+ alias_method :cmp, :compare
+ alias_method :mv, :move
+ alias_method :cp, :copy
+ alias_method :rm_f, :safe_unlink
+ alias_method :mkpath, :makedirs
end
end
diff --git a/lib/shell/error.rb b/lib/shell/error.rb
index 97df30b3c2..d338b1c5d1 100644
--- a/lib/shell/error.rb
+++ b/lib/shell/error.rb
@@ -1,9 +1,9 @@
#
# shell/error.rb -
-# $Release Version: 0.7 $
+# $Release Version: 0.6.0 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
diff --git a/lib/shell/filter.rb b/lib/shell/filter.rb
index 0ec967e691..27c5534695 100644
--- a/lib/shell/filter.rb
+++ b/lib/shell/filter.rb
@@ -1,9 +1,9 @@
#
# shell/filter.rb -
-# $Release Version: 0.7 $
+# $Release Version: 0.6.0 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb
index c38d8bc987..8929805506 100644
--- a/lib/shell/process-controller.rb
+++ b/lib/shell/process-controller.rb
@@ -1,38 +1,33 @@
#
# shell/process-controller.rb -
-# $Release Version: 0.7 $
+# $Release Version: 0.6.0 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
#
#
-require "forwardable"
-require "thread"
+require "mutex_m"
+require "monitor"
require "sync"
class Shell
class ProcessController
@ProcessControllers = {}
- @ProcessControllersMonitor = Mutex.new
- @ProcessControllersCV = ConditionVariable.new
-
- @BlockOutputMonitor = Mutex.new
- @BlockOutputCV = ConditionVariable.new
+ @ProcessControllers.extend Mutex_m
class<<self
- extend Forwardable
-
- def_delegator("@ProcessControllersMonitor",
- "synchronize", "process_controllers_exclusive")
- def active_process_controllers
- process_controllers_exclusive do
- @ProcessControllers.dup
+ def process_controllers_exclusive
+ begin
+ @ProcessControllers.lock unless Thread.critical
+ yield
+ ensure
+ @ProcessControllers.unlock unless Thread.critical
end
end
@@ -48,7 +43,6 @@ class Shell
if @ProcessControllers[pc]
if (@ProcessControllers[pc] -= 1) == 0
@ProcessControllers.delete(pc)
- @ProcessControllersCV.signal
end
end
end
@@ -61,34 +55,6 @@ class Shell
end
end
end
-
- def block_output_synchronize(&b)
- @BlockOutputMonitor.synchronize &b
- end
-
- def wait_to_finish_all_process_controllers
- process_controllers_exclusive do
- while !@ProcessControllers.empty?
- Shell::notify("Process finishing, but active shell exists",
- "You can use Shell#transact or Shell#check_point for more safe execution.")
- if Shell.debug?
- for pc in @ProcessControllers.keys
- Shell::notify(" Not finished jobs in "+pc.shell.to_s)
- for com in pc.jobs
- com.notify(" Jobs: %id")
- end
- end
- end
- @ProcessControllersCV.wait(@ProcessControllersMonitor)
- end
- end
- end
- end
-
- # for shell-command complete finish at this prosess exit.
- USING_AT_EXIT_WHEN_PROCESS_EXIT = true
- at_exit do
- wait_to_finish_all_process_controllers unless $@
end
def initialize(shell)
@@ -101,8 +67,6 @@ class Shell
@job_condition = ConditionVariable.new
end
- attr_reader :shell
-
def jobs
jobs = []
@jobs_sync.synchronize(:SH) do
@@ -158,19 +122,15 @@ class Shell
@waiting_jobs.delete command
else
command = @waiting_jobs.shift
-# command.notify "job(%id) pre-start.", @shell.debug?
-
return unless command
end
@active_jobs.push command
command.start
-# command.notify "job(%id) post-start.", @shell.debug?
# start all jobs that input from the job
- for job in @waiting_jobs.dup
+ for job in @waiting_jobs
start_job(job) if job.input == command
end
-# command.notify "job(%id) post2-start.", @shell.debug?
end
end
@@ -192,7 +152,6 @@ class Shell
@active_jobs.delete command
ProcessController.inactivate(self)
if @active_jobs.empty?
- command.notify("start_jon in ierminate_jon(%id)", Shell::debug?)
start_job
end
end
@@ -200,7 +159,7 @@ class Shell
# kill a job
def kill_job(sig, command)
- @jobs_sync.synchronize(:EX) do
+ @jobs_sync.synchronize(:SH) do
if @waiting_jobs.delete command
ProcessController.inactivate(self)
return
@@ -224,9 +183,6 @@ class Shell
begin
while !jobs.empty?
@job_condition.wait(@job_monitor)
- for job in jobs
- job.notify("waiting job(%id)", Shell::debug?)
- end
end
ensure
redo unless jobs.empty?
@@ -238,82 +194,66 @@ class Shell
def sfork(command, &block)
pipe_me_in, pipe_peer_out = IO.pipe
pipe_peer_in, pipe_me_out = IO.pipe
+ Thread.critical = true
+ STDOUT.flush
+ ProcessController.each_active_object do |pc|
+ for jobs in pc.active_jobs
+ jobs.flush
+ end
+ end
+
+ pid = fork {
+ Thread.critical = true
- pid = nil
- pid_mutex = Mutex.new
- pid_cv = ConditionVariable.new
-
- Thread.start do
- ProcessController.block_output_synchronize do
- STDOUT.flush
- ProcessController.each_active_object do |pc|
- for jobs in pc.active_jobs
- jobs.flush
- end
- end
-
- pid = fork {
- Thread.list.each do |th|
-# th.kill unless [Thread.main, Thread.current].include?(th)
- th.kill unless Thread.current == th
- end
-
- STDIN.reopen(pipe_peer_in)
- STDOUT.reopen(pipe_peer_out)
+ Thread.list.each do |th|
+ th.kill unless [Thread.main, Thread.current].include?(th)
+ end
- ObjectSpace.each_object(IO) do |io|
- if ![STDIN, STDOUT, STDERR].include?(io)
- io.close unless io.closed?
- end
- end
+ STDIN.reopen(pipe_peer_in)
+ STDOUT.reopen(pipe_peer_out)
- yield
- }
+ ObjectSpace.each_object(IO) do |io|
+ if ![STDIN, STDOUT, STDERR].include?(io)
+ io.close unless io.closed?
+ end
end
- pid_cv.signal
+ yield
+ }
- pipe_peer_in.close
- pipe_peer_out.close
- command.notify "job(%name:##{pid}) start", @shell.debug?
+ pipe_peer_in.close
+ pipe_peer_out.close
+ command.notify "job(%name:##{pid}) start", @shell.debug?
+ Thread.critical = false
+ th = Thread.start {
+ Thread.critical = true
begin
_pid = nil
command.notify("job(%id) start to waiting finish.", @shell.debug?)
+ Thread.critical = false
_pid = Process.waitpid(pid, nil)
rescue Errno::ECHILD
command.notify "warn: job(%id) was done already waitipd."
_pid = true
- # rescue
- # STDERR.puts $!
ensure
- command.notify("Job(%id): Wait to finish when Process finished.", @shell.debug?)
# when the process ends, wait until the command termintes
- if USING_AT_EXIT_WHEN_PROCESS_EXIT or _pid
+ if _pid
else
command.notify("notice: Process finishing...",
"wait for Job[%id] to finish.",
"You can use Shell#transact or Shell#check_point for more safe execution.")
redo
end
-
-# command.notify "job(%id) pre-pre-finish.", @shell.debug?
- @job_monitor.synchronize do
-# command.notify "job(%id) pre-finish.", @shell.debug?
- terminate_job(command)
-# command.notify "job(%id) pre-finish2.", @shell.debug?
- @job_condition.signal
- command.notify "job(%id) finish.", @shell.debug?
+ Thread.exclusive do
+ @job_monitor.synchronize do
+ terminate_job(command)
+ @job_condition.signal
+ command.notify "job(%id) finish.", @shell.debug?
+ end
end
end
- end
-
- pid_mutex.synchronize do
- while !pid
- pid_cv.wait(pid_mutex)
- end
- end
-
+ }
return pid, pipe_me_in, pipe_me_out
end
end
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
index 4bf4f2b86a..f87ba890ea 100644
--- a/lib/shell/system-command.rb
+++ b/lib/shell/system-command.rb
@@ -1,9 +1,9 @@
#
# shell/system-command.rb -
-# $Release Version: 0.7 $
+# $Release Version: 0.6.0 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
@@ -47,15 +47,12 @@ class Shell
end
def start
- notify([@command, *@opts].join(" "))
-
@pid, @pipe_in, @pipe_out = @shell.process_controller.sfork(self) {
Dir.chdir @shell.pwd
- $0 = @command
exec(@command, *@opts)
}
if @input
- start_export
+ start_export
end
start_import
end
@@ -81,12 +78,17 @@ class Shell
end
end
+
def start_import
+# Thread.critical = true
notify "Job(%id) start imp-pipe.", @shell.debug?
rs = @shell.record_separator unless rs
_eop = true
+# Thread.critical = false
th = Thread.start {
+ Thread.critical = true
begin
+ Thread.critical = false
while l = @pipe_in.gets
@input_queue.push l
end
@@ -94,15 +96,19 @@ class Shell
rescue Errno::EPIPE
_eop = false
ensure
- if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
+ if _eop
notify("warn: Process finishing...",
"wait for Job[%id] to finish pipe importing.",
"You can use Shell#transact or Shell#check_point for more safe execution.")
+# Tracer.on
+ Thread.current.run
redo
end
- notify "job(%id}) close imp-pipe.", @shell.debug?
- @input_queue.push :EOF
- @pipe_in.close
+ Thread.exclusive do
+ notify "job(%id}) close imp-pipe.", @shell.debug?
+ @input_queue.push :EOF
+ @pipe_in.close
+ end
end
}
end
@@ -111,24 +117,25 @@ class Shell
notify "job(%id) start exp-pipe.", @shell.debug?
_eop = true
th = Thread.start{
+ Thread.critical = true
begin
- @input.each do |l|
- ProcessController::block_output_synchronize do
- @pipe_out.print l
- end
- end
+ Thread.critical = false
+ @input.each{|l| @pipe_out.print l}
_eop = false
- rescue Errno::EPIPE, Errno::EIO
+ rescue Errno::EPIPE
_eop = false
ensure
- if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
+ if _eop
notify("shell: warn: Process finishing...",
"wait for Job(%id) to finish pipe exporting.",
"You can use Shell#transact or Shell#check_point for more safe execution.")
+# Tracer.on
redo
end
- notify "job(%id) close exp-pipe.", @shell.debug?
- @pipe_out.close
+ Thread.exclusive do
+ notify "job(%id) close exp-pipe.", @shell.debug?
+ @pipe_out.close
+ end
end
}
end
@@ -147,13 +154,14 @@ class Shell
# mes: "job(%id) close pipe-out."
# yorn: Boolean(@shell.debug? or @shell.verbose?)
def notify(*opts, &block)
- @shell.notify(*opts) do |mes|
- yield mes if iterator?
-
- mes.gsub!("%id", "#{@command}:##{@pid}")
- mes.gsub!("%name", "#{@command}")
- mes.gsub!("%pid", "#{@pid}")
- mes
+ Thread.exclusive do
+ @shell.notify(*opts) {|mes|
+ yield mes if iterator?
+
+ mes.gsub!("%id", "#{@command}:##{@pid}")
+ mes.gsub!("%name", "#{@command}")
+ mes.gsub!("%pid", "#{@pid}")
+ }
end
end
end
diff --git a/lib/shell/version.rb b/lib/shell/version.rb
index e40aa03abb..6694c804d8 100644
--- a/lib/shell/version.rb
+++ b/lib/shell/version.rb
@@ -1,9 +1,9 @@
#
# version.rb - shell version definition file
-# $Release Version: 0.7$
+# $Release Version: 0.6.0$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
#
# --
#
@@ -11,6 +11,6 @@
#
class Shell
- @RELEASE_VERSION = "0.7"
- @LAST_UPDATE_DATE = "07/03/20"
+ @RELEASE_VERSION = "0.6.0"
+ @LAST_UPDATE_DATE = "01/03/19"
end
diff --git a/lib/shellwords.rb b/lib/shellwords.rb
index ff1474b4e8..a4ec552a7e 100644
--- a/lib/shellwords.rb
+++ b/lib/shellwords.rb
@@ -13,6 +13,9 @@
# - Wakou Aoyama
# - Akinori MUSHA <knu@iDaemons.org>
#
+# Contact:
+# - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
+#
module Shellwords
#
# Splits a string into an array of tokens in the same way the UNIX
@@ -27,16 +30,32 @@ module Shellwords
# argv #=> ["here", "are", "two words"]
#
def shellsplit(line)
+ line = String.new(line) rescue
+ raise(ArgumentError, "Argument must be a string")
+ line.lstrip!
words = []
- field = ''
- line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do
- |word, sq, dq, esc, garbage, sep|
- raise ArgumentError, "Unmatched double quote: #{line.inspect}" if garbage
- field << (word || sq || (dq || esc).gsub(/\\(?=.)/, ''))
- if sep
- words << field
- field = ''
+ until line.empty?
+ field = ''
+ loop do
+ if line.sub!(/\A"(([^"\\]|\\.)*)"/, '') then
+ snippet = $1.gsub(/\\(.)/, '\1')
+ elsif line =~ /\A"/ then
+ raise ArgumentError, "Unmatched double quote: #{line}"
+ elsif line.sub!(/\A'([^']*)'/, '') then
+ snippet = $1
+ elsif line =~ /\A'/ then
+ raise ArgumentError, "Unmatched single quote: #{line}"
+ elsif line.sub!(/\A\\(.)?/, '') then
+ snippet = $1 || '\\'
+ elsif line.sub!(/\A([^\s\\'"]+)/, '') then
+ snippet = $1
+ else
+ line.lstrip!
+ break
+ end
+ field.concat(snippet)
end
+ words.push(field)
end
words
end
@@ -86,7 +105,7 @@ module Shellwords
module_function :shellescape
class << self
- alias escape shellsplit
+ alias escape shellescape
end
#
diff --git a/lib/singleton.rb b/lib/singleton.rb
index acacfc48c7..592d33c063 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -30,7 +30,7 @@
# * Klass.new and Klass.allocate - as private
#
# Providing (or modifying) the class methods
-# * Klass.inherited(sub_klass) and Klass.clone() -
+# * Klass.inherited(sub_klass) and Klass.clone() -
# to ensure that the Singleton pattern is properly
# inherited and cloned.
#
@@ -39,7 +39,7 @@
# method body is a simple:
#
# def Klass.instance()
-# return @singleton__instance__
+# return @__instance__
# end
#
# * Klass._load(str) - calling Klass.instance()
@@ -60,7 +60,7 @@
# and _dump(depth) hooks allows the (partially) resurrections of
# a previous state of ``the instance''.
-require 'thread'
+
module Singleton
# disable build-in copying methods
@@ -70,87 +70,131 @@ module Singleton
def dup
raise TypeError, "can't dup instance of singleton #{self.class}"
end
-
- private
# default marshalling strategy
- def _dump(depth = -1)
+ def _dump(depth=-1)
''
end
+end
+
+
+class << Singleton
+ # Method body of first instance call.
+ FirstInstanceCall = proc do
+ # @__instance__ takes on one of the following values
+ # * nil - before and after a failed creation
+ # * false - during creation
+ # * sub_class instance - after a successful creation
+ # the form makes up for the lack of returns in progs
+ Thread.critical = true
+ if @__instance__.nil?
+ @__instance__ = false
+ Thread.critical = false
+ begin
+ @__instance__ = new
+ ensure
+ if @__instance__
+ class <<self
+ remove_method :instance
+ def instance; @__instance__ end
+ end
+ else
+ @__instance__ = nil # failed instance creation
+ end
+ end
+ elsif _instantiate?()
+ Thread.critical = false
+ else
+ @__instance__ = false
+ Thread.critical = false
+ begin
+ @__instance__ = new
+ ensure
+ if @__instance__
+ class <<self
+ remove_method :instance
+ def instance; @__instance__ end
+ end
+ else
+ @__instance__ = nil
+ end
+ end
+ end
+ @__instance__
+ end
- module SingletonClassMethods
+ module SingletonClassMethods
# properly clone the Singleton pattern - did you know
- # that duping doesn't copy class methods?
+ # that duping doesn't copy class methods?
def clone
Singleton.__init__(super)
end
+ def _load(str)
+ instance
+ end
+
private
-
- # ensure that the Singleton pattern is properly inherited
+
+ # ensure that the Singleton pattern is properly inherited
def inherited(sub_klass)
super
Singleton.__init__(sub_klass)
end
-
- def _load(str)
- instance
- end
- end
- class << Singleton
- def __init__(klass)
- klass.instance_eval {
- @singleton__instance__ = nil
- @singleton__mutex__ = Mutex.new
- }
- def klass.instance
- return @singleton__instance__ if @singleton__instance__
- @singleton__mutex__.synchronize {
- return @singleton__instance__ if @singleton__instance__
- @singleton__instance__ = new()
- }
- @singleton__instance__
+ # waiting-loop hook
+ def _instantiate?()
+ while false.equal?(@__instance__)
+ Thread.critical = false
+ sleep(0.08) # timeout
+ Thread.critical = true
end
- klass
+ @__instance__
end
-
- private
+ end
- # extending an object with Singleton is a bad idea
- undef_method :extend_object
-
- def append_features(mod)
- # help out people counting on transitive mixins
- unless mod.instance_of?(Class)
- raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}"
- end
- super
+ def __init__(klass)
+ klass.instance_eval { @__instance__ = nil }
+ class << klass
+ define_method(:instance,FirstInstanceCall)
end
-
- def included(klass)
- super
- klass.private_class_method :new, :allocate
- klass.extend SingletonClassMethods
- Singleton.__init__(klass)
+ klass
+ end
+
+ private
+ # extending an object with Singleton is a bad idea
+ undef_method :extend_object
+
+ def append_features(mod)
+ # help out people counting on transitive mixins
+ unless mod.instance_of?(Class)
+ raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}"
end
+ super
+ end
+
+ def included(klass)
+ super
+ klass.private_class_method :new, :allocate
+ klass.extend SingletonClassMethods
+ Singleton.__init__(klass)
end
-
end
+
if __FILE__ == $0
def num_of_instances(klass)
"#{ObjectSpace.each_object(klass){}} #{klass} instance(s)"
-end
+end
# The basic and most important example.
class SomeSingletonClass
include Singleton
end
-puts "There are #{num_of_instances(SomeSingletonClass)}"
+puts "There are #{num_of_instances(SomeSingletonClass)}"
a = SomeSingletonClass.instance
b = SomeSingletonClass.instance # a and b are same object
@@ -173,23 +217,23 @@ class Ups < SomeSingletonClass
puts "initialize called by thread ##{Thread.current[:i]}"
end
end
-
+
class << Ups
def _instantiate?
@enter.push Thread.current[:i]
- while false.equal?(@singleton__instance__)
- @singleton__mutex__.unlock
- sleep 0.08
- @singleton__mutex__.lock
+ while false.equal?(@__instance__)
+ Thread.critical = false
+ sleep 0.08
+ Thread.critical = true
end
@leave.push Thread.current[:i]
- @singleton__instance__
+ @__instance__
end
-
+
def __sleep
sleep(rand(0.08))
end
-
+
def new
begin
__sleep
@@ -201,12 +245,12 @@ class << Ups
end
end
end
-
+
def instantiate_all
@enter = []
@leave = []
- 1.upto(9) {|i|
- Thread.new {
+ 1.upto(9) {|i|
+ Thread.new {
begin
Thread.current[:i] = i
__sleep
@@ -296,7 +340,7 @@ end
class Down < Middle; end
puts "and basic \"Down test\" is #{Down.instance == Down.instance}\n
-Various exceptions"
+Various exceptions"
begin
module AModule
diff --git a/lib/soap/attachment.rb b/lib/soap/attachment.rb
new file mode 100644
index 0000000000..1a59b14018
--- /dev/null
+++ b/lib/soap/attachment.rb
@@ -0,0 +1,107 @@
+# soap/attachment.rb: SOAP4R - SwA implementation.
+# Copyright (C) 2002, 2003 Jamie Herre and NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/baseData'
+require 'soap/mapping'
+
+
+module SOAP
+
+
+class SOAPAttachment < SOAPExternalReference
+ attr_reader :data
+
+ def initialize(value)
+ super()
+ @data = value
+ end
+
+private
+
+ def external_contentid
+ @data.contentid
+ end
+end
+
+
+class Attachment
+ attr_reader :io
+ attr_accessor :contenttype
+
+ def initialize(string_or_readable = nil)
+ @string_or_readable = string_or_readable
+ @contenttype = "application/octet-stream"
+ @contentid = nil
+ end
+
+ def contentid
+ @contentid ||= Attachment.contentid(self)
+ end
+
+ def contentid=(contentid)
+ @contentid = contentid
+ end
+
+ def mime_contentid
+ '<' + contentid + '>'
+ end
+
+ def content
+ if @content == nil and @string_or_readable != nil
+ @content = @string_or_readable.respond_to?(:read) ?
+ @string_or_readable.read : @string_or_readable
+ end
+ @content
+ end
+
+ def to_s
+ content
+ end
+
+ def write(out)
+ out.write(content)
+ end
+
+ def save(filename)
+ File.open(filename, "wb") do |f|
+ write(f)
+ end
+ end
+
+ def self.contentid(obj)
+ # this needs to be fixed
+ [obj.__id__.to_s, Process.pid.to_s].join('.')
+ end
+
+ def self.mime_contentid(obj)
+ '<' + contentid(obj) + '>'
+ end
+end
+
+
+module Mapping
+ class AttachmentFactory < SOAP::Mapping::Factory
+ def obj2soap(soap_class, obj, info, map)
+ soap_obj = soap_class.new(obj)
+ mark_marshalled_obj(obj, soap_obj)
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = node.data
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ end
+ end
+
+ DefaultRegistry.add(::SOAP::Attachment, ::SOAP::SOAPAttachment,
+ AttachmentFactory.new, nil)
+end
+
+
+end
diff --git a/lib/soap/baseData.rb b/lib/soap/baseData.rb
new file mode 100644
index 0000000000..0e8b00d450
--- /dev/null
+++ b/lib/soap/baseData.rb
@@ -0,0 +1,942 @@
+# soap/baseData.rb: SOAP4R - Base type library
+# Copyright (C) 2000, 2001, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/datatypes'
+require 'soap/soap'
+
+
+module SOAP
+
+
+###
+## Mix-in module for SOAP base type classes.
+#
+module SOAPModuleUtils
+ include SOAP
+
+public
+
+ def decode(elename)
+ d = self.new
+ d.elename = elename
+ d
+ end
+end
+
+
+###
+## for SOAP type(base and compound)
+#
+module SOAPType
+ attr_accessor :encodingstyle
+ attr_accessor :elename
+ attr_accessor :id
+ attr_reader :precedents
+ attr_accessor :root
+ attr_accessor :parent
+ attr_accessor :position
+ attr_reader :extraattr
+ attr_accessor :definedtype
+
+ def initialize(*arg)
+ super
+ @encodingstyle = nil
+ @elename = XSD::QName::EMPTY
+ @id = nil
+ @precedents = []
+ @root = false
+ @parent = nil
+ @position = nil
+ @definedtype = nil
+ @extraattr = {}
+ end
+
+ def inspect
+ if self.is_a?(XSD::NSDBase)
+ sprintf("#<%s:0x%x %s %s>", self.class.name, __id__, self.elename, self.type)
+ else
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename)
+ end
+ end
+
+ def rootnode
+ node = self
+ while node = node.parent
+ break if SOAPEnvelope === node
+ end
+ node
+ end
+end
+
+
+###
+## for SOAP base type
+#
+module SOAPBasetype
+ include SOAPType
+ include SOAP
+
+ def initialize(*arg)
+ super
+ end
+end
+
+
+###
+## for SOAP compound type
+#
+module SOAPCompoundtype
+ include SOAPType
+ include SOAP
+
+ def initialize(*arg)
+ super
+ end
+end
+
+
+###
+## Convenience datatypes.
+#
+class SOAPReference < XSD::NSDBase
+ include SOAPBasetype
+ extend SOAPModuleUtils
+
+public
+
+ attr_accessor :refid
+
+ # Override the definition in SOAPBasetype.
+ def initialize(obj = nil)
+ super()
+ @type = XSD::QName::EMPTY
+ @refid = nil
+ @obj = nil
+ __setobj__(obj) if obj
+ end
+
+ def __getobj__
+ @obj
+ end
+
+ def __setobj__(obj)
+ @obj = obj
+ @refid = @obj.id || SOAPReference.create_refid(@obj)
+ @obj.id = @refid unless @obj.id
+ @obj.precedents << self
+ # Copies NSDBase information
+ @obj.type = @type unless @obj.type
+ end
+
+ # Why don't I use delegate.rb?
+ # -> delegate requires target object type at initialize time.
+ # Why don't I use forwardable.rb?
+ # -> forwardable requires a list of forwarding methods.
+ #
+ # ToDo: Maybe I should use forwardable.rb and give it a methods list like
+ # delegate.rb...
+ #
+ def method_missing(msg_id, *params)
+ if @obj
+ @obj.send(msg_id, *params)
+ else
+ nil
+ end
+ end
+
+ def refidstr
+ '#' + @refid
+ end
+
+ def self.create_refid(obj)
+ 'id' + obj.__id__.to_s
+ end
+
+ def self.decode(elename, refidstr)
+ if /\A#(.*)\z/ =~ refidstr
+ refid = $1
+ elsif /\Acid:(.*)\z/ =~ refidstr
+ refid = $1
+ else
+ raise ArgumentError.new("illegal refid #{refidstr}")
+ end
+ d = super(elename)
+ d.refid = refid
+ d
+ end
+end
+
+
+class SOAPExternalReference < XSD::NSDBase
+ include SOAPBasetype
+ extend SOAPModuleUtils
+
+ def initialize
+ super()
+ @type = XSD::QName::EMPTY
+ end
+
+ def referred
+ rootnode.external_content[external_contentid] = self
+ end
+
+ def refidstr
+ 'cid:' + external_contentid
+ end
+
+private
+
+ def external_contentid
+ raise NotImplementedError.new
+ end
+end
+
+
+class SOAPNil < XSD::XSDNil
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+# SOAPRawString is for sending raw string. In contrast to SOAPString,
+# SOAP4R does not do XML encoding and does not convert its CES. The string it
+# holds is embedded to XML instance directly as a 'xsd:string'.
+class SOAPRawString < XSD::XSDString
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+
+###
+## Basic datatypes.
+#
+class SOAPAnySimpleType < XSD::XSDAnySimpleType
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPString < XSD::XSDString
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPBoolean < XSD::XSDBoolean
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPDecimal < XSD::XSDDecimal
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPFloat < XSD::XSDFloat
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPDouble < XSD::XSDDouble
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPDuration < XSD::XSDDuration
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPDateTime < XSD::XSDDateTime
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPTime < XSD::XSDTime
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPDate < XSD::XSDDate
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPGYearMonth < XSD::XSDGYearMonth
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPGYear < XSD::XSDGYear
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPGMonthDay < XSD::XSDGMonthDay
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPGDay < XSD::XSDGDay
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPGMonth < XSD::XSDGMonth
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPHexBinary < XSD::XSDHexBinary
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPBase64 < XSD::XSDBase64Binary
+ include SOAPBasetype
+ extend SOAPModuleUtils
+ Type = QName.new(EncodingNamespace, Base64Literal)
+
+public
+ # Override the definition in SOAPBasetype.
+ def initialize(value = nil)
+ super(value)
+ @type = Type
+ end
+
+ def as_xsd
+ @type = XSD::XSDBase64Binary::Type
+ end
+end
+
+class SOAPAnyURI < XSD::XSDAnyURI
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPQName < XSD::XSDQName
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+
+class SOAPInteger < XSD::XSDInteger
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPNonPositiveInteger < XSD::XSDNonPositiveInteger
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPNegativeInteger < XSD::XSDNegativeInteger
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPLong < XSD::XSDLong
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPInt < XSD::XSDInt
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPShort < XSD::XSDShort
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPByte < XSD::XSDByte
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPNonNegativeInteger < XSD::XSDNonNegativeInteger
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPUnsignedLong < XSD::XSDUnsignedLong
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPUnsignedInt < XSD::XSDUnsignedInt
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPUnsignedShort < XSD::XSDUnsignedShort
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPUnsignedByte < XSD::XSDUnsignedByte
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+class SOAPPositiveInteger < XSD::XSDPositiveInteger
+ include SOAPBasetype
+ extend SOAPModuleUtils
+end
+
+
+###
+## Compound datatypes.
+#
+class SOAPStruct < XSD::NSDBase
+ include SOAPCompoundtype
+ include Enumerable
+
+public
+
+ def initialize(type = nil)
+ super()
+ @type = type || XSD::QName::EMPTY
+ @array = []
+ @data = []
+ end
+
+ def to_s()
+ str = ''
+ self.each do |key, data|
+ str << "#{key}: #{data}\n"
+ end
+ str
+ end
+
+ def add(name, value)
+ add_member(name, value)
+ end
+
+ def [](idx)
+ if idx.is_a?(Range)
+ @data[idx]
+ elsif idx.is_a?(Integer)
+ if (idx > @array.size)
+ raise ArrayIndexOutOfBoundsError.new('In ' << @type.name)
+ end
+ @data[idx]
+ else
+ if @array.include?(idx)
+ @data[@array.index(idx)]
+ else
+ nil
+ end
+ end
+ end
+
+ def []=(idx, data)
+ if @array.include?(idx)
+ data.parent = self if data.respond_to?(:parent=)
+ @data[@array.index(idx)] = data
+ else
+ add(idx, data)
+ end
+ end
+
+ def key?(name)
+ @array.include?(name)
+ end
+
+ def members
+ @array
+ end
+
+ def to_obj
+ hash = {}
+ proptype = {}
+ each do |k, v|
+ value = v.respond_to?(:to_obj) ? v.to_obj : v.to_s
+ case proptype[k]
+ when :single
+ hash[k] = [hash[k], value]
+ proptype[k] = :multi
+ when :multi
+ hash[k] << value
+ else
+ hash[k] = value
+ proptype[k] = :single
+ end
+ end
+ hash
+ end
+
+ def each
+ idx = 0
+ while idx < @array.length
+ yield(@array[idx], @data[idx])
+ idx += 1
+ end
+ end
+
+ def replace
+ members.each do |member|
+ self[member] = yield(self[member])
+ end
+ end
+
+ def self.decode(elename, type)
+ s = SOAPStruct.new(type)
+ s.elename = elename
+ s
+ end
+
+private
+
+ def add_member(name, value = nil)
+ value = SOAPNil.new() if value.nil?
+ @array.push(name)
+ value.elename = value.elename.dup_name(name)
+ @data.push(value)
+ value.parent = self if value.respond_to?(:parent=)
+ value
+ end
+end
+
+
+# SOAPElement is not typed so it is not derived from NSDBase.
+class SOAPElement
+ include Enumerable
+
+ attr_accessor :encodingstyle
+
+ attr_accessor :elename
+ attr_accessor :id
+ attr_reader :precedents
+ attr_accessor :root
+ attr_accessor :parent
+ attr_accessor :position
+ attr_accessor :extraattr
+
+ attr_accessor :qualified
+
+ def initialize(elename, text = nil)
+ if !elename.is_a?(XSD::QName)
+ elename = XSD::QName.new(nil, elename)
+ end
+ @encodingstyle = LiteralNamespace
+ @elename = elename
+ @id = nil
+ @precedents = []
+ @root = false
+ @parent = nil
+ @position = nil
+ @extraattr = {}
+
+ @qualified = nil
+
+ @array = []
+ @data = []
+ @text = text
+ end
+
+ def inspect
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.elename)
+ end
+
+ # Text interface.
+ attr_accessor :text
+ alias data text
+
+ # Element interfaces.
+ def add(value)
+ add_member(value.elename.name, value)
+ end
+
+ def [](idx)
+ if @array.include?(idx)
+ @data[@array.index(idx)]
+ else
+ nil
+ end
+ end
+
+ def []=(idx, data)
+ if @array.include?(idx)
+ data.parent = self if data.respond_to?(:parent=)
+ @data[@array.index(idx)] = data
+ else
+ add(data)
+ end
+ end
+
+ def key?(name)
+ @array.include?(name)
+ end
+
+ def members
+ @array
+ end
+
+ def to_obj
+ if members.empty?
+ @text
+ else
+ hash = {}
+ proptype = {}
+ each do |k, v|
+ value = v.respond_to?(:to_obj) ? v.to_obj : v.to_s
+ case proptype[k]
+ when :single
+ hash[k] = [hash[k], value]
+ proptype[k] = :multi
+ when :multi
+ hash[k] << value
+ else
+ hash[k] = value
+ proptype[k] = :single
+ end
+ end
+ hash
+ end
+ end
+
+ def each
+ idx = 0
+ while idx < @array.length
+ yield(@array[idx], @data[idx])
+ idx += 1
+ end
+ end
+
+ def self.decode(elename)
+ o = SOAPElement.new(elename)
+ o
+ end
+
+ def self.from_obj(obj, namespace = nil)
+ o = SOAPElement.new(nil)
+ case obj
+ when nil
+ o.text = nil
+ when Hash
+ obj.each do |elename, value|
+ if value.is_a?(Array)
+ value.each do |subvalue|
+ child = from_obj(subvalue, namespace)
+ child.elename = to_elename(elename, namespace)
+ o.add(child)
+ end
+ else
+ child = from_obj(value, namespace)
+ child.elename = to_elename(elename, namespace)
+ o.add(child)
+ end
+ end
+ else
+ o.text = obj.to_s
+ end
+ o
+ end
+
+ def self.to_elename(obj, namespace = nil)
+ if obj.is_a?(XSD::QName)
+ obj
+ elsif /\A(.+):([^:]+)\z/ =~ obj.to_s
+ XSD::QName.new($1, $2)
+ else
+ XSD::QName.new(namespace, obj.to_s)
+ end
+ end
+
+private
+
+ def add_member(name, value)
+ add_accessor(name)
+ @array.push(name)
+ @data.push(value)
+ value.parent = self if value.respond_to?(:parent=)
+ value
+ end
+
+ if RUBY_VERSION > "1.7.0"
+ def add_accessor(name)
+ methodname = name
+ if self.respond_to?(methodname)
+ methodname = safe_accessor_name(methodname)
+ end
+ Mapping.define_singleton_method(self, methodname) do
+ @data[@array.index(name)]
+ end
+ Mapping.define_singleton_method(self, methodname + '=') do |value|
+ @data[@array.index(name)] = value
+ end
+ end
+ else
+ def add_accessor(name)
+ methodname = safe_accessor_name(name)
+ instance_eval <<-EOS
+ def #{methodname}
+ @data[@array.index(#{name.dump})]
+ end
+
+ def #{methodname}=(value)
+ @data[@array.index(#{name.dump})] = value
+ end
+ EOS
+ end
+ end
+
+ def safe_accessor_name(name)
+ "var_" << name.gsub(/[^a-zA-Z0-9_]/, '')
+ end
+end
+
+
+class SOAPArray < XSD::NSDBase
+ include SOAPCompoundtype
+ include Enumerable
+
+public
+
+ attr_accessor :sparse
+
+ attr_reader :offset, :rank
+ attr_accessor :size, :size_fixed
+ attr_reader :arytype
+
+ def initialize(type = nil, rank = 1, arytype = nil)
+ super()
+ @type = type || ValueArrayName
+ @rank = rank
+ @data = Array.new
+ @sparse = false
+ @offset = Array.new(rank, 0)
+ @size = Array.new(rank, 0)
+ @size_fixed = false
+ @position = nil
+ @arytype = arytype
+ end
+
+ def offset=(var)
+ @offset = var
+ @sparse = true
+ end
+
+ def add(value)
+ self[*(@offset)] = value
+ end
+
+ def [](*idxary)
+ if idxary.size != @rank
+ raise ArgumentError.new("given #{idxary.size} params does not match rank: #{@rank}")
+ end
+
+ retrieve(idxary)
+ end
+
+ def []=(*idxary)
+ value = idxary.slice!(-1)
+
+ if idxary.size != @rank
+ raise ArgumentError.new("given #{idxary.size} params(#{idxary})" +
+ " does not match rank: #{@rank}")
+ end
+
+ idx = 0
+ while idx < idxary.size
+ if idxary[idx] + 1 > @size[idx]
+ @size[idx] = idxary[idx] + 1
+ end
+ idx += 1
+ end
+
+ data = retrieve(idxary[0, idxary.size - 1])
+ data[idxary.last] = value
+
+ if value.is_a?(SOAPType)
+ value.elename = ITEM_NAME
+ # Sync type
+ unless @type.name
+ @type = XSD::QName.new(value.type.namespace,
+ SOAPArray.create_arytype(value.type.name, @rank))
+ end
+ value.type ||= @type
+ end
+
+ @offset = idxary
+ value.parent = self if value.respond_to?(:parent=)
+ offsetnext
+ end
+
+ def each
+ @data.each do |data|
+ yield(data)
+ end
+ end
+
+ def to_a
+ @data.dup
+ end
+
+ def replace
+ @data = deep_map(@data) do |ele|
+ yield(ele)
+ end
+ end
+
+ def deep_map(ary, &block)
+ ary.collect do |ele|
+ if ele.is_a?(Array)
+ deep_map(ele, &block)
+ else
+ new_obj = block.call(ele)
+ new_obj.elename = ITEM_NAME
+ new_obj
+ end
+ end
+ end
+
+ def include?(var)
+ traverse_data(@data) do |v, *rank|
+ if v.is_a?(SOAPBasetype) && v.data == var
+ return true
+ end
+ end
+ false
+ end
+
+ def traverse
+ traverse_data(@data) do |v, *rank|
+ unless @sparse
+ yield(v)
+ else
+ yield(v, *rank) if v && !v.is_a?(SOAPNil)
+ end
+ end
+ end
+
+ def soap2array(ary)
+ traverse_data(@data) do |v, *position|
+ iteary = ary
+ rank = 1
+ while rank < position.size
+ idx = position[rank - 1]
+ if iteary[idx].nil?
+ iteary = iteary[idx] = Array.new
+ else
+ iteary = iteary[idx]
+ end
+ rank += 1
+ end
+ if block_given?
+ iteary[position.last] = yield(v)
+ else
+ iteary[position.last] = v
+ end
+ end
+ end
+
+ def position
+ @position
+ end
+
+private
+
+ ITEM_NAME = XSD::QName.new(nil, 'item')
+
+ def retrieve(idxary)
+ data = @data
+ rank = 1
+ while rank <= idxary.size
+ idx = idxary[rank - 1]
+ if data[idx].nil?
+ data = data[idx] = Array.new
+ else
+ data = data[idx]
+ end
+ rank += 1
+ end
+ data
+ end
+
+ def traverse_data(data, rank = 1)
+ idx = 0
+ while idx < ranksize(rank)
+ if rank < @rank
+ traverse_data(data[idx], rank + 1) do |*v|
+ v[1, 0] = idx
+ yield(*v)
+ end
+ else
+ yield(data[idx], idx)
+ end
+ idx += 1
+ end
+ end
+
+ def ranksize(rank)
+ @size[rank - 1]
+ end
+
+ def offsetnext
+ move = false
+ idx = @offset.size - 1
+ while !move && idx >= 0
+ @offset[idx] += 1
+ if @size_fixed
+ if @offset[idx] < @size[idx]
+ move = true
+ else
+ @offset[idx] = 0
+ idx -= 1
+ end
+ else
+ move = true
+ end
+ end
+ end
+
+ # Module function
+
+public
+
+ def self.decode(elename, type, arytype)
+ typestr, nofary = parse_type(arytype.name)
+ rank = nofary.count(',') + 1
+ plain_arytype = XSD::QName.new(arytype.namespace, typestr)
+ o = SOAPArray.new(type, rank, plain_arytype)
+ size = []
+ nofary.split(',').each do |s|
+ if s.empty?
+ size.clear
+ break
+ else
+ size << s.to_i
+ end
+ end
+ unless size.empty?
+ o.size = size
+ o.size_fixed = true
+ end
+ o.elename = elename
+ o
+ end
+
+private
+
+ def self.create_arytype(typename, rank)
+ "#{typename}[" << ',' * (rank - 1) << ']'
+ end
+
+ TypeParseRegexp = Regexp.new('^(.+)\[([\d,]*)\]$')
+
+ def self.parse_type(string)
+ TypeParseRegexp =~ string
+ return $1, $2
+ end
+end
+
+
+require 'soap/mapping/typeMap'
+
+
+end
diff --git a/lib/soap/element.rb b/lib/soap/element.rb
new file mode 100644
index 0000000000..cc58b5d341
--- /dev/null
+++ b/lib/soap/element.rb
@@ -0,0 +1,258 @@
+# SOAP4R - SOAP elements library
+# Copyright (C) 2000, 2001, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'soap/baseData'
+
+
+module SOAP
+
+
+###
+## SOAP elements
+#
+module SOAPEnvelopeElement; end
+
+class SOAPFault < SOAPStruct
+ include SOAPEnvelopeElement
+ include SOAPCompoundtype
+
+public
+
+ def faultcode
+ self['faultcode']
+ end
+
+ def faultstring
+ self['faultstring']
+ end
+
+ def faultactor
+ self['faultactor']
+ end
+
+ def detail
+ self['detail']
+ end
+
+ def faultcode=(rhs)
+ self['faultcode'] = rhs
+ end
+
+ def faultstring=(rhs)
+ self['faultstring'] = rhs
+ end
+
+ def faultactor=(rhs)
+ self['faultactor'] = rhs
+ end
+
+ def detail=(rhs)
+ self['detail'] = rhs
+ end
+
+ def initialize(faultcode = nil, faultstring = nil, faultactor = nil, detail = nil)
+ super(EleFaultName)
+ @elename = EleFaultName
+ @encodingstyle = EncodingNamespace
+
+ if faultcode
+ self.faultcode = faultcode
+ self.faultstring = faultstring
+ self.faultactor = faultactor
+ self.detail = detail
+ self.faultcode.elename = EleFaultCodeName if self.faultcode
+ self.faultstring.elename = EleFaultStringName if self.faultstring
+ self.faultactor.elename = EleFaultActorName if self.faultactor
+ self.detail.elename = EleFaultDetailName if self.detail
+ end
+ faultcode.parent = self if faultcode
+ faultstring.parent = self if faultstring
+ faultactor.parent = self if faultactor
+ detail.parent = self if detail
+ end
+
+ def encode(generator, ns, attrs = {})
+ SOAPGenerator.assign_ns(attrs, ns, EnvelopeNamespace)
+ SOAPGenerator.assign_ns(attrs, ns, EncodingNamespace)
+ attrs[ns.name(AttrEncodingStyleName)] = EncodingNamespace
+ name = ns.name(@elename)
+ generator.encode_tag(name, attrs)
+ yield(self.faultcode)
+ yield(self.faultstring)
+ yield(self.faultactor)
+ yield(self.detail) if self.detail
+ generator.encode_tag_end(name, true)
+ end
+end
+
+
+class SOAPBody < SOAPStruct
+ include SOAPEnvelopeElement
+
+ def initialize(data = nil, is_fault = false)
+ super(nil)
+ @elename = EleBodyName
+ @encodingstyle = nil
+ if data
+ if data.respond_to?(:elename)
+ add(data.elename.name, data)
+ else
+ data.to_a.each do |datum|
+ add(datum.elename.name, datum)
+ end
+ end
+ end
+ @is_fault = is_fault
+ end
+
+ def encode(generator, ns, attrs = {})
+ name = ns.name(@elename)
+ generator.encode_tag(name, attrs)
+ if @is_fault
+ yield(@data)
+ else
+ @data.each do |data|
+ yield(data)
+ end
+ end
+ generator.encode_tag_end(name, true)
+ end
+
+ def root_node
+ @data.each do |node|
+ if node.root == 1
+ return node
+ end
+ end
+ # No specified root...
+ @data.each do |node|
+ if node.root != 0
+ return node
+ end
+ end
+
+ raise Parser::FormatDecodeError.new('no root element')
+ end
+end
+
+
+class SOAPHeaderItem < XSD::NSDBase
+ include SOAPEnvelopeElement
+ include SOAPCompoundtype
+
+public
+
+ attr_accessor :element
+ attr_accessor :mustunderstand
+ attr_accessor :encodingstyle
+
+ def initialize(element, mustunderstand = true, encodingstyle = nil)
+ super()
+ @type = nil
+ @element = element
+ @mustunderstand = mustunderstand
+ @encodingstyle = encodingstyle
+ element.parent = self if element
+ end
+
+ def encode(generator, ns, attrs = {})
+ attrs.each do |key, value|
+ @element.extraattr[key] = value
+ end
+ @element.extraattr[ns.name(AttrMustUnderstandName)] =
+ (@mustunderstand ? '1' : '0')
+ if @encodingstyle
+ @element.extraattr[ns.name(AttrEncodingStyleName)] = @encodingstyle
+ end
+ @element.encodingstyle = @encodingstyle if !@element.encodingstyle
+ yield(@element)
+ end
+end
+
+
+class SOAPHeader < SOAPStruct
+ include SOAPEnvelopeElement
+
+ def initialize
+ super(nil)
+ @elename = EleHeaderName
+ @encodingstyle = nil
+ end
+
+ def encode(generator, ns, attrs = {})
+ name = ns.name(@elename)
+ generator.encode_tag(name, attrs)
+ @data.each do |data|
+ yield(data)
+ end
+ generator.encode_tag_end(name, true)
+ end
+
+ def add(name, value)
+ mu = (value.extraattr[AttrMustUnderstandName] == '1')
+ encstyle = value.extraattr[AttrEncodingStyleName]
+ item = SOAPHeaderItem.new(value, mu, encstyle)
+ super(name, item)
+ end
+
+ def length
+ @data.length
+ end
+ alias size length
+end
+
+
+class SOAPEnvelope < XSD::NSDBase
+ include SOAPEnvelopeElement
+ include SOAPCompoundtype
+
+ attr_reader :header
+ attr_reader :body
+ attr_reader :external_content
+
+ def initialize(header = nil, body = nil)
+ super()
+ @type = nil
+ @elename = EleEnvelopeName
+ @encodingstyle = nil
+ @header = header
+ @body = body
+ @external_content = {}
+ header.parent = self if header
+ body.parent = self if body
+ end
+
+ def header=(header)
+ header.parent = self
+ @header = header
+ end
+
+ def body=(body)
+ body.parent = self
+ @body = body
+ end
+
+ def encode(generator, ns, attrs = {})
+ SOAPGenerator.assign_ns(attrs, ns, elename.namespace, SOAPNamespaceTag)
+ name = ns.name(@elename)
+ generator.encode_tag(name, attrs)
+
+ yield(@header) if @header and @header.length > 0
+ yield(@body)
+
+ generator.encode_tag_end(name, true)
+ end
+
+ def to_ary
+ [header, body]
+ end
+end
+
+
+end
diff --git a/lib/soap/encodingstyle/aspDotNetHandler.rb b/lib/soap/encodingstyle/aspDotNetHandler.rb
new file mode 100644
index 0000000000..fd7e0fa217
--- /dev/null
+++ b/lib/soap/encodingstyle/aspDotNetHandler.rb
@@ -0,0 +1,213 @@
+# SOAP4R - ASP.NET EncodingStyle handler library
+# Copyright (C) 2001, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/encodingstyle/handler'
+
+
+module SOAP
+module EncodingStyle
+
+
+class ASPDotNetHandler < Handler
+ Namespace = 'http://tempuri.org/ASP.NET'
+ add_handler
+
+ def initialize(charset = nil)
+ super(charset)
+ @textbuf = ''
+ @decode_typemap = nil
+ end
+
+
+ ###
+ ## encode interface.
+ #
+ def encode_data(generator, ns, data, parent)
+ attrs = {}
+ # ASPDotNetHandler is intended to be used for accessing an ASP.NET doc/lit
+ # service as an rpc/encoded service. in the situation, local elements
+ # should be qualified. propagate parent's namespace to children.
+ if data.elename.namespace.nil?
+ data.elename.namespace = parent.elename.namespace
+ end
+ name = generator.encode_name(ns, data, attrs)
+ case data
+ when SOAPRawString
+ generator.encode_tag(name, attrs)
+ generator.encode_rawstring(data.to_s)
+ when XSD::XSDString
+ generator.encode_tag(name, attrs)
+ generator.encode_string(@charset ?
+ XSD::Charset.encoding_to_xml(data.to_s, @charset) : data.to_s)
+ when XSD::XSDAnySimpleType
+ generator.encode_tag(name, attrs)
+ generator.encode_string(data.to_s)
+ when SOAPStruct
+ generator.encode_tag(name, attrs)
+ data.each do |key, value|
+ generator.encode_child(ns, value, data)
+ end
+ when SOAPArray
+ generator.encode_tag(name, attrs)
+ data.traverse do |child, *rank|
+ data.position = nil
+ generator.encode_child(ns, child, data)
+ end
+ else
+ raise EncodingStyleError.new(
+ "unknown object:#{data} in this encodingStyle")
+ end
+ end
+
+ def encode_data_end(generator, ns, data, parent)
+ name = generator.encode_name_end(ns, data)
+ cr = data.is_a?(SOAPCompoundtype)
+ generator.encode_tag_end(name, cr)
+ end
+
+
+ ###
+ ## decode interface.
+ #
+ class SOAPTemporalObject
+ attr_accessor :parent
+
+ def initialize
+ @parent = nil
+ end
+ end
+
+ class SOAPUnknown < SOAPTemporalObject
+ def initialize(handler, elename)
+ super()
+ @handler = handler
+ @elename = elename
+ end
+
+ def as_struct
+ o = SOAPStruct.decode(@elename, XSD::AnyTypeName)
+ o.parent = @parent
+ o.type.name = @name
+ @handler.decode_parent(@parent, o)
+ o
+ end
+
+ def as_string
+ o = SOAPString.decode(@elename)
+ o.parent = @parent
+ @handler.decode_parent(@parent, o)
+ o
+ end
+
+ def as_nil
+ o = SOAPNil.decode(@elename)
+ o.parent = @parent
+ @handler.decode_parent(@parent, o)
+ o
+ end
+ end
+
+ def decode_tag(ns, elename, attrs, parent)
+ @textbuf = ''
+ o = SOAPUnknown.new(self, elename)
+ o.parent = parent
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ o = node.node
+ if o.is_a?(SOAPUnknown)
+ newnode = o.as_string
+# if /\A\s*\z/ =~ @textbuf
+# o.as_struct
+# else
+# o.as_string
+# end
+ node.replace_node(newnode)
+ o = node.node
+ end
+
+ decode_textbuf(o)
+ @textbuf = ''
+ end
+
+ def decode_text(ns, text)
+ # @textbuf is set at decode_tag_end.
+ @textbuf << text
+ end
+
+ def decode_prologue
+ end
+
+ def decode_epilogue
+ end
+
+ def decode_parent(parent, node)
+ case parent.node
+ when SOAPUnknown
+ newparent = parent.node.as_struct
+ node.parent = newparent
+ parent.replace_node(newparent)
+ decode_parent(parent, node)
+
+ when SOAPStruct
+ data = parent.node[node.elename.name]
+ case data
+ when nil
+ parent.node.add(node.elename.name, node)
+ when SOAPArray
+ name, type_ns = node.elename.name, node.type.namespace
+ data.add(node)
+ node.elename, node.type.namespace = name, type_ns
+ else
+ parent.node[node.elename.name] = SOAPArray.new
+ name, type_ns = data.elename.name, data.type.namespace
+ parent.node[node.elename.name].add(data)
+ data.elename.name, data.type.namespace = name, type_ns
+ name, type_ns = node.elename.name, node.type.namespace
+ parent.node[node.elename.name].add(node)
+ node.elename.name, node.type.namespace = name, type_ns
+ end
+
+ when SOAPArray
+ if node.position
+ parent.node[*(decode_arypos(node.position))] = node
+ parent.node.sparse = true
+ else
+ parent.node.add(node)
+ end
+
+ when SOAPBasetype
+ raise EncodingStyleError.new("SOAP base type must not have a child")
+
+ else
+ # SOAPUnknown does not have parent.
+ # raise EncodingStyleError.new("illegal parent: #{parent}")
+ end
+ end
+
+private
+
+ def decode_textbuf(node)
+ if node.is_a?(XSD::XSDString)
+ if @charset
+ node.set(XSD::Charset.encoding_from_xml(@textbuf, @charset))
+ else
+ node.set(@textbuf)
+ end
+ else
+ # Nothing to do...
+ end
+ end
+end
+
+ASPDotNetHandler.new
+
+
+end
+end
diff --git a/lib/soap/encodingstyle/handler.rb b/lib/soap/encodingstyle/handler.rb
new file mode 100644
index 0000000000..c015417435
--- /dev/null
+++ b/lib/soap/encodingstyle/handler.rb
@@ -0,0 +1,100 @@
+# SOAP4R - EncodingStyle handler library
+# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/soap'
+require 'soap/baseData'
+require 'soap/element'
+
+
+module SOAP
+module EncodingStyle
+
+
+class Handler
+ @@handlers = {}
+
+ class EncodingStyleError < Error; end
+
+ class << self
+ def uri
+ self::Namespace
+ end
+
+ def handler(uri)
+ @@handlers[uri]
+ end
+
+ def each
+ @@handlers.each do |key, value|
+ yield(value)
+ end
+ end
+
+ private
+
+ def add_handler
+ @@handlers[self.uri] = self
+ end
+ end
+
+ attr_reader :charset
+ attr_accessor :generate_explicit_type
+ def decode_typemap=(definedtypes)
+ @decode_typemap = definedtypes
+ end
+
+ def initialize(charset)
+ @charset = charset
+ @generate_explicit_type = true
+ @decode_typemap = nil
+ end
+
+ ###
+ ## encode interface.
+ #
+ # Returns a XML instance as a string.
+ def encode_data(generator, ns, data, parent)
+ raise NotImplementError
+ end
+
+ def encode_data_end(generator, ns, data, parent)
+ raise NotImplementError
+ end
+
+ def encode_prologue
+ end
+
+ def encode_epilogue
+ end
+
+ ###
+ ## decode interface.
+ #
+ # Returns SOAP/OM data.
+ def decode_tag(ns, name, attrs, parent)
+ raise NotImplementError.new('Method decode_tag must be defined in derived class.')
+ end
+
+ def decode_tag_end(ns, name)
+ raise NotImplementError.new('Method decode_tag_end must be defined in derived class.')
+ end
+
+ def decode_text(ns, text)
+ raise NotImplementError.new('Method decode_text must be defined in derived class.')
+ end
+
+ def decode_prologue
+ end
+
+ def decode_epilogue
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/encodingstyle/literalHandler.rb b/lib/soap/encodingstyle/literalHandler.rb
new file mode 100644
index 0000000000..59c7205366
--- /dev/null
+++ b/lib/soap/encodingstyle/literalHandler.rb
@@ -0,0 +1,226 @@
+# SOAP4R - XML Literal EncodingStyle handler library
+# Copyright (C) 2001, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/encodingstyle/handler'
+
+
+module SOAP
+module EncodingStyle
+
+
+class LiteralHandler < Handler
+ Namespace = SOAP::LiteralNamespace
+ add_handler
+
+ def initialize(charset = nil)
+ super(charset)
+ @textbuf = ''
+ end
+
+
+ ###
+ ## encode interface.
+ #
+ def encode_data(generator, ns, data, parent)
+ attrs = {}
+ name = generator.encode_name(ns, data, attrs)
+ data.extraattr.each do |k, v|
+ # ToDo: check generator.attributeformdefault here
+ if k.is_a?(XSD::QName)
+ if k.namespace
+ SOAPGenerator.assign_ns(attrs, ns, k.namespace)
+ k = ns.name(k)
+ else
+ k = k.name
+ end
+ end
+ attrs[k] = v
+ end
+ case data
+ when SOAPRawString
+ generator.encode_tag(name, attrs)
+ generator.encode_rawstring(data.to_s)
+ when XSD::XSDString
+ generator.encode_tag(name, attrs)
+ str = data.to_s
+ str = XSD::Charset.encoding_to_xml(str, @charset) if @charset
+ generator.encode_string(str)
+ when XSD::XSDAnySimpleType
+ generator.encode_tag(name, attrs)
+ generator.encode_string(data.to_s)
+ when SOAPStruct
+ generator.encode_tag(name, attrs)
+ data.each do |key, value|
+ generator.encode_child(ns, value, data)
+ end
+ when SOAPArray
+ generator.encode_tag(name, attrs)
+ data.traverse do |child, *rank|
+ data.position = nil
+ generator.encode_child(ns, child, data)
+ end
+ when SOAPElement
+ # passes 2 times for simplifying namespace definition
+ data.each do |key, value|
+ if value.elename.namespace
+ SOAPGenerator.assign_ns(attrs, ns, value.elename.namespace)
+ end
+ end
+ generator.encode_tag(name, attrs)
+ generator.encode_rawstring(data.text) if data.text
+ data.each do |key, value|
+ generator.encode_child(ns, value, data)
+ end
+ else
+ raise EncodingStyleError.new(
+ "unknown object:#{data} in this encodingStyle")
+ end
+ end
+
+ def encode_data_end(generator, ns, data, parent)
+ name = generator.encode_name_end(ns, data)
+ cr = (data.is_a?(SOAPCompoundtype) or
+ (data.is_a?(SOAPElement) and !data.text))
+ generator.encode_tag_end(name, cr)
+ end
+
+
+ ###
+ ## decode interface.
+ #
+ class SOAPTemporalObject
+ attr_accessor :parent
+
+ def initialize
+ @parent = nil
+ end
+ end
+
+ class SOAPUnknown < SOAPTemporalObject
+ def initialize(handler, elename, extraattr)
+ super()
+ @handler = handler
+ @elename = elename
+ @extraattr = extraattr
+ end
+
+ def as_element
+ o = SOAPElement.decode(@elename)
+ o.parent = @parent
+ o.extraattr.update(@extraattr)
+ @handler.decode_parent(@parent, o)
+ o
+ end
+
+ def as_string
+ o = SOAPString.decode(@elename)
+ o.parent = @parent
+ o.extraattr.update(@extraattr)
+ @handler.decode_parent(@parent, o)
+ o
+ end
+
+ def as_nil
+ o = SOAPNil.decode(@elename)
+ o.parent = @parent
+ o.extraattr.update(@extraattr)
+ @handler.decode_parent(@parent, o)
+ o
+ end
+ end
+
+ def decode_tag(ns, elename, attrs, parent)
+ @textbuf = ''
+ o = SOAPUnknown.new(self, elename, decode_attrs(ns, attrs))
+ o.parent = parent
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ o = node.node
+ if o.is_a?(SOAPUnknown)
+ newnode = if /\A\s*\z/ =~ @textbuf
+ o.as_element
+ else
+ o.as_string
+ end
+ node.replace_node(newnode)
+ o = node.node
+ end
+
+ decode_textbuf(o)
+ @textbuf = ''
+ end
+
+ def decode_text(ns, text)
+ # @textbuf is set at decode_tag_end.
+ @textbuf << text
+ end
+
+ def decode_attrs(ns, attrs)
+ extraattr = {}
+ attrs.each do |key, value|
+ qname = ns.parse_local(key)
+ extraattr[qname] = value
+ end
+ extraattr
+ end
+
+ def decode_prologue
+ end
+
+ def decode_epilogue
+ end
+
+ def decode_parent(parent, node)
+ return unless parent.node
+ case parent.node
+ when SOAPUnknown
+ newparent = parent.node.as_element
+ node.parent = newparent
+ parent.replace_node(newparent)
+ decode_parent(parent, node)
+ when SOAPElement
+ parent.node.add(node)
+ node.parent = parent.node
+ when SOAPStruct
+ parent.node.add(node.elename.name, node)
+ node.parent = parent.node
+ when SOAPArray
+ if node.position
+ parent.node[*(decode_arypos(node.position))] = node
+ parent.node.sparse = true
+ else
+ parent.node.add(node)
+ end
+ node.parent = parent.node
+ else
+ raise EncodingStyleError.new("illegal parent: #{parent.node}")
+ end
+ end
+
+private
+
+ def decode_textbuf(node)
+ if node.is_a?(XSD::XSDString)
+ if @charset
+ node.set(XSD::Charset.encoding_from_xml(@textbuf, @charset))
+ else
+ node.set(@textbuf)
+ end
+ else
+ # Nothing to do...
+ end
+ end
+end
+
+LiteralHandler.new
+
+
+end
+end
diff --git a/lib/soap/encodingstyle/soapHandler.rb b/lib/soap/encodingstyle/soapHandler.rb
new file mode 100644
index 0000000000..a522392625
--- /dev/null
+++ b/lib/soap/encodingstyle/soapHandler.rb
@@ -0,0 +1,582 @@
+# SOAP4R - SOAP EncodingStyle handler library
+# Copyright (C) 2001, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/encodingstyle/handler'
+
+
+module SOAP
+module EncodingStyle
+
+
+class SOAPHandler < Handler
+ Namespace = SOAP::EncodingNamespace
+ add_handler
+
+ def initialize(charset = nil)
+ super(charset)
+ @refpool = []
+ @idpool = []
+ @textbuf = ''
+ @is_first_top_ele = true
+ end
+
+
+ ###
+ ## encode interface.
+ #
+ def encode_data(generator, ns, data, parent)
+ attrs = encode_attrs(generator, ns, data, parent)
+ if parent && parent.is_a?(SOAPArray) && parent.position
+ attrs[ns.name(AttrPositionName)] = "[#{parent.position.join(',')}]"
+ end
+ name = generator.encode_name(ns, data, attrs)
+ case data
+ when SOAPReference
+ attrs['href'] = data.refidstr
+ generator.encode_tag(name, attrs)
+ when SOAPExternalReference
+ data.referred
+ attrs['href'] = data.refidstr
+ generator.encode_tag(name, attrs)
+ when SOAPRawString
+ generator.encode_tag(name, attrs)
+ generator.encode_rawstring(data.to_s)
+ when XSD::XSDString
+ generator.encode_tag(name, attrs)
+ generator.encode_string(@charset ?
+ XSD::Charset.encoding_to_xml(data.to_s, @charset) : data.to_s)
+ when XSD::XSDAnySimpleType
+ generator.encode_tag(name, attrs)
+ generator.encode_string(data.to_s)
+ when SOAPStruct
+ generator.encode_tag(name, attrs)
+ data.each do |key, value|
+ generator.encode_child(ns, value, data)
+ end
+ when SOAPArray
+ generator.encode_tag(name, attrs)
+ data.traverse do |child, *rank|
+ data.position = data.sparse ? rank : nil
+ generator.encode_child(ns, child, data)
+ end
+ else
+ raise EncodingStyleError.new(
+ "unknown object:#{data} in this encodingStyle")
+ end
+ end
+
+ def encode_data_end(generator, ns, data, parent)
+ name = generator.encode_name_end(ns, data)
+ cr = data.is_a?(SOAPCompoundtype)
+ generator.encode_tag_end(name, cr)
+ end
+
+
+ ###
+ ## decode interface.
+ #
+ class SOAPTemporalObject
+ attr_accessor :parent
+ attr_accessor :position
+ attr_accessor :id
+ attr_accessor :root
+
+ def initialize
+ @parent = nil
+ @position = nil
+ @id = nil
+ @root = nil
+ end
+ end
+
+ class SOAPUnknown < SOAPTemporalObject
+ attr_reader :type
+ attr_accessor :definedtype
+ attr_reader :extraattr
+
+ def initialize(handler, elename, type, extraattr)
+ super()
+ @handler = handler
+ @elename = elename
+ @type = type
+ @extraattr = extraattr
+ @definedtype = nil
+ end
+
+ def as_struct
+ o = SOAPStruct.decode(@elename, @type)
+ o.id = @id
+ o.root = @root
+ o.parent = @parent
+ o.position = @position
+ o.extraattr.update(@extraattr)
+ @handler.decode_parent(@parent, o)
+ o
+ end
+
+ def as_string
+ o = SOAPString.decode(@elename)
+ o.id = @id
+ o.root = @root
+ o.parent = @parent
+ o.position = @position
+ o.extraattr.update(@extraattr)
+ @handler.decode_parent(@parent, o)
+ o
+ end
+
+ def as_nil
+ o = SOAPNil.decode(@elename)
+ o.id = @id
+ o.root = @root
+ o.parent = @parent
+ o.position = @position
+ o.extraattr.update(@extraattr)
+ @handler.decode_parent(@parent, o)
+ o
+ end
+ end
+
+ def decode_tag(ns, elename, attrs, parent)
+ @textbuf = ''
+ is_nil, type, arytype, root, offset, position, href, id, extraattr =
+ decode_attrs(ns, attrs)
+ o = nil
+ if is_nil
+ o = SOAPNil.decode(elename)
+ elsif href
+ o = SOAPReference.decode(elename, href)
+ @refpool << o
+ elsif @decode_typemap
+ o = decode_tag_by_wsdl(ns, elename, type, parent.node, arytype, extraattr)
+ else
+ o = decode_tag_by_type(ns, elename, type, parent.node, arytype, extraattr)
+ end
+
+ if o.is_a?(SOAPArray)
+ if offset
+ o.offset = decode_arypos(offset)
+ o.sparse = true
+ else
+ o.sparse = false
+ end
+ end
+
+ o.parent = parent
+ o.id = id
+ o.root = root
+ o.position = position
+
+ unless o.is_a?(SOAPTemporalObject)
+ @idpool << o if o.id
+ decode_parent(parent, o)
+ end
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ o = node.node
+ if o.is_a?(SOAPUnknown)
+ newnode = if /\A\s*\z/ =~ @textbuf
+ o.as_struct
+ else
+ o.as_string
+ end
+ if newnode.id
+ @idpool << newnode
+ end
+ node.replace_node(newnode)
+ o = node.node
+ end
+ decode_textbuf(o)
+ # unlink definedtype
+ o.definedtype = nil
+ end
+
+ def decode_text(ns, text)
+ @textbuf << text
+ end
+
+ def decode_prologue
+ @refpool.clear
+ @idpool.clear
+ @is_first_top_ele = true
+ end
+
+ def decode_epilogue
+ decode_resolve_id
+ end
+
+ def decode_parent(parent, node)
+ return unless parent.node
+ case parent.node
+ when SOAPUnknown
+ newparent = parent.node.as_struct
+ node.parent = newparent
+ if newparent.id
+ @idpool << newparent
+ end
+ parent.replace_node(newparent)
+ decode_parent(parent, node)
+ when SOAPStruct
+ parent.node.add(node.elename.name, node)
+ node.parent = parent.node
+ when SOAPArray
+ if node.position
+ parent.node[*(decode_arypos(node.position))] = node
+ parent.node.sparse = true
+ else
+ parent.node.add(node)
+ end
+ node.parent = parent.node
+ else
+ raise EncodingStyleError.new("illegal parent: #{parent.node}")
+ end
+ end
+
+private
+
+ def content_ranksize(typename)
+ typename.scan(/\[[\d,]*\]$/)[0]
+ end
+
+ def content_typename(typename)
+ typename.sub(/\[,*\]$/, '')
+ end
+
+ def create_arytype(ns, data)
+ XSD::QName.new(data.arytype.namespace,
+ content_typename(data.arytype.name) + "[#{data.size.join(',')}]")
+ end
+
+ def encode_attrs(generator, ns, data, parent)
+ attrs = {}
+ return attrs if data.is_a?(SOAPReference)
+
+ if !parent || parent.encodingstyle != EncodingNamespace
+ if @generate_explicit_type
+ SOAPGenerator.assign_ns(attrs, ns, EnvelopeNamespace)
+ attrs[ns.name(AttrEncodingStyleName)] = EncodingNamespace
+ end
+ data.encodingstyle = EncodingNamespace
+ end
+
+ if data.is_a?(SOAPNil)
+ attrs[ns.name(XSD::AttrNilName)] = XSD::NilValue
+ elsif @generate_explicit_type
+ if data.type.namespace
+ SOAPGenerator.assign_ns(attrs, ns, data.type.namespace)
+ end
+ if data.is_a?(SOAPArray)
+ if data.arytype.namespace
+ SOAPGenerator.assign_ns(attrs, ns, data.arytype.namespace)
+ end
+ SOAPGenerator.assign_ns(attrs, ns, EncodingNamespace)
+ attrs[ns.name(AttrArrayTypeName)] = ns.name(create_arytype(ns, data))
+ if data.type.name
+ attrs[ns.name(XSD::AttrTypeName)] = ns.name(data.type)
+ end
+ elsif parent && parent.is_a?(SOAPArray) && (parent.arytype == data.type)
+ # No need to add.
+ elsif !data.type.namespace
+ # No need to add.
+ else
+ attrs[ns.name(XSD::AttrTypeName)] = ns.name(data.type)
+ end
+ end
+
+ data.extraattr.each do |key, value|
+ SOAPGenerator.assign_ns(attrs, ns, key.namespace)
+ attrs[ns.name(key)] = encode_attr_value(generator, ns, key, value)
+ end
+ if data.id
+ attrs['id'] = data.id
+ end
+ attrs
+ end
+
+ def encode_attr_value(generator, ns, qname, value)
+ if value.is_a?(SOAPType)
+ ref = SOAPReference.new(value)
+ generator.add_reftarget(qname.name, value)
+ ref.refidstr
+ else
+ value.to_s
+ end
+ end
+
+ def decode_tag_by_wsdl(ns, elename, typestr, parent, arytypestr, extraattr)
+ o = nil
+ if parent.class == SOAPBody
+ # root element: should branch by root attribute?
+ if @is_first_top_ele
+ # Unqualified name is allowed here.
+ @is_first_top_ele = false
+ type = @decode_typemap[elename] ||
+ @decode_typemap.find_name(elename.name)
+ if type
+ o = SOAPStruct.new(elename)
+ o.definedtype = type
+ return o
+ end
+ end
+ # multi-ref element.
+ if typestr
+ typename = ns.parse(typestr)
+ typedef = @decode_typemap[typename]
+ if typedef
+ return decode_definedtype(elename, typename, typedef, arytypestr)
+ end
+ end
+ return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
+ extraattr)
+ end
+
+ if parent.type == XSD::AnyTypeName
+ return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
+ extraattr)
+ end
+
+ # parent.definedtype == nil means the parent is SOAPUnknown. SOAPUnknown
+ # is generated by decode_tag_by_type when its type is anyType.
+ parenttype = parent.definedtype || @decode_typemap[parent.type]
+ unless parenttype
+ return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
+ extraattr)
+ end
+
+ definedtype_name = parenttype.child_type(elename)
+ if definedtype_name and (klass = TypeMap[definedtype_name])
+ return decode_basetype(klass, elename)
+ elsif definedtype_name == XSD::AnyTypeName
+ return decode_tag_by_type(ns, elename, typestr, parent, arytypestr,
+ extraattr)
+ end
+
+ if definedtype_name
+ typedef = @decode_typemap[definedtype_name]
+ else
+ typedef = parenttype.child_defined_complextype(elename)
+ end
+ decode_definedtype(elename, definedtype_name, typedef, arytypestr)
+ end
+
+ def decode_definedtype(elename, typename, typedef, arytypestr)
+ unless typedef
+ raise EncodingStyleError.new("unknown type '#{typename}'")
+ end
+ if typedef.is_a?(::WSDL::XMLSchema::SimpleType)
+ decode_defined_simpletype(elename, typename, typedef, arytypestr)
+ else
+ decode_defined_complextype(elename, typename, typedef, arytypestr)
+ end
+ end
+
+ def decode_basetype(klass, elename)
+ klass.decode(elename)
+ end
+
+ def decode_defined_simpletype(elename, typename, typedef, arytypestr)
+ o = decode_basetype(TypeMap[typedef.base], elename)
+ o.definedtype = typedef
+ o
+ end
+
+ def decode_defined_complextype(elename, typename, typedef, arytypestr)
+ case typedef.compoundtype
+ when :TYPE_STRUCT, :TYPE_MAP
+ o = SOAPStruct.decode(elename, typename)
+ o.definedtype = typedef
+ return o
+ when :TYPE_ARRAY
+ expected_arytype = typedef.find_arytype
+ if arytypestr
+ actual_arytype = XSD::QName.new(expected_arytype.namespace,
+ content_typename(expected_arytype.name) <<
+ content_ranksize(arytypestr))
+ o = SOAPArray.decode(elename, typename, actual_arytype)
+ else
+ o = SOAPArray.new(typename, 1, expected_arytype)
+ o.elename = elename
+ end
+ o.definedtype = typedef
+ return o
+ when :TYPE_EMPTY
+ o = SOAPNil.decode(elename)
+ o.definedtype = typedef
+ return o
+ else
+ raise RuntimeError.new(
+ "Unknown kind of complexType: #{typedef.compoundtype}")
+ end
+ nil
+ end
+
+ def decode_tag_by_type(ns, elename, typestr, parent, arytypestr, extraattr)
+ if arytypestr
+ type = typestr ? ns.parse(typestr) : ValueArrayName
+ node = SOAPArray.decode(elename, type, ns.parse(arytypestr))
+ node.extraattr.update(extraattr)
+ return node
+ end
+
+ type = nil
+ if typestr
+ type = ns.parse(typestr)
+ elsif parent.is_a?(SOAPArray)
+ type = parent.arytype
+ else
+ # Since it's in dynamic(without any type) encoding process,
+ # assumes entity as its type itself.
+ # <SOAP-ENC:Array ...> => type Array in SOAP-ENC.
+ # <Country xmlns="foo"> => type Country in foo.
+ type = elename
+ end
+
+ if (klass = TypeMap[type])
+ node = decode_basetype(klass, elename)
+ node.extraattr.update(extraattr)
+ return node
+ end
+
+ # Unknown type... Struct or String
+ SOAPUnknown.new(self, elename, type, extraattr)
+ end
+
+ def decode_textbuf(node)
+ case node
+ when XSD::XSDHexBinary, XSD::XSDBase64Binary
+ node.set_encoded(@textbuf)
+ when XSD::XSDString
+ if @charset
+ @textbuf = XSD::Charset.encoding_from_xml(@textbuf, @charset)
+ end
+ if node.definedtype
+ node.definedtype.check_lexical_format(@textbuf)
+ end
+ node.set(@textbuf)
+ when SOAPNil
+ # Nothing to do.
+ when SOAPBasetype
+ node.set(@textbuf)
+ else
+ # Nothing to do...
+ end
+ @textbuf = ''
+ end
+
+ NilLiteralMap = {
+ 'true' => true,
+ '1' => true,
+ 'false' => false,
+ '0' => false
+ }
+ RootLiteralMap = {
+ '1' => 1,
+ '0' => 0
+ }
+ def decode_attrs(ns, attrs)
+ is_nil = false
+ type = nil
+ arytype = nil
+ root = nil
+ offset = nil
+ position = nil
+ href = nil
+ id = nil
+ extraattr = {}
+
+ attrs.each do |key, value|
+ qname = ns.parse(key)
+ case qname.namespace
+ when XSD::InstanceNamespace
+ case qname.name
+ when XSD::NilLiteral
+ is_nil = NilLiteralMap[value] or
+ raise EncodingStyleError.new("cannot accept attribute value: #{value} as the value of xsi:#{XSD::NilLiteral} (expected 'true', 'false', '1', or '0')")
+ next
+ when XSD::AttrType
+ type = value
+ next
+ end
+ when EncodingNamespace
+ case qname.name
+ when AttrArrayType
+ arytype = value
+ next
+ when AttrRoot
+ root = RootLiteralMap[value] or
+ raise EncodingStyleError.new(
+ "illegal root attribute value: #{value}")
+ next
+ when AttrOffset
+ offset = value
+ next
+ when AttrPosition
+ position = value
+ next
+ end
+ end
+ if key == 'href'
+ href = value
+ next
+ elsif key == 'id'
+ id = value
+ next
+ end
+ qname = ns.parse_local(key)
+ extraattr[qname] = decode_attr_value(ns, qname, value)
+ end
+
+ return is_nil, type, arytype, root, offset, position, href, id, extraattr
+ end
+
+ def decode_attr_value(ns, qname, value)
+ if /\A#/ =~ value
+ o = SOAPReference.decode(nil, value)
+ @refpool << o
+ o
+ else
+ value
+ end
+ end
+
+ def decode_arypos(position)
+ /^\[(.+)\]$/ =~ position
+ $1.split(',').collect { |s| s.to_i }
+ end
+
+ def decode_resolve_id
+ count = @refpool.length # To avoid infinite loop
+ while !@refpool.empty? && count > 0
+ @refpool = @refpool.find_all { |ref|
+ o = @idpool.find { |item|
+ item.id == ref.refid
+ }
+ if o.is_a?(SOAPReference)
+ true # link of link.
+ elsif o
+ ref.__setobj__(o)
+ false
+ elsif o = ref.rootnode.external_content[ref.refid]
+ ref.__setobj__(o)
+ false
+ else
+ raise EncodingStyleError.new("unresolved reference: #{ref.refid}")
+ end
+ }
+ count -= 1
+ end
+ end
+end
+
+SOAPHandler.new
+
+
+end
+end
diff --git a/lib/soap/generator.rb b/lib/soap/generator.rb
new file mode 100644
index 0000000000..f179555e1d
--- /dev/null
+++ b/lib/soap/generator.rb
@@ -0,0 +1,268 @@
+# SOAP4R - SOAP XML Instance Generator library.
+# Copyright (C) 2001, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/ns'
+require 'soap/soap'
+require 'soap/baseData'
+require 'soap/encodingstyle/handler'
+
+
+module SOAP
+
+
+###
+## CAUTION: MT-unsafe
+#
+class SOAPGenerator
+ include SOAP
+
+ class FormatEncodeError < Error; end
+
+public
+
+ attr_accessor :charset
+ attr_accessor :default_encodingstyle
+ attr_accessor :generate_explicit_type
+ attr_accessor :use_numeric_character_reference
+
+ def initialize(opt = {})
+ @reftarget = nil
+ @handlers = {}
+ @charset = opt[:charset] || XSD::Charset.xml_encoding_label
+ @default_encodingstyle = opt[:default_encodingstyle] || EncodingNamespace
+ @generate_explicit_type =
+ opt.key?(:generate_explicit_type) ? opt[:generate_explicit_type] : true
+ @elementformdefault = opt[:elementformdefault]
+ @attributeformdefault = opt[:attributeformdefault]
+ @use_numeric_character_reference = opt[:use_numeric_character_reference]
+ @indentstr = opt[:no_indent] ? '' : ' '
+ @buf = @indent = @curr = nil
+ end
+
+ def generate(obj, io = nil)
+ @buf = io || ''
+ @indent = ''
+
+ prologue
+ @handlers.each do |uri, handler|
+ handler.encode_prologue
+ end
+
+ ns = XSD::NS.new
+ @buf << xmldecl
+ encode_data(ns, obj, nil)
+
+ @handlers.each do |uri, handler|
+ handler.encode_epilogue
+ end
+ epilogue
+
+ @buf
+ end
+
+ def encode_data(ns, obj, parent)
+ if obj.is_a?(SOAPEnvelopeElement)
+ encode_element(ns, obj, parent)
+ return
+ end
+ if @reftarget && !obj.precedents.empty?
+ add_reftarget(obj.elename.name, obj)
+ ref = SOAPReference.new(obj)
+ ref.elename = ref.elename.dup_name(obj.elename.name)
+ obj.precedents.clear # Avoid cyclic delay.
+ obj.encodingstyle = parent.encodingstyle
+ # SOAPReference is encoded here.
+ obj = ref
+ end
+ encodingstyle = obj.encodingstyle
+ # Children's encodingstyle is derived from its parent.
+ encodingstyle ||= parent.encodingstyle if parent
+ obj.encodingstyle = encodingstyle
+ handler = find_handler(encodingstyle || @default_encodingstyle)
+ unless handler
+ raise FormatEncodeError.new("Unknown encodingStyle: #{ encodingstyle }.")
+ end
+ if !obj.elename.name
+ raise FormatEncodeError.new("Element name not defined: #{ obj }.")
+ end
+ handler.encode_data(self, ns, obj, parent)
+ handler.encode_data_end(self, ns, obj, parent)
+ end
+
+ def add_reftarget(name, node)
+ unless @reftarget
+ raise FormatEncodeError.new("Reftarget is not defined.")
+ end
+ @reftarget.add(name, node)
+ end
+
+ def encode_child(ns, child, parent)
+ indent_backup, @indent = @indent, @indent + @indentstr
+ encode_data(ns.clone_ns, child, parent)
+ @indent = indent_backup
+ end
+
+ def encode_element(ns, obj, parent)
+ attrs = {}
+ if obj.is_a?(SOAPBody)
+ @reftarget = obj
+ obj.encode(self, ns, attrs) do |child|
+ indent_backup, @indent = @indent, @indent + @indentstr
+ encode_data(ns.clone_ns, child, obj)
+ @indent = indent_backup
+ end
+ @reftarget = nil
+ else
+ if obj.is_a?(SOAPEnvelope)
+ # xsi:nil="true" can appear even if dumping without explicit type.
+ SOAPGenerator.assign_ns(attrs, ns,
+ XSD::InstanceNamespace, XSINamespaceTag)
+ if @generate_explicit_type
+ SOAPGenerator.assign_ns(attrs, ns, XSD::Namespace, XSDNamespaceTag)
+ end
+ end
+ obj.encode(self, ns, attrs) do |child|
+ indent_backup, @indent = @indent, @indent + @indentstr
+ encode_data(ns.clone_ns, child, obj)
+ @indent = indent_backup
+ end
+ end
+ end
+
+ def encode_name(ns, data, attrs)
+ if element_local?(data)
+ data.elename.name
+ else
+ if element_qualified?(data)
+ SOAPGenerator.assign_ns(attrs, ns, data.elename.namespace, '')
+ else
+ SOAPGenerator.assign_ns(attrs, ns, data.elename.namespace)
+ end
+ ns.name(data.elename)
+ end
+ end
+
+ def encode_name_end(ns, data)
+ if element_local?(data)
+ data.elename.name
+ else
+ ns.name(data.elename)
+ end
+ end
+
+ def encode_tag(elename, attrs = nil)
+ if !attrs or attrs.empty?
+ @buf << "\n#{ @indent }<#{ elename }>"
+ elsif attrs.size == 1
+ key, value = attrs.shift
+ @buf << %Q[\n#{ @indent }<#{ elename } #{ key }="#{ value }">]
+ else
+ @buf << "\n#{ @indent }<#{ elename } " <<
+ attrs.collect { |key, value|
+ %Q[#{ key }="#{ value }"]
+ }.join("\n#{ @indent }#{ @indentstr * 2 }") <<
+ '>'
+ end
+ end
+
+ def encode_tag_end(elename, cr = nil)
+ if cr
+ @buf << "\n#{ @indent }</#{ elename }>"
+ else
+ @buf << "</#{ elename }>"
+ end
+ end
+
+ def encode_rawstring(str)
+ @buf << str
+ end
+
+ EncodeMap = {
+ '&' => '&amp;',
+ '<' => '&lt;',
+ '>' => '&gt;',
+ '"' => '&quot;',
+ '\'' => '&apos;',
+ "\r" => '&#xd;'
+ }
+ EncodeCharRegexp = Regexp.new("[#{EncodeMap.keys.join}]")
+ def encode_string(str)
+ if @use_numeric_character_reference and !XSD::Charset.is_us_ascii(str)
+ str.gsub!(EncodeCharRegexp) { |c| EncodeMap[c] }
+ @buf << str.unpack("U*").collect { |c|
+ if c == 0x9 or c == 0xa or c == 0xd or (c >= 0x20 and c <= 0x7f)
+ c.chr
+ else
+ sprintf("&#x%x;", c)
+ end
+ }.join
+ else
+ @buf << str.gsub(EncodeCharRegexp) { |c| EncodeMap[c] }
+ end
+ end
+
+ def element_local?(element)
+ element.elename.namespace.nil?
+ end
+
+ def element_qualified?(element)
+ if element.respond_to?(:qualified)
+ if element.qualified.nil?
+ @elementformdefault
+ else
+ element.qualified
+ end
+ else
+ @elementformdefault
+ end
+ end
+
+ def self.assign_ns(attrs, ns, namespace, tag = nil)
+ if namespace.nil?
+ raise FormatEncodeError.new("empty namespace")
+ end
+ unless ns.assigned?(namespace)
+ tag = ns.assign(namespace, tag)
+ if tag == ''
+ attr = 'xmlns'
+ else
+ attr = "xmlns:#{tag}"
+ end
+ attrs[attr] = namespace
+ end
+ end
+
+private
+
+ def prologue
+ end
+
+ def epilogue
+ end
+
+ def find_handler(encodingstyle)
+ unless @handlers.key?(encodingstyle)
+ handler = SOAP::EncodingStyle::Handler.handler(encodingstyle).new(@charset)
+ handler.generate_explicit_type = @generate_explicit_type
+ handler.encode_prologue
+ @handlers[encodingstyle] = handler
+ end
+ @handlers[encodingstyle]
+ end
+
+ def xmldecl
+ if @charset
+ %Q[<?xml version="1.0" encoding="#{ @charset }" ?>]
+ else
+ %Q[<?xml version="1.0" ?>]
+ end
+ end
+end
+
+
+end
diff --git a/lib/soap/header/handler.rb b/lib/soap/header/handler.rb
new file mode 100644
index 0000000000..7da2836e24
--- /dev/null
+++ b/lib/soap/header/handler.rb
@@ -0,0 +1,57 @@
+# SOAP4R - SOAP Header handler item
+# Copyright (C) 2003, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/element'
+
+
+module SOAP
+module Header
+
+
+class Handler
+ attr_reader :elename
+ attr_reader :mustunderstand
+ attr_reader :encodingstyle
+
+ def initialize(elename)
+ @elename = elename
+ @mustunderstand = false
+ @encodingstyle = nil
+ end
+
+ # Should return a SOAP/OM, a SOAPHeaderItem or nil.
+ def on_outbound
+ nil
+ end
+
+ # Given header is a SOAPHeaderItem or nil.
+ def on_inbound(header, mustunderstand = false)
+ # do something.
+ end
+
+ def on_outbound_headeritem
+ item = on_outbound
+ if item.nil?
+ nil
+ elsif item.is_a?(::SOAP::SOAPHeaderItem)
+ item.elename = @elename
+ item
+ else
+ item.elename = @elename
+ ::SOAP::SOAPHeaderItem.new(item, @mustunderstand, @encodingstyle)
+ end
+ end
+
+ def on_inbound_headeritem(header)
+ on_inbound(header.element, header.mustunderstand)
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/header/handlerset.rb b/lib/soap/header/handlerset.rb
new file mode 100644
index 0000000000..a8eee03023
--- /dev/null
+++ b/lib/soap/header/handlerset.rb
@@ -0,0 +1,70 @@
+# SOAP4R - SOAP Header handler set
+# Copyright (C) 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/namedelements'
+
+
+module SOAP
+module Header
+
+
+class HandlerSet
+ def initialize
+ @store = XSD::NamedElements.new
+ end
+
+ def dup
+ obj = HandlerSet.new
+ obj.store = @store.dup
+ obj
+ end
+
+ def add(handler)
+ @store << handler
+ end
+ alias << add
+
+ def delete(handler)
+ @store.delete(handler)
+ end
+
+ def include?(handler)
+ @store.include?(handler)
+ end
+
+ # returns: Array of SOAPHeaderItem
+ def on_outbound
+ @store.collect { |handler|
+ handler.on_outbound_headeritem
+ }.compact
+ end
+
+ # headers: SOAPHeaderItem enumerable object
+ def on_inbound(headers)
+ headers.each do |name, item|
+ handler = @store.find { |handler|
+ handler.elename == item.element.elename
+ }
+ if handler
+ handler.on_inbound_headeritem(item)
+ elsif item.mustunderstand
+ raise UnhandledMustUnderstandHeaderError.new(item.element.elename.to_s)
+ end
+ end
+ end
+
+protected
+
+ def store=(store)
+ @store = store
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/header/simplehandler.rb b/lib/soap/header/simplehandler.rb
new file mode 100644
index 0000000000..7b206f77db
--- /dev/null
+++ b/lib/soap/header/simplehandler.rb
@@ -0,0 +1,44 @@
+# SOAP4R - SOAP Simple header item handler
+# Copyright (C) 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/header/handler'
+require 'soap/baseData'
+
+
+module SOAP
+module Header
+
+
+class SimpleHandler < SOAP::Header::Handler
+ def initialize(elename)
+ super(elename)
+ end
+
+ # Should return a Hash, String or nil.
+ def on_simple_outbound
+ nil
+ end
+
+ # Given header is a Hash, String or nil.
+ def on_simple_inbound(header, mustunderstand)
+ end
+
+ def on_outbound
+ h = on_simple_outbound
+ h ? SOAPElement.from_obj(h, elename.namespace) : nil
+ end
+
+ def on_inbound(header, mustunderstand)
+ h = header.respond_to?(:to_obj) ? header.to_obj : header.data
+ on_simple_inbound(h, mustunderstand)
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/httpconfigloader.rb b/lib/soap/httpconfigloader.rb
new file mode 100644
index 0000000000..cd7bca8a65
--- /dev/null
+++ b/lib/soap/httpconfigloader.rb
@@ -0,0 +1,119 @@
+# SOAP4R - HTTP config loader.
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/property'
+
+
+module SOAP
+
+
+module HTTPConfigLoader
+module_function
+
+ def set_options(client, options)
+ client.proxy = options["proxy"]
+ options.add_hook("proxy") do |key, value|
+ client.proxy = value
+ end
+ client.no_proxy = options["no_proxy"]
+ options.add_hook("no_proxy") do |key, value|
+ client.no_proxy = value
+ end
+ if client.respond_to?(:protocol_version=)
+ client.protocol_version = options["protocol_version"]
+ options.add_hook("protocol_version") do |key, value|
+ client.protocol_version = value
+ end
+ end
+ ssl_config = options["ssl_config"] ||= ::SOAP::Property.new
+ set_ssl_config(client, ssl_config)
+ ssl_config.add_hook(true) do |key, value|
+ set_ssl_config(client, ssl_config)
+ end
+ basic_auth = options["basic_auth"] ||= ::SOAP::Property.new
+ set_basic_auth(client, basic_auth)
+ basic_auth.add_hook do |key, value|
+ set_basic_auth(client, basic_auth)
+ end
+ options.add_hook("connect_timeout") do |key, value|
+ client.connect_timeout = value
+ end
+ options.add_hook("send_timeout") do |key, value|
+ client.send_timeout = value
+ end
+ options.add_hook("receive_timeout") do |key, value|
+ client.receive_timeout = value
+ end
+ end
+
+ def set_basic_auth(client, basic_auth)
+ basic_auth.values.each do |url, userid, passwd|
+ client.set_basic_auth(url, userid, passwd)
+ end
+ end
+
+ def set_ssl_config(client, ssl_config)
+ ssl_config.each do |key, value|
+ cfg = client.ssl_config
+ if cfg.nil?
+ raise NotImplementedError.new("SSL not supported")
+ end
+ case key
+ when 'client_cert'
+ cfg.client_cert = cert_from_file(value)
+ when 'client_key'
+ cfg.client_key = key_from_file(value)
+ when 'client_ca'
+ cfg.client_ca = value
+ when 'ca_path'
+ cfg.set_trust_ca(value)
+ when 'ca_file'
+ cfg.set_trust_ca(value)
+ when 'crl'
+ cfg.set_crl(value)
+ when 'verify_mode'
+ cfg.verify_mode = ssl_config_int(value)
+ when 'verify_depth'
+ cfg.verify_depth = ssl_config_int(value)
+ when 'options'
+ cfg.options = value
+ when 'ciphers'
+ cfg.ciphers = value
+ when 'verify_callback'
+ cfg.verify_callback = value
+ when 'cert_store'
+ cfg.cert_store = value
+ else
+ raise ArgumentError.new("unknown ssl_config property #{key}")
+ end
+ end
+ end
+
+ def ssl_config_int(value)
+ if value.nil? or value.to_s.empty?
+ nil
+ else
+ begin
+ Integer(value)
+ rescue ArgumentError
+ ::SOAP::Property::Util.const_from_name(value.to_s)
+ end
+ end
+ end
+
+ def cert_from_file(filename)
+ OpenSSL::X509::Certificate.new(File.open(filename) { |f| f.read })
+ end
+
+ def key_from_file(filename)
+ OpenSSL::PKey::RSA.new(File.open(filename) { |f| f.read })
+ end
+end
+
+
+end
diff --git a/lib/soap/mapping.rb b/lib/soap/mapping.rb
new file mode 100644
index 0000000000..b83f8b484a
--- /dev/null
+++ b/lib/soap/mapping.rb
@@ -0,0 +1,10 @@
+# SOAP4R - Ruby type mapping utility.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/mapping/mapping'
+require 'soap/mapping/registry'
diff --git a/lib/soap/mapping/factory.rb b/lib/soap/mapping/factory.rb
new file mode 100644
index 0000000000..978b303b3d
--- /dev/null
+++ b/lib/soap/mapping/factory.rb
@@ -0,0 +1,355 @@
+# SOAP4R - Mapping factory.
+# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module SOAP
+module Mapping
+
+
+class Factory
+ include TraverseSupport
+
+ def initialize
+ # nothing to do
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ raise NotImplementError.new
+ # return soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ raise NotImplementError.new
+ # return convert_succeeded_or_not, obj
+ end
+
+ def setiv2obj(obj, node, map)
+ return if node.nil?
+ if obj.is_a?(Array)
+ setiv2ary(obj, node, map)
+ else
+ setiv2struct(obj, node, map)
+ end
+ end
+
+ def setiv2soap(node, obj, map)
+ if obj.class.class_variables.include?('@@schema_element')
+ obj.class.class_eval('@@schema_element').each do |name, info|
+ type, qname = info
+ if qname
+ elename = qname.name
+ else
+ elename = Mapping.name2elename(name)
+ end
+ node.add(elename,
+ Mapping._obj2soap(obj.instance_variable_get('@' + name), map))
+ end
+ else
+ # should we sort instance_variables?
+ obj.instance_variables.each do |var|
+ name = var.sub(/^@/, '')
+ elename = Mapping.name2elename(name)
+ node.add(elename,
+ Mapping._obj2soap(obj.instance_variable_get(var), map))
+ end
+ end
+ end
+
+private
+
+ def setiv2ary(obj, node, map)
+ node.each do |name, value|
+ Array.instance_method(:<<).bind(obj).call(Mapping._soap2obj(value, map))
+ end
+ end
+
+ def setiv2struct(obj, node, map)
+ vars = {}
+ node.each do |name, value|
+ vars[Mapping.elename2name(name)] = Mapping._soap2obj(value, map)
+ end
+ Mapping.set_attributes(obj, vars)
+ end
+end
+
+class StringFactory_ < Factory
+ def initialize(allow_original_mapping = false)
+ super()
+ @allow_original_mapping = allow_original_mapping
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ if !@allow_original_mapping and !obj.instance_variables.empty?
+ return nil
+ end
+ begin
+ unless XSD::Charset.is_ces(obj, Thread.current[:SOAPExternalCES])
+ return nil
+ end
+ encoded = XSD::Charset.encoding_conv(obj,
+ Thread.current[:SOAPExternalCES], XSD::Charset.encoding)
+ soap_obj = soap_class.new(encoded)
+ rescue XSD::ValueSpaceError
+ return nil
+ end
+ mark_marshalled_obj(obj, soap_obj)
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = Mapping.create_empty_object(obj_class)
+ decoded = XSD::Charset.encoding_conv(node.data, XSD::Charset.encoding,
+ Thread.current[:SOAPExternalCES])
+ obj.replace(decoded)
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ end
+end
+
+class BasetypeFactory_ < Factory
+ def initialize(allow_original_mapping = false)
+ super()
+ @allow_original_mapping = allow_original_mapping
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ if !@allow_original_mapping and !obj.instance_variables.empty?
+ return nil
+ end
+ soap_obj = nil
+ begin
+ soap_obj = soap_class.new(obj)
+ rescue XSD::ValueSpaceError
+ return nil
+ end
+ if @allow_original_mapping
+ # Basetype except String should not be multiref-ed in SOAP/1.1.
+ mark_marshalled_obj(obj, soap_obj)
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = node.data
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ end
+end
+
+class DateTimeFactory_ < Factory
+ def initialize(allow_original_mapping = false)
+ super()
+ @allow_original_mapping = allow_original_mapping
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ if !@allow_original_mapping and
+ Time === obj and !obj.instance_variables.empty?
+ return nil
+ end
+ soap_obj = nil
+ begin
+ soap_obj = soap_class.new(obj)
+ rescue XSD::ValueSpaceError
+ return nil
+ end
+ mark_marshalled_obj(obj, soap_obj)
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ if node.respond_to?(:to_obj)
+ obj = node.to_obj(obj_class)
+ return false if obj.nil?
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ else
+ return false
+ end
+ end
+end
+
+class Base64Factory_ < Factory
+ def obj2soap(soap_class, obj, info, map)
+ return nil unless obj.instance_variables.empty?
+ soap_obj = soap_class.new(obj)
+ mark_marshalled_obj(obj, soap_obj) if soap_obj
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = node.string
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ end
+end
+
+class URIFactory_ < Factory
+ def obj2soap(soap_class, obj, info, map)
+ soap_obj = soap_class.new(obj)
+ mark_marshalled_obj(obj, soap_obj) if soap_obj
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = node.data
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ end
+end
+
+class ArrayFactory_ < Factory
+ def initialize(allow_original_mapping = false)
+ super()
+ @allow_original_mapping = allow_original_mapping
+ end
+
+ # [[1], [2]] is converted to Array of Array, not 2-D Array.
+ # To create M-D Array, you must call Mapping.ary2md.
+ def obj2soap(soap_class, obj, info, map)
+ if !@allow_original_mapping and !obj.instance_variables.empty?
+ return nil
+ end
+ arytype = Mapping.obj2element(obj)
+ if arytype.name
+ arytype.namespace ||= RubyTypeNamespace
+ else
+ arytype = XSD::AnyTypeName
+ end
+ soap_obj = SOAPArray.new(ValueArrayName, 1, arytype)
+ mark_marshalled_obj(obj, soap_obj)
+ obj.each do |item|
+ soap_obj.add(Mapping._obj2soap(item, map))
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = Mapping.create_empty_object(obj_class)
+ mark_unmarshalled_obj(node, obj)
+ node.soap2array(obj) do |elem|
+ elem ? Mapping._soap2obj(elem, map) : nil
+ end
+ return true, obj
+ end
+end
+
+class TypedArrayFactory_ < Factory
+ def initialize(allow_original_mapping = false)
+ super()
+ @allow_original_mapping = allow_original_mapping
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ if !@allow_original_mapping and !obj.instance_variables.empty?
+ return nil
+ end
+ arytype = info[:type] || info[0]
+ soap_obj = SOAPArray.new(ValueArrayName, 1, arytype)
+ mark_marshalled_obj(obj, soap_obj)
+ obj.each do |var|
+ soap_obj.add(Mapping._obj2soap(var, map))
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ if node.rank > 1
+ return false
+ end
+ arytype = info[:type] || info[0]
+ unless node.arytype == arytype
+ return false
+ end
+ obj = Mapping.create_empty_object(obj_class)
+ mark_unmarshalled_obj(node, obj)
+ node.soap2array(obj) do |elem|
+ elem ? Mapping._soap2obj(elem, map) : nil
+ end
+ return true, obj
+ end
+end
+
+class TypedStructFactory_ < Factory
+ def obj2soap(soap_class, obj, info, map)
+ type = info[:type] || info[0]
+ soap_obj = soap_class.new(type)
+ mark_marshalled_obj(obj, soap_obj)
+ if obj.class <= SOAP::Marshallable
+ setiv2soap(soap_obj, obj, map)
+ else
+ setiv2soap(soap_obj, obj, map)
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ type = info[:type] || info[0]
+ unless node.type == type
+ return false
+ end
+ obj = Mapping.create_empty_object(obj_class)
+ mark_unmarshalled_obj(node, obj)
+ setiv2obj(obj, node, map)
+ return true, obj
+ end
+end
+
+MapQName = XSD::QName.new(ApacheSOAPTypeNamespace, 'Map')
+class HashFactory_ < Factory
+ def initialize(allow_original_mapping = false)
+ super()
+ @allow_original_mapping = allow_original_mapping
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ if !@allow_original_mapping and !obj.instance_variables.empty?
+ return nil
+ end
+ if !obj.default.nil? or
+ (obj.respond_to?(:default_proc) and obj.default_proc)
+ return nil
+ end
+ soap_obj = SOAPStruct.new(MapQName)
+ mark_marshalled_obj(obj, soap_obj)
+ obj.each do |key, value|
+ elem = SOAPStruct.new
+ elem.add("key", Mapping._obj2soap(key, map))
+ elem.add("value", Mapping._obj2soap(value, map))
+ # ApacheAxis allows only 'item' here.
+ soap_obj.add("item", elem)
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ unless node.type == MapQName
+ return false
+ end
+ if node.class == SOAPStruct and node.key?('default')
+ return false
+ end
+ obj = Mapping.create_empty_object(obj_class)
+ mark_unmarshalled_obj(node, obj)
+ if node.class == SOAPStruct
+ node.each do |key, value|
+ obj[Mapping._soap2obj(value['key'], map)] =
+ Mapping._soap2obj(value['value'], map)
+ end
+ else
+ node.each do |value|
+ obj[Mapping._soap2obj(value['key'], map)] =
+ Mapping._soap2obj(value['value'], map)
+ end
+ end
+ return true, obj
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/mapping/mapping.rb b/lib/soap/mapping/mapping.rb
new file mode 100644
index 0000000000..65d6bb4d5b
--- /dev/null
+++ b/lib/soap/mapping/mapping.rb
@@ -0,0 +1,381 @@
+# SOAP4R - Ruby type mapping utility.
+# Copyright (C) 2000, 2001, 2003-2005 NAKAMURA Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+
+
+module SOAP
+
+
+module Mapping
+ RubyTypeNamespace = 'http://www.ruby-lang.org/xmlns/ruby/type/1.6'
+ RubyTypeInstanceNamespace =
+ 'http://www.ruby-lang.org/xmlns/ruby/type-instance'
+ RubyCustomTypeNamespace = 'http://www.ruby-lang.org/xmlns/ruby/type/custom'
+ ApacheSOAPTypeNamespace = 'http://xml.apache.org/xml-soap'
+
+
+ # TraverseSupport breaks following thread variables.
+ # Thread.current[:SOAPMarshalDataKey]
+ module TraverseSupport
+ def mark_marshalled_obj(obj, soap_obj)
+ raise if obj.nil?
+ Thread.current[:SOAPMarshalDataKey][obj.__id__] = soap_obj
+ end
+
+ def mark_unmarshalled_obj(node, obj)
+ return if obj.nil?
+ # node.id is not Object#id but SOAPReference#id
+ Thread.current[:SOAPMarshalDataKey][node.id] = obj
+ end
+ end
+
+
+ EMPTY_OPT = {}
+ def self.obj2soap(obj, registry = nil, type = nil, opt = EMPTY_OPT)
+ registry ||= Mapping::DefaultRegistry
+ soap_obj = nil
+ protect_threadvars(:SOAPMarshalDataKey, :SOAPExternalCES, :SOAPMarshalNoReference) do
+ Thread.current[:SOAPMarshalDataKey] = {}
+ Thread.current[:SOAPExternalCES] = opt[:external_ces] || $KCODE
+ Thread.current[:SOAPMarshalNoReference] = opt[:no_reference]
+ soap_obj = _obj2soap(obj, registry, type)
+ end
+ soap_obj
+ end
+
+ def self.soap2obj(node, registry = nil, klass = nil, opt = EMPTY_OPT)
+ registry ||= Mapping::DefaultRegistry
+ obj = nil
+ protect_threadvars(:SOAPMarshalDataKey, :SOAPExternalCES, :SOAPMarshalNoReference) do
+ Thread.current[:SOAPMarshalDataKey] = {}
+ Thread.current[:SOAPExternalCES] = opt[:external_ces] || $KCODE
+ Thread.current[:SOAPMarshalNoReference] = opt[:no_reference]
+ obj = _soap2obj(node, registry, klass)
+ end
+ obj
+ end
+
+ def self.ary2soap(ary, type_ns = XSD::Namespace, typename = XSD::AnyTypeLiteral, registry = nil, opt = EMPTY_OPT)
+ registry ||= Mapping::DefaultRegistry
+ type = XSD::QName.new(type_ns, typename)
+ soap_ary = SOAPArray.new(ValueArrayName, 1, type)
+ protect_threadvars(:SOAPMarshalDataKey, :SOAPExternalCES, :SOAPMarshalNoReference) do
+ Thread.current[:SOAPMarshalDataKey] = {}
+ Thread.current[:SOAPExternalCES] = opt[:external_ces] || $KCODE
+ Thread.current[:SOAPMarshalNoReference] = opt[:no_reference]
+ ary.each do |ele|
+ soap_ary.add(_obj2soap(ele, registry, type))
+ end
+ end
+ soap_ary
+ end
+
+ def self.ary2md(ary, rank, type_ns = XSD::Namespace, typename = XSD::AnyTypeLiteral, registry = nil, opt = EMPTY_OPT)
+ registry ||= Mapping::DefaultRegistry
+ type = XSD::QName.new(type_ns, typename)
+ md_ary = SOAPArray.new(ValueArrayName, rank, type)
+ protect_threadvars(:SOAPMarshalDataKey, :SOAPExternalCES, :SOAPMarshalNoReference) do
+ Thread.current[:SOAPMarshalDataKey] = {}
+ Thread.current[:SOAPExternalCES] = opt[:external_ces] || $KCODE
+ Thread.current[:SOAPMarshalNoReference] = opt[:no_reference]
+ add_md_ary(md_ary, ary, [], registry)
+ end
+ md_ary
+ end
+
+ def self.fault2exception(fault, registry = nil)
+ registry ||= Mapping::DefaultRegistry
+ detail = if fault.detail
+ soap2obj(fault.detail, registry) || ""
+ else
+ ""
+ end
+ if detail.is_a?(Mapping::SOAPException)
+ begin
+ e = detail.to_e
+ remote_backtrace = e.backtrace
+ e.set_backtrace(nil)
+ raise e # ruby sets current caller as local backtrace of e => e2.
+ rescue Exception => e
+ e.set_backtrace(remote_backtrace + e.backtrace[1..-1])
+ raise
+ end
+ else
+ fault.detail = detail
+ fault.set_backtrace(
+ if detail.is_a?(Array)
+ detail
+ else
+ [detail.to_s]
+ end
+ )
+ raise
+ end
+ end
+
+ def self._obj2soap(obj, registry, type = nil)
+ if referent = Thread.current[:SOAPMarshalDataKey][obj.__id__] and
+ !Thread.current[:SOAPMarshalNoReference]
+ SOAPReference.new(referent)
+ elsif registry
+ registry.obj2soap(obj, type)
+ else
+ raise MappingError.new("no mapping registry given")
+ end
+ end
+
+ def self._soap2obj(node, registry, klass = nil)
+ if node.nil?
+ return nil
+ elsif node.is_a?(SOAPReference)
+ target = node.__getobj__
+ # target.id is not Object#id but SOAPReference#id
+ if referent = Thread.current[:SOAPMarshalDataKey][target.id] and
+ !Thread.current[:SOAPMarshalNoReference]
+ return referent
+ else
+ return _soap2obj(target, registry, klass)
+ end
+ end
+ return registry.soap2obj(node, klass)
+ end
+
+ if Object.respond_to?(:allocate)
+ # ruby/1.7 or later.
+ def self.create_empty_object(klass)
+ klass.allocate
+ end
+ else
+ MARSHAL_TAG = {
+ String => ['"', 1],
+ Regexp => ['/', 2],
+ Array => ['[', 1],
+ Hash => ['{', 1]
+ }
+ def self.create_empty_object(klass)
+ if klass <= Struct
+ name = klass.name
+ return ::Marshal.load(sprintf("\004\006S:%c%s\000", name.length + 5, name))
+ end
+ if MARSHAL_TAG.has_key?(klass)
+ tag, terminate = MARSHAL_TAG[klass]
+ return ::Marshal.load(sprintf("\004\006%s%s", tag, "\000" * terminate))
+ end
+ MARSHAL_TAG.each do |k, v|
+ if klass < k
+ name = klass.name
+ tag, terminate = v
+ return ::Marshal.load(sprintf("\004\006C:%c%s%s%s", name.length + 5, name, tag, "\000" * terminate))
+ end
+ end
+ name = klass.name
+ ::Marshal.load(sprintf("\004\006o:%c%s\000", name.length + 5, name))
+ end
+ end
+
+ # Allow only (Letter | '_') (Letter | Digit | '-' | '_')* here.
+ # Caution: '.' is not allowed here.
+ # To follow XML spec., it should be NCName.
+ # (denied chars) => .[0-F][0-F]
+ # ex. a.b => a.2eb
+ #
+ def self.name2elename(name)
+ name.gsub(/([^a-zA-Z0-9:_\-]+)/n) {
+ '.' << $1.unpack('H2' * $1.size).join('.')
+ }.gsub(/::/n, '..')
+ end
+
+ def self.elename2name(name)
+ name.gsub(/\.\./n, '::').gsub(/((?:\.[0-9a-fA-F]{2})+)/n) {
+ [$1.delete('.')].pack('H*')
+ }
+ end
+
+ def self.const_from_name(name, lenient = false)
+ const = ::Object
+ name.sub(/\A::/, '').split('::').each do |const_str|
+ if XSD::CodeGen::GenSupport.safeconstname?(const_str)
+ if const.const_defined?(const_str)
+ const = const.const_get(const_str)
+ next
+ end
+ elsif lenient
+ const_str = XSD::CodeGen::GenSupport.safeconstname(const_str)
+ if const.const_defined?(const_str)
+ const = const.const_get(const_str)
+ next
+ end
+ end
+ return nil
+ end
+ const
+ end
+
+ def self.class_from_name(name, lenient = false)
+ const = const_from_name(name, lenient)
+ if const.is_a?(::Class)
+ const
+ else
+ nil
+ end
+ end
+
+ def self.module_from_name(name, lenient = false)
+ const = const_from_name(name, lenient)
+ if const.is_a?(::Module)
+ const
+ else
+ nil
+ end
+ end
+
+ def self.class2qname(klass)
+ name = schema_type_definition(klass)
+ namespace = schema_ns_definition(klass)
+ XSD::QName.new(namespace, name)
+ end
+
+ def self.class2element(klass)
+ type = Mapping.class2qname(klass)
+ type.name ||= Mapping.name2elename(klass.name)
+ type.namespace ||= RubyCustomTypeNamespace
+ type
+ end
+
+ def self.obj2element(obj)
+ name = namespace = nil
+ ivars = obj.instance_variables
+ if ivars.include?('@schema_type')
+ name = obj.instance_variable_get('@schema_type')
+ end
+ if ivars.include?('@schema_ns')
+ namespace = obj.instance_variable_get('@schema_ns')
+ end
+ if !name or !namespace
+ class2qname(obj.class)
+ else
+ XSD::QName.new(namespace, name)
+ end
+ end
+
+ def self.define_singleton_method(obj, name, &block)
+ sclass = (class << obj; self; end)
+ sclass.class_eval {
+ define_method(name, &block)
+ }
+ end
+
+ def self.get_attribute(obj, attr_name)
+ if obj.is_a?(::Hash)
+ obj[attr_name] || obj[attr_name.intern]
+ else
+ name = XSD::CodeGen::GenSupport.safevarname(attr_name)
+ if obj.instance_variables.include?('@' + name)
+ obj.instance_variable_get('@' + name)
+ elsif ((obj.is_a?(::Struct) or obj.is_a?(Marshallable)) and
+ obj.respond_to?(name))
+ obj.__send__(name)
+ end
+ end
+ end
+
+ def self.set_attributes(obj, values)
+ if obj.is_a?(::SOAP::Mapping::Object)
+ values.each do |attr_name, value|
+ obj.__add_xmlele_value(attr_name, value)
+ end
+ else
+ values.each do |attr_name, value|
+ name = XSD::CodeGen::GenSupport.safevarname(attr_name)
+ setter = name + "="
+ if obj.respond_to?(setter)
+ obj.__send__(setter, value)
+ else
+ obj.instance_variable_set('@' + name, value)
+ begin
+ define_attr_accessor(obj, name,
+ proc { instance_variable_get('@' + name) },
+ proc { |value| instance_variable_set('@' + name, value) })
+ rescue TypeError
+ # singleton class may not exist (e.g. Float)
+ end
+ end
+ end
+ end
+ end
+
+ def self.define_attr_accessor(obj, name, getterproc, setterproc = nil)
+ define_singleton_method(obj, name, &getterproc)
+ define_singleton_method(obj, name + '=', &setterproc) if setterproc
+ end
+
+ def self.schema_type_definition(klass)
+ class_schema_variable(:schema_type, klass)
+ end
+
+ def self.schema_ns_definition(klass)
+ class_schema_variable(:schema_ns, klass)
+ end
+
+ def self.schema_element_definition(klass)
+ schema_element = class_schema_variable(:schema_element, klass) or return nil
+ schema_ns = schema_ns_definition(klass)
+ elements = []
+ as_array = []
+ schema_element.each do |varname, definition|
+ class_name, name = definition
+ if /\[\]$/ =~ class_name
+ class_name = class_name.sub(/\[\]$/, '')
+ as_array << (name ? name.name : varname)
+ end
+ elements << [name || XSD::QName.new(schema_ns, varname), class_name]
+ end
+ [elements, as_array]
+ end
+
+ def self.schema_attribute_definition(klass)
+ class_schema_variable(:schema_attribute, klass)
+ end
+
+ class << Mapping
+ private
+
+ def class_schema_variable(sym, klass)
+ var = "@@#{sym}"
+ klass.class_variables.include?(var) ? klass.class_eval(var) : nil
+ end
+
+ def protect_threadvars(*symbols)
+ backup = {}
+ begin
+ symbols.each do |sym|
+ backup[sym] = Thread.current[sym]
+ end
+ yield
+ ensure
+ symbols.each do |sym|
+ Thread.current[sym] = backup[sym]
+ end
+ end
+ end
+
+ def add_md_ary(md_ary, ary, indices, registry)
+ for idx in 0..(ary.size - 1)
+ if ary[idx].is_a?(Array)
+ add_md_ary(md_ary, ary[idx], indices + [idx], registry)
+ else
+ md_ary[*(indices + [idx])] = _obj2soap(ary[idx], registry)
+ end
+ end
+ end
+ end
+end
+
+
+end
diff --git a/lib/soap/mapping/registry.rb b/lib/soap/mapping/registry.rb
new file mode 100644
index 0000000000..823e80666d
--- /dev/null
+++ b/lib/soap/mapping/registry.rb
@@ -0,0 +1,541 @@
+# SOAP4R - Mapping registry.
+# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/baseData'
+require 'soap/mapping/mapping'
+require 'soap/mapping/typeMap'
+require 'soap/mapping/factory'
+require 'soap/mapping/rubytypeFactory'
+
+
+module SOAP
+
+
+module Marshallable
+ # @@type_ns = Mapping::RubyCustomTypeNamespace
+end
+
+
+module Mapping
+
+
+module MappedException; end
+
+
+RubyTypeName = XSD::QName.new(RubyTypeInstanceNamespace, 'rubyType')
+RubyExtendName = XSD::QName.new(RubyTypeInstanceNamespace, 'extends')
+RubyIVarName = XSD::QName.new(RubyTypeInstanceNamespace, 'ivars')
+
+
+# Inner class to pass an exception.
+class SOAPException; include Marshallable
+ attr_reader :excn_type_name, :cause
+ def initialize(e)
+ @excn_type_name = Mapping.name2elename(e.class.to_s)
+ @cause = e
+ end
+
+ def to_e
+ if @cause.is_a?(::Exception)
+ @cause.extend(::SOAP::Mapping::MappedException)
+ return @cause
+ elsif @cause.respond_to?(:message) and @cause.respond_to?(:backtrace)
+ e = RuntimeError.new(@cause.message)
+ e.set_backtrace(@cause.backtrace)
+ return e
+ end
+ klass = Mapping.class_from_name(Mapping.elename2name(@excn_type_name.to_s))
+ if klass.nil? or not klass <= ::Exception
+ return RuntimeError.new(@cause.inspect)
+ end
+ obj = klass.new(@cause.message)
+ obj.extend(::SOAP::Mapping::MappedException)
+ obj
+ end
+end
+
+
+# For anyType object: SOAP::Mapping::Object not ::Object
+class Object; include Marshallable
+ def initialize
+ @__xmlele_type = {}
+ @__xmlele = []
+ @__xmlattr = {}
+ end
+
+ def inspect
+ sprintf("#<%s:0x%x%s>", self.class.name, __id__,
+ @__xmlele.collect { |name, value| " #{name}=#{value.inspect}" }.join)
+ end
+
+ def __xmlattr
+ @__xmlattr
+ end
+
+ def __xmlele
+ @__xmlele
+ end
+
+ def [](qname)
+ unless qname.is_a?(XSD::QName)
+ qname = XSD::QName.new(nil, qname)
+ end
+ @__xmlele.each do |k, v|
+ return v if k == qname
+ end
+ # fallback
+ @__xmlele.each do |k, v|
+ return v if k.name == qname.name
+ end
+ nil
+ end
+
+ def []=(qname, value)
+ unless qname.is_a?(XSD::QName)
+ qname = XSD::QName.new(nil, qname)
+ end
+ found = false
+ @__xmlele.each do |pair|
+ if pair[0] == qname
+ found = true
+ pair[1] = value
+ end
+ end
+ unless found
+ __define_attr_accessor(qname)
+ @__xmlele << [qname, value]
+ end
+ @__xmlele_type[qname] = :single
+ end
+
+ def __add_xmlele_value(qname, value)
+ found = false
+ @__xmlele.map! do |k, v|
+ if k == qname
+ found = true
+ [k, __set_xmlele_value(k, v, value)]
+ else
+ [k, v]
+ end
+ end
+ unless found
+ __define_attr_accessor(qname)
+ @__xmlele << [qname, value]
+ @__xmlele_type[qname] = :single
+ end
+ value
+ end
+
+private
+
+ if RUBY_VERSION > "1.7.0"
+ def __define_attr_accessor(qname)
+ name = XSD::CodeGen::GenSupport.safemethodname(qname.name)
+ Mapping.define_attr_accessor(self, name,
+ proc { self[qname] },
+ proc { |value| self[qname] = value })
+ end
+ else
+ def __define_attr_accessor(qname)
+ name = XSD::CodeGen::GenSupport.safemethodname(qname.name)
+ instance_eval <<-EOS
+ def #{name}
+ self[#{qname.dump}]
+ end
+
+ def #{name}=(value)
+ self[#{qname.dump}] = value
+ end
+ EOS
+ end
+ end
+
+ def __set_xmlele_value(key, org, value)
+ case @__xmlele_type[key]
+ when :multi
+ org << value
+ org
+ when :single
+ @__xmlele_type[key] = :multi
+ [org, value]
+ else
+ raise RuntimeError.new("unknown type")
+ end
+ end
+end
+
+
+class MappingError < Error; end
+
+
+class Registry
+ class Map
+ def initialize(registry)
+ @obj2soap = {}
+ @soap2obj = {}
+ @registry = registry
+ end
+
+ def obj2soap(obj)
+ klass = obj.class
+ if map = @obj2soap[klass]
+ map.each do |soap_class, factory, info|
+ ret = factory.obj2soap(soap_class, obj, info, @registry)
+ return ret if ret
+ end
+ end
+ ancestors = klass.ancestors
+ ancestors.delete(klass)
+ ancestors.delete(::Object)
+ ancestors.delete(::Kernel)
+ ancestors.each do |klass|
+ if map = @obj2soap[klass]
+ map.each do |soap_class, factory, info|
+ if info[:derived_class]
+ ret = factory.obj2soap(soap_class, obj, info, @registry)
+ return ret if ret
+ end
+ end
+ end
+ end
+ nil
+ end
+
+ def soap2obj(node, klass = nil)
+ if map = @soap2obj[node.class]
+ map.each do |obj_class, factory, info|
+ next if klass and obj_class != klass
+ conv, obj = factory.soap2obj(obj_class, node, info, @registry)
+ return true, obj if conv
+ end
+ end
+ return false, nil
+ end
+
+ # Give priority to former entry.
+ def init(init_map = [])
+ clear
+ init_map.reverse_each do |obj_class, soap_class, factory, info|
+ add(obj_class, soap_class, factory, info)
+ end
+ end
+
+ # Give priority to latter entry.
+ def add(obj_class, soap_class, factory, info)
+ info ||= {}
+ (@obj2soap[obj_class] ||= []).unshift([soap_class, factory, info])
+ (@soap2obj[soap_class] ||= []).unshift([obj_class, factory, info])
+ end
+
+ def clear
+ @obj2soap.clear
+ @soap2obj.clear
+ end
+
+ def find_mapped_soap_class(target_obj_class)
+ map = @obj2soap[target_obj_class]
+ map.empty? ? nil : map[0][1]
+ end
+
+ def find_mapped_obj_class(target_soap_class)
+ map = @soap2obj[target_soap_class]
+ map.empty? ? nil : map[0][0]
+ end
+ end
+
+ StringFactory = StringFactory_.new
+ BasetypeFactory = BasetypeFactory_.new
+ DateTimeFactory = DateTimeFactory_.new
+ ArrayFactory = ArrayFactory_.new
+ Base64Factory = Base64Factory_.new
+ URIFactory = URIFactory_.new
+ TypedArrayFactory = TypedArrayFactory_.new
+ TypedStructFactory = TypedStructFactory_.new
+
+ HashFactory = HashFactory_.new
+
+ SOAPBaseMap = [
+ [::NilClass, ::SOAP::SOAPNil, BasetypeFactory],
+ [::TrueClass, ::SOAP::SOAPBoolean, BasetypeFactory],
+ [::FalseClass, ::SOAP::SOAPBoolean, BasetypeFactory],
+ [::String, ::SOAP::SOAPString, StringFactory],
+ [::DateTime, ::SOAP::SOAPDateTime, DateTimeFactory],
+ [::Date, ::SOAP::SOAPDate, DateTimeFactory],
+ [::Time, ::SOAP::SOAPDateTime, DateTimeFactory],
+ [::Time, ::SOAP::SOAPTime, DateTimeFactory],
+ [::Float, ::SOAP::SOAPDouble, BasetypeFactory,
+ {:derived_class => true}],
+ [::Float, ::SOAP::SOAPFloat, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPInt, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPLong, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPShort, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPByte, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPNonPositiveInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPNegativeInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPNonNegativeInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPPositiveInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedLong, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedInt, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedShort, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedByte, BasetypeFactory,
+ {:derived_class => true}],
+ [::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory,
+ {:derived_class => true}],
+ [::String, ::SOAP::SOAPBase64, Base64Factory],
+ [::String, ::SOAP::SOAPHexBinary, Base64Factory],
+ [::String, ::SOAP::SOAPDecimal, BasetypeFactory],
+ [::String, ::SOAP::SOAPDuration, BasetypeFactory],
+ [::String, ::SOAP::SOAPGYearMonth, BasetypeFactory],
+ [::String, ::SOAP::SOAPGYear, BasetypeFactory],
+ [::String, ::SOAP::SOAPGMonthDay, BasetypeFactory],
+ [::String, ::SOAP::SOAPGDay, BasetypeFactory],
+ [::String, ::SOAP::SOAPGMonth, BasetypeFactory],
+ [::String, ::SOAP::SOAPQName, BasetypeFactory],
+
+ [::Hash, ::SOAP::SOAPArray, HashFactory],
+ [::Hash, ::SOAP::SOAPStruct, HashFactory],
+
+ [::Array, ::SOAP::SOAPArray, ArrayFactory,
+ {:derived_class => true}],
+
+ [::SOAP::Mapping::SOAPException,
+ ::SOAP::SOAPStruct, TypedStructFactory,
+ {:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}],
+ ]
+
+ RubyOriginalMap = [
+ [::NilClass, ::SOAP::SOAPNil, BasetypeFactory],
+ [::TrueClass, ::SOAP::SOAPBoolean, BasetypeFactory],
+ [::FalseClass, ::SOAP::SOAPBoolean, BasetypeFactory],
+ [::String, ::SOAP::SOAPString, StringFactory],
+ [::DateTime, ::SOAP::SOAPDateTime, DateTimeFactory],
+ [::Date, ::SOAP::SOAPDate, DateTimeFactory],
+ [::Time, ::SOAP::SOAPDateTime, DateTimeFactory],
+ [::Time, ::SOAP::SOAPTime, DateTimeFactory],
+ [::Float, ::SOAP::SOAPDouble, BasetypeFactory,
+ {:derived_class => true}],
+ [::Float, ::SOAP::SOAPFloat, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPInt, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPLong, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPShort, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPByte, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPNonPositiveInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPNegativeInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPNonNegativeInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPPositiveInteger, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedLong, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedInt, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedShort, BasetypeFactory,
+ {:derived_class => true}],
+ [::Integer, ::SOAP::SOAPUnsignedByte, BasetypeFactory,
+ {:derived_class => true}],
+ [::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory,
+ {:derived_class => true}],
+ [::String, ::SOAP::SOAPBase64, Base64Factory],
+ [::String, ::SOAP::SOAPHexBinary, Base64Factory],
+ [::String, ::SOAP::SOAPDecimal, BasetypeFactory],
+ [::String, ::SOAP::SOAPDuration, BasetypeFactory],
+ [::String, ::SOAP::SOAPGYearMonth, BasetypeFactory],
+ [::String, ::SOAP::SOAPGYear, BasetypeFactory],
+ [::String, ::SOAP::SOAPGMonthDay, BasetypeFactory],
+ [::String, ::SOAP::SOAPGDay, BasetypeFactory],
+ [::String, ::SOAP::SOAPGMonth, BasetypeFactory],
+ [::String, ::SOAP::SOAPQName, BasetypeFactory],
+
+ [::Hash, ::SOAP::SOAPArray, HashFactory],
+ [::Hash, ::SOAP::SOAPStruct, HashFactory],
+
+ # Does not allow Array's subclass here.
+ [::Array, ::SOAP::SOAPArray, ArrayFactory],
+
+ [::SOAP::Mapping::SOAPException,
+ ::SOAP::SOAPStruct, TypedStructFactory,
+ {:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}],
+ ]
+
+ attr_accessor :default_factory
+ attr_accessor :excn_handler_obj2soap
+ attr_accessor :excn_handler_soap2obj
+
+ def initialize(config = {})
+ @config = config
+ @map = Map.new(self)
+ if @config[:allow_original_mapping]
+ @allow_original_mapping = true
+ @map.init(RubyOriginalMap)
+ else
+ @allow_original_mapping = false
+ @map.init(SOAPBaseMap)
+ end
+ @allow_untyped_struct = @config.key?(:allow_untyped_struct) ?
+ @config[:allow_untyped_struct] : true
+ @rubytype_factory = RubytypeFactory.new(
+ :allow_untyped_struct => @allow_untyped_struct,
+ :allow_original_mapping => @allow_original_mapping
+ )
+ @default_factory = @rubytype_factory
+ @excn_handler_obj2soap = nil
+ @excn_handler_soap2obj = nil
+ end
+
+ def add(obj_class, soap_class, factory, info = nil)
+ @map.add(obj_class, soap_class, factory, info)
+ end
+ alias set add
+
+ # general Registry ignores type_qname
+ def obj2soap(obj, type_qname = nil)
+ soap = _obj2soap(obj)
+ if @allow_original_mapping
+ addextend2soap(soap, obj)
+ end
+ soap
+ end
+
+ def soap2obj(node, klass = nil)
+ obj = _soap2obj(node, klass)
+ if @allow_original_mapping
+ addextend2obj(obj, node.extraattr[RubyExtendName])
+ addiv2obj(obj, node.extraattr[RubyIVarName])
+ end
+ obj
+ end
+
+ def find_mapped_soap_class(obj_class)
+ @map.find_mapped_soap_class(obj_class)
+ end
+
+ def find_mapped_obj_class(soap_class)
+ @map.find_mapped_obj_class(soap_class)
+ end
+
+private
+
+ def _obj2soap(obj)
+ ret = nil
+ if obj.is_a?(SOAPStruct) or obj.is_a?(SOAPArray)
+ obj.replace do |ele|
+ Mapping._obj2soap(ele, self)
+ end
+ return obj
+ elsif obj.is_a?(SOAPBasetype)
+ return obj
+ end
+ begin
+ ret = @map.obj2soap(obj) ||
+ @default_factory.obj2soap(nil, obj, nil, self)
+ return ret if ret
+ rescue MappingError
+ end
+ if @excn_handler_obj2soap
+ ret = @excn_handler_obj2soap.call(obj) { |yield_obj|
+ Mapping._obj2soap(yield_obj, self)
+ }
+ return ret if ret
+ end
+ raise MappingError.new("Cannot map #{ obj.class.name } to SOAP/OM.")
+ end
+
+ # Might return nil as a mapping result.
+ def _soap2obj(node, klass = nil)
+ if node.extraattr.key?(RubyTypeName)
+ conv, obj = @rubytype_factory.soap2obj(nil, node, nil, self)
+ return obj if conv
+ else
+ conv, obj = @map.soap2obj(node, klass)
+ return obj if conv
+ conv, obj = @default_factory.soap2obj(nil, node, nil, self)
+ return obj if conv
+ end
+ if @excn_handler_soap2obj
+ begin
+ return @excn_handler_soap2obj.call(node) { |yield_node|
+ Mapping._soap2obj(yield_node, self)
+ }
+ rescue Exception
+ end
+ end
+ raise MappingError.new("Cannot map #{ node.type.name } to Ruby object.")
+ end
+
+ def addiv2obj(obj, attr)
+ return unless attr
+ vars = {}
+ attr.__getobj__.each do |name, value|
+ vars[name] = Mapping._soap2obj(value, self)
+ end
+ Mapping.set_attributes(obj, vars)
+ end
+
+ if RUBY_VERSION >= '1.8.0'
+ def addextend2obj(obj, attr)
+ return unless attr
+ attr.split(/ /).reverse_each do |mstr|
+ obj.extend(Mapping.module_from_name(mstr))
+ end
+ end
+ else
+ # (class < false; self; end).ancestors includes "TrueClass" under 1.6...
+ def addextend2obj(obj, attr)
+ return unless attr
+ attr.split(/ /).reverse_each do |mstr|
+ m = Mapping.module_from_name(mstr)
+ obj.extend(m)
+ end
+ end
+ end
+
+ def addextend2soap(node, obj)
+ return if obj.is_a?(Symbol) or obj.is_a?(Fixnum)
+ list = (class << obj; self; end).ancestors - obj.class.ancestors
+ unless list.empty?
+ node.extraattr[RubyExtendName] = list.collect { |c|
+ if c.name.empty?
+ raise TypeError.new("singleton can't be dumped #{ obj }")
+ end
+ c.name
+ }.join(" ")
+ end
+ end
+
+end
+
+
+DefaultRegistry = Registry.new
+RubyOriginalRegistry = Registry.new(:allow_original_mapping => true)
+
+
+end
+end
diff --git a/lib/soap/mapping/rubytypeFactory.rb b/lib/soap/mapping/rubytypeFactory.rb
new file mode 100644
index 0000000000..61c21d8b20
--- /dev/null
+++ b/lib/soap/mapping/rubytypeFactory.rb
@@ -0,0 +1,475 @@
+# SOAP4R - Ruby type mapping factory.
+# Copyright (C) 2000-2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module SOAP
+module Mapping
+
+
+class RubytypeFactory < Factory
+ TYPE_STRING = XSD::QName.new(RubyTypeNamespace, 'String')
+ TYPE_TIME = XSD::QName.new(RubyTypeNamespace, 'Time')
+ TYPE_ARRAY = XSD::QName.new(RubyTypeNamespace, 'Array')
+ TYPE_REGEXP = XSD::QName.new(RubyTypeNamespace, 'Regexp')
+ TYPE_RANGE = XSD::QName.new(RubyTypeNamespace, 'Range')
+ TYPE_CLASS = XSD::QName.new(RubyTypeNamespace, 'Class')
+ TYPE_MODULE = XSD::QName.new(RubyTypeNamespace, 'Module')
+ TYPE_SYMBOL = XSD::QName.new(RubyTypeNamespace, 'Symbol')
+ TYPE_STRUCT = XSD::QName.new(RubyTypeNamespace, 'Struct')
+ TYPE_HASH = XSD::QName.new(RubyTypeNamespace, 'Map')
+
+ def initialize(config = {})
+ @config = config
+ @allow_untyped_struct = @config.key?(:allow_untyped_struct) ?
+ @config[:allow_untyped_struct] : true
+ @allow_original_mapping = @config.key?(:allow_original_mapping) ?
+ @config[:allow_original_mapping] : false
+ @string_factory = StringFactory_.new(true)
+ @basetype_factory = BasetypeFactory_.new(true)
+ @datetime_factory = DateTimeFactory_.new(true)
+ @array_factory = ArrayFactory_.new(true)
+ @hash_factory = HashFactory_.new(true)
+ end
+
+ def obj2soap(soap_class, obj, info, map)
+ param = nil
+ case obj
+ when ::String
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @string_factory.obj2soap(SOAPString, obj, info, map)
+ if obj.class != String
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ addiv2soapattr(param, obj, map)
+ when ::Time
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @datetime_factory.obj2soap(SOAPDateTime, obj, info, map)
+ if obj.class != Time
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ addiv2soapattr(param, obj, map)
+ when ::Array
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @array_factory.obj2soap(nil, obj, info, map)
+ if obj.class != Array
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ addiv2soapattr(param, obj, map)
+ when ::NilClass
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @basetype_factory.obj2soap(SOAPNil, obj, info, map)
+ addiv2soapattr(param, obj, map)
+ when ::FalseClass, ::TrueClass
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @basetype_factory.obj2soap(SOAPBoolean, obj, info, map)
+ addiv2soapattr(param, obj, map)
+ when ::Integer
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @basetype_factory.obj2soap(SOAPInt, obj, info, map)
+ param ||= @basetype_factory.obj2soap(SOAPInteger, obj, info, map)
+ param ||= @basetype_factory.obj2soap(SOAPDecimal, obj, info, map)
+ addiv2soapattr(param, obj, map)
+ when ::Float
+ unless @allow_original_mapping
+ return nil
+ end
+ param = @basetype_factory.obj2soap(SOAPDouble, obj, info, map)
+ if obj.class != Float
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ addiv2soapattr(param, obj, map)
+ when ::Hash
+ unless @allow_original_mapping
+ return nil
+ end
+ if obj.respond_to?(:default_proc) && obj.default_proc
+ raise TypeError.new("cannot dump hash with default proc")
+ end
+ param = SOAPStruct.new(TYPE_HASH)
+ mark_marshalled_obj(obj, param)
+ if obj.class != Hash
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ obj.each do |key, value|
+ elem = SOAPStruct.new # Undefined type.
+ elem.add("key", Mapping._obj2soap(key, map))
+ elem.add("value", Mapping._obj2soap(value, map))
+ param.add("item", elem)
+ end
+ param.add('default', Mapping._obj2soap(obj.default, map))
+ addiv2soapattr(param, obj, map)
+ when ::Regexp
+ unless @allow_original_mapping
+ return nil
+ end
+ param = SOAPStruct.new(TYPE_REGEXP)
+ mark_marshalled_obj(obj, param)
+ if obj.class != Regexp
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ param.add('source', SOAPBase64.new(obj.source))
+ if obj.respond_to?('options')
+ # Regexp#options is from Ruby/1.7
+ options = obj.options
+ else
+ options = 0
+ obj.inspect.sub(/^.*\//, '').each_byte do |c|
+ options += case c
+ when ?i
+ 1
+ when ?x
+ 2
+ when ?m
+ 4
+ when ?n
+ 16
+ when ?e
+ 32
+ when ?s
+ 48
+ when ?u
+ 64
+ end
+ end
+ end
+ param.add('options', SOAPInt.new(options))
+ addiv2soapattr(param, obj, map)
+ when ::Range
+ unless @allow_original_mapping
+ return nil
+ end
+ param = SOAPStruct.new(TYPE_RANGE)
+ mark_marshalled_obj(obj, param)
+ if obj.class != Range
+ param.extraattr[RubyTypeName] = obj.class.name
+ end
+ param.add('begin', Mapping._obj2soap(obj.begin, map))
+ param.add('end', Mapping._obj2soap(obj.end, map))
+ param.add('exclude_end', SOAP::SOAPBoolean.new(obj.exclude_end?))
+ addiv2soapattr(param, obj, map)
+ when ::Class
+ unless @allow_original_mapping
+ return nil
+ end
+ if obj.to_s[0] == ?#
+ raise TypeError.new("can't dump anonymous class #{obj}")
+ end
+ param = SOAPStruct.new(TYPE_CLASS)
+ mark_marshalled_obj(obj, param)
+ param.add('name', SOAPString.new(obj.name))
+ addiv2soapattr(param, obj, map)
+ when ::Module
+ unless @allow_original_mapping
+ return nil
+ end
+ if obj.to_s[0] == ?#
+ raise TypeError.new("can't dump anonymous module #{obj}")
+ end
+ param = SOAPStruct.new(TYPE_MODULE)
+ mark_marshalled_obj(obj, param)
+ param.add('name', SOAPString.new(obj.name))
+ addiv2soapattr(param, obj, map)
+ when ::Symbol
+ unless @allow_original_mapping
+ return nil
+ end
+ param = SOAPStruct.new(TYPE_SYMBOL)
+ mark_marshalled_obj(obj, param)
+ param.add('id', SOAPString.new(obj.id2name))
+ addiv2soapattr(param, obj, map)
+ when ::Struct
+ unless @allow_original_mapping
+ # treat it as an user defined class. [ruby-talk:104980]
+ #param = unknownobj2soap(soap_class, obj, info, map)
+ param = SOAPStruct.new(XSD::AnyTypeName)
+ mark_marshalled_obj(obj, param)
+ obj.members.each do |member|
+ param.add(Mapping.name2elename(member),
+ Mapping._obj2soap(obj[member], map))
+ end
+ else
+ param = SOAPStruct.new(TYPE_STRUCT)
+ mark_marshalled_obj(obj, param)
+ param.add('type', ele_type = SOAPString.new(obj.class.to_s))
+ ele_member = SOAPStruct.new
+ obj.members.each do |member|
+ ele_member.add(Mapping.name2elename(member),
+ Mapping._obj2soap(obj[member], map))
+ end
+ param.add('member', ele_member)
+ addiv2soapattr(param, obj, map)
+ end
+ when ::IO, ::Binding, ::Continuation, ::Data, ::Dir, ::File::Stat,
+ ::MatchData, Method, ::Proc, ::Thread, ::ThreadGroup
+ # from 1.8: Process::Status, UnboundMethod
+ return nil
+ when ::SOAP::Mapping::Object
+ param = SOAPStruct.new(XSD::AnyTypeName)
+ mark_marshalled_obj(obj, param)
+ obj.__xmlele.each do |key, value|
+ param.add(key.name, Mapping._obj2soap(value, map))
+ end
+ obj.__xmlattr.each do |key, value|
+ param.extraattr[key] = value
+ end
+ when ::Exception
+ typestr = Mapping.name2elename(obj.class.to_s)
+ param = SOAPStruct.new(XSD::QName.new(RubyTypeNamespace, typestr))
+ mark_marshalled_obj(obj, param)
+ param.add('message', Mapping._obj2soap(obj.message, map))
+ param.add('backtrace', Mapping._obj2soap(obj.backtrace, map))
+ addiv2soapattr(param, obj, map)
+ else
+ param = unknownobj2soap(soap_class, obj, info, map)
+ end
+ param
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ rubytype = node.extraattr[RubyTypeName]
+ if rubytype or node.type.namespace == RubyTypeNamespace
+ rubytype2obj(node, info, map, rubytype)
+ elsif node.type == XSD::AnyTypeName or node.type == XSD::AnySimpleTypeName
+ anytype2obj(node, info, map)
+ else
+ unknowntype2obj(node, info, map)
+ end
+ end
+
+private
+
+ def addiv2soapattr(node, obj, map)
+ return if obj.instance_variables.empty?
+ ivars = SOAPStruct.new # Undefined type.
+ setiv2soap(ivars, obj, map)
+ node.extraattr[RubyIVarName] = ivars
+ end
+
+ def unknownobj2soap(soap_class, obj, info, map)
+ if obj.class.name.empty?
+ raise TypeError.new("can't dump anonymous class #{obj}")
+ end
+ singleton_class = class << obj; self; end
+ if !singleton_methods_true(obj).empty? or
+ !singleton_class.instance_variables.empty?
+ raise TypeError.new("singleton can't be dumped #{obj}")
+ end
+ if !(singleton_class.ancestors - obj.class.ancestors).empty?
+ typestr = Mapping.name2elename(obj.class.to_s)
+ type = XSD::QName.new(RubyTypeNamespace, typestr)
+ else
+ type = Mapping.class2element(obj.class)
+ end
+ param = SOAPStruct.new(type)
+ mark_marshalled_obj(obj, param)
+ setiv2soap(param, obj, map)
+ param
+ end
+
+ if RUBY_VERSION >= '1.8.0'
+ def singleton_methods_true(obj)
+ obj.singleton_methods(true)
+ end
+ else
+ def singleton_methods_true(obj)
+ obj.singleton_methods
+ end
+ end
+
+ def rubytype2obj(node, info, map, rubytype)
+ klass = rubytype ? Mapping.class_from_name(rubytype) : nil
+ obj = nil
+ case node
+ when SOAPString
+ return @string_factory.soap2obj(klass || String, node, info, map)
+ when SOAPDateTime
+ #return @datetime_factory.soap2obj(klass || Time, node, info, map)
+ klass ||= Time
+ t = node.to_time
+ arg = [t.year, t.month, t.mday, t.hour, t.min, t.sec, t.usec]
+ obj = t.gmt? ? klass.gm(*arg) : klass.local(*arg)
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ when SOAPArray
+ return @array_factory.soap2obj(klass || Array, node, info, map)
+ when SOAPNil, SOAPBoolean, SOAPInt, SOAPInteger, SOAPDecimal, SOAPDouble
+ return @basetype_factory.soap2obj(nil, node, info, map)
+ when SOAPStruct
+ return rubytypestruct2obj(node, info, map, rubytype)
+ else
+ raise
+ end
+ end
+
+ def rubytypestruct2obj(node, info, map, rubytype)
+ klass = rubytype ? Mapping.class_from_name(rubytype) : nil
+ obj = nil
+ case node.type
+ when TYPE_HASH
+ klass = rubytype ? Mapping.class_from_name(rubytype) : Hash
+ obj = Mapping.create_empty_object(klass)
+ mark_unmarshalled_obj(node, obj)
+ node.each do |key, value|
+ next unless key == 'item'
+ obj[Mapping._soap2obj(value['key'], map)] =
+ Mapping._soap2obj(value['value'], map)
+ end
+ if node.key?('default')
+ obj.default = Mapping._soap2obj(node['default'], map)
+ end
+ when TYPE_REGEXP
+ klass = rubytype ? Mapping.class_from_name(rubytype) : Regexp
+ obj = Mapping.create_empty_object(klass)
+ mark_unmarshalled_obj(node, obj)
+ source = node['source'].string
+ options = node['options'].data || 0
+ Regexp.instance_method(:initialize).bind(obj).call(source, options)
+ when TYPE_RANGE
+ klass = rubytype ? Mapping.class_from_name(rubytype) : Range
+ obj = Mapping.create_empty_object(klass)
+ mark_unmarshalled_obj(node, obj)
+ first = Mapping._soap2obj(node['begin'], map)
+ last = Mapping._soap2obj(node['end'], map)
+ exclude_end = node['exclude_end'].data
+ Range.instance_method(:initialize).bind(obj).call(first, last, exclude_end)
+ when TYPE_CLASS
+ obj = Mapping.class_from_name(node['name'].data)
+ when TYPE_MODULE
+ obj = Mapping.class_from_name(node['name'].data)
+ when TYPE_SYMBOL
+ obj = node['id'].data.intern
+ when TYPE_STRUCT
+ typestr = Mapping.elename2name(node['type'].data)
+ klass = Mapping.class_from_name(typestr)
+ if klass.nil?
+ return false
+ end
+ unless klass <= ::Struct
+ return false
+ end
+ obj = Mapping.create_empty_object(klass)
+ mark_unmarshalled_obj(node, obj)
+ node['member'].each do |name, value|
+ obj[Mapping.elename2name(name)] = Mapping._soap2obj(value, map)
+ end
+ else
+ return unknowntype2obj(node, info, map)
+ end
+ return true, obj
+ end
+
+ def anytype2obj(node, info, map)
+ case node
+ when SOAPBasetype
+ return true, node.data
+ when SOAPStruct
+ klass = ::SOAP::Mapping::Object
+ obj = klass.new
+ mark_unmarshalled_obj(node, obj)
+ node.each do |name, value|
+ obj.__add_xmlele_value(XSD::QName.new(nil, name),
+ Mapping._soap2obj(value, map))
+ end
+ unless node.extraattr.empty?
+ obj.instance_variable_set('@__xmlattr', node.extraattr)
+ end
+ return true, obj
+ else
+ return false
+ end
+ end
+
+ def unknowntype2obj(node, info, map)
+ case node
+ when SOAPBasetype
+ return true, node.data
+ when SOAPArray
+ return @array_factory.soap2obj(Array, node, info, map)
+ when SOAPStruct
+ obj = unknownstruct2obj(node, info, map)
+ return true, obj if obj
+ if !@allow_untyped_struct
+ return false
+ end
+ return anytype2obj(node, info, map)
+ else
+ # Basetype which is not defined...
+ return false
+ end
+ end
+
+ def unknownstruct2obj(node, info, map)
+ unless node.type.name
+ return nil
+ end
+ typestr = Mapping.elename2name(node.type.name)
+ klass = Mapping.class_from_name(typestr)
+ if klass.nil? and @allow_untyped_struct
+ klass = Mapping.class_from_name(typestr, true) # lenient
+ end
+ if klass.nil?
+ return nil
+ end
+ if klass <= ::Exception
+ return exception2obj(klass, node, map)
+ end
+ klass_type = Mapping.class2qname(klass)
+ return nil unless node.type.match(klass_type)
+ obj = nil
+ begin
+ obj = Mapping.create_empty_object(klass)
+ rescue
+ # type name "data" tries Data.new which raises TypeError
+ nil
+ end
+ mark_unmarshalled_obj(node, obj)
+ setiv2obj(obj, node, map)
+ obj
+ end
+
+ def exception2obj(klass, node, map)
+ message = Mapping._soap2obj(node['message'], map)
+ backtrace = Mapping._soap2obj(node['backtrace'], map)
+ obj = Mapping.create_empty_object(klass)
+ obj = obj.exception(message)
+ mark_unmarshalled_obj(node, obj)
+ obj.set_backtrace(backtrace)
+ obj
+ end
+
+ # Only creates empty array. Do String#replace it with real string.
+ def array2obj(node, map, rubytype)
+ klass = rubytype ? Mapping.class_from_name(rubytype) : Array
+ obj = Mapping.create_empty_object(klass)
+ mark_unmarshalled_obj(node, obj)
+ obj
+ end
+
+ # Only creates empty string. Do String#replace it with real string.
+ def string2obj(node, map, rubytype)
+ klass = rubytype ? Mapping.class_from_name(rubytype) : String
+ obj = Mapping.create_empty_object(klass)
+ mark_unmarshalled_obj(node, obj)
+ obj
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/mapping/typeMap.rb b/lib/soap/mapping/typeMap.rb
new file mode 100644
index 0000000000..34db19a5b6
--- /dev/null
+++ b/lib/soap/mapping/typeMap.rb
@@ -0,0 +1,50 @@
+# SOAP4R - Base type mapping definition
+# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module SOAP
+
+
+TypeMap = {
+ XSD::XSDAnySimpleType::Type => SOAPAnySimpleType,
+ XSD::XSDString::Type => SOAPString,
+ XSD::XSDBoolean::Type => SOAPBoolean,
+ XSD::XSDDecimal::Type => SOAPDecimal,
+ XSD::XSDFloat::Type => SOAPFloat,
+ XSD::XSDDouble::Type => SOAPDouble,
+ XSD::XSDDuration::Type => SOAPDuration,
+ XSD::XSDDateTime::Type => SOAPDateTime,
+ XSD::XSDTime::Type => SOAPTime,
+ XSD::XSDDate::Type => SOAPDate,
+ XSD::XSDGYearMonth::Type => SOAPGYearMonth,
+ XSD::XSDGYear::Type => SOAPGYear,
+ XSD::XSDGMonthDay::Type => SOAPGMonthDay,
+ XSD::XSDGDay::Type => SOAPGDay,
+ XSD::XSDGMonth::Type => SOAPGMonth,
+ XSD::XSDHexBinary::Type => SOAPHexBinary,
+ XSD::XSDBase64Binary::Type => SOAPBase64,
+ XSD::XSDAnyURI::Type => SOAPAnyURI,
+ XSD::XSDQName::Type => SOAPQName,
+ XSD::XSDInteger::Type => SOAPInteger,
+ XSD::XSDNonPositiveInteger::Type => SOAPNonPositiveInteger,
+ XSD::XSDNegativeInteger::Type => SOAPNegativeInteger,
+ XSD::XSDLong::Type => SOAPLong,
+ XSD::XSDInt::Type => SOAPInt,
+ XSD::XSDShort::Type => SOAPShort,
+ XSD::XSDByte::Type => SOAPByte,
+ XSD::XSDNonNegativeInteger::Type => SOAPNonNegativeInteger,
+ XSD::XSDUnsignedLong::Type => SOAPUnsignedLong,
+ XSD::XSDUnsignedInt::Type => SOAPUnsignedInt,
+ XSD::XSDUnsignedShort::Type => SOAPUnsignedShort,
+ XSD::XSDUnsignedByte::Type => SOAPUnsignedByte,
+ XSD::XSDPositiveInteger::Type => SOAPPositiveInteger,
+
+ SOAP::SOAPBase64::Type => SOAPBase64,
+}
+
+
+end
diff --git a/lib/soap/mapping/wsdlencodedregistry.rb b/lib/soap/mapping/wsdlencodedregistry.rb
new file mode 100644
index 0000000000..4efb60188f
--- /dev/null
+++ b/lib/soap/mapping/wsdlencodedregistry.rb
@@ -0,0 +1,280 @@
+# SOAP4R - WSDL encoded mapping registry.
+# Copyright (C) 2000-2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'xsd/namedelements'
+require 'soap/baseData'
+require 'soap/mapping/mapping'
+require 'soap/mapping/typeMap'
+
+
+module SOAP
+module Mapping
+
+
+class WSDLEncodedRegistry < Registry
+ include TraverseSupport
+
+ attr_reader :definedelements
+ attr_reader :definedtypes
+ attr_accessor :excn_handler_obj2soap
+ attr_accessor :excn_handler_soap2obj
+
+ def initialize(definedtypes = XSD::NamedElements::Empty)
+ @definedtypes = definedtypes
+ # @definedelements = definedelements needed?
+ @excn_handler_obj2soap = nil
+ @excn_handler_soap2obj = nil
+ # For mapping AnyType element.
+ @rubytype_factory = RubytypeFactory.new(
+ :allow_untyped_struct => true,
+ :allow_original_mapping => true
+ )
+ @schema_element_cache = {}
+ end
+
+ def obj2soap(obj, qname = nil)
+ soap_obj = nil
+ if type = @definedtypes[qname]
+ soap_obj = obj2typesoap(obj, type)
+ else
+ soap_obj = any2soap(obj, qname)
+ end
+ return soap_obj if soap_obj
+ if @excn_handler_obj2soap
+ soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj|
+ Mapping._obj2soap(yield_obj, self)
+ }
+ return soap_obj if soap_obj
+ end
+ if qname
+ raise MappingError.new("cannot map #{obj.class.name} as #{qname}")
+ else
+ raise MappingError.new("cannot map #{obj.class.name} to SOAP/OM")
+ end
+ end
+
+ # map anything for now: must refer WSDL while mapping. [ToDo]
+ def soap2obj(node, obj_class = nil)
+ begin
+ return any2obj(node, obj_class)
+ rescue MappingError
+ end
+ if @excn_handler_soap2obj
+ begin
+ return @excn_handler_soap2obj.call(node) { |yield_node|
+ Mapping._soap2obj(yield_node, self)
+ }
+ rescue Exception
+ end
+ end
+ raise MappingError.new("cannot map #{node.type.name} to Ruby object")
+ end
+
+private
+
+ def any2soap(obj, qname)
+ if obj.nil?
+ SOAPNil.new
+ elsif qname.nil? or qname == XSD::AnyTypeName
+ @rubytype_factory.obj2soap(nil, obj, nil, self)
+ elsif obj.is_a?(XSD::NSDBase)
+ soap2soap(obj, qname)
+ elsif (type = TypeMap[qname])
+ base2soap(obj, type)
+ else
+ nil
+ end
+ end
+
+ def soap2soap(obj, type_qname)
+ if obj.is_a?(SOAPBasetype)
+ obj
+ elsif obj.is_a?(SOAPStruct) && (type = @definedtypes[type_qname])
+ soap_obj = obj
+ mark_marshalled_obj(obj, soap_obj)
+ elements2soap(obj, soap_obj, type.content.elements)
+ soap_obj
+ elsif obj.is_a?(SOAPArray) && (type = @definedtypes[type_qname])
+ soap_obj = obj
+ contenttype = type.child_type
+ mark_marshalled_obj(obj, soap_obj)
+ obj.replace do |ele|
+ Mapping._obj2soap(ele, self, contenttype)
+ end
+ soap_obj
+ else
+ nil
+ end
+ end
+
+ def obj2typesoap(obj, type)
+ if type.is_a?(::WSDL::XMLSchema::SimpleType)
+ simpleobj2soap(obj, type)
+ else
+ complexobj2soap(obj, type)
+ end
+ end
+
+ def simpleobj2soap(obj, type)
+ type.check_lexical_format(obj)
+ return SOAPNil.new if obj.nil? # ToDo: check nillable.
+ o = base2soap(obj, TypeMap[type.base])
+ o
+ end
+
+ def complexobj2soap(obj, type)
+ case type.compoundtype
+ when :TYPE_STRUCT
+ struct2soap(obj, type.name, type)
+ when :TYPE_ARRAY
+ array2soap(obj, type.name, type)
+ when :TYPE_MAP
+ map2soap(obj, type.name, type)
+ when :TYPE_SIMPLE
+ simpleobj2soap(obj, type.simplecontent)
+ when :TYPE_EMPTY
+ raise MappingError.new("should be empty") unless obj.nil?
+ SOAPNil.new
+ else
+ raise MappingError.new("unknown compound type: #{type.compoundtype}")
+ end
+ end
+
+ def base2soap(obj, type)
+ soap_obj = nil
+ if type <= XSD::XSDString
+ str = XSD::Charset.encoding_conv(obj.to_s,
+ Thread.current[:SOAPExternalCES], XSD::Charset.encoding)
+ soap_obj = type.new(str)
+ mark_marshalled_obj(obj, soap_obj)
+ else
+ soap_obj = type.new(obj)
+ end
+ soap_obj
+ end
+
+ def struct2soap(obj, type_qname, type)
+ return SOAPNil.new if obj.nil? # ToDo: check nillable.
+ soap_obj = SOAPStruct.new(type_qname)
+ unless obj.nil?
+ mark_marshalled_obj(obj, soap_obj)
+ elements2soap(obj, soap_obj, type.content.elements)
+ end
+ soap_obj
+ end
+
+ def array2soap(obj, type_qname, type)
+ return SOAPNil.new if obj.nil? # ToDo: check nillable.
+ arytype = type.child_type
+ soap_obj = SOAPArray.new(ValueArrayName, 1, arytype)
+ unless obj.nil?
+ mark_marshalled_obj(obj, soap_obj)
+ obj.each do |item|
+ soap_obj.add(Mapping._obj2soap(item, self, arytype))
+ end
+ end
+ soap_obj
+ end
+
+ MapKeyName = XSD::QName.new(nil, "key")
+ MapValueName = XSD::QName.new(nil, "value")
+ def map2soap(obj, type_qname, type)
+ return SOAPNil.new if obj.nil? # ToDo: check nillable.
+ keytype = type.child_type(MapKeyName) || XSD::AnyTypeName
+ valuetype = type.child_type(MapValueName) || XSD::AnyTypeName
+ soap_obj = SOAPStruct.new(MapQName)
+ unless obj.nil?
+ mark_marshalled_obj(obj, soap_obj)
+ obj.each do |key, value|
+ elem = SOAPStruct.new
+ elem.add("key", Mapping._obj2soap(key, self, keytype))
+ elem.add("value", Mapping._obj2soap(value, self, valuetype))
+ # ApacheAxis allows only 'item' here.
+ soap_obj.add("item", elem)
+ end
+ end
+ soap_obj
+ end
+
+ def elements2soap(obj, soap_obj, elements)
+ elements.each do |element|
+ name = element.name.name
+ child_obj = Mapping.get_attribute(obj, name)
+ soap_obj.add(name,
+ Mapping._obj2soap(child_obj, self, element.type || element.name))
+ end
+ end
+
+ def any2obj(node, obj_class)
+ unless obj_class
+ typestr = XSD::CodeGen::GenSupport.safeconstname(node.elename.name)
+ obj_class = Mapping.class_from_name(typestr)
+ end
+ if obj_class and obj_class.class_variables.include?('@@schema_element')
+ soap2stubobj(node, obj_class)
+ else
+ Mapping._soap2obj(node, Mapping::DefaultRegistry, obj_class)
+ end
+ end
+
+ def soap2stubobj(node, obj_class)
+ obj = Mapping.create_empty_object(obj_class)
+ unless node.is_a?(SOAPNil)
+ add_elements2stubobj(node, obj)
+ end
+ obj
+ end
+
+ def add_elements2stubobj(node, obj)
+ elements, as_array = schema_element_definition(obj.class)
+ vars = {}
+ node.each do |name, value|
+ item = elements.find { |k, v| k.name == name }
+ if item
+ elename, class_name = item
+ if klass = Mapping.class_from_name(class_name)
+ # klass must be a SOAPBasetype or a class
+ if klass.ancestors.include?(::SOAP::SOAPBasetype)
+ if value.respond_to?(:data)
+ child = klass.new(value.data).data
+ else
+ child = klass.new(nil).data
+ end
+ else
+ child = Mapping._soap2obj(value, self, klass)
+ end
+ elsif klass = Mapping.module_from_name(class_name)
+ # simpletype
+ if value.respond_to?(:data)
+ child = value.data
+ else
+ raise MappingError.new(
+ "cannot map to a module value: #{class_name}")
+ end
+ else
+ raise MappingError.new("unknown class: #{class_name}")
+ end
+ else # untyped element is treated as anyType.
+ child = Mapping._soap2obj(value, self)
+ end
+ vars[name] = child
+ end
+ Mapping.set_attributes(obj, vars)
+ end
+
+ # it caches @@schema_element. this means that @@schema_element must not be
+ # changed while a lifetime of a WSDLLiteralRegistry.
+ def schema_element_definition(klass)
+ @schema_element_cache[klass] ||= Mapping.schema_element_definition(klass)
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/mapping/wsdlliteralregistry.rb b/lib/soap/mapping/wsdlliteralregistry.rb
new file mode 100644
index 0000000000..7bb8e12203
--- /dev/null
+++ b/lib/soap/mapping/wsdlliteralregistry.rb
@@ -0,0 +1,418 @@
+# SOAP4R - WSDL literal mapping registry.
+# Copyright (C) 2004, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/baseData'
+require 'soap/mapping/mapping'
+require 'soap/mapping/typeMap'
+require 'xsd/codegen/gensupport'
+require 'xsd/namedelements'
+
+
+module SOAP
+module Mapping
+
+
+class WSDLLiteralRegistry < Registry
+ attr_reader :definedelements
+ attr_reader :definedtypes
+ attr_accessor :excn_handler_obj2soap
+ attr_accessor :excn_handler_soap2obj
+
+ def initialize(definedtypes = XSD::NamedElements::Empty,
+ definedelements = XSD::NamedElements::Empty)
+ @definedtypes = definedtypes
+ @definedelements = definedelements
+ @excn_handler_obj2soap = nil
+ @excn_handler_soap2obj = nil
+ @schema_element_cache = {}
+ @schema_attribute_cache = {}
+ end
+
+ def obj2soap(obj, qname)
+ soap_obj = nil
+ if ele = @definedelements[qname]
+ soap_obj = obj2elesoap(obj, ele)
+ elsif type = @definedtypes[qname]
+ soap_obj = obj2typesoap(obj, type, true)
+ else
+ soap_obj = any2soap(obj, qname)
+ end
+ return soap_obj if soap_obj
+ if @excn_handler_obj2soap
+ soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj|
+ Mapping.obj2soap(yield_obj, nil, nil, MAPPING_OPT)
+ }
+ return soap_obj if soap_obj
+ end
+ raise MappingError.new("cannot map #{obj.class.name} as #{qname}")
+ end
+
+ # node should be a SOAPElement
+ def soap2obj(node, obj_class = nil)
+ # obj_class is given when rpc/literal service. but ignored for now.
+ begin
+ return any2obj(node)
+ rescue MappingError
+ end
+ if @excn_handler_soap2obj
+ begin
+ return @excn_handler_soap2obj.call(node) { |yield_node|
+ Mapping.soap2obj(yield_node, nil, nil, MAPPING_OPT)
+ }
+ rescue Exception
+ end
+ end
+ if node.respond_to?(:type)
+ raise MappingError.new("cannot map #{node.type.name} to Ruby object")
+ else
+ raise MappingError.new("cannot map #{node.elename.name} to Ruby object")
+ end
+ end
+
+private
+
+ MAPPING_OPT = { :no_reference => true }
+
+ def obj2elesoap(obj, ele)
+ o = nil
+ qualified = (ele.elementform == 'qualified')
+ if ele.type
+ if type = @definedtypes[ele.type]
+ o = obj2typesoap(obj, type, qualified)
+ elsif type = TypeMap[ele.type]
+ o = base2soap(obj, type)
+ else
+ raise MappingError.new("cannot find type #{ele.type}")
+ end
+ elsif ele.local_complextype
+ o = obj2typesoap(obj, ele.local_complextype, qualified)
+ add_attributes2soap(obj, o)
+ elsif ele.local_simpletype
+ o = obj2typesoap(obj, ele.local_simpletype, qualified)
+ else
+ raise MappingError.new('illegal schema?')
+ end
+ o.elename = ele.name
+ o
+ end
+
+ def obj2typesoap(obj, type, qualified)
+ if type.is_a?(::WSDL::XMLSchema::SimpleType)
+ simpleobj2soap(obj, type)
+ else
+ complexobj2soap(obj, type, qualified)
+ end
+ end
+
+ def simpleobj2soap(obj, type)
+ type.check_lexical_format(obj)
+ return SOAPNil.new if obj.nil? # ToDo: check nillable.
+ o = base2soap(obj, TypeMap[type.base])
+ o
+ end
+
+ def complexobj2soap(obj, type, qualified)
+ o = SOAPElement.new(type.name)
+ o.qualified = qualified
+ type.each_element do |child_ele|
+ child = Mapping.get_attribute(obj, child_ele.name.name)
+ if child.nil?
+ if child_ele.nillable
+ # ToDo: test
+ # add empty element
+ child_soap = obj2elesoap(nil, child_ele)
+ o.add(child_soap)
+ elsif Integer(child_ele.minoccurs) == 0
+ # nothing to do
+ else
+ raise MappingError.new("nil not allowed: #{child_ele.name.name}")
+ end
+ elsif child_ele.map_as_array?
+ child.each do |item|
+ child_soap = obj2elesoap(item, child_ele)
+ o.add(child_soap)
+ end
+ else
+ child_soap = obj2elesoap(child, child_ele)
+ o.add(child_soap)
+ end
+ end
+ o
+ end
+
+ def any2soap(obj, qname)
+ if obj.is_a?(SOAPElement)
+ obj
+ elsif obj.class.class_variables.include?('@@schema_element')
+ stubobj2soap(obj, qname)
+ elsif obj.is_a?(SOAP::Mapping::Object)
+ mappingobj2soap(obj, qname)
+ elsif obj.is_a?(Hash)
+ ele = SOAPElement.from_obj(obj)
+ ele.elename = qname
+ ele
+ else
+ # expected to be a basetype or an anyType.
+ # SOAPStruct, etc. is used instead of SOAPElement.
+ begin
+ ele = Mapping.obj2soap(obj, nil, nil, MAPPING_OPT)
+ ele.elename = qname
+ ele
+ rescue MappingError
+ ele = SOAPElement.new(qname, obj.to_s)
+ end
+ if obj.respond_to?(:__xmlattr)
+ obj.__xmlattr.each do |key, value|
+ ele.extraattr[key] = value
+ end
+ end
+ ele
+ end
+ end
+
+ def stubobj2soap(obj, qname)
+ ele = SOAPElement.new(qname)
+ ele.qualified =
+ (obj.class.class_variables.include?('@@schema_qualified') and
+ obj.class.class_eval('@@schema_qualified'))
+ add_elements2soap(obj, ele)
+ add_attributes2soap(obj, ele)
+ ele
+ end
+
+ def mappingobj2soap(obj, qname)
+ ele = SOAPElement.new(qname)
+ obj.__xmlele.each do |key, value|
+ if value.is_a?(::Array)
+ value.each do |item|
+ ele.add(obj2soap(item, key))
+ end
+ else
+ ele.add(obj2soap(value, key))
+ end
+ end
+ obj.__xmlattr.each do |key, value|
+ ele.extraattr[key] = value
+ end
+ ele
+ end
+
+ def add_elements2soap(obj, ele)
+ elements, as_array = schema_element_definition(obj.class)
+ if elements
+ elements.each do |elename, type|
+ if child = Mapping.get_attribute(obj, elename.name)
+ if as_array.include?(elename.name)
+ child.each do |item|
+ ele.add(obj2soap(item, elename))
+ end
+ else
+ ele.add(obj2soap(child, elename))
+ end
+ elsif obj.is_a?(::Array) and as_array.include?(elename.name)
+ obj.each do |item|
+ ele.add(obj2soap(item, elename))
+ end
+ end
+ end
+ end
+ end
+
+ def add_attributes2soap(obj, ele)
+ attributes = schema_attribute_definition(obj.class)
+ if attributes
+ attributes.each do |qname, param|
+ attr = obj.__send__('xmlattr_' +
+ XSD::CodeGen::GenSupport.safevarname(qname.name))
+ ele.extraattr[qname] = attr
+ end
+ end
+ end
+
+ def base2soap(obj, type)
+ soap_obj = nil
+ if type <= XSD::XSDString
+ str = XSD::Charset.encoding_conv(obj.to_s,
+ Thread.current[:SOAPExternalCES], XSD::Charset.encoding)
+ soap_obj = type.new(str)
+ else
+ soap_obj = type.new(obj)
+ end
+ soap_obj
+ end
+
+ def anytype2obj(node)
+ if node.is_a?(::SOAP::SOAPBasetype)
+ return node.data
+ end
+ klass = ::SOAP::Mapping::Object
+ obj = klass.new
+ obj
+ end
+
+ def any2obj(node, obj_class = nil)
+ unless obj_class
+ typestr = XSD::CodeGen::GenSupport.safeconstname(node.elename.name)
+ obj_class = Mapping.class_from_name(typestr)
+ end
+ if obj_class and obj_class.class_variables.include?('@@schema_element')
+ soapele2stubobj(node, obj_class)
+ elsif node.is_a?(SOAPElement) or node.is_a?(SOAPStruct)
+ # SOAPArray for literal?
+ soapele2plainobj(node)
+ else
+ obj = Mapping.soap2obj(node, nil, obj_class, MAPPING_OPT)
+ add_attributes2plainobj(node, obj)
+ obj
+ end
+ end
+
+ def soapele2stubobj(node, obj_class)
+ obj = Mapping.create_empty_object(obj_class)
+ add_elements2stubobj(node, obj)
+ add_attributes2stubobj(node, obj)
+ obj
+ end
+
+ def soapele2plainobj(node)
+ obj = anytype2obj(node)
+ add_elements2plainobj(node, obj)
+ add_attributes2plainobj(node, obj)
+ obj
+ end
+
+ def add_elements2stubobj(node, obj)
+ elements, as_array = schema_element_definition(obj.class)
+ vars = {}
+ node.each do |name, value|
+ item = elements.find { |k, v| k.name == name }
+ if item
+ elename, class_name = item
+ if klass = Mapping.class_from_name(class_name)
+ # klass must be a SOAPBasetype or a class
+ if klass.ancestors.include?(::SOAP::SOAPBasetype)
+ if value.respond_to?(:data)
+ child = klass.new(value.data).data
+ else
+ child = klass.new(nil).data
+ end
+ else
+ child = any2obj(value, klass)
+ end
+ elsif klass = Mapping.module_from_name(class_name)
+ # simpletype
+ if value.respond_to?(:data)
+ child = value.data
+ else
+ raise MappingError.new(
+ "cannot map to a module value: #{class_name}")
+ end
+ else
+ raise MappingError.new("unknown class/module: #{class_name}")
+ end
+ else # untyped element is treated as anyType.
+ child = any2obj(value)
+ end
+ if as_array.include?(elename.name)
+ (vars[name] ||= []) << child
+ else
+ vars[name] = child
+ end
+ end
+ Mapping.set_attributes(obj, vars)
+ end
+
+ def add_attributes2stubobj(node, obj)
+ if attributes = schema_attribute_definition(obj.class)
+ define_xmlattr(obj)
+ attributes.each do |qname, class_name|
+ attr = node.extraattr[qname]
+ next if attr.nil? or attr.empty?
+ klass = Mapping.class_from_name(class_name)
+ if klass.ancestors.include?(::SOAP::SOAPBasetype)
+ child = klass.new(attr).data
+ else
+ child = attr
+ end
+ obj.__xmlattr[qname] = child
+ define_xmlattr_accessor(obj, qname)
+ end
+ end
+ end
+
+ def add_elements2plainobj(node, obj)
+ node.each do |name, value|
+ obj.__add_xmlele_value(value.elename, any2obj(value))
+ end
+ end
+
+ def add_attributes2plainobj(node, obj)
+ return if node.extraattr.empty?
+ define_xmlattr(obj)
+ node.extraattr.each do |qname, value|
+ obj.__xmlattr[qname] = value
+ define_xmlattr_accessor(obj, qname)
+ end
+ end
+
+ if RUBY_VERSION > "1.7.0"
+ def define_xmlattr_accessor(obj, qname)
+ name = XSD::CodeGen::GenSupport.safemethodname(qname.name)
+ Mapping.define_attr_accessor(obj, 'xmlattr_' + name,
+ proc { @__xmlattr[qname] },
+ proc { |value| @__xmlattr[qname] = value })
+ end
+ else
+ def define_xmlattr_accessor(obj, qname)
+ name = XSD::CodeGen::GenSupport.safemethodname(qname.name)
+ obj.instance_eval <<-EOS
+ def #{name}
+ @__xmlattr[#{qname.dump}]
+ end
+
+ def #{name}=(value)
+ @__xmlattr[#{qname.dump}] = value
+ end
+ EOS
+ end
+ end
+
+ if RUBY_VERSION > "1.7.0"
+ def define_xmlattr(obj)
+ obj.instance_variable_set('@__xmlattr', {})
+ unless obj.respond_to?(:__xmlattr)
+ Mapping.define_attr_accessor(obj, :__xmlattr, proc { @__xmlattr })
+ end
+ end
+ else
+ def define_xmlattr(obj)
+ obj.instance_variable_set('@__xmlattr', {})
+ unless obj.respond_to?(:__xmlattr)
+ obj.instance_eval <<-EOS
+ def __xmlattr
+ @__xmlattr
+ end
+ EOS
+ end
+ end
+ end
+
+ # it caches @@schema_element. this means that @@schema_element must not be
+ # changed while a lifetime of a WSDLLiteralRegistry.
+ def schema_element_definition(klass)
+ @schema_element_cache[klass] ||= Mapping.schema_element_definition(klass)
+ end
+
+ def schema_attribute_definition(klass)
+ @schema_attribute_cache[klass] ||= Mapping.schema_attribute_definition(klass)
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/marshal.rb b/lib/soap/marshal.rb
new file mode 100644
index 0000000000..1c3d5b01db
--- /dev/null
+++ b/lib/soap/marshal.rb
@@ -0,0 +1,59 @@
+# SOAP4R - Marshalling/Unmarshalling Ruby's object using SOAP Encoding.
+# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require "soap/mapping"
+require "soap/processor"
+
+
+module SOAP
+
+
+module Marshal
+ # Trying xsd:dateTime data to be recovered as aTime.
+ MarshalMappingRegistry = Mapping::Registry.new(
+ :allow_original_mapping => true)
+ MarshalMappingRegistry.add(
+ Time,
+ ::SOAP::SOAPDateTime,
+ ::SOAP::Mapping::Registry::DateTimeFactory
+ )
+
+ class << self
+ public
+ def dump(obj, io = nil)
+ marshal(obj, MarshalMappingRegistry, io)
+ end
+
+ def load(stream)
+ unmarshal(stream, MarshalMappingRegistry)
+ end
+
+ def marshal(obj, mapping_registry = MarshalMappingRegistry, io = nil)
+ elename = Mapping.name2elename(obj.class.to_s)
+ soap_obj = Mapping.obj2soap(obj, mapping_registry)
+ body = SOAPBody.new
+ body.add(elename, soap_obj)
+ env = SOAPEnvelope.new(nil, body)
+ SOAP::Processor.marshal(env, {}, io)
+ end
+
+ def unmarshal(stream, mapping_registry = MarshalMappingRegistry)
+ env = SOAP::Processor.unmarshal(stream)
+ if env.nil?
+ raise ArgumentError.new("Illegal SOAP marshal format.")
+ end
+ Mapping.soap2obj(env.body.root_node, mapping_registry)
+ end
+ end
+end
+
+
+end
+
+
+SOAPMarshal = SOAP::Marshal
diff --git a/lib/soap/mimemessage.rb b/lib/soap/mimemessage.rb
new file mode 100644
index 0000000000..acb4322e11
--- /dev/null
+++ b/lib/soap/mimemessage.rb
@@ -0,0 +1,240 @@
+# SOAP4R - MIME Message implementation.
+# Copyright (C) 2002 Jamie Herre.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/attachment'
+
+
+module SOAP
+
+
+# Classes for MIME message handling. Should be put somewhere else!
+# Tried using the 'tmail' module but found that I needed something
+# lighter in weight.
+
+
+class MIMEMessage
+ class MIMEMessageError < StandardError; end
+
+ MultipartContentType = 'multipart/\w+'
+
+ class Header
+ attr_accessor :str, :key, :root
+
+ def initialize
+ @attrs = {}
+ end
+
+ def [](key)
+ @attrs[key]
+ end
+
+ def []=(key, value)
+ @attrs[key] = value
+ end
+
+ def to_s
+ @key + ": " + @str
+ end
+ end
+
+ class Headers < Hash
+ def self.parse(str)
+ new.parse(str)
+ end
+
+ def parse(str)
+ header_cache = nil
+ str.each do |line|
+ case line
+ when /^\A[^\: \t]+:\s*.+$/
+ parse_line(header_cache) if header_cache
+ header_cache = line.sub(/\r?\n\z/, '')
+ when /^\A\s+(.*)$/
+ # a continuous line at the beginning line crashes here.
+ header_cache << line
+ else
+ raise RuntimeError.new("unexpected header: #{line.inspect}")
+ end
+ end
+ parse_line(header_cache) if header_cache
+ self
+ end
+
+ def parse_line(line)
+ if /^\A([^\: \t]+):\s*(.+)\z/ =~ line
+ header = parse_rhs($2.strip)
+ header.key = $1.strip
+ self[header.key.downcase] = header
+ else
+ raise RuntimeError.new("unexpected header line: #{line.inspect}")
+ end
+ end
+
+ def parse_rhs(str)
+ a = str.split(/;+\s+/)
+ header = Header.new
+ header.str = str
+ header.root = a.shift
+ a.each do |pair|
+ if pair =~ /(\w+)\s*=\s*"?([^"]+)"?/
+ header[$1.downcase] = $2
+ else
+ raise RuntimeError.new("unexpected header component: #{pair.inspect}")
+ end
+ end
+ header
+ end
+
+ def add(key, value)
+ if key != nil and value != nil
+ header = parse_rhs(value)
+ header.key = key
+ self[key.downcase] = header
+ end
+ end
+
+ def to_s
+ self.values.collect { |hdr|
+ hdr.to_s
+ }.join("\r\n")
+ end
+ end
+
+ class Part
+ attr_accessor :headers, :body
+
+ def initialize
+ @headers = Headers.new
+ @headers.add("Content-Transfer-Encoding", "8bit")
+ @body = nil
+ @contentid = nil
+ end
+
+ def self.parse(str)
+ new.parse(str)
+ end
+
+ def parse(str)
+ headers, body = str.split(/\r\n\r\n/s)
+ if headers != nil and body != nil
+ @headers = Headers.parse(headers)
+ @body = body.sub(/\r\n\z/, '')
+ else
+ raise RuntimeError.new("unexpected part: #{str.inspect}")
+ end
+ self
+ end
+
+ def contentid
+ if @contentid == nil and @headers.key?('content-id')
+ @contentid = @headers['content-id'].str
+ @contentid = $1 if @contentid =~ /^<(.+)>$/
+ end
+ @contentid
+ end
+
+ alias content body
+
+ def to_s
+ @headers.to_s + "\r\n\r\n" + @body
+ end
+ end
+
+ def initialize
+ @parts = []
+ @headers = Headers.new
+ @root = nil
+ end
+
+ def self.parse(head, str)
+ new.parse(head, str)
+ end
+
+ attr_reader :parts, :headers
+
+ def close
+ @headers.add(
+ "Content-Type",
+ "multipart/related; type=\"text/xml\"; boundary=\"#{boundary}\"; start=\"#{@parts[0].contentid}\""
+ )
+ end
+
+ def parse(head, str)
+ @headers = Headers.parse(head + "\r\n" + "From: jfh\r\n")
+ boundary = @headers['content-type']['boundary']
+ if boundary != nil
+ parts = str.split(/--#{Regexp.quote(boundary)}\s*(?:\r\n|--\r\n)/)
+ part = parts.shift # preamble must be ignored.
+ @parts = parts.collect { |part| Part.parse(part) }
+ else
+ @parts = [Part.parse(str)]
+ end
+ if @parts.length < 1
+ raise MIMEMessageError.new("This message contains no valid parts!")
+ end
+ self
+ end
+
+ def root
+ if @root == nil
+ start = @headers['content-type']['start']
+ @root = (start && @parts.find { |prt| prt.contentid == start }) ||
+ @parts[0]
+ end
+ @root
+ end
+
+ def boundary
+ if @boundary == nil
+ @boundary = "----=Part_" + __id__.to_s + rand.to_s
+ end
+ @boundary
+ end
+
+ def add_part(content)
+ part = Part.new
+ part.headers.add("Content-Type",
+ "text/xml; charset=" + XSD::Charset.xml_encoding_label)
+ part.headers.add("Content-ID", Attachment.contentid(part))
+ part.body = content
+ @parts.unshift(part)
+ end
+
+ def add_attachment(attach)
+ part = Part.new
+ part.headers.add("Content-Type", attach.contenttype)
+ part.headers.add("Content-ID", attach.mime_contentid)
+ part.body = attach.content
+ @parts.unshift(part)
+ end
+
+ def has_parts?
+ (@parts.length > 0)
+ end
+
+ def headers_str
+ @headers.to_s
+ end
+
+ def content_str
+ str = ''
+ @parts.each do |prt|
+ str << "--" + boundary + "\r\n"
+ str << prt.to_s + "\r\n"
+ end
+ str << '--' + boundary + "--\r\n"
+ str
+ end
+
+ def to_s
+ str = headers_str + "\r\n\r\n" + conent_str
+ end
+end
+
+
+end
diff --git a/lib/soap/netHttpClient.rb b/lib/soap/netHttpClient.rb
new file mode 100644
index 0000000000..10d68e2a4c
--- /dev/null
+++ b/lib/soap/netHttpClient.rb
@@ -0,0 +1,190 @@
+# SOAP4R - net/http wrapper
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'net/http'
+
+
+module SOAP
+
+
+class NetHttpClient
+
+ SSLEnabled = begin
+ require 'net/https'
+ true
+ rescue LoadError
+ false
+ end
+
+ attr_reader :proxy
+ attr_accessor :no_proxy
+ attr_accessor :debug_dev
+ attr_accessor :ssl_config # ignored for now.
+ attr_accessor :protocol_version # ignored for now.
+ attr_accessor :connect_timeout
+ attr_accessor :send_timeout # ignored for now.
+ attr_accessor :receive_timeout
+
+ def initialize(proxy = nil, agent = nil)
+ @proxy = proxy ? URI.parse(proxy) : nil
+ @agent = agent
+ @debug_dev = nil
+ @session_manager = SessionManager.new
+ @no_proxy = @ssl_config = @protocol_version = nil
+ @connect_timeout = @send_timeout = @receive_timeout = nil
+ end
+
+ def test_loopback_response
+ raise NotImplementedError.new("not supported for now")
+ end
+
+ def proxy=(proxy)
+ if proxy.nil?
+ @proxy = nil
+ else
+ if proxy.is_a?(URI)
+ @proxy = proxy
+ else
+ @proxy = URI.parse(proxy)
+ end
+ if @proxy.scheme == nil or @proxy.scheme.downcase != 'http' or
+ @proxy.host == nil or @proxy.port == nil
+ raise ArgumentError.new("unsupported proxy `#{proxy}'")
+ end
+ end
+ reset_all
+ @proxy
+ end
+
+ def set_basic_auth(uri, user_id, passwd)
+ # net/http does not handle url.
+ @basic_auth = [user_id, passwd]
+ raise NotImplementedError.new("basic_auth is not supported under soap4r + net/http.")
+ end
+
+ def set_cookie_store(filename)
+ raise NotImplementedError.new
+ end
+
+ def save_cookie_store(filename)
+ raise NotImplementedError.new
+ end
+
+ def reset(url)
+ # no persistent connection. ignored.
+ end
+
+ def reset_all
+ # no persistent connection. ignored.
+ end
+
+ def post(url, req_body, header = {})
+ unless url.is_a?(URI)
+ url = URI.parse(url)
+ end
+ extra = header.dup
+ extra['User-Agent'] = @agent if @agent
+ res = start(url) { |http|
+ http.post(url.request_uri, req_body, extra)
+ }
+ Response.new(res)
+ end
+
+ def get_content(url, header = {})
+ unless url.is_a?(URI)
+ url = URI.parse(url)
+ end
+ extra = header.dup
+ extra['User-Agent'] = @agent if @agent
+ res = start(url) { |http|
+ http.get(url.request_uri, extra)
+ }
+ res.body
+ end
+
+private
+
+ def start(url)
+ http = create_connection(url)
+ response = nil
+ http.start { |worker|
+ response = yield(worker)
+ worker.finish
+ }
+ @debug_dev << response.body if @debug_dev
+ response
+ end
+
+ def create_connection(url)
+ proxy_host = proxy_port = nil
+ unless no_proxy?(url)
+ proxy_host = @proxy.host
+ proxy_port = @proxy.port
+ end
+ http = Net::HTTP::Proxy(proxy_host, proxy_port).new(url.host, url.port)
+ if http.respond_to?(:set_debug_output)
+ http.set_debug_output(@debug_dev)
+ end
+ http.open_timeout = @connect_timeout if @connect_timeout
+ http.read_timeout = @receive_timeout if @receive_timeout
+ case url
+ when URI::HTTPS
+ if SSLEnabled
+ http.use_ssl = true
+ else
+ raise RuntimeError.new("Cannot connect to #{url} (OpenSSL is not installed.)")
+ end
+ when URI::HTTP
+ # OK
+ else
+ raise RuntimeError.new("Cannot connect to #{url} (Not HTTP.)")
+ end
+ http
+ end
+
+ NO_PROXY_HOSTS = ['localhost']
+
+ def no_proxy?(uri)
+ if !@proxy or NO_PROXY_HOSTS.include?(uri.host)
+ return true
+ end
+ if @no_proxy
+ @no_proxy.scan(/([^:,]*)(?::(\d+))?/) do |host, port|
+ if /(\A|\.)#{Regexp.quote(host)}\z/i =~ uri.host &&
+ (!port || uri.port == port.to_i)
+ return true
+ end
+ end
+ else
+ false
+ end
+ end
+
+ class SessionManager
+ attr_accessor :connect_timeout
+ attr_accessor :send_timeout
+ attr_accessor :receive_timeout
+ end
+
+ class Response
+ attr_reader :content
+ attr_reader :status
+ attr_reader :reason
+ attr_reader :contenttype
+
+ def initialize(res)
+ @status = res.code.to_i
+ @reason = res.message
+ @contenttype = res['content-type']
+ @content = res.body
+ end
+ end
+end
+
+
+end
diff --git a/lib/soap/parser.rb b/lib/soap/parser.rb
new file mode 100644
index 0000000000..412fd4855a
--- /dev/null
+++ b/lib/soap/parser.rb
@@ -0,0 +1,251 @@
+# SOAP4R - SOAP XML Instance Parser library.
+# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/ns'
+require 'xsd/xmlparser'
+require 'soap/soap'
+require 'soap/baseData'
+require 'soap/encodingstyle/handler'
+
+
+module SOAP
+
+
+class Parser
+ include SOAP
+
+ class ParseError < Error; end
+ class FormatDecodeError < ParseError; end
+ class UnexpectedElementError < ParseError; end
+
+private
+
+ class ParseFrame
+ attr_reader :node
+ attr_reader :name
+ attr_reader :ns, :encodingstyle
+
+ class NodeContainer
+ def initialize(node)
+ @node = node
+ end
+
+ def node
+ @node
+ end
+
+ def replace_node(node)
+ @node = node
+ end
+ end
+
+ public
+
+ def initialize(ns, name, node, encodingstyle)
+ @ns = ns
+ @name = name
+ self.node = node
+ @encodingstyle = encodingstyle
+ end
+
+ def node=(node)
+ @node = NodeContainer.new(node)
+ end
+ end
+
+public
+
+ attr_accessor :envelopenamespace
+ attr_accessor :default_encodingstyle
+ attr_accessor :decode_typemap
+ attr_accessor :allow_unqualified_element
+
+ def initialize(opt = {})
+ @opt = opt
+ @parser = XSD::XMLParser.create_parser(self, opt)
+ @parsestack = nil
+ @lastnode = nil
+ @handlers = {}
+ @envelopenamespace = opt[:envelopenamespace] || EnvelopeNamespace
+ @default_encodingstyle = opt[:default_encodingstyle] || EncodingNamespace
+ @decode_typemap = opt[:decode_typemap] || nil
+ @allow_unqualified_element = opt[:allow_unqualified_element] || false
+ end
+
+ def charset
+ @parser.charset
+ end
+
+ def parse(string_or_readable)
+ @parsestack = []
+ @lastnode = nil
+
+ @handlers.each do |uri, handler|
+ handler.decode_prologue
+ end
+
+ @parser.do_parse(string_or_readable)
+
+ unless @parsestack.empty?
+ raise FormatDecodeError.new("Unbalanced tag in XML.")
+ end
+
+ @handlers.each do |uri, handler|
+ handler.decode_epilogue
+ end
+
+ @lastnode
+ end
+
+ def start_element(name, attrs)
+ lastframe = @parsestack.last
+ ns = parent = parent_encodingstyle = nil
+ if lastframe
+ ns = lastframe.ns.clone_ns
+ parent = lastframe.node
+ parent_encodingstyle = lastframe.encodingstyle
+ else
+ ns = XSD::NS.new
+ parent = ParseFrame::NodeContainer.new(nil)
+ parent_encodingstyle = nil
+ end
+
+ attrs = XSD::XMLParser.filter_ns(ns, attrs)
+ encodingstyle = find_encodingstyle(ns, attrs)
+
+ # Children's encodingstyle is derived from its parent.
+ if encodingstyle.nil?
+ if parent.node.is_a?(SOAPHeader)
+ encodingstyle = LiteralNamespace
+ else
+ encodingstyle = parent_encodingstyle || @default_encodingstyle
+ end
+ end
+
+ node = decode_tag(ns, name, attrs, parent, encodingstyle)
+
+ @parsestack << ParseFrame.new(ns, name, node, encodingstyle)
+ end
+
+ def characters(text)
+ lastframe = @parsestack.last
+ if lastframe
+ # Need not to be cloned because character does not have attr.
+ decode_text(lastframe.ns, text, lastframe.encodingstyle)
+ else
+ # Ignore Text outside of SOAP Envelope.
+ p text if $DEBUG
+ end
+ end
+
+ def end_element(name)
+ lastframe = @parsestack.pop
+ unless name == lastframe.name
+ raise UnexpectedElementError.new("Closing element name '#{ name }' does not match with opening element '#{ lastframe.name }'.")
+ end
+ decode_tag_end(lastframe.ns, lastframe.node, lastframe.encodingstyle)
+ @lastnode = lastframe.node.node
+ end
+
+private
+
+ def find_encodingstyle(ns, attrs)
+ attrs.each do |key, value|
+ if (ns.compare(@envelopenamespace, AttrEncodingStyle, key))
+ return value
+ end
+ end
+ nil
+ end
+
+ def decode_tag(ns, name, attrs, parent, encodingstyle)
+ ele = ns.parse(name)
+
+ # Envelope based parsing.
+ if ((ele.namespace == @envelopenamespace) ||
+ (@allow_unqualified_element && ele.namespace.nil?))
+ o = decode_soap_envelope(ns, ele, attrs, parent)
+ return o if o
+ end
+
+ # Encoding based parsing.
+ handler = find_handler(encodingstyle)
+ if handler
+ return handler.decode_tag(ns, ele, attrs, parent)
+ else
+ raise FormatDecodeError.new("Unknown encodingStyle: #{ encodingstyle }.")
+ end
+ end
+
+ def decode_tag_end(ns, node, encodingstyle)
+ return unless encodingstyle
+
+ handler = find_handler(encodingstyle)
+ if handler
+ return handler.decode_tag_end(ns, node)
+ else
+ raise FormatDecodeError.new("Unknown encodingStyle: #{ encodingstyle }.")
+ end
+ end
+
+ def decode_text(ns, text, encodingstyle)
+ handler = find_handler(encodingstyle)
+
+ if handler
+ handler.decode_text(ns, text)
+ else
+ # How should I do?
+ end
+ end
+
+ def decode_soap_envelope(ns, ele, attrs, parent)
+ o = nil
+ if ele.name == EleEnvelope
+ o = SOAPEnvelope.new
+ if ext = @opt[:external_content]
+ ext.each do |k, v|
+ o.external_content[k] = v
+ end
+ end
+ elsif ele.name == EleHeader
+ unless parent.node.is_a?(SOAPEnvelope)
+ raise FormatDecodeError.new("Header should be a child of Envelope.")
+ end
+ o = SOAPHeader.new
+ parent.node.header = o
+ elsif ele.name == EleBody
+ unless parent.node.is_a?(SOAPEnvelope)
+ raise FormatDecodeError.new("Body should be a child of Envelope.")
+ end
+ o = SOAPBody.new
+ parent.node.body = o
+ elsif ele.name == EleFault
+ unless parent.node.is_a?(SOAPBody)
+ raise FormatDecodeError.new("Fault should be a child of Body.")
+ end
+ o = SOAPFault.new
+ parent.node.fault = o
+ end
+ o
+ end
+
+ def find_handler(encodingstyle)
+ unless @handlers.key?(encodingstyle)
+ handler_factory = SOAP::EncodingStyle::Handler.handler(encodingstyle) ||
+ SOAP::EncodingStyle::Handler.handler(EncodingNamespace)
+ handler = handler_factory.new(@parser.charset)
+ handler.decode_typemap = @decode_typemap
+ handler.decode_prologue
+ @handlers[encodingstyle] = handler
+ end
+ @handlers[encodingstyle]
+ end
+end
+
+
+end
diff --git a/lib/soap/processor.rb b/lib/soap/processor.rb
new file mode 100644
index 0000000000..3c6dbedf2f
--- /dev/null
+++ b/lib/soap/processor.rb
@@ -0,0 +1,66 @@
+# SOAP4R - marshal/unmarshal interface.
+# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/datatypes'
+require 'soap/soap'
+require 'soap/element'
+require 'soap/parser'
+require 'soap/generator'
+require 'soap/encodingstyle/soapHandler'
+require 'soap/encodingstyle/literalHandler'
+require 'soap/encodingstyle/aspDotNetHandler'
+
+
+module SOAP
+
+
+module Processor
+ @@default_parser_option = {}
+
+ class << self
+ public
+
+ def marshal(env, opt = {}, io = nil)
+ generator = create_generator(opt)
+ marshalled_str = generator.generate(env, io)
+ unless env.external_content.empty?
+ opt[:external_content] = env.external_content
+ end
+ marshalled_str
+ end
+
+ def unmarshal(stream, opt = {})
+ parser = create_parser(opt)
+ parser.parse(stream)
+ end
+
+ def default_parser_option=(rhs)
+ @@default_parser_option = rhs
+ end
+
+ def default_parser_option
+ @@default_parser_option
+ end
+
+ private
+
+ def create_generator(opt)
+ SOAPGenerator.new(opt)
+ end
+
+ def create_parser(opt)
+ if opt.empty?
+ opt = @@default_parser_option
+ end
+ ::SOAP::Parser.new(opt)
+ end
+ end
+end
+
+
+end
diff --git a/lib/soap/property.rb b/lib/soap/property.rb
new file mode 100644
index 0000000000..882dcc6e28
--- /dev/null
+++ b/lib/soap/property.rb
@@ -0,0 +1,333 @@
+# soap/property.rb: SOAP4R - Property implementation.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module SOAP
+
+
+# Property stream format:
+#
+# line separator is \r?\n. 1 line per a property.
+# line which begins with '#' is a comment line. empty line is ignored, too.
+# key/value separator is ':' or '='.
+# '\' as escape character. but line separator cannot be escaped.
+# \s at the head/tail of key/value are trimmed.
+#
+# '[' + key + ']' indicates property section. for example,
+#
+# [aaa.bbb]
+# ccc = ddd
+# eee.fff = ggg
+# []
+# aaa.hhh = iii
+#
+# is the same as;
+#
+# aaa.bbb.ccc = ddd
+# aaa.bbb.eee.fff = ggg
+# aaa.hhh = iii
+#
+class Property
+ FrozenError = (RUBY_VERSION >= "1.9.0") ? RuntimeError : TypeError
+
+ include Enumerable
+
+ module Util
+ def const_from_name(fqname)
+ fqname.split("::").inject(Kernel) { |klass, name| klass.const_get(name) }
+ end
+ module_function :const_from_name
+
+ def require_from_name(fqname)
+ require File.join(fqname.split("::").collect { |ele| ele.downcase })
+ end
+ module_function :require_from_name
+ end
+
+ def self.load(stream)
+ new.load(stream)
+ end
+
+ def self.loadproperty(propname)
+ new.loadproperty(propname)
+ end
+
+ def initialize
+ @store = Hash.new
+ @hook = Hash.new
+ @self_hook = Array.new
+ @locked = false
+ end
+
+ KEY_REGSRC = '([^=:\\\\]*(?:\\\\.[^=:\\\\]*)*)'
+ DEF_REGSRC = '\\s*' + KEY_REGSRC + '\\s*[=:]\\s*(.*)'
+ COMMENT_REGEXP = Regexp.new('^(?:#.*|)$')
+ CATDEF_REGEXP = Regexp.new("^\\[\\s*#{KEY_REGSRC}\\s*\\]$")
+ LINE_REGEXP = Regexp.new("^#{DEF_REGSRC}$")
+ def load(stream)
+ key_prefix = ""
+ stream.each_with_index do |line, lineno|
+ line.sub!(/\r?\n\z/, '')
+ case line
+ when COMMENT_REGEXP
+ next
+ when CATDEF_REGEXP
+ key_prefix = $1.strip
+ when LINE_REGEXP
+ key, value = $1.strip, $2.strip
+ key = "#{key_prefix}.#{key}" unless key_prefix.empty?
+ key, value = loadstr(key), loadstr(value)
+ self[key] = value
+ else
+ raise TypeError.new(
+ "property format error at line #{lineno + 1}: `#{line}'")
+ end
+ end
+ self
+ end
+
+ # find property from $:.
+ def loadproperty(propname)
+ return loadpropertyfile(propname) if File.file?(propname)
+ $:.each do |path|
+ if File.file?(file = File.join(path, propname))
+ return loadpropertyfile(file)
+ end
+ end
+ nil
+ end
+
+ # name: a Symbol, String or an Array
+ def [](name)
+ referent(name_to_a(name))
+ end
+
+ # name: a Symbol, String or an Array
+ # value: an Object
+ def []=(name, value)
+ name_pair = name_to_a(name).freeze
+ hooks = assign(name_pair, value)
+ hooks.each do |hook|
+ hook.call(name_pair, value)
+ end
+ value
+ end
+
+ # value: an Object
+ # key is generated by property
+ def <<(value)
+ self[generate_new_key] = value
+ end
+
+ # name: a Symbol, String or an Array; nil means hook to the root
+ # cascade: true/false; for cascading hook of sub key
+ # hook: block which will be called with 2 args, name and value
+ def add_hook(name = nil, cascade = false, &hook)
+ if name == nil or name == true or name == false
+ cascade = name
+ assign_self_hook(cascade, &hook)
+ else
+ assign_hook(name_to_a(name), cascade, &hook)
+ end
+ end
+
+ def each
+ @store.each do |key, value|
+ yield(key, value)
+ end
+ end
+
+ def empty?
+ @store.empty?
+ end
+
+ def keys
+ @store.keys
+ end
+
+ def values
+ @store.values
+ end
+
+ def lock(cascade = false)
+ if cascade
+ each_key do |key|
+ key.lock(cascade)
+ end
+ end
+ @locked = true
+ self
+ end
+
+ def unlock(cascade = false)
+ @locked = false
+ if cascade
+ each_key do |key|
+ key.unlock(cascade)
+ end
+ end
+ self
+ end
+
+ def locked?
+ @locked
+ end
+
+protected
+
+ def deref_key(key)
+ check_lock(key)
+ ref = @store[key] ||= self.class.new
+ unless propkey?(ref)
+ raise ArgumentError.new("key `#{key}' already defined as a value")
+ end
+ ref
+ end
+
+ def local_referent(key)
+ check_lock(key)
+ if propkey?(@store[key]) and @store[key].locked?
+ raise FrozenError.new("cannot split any key from locked property")
+ end
+ @store[key]
+ end
+
+ def local_assign(key, value)
+ check_lock(key)
+ if @locked
+ if propkey?(value)
+ raise FrozenError.new("cannot add any key to locked property")
+ elsif propkey?(@store[key])
+ raise FrozenError.new("cannot override any key in locked property")
+ end
+ end
+ @store[key] = value
+ end
+
+ def local_hook(key, direct)
+ hooks = []
+ (@self_hook + (@hook[key] || NO_HOOK)).each do |hook, cascade|
+ hooks << hook if direct or cascade
+ end
+ hooks
+ end
+
+ def local_assign_hook(key, cascade, &hook)
+ check_lock(key)
+ @store[key] ||= nil
+ (@hook[key] ||= []) << [hook, cascade]
+ end
+
+private
+
+ NO_HOOK = [].freeze
+
+ def referent(ary)
+ ary[0..-2].inject(self) { |ref, name|
+ ref.deref_key(to_key(name))
+ }.local_referent(to_key(ary.last))
+ end
+
+ def assign(ary, value)
+ ref = self
+ hook = NO_HOOK
+ ary[0..-2].each do |name|
+ key = to_key(name)
+ hook += ref.local_hook(key, false)
+ ref = ref.deref_key(key)
+ end
+ last_key = to_key(ary.last)
+ ref.local_assign(last_key, value)
+ hook + ref.local_hook(last_key, true)
+ end
+
+ def assign_hook(ary, cascade, &hook)
+ ary[0..-2].inject(self) { |ref, name|
+ ref.deref_key(to_key(name))
+ }.local_assign_hook(to_key(ary.last), cascade, &hook)
+ end
+
+ def assign_self_hook(cascade, &hook)
+ check_lock(nil)
+ @self_hook << [hook, cascade]
+ end
+
+ def each_key
+ self.each do |key, value|
+ if propkey?(value)
+ yield(value)
+ end
+ end
+ end
+
+ def check_lock(key)
+ if @locked and (key.nil? or !@store.key?(key))
+ raise FrozenError.new("cannot add any key to locked property")
+ end
+ end
+
+ def propkey?(value)
+ value.is_a?(::SOAP::Property)
+ end
+
+ def name_to_a(name)
+ case name
+ when Symbol
+ [name]
+ when String
+ name.scan(/[^.\\]+(?:\\.[^.\\])*/) # split with unescaped '.'
+ when Array
+ name
+ else
+ raise ArgumentError.new("Unknown name #{name}(#{name.class})")
+ end
+ end
+
+ def to_key(name)
+ name.to_s.downcase
+ end
+
+ def generate_new_key
+ if @store.empty?
+ "0"
+ else
+ (key_max + 1).to_s
+ end
+ end
+
+ def key_max
+ (@store.keys.max { |l, r| l.to_s.to_i <=> r.to_s.to_i }).to_s.to_i
+ end
+
+ def loadpropertyfile(file)
+ puts "find property at #{file}" if $DEBUG
+ File.open(file) do |f|
+ load(f)
+ end
+ end
+
+ def loadstr(str)
+ str.gsub(/\\./) { |c| eval("\"#{c}\"") }
+ end
+end
+
+
+end
+
+
+# for ruby/1.6.
+unless Enumerable.instance_methods.include?('inject')
+ module Enumerable
+ def inject(init)
+ result = init
+ each do |item|
+ result = yield(result, item)
+ end
+ result
+ end
+ end
+end
diff --git a/lib/soap/rpc/cgistub.rb b/lib/soap/rpc/cgistub.rb
new file mode 100644
index 0000000000..487f05a9bf
--- /dev/null
+++ b/lib/soap/rpc/cgistub.rb
@@ -0,0 +1,206 @@
+# SOAP4R - CGI/mod_ruby stub library
+# Copyright (C) 2001, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/streamHandler'
+require 'webrick/httpresponse'
+require 'webrick/httpstatus'
+require 'logger'
+require 'soap/rpc/soaplet'
+
+
+module SOAP
+module RPC
+
+
+###
+# SYNOPSIS
+# CGIStub.new
+#
+# DESCRIPTION
+# To be written...
+#
+class CGIStub < Logger::Application
+ include SOAP
+ include WEBrick
+
+ class SOAPRequest
+ attr_reader :body
+
+ def [](var); end
+
+ def meta_vars; end
+ end
+
+ class SOAPStdinRequest < SOAPRequest
+ attr_reader :body
+
+ def initialize(stream)
+ size = ENV['CONTENT_LENGTH'].to_i || 0
+ @body = stream.read(size)
+ end
+
+ def [](var)
+ ENV[var.gsub(/-/, '_').upcase]
+ end
+
+ def meta_vars
+ {
+ 'HTTP_SOAPACTION' => ENV['HTTP_SOAPAction']
+ }
+ end
+ end
+
+ class SOAPFCGIRequest < SOAPRequest
+ attr_reader :body
+
+ def initialize(request)
+ @request = request
+ @body = @request.in.read
+ end
+
+ def [](var)
+ @request.env[var.gsub(/-/, '_').upcase]
+ end
+
+ def meta_vars
+ {
+ 'HTTP_SOAPACTION' => @request.env['HTTP_SOAPAction']
+ }
+ end
+ end
+
+ def initialize(appname, default_namespace)
+ super(appname)
+ set_log(STDERR)
+ self.level = ERROR
+ @default_namespace = default_namespace
+ @remote_host = ENV['REMOTE_HOST'] || ENV['REMOTE_ADDR'] || 'unknown'
+ @router = ::SOAP::RPC::Router.new(self.class.name)
+ @soaplet = ::SOAP::RPC::SOAPlet.new(@router)
+ on_init
+ end
+
+ def on_init
+ # do extra initialization in a derived class if needed.
+ end
+
+ def mapping_registry
+ @router.mapping_registry
+ end
+
+ def mapping_registry=(value)
+ @router.mapping_registry = value
+ end
+
+ def generate_explicit_type
+ @router.generate_explicit_type
+ end
+
+ def generate_explicit_type=(generate_explicit_type)
+ @router.generate_explicit_type = generate_explicit_type
+ end
+
+ # servant entry interface
+
+ def add_rpc_servant(obj, namespace = @default_namespace)
+ @router.add_rpc_servant(obj, namespace)
+ end
+ alias add_servant add_rpc_servant
+
+ def add_headerhandler(obj)
+ @router.add_headerhandler(obj)
+ end
+ alias add_rpc_headerhandler add_headerhandler
+
+ # method entry interface
+
+ def add_rpc_method(obj, name, *param)
+ add_rpc_method_with_namespace_as(@default_namespace, obj, name, name, *param)
+ end
+ alias add_method add_rpc_method
+
+ def add_rpc_method_as(obj, name, name_as, *param)
+ add_rpc_method_with_namespace_as(@default_namespace, obj, name, name_as, *param)
+ end
+ alias add_method_as add_rpc_method_as
+
+ def add_rpc_method_with_namespace(namespace, obj, name, *param)
+ add_rpc_method_with_namespace_as(namespace, obj, name, name, *param)
+ end
+ alias add_method_with_namespace add_rpc_method_with_namespace
+
+ def add_rpc_method_with_namespace_as(namespace, obj, name, name_as, *param)
+ qname = XSD::QName.new(namespace, name_as)
+ soapaction = nil
+ param_def = SOAPMethod.derive_rpc_param_def(obj, name, *param)
+ @router.add_rpc_operation(obj, qname, soapaction, name, param_def)
+ end
+ alias add_method_with_namespace_as add_rpc_method_with_namespace_as
+
+ def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
+ @router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
+ end
+
+ def add_document_operation(receiver, soapaction, name, param_def, opt = {})
+ @router.add_document_operation(receiver, soapaction, name, param_def, opt)
+ end
+
+ def set_fcgi_request(request)
+ @fcgi = request
+ end
+
+private
+
+ HTTPVersion = WEBrick::HTTPVersion.new('1.0') # dummy; ignored
+
+ def run
+ res = WEBrick::HTTPResponse.new({:HTTPVersion => HTTPVersion})
+ begin
+ @log.info { "received a request from '#{ @remote_host }'" }
+ if @fcgi
+ req = SOAPFCGIRequest.new(@fcgi)
+ else
+ req = SOAPStdinRequest.new($stdin)
+ end
+ @soaplet.do_POST(req, res)
+ rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
+ res.set_error(ex)
+ rescue HTTPStatus::Error => ex
+ res.set_error(ex)
+ rescue HTTPStatus::Status => ex
+ res.status = ex.code
+ rescue StandardError, NameError => ex # for Ruby 1.6
+ res.set_error(ex, true)
+ ensure
+ if defined?(MOD_RUBY)
+ r = Apache.request
+ r.status = res.status
+ r.content_type = res.content_type
+ r.send_http_header
+ buf = res.body
+ else
+ buf = ''
+ res.send_response(buf)
+ buf.sub!(/^[^\r]+\r\n/, '') # Trim status line.
+ end
+ @log.debug { "SOAP CGI Response:\n#{ buf }" }
+ if @fcgi
+ @fcgi.out.print buf
+ @fcgi.finish
+ @fcgi = nil
+ else
+ print buf
+ end
+ end
+ 0
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/driver.rb b/lib/soap/rpc/driver.rb
new file mode 100644
index 0000000000..0fb4e82488
--- /dev/null
+++ b/lib/soap/rpc/driver.rb
@@ -0,0 +1,254 @@
+# SOAP4R - SOAP RPC driver
+# Copyright (C) 2000, 2001, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/soap'
+require 'soap/mapping'
+require 'soap/mapping/wsdlliteralregistry'
+require 'soap/rpc/rpc'
+require 'soap/rpc/proxy'
+require 'soap/rpc/element'
+require 'soap/streamHandler'
+require 'soap/property'
+require 'soap/header/handlerset'
+
+
+module SOAP
+module RPC
+
+
+class Driver
+ class << self
+ if RUBY_VERSION >= "1.7.0"
+ def __attr_proxy(symbol, assignable = false)
+ name = symbol.to_s
+ define_method(name) {
+ @proxy.__send__(name)
+ }
+ if assignable
+ aname = name + '='
+ define_method(aname) { |rhs|
+ @proxy.__send__(aname, rhs)
+ }
+ end
+ end
+ else
+ def __attr_proxy(symbol, assignable = false)
+ name = symbol.to_s
+ module_eval <<-EOS
+ def #{name}
+ @proxy.#{name}
+ end
+ EOS
+ if assignable
+ module_eval <<-EOS
+ def #{name}=(value)
+ @proxy.#{name} = value
+ end
+ EOS
+ end
+ end
+ end
+ end
+
+ __attr_proxy :endpoint_url, true
+ __attr_proxy :mapping_registry, true
+ __attr_proxy :default_encodingstyle, true
+ __attr_proxy :generate_explicit_type, true
+ __attr_proxy :allow_unqualified_element, true
+ __attr_proxy :headerhandler
+ __attr_proxy :streamhandler
+ __attr_proxy :test_loopback_response
+ __attr_proxy :reset_stream
+
+ attr_reader :proxy
+ attr_reader :options
+ attr_accessor :soapaction
+
+ def inspect
+ "#<#{self.class}:#{@proxy.inspect}>"
+ end
+
+ def httpproxy
+ options["protocol.http.proxy"]
+ end
+
+ def httpproxy=(httpproxy)
+ options["protocol.http.proxy"] = httpproxy
+ end
+
+ def wiredump_dev
+ options["protocol.http.wiredump_dev"]
+ end
+
+ def wiredump_dev=(wiredump_dev)
+ options["protocol.http.wiredump_dev"] = wiredump_dev
+ end
+
+ def mandatorycharset
+ options["protocol.mandatorycharset"]
+ end
+
+ def mandatorycharset=(mandatorycharset)
+ options["protocol.mandatorycharset"] = mandatorycharset
+ end
+
+ def wiredump_file_base
+ options["protocol.wiredump_file_base"]
+ end
+
+ def wiredump_file_base=(wiredump_file_base)
+ options["protocol.wiredump_file_base"] = wiredump_file_base
+ end
+
+ def initialize(endpoint_url, namespace = nil, soapaction = nil)
+ @namespace = namespace
+ @soapaction = soapaction
+ @options = setup_options
+ @wiredump_file_base = nil
+ @proxy = Proxy.new(endpoint_url, @soapaction, @options)
+ end
+
+ def loadproperty(propertyname)
+ unless options.loadproperty(propertyname)
+ raise LoadError.new("No such property to load -- #{propertyname}")
+ end
+ end
+
+ def add_rpc_method(name, *params)
+ add_rpc_method_with_soapaction_as(name, name, @soapaction, *params)
+ end
+
+ def add_rpc_method_as(name, name_as, *params)
+ add_rpc_method_with_soapaction_as(name, name_as, @soapaction, *params)
+ end
+
+ def add_rpc_method_with_soapaction(name, soapaction, *params)
+ add_rpc_method_with_soapaction_as(name, name, soapaction, *params)
+ end
+
+ def add_rpc_method_with_soapaction_as(name, name_as, soapaction, *params)
+ param_def = SOAPMethod.create_rpc_param_def(params)
+ qname = XSD::QName.new(@namespace, name_as)
+ @proxy.add_rpc_method(qname, soapaction, name, param_def)
+ add_rpc_method_interface(name, param_def)
+ end
+
+ # add_method is for shortcut of typical rpc/encoded method definition.
+ alias add_method add_rpc_method
+ alias add_method_as add_rpc_method_as
+ alias add_method_with_soapaction add_rpc_method_with_soapaction
+ alias add_method_with_soapaction_as add_rpc_method_with_soapaction_as
+
+ def add_document_method(name, soapaction, req_qname, res_qname)
+ param_def = SOAPMethod.create_doc_param_def(req_qname, res_qname)
+ @proxy.add_document_method(soapaction, name, param_def)
+ add_document_method_interface(name, param_def)
+ end
+
+ def add_rpc_operation(qname, soapaction, name, param_def, opt = {})
+ @proxy.add_rpc_operation(qname, soapaction, name, param_def, opt)
+ add_rpc_method_interface(name, param_def)
+ end
+
+ def add_document_operation(soapaction, name, param_def, opt = {})
+ @proxy.add_document_operation(soapaction, name, param_def, opt)
+ add_document_method_interface(name, param_def)
+ end
+
+ def invoke(headers, body)
+ if headers and !headers.is_a?(SOAPHeader)
+ headers = create_header(headers)
+ end
+ set_wiredump_file_base(body.elename.name)
+ env = @proxy.invoke(headers, body)
+ if env.nil?
+ return nil, nil
+ else
+ return env.header, env.body
+ end
+ end
+
+ def call(name, *params)
+ set_wiredump_file_base(name)
+ @proxy.call(name, *params)
+ end
+
+private
+
+ def set_wiredump_file_base(name)
+ if @wiredump_file_base
+ @proxy.set_wiredump_file_base("#{@wiredump_file_base}_#{name}")
+ end
+ end
+
+ def create_header(headers)
+ header = SOAPHeader.new()
+ headers.each do |content, mustunderstand, encodingstyle|
+ header.add(SOAPHeaderItem.new(content, mustunderstand, encodingstyle))
+ end
+ header
+ end
+
+ def setup_options
+ if opt = Property.loadproperty(::SOAP::PropertyName)
+ opt = opt["client"]
+ end
+ opt ||= Property.new
+ opt.add_hook("protocol.mandatorycharset") do |key, value|
+ @proxy.mandatorycharset = value
+ end
+ opt.add_hook("protocol.wiredump_file_base") do |key, value|
+ @wiredump_file_base = value
+ end
+ opt["protocol.http.charset"] ||= XSD::Charset.xml_encoding_label
+ opt["protocol.http.proxy"] ||= Env::HTTP_PROXY
+ opt["protocol.http.no_proxy"] ||= Env::NO_PROXY
+ opt
+ end
+
+ def add_rpc_method_interface(name, param_def)
+ param_count = RPC::SOAPMethod.param_count(param_def,
+ RPC::SOAPMethod::IN, RPC::SOAPMethod::INOUT)
+ add_method_interface(name, param_count)
+ end
+
+ def add_document_method_interface(name, param_def)
+ param_count = RPC::SOAPMethod.param_count(param_def, RPC::SOAPMethod::IN)
+ add_method_interface(name, param_count)
+ end
+
+ if RUBY_VERSION > "1.7.0"
+ def add_method_interface(name, param_count)
+ ::SOAP::Mapping.define_singleton_method(self, name) do |*arg|
+ unless arg.size == param_count
+ raise ArgumentError.new(
+ "wrong number of arguments (#{arg.size} for #{param_count})")
+ end
+ call(name, *arg)
+ end
+ self.method(name)
+ end
+ else
+ def add_method_interface(name, param_count)
+ instance_eval <<-EOS
+ def #{name}(*arg)
+ unless arg.size == #{param_count}
+ raise ArgumentError.new(
+ "wrong number of arguments (\#{arg.size} for #{param_count})")
+ end
+ call(#{name.dump}, *arg)
+ end
+ EOS
+ self.method(name)
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/element.rb b/lib/soap/rpc/element.rb
new file mode 100644
index 0000000000..c224b03d0d
--- /dev/null
+++ b/lib/soap/rpc/element.rb
@@ -0,0 +1,325 @@
+# SOAP4R - RPC element definition.
+# Copyright (C) 2000, 2001, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/baseData'
+
+
+module SOAP
+
+# Add method definitions for RPC to common definition in element.rb
+class SOAPBody < SOAPStruct
+ public
+
+ def request
+ root_node
+ end
+
+ def response
+ root = root_node
+ if !@is_fault
+ if root.nil?
+ nil
+ elsif root.is_a?(SOAPBasetype)
+ root
+ else
+ # Initial element is [retval].
+ root[0]
+ end
+ else
+ root
+ end
+ end
+
+ def outparams
+ root = root_node
+ if !@is_fault and !root.nil? and !root.is_a?(SOAPBasetype)
+ op = root[1..-1]
+ op = nil if op && op.empty?
+ op
+ else
+ nil
+ end
+ end
+
+ def fault
+ if @is_fault
+ self['fault']
+ else
+ nil
+ end
+ end
+
+ def fault=(fault)
+ @is_fault = true
+ add_member('fault', fault)
+ end
+end
+
+
+module RPC
+
+
+class RPCError < Error; end
+class MethodDefinitionError < RPCError; end
+class ParameterError < RPCError; end
+
+class SOAPMethod < SOAPStruct
+ RETVAL = 'retval'
+ IN = 'in'
+ OUT = 'out'
+ INOUT = 'inout'
+
+ attr_reader :param_def
+ attr_reader :inparam
+ attr_reader :outparam
+ attr_reader :retval_name
+ attr_reader :retval_class_name
+
+ def initialize(qname, param_def = nil)
+ super(nil)
+ @elename = qname
+ @encodingstyle = nil
+
+ @param_def = param_def
+
+ @signature = []
+ @inparam_names = []
+ @inoutparam_names = []
+ @outparam_names = []
+
+ @inparam = {}
+ @outparam = {}
+ @retval_name = nil
+ @retval_class_name = nil
+
+ init_param(@param_def) if @param_def
+ end
+
+ def have_outparam?
+ @outparam_names.size > 0
+ end
+
+ def input_params
+ collect_params(IN, INOUT)
+ end
+
+ def output_params
+ collect_params(OUT, INOUT)
+ end
+
+ def set_param(params)
+ params.each do |param, data|
+ @inparam[param] = data
+ data.elename.name = param
+ data.parent = self
+ end
+ end
+
+ def set_outparam(params)
+ params.each do |param, data|
+ @outparam[param] = data
+ data.elename.name = param
+ end
+ end
+
+ def SOAPMethod.param_count(param_def, *type)
+ count = 0
+ param_def.each do |io_type, name, param_type|
+ if type.include?(io_type)
+ count += 1
+ end
+ end
+ count
+ end
+
+ def SOAPMethod.derive_rpc_param_def(obj, name, *param)
+ if param.size == 1 and param[0].is_a?(Array)
+ return param[0]
+ end
+ if param.empty?
+ method = obj.method(name)
+ param_names = (1..method.arity.abs).collect { |i| "p#{i}" }
+ else
+ param_names = param
+ end
+ create_rpc_param_def(param_names)
+ end
+
+ def SOAPMethod.create_rpc_param_def(param_names)
+ param_def = []
+ param_names.each do |param_name|
+ param_def.push([IN, param_name, nil])
+ end
+ param_def.push([RETVAL, 'return', nil])
+ param_def
+ end
+
+ def SOAPMethod.create_doc_param_def(req_qnames, res_qnames)
+ req_qnames = [req_qnames] if req_qnames.is_a?(XSD::QName)
+ res_qnames = [res_qnames] if res_qnames.is_a?(XSD::QName)
+ param_def = []
+ req_qnames.each do |qname|
+ param_def << [IN, qname.name, [nil, qname.namespace, qname.name]]
+ end
+ res_qnames.each do |qname|
+ param_def << [OUT, qname.name, [nil, qname.namespace, qname.name]]
+ end
+ param_def
+ end
+
+private
+
+ def collect_params(*type)
+ names = []
+ @signature.each do |io_type, name, param_type|
+ names << name if type.include?(io_type)
+ end
+ names
+ end
+
+ def init_param(param_def)
+ param_def.each do |io_type, name, param_type|
+ case io_type
+ when IN
+ @signature.push([IN, name, param_type])
+ @inparam_names.push(name)
+ when OUT
+ @signature.push([OUT, name, param_type])
+ @outparam_names.push(name)
+ when INOUT
+ @signature.push([INOUT, name, param_type])
+ @inoutparam_names.push(name)
+ when RETVAL
+ if @retval_name
+ raise MethodDefinitionError.new('duplicated retval')
+ end
+ @retval_name = name
+ @retval_class_name = nil
+ if param_type
+ if param_type[0].is_a?(String)
+ @retval_class_name = Mapping.class_from_name(param_type[0])
+ else
+ @retval_class_name = param_type[0]
+ end
+ end
+ else
+ raise MethodDefinitionError.new("unknown type: #{io_type}")
+ end
+ end
+ end
+end
+
+
+class SOAPMethodRequest < SOAPMethod
+ attr_accessor :soapaction
+
+ def SOAPMethodRequest.create_request(qname, *params)
+ param_def = []
+ param_value = []
+ i = 0
+ params.each do |param|
+ param_name = "p#{i}"
+ i += 1
+ param_def << [IN, param_name, nil]
+ param_value << [param_name, param]
+ end
+ param_def << [RETVAL, 'return', nil]
+ o = new(qname, param_def)
+ o.set_param(param_value)
+ o
+ end
+
+ def initialize(qname, param_def = nil, soapaction = nil)
+ check_elename(qname)
+ super(qname, param_def)
+ @soapaction = soapaction
+ end
+
+ def each
+ input_params.each do |name|
+ unless @inparam[name]
+ raise ParameterError.new("parameter: #{name} was not given")
+ end
+ yield(name, @inparam[name])
+ end
+ end
+
+ def dup
+ req = self.class.new(@elename.dup, @param_def, @soapaction)
+ req.encodingstyle = @encodingstyle
+ req
+ end
+
+ def create_method_response(response_name = nil)
+ response_name ||=
+ XSD::QName.new(@elename.namespace, @elename.name + 'Response')
+ SOAPMethodResponse.new(response_name, @param_def)
+ end
+
+private
+
+ def check_elename(qname)
+ # NCName & ruby's method name
+ unless /\A[\w_][\w\d_\-]*\z/ =~ qname.name
+ raise MethodDefinitionError.new("element name '#{qname.name}' not allowed")
+ end
+ end
+end
+
+
+class SOAPMethodResponse < SOAPMethod
+
+ def initialize(qname, param_def = nil)
+ super(qname, param_def)
+ @retval = nil
+ end
+
+ def retval=(retval)
+ @retval = retval
+ @retval.elename = @retval.elename.dup_name(@retval_name || 'return')
+ retval.parent = self
+ retval
+ end
+
+ def each
+ if @retval_name and !@retval.is_a?(SOAPVoid)
+ yield(@retval_name, @retval)
+ end
+
+ output_params.each do |name|
+ unless @outparam[name]
+ raise ParameterError.new("parameter: #{name} was not given")
+ end
+ yield(name, @outparam[name])
+ end
+ end
+end
+
+
+# To return(?) void explicitly.
+# def foo(input_var)
+# ...
+# return SOAP::RPC::SOAPVoid.new
+# end
+class SOAPVoid < XSD::XSDAnySimpleType
+ include SOAPBasetype
+ extend SOAPModuleUtils
+ Name = XSD::QName.new(Mapping::RubyCustomTypeNamespace, nil)
+
+public
+ def initialize()
+ @elename = Name
+ @id = nil
+ @precedents = []
+ @parent = nil
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/httpserver.rb b/lib/soap/rpc/httpserver.rb
new file mode 100644
index 0000000000..6d2a72ebe3
--- /dev/null
+++ b/lib/soap/rpc/httpserver.rb
@@ -0,0 +1,129 @@
+# SOAP4R - WEBrick HTTP Server
+# Copyright (C) 2003, 2004 by NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'logger'
+require 'soap/rpc/soaplet'
+require 'soap/streamHandler'
+require 'webrick'
+
+
+module SOAP
+module RPC
+
+
+class HTTPServer < Logger::Application
+ attr_reader :server
+ attr_accessor :default_namespace
+
+ def initialize(config)
+ super(config[:SOAPHTTPServerApplicationName] || self.class.name)
+ @default_namespace = config[:SOAPDefaultNamespace]
+ @webrick_config = config.dup
+ self.level = Logger::Severity::ERROR # keep silent by default
+ @webrick_config[:Logger] ||= @log
+ @log = @webrick_config[:Logger] # sync logger of App and HTTPServer
+ @router = ::SOAP::RPC::Router.new(self.class.name)
+ @soaplet = ::SOAP::RPC::SOAPlet.new(@router)
+ on_init
+ @server = WEBrick::HTTPServer.new(@webrick_config)
+ @server.mount('/', @soaplet)
+ end
+
+ def on_init
+ # do extra initialization in a derived class if needed.
+ end
+
+ def status
+ @server.status if @server
+ end
+
+ def shutdown
+ @server.shutdown if @server
+ end
+
+ def mapping_registry
+ @router.mapping_registry
+ end
+
+ def mapping_registry=(mapping_registry)
+ @router.mapping_registry = mapping_registry
+ end
+
+ def generate_explicit_type
+ @router.generate_explicit_type
+ end
+
+ def generate_explicit_type=(generate_explicit_type)
+ @router.generate_explicit_type = generate_explicit_type
+ end
+
+ # servant entry interface
+
+ def add_rpc_request_servant(factory, namespace = @default_namespace)
+ @router.add_rpc_request_servant(factory, namespace)
+ end
+
+ def add_rpc_servant(obj, namespace = @default_namespace)
+ @router.add_rpc_servant(obj, namespace)
+ end
+
+ def add_request_headerhandler(factory)
+ @router.add_request_headerhandler(factory)
+ end
+
+ def add_headerhandler(obj)
+ @router.add_headerhandler(obj)
+ end
+ alias add_rpc_headerhandler add_headerhandler
+
+ # method entry interface
+
+ def add_rpc_method(obj, name, *param)
+ add_rpc_method_as(obj, name, name, *param)
+ end
+ alias add_method add_rpc_method
+
+ def add_rpc_method_as(obj, name, name_as, *param)
+ qname = XSD::QName.new(@default_namespace, name_as)
+ soapaction = nil
+ param_def = SOAPMethod.derive_rpc_param_def(obj, name, *param)
+ @router.add_rpc_operation(obj, qname, soapaction, name, param_def)
+ end
+ alias add_method_as add_rpc_method_as
+
+ def add_document_method(obj, soapaction, name, req_qnames, res_qnames)
+ param_def = SOAPMethod.create_doc_param_def(req_qnames, res_qnames)
+ @router.add_document_operation(obj, soapaction, name, param_def)
+ end
+
+ def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
+ @router.add_rpc_operation(receiver, qname, soapaction, name, param_def, opt)
+ end
+
+ def add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {})
+ @router.add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt)
+ end
+
+ def add_document_operation(receiver, soapaction, name, param_def, opt = {})
+ @router.add_document_operation(receiver, soapaction, name, param_def, opt)
+ end
+
+ def add_document_request_operation(factory, soapaction, name, param_def, opt = {})
+ @router.add_document_request_operation(factory, soapaction, name, param_def, opt)
+ end
+
+private
+
+ def run
+ @server.start
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/proxy.rb b/lib/soap/rpc/proxy.rb
new file mode 100644
index 0000000000..7dfda62006
--- /dev/null
+++ b/lib/soap/rpc/proxy.rb
@@ -0,0 +1,497 @@
+# SOAP4R - RPC Proxy library.
+# Copyright (C) 2000, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/soap'
+require 'soap/processor'
+require 'soap/mapping'
+require 'soap/rpc/rpc'
+require 'soap/rpc/element'
+require 'soap/streamHandler'
+require 'soap/mimemessage'
+
+
+module SOAP
+module RPC
+
+
+class Proxy
+ include SOAP
+
+public
+
+ attr_accessor :soapaction
+ attr_accessor :mandatorycharset
+ attr_accessor :allow_unqualified_element
+ attr_accessor :default_encodingstyle
+ attr_accessor :generate_explicit_type
+ attr_reader :headerhandler
+ attr_reader :streamhandler
+
+ attr_accessor :mapping_registry
+ attr_accessor :literal_mapping_registry
+
+ attr_reader :operation
+
+ def initialize(endpoint_url, soapaction, options)
+ @endpoint_url = endpoint_url
+ @soapaction = soapaction
+ @options = options
+ @streamhandler = HTTPStreamHandler.new(
+ @options["protocol.http"] ||= ::SOAP::Property.new)
+ @operation = {}
+ @mandatorycharset = nil
+ @allow_unqualified_element = true
+ @default_encodingstyle = nil
+ @generate_explicit_type = true
+ @headerhandler = Header::HandlerSet.new
+ @mapping_registry = nil
+ @literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new
+ end
+
+ def inspect
+ "#<#{self.class}:#{@endpoint_url}>"
+ end
+
+ def endpoint_url
+ @endpoint_url
+ end
+
+ def endpoint_url=(endpoint_url)
+ @endpoint_url = endpoint_url
+ reset_stream
+ end
+
+ def reset_stream
+ @streamhandler.reset(@endpoint_url)
+ end
+
+ def set_wiredump_file_base(wiredump_file_base)
+ @streamhandler.wiredump_file_base = wiredump_file_base
+ end
+
+ def test_loopback_response
+ @streamhandler.test_loopback_response
+ end
+
+ def add_rpc_operation(qname, soapaction, name, param_def, opt = {})
+ opt[:request_qname] = qname
+ opt[:request_style] ||= :rpc
+ opt[:response_style] ||= :rpc
+ opt[:request_use] ||= :encoded
+ opt[:response_use] ||= :encoded
+ @operation[name] = Operation.new(soapaction, param_def, opt)
+ end
+
+ def add_document_operation(soapaction, name, param_def, opt = {})
+ opt[:request_style] ||= :document
+ opt[:response_style] ||= :document
+ opt[:request_use] ||= :literal
+ opt[:response_use] ||= :literal
+ # default values of these values are unqualified in XML Schema.
+ # set true for backward compatibility.
+ unless opt.key?(:elementformdefault)
+ opt[:elementformdefault] = true
+ end
+ unless opt.key?(:attributeformdefault)
+ opt[:attributeformdefault] = true
+ end
+ @operation[name] = Operation.new(soapaction, param_def, opt)
+ end
+
+ # add_method is for shortcut of typical rpc/encoded method definition.
+ alias add_method add_rpc_operation
+ alias add_rpc_method add_rpc_operation
+ alias add_document_method add_document_operation
+
+ def invoke(req_header, req_body, opt = nil)
+ opt ||= create_encoding_opt
+ route(req_header, req_body, opt, opt)
+ end
+
+ def call(name, *params)
+ unless op_info = @operation[name]
+ raise MethodDefinitionError, "method: #{name} not defined"
+ end
+ mapping_opt = create_mapping_opt
+ req_header = create_request_header
+ req_body = SOAPBody.new(
+ op_info.request_body(params, @mapping_registry,
+ @literal_mapping_registry, mapping_opt)
+ )
+ reqopt = create_encoding_opt(
+ :soapaction => op_info.soapaction || @soapaction,
+ :envelopenamespace => @options["soap.envelope.requestnamespace"],
+ :default_encodingstyle =>
+ @default_encodingstyle || op_info.request_default_encodingstyle,
+ :elementformdefault => op_info.elementformdefault,
+ :attributeformdefault => op_info.attributeformdefault
+ )
+ resopt = create_encoding_opt(
+ :envelopenamespace => @options["soap.envelope.responsenamespace"],
+ :default_encodingstyle =>
+ @default_encodingstyle || op_info.response_default_encodingstyle,
+ :elementformdefault => op_info.elementformdefault,
+ :attributeformdefault => op_info.attributeformdefault
+ )
+ env = route(req_header, req_body, reqopt, resopt)
+ raise EmptyResponseError unless env
+ receive_headers(env.header)
+ begin
+ check_fault(env.body)
+ rescue ::SOAP::FaultError => e
+ op_info.raise_fault(e, @mapping_registry, @literal_mapping_registry)
+ end
+ op_info.response_obj(env.body, @mapping_registry,
+ @literal_mapping_registry, mapping_opt)
+ end
+
+ def route(req_header, req_body, reqopt, resopt)
+ req_env = ::SOAP::SOAPEnvelope.new(req_header, req_body)
+ unless reqopt[:envelopenamespace].nil?
+ set_envelopenamespace(req_env, reqopt[:envelopenamespace])
+ end
+ reqopt[:external_content] = nil
+ conn_data = marshal(req_env, reqopt)
+ if ext = reqopt[:external_content]
+ mime = MIMEMessage.new
+ ext.each do |k, v|
+ mime.add_attachment(v.data)
+ end
+ mime.add_part(conn_data.send_string + "\r\n")
+ mime.close
+ conn_data.send_string = mime.content_str
+ conn_data.send_contenttype = mime.headers['content-type'].str
+ end
+ conn_data = @streamhandler.send(@endpoint_url, conn_data,
+ reqopt[:soapaction])
+ if conn_data.receive_string.empty?
+ return nil
+ end
+ unmarshal(conn_data, resopt)
+ end
+
+ def check_fault(body)
+ if body.fault
+ raise SOAP::FaultError.new(body.fault)
+ end
+ end
+
+private
+
+ def set_envelopenamespace(env, namespace)
+ env.elename = XSD::QName.new(namespace, env.elename.name)
+ if env.header
+ env.header.elename = XSD::QName.new(namespace, env.header.elename.name)
+ end
+ if env.body
+ env.body.elename = XSD::QName.new(namespace, env.body.elename.name)
+ end
+ end
+
+ def create_request_header
+ headers = @headerhandler.on_outbound
+ if headers.empty?
+ nil
+ else
+ h = ::SOAP::SOAPHeader.new
+ headers.each do |header|
+ h.add(header.elename.name, header)
+ end
+ h
+ end
+ end
+
+ def receive_headers(headers)
+ @headerhandler.on_inbound(headers) if headers
+ end
+
+ def marshal(env, opt)
+ send_string = Processor.marshal(env, opt)
+ StreamHandler::ConnectionData.new(send_string)
+ end
+
+ def unmarshal(conn_data, opt)
+ contenttype = conn_data.receive_contenttype
+ if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
+ opt[:external_content] = {}
+ mime = MIMEMessage.parse("Content-Type: " + contenttype,
+ conn_data.receive_string)
+ mime.parts.each do |part|
+ value = Attachment.new(part.content)
+ value.contentid = part.contentid
+ obj = SOAPAttachment.new(value)
+ opt[:external_content][value.contentid] = obj if value.contentid
+ end
+ opt[:charset] = @mandatorycharset ||
+ StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
+ env = Processor.unmarshal(mime.root.content, opt)
+ else
+ opt[:charset] = @mandatorycharset ||
+ ::SOAP::StreamHandler.parse_media_type(contenttype)
+ env = Processor.unmarshal(conn_data.receive_string, opt)
+ end
+ unless env.is_a?(::SOAP::SOAPEnvelope)
+ raise ResponseFormatError.new(
+ "response is not a SOAP envelope: #{conn_data.receive_string}")
+ end
+ env
+ end
+
+ def create_header(headers)
+ header = SOAPHeader.new()
+ headers.each do |content, mustunderstand, encodingstyle|
+ header.add(SOAPHeaderItem.new(content, mustunderstand, encodingstyle))
+ end
+ header
+ end
+
+ def create_encoding_opt(hash = nil)
+ opt = {}
+ opt[:default_encodingstyle] = @default_encodingstyle
+ opt[:allow_unqualified_element] = @allow_unqualified_element
+ opt[:generate_explicit_type] = @generate_explicit_type
+ opt[:no_indent] = @options["soap.envelope.no_indent"]
+ opt[:use_numeric_character_reference] =
+ @options["soap.envelope.use_numeric_character_reference"]
+ opt.update(hash) if hash
+ opt
+ end
+
+ def create_mapping_opt(hash = nil)
+ opt = {
+ :external_ces => @options["soap.mapping.external_ces"]
+ }
+ opt.update(hash) if hash
+ opt
+ end
+
+ class Operation
+ attr_reader :soapaction
+ attr_reader :request_style
+ attr_reader :response_style
+ attr_reader :request_use
+ attr_reader :response_use
+ attr_reader :elementformdefault
+ attr_reader :attributeformdefault
+
+ def initialize(soapaction, param_def, opt)
+ @soapaction = soapaction
+ @request_style = opt[:request_style]
+ @response_style = opt[:response_style]
+ @request_use = opt[:request_use]
+ @response_use = opt[:response_use]
+ # set nil(unqualified) by default
+ @elementformdefault = opt[:elementformdefault]
+ @attributeformdefault = opt[:attributeformdefault]
+ check_style(@request_style)
+ check_style(@response_style)
+ check_use(@request_use)
+ check_use(@response_use)
+ if @request_style == :rpc
+ @rpc_request_qname = opt[:request_qname]
+ if @rpc_request_qname.nil?
+ raise MethodDefinitionError.new("rpc_request_qname must be given")
+ end
+ @rpc_method_factory =
+ RPC::SOAPMethodRequest.new(@rpc_request_qname, param_def, @soapaction)
+ else
+ @doc_request_qnames = []
+ @doc_request_qualified = []
+ @doc_response_qnames = []
+ @doc_response_qualified = []
+ param_def.each do |inout, paramname, typeinfo, eleinfo|
+ klass_not_used, nsdef, namedef = typeinfo
+ qualified = eleinfo
+ if namedef.nil?
+ raise MethodDefinitionError.new("qname must be given")
+ end
+ case inout
+ when SOAPMethod::IN
+ @doc_request_qnames << XSD::QName.new(nsdef, namedef)
+ @doc_request_qualified << qualified
+ when SOAPMethod::OUT
+ @doc_response_qnames << XSD::QName.new(nsdef, namedef)
+ @doc_response_qualified << qualified
+ else
+ raise MethodDefinitionError.new(
+ "illegal inout definition for document style: #{inout}")
+ end
+ end
+ end
+ end
+
+ def request_default_encodingstyle
+ (@request_use == :encoded) ? EncodingNamespace : LiteralNamespace
+ end
+
+ def response_default_encodingstyle
+ (@response_use == :encoded) ? EncodingNamespace : LiteralNamespace
+ end
+
+ def request_body(values, mapping_registry, literal_mapping_registry, opt)
+ if @request_style == :rpc
+ request_rpc(values, mapping_registry, literal_mapping_registry, opt)
+ else
+ request_doc(values, mapping_registry, literal_mapping_registry, opt)
+ end
+ end
+
+ def response_obj(body, mapping_registry, literal_mapping_registry, opt)
+ if @response_style == :rpc
+ response_rpc(body, mapping_registry, literal_mapping_registry, opt)
+ else
+ response_doc(body, mapping_registry, literal_mapping_registry, opt)
+ end
+ end
+
+ def raise_fault(e, mapping_registry, literal_mapping_registry)
+ if @response_style == :rpc
+ Mapping.fault2exception(e, mapping_registry)
+ else
+ Mapping.fault2exception(e, literal_mapping_registry)
+ end
+ end
+
+ private
+
+ def check_style(style)
+ unless [:rpc, :document].include?(style)
+ raise MethodDefinitionError.new("unknown style: #{style}")
+ end
+ end
+
+ def check_use(use)
+ unless [:encoded, :literal].include?(use)
+ raise MethodDefinitionError.new("unknown use: #{use}")
+ end
+ end
+
+ def request_rpc(values, mapping_registry, literal_mapping_registry, opt)
+ if @request_use == :encoded
+ request_rpc_enc(values, mapping_registry, opt)
+ else
+ request_rpc_lit(values, literal_mapping_registry, opt)
+ end
+ end
+
+ def request_doc(values, mapping_registry, literal_mapping_registry, opt)
+ if @request_use == :encoded
+ request_doc_enc(values, mapping_registry, opt)
+ else
+ request_doc_lit(values, literal_mapping_registry, opt)
+ end
+ end
+
+ def request_rpc_enc(values, mapping_registry, opt)
+ method = @rpc_method_factory.dup
+ names = method.input_params
+ obj = create_request_obj(names, values)
+ soap = Mapping.obj2soap(obj, mapping_registry, @rpc_request_qname, opt)
+ method.set_param(soap)
+ method
+ end
+
+ def request_rpc_lit(values, mapping_registry, opt)
+ method = @rpc_method_factory.dup
+ params = {}
+ idx = 0
+ method.input_params.each do |name|
+ params[name] = Mapping.obj2soap(values[idx], mapping_registry,
+ XSD::QName.new(nil, name), opt)
+ idx += 1
+ end
+ method.set_param(params)
+ method
+ end
+
+ def request_doc_enc(values, mapping_registry, opt)
+ (0...values.size).collect { |idx|
+ ele = Mapping.obj2soap(values[idx], mapping_registry, nil, opt)
+ ele.elename = @doc_request_qnames[idx]
+ ele
+ }
+ end
+
+ def request_doc_lit(values, mapping_registry, opt)
+ (0...values.size).collect { |idx|
+ ele = Mapping.obj2soap(values[idx], mapping_registry,
+ @doc_request_qnames[idx], opt)
+ ele.encodingstyle = LiteralNamespace
+ if ele.respond_to?(:qualified)
+ ele.qualified = @doc_request_qualified[idx]
+ end
+ ele
+ }
+ end
+
+ def response_rpc(body, mapping_registry, literal_mapping_registry, opt)
+ if @response_use == :encoded
+ response_rpc_enc(body, mapping_registry, opt)
+ else
+ response_rpc_lit(body, literal_mapping_registry, opt)
+ end
+ end
+
+ def response_doc(body, mapping_registry, literal_mapping_registry, opt)
+ if @response_use == :encoded
+ return *response_doc_enc(body, mapping_registry, opt)
+ else
+ return *response_doc_lit(body, literal_mapping_registry, opt)
+ end
+ end
+
+ def response_rpc_enc(body, mapping_registry, opt)
+ ret = nil
+ if body.response
+ ret = Mapping.soap2obj(body.response, mapping_registry,
+ @rpc_method_factory.retval_class_name, opt)
+ end
+ if body.outparams
+ outparams = body.outparams.collect { |outparam|
+ Mapping.soap2obj(outparam, mapping_registry, nil, opt)
+ }
+ [ret].concat(outparams)
+ else
+ ret
+ end
+ end
+
+ def response_rpc_lit(body, mapping_registry, opt)
+ body.root_node.collect { |key, value|
+ Mapping.soap2obj(value, mapping_registry,
+ @rpc_method_factory.retval_class_name, opt)
+ }
+ end
+
+ def response_doc_enc(body, mapping_registry, opt)
+ body.collect { |key, value|
+ Mapping.soap2obj(value, mapping_registry, nil, opt)
+ }
+ end
+
+ def response_doc_lit(body, mapping_registry, opt)
+ body.collect { |key, value|
+ Mapping.soap2obj(value, mapping_registry)
+ }
+ end
+
+ def create_request_obj(names, params)
+ o = Object.new
+ idx = 0
+ while idx < params.length
+ o.instance_variable_set('@' + names[idx], params[idx])
+ idx += 1
+ end
+ o
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/router.rb b/lib/soap/rpc/router.rb
new file mode 100644
index 0000000000..71c6eb625b
--- /dev/null
+++ b/lib/soap/rpc/router.rb
@@ -0,0 +1,594 @@
+# SOAP4R - RPC Routing library
+# Copyright (C) 2001, 2002, 2004, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/soap'
+require 'soap/processor'
+require 'soap/mapping'
+require 'soap/mapping/wsdlliteralregistry'
+require 'soap/rpc/rpc'
+require 'soap/rpc/element'
+require 'soap/streamHandler'
+require 'soap/mimemessage'
+require 'soap/header/handlerset'
+
+
+module SOAP
+module RPC
+
+
+class Router
+ include SOAP
+
+ attr_reader :actor
+ attr_accessor :mapping_registry
+ attr_accessor :literal_mapping_registry
+ attr_accessor :generate_explicit_type
+ attr_accessor :external_ces
+
+ def initialize(actor)
+ @actor = actor
+ @mapping_registry = nil
+ @headerhandler = Header::HandlerSet.new
+ @literal_mapping_registry = ::SOAP::Mapping::WSDLLiteralRegistry.new
+ @generate_explicit_type = true
+ @external_ces = nil
+ @operation_by_soapaction = {}
+ @operation_by_qname = {}
+ @headerhandlerfactory = []
+ end
+
+ ###
+ ## header handler interface
+ #
+ def add_request_headerhandler(factory)
+ unless factory.respond_to?(:create)
+ raise TypeError.new("factory must respond to 'create'")
+ end
+ @headerhandlerfactory << factory
+ end
+
+ def add_headerhandler(handler)
+ @headerhandler.add(handler)
+ end
+
+ ###
+ ## servant definition interface
+ #
+ def add_rpc_request_servant(factory, namespace)
+ unless factory.respond_to?(:create)
+ raise TypeError.new("factory must respond to 'create'")
+ end
+ obj = factory.create # a dummy instance for introspection
+ ::SOAP::RPC.defined_methods(obj).each do |name|
+ begin
+ qname = XSD::QName.new(namespace, name)
+ param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name)
+ opt = create_styleuse_option(:rpc, :encoded)
+ add_rpc_request_operation(factory, qname, nil, name, param_def, opt)
+ rescue SOAP::RPC::MethodDefinitionError => e
+ p e if $DEBUG
+ end
+ end
+ end
+
+ def add_rpc_servant(obj, namespace)
+ ::SOAP::RPC.defined_methods(obj).each do |name|
+ begin
+ qname = XSD::QName.new(namespace, name)
+ param_def = ::SOAP::RPC::SOAPMethod.derive_rpc_param_def(obj, name)
+ opt = create_styleuse_option(:rpc, :encoded)
+ add_rpc_operation(obj, qname, nil, name, param_def, opt)
+ rescue SOAP::RPC::MethodDefinitionError => e
+ p e if $DEBUG
+ end
+ end
+ end
+ alias add_servant add_rpc_servant
+
+ ###
+ ## operation definition interface
+ #
+ def add_rpc_operation(receiver, qname, soapaction, name, param_def, opt = {})
+ ensure_styleuse_option(opt, :rpc, :encoded)
+ opt[:request_qname] = qname
+ op = ApplicationScopeOperation.new(soapaction, receiver, name, param_def,
+ opt)
+ if opt[:request_style] != :rpc
+ raise RPCRoutingError.new("illegal request_style given")
+ end
+ assign_operation(soapaction, qname, op)
+ end
+ alias add_method add_rpc_operation
+ alias add_rpc_method add_rpc_operation
+
+ def add_rpc_request_operation(factory, qname, soapaction, name, param_def, opt = {})
+ ensure_styleuse_option(opt, :rpc, :encoded)
+ opt[:request_qname] = qname
+ op = RequestScopeOperation.new(soapaction, factory, name, param_def, opt)
+ if opt[:request_style] != :rpc
+ raise RPCRoutingError.new("illegal request_style given")
+ end
+ assign_operation(soapaction, qname, op)
+ end
+
+ def add_document_operation(receiver, soapaction, name, param_def, opt = {})
+ #
+ # adopt workaround for doc/lit wrapper method
+ # (you should consider to simply use rpc/lit service)
+ #
+ #unless soapaction
+ # raise RPCRoutingError.new("soapaction is a must for document method")
+ #end
+ ensure_styleuse_option(opt, :document, :literal)
+ op = ApplicationScopeOperation.new(soapaction, receiver, name, param_def,
+ opt)
+ if opt[:request_style] != :document
+ raise RPCRoutingError.new("illegal request_style given")
+ end
+ assign_operation(soapaction, first_input_part_qname(param_def), op)
+ end
+ alias add_document_method add_document_operation
+
+ def add_document_request_operation(factory, soapaction, name, param_def, opt = {})
+ #
+ # adopt workaround for doc/lit wrapper method
+ # (you should consider to simply use rpc/lit service)
+ #
+ #unless soapaction
+ # raise RPCRoutingError.new("soapaction is a must for document method")
+ #end
+ ensure_styleuse_option(opt, :document, :literal)
+ op = RequestScopeOperation.new(soapaction, receiver, name, param_def, opt)
+ if opt[:request_style] != :document
+ raise RPCRoutingError.new("illegal request_style given")
+ end
+ assign_operation(soapaction, first_input_part_qname(param_def), op)
+ end
+
+ def route(conn_data)
+ # we cannot set request_default_encodingsyle before parsing the content.
+ env = unmarshal(conn_data)
+ if env.nil?
+ raise ArgumentError.new("illegal SOAP marshal format")
+ end
+ op = lookup_operation(conn_data.soapaction, env.body)
+ headerhandler = @headerhandler.dup
+ @headerhandlerfactory.each do |f|
+ headerhandler.add(f.create)
+ end
+ receive_headers(headerhandler, env.header)
+ soap_response = default_encodingstyle = nil
+ begin
+ soap_response =
+ op.call(env.body, @mapping_registry, @literal_mapping_registry,
+ create_mapping_opt)
+ default_encodingstyle = op.response_default_encodingstyle
+ rescue Exception
+ soap_response = fault($!)
+ default_encodingstyle = nil
+ end
+ conn_data.is_fault = true if soap_response.is_a?(SOAPFault)
+ header = call_headers(headerhandler)
+ body = SOAPBody.new(soap_response)
+ env = SOAPEnvelope.new(header, body)
+ marshal(conn_data, env, default_encodingstyle)
+ end
+
+ # Create fault response string.
+ def create_fault_response(e)
+ env = SOAPEnvelope.new(SOAPHeader.new, SOAPBody.new(fault(e)))
+ opt = {}
+ opt[:external_content] = nil
+ response_string = Processor.marshal(env, opt)
+ conn_data = StreamHandler::ConnectionData.new(response_string)
+ conn_data.is_fault = true
+ if ext = opt[:external_content]
+ mimeize(conn_data, ext)
+ end
+ conn_data
+ end
+
+private
+
+ def first_input_part_qname(param_def)
+ param_def.each do |inout, paramname, typeinfo|
+ if inout == SOAPMethod::IN
+ klass, nsdef, namedef = typeinfo
+ return XSD::QName.new(nsdef, namedef)
+ end
+ end
+ nil
+ end
+
+ def create_styleuse_option(style, use)
+ opt = {}
+ opt[:request_style] = opt[:response_style] = style
+ opt[:request_use] = opt[:response_use] = use
+ opt
+ end
+
+ def ensure_styleuse_option(opt, style, use)
+ opt[:request_style] ||= style
+ opt[:response_style] ||= style
+ opt[:request_use] ||= use
+ opt[:response_use] ||= use
+ end
+
+ def assign_operation(soapaction, qname, op)
+ assigned = false
+ if soapaction and !soapaction.empty?
+ @operation_by_soapaction[soapaction] = op
+ assigned = true
+ end
+ if qname
+ @operation_by_qname[qname] = op
+ assigned = true
+ end
+ unless assigned
+ raise RPCRoutingError.new("cannot assign operation")
+ end
+ end
+
+ def lookup_operation(soapaction, body)
+ if op = @operation_by_soapaction[soapaction]
+ return op
+ end
+ qname = body.root_node.elename
+ if op = @operation_by_qname[qname]
+ return op
+ end
+ if soapaction
+ raise RPCRoutingError.new(
+ "operation: #{soapaction} #{qname} not supported")
+ else
+ raise RPCRoutingError.new("operation: #{qname} not supported")
+ end
+ end
+
+ def call_headers(headerhandler)
+ headers = headerhandler.on_outbound
+ if headers.empty?
+ nil
+ else
+ h = ::SOAP::SOAPHeader.new
+ headers.each do |header|
+ h.add(header.elename.name, header)
+ end
+ h
+ end
+ end
+
+ def receive_headers(headerhandler, headers)
+ headerhandler.on_inbound(headers) if headers
+ end
+
+ def unmarshal(conn_data)
+ opt = {}
+ contenttype = conn_data.receive_contenttype
+ if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
+ opt[:external_content] = {}
+ mime = MIMEMessage.parse("Content-Type: " + contenttype,
+ conn_data.receive_string)
+ mime.parts.each do |part|
+ value = Attachment.new(part.content)
+ value.contentid = part.contentid
+ obj = SOAPAttachment.new(value)
+ opt[:external_content][value.contentid] = obj if value.contentid
+ end
+ opt[:charset] =
+ StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
+ env = Processor.unmarshal(mime.root.content, opt)
+ else
+ opt[:charset] = ::SOAP::StreamHandler.parse_media_type(contenttype)
+ env = Processor.unmarshal(conn_data.receive_string, opt)
+ end
+ charset = opt[:charset]
+ conn_data.send_contenttype = "text/xml; charset=\"#{charset}\""
+ env
+ end
+
+ def marshal(conn_data, env, default_encodingstyle = nil)
+ opt = {}
+ opt[:external_content] = nil
+ opt[:default_encodingstyle] = default_encodingstyle
+ opt[:generate_explicit_type] = @generate_explicit_type
+ response_string = Processor.marshal(env, opt)
+ conn_data.send_string = response_string
+ if ext = opt[:external_content]
+ mimeize(conn_data, ext)
+ end
+ conn_data
+ end
+
+ def mimeize(conn_data, ext)
+ mime = MIMEMessage.new
+ ext.each do |k, v|
+ mime.add_attachment(v.data)
+ end
+ mime.add_part(conn_data.send_string + "\r\n")
+ mime.close
+ conn_data.send_string = mime.content_str
+ conn_data.send_contenttype = mime.headers['content-type'].str
+ conn_data
+ end
+
+ # Create fault response.
+ def fault(e)
+ detail = Mapping::SOAPException.new(e)
+ SOAPFault.new(
+ SOAPString.new('Server'),
+ SOAPString.new(e.to_s),
+ SOAPString.new(@actor),
+ Mapping.obj2soap(detail, @mapping_registry))
+ end
+
+ def create_mapping_opt
+ { :external_ces => @external_ces }
+ end
+
+ class Operation
+ attr_reader :name
+ attr_reader :soapaction
+ attr_reader :request_style
+ attr_reader :response_style
+ attr_reader :request_use
+ attr_reader :response_use
+
+ def initialize(soapaction, name, param_def, opt)
+ @soapaction = soapaction
+ @name = name
+ @request_style = opt[:request_style]
+ @response_style = opt[:response_style]
+ @request_use = opt[:request_use]
+ @response_use = opt[:response_use]
+ check_style(@request_style)
+ check_style(@response_style)
+ check_use(@request_use)
+ check_use(@response_use)
+ if @response_style == :rpc
+ request_qname = opt[:request_qname] or raise
+ @rpc_method_factory =
+ RPC::SOAPMethodRequest.new(request_qname, param_def, @soapaction)
+ @rpc_response_qname = opt[:response_qname]
+ else
+ @doc_request_qnames = []
+ @doc_request_qualified = []
+ @doc_response_qnames = []
+ @doc_response_qualified = []
+ param_def.each do |inout, paramname, typeinfo, eleinfo|
+ klass, nsdef, namedef = typeinfo
+ qualified = eleinfo
+ case inout
+ when SOAPMethod::IN
+ @doc_request_qnames << XSD::QName.new(nsdef, namedef)
+ @doc_request_qualified << qualified
+ when SOAPMethod::OUT
+ @doc_response_qnames << XSD::QName.new(nsdef, namedef)
+ @doc_response_qualified << qualified
+ else
+ raise ArgumentError.new(
+ "illegal inout definition for document style: #{inout}")
+ end
+ end
+ end
+ end
+
+ def request_default_encodingstyle
+ (@request_use == :encoded) ? EncodingNamespace : LiteralNamespace
+ end
+
+ def response_default_encodingstyle
+ (@response_use == :encoded) ? EncodingNamespace : LiteralNamespace
+ end
+
+ def call(body, mapping_registry, literal_mapping_registry, opt)
+ if @request_style == :rpc
+ values = request_rpc(body, mapping_registry, literal_mapping_registry,
+ opt)
+ else
+ values = request_document(body, mapping_registry,
+ literal_mapping_registry, opt)
+ end
+ result = receiver.method(@name.intern).call(*values)
+ return result if result.is_a?(SOAPFault)
+ if @response_style == :rpc
+ response_rpc(result, mapping_registry, literal_mapping_registry, opt)
+ else
+ response_doc(result, mapping_registry, literal_mapping_registry, opt)
+ end
+ end
+
+ private
+
+ def receiver
+ raise NotImplementedError.new('must be defined in derived class')
+ end
+
+ def request_rpc(body, mapping_registry, literal_mapping_registry, opt)
+ request = body.request
+ unless request.is_a?(SOAPStruct)
+ raise RPCRoutingError.new("not an RPC style")
+ end
+ if @request_use == :encoded
+ request_rpc_enc(request, mapping_registry, opt)
+ else
+ request_rpc_lit(request, literal_mapping_registry, opt)
+ end
+ end
+
+ def request_document(body, mapping_registry, literal_mapping_registry, opt)
+ # ToDo: compare names with @doc_request_qnames
+ if @request_use == :encoded
+ request_doc_enc(body, mapping_registry, opt)
+ else
+ request_doc_lit(body, literal_mapping_registry, opt)
+ end
+ end
+
+ def request_rpc_enc(request, mapping_registry, opt)
+ param = Mapping.soap2obj(request, mapping_registry, nil, opt)
+ request.collect { |key, value|
+ param[key]
+ }
+ end
+
+ def request_rpc_lit(request, mapping_registry, opt)
+ request.collect { |key, value|
+ Mapping.soap2obj(value, mapping_registry, nil, opt)
+ }
+ end
+
+ def request_doc_enc(body, mapping_registry, opt)
+ body.collect { |key, value|
+ Mapping.soap2obj(value, mapping_registry, nil, opt)
+ }
+ end
+
+ def request_doc_lit(body, mapping_registry, opt)
+ body.collect { |key, value|
+ Mapping.soap2obj(value, mapping_registry, nil, opt)
+ }
+ end
+
+ def response_rpc(result, mapping_registry, literal_mapping_registry, opt)
+ if @response_use == :encoded
+ response_rpc_enc(result, mapping_registry, opt)
+ else
+ response_rpc_lit(result, literal_mapping_registry, opt)
+ end
+ end
+
+ def response_doc(result, mapping_registry, literal_mapping_registry, opt)
+ if @doc_response_qnames.size == 1 and !result.is_a?(Array)
+ result = [result]
+ end
+ if result.size != @doc_response_qnames.size
+ raise "required #{@doc_response_qnames.size} responses " +
+ "but #{result.size} given"
+ end
+ if @response_use == :encoded
+ response_doc_enc(result, mapping_registry, opt)
+ else
+ response_doc_lit(result, literal_mapping_registry, opt)
+ end
+ end
+
+ def response_rpc_enc(result, mapping_registry, opt)
+ soap_response =
+ @rpc_method_factory.create_method_response(@rpc_response_qname)
+ if soap_response.have_outparam?
+ unless result.is_a?(Array)
+ raise RPCRoutingError.new("out parameter was not returned")
+ end
+ outparams = {}
+ i = 1
+ soap_response.output_params.each do |outparam|
+ outparams[outparam] = Mapping.obj2soap(result[i], mapping_registry,
+ nil, opt)
+ i += 1
+ end
+ soap_response.set_outparam(outparams)
+ soap_response.retval = Mapping.obj2soap(result[0], mapping_registry,
+ nil, opt)
+ else
+ soap_response.retval = Mapping.obj2soap(result, mapping_registry, nil,
+ opt)
+ end
+ soap_response
+ end
+
+ def response_rpc_lit(result, mapping_registry, opt)
+ soap_response =
+ @rpc_method_factory.create_method_response(@rpc_response_qname)
+ if soap_response.have_outparam?
+ unless result.is_a?(Array)
+ raise RPCRoutingError.new("out parameter was not returned")
+ end
+ outparams = {}
+ i = 1
+ soap_response.output_params.each do |outparam|
+ outparams[outparam] = Mapping.obj2soap(result[i], mapping_registry,
+ XSD::QName.new(nil, outparam), opt)
+ i += 1
+ end
+ soap_response.set_outparam(outparams)
+ soap_response.retval = Mapping.obj2soap(result[0], mapping_registry,
+ XSD::QName.new(nil, soap_response.elename), opt)
+ else
+ soap_response.retval = Mapping.obj2soap(result, mapping_registry,
+ XSD::QName.new(nil, soap_response.elename), opt)
+ end
+ soap_response
+ end
+
+ def response_doc_enc(result, mapping_registry, opt)
+ (0...result.size).collect { |idx|
+ ele = Mapping.obj2soap(result[idx], mapping_registry, nil, opt)
+ ele.elename = @doc_response_qnames[idx]
+ ele
+ }
+ end
+
+ def response_doc_lit(result, mapping_registry, opt)
+ (0...result.size).collect { |idx|
+ ele = Mapping.obj2soap(result[idx], mapping_registry,
+ @doc_response_qnames[idx])
+ ele.encodingstyle = LiteralNamespace
+ if ele.respond_to?(:qualified)
+ ele.qualified = @doc_response_qualified[idx]
+ end
+ ele
+ }
+ end
+
+ def check_style(style)
+ unless [:rpc, :document].include?(style)
+ raise ArgumentError.new("unknown style: #{style}")
+ end
+ end
+
+ def check_use(use)
+ unless [:encoded, :literal].include?(use)
+ raise ArgumentError.new("unknown use: #{use}")
+ end
+ end
+ end
+
+ class ApplicationScopeOperation < Operation
+ def initialize(soapaction, receiver, name, param_def, opt)
+ super(soapaction, name, param_def, opt)
+ @receiver = receiver
+ end
+
+ private
+
+ def receiver
+ @receiver
+ end
+ end
+
+ class RequestScopeOperation < Operation
+ def initialize(soapaction, receiver_factory, name, param_def, opt)
+ super(soapaction, name, param_def, opt)
+ unless receiver_factory.respond_to?(:create)
+ raise TypeError.new("factory must respond to 'create'")
+ end
+ @receiver_factory = receiver_factory
+ end
+
+ private
+
+ def receiver
+ @receiver_factory.create
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/rpc.rb b/lib/soap/rpc/rpc.rb
new file mode 100644
index 0000000000..a48b525dbb
--- /dev/null
+++ b/lib/soap/rpc/rpc.rb
@@ -0,0 +1,25 @@
+# SOAP4R - RPC utility.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module SOAP
+
+
+module RPC
+ ServerException = Mapping::MappedException
+
+ def self.defined_methods(obj)
+ if obj.is_a?(Module)
+ obj.methods - Module.methods
+ else
+ obj.methods - Object.instance_methods(true)
+ end
+ end
+end
+
+
+end
diff --git a/lib/soap/rpc/soaplet.rb b/lib/soap/rpc/soaplet.rb
new file mode 100644
index 0000000000..7cccdd3e31
--- /dev/null
+++ b/lib/soap/rpc/soaplet.rb
@@ -0,0 +1,162 @@
+# SOAP4R - SOAP handler servlet for WEBrick
+# Copyright (C) 2001-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'webrick/httpservlet/abstract'
+require 'webrick/httpstatus'
+require 'soap/rpc/router'
+require 'soap/streamHandler'
+begin
+ require 'stringio'
+ require 'zlib'
+rescue LoadError
+ warn("Loading stringio or zlib failed. No gzipped response supported.") if $DEBUG
+end
+
+
+warn("Overriding WEBrick::Log#debug") if $DEBUG
+require 'webrick/log'
+module WEBrick
+ class Log < BasicLog
+ alias __debug debug
+ def debug(msg = nil)
+ if block_given? and msg.nil?
+ __debug(yield)
+ else
+ __debug(msg)
+ end
+ end
+ end
+end
+
+
+module SOAP
+module RPC
+
+
+class SOAPlet < WEBrick::HTTPServlet::AbstractServlet
+public
+ attr_reader :options
+
+ def initialize(router = nil)
+ @router = router || ::SOAP::RPC::Router.new(self.class.name)
+ @options = {}
+ @config = {}
+ end
+
+ # for backward compatibility
+ def app_scope_router
+ @router
+ end
+
+ # for backward compatibility
+ def add_servant(obj, namespace)
+ @router.add_rpc_servant(obj, namespace)
+ end
+
+ def allow_content_encoding_gzip=(allow)
+ @options[:allow_content_encoding_gzip] = allow
+ end
+
+ ###
+ ## Servlet interfaces for WEBrick.
+ #
+ def get_instance(config, *options)
+ @config = config
+ self
+ end
+
+ def require_path_info?
+ false
+ end
+
+ def do_GET(req, res)
+ res.header['Allow'] = 'POST'
+ raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed"
+ end
+
+ def do_POST(req, res)
+ logger.debug { "SOAP request: " + req.body } if logger
+ begin
+ conn_data = ::SOAP::StreamHandler::ConnectionData.new
+ setup_req(conn_data, req)
+ @router.external_ces = @options[:external_ces]
+ conn_data = @router.route(conn_data)
+ setup_res(conn_data, req, res)
+ rescue Exception => e
+ conn_data = @router.create_fault_response(e)
+ res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
+ res.body = conn_data.send_string
+ res['content-type'] = conn_data.send_contenttype || "text/xml"
+ end
+ if res.body.is_a?(IO)
+ res.chunked = true
+ logger.debug { "SOAP response: (chunked response not logged)" } if logger
+ else
+ logger.debug { "SOAP response: " + res.body } if logger
+ end
+ end
+
+private
+
+ def logger
+ @config[:Logger]
+ end
+
+ def setup_req(conn_data, req)
+ conn_data.receive_string = req.body
+ conn_data.receive_contenttype = req['content-type']
+ conn_data.soapaction = parse_soapaction(req.meta_vars['HTTP_SOAPACTION'])
+ end
+
+ def setup_res(conn_data, req, res)
+ res['content-type'] = conn_data.send_contenttype
+ if conn_data.is_fault
+ res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR
+ end
+ if outstring = encode_gzip(req, conn_data.send_string)
+ res['content-encoding'] = 'gzip'
+ res['content-length'] = outstring.size
+ res.body = outstring
+ else
+ res.body = conn_data.send_string
+ end
+ end
+
+ def parse_soapaction(soapaction)
+ if !soapaction.nil? and !soapaction.empty?
+ if /^"(.+)"$/ =~ soapaction
+ return $1
+ end
+ end
+ nil
+ end
+
+ def encode_gzip(req, outstring)
+ unless encode_gzip?(req)
+ return nil
+ end
+ begin
+ ostream = StringIO.new
+ gz = Zlib::GzipWriter.new(ostream)
+ gz.write(outstring)
+ ostream.string
+ ensure
+ gz.close
+ end
+ end
+
+ def encode_gzip?(req)
+ @options[:allow_content_encoding_gzip] and defined?(::Zlib) and
+ req['accept-encoding'] and
+ req['accept-encoding'].split(/,\s*/).include?('gzip')
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/rpc/standaloneServer.rb b/lib/soap/rpc/standaloneServer.rb
new file mode 100644
index 0000000000..080343ba33
--- /dev/null
+++ b/lib/soap/rpc/standaloneServer.rb
@@ -0,0 +1,43 @@
+# SOAP4R - WEBrick Server
+# Copyright (C) 2003 by NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/rpc/httpserver'
+
+
+module SOAP
+module RPC
+
+
+class StandaloneServer < HTTPServer
+ def initialize(appname, default_namespace, host = "0.0.0.0", port = 8080)
+ @appname = appname
+ @default_namespace = default_namespace
+ @host = host
+ @port = port
+ super(create_config)
+ end
+
+ alias add_servant add_rpc_servant
+ alias add_headerhandler add_rpc_headerhandler
+
+private
+
+ def create_config
+ {
+ :BindAddress => @host,
+ :Port => @port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => @default_namespace,
+ :SOAPHTTPServerApplicationName => @appname,
+ }
+ end
+end
+
+
+end
+end
diff --git a/lib/soap/soap.rb b/lib/soap/soap.rb
new file mode 100644
index 0000000000..12e09eccfe
--- /dev/null
+++ b/lib/soap/soap.rb
@@ -0,0 +1,140 @@
+# soap/soap.rb: SOAP4R - Base definitions.
+# Copyright (C) 2000-2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'xsd/charset'
+
+
+module SOAP
+
+
+VERSION = Version = '1.5.5'
+PropertyName = 'soap/property'
+
+EnvelopeNamespace = 'http://schemas.xmlsoap.org/soap/envelope/'
+EncodingNamespace = 'http://schemas.xmlsoap.org/soap/encoding/'
+LiteralNamespace = 'http://xml.apache.org/xml-soap/literalxml'
+
+NextActor = 'http://schemas.xmlsoap.org/soap/actor/next'
+
+EleEnvelope = 'Envelope'
+EleHeader = 'Header'
+EleBody = 'Body'
+EleFault = 'Fault'
+EleFaultString = 'faultstring'
+EleFaultActor = 'faultactor'
+EleFaultCode = 'faultcode'
+EleFaultDetail = 'detail'
+
+AttrMustUnderstand = 'mustUnderstand'
+AttrEncodingStyle = 'encodingStyle'
+AttrActor = 'actor'
+AttrRoot = 'root'
+AttrArrayType = 'arrayType'
+AttrOffset = 'offset'
+AttrPosition = 'position'
+ValueArray = 'Array'
+
+EleEnvelopeName = XSD::QName.new(EnvelopeNamespace, EleEnvelope).freeze
+EleHeaderName = XSD::QName.new(EnvelopeNamespace, EleHeader).freeze
+EleBodyName = XSD::QName.new(EnvelopeNamespace, EleBody).freeze
+EleFaultName = XSD::QName.new(EnvelopeNamespace, EleFault).freeze
+EleFaultStringName = XSD::QName.new(nil, EleFaultString).freeze
+EleFaultActorName = XSD::QName.new(nil, EleFaultActor).freeze
+EleFaultCodeName = XSD::QName.new(nil, EleFaultCode).freeze
+EleFaultDetailName = XSD::QName.new(nil, EleFaultDetail).freeze
+AttrMustUnderstandName = XSD::QName.new(EnvelopeNamespace, AttrMustUnderstand).freeze
+AttrEncodingStyleName = XSD::QName.new(EnvelopeNamespace, AttrEncodingStyle).freeze
+AttrRootName = XSD::QName.new(EncodingNamespace, AttrRoot).freeze
+AttrArrayTypeName = XSD::QName.new(EncodingNamespace, AttrArrayType).freeze
+AttrOffsetName = XSD::QName.new(EncodingNamespace, AttrOffset).freeze
+AttrPositionName = XSD::QName.new(EncodingNamespace, AttrPosition).freeze
+ValueArrayName = XSD::QName.new(EncodingNamespace, ValueArray).freeze
+
+Base64Literal = 'base64'
+
+SOAPNamespaceTag = 'env'
+XSDNamespaceTag = 'xsd'
+XSINamespaceTag = 'xsi'
+
+MediaType = 'text/xml'
+
+class Error < StandardError; end
+
+class StreamError < Error; end
+class HTTPStreamError < StreamError; end
+class PostUnavailableError < HTTPStreamError; end
+class MPostUnavailableError < HTTPStreamError; end
+
+class ArrayIndexOutOfBoundsError < Error; end
+class ArrayStoreError < Error; end
+
+class RPCRoutingError < Error; end
+class EmptyResponseError < Error; end
+class ResponseFormatError < Error; end
+
+class UnhandledMustUnderstandHeaderError < Error; end
+
+class FaultError < Error
+ attr_reader :faultcode
+ attr_reader :faultstring
+ attr_reader :faultactor
+ attr_accessor :detail
+
+ def initialize(fault)
+ @faultcode = fault.faultcode
+ @faultstring = fault.faultstring
+ @faultactor = fault.faultactor
+ @detail = fault.detail
+ super(self.to_s)
+ end
+
+ def to_s
+ str = nil
+ if @faultstring and @faultstring.respond_to?('data')
+ str = @faultstring.data
+ end
+ str || '(No faultstring)'
+ end
+end
+
+
+module Env
+ def self.getenv(name)
+ ENV[name.downcase] || ENV[name.upcase]
+ end
+
+ use_proxy = getenv('soap_use_proxy') == 'on'
+ HTTP_PROXY = use_proxy ? getenv('http_proxy') : nil
+ NO_PROXY = use_proxy ? getenv('no_proxy') : nil
+end
+
+
+end
+
+
+unless Object.respond_to?(:instance_variable_get)
+ class Object
+ def instance_variable_get(ivarname)
+ instance_eval(ivarname)
+ end
+
+ def instance_variable_set(ivarname, value)
+ instance_eval("#{ivarname} = value")
+ end
+ end
+end
+
+
+unless Kernel.respond_to?(:warn)
+ module Kernel
+ def warn(msg)
+ STDERR.puts(msg + "\n") unless $VERBOSE.nil?
+ end
+ end
+end
diff --git a/lib/soap/streamHandler.rb b/lib/soap/streamHandler.rb
new file mode 100644
index 0000000000..672396ecce
--- /dev/null
+++ b/lib/soap/streamHandler.rb
@@ -0,0 +1,229 @@
+# SOAP4R - Stream handler.
+# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/soap'
+require 'soap/httpconfigloader'
+begin
+ require 'stringio'
+ require 'zlib'
+rescue LoadError
+ warn("Loading stringio or zlib failed. No gzipped response support.") if $DEBUG
+end
+
+
+module SOAP
+
+
+class StreamHandler
+ RUBY_VERSION_STRING = "ruby #{ RUBY_VERSION } (#{ RUBY_RELEASE_DATE }) [#{ RUBY_PLATFORM }]"
+
+ class ConnectionData
+ attr_accessor :send_string
+ attr_accessor :send_contenttype
+ attr_accessor :receive_string
+ attr_accessor :receive_contenttype
+ attr_accessor :is_fault
+ attr_accessor :soapaction
+
+ def initialize(send_string = nil)
+ @send_string = send_string
+ @send_contenttype = nil
+ @receive_string = nil
+ @receive_contenttype = nil
+ @is_fault = false
+ @soapaction = nil
+ end
+ end
+
+ def self.parse_media_type(str)
+ if /^#{ MediaType }(?:\s*;\s*charset=([^"]+|"[^"]+"))?$/i !~ str
+ return nil
+ end
+ charset = $1
+ charset.gsub!(/"/, '') if charset
+ charset || 'us-ascii'
+ end
+
+ def self.create_media_type(charset)
+ "#{ MediaType }; charset=#{ charset }"
+ end
+end
+
+
+class HTTPStreamHandler < StreamHandler
+ include SOAP
+
+ begin
+ require 'http-access2'
+ if HTTPAccess2::VERSION < "2.0"
+ raise LoadError.new("http-access/2.0 or later is required.")
+ end
+ Client = HTTPAccess2::Client
+ RETRYABLE = true
+ rescue LoadError
+ warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
+ require 'soap/netHttpClient'
+ Client = SOAP::NetHttpClient
+ RETRYABLE = false
+ end
+
+
+public
+
+ attr_reader :client
+ attr_accessor :wiredump_file_base
+
+ MAX_RETRY_COUNT = 10 # [times]
+
+ def initialize(options)
+ super()
+ @client = Client.new(nil, "SOAP4R/#{ Version }")
+ @wiredump_file_base = nil
+ @charset = @wiredump_dev = nil
+ @options = options
+ set_options
+ @client.debug_dev = @wiredump_dev
+ @cookie_store = nil
+ @accept_encoding_gzip = false
+ end
+
+ def test_loopback_response
+ @client.test_loopback_response
+ end
+
+ def accept_encoding_gzip=(allow)
+ @accept_encoding_gzip = allow
+ end
+
+ def inspect
+ "#<#{self.class}>"
+ end
+
+ def send(endpoint_url, conn_data, soapaction = nil, charset = @charset)
+ conn_data.soapaction ||= soapaction # for backward conpatibility
+ send_post(endpoint_url, conn_data, charset)
+ end
+
+ def reset(endpoint_url = nil)
+ if endpoint_url.nil?
+ @client.reset_all
+ else
+ @client.reset(endpoint_url)
+ end
+ @client.save_cookie_store if @cookie_store
+ end
+
+private
+
+ def set_options
+ HTTPConfigLoader.set_options(@client, @options)
+ @charset = @options["charset"] || XSD::Charset.xml_encoding_label
+ @options.add_hook("charset") do |key, value|
+ @charset = value
+ end
+ @wiredump_dev = @options["wiredump_dev"]
+ @options.add_hook("wiredump_dev") do |key, value|
+ @wiredump_dev = value
+ @client.debug_dev = @wiredump_dev
+ end
+ set_cookie_store_file(@options["cookie_store_file"])
+ @options.add_hook("cookie_store_file") do |key, value|
+ set_cookie_store_file(value)
+ end
+ ssl_config = @options["ssl_config"]
+ basic_auth = @options["basic_auth"]
+ @options.lock(true)
+ ssl_config.unlock
+ basic_auth.unlock
+ end
+
+ def set_cookie_store_file(value)
+ value = nil if value and value.empty?
+ @cookie_store = value
+ @client.set_cookie_store(@cookie_store) if @cookie_store
+ end
+
+ def send_post(endpoint_url, conn_data, charset)
+ conn_data.send_contenttype ||= StreamHandler.create_media_type(charset)
+
+ if @wiredump_file_base
+ filename = @wiredump_file_base + '_request.xml'
+ f = File.open(filename, "w")
+ f << conn_data.send_string
+ f.close
+ end
+
+ extra = {}
+ extra['Content-Type'] = conn_data.send_contenttype
+ extra['SOAPAction'] = "\"#{ conn_data.soapaction }\""
+ extra['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip?
+ send_string = conn_data.send_string
+ @wiredump_dev << "Wire dump:\n\n" if @wiredump_dev
+ begin
+ retry_count = 0
+ while true
+ res = @client.post(endpoint_url, send_string, extra)
+ if RETRYABLE and HTTP::Status.redirect?(res.status)
+ retry_count += 1
+ if retry_count >= MAX_RETRY_COUNT
+ raise HTTPStreamError.new("redirect count exceeded")
+ end
+ endpoint_url = res.header["location"][0]
+ puts "redirected to #{endpoint_url}" if $DEBUG
+ else
+ break
+ end
+ end
+ rescue
+ @client.reset(endpoint_url)
+ raise
+ end
+ @wiredump_dev << "\n\n" if @wiredump_dev
+ receive_string = res.content
+ if @wiredump_file_base
+ filename = @wiredump_file_base + '_response.xml'
+ f = File.open(filename, "w")
+ f << receive_string
+ f.close
+ end
+ case res.status
+ when 405
+ raise PostUnavailableError.new("#{ res.status }: #{ res.reason }")
+ when 200, 500
+ # Nothing to do.
+ else
+ raise HTTPStreamError.new("#{ res.status }: #{ res.reason }")
+ end
+ if res.respond_to?(:header) and !res.header['content-encoding'].empty? and
+ res.header['content-encoding'][0].downcase == 'gzip'
+ receive_string = decode_gzip(receive_string)
+ end
+ conn_data.receive_string = receive_string
+ conn_data.receive_contenttype = res.contenttype
+ conn_data
+ end
+
+ def send_accept_encoding_gzip?
+ @accept_encoding_gzip and defined?(::Zlib)
+ end
+
+ def decode_gzip(instring)
+ unless send_accept_encoding_gzip?
+ raise HTTPStreamError.new("Gzipped response content.")
+ end
+ begin
+ gz = Zlib::GzipReader.new(StringIO.new(instring))
+ gz.read
+ ensure
+ gz.close
+ end
+ end
+end
+
+
+end
diff --git a/lib/soap/wsdlDriver.rb b/lib/soap/wsdlDriver.rb
new file mode 100644
index 0000000000..eba9608df5
--- /dev/null
+++ b/lib/soap/wsdlDriver.rb
@@ -0,0 +1,575 @@
+# SOAP4R - SOAP WSDL driver
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/parser'
+require 'wsdl/importer'
+require 'xsd/qname'
+require 'xsd/codegen/gensupport'
+require 'soap/mapping/wsdlencodedregistry'
+require 'soap/mapping/wsdlliteralregistry'
+require 'soap/rpc/driver'
+require 'wsdl/soap/methodDefCreator'
+
+
+module SOAP
+
+
+class WSDLDriverFactory
+ class FactoryError < StandardError; end
+
+ attr_reader :wsdl
+
+ def initialize(wsdl)
+ @wsdl = import(wsdl)
+ @methoddefcreator = WSDL::SOAP::MethodDefCreator.new(@wsdl)
+ end
+
+ def inspect
+ "#<#{self.class}:#{@wsdl.name}>"
+ end
+
+ def create_rpc_driver(servicename = nil, portname = nil)
+ port = find_port(servicename, portname)
+ drv = SOAP::RPC::Driver.new(port.soap_address.location)
+ init_driver(drv, port)
+ add_operation(drv, port)
+ drv
+ end
+
+ # depricated old interface
+ def create_driver(servicename = nil, portname = nil)
+ warn("WSDLDriverFactory#create_driver is depricated. Use create_rpc_driver instead.")
+ port = find_port(servicename, portname)
+ WSDLDriver.new(@wsdl, port, nil)
+ end
+
+ # Backward compatibility.
+ alias createDriver create_driver
+
+private
+
+ def find_port(servicename = nil, portname = nil)
+ service = port = nil
+ if servicename
+ service = @wsdl.service(
+ XSD::QName.new(@wsdl.targetnamespace, servicename))
+ else
+ service = @wsdl.services[0]
+ end
+ if service.nil?
+ raise FactoryError.new("service #{servicename} not found in WSDL")
+ end
+ if portname
+ port = service.ports[XSD::QName.new(@wsdl.targetnamespace, portname)]
+ if port.nil?
+ raise FactoryError.new("port #{portname} not found in WSDL")
+ end
+ else
+ port = service.ports.find { |port| !port.soap_address.nil? }
+ if port.nil?
+ raise FactoryError.new("no ports have soap:address")
+ end
+ end
+ if port.soap_address.nil?
+ raise FactoryError.new("soap:address element not found in WSDL")
+ end
+ port
+ end
+
+ def init_driver(drv, port)
+ wsdl_elements = @wsdl.collect_elements
+ wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
+ rpc_decode_typemap = wsdl_types +
+ @wsdl.soap_rpc_complextypes(port.find_binding)
+ drv.proxy.mapping_registry =
+ Mapping::WSDLEncodedRegistry.new(rpc_decode_typemap)
+ drv.proxy.literal_mapping_registry =
+ Mapping::WSDLLiteralRegistry.new(wsdl_types, wsdl_elements)
+ end
+
+ def add_operation(drv, port)
+ port.find_binding.operations.each do |op_bind|
+ op_name = op_bind.soapoperation_name
+ soapaction = op_bind.soapaction || ''
+ orgname = op_name.name
+ name = XSD::CodeGen::GenSupport.safemethodname(orgname)
+ param_def = create_param_def(op_bind)
+ opt = {
+ :request_style => op_bind.soapoperation_style,
+ :response_style => op_bind.soapoperation_style,
+ :request_use => op_bind.input.soapbody_use,
+ :response_use => op_bind.output.soapbody_use,
+ :elementformdefault => false,
+ :attributeformdefault => false
+ }
+ if op_bind.soapoperation_style == :rpc
+ drv.add_rpc_operation(op_name, soapaction, name, param_def, opt)
+ else
+ drv.add_document_operation(soapaction, name, param_def, opt)
+ end
+ if orgname != name and orgname.capitalize == name.capitalize
+ ::SOAP::Mapping.define_singleton_method(drv, orgname) do |*arg|
+ __send__(name, *arg)
+ end
+ end
+ end
+ end
+
+ def import(location)
+ WSDL::Importer.import(location)
+ end
+
+ def create_param_def(op_bind)
+ op = op_bind.find_operation
+ if op_bind.soapoperation_style == :rpc
+ param_def = @methoddefcreator.collect_rpcparameter(op)
+ else
+ param_def = @methoddefcreator.collect_documentparameter(op)
+ end
+ # the first element of typedef in param_def is a String like
+ # "::SOAP::SOAPStruct". turn this String to a class.
+ param_def.collect { |io, name, typedef|
+ typedef[0] = Mapping.class_from_name(typedef[0])
+ [io, name, typedef]
+ }
+ end
+
+ def partqname(part)
+ if part.type
+ part.type
+ else
+ part.element
+ end
+ end
+
+ def param_def(type, name, klass, partqname)
+ [type, name, [klass, partqname.namespace, partqname.name]]
+ end
+
+ def filter_parts(partsdef, partssource)
+ parts = partsdef.split(/\s+/)
+ partssource.find_all { |part| parts.include?(part.name) }
+ end
+end
+
+
+class WSDLDriver
+ class << self
+ if RUBY_VERSION >= "1.7.0"
+ def __attr_proxy(symbol, assignable = false)
+ name = symbol.to_s
+ define_method(name) {
+ @servant.__send__(name)
+ }
+ if assignable
+ aname = name + '='
+ define_method(aname) { |rhs|
+ @servant.__send__(aname, rhs)
+ }
+ end
+ end
+ else
+ def __attr_proxy(symbol, assignable = false)
+ name = symbol.to_s
+ module_eval <<-EOS
+ def #{name}
+ @servant.#{name}
+ end
+ EOS
+ if assignable
+ module_eval <<-EOS
+ def #{name}=(value)
+ @servant.#{name} = value
+ end
+ EOS
+ end
+ end
+ end
+ end
+
+ __attr_proxy :options
+ __attr_proxy :headerhandler
+ __attr_proxy :streamhandler
+ __attr_proxy :test_loopback_response
+ __attr_proxy :endpoint_url, true
+ __attr_proxy :mapping_registry, true # for RPC unmarshal
+ __attr_proxy :wsdl_mapping_registry, true # for RPC marshal
+ __attr_proxy :default_encodingstyle, true
+ __attr_proxy :generate_explicit_type, true
+ __attr_proxy :allow_unqualified_element, true
+
+ def httpproxy
+ @servant.options["protocol.http.proxy"]
+ end
+
+ def httpproxy=(httpproxy)
+ @servant.options["protocol.http.proxy"] = httpproxy
+ end
+
+ def wiredump_dev
+ @servant.options["protocol.http.wiredump_dev"]
+ end
+
+ def wiredump_dev=(wiredump_dev)
+ @servant.options["protocol.http.wiredump_dev"] = wiredump_dev
+ end
+
+ def mandatorycharset
+ @servant.options["protocol.mandatorycharset"]
+ end
+
+ def mandatorycharset=(mandatorycharset)
+ @servant.options["protocol.mandatorycharset"] = mandatorycharset
+ end
+
+ def wiredump_file_base
+ @servant.options["protocol.wiredump_file_base"]
+ end
+
+ def wiredump_file_base=(wiredump_file_base)
+ @servant.options["protocol.wiredump_file_base"] = wiredump_file_base
+ end
+
+ def initialize(wsdl, port, logdev)
+ @servant = Servant__.new(self, wsdl, port, logdev)
+ end
+
+ def inspect
+ "#<#{self.class}:#{@servant.port.name}>"
+ end
+
+ def reset_stream
+ @servant.reset_stream
+ end
+
+ # Backward compatibility.
+ alias generateEncodeType= generate_explicit_type=
+
+ class Servant__
+ include SOAP
+
+ attr_reader :options
+ attr_reader :port
+
+ attr_accessor :soapaction
+ attr_accessor :default_encodingstyle
+ attr_accessor :allow_unqualified_element
+ attr_accessor :generate_explicit_type
+ attr_accessor :mapping_registry
+ attr_accessor :wsdl_mapping_registry
+
+ def initialize(host, wsdl, port, logdev)
+ @host = host
+ @wsdl = wsdl
+ @port = port
+ @logdev = logdev
+ @soapaction = nil
+ @options = setup_options
+ @default_encodingstyle = nil
+ @allow_unqualified_element = nil
+ @generate_explicit_type = false
+ @mapping_registry = nil # for rpc unmarshal
+ @wsdl_mapping_registry = nil # for rpc marshal
+ @wiredump_file_base = nil
+ @mandatorycharset = nil
+ @wsdl_elements = @wsdl.collect_elements
+ @wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
+ @rpc_decode_typemap = @wsdl_types +
+ @wsdl.soap_rpc_complextypes(port.find_binding)
+ @wsdl_mapping_registry = Mapping::WSDLEncodedRegistry.new(
+ @rpc_decode_typemap)
+ @doc_mapper = Mapping::WSDLLiteralRegistry.new(
+ @wsdl_types, @wsdl_elements)
+ endpoint_url = @port.soap_address.location
+ # Convert a map which key is QName, to a Hash which key is String.
+ @operation = {}
+ @port.inputoperation_map.each do |op_name, op_info|
+ orgname = op_name.name
+ name = XSD::CodeGen::GenSupport.safemethodname(orgname)
+ @operation[name] = @operation[orgname] = op_info
+ add_method_interface(op_info)
+ end
+ @proxy = ::SOAP::RPC::Proxy.new(endpoint_url, @soapaction, @options)
+ end
+
+ def inspect
+ "#<#{self.class}:#{@proxy.inspect}>"
+ end
+
+ def endpoint_url
+ @proxy.endpoint_url
+ end
+
+ def endpoint_url=(endpoint_url)
+ @proxy.endpoint_url = endpoint_url
+ end
+
+ def headerhandler
+ @proxy.headerhandler
+ end
+
+ def streamhandler
+ @proxy.streamhandler
+ end
+
+ def test_loopback_response
+ @proxy.test_loopback_response
+ end
+
+ def reset_stream
+ @proxy.reset_stream
+ end
+
+ def rpc_call(name, *values)
+ set_wiredump_file_base(name)
+ unless op_info = @operation[name]
+ raise RuntimeError, "method: #{name} not defined"
+ end
+ req_header = create_request_header
+ req_body = create_request_body(op_info, *values)
+ reqopt = create_options({
+ :soapaction => op_info.soapaction || @soapaction})
+ resopt = create_options({
+ :decode_typemap => @rpc_decode_typemap})
+ env = @proxy.route(req_header, req_body, reqopt, resopt)
+ raise EmptyResponseError unless env
+ receive_headers(env.header)
+ begin
+ @proxy.check_fault(env.body)
+ rescue ::SOAP::FaultError => e
+ Mapping.fault2exception(e)
+ end
+ ret = env.body.response ?
+ Mapping.soap2obj(env.body.response, @mapping_registry) : nil
+ if env.body.outparams
+ outparams = env.body.outparams.collect { |outparam|
+ Mapping.soap2obj(outparam)
+ }
+ return [ret].concat(outparams)
+ else
+ return ret
+ end
+ end
+
+ # req_header: [[element, mustunderstand, encodingstyle(QName/String)], ...]
+ # req_body: SOAPBasetype/SOAPCompoundtype
+ def document_send(name, header_obj, body_obj)
+ set_wiredump_file_base(name)
+ unless op_info = @operation[name]
+ raise RuntimeError, "method: #{name} not defined"
+ end
+ req_header = header_obj ? header_from_obj(header_obj, op_info) : nil
+ req_body = body_from_obj(body_obj, op_info)
+ opt = create_options({
+ :soapaction => op_info.soapaction || @soapaction,
+ :decode_typemap => @wsdl_types})
+ env = @proxy.invoke(req_header, req_body, opt)
+ raise EmptyResponseError unless env
+ if env.body.fault
+ raise ::SOAP::FaultError.new(env.body.fault)
+ end
+ res_body_obj = env.body.response ?
+ Mapping.soap2obj(env.body.response, @mapping_registry) : nil
+ return env.header, res_body_obj
+ end
+
+ private
+
+ def create_options(hash = nil)
+ opt = {}
+ opt[:default_encodingstyle] = @default_encodingstyle
+ opt[:allow_unqualified_element] = @allow_unqualified_element
+ opt[:generate_explicit_type] = @generate_explicit_type
+ opt.update(hash) if hash
+ opt
+ end
+
+ def set_wiredump_file_base(name)
+ if @wiredump_file_base
+ @proxy.set_wiredump_file_base(@wiredump_file_base + "_#{name}")
+ end
+ end
+
+ def create_request_header
+ headers = @proxy.headerhandler.on_outbound
+ if headers.empty?
+ nil
+ else
+ h = SOAPHeader.new
+ headers.each do |header|
+ h.add(header.elename.name, header)
+ end
+ h
+ end
+ end
+
+ def receive_headers(headers)
+ @proxy.headerhandler.on_inbound(headers) if headers
+ end
+
+ def create_request_body(op_info, *values)
+ method = create_method_struct(op_info, *values)
+ SOAPBody.new(method)
+ end
+
+ def create_method_struct(op_info, *params)
+ parts_names = op_info.bodyparts.collect { |part| part.name }
+ obj = create_method_obj(parts_names, params)
+ method = Mapping.obj2soap(obj, @wsdl_mapping_registry, op_info.op_name)
+ if method.members.size != parts_names.size
+ new_method = SOAPStruct.new
+ method.each do |key, value|
+ if parts_names.include?(key)
+ new_method.add(key, value)
+ end
+ end
+ method = new_method
+ end
+ method.elename = op_info.op_name
+ method.type = XSD::QName.new # Request should not be typed.
+ method
+ end
+
+ def create_method_obj(names, params)
+ o = Object.new
+ idx = 0
+ while idx < params.length
+ o.instance_variable_set('@' + names[idx], params[idx])
+ idx += 1
+ end
+ o
+ end
+
+ def header_from_obj(obj, op_info)
+ if obj.is_a?(SOAPHeader)
+ obj
+ elsif op_info.headerparts.empty?
+ if obj.nil?
+ nil
+ else
+ raise RuntimeError.new("no header definition in schema: #{obj}")
+ end
+ elsif op_info.headerparts.size == 1
+ part = op_info.headerparts[0]
+ header = SOAPHeader.new()
+ header.add(headeritem_from_obj(obj, part.element || part.eletype))
+ header
+ else
+ header = SOAPHeader.new()
+ op_info.headerparts.each do |part|
+ child = Mapping.get_attribute(obj, part.name)
+ ele = headeritem_from_obj(child, part.element || part.eletype)
+ header.add(part.name, ele)
+ end
+ header
+ end
+ end
+
+ def headeritem_from_obj(obj, name)
+ if obj.nil?
+ SOAPElement.new(name)
+ elsif obj.is_a?(SOAPHeaderItem)
+ obj
+ else
+ Mapping.obj2soap(obj, @doc_mapper, name)
+ end
+ end
+
+ def body_from_obj(obj, op_info)
+ if obj.is_a?(SOAPBody)
+ obj
+ elsif op_info.bodyparts.empty?
+ if obj.nil?
+ nil
+ else
+ raise RuntimeError.new("no body found in schema")
+ end
+ elsif op_info.bodyparts.size == 1
+ part = op_info.bodyparts[0]
+ ele = bodyitem_from_obj(obj, part.element || part.type)
+ SOAPBody.new(ele)
+ else
+ body = SOAPBody.new
+ op_info.bodyparts.each do |part|
+ child = Mapping.get_attribute(obj, part.name)
+ ele = bodyitem_from_obj(child, part.element || part.type)
+ body.add(ele.elename.name, ele)
+ end
+ body
+ end
+ end
+
+ def bodyitem_from_obj(obj, name)
+ if obj.nil?
+ SOAPElement.new(name)
+ elsif obj.is_a?(SOAPElement)
+ obj
+ else
+ Mapping.obj2soap(obj, @doc_mapper, name)
+ end
+ end
+
+ def add_method_interface(op_info)
+ name = XSD::CodeGen::GenSupport.safemethodname(op_info.op_name.name)
+ orgname = op_info.op_name.name
+ parts_names = op_info.bodyparts.collect { |part| part.name }
+ case op_info.style
+ when :document
+ if orgname != name and orgname.capitalize == name.capitalize
+ add_document_method_interface(orgname, parts_names)
+ end
+ add_document_method_interface(name, parts_names)
+ when :rpc
+ if orgname != name and orgname.capitalize == name.capitalize
+ add_rpc_method_interface(orgname, parts_names)
+ end
+ add_rpc_method_interface(name, parts_names)
+ else
+ raise RuntimeError.new("unknown style: #{op_info.style}")
+ end
+ end
+
+ def add_rpc_method_interface(name, parts_names)
+ ::SOAP::Mapping.define_singleton_method(@host, name) do |*arg|
+ unless arg.size == parts_names.size
+ raise ArgumentError.new(
+ "wrong number of arguments (#{arg.size} for #{parts_names.size})")
+ end
+ @servant.rpc_call(name, *arg)
+ end
+ @host.method(name)
+ end
+
+ def add_document_method_interface(name, parts_names)
+ ::SOAP::Mapping.define_singleton_method(@host, name) do |h, b|
+ @servant.document_send(name, h, b)
+ end
+ @host.method(name)
+ end
+
+ def setup_options
+ if opt = Property.loadproperty(::SOAP::PropertyName)
+ opt = opt["client"]
+ end
+ opt ||= Property.new
+ opt.add_hook("protocol.mandatorycharset") do |key, value|
+ @mandatorycharset = value
+ end
+ opt.add_hook("protocol.wiredump_file_base") do |key, value|
+ @wiredump_file_base = value
+ end
+ opt["protocol.http.charset"] ||= XSD::Charset.xml_encoding_label
+ opt["protocol.http.proxy"] ||= Env::HTTP_PROXY
+ opt["protocol.http.no_proxy"] ||= Env::NO_PROXY
+ opt
+ end
+ end
+end
+
+
+end
diff --git a/lib/sync.rb b/lib/sync.rb
index 356a6893ab..79522ed885 100644
--- a/lib/sync.rb
+++ b/lib/sync.rb
@@ -23,8 +23,9 @@
# Sync_m#sync_lock, lock
# Sync_m#sync_unlock, unlock
#
-# Sync, Synchronizer:
-# Usage:
+# Sync, Synchronicer:
+# include Sync_m
+# Usage:
# sync = Sync.new
#
# Sync#mode
@@ -39,7 +40,7 @@
#
unless defined? Thread
- raise "Thread not available for this ruby interpreter"
+ fail "Thread not available for this ruby interpreter"
end
module Sync_m
@@ -88,18 +89,19 @@ module Sync_m
def Sync_m.append_features(cl)
super
- # do nothing for Modules
- # make aliases for Classes.
- define_aliases(cl) unless cl.instance_of?(Module)
- self
+ unless cl.instance_of?(Module)
+ # do nothing for Modules
+ # make aliases and include the proper module.
+ define_aliases(cl)
+ end
end
def Sync_m.extend_object(obj)
super
- obj.sync_extend
+ obj.sync_extended
end
-
- def sync_extend
+
+ def sync_extended
unless (defined? locked? and
defined? shared? and
defined? exclusive? and
@@ -128,120 +130,116 @@ module Sync_m
# locking methods.
def sync_try_lock(mode = EX)
return unlock if sync_mode == UN
- @sync_mutex.synchronize do
- ret = sync_try_lock_sub(sync_mode)
- end
+
+ Thread.critical = true
+ ret = sync_try_lock_sub(sync_mode)
+ Thread.critical = false
ret
end
def sync_lock(m = EX)
return unlock if m == UN
- while true
- @sync_mutex.synchronize do
- if sync_try_lock_sub(m)
- return self
- else
- if sync_sh_locker[Thread.current]
- sync_upgrade_waiting.push [Thread.current, sync_sh_locker[Thread.current]]
- sync_sh_locker.delete(Thread.current)
- else
- sync_waiting.push Thread.current
- end
- @sync_mutex.sleep
- end
+ until (Thread.critical = true; sync_try_lock_sub(m))
+ if sync_sh_locker[Thread.current]
+ sync_upgrade_waiting.push [Thread.current, sync_sh_locker[Thread.current]]
+ sync_sh_locker.delete(Thread.current)
+ else
+ sync_waiting.push Thread.current
end
+ Thread.stop
end
+ Thread.critical = false
self
end
def sync_unlock(m = EX)
- wakeup_threads = []
- @sync_mutex.synchronize do
- if sync_mode == UN
+ Thread.critical = true
+ if sync_mode == UN
+ Thread.critical = false
+ Err::UnknownLocker.Fail(Thread.current)
+ end
+
+ m = sync_mode if m == EX and sync_mode == SH
+
+ runnable = false
+ case m
+ when UN
+ Thread.critical = false
+ Err::UnknownLocker.Fail(Thread.current)
+
+ when EX
+ if sync_ex_locker == Thread.current
+ if (self.sync_ex_count = sync_ex_count - 1) == 0
+ self.sync_ex_locker = nil
+ if sync_sh_locker.include?(Thread.current)
+ self.sync_mode = SH
+ else
+ self.sync_mode = UN
+ end
+ runnable = true
+ end
+ else
Err::UnknownLocker.Fail(Thread.current)
end
- m = sync_mode if m == EX and sync_mode == SH
-
- runnable = false
- case m
- when UN
+ when SH
+ if (count = sync_sh_locker[Thread.current]).nil?
Err::UnknownLocker.Fail(Thread.current)
-
- when EX
- if sync_ex_locker == Thread.current
- if (self.sync_ex_count = sync_ex_count - 1) == 0
- self.sync_ex_locker = nil
- if sync_sh_locker.include?(Thread.current)
- self.sync_mode = SH
- else
- self.sync_mode = UN
- end
+ else
+ if (sync_sh_locker[Thread.current] = count - 1) == 0
+ sync_sh_locker.delete(Thread.current)
+ if sync_sh_locker.empty? and sync_ex_count == 0
+ self.sync_mode = UN
runnable = true
end
- else
- Err::UnknownLocker.Fail(Thread.current)
end
+ end
+ end
+
+ if runnable
+ if sync_upgrade_waiting.size > 0
+ for k, v in sync_upgrade_waiting
+ sync_sh_locker[k] = v
+ end
+ wait = sync_upgrade_waiting
+ self.sync_upgrade_waiting = []
+ Thread.critical = false
- when SH
- if (count = sync_sh_locker[Thread.current]).nil?
- Err::UnknownLocker.Fail(Thread.current)
- else
- if (sync_sh_locker[Thread.current] = count - 1) == 0
- sync_sh_locker.delete(Thread.current)
- if sync_sh_locker.empty? and sync_ex_count == 0
- self.sync_mode = UN
- runnable = true
- end
- end
+ for w, v in wait
+ w.run
end
- end
-
- if runnable
- if sync_upgrade_waiting.size > 0
- th, count = sync_upgrade_waiting.shift
- sync_sh_locker[th] = count
- th.wakeup
- wakeup_threads.push th
- else
- wait = sync_waiting
- self.sync_waiting = []
- for th in wait
- th.wakeup
- wakeup_threads.push th
- end
+ else
+ wait = sync_waiting
+ self.sync_waiting = []
+ Thread.critical = false
+ for w in wait
+ w.run
end
end
end
- for th in wakeup_threads
- th.run
- end
+
+ Thread.critical = false
self
end
def sync_synchronize(mode = EX)
- sync_lock(mode)
begin
+ sync_lock(mode)
yield
ensure
sync_unlock
end
end
- attr_accessor :sync_mode
+ attr :sync_mode, true
+
+ attr :sync_waiting, true
+ attr :sync_upgrade_waiting, true
+ attr :sync_sh_locker, true
+ attr :sync_ex_locker, true
+ attr :sync_ex_count, true
- attr_accessor :sync_waiting
- attr_accessor :sync_upgrade_waiting
- attr_accessor :sync_sh_locker
- attr_accessor :sync_ex_locker
- attr_accessor :sync_ex_count
-
- def sync_inspect
- sync_iv = instance_variables.select{|iv| /^@sync_/ =~ iv.id2name}.collect{|iv| iv.id2name + '=' + instance_eval(iv.id2name).inspect}.join(",")
- print "<#{self.class}.extend Sync_m: #{inspect}, <Sync_m: #{sync_iv}>"
- end
-
private
def sync_initialize
@@ -251,13 +249,11 @@ module Sync_m
@sync_sh_locker = Hash.new
@sync_ex_locker = nil
@sync_ex_count = 0
-
- @sync_mutex = Mutex.new
end
def initialize(*args)
- super
sync_initialize
+ super
end
def sync_try_lock_sub(m)
@@ -283,7 +279,7 @@ module Sync_m
end
when EX
if sync_mode == UN or
- sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
+ sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
self.sync_mode = m
self.sync_ex_locker = Thread.current
self.sync_ex_count = 1
@@ -295,6 +291,7 @@ module Sync_m
ret = false
end
else
+ Thread.critical = false
Err::LockModeFailer.Fail mode
end
return ret
@@ -303,6 +300,12 @@ end
Synchronizer_m = Sync_m
class Sync
+ #Sync_m.extend_class self
include Sync_m
+
+ def initialize
+ super
+ end
+
end
Synchronizer = Sync
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 5eb294e390..c984cd3393 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -6,14 +6,12 @@
require 'delegate'
require 'tmpdir'
-require 'thread'
# A class for managing temporary files. This library is written to be
# thread safe.
class Tempfile < DelegateClass(File)
MAX_TRY = 10
@@cleanlist = []
- @@lock = Mutex.new
# Creates a temporary file of mode 0600 in the temporary directory,
# opens it with mode "w+", and returns a Tempfile object which
@@ -34,23 +32,27 @@ class Tempfile < DelegateClass(File)
tmpdir = '/tmp'
end
- lock = tmpname = nil
+ lock = nil
n = failure = 0
- @@lock.synchronize {
+
+ begin
+ Thread.critical = true
+
begin
- begin
- tmpname = File.join(tmpdir, make_tmpname(basename, n))
- lock = tmpname + '.lock'
- n += 1
- end while @@cleanlist.include?(tmpname) or
- File.exist?(lock) or File.exist?(tmpname)
- Dir.mkdir(lock)
- rescue
- failure += 1
- retry if failure < MAX_TRY
- raise "cannot generate tempfile `%s'" % tmpname
- end
- }
+ tmpname = File.join(tmpdir, make_tmpname(basename, n))
+ lock = tmpname + '.lock'
+ n += 1
+ end while @@cleanlist.include?(tmpname) or
+ File.exist?(lock) or File.exist?(tmpname)
+
+ Dir.mkdir(lock)
+ rescue
+ failure += 1
+ retry if failure < MAX_TRY
+ raise "cannot generate tempfile `%s'" % tmpname
+ ensure
+ Thread.critical = false
+ end
@data = [tmpname]
@clean_proc = Tempfile.callback(@data)
@@ -95,10 +97,10 @@ class Tempfile < DelegateClass(File)
@tmpfile.close if @tmpfile
@tmpfile = nil
@data[1] = nil if @data
- end
+ end
protected :_close
- #Closes the file. If the optional flag is true, unlinks the file
+ # Closes the file. If the optional flag is true, unlinks the file
# after closing.
#
# If you don't explicitly unlink the temporary file, the removal
@@ -156,7 +158,7 @@ class Tempfile < DelegateClass(File)
class << self
def callback(data) # :nodoc:
pid = $$
- Proc.new {
+ lambda{
if pid == $$
path, tmpfile, cleanlist = *data
diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb
index 0d55b0b068..aa97799de8 100644
--- a/lib/test/unit/assertions.rb
+++ b/lib/test/unit/assertions.rb
@@ -5,8 +5,8 @@
require 'test/unit/assertionfailederror'
require 'test/unit/util/backtracefilter'
-module Test # :nodoc:
- module Unit # :nodoc:
+module Test
+ module Unit
##
# Test::Unit::Assertions contains the standard Test::Unit assertions.
@@ -480,13 +480,13 @@ EOT
# +arguments+ replaces the '?'s positionally in the template.
public
- def build_message(head, template=nil, *arguments) # :nodoc:
+ def build_message(head, template=nil, *arguments)
template &&= template.chomp
return AssertionMessage.new(head, template, arguments)
end
private
- def _wrap_assertion # :nodoc:
+ def _wrap_assertion
@_assertion_wrapped ||= false
unless (@_assertion_wrapped)
@_assertion_wrapped = true
diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb
index 861b50e00f..86c9b12940 100644
--- a/lib/test/unit/autorunner.rb
+++ b/lib/test/unit/autorunner.rb
@@ -81,7 +81,7 @@ module Test
@filters = []
@to_run = []
@output_level = UI::NORMAL
- @workdir = false
+ @workdir = nil
yield(self) if(block_given?)
end
diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb
index 59c664dbb7..97c8d28481 100644
--- a/lib/test/unit/collector/dir.rb
+++ b/lib/test/unit/collector/dir.rb
@@ -91,7 +91,7 @@ module Test
end
find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
ensure
- $:.delete_at($:.index(dir)) if dir
+ $:.delete_at($:.rindex(dir)) if(dir)
end
def realdir(path)
diff --git a/lib/test/unit/collector/objectspace.rb b/lib/test/unit/collector/objectspace.rb
index a0f837e33e..d1127a981f 100644
--- a/lib/test/unit/collector/objectspace.rb
+++ b/lib/test/unit/collector/objectspace.rb
@@ -8,7 +8,7 @@ module Test
module Unit
module Collector
class ObjectSpace
- include Test::Unit::Collector
+ include Collector
NAME = 'collected from the ObjectSpace'
diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb
index 017cd15b8c..f53b460c5d 100644
--- a/lib/test/unit/testcase.rb
+++ b/lib/test/unit/testcase.rb
@@ -37,7 +37,9 @@ module Test
# Creates a new instance of the fixture for running the
# test represented by test_method_name.
def initialize(test_method_name)
- unless(respond_to?(test_method_name) && method(test_method_name).arity == 0)
+ unless(respond_to?(test_method_name) and
+ (method(test_method_name).arity == 0 ||
+ method(test_method_name).arity == -1))
throw :invalid_test
end
@method_name = test_method_name
@@ -59,7 +61,7 @@ module Test
end
if (suite.empty?)
catch(:invalid_test) do
- suite << new(:default_test)
+ suite << new("default_test")
end
end
return suite
@@ -115,22 +117,22 @@ module Test
end
private :passed?
- def size # :nodoc:
+ def size
1
end
- def add_assertion # :nodoc:
+ def add_assertion
@_result.add_assertion
end
private :add_assertion
- def add_failure(message, all_locations=caller()) # :nodoc:
+ def add_failure(message, all_locations=caller())
@test_passed = false
@_result.add_failure(Failure.new(name, filter_backtrace(all_locations), message))
end
private :add_failure
- def add_error(exception) # :nodoc:
+ def add_error(exception)
@test_passed = false
@_result.add_error(Error.new(name, exception))
end
diff --git a/lib/test/unit/testresult.rb b/lib/test/unit/testresult.rb
index 3fe9b7c57f..e3a472ef7f 100644
--- a/lib/test/unit/testresult.rb
+++ b/lib/test/unit/testresult.rb
@@ -1,5 +1,4 @@
#--
-#
# Author:: Nathaniel Talbott.
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
# License:: Ruby license.
diff --git a/lib/test/unit/ui/console/testrunner.rb b/lib/test/unit/ui/console/testrunner.rb
index 2bd01eefa8..6b600e319a 100644
--- a/lib/test/unit/ui/console/testrunner.rb
+++ b/lib/test/unit/ui/console/testrunner.rb
@@ -10,7 +10,7 @@ require 'test/unit/ui/testrunnerutilities'
module Test
module Unit
module UI
- module Console # :nodoc:
+ module Console
# Runs a Test::Unit::TestSuite on the console.
class TestRunner
@@ -42,7 +42,7 @@ module Test
end
private
- def setup_mediator # :nodoc:
+ def setup_mediator
@mediator = create_mediator(@suite)
suite_name = @suite.to_s
if ( @suite.kind_of?(Module) )
@@ -51,11 +51,11 @@ module Test
output("Loaded suite #{suite_name}")
end
- def create_mediator(suite) # :nodoc:
+ def create_mediator(suite)
return TestRunnerMediator.new(suite)
end
- def attach_to_mediator # :nodoc:
+ def attach_to_mediator
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
@@ -63,11 +63,11 @@ module Test
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
end
- def start_mediator # :nodoc:
+ def start_mediator
return @mediator.run_suite
end
- def add_fault(fault) # :nodoc:
+ def add_fault(fault)
@faults << fault
output_single(fault.single_character_display, PROGRESS_ONLY)
@already_outputted = true
@@ -90,8 +90,6 @@ module Test
end
def test_started(name)
- $0 += "\0#{name}"
- $0.sub!(/\0.*\z/, '')
output_single(name + ": ", VERBOSE)
end
diff --git a/lib/test/unit/ui/fox/testrunner.rb b/lib/test/unit/ui/fox/testrunner.rb
index 34a8ff1288..a23a450567 100644
--- a/lib/test/unit/ui/fox/testrunner.rb
+++ b/lib/test/unit/ui/fox/testrunner.rb
@@ -13,7 +13,7 @@ include Fox
module Test
module Unit
module UI
- module Fox # :nodoc:
+ module Fox
# Runs a Test::Unit::TestSuite in a Fox UI. Obviously,
# this one requires you to have Fox
@@ -49,7 +49,7 @@ module Test
@result
end
- def setup_mediator # :nodoc:
+ def setup_mediator
@mediator = TestRunnerMediator.new(@suite)
suite_name = @suite.to_s
if ( @suite.kind_of?(Module) )
@@ -58,7 +58,7 @@ module Test
@suite_name_entry.text = suite_name
end
- def attach_to_mediator # :nodoc:
+ def attach_to_mediator
@mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui))
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
@mediator.add_listener(TestResult::CHANGED, &method(:result_changed))
@@ -67,7 +67,7 @@ module Test
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
end
- def start_ui # :nodoc:
+ def start_ui
@application.create
@window.show(PLACEMENT_SCREEN)
@application.addTimeout(1) do
@@ -76,11 +76,11 @@ module Test
@application.run
end
- def stop # :nodoc:
+ def stop
@application.exit(0)
end
- def reset_ui(count) # :nodoc:
+ def reset_ui(count)
@test_progress_bar.barColor = GREEN_STYLE
@test_progress_bar.total = count
@test_progress_bar.progress = 0
@@ -94,7 +94,7 @@ module Test
@fault_list.clearItems
end
- def add_fault(fault) # :nodoc:
+ def add_fault(fault)
if ( ! @red )
@test_progress_bar.barColor = RED_STYLE
@red = true
@@ -103,19 +103,19 @@ module Test
@fault_list.appendItem(item)
end
- def show_fault(fault) # :nodoc:
+ def show_fault(fault)
raw_show_fault(fault.long_display)
end
- def raw_show_fault(string) # :nodoc:
+ def raw_show_fault(string)
@detail_text.setText(string)
end
- def clear_fault # :nodoc:
+ def clear_fault
raw_show_fault("")
end
- def result_changed(result) # :nodoc:
+ def result_changed(result)
@test_progress_bar.progress = result.run_count
@test_count_label.text = result.run_count.to_s
@@ -128,7 +128,7 @@ module Test
@application.flush
end
- def started(result) # :nodoc:
+ def started(result)
@result = result
output_status("Started...")
end
@@ -146,7 +146,7 @@ module Test
@status_entry.repaint
end
- def setup_ui # :nodoc:
+ def setup_ui
@application = create_application
create_tooltip(@application)
@@ -180,7 +180,7 @@ module Test
@detail_text = create_text(detail_panel)
end
- def create_application # :nodoc:
+ def create_application
app = FXApp.new("TestRunner", "Test::Unit")
app.init([])
app
@@ -194,25 +194,25 @@ module Test
FXTooltip.new(app)
end
- def create_main_panel(parent) # :nodoc:
+ def create_main_panel(parent)
panel = FXVerticalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y)
panel.vSpacing = 10
panel
end
- def create_suite_panel(parent) # :nodoc:
+ def create_suite_panel(parent)
FXHorizontalFrame.new(parent, LAYOUT_SIDE_LEFT | LAYOUT_FILL_X)
end
- def create_button(parent, text, action) # :nodoc:
+ def create_button(parent, text, action)
FXButton.new(parent, text).connect(SEL_COMMAND, &action)
end
- def create_progress_bar(parent) # :nodoc:
+ def create_progress_bar(parent)
FXProgressBar.new(parent, nil, 0, PROGRESSBAR_NORMAL | LAYOUT_FILL_X)
end
- def create_info_panel(parent) # :nodoc:
+ def create_info_panel(parent)
FXMatrix.new(parent, 1, MATRIX_BY_ROWS | LAYOUT_FILL_X)
end
@@ -220,11 +220,11 @@ module Test
FXLabel.new(parent, text, nil, JUSTIFY_CENTER_X | LAYOUT_FILL_COLUMN)
end
- def create_list_panel(parent) # :nodoc:
+ def create_list_panel(parent)
FXHorizontalFrame.new(parent, LAYOUT_FILL_X | FRAME_SUNKEN | FRAME_THICK)
end
- def create_fault_list(parent) # :nodoc:
+ def create_fault_list(parent)
list = FXList.new(parent, 10, nil, 0, LIST_SINGLESELECT | LAYOUT_FILL_X) #, 0, 0, 0, 150)
list.connect(SEL_COMMAND) do |sender, sel, ptr|
if sender.retrieveItem(sender.currentItem).selected?
@@ -236,22 +236,22 @@ module Test
list
end
- def create_detail_panel(parent) # :nodoc:
+ def create_detail_panel(parent)
FXHorizontalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK)
end
- def create_text(parent) # :nodoc:
+ def create_text(parent)
FXText.new(parent, nil, 0, TEXT_READONLY | LAYOUT_FILL_X | LAYOUT_FILL_Y)
end
- def create_entry(parent) # :nodoc:
+ def create_entry(parent)
entry = FXTextField.new(parent, 30, nil, 0, TEXTFIELD_NORMAL | LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X)
entry.disable
entry
end
end
- class FaultListItem < FXListItem # :nodoc: all
+ class FaultListItem < FXListItem
attr_reader(:fault)
def initialize(fault)
super(fault.short_display)
diff --git a/lib/test/unit/ui/gtk/testrunner.rb b/lib/test/unit/ui/gtk/testrunner.rb
index c63cc6a39b..994328dc9b 100644
--- a/lib/test/unit/ui/gtk/testrunner.rb
+++ b/lib/test/unit/ui/gtk/testrunner.rb
@@ -11,7 +11,7 @@ require 'test/unit/ui/testrunnerutilities'
module Test
module Unit
module UI
- module GTK # :nodoc:
+ module GTK
# Runs a Test::Unit::TestSuite in a Gtk UI. Obviously,
# this one requires you to have Gtk
@@ -49,7 +49,7 @@ module Test
end
private
- def setup_mediator # :nodoc:
+ def setup_mediator
@mediator = TestRunnerMediator.new(@suite)
suite_name = @suite.to_s
if ( @suite.kind_of?(Module) )
@@ -58,7 +58,7 @@ module Test
suite_name_entry.set_text(suite_name)
end
- def attach_to_mediator # :nodoc:
+ def attach_to_mediator
run_button.signal_connect("clicked", nil, &method(:run_test))
@mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui))
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
@@ -73,7 +73,7 @@ module Test
@runner.raise(@restart_signal)
end
- def start_ui # :nodoc:
+ def start_ui
@viewer.run
running = false
begin
@@ -93,11 +93,11 @@ module Test
end
end
- def stop(*) # :nodoc:
+ def stop(*)
Gtk.main_quit
end
- def reset_ui(count) # :nodoc:
+ def reset_ui(count)
test_progress_bar.set_style(green_style)
test_progress_bar.configure(0, 0, count)
@red = false
@@ -110,7 +110,7 @@ module Test
fault_list.remove_items(fault_list.children)
end
- def add_fault(fault) # :nodoc:
+ def add_fault(fault)
if ( ! @red )
test_progress_bar.set_style(red_style)
@red = true
@@ -120,27 +120,27 @@ module Test
fault_list.append_items([item])
end
- def show_fault(fault) # :nodoc:
+ def show_fault(fault)
raw_show_fault(fault.long_display)
end
- def raw_show_fault(string) # :nodoc:
+ def raw_show_fault(string)
fault_detail_label.set_text(string)
outer_detail_sub_panel.queue_resize
end
- def clear_fault # :nodoc:
+ def clear_fault
raw_show_fault("")
end
- def result_changed(result) # :nodoc:
+ def result_changed(result)
run_count_label.set_text(result.run_count.to_s)
assertion_count_label.set_text(result.assertion_count.to_s)
failure_count_label.set_text(result.failure_count.to_s)
error_count_label.set_text(result.error_count.to_s)
end
- def started(result) # :nodoc:
+ def started(result)
@result = result
output_status("Started...")
end
@@ -157,11 +157,11 @@ module Test
output_status("Finished in #{elapsed_time} seconds")
end
- def output_status(string) # :nodoc:
+ def output_status(string)
status_entry.set_text(string)
end
- def setup_ui # :nodoc:
+ def setup_ui
main_window.signal_connect("destroy", nil, &method(:stop))
main_window.show_all
fault_list.signal_connect("select-child", nil) {
@@ -174,7 +174,7 @@ module Test
@red = false
end
- def main_window # :nodoc:
+ def main_window
lazy_initialize(:main_window) {
@main_window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
@main_window.set_title("Test::Unit TestRunner")
@@ -185,7 +185,7 @@ module Test
}
end
- def main_panel # :nodoc:
+ def main_panel
lazy_initialize(:main_panel) {
@main_panel = Gtk::VBox.new(false, 0)
@main_panel.pack_start(suite_panel, false, false, 0)
@@ -197,7 +197,7 @@ module Test
}
end
- def suite_panel # :nodoc:
+ def suite_panel
lazy_initialize(:suite_panel) {
@suite_panel = Gtk::HBox.new(false, 10)
@suite_panel.border_width(10)
@@ -207,20 +207,20 @@ module Test
}
end
- def suite_name_entry # :nodoc:
+ def suite_name_entry
lazy_initialize(:suite_name_entry) {
@suite_name_entry = Gtk::Entry.new
@suite_name_entry.set_editable(false)
}
end
- def run_button # :nodoc:
+ def run_button
lazy_initialize(:run_button) {
@run_button = Gtk::Button.new("Run")
}
end
- def progress_panel # :nodoc:
+ def progress_panel
lazy_initialize(:progress_panel) {
@progress_panel = Gtk::HBox.new(false, 10)
@progress_panel.border_width(10)
@@ -228,7 +228,7 @@ module Test
}
end
- def test_progress_bar # :nodoc:
+ def test_progress_bar
lazy_initialize(:test_progress_bar) {
@test_progress_bar = EnhancedProgressBar.new
@test_progress_bar.set_usize(@test_progress_bar.allocation.width,
@@ -237,21 +237,21 @@ module Test
}
end
- def green_style # :nodoc:
+ def green_style
lazy_initialize(:green_style) {
@green_style = Gtk::Style.new
@green_style.set_bg(Gtk::STATE_PRELIGHT, 0x0000, 0xFFFF, 0x0000)
}
end
- def red_style # :nodoc:
+ def red_style
lazy_initialize(:red_style) {
@red_style = Gtk::Style.new
@red_style.set_bg(Gtk::STATE_PRELIGHT, 0xFFFF, 0x0000, 0x0000)
}
end
- def info_panel # :nodoc:
+ def info_panel
lazy_initialize(:info_panel) {
@info_panel = Gtk::HBox.new(false, 0)
@info_panel.border_width(10)
@@ -266,35 +266,35 @@ module Test
}
end
- def run_count_label # :nodoc:
+ def run_count_label
lazy_initialize(:run_count_label) {
@run_count_label = Gtk::Label.new("0")
@run_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
- def assertion_count_label # :nodoc:
+ def assertion_count_label
lazy_initialize(:assertion_count_label) {
@assertion_count_label = Gtk::Label.new("0")
@assertion_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
- def failure_count_label # :nodoc:
+ def failure_count_label
lazy_initialize(:failure_count_label) {
@failure_count_label = Gtk::Label.new("0")
@failure_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
- def error_count_label # :nodoc:
+ def error_count_label
lazy_initialize(:error_count_label) {
@error_count_label = Gtk::Label.new("0")
@error_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
- def list_panel # :nodoc:
+ def list_panel
lazy_initialize(:list_panel) {
@list_panel = Gtk::HBox.new
@list_panel.border_width(10)
@@ -302,7 +302,7 @@ module Test
}
end
- def list_scrolled_window # :nodoc:
+ def list_scrolled_window
lazy_initialize(:list_scrolled_window) {
@list_scrolled_window = Gtk::ScrolledWindow.new
@list_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
@@ -311,13 +311,13 @@ module Test
}
end
- def fault_list # :nodoc:
+ def fault_list
lazy_initialize(:fault_list) {
@fault_list = Gtk::List.new
}
end
- def detail_panel # :nodoc:
+ def detail_panel
lazy_initialize(:detail_panel) {
@detail_panel = Gtk::HBox.new
@detail_panel.border_width(10)
@@ -325,7 +325,7 @@ module Test
}
end
- def detail_scrolled_window # :nodoc:
+ def detail_scrolled_window
lazy_initialize(:detail_scrolled_window) {
@detail_scrolled_window = Gtk::ScrolledWindow.new
@detail_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
@@ -334,21 +334,21 @@ module Test
}
end
- def outer_detail_sub_panel # :nodoc:
+ def outer_detail_sub_panel
lazy_initialize(:outer_detail_sub_panel) {
@outer_detail_sub_panel = Gtk::VBox.new
@outer_detail_sub_panel.pack_start(inner_detail_sub_panel, false, false, 0)
}
end
- def inner_detail_sub_panel # :nodoc:
+ def inner_detail_sub_panel
lazy_initialize(:inner_detail_sub_panel) {
@inner_detail_sub_panel = Gtk::HBox.new
@inner_detail_sub_panel.pack_start(fault_detail_label, false, false, 0)
}
end
- def fault_detail_label # :nodoc:
+ def fault_detail_label
lazy_initialize(:fault_detail_label) {
@fault_detail_label = EnhancedLabel.new("")
style = Gtk::Style.new
@@ -362,7 +362,7 @@ module Test
}
end
- def status_panel # :nodoc:
+ def status_panel
lazy_initialize(:status_panel) {
@status_panel = Gtk::HBox.new
@status_panel.border_width(10)
@@ -370,14 +370,14 @@ module Test
}
end
- def status_entry # :nodoc:
+ def status_entry
lazy_initialize(:status_entry) {
@status_entry = Gtk::Entry.new
@status_entry.set_editable(false)
}
end
- def lazy_initialize(symbol) # :nodoc:
+ def lazy_initialize(symbol)
if (!instance_eval("defined?(@#{symbol.to_s})"))
yield
end
@@ -385,7 +385,7 @@ module Test
end
end
- class EnhancedProgressBar < Gtk::ProgressBar # :nodoc: all
+ class EnhancedProgressBar < Gtk::ProgressBar
def set_style(style)
super
hide
@@ -393,13 +393,13 @@ module Test
end
end
- class EnhancedLabel < Gtk::Label # :nodoc: all
+ class EnhancedLabel < Gtk::Label
def set_text(text)
super(text.gsub(/\n\t/, "\n" + (" " * 4)))
end
end
- class FaultListItem < Gtk::ListItem # :nodoc: all
+ class FaultListItem < Gtk::ListItem
attr_reader(:fault)
def initialize(fault)
super(fault.short_display)
diff --git a/lib/test/unit/ui/gtk2/testrunner.rb b/lib/test/unit/ui/gtk2/testrunner.rb
index 128424cf34..b05549c0e8 100644
--- a/lib/test/unit/ui/gtk2/testrunner.rb
+++ b/lib/test/unit/ui/gtk2/testrunner.rb
@@ -11,17 +11,17 @@ require "test/unit/ui/testrunnerutilities"
module Test
module Unit
module UI
- module GTK2 # :nodoc: all
+ module GTK2
Gtk.init
- class EnhancedLabel < Gtk::Label # :nodoc: all
+ class EnhancedLabel < Gtk::Label
def set_text(text)
super(text.gsub(/\n\t/, "\n "))
end
end
- class FaultList < Gtk::TreeView # :nodoc: all
+ class FaultList < Gtk::TreeView
def initialize
@faults = []
@model = Gtk::ListStore.new(String, String)
@@ -56,7 +56,7 @@ module Test
class TestRunner
extend TestRunnerUtilities
- def lazy_initialize(symbol) # :nodoc:
+ def lazy_initialize(symbol)
if !instance_eval("defined?(@#{symbol})") then
yield
end
@@ -64,7 +64,7 @@ module Test
end
private :lazy_initialize
- def status_entry # :nodoc:
+ def status_entry
lazy_initialize(:status_entry) do
@status_entry = Gtk::Entry.new
@status_entry.editable = false
@@ -72,7 +72,7 @@ module Test
end
private :status_entry
- def status_panel # :nodoc:
+ def status_panel
lazy_initialize(:status_panel) do
@status_panel = Gtk::HBox.new
@status_panel.border_width = 10
@@ -81,7 +81,7 @@ module Test
end
private :status_panel
- def fault_detail_label # :nodoc:
+ def fault_detail_label
lazy_initialize(:fault_detail_label) do
@fault_detail_label = EnhancedLabel.new("")
# style = Gtk::Style.new
@@ -95,7 +95,7 @@ module Test
end
private :fault_detail_label
- def inner_detail_sub_panel # :nodoc:
+ def inner_detail_sub_panel
lazy_initialize(:inner_detail_sub_panel) do
@inner_detail_sub_panel = Gtk::HBox.new
@inner_detail_sub_panel.pack_start(fault_detail_label, false, false, 0)
@@ -103,7 +103,7 @@ module Test
end
private :inner_detail_sub_panel
- def outer_detail_sub_panel # :nodoc:
+ def outer_detail_sub_panel
lazy_initialize(:outer_detail_sub_panel) do
@outer_detail_sub_panel = Gtk::VBox.new
@outer_detail_sub_panel.pack_start(inner_detail_sub_panel, false, false, 0)
@@ -111,7 +111,7 @@ module Test
end
private :outer_detail_sub_panel
- def detail_scrolled_window # :nodoc:
+ def detail_scrolled_window
lazy_initialize(:detail_scrolled_window) do
@detail_scrolled_window = Gtk::ScrolledWindow.new
@detail_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
@@ -122,7 +122,7 @@ module Test
end
private :detail_scrolled_window
- def detail_panel # :nodoc:
+ def detail_panel
lazy_initialize(:detail_panel) do
@detail_panel = Gtk::HBox.new
@detail_panel.border_width = 10
@@ -131,14 +131,14 @@ module Test
end
private :detail_panel
- def fault_list # :nodoc:
+ def fault_list
lazy_initialize(:fault_list) do
@fault_list = FaultList.new
end
end
private :fault_list
- def list_scrolled_window # :nodoc:
+ def list_scrolled_window
lazy_initialize(:list_scrolled_window) do
@list_scrolled_window = Gtk::ScrolledWindow.new
@list_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
@@ -149,7 +149,7 @@ module Test
end
private :list_scrolled_window
- def list_panel # :nodoc:
+ def list_panel
lazy_initialize(:list_panel) do
@list_panel = Gtk::HBox.new
@list_panel.border_width = 10
@@ -158,7 +158,7 @@ module Test
end
private :list_panel
- def error_count_label # :nodoc:
+ def error_count_label
lazy_initialize(:error_count_label) do
@error_count_label = Gtk::Label.new("0")
@error_count_label.justify = Gtk::JUSTIFY_LEFT
@@ -166,7 +166,7 @@ module Test
end
private :error_count_label
- def failure_count_label # :nodoc:
+ def failure_count_label
lazy_initialize(:failure_count_label) do
@failure_count_label = Gtk::Label.new("0")
@failure_count_label.justify = Gtk::JUSTIFY_LEFT
@@ -174,7 +174,7 @@ module Test
end
private :failure_count_label
- def assertion_count_label # :nodoc:
+ def assertion_count_label
lazy_initialize(:assertion_count_label) do
@assertion_count_label = Gtk::Label.new("0")
@assertion_count_label.justify = Gtk::JUSTIFY_LEFT
@@ -182,7 +182,7 @@ module Test
end
private :assertion_count_label
- def run_count_label # :nodoc:
+ def run_count_label
lazy_initialize(:run_count_label) do
@run_count_label = Gtk::Label.new("0")
@run_count_label.justify = Gtk::JUSTIFY_LEFT
@@ -190,7 +190,7 @@ module Test
end
private :run_count_label
- def info_panel # :nodoc:
+ def info_panel
lazy_initialize(:info_panel) do
@info_panel = Gtk::HBox.new(false, 0)
@info_panel.border_width = 10
@@ -206,7 +206,7 @@ module Test
end # def info_panel
private :info_panel
- def green_style # :nodoc:
+ def green_style
lazy_initialize(:green_style) do
@green_style = Gtk::Style.new
@green_style.set_bg(Gtk::STATE_PRELIGHT, 0x0000, 0xFFFF, 0x0000)
@@ -214,7 +214,7 @@ module Test
end # def green_style
private :green_style
- def red_style # :nodoc:
+ def red_style
lazy_initialize(:red_style) do
@red_style = Gtk::Style.new
@red_style.set_bg(Gtk::STATE_PRELIGHT, 0xFFFF, 0x0000, 0x0000)
@@ -222,7 +222,7 @@ module Test
end # def red_style
private :red_style
- def test_progress_bar # :nodoc:
+ def test_progress_bar
lazy_initialize(:test_progress_bar) {
@test_progress_bar = Gtk::ProgressBar.new
@test_progress_bar.fraction = 0.0
@@ -234,7 +234,7 @@ module Test
end # def test_progress_bar
private :test_progress_bar
- def progress_panel # :nodoc:
+ def progress_panel
lazy_initialize(:progress_panel) do
@progress_panel = Gtk::HBox.new(false, 10)
@progress_panel.border_width = 10
@@ -242,13 +242,13 @@ module Test
end
end # def progress_panel
- def run_button # :nodoc:
+ def run_button
lazy_initialize(:run_button) do
@run_button = Gtk::Button.new("Run")
end
end # def run_button
- def suite_name_entry # :nodoc:
+ def suite_name_entry
lazy_initialize(:suite_name_entry) do
@suite_name_entry = Gtk::Entry.new
@suite_name_entry.editable = false
@@ -256,7 +256,7 @@ module Test
end # def suite_name_entry
private :suite_name_entry
- def suite_panel # :nodoc:
+ def suite_panel
lazy_initialize(:suite_panel) do
@suite_panel = Gtk::HBox.new(false, 10)
@suite_panel.border_width = 10
@@ -267,7 +267,7 @@ module Test
end # def suite_panel
private :suite_panel
- def main_panel # :nodoc:
+ def main_panel
lazy_initialize(:main_panel) do
@main_panel = Gtk::VBox.new(false, 0)
@main_panel.pack_start(suite_panel, false, false, 0)
@@ -280,7 +280,7 @@ module Test
end # def main_panel
private :main_panel
- def main_window # :nodoc:
+ def main_window
lazy_initialize(:main_window) do
@main_window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
@main_window.set_title("Test::Unit TestRunner")
@@ -291,7 +291,7 @@ module Test
end # def main_window
private :main_window
- def setup_ui # :nodoc:
+ def setup_ui
main_window.signal_connect("destroy", nil) { stop }
main_window.show_all
fault_list.selection.signal_connect("changed", nil) do
@@ -305,33 +305,33 @@ module Test
end # def setup_ui
private :setup_ui
- def output_status(string) # :nodoc:
+ def output_status(string)
status_entry.set_text(string)
end # def output_status(string)
private :output_status
- def finished(elapsed_time) # :nodoc:
+ def finished(elapsed_time)
test_progress_bar.fraction = 1.0
output_status("Finished in #{elapsed_time} seconds")
end # def finished(elapsed_time)
private :finished
- def test_started(test_name) # :nodoc:
+ def test_started(test_name)
output_status("Running #{test_name}...")
end # def test_started(test_name)
private :test_started
- def started(result) # :nodoc:
+ def started(result)
@result = result
output_status("Started...")
end # def started(result)
private :started
- def test_finished(result) # :nodoc:
+ def test_finished(result)
test_progress_bar.fraction += 1.0 / @count
end # def test_finished(result)
- def result_changed(result) # :nodoc:
+ def result_changed(result)
run_count_label.label = result.run_count.to_s
assertion_count_label.label = result.assertion_count.to_s
failure_count_label.label = result.failure_count.to_s
@@ -339,23 +339,23 @@ module Test
end # def result_changed(result)
private :result_changed
- def clear_fault # :nodoc:
+ def clear_fault
raw_show_fault("")
end # def clear_fault
private :clear_fault
- def raw_show_fault(string) # :nodoc:
+ def raw_show_fault(string)
fault_detail_label.set_text(string)
outer_detail_sub_panel.queue_resize
end # def raw_show_fault(string)
private :raw_show_fault
- def show_fault(fault) # :nodoc:
+ def show_fault(fault)
raw_show_fault(fault.long_display)
end # def show_fault(fault)
private :show_fault
- def add_fault(fault) # :nodoc:
+ def add_fault(fault)
if not @red then
test_progress_bar.style = red_style
@red = true
@@ -364,7 +364,7 @@ module Test
end # def add_fault(fault)
private :add_fault
- def reset_ui(count) # :nodoc:
+ def reset_ui(count)
test_progress_bar.style = green_style
test_progress_bar.fraction = 0.0
@count = count + 1
@@ -379,7 +379,7 @@ module Test
end # def reset_ui(count)
private :reset_ui
- def stop # :nodoc:
+ def stop
Gtk.main_quit
end # def stop
private :stop
@@ -389,7 +389,7 @@ module Test
end
private :run_test
- def start_ui # :nodoc
+ def start_ui
@viewer.run
running = false
begin
diff --git a/lib/test/unit/ui/testrunnermediator.rb b/lib/test/unit/ui/testrunnermediator.rb
index 07bb462cc0..d34510d1c6 100644
--- a/lib/test/unit/ui/testrunnermediator.rb
+++ b/lib/test/unit/ui/testrunnermediator.rb
@@ -10,7 +10,7 @@ require 'test/unit/testresult'
module Test
module Unit
- module UI # :nodoc:
+ module UI
# Provides an interface to write any given UI against,
# hopefully making it easy to write new UIs.
diff --git a/lib/test/unit/ui/tk/testrunner.rb b/lib/test/unit/ui/tk/testrunner.rb
index 4521b8e258..4d05f2fb22 100644
--- a/lib/test/unit/ui/tk/testrunner.rb
+++ b/lib/test/unit/ui/tk/testrunner.rb
@@ -13,7 +13,7 @@ require 'test/unit/ui/testrunnerutilities'
module Test
module Unit
module UI
- module Tk # :nodoc:
+ module Tk
# Runs a Test::Unit::TestSuite in a Tk UI. Obviously,
# this one requires you to have Tk
@@ -52,7 +52,7 @@ module Test
end
private
- def setup_mediator # :nodoc:
+ def setup_mediator
@mediator = TestRunnerMediator.new(@suite)
suite_name = @suite.to_s
if ( @suite.kind_of?(Module) )
@@ -61,7 +61,7 @@ module Test
@suite_name_entry.value = suite_name
end
- def attach_to_mediator # :nodoc:
+ def attach_to_mediator
@run_button.command(method(:run_test))
@fault_list.bind('ButtonPress-1', proc{|y|
fault = @fault_detail_list[@fault_list.nearest(y)]
@@ -81,7 +81,7 @@ module Test
@runner.raise(@restart_signal)
end
- def start_ui # :nodoc:
+ def start_ui
@viewer.run
running = false
begin
@@ -101,11 +101,11 @@ module Test
end
end
- def stop # :nodoc:
+ def stop
::Tk.exit
end
- def reset_ui(count) # :nodoc:
+ def reset_ui(count)
@test_total_count = count.to_f
@test_progress_bar.configure('background'=>'green')
@test_progress_bar.place('relwidth'=>(count.zero? ? 0 : 0/count))
@@ -121,7 +121,7 @@ module Test
clear_fault
end
- def add_fault(fault) # :nodoc:
+ def add_fault(fault)
if ( ! @red )
@test_progress_bar.configure('background'=>'red')
@red = true
@@ -130,19 +130,19 @@ module Test
@fault_list.insert('end', fault.short_display)
end
- def show_fault(fault) # :nodoc:
+ def show_fault(fault)
raw_show_fault(fault.long_display)
end
- def raw_show_fault(string) # :nodoc:
+ def raw_show_fault(string)
@detail_text.value = string
end
- def clear_fault # :nodoc:
+ def clear_fault
raw_show_fault("")
end
- def result_changed(result) # :nodoc:
+ def result_changed(result)
@test_count_label.value = result.run_count
@test_progress_bar.place('relwidth'=>result.run_count/@test_total_count)
@assertion_count_label.value = result.assertion_count
@@ -150,7 +150,7 @@ module Test
@error_count_label.value = result.error_count
end
- def started(result) # :nodoc:
+ def started(result)
@result = result
output_status("Started...")
end
@@ -163,11 +163,11 @@ module Test
output_status("Finished in #{elapsed_time} seconds")
end
- def output_status(string) # :nodoc:
+ def output_status(string)
@status_entry.value = string
end
- def setup_ui # :nodoc:
+ def setup_ui
@status_entry = TkVariable.new
l = TkLabel.new(nil, 'textvariable'=>@status_entry, 'relief'=>'sunken')
l.pack('side'=>'bottom', 'fill'=>'x')
@@ -243,7 +243,7 @@ module Test
end
end
- def create_count_label(parent, label) # :nodoc:
+ def create_count_label(parent, label)
TkLabel.new(parent, 'text'=>label).pack('side'=>'left', 'expand'=>true)
v = TkVariable.new(0)
TkLabel.new(parent, 'textvariable'=>v).pack('side'=>'left', 'expand'=>true)
diff --git a/lib/test/unit/util/observable.rb b/lib/test/unit/util/observable.rb
index 924c10f24c..3567d34271 100644
--- a/lib/test/unit/util/observable.rb
+++ b/lib/test/unit/util/observable.rb
@@ -8,7 +8,7 @@ require 'test/unit/util/procwrapper'
module Test
module Unit
- module Util # :nodoc:
+ module Util
# This is a utility class that allows anything mixing
# it in to notify a set of listeners about interesting
@@ -80,7 +80,7 @@ module Test
end
private
- def channels # :nodoc:
+ def channels
@channels ||= {}
return @channels
end
diff --git a/lib/test/unit/util/procwrapper.rb b/lib/test/unit/util/procwrapper.rb
index 4d49a52a9d..ad7252186d 100644
--- a/lib/test/unit/util/procwrapper.rb
+++ b/lib/test/unit/util/procwrapper.rb
@@ -25,11 +25,11 @@ module Test
@hash = a_proc.inspect.sub(/^(#<#{a_proc.class}:)/){''}.sub(/(>)$/){''}.hex
end
- def hash # :nodoc:
+ def hash
return @hash
end
- def ==(other) # :nodoc:
+ def ==(other)
case(other)
when ProcWrapper
return @a_proc == other.to_proc
@@ -39,7 +39,7 @@ module Test
end
alias :eql? :==
- def to_proc # :nodoc:
+ def to_proc
return @a_proc
end
end
diff --git a/lib/thread.rb b/lib/thread.rb
index 7dd4b1115d..7df6a140f5 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -1,4 +1,8 @@
#
+# NOTE:
+# This file is overwritten by ext/thread/lib/thread.rb unless ruby
+# is configured with --disable-fastthread.
+#
# thread.rb - thread support classes
# $Date$
# by Yukihiro Matsumoto <matz@netlab.co.jp>
@@ -9,16 +13,144 @@
#
unless defined? Thread
- raise "Thread not available for this ruby interpreter"
+ fail "Thread not available for this ruby interpreter"
end
-unless defined? ThreadError
- class ThreadError < StandardError
+class Thread
+ #
+ # Wraps a block in Thread.critical, restoring the original value upon exit
+ # from the critical section.
+ #
+ def Thread.exclusive
+ _old = Thread.critical
+ begin
+ Thread.critical = true
+ return yield
+ ensure
+ Thread.critical = _old
+ end
end
end
-if $DEBUG
- Thread.abort_on_exception = true
+#
+# 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
+# }
+# }
+#
+class Mutex
+ #
+ # Creates a new Mutex
+ #
+ def initialize
+ @waiting = []
+ @locked = false;
+ @waiting.taint # enable tainted comunication
+ self.taint
+ end
+
+ #
+ # Returns +true+ if this lock is currently held by some thread.
+ #
+ def locked?
+ @locked
+ end
+
+ #
+ # Attempts to obtain the lock and returns immediately. Returns +true+ if the
+ # lock was granted.
+ #
+ def try_lock
+ result = false
+ Thread.critical = true
+ unless @locked
+ @locked = true
+ result = true
+ end
+ Thread.critical = false
+ result
+ end
+
+ #
+ # Attempts to grab the lock and waits if it isn't available.
+ #
+ def lock
+ while (Thread.critical = true; @locked)
+ @waiting.push Thread.current
+ Thread.stop
+ end
+ @locked = true
+ Thread.critical = false
+ self
+ end
+
+ #
+ # Releases the lock. Returns +nil+ if ref wasn't locked.
+ #
+ def unlock
+ return unless @locked
+ Thread.critical = true
+ @locked = false
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
+ Thread.critical = false
+ begin
+ t.run if t
+ rescue ThreadError
+ end
+ self
+ end
+
+ #
+ # Obtains a lock, runs the block, and releases the lock when the block
+ # completes. See the example under Mutex.
+ #
+ def synchronize
+ lock
+ begin
+ yield
+ ensure
+ unlock
+ end
+ end
+
+ #
+ # If the mutex is locked, unlocks the mutex, wakes one waiting thread, and
+ # yields in a critical section.
+ #
+ def exclusive_unlock
+ return unless @locked
+ Thread.exclusive do
+ @locked = false
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ end
+ yield
+ end
+ self
+ end
end
#
@@ -54,7 +186,6 @@ class ConditionVariable
#
def initialize
@waiters = []
- @waiters_mutex = Mutex.new
end
#
@@ -62,11 +193,12 @@ class ConditionVariable
#
def wait(mutex)
begin
- # TODO: mutex should not be used
- @waiters_mutex.synchronize do
+ mutex.exclusive_unlock do
@waiters.push(Thread.current)
+ Thread.stop
end
- mutex.sleep
+ ensure
+ mutex.lock
end
end
@@ -75,7 +207,7 @@ class ConditionVariable
#
def signal
begin
- t = @waiters_mutex.synchronize { @waiters.shift }
+ t = @waiters.shift
t.run if t
rescue ThreadError
retry
@@ -86,9 +218,8 @@ class ConditionVariable
# Wakes up all threads waiting for this lock.
#
def broadcast
- # TODO: imcomplete
waiters0 = nil
- @waiters_mutex.synchronize do
+ Thread.exclusive do
waiters0 = @waiters.dup
@waiters.clear
end
@@ -138,23 +269,22 @@ class Queue
@que.taint # enable tainted comunication
@waiting.taint
self.taint
- @mutex = Mutex.new
end
#
# Pushes +obj+ to the queue.
#
def push(obj)
- t = nil
- @mutex.synchronize{
- @que.push obj
- begin
- t = @waiting.shift
- t.wakeup if t
- rescue ThreadError
- retry
- end
- }
+ Thread.critical = true
+ @que.push obj
+ begin
+ t = @waiting.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ ensure
+ Thread.critical = false
+ end
begin
t.run if t
rescue ThreadError
@@ -177,17 +307,14 @@ class Queue
# thread isn't suspended, and an exception is raised.
#
def pop(non_block=false)
- while true
- @mutex.synchronize{
- if @que.empty?
- raise ThreadError, "queue empty" if non_block
- @waiting.push Thread.current
- @mutex.sleep
- else
- return @que.shift
- end
- }
+ while (Thread.critical = true; @que.empty?)
+ raise ThreadError, "queue empty" if non_block
+ @waiting.push Thread.current
+ Thread.stop
end
+ @que.shift
+ ensure
+ Thread.critical = false
end
#
@@ -201,7 +328,7 @@ class Queue
alias deq pop
#
- # Returns +true+ if the queue is empty.
+ # Returns +true+ is the queue is empty.
#
def empty?
@que.empty?
@@ -240,7 +367,7 @@ end
#
# See Queue for an example of how a SizedQueue works.
#
-class SizedQueue < Queue
+class SizedQueue<Queue
#
# Creates a fixed-length queue with a maximum size of +max+.
#
@@ -263,16 +390,14 @@ class SizedQueue < Queue
# Sets the maximum size of the queue.
#
def max=(max)
- diff = nil
- @mutex.synchronize {
- if max <= @max
- @max = max
- else
- diff = max - @max
- @max = max
- end
- }
- if diff
+ Thread.critical = true
+ if max <= @max
+ @max = max
+ Thread.critical = false
+ else
+ diff = max - @max
+ @max = max
+ Thread.critical = false
diff.times do
begin
t = @queue_wait.shift
@@ -290,27 +415,13 @@ class SizedQueue < Queue
# until space becomes available.
#
def push(obj)
- t = nil
- @mutex.synchronize{
- while true
- break if @que.length <= @max
- @queue_wait.push Thread.current
- @mutex.sleep
- end
-
- @que.push obj
- begin
- t = @waiting.shift
- t.wakeup if t
- rescue ThreadError
- retry
- end
- }
-
- begin
- t.run if t
- rescue ThreadError
+ Thread.critical = true
+ while @que.length >= @max
+ @queue_wait.push Thread.current
+ Thread.stop
+ Thread.critical = true
end
+ super
end
#
@@ -328,20 +439,20 @@ class SizedQueue < Queue
#
def pop(*args)
retval = super
- t = nil
- @mutex.synchronize {
- if @que.length < @max
- begin
- t = @queue_wait.shift
- t.wakeup if t
- rescue ThreadError
- retry
- end
+ Thread.critical = true
+ if @que.length < @max
+ begin
+ t = @queue_wait.shift
+ t.wakeup if t
+ rescue ThreadError
+ retry
+ ensure
+ Thread.critical = false
+ end
+ begin
+ t.run if t
+ rescue ThreadError
end
- }
- begin
- t.run if t
- rescue ThreadError
end
retval
end
diff --git a/lib/time.rb b/lib/time.rb
index 201f2fee39..a37a067390 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -40,7 +40,7 @@
# $Id$
#
-require 'date/format'
+require 'parsedate'
#
# Implements the extensions to the Time class that are described in the
@@ -66,7 +66,7 @@ class Time
'N' => -1, 'O' => -2, 'P' => -3, 'Q' => -4, 'R' => -5, 'S' => -6,
'T' => -7, 'U' => -8, 'V' => -9, 'W' => -10, 'X' => -11, 'Y' => -12,
}
- def zone_offset(zone, year=Time.now.year)
+ def zone_offset(zone, year=self.now.year)
off = nil
zone = zone.upcase
if /\A([+-])(\d\d):?(\d\d)\z/ =~ zone
@@ -75,9 +75,9 @@ class Time
off = zone.to_i * 3600
elsif ZoneOffset.include?(zone)
off = ZoneOffset[zone] * 3600
- elsif ((t = Time.local(year, 1, 1)).zone.upcase == zone rescue false)
+ elsif ((t = self.local(year, 1, 1)).zone.upcase == zone rescue false)
off = t.utc_offset
- elsif ((t = Time.local(year, 7, 1)).zone.upcase == zone rescue false)
+ elsif ((t = self.local(year, 7, 1)).zone.upcase == zone rescue false)
off = t.utc_offset
end
off
@@ -150,7 +150,7 @@ class Time
def make_time(year, mon, day, hour, min, sec, sec_fraction, zone, now)
usec = nil
- usec = sec_fraction * 1000000 if sec_fraction
+ usec = (sec_fraction * 1000000).to_i if sec_fraction
if now
begin
break if year; year = now.year
@@ -177,7 +177,7 @@ class Time
if off
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, off)
- t = Time.utc(year, mon, day, hour, min, sec, usec)
+ t = self.utc(year, mon, day, hour, min, sec, usec)
t.localtime if !zone_utc?(zone)
t
else
@@ -236,28 +236,13 @@ class Time
#
# A failure for Time.parse should be checked, though.
#
- def parse(date, now=Time.now)
+ def parse(date, now=self.now)
d = Date._parse(date, false)
year = d[:year]
year = yield(year) if year && block_given?
make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
- #
- # Parses +date+ using Date._strptime and converts it to a Time object.
- #
- # If a block is given, the year described in +date+ is converted by the
- # block. For example:
- #
- # Time.strptime(...) {|y| y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y}
- def strptime(date, format, now=Time.now)
- d = Date._strptime(date, format)
- raise ArgumentError, "invalid strptime format - `#{format}'" unless d
- year = d[:year]
- year = yield(year) if year && block_given?
- make_time(year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
- end
-
MonthValue = {
'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6,
'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' =>10, 'NOV' =>11, 'DEC' =>12
@@ -338,13 +323,7 @@ class Time
(\d\d):(\d\d):(\d\d)\x20
GMT
\s*\z/ix =~ date
- year = $3.to_i
- if year < 50
- year += 2000
- else
- year += 1900
- end
- Time.utc(year, $2, $1.to_i, $4.to_i, $5.to_i, $6.to_i)
+ self.parse(date)
elsif /\A\s*
(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\x20
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\x20
@@ -384,14 +363,14 @@ class Time
min = $5.to_i
sec = $6.to_i
usec = 0
- usec = $7.to_f * 1000000 if $7
+ usec = ($7[1..-1] + '000000')[0,6].to_i if $7
if $8
zone = $8
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, zone_offset(zone))
- Time.utc(year, mon, day, hour, min, sec, usec)
+ self.utc(year, mon, day, hour, min, sec, usec)
else
- Time.local(year, mon, day, hour, min, sec, usec)
+ self.local(year, mon, day, hour, min, sec, usec)
end
else
raise ArgumentError.new("invalid date: #{date.inspect}")
@@ -467,10 +446,10 @@ class Time
year, mon, day, hour, min, sec) +
if fraction_digits == 0
''
- elsif fraction_digits <= 9
- '.' + sprintf('%09d', nsec)[0, fraction_digits]
+ elsif fraction_digits <= 6
+ '.' + sprintf('%06d', usec)[0, fraction_digits]
else
- '.' + sprintf('%09d', nsec) + '0' * (fraction_digits - 9)
+ '.' + sprintf('%06d', usec) + '0' * (fraction_digits - 6)
end +
if utc?
'Z'
@@ -549,9 +528,6 @@ if __FILE__ == $0
Time.httpdate("Tue, 15 Nov 1994 12:45:26 GMT"))
assert_equal(Time.utc(1999, 12, 31, 23, 59, 59),
Time.httpdate("Fri, 31 Dec 1999 23:59:59 GMT"))
-
- assert_equal(Time.utc(2007, 12, 23, 11, 22, 33),
- Time.httpdate('Sunday, 23-Dec-07 11:22:33 GMT'))
end
def test_rfc3339
@@ -645,6 +621,8 @@ if __FILE__ == $0
t = Time.utc(1960, 12, 31, 23, 0, 0, 123456)
assert_equal("1960-12-31T23:00:00.123456Z", t.xmlschema(6))
end
+
+ assert_equal(249, Time.xmlschema("2008-06-05T23:49:23.000249+09:00").usec)
end
def test_completion
@@ -817,14 +795,5 @@ if __FILE__ == $0
def test_parse_fraction
assert_equal(500000, Time.parse("2000-01-01T00:00:00.5+00:00").tv_usec)
end
-
- def test_strptime
- assert_equal(Time.utc(2005, 8, 28, 06, 54, 20), Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z"))
- end
-
- def test_nsec
- assert_equal(123456789, Time.xmlschema("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
- assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
- end
end
end
diff --git a/lib/timeout.rb b/lib/timeout.rb
index d68312cf6d..5a99c28092 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -1,73 +1,103 @@
+#--
# = timeout.rb
#
# execution timeout
#
-# = Synopsis
+# = Copyright
#
-# require 'timeout'
-# status = Timeout::timeout(5) {
-# # Something that should be interrupted if it takes too much time...
-# }
+# Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc.
+# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
+#
+#++
#
# = Description
#
-# A way of performing a potentially long-running operation in a thread, and terminating
-# it's execution if it hasn't finished by a fixed amount of time.
+# A way of performing a potentially long-running operation in a thread, and
+# terminating it's execution if it hasn't finished within fixed amount of
+# time.
#
-# Previous versions of timeout didn't provide use a module for namespace. This version
+# Previous versions of timeout didn't use a module for namespace. This version
# provides both Timeout.timeout, and a backwards-compatible #timeout.
#
-# = Copyright
+# = Synopsis
+#
+# require 'timeout'
+# status = Timeout::timeout(5) {
+# # Something that should be interrupted if it takes too much time...
+# }
#
-# Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc.
-# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
module Timeout
+
+ ##
# Raised by Timeout#timeout when the block times out.
+
class Error < Interrupt
end
+ class ExitException < ::Exception # :nodoc:
+ end
+
+ THIS_FILE = /\A#{Regexp.quote(__FILE__)}:/o
+ CALLER_OFFSET = ((c = caller[0]) && THIS_FILE =~ c) ? 1 : 0
- # Executes the method's block. If the block execution terminates before
- # +sec+ seconds has passed, it returns the result value of the block.
- # If not, it terminates the execution and raises +exception+ (which defaults
- # to Timeout::Error).
+ ##
+ # Executes the method's block. If the block execution terminates before +sec+
+ # seconds has passed, it returns true. If not, it terminates the execution
+ # and raises +exception+ (which defaults to Timeout::Error).
#
- # Note that this is both a method of module Timeout, so you can 'include Timeout'
- # into your classes so they have a #timeout method, as well as a module method,
- # so you can call it directly as Timeout.timeout().
- def timeout(sec, exception = Error) #:yield: +sec+
- return yield(sec) if sec == nil or sec.zero?
+ # Note that this is both a method of module Timeout, so you can 'include
+ # Timeout' into your classes so they have a #timeout method, as well as a
+ # module method, so you can call it directly as Timeout.timeout().
+
+ def timeout(sec, klass = nil)
+ return yield if sec == nil or sec.zero?
+ raise ThreadError, "timeout within critical session" if Thread.critical
+ exception = klass || Class.new(ExitException)
begin
x = Thread.current
y = Thread.start {
sleep sec
x.raise exception, "execution expired" if x.alive?
}
- return yield(sec)
- ensure
- if y and y.alive?
- y.kill
- y.join # make sure y is dead.
+ yield sec
+ # return true
+ rescue exception => e
+ rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
+ (bt = e.backtrace).reject! {|m| rej =~ m}
+ level = -caller(CALLER_OFFSET).size
+ while THIS_FILE =~ bt[level]
+ bt.delete_at(level)
+ level += 1
end
+ raise if klass # if exception class is specified, it
+ # would be expected outside.
+ raise Error, e.message, e.backtrace
+ ensure
+ y.kill if y and y.alive?
end
end
module_function :timeout
+
end
+##
# Identical to:
#
# Timeout::timeout(n, e, &block).
#
# Defined for backwards compatibility with earlier versions of timeout.rb, see
# Timeout#timeout.
-def timeout(n, e = Timeout::Error, &block)
+
+def timeout(n, e = nil, &block) # :nodoc:
Timeout::timeout(n, e, &block)
end
+##
# Another name for Timeout::Error, defined for backwards compatibility with
# earlier versions of timeout.rb.
-TimeoutError = Timeout::Error
+
+TimeoutError = Timeout::Error # :nodoc:
if __FILE__ == $0
p timeout(5) {
@@ -89,3 +119,4 @@ if __FILE__ == $0
}
}
end
+
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 95ef08cfd6..2e82aa528e 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -12,16 +12,23 @@ class Dir
begin
require 'Win32API'
+ CSIDL_LOCAL_APPDATA = 0x001c
max_pathlen = 260
windir = ' '*(max_pathlen+1)
begin
- getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
+ getdir = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
+ raise RuntimeError if getdir.call(0, CSIDL_LOCAL_APPDATA, 0, 0, windir) != 0
+ windir = File.expand_path(windir.rstrip)
rescue RuntimeError
- getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
+ begin
+ getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
+ rescue RuntimeError
+ getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
+ end
+ len = getdir.call(windir, windir.size)
+ windir = File.expand_path(windir[0, len])
end
- len = getdir.call(windir, windir.size)
- windir = File.expand_path(windir[0, len])
- temp = File.join(windir, 'temp')
+ temp = File.join(windir.untaint, 'temp')
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
rescue LoadError
end
@@ -41,8 +48,8 @@ class Dir
break
end
end
+ File.expand_path(tmp)
end
- File.expand_path(tmp)
end
# Dir.mktmpdir creates a temporary directory.
diff --git a/lib/tracer.rb b/lib/tracer.rb
index 5b3983bb9f..71aa49c306 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -19,9 +19,9 @@ class Tracer
@stdout = STDOUT
@verbose = false
class << self
- attr_accessor :verbose
+ attr :verbose, true
alias verbose? verbose
- attr_accessor :stdout
+ attr :stdout, true
end
EVENT_SYMBOL = {
@@ -118,8 +118,8 @@ class Tracer
return unless p.call event, file, line, id, binding, klass
end
- # saved_crit = Thread.critical
- # Thread.critical = true
+ saved_crit = Thread.critical
+ Thread.critical = true
stdout.printf("#%d:%s:%d:%s:%s: %s",
get_thread_no,
file,
@@ -127,7 +127,7 @@ class Tracer
klass || '',
EVENT_SYMBOL[event],
get_line(file, line))
- # Thread.critical = saved_crit
+ Thread.critical = saved_crit
end
Single = new
diff --git a/lib/ubygems.rb b/lib/ubygems.rb
deleted file mode 100644
index fec880f73b..0000000000
--- a/lib/ubygems.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# This file allows for the running of rubygems with a nice
-# command line look-and-feel: ruby -rubygems foo.rb
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-
-require 'rubygems'
diff --git a/lib/uri/.document b/lib/uri/.document
deleted file mode 100644
index 214dd2e48f..0000000000
--- a/lib/uri/.document
+++ /dev/null
@@ -1,7 +0,0 @@
-common.rb
-ftp.rb
-generic.rb
-http.rb
-https.rb
-ldap.rb
-mailto.rb
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index cf7d147cc4..af6aaf26fb 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -186,30 +186,31 @@ module URI
# for URI::split
ABS_URI = Regexp.new('^' + PATTERN::X_ABS_URI + '$', #'
- Regexp::EXTENDED).freeze
+ Regexp::EXTENDED, 'N').freeze
REL_URI = Regexp.new('^' + PATTERN::X_REL_URI + '$', #'
- Regexp::EXTENDED).freeze
+ Regexp::EXTENDED, 'N').freeze
# for URI::extract
- URI_REF = Regexp.new(PATTERN::URI_REF).freeze
- ABS_URI_REF = Regexp.new(PATTERN::X_ABS_URI, Regexp::EXTENDED).freeze
- REL_URI_REF = Regexp.new(PATTERN::X_REL_URI, Regexp::EXTENDED).freeze
+ URI_REF = Regexp.new(PATTERN::URI_REF, false, 'N').freeze
+ ABS_URI_REF = Regexp.new(PATTERN::X_ABS_URI, Regexp::EXTENDED, 'N').freeze
+ REL_URI_REF = Regexp.new(PATTERN::X_REL_URI, Regexp::EXTENDED, 'N').freeze
# for URI::escape/unescape
- ESCAPED = Regexp.new(PATTERN::ESCAPED).freeze
- UNSAFE = Regexp.new("[^#{PATTERN::UNRESERVED}#{PATTERN::RESERVED}]").freeze
+ ESCAPED = Regexp.new(PATTERN::ESCAPED, false, 'N').freeze
+ UNSAFE = Regexp.new("[^#{PATTERN::UNRESERVED}#{PATTERN::RESERVED}]",
+ false, 'N').freeze
# for Generic#initialize
- SCHEME = Regexp.new("^#{PATTERN::SCHEME}$").freeze #"
- USERINFO = Regexp.new("^#{PATTERN::USERINFO}$").freeze #"
- HOST = Regexp.new("^#{PATTERN::HOST}$").freeze #"
- PORT = Regexp.new("^#{PATTERN::PORT}$").freeze #"
- OPAQUE = Regexp.new("^#{PATTERN::OPAQUE_PART}$").freeze #"
- REGISTRY = Regexp.new("^#{PATTERN::REG_NAME}$").freeze #"
- ABS_PATH = Regexp.new("^#{PATTERN::ABS_PATH}$").freeze #"
- REL_PATH = Regexp.new("^#{PATTERN::REL_PATH}$").freeze #"
- QUERY = Regexp.new("^#{PATTERN::QUERY}$").freeze #"
- FRAGMENT = Regexp.new("^#{PATTERN::FRAGMENT}$").freeze #"
+ SCHEME = Regexp.new("^#{PATTERN::SCHEME}$", false, 'N').freeze #"
+ USERINFO = Regexp.new("^#{PATTERN::USERINFO}$", false, 'N').freeze #"
+ HOST = Regexp.new("^#{PATTERN::HOST}$", false, 'N').freeze #"
+ PORT = Regexp.new("^#{PATTERN::PORT}$", false, 'N').freeze #"
+ OPAQUE = Regexp.new("^#{PATTERN::OPAQUE_PART}$", false, 'N').freeze #"
+ REGISTRY = Regexp.new("^#{PATTERN::REG_NAME}$", false, 'N').freeze #"
+ ABS_PATH = Regexp.new("^#{PATTERN::ABS_PATH}$", false, 'N').freeze #"
+ REL_PATH = Regexp.new("^#{PATTERN::REL_PATH}$", false, 'N').freeze #"
+ QUERY = Regexp.new("^#{PATTERN::QUERY}$", false, 'N').freeze #"
+ FRAGMENT = Regexp.new("^#{PATTERN::FRAGMENT}$", false, 'N').freeze #"
# :startdoc:
end # REGEXP
diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb
index 3afdce01b4..1a18e9cae7 100644
--- a/lib/uri/ftp.rb
+++ b/lib/uri/ftp.rb
@@ -177,7 +177,7 @@ module URI
# This method will then return "/pub/ruby"
#
def path
- return @path.sub(/^\//,'').sub(/^%2F/,'/')
+ return @path.sub(/^\//,'').sub(/^%2F/i,'/')
end
def to_s
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index bcf293ec0a..d907e0b4b2 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -1103,8 +1103,9 @@ module URI
end
end
+ @@to_s = Kernel.instance_method(:to_s)
def inspect
- sprintf("#<%s:%#0x URL:%s>", self.class.to_s, self.object_id, self.to_s)
+ @@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"}
end
def coerce(oth)
diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb
index 3a9d15318f..44f04f2dd5 100644
--- a/lib/uri/mailto.rb
+++ b/lib/uri/mailto.rb
@@ -55,7 +55,7 @@ module URI
(#{PATTERN::FRAGMENT}) (?# 3: fragment)
)?
\\z
- ", Regexp::EXTENDED).freeze
+ ", Regexp::EXTENDED, 'N').freeze
# :startdoc:
#
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 3b5bcd1b8e..591819c948 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -1,6 +1,13 @@
-# Weak Reference class that does not bother GCing.
+require "delegate"
+
+# WeakRef is a class to represent a reference to an object that is not seen by
+# the tracing phase of the garbage collector. This allows the referenced
+# object to be garbage collected as if nothing is referring to it. Because
+# WeakRef delegates method calls to the referenced object, it may be used in
+# place of that object, i.e. it is of the same duck type.
#
# Usage:
+#
# foo = Object.new
# foo = Object.new
# p foo.to_s # original's class
@@ -8,20 +15,18 @@
# p foo.to_s # should be same class
# ObjectSpace.garbage_collect
# p foo.to_s # should raise exception (recycled)
+class WeakRef<Delegator
-require "delegate"
-require 'thread'
-
-class WeakRef < Delegator
-
- class RefError < StandardError
+ # RefError is raised if an object cannot be referenced by a WeakRef.
+ class RefError<StandardError
end
@@id_map = {} # obj -> [ref,...]
@@id_rev_map = {} # ref -> obj
- @@mutex = Mutex.new
- @@final = lambda {|id|
- @@mutex.synchronize {
+ @@final = lambda{|id|
+ __old_status = Thread.critical
+ Thread.critical = true
+ begin
rids = @@id_map[id]
if rids
for rid in rids
@@ -35,46 +40,61 @@ class WeakRef < Delegator
@@id_map[rid].delete(id)
@@id_map.delete(rid) if @@id_map[rid].empty?
end
- }
+ ensure
+ Thread.critical = __old_status
+ end
}
+ # Create a new WeakRef from +orig+.
def initialize(orig)
- @__id = orig.object_id
- ObjectSpace.define_finalizer orig, @@final
- ObjectSpace.define_finalizer self, @@final
- @@mutex.synchronize {
- @@id_map[@__id] = [] unless @@id_map[@__id]
- }
- @@id_map[@__id].push self.object_id
- @@id_rev_map[self.object_id] = @__id
super
+ __setobj__(orig)
end
+ # Return the object this WeakRef references. Raises RefError if the object
+ # has been garbage collected. The object returned is the object to which
+ # method calls are delegated (see Delegator).
def __getobj__
- unless @@id_rev_map[self.object_id] == @__id
- Kernel::raise RefError, "Illegal Reference - probably recycled", Kernel::caller(2)
+ unless @@id_rev_map[self.__id__] == @__id
+ raise RefError, "Illegal Reference - probably recycled", caller(2)
end
begin
ObjectSpace._id2ref(@__id)
rescue RangeError
- Kernel::raise RefError, "Illegal Reference - probably recycled", Kernel::caller(2)
+ raise RefError, "Illegal Reference - probably recycled", caller(2)
end
end
+
def __setobj__(obj)
+ @__id = obj.__id__
+ __old_status = Thread.critical
+ begin
+ Thread.critical = true
+ unless @@id_rev_map.key?(self)
+ ObjectSpace.define_finalizer obj, @@final
+ ObjectSpace.define_finalizer self, @@final
+ end
+ @@id_map[@__id] = [] unless @@id_map[@__id]
+ ensure
+ Thread.critical = __old_status
+ end
+ @@id_map[@__id].push self.__id__
+ @@id_rev_map[self.__id__] = @__id
end
+ # Returns true if the referenced object still exists, and false if it has
+ # been garbage collected.
def weakref_alive?
- @@id_rev_map[self.object_id] == @__id
+ @@id_rev_map[self.__id__] == @__id
end
end
if __FILE__ == $0
-# require 'thread'
+ require 'thread'
foo = Object.new
p foo.to_s # original's class
foo = WeakRef.new(foo)
p foo.to_s # should be same class
ObjectSpace.garbage_collect
- ObjectSpace.garbage_collect
p foo.to_s # should raise exception (recycled)
end
diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb
index 8e43ac570e..ff5f7a6102 100644
--- a/lib/webrick/cgi.rb
+++ b/lib/webrick/cgi.rb
@@ -166,19 +166,20 @@ module WEBrick
end
def setup_header
- @env.each{|key, value|
- case key
- when "CONTENT_TYPE", "CONTENT_LENGTH"
- add_header(key.gsub(/_/, "-"), value)
- when /^HTTP_(.*)/
- add_header($1.gsub(/_/, "-"), value)
+ add_header("CONTENT_TYPE", "Content-Type")
+ add_header("CONTENT_LENGTH", "Content-length")
+ @env.each_key{|name|
+ if /^HTTP_(.*)/ =~ name
+ add_header(name, $1.gsub(/_/, "-"))
end
}
end
- def add_header(hdrname, value)
- unless value.empty?
- @header_part << hdrname << ": " << value << CRLF
+ def add_header(envname, hdrname)
+ if value = @env[envname]
+ unless value.empty?
+ @header_part << hdrname << ": " << value << CRLF
+ end
end
end
@@ -196,8 +197,8 @@ module WEBrick
[nil, @server_port, @server_name, @server_addr]
end
- def gets(eol=LF, size=nil)
- input.gets(eol, size)
+ def gets(eol=LF)
+ input.gets(eol)
end
def read(size=nil)
diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb
index 121669c13a..5897b977d8 100644
--- a/lib/webrick/config.rb
+++ b/lib/webrick/config.rb
@@ -33,8 +33,6 @@ module WEBrick
:StartCallback => nil,
:StopCallback => nil,
:AcceptCallback => nil,
- :DoNotReverseLookup => nil,
- :ShutdownSocketWithoutClose => false,
}
# for HTTPServer, HTTPRequest, HTTPResponse ...
@@ -47,10 +45,9 @@ module WEBrick
:DirectoryIndex => ["index.html","index.htm","index.cgi","index.rhtml"],
:DocumentRoot => nil,
:DocumentRootOptions => { :FancyIndexing => true },
- :RequestCallback => nil,
+ :RequestHandler => nil,
+ :RequestCallback => nil, # alias of :RequestHandler
:ServerAlias => nil,
- :InputBufferSize => 65536, # input buffer size in reading request body
- :OutputBufferSize => 65536, # output buffer size in sending File or IO
# for HTTPProxyServer
:ProxyAuthProc => nil,
diff --git a/lib/webrick/httpauth/authenticator.rb b/lib/webrick/httpauth/authenticator.rb
index f90d1bf75b..fe2dbf4e0c 100644
--- a/lib/webrick/httpauth/authenticator.rb
+++ b/lib/webrick/httpauth/authenticator.rb
@@ -42,7 +42,7 @@ module WEBrick
error("no credentials in the request.")
return nil
end
- unless match = /^#{@auth_scheme}\s+/i.match(credentials)
+ unless match = /^#{@auth_scheme}\s+/.match(credentials)
error("invalid scheme in %s.", credentials)
info("%s: %s", @request_field, credentials) if $DEBUG
return nil
diff --git a/lib/webrick/httpauth/basicauth.rb b/lib/webrick/httpauth/basicauth.rb
index 210fb00bbe..e835361dc2 100644
--- a/lib/webrick/httpauth/basicauth.rb
+++ b/lib/webrick/httpauth/basicauth.rb
@@ -34,7 +34,7 @@ module WEBrick
unless basic_credentials = check_scheme(req)
challenge(req, res)
end
- userid, password = basic_credentials.unpack("m*")[0].split(":", 2)
+ userid, password = basic_credentials.unpack("m*")[0].split(":", 2)
password ||= ""
if userid.empty?
error("user id was not given.")
diff --git a/lib/webrick/httpauth/digestauth.rb b/lib/webrick/httpauth/digestauth.rb
index 2bc3e97817..318e0bf17f 100644
--- a/lib/webrick/httpauth/digestauth.rb
+++ b/lib/webrick/httpauth/digestauth.rb
@@ -330,7 +330,6 @@ module WEBrick
def hexdigest(*args)
@h.hexdigest(args.join(":"))
end
-
end
class ProxyDigestAuth < DigestAuth
diff --git a/lib/webrick/httpauth/htpasswd.rb b/lib/webrick/httpauth/htpasswd.rb
index 8a058861d3..40f9297b05 100644
--- a/lib/webrick/httpauth/htpasswd.rb
+++ b/lib/webrick/httpauth/htpasswd.rb
@@ -35,7 +35,7 @@ module WEBrick
case line
when %r!\A[^:]+:[a-zA-Z0-9./]{13}\z!
user, pass = line.split(":")
- when /:\$/, /:{SHA}/
+ when /:\$/, /:\{SHA\}/
raise NotImplementedError,
'MD5, SHA1 .htpasswd file not supported'
else
diff --git a/lib/webrick/httpproxy.rb b/lib/webrick/httpproxy.rb
index 32603e763a..9295259085 100644
--- a/lib/webrick/httpproxy.rb
+++ b/lib/webrick/httpproxy.rb
@@ -24,8 +24,8 @@ module WEBrick
end
class HTTPProxyServer < HTTPServer
- def initialize(config={}, default=Config::HTTP)
- super(config, default)
+ def initialize(config)
+ super
c = @config
@via = "#{c[:HTTPVersion]} #{c[:ServerName]}:#{c[:Port]}"
end
@@ -47,7 +47,7 @@ module WEBrick
req.header.delete("proxy-authorization")
end
- # Some header fields shuold not be transfered.
+ # Some header fields should not be transferred.
HopByHop = %w( connection keep-alive proxy-authenticate upgrade
proxy-authorization te trailers transfer-encoding )
ShouldNotTransfer = %w( set-cookie proxy-connection )
@@ -118,7 +118,8 @@ module WEBrick
proxy_host = proxy.host
proxy_port = proxy.port
if proxy.userinfo
- credentials = "Basic " + [proxy.userinfo].pack("m").delete("\n")
+ credentials = "Basic " + [proxy.userinfo].pack("m*")
+ credentials.chomp!
header['proxy-authorization'] = credentials
end
end
@@ -178,7 +179,8 @@ module WEBrick
if proxy = proxy_uri(req, res)
proxy_request_line = "CONNECT #{host}:#{port} HTTP/1.0"
if proxy.userinfo
- credentials = "Basic " + [proxy.userinfo].pack("m").delete("\n")
+ credentials = "Basic " + [proxy.userinfo].pack("m*")
+ credentials.chomp!
end
host, port = proxy.host, proxy.port
end
diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb
index 430054bb29..1d32293a27 100644
--- a/lib/webrick/httprequest.rb
+++ b/lib/webrick/httprequest.rb
@@ -8,15 +8,19 @@
#
# $IPR: httprequest.rb,v 1.64 2003/07/13 17:18:22 gotoyuzo Exp $
+require 'timeout'
require 'uri'
+
require 'webrick/httpversion'
require 'webrick/httpstatus'
require 'webrick/httputils'
require 'webrick/cookie'
module WEBrick
+
class HTTPRequest
BODY_CONTAINABLE_METHODS = [ "POST", "PUT" ]
+ BUFSIZE = 1024*4
# Request line
attr_reader :request_line
@@ -40,7 +44,6 @@ module WEBrick
def initialize(config)
@config = config
- @buffer_size = @config[:InputBufferSize]
@logger = config[:Logger]
@request_line = @request_method =
@@ -219,10 +222,7 @@ module WEBrick
private
def read_request_line(socket)
- @request_line = read_line(socket, 1024) if socket
- if @request_line.size >= 1024 and @request_line[-1, 1] != LF
- raise HTTPStatus::RequestURITooLarge
- end
+ @request_line = read_line(socket) if socket
@request_time = Time.now
raise HTTPStatus::EOFError unless @request_line
if /^(\S+)\s+(\S+)(?:\s+HTTP\/(\d+\.\d+))?\r?\n/mo =~ @request_line
@@ -243,7 +243,7 @@ module WEBrick
end
end
begin
- @header = HTTPUtils::parse_header(@raw_header.join)
+ @header = HTTPUtils::parse_header(@raw_header)
rescue => ex
raise HTTPStatus::BadRequest, ex.message
end
@@ -279,7 +279,7 @@ module WEBrick
elsif self['content-length'] || @remaining_size
@remaining_size ||= self['content-length'].to_i
while @remaining_size > 0
- sz = [@buffer_size, @remaining_size].min
+ sz = BUFSIZE < @remaining_size ? BUFSIZE : @remaining_size
break unless buf = read_data(socket, sz)
@remaining_size -= buf.size
block.call(buf)
@@ -307,7 +307,12 @@ module WEBrick
def read_chunked(socket, block)
chunk_size, = read_chunk_size(socket)
while chunk_size > 0
- data = read_data(socket, chunk_size) # read chunk-data
+ data = ""
+ while data.size < chunk_size
+ tmp = read_data(socket, chunk_size-data.size) # read chunk-data
+ break unless tmp
+ data << tmp
+ end
if data.nil? || data.size != chunk_size
raise BadRequest, "bad chunk data size."
end
@@ -320,10 +325,10 @@ module WEBrick
@remaining_size = 0
end
- def _read_data(io, method, *arg)
+ def _read_data(io, method, arg)
begin
- WEBrick::Utils.timeout(@config[:RequestTimeout]){
- return io.__send__(method, *arg)
+ timeout(@config[:RequestTimeout]){
+ return io.__send__(method, arg)
}
rescue Errno::ECONNRESET
return nil
@@ -332,8 +337,8 @@ module WEBrick
end
end
- def read_line(io, size=4096)
- _read_data(io, :gets, LF, size)
+ def read_line(io)
+ _read_data(io, :gets, LF)
end
def read_data(io, size)
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index b3f1abef88..62156b1abd 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -16,6 +16,8 @@ require 'webrick/httpstatus'
module WEBrick
class HTTPResponse
+ BUFSIZE = 1024*4
+
attr_reader :http_version, :status, :header
attr_reader :cookies
attr_accessor :reason_phrase
@@ -28,7 +30,6 @@ module WEBrick
def initialize(config)
@config = config
- @buffer_size = config[:OutputBufferSize]
@logger = config[:Logger]
@header = Hash.new
@status = HTTPStatus::RC_OK
@@ -131,7 +132,7 @@ module WEBrick
end
end
- # Determin the message length (RFC2616 -- 4.4 Message Length)
+ # Determine the message length (RFC2616 -- 4.4 Message Length)
if @status == 304 || @status == 204 || HTTPStatus::info?(@status)
@header.delete('content-length')
@body = ""
@@ -257,7 +258,7 @@ module WEBrick
if @request_method == "HEAD"
# do nothing
elsif chunked?
- while buf = @body.read(@buffer_size)
+ while buf = @body.read(BUFSIZE)
next if buf.empty?
data = ""
data << format("%x", buf.size) << CRLF
@@ -281,7 +282,7 @@ module WEBrick
# do nothing
elsif chunked?
remain = body ? @body.size : 0
- while buf = @body[@sent_size, @buffer_size]
+ while buf = @body[@sent_size, BUFSIZE]
break if buf.empty?
data = ""
data << format("%x", buf.size) << CRLF
@@ -300,18 +301,18 @@ module WEBrick
def _send_file(output, input, offset, size)
while offset > 0
- sz = @buffer_size < size ? @buffer_size : size
+ sz = BUFSIZE < offset ? BUFSIZE : offset
buf = input.read(sz)
offset -= buf.size
end
if size == 0
- while buf = input.read(@buffer_size)
+ while buf = input.read(BUFSIZE)
_write_data(output, buf)
end
else
while size > 0
- sz = @buffer_size < size ? @buffer_size : size
+ sz = BUFSIZE < size ? BUFSIZE : size
buf = input.read(sz)
_write_data(output, buf)
size -= buf.size
diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb
index 495be263b3..9edb0018f8 100644
--- a/lib/webrick/httpserver.rb
+++ b/lib/webrick/httpserver.rb
@@ -21,7 +21,7 @@ module WEBrick
class HTTPServer < ::WEBrick::GenericServer
def initialize(config={}, default=Config::HTTP)
- super(config, default)
+ super
@http_version = HTTPVersion::convert(@config[:HTTPVersion])
@mount_tab = MountTable.new
@@ -52,19 +52,14 @@ module WEBrick
timeout = 0 if @status != :Running
timeout -= 0.5
end
- raise HTTPStatus::EOFError if timeout <= 0
- raise HTTPStatus::EOFError if sock.eof?
+ raise HTTPStatus::EOFError if timeout <= 0 || sock.eof?
req.parse(sock)
res.request_method = req.request_method
res.request_uri = req.request_uri
res.request_http_version = req.http_version
res.keep_alive = req.keep_alive?
server = lookup_server(req) || self
- if callback = server[:RequestCallback]
- callback.call(req, res)
- elsif callback = server[:RequestHandler]
- msg = ":RequestHandler is deprecated, please use :RequestCallback"
- @logger.warn(msg)
+ if callback = server[:RequestCallback] || server[:RequestHandler]
callback.call(req, res)
end
server.service(req, res)
@@ -80,9 +75,7 @@ module WEBrick
res.set_error(ex, true)
ensure
if req.request_line
- if req.keep_alive? && res.keep_alive?
- req.fixup()
- end
+ req.fixup()
res.send_response(sock)
server.access_log(@config, req, res)
end
diff --git a/lib/webrick/httpservlet/abstract.rb b/lib/webrick/httpservlet/abstract.rb
index 03861e8fc7..5375c4622d 100644
--- a/lib/webrick/httpservlet/abstract.rb
+++ b/lib/webrick/httpservlet/abstract.rb
@@ -58,7 +58,7 @@ module WEBrick
def redirect_to_directory_uri(req, res)
if req.path[-1] != ?/
- location = req.path + "/"
+ location = WEBrick::HTTPUtils.escape_path(req.path + "/")
if req.query_string && req.query_string.size > 0
location << "?" << req.query_string
end
diff --git a/lib/webrick/httpservlet/cgi_runner.rb b/lib/webrick/httpservlet/cgi_runner.rb
index 1069a68d58..006abd458e 100644
--- a/lib/webrick/httpservlet/cgi_runner.rb
+++ b/lib/webrick/httpservlet/cgi_runner.rb
@@ -39,7 +39,9 @@ dir = File::dirname(ENV["SCRIPT_FILENAME"])
Dir::chdir dir
if interpreter = ARGV[0]
- exec(interpreter, ENV["SCRIPT_FILENAME"])
+ argv = ARGV.dup
+ argv << ENV["SCRIPT_FILENAME"]
+ exec(*argv)
# NOTREACHED
end
exec ENV["SCRIPT_FILENAME"]
diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb
index c6583c5a33..d5895e5285 100644
--- a/lib/webrick/httpservlet/cgihandler.rb
+++ b/lib/webrick/httpservlet/cgihandler.rb
@@ -17,13 +17,13 @@ module WEBrick
module HTTPServlet
class CGIHandler < AbstractServlet
- Ruby = File::join(RbConfig::CONFIG['bindir'],
- RbConfig::CONFIG['ruby_install_name'])
- Ruby << RbConfig::CONFIG['EXEEXT']
- CGIRunner = "\"#{Ruby}\" \"#{WEBrick::Config::LIBDIR}/httpservlet/cgi_runner.rb\""
+ Ruby = File::join(::Config::CONFIG['bindir'],
+ ::Config::CONFIG['ruby_install_name'])
+ Ruby << ::Config::CONFIG['EXEEXT']
+ CGIRunner = "\"#{Ruby}\" \"#{Config::LIBDIR}/httpservlet/cgi_runner.rb\""
def initialize(server, name)
- super(server, name)
+ super
@script_filename = name
@tempdir = server[:TempDir]
@cgicmd = "#{CGIRunner} #{server[:CGIInterpreter]}"
@@ -75,7 +75,7 @@ module WEBrick
end
data = "" unless data
- raw_header, body = data.split(/^[\xd\xa]+/, 2)
+ raw_header, body = data.split(/^[\xd\xa]+/on, 2)
raise HTTPStatus::InternalServerError,
"Premature end of script headers: #{@script_filename}" if body.nil?
@@ -85,6 +85,10 @@ module WEBrick
res.status = $1.to_i
header.delete('status')
end
+ if header.has_key?('location')
+ # RFC 3875 6.2.3, 6.2.4
+ res.status = 302 unless (300...400) === res.status
+ end
if header.has_key?('set-cookie')
header['set-cookie'].each{|k|
res.cookies << Cookie.parse_set_cookie(k)
diff --git a/lib/webrick/httpservlet/erbhandler.rb b/lib/webrick/httpservlet/erbhandler.rb
index 49792193ba..b9d5e65b65 100644
--- a/lib/webrick/httpservlet/erbhandler.rb
+++ b/lib/webrick/httpservlet/erbhandler.rb
@@ -17,7 +17,7 @@ module WEBrick
class ERBHandler < AbstractServlet
def initialize(server, name)
- super(server, name)
+ super
@script_filename = name
end
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index ae30c436fe..24f59d7142 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -20,7 +20,7 @@ module WEBrick
class DefaultFileHandler < AbstractServlet
def initialize(server, local_path)
- super(server, local_path)
+ super
@local_path = local_path
end
@@ -163,6 +163,7 @@ module WEBrick
end
end
end
+ prevent_directory_traversal(req, res)
super(req, res)
end
@@ -198,10 +199,38 @@ module WEBrick
private
+ def trailing_pathsep?(path)
+ # check for trailing path separator:
+ # File.dirname("/aaaa/bbbb/") #=> "/aaaa")
+ # File.dirname("/aaaa/bbbb/x") #=> "/aaaa/bbbb")
+ # File.dirname("/aaaa/bbbb") #=> "/aaaa")
+ # File.dirname("/aaaa/bbbbx") #=> "/aaaa")
+ return File.dirname(path) != File.dirname(path+"x")
+ end
+
+ def prevent_directory_traversal(req, res)
+ # Preventing directory traversal on Windows platforms;
+ # Backslashes (0x5c) in path_info are not interpreted as special
+ # character in URI notation. So the value of path_info should be
+ # normalize before accessing to the filesystem.
+
+ if trailing_pathsep?(req.path_info)
+ # File.expand_path removes the trailing path separator.
+ # Adding a character is a workaround to save it.
+ # File.expand_path("/aaa/") #=> "/aaa"
+ # File.expand_path("/aaa/" + "x") #=> "/aaa/x"
+ expanded = File.expand_path(req.path_info + "x")
+ expanded.chop! # remove trailing "x"
+ else
+ expanded = File.expand_path(req.path_info)
+ end
+ req.path_info = expanded
+ end
+
def exec_handler(req, res)
raise HTTPStatus::NotFound, "`#{req.path}' not found" unless @root
if set_filename(req, res)
- handler = get_handler(req)
+ handler = get_handler(req, res)
call_callback(:HandlerCallback, req, res)
h = handler.get_instance(@config, res.filename)
h.service(req, res)
@@ -211,9 +240,13 @@ module WEBrick
return false
end
- def get_handler(req)
- suffix1 = (/\.(\w+)$/ =~ req.script_name) && $1.downcase
- suffix2 = (/\.(\w+)\.[\w\-]+$/ =~ req.script_name) && $1.downcase
+ def get_handler(req, res)
+ suffix1 = (/\.(\w+)\z/ =~ res.filename) && $1.downcase
+ if /\.(\w+)\.([\w\-]+)\z/ =~ res.filename
+ if @options[:AcceptableLanguages].include?($2.downcase)
+ suffix2 = $1.downcase
+ end
+ end
handler_table = @options[:HandlerTable]
return handler_table[suffix1] || handler_table[suffix2] ||
HandlerTable[suffix1] || HandlerTable[suffix2] ||
@@ -226,15 +259,13 @@ module WEBrick
path_info.unshift("") # dummy for checking @root dir
while base = path_info.first
- check_filename(req, res, base)
break if base == "/"
- break unless File.directory?(res.filename + base)
+ break unless File.directory?(File.expand_path(res.filename + base))
shift_path_info(req, res, path_info)
call_callback(:DirectoryCallback, req, res)
end
if base = path_info.first
- check_filename(req, res, base)
if base == "/"
if file = search_index_file(req, res)
shift_path_info(req, res, path_info, file)
@@ -255,12 +286,10 @@ module WEBrick
end
def check_filename(req, res, name)
- @options[:NondisclosureName].each{|pattern|
- if File.fnmatch("/#{pattern}", name)
- @logger.warn("the request refers nondisclosure name `#{name}'.")
- raise HTTPStatus::NotFound, "`#{req.path}' not found."
- end
- }
+ if nondisclosure_name?(name) || windows_ambiguous_name?(name)
+ @logger.warn("the request refers nondisclosure name `#{name}'.")
+ raise HTTPStatus::NotFound, "`#{req.path}' not found."
+ end
end
def shift_path_info(req, res, path_info, base=nil)
@@ -268,7 +297,8 @@ module WEBrick
base = base || tmp
req.path_info = path_info.join
req.script_name << base
- res.filename << base
+ res.filename = File.expand_path(res.filename + base)
+ check_filename(req, res, File.basename(res.filename))
end
def search_index_file(req, res)
@@ -308,9 +338,15 @@ module WEBrick
end
end
+ def windows_ambiguous_name?(name)
+ return true if /[. ]+\z/ =~ name
+ return true if /::\$DATA\z/ =~ name
+ return false
+ end
+
def nondisclosure_name?(name)
@options[:NondisclosureName].each{|pattern|
- if File.fnmatch(pattern, name)
+ if File.fnmatch(pattern, name, File::FNM_CASEFOLD)
return true
end
}
@@ -326,7 +362,8 @@ module WEBrick
list = Dir::entries(local_path).collect{|name|
next if name == "." || name == ".."
next if nondisclosure_name?(name)
- st = (File::stat(local_path + name) rescue nil)
+ next if windows_ambiguous_name?(name)
+ st = (File::stat(File.join(local_path, name)) rescue nil)
if st.nil?
[ name, nil, -1 ]
elsif st.directory?
@@ -366,7 +403,7 @@ module WEBrick
res.body << "<A HREF=\"?S=#{d1}\">Size</A>\n"
res.body << "<HR>\n"
- list.unshift [ "..", File::mtime(local_path+".."), -1 ]
+ list.unshift [ "..", File::mtime(local_path+"/.."), -1 ]
list.each{ |name, time, size|
if name == ".."
dname = "Parent Directory"
diff --git a/lib/webrick/httpstatus.rb b/lib/webrick/httpstatus.rb
index a4b42f5a90..0b22c992b3 100644
--- a/lib/webrick/httpstatus.rb
+++ b/lib/webrick/httpstatus.rb
@@ -23,46 +23,46 @@ module WEBrick
class EOFError < StandardError; end
StatusMessage = {
- 100 => 'Continue',
- 101 => 'Switching Protocols',
- 200 => 'OK',
- 201 => 'Created',
- 202 => 'Accepted',
- 203 => 'Non-Authoritative Information',
- 204 => 'No Content',
- 205 => 'Reset Content',
- 206 => 'Partial Content',
- 300 => 'Multiple Choices',
- 301 => 'Moved Permanently',
- 302 => 'Found',
- 303 => 'See Other',
- 304 => 'Not Modified',
- 305 => 'Use Proxy',
- 307 => 'Temporary Redirect',
- 400 => 'Bad Request',
- 401 => 'Unauthorized',
- 402 => 'Payment Required',
- 403 => 'Forbidden',
- 404 => 'Not Found',
- 405 => 'Method Not Allowed',
- 406 => 'Not Acceptable',
- 407 => 'Proxy Authentication Required',
- 408 => 'Request Timeout',
- 409 => 'Conflict',
- 410 => 'Gone',
- 411 => 'Length Required',
- 412 => 'Precondition Failed',
- 413 => 'Request Entity Too Large',
- 414 => 'Request-URI Too Large',
- 415 => 'Unsupported Media Type',
- 416 => 'Request Range Not Satisfiable',
- 417 => 'Expectation Failed',
- 500 => 'Internal Server Error',
- 501 => 'Not Implemented',
- 502 => 'Bad Gateway',
- 503 => 'Service Unavailable',
- 504 => 'Gateway Timeout',
- 505 => 'HTTP Version Not Supported'
+ 100, 'Continue',
+ 101, 'Switching Protocols',
+ 200, 'OK',
+ 201, 'Created',
+ 202, 'Accepted',
+ 203, 'Non-Authoritative Information',
+ 204, 'No Content',
+ 205, 'Reset Content',
+ 206, 'Partial Content',
+ 300, 'Multiple Choices',
+ 301, 'Moved Permanently',
+ 302, 'Found',
+ 303, 'See Other',
+ 304, 'Not Modified',
+ 305, 'Use Proxy',
+ 307, 'Temporary Redirect',
+ 400, 'Bad Request',
+ 401, 'Unauthorized',
+ 402, 'Payment Required',
+ 403, 'Forbidden',
+ 404, 'Not Found',
+ 405, 'Method Not Allowed',
+ 406, 'Not Acceptable',
+ 407, 'Proxy Authentication Required',
+ 408, 'Request Timeout',
+ 409, 'Conflict',
+ 410, 'Gone',
+ 411, 'Length Required',
+ 412, 'Precondition Failed',
+ 413, 'Request Entity Too Large',
+ 414, 'Request-URI Too Large',
+ 415, 'Unsupported Media Type',
+ 416, 'Request Range Not Satisfiable',
+ 417, 'Expectation Failed',
+ 500, 'Internal Server Error',
+ 501, 'Not Implemented',
+ 502, 'Bad Gateway',
+ 503, 'Service Unavailable',
+ 504, 'Gateway Timeout',
+ 505, 'HTTP Version Not Supported'
}
CodeToError = {}
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index b9bd5ae91d..976d3e915e 100644
--- a/lib/webrick/httputils.rb
+++ b/lib/webrick/httputils.rb
@@ -23,16 +23,8 @@ module WEBrick
ret = path.dup
ret.gsub!(%r{/+}o, '/') # // => /
- while ret.sub!(%r{/\.(/|\Z)}o, '/'); end # /. => /
- begin # /foo/.. => /foo
- match = ret.sub!(%r{/([^/]+)/\.\.(/|\Z)}o){
- if $1 == ".."
- raise "abnormal path `#{path}'"
- else
- "/"
- end
- }
- end while match
+ while ret.sub!(%r'/\.(?:/|\Z)', '/'); end # /. => /
+ while ret.sub!(%r'/(?!\.\./)[^/]+/\.\.(?:/|\Z)', '/'); end # /foo/.. => /foo
raise "abnormal path `#{path}'" if %r{/\.\.(/|\Z)} =~ ret
ret
@@ -90,7 +82,6 @@ module WEBrick
"tiff" => "image/tiff",
"txt" => "text/plain",
"xbm" => "image/x-xbitmap",
- "xhtml" => "text/html",
"xls" => "application/vnd.ms-excel",
"xml" => "text/xml",
"xpm" => "image/x-xpixmap",
@@ -127,7 +118,7 @@ module WEBrick
def parse_header(raw)
header = Hash.new([].freeze)
field = nil
- raw.each_line{|line|
+ raw.each{|line|
case line
when /^([A-Za-z0-9!\#$%&'*+\-.^_`|~]+):\s*(.*?)\s*\z/om
field, value = $1, $2
@@ -155,8 +146,8 @@ module WEBrick
module_function :parse_header
def split_header_value(str)
- str.scan(/((?:"(?:\\.|[^"])+?"|[^",]+)+)
- (?:,\s*|\Z)/xn).collect{|v| v[0] }
+ str.scan(%r'\G((?:"(?:\\.|[^"])+?"|[^",]+)+)
+ (?:,\s*|\Z)'xn).flatten
end
module_function :split_header_value
@@ -244,7 +235,7 @@ module WEBrick
if @header
super
elsif str == CRLF
- @header = HTTPUtils::parse_header(@raw_header.join)
+ @header = HTTPUtils::parse_header(@raw_header)
if cd = self['content-disposition']
if /\s+name="(.*?)"/ =~ cd then @name = $1 end
if /\s+filename="(.*?)"/ =~ cd then @filename = $1 end
@@ -295,7 +286,7 @@ module WEBrick
query = Hash.new
if str
str.split(/[&;]/).each{|x|
- next if x.empty?
+ next if x.empty?
key, val = x.split(/=/,2)
key = unescape_form(key)
val = unescape_form(val.to_s)
@@ -317,7 +308,7 @@ module WEBrick
form_data = Hash.new
return form_data unless io
data = nil
- io.each_line{|line|
+ io.each{|line|
if boundary_regexp =~ line
if data
data.chop!
@@ -358,7 +349,7 @@ module WEBrick
def _make_regex(str) /([#{Regexp.escape(str)}])/n end
def _make_regex!(str) /([^#{Regexp.escape(str)}])/n end
- def _escape(str, regex) str.gsub(regex){ "%%%02X" % $1.ord } end
+ def _escape(str, regex) str.gsub(regex){ "%%%02X" % $1[0] } end
def _unescape(str, regex) str.gsub(regex){ $1.hex.chr } end
UNESCAPED = _make_regex(control+space+delims+unwise+nonascii)
diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb
index 54375d2e7d..16dbd46f98 100644
--- a/lib/webrick/server.rb
+++ b/lib/webrick/server.rb
@@ -10,6 +10,7 @@
require 'thread'
require 'socket'
+require 'timeout'
require 'webrick/config'
require 'webrick/log'
@@ -129,10 +130,7 @@ module WEBrick
addr = s.addr
@logger.debug("close TCPSocket(#{addr[2]}, #{addr[1]})")
end
- s.shutdown
- unless @config[:ShutdownSocketWithoutClose]
- s.close
- end
+ s.close
}
@listeners.clear
end
@@ -148,10 +146,11 @@ module WEBrick
begin
sock = svr.accept
sock.sync = true
- Utils::set_non_blocking(sock)
+ Utils::set_non_blocking(sock)
Utils::set_close_on_exec(sock)
- rescue Errno::ECONNRESET, Errno::ECONNABORTED,
- Errno::EPROTO, Errno::EINVAL => ex
+ rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO => ex
+ # TCP connection was established but RST segment was sent
+ # from peer before calling TCPServer#accept.
rescue Exception => ex
msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
@logger.error msg
diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb
index 654abb28b1..cf9da6f2ce 100644
--- a/lib/webrick/utils.rb
+++ b/lib/webrick/utils.rb
@@ -96,80 +96,5 @@ module WEBrick
end
module_function :random_string
- ###########
-
- require "thread"
- require "timeout"
- require "singleton"
-
- class TimeoutHandler
- include Singleton
- TimeoutMutex = Mutex.new
-
- def TimeoutHandler.register(seconds, exception)
- TimeoutMutex.synchronize{
- instance.register(Thread.current, Time.now + seconds, exception)
- }
- end
-
- def TimeoutHandler.cancel(id)
- TimeoutMutex.synchronize{
- instance.cancel(Thread.current, id)
- }
- end
-
- def initialize
- @timeout_info = Hash.new
- Thread.start{
- while true
- now = Time.now
- @timeout_info.each{|thread, ary|
- ary.dup.each{|info|
- time, exception = *info
- interrupt(thread, info.object_id, exception) if time < now
- }
- }
- sleep 0.5
- end
- }
- end
-
- def interrupt(thread, id, exception)
- TimeoutMutex.synchronize{
- if cancel(thread, id) && thread.alive?
- thread.raise(exception, "execution timeout")
- end
- }
- end
-
- def register(thread, time, exception)
- @timeout_info[thread] ||= Array.new
- @timeout_info[thread] << [time, exception]
- return @timeout_info[thread].last.object_id
- end
-
- def cancel(thread, id)
- if ary = @timeout_info[thread]
- ary.delete_if{|info| info.object_id == id }
- if ary.empty?
- @timeout_info.delete(thread)
- end
- return true
- end
- return false
- end
- end
-
- def timeout(seconds, exception=Timeout::Error)
- return yield if seconds.nil? or seconds.zero?
- # raise ThreadError, "timeout within critical session" if Thread.critical
- id = TimeoutHandler.register(seconds, exception)
- begin
- yield(seconds)
- ensure
- TimeoutHandler.cancel(id)
- end
- end
- module_function :timeout
end
end
diff --git a/lib/wsdl/binding.rb b/lib/wsdl/binding.rb
new file mode 100644
index 0000000000..58a21d820d
--- /dev/null
+++ b/lib/wsdl/binding.rb
@@ -0,0 +1,65 @@
+# WSDL4R - WSDL binding definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+
+
+class Binding < Info
+ attr_reader :name # required
+ attr_reader :type # required
+ attr_reader :operations
+ attr_reader :soapbinding
+
+ def initialize
+ super
+ @name = nil
+ @type = nil
+ @operations = XSD::NamedElements.new
+ @soapbinding = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when OperationName
+ o = OperationBinding.new
+ @operations << o
+ o
+ when SOAPBindingName
+ o = WSDL::SOAP::Binding.new
+ @soapbinding = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when TypeAttrName
+ @type = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/data.rb b/lib/wsdl/data.rb
new file mode 100644
index 0000000000..45eaad8526
--- /dev/null
+++ b/lib/wsdl/data.rb
@@ -0,0 +1,64 @@
+# WSDL4R - WSDL data definitions.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'wsdl/documentation'
+require 'wsdl/definitions'
+require 'wsdl/types'
+require 'wsdl/message'
+require 'wsdl/part'
+require 'wsdl/portType'
+require 'wsdl/operation'
+require 'wsdl/param'
+require 'wsdl/binding'
+require 'wsdl/operationBinding'
+require 'wsdl/service'
+require 'wsdl/port'
+require 'wsdl/import'
+
+
+module WSDL
+
+
+ArrayTypeAttrName = XSD::QName.new(Namespace, 'arrayType')
+BindingName = XSD::QName.new(Namespace, 'binding')
+DefinitionsName = XSD::QName.new(Namespace, 'definitions')
+DocumentationName = XSD::QName.new(Namespace, 'documentation')
+FaultName = XSD::QName.new(Namespace, 'fault')
+ImportName = XSD::QName.new(Namespace, 'import')
+InputName = XSD::QName.new(Namespace, 'input')
+MessageName = XSD::QName.new(Namespace, 'message')
+OperationName = XSD::QName.new(Namespace, 'operation')
+OutputName = XSD::QName.new(Namespace, 'output')
+PartName = XSD::QName.new(Namespace, 'part')
+PortName = XSD::QName.new(Namespace, 'port')
+PortTypeName = XSD::QName.new(Namespace, 'portType')
+ServiceName = XSD::QName.new(Namespace, 'service')
+TypesName = XSD::QName.new(Namespace, 'types')
+
+SchemaName = XSD::QName.new(XSD::Namespace, 'schema')
+
+SOAPAddressName = XSD::QName.new(SOAPBindingNamespace, 'address')
+SOAPBindingName = XSD::QName.new(SOAPBindingNamespace, 'binding')
+SOAPHeaderName = XSD::QName.new(SOAPBindingNamespace, 'header')
+SOAPBodyName = XSD::QName.new(SOAPBindingNamespace, 'body')
+SOAPFaultName = XSD::QName.new(SOAPBindingNamespace, 'fault')
+SOAPOperationName = XSD::QName.new(SOAPBindingNamespace, 'operation')
+
+BindingAttrName = XSD::QName.new(nil, 'binding')
+ElementAttrName = XSD::QName.new(nil, 'element')
+LocationAttrName = XSD::QName.new(nil, 'location')
+MessageAttrName = XSD::QName.new(nil, 'message')
+NameAttrName = XSD::QName.new(nil, 'name')
+NamespaceAttrName = XSD::QName.new(nil, 'namespace')
+ParameterOrderAttrName = XSD::QName.new(nil, 'parameterOrder')
+TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
+TypeAttrName = XSD::QName.new(nil, 'type')
+
+
+end
diff --git a/lib/wsdl/definitions.rb b/lib/wsdl/definitions.rb
new file mode 100644
index 0000000000..5235037cfe
--- /dev/null
+++ b/lib/wsdl/definitions.rb
@@ -0,0 +1,250 @@
+# WSDL4R - WSDL definitions.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+
+
+class Definitions < Info
+ attr_reader :name
+ attr_reader :targetnamespace
+ attr_reader :imports
+
+ attr_accessor :location
+ attr_reader :importedschema
+
+ def initialize
+ super
+ @name = nil
+ @targetnamespace = nil
+ @location = nil
+ @importedschema = {}
+
+ @types = nil
+ @imports = []
+ @messages = XSD::NamedElements.new
+ @porttypes = XSD::NamedElements.new
+ @bindings = XSD::NamedElements.new
+ @services = XSD::NamedElements.new
+
+ @anontypes = XSD::NamedElements.new
+ @root = self
+ end
+
+ def inspect
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__, @name || '(unnamed)')
+ end
+
+ def targetnamespace=(targetnamespace)
+ @targetnamespace = targetnamespace
+ if @name
+ @name = XSD::QName.new(@targetnamespace, @name.name)
+ end
+ end
+
+ def collect_attributes
+ result = XSD::NamedElements.new
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_attributes)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_attributes)
+ end
+ result
+ end
+
+ def collect_elements
+ result = XSD::NamedElements.new
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_elements)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_elements)
+ end
+ result
+ end
+
+ def collect_complextypes
+ result = @anontypes.dup
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_complextypes)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_complextypes)
+ end
+ result
+ end
+
+ def collect_simpletypes
+ result = XSD::NamedElements.new
+ if @types
+ @types.schemas.each do |schema|
+ result.concat(schema.collect_simpletypes)
+ end
+ end
+ @imports.each do |import|
+ result.concat(import.content.collect_simpletypes)
+ end
+ result
+ end
+
+ # ToDo: simpletype must be accepted...
+ def add_type(complextype)
+ @anontypes << complextype
+ end
+
+ def messages
+ result = @messages.dup
+ @imports.each do |import|
+ result.concat(import.content.messages) if self.class === import.content
+ end
+ result
+ end
+
+ def porttypes
+ result = @porttypes.dup
+ @imports.each do |import|
+ result.concat(import.content.porttypes) if self.class === import.content
+ end
+ result
+ end
+
+ def bindings
+ result = @bindings.dup
+ @imports.each do |import|
+ result.concat(import.content.bindings) if self.class === import.content
+ end
+ result
+ end
+
+ def services
+ result = @services.dup
+ @imports.each do |import|
+ result.concat(import.content.services) if self.class === import.content
+ end
+ result
+ end
+
+ def message(name)
+ message = @messages[name]
+ return message if message
+ @imports.each do |import|
+ message = import.content.message(name) if self.class === import.content
+ return message if message
+ end
+ nil
+ end
+
+ def porttype(name)
+ porttype = @porttypes[name]
+ return porttype if porttype
+ @imports.each do |import|
+ porttype = import.content.porttype(name) if self.class === import.content
+ return porttype if porttype
+ end
+ nil
+ end
+
+ def binding(name)
+ binding = @bindings[name]
+ return binding if binding
+ @imports.each do |import|
+ binding = import.content.binding(name) if self.class === import.content
+ return binding if binding
+ end
+ nil
+ end
+
+ def service(name)
+ service = @services[name]
+ return service if service
+ @imports.each do |import|
+ service = import.content.service(name) if self.class === import.content
+ return service if service
+ end
+ nil
+ end
+
+ def porttype_binding(name)
+ binding = @bindings.find { |item| item.type == name }
+ return binding if binding
+ @imports.each do |import|
+ binding = import.content.porttype_binding(name) if self.class === import.content
+ return binding if binding
+ end
+ nil
+ end
+
+ def parse_element(element)
+ case element
+ when ImportName
+ o = Import.new
+ @imports << o
+ o
+ when TypesName
+ o = Types.new
+ @types = o
+ o
+ when MessageName
+ o = Message.new
+ @messages << o
+ o
+ when PortTypeName
+ o = PortType.new
+ @porttypes << o
+ o
+ when BindingName
+ o = Binding.new
+ @bindings << o
+ o
+ when ServiceName
+ o = Service.new
+ @services << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when TargetNamespaceAttrName
+ self.targetnamespace = value.source
+ else
+ nil
+ end
+ end
+
+ def self.parse_element(element)
+ if element == DefinitionsName
+ Definitions.new
+ else
+ nil
+ end
+ end
+
+private
+
+end
+
+
+end
diff --git a/lib/wsdl/documentation.rb b/lib/wsdl/documentation.rb
new file mode 100644
index 0000000000..3a7fd7d23e
--- /dev/null
+++ b/lib/wsdl/documentation.rb
@@ -0,0 +1,32 @@
+# WSDL4R - WSDL SOAP documentation element.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Documentation < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ # Accepts any element.
+ self
+ end
+
+ def parse_attr(attr, value)
+ # Accepts any attribute.
+ true
+ end
+end
+
+
+end
diff --git a/lib/wsdl/import.rb b/lib/wsdl/import.rb
new file mode 100644
index 0000000000..faf60871a5
--- /dev/null
+++ b/lib/wsdl/import.rb
@@ -0,0 +1,80 @@
+# WSDL4R - WSDL import definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/importer'
+
+
+module WSDL
+
+
+class Import < Info
+ attr_reader :namespace
+ attr_reader :location
+ attr_reader :content
+
+ def initialize
+ super
+ @namespace = nil
+ @location = nil
+ @content = nil
+ @web_client = nil
+ end
+
+ def parse_element(element)
+ case element
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NamespaceAttrName
+ @namespace = value.source
+ if @content
+ @content.targetnamespace = @namespace
+ end
+ @namespace
+ when LocationAttrName
+ @location = URI.parse(value.source)
+ if @location.relative? and !parent.location.nil? and
+ !parent.location.relative?
+ @location = parent.location + @location
+ end
+ if root.importedschema.key?(@location)
+ @content = root.importedschema[@location]
+ else
+ root.importedschema[@location] = nil # placeholder
+ @content = import(@location)
+ if @content.is_a?(Definitions)
+ @content.root = root
+ if @namespace
+ @content.targetnamespace = @namespace
+ end
+ end
+ root.importedschema[@location] = @content
+ end
+ @location
+ else
+ nil
+ end
+ end
+
+private
+
+ def import(location)
+ Importer.import(location, root)
+ end
+end
+
+
+end
diff --git a/lib/wsdl/importer.rb b/lib/wsdl/importer.rb
new file mode 100644
index 0000000000..481bd81b25
--- /dev/null
+++ b/lib/wsdl/importer.rb
@@ -0,0 +1,38 @@
+# WSDL4R - WSDL importer library.
+# Copyright (C) 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/xmlSchema/importer'
+require 'wsdl/parser'
+
+
+module WSDL
+
+
+class Importer < WSDL::XMLSchema::Importer
+ def self.import(location, originalroot = nil)
+ new.import(location, originalroot)
+ end
+
+private
+
+ def parse(content, location, originalroot)
+ opt = {
+ :location => location,
+ :originalroot => originalroot
+ }
+ begin
+ WSDL::Parser.new(opt).parse(content)
+ rescue WSDL::Parser::ParseError
+ super(content, location, originalroot)
+ end
+ end
+
+end
+
+
+end
diff --git a/lib/wsdl/info.rb b/lib/wsdl/info.rb
new file mode 100644
index 0000000000..ffd90390a4
--- /dev/null
+++ b/lib/wsdl/info.rb
@@ -0,0 +1,39 @@
+# WSDL4R - WSDL information base.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module WSDL
+
+
+class Info
+ attr_accessor :root
+ attr_accessor :parent
+ attr_accessor :id
+
+ def initialize
+ @root = nil
+ @parent = nil
+ @id = nil
+ end
+
+ def inspect
+ if self.respond_to?(:name)
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.name)
+ else
+ sprintf("#<%s:0x%x>", self.class.name, __id__)
+ end
+ end
+
+ def parse_element(element); end # abstract
+
+ def parse_attr(attr, value); end # abstract
+
+ def parse_epilogue; end # abstract
+end
+
+
+end
diff --git a/lib/wsdl/message.rb b/lib/wsdl/message.rb
new file mode 100644
index 0000000000..cecc602da3
--- /dev/null
+++ b/lib/wsdl/message.rb
@@ -0,0 +1,54 @@
+# WSDL4R - WSDL message definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Message < Info
+ attr_reader :name # required
+ attr_reader :parts
+
+ def initialize
+ super
+ @name = nil
+ @parts = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when PartName
+ o = Part.new
+ @parts << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(parent.targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/operation.rb b/lib/wsdl/operation.rb
new file mode 100644
index 0000000000..fb7f4a80f4
--- /dev/null
+++ b/lib/wsdl/operation.rb
@@ -0,0 +1,130 @@
+# WSDL4R - WSDL operation definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Operation < Info
+ class NameInfo
+ attr_reader :op_name
+ attr_reader :optype_name
+ attr_reader :parts
+ def initialize(op_name, optype_name, parts)
+ @op_name = op_name
+ @optype_name = optype_name
+ @parts = parts
+ end
+ end
+
+ attr_reader :name # required
+ attr_reader :parameter_order # optional
+ attr_reader :input
+ attr_reader :output
+ attr_reader :fault
+ attr_reader :type # required
+
+ def initialize
+ super
+ @name = nil
+ @type = nil
+ @parameter_order = nil
+ @input = nil
+ @output = nil
+ @fault = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def input_info
+ typename = input.find_message.name
+ NameInfo.new(@name, typename, inputparts)
+ end
+
+ def output_info
+ typename = output.find_message.name
+ NameInfo.new(@name, typename, outputparts)
+ end
+
+ def inputparts
+ sort_parts(input.find_message.parts)
+ end
+
+ def inputname
+ XSD::QName.new(targetnamespace, input.name ? input.name.name : @name.name)
+ end
+
+ def outputparts
+ sort_parts(output.find_message.parts)
+ end
+
+ def outputname
+ XSD::QName.new(targetnamespace,
+ output.name ? output.name.name : @name.name + 'Response')
+ end
+
+ def parse_element(element)
+ case element
+ when InputName
+ o = Param.new
+ @input = o
+ o
+ when OutputName
+ o = Param.new
+ @output = o
+ o
+ when FaultName
+ o = Param.new
+ @fault << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when TypeAttrName
+ @type = value
+ when ParameterOrderAttrName
+ @parameter_order = value.source.split(/\s+/)
+ else
+ nil
+ end
+ end
+
+private
+
+ def sort_parts(parts)
+ return parts.dup unless parameter_order
+ result = []
+ parameter_order.each do |orderitem|
+ if (ele = parts.find { |part| part.name == orderitem })
+ result << ele
+ end
+ end
+ if result.length == 0
+ return parts.dup
+ end
+ # result length can be shorter than parts's.
+ # return part must not be a part of the parameterOrder.
+ result
+ end
+end
+
+
+end
diff --git a/lib/wsdl/operationBinding.rb b/lib/wsdl/operationBinding.rb
new file mode 100644
index 0000000000..c2b8cd6591
--- /dev/null
+++ b/lib/wsdl/operationBinding.rb
@@ -0,0 +1,108 @@
+# WSDL4R - WSDL bound operation definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class OperationBinding < Info
+ attr_reader :name # required
+ attr_reader :input
+ attr_reader :output
+ attr_reader :fault
+ attr_reader :soapoperation
+
+ def initialize
+ super
+ @name = nil
+ @input = nil
+ @output = nil
+ @fault = []
+ @soapoperation = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def porttype
+ root.porttype(parent.type)
+ end
+
+ def find_operation
+ porttype.operations[@name] or raise RuntimeError.new("#{@name} not found")
+ end
+
+ def soapoperation_name
+ if @soapoperation
+ @soapoperation.input_info.op_name
+ else
+ find_operation.name
+ end
+ end
+
+ def soapoperation_style
+ style = nil
+ if @soapoperation
+ style = @soapoperation.operation_style
+ elsif parent.soapbinding
+ style = parent.soapbinding.style
+ else
+ raise TypeError.new("operation style definition not found")
+ end
+ style || :document
+ end
+
+ def soapaction
+ if @soapoperation
+ @soapoperation.soapaction
+ else
+ nil
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when InputName
+ o = Param.new
+ @input = o
+ o
+ when OutputName
+ o = Param.new
+ @output = o
+ o
+ when FaultName
+ o = Param.new
+ @fault << o
+ o
+ when SOAPOperationName
+ o = WSDL::SOAP::Operation.new
+ @soapoperation = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/param.rb b/lib/wsdl/param.rb
new file mode 100644
index 0000000000..b6836b7def
--- /dev/null
+++ b/lib/wsdl/param.rb
@@ -0,0 +1,85 @@
+# WSDL4R - WSDL param definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Param < Info
+ attr_reader :message # required
+ attr_reader :name # optional but required for fault.
+ attr_reader :soapbody
+ attr_reader :soapheader
+ attr_reader :soapfault
+
+ def initialize
+ super
+ @message = nil
+ @name = nil
+ @soapbody = nil
+ @soapheader = []
+ @soapfault = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def find_message
+ root.message(@message) or raise RuntimeError.new("#{@message} not found")
+ end
+
+ def soapbody_use
+ if @soapbody
+ @soapbody.use || :literal
+ else
+ raise RuntimeError.new("soap:body not found")
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when SOAPBodyName
+ o = WSDL::SOAP::Body.new
+ @soapbody = o
+ o
+ when SOAPHeaderName
+ o = WSDL::SOAP::Header.new
+ @soapheader << o
+ o
+ when SOAPFaultName
+ o = WSDL::SOAP::Fault.new
+ @soap_fault = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MessageAttrName
+ if value.namespace.nil?
+ value = XSD::QName.new(targetnamespace, value.source)
+ end
+ @message = value
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/parser.rb b/lib/wsdl/parser.rb
new file mode 100644
index 0000000000..f96e96ee2a
--- /dev/null
+++ b/lib/wsdl/parser.rb
@@ -0,0 +1,163 @@
+# WSDL4R - WSDL XML Instance parser library.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'xsd/ns'
+require 'xsd/charset'
+require 'xsd/datatypes'
+require 'xsd/xmlparser'
+require 'wsdl/wsdl'
+require 'wsdl/data'
+require 'wsdl/xmlSchema/data'
+require 'wsdl/soap/data'
+
+
+module WSDL
+
+
+class Parser
+ include WSDL
+
+ class ParseError < Error; end
+ class FormatDecodeError < ParseError; end
+ class UnknownElementError < FormatDecodeError; end
+ class UnknownAttributeError < FormatDecodeError; end
+ class UnexpectedElementError < FormatDecodeError; end
+ class ElementConstraintError < FormatDecodeError; end
+ class AttributeConstraintError < FormatDecodeError; end
+
+private
+
+ class ParseFrame
+ attr_reader :ns
+ attr_reader :name
+ attr_accessor :node
+
+ private
+
+ def initialize(ns, name, node)
+ @ns = ns
+ @name = name
+ @node = node
+ end
+ end
+
+public
+
+ def initialize(opt = {})
+ @parser = XSD::XMLParser.create_parser(self, opt)
+ @parsestack = nil
+ @lastnode = nil
+ @ignored = {}
+ @location = opt[:location]
+ @originalroot = opt[:originalroot]
+ end
+
+ def parse(string_or_readable)
+ @parsestack = []
+ @lastnode = nil
+ @textbuf = ''
+ @parser.do_parse(string_or_readable)
+ @lastnode
+ end
+
+ def charset
+ @parser.charset
+ end
+
+ def start_element(name, attrs)
+ lastframe = @parsestack.last
+ ns = parent = nil
+ if lastframe
+ ns = lastframe.ns.clone_ns
+ parent = lastframe.node
+ else
+ ns = XSD::NS.new
+ parent = nil
+ end
+ attrs = XSD::XMLParser.filter_ns(ns, attrs)
+ node = decode_tag(ns, name, attrs, parent)
+ @parsestack << ParseFrame.new(ns, name, node)
+ end
+
+ def characters(text)
+ lastframe = @parsestack.last
+ if lastframe
+ # Need not to be cloned because character does not have attr.
+ ns = lastframe.ns
+ decode_text(ns, text)
+ else
+ p text if $DEBUG
+ end
+ end
+
+ def end_element(name)
+ lastframe = @parsestack.pop
+ unless name == lastframe.name
+ raise UnexpectedElementError.new("closing element name '#{name}' does not match with opening element '#{lastframe.name}'")
+ end
+ decode_tag_end(lastframe.ns, lastframe.node)
+ @lastnode = lastframe.node
+ end
+
+private
+
+ def decode_tag(ns, name, attrs, parent)
+ o = nil
+ elename = ns.parse(name)
+ if !parent
+ if elename == DefinitionsName
+ o = Definitions.parse_element(elename)
+ o.location = @location
+ else
+ raise UnknownElementError.new("unknown element: #{elename}")
+ end
+ o.root = @originalroot if @originalroot # o.root = o otherwise
+ else
+ if elename == XMLSchema::AnnotationName
+ # only the first annotation element is allowed for each xsd element.
+ o = XMLSchema::Annotation.new
+ else
+ o = parent.parse_element(elename)
+ end
+ unless o
+ unless @ignored.key?(elename)
+ warn("ignored element: #{elename}")
+ @ignored[elename] = elename
+ end
+ o = Documentation.new # which accepts any element.
+ end
+ # node could be a pseudo element. pseudo element has its own parent.
+ o.root = parent.root
+ o.parent = parent if o.parent.nil?
+ end
+ attrs.each do |key, value|
+ attr_ele = ns.parse(key, true)
+ value_ele = ns.parse(value, true)
+ value_ele.source = value # for recovery; value may not be a QName
+ unless o.parse_attr(attr_ele, value_ele)
+ unless @ignored.key?(attr_ele)
+ warn("ignored attr: #{attr_ele}")
+ @ignored[attr_ele] = attr_ele
+ end
+ end
+ end
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ node.parse_epilogue
+ end
+
+ def decode_text(ns, text)
+ @textbuf << text
+ end
+end
+
+
+end
diff --git a/lib/wsdl/part.rb b/lib/wsdl/part.rb
new file mode 100644
index 0000000000..5dafd4ee73
--- /dev/null
+++ b/lib/wsdl/part.rb
@@ -0,0 +1,52 @@
+# WSDL4R - WSDL part definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Part < Info
+ attr_reader :name # required
+ attr_reader :element # optional
+ attr_reader :type # optional
+
+ def initialize
+ super
+ @name = nil
+ @element = nil
+ @type = nil
+ end
+
+ def parse_element(element)
+ case element
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = value.source
+ when ElementAttrName
+ @element = value
+ when TypeAttrName
+ @type = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/port.rb b/lib/wsdl/port.rb
new file mode 100644
index 0000000000..883cc3232d
--- /dev/null
+++ b/lib/wsdl/port.rb
@@ -0,0 +1,84 @@
+# WSDL4R - WSDL port definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Port < Info
+ attr_reader :name # required
+ attr_reader :binding # required
+ attr_reader :soap_address
+
+ def initialize
+ super
+ @name = nil
+ @binding = nil
+ @soap_address = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def porttype
+ root.porttype(find_binding.type)
+ end
+
+ def find_binding
+ root.binding(@binding) or raise RuntimeError.new("#{@binding} not found")
+ end
+
+ def inputoperation_map
+ result = {}
+ find_binding.operations.each do |op_bind|
+ op_info = op_bind.soapoperation.input_info
+ result[op_info.op_name] = op_info
+ end
+ result
+ end
+
+ def outputoperation_map
+ result = {}
+ find_binding.operations.each do |op_bind|
+ op_info = op_bind.soapoperation.output_info
+ result[op_info.op_name] = op_info
+ end
+ result
+ end
+
+ def parse_element(element)
+ case element
+ when SOAPAddressName
+ o = WSDL::SOAP::Address.new
+ @soap_address = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when BindingAttrName
+ @binding = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/portType.rb b/lib/wsdl/portType.rb
new file mode 100644
index 0000000000..03e37690a8
--- /dev/null
+++ b/lib/wsdl/portType.rb
@@ -0,0 +1,73 @@
+# WSDL4R - WSDL portType definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+
+
+class PortType < Info
+ attr_reader :name # required
+ attr_reader :operations
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def initialize
+ super
+ @name = nil
+ @operations = XSD::NamedElements.new
+ end
+
+ def find_binding
+ root.bindings.find { |item| item.type == @name } or
+ raise RuntimeError.new("#{@name} not found")
+ end
+
+ def locations
+ bind_name = find_binding.name
+ result = []
+ root.services.each do |service|
+ service.ports.each do |port|
+ if port.binding == bind_name
+ result << port.soap_address.location if port.soap_address
+ end
+ end
+ end
+ result
+ end
+
+ def parse_element(element)
+ case element
+ when OperationName
+ o = Operation.new
+ @operations << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/service.rb b/lib/wsdl/service.rb
new file mode 100644
index 0000000000..652b127331
--- /dev/null
+++ b/lib/wsdl/service.rb
@@ -0,0 +1,61 @@
+# WSDL4R - WSDL service definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+
+
+class Service < Info
+ attr_reader :name # required
+ attr_reader :ports
+ attr_reader :soap_address
+
+ def initialize
+ super
+ @name = nil
+ @ports = XSD::NamedElements.new
+ @soap_address = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when PortName
+ o = Port.new
+ @ports << o
+ o
+ when SOAPAddressName
+ o = WSDL::SOAP::Address.new
+ @soap_address = o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
diff --git a/lib/wsdl/soap/address.rb b/lib/wsdl/soap/address.rb
new file mode 100644
index 0000000000..0b2b59caf0
--- /dev/null
+++ b/lib/wsdl/soap/address.rb
@@ -0,0 +1,40 @@
+# WSDL4R - WSDL SOAP address definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class Address < Info
+ attr_reader :location
+
+ def initialize
+ super
+ @location = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when LocationAttrName
+ @location = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/binding.rb b/lib/wsdl/soap/binding.rb
new file mode 100644
index 0000000000..7e15a99701
--- /dev/null
+++ b/lib/wsdl/soap/binding.rb
@@ -0,0 +1,49 @@
+# WSDL4R - WSDL SOAP binding definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class Binding < Info
+ attr_reader :style
+ attr_reader :transport
+
+ def initialize
+ super
+ @style = nil
+ @transport = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when StyleAttrName
+ if ["document", "rpc"].include?(value.source)
+ @style = value.source.intern
+ else
+ raise Parser::AttributeConstraintError.new(
+ "Unexpected value #{ value }.")
+ end
+ when TransportAttrName
+ @transport = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/body.rb b/lib/wsdl/soap/body.rb
new file mode 100644
index 0000000000..824f8121a2
--- /dev/null
+++ b/lib/wsdl/soap/body.rb
@@ -0,0 +1,56 @@
+# WSDL4R - WSDL SOAP body definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class Body < Info
+ attr_reader :parts
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @parts = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when PartsAttrName
+ @parts = value.source
+ when UseAttrName
+ if ['literal', 'encoded'].include?(value.source)
+ @use = value.source.intern
+ else
+ raise RuntimeError.new("unknown use of soap:body: #{value.source}")
+ end
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/cgiStubCreator.rb b/lib/wsdl/soap/cgiStubCreator.rb
new file mode 100644
index 0000000000..2c4dff2f62
--- /dev/null
+++ b/lib/wsdl/soap/cgiStubCreator.rb
@@ -0,0 +1,76 @@
+# WSDL4R - Creating CGI stub code from WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/mappingRegistryCreator'
+require 'wsdl/soap/methodDefCreator'
+require 'wsdl/soap/classDefCreatorSupport'
+
+
+module WSDL
+module SOAP
+
+
+class CGIStubCreator
+ include ClassDefCreatorSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ end
+
+ def dump(service_name)
+ warn("CGI stub can have only 1 port. Creating stub for the first port... Rests are ignored.")
+ port = @definitions.service(service_name).ports[0]
+ dump_porttype(port.porttype.name)
+ end
+
+private
+
+ def dump_porttype(name)
+ class_name = create_class_name(name)
+ methoddef, types = MethodDefCreator.new(@definitions).dump(name)
+ mr_creator = MappingRegistryCreator.new(@definitions)
+ c1 = XSD::CodeGen::ClassDef.new(class_name)
+ c1.def_require("soap/rpc/cgistub")
+ c1.def_require("soap/mapping/registry")
+ c1.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
+ c1.def_code(mr_creator.dump(types))
+ c1.def_code <<-EOD
+Methods = [
+#{methoddef.gsub(/^/, " ")}
+]
+ EOD
+ c2 = XSD::CodeGen::ClassDef.new(class_name + "App",
+ "::SOAP::RPC::CGIStub")
+ c2.def_method("initialize", "*arg") do
+ <<-EOD
+ super(*arg)
+ servant = #{class_name}.new
+ #{class_name}::Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
+ else
+ @router.add_rpc_operation(servant, *definitions)
+ end
+ end
+ self.mapping_registry = #{class_name}::MappingRegistry
+ self.level = Logger::Severity::ERROR
+ EOD
+ end
+ c1.dump + "\n" + c2.dump + format(<<-EOD)
+ #{class_name}App.new('app', nil).start
+ EOD
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/classDefCreator.rb b/lib/wsdl/soap/classDefCreator.rb
new file mode 100644
index 0000000000..aeb67c0613
--- /dev/null
+++ b/lib/wsdl/soap/classDefCreator.rb
@@ -0,0 +1,314 @@
+# WSDL4R - Creating class definition from WSDL
+# Copyright (C) 2002, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/data'
+require 'wsdl/soap/classDefCreatorSupport'
+require 'xsd/codegen'
+
+
+module WSDL
+module SOAP
+
+
+class ClassDefCreator
+ include ClassDefCreatorSupport
+
+ def initialize(definitions)
+ @elements = definitions.collect_elements
+ @simpletypes = definitions.collect_simpletypes
+ @complextypes = definitions.collect_complextypes
+ @faulttypes = nil
+ if definitions.respond_to?(:collect_faulttypes)
+ @faulttypes = definitions.collect_faulttypes
+ end
+ end
+
+ def dump(type = nil)
+ result = "require 'xsd/qname'\n"
+ if type
+ result = dump_classdef(type.name, type)
+ else
+ str = dump_element
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ str = dump_complextype
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ str = dump_simpletype
+ unless str.empty?
+ result << "\n" unless result.empty?
+ result << str
+ end
+ end
+ result
+ end
+
+private
+
+ def dump_element
+ @elements.collect { |ele|
+ if ele.local_complextype
+ dump_classdef(ele.name, ele.local_complextype,
+ ele.elementform == 'qualified')
+ elsif ele.local_simpletype
+ dump_simpletypedef(ele.name, ele.local_simpletype)
+ else
+ nil
+ end
+ }.compact.join("\n")
+ end
+
+ def dump_simpletype
+ @simpletypes.collect { |type|
+ dump_simpletypedef(type.name, type)
+ }.compact.join("\n")
+ end
+
+ def dump_complextype
+ @complextypes.collect { |type|
+ case type.compoundtype
+ when :TYPE_STRUCT, :TYPE_EMPTY
+ dump_classdef(type.name, type)
+ when :TYPE_ARRAY
+ dump_arraydef(type)
+ when :TYPE_SIMPLE
+ dump_simpleclassdef(type)
+ when :TYPE_MAP
+ # mapped as a general Hash
+ nil
+ else
+ raise RuntimeError.new(
+ "unknown kind of complexContent: #{type.compoundtype}")
+ end
+ }.compact.join("\n")
+ end
+
+ def dump_simpletypedef(qname, simpletype)
+ if !simpletype.restriction or simpletype.restriction.enumeration.empty?
+ return nil
+ end
+ c = XSD::CodeGen::ModuleDef.new(create_class_name(qname))
+ c.comment = "#{qname}"
+ const = {}
+ simpletype.restriction.enumeration.each do |value|
+ constname = safeconstname(value)
+ const[constname] ||= 0
+ if (const[constname] += 1) > 1
+ constname += "_#{const[constname]}"
+ end
+ c.def_const(constname, ndq(value))
+ end
+ c.dump
+ end
+
+ def dump_simpleclassdef(type_or_element)
+ qname = type_or_element.name
+ base = create_class_name(type_or_element.simplecontent.base)
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname), base)
+ c.comment = "#{qname}"
+ c.dump
+ end
+
+ def dump_classdef(qname, typedef, qualified = false)
+ if @faulttypes and @faulttypes.index(qname)
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname),
+ '::StandardError')
+ else
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname))
+ end
+ c.comment = "#{qname}"
+ c.def_classvar('schema_type', ndq(qname.name))
+ c.def_classvar('schema_ns', ndq(qname.namespace))
+ c.def_classvar('schema_qualified', dq('true')) if qualified
+ schema_element = []
+ init_lines = ''
+ params = []
+ typedef.each_element do |element|
+ if element.type == XSD::AnyTypeName
+ type = nil
+ elsif klass = element_basetype(element)
+ type = klass.name
+ elsif element.type
+ type = create_class_name(element.type)
+ else
+ type = nil # means anyType.
+ # do we define a class for local complexType from it's name?
+ # type = create_class_name(element.name)
+ # <element>
+ # <complexType>
+ # <seq...>
+ # </complexType>
+ # </element>
+ end
+ name = name_element(element).name
+ attrname = safemethodname?(name) ? name : safemethodname(name)
+ varname = safevarname(name)
+ c.def_attr(attrname, true, varname)
+ init_lines << "@#{varname} = #{varname}\n"
+ if element.map_as_array?
+ params << "#{varname} = []"
+ type << '[]' if type
+ else
+ params << "#{varname} = nil"
+ end
+ # nil means @@schema_ns + varname
+ eleqname =
+ (varname == name && element.name.namespace == qname.namespace) ?
+ nil : element.name
+ schema_element << [varname, eleqname, type]
+ end
+ unless typedef.attributes.empty?
+ define_attribute(c, typedef.attributes)
+ init_lines << "@__xmlattr = {}\n"
+ end
+ c.def_classvar('schema_element',
+ '[' +
+ schema_element.collect { |varname, name, type|
+ '[' +
+ (
+ if name
+ varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
+ else
+ varname.dump + ', ' + ndq(type)
+ end
+ ) +
+ ']'
+ }.join(', ') +
+ ']'
+ )
+ c.def_method('initialize', *params) do
+ init_lines
+ end
+ c.dump
+ end
+
+ def element_basetype(ele)
+ if klass = basetype_class(ele.type)
+ klass
+ elsif ele.local_simpletype
+ basetype_class(ele.local_simpletype.base)
+ else
+ nil
+ end
+ end
+
+ def attribute_basetype(attr)
+ if klass = basetype_class(attr.type)
+ klass
+ elsif attr.local_simpletype
+ basetype_class(attr.local_simpletype.base)
+ else
+ nil
+ end
+ end
+
+ def basetype_class(type)
+ return nil if type.nil?
+ if simpletype = @simpletypes[type]
+ basetype_mapped_class(simpletype.base)
+ else
+ basetype_mapped_class(type)
+ end
+ end
+
+ def define_attribute(c, attributes)
+ schema_attribute = []
+ attributes.each do |attribute|
+ name = name_attribute(attribute)
+ if klass = attribute_basetype(attribute)
+ type = klass.name
+ else
+ type = nil
+ end
+ methodname = safemethodname('xmlattr_' + name.name)
+ c.def_method(methodname) do <<-__EOD__
+ (@__xmlattr ||= {})[#{dqname(name)}]
+ __EOD__
+ end
+ c.def_method(methodname + '=', 'value') do <<-__EOD__
+ (@__xmlattr ||= {})[#{dqname(name)}] = value
+ __EOD__
+ end
+ schema_attribute << [name, type]
+ end
+ c.def_classvar('schema_attribute',
+ '{' +
+ schema_attribute.collect { |name, type|
+ dqname(name) + ' => ' + ndq(type)
+ }.join(', ') +
+ '}'
+ )
+ end
+
+ def name_element(element)
+ return element.name if element.name
+ return element.ref if element.ref
+ raise RuntimeError.new("cannot define name of #{element}")
+ end
+
+ def name_attribute(attribute)
+ return attribute.name if attribute.name
+ return attribute.ref if attribute.ref
+ raise RuntimeError.new("cannot define name of #{attribute}")
+ end
+
+ DEFAULT_ITEM_NAME = XSD::QName.new(nil, 'item')
+
+ def dump_arraydef(complextype)
+ qname = complextype.name
+ c = XSD::CodeGen::ClassDef.new(create_class_name(qname), '::Array')
+ c.comment = "#{qname}"
+ child_type = complextype.child_type
+ c.def_classvar('schema_type', ndq(child_type.name))
+ c.def_classvar('schema_ns', ndq(child_type.namespace))
+ child_element = complextype.find_aryelement
+ schema_element = []
+ if child_type == XSD::AnyTypeName
+ type = nil
+ elsif child_element and (klass = element_basetype(child_element))
+ type = klass.name
+ elsif child_type
+ type = create_class_name(child_type)
+ else
+ type = nil
+ end
+ if child_element
+ if child_element.map_as_array?
+ type << '[]' if type
+ end
+ child_element_name = child_element.name
+ else
+ child_element_name = DEFAULT_ITEM_NAME
+ end
+ schema_element << [child_element_name.name, child_element_name, type]
+ c.def_classvar('schema_element',
+ '[' +
+ schema_element.collect { |varname, name, type|
+ '[' +
+ (
+ if name
+ varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']'
+ else
+ varname.dump + ', ' + ndq(type)
+ end
+ ) +
+ ']'
+ }.join(', ') +
+ ']'
+ )
+ c.dump
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/classDefCreatorSupport.rb b/lib/wsdl/soap/classDefCreatorSupport.rb
new file mode 100644
index 0000000000..8f335653c8
--- /dev/null
+++ b/lib/wsdl/soap/classDefCreatorSupport.rb
@@ -0,0 +1,126 @@
+# WSDL4R - Creating class code support from WSDL.
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'soap/mapping'
+require 'soap/mapping/typeMap'
+require 'xsd/codegen/gensupport'
+
+
+module WSDL
+module SOAP
+
+
+module ClassDefCreatorSupport
+ include XSD::CodeGen::GenSupport
+
+ def create_class_name(qname)
+ if klass = basetype_mapped_class(qname)
+ ::SOAP::Mapping::DefaultRegistry.find_mapped_obj_class(klass).name
+ else
+ safeconstname(qname.name)
+ end
+ end
+
+ def basetype_mapped_class(name)
+ ::SOAP::TypeMap[name]
+ end
+
+ def dump_method_signature(operation)
+ name = operation.name.name
+ input = operation.input
+ output = operation.output
+ fault = operation.fault
+ signature = "#{ name }#{ dump_inputparam(input) }"
+ str = <<__EOD__
+# SYNOPSIS
+# #{name}#{dump_inputparam(input)}
+#
+# ARGS
+#{dump_inout_type(input).chomp}
+#
+# RETURNS
+#{dump_inout_type(output).chomp}
+#
+__EOD__
+ unless fault.empty?
+ faultstr = (fault.collect { |f| dump_inout_type(f).chomp }).join(', ')
+ str <<<<__EOD__
+# RAISES
+# #{faultstr}
+#
+__EOD__
+ end
+ str
+ end
+
+ def dq(ele)
+ ele.dump
+ end
+
+ def ndq(ele)
+ ele.nil? ? 'nil' : dq(ele)
+ end
+
+ def sym(ele)
+ ':' + ele
+ end
+
+ def dqname(qname)
+ qname.dump
+ end
+
+private
+
+ def dump_inout_type(param)
+ if param
+ message = param.find_message
+ params = ""
+ message.parts.each do |part|
+ name = safevarname(part.name)
+ if part.type
+ typename = safeconstname(part.type.name)
+ params << add_at("# #{name}", "#{typename} - #{part.type}\n", 20)
+ elsif part.element
+ typename = safeconstname(part.element.name)
+ params << add_at("# #{name}", "#{typename} - #{part.element}\n", 20)
+ end
+ end
+ unless params.empty?
+ return params
+ end
+ end
+ "# N/A\n"
+ end
+
+ def dump_inputparam(input)
+ message = input.find_message
+ params = ""
+ message.parts.each do |part|
+ params << ", " unless params.empty?
+ params << safevarname(part.name)
+ end
+ if params.empty?
+ ""
+ else
+ "(#{ params })"
+ end
+ end
+
+ def add_at(base, str, pos)
+ if base.size >= pos
+ base + ' ' + str
+ else
+ base + ' ' * (pos - base.size) + str
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/clientSkeltonCreator.rb b/lib/wsdl/soap/clientSkeltonCreator.rb
new file mode 100644
index 0000000000..916f0d4dc0
--- /dev/null
+++ b/lib/wsdl/soap/clientSkeltonCreator.rb
@@ -0,0 +1,78 @@
+# WSDL4R - Creating client skelton code from WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/classDefCreatorSupport'
+
+
+module WSDL
+module SOAP
+
+
+class ClientSkeltonCreator
+ include ClassDefCreatorSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ end
+
+ def dump(service_name)
+ result = ""
+ @definitions.service(service_name).ports.each do |port|
+ result << dump_porttype(port.porttype.name)
+ result << "\n"
+ end
+ result
+ end
+
+private
+
+ def dump_porttype(name)
+ drv_name = create_class_name(name)
+
+ result = ""
+ result << <<__EOD__
+endpoint_url = ARGV.shift
+obj = #{ drv_name }.new(endpoint_url)
+
+# run ruby with -d to see SOAP wiredumps.
+obj.wiredump_dev = STDERR if $DEBUG
+
+__EOD__
+ @definitions.porttype(name).operations.each do |operation|
+ result << dump_method_signature(operation)
+ result << dump_input_init(operation.input) << "\n"
+ result << dump_operation(operation) << "\n\n"
+ end
+ result
+ end
+
+ def dump_operation(operation)
+ name = operation.name
+ input = operation.input
+ "puts obj.#{ safemethodname(name.name) }#{ dump_inputparam(input) }"
+ end
+
+ def dump_input_init(input)
+ result = input.find_message.parts.collect { |part|
+ safevarname(part.name)
+ }.join(" = ")
+ if result.empty?
+ ""
+ else
+ result << " = nil"
+ end
+ result
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb
new file mode 100644
index 0000000000..b2e13d0564
--- /dev/null
+++ b/lib/wsdl/soap/complexType.rb
@@ -0,0 +1,161 @@
+# WSDL4R - SOAP complexType definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/xmlSchema/complexType'
+require 'soap/mapping'
+
+
+module WSDL
+module XMLSchema
+
+
+class ComplexType < Info
+ def compoundtype
+ @compoundtype ||= check_type
+ end
+
+ def check_type
+ if content
+ if attributes.empty? and
+ content.elements.size == 1 and content.elements[0].maxoccurs != '1'
+ if name == ::SOAP::Mapping::MapQName
+ :TYPE_MAP
+ else
+ :TYPE_ARRAY
+ end
+ else
+ :TYPE_STRUCT
+ end
+ elsif complexcontent
+ if complexcontent.base == ::SOAP::ValueArrayName
+ :TYPE_ARRAY
+ else
+ complexcontent.basetype.check_type
+ end
+ elsif simplecontent
+ :TYPE_SIMPLE
+ elsif !attributes.empty?
+ :TYPE_STRUCT
+ else # empty complexType definition (seen in partner.wsdl of salesforce)
+ :TYPE_EMPTY
+ end
+ end
+
+ def child_type(name = nil)
+ case compoundtype
+ when :TYPE_STRUCT
+ if ele = find_element(name)
+ ele.type
+ elsif ele = find_element_by_name(name.name)
+ ele.type
+ end
+ when :TYPE_ARRAY
+ @contenttype ||= content_arytype
+ when :TYPE_MAP
+ item_ele = find_element_by_name("item") or
+ raise RuntimeError.new("'item' element not found in Map definition.")
+ content = item_ele.local_complextype or
+ raise RuntimeError.new("No complexType definition for 'item'.")
+ if ele = content.find_element(name)
+ ele.type
+ elsif ele = content.find_element_by_name(name.name)
+ ele.type
+ end
+ else
+ raise NotImplementedError.new("Unknown kind of complexType.")
+ end
+ end
+
+ def child_defined_complextype(name)
+ ele = nil
+ case compoundtype
+ when :TYPE_STRUCT, :TYPE_MAP
+ unless ele = find_element(name)
+ if name.namespace.nil?
+ ele = find_element_by_name(name.name)
+ end
+ end
+ when :TYPE_ARRAY
+ if content.elements.size == 1
+ ele = content.elements[0]
+ else
+ raise RuntimeError.new("Assert: must not reach.")
+ end
+ else
+ raise RuntimeError.new("Assert: Not implemented.")
+ end
+ unless ele
+ raise RuntimeError.new("Cannot find #{name} as a children of #{@name}.")
+ end
+ ele.local_complextype
+ end
+
+ def find_arytype
+ unless compoundtype == :TYPE_ARRAY
+ raise RuntimeError.new("Assert: not for array")
+ end
+ if complexcontent
+ complexcontent.attributes.each do |attribute|
+ if attribute.ref == ::SOAP::AttrArrayTypeName
+ return attribute.arytype
+ end
+ end
+ if check_array_content(complexcontent.content)
+ return element_simpletype(complexcontent.content.elements[0])
+ end
+ elsif check_array_content(content)
+ return element_simpletype(content.elements[0])
+ end
+ raise RuntimeError.new("Assert: Unknown array definition.")
+ end
+
+ def find_aryelement
+ unless compoundtype == :TYPE_ARRAY
+ raise RuntimeError.new("Assert: not for array")
+ end
+ if complexcontent
+ if check_array_content(complexcontent.content)
+ return complexcontent.content.elements[0]
+ end
+ elsif check_array_content(content)
+ return content.elements[0]
+ end
+ nil # use default item name
+ end
+
+private
+
+ def element_simpletype(element)
+ if element.type
+ element.type
+ elsif element.local_simpletype
+ element.local_simpletype.base
+ else
+ nil
+ end
+ end
+
+ def check_array_content(content)
+ content and content.elements.size == 1 and
+ content.elements[0].maxoccurs != '1'
+ end
+
+ def content_arytype
+ if arytype = find_arytype
+ ns = arytype.namespace
+ name = arytype.name.sub(/\[(?:,)*\]$/, '')
+ XSD::QName.new(ns, name)
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/data.rb b/lib/wsdl/soap/data.rb
new file mode 100644
index 0000000000..48512d3751
--- /dev/null
+++ b/lib/wsdl/soap/data.rb
@@ -0,0 +1,42 @@
+# WSDL4R - WSDL SOAP binding data definitions.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'wsdl/soap/definitions'
+require 'wsdl/soap/binding'
+require 'wsdl/soap/operation'
+require 'wsdl/soap/body'
+require 'wsdl/soap/element'
+require 'wsdl/soap/header'
+require 'wsdl/soap/headerfault'
+require 'wsdl/soap/fault'
+require 'wsdl/soap/address'
+require 'wsdl/soap/complexType'
+
+
+module WSDL
+module SOAP
+
+
+HeaderFaultName = XSD::QName.new(SOAPBindingNamespace, 'headerfault')
+
+LocationAttrName = XSD::QName.new(nil, 'location')
+StyleAttrName = XSD::QName.new(nil, 'style')
+TransportAttrName = XSD::QName.new(nil, 'transport')
+UseAttrName = XSD::QName.new(nil, 'use')
+PartsAttrName = XSD::QName.new(nil, 'parts')
+PartAttrName = XSD::QName.new(nil, 'part')
+NameAttrName = XSD::QName.new(nil, 'name')
+MessageAttrName = XSD::QName.new(nil, 'message')
+EncodingStyleAttrName = XSD::QName.new(nil, 'encodingStyle')
+NamespaceAttrName = XSD::QName.new(nil, 'namespace')
+SOAPActionAttrName = XSD::QName.new(nil, 'soapAction')
+
+
+end
+end
diff --git a/lib/wsdl/soap/definitions.rb b/lib/wsdl/soap/definitions.rb
new file mode 100644
index 0000000000..b014d5af6b
--- /dev/null
+++ b/lib/wsdl/soap/definitions.rb
@@ -0,0 +1,149 @@
+# WSDL4R - WSDL additional definitions for SOAP.
+# Copyright (C) 2002-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+require 'soap/mapping'
+
+
+module WSDL
+
+
+class Definitions < Info
+ def self.soap_rpc_complextypes
+ types = XSD::NamedElements.new
+ types << array_complextype
+ types << fault_complextype
+ types << exception_complextype
+ types
+ end
+
+ def self.array_complextype
+ type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName)
+ type.complexcontent = XMLSchema::ComplexContent.new
+ type.complexcontent.base = ::SOAP::ValueArrayName
+ attr = XMLSchema::Attribute.new
+ attr.ref = ::SOAP::AttrArrayTypeName
+ anytype = XSD::AnyTypeName.dup
+ anytype.name += '[]'
+ attr.arytype = anytype
+ type.complexcontent.attributes << attr
+ type
+ end
+
+=begin
+<xs:complexType name="Fault" final="extension">
+ <xs:sequence>
+ <xs:element name="faultcode" type="xs:QName" />
+ <xs:element name="faultstring" type="xs:string" />
+ <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
+ <xs:element name="detail" type="tns:detail" minOccurs="0" />
+ </xs:sequence>
+</xs:complexType>
+=end
+ def self.fault_complextype
+ type = XMLSchema::ComplexType.new(::SOAP::EleFaultName)
+ faultcode = XMLSchema::Element.new(::SOAP::EleFaultCodeName, XSD::XSDQName::Type)
+ faultstring = XMLSchema::Element.new(::SOAP::EleFaultStringName, XSD::XSDString::Type)
+ faultactor = XMLSchema::Element.new(::SOAP::EleFaultActorName, XSD::XSDAnyURI::Type)
+ faultactor.minoccurs = 0
+ detail = XMLSchema::Element.new(::SOAP::EleFaultDetailName, XSD::AnyTypeName)
+ detail.minoccurs = 0
+ type.all_elements = [faultcode, faultstring, faultactor, detail]
+ type.final = 'extension'
+ type
+ end
+
+ def self.exception_complextype
+ type = XMLSchema::ComplexType.new(XSD::QName.new(
+ ::SOAP::Mapping::RubyCustomTypeNamespace, 'SOAPException'))
+ excn_name = XMLSchema::Element.new(XSD::QName.new(nil, 'excn_type_name'), XSD::XSDString::Type)
+ cause = XMLSchema::Element.new(XSD::QName.new(nil, 'cause'), XSD::AnyTypeName)
+ backtrace = XMLSchema::Element.new(XSD::QName.new(nil, 'backtrace'), ::SOAP::ValueArrayName)
+ message = XMLSchema::Element.new(XSD::QName.new(nil, 'message'), XSD::XSDString::Type)
+ type.all_elements = [excn_name, cause, backtrace, message]
+ type
+ end
+
+ def soap_rpc_complextypes(binding)
+ types = rpc_operation_complextypes(binding)
+ types + self.class.soap_rpc_complextypes
+ end
+
+ def collect_faulttypes
+ result = []
+ collect_fault_messages.each do |name|
+ faultparts = message(name).parts
+ if faultparts.size != 1
+ raise RuntimeError.new("expecting fault message to have only 1 part")
+ end
+ if result.index(faultparts[0].type).nil?
+ result << faultparts[0].type
+ end
+ end
+ result
+ end
+
+private
+
+ def collect_fault_messages
+ result = []
+ porttypes.each do |porttype|
+ porttype.operations.each do |operation|
+ operation.fault.each do |fault|
+ if result.index(fault.message).nil?
+ result << fault.message
+ end
+ end
+ end
+ end
+ result
+ end
+
+ def rpc_operation_complextypes(binding)
+ types = XSD::NamedElements.new
+ binding.operations.each do |op_bind|
+ if op_bind_rpc?(op_bind)
+ operation = op_bind.find_operation
+ if op_bind.input
+ type = XMLSchema::ComplexType.new(op_bind.soapoperation_name)
+ message = messages[operation.input.message]
+ type.sequence_elements = elements_from_message(message)
+ types << type
+ end
+ if op_bind.output
+ type = XMLSchema::ComplexType.new(operation.outputname)
+ message = messages[operation.output.message]
+ type.sequence_elements = elements_from_message(message)
+ types << type
+ end
+ end
+ end
+ types
+ end
+
+ def op_bind_rpc?(op_bind)
+ op_bind.soapoperation_style == :rpc
+ end
+
+ def elements_from_message(message)
+ message.parts.collect { |part|
+ if part.element
+ collect_elements[part.element]
+ elsif part.name.nil? or part.type.nil?
+ raise RuntimeError.new("part of a message must be an element or typed")
+ else
+ qname = XSD::QName.new(nil, part.name)
+ XMLSchema::Element.new(qname, part.type)
+ end
+ }
+ end
+end
+
+
+end
diff --git a/lib/wsdl/soap/driverCreator.rb b/lib/wsdl/soap/driverCreator.rb
new file mode 100644
index 0000000000..eba7c158a2
--- /dev/null
+++ b/lib/wsdl/soap/driverCreator.rb
@@ -0,0 +1,95 @@
+# WSDL4R - Creating driver code from WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/mappingRegistryCreator'
+require 'wsdl/soap/methodDefCreator'
+require 'wsdl/soap/classDefCreatorSupport'
+require 'xsd/codegen'
+
+
+module WSDL
+module SOAP
+
+
+class DriverCreator
+ include ClassDefCreatorSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ end
+
+ def dump(porttype = nil)
+ if porttype.nil?
+ result = ""
+ @definitions.porttypes.each do |type|
+ result << dump_porttype(type.name)
+ result << "\n"
+ end
+ else
+ result = dump_porttype(porttype)
+ end
+ result
+ end
+
+private
+
+ def dump_porttype(name)
+ class_name = create_class_name(name)
+ methoddef, types = MethodDefCreator.new(@definitions).dump(name)
+ mr_creator = MappingRegistryCreator.new(@definitions)
+ binding = @definitions.bindings.find { |item| item.type == name }
+ return '' unless binding.soapbinding # not a SOAP binding
+ address = @definitions.porttype(name).locations[0]
+
+ c = XSD::CodeGen::ClassDef.new(class_name, "::SOAP::RPC::Driver")
+ c.def_require("soap/rpc/driver")
+ c.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
+ c.def_const("DefaultEndpointUrl", ndq(address))
+ c.def_code(mr_creator.dump(types))
+ c.def_code <<-EOD
+Methods = [
+#{methoddef.gsub(/^/, " ")}
+]
+ EOD
+ c.def_method("initialize", "endpoint_url = nil") do
+ <<-EOD
+ endpoint_url ||= DefaultEndpointUrl
+ super(endpoint_url, nil)
+ self.mapping_registry = MappingRegistry
+ init_methods
+ EOD
+ end
+ c.def_privatemethod("init_methods") do
+ <<-EOD
+ Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ add_document_operation(*definitions)
+ else
+ add_rpc_operation(*definitions)
+ qname = definitions[0]
+ name = definitions[2]
+ if qname.name != name and qname.name.capitalize == name.capitalize
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
+ __send__(name, *arg)
+ end
+ end
+ end
+ end
+ EOD
+ end
+ c.dump
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/element.rb b/lib/wsdl/soap/element.rb
new file mode 100644
index 0000000000..0fa6017c5b
--- /dev/null
+++ b/lib/wsdl/soap/element.rb
@@ -0,0 +1,28 @@
+# WSDL4R - XMLSchema element definition for WSDL.
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/xmlSchema/element'
+
+
+module WSDL
+module XMLSchema
+
+
+class Element < Info
+ def map_as_array?
+ maxoccurs != '1'
+ end
+
+ def attributes
+ @local_complextype.attributes
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/fault.rb b/lib/wsdl/soap/fault.rb
new file mode 100644
index 0000000000..2862b659ab
--- /dev/null
+++ b/lib/wsdl/soap/fault.rb
@@ -0,0 +1,56 @@
+# WSDL4R - WSDL SOAP body definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class Fault < Info
+ attr_reader :name # required
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @name = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ when UseAttrName
+ @use = value.source
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/header.rb b/lib/wsdl/soap/header.rb
new file mode 100644
index 0000000000..8d7c4e9d70
--- /dev/null
+++ b/lib/wsdl/soap/header.rb
@@ -0,0 +1,86 @@
+# WSDL4R - WSDL SOAP body definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class Header < Info
+ attr_reader :headerfault
+
+ attr_reader :message # required
+ attr_reader :part # required
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @message = nil
+ @part = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ @headerfault = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def find_message
+ root.message(@message) or raise RuntimeError.new("#{@message} not found")
+ end
+
+ def find_part
+ find_message.parts.each do |part|
+ if part.name == @part
+ return part
+ end
+ end
+ raise RuntimeError.new("#{@part} not found")
+ end
+
+ def parse_element(element)
+ case element
+ when HeaderFaultName
+ o = WSDL::SOAP::HeaderFault.new
+ @headerfault = o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MessageAttrName
+ if value.namespace.nil?
+ value = XSD::QName.new(targetnamespace, value.source)
+ end
+ @message = value
+ when PartAttrName
+ @part = value.source
+ when UseAttrName
+ @use = value.source
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/headerfault.rb b/lib/wsdl/soap/headerfault.rb
new file mode 100644
index 0000000000..d6b14f2646
--- /dev/null
+++ b/lib/wsdl/soap/headerfault.rb
@@ -0,0 +1,56 @@
+# WSDL4R - WSDL SOAP body definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class HeaderFault < Info
+ attr_reader :message # required
+ attr_reader :part # required
+ attr_reader :use # required
+ attr_reader :encodingstyle
+ attr_reader :namespace
+
+ def initialize
+ super
+ @message = nil
+ @part = nil
+ @use = nil
+ @encodingstyle = nil
+ @namespace = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MessageAttrName
+ @message = value
+ when PartAttrName
+ @part = value.source
+ when UseAttrName
+ @use = value.source
+ when EncodingStyleAttrName
+ @encodingstyle = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/mappingRegistryCreator.rb b/lib/wsdl/soap/mappingRegistryCreator.rb
new file mode 100644
index 0000000000..8669339ce4
--- /dev/null
+++ b/lib/wsdl/soap/mappingRegistryCreator.rb
@@ -0,0 +1,92 @@
+# WSDL4R - Creating MappingRegistry code from WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/classDefCreatorSupport'
+
+
+module WSDL
+module SOAP
+
+
+class MappingRegistryCreator
+ include ClassDefCreatorSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ @complextypes = @definitions.collect_complextypes
+ @types = nil
+ end
+
+ def dump(types)
+ @types = types
+ map_cache = []
+ map = ""
+ @types.each do |type|
+ if map_cache.index(type).nil?
+ map_cache << type
+ if type.namespace != XSD::Namespace
+ if typemap = dump_typemap(type)
+ map << typemap
+ end
+ end
+ end
+ end
+ return map
+ end
+
+private
+
+ def dump_typemap(type)
+ if definedtype = @complextypes[type]
+ case definedtype.compoundtype
+ when :TYPE_STRUCT
+ dump_struct_typemap(definedtype)
+ when :TYPE_ARRAY
+ dump_array_typemap(definedtype)
+ when :TYPE_MAP, :TYPE_EMPTY
+ nil
+ else
+ raise NotImplementedError.new("must not reach here")
+ end
+ end
+ end
+
+ def dump_struct_typemap(definedtype)
+ ele = definedtype.name
+ return <<__EOD__
+MappingRegistry.set(
+ #{create_class_name(ele)},
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => #{dqname(ele)} }
+)
+__EOD__
+ end
+
+ def dump_array_typemap(definedtype)
+ ele = definedtype.name
+ arytype = definedtype.find_arytype || XSD::AnyTypeName
+ type = XSD::QName.new(arytype.namespace, arytype.name.sub(/\[(?:,)*\]$/, ''))
+ @types << type
+ return <<__EOD__
+MappingRegistry.set(
+ #{create_class_name(ele)},
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => #{dqname(type)} }
+)
+__EOD__
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/methodDefCreator.rb b/lib/wsdl/soap/methodDefCreator.rb
new file mode 100644
index 0000000000..f3ffadbe69
--- /dev/null
+++ b/lib/wsdl/soap/methodDefCreator.rb
@@ -0,0 +1,228 @@
+# WSDL4R - Creating driver code from WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/classDefCreatorSupport'
+require 'soap/rpc/element'
+
+
+module WSDL
+module SOAP
+
+
+class MethodDefCreator
+ include ClassDefCreatorSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ @simpletypes = @definitions.collect_simpletypes
+ @complextypes = @definitions.collect_complextypes
+ @elements = @definitions.collect_elements
+ @types = []
+ end
+
+ def dump(porttype)
+ @types.clear
+ result = ""
+ operations = @definitions.porttype(porttype).operations
+ binding = @definitions.porttype_binding(porttype)
+ operations.each do |operation|
+ op_bind = binding.operations[operation.name]
+ next unless op_bind # no binding is defined
+ next unless op_bind.soapoperation # not a SOAP operation binding
+ result << ",\n" unless result.empty?
+ result << dump_method(operation, op_bind).chomp
+ end
+ return result, @types
+ end
+
+ def collect_rpcparameter(operation)
+ result = operation.inputparts.collect { |part|
+ collect_type(part.type)
+ param_set(::SOAP::RPC::SOAPMethod::IN, part.name, rpcdefinedtype(part))
+ }
+ outparts = operation.outputparts
+ if outparts.size > 0
+ retval = outparts[0]
+ collect_type(retval.type)
+ result << param_set(::SOAP::RPC::SOAPMethod::RETVAL, retval.name,
+ rpcdefinedtype(retval))
+ cdr(outparts).each { |part|
+ collect_type(part.type)
+ result << param_set(::SOAP::RPC::SOAPMethod::OUT, part.name,
+ rpcdefinedtype(part))
+ }
+ end
+ result
+ end
+
+ def collect_documentparameter(operation)
+ param = []
+ operation.inputparts.each do |input|
+ param << param_set(::SOAP::RPC::SOAPMethod::IN, input.name,
+ documentdefinedtype(input), elementqualified(input))
+ end
+ operation.outputparts.each do |output|
+ param << param_set(::SOAP::RPC::SOAPMethod::OUT, output.name,
+ documentdefinedtype(output), elementqualified(output))
+ end
+ param
+ end
+
+private
+
+ def dump_method(operation, binding)
+ name = safemethodname(operation.name.name)
+ name_as = operation.name.name
+ style = binding.soapoperation_style
+ inputuse = binding.input.soapbody_use
+ outputuse = binding.output.soapbody_use
+ namespace = binding.input.soapbody.namespace
+ if style == :rpc
+ qname = XSD::QName.new(namespace, name_as)
+ paramstr = param2str(collect_rpcparameter(operation))
+ else
+ qname = nil
+ paramstr = param2str(collect_documentparameter(operation))
+ end
+ if paramstr.empty?
+ paramstr = '[]'
+ else
+ paramstr = "[ " << paramstr.split(/\r?\n/).join("\n ") << " ]"
+ end
+ definitions = <<__EOD__
+#{ndq(binding.soapaction)},
+ #{dq(name)},
+ #{paramstr},
+ { :request_style => #{sym(style.id2name)}, :request_use => #{sym(inputuse.id2name)},
+ :response_style => #{sym(style.id2name)}, :response_use => #{sym(outputuse.id2name)} }
+__EOD__
+ if style == :rpc
+ return <<__EOD__
+[ #{qname.dump},
+ #{definitions}]
+__EOD__
+ else
+ return <<__EOD__
+[ #{definitions}]
+__EOD__
+ end
+ end
+
+ def rpcdefinedtype(part)
+ if mapped = basetype_mapped_class(part.type)
+ ['::' + mapped.name]
+ elsif definedtype = @simpletypes[part.type]
+ ['::' + basetype_mapped_class(definedtype.base).name]
+ elsif definedtype = @elements[part.element]
+ #['::SOAP::SOAPStruct', part.element.namespace, part.element.name]
+ ['nil', part.element.namespace, part.element.name]
+ elsif definedtype = @complextypes[part.type]
+ case definedtype.compoundtype
+ when :TYPE_STRUCT, :TYPE_EMPTY # ToDo: empty should be treated as void.
+ type = create_class_name(part.type)
+ [type, part.type.namespace, part.type.name]
+ when :TYPE_MAP
+ [Hash.name, part.type.namespace, part.type.name]
+ when :TYPE_ARRAY
+ arytype = definedtype.find_arytype || XSD::AnyTypeName
+ ns = arytype.namespace
+ name = arytype.name.sub(/\[(?:,)*\]$/, '')
+ type = create_class_name(XSD::QName.new(ns, name))
+ [type + '[]', ns, name]
+ else
+ raise NotImplementedError.new("must not reach here")
+ end
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def documentdefinedtype(part)
+ if mapped = basetype_mapped_class(part.type)
+ ['::' + mapped.name, nil, part.name]
+ elsif definedtype = @simpletypes[part.type]
+ ['::' + basetype_mapped_class(definedtype.base).name, nil, part.name]
+ elsif definedtype = @elements[part.element]
+ ['::SOAP::SOAPElement', part.element.namespace, part.element.name]
+ elsif definedtype = @complextypes[part.type]
+ ['::SOAP::SOAPElement', part.type.namespace, part.type.name]
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def elementqualified(part)
+ if mapped = basetype_mapped_class(part.type)
+ false
+ elsif definedtype = @simpletypes[part.type]
+ false
+ elsif definedtype = @elements[part.element]
+ definedtype.elementform == 'qualified'
+ elsif definedtype = @complextypes[part.type]
+ false
+ else
+ raise RuntimeError.new("part: #{part.name} cannot be resolved")
+ end
+ end
+
+ def param_set(io_type, name, type, ele = nil)
+ [io_type, name, type, ele]
+ end
+
+ def collect_type(type)
+ # ignore inline type definition.
+ return if type.nil?
+ return if @types.include?(type)
+ @types << type
+ return unless @complextypes[type]
+ @complextypes[type].each_element do |element|
+ collect_type(element.type)
+ end
+ end
+
+ def param2str(params)
+ params.collect { |param|
+ io, name, type, ele = param
+ unless ele.nil?
+ "[#{dq(io)}, #{dq(name)}, #{type2str(type)}, #{ele2str(ele)}]"
+ else
+ "[#{dq(io)}, #{dq(name)}, #{type2str(type)}]"
+ end
+ }.join(",\n")
+ end
+
+ def type2str(type)
+ if type.size == 1
+ "[#{dq(type[0])}]"
+ else
+ "[#{dq(type[0])}, #{ndq(type[1])}, #{dq(type[2])}]"
+ end
+ end
+
+ def ele2str(ele)
+ qualified = ele
+ if qualified
+ "true"
+ else
+ "false"
+ end
+ end
+
+ def cdr(ary)
+ result = ary.dup
+ result.shift
+ result
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/operation.rb b/lib/wsdl/soap/operation.rb
new file mode 100644
index 0000000000..502d34a07d
--- /dev/null
+++ b/lib/wsdl/soap/operation.rb
@@ -0,0 +1,122 @@
+# WSDL4R - WSDL SOAP operation definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module SOAP
+
+
+class Operation < Info
+ class OperationInfo
+ attr_reader :style
+ attr_reader :op_name
+ attr_reader :optype_name
+ attr_reader :headerparts
+ attr_reader :bodyparts
+ attr_reader :faultpart
+ attr_reader :soapaction
+
+ def initialize(style, op_name, optype_name, headerparts, bodyparts, faultpart, soapaction)
+ @style = style
+ @op_name = op_name
+ @optype_name = optype_name
+ @headerparts = headerparts
+ @bodyparts = bodyparts
+ @faultpart = faultpart
+ @soapaction = soapaction
+ end
+ end
+
+ attr_reader :soapaction
+ attr_reader :style
+
+ def initialize
+ super
+ @soapaction = nil
+ @style = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when StyleAttrName
+ if ["document", "rpc"].include?(value.source)
+ @style = value.source.intern
+ else
+ raise Parser::AttributeConstraintError.new(
+ "Unexpected value #{ value }.")
+ end
+ when SOAPActionAttrName
+ @soapaction = value.source
+ else
+ nil
+ end
+ end
+
+ def input_info
+ name_info = parent.find_operation.input_info
+ param_info(name_info, parent.input)
+ end
+
+ def output_info
+ name_info = parent.find_operation.output_info
+ param_info(name_info, parent.output)
+ end
+
+ def operation_style
+ return @style if @style
+ if parent_binding.soapbinding
+ return parent_binding.soapbinding.style
+ end
+ nil
+ end
+
+private
+
+ def parent_binding
+ parent.parent
+ end
+
+ def param_info(name_info, param)
+ op_name = name_info.op_name
+ optype_name = name_info.optype_name
+
+ soapheader = param.soapheader
+ headerparts = soapheader.collect { |item| item.find_part }
+
+ soapbody = param.soapbody
+ if soapbody.encodingstyle and
+ soapbody.encodingstyle != ::SOAP::EncodingNamespace
+ raise NotImplementedError.new(
+ "EncodingStyle '#{ soapbody.encodingstyle }' not supported.")
+ end
+ if soapbody.namespace
+ op_name = XSD::QName.new(soapbody.namespace, op_name.name)
+ end
+ if soapbody.parts
+ target = soapbody.parts.split(/\s+/)
+ bodyparts = name_info.parts.find_all { |part|
+ target.include?(part.name)
+ }
+ else
+ bodyparts = name_info.parts
+ end
+
+ faultpart = nil
+ OperationInfo.new(operation_style, op_name, optype_name, headerparts, bodyparts, faultpart, parent.soapaction)
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/servantSkeltonCreator.rb b/lib/wsdl/soap/servantSkeltonCreator.rb
new file mode 100644
index 0000000000..88294ffed8
--- /dev/null
+++ b/lib/wsdl/soap/servantSkeltonCreator.rb
@@ -0,0 +1,67 @@
+# WSDL4R - Creating servant skelton code from WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/classDefCreatorSupport'
+require 'xsd/codegen'
+
+
+module WSDL
+module SOAP
+
+
+class ServantSkeltonCreator
+ include ClassDefCreatorSupport
+ include XSD::CodeGen::GenSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ end
+
+ def dump(porttype = nil)
+ if porttype.nil?
+ result = ""
+ @definitions.porttypes.each do |type|
+ result << dump_porttype(type.name)
+ result << "\n"
+ end
+ else
+ result = dump_porttype(porttype)
+ end
+ result
+ end
+
+private
+
+ def dump_porttype(name)
+ class_name = create_class_name(name)
+ c = XSD::CodeGen::ClassDef.new(class_name)
+ operations = @definitions.porttype(name).operations
+ operations.each do |operation|
+ name = safemethodname(operation.name.name)
+ input = operation.input
+ params = input.find_message.parts.collect { |part|
+ safevarname(part.name)
+ }
+ m = XSD::CodeGen::MethodDef.new(name, params) do <<-EOD
+ p [#{params.join(", ")}]
+ raise NotImplementedError.new
+ EOD
+ end
+ m.comment = dump_method_signature(operation)
+ c.add_method(m)
+ end
+ c.dump
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/standaloneServerStubCreator.rb b/lib/wsdl/soap/standaloneServerStubCreator.rb
new file mode 100644
index 0000000000..0b751b5153
--- /dev/null
+++ b/lib/wsdl/soap/standaloneServerStubCreator.rb
@@ -0,0 +1,85 @@
+# WSDL4R - Creating standalone server stub code from WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/soap/mappingRegistryCreator'
+require 'wsdl/soap/methodDefCreator'
+require 'wsdl/soap/classDefCreatorSupport'
+
+
+module WSDL
+module SOAP
+
+
+class StandaloneServerStubCreator
+ include ClassDefCreatorSupport
+
+ attr_reader :definitions
+
+ def initialize(definitions)
+ @definitions = definitions
+ end
+
+ def dump(service_name)
+ warn("- Standalone stub can have only 1 port for now. So creating stub for the first port and rests are ignored.")
+ warn("- Standalone server stub ignores port location defined in WSDL. Location is http://localhost:10080/ by default. Generated client from WSDL must be configured to point this endpoint manually.")
+ port = @definitions.service(service_name).ports[0]
+ dump_porttype(port.porttype.name)
+ end
+
+private
+
+ def dump_porttype(name)
+ class_name = create_class_name(name)
+ methoddef, types = MethodDefCreator.new(@definitions).dump(name)
+ mr_creator = MappingRegistryCreator.new(@definitions)
+
+ c1 = XSD::CodeGen::ClassDef.new(class_name)
+ c1.def_require("soap/rpc/standaloneServer")
+ c1.def_require("soap/mapping/registry")
+ c1.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
+ c1.def_code(mr_creator.dump(types))
+ c1.def_code <<-EOD
+Methods = [
+#{methoddef.gsub(/^/, " ")}
+]
+ EOD
+ c2 = XSD::CodeGen::ClassDef.new(class_name + "App",
+ "::SOAP::RPC::StandaloneServer")
+ c2.def_method("initialize", "*arg") do
+ <<-EOD
+ super(*arg)
+ servant = #{class_name}.new
+ #{class_name}::Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
+ else
+ @router.add_rpc_operation(servant, *definitions)
+ end
+ end
+ self.mapping_registry = #{class_name}::MappingRegistry
+ EOD
+ end
+ c1.dump + "\n" + c2.dump + format(<<-EOD)
+
+ if $0 == __FILE__
+ # Change listen port.
+ server = #{class_name}App.new('app', nil, '0.0.0.0', 10080)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
+ end
+ EOD
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/soap/wsdl2ruby.rb b/lib/wsdl/soap/wsdl2ruby.rb
new file mode 100644
index 0000000000..16b05fb032
--- /dev/null
+++ b/lib/wsdl/soap/wsdl2ruby.rb
@@ -0,0 +1,176 @@
+# WSDL4R - WSDL to ruby mapping library.
+# Copyright (C) 2002-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'logger'
+require 'xsd/qname'
+require 'wsdl/importer'
+require 'wsdl/soap/classDefCreator'
+require 'wsdl/soap/servantSkeltonCreator'
+require 'wsdl/soap/driverCreator'
+require 'wsdl/soap/clientSkeltonCreator'
+require 'wsdl/soap/standaloneServerStubCreator'
+require 'wsdl/soap/cgiStubCreator'
+
+
+module WSDL
+module SOAP
+
+
+class WSDL2Ruby
+ attr_accessor :location
+ attr_reader :opt
+ attr_accessor :logger
+ attr_accessor :basedir
+
+ def run
+ unless @location
+ raise RuntimeError, "WSDL location not given"
+ end
+ @wsdl = import(@location)
+ @name = @wsdl.name ? @wsdl.name.name : 'default'
+ create_file
+ end
+
+private
+
+ def initialize
+ @location = nil
+ @opt = {}
+ @logger = Logger.new(STDERR)
+ @basedir = nil
+ @wsdl = nil
+ @name = nil
+ end
+
+ def create_file
+ create_classdef if @opt.key?('classdef')
+ create_servant_skelton(@opt['servant_skelton']) if @opt.key?('servant_skelton')
+ create_cgi_stub(@opt['cgi_stub']) if @opt.key?('cgi_stub')
+ create_standalone_server_stub(@opt['standalone_server_stub']) if @opt.key?('standalone_server_stub')
+ create_driver(@opt['driver']) if @opt.key?('driver')
+ create_client_skelton(@opt['client_skelton']) if @opt.key?('client_skelton')
+ end
+
+ def create_classdef
+ @logger.info { "Creating class definition." }
+ @classdef_filename = @name + '.rb'
+ check_file(@classdef_filename) or return
+ write_file(@classdef_filename) do |f|
+ f << WSDL::SOAP::ClassDefCreator.new(@wsdl).dump
+ end
+ end
+
+ def create_client_skelton(servicename)
+ @logger.info { "Creating client skelton." }
+ servicename ||= @wsdl.services[0].name.name
+ @client_skelton_filename = servicename + 'Client.rb'
+ check_file(@client_skelton_filename) or return
+ write_file(@client_skelton_filename) do |f|
+ f << shbang << "\n"
+ f << "require '#{@driver_filename}'\n\n" if @driver_filename
+ f << WSDL::SOAP::ClientSkeltonCreator.new(@wsdl).dump(
+ create_name(servicename))
+ end
+ end
+
+ def create_servant_skelton(porttypename)
+ @logger.info { "Creating servant skelton." }
+ @servant_skelton_filename = (porttypename || @name + 'Servant') + '.rb'
+ check_file(@servant_skelton_filename) or return
+ write_file(@servant_skelton_filename) do |f|
+ f << "require '#{@classdef_filename}'\n\n" if @classdef_filename
+ f << WSDL::SOAP::ServantSkeltonCreator.new(@wsdl).dump(
+ create_name(porttypename))
+ end
+ end
+
+ def create_cgi_stub(servicename)
+ @logger.info { "Creating CGI stub." }
+ servicename ||= @wsdl.services[0].name.name
+ @cgi_stubFilename = servicename + '.cgi'
+ check_file(@cgi_stubFilename) or return
+ write_file(@cgi_stubFilename) do |f|
+ f << shbang << "\n"
+ if @servant_skelton_filename
+ f << "require '#{@servant_skelton_filename}'\n\n"
+ end
+ f << WSDL::SOAP::CGIStubCreator.new(@wsdl).dump(create_name(servicename))
+ end
+ end
+
+ def create_standalone_server_stub(servicename)
+ @logger.info { "Creating standalone stub." }
+ servicename ||= @wsdl.services[0].name.name
+ @standalone_server_stub_filename = servicename + '.rb'
+ check_file(@standalone_server_stub_filename) or return
+ write_file(@standalone_server_stub_filename) do |f|
+ f << shbang << "\n"
+ f << "require '#{@servant_skelton_filename}'\n\n" if @servant_skelton_filename
+ f << WSDL::SOAP::StandaloneServerStubCreator.new(@wsdl).dump(
+ create_name(servicename))
+ end
+ end
+
+ def create_driver(porttypename)
+ @logger.info { "Creating driver." }
+ @driver_filename = (porttypename || @name) + 'Driver.rb'
+ check_file(@driver_filename) or return
+ write_file(@driver_filename) do |f|
+ f << "require '#{@classdef_filename}'\n\n" if @classdef_filename
+ f << WSDL::SOAP::DriverCreator.new(@wsdl).dump(
+ create_name(porttypename))
+ end
+ end
+
+ def write_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ File.open(filename, "w") do |f|
+ yield f
+ end
+ end
+
+ def check_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ if FileTest.exist?(filename)
+ if @opt.key?('force')
+ @logger.warn {
+ "File '#{filename}' exists but overrides it."
+ }
+ true
+ else
+ @logger.warn {
+ "File '#{filename}' exists. #{$0} did not override it."
+ }
+ false
+ end
+ else
+ @logger.info { "Creates file '#{filename}'." }
+ true
+ end
+ end
+
+ def shbang
+ "#!/usr/bin/env ruby"
+ end
+
+ def create_name(name)
+ name ? XSD::QName.new(@wsdl.targetnamespace, name) : nil
+ end
+
+ def import(location)
+ WSDL::Importer.import(location)
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/types.rb b/lib/wsdl/types.rb
new file mode 100644
index 0000000000..96ae5a4988
--- /dev/null
+++ b/lib/wsdl/types.rb
@@ -0,0 +1,43 @@
+# WSDL4R - WSDL types definition.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+
+
+class Types < Info
+ attr_reader :schemas
+
+ def initialize
+ super
+ @schemas = []
+ end
+
+ def parse_element(element)
+ case element
+ when SchemaName
+ o = XMLSchema::Schema.new
+ @schemas << o
+ o
+ when DocumentationName
+ o = Documentation.new
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ nil
+ end
+end
+
+
+end
diff --git a/lib/wsdl/wsdl.rb b/lib/wsdl/wsdl.rb
new file mode 100644
index 0000000000..eb13c18806
--- /dev/null
+++ b/lib/wsdl/wsdl.rb
@@ -0,0 +1,23 @@
+# WSDL4R - Base definitions.
+# Copyright (C) 2000, 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+
+
+module WSDL
+
+
+Version = '0.0.2'
+
+Namespace = 'http://schemas.xmlsoap.org/wsdl/'
+SOAPBindingNamespace ='http://schemas.xmlsoap.org/wsdl/soap/'
+
+class Error < StandardError; end
+
+
+end
diff --git a/lib/wsdl/xmlSchema/all.rb b/lib/wsdl/xmlSchema/all.rb
new file mode 100644
index 0000000000..bb9566feac
--- /dev/null
+++ b/lib/wsdl/xmlSchema/all.rb
@@ -0,0 +1,69 @@
+# WSDL4R - XMLSchema complexType definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class All < Info
+ attr_reader :minoccurs
+ attr_reader :maxoccurs
+ attr_reader :elements
+
+ def initialize
+ super()
+ @minoccurs = '1'
+ @maxoccurs = '1'
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def <<(element)
+ @elements << element
+ end
+
+ def parse_element(element)
+ case element
+ when AnyName
+ o = Any.new
+ @elements << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/annotation.rb b/lib/wsdl/xmlSchema/annotation.rb
new file mode 100644
index 0000000000..633bd196f1
--- /dev/null
+++ b/lib/wsdl/xmlSchema/annotation.rb
@@ -0,0 +1,34 @@
+# WSDL4R - WSDL SOAP documentation element.
+# Copyright (C) 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Annotation < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ # Accepts any element.
+ self
+ end
+
+ def parse_attr(attr, value)
+ # Accepts any attribute.
+ true
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/any.rb b/lib/wsdl/xmlSchema/any.rb
new file mode 100644
index 0000000000..72d25e8dde
--- /dev/null
+++ b/lib/wsdl/xmlSchema/any.rb
@@ -0,0 +1,56 @@
+# WSDL4R - XMLSchema any definition for WSDL.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Any < Info
+ attr_accessor :maxoccurs
+ attr_accessor :minoccurs
+ attr_accessor :namespace
+ attr_accessor :process_contents
+
+ def initialize
+ super()
+ @maxoccurs = '1'
+ @minoccurs = '1'
+ @namespace = '##any'
+ @process_contents = 'strict'
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ when NamespaceAttrName
+ @namespace = value.source
+ when ProcessContentsAttrName
+ @process_contents = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/attribute.rb b/lib/wsdl/xmlSchema/attribute.rb
new file mode 100644
index 0000000000..f9048661a2
--- /dev/null
+++ b/lib/wsdl/xmlSchema/attribute.rb
@@ -0,0 +1,127 @@
+# WSDL4R - XMLSchema attribute definition for WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Attribute < Info
+ class << self
+ if RUBY_VERSION > "1.7.0"
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ define_method(name) {
+ instance_variable_get("@#{name}") ||
+ (refelement ? refelement.__send__(name) : nil)
+ }
+ end
+ else
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ module_eval <<-EOS
+ def #{name}
+ @#{name} || (refelement ? refelement.#{name} : nil)
+ end
+ EOS
+ end
+ end
+ end
+
+ attr_writer :use
+ attr_writer :form
+ attr_writer :name
+ attr_writer :type
+ attr_writer :local_simpletype
+ attr_writer :default
+ attr_writer :fixed
+
+ attr_reader_ref :use
+ attr_reader_ref :form
+ attr_reader_ref :name
+ attr_reader_ref :type
+ attr_reader_ref :local_simpletype
+ attr_reader_ref :default
+ attr_reader_ref :fixed
+
+ attr_accessor :ref
+ attr_accessor :arytype
+
+ def initialize
+ super
+ @use = nil
+ @form = nil
+ @name = nil
+ @type = nil
+ @local_simpletype = nil
+ @default = nil
+ @fixed = nil
+ @ref = nil
+ @refelement = nil
+ @arytype = nil
+ end
+
+ def refelement
+ @refelement ||= root.collect_attributes[@ref]
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when SimpleTypeName
+ @local_simpletype = SimpleType.new
+ @local_simpletype
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when RefAttrName
+ @ref = value
+ when UseAttrName
+ @use = value.source
+ when FormAttrName
+ @form = value.source
+ when NameAttrName
+ if directelement?
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ @name = XSD::QName.new(nil, value.source)
+ end
+ when TypeAttrName
+ @type = value
+ when DefaultAttrName
+ @default = value.source
+ when FixedAttrName
+ @fixed = value.source
+ when ArrayTypeAttrName
+ @arytype = if value.namespace.nil?
+ XSD::QName.new(XSD::Namespace, value.source)
+ else
+ value
+ end
+ else
+ nil
+ end
+ end
+
+private
+
+ def directelement?
+ parent.is_a?(Schema)
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/choice.rb b/lib/wsdl/xmlSchema/choice.rb
new file mode 100644
index 0000000000..f6d27fa38c
--- /dev/null
+++ b/lib/wsdl/xmlSchema/choice.rb
@@ -0,0 +1,69 @@
+# WSDL4R - XMLSchema complexType definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Choice < Info
+ attr_reader :minoccurs
+ attr_reader :maxoccurs
+ attr_reader :elements
+
+ def initialize
+ super()
+ @minoccurs = '1'
+ @maxoccurs = '1'
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def <<(element)
+ @elements << element
+ end
+
+ def parse_element(element)
+ case element
+ when AnyName
+ o = Any.new
+ @elements << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/complexContent.rb b/lib/wsdl/xmlSchema/complexContent.rb
new file mode 100644
index 0000000000..f7fb6c16b4
--- /dev/null
+++ b/lib/wsdl/xmlSchema/complexContent.rb
@@ -0,0 +1,92 @@
+# WSDL4R - XMLSchema complexContent definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class ComplexContent < Info
+ attr_accessor :base
+ attr_reader :derivetype
+ attr_reader :content
+ attr_reader :attributes
+
+ def initialize
+ super
+ @base = nil
+ @derivetype = nil
+ @content = nil
+ @attributes = XSD::NamedElements.new
+ @basetype = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def basetype
+ @basetype ||= root.collect_complextypes[@base]
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName, ExtensionName
+ @derivetype = element.name
+ self
+ when AllName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ @content = All.new
+ @content
+ when SequenceName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ @content = Sequence.new
+ @content
+ when ChoiceName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ @content = Choice.new
+ @content
+ when AttributeName
+ if @derivetype.nil?
+ raise Parser::ElementConstraintError.new("base attr not found.")
+ end
+ o = Attribute.new
+ @attributes << o
+ o
+ end
+ end
+
+ def parse_attr(attr, value)
+ if @derivetype.nil?
+ return nil
+ end
+ case attr
+ when BaseAttrName
+ @base = value
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/complexType.rb b/lib/wsdl/xmlSchema/complexType.rb
new file mode 100644
index 0000000000..dc9ec954fc
--- /dev/null
+++ b/lib/wsdl/xmlSchema/complexType.rb
@@ -0,0 +1,139 @@
+# WSDL4R - XMLSchema complexType definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/xmlSchema/content'
+require 'wsdl/xmlSchema/element'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class ComplexType < Info
+ attr_accessor :name
+ attr_accessor :complexcontent
+ attr_accessor :simplecontent
+ attr_reader :content
+ attr_accessor :final
+ attr_accessor :mixed
+ attr_reader :attributes
+
+ def initialize(name = nil)
+ super()
+ @name = name
+ @complexcontent = nil
+ @simplecontent = nil
+ @content = nil
+ @final = nil
+ @mixed = false
+ @attributes = XSD::NamedElements.new
+ end
+
+ def targetnamespace
+ # inner elements can be qualified
+ # parent.is_a?(WSDL::XMLSchema::Element) ? nil : parent.targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
+ def each_element
+ if content
+ content.elements.each do |element|
+ if element.is_a?(Any)
+ yield(AnyAsElement)
+ else
+ yield(element)
+ end
+ end
+ end
+ end
+
+ def find_element(name)
+ if content
+ content.elements.each do |element|
+ if element.is_a?(Any)
+ return AnyAsElement if name == AnyAsElement.name
+ else
+ return element if name == element.name
+ end
+ end
+ end
+ nil
+ end
+
+ def find_element_by_name(name)
+ if content
+ content.elements.each do |element|
+ if element.is_a?(Any)
+ return AnyAsElement if name == AnyAsElement.name.name
+ else
+ return element if name == element.name.name
+ end
+ end
+ end
+ nil
+ end
+
+ def sequence_elements=(elements)
+ @content = Sequence.new
+ elements.each do |element|
+ @content << element
+ end
+ end
+
+ def all_elements=(elements)
+ @content = All.new
+ elements.each do |element|
+ @content << element
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when AllName
+ @content = All.new
+ when SequenceName
+ @content = Sequence.new
+ when ChoiceName
+ @content = Choice.new
+ when ComplexContentName
+ @complexcontent = ComplexContent.new
+ when SimpleContentName
+ @simplecontent = SimpleContent.new
+ when AttributeName
+ o = Attribute.new
+ @attributes << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when FinalAttrName
+ @final = value.source
+ when MixedAttrName
+ @mixed = (value.source == 'true')
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/content.rb b/lib/wsdl/xmlSchema/content.rb
new file mode 100644
index 0000000000..2f1dfb4b6c
--- /dev/null
+++ b/lib/wsdl/xmlSchema/content.rb
@@ -0,0 +1,96 @@
+# WSDL4R - XMLSchema complexType definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Content < Info
+ attr_accessor :final
+ attr_accessor :mixed
+ attr_accessor :type
+ attr_reader :contents
+ attr_reader :elements
+
+ def initialize
+ super()
+ @final = nil
+ @mixed = false
+ @type = nil
+ @contents = []
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def <<(content)
+ @contents << content
+ update_elements
+ end
+
+ def each
+ @contents.each do |content|
+ yield content
+ end
+ end
+
+ def parse_element(element)
+ case element
+ when AllName, SequenceName, ChoiceName
+ o = Content.new
+ o.type = element.name
+ @contents << o
+ o
+ when AnyName
+ o = Any.new
+ @contents << o
+ o
+ when ElementName
+ o = Element.new
+ @contents << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when FinalAttrName
+ @final = value.source
+ when MixedAttrName
+ @mixed = (value.source == 'true')
+ else
+ nil
+ end
+ end
+
+ def parse_epilogue
+ update_elements
+ end
+
+private
+
+ def update_elements
+ @elements = []
+ @contents.each do |content|
+ if content.is_a?(Element)
+ @elements << [content.name, content]
+ end
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/data.rb b/lib/wsdl/xmlSchema/data.rb
new file mode 100644
index 0000000000..23ab1adf0b
--- /dev/null
+++ b/lib/wsdl/xmlSchema/data.rb
@@ -0,0 +1,80 @@
+# WSDL4R - XMLSchema data definitions.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/datatypes'
+require 'wsdl/xmlSchema/annotation'
+require 'wsdl/xmlSchema/schema'
+require 'wsdl/xmlSchema/import'
+require 'wsdl/xmlSchema/include'
+require 'wsdl/xmlSchema/simpleType'
+require 'wsdl/xmlSchema/simpleRestriction'
+require 'wsdl/xmlSchema/simpleExtension'
+require 'wsdl/xmlSchema/complexType'
+require 'wsdl/xmlSchema/complexContent'
+require 'wsdl/xmlSchema/simpleContent'
+require 'wsdl/xmlSchema/any'
+require 'wsdl/xmlSchema/element'
+require 'wsdl/xmlSchema/all'
+require 'wsdl/xmlSchema/choice'
+require 'wsdl/xmlSchema/sequence'
+require 'wsdl/xmlSchema/attribute'
+require 'wsdl/xmlSchema/unique'
+require 'wsdl/xmlSchema/enumeration'
+require 'wsdl/xmlSchema/length'
+require 'wsdl/xmlSchema/pattern'
+
+module WSDL
+module XMLSchema
+
+
+AllName = XSD::QName.new(XSD::Namespace, 'all')
+AnnotationName = XSD::QName.new(XSD::Namespace, 'annotation')
+AnyName = XSD::QName.new(XSD::Namespace, 'any')
+AttributeName = XSD::QName.new(XSD::Namespace, 'attribute')
+ChoiceName = XSD::QName.new(XSD::Namespace, 'choice')
+ComplexContentName = XSD::QName.new(XSD::Namespace, 'complexContent')
+ComplexTypeName = XSD::QName.new(XSD::Namespace, 'complexType')
+ElementName = XSD::QName.new(XSD::Namespace, 'element')
+EnumerationName = XSD::QName.new(XSD::Namespace, 'enumeration')
+ExtensionName = XSD::QName.new(XSD::Namespace, 'extension')
+ImportName = XSD::QName.new(XSD::Namespace, 'import')
+IncludeName = XSD::QName.new(XSD::Namespace, 'include')
+LengthName = XSD::QName.new(XSD::Namespace, 'length')
+PatternName = XSD::QName.new(XSD::Namespace, 'pattern')
+RestrictionName = XSD::QName.new(XSD::Namespace, 'restriction')
+SequenceName = XSD::QName.new(XSD::Namespace, 'sequence')
+SchemaName = XSD::QName.new(XSD::Namespace, 'schema')
+SimpleContentName = XSD::QName.new(XSD::Namespace, 'simpleContent')
+SimpleTypeName = XSD::QName.new(XSD::Namespace, 'simpleType')
+UniqueName = XSD::QName.new(XSD::Namespace, 'unique')
+
+AttributeFormDefaultAttrName = XSD::QName.new(nil, 'attributeFormDefault')
+BaseAttrName = XSD::QName.new(nil, 'base')
+DefaultAttrName = XSD::QName.new(nil, 'default')
+ElementFormDefaultAttrName = XSD::QName.new(nil, 'elementFormDefault')
+FinalAttrName = XSD::QName.new(nil, 'final')
+FixedAttrName = XSD::QName.new(nil, 'fixed')
+FormAttrName = XSD::QName.new(nil, 'form')
+IdAttrName = XSD::QName.new(nil, 'id')
+MaxOccursAttrName = XSD::QName.new(nil, 'maxOccurs')
+MinOccursAttrName = XSD::QName.new(nil, 'minOccurs')
+MixedAttrName = XSD::QName.new(nil, 'mixed')
+NameAttrName = XSD::QName.new(nil, 'name')
+NamespaceAttrName = XSD::QName.new(nil, 'namespace')
+NillableAttrName = XSD::QName.new(nil, 'nillable')
+ProcessContentsAttrName = XSD::QName.new(nil, 'processContents')
+RefAttrName = XSD::QName.new(nil, 'ref')
+SchemaLocationAttrName = XSD::QName.new(nil, 'schemaLocation')
+TargetNamespaceAttrName = XSD::QName.new(nil, 'targetNamespace')
+TypeAttrName = XSD::QName.new(nil, 'type')
+UseAttrName = XSD::QName.new(nil, 'use')
+ValueAttrName = XSD::QName.new(nil, 'value')
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/element.rb b/lib/wsdl/xmlSchema/element.rb
new file mode 100644
index 0000000000..fffb6485d0
--- /dev/null
+++ b/lib/wsdl/xmlSchema/element.rb
@@ -0,0 +1,154 @@
+# WSDL4R - XMLSchema element definition for WSDL.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Element < Info
+ class << self
+ if RUBY_VERSION > "1.7.0"
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ define_method(name) {
+ instance_variable_get("@#{name}") ||
+ (refelement ? refelement.__send__(name) : nil)
+ }
+ end
+ else
+ def attr_reader_ref(symbol)
+ name = symbol.to_s
+ module_eval <<-EOS
+ def #{name}
+ @#{name} || (refelement ? refelement.#{name} : nil)
+ end
+ EOS
+ end
+ end
+ end
+
+ attr_writer :name # required
+ attr_writer :form
+ attr_writer :type
+ attr_writer :local_simpletype
+ attr_writer :local_complextype
+ attr_writer :constraint
+ attr_writer :maxoccurs
+ attr_writer :minoccurs
+ attr_writer :nillable
+
+ attr_reader_ref :name
+ attr_reader_ref :form
+ attr_reader_ref :type
+ attr_reader_ref :local_simpletype
+ attr_reader_ref :local_complextype
+ attr_reader_ref :constraint
+ attr_reader_ref :maxoccurs
+ attr_reader_ref :minoccurs
+ attr_reader_ref :nillable
+
+ attr_accessor :ref
+
+ def initialize(name = nil, type = nil)
+ super()
+ @name = name
+ @form = nil
+ @type = type
+ @local_simpletype = @local_complextype = nil
+ @constraint = nil
+ @maxoccurs = '1'
+ @minoccurs = '1'
+ @nillable = nil
+ @ref = nil
+ @refelement = nil
+ end
+
+ def refelement
+ @refelement ||= (@ref ? root.collect_elements[@ref] : nil)
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def elementform
+ self.form.nil? ? parent.elementformdefault : self.form
+ end
+
+ def parse_element(element)
+ case element
+ when SimpleTypeName
+ @local_simpletype = SimpleType.new
+ @local_simpletype
+ when ComplexTypeName
+ @type = nil
+ @local_complextype = ComplexType.new
+ @local_complextype
+ when UniqueName
+ @constraint = Unique.new
+ @constraint
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ # namespace may be nil
+ if directelement? or elementform == 'qualified'
+ @name = XSD::QName.new(targetnamespace, value.source)
+ else
+ @name = XSD::QName.new(nil, value.source)
+ end
+ when FormAttrName
+ @form = value.source
+ when TypeAttrName
+ @type = value
+ when RefAttrName
+ @ref = value
+ when MaxOccursAttrName
+ if parent.is_a?(All)
+ if value.source != '1'
+ raise Parser::AttrConstraintError.new(
+ "cannot parse #{value} for #{attr}")
+ end
+ end
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ if parent.is_a?(All)
+ unless ['0', '1'].include?(value.source)
+ raise Parser::AttrConstraintError.new(
+ "cannot parse #{value} for #{attr}")
+ end
+ end
+ @minoccurs = value.source
+ when NillableAttrName
+ @nillable = (value.source == 'true')
+ else
+ nil
+ end
+ end
+
+private
+
+ def directelement?
+ parent.is_a?(Schema)
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/enumeration.rb b/lib/wsdl/xmlSchema/enumeration.rb
new file mode 100644
index 0000000000..5a16476032
--- /dev/null
+++ b/lib/wsdl/xmlSchema/enumeration.rb
@@ -0,0 +1,36 @@
+# WSDL4R - XMLSchema enumeration definition for WSDL.
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Enumeration < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when ValueAttrName
+ parent.enumeration << value.source
+ value.source
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/import.rb b/lib/wsdl/xmlSchema/import.rb
new file mode 100644
index 0000000000..d3487af934
--- /dev/null
+++ b/lib/wsdl/xmlSchema/import.rb
@@ -0,0 +1,65 @@
+# WSDL4R - XMLSchema import definition.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/xmlSchema/importer'
+
+
+module WSDL
+module XMLSchema
+
+
+class Import < Info
+ attr_reader :namespace
+ attr_reader :schemalocation
+ attr_reader :content
+
+ def initialize
+ super
+ @namespace = nil
+ @schemalocation = nil
+ @content = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NamespaceAttrName
+ @namespace = value.source
+ when SchemaLocationAttrName
+ @schemalocation = URI.parse(value.source)
+ if @schemalocation.relative? and !parent.location.nil? and
+ !parent.location.relative?
+ @schemalocation = parent.location + @schemalocation
+ end
+ if root.importedschema.key?(@schemalocation)
+ @content = root.importedschema[@schemalocation]
+ else
+ root.importedschema[@schemalocation] = nil # placeholder
+ @content = import(@schemalocation)
+ root.importedschema[@schemalocation] = @content
+ end
+ @schemalocation
+ else
+ nil
+ end
+ end
+
+private
+
+ def import(location)
+ Importer.import(location, root)
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/importer.rb b/lib/wsdl/xmlSchema/importer.rb
new file mode 100644
index 0000000000..f57bfd972a
--- /dev/null
+++ b/lib/wsdl/xmlSchema/importer.rb
@@ -0,0 +1,87 @@
+# WSDL4R - XSD importer library.
+# Copyright (C) 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'soap/httpconfigloader'
+require 'wsdl/xmlSchema/parser'
+
+
+module WSDL
+module XMLSchema
+
+
+class Importer
+ def self.import(location, originalroot = nil)
+ new.import(location, originalroot)
+ end
+
+ def initialize
+ @web_client = nil
+ end
+
+ def import(location, originalroot = nil)
+ unless location.is_a?(URI)
+ location = URI.parse(location)
+ end
+ content = parse(fetch(location), location, originalroot)
+ content.location = location
+ content
+ end
+
+private
+
+ def parse(content, location, originalroot)
+ opt = {
+ :location => location,
+ :originalroot => originalroot
+ }
+ WSDL::XMLSchema::Parser.new(opt).parse(content)
+ end
+
+ def fetch(location)
+ warn("importing: #{location}") if $DEBUG
+ content = nil
+ if location.scheme == 'file' or
+ (location.relative? and FileTest.exist?(location.path))
+ content = File.open(location.path).read
+ elsif location.scheme and location.scheme.size == 1 and
+ FileTest.exist?(location.to_s)
+ # ToDo: remove this ugly workaround for a path with drive letter
+ # (D://foo/bar)
+ content = File.open(location.to_s).read
+ else
+ client = web_client.new(nil, "WSDL4R")
+ client.proxy = ::SOAP::Env::HTTP_PROXY
+ client.no_proxy = ::SOAP::Env::NO_PROXY
+ if opt = ::SOAP::Property.loadproperty(::SOAP::PropertyName)
+ ::SOAP::HTTPConfigLoader.set_options(client,
+ opt["client.protocol.http"])
+ end
+ content = client.get_content(location)
+ end
+ content
+ end
+
+ def web_client
+ @web_client ||= begin
+ require 'http-access2'
+ if HTTPAccess2::VERSION < "2.0"
+ raise LoadError.new("http-access/2.0 or later is required.")
+ end
+ HTTPAccess2::Client
+ rescue LoadError
+ warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
+ require 'soap/netHttpClient'
+ ::SOAP::NetHttpClient
+ end
+ @web_client
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/include.rb b/lib/wsdl/xmlSchema/include.rb
new file mode 100644
index 0000000000..af1ef942bb
--- /dev/null
+++ b/lib/wsdl/xmlSchema/include.rb
@@ -0,0 +1,54 @@
+# WSDL4R - XMLSchema include definition.
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'wsdl/xmlSchema/importer'
+
+
+module WSDL
+module XMLSchema
+
+
+class Include < Info
+ attr_reader :schemalocation
+ attr_reader :content
+
+ def initialize
+ super
+ @schemalocation = nil
+ @content = nil
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when SchemaLocationAttrName
+ @schemalocation = URI.parse(value.source)
+ if @schemalocation.relative?
+ @schemalocation = parent.location + @schemalocation
+ end
+ @content = import(@schemalocation)
+ @schemalocation
+ else
+ nil
+ end
+ end
+
+private
+
+ def import(location)
+ Importer.import(location)
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/length.rb b/lib/wsdl/xmlSchema/length.rb
new file mode 100644
index 0000000000..7f61602da9
--- /dev/null
+++ b/lib/wsdl/xmlSchema/length.rb
@@ -0,0 +1,35 @@
+# WSDL4R - XMLSchema length definition for WSDL.
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Length < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when ValueAttrName
+ value.source
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/parser.rb b/lib/wsdl/xmlSchema/parser.rb
new file mode 100644
index 0000000000..057d9d9b70
--- /dev/null
+++ b/lib/wsdl/xmlSchema/parser.rb
@@ -0,0 +1,166 @@
+# WSDL4R - WSDL XML Instance parser library.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'xsd/ns'
+require 'xsd/charset'
+require 'xsd/datatypes'
+require 'xsd/xmlparser'
+require 'wsdl/xmlSchema/data'
+
+
+module WSDL
+module XMLSchema
+
+
+class Parser
+ include XSD
+
+ class ParseError < Error; end
+ class FormatDecodeError < ParseError; end
+ class UnknownElementError < FormatDecodeError; end
+ class UnknownAttributeError < FormatDecodeError; end
+ class UnexpectedElementError < FormatDecodeError; end
+ class ElementConstraintError < FormatDecodeError; end
+ class AttributeConstraintError < FormatDecodeError; end
+
+private
+
+ class ParseFrame
+ attr_reader :ns
+ attr_reader :name
+ attr_accessor :node
+
+ private
+
+ def initialize(ns, name, node)
+ @ns = ns
+ @name = name
+ @node = node
+ end
+ end
+
+public
+
+ def initialize(opt = {})
+ @parser = XSD::XMLParser.create_parser(self, opt)
+ @parsestack = nil
+ @lastnode = nil
+ @ignored = {}
+ @location = opt[:location]
+ @originalroot = opt[:originalroot]
+ end
+
+ def parse(string_or_readable)
+ @parsestack = []
+ @lastnode = nil
+ @textbuf = ''
+ @parser.do_parse(string_or_readable)
+ @lastnode
+ end
+
+ def charset
+ @parser.charset
+ end
+
+ def start_element(name, attrs)
+ lastframe = @parsestack.last
+ ns = parent = nil
+ if lastframe
+ ns = lastframe.ns.clone_ns
+ parent = lastframe.node
+ else
+ ns = XSD::NS.new
+ parent = nil
+ end
+ attrs = XSD::XMLParser.filter_ns(ns, attrs)
+ node = decode_tag(ns, name, attrs, parent)
+ @parsestack << ParseFrame.new(ns, name, node)
+ end
+
+ def characters(text)
+ lastframe = @parsestack.last
+ if lastframe
+ # Need not to be cloned because character does not have attr.
+ ns = lastframe.ns
+ decode_text(ns, text)
+ else
+ p text if $DEBUG
+ end
+ end
+
+ def end_element(name)
+ lastframe = @parsestack.pop
+ unless name == lastframe.name
+ raise UnexpectedElementError.new("closing element name '#{name}' does not match with opening element '#{lastframe.name}'")
+ end
+ decode_tag_end(lastframe.ns, lastframe.node)
+ @lastnode = lastframe.node
+ end
+
+private
+
+ def decode_tag(ns, name, attrs, parent)
+ o = nil
+ elename = ns.parse(name)
+ if !parent
+ if elename == SchemaName
+ o = Schema.parse_element(elename)
+ o.location = @location
+ else
+ raise UnknownElementError.new("unknown element: #{elename}")
+ end
+ o.root = @originalroot if @originalroot # o.root = o otherwise
+ else
+ if elename == AnnotationName
+ # only the first annotation element is allowed for each element.
+ o = Annotation.new
+ else
+ o = parent.parse_element(elename)
+ end
+ unless o
+ unless @ignored.key?(elename)
+ warn("ignored element: #{elename} of #{parent.class}")
+ @ignored[elename] = elename
+ end
+ o = Documentation.new # which accepts any element.
+ end
+ # node could be a pseudo element. pseudo element has its own parent.
+ o.root = parent.root
+ o.parent = parent if o.parent.nil?
+ end
+ attrs.each do |key, value|
+ attr_ele = ns.parse(key, true)
+ value_ele = ns.parse(value, true)
+ value_ele.source = value # for recovery; value may not be a QName
+ if attr_ele == IdAttrName
+ o.id = value_ele
+ else
+ unless o.parse_attr(attr_ele, value_ele)
+ unless @ignored.key?(attr_ele)
+ warn("ignored attr: #{attr_ele}")
+ @ignored[attr_ele] = attr_ele
+ end
+ end
+ end
+ end
+ o
+ end
+
+ def decode_tag_end(ns, node)
+ node.parse_epilogue
+ end
+
+ def decode_text(ns, text)
+ @textbuf << text
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/pattern.rb b/lib/wsdl/xmlSchema/pattern.rb
new file mode 100644
index 0000000000..f826be4578
--- /dev/null
+++ b/lib/wsdl/xmlSchema/pattern.rb
@@ -0,0 +1,36 @@
+# WSDL4R - XMLSchema pattern definition for WSDL.
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Pattern < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ nil
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when ValueAttrName
+ parent.pattern = /\A#{value.source}\z/n
+ value.source
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/schema.rb b/lib/wsdl/xmlSchema/schema.rb
new file mode 100644
index 0000000000..ec97d07aa5
--- /dev/null
+++ b/lib/wsdl/xmlSchema/schema.rb
@@ -0,0 +1,143 @@
+# WSDL4R - XMLSchema schema definition for WSDL.
+# Copyright (C) 2002, 2003-2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class Schema < Info
+ attr_reader :targetnamespace # required
+ attr_reader :complextypes
+ attr_reader :simpletypes
+ attr_reader :elements
+ attr_reader :attributes
+ attr_reader :imports
+ attr_accessor :attributeformdefault
+ attr_accessor :elementformdefault
+
+ attr_reader :importedschema
+
+ def initialize
+ super
+ @targetnamespace = nil
+ @complextypes = XSD::NamedElements.new
+ @simpletypes = XSD::NamedElements.new
+ @elements = XSD::NamedElements.new
+ @attributes = XSD::NamedElements.new
+ @imports = []
+ @attributeformdefault = "unqualified"
+ @elementformdefault = "unqualified"
+ @importedschema = {}
+ @location = nil
+ @root = self
+ end
+
+ def location
+ @location || (root.nil? ? nil : root.location)
+ end
+
+ def location=(location)
+ @location = location
+ end
+
+ def parse_element(element)
+ case element
+ when ImportName
+ o = Import.new
+ @imports << o
+ o
+ when IncludeName
+ o = Include.new
+ @imports << o
+ o
+ when ComplexTypeName
+ o = ComplexType.new
+ @complextypes << o
+ o
+ when SimpleTypeName
+ o = SimpleType.new
+ @simpletypes << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ when AttributeName
+ o = Attribute.new
+ @attributes << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when TargetNamespaceAttrName
+ @targetnamespace = value.source
+ when AttributeFormDefaultAttrName
+ @attributeformdefault = value.source
+ when ElementFormDefaultAttrName
+ @elementformdefault = value.source
+ else
+ nil
+ end
+ end
+
+ def collect_attributes
+ result = XSD::NamedElements.new
+ result.concat(@attributes)
+ @imports.each do |import|
+ result.concat(import.content.collect_attributes) if import.content
+ end
+ result
+ end
+
+ def collect_elements
+ result = XSD::NamedElements.new
+ result.concat(@elements)
+ @imports.each do |import|
+ result.concat(import.content.collect_elements) if import.content
+ end
+ result
+ end
+
+ def collect_complextypes
+ result = XSD::NamedElements.new
+ result.concat(@complextypes)
+ @imports.each do |import|
+ result.concat(import.content.collect_complextypes) if import.content
+ end
+ result
+ end
+
+ def collect_simpletypes
+ result = XSD::NamedElements.new
+ result.concat(@simpletypes)
+ @imports.each do |import|
+ result.concat(import.content.collect_simpletypes) if import.content
+ end
+ result
+ end
+
+ def self.parse_element(element)
+ if element == SchemaName
+ Schema.new
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/sequence.rb b/lib/wsdl/xmlSchema/sequence.rb
new file mode 100644
index 0000000000..823fa3b7f9
--- /dev/null
+++ b/lib/wsdl/xmlSchema/sequence.rb
@@ -0,0 +1,69 @@
+# WSDL4R - XMLSchema complexType definition for WSDL.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Sequence < Info
+ attr_reader :minoccurs
+ attr_reader :maxoccurs
+ attr_reader :elements
+
+ def initialize
+ super()
+ @minoccurs = '1'
+ @maxoccurs = '1'
+ @elements = []
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def elementformdefault
+ parent.elementformdefault
+ end
+
+ def <<(element)
+ @elements << element
+ end
+
+ def parse_element(element)
+ case element
+ when AnyName
+ o = Any.new
+ @elements << o
+ o
+ when ElementName
+ o = Element.new
+ @elements << o
+ o
+ else
+ nil
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when MaxOccursAttrName
+ @maxoccurs = value.source
+ when MinOccursAttrName
+ @minoccurs = value.source
+ else
+ nil
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/simpleContent.rb b/lib/wsdl/xmlSchema/simpleContent.rb
new file mode 100644
index 0000000000..e1f35c88b8
--- /dev/null
+++ b/lib/wsdl/xmlSchema/simpleContent.rb
@@ -0,0 +1,65 @@
+# WSDL4R - XMLSchema simpleContent definition for WSDL.
+# Copyright (C) 2004, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class SimpleContent < Info
+ attr_reader :restriction
+ attr_reader :extension
+
+ def check_lexical_format(value)
+ check(value)
+ end
+
+ def initialize
+ super
+ @restriction = nil
+ @extension = nil
+ end
+
+ def base
+ content.base
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName
+ @restriction = SimpleRestriction.new
+ @restriction
+ when ExtensionName
+ @extension = SimpleExtension.new
+ @extension
+ end
+ end
+
+private
+
+ def content
+ @restriction || @extension
+ end
+
+ def check(value)
+ unless content.valid?(value)
+ raise XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'")
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/simpleExtension.rb b/lib/wsdl/xmlSchema/simpleExtension.rb
new file mode 100644
index 0000000000..3c53a7328c
--- /dev/null
+++ b/lib/wsdl/xmlSchema/simpleExtension.rb
@@ -0,0 +1,54 @@
+# WSDL4R - XMLSchema simpleType extension definition for WSDL.
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class SimpleExtension < Info
+ attr_reader :base
+ attr_reader :attributes
+
+ def initialize
+ super
+ @base = nil
+ @attributes = XSD::NamedElements.new
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def valid?(value)
+ true
+ end
+
+ def parse_element(element)
+ case element
+ when AttributeName
+ o = Attribute.new
+ @attributes << o
+ o
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when BaseAttrName
+ @base = value
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/simpleRestriction.rb b/lib/wsdl/xmlSchema/simpleRestriction.rb
new file mode 100644
index 0000000000..e8bf3ebfa5
--- /dev/null
+++ b/lib/wsdl/xmlSchema/simpleRestriction.rb
@@ -0,0 +1,73 @@
+# WSDL4R - XMLSchema simpleContent restriction definition for WSDL.
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class SimpleRestriction < Info
+ attr_reader :base
+ attr_reader :enumeration
+ attr_accessor :length
+ attr_accessor :pattern
+
+ def initialize
+ super
+ @base = nil
+ @enumeration = [] # NamedElements?
+ @length = nil
+ @pattern = nil
+ end
+
+ def valid?(value)
+ return false unless check_restriction(value)
+ return false unless check_length(value)
+ return false unless check_pattern(value)
+ true
+ end
+
+ def parse_element(element)
+ case element
+ when EnumerationName
+ Enumeration.new # just a parsing handler
+ when LengthName
+ Length.new # just a parsing handler
+ when PatternName
+ Pattern.new # just a parsing handler
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when BaseAttrName
+ @base = value
+ end
+ end
+
+private
+
+ def check_restriction(value)
+ @enumeration.empty? or @enumeration.include?(value)
+ end
+
+ def check_length(value)
+ @length.nil? or value.size == @length
+ end
+
+ def check_pattern(value)
+ @pattern.nil? or @pattern =~ value
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/simpleType.rb b/lib/wsdl/xmlSchema/simpleType.rb
new file mode 100644
index 0000000000..e808c318c4
--- /dev/null
+++ b/lib/wsdl/xmlSchema/simpleType.rb
@@ -0,0 +1,73 @@
+# WSDL4R - XMLSchema simpleType definition for WSDL.
+# Copyright (C) 2004, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+require 'xsd/namedelements'
+
+
+module WSDL
+module XMLSchema
+
+
+class SimpleType < Info
+ attr_accessor :name
+ attr_reader :restriction
+
+ def check_lexical_format(value)
+ if @restriction
+ check_restriction(value)
+ else
+ raise ArgumentError.new("incomplete simpleType")
+ end
+ end
+
+ def base
+ if @restriction
+ @restriction.base
+ else
+ raise ArgumentError.new("incomplete simpleType")
+ end
+ end
+
+ def initialize(name = nil)
+ super()
+ @name = name
+ @restriction = nil
+ end
+
+ def targetnamespace
+ parent.targetnamespace
+ end
+
+ def parse_element(element)
+ case element
+ when RestrictionName
+ @restriction = SimpleRestriction.new
+ @restriction
+ end
+ end
+
+ def parse_attr(attr, value)
+ case attr
+ when NameAttrName
+ @name = XSD::QName.new(targetnamespace, value.source)
+ end
+ end
+
+private
+
+ def check_restriction(value)
+ unless @restriction.valid?(value)
+ raise XSD::ValueSpaceError.new("#{@name}: cannot accept '#{value}'")
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/unique.rb b/lib/wsdl/xmlSchema/unique.rb
new file mode 100644
index 0000000000..837ff22b4a
--- /dev/null
+++ b/lib/wsdl/xmlSchema/unique.rb
@@ -0,0 +1,34 @@
+# WSDL4R - XMLSchema unique element.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'wsdl/info'
+
+
+module WSDL
+module XMLSchema
+
+
+class Unique < Info
+ def initialize
+ super
+ end
+
+ def parse_element(element)
+ # Accepts any element.
+ self
+ end
+
+ def parse_attr(attr, value)
+ # Accepts any attribute.
+ true
+ end
+end
+
+
+end
+end
diff --git a/lib/wsdl/xmlSchema/xsd2ruby.rb b/lib/wsdl/xmlSchema/xsd2ruby.rb
new file mode 100644
index 0000000000..afe5fc5ada
--- /dev/null
+++ b/lib/wsdl/xmlSchema/xsd2ruby.rb
@@ -0,0 +1,107 @@
+# XSD4R - XSD to ruby mapping library.
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+require 'wsdl/xmlSchema/importer'
+require 'wsdl/soap/classDefCreator'
+
+
+module WSDL
+module XMLSchema
+
+
+class XSD2Ruby
+ attr_accessor :location
+ attr_reader :opt
+ attr_accessor :logger
+ attr_accessor :basedir
+
+ def run
+ unless @location
+ raise RuntimeError, "XML Schema location not given"
+ end
+ @xsd = import(@location)
+ @name = create_classname(@xsd)
+ create_file
+ end
+
+private
+
+ def initialize
+ @location = nil
+ @opt = {}
+ @logger = Logger.new(STDERR)
+ @basedir = nil
+ @xsd = nil
+ @name = nil
+ end
+
+ def create_file
+ create_classdef
+ end
+
+ def create_classdef
+ @logger.info { "Creating class definition." }
+ @classdef_filename = @name + '.rb'
+ check_file(@classdef_filename) or return
+ write_file(@classdef_filename) do |f|
+ f << WSDL::SOAP::ClassDefCreator.new(@xsd).dump
+ end
+ end
+
+ def write_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ File.open(filename, "w") do |f|
+ yield f
+ end
+ end
+
+ def check_file(filename)
+ if @basedir
+ filename = File.join(basedir, filename)
+ end
+ if FileTest.exist?(filename)
+ if @opt.key?('force')
+ @logger.warn {
+ "File '#{filename}' exists but overrides it."
+ }
+ true
+ else
+ @logger.warn {
+ "File '#{filename}' exists. #{$0} did not override it."
+ }
+ false
+ end
+ else
+ @logger.info { "Creates file '#{filename}'." }
+ true
+ end
+ end
+
+ def create_classname(xsd)
+ name = nil
+ if xsd.targetnamespace
+ name = xsd.targetnamespace.scan(/[a-zA-Z0-9]+$/)[0]
+ end
+ if name.nil?
+ 'default'
+ else
+ XSD::CodeGen::GenSupport.safevarname(name)
+ end
+ end
+
+ def import(location)
+ WSDL::XMLSchema::Importer.import(location)
+ end
+end
+
+
+end
+end
diff --git a/lib/xmlrpc/README.rdoc b/lib/xmlrpc/README.rdoc
deleted file mode 100644
index 221d675219..0000000000
--- a/lib/xmlrpc/README.rdoc
+++ /dev/null
@@ -1,300 +0,0 @@
-= XMLRPC for Ruby
-
-== Author and Copyright
-
-Copyright (C) 2001-2004 by Michael Neumann (mailto:mneumann@ntecs.de)
-
-Released under the same term of license as Ruby.
-
-== Overview
-
-XMLRPC is a lightweight protocol that enables remote procedure calls over
-HTTP. It is defined at http://www.xmlrpc.com.
-
-XMLRPC allows you to create simple distributed computing solutions that span
-computer languages. Its distinctive feature is its simplicity compared to
-other approaches like SOAP and CORBA.
-
-The Ruby standard library package 'xmlrpc' enables you to create a server that
-implements remote procedures and a client that calls them. Very little code
-is required to achieve either of these.
-
-== Example
-
-Try the following code. It calls a standard demonstration remote procedure.
-
- require 'xmlrpc/client'
- require 'pp'
-
- server = XMLRPC::Client.new2("http://xmlrpc-c.sourceforge.net/api/sample.php")
- result = server.call("sample.sumAndDifference", 5, 3)
- pp result
-
-== Documentation
-
-See http://www.ntecs.de/projects/xmlrpc4r. There is plenty of detail there to
-use the client and implement a server.
-
-== Features of XMLRPC for Ruby
-
-* Extensions
- * Introspection
- * multiCall
- * optionally nil values and integers larger than 32 Bit
-
-* Server
- * Standalone XML-RPC server
- * CGI-based (works with FastCGI)
- * Apache mod_ruby server
- * WEBrick servlet
-
-* Client
- * synchronous/asynchronous calls
- * Basic HTTP-401 Authentification
- * HTTPS protocol (SSL)
-
-* Parsers
- * NQXML (NQXMLStreamParser, NQXMLTreeParser)
- * Expat (XMLStreamParser, XMLTreeParser)
- * REXML (REXMLStreamParser)
- * xml-scan (XMLScanStreamParser)
- * Fastest parser is Expat's XMLStreamParser!
-
-* General
- * possible to choose between XMLParser module (Expat wrapper) and REXML/NQXML (pure Ruby) parsers
- * Marshalling Ruby objects to Hashs and reconstruct them later from a Hash
- * SandStorm component architecture Client interface
-
-== Howto
-
-=== Client
-
- require "xmlrpc/client"
-
- # Make an object to represent the XML-RPC server.
- server = XMLRPC::Client.new( "xmlrpc-c.sourceforge.net", "/api/sample.php")
-
- # Call the remote server and get our result
- result = server.call("sample.sumAndDifference", 5, 3)
-
- sum = result["sum"]
- difference = result["difference"]
-
- puts "Sum: #{sum}, Difference: #{difference}"
-
-=== Client with XML-RPC fault-structure handling
-
-There are two possible ways, of handling a fault-structure:
-
-==== by catching a XMLRPC::FaultException exception
-
- require "xmlrpc/client"
-
- # Make an object to represent the XML-RPC server.
- server = XMLRPC::Client.new( "xmlrpc-c.sourceforge.net", "/api/sample.php")
-
- begin
- # Call the remote server and get our result
- result = server.call("sample.sumAndDifference", 5, 3)
-
- sum = result["sum"]
- difference = result["difference"]
-
- puts "Sum: #{sum}, Difference: #{difference}"
-
- rescue XMLRPC::FaultException => e
- puts "Error: "
- puts e.faultCode
- puts e.faultString
- end
-
-==== by calling "call2" which returns a boolean
-
- require "xmlrpc/client"
-
- # Make an object to represent the XML-RPC server.
- server = XMLRPC::Client.new( "xmlrpc-c.sourceforge.net", "/api/sample.php")
-
- # Call the remote server and get our result
- ok, result = server.call2("sample.sumAndDifference", 5, 3)
-
- if ok
- sum = result["sum"]
- difference = result["difference"]
-
- puts "Sum: #{sum}, Difference: #{difference}"
- else
- puts "Error: "
- puts result.faultCode
- puts result.faultString
- end
-
-=== Client using Proxy
-
-You can create a +Proxy+ object onto which you can call methods. This way it
-looks nicer. Both forms, _call_ and _call2_ are supported through _proxy_ and
-<i>proxy2</i>. You can additionally give arguments to the Proxy, which will be
-given to each XML-RPC call using that Proxy.
-
- require "xmlrpc/client"
-
- # Make an object to represent the XML-RPC server.
- server = XMLRPC::Client.new( "xmlrpc-c.sourceforge.net", "/api/sample.php")
-
- # Create a Proxy object
- sample = server.proxy("sample")
-
- # Call the remote server and get our result
- result = sample.sumAndDifference(5,3)
-
- sum = result["sum"]
- difference = result["difference"]
-
- puts "Sum: #{sum}, Difference: #{difference}"
-
-=== CGI-based Server
-
-There are also two ways to define handler, the first is
-like C/PHP, the second like Java, of course both ways
-can be mixed:
-
-==== C/PHP-like (handler functions)
-
- require "xmlrpc/server"
-
- s = XMLRPC::CGIServer.new
-
- s.add_handler("sample.sumAndDifference") do |a,b|
- { "sum" => a + b, "difference" => a - b }
- end
-
- s.serve
-
-==== Java-like (handler classes)
-
- require "xmlrpc/server"
-
- s = XMLRPC::CGIServer.new
-
- class MyHandler
- def sumAndDifference(a, b)
- { "sum" => a + b, "difference" => a - b }
- end
- end
-
- # NOTE: Security Hole (read below)!!!
- s.add_handler("sample", MyHandler.new)
- s.serve
-
-
-To return a fault-structure you have to raise an FaultException e.g.:
-
- raise XMLRPC::FaultException.new(3, "division by Zero")
-
-===== Security Note
-
-From Brian Candler:
-
- Above code sample has an extremely nasty security hole, in that you can now call
- any method of 'MyHandler' remotely, including methods inherited from Object
- and Kernel! For example, in the client code, you can use
-
- puts server.call("sample.send","`","ls")
-
- (backtick being the method name for running system processes). Needless to
- say, 'ls' can be replaced with something else.
-
- The version which binds proc objects (or the version presented below in the next section)
- doesn't have this problem, but people may be tempted to use the second version because it's
- so nice and 'Rubyesque'. I think it needs a big red disclaimer.
-
-
-From Michael:
-
-A solution is to undef insecure methods or to use (({XMLRPC::iPIMethods})) as shown below:
-
- class MyHandler
- def sumAndDifference(a, b)
- { "sum" => a + b, "difference" => a - b }
- end
- end
-
- # ... server initialization ...
-
- s.add_handler(XMLRPC::iPIMethods("sample"), MyHandler.new)
-
- # ...
-
-This adds only public instance methods explicitly declared in class MyHandler
-(and not those inherited from any other class).
-
-==== With interface declarations
-
-Code sample from the book Ruby Developer's Guide:
-
- require "xmlrpc/server"
-
- class Num
- INTERFACE = XMLRPC::interface("num") {
- meth 'int add(int, int)', 'Add two numbers', 'add'
- meth 'int div(int, int)', 'Divide two numbers'
- }
-
- def add(a, b) a + b end
- def div(a, b) a / b end
- end
-
-
- s = XMLRPC::CGIServer.new
- s.add_handler(Num::INTERFACE, Num.new)
- s.serve
-
-=== Standalone server
-
-Same as CGI-based server, only that the line
-
- server = XMLRPC::CGIServer.new
-
-must be changed to
-
- server = XMLRPC::Server.new(8080)
-
-if you want a server listening on port 8080.
-The rest is the same.
-
-=== Choosing a different XML Parser or XML Writer
-
-The examples above all use the default parser (which is now since 1.8
-REXMLStreamParser) and a default XML writer. If you want to use a different
-XML parser, then you have to call the <i>set_parser</i> method of
-<tt>XMLRPC::Client</tt> instances or instances of subclasses of
-<tt>XMLRPC::BasicServer</tt> or by editing xmlrpc/config.rb.
-
-Client Example:
-
- # ...
- server = XMLRPC::Client.new( "xmlrpc-c.sourceforge.net", "/api/sample.php")
- server.set_parser(XMLRPC::XMLParser::XMLParser.new)
- # ...
-
-Server Example:
-
- # ...
- s = XMLRPC::CGIServer.new
- s.set_parser(XMLRPC::XMLParser::XMLStreamParser.new)
- # ...
-
-or:
-
- # ...
- server = XMLRPC::Server.new(8080)
- server.set_parser(XMLRPC::XMLParser::NQXMLParser.new)
- # ...
-
-
-Note that XMLStreamParser is incredible faster (and uses less memory) than any
-other parser and scales well for large documents. For example for a 0.5 MB XML
-document with many tags, XMLStreamParser is ~350 (!) times faster than
-NQXMLTreeParser and still ~18 times as fast as XMLTreeParser.
-
-You can change the XML-writer by calling method <i>set_writer</i>.
diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb
index 726945ea39..278855e01d 100644
--- a/lib/xmlrpc/client.rb
+++ b/lib/xmlrpc/client.rb
@@ -565,8 +565,14 @@ module XMLRPC
raise "Wrong size. Was #{data.size}, should be #{expected}"
end
- c = resp["Set-Cookie"]
- @cookie = c if c
+ set_cookies = resp.get_fields("Set-Cookie")
+ if set_cookies and !set_cookies.empty?
+ require 'webrick/cookie'
+ @cookie = set_cookies.collect do |set_cookie|
+ cookie = WEBrick::Cookie.parse_set_cookie(set_cookie)
+ WEBrick::Cookie.new(cookie.name, cookie.value).to_s
+ end.join("; ")
+ end
return data
end
diff --git a/lib/xmlrpc/create.rb b/lib/xmlrpc/create.rb
index 3c2bbd24e6..b5c94254a4 100644
--- a/lib/xmlrpc/create.rb
+++ b/lib/xmlrpc/create.rb
@@ -194,12 +194,12 @@ module XMLRPC
when TrueClass, FalseClass
@writer.tag("boolean", param ? "1" : "0")
- when Symbol
- @writer.tag("string", param.to_s)
-
when String
@writer.tag("string", param)
+ when Symbol
+ @writer.tag("string", param.to_s)
+
when NilClass
if Config::ENABLE_NIL_CREATE
@writer.ele("nil")
diff --git a/lib/xmlrpc/datetime.rb b/lib/xmlrpc/datetime.rb
index f66ef8963a..298263fe8a 100644
--- a/lib/xmlrpc/datetime.rb
+++ b/lib/xmlrpc/datetime.rb
@@ -127,7 +127,7 @@ class DateTime
end
def ==(o)
- self.to_a == Array(o) rescue false
+ Array(self) == Array(o)
end
end
diff --git a/lib/xsd/charset.rb b/lib/xsd/charset.rb
new file mode 100644
index 0000000000..15d5500fce
--- /dev/null
+++ b/lib/xsd/charset.rb
@@ -0,0 +1,187 @@
+# XSD4R - Charset handling library.
+# Copyright (C) 2001, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module XSD
+
+
+module Charset
+ @internal_encoding = $KCODE
+
+ class XSDError < StandardError; end
+ class CharsetError < XSDError; end
+ class UnknownCharsetError < CharsetError; end
+ class CharsetConversionError < CharsetError; end
+
+public
+
+ ###
+ ## Maps
+ #
+ EncodingConvertMap = {}
+ def Charset.init
+ EncodingConvertMap[['UTF8', 'X_ISO8859_1']] =
+ Proc.new { |str| str.unpack('U*').pack('C*') }
+ EncodingConvertMap[['X_ISO8859_1', 'UTF8']] =
+ Proc.new { |str| str.unpack('C*').pack('U*') }
+ begin
+ require 'xsd/iconvcharset'
+ @internal_encoding = 'UTF8'
+ sjtag = (/(mswin|bccwin|mingw|cygwin|emx)/ =~ RUBY_PLATFORM) ? 'cp932' :
+ 'shift_jis'
+ EncodingConvertMap[['UTF8', 'EUC' ]] =
+ Proc.new { |str| IconvCharset.safe_iconv("euc-jp", "utf-8", str) }
+ EncodingConvertMap[['EUC' , 'UTF8']] =
+ Proc.new { |str| IconvCharset.safe_iconv("utf-8", "euc-jp", str) }
+ EncodingConvertMap[['EUC' , 'SJIS']] =
+ Proc.new { |str| IconvCharset.safe_iconv(sjtag, "euc-jp", str) }
+ EncodingConvertMap[['UTF8', 'SJIS']] =
+ Proc.new { |str| IconvCharset.safe_iconv(sjtag, "utf-8", str) }
+ EncodingConvertMap[['SJIS', 'UTF8']] =
+ Proc.new { |str| IconvCharset.safe_iconv("utf-8", sjtag, str) }
+ EncodingConvertMap[['SJIS', 'EUC' ]] =
+ Proc.new { |str| IconvCharset.safe_iconv("euc-jp", sjtag, str) }
+ rescue LoadError
+ begin
+ require 'nkf'
+ EncodingConvertMap[['EUC' , 'SJIS']] =
+ Proc.new { |str| NKF.nkf('-sXm0', str) }
+ EncodingConvertMap[['SJIS', 'EUC' ]] =
+ Proc.new { |str| NKF.nkf('-eXm0', str) }
+ rescue LoadError
+ end
+
+ begin
+ require 'uconv'
+ @internal_encoding = 'UTF8'
+ EncodingConvertMap[['UTF8', 'EUC' ]] = Uconv.method(:u8toeuc)
+ EncodingConvertMap[['UTF8', 'SJIS']] = Uconv.method(:u8tosjis)
+ EncodingConvertMap[['EUC' , 'UTF8']] = Uconv.method(:euctou8)
+ EncodingConvertMap[['SJIS', 'UTF8']] = Uconv.method(:sjistou8)
+ rescue LoadError
+ end
+ end
+ end
+ self.init
+
+ CharsetMap = {
+ 'NONE' => 'us-ascii',
+ 'EUC' => 'euc-jp',
+ 'SJIS' => 'shift_jis',
+ 'UTF8' => 'utf-8',
+ 'X_ISO_8859_1' => 'iso-8859-1',
+ 'X_UNKNOWN' => nil,
+ }
+
+
+ ###
+ ## handlers
+ #
+ def Charset.encoding
+ @internal_encoding
+ end
+
+ def Charset.encoding=(encoding)
+ warn("xsd charset is set to #{encoding}") if $DEBUG
+ @internal_encoding = encoding
+ end
+
+ def Charset.xml_encoding_label
+ charset_label(@internal_encoding)
+ end
+
+ def Charset.encoding_to_xml(str, charset)
+ encoding_conv(str, @internal_encoding, charset_str(charset))
+ end
+
+ def Charset.encoding_from_xml(str, charset)
+ encoding_conv(str, charset_str(charset), @internal_encoding)
+ end
+
+ def Charset.encoding_conv(str, enc_from, enc_to)
+ if enc_from == enc_to or enc_from == 'NONE' or enc_to == 'NONE'
+ str
+ elsif converter = EncodingConvertMap[[enc_from, enc_to]]
+ converter.call(str)
+ else
+ raise CharsetConversionError.new(
+ "Converter not found: #{enc_from} -> #{enc_to}")
+ end
+ end
+
+ def Charset.charset_label(encoding)
+ CharsetMap[encoding.upcase]
+ end
+
+ def Charset.charset_str(label)
+ if CharsetMap.respond_to?(:key)
+ CharsetMap.key(label.downcase) || 'X_UNKNOWN'
+ else
+ CharsetMap.index(label.downcase) || 'X_UNKNOWN'
+ end
+ end
+
+ # us_ascii = '[\x00-\x7F]'
+ us_ascii = '[\x9\xa\xd\x20-\x7F]' # XML 1.0 restricted.
+ USASCIIRegexp = Regexp.new("\\A#{us_ascii}*\\z", nil, "NONE")
+
+ twobytes_euc = '(?:[\x8E\xA1-\xFE][\xA1-\xFE])'
+ threebytes_euc = '(?:\x8F[\xA1-\xFE][\xA1-\xFE])'
+ character_euc = "(?:#{us_ascii}|#{twobytes_euc}|#{threebytes_euc})"
+ EUCRegexp = Regexp.new("\\A#{character_euc}*\\z", nil, "NONE")
+
+ # onebyte_sjis = '[\x00-\x7F\xA1-\xDF]'
+ onebyte_sjis = '[\x9\xa\xd\x20-\x7F\xA1-\xDF]' # XML 1.0 restricted.
+ twobytes_sjis = '(?:[\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC])'
+ character_sjis = "(?:#{onebyte_sjis}|#{twobytes_sjis})"
+ SJISRegexp = Regexp.new("\\A#{character_sjis}*\\z", nil, "NONE")
+
+ # 0xxxxxxx
+ # 110yyyyy 10xxxxxx
+ twobytes_utf8 = '(?:[\xC0-\xDF][\x80-\xBF])'
+ # 1110zzzz 10yyyyyy 10xxxxxx
+ threebytes_utf8 = '(?:[\xE0-\xEF][\x80-\xBF][\x80-\xBF])'
+ # 11110uuu 10uuuzzz 10yyyyyy 10xxxxxx
+ fourbytes_utf8 = '(?:[\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF])'
+ character_utf8 =
+ "(?:#{us_ascii}|#{twobytes_utf8}|#{threebytes_utf8}|#{fourbytes_utf8})"
+ UTF8Regexp = Regexp.new("\\A#{character_utf8}*\\z", nil, "NONE")
+
+ def Charset.is_us_ascii(str)
+ USASCIIRegexp =~ str
+ end
+
+ def Charset.is_utf8(str)
+ UTF8Regexp =~ str
+ end
+
+ def Charset.is_euc(str)
+ EUCRegexp =~ str
+ end
+
+ def Charset.is_sjis(str)
+ SJISRegexp =~ str
+ end
+
+ def Charset.is_ces(str, code = $KCODE)
+ case code
+ when 'NONE'
+ is_us_ascii(str)
+ when 'UTF8'
+ is_utf8(str)
+ when 'EUC'
+ is_euc(str)
+ when 'SJIS'
+ is_sjis(str)
+ else
+ raise UnknownCharsetError.new("Unknown charset: #{code}")
+ end
+ end
+end
+
+
+end
diff --git a/lib/xsd/codegen.rb b/lib/xsd/codegen.rb
new file mode 100644
index 0000000000..d820ebf1f2
--- /dev/null
+++ b/lib/xsd/codegen.rb
@@ -0,0 +1,12 @@
+# XSD4R - Generating code library
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+require 'xsd/codegen/moduledef'
+require 'xsd/codegen/classdef'
+require 'xsd/codegen/methoddef'
diff --git a/lib/xsd/codegen/classdef.rb b/lib/xsd/codegen/classdef.rb
new file mode 100644
index 0000000000..9eb1ce6607
--- /dev/null
+++ b/lib/xsd/codegen/classdef.rb
@@ -0,0 +1,203 @@
+# XSD4R - Generating class definition code
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+require 'xsd/codegen/moduledef'
+require 'xsd/codegen/methoddef'
+
+
+module XSD
+module CodeGen
+
+
+class ClassDef < ModuleDef
+ include GenSupport
+
+ def initialize(name, baseclass = nil)
+ super(name)
+ @baseclass = baseclass
+ @classvar = []
+ @attrdef = []
+ end
+
+ def def_classvar(var, value)
+ var = var.sub(/\A@@/, "")
+ unless safevarname?(var)
+ raise ArgumentError.new("#{var} seems to be unsafe")
+ end
+ @classvar << [var, value]
+ end
+
+ def def_attr(attrname, writable = true, varname = nil)
+ unless safevarname?(varname || attrname)
+ raise ArgumentError.new("#{varname || attrname} seems to be unsafe")
+ end
+ @attrdef << [attrname, writable, varname]
+ end
+
+ def dump
+ buf = ""
+ unless @requirepath.empty?
+ buf << dump_requirepath
+ end
+ buf << dump_emptyline unless buf.empty?
+ package = @name.split(/::/)[0..-2]
+ buf << dump_package_def(package) unless package.empty?
+ buf << dump_comment if @comment
+ buf << dump_class_def
+ spacer = false
+ unless @classvar.empty?
+ spacer = true
+ buf << dump_classvar
+ end
+ unless @const.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_const
+ end
+ unless @code.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_code
+ end
+ unless @attrdef.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_attributes
+ end
+ unless @methoddef.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_methods
+ end
+ buf << dump_class_def_end
+ buf << dump_package_def_end(package) unless package.empty?
+ buf.gsub(/^\s+$/, '')
+ end
+
+private
+
+ def dump_class_def
+ name = @name.to_s.split(/::/)
+ if @baseclass
+ format("class #{name.last} < #{@baseclass}")
+ else
+ format("class #{name.last}")
+ end
+ end
+
+ def dump_class_def_end
+ str = format("end")
+ end
+
+ def dump_classvar
+ dump_static(
+ @classvar.collect { |var, value|
+ %Q(@@#{var.sub(/^@@/, "")} = #{dump_value(value)})
+ }.join("\n")
+ )
+ end
+
+ def dump_attributes
+ str = ""
+ @attrdef.each do |attrname, writable, varname|
+ varname ||= attrname
+ if attrname == varname
+ str << format(dump_accessor(attrname, writable), 2)
+ end
+ end
+ @attrdef.each do |attrname, writable, varname|
+ varname ||= attrname
+ if attrname != varname
+ str << "\n" unless str.empty?
+ str << format(dump_attribute(attrname, writable, varname), 2)
+ end
+ end
+ str
+ end
+
+ def dump_accessor(attrname, writable)
+ if writable
+ "attr_accessor :#{attrname}"
+ else
+ "attr_reader :#{attrname}"
+ end
+ end
+
+ def dump_attribute(attrname, writable, varname)
+ str = nil
+ mr = MethodDef.new(attrname)
+ mr.definition = "@#{varname}"
+ str = mr.dump
+ if writable
+ mw = MethodDef.new(attrname + "=", 'value')
+ mw.definition = "@#{varname} = value"
+ str << "\n" + mw.dump
+ end
+ str
+ end
+end
+
+
+end
+end
+
+
+if __FILE__ == $0
+ require 'xsd/codegen/classdef'
+ include XSD::CodeGen
+ c = ClassDef.new("Foo::Bar::HobbitName", String)
+ c.def_require("foo/bar")
+ c.comment = <<-EOD
+ foo
+ bar
+ baz
+ EOD
+ c.def_const("FOO", 1)
+ c.def_classvar("@@foo", "var".dump)
+ c.def_classvar("baz", "1".dump)
+ c.def_attr("Foo", true, "foo")
+ c.def_attr("bar")
+ c.def_attr("baz", true)
+ c.def_attr("Foo2", true, "foo2")
+ c.def_attr("foo3", false, "foo3")
+ c.def_method("foo") do
+ <<-EOD
+ foo.bar = 1
+\tbaz.each do |ele|
+\t ele
+ end
+ EOD
+ end
+ c.def_method("baz", "qux") do
+ <<-EOD
+ [1, 2, 3].each do |i|
+ p i
+ end
+ EOD
+ end
+
+ m = MethodDef.new("qux", "quxx", "quxxx") do
+ <<-EOD
+ p quxx + quxxx
+ EOD
+ end
+ m.comment = "hello world\n123"
+ c.add_method(m)
+ c.def_code <<-EOD
+ Foo.new
+ Bar.z
+ EOD
+ c.def_code <<-EOD
+ Foo.new
+ Bar.z
+ EOD
+ c.def_privatemethod("foo", "baz", "*arg", "&block")
+
+ puts c.dump
+end
diff --git a/lib/xsd/codegen/commentdef.rb b/lib/xsd/codegen/commentdef.rb
new file mode 100644
index 0000000000..c9493a1363
--- /dev/null
+++ b/lib/xsd/codegen/commentdef.rb
@@ -0,0 +1,34 @@
+# XSD4R - Generating comment definition code
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+
+
+module XSD
+module CodeGen
+
+
+module CommentDef
+ include GenSupport
+
+ attr_accessor :comment
+
+private
+
+ def dump_comment
+ if /\A#/ =~ @comment
+ format(@comment)
+ else
+ format(@comment).gsub(/^/, '# ')
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/xsd/codegen/gensupport.rb b/lib/xsd/codegen/gensupport.rb
new file mode 100644
index 0000000000..1e85d3668f
--- /dev/null
+++ b/lib/xsd/codegen/gensupport.rb
@@ -0,0 +1,166 @@
+# XSD4R - Code generation support
+# Copyright (C) 2004, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module XSD
+module CodeGen
+
+# from the file 'keywords' in 1.9.
+KEYWORD = {}
+%w(
+__LINE__
+__FILE__
+BEGIN
+END
+alias
+and
+begin
+break
+case
+class
+def
+defined?
+do
+else
+elsif
+end
+ensure
+false
+for
+if
+in
+module
+next
+nil
+not
+or
+redo
+rescue
+retry
+return
+self
+super
+then
+true
+undef
+unless
+until
+when
+while
+yield
+).each { |k| KEYWORD[k] = nil }
+
+module GenSupport
+ def capitalize(target)
+ target.sub(/^([a-z])/) { $1.tr!('[a-z]', '[A-Z]') }
+ end
+ module_function :capitalize
+
+ def uncapitalize(target)
+ target.sub(/^([A-Z])/) { $1.tr!('[A-Z]', '[a-z]') }
+ end
+ module_function :uncapitalize
+
+ def safeconstname(name)
+ safename = name.scan(/[a-zA-Z0-9_]+/).collect { |ele|
+ GenSupport.capitalize(ele)
+ }.join
+ if /^[A-Z]/ !~ safename or keyword?(safename)
+ safename = "C_#{safename}"
+ end
+ safename
+ end
+ module_function :safeconstname
+
+ def safeconstname?(name)
+ /\A[A-Z][a-zA-Z0-9_]*\z/ =~ name and !keyword?(name)
+ end
+ module_function :safeconstname?
+
+ def safemethodname(name)
+ safename = name.scan(/[a-zA-Z0-9_]+/).join('_')
+ safename = uncapitalize(safename)
+ if /^[a-z]/ !~ safename
+ safename = "m_#{safename}"
+ end
+ safename
+ end
+ module_function :safemethodname
+
+ def safemethodname?(name)
+ /\A[a-zA-Z_][a-zA-Z0-9_]*[=!?]?\z/ =~ name
+ end
+ module_function :safemethodname?
+
+ def safevarname(name)
+ safename = uncapitalize(name.scan(/[a-zA-Z0-9_]+/).join('_'))
+ if /^[a-z]/ !~ safename or keyword?(safename)
+ "v_#{safename}"
+ else
+ safename
+ end
+ end
+ module_function :safevarname
+
+ def safevarname?(name)
+ /\A[a-z_][a-zA-Z0-9_]*\z/ =~ name and !keyword?(name)
+ end
+ module_function :safevarname?
+
+ def keyword?(word)
+ KEYWORD.key?(word)
+ end
+ module_function :keyword?
+
+ def format(str, indent = nil)
+ str = trim_eol(str)
+ str = trim_indent(str)
+ if indent
+ str.gsub(/^/, " " * indent)
+ else
+ str
+ end
+ end
+
+private
+
+ def trim_eol(str)
+ str.collect { |line|
+ line.sub(/\r?\n\z/, "") + "\n"
+ }.join
+ end
+
+ def trim_indent(str)
+ indent = nil
+ str = str.collect { |line| untab(line) }.join
+ str.each do |line|
+ head = line.index(/\S/)
+ if !head.nil? and (indent.nil? or head < indent)
+ indent = head
+ end
+ end
+ return str unless indent
+ str.collect { |line|
+ line.sub(/^ {0,#{indent}}/, "")
+ }.join
+ end
+
+ def untab(line, ts = 8)
+ while pos = line.index(/\t/)
+ line = line.sub(/\t/, " " * (ts - (pos % ts)))
+ end
+ line
+ end
+
+ def dump_emptyline
+ "\n"
+ end
+end
+
+
+end
+end
diff --git a/lib/xsd/codegen/methoddef.rb b/lib/xsd/codegen/methoddef.rb
new file mode 100644
index 0000000000..15892fc5bf
--- /dev/null
+++ b/lib/xsd/codegen/methoddef.rb
@@ -0,0 +1,63 @@
+# XSD4R - Generating method definition code
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+require 'xsd/codegen/commentdef'
+
+
+module XSD
+module CodeGen
+
+
+class MethodDef
+ include GenSupport
+ include CommentDef
+
+ attr_accessor :definition
+
+ def initialize(name, *params)
+ unless safemethodname?(name)
+ raise ArgumentError.new("name '#{name}' seems to be unsafe")
+ end
+ @name = name
+ @params = params
+ @comment = nil
+ @definition = yield if block_given?
+ end
+
+ def dump
+ buf = ""
+ buf << dump_comment if @comment
+ buf << dump_method_def
+ buf << dump_definition if @definition and !@definition.empty?
+ buf << dump_method_def_end
+ buf
+ end
+
+private
+
+ def dump_method_def
+ if @params.empty?
+ format("def #{@name}")
+ else
+ format("def #{@name}(#{@params.join(", ")})")
+ end
+ end
+
+ def dump_method_def_end
+ format("end")
+ end
+
+ def dump_definition
+ format(@definition, 2)
+ end
+end
+
+
+end
+end
diff --git a/lib/xsd/codegen/moduledef.rb b/lib/xsd/codegen/moduledef.rb
new file mode 100644
index 0000000000..744af2ff97
--- /dev/null
+++ b/lib/xsd/codegen/moduledef.rb
@@ -0,0 +1,191 @@
+# XSD4R - Generating module definition code
+# Copyright (C) 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/codegen/gensupport'
+require 'xsd/codegen/methoddef'
+require 'xsd/codegen/commentdef'
+
+
+module XSD
+module CodeGen
+
+
+class ModuleDef
+ include GenSupport
+ include CommentDef
+
+ def initialize(name)
+ @name = name
+ @comment = nil
+ @const = []
+ @code = []
+ @requirepath = []
+ @methoddef = []
+ end
+
+ def def_require(path)
+ @requirepath << path
+ end
+
+ def def_const(const, value)
+ unless safeconstname?(const)
+ raise ArgumentError.new("#{const} seems to be unsafe")
+ end
+ @const << [const, value]
+ end
+
+ def def_code(code)
+ @code << code
+ end
+
+ def def_method(name, *params)
+ add_method(MethodDef.new(name, *params) { yield if block_given? }, :public)
+ end
+ alias def_publicmethod def_method
+
+ def def_protectedmethod(name, *params)
+ add_method(MethodDef.new(name, *params) { yield if block_given? },
+ :protected)
+ end
+
+ def def_privatemethod(name, *params)
+ add_method(MethodDef.new(name, *params) { yield if block_given? }, :private)
+ end
+
+ def add_method(m, visibility = :public)
+ @methoddef << [visibility, m]
+ end
+
+ def dump
+ buf = ""
+ unless @requirepath.empty?
+ buf << dump_requirepath
+ end
+ buf << dump_emptyline unless buf.empty?
+ package = @name.split(/::/)[0..-2]
+ buf << dump_package_def(package) unless package.empty?
+ buf << dump_comment if @comment
+ buf << dump_module_def
+ spacer = false
+ unless @const.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_const
+ end
+ unless @code.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_code
+ end
+ unless @methoddef.empty?
+ buf << dump_emptyline if spacer
+ spacer = true
+ buf << dump_methods
+ end
+ buf << dump_module_def_end
+ buf << dump_package_def_end(package) unless package.empty?
+ buf.gsub(/^\s+$/, '')
+ end
+
+private
+
+ def dump_requirepath
+ format(
+ @requirepath.collect { |path|
+ %Q(require '#{path}')
+ }.join("\n")
+ )
+ end
+
+ def dump_const
+ dump_static(
+ @const.sort.collect { |var, value|
+ %Q(#{var} = #{dump_value(value)})
+ }.join("\n")
+ )
+ end
+
+ def dump_code
+ dump_static(@code.join("\n"))
+ end
+
+ def dump_static(str)
+ format(str, 2)
+ end
+
+ def dump_methods
+ methods = {}
+ @methoddef.each do |visibility, method|
+ (methods[visibility] ||= []) << method
+ end
+ str = ""
+ [:public, :protected, :private].each do |visibility|
+ if methods[visibility]
+ str << "\n" unless str.empty?
+ str << visibility.to_s << "\n\n" unless visibility == :public
+ str << methods[visibility].collect { |m| format(m.dump, 2) }.join("\n")
+ end
+ end
+ str
+ end
+
+ def dump_value(value)
+ if value.respond_to?(:to_src)
+ value.to_src
+ else
+ value
+ end
+ end
+
+ def dump_package_def(package)
+ format(package.collect { |ele| "module #{ele}" }.join("; ")) + "\n\n"
+ end
+
+ def dump_package_def_end(package)
+ "\n\n" + format(package.collect { |ele| "end" }.join("; "))
+ end
+
+ def dump_module_def
+ name = @name.to_s.split(/::/)
+ format("module #{name.last}")
+ end
+
+ def dump_module_def_end
+ format("end")
+ end
+end
+
+
+end
+end
+
+
+if __FILE__ == $0
+ require 'xsd/codegen/moduledef'
+ include XSD::CodeGen
+ m = ModuleDef.new("Foo::Bar::HobbitName")
+ m.def_require("foo/bar")
+ m.def_require("baz")
+ m.comment = <<-EOD
+ foo
+ bar
+ baz
+ EOD
+ m.def_method("foo") do
+ <<-EOD
+ foo.bar = 1
+ baz.each do |ele|
+ ele + 1
+ end
+ EOD
+ end
+ m.def_method("baz", "qux")
+ #m.def_protectedmethod("aaa")
+ m.def_privatemethod("bbb")
+ puts m.dump
+end
diff --git a/lib/xsd/datatypes.rb b/lib/xsd/datatypes.rb
new file mode 100644
index 0000000000..bbe6c8578f
--- /dev/null
+++ b/lib/xsd/datatypes.rb
@@ -0,0 +1,1269 @@
+# XSD4R - XML Schema Datatype implementation.
+# Copyright (C) 2000, 2001, 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'xsd/charset'
+require 'uri'
+
+
+###
+## XMLSchamaDatatypes general definitions.
+#
+module XSD
+
+
+Namespace = 'http://www.w3.org/2001/XMLSchema'
+InstanceNamespace = 'http://www.w3.org/2001/XMLSchema-instance'
+
+AttrType = 'type'
+NilValue = 'true'
+
+AnyTypeLiteral = 'anyType'
+AnySimpleTypeLiteral = 'anySimpleType'
+NilLiteral = 'nil'
+StringLiteral = 'string'
+BooleanLiteral = 'boolean'
+DecimalLiteral = 'decimal'
+FloatLiteral = 'float'
+DoubleLiteral = 'double'
+DurationLiteral = 'duration'
+DateTimeLiteral = 'dateTime'
+TimeLiteral = 'time'
+DateLiteral = 'date'
+GYearMonthLiteral = 'gYearMonth'
+GYearLiteral = 'gYear'
+GMonthDayLiteral = 'gMonthDay'
+GDayLiteral = 'gDay'
+GMonthLiteral = 'gMonth'
+HexBinaryLiteral = 'hexBinary'
+Base64BinaryLiteral = 'base64Binary'
+AnyURILiteral = 'anyURI'
+QNameLiteral = 'QName'
+
+NormalizedStringLiteral = 'normalizedString'
+#3.3.2 token
+#3.3.3 language
+#3.3.4 NMTOKEN
+#3.3.5 NMTOKENS
+#3.3.6 Name
+#3.3.7 NCName
+#3.3.8 ID
+#3.3.9 IDREF
+#3.3.10 IDREFS
+#3.3.11 ENTITY
+#3.3.12 ENTITIES
+IntegerLiteral = 'integer'
+NonPositiveIntegerLiteral = 'nonPositiveInteger'
+NegativeIntegerLiteral = 'negativeInteger'
+LongLiteral = 'long'
+IntLiteral = 'int'
+ShortLiteral = 'short'
+ByteLiteral = 'byte'
+NonNegativeIntegerLiteral = 'nonNegativeInteger'
+UnsignedLongLiteral = 'unsignedLong'
+UnsignedIntLiteral = 'unsignedInt'
+UnsignedShortLiteral = 'unsignedShort'
+UnsignedByteLiteral = 'unsignedByte'
+PositiveIntegerLiteral = 'positiveInteger'
+
+AttrTypeName = QName.new(InstanceNamespace, AttrType)
+AttrNilName = QName.new(InstanceNamespace, NilLiteral)
+
+AnyTypeName = QName.new(Namespace, AnyTypeLiteral)
+AnySimpleTypeName = QName.new(Namespace, AnySimpleTypeLiteral)
+
+class Error < StandardError; end
+class ValueSpaceError < Error; end
+
+
+###
+## The base class of all datatypes with Namespace.
+#
+class NSDBase
+ @@types = []
+
+ attr_accessor :type
+
+ def self.inherited(klass)
+ @@types << klass
+ end
+
+ def self.types
+ @@types
+ end
+
+ def initialize
+ end
+
+ def init(type)
+ @type = type
+ end
+end
+
+
+###
+## The base class of XSD datatypes.
+#
+class XSDAnySimpleType < NSDBase
+ include XSD
+ Type = QName.new(Namespace, AnySimpleTypeLiteral)
+
+ # @data represents canonical space (ex. Integer: 123).
+ attr_reader :data
+ # @is_nil represents this data is nil or not.
+ attr_accessor :is_nil
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+ # true or raise
+ def check_lexical_format(value)
+ screen_data(value)
+ true
+ end
+
+ # set accepts a string which follows lexical space (ex. String: "+123"), or
+ # an object which follows canonical space (ex. Integer: 123).
+ def set(value)
+ if value.nil?
+ @is_nil = true
+ @data = nil
+ _set(nil)
+ else
+ @is_nil = false
+ _set(screen_data(value))
+ end
+ end
+
+ # to_s creates a string which follows lexical space (ex. String: "123").
+ def to_s()
+ if @is_nil
+ ""
+ else
+ _to_s
+ end
+ end
+
+private
+
+ def init(type, value)
+ super(type)
+ set(value)
+ end
+
+ # raises ValueSpaceError if check failed
+ def screen_data(value)
+ value
+ end
+
+ def _set(value)
+ @data = value
+ end
+
+ def _to_s
+ @data.to_s
+ end
+end
+
+class XSDNil < XSDAnySimpleType
+ Type = QName.new(Namespace, NilLiteral)
+ Value = 'true'
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+end
+
+
+###
+## Primitive datatypes.
+#
+class XSDString < XSDAnySimpleType
+ Type = QName.new(Namespace, StringLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ unless XSD::Charset.is_ces(value, XSD::Charset.encoding)
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ value
+ end
+end
+
+class XSDBoolean < XSDAnySimpleType
+ Type = QName.new(Namespace, BooleanLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ if value.is_a?(String)
+ str = value.strip
+ if str == 'true' || str == '1'
+ true
+ elsif str == 'false' || str == '0'
+ false
+ else
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ else
+ value ? true : false
+ end
+ end
+end
+
+class XSDDecimal < XSDAnySimpleType
+ Type = QName.new(Namespace, DecimalLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+ def nonzero?
+ (@number != '0')
+ end
+
+private
+
+ def screen_data(d)
+ if d.is_a?(String)
+ # Integer("00012") => 10 in Ruby.
+ d.sub!(/^([+\-]?)0*(?=\d)/, "\\1")
+ end
+ screen_data_str(d)
+ end
+
+ def screen_data_str(str)
+ /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ sign = $1 || '+'
+ int_part = $2
+ frac_part = $3
+ int_part = '0' if int_part.empty?
+ frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
+ point = - frac_part.size
+ number = int_part + frac_part
+ # normalize
+ if sign == '+'
+ sign = ''
+ elsif sign == '-'
+ if number == '0'
+ sign = ''
+ end
+ end
+ [sign, point, number]
+ end
+
+ def _set(data)
+ if data.nil?
+ @sign = @point = @number = @data = nil
+ return
+ end
+ @sign, @point, @number = data
+ @data = _to_s
+ @data.freeze
+ end
+
+ # 0.0 -> 0; right?
+ def _to_s
+ str = @number.dup
+ if @point.nonzero?
+ str[@number.size + @point, 0] = '.'
+ end
+ @sign + str
+ end
+end
+
+module FloatConstants
+ NaN = 0.0/0.0
+ POSITIVE_INF = +1.0/0.0
+ NEGATIVE_INF = -1.0/0.0
+ POSITIVE_ZERO = +1.0/POSITIVE_INF
+ NEGATIVE_ZERO = -1.0/POSITIVE_INF
+ MIN_POSITIVE_SINGLE = 2.0 ** -149
+end
+
+class XSDFloat < XSDAnySimpleType
+ include FloatConstants
+ Type = QName.new(Namespace, FloatLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ # "NaN".to_f => 0 in some environment. libc?
+ if value.is_a?(Float)
+ return narrow32bit(value)
+ end
+ str = value.to_s.strip
+ if str == 'NaN'
+ NaN
+ elsif str == 'INF'
+ POSITIVE_INF
+ elsif str == '-INF'
+ NEGATIVE_INF
+ else
+ if /^[+\-\.\deE]+$/ !~ str
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ # Float("-1.4E") might fail on some system.
+ str << '0' if /e$/i =~ str
+ begin
+ return narrow32bit(Float(str))
+ rescue ArgumentError
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ end
+ end
+
+ def _to_s
+ if @data.nan?
+ 'NaN'
+ elsif @data.infinite? == 1
+ 'INF'
+ elsif @data.infinite? == -1
+ '-INF'
+ else
+ sign = XSDFloat.positive?(@data) ? '+' : '-'
+ sign + sprintf("%.10g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
+ end
+ end
+
+ # Convert to single-precision 32-bit floating point value.
+ def narrow32bit(f)
+ if f.nan? || f.infinite?
+ f
+ elsif f.abs < MIN_POSITIVE_SINGLE
+ XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
+ else
+ f
+ end
+ end
+
+ def self.positive?(value)
+ (1 / value) > 0.0
+ end
+end
+
+# Ruby's Float is double-precision 64-bit floating point value.
+class XSDDouble < XSDAnySimpleType
+ include FloatConstants
+ Type = QName.new(Namespace, DoubleLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ # "NaN".to_f => 0 in some environment. libc?
+ if value.is_a?(Float)
+ return value
+ end
+ str = value.to_s.strip
+ if str == 'NaN'
+ NaN
+ elsif str == 'INF'
+ POSITIVE_INF
+ elsif str == '-INF'
+ NEGATIVE_INF
+ else
+ begin
+ return Float(str)
+ rescue ArgumentError
+ # '1.4e' cannot be parsed on some architecture.
+ if /e\z/i =~ str
+ begin
+ return Float(str + '0')
+ rescue ArgumentError
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ else
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ end
+ end
+ end
+
+ def _to_s
+ if @data.nan?
+ 'NaN'
+ elsif @data.infinite? == 1
+ 'INF'
+ elsif @data.infinite? == -1
+ '-INF'
+ else
+ sign = (1 / @data > 0.0) ? '+' : '-'
+ sign + sprintf("%.16g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
+ end
+ end
+end
+
+class XSDDuration < XSDAnySimpleType
+ Type = QName.new(Namespace, DurationLiteral)
+
+ attr_accessor :sign
+ attr_accessor :year
+ attr_accessor :month
+ attr_accessor :day
+ attr_accessor :hour
+ attr_accessor :min
+ attr_accessor :sec
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ /^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ if ($5 and ((!$2 and !$3 and !$4) or (!$6 and !$7 and !$8)))
+ # Should we allow 'PT5S' here?
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ sign = $1
+ year = $2.to_i
+ month = $3.to_i
+ day = $4.to_i
+ hour = $6.to_i
+ min = $7.to_i
+ sec = $8 ? XSDDecimal.new($8) : 0
+ [sign, year, month, day, hour, min, sec]
+ end
+
+ def _set(data)
+ if data.nil?
+ @sign = @year = @month = @day = @hour = @min = @sec = @data = nil
+ return
+ end
+ @sign, @year, @month, @day, @hour, @min, @sec = data
+ @data = _to_s
+ @data.freeze
+ end
+
+ def _to_s
+ str = ''
+ str << @sign if @sign
+ str << 'P'
+ l = ''
+ l << "#{ @year }Y" if @year.nonzero?
+ l << "#{ @month }M" if @month.nonzero?
+ l << "#{ @day }D" if @day.nonzero?
+ r = ''
+ r << "#{ @hour }H" if @hour.nonzero?
+ r << "#{ @min }M" if @min.nonzero?
+ r << "#{ @sec }S" if @sec.nonzero?
+ str << l
+ if l.empty?
+ str << "0D"
+ end
+ unless r.empty?
+ str << "T" << r
+ end
+ str
+ end
+end
+
+
+require 'rational'
+require 'date'
+
+module XSDDateTimeImpl
+ SecInDay = 86400 # 24 * 60 * 60
+
+ def to_obj(klass)
+ if klass == Time
+ to_time
+ elsif klass == Date
+ to_date
+ elsif klass == DateTime
+ to_datetime
+ else
+ nil
+ end
+ end
+
+ def to_time
+ begin
+ if @data.offset * SecInDay == Time.now.utc_offset
+ d = @data
+ usec = (d.sec_fraction * SecInDay * 1000000).round
+ Time.local(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
+ else
+ d = @data.newof
+ usec = (d.sec_fraction * SecInDay * 1000000).round
+ Time.gm(d.year, d.month, d.mday, d.hour, d.min, d.sec, usec)
+ end
+ rescue ArgumentError
+ nil
+ end
+ end
+
+ def to_date
+ Date.new0(@data.class.jd_to_ajd(@data.jd, 0, 0), 0, @data.start)
+ end
+
+ def to_datetime
+ data
+ end
+
+ def tz2of(str)
+ /^(?:Z|(?:([+\-])(\d\d):(\d\d))?)$/ =~ str
+ sign = $1
+ hour = $2.to_i
+ min = $3.to_i
+
+ of = case sign
+ when '+'
+ of = +(hour.to_r * 60 + min) / 1440 # 24 * 60
+ when '-'
+ of = -(hour.to_r * 60 + min) / 1440 # 24 * 60
+ else
+ 0
+ end
+ of
+ end
+
+ def of2tz(offset)
+ diffmin = offset * 24 * 60
+ if diffmin.zero?
+ 'Z'
+ else
+ ((diffmin < 0) ? '-' : '+') << format('%02d:%02d',
+ (diffmin.abs / 60.0).to_i, (diffmin.abs % 60.0).to_i)
+ end
+ end
+
+ def screen_data(t)
+ # convert t to a DateTime as an internal representation.
+ if t.respond_to?(:to_datetime) # 1.9 or later
+ t.to_datetime
+ elsif t.is_a?(DateTime)
+ t
+ elsif t.is_a?(Date)
+ t = screen_data_str(t)
+ t <<= 12 if t.year < 0
+ t
+ elsif t.is_a?(Time)
+ jd = DateTime.civil_to_jd(t.year, t.mon, t.mday, DateTime::ITALY)
+ fr = DateTime.time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
+ t.usec.to_r / 1000000 / SecInDay
+ of = t.utc_offset.to_r / SecInDay
+ DateTime.new0(DateTime.jd_to_ajd(jd, fr, of), of, DateTime::ITALY)
+ else
+ screen_data_str(t)
+ end
+ end
+
+ def add_tz(s)
+ s + of2tz(@data.offset)
+ end
+end
+
+class XSDDateTime < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, DateTimeLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^([+\-]?\d{4,})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ if $1 == '0000'
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ year = $1.to_i
+ if year < 0
+ year += 1
+ end
+ mon = $2.to_i
+ mday = $3.to_i
+ hour = $4.to_i
+ min = $5.to_i
+ sec = $6.to_i
+ secfrac = $7
+ zonestr = $8
+ data = DateTime.civil(year, mon, mday, hour, min, sec, tz2of(zonestr))
+ if secfrac
+ diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
+ data += diffday
+ # FYI: new0 and jd_to_rjd are not necessary to use if you don't have
+ # exceptional reason.
+ end
+ [data, secfrac]
+ end
+
+ def _set(data)
+ if data.nil?
+ @data = @secfrac = nil
+ return
+ end
+ @data, @secfrac = data
+ end
+
+ def _to_s
+ year = (@data.year > 0) ? @data.year : @data.year - 1
+ s = format('%.4d-%02d-%02dT%02d:%02d:%02d',
+ year, @data.mon, @data.mday, @data.hour, @data.min, @data.sec)
+ if @data.sec_fraction.nonzero?
+ if @secfrac
+ s << ".#{ @secfrac }"
+ else
+ s << sprintf("%.16f",
+ (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
+ end
+ end
+ add_tz(s)
+ end
+end
+
+class XSDTime < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, TimeLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^(\d\d):(\d\d):(\d\d(?:\.(\d*))?)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ hour = $1.to_i
+ min = $2.to_i
+ sec = $3.to_i
+ secfrac = $4
+ zonestr = $5
+ data = DateTime.civil(1, 1, 1, hour, min, sec, tz2of(zonestr))
+ if secfrac
+ diffday = secfrac.to_i.to_r / (10 ** secfrac.size) / SecInDay
+ data += diffday
+ end
+ [data, secfrac]
+ end
+
+ def _set(data)
+ if data.nil?
+ @data = @secfrac = nil
+ return
+ end
+ @data, @secfrac = data
+ end
+
+ def _to_s
+ s = format('%02d:%02d:%02d', @data.hour, @data.min, @data.sec)
+ if @data.sec_fraction.nonzero?
+ if @secfrac
+ s << ".#{ @secfrac }"
+ else
+ s << sprintf("%.16f",
+ (@data.sec_fraction * SecInDay).to_f).sub(/^0/, '').sub(/0*$/, '')
+ end
+ end
+ add_tz(s)
+ end
+end
+
+class XSDDate < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, DateLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^([+\-]?\d{4,})-(\d\d)-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ year = $1.to_i
+ if year < 0
+ year += 1
+ end
+ mon = $2.to_i
+ mday = $3.to_i
+ zonestr = $4
+ DateTime.civil(year, mon, mday, 0, 0, 0, tz2of(zonestr))
+ end
+
+ def _to_s
+ year = (@data.year > 0) ? @data.year : @data.year - 1
+ s = format('%.4d-%02d-%02d', year, @data.mon, @data.mday)
+ add_tz(s)
+ end
+end
+
+class XSDGYearMonth < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, GYearMonthLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^([+\-]?\d{4,})-(\d\d)(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ year = $1.to_i
+ if year < 0
+ year += 1
+ end
+ mon = $2.to_i
+ zonestr = $3
+ DateTime.civil(year, mon, 1, 0, 0, 0, tz2of(zonestr))
+ end
+
+ def _to_s
+ year = (@data.year > 0) ? @data.year : @data.year - 1
+ s = format('%.4d-%02d', year, @data.mon)
+ add_tz(s)
+ end
+end
+
+class XSDGYear < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, GYearLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^([+\-]?\d{4,})(Z|(?:([+\-])(\d\d):(\d\d))?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ year = $1.to_i
+ if year < 0
+ year += 1
+ end
+ zonestr = $2
+ DateTime.civil(year, 1, 1, 0, 0, 0, tz2of(zonestr))
+ end
+
+ def _to_s
+ year = (@data.year > 0) ? @data.year : @data.year - 1
+ s = format('%.4d', year)
+ add_tz(s)
+ end
+end
+
+class XSDGMonthDay < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, GMonthDayLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^(\d\d)-(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ mon = $1.to_i
+ mday = $2.to_i
+ zonestr = $3
+ DateTime.civil(1, mon, mday, 0, 0, 0, tz2of(zonestr))
+ end
+
+ def _to_s
+ s = format('%02d-%02d', @data.mon, @data.mday)
+ add_tz(s)
+ end
+end
+
+class XSDGDay < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, GDayLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ mday = $1.to_i
+ zonestr = $2
+ DateTime.civil(1, 1, mday, 0, 0, 0, tz2of(zonestr))
+ end
+
+ def _to_s
+ s = format('%02d', @data.mday)
+ add_tz(s)
+ end
+end
+
+class XSDGMonth < XSDAnySimpleType
+ include XSDDateTimeImpl
+ Type = QName.new(Namespace, GMonthLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(t)
+ /^(\d\d)(Z|(?:[+\-]\d\d:\d\d)?)?$/ =~ t.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ t }'.")
+ end
+ mon = $1.to_i
+ zonestr = $2
+ DateTime.civil(1, mon, 1, 0, 0, 0, tz2of(zonestr))
+ end
+
+ def _to_s
+ s = format('%02d', @data.mon)
+ add_tz(s)
+ end
+end
+
+class XSDHexBinary < XSDAnySimpleType
+ Type = QName.new(Namespace, HexBinaryLiteral)
+
+ # String in Ruby could be a binary.
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+ def set_encoded(value)
+ if /^[0-9a-fA-F]*$/ !~ value
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ @data = String.new(value).strip
+ @is_nil = false
+ end
+
+ def string
+ [@data].pack("H*")
+ end
+
+private
+
+ def screen_data(value)
+ value.unpack("H*")[0].tr('a-f', 'A-F')
+ end
+end
+
+class XSDBase64Binary < XSDAnySimpleType
+ Type = QName.new(Namespace, Base64BinaryLiteral)
+
+ # String in Ruby could be a binary.
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+ def set_encoded(value)
+ if /^[A-Za-z0-9+\/=]*$/ !~ value
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ @data = String.new(value).strip
+ @is_nil = false
+ end
+
+ def string
+ @data.unpack("m")[0]
+ end
+
+private
+
+ def screen_data(value)
+ [value].pack("m").strip
+ end
+end
+
+class XSDAnyURI < XSDAnySimpleType
+ Type = QName.new(Namespace, AnyURILiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ begin
+ URI.parse(value.to_s.strip)
+ rescue URI::InvalidURIError
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ end
+end
+
+class XSDQName < XSDAnySimpleType
+ Type = QName.new(Namespace, QNameLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ /^(?:([^:]+):)?([^:]+)$/ =~ value.to_s.strip
+ unless Regexp.last_match
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ prefix = $1
+ localpart = $2
+ [prefix, localpart]
+ end
+
+ def _set(data)
+ if data.nil?
+ @prefix = @localpart = @data = nil
+ return
+ end
+ @prefix, @localpart = data
+ @data = _to_s
+ @data.freeze
+ end
+
+ def _to_s
+ if @prefix
+ "#{ @prefix }:#{ @localpart }"
+ else
+ "#{ @localpart }"
+ end
+ end
+end
+
+
+###
+## Derived types
+#
+class XSDNormalizedString < XSDString
+ Type = QName.new(Namespace, NormalizedStringLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data(value)
+ if /[\t\r\n]/ =~ value
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
+ end
+ super
+ end
+end
+
+class XSDInteger < XSDDecimal
+ Type = QName.new(Namespace, IntegerLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def screen_data_str(str)
+ begin
+ data = Integer(str)
+ rescue ArgumentError
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ unless validate(data)
+ raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
+ end
+ data
+ end
+
+ def _set(value)
+ @data = value
+ end
+
+ def _to_s()
+ @data.to_s
+ end
+
+ def validate(v)
+ max = maxinclusive
+ min = mininclusive
+ (max.nil? or v <= max) and (min.nil? or v >= min)
+ end
+
+ def maxinclusive
+ nil
+ end
+
+ def mininclusive
+ nil
+ end
+
+ PositiveMinInclusive = 1
+ def positive(v)
+ PositiveMinInclusive <= v
+ end
+end
+
+class XSDNonPositiveInteger < XSDInteger
+ Type = QName.new(Namespace, NonPositiveIntegerLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ 0
+ end
+
+ def mininclusive
+ nil
+ end
+end
+
+class XSDNegativeInteger < XSDNonPositiveInteger
+ Type = QName.new(Namespace, NegativeIntegerLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ -1
+ end
+
+ def mininclusive
+ nil
+ end
+end
+
+class XSDLong < XSDInteger
+ Type = QName.new(Namespace, LongLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +9223372036854775807
+ end
+
+ def mininclusive
+ -9223372036854775808
+ end
+end
+
+class XSDInt < XSDLong
+ Type = QName.new(Namespace, IntLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +2147483647
+ end
+
+ def mininclusive
+ -2147483648
+ end
+end
+
+class XSDShort < XSDInt
+ Type = QName.new(Namespace, ShortLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +32767
+ end
+
+ def mininclusive
+ -32768
+ end
+end
+
+class XSDByte < XSDShort
+ Type = QName.new(Namespace, ByteLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +127
+ end
+
+ def mininclusive
+ -128
+ end
+end
+
+class XSDNonNegativeInteger < XSDInteger
+ Type = QName.new(Namespace, NonNegativeIntegerLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ nil
+ end
+
+ def mininclusive
+ 0
+ end
+end
+
+class XSDUnsignedLong < XSDNonNegativeInteger
+ Type = QName.new(Namespace, UnsignedLongLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +18446744073709551615
+ end
+
+ def mininclusive
+ 0
+ end
+end
+
+class XSDUnsignedInt < XSDUnsignedLong
+ Type = QName.new(Namespace, UnsignedIntLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +4294967295
+ end
+
+ def mininclusive
+ 0
+ end
+end
+
+class XSDUnsignedShort < XSDUnsignedInt
+ Type = QName.new(Namespace, UnsignedShortLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +65535
+ end
+
+ def mininclusive
+ 0
+ end
+end
+
+class XSDUnsignedByte < XSDUnsignedShort
+ Type = QName.new(Namespace, UnsignedByteLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ +255
+ end
+
+ def mininclusive
+ 0
+ end
+end
+
+class XSDPositiveInteger < XSDNonNegativeInteger
+ Type = QName.new(Namespace, PositiveIntegerLiteral)
+
+ def initialize(value = nil)
+ init(Type, value)
+ end
+
+private
+
+ def maxinclusive
+ nil
+ end
+
+ def mininclusive
+ 1
+ end
+end
+
+
+end
diff --git a/lib/xsd/datatypes1999.rb b/lib/xsd/datatypes1999.rb
new file mode 100644
index 0000000000..c7d6479e54
--- /dev/null
+++ b/lib/xsd/datatypes1999.rb
@@ -0,0 +1,20 @@
+# XSD4R - XML Schema Datatype 1999 support
+# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/datatypes'
+
+
+module XSD
+ Namespace.replace('http://www.w3.org/1999/XMLSchema')
+ InstanceNamespace.replace('http://www.w3.org/1999/XMLSchema-instance')
+ AnyTypeLiteral.replace('ur-type')
+ AnySimpleTypeLiteral.replace('ur-type')
+ NilLiteral.replace('null')
+ NilValue.replace('1')
+ DateTimeLiteral.replace('timeInstant')
+end
diff --git a/lib/xsd/iconvcharset.rb b/lib/xsd/iconvcharset.rb
new file mode 100644
index 0000000000..7e629d569b
--- /dev/null
+++ b/lib/xsd/iconvcharset.rb
@@ -0,0 +1,33 @@
+# XSD4R - Charset handling with iconv.
+# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'iconv'
+
+
+module XSD
+
+
+class IconvCharset
+ def self.safe_iconv(to, from, str)
+ iconv = Iconv.new(to, from)
+ out = ""
+ begin
+ out << iconv.iconv(str)
+ rescue Iconv::IllegalSequence => e
+ out << e.success
+ ch, str = e.failed.split(//, 2)
+ out << '?'
+ warn("Failed to convert #{ch}")
+ retry
+ end
+ return out
+ end
+end
+
+
+end
diff --git a/lib/xsd/mapping.rb b/lib/xsd/mapping.rb
new file mode 100644
index 0000000000..06d30d4cbf
--- /dev/null
+++ b/lib/xsd/mapping.rb
@@ -0,0 +1,42 @@
+# XSD4R - XML Mapping for Ruby
+# Copyright (C) 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require "soap/parser"
+require 'soap/encodingstyle/literalHandler'
+require "soap/generator"
+require "soap/mapping"
+require "soap/mapping/wsdlliteralregistry"
+
+
+module XSD
+
+
+module Mapping
+ MappingRegistry = SOAP::Mapping::WSDLLiteralRegistry.new
+ MappingOpt = {:default_encodingstyle => SOAP::LiteralNamespace}
+
+ def self.obj2xml(obj, elename = nil, io = nil)
+ if !elename.nil? and !elename.is_a?(XSD::QName)
+ elename = XSD::QName.new(nil, elename)
+ end
+ elename ||= XSD::QName.new(nil, SOAP::Mapping.name2elename(obj.class.to_s))
+ soap = SOAP::Mapping.obj2soap(obj, MappingRegistry)
+ soap.elename = elename
+ generator = SOAP::SOAPGenerator.new(MappingOpt)
+ generator.generate(soap, io)
+ end
+
+ def self.xml2obj(stream)
+ parser = SOAP::Parser.new(MappingOpt)
+ soap = parser.parse(stream)
+ SOAP::Mapping.soap2obj(soap, MappingRegistry)
+ end
+end
+
+
+end
diff --git a/lib/xsd/namedelements.rb b/lib/xsd/namedelements.rb
new file mode 100644
index 0000000000..a13396bb71
--- /dev/null
+++ b/lib/xsd/namedelements.rb
@@ -0,0 +1,95 @@
+# XSD4R - WSDL named element collection.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module XSD
+
+
+class NamedElements
+ include Enumerable
+
+ def initialize
+ @elements = []
+ @cache = {}
+ end
+
+ def dup
+ o = NamedElements.new
+ o.elements = @elements.dup
+ o
+ end
+
+ def freeze
+ super
+ @elements.freeze
+ self
+ end
+
+ def empty?
+ size == 0
+ end
+
+ def size
+ @elements.size
+ end
+
+ def [](idx)
+ if idx.is_a?(Numeric)
+ @elements[idx]
+ else
+ @cache[idx] ||= @elements.find { |item| item.name == idx }
+ end
+ end
+
+ def find_name(name)
+ @elements.find { |item| item.name.name == name }
+ end
+
+ def keys
+ collect { |element| element.name }
+ end
+
+ def each
+ @elements.each do |element|
+ yield(element)
+ end
+ end
+
+ def <<(rhs)
+ @elements << rhs
+ self
+ end
+
+ def delete(rhs)
+ @elements.delete(rhs)
+ end
+
+ def +(rhs)
+ o = NamedElements.new
+ o.elements = @elements + rhs.elements
+ o
+ end
+
+ def concat(rhs)
+ @elements.concat(rhs.elements)
+ self
+ end
+
+ Empty = NamedElements.new.freeze
+
+protected
+
+ def elements=(rhs)
+ @elements = rhs
+ end
+
+ def elements
+ @elements
+ end
+end
+
+end
diff --git a/lib/xsd/ns.rb b/lib/xsd/ns.rb
new file mode 100644
index 0000000000..53eeae7130
--- /dev/null
+++ b/lib/xsd/ns.rb
@@ -0,0 +1,140 @@
+# XSD4R - XML Schema Namespace library
+# Copyright (C) 2000-2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/datatypes'
+
+
+module XSD
+
+
+class NS
+ class Assigner
+ def initialize
+ @count = 0
+ end
+
+ def assign(ns)
+ @count += 1
+ "n#{@count}"
+ end
+ end
+
+ attr_reader :default_namespace
+
+ class FormatError < Error; end
+
+public
+
+ def initialize(tag2ns = {})
+ @tag2ns = tag2ns
+ @assigner = nil
+ @ns2tag = {}
+ @tag2ns.each do |tag, ns|
+ @ns2tag[ns] = tag
+ end
+ @default_namespace = nil
+ end
+
+ def assign(ns, tag = nil)
+ if (tag == '')
+ @default_namespace = ns
+ tag
+ else
+ @assigner ||= Assigner.new
+ tag ||= @assigner.assign(ns)
+ @ns2tag[ns] = tag
+ @tag2ns[tag] = ns
+ tag
+ end
+ end
+
+ def assigned?(ns)
+ @default_namespace == ns or @ns2tag.key?(ns)
+ end
+
+ def assigned_tag?(tag)
+ @tag2ns.key?(tag)
+ end
+
+ def clone_ns
+ cloned = NS.new(@tag2ns.dup)
+ cloned.assigner = @assigner
+ cloned.assign(@default_namespace, '') if @default_namespace
+ cloned
+ end
+
+ def name(name)
+ if (name.namespace == @default_namespace)
+ name.name
+ elsif @ns2tag.key?(name.namespace)
+ "#{@ns2tag[name.namespace]}:#{name.name}"
+ else
+ raise FormatError.new("namespace: #{name.namespace} not defined yet")
+ end
+ end
+
+ def compare(ns, name, rhs)
+ if (ns == @default_namespace)
+ return true if (name == rhs)
+ end
+ @tag2ns.each do |assigned_tag, assigned_ns|
+ if assigned_ns == ns && "#{assigned_tag}:#{name}" == rhs
+ return true
+ end
+ end
+ false
+ end
+
+ # $1 and $2 are necessary.
+ ParseRegexp = Regexp.new('^([^:]+)(?::(.+))?$')
+
+ def parse(str, local = false)
+ if ParseRegexp =~ str
+ if (name = $2) and (ns = @tag2ns[$1])
+ return XSD::QName.new(ns, name)
+ end
+ end
+ XSD::QName.new(local ? nil : @default_namespace, str)
+ end
+
+ # For local attribute key parsing
+ # <foo xmlns="urn:a" xmlns:n1="urn:a" bar="1" n1:baz="2" />
+ # =>
+ # {}bar, {urn:a}baz
+ def parse_local(elem)
+ ParseRegexp =~ elem
+ if $2
+ ns = @tag2ns[$1]
+ name = $2
+ if !ns
+ raise FormatError.new("unknown namespace qualifier: #{$1}")
+ end
+ elsif $1
+ ns = nil
+ name = $1
+ else
+ raise FormatError.new("illegal element format: #{elem}")
+ end
+ XSD::QName.new(ns, name)
+ end
+
+ def each_ns
+ @ns2tag.each do |ns, tag|
+ yield(ns, tag)
+ end
+ end
+
+protected
+
+ def assigner=(assigner)
+ @assigner = assigner
+ end
+end
+
+
+end
diff --git a/lib/xsd/qname.rb b/lib/xsd/qname.rb
new file mode 100644
index 0000000000..bb9763a69a
--- /dev/null
+++ b/lib/xsd/qname.rb
@@ -0,0 +1,78 @@
+# XSD4R - XML QName definition.
+# Copyright (C) 2002, 2003, 2004 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+module XSD
+
+
+class QName
+ attr_accessor :namespace
+ attr_accessor :name
+ attr_accessor :source
+
+ def initialize(namespace = nil, name = nil)
+ @namespace = namespace
+ @name = name
+ @source = nil
+ end
+
+ def dup_name(name)
+ XSD::QName.new(@namespace, name)
+ end
+
+ def dump
+ ns = @namespace.nil? ? 'nil' : @namespace.dump
+ name = @name.nil? ? 'nil' : @name.dump
+ "XSD::QName.new(#{ns}, #{name})"
+ end
+
+ def match(rhs)
+ if rhs.namespace and (rhs.namespace != @namespace)
+ return false
+ end
+ if rhs.name and (rhs.name != @name)
+ return false
+ end
+ true
+ end
+
+ def ==(rhs)
+ !rhs.nil? and @namespace == rhs.namespace and @name == rhs.name
+ end
+
+ def ===(rhs)
+ (self == rhs)
+ end
+
+ def eql?(rhs)
+ (self == rhs)
+ end
+
+ def hash
+ @namespace.hash ^ @name.hash
+ end
+
+ def to_s
+ "{#{ namespace }}#{ name }"
+ end
+
+ def inspect
+ sprintf("#<%s:0x%x %s>", self.class.name, __id__,
+ "{#{ namespace }}#{ name }")
+ end
+
+ NormalizedNameRegexp = /^\{([^}]*)\}(.*)$/
+ def parse(str)
+ NormalizedNameRegexp =~ str
+ self.new($1, $2)
+ end
+
+ EMPTY = QName.new.freeze
+end
+
+
+end
diff --git a/lib/xsd/xmlparser.rb b/lib/xsd/xmlparser.rb
new file mode 100644
index 0000000000..e79e36c58c
--- /dev/null
+++ b/lib/xsd/xmlparser.rb
@@ -0,0 +1,61 @@
+# XSD4R - XML Instance parser library.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/xmlparser/parser'
+
+
+module XSD
+
+
+module XMLParser
+ def create_parser(host, opt)
+ XSD::XMLParser::Parser.create_parser(host, opt)
+ end
+ module_function :create_parser
+
+ # $1 is necessary.
+ NSParseRegexp = Regexp.new('^xmlns:?(.*)$')
+
+ def filter_ns(ns, attrs)
+ return attrs if attrs.nil? or attrs.empty?
+ newattrs = {}
+ attrs.each do |key, value|
+ if (NSParseRegexp =~ key)
+ # '' means 'default namespace'.
+ tag = $1 || ''
+ ns.assign(value, tag)
+ else
+ newattrs[key] = value
+ end
+ end
+ newattrs
+ end
+ module_function :filter_ns
+end
+
+
+end
+
+
+# Try to load XML processor.
+loaded = false
+[
+ 'xsd/xmlparser/xmlparser',
+ 'xsd/xmlparser/xmlscanner',
+ 'xsd/xmlparser/rexmlparser',
+].each do |lib|
+ begin
+ require lib
+ loaded = true
+ break
+ rescue LoadError
+ end
+end
+unless loaded
+ raise RuntimeError.new("XML processor module not found.")
+end
diff --git a/lib/xsd/xmlparser/parser.rb b/lib/xsd/xmlparser/parser.rb
new file mode 100644
index 0000000000..ad01d55aa0
--- /dev/null
+++ b/lib/xsd/xmlparser/parser.rb
@@ -0,0 +1,96 @@
+# XSD4R - XML Instance parser library.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/qname'
+require 'xsd/ns'
+require 'xsd/charset'
+
+
+module XSD
+module XMLParser
+
+
+class Parser
+ class ParseError < Error; end
+ class FormatDecodeError < ParseError; end
+ class UnknownElementError < FormatDecodeError; end
+ class UnknownAttributeError < FormatDecodeError; end
+ class UnexpectedElementError < FormatDecodeError; end
+ class ElementConstraintError < FormatDecodeError; end
+
+ @@parser_factory = nil
+
+ def self.factory
+ @@parser_factory
+ end
+
+ def self.create_parser(host, opt = {})
+ @@parser_factory.new(host, opt)
+ end
+
+ def self.add_factory(factory)
+ if $DEBUG
+ puts "Set #{ factory } as XML processor."
+ end
+ @@parser_factory = factory
+ end
+
+public
+
+ attr_accessor :charset
+
+ def initialize(host, opt = {})
+ @host = host
+ @charset = opt[:charset] || nil
+ end
+
+ def parse(string_or_readable)
+ @textbuf = ''
+ prologue
+ do_parse(string_or_readable)
+ epilogue
+ end
+
+private
+
+ def do_parse(string_or_readable)
+ raise NotImplementError.new(
+ 'Method do_parse must be defined in derived class.')
+ end
+
+ def start_element(name, attrs)
+ @host.start_element(name, attrs)
+ end
+
+ def characters(text)
+ @host.characters(text)
+ end
+
+ def end_element(name)
+ @host.end_element(name)
+ end
+
+ def prologue
+ end
+
+ def epilogue
+ end
+
+ def xmldecl_encoding=(charset)
+ if @charset.nil?
+ @charset = charset
+ else
+ # Definition in a stream (like HTTP) has a priority.
+ p "encoding definition: #{ charset } is ignored." if $DEBUG
+ end
+ end
+end
+
+
+end
+end
diff --git a/lib/xsd/xmlparser/rexmlparser.rb b/lib/xsd/xmlparser/rexmlparser.rb
new file mode 100644
index 0000000000..61da9aafc7
--- /dev/null
+++ b/lib/xsd/xmlparser/rexmlparser.rb
@@ -0,0 +1,54 @@
+# XSD4R - REXMLParser XML parser library.
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/xmlparser'
+require 'rexml/streamlistener'
+require 'rexml/document'
+
+
+module XSD
+module XMLParser
+
+
+class REXMLParser < XSD::XMLParser::Parser
+ include REXML::StreamListener
+
+ def do_parse(string_or_readable)
+ source = nil
+ source = REXML::SourceFactory.create_from(string_or_readable)
+ source.encoding = charset if charset
+ # Listener passes a String in utf-8.
+ @charset = 'utf-8'
+ REXML::Document.parse_stream(source, self)
+ end
+
+ def epilogue
+ end
+
+ def tag_start(name, attrs)
+ start_element(name, attrs)
+ end
+
+ def tag_end(name)
+ end_element(name)
+ end
+
+ def text(text)
+ characters(text)
+ end
+
+ def xmldecl(version, encoding, standalone)
+ # Version should be checked.
+ end
+
+ add_factory(self)
+end
+
+
+end
+end
diff --git a/lib/xsd/xmlparser/xmlparser.rb b/lib/xsd/xmlparser/xmlparser.rb
new file mode 100644
index 0000000000..6db914cd37
--- /dev/null
+++ b/lib/xsd/xmlparser/xmlparser.rb
@@ -0,0 +1,50 @@
+# XSD4R - XMLParser XML parser library.
+# Copyright (C) 2001, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/xmlparser'
+require 'xml/parser'
+
+
+module XSD
+module XMLParser
+
+
+class XMLParser < XSD::XMLParser::Parser
+ class Listener < XML::Parser
+ begin
+ require 'xml/encoding-ja'
+ include XML::Encoding_ja
+ rescue LoadError
+ # uconv may not be installed.
+ end
+ end
+
+ def do_parse(string_or_readable)
+ # XMLParser passes a String in utf-8.
+ @charset = 'utf-8'
+ @parser = Listener.new
+ @parser.parse(string_or_readable) do |type, name, data|
+ case type
+ when XML::Parser::START_ELEM
+ start_element(name, data)
+ when XML::Parser::END_ELEM
+ end_element(name)
+ when XML::Parser::CDATA
+ characters(data)
+ else
+ raise FormatDecodeError.new("Unexpected XML: #{ type }/#{ name }/#{ data }.")
+ end
+ end
+ end
+
+ add_factory(self)
+end
+
+
+end
+end
diff --git a/lib/xsd/xmlparser/xmlscanner.rb b/lib/xsd/xmlparser/xmlscanner.rb
new file mode 100644
index 0000000000..c80dc23910
--- /dev/null
+++ b/lib/xsd/xmlparser/xmlscanner.rb
@@ -0,0 +1,147 @@
+# XSD4R - XMLScan XML parser library.
+# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+require 'xsd/xmlparser'
+require 'xmlscan/scanner'
+
+
+module XSD
+module XMLParser
+
+
+class XMLScanner < XSD::XMLParser::Parser
+ include XMLScan::Visitor
+
+ def do_parse(string_or_readable)
+ @attrs = {}
+ @curattr = nil
+ @scanner = XMLScan::XMLScanner.new(self)
+ @scanner.kcode = XSD::Charset.charset_str(charset) if charset
+ @scanner.parse(string_or_readable)
+ end
+
+ def scanner_kcode=(charset)
+ @scanner.kcode = XSD::Charset.charset_str(charset) if charset
+ self.xmldecl_encoding = charset
+ end
+
+ ENTITY_REF_MAP = {
+ 'lt' => '<',
+ 'gt' => '>',
+ 'amp' => '&',
+ 'quot' => '"',
+ 'apos' => '\''
+ }
+
+ def parse_error(msg)
+ raise ParseError.new(msg)
+ end
+
+ def wellformed_error(msg)
+ raise NotWellFormedError.new(msg)
+ end
+
+ def valid_error(msg)
+ raise NotValidError.new(msg)
+ end
+
+ def warning(msg)
+ p msg if $DEBUG
+ end
+
+ # def on_xmldecl; end
+
+ def on_xmldecl_version(str)
+ # 1.0 expected.
+ end
+
+ def on_xmldecl_encoding(str)
+ self.scanner_kcode = str
+ end
+
+ # def on_xmldecl_standalone(str); end
+
+ # def on_xmldecl_other(name, value); end
+
+ # def on_xmldecl_end; end
+
+ # def on_doctype(root, pubid, sysid); end
+
+ # def on_prolog_space(str); end
+
+ # def on_comment(str); end
+
+ # def on_pi(target, pi); end
+
+ def on_chardata(str)
+ characters(str)
+ end
+
+ # def on_cdata(str); end
+
+ def on_etag(name)
+ end_element(name)
+ end
+
+ def on_entityref(ref)
+ characters(ENTITY_REF_MAP[ref])
+ end
+
+ def on_charref(code)
+ characters([code].pack('U'))
+ end
+
+ def on_charref_hex(code)
+ on_charref(code)
+ end
+
+ # def on_start_document; end
+
+ # def on_end_document; end
+
+ def on_stag(name)
+ @attrs = {}
+ end
+
+ def on_attribute(name)
+ @attrs[name] = @curattr = ''
+ end
+
+ def on_attr_value(str)
+ @curattr << str
+ end
+
+ def on_attr_entityref(ref)
+ @curattr << ENTITY_REF_MAP[ref]
+ end
+
+ def on_attr_charref(code)
+ @curattr << [code].pack('U')
+ end
+
+ def on_attr_charref_hex(code)
+ on_attr_charref(code)
+ end
+
+ # def on_attribute_end(name); end
+
+ def on_stag_end_empty(name)
+ on_stag_end(name)
+ on_etag(name)
+ end
+
+ def on_stag_end(name)
+ start_element(name, @attrs)
+ end
+
+ add_factory(self)
+end
+
+
+end
+end
diff --git a/lib/yaml/baseemitter.rb b/lib/yaml/baseemitter.rb
index 1aef152749..a1992f498b 100644
--- a/lib/yaml/baseemitter.rb
+++ b/lib/yaml/baseemitter.rb
@@ -132,7 +132,7 @@ module YAML
# Folding paragraphs within a column
#
def fold( value )
- value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]|\Z))|$)/ ) do |s|
+ value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]|\Z))|$)/ ) do
$1 || $2 + ( $3 || "\n" )
end
end
diff --git a/lib/yaml/encoding.rb b/lib/yaml/encoding.rb
index 37f5cfda64..57dc553606 100644
--- a/lib/yaml/encoding.rb
+++ b/lib/yaml/encoding.rb
@@ -10,8 +10,8 @@ module YAML
def YAML.escape( value, skip = "" )
value.gsub( /\\/, "\\\\\\" ).
gsub( /"/, "\\\"" ).
- gsub( /([\x00-\x1f])/ ) do |x|
- skip[x] || ESCAPES[ x.unpack("C")[0] ]
+ gsub( /([\x00-\x1f])/ ) do
+ skip[$&] || ESCAPES[ $&.unpack("C")[0] ]
end
end
@@ -19,7 +19,7 @@ module YAML
# Unescape the condenses escapes
#
def YAML.unescape( value )
- value.gsub( /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ ) { |x|
+ value.gsub( /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ ) {
if $3
["#$3".hex ].pack('U*')
elsif $2
diff --git a/lib/yaml/store.rb b/lib/yaml/store.rb
index 2ffa9554b9..e3a8e9fcdd 100644
--- a/lib/yaml/store.rb
+++ b/lib/yaml/store.rb
@@ -20,10 +20,24 @@ class YAML::Store < PStore
end
def load(content)
- YAML::load(content)
+ table = YAML::load(content)
+ if table == false
+ {}
+ else
+ table
+ end
+ end
+
+ def marshal_dump_supports_canonical_option?
+ false
end
- def load_file(file)
- YAML::load(file)
+ EMPTY_MARSHAL_DATA = {}.to_yaml
+ EMPTY_MARSHAL_CHECKSUM = Digest::MD5.digest(EMPTY_MARSHAL_DATA)
+ def empty_marshal_data
+ EMPTY_MARSHAL_DATA
+ end
+ def empty_marshal_checksum
+ EMPTY_MARSHAL_CHECKSUM
end
end
diff --git a/load.c b/load.c
deleted file mode 100644
index 541e6c81bc..0000000000
--- a/load.c
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * load methods from eval.c
- */
-
-#include "eval_intern.h"
-
-VALUE ruby_dln_librefs;
-
-#define IS_RBEXT(e) (strcmp(e, ".rb") == 0)
-#define IS_SOEXT(e) (strcmp(e, ".so") == 0 || strcmp(e, ".o") == 0)
-#ifdef DLEXT2
-#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0 || strcmp(e, DLEXT2) == 0)
-#else
-#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0)
-#endif
-
-
-static const char *const loadable_ext[] = {
- ".rb", DLEXT,
-#ifdef DLEXT2
- DLEXT2,
-#endif
- 0
-};
-
-VALUE rb_load_path; /* to be moved to VM */
-static VALUE
-get_load_path(void)
-{
- VALUE load_path = rb_load_path;
- VALUE ary = rb_ary_new2(RARRAY_LEN(load_path));
- long i;
-
- for (i = 0; i < RARRAY_LEN(load_path); ++i) {
- rb_ary_push(ary, rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil));
- }
- return ary;
-}
-
-static VALUE
-get_loaded_features(void)
-{
- return GET_VM()->loaded_features;
-}
-
-static st_table *
-get_loading_table(void)
-{
- return GET_VM()->loading_table;
-}
-
-static VALUE
-loaded_feature_path(const char *name, long vlen, const char *feature, long len,
- int type, VALUE load_path)
-{
- long i;
-
- for (i = 0; i < RARRAY_LEN(load_path); ++i) {
- VALUE p = RARRAY_PTR(load_path)[i];
- const char *s = StringValuePtr(p);
- long n = RSTRING_LEN(p);
-
- if (vlen < n + len + 1) continue;
- if (n && (strncmp(name, s, n) || name[n] != '/')) continue;
- if (strncmp(name + n + 1, feature, len)) continue;
- if (name[n+len+1] && name[n+len+1] != '.') continue;
- switch (type) {
- case 's':
- if (IS_DLEXT(&name[n+len+1])) return p;
- break;
- case 'r':
- if (IS_RBEXT(&name[n+len+1])) return p;
- break;
- default:
- return p;
- }
- }
- return 0;
-}
-
-struct loaded_feature_searching {
- const char *name;
- long len;
- int type;
- VALUE load_path;
- const char *result;
-};
-
-static int
-loaded_feature_path_i(st_data_t v, st_data_t b, st_data_t f)
-{
- const char *s = (const char *)v;
- struct loaded_feature_searching *fp = (struct loaded_feature_searching *)f;
- VALUE p = loaded_feature_path(s, strlen(s), fp->name, fp->len,
- fp->type, fp->load_path);
- if (!p) return ST_CONTINUE;
- fp->result = s;
- return ST_STOP;
-}
-
-static int
-rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const char **fn)
-{
- VALUE v, features, p, load_path = 0;
- const char *f, *e;
- long i, len, elen, n;
- st_table *loading_tbl;
- st_data_t data;
- int type;
-
- if (fn) *fn = 0;
- if (ext) {
- len = ext - feature;
- elen = strlen(ext);
- type = rb ? 'r' : 's';
- }
- else {
- len = strlen(feature);
- elen = 0;
- type = 0;
- }
- features = get_loaded_features();
- for (i = 0; i < RARRAY_LEN(features); ++i) {
- v = RARRAY_PTR(features)[i];
- f = StringValuePtr(v);
- if ((n = RSTRING_LEN(v)) < len) continue;
- if (strncmp(f, feature, len) != 0) {
- if (expanded) continue;
- if (!load_path) load_path = get_load_path();
- if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
- continue;
- f += RSTRING_LEN(p) + 1;
- }
- if (!*(e = f + len)) {
- if (ext) continue;
- return 'u';
- }
- if (*e != '.') continue;
- if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
- return 's';
- }
- if ((rb || !ext) && (IS_RBEXT(e))) {
- return 'r';
- }
- }
- loading_tbl = get_loading_table();
- if (loading_tbl) {
- f = 0;
- if (!expanded) {
- struct loaded_feature_searching fs;
- fs.name = feature;
- fs.len = len;
- fs.type = type;
- fs.load_path = load_path ? load_path : get_load_path();
- fs.result = 0;
- st_foreach(loading_tbl, loaded_feature_path_i, (st_data_t)&fs);
- if ((f = fs.result) != 0) {
- if (fn) *fn = f;
- goto loading;
- }
- }
- if (st_get_key(loading_tbl, (st_data_t)feature, &data)) {
- if (fn) *fn = (const char*)data;
- loading:
- if (!ext) return 'u';
- return !IS_RBEXT(ext) ? '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_get_key(loading_tbl, (st_data_t)buf, &data)) {
- if (fn) *fn = (const char*)data;
- return i ? 's' : 'r';
- }
- }
- }
- }
- return 0;
-}
-
-int
-rb_provided(const char *feature)
-{
- const char *ext = strrchr(feature, '.');
-
- if (ext && !strchr(ext, '/')) {
- if (IS_RBEXT(ext)) {
- if (rb_feature_p(feature, ext, Qtrue, Qfalse, 0)) return Qtrue;
- return Qfalse;
- }
- else if (IS_SOEXT(ext) || IS_DLEXT(ext)) {
- if (rb_feature_p(feature, ext, Qfalse, Qfalse, 0)) return Qtrue;
- return Qfalse;
- }
- }
- if (rb_feature_p(feature, feature + strlen(feature), Qtrue, Qfalse, 0))
- return Qtrue;
- return Qfalse;
-}
-
-static void
-rb_provide_feature(VALUE feature)
-{
- rb_ary_push(get_loaded_features(), feature);
-}
-
-void
-rb_provide(const char *feature)
-{
- rb_provide_feature(rb_str_new2(feature));
-}
-
-NORETURN(static void load_failed(VALUE));
-
-void
-rb_load(VALUE fname, int wrap)
-{
- VALUE tmp;
- int state;
- rb_thread_t *th = GET_THREAD();
- volatile VALUE wrapper = th->top_wrapper;
- volatile VALUE self = th->top_self;
- volatile int parse_in_eval;
- volatile int loaded = Qfalse;
-#ifndef __GNUC__
- rb_thread_t *volatile th0 = th;
-#endif
-
- FilePathValue(fname);
- fname = rb_str_new4(fname);
- tmp = rb_find_file(fname);
- if (!tmp) {
- load_failed(fname);
- }
- RB_GC_GUARD(fname) = rb_str_new4(tmp);
-
- th->errinfo = Qnil; /* ensure */
-
- if (!wrap) {
- rb_secure(4); /* should alter global state */
- th->top_wrapper = 0;
- }
- else {
- /* load in anonymous module as toplevel */
- th->top_self = rb_obj_clone(rb_vm_top_self());
- th->top_wrapper = rb_module_new();
- rb_extend_object(th->top_self, th->top_wrapper);
- }
-
- parse_in_eval = th->parse_in_eval;
- PUSH_TAG();
- state = EXEC_TAG();
- if (state == 0) {
- NODE *node;
- VALUE iseq;
-
- th->parse_in_eval++;
- node = (NODE *)rb_load_file(RSTRING_PTR(fname));
- th->parse_in_eval--;
- loaded = Qtrue;
- iseq = rb_iseq_new(node, rb_str_new2("<top (required)>"),
- fname, Qfalse, ISEQ_TYPE_TOP);
- rb_iseq_eval(iseq);
- }
- POP_TAG();
-
-#ifndef __GNUC__
- th = th0;
- fname = RB_GC_GUARD(fname);
-#endif
- th->parse_in_eval = parse_in_eval;
- th->top_self = self;
- th->top_wrapper = wrapper;
-
- if (!loaded) {
- rb_exc_raise(GET_THREAD()->errinfo);
- }
- if (state) {
- vm_jump_tag_but_local_jump(state, Qundef);
- }
-
- if (!NIL_P(GET_THREAD()->errinfo)) {
- /* exception during load */
- rb_exc_raise(th->errinfo);
- }
-}
-
-void
-rb_load_protect(VALUE fname, int wrap, int *state)
-{
- int status;
-
- PUSH_TAG();
- if ((status = EXEC_TAG()) == 0) {
- rb_load(fname, wrap);
- }
- POP_TAG();
- if (state)
- *state = status;
-}
-
-/*
- * call-seq:
- * load(filename, wrap=false) => true
- *
- * Loads and executes the Ruby
- * program in the file _filename_. If the filename does not
- * resolve to an absolute path, the file is searched for in the library
- * directories listed in <code>$:</code>. If the optional _wrap_
- * parameter is +true+, the loaded script will be executed
- * under an anonymous module, protecting the calling program's global
- * namespace. In no circumstance will any local variables in the loaded
- * file be propagated to the loading environment.
- */
-
-static VALUE
-rb_f_load(int argc, VALUE *argv)
-{
- VALUE fname, wrap;
-
- rb_scan_args(argc, argv, "11", &fname, &wrap);
- rb_load(fname, RTEST(wrap));
- return Qtrue;
-}
-
-static char *
-load_lock(const char *ftptr)
-{
- st_data_t data;
- st_table *loading_tbl = get_loading_table();
-
- if (!loading_tbl || !st_lookup(loading_tbl, (st_data_t)ftptr, &data)) {
- /* loading ruby library should be serialized. */
- if (!loading_tbl) {
- GET_VM()->loading_table = loading_tbl = st_init_strtable();
- }
- /* partial state */
- ftptr = ruby_strdup(ftptr);
- data = (st_data_t)rb_barrier_new();
- st_insert(loading_tbl, (st_data_t)ftptr, data);
- return (char *)ftptr;
- }
- return RTEST(rb_barrier_wait((VALUE)data)) ? (char *)ftptr : 0;
-}
-
-static void
-load_unlock(const char *ftptr)
-{
- if (ftptr) {
- st_data_t key = (st_data_t)ftptr;
- st_data_t data;
- st_table *loading_tbl = get_loading_table();
-
- if (st_delete(loading_tbl, &key, &data)) {
- free((char *)key);
- rb_barrier_release((VALUE)data);
- }
- }
-}
-
-
-/*
- * call-seq:
- * require(string) => true or false
- *
- * Ruby tries to load the library named _string_, returning
- * +true+ if successful. If the filename does not resolve to
- * an absolute path, it will be searched for in the directories listed
- * in <code>$:</code>. If the file has the extension ``.rb'', it is
- * loaded as a source file; if the extension is ``.so'', ``.o'', or
- * ``.dll'', or whatever the default shared library extension is on
- * the current platform, Ruby loads the shared library as a Ruby
- * extension. Otherwise, Ruby tries adding ``.rb'', ``.so'', and so on
- * to the name. The name of the loaded feature is added to the array in
- * <code>$"</code>. A feature will not be loaded if it's name already
- * appears in <code>$"</code>. However, the file name is not converted
- * to an absolute path, so that ``<code>require 'a';require
- * './a'</code>'' will load <code>a.rb</code> twice.
- *
- * require "my-library.rb"
- * require "db-driver"
- */
-
-VALUE
-rb_f_require(VALUE obj, VALUE fname)
-{
- return rb_require_safe(fname, rb_safe_level());
-}
-
-static int
-search_required(VALUE fname, volatile VALUE *path)
-{
- VALUE tmp;
- char *ext, *ftptr;
- int type, ft = 0;
- const char *loading;
-
- *path = 0;
- ext = strrchr(ftptr = RSTRING_PTR(fname), '.');
- if (ext && !strchr(ext, '/')) {
- if (IS_RBEXT(ext)) {
- if (rb_feature_p(ftptr, ext, Qtrue, Qfalse, &loading)) {
- if (loading) *path = rb_str_new2(loading);
- return 'r';
- }
- if ((tmp = rb_find_file(fname)) != 0) {
- tmp = rb_file_expand_path(tmp, Qnil);
- ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(ftptr, ext, Qtrue, Qtrue, 0))
- *path = tmp;
- return 'r';
- }
- return 0;
- }
- else if (IS_SOEXT(ext)) {
- if (rb_feature_p(ftptr, ext, Qfalse, Qfalse, &loading)) {
- if (loading) *path = rb_str_new2(loading);
- return 's';
- }
- tmp = rb_str_new(RSTRING_PTR(fname), ext - RSTRING_PTR(fname));
-#ifdef DLEXT2
- OBJ_FREEZE(tmp);
- if (rb_find_file_ext(&tmp, loadable_ext + 1)) {
- tmp = rb_file_expand_path(tmp, Qnil);
- ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, 0))
- *path = tmp;
- return 's';
- }
-#else
- rb_str_cat2(tmp, DLEXT);
- OBJ_FREEZE(tmp);
- if ((tmp = rb_find_file(tmp)) != 0) {
- tmp = rb_file_expand_path(tmp, Qnil);
- ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, 0))
- *path = tmp;
- return 's';
- }
-#endif
- }
- else if (IS_DLEXT(ext)) {
- if (rb_feature_p(ftptr, ext, Qfalse, Qfalse, &loading)) {
- if (loading) *path = rb_str_new2(loading);
- return 's';
- }
- if ((tmp = rb_find_file(fname)) != 0) {
- tmp = rb_file_expand_path(tmp, Qnil);
- ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (!rb_feature_p(ftptr, ext, Qfalse, Qtrue, 0))
- *path = tmp;
- return 's';
- }
- }
- }
- else if ((ft = rb_feature_p(ftptr, 0, Qfalse, Qfalse, &loading)) == 'r') {
- if (loading) *path = rb_str_new2(loading);
- return 'r';
- }
- tmp = fname;
- type = rb_find_file_ext(&tmp, loadable_ext);
- tmp = rb_file_expand_path(tmp, Qnil);
- switch (type) {
- case 0:
- if (ft)
- break;
- ftptr = RSTRING_PTR(tmp);
- return rb_feature_p(ftptr, 0, Qfalse, Qtrue, 0);
-
- default:
- if (ft)
- break;
- case 1:
- ext = strrchr(ftptr = RSTRING_PTR(tmp), '.');
- if (rb_feature_p(ftptr, ext, !--type, Qtrue, &loading) && !loading)
- break;
- *path = tmp;
- }
- return type ? 's' : 'r';
-}
-
-static void
-load_failed(VALUE fname)
-{
- rb_raise(rb_eLoadError, "no such file to load -- %s",
- RSTRING_PTR(fname));
-}
-
-static VALUE
-load_ext(VALUE path)
-{
- SCOPE_SET(NOEX_PUBLIC);
- return (VALUE)dln_load(RSTRING_PTR(path));
-}
-
-VALUE
-rb_require_safe(VALUE fname, int safe)
-{
- VALUE result = Qnil;
- rb_thread_t *th = GET_THREAD();
- volatile VALUE errinfo = th->errinfo;
- int state;
- struct {
- int safe;
- } volatile saved;
- char *volatile ftptr = 0;
-
- FilePathValue(fname);
- RB_GC_GUARD(fname) = rb_str_new4(fname);
- PUSH_TAG();
- saved.safe = rb_safe_level();
- if ((state = EXEC_TAG()) == 0) {
- VALUE path;
- long handle;
- int found;
-
- rb_set_safe_level_force(safe);
- found = search_required(fname, &path);
- if (found) {
- if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
- result = Qfalse;
- }
- else {
- rb_set_safe_level_force(0);
- switch (found) {
- case 'r':
- rb_load(path, 0);
- break;
-
- case 's':
- handle = (long)rb_vm_call_cfunc(rb_vm_top_self(), load_ext,
- path, 0, path);
- rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
- break;
- }
- rb_provide_feature(path);
- result = Qtrue;
- }
- }
- }
- POP_TAG();
- load_unlock(ftptr);
-
- rb_set_safe_level_force(saved.safe);
- if (state) {
- JUMP_TAG(state);
- }
-
- if (NIL_P(result)) {
- load_failed(fname);
- }
-
- th->errinfo = errinfo;
-
- return result;
-}
-
-VALUE
-rb_require(const char *fname)
-{
- VALUE fn = rb_str_new2(fname);
- OBJ_FREEZE(fn);
- return rb_require_safe(fn, rb_safe_level());
-}
-
-static VALUE
-init_ext_call(VALUE arg)
-{
- SCOPE_SET(NOEX_PUBLIC);
- (*(void (*)(void))arg)();
- return Qnil;
-}
-
-void
-ruby_init_ext(const char *name, void (*init)(void))
-{
- if (load_lock(name)) {
- rb_vm_call_cfunc(rb_vm_top_self(), init_ext_call, (VALUE)init,
- 0, rb_str_new2(name));
- rb_provide(name);
- load_unlock(name);
- }
-}
-
-/*
- * call-seq:
- * mod.autoload(name, filename) => nil
- *
- * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
- * the first time that _module_ (which may be a <code>String</code> or
- * a symbol) is accessed in the namespace of _mod_.
- *
- * module A
- * end
- * A.autoload(:B, "b")
- * A::B.doit # autoloads "b"
- */
-
-static VALUE
-rb_mod_autoload(VALUE mod, VALUE sym, VALUE file)
-{
- ID id = rb_to_id(sym);
-
- Check_SafeStr(file);
- rb_autoload(mod, id, RSTRING_PTR(file));
- return Qnil;
-}
-
-/*
- * MISSING: documentation
- */
-
-static VALUE
-rb_mod_autoload_p(VALUE mod, VALUE sym)
-{
- return rb_autoload_p(mod, rb_to_id(sym));
-}
-
-/*
- * call-seq:
- * autoload(module, filename) => nil
- *
- * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
- * the first time that _module_ (which may be a <code>String</code> or
- * a symbol) is accessed.
- *
- * autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
- */
-
-static VALUE
-rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
-{
- VALUE klass = ruby_cbase();
- if (NIL_P(klass)) {
- rb_raise(rb_eTypeError, "Can not set autoload on singleton class");
- }
- return rb_mod_autoload(klass, sym, file);
-}
-
-/*
- * MISSING: documentation
- */
-
-static VALUE
-rb_f_autoload_p(VALUE obj, VALUE sym)
-{
- /* use ruby_cbase() as same as rb_f_autoload. */
- VALUE klass = ruby_cbase();
- if (NIL_P(klass)) {
- return Qnil;
- }
- return rb_mod_autoload_p(klass, sym);
-}
-
-void
-Init_load()
-{
- rb_define_readonly_variable("$:", &rb_load_path);
- rb_define_readonly_variable("$-I", &rb_load_path);
- rb_define_readonly_variable("$LOAD_PATH", &rb_load_path);
- rb_load_path = rb_ary_new();
-
- rb_define_virtual_variable("$\"", get_loaded_features, 0);
- rb_define_virtual_variable("$LOADED_FEATURES", get_loaded_features, 0);
- GET_VM()->loaded_features = rb_ary_new();
-
- rb_define_global_function("load", rb_f_load, -1);
- rb_define_global_function("require", rb_f_require, 1);
- rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
- rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
- rb_define_global_function("autoload", rb_f_autoload, 2);
- rb_define_global_function("autoload?", rb_f_autoload_p, 1);
-
- ruby_dln_librefs = rb_ary_new();
- rb_register_mark_object(ruby_dln_librefs);
-}
diff --git a/main.c b/main.c
index 2cdb45f7b9..bee9a4b15b 100644
--- a/main.c
+++ b/main.c
@@ -6,36 +6,46 @@
$Date$
created at: Fri Aug 19 13:19:58 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#undef RUBY_EXPORT
-#include "ruby/ruby.h"
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
+#include "ruby.h"
+
+#ifdef __human68k__
+int _stacksize = 262144;
+#endif
+
+#if defined __MINGW32__
+int _CRT_glob = 0;
#endif
-RUBY_GLOBAL_SETUP
+#if defined(__MACOS__) && defined(__MWERKS__)
+#include <console.h>
+#endif
+
+/* to link startup code with ObjC support */
+#if (defined(__APPLE__) || defined(__NeXT__)) && defined(__MACH__)
+static void objcdummyfunction( void ) { objc_msgSend(); }
+#endif
int
-main(int argc, char **argv, char **envp)
+main(argc, argv, envp)
+ int argc;
+ char **argv, **envp;
{
-#ifdef RUBY_DEBUG_ENV
- extern void ruby_set_debug_option(const char *);
- ruby_set_debug_option(getenv("RUBY_DEBUG"));
+#ifdef _WIN32
+ NtInitialize(&argc, &argv);
#endif
-#ifdef HAVE_LOCALE_H
- setlocale(LC_CTYPE, "");
+#if defined(__MACOS__) && defined(__MWERKS__)
+ argc = ccommand(&argv);
#endif
- ruby_sysinit(&argc, &argv);
{
- RUBY_INIT_STACK;
- ruby_init();
-#ifdef RUBY_MAIN_INIT
- RUBY_MAIN_INIT();
-#endif
- return ruby_run_node(ruby_options(argc, argv));
+ RUBY_INIT_STACK
+ ruby_init();
+ ruby_options(argc, argv);
+ ruby_run();
}
+ return 0;
}
diff --git a/marshal.c b/marshal.c
index d0f8e7500b..f643450abd 100644
--- a/marshal.c
+++ b/marshal.c
@@ -6,15 +6,14 @@
$Date$
created at: Thu Apr 27 16:30:01 JST 1995
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/io.h"
-#include "ruby/st.h"
-#include "ruby/util.h"
-#include "ruby/encoding.h"
+#include "ruby.h"
+#include "rubyio.h"
+#include "st.h"
+#include "util.h"
#include <math.h>
#ifdef HAVE_FLOAT_H
@@ -32,7 +31,9 @@
#define SHORTLEN(x) (x)
#else
static int
-shortlen(long len, BDIGIT *ds)
+shortlen(len, ds)
+ long len;
+ BDIGIT *ds;
{
BDIGIT num;
int offset = 0;
@@ -80,56 +81,17 @@ shortlen(long len, BDIGIT *ds)
#define TYPE_LINK '@'
static ID s_dump, s_load, s_mdump, s_mload;
-static ID s_dump_data, s_load_data, s_alloc;
+static ID s_dump_data, s_load_data, s_alloc, s_call;
static ID s_getc, s_read, s_write, s_binmode;
-ID rb_id_encoding(void);
-
-typedef struct {
- VALUE newclass;
- VALUE oldclass;
- VALUE (*dumper)(VALUE);
- VALUE (*loader)(VALUE, VALUE);
-} marshal_compat_t;
-
-static st_table *compat_allocator_tbl;
-static VALUE compat_allocator_tbl_wrapper;
-
-static int
-mark_marshal_compat_i(st_data_t key, st_data_t value)
-{
- marshal_compat_t *p = (marshal_compat_t *)value;
- rb_gc_mark(p->newclass);
- rb_gc_mark(p->oldclass);
- return ST_CONTINUE;
-}
-
static void
-mark_marshal_compat_t(void *tbl)
-{
- if (!tbl) return;
- st_foreach(tbl, mark_marshal_compat_i, 0);
-}
-
-void
-rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE), VALUE (*loader)(VALUE, VALUE))
+reentrant_check(obj, sym)
+ VALUE obj;
+ ID sym;
{
- marshal_compat_t *compat;
- rb_alloc_func_t allocator = rb_get_alloc_func(newclass);
-
- if (!allocator) {
- rb_raise(rb_eTypeError, "no allocator");
+ if (obj && RBASIC(obj)->klass) {
+ rb_raise(rb_eRuntimeError, "%s reentered", rb_id2name(sym));
}
-
- compat = ALLOC(marshal_compat_t);
- compat->newclass = Qnil;
- compat->oldclass = Qnil;
- compat->newclass = newclass;
- compat->oldclass = oldclass;
- compat->dumper = dumper;
- compat->loader = loader;
-
- st_insert(compat_allocator_tbl, (st_data_t)allocator, (st_data_t)compat);
}
struct dump_arg {
@@ -138,9 +100,6 @@ struct dump_arg {
st_table *symbols;
st_table *data;
int taint;
- st_table *compat_tbl;
- VALUE wrapper;
- st_table *encodings;
};
struct dump_call_arg {
@@ -149,21 +108,12 @@ struct dump_call_arg {
int limit;
};
-static void
-mark_dump_arg(void *ptr)
-{
- struct dump_arg *p = ptr;
- if (!ptr)
- return;
- rb_mark_set(p->data);
- rb_mark_hash(p->compat_tbl);
-}
-
static VALUE
-class2path(VALUE klass)
+class2path(klass)
+ VALUE klass;
{
VALUE path = rb_class_path(klass);
- char *n = RSTRING_PTR(path);
+ char *n = RSTRING(path)->ptr;
if (n[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous %s %s",
@@ -176,14 +126,17 @@ class2path(VALUE klass)
return path;
}
-static void w_long(long, struct dump_arg*);
+static void w_long _((long, struct dump_arg*));
static void
-w_nbyte(const char *s, int n, struct dump_arg *arg)
+w_nbyte(s, n, arg)
+ const char *s;
+ int n;
+ struct dump_arg *arg;
{
VALUE buf = arg->str;
rb_str_buf_cat(buf, s, n);
- if (arg->dest && RSTRING_LEN(buf) >= BUFSIZ) {
+ if (arg->dest && RSTRING(buf)->len >= BUFSIZ) {
if (arg->taint) OBJ_TAINT(buf);
rb_io_write(arg->dest, buf);
rb_str_resize(buf, 0);
@@ -191,27 +144,36 @@ w_nbyte(const char *s, int n, struct dump_arg *arg)
}
static void
-w_byte(char c, struct dump_arg *arg)
+w_byte(c, arg)
+ char c;
+ struct dump_arg *arg;
{
w_nbyte(&c, 1, arg);
}
static void
-w_bytes(const char *s, int n, struct dump_arg *arg)
+w_bytes(s, n, arg)
+ const char *s;
+ int n;
+ struct dump_arg *arg;
{
w_long(n, arg);
w_nbyte(s, n, arg);
}
static void
-w_short(int x, struct dump_arg *arg)
+w_short(x, arg)
+ int x;
+ struct dump_arg *arg;
{
- w_byte((char)((x >> 0) & 0xff), arg);
- w_byte((char)((x >> 8) & 0xff), arg);
+ w_byte((x >> 0) & 0xff, arg);
+ w_byte((x >> 8) & 0xff, arg);
}
static void
-w_long(long x, struct dump_arg *arg)
+w_long(x, arg)
+ long x;
+ struct dump_arg *arg;
{
char buf[sizeof(long)+1];
int i, len = 0;
@@ -228,11 +190,11 @@ w_long(long x, struct dump_arg *arg)
return;
}
if (0 < x && x < 123) {
- w_byte((char)(x + 5), arg);
+ w_byte(x + 5, arg);
return;
}
if (-124 < x && x < 0) {
- w_byte((char)((x - 5)&0xff), arg);
+ w_byte((x - 5)&0xff, arg);
return;
}
for (i=1;i<sizeof(long)+1;i++) {
@@ -267,7 +229,9 @@ w_long(long x, struct dump_arg *arg)
#endif
static int
-save_mantissa(double d, char *buf)
+save_mantissa(d, buf)
+ double d;
+ char *buf;
{
int e, i = 0;
unsigned long m;
@@ -296,7 +260,10 @@ save_mantissa(double d, char *buf)
}
static double
-load_mantissa(double d, const char *buf, int len)
+load_mantissa(d, buf, len)
+ double d;
+ const char *buf;
+ int len;
{
if (--len > 0 && !*buf++) { /* binary mantissa mark */
int e, s = d < 0, dig = 0;
@@ -337,9 +304,11 @@ load_mantissa(double d, const char *buf, int len)
#endif
static void
-w_float(double d, struct dump_arg *arg)
+w_float(d, arg)
+ double d;
+ struct dump_arg *arg;
{
- char buf[FLOAT_DIG + (DECIMAL_MANT + 7) / 8 + 10];
+ char buf[100];
if (isinf(d)) {
if (d < 0) strcpy(buf, "-inf");
@@ -356,7 +325,7 @@ w_float(double d, struct dump_arg *arg)
int len;
/* xxx: should not use system's sprintf(3) */
- snprintf(buf, sizeof(buf), "%.*g", FLOAT_DIG, d);
+ sprintf(buf, "%.*g", FLOAT_DIG, d);
len = strlen(buf);
w_bytes(buf, len + save_mantissa(d, buf + len), arg);
return;
@@ -365,9 +334,11 @@ w_float(double d, struct dump_arg *arg)
}
static void
-w_symbol(ID id, struct dump_arg *arg)
+w_symbol(id, arg)
+ ID id;
+ struct dump_arg *arg;
{
- const char *sym;
+ const char *sym = rb_id2name(id);
st_data_t num;
if (st_lookup(arg->symbols, id, &num)) {
@@ -375,10 +346,6 @@ w_symbol(ID id, struct dump_arg *arg)
w_long((long)num, arg);
}
else {
- sym = rb_id2name(id);
- if (!sym) {
- rb_raise(rb_eTypeError, "can't dump anonymous ID %ld", id);
- }
w_byte(TYPE_SYMBOL, arg);
w_bytes(sym, strlen(sym), arg);
st_add_direct(arg->symbols, id, arg->symbols->num_entries);
@@ -386,7 +353,9 @@ w_symbol(ID id, struct dump_arg *arg)
}
static void
-w_unique(const char *s, struct dump_arg *arg)
+w_unique(s, arg)
+ const char *s;
+ struct dump_arg *arg;
{
if (s[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous class %s", s);
@@ -394,10 +363,12 @@ w_unique(const char *s, struct dump_arg *arg)
w_symbol(rb_intern(s), arg);
}
-static void w_object(VALUE,struct dump_arg*,int);
+static void w_object _((VALUE,struct dump_arg*,int));
static int
-hash_each(VALUE key, VALUE value, struct dump_call_arg *arg)
+hash_each(key, value, arg)
+ VALUE key, value;
+ struct dump_call_arg *arg;
{
w_object(key, arg->arg, arg->limit);
w_object(value, arg->arg, arg->limit);
@@ -405,129 +376,93 @@ hash_each(VALUE key, VALUE value, struct dump_call_arg *arg)
}
static void
-w_extended(VALUE klass, struct dump_arg *arg, int check)
+w_extended(klass, arg, check)
+ VALUE klass;
+ struct dump_arg *arg;
+ int check;
{
- char *path;
+ const char *path;
if (check && FL_TEST(klass, FL_SINGLETON)) {
- if (RCLASS_M_TBL(klass)->num_entries ||
- (RCLASS_IV_TBL(klass) && RCLASS_IV_TBL(klass)->num_entries > 1)) {
+ if (RCLASS(klass)->m_tbl->num_entries ||
+ (RCLASS(klass)->iv_tbl && RCLASS(klass)->iv_tbl->num_entries > 1)) {
rb_raise(rb_eTypeError, "singleton can't be dumped");
}
- klass = RCLASS_SUPER(klass);
+ klass = RCLASS(klass)->super;
}
while (BUILTIN_TYPE(klass) == T_ICLASS) {
path = rb_class2name(RBASIC(klass)->klass);
w_byte(TYPE_EXTENDED, arg);
w_unique(path, arg);
- klass = RCLASS_SUPER(klass);
+ klass = RCLASS(klass)->super;
}
}
static void
-w_class(char type, VALUE obj, struct dump_arg *arg, int check)
+w_class(type, obj, arg, check)
+ int type;
+ VALUE obj;
+ struct dump_arg *arg;
+ int check;
{
- volatile VALUE p;
char *path;
- st_data_t real_obj;
- VALUE klass;
- if (st_lookup(arg->compat_tbl, (st_data_t)obj, &real_obj)) {
- obj = (VALUE)real_obj;
- }
- klass = CLASS_OF(obj);
+ VALUE klass = CLASS_OF(obj);
w_extended(klass, arg, check);
w_byte(type, arg);
- p = class2path(rb_class_real(klass));
- path = RSTRING_PTR(p);
+ path = RSTRING(class2path(rb_class_real(klass)))->ptr;
w_unique(path, arg);
}
static void
-w_uclass(VALUE obj, VALUE super, struct dump_arg *arg)
+w_uclass(obj, base_klass, arg)
+ VALUE obj, base_klass;
+ struct dump_arg *arg;
{
VALUE klass = CLASS_OF(obj);
w_extended(klass, arg, Qtrue);
klass = rb_class_real(klass);
- if (klass != super) {
+ if (klass != base_klass) {
w_byte(TYPE_UCLASS, arg);
- w_unique(RSTRING_PTR(class2path(klass)), arg);
+ w_unique(RSTRING(class2path(klass))->ptr, arg);
}
}
static int
-w_obj_each(ID id, VALUE value, struct dump_call_arg *arg)
+w_obj_each(id, value, arg)
+ ID id;
+ VALUE value;
+ struct dump_call_arg *arg;
{
- if (id == rb_id_encoding()) return ST_CONTINUE;
w_symbol(id, arg->arg);
w_object(value, arg->arg, arg->limit);
return ST_CONTINUE;
}
static void
-w_encoding(VALUE obj, long num, struct dump_call_arg *arg)
+w_ivar(tbl, arg)
+ st_table *tbl;
+ struct dump_call_arg *arg;
{
- int encidx = rb_enc_get_index(obj);
- rb_encoding *enc = 0;
- st_data_t name;
-
- if (encidx <= 0 || !(enc = rb_enc_from_index(encidx))) {
- w_long(num, arg->arg);
- return;
- }
- w_long(num + 1, arg->arg);
- w_symbol(rb_id_encoding(), arg->arg);
- do {
- if (!arg->arg->encodings)
- arg->arg->encodings = st_init_strcasetable();
- else if (st_lookup(arg->arg->encodings, (st_data_t)rb_enc_name(enc), &name))
- break;
- name = (st_data_t)rb_str_new2(rb_enc_name(enc));
- st_insert(arg->arg->encodings, (st_data_t)rb_enc_name(enc), name);
- } while (0);
- w_object(name, arg->arg, arg->limit);
-}
-
-static void
-w_ivar(VALUE obj, st_table *tbl, struct dump_call_arg *arg)
-{
- long num = tbl ? tbl->num_entries : 0;
-
- w_encoding(obj, num, arg);
if (tbl) {
+ w_long(tbl->num_entries, arg->arg);
st_foreach_safe(tbl, w_obj_each, (st_data_t)arg);
}
-}
-
-static void
-w_objivar(VALUE obj, struct dump_call_arg *arg)
-{
- VALUE *ptr;
- long i, len, num;
-
- len = ROBJECT_LEN(obj);
- ptr = ROBJECT_PTR(obj);
- num = 0;
- for (i = 0; i < len; i++)
- if (ptr[i] != Qundef)
- num += 1;
-
- w_encoding(obj, num, arg);
- if (num != 0) {
- rb_ivar_foreach(obj, w_obj_each, (st_data_t)arg);
+ else {
+ w_long(0, arg->arg);
}
}
static void
-w_object(VALUE obj, struct dump_arg *arg, int limit)
+w_object(obj, arg, limit)
+ VALUE obj;
+ struct dump_arg *arg;
+ int limit;
{
struct dump_call_arg c_arg;
st_table *ivtbl = 0;
st_data_t num;
- int hasiv = 0;
-#define has_ivars(obj, ivtbl) ((ivtbl = rb_generic_ivar_table(obj)) != 0 || \
- (!SPECIAL_CONST_P(obj) && ENCODING_GET(obj)))
if (limit == 0) {
rb_raise(rb_eArgError, "exceed depth limit");
@@ -543,7 +478,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
return;
}
- if ((hasiv = has_ivars(obj, ivtbl)) != 0) {
+ if ((ivtbl = rb_generic_ivar_table(obj)) != 0) {
w_byte(TYPE_IVAR, arg);
}
if (obj == Qnil) {
@@ -576,48 +511,31 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
if (OBJ_TAINTED(obj)) arg->taint = Qtrue;
st_add_direct(arg->data, obj, arg->data->num_entries);
-
- {
- st_data_t compat_data;
- rb_alloc_func_t allocator = rb_get_alloc_func(RBASIC(obj)->klass);
- if (st_lookup(compat_allocator_tbl,
- (st_data_t)allocator,
- &compat_data)) {
- marshal_compat_t *compat = (marshal_compat_t*)compat_data;
- VALUE real_obj = obj;
- obj = compat->dumper(real_obj);
- st_insert(arg->compat_tbl, (st_data_t)obj, (st_data_t)real_obj);
- }
- }
-
if (rb_respond_to(obj, s_mdump)) {
- VALUE v;
+ volatile VALUE v;
v = rb_funcall(obj, s_mdump, 0, 0);
+ reentrant_check(arg->str, s_mdump);
w_class(TYPE_USRMARSHAL, obj, arg, Qfalse);
w_object(v, arg, limit);
- if (hasiv) w_ivar(obj, 0, &c_arg);
+ if (ivtbl) w_ivar(0, &c_arg);
return;
}
if (rb_respond_to(obj, s_dump)) {
VALUE v;
- st_table *ivtbl2 = 0;
- int hasiv2;
v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
+ reentrant_check(arg->str, s_dump);
if (TYPE(v) != T_STRING) {
rb_raise(rb_eTypeError, "_dump() must return string");
}
- if ((hasiv2 = has_ivars(v, ivtbl2)) != 0 && !hasiv) {
+ if (!ivtbl && (ivtbl = rb_generic_ivar_table(v))) {
w_byte(TYPE_IVAR, arg);
}
w_class(TYPE_USERDEF, obj, arg, Qfalse);
- w_bytes(RSTRING_PTR(v), RSTRING_LEN(v), arg);
- if (hasiv2) {
- w_ivar(obj, ivtbl2, &c_arg);
- }
- else if (hasiv) {
- w_ivar(obj, ivtbl, &c_arg);
+ w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg);
+ if (ivtbl) {
+ w_ivar(ivtbl, &c_arg);
}
return;
}
@@ -629,8 +547,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
}
w_byte(TYPE_CLASS, arg);
{
- volatile VALUE path = class2path(obj);
- w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
+ VALUE path = class2path(obj);
+ w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
}
break;
@@ -638,21 +556,21 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
w_byte(TYPE_MODULE, arg);
{
VALUE path = class2path(obj);
- w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
+ w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
}
break;
case T_FLOAT:
w_byte(TYPE_FLOAT, arg);
- w_float(RFLOAT_VALUE(obj), arg);
+ w_float(RFLOAT(obj)->value, arg);
break;
case T_BIGNUM:
w_byte(TYPE_BIGNUM, arg);
{
- char sign = RBIGNUM_SIGN(obj) ? '+' : '-';
- long len = RBIGNUM_LEN(obj);
- BDIGIT *d = RBIGNUM_DIGITS(obj);
+ char sign = RBIGNUM(obj)->sign ? '+' : '-';
+ long len = RBIGNUM(obj)->len;
+ BDIGIT *d = RBIGNUM(obj)->digits;
w_byte(sign, arg);
w_long(SHORTLEN(len), arg); /* w_short? */
@@ -677,22 +595,22 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
case T_STRING:
w_uclass(obj, rb_cString, arg);
w_byte(TYPE_STRING, arg);
- w_bytes(RSTRING_PTR(obj), RSTRING_LEN(obj), arg);
+ w_bytes(RSTRING(obj)->ptr, RSTRING(obj)->len, arg);
break;
case T_REGEXP:
w_uclass(obj, rb_cRegexp, arg);
w_byte(TYPE_REGEXP, arg);
w_bytes(RREGEXP(obj)->str, RREGEXP(obj)->len, arg);
- w_byte((char)rb_reg_options(obj), arg);
+ w_byte(rb_reg_options(obj), arg);
break;
case T_ARRAY:
w_uclass(obj, rb_cArray, arg);
w_byte(TYPE_ARRAY, arg);
{
- long len = RARRAY_LEN(obj);
- VALUE *ptr = RARRAY_PTR(obj);
+ long len = RARRAY(obj)->len;
+ VALUE *ptr = RARRAY(obj)->ptr;
w_long(len, arg);
while (len--) {
@@ -714,7 +632,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
else {
w_byte(TYPE_HASH_DEF, arg);
}
- w_long(RHASH_SIZE(obj), arg);
+ w_long(RHASH(obj)->tbl->num_entries, arg);
rb_hash_foreach(obj, hash_each, (st_data_t)&c_arg);
if (!NIL_P(RHASH(obj)->ifnone)) {
w_object(RHASH(obj)->ifnone, arg, limit);
@@ -724,22 +642,22 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
case T_STRUCT:
w_class(TYPE_STRUCT, obj, arg, Qtrue);
{
- long len = RSTRUCT_LEN(obj);
+ long len = RSTRUCT(obj)->len;
VALUE mem;
long i;
w_long(len, arg);
mem = rb_struct_members(obj);
for (i=0; i<len; i++) {
- w_symbol(SYM2ID(RARRAY_PTR(mem)[i]), arg);
- w_object(RSTRUCT_PTR(obj)[i], arg, limit);
+ w_symbol(SYM2ID(RARRAY(mem)->ptr[i]), arg);
+ w_object(RSTRUCT(obj)->ptr[i], arg, limit);
}
}
break;
case T_OBJECT:
w_class(TYPE_OBJECT, obj, arg, Qtrue);
- w_objivar(obj, &c_arg);
+ w_ivar(ROBJECT(obj)->iv_tbl, &c_arg);
break;
case T_DATA:
@@ -752,6 +670,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
rb_obj_classname(obj));
}
v = rb_funcall(obj, s_dump_data, 0);
+ reentrant_check(arg->str, s_dump_data);
w_class(TYPE_DATA, obj, arg, Qtrue);
w_object(v, arg, limit);
}
@@ -763,13 +682,14 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
break;
}
}
- if (hasiv) {
- w_ivar(obj, ivtbl, &c_arg);
+ if (ivtbl) {
+ w_ivar(ivtbl, &c_arg);
}
}
static VALUE
-dump(struct dump_call_arg *arg)
+dump(arg)
+ struct dump_call_arg *arg;
{
w_object(arg->obj, arg->arg, arg->limit);
if (arg->arg->dest) {
@@ -780,16 +700,16 @@ dump(struct dump_call_arg *arg)
}
static VALUE
-dump_ensure(struct dump_arg *arg)
+dump_ensure(arg)
+ struct dump_arg *arg;
{
+ if (RBASIC(arg->str)->klass) return 0; /* ignore reentrant */
st_free_table(arg->symbols);
st_free_table(arg->data);
- st_free_table(arg->compat_tbl);
- DATA_PTR(arg->wrapper) = 0;
- arg->wrapper = 0;
if (arg->taint) {
OBJ_TAINT(arg->str);
}
+
return 0;
}
@@ -820,7 +740,9 @@ dump_ensure(struct dump_arg *arg)
* obj.sayHello #=> "hello\n"
*/
static VALUE
-marshal_dump(int argc, VALUE *argv)
+marshal_dump(argc, argv)
+ int argc;
+ VALUE* argv;
{
VALUE obj, port, a1, a2;
int limit = -1;
@@ -840,28 +762,26 @@ marshal_dump(int argc, VALUE *argv)
else port = a1;
}
arg.dest = 0;
+ arg.str = rb_str_buf_new(0);
+ RBASIC(arg.str)->klass = 0;
if (!NIL_P(port)) {
if (!rb_respond_to(port, s_write)) {
type_error:
rb_raise(rb_eTypeError, "instance of IO needed");
}
- arg.str = rb_str_buf_new(0);
arg.dest = port;
if (rb_respond_to(port, s_binmode)) {
rb_funcall2(port, s_binmode, 0, 0);
+ reentrant_check(arg.str, s_dump_data);
}
}
else {
- port = rb_str_buf_new(0);
- arg.str = port;
+ port = arg.str;
}
arg.symbols = st_init_numtable();
arg.data = st_init_numtable();
arg.taint = Qfalse;
- arg.compat_tbl = st_init_numtable();
- arg.wrapper = Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, &arg);
- arg.encodings = 0;
c_arg.obj = obj;
c_arg.arg = &arg;
c_arg.limit = limit;
@@ -870,6 +790,7 @@ marshal_dump(int argc, VALUE *argv)
w_byte(MARSHAL_MINOR, &arg);
rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
+ RBASIC(arg.str)->klass = rb_cString;
return port;
}
@@ -881,22 +802,19 @@ struct load_arg {
VALUE data;
VALUE proc;
int taint;
- st_table *compat_tbl;
- VALUE compat_tbl_wrapper;
};
-static VALUE r_entry(VALUE v, struct load_arg *arg);
-static VALUE r_object(struct load_arg *arg);
-static VALUE path2class(const char *path);
+static VALUE r_object _((struct load_arg *arg));
static int
-r_byte(struct load_arg *arg)
+r_byte(arg)
+ struct load_arg *arg;
{
int c;
if (TYPE(arg->src) == T_STRING) {
- if (RSTRING_LEN(arg->src) > arg->offset) {
- c = (unsigned char)RSTRING_PTR(arg->src)[arg->offset++];
+ if (RSTRING(arg->src)->len > arg->offset) {
+ c = (unsigned char)RSTRING(arg->src)->ptr[arg->offset++];
}
else {
rb_raise(rb_eArgError, "marshal data too short");
@@ -905,14 +823,16 @@ r_byte(struct load_arg *arg)
else {
VALUE src = arg->src;
VALUE v = rb_funcall2(src, s_getc, 0, 0);
+ reentrant_check(arg->data, s_getc);
if (NIL_P(v)) rb_eof_error();
- c = (unsigned char)NUM2CHR(v);
+ c = (unsigned char)FIX2INT(v);
}
return c;
}
static void
-long_toobig(int size)
+long_toobig(size)
+ int size;
{
rb_raise(rb_eTypeError, "long too big for this architecture (size %d, given %d)",
sizeof(long), size);
@@ -927,7 +847,8 @@ long_toobig(int size)
#endif
static long
-r_long(struct load_arg *arg)
+r_long(arg)
+ struct load_arg *arg;
{
register long x;
int c = SIGN_EXTEND_CHAR(r_byte(arg));
@@ -962,14 +883,16 @@ r_long(struct load_arg *arg)
#define r_bytes(arg) r_bytes0(r_long(arg), (arg))
static VALUE
-r_bytes0(long len, struct load_arg *arg)
+r_bytes0(len, arg)
+ long len;
+ struct load_arg *arg;
{
VALUE str;
if (len == 0) return rb_str_new(0, 0);
if (TYPE(arg->src) == T_STRING) {
- if (RSTRING_LEN(arg->src) - arg->offset >= len) {
- str = rb_str_new(RSTRING_PTR(arg->src)+arg->offset, len);
+ if (RSTRING(arg->src)->len - arg->offset >= len) {
+ str = rb_str_new(RSTRING(arg->src)->ptr+arg->offset, len);
arg->offset += len;
}
else {
@@ -981,16 +904,18 @@ r_bytes0(long len, struct load_arg *arg)
VALUE src = arg->src;
VALUE n = LONG2NUM(len);
str = rb_funcall2(src, s_read, 1, &n);
+ reentrant_check(arg->data, s_read);
if (NIL_P(str)) goto too_short;
StringValue(str);
- if (RSTRING_LEN(str) != len) goto too_short;
+ if (RSTRING(str)->len != len) goto too_short;
if (OBJ_TAINTED(str)) arg->taint = Qtrue;
}
return str;
}
static ID
-r_symlink(struct load_arg *arg)
+r_symlink(arg)
+ struct load_arg *arg;
{
ID id;
long num = r_long(arg);
@@ -1002,85 +927,55 @@ r_symlink(struct load_arg *arg)
}
static ID
-r_symreal(struct load_arg *arg)
+r_symreal(arg)
+ struct load_arg *arg;
{
- volatile VALUE s = r_bytes(arg);
- ID id = rb_intern(RSTRING_PTR(s));
+ ID id;
+ id = rb_intern(RSTRING(r_bytes(arg))->ptr);
st_insert(arg->symbols, arg->symbols->num_entries, id);
return id;
}
static ID
-r_symbol(struct load_arg *arg)
+r_symbol(arg)
+ struct load_arg *arg;
{
- int type;
-
- switch ((type = r_byte(arg))) {
- case TYPE_SYMBOL:
- return r_symreal(arg);
- case TYPE_SYMLINK:
+ if (r_byte(arg) == TYPE_SYMLINK) {
return r_symlink(arg);
- default:
- rb_raise(rb_eArgError, "dump format error(0x%x)", type);
- break;
}
+ return r_symreal(arg);
}
static const char*
-r_unique(struct load_arg *arg)
+r_unique(arg)
+ struct load_arg *arg;
{
return rb_id2name(r_symbol(arg));
}
static VALUE
-r_string(struct load_arg *arg)
+r_string(arg)
+ struct load_arg *arg;
{
return r_bytes(arg);
}
static VALUE
-r_entry(VALUE v, struct load_arg *arg)
+r_entry(v, arg)
+ VALUE v;
+ struct load_arg *arg;
{
- st_data_t real_obj = (VALUE)Qundef;
- if (st_lookup(arg->compat_tbl, v, &real_obj)) {
- rb_hash_aset(arg->data, INT2FIX(RHASH_SIZE(arg->data)), (VALUE)real_obj);
- }
- else {
- rb_hash_aset(arg->data, INT2FIX(RHASH_SIZE(arg->data)), v);
- }
- if (arg->taint) {
- OBJ_TAINT(v);
- if ((VALUE)real_obj != Qundef)
- OBJ_TAINT((VALUE)real_obj);
- }
- return v;
-}
-
-static VALUE
-r_leave(VALUE v, struct load_arg *arg)
-{
- st_data_t data;
- if (st_lookup(arg->compat_tbl, v, &data)) {
- VALUE real_obj = (VALUE)data;
- rb_alloc_func_t allocator = rb_get_alloc_func(CLASS_OF(real_obj));
- st_data_t key = v;
- if (st_lookup(compat_allocator_tbl, (st_data_t)allocator, &data)) {
- marshal_compat_t *compat = (marshal_compat_t*)data;
- compat->loader(real_obj, v);
- }
- st_delete(arg->compat_tbl, &key, 0);
- v = real_obj;
- }
- if (arg->proc) {
- v = rb_funcall(arg->proc, rb_intern("call"), 1, v);
- }
+ rb_hash_aset(arg->data, INT2FIX(RHASH(arg->data)->tbl->num_entries), v);
+ if (arg->taint) OBJ_TAINT(v);
return v;
}
static void
-r_ivar(VALUE obj, struct load_arg *arg)
+r_ivar(obj, arg)
+ VALUE obj;
+ struct load_arg *arg;
{
long len;
@@ -1089,19 +984,14 @@ r_ivar(VALUE obj, struct load_arg *arg)
while (len--) {
ID id = r_symbol(arg);
VALUE val = r_object(arg);
- if (id == rb_id_encoding()) {
- int idx = rb_enc_find_index(StringValueCStr(val));
- if (idx > 0) rb_enc_associate_index(obj, idx);
- }
- else {
- rb_ivar_set(obj, id, val);
- }
+ rb_ivar_set(obj, id, val);
}
}
}
static VALUE
-path2class(const char *path)
+path2class(path)
+ const char *path;
{
VALUE v = rb_path2class(path);
@@ -1112,7 +1002,8 @@ path2class(const char *path)
}
static VALUE
-path2module(const char *path)
+path2module(path)
+ const char *path;
{
VALUE v = rb_path2class(path);
@@ -1123,28 +1014,11 @@ path2module(const char *path)
}
static VALUE
-obj_alloc_by_path(const char *path, struct load_arg *arg)
-{
- VALUE klass;
- st_data_t data;
- rb_alloc_func_t allocator;
-
- klass = path2class(path);
-
- allocator = rb_get_alloc_func(klass);
- if (st_lookup(compat_allocator_tbl, (st_data_t)allocator, &data)) {
- marshal_compat_t *compat = (marshal_compat_t*)data;
- VALUE real_obj = rb_obj_alloc(klass);
- VALUE obj = rb_obj_alloc(compat->oldclass);
- st_insert(arg->compat_tbl, (st_data_t)obj, (st_data_t)real_obj);
- return obj;
- }
-
- return rb_obj_alloc(klass);
-}
-
-static VALUE
-r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
+r_object0(arg, proc, ivp, extmod)
+ struct load_arg *arg;
+ VALUE proc;
+ int *ivp;
+ VALUE extmod;
{
VALUE v = Qnil;
int type = r_byte(arg);
@@ -1157,16 +1031,13 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
if (NIL_P(v)) {
rb_raise(rb_eArgError, "dump format error (unlinked)");
}
- if (arg->proc) {
- v = rb_funcall(arg->proc, rb_intern("call"), 1, v);
- }
- break;
+ return v;
case TYPE_IVAR:
{
int ivar = Qtrue;
- v = r_object0(arg, &ivar, extmod);
+ v = r_object0(arg, 0, &ivar, extmod);
if (ivar) r_ivar(v, arg);
}
break;
@@ -1178,8 +1049,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
if (NIL_P(extmod)) extmod = rb_ary_new2(0);
rb_ary_push(extmod, m);
- v = r_object0(arg, 0, extmod);
- while (RARRAY_LEN(extmod) > 0) {
+ v = r_object0(arg, 0, 0, extmod);
+ while (RARRAY(extmod)->len > 0) {
m = rb_ary_pop(extmod);
rb_extend_object(v, m);
}
@@ -1193,7 +1064,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
if (FL_TEST(c, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "singleton can't be loaded");
}
- v = r_object0(arg, 0, extmod);
+ v = r_object0(arg, 0, 0, extmod);
if (rb_special_const_p(v) || TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS) {
format_error:
rb_raise(rb_eArgError, "dump format error (user class)");
@@ -1230,7 +1101,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
double d, t = 0.0;
VALUE str = r_bytes(arg);
- const char *ptr = RSTRING_PTR(str);
+ const char *ptr = RSTRING(str)->ptr;
if (strcmp(ptr, "nan") == 0) {
d = t / t;
@@ -1244,11 +1115,10 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
else {
char *e;
d = strtod(ptr, &e);
- d = load_mantissa(d, e, RSTRING_LEN(str) - (e - ptr));
+ d = load_mantissa(d, e, RSTRING(str)->len - (e - ptr));
}
- v = DOUBLE2NUM(d);
- v = r_entry(v, arg);
- v = r_leave(v, arg);
+ v = rb_float_new(d);
+ r_entry(v, arg);
}
break;
@@ -1260,21 +1130,21 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
NEWOBJ(big, struct RBignum);
OBJSETUP(big, rb_cBignum, T_BIGNUM);
- RBIGNUM_SET_SIGN(big, (r_byte(arg) == '+'));
+ big->sign = (r_byte(arg) == '+');
len = r_long(arg);
data = r_bytes0(len * 2, arg);
#if SIZEOF_BDIGITS == SIZEOF_SHORT
- rb_big_resize((VALUE)big, len);
+ big->len = len;
#else
- rb_big_resize((VALUE)big, (len + 1) * 2 / sizeof(BDIGIT));
+ big->len = (len + 1) * 2 / sizeof(BDIGIT);
#endif
- digits = RBIGNUM_DIGITS(big);
- MEMCPY(digits, RSTRING_PTR(data), char, len * 2);
+ big->digits = digits = ALLOC_N(BDIGIT, big->len);
+ MEMCPY(digits, RSTRING(data)->ptr, char, len * 2);
#if SIZEOF_BDIGITS > SIZEOF_SHORT
MEMZERO((char *)digits + len * 2, char,
- RBIGNUM_LEN(big) * sizeof(BDIGIT) - len * 2);
+ big->len * sizeof(BDIGIT) - len * 2);
#endif
- len = RBIGNUM_LEN(big);
+ len = big->len;
while (len > 0) {
unsigned char *p = (unsigned char *)digits;
BDIGIT num = 0;
@@ -1293,22 +1163,19 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
len--;
}
v = rb_big_norm((VALUE)big);
- v = r_entry(v, arg);
- v = r_leave(v, arg);
+ r_entry(v, arg);
}
break;
case TYPE_STRING:
v = r_entry(r_string(arg), arg);
- v = r_leave(v, arg);
break;
case TYPE_REGEXP:
{
volatile VALUE str = r_bytes(arg);
int options = r_byte(arg);
- v = r_entry(rb_reg_new(str, options), arg);
- v = r_leave(v, arg);
+ v = r_entry(rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, options), arg);
}
break;
@@ -1317,11 +1184,10 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
volatile long len = r_long(arg); /* gcc 2.7.2.3 -O2 bug?? */
v = rb_ary_new2(len);
- v = r_entry(v, arg);
+ r_entry(v, arg);
while (len--) {
rb_ary_push(v, r_object(arg));
}
- v = r_leave(v, arg);
}
break;
@@ -1331,7 +1197,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
long len = r_long(arg);
v = rb_hash_new();
- v = r_entry(v, arg);
+ r_entry(v, arg);
while (len--) {
VALUE key = r_object(arg);
VALUE value = r_object(arg);
@@ -1340,46 +1206,37 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
if (type == TYPE_HASH_DEF) {
RHASH(v)->ifnone = r_object(arg);
}
- v = r_leave(v, arg);
}
break;
case TYPE_STRUCT:
{
- VALUE klass, mem;
- VALUE values;
+ VALUE klass, mem, values;
volatile long i; /* gcc 2.7.2.3 -O2 bug?? */
long len;
ID slot;
klass = path2class(r_unique(arg));
- len = r_long(arg);
-
- v = rb_obj_alloc(klass);
- if (TYPE(v) != T_STRUCT) {
- rb_raise(rb_eTypeError, "class %s not a struct", rb_class2name(klass));
- }
mem = rb_struct_s_members(klass);
- if (RARRAY_LEN(mem) != len) {
- rb_raise(rb_eTypeError, "struct %s not compatible (struct size differs)",
- rb_class2name(klass));
- }
+ len = r_long(arg);
- v = r_entry(v, arg);
values = rb_ary_new2(len);
for (i=0; i<len; i++) {
+ rb_ary_push(values, Qnil);
+ }
+ v = rb_struct_alloc(klass, values);
+ r_entry(v, arg);
+ for (i=0; i<len; i++) {
slot = r_symbol(arg);
- if (RARRAY_PTR(mem)[i] != ID2SYM(slot)) {
+ if (RARRAY(mem)->ptr[i] != ID2SYM(slot)) {
rb_raise(rb_eTypeError, "struct %s not compatible (:%s for :%s)",
rb_class2name(klass),
rb_id2name(slot),
- rb_id2name(SYM2ID(RARRAY_PTR(mem)[i])));
+ rb_id2name(SYM2ID(RARRAY(mem)->ptr[i])));
}
- rb_ary_push(values, r_object(arg));
+ rb_struct_aset(v, LONG2FIX(i), r_object(arg));
}
- rb_struct_initialize(v, values);
- v = r_leave(v, arg);
}
break;
@@ -1398,8 +1255,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
*ivp = Qfalse;
}
v = rb_funcall(klass, s_load, 1, data);
- v = r_entry(v, arg);
- v = r_leave(v, arg);
+ reentrant_check(arg->data, s_load);
+ r_entry(v, arg);
}
break;
@@ -1409,8 +1266,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
VALUE data;
v = rb_obj_alloc(klass);
- if (!NIL_P(extmod)) {
- while (RARRAY_LEN(extmod) > 0) {
+ if (! NIL_P(extmod)) {
+ while (RARRAY(extmod)->len > 0) {
VALUE m = rb_ary_pop(extmod);
rb_extend_object(v, m);
}
@@ -1419,22 +1276,23 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'",
rb_class2name(klass));
}
- v = r_entry(v, arg);
+ r_entry(v, arg);
data = r_object(arg);
rb_funcall(v, s_mload, 1, data);
- v = r_leave(v, arg);
+ reentrant_check(arg->data, s_mload);
}
break;
case TYPE_OBJECT:
{
- v = obj_alloc_by_path(r_unique(arg), arg);
+ VALUE klass = path2class(r_unique(arg));
+
+ v = rb_obj_alloc(klass);
if (TYPE(v) != T_OBJECT) {
rb_raise(rb_eArgError, "dump format error");
}
- v = r_entry(v, arg);
+ r_entry(v, arg);
r_ivar(v, arg);
- v = r_leave(v, arg);
}
break;
@@ -1448,6 +1306,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
warn = Qfalse;
}
v = rb_funcall(klass, s_alloc, 0);
+ reentrant_check(arg->data, s_alloc);
}
else {
v = rb_obj_alloc(klass);
@@ -1455,14 +1314,14 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
if (TYPE(v) != T_DATA) {
rb_raise(rb_eArgError, "dump format error");
}
- v = r_entry(v, arg);
+ r_entry(v, arg);
if (!rb_respond_to(v, s_load_data)) {
rb_raise(rb_eTypeError,
"class %s needs to have instance method `_load_data'",
rb_class2name(klass));
}
- rb_funcall(v, s_load_data, 1, r_object0(arg, 0, extmod));
- v = r_leave(v, arg);
+ rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extmod));
+ reentrant_check(arg->data, s_load_data);
}
break;
@@ -1470,9 +1329,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
volatile VALUE str = r_bytes(arg);
- v = rb_path2class(RSTRING_PTR(str));
- v = r_entry(v, arg);
- v = r_leave(v, arg);
+ v = rb_path2class(RSTRING(str)->ptr);
+ r_entry(v, arg);
}
break;
@@ -1480,9 +1338,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
volatile VALUE str = r_bytes(arg);
- v = path2class(RSTRING_PTR(str));
- v = r_entry(v, arg);
- v = r_leave(v, arg);
+ v = path2class(RSTRING(str)->ptr);
+ r_entry(v, arg);
}
break;
@@ -1490,9 +1347,8 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
volatile VALUE str = r_bytes(arg);
- v = path2module(RSTRING_PTR(str));
- v = r_entry(v, arg);
- v = r_leave(v, arg);
+ v = path2module(RSTRING(str)->ptr);
+ r_entry(v, arg);
}
break;
@@ -1501,35 +1357,39 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
break;
case TYPE_SYMLINK:
- v = ID2SYM(r_symlink(arg));
- break;
+ return ID2SYM(r_symlink(arg));
default:
rb_raise(rb_eArgError, "dump format error(0x%x)", type);
break;
}
+ if (proc) {
+ rb_funcall(proc, s_call, 1, v);
+ reentrant_check(arg->data, s_call);
+ }
return v;
}
static VALUE
-r_object(struct load_arg *arg)
+r_object(arg)
+ struct load_arg *arg;
{
- return r_object0(arg, 0, Qnil);
+ return r_object0(arg, arg->proc, 0, Qnil);
}
static VALUE
-load(struct load_arg *arg)
+load(arg)
+ struct load_arg *arg;
{
return r_object(arg);
}
static VALUE
-load_ensure(struct load_arg *arg)
+load_ensure(arg)
+ struct load_arg *arg;
{
+ if (RBASIC(arg->data)->klass) return 0; /* ignore reentrant */
st_free_table(arg->symbols);
- st_free_table(arg->compat_tbl);
- DATA_PTR(arg->compat_tbl_wrapper) = 0;
- arg->compat_tbl_wrapper = 0;
return 0;
}
@@ -1545,7 +1405,9 @@ load_ensure(struct load_arg *arg)
* is deserialized.
*/
static VALUE
-marshal_load(int argc, VALUE *argv)
+marshal_load(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE port, proc;
int major, minor;
@@ -1553,9 +1415,10 @@ marshal_load(int argc, VALUE *argv)
struct load_arg arg;
rb_scan_args(argc, argv, "11", &port, &proc);
- if (rb_respond_to(port, rb_intern("to_str"))) {
+ v = rb_check_string_type(port);
+ if (!NIL_P(v)) {
arg.taint = OBJ_TAINTED(port); /* original taintedness */
- StringValue(port); /* possible conversion */
+ port = v;
}
else if (rb_respond_to(port, s_getc) && rb_respond_to(port, s_read)) {
if (rb_respond_to(port, s_binmode)) {
@@ -1568,8 +1431,7 @@ marshal_load(int argc, VALUE *argv)
}
arg.src = port;
arg.offset = 0;
- arg.compat_tbl = st_init_numtable();
- arg.compat_tbl_wrapper = Data_Wrap_Struct(rb_cData, rb_mark_tbl, 0, arg.compat_tbl);
+ arg.data = 0;
major = r_byte(&arg);
minor = r_byte(&arg);
@@ -1586,9 +1448,11 @@ marshal_load(int argc, VALUE *argv)
arg.symbols = st_init_numtable();
arg.data = rb_hash_new();
+ RBASIC(arg.data)->klass = 0;
if (NIL_P(proc)) arg.proc = 0;
else arg.proc = proc;
v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
+ RBASIC(arg.data)->klass = rb_cHash;
return v;
}
@@ -1627,7 +1491,7 @@ marshal_load(int argc, VALUE *argv)
* The class method _load should take a String and return an object of this class.
*/
void
-Init_marshal(void)
+Init_marshal()
{
VALUE rb_mMarshal = rb_define_module("Marshal");
@@ -1638,6 +1502,7 @@ Init_marshal(void)
s_dump_data = rb_intern("_dump_data");
s_load_data = rb_intern("_load_data");
s_alloc = rb_intern("_alloc");
+ s_call = rb_intern("call");
s_getc = rb_intern("getc");
s_read = rb_intern("read");
s_write = rb_intern("write");
@@ -1649,15 +1514,11 @@ Init_marshal(void)
rb_define_const(rb_mMarshal, "MAJOR_VERSION", INT2FIX(MARSHAL_MAJOR));
rb_define_const(rb_mMarshal, "MINOR_VERSION", INT2FIX(MARSHAL_MINOR));
-
- compat_allocator_tbl = st_init_numtable();
- rb_gc_register_address(&compat_allocator_tbl_wrapper);
- compat_allocator_tbl_wrapper =
- Data_Wrap_Struct(rb_cData, mark_marshal_compat_t, 0, compat_allocator_tbl);
}
VALUE
-rb_marshal_dump(VALUE obj, VALUE port)
+rb_marshal_dump(obj, port)
+ VALUE obj, port;
{
int argc = 1;
VALUE argv[2];
@@ -1669,7 +1530,8 @@ rb_marshal_dump(VALUE obj, VALUE port)
}
VALUE
-rb_marshal_load(VALUE port)
+rb_marshal_load(port)
+ VALUE port;
{
return marshal_load(1, &port);
}
diff --git a/math.c b/math.c
index 85040f9c59..bf9b598156 100644
--- a/math.c
+++ b/math.c
@@ -6,11 +6,11 @@
$Date$
created at: Tue Jan 25 14:12:56 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <math.h>
#include <errno.h>
@@ -23,7 +23,9 @@ VALUE rb_mMath;
} while (0)
static void
-domain_check(double x, char *msg)
+domain_check(x, msg)
+ double x;
+ char *msg;
{
while(1) {
if (errno) {
@@ -52,10 +54,11 @@ domain_check(double x, char *msg)
*/
static VALUE
-math_atan2(VALUE obj, VALUE y, VALUE x)
+math_atan2(obj, y, x)
+ VALUE obj, x, y;
{
Need_Float2(y, x);
- return DOUBLE2NUM(atan2(RFLOAT_VALUE(y), RFLOAT_VALUE(x)));
+ return rb_float_new(atan2(RFLOAT(y)->value, RFLOAT(x)->value));
}
@@ -68,10 +71,11 @@ math_atan2(VALUE obj, VALUE y, VALUE x)
*/
static VALUE
-math_cos(VALUE obj, VALUE x)
+math_cos(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(cos(RFLOAT_VALUE(x)));
+ return rb_float_new(cos(RFLOAT(x)->value));
}
/*
@@ -83,11 +87,12 @@ math_cos(VALUE obj, VALUE x)
*/
static VALUE
-math_sin(VALUE obj, VALUE x)
+math_sin(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(sin(RFLOAT_VALUE(x)));
+ return rb_float_new(sin(RFLOAT(x)->value));
}
@@ -99,11 +104,12 @@ math_sin(VALUE obj, VALUE x)
*/
static VALUE
-math_tan(VALUE obj, VALUE x)
+math_tan(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(tan(RFLOAT_VALUE(x)));
+ return rb_float_new(tan(RFLOAT(x)->value));
}
/*
@@ -114,34 +120,36 @@ math_tan(VALUE obj, VALUE x)
*/
static VALUE
-math_acos(VALUE obj, VALUE x)
+math_acos(obj, x)
+ VALUE obj, x;
{
double d;
Need_Float(x);
errno = 0;
- d = acos(RFLOAT_VALUE(x));
+ d = acos(RFLOAT(x)->value);
domain_check(d, "acos");
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
* call-seq:
* Math.asin(x) => float
*
- * Computes the arc sine of <i>x</i>. Returns 0..PI.
+ * Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
*/
static VALUE
-math_asin(VALUE obj, VALUE x)
+math_asin(obj, x)
+ VALUE obj, x;
{
double d;
Need_Float(x);
errno = 0;
- d = asin(RFLOAT_VALUE(x));
+ d = asin(RFLOAT(x)->value);
domain_check(d, "asin");
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
@@ -152,15 +160,17 @@ math_asin(VALUE obj, VALUE x)
*/
static VALUE
-math_atan(VALUE obj, VALUE x)
+math_atan(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(atan(RFLOAT_VALUE(x)));
+ return rb_float_new(atan(RFLOAT(x)->value));
}
#ifndef HAVE_COSH
double
-cosh(double x)
+cosh(x)
+ double x;
{
return (exp(x) + exp(-x)) / 2;
}
@@ -174,16 +184,18 @@ cosh(double x)
*/
static VALUE
-math_cosh(VALUE obj, VALUE x)
+math_cosh(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(cosh(RFLOAT_VALUE(x)));
+ return rb_float_new(cosh(RFLOAT(x)->value));
}
#ifndef HAVE_SINH
double
-sinh(double x)
+sinh(x)
+ double x;
{
return (exp(x) - exp(-x)) / 2;
}
@@ -198,15 +210,17 @@ sinh(double x)
*/
static VALUE
-math_sinh(VALUE obj, VALUE x)
+math_sinh(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(sinh(RFLOAT_VALUE(x)));
+ return rb_float_new(sinh(RFLOAT(x)->value));
}
#ifndef HAVE_TANH
double
-tanh(double x)
+tanh(x)
+ double x;
{
return sinh(x) / cosh(x);
}
@@ -221,10 +235,11 @@ tanh(double x)
*/
static VALUE
-math_tanh(VALUE obj, VALUE x)
+math_tanh(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(tanh(RFLOAT_VALUE(x)));
+ return rb_float_new(tanh(RFLOAT(x)->value));
}
/*
@@ -235,15 +250,16 @@ math_tanh(VALUE obj, VALUE x)
*/
static VALUE
-math_acosh(VALUE obj, VALUE x)
+math_acosh(obj, x)
+ VALUE obj, x;
{
double d;
Need_Float(x);
errno = 0;
- d = acosh(RFLOAT_VALUE(x));
+ d = acosh(RFLOAT(x)->value);
domain_check(d, "acosh");
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
@@ -254,10 +270,11 @@ math_acosh(VALUE obj, VALUE x)
*/
static VALUE
-math_asinh(VALUE obj, VALUE x)
+math_asinh(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(asinh(RFLOAT_VALUE(x)));
+ return rb_float_new(asinh(RFLOAT(x)->value));
}
/*
@@ -268,15 +285,16 @@ math_asinh(VALUE obj, VALUE x)
*/
static VALUE
-math_atanh(VALUE obj, VALUE x)
+math_atanh(obj, x)
+ VALUE obj, x;
{
double d;
Need_Float(x);
errno = 0;
- d = atanh(RFLOAT_VALUE(x));
+ d = atanh(RFLOAT(x)->value);
domain_check(d, "atanh");
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
@@ -287,10 +305,11 @@ math_atanh(VALUE obj, VALUE x)
*/
static VALUE
-math_exp(VALUE obj, VALUE x)
+math_exp(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(exp(RFLOAT_VALUE(x)));
+ return rb_float_new(exp(RFLOAT(x)->value));
}
#if defined __CYGWIN__
@@ -305,62 +324,21 @@ math_exp(VALUE obj, VALUE x)
/*
* call-seq:
* Math.log(numeric) => float
- * Math.log(num,base) => float
*
* Returns the natural logarithm of <i>numeric</i>.
- * If additional second argument is given, it will be the base
- * of logarithm.
*/
static VALUE
-math_log(int argc, VALUE *argv)
+math_log(obj, x)
+ VALUE obj, x;
{
- VALUE x, base;
double d;
- rb_scan_args(argc, argv, "11", &x, &base);
Need_Float(x);
errno = 0;
- d = log(RFLOAT_VALUE(x));
- if (!NIL_P(base)) {
- Need_Float(base);
- d /= log(RFLOAT_VALUE(base));
- }
+ d = log(RFLOAT(x)->value);
domain_check(d, "log");
- return DOUBLE2NUM(d);
-}
-
-#ifndef log2
-#ifndef HAVE_LOG2
-double
-log2(double x)
-{
- return log10(x)/log10(2.0);
-}
-#else
-extern double log2(double);
-#endif
-#endif
-
-/*
- * call-seq:
- * Math.log2(numeric) => float
- *
- * Returns the base 2 logarithm of <i>numeric</i>.
- */
-
-static VALUE
-math_log2(VALUE obj, VALUE x)
-{
- double d;
-
- Need_Float(x);
- errno = 0;
- d = log2(RFLOAT_VALUE(x));
- if (errno) {
- rb_sys_fail("log2");
- }
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
@@ -371,15 +349,16 @@ math_log2(VALUE obj, VALUE x)
*/
static VALUE
-math_log10(VALUE obj, VALUE x)
+math_log10(obj, x)
+ VALUE obj, x;
{
double d;
Need_Float(x);
errno = 0;
- d = log10(RFLOAT_VALUE(x));
+ d = log10(RFLOAT(x)->value);
domain_check(d, "log10");
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
@@ -390,15 +369,16 @@ math_log10(VALUE obj, VALUE x)
*/
static VALUE
-math_sqrt(VALUE obj, VALUE x)
+math_sqrt(obj, x)
+ VALUE obj, x;
{
double d;
Need_Float(x);
errno = 0;
- d = sqrt(RFLOAT_VALUE(x));
+ d = sqrt(RFLOAT(x)->value);
domain_check(d, "sqrt");
- return DOUBLE2NUM(d);
+ return rb_float_new(d);
}
/*
@@ -414,15 +394,16 @@ math_sqrt(VALUE obj, VALUE x)
*/
static VALUE
-math_frexp(VALUE obj, VALUE x)
+math_frexp(obj, x)
+ VALUE obj, x;
{
double d;
int exp;
Need_Float(x);
- d = frexp(RFLOAT_VALUE(x), &exp);
- return rb_assoc_new(DOUBLE2NUM(d), INT2NUM(exp));
+ d = frexp(RFLOAT(x)->value, &exp);
+ return rb_assoc_new(rb_float_new(d), INT2NUM(exp));
}
/*
@@ -436,10 +417,11 @@ math_frexp(VALUE obj, VALUE x)
*/
static VALUE
-math_ldexp(VALUE obj, VALUE x, VALUE n)
+math_ldexp(obj, x, n)
+ VALUE obj, x, n;
{
Need_Float(x);
- return DOUBLE2NUM(ldexp(RFLOAT_VALUE(x), NUM2INT(n)));
+ return rb_float_new(ldexp(RFLOAT(x)->value, NUM2INT(n)));
}
/*
@@ -453,10 +435,11 @@ math_ldexp(VALUE obj, VALUE x, VALUE n)
*/
static VALUE
-math_hypot(VALUE obj, VALUE x, VALUE y)
+math_hypot(obj, x, y)
+ VALUE obj, x, y;
{
Need_Float2(x, y);
- return DOUBLE2NUM(hypot(RFLOAT_VALUE(x), RFLOAT_VALUE(y)));
+ return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
}
/*
@@ -467,10 +450,11 @@ math_hypot(VALUE obj, VALUE x, VALUE y)
*/
static VALUE
-math_erf(VALUE obj, VALUE x)
+math_erf(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(erf(RFLOAT_VALUE(x)));
+ return rb_float_new(erf(RFLOAT(x)->value));
}
/*
@@ -481,10 +465,11 @@ math_erf(VALUE obj, VALUE x)
*/
static VALUE
-math_erfc(VALUE obj, VALUE x)
+math_erfc(obj, x)
+ VALUE obj, x;
{
Need_Float(x);
- return DOUBLE2NUM(erfc(RFLOAT_VALUE(x)));
+ return rb_float_new(erfc(RFLOAT(x)->value));
}
/*
@@ -496,20 +481,20 @@ math_erfc(VALUE obj, VALUE x)
void
-Init_Math(void)
+Init_Math()
{
rb_mMath = rb_define_module("Math");
#ifdef M_PI
- rb_define_const(rb_mMath, "PI", DOUBLE2NUM(M_PI));
+ rb_define_const(rb_mMath, "PI", rb_float_new(M_PI));
#else
- rb_define_const(rb_mMath, "PI", DOUBLE2NUM(atan(1.0)*4.0));
+ rb_define_const(rb_mMath, "PI", rb_float_new(atan(1.0)*4.0));
#endif
#ifdef M_E
- rb_define_const(rb_mMath, "E", DOUBLE2NUM(M_E));
+ rb_define_const(rb_mMath, "E", rb_float_new(M_E));
#else
- rb_define_const(rb_mMath, "E", DOUBLE2NUM(exp(1.0)));
+ rb_define_const(rb_mMath, "E", rb_float_new(exp(1.0)));
#endif
rb_define_module_function(rb_mMath, "atan2", math_atan2, 2);
@@ -530,8 +515,7 @@ Init_Math(void)
rb_define_module_function(rb_mMath, "atanh", math_atanh, 1);
rb_define_module_function(rb_mMath, "exp", math_exp, 1);
- rb_define_module_function(rb_mMath, "log", math_log, -1);
- rb_define_module_function(rb_mMath, "log2", math_log2, 1);
+ rb_define_module_function(rb_mMath, "log", math_log, 1);
rb_define_module_function(rb_mMath, "log10", math_log10, 1);
rb_define_module_function(rb_mMath, "sqrt", math_sqrt, 1);
diff --git a/misc/README b/misc/README
index c7e63d7799..12646ac819 100644
--- a/misc/README
+++ b/misc/README
@@ -4,4 +4,5 @@ ruby-mode.el ruby mode for emacs
rubydb2x.el ruby debugger support for emacs 19.2x or before
rubydb3x.el ruby debugger support for emacs 19.3x or later
ruby-electric.el emacs minor mode providing electric commands
-rdebug.el ruby-debug (rdebug) support for emacs 19.3x or later
+
+Check out http://rubyforge.org/projects/ruby-debug/ also.
diff --git a/misc/rdebug.el b/misc/rdebug.el
deleted file mode 100644
index 81ab0071a0..0000000000
--- a/misc/rdebug.el
+++ /dev/null
@@ -1,136 +0,0 @@
-;; This file adds support for ruby-debug (rdebug) in Emacs.
-;; Copyright (C) 2007 Martin Nordholts <enselic@gmail.com>
-;;
-;; This file is based on 'rubydb3x.el' that comes with Ruby which is
-;; Copyright (C) Yukihiro Matsumoto aka Matz
-;;
-;; Installation:
-;; -------------
-;;
-;; 1. Make sure you have ruby-debug on your system (test by running
-;; the commmand 'rdebug -v' in a shell).
-;;
-;; 2. Copy this file into e.g. ~/.elisp and make sure this is in
-;; your ~/.emacs:
-;;
-;; (add-to-list 'load-path "~/.elisp")
-;; (load-library "rdebug")
-;;
-;; you can then start the debugger with M-x rdebug
-;;
-;; 3. Setup convenient keybindings etc. This is what I have:
-;;
-;; (global-set-key [f9] 'gud-step)
-;; (global-set-key [f10] 'gud-next)
-;; (global-set-key [f11] 'gud-cont)
-;;
-;; (global-set-key "\C-c\C-d" 'rdebug)
-;;
-;; 4. Debug like crazy!
-;;
-;; Bugs:
-;; -----
-;;
-;; Basic functionality works fine, though there might be a bug hiding somewhere.
-
-(require 'gud)
-(provide 'rdebug)
-
-;; ======================================================================
-;; rdebug functions
-
-;;; History of argument lists passed to rdebug.
-(defvar gud-rdebug-history nil)
-
-(if (fboundp 'gud-overload-functions)
- (defun gud-rdebug-massage-args (file args)
- (cons file args))
- (defun gud-rdebug-massage-args (file args)
- args))
-
-;; There's no guarantee that Emacs will hand the filter the entire
-;; marker at once; it could be broken up across several strings. We
-;; might even receive a big chunk with several markers in it. If we
-;; receive a chunk of text which looks like it might contain the
-;; beginning of a marker, we save it here between calls to the
-;; filter.
-(defvar gud-rdebug-marker-acc "")
-(make-variable-buffer-local 'gud-rdebug-marker-acc)
-
-(defun gud-rdebug-marker-filter (string)
- (setq gud-rdebug-marker-acc (concat gud-rdebug-marker-acc string))
- (let ((output ""))
-
- ;; Process all the complete markers in this chunk.
- (while (string-match "\\([^:\n]*\\):\\([0-9]+\\):.*\n"
- gud-rdebug-marker-acc)
- (setq
-
- ;; Extract the frame position from the marker.
- gud-last-frame
- (cons (substring gud-rdebug-marker-acc (match-beginning 1) (match-end 1))
- (string-to-int (substring gud-rdebug-marker-acc
- (match-beginning 2)
- (match-end 2))))
-
-
- ;; Append any text before the marker to the output we're going
- ;; to return - we don't include the marker in this text.
- output (concat output
- (substring gud-rdebug-marker-acc 0 (match-beginning 0)))
-
- ;; Set the accumulator to the remaining text.
- gud-rdebug-marker-acc (substring gud-rdebug-marker-acc (match-end 0))))
-
- (setq output (concat output gud-rdebug-marker-acc)
- gud-rdebug-marker-acc "")
-
- output))
-
-(defun gud-rdebug-find-file (f)
- (save-excursion
- (let ((buf (find-file-noselect f)))
- (set-buffer buf)
-;; (gud-make-debug-menu)
- buf)))
-
-(defvar rdebug-command-name "rdebug"
- "File name for executing rdebug.")
-
-;;;###autoload
-(defun rdebug (command-line)
- "Run rdebug on program FILE in buffer *gud-FILE*.
-The directory containing FILE becomes the initial working directory
-and source-file directory for your debugger."
- (interactive
- (list (read-from-minibuffer "Run rdebug (like this): "
- (if (consp gud-rdebug-history)
- (car gud-rdebug-history)
- (concat rdebug-command-name " "))
- nil nil
- '(gud-rdebug-history . 1))))
-
- (if (not (fboundp 'gud-overload-functions))
- (gud-common-init command-line 'gud-rdebug-massage-args
- 'gud-rdebug-marker-filter 'gud-rdebug-find-file)
- (gud-overload-functions '((gud-massage-args . gud-rdebug-massage-args)
- (gud-marker-filter . gud-rdebug-marker-filter)
- (gud-find-file . gud-rdebug-find-file)))
- (gud-common-init command-line rdebug-command-name))
-
- (gud-def gud-break "break %d%f:%l" "\C-b" "Set breakpoint at current line in current file.")
-; (gud-def gud-remove "delete %d%f:%l" "\C-d" "Remove breakpoint at current line in current file.")
- (gud-def gud-step "step" "\C-s" "Step one source line with display.")
- (gud-def gud-next "next" "\C-n" "Step one line (skip functions).")
- (gud-def gud-cont "cont" "\C-r" "Continue with display.")
- (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
- (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
- (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
- (gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
-
- (setq comint-prompt-regexp "^(rdb:-) ")
- (if (boundp 'comint-last-output-start)
- (set-marker comint-last-output-start (point)))
- (set (make-local-variable 'paragraph-start) comint-prompt-regexp)
- (run-hooks 'rdebug-mode-hook)
- )
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index bc7284a94f..90204d0812 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -255,7 +255,12 @@ The variable ruby-indent-level controls the amount of indentation.
(make-local-variable 'add-log-current-defun-function)
(setq add-log-current-defun-function 'ruby-add-log-current-method)
- (run-hooks 'ruby-mode-hook))
+ (set (make-local-variable 'font-lock-defaults) '((ruby-font-lock-keywords) nil nil))
+ (set (make-local-variable 'font-lock-keywords) ruby-font-lock-keywords)
+ (set (make-local-variable 'font-lock-syntax-table) ruby-font-lock-syntax-table)
+ (set (make-local-variable 'font-lock-syntactic-keywords) ruby-font-lock-syntactic-keywords)
+
+ (run-mode-hooks 'ruby-mode-hook))
(defun ruby-current-indentation ()
(save-excursion
@@ -728,19 +733,15 @@ The variable ruby-indent-level controls the amount of indentation.
(not (looking-at (concat "\\<\\(" ruby-block-hanging-re "\\)\\>")))
(eq (ruby-deep-indent-paren-p t) 'space)
(not (bobp)))
- (widen)
- (goto-char (or begin parse-start))
- (skip-syntax-forward " ")
- (current-column))
+ (save-excursion
+ (widen)
+ (goto-char (or begin parse-start))
+ (skip-syntax-forward " ")
+ (current-column)))
((car (nth 1 state)) indent)
(t
(+ indent ruby-indent-level))))))))
- (goto-char indent-point)
- (beginning-of-line)
- (skip-syntax-forward " ")
- (if (looking-at "\\.[^.]")
- (+ indent ruby-indent-level)
- indent))))
+ indent)))
(defun ruby-electric-brace (arg)
(interactive "P")
@@ -1024,24 +1025,13 @@ balanced expression is found."
("^\\(=\\)begin\\(\\s \\|$\\)" 1 (7 . nil))
("^\\(=\\)end\\(\\s \\|$\\)" 1 (7 . nil))))
- (cond ((featurep 'xemacs)
- (put 'ruby-mode 'font-lock-defaults
- '((ruby-font-lock-keywords)
- nil nil nil
- beginning-of-line
- (font-lock-syntactic-keywords
- . ruby-font-lock-syntactic-keywords))))
- (t
- (add-hook 'ruby-mode-hook
- '(lambda ()
- (make-local-variable 'font-lock-defaults)
- (make-local-variable 'font-lock-keywords)
- (make-local-variable 'font-lock-syntax-table)
- (make-local-variable 'font-lock-syntactic-keywords)
- (setq font-lock-defaults '((ruby-font-lock-keywords) nil nil))
- (setq font-lock-keywords ruby-font-lock-keywords)
- (setq font-lock-syntax-table ruby-font-lock-syntax-table)
- (setq font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)))))
+ (if (featurep 'xemacs)
+ (put 'ruby-mode 'font-lock-defaults
+ '((ruby-font-lock-keywords)
+ nil nil nil
+ beginning-of-line
+ (font-lock-syntactic-keywords
+ . ruby-font-lock-syntactic-keywords))))
(defun ruby-font-lock-docs (limit)
(if (re-search-forward "^=begin\\(\\s \\|$\\)" limit t)
diff --git a/misc/ruby-style.el b/misc/ruby-style.el
index 6591581103..ef05ea004a 100644
--- a/misc/ruby-style.el
+++ b/misc/ruby-style.el
@@ -4,12 +4,11 @@
;;;
;;; C/C++ mode style for Ruby.
;;;
-;;; $Author$
-;;; $Date$
+;;; $Author: nobu $
;;; created at: Thu Apr 26 13:54:01 JST 2007
;;;
-(defconst ruby-style-revision "$Revision$"
+(defconst ruby-style-revision "$Revision: 15588 $"
"Ruby style revision string.")
(defconst ruby-style-version
@@ -28,7 +27,7 @@
(defun ruby-style-label-indent (x)
(save-excursion
(unless (progn (backward-up-list) (back-to-indentation)
- (> (point) (cdr x)))
+ (>= (point) (cdr x)))
(goto-char (cdr x))
(condition-case ()
(progn
diff --git a/missing.h b/missing.h
new file mode 100644
index 0000000000..6eda516527
--- /dev/null
+++ b/missing.h
@@ -0,0 +1,142 @@
+/************************************************
+
+ missing.h - prototype for *.c in ./missing, and
+ for missing timeval struct
+
+ $Author$
+ $Date$
+ created at: Sat May 11 23:46:03 JST 2002
+
+************************************************/
+
+#ifndef MISSING_H
+#define MISSING_H
+
+#if defined(HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#elif !defined(_WIN32)
+# define time_t long
+struct timeval {
+ time_t tv_sec; /* seconds */
+ time_t tv_usec; /* microseconds */
+};
+#endif
+#if defined(HAVE_SYS_TYPES_H)
+# include <sys/types.h>
+#endif
+
+#ifndef HAVE_ACOSH
+extern double acosh _((double));
+extern double asinh _((double));
+extern double atanh _((double));
+#endif
+
+#ifndef HAVE_CRYPT
+extern char *crypt _((const char *, const char *));
+#endif
+
+#ifndef HAVE_DUP2
+extern int dup2 _((int, int));
+#endif
+
+#ifndef HAVE_EACCESS
+extern int eaccess _((const char*, int));
+#endif
+
+#ifndef HAVE_FINITE
+extern int finite _((double));
+#endif
+
+#ifndef HAVE_FLOCK
+extern int flock _((int, int));
+#endif
+
+/*
+#ifndef HAVE_FREXP
+extern double frexp _((double, int *));
+#endif
+*/
+
+#ifndef HAVE_HYPOT
+extern double hypot _((double, double));
+#endif
+
+#ifndef HAVE_ERF
+extern double erf _((double));
+extern double erfc _((double));
+#endif
+
+#ifndef HAVE_ISINF
+# if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
+# define isinf(x) (!finite(x) && !isnan(x))
+# else
+extern int isinf _((double));
+# endif
+#endif
+
+#ifndef HAVE_ISNAN
+extern int isnan _((double));
+#endif
+
+/*
+#ifndef HAVE_MEMCMP
+extern int memcmp _((char *, char *, int));
+#endif
+*/
+
+#ifndef HAVE_MEMMOVE
+extern void *memmove _((void *, void *, int));
+#endif
+
+/*
+#ifndef HAVE_MODF
+extern double modf _((double, double *));
+#endif
+*/
+
+#ifndef HAVE_STRCASECMP
+extern int strcasecmp _((char *, char *));
+#endif
+
+#ifndef HAVE_STRNCASECMP
+extern int strncasecmp _((char *, char *, int));
+#endif
+
+#ifndef HAVE_STRCHR
+extern char *strchr _((char *, int));
+extern char *strrchr _((char *, int));
+#endif
+
+#ifndef HAVE_STRERROR
+extern char *strerror _((int));
+#endif
+
+#ifndef HAVE_STRFTIME
+extern size_t strftime _((char *, size_t, const char *, const struct tm *));
+#endif
+
+#ifndef HAVE_STRSTR
+extern char *strstr _((char *, char *));
+#endif
+
+/*
+#ifndef HAVE_STRTOL
+extern long strtol _((char *, char **, int));
+#endif
+*/
+
+#ifndef HAVE_STRTOUL
+extern unsigned long strtoul _((char *, char **, int));
+#endif
+
+#ifndef HAVE_VSNPRINTF
+# ifdef HAVE_STDARG_PROTOTYPES
+# include <stdarg.h>
+# else
+# include <varargs.h>
+# endif
+extern int snprintf __((char *, size_t n, char const *, ...));
+extern int vsnprintf _((char *, size_t n, char const *, va_list));
+#endif
+
+#endif /* MISSING_H */
diff --git a/missing/acosh.c b/missing/acosh.c
index 59f4af9248..a4443e191f 100644
--- a/missing/acosh.c
+++ b/missing/acosh.c
@@ -33,7 +33,8 @@
#ifndef HAVE_ACOSH
double
-acosh(double x)
+acosh(x)
+ double x;
{
if (x < 1)
x = -1; /* NaN */
@@ -49,7 +50,8 @@ acosh(double x)
#ifndef HAVE_ASINH
double
-asinh(double x)
+asinh(x)
+ double x;
{
int neg = x < 0;
double z = fabs(x);
@@ -72,7 +74,8 @@ asinh(double x)
#ifndef HAVE_ATANH
double
-atanh(double x)
+atanh(x)
+ double x;
{
int neg = x < 0;
double z = fabs(x);
diff --git a/missing/alloca.c b/missing/alloca.c
index 067f76b183..39697f114a 100644
--- a/missing/alloca.c
+++ b/missing/alloca.c
@@ -29,7 +29,7 @@
static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */
#endif
-#include "ruby/config.h"
+#include "config.h"
#ifdef emacs
#ifdef static
/* actually, only want this if static is defined as ""
diff --git a/missing/crypt.c b/missing/crypt.c
index 486df5050b..32736bccfb 100644
--- a/missing/crypt.c
+++ b/missing/crypt.c
@@ -107,13 +107,15 @@ static char sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93";
#define LARGEDATA
#endif
+int des_setkey(), des_cipher();
+
/* compile with "-DSTATIC=int" when profiling */
#ifndef STATIC
#define STATIC static
#endif
-STATIC init_des(), init_perm(), permute();
+STATIC void init_des(), init_perm(), permute();
#ifdef DEBUG
-STATIC prtab();
+STATIC void prtab();
#endif
/* ==================================== */
@@ -299,7 +301,7 @@ typedef union {
#define PERM3264(d,d0,d1,cpp,p) \
{ C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); }
-STATIC
+STATIC void
permute(cp, out, p, chars_in)
unsigned char *cp;
C_block *out;
@@ -377,46 +379,62 @@ static unsigned char PC2[] = { /* permuted choice table 2 */
};
static unsigned char S[8][64] = { /* 48->32 bit substitution tables */
+ {
/* S[1] */
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
+ },
+ {
/* S[2] */
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
+ },
+ {
/* S[3] */
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
+ },
+ {
/* S[4] */
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
+ },
+ {
/* S[5] */
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
+ },
+ {
/* S[6] */
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
+ },
+ {
/* S[7] */
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
+ },
+ {
/* S[8] */
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
+ },
};
static unsigned char P32Tr[] = { /* 32-bit permutation function */
@@ -580,6 +598,7 @@ static C_block KS[KS_SIZE];
/*
* Set up the key schedule from the key.
*/
+int
des_setkey(key)
register const char *key;
{
@@ -614,6 +633,7 @@ des_setkey(key)
* NOTE: the performance of this routine is critically dependent on your
* compiler and machine architecture.
*/
+int
des_cipher(in, out, salt, num_iter)
const char *in;
char *out;
@@ -734,7 +754,7 @@ des_cipher(in, out, salt, num_iter)
* Initialize various tables. This need only be done once. It could even be
* done at compile time, if the compiler were capable of that sort of thing.
*/
-STATIC
+STATIC void
init_des()
{
register int i, j;
@@ -878,7 +898,7 @@ init_des()
*
* "perm" must be all-zeroes on entry to this routine.
*/
-STATIC
+STATIC void
init_perm(perm, p, chars_in, chars_out)
C_block perm[64/CHUNKBITS][1<<CHUNKBITS];
unsigned char p[64];
@@ -902,6 +922,7 @@ init_perm(perm, p, chars_in, chars_out)
/*
* "setkey" routine (for backwards compatibility)
*/
+int
setkey(key)
register const char *key;
{
@@ -922,6 +943,7 @@ setkey(key)
/*
* "encrypt" routine (for backwards compatibility)
*/
+int
encrypt(block, flag)
register char *block;
int flag;
@@ -950,7 +972,7 @@ encrypt(block, flag)
}
#ifdef DEBUG
-STATIC
+STATIC void
prtab(s, t, num_rows)
char *s;
unsigned char *t;
diff --git a/missing/dup2.c b/missing/dup2.c
index 7554084c5d..e7cc46f4c1 100644
--- a/missing/dup2.c
+++ b/missing/dup2.c
@@ -11,7 +11,7 @@
* Return fd2 if all went well; return BADEXIT otherwise.
*/
-#include "ruby/config.h"
+#include "config.h"
#if defined(HAVE_FCNTL)
# include <fcntl.h>
@@ -24,7 +24,8 @@
#define BADEXIT -1
int
-dup2(int fd1, int fd2)
+dup2(fd1, fd2)
+int fd1, fd2;
{
#if defined(HAVE_FCNTL) && defined(F_DUPFD)
if (fd1 != fd2) {
diff --git a/missing/erf.c b/missing/erf.c
index fe65b9a479..d9e7469024 100644
--- a/missing/erf.c
+++ b/missing/erf.c
@@ -25,7 +25,8 @@ static double q_gamma(double, double, double);
/* Incomplete gamma function
1 / Gamma(a) * Int_0^x exp(-t) t^(a-1) dt */
-static double p_gamma(double a, double x, double loggamma_a)
+static double p_gamma(a, x, loggamma_a)
+ double a, x, loggamma_a;
{
int k;
double result, term, previous;
@@ -44,7 +45,8 @@ static double p_gamma(double a, double x, double loggamma_a)
/* Incomplete gamma function
1 / Gamma(a) * Int_x^inf exp(-t) t^(a-1) dt */
-static double q_gamma(double a, double x, double loggamma_a)
+static double q_gamma(a, x, loggamma_a)
+ double a, x, loggamma_a;
{
int k;
double result, w, temp, previous;
@@ -67,7 +69,8 @@ static double q_gamma(double a, double x, double loggamma_a)
#define LOG_PI_OVER_2 0.572364942924700087071713675675 /* log_e(PI)/2 */
-double erf(double x)
+double erf(x)
+ double x;
{
if (!finite(x)) {
if (isnan(x)) return x; /* erf(NaN) = NaN */
@@ -77,7 +80,8 @@ double erf(double x)
else return - p_gamma(0.5, x * x, LOG_PI_OVER_2);
}
-double erfc(double x)
+double erfc(x)
+ double x;
{
if (!finite(x)) {
if (isnan(x)) return x; /* erfc(NaN) = NaN */
diff --git a/missing/finite.c b/missing/finite.c
index 8d0b7af262..f91035a8cd 100644
--- a/missing/finite.c
+++ b/missing/finite.c
@@ -1,7 +1,8 @@
/* public domain rewrite of finite(3) */
int
-finite(double n)
+finite(n)
+ double n;
{
return !isnan(n) && !isinf(n);
}
diff --git a/missing/flock.c b/missing/flock.c
index b02f8bf832..5f6b41c357 100644
--- a/missing/flock.c
+++ b/missing/flock.c
@@ -1,4 +1,4 @@
-#include "ruby/config.h"
+#include "config.h"
#if defined _WIN32
#elif defined HAVE_FCNTL && defined HAVE_FCNTL_H
@@ -24,7 +24,9 @@
#include <errno.h>
int
-flock(int fd, int operation)
+flock(fd, operation)
+ int fd;
+ int operation;
{
struct flock lock;
@@ -89,7 +91,9 @@ flock(int fd, int operation)
# endif
int
-flock(int fd, int operation)
+flock(fd, operation)
+ int fd;
+ int operation;
{
switch (operation) {
@@ -121,7 +125,9 @@ flock(int fd, int operation)
}
#else
int
-flock(int fd, int operation)
+flock(fd, operation)
+ int fd;
+ int operation;
{
rb_notimplement();
return -1;
diff --git a/missing/hypot.c b/missing/hypot.c
index 5a663553cf..aad5259e92 100644
--- a/missing/hypot.c
+++ b/missing/hypot.c
@@ -2,7 +2,8 @@
#include <math.h>
-double hypot(double x, double y)
+double hypot(x,y)
+ double x, y;
{
if (x < 0) x = -x;
if (y < 0) y = -y;
diff --git a/missing/isinf.c b/missing/isinf.c
index 4aef51b213..c9e49c6795 100644
--- a/missing/isinf.c
+++ b/missing/isinf.c
@@ -6,7 +6,8 @@
#include <nan.h>
int
-isinf(double n)
+isinf(n)
+ double n;
{
if (IsNANorINF(n) && IsINF(n)) {
return 1;
@@ -18,7 +19,7 @@ isinf(double n)
#else
-#include "ruby/config.h"
+#include "config.h"
#if defined(HAVE_FINITE) && defined(HAVE_ISNAN)
@@ -34,7 +35,8 @@ isinf(double n)
*/
#ifndef isinf
int
-isinf(double n)
+isinf(n)
+ double n;
{
return (!finite(n) && !isnan(n));
}
@@ -48,12 +50,13 @@ isinf(double n)
# include <strings.h>
#endif
-static double zero(void) { return 0.0; }
-static double one (void) { return 1.0; }
-static double inf (void) { return one() / zero(); }
+static double zero() { return 0.0; }
+static double one() { return 1.0; }
+static double inf() { return one() / zero(); }
int
-isinf(double n)
+isinf(n)
+ double n;
{
static double pinf = 0.0;
static double ninf = 0.0;
diff --git a/missing/isnan.c b/missing/isnan.c
index a8733978ad..459048e936 100644
--- a/missing/isnan.c
+++ b/missing/isnan.c
@@ -1,15 +1,17 @@
/* public domain rewrite of isnan(3) */
-static int double_ne(double n1, double n2);
+static int double_ne();
int
-isnan(double n)
+isnan(n)
+ double n;
{
return double_ne(n, n);
}
static int
-double_ne(double n1, double n2)
+double_ne(n1, n2)
+ double n1, n2;
{
return n1 != n2;
}
diff --git a/missing/memcmp.c b/missing/memcmp.c
index 5b3ad3817a..9edc9c13b9 100644
--- a/missing/memcmp.c
+++ b/missing/memcmp.c
@@ -1,15 +1,16 @@
/* public domain rewrite of memcmp(3) */
-#include <stddef.h>
-
int
-memcmp(const void *s1, const void *s2, size_t len)
+memcmp(s1,s2,len)
+ char *s1;
+ char *s2;
+ register int len;
{
register unsigned char *a = (unsigned char*)s1;
register unsigned char *b = (unsigned char*)s2;
register int tmp;
- for (; len; --len) {
+ while (len--) {
if (tmp = *a++ - *b++)
return tmp;
}
diff --git a/missing/memmove.c b/missing/memmove.c
index 19c5f18847..c9d67d8b45 100644
--- a/missing/memmove.c
+++ b/missing/memmove.c
@@ -1,21 +1,22 @@
/* public domain rewrite of memcmp(3) */
-#include <stddef.h>
-
void *
-memmove(void *d, const void *s, size_t n)
+memmove (d, s, n)
+ void *d, *s;
+ int n;
{
- char *dst = (char *)d;
- const char *src = (const char *)s;
+ char *dst = d;
+ char *src = s;
+ void *ret = dst;
if (src < dst) {
src += n;
dst += n;
- for (; n; --n)
+ while (n--)
*--dst = *--src;
}
else if (dst < src)
- for (; n; --n)
+ while (n--)
*dst++ = *src++;
- return d;
+ return ret;
}
diff --git a/missing/os2.c b/missing/os2.c
index 3448cdc281..fe7238aad1 100644
--- a/missing/os2.c
+++ b/missing/os2.c
@@ -17,36 +17,11 @@ chown(char *path, int owner, int group)
return 0;
}
-#if 0
int
link(char *from, char *to)
{
return -1;
}
-#endif
-
-#if defined(EMX_REPLACE_GETCWD) && (EMX_REPLACE_GETCWD) \
- || defined(EMX_REPLACE_CHDIR) && (EMX_REPLACE_CHDIR)
-#include <unistd.h>
-
-#if defined(EMX_REPLACE_GETCWD) && (EMX_REPLACE_GETCWD)
-/* to handle the drive letter and DBCS characters within a given path */
-char *
-getcwd(char *path, size_t len)
-{
- return _getcwd2(path, (int)len);
-}
-#endif
-
-#if defined(EMX_REPLACE_CHDIR) && (EMX_REPLACE_CHDIR)
-/* to handle the drive letter and DBCS characters within a given path */
-int
-chdir(__const__ char *path)
-{
- return _chdir2(path);
-}
-#endif
-#endif
typedef char* CHARP;
diff --git a/missing/strcasecmp.c b/missing/strcasecmp.c
index 1ce20704c1..fddb8385be 100644
--- a/missing/strcasecmp.c
+++ b/missing/strcasecmp.c
@@ -3,7 +3,8 @@
#include <ctype.h>
int
-strcasecmp(const char *p1, const char *p2)
+strcasecmp(p1, p2)
+ char *p1, *p2;
{
while (*p1 && *p2) {
if (toupper(*p1) != toupper(*p2))
diff --git a/missing/strchr.c b/missing/strchr.c
index bebd7ba578..886d70ede6 100644
--- a/missing/strchr.c
+++ b/missing/strchr.c
@@ -1,28 +1,32 @@
/* public domain rewrite of strchr(3) and strrchr(3) */
char *
-strchr(const char *s, int c)
+strchr(s, c)
+ char *s;
+ int c;
{
- if (c == 0) return (char *)s + strlen(s);
+ if (c == 0) return s + strlen(s);
while (*s) {
if (*s == c)
- return (char *)s;
+ return s;
s++;
}
return 0;
}
char *
-strrchr(const char *s, int c)
+strrchr(s, c)
+ char *s;
+ int c;
{
- const char *save;
+ char *save;
- if (c == 0) return (char *)s + strlen(s);
+ if (c == 0) return s + strlen(s);
save = 0;
while (*s) {
if (*s == c)
save = s;
s++;
}
- return (char *)save;
+ return save;
}
diff --git a/missing/strerror.c b/missing/strerror.c
index 023935a1ff..c1bf6feff8 100644
--- a/missing/strerror.c
+++ b/missing/strerror.c
@@ -6,7 +6,8 @@ extern char *sys_errlist[];
static char msg[50];
char *
-strerror(int error)
+strerror(error)
+ int error;
{
if (error <= sys_nerr && error > 0) {
return sys_errlist[error];
diff --git a/missing/strftime.c b/missing/strftime.c
index a4e780447e..caa5eb8719 100644
--- a/missing/strftime.c
+++ b/missing/strftime.c
@@ -45,7 +45,7 @@
* January 1996
*/
-#include "ruby/config.h"
+#include "config.h"
#ifndef GAWK
#include <stdio.h>
diff --git a/missing/strlcat.c b/missing/strlcat.c
deleted file mode 100644
index b309648155..0000000000
--- a/missing/strlcat.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* $OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``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 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Appends src to string dst of size siz (unlike strncat, siz is the
- * full size of dst, not space left). At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
- * Returns strlen(src) + MIN(siz, strlen(initial dst)).
- * If retval >= siz, truncation occurred.
- */
-size_t
-strlcat(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (n-- != 0 && *d != '\0')
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
-
- return(dlen + (s - src)); /* count does not include NUL */
-}
diff --git a/missing/strlcpy.c b/missing/strlcpy.c
deleted file mode 100644
index 5f586964b7..0000000000
--- a/missing/strlcpy.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``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 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t
-strlcpy(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
diff --git a/missing/strncasecmp.c b/missing/strncasecmp.c
index 59d4477a40..a4cc5828b8 100644
--- a/missing/strncasecmp.c
+++ b/missing/strncasecmp.c
@@ -1,10 +1,12 @@
/* public domain rewrite of strncasecmp(3) */
#include <ctype.h>
-#include <stddef.h>
int
-strncasecmp(const char *p1, const char *p2, size_t len)
+strncasecmp(p1, p2, len)
+ char *p1;
+ char *p2;
+ int len;
{
while (len != 0) {
if (toupper(*p1) != toupper(*p2)) {
diff --git a/missing/strstr.c b/missing/strstr.c
index 2e9c282fb1..1673518f06 100644
--- a/missing/strstr.c
+++ b/missing/strstr.c
@@ -1,19 +1,20 @@
/* public domain rewrite of strstr(3) */
char *
-strstr(const char *haystack, const char *needle)
+strstr(haystack, needle)
+ char *haystack, *needle;
{
- const char *hend;
- const char *a, *b;
+ char *hend;
+ char *a, *b;
- if (*needle == 0) return (char *)haystack;
+ if (*needle == 0) return haystack;
hend = haystack + strlen(haystack) - strlen(needle) + 1;
while (haystack < hend) {
if (*haystack == *needle) {
a = haystack;
b = needle;
for (;;) {
- if (*b == 0) return (char *)haystack;
+ if (*b == 0) return haystack;
if (*a++ != *b++) {
break;
}
diff --git a/missing/strtod.c b/missing/strtod.c
new file mode 100644
index 0000000000..fdccd48081
--- /dev/null
+++ b/missing/strtod.c
@@ -0,0 +1,271 @@
+/*
+ * strtod.c --
+ *
+ * Source code for the "strtod" library procedure.
+ *
+ * Copyright (c) 1988-1993 The Regents of the University of California.
+ * Copyright (c) 1994 Sun Microsystems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ * RCS: @(#) $Id$
+ */
+
+#include "config.h"
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#include <ctype.h>
+#include <errno.h>
+extern int errno;
+
+#ifndef __STDC__
+# ifdef __GNUC__
+# define const __const__
+# else
+# define const
+# endif
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+#ifndef NULL
+#define NULL 0
+#endif
+
+static int maxExponent = 511; /* Largest possible base 10 exponent. Any
+ * exponent larger than this will already
+ * produce underflow or overflow, so there's
+ * no need to worry about additional digits.
+ */
+static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
+ 10., /* is 10^2^i. Used to convert decimal */
+ 100., /* exponents into floating-point numbers. */
+ 1.0e4,
+ 1.0e8,
+ 1.0e16,
+ 1.0e32,
+ 1.0e64,
+ 1.0e128,
+ 1.0e256
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * strtod --
+ *
+ * This procedure converts a floating-point number from an ASCII
+ * decimal representation to internal double-precision format.
+ *
+ * Results:
+ * The return value is the double-precision floating-point
+ * representation of the characters in string. If endPtr isn't
+ * NULL, then *endPtr is filled in with the address of the
+ * next character after the last one that was part of the
+ * floating-point number.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+double
+strtod(string, endPtr)
+ const char *string; /* A decimal ASCII floating-point number,
+ * optionally preceded by white space.
+ * Must have form "-I.FE-X", where I is the
+ * integer part of the mantissa, F is the
+ * fractional part of the mantissa, and X
+ * is the exponent. Either of the signs
+ * may be "+", "-", or omitted. Either I
+ * or F may be omitted, or both. The decimal
+ * point isn't necessary unless F is present.
+ * The "E" may actually be an "e". E and X
+ * may both be omitted (but not just one).
+ */
+ char **endPtr; /* If non-NULL, store terminating character's
+ * address here. */
+{
+ int sign, expSign = FALSE;
+ double fraction, dblExp, *d;
+ register const char *p;
+ register int c;
+ int exp = 0; /* Exponent read from "EX" field. */
+ int fracExp = 0; /* Exponent that derives from the fractional
+ * part. Under normal circumstatnces, it is
+ * the negative of the number of digits in F.
+ * However, if I is very long, the last digits
+ * of I get dropped (otherwise a long I with a
+ * large negative exponent could cause an
+ * unnecessary overflow on I alone). In this
+ * case, fracExp is incremented one for each
+ * dropped digit. */
+ int mantSize; /* Number of digits in mantissa. */
+ int decPt; /* Number of mantissa digits BEFORE decimal
+ * point. */
+ const char *pExp; /* Temporarily holds location of exponent
+ * in string. */
+
+ /*
+ * Strip off leading blanks and check for a sign.
+ */
+
+ p = string;
+ while (isspace(*p)) {
+ p += 1;
+ }
+ if (*p == '-') {
+ sign = TRUE;
+ p += 1;
+ } else {
+ if (*p == '+') {
+ p += 1;
+ }
+ sign = FALSE;
+ }
+
+ /*
+ * Count the number of digits in the mantissa (including the decimal
+ * point), and also locate the decimal point.
+ */
+
+ decPt = -1;
+ for (mantSize = 0; ; mantSize += 1)
+ {
+ c = *p;
+ if (!isdigit(c)) {
+ if ((c != '.') || (decPt >= 0)) {
+ break;
+ }
+ decPt = mantSize;
+ }
+ p += 1;
+ }
+
+ /*
+ * Now suck up the digits in the mantissa. Use two integers to
+ * collect 9 digits each (this is faster than using floating-point).
+ * If the mantissa has more than 18 digits, ignore the extras, since
+ * they can't affect the value anyway.
+ */
+
+ pExp = p;
+ p -= mantSize;
+ if (decPt < 0) {
+ decPt = mantSize;
+ } else {
+ mantSize -= 1; /* One of the digits was the point. */
+ }
+ if (mantSize > 18) {
+ fracExp = decPt - 18;
+ mantSize = 18;
+ } else {
+ fracExp = decPt - mantSize;
+ }
+ if (mantSize == 0) {
+ fraction = 0.0;
+ p = string;
+ goto done;
+ } else {
+ int frac1, frac2;
+ frac1 = 0;
+ for ( ; mantSize > 9; mantSize -= 1)
+ {
+ c = *p;
+ p += 1;
+ if (c == '.') {
+ c = *p;
+ p += 1;
+ }
+ frac1 = 10*frac1 + (c - '0');
+ }
+ frac2 = 0;
+ for (; mantSize > 0; mantSize -= 1)
+ {
+ c = *p;
+ p += 1;
+ if (c == '.') {
+ c = *p;
+ p += 1;
+ }
+ frac2 = 10*frac2 + (c - '0');
+ }
+ fraction = (1.0e9 * frac1) + frac2;
+ }
+
+ /*
+ * Skim off the exponent.
+ */
+
+ p = pExp;
+ if ((*p == 'E') || (*p == 'e')) {
+ p += 1;
+ if (*p == '-') {
+ expSign = TRUE;
+ p += 1;
+ } else {
+ if (*p == '+') {
+ p += 1;
+ }
+ expSign = FALSE;
+ }
+ while (isdigit(*p)) {
+ exp = exp * 10 + (*p - '0');
+ p += 1;
+ }
+ }
+ if (expSign) {
+ exp = fracExp - exp;
+ } else {
+ exp = fracExp + exp;
+ }
+
+ /*
+ * Generate a floating-point number that represents the exponent.
+ * Do this by processing the exponent one bit at a time to combine
+ * many powers of 2 of 10. Then combine the exponent with the
+ * fraction.
+ */
+
+ if (exp < 0) {
+ expSign = TRUE;
+ exp = -exp;
+ } else {
+ expSign = FALSE;
+ }
+ if (exp > maxExponent) {
+ exp = maxExponent;
+ errno = ERANGE;
+ }
+ dblExp = 1.0;
+ for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {
+ if (exp & 01) {
+ dblExp *= *d;
+ }
+ }
+ if (expSign) {
+ fraction /= dblExp;
+ } else {
+ fraction *= dblExp;
+ }
+
+done:
+ if (endPtr != NULL) {
+ *endPtr = (char *) p;
+ }
+
+ if (sign) {
+ return -fraction;
+ }
+ return fraction;
+}
diff --git a/missing/strtol.c b/missing/strtol.c
index da6636f316..e94aa54ca0 100644
--- a/missing/strtol.c
+++ b/missing/strtol.c
@@ -3,10 +3,13 @@
#include <ctype.h>
long
-strtol(const char *nptr, char **endptr, int base)
+strtol(nptr, endptr, base)
+ char *nptr;
+ char **endptr;
+ int base;
{
long result;
- const char *p = nptr;
+ char *p = nptr;
while (isspace(*p)) {
p++;
@@ -20,7 +23,7 @@ strtol(const char *nptr, char **endptr, int base)
result = strtoul(p, endptr, base);
}
if (endptr != 0 && *endptr == p) {
- *endptr = (char *)nptr;
+ *endptr = nptr;
}
return result;
}
diff --git a/missing/strtoul.c b/missing/strtoul.c
index 4f09f899a1..f16f2ad9cf 100644
--- a/missing/strtoul.c
+++ b/missing/strtoul.c
@@ -21,7 +21,7 @@
* (100 for non-digit characters).
*/
-static const char cvtIn[] = {
+static char cvtIn[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* '0' - '9' */
100, 100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'A' - 'Z' */
@@ -53,22 +53,22 @@ static const char cvtIn[] = {
*/
unsigned long int
-strtoul(
- const char *string, /* String of ASCII digits, possibly
+strtoul(string, endPtr, base)
+ char *string; /* String of ASCII digits, possibly
* preceded by white space. For bases
* greater than 10, either lower- or
* upper-case digits may be used.
*/
- char **endPtr, /* Where to store address of terminating
+ char **endPtr; /* Where to store address of terminating
* character, or NULL. */
- int base) /* Base for conversion. Must be less
+ int base; /* Base for conversion. Must be less
* than 37. If 0, then the base is chosen
* from the leading characters of string:
* "0x" means hex, "0" means octal, anything
* else means decimal.
*/
{
- register const char *p;
+ register char *p;
register unsigned long int result = 0;
register unsigned digit;
int anyDigits = 0;
@@ -177,7 +177,7 @@ strtoul(
}
if (endPtr != 0) {
- *endPtr = (char *)p;
+ *endPtr = p;
}
return result;
diff --git a/missing/vsnprintf.c b/missing/vsnprintf.c
index 3c8b76686a..dd4f75cfd8 100644
--- a/missing/vsnprintf.c
+++ b/missing/vsnprintf.c
@@ -65,14 +65,8 @@
#define u_short unsigned short
#define u_int unsigned int
-#if !defined(HAVE_STDARG_PROTOTYPES)
-#if defined(__STDC__)
-#define HAVE_STDARG_PROTOTYPES 1
-#endif
-#endif
-
#undef __P
-#if defined(HAVE_STDARG_PROTOTYPES)
+#if defined(__STDC__)
# include <stdarg.h>
# if !defined(__P)
# define __P(x) x
@@ -111,13 +105,6 @@
#endif /* People who don't like const sys_error */
#include <stddef.h>
-#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC)
-#include <string.h>
-#endif
-
-#if !defined(__CYGWIN32__) && defined(__hpux) && !defined(__GNUC__)
-#include <stdlib.h>
-#endif
#ifndef NULL
#define NULL 0
@@ -164,15 +151,12 @@ struct __sbuf {
*/
typedef struct __sFILE {
unsigned char *_p; /* current position in (some) buffer */
-#if 0
int _r; /* read space left for getc() */
-#endif
int _w; /* write space left for putc() */
short _flags; /* flags, below; this FILE is free if 0 */
short _file; /* fileno, if Unix descriptor, else -1 */
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
int _lbfsize; /* 0 or -_bf._size, for inline putc */
- int (*vwrite)(/* struct __sFILE*, struct __suio * */);
} FILE;
@@ -201,9 +185,6 @@ typedef struct __sFILE {
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
#define __sfileno(p) ((p)->_file)
-#undef feof
-#undef ferror
-#undef clearerr
#define feof(p) __sfeof(p)
#define ferror(p) __sferror(p)
#define clearerr(p) __sclearerr(p)
@@ -213,6 +194,10 @@ typedef struct __sFILE {
#endif
+#if defined(__hpux) && !defined(__GNUC__) || defined(__DECC)
+#include <string.h>
+#endif
+
/*
* I/O descriptors for __sfvwrite().
*/
@@ -226,14 +211,13 @@ struct __suio {
int uio_resid;
};
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_SNPRINTF)
/*
* Write some memory regions. Return zero on success, EOF on error.
*
* This routine is large and unsightly, but most of the ugliness due
* to the three different kinds of output buffering is handled here.
*/
-static int BSD__sfvwrite(fp, uio)
+static BSD__sfvwrite(fp, uio)
register FILE *fp;
register struct __suio *uio;
{
@@ -300,8 +284,11 @@ static int BSD__sfvwrite(fp, uio)
*/
}
return (0);
+
+err:
+ fp->_flags |= __SERR;
+ return (EOF);
}
-#endif
/*
* Actual printf innards.
@@ -309,12 +296,18 @@ static int BSD__sfvwrite(fp, uio)
* This code is large and complicated...
*/
+#if !defined(__CYGWIN32__) && defined(__hpux) && !defined(__GNUC__)
+#include <stdlib.h>
+#endif
+
/*
* Flush out all the vectors defined by the given uio,
* then reset it so that it can be reused.
*/
static int
-BSD__sprint(FILE *fp, register struct __suio *uio)
+BSD__sprint(fp, uio)
+ FILE *fp;
+ register struct __suio *uio;
{
register int err;
@@ -322,7 +315,7 @@ BSD__sprint(FILE *fp, register struct __suio *uio)
uio->uio_iovcnt = 0;
return (0);
}
- err = (*fp->vwrite)(fp, uio);
+ err = BSD__sfvwrite(fp, uio);
uio->uio_resid = 0;
uio->uio_iovcnt = 0;
return (err);
@@ -335,7 +328,10 @@ BSD__sprint(FILE *fp, register struct __suio *uio)
* worries about ungetc buffers and so forth.
*/
static int
-BSD__sbprintf(register FILE *fp, const char *fmt, va_list ap)
+BSD__sbprintf(fp, fmt, ap)
+ register FILE *fp;
+ const char *fmt;
+ va_list ap;
{
/* We don't support files. */
return 0;
@@ -349,72 +345,6 @@ BSD__sbprintf(register FILE *fp, const char *fmt, va_list ap)
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
#define to_char(n) ((n) + '0')
-#ifdef _HAVE_SANE_QUAD_
-/*
- * Convert an unsigned long long to ASCII for printf purposes, returning
- * a pointer to the first character of the string representation.
- * Octal numbers can be forced to have a leading zero; hex numbers
- * use the given digits.
- */
-static char *
-BSD__uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs)
-{
- register char *cp = endp;
- register long sval;
-
- /*
- * Handle the three cases separately, in the hope of getting
- * better/faster code.
- */
- switch (base) {
- case 10:
- if (val < 10) { /* many numbers are 1 digit */
- *--cp = to_char(val);
- return (cp);
- }
- /*
- * On many machines, unsigned arithmetic is harder than
- * signed arithmetic, so we do at most one unsigned mod and
- * divide; this is sufficient to reduce the range of
- * the incoming value to where signed arithmetic works.
- */
- if (val > LLONG_MAX) {
- *--cp = to_char(val % 10);
- sval = val / 10;
- } else
- sval = val;
- do {
- *--cp = to_char(sval % 10);
- sval /= 10;
- } while (sval != 0);
- break;
-
- case 8:
- do {
- *--cp = to_char(val & 7);
- val >>= 3;
- } while (val);
- if (octzero && *cp != '0')
- *--cp = '0';
- break;
-
- case 16:
- do {
- *--cp = xdigs[val & 15];
- val >>= 4;
- } while (val);
- break;
-
- default: /* oops */
- /*
- abort();
- */
- break; /* fjc 7-31-97. Don't reference abort() here */
- }
- return (cp);
-}
-#endif /* _HAVE_SANE_QUAD_ */
-
/*
* Convert an unsigned long to ASCII for printf purposes, returning
* a pointer to the first character of the string representation.
@@ -422,7 +352,11 @@ BSD__uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs
* use the given digits.
*/
static char *
-BSD__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
+BSD__ultoa(val, endp, base, octzero, xdigs)
+ register u_long val;
+ char *endp;
+ int base, octzero;
+ char *xdigs;
{
register char *cp = endp;
register long sval;
@@ -521,7 +455,10 @@ static int exponent __P((char *, int, int));
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
#define FPT 0x100 /* Floating point number */
static int
-BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
+BSD_vfprintf(fp, fmt0, ap)
+ FILE *fp;
+ const char *fmt0;
+ va_list ap;
{
register char *fmt; /* format string */
register int ch; /* character from fmt */
@@ -559,7 +496,7 @@ BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
/*
* Choose PADSIZE to trade efficiency vs. size. If larger printf
- * fields occur frequently, increase PADSIZE and make the initialisers
+ * fields occur frequently, increase PADSIZE and make the initializers
* below longer.
*/
#define PADSIZE 16 /* pad chunk size */
@@ -736,9 +673,10 @@ reswitch: switch (ch) {
uqval = -uqval;
sign = '-';
}
- } else
-#endif /* _HAVE_SANE_QUAD_ */
+ } else {
+#else /* _HAVE_SANE_QUAD_ */
{
+#endif /* _HAVE_SANE_QUAD_ */
ulval = SARG();
if ((long)ulval < 0) {
ulval = -ulval;
@@ -843,7 +781,6 @@ fp_begin: _double = va_arg(ap, double);
* defined manner.''
* -- ANSI X3J11
*/
- prec = sizeof(void*)*CHAR_BIT/4;
#ifdef _HAVE_LLP64_
uqval = (u_long)va_arg(ap, void *);
flags = (flags) | QUADINT | HEXPREFIX;
@@ -933,7 +870,7 @@ number: if ((dprec = prec) >= 0)
#ifdef _HAVE_SANE_QUAD_
if (flags & QUADINT) {
if (uqval != 0 || prec != 0)
- cp = BSD__uqtoa(uqval, cp, base,
+ cp = __uqtoa(uqval, cp, base,
flags & ALT, xdigs);
} else {
#else /* _HAVE_SANE_QUAD_ */
@@ -1136,7 +1073,6 @@ exponent(p0, exp, fmtch)
}
#endif /* FLOATING_POINT */
-#ifndef HAVE_VSNPRINTF
int
vsnprintf(str, n, fmt, ap)
char *str;
@@ -1152,20 +1088,23 @@ vsnprintf(str, n, fmt, ap)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n - 1;
- f.vwrite = BSD__sfvwrite;
ret = BSD_vfprintf(&f, fmt, ap);
*f._p = 0;
return (ret);
}
-#endif
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#ifndef HAVE_SNPRINTF
+#if defined(__STDC__)
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#endif
+
int
-#if defined(HAVE_STDARG_PROTOTYPES)
+#if defined(__STDC__)
snprintf(char *str, size_t n, char const *fmt, ...)
#else
snprintf(str, n, fmt, va_alist)
@@ -1181,7 +1120,7 @@ va_dcl
if ((int)n < 1)
return (EOF);
-#if defined(HAVE_STDARG_PROTOTYPES)
+#if defined(__STDC__)
va_start(ap, fmt);
#else
va_start(ap);
@@ -1189,10 +1128,8 @@ va_dcl
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n - 1;
- f.vwrite = BSD__sfvwrite;
ret = BSD_vfprintf(&f, fmt, ap);
*f._p = 0;
va_end(ap);
return (ret);
}
-#endif
diff --git a/missing/x68.c b/missing/x68.c
index ece840d9ce..8d00d50041 100644
--- a/missing/x68.c
+++ b/missing/x68.c
@@ -1,6 +1,6 @@
/* x68 compatibility functions -- follows Ruby's license */
-#include "ruby/config.h"
+#include "config.h"
#if !HAVE_SELECT
#include "x68/select.c"
diff --git a/mkconfig.rb b/mkconfig.rb
index 1086c57909..255bfa7436 100755
--- a/mkconfig.rb
+++ b/mkconfig.rb
@@ -5,7 +5,8 @@ $install_name ||= nil
$so_name ||= nil
srcdir = File.dirname(__FILE__)
-$:.replace [srcdir+"/lib", "."]
+$:.replace [srcdir+"/lib"] unless defined?(CROSS_COMPILING)
+$:.unshift(".")
require "fileutils"
mkconfig = File.basename($0)
@@ -26,7 +27,7 @@ print %[
# This file was created by #{mkconfig} when ruby was built. Any
# changes made to this file will be lost the next time ruby is built.
-module RbConfig
+module Config
RUBY_VERSION == "#{version}" or
raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})"
@@ -74,6 +75,7 @@ File.foreach "config.status" do |line|
next if /^\$ac_\w+$/ =~ val
next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
next if $so_name and /^RUBY_SO_NAME$/ =~ name
+ next if /^(?:X|(?:MINI|RUN)RUBY$)/ =~ name
if /^program_transform_name$/ =~ name and /^s(\\?.)(.*)\1$/ =~ val
next if $install_name
sep = %r"#{Regexp.quote($1)}"
@@ -138,7 +140,7 @@ end
print(*v_fast)
print(*v_others)
print <<EOS
- CONFIG["ruby_version"] = "$(MAJOR).$(MINOR).$(TEENY)"
+ CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
@@ -148,14 +150,14 @@ print <<EOS
CONFIG["topdir"] = File.dirname(__FILE__)
MAKEFILE_CONFIG = {}
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
- def RbConfig::expand(val, config = CONFIG)
+ def Config::expand(val, config = CONFIG)
val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do |var|
if !(v = $1 || $2)
'$'
elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]]
pat, sub = $1, $2
config[v] = false
- RbConfig::expand(key, config)
+ Config::expand(key, config)
config[v] = key
key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat
key
@@ -166,10 +168,10 @@ print <<EOS
val
end
CONFIG.each_value do |val|
- RbConfig::expand(val)
+ Config::expand(val)
end
end
-Config = RbConfig # compatibility for ruby-1.8.4 and older.
+RbConfig = Config # compatibility for ruby-1.9
CROSS_COMPILING = nil unless defined? CROSS_COMPILING
EOS
diff --git a/node.h b/node.h
new file mode 100644
index 0000000000..10ab4855c7
--- /dev/null
+++ b/node.h
@@ -0,0 +1,488 @@
+/**********************************************************************
+
+ node.h -
+
+ $Author$
+ $Date$
+ created at: Fri May 28 15:14:02 JST 1993
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef NODE_H
+#define NODE_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+enum node_type {
+ NODE_METHOD,
+ NODE_FBODY,
+ NODE_CFUNC,
+ NODE_SCOPE,
+ NODE_BLOCK,
+ NODE_IF,
+ NODE_CASE,
+ NODE_WHEN,
+ NODE_OPT_N,
+ NODE_WHILE,
+ NODE_UNTIL,
+ NODE_ITER,
+ NODE_FOR,
+ NODE_BREAK,
+ NODE_NEXT,
+ NODE_REDO,
+ NODE_RETRY,
+ NODE_BEGIN,
+ NODE_RESCUE,
+ NODE_RESBODY,
+ NODE_ENSURE,
+ NODE_AND,
+ NODE_OR,
+ NODE_NOT,
+ NODE_MASGN,
+ NODE_LASGN,
+ NODE_DASGN,
+ NODE_DASGN_CURR,
+ NODE_GASGN,
+ NODE_IASGN,
+ NODE_CDECL,
+ NODE_CVASGN,
+ NODE_CVDECL,
+ NODE_OP_ASGN1,
+ NODE_OP_ASGN2,
+ NODE_OP_ASGN_AND,
+ NODE_OP_ASGN_OR,
+ NODE_CALL,
+ NODE_FCALL,
+ NODE_VCALL,
+ NODE_SUPER,
+ NODE_ZSUPER,
+ NODE_ARRAY,
+ NODE_ZARRAY,
+ NODE_HASH,
+ NODE_RETURN,
+ NODE_YIELD,
+ NODE_LVAR,
+ NODE_DVAR,
+ NODE_GVAR,
+ NODE_IVAR,
+ NODE_CONST,
+ NODE_CVAR,
+ NODE_NTH_REF,
+ NODE_BACK_REF,
+ NODE_MATCH,
+ NODE_MATCH2,
+ NODE_MATCH3,
+ NODE_LIT,
+ NODE_STR,
+ NODE_DSTR,
+ NODE_XSTR,
+ NODE_DXSTR,
+ NODE_EVSTR,
+ NODE_DREGX,
+ NODE_DREGX_ONCE,
+ NODE_ARGS,
+ NODE_ARGSCAT,
+ NODE_ARGSPUSH,
+ NODE_SPLAT,
+ NODE_TO_ARY,
+ NODE_SVALUE,
+ NODE_BLOCK_ARG,
+ NODE_BLOCK_PASS,
+ NODE_DEFN,
+ NODE_DEFS,
+ NODE_ALIAS,
+ NODE_VALIAS,
+ NODE_UNDEF,
+ NODE_CLASS,
+ NODE_MODULE,
+ NODE_SCLASS,
+ NODE_COLON2,
+ NODE_COLON3,
+ NODE_CREF,
+ NODE_DOT2,
+ NODE_DOT3,
+ NODE_FLIP2,
+ NODE_FLIP3,
+ NODE_ATTRSET,
+ NODE_SELF,
+ NODE_NIL,
+ NODE_TRUE,
+ NODE_FALSE,
+ NODE_DEFINED,
+ NODE_NEWLINE,
+ NODE_POSTEXE,
+ NODE_ALLOCA,
+ NODE_DMETHOD,
+ NODE_BMETHOD,
+ NODE_MEMO,
+ NODE_IFUNC,
+ NODE_DSYM,
+ NODE_ATTRASGN,
+ NODE_LAST
+};
+
+typedef struct RNode {
+ unsigned long flags;
+ char *nd_file;
+ union {
+ struct RNode *node;
+ ID id;
+ VALUE value;
+ VALUE (*cfunc)(ANYARGS);
+ ID *tbl;
+ } u1;
+ union {
+ struct RNode *node;
+ ID id;
+ long argc;
+ VALUE value;
+ } u2;
+ union {
+ struct RNode *node;
+ ID id;
+ long state;
+ struct global_entry *entry;
+ long cnt;
+ VALUE value;
+ } u3;
+} NODE;
+
+extern NODE *ruby_cref;
+extern NODE *ruby_top_cref;
+
+#define RNODE(obj) (R_CAST(RNode)(obj))
+
+#define nd_type(n) ((int)(((RNODE(n))->flags>>FL_USHIFT)&0xff))
+#define nd_set_type(n,t) \
+ RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK))
+
+#define NODE_LSHIFT (FL_USHIFT+8)
+#define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
+#define nd_line(n) ((unsigned int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
+#define nd_set_line(n,l) \
+ RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
+
+#define nd_head u1.node
+#define nd_alen u2.argc
+#define nd_next u3.node
+
+#define nd_cond u1.node
+#define nd_body u2.node
+#define nd_else u3.node
+
+#define nd_orig u3.value
+
+#define nd_resq u2.node
+#define nd_ensr u3.node
+
+#define nd_1st u1.node
+#define nd_2nd u2.node
+
+#define nd_stts u1.node
+
+#define nd_entry u3.entry
+#define nd_vid u1.id
+#define nd_cflag u2.id
+#define nd_cval u3.value
+
+#define nd_cnt u3.cnt
+#define nd_tbl u1.tbl
+
+#define nd_var u1.node
+#define nd_ibdy u2.node
+#define nd_iter u3.node
+
+#define nd_value u2.node
+#define nd_aid u3.id
+
+#define nd_lit u1.value
+
+#define nd_frml u1.node
+#define nd_rest u2.node
+#define nd_opt u1.node
+
+#define nd_recv u1.node
+#define nd_mid u2.id
+#define nd_args u3.node
+
+#define nd_noex u1.id
+#define nd_defn u3.node
+
+#define nd_cfnc u1.cfunc
+#define nd_argc u2.argc
+
+#define nd_cpath u1.node
+#define nd_super u3.node
+
+#define nd_modl u1.id
+#define nd_clss u1.value
+
+#define nd_beg u1.node
+#define nd_end u2.node
+#define nd_state u3.state
+#define nd_rval u2.value
+
+#define nd_nth u2.argc
+
+#define nd_tag u1.id
+#define nd_tval u2.value
+
+#define NEW_NODE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
+
+#define NEW_METHOD(n,x) NEW_NODE(NODE_METHOD,x,n,0)
+#define NEW_FBODY(n,i,o) NEW_NODE(NODE_FBODY,n,i,o)
+#define NEW_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,p,i,NEW_RFUNC(a,d))
+#define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_RFUNC(a,d))
+#define NEW_CFUNC(f,c) NEW_NODE(NODE_CFUNC,f,c,0)
+#define NEW_IFUNC(f,c) NEW_NODE(NODE_IFUNC,f,c,0)
+#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
+#define NEW_SCOPE(b) NEW_NODE(NODE_SCOPE,local_tbl(),0,(b))
+#define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
+#define NEW_IF(c,t,e) NEW_NODE(NODE_IF,c,t,e)
+#define NEW_UNLESS(c,t,e) NEW_IF(c,e,t)
+#define NEW_CASE(h,b) NEW_NODE(NODE_CASE,h,b,0)
+#define NEW_WHEN(c,t,e) NEW_NODE(NODE_WHEN,c,t,e)
+#define NEW_OPT_N(b) NEW_NODE(NODE_OPT_N,0,b,0)
+#define NEW_WHILE(c,b,n) NEW_NODE(NODE_WHILE,c,b,n)
+#define NEW_UNTIL(c,b,n) NEW_NODE(NODE_UNTIL,c,b,n)
+#define NEW_FOR(v,i,b) NEW_NODE(NODE_FOR,v,b,i)
+#define NEW_ITER(v,i,b) NEW_NODE(NODE_ITER,v,b,i)
+#define NEW_BREAK(s) NEW_NODE(NODE_BREAK,s,0,0)
+#define NEW_NEXT(s) NEW_NODE(NODE_NEXT,s,0,0)
+#define NEW_REDO() NEW_NODE(NODE_REDO,0,0,0)
+#define NEW_RETRY() NEW_NODE(NODE_RETRY,0,0,0)
+#define NEW_BEGIN(b) NEW_NODE(NODE_BEGIN,0,b,0)
+#define NEW_RESCUE(b,res,e) NEW_NODE(NODE_RESCUE,b,res,e)
+#define NEW_RESBODY(a,ex,n) NEW_NODE(NODE_RESBODY,n,ex,a)
+#define NEW_ENSURE(b,en) NEW_NODE(NODE_ENSURE,b,0,en)
+#define NEW_RETURN(s) NEW_NODE(NODE_RETURN,s,0,0)
+#define NEW_YIELD(a,s) NEW_NODE(NODE_YIELD,a,0,s)
+#define NEW_LIST(a) NEW_ARRAY(a)
+#define NEW_ARRAY(a) NEW_NODE(NODE_ARRAY,a,1,0)
+#define NEW_ZARRAY() NEW_NODE(NODE_ZARRAY,0,0,0)
+#define NEW_HASH(a) NEW_NODE(NODE_HASH,a,0,0)
+#define NEW_NOT(a) NEW_NODE(NODE_NOT,0,a,0)
+#define NEW_MASGN(l,r) NEW_NODE(NODE_MASGN,l,0,r)
+#define NEW_GASGN(v,val) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v))
+#define NEW_LASGN(v,val) NEW_NODE(NODE_LASGN,v,val,local_cnt(v))
+#define NEW_DASGN(v,val) NEW_NODE(NODE_DASGN,v,val,0)
+#define NEW_DASGN_CURR(v,val) NEW_NODE(NODE_DASGN_CURR,v,val,0)
+#define NEW_IASGN(v,val) NEW_NODE(NODE_IASGN,v,val,0)
+#define NEW_CDECL(v,val,path) NEW_NODE(NODE_CDECL,v,val,path)
+#define NEW_CVASGN(v,val) NEW_NODE(NODE_CVASGN,v,val,0)
+#define NEW_CVDECL(v,val) NEW_NODE(NODE_CVDECL,v,val,0)
+#define NEW_OP_ASGN1(p,id,a) NEW_NODE(NODE_OP_ASGN1,p,id,a)
+#define NEW_OP_ASGN2(r,i,o,val) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o))
+#define NEW_OP_ASGN22(i,o) NEW_NODE(NODE_OP_ASGN2,i,o,rb_id_attrset(i))
+#define NEW_OP_ASGN_OR(i,val) NEW_NODE(NODE_OP_ASGN_OR,i,val,0)
+#define NEW_OP_ASGN_AND(i,val) NEW_NODE(NODE_OP_ASGN_AND,i,val,0)
+#define NEW_GVAR(v) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v))
+#define NEW_LVAR(v) NEW_NODE(NODE_LVAR,v,0,local_cnt(v))
+#define NEW_DVAR(v) NEW_NODE(NODE_DVAR,v,0,0)
+#define NEW_IVAR(v) NEW_NODE(NODE_IVAR,v,0,0)
+#define NEW_CONST(v) NEW_NODE(NODE_CONST,v,0,0)
+#define NEW_CVAR(v) NEW_NODE(NODE_CVAR,v,0,0)
+#define NEW_NTH_REF(n) NEW_NODE(NODE_NTH_REF,0,n,local_cnt('~'))
+#define NEW_BACK_REF(n) NEW_NODE(NODE_BACK_REF,0,n,local_cnt('~'))
+#define NEW_MATCH(c) NEW_NODE(NODE_MATCH,c,0,0)
+#define NEW_MATCH2(n1,n2) NEW_NODE(NODE_MATCH2,n1,n2,0)
+#define NEW_MATCH3(r,n2) NEW_NODE(NODE_MATCH3,r,n2,0)
+#define NEW_LIT(l) NEW_NODE(NODE_LIT,l,0,0)
+#define NEW_STR(s) NEW_NODE(NODE_STR,s,0,0)
+#define NEW_DSTR(s) NEW_NODE(NODE_DSTR,s,1,0)
+#define NEW_XSTR(s) NEW_NODE(NODE_XSTR,s,0,0)
+#define NEW_DXSTR(s) NEW_NODE(NODE_DXSTR,s,0,0)
+#define NEW_DSYM(s) NEW_NODE(NODE_DSYM,s,0,0)
+#define NEW_EVSTR(n) NEW_NODE(NODE_EVSTR,0,(n),0)
+#define NEW_CALL(r,m,a) NEW_NODE(NODE_CALL,r,m,a)
+#define NEW_FCALL(m,a) NEW_NODE(NODE_FCALL,0,m,a)
+#define NEW_VCALL(m) NEW_NODE(NODE_VCALL,0,m,0)
+#define NEW_SUPER(a) NEW_NODE(NODE_SUPER,0,0,a)
+#define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
+#define NEW_ARGS(f,o,r) NEW_NODE(NODE_ARGS,o,r,f)
+#define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
+#define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
+#define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
+#define NEW_TO_ARY(a) NEW_NODE(NODE_TO_ARY,a,0,0)
+#define NEW_SVALUE(a) NEW_NODE(NODE_SVALUE,a,0,0)
+#define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
+#define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
+#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
+#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0)
+#define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0)
+#define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(b),(s))
+#define NEW_SCLASS(r,b) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(b),0)
+#define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(b),0)
+#define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
+#define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
+#define NEW_CREF(c) (NEW_NODE(NODE_CREF,0,0,c))
+#define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
+#define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
+#define NEW_ATTRSET(a) NEW_NODE(NODE_ATTRSET,a,0,0)
+#define NEW_SELF() NEW_NODE(NODE_SELF,0,0,0)
+#define NEW_NIL() NEW_NODE(NODE_NIL,0,0,0)
+#define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0)
+#define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0)
+#define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0)
+#define NEW_NEWLINE(n) NEW_NODE(NODE_NEWLINE,0,0,n)
+#define NEW_PREEXE(b) NEW_SCOPE(b)
+#define NEW_POSTEXE() NEW_NODE(NODE_POSTEXE,0,0,0)
+#define NEW_DMETHOD(b) NEW_NODE(NODE_DMETHOD,0,0,b)
+#define NEW_BMETHOD(b) NEW_NODE(NODE_BMETHOD,0,0,b)
+#define NEW_ATTRASGN(r,m,a) NEW_NODE(NODE_ATTRASGN,r,m,a)
+
+#define NOEX_PUBLIC 0
+#define NOEX_NOSUPER 1
+#define NOEX_PRIVATE 2
+#define NOEX_PROTECTED 4
+#define NOEX_MASK 6
+
+#define NOEX_UNDEF NOEX_NOSUPER
+
+NODE *rb_compile_cstr _((const char*, const char*, int, int));
+NODE *rb_compile_string _((const char*, VALUE, int));
+NODE *rb_compile_file _((const char*, VALUE, int));
+
+void rb_add_method _((VALUE, ID, NODE *, int));
+NODE *rb_node_newnode _((enum node_type,VALUE,VALUE,VALUE));
+
+NODE* rb_method_node _((VALUE klass, ID id));
+
+struct global_entry *rb_global_entry _((ID));
+VALUE rb_gvar_get _((struct global_entry *));
+VALUE rb_gvar_set _((struct global_entry *, VALUE));
+VALUE rb_gvar_defined _((struct global_entry *));
+
+typedef unsigned int rb_event_t;
+
+#define RUBY_EVENT_NONE 0x00
+#define RUBY_EVENT_LINE 0x01
+#define RUBY_EVENT_CLASS 0x02
+#define RUBY_EVENT_END 0x04
+#define RUBY_EVENT_CALL 0x08
+#define RUBY_EVENT_RETURN 0x10
+#define RUBY_EVENT_C_CALL 0x20
+#define RUBY_EVENT_C_RETURN 0x40
+#define RUBY_EVENT_RAISE 0x80
+#define RUBY_EVENT_ALL 0xff
+
+typedef void (*rb_event_hook_func_t) _((rb_event_t,NODE*,VALUE,ID,VALUE));
+NODE *rb_copy_node_scope _((NODE *, NODE *));
+void rb_add_event_hook _((rb_event_hook_func_t,rb_event_t));
+int rb_remove_event_hook _((rb_event_hook_func_t));
+
+#if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT)
+#include <ucontext.h>
+#define USE_CONTEXT
+#endif
+#include <setjmp.h>
+#include "st.h"
+
+#ifdef USE_CONTEXT
+typedef struct {
+ ucontext_t context;
+ volatile int status;
+} rb_jmpbuf_t[1];
+#else
+typedef RUBY_JMP_BUF rb_jmpbuf_t;
+#endif
+
+enum rb_thread_status {
+ THREAD_TO_KILL,
+ THREAD_RUNNABLE,
+ THREAD_STOPPED,
+ THREAD_KILLED,
+};
+
+typedef struct rb_thread *rb_thread_t;
+
+struct rb_thread {
+ rb_thread_t next, prev;
+ rb_jmpbuf_t context;
+#if (defined _WIN32 && !defined _WIN32_WCE) || defined __CYGWIN__
+ unsigned long win32_exception_list;
+#endif
+
+ VALUE result;
+
+ long stk_len;
+ long stk_max;
+ VALUE *stk_ptr;
+ VALUE *stk_pos;
+#ifdef __ia64
+ long bstr_len;
+ long bstr_max;
+ VALUE *bstr_ptr;
+ VALUE *bstr_pos;
+#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 rb_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;
+
+ struct st_table *locals;
+
+ VALUE thread;
+
+ VALUE sandbox;
+};
+
+extern VALUE (*ruby_sandbox_save)_((rb_thread_t));
+extern VALUE (*ruby_sandbox_restore)_((rb_thread_t));
+extern rb_thread_t rb_curr_thread;
+extern rb_thread_t rb_main_thread;
+
+enum {
+ RAISED_EXCEPTION = 0x1000,
+ RAISED_STACKOVERFLOW = 0x2000,
+ RAISED_NOMEMORY = 0x4000,
+ RAISED_MASK = 0xf000
+};
+int rb_thread_set_raised(rb_thread_t th);
+int rb_thread_reset_raised(rb_thread_t th);
+#define rb_thread_raised_set(th, f) ((th)->flags |= (f))
+#define rb_thread_raised_reset(th, f) ((th)->flags &= ~(f))
+#define rb_thread_raised_p(th, f) (((th)->flags & (f)) != 0)
+#define rb_thread_raised_clear(th) ((th)->flags = 0)
+
+#if defined(__cplusplus)
+} /* extern "C" { */
+#endif
+
+#endif
diff --git a/numeric.c b/numeric.c
index b9f2b1d084..4f181035ae 100644
--- a/numeric.c
+++ b/numeric.c
@@ -6,12 +6,12 @@
$Date$
created at: Fri Aug 13 18:33:09 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/encoding.h"
+#include "ruby.h"
+#include "env.h"
#include <ctype.h>
#include <math.h>
#include <stdio.h>
@@ -65,7 +65,8 @@
#ifndef HAVE_ROUND
double
-round(double x)
+round(x)
+ double x;
{
double f;
@@ -92,7 +93,7 @@ VALUE rb_eZeroDivError;
VALUE rb_eFloatDomainError;
void
-rb_num_zerodiv(void)
+rb_num_zerodiv()
{
rb_raise(rb_eZeroDivError, "divided by 0");
}
@@ -115,34 +116,41 @@ rb_num_zerodiv(void)
*/
static VALUE
-num_coerce(VALUE x, VALUE y)
+num_coerce(x, y)
+ VALUE x, y;
{
if (CLASS_OF(x) == CLASS_OF(y))
return rb_assoc_new(y, x);
- return rb_assoc_new(rb_Float(y), rb_Float(x));
+ x = rb_Float(x);
+ y = rb_Float(y);
+ return rb_assoc_new(y, x);
}
static VALUE
-coerce_body(VALUE *x)
+coerce_body(x)
+ VALUE *x;
{
return rb_funcall(x[1], id_coerce, 1, x[0]);
}
static VALUE
-coerce_rescue(VALUE *x)
+coerce_rescue(x)
+ VALUE *x;
{
volatile VALUE v = rb_inspect(x[1]);
rb_raise(rb_eTypeError, "%s can't be coerced into %s",
rb_special_const_p(x[1])?
- RSTRING_PTR(v):
+ RSTRING(v)->ptr:
rb_obj_classname(x[1]),
rb_obj_classname(x[0]));
return Qnil; /* dummy */
}
static int
-do_coerce(VALUE *x, VALUE *y, int err)
+do_coerce(x, y, err)
+ VALUE *x, *y;
+ int err;
{
VALUE ary;
VALUE a[2];
@@ -150,40 +158,43 @@ do_coerce(VALUE *x, VALUE *y, int err)
a[0] = *x; a[1] = *y;
ary = rb_rescue(coerce_body, (VALUE)a, err?coerce_rescue:0, (VALUE)a);
- if (TYPE(ary) != T_ARRAY || RARRAY_LEN(ary) != 2) {
+ if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) {
if (err) {
rb_raise(rb_eTypeError, "coerce must return [x, y]");
}
return Qfalse;
}
- *x = RARRAY_PTR(ary)[0];
- *y = RARRAY_PTR(ary)[1];
+ *x = RARRAY(ary)->ptr[0];
+ *y = RARRAY(ary)->ptr[1];
return Qtrue;
}
VALUE
-rb_num_coerce_bin(VALUE x, VALUE y)
+rb_num_coerce_bin(x, y)
+ VALUE x, y;
{
do_coerce(&x, &y, Qtrue);
- return rb_funcall(x, rb_frame_this_func(), 1, y);
+ return rb_funcall(x, ruby_frame->orig_func, 1, y);
}
VALUE
-rb_num_coerce_cmp(VALUE x, VALUE y)
+rb_num_coerce_cmp(x, y)
+ VALUE x, y;
{
if (do_coerce(&x, &y, Qfalse))
- return rb_funcall(x, rb_frame_this_func(), 1, y);
+ return rb_funcall(x, ruby_frame->orig_func, 1, y);
return Qnil;
}
VALUE
-rb_num_coerce_relop(VALUE x, VALUE y)
+rb_num_coerce_relop(x, y)
+ VALUE x, y;
{
VALUE c, x0 = x, y0 = y;
if (!do_coerce(&x, &y, Qfalse) ||
- NIL_P(c = rb_funcall(x, rb_frame_this_func(), 1, y))) {
+ NIL_P(c = rb_funcall(x, ruby_frame->orig_func, 1, y))) {
rb_cmperr(x0, y0);
return Qnil; /* not reached */
}
@@ -196,9 +207,10 @@ rb_num_coerce_relop(VALUE x, VALUE y)
*/
static VALUE
-num_sadded(VALUE x, VALUE name)
+num_sadded(x, name)
+ VALUE x, name;
{
- /* ruby_frame = ruby_frame->prev; */ /* pop frame for "singleton_method_added" */
+ ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */
/* Numerics should be values; singleton_methods should not be added to them */
rb_raise(rb_eTypeError,
"can't define singleton method \"%s\" for %s",
@@ -209,7 +221,8 @@ num_sadded(VALUE x, VALUE name)
/* :nodoc: */
static VALUE
-num_init_copy(VALUE x, VALUE y)
+num_init_copy(x, y)
+ VALUE x, y;
{
/* Numerics are immutable values, which should not be copied */
rb_raise(rb_eTypeError, "can't copy %s", rb_obj_classname(x));
@@ -224,7 +237,8 @@ num_init_copy(VALUE x, VALUE y)
*/
static VALUE
-num_uplus(VALUE num)
+num_uplus(num)
+ VALUE num;
{
return num;
}
@@ -237,7 +251,8 @@ num_uplus(VALUE num)
*/
static VALUE
-num_uminus(VALUE num)
+num_uminus(num)
+ VALUE num;
{
VALUE zero;
@@ -256,7 +271,8 @@ num_uminus(VALUE num)
*/
static VALUE
-num_quo(VALUE x, VALUE y)
+num_quo(x, y)
+ VALUE x, y;
{
return rb_funcall(x, '/', 1, y);
}
@@ -274,12 +290,14 @@ static VALUE num_floor(VALUE num);
*/
static VALUE
-num_div(VALUE x, VALUE y)
+num_div(x, y)
+ VALUE x, y;
{
return num_floor(rb_funcall(x, '/', 1, y));
}
+
/*
* call-seq:
* num.divmod( aNumeric ) -> anArray
@@ -309,7 +327,7 @@ num_div(VALUE x, VALUE y)
* ------+-----+---------------+---------+-------------+---------------
* -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5
* ------+-----+---------------+---------+-------------+---------------
- * -11.5 | -4 | 2, -3.5 | 2.875 | -3.5 | -3.5
+ * -11.5 | -4 | 2 -3.5 | 2.875 | -3.5 | -3.5
*
*
* Examples
@@ -321,7 +339,8 @@ num_div(VALUE x, VALUE y)
*/
static VALUE
-num_divmod(VALUE x, VALUE y)
+num_divmod(x, y)
+ VALUE x, y;
{
return rb_assoc_new(num_div(x, y), rb_funcall(x, '%', 1, y));
}
@@ -335,7 +354,8 @@ num_divmod(VALUE x, VALUE y)
*/
static VALUE
-num_modulo(VALUE x, VALUE y)
+num_modulo(x, y)
+ VALUE x, y;
{
return rb_funcall(x, '%', 1, y);
}
@@ -353,7 +373,8 @@ num_modulo(VALUE x, VALUE y)
*/
static VALUE
-num_remainder(VALUE x, VALUE y)
+num_remainder(x, y)
+ VALUE x, y;
{
VALUE z = rb_funcall(x, '%', 1, y);
@@ -369,20 +390,6 @@ num_remainder(VALUE x, VALUE y)
/*
* call-seq:
- * num.scalar? -> true or false
- *
- * Returns <code>true</code> if <i>num</i> is an <code>Scalar</code>
- * (i.e. non <code>Complex</code>).
- */
-
-static VALUE
-num_scalar_p(VALUE num)
-{
- return Qtrue;
-}
-
-/*
- * call-seq:
* num.integer? -> true or false
*
* Returns <code>true</code> if <i>num</i> is an <code>Integer</code>
@@ -390,7 +397,8 @@ num_scalar_p(VALUE num)
*/
static VALUE
-num_int_p(VALUE num)
+num_int_p(num)
+ VALUE num;
{
return Qfalse;
}
@@ -407,7 +415,8 @@ num_int_p(VALUE num)
*/
static VALUE
-num_abs(VALUE num)
+num_abs(num)
+ VALUE num;
{
if (RTEST(rb_funcall(num, '<', 1, INT2FIX(0)))) {
return rb_funcall(num, rb_intern("-@"), 0);
@@ -424,7 +433,8 @@ num_abs(VALUE num)
*/
static VALUE
-num_zero_p(VALUE num)
+num_zero_p(num)
+ VALUE num;
{
if (rb_equal(num, INT2FIX(0))) {
return Qtrue;
@@ -446,7 +456,8 @@ num_zero_p(VALUE num)
*/
static VALUE
-num_nonzero_p(VALUE num)
+num_nonzero_p(num)
+ VALUE num;
{
if (RTEST(rb_funcall(num, rb_intern("zero?"), 0, 0))) {
return Qnil;
@@ -463,7 +474,8 @@ num_nonzero_p(VALUE num)
*/
static VALUE
-num_to_int(VALUE num)
+num_to_int(num)
+ VALUE num;
{
return rb_funcall(num, id_to_i, 0, 0);
}
@@ -478,12 +490,13 @@ num_to_int(VALUE num)
*/
VALUE
-rb_float_new(double d)
+rb_float_new(d)
+ double d;
{
NEWOBJ(flt, struct RFloat);
OBJSETUP(flt, rb_cFloat, T_FLOAT);
- flt->float_value = d;
+ flt->value = d;
return (VALUE)flt;
}
@@ -498,10 +511,11 @@ rb_float_new(double d)
*/
static VALUE
-flo_to_s(VALUE flt)
+flo_to_s(flt)
+ VALUE flt;
{
char buf[32];
- double value = RFLOAT_VALUE(flt);
+ double value = RFLOAT(flt)->value;
char *p, *e;
if (isinf(value))
@@ -531,7 +545,8 @@ flo_to_s(VALUE flt)
*/
static VALUE
-flo_coerce(VALUE x, VALUE y)
+flo_coerce(x, y)
+ VALUE x, y;
{
return rb_assoc_new(rb_Float(y), x);
}
@@ -544,9 +559,10 @@ flo_coerce(VALUE x, VALUE y)
*/
static VALUE
-flo_uminus(VALUE flt)
+flo_uminus(flt)
+ VALUE flt;
{
- return DOUBLE2NUM(-RFLOAT_VALUE(flt));
+ return rb_float_new(-RFLOAT(flt)->value);
}
/*
@@ -558,15 +574,16 @@ flo_uminus(VALUE flt)
*/
static VALUE
-flo_plus(VALUE x, VALUE y)
+flo_plus(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
- return DOUBLE2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y));
+ return rb_float_new(RFLOAT(x)->value + (double)FIX2LONG(y));
case T_BIGNUM:
- return DOUBLE2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y));
+ return rb_float_new(RFLOAT(x)->value + rb_big2dbl(y));
case T_FLOAT:
- return DOUBLE2NUM(RFLOAT_VALUE(x) + RFLOAT_VALUE(y));
+ return rb_float_new(RFLOAT(x)->value + RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}
@@ -581,15 +598,16 @@ flo_plus(VALUE x, VALUE y)
*/
static VALUE
-flo_minus(VALUE x, VALUE y)
+flo_minus(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
- return DOUBLE2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y));
+ return rb_float_new(RFLOAT(x)->value - (double)FIX2LONG(y));
case T_BIGNUM:
- return DOUBLE2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y));
+ return rb_float_new(RFLOAT(x)->value - rb_big2dbl(y));
case T_FLOAT:
- return DOUBLE2NUM(RFLOAT_VALUE(x) - RFLOAT_VALUE(y));
+ return rb_float_new(RFLOAT(x)->value - RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}
@@ -604,15 +622,16 @@ flo_minus(VALUE x, VALUE y)
*/
static VALUE
-flo_mul(VALUE x, VALUE y)
+flo_mul(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
- return DOUBLE2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
+ return rb_float_new(RFLOAT(x)->value * (double)FIX2LONG(y));
case T_BIGNUM:
- return DOUBLE2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y));
+ return rb_float_new(RFLOAT(x)->value * rb_big2dbl(y));
case T_FLOAT:
- return DOUBLE2NUM(RFLOAT_VALUE(x) * RFLOAT_VALUE(y));
+ return rb_float_new(RFLOAT(x)->value * RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}
@@ -627,7 +646,8 @@ flo_mul(VALUE x, VALUE y)
*/
static VALUE
-flo_div(VALUE x, VALUE y)
+flo_div(x, y)
+ VALUE x, y;
{
long f_y;
double d;
@@ -635,12 +655,12 @@ flo_div(VALUE x, VALUE y)
switch (TYPE(y)) {
case T_FIXNUM:
f_y = FIX2LONG(y);
- return DOUBLE2NUM(RFLOAT_VALUE(x) / (double)f_y);
+ return rb_float_new(RFLOAT(x)->value / (double)f_y);
case T_BIGNUM:
d = rb_big2dbl(y);
- return DOUBLE2NUM(RFLOAT_VALUE(x) / d);
+ return rb_float_new(RFLOAT(x)->value / d);
case T_FLOAT:
- return DOUBLE2NUM(RFLOAT_VALUE(x) / RFLOAT_VALUE(y));
+ return rb_float_new(RFLOAT(x)->value / RFLOAT(y)->value);
default:
return rb_num_coerce_bin(x, y);
}
@@ -648,7 +668,9 @@ flo_div(VALUE x, VALUE y)
static void
-flodivmod(double x, double y, double *divp, double *modp)
+flodivmod(x, y, divp, modp)
+ double x, y;
+ double *divp, *modp;
{
double div, mod;
@@ -687,7 +709,8 @@ flodivmod(double x, double y, double *divp, double *modp)
*/
static VALUE
-flo_mod(VALUE x, VALUE y)
+flo_mod(x, y)
+ VALUE x, y;
{
double fy, mod;
@@ -699,13 +722,13 @@ flo_mod(VALUE x, VALUE y)
fy = rb_big2dbl(y);
break;
case T_FLOAT:
- fy = RFLOAT_VALUE(y);
+ fy = RFLOAT(y)->value;
break;
default:
return rb_num_coerce_bin(x, y);
}
- flodivmod(RFLOAT_VALUE(x), fy, 0, &mod);
- return DOUBLE2NUM(mod);
+ flodivmod(RFLOAT(x)->value, fy, 0, &mod);
+ return rb_float_new(mod);
}
/*
@@ -716,7 +739,8 @@ flo_mod(VALUE x, VALUE y)
*/
static VALUE
-flo_divmod(VALUE x, VALUE y)
+flo_divmod(x, y)
+ VALUE x, y;
{
double fy, div, mod, val;
volatile VALUE a, b;
@@ -729,23 +753,20 @@ flo_divmod(VALUE x, VALUE y)
fy = rb_big2dbl(y);
break;
case T_FLOAT:
- fy = RFLOAT_VALUE(y);
+ fy = RFLOAT(y)->value;
break;
default:
return rb_num_coerce_bin(x, y);
}
- flodivmod(RFLOAT_VALUE(x), fy, &div, &mod);
+ flodivmod(RFLOAT(x)->value, fy, &div, &mod);
if (FIXABLE(div)) {
- val = round(div);
+ val = round(div);
a = LONG2FIX(val);
}
- else if (isnan(div) || isinf(div)) {
- a = rb_float_new(div);
- }
else {
a = rb_dbl2big(div);
}
- b = DOUBLE2NUM(mod);
+ b = rb_float_new(mod);
return rb_assoc_new(a, b);
}
@@ -758,17 +779,18 @@ flo_divmod(VALUE x, VALUE y)
*/
static VALUE
-flo_pow(VALUE x, VALUE y)
+flo_pow(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_FIXNUM:
- return DOUBLE2NUM(pow(RFLOAT_VALUE(x), (double)FIX2LONG(y)));
+ return rb_float_new(pow(RFLOAT(x)->value, (double)FIX2LONG(y)));
case T_BIGNUM:
- return DOUBLE2NUM(pow(RFLOAT_VALUE(x), rb_big2dbl(y)));
+ return rb_float_new(pow(RFLOAT(x)->value, rb_big2dbl(y)));
case T_FLOAT:
- return DOUBLE2NUM(pow(RFLOAT_VALUE(x), RFLOAT_VALUE(y)));
+ return rb_float_new(pow(RFLOAT(x)->value, RFLOAT(y)->value));
default:
- return rb_num_coerce_bin(x, y);
+ return rb_num_coerce_bin(x, y);
}
}
@@ -785,7 +807,8 @@ flo_pow(VALUE x, VALUE y)
*/
static VALUE
-num_eql(VALUE x, VALUE y)
+num_eql(x, y)
+ VALUE x, y;
{
if (TYPE(x) != TYPE(y)) return Qfalse;
@@ -801,14 +824,16 @@ num_eql(VALUE x, VALUE y)
*/
static VALUE
-num_cmp(VALUE x, VALUE y)
+num_cmp(x, y)
+ VALUE x, y;
{
if (x == y) return INT2FIX(0);
return Qnil;
}
static VALUE
-num_equal(VALUE x, VALUE y)
+num_equal(x, y)
+ VALUE x, y;
{
if (x == y) return Qtrue;
return rb_funcall(y, id_eq, 1, x);
@@ -827,7 +852,8 @@ num_equal(VALUE x, VALUE y)
*/
static VALUE
-flo_eq(VALUE x, VALUE y)
+flo_eq(x, y)
+ VALUE x, y;
{
volatile double a, b;
@@ -839,13 +865,13 @@ flo_eq(VALUE x, VALUE y)
b = rb_big2dbl(y);
break;
case T_FLOAT:
- b = RFLOAT_VALUE(y);
+ b = RFLOAT(y)->value;
if (isnan(b)) return Qfalse;
break;
default:
return num_equal(x, y);
}
- a = RFLOAT_VALUE(x);
+ a = RFLOAT(x)->value;
if (isnan(a)) return Qfalse;
return (a == b)?Qtrue:Qfalse;
}
@@ -858,18 +884,26 @@ flo_eq(VALUE x, VALUE y)
*/
static VALUE
-flo_hash(VALUE num)
+flo_hash(num)
+ VALUE num;
{
double d;
- int hash;
+ char *c;
+ int i, hash;
- d = RFLOAT_VALUE(num);
- hash = rb_memhash(&d, sizeof(d));
+ d = RFLOAT(num)->value;
+ if (d == 0) d = fabs(d);
+ c = (char*)&d;
+ for (hash=0, i=0; i<sizeof(double);i++) {
+ hash = (hash * 971) ^ (unsigned char)c[i];
+ }
+ if (hash < 0) hash = -hash;
return INT2FIX(hash);
}
VALUE
-rb_dbl_cmp(double a, double b)
+rb_dbl_cmp(a, b)
+ double a, b;
{
if (isnan(a) || isnan(b)) return Qnil;
if (a == b) return INT2FIX(0);
@@ -888,11 +922,12 @@ rb_dbl_cmp(double a, double b)
*/
static VALUE
-flo_cmp(VALUE x, VALUE y)
+flo_cmp(x, y)
+ VALUE x, y;
{
double a, b;
- a = RFLOAT_VALUE(x);
+ a = RFLOAT(x)->value;
switch (TYPE(y)) {
case T_FIXNUM:
b = (double)FIX2LONG(y);
@@ -903,7 +938,7 @@ flo_cmp(VALUE x, VALUE y)
break;
case T_FLOAT:
- b = RFLOAT_VALUE(y);
+ b = RFLOAT(y)->value;
break;
default:
@@ -920,11 +955,12 @@ flo_cmp(VALUE x, VALUE y)
*/
static VALUE
-flo_gt(VALUE x, VALUE y)
+flo_gt(x, y)
+ VALUE x, y;
{
double a, b;
- a = RFLOAT_VALUE(x);
+ a = RFLOAT(x)->value;
switch (TYPE(y)) {
case T_FIXNUM:
b = (double)FIX2LONG(y);
@@ -935,7 +971,7 @@ flo_gt(VALUE x, VALUE y)
break;
case T_FLOAT:
- b = RFLOAT_VALUE(y);
+ b = RFLOAT(y)->value;
if (isnan(b)) return Qfalse;
break;
@@ -955,11 +991,12 @@ flo_gt(VALUE x, VALUE y)
*/
static VALUE
-flo_ge(VALUE x, VALUE y)
+flo_ge(x, y)
+ VALUE x, y;
{
double a, b;
- a = RFLOAT_VALUE(x);
+ a = RFLOAT(x)->value;
switch (TYPE(y)) {
case T_FIXNUM:
b = (double)FIX2LONG(y);
@@ -970,7 +1007,7 @@ flo_ge(VALUE x, VALUE y)
break;
case T_FLOAT:
- b = RFLOAT_VALUE(y);
+ b = RFLOAT(y)->value;
if (isnan(b)) return Qfalse;
break;
@@ -989,11 +1026,12 @@ flo_ge(VALUE x, VALUE y)
*/
static VALUE
-flo_lt(VALUE x, VALUE y)
+flo_lt(x, y)
+ VALUE x, y;
{
double a, b;
- a = RFLOAT_VALUE(x);
+ a = RFLOAT(x)->value;
switch (TYPE(y)) {
case T_FIXNUM:
b = (double)FIX2LONG(y);
@@ -1004,7 +1042,7 @@ flo_lt(VALUE x, VALUE y)
break;
case T_FLOAT:
- b = RFLOAT_VALUE(y);
+ b = RFLOAT(y)->value;
if (isnan(b)) return Qfalse;
break;
@@ -1024,11 +1062,12 @@ flo_lt(VALUE x, VALUE y)
*/
static VALUE
-flo_le(VALUE x, VALUE y)
+flo_le(x, y)
+ VALUE x, y;
{
double a, b;
- a = RFLOAT_VALUE(x);
+ a = RFLOAT(x)->value;
switch (TYPE(y)) {
case T_FIXNUM:
b = (double)FIX2LONG(y);
@@ -1039,7 +1078,7 @@ flo_le(VALUE x, VALUE y)
break;
case T_FLOAT:
- b = RFLOAT_VALUE(y);
+ b = RFLOAT(y)->value;
if (isnan(b)) return Qfalse;
break;
@@ -1062,11 +1101,12 @@ flo_le(VALUE x, VALUE y)
*/
static VALUE
-flo_eql(VALUE x, VALUE y)
+flo_eql(x, y)
+ VALUE x, y;
{
if (TYPE(y) == T_FLOAT) {
- double a = RFLOAT_VALUE(x);
- double b = RFLOAT_VALUE(y);
+ double a = RFLOAT(x)->value;
+ double b = RFLOAT(y)->value;
if (isnan(a) || isnan(b)) return Qfalse;
if (a == b) return Qtrue;
@@ -1082,7 +1122,8 @@ flo_eql(VALUE x, VALUE y)
*/
static VALUE
-flo_to_f(VALUE num)
+flo_to_f(num)
+ VALUE num;
{
return num;
}
@@ -1099,10 +1140,11 @@ flo_to_f(VALUE num)
*/
static VALUE
-flo_abs(VALUE flt)
+flo_abs(flt)
+ VALUE flt;
{
- double val = fabs(RFLOAT_VALUE(flt));
- return DOUBLE2NUM(val);
+ double val = fabs(RFLOAT(flt)->value);
+ return rb_float_new(val);
}
/*
@@ -1114,9 +1156,10 @@ flo_abs(VALUE flt)
*/
static VALUE
-flo_zero_p(VALUE num)
+flo_zero_p(num)
+ VALUE num;
{
- if (RFLOAT_VALUE(num) == 0.0) {
+ if (RFLOAT(num)->value == 0.0) {
return Qtrue;
}
return Qfalse;
@@ -1136,9 +1179,10 @@ flo_zero_p(VALUE num)
*/
static VALUE
-flo_is_nan_p(VALUE num)
+flo_is_nan_p(num)
+ VALUE num;
{
- double value = RFLOAT_VALUE(num);
+ double value = RFLOAT(num)->value;
return isnan(value) ? Qtrue : Qfalse;
}
@@ -1156,9 +1200,10 @@ flo_is_nan_p(VALUE num)
*/
static VALUE
-flo_is_infinite_p(VALUE num)
+flo_is_infinite_p(num)
+ VALUE num;
{
- double value = RFLOAT_VALUE(num);
+ double value = RFLOAT(num)->value;
if (isinf(value)) {
return INT2FIX( value < 0 ? -1 : 1 );
@@ -1178,9 +1223,10 @@ flo_is_infinite_p(VALUE num)
*/
static VALUE
-flo_is_finite_p(VALUE num)
+flo_is_finite_p(num)
+ VALUE num;
{
- double value = RFLOAT_VALUE(num);
+ double value = RFLOAT(num)->value;
#if HAVE_FINITE
if (!finite(value))
@@ -1206,9 +1252,10 @@ flo_is_finite_p(VALUE num)
*/
static VALUE
-flo_floor(VALUE num)
+flo_floor(num)
+ VALUE num;
{
- double f = floor(RFLOAT_VALUE(num));
+ double f = floor(RFLOAT(num)->value);
long val;
if (!FIXABLE(f)) {
@@ -1232,9 +1279,10 @@ flo_floor(VALUE num)
*/
static VALUE
-flo_ceil(VALUE num)
+flo_ceil(num)
+ VALUE num;
{
- double f = ceil(RFLOAT_VALUE(num));
+ double f = ceil(RFLOAT(num)->value);
long val;
if (!FIXABLE(f)) {
@@ -1246,45 +1294,34 @@ flo_ceil(VALUE num)
/*
* call-seq:
- * flt.round([ndigits]) => integer or float
+ * flt.round => integer
+ *
+ * Rounds <i>flt</i> to the nearest integer. Equivalent to:
*
- * Rounds <i>flt</i> to a given precision in decimal digits (default 0 digits).
- * Precision may be negative. Returns a a floating point number when ndigits
- * is more than one.
+ * def round
+ * return (self+0.5).floor if self > 0.0
+ * return (self-0.5).ceil if self < 0.0
+ * return 0
+ * end
*
* 1.5.round #=> 2
* (-1.5).round #=> -2
+ *
*/
static VALUE
-flo_round(int argc, VALUE *argv, VALUE num)
+flo_round(num)
+ VALUE num;
{
- VALUE nd;
- double number, f;
- int ndigits = 0, i;
+ double f = RFLOAT(num)->value;
long val;
- if (rb_scan_args(argc, argv, "01", &nd) == 1) {
- ndigits = NUM2INT(nd);
- }
- number = RFLOAT_VALUE(num);
- f = 1.0;
- i = abs(ndigits);
- while (--i >= 0)
- f = f*10.0;
-
- if (ndigits < 0) number /= f;
- else number *= f;
- number = round(number);
- if (ndigits < 0) number *= f;
- else number /= f;
+ f = round(f);
- if (ndigits > 0) return DOUBLE2NUM(number);
-
- if (!FIXABLE(number)) {
- return rb_dbl2big(number);
+ if (!FIXABLE(f)) {
+ return rb_dbl2big(f);
}
- val = number;
+ val = f;
return LONG2FIX(val);
}
@@ -1298,9 +1335,10 @@ flo_round(int argc, VALUE *argv, VALUE num)
*/
static VALUE
-flo_truncate(VALUE num)
+flo_truncate(num)
+ VALUE num;
{
- double f = RFLOAT_VALUE(num);
+ double f = RFLOAT(num)->value;
long val;
if (f > 0.0) f = floor(f);
@@ -1327,7 +1365,8 @@ flo_truncate(VALUE num)
*/
static VALUE
-num_floor(VALUE num)
+num_floor(num)
+ VALUE num;
{
return flo_floor(rb_Float(num));
}
@@ -1349,25 +1388,26 @@ num_floor(VALUE num)
*/
static VALUE
-num_ceil(VALUE num)
+num_ceil(num)
+ VALUE num;
{
return flo_ceil(rb_Float(num));
}
/*
* call-seq:
- * num.round([ndigits]) => integer or float
+ * num.round => integer
*
- * Rounds <i>num</i> to a given precision in decimal digits (default 0 digits).
- * Precision may be negative. Returns a a floating point number when ndigits
- * is more than one. <code>Numeric</code> implements this by converting itself
- * to a <code>Float</code> and invoking <code>Float#round</code>.
+ * Rounds <i>num</i> to the nearest integer. <code>Numeric</code>
+ * implements this by converting itself to a
+ * <code>Float</code> and invoking <code>Float#round</code>.
*/
static VALUE
-num_round(int argc, VALUE* argv, VALUE num)
+num_round(num)
+ VALUE num;
{
- return flo_round(argc, argv, rb_Float(num));
+ return flo_round(rb_Float(num));
}
/*
@@ -1380,7 +1420,8 @@ num_round(int argc, VALUE* argv, VALUE num)
*/
static VALUE
-num_truncate(VALUE num)
+num_truncate(num)
+ VALUE num;
{
return flo_truncate(rb_Float(num));
}
@@ -1414,11 +1455,15 @@ num_truncate(VALUE num)
*/
static VALUE
-num_step(int argc, VALUE *argv, VALUE from)
+num_step(argc, argv, from)
+ int argc;
+ VALUE *argv;
+ VALUE from;
{
VALUE to, step;
RETURN_ENUMERATOR(from, argc, argv);
+
if (argc == 1) {
to = argv[0];
step = INT2FIX(1);
@@ -1468,7 +1513,7 @@ num_step(int argc, VALUE *argv, VALUE from)
if (err>0.5) err=0.5;
n = floor(n + err) + 1;
for (i=0; i<n; i++) {
- rb_yield(DOUBLE2NUM(i*unit+beg));
+ rb_yield(rb_float_new(i*unit+beg));
}
}
else {
@@ -1490,9 +1535,11 @@ num_step(int argc, VALUE *argv, VALUE from)
return from;
}
-SIGNED_VALUE
-rb_num2long(VALUE val)
+long
+rb_num2long(val)
+ VALUE val;
{
+ again:
if (NIL_P(val)) {
rb_raise(rb_eTypeError, "no implicit conversion from nil to integer");
}
@@ -1501,15 +1548,15 @@ rb_num2long(VALUE val)
switch (TYPE(val)) {
case T_FLOAT:
- if (RFLOAT_VALUE(val) <= (double)LONG_MAX
- && RFLOAT_VALUE(val) >= (double)LONG_MIN) {
- return (SIGNED_VALUE)(RFLOAT_VALUE(val));
+ if (RFLOAT(val)->value <= (double)LONG_MAX
+ && RFLOAT(val)->value >= (double)LONG_MIN) {
+ return (long)(RFLOAT(val)->value);
}
else {
char buf[24];
char *s;
- sprintf(buf, "%-.10g", RFLOAT_VALUE(val));
+ sprintf(buf, "%-.10g", RFLOAT(val)->value);
if ((s = strchr(buf, ' ')) != 0) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of integer", buf);
}
@@ -1519,22 +1566,24 @@ rb_num2long(VALUE val)
default:
val = rb_to_int(val);
- return NUM2LONG(val);
+ goto again;
}
}
-VALUE
-rb_num2ulong(VALUE val)
+unsigned long
+rb_num2ulong(val)
+ VALUE val;
{
if (TYPE(val) == T_BIGNUM) {
return rb_big2ulong(val);
}
- return (VALUE)rb_num2long(val);
+ return (unsigned long)rb_num2long(val);
}
-#if SIZEOF_INT < SIZEOF_VALUE
+#if SIZEOF_INT < SIZEOF_LONG
static void
-check_int(SIGNED_VALUE num)
+check_int(num)
+ long num;
{
const char *s;
@@ -1547,27 +1596,31 @@ check_int(SIGNED_VALUE num)
else {
return;
}
-#ifdef LONG_LONG_VALUE
- rb_raise(rb_eRangeError, "integer %lld too %s to convert to `int'", num, s);
-#else
rb_raise(rb_eRangeError, "integer %ld too %s to convert to `int'", num, s);
-#endif
}
static void
-check_uint(VALUE num)
+check_uint(num, sign)
+ unsigned long num;
+ VALUE sign;
{
- if (num > UINT_MAX) {
-#ifdef LONG_LONG_VALUE
- rb_raise(rb_eRangeError, "integer %llu too big to convert to `unsigned int'", num);
-#else
- rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned int'", num);
-#endif
+ static const unsigned long mask = ~(unsigned long)UINT_MAX;
+
+ if (RTEST(sign)) {
+ /* minus */
+ if ((num & mask) != mask || (num & ~mask) <= INT_MAX + 1UL)
+ rb_raise(rb_eRangeError, "integer %ld too small to convert to `unsigned int'", num);
+ }
+ else {
+ /* plus */
+ if ((num & mask) != 0)
+ rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned int'", num);
}
}
long
-rb_num2int(VALUE val)
+rb_num2int(val)
+ VALUE val;
{
long num = rb_num2long(val);
@@ -1576,7 +1629,8 @@ rb_num2int(VALUE val)
}
long
-rb_fix2int(VALUE val)
+rb_fix2int(val)
+ VALUE val;
{
long num = FIXNUM_P(val)?FIX2LONG(val):rb_num2long(val);
@@ -1585,46 +1639,48 @@ rb_fix2int(VALUE val)
}
unsigned long
-rb_num2uint(VALUE val)
+rb_num2uint(val)
+ VALUE val;
{
unsigned long num = rb_num2ulong(val);
- if (RTEST(rb_funcall(INT2FIX(0), '<', 1, val))) {
- check_uint(num);
- }
+ check_uint(num, rb_funcall(val, '<', 1, INT2FIX(0)));
return num;
}
unsigned long
-rb_fix2uint(VALUE val)
+rb_fix2uint(val)
+ VALUE val;
{
unsigned long num;
if (!FIXNUM_P(val)) {
- return rb_num2uint(val);
+ return rb_num2uint(val);
}
num = FIX2ULONG(val);
- if (FIX2LONG(val) > 0) {
- check_uint(num);
- }
+
+ check_uint(num, rb_funcall(val, '<', 1, INT2FIX(0)));
return num;
}
#else
long
-rb_num2int(VALUE val)
+rb_num2int(val)
+ VALUE val;
{
return rb_num2long(val);
}
long
-rb_fix2int(VALUE val)
+rb_fix2int(val)
+ VALUE val;
{
return FIX2INT(val);
}
#endif
VALUE
-rb_num2fix(VALUE val)
+rb_num2fix(val)
+ VALUE val;
{
long v;
@@ -1639,7 +1695,8 @@ rb_num2fix(VALUE val)
#if HAVE_LONG_LONG
LONG_LONG
-rb_num2ll(VALUE val)
+rb_num2ll(val)
+ VALUE val;
{
if (NIL_P(val)) {
rb_raise(rb_eTypeError, "no implicit conversion from nil");
@@ -1648,40 +1705,41 @@ rb_num2ll(VALUE val)
if (FIXNUM_P(val)) return (LONG_LONG)FIX2LONG(val);
switch (TYPE(val)) {
- case T_FLOAT:
- if (RFLOAT_VALUE(val) <= (double)LLONG_MAX
- && RFLOAT_VALUE(val) >= (double)LLONG_MIN) {
- return (LONG_LONG)(RFLOAT_VALUE(val));
+ case T_FLOAT:
+ if (RFLOAT(val)->value <= (double)LLONG_MAX
+ && RFLOAT(val)->value >= (double)LLONG_MIN) {
+ return (LONG_LONG)(RFLOAT(val)->value);
}
else {
char buf[24];
char *s;
- sprintf(buf, "%-.10g", RFLOAT_VALUE(val));
+ sprintf(buf, "%-.10g", RFLOAT(val)->value);
if ((s = strchr(buf, ' ')) != 0) *s = '\0';
rb_raise(rb_eRangeError, "float %s out of range of long long", buf);
}
- case T_BIGNUM:
+ case T_BIGNUM:
return rb_big2ll(val);
- case T_STRING:
+ case T_STRING:
rb_raise(rb_eTypeError, "no implicit conversion from string");
return Qnil; /* not reached */
- case T_TRUE:
- case T_FALSE:
+ case T_TRUE:
+ case T_FALSE:
rb_raise(rb_eTypeError, "no implicit conversion from boolean");
return Qnil; /* not reached */
default:
- val = rb_to_int(val);
- return NUM2LL(val);
+ val = rb_to_int(val);
+ return NUM2LL(val);
}
}
unsigned LONG_LONG
-rb_num2ull(VALUE val)
+rb_num2ull(val)
+ VALUE val;
{
if (TYPE(val) == T_BIGNUM) {
return rb_big2ull(val);
@@ -1715,7 +1773,8 @@ rb_num2ull(VALUE val)
*/
static VALUE
-int_to_i(VALUE num)
+int_to_i(num)
+ VALUE num;
{
return num;
}
@@ -1728,7 +1787,8 @@ int_to_i(VALUE num)
*/
static VALUE
-int_int_p(VALUE num)
+int_int_p(num)
+ VALUE num;
{
return Qtrue;
}
@@ -1744,7 +1804,7 @@ static VALUE
int_odd_p(VALUE num)
{
if (rb_funcall(num, '%', 1, INT2FIX(2)) != INT2FIX(0)) {
- return Qtrue;
+ return Qtrue;
}
return Qfalse;
}
@@ -1760,28 +1820,11 @@ static VALUE
int_even_p(VALUE num)
{
if (rb_funcall(num, '%', 1, INT2FIX(2)) == INT2FIX(0)) {
- return Qtrue;
+ return Qtrue;
}
return Qfalse;
}
-/*
- * call-seq:
- * fixnum.next => integer
- * fixnum.succ => integer
- *
- * Returns the <code>Integer</code> equal to <i>int</i> + 1.
- *
- * 1.next #=> 2
- * (-1).next #=> 0
- */
-
-static VALUE
-fix_succ(VALUE num)
-{
- long i = FIX2LONG(num) + 1;
- return LONG2NUM(i);
-}
/*
* call-seq:
@@ -1795,7 +1838,8 @@ fix_succ(VALUE num)
*/
static VALUE
-int_succ(VALUE num)
+int_succ(num)
+ VALUE num;
{
if (FIXNUM_P(num)) {
long i = FIX2LONG(num) + 1;
@@ -1818,53 +1862,55 @@ static VALUE
int_pred(VALUE num)
{
if (FIXNUM_P(num)) {
- long i = FIX2LONG(num) - 1;
- return LONG2NUM(i);
+ long i = FIX2LONG(num) - 1;
+ return LONG2NUM(i);
}
return rb_funcall(num, '-', 1, INT2FIX(1));
}
/*
* call-seq:
- * int.chr([encoding]) => string
+ * int.chr => string
*
- * Returns a string containing the character represented by the
- * receiver's value according to +encoding+.
+ * Returns a string containing the ASCII character represented by the
+ * receiver's value.
*
* 65.chr #=> "A"
+ * ?a.chr #=> "a"
* 230.chr #=> "\346"
- * 255.chr(Encoding::UTF_8) #=> "\303\277"
*/
static VALUE
-int_chr(int argc, VALUE *argv, VALUE num)
+int_chr(num)
+ VALUE num;
{
char c;
- int n;
long i = NUM2LONG(num);
- rb_encoding *enc;
- VALUE str;
-
- switch (argc) {
- case 0:
- if (i < 0 || 0xff < i) {
- out_of_range:
- rb_raise(rb_eRangeError, "%ld out of char range", i);
- }
- c = i;
- return rb_str_new(&c, 1);
- case 1:
- break;
- default:
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
- break;
- }
- enc = rb_to_encoding(argv[0]);
- if (!enc) enc = rb_ascii8bit_encoding();
- if (i < 0 || (n = rb_enc_codelen(i, enc)) <= 0) goto out_of_range;
- str = rb_enc_str_new(0, n, enc);
- rb_enc_mbcput(i, RSTRING_PTR(str), enc);
- return str;
+
+ if (i < 0 || 0xff < i)
+ rb_raise(rb_eRangeError, "%ld out of char range", i);
+ c = i;
+ return rb_str_new(&c, 1);
+}
+
+/*
+ * call-seq:
+ * int.ord => int
+ *
+ * Returns the int itself.
+ *
+ * ?a.ord #=> 97
+ *
+ * This method is intended for compatibility to
+ * character constant in Ruby 1.9.
+ * For example, ?a.ord returns 97 both in 1.8 and 1.9.
+ */
+
+static VALUE
+int_ord(num)
+ VALUE num;
+{
+ return num;
}
/********************************************************************
@@ -1895,7 +1941,8 @@ int_chr(int argc, VALUE *argv, VALUE num)
*/
static VALUE
-rb_fix_induced_from(VALUE klass, VALUE x)
+rb_fix_induced_from(klass, x)
+ VALUE klass, x;
{
return rb_num2fix(x);
}
@@ -1908,17 +1955,18 @@ rb_fix_induced_from(VALUE klass, VALUE x)
*/
static VALUE
-rb_int_induced_from(VALUE klass, VALUE x)
+rb_int_induced_from(klass, x)
+ VALUE klass, x;
{
switch (TYPE(x)) {
- case T_FIXNUM:
- case T_BIGNUM:
- return x;
- case T_FLOAT:
- return rb_funcall(x, id_to_i, 0);
- default:
- rb_raise(rb_eTypeError, "failed to convert %s into Integer",
- rb_obj_classname(x));
+ case T_FIXNUM:
+ case T_BIGNUM:
+ return x;
+ case T_FLOAT:
+ return rb_funcall(x, id_to_i, 0);
+ default:
+ rb_raise(rb_eTypeError, "failed to convert %s into Integer",
+ rb_obj_classname(x));
}
}
@@ -1930,17 +1978,18 @@ rb_int_induced_from(VALUE klass, VALUE x)
*/
static VALUE
-rb_flo_induced_from(VALUE klass, VALUE x)
+rb_flo_induced_from(klass, x)
+ VALUE klass, x;
{
switch (TYPE(x)) {
- case T_FIXNUM:
- case T_BIGNUM:
- return rb_funcall(x, rb_intern("to_f"), 0);
- case T_FLOAT:
- return x;
- default:
- rb_raise(rb_eTypeError, "failed to convert %s into Float",
- rb_obj_classname(x));
+ case T_FIXNUM:
+ case T_BIGNUM:
+ return rb_funcall(x, rb_intern("to_f"), 0);
+ case T_FLOAT:
+ return x;
+ default:
+ rb_raise(rb_eTypeError, "failed to convert %s into Float",
+ rb_obj_classname(x));
}
}
@@ -1952,21 +2001,24 @@ rb_flo_induced_from(VALUE klass, VALUE x)
*/
static VALUE
-fix_uminus(VALUE num)
+fix_uminus(num)
+ VALUE num;
{
return LONG2NUM(-FIX2LONG(num));
}
VALUE
-rb_fix2str(VALUE x, int base)
+rb_fix2str(x, base)
+ VALUE x;
+ int base;
{
extern const char ruby_digitmap[];
- char buf[SIZEOF_VALUE*CHAR_BIT + 2], *b = buf + sizeof buf;
+ char buf[SIZEOF_LONG*CHAR_BIT + 2], *b = buf + sizeof buf;
long val = FIX2LONG(x);
int neg = 0;
if (base < 2 || 36 < base) {
- rb_raise(rb_eArgError, "invalid radix %d", base);
+ rb_raise(rb_eArgError, "illegal radix %d", base);
}
if (val == 0) {
return rb_str_new2("0");
@@ -2002,7 +2054,10 @@ rb_fix2str(VALUE x, int base)
*
*/
static VALUE
-fix_to_s(int argc, VALUE *argv, VALUE x)
+fix_to_s(argc, argv, x)
+ int argc;
+ VALUE *argv;
+ VALUE x;
{
VALUE b;
int base;
@@ -2024,7 +2079,8 @@ fix_to_s(int argc, VALUE *argv, VALUE x)
*/
static VALUE
-fix_plus(VALUE x, VALUE y)
+fix_plus(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
long a, b, c;
@@ -2037,14 +2093,10 @@ fix_plus(VALUE x, VALUE y)
return r;
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return rb_big_plus(y, x);
- case T_FLOAT:
- return DOUBLE2NUM((double)FIX2LONG(x) + RFLOAT_VALUE(y));
- default:
- return rb_num_coerce_bin(x, y);
+ if (TYPE(y) == T_FLOAT) {
+ return rb_float_new((double)FIX2LONG(x) + RFLOAT(y)->value);
}
+ return rb_num_coerce_bin(x, y);
}
/*
@@ -2057,7 +2109,8 @@ fix_plus(VALUE x, VALUE y)
*/
static VALUE
-fix_minus(VALUE x, VALUE y)
+fix_minus(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
long a, b, c;
@@ -2070,21 +2123,12 @@ fix_minus(VALUE x, VALUE y)
return r;
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- x = rb_int2big(FIX2LONG(x));
- return rb_big_minus(x, y);
- case T_FLOAT:
- return DOUBLE2NUM((double)FIX2LONG(x) - RFLOAT_VALUE(y));
- default:
- return rb_num_coerce_bin(x, y);
+ if (TYPE(y) == T_FLOAT) {
+ return rb_float_new((double)FIX2LONG(x) - RFLOAT(y)->value);
}
+ return rb_num_coerce_bin(x, y);
}
-#define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
-/*tests if N*N would overflow*/
-#define FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))
-
/*
* call-seq:
* fix * numeric => numeric_result
@@ -2095,53 +2139,39 @@ fix_minus(VALUE x, VALUE y)
*/
static VALUE
-fix_mul(VALUE x, VALUE y)
+fix_mul(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
#ifdef __HP_cc
-/* avoids an optimization bug of HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005] */
- volatile
+ /* avoids an optimization bug of HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005] */
+ volatile
#endif
- SIGNED_VALUE a, b;
-#if SIZEOF_VALUE * 2 <= SIZEOF_LONG_LONG
- LONG_LONG d;
-#else
- SIGNED_VALUE c;
+ long a, b, c;
VALUE r;
-#endif
a = FIX2LONG(x);
- b = FIX2LONG(y);
+ if (a == 0) return x;
-#if SIZEOF_VALUE * 2 <= SIZEOF_LONG_LONG
- d = (LONG_LONG)a * b;
- if (FIXABLE(d)) return LONG2FIX(d);
- return rb_ll2inum(d);
-#else
- if (FIT_SQRT_LONG(a) && FIT_SQRT_LONG(b))
- return LONG2FIX(a*b);
+ b = FIX2LONG(y);
c = a * b;
r = LONG2FIX(c);
- if (a == 0) return x;
if (FIX2LONG(r) != c || c/a != b) {
r = rb_big_mul(rb_int2big(a), rb_int2big(b));
}
return r;
-#endif
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return rb_big_mul(y, x);
- case T_FLOAT:
- return DOUBLE2NUM((double)FIX2LONG(x) * RFLOAT_VALUE(y));
- default:
- return rb_num_coerce_bin(x, y);
+ if (TYPE(y) == T_FLOAT) {
+ return rb_float_new((double)FIX2LONG(x) * RFLOAT(y)->value);
}
+ return rb_num_coerce_bin(x, y);
}
static void
-fixdivmod(long x, long y, long *divp, long *modp)
+fixdivmod(x, y, divp, modp)
+ long x, y;
+ long *divp, *modp;
{
long div, mod;
@@ -2181,50 +2211,19 @@ fixdivmod(long x, long y, long *divp, long *modp)
*/
static VALUE
-fix_quo(VALUE x, VALUE y)
+fix_quo(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
- return DOUBLE2NUM((double)FIX2LONG(x) / (double)FIX2LONG(y));
- }
- switch (TYPE(y)) {
- case T_BIGNUM:
- return DOUBLE2NUM((double)FIX2LONG(y) / rb_big2dbl(y));
- case T_FLOAT:
- return DOUBLE2NUM((double)FIX2LONG(x) / RFLOAT_VALUE(y));
- default:
- return rb_num_coerce_bin(x, y);
- }
-}
-
-static VALUE
-fix_divide(VALUE x, VALUE y, int flo)
-{
- if (FIXNUM_P(y)) {
- long div;
-
- fixdivmod(FIX2LONG(x), FIX2LONG(y), &div, 0);
- return LONG2NUM(div);
- }
- switch (TYPE(y)) {
- case T_BIGNUM:
- x = rb_int2big(FIX2LONG(x));
- return rb_big_div(x, y);
- case T_FLOAT:
- if (flo) {
- return DOUBLE2NUM((double)FIX2LONG(x) / RFLOAT_VALUE(y));
- }
- else {
- long div = (double)FIX2LONG(x) / RFLOAT_VALUE(y);
- return LONG2NUM(div);
- }
- default:
- return rb_num_coerce_bin(x, y);
+ return rb_float_new((double)FIX2LONG(x) / (double)FIX2LONG(y));
}
+ return rb_num_coerce_bin(x, y);
}
/*
* call-seq:
* fix / numeric => numeric_result
+ * fix.div(numeric) => numeric_result
*
* Performs division: the class of the resulting object depends on
* the class of <code>numeric</code> and on the magnitude of the
@@ -2232,22 +2231,16 @@ fix_divide(VALUE x, VALUE y, int flo)
*/
static VALUE
-fix_div(VALUE x, VALUE y)
+fix_div(x, y)
+ VALUE x, y;
{
- return fix_divide(x, y, Qtrue);
-}
-
-/*
- * call-seq:
- * fix.div(numeric) => numeric_result
- *
- * Performs integer division: returns integer value.
- */
+ if (FIXNUM_P(y)) {
+ long div;
-static VALUE
-fix_idiv(VALUE x, VALUE y)
-{
- return fix_divide(x, y, Qfalse);
+ fixdivmod(FIX2LONG(x), FIX2LONG(y), &div, 0);
+ return LONG2NUM(div);
+ }
+ return rb_num_coerce_bin(x, y);
}
/*
@@ -2260,7 +2253,8 @@ fix_idiv(VALUE x, VALUE y)
*/
static VALUE
-fix_mod(VALUE x, VALUE y)
+fix_mod(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
long mod;
@@ -2268,20 +2262,7 @@ fix_mod(VALUE x, VALUE y)
fixdivmod(FIX2LONG(x), FIX2LONG(y), 0, &mod);
return LONG2NUM(mod);
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- x = rb_int2big(FIX2LONG(x));
- return rb_big_modulo(x, y);
- case T_FLOAT:
- {
- double mod;
-
- flodivmod((double)FIX2LONG(x), RFLOAT_VALUE(y), 0, &mod);
- return DOUBLE2NUM(mod);
- }
- default:
- return rb_num_coerce_bin(x, y);
- }
+ return rb_num_coerce_bin(x, y);
}
/*
@@ -2291,7 +2272,8 @@ fix_mod(VALUE x, VALUE y)
* See <code>Numeric#divmod</code>.
*/
static VALUE
-fix_divmod(VALUE x, VALUE y)
+fix_divmod(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
long div, mod;
@@ -2300,27 +2282,13 @@ fix_divmod(VALUE x, VALUE y)
return rb_assoc_new(LONG2NUM(div), LONG2NUM(mod));
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- x = rb_int2big(FIX2LONG(x));
- return rb_big_divmod(x, y);
- case T_FLOAT:
- {
- double div, mod;
- volatile VALUE a, b;
-
- flodivmod((double)FIX2LONG(x), RFLOAT_VALUE(y), &div, &mod);
- a = DOUBLE2NUM(div);
- b = DOUBLE2NUM(mod);
- return rb_assoc_new(a, b);
- }
- default:
- return rb_num_coerce_bin(x, y);
- }
+ return rb_num_coerce_bin(x, y);
}
static VALUE
-int_pow(long x, unsigned long y)
+int_pow(x, y)
+ long x;
+ unsigned long y;
{
int neg = x < 0;
long z = 1;
@@ -2333,14 +2301,15 @@ int_pow(long x, unsigned long y)
y &= ~1;
do {
while (y % 2 == 0) {
- if (!FIT_SQRT_LONG(x)) {
+ long x2 = x * x;
+ if (x2/x != x || !POSFIXABLE(x2)) {
VALUE v;
bignum:
v = rb_big_pow(rb_int2big(x), LONG2NUM(y));
if (z != 1) v = rb_big_mul(rb_int2big(neg ? -z : z), v);
return v;
}
- x = x * x;
+ x = x2;
y >>= 1;
}
{
@@ -2368,7 +2337,8 @@ int_pow(long x, unsigned long y)
*/
static VALUE
-fix_pow(VALUE x, VALUE y)
+fix_pow(x, y)
+ VALUE x, y;
{
static const double zero = 0.0;
long a = FIX2LONG(x);
@@ -2380,7 +2350,7 @@ fix_pow(VALUE x, VALUE y)
if (b == 1) return x;
if (a == 0) {
if (b > 0) return INT2FIX(0);
- return DOUBLE2NUM(1.0 / zero);
+ return rb_float_new(1.0 / zero);
}
if (a == 1) return INT2FIX(1);
if (a == -1) {
@@ -2392,7 +2362,7 @@ fix_pow(VALUE x, VALUE y)
if (b > 0) {
return int_pow(a, b);
}
- return DOUBLE2NUM(pow((double)a, (double)b));
+ return rb_float_new(pow((double)a, (double)b));
}
switch (TYPE(y)) {
case T_BIGNUM:
@@ -2405,12 +2375,12 @@ fix_pow(VALUE x, VALUE y)
x = rb_int2big(FIX2LONG(x));
return rb_big_pow(x, y);
case T_FLOAT:
- if (RFLOAT_VALUE(y) == 0.0) return DOUBLE2NUM(1.0);
+ if (RFLOAT(y)->value == 0.0) return rb_float_new(1.0);
if (a == 0) {
- return DOUBLE2NUM(RFLOAT_VALUE(y) < 0 ? (1.0 / zero) : 0.0);
+ return rb_float_new(RFLOAT(y)->value < 0 ? (1.0 / zero) : 0.0);
}
- if (a == 1) return DOUBLE2NUM(1.0);
- return DOUBLE2NUM(pow((double)a, RFLOAT_VALUE(y)));
+ if (a == 1) return rb_float_new(1.0);
+ return rb_float_new(pow((double)a, RFLOAT(y)->value));
default:
return rb_num_coerce_bin(x, y);
}
@@ -2428,18 +2398,12 @@ fix_pow(VALUE x, VALUE y)
*/
static VALUE
-fix_equal(VALUE x, VALUE y)
+fix_equal(x, y)
+ VALUE x, y;
{
if (x == y) return Qtrue;
if (FIXNUM_P(y)) return Qfalse;
- switch (TYPE(y)) {
- case T_BIGNUM:
- return rb_big_eq(y, x);
- case T_FLOAT:
- return (double)FIX2LONG(x) == RFLOAT_VALUE(y) ? Qtrue : Qfalse;
- default:
- return num_equal(x, y);
- }
+ return num_equal(x, y);
}
/*
@@ -2452,19 +2416,17 @@ fix_equal(VALUE x, VALUE y)
*/
static VALUE
-fix_cmp(VALUE x, VALUE y)
+fix_cmp(x, y)
+ VALUE x, y;
{
if (x == y) return INT2FIX(0);
if (FIXNUM_P(y)) {
- if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1);
+ long a = FIX2LONG(x), b = FIX2LONG(y);
+
+ if (a > b) return INT2FIX(1);
return INT2FIX(-1);
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return rb_big_cmp(rb_int2big(FIX2LONG(x)), y);
- case T_FLOAT:
- return rb_dbl_cmp((double)FIX2LONG(x), RFLOAT_VALUE(y));
- default:
+ else {
return rb_num_coerce_cmp(x, y);
}
}
@@ -2478,18 +2440,16 @@ fix_cmp(VALUE x, VALUE y)
*/
static VALUE
-fix_gt(VALUE x, VALUE y)
+fix_gt(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
- if (FIX2LONG(x) > FIX2LONG(y)) return Qtrue;
+ long a = FIX2LONG(x), b = FIX2LONG(y);
+
+ if (a > b) return Qtrue;
return Qfalse;
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) > 0 ? Qtrue : Qfalse;
- case T_FLOAT:
- return (double)FIX2LONG(x) > RFLOAT_VALUE(y) ? Qtrue : Qfalse;
- default:
+ else {
return rb_num_coerce_relop(x, y);
}
}
@@ -2503,18 +2463,16 @@ fix_gt(VALUE x, VALUE y)
*/
static VALUE
-fix_ge(VALUE x, VALUE y)
+fix_ge(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
- if (FIX2LONG(x) >= FIX2LONG(y)) return Qtrue;
+ long a = FIX2LONG(x), b = FIX2LONG(y);
+
+ if (a >= b) return Qtrue;
return Qfalse;
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) >= 0 ? Qtrue : Qfalse;
- case T_FLOAT:
- return (double)FIX2LONG(x) >= RFLOAT_VALUE(y) ? Qtrue : Qfalse;
- default:
+ else {
return rb_num_coerce_relop(x, y);
}
}
@@ -2528,18 +2486,16 @@ fix_ge(VALUE x, VALUE y)
*/
static VALUE
-fix_lt(VALUE x, VALUE y)
+fix_lt(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
- if (FIX2LONG(x) < FIX2LONG(y)) return Qtrue;
+ long a = FIX2LONG(x), b = FIX2LONG(y);
+
+ if (a < b) return Qtrue;
return Qfalse;
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) < 0 ? Qtrue : Qfalse;
- case T_FLOAT:
- return (double)FIX2LONG(x) < RFLOAT_VALUE(y) ? Qtrue : Qfalse;
- default:
+ else {
return rb_num_coerce_relop(x, y);
}
}
@@ -2553,18 +2509,16 @@ fix_lt(VALUE x, VALUE y)
*/
static VALUE
-fix_le(VALUE x, VALUE y)
+fix_le(x, y)
+ VALUE x, y;
{
if (FIXNUM_P(y)) {
- if (FIX2LONG(x) <= FIX2LONG(y)) return Qtrue;
+ long a = FIX2LONG(x), b = FIX2LONG(y);
+
+ if (a <= b) return Qtrue;
return Qfalse;
}
- switch (TYPE(y)) {
- case T_BIGNUM:
- return FIX2INT(rb_big_cmp(rb_int2big(FIX2LONG(x)), y)) <= 0 ? Qtrue : Qfalse;
- case T_FLOAT:
- return (double)FIX2LONG(x) <= RFLOAT_VALUE(y) ? Qtrue : Qfalse;
- default:
+ else {
return rb_num_coerce_relop(x, y);
}
}
@@ -2577,7 +2531,8 @@ fix_le(VALUE x, VALUE y)
*/
static VALUE
-fix_rev(VALUE num)
+fix_rev(num)
+ VALUE num;
{
long val = FIX2LONG(num);
@@ -2585,6 +2540,16 @@ fix_rev(VALUE num)
return LONG2NUM(val);
}
+static VALUE
+fix_coerce(x)
+ VALUE x;
+{
+ while (!FIXNUM_P(x) && TYPE(x) != T_BIGNUM) {
+ x = rb_to_int(x);
+ }
+ return x;
+}
+
/*
* call-seq:
* fix & other => integer
@@ -2593,14 +2558,15 @@ fix_rev(VALUE num)
*/
static VALUE
-fix_and(VALUE x, VALUE y)
+fix_and(x, y)
+ VALUE x, y;
{
long val;
- if (TYPE(y) == T_BIGNUM) {
+ if (!FIXNUM_P(y = fix_coerce(y))) {
return rb_big_and(y, x);
}
- val = FIX2LONG(x) & NUM2LONG(y);
+ val = FIX2LONG(x) & FIX2LONG(y);
return LONG2NUM(val);
}
@@ -2612,14 +2578,15 @@ fix_and(VALUE x, VALUE y)
*/
static VALUE
-fix_or(VALUE x, VALUE y)
+fix_or(x, y)
+ VALUE x, y;
{
long val;
- if (TYPE(y) == T_BIGNUM) {
+ if (!FIXNUM_P(y = fix_coerce(y))) {
return rb_big_or(y, x);
}
- val = FIX2LONG(x) | NUM2LONG(y);
+ val = FIX2LONG(x) | FIX2LONG(y);
return LONG2NUM(val);
}
@@ -2631,19 +2598,20 @@ fix_or(VALUE x, VALUE y)
*/
static VALUE
-fix_xor(VALUE x, VALUE y)
+fix_xor(x, y)
+ VALUE x, y;
{
long val;
- if (TYPE(y) == T_BIGNUM) {
+ if (!FIXNUM_P(y = fix_coerce(y))) {
return rb_big_xor(y, x);
}
- val = FIX2LONG(x) ^ NUM2LONG(y);
+ val = FIX2LONG(x) ^ FIX2LONG(y);
return LONG2NUM(val);
}
-static VALUE fix_lshift(long, unsigned long);
-static VALUE fix_rshift(long, unsigned long);
+static VALUE fix_lshift _((long, unsigned long));
+static VALUE fix_rshift _((long, unsigned long));
/*
* call-seq:
@@ -2653,7 +2621,8 @@ static VALUE fix_rshift(long, unsigned long);
*/
static VALUE
-rb_fix_lshift(VALUE x, VALUE y)
+rb_fix_lshift(x, y)
+ VALUE x, y;
{
long val, width;
@@ -2667,10 +2636,12 @@ rb_fix_lshift(VALUE x, VALUE y)
}
static VALUE
-fix_lshift(long val, unsigned long width)
+fix_lshift(val, width)
+ long val;
+ unsigned long width;
{
- if (width > (SIZEOF_LONG*CHAR_BIT-1)
- || ((unsigned long)val)>>(SIZEOF_LONG*CHAR_BIT-1-width) > 0) {
+ if (width > (sizeof(VALUE)*CHAR_BIT-1)
+ || ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) {
return rb_big_lshift(rb_int2big(val), ULONG2NUM(width));
}
val = val << width;
@@ -2685,7 +2656,8 @@ fix_lshift(long val, unsigned long width)
*/
static VALUE
-rb_fix_rshift(VALUE x, VALUE y)
+rb_fix_rshift(x, y)
+ VALUE x, y;
{
long i, val;
@@ -2727,23 +2699,24 @@ fix_rshift(long val, unsigned long i)
*/
static VALUE
-fix_aref(VALUE fix, VALUE idx)
+fix_aref(fix, idx)
+ VALUE fix, idx;
{
long val = FIX2LONG(fix);
long i;
- if (TYPE(idx) == T_BIGNUM) {
+ if (!FIXNUM_P(idx = fix_coerce(idx))) {
idx = rb_big_norm(idx);
if (!FIXNUM_P(idx)) {
- if (!RBIGNUM_SIGN(idx) || val >= 0)
+ if (!RBIGNUM(idx)->sign || val >= 0)
return INT2FIX(0);
return INT2FIX(1);
}
}
- i = NUM2LONG(idx);
+ i = FIX2LONG(idx);
if (i < 0) return INT2FIX(0);
- if (SIZEOF_LONG*CHAR_BIT-1 < i) {
+ if (sizeof(VALUE)*CHAR_BIT-1 < i) {
if (val < 0) return INT2FIX(1);
return INT2FIX(0);
}
@@ -2761,13 +2734,14 @@ fix_aref(VALUE fix, VALUE idx)
*/
static VALUE
-fix_to_f(VALUE num)
+fix_to_f(num)
+ VALUE num;
{
double val;
val = (double)FIX2LONG(num);
- return DOUBLE2NUM(val);
+ return rb_float_new(val);
}
/*
@@ -2782,7 +2756,8 @@ fix_to_f(VALUE num)
*/
static VALUE
-fix_abs(VALUE fix)
+fix_abs(fix)
+ VALUE fix;
{
long i = FIX2LONG(fix);
@@ -2807,10 +2782,11 @@ fix_abs(VALUE fix)
*/
static VALUE
-fix_id2name(VALUE fix)
+fix_id2name(fix)
+ VALUE fix;
{
- VALUE name = rb_id2str(FIX2UINT(fix));
- if (name) return rb_str_dup(name);
+ const char *name = rb_id2name(FIX2UINT(fix));
+ if (name) return rb_str_new2(name);
return Qnil;
}
@@ -2828,7 +2804,8 @@ fix_id2name(VALUE fix)
*/
static VALUE
-fix_to_sym(VALUE fix)
+fix_to_sym(fix)
+ VALUE fix;
{
ID id = FIX2UINT(fix);
@@ -2852,7 +2829,8 @@ fix_to_sym(VALUE fix)
*/
static VALUE
-fix_size(VALUE fix)
+fix_size(fix)
+ VALUE fix;
{
return INT2FIX(sizeof(long));
}
@@ -2872,9 +2850,11 @@ fix_size(VALUE fix)
*/
static VALUE
-int_upto(VALUE from, VALUE to)
+int_upto(from, to)
+ VALUE from, to;
{
RETURN_ENUMERATOR(from, 1, &to);
+
if (FIXNUM_P(from) && FIXNUM_P(to)) {
long i, end;
@@ -2911,9 +2891,11 @@ int_upto(VALUE from, VALUE to)
*/
static VALUE
-int_downto(VALUE from, VALUE to)
+int_downto(from, to)
+ VALUE from, to;
{
RETURN_ENUMERATOR(from, 1, &to);
+
if (FIXNUM_P(from) && FIXNUM_P(to)) {
long i, end;
@@ -2951,7 +2933,8 @@ int_downto(VALUE from, VALUE to)
*/
static VALUE
-int_dotimes(VALUE num)
+int_dotimes(num)
+ VALUE num;
{
RETURN_ENUMERATOR(num, 0, 0);
@@ -2975,43 +2958,6 @@ int_dotimes(VALUE num)
return num;
}
-static VALUE
-int_round(int argc, VALUE* argv, VALUE num)
-{
- VALUE n, f, h, r;
- int ndigits;
-
- if (argc == 0) return num;
- rb_scan_args(argc, argv, "1", &n);
- ndigits = NUM2INT(n);
- if (ndigits > 0) {
- return rb_Float(num);
- }
- if (ndigits == 0) {
- return num;
- }
- ndigits = -ndigits;
- if (ndigits < 0) {
- rb_raise(rb_eArgError, "ndigits out of range");
- }
- f = int_pow(10, ndigits);
- if (FIXNUM_P(num) && FIXNUM_P(f)) {
- SIGNED_VALUE x = FIX2LONG(num), y = FIX2LONG(f);
- int neg = x < 0;
- if (neg) x = -x;
- x = (x + y / 2) / y * y;
- if (neg) x = -x;
- return LONG2NUM(x);
- }
- h = rb_funcall(f, '/', 1, INT2FIX(2));
- r = rb_funcall(num, '%', 1, f);
- n = rb_funcall(num, '-', 1, r);
- if (!RTEST(rb_funcall(r, '<', 1, h))) {
- n = rb_funcall(n, '+', 1, f);
- }
- return n;
-}
-
/*
* call-seq:
* fix.zero? => true or false
@@ -3021,7 +2967,8 @@ int_round(int argc, VALUE* argv, VALUE num)
*/
static VALUE
-fix_zero_p(VALUE num)
+fix_zero_p(num)
+ VALUE num;
{
if (FIX2LONG(num) == 0) {
return Qtrue;
@@ -3040,7 +2987,7 @@ static VALUE
fix_odd_p(VALUE num)
{
if (num & 2) {
- return Qtrue;
+ return Qtrue;
}
return Qfalse;
}
@@ -3056,13 +3003,13 @@ static VALUE
fix_even_p(VALUE num)
{
if (num & 2) {
- return Qfalse;
+ return Qfalse;
}
return Qtrue;
}
void
-Init_Numeric(void)
+Init_Numeric()
{
#if defined(__FreeBSD__) && __FreeBSD__ < 4
/* allow divide by zero -- Inf */
@@ -3100,14 +3047,13 @@ Init_Numeric(void)
rb_define_method(rb_cNumeric, "abs", num_abs, 0);
rb_define_method(rb_cNumeric, "to_int", num_to_int, 0);
- rb_define_method(rb_cNumeric, "scalar?", num_scalar_p, 0);
rb_define_method(rb_cNumeric, "integer?", num_int_p, 0);
rb_define_method(rb_cNumeric, "zero?", num_zero_p, 0);
rb_define_method(rb_cNumeric, "nonzero?", num_nonzero_p, 0);
rb_define_method(rb_cNumeric, "floor", num_floor, 0);
rb_define_method(rb_cNumeric, "ceil", num_ceil, 0);
- rb_define_method(rb_cNumeric, "round", num_round, -1);
+ rb_define_method(rb_cNumeric, "round", num_round, 0);
rb_define_method(rb_cNumeric, "truncate", num_truncate, 0);
rb_define_method(rb_cNumeric, "step", num_step, -1);
@@ -3125,13 +3071,14 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "succ", int_succ, 0);
rb_define_method(rb_cInteger, "next", int_succ, 0);
rb_define_method(rb_cInteger, "pred", int_pred, 0);
- rb_define_method(rb_cInteger, "chr", int_chr, -1);
+ rb_define_method(rb_cInteger, "chr", int_chr, 0);
+ rb_define_method(rb_cInteger, "ord", int_ord, 0);
rb_define_method(rb_cInteger, "to_i", int_to_i, 0);
rb_define_method(rb_cInteger, "to_int", int_to_i, 0);
rb_define_method(rb_cInteger, "floor", int_to_i, 0);
rb_define_method(rb_cInteger, "ceil", int_to_i, 0);
+ rb_define_method(rb_cInteger, "round", int_to_i, 0);
rb_define_method(rb_cInteger, "truncate", int_to_i, 0);
- rb_define_method(rb_cInteger, "round", int_round, -1);
rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);
rb_include_module(rb_cFixnum, rb_mPrecision);
@@ -3148,7 +3095,7 @@ Init_Numeric(void)
rb_define_method(rb_cFixnum, "-", fix_minus, 1);
rb_define_method(rb_cFixnum, "*", fix_mul, 1);
rb_define_method(rb_cFixnum, "/", fix_div, 1);
- rb_define_method(rb_cFixnum, "div", fix_idiv, 1);
+ rb_define_method(rb_cFixnum, "div", fix_div, 1);
rb_define_method(rb_cFixnum, "%", fix_mod, 1);
rb_define_method(rb_cFixnum, "modulo", fix_mod, 1);
rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1);
@@ -3179,7 +3126,6 @@ Init_Numeric(void)
rb_define_method(rb_cFixnum, "zero?", fix_zero_p, 0);
rb_define_method(rb_cFixnum, "odd?", fix_odd_p, 0);
rb_define_method(rb_cFixnum, "even?", fix_even_p, 0);
- rb_define_method(rb_cFixnum, "succ", fix_succ, 0);
rb_cFloat = rb_define_class("Float", rb_cNumeric);
@@ -3197,9 +3143,9 @@ Init_Numeric(void)
rb_define_const(rb_cFloat, "MAX_EXP", INT2FIX(DBL_MAX_EXP));
rb_define_const(rb_cFloat, "MIN_10_EXP", INT2FIX(DBL_MIN_10_EXP));
rb_define_const(rb_cFloat, "MAX_10_EXP", INT2FIX(DBL_MAX_10_EXP));
- rb_define_const(rb_cFloat, "MIN", DOUBLE2NUM(DBL_MIN));
- rb_define_const(rb_cFloat, "MAX", DOUBLE2NUM(DBL_MAX));
- rb_define_const(rb_cFloat, "EPSILON", DOUBLE2NUM(DBL_EPSILON));
+ rb_define_const(rb_cFloat, "MIN", rb_float_new(DBL_MIN));
+ rb_define_const(rb_cFloat, "MAX", rb_float_new(DBL_MAX));
+ rb_define_const(rb_cFloat, "EPSILON", rb_float_new(DBL_EPSILON));
rb_define_method(rb_cFloat, "to_s", flo_to_s, 0);
rb_define_method(rb_cFloat, "coerce", flo_coerce, 1);
@@ -3228,7 +3174,7 @@ Init_Numeric(void)
rb_define_method(rb_cFloat, "to_int", flo_truncate, 0);
rb_define_method(rb_cFloat, "floor", flo_floor, 0);
rb_define_method(rb_cFloat, "ceil", flo_ceil, 0);
- rb_define_method(rb_cFloat, "round", flo_round, -1);
+ rb_define_method(rb_cFloat, "round", flo_round, 0);
rb_define_method(rb_cFloat, "truncate", flo_truncate, 0);
rb_define_method(rb_cFloat, "nan?", flo_is_nan_p, 0);
diff --git a/object.c b/object.c
index 29c98356a4..75153b843a 100644
--- a/object.c
+++ b/object.c
@@ -6,22 +6,20 @@
$Date$
created at: Thu Jul 15 12:01:24 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/st.h"
-#include "ruby/util.h"
-#include "debug.h"
+#include "ruby.h"
+#include "st.h"
+#include "util.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <math.h>
-VALUE rb_cBasicObject;
VALUE rb_mKernel;
VALUE rb_cObject;
VALUE rb_cModule;
@@ -31,8 +29,9 @@ VALUE rb_cData;
VALUE rb_cNilClass;
VALUE rb_cTrueClass;
VALUE rb_cFalseClass;
+VALUE rb_cSymbol;
-static ID id_eq, id_eql, id_match, id_inspect, id_init_copy;
+static ID id_eq, id_eql, id_inspect, id_init_copy;
/*
* call-seq:
@@ -44,7 +43,8 @@ static ID id_eq, id_eql, id_match, id_inspect, id_init_copy;
*/
VALUE
-rb_equal(VALUE obj1, VALUE obj2)
+rb_equal(obj1, obj2)
+ VALUE obj1, obj2;
{
VALUE result;
@@ -55,7 +55,8 @@ rb_equal(VALUE obj1, VALUE obj2)
}
int
-rb_eql(VALUE obj1, VALUE obj2)
+rb_eql(obj1, obj2)
+ VALUE obj1, obj2;
{
return RTEST(rb_funcall(obj1, id_eql, 1, obj2));
}
@@ -77,20 +78,21 @@ rb_eql(VALUE obj1, VALUE obj2)
* object as <code>b</code>).
*
* The <code>eql?</code> method returns <code>true</code> if
- * <i>obj</i> and <i>anObject</i> have the same value. Used by
- * <code>Hash</code> to test members for equality. For objects of
- * class <code>Object</code>, <code>eql?</code> is synonymous with
- * <code>==</code>. Subclasses normally continue this tradition, but
- * there are exceptions. <code>Numeric</code> types, for example,
- * perform type conversion across <code>==</code>, but not across
- * <code>eql?</code>, so:
+ <i>obj</i> and <i>anObject</i> have the
+ * same value. Used by <code>Hash</code> to test members for equality.
+ * For objects of class <code>Object</code>, <code>eql?</code> is
+ * synonymous with <code>==</code>. Subclasses normally continue this
+ * tradition, but there are exceptions. <code>Numeric</code> types, for
+ * example, perform type conversion across <code>==</code>, but not
+ * across <code>eql?</code>, so:
*
* 1 == 1.0 #=> true
* 1.eql? 1.0 #=> false
*/
-VALUE
-rb_obj_equal(VALUE obj1, VALUE obj2)
+static VALUE
+rb_obj_equal(obj1, obj2)
+ VALUE obj1, obj2;
{
if (obj1 == obj2) return Qtrue;
return Qfalse;
@@ -98,41 +100,44 @@ rb_obj_equal(VALUE obj1, VALUE obj2)
/*
* call-seq:
- * !obj => true or false
- *
- * Boolean negate.
+ * obj.id => fixnum
+ *
+ * Soon-to-be deprecated version of <code>Object#object_id</code>.
*/
VALUE
-rb_obj_not(VALUE obj)
+rb_obj_id_obsolete(obj)
+ VALUE obj;
{
- return RTEST(obj) ? Qfalse : Qtrue;
+ rb_warn("Object#id will be deprecated; use Object#object_id");
+ return rb_obj_id(obj);
+}
+
+VALUE
+rb_class_real(cl)
+ VALUE cl;
+{
+ while (FL_TEST(cl, FL_SINGLETON) || TYPE(cl) == T_ICLASS) {
+ cl = RCLASS(cl)->super;
+ }
+ return cl;
}
/*
* call-seq:
- * obj != other => true or false
- *
- * Returns true if two objects are not-equal, otherwise false.
+ * obj.type => class
+ *
+ * Deprecated synonym for <code>Object#class</code>.
*/
VALUE
-rb_obj_not_equal(VALUE obj1, VALUE obj2)
+rb_obj_type(obj)
+ VALUE obj;
{
- VALUE result = rb_funcall(obj1, id_eq, 1, obj2);
- return RTEST(result) ? Qfalse : Qtrue;
+ rb_warn("Object#type is deprecated; use Object#class");
+ return rb_class_real(CLASS_OF(obj));
}
-VALUE
-rb_class_real(VALUE cl)
-{
- if (cl == 0)
- return 0;
- while ((RBASIC(cl)->flags & FL_SINGLETON) || BUILTIN_TYPE(cl) == T_ICLASS) {
- cl = RCLASS_SUPER(cl);
- }
- return cl;
-}
/*
* call-seq:
@@ -149,51 +154,36 @@ rb_class_real(VALUE cl)
*/
VALUE
-rb_obj_class(VALUE obj)
+rb_obj_class(obj)
+ VALUE obj;
{
return rb_class_real(CLASS_OF(obj));
}
static void
-init_copy(VALUE dest, VALUE obj)
+init_copy(dest, obj)
+ VALUE dest, obj;
{
if (OBJ_FROZEN(dest)) {
rb_raise(rb_eTypeError, "[bug] frozen object (%s) allocated", rb_obj_classname(dest));
}
RBASIC(dest)->flags &= ~(T_MASK|FL_EXIVAR);
RBASIC(dest)->flags |= RBASIC(obj)->flags & (T_MASK|FL_EXIVAR|FL_TAINT);
- rb_copy_generic_ivar(dest, obj);
+ if (FL_TEST(obj, FL_EXIVAR)) {
+ rb_copy_generic_ivar(dest, obj);
+ }
rb_gc_copy_finalizer(dest, obj);
switch (TYPE(obj)) {
case T_OBJECT:
- if (!(RBASIC(dest)->flags & ROBJECT_EMBED) && ROBJECT_PTR(dest)) {
- xfree(ROBJECT_PTR(dest));
- ROBJECT(dest)->as.heap.ptr = 0;
- ROBJECT(dest)->as.heap.len = 0;
- }
- if (RBASIC(obj)->flags & ROBJECT_EMBED) {
- MEMCPY(ROBJECT(dest)->as.ary, ROBJECT(obj)->as.ary, VALUE, ROBJECT_EMBED_LEN_MAX);
- RBASIC(dest)->flags |= ROBJECT_EMBED;
- }
- else {
- long len = ROBJECT(obj)->as.heap.len;
- VALUE *ptr = ALLOC_N(VALUE, len);
- MEMCPY(ptr, ROBJECT(obj)->as.heap.ptr, VALUE, len);
- ROBJECT(dest)->as.heap.ptr = ptr;
- ROBJECT(dest)->as.heap.len = len;
- RBASIC(dest)->flags &= ~ROBJECT_EMBED;
- }
- break;
case T_CLASS:
case T_MODULE:
- if (RCLASS_IV_TBL(dest)) {
- st_free_table(RCLASS_IV_TBL(dest));
- RCLASS_IV_TBL(dest) = 0;
+ if (ROBJECT(dest)->iv_tbl) {
+ st_free_table(ROBJECT(dest)->iv_tbl);
+ ROBJECT(dest)->iv_tbl = 0;
}
- if (RCLASS_IV_TBL(obj)) {
- RCLASS_IV_TBL(dest) = st_copy(RCLASS_IV_TBL(obj));
+ if (ROBJECT(obj)->iv_tbl) {
+ ROBJECT(dest)->iv_tbl = st_copy(ROBJECT(obj)->iv_tbl);
}
- break;
}
rb_funcall(dest, id_init_copy, 1, obj);
}
@@ -223,7 +213,8 @@ init_copy(VALUE dest, VALUE obj)
*/
VALUE
-rb_obj_clone(VALUE obj)
+rb_obj_clone(obj)
+ VALUE obj;
{
VALUE clone;
@@ -258,7 +249,8 @@ rb_obj_clone(VALUE obj)
*/
VALUE
-rb_obj_dup(VALUE obj)
+rb_obj_dup(obj)
+ VALUE obj;
{
VALUE dup;
@@ -273,7 +265,8 @@ rb_obj_dup(VALUE obj)
/* :nodoc: */
VALUE
-rb_obj_init_copy(VALUE obj, VALUE orig)
+rb_obj_init_copy(obj, orig)
+ VALUE obj, orig;
{
if (obj == orig) return obj;
rb_check_frozen(obj);
@@ -285,6 +278,30 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
/*
* call-seq:
+ * obj.to_a -> anArray
+ *
+ * Returns an array representation of <i>obj</i>. For objects of class
+ * <code>Object</code> and others that don't explicitly override the
+ * method, the return value is an array containing <code>self</code>.
+ * However, this latter behavior will soon be obsolete.
+ *
+ * self.to_a #=> -:1: warning: default `to_a' will be obsolete
+ * "hello".to_a #=> ["hello"]
+ * Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"]
+ */
+
+
+static VALUE
+rb_any_to_a(obj)
+ VALUE obj;
+{
+ rb_warn("default `to_a' will be obsolete");
+ return rb_ary_new3(1, obj);
+}
+
+
+/*
+ * call-seq:
* obj.to_s => string
*
* Returns a string representing <i>obj</i>. The default
@@ -294,25 +311,34 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
*/
VALUE
-rb_any_to_s(VALUE obj)
+rb_any_to_s(obj)
+ VALUE obj;
{
- char *cname = rb_obj_classname(obj);
+ const char *cname = rb_obj_classname(obj);
+ size_t len;
VALUE str;
- str = rb_sprintf("#<%s:%p>", cname, (void*)obj);
+ len = strlen(cname)+6+16;
+ str = rb_str_new(0, len); /* 6:tags 16:addr */
+ snprintf(RSTRING(str)->ptr, len+1, "#<%s:0x%lx>", cname, obj);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(obj)) OBJ_TAINT(str);
return str;
}
VALUE
-rb_inspect(VALUE obj)
+rb_inspect(obj)
+ VALUE obj;
{
return rb_obj_as_string(rb_funcall(obj, id_inspect, 0, 0));
}
static int
-inspect_i(ID id, VALUE value, VALUE str)
+inspect_i(id, value, str)
+ ID id;
+ VALUE value;
+ VALUE str;
{
VALUE str2;
const char *ivname;
@@ -320,8 +346,8 @@ inspect_i(ID id, VALUE value, VALUE str)
/* need not to show internal data */
if (CLASS_OF(value) == 0) return ST_CONTINUE;
if (!rb_is_instance_id(id)) return ST_CONTINUE;
- if (RSTRING_PTR(str)[0] == '-') { /* first element */
- RSTRING_PTR(str)[0] = '#';
+ if (RSTRING(str)->ptr[0] == '-') { /* first element */
+ RSTRING(str)->ptr[0] = '#';
rb_str_cat2(str, " ");
}
else {
@@ -338,16 +364,12 @@ inspect_i(ID id, VALUE value, VALUE str)
}
static VALUE
-inspect_obj(VALUE obj, VALUE str, int recur)
+inspect_obj(obj, str)
+ VALUE obj, str;
{
- if (recur) {
- rb_str_cat2(str, " ...");
- }
- else {
- rb_ivar_foreach(obj, inspect_i, str);
- }
+ st_foreach_safe(ROBJECT(obj)->iv_tbl, inspect_i, str);
rb_str_cat2(str, ">");
- RSTRING_PTR(str)[0] = '#';
+ RSTRING(str)->ptr[0] = '#';
OBJ_INFECT(str, obj);
return str;
@@ -367,30 +389,28 @@ inspect_obj(VALUE obj, VALUE str, int recur)
static VALUE
-rb_obj_inspect(VALUE obj)
+rb_obj_inspect(obj)
+ VALUE obj;
{
-
- if (TYPE(obj) == T_OBJECT) {
- int has_ivar = 0;
- VALUE *ptr = ROBJECT_PTR(obj);
- long len = ROBJECT_LEN(obj);
- long i;
-
- for (i = 0; i < len; i++) {
- if (ptr[i] != Qundef) {
- has_ivar = 1;
- break;
- }
- }
-
- if (has_ivar) {
- VALUE str;
- char *c;
-
- c = rb_obj_classname(obj);
- str = rb_sprintf("-<%s:%p", c, (void*)obj);
- return rb_exec_recursive(inspect_obj, obj, str);
- }
+ if (TYPE(obj) == T_OBJECT
+ && ROBJECT(obj)->iv_tbl
+ && ROBJECT(obj)->iv_tbl->num_entries > 0) {
+ VALUE str;
+ size_t len;
+ const char *c = rb_obj_classname(obj);
+
+ if (rb_inspecting_p(obj)) {
+ len = strlen(c)+10+16+1;
+ str = rb_str_new(0, len); /* 10:tags 16:addr 1:nul */
+ snprintf(RSTRING(str)->ptr, len, "#<%s:0x%lx ...>", c, obj);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ return str;
+ }
+ len = strlen(c)+6+16+1;
+ str = rb_str_new(0, len); /* 6:tags 16:addr 1:nul */
+ snprintf(RSTRING(str)->ptr, len, "-<%s:0x%lx", c, obj);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ return rb_protect_inspect(inspect_obj, obj, str);
}
return rb_funcall(obj, rb_intern("to_s"), 0, 0);
}
@@ -405,7 +425,8 @@ rb_obj_inspect(VALUE obj)
*/
VALUE
-rb_obj_is_instance_of(VALUE obj, VALUE c)
+rb_obj_is_instance_of(obj, c)
+ VALUE obj, c;
{
switch (TYPE(c)) {
case T_MODULE:
@@ -448,7 +469,8 @@ rb_obj_is_instance_of(VALUE obj, VALUE c)
*/
VALUE
-rb_obj_is_kind_of(VALUE obj, VALUE c)
+rb_obj_is_kind_of(obj, c)
+ VALUE obj, c;
{
VALUE cl = CLASS_OF(obj);
@@ -463,9 +485,9 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
}
while (cl) {
- if (cl == c || RCLASS_M_TBL(cl) == RCLASS_M_TBL(c))
+ if (cl == c || RCLASS(cl)->m_tbl == RCLASS(c)->m_tbl)
return Qtrue;
- cl = RCLASS_SUPER(cl);
+ cl = RCLASS(cl)->super;
}
return Qfalse;
}
@@ -479,15 +501,21 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
* The primary purpose of this method is to "tap into" a method chain,
* in order to perform operations on intermediate results within the chain.
*
- * (1..10) .tap {|x| puts "original: #{x.inspect}"}
- * .to_a .tap {|x| puts "array: #{x.inspect}"}
- * .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"}
- * .map { |x| x*x } .tap {|x| puts "squares: #{x.inspect}"}
+ * (1..10).tap {
+ * |x| puts "original: #{x.inspect}"
+ * }.to_a.tap {
+ * |x| puts "array: #{x.inspect}"
+ * }.select {|x| x%2==0}.tap {
+ * |x| puts "evens: #{x.inspect}"
+ * }.map {|x| x*x}.tap {
+ * |x| puts "squares: #{x.inspect}"
+ * }
*
*/
VALUE
-rb_obj_tap(VALUE obj)
+rb_obj_tap(obj)
+ VALUE obj;
{
rb_yield(obj);
return obj;
@@ -628,7 +656,7 @@ rb_obj_tap(VALUE obj)
*/
static VALUE
-rb_obj_dummy(void)
+rb_obj_dummy()
{
return Qnil;
}
@@ -641,7 +669,8 @@ rb_obj_dummy(void)
*/
VALUE
-rb_obj_tainted(VALUE obj)
+rb_obj_tainted(obj)
+ VALUE obj;
{
if (OBJ_TAINTED(obj))
return Qtrue;
@@ -658,7 +687,8 @@ rb_obj_tainted(VALUE obj)
*/
VALUE
-rb_obj_taint(VALUE obj)
+rb_obj_taint(obj)
+ VALUE obj;
{
rb_secure(4);
if (!OBJ_TAINTED(obj)) {
@@ -679,7 +709,8 @@ rb_obj_taint(VALUE obj)
*/
VALUE
-rb_obj_untaint(VALUE obj)
+rb_obj_untaint(obj)
+ VALUE obj;
{
rb_secure(3);
if (OBJ_TAINTED(obj)) {
@@ -692,12 +723,12 @@ rb_obj_untaint(VALUE obj)
}
void
-rb_obj_infect(VALUE obj1, VALUE obj2)
+rb_obj_infect(obj1, obj2)
+ VALUE obj1, obj2;
{
OBJ_INFECT(obj1, obj2);
}
-static st_table *immediate_frozen_tbl = 0;
/*
* call-seq:
@@ -719,19 +750,14 @@ static st_table *immediate_frozen_tbl = 0;
*/
VALUE
-rb_obj_freeze(VALUE obj)
+rb_obj_freeze(obj)
+ VALUE obj;
{
if (!OBJ_FROZEN(obj)) {
if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {
rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
}
OBJ_FREEZE(obj);
- if (SPECIAL_CONST_P(obj)) {
- if (!immediate_frozen_tbl) {
- immediate_frozen_tbl = st_init_numtable();
- }
- st_insert(immediate_frozen_tbl, obj, (st_data_t)Qtrue);
- }
}
return obj;
}
@@ -747,14 +773,11 @@ rb_obj_freeze(VALUE obj)
* a.frozen? #=> true
*/
-VALUE
-rb_obj_frozen_p(VALUE obj)
+static VALUE
+rb_obj_frozen_p(obj)
+ VALUE obj;
{
if (OBJ_FROZEN(obj)) return Qtrue;
- if (SPECIAL_CONST_P(obj)) {
- if (!immediate_frozen_tbl) return Qfalse;
- if (st_lookup(immediate_frozen_tbl, obj, 0)) return Qtrue;
- }
return Qfalse;
}
@@ -776,7 +799,8 @@ rb_obj_frozen_p(VALUE obj)
static VALUE
-nil_to_i(VALUE obj)
+nil_to_i(obj)
+ VALUE obj;
{
return INT2FIX(0);
}
@@ -791,9 +815,10 @@ nil_to_i(VALUE obj)
*/
static VALUE
-nil_to_f(VALUE obj)
+nil_to_f(obj)
+ VALUE obj;
{
- return DOUBLE2NUM(0.0);
+ return rb_float_new(0.0);
}
/*
@@ -801,17 +826,18 @@ nil_to_f(VALUE obj)
* nil.to_s => ""
*
* Always returns the empty string.
+ *
+ * nil.to_s #=> ""
*/
static VALUE
-nil_to_s(VALUE obj)
+nil_to_s(obj)
+ VALUE obj;
{
return rb_str_new2("");
}
/*
- * Document-method: to_a
- *
* call-seq:
* nil.to_a => []
*
@@ -821,7 +847,8 @@ nil_to_s(VALUE obj)
*/
static VALUE
-nil_to_a(VALUE obj)
+nil_to_a(obj)
+ VALUE obj;
{
return rb_ary_new2(0);
}
@@ -834,11 +861,20 @@ nil_to_a(VALUE obj)
*/
static VALUE
-nil_inspect(VALUE obj)
+nil_inspect(obj)
+ VALUE obj;
{
return rb_str_new2("nil");
}
+static VALUE
+main_to_s(obj)
+ VALUE obj;
+{
+ return rb_str_new2("main");
+}
+
+
/***********************************************************************
* Document-class: TrueClass
*
@@ -857,7 +893,8 @@ nil_inspect(VALUE obj)
*/
static VALUE
-true_to_s(VALUE obj)
+true_to_s(obj)
+ VALUE obj;
{
return rb_str_new2("true");
}
@@ -872,7 +909,8 @@ true_to_s(VALUE obj)
*/
static VALUE
-true_and(VALUE obj, VALUE obj2)
+true_and(obj, obj2)
+ VALUE obj, obj2;
{
return RTEST(obj2)?Qtrue:Qfalse;
}
@@ -894,7 +932,8 @@ true_and(VALUE obj, VALUE obj2)
*/
static VALUE
-true_or(VALUE obj, VALUE obj2)
+true_or(obj, obj2)
+ VALUE obj, obj2;
{
return Qtrue;
}
@@ -910,7 +949,8 @@ true_or(VALUE obj, VALUE obj2)
*/
static VALUE
-true_xor(VALUE obj, VALUE obj2)
+true_xor(obj, obj2)
+ VALUE obj, obj2;
{
return RTEST(obj2)?Qfalse:Qtrue;
}
@@ -934,7 +974,8 @@ true_xor(VALUE obj, VALUE obj2)
*/
static VALUE
-false_to_s(VALUE obj)
+false_to_s(obj)
+ VALUE obj;
{
return rb_str_new2("false");
}
@@ -950,7 +991,8 @@ false_to_s(VALUE obj)
*/
static VALUE
-false_and(VALUE obj, VALUE obj2)
+false_and(obj, obj2)
+ VALUE obj, obj2;
{
return Qfalse;
}
@@ -966,7 +1008,8 @@ false_and(VALUE obj, VALUE obj2)
*/
static VALUE
-false_or(VALUE obj, VALUE obj2)
+false_or(obj, obj2)
+ VALUE obj, obj2;
{
return RTEST(obj2)?Qtrue:Qfalse;
}
@@ -985,7 +1028,8 @@ false_or(VALUE obj, VALUE obj2)
*/
static VALUE
-false_xor(VALUE obj, VALUE obj2)
+false_xor(obj, obj2)
+ VALUE obj, obj2;
{
return RTEST(obj2)?Qtrue:Qfalse;
}
@@ -998,7 +1042,8 @@ false_xor(VALUE obj, VALUE obj2)
*/
static VALUE
-rb_true(VALUE obj)
+rb_true(obj)
+ VALUE obj;
{
return Qtrue;
}
@@ -1013,7 +1058,8 @@ rb_true(VALUE obj)
static VALUE
-rb_false(VALUE obj)
+rb_false(obj)
+ VALUE obj;
{
return Qfalse;
}
@@ -1021,7 +1067,7 @@ rb_false(VALUE obj)
/*
* call-seq:
- * obj =~ other => nil
+ * obj =~ other => false
*
* Pattern Match---Overridden by descendents (notably
* <code>Regexp</code> and <code>String</code>) to provide meaningful
@@ -1029,23 +1075,170 @@ rb_false(VALUE obj)
*/
static VALUE
-rb_obj_match(VALUE obj1, VALUE obj2)
+rb_obj_pattern_match(obj1, obj2)
+ VALUE obj1, obj2;
{
- return Qnil;
+ return Qfalse;
+}
+
+/**********************************************************************
+ * Document-class: Symbol
+ *
+ * <code>Symbol</code> objects represent names and some strings
+ * inside the Ruby
+ * interpreter. They are generated using the <code>:name</code> and
+ * <code>:"string"</code> literals
+ * syntax, and by the various <code>to_sym</code> methods. The same
+ * <code>Symbol</code> object will be created for a given name or string
+ * for the duration of a program's execution, regardless of the context
+ * or meaning of that name. Thus if <code>Fred</code> is a constant in
+ * one context, a method in another, and a class in a third, the
+ * <code>Symbol</code> <code>:Fred</code> will be the same object in
+ * all three contexts.
+ *
+ * module One
+ * class Fred
+ * end
+ * $f1 = :Fred
+ * end
+ * module Two
+ * Fred = 1
+ * $f2 = :Fred
+ * end
+ * def Fred()
+ * end
+ * $f3 = :Fred
+ * $f1.id #=> 2514190
+ * $f2.id #=> 2514190
+ * $f3.id #=> 2514190
+ *
+ */
+
+/*
+ * call-seq:
+ * sym.to_i => fixnum
+ *
+ * Returns an integer that is unique for each symbol within a
+ * particular execution of a program.
+ *
+ * :fred.to_i #=> 9809
+ * "fred".to_sym.to_i #=> 9809
+ */
+
+static VALUE
+sym_to_i(sym)
+ VALUE sym;
+{
+ ID id = SYM2ID(sym);
+
+ return LONG2FIX(id);
+}
+
+
+/* :nodoc: */
+
+static VALUE
+sym_to_int(sym)
+ VALUE sym;
+{
+ rb_warning("treating Symbol as an integer");
+ return sym_to_i(sym);
}
+
/*
* call-seq:
- * obj !~ other => nil
+ * sym.inspect => string
*
- * Returns true if two objects does not match, using <i>=~</i> method.
+ * Returns the representation of <i>sym</i> as a symbol literal.
+ *
+ * :fred.inspect #=> ":fred"
*/
static VALUE
-rb_obj_not_match(VALUE obj1, VALUE obj2)
+sym_inspect(sym)
+ VALUE sym;
{
- VALUE result = rb_funcall(obj1, id_match, 1, obj2);
- return RTEST(result) ? Qfalse : Qtrue;
+ VALUE str;
+ const char *name;
+ ID id = SYM2ID(sym);
+
+ name = rb_id2name(id);
+ str = rb_str_new(0, strlen(name)+1);
+ RSTRING(str)->ptr[0] = ':';
+ strcpy(RSTRING(str)->ptr+1, name);
+ if (!rb_symname_p(name)) {
+ str = rb_str_dump(str);
+ strncpy(RSTRING(str)->ptr, ":\"", 2);
+ }
+ return str;
+}
+
+
+/*
+ * call-seq:
+ * sym.id2name => string
+ * sym.to_s => string
+ *
+ * Returns the name or string corresponding to <i>sym</i>.
+ *
+ * :fred.id2name #=> "fred"
+ */
+
+
+static VALUE
+sym_to_s(sym)
+ VALUE sym;
+{
+ return rb_str_new2(rb_id2name(SYM2ID(sym)));
+}
+
+
+/*
+ * call-seq:
+ * sym.to_sym => sym
+ *
+ * In general, <code>to_sym</code> returns the <code>Symbol</code> corresponding
+ * to an object. As <i>sym</i> is already a symbol, <code>self</code> is returned
+ * in this case.
+ */
+
+static VALUE
+sym_to_sym(sym)
+ VALUE sym;
+{
+ return sym;
+}
+
+
+static VALUE
+sym_call(args, mid)
+ VALUE args, mid;
+{
+ VALUE obj;
+
+ if (RARRAY(args)->len < 1) {
+ rb_raise(rb_eArgError, "no receiver given");
+ }
+ obj = rb_ary_shift(args);
+ return rb_apply(obj, (ID)mid, args);
+}
+
+VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
+
+/*
+ * call-seq:
+ * sym.to_proc
+ *
+ * Returns a _Proc_ object which respond to the given method by _sym_.
+ *
+ * (1..3).collect(&:to_s) #=> ["1", "2", "3"]
+ */
+
+static VALUE
+sym_to_proc(VALUE sym)
+{
+ return rb_proc_new(sym_call, (VALUE)SYM2ID(sym));
}
@@ -1087,7 +1280,9 @@ rb_obj_not_match(VALUE obj1, VALUE obj2)
*/
static VALUE
-rb_mod_to_s(VALUE klass)
+rb_mod_to_s(klass)
+ VALUE klass;
+
{
if (FL_TEST(klass, FL_SINGLETON)) {
VALUE s = rb_str_new2("#<");
@@ -1117,7 +1312,8 @@ rb_mod_to_s(VALUE klass)
*/
static VALUE
-rb_mod_freeze(VALUE mod)
+rb_mod_freeze(mod)
+ VALUE mod;
{
rb_mod_to_s(mod);
return rb_obj_freeze(mod);
@@ -1134,7 +1330,8 @@ rb_mod_freeze(VALUE mod)
*/
static VALUE
-rb_mod_eqq(VALUE mod, VALUE arg)
+rb_mod_eqq(mod, arg)
+ VALUE mod, arg;
{
return rb_obj_is_kind_of(arg, mod);
}
@@ -1152,7 +1349,8 @@ rb_mod_eqq(VALUE mod, VALUE arg)
*/
VALUE
-rb_class_inherited_p(VALUE mod, VALUE arg)
+rb_class_inherited_p(mod, arg)
+ VALUE mod, arg;
{
VALUE start = mod;
@@ -1164,16 +1362,22 @@ rb_class_inherited_p(VALUE mod, VALUE arg)
default:
rb_raise(rb_eTypeError, "compared with non class/module");
}
+
+ if (FL_TEST(mod, FL_SINGLETON)) {
+ if (RCLASS(mod)->m_tbl == RCLASS(arg)->m_tbl)
+ return Qtrue;
+ mod = RBASIC(mod)->klass;
+ }
while (mod) {
- if (RCLASS_M_TBL(mod) == RCLASS_M_TBL(arg))
+ if (RCLASS(mod)->m_tbl == RCLASS(arg)->m_tbl)
return Qtrue;
- mod = RCLASS_SUPER(mod);
+ mod = RCLASS(mod)->super;
}
/* not mod < arg; check if mod > arg */
while (arg) {
- if (RCLASS_M_TBL(arg) == RCLASS_M_TBL(start))
+ if (RCLASS(arg)->m_tbl == RCLASS(start)->m_tbl)
return Qfalse;
- arg = RCLASS_SUPER(arg);
+ arg = RCLASS(arg)->super;
}
return Qnil;
}
@@ -1190,7 +1394,8 @@ rb_class_inherited_p(VALUE mod, VALUE arg)
*/
static VALUE
-rb_mod_lt(VALUE mod, VALUE arg)
+rb_mod_lt(mod, arg)
+ VALUE mod, arg;
{
if (mod == arg) return Qfalse;
return rb_class_inherited_p(mod, arg);
@@ -1210,7 +1415,8 @@ rb_mod_lt(VALUE mod, VALUE arg)
*/
static VALUE
-rb_mod_ge(VALUE mod, VALUE arg)
+rb_mod_ge(mod, arg)
+ VALUE mod, arg;
{
switch (TYPE(arg)) {
case T_MODULE:
@@ -1235,7 +1441,8 @@ rb_mod_ge(VALUE mod, VALUE arg)
*/
static VALUE
-rb_mod_gt(VALUE mod, VALUE arg)
+rb_mod_gt(mod, arg)
+ VALUE mod, arg;
{
if (mod == arg) return Qfalse;
return rb_mod_ge(mod, arg);
@@ -1253,7 +1460,8 @@ rb_mod_gt(VALUE mod, VALUE arg)
*/
static VALUE
-rb_mod_cmp(VALUE mod, VALUE arg)
+rb_mod_cmp(mod, arg)
+ VALUE mod, arg;
{
VALUE cmp;
@@ -1274,8 +1482,10 @@ rb_mod_cmp(VALUE mod, VALUE arg)
return INT2FIX(1);
}
+static VALUE rb_module_s_alloc _((VALUE));
static VALUE
-rb_module_s_alloc(VALUE klass)
+rb_module_s_alloc(klass)
+ VALUE klass;
{
VALUE mod = rb_module_new();
@@ -1283,8 +1493,10 @@ rb_module_s_alloc(VALUE klass)
return mod;
}
+static VALUE rb_class_s_alloc _((VALUE));
static VALUE
-rb_class_s_alloc(VALUE klass)
+rb_class_s_alloc(klass)
+ VALUE klass;
{
return rb_class_boot(0);
}
@@ -1313,12 +1525,11 @@ rb_class_s_alloc(VALUE klass)
*/
static VALUE
-rb_mod_initialize(VALUE module)
+rb_mod_initialize(module)
+ VALUE module;
{
- extern VALUE rb_mod_module_exec(int argc, VALUE *argv, VALUE mod);
-
if (rb_block_given_p()) {
- rb_mod_module_exec(1, &module, module);
+ rb_mod_module_eval(0, 0, module);
}
return Qnil;
}
@@ -1334,11 +1545,14 @@ rb_mod_initialize(VALUE module)
*/
static VALUE
-rb_class_initialize(int argc, VALUE *argv, VALUE klass)
+rb_class_initialize(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE super;
- if (RCLASS_SUPER(klass) != 0) {
+ if (RCLASS(klass)->super != 0) {
rb_raise(rb_eTypeError, "already initialized class");
}
if (rb_scan_args(argc, argv, "01", &super) == 0) {
@@ -1347,10 +1561,10 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
else {
rb_check_inheritable(super);
}
- RCLASS_SUPER(klass) = super;
+ RCLASS(klass)->super = super;
rb_make_metaclass(klass, RBASIC(super)->klass);
- rb_class_inherited(super, klass);
rb_mod_initialize(klass);
+ rb_class_inherited(super, klass);
return klass;
}
@@ -1359,21 +1573,35 @@ rb_class_initialize(int argc, VALUE *argv, VALUE klass)
* call-seq:
* class.allocate() => obj
*
- * Allocates space for a new object of <i>class</i>'s class. The
- * returned object must be an instance of <i>class</i>.
+ * Allocates space for a new object of <i>class</i>'s class and does not
+ * call initialize on the new instance. The returned object must be an
+ * instance of <i>class</i>.
+ *
+ * klass = Class.new do
+ * def initialize(*args)
+ * @initialized = true
+ * end
+ *
+ * def initialized?
+ * @initialized || false
+ * end
+ * end
+ *
+ * klass.allocate.initialized? #=> false
*
*/
VALUE
-rb_obj_alloc(VALUE klass)
+rb_obj_alloc(klass)
+ VALUE klass;
{
VALUE obj;
- if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject) {
+ if (RCLASS(klass)->super == 0) {
rb_raise(rb_eTypeError, "can't instantiate uninitialized class");
}
if (FL_TEST(klass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "can't create instance of singleton class");
+ rb_raise(rb_eTypeError, "can't create instance of virtual class");
}
obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0);
if (rb_obj_class(obj) != rb_class_real(klass)) {
@@ -1382,8 +1610,10 @@ rb_obj_alloc(VALUE klass)
return obj;
}
+static VALUE rb_class_allocate_instance _((VALUE));
static VALUE
-rb_class_allocate_instance(VALUE klass)
+rb_class_allocate_instance(klass)
+ VALUE klass;
{
NEWOBJ(obj, struct RObject);
OBJSETUP(obj, klass, T_OBJECT);
@@ -1403,7 +1633,10 @@ rb_class_allocate_instance(VALUE klass)
*/
VALUE
-rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
+rb_class_new_instance(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE obj;
@@ -1426,16 +1659,19 @@ rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
*/
static VALUE
-rb_class_superclass(VALUE klass)
+rb_class_superclass(klass)
+ VALUE klass;
{
- VALUE super = RCLASS_SUPER(klass);
+ VALUE super = RCLASS(klass)->super;
if (!super) {
- if (klass == rb_cBasicObject) return Qnil;
rb_raise(rb_eTypeError, "uninitialized class");
}
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ super = RBASIC(klass)->klass;
+ }
while (TYPE(super) == T_ICLASS) {
- super = RCLASS_SUPER(super);
+ super = RCLASS(super)->super;
}
if (!super) {
return Qnil;
@@ -1443,10 +1679,87 @@ rb_class_superclass(VALUE klass)
return super;
}
+static ID
+str_to_id(str)
+ VALUE str;
+{
+ VALUE sym = rb_str_intern(str);
+
+ return SYM2ID(sym);
+}
+
+ID
+rb_to_id(name)
+ VALUE name;
+{
+ VALUE tmp;
+ ID id;
+
+ switch (TYPE(name)) {
+ case T_STRING:
+ return str_to_id(name);
+ case T_FIXNUM:
+ rb_warn("do not use Fixnums as Symbols");
+ id = FIX2LONG(name);
+ if (!rb_id2name(id)) {
+ rb_raise(rb_eArgError, "%ld is not a symbol", id);
+ }
+ break;
+ case T_SYMBOL:
+ id = SYM2ID(name);
+ break;
+ default:
+ tmp = rb_check_string_type(name);
+ if (!NIL_P(tmp)) {
+ return str_to_id(tmp);
+ }
+ rb_raise(rb_eTypeError, "%s is not a symbol", RSTRING(rb_inspect(name))->ptr);
+ }
+ return id;
+}
+
+/*
+ * call-seq:
+ * attr(symbol, writable=false) => nil
+ *
+ * Defines a named attribute for this module, where the name is
+ * <i>symbol.</i><code>id2name</code>, creating an instance variable
+ * (<code>@name</code>) and a corresponding access method to read it.
+ * If the optional <i>writable</i> argument is <code>true</code>, also
+ * creates a method called <code>name=</code> to set the attribute.
+ *
+ * module Mod
+ * attr :size, true
+ * end
+ *
+ * <em>is equivalent to:</em>
+ *
+ * module Mod
+ * def size
+ * @size
+ * end
+ * def size=(val)
+ * @size = val
+ * end
+ * end
+ */
+
+static VALUE
+rb_mod_attr(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE name, pub;
+
+ rb_scan_args(argc, argv, "11", &name, &pub);
+ rb_attr(klass, rb_to_id(name), 1, RTEST(pub), Qtrue);
+ return Qnil;
+}
+
/*
* call-seq:
* attr_reader(symbol, ...) => nil
- * attr(symbol, ...) => nil
*
* Creates instance variables and corresponding methods that return the
* value of each instance variable. Equivalent to calling
@@ -1454,27 +1767,19 @@ rb_class_superclass(VALUE klass)
*/
static VALUE
-rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
+rb_mod_attr_reader(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
int i;
for (i=0; i<argc; i++) {
- rb_attr(klass, rb_to_id(argv[i]), Qtrue, Qfalse, Qtrue);
+ rb_attr(klass, rb_to_id(argv[i]), 1, 0, Qtrue);
}
return Qnil;
}
-VALUE
-rb_mod_attr(int argc, VALUE *argv, VALUE klass)
-{
- if (argc == 2 && (argv[1] == Qtrue || argv[1] == Qfalse)) {
- rb_warning("optional boolean argument is obsoleted");
- rb_attr(klass, rb_to_id(argv[0]), 1, RTEST(argv[1]), Qtrue);
- return Qnil;
- }
- return rb_mod_attr_reader(argc, argv, klass);
-}
-
/*
* call-seq:
* attr_writer(symbol, ...) => nil
@@ -1484,12 +1789,15 @@ rb_mod_attr(int argc, VALUE *argv, VALUE klass)
*/
static VALUE
-rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
+rb_mod_attr_writer(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
int i;
for (i=0; i<argc; i++) {
- rb_attr(klass, rb_to_id(argv[i]), Qfalse, Qtrue, Qtrue);
+ rb_attr(klass, rb_to_id(argv[i]), 0, 1, Qtrue);
}
return Qnil;
}
@@ -1498,10 +1806,8 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
* call-seq:
* attr_accessor(symbol, ...) => nil
*
- * Defines a named attribute for this module, where the name is
- * <i>symbol.</i><code>id2name</code>, creating an instance variable
- * (<code>@name</code>) and a corresponding access method to read it.
- * Also creates a method called <code>name=</code> to set the attribute.
+ * Equivalent to calling ``<code>attr</code><i>symbol</i><code>,
+ * true</code>'' on each <i>symbol</i> in turn.
*
* module Mod
* attr_accessor(:one, :two)
@@ -1510,46 +1816,38 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
*/
static VALUE
-rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
+rb_mod_attr_accessor(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
int i;
for (i=0; i<argc; i++) {
- rb_attr(klass, rb_to_id(argv[i]), Qtrue, Qtrue, Qtrue);
+ rb_attr(klass, rb_to_id(argv[i]), 1, 1, Qtrue);
}
return Qnil;
}
/*
* call-seq:
- * mod.const_get(sym, inherit=true) => obj
+ * mod.const_get(sym) => obj
*
* Returns the value of the named constant in <i>mod</i>.
*
* Math.const_get(:PI) #=> 3.14159265358979
- *
- * If the constant is not defined or is defined by the ancestors and
- * +inherit+ is false, +NameError+ will be raised.
*/
static VALUE
-rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
+rb_mod_const_get(mod, name)
+ VALUE mod, name;
{
- VALUE name, recur;
- ID id;
+ ID id = rb_to_id(name);
- if (argc == 1) {
- name = argv[0];
- recur = Qtrue;
- }
- else {
- rb_scan_args(argc, argv, "11", &name, &recur);
- }
- id = rb_to_id(name);
if (!rb_is_const_id(id)) {
rb_name_error(id, "wrong constant name %s", rb_id2name(id));
}
- return RTEST(recur) ? rb_const_get(mod, id) : rb_const_get_at(mod, id);
+ return rb_const_get(mod, id);
}
/*
@@ -1565,7 +1863,8 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
*/
static VALUE
-rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
+rb_mod_const_set(mod, name, value)
+ VALUE mod, name, value;
{
ID id = rb_to_id(name);
@@ -1578,34 +1877,24 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
/*
* call-seq:
- * mod.const_defined?(sym, inherit=true) => true or false
+ * mod.const_defined?(sym) => true or false
*
* Returns <code>true</code> if a constant with the given name is
- * defined by <i>mod</i>, or its ancestors if +inherit+ is not false.
+ * defined by <i>mod</i>.
*
* Math.const_defined? "PI" #=> true
- * IO.const_defined? "SYNC" #=> true
- * IO.const_defined? "SYNC", false #=> false
*/
static VALUE
-rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
+rb_mod_const_defined(mod, name)
+ VALUE mod, name;
{
- VALUE name, recur;
- ID id;
+ ID id = rb_to_id(name);
- if (argc == 1) {
- name = argv[0];
- recur = Qtrue;
- }
- else {
- rb_scan_args(argc, argv, "11", &name, &recur);
- }
- id = rb_to_id(name);
if (!rb_is_const_id(id)) {
rb_name_error(id, "wrong constant name %s", rb_id2name(id));
}
- return RTEST(recur) ? rb_const_defined(mod, id) : rb_const_defined_at(mod, id);
+ return rb_const_defined_at(mod, id);
}
/*
@@ -1628,7 +1917,10 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
*/
static VALUE
-rb_obj_methods(int argc, VALUE *argv, VALUE obj)
+rb_obj_methods(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
retry:
if (argc == 0) {
@@ -1659,7 +1951,10 @@ rb_obj_methods(int argc, VALUE *argv, VALUE obj)
*/
static VALUE
-rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
+rb_obj_protected_methods(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
if (argc == 0) { /* hack to stop warning */
VALUE args[1];
@@ -1680,7 +1975,10 @@ rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
*/
static VALUE
-rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
+rb_obj_private_methods(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
if (argc == 0) { /* hack to stop warning */
VALUE args[1];
@@ -1701,7 +1999,10 @@ rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
*/
static VALUE
-rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
+rb_obj_public_methods(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
if (argc == 0) { /* hack to stop warning */
VALUE args[1];
@@ -1733,7 +2034,8 @@ rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
*/
static VALUE
-rb_obj_ivar_get(VALUE obj, VALUE iv)
+rb_obj_ivar_get(obj, iv)
+ VALUE obj, iv;
{
ID id = rb_to_id(iv);
@@ -1764,7 +2066,8 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
*/
static VALUE
-rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
+rb_obj_ivar_set(obj, iv, val)
+ VALUE obj, iv, val;
{
ID id = rb_to_id(iv);
@@ -1793,7 +2096,8 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
*/
static VALUE
-rb_obj_ivar_defined(VALUE obj, VALUE iv)
+rb_obj_ivar_defined(obj, iv)
+ VALUE obj, iv;
{
ID id = rb_to_id(iv);
@@ -1814,11 +2118,15 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
* class Fred
* @@foo = 99
* end
- * Fred.class_variable_get(:@@foo) #=> 99
+ *
+ * def Fred.foo
+ * class_variable_get(:@@foo) #=> 99
+ * end
*/
static VALUE
-rb_mod_cvar_get(VALUE obj, VALUE iv)
+rb_mod_cvar_get(obj, iv)
+ VALUE obj, iv;
{
ID id = rb_to_id(iv);
@@ -1841,19 +2149,24 @@ rb_mod_cvar_get(VALUE obj, VALUE iv)
* @@foo
* end
* end
- * Fred.class_variable_set(:@@foo, 101) #=> 101
+ *
+ * def Fred.foo
+ * class_variable_set(:@@foo, 101) #=> 101
+ * end
+ * Fred.foo
* Fred.new.foo #=> 101
*/
static VALUE
-rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
+rb_mod_cvar_set(obj, iv, val)
+ VALUE obj, iv, val;
{
ID id = rb_to_id(iv);
if (!rb_is_class_id(id)) {
rb_name_error(id, "`%s' is not allowed as a class variable name", rb_id2name(id));
}
- rb_cvar_set(obj, id, val);
+ rb_cvar_set(obj, id, val, Qfalse);
return val;
}
@@ -1872,7 +2185,8 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
*/
static VALUE
-rb_mod_cvar_defined(VALUE obj, VALUE iv)
+rb_mod_cvar_defined(obj, iv)
+ VALUE obj, iv;
{
ID id = rb_to_id(iv);
@@ -1883,7 +2197,10 @@ rb_mod_cvar_defined(VALUE obj, VALUE iv)
}
static VALUE
-convert_type(VALUE val, const char *tname, const char *method, int raise)
+convert_type(val, tname, method, raise)
+ VALUE val;
+ const char *tname, *method;
+ int raise;
{
ID m;
@@ -1905,22 +2222,27 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
}
VALUE
-rb_convert_type(VALUE val, int type, const char *tname, const char *method)
+rb_convert_type(val, type, tname, method)
+ VALUE val;
+ int type;
+ const char *tname, *method;
{
VALUE v;
if (TYPE(val) == type) return val;
v = convert_type(val, tname, method, Qtrue);
if (TYPE(v) != type) {
- char *cname = rb_obj_classname(val);
- rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
- cname, tname, cname, method, rb_obj_classname(v));
+ rb_raise(rb_eTypeError, "%s#%s should return %s",
+ rb_obj_classname(val), method, tname);
}
return v;
}
VALUE
-rb_check_convert_type(VALUE val, int type, const char *tname, const char *method)
+rb_check_convert_type(val, type, tname, method)
+ VALUE val;
+ int type;
+ const char *tname, *method;
{
VALUE v;
@@ -1929,22 +2251,22 @@ rb_check_convert_type(VALUE val, int type, const char *tname, const char *method
v = convert_type(val, tname, method, Qfalse);
if (NIL_P(v)) return Qnil;
if (TYPE(v) != type) {
- char *cname = rb_obj_classname(val);
- rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
- cname, tname, cname, method, rb_obj_classname(v));
+ rb_raise(rb_eTypeError, "%s#%s should return %s",
+ rb_obj_classname(val), method, tname);
}
return v;
}
static VALUE
-rb_to_integer(VALUE val, const char *method)
+rb_to_integer(val, method)
+ VALUE val;
+ const char *method;
{
VALUE v = convert_type(val, "Integer", method, Qtrue);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
- char *cname = rb_obj_classname(val);
- rb_raise(rb_eTypeError, "can't convert %s to Integer (%s#%s gives %s)",
- cname, cname, method, rb_obj_classname(v));
+ rb_raise(rb_eTypeError, "%s#%s should return Integer",
+ rb_obj_classname(val), method);
}
return v;
}
@@ -1952,7 +2274,10 @@ rb_to_integer(VALUE val, const char *method)
VALUE
rb_check_to_integer(VALUE val, const char *method)
{
- VALUE v = convert_type(val, "Integer", method, Qfalse);
+ VALUE v;
+
+ if (FIXNUM_P(val)) return val;
+ v = convert_type(val, "Integer", method, Qfalse);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
return Qnil;
}
@@ -1960,23 +2285,25 @@ rb_check_to_integer(VALUE val, const char *method)
}
VALUE
-rb_to_int(VALUE val)
+rb_to_int(val)
+ VALUE val;
{
return rb_to_integer(val, "to_int");
}
VALUE
-rb_Integer(VALUE val)
+rb_Integer(val)
+ VALUE val;
{
VALUE tmp;
switch (TYPE(val)) {
case T_FLOAT:
- if (RFLOAT_VALUE(val) <= (double)FIXNUM_MAX
- && RFLOAT_VALUE(val) >= (double)FIXNUM_MIN) {
+ if (RFLOAT(val)->value <= (double)FIXNUM_MAX
+ && RFLOAT(val)->value >= (double)FIXNUM_MIN) {
break;
}
- return rb_dbl2big(RFLOAT_VALUE(val));
+ return rb_dbl2big(RFLOAT(val)->value);
case T_FIXNUM:
case T_BIGNUM:
@@ -1985,10 +2312,6 @@ rb_Integer(VALUE val)
case T_STRING:
return rb_str_to_inum(val, 0, Qtrue);
- case T_NIL:
- rb_raise(rb_eTypeError, "can't convert nil into Integer");
- break;
-
default:
break;
}
@@ -2017,13 +2340,16 @@ rb_Integer(VALUE val)
*/
static VALUE
-rb_f_integer(VALUE obj, VALUE arg)
+rb_f_integer(obj, arg)
+ VALUE obj, arg;
{
return rb_Integer(arg);
}
double
-rb_cstr_to_dbl(const char *p, int badcheck)
+rb_cstr_to_dbl(p, badcheck)
+ const char *p;
+ int badcheck;
{
const char *q;
char *end;
@@ -2034,7 +2360,13 @@ rb_cstr_to_dbl(const char *p, int badcheck)
if (!p) return 0.0;
q = p;
+ if (badcheck) {
while (ISSPACE(*p)) p++;
+ }
+ else {
+ while (ISSPACE(*p) || *p == '_') p++;
+ }
+ errno = 0;
d = strtod(p, &end);
if (errno == ERANGE) {
OutOfRange();
@@ -2042,8 +2374,8 @@ rb_cstr_to_dbl(const char *p, int badcheck)
errno = 0;
}
if (p == end) {
- bad:
if (badcheck) {
+ bad:
rb_invalid_str(q, "Float()");
}
return d;
@@ -2056,11 +2388,14 @@ rb_cstr_to_dbl(const char *p, int badcheck)
while (*p) {
if (*p == '_') {
/* remove underscores between digits */
+ if (badcheck) {
if (n == buf || !ISDIGIT(n[-1])) goto bad;
+ ++p;
+ if (!ISDIGIT(*p)) goto bad;
+ }
+ else {
while (*++p == '_');
- if (!ISDIGIT(*p)) {
- if (badcheck) goto bad;
- break;
+ continue;
}
}
*n++ = *p++;
@@ -2088,14 +2423,16 @@ rb_cstr_to_dbl(const char *p, int badcheck)
}
double
-rb_str_to_dbl(VALUE str, int badcheck)
+rb_str_to_dbl(str, badcheck)
+ VALUE str;
+ int badcheck;
{
char *s;
long len;
StringValue(str);
- s = RSTRING_PTR(str);
- len = RSTRING_LEN(str);
+ s = RSTRING(str)->ptr;
+ len = RSTRING(str)->len;
if (s) {
if (s[len]) { /* no sentinel somehow */
char *p = ALLOCA_N(char, len+1);
@@ -2112,20 +2449,21 @@ rb_str_to_dbl(VALUE str, int badcheck)
}
VALUE
-rb_Float(VALUE val)
+rb_Float(val)
+ VALUE val;
{
switch (TYPE(val)) {
case T_FIXNUM:
- return DOUBLE2NUM((double)FIX2LONG(val));
+ return rb_float_new((double)FIX2LONG(val));
case T_FLOAT:
return val;
case T_BIGNUM:
- return DOUBLE2NUM(rb_big2dbl(val));
+ return rb_float_new(rb_big2dbl(val));
case T_STRING:
- return DOUBLE2NUM(rb_str_to_dbl(val, Qtrue));
+ return rb_float_new(rb_str_to_dbl(val, Qtrue));
case T_NIL:
rb_raise(rb_eTypeError, "can't convert nil into Float");
@@ -2134,7 +2472,7 @@ rb_Float(VALUE val)
default:
{
VALUE f = rb_convert_type(val, T_FLOAT, "Float", "to_f");
- if (isnan(RFLOAT_VALUE(f))) {
+ if (isnan(RFLOAT(f)->value)) {
rb_raise(rb_eArgError, "invalid value for Float()");
}
return f;
@@ -2155,17 +2493,19 @@ rb_Float(VALUE val)
*/
static VALUE
-rb_f_float(VALUE obj, VALUE arg)
+rb_f_float(obj, arg)
+ VALUE obj, arg;
{
return rb_Float(arg);
}
double
-rb_num2dbl(VALUE val)
+rb_num2dbl(val)
+ VALUE val;
{
switch (TYPE(val)) {
case T_FLOAT:
- return RFLOAT_VALUE(val);
+ return RFLOAT(val)->value;
case T_STRING:
rb_raise(rb_eTypeError, "no implicit conversion to float from string");
@@ -2179,22 +2519,25 @@ rb_num2dbl(VALUE val)
break;
}
- return RFLOAT_VALUE(rb_Float(val));
+ return RFLOAT(rb_Float(val))->value;
}
char*
-rb_str2cstr(VALUE str, long *len)
+rb_str2cstr(str, len)
+ VALUE str;
+ long *len;
{
StringValue(str);
- if (len) *len = RSTRING_LEN(str);
- else if (RTEST(ruby_verbose) && RSTRING_LEN(str) != strlen(RSTRING_PTR(str))) {
+ if (len) *len = RSTRING(str)->len;
+ else if (RTEST(ruby_verbose) && RSTRING(str)->len != strlen(RSTRING(str)->ptr)) {
rb_warn("string contains \\0 character");
}
- return RSTRING_PTR(str);
+ return RSTRING(str)->ptr;
}
VALUE
-rb_String(VALUE val)
+rb_String(val)
+ VALUE val;
{
return rb_convert_type(val, T_STRING, "String", "to_s");
}
@@ -2208,18 +2551,21 @@ rb_String(VALUE val)
* <code>to_s</code> method.
*
* String(self) #=> "main"
- * String(self.class) #=> "Object"
+ * String(self.class #=> "Object"
* String(123456) #=> "123456"
*/
static VALUE
-rb_f_string(VALUE obj, VALUE arg)
+rb_f_string(obj, arg)
+ VALUE obj, arg;
{
return rb_String(arg);
}
+#if 0
VALUE
-rb_Array(VALUE val)
+rb_Array(val)
+ VALUE val;
{
VALUE tmp = rb_check_array_type(val);
@@ -2231,6 +2577,7 @@ rb_Array(VALUE val)
}
return tmp;
}
+#endif
/*
* call-seq:
@@ -2238,18 +2585,23 @@ rb_Array(VALUE val)
*
* Returns <i>arg</i> as an <code>Array</code>. First tries to call
* <i>arg</i><code>.to_ary</code>, then <i>arg</i><code>.to_a</code>.
+ * If both fail, creates a single element array containing <i>arg</i>
+ * (unless <i>arg</i> is <code>nil</code>).
*
* Array(1..5) #=> [1, 2, 3, 4, 5]
*/
static VALUE
-rb_f_array(VALUE obj, VALUE arg)
+rb_f_array(obj, arg)
+ VALUE obj, arg;
{
return rb_Array(arg);
}
static VALUE
-boot_defclass(const char *name, VALUE super)
+boot_defclass(name, super)
+ char *name;
+ VALUE super;
{
extern st_table *rb_class_tbl;
VALUE obj = rb_class_boot(super);
@@ -2261,6 +2613,8 @@ boot_defclass(const char *name, VALUE super)
return obj;
}
+VALUE ruby_top_self;
+
/*
* Document-class: Class
*
@@ -2299,11 +2653,8 @@ boot_defclass(const char *name, VALUE super)
* parentheses meta-classes. All metaclasses are instances
* of the class `Class'.
*
- * +-----------------+
+ * +------------------+
* | |
- * BasicObject-->(BasicObject) |
- * ^ ^ |
- * | | |
* Object---->(Object) |
* ^ ^ ^ ^ |
* | | | | |
@@ -2323,9 +2674,7 @@ boot_defclass(const char *name, VALUE super)
/*
- * <code>BasicObject</code> is the parent class of all classes in Ruby.
- * It's an explicit blank class. <code>Object</code>, the root of Ruby's
- * class hierarchy is a direct subclass of <code>BasicObject</code>. Its
+ * <code>Object</code> is the parent class of all classes in Ruby. Its
* methods are therefore available to all objects unless explicitly
* overridden.
*
@@ -2341,33 +2690,22 @@ boot_defclass(const char *name, VALUE super)
*/
void
-Init_Object(void)
+Init_Object()
{
VALUE metaclass;
- rb_cBasicObject = boot_defclass("BasicObject", 0);
- rb_cObject = boot_defclass("Object", rb_cBasicObject);
+ rb_cObject = boot_defclass("Object", 0);
rb_cModule = boot_defclass("Module", rb_cObject);
rb_cClass = boot_defclass("Class", rb_cModule);
- metaclass = rb_make_metaclass(rb_cBasicObject, rb_cClass);
- metaclass = rb_make_metaclass(rb_cObject, metaclass);
+ metaclass = rb_make_metaclass(rb_cObject, rb_cClass);
metaclass = rb_make_metaclass(rb_cModule, metaclass);
metaclass = rb_make_metaclass(rb_cClass, metaclass);
- rb_define_private_method(rb_cBasicObject, "initialize", rb_obj_dummy, 0);
- rb_define_alloc_func(rb_cBasicObject, rb_class_allocate_instance);
- rb_define_method(rb_cBasicObject, "==", rb_obj_equal, 1);
- rb_define_method(rb_cBasicObject, "equal?", rb_obj_equal, 1);
- rb_define_method(rb_cBasicObject, "!", rb_obj_not, 0);
- rb_define_method(rb_cBasicObject, "!=", rb_obj_not_equal, 1);
-
- rb_define_private_method(rb_cBasicObject, "singleton_method_added", rb_obj_dummy, 1);
- rb_define_private_method(rb_cBasicObject, "singleton_method_removed", rb_obj_dummy, 1);
- rb_define_private_method(rb_cBasicObject, "singleton_method_undefined", rb_obj_dummy, 1);
-
rb_mKernel = rb_define_module("Kernel");
rb_include_module(rb_cObject, rb_mKernel);
+ rb_define_alloc_func(rb_cObject, rb_class_allocate_instance);
+ rb_define_private_method(rb_cObject, "initialize", rb_obj_dummy, 0);
rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy, 1);
rb_define_private_method(rb_cModule, "included", rb_obj_dummy, 1);
rb_define_private_method(rb_cModule, "extended", rb_obj_dummy, 1);
@@ -2375,13 +2713,19 @@ Init_Object(void)
rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1);
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
+
rb_define_method(rb_mKernel, "nil?", rb_false, 0);
+ rb_define_method(rb_mKernel, "==", rb_obj_equal, 1);
+ rb_define_method(rb_mKernel, "equal?", rb_obj_equal, 1);
rb_define_method(rb_mKernel, "===", rb_equal, 1);
- rb_define_method(rb_mKernel, "=~", rb_obj_match, 1);
- rb_define_method(rb_mKernel, "!~", rb_obj_not_match, 1);
+ rb_define_method(rb_mKernel, "=~", rb_obj_pattern_match, 1);
+
rb_define_method(rb_mKernel, "eql?", rb_obj_equal, 1);
+ rb_define_method(rb_mKernel, "id", rb_obj_id_obsolete, 0);
+ rb_define_method(rb_mKernel, "type", rb_obj_type, 0);
rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
+
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);
rb_define_method(rb_mKernel, "initialize_copy", rb_obj_init_copy, 1);
@@ -2392,14 +2736,18 @@ Init_Object(void)
rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0);
rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 0);
+ rb_define_method(rb_mKernel, "to_a", rb_any_to_a, 0); /* to be removed */
rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0);
rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0);
rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1);
- rb_define_method(rb_mKernel, "singleton_methods", rb_obj_singleton_methods, -1); /* in class.c */
- rb_define_method(rb_mKernel, "protected_methods", rb_obj_protected_methods, -1);
+ rb_define_method(rb_mKernel, "singleton_methods",
+ rb_obj_singleton_methods, -1); /* in class.c */
+ rb_define_method(rb_mKernel, "protected_methods",
+ rb_obj_protected_methods, -1);
rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, -1);
rb_define_method(rb_mKernel, "public_methods", rb_obj_public_methods, -1);
- rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0); /* in variable.c */
+ rb_define_method(rb_mKernel, "instance_variables",
+ rb_obj_instance_variables, 0); /* in variable.c */
rb_define_method(rb_mKernel, "instance_variable_get", rb_obj_ivar_get, 1);
rb_define_method(rb_mKernel, "instance_variable_set", rb_obj_ivar_set, 2);
rb_define_method(rb_mKernel, "instance_variable_defined?", rb_obj_ivar_defined, 1);
@@ -2411,8 +2759,12 @@ Init_Object(void)
rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
rb_define_method(rb_mKernel, "tap", rb_obj_tap, 0);
+ rb_define_private_method(rb_mKernel, "singleton_method_added", rb_obj_dummy, 1);
+ rb_define_private_method(rb_mKernel, "singleton_method_removed", rb_obj_dummy, 1);
+ rb_define_private_method(rb_mKernel, "singleton_method_undefined", rb_obj_dummy, 1);
+
rb_define_global_function("sprintf", rb_f_sprintf, -1); /* in sprintf.c */
- rb_define_global_function("format", rb_f_sprintf, -1); /* in sprintf.c */
+ rb_define_global_function("format", rb_f_sprintf, -1); /* in sprintf.c */
rb_define_global_function("Integer", rb_f_integer, 1);
rb_define_global_function("Float", rb_f_float, 1);
@@ -2435,6 +2787,21 @@ Init_Object(void)
rb_undef_method(CLASS_OF(rb_cNilClass), "new");
rb_define_global_const("NIL", Qnil);
+ rb_cSymbol = rb_define_class("Symbol", rb_cObject);
+ rb_define_singleton_method(rb_cSymbol, "all_symbols",
+ rb_sym_all_symbols, 0); /* in parse.y */
+ rb_undef_alloc_func(rb_cSymbol);
+ rb_undef_method(CLASS_OF(rb_cSymbol), "new");
+
+ rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0);
+ rb_define_method(rb_cSymbol, "to_int", sym_to_int, 0);
+ rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
+ rb_define_method(rb_cSymbol, "to_s", sym_to_s, 0);
+ rb_define_method(rb_cSymbol, "id2name", sym_to_s, 0);
+ rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
+ rb_define_method(rb_cSymbol, "to_proc", sym_to_proc, 0);
+ rb_define_method(rb_cSymbol, "===", rb_obj_equal, 1);
+
rb_define_method(rb_cModule, "freeze", rb_mod_freeze, 0);
rb_define_method(rb_cModule, "===", rb_mod_eqq, 1);
rb_define_method(rb_cModule, "==", rb_obj_equal, 1);
@@ -2445,7 +2812,8 @@ Init_Object(void)
rb_define_method(rb_cModule, ">=", rb_mod_ge, 1);
rb_define_method(rb_cModule, "initialize_copy", rb_mod_init_copy, 1); /* in class.c */
rb_define_method(rb_cModule, "to_s", rb_mod_to_s, 0);
- rb_define_method(rb_cModule, "included_modules", rb_mod_included_modules, 0); /* in class.c */
+ rb_define_method(rb_cModule, "included_modules",
+ rb_mod_included_modules, 0); /* in class.c */
rb_define_method(rb_cModule, "include?", rb_mod_include_p, 1); /* in class.c */
rb_define_method(rb_cModule, "name", rb_mod_name, 0); /* in variable.c */
rb_define_method(rb_cModule, "ancestors", rb_mod_ancestors, 0); /* in class.c */
@@ -2457,7 +2825,8 @@ Init_Object(void)
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
- rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
+ rb_define_method(rb_cModule, "instance_methods",
+ rb_class_instance_methods, -1); /* in class.c */
rb_define_method(rb_cModule, "public_instance_methods",
rb_class_public_instance_methods, -1); /* in class.c */
rb_define_method(rb_cModule, "protected_instance_methods",
@@ -2465,21 +2834,21 @@ Init_Object(void)
rb_define_method(rb_cModule, "private_instance_methods",
rb_class_private_instance_methods, -1); /* in class.c */
- rb_define_method(rb_cModule, "constants", rb_mod_constants, -1); /* in variable.c */
- rb_define_method(rb_cModule, "const_get", rb_mod_const_get, -1);
+ rb_define_method(rb_cModule, "class_variable_defined?", rb_mod_cvar_defined, 1);
+ rb_define_method(rb_cModule, "constants", rb_mod_constants, 0); /* in variable.c */
+ rb_define_method(rb_cModule, "const_get", rb_mod_const_get, 1);
rb_define_method(rb_cModule, "const_set", rb_mod_const_set, 2);
- rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, -1);
+ rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, 1);
rb_define_private_method(rb_cModule, "remove_const",
rb_mod_remove_const, 1); /* in variable.c */
rb_define_method(rb_cModule, "const_missing",
rb_mod_const_missing, 1); /* in variable.c */
rb_define_method(rb_cModule, "class_variables",
rb_mod_class_variables, 0); /* in variable.c */
- rb_define_method(rb_cModule, "remove_class_variable",
- rb_mod_remove_cvar, 1); /* in variable.c */
- rb_define_method(rb_cModule, "class_variable_get", rb_mod_cvar_get, 1);
- rb_define_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
- rb_define_method(rb_cModule, "class_variable_defined?", rb_mod_cvar_defined, 1);
+ rb_define_private_method(rb_cModule, "remove_class_variable",
+ rb_mod_remove_cvar, 1); /* in variable.c */
+ rb_define_private_method(rb_cModule, "class_variable_get", rb_mod_cvar_get, 1);
+ rb_define_private_method(rb_cModule, "class_variable_set", rb_mod_cvar_set, 2);
rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
@@ -2493,6 +2862,10 @@ Init_Object(void)
rb_cData = rb_define_class("Data", rb_cObject);
rb_undef_alloc_func(rb_cData);
+ rb_global_variable(&ruby_top_self);
+ ruby_top_self = rb_obj_alloc(rb_cObject);
+ rb_define_singleton_method(ruby_top_self, "to_s", main_to_s, 0);
+
rb_cTrueClass = rb_define_class("TrueClass", rb_cObject);
rb_define_method(rb_cTrueClass, "to_s", true_to_s, 0);
rb_define_method(rb_cTrueClass, "&", true_and, 1);
@@ -2513,7 +2886,6 @@ Init_Object(void)
id_eq = rb_intern("==");
id_eql = rb_intern("eql?");
- id_match = rb_intern("=~");
id_inspect = rb_intern("inspect");
id_init_copy = rb_intern("initialize_copy");
}
diff --git a/opt_insn_unif.def b/opt_insn_unif.def
deleted file mode 100644
index 1ac613dbea..0000000000
--- a/opt_insn_unif.def
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# a definition of instruction unification
-#
-#
-
-__END__
-
-putobject putobject
-putobject putstring
-putobject setlocal
-putobject setdynamic
-
-putstring putstring
-putstring putobject
-putstring setlocal
-putstring setdynamic
-
-# putnil end
-
-dup setlocal
-
-# from tarai
-getlocal getlocal
-# getlocal send
-
-# from tak, ackermann
-getlocal putobject
-
-
diff --git a/opt_operand.def b/opt_operand.def
deleted file mode 100644
index 5ca1d74028..0000000000
--- a/opt_operand.def
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# configration file for operand union optimization
-#
-# format:
-# [insn name] op1, op2 ...
-#
-# wildcard: *
-#
-
-__END__
-
-getlocal 2
-getlocal 3
-getlocal 4
-
-setlocal 2
-setlocal 3
-setlocal 4
-
-getdynamic *, 0
-getdynamic 1, 0
-getdynamic 2, 0
-getdynamic 3, 0
-getdynamic 4, 0
-
-setdynamic *, 0
-setdynamic 1, 0
-setdynamic 2, 0
-setdynamic 3, 0
-setdynamic 4, 0
-
-putobject INT2FIX(0)
-putobject INT2FIX(1)
-putobject Qtrue
-putobject Qfalse
-
-# CALL
-send *, *, Qfalse, 0, *
-send *, 0, Qfalse, 0, *
-send *, 1, Qfalse, 0, *
-send *, 2, Qfalse, 0, *
-send *, 3, Qfalse, 0, *
-
-# FCALL
-send *, *, Qfalse, 0x04, *
-send *, 0, Qfalse, 0x04, *
-send *, 1, Qfalse, 0x04, *
-send *, 2, Qfalse, 0x04, *
-send *, 3, Qfalse, 0x04, *
-
-# VCALL
-send *, 0, Qfalse, 0x0c, *
-
-
-__END__
-
-
-
-
diff --git a/pack.c b/pack.c
index 0df3c567ed..b22a8348b2 100644
--- a/pack.c
+++ b/pack.c
@@ -6,11 +6,11 @@
$Date$
created at: Thu Feb 10 15:17:05 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
#include <sys/types.h>
#include <ctype.h>
@@ -52,7 +52,8 @@
#define define_swapx(x, xtype) \
static xtype \
-TOKEN_PASTE(swap,x)(xtype z) \
+TOKEN_PASTE(swap,x)(z) \
+ xtype z; \
{ \
xtype r; \
xtype *zp; \
@@ -134,7 +135,8 @@ define_swapx(f,float)
#else
#if SIZEOF_LONG == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_LONG */
static double
-swapd(const double d)
+swapd(d)
+ const double d;
{
double dtmp = d;
unsigned long utmp[2];
@@ -151,7 +153,8 @@ swapd(const double d)
#else
#if SIZEOF_SHORT == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_SHORT */
static double
-swapd(const double d)
+swapd(d)
+ const double d;
{
double dtmp = d;
unsigned short utmp[2];
@@ -184,7 +187,7 @@ define_swapx(d, double)
#undef htonl
#endif
static int
-endian(void)
+endian()
{
static int init = 0;
static int endian_value;
@@ -328,10 +331,11 @@ endian(void)
#define VTOHD(x,y) vtohd(x)
#endif
-unsigned long rb_big2ulong_pack(VALUE x);
+unsigned long rb_big2ulong_pack _((VALUE x));
static unsigned long
-num2i32(VALUE x)
+num2i32(x)
+ VALUE x;
{
x = rb_to_int(x); /* is nil OK? (should not) */
@@ -344,13 +348,13 @@ num2i32(VALUE x)
}
#if SIZEOF_LONG == SIZE32
-# define EXTEND32(x)
+# define EXTEND32(x)
#else
/* invariant in modulo 1<<31 */
# define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0)
#endif
#if SIZEOF_SHORT == SIZE16
-# define EXTEND16(x)
+# define EXTEND16(x)
#else
# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0)
#endif
@@ -362,15 +366,16 @@ num2i32(VALUE x)
#endif
static const char toofew[] = "too few arguments";
-static void encodes(VALUE,const char*,long,int);
-static void qpencode(VALUE,VALUE,long);
+static void encodes _((VALUE,const char*,long,int));
+static void qpencode _((VALUE,VALUE,long));
-static unsigned long utf8_to_uv(const char*,long*);
+static int uv_to_utf8 _((char*,unsigned long));
+static unsigned long utf8_to_uv _((char*,long*));
/*
* call-seq:
* arr.pack ( aTemplateString ) -> aBinaryString
- *
+ *
* Packs the contents of <i>arr</i> into a binary sequence according to
* the directives in <i>aTemplateString</i> (see the table below)
* Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
@@ -383,24 +388,24 @@ static unsigned long utf8_to_uv(const char*,long*);
* platform's native size for the specified type; otherwise, they use a
* platform-independent size. Spaces are ignored in the template
* string. See also <code>String#unpack</code>.
- *
+ *
* a = [ "a", "b", "c" ]
* n = [ 65, 66, 67 ]
* a.pack("A3A3A3") #=> "a b c "
* a.pack("a3a3a3") #=> "a\000\000b\000\000c\000\000"
* n.pack("ccc") #=> "ABC"
- *
+ *
* Directives for +pack+.
*
* Directive Meaning
* ---------------------------------------------------------------
* @ | Moves to absolute position
- * A | arbitrary binary string (space padded, count is width)
- * a | arbitrary binary string (null padded, count is width)
+ * A | ASCII string (space padded, count is width)
+ * a | ASCII string (null padded, count is width)
* B | Bit string (descending bit order)
* b | Bit string (ascending bit order)
- * C | Unsigned byte (C unsigned char)
- * c | Byte (C char)
+ * C | Unsigned char
+ * c | Char
* D, d | Double-precision float, native format
* E | Double-precision float, little-endian byte order
* e | Single-precision float, little-endian byte order
@@ -433,11 +438,12 @@ static unsigned long utf8_to_uv(const char*,long*);
*/
static VALUE
-pack_pack(VALUE ary, VALUE fmt)
+pack_pack(ary, fmt)
+ VALUE ary, fmt;
{
static const char nul10[] = "\0\0\0\0\0\0\0\0\0\0";
static const char spc10[] = " ";
- const char *p, *pend;
+ char *p, *pend;
VALUE res, from, associates = 0;
char type;
long items, len, idx, plen;
@@ -447,19 +453,19 @@ pack_pack(VALUE ary, VALUE fmt)
#endif
StringValue(fmt);
- p = RSTRING_PTR(fmt);
- pend = p + RSTRING_LEN(fmt);
+ p = RSTRING(fmt)->ptr;
+ pend = p + RSTRING(fmt)->len;
res = rb_str_buf_new(0);
- items = RARRAY_LEN(ary);
+ items = RARRAY(ary)->len;
idx = 0;
#define TOO_FEW (rb_raise(rb_eArgError, toofew), 0)
-#define THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW)
-#define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW)
+#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : TOO_FEW)
+#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : TOO_FEW)
while (p < pend) {
- if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) {
+ if (RSTRING(fmt)->ptr + RSTRING(fmt)->len != pend) {
rb_raise(rb_eRuntimeError, "format string modified");
}
type = *p++; /* get data type */
@@ -509,8 +515,8 @@ pack_pack(VALUE ary, VALUE fmt)
}
else {
StringValue(from);
- ptr = RSTRING_PTR(from);
- plen = RSTRING_LEN(from);
+ ptr = RSTRING(from)->ptr;
+ plen = RSTRING(from)->len;
OBJ_INFECT(res, from);
}
@@ -519,8 +525,8 @@ pack_pack(VALUE ary, VALUE fmt)
switch (type) {
case 'a': /* arbitrary binary string (null padded) */
- case 'A': /* arbitrary binary string (ASCII space padded) */
- case 'Z': /* null terminated string */
+ case 'A': /* ASCII string (space padded) */
+ case 'Z': /* null terminated ASCII string */
if (plen >= len) {
rb_str_buf_cat(res, ptr, len);
if (p[-1] == '*' && type == 'Z')
@@ -767,7 +773,7 @@ pack_pack(VALUE ary, VALUE fmt)
float f;
from = NEXTFROM;
- f = RFLOAT_VALUE(rb_Float(from));
+ f = RFLOAT(rb_Float(from))->value;
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
break;
@@ -778,7 +784,7 @@ pack_pack(VALUE ary, VALUE fmt)
FLOAT_CONVWITH(ftmp);
from = NEXTFROM;
- f = RFLOAT_VALUE(rb_Float(from));
+ f = RFLOAT(rb_Float(from))->value;
f = HTOVF(f,ftmp);
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
@@ -790,7 +796,7 @@ pack_pack(VALUE ary, VALUE fmt)
DOUBLE_CONVWITH(dtmp);
from = NEXTFROM;
- d = RFLOAT_VALUE(rb_Float(from));
+ d = RFLOAT(rb_Float(from))->value;
d = HTOVD(d,dtmp);
rb_str_buf_cat(res, (char*)&d, sizeof(double));
}
@@ -802,7 +808,7 @@ pack_pack(VALUE ary, VALUE fmt)
double d;
from = NEXTFROM;
- d = RFLOAT_VALUE(rb_Float(from));
+ d = RFLOAT(rb_Float(from))->value;
rb_str_buf_cat(res, (char*)&d, sizeof(double));
}
break;
@@ -813,7 +819,7 @@ pack_pack(VALUE ary, VALUE fmt)
FLOAT_CONVWITH(ftmp);
from = NEXTFROM;
- f = RFLOAT_VALUE(rb_Float(from));
+ f = RFLOAT(rb_Float(from))->value;
f = HTONF(f,ftmp);
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
@@ -825,7 +831,7 @@ pack_pack(VALUE ary, VALUE fmt)
DOUBLE_CONVWITH(dtmp);
from = NEXTFROM;
- d = RFLOAT_VALUE(rb_Float(from));
+ d = RFLOAT(rb_Float(from))->value;
d = HTOND(d,dtmp);
rb_str_buf_cat(res, (char*)&d, sizeof(double));
}
@@ -842,14 +848,15 @@ pack_pack(VALUE ary, VALUE fmt)
case 'X': /* back up byte */
shrink:
- plen = RSTRING_LEN(res);
+ plen = RSTRING(res)->len;
if (plen < len)
rb_raise(rb_eArgError, "X outside of string");
- rb_str_set_len(res, plen - len);
+ RSTRING(res)->len = plen - len;
+ RSTRING(res)->ptr[plen - len] = '\0';
break;
case '@': /* null fill to absolute position */
- len -= RSTRING_LEN(res);
+ len -= RSTRING(res)->len;
if (len > 0) goto grow;
len = -len;
if (len > 0) goto shrink;
@@ -861,17 +868,17 @@ pack_pack(VALUE ary, VALUE fmt)
case 'U': /* Unicode character */
while (len-- > 0) {
- SIGNED_VALUE l;
+ long l;
char buf[8];
int le;
from = NEXTFROM;
from = rb_to_int(from);
- l = NUM2LONG(from);
+ l = NUM2INT(from);
if (l < 0) {
rb_raise(rb_eRangeError, "pack(U): value out of range");
}
- le = rb_uv_to_utf8(buf, l);
+ le = uv_to_utf8(buf, l);
rb_str_buf_cat(res, (char*)buf, le);
}
break;
@@ -880,8 +887,8 @@ pack_pack(VALUE ary, VALUE fmt)
case 'm': /* base64 encoded string */
from = NEXTFROM;
StringValue(from);
- ptr = RSTRING_PTR(from);
- plen = RSTRING_LEN(from);
+ ptr = RSTRING(from)->ptr;
+ plen = RSTRING(from)->len;
if (len <= 2)
len = 45;
@@ -911,9 +918,9 @@ pack_pack(VALUE ary, VALUE fmt)
from = THISFROM;
if (!NIL_P(from)) {
StringValue(from);
- if (RSTRING_LEN(from) < len) {
+ if (RSTRING(from)->len < len) {
rb_raise(rb_eArgError, "too short buffer for P(%ld for %ld)",
- RSTRING_LEN(from), len);
+ RSTRING(from)->len, len);
}
}
len = 1;
@@ -948,9 +955,9 @@ pack_pack(VALUE ary, VALUE fmt)
VALUE big128 = rb_uint2big(128);
while (TYPE(from) == T_BIGNUM) {
from = rb_big_divmod(from, big128);
- c = NUM2INT(RARRAY_PTR(from)[1]) | 0x80; /* mod */
+ c = NUM2INT(RARRAY(from)->ptr[1]) | 0x80; /* mod */
rb_str_buf_cat(buf, &c, sizeof(char));
- from = RARRAY_PTR(from)[0]; /* div */
+ from = RARRAY(from)->ptr[0]; /* div */
}
}
@@ -968,16 +975,16 @@ pack_pack(VALUE ary, VALUE fmt)
ul >>= 7;
}
- if (RSTRING_LEN(buf)) {
- bufs = RSTRING_PTR(buf);
- bufe = bufs + RSTRING_LEN(buf) - 1;
+ if (RSTRING(buf)->len) {
+ bufs = RSTRING(buf)->ptr;
+ bufe = bufs + RSTRING(buf)->len - 1;
*bufs &= 0x7f; /* clear continue bit */
while (bufs < bufe) { /* reverse */
c = *bufs;
*bufs++ = *bufe;
*bufe-- = c;
}
- rb_str_buf_cat(res, RSTRING_PTR(buf), RSTRING_LEN(buf));
+ rb_str_buf_cat(res, RSTRING(buf)->ptr, RSTRING(buf)->len);
}
else {
c = 0;
@@ -1003,7 +1010,11 @@ static const char b64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static void
-encodes(VALUE str, const char *s, long len, int type)
+encodes(str, s, len, type)
+ VALUE str;
+ const char *s;
+ long len;
+ int type;
{
char *buff = ALLOCA_N(char, len * 4 / 3 + 6);
long i = 0;
@@ -1041,15 +1052,17 @@ encodes(VALUE str, const char *s, long len, int type)
rb_str_buf_cat(str, buff, i);
}
-static const char hex_table[] = "0123456789ABCDEF";
+static char hex_table[] = "0123456789ABCDEF";
static void
-qpencode(VALUE str, VALUE from, long len)
+qpencode(str, from, len)
+ VALUE str, from;
+ long len;
{
char buff[1024];
long i = 0, n = 0, prev = EOF;
- unsigned char *s = (unsigned char*)RSTRING_PTR(from);
- unsigned char *send = s + RSTRING_LEN(from);
+ unsigned char *s = (unsigned char*)RSTRING(from)->ptr;
+ unsigned char *send = s + RSTRING(from)->len;
while (s < send) {
if ((*s > 126) ||
@@ -1097,19 +1110,20 @@ qpencode(VALUE str, VALUE from, long len)
}
static inline int
-hex2num(char c)
+hex2num(c)
+ char c;
{
switch (c) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
return c - '0';
- case 'a': case 'b': case 'c':
- case 'd': case 'e': case 'f':
+ case 'a': case 'b': case 'c':
+ case 'd': case 'e': case 'f':
return c - 'a' + 10;
- case 'A': case 'B': case 'C':
- case 'D': case 'E': case 'F':
+ case 'A': case 'B': case 'C':
+ case 'D': case 'E': case 'F':
return c - 'A' + 10;
- default:
+ default:
return -1;
}
}
@@ -1137,18 +1151,21 @@ hex2num(char c)
#define PACK_ITEM_ADJUST() while (tmp--) rb_ary_push(ary, Qnil)
static VALUE
-infected_str_new(const char *ptr, long len, VALUE str)
+infected_str_new(ptr, len, str)
+ const char *ptr;
+ long len;
+ VALUE str;
{
VALUE s = rb_str_new(ptr, len);
OBJ_INFECT(s, str);
return s;
}
-
+
/*
* call-seq:
* str.unpack(format) => anArray
- *
+ *
* Decodes <i>str</i> (which may contain binary data) according to the
* format string, returning an array of each value extracted. The
* format string consists of a sequence of single-character directives,
@@ -1161,7 +1178,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
* platform's native size for the specified type; otherwise, it uses a
* platform-independent consistent size. Spaces are ignored in the
* format string. See also <code>Array#pack</code>.
- *
+ *
* "abc \0\0abc \0\0".unpack('A6Z6') #=> ["abc", "abc "]
* "abc \0\0".unpack('a3a3') #=> ["abc", " \000\000"]
* "abc \0abc \0".unpack('Z*Z*') #=> ["abc ", "abc "]
@@ -1173,21 +1190,20 @@ infected_str_new(const char *ptr, long len, VALUE str)
*
* This table summarizes the various formats and the Ruby classes
* returned by each.
- *
+ *
* Format | Returns | Function
* -------+---------+-----------------------------------------
- * A | String | arbitrary binary string with trailing
- * | | nulls and ASCII spaces removed
+ * A | String | with trailing nulls and spaces removed
* -------+---------+-----------------------------------------
- * a | String | arbitrary binary string
+ * a | String | string
* -------+---------+-----------------------------------------
* B | String | extract bits from each character (msb first)
* -------+---------+-----------------------------------------
* b | String | extract bits from each character (lsb first)
* -------+---------+-----------------------------------------
- * C | Fixnum | extract a byte (C char) as an unsigned integer
+ * C | Fixnum | extract a character as an unsigned integer
* -------+---------+-----------------------------------------
- * c | Fixnum | extract a byte (C char) as an integer
+ * c | Fixnum | extract a character as an integer
* -------+---------+-----------------------------------------
* d,D | Float | treat sizeof(double) characters as
* | | a native double
@@ -1246,17 +1262,17 @@ infected_str_new(const char *ptr, long len, VALUE str)
* p | String | treat sizeof(char *) characters as a
* | | pointer to a null-terminated string
* -------+---------+-----------------------------------------
- * Q | Integer | treat 8 characters as an unsigned
+ * Q | Integer | treat 8 characters as an unsigned
* | | quad word (64 bits)
* -------+---------+-----------------------------------------
- * q | Integer | treat 8 characters as a signed
+ * q | Integer | treat 8 characters as a signed
* | | quad word (64 bits)
* -------+---------+-----------------------------------------
* S | Fixnum | treat two (different if _ used)
* | | successive characters as an unsigned
* | | short in native byte order
* -------+---------+-----------------------------------------
- * s | Fixnum | Treat two (different if _ used)
+ * s | Fixnum | Treat two (different if _ used)
* | | successive characters as a signed short
* | | in native byte order
* -------+---------+-----------------------------------------
@@ -1279,15 +1295,16 @@ infected_str_new(const char *ptr, long len, VALUE str)
* Z | String | with trailing nulls removed
* | | upto first null with *
* -------+---------+-----------------------------------------
- * @ | --- | skip to the offset given by the
+ * @ | --- | skip to the offset given by the
* | | length argument
* -------+---------+-----------------------------------------
*/
static VALUE
-pack_unpack(VALUE str, VALUE fmt)
+pack_unpack(str, fmt)
+ VALUE str, fmt;
{
- static const char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
+ static const char hexdigits[] = "0123456789abcdef0123456789ABCDEFx";
char *s, *send;
char *p, *pend;
VALUE ary;
@@ -1297,25 +1314,15 @@ pack_unpack(VALUE str, VALUE fmt)
#ifdef NATINT_PACK
int natint; /* native integer */
#endif
- int block_p = rb_block_given_p();
-#define UNPACK_PUSH(item) do {\
- VALUE item_val = (item);\
- if (block_p) {\
- rb_yield(item_val);\
- }\
- else {\
- rb_ary_push(ary, item_val);\
- }\
- } while (0)
StringValue(str);
StringValue(fmt);
- s = RSTRING_PTR(str);
- send = s + RSTRING_LEN(str);
- p = RSTRING_PTR(fmt);
- pend = p + RSTRING_LEN(fmt);
+ s = RSTRING(str)->ptr;
+ send = s + RSTRING(str)->len;
+ p = RSTRING(fmt)->ptr;
+ pend = p + RSTRING(fmt)->len;
- ary = block_p ? Qnil : rb_ary_new();
+ ary = rb_ary_new();
while (p < pend) {
type = *p++;
#ifdef NATINT_PACK
@@ -1331,7 +1338,7 @@ pack_unpack(VALUE str, VALUE fmt)
}
star = 0;
if (*p == '_' || *p == '!') {
- const char *natstr = "sSiIlL";
+ static const char natstr[] = "sSiIlL";
if (strchr(natstr, type)) {
#ifdef NATINT_PACK
@@ -1372,7 +1379,7 @@ pack_unpack(VALUE str, VALUE fmt)
if (*t != ' ' && *t != '\0') break;
t--; len--;
}
- UNPACK_PUSH(infected_str_new(s, len, str));
+ rb_ary_push(ary, infected_str_new(s, len, str));
s += end;
}
break;
@@ -1383,7 +1390,7 @@ pack_unpack(VALUE str, VALUE fmt)
if (len > send-s) len = send-s;
while (t < s+len && *t) t++;
- UNPACK_PUSH(infected_str_new(s, t-s, str));
+ rb_ary_push(ary, infected_str_new(s, t-s, str));
if (t < send) t++;
s = star ? t : s+len;
}
@@ -1391,7 +1398,7 @@ pack_unpack(VALUE str, VALUE fmt)
case 'a':
if (len > send - s) len = send - s;
- UNPACK_PUSH(infected_str_new(s, len, str));
+ rb_ary_push(ary, infected_str_new(s, len, str));
s += len;
break;
@@ -1405,8 +1412,8 @@ pack_unpack(VALUE str, VALUE fmt)
if (p[-1] == '*' || len > (send - s) * 8)
len = (send - s) * 8;
bits = 0;
- UNPACK_PUSH(bitstr = rb_str_new(0, len));
- t = RSTRING_PTR(bitstr);
+ rb_ary_push(ary, bitstr = rb_str_new(0, len));
+ t = RSTRING(bitstr)->ptr;
for (i=0; i<len; i++) {
if (i & 7) bits >>= 1;
else bits = *s++;
@@ -1425,8 +1432,8 @@ pack_unpack(VALUE str, VALUE fmt)
if (p[-1] == '*' || len > (send - s) * 8)
len = (send - s) * 8;
bits = 0;
- UNPACK_PUSH(bitstr = rb_str_new(0, len));
- t = RSTRING_PTR(bitstr);
+ rb_ary_push(ary, bitstr = rb_str_new(0, len));
+ t = RSTRING(bitstr)->ptr;
for (i=0; i<len; i++) {
if (i & 7) bits <<= 1;
else bits = *s++;
@@ -1445,8 +1452,8 @@ pack_unpack(VALUE str, VALUE fmt)
if (p[-1] == '*' || len > (send - s) * 2)
len = (send - s) * 2;
bits = 0;
- UNPACK_PUSH(bitstr = rb_str_new(0, len));
- t = RSTRING_PTR(bitstr);
+ rb_ary_push(ary, bitstr = rb_str_new(0, len));
+ t = RSTRING(bitstr)->ptr;
for (i=0; i<len; i++) {
if (i & 1)
bits >>= 4;
@@ -1467,8 +1474,8 @@ pack_unpack(VALUE str, VALUE fmt)
if (p[-1] == '*' || len > (send - s) * 2)
len = (send - s) * 2;
bits = 0;
- UNPACK_PUSH(bitstr = rb_str_new(0, len));
- t = RSTRING_PTR(bitstr);
+ rb_ary_push(ary, bitstr = rb_str_new(0, len));
+ t = RSTRING(bitstr)->ptr;
for (i=0; i<len; i++) {
if (i & 1)
bits <<= 4;
@@ -1484,7 +1491,7 @@ pack_unpack(VALUE str, VALUE fmt)
while (len-- > 0) {
int c = *s++;
if (c > (char)127) c-=256;
- UNPACK_PUSH(INT2FIX(c));
+ rb_ary_push(ary, INT2FIX(c));
}
PACK_ITEM_ADJUST();
break;
@@ -1493,7 +1500,7 @@ pack_unpack(VALUE str, VALUE fmt)
PACK_LENGTH_ADJUST(unsigned char,sizeof(unsigned char));
while (len-- > 0) {
unsigned char c = *s++;
- UNPACK_PUSH(INT2FIX(c));
+ rb_ary_push(ary, INT2FIX(c));
}
PACK_ITEM_ADJUST();
break;
@@ -1505,7 +1512,7 @@ pack_unpack(VALUE str, VALUE fmt)
memcpy(OFF16(&tmp), s, NATINT_LEN(short,2));
EXTEND16(tmp);
s += NATINT_LEN(short,2);
- UNPACK_PUSH(INT2FIX(tmp));
+ rb_ary_push(ary, INT2FIX(tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1516,7 +1523,7 @@ pack_unpack(VALUE str, VALUE fmt)
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
- UNPACK_PUSH(INT2FIX(tmp));
+ rb_ary_push(ary, INT2FIX(tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1527,7 +1534,7 @@ pack_unpack(VALUE str, VALUE fmt)
int tmp;
memcpy(&tmp, s, sizeof(int));
s += sizeof(int);
- UNPACK_PUSH(INT2NUM(tmp));
+ rb_ary_push(ary, INT2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1538,7 +1545,7 @@ pack_unpack(VALUE str, VALUE fmt)
unsigned int tmp;
memcpy(&tmp, s, sizeof(unsigned int));
s += sizeof(unsigned int);
- UNPACK_PUSH(UINT2NUM(tmp));
+ rb_ary_push(ary, UINT2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1550,17 +1557,18 @@ pack_unpack(VALUE str, VALUE fmt)
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
EXTEND32(tmp);
s += NATINT_LEN(long,4);
- UNPACK_PUSH(LONG2NUM(tmp));
+ rb_ary_push(ary, LONG2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
+
case 'L':
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
- UNPACK_PUSH(ULONG2NUM(tmp));
+ rb_ary_push(ary, ULONG2NUM(tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1570,16 +1578,17 @@ pack_unpack(VALUE str, VALUE fmt)
while (len-- > 0) {
char *tmp = (char*)s;
s += QUAD_SIZE;
- UNPACK_PUSH(rb_quad_unpack(tmp, 1));
+ rb_ary_push(ary, rb_quad_unpack(tmp, 1));
}
PACK_ITEM_ADJUST();
break;
+
case 'Q':
PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE);
while (len-- > 0) {
char *tmp = (char*)s;
s += QUAD_SIZE;
- UNPACK_PUSH(rb_quad_unpack(tmp, 0));
+ rb_ary_push(ary, rb_quad_unpack(tmp, 0));
}
break;
@@ -1589,7 +1598,7 @@ pack_unpack(VALUE str, VALUE fmt)
unsigned short tmp = 0;
memcpy(OFF16B(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
- UNPACK_PUSH(UINT2NUM(ntohs(tmp)));
+ rb_ary_push(ary, UINT2NUM(ntohs(tmp)));
}
PACK_ITEM_ADJUST();
break;
@@ -1600,7 +1609,7 @@ pack_unpack(VALUE str, VALUE fmt)
unsigned long tmp = 0;
memcpy(OFF32B(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
- UNPACK_PUSH(ULONG2NUM(ntohl(tmp)));
+ rb_ary_push(ary, ULONG2NUM(ntohl(tmp)));
}
PACK_ITEM_ADJUST();
break;
@@ -1611,7 +1620,7 @@ pack_unpack(VALUE str, VALUE fmt)
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
- UNPACK_PUSH(UINT2NUM(vtohs(tmp)));
+ rb_ary_push(ary, UINT2NUM(vtohs(tmp)));
}
PACK_ITEM_ADJUST();
break;
@@ -1622,7 +1631,7 @@ pack_unpack(VALUE str, VALUE fmt)
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(long,4));
s += NATINT_LEN(long,4);
- UNPACK_PUSH(ULONG2NUM(vtohl(tmp)));
+ rb_ary_push(ary, ULONG2NUM(vtohl(tmp)));
}
PACK_ITEM_ADJUST();
break;
@@ -1634,7 +1643,7 @@ pack_unpack(VALUE str, VALUE fmt)
float tmp;
memcpy(&tmp, s, sizeof(float));
s += sizeof(float);
- UNPACK_PUSH(DOUBLE2NUM((double)tmp));
+ rb_ary_push(ary, rb_float_new((double)tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1648,11 +1657,11 @@ pack_unpack(VALUE str, VALUE fmt)
memcpy(&tmp, s, sizeof(float));
s += sizeof(float);
tmp = VTOHF(tmp,ftmp);
- UNPACK_PUSH(DOUBLE2NUM((double)tmp));
+ rb_ary_push(ary, rb_float_new((double)tmp));
}
PACK_ITEM_ADJUST();
break;
-
+
case 'E':
PACK_LENGTH_ADJUST(double,sizeof(double));
while (len-- > 0) {
@@ -1662,11 +1671,11 @@ pack_unpack(VALUE str, VALUE fmt)
memcpy(&tmp, s, sizeof(double));
s += sizeof(double);
tmp = VTOHD(tmp,dtmp);
- UNPACK_PUSH(DOUBLE2NUM(tmp));
+ rb_ary_push(ary, rb_float_new(tmp));
}
PACK_ITEM_ADJUST();
break;
-
+
case 'D':
case 'd':
PACK_LENGTH_ADJUST(double,sizeof(double));
@@ -1674,7 +1683,7 @@ pack_unpack(VALUE str, VALUE fmt)
double tmp;
memcpy(&tmp, s, sizeof(double));
s += sizeof(double);
- UNPACK_PUSH(DOUBLE2NUM(tmp));
+ rb_ary_push(ary, rb_float_new(tmp));
}
PACK_ITEM_ADJUST();
break;
@@ -1688,11 +1697,11 @@ pack_unpack(VALUE str, VALUE fmt)
memcpy(&tmp, s, sizeof(float));
s += sizeof(float);
tmp = NTOHF(tmp,ftmp);
- UNPACK_PUSH(DOUBLE2NUM((double)tmp));
+ rb_ary_push(ary, rb_float_new((double)tmp));
}
PACK_ITEM_ADJUST();
break;
-
+
case 'G':
PACK_LENGTH_ADJUST(double,sizeof(double));
while (len-- > 0) {
@@ -1702,11 +1711,11 @@ pack_unpack(VALUE str, VALUE fmt)
memcpy(&tmp, s, sizeof(double));
s += sizeof(double);
tmp = NTOHD(tmp,dtmp);
- UNPACK_PUSH(DOUBLE2NUM(tmp));
+ rb_ary_push(ary, rb_float_new(tmp));
}
PACK_ITEM_ADJUST();
break;
-
+
case 'U':
if (len > send - s) len = send - s;
while (len > 0 && s < send) {
@@ -1715,14 +1724,14 @@ pack_unpack(VALUE str, VALUE fmt)
l = utf8_to_uv(s, &alen);
s += alen; len--;
- UNPACK_PUSH(ULONG2NUM(l));
+ rb_ary_push(ary, ULONG2NUM(l));
}
break;
case 'u':
{
VALUE buf = infected_str_new(0, (send - s)*3/4, str);
- char *ptr = RSTRING_PTR(buf);
+ char *ptr = RSTRING(buf)->ptr;
long total = 0;
while (s < send && *s > ' ' && *s < 'a') {
@@ -1732,9 +1741,9 @@ pack_unpack(VALUE str, VALUE fmt)
hunk[3] = '\0';
len = (*s++ - ' ') & 077;
total += len;
- if (total > RSTRING_LEN(buf)) {
- len -= total - RSTRING_LEN(buf);
- total = RSTRING_LEN(buf);
+ if (total > RSTRING(buf)->len) {
+ len -= total - RSTRING(buf)->len;
+ total = RSTRING(buf)->len;
}
while (len > 0) {
@@ -1768,16 +1777,17 @@ pack_unpack(VALUE str, VALUE fmt)
else if (s < send && (s+1 == send || s[1] == '\n'))
s += 2; /* possible checksum byte */
}
-
- rb_str_set_len(buf, total);
- UNPACK_PUSH(buf);
+
+ RSTRING(buf)->ptr[total] = '\0';
+ RSTRING(buf)->len = total;
+ rb_ary_push(ary, buf);
}
break;
case 'm':
{
VALUE buf = infected_str_new(0, (send - s)*3/4, str);
- char *ptr = RSTRING_PTR(buf);
+ char *ptr = RSTRING(buf)->ptr;
int a = -1,b = -1,c = 0,d;
static int first = 1;
static int b64_xtable[256];
@@ -1819,15 +1829,16 @@ pack_unpack(VALUE str, VALUE fmt)
*ptr++ = b << 4 | c >> 2;
}
}
- rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
- UNPACK_PUSH(buf);
+ *ptr = '\0';
+ RSTRING(buf)->len = ptr - RSTRING(buf)->ptr;
+ rb_ary_push(ary, buf);
}
break;
case 'M':
{
VALUE buf = infected_str_new(0, send - s, str);
- char *ptr = RSTRING_PTR(buf);
+ char *ptr = RSTRING(buf)->ptr;
int c1, c2;
while (s < send) {
@@ -1847,19 +1858,20 @@ pack_unpack(VALUE str, VALUE fmt)
}
s++;
}
- rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
- UNPACK_PUSH(buf);
+ *ptr = '\0';
+ RSTRING(buf)->len = ptr - RSTRING(buf)->ptr;
+ rb_ary_push(ary, buf);
}
break;
case '@':
- if (len > RSTRING_LEN(str))
+ if (len > RSTRING(str)->len)
rb_raise(rb_eArgError, "@ outside of string");
- s = RSTRING_PTR(str) + len;
+ s = RSTRING(str)->ptr + len;
break;
case 'X':
- if (len > s - RSTRING_PTR(str))
+ if (len > s - RSTRING(str)->ptr)
rb_raise(rb_eArgError, "X outside of string");
s -= len;
break;
@@ -1872,8 +1884,8 @@ pack_unpack(VALUE str, VALUE fmt)
case 'P':
if (sizeof(char *) <= send - s) {
+ VALUE tmp = Qnil;
char *t;
- VALUE tmp;
memcpy(&t, s, sizeof(char *));
s += sizeof(char *);
@@ -1884,11 +1896,11 @@ pack_unpack(VALUE str, VALUE fmt)
if (!(a = rb_str_associated(str))) {
rb_raise(rb_eArgError, "no associated pointer");
}
- p = RARRAY_PTR(a);
- pend = p + RARRAY_LEN(a);
+ p = RARRAY(a)->ptr;
+ pend = p + RARRAY(a)->len;
while (p < pend) {
- if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) {
- if (len < RSTRING_LEN(*p)) {
+ if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t) {
+ if (len < RSTRING(*p)->len) {
tmp = rb_tainted_str_new(t, len);
rb_str_associate(tmp, a);
}
@@ -1903,10 +1915,7 @@ pack_unpack(VALUE str, VALUE fmt)
rb_raise(rb_eArgError, "non associated pointer");
}
}
- else {
- tmp = Qnil;
- }
- UNPACK_PUSH(tmp);
+ rb_ary_push(ary, tmp);
}
break;
@@ -1917,7 +1926,7 @@ pack_unpack(VALUE str, VALUE fmt)
if (send - s < sizeof(char *))
break;
else {
- VALUE tmp;
+ VALUE tmp = Qnil;
char *t;
memcpy(&t, s, sizeof(char *));
@@ -1929,10 +1938,10 @@ pack_unpack(VALUE str, VALUE fmt)
if (!(a = rb_str_associated(str))) {
rb_raise(rb_eArgError, "no associated pointer");
}
- p = RARRAY_PTR(a);
- pend = p + RARRAY_LEN(a);
+ p = RARRAY(a)->ptr;
+ pend = p + RARRAY(a)->len;
while (p < pend) {
- if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) {
+ if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t) {
tmp = *p;
break;
}
@@ -1942,10 +1951,7 @@ pack_unpack(VALUE str, VALUE fmt)
rb_raise(rb_eArgError, "non associated pointer");
}
}
- else {
- tmp = Qnil;
- }
- UNPACK_PUSH(tmp);
+ rb_ary_push(ary, tmp);
}
}
break;
@@ -1959,7 +1965,7 @@ pack_unpack(VALUE str, VALUE fmt)
ul <<= 7;
ul |= (*s & 0x7f);
if (!(*s++ & 0x80)) {
- UNPACK_PUSH(ULONG2NUM(ul));
+ rb_ary_push(ary, ULONG2NUM(ul));
len--;
ul = 0;
}
@@ -1970,7 +1976,7 @@ pack_unpack(VALUE str, VALUE fmt)
big = rb_big_mul(big, big128);
big = rb_big_plus(big, rb_uint2big(*s & 0x7f));
if (!(*s++ & 0x80)) {
- UNPACK_PUSH(big);
+ rb_ary_push(ary, big);
len--;
ul = 0;
break;
@@ -1991,8 +1997,10 @@ pack_unpack(VALUE str, VALUE fmt)
#define BYTEWIDTH 8
-int
-rb_uv_to_utf8(char buf[6], unsigned long uv)
+static int
+uv_to_utf8(buf, uv)
+ char *buf;
+ unsigned long uv;
{
if (uv <= 0x7f) {
buf[0] = (char)uv;
@@ -2047,7 +2055,9 @@ static const unsigned long utf8_limits[] = {
};
static unsigned long
-utf8_to_uv(const char *p, long *lenp)
+utf8_to_uv(p, lenp)
+ char *p;
+ long *lenp;
{
int c = *p++ & 0xff;
unsigned long uv = c;
@@ -2072,7 +2082,7 @@ utf8_to_uv(const char *p, long *lenp)
rb_raise(rb_eArgError, "malformed UTF-8 character");
}
if (n > *lenp) {
- rb_raise(rb_eArgError, "malformed UTF-8 character (expected %ld bytes, given %ld bytes)",
+ rb_raise(rb_eArgError, "malformed UTF-8 character (expected %d bytes, given %d bytes)",
n, *lenp);
}
*lenp = n--;
@@ -2097,7 +2107,7 @@ utf8_to_uv(const char *p, long *lenp)
}
void
-Init_pack(void)
+Init_pack()
{
rb_define_method(rb_cArray, "pack", pack_pack, 1);
rb_define_method(rb_cString, "unpack", pack_unpack, 1);
diff --git a/parse.y b/parse.y
index 9e0c8b18e2..101ac1900c 100644
--- a/parse.y
+++ b/parse.y
@@ -6,7 +6,7 @@
$Date$
created at: Fri May 28 18:02:42 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -14,38 +14,49 @@
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
+#ifndef YYSTACK_USE_ALLOCA
#define YYSTACK_USE_ALLOCA 0
+#endif
-#include "ruby/ruby.h"
-#include "ruby/intern.h"
-#include "ruby/node.h"
-#include "ruby/st.h"
-#include "ruby/encoding.h"
-#include "id.h"
-#include "regenc.h"
+#include "ruby.h"
+#include "env.h"
+#include "intern.h"
+#include "node.h"
+#include "st.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
-#define YYMALLOC(size) rb_parser_malloc(parser, size)
-#define YYREALLOC(ptr, size) rb_parser_realloc(parser, ptr, size)
-#define YYCALLOC(nelem, size) rb_parser_calloc(parser, nelem, size)
-#define YYFREE(ptr) rb_parser_free(parser, ptr)
+#define YYMALLOC rb_parser_malloc
+#define YYREALLOC rb_parser_realloc
+#define YYCALLOC rb_parser_calloc
+#define YYFREE rb_parser_free
#define malloc YYMALLOC
#define realloc YYREALLOC
#define calloc YYCALLOC
#define free YYFREE
+static void *rb_parser_malloc _((size_t));
+static void *rb_parser_realloc _((void *, size_t));
+static void *rb_parser_calloc _((size_t, size_t));
+static void rb_parser_free _((void *));
+
+#define yyparse ruby_yyparse
+#define yylex ruby_yylex
+#define yyerror ruby_yyerror
+#define yylval ruby_yylval
+#define yychar ruby_yychar
+#define yydebug ruby_yydebug
#define ID_SCOPE_SHIFT 3
#define ID_SCOPE_MASK 0x07
-#define ID_LOCAL 0x00
-#define ID_INSTANCE 0x01
-#define ID_GLOBAL 0x03
-#define ID_ATTRSET 0x04
-#define ID_CONST 0x05
-#define ID_CLASS 0x06
-#define ID_JUNK 0x07
-#define ID_INTERNAL ID_JUNK
+#define ID_LOCAL 0x01
+#define ID_INSTANCE 0x02
+#define ID_GLOBAL 0x03
+#define ID_ATTRSET 0x04
+#define ID_CONST 0x05
+#define ID_CLASS 0x06
+#define ID_JUNK 0x07
+#define ID_INTERNAL ID_JUNK
#define is_notop_id(id) ((id)>tLAST_TOKEN)
#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
@@ -61,403 +72,120 @@
((id)&ID_SCOPE_MASK) == ID_INSTANCE || \
((id)&ID_SCOPE_MASK) == ID_CLASS))
-enum lex_state_e {
+NODE *ruby_eval_tree_begin = 0;
+NODE *ruby_eval_tree = 0;
+
+char *ruby_sourcefile; /* current source file */
+int ruby_sourceline; /* current line no. */
+
+static int yylex();
+static int yyerror();
+
+static enum lex_state {
EXPR_BEG, /* ignore newline, +/- is a sign. */
- EXPR_END, /* newline significant, +/- is a operator. */
- EXPR_ENDARG, /* ditto, and unbound braces. */
- EXPR_ARG, /* newline significant, +/- is a operator. */
- EXPR_CMDARG, /* newline significant, +/- is a operator. */
- EXPR_MID, /* newline significant, +/- is a operator. */
+ EXPR_END, /* newline significant, +/- is an operator. */
+ EXPR_ARG, /* newline significant, +/- is an operator. */
+ EXPR_CMDARG, /* newline significant, +/- is an operator. */
+ EXPR_ENDARG, /* newline significant, +/- is an operator. */
+ EXPR_MID, /* newline significant, +/- is an operator. */
EXPR_FNAME, /* ignore newline, no reserved words. */
EXPR_DOT, /* right after `.' or `::', no reserved words. */
EXPR_CLASS, /* immediate after `class', no here document. */
- EXPR_VALUE, /* alike EXPR_BEG but label is disallowed. */
-};
+} lex_state;
+static NODE *lex_strterm;
-# ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG
typedef unsigned LONG_LONG stack_type;
-# else
+#else
typedef unsigned long stack_type;
-# endif
+#endif
-# define BITSTACK_PUSH(stack, n) (stack = (stack<<1)|((n)&1))
-# define BITSTACK_POP(stack) (stack = stack >> 1)
-# define BITSTACK_LEXPOP(stack) (stack = (stack >> 1) | (stack & 1))
-# define BITSTACK_SET_P(stack) (stack&1)
+#define BITSTACK_PUSH(stack, n) (stack = (stack<<1)|((n)&1))
+#define BITSTACK_POP(stack) (stack >>= 1)
+#define BITSTACK_LEXPOP(stack) (stack = (stack >> 1) | (stack & 1))
+#define BITSTACK_SET_P(stack) (stack&1)
+static stack_type cond_stack = 0;
#define COND_PUSH(n) BITSTACK_PUSH(cond_stack, n)
#define COND_POP() BITSTACK_POP(cond_stack)
#define COND_LEXPOP() BITSTACK_LEXPOP(cond_stack)
#define COND_P() BITSTACK_SET_P(cond_stack)
+static stack_type cmdarg_stack = 0;
#define CMDARG_PUSH(n) BITSTACK_PUSH(cmdarg_stack, n)
#define CMDARG_POP() BITSTACK_POP(cmdarg_stack)
#define CMDARG_LEXPOP() BITSTACK_LEXPOP(cmdarg_stack)
#define CMDARG_P() BITSTACK_SET_P(cmdarg_stack)
-/* must sync with real YYSTYPE */
-union tmpyystype {
- VALUE val;
- NODE *node;
- unsigned long id;
- int num;
- struct RVarmap *vars;
-};
-
-struct vtable {
- ID *tbl;
- int pos;
- int capa;
- struct vtable *prev;
-};
-
-struct local_vars {
- struct vtable *args;
- struct vtable *vars;
- struct local_vars *prev;
-};
-
-#define DVARS_INHERIT ((void*)1)
-#define DVARS_TOPSCOPE NULL
-#define DVARS_SPECIAL_P(tbl) (!POINTER_P(tbl))
-#define POINTER_P(val) ((VALUE)(val) & ~(VALUE)3)
-
-#ifndef RIPPER
-static int
-vtable_size(const struct vtable *tbl)
-{
- if (POINTER_P(tbl)) {
- return tbl->pos;
- }
- else {
- return 0;
- }
-}
-
-#define VTBL_DEBUG 0
-
-static struct vtable *
-vtable_alloc(struct vtable *prev)
-{
- struct vtable *tbl = ALLOC(struct vtable);
- tbl->pos = 0;
- tbl->capa = 8;
- tbl->tbl = ALLOC_N(ID, tbl->capa);
- tbl->prev = prev;
- if (VTBL_DEBUG) printf("vtable_alloc: %p\n", tbl);
- return tbl;
-}
-
-static void
-vtable_free(struct vtable *tbl)
-{
- if (VTBL_DEBUG)printf("vtable_free: %p\n", tbl);
- if (POINTER_P(tbl)) {
- if (tbl->tbl) {
- xfree(tbl->tbl);
- }
- if (tbl) {
- xfree(tbl);
- }
- }
-}
-
-static void
-vtable_add(struct vtable *tbl, ID id)
-{
- if (!POINTER_P(tbl)) {
- rb_bug("vtable_add: vtable is not allocated (%p)", tbl);
- }
- if (VTBL_DEBUG) printf("vtable_add: %p, %s\n", tbl, rb_id2name(id));
-
- if (tbl->pos == tbl->capa) {
- tbl->capa = tbl->capa * 2;
- REALLOC_N(tbl->tbl, ID, tbl->capa);
- }
- tbl->tbl[tbl->pos++] = id;
-}
-
-static int
-vtable_included(const struct vtable * tbl, ID id)
-{
- int i;
-
- if (POINTER_P(tbl)) {
- for (i = 0; i < tbl->pos; i++) {
- if (tbl->tbl[i] == id) {
- return 1;
- }
- }
- }
- return 0;
-}
-#endif
+static int class_nest = 0;
+static int in_single = 0;
+static int in_def = 0;
+static int compile_for_eval = 0;
+static ID cur_mid = 0;
+static int command_start = Qtrue;
-/*
- Structure of Lexer Buffer:
-
- lex_pbeg tokp lex_p lex_pend
- | | | |
- |-----------+--------------+------------|
- |<------------>|
- token
-*/
-struct parser_params {
- int is_ripper;
- NODE *heap;
-
- union tmpyystype *parser_yylval; /* YYSTYPE not defined yet */
- VALUE eofp;
-
- NODE *parser_lex_strterm;
- enum lex_state_e parser_lex_state;
- stack_type parser_cond_stack;
- stack_type parser_cmdarg_stack;
- int parser_class_nest;
- int parser_paren_nest;
- int parser_lpar_beg;
- int parser_in_single;
- int parser_in_def;
- int parser_compile_for_eval;
- VALUE parser_cur_mid;
- int parser_in_defined;
- char *parser_tokenbuf;
- int parser_tokidx;
- int parser_toksiz;
- VALUE parser_lex_input;
- VALUE parser_lex_lastline;
- VALUE parser_lex_nextline;
- const char *parser_lex_pbeg;
- const char *parser_lex_p;
- const char *parser_lex_pend;
- int parser_heredoc_end;
- int parser_command_start;
- int parser_lex_gets_ptr;
- VALUE (*parser_lex_gets)(struct parser_params*,VALUE);
- struct local_vars *parser_lvtbl;
- int parser_ruby__end__seen;
- int line_count;
- int has_shebang;
- char *parser_ruby_sourcefile; /* current source file */
- int parser_ruby_sourceline; /* current line no. */
- rb_encoding *enc;
- rb_encoding *utf8;
-
- int parser_yydebug;
-
-#ifndef RIPPER
- /* Ruby core only */
- NODE *parser_eval_tree_begin;
- NODE *parser_eval_tree;
- VALUE debug_lines;
- int nerr;
-#else
- /* Ripper only */
- VALUE parser_ruby_sourcefile_string;
- const char *tokp;
- VALUE delayed;
- int delayed_line;
- int delayed_col;
-
- VALUE value;
- VALUE result;
- VALUE parsing_thread;
- int toplevel_p;
-#endif
-};
+static NODE *deferred_nodes;
-#define UTF8_ENC() (parser->utf8 ? parser->utf8 : \
- (parser->utf8 = rb_utf8_encoding()))
-#define STR_NEW(p,n) rb_enc_str_new((p),(n),parser->enc)
-#define STR_NEW0() rb_str_new(0,0)
-#define STR_NEW2(p) rb_enc_str_new((p),strlen(p),parser->enc)
-#define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func))
-#define STR_ENC(m) ((m)?parser->enc:rb_enc_from_index(0))
-#define ENC_SINGLE(cr) ((cr)==ENC_CODERANGE_7BIT)
-#define TOK_INTERN(mb) rb_intern3(tok(), toklen(), STR_ENC(mb))
+static NODE *cond();
+static NODE *logop();
+static int cond_negative();
-#ifdef YYMALLOC
-void *rb_parser_malloc(struct parser_params *, size_t);
-void *rb_parser_realloc(struct parser_params *, void *, size_t);
-void *rb_parser_calloc(struct parser_params *, size_t, size_t);
-void rb_parser_free(struct parser_params *, void *);
-#endif
+static NODE *newline_node();
+static void fixpos();
-static int parser_yyerror(struct parser_params*, const char*);
-#define yyerror(msg) parser_yyerror(parser, msg)
-
-#define YYLEX_PARAM parser
-
-#define lex_strterm (parser->parser_lex_strterm)
-#define lex_state (parser->parser_lex_state)
-#define cond_stack (parser->parser_cond_stack)
-#define cmdarg_stack (parser->parser_cmdarg_stack)
-#define class_nest (parser->parser_class_nest)
-#define paren_nest (parser->parser_paren_nest)
-#define lpar_beg (parser->parser_lpar_beg)
-#define in_single (parser->parser_in_single)
-#define in_def (parser->parser_in_def)
-#define compile_for_eval (parser->parser_compile_for_eval)
-#define cur_mid (parser->parser_cur_mid)
-#define in_defined (parser->parser_in_defined)
-#define tokenbuf (parser->parser_tokenbuf)
-#define tokidx (parser->parser_tokidx)
-#define toksiz (parser->parser_toksiz)
-#define lex_input (parser->parser_lex_input)
-#define lex_lastline (parser->parser_lex_lastline)
-#define lex_nextline (parser->parser_lex_nextline)
-#define lex_pbeg (parser->parser_lex_pbeg)
-#define lex_p (parser->parser_lex_p)
-#define lex_pend (parser->parser_lex_pend)
-#define heredoc_end (parser->parser_heredoc_end)
-#define command_start (parser->parser_command_start)
-#define lex_gets_ptr (parser->parser_lex_gets_ptr)
-#define lex_gets (parser->parser_lex_gets)
-#define lvtbl (parser->parser_lvtbl)
-#define ruby__end__seen (parser->parser_ruby__end__seen)
-#define ruby_sourceline (parser->parser_ruby_sourceline)
-#define ruby_sourcefile (parser->parser_ruby_sourcefile)
-#define yydebug (parser->parser_yydebug)
-#ifdef RIPPER
-#else
-#define ruby_eval_tree (parser->parser_eval_tree)
-#define ruby_eval_tree_begin (parser->parser_eval_tree_begin)
-#define ruby_debug_lines (parser->debug_lines)
-#endif
-
-static int yylex(void*, void*);
-
-#ifndef RIPPER
-#define yyparse ruby_yyparse
-
-static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE);
-#define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, type, a1, a2, a3)
-
-static NODE *cond_gen(struct parser_params*,NODE*);
-#define cond(node) cond_gen(parser, node)
-static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*);
-#define logop(type,node1,node2) logop_gen(parser, type, node1, node2)
-
-static NODE *newline_node(NODE*);
-static void fixpos(NODE*,NODE*);
-
-static int value_expr_gen(struct parser_params*,NODE*);
-static void void_expr_gen(struct parser_params*,NODE*);
-static NODE *remove_begin(NODE*);
-#define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
-#define void_expr0(node) void_expr_gen(parser, (node))
+static int value_expr0();
+static void void_expr0();
+static void void_stmts();
+static NODE *remove_begin();
+#define value_expr(node) value_expr0((node) = remove_begin(node))
#define void_expr(node) void_expr0((node) = remove_begin(node))
-static void void_stmts_gen(struct parser_params*,NODE*);
-#define void_stmts(node) void_stmts_gen(parser, node)
-static void reduce_nodes_gen(struct parser_params*,NODE**);
-#define reduce_nodes(n) reduce_nodes_gen(parser,n)
-static void block_dup_check_gen(struct parser_params*,NODE*,NODE*);
-#define block_dup_check(n1,n2) block_dup_check_gen(parser,n1,n2)
-
-static NODE *block_append_gen(struct parser_params*,NODE*,NODE*);
-#define block_append(h,t) block_append_gen(parser,h,t)
-static NODE *list_append_gen(struct parser_params*,NODE*,NODE*);
-#define list_append(l,i) list_append_gen(parser,l,i)
-static NODE *list_concat_gen(struct parser_params*,NODE*,NODE*);
-#define list_concat(h,t) list_concat_gen(parser,h,t)
-static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*);
-#define arg_append(h,t) arg_append_gen(parser,h,t)
-static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*);
-#define arg_concat(h,t) arg_concat_gen(parser,h,t)
-static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*);
-#define literal_concat(h,t) literal_concat_gen(parser,h,t)
-static NODE *new_evstr_gen(struct parser_params*,NODE*);
-#define new_evstr(n) new_evstr_gen(parser,n)
-static NODE *evstr2dstr_gen(struct parser_params*,NODE*);
-#define evstr2dstr(n) evstr2dstr_gen(parser,n)
-
-static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*);
-#define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, recv,id,arg1)
-static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID);
-#define call_uni_op(recv,id) call_uni_op_gen(parser, recv,id)
-
-static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,ID);
-#define new_args(f,o,r,p,b) new_args_gen(parser, f,o,r,p,b)
-static void shadowing_lvar_gen(struct parser_params*,ID);
-#define shadowing_lvar(name) shadowing_lvar_gen(parser, name)
-
-static NODE *negate_lit(NODE*);
-static NODE *ret_args_gen(struct parser_params*,NODE*);
-#define ret_args(node) ret_args_gen(parser, node)
-static NODE *arg_blk_pass(NODE*,NODE*);
-static NODE *new_yield_gen(struct parser_params*,NODE*);
-#define new_yield(node) new_yield_gen(parser, node)
-
-static NODE *gettable_gen(struct parser_params*,ID);
-#define gettable(id) gettable_gen(parser,id)
-static NODE *assignable_gen(struct parser_params*,ID,NODE*);
-#define assignable(id,node) assignable_gen(parser, id, node)
-static void new_bv_gen(struct parser_params*,ID);
-#define new_bv(id) new_bv_gen(parser, id)
-static NODE *aryset_gen(struct parser_params*,NODE*,NODE*);
-#define aryset(node1,node2) aryset_gen(parser, node1, node2)
-static NODE *attrset_gen(struct parser_params*,NODE*,ID);
-#define attrset(node,id) attrset_gen(parser, node, id)
-
-static void rb_backref_error_gen(struct parser_params*,NODE*);
-#define rb_backref_error(n) rb_backref_error_gen(parser,n)
-static NODE *node_assign_gen(struct parser_params*,NODE*,NODE*);
-#define node_assign(node1, node2) node_assign_gen(parser, node1, node2)
-
-static NODE *match_op_gen(struct parser_params*,NODE*,NODE*);
-#define match_op(node1,node2) match_op_gen(parser, node1, node2)
-
-static void local_push_gen(struct parser_params*,int);
-#define local_push(top) local_push_gen(parser,top)
-static void local_pop_gen(struct parser_params*);
-#define local_pop() local_pop_gen(parser)
-static int local_var_gen(struct parser_params*, ID);
-#define local_var(id) local_var_gen(parser, id);
-static int arg_var_gen(struct parser_params*, ID);
-#define arg_var(id) arg_var_gen(parser, id)
-static int local_id_gen(struct parser_params*, ID);
-#define local_id(id) local_id_gen(parser, id)
-static ID *local_tbl_gen(struct parser_params*);
-#define local_tbl() local_tbl_gen(parser)
-static ID internal_id_gen(struct parser_params*);
-#define internal_id() internal_id_gen(parser)
-
-static void dyna_push_gen(struct parser_params*);
-#define dyna_push() dyna_push_gen(parser)
-static void dyna_pop_gen(struct parser_params*);
-#define dyna_pop() dyna_pop_gen(parser)
-static int dyna_in_block_gen(struct parser_params*);
-#define dyna_in_block() dyna_in_block_gen(parser)
-#define dyna_var(id) local_var(id)
-static int dvar_defined_gen(struct parser_params*,ID);
-#define dvar_defined(id) dvar_defined_gen(parser, id)
-static int dvar_curr_gen(struct parser_params*,ID);
-#define dvar_curr(id) dvar_curr_gen(parser, id)
-
-extern int rb_dvar_defined(ID);
-extern int rb_local_defined(ID);
-extern int rb_parse_in_eval(void);
-
-static VALUE reg_compile_gen(struct parser_params*, VALUE, int);
-#define reg_compile(str,options) reg_compile_gen(parser, str, options)
-static void reg_fragment_setenc_gen(struct parser_params*, VALUE, int);
-#define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, str, options)
-static void reg_fragment_check_gen(struct parser_params*, VALUE, int);
-#define reg_fragment_check(str,options) reg_fragment_check_gen(parser, str, options)
-static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, NODE *match);
-#define reg_named_capture_assign(regexp,match) reg_named_capture_assign_gen(parser,regexp,match)
-int rb_enc_symname2_p(const char *, int, rb_encoding *);
-#else
-#define remove_begin(node) (node)
-#endif /* !RIPPER */
-static int lvar_defined_gen(struct parser_params*, ID);
-#define lvar_defined(id) lvar_defined_gen(parser, id)
-#define RE_OPTION_ONCE (1<<16)
-#define RE_OPTION_ENCODING_SHIFT 8
-#define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
-#define RE_OPTION_ENCODING_IDX(o) (((o)>>RE_OPTION_ENCODING_SHIFT)&0xff)
-#define RE_OPTION_MASK 0xff
+static NODE *block_append();
+static NODE *list_append();
+static NODE *list_concat();
+static NODE *arg_concat();
+static NODE *arg_prepend();
+static NODE *literal_concat();
+static NODE *new_evstr();
+static NODE *evstr2dstr();
+static NODE *call_op();
+static int in_defined = 0;
+
+static NODE *negate_lit();
+static NODE *ret_args();
+static NODE *arg_blk_pass();
+static NODE *new_call();
+static NODE *new_fcall();
+static NODE *new_super();
+static NODE *new_yield();
+
+static NODE *gettable();
+static NODE *assignable();
+static NODE *aryset();
+static NODE *attrset();
+static void rb_backref_error();
+static NODE *node_assign();
+
+static NODE *match_gen();
+static void local_push();
+static void local_pop();
+static int local_append();
+static int local_cnt();
+static int local_id();
+static ID *local_tbl();
+static ID internal_id();
+
+static struct RVarmap *dyna_push();
+static void dyna_pop();
+static int dyna_in_block();
+static NODE *dyna_init();
+
+static void top_local_init();
+static void top_local_setup();
+
+static void fixup_nodes();
+
+#define RE_OPTION_ONCE 0x80
#define NODE_STRTERM NODE_ZARRAY /* nothing to gc */
#define NODE_HEREDOC NODE_ARRAY /* 1, 3 to gc */
@@ -469,107 +197,9 @@ static int lvar_defined_gen(struct parser_params*, ID);
#define nd_term(node) SIGN_EXTEND((node)->u2.id, CHAR_BIT*2)
#endif
#define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
-#define nd_nest u3.cnt
-
-/****** Ripper *******/
-
-#ifdef RIPPER
-#define RIPPER_VERSION "0.1.0"
-
-#include "eventids1.c"
-#include "eventids2.c"
-static ID ripper_id_gets;
+#define nd_nest u3.id
-static VALUE ripper_dispatch0(struct parser_params*,ID);
-static VALUE ripper_dispatch1(struct parser_params*,ID,VALUE);
-static VALUE ripper_dispatch2(struct parser_params*,ID,VALUE,VALUE);
-static VALUE ripper_dispatch3(struct parser_params*,ID,VALUE,VALUE,VALUE);
-static VALUE ripper_dispatch4(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE);
-static VALUE ripper_dispatch5(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,VALUE);
-
-#define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
-#define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), a)
-#define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), a, b)
-#define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), a, b, c)
-#define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), a, b, c, d)
-#define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), a, b, c, d, e)
-
-#define yyparse ripper_yyparse
-
-static VALUE ripper_intern(const char*);
-static VALUE ripper_id2sym(ID);
-
-#define arg_new() dispatch0(args_new)
-#define arg_add(l,a) dispatch2(args_add, l, a)
-#define arg_prepend(l,a) dispatch2(args_prepend, l, a)
-#define arg_add_star(l,a) dispatch2(args_add_star, l, a)
-#define arg_add_block(l,b) dispatch2(args_add_block, l, b)
-#define arg_add_optblock(l,b) ((b)==Qundef? l : dispatch2(args_add_block, l, b))
-#define bare_assoc(v) dispatch1(bare_assoc_hash, v)
-#define arg_add_assocs(l,b) arg_add(l, bare_assoc(b))
-
-#define args2mrhs(a) dispatch1(mrhs_new_from_args, a)
-#define mrhs_new() dispatch0(mrhs_new)
-#define mrhs_add(l,a) dispatch2(mrhs_add, l, a)
-#define mrhs_add_star(l,a) dispatch2(mrhs_add_star, l, a)
-
-#define mlhs_new() dispatch0(mlhs_new)
-#define mlhs_add(l,a) dispatch2(mlhs_add, l, a)
-#define mlhs_add_star(l,a) dispatch2(mlhs_add_star, l, a)
-
-#define params_new(pars, opts, rest, pars2, blk) \
- dispatch5(params, pars, opts, rest, pars2, blk)
-
-#define blockvar_new(p,v) dispatch2(block_var, p, v)
-#define blockvar_add_star(l,a) dispatch2(block_var_add_star, l, a)
-#define blockvar_add_block(l,a) dispatch2(block_var_add_block, l, a)
-
-#define method_optarg(m,a) ((a)==Qundef ? m : dispatch2(method_add_arg,m,a))
-#define method_arg(m,a) dispatch2(method_add_arg,m,a)
-#define method_add_block(m,b) dispatch2(method_add_block, m, b)
-
-#define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
-
-#define FIXME 0
-
-#endif /* RIPPER */
-
-#ifndef RIPPER
-# define ifndef_ripper(x) x
-#else
-# define ifndef_ripper(x)
-#endif
-
-#ifndef RIPPER
-# define rb_warn0(fmt) rb_compile_warn(ruby_sourcefile, ruby_sourceline, fmt)
-# define rb_warnI(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, fmt, a)
-# define rb_warnS(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, fmt, a)
-# define rb_warning0(fmt) rb_compile_warning(ruby_sourcefile, ruby_sourceline, fmt)
-# define rb_warningS(fmt,a) rb_compile_warning(ruby_sourcefile, ruby_sourceline, fmt, a)
-#else
-# define rb_warn0(fmt) ripper_warn0(parser, fmt)
-# define rb_warnI(fmt,a) ripper_warnI(parser, fmt, a)
-# define rb_warnS(fmt,a) ripper_warnS(parser, fmt, a)
-# define rb_warning0(fmt) ripper_warning0(parser, fmt)
-# define rb_warningS(fmt,a) ripper_warningS(parser, fmt, a)
-static void ripper_warn0(struct parser_params*, const char*);
-static void ripper_warnI(struct parser_params*, const char*, int);
-static void ripper_warnS(struct parser_params*, const char*, const char*);
-static void ripper_warning0(struct parser_params*, const char*);
-#if 0 /* unused in ripper right now */
-static void ripper_warningS(struct parser_params*, const char*, const char*);
-#endif
-#endif
-
-#ifdef RIPPER
-static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
-# define rb_compile_error ripper_compile_error
-# define compile_error ripper_compile_error
-# define PARSER_ARG parser,
-#else
-# define compile_error parser->nerr++,rb_compile_error
-# define PARSER_ARG ruby_sourcefile, ruby_sourceline,
-#endif
+#define NEW_BLOCK_VAR(b, v) NEW_NODE(NODE_BLOCK_PASS, 0, b, v)
/* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150,
for instance). This is too low for Ruby to parse some files, such as
@@ -582,74 +212,63 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
%}
-%pure_parser
-%parse-param {struct parser_params *parser}
-
%union {
- VALUE val;
NODE *node;
ID id;
int num;
struct RVarmap *vars;
}
-/*%%%*/
-%token
-/*%
-%token <val>
-%*/
- keyword_class
- keyword_module
- keyword_def
- keyword_undef
- keyword_begin
- keyword_rescue
- keyword_ensure
- keyword_end
- keyword_if
- keyword_unless
- keyword_then
- keyword_elsif
- keyword_else
- keyword_case
- keyword_when
- keyword_while
- keyword_until
- keyword_for
- keyword_break
- keyword_next
- keyword_redo
- keyword_retry
- keyword_in
- keyword_do
- keyword_do_cond
- keyword_do_block
- keyword_do_LAMBDA
- keyword_return
- keyword_yield
- keyword_super
- keyword_self
- keyword_nil
- keyword_true
- keyword_false
- keyword_and
- keyword_or
- keyword_not
- modifier_if
- modifier_unless
- modifier_while
- modifier_until
- modifier_rescue
- keyword_alias
- keyword_defined
- keyword_BEGIN
- keyword_END
- keyword__LINE__
- keyword__FILE__
- keyword__ENCODING__
-
-%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
-%token <node> tINTEGER tFLOAT tSTRING_CONTENT tCHAR
+%token kCLASS
+ kMODULE
+ kDEF
+ kUNDEF
+ kBEGIN
+ kRESCUE
+ kENSURE
+ kEND
+ kIF
+ kUNLESS
+ kTHEN
+ kELSIF
+ kELSE
+ kCASE
+ kWHEN
+ kWHILE
+ kUNTIL
+ kFOR
+ kBREAK
+ kNEXT
+ kREDO
+ kRETRY
+ kIN
+ kDO
+ kDO_COND
+ kDO_BLOCK
+ kRETURN
+ kYIELD
+ kSUPER
+ kSELF
+ kNIL
+ kTRUE
+ kFALSE
+ kAND
+ kOR
+ kNOT
+ kIF_MOD
+ kUNLESS_MOD
+ kWHILE_MOD
+ kUNTIL_MOD
+ kRESCUE_MOD
+ kALIAS
+ kDEFINED
+ klBEGIN
+ klEND
+ k__LINE__
+ k__FILE__
+
+%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR
+%token <node> tINTEGER tFLOAT tSTRING_CONTENT
%token <node> tNTH_REF tBACK_REF
%token <num> tREGEXP_END
@@ -660,32 +279,26 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
%type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
%type <node> expr_value arg_value primary_value
%type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
-%type <node> args call_args call_args2 opt_call_args
-%type <node> open_args paren_args opt_paren_args
+%type <node> args when_args call_args call_args2 open_args paren_args opt_paren_args
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
%type <node> mrhs superclass block_call block_command
-%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
-%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
-%type <node> block_param opt_block_param block_param_def f_opt
-%type <node> bv_decls opt_bv_decl bvar
-%type <node> lambda f_larglist lambda_body
+%type <node> f_arglist f_args f_optarg f_opt f_rest_arg f_block_arg opt_f_block_arg
+%type <node> assoc_list assocs assoc undef_list backref string_dvar
+%type <node> for_var block_var opt_block_var block_par
%type <node> brace_block cmd_brace_block do_block lhs none fitem
-%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
+%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
%type <id> fsym variable sym symbol operation operation2 operation3
-%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
-/*%%%*/
-/*%
-%type <val> program reswords then do dot_or_colon
-%*/
-%token tUPLUS /* unary+ */
-%token tUMINUS /* unary- */
+%type <id> cname fname op
+%type <num> f_norm_arg f_arg
+%token tUPLUS /* unary+ */
+%token tUMINUS /* unary- */
%token tPOW /* ** */
-%token tCMP /* <=> */
-%token tEQ /* == */
-%token tEQQ /* === */
-%token tNEQ /* != */
-%token tGEQ /* >= */
-%token tLEQ /* <= */
+%token tCMP /* <=> */
+%token tEQ /* == */
+%token tEQQ /* === */
+%token tNEQ /* != */
+%token tGEQ /* >= */
+%token tLEQ /* <= */
%token tANDOP tOROP /* && and || */
%token tMATCH tNMATCH /* =~ and !~ */
%token tDOT2 tDOT3 /* .. and ... */
@@ -703,9 +316,8 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
%token tLBRACE_ARG /* { */
%token tSTAR /* * */
%token tAMPER /* & */
-%token tLAMBDA /* -> */
%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG
-%token tSTRING_DBEG tSTRING_DVAR tSTRING_END tLAMBEG
+%token tSTRING_DBEG tSTRING_DVAR tSTRING_END
/*
* precedence table
@@ -714,12 +326,12 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
%nonassoc tLOWEST
%nonassoc tLBRACE_ARG
-%nonassoc modifier_if modifier_unless modifier_while modifier_until
-%left keyword_or keyword_and
-%right keyword_not
-%nonassoc keyword_defined
+%nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
+%left kOR kAND
+%right kNOT
+%nonassoc kDEFINED
%right '=' tOP_ASGN
-%left modifier_rescue
+%left kRESCUE_MOD
%right '?' ':'
%nonassoc tDOT2 tDOT3
%left tOROP
@@ -740,16 +352,14 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
%%
program : {
lex_state = EXPR_BEG;
- /*%%%*/
- local_push(compile_for_eval);
- /*%
- %*/
+ top_local_init();
+ if (ruby_class == rb_cObject) class_nest = 0;
+ else class_nest = 1;
}
compstmt
{
- /*%%%*/
if ($2 && !compile_for_eval) {
- /* last expression should not be void */
+ /* last expression should not be void */
if (nd_type($2) != NODE_BLOCK) void_expr($2);
else {
NODE *node = $2;
@@ -759,12 +369,9 @@ program : {
void_expr(node->nd_head);
}
}
- ruby_eval_tree = NEW_SCOPE(0, block_append(ruby_eval_tree, $2));
- local_pop();
- /*%
- $$ = $2;
- parser->result = dispatch1(program, $$);
- %*/
+ ruby_eval_tree = block_append(ruby_eval_tree, $2);
+ top_local_setup();
+ class_nest = 0;
}
;
@@ -773,68 +380,37 @@ bodystmt : compstmt
opt_else
opt_ensure
{
- /*%%%*/
- $$ = $1;
+ $$ = $1;
if ($2) {
$$ = NEW_RESCUE($1, $2, $3);
}
else if ($3) {
- rb_warn0("else without rescue is useless");
+ rb_warn("else without rescue is useless");
$$ = block_append($$, $3);
}
if ($4) {
- if ($$) {
- $$ = NEW_ENSURE($$, $4);
- }
- else {
- $$ = block_append($4, NEW_NIL());
- }
+ $$ = NEW_ENSURE($$, $4);
}
fixpos($$, $1);
- /*%
- $$ = dispatch4(body_stmt,
- escape_Qundef($1),
- escape_Qundef($2),
- escape_Qundef($3),
- escape_Qundef($4));
- %*/
}
;
compstmt : stmts opt_terms
{
- /*%%%*/
void_stmts($1);
- /*%
- %*/
- $$ = $1;
+ fixup_nodes(&deferred_nodes);
+ $$ = $1;
}
;
stmts : none
- {
- /*%%%*/
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch2(stmts_add, dispatch0(stmts_new),
- dispatch0(void_stmt));
- %*/
- }
| stmt
{
- /*%%%*/
$$ = newline_node($1);
- /*%
- $$ = dispatch2(stmts_add, dispatch0(stmts_new), $1);
- %*/
}
| stmts terms stmt
{
- /*%%%*/
$$ = block_append($1, newline_node($3));
- /*%
- $$ = dispatch2(stmts_add, $1, $3);
- %*/
}
| error stmt
{
@@ -842,160 +418,111 @@ stmts : none
}
;
-stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
+stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
{
- /*%%%*/
- $$ = NEW_ALIAS($2, $4);
- /*%
- $$ = dispatch2(alias, $2, $4);
- %*/
+ $$ = NEW_ALIAS($2, $4);
}
- | keyword_alias tGVAR tGVAR
+ | kALIAS tGVAR tGVAR
{
- /*%%%*/
- $$ = NEW_VALIAS($2, $3);
- /*%
- $$ = dispatch2(var_alias, $2, $3);
- %*/
+ $$ = NEW_VALIAS($2, $3);
}
- | keyword_alias tGVAR tBACK_REF
+ | kALIAS tGVAR tBACK_REF
{
- /*%%%*/
char buf[3];
sprintf(buf, "$%c", (char)$3->nd_nth);
- $$ = NEW_VALIAS($2, rb_intern(buf));
- /*%
- $$ = dispatch2(var_alias, $2, $3);
- %*/
+ $$ = NEW_VALIAS($2, rb_intern(buf));
}
- | keyword_alias tGVAR tNTH_REF
+ | kALIAS tGVAR tNTH_REF
{
- /*%%%*/
- yyerror("can't make alias for the number variables");
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch2(var_alias, $2, $3);
- $$ = dispatch1(alias_error, $$);
- %*/
+ yyerror("can't make alias for the number variables");
+ $$ = 0;
}
- | keyword_undef undef_list
+ | kUNDEF undef_list
{
- /*%%%*/
$$ = $2;
- /*%
- $$ = dispatch1(undef, $2);
- %*/
}
- | stmt modifier_if expr_value
+ | stmt kIF_MOD expr_value
{
- /*%%%*/
$$ = NEW_IF(cond($3), remove_begin($1), 0);
- fixpos($$, $3);
- /*%
- $$ = dispatch2(if_mod, $3, $1);
- %*/
+ fixpos($$, $3);
+ if (cond_negative(&$$->nd_cond)) {
+ $$->nd_else = $$->nd_body;
+ $$->nd_body = 0;
+ }
}
- | stmt modifier_unless expr_value
+ | stmt kUNLESS_MOD expr_value
{
- /*%%%*/
$$ = NEW_UNLESS(cond($3), remove_begin($1), 0);
- fixpos($$, $3);
- /*%
- $$ = dispatch2(unless_mod, $3, $1);
- %*/
+ fixpos($$, $3);
+ if (cond_negative(&$$->nd_cond)) {
+ $$->nd_body = $$->nd_else;
+ $$->nd_else = 0;
+ }
}
- | stmt modifier_while expr_value
+ | stmt kWHILE_MOD expr_value
{
- /*%%%*/
if ($1 && nd_type($1) == NODE_BEGIN) {
$$ = NEW_WHILE(cond($3), $1->nd_body, 0);
}
else {
$$ = NEW_WHILE(cond($3), $1, 1);
}
- /*%
- $$ = dispatch2(while_mod, $3, $1);
- %*/
+ if (cond_negative(&$$->nd_cond)) {
+ nd_set_type($$, NODE_UNTIL);
+ }
}
- | stmt modifier_until expr_value
+ | stmt kUNTIL_MOD expr_value
{
- /*%%%*/
if ($1 && nd_type($1) == NODE_BEGIN) {
$$ = NEW_UNTIL(cond($3), $1->nd_body, 0);
}
else {
$$ = NEW_UNTIL(cond($3), $1, 1);
}
- /*%
- $$ = dispatch2(until_mod, $3, $1);
- %*/
+ if (cond_negative(&$$->nd_cond)) {
+ nd_set_type($$, NODE_WHILE);
+ }
}
- | stmt modifier_rescue stmt
+ | stmt kRESCUE_MOD stmt
{
- /*%%%*/
NODE *resq = NEW_RESBODY(0, remove_begin($3), 0);
$$ = NEW_RESCUE(remove_begin($1), resq, 0);
- /*%
- $$ = dispatch2(rescue_mod, $3, $1);
- %*/
}
- | keyword_BEGIN
+ | klBEGIN
{
if (in_def || in_single) {
yyerror("BEGIN in method");
}
- /*%%%*/
- /* local_push(0); */
- /*%
- %*/
+ local_push(0);
}
'{' compstmt '}'
{
- /*%%%*/
ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
- $4);
- /* NEW_PREEXE($4)); */
- /* local_pop(); */
- $$ = 0;
- /*%
- $$ = dispatch1(BEGIN, $4);
- %*/
+ NEW_PREEXE($4));
+ local_pop();
+ $$ = 0;
}
- | keyword_END '{' compstmt '}'
+ | klEND '{' compstmt '}'
{
if (in_def || in_single) {
- rb_warn0("END in method; use at_exit");
+ rb_warn("END in method; use at_exit");
}
- /*%%%*/
- $$ = NEW_POSTEXE(NEW_NODE(
- NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */));
- /*%
- $$ = dispatch1(END, $3);
- %*/
+
+ $$ = NEW_ITER(0, NEW_POSTEXE(), $3);
}
| lhs '=' command_call
{
- /*%%%*/
- value_expr($3);
$$ = node_assign($1, $3);
- /*%
- $$ = dispatch2(assign, $1, $3);
- %*/
}
| mlhs '=' command_call
{
- /*%%%*/
value_expr($3);
- $1->nd_value = $3;
+ $1->nd_value = ($1->nd_head) ? NEW_TO_ARY($3) : NEW_ARRAY($3);
$$ = $1;
- /*%
- $$ = dispatch2(massign, $1, $3);
- %*/
}
| var_lhs tOP_ASGN command_call
{
- /*%%%*/
value_expr($3);
if ($1) {
ID vid = $1->nd_vid;
@@ -1012,20 +539,16 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
}
else {
$$ = $1;
- $$->nd_value = NEW_CALL(gettable(vid), $2, NEW_LIST($3));
+ $$->nd_value = call_op(gettable(vid),$2,1,$3);
}
}
else {
- $$ = NEW_BEGIN(0);
+ $$ = 0;
}
- /*%
- $$ = dispatch3(opassign, $1, $2, $3);
- %*/
}
- | primary_value '[' opt_call_args rbracket tOP_ASGN command_call
+ | primary_value '[' aref_args ']' tOP_ASGN command_call
{
- /*%%%*/
- NODE *args;
+ NODE *args;
value_expr($6);
if (!$3) $3 = NEW_ZARRAY();
@@ -1037,15 +560,10 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
$5 = 1;
}
$$ = NEW_OP_ASGN1($1, $5, args);
- fixpos($$, $1);
- /*%
- $$ = dispatch2(aref_field, $1, escape_Qundef($3));
- $$ = dispatch3(opassign, $$, $5, $6);
- %*/
+ fixpos($$, $1);
}
| primary_value '.' tIDENTIFIER tOP_ASGN command_call
{
- /*%%%*/
value_expr($5);
if ($4 == tOROP) {
$4 = 0;
@@ -1054,15 +572,10 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
$4 = 1;
}
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(field, $1, ripper_id2sym('.'), $3);
- $$ = dispatch3(opassign, $$, $4, $5);
- %*/
+ fixpos($$, $1);
}
| primary_value '.' tCONSTANT tOP_ASGN command_call
{
- /*%%%*/
value_expr($5);
if ($4 == tOROP) {
$4 = 0;
@@ -1071,15 +584,10 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
$4 = 1;
}
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(field, $1, ripper_id2sym('.'), $3);
- $$ = dispatch3(opassign, $$, $4, $5);
- %*/
+ fixpos($$, $1);
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
{
- /*%%%*/
value_expr($5);
if ($4 == tOROP) {
$4 = 0;
@@ -1088,590 +596,315 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
$4 = 1;
}
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(field, $1, ripper_intern("::"), $3);
- $$ = dispatch3(opassign, $$, $4, $5);
- %*/
+ fixpos($$, $1);
}
| backref tOP_ASGN command_call
{
- /*%%%*/
- rb_backref_error($1);
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch2(assign, dispatch1(var_field, $1), $3);
- $$ = dispatch1(assign_error, $$);
- %*/
+ rb_backref_error($1);
+ $$ = 0;
}
| lhs '=' mrhs
{
- /*%%%*/
- value_expr($3);
- $$ = node_assign($1, $3);
- /*%
- $$ = dispatch2(assign, $1, $3);
- %*/
+ $$ = node_assign($1, NEW_SVALUE($3));
}
| mlhs '=' arg_value
{
- /*%%%*/
- $1->nd_value = $3;
+ $1->nd_value = ($1->nd_head) ? NEW_TO_ARY($3) : NEW_ARRAY($3);
$$ = $1;
- /*%
- dispatch2(massign, $1, $3);
- %*/
}
| mlhs '=' mrhs
{
- /*%%%*/
$1->nd_value = $3;
$$ = $1;
- /*%
- $$ = dispatch2(massign, $1, $3);
- %*/
}
| expr
;
expr : command_call
- | expr keyword_and expr
+ | expr kAND expr
{
- /*%%%*/
$$ = logop(NODE_AND, $1, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("and"), $3);
- %*/
}
- | expr keyword_or expr
+ | expr kOR expr
{
- /*%%%*/
$$ = logop(NODE_OR, $1, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("or"), $3);
- %*/
}
- | keyword_not expr
+ | kNOT expr
{
- /*%%%*/
- $$ = call_uni_op(cond($2), '!');
- /*%
- $$ = dispatch2(unary, ripper_intern("not"), $2);
- %*/
+ $$ = NEW_NOT(cond($2));
}
| '!' command_call
{
- /*%%%*/
- $$ = call_uni_op(cond($2), '!');
- /*%
- $$ = dispatch2(unary, ripper_id2sym('!'), $2);
- %*/
+ $$ = NEW_NOT(cond($2));
}
| arg
;
expr_value : expr
{
- /*%%%*/
- value_expr($1);
- $$ = $1;
- if (!$$) $$ = NEW_NIL();
- /*%
+ value_expr($$);
$$ = $1;
- %*/
}
;
command_call : command
| block_command
- | keyword_return call_args
+ | kRETURN call_args
{
- /*%%%*/
$$ = NEW_RETURN(ret_args($2));
- /*%
- $$ = dispatch1(return, $2);
- %*/
}
- | keyword_break call_args
+ | kBREAK call_args
{
- /*%%%*/
$$ = NEW_BREAK(ret_args($2));
- /*%
- $$ = dispatch1(break, $2);
- %*/
}
- | keyword_next call_args
+ | kNEXT call_args
{
- /*%%%*/
$$ = NEW_NEXT(ret_args($2));
- /*%
- $$ = dispatch1(next, $2);
- %*/
}
;
block_command : block_call
| block_call '.' operation2 command_args
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- /*%
- $$ = dispatch3(call, $1, ripper_id2sym('.'), $3);
- $$ = method_arg($$, $4);
- %*/
+ $$ = new_call($1, $3, $4);
}
| block_call tCOLON2 operation2 command_args
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- /*%
- $$ = dispatch3(call, $1, ripper_intern("::"), $3);
- $$ = method_arg($$, $4);
- %*/
+ $$ = new_call($1, $3, $4);
}
;
cmd_brace_block : tLBRACE_ARG
{
- /*%%%*/
- dyna_push();
- $<num>$ = ruby_sourceline;
- /*%
- %*/
+ $<vars>$ = dyna_push();
+ $<num>1 = ruby_sourceline;
}
- opt_block_param
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt
'}'
{
- /*%%%*/
- $$ = NEW_ITER($3,$4);
- nd_set_line($$, $<num>2);
- dyna_pop();
- /*%
- $$ = dispatch2(brace_block, escape_Qundef($3), $4);
- %*/
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
+ nd_set_line($$, $<num>1);
+ dyna_pop($<vars>2);
}
;
command : operation command_args %prec tLOWEST
{
- /*%%%*/
- $$ = NEW_FCALL($1, $2);
- fixpos($$, $2);
- /*%
- $$ = dispatch2(command, $1, $2);
- %*/
- }
+ $$ = new_fcall($1, $2);
+ fixpos($$, $2);
+ }
| operation command_args cmd_brace_block
{
- /*%%%*/
- block_dup_check($2,$3);
- $3->nd_iter = NEW_FCALL($1, $2);
- $$ = $3;
- fixpos($$, $2);
- /*%
- $$ = dispatch2(command, $1, $2);
- $$ = method_add_block($$, $3);
- %*/
- }
+ $$ = new_fcall($1, $2);
+ if ($3) {
+ if (nd_type($$) == NODE_BLOCK_PASS) {
+ rb_compile_error("both block arg and actual block given");
+ }
+ $3->nd_iter = $$;
+ $$ = $3;
+ }
+ fixpos($$, $2);
+ }
| primary_value '.' operation2 command_args %prec tLOWEST
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- fixpos($$, $1);
- /*%
- $$ = dispatch4(command_call, $1, ripper_id2sym('.'), $3, $4);
- %*/
+ $$ = new_call($1, $3, $4);
+ fixpos($$, $1);
}
| primary_value '.' operation2 command_args cmd_brace_block
{
- /*%%%*/
- block_dup_check($4,$5);
- $5->nd_iter = NEW_CALL($1, $3, $4);
- $$ = $5;
- fixpos($$, $1);
- /*%
- $$ = dispatch4(command_call, $1, ripper_id2sym('.'), $3, $4);
- $$ = method_add_block($$, $5);
- %*/
+ $$ = new_call($1, $3, $4);
+ if ($5) {
+ if (nd_type($$) == NODE_BLOCK_PASS) {
+ rb_compile_error("both block arg and actual block given");
+ }
+ $5->nd_iter = $$;
+ $$ = $5;
+ }
+ fixpos($$, $1);
}
| primary_value tCOLON2 operation2 command_args %prec tLOWEST
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- fixpos($$, $1);
- /*%
- $$ = dispatch4(command_call, $1, ripper_intern("::"), $3, $4);
- %*/
+ $$ = new_call($1, $3, $4);
+ fixpos($$, $1);
}
| primary_value tCOLON2 operation2 command_args cmd_brace_block
{
- /*%%%*/
- block_dup_check($4,$5);
- $5->nd_iter = NEW_CALL($1, $3, $4);
- $$ = $5;
- fixpos($$, $1);
- /*%
- $$ = dispatch4(command_call, $1, ripper_intern("::"), $3, $4);
- $$ = method_add_block($$, $5);
- %*/
+ $$ = new_call($1, $3, $4);
+ if ($5) {
+ if (nd_type($$) == NODE_BLOCK_PASS) {
+ rb_compile_error("both block arg and actual block given");
+ }
+ $5->nd_iter = $$;
+ $$ = $5;
+ }
+ fixpos($$, $1);
}
- | keyword_super command_args
+ | kSUPER command_args
{
- /*%%%*/
- $$ = NEW_SUPER($2);
- fixpos($$, $2);
- /*%
- $$ = dispatch1(super, $2);
- %*/
+ $$ = new_super($2);
+ fixpos($$, $2);
}
- | keyword_yield command_args
+ | kYIELD command_args
{
- /*%%%*/
$$ = new_yield($2);
- fixpos($$, $2);
- /*%
- $$ = dispatch1(yield, $2);
- %*/
+ fixpos($$, $2);
}
;
mlhs : mlhs_basic
- | tLPAREN mlhs_inner rparen
+ | tLPAREN mlhs_entry ')'
{
- /*%%%*/
$$ = $2;
- /*%
- $$ = dispatch1(mlhs_paren, $2);
- %*/
}
;
-mlhs_inner : mlhs_basic
- | tLPAREN mlhs_inner rparen
+mlhs_entry : mlhs_basic
+ | tLPAREN mlhs_entry ')'
{
- /*%%%*/
$$ = NEW_MASGN(NEW_LIST($2), 0);
- /*%
- $$ = dispatch1(mlhs_paren, $2);
- %*/
}
;
mlhs_basic : mlhs_head
{
- /*%%%*/
$$ = NEW_MASGN($1, 0);
- /*%
- $$ = $1;
- %*/
}
| mlhs_head mlhs_item
{
- /*%%%*/
$$ = NEW_MASGN(list_append($1,$2), 0);
- /*%
- $$ = mlhs_add($1, $2);
- %*/
}
| mlhs_head tSTAR mlhs_node
{
- /*%%%*/
$$ = NEW_MASGN($1, $3);
- /*%
- $$ = mlhs_add_star($1, $3);
- %*/
- }
- | mlhs_head tSTAR mlhs_node ',' mlhs_post
- {
- /*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG($3,$5));
- /*%
- $$ = mlhs_add_star($1, $3);
- %*/
}
| mlhs_head tSTAR
{
- /*%%%*/
$$ = NEW_MASGN($1, -1);
- /*%
- $$ = mlhs_add_star($1, Qnil);
- %*/
- }
- | mlhs_head tSTAR ',' mlhs_post
- {
- /*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG(-1, $4));
- /*%
- $$ = mlhs_add_star($1, Qnil);
- %*/
}
| tSTAR mlhs_node
{
- /*%%%*/
$$ = NEW_MASGN(0, $2);
- /*%
- $$ = mlhs_add_star(mlhs_new(), $2);
- %*/
- }
- | tSTAR mlhs_node ',' mlhs_post
- {
- /*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG($2,$4));
- /*%
- $$ = mlhs_add_star(mlhs_new(), $2);
- %*/
}
| tSTAR
{
- /*%%%*/
$$ = NEW_MASGN(0, -1);
- /*%
- $$ = mlhs_add_star(mlhs_new(), Qnil);
- %*/
- }
- | tSTAR ',' mlhs_post
- {
- /*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG(-1, $3));
- /*%
- $$ = mlhs_add_star(mlhs_new(), Qnil);
- %*/
}
;
mlhs_item : mlhs_node
- | tLPAREN mlhs_inner rparen
+ | tLPAREN mlhs_entry ')'
{
- /*%%%*/
$$ = $2;
- /*%
- $$ = dispatch1(mlhs_paren, $2);
- %*/
}
;
mlhs_head : mlhs_item ','
{
- /*%%%*/
$$ = NEW_LIST($1);
- /*%
- $$ = mlhs_add(mlhs_new(), $1);
- %*/
}
| mlhs_head mlhs_item ','
{
- /*%%%*/
$$ = list_append($1, $2);
- /*%
- $$ = mlhs_add($1, $2);
- %*/
- }
- ;
-
-mlhs_post : mlhs_item
- {
- /*%%%*/
- $$ = NEW_LIST($1);
- /*%
- $$ = mlhs_add(mlhs_new(), $1);
- %*/
- }
- | mlhs_post ',' mlhs_item
- {
- /*%%%*/
- $$ = list_append($1, $3);
- /*%
- $$ = mlhs_add($1, $3);
- %*/
}
;
mlhs_node : variable
{
- /*%%%*/
$$ = assignable($1, 0);
- /*%
- $$ = $1;
- %*/
}
- | primary_value '[' opt_call_args rbracket
+ | primary_value '[' aref_args ']'
{
- /*%%%*/
$$ = aryset($1, $3);
- /*%
- $$ = dispatch2(aref_field, $1, escape_Qundef($3));
- %*/
}
| primary_value '.' tIDENTIFIER
{
- /*%%%*/
$$ = attrset($1, $3);
- /*%
- $$ = dispatch3(field, $1, ripper_id2sym('.'), $3);
- %*/
}
| primary_value tCOLON2 tIDENTIFIER
{
- /*%%%*/
$$ = attrset($1, $3);
- /*%
- $$ = dispatch2(const_path_field, $1, $3);
- %*/
}
| primary_value '.' tCONSTANT
{
- /*%%%*/
$$ = attrset($1, $3);
- /*%
- $$ = dispatch3(field, $1, ripper_id2sym('.'), $3);
- %*/
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
if (in_def || in_single)
yyerror("dynamic constant assignment");
$$ = NEW_CDECL(0, 0, NEW_COLON2($1, $3));
- /*%
- if (in_def || in_single)
- yyerror("dynamic constant assignment");
- $$ = dispatch2(const_path_field, $1, $3);
- %*/
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
if (in_def || in_single)
yyerror("dynamic constant assignment");
$$ = NEW_CDECL(0, 0, NEW_COLON3($2));
- /*%
- $$ = dispatch1(top_const_field, $2);
- %*/
}
| backref
{
- /*%%%*/
- rb_backref_error($1);
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch1(var_field, $1);
- $$ = dispatch1(assign_error, $$);
- %*/
+ rb_backref_error($1);
+ $$ = 0;
}
;
lhs : variable
{
- /*%%%*/
- if (!($$ = assignable($1, 0))) $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch1(var_field, $1);
- %*/
+ $$ = assignable($1, 0);
}
- | primary_value '[' opt_call_args rbracket
+ | primary_value '[' aref_args ']'
{
- /*%%%*/
$$ = aryset($1, $3);
- /*%
- $$ = dispatch2(aref_field, $1, escape_Qundef($3));
- %*/
}
| primary_value '.' tIDENTIFIER
{
- /*%%%*/
$$ = attrset($1, $3);
- /*%
- $$ = dispatch3(field, $1, ripper_id2sym('.'), $3);
- %*/
}
| primary_value tCOLON2 tIDENTIFIER
{
- /*%%%*/
$$ = attrset($1, $3);
- /*%
- $$ = dispatch3(field, $1, ripper_intern("::"), $3);
- %*/
}
| primary_value '.' tCONSTANT
{
- /*%%%*/
$$ = attrset($1, $3);
- /*%
- $$ = dispatch3(field, $1, ripper_id2sym('.'), $3);
- %*/
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
if (in_def || in_single)
yyerror("dynamic constant assignment");
$$ = NEW_CDECL(0, 0, NEW_COLON2($1, $3));
- /*%
- $$ = dispatch2(const_path_field, $1, $3);
- if (in_def || in_single) {
- $$ = dispatch1(assign_error, $$);
- }
- %*/
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
if (in_def || in_single)
yyerror("dynamic constant assignment");
$$ = NEW_CDECL(0, 0, NEW_COLON3($2));
- /*%
- $$ = dispatch1(top_const_field, $2);
- if (in_def || in_single) {
- $$ = dispatch1(assign_error, $$);
- }
- %*/
}
| backref
{
- /*%%%*/
- rb_backref_error($1);
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch1(assign_error, $1);
- %*/
+ rb_backref_error($1);
+ $$ = 0;
}
;
cname : tIDENTIFIER
{
- /*%%%*/
yyerror("class/module name must be CONSTANT");
- /*%
- $$ = dispatch1(class_name_error, $1);
- %*/
}
| tCONSTANT
;
cpath : tCOLON3 cname
{
- /*%%%*/
$$ = NEW_COLON3($2);
- /*%
- $$ = dispatch1(top_const_ref, $2);
- %*/
}
| cname
{
- /*%%%*/
$$ = NEW_COLON2(0, $$);
- /*%
- $$ = dispatch1(const_ref, $1);
- %*/
}
| primary_value tCOLON2 cname
{
- /*%%%*/
$$ = NEW_COLON2($1, $3);
- /*%
- $$ = dispatch2(const_path_ref, $1, $3);
- %*/
}
;
@@ -1680,23 +913,13 @@ fname : tIDENTIFIER
| tFID
| op
{
- /*%%%*/
- lex_state = EXPR_END;
- $$ = $1;
- /*%
lex_state = EXPR_END;
$$ = $1;
- %*/
}
| reswords
{
- /*%%%*/
lex_state = EXPR_END;
$$ = $<id>1;
- /*%
- lex_state = EXPR_END;
- $$ = $1;
- %*/
}
;
@@ -1706,98 +929,68 @@ fsym : fname
fitem : fsym
{
- /*%%%*/
$$ = NEW_LIT(ID2SYM($1));
- /*%
- $$ = dispatch1(symbol_literal, $1);
- %*/
}
| dsym
;
undef_list : fitem
{
- /*%%%*/
$$ = NEW_UNDEF($1);
- /*%
- $$ = rb_ary_new3(1, $1);
- %*/
}
| undef_list ',' {lex_state = EXPR_FNAME;} fitem
{
- /*%%%*/
$$ = block_append($1, NEW_UNDEF($4));
- /*%
- rb_ary_push($1, $4);
- %*/
}
;
-op : '|' { ifndef_ripper($$ = '|'); }
- | '^' { ifndef_ripper($$ = '^'); }
- | '&' { ifndef_ripper($$ = '&'); }
- | tCMP { ifndef_ripper($$ = tCMP); }
- | tEQ { ifndef_ripper($$ = tEQ); }
- | tEQQ { ifndef_ripper($$ = tEQQ); }
- | tMATCH { ifndef_ripper($$ = tMATCH); }
- | tNMATCH { ifndef_ripper($$ = tNMATCH); }
- | '>' { ifndef_ripper($$ = '>'); }
- | tGEQ { ifndef_ripper($$ = tGEQ); }
- | '<' { ifndef_ripper($$ = '<'); }
- | tLEQ { ifndef_ripper($$ = tLEQ); }
- | tNEQ { ifndef_ripper($$ = tNEQ); }
- | tLSHFT { ifndef_ripper($$ = tLSHFT); }
- | tRSHFT { ifndef_ripper($$ = tRSHFT); }
- | '+' { ifndef_ripper($$ = '+'); }
- | '-' { ifndef_ripper($$ = '-'); }
- | '*' { ifndef_ripper($$ = '*'); }
- | tSTAR { ifndef_ripper($$ = '*'); }
- | '/' { ifndef_ripper($$ = '/'); }
- | '%' { ifndef_ripper($$ = '%'); }
- | tPOW { ifndef_ripper($$ = tPOW); }
- | '!' { ifndef_ripper($$ = '!'); }
- | '~' { ifndef_ripper($$ = '~'); }
- | tUPLUS { ifndef_ripper($$ = tUPLUS); }
- | tUMINUS { ifndef_ripper($$ = tUMINUS); }
- | tAREF { ifndef_ripper($$ = tAREF); }
- | tASET { ifndef_ripper($$ = tASET); }
- | '`' { ifndef_ripper($$ = '`'); }
+op : '|' { $$ = '|'; }
+ | '^' { $$ = '^'; }
+ | '&' { $$ = '&'; }
+ | tCMP { $$ = tCMP; }
+ | tEQ { $$ = tEQ; }
+ | tEQQ { $$ = tEQQ; }
+ | tMATCH { $$ = tMATCH; }
+ | '>' { $$ = '>'; }
+ | tGEQ { $$ = tGEQ; }
+ | '<' { $$ = '<'; }
+ | tLEQ { $$ = tLEQ; }
+ | tLSHFT { $$ = tLSHFT; }
+ | tRSHFT { $$ = tRSHFT; }
+ | '+' { $$ = '+'; }
+ | '-' { $$ = '-'; }
+ | '*' { $$ = '*'; }
+ | tSTAR { $$ = '*'; }
+ | '/' { $$ = '/'; }
+ | '%' { $$ = '%'; }
+ | tPOW { $$ = tPOW; }
+ | '~' { $$ = '~'; }
+ | tUPLUS { $$ = tUPLUS; }
+ | tUMINUS { $$ = tUMINUS; }
+ | tAREF { $$ = tAREF; }
+ | tASET { $$ = tASET; }
+ | '`' { $$ = '`'; }
;
-reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
- | keyword_BEGIN | keyword_END
- | keyword_alias | keyword_and | keyword_begin
- | keyword_break | keyword_case | keyword_class | keyword_def
- | keyword_defined | keyword_do | keyword_else | keyword_elsif
- | keyword_end | keyword_ensure | keyword_false
- | keyword_for | keyword_in | keyword_module | keyword_next
- | keyword_nil | keyword_not | keyword_or | keyword_redo
- | keyword_rescue | keyword_retry | keyword_return | keyword_self
- | keyword_super | keyword_then | keyword_true | keyword_undef
- | keyword_when | keyword_yield | keyword_if | keyword_unless
- | keyword_while | keyword_until
+reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
+ | kALIAS | kAND | kBEGIN | kBREAK | kCASE | kCLASS | kDEF
+ | kDEFINED | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE
+ | kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT
+ | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
+ | kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD
+ | kIF | kUNLESS | kWHILE | kUNTIL
;
arg : lhs '=' arg
{
- /*%%%*/
- value_expr($3);
$$ = node_assign($1, $3);
- /*%
- $$ = dispatch2(assign, $1, $3);
- %*/
}
- | lhs '=' arg modifier_rescue arg
+ | lhs '=' arg kRESCUE_MOD arg
{
- /*%%%*/
$$ = node_assign($1, NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0));
- /*%
- $$ = dispatch2(assign, $1, dispatch2(rescue_mod,$3,$5));
- %*/
}
| var_lhs tOP_ASGN arg
{
- /*%%%*/
value_expr($3);
if ($1) {
ID vid = $1->nd_vid;
@@ -1814,20 +1007,16 @@ arg : lhs '=' arg
}
else {
$$ = $1;
- $$->nd_value = NEW_CALL(gettable(vid), $2, NEW_LIST($3));
+ $$->nd_value = call_op(gettable(vid),$2,1,$3);
}
}
else {
- $$ = NEW_BEGIN(0);
+ $$ = 0;
}
- /*%
- $$ = dispatch3(opassign, $1, $2, $3);
- %*/
}
- | primary_value '[' opt_call_args rbracket tOP_ASGN arg
+ | primary_value '[' aref_args ']' tOP_ASGN arg
{
- /*%%%*/
- NODE *args;
+ NODE *args;
value_expr($6);
if (!$3) $3 = NEW_ZARRAY();
@@ -1839,15 +1028,10 @@ arg : lhs '=' arg
$5 = 1;
}
$$ = NEW_OP_ASGN1($1, $5, args);
- fixpos($$, $1);
- /*%
- $1 = dispatch2(aref_field, $1, escape_Qundef($3));
- $$ = dispatch3(opassign, $1, $5, $6);
- %*/
+ fixpos($$, $1);
}
| primary_value '.' tIDENTIFIER tOP_ASGN arg
{
- /*%%%*/
value_expr($5);
if ($4 == tOROP) {
$4 = 0;
@@ -1856,15 +1040,10 @@ arg : lhs '=' arg
$4 = 1;
}
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
- fixpos($$, $1);
- /*%
- $1 = dispatch3(field, $1, ripper_id2sym('.'), $3);
- $$ = dispatch3(opassign, $1, $4, $5);
- %*/
+ fixpos($$, $1);
}
| primary_value '.' tCONSTANT tOP_ASGN arg
{
- /*%%%*/
value_expr($5);
if ($4 == tOROP) {
$4 = 0;
@@ -1873,15 +1052,10 @@ arg : lhs '=' arg
$4 = 1;
}
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
- fixpos($$, $1);
- /*%
- $1 = dispatch3(field, $1, ripper_id2sym('.'), $3);
- $$ = dispatch3(opassign, $1, $4, $5);
- %*/
+ fixpos($$, $1);
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
{
- /*%%%*/
value_expr($5);
if ($4 == tOROP) {
$4 = 0;
@@ -1890,335 +1064,173 @@ arg : lhs '=' arg
$4 = 1;
}
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
- fixpos($$, $1);
- /*%
- $1 = dispatch3(field, $1, ripper_intern("::"), $3);
- $$ = dispatch3(opassign, $1, $4, $5);
- %*/
+ fixpos($$, $1);
}
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg
{
- /*%%%*/
yyerror("constant re-assignment");
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch2(const_path_field, $1, $3);
- $$ = dispatch3(opassign, $$, $4, $5);
- $$ = dispatch1(assign_error, $$);
- %*/
+ $$ = 0;
}
| tCOLON3 tCONSTANT tOP_ASGN arg
{
- /*%%%*/
yyerror("constant re-assignment");
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch1(top_const_field, $2);
- $$ = dispatch3(opassign, $$, $3, $4);
- $$ = dispatch1(assign_error, $$);
- %*/
+ $$ = 0;
}
| backref tOP_ASGN arg
{
- /*%%%*/
- rb_backref_error($1);
- $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch1(var_field, $1);
- $$ = dispatch3(opassign, $$, $2, $3);
- $$ = dispatch1(assign_error, $$);
- %*/
+ rb_backref_error($1);
+ $$ = 0;
}
| arg tDOT2 arg
{
- /*%%%*/
value_expr($1);
value_expr($3);
+ $$ = NEW_DOT2($1, $3);
if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) {
- $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qfalse);
- $$ = $1;
- }
- else {
- $$ = NEW_DOT2($1, $3);
+ deferred_nodes = list_append(deferred_nodes, $$);
}
- /*%
- $$ = dispatch2(dot2, $1, $3);
- %*/
}
| arg tDOT3 arg
{
- /*%%%*/
value_expr($1);
value_expr($3);
+ $$ = NEW_DOT3($1, $3);
if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) {
- $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qtrue);
- $$ = $1;
+ deferred_nodes = list_append(deferred_nodes, $$);
}
- else {
- $$ = NEW_DOT3($1, $3);
- }
- /*%
- $$ = dispatch2(dot3, $1, $3);
- %*/
}
| arg '+' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '+', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('+'), $3);
- %*/
+ $$ = call_op($1, '+', 1, $3);
}
| arg '-' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '-', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('-'), $3);
- %*/
+ $$ = call_op($1, '-', 1, $3);
}
| arg '*' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '*', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('*'), $3);
- %*/
+ $$ = call_op($1, '*', 1, $3);
}
| arg '/' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '/', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('/'), $3);
- %*/
+ $$ = call_op($1, '/', 1, $3);
}
| arg '%' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '%', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('%'), $3);
- %*/
+ $$ = call_op($1, '%', 1, $3);
}
| arg tPOW arg
{
- /*%%%*/
- $$ = call_bin_op($1, tPOW, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("**"), $3);
- %*/
+ $$ = call_op($1, tPOW, 1, $3);
}
| tUMINUS_NUM tINTEGER tPOW arg
{
- /*%%%*/
- $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0);
- /*%
- $$ = dispatch3(binary, $2, ripper_intern("**"), $4);
- $$ = dispatch2(unary, ripper_intern("-@"), $$);
- %*/
+ $$ = call_op(call_op($2, tPOW, 1, $4), tUMINUS, 0, 0);
}
| tUMINUS_NUM tFLOAT tPOW arg
{
- /*%%%*/
- $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0);
- /*%
- $$ = dispatch3(binary, $2, ripper_intern("**"), $4);
- $$ = dispatch2(unary, ripper_intern("-@"), $$);
- %*/
+ $$ = call_op(call_op($2, tPOW, 1, $4), tUMINUS, 0, 0);
}
| tUPLUS arg
{
- /*%%%*/
- $$ = call_uni_op($2, tUPLUS);
- /*%
- $$ = dispatch2(unary, ripper_intern("+@"), $2);
- %*/
+ if ($2 && nd_type($2) == NODE_LIT) {
+ $$ = $2;
+ }
+ else {
+ $$ = call_op($2, tUPLUS, 0, 0);
+ }
}
| tUMINUS arg
{
- /*%%%*/
- $$ = call_uni_op($2, tUMINUS);
- /*%
- $$ = dispatch2(unary, ripper_intern("-@"), $2);
- %*/
+ $$ = call_op($2, tUMINUS, 0, 0);
}
| arg '|' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '|', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('|'), $3);
- %*/
+ $$ = call_op($1, '|', 1, $3);
}
| arg '^' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '^', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('^'), $3);
- %*/
+ $$ = call_op($1, '^', 1, $3);
}
| arg '&' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '&', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('&'), $3);
- %*/
+ $$ = call_op($1, '&', 1, $3);
}
| arg tCMP arg
{
- /*%%%*/
- $$ = call_bin_op($1, tCMP, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("<=>"), $3);
- %*/
+ $$ = call_op($1, tCMP, 1, $3);
}
| arg '>' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '>', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('>'), $3);
- %*/
+ $$ = call_op($1, '>', 1, $3);
}
| arg tGEQ arg
{
- /*%%%*/
- $$ = call_bin_op($1, tGEQ, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern(">="), $3);
- %*/
+ $$ = call_op($1, tGEQ, 1, $3);
}
| arg '<' arg
{
- /*%%%*/
- $$ = call_bin_op($1, '<', $3);
- /*%
- $$ = dispatch3(binary, $1, ID2SYM('<'), $3);
- %*/
+ $$ = call_op($1, '<', 1, $3);
}
| arg tLEQ arg
{
- /*%%%*/
- $$ = call_bin_op($1, tLEQ, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("<="), $3);
- %*/
+ $$ = call_op($1, tLEQ, 1, $3);
}
| arg tEQ arg
{
- /*%%%*/
- $$ = call_bin_op($1, tEQ, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("=="), $3);
- %*/
+ $$ = call_op($1, tEQ, 1, $3);
}
| arg tEQQ arg
{
- /*%%%*/
- $$ = call_bin_op($1, tEQQ, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("==="), $3);
- %*/
+ $$ = call_op($1, tEQQ, 1, $3);
}
| arg tNEQ arg
{
- /*%%%*/
- $$ = call_bin_op($1, tNEQ, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("!="), $3);
- %*/
+ $$ = NEW_NOT(call_op($1, tEQ, 1, $3));
}
| arg tMATCH arg
{
- /*%%%*/
- $$ = match_op($1, $3);
- if (nd_type($1) == NODE_LIT && TYPE($1->nd_lit) == T_REGEXP) {
- $$ = reg_named_capture_assign($1->nd_lit, $$);
- }
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("=~"), $3);
- %*/
+ $$ = match_gen($1, $3);
}
| arg tNMATCH arg
{
- /*%%%*/
- $$ = call_bin_op($1, tNMATCH, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("!~"), $3);
- %*/
+ $$ = NEW_NOT(match_gen($1, $3));
}
| '!' arg
{
- /*%%%*/
- $$ = call_uni_op(cond($2), '!');
- /*%
- $$ = dispatch2(unary, ID2SYM('!'), $2);
- %*/
+ $$ = NEW_NOT(cond($2));
}
| '~' arg
{
- /*%%%*/
- $$ = call_uni_op($2, '~');
- /*%
- $$ = dispatch2(unary, ID2SYM('~'), $2);
- %*/
+ $$ = call_op($2, '~', 0, 0);
}
| arg tLSHFT arg
{
- /*%%%*/
- $$ = call_bin_op($1, tLSHFT, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("<<"), $3);
- %*/
+ $$ = call_op($1, tLSHFT, 1, $3);
}
| arg tRSHFT arg
{
- /*%%%*/
- $$ = call_bin_op($1, tRSHFT, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern(">>"), $3);
- %*/
+ $$ = call_op($1, tRSHFT, 1, $3);
}
| arg tANDOP arg
{
- /*%%%*/
$$ = logop(NODE_AND, $1, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("&&"), $3);
- %*/
}
| arg tOROP arg
{
- /*%%%*/
$$ = logop(NODE_OR, $1, $3);
- /*%
- $$ = dispatch3(binary, $1, ripper_intern("||"), $3);
- %*/
}
- | keyword_defined opt_nl {in_defined = 1;} arg
+ | kDEFINED opt_nl {in_defined = 1;} arg
{
- /*%%%*/
- in_defined = 0;
+ in_defined = 0;
$$ = NEW_DEFINED($4);
- /*%
- in_defined = 0;
- $$ = dispatch1(defined, $4);
- %*/
}
- | arg '?' arg opt_nl ':' arg
+ | arg '?' arg ':' arg
{
- /*%%%*/
- value_expr($1);
- $$ = NEW_IF(cond($1), $3, $6);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(ifop, $1, $3, $6);
- %*/
+ $$ = NEW_IF(cond($1), $3, $5);
+ fixpos($$, $1);
}
| primary
{
@@ -2228,46 +1240,51 @@ arg : lhs '=' arg
arg_value : arg
{
- /*%%%*/
value_expr($1);
$$ = $1;
- if (!$$) $$ = NEW_NIL();
- /*%
- $$ = $1;
- %*/
}
;
aref_args : none
+ | command opt_nl
+ {
+ $$ = NEW_LIST($1);
+ }
| args trailer
{
$$ = $1;
}
- | args ',' assocs trailer
+ | args ',' tSTAR arg opt_nl
{
- /*%%%*/
- $$ = arg_append($1, NEW_HASH($3));
- /*%
- $$ = arg_add_assocs($1, $3);
- %*/
+ value_expr($4);
+ $$ = arg_concat($1, $4);
}
| assocs trailer
{
- /*%%%*/
$$ = NEW_LIST(NEW_HASH($1));
- /*%
- $$ = arg_add_assocs(arg_new(), $1);
- %*/
+ }
+ | tSTAR arg opt_nl
+ {
+ value_expr($2);
+ $$ = NEW_NEWLINE(NEW_SPLAT($2));
}
;
-paren_args : '(' opt_call_args rparen
+paren_args : '(' none ')'
+ {
+ $$ = $2;
+ }
+ | '(' call_args opt_nl ')'
{
- /*%%%*/
$$ = $2;
- /*%
- $$ = dispatch1(arg_paren, escape_Qundef($2));
- %*/
+ }
+ | '(' block_call opt_nl ')'
+ {
+ $$ = NEW_LIST($2);
+ }
+ | '(' args ',' block_call opt_nl ')'
+ {
+ $$ = list_append($2, $4);
}
;
@@ -2275,99 +1292,98 @@ opt_paren_args : none
| paren_args
;
-opt_call_args : none
- | call_args
- ;
-
call_args : command
{
- /*%%%*/
$$ = NEW_LIST($1);
- /*%
- $$ = arg_add(arg_new(), $1);
- %*/
}
| args opt_block_arg
{
- /*%%%*/
$$ = arg_blk_pass($1, $2);
- /*%
- $$ = arg_add_optblock($1, $2);
- %*/
+ }
+ | args ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat($1, $4);
+ $$ = arg_blk_pass($$, $5);
}
| assocs opt_block_arg
{
- /*%%%*/
$$ = NEW_LIST(NEW_HASH($1));
$$ = arg_blk_pass($$, $2);
- /*%
- $$ = arg_add_assocs(arg_new(), $1);
- $$ = arg_add_optblock($$, $2);
- %*/
+ }
+ | assocs ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat(NEW_LIST(NEW_HASH($1)), $4);
+ $$ = arg_blk_pass($$, $5);
}
| args ',' assocs opt_block_arg
{
- /*%%%*/
- $$ = arg_append($1, NEW_HASH($3));
+ $$ = list_append($1, NEW_HASH($3));
$$ = arg_blk_pass($$, $4);
- /*%
- $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
- %*/
}
- | block_arg
- /*%c%*/
- /*%c
+ | args ',' assocs ',' tSTAR arg opt_block_arg
{
- $$ = arg_add_block(arg_new(), $1);
+ value_expr($6);
+ $$ = arg_concat(list_append($1, NEW_HASH($3)), $6);
+ $$ = arg_blk_pass($$, $7);
}
- %*/
+ | tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_blk_pass(NEW_SPLAT($2), $3);
+ }
+ | block_arg
;
call_args2 : arg_value ',' args opt_block_arg
{
- /*%%%*/
$$ = arg_blk_pass(list_concat(NEW_LIST($1),$3), $4);
- /*%
- $$ = arg_add_optblock(arg_prepend($3, $1), $4);
- %*/
}
| arg_value ',' block_arg
{
- /*%%%*/
- $$ = arg_blk_pass(NEW_LIST($1), $3);
- /*%
- $$ = arg_add_block(arg_add(arg_new(), $1), $3);
- %*/
+ $$ = arg_blk_pass($1, $3);
+ }
+ | arg_value ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat(NEW_LIST($1), $4);
+ $$ = arg_blk_pass($$, $5);
+ }
+ | arg_value ',' args ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat(list_concat(NEW_LIST($1),$3), $6);
+ $$ = arg_blk_pass($$, $7);
}
| assocs opt_block_arg
{
- /*%%%*/
$$ = NEW_LIST(NEW_HASH($1));
$$ = arg_blk_pass($$, $2);
- /*%
- $$ = arg_add_assocs(arg_new(), $1);
- $$ = arg_add_optblock($$, $2);
- %*/
+ }
+ | assocs ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat(NEW_LIST(NEW_HASH($1)), $4);
+ $$ = arg_blk_pass($$, $5);
}
| arg_value ',' assocs opt_block_arg
{
- /*%%%*/
- $$ = arg_append(NEW_LIST($1), NEW_HASH($3));
+ $$ = list_append(NEW_LIST($1), NEW_HASH($3));
$$ = arg_blk_pass($$, $4);
- /*%
- $$ = arg_add_assocs(arg_add(arg_new(), $1), $3);
- $$ = arg_add_optblock($$, $4);
- %*/
}
| arg_value ',' args ',' assocs opt_block_arg
{
- /*%%%*/
- $$ = arg_append(list_concat(NEW_LIST($1),$3), NEW_HASH($5));
+ $$ = list_append(list_concat(NEW_LIST($1),$3), NEW_HASH($5));
$$ = arg_blk_pass($$, $6);
- /*%
- $$ = arg_add_assocs(arg_prepend($3, $1), $5);
- $$ = arg_add_optblock($$, $6);
- %*/
+ }
+ | arg_value ',' assocs ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat(list_append(NEW_LIST($1), NEW_HASH($3)), $6);
+ $$ = arg_blk_pass($$, $7);
+ }
+ | arg_value ',' args ',' assocs ',' tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_concat(list_append(list_concat(NEW_LIST($1), $3), NEW_HASH($5)), $8);
+ $$ = arg_blk_pass($$, $9);
+ }
+ | tSTAR arg_value opt_block_arg
+ {
+ $$ = arg_blk_pass(NEW_SPLAT($2), $3);
}
| block_arg
;
@@ -2379,39 +1395,27 @@ command_args : {
open_args
{
/* CMDARG_POP() */
- cmdarg_stack = $<num>1;
+ cmdarg_stack = $<num>1;
$$ = $2;
}
;
open_args : call_args
- | tLPAREN_ARG {lex_state = EXPR_ENDARG;} rparen
+ | tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')'
{
- /*%%%*/
- rb_warning0("don't put space before argument parentheses");
+ rb_warn("don't put space before argument parentheses");
$$ = 0;
- /*%
- $$ = dispatch1(space, dispatch1(arg_paren, arg_new()));
- %*/
}
- | tLPAREN_ARG call_args2 {lex_state = EXPR_ENDARG;} rparen
+ | tLPAREN_ARG call_args2 {lex_state = EXPR_ENDARG;} ')'
{
- /*%%%*/
- rb_warning0("don't put space before argument parentheses");
+ rb_warn("don't put space before argument parentheses");
$$ = $2;
- /*%
- $$ = dispatch1(space, dispatch1(arg_paren, $2));
- %*/
}
;
block_arg : tAMPER arg_value
{
- /*%%%*/
$$ = NEW_BLOCK_PASS($2);
- /*%
- $$ = $2;
- %*/
}
;
@@ -2420,68 +1424,29 @@ opt_block_arg : ',' block_arg
$$ = $2;
}
| none
- {
- $$ = 0;
- }
;
-args : arg_value
+args : arg_value
{
- /*%%%*/
$$ = NEW_LIST($1);
- /*%
- $$ = arg_add(arg_new(), $1);
- %*/
- }
- | tSTAR arg_value
- {
- /*%%%*/
- $$ = NEW_SPLAT($2);
- /*%
- $$ = arg_add_star(arg_new(), $2);
- %*/
}
| args ',' arg_value
{
- /*%%%*/
- $$ = arg_append($1, $3);
- /*%
- $$ = arg_add($1, $3);
- %*/
- }
- | args ',' tSTAR arg_value
- {
- /*%%%*/
- $$ = arg_concat($1, $4);
- /*%
- $$ = arg_add_star($1, $4);
- %*/
+ $$ = list_append($1, $3);
}
;
mrhs : args ',' arg_value
{
- /*%%%*/
- $$ = arg_append($1, $3);
- /*%
- $$ = mrhs_add(args2mrhs($1), $3);
- %*/
+ $$ = list_append($1, $3);
}
| args ',' tSTAR arg_value
{
- /*%%%*/
$$ = arg_concat($1, $4);
- /*%
- $$ = mrhs_add_star(args2mrhs($1), $4);
- %*/
}
| tSTAR arg_value
{
- /*%%%*/
$$ = NEW_SPLAT($2);
- /*%
- $$ = mrhs_add_star(mrhs_new(), $2);
- %*/
}
;
@@ -2495,992 +1460,497 @@ primary : literal
| backref
| tFID
{
- /*%%%*/
$$ = NEW_FCALL($1, 0);
- /*%
- $$ = method_arg(dispatch1(fcall, $1), arg_new());
- %*/
}
- | keyword_begin
+ | kBEGIN
{
- /*%%%*/
- $<num>$ = ruby_sourceline;
- /*%
- %*/
+ $<num>1 = ruby_sourceline;
}
bodystmt
- keyword_end
+ kEND
{
- /*%%%*/
- if ($3 == NULL) {
+ if ($3 == NULL)
$$ = NEW_NIL();
- }
- else {
- if (nd_type($3) == NODE_RESCUE ||
- nd_type($3) == NODE_ENSURE)
- nd_set_line($3, $<num>2);
+ else
$$ = NEW_BEGIN($3);
- }
- nd_set_line($$, $<num>2);
- /*%
- $$ = dispatch1(begin, $3);
- %*/
+ nd_set_line($$, $<num>1);
}
- | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
+ | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} opt_nl ')'
{
- rb_warning0("(...) interpreted as grouped expression");
- /*%%%*/
+ rb_warning("(...) interpreted as grouped expression");
$$ = $2;
- /*%
- $$ = dispatch1(paren, $2);
- %*/
}
| tLPAREN compstmt ')'
{
- /*%%%*/
- $$ = $2;
- /*%
- $$ = dispatch1(paren, $2);
- %*/
+ if (!$2) $$ = NEW_NIL();
+ else $$ = $2;
}
| primary_value tCOLON2 tCONSTANT
{
- /*%%%*/
$$ = NEW_COLON2($1, $3);
- /*%
- $$ = dispatch2(const_path_ref, $1, $3);
- %*/
}
| tCOLON3 tCONSTANT
{
- /*%%%*/
$$ = NEW_COLON3($2);
- /*%
- $$ = dispatch1(top_const_ref, $2);
- %*/
+ }
+ | primary_value '[' aref_args ']'
+ {
+ if ($1 && nd_type($1) == NODE_SELF)
+ $$ = NEW_FCALL(tAREF, $3);
+ else
+ $$ = NEW_CALL($1, tAREF, $3);
+ fixpos($$, $1);
}
| tLBRACK aref_args ']'
{
- /*%%%*/
- if ($2 == 0) {
+ if ($2 == 0) {
$$ = NEW_ZARRAY(); /* zero length array*/
}
else {
$$ = $2;
}
- /*%
- $$ = dispatch1(array, escape_Qundef($2));
- %*/
}
| tLBRACE assoc_list '}'
{
- /*%%%*/
$$ = NEW_HASH($2);
- /*%
- $$ = dispatch1(hash, escape_Qundef($2));
- %*/
}
- | keyword_return
+ | kRETURN
{
- /*%%%*/
$$ = NEW_RETURN(0);
- /*%
- $$ = dispatch0(return0);
- %*/
}
- | keyword_yield '(' call_args rparen
+ | kYIELD '(' call_args ')'
{
- /*%%%*/
$$ = new_yield($3);
- /*%
- $$ = dispatch1(yield, dispatch1(paren, $3));
- %*/
}
- | keyword_yield '(' rparen
+ | kYIELD '(' ')'
{
- /*%%%*/
$$ = NEW_YIELD(0, Qfalse);
- /*%
- $$ = dispatch1(yield, dispatch1(paren, arg_new()));
- %*/
}
- | keyword_yield
+ | kYIELD
{
- /*%%%*/
$$ = NEW_YIELD(0, Qfalse);
- /*%
- $$ = dispatch0(yield0);
- %*/
}
- | keyword_defined opt_nl '(' {in_defined = 1;} expr rparen
+ | kDEFINED opt_nl '(' {in_defined = 1;} expr ')'
{
- /*%%%*/
- in_defined = 0;
+ in_defined = 0;
$$ = NEW_DEFINED($5);
- /*%
- in_defined = 0;
- $$ = dispatch1(defined, $5);
- %*/
}
| operation brace_block
{
- /*%%%*/
$2->nd_iter = NEW_FCALL($1, 0);
$$ = $2;
fixpos($2->nd_iter, $2);
- /*%
- $$ = method_arg(dispatch1(fcall, $1), arg_new());
- $$ = method_add_block($$, $2);
- %*/
}
| method_call
| method_call brace_block
{
- /*%%%*/
- block_dup_check($1->nd_args, $2);
+ if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
+ rb_compile_error("both block arg and actual block given");
+ }
$2->nd_iter = $1;
$$ = $2;
- fixpos($$, $1);
- /*%
- $$ = method_add_block($1, $2);
- %*/
+ fixpos($$, $1);
}
- | tLAMBDA lambda
- {
- $$ = $2;
- }
- | keyword_if expr_value then
+ | kIF expr_value then
compstmt
if_tail
- keyword_end
+ kEND
{
- /*%%%*/
$$ = NEW_IF(cond($2), $4, $5);
- fixpos($$, $2);
- /*%
- $$ = dispatch3(if, $2, $4, escape_Qundef($5));
- %*/
+ fixpos($$, $2);
+ if (cond_negative(&$$->nd_cond)) {
+ NODE *tmp = $$->nd_body;
+ $$->nd_body = $$->nd_else;
+ $$->nd_else = tmp;
+ }
}
- | keyword_unless expr_value then
+ | kUNLESS expr_value then
compstmt
opt_else
- keyword_end
+ kEND
{
- /*%%%*/
$$ = NEW_UNLESS(cond($2), $4, $5);
- fixpos($$, $2);
- /*%
- $$ = dispatch3(unless, $2, $4, escape_Qundef($5));
- %*/
+ fixpos($$, $2);
+ if (cond_negative(&$$->nd_cond)) {
+ NODE *tmp = $$->nd_body;
+ $$->nd_body = $$->nd_else;
+ $$->nd_else = tmp;
+ }
}
- | keyword_while {COND_PUSH(1);} expr_value do {COND_POP();}
+ | kWHILE {COND_PUSH(1);} expr_value do {COND_POP();}
compstmt
- keyword_end
+ kEND
{
- /*%%%*/
$$ = NEW_WHILE(cond($3), $6, 1);
- fixpos($$, $3);
- /*%
- $$ = dispatch2(while, $3, $6);
- %*/
+ fixpos($$, $3);
+ if (cond_negative(&$$->nd_cond)) {
+ nd_set_type($$, NODE_UNTIL);
+ }
}
- | keyword_until {COND_PUSH(1);} expr_value do {COND_POP();}
+ | kUNTIL {COND_PUSH(1);} expr_value do {COND_POP();}
compstmt
- keyword_end
+ kEND
{
- /*%%%*/
$$ = NEW_UNTIL(cond($3), $6, 1);
- fixpos($$, $3);
- /*%
- $$ = dispatch2(until, $3, $6);
- %*/
+ fixpos($$, $3);
+ if (cond_negative(&$$->nd_cond)) {
+ nd_set_type($$, NODE_WHILE);
+ }
}
- | keyword_case expr_value opt_terms
+ | kCASE expr_value opt_terms
case_body
- keyword_end
+ kEND
{
- /*%%%*/
$$ = NEW_CASE($2, $4);
- fixpos($$, $2);
- /*%
- $$ = dispatch2(case, $2, $4);
- %*/
- }
- | keyword_case opt_terms case_body keyword_end
- {
- /*%%%*/
- $$ = NEW_CASE(0, $3);
- /*%
- $$ = dispatch2(case, Qnil, $3);
- %*/
- }
- | keyword_for for_var keyword_in
- {COND_PUSH(1);}
- expr_value do
- {COND_POP();}
+ fixpos($$, $2);
+ }
+ | kCASE opt_terms case_body kEND
+ {
+ $$ = $3;
+ }
+ | kCASE opt_terms kELSE compstmt kEND
+ {
+ $$ = $4;
+ }
+ | kFOR for_var kIN {COND_PUSH(1);} expr_value do {COND_POP();}
compstmt
- keyword_end
- {
- /*%%%*/
- /*
- * for a, b, c in e
- * #=>
- * e.each{|*x| a, b, c = x
- *
- * for a in e
- * #=>
- * e.each{|x| a, = x}
- */
- ID id = internal_id();
- ID *tbl = ALLOC_N(ID, 2);
- NODE *m = NEW_ARGS_AUX(0, 0);
- NODE *args, *scope;
-
- if (nd_type($2) == NODE_MASGN) {
- /* if args.length == 1 && args[0].kind_of?(Array)
- * args = args[0]
- * end
- */
- NODE *one = NEW_LIST(NEW_LIT(INT2FIX(1)));
- NODE *zero = NEW_LIST(NEW_LIT(INT2FIX(0)));
- m->nd_next = block_append(
- NEW_IF(
- NEW_NODE(NODE_AND,
- NEW_CALL(NEW_CALL(NEW_DVAR(id), rb_intern("length"), 0),
- rb_intern("=="), one),
- NEW_CALL(NEW_CALL(NEW_DVAR(id), rb_intern("[]"), zero),
- rb_intern("kind_of?"), NEW_LIST(NEW_LIT(rb_cArray))),
- 0),
- NEW_DASGN_CURR(id,
- NEW_CALL(NEW_DVAR(id), rb_intern("[]"), zero)),
- 0),
- node_assign($2, NEW_DVAR(id)));
- }
- else {
- m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id));
- }
-
- args = new_args(m, 0, id, 0, 0);
- scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
- tbl[0] = 1; tbl[1] = id;
- $$ = NEW_FOR(0, $5, scope);
- fixpos($$, $2);
- /*%
- $$ = dispatch3(for, $2, $5, $8);
- %*/
+ kEND
+ {
+ $$ = NEW_FOR($2, $5, $8);
+ fixpos($$, $2);
}
- | keyword_class cpath superclass
+ | kCLASS cpath superclass
{
if (in_def || in_single)
yyerror("class definition in method body");
- /*%%%*/
+ class_nest++;
local_push(0);
- $<num>$ = ruby_sourceline;
- /*%
- %*/
+ $<num>$ = ruby_sourceline;
}
bodystmt
- keyword_end
+ kEND
{
- /*%%%*/
- $$ = NEW_CLASS($2, $5, $3);
- nd_set_line($$, $<num>4);
- local_pop();
- /*%
- $$ = dispatch3(class, $2, $3, $5);
- %*/
+ $$ = NEW_CLASS($2, $5, $3);
+ nd_set_line($$, $<num>4);
+ local_pop();
+ class_nest--;
}
- | keyword_class tLSHFT expr
+ | kCLASS tLSHFT expr
{
- /*%%%*/
$<num>$ = in_def;
- in_def = 0;
- /*%
- in_def = 0;
- %*/
+ in_def = 0;
}
term
{
- /*%%%*/
- $<num>$ = in_single;
- in_single = 0;
+ $<num>$ = in_single;
+ in_single = 0;
+ class_nest++;
local_push(0);
- /*%
- $$ = in_single;
- in_single = 0;
- %*/
}
bodystmt
- keyword_end
- {
- /*%%%*/
- $$ = NEW_SCLASS($3, $7);
- fixpos($$, $3);
- local_pop();
- in_def = $<num>4;
- in_single = $<num>6;
- /*%
- $$ = dispatch2(sclass, $3, $7);
- in_def = $<val>4;
- in_single = $<val>6;
- %*/
- }
- | keyword_module cpath
+ kEND
+ {
+ $$ = NEW_SCLASS($3, $7);
+ fixpos($$, $3);
+ local_pop();
+ class_nest--;
+ in_def = $<num>4;
+ in_single = $<num>6;
+ }
+ | kMODULE cpath
{
if (in_def || in_single)
yyerror("module definition in method body");
- /*%%%*/
+ class_nest++;
local_push(0);
- $<num>$ = ruby_sourceline;
- /*%
- %*/
+ $<num>$ = ruby_sourceline;
}
bodystmt
- keyword_end
+ kEND
{
- /*%%%*/
- $$ = NEW_MODULE($2, $4);
- nd_set_line($$, $<num>3);
- local_pop();
- /*%
- $$ = dispatch2(module, $2, $4);
- %*/
+ $$ = NEW_MODULE($2, $4);
+ nd_set_line($$, $<num>3);
+ local_pop();
+ class_nest--;
}
- | keyword_def fname
+ | kDEF fname
{
$<id>$ = cur_mid;
cur_mid = $2;
in_def++;
- /*%%%*/
local_push(0);
- /*%
- %*/
}
f_arglist
bodystmt
- keyword_end
- {
- /*%%%*/
- NODE *body = remove_begin($5);
- reduce_nodes(&body);
- $$ = NEW_DEFN($2, $4, body, NOEX_PRIVATE);
- fixpos($$, $4);
- local_pop();
- in_def--;
- cur_mid = $<id>3;
- /*%
- $$ = dispatch3(def, $2, $4, $5);
+ kEND
+ {
+ if (!$5) $5 = NEW_NIL();
+ $$ = NEW_DEFN($2, $4, $5, NOEX_PRIVATE);
+ fixpos($$, $4);
+ local_pop();
in_def--;
cur_mid = $<id>3;
- %*/
}
- | keyword_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
+ | kDEF singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
{
in_single++;
- lex_state = EXPR_END; /* force for args */
- /*%%%*/
local_push(0);
- /*%
- %*/
+ lex_state = EXPR_END; /* force for args */
}
f_arglist
bodystmt
- keyword_end
- {
- /*%%%*/
- NODE *body = remove_begin($8);
- reduce_nodes(&body);
- $$ = NEW_DEFS($2, $5, $7, body);
- fixpos($$, $2);
- local_pop();
- in_single--;
- /*%
- $$ = dispatch5(defs, $2, $3, $5, $7, $8);
+ kEND
+ {
+ $$ = NEW_DEFS($2, $5, $7, $8);
+ fixpos($$, $2);
+ local_pop();
in_single--;
- %*/
}
- | keyword_break
+ | kBREAK
{
- /*%%%*/
$$ = NEW_BREAK(0);
- /*%
- $$ = dispatch1(break, arg_new());
- %*/
}
- | keyword_next
+ | kNEXT
{
- /*%%%*/
$$ = NEW_NEXT(0);
- /*%
- $$ = dispatch1(next, arg_new());
- %*/
}
- | keyword_redo
+ | kREDO
{
- /*%%%*/
$$ = NEW_REDO();
- /*%
- $$ = dispatch0(redo);
- %*/
}
- | keyword_retry
+ | kRETRY
{
- /*%%%*/
$$ = NEW_RETRY();
- /*%
- $$ = dispatch0(retry);
- %*/
}
;
-primary_value : primary
+primary_value : primary
{
- /*%%%*/
value_expr($1);
$$ = $1;
- if (!$$) $$ = NEW_NIL();
- /*%
- $$ = $1;
- %*/
}
;
then : term
- /*%c%*/
- /*%c
- { $$ = Qnil; }
- %*/
- | keyword_then
- | term keyword_then
- /*%c%*/
- /*%c
- { $$ = $2; }
- %*/
+ | ':'
+ | kTHEN
+ | term kTHEN
;
do : term
- /*%c%*/
- /*%c
- { $$ = Qnil; }
- %*/
- | keyword_do_cond
+ | ':'
+ | kDO_COND
;
if_tail : opt_else
- | keyword_elsif expr_value then
+ | kELSIF expr_value then
compstmt
if_tail
{
- /*%%%*/
$$ = NEW_IF(cond($2), $4, $5);
- fixpos($$, $2);
- /*%
- $$ = dispatch3(elsif, $2, $4, escape_Qundef($5));
- %*/
+ fixpos($$, $2);
}
;
opt_else : none
- | keyword_else compstmt
+ | kELSE compstmt
{
- /*%%%*/
$$ = $2;
- /*%
- $$ = dispatch1(else, $2);
- %*/
}
;
-for_var : lhs
+for_var : lhs
| mlhs
;
-f_marg : f_norm_arg
+block_par : mlhs_item
{
- /*%%%*/
- $$ = assignable($1, 0);
- /*%
- $$ = dispatch1(mlhs_paren, $1);
- %*/
- }
- | tLPAREN f_margs rparen
- {
- /*%%%*/
- $$ = $2;
- /*%
- $$ = dispatch1(mlhs_paren, $2);
- %*/
- }
- ;
-
-f_marg_list : f_marg
- {
- /*%%%*/
$$ = NEW_LIST($1);
- /*%
- $$ = mlhs_add(mlhs_new(), $1);
- %*/
}
- | f_marg_list ',' f_marg
+ | block_par ',' mlhs_item
{
- /*%%%*/
$$ = list_append($1, $3);
- /*%
- $$ = mlhs_add($1, $3);
- %*/
}
;
-f_margs : f_marg_list
- {
- /*%%%*/
- $$ = NEW_MASGN($1, 0);
- /*%
- $$ = $1;
- %*/
- }
- | f_marg_list ',' tSTAR f_norm_arg
- {
- /*%%%*/
- $$ = NEW_MASGN($1, assignable($4, 0));
- /*%
- $$ = mlhs_add_star($1, $4);
- %*/
- }
- | f_marg_list ',' tSTAR f_norm_arg ',' f_marg_list
- {
- /*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG(assignable($4, 0), $6));
- /*%
- $$ = mlhs_add_star($1, $4);
- %*/
- }
- | f_marg_list ',' tSTAR
- {
- /*%%%*/
- $$ = NEW_MASGN($1, -1);
- /*%
- $$ = mlhs_add_star($1, Qnil);
- %*/
- }
- | f_marg_list ',' tSTAR ',' f_marg_list
+block_var : block_par
{
- /*%%%*/
- $$ = NEW_MASGN($1, NEW_POSTARG(-1, $5));
- /*%
- $$ = mlhs_add_star($1, $5);
- %*/
+ if ($1->nd_alen == 1) {
+ $$ = $1->nd_head;
+ rb_gc_force_recycle((VALUE)$1);
+ }
+ else {
+ $$ = NEW_MASGN($1, 0);
+ }
}
- | tSTAR f_norm_arg
+ | block_par ','
{
- /*%%%*/
- $$ = NEW_MASGN(0, assignable($2, 0));
- /*%
- $$ = mlhs_add_star(mlhs_new(), $2);
- %*/
+ $$ = NEW_MASGN($1, 0);
}
- | tSTAR f_norm_arg ',' f_marg_list
+ | block_par ',' tAMPER lhs
{
- /*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG(assignable($2, 0), $4));
- /*%
- #if 0
- TODO: Check me
- #endif
- $$ = mlhs_add_star($2, $4);
- %*/
+ $$ = NEW_BLOCK_VAR($4, NEW_MASGN($1, 0));
}
- | tSTAR
+ | block_par ',' tSTAR lhs ',' tAMPER lhs
{
- /*%%%*/
- $$ = NEW_MASGN(0, -1);
- /*%
- $$ = mlhs_add_star(mlhs_new(), Qnil);
- %*/
+ $$ = NEW_BLOCK_VAR($7, NEW_MASGN($1, $4));
}
- | tSTAR ',' f_marg_list
+ | block_par ',' tSTAR ',' tAMPER lhs
{
- /*%%%*/
- $$ = NEW_MASGN(0, NEW_POSTARG(-1, $3));
- /*%
- $$ = mlhs_add_star(mlhs_new(), Qnil);
- %*/
+ $$ = NEW_BLOCK_VAR($6, NEW_MASGN($1, -1));
}
- ;
-
-block_param : f_arg ',' f_rest_arg opt_f_block_arg
+ | block_par ',' tSTAR lhs
{
- /*%%%*/
- $$ = new_args($1, 0, $3, 0, $4);
- /*%
- $$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4));
- %*/
+ $$ = NEW_MASGN($1, $4);
}
- | f_arg ','
+ | block_par ',' tSTAR
{
- /*%%%*/
- $$ = new_args($1, 0, 1, 0, 0);
- /*%
- $$ = params_new($1, Qnil, Qnil, Qnil, Qnil);
- dispatch1(excessed_comma, $$);
- %*/
+ $$ = NEW_MASGN($1, -1);
}
- | f_arg ',' f_rest_arg ',' f_arg opt_f_block_arg
+ | tSTAR lhs ',' tAMPER lhs
{
- /*%%%*/
- $$ = new_args($1, 0, $3, $5, $6);
- /*%
- $$ = params_new($1, Qnil, $3, $5, escape_Qundef($6));
- %*/
+ $$ = NEW_BLOCK_VAR($5, NEW_MASGN(0, $2));
}
- | f_arg opt_f_block_arg
+ | tSTAR ',' tAMPER lhs
{
- /*%%%*/
- $$ = new_args($1, 0, 0, 0, $2);
- /*%
- $$ = params_new($1, Qnil,Qnil, Qnil, escape_Qundef($2));
- %*/
+ $$ = NEW_BLOCK_VAR($4, NEW_MASGN(0, -1));
}
- | f_rest_arg opt_f_block_arg
+ | tSTAR lhs
{
- /*%%%*/
- $$ = new_args(0, 0, $1, 0, $2);
- /*%
- $$ = params_new(Qnil, Qnil, $1, Qnil, escape_Qundef($2));
- %*/
+ $$ = NEW_MASGN(0, $2);
}
- | f_rest_arg ',' f_arg opt_f_block_arg
+ | tSTAR
{
- /*%%%*/
- $$ = new_args(0, 0, $1, $3, $4);
- /*%
- $$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4));
- %*/
+ $$ = NEW_MASGN(0, -1);
}
- | f_block_arg
+ | tAMPER lhs
{
- /*%%%*/
- $$ = new_args(0, 0, 0, 0, $1);
- /*%
- $$ = params_new(Qnil, Qnil, Qnil, Qnil, $1);
- %*/
+ $$ = NEW_BLOCK_VAR($2, (NODE*)1);
}
;
-opt_block_param : none
- | block_param_def
- ;
-
-block_param_def : '|' opt_bv_decl '|'
+opt_block_var : none
+ | '|' /* none */ '|'
{
- /*%%%*/
- $$ = 0;
- /*%
- $$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil),
- escape_Qundef($2));
- %*/
+ $$ = (NODE*)1;
+ command_start = Qtrue;
}
| tOROP
{
- /*%%%*/
- $$ = 0;
- /*%
- $$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil),
- Qnil);
- %*/
- }
- | '|' block_param opt_bv_decl '|'
- {
- /*%%%*/
- $$ = $2;
- /*%
- $$ = blockvar_new(escape_Qundef($2), escape_Qundef($3));
- %*/
- }
- ;
-
-
-opt_bv_decl : none
- | ';' bv_decls
- {
- /*%%%*/
- $$ = 0;
- /*%
- $$ = $2;
- %*/
- }
- ;
-
-bv_decls : bvar
- /*%c%*/
- /*%c
- {
- $$ = rb_ary_new2($1);
- }
- %*/
- | bv_decls ',' bvar
- /*%c%*/
- /*%c
- {
- rb_ary_push($$, $3);
- }
- %*/
- ;
-
-bvar : tIDENTIFIER
- {
- /*%%%*/
- new_bv($1);
- /*%
- $$ = $1;
- %*/
- }
- | f_bad_arg
- {
- $$ = 0;
- }
- ;
-
-lambda : {
- /*%%%*/
- dyna_push();
- $<num>$ = lpar_beg;
- lpar_beg = ++paren_nest;
- /*%
- %*/
- }
- f_larglist
- lambda_body
- {
- /*%%%*/
- $$ = $2;
- $$->nd_body = NEW_SCOPE($2->nd_head, $3);
- dyna_pop();
- lpar_beg = $<num>1;
- /*%
- $$ = dispatch2(lambda, $2, $3);
- %*/
- }
- ;
-
-f_larglist : '(' f_args opt_bv_decl rparen
- {
- /*%%%*/
- $$ = NEW_LAMBDA($2);
- /*%
- $$ = dispatch1(paren, $2);
- %*/
- }
- | f_args opt_bv_decl
- {
- /*%%%*/
- $$ = NEW_LAMBDA($1);
- /*%
- $$ = $1;
- %*/
- }
- ;
-
-lambda_body : tLAMBEG compstmt '}'
- {
- $$ = $2;
+ $$ = (NODE*)1;
+ command_start = Qtrue;
}
- | keyword_do_LAMBDA compstmt keyword_end
+ | '|' block_var '|'
{
$$ = $2;
+ command_start = Qtrue;
}
;
-do_block : keyword_do_block
+do_block : kDO_BLOCK
{
- /*%%%*/
- dyna_push();
- $<num>$ = ruby_sourceline;
- /*% %*/
+ $<vars>$ = dyna_push();
+ $<num>1 = ruby_sourceline;
}
- opt_block_param
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt
- keyword_end
+ kEND
{
- /*%%%*/
- $$ = NEW_ITER($3,$4);
- nd_set_line($$, $<num>2);
- dyna_pop();
- /*%
- $$ = dispatch2(do_block, escape_Qundef($3), $4);
- %*/
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
+ nd_set_line($$, $<num>1);
+ dyna_pop($<vars>2);
}
;
block_call : command do_block
{
- /*%%%*/
- block_dup_check($1->nd_args, $2);
+ if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
+ rb_compile_error("both block arg and actual block given");
+ }
$2->nd_iter = $1;
$$ = $2;
- fixpos($$, $1);
- /*%
- $$ = method_add_block($1, $2);
- %*/
+ fixpos($$, $1);
}
| block_call '.' operation2 opt_paren_args
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- /*%
- $$ = dispatch3(call, $1, ripper_id2sym('.'), $3);
- $$ = method_optarg($$, $4);
- %*/
+ $$ = new_call($1, $3, $4);
}
| block_call tCOLON2 operation2 opt_paren_args
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- /*%
- $$ = dispatch3(call, $1, ripper_intern("::"), $3);
- $$ = method_optarg($$, $4);
- %*/
+ $$ = new_call($1, $3, $4);
}
;
method_call : operation paren_args
{
- /*%%%*/
- $$ = NEW_FCALL($1, $2);
- fixpos($$, $2);
- /*%
- $$ = method_arg(dispatch1(fcall, $1), $2);
- %*/
+ $$ = new_fcall($1, $2);
+ fixpos($$, $2);
}
| primary_value '.' operation2 opt_paren_args
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(call, $1, ripper_id2sym('.'), $3);
- $$ = method_optarg($$, $4);
- %*/
+ $$ = new_call($1, $3, $4);
+ fixpos($$, $1);
}
| primary_value tCOLON2 operation2 paren_args
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, $4);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(call, $1, ripper_id2sym('.'), $3);
- $$ = method_optarg($$, $4);
- %*/
+ $$ = new_call($1, $3, $4);
+ fixpos($$, $1);
}
| primary_value tCOLON2 operation3
{
- /*%%%*/
- $$ = NEW_CALL($1, $3, 0);
- /*%
- $$ = dispatch3(call, $1, ripper_intern("::"), $3);
- %*/
- }
- | primary_value '.' paren_args
- {
- /*%%%*/
- $$ = NEW_CALL($1, rb_intern("call"), $3);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(call, dispatch1(paren, $1),
- ripper_id2sym('.'), rb_intern("call"));
- $$ = method_optarg($$, $3);
- %*/
- }
- | primary_value tCOLON2 paren_args
- {
- /*%%%*/
- $$ = NEW_CALL($1, rb_intern("call"), $3);
- fixpos($$, $1);
- /*%
- $$ = dispatch3(call, dispatch1(paren, $1),
- ripper_id2sym('.'), rb_intern("call"));
- $$ = method_optarg($$, $3);
- %*/
+ $$ = new_call($1, $3, 0);
}
- | keyword_super paren_args
+ | kSUPER paren_args
{
- /*%%%*/
- $$ = NEW_SUPER($2);
- /*%
- $$ = dispatch1(super, $2);
- %*/
+ $$ = new_super($2);
}
- | keyword_super
+ | kSUPER
{
- /*%%%*/
$$ = NEW_ZSUPER();
- /*%
- $$ = dispatch0(zsuper);
- %*/
- }
- | primary_value '[' opt_call_args rbracket
- {
- /*%%%*/
- if ($1 && nd_type($1) == NODE_SELF)
- $$ = NEW_FCALL(tAREF, $3);
- else
- $$ = NEW_CALL($1, tAREF, $3);
- fixpos($$, $1);
- /*%
- $$ = dispatch2(aref, $1, escape_Qundef($3));
- %*/
}
;
brace_block : '{'
{
- /*%%%*/
- dyna_push();
- $<num>$ = ruby_sourceline;
- /*%
- %*/
+ $<vars>$ = dyna_push();
+ $<num>1 = ruby_sourceline;
}
- opt_block_param
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt '}'
{
- /*%%%*/
- $$ = NEW_ITER($3,$4);
- nd_set_line($$, $<num>2);
- dyna_pop();
- /*%
- $$ = dispatch2(brace_block, escape_Qundef($3), $4);
- %*/
- }
- | keyword_do
- {
- /*%%%*/
- dyna_push();
- $<num>$ = ruby_sourceline;
- /*%
- %*/
- }
- opt_block_param
- compstmt keyword_end
- {
- /*%%%*/
- $$ = NEW_ITER($3,$4);
- nd_set_line($$, $<num>2);
- dyna_pop();
- /*%
- $$ = dispatch2(do_block, escape_Qundef($3), $4);
- %*/
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
+ nd_set_line($$, $<num>1);
+ dyna_pop($<vars>2);
+ }
+ | kDO
+ {
+ $<vars>$ = dyna_push();
+ $<num>1 = ruby_sourceline;
+ }
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
+ compstmt kEND
+ {
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
+ nd_set_line($$, $<num>1);
+ dyna_pop($<vars>2);
}
;
-case_body : keyword_when args then
+case_body : kWHEN when_args then
compstmt
cases
{
- /*%%%*/
$$ = NEW_WHEN($2, $4, $5);
- /*%
- $$ = dispatch3(when, $2, $4, escape_Qundef($5));
- %*/
+ }
+ ;
+when_args : args
+ | args ',' tSTAR arg_value
+ {
+ $$ = list_append($1, NEW_WHEN($4, 0, 0));
+ }
+ | tSTAR arg_value
+ {
+ $$ = NEW_LIST(NEW_WHEN($2, 0, 0));
}
;
@@ -3488,35 +1958,23 @@ cases : opt_else
| case_body
;
-opt_rescue : keyword_rescue exc_list exc_var then
+opt_rescue : kRESCUE exc_list exc_var then
compstmt
opt_rescue
{
- /*%%%*/
- if ($3) {
- $3 = node_assign($3, NEW_ERRINFO());
+ if ($3) {
+ $3 = node_assign($3, NEW_GVAR(rb_intern("$!")));
$5 = block_append($3, $5);
}
$$ = NEW_RESBODY($2, $5, $6);
- fixpos($$, $2?$2:$5);
- /*%
- $$ = dispatch4(rescue,
- escape_Qundef($2),
- escape_Qundef($3),
- escape_Qundef($5),
- escape_Qundef($6));
- %*/
+ fixpos($$, $2?$2:$5);
}
| none
;
exc_list : arg_value
{
- /*%%%*/
$$ = NEW_LIST($1);
- /*%
- $$ = rb_ary_new3(1, $1);
- %*/
}
| mrhs
| none
@@ -3529,13 +1987,13 @@ exc_var : tASSOC lhs
| none
;
-opt_ensure : keyword_ensure compstmt
+opt_ensure : kENSURE compstmt
{
- /*%%%*/
- $$ = $2;
- /*%
- $$ = dispatch1(ensure, $2);
- %*/
+ if ($2)
+ $$ = $2;
+ else
+ /* place holder */
+ $$ = NEW_NIL();
}
| none
;
@@ -3543,60 +2001,42 @@ opt_ensure : keyword_ensure compstmt
literal : numeric
| symbol
{
- /*%%%*/
$$ = NEW_LIT(ID2SYM($1));
- /*%
- $$ = dispatch1(symbol_literal, $1);
- %*/
}
| dsym
;
strings : string
{
- /*%%%*/
NODE *node = $1;
if (!node) {
- node = NEW_STR(STR_NEW0());
+ node = NEW_STR(rb_str_new(0, 0));
}
else {
node = evstr2dstr(node);
}
$$ = node;
- /*%
- $$ = $1;
- %*/
}
;
-string : tCHAR
- | string1
+string : string1
| string string1
{
- /*%%%*/
$$ = literal_concat($1, $2);
- /*%
- $$ = dispatch2(string_concat, $1, $2);
- %*/
}
;
string1 : tSTRING_BEG string_contents tSTRING_END
{
- /*%%%*/
$$ = $2;
- /*%
- $$ = dispatch1(string_literal, $2);
- %*/
}
;
xstring : tXSTRING_BEG xstring_contents tSTRING_END
{
- /*%%%*/
NODE *node = $2;
if (!node) {
- node = NEW_XSTR(STR_NEW0());
+ node = NEW_XSTR(rb_str_new(0, 0));
}
else {
switch (nd_type(node)) {
@@ -3607,36 +2047,33 @@ xstring : tXSTRING_BEG xstring_contents tSTRING_END
nd_set_type(node, NODE_DXSTR);
break;
default:
- node = NEW_NODE(NODE_DXSTR, STR_NEW0(), 1, NEW_LIST(node));
+ node = NEW_NODE(NODE_DXSTR, rb_str_new(0, 0), 1, NEW_LIST(node));
break;
}
}
$$ = node;
- /*%
- $$ = dispatch1(xstring_literal, $2);
- %*/
}
;
regexp : tREGEXP_BEG xstring_contents tREGEXP_END
{
- /*%%%*/
int options = $3;
NODE *node = $2;
- NODE *list;
if (!node) {
- node = NEW_LIT(reg_compile(STR_NEW0(), options));
+ node = NEW_LIT(rb_reg_new("", 0, options & ~RE_OPTION_ONCE));
}
else switch (nd_type(node)) {
case NODE_STR:
{
VALUE src = node->nd_lit;
nd_set_type(node, NODE_LIT);
- node->nd_lit = reg_compile(src, options);
+ node->nd_lit = rb_reg_new(RSTRING(src)->ptr,
+ RSTRING(src)->len,
+ options & ~RE_OPTION_ONCE);
}
break;
default:
- node = NEW_NODE(NODE_DSTR, STR_NEW0(), 1, NEW_LIST(node));
+ node = NEW_NODE(NODE_DSTR, rb_str_new(0, 0), 1, NEW_LIST(node));
case NODE_DSTR:
if (options & RE_OPTION_ONCE) {
nd_set_type(node, NODE_DREGX_ONCE);
@@ -3644,29 +2081,16 @@ regexp : tREGEXP_BEG xstring_contents tREGEXP_END
else {
nd_set_type(node, NODE_DREGX);
}
- node->nd_cflag = options & RE_OPTION_MASK;
- reg_fragment_check(node->nd_lit, options);
- for (list = node->nd_next; list; list = list->nd_next) {
- if (nd_type(list->nd_head) == NODE_STR) {
- reg_fragment_check(list->nd_head->nd_lit, options);
- }
- }
+ node->nd_cflag = options & ~RE_OPTION_ONCE;
break;
}
$$ = node;
- /*%
- $$ = dispatch2(regexp_literal, $2, $3);
- %*/
}
;
words : tWORDS_BEG ' ' tSTRING_END
{
- /*%%%*/
$$ = NEW_ZARRAY();
- /*%
- $$ = dispatch0(words_new);
- %*/
}
| tWORDS_BEG word_list tSTRING_END
{
@@ -3676,47 +2100,24 @@ words : tWORDS_BEG ' ' tSTRING_END
word_list : /* none */
{
- /*%%%*/
$$ = 0;
- /*%
- $$ = dispatch0(words_new);
- %*/
}
| word_list word ' '
{
- /*%%%*/
$$ = list_append($1, evstr2dstr($2));
- /*%
- $$ = dispatch2(words_add, $1, $2);
- %*/
}
;
word : string_content
- /*%c%*/
- /*%c
- {
- $$ = dispatch0(word_new);
- $$ = dispatch2(word_add, $$, $1);
- }
- %*/
| word string_content
{
- /*%%%*/
$$ = literal_concat($1, $2);
- /*%
- $$ = dispatch2(word_add, $1, $2);
- %*/
}
;
qwords : tQWORDS_BEG ' ' tSTRING_END
{
- /*%%%*/
$$ = NEW_ZARRAY();
- /*%
- $$ = dispatch0(qwords_new);
- %*/
}
| tQWORDS_BEG qword_list tSTRING_END
{
@@ -3726,55 +2127,31 @@ qwords : tQWORDS_BEG ' ' tSTRING_END
qword_list : /* none */
{
- /*%%%*/
$$ = 0;
- /*%
- $$ = dispatch0(qwords_new);
- %*/
}
| qword_list tSTRING_CONTENT ' '
{
- /*%%%*/
$$ = list_append($1, $2);
- /*%
- $$ = dispatch2(qwords_add, $1, $2);
- %*/
}
;
string_contents : /* none */
{
- /*%%%*/
$$ = 0;
- /*%
- $$ = dispatch0(string_content);
- %*/
}
| string_contents string_content
{
- /*%%%*/
$$ = literal_concat($1, $2);
- /*%
- $$ = dispatch2(string_add, $1, $2);
- %*/
}
;
xstring_contents: /* none */
{
- /*%%%*/
$$ = 0;
- /*%
- $$ = dispatch0(xstring_new);
- %*/
}
| xstring_contents string_content
{
- /*%%%*/
$$ = literal_concat($1, $2);
- /*%
- $$ = dispatch2(xstring_add, $1, $2);
- %*/
}
;
@@ -3787,13 +2164,8 @@ string_content : tSTRING_CONTENT
}
string_dvar
{
- /*%%%*/
- lex_strterm = $<node>2;
- $$ = NEW_EVSTR($3);
- /*%
lex_strterm = $<node>2;
- $$ = dispatch1(string_dvar, $3);
- %*/
+ $$ = NEW_EVSTR($3);
}
| tSTRING_DBEG
{
@@ -3808,51 +2180,24 @@ string_content : tSTRING_CONTENT
lex_strterm = $<node>2;
COND_LEXPOP();
CMDARG_LEXPOP();
- /*%%%*/
- if ($3) $3->flags &= ~NODE_NEWLINE;
- $$ = new_evstr($3);
- /*%
- $$ = dispatch1(string_embexpr, $3);
- %*/
+ if (($$ = $3) && nd_type($$) == NODE_NEWLINE) {
+ $$ = $$->nd_next;
+ rb_gc_force_recycle((VALUE)$3);
+ }
+ $$ = new_evstr($$);
}
;
-string_dvar : tGVAR
- {
- /*%%%*/
- $$ = NEW_GVAR($1);
- /*%
- $$ = dispatch1(var_ref, $1);
- %*/
- }
- | tIVAR
- {
- /*%%%*/
- $$ = NEW_IVAR($1);
- /*%
- $$ = dispatch1(var_ref, $1);
- %*/
- }
- | tCVAR
- {
- /*%%%*/
- $$ = NEW_CVAR($1);
- /*%
- $$ = dispatch1(var_ref, $1);
- %*/
- }
+string_dvar : tGVAR {$$ = NEW_GVAR($1);}
+ | tIVAR {$$ = NEW_IVAR($1);}
+ | tCVAR {$$ = NEW_CVAR($1);}
| backref
;
symbol : tSYMBEG sym
{
- /*%%%*/
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
$$ = $2;
- /*%
- lex_state = EXPR_ENDARG;
- $$ = dispatch1(symbol, $2);
- %*/
}
;
@@ -3864,8 +2209,7 @@ sym : fname
dsym : tSYMBEG xstring_contents tSTRING_END
{
- /*%%%*/
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
if (!($$ = $2)) {
$$ = NEW_NIL();
yyerror("empty symbol literal");
@@ -3879,42 +2223,33 @@ dsym : tSYMBEG xstring_contents tSTRING_END
break;
case NODE_STR:
lit = $$->nd_lit;
- if (RSTRING_LEN(lit) == 0) {
+ if (RSTRING(lit)->len == 0) {
yyerror("empty symbol literal");
break;
}
- $$->nd_lit = ID2SYM(rb_intern_str(lit));
- nd_set_type($$, NODE_LIT);
- break;
+ if (strlen(RSTRING(lit)->ptr) == RSTRING(lit)->len) {
+ $$->nd_lit = ID2SYM(rb_intern(RSTRING($$->nd_lit)->ptr));
+ nd_set_type($$, NODE_LIT);
+ break;
+ }
+ /* fall through */
default:
- $$ = NEW_NODE(NODE_DSYM, STR_NEW0(), 1, NEW_LIST($$));
+ $$ = NEW_NODE(NODE_DSYM, rb_str_new(0, 0), 1, NEW_LIST($$));
break;
}
}
- /*%
- lex_state = EXPR_ENDARG;
- $$ = dispatch1(dyna_symbol, $2);
- %*/
}
;
-numeric : tINTEGER
+numeric : tINTEGER
| tFLOAT
| tUMINUS_NUM tINTEGER %prec tLOWEST
{
- /*%%%*/
$$ = negate_lit($2);
- /*%
- $$ = dispatch2(unary, ripper_intern("-@"), $2);
- %*/
}
| tUMINUS_NUM tFLOAT %prec tLOWEST
{
- /*%%%*/
$$ = negate_lit($2);
- /*%
- $$ = dispatch2(unary, ripper_intern("-@"), $2);
- %*/
}
;
@@ -3923,32 +2258,23 @@ variable : tIDENTIFIER
| tGVAR
| tCONSTANT
| tCVAR
- | keyword_nil {ifndef_ripper($$ = keyword_nil);}
- | keyword_self {ifndef_ripper($$ = keyword_self);}
- | keyword_true {ifndef_ripper($$ = keyword_true);}
- | keyword_false {ifndef_ripper($$ = keyword_false);}
- | keyword__FILE__ {ifndef_ripper($$ = keyword__FILE__);}
- | keyword__LINE__ {ifndef_ripper($$ = keyword__LINE__);}
- | keyword__ENCODING__ {ifndef_ripper($$ = keyword__ENCODING__);}
+ | kNIL {$$ = kNIL;}
+ | kSELF {$$ = kSELF;}
+ | kTRUE {$$ = kTRUE;}
+ | kFALSE {$$ = kFALSE;}
+ | k__FILE__ {$$ = k__FILE__;}
+ | k__LINE__ {$$ = k__LINE__;}
;
var_ref : variable
{
- /*%%%*/
- if (!($$ = gettable($1))) $$ = NEW_BEGIN(0);
- /*%
- $$ = dispatch1(var_ref, $1);
- %*/
+ $$ = gettable($1);
}
;
var_lhs : variable
{
- /*%%%*/
$$ = assignable($1, 0);
- /*%
- $$ = dispatch1(var_field, $1);
- %*/
}
;
@@ -3958,11 +2284,7 @@ backref : tNTH_REF
superclass : term
{
- /*%%%*/
$$ = 0;
- /*%
- $$ = Qnil;
- %*/
}
| '<'
{
@@ -3972,29 +2294,14 @@ superclass : term
{
$$ = $3;
}
- | error term
- {
- /*%%%*/
- yyerrok;
- $$ = 0;
- /*%
- yyerrok;
- $$ = Qnil;
- %*/
- }
+ | error term {yyerrok; $$ = 0;}
;
-f_arglist : '(' f_args rparen
+f_arglist : '(' f_args opt_nl ')'
{
- /*%%%*/
$$ = $2;
lex_state = EXPR_BEG;
- command_start = Qtrue;
- /*%
- $$ = dispatch1(paren, $2);
- lex_state = EXPR_BEG;
- command_start = Qtrue;
- %*/
+ command_start = Qtrue;
}
| f_args term
{
@@ -4004,259 +2311,94 @@ f_arglist : '(' f_args rparen
f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args($1, $3, $5, 0, $6);
- /*%
- $$ = params_new($1, $3, $5, Qnil, escape_Qundef($6));
- %*/
- }
- | f_arg ',' f_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
- {
- /*%%%*/
- $$ = new_args($1, $3, $5, $7, $8);
- /*%
- $$ = params_new($1, $3, $5, $7, escape_Qundef($8));
- %*/
+ $$ = block_append(NEW_ARGS($1, $3, $5), $6);
}
| f_arg ',' f_optarg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args($1, $3, 0, 0, $4);
- /*%
- $$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4));
- %*/
- }
- | f_arg ',' f_optarg ',' f_arg opt_f_block_arg
- {
- /*%%%*/
- $$ = new_args($1, $3, 0, $5, $6);
- /*%
- $$ = params_new($1, $3, Qnil, $5, escape_Qundef($6));
- %*/
+ $$ = block_append(NEW_ARGS($1, $3, 0), $4);
}
| f_arg ',' f_rest_arg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args($1, 0, $3, 0, $4);
- /*%
- $$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4));
- %*/
- }
- | f_arg ',' f_rest_arg ',' f_arg opt_f_block_arg
- {
- /*%%%*/
- $$ = new_args($1, 0, $3, $5, $6);
- /*%
- $$ = params_new($1, Qnil, $3, $5, escape_Qundef($6));
- %*/
+ $$ = block_append(NEW_ARGS($1, 0, $3), $4);
}
| f_arg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args($1, 0, 0, 0, $2);
- /*%
- $$ = params_new($1, Qnil, Qnil, Qnil,escape_Qundef($2));
- %*/
+ $$ = block_append(NEW_ARGS($1, 0, 0), $2);
}
| f_optarg ',' f_rest_arg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args(0, $1, $3, 0, $4);
- /*%
- $$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4));
- %*/
- }
- | f_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
- {
- /*%%%*/
- $$ = new_args(0, $1, $3, $5, $6);
- /*%
- $$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6));
- %*/
+ $$ = block_append(NEW_ARGS(0, $1, $3), $4);
}
| f_optarg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args(0, $1, 0, 0, $2);
- /*%
- $$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2));
- %*/
- }
- | f_optarg ',' f_arg opt_f_block_arg
- {
- /*%%%*/
- $$ = new_args(0, $1, 0, $3, $4);
- /*%
- $$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4));
- %*/
+ $$ = block_append(NEW_ARGS(0, $1, 0), $2);
}
| f_rest_arg opt_f_block_arg
{
- /*%%%*/
- $$ = new_args(0, 0, $1, 0, $2);
- /*%
- $$ = params_new(Qnil, Qnil, $1, Qnil,escape_Qundef($2));
- %*/
- }
- | f_rest_arg ',' f_arg opt_f_block_arg
- {
- /*%%%*/
- $$ = new_args(0, 0, $1, $3, $4);
- /*%
- $$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4));
- %*/
+ $$ = block_append(NEW_ARGS(0, 0, $1), $2);
}
| f_block_arg
{
- /*%%%*/
- $$ = new_args(0, 0, 0, 0, $1);
- /*%
- $$ = params_new(Qnil, Qnil, Qnil, Qnil, $1);
- %*/
+ $$ = block_append(NEW_ARGS(0, 0, 0), $1);
}
| /* none */
{
- /*%%%*/
- $$ = new_args(0, 0, 0, 0, 0);
- /*%
- $$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil);
- %*/
+ $$ = NEW_ARGS(0, 0, 0);
}
;
-f_bad_arg : tCONSTANT
+f_norm_arg : tCONSTANT
{
- /*%%%*/
yyerror("formal argument cannot be a constant");
- $$ = 0;
- /*%
- $$ = dispatch1(param_error, $1);
- %*/
}
- | tIVAR
+ | tIVAR
{
- /*%%%*/
- yyerror("formal argument cannot be an instance variable");
- $$ = 0;
- /*%
- $$ = dispatch1(param_error, $1);
- %*/
+ yyerror("formal argument cannot be an instance variable");
}
- | tGVAR
+ | tGVAR
{
- /*%%%*/
- yyerror("formal argument cannot be a global variable");
- $$ = 0;
- /*%
- $$ = dispatch1(param_error, $1);
- %*/
+ yyerror("formal argument cannot be a global variable");
}
- | tCVAR
+ | tCVAR
{
- /*%%%*/
- yyerror("formal argument cannot be a class variable");
- $$ = 0;
- /*%
- $$ = dispatch1(param_error, $1);
- %*/
+ yyerror("formal argument cannot be a class variable");
}
- ;
-
-f_norm_arg : f_bad_arg
| tIDENTIFIER
{
- /*%%%*/
if (!is_local_id($1))
yyerror("formal argument must be local variable");
- shadowing_lvar($1);
- /*%
- %*/
- $$ = $1;
- }
- ;
-
-f_arg_item : f_norm_arg
- {
- /*%%%*/
- arg_var($1);
- $$ = NEW_ARGS_AUX($1, 1);
- /*%
- %*/
- }
- | tLPAREN f_margs rparen
- {
- /*%%%*/
- ID tid = internal_id();
- arg_var(tid);
- if (dyna_in_block()) {
- $2->nd_value = NEW_DVAR(tid);
- }
- else {
- $2->nd_value = NEW_LVAR(tid);
- }
- $$ = NEW_ARGS_AUX(tid, 1);
- $$->nd_next = $2;
- /*%
- $$ = dispatch1(mlhs_paren, $2);
- %*/
+ else if (local_id($1))
+ yyerror("duplicate argument name");
+ local_cnt($1);
+ $$ = 1;
}
;
-f_arg : f_arg_item
- /*%c%*/
- /*%c
+f_arg : f_norm_arg
+ | f_arg ',' f_norm_arg
{
- $$ = rb_ary_new3(1, $1);
- }
- c%*/
- | f_arg ',' f_arg_item
- {
- /*%%%*/
- $$ = $1;
- $$->nd_plen++;
- $$->nd_next = block_append($$->nd_next, $3->nd_next);
- rb_gc_force_recycle((VALUE)$3);
- /*%
- $$ = rb_ary_push($1, $3);
- %*/
+ $$ += 1;
}
;
f_opt : tIDENTIFIER '=' arg_value
{
- /*%%%*/
if (!is_local_id($1))
yyerror("formal argument must be local variable");
- shadowing_lvar($1);
- arg_var($1);
- $$ = NEW_OPT_ARG(0, assignable($1, $3));
- /*%
- $$ = rb_assoc_new($1, $3);
- %*/
+ else if (local_id($1))
+ yyerror("duplicate optional argument name");
+ $$ = assignable($1, $3);
}
;
f_optarg : f_opt
{
- /*%%%*/
- $$ = $1;
- /*%
- $$ = rb_ary_new3(1, $1);
- %*/
+ $$ = NEW_BLOCK($1);
+ $$->nd_end = $$;
}
| f_optarg ',' f_opt
{
- /*%%%*/
- NODE *opts = $1;
-
- while (opts->nd_next) {
- opts = opts->nd_next;
- }
- opts->nd_next = $3;
- $$ = $1;
- /*%
- $$ = rb_ary_push($1, $3);
- %*/
+ $$ = block_append($1, $3);
}
;
@@ -4266,24 +2408,23 @@ restarg_mark : '*'
f_rest_arg : restarg_mark tIDENTIFIER
{
- /*%%%*/
if (!is_local_id($2))
yyerror("rest argument must be local variable");
- shadowing_lvar($2);
- arg_var($2);
- $$ = $2;
- /*%
- $$ = dispatch1(rest_param, $2);
- %*/
+ else if (local_id($2))
+ yyerror("duplicate rest argument name");
+ if (dyna_in_block()) {
+ rb_dvar_push($2, Qnil);
+ }
+ $$ = assignable($2, 0);
}
| restarg_mark
{
- /*%%%*/
- $$ = internal_id();
- arg_var($$);
- /*%
- $$ = dispatch1(rest_param, Qnil);
- %*/
+ if (dyna_in_block()) {
+ $$ = NEW_DASGN_CURR(internal_id(), 0);
+ }
+ else {
+ $$ = NEW_NODE(NODE_LASGN,0,0,local_append(0));
+ }
}
;
@@ -4293,17 +2434,11 @@ blkarg_mark : '&'
f_block_arg : blkarg_mark tIDENTIFIER
{
- /*%%%*/
if (!is_local_id($2))
yyerror("block argument must be local variable");
- else if (!dyna_in_block() && local_id($2))
- yyerror("duplicated block argument name");
- shadowing_lvar($2);
- arg_var($2);
- $$ = $2;
- /*%
- $$ = dispatch1(blockarg, $2);
- %*/
+ else if (local_id($2))
+ yyerror("duplicate block argument name");
+ $$ = NEW_BLOCK_ARG($2);
}
;
@@ -4312,28 +2447,15 @@ opt_f_block_arg : ',' f_block_arg
$$ = $2;
}
| none
- {
- /*%%%*/
- $$ = 0;
- /*%
- $$ = Qundef;
- %*/
- }
;
singleton : var_ref
{
- /*%%%*/
- value_expr($1);
- $$ = $1;
- if (!$$) $$ = NEW_NIL();
- /*%
$$ = $1;
- %*/
+ value_expr($$);
}
- | '(' {lex_state = EXPR_BEG;} expr rparen
+ | '(' {lex_state = EXPR_BEG;} expr opt_nl ')'
{
- /*%%%*/
if ($3 == 0) {
yyerror("can't define singleton method for ().");
}
@@ -4354,55 +2476,33 @@ singleton : var_ref
}
}
$$ = $3;
- /*%
- $$ = dispatch1(paren, $3);
- %*/
}
;
assoc_list : none
| assocs trailer
{
- /*%%%*/
$$ = $1;
- /*%
- $$ = dispatch1(assoclist_from_args, $1);
- %*/
+ }
+ | args trailer
+ {
+ if ($1->nd_alen%2 != 0) {
+ yyerror("odd number list for Hash");
+ }
+ $$ = $1;
}
;
assocs : assoc
- /*%c%*/
- /*%c
- {
- $$ = rb_ary_new3(1, $1);
- }
- %*/
| assocs ',' assoc
{
- /*%%%*/
$$ = list_concat($1, $3);
- /*%
- $$ = rb_ary_push($1, $3);
- %*/
}
;
assoc : arg_value tASSOC arg_value
{
- /*%%%*/
$$ = list_append(NEW_LIST($1), $3);
- /*%
- $$ = dispatch2(assoc_new, $1, $3);
- %*/
- }
- | tLABEL arg_value
- {
- /*%%%*/
- $$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
- /*%
- $$ = dispatch2(assoc_new, $1, $2);
- %*/
}
;
@@ -4423,15 +2523,7 @@ operation3 : tIDENTIFIER
;
dot_or_colon : '.'
- /*%c%*/
- /*%c
- { $$ = $<val>1; }
- %*/
| tCOLON2
- /*%c%*/
- /*%c
- { $$ = $<val>1; }
- %*/
;
opt_terms : /* none */
@@ -4442,12 +2534,6 @@ opt_nl : /* none */
| '\n'
;
-rparen : opt_nl ')'
- ;
-
-rbracket : opt_nl ']'
- ;
-
trailer : /* none */
| '\n'
| ','
@@ -4461,99 +2547,15 @@ terms : term
| terms ';' {yyerrok;}
;
-none : /* none */
- {
- /*%%%*/
- $$ = 0;
- /*%
- $$ = Qundef;
- %*/
- }
+none : /* none */ {$$ = 0;}
;
%%
-# undef parser
-# undef yylex
-# undef yylval
-# define yylval (*((YYSTYPE*)(parser->parser_yylval)))
-
-static int parser_regx_options(struct parser_params*);
-static int parser_tokadd_string(struct parser_params*,int,int,int,long*,rb_encoding**);
-static void parser_tokaddmbc(struct parser_params *parser, int c, rb_encoding *enc);
-static int parser_parse_string(struct parser_params*,NODE*);
-static int parser_here_document(struct parser_params*,NODE*);
-
-
-# define nextc() parser_nextc(parser)
-# define pushback(c) parser_pushback(parser, c)
-# define newtok() parser_newtok(parser)
-# define tokspace(n) parser_tokspace(parser, n)
-# define tokadd(c) parser_tokadd(parser, c)
-# define tok_hex(numlen) parser_tok_hex(parser, numlen)
-# define read_escape(flags,e) parser_read_escape(parser, flags, e)
-# define tokadd_escape(t,e) parser_tokadd_escape(parser, t, e)
-# define regx_options() parser_regx_options(parser)
-# define tokadd_string(f,t,p,n,e) parser_tokadd_string(parser,f,t,p,n,e)
-# define parse_string(n) parser_parse_string(parser,n)
-# define tokaddmbc(c, enc) parser_tokaddmbc(parser, c, enc)
-# define here_document(n) parser_here_document(parser,n)
-# define heredoc_identifier() parser_heredoc_identifier(parser)
-# define heredoc_restore(n) parser_heredoc_restore(parser,n)
-# define whole_match_p(e,l,i) parser_whole_match_p(parser,e,l,i)
-
-#ifdef RIPPER
-/* FIXME */
-# define local_id(x) 1
-# define dyna_in_block() 1
-#endif /* RIPPER */
-
-#ifndef RIPPER
-# define set_yylval_str(x) yylval.node = NEW_STR(x)
-# define set_yylval_num(x) yylval.num = x
-# define set_yylval_id(x) yylval.id = x
-# define set_yylval_literal(x) yylval.node = NEW_LIT(x)
-# define set_yylval_node(x) yylval.node = x
-# define yylval_id() yylval.id
-#else
-# define set_yylval_str(x) (void)(x)
-# define set_yylval_num(x) (void)(x)
-# define set_yylval_id(x) (void)(x)
-# define set_yylval_literal(x) (void)(x)
-# define set_yylval_node(x) (void)(x)
-# define yylval_id() SYM2ID(yylval.val)
+#ifdef yystacksize
+#undef YYMALLOC
#endif
-#ifdef RIPPER
-#define ripper_flush(p) (p->tokp = p->parser_lex_p)
-
-static void
-ripper_dispatch_scan_event(struct parser_params *parser, int t)
-{
- VALUE str;
-
- if (lex_p < parser->tokp) rb_raise(rb_eRuntimeError, "lex_p < tokp");
- if (lex_p == parser->tokp) return;
- str = STR_NEW(parser->tokp, lex_p - parser->tokp);
- yylval.val = ripper_dispatch1(parser, ripper_token2eventid(t), str);
- ripper_flush(parser);
-}
-
-static void
-ripper_dispatch_delayed_token(struct parser_params *parser, int t)
-{
- int saved_line = ruby_sourceline;
- const char *saved_tokp = parser->tokp;
-
- ruby_sourceline = parser->delayed_line;
- parser->tokp = lex_pbeg + parser->delayed_col;
- yylval.val = ripper_dispatch1(parser, ripper_token2eventid(t), parser->delayed);
- parser->delayed = Qnil;
- ruby_sourceline = saved_line;
- parser->tokp = saved_tokp;
-}
-#endif /* RIPPER */
-
-#include "ruby/regex.h"
-#include "ruby/util.h"
+#include "regex.h"
+#include "util.h"
/* We remove any previous definition of `SIGN_EXTEND_CHAR',
since ours (we hope) works properly with all combinations of
@@ -4566,24 +2568,30 @@ ripper_dispatch_delayed_token(struct parser_params *parser, int t)
/* As in Harbison and Steele. */
# define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
#endif
+#define is_identchar(c) (SIGN_EXTEND_CHAR(c)!=-1&&(ISALNUM(c) || (c) == '_' || ismbchar(c)))
-#define parser_mbclen() mbclen((lex_p-1),lex_pend,parser->enc)
-#define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,parser->enc)
-#define is_identchar(p,e,enc) (rb_enc_isalnum(*p,enc) || (*p) == '_' || !ISASCII(*p))
-#define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,parser->enc))
+static char *tokenbuf = NULL;
+static int tokidx, toksiz = 0;
-#define parser_isascii() ISASCII(*(lex_p-1))
+#define LEAVE_BS 1
+
+static VALUE (*lex_gets)(); /* gets function */
+static VALUE lex_input; /* non-nil if File */
+static VALUE lex_lastline; /* gc protect */
+static char *lex_pbeg;
+static char *lex_p;
+static char *lex_pend;
static int
-parser_yyerror(struct parser_params *parser, const char *msg)
+yyerror(msg)
+ const char *msg;
{
-#ifndef RIPPER
const int max_line_margin = 30;
const char *p, *pe;
char *buf;
int len, i;
- compile_error(PARSER_ARG "%s", msg);
+ rb_compile_error("%s", msg);
p = lex_p;
while (lex_pbeg <= p) {
if (*p == '\n') break;
@@ -4603,12 +2611,13 @@ parser_yyerror(struct parser_params *parser, const char *msg)
const char *pre = "", *post = "";
if (len > max_line_margin * 2 + 10) {
- if (lex_p - p > max_line_margin) {
- p = rb_enc_prev_char(p, lex_p - max_line_margin, rb_enc_get(lex_lastline));
+ int re_mbc_startpos _((const char *, int, int, int));
+ if ((len = lex_p - p) > max_line_margin) {
+ p = p + re_mbc_startpos(p, len, len - max_line_margin, 0);
pre = "...";
}
- if (pe - lex_p > max_line_margin) {
- pe = rb_enc_prev_char(lex_p, lex_p + max_line_margin, rb_enc_get(lex_lastline));
+ if ((len = pe - lex_p) > max_line_margin) {
+ pe = lex_p + re_mbc_startpos(lex_p, len, max_line_margin, 1);
post = "...";
}
len = pe - p;
@@ -4627,277 +2636,178 @@ parser_yyerror(struct parser_params *parser, const char *msg)
}
buf[i] = '^';
buf[i+1] = '\0';
- rb_compile_error_append("%s%s", pre, buf);
+ rb_compile_error_append("%s", buf);
}
-#else
- dispatch1(parse_error, STR_NEW2(msg));
-#endif /* !RIPPER */
+
return 0;
}
-static void parser_prepare(struct parser_params *parser);
+static int heredoc_end;
-#ifndef RIPPER
-VALUE ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always);
+int ruby_in_compile = 0;
+int ruby__end__seen;
-static VALUE
-debug_lines(const char *f)
-{
- if (rb_const_defined_at(rb_cObject, rb_intern("SCRIPT_LINES__"))) {
- VALUE hash = rb_const_get_at(rb_cObject, rb_intern("SCRIPT_LINES__"));
- if (TYPE(hash) == T_HASH) {
- VALUE fname = rb_str_new2(f);
- VALUE lines = rb_hash_lookup(hash, fname);
- if (NIL_P(lines)) {
- lines = rb_ary_new();
- rb_hash_aset(hash, fname, lines);
- }
- return lines;
- }
- }
- return 0;
-}
+static VALUE ruby_debug_lines;
+#ifdef YYMALLOC
+static NODE *parser_heap;
+#endif
-static VALUE
-yycompile0(VALUE arg, int tracing)
+static NODE*
+yycompile(f, line)
+ char *f;
+ int line;
{
int n;
- NODE *tree;
- struct parser_params *parser = (struct parser_params *)arg;
-
- if (!compile_for_eval && rb_safe_level() == 0) {
- ruby_debug_lines = debug_lines(ruby_sourcefile);
- if (ruby_debug_lines && ruby_sourceline > 0) {
- VALUE str = rb_str_new(0, 0);
- n = ruby_sourceline;
- do {
+ NODE *node = 0;
+ struct RVarmap *vp, *vars = ruby_dyna_vars;
+
+ ruby_in_compile = 1;
+ if (!compile_for_eval && rb_safe_level() == 0 &&
+ rb_const_defined(rb_cObject, rb_intern("SCRIPT_LINES__"))) {
+ VALUE hash, fname;
+
+ hash = rb_const_get(rb_cObject, rb_intern("SCRIPT_LINES__"));
+ if (TYPE(hash) == T_HASH) {
+ fname = rb_str_new2(f);
+ ruby_debug_lines = rb_ary_new();
+ rb_hash_aset(hash, fname, ruby_debug_lines);
+ }
+ if (line > 1) {
+ VALUE str = rb_str_new(0,0);
+ while (line > 1) {
rb_ary_push(ruby_debug_lines, str);
- } while (--n);
+ line--;
+ }
}
}
- parser->enc = rb_enc_get(lex_input);
- parser_prepare(parser);
- n = yyparse((void*)parser);
+ ruby__end__seen = 0;
+ ruby_eval_tree = 0;
+ ruby_eval_tree_begin = 0;
+ heredoc_end = 0;
+ lex_strterm = 0;
+ ruby_current_node = 0;
+ ruby_sourcefile = rb_source_filename(f);
+ deferred_nodes = 0;
+ n = yyparse();
ruby_debug_lines = 0;
compile_for_eval = 0;
-
+ ruby_in_compile = 0;
+ cond_stack = 0;
+ cmdarg_stack = 0;
+ command_start = 1;
+ class_nest = 0;
+ in_single = 0;
+ in_def = 0;
+ cur_mid = 0;
+ deferred_nodes = 0;
+
+ vp = ruby_dyna_vars;
+ ruby_dyna_vars = vars;
lex_strterm = 0;
- if (parser->nerr) {
- return 0;
+ while (vp && vp != vars) {
+ struct RVarmap *tmp = vp;
+ vp = vp->next;
+ rb_gc_force_recycle((VALUE)tmp);
}
- tree = ruby_eval_tree;
- if (!tree) {
- tree = NEW_NIL();
- }
- if (ruby_eval_tree_begin) {
- NODE *scope = ruby_eval_tree;
-
- if (scope) {
- scope->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, scope->nd_body);
- }
- tree = scope;
- }
- else {
- tree = ruby_eval_tree;
- }
- return (VALUE)tree;
+ if (n == 0) node = ruby_eval_tree;
+ if (ruby_nerrs) ruby_eval_tree_begin = 0;
+ return node;
}
-static NODE*
-yycompile(struct parser_params *parser, const char *f, int line)
-{
- ruby_sourcefile = rb_source_filename(f);
- ruby_sourceline = line - 1;
- return (NODE *)ruby_suppress_tracing(yycompile0, (VALUE)parser, Qtrue);
-}
-#endif /* !RIPPER */
+static int lex_gets_ptr;
static VALUE
-lex_get_str(struct parser_params *parser, VALUE s)
+lex_get_str(s)
+ VALUE s;
{
char *beg, *end, *pend;
- beg = RSTRING_PTR(s);
+ beg = RSTRING(s)->ptr;
if (lex_gets_ptr) {
- if (RSTRING_LEN(s) == lex_gets_ptr) return Qnil;
+ if (RSTRING(s)->len == lex_gets_ptr) return Qnil;
beg += lex_gets_ptr;
}
- pend = RSTRING_PTR(s) + RSTRING_LEN(s);
+ pend = RSTRING(s)->ptr + RSTRING(s)->len;
end = beg;
while (end < pend) {
if (*end++ == '\n') break;
}
- lex_gets_ptr = end - RSTRING_PTR(s);
- return STR_NEW(beg, end - beg);
+ lex_gets_ptr = end - RSTRING(s)->ptr;
+ return rb_str_new(beg, end - beg);
}
static VALUE
-lex_getline(struct parser_params *parser)
+lex_getline()
{
- VALUE line = (*parser->parser_lex_gets)(parser, parser->parser_lex_input);
-#ifndef RIPPER
+ VALUE line = (*lex_gets)(lex_input);
if (ruby_debug_lines && !NIL_P(line)) {
rb_ary_push(ruby_debug_lines, line);
}
-#endif
return line;
}
-#ifndef RIPPER
-NODE*
-rb_compile_string(const char *f, VALUE s, int line)
-{
- VALUE volatile vparser = rb_parser_new();
-
- return rb_parser_compile_string(vparser, f, s, line);
-}
-
NODE*
-rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
+rb_compile_string(f, s, line)
+ const char *f;
+ VALUE s;
+ int line;
{
- struct parser_params *parser;
- NODE *node;
- volatile VALUE tmp;
-
- Data_Get_Struct(vparser, struct parser_params, parser);
lex_gets = lex_get_str;
lex_gets_ptr = 0;
lex_input = s;
lex_pbeg = lex_p = lex_pend = 0;
- compile_for_eval = rb_parse_in_eval();
-
- node = yycompile(parser, f, line);
- tmp = vparser; /* prohibit tail call optimization */
+ ruby_sourceline = line - 1;
+ compile_for_eval = ruby_in_eval;
- return node;
+ return yycompile(f, line);
}
NODE*
-rb_compile_cstr(const char *f, const char *s, int len, int line)
+rb_compile_cstr(f, s, len, line)
+ const char *f, *s;
+ int len, line;
{
return rb_compile_string(f, rb_str_new(s, len), line);
}
NODE*
-rb_parser_compile_cstr(volatile VALUE vparser, const char *f, const char *s, int len, int line)
+rb_compile_file(f, file, start)
+ const char *f;
+ VALUE file;
+ int start;
{
- return rb_parser_compile_string(vparser, f, rb_str_new(s, len), line);
-}
-
-static VALUE
-lex_io_gets(struct parser_params *parser, VALUE io)
-{
- return rb_io_gets(io);
-}
-
-NODE*
-rb_compile_file(const char *f, VALUE file, int start)
-{
- VALUE volatile vparser = rb_parser_new();
-
- return rb_parser_compile_file(vparser, f, file, start);
-}
-
-NODE*
-rb_parser_compile_file(volatile VALUE vparser, const char *f, VALUE file, int start)
-{
- struct parser_params *parser;
- volatile VALUE tmp;
- NODE *node;
-
- Data_Get_Struct(vparser, struct parser_params, parser);
- lex_gets = lex_io_gets;
+ lex_gets = rb_io_gets;
lex_input = file;
lex_pbeg = lex_p = lex_pend = 0;
+ ruby_sourceline = start - 1;
- node = yycompile(parser, f, start);
- tmp = vparser; /* prohibit tail call optimization */
-
- return node;
-}
-#endif /* !RIPPER */
-
-#define STR_FUNC_ESCAPE 0x01
-#define STR_FUNC_EXPAND 0x02
-#define STR_FUNC_REGEXP 0x04
-#define STR_FUNC_QWORDS 0x08
-#define STR_FUNC_SYMBOL 0x10
-#define STR_FUNC_INDENT 0x20
-
-enum string_type {
- str_squote = (0),
- str_dquote = (STR_FUNC_EXPAND),
- str_xquote = (STR_FUNC_EXPAND),
- str_regexp = (STR_FUNC_REGEXP|STR_FUNC_ESCAPE|STR_FUNC_EXPAND),
- str_sword = (STR_FUNC_QWORDS),
- str_dword = (STR_FUNC_QWORDS|STR_FUNC_EXPAND),
- str_ssym = (STR_FUNC_SYMBOL),
- str_dsym = (STR_FUNC_SYMBOL|STR_FUNC_EXPAND),
-};
-
-static VALUE
-parser_str_new(const char *p, long n, rb_encoding *enc, int func)
-{
- VALUE str;
-
- str = rb_enc_str_new(p, n, enc);
- if (!(func & STR_FUNC_REGEXP) &&
- rb_enc_asciicompat(enc) &&
- rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) {
- rb_enc_associate(str, rb_ascii8bit_encoding());
- }
-
- return str;
+ return yycompile(f, start);
}
static inline int
-parser_nextc(struct parser_params *parser)
+nextc()
{
int c;
if (lex_p == lex_pend) {
- VALUE v = lex_nextline;
- lex_nextline = 0;
- if (!v) {
- if (parser->eofp)
- return -1;
+ if (lex_input) {
+ VALUE v = lex_getline();
- if (!lex_input || NIL_P(v = lex_getline(parser))) {
- parser->eofp = Qtrue;
- lex_lastline = 0;
- return -1;
- }
- }
- {
-#ifdef RIPPER
- if (parser->tokp < lex_pend) {
- if (NIL_P(parser->delayed)) {
- parser->delayed = rb_str_buf_new(1024);
- rb_str_buf_cat(parser->delayed,
- parser->tokp, lex_pend - parser->tokp);
- parser->delayed_line = ruby_sourceline;
- parser->delayed_col = parser->tokp - lex_pbeg;
- }
- else {
- rb_str_buf_cat(parser->delayed,
- parser->tokp, lex_pend - parser->tokp);
- }
- }
-#endif
+ if (NIL_P(v)) return -1;
if (heredoc_end > 0) {
ruby_sourceline = heredoc_end;
heredoc_end = 0;
}
ruby_sourceline++;
- parser->line_count++;
- lex_pbeg = lex_p = RSTRING_PTR(v);
- lex_pend = lex_p + RSTRING_LEN(v);
-#ifdef RIPPER
- ripper_flush(parser);
-#endif
+ lex_pbeg = lex_p = RSTRING(v)->ptr;
+ lex_pend = lex_p + RSTRING(v)->len;
lex_lastline = v;
}
+ else {
+ lex_lastline = 0;
+ return -1;
+ }
}
c = (unsigned char)*lex_p++;
if (c == '\r' && lex_p < lex_pend && *lex_p == '\n') {
@@ -4909,16 +2819,13 @@ parser_nextc(struct parser_params *parser)
}
static void
-parser_pushback(struct parser_params *parser, int c)
+pushback(c)
+ int c;
{
if (c == -1) return;
lex_p--;
- if (lex_p > lex_pbeg && lex_p[0] == '\n' && lex_p[-1] == '\r') {
- lex_p--;
- }
}
-#define lex_goto_eol(parser) (parser->parser_lex_p = parser->parser_lex_pend)
#define was_bol() (lex_p == lex_pbeg + 1)
#define peek(c) (lex_p != lex_pend && (c) == *lex_p)
@@ -4928,7 +2835,7 @@ parser_pushback(struct parser_params *parser, int c)
#define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
static char*
-parser_newtok(struct parser_params *parser)
+newtok()
{
tokidx = 0;
if (!tokenbuf) {
@@ -4942,22 +2849,11 @@ parser_newtok(struct parser_params *parser)
return tokenbuf;
}
-static char *
-parser_tokspace(struct parser_params *parser, int n)
-{
- tokidx += n;
-
- if (tokidx >= toksiz) {
- do {toksiz *= 2;} while (toksiz < tokidx);
- REALLOC_N(tokenbuf, char, toksiz);
- }
- return &tokenbuf[tokidx-n];
-}
-
static void
-parser_tokadd(struct parser_params *parser, int c)
+tokadd(c)
+ char c;
{
- tokenbuf[tokidx++] = (char)c;
+ tokenbuf[tokidx++] = c;
if (tokidx >= toksiz) {
toksiz *= 2;
REALLOC_N(tokenbuf, char, toksiz);
@@ -4965,112 +2861,9 @@ parser_tokadd(struct parser_params *parser, int c)
}
static int
-parser_tok_hex(struct parser_params *parser, int *numlen)
-{
- int c;
-
- c = scan_hex(lex_p, 2, numlen);
- if (!*numlen) {
- yyerror("invalid hex escape");
- return 0;
- }
- lex_p += *numlen;
- return c;
-}
-
-#define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
-
-static int
-parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
- int string_literal, int symbol_literal, int regexp_literal)
-{
- /*
- * If string_literal is true, then we allow multiple codepoints
- * in \u{}, and add the codepoints to the current token.
- * Otherwise we're parsing a character literal and return a single
- * codepoint without adding it
- */
-
- int codepoint;
- int numlen;
-
- if (regexp_literal) { tokadd('\\'); tokadd('u'); }
-
- if (peek('{')) { /* handle \u{...} form */
- do {
- if (regexp_literal) { tokadd(*lex_p); }
- nextc();
- codepoint = scan_hex(lex_p, 6, &numlen);
- if (numlen == 0) {
- yyerror("invalid Unicode escape");
- return 0;
- }
- if (codepoint > 0x10ffff) {
- yyerror("invalid Unicode codepoint (too large)");
- return 0;
- }
- lex_p += numlen;
- if (regexp_literal) {
- tokcopy(numlen);
- }
- else if (codepoint >= 0x80) {
- *encp = UTF8_ENC();
- if (string_literal) tokaddmbc(codepoint, *encp);
- }
- else if (string_literal) {
- if (codepoint == 0 && symbol_literal) {
- yyerror("symbol cannot contain '\\u{0}'");
- return 0;
- }
-
- tokadd(codepoint);
- }
- } while (string_literal && (peek(' ') || peek('\t')));
-
- if (!peek('}')) {
- yyerror("unterminated Unicode escape");
- return 0;
- }
-
- if (regexp_literal) { tokadd('}'); }
- nextc();
- }
- else { /* handle \uxxxx form */
- codepoint = scan_hex(lex_p, 4, &numlen);
- if (numlen < 4) {
- yyerror("invalid Unicode escape");
- return 0;
- }
- lex_p += 4;
- if (regexp_literal) {
- tokcopy(4);
- }
- else if (codepoint >= 0x80) {
- *encp = UTF8_ENC();
- if (string_literal) tokaddmbc(codepoint, *encp);
- }
- else if (string_literal) {
- if (codepoint == 0 && symbol_literal) {
- yyerror("symbol cannot contain '\\u0000'");
- return 0;
- }
-
- tokadd(codepoint);
- }
- }
-
- return codepoint;
-}
-
-#define ESCAPE_CONTROL 1
-#define ESCAPE_META 2
-
-static int
-parser_read_escape(struct parser_params *parser, int flags,
- rb_encoding **encp)
+read_escape()
{
int c;
- int numlen;
switch (c = nextc()) {
case '\\': /* Backslash */
@@ -5099,7 +2892,6 @@ parser_read_escape(struct parser_params *parser, int flags,
case '0': case '1': case '2': case '3': /* octal constant */
case '4': case '5': case '6': case '7':
- if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
{
int numlen;
@@ -5110,9 +2902,16 @@ parser_read_escape(struct parser_params *parser, int flags,
return c;
case 'x': /* hex constant */
- if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
- c = tok_hex(&numlen);
- if (numlen == 0) return 0;
+ {
+ int numlen;
+
+ c = scan_hex(lex_p, 2, &numlen);
+ if (numlen == 0) {
+ yyerror("Invalid escape character syntax");
+ return 0;
+ }
+ lex_p += numlen;
+ }
return c;
case 'b': /* backspace */
@@ -5122,32 +2921,32 @@ parser_read_escape(struct parser_params *parser, int flags,
return ' ';
case 'M':
- if (flags & ESCAPE_META) goto eof;
if ((c = nextc()) != '-') {
+ yyerror("Invalid escape character syntax");
pushback(c);
- goto eof;
+ return '\0';
}
if ((c = nextc()) == '\\') {
- return read_escape(flags|ESCAPE_META, encp) | 0x80;
+ return read_escape() | 0x80;
}
- else if (c == -1 || !ISASCII(c)) goto eof;
+ else if (c == -1) goto eof;
else {
return ((c & 0xff) | 0x80);
}
case 'C':
if ((c = nextc()) != '-') {
+ yyerror("Invalid escape character syntax");
pushback(c);
- goto eof;
+ return '\0';
}
case 'c':
- if (flags & ESCAPE_CONTROL) goto eof;
if ((c = nextc())== '\\') {
- c = read_escape(flags|ESCAPE_CONTROL, encp);
+ c = read_escape();
}
else if (c == '?')
return 0177;
- else if (c == -1 || !ISASCII(c)) goto eof;
+ else if (c == -1) goto eof;
return c & 0x9f;
eof:
@@ -5160,77 +2959,73 @@ parser_read_escape(struct parser_params *parser, int flags,
}
}
-static void
-parser_tokaddmbc(struct parser_params *parser, int c, rb_encoding *enc)
-{
- int len = rb_enc_codelen(c, enc);
- rb_enc_mbcput(c, tokspace(len), enc);
-}
-
static int
-parser_tokadd_escape(struct parser_params *parser, int term,
- rb_encoding **encp)
+tokadd_escape()
{
int c;
- int flags = 0;
- first:
switch (c = nextc()) {
case '\n':
return 0; /* just ignore */
case '0': case '1': case '2': case '3': /* octal constant */
case '4': case '5': case '6': case '7':
- if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
{
- int numlen;
- int oct;
+ int i;
- oct = scan_oct(--lex_p, 3, &numlen);
- if (numlen == 0) goto eof;
- lex_p += numlen;
- tokcopy(numlen + 1);
+ tokadd('\\');
+ tokadd(c);
+ for (i=0; i<2; i++) {
+ c = nextc();
+ if (c == -1) goto eof;
+ if (c < '0' || '7' < c) {
+ pushback(c);
+ break;
+ }
+ tokadd(c);
+ }
}
return 0;
case 'x': /* hex constant */
- if (flags & (ESCAPE_CONTROL|ESCAPE_META)) goto eof;
{
int numlen;
- int hex;
- hex = tok_hex(&numlen);
- if (numlen == 0) goto eof;
- tokcopy(numlen + 2);
+ tokadd('\\');
+ tokadd(c);
+ scan_hex(lex_p, 2, &numlen);
+ if (numlen == 0) {
+ yyerror("Invalid escape character syntax");
+ return -1;
+ }
+ while (numlen--)
+ tokadd(nextc());
}
return 0;
case 'M':
- if (flags & ESCAPE_META) goto eof;
if ((c = nextc()) != '-') {
+ yyerror("Invalid escape character syntax");
pushback(c);
- goto eof;
+ return 0;
}
- tokcopy(3);
- flags |= ESCAPE_META;
+ tokadd('\\'); tokadd('M'); tokadd('-');
goto escaped;
case 'C':
- if (flags & ESCAPE_CONTROL) goto eof;
if ((c = nextc()) != '-') {
+ yyerror("Invalid escape character syntax");
pushback(c);
- goto eof;
+ return 0;
}
- tokcopy(3);
+ tokadd('\\'); tokadd('C'); tokadd('-');
goto escaped;
case 'c':
- if (flags & ESCAPE_CONTROL) goto eof;
- tokcopy(2);
- flags |= ESCAPE_CONTROL;
+ tokadd('\\'); tokadd('c');
escaped:
if ((c = nextc()) == '\\') {
- goto first;
+ return tokadd_escape();
}
else if (c == -1) goto eof;
tokadd(c);
@@ -5242,96 +3037,91 @@ parser_tokadd_escape(struct parser_params *parser, int term,
return -1;
default:
- if (c != '\\' || c != term)
- tokadd('\\');
+ tokadd('\\');
tokadd(c);
}
return 0;
}
-extern int rb_char_to_option_kcode(int c, int *option, int *kcode);
-
static int
-parser_regx_options(struct parser_params *parser)
+regx_options()
{
- int kcode = 0;
+ char kcode = 0;
int options = 0;
- int c, opt, kc;
+ int c;
newtok();
while (c = nextc(), ISALPHA(c)) {
- if (c == 'o') {
- options |= RE_OPTION_ONCE;
- }
- else if (rb_char_to_option_kcode(c, &opt, &kc)) {
- options |= opt;
- if (kc >= 0) kcode = c;
- }
- else {
+ switch (c) {
+ case 'i':
+ options |= RE_OPTION_IGNORECASE;
+ break;
+ case 'x':
+ options |= RE_OPTION_EXTENDED;
+ break;
+ case 'm':
+ options |= RE_OPTION_MULTILINE;
+ break;
+ case 'o':
+ options |= RE_OPTION_ONCE;
+ break;
+ case 'n':
+ kcode = 16;
+ break;
+ case 'e':
+ kcode = 32;
+ break;
+ case 's':
+ kcode = 48;
+ break;
+ case 'u':
+ kcode = 64;
+ break;
+ default:
tokadd(c);
- }
+ break;
+ }
}
pushback(c);
if (toklen()) {
tokfix();
- compile_error(PARSER_ARG "unknown regexp option%s - %s",
- toklen() > 1 ? "s" : "", tok());
+ rb_compile_error("unknown regexp option%s - %s",
+ toklen() > 1 ? "s" : "", tok());
}
- return options | RE_OPTION_ENCODING(kcode);
+ return options | kcode;
}
+#define STR_FUNC_ESCAPE 0x01
+#define STR_FUNC_EXPAND 0x02
+#define STR_FUNC_REGEXP 0x04
+#define STR_FUNC_QWORDS 0x08
+#define STR_FUNC_SYMBOL 0x10
+#define STR_FUNC_INDENT 0x20
+
+enum string_type {
+ str_squote = (0),
+ str_dquote = (STR_FUNC_EXPAND),
+ str_xquote = (STR_FUNC_EXPAND),
+ str_regexp = (STR_FUNC_REGEXP|STR_FUNC_ESCAPE|STR_FUNC_EXPAND),
+ str_sword = (STR_FUNC_QWORDS),
+ str_dword = (STR_FUNC_QWORDS|STR_FUNC_EXPAND),
+ str_ssym = (STR_FUNC_SYMBOL),
+ str_dsym = (STR_FUNC_SYMBOL|STR_FUNC_EXPAND),
+};
+
static void
-dispose_string(VALUE str)
+dispose_string(str)
+ VALUE str;
{
- /* TODO: should use another API? */
- if (RBASIC(str)->flags & RSTRING_NOEMBED)
- xfree(RSTRING_PTR(str));
+ xfree(RSTRING(str)->ptr);
rb_gc_force_recycle(str);
}
static int
-parser_tokadd_mbchar(struct parser_params *parser, int c)
-{
- int len = parser_precise_mbclen();
- if (!MBCLEN_CHARFOUND(len)) {
- compile_error(PARSER_ARG "invalid multibyte char");
- return -1;
- }
- tokadd(c);
- lex_p += --len;
- if (len > 0) tokcopy(len);
- return c;
-}
-
-#define tokadd_mbchar(c) parser_tokadd_mbchar(parser, c)
-
-static int
-parser_tokadd_string(struct parser_params *parser,
- int func, int term, int paren, long *nest,
- rb_encoding **encp)
+tokadd_string(func, term, paren, nest)
+ int func, term, paren, *nest;
{
int c;
- int has_nonascii = 0;
- rb_encoding *enc = *encp;
- char *errbuf = 0;
- static const char mixed_msg[] = "%s mixed within %s source";
-
-#define mixed_error(enc1, enc2) if (!errbuf) { \
- int len = sizeof(mixed_msg) - 4; \
- len += strlen(rb_enc_name(enc1)); \
- len += strlen(rb_enc_name(enc2)); \
- errbuf = ALLOCA_N(char, len); \
- snprintf(errbuf, len, mixed_msg, \
- rb_enc_name(enc1), \
- rb_enc_name(enc2)); \
- yyerror(errbuf); \
- }
-#define mixed_escape(beg, enc1, enc2) do { \
- const char *pos = lex_p; \
- lex_p = beg; \
- mixed_error(enc1, enc2); \
- lex_p = pos; \
- } while (0)
while ((c = nextc()) != -1) {
if (paren && c == paren) {
@@ -5352,7 +3142,6 @@ parser_tokadd_string(struct parser_params *parser,
}
}
else if (c == '\\') {
- const char *beg = lex_p - 1;
c = nextc();
switch (c) {
case '\n':
@@ -5365,33 +3154,17 @@ parser_tokadd_string(struct parser_params *parser,
if (func & STR_FUNC_ESCAPE) tokadd(c);
break;
- case 'u':
- if ((func & STR_FUNC_EXPAND) == 0) {
- tokadd('\\');
- break;
- }
- parser_tokadd_utf8(parser, &enc, 1,
- func & STR_FUNC_SYMBOL,
- func & STR_FUNC_REGEXP);
- if (has_nonascii && enc != *encp) {
- mixed_escape(beg, enc, *encp);
- }
- continue;
-
default:
if (func & STR_FUNC_REGEXP) {
pushback(c);
- if ((c = tokadd_escape(term, &enc)) < 0)
+ if (tokadd_escape() < 0)
return -1;
- if (has_nonascii && enc != *encp) {
- mixed_escape(beg, enc, *encp);
- }
continue;
}
else if (func & STR_FUNC_EXPAND) {
pushback(c);
if (func & STR_FUNC_ESCAPE) tokadd('\\');
- c = read_escape(0, &enc);
+ c = read_escape();
}
else if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
/* ignore backslashed spaces in %w */
@@ -5401,14 +3174,13 @@ parser_tokadd_string(struct parser_params *parser,
}
}
}
- else if (!parser_isascii()) {
- has_nonascii = 1;
- if (enc != *encp) {
- mixed_error(enc, *encp);
- continue;
+ else if (ismbchar(c)) {
+ int i, len = mbclen(c)-1;
+
+ for (i = 0; i < len; i++) {
+ tokadd(c);
+ c = nextc();
}
- if (tokadd_mbchar(c) == -1) return -1;
- continue;
}
else if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
pushback(c);
@@ -5416,19 +3188,11 @@ parser_tokadd_string(struct parser_params *parser,
}
if (!c && (func & STR_FUNC_SYMBOL)) {
func &= ~STR_FUNC_SYMBOL;
- compile_error(PARSER_ARG "symbol cannot contain '\\0'");
+ rb_compile_error("symbol cannot contain '\\0'");
continue;
}
- if (c & 0x80) {
- has_nonascii = 1;
- if (enc != *encp) {
- mixed_error(enc, *encp);
- continue;
- }
- }
tokadd(c);
}
- *encp = enc;
return c;
}
@@ -5436,13 +3200,13 @@ parser_tokadd_string(struct parser_params *parser,
rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
static int
-parser_parse_string(struct parser_params *parser, NODE *quote)
+parse_string(quote)
+ NODE *quote;
{
int func = quote->nd_func;
int term = nd_term(quote);
int paren = nd_paren(quote);
int c, space = 0;
- rb_encoding *enc = parser->enc;
if (func == -1) return tSTRING_END;
c = nextc();
@@ -5456,7 +3220,7 @@ parser_parse_string(struct parser_params *parser, NODE *quote)
return ' ';
}
if (!(func & STR_FUNC_REGEXP)) return tSTRING_END;
- set_yylval_num(regx_options());
+ yylval.num = regx_options();
return tREGEXP_END;
}
if (space) {
@@ -5476,28 +3240,19 @@ parser_parse_string(struct parser_params *parser, NODE *quote)
tokadd('#');
}
pushback(c);
- if (tokadd_string(func, term, paren, &quote->nd_nest,
- &enc) == -1) {
+ if (tokadd_string(func, term, paren, &quote->nd_nest) == -1) {
ruby_sourceline = nd_line(quote);
- if (func & STR_FUNC_REGEXP) {
- if (parser->eofp)
- compile_error(PARSER_ARG "unterminated regexp meets end of file");
- return tREGEXP_END;
- }
- else {
- if (parser->eofp)
- compile_error(PARSER_ARG "unterminated string meets end of file");
- return tSTRING_END;
- }
+ rb_compile_error("unterminated string meets end of file");
+ return tSTRING_END;
}
tokfix();
- set_yylval_str(STR_NEW3(tok(), toklen(), enc, func));
+ yylval.node = NEW_STR(rb_str_new(tok(), toklen()));
return tSTRING_CONTENT;
}
static int
-parser_heredoc_identifier(struct parser_params *parser)
+heredoc_identifier()
{
int c = nextc(), term, func = 0, len;
@@ -5517,16 +3272,17 @@ parser_heredoc_identifier(struct parser_params *parser)
tokadd(func);
term = c;
while ((c = nextc()) != -1 && c != term) {
- if (tokadd_mbchar(c) == -1) return 0;
+ len = mbclen(c);
+ do {tokadd(c);} while (--len > 0 && (c = nextc()) != -1);
}
if (c == -1) {
- compile_error(PARSER_ARG "unterminated here document identifier");
+ rb_compile_error("unterminated here document identifier");
return 0;
}
break;
default:
- if (!parser_is_identchar()) {
+ if (!is_identchar(c)) {
pushback(c);
if (func & STR_FUNC_INDENT) {
pushback('-');
@@ -5537,59 +3293,44 @@ parser_heredoc_identifier(struct parser_params *parser)
term = '"';
tokadd(func |= str_dquote);
do {
- if (tokadd_mbchar(c) == -1) return 0;
- } while ((c = nextc()) != -1 && parser_is_identchar());
+ len = mbclen(c);
+ do {tokadd(c);} while (--len > 0 && (c = nextc()) != -1);
+ } while ((c = nextc()) != -1 && is_identchar(c));
pushback(c);
break;
}
tokfix();
-#ifdef RIPPER
- ripper_dispatch_scan_event(parser, tHEREDOC_BEG);
-#endif
len = lex_p - lex_pbeg;
- lex_goto_eol(parser);
+ lex_p = lex_pend;
lex_strterm = rb_node_newnode(NODE_HEREDOC,
- STR_NEW(tok(), toklen()), /* nd_lit */
+ rb_str_new(tok(), toklen()), /* nd_lit */
len, /* nd_nth */
lex_lastline); /* nd_orig */
- nd_set_line(lex_strterm, ruby_sourceline);
-#ifdef RIPPER
- ripper_flush(parser);
-#endif
return term == '`' ? tXSTRING_BEG : tSTRING_BEG;
}
static void
-parser_heredoc_restore(struct parser_params *parser, NODE *here)
+heredoc_restore(here)
+ NODE *here;
{
- VALUE line;
-
-#ifdef RIPPER
- if (!NIL_P(parser->delayed))
- ripper_dispatch_delayed_token(parser, tSTRING_CONTENT);
- lex_goto_eol(parser);
- ripper_dispatch_scan_event(parser, tHEREDOC_END);
-#endif
- line = here->nd_orig;
+ VALUE line = here->nd_orig;
lex_lastline = line;
- lex_pbeg = RSTRING_PTR(line);
- lex_pend = lex_pbeg + RSTRING_LEN(line);
+ lex_pbeg = RSTRING(line)->ptr;
+ lex_pend = lex_pbeg + RSTRING(line)->len;
lex_p = lex_pbeg + here->nd_nth;
heredoc_end = ruby_sourceline;
ruby_sourceline = nd_line(here);
dispose_string(here->nd_lit);
rb_gc_force_recycle((VALUE)here);
-#ifdef RIPPER
- ripper_flush(parser);
-#endif
}
static int
-parser_whole_match_p(struct parser_params *parser,
- const char *eos, int len, int indent)
+whole_match_p(eos, len, indent)
+ char *eos;
+ int len, indent;
{
- const char *p = lex_pbeg;
+ char *p = lex_pbeg;
int n;
if (indent) {
@@ -5602,21 +3343,21 @@ parser_whole_match_p(struct parser_params *parser,
}
static int
-parser_here_document(struct parser_params *parser, NODE *here)
+here_document(here)
+ NODE *here;
{
int c, func, indent = 0;
- const char *eos, *p, *pend;
+ char *eos, *p, *pend;
long len;
VALUE str = 0;
- eos = RSTRING_PTR(here->nd_lit);
- len = RSTRING_LEN(here->nd_lit) - 1;
+ eos = RSTRING(here->nd_lit)->ptr;
+ len = RSTRING(here->nd_lit)->len - 1;
indent = (func = *eos++) & STR_FUNC_INDENT;
if ((c = nextc()) == -1) {
error:
- compile_error(PARSER_ARG "can't find string \"%s\" anywhere before EOF", eos);
- restore:
+ rb_compile_error("can't find string \"%s\" anywhere before EOF", eos);
heredoc_restore(lex_strterm);
lex_strterm = 0;
return 0;
@@ -5628,7 +3369,7 @@ parser_here_document(struct parser_params *parser, NODE *here)
if (!(func & STR_FUNC_EXPAND)) {
do {
- p = RSTRING_PTR(lex_lastline);
+ p = RSTRING(lex_lastline)->ptr;
pend = lex_pend;
if (pend > p) {
switch (pend[-1]) {
@@ -5644,9 +3385,9 @@ parser_here_document(struct parser_params *parser, NODE *here)
if (str)
rb_str_cat(str, p, pend - p);
else
- str = STR_NEW(p, pend - p);
+ str = rb_str_new(p, pend - p);
if (pend < lex_pend) rb_str_cat(str, "\n", 1);
- lex_goto_eol(parser);
+ lex_p = lex_pend;
if (nextc() == -1) {
if (str) dispose_string(str);
goto error;
@@ -5654,8 +3395,6 @@ parser_here_document(struct parser_params *parser, NODE *here)
} while (!whole_match_p(eos, len, indent));
}
else {
- /* int mb = ENC_CODERANGE_7BIT, *mbp = &mb;*/
- rb_encoding *enc = parser->enc;
newtok();
if (c == '#') {
switch (c = nextc()) {
@@ -5670,308 +3409,39 @@ parser_here_document(struct parser_params *parser, NODE *here)
}
do {
pushback(c);
- if ((c = tokadd_string(func, '\n', 0, NULL, &enc)) == -1) {
- if (parser->eofp) goto error;
- goto restore;
- }
+ if ((c = tokadd_string(func, '\n', 0, NULL)) == -1) goto error;
if (c != '\n') {
- set_yylval_str(STR_NEW3(tok(), toklen(), enc, func));
+ yylval.node = NEW_STR(rb_str_new(tok(), toklen()));
return tSTRING_CONTENT;
}
tokadd(nextc());
- /* if (mbp && mb == ENC_CODERANGE_UNKNOWN) mbp = 0;*/
if ((c = nextc()) == -1) goto error;
} while (!whole_match_p(eos, len, indent));
- str = STR_NEW3(tok(), toklen(), enc, func);
+ str = rb_str_new(tok(), toklen());
}
heredoc_restore(lex_strterm);
lex_strterm = NEW_STRTERM(-1, 0, 0);
- set_yylval_str(str);
+ yylval.node = NEW_STR(str);
return tSTRING_CONTENT;
}
#include "lex.c"
-#ifndef RIPPER
-static void
-arg_ambiguous_gen(struct parser_params *parser)
-{
- rb_warning0("ambiguous first argument; put parentheses or even spaces");
-}
-#else
-static void
-arg_ambiguous_gen(struct parser_params *parser)
-{
- dispatch0(arg_ambiguous);
-}
-#endif
-#define arg_ambiguous() arg_ambiguous_gen(parser)
-
-static int
-lvar_defined_gen(struct parser_params *parser, ID id)
-{
-#ifndef RIPPER
- return (dyna_in_block() && dvar_defined(id)) || local_id(id);
-#else
- return 0;
-#endif
-}
-
-/* emacsen -*- hack */
-static int
-parser_encode_length(struct parser_params *parser, const char *name, int len)
-{
- int nlen;
-
- if (len > 5 && name[nlen = len - 5] == '-') {
- if (rb_memcicmp(name + nlen + 1, "unix", 4) == 0)
- return nlen;
- }
- if (len > 4 && name[nlen = len - 5] == '-') {
- if (rb_memcicmp(name + nlen + 1, "dos", 3) == 0)
- return nlen;
- if (rb_memcicmp(name + nlen + 1, "mac", 3) == 0)
- return nlen;
- }
- return len;
-}
-
-static void
-parser_set_encode(struct parser_params *parser, const char *name)
-{
- int idx = rb_enc_find_index(name);
- if (idx < 0) {
- rb_raise(rb_eArgError, "unknown encoding name: %s", name);
- }
- parser->enc = rb_enc_from_index(idx);
-}
-
-#ifndef RIPPER
-typedef int (*rb_magic_comment_length_t)(struct parser_params *parser, const char *name, int len);
-typedef void (*rb_magic_comment_setter_t)(struct parser_params *parser, const char *name, const char *val);
-
-static void
-magic_comment_encoding(struct parser_params *parser, const char *name, const char *val)
-{
- if (parser && parser->line_count != (parser->has_shebang ? 2 : 1))
- return;
- parser_set_encode(parser, val);
-}
-
-struct magic_comment {
- const char *name;
- rb_magic_comment_setter_t func;
- rb_magic_comment_length_t length;
-};
-
-static const struct magic_comment magic_comments[] = {
- {"coding", magic_comment_encoding, parser_encode_length},
- {"encoding", magic_comment_encoding, parser_encode_length},
-};
-#endif
-
-static const char *
-magic_comment_marker(const char *str, int len)
-{
- int i = 2;
-
- while (i < len) {
- switch (str[i]) {
- case '-':
- if (str[i-1] == '*' && str[i-2] == '-') {
- return str + i + 1;
- }
- i += 2;
- break;
- case '*':
- if (i + 1 >= len) return 0;
- if (str[i+1] != '-') {
- i += 4;
- }
- else if (str[i-1] != '-') {
- i += 2;
- }
- else {
- return str + i + 2;
- }
- break;
- default:
- i += 3;
- break;
- }
- }
- return 0;
-}
-
-static int
-parser_magic_comment(struct parser_params *parser, const char *str, int len)
-{
- VALUE name = 0, val = 0;
- const char *beg, *end, *vbeg, *vend;
-#define str_copy(_s, _p, _n) ((_s) \
- ? (rb_str_resize((_s), (_n)), \
- MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
- : ((_s) = STR_NEW((_p), (_n))))
-
- if (len <= 7) return Qfalse;
- if (!(beg = magic_comment_marker(str, len))) return Qfalse;
- if (!(end = magic_comment_marker(beg, str + len - beg))) return Qfalse;
- str = beg;
- len = end - beg - 3;
-
- /* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
- while (len > 0) {
-#ifndef RIPPER
- const struct magic_comment *p = magic_comments;
-#endif
- int n = 0;
-
- for (; len > 0 && *str; str++, --len) {
- switch (*str) {
- case '\'': case '"': case ':': case ';':
- continue;
- }
- if (!ISSPACE(*str)) break;
- }
- for (beg = str; len > 0; str++, --len) {
- switch (*str) {
- case '\'': case '"': case ':': case ';':
- break;
- default:
- if (ISSPACE(*str)) break;
- continue;
- }
- break;
- }
- for (end = str; len > 0 && ISSPACE(*str); str++, --len);
- if (!len) break;
- if (*str != ':') continue;
-
- do str++; while (--len > 0 && ISSPACE(*str));
- if (!len) break;
- if (*str == '"') {
- for (vbeg = ++str; --len > 0 && *str != '"'; str++) {
- if (*str == '\\') {
- --len;
- ++str;
- }
- }
- vend = str;
- if (len) {
- --len;
- ++str;
- }
- }
- else {
- for (vbeg = str; len > 0 && *str != '"' && *str != ';' && !ISSPACE(*str); --len, str++);
- vend = str;
- }
- while (len > 0 && (*str == ';' || ISSPACE(*str))) --len, str++;
-
- n = end - beg;
- str_copy(name, beg, n);
-#ifndef RIPPER
- do {
- if (strncasecmp(p->name, RSTRING_PTR(name), n) == 0) {
- n = vend - vbeg;
- if (p->length) {
- n = (*p->length)(parser, vbeg, n);
- }
- str_copy(val, vbeg, n);
- (*p->func)(parser, RSTRING_PTR(name), RSTRING_PTR(val));
- break;
- }
- } while (++p < magic_comments + sizeof(magic_comments) / sizeof(*p));
-#else
- dispatch2(magic_comment, name, val);
-#endif
- }
-
- return Qtrue;
-}
-
-static void
-set_file_encoding(struct parser_params *parser, const char *str, const char *send)
-{
- int sep = 0;
- const char *beg = str;
- VALUE s;
-
- for (;;) {
- if (send - str <= 6) return;
- switch (str[6]) {
- case 'C': case 'c': str += 6; continue;
- case 'O': case 'o': str += 5; continue;
- case 'D': case 'd': str += 4; continue;
- case 'I': case 'i': str += 3; continue;
- case 'N': case 'n': str += 2; continue;
- case 'G': case 'g': str += 1; continue;
- case '=': case ':':
- sep = 1;
- str += 6;
- break;
- default:
- str += 6;
- if (ISSPACE(*str)) break;
- continue;
- }
- if (strncasecmp(str-6, "coding", 6) == 0) break;
- }
- for (;;) {
- do {
- if (++str >= send) return;
- } while (ISSPACE(*str));
- if (sep) break;
- if (*str != '=' && *str != ':') return;
- sep = 1;
- str++;
- }
- beg = str;
- while ((*str == '-' || *str == '_' || ISALNUM(*str)) && ++str < send);
- s = rb_str_new(beg, parser_encode_length(parser, beg, str - beg));
- parser_set_encode(parser, RSTRING_PTR(s));
- rb_str_resize(s, 0);
-}
-
static void
-parser_prepare(struct parser_params *parser)
+arg_ambiguous()
{
- int c = nextc();
- switch (c) {
- case '#':
- if (peek('!')) parser->has_shebang = 1;
- break;
- case 0xef: /* UTF-8 BOM marker */
- if (lex_pend - lex_p >= 2 &&
- (unsigned char)lex_p[0] == 0xbb &&
- (unsigned char)lex_p[1] == 0xbf) {
- parser_set_encode(parser, "UTF-8");
- lex_p += 2;
- lex_pbeg = lex_p;
- return;
- }
- break;
- case EOF:
- return;
- }
- pushback(c);
+ rb_warning("ambiguous first argument; put parentheses or even spaces");
}
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
-#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_VALUE || lex_state == EXPR_CLASS)
static int
-parser_yylex(struct parser_params *parser)
+yylex()
{
register int c;
int space_seen = 0;
int cmd_state;
- enum lex_state_e last_state;
- rb_encoding *enc;
- int mb;
-#ifdef RIPPER
- int fallthru = Qfalse;
-#endif
+ enum lex_state last_state;
if (lex_strterm) {
int token;
@@ -5979,7 +3449,7 @@ parser_yylex(struct parser_params *parser)
token = here_document(lex_strterm);
if (token == tSTRING_END) {
lex_strterm = 0;
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
}
}
else {
@@ -5987,7 +3457,7 @@ parser_yylex(struct parser_params *parser)
if (token == tSTRING_END || token == tREGEXP_END) {
rb_gc_force_recycle((VALUE)lex_strterm);
lex_strterm = 0;
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
}
}
return token;
@@ -6006,36 +3476,13 @@ parser_yylex(struct parser_params *parser)
case ' ': case '\t': case '\f': case '\r':
case '\13': /* '\v' */
space_seen++;
-#ifdef RIPPER
- while ((c = nextc())) {
- switch (c) {
- case ' ': case '\t': case '\f': case '\r':
- case '\13': /* '\v' */
- break;
- default:
- goto outofloop;
- }
- }
- outofloop:
- pushback(c);
- ripper_dispatch_scan_event(parser, tSP);
-#endif
goto retry;
case '#': /* it's a comment */
- if (!parser->has_shebang || parser->line_count != 1) {
- /* no magic_comment in shebang line */
- if (!parser_magic_comment(parser, lex_p, lex_pend - lex_p)) {
- if (parser->line_count == (parser->has_shebang ? 2 : 1)) {
- set_file_encoding(parser, lex_p, lex_pend);
- }
- }
+ while ((c = nextc()) != '\n') {
+ if (c == -1)
+ return 0;
}
- lex_p = lex_pend;
-#ifdef RIPPER
- ripper_dispatch_scan_event(parser, tCOMMENT);
- fallthru = Qtrue;
-#endif
/* fall through */
case '\n':
switch (lex_state) {
@@ -6043,44 +3490,10 @@ parser_yylex(struct parser_params *parser)
case EXPR_FNAME:
case EXPR_DOT:
case EXPR_CLASS:
- case EXPR_VALUE:
-#ifdef RIPPER
- if (!fallthru) {
- ripper_dispatch_scan_event(parser, tIGNORED_NL);
- }
- fallthru = Qfalse;
-#endif
goto retry;
default:
break;
}
- while ((c = nextc())) {
- switch (c) {
- case ' ': case '\t': case '\f': case '\r':
- case '\13': /* '\v' */
- space_seen++;
- break;
- case '.': {
- if ((c = nextc()) != '.') {
- pushback(c);
- pushback('.');
- goto retry;
- }
- }
- default:
- --ruby_sourceline;
- case -1: /* EOF no decrement*/
- lex_nextline = lex_lastline;
- lex_p = lex_pend;
-#ifdef RIPPER
- if (c != -1) {
- parser->tokp = lex_p;
- }
-#endif
- goto normal_newline;
- }
- }
- normal_newline:
command_start = Qtrue;
lex_state = EXPR_BEG;
return '\n';
@@ -6088,7 +3501,7 @@ parser_yylex(struct parser_params *parser)
case '*':
if ((c = nextc()) == '*') {
if ((c = nextc()) == '=') {
- set_yylval_id(tPOW);
+ yylval.id = tPOW;
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6097,16 +3510,16 @@ parser_yylex(struct parser_params *parser)
}
else {
if (c == '=') {
- set_yylval_id('*');
+ yylval.id = '*';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
pushback(c);
- if (IS_ARG() && space_seen && !ISSPACE(c)) {
- rb_warning0("`*' interpreted as argument prefix");
+ if (IS_ARG() && space_seen && !ISSPACE(c)){
+ rb_warning("`*' interpreted as argument prefix");
c = tSTAR;
}
- else if (IS_BEG()) {
+ else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tSTAR;
}
else {
@@ -6122,17 +3535,8 @@ parser_yylex(struct parser_params *parser)
return c;
case '!':
- c = nextc();
- if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
- lex_state = EXPR_ARG;
- if (c == '@') {
- return '!';
- }
- }
- else {
- lex_state = EXPR_BEG;
- }
- if (c == '=') {
+ lex_state = EXPR_BEG;
+ if ((c = nextc()) == '=') {
return tNEQ;
}
if (c == '~') {
@@ -6145,23 +3549,11 @@ parser_yylex(struct parser_params *parser)
if (was_bol()) {
/* skip embedded rd document */
if (strncmp(lex_p, "begin", 5) == 0 && ISSPACE(lex_p[5])) {
-#ifdef RIPPER
- int first_p = Qtrue;
-
- lex_goto_eol(parser);
- ripper_dispatch_scan_event(parser, tEMBDOC_BEG);
-#endif
for (;;) {
- lex_goto_eol(parser);
-#ifdef RIPPER
- if (!first_p) {
- ripper_dispatch_scan_event(parser, tEMBDOC);
- }
- first_p = Qfalse;
-#endif
+ lex_p = lex_pend;
c = nextc();
if (c == -1) {
- compile_error(PARSER_ARG "embedded document meets end of file");
+ rb_compile_error("embedded document meets end of file");
return 0;
}
if (c != '=') continue;
@@ -6170,10 +3562,7 @@ parser_yylex(struct parser_params *parser)
break;
}
}
- lex_goto_eol(parser);
-#ifdef RIPPER
- ripper_dispatch_scan_event(parser, tEMBDOC_END);
-#endif
+ lex_p = lex_pend;
goto retry;
}
}
@@ -6226,7 +3615,7 @@ parser_yylex(struct parser_params *parser)
}
if (c == '<') {
if ((c = nextc()) == '=') {
- set_yylval_id(tLSHFT);
+ yylval.id = tLSHFT;
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6248,7 +3637,7 @@ parser_yylex(struct parser_params *parser)
}
if (c == '>') {
if ((c = nextc()) == '=') {
- set_yylval_id(tRSHFT);
+ yylval.id = tRSHFT;
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6282,18 +3671,17 @@ parser_yylex(struct parser_params *parser)
return tSTRING_BEG;
case '?':
- if (lex_state == EXPR_END ||
- lex_state == EXPR_ENDARG) {
- lex_state = EXPR_VALUE;
+ if (lex_state == EXPR_END || lex_state == EXPR_ENDARG) {
+ lex_state = EXPR_BEG;
return '?';
}
c = nextc();
if (c == -1) {
- compile_error(PARSER_ARG "incomplete character syntax");
+ rb_compile_error("incomplete character syntax");
return 0;
}
- if (rb_enc_isspace(c, parser->enc)) {
- if (!IS_ARG()) {
+ if (ISSPACE(c)){
+ if (!IS_ARG()){
int c2 = 0;
switch (c) {
case ' ':
@@ -6316,52 +3704,34 @@ parser_yylex(struct parser_params *parser)
break;
}
if (c2) {
- rb_warnI("invalid character syntax; use ?\\%c", c2);
+ rb_warn("invalid character syntax; use ?\\%c", c2);
}
}
ternary:
pushback(c);
- lex_state = EXPR_VALUE;
+ lex_state = EXPR_BEG;
return '?';
}
- newtok();
- enc = parser->enc;
- if (!parser_isascii()) {
- if (tokadd_mbchar(c) == -1) return 0;
+ else if (ismbchar(c)) {
+ rb_warn("multibyte character literal not supported yet; use ?\\%.3o", c);
+ goto ternary;
}
- else if ((rb_enc_isalnum(c, parser->enc) || c == '_') &&
- lex_p < lex_pend && is_identchar(lex_p, lex_pend, parser->enc)) {
+ else if ((ISALNUM(c) || c == '_') && lex_p < lex_pend && is_identchar(*lex_p)) {
goto ternary;
}
- else if (c == '\\') {
- if (peek('u')) {
- nextc();
- c = parser_tokadd_utf8(parser, &enc, 0, 0, 0);
- if (0x80 <= c) {
- tokaddmbc(c, enc);
- }
- else {
- tokadd(c);
- }
- }
- else {
- c = read_escape(0, &enc);
- tokadd(c);
- }
- }
- else {
- tokadd(c);
- }
- tokfix();
- set_yylval_str(STR_NEW3(tok(), toklen(), enc, 0));
- lex_state = EXPR_ENDARG;
- return tCHAR;
+ else if (c == '\\') {
+ c = read_escape();
+ }
+ c &= 0xff;
+ lex_state = EXPR_END;
+ yylval.node = NEW_LIT(INT2FIX(c));
+ return tINTEGER;
case '&':
if ((c = nextc()) == '&') {
lex_state = EXPR_BEG;
if ((c = nextc()) == '=') {
- set_yylval_id(tANDOP);
+ yylval.id = tANDOP;
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6369,16 +3739,16 @@ parser_yylex(struct parser_params *parser)
return tANDOP;
}
else if (c == '=') {
- set_yylval_id('&');
+ yylval.id = '&';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
pushback(c);
- if (IS_ARG() && space_seen && !ISSPACE(c)) {
- rb_warning0("`&' interpreted as argument prefix");
+ if (IS_ARG() && space_seen && !ISSPACE(c)){
+ rb_warning("`&' interpreted as argument prefix");
c = tAMPER;
}
- else if (IS_BEG()) {
+ else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tAMPER;
}
else {
@@ -6396,7 +3766,7 @@ parser_yylex(struct parser_params *parser)
if ((c = nextc()) == '|') {
lex_state = EXPR_BEG;
if ((c = nextc()) == '=') {
- set_yylval_id(tOROP);
+ yylval.id = tOROP;
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6404,7 +3774,7 @@ parser_yylex(struct parser_params *parser)
return tOROP;
}
if (c == '=') {
- set_yylval_id('|');
+ yylval.id = '|';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6428,11 +3798,11 @@ parser_yylex(struct parser_params *parser)
return '+';
}
if (c == '=') {
- set_yylval_id('+');
+ yylval.id = '+';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
- if (IS_BEG() ||
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
(IS_ARG() && space_seen && !ISSPACE(c))) {
if (IS_ARG()) arg_ambiguous();
lex_state = EXPR_BEG;
@@ -6458,15 +3828,11 @@ parser_yylex(struct parser_params *parser)
return '-';
}
if (c == '=') {
- set_yylval_id('-');
+ yylval.id = '-';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
- if (c == '>') {
- lex_state = EXPR_ARG;
- return tLAMBDA;
- }
- if (IS_BEG() ||
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
(IS_ARG() && space_seen && !ISSPACE(c))) {
if (IS_ARG()) arg_ambiguous();
lex_state = EXPR_BEG;
@@ -6503,7 +3869,7 @@ parser_yylex(struct parser_params *parser)
int is_float, seen_point, seen_e, nondigit;
is_float = seen_point = seen_e = nondigit = 0;
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
newtok();
if (c == '-' || c == '+') {
tokadd(c);
@@ -6533,7 +3899,7 @@ parser_yylex(struct parser_params *parser)
yyerror("numeric literal without digits");
}
else if (nondigit) goto trailing_uc;
- set_yylval_literal(rb_cstr_to_inum(tok(), 16, Qfalse));
+ yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 16, Qfalse));
return tINTEGER;
}
if (c == 'b' || c == 'B') {
@@ -6557,7 +3923,7 @@ parser_yylex(struct parser_params *parser)
yyerror("numeric literal without digits");
}
else if (nondigit) goto trailing_uc;
- set_yylval_literal(rb_cstr_to_inum(tok(), 2, Qfalse));
+ yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 2, Qfalse));
return tINTEGER;
}
if (c == 'd' || c == 'D') {
@@ -6581,7 +3947,7 @@ parser_yylex(struct parser_params *parser)
yyerror("numeric literal without digits");
}
else if (nondigit) goto trailing_uc;
- set_yylval_literal(rb_cstr_to_inum(tok(), 10, Qfalse));
+ yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 10, Qfalse));
return tINTEGER;
}
if (c == '_') {
@@ -6604,7 +3970,8 @@ parser_yylex(struct parser_params *parser)
nondigit = c;
continue;
}
- if (c < '0' || c > '7') break;
+ if (c < '0' || c > '9') break;
+ if (c > '7') goto invalid_octal;
nondigit = 0;
tokadd(c);
} while ((c = nextc()) != -1);
@@ -6612,7 +3979,7 @@ parser_yylex(struct parser_params *parser)
pushback(c);
tokfix();
if (nondigit) goto trailing_uc;
- set_yylval_literal(rb_cstr_to_inum(tok(), 8, Qfalse));
+ yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 8, Qfalse));
return tINTEGER;
}
if (nondigit) {
@@ -6621,6 +3988,7 @@ parser_yylex(struct parser_params *parser)
}
}
if (c > '7' && c <= '9') {
+ invalid_octal:
yyerror("Illegal octal digit");
}
else if (c == '.' || c == 'e' || c == 'E') {
@@ -6628,7 +3996,7 @@ parser_yylex(struct parser_params *parser)
}
else {
pushback(c);
- set_yylval_literal(INT2FIX(0));
+ yylval.node = NEW_LIT(INT2FIX(0));
return tINTEGER;
}
}
@@ -6704,32 +4072,28 @@ parser_yylex(struct parser_params *parser)
if (is_float) {
double d = strtod(tok(), 0);
if (errno == ERANGE) {
- rb_warnS("Float %s out of range", tok());
+ rb_warn("Float %s out of range", tok());
errno = 0;
}
- set_yylval_literal(DOUBLE2NUM(d));
+ yylval.node = NEW_LIT(rb_float_new(d));
return tFLOAT;
}
- set_yylval_literal(rb_cstr_to_inum(tok(), 10, Qfalse));
+ yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 10, Qfalse));
return tINTEGER;
}
- case ')':
case ']':
- paren_nest--;
case '}':
+ case ')':
COND_LEXPOP();
CMDARG_LEXPOP();
- if (c == ')')
- lex_state = EXPR_END;
- else
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
return c;
case ':':
c = nextc();
if (c == ':') {
- if (IS_BEG() ||
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID ||
lex_state == EXPR_CLASS || (IS_ARG() && space_seen)) {
lex_state = EXPR_BEG;
return tCOLON3;
@@ -6737,8 +4101,7 @@ parser_yylex(struct parser_params *parser)
lex_state = EXPR_DOT;
return tCOLON2;
}
- if (lex_state == EXPR_END ||
- lex_state == EXPR_ENDARG || ISSPACE(c)) {
+ if (lex_state == EXPR_END || lex_state == EXPR_ENDARG || ISSPACE(c)) {
pushback(c);
lex_state = EXPR_BEG;
return ':';
@@ -6758,12 +4121,12 @@ parser_yylex(struct parser_params *parser)
return tSYMBEG;
case '/':
- if (IS_BEG()) {
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_strterm = NEW_STRTERM(str_regexp, '/', 0);
return tREGEXP_BEG;
}
if ((c = nextc()) == '=') {
- set_yylval_id('/');
+ yylval.id = '/';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6785,7 +4148,7 @@ parser_yylex(struct parser_params *parser)
case '^':
if ((c = nextc()) == '=') {
- set_yylval_id('^');
+ yylval.id = '^';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6799,28 +4162,28 @@ parser_yylex(struct parser_params *parser)
return '^';
case ';':
- lex_state = EXPR_BEG;
command_start = Qtrue;
- return ';';
-
case ',':
lex_state = EXPR_BEG;
- return ',';
+ return c;
case '~':
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
if ((c = nextc()) != '@') {
pushback(c);
}
- lex_state = EXPR_ARG;
}
- else {
- lex_state = EXPR_BEG;
+ switch (lex_state) {
+ case EXPR_FNAME: case EXPR_DOT:
+ lex_state = EXPR_ARG; break;
+ default:
+ lex_state = EXPR_BEG; break;
}
return '~';
case '(':
- if (IS_BEG()) {
+ command_start = Qtrue;
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tLPAREN;
}
else if (space_seen) {
@@ -6828,18 +4191,16 @@ parser_yylex(struct parser_params *parser)
c = tLPAREN_ARG;
}
else if (lex_state == EXPR_ARG) {
- rb_warning0("don't put space before argument parentheses");
+ rb_warn("don't put space before argument parentheses");
c = '(';
}
}
- paren_nest++;
COND_PUSH(0);
CMDARG_PUSH(0);
lex_state = EXPR_BEG;
return c;
case '[':
- paren_nest++;
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
lex_state = EXPR_ARG;
if ((c = nextc()) == ']') {
@@ -6852,7 +4213,7 @@ parser_yylex(struct parser_params *parser)
pushback(c);
return '[';
}
- else if (IS_BEG()) {
+ else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
c = tLBRACK;
}
else if (IS_ARG() && space_seen) {
@@ -6864,12 +4225,6 @@ parser_yylex(struct parser_params *parser)
return c;
case '{':
- if (lpar_beg && lpar_beg == paren_nest) {
- lex_state = EXPR_BEG;
- lpar_beg = 0;
- --paren_nest;
- return tLAMBEG;
- }
if (IS_ARG() || lex_state == EXPR_END)
c = '{'; /* block (primary) */
else if (lex_state == EXPR_ENDARG)
@@ -6886,16 +4241,13 @@ parser_yylex(struct parser_params *parser)
c = nextc();
if (c == '\n') {
space_seen = 1;
-#ifdef RIPPER
- ripper_dispatch_scan_event(parser, tSP);
-#endif
goto retry; /* skip \\n */
}
pushback(c);
return '\\';
case '%':
- if (IS_BEG()) {
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
int term;
int paren;
@@ -6907,13 +4259,13 @@ parser_yylex(struct parser_params *parser)
}
else {
term = nextc();
- if (rb_enc_isalnum(term, parser->enc) || !parser_isascii()) {
+ if (ISALNUM(term) || ismbchar(term)) {
yyerror("unknown type of %string");
return 0;
}
}
if (c == -1 || term == -1) {
- compile_error(PARSER_ARG "unterminated quoted string meets end of file");
+ rb_compile_error("unterminated quoted string meets end of file");
return 0;
}
paren = term;
@@ -6963,7 +4315,7 @@ parser_yylex(struct parser_params *parser)
}
}
if ((c = nextc()) == '=') {
- set_yylval_id('%');
+ yylval.id = '%';
lex_state = EXPR_BEG;
return tOP_ASGN;
}
@@ -6981,13 +4333,13 @@ parser_yylex(struct parser_params *parser)
case '$':
last_state = lex_state;
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
newtok();
c = nextc();
switch (c) {
case '_': /* $_: last read line string */
c = nextc();
- if (parser_is_identchar()) {
+ if (is_identchar(c)) {
tokadd('$');
tokadd('_');
break;
@@ -6996,6 +4348,8 @@ parser_yylex(struct parser_params *parser)
c = '_';
/* fall through */
case '~': /* $~: match-data */
+ local_cnt(c);
+ /* fall through */
case '*': /* $*: argv */
case '$': /* $$: pid */
case '?': /* $?: last status */
@@ -7014,22 +4368,23 @@ parser_yylex(struct parser_params *parser)
tokadd('$');
tokadd(c);
tokfix();
- set_yylval_id(rb_intern(tok()));
+ yylval.id = rb_intern(tok());
return tGVAR;
case '-':
tokadd('$');
tokadd(c);
c = nextc();
- if (parser_is_identchar()) {
- if (tokadd_mbchar(c) == -1) return 0;
+ if (is_identchar(c)) {
+ tokadd(c);
}
else {
pushback(c);
}
gvar:
tokfix();
- set_yylval_id(rb_intern(tok()));
+ yylval.id = rb_intern(tok());
+ /* xxx shouldn't check if valid option variable */
return tGVAR;
case '&': /* $&: last match */
@@ -7041,7 +4396,7 @@ parser_yylex(struct parser_params *parser)
tokadd(c);
goto gvar;
}
- set_yylval_node(NEW_BACK_REF(c));
+ yylval.node = NEW_BACK_REF(c);
return tBACK_REF;
case '1': case '2': case '3':
@@ -7055,11 +4410,11 @@ parser_yylex(struct parser_params *parser)
pushback(c);
if (last_state == EXPR_FNAME) goto gvar;
tokfix();
- set_yylval_node(NEW_NTH_REF(atoi(tok()+1)));
+ yylval.node = NEW_NTH_REF(atoi(tok()+1));
return tNTH_REF;
default:
- if (!parser_is_identchar()) {
+ if (!is_identchar(c)) {
pushback(c);
return '$';
}
@@ -7078,14 +4433,14 @@ parser_yylex(struct parser_params *parser)
}
if (ISDIGIT(c)) {
if (tokidx == 1) {
- compile_error(PARSER_ARG "`@%c' is not allowed as an instance variable name", c);
+ rb_compile_error("`@%c' is not allowed as an instance variable name", c);
}
else {
- compile_error(PARSER_ARG "`@@%c' is not allowed as a class variable name", c);
+ rb_compile_error("`@@%c' is not allowed as a class variable name", c);
}
return 0;
}
- if (!parser_is_identchar()) {
+ if (!is_identchar(c)) {
pushback(c);
return '@';
}
@@ -7095,20 +4450,14 @@ parser_yylex(struct parser_params *parser)
if (was_bol() && whole_match_p("__END__", 7, 0)) {
ruby__end__seen = 1;
lex_lastline = 0;
-#ifndef RIPPER
return -1;
-#else
- lex_goto_eol(parser);
- ripper_dispatch_scan_event(parser, k__END__);
- return 0;
-#endif
}
newtok();
break;
default:
- if (!parser_is_identchar()) {
- rb_compile_error(PARSER_ARG "Invalid char `\\x%02X' in expression", c);
+ if (!is_identchar(c)) {
+ rb_compile_error("Invalid char `\\%03o' in expression", c);
goto retry;
}
@@ -7116,13 +4465,19 @@ parser_yylex(struct parser_params *parser)
break;
}
- mb = ENC_CODERANGE_7BIT;
do {
- if (!ISASCII(c)) mb = ENC_CODERANGE_UNKNOWN;
- if (tokadd_mbchar(c) == -1) return 0;
+ tokadd(c);
+ if (ismbchar(c)) {
+ int i, len = mbclen(c)-1;
+
+ for (i = 0; i < len; i++) {
+ c = nextc();
+ tokadd(c);
+ }
+ }
c = nextc();
- } while (parser_is_identchar());
- if ((c == '!' || c == '?') && !peek('=')) {
+ } while (is_identchar(c));
+ if ((c == '!' || c == '?') && is_identchar(tok()[0]) && !peek('=')) {
tokadd(c);
}
else {
@@ -7136,11 +4491,11 @@ parser_yylex(struct parser_params *parser)
last_state = lex_state;
switch (tok()[0]) {
case '$':
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
result = tGVAR;
break;
case '@':
- lex_state = EXPR_ENDARG;
+ lex_state = EXPR_END;
if (tok()[1] == '@')
result = tCVAR;
else
@@ -7171,33 +4526,28 @@ parser_yylex(struct parser_params *parser)
}
}
- if (mb == ENC_CODERANGE_7BIT && lex_state != EXPR_DOT) {
+ if (lex_state != EXPR_DOT) {
const struct kwtable *kw;
/* See if it is a reserved word. */
kw = rb_reserved_word(tok(), toklen());
if (kw) {
- enum lex_state_e state = lex_state;
+ enum lex_state state = lex_state;
lex_state = kw->state;
if (state == EXPR_FNAME) {
- set_yylval_id(rb_intern(kw->name));
+ yylval.id = rb_intern(kw->name);
return kw->id[0];
}
- if (kw->id[0] == keyword_do) {
+ if (kw->id[0] == kDO) {
command_start = Qtrue;
- if (lpar_beg && lpar_beg == paren_nest) {
- lpar_beg = 0;
- --paren_nest;
- return keyword_do_LAMBDA;
- }
- if (COND_P()) return keyword_do_cond;
+ if (COND_P()) return kDO_COND;
if (CMDARG_P() && state != EXPR_CMDARG)
- return keyword_do_block;
- if (state == EXPR_ENDARG || state == EXPR_BEG)
- return keyword_do_block;
- return keyword_do;
+ return kDO_BLOCK;
+ if (state == EXPR_ENDARG)
+ return kDO_BLOCK;
+ return kDO;
}
- if (state == EXPR_BEG || state == EXPR_VALUE)
+ if (state == EXPR_BEG)
return kw->id[0];
else {
if (kw->id[0] != kw->id[1])
@@ -7207,19 +4557,11 @@ parser_yylex(struct parser_params *parser)
}
}
- if ((lex_state == EXPR_BEG && !cmd_state) ||
+ if (lex_state == EXPR_BEG ||
+ lex_state == EXPR_MID ||
+ lex_state == EXPR_DOT ||
lex_state == EXPR_ARG ||
lex_state == EXPR_CMDARG) {
- if (peek(':') && !(lex_p + 1 < lex_pend && lex_p[1] == ':')) {
- lex_state = EXPR_BEG;
- nextc();
- set_yylval_id(TOK_INTERN(!ENC_SINGLE(mb)));
- return tLABEL;
- }
- }
- if (IS_BEG() ||
- lex_state == EXPR_DOT ||
- IS_ARG()) {
if (cmd_state) {
lex_state = EXPR_CMDARG;
}
@@ -7231,79 +4573,69 @@ parser_yylex(struct parser_params *parser)
lex_state = EXPR_END;
}
}
- {
- ID ident = TOK_INTERN(!ENC_SINGLE(mb));
-
- set_yylval_id(ident);
- if (last_state != EXPR_DOT && is_local_id(ident) && lvar_defined(ident)) {
- lex_state = EXPR_END;
- }
- }
+ yylval.id = rb_intern(tok());
+ if (is_local_id(yylval.id) &&
+ last_state != EXPR_DOT &&
+ ((dyna_in_block() && rb_dvar_defined(yylval.id)) || local_id(yylval.id))) {
+ lex_state = EXPR_END;
+ }
return result;
}
}
-#if YYPURE
-static int
-yylex(void *lval, void *p)
-#else
-yylex(void *p)
-#endif
+NODE*
+rb_node_newnode(type, a0, a1, a2)
+ enum node_type type;
+ VALUE a0, a1, a2;
{
- struct parser_params *parser = (struct parser_params*)p;
- int t;
-
-#if YYPURE
- parser->parser_yylval = (union tmpyystype*)lval;
- parser->parser_yylval->val = Qundef;
-#endif
- t = parser_yylex(parser);
-#ifdef RIPPER
- if (!NIL_P(parser->delayed)) {
- ripper_dispatch_delayed_token(parser, t);
- return t;
- }
- if (t != 0)
- ripper_dispatch_scan_event(parser, t);
-#endif
-
- return t;
-}
+ NODE *n = (NODE*)rb_newobj();
-#ifndef RIPPER
-static NODE*
-node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
-{
- NODE *n = (rb_node_newnode)(type, a0, a1, a2);
+ n->flags |= T_NODE;
+ nd_set_type(n, type);
nd_set_line(n, ruby_sourceline);
n->nd_file = ruby_sourcefile;
+
+ n->u1.value = a0;
+ n->u2.value = a1;
+ n->u3.value = a2;
+
return n;
}
-enum node_type
-nodetype(NODE *node) /* for debug */
+static enum node_type
+nodetype(node) /* for debug */
+ NODE *node;
{
return (enum node_type)nd_type(node);
}
-int
-nodeline(NODE *node)
+static int
+nodeline(node)
+ NODE *node;
{
return nd_line(node);
}
static NODE*
-newline_node(NODE *node)
+newline_node(node)
+ NODE *node;
{
+ NODE *nl = 0;
if (node) {
+ int line;
+ if (nd_type(node) == NODE_NEWLINE) return node;
+ line = nd_line(node);
node = remove_begin(node);
- node->flags |= NODE_NEWLINE;
+ nl = NEW_NEWLINE(node);
+ nd_set_line(nl, line);
+ nl->nd_nth = line;
}
- return node;
+ return nl;
}
static void
-fixpos(NODE *node, NODE *orig)
+fixpos(node, orig)
+ NODE *node, *orig;
{
if (!node) return;
if (!orig) return;
@@ -7313,32 +4645,43 @@ fixpos(NODE *node, NODE *orig)
}
static void
-parser_warning(NODE *node, const char *mesg)
+parser_warning(node, mesg)
+ NODE *node;
+ const char *mesg;
{
- rb_compile_warning(node->nd_file, nd_line(node), "%s", mesg);
+ int line = ruby_sourceline;
+ ruby_sourceline = nd_line(node);
+ rb_warning("%s", mesg);
+ ruby_sourceline = line;
}
static void
-parser_warn(NODE *node, const char *mesg)
+parser_warn(node, mesg)
+ NODE *node;
+ const char *mesg;
{
- rb_compile_warn(node->nd_file, nd_line(node), "%s", mesg);
+ int line = ruby_sourceline;
+ ruby_sourceline = nd_line(node);
+ rb_warn("%s", mesg);
+ ruby_sourceline = line;
}
static NODE*
-block_append_gen(struct parser_params *parser, NODE *head, NODE *tail)
+block_append(head, tail)
+ NODE *head, *tail;
{
- NODE *end, *h = head, *nd;
+ NODE *end, *h = head;
if (tail == 0) return head;
+ again:
if (h == 0) return tail;
switch (nd_type(h)) {
+ case NODE_NEWLINE:
+ h = h->nd_next;
+ goto again;
case NODE_LIT:
case NODE_STR:
- case NODE_SELF:
- case NODE_TRUE:
- case NODE_FALSE:
- case NODE_NIL:
parser_warning(h, "unused literal ignored");
return tail;
default:
@@ -7352,20 +4695,25 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail)
break;
}
- nd = end->nd_head;
- switch (nd_type(nd)) {
- case NODE_RETURN:
- case NODE_BREAK:
- case NODE_NEXT:
- case NODE_REDO:
- case NODE_RETRY:
- if (RTEST(ruby_verbose)) {
+ if (RTEST(ruby_verbose)) {
+ NODE *nd = end->nd_head;
+ newline:
+ switch (nd_type(nd)) {
+ case NODE_RETURN:
+ case NODE_BREAK:
+ case NODE_NEXT:
+ case NODE_REDO:
+ case NODE_RETRY:
parser_warning(nd, "statement not reached");
- }
- break;
+ break;
- default:
- break;
+ case NODE_NEWLINE:
+ nd = nd->nd_next;
+ goto newline;
+
+ default:
+ break;
+ }
}
if (nd_type(tail) != NODE_BLOCK) {
@@ -7379,7 +4727,8 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail)
/* append item to the list */
static NODE*
-list_append_gen(struct parser_params *parser, NODE *list, NODE *item)
+list_append(list, item)
+ NODE *list, *item;
{
NODE *last;
@@ -7399,7 +4748,8 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item)
/* concat two lists */
static NODE*
-list_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
+list_concat(head, tail)
+ NODE *head, *tail;
{
NODE *last;
@@ -7422,20 +4772,10 @@ list_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
return head;
}
-static void
-literal_concat0(struct parser_params *parser, VALUE head, VALUE tail)
-{
- if (!rb_enc_compatible(head, tail)) {
- compile_error(PARSER_ARG "string literal encodings differ (%s / %s)",
- rb_enc_name(rb_enc_get(head)),
- rb_enc_name(rb_enc_get(tail)));
- }
- rb_str_buf_append(head, tail);
-}
-
/* concat two string literals */
static NODE *
-literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
+literal_concat(head, tail)
+ NODE *head, *tail;
{
enum node_type htype;
@@ -7450,7 +4790,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
switch (nd_type(tail)) {
case NODE_STR:
if (htype == NODE_STR) {
- literal_concat0(parser, head->nd_lit, tail->nd_lit);
+ rb_str_concat(head->nd_lit, tail->nd_lit);
rb_gc_force_recycle((VALUE)tail);
}
else {
@@ -7460,7 +4800,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
case NODE_DSTR:
if (htype == NODE_STR) {
- literal_concat0(parser, head->nd_lit, tail->nd_lit);
+ rb_str_concat(head->nd_lit, tail->nd_lit);
tail->nd_lit = head->nd_lit;
rb_gc_force_recycle((VALUE)head);
head = tail;
@@ -7484,7 +4824,8 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
}
static NODE *
-evstr2dstr_gen(struct parser_params *parser, NODE *node)
+evstr2dstr(node)
+ NODE *node;
{
if (nd_type(node) == NODE_EVSTR) {
node = list_append(NEW_DSTR(rb_str_new(0, 0)), node);
@@ -7493,37 +4834,49 @@ evstr2dstr_gen(struct parser_params *parser, NODE *node)
}
static NODE *
-new_evstr_gen(struct parser_params *parser, NODE *node)
+new_evstr(node)
+ NODE *node;
{
NODE *head = node;
+ again:
if (node) {
switch (nd_type(node)) {
case NODE_STR: case NODE_DSTR: case NODE_EVSTR:
return node;
+ case NODE_NEWLINE:
+ node = node->nd_next;
+ goto again;
}
}
return NEW_EVSTR(head);
}
static NODE *
-call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1)
-{
- value_expr(recv);
- value_expr(arg1);
- return NEW_CALL(recv, id, NEW_LIST(arg1));
-}
-
-static NODE *
-call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id)
+call_op(recv, id, narg, arg1)
+ NODE *recv;
+ ID id;
+ int narg;
+ NODE *arg1;
{
value_expr(recv);
- return NEW_CALL(recv, id, 0);
+ if (narg == 1) {
+ value_expr(arg1);
+ arg1 = NEW_LIST(arg1);
+ }
+ else {
+ arg1 = 0;
+ }
+ return NEW_CALL(recv, id, arg1);
}
static NODE*
-match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2)
+match_gen(node1, node2)
+ NODE *node1;
+ NODE *node2;
{
+ local_cnt('~');
+
value_expr(node1);
value_expr(node2);
if (node1) {
@@ -7556,33 +4909,36 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2)
}
static NODE*
-gettable_gen(struct parser_params *parser, ID id)
+gettable(id)
+ ID id;
{
- if (id == keyword_self) {
+ if (id == kSELF) {
return NEW_SELF();
}
- else if (id == keyword_nil) {
+ else if (id == kNIL) {
return NEW_NIL();
}
- else if (id == keyword_true) {
+ else if (id == kTRUE) {
return NEW_TRUE();
}
- else if (id == keyword_false) {
+ else if (id == kFALSE) {
return NEW_FALSE();
}
- else if (id == keyword__FILE__) {
- return NEW_STR(STR_NEW2(ruby_sourcefile));
+ else if (id == k__FILE__) {
+ return NEW_STR(rb_str_new2(ruby_sourcefile));
}
- else if (id == keyword__LINE__) {
+ else if (id == k__LINE__) {
return NEW_LIT(INT2FIX(ruby_sourceline));
}
- else if (id == keyword__ENCODING__) {
- return NEW_LIT(rb_enc_from_encoding(parser->enc));
- }
else if (is_local_id(id)) {
- if (dyna_in_block() && dvar_defined(id)) return NEW_DVAR(id);
+ if (dyna_in_block() && rb_dvar_defined(id)) return NEW_DVAR(id);
if (local_id(id)) return NEW_LVAR(id);
/* method call without arguments */
+#if 0
+ /* Rite will warn this */
+ rb_warn("ambiguous identifier; %s() or self.%s is better for method call",
+ rb_id2name(id), rb_id2name(id));
+#endif
return NEW_VCALL(id);
}
else if (is_global_id(id)) {
@@ -7597,54 +4953,50 @@ gettable_gen(struct parser_params *parser, ID id)
else if (is_class_id(id)) {
return NEW_CVAR(id);
}
- compile_error(PARSER_ARG "identifier %s is not valid to get", rb_id2name(id));
+ rb_compile_error("identifier %s is not valid", rb_id2name(id));
return 0;
}
+static VALUE dyna_var_lookup _((ID id));
+
static NODE*
-assignable_gen(struct parser_params *parser, ID id, NODE *val)
+assignable(id, val)
+ ID id;
+ NODE *val;
{
- if (!id) return 0;
- if (id == keyword_self) {
+ value_expr(val);
+ if (id == kSELF) {
yyerror("Can't change the value of self");
}
- else if (id == keyword_nil) {
+ else if (id == kNIL) {
yyerror("Can't assign to nil");
}
- else if (id == keyword_true) {
+ else if (id == kTRUE) {
yyerror("Can't assign to true");
}
- else if (id == keyword_false) {
+ else if (id == kFALSE) {
yyerror("Can't assign to false");
}
- else if (id == keyword__FILE__) {
+ else if (id == k__FILE__) {
yyerror("Can't assign to __FILE__");
}
- else if (id == keyword__LINE__) {
+ else if (id == k__LINE__) {
yyerror("Can't assign to __LINE__");
}
else if (is_local_id(id)) {
- if (dyna_in_block()) {
- if (dvar_curr(id)) {
- return NEW_DASGN_CURR(id, val);
- }
- else if (dvar_defined(id)) {
- return NEW_DASGN(id, val);
- }
- else if (local_id(id)) {
- return NEW_LASGN(id, val);
- }
- else{
- dyna_var(id);
- return NEW_DASGN_CURR(id, val);
- }
+ if (rb_dvar_curr(id)) {
+ return NEW_DASGN_CURR(id, val);
}
- else {
- if (!local_id(id)) {
- local_var(id);
- }
+ else if (dyna_var_lookup(id)) {
+ return NEW_DASGN(id, val);
+ }
+ else if (local_id(id) || !dyna_in_block()) {
return NEW_LASGN(id, val);
}
+ else{
+ rb_dvar_push(id, Qnil);
+ return NEW_DASGN_CURR(id, val);
+ }
}
else if (is_global_id(id)) {
return NEW_GASGN(id, val);
@@ -7658,66 +5010,29 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
return NEW_CDECL(id, val, 0);
}
else if (is_class_id(id)) {
- return NEW_CVASGN(id, val);
- }
- compile_error(PARSER_ARG "identifier %s is not valid to set", rb_id2name(id));
- return 0;
-}
-
-static void
-shadowing_lvar_gen(struct parser_params *parser, ID name)
-{
- static ID uscore;
-
- if (!uscore) uscore = rb_intern("_");
- if (uscore == name) return;
- if (dyna_in_block()) {
- if (dvar_curr(name)) {
- yyerror("duplicated argument name");
- }
- else if (dvar_defined(name) || local_id(name)) {
- rb_warningS("shadowing outer local variable - %s", rb_id2name(name));
- vtable_add(lvtbl->vars, name);
- }
+ if (in_def || in_single) return NEW_CVASGN(id, val);
+ return NEW_CVDECL(id, val);
}
else {
- if (local_id(name)) {
- yyerror("duplicated argument name");
- }
+ rb_compile_error("identifier %s is not valid", rb_id2name(id));
}
-}
-
-static void
-new_bv_gen(struct parser_params *parser, ID name)
-{
- if (!name) return;
- if (!is_local_id(name)) {
- compile_error(PARSER_ARG "invalid local variable - %s",
- rb_id2name(name));
- return;
- }
- shadowing_lvar(name);
- dyna_var(name);
+ return 0;
}
static NODE *
-aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx)
+aryset(recv, idx)
+ NODE *recv, *idx;
{
if (recv && nd_type(recv) == NODE_SELF)
recv = (NODE *)1;
+ else
+ value_expr(recv);
return NEW_ATTRASGN(recv, tASET, idx);
}
-static void
-block_dup_check_gen(struct parser_params *parser, NODE *node1, NODE *node2)
-{
- if (node2 && node1 && nd_type(node1) == NODE_BLOCK_PASS) {
- compile_error(PARSER_ARG "both block arg and actual block given");
- }
-}
-
ID
-rb_id_attrset(ID id)
+rb_id_attrset(id)
+ ID id;
{
id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
@@ -7725,82 +5040,70 @@ rb_id_attrset(ID id)
}
static NODE *
-attrset_gen(struct parser_params *parser, NODE *recv, ID id)
+attrset(recv, id)
+ NODE *recv;
+ ID id;
{
if (recv && nd_type(recv) == NODE_SELF)
recv = (NODE *)1;
+ else
+ value_expr(recv);
return NEW_ATTRASGN(recv, rb_id_attrset(id), 0);
}
static void
-rb_backref_error_gen(struct parser_params *parser, NODE *node)
+rb_backref_error(node)
+ NODE *node;
{
switch (nd_type(node)) {
case NODE_NTH_REF:
- compile_error(PARSER_ARG "Can't set variable $%ld", node->nd_nth);
+ rb_compile_error("Can't set variable $%d", node->nd_nth);
break;
case NODE_BACK_REF:
- compile_error(PARSER_ARG "Can't set variable $%c", (int)node->nd_nth);
+ rb_compile_error("Can't set variable $%c", (int)node->nd_nth);
break;
}
}
static NODE *
-arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2)
+arg_concat(node1, node2)
+ NODE *node1;
+ NODE *node2;
{
if (!node2) return node1;
- if (nd_type(node1) == NODE_BLOCK_PASS) {
- node1->nd_iter = arg_concat(node1->nd_iter, node2);
- return node1;
- }
return NEW_ARGSCAT(node1, node2);
}
static NODE *
-arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2)
+arg_add(node1, node2)
+ NODE *node1;
+ NODE *node2;
{
if (!node1) return NEW_LIST(node2);
- switch (nd_type(node1)) {
- case NODE_ARRAY:
+ if (nd_type(node1) == NODE_ARRAY) {
return list_append(node1, node2);
- case NODE_BLOCK_PASS:
- node1->nd_head = arg_append(node1->nd_head, node2);
- return node1;
- default:
- return NEW_ARGSPUSH(node1, node2);
}
-}
-
-#define arg_add(n1, n2) arg_add_gen(parser,n1,n2)
-static NODE *
-arg_add_gen(struct parser_params *parser, NODE *node1, NODE *node2)
-{
- if (!node1) return NEW_LIST(node2);
- switch (nd_type(node1)) {
- case NODE_ARRAY:
- return list_append(node1, node2);
- case NODE_BLOCK_PASS:
- node1->nd_head = arg_add(node1->nd_head, node2);
- return node1;
- default:
+ else {
return NEW_ARGSPUSH(node1, node2);
}
}
-static NODE *
-node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs)
+static NODE*
+node_assign(lhs, rhs)
+ NODE *lhs, *rhs;
{
if (!lhs) return 0;
+ value_expr(rhs);
switch (nd_type(lhs)) {
case NODE_GASGN:
case NODE_IASGN:
- case NODE_IASGN2:
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_MASGN:
case NODE_CDECL:
+ case NODE_CVDECL:
case NODE_CVASGN:
lhs->nd_value = rhs;
break;
@@ -7819,11 +5122,11 @@ node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs)
}
static int
-value_expr_gen(struct parser_params *parser, NODE *node)
+value_expr0(node)
+ NODE *node;
{
- if (!node) {
- rb_warning0("empty expression");
- }
+ int cond = 0;
+
while (node) {
switch (nd_type(node)) {
case NODE_DEFN:
@@ -7836,7 +5139,7 @@ value_expr_gen(struct parser_params *parser, NODE *node)
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
- yyerror("void value expression");
+ if (!cond) yyerror("void value expression");
/* or "control never reach"? */
return Qfalse;
@@ -7858,9 +5161,14 @@ value_expr_gen(struct parser_params *parser, NODE *node)
case NODE_AND:
case NODE_OR:
+ cond = 1;
node = node->nd_2nd;
break;
+ case NODE_NEWLINE:
+ node = node->nd_next;
+ break;
+
default:
return Qtrue;
}
@@ -7870,14 +5178,20 @@ value_expr_gen(struct parser_params *parser, NODE *node)
}
static void
-void_expr_gen(struct parser_params *parser, NODE *node)
+void_expr0(node)
+ NODE *node;
{
const char *useless = 0;
if (!RTEST(ruby_verbose)) return;
+ again:
if (!node) return;
switch (nd_type(node)) {
+ case NODE_NEWLINE:
+ node = node->nd_next;
+ goto again;
+
case NODE_CALL:
switch (node->nd_mid) {
case '+':
@@ -7913,6 +5227,7 @@ void_expr_gen(struct parser_params *parser, NODE *node)
useless = "a variable";
break;
case NODE_CONST:
+ case NODE_CREF:
useless = "a constant";
break;
case NODE_LIT:
@@ -7953,13 +5268,14 @@ void_expr_gen(struct parser_params *parser, NODE *node)
int line = ruby_sourceline;
ruby_sourceline = nd_line(node);
- rb_warnS("useless use of %s in void context", useless);
+ rb_warn("useless use of %s in void context", useless);
ruby_sourceline = line;
}
}
static void
-void_stmts_gen(struct parser_params *parser, NODE *node)
+void_stmts(node)
+ NODE *node;
{
if (!RTEST(ruby_verbose)) return;
if (!node) return;
@@ -7973,70 +5289,27 @@ void_stmts_gen(struct parser_params *parser, NODE *node)
}
static NODE *
-remove_begin(NODE *node)
-{
- NODE **n = &node, *n1 = node;
- while (n1 && nd_type(n1) == NODE_BEGIN && n1->nd_body) {
- *n = n1 = n1->nd_body;
- }
- return node;
-}
-
-static void
-reduce_nodes_gen(struct parser_params *parser, NODE **body)
+remove_begin(node)
+ NODE *node;
{
- NODE *node = *body;
-
- if (!node) {
- *body = NEW_NIL();
- return;
- }
-#define subnodes(n1, n2) \
- ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
- (!node->n2) ? (body = &node->n1, 1) : \
- (reduce_nodes(&node->n1), body = &node->n2, 1))
-
- while (node) {
- switch (nd_type(node)) {
- end:
- case NODE_NIL:
- *body = 0;
- return;
- case NODE_RETURN:
- *body = node = node->nd_stts;
+ NODE **n = &node;
+ while (*n) {
+ switch (nd_type(*n)) {
+ case NODE_NEWLINE:
+ n = &(*n)->nd_next;
continue;
case NODE_BEGIN:
- *body = node = node->nd_body;
- continue;
- case NODE_BLOCK:
- body = &node->nd_end->nd_head;
- break;
- case NODE_IF:
- if (subnodes(nd_body, nd_else)) break;
- return;
- case NODE_CASE:
- body = &node->nd_body;
- break;
- case NODE_WHEN:
- if (!subnodes(nd_body, nd_next)) goto end;
- break;
- case NODE_ENSURE:
- if (!subnodes(nd_head, nd_resq)) goto end;
- break;
- case NODE_RESCUE:
- if (!subnodes(nd_head, nd_resq)) goto end;
- break;
+ *n = (*n)->nd_body;
default:
- return;
+ return node;
}
- node = *body;
}
-
-#undef subnodes
+ return node;
}
static int
-assign_in_cond(struct parser_params *parser, NODE *node)
+assign_in_cond(node)
+ NODE *node;
{
switch (nd_type(node)) {
case NODE_MASGN:
@@ -8049,6 +5322,7 @@ assign_in_cond(struct parser_params *parser, NODE *node)
case NODE_IASGN:
break;
+ case NODE_NEWLINE:
default:
return 0;
}
@@ -8071,51 +5345,94 @@ assign_in_cond(struct parser_params *parser, NODE *node)
default:
break;
}
+#if 0
+ if (assign_in_cond(node->nd_value) == 0) {
+ parser_warning(node->nd_value, "assignment in condition");
+ }
+#endif
return 1;
}
static int
-e_option_supplied(NODE *node)
+e_option_supplied()
{
- if (strcmp(node->nd_file, "-e") == 0)
+ if (strcmp(ruby_sourcefile, "-e") == 0)
return Qtrue;
return Qfalse;
}
static void
-warn_unless_e_option(NODE *node, const char *str)
+warn_unless_e_option(node, str)
+ NODE *node;
+ const char *str;
{
- if (!e_option_supplied(node)) parser_warn(node, str);
+ if (!e_option_supplied()) parser_warn(node, str);
}
static void
-warning_unless_e_option(NODE *node, const char *str)
+warning_unless_e_option(node, str)
+ NODE *node;
+ const char *str;
{
- if (!e_option_supplied(node)) parser_warning(node, str);
+ if (!e_option_supplied()) parser_warning(node, str);
}
-static NODE *cond0(struct parser_params*,NODE*);
+static void
+fixup_nodes(rootnode)
+ NODE **rootnode;
+{
+ NODE *node, *next, *head;
+
+ for (node = *rootnode; node; node = next) {
+ enum node_type type;
+ VALUE val;
+
+ next = node->nd_next;
+ head = node->nd_head;
+ rb_gc_force_recycle((VALUE)node);
+ *rootnode = next;
+ switch (type = nd_type(head)) {
+ case NODE_DOT2:
+ case NODE_DOT3:
+ val = rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit,
+ type == NODE_DOT3 ? Qtrue : Qfalse);
+ rb_gc_force_recycle((VALUE)head->nd_beg);
+ rb_gc_force_recycle((VALUE)head->nd_end);
+ nd_set_type(head, NODE_LIT);
+ head->nd_lit = val;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static NODE *cond0();
static NODE*
-range_op(struct parser_params *parser, NODE *node)
+range_op(node)
+ NODE *node;
{
enum node_type type;
- if (!e_option_supplied(node)) return node;
if (node == 0) return 0;
- value_expr(node);
- node = cond0(parser, node);
type = nd_type(node);
+ if (type == NODE_NEWLINE) {
+ node = node->nd_next;
+ type = nd_type(node);
+ }
+ value_expr(node);
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
warn_unless_e_option(node, "integer literal in conditional range");
- return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."))));
+ return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")));
}
- return node;
+ return cond0(node);
}
static int
-literal_node(NODE *node)
+literal_node(node)
+ NODE *node;
{
if (!node) return 1; /* same as NODE_NIL */
switch (nd_type(node)) {
@@ -8136,36 +5453,40 @@ literal_node(NODE *node)
}
static NODE*
-cond0(struct parser_params *parser, NODE *node)
+cond0(node)
+ NODE *node;
{
if (node == 0) return 0;
- assign_in_cond(parser, node);
+ assign_in_cond(node);
switch (nd_type(node)) {
case NODE_DSTR:
case NODE_EVSTR:
case NODE_STR:
- rb_warn0("string literal in condition");
+ rb_warn("string literal in condition");
break;
case NODE_DREGX:
case NODE_DREGX_ONCE:
warning_unless_e_option(node, "regex literal in condition");
+ local_cnt('_');
+ local_cnt('~');
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
case NODE_AND:
case NODE_OR:
- node->nd_1st = cond0(parser, node->nd_1st);
- node->nd_2nd = cond0(parser, node->nd_2nd);
+ node->nd_1st = cond0(node->nd_1st);
+ node->nd_2nd = cond0(node->nd_2nd);
break;
case NODE_DOT2:
case NODE_DOT3:
- node->nd_beg = range_op(parser, node->nd_beg);
- node->nd_end = range_op(parser, node->nd_end);
+ node->nd_beg = range_op(node->nd_beg);
+ node->nd_end = range_op(node->nd_end);
if (nd_type(node) == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
else if (nd_type(node) == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
- if (!e_option_supplied(node)) {
+ node->nd_cnt = local_append(internal_id());
+ if (!e_option_supplied()) {
int b = literal_node(node->nd_beg);
int e = literal_node(node->nd_end);
if ((b == 1 && e == 1) || (b + e >= 2 && RTEST(ruby_verbose))) {
@@ -8182,6 +5503,8 @@ cond0(struct parser_params *parser, NODE *node)
if (TYPE(node->nd_lit) == T_REGEXP) {
warn_unless_e_option(node, "regex literal in condition");
nd_set_type(node, NODE_MATCH);
+ local_cnt('_');
+ local_cnt('~');
}
else {
parser_warning(node, "literal in condition");
@@ -8193,14 +5516,22 @@ cond0(struct parser_params *parser, NODE *node)
}
static NODE*
-cond_gen(struct parser_params *parser, NODE *node)
+cond(node)
+ NODE *node;
{
if (node == 0) return 0;
- return cond0(parser, node);
+ value_expr(node);
+ if (nd_type(node) == NODE_NEWLINE){
+ node->nd_next = cond0(node->nd_next);
+ return node;
+ }
+ return cond0(node);
}
static NODE*
-logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right)
+logop(type, left, right)
+ enum node_type type;
+ NODE *left, *right;
{
value_expr(left);
if (left && nd_type(left) == type) {
@@ -8214,41 +5545,66 @@ logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *r
return NEW_NODE(type, left, right, 0);
}
+static int
+cond_negative(nodep)
+ NODE **nodep;
+{
+ NODE *c = *nodep;
+
+ if (!c) return 0;
+ switch (nd_type(c)) {
+ case NODE_NOT:
+ *nodep = c->nd_body;
+ return 1;
+ case NODE_NEWLINE:
+ if (c->nd_next && nd_type(c->nd_next) == NODE_NOT) {
+ c->nd_next = c->nd_next->nd_body;
+ return 1;
+ }
+ }
+ return 0;
+}
+
static void
-no_blockarg(struct parser_params *parser, NODE *node)
+no_blockarg(node)
+ NODE *node;
{
if (node && nd_type(node) == NODE_BLOCK_PASS) {
- compile_error(PARSER_ARG "block argument should not be given");
+ rb_compile_error("block argument should not be given");
}
}
static NODE *
-ret_args_gen(struct parser_params *parser, NODE *node)
+ret_args(node)
+ NODE *node;
{
if (node) {
- no_blockarg(parser, node);
- if (nd_type(node) == NODE_ARRAY) {
- if (node->nd_next == 0) {
- node = node->nd_head;
- }
- else {
- nd_set_type(node, NODE_VALUES);
- }
+ no_blockarg(node);
+ if (nd_type(node) == NODE_ARRAY && node->nd_next == 0) {
+ node = node->nd_head;
+ }
+ if (node && nd_type(node) == NODE_SPLAT) {
+ node = NEW_SVALUE(node);
}
}
return node;
}
static NODE *
-new_yield_gen(struct parser_params *parser, NODE *node)
+new_yield(node)
+ NODE *node;
{
long state = Qtrue;
if (node) {
- no_blockarg(parser, node);
- if (node && nd_type(node) == NODE_SPLAT) {
- state = Qtrue;
- }
+ no_blockarg(node);
+ if (nd_type(node) == NODE_ARRAY && node->nd_next == 0) {
+ node = node->nd_head;
+ state = Qfalse;
+ }
+ if (node && nd_type(node) == NODE_SPLAT) {
+ state = Qtrue;
+ }
}
else {
state = Qfalse;
@@ -8257,7 +5613,8 @@ new_yield_gen(struct parser_params *parser, NODE *node)
}
static NODE*
-negate_lit(NODE *node)
+negate_lit(node)
+ NODE *node;
{
switch (TYPE(node->nd_lit)) {
case T_FIXNUM:
@@ -8267,7 +5624,7 @@ negate_lit(NODE *node)
node->nd_lit = rb_funcall(node->nd_lit,tUMINUS,0,0);
break;
case T_FLOAT:
- RFLOAT(node->nd_lit)->float_value = -RFLOAT_VALUE(node->nd_lit);
+ RFLOAT(node->nd_lit)->value = -RFLOAT(node->nd_lit)->value;
break;
default:
break;
@@ -8276,7 +5633,9 @@ negate_lit(NODE *node)
}
static NODE *
-arg_blk_pass(NODE *node1, NODE *node2)
+arg_blk_pass(node1, node2)
+ NODE *node1;
+ NODE *node2;
{
if (node2) {
node2->nd_head = node1;
@@ -8286,384 +5645,341 @@ arg_blk_pass(NODE *node1, NODE *node2)
}
static NODE*
-new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, ID b)
+arg_prepend(node1, node2)
+ NODE *node1, *node2;
{
- int saved_line = ruby_sourceline;
- NODE *node;
- NODE *i1, *i2 = 0;
+ switch (nd_type(node2)) {
+ case NODE_ARRAY:
+ return list_concat(NEW_LIST(node1), node2);
- node = NEW_ARGS(m ? m->nd_plen : 0, o);
- i1 = m ? m->nd_next : 0;
- node->nd_next = NEW_ARGS_AUX(r, b);
+ case NODE_SPLAT:
+ return arg_concat(node1, node2->nd_head);
- if (p) {
- i2 = p->nd_next;
- node->nd_next->nd_next = NEW_ARGS_AUX(p->nd_pid, p->nd_plen);
+ case NODE_BLOCK_PASS:
+ node2->nd_body = arg_prepend(node1, node2->nd_body);
+ return node2;
+
+ default:
+ rb_bug("unknown nodetype(%d) for arg_prepend", nd_type(node2));
}
- else if (i1) {
- node->nd_next->nd_next = NEW_ARGS_AUX(0, 0);
+ return 0; /* not reached */
+}
+
+static NODE*
+new_call(r,m,a)
+ NODE *r;
+ ID m;
+ NODE *a;
+{
+ if (a && nd_type(a) == NODE_BLOCK_PASS) {
+ a->nd_iter = NEW_CALL(r,m,a->nd_head);
+ return a;
}
- if (i1 || i2) {
- node->nd_next->nd_next->nd_next = NEW_NODE(NODE_AND, i1, i2, 0);
+ return NEW_CALL(r,m,a);
+}
+
+static NODE*
+new_fcall(m,a)
+ ID m;
+ NODE *a;
+{
+ if (a && nd_type(a) == NODE_BLOCK_PASS) {
+ a->nd_iter = NEW_FCALL(m,a->nd_head);
+ return a;
}
- ruby_sourceline = saved_line;
- return node;
+ return NEW_FCALL(m,a);
+}
+
+static NODE*
+new_super(a)
+ NODE *a;
+{
+ if (a && nd_type(a) == NODE_BLOCK_PASS) {
+ a->nd_iter = NEW_SUPER(a->nd_head);
+ return a;
+ }
+ return NEW_SUPER(a);
}
+static struct local_vars {
+ ID *tbl;
+ int nofree;
+ int cnt;
+ int dlev;
+ struct RVarmap* dyna_vars;
+ struct local_vars *prev;
+} *lvtbl;
+
static void
-local_push_gen(struct parser_params *parser, int inherit_dvars)
+local_push(top)
+ int top;
{
struct local_vars *local;
local = ALLOC(struct local_vars);
local->prev = lvtbl;
- local->args = vtable_alloc(0);
- local->vars = vtable_alloc(inherit_dvars ? DVARS_INHERIT : DVARS_TOPSCOPE);
+ local->nofree = 0;
+ local->cnt = 0;
+ local->tbl = 0;
+ local->dlev = 0;
+ local->dyna_vars = ruby_dyna_vars;
lvtbl = local;
+ if (!top) {
+ /* preserve reference for GC, but link should be cut. */
+ rb_dvar_push(0, (VALUE)ruby_dyna_vars);
+ ruby_dyna_vars->next = 0;
+ }
}
static void
-local_pop_gen(struct parser_params *parser)
+local_pop()
{
struct local_vars *local = lvtbl->prev;
- vtable_free(lvtbl->args);
- vtable_free(lvtbl->vars);
- xfree(lvtbl);
- lvtbl = local;
-}
-static ID*
-vtable_tblcpy(ID *buf, const struct vtable *src)
-{
- int i, cnt = vtable_size(src);
-
- if (cnt > 0) {
- buf[0] = cnt;
- for (i = 0; i < cnt; i++) {
- buf[i] = src->tbl[i];
- }
- return buf;
+ if (lvtbl->tbl) {
+ if (!lvtbl->nofree) xfree(lvtbl->tbl);
+ else lvtbl->tbl[0] = lvtbl->cnt;
}
- return 0;
+ ruby_dyna_vars = lvtbl->dyna_vars;
+ xfree(lvtbl);
+ lvtbl = local;
}
static ID*
-local_tbl_gen(struct parser_params *parser)
+local_tbl()
{
- int cnt = vtable_size(lvtbl->args) + vtable_size(lvtbl->vars);
- ID *buf;
-
- if (cnt <= 0) return 0;
- buf = ALLOC_N(ID, cnt + 1);
- vtable_tblcpy(buf+1, lvtbl->args);
- vtable_tblcpy(buf+vtable_size(lvtbl->args)+1, lvtbl->vars);
- buf[0] = cnt;
- return buf;
+ lvtbl->nofree = 1;
+ return lvtbl->tbl;
}
-#include "debug.h"
static int
-arg_var_gen(struct parser_params *parser, ID id)
+local_append(id)
+ ID id;
{
- vtable_add(lvtbl->args, id);
- return vtable_size(lvtbl->args) - 1;
+ if (lvtbl->tbl == 0) {
+ lvtbl->tbl = ALLOC_N(ID, 4);
+ lvtbl->tbl[0] = 0;
+ lvtbl->tbl[1] = '_';
+ lvtbl->tbl[2] = '~';
+ lvtbl->cnt = 2;
+ if (id == '_') return 0;
+ if (id == '~') return 1;
+ }
+ else {
+ REALLOC_N(lvtbl->tbl, ID, lvtbl->cnt+2);
+ }
+
+ lvtbl->tbl[lvtbl->cnt+1] = id;
+ return lvtbl->cnt++;
}
static int
-local_var_gen(struct parser_params *parser, ID id)
+local_cnt(id)
+ ID id;
{
- vtable_add(lvtbl->vars, id);
- return vtable_size(lvtbl->vars) - 1;
+ int cnt, max;
+
+ if (id == 0) return lvtbl->cnt;
+
+ for (cnt=1, max=lvtbl->cnt+1; cnt<max;cnt++) {
+ if (lvtbl->tbl[cnt] == id) return cnt-1;
+ }
+ return local_append(id);
}
static int
-local_id_gen(struct parser_params *parser, ID id)
+local_id(id)
+ ID id;
{
- struct vtable *vars, *args;
-
- vars = lvtbl->vars;
- args = lvtbl->args;
+ int i, max;
- while (vars && POINTER_P(vars->prev)) {
- vars = vars->prev;
- args = args->prev;
+ if (lvtbl == 0) return Qfalse;
+ for (i=3, max=lvtbl->cnt+1; i<max; i++) {
+ if (lvtbl->tbl[i] == id) return Qtrue;
}
+ return Qfalse;
+}
- if (vars && vars->prev == DVARS_INHERIT) {
- return rb_local_defined(id);
+static void
+top_local_init()
+{
+ local_push(1);
+ lvtbl->cnt = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0;
+ if (lvtbl->cnt > 0) {
+ lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt+3);
+ MEMCPY(lvtbl->tbl, ruby_scope->local_tbl, ID, lvtbl->cnt+1);
}
else {
- return (vtable_included(args, id) ||
- vtable_included(vars, id));
+ lvtbl->tbl = 0;
}
+ if (ruby_dyna_vars)
+ lvtbl->dlev = 1;
+ else
+ lvtbl->dlev = 0;
}
static void
-dyna_push_gen(struct parser_params *parser)
+top_local_setup()
{
- lvtbl->args = vtable_alloc(lvtbl->args);
- lvtbl->vars = vtable_alloc(lvtbl->vars);
-}
+ int len = lvtbl->cnt;
+ int i;
-static void
-dyna_pop_gen(struct parser_params *parser)
-{
- struct vtable *tmp;
-
- tmp = lvtbl->args;
- lvtbl->args = lvtbl->args->prev;
- vtable_free(tmp);
- tmp = lvtbl->vars;
- lvtbl->vars = lvtbl->vars->prev;
- vtable_free(tmp);
-}
+ if (len > 0) {
+ i = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0;
-static int
-dyna_in_block_gen(struct parser_params *parser)
-{
- return POINTER_P(lvtbl->vars) && lvtbl->vars->prev != DVARS_TOPSCOPE;
+ if (i < len) {
+ if (i == 0 || (ruby_scope->flags & SCOPE_MALLOC) == 0) {
+ VALUE *vars = ALLOC_N(VALUE, len+1);
+ if (ruby_scope->local_vars) {
+ *vars++ = ruby_scope->local_vars[-1];
+ MEMCPY(vars, ruby_scope->local_vars, VALUE, i);
+ rb_mem_clear(vars+i, len-i);
+ }
+ else {
+ *vars++ = 0;
+ rb_mem_clear(vars, len);
+ }
+ ruby_scope->local_vars = vars;
+ ruby_scope->flags |= SCOPE_MALLOC;
+ }
+ else {
+ VALUE *vars = ruby_scope->local_vars-1;
+ REALLOC_N(vars, VALUE, len+1);
+ ruby_scope->local_vars = vars+1;
+ rb_mem_clear(ruby_scope->local_vars+i, len-i);
+ }
+ if (ruby_scope->local_tbl && ruby_scope->local_vars[-1] == 0) {
+ if (!(ruby_scope->flags & SCOPE_CLONE))
+ xfree(ruby_scope->local_tbl);
+ }
+ ruby_scope->local_vars[-1] = 0; /* no reference needed */
+ ruby_scope->local_tbl = local_tbl();
+ }
+ }
+ local_pop();
}
-static int
-dvar_defined_gen(struct parser_params *parser, ID id)
-{
- struct vtable *vars, *args;
+#define DVAR_USED FL_USER6
- args = lvtbl->args;
- vars = lvtbl->vars;
+static VALUE
+dyna_var_lookup(id)
+ ID id;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
- while (POINTER_P(vars)) {
- if (vtable_included(args, id)) {
- return 1;
- }
- if (vtable_included(vars, id)) {
- return 1;
+ while (vars) {
+ if (vars->id == id) {
+ FL_SET(vars, DVAR_USED);
+ return Qtrue;
}
- args = args->prev;
- vars = vars->prev;
+ vars = vars->next;
}
-
- if (vars == DVARS_INHERIT) {
- return rb_dvar_defined(id);
- }
-
- return 0;
-}
-
-static int
-dvar_curr_gen(struct parser_params *parser, ID id)
-{
- return (vtable_included(lvtbl->args, id) ||
- vtable_included(lvtbl->vars, id));
+ return Qfalse;
}
-VALUE rb_reg_compile(VALUE str, int options);
-VALUE rb_reg_check_preprocess(VALUE);
-
-static void
-reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
+static struct RVarmap*
+dyna_push()
{
- int c = RE_OPTION_ENCODING_IDX(options);
+ struct RVarmap* vars = ruby_dyna_vars;
- if (c) {
- int opt, idx;
- rb_char_to_option_kcode(c, &opt, &idx);
- if (idx != ENCODING_GET(str) && ENCODING_GET(str) &&
- rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
- compile_error(PARSER_ARG
- "regexp encoding option '%c' differs from source encoding '%s'",
- c, rb_enc_name(rb_enc_get(str)));
- }
- ENCODING_SET(str, idx);
- }
+ rb_dvar_push(0, 0);
+ lvtbl->dlev++;
+ return vars;
}
static void
-reg_fragment_check_gen(struct parser_params* parser, VALUE str, int options)
+dyna_pop(vars)
+ struct RVarmap* vars;
{
- VALUE err;
- reg_fragment_setenc_gen(parser, str, options);
- err = rb_reg_check_preprocess(str);
- if (err != Qnil) {
- err = rb_obj_as_string(err);
- compile_error(PARSER_ARG "%s", RSTRING_PTR(err));
- RB_GC_GUARD(err);
- }
+ lvtbl->dlev--;
+ ruby_dyna_vars = vars;
}
-typedef struct {
- struct parser_params* parser;
- rb_encoding *enc;
- NODE *succ_block;
- NODE *fail_block;
- int num;
-} reg_named_capture_assign_t;
-
static int
-reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
- int back_num, int *back_refs, OnigRegex regex, void *arg0)
+dyna_in_block()
{
- reg_named_capture_assign_t *arg = (reg_named_capture_assign_t*)arg0;
- struct parser_params* parser = arg->parser;
- rb_encoding *enc = arg->enc;
- int len = name_end - name;
- const char *s = (const char *)name;
- ID var;
-
- arg->num++;
-
- if (arg->succ_block == 0) {
- arg->succ_block = NEW_BEGIN(0);
- arg->fail_block = NEW_BEGIN(0);
- }
-
- if (!len || (*name != '_' && ISASCII(*name) && !rb_enc_islower(*name, enc)) ||
- rb_reserved_word(s, len) || !rb_enc_symname2_p(s, len, enc)) {
- return ST_CONTINUE;
- }
- var = rb_intern3(s, len, enc);
- if (dvar_defined(var) || local_id(var)) {
- rb_warningS("named capture conflicts a local variable - %s",
- rb_id2name(var));
- }
- arg->succ_block = block_append(arg->succ_block,
- newline_node(node_assign(assignable(var,0),
- NEW_CALL(
- gettable(rb_intern("$~")),
- idAREF,
- NEW_LIST(NEW_LIT(ID2SYM(var))))
- )));
- arg->fail_block = block_append(arg->fail_block,
- newline_node(node_assign(assignable(var,0), NEW_LIT(Qnil))));
- return ST_CONTINUE;
+ return (lvtbl->dlev > 0);
}
static NODE *
-reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, NODE *match)
-{
- reg_named_capture_assign_t arg;
-
- arg.parser = parser;
- arg.enc = rb_enc_get(regexp);
- arg.succ_block = 0;
- arg.fail_block = 0;
- arg.num = 0;
- onig_foreach_name(RREGEXP(regexp)->ptr, reg_named_capture_assign_iter, (void*)&arg);
-
- if (arg.num == 0)
- return match;
-
- return
- block_append(
- newline_node(match),
- NEW_IF(gettable(rb_intern("$~")),
- block_append(
- newline_node(arg.succ_block),
- newline_node(
- NEW_CALL(
- gettable(rb_intern("$~")),
- rb_intern("begin"),
- NEW_LIST(NEW_LIT(INT2FIX(0)))))),
- block_append(
- newline_node(arg.fail_block),
- newline_node(
- NEW_LIT(Qnil)))));
-}
-
-static VALUE
-reg_compile_gen(struct parser_params* parser, VALUE str, int options)
+dyna_init(node, pre)
+ NODE *node;
+ struct RVarmap *pre;
{
- VALUE re;
+ struct RVarmap *post = ruby_dyna_vars;
+ NODE *var;
- reg_fragment_setenc(str, options);
- re = rb_reg_compile(str, options & RE_OPTION_MASK);
- if (NIL_P(re)) {
- RB_GC_GUARD(re) = rb_obj_as_string(rb_errinfo());
- compile_error(PARSER_ARG "%s", RSTRING_PTR(re));
- return Qnil;
+ if (!node || !post || pre == post) return node;
+ for (var = 0; post != pre && post->id; post = post->next) {
+ if (FL_TEST(post, DVAR_USED)) {
+ var = NEW_DASGN_CURR(post->id, var);
+ }
}
- return re;
+ return block_append(var, node);
}
-void
-rb_gc_mark_parser(void)
+int
+ruby_parser_stack_on_heap()
{
+#if defined(YYMALLOC)
+ (void)rb_parser_realloc;
+ (void)rb_parser_calloc;
+ (void)nodetype;
+ (void)nodeline;
+ return Qfalse;
+#else
+ return Qtrue;
+#endif
}
-NODE*
-rb_parser_append_print(VALUE vparser, NODE *node)
+void
+rb_gc_mark_parser()
{
- NODE *prelude = 0;
- NODE *scope = node;
- struct parser_params *parser;
-
- if (!node) return node;
-
- Data_Get_Struct(vparser, struct parser_params, parser);
-
- node = node->nd_body;
+#if defined YYMALLOC
+ rb_gc_mark((VALUE)parser_heap);
+#elif defined yystacksize
+ if (yyvsp) rb_gc_mark_locations((VALUE *)yyvs, (VALUE *)yyvsp);
+#endif
- if (nd_type(node) == NODE_PRELUDE) {
- prelude = node;
- node = node->nd_body;
- }
+ if (!ruby_in_compile) return;
- node = block_append(node,
- NEW_FCALL(rb_intern("print"),
- NEW_ARRAY(NEW_GVAR(rb_intern("$_")))));
- if (prelude) {
- prelude->nd_body = node;
- scope->nd_body = prelude;
- }
- else {
- scope->nd_body = node;
- }
-
- return scope;
+ rb_gc_mark_maybe((VALUE)yylval.node);
+ rb_gc_mark(ruby_debug_lines);
+ rb_gc_mark(lex_lastline);
+ rb_gc_mark(lex_input);
+ rb_gc_mark((VALUE)lex_strterm);
+ rb_gc_mark((VALUE)deferred_nodes);
}
-NODE *
-rb_parser_while_loop(VALUE vparser, NODE *node, int chop, int split)
+void
+rb_parser_append_print()
{
- NODE *prelude = 0;
- NODE *scope = node;
- struct parser_params *parser;
-
- if (!node) return node;
-
- Data_Get_Struct(vparser, struct parser_params, parser);
-
- node = node->nd_body;
+ ruby_eval_tree =
+ block_append(ruby_eval_tree,
+ NEW_FCALL(rb_intern("print"),
+ NEW_ARRAY(NEW_GVAR(rb_intern("$_")))));
+}
- if (nd_type(node) == NODE_PRELUDE) {
- prelude = node;
- node = node->nd_body;
- }
+void
+rb_parser_while_loop(chop, split)
+ int chop, split;
+{
if (split) {
- node = block_append(NEW_GASGN(rb_intern("$F"),
- NEW_CALL(NEW_GVAR(rb_intern("$_")),
- rb_intern("split"), 0)),
- node);
+ ruby_eval_tree =
+ block_append(NEW_GASGN(rb_intern("$F"),
+ NEW_CALL(NEW_GVAR(rb_intern("$_")),
+ rb_intern("split"), 0)),
+ ruby_eval_tree);
}
if (chop) {
- node = block_append(NEW_CALL(NEW_GVAR(rb_intern("$_")),
- rb_intern("chop!"), 0), node);
- }
-
- node = NEW_OPT_N(node);
-
- if (prelude) {
- prelude->nd_body = node;
- scope->nd_body = prelude;
- }
- else {
- scope->nd_body = node;
+ ruby_eval_tree =
+ block_append(NEW_CALL(NEW_GVAR(rb_intern("$_")),
+ rb_intern("chop!"), 0), ruby_eval_tree);
}
-
- return scope;
+ ruby_eval_tree = NEW_OPT_N(ruby_eval_tree);
}
-static const struct {
+static struct {
ID token;
const char *name;
} op_tbl[] = {
@@ -8679,10 +5995,11 @@ static const struct {
{tPOW, "**"},
{tUPLUS, "+@"},
{tUMINUS, "-@"},
+ {tUPLUS, "+(unary)"},
+ {tUMINUS, "-(unary)"},
{'|', "|"},
{'^', "^"},
{'&', "&"},
- {'!', "!"},
{tCMP, "<=>"},
{'>', ">"},
{tGEQ, ">="},
@@ -8693,8 +6010,12 @@ static const struct {
{tNEQ, "!="},
{tMATCH, "=~"},
{tNMATCH, "!~"},
- {'~', "~"},
{'!', "!"},
+ {'~', "~"},
+ {'!', "!(unary)"},
+ {'~', "~(unary)"},
+ {'!', "!@"},
+ {'~', "~@"},
{tAREF, "[]"},
{tASET, "[]="},
{tLSHFT, "<<"},
@@ -8704,77 +6025,28 @@ static const struct {
{0, 0}
};
-static struct symbols {
- ID last_id;
- st_table *sym_id;
- st_table *id_str;
- st_table *ivar2_id;
- st_table *id_ivar2;
- VALUE op_sym[tLAST_TOKEN];
-} global_symbols = {tLAST_TOKEN >> ID_SCOPE_SHIFT};
-
-static const struct st_hash_type symhash = {
- rb_str_cmp,
- rb_str_hash,
-};
-
-struct ivar2_key {
- ID id;
- VALUE klass;
-};
-
-static int
-ivar2_cmp(struct ivar2_key *key1, struct ivar2_key *key2)
-{
- if (key1->id == key2->id && key1->klass == key2->klass) {
- return 0;
- }
- return 1;
-}
-
-static int
-ivar2_hash(struct ivar2_key *key)
-{
- return (key->id << 8) ^ (key->klass >> 2);
-}
-
-static const struct st_hash_type ivar2_hash_type = {
- ivar2_cmp,
- ivar2_hash,
-};
+static st_table *sym_tbl;
+static st_table *sym_rev_tbl;
void
-Init_sym(void)
+Init_sym()
{
- global_symbols.sym_id = st_init_table_with_size(&symhash, 1000);
- global_symbols.id_str = st_init_numtable_with_size(1000);
- global_symbols.ivar2_id = st_init_table_with_size(&ivar2_hash_type, 1000);
- global_symbols.id_ivar2 = st_init_numtable_with_size(1000);
- rb_intern2("", 0);
+ sym_tbl = st_init_strtable_with_size(200);
+ sym_rev_tbl = st_init_numtable_with_size(200);
}
-void
-rb_gc_mark_symbols(void)
-{
- rb_mark_tbl(global_symbols.id_str);
- rb_gc_mark_locations(global_symbols.op_sym,
- global_symbols.op_sym + tLAST_TOKEN);
-}
+static ID last_id = tLAST_TOKEN;
static ID
-internal_id_gen(struct parser_params *parser)
+internal_id()
{
- ID id = (ID)vtable_size(lvtbl->args) + (ID)vtable_size(lvtbl->vars);
- id += ((tLAST_TOKEN - ID_INTERNAL) >> ID_SCOPE_SHIFT) + 1;
- return ID_INTERNAL | (id << ID_SCOPE_SHIFT);
+ return ID_INTERNAL | (++last_id << ID_SCOPE_SHIFT);
}
static int
-is_special_global_name(const char *m, const char *e, rb_encoding *enc)
+is_special_global_name(m)
+ const char *m;
{
- int mb = 0;
-
- if (m >= e) return 0;
switch (*m) {
case '~': case '*': case '$': case '?': case '!': case '@':
case '/': case '\\': case ';': case ',': case '.': case '=':
@@ -8785,38 +6057,20 @@ is_special_global_name(const char *m, const char *e, rb_encoding *enc)
break;
case '-':
++m;
- if (m < e && is_identchar(m, e, enc)) {
- if (!ISASCII(*m)) mb = 1;
- m += rb_enc_mbclen(m, e, enc);
- }
+ if (is_identchar(*m)) m += mbclen(*m);
break;
default:
- if (!rb_enc_isdigit(*m, enc)) return 0;
- do {
- if (!ISASCII(*m)) mb = 1;
- ++m;
- } while (rb_enc_isdigit(*m, enc));
+ if (!ISDIGIT(*m)) return 0;
+ do ++m; while (ISDIGIT(*m));
}
- return m == e ? mb + 1 : 0;
-}
-
-int
-rb_symname_p(const char *name)
-{
- return rb_enc_symname_p(name, rb_enc_from_index(0));
-}
-
-int
-rb_enc_symname_p(const char *name, rb_encoding *enc)
-{
- return rb_enc_symname2_p(name, strlen(name), enc);
+ return !*m;
}
int
-rb_enc_symname2_p(const char *name, int len, rb_encoding *enc)
+rb_symname_p(name)
+ const char *name;
{
const char *m = name;
- const char *e = m + len;
int localid = Qfalse;
if (!m) return Qfalse;
@@ -8825,7 +6079,7 @@ rb_enc_symname2_p(const char *name, int len, rb_encoding *enc)
return Qfalse;
case '$':
- if (is_special_global_name(++m, e, enc)) return Qtrue;
+ if (is_special_global_name(++m)) return Qtrue;
goto id;
case '@':
@@ -8872,11 +6126,10 @@ rb_enc_symname2_p(const char *name, int len, rb_encoding *enc)
break;
default:
- localid = !rb_enc_isupper(*m, enc);
+ localid = !ISUPPER(*m);
id:
- if (m >= e || (*m != '_' && !rb_enc_isalpha(*m, enc) && ISASCII(*m)))
- return Qfalse;
- while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
+ if (*m != '_' && !ISALPHA(*m) && !ismbchar(*m)) return Qfalse;
+ while (is_identchar(*m)) m += mbclen(*m);
if (localid) {
switch (*m) {
case '!': case '?': case '=': ++m;
@@ -8887,39 +6140,37 @@ rb_enc_symname2_p(const char *name, int len, rb_encoding *enc)
return *m ? Qfalse : Qtrue;
}
+int
+rb_sym_interned_p(str)
+ VALUE str;
+{
+ ID id;
+
+ if (st_lookup(sym_tbl, (st_data_t)RSTRING(str)->ptr, (st_data_t *)&id))
+ return Qtrue;
+ return Qfalse;
+}
+
ID
-rb_intern3(const char *name, long len, rb_encoding *enc)
+rb_intern(name)
+ const char *name;
{
const char *m = name;
- const char *e = m + len;
- VALUE str;
ID id;
int last;
- int mb;
- struct RString fake_str;
- fake_str.basic.flags = T_STRING|RSTRING_NOEMBED|FL_FREEZE;
- fake_str.basic.klass = rb_cString;
- fake_str.as.heap.len = len;
- fake_str.as.heap.ptr = (char *)name;
- fake_str.as.heap.aux.capa = len;
- str = (VALUE)&fake_str;
- rb_enc_associate(str, enc);
-
- if (st_lookup(global_symbols.sym_id, str, (st_data_t *)&id))
+
+ if (st_lookup(sym_tbl, (st_data_t)name, (st_data_t *)&id))
return id;
- last = len-1;
+ last = strlen(name)-1;
id = 0;
- switch (*m) {
+ switch (*name) {
case '$':
id |= ID_GLOBAL;
- if ((mb = is_special_global_name(++m, e, enc)) != 0) {
- if (!--mb) enc = rb_enc_from_index(0);
- goto new_id;
- }
+ if (is_special_global_name(++m)) goto new_id;
break;
case '@':
- if (m[1] == '@') {
+ if (name[1] == '@') {
m++;
id |= ID_CLASS;
}
@@ -8929,31 +6180,33 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
m++;
break;
default:
- if (m[0] != '_' && rb_enc_isascii((unsigned char)m[0], enc)
- && !rb_enc_isalnum(m[0], enc)) {
+ if (name[0] != '_' && ISASCII(name[0]) && !ISALNUM(name[0])) {
/* operators */
int i;
for (i=0; op_tbl[i].token; i++) {
- if (*op_tbl[i].name == *m &&
- strcmp(op_tbl[i].name, m) == 0) {
+ if (*op_tbl[i].name == *name &&
+ strcmp(op_tbl[i].name, name) == 0) {
id = op_tbl[i].token;
- goto id_register;
+ goto id_regist;
}
}
}
- if (m[last] == '=') {
+ if (name[last] == '=') {
/* attribute assignment */
- id = rb_intern3(name, last, enc);
+ char *buf = ALLOCA_N(char,last+1);
+
+ strncpy(buf, name, last);
+ buf[last] = '\0';
+ id = rb_intern(buf);
if (id > tLAST_TOKEN && !is_attrset_id(id)) {
- enc = rb_enc_get(rb_id2str(id));
id = rb_id_attrset(id);
- goto id_register;
+ goto id_regist;
}
id = ID_ATTRSET;
}
- else if (rb_enc_isupper(m[0], enc)) {
+ else if (ISUPPER(name[0])) {
id = ID_CONST;
}
else {
@@ -8961,124 +6214,66 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
}
break;
}
- mb = 0;
- if (!rb_enc_isdigit(*m, enc)) {
- while (m <= name + last && is_identchar(m, e, enc)) {
- if (!ISASCII(*m)) mb = 1;
- m += rb_enc_mbclen(m, e, enc);
- }
- }
- if (m - name < len) id = ID_JUNK;
- if (enc != rb_ascii8bit_encoding()) {
- /*
- * this clause makes sense only when called from other than
- * rb_intern_str() taking care of code-range.
- */
- if (!mb) {
- for (; m <= name + len; ++m) {
- if (!ISASCII(*m)) goto mbstr;
- }
- enc = rb_ascii8bit_encoding();
+ if (!ISDIGIT(*m)) {
+ while (m <= name + last && is_identchar(*m)) {
+ m += mbclen(*m);
}
- mbstr:;
}
+ if (*m) id = ID_JUNK;
new_id:
- id |= ++global_symbols.last_id << ID_SCOPE_SHIFT;
- id_register:
- str = rb_enc_str_new(name, len, enc);
- OBJ_FREEZE(str);
- st_add_direct(global_symbols.sym_id, (st_data_t)str, id);
- st_add_direct(global_symbols.id_str, id, (st_data_t)str);
+ id |= ++last_id << ID_SCOPE_SHIFT;
+ id_regist:
+ name = strdup(name);
+ st_add_direct(sym_tbl, (st_data_t)name, id);
+ st_add_direct(sym_rev_tbl, id, (st_data_t)name);
return id;
}
-ID
-rb_intern2(const char *name, long len)
-{
- return rb_intern3(name, len, rb_enc_from_index(0));
-}
-
-ID
-rb_intern(const char *name)
-{
- return rb_intern2(name, strlen(name));
-}
-
-ID
-rb_intern_str(VALUE str)
-{
- int idx = 0;
+const char *
+rb_id2name(id)
ID id;
-
- if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
- idx = rb_enc_get_index(str);
- }
- id = rb_intern3(RSTRING_PTR(str), RSTRING_LEN(str),
- rb_enc_from_index(idx));
- RB_GC_GUARD(str);
- return id;
-}
-
-VALUE
-rb_id2str(ID id)
{
+ const char *name;
st_data_t data;
if (id < tLAST_TOKEN) {
- int i = 0;
+ int i;
for (i=0; op_tbl[i].token; i++) {
- if (op_tbl[i].token == id) {
- VALUE str = global_symbols.op_sym[i];
- if (!str) {
- str = rb_str_new2(op_tbl[i].name);
- OBJ_FREEZE(str);
- global_symbols.op_sym[i] = str;
- }
- return str;
- }
+ if (op_tbl[i].token == id)
+ return op_tbl[i].name;
}
}
- if (st_lookup(global_symbols.id_str, id, &data)) {
- VALUE str = (VALUE)data;
- if (RBASIC(str)->klass == 0)
- RBASIC(str)->klass = rb_cString;
- return str;
- }
+ if (st_lookup(sym_rev_tbl, id, &data))
+ return (char *)data;
if (is_attrset_id(id)) {
ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL;
- VALUE str;
- while (!(str = rb_id2str(id2))) {
- if (!is_local_id(id2)) return 0;
+ again:
+ name = rb_id2name(id2);
+ if (name) {
+ char *buf = ALLOCA_N(char, strlen(name)+2);
+
+ strcpy(buf, name);
+ strcat(buf, "=");
+ rb_intern(buf);
+ return rb_id2name(id);
+ }
+ if (is_local_id(id2)) {
id2 = (id & ~ID_SCOPE_MASK) | ID_CONST;
+ goto again;
}
- str = rb_str_dup(str);
- rb_str_cat(str, "=", 1);
- rb_intern_str(str);
- if (st_lookup(global_symbols.id_str, id, &data)) {
- VALUE str = (VALUE)data;
- if (RBASIC(str)->klass == 0)
- RBASIC(str)->klass = rb_cString;
- return str;
- }
}
return 0;
}
-const char *
-rb_id2name(ID id)
-{
- VALUE str = rb_id2str(id);
-
- if (!str) return 0;
- return RSTRING_PTR(str);
-}
-
static int
-symbols_i(VALUE sym, ID value, VALUE ary)
+symbols_i(key, value, ary)
+ char *key;
+ ID value;
+ VALUE ary;
{
rb_ary_push(ary, ID2SYM(value));
return ST_CONTINUE;
@@ -9087,254 +6282,136 @@ symbols_i(VALUE sym, ID value, VALUE ary)
/*
* call-seq:
* Symbol.all_symbols => array
- *
+ *
* Returns an array of all the symbols currently in Ruby's symbol
* table.
- *
+ *
* Symbol.all_symbols.size #=> 903
* Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
- * :chown, :EOFError, :$;, :String,
- * :LOCK_SH, :"setuid?", :$<,
- * :default_proc, :compact, :extend,
+ * :chown, :EOFError, :$;, :String,
+ * :LOCK_SH, :"setuid?", :$<,
+ * :default_proc, :compact, :extend,
* :Tms, :getwd, :$=, :ThreadGroup,
* :wait2, :$>]
*/
VALUE
-rb_sym_all_symbols(void)
+rb_sym_all_symbols()
{
- VALUE ary = rb_ary_new2(global_symbols.sym_id->num_entries);
+ VALUE ary = rb_ary_new2(sym_tbl->num_entries);
- st_foreach(global_symbols.sym_id, symbols_i, ary);
+ st_foreach(sym_tbl, symbols_i, ary);
return ary;
}
int
-rb_is_const_id(ID id)
+rb_is_const_id(id)
+ ID id;
{
if (is_const_id(id)) return Qtrue;
return Qfalse;
}
int
-rb_is_class_id(ID id)
+rb_is_class_id(id)
+ ID id;
{
if (is_class_id(id)) return Qtrue;
return Qfalse;
}
int
-rb_is_instance_id(ID id)
+rb_is_instance_id(id)
+ ID id;
{
if (is_instance_id(id)) return Qtrue;
return Qfalse;
}
int
-rb_is_local_id(ID id)
+rb_is_local_id(id)
+ ID id;
{
if (is_local_id(id)) return Qtrue;
return Qfalse;
}
int
-rb_is_junk_id(ID id)
+rb_is_junk_id(id)
+ ID id;
{
if (is_junk_id(id)) return Qtrue;
return Qfalse;
}
-#endif /* !RIPPER */
-
static void
-parser_initialize(struct parser_params *parser)
+special_local_set(c, val)
+ char c;
+ VALUE val;
{
- parser->eofp = Qfalse;
-
- parser->parser_lex_strterm = 0;
- parser->parser_cond_stack = 0;
- parser->parser_cmdarg_stack = 0;
- parser->parser_class_nest = 0;
- parser->parser_paren_nest = 0;
- parser->parser_lpar_beg = 0;
- parser->parser_in_single = 0;
- parser->parser_in_def = 0;
- parser->parser_in_defined = 0;
- parser->parser_compile_for_eval = 0;
- parser->parser_cur_mid = 0;
- parser->parser_tokenbuf = NULL;
- parser->parser_tokidx = 0;
- parser->parser_toksiz = 0;
- parser->parser_heredoc_end = 0;
- parser->parser_command_start = Qtrue;
- parser->parser_lex_pbeg = 0;
- parser->parser_lex_p = 0;
- parser->parser_lex_pend = 0;
- parser->parser_lvtbl = 0;
- parser->parser_ruby__end__seen = 0;
- parser->parser_ruby_sourcefile = 0;
-#ifndef RIPPER
- parser->is_ripper = 0;
- parser->parser_eval_tree_begin = 0;
- parser->parser_eval_tree = 0;
-#else
- parser->is_ripper = 1;
- parser->parser_ruby_sourcefile_string = Qnil;
- parser->delayed = Qnil;
+ int cnt;
- parser->result = Qnil;
- parser->parsing_thread = Qnil;
- parser->toplevel_p = Qtrue;
-#endif
-#ifdef YYMALLOC
- parser->heap = NULL;
-#endif
- parser->enc = rb_enc_from_index(0);
+ top_local_init();
+ cnt = local_cnt(c);
+ top_local_setup();
+ ruby_scope->local_vars[cnt] = val;
}
-extern void rb_mark_source_filename(char *);
-
-#ifdef RIPPER
-#define parser_mark ripper_parser_mark
-#define parser_free ripper_parser_free
-#endif
-
-static void
-parser_mark(void *ptr)
+VALUE
+rb_backref_get()
{
- struct parser_params *p = (struct parser_params*)ptr;
-
- rb_gc_mark((VALUE)p->parser_lex_strterm);
- rb_gc_mark(p->parser_lex_input);
- rb_gc_mark(p->parser_lex_lastline);
- rb_gc_mark(p->parser_lex_nextline);
-#ifndef RIPPER
- rb_gc_mark((VALUE)p->parser_eval_tree_begin) ;
- rb_gc_mark((VALUE)p->parser_eval_tree) ;
- rb_gc_mark(p->debug_lines);
- rb_mark_source_filename(p->parser_ruby_sourcefile);
-#else
- rb_gc_mark(p->parser_ruby_sourcefile_string);
- rb_gc_mark(p->delayed);
- rb_gc_mark(p->value);
- rb_gc_mark(p->result);
- rb_gc_mark(p->parsing_thread);
-#endif
-#ifdef YYMALLOC
- rb_gc_mark((VALUE)p->heap);
-#endif
+ VALUE *var = rb_svar(1);
+ if (var) {
+ return *var;
+ }
+ return Qnil;
}
-static void
-parser_free(void *ptr)
+void
+rb_backref_set(val)
+ VALUE val;
{
- struct parser_params *p = (struct parser_params*)ptr;
- struct local_vars *local, *prev;
-
- if (p->parser_tokenbuf) {
- xfree(p->parser_tokenbuf);
+ VALUE *var = rb_svar(1);
+ if (var) {
+ *var = val;
}
- for (local = p->parser_lvtbl; local; local = prev) {
- if (local->vars) xfree(local->vars);
- prev = local->prev;
- xfree(local);
+ else {
+ special_local_set('~', val);
}
- xfree(p);
-}
-
-VALUE rb_parser_get_yydebug(VALUE);
-VALUE rb_parser_set_yydebug(VALUE, VALUE);
-
-#ifndef RIPPER
-static struct parser_params *
-parser_new(void)
-{
- struct parser_params *p;
-
- p = ALLOC_N(struct parser_params, 1);
- MEMZERO(p, struct parser_params, 1);
- parser_initialize(p);
- return p;
-}
-
-VALUE
-rb_parser_new(void)
-{
- struct parser_params *p = parser_new();
-
- return Data_Wrap_Struct(0, parser_mark, parser_free, p);
-}
-
-/*
- * call-seq:
- * ripper#end_seen? -> Boolean
- *
- * Return if parsed source ended by +\_\_END\_\_+.
- * This number starts from 1.
- */
-VALUE
-rb_parser_end_seen_p(VALUE vparser)
-{
- struct parser_params *parser;
-
- Data_Get_Struct(vparser, struct parser_params, parser);
- return ruby__end__seen ? Qtrue : Qfalse;
}
-/*
- * call-seq:
- * ripper#encoding -> encoding
- *
- * Return encoding of the source.
- */
VALUE
-rb_parser_encoding(VALUE vparser)
+rb_lastline_get()
{
- struct parser_params *parser;
-
- Data_Get_Struct(vparser, struct parser_params, parser);
- return rb_enc_from_encoding(parser->enc);
-}
-
-/*
- * call-seq:
- * ripper.yydebug -> true or false
- *
- * Get yydebug.
- */
-VALUE
-rb_parser_get_yydebug(VALUE self)
-{
- struct parser_params *parser;
-
- Data_Get_Struct(self, struct parser_params, parser);
- return yydebug ? Qtrue : Qfalse;
+ VALUE *var = rb_svar(0);
+ if (var) {
+ return *var;
+ }
+ return Qnil;
}
-/*
- * call-seq:
- * ripper.yydebug = flag
- *
- * Set yydebug.
- */
-VALUE
-rb_parser_set_yydebug(VALUE self, VALUE flag)
+void
+rb_lastline_set(val)
+ VALUE val;
{
- struct parser_params *parser;
-
- Data_Get_Struct(self, struct parser_params, parser);
- yydebug = RTEST(flag);
- return flag;
+ VALUE *var = rb_svar(0);
+ if (var) {
+ *var = val;
+ }
+ else {
+ special_local_set('_', val);
+ }
}
#ifdef YYMALLOC
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
-#define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
-#define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
+#define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser_heap, 0)
+#define ADD2HEAP(n, c, p) ((parser_heap = (n))->u1.node = (p), \
(n)->u3.cnt = (c), (p))
-void *
-rb_parser_malloc(struct parser_params *parser, size_t size)
+static void *
+rb_parser_malloc(size)
+ size_t size;
{
size_t cnt = HEAPCNT(1, size);
NODE *n = NEWHEAP();
@@ -9343,8 +6420,9 @@ rb_parser_malloc(struct parser_params *parser, size_t size)
return ADD2HEAP(n, cnt, ptr);
}
-void *
-rb_parser_calloc(struct parser_params *parser, size_t nelem, size_t size)
+static void *
+rb_parser_calloc(nelem, size)
+ size_t nelem, size;
{
size_t cnt = HEAPCNT(nelem, size);
NODE *n = NEWHEAP();
@@ -9353,13 +6431,15 @@ rb_parser_calloc(struct parser_params *parser, size_t nelem, size_t size)
return ADD2HEAP(n, cnt, ptr);
}
-void *
-rb_parser_realloc(struct parser_params *parser, void *ptr, size_t size)
+static void *
+rb_parser_realloc(ptr, size)
+ void *ptr;
+ size_t size;
{
NODE *n;
size_t cnt = HEAPCNT(1, size);
- if (ptr && (n = parser->heap) != NULL) {
+ if (ptr && (n = parser_heap) != NULL) {
do {
if (n->u1.node == ptr) {
n->u1.node = ptr = xrealloc(ptr, size);
@@ -9373,12 +6453,13 @@ rb_parser_realloc(struct parser_params *parser, void *ptr, size_t size)
return ADD2HEAP(n, cnt, ptr);
}
-void
-rb_parser_free(struct parser_params *parser, void *ptr)
+static void
+rb_parser_free(ptr)
+ void *ptr;
{
- NODE **prev = &parser->heap, *n;
+ NODE **prev = &parser_heap, *n;
- while ((n = *prev) != NULL) {
+ while ((n = *prev) != 0) {
if (n->u1.node == ptr) {
*prev = n->u2.node;
rb_gc_force_recycle((VALUE)n);
@@ -9389,456 +6470,3 @@ rb_parser_free(struct parser_params *parser, void *ptr)
xfree(ptr);
}
#endif
-#endif
-
-#ifdef RIPPER
-#ifdef RIPPER_DEBUG
-extern int rb_is_pointer_to_heap(VALUE);
-
-/* :nodoc: */
-static VALUE
-ripper_validate_object(VALUE self, VALUE x)
-{
- if (x == Qfalse) return x;
- if (x == Qtrue) return x;
- if (x == Qnil) return x;
- if (x == Qundef)
- rb_raise(rb_eArgError, "Qundef given");
- if (FIXNUM_P(x)) return x;
- if (SYMBOL_P(x)) return x;
- if (!rb_is_pointer_to_heap(x))
- rb_raise(rb_eArgError, "invalid pointer: %p", x);
- switch (TYPE(x)) {
- case T_STRING:
- case T_OBJECT:
- case T_ARRAY:
- case T_BIGNUM:
- case T_FLOAT:
- return x;
- case T_NODE:
- rb_raise(rb_eArgError, "NODE given: %p", x);
- default:
- rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)",
- x, rb_obj_classname(x));
- }
- return x;
-}
-#endif
-
-#define validate(x)
-
-static VALUE
-ripper_dispatch0(struct parser_params *parser, ID mid)
-{
- return rb_funcall(parser->value, mid, 0);
-}
-
-static VALUE
-ripper_dispatch1(struct parser_params *parser, ID mid, VALUE a)
-{
- validate(a);
- return rb_funcall(parser->value, mid, 1, a);
-}
-
-static VALUE
-ripper_dispatch2(struct parser_params *parser, ID mid, VALUE a, VALUE b)
-{
- validate(a);
- validate(b);
- return rb_funcall(parser->value, mid, 2, a, b);
-}
-
-static VALUE
-ripper_dispatch3(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c)
-{
- validate(a);
- validate(b);
- validate(c);
- return rb_funcall(parser->value, mid, 3, a, b, c);
-}
-
-static VALUE
-ripper_dispatch4(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d)
-{
- validate(a);
- validate(b);
- validate(c);
- validate(d);
- return rb_funcall(parser->value, mid, 4, a, b, c, d);
-}
-
-static VALUE
-ripper_dispatch5(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e)
-{
- validate(a);
- validate(b);
- validate(c);
- validate(d);
- validate(e);
- return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
-}
-
-static const struct kw_assoc {
- ID id;
- const char *name;
-} keyword_to_name[] = {
- {keyword_class, "class"},
- {keyword_module, "module"},
- {keyword_def, "def"},
- {keyword_undef, "undef"},
- {keyword_begin, "begin"},
- {keyword_rescue, "rescue"},
- {keyword_ensure, "ensure"},
- {keyword_end, "end"},
- {keyword_if, "if"},
- {keyword_unless, "unless"},
- {keyword_then, "then"},
- {keyword_elsif, "elsif"},
- {keyword_else, "else"},
- {keyword_case, "case"},
- {keyword_when, "when"},
- {keyword_while, "while"},
- {keyword_until, "until"},
- {keyword_for, "for"},
- {keyword_break, "break"},
- {keyword_next, "next"},
- {keyword_redo, "redo"},
- {keyword_retry, "retry"},
- {keyword_in, "in"},
- {keyword_do, "do"},
- {keyword_do_cond, "do"},
- {keyword_do_block, "do"},
- {keyword_return, "return"},
- {keyword_yield, "yield"},
- {keyword_super, "super"},
- {keyword_self, "self"},
- {keyword_nil, "nil"},
- {keyword_true, "true"},
- {keyword_false, "false"},
- {keyword_and, "and"},
- {keyword_or, "or"},
- {keyword_not, "not"},
- {modifier_if, "if"},
- {modifier_unless, "unless"},
- {modifier_while, "while"},
- {modifier_until, "until"},
- {modifier_rescue, "rescue"},
- {keyword_alias, "alias"},
- {keyword_defined, "defined?"},
- {keyword_BEGIN, "BEGIN"},
- {keyword_END, "END"},
- {keyword__LINE__, "__LINE__"},
- {keyword__FILE__, "__FILE__"},
- {0, NULL}
-};
-
-static const char*
-keyword_id_to_str(ID id)
-{
- const struct kw_assoc *a;
-
- for (a = keyword_to_name; a->id; a++) {
- if (a->id == id)
- return a->name;
- }
- return NULL;
-}
-
-static VALUE
-ripper_id2sym(ID id)
-{
- const char *name;
- char buf[8];
-
- if (id <= 256) {
- buf[0] = id;
- buf[1] = '\0';
- return ID2SYM(rb_intern(buf));
- }
- if ((name = keyword_id_to_str(id))) {
- return ID2SYM(rb_intern(name));
- }
- switch (id) {
- case tOROP:
- name = "||";
- break;
- case tANDOP:
- name = "&&";
- break;
- default:
- name = rb_id2name(id);
- if (!name) {
- rb_bug("cannot convert ID to string: %ld", (unsigned long)id);
- }
- break;
- }
- return ID2SYM(rb_intern(name));
-}
-
-static VALUE
-ripper_intern(const char *s)
-{
- return ID2SYM(rb_intern(s));
-}
-
-static void
-ripper_compile_error(struct parser_params *parser, const char *fmt, ...)
-{
- VALUE str;
- va_list args;
-
- va_start(args, fmt);
- str = rb_vsprintf(fmt, args);
- va_end(args);
- rb_funcall(parser->value, rb_intern("compile_error"), 1, str);
-}
-
-static void
-ripper_warn0(struct parser_params *parser, const char *fmt)
-{
- rb_funcall(parser->value, rb_intern("warn"), 1, STR_NEW2(fmt));
-}
-
-static void
-ripper_warnI(struct parser_params *parser, const char *fmt, int a)
-{
- rb_funcall(parser->value, rb_intern("warn"), 2,
- STR_NEW2(fmt), INT2NUM(a));
-}
-
-static void
-ripper_warnS(struct parser_params *parser, const char *fmt, const char *str)
-{
- rb_funcall(parser->value, rb_intern("warn"), 2,
- STR_NEW2(fmt), STR_NEW2(str));
-}
-
-static void
-ripper_warning0(struct parser_params *parser, const char *fmt)
-{
- rb_funcall(parser->value, rb_intern("warning"), 1, STR_NEW2(fmt));
-}
-
-#if 0 /* unused in ripper right now */
-static void
-ripper_warningS(struct parser_params *parser, const char *fmt, const char *str)
-{
- rb_funcall(parser->value, rb_intern("warning"), 2,
- STR_NEW2(fmt), STR_NEW2(str));
-}
-#endif
-
-static VALUE
-ripper_lex_get_generic(struct parser_params *parser, VALUE src)
-{
- return rb_funcall(src, ripper_id_gets, 0);
-}
-
-static VALUE
-ripper_s_allocate(VALUE klass)
-{
- struct parser_params *p;
- VALUE self;
-
- p = ALLOC_N(struct parser_params, 1);
- MEMZERO(p, struct parser_params, 1);
- self = Data_Wrap_Struct(klass, parser_mark, parser_free, p);
- p->value = self;
- return self;
-}
-
-#define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
-
-/*
- * call-seq:
- * Ripper.new(src, filename="(ripper)", lineno=1) -> ripper
- *
- * Create a new Ripper object.
- * _src_ must be a String, a IO, or an Object which has #gets method.
- *
- * This method does not starts parsing.
- * See also Ripper#parse and Ripper.parse.
- */
-static VALUE
-ripper_initialize(int argc, VALUE *argv, VALUE self)
-{
- struct parser_params *parser;
- VALUE src, fname, lineno;
- VALUE fname2;
-
- Data_Get_Struct(self, struct parser_params, parser);
- rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
- if (rb_obj_respond_to(src, ripper_id_gets, 0)) {
- parser->parser_lex_gets = ripper_lex_get_generic;
- }
- else {
- StringValue(src);
- parser->parser_lex_gets = lex_get_str;
- }
- parser->parser_lex_input = src;
- parser->eofp = Qfalse;
- if (NIL_P(fname)) {
- fname2 = STR_NEW2(" (ripper)");
- }
- else {
- StringValue(fname);
- fname2 = rb_str_new2(" ");
- rb_str_append(fname2, fname);
- }
- parser_initialize(parser);
-
- parser->parser_ruby_sourcefile_string = fname2;
- parser->parser_ruby_sourcefile = RSTRING_PTR(fname2)+1;
- parser->parser_ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
-
- return Qnil;
-}
-
-extern VALUE rb_thread_pass(void);
-
-struct ripper_args {
- struct parser_params *parser;
- int argc;
- VALUE *argv;
-};
-
-static VALUE
-ripper_parse0(VALUE parser_v)
-{
- struct parser_params *parser;
-
- Data_Get_Struct(parser_v, struct parser_params, parser);
- parser_prepare(parser);
- ripper_yyparse((void*)parser);
- return parser->result;
-}
-
-static VALUE
-ripper_ensure(VALUE parser_v)
-{
- struct parser_params *parser;
-
- Data_Get_Struct(parser_v, struct parser_params, parser);
- parser->parsing_thread = Qnil;
- return Qnil;
-}
-
-/*
- * call-seq:
- * ripper#parse
- *
- * Start parsing and returns the value of the root action.
- */
-static VALUE
-ripper_parse(VALUE self)
-{
- struct parser_params *parser;
-
- Data_Get_Struct(self, struct parser_params, parser);
- if (!ripper_initialized_p(parser)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (!NIL_P(parser->parsing_thread)) {
- if (parser->parsing_thread == rb_thread_current())
- rb_raise(rb_eArgError, "Ripper#parse is not reentrant");
- else
- rb_raise(rb_eArgError, "Ripper#parse is not multithread-safe");
- }
- parser->parsing_thread = rb_thread_current();
- rb_ensure(ripper_parse0, self, ripper_ensure, self);
-
- return parser->result;
-}
-
-/*
- * call-seq:
- * ripper#column -> Integer
- *
- * Return column number of current parsing line.
- * This number starts from 0.
- */
-static VALUE
-ripper_column(VALUE self)
-{
- struct parser_params *parser;
- long col;
-
- Data_Get_Struct(self, struct parser_params, parser);
- if (!ripper_initialized_p(parser)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(parser->parsing_thread)) return Qnil;
- col = parser->tokp - parser->parser_lex_pbeg;
- return LONG2NUM(col);
-}
-
-/*
- * call-seq:
- * ripper#lineno -> Integer
- *
- * Return line number of current parsing line.
- * This number starts from 1.
- */
-static VALUE
-ripper_lineno(VALUE self)
-{
- struct parser_params *parser;
-
- Data_Get_Struct(self, struct parser_params, parser);
- if (!ripper_initialized_p(parser)) {
- rb_raise(rb_eArgError, "method called for uninitialized object");
- }
- if (NIL_P(parser->parsing_thread)) return Qnil;
- return INT2NUM(parser->parser_ruby_sourceline);
-}
-
-#ifdef RIPPER_DEBUG
-/* :nodoc: */
-static VALUE
-ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
-{
- StringValue(msg);
- if (obj == Qundef) {
- rb_raise(rb_eArgError, "%s", RSTRING_PTR(msg));
- }
- return Qnil;
-}
-
-/* :nodoc: */
-static VALUE
-ripper_value(VALUE self, VALUE obj)
-{
- return ULONG2NUM(obj);
-}
-#endif
-
-void
-Init_ripper(void)
-{
- VALUE Ripper;
-
- Ripper = rb_define_class("Ripper", rb_cObject);
- rb_define_const(Ripper, "Version", rb_str_new2(RIPPER_VERSION));
- rb_define_alloc_func(Ripper, ripper_s_allocate);
- rb_define_method(Ripper, "initialize", ripper_initialize, -1);
- rb_define_method(Ripper, "parse", ripper_parse, 0);
- rb_define_method(Ripper, "column", ripper_column, 0);
- rb_define_method(Ripper, "lineno", ripper_lineno, 0);
- rb_define_method(Ripper, "end_seen?", rb_parser_end_seen_p, 0);
- rb_define_method(Ripper, "encoding", rb_parser_encoding, 0);
- rb_define_method(Ripper, "yydebug", rb_parser_get_yydebug, 0);
- rb_define_method(Ripper, "yydebug=", rb_parser_set_yydebug, 1);
-#ifdef RIPPER_DEBUG
- rb_define_method(rb_mKernel, "assert_Qundef", ripper_assert_Qundef, 2);
- rb_define_method(rb_mKernel, "rawVALUE", ripper_value, 1);
- rb_define_method(rb_mKernel, "validate_object", ripper_validate_object, 1);
-#endif
-
- ripper_id_gets = rb_intern("gets");
- ripper_init_eventids1(Ripper);
- ripper_init_eventids2(Ripper);
- /* ensure existing in symbol table */
- rb_intern("||");
- rb_intern("&&");
-}
-#endif /* RIPPER */
diff --git a/prec.c b/prec.c
index 02752270ae..7b215fba09 100644
--- a/prec.c
+++ b/prec.c
@@ -6,11 +6,11 @@
$Date$
created at: Tue Jan 26 02:40:41 2000
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
VALUE rb_mPrecision;
@@ -19,7 +19,7 @@ static ID prc_pr, prc_if;
/*
* call-seq:
- * num.prec(klass) => a_class
+ * num.prec(klass) => a_klass
*
* Converts _self_ into an instance of _klass_. By default,
* +prec+ invokes
@@ -32,7 +32,8 @@ static ID prc_pr, prc_if;
*/
static VALUE
-prec_prec(VALUE x, VALUE klass)
+prec_prec(x, klass)
+ VALUE x, klass;
{
return rb_funcall(klass, prc_if, 1, x);
}
@@ -46,7 +47,8 @@ prec_prec(VALUE x, VALUE klass)
*/
static VALUE
-prec_prec_i(VALUE x)
+prec_prec_i(x)
+ VALUE x;
{
VALUE klass = rb_cInteger;
@@ -62,7 +64,8 @@ prec_prec_i(VALUE x)
*/
static VALUE
-prec_prec_f(VALUE x)
+prec_prec_f(x)
+ VALUE x;
{
VALUE klass = rb_cFloat;
@@ -83,7 +86,8 @@ prec_prec_f(VALUE x)
*/
static VALUE
-prec_induced_from(VALUE module, VALUE x)
+prec_induced_from(module, x)
+ VALUE module, x;
{
rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
rb_obj_classname(x), rb_class2name(module));
@@ -100,7 +104,8 @@ prec_induced_from(VALUE module, VALUE x)
*/
static VALUE
-prec_included(VALUE module, VALUE include)
+prec_included(module, include)
+ VALUE module, include;
{
switch (TYPE(include)) {
case T_CLASS:
@@ -123,7 +128,7 @@ prec_included(VALUE module, VALUE include)
*/
void
-Init_Precision(void)
+Init_Precision()
{
rb_mPrecision = rb_define_module("Precision");
rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);
diff --git a/prelude.rb b/prelude.rb
deleted file mode 100644
index 8d6f70657e..0000000000
--- a/prelude.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-
-# Mutex
-
-class Mutex
- def synchronize
- self.lock
- begin
- yield
- ensure
- self.unlock
- end
- end
-end
-
-# Thread
-
-class Thread
- MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new
- def self.exclusive
- MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
- yield
- }
- end
-end
-
diff --git a/proc.c b/proc.c
deleted file mode 100644
index 422af20c52..0000000000
--- a/proc.c
+++ /dev/null
@@ -1,1686 +0,0 @@
-/**********************************************************************
-
- proc.c - Proc, Binding, Env
-
- $Author$
- $Date$
- created at: Wed Jan 17 12:13:14 2007
-
- Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include "eval_intern.h"
-#include "gc.h"
-
-struct METHOD {
- VALUE oclass; /* class that holds the method */
- VALUE rclass; /* class of the recevier */
- VALUE recv;
- ID id, oid;
- NODE *body;
-};
-
-VALUE rb_cUnboundMethod;
-VALUE rb_cMethod;
-VALUE rb_cBinding;
-VALUE rb_cProc;
-
-static VALUE bmcall(VALUE, VALUE);
-static int method_arity(VALUE);
-static VALUE rb_obj_is_method(VALUE m);
-
-/* Proc */
-
-static void
-proc_free(void *ptr)
-{
- RUBY_FREE_ENTER("proc");
- if (ptr) {
- ruby_xfree(ptr);
- }
- RUBY_FREE_LEAVE("proc");
-}
-
-static void
-proc_mark(void *ptr)
-{
- rb_proc_t *proc;
- RUBY_MARK_ENTER("proc");
- if (ptr) {
- proc = ptr;
- RUBY_MARK_UNLESS_NULL(proc->envval);
- RUBY_MARK_UNLESS_NULL(proc->blockprocval);
- RUBY_MARK_UNLESS_NULL((VALUE)proc->special_cref_stack);
- RUBY_MARK_UNLESS_NULL(proc->block.proc);
- if (proc->block.iseq && RUBY_VM_IFUNC_P(proc->block.iseq)) {
- RUBY_MARK_UNLESS_NULL((VALUE)(proc->block.iseq));
- }
- }
- RUBY_MARK_LEAVE("proc");
-}
-
-VALUE
-rb_proc_alloc(VALUE klass)
-{
- VALUE obj;
- rb_proc_t *proc;
- obj = Data_Make_Struct(klass, rb_proc_t, proc_mark, proc_free, proc);
- MEMZERO(proc, rb_proc_t, 1);
- return obj;
-}
-
-VALUE
-rb_obj_is_proc(VALUE proc)
-{
- if (TYPE(proc) == T_DATA &&
- RDATA(proc)->dfree == (RUBY_DATA_FUNC) proc_free) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
-}
-
-static VALUE
-proc_dup(VALUE self)
-{
- VALUE procval = rb_proc_alloc(rb_cProc);
- rb_proc_t *src, *dst;
- GetProcPtr(self, src);
- GetProcPtr(procval, dst);
-
- dst->block = src->block;
- dst->block.proc = procval;
- dst->envval = src->envval;
- dst->safe_level = dst->safe_level;
- dst->special_cref_stack = src->special_cref_stack;
-
- return procval;
-}
-
-static VALUE
-proc_clone(VALUE self)
-{
- VALUE procval = proc_dup(self);
- CLONESETUP(procval, self);
- return procval;
-}
-
-/*
- * call-seq:
- * prc.lambda? => true or false
- *
- * Returns true for a Proc object which argument check is rigid.
- * Such procs are typically generated by lambda.
- *
- * lambda {}.lambda? => true
- * lambda {|a,b| [a,b]}.call(1,2,3) => ArgumentError
- *
- * proc {}.lambda? => false
- * proc {|a,b| [a,b]}.call(1,2,3) => [1,2]
- *
- * Proc.new {}.lambda? => false
- *
- * def m() end
- * method(:m).to_proc.lambda? => true
- *
- * def n(&b) b.lambda? end
- * n {} => false
- * n(&proc {}) => false
- * n(&Proc.new {}) => false
- * n(&lambda {}) => true
- * n(&method(:m)) => true
- * n(&method(:m)).to_proc => true
- *
- * class C
- * define_method(:d) {}
- * end
- * C.new.method(:d).to_proc.lambda? => true
- *
- */
-
-static VALUE
-proc_lambda_p(VALUE procval)
-{
- rb_proc_t *proc;
- GetProcPtr(procval, proc);
-
- return proc->is_lambda ? Qtrue : Qfalse;
-}
-
-/* Binding */
-
-static void
-binding_free(void *ptr)
-{
- rb_binding_t *bind;
- RUBY_FREE_ENTER("binding");
- if (ptr) {
- bind = ptr;
- ruby_xfree(ptr);
- }
- RUBY_FREE_LEAVE("binding");
-}
-
-static void
-binding_mark(void *ptr)
-{
- rb_binding_t *bind;
- RUBY_MARK_ENTER("binding");
- if (ptr) {
- bind = ptr;
- RUBY_MARK_UNLESS_NULL(bind->env);
- RUBY_MARK_UNLESS_NULL((VALUE)bind->cref_stack);
- }
- RUBY_MARK_LEAVE("binding");
-}
-
-static VALUE
-binding_alloc(VALUE klass)
-{
- VALUE obj;
- rb_binding_t *bind;
- obj = Data_Make_Struct(klass, rb_binding_t,
- binding_mark, binding_free, bind);
- return obj;
-}
-
-static VALUE
-binding_dup(VALUE self)
-{
- VALUE bindval = binding_alloc(rb_cBinding);
- rb_binding_t *src, *dst;
- GetBindingPtr(self, src);
- GetBindingPtr(bindval, dst);
- dst->env = src->env;
- dst->cref_stack = src->cref_stack;
- return bindval;
-}
-
-static VALUE
-binding_clone(VALUE self)
-{
- VALUE bindval = binding_dup(self);
- CLONESETUP(bindval, self);
- return bindval;
-}
-
-VALUE
-rb_binding_new(void)
-{
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
- VALUE bindval = binding_alloc(rb_cBinding);
- rb_binding_t *bind;
-
- GetBindingPtr(bindval, bind);
- bind->env = vm_make_env_object(th, cfp);
- bind->cref_stack = ruby_cref();
- return bindval;
-}
-
-/*
- * call-seq:
- * binding -> a_binding
- *
- * Returns a +Binding+ object, describing the variable and
- * method bindings at the point of call. This object can be used when
- * calling +eval+ to execute the evaluated command in this
- * environment. Also see the description of class +Binding+.
- *
- * def getBinding(param)
- * return binding
- * end
- * b = getBinding("hello")
- * eval("param", b) #=> "hello"
- */
-
-static VALUE
-rb_f_binding(VALUE self)
-{
- return rb_binding_new();
-}
-
-/*
- * 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(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 */);
-}
-
-static VALUE
-proc_new(VALUE klass, int is_lambda)
-{
- VALUE procval = Qnil;
- rb_thread_t *th = GET_THREAD();
- rb_control_frame_t *cfp = th->cfp;
- rb_block_t *block;
-
- if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0 &&
- !RUBY_VM_CLASS_SPECIAL_P(cfp->lfp[0])) {
-
- block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
- }
- else {
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
-
- if ((GC_GUARDED_PTR_REF(cfp->lfp[0])) != 0 &&
- !RUBY_VM_CLASS_SPECIAL_P(cfp->lfp[0])) {
-
- block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
-
- /* TODO: check more (cfp limit, called via cfunc, etc) */
- while (cfp->dfp != block->dfp) {
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
- }
-
- if (is_lambda) {
- rb_warn("tried to create Proc object without a block");
- }
- }
- else {
- rb_raise(rb_eArgError,
- "tried to create Proc object without a block");
- }
- }
-
- if (block->proc) {
- return block->proc;
- }
-
- procval = vm_make_proc(th, cfp, block);
-
- if (is_lambda) {
- rb_proc_t *proc;
- GetProcPtr(procval, proc);
- proc->is_lambda = Qtrue;
- }
- return procval;
-}
-
-/*
- * call-seq:
- * Proc.new {|...| block } => a_proc
- * Proc.new => a_proc
- *
- * Creates a new <code>Proc</code> object, bound to the current
- * context. <code>Proc::new</code> may be called without a block only
- * within a method with an attached block, in which case that block is
- * converted to the <code>Proc</code> object.
- *
- * def proc_from
- * Proc.new
- * end
- * proc = proc_from { "hello" }
- * proc.call #=> "hello"
- */
-
-static VALUE
-rb_proc_s_new(int argc, VALUE *argv, VALUE klass)
-{
- VALUE block = proc_new(klass, Qfalse);
-
- rb_obj_call_init(block, argc, argv);
- return block;
-}
-
-/*
- * call-seq:
- * proc { |...| block } => a_proc
- *
- * Equivalent to <code>Proc.new</code>.
- */
-
-VALUE
-rb_block_proc(void)
-{
- return proc_new(rb_cProc, Qfalse);
-}
-
-VALUE
-rb_block_lambda(void)
-{
- return proc_new(rb_cProc, Qtrue);
-}
-
-VALUE
-rb_f_lambda(void)
-{
- rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
- return rb_block_lambda();
-}
-
-/*
- * call-seq:
- * lambda { |...| block } => a_proc
- *
- * Equivalent to <code>Proc.new</code>, except the resulting Proc objects
- * check the number of parameters passed when called.
- */
-
-static VALUE
-proc_lambda(void)
-{
- return rb_block_lambda();
-}
-
-/* CHECKME: are the argument checking semantics correct? */
-
-/*
- * call-seq:
- * prc.call(params,...) => obj
- * prc[params,...] => obj
- *
- * Invokes the block, setting the block's parameters to the values in
- * <i>params</i> using something close to method calling semantics.
- * Generates a warning if multiple values are passed to a proc that
- * expects just one (previously this silently converted the parameters
- * to an array).
- *
- * For procs created using <code>Kernel.proc</code>, generates an
- * error if the wrong number of parameters
- * are passed to a proc with multiple parameters. For procs created using
- * <code>Proc.new</code>, extra parameters are silently discarded.
- *
- * Returns the value of the last expression evaluated in the block. See
- * also <code>Proc#yield</code>.
- *
- * a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
- * a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
- * a_proc[9, 1, 2, 3] #=> [9, 18, 27]
- * a_proc = Proc.new {|a,b| a}
- * a_proc.call(1,2,3)
- *
- * <em>produces:</em>
- *
- * prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
- * from prog.rb:4:in `call'
- * from prog.rb:5
- */
-
-static VALUE
-proc_call(int argc, VALUE *argv, VALUE procval)
-{
- rb_proc_t *proc;
- rb_block_t *blockptr = 0;
- GetProcPtr(procval, proc);
-
- if (BUILTIN_TYPE(proc->block.iseq) != T_NODE &&
- proc->block.iseq->arg_block != -1) {
-
- if (rb_block_given_p()) {
- rb_proc_t *proc;
- VALUE procval;
- procval = rb_block_proc();
- GetProcPtr(procval, proc);
- blockptr = &proc->block;
- }
- }
-
- return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
- argc, argv, blockptr);
-}
-
-VALUE
-rb_proc_call(VALUE self, VALUE args)
-{
- rb_proc_t *proc;
- GetProcPtr(self, proc);
- return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
- RARRAY_LEN(args), RARRAY_PTR(args), 0);
-}
-
-/*
- * call-seq:
- * prc.arity -> fixnum
- *
- * Returns the number of arguments that would not be ignored. If the block
- * is declared to take no arguments, returns 0. If the block is known
- * to take exactly n arguments, returns n. If the block has optional
- * arguments, return -n-1, where n is the number of mandatory
- * arguments. A <code>proc</code> with no argument declarations
- * is the same a block declaring <code>||</code> as its arguments.
- *
- * Proc.new {}.arity #=> 0
- * Proc.new {||}.arity #=> 0
- * Proc.new {|a|}.arity #=> 1
- * Proc.new {|a,b|}.arity #=> 2
- * Proc.new {|a,b,c|}.arity #=> 3
- * Proc.new {|*a|}.arity #=> -1
- * Proc.new {|a,*b|}.arity #=> -2
- * Proc.new {|a,*b, c|}.arity #=> -3
- */
-
-static VALUE
-proc_arity(VALUE self)
-{
- rb_proc_t *proc;
- rb_iseq_t *iseq;
- GetProcPtr(self, proc);
- iseq = proc->block.iseq;
- if (iseq) {
- if (BUILTIN_TYPE(iseq) != T_NODE) {
- if (iseq->arg_rest < 0) {
- return INT2FIX(iseq->argc);
- }
- else {
- return INT2FIX(-(iseq->argc + 1 + iseq->arg_post_len));
- }
- }
- else {
- NODE *node = (NODE *)iseq;
- if (nd_type(node) == NODE_IFUNC && node->nd_cfnc == bmcall) {
- /* method(:foo).to_proc.arity */
- return INT2FIX(method_arity(node->nd_tval));
- }
- }
- }
- return INT2FIX(-1);
-}
-
-int
-rb_proc_arity(VALUE proc)
-{
- return FIX2INT(proc_arity(proc));
-}
-
-static rb_iseq_t *
-get_proc_iseq(VALUE self)
-{
- rb_proc_t *proc;
- rb_iseq_t *iseq;
-
- GetProcPtr(self, proc);
- iseq = proc->block.iseq;
- if (!RUBY_VM_NORMAL_ISEQ_P(iseq))
- return 0;
- return iseq;
-}
-
-VALUE
-rb_proc_location(VALUE self)
-{
- rb_iseq_t *iseq = get_proc_iseq(self);
- VALUE loc[2];
-
- if (!iseq) return Qnil;
- loc[0] = iseq->filename;
- if (iseq->insn_info_table) {
- loc[1] = INT2FIX(iseq->insn_info_table[0].line_no);
- }
- else {
- loc[1] = Qnil;
- }
- return rb_ary_new4(2, loc);
-}
-
-/*
- * call-seq:
- * prc == other_proc => true or false
- *
- * Return <code>true</code> if <i>prc</i> is the same object as
- * <i>other_proc</i>, or if they are both procs with the same body.
- */
-
-static VALUE
-proc_eq(VALUE self, VALUE other)
-{
- if (self == other) {
- return Qtrue;
- }
- else {
- if (TYPE(other) == T_DATA &&
- RBASIC(other)->klass == rb_cProc &&
- CLASS_OF(self) == CLASS_OF(other)) {
- rb_proc_t *p1, *p2;
- GetProcPtr(self, p1);
- GetProcPtr(other, p2);
- if (p1->block.iseq == p2->block.iseq && p1->envval == p2->envval) {
- return Qtrue;
- }
- }
- }
- return Qfalse;
-}
-
-/*
- * call-seq:
- * prc.hash => integer
- *
- * Return hash value corresponding to proc body.
- */
-
-static VALUE
-proc_hash(VALUE self)
-{
- int hash;
- rb_proc_t *proc;
- GetProcPtr(self, proc);
- hash = (long)proc->block.iseq;
- hash ^= (long)proc->envval;
- hash ^= (long)proc->block.lfp >> 16;
- return INT2FIX(hash);
-}
-
-/*
- * call-seq:
- * prc.to_s => string
- *
- * Shows the unique identifier for this proc, along with
- * an indication of where the proc was defined.
- */
-
-static VALUE
-proc_to_s(VALUE self)
-{
- VALUE str = 0;
- rb_proc_t *proc;
- char *cname = rb_obj_classname(self);
- rb_iseq_t *iseq;
- const char *is_lambda;
-
- GetProcPtr(self, proc);
- iseq = proc->block.iseq;
- is_lambda = proc->is_lambda ? " (lambda)" : "";
-
- if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
- int line_no = 0;
-
- if (iseq->insn_info_table) {
- line_no = iseq->insn_info_table[0].line_no;
- }
- str = rb_sprintf("#<%s:%p@%s:%d%s>", cname, (void *)self,
- RSTRING_PTR(iseq->filename),
- line_no, is_lambda);
- }
- else {
- str = rb_sprintf("#<%s:%p%s>", cname, proc->block.iseq,
- is_lambda);
- }
-
- if (OBJ_TAINTED(self)) {
- OBJ_TAINT(str);
- }
- return str;
-}
-
-/*
- * call-seq:
- * prc.to_proc -> prc
- *
- * Part of the protocol for converting objects to <code>Proc</code>
- * objects. Instances of class <code>Proc</code> simply return
- * themselves.
- */
-
-static VALUE
-proc_to_proc(VALUE self)
-{
- return self;
-}
-
-/*
- * call-seq:
- * prc.binding => binding
- *
- * Returns the binding associated with <i>prc</i>. Note that
- * <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
- * <code>Binding</code> object as its second parameter.
- *
- * def fred(param)
- * proc {}
- * end
- *
- * b = fred(99)
- * eval("param", b.binding) #=> 99
- * eval("param", b) #=> 99
- */
-
-static void
-bm_mark(struct METHOD *data)
-{
- rb_gc_mark(data->rclass);
- rb_gc_mark(data->oclass);
- rb_gc_mark(data->recv);
- rb_gc_mark((VALUE)data->body);
-}
-
-NODE *
-rb_method_body(VALUE method)
-{
- struct METHOD *data;
-
- if (TYPE(method) == T_DATA &&
- RDATA(method)->dmark == (RUBY_DATA_FUNC) bm_mark) {
- Data_Get_Struct(method, struct METHOD, data);
- return data->body;
- }
- else {
- return 0;
- }
-}
-
-NODE *rb_get_method_body(VALUE klass, ID id, ID *idp);
-
-static VALUE
-mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
-{
- VALUE method;
- NODE *body;
- struct METHOD *data;
- VALUE rclass = klass;
- ID oid = id;
-
- again:
- if ((body = rb_get_method_body(klass, id, 0)) == 0) {
- rb_print_undef(rclass, oid, 0);
- }
- if (scope && (body->nd_noex & NOEX_MASK) != NOEX_PUBLIC) {
- rb_print_undef(rclass, oid, (body->nd_noex & NOEX_MASK));
- }
-
- klass = body->nd_clss;
- body = body->nd_body;
-
- if (nd_type(body) == NODE_ZSUPER) {
- klass = RCLASS_SUPER(klass);
- goto again;
- }
-
- while (rclass != klass &&
- (FL_TEST(rclass, FL_SINGLETON) || TYPE(rclass) == T_ICLASS)) {
- rclass = RCLASS_SUPER(rclass);
- }
- if (TYPE(klass) == T_ICLASS)
- klass = RBASIC(klass)->klass;
- method = Data_Make_Struct(mclass, struct METHOD, bm_mark, -1, data);
- data->oclass = klass;
- data->recv = obj;
-
- data->id = id;
- data->body = body;
- data->rclass = rclass;
- data->oid = oid;
- OBJ_INFECT(method, klass);
-
- return method;
-}
-
-
-/**********************************************************************
- *
- * Document-class : Method
- *
- * Method objects are created by <code>Object#method</code>, and are
- * associated with a particular object (not just with a class). They
- * may be used to invoke the method within the object, and as a block
- * associated with an iterator. They may also be unbound from one
- * object (creating an <code>UnboundMethod</code>) and bound to
- * another.
- *
- * class Thing
- * def square(n)
- * n*n
- * end
- * end
- * thing = Thing.new
- * meth = thing.method(:square)
- *
- * meth.call(9) #=> 81
- * [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
- *
- */
-
-/*
- * call-seq:
- * meth == other_meth => true or false
- *
- * Two method objects are equal if that are bound to the same
- * object and contain the same body.
- */
-
-
-static VALUE
-method_eq(VALUE method, VALUE other)
-{
- struct METHOD *m1, *m2;
-
- if (TYPE(other) != T_DATA
- || RDATA(other)->dmark != (RUBY_DATA_FUNC) bm_mark)
- return Qfalse;
- if (CLASS_OF(method) != CLASS_OF(other))
- return Qfalse;
-
- Data_Get_Struct(method, struct METHOD, m1);
- Data_Get_Struct(other, struct METHOD, m2);
-
- if (m1->oclass != m2->oclass || m1->rclass != m2->rclass ||
- m1->recv != m2->recv || m1->body != m2->body)
- return Qfalse;
-
- return Qtrue;
-}
-
-/*
- * call-seq:
- * meth.hash => integer
- *
- * Return a hash value corresponding to the method object.
- */
-
-static VALUE
-method_hash(VALUE method)
-{
- struct METHOD *m;
- long hash;
-
- Data_Get_Struct(method, struct METHOD, m);
- hash = (long)m->oclass;
- hash ^= (long)m->rclass;
- hash ^= (long)m->recv;
- hash ^= (long)m->body;
-
- return INT2FIX(hash);
-}
-
-/*
- * call-seq:
- * meth.unbind => unbound_method
- *
- * Dissociates <i>meth</i> from it's current receiver. The resulting
- * <code>UnboundMethod</code> can subsequently be bound to a new object
- * of the same class (see <code>UnboundMethod</code>).
- */
-
-static VALUE
-method_unbind(VALUE obj)
-{
- VALUE method;
- struct METHOD *orig, *data;
-
- Data_Get_Struct(obj, struct METHOD, orig);
- method =
- Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, free,
- data);
- data->oclass = orig->oclass;
- data->recv = Qundef;
- data->id = orig->id;
- data->body = orig->body;
- data->rclass = orig->rclass;
- data->oid = orig->oid;
- OBJ_INFECT(method, obj);
-
- return method;
-}
-
-/*
- * call-seq:
- * meth.receiver => object
- *
- * Returns the bound receiver of the method object.
- */
-
-static VALUE
-method_receiver(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(VALUE obj)
-{
- struct METHOD *data;
-
- Data_Get_Struct(obj, struct METHOD, data);
- return rb_str_dup(rb_id2str(data->id));
-}
-
-/*
- * call-seq:
- * meth.owner => class_or_module
- *
- * Returns the class or module that defines the method.
- */
-
-static VALUE
-method_owner(VALUE obj)
-{
- struct METHOD *data;
-
- Data_Get_Struct(obj, struct METHOD, data);
- return data->oclass;
-}
-
-/*
- * call-seq:
- * obj.method(sym) => method
- *
- * Looks up the named method as a receiver in <i>obj</i>, returning a
- * <code>Method</code> object (or raising <code>NameError</code>). The
- * <code>Method</code> object acts as a closure in <i>obj</i>'s object
- * instance, so instance variables and the value of <code>self</code>
- * remain available.
- *
- * class Demo
- * def initialize(n)
- * @iv = n
- * end
- * def hello()
- * "Hello, @iv = #{@iv}"
- * end
- * end
- *
- * k = Demo.new(99)
- * m = k.method(:hello)
- * m.call #=> "Hello, @iv = 99"
- *
- * l = Demo.new('Fred')
- * m = l.method("hello")
- * m.call #=> "Hello, @iv = Fred"
- */
-
-VALUE
-rb_obj_method(VALUE obj, VALUE vid)
-{
- return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod, Qfalse);
-}
-
-VALUE
-rb_obj_public_method(VALUE obj, VALUE vid)
-{
- return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod, Qtrue);
-}
-
-/*
- * call-seq:
- * mod.instance_method(symbol) => unbound_method
- *
- * Returns an +UnboundMethod+ representing the given
- * instance method in _mod_.
- *
- * class Interpreter
- * def do_a() print "there, "; end
- * def do_d() print "Hello "; end
- * def do_e() print "!\n"; end
- * def do_v() print "Dave"; end
- * Dispatcher = {
- * ?a => instance_method(:do_a),
- * ?d => instance_method(:do_d),
- * ?e => instance_method(:do_e),
- * ?v => instance_method(:do_v)
- * }
- * def interpret(string)
- * string.each_byte {|b| Dispatcher[b].bind(self).call }
- * end
- * end
- *
- *
- * interpreter = Interpreter.new
- * interpreter.interpret('dave')
- *
- * <em>produces:</em>
- *
- * Hello there, Dave!
- */
-
-static VALUE
-rb_mod_instance_method(VALUE mod, VALUE vid)
-{
- return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod, Qfalse);
-}
-
-static VALUE
-rb_mod_public_instance_method(VALUE mod, VALUE vid)
-{
- return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod, Qtrue);
-}
-
-/*
- * call-seq:
- * define_method(symbol, method) => new_method
- * define_method(symbol) { block } => proc
- *
- * Defines an instance method in the receiver. The _method_
- * parameter can be a +Proc+ or +Method+ object.
- * If a block is specified, it is used as the method body. This block
- * is evaluated using <code>instance_eval</code>, a point that is
- * tricky to demonstrate because <code>define_method</code> is private.
- * (This is why we resort to the +send+ hack in this example.)
- *
- * class A
- * def fred
- * puts "In Fred"
- * end
- * def create_method(name, &block)
- * self.class.send(:define_method, name, &block)
- * end
- * define_method(:wilma) { puts "Charge it!" }
- * end
- * class B < A
- * define_method(:barney, instance_method(:fred))
- * end
- * a = B.new
- * a.barney
- * a.wilma
- * a.create_method(:betty) { p self }
- * a.betty
- *
- * <em>produces:</em>
- *
- * In Fred
- * Charge it!
- * #<B:0x401b39e8>
- */
-
-static VALUE
-rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
-{
- ID id;
- VALUE body;
- NODE *node;
- int noex = NOEX_PUBLIC;
-
- if (argc == 1) {
- id = rb_to_id(argv[0]);
- body = rb_block_lambda();
- }
- else if (argc == 2) {
- id = rb_to_id(argv[0]);
- body = argv[1];
- if (!rb_obj_is_method(body) && !rb_obj_is_proc(body)) {
- rb_raise(rb_eTypeError,
- "wrong argument type %s (expected Proc/Method)",
- rb_obj_classname(body));
- }
- }
- else {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
- }
-
- if (RDATA(body)->dmark == (RUBY_DATA_FUNC) bm_mark) {
- struct METHOD *method = (struct METHOD *)DATA_PTR(body);
- VALUE rclass = method->rclass;
- if (rclass != mod) {
- if (FL_TEST(rclass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError,
- "can't bind singleton method to a different class");
- }
- if (!RTEST(rb_class_inherited_p(mod, rclass))) {
- rb_raise(rb_eTypeError,
- "bind argument must be a subclass of %s",
- rb_class2name(rclass));
- }
- }
- node = method->body;
- }
- else if (rb_obj_is_proc(body)) {
- rb_proc_t *proc;
- body = proc_dup(body);
- GetProcPtr(body, proc);
- if (BUILTIN_TYPE(proc->block.iseq) != T_NODE) {
- proc->block.iseq->defined_method_id = id;
- proc->block.iseq->klass = mod;
- proc->is_lambda = Qtrue;
- proc->is_from_method = Qtrue;
- }
- node = NEW_BMETHOD(body);
- }
- else {
- /* type error */
- rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)");
- }
-
- /* TODO: visibility */
-
- rb_add_method(mod, id, node, noex);
- return body;
-}
-
-static VALUE
-rb_obj_define_method(int argc, VALUE *argv, VALUE obj)
-{
- VALUE klass = rb_singleton_class(obj);
-
- return rb_mod_define_method(argc, argv, klass);
-}
-
-
-/*
- * MISSING: documentation
- */
-
-static VALUE
-method_clone(VALUE self)
-{
- 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);
- CLONESETUP(clone, self);
- *data = *orig;
-
- return clone;
-}
-
-/*
- * call-seq:
- * meth.call(args, ...) => obj
- * meth[args, ...] => obj
- *
- * Invokes the <i>meth</i> with the specified arguments, returning the
- * method's return value.
- *
- * m = 12.method("+")
- * m.call(3) #=> 15
- * m.call(20) #=> 32
- */
-
-VALUE
-rb_method_call(int argc, VALUE *argv, VALUE method)
-{
- VALUE result = Qnil; /* OK */
- struct METHOD *data;
- int state;
- volatile int safe = -1;
-
- Data_Get_Struct(method, struct METHOD, data);
- if (data->recv == Qundef) {
- rb_raise(rb_eTypeError, "can't call unbound method; bind first");
- }
- PUSH_TAG();
- if (OBJ_TAINTED(method)) {
- safe = rb_safe_level();
- if (rb_safe_level() < 4) {
- rb_set_safe_level_force(4);
- }
- }
- if ((state = EXEC_TAG()) == 0) {
- PASS_PASSED_BLOCK();
- result = vm_call0(GET_THREAD(),
- data->oclass, data->recv, data->id, data->oid,
- argc, argv, data->body, 0);
- }
- POP_TAG();
- if (safe >= 0)
- rb_set_safe_level_force(safe);
- if (state)
- JUMP_TAG(state);
- return result;
-}
-
-/**********************************************************************
- *
- * Document-class: UnboundMethod
- *
- * Ruby supports two forms of objectified methods. Class
- * <code>Method</code> is used to represent methods that are associated
- * with a particular object: these method objects are bound to that
- * object. Bound method objects for an object can be created using
- * <code>Object#method</code>.
- *
- * Ruby also supports unbound methods; methods objects that are not
- * associated with a particular object. These can be created either by
- * calling <code>Module#instance_method</code> or by calling
- * <code>unbind</code> on a bound method object. The result of both of
- * these is an <code>UnboundMethod</code> object.
- *
- * Unbound methods can only be called after they are bound to an
- * object. That object must be be a kind_of? the method's original
- * class.
- *
- * class Square
- * def area
- * @side * @side
- * end
- * def initialize(side)
- * @side = side
- * end
- * end
- *
- * area_un = Square.instance_method(:area)
- *
- * s = Square.new(12)
- * area = area_un.bind(s)
- * area.call #=> 144
- *
- * Unbound methods are a reference to the method at the time it was
- * objectified: subsequent changes to the underlying class will not
- * affect the unbound method.
- *
- * class Test
- * def test
- * :original
- * end
- * end
- * um = Test.instance_method(:test)
- * class Test
- * def test
- * :modified
- * end
- * end
- * t = Test.new
- * t.test #=> :modified
- * um.bind(t).call #=> :original
- *
- */
-
-/*
- * call-seq:
- * umeth.bind(obj) -> method
- *
- * Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
- * from which <i>umeth</i> was obtained,
- * <code>obj.kind_of?(Klass)</code> must be true.
- *
- * class A
- * def test
- * puts "In test, class = #{self.class}"
- * end
- * end
- * class B < A
- * end
- * class C < B
- * end
- *
- *
- * um = B.instance_method(:test)
- * bm = um.bind(C.new)
- * bm.call
- * bm = um.bind(B.new)
- * bm.call
- * bm = um.bind(A.new)
- * bm.call
- *
- * <em>produces:</em>
- *
- * In test, class = C
- * In test, class = B
- * prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
- * from prog.rb:16
- */
-
-static VALUE
-umethod_bind(VALUE method, VALUE recv)
-{
- struct METHOD *data, *bound;
-
- Data_Get_Struct(method, struct METHOD, data);
- if (data->rclass != CLASS_OF(recv)) {
- if (FL_TEST(data->rclass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError,
- "singleton method called for a different object");
- }
- if (!rb_obj_is_kind_of(recv, data->rclass)) {
- rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
- rb_class2name(data->rclass));
- }
- }
-
- method = Data_Make_Struct(rb_cMethod, struct METHOD, bm_mark, free, bound);
- *bound = *data;
- bound->recv = recv;
- bound->rclass = CLASS_OF(recv);
-
- return method;
-}
-
-int
-rb_node_arity(NODE* body)
-{
- switch (nd_type(body)) {
- case NODE_CFUNC:
- if (body->nd_argc < 0)
- return -1;
- return body->nd_argc;
- case NODE_ZSUPER:
- return -1;
- case NODE_ATTRSET:
- return 1;
- case NODE_IVAR:
- return 0;
- case NODE_BMETHOD:
- return rb_proc_arity(body->nd_cval);
- case RUBY_VM_METHOD_NODE:
- {
- rb_iseq_t *iseq;
- GetISeqPtr((VALUE)body->nd_body, iseq);
- if (iseq->arg_rest == -1 && iseq->arg_opts == 0) {
- return iseq->argc;
- }
- else {
- return -(iseq->argc + 1 + iseq->arg_post_len);
- }
- }
- default:
- rb_raise(rb_eArgError, "invalid node 0x%x", nd_type(body));
- }
-}
-
-/*
- * call-seq:
- * meth.arity => fixnum
- *
- * Returns an indication of the number of arguments accepted by a
- * method. Returns a nonnegative integer for methods that take a fixed
- * number of arguments. For Ruby methods that take a variable number of
- * arguments, returns -n-1, where n is the number of required
- * arguments. For methods written in C, returns -1 if the call takes a
- * variable number of arguments.
- *
- * class C
- * def one; end
- * def two(a); end
- * def three(*a); end
- * def four(a, b); end
- * def five(a, b, *c); end
- * def six(a, b, *c, &d); end
- * end
- * c = C.new
- * c.method(:one).arity #=> 0
- * c.method(:two).arity #=> 1
- * c.method(:three).arity #=> -1
- * c.method(:four).arity #=> 2
- * c.method(:five).arity #=> -3
- * c.method(:six).arity #=> -3
- *
- * "cat".method(:size).arity #=> 0
- * "cat".method(:replace).arity #=> 1
- * "cat".method(:squeeze).arity #=> -1
- * "cat".method(:count).arity #=> -1
- */
-
-static VALUE
-method_arity_m(VALUE method)
-{
- int n = method_arity(method);
- return INT2FIX(n);
-}
-
-static int
-method_arity(VALUE method)
-{
- struct METHOD *data;
-
- Data_Get_Struct(method, struct METHOD, data);
- return rb_node_arity(data->body);
-}
-
-int
-rb_mod_method_arity(VALUE mod, ID id)
-{
- NODE *node = rb_method_node(mod, id);
- return rb_node_arity(node);
-}
-
-int
-rb_obj_method_arity(VALUE obj, ID id)
-{
- return rb_mod_method_arity(CLASS_OF(obj), id);
-}
-
-/*
- * call-seq:
- * meth.to_s => string
- * meth.inspect => string
- *
- * Show the name of the underlying method.
- *
- * "cat".method(:count).inspect #=> "#<Method: String#count>"
- */
-
-static VALUE
-method_inspect(VALUE method)
-{
- struct METHOD *data;
- VALUE str;
- const char *s;
- char *sharp = "#";
-
- Data_Get_Struct(method, struct METHOD, data);
- str = rb_str_buf_new2("#<");
- s = rb_obj_classname(method);
- rb_str_buf_cat2(str, s);
- rb_str_buf_cat2(str, ": ");
-
- if (FL_TEST(data->oclass, FL_SINGLETON)) {
- VALUE v = rb_iv_get(data->oclass, "__attached__");
-
- if (data->recv == Qundef) {
- rb_str_buf_append(str, rb_inspect(data->oclass));
- }
- else if (data->recv == v) {
- rb_str_buf_append(str, rb_inspect(v));
- sharp = ".";
- }
- else {
- rb_str_buf_append(str, rb_inspect(data->recv));
- rb_str_buf_cat2(str, "(");
- rb_str_buf_append(str, rb_inspect(v));
- rb_str_buf_cat2(str, ")");
- sharp = ".";
- }
- }
- else {
- rb_str_buf_cat2(str, rb_class2name(data->rclass));
- if (data->rclass != data->oclass) {
- rb_str_buf_cat2(str, "(");
- rb_str_buf_cat2(str, rb_class2name(data->oclass));
- rb_str_buf_cat2(str, ")");
- }
- }
- rb_str_buf_cat2(str, sharp);
- rb_str_append(str, rb_id2str(data->oid));
- rb_str_buf_cat2(str, ">");
-
- return str;
-}
-
-static VALUE
-mproc(VALUE method)
-{
- return rb_funcall(Qnil, rb_intern("proc"), 0);
-}
-
-static VALUE
-mlambda(VALUE method)
-{
- return rb_funcall(Qnil, rb_intern("lambda"), 0);
-}
-
-static VALUE
-bmcall(VALUE args, VALUE method)
-{
- volatile VALUE a;
-
- if (CLASS_OF(args) != rb_cArray) {
- args = rb_ary_new3(1, args);
- }
-
- a = args;
- return rb_method_call(RARRAY_LEN(a), RARRAY_PTR(a), method);
-}
-
-VALUE
-rb_proc_new(
- VALUE (*func)(ANYARGS), /* VALUE yieldarg[, VALUE procarg] */
- VALUE val)
-{
- VALUE procval = rb_iterate(mproc, 0, func, val);
- return procval;
-}
-
-/*
- * call-seq:
- * meth.to_proc => prc
- *
- * Returns a <code>Proc</code> object corresponding to this method.
- */
-
-static VALUE
-method_proc(VALUE method)
-{
- VALUE procval;
- rb_proc_t *proc;
- /*
- * class Method
- * def to_proc
- * proc{|*args|
- * self.call(*args)
- * }
- * end
- * end
- */
- procval = rb_iterate(mlambda, 0, bmcall, method);
- GetProcPtr(procval, proc);
- proc->is_from_method = 1;
- return procval;
-}
-
-static VALUE
-rb_obj_is_method(VALUE m)
-{
- if (TYPE(m) == T_DATA && RDATA(m)->dmark == (RUBY_DATA_FUNC) bm_mark) {
- return Qtrue;
- }
- return Qfalse;
-}
-
-/*
- * call_seq:
- * local_jump_error.exit_value => obj
- *
- * Returns the exit value associated with this +LocalJumpError+.
- */
-static VALUE
-localjump_xvalue(VALUE exc)
-{
- return rb_iv_get(exc, "@exit_value");
-}
-
-/*
- * call-seq:
- * local_jump_error.reason => symbol
- *
- * The reason this block was terminated:
- * :break, :redo, :retry, :next, :return, or :noreason.
- */
-
-static VALUE
-localjump_reason(VALUE exc)
-{
- return rb_iv_get(exc, "@reason");
-}
-
-/*
- * call-seq:
- * prc.binding => binding
- *
- * Returns the binding associated with <i>prc</i>. Note that
- * <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
- * <code>Binding</code> object as its second parameter.
- *
- * def fred(param)
- * proc {}
- * end
- *
- * b = fred(99)
- * eval("param", b.binding) #=> 99
- * eval("param", b) #=> 99
- */
-static VALUE
-proc_binding(VALUE self)
-{
- rb_proc_t *proc;
- VALUE bindval = binding_alloc(rb_cBinding);
- rb_binding_t *bind;
-
- GetProcPtr(self, proc);
- GetBindingPtr(bindval, bind);
-
- if (TYPE(proc->block.iseq) == T_NODE) {
- rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
- }
-
- bind->env = proc->envval;
- bind->cref_stack = proc->special_cref_stack;
- return bindval;
-}
-
-/*
- * <code>Proc</code> objects are blocks of code that have been bound to
- * a set of local variables. Once bound, the code may be called in
- * different contexts and still access those variables.
- *
- * def gen_times(factor)
- * return Proc.new {|n| n*factor }
- * end
- *
- * times3 = gen_times(3)
- * times5 = gen_times(5)
- *
- * times3.call(12) #=> 36
- * times5.call(5) #=> 25
- * times3.call(times5.call(4)) #=> 60
- *
- */
-
-void
-Init_Proc(void)
-{
- /* Proc */
- rb_cProc = rb_define_class("Proc", rb_cObject);
- rb_undef_alloc_func(rb_cProc);
- rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, -1);
- rb_define_method(rb_cProc, "call", proc_call, -1);
- rb_define_method(rb_cProc, "[]", proc_call, -1);
- rb_define_method(rb_cProc, "yield", proc_call, -1);
- rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
- rb_define_method(rb_cProc, "arity", proc_arity, 0);
- rb_define_method(rb_cProc, "clone", proc_clone, 0);
- rb_define_method(rb_cProc, "dup", proc_dup, 0);
- rb_define_method(rb_cProc, "==", proc_eq, 1);
- rb_define_method(rb_cProc, "eql?", proc_eq, 1);
- rb_define_method(rb_cProc, "hash", proc_hash, 0);
- rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
- rb_define_method(rb_cProc, "lambda?", proc_lambda_p, 0);
- rb_define_method(rb_cProc, "binding", proc_binding, 0);
-
- /* Exceptions */
- rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
- rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0);
- rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
-
- rb_eSysStackError = rb_define_class("SystemStackError", rb_eException);
- sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
- OBJ_TAINT(sysstack_error);
- rb_register_mark_object(sysstack_error);
-
- /* utility functions */
- rb_define_global_function("proc", rb_block_proc, 0);
- rb_define_global_function("lambda", proc_lambda, 0);
-
- /* Method */
- rb_cMethod = rb_define_class("Method", rb_cObject);
- rb_undef_alloc_func(rb_cMethod);
- rb_undef_method(CLASS_OF(rb_cMethod), "new");
- rb_define_method(rb_cMethod, "==", method_eq, 1);
- rb_define_method(rb_cMethod, "eql?", method_eq, 1);
- rb_define_method(rb_cMethod, "hash", method_hash, 0);
- rb_define_method(rb_cMethod, "clone", method_clone, 0);
- rb_define_method(rb_cMethod, "call", rb_method_call, -1);
- rb_define_method(rb_cMethod, "[]", rb_method_call, -1);
- rb_define_method(rb_cMethod, "arity", method_arity_m, 0);
- rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
- rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
- rb_define_method(rb_cMethod, "to_proc", method_proc, 0);
- rb_define_method(rb_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);
- rb_define_method(rb_mKernel, "public_method", rb_obj_public_method, 1);
-
- /* UnboundMethod */
- rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject);
- rb_undef_alloc_func(rb_cUnboundMethod);
- rb_undef_method(CLASS_OF(rb_cUnboundMethod), "new");
- rb_define_method(rb_cUnboundMethod, "==", method_eq, 1);
- rb_define_method(rb_cUnboundMethod, "eql?", method_eq, 1);
- rb_define_method(rb_cUnboundMethod, "hash", method_hash, 0);
- rb_define_method(rb_cUnboundMethod, "clone", method_clone, 0);
- rb_define_method(rb_cUnboundMethod, "arity", method_arity_m, 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);
-
- /* Module#*_method */
- rb_define_method(rb_cModule, "instance_method", rb_mod_instance_method, 1);
- rb_define_method(rb_cModule, "public_instance_method", rb_mod_public_instance_method, 1);
- rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1);
-
- /* Kernel */
- rb_define_method(rb_mKernel, "define_singleton_method", rb_obj_define_method, -1);
-}
-
-/*
- * Objects of class <code>Binding</code> encapsulate the execution
- * context at some particular place in the code and retain this context
- * for future use. The variables, methods, value of <code>self</code>,
- * and possibly an iterator block that can be accessed in this context
- * are all retained. Binding objects can be created using
- * <code>Kernel#binding</code>, and are made available to the callback
- * of <code>Kernel#set_trace_func</code>.
- *
- * These binding objects can be passed as the second argument of the
- * <code>Kernel#eval</code> method, establishing an environment for the
- * evaluation.
- *
- * class Demo
- * def initialize(n)
- * @secret = n
- * end
- * def getBinding
- * return binding()
- * end
- * end
- *
- * k1 = Demo.new(99)
- * b1 = k1.getBinding
- * k2 = Demo.new(-3)
- * b2 = k2.getBinding
- *
- * eval("@secret", b1) #=> 99
- * eval("@secret", b2) #=> -3
- * eval("@secret") #=> nil
- *
- * Binding objects have no class-specific methods.
- *
- */
-
-void
-Init_Binding(void)
-{
- rb_cBinding = rb_define_class("Binding", rb_cObject);
- rb_undef_alloc_func(rb_cBinding);
- rb_undef_method(CLASS_OF(rb_cBinding), "new");
- rb_define_method(rb_cBinding, "clone", binding_clone, 0);
- rb_define_method(rb_cBinding, "dup", binding_dup, 0);
- rb_define_method(rb_cBinding, "eval", bind_eval, -1);
- rb_define_global_function("binding", rb_f_binding, 0);
-}
-
diff --git a/process.c b/process.c
index 14c8d1b169..0d16bb6e43 100644
--- a/process.c
+++ b/process.c
@@ -6,16 +6,14 @@
$Date$
created at: Tue Aug 10 14:30:50 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/signal.h"
-#include "vm_core.h"
-
+#include "ruby.h"
+#include "rubysig.h"
#include <stdio.h>
#include <errno.h>
#include <signal.h>
@@ -25,9 +23,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#ifdef __DJGPP__
#include <process.h>
#endif
@@ -42,7 +37,7 @@
#define EXIT_FAILURE 1
#endif
-struct timeval rb_time_interval(VALUE);
+struct timeval rb_time_interval _((VALUE));
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -50,7 +45,7 @@ struct timeval rb_time_interval(VALUE);
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
-#include "ruby/st.h"
+#include "st.h"
#ifdef __EMX__
#undef HAVE_GETPGRP
@@ -101,11 +96,6 @@ static VALUE S_Tms;
#undef HAVE_SETRGID
#endif
-#if defined(__MacOS_X__) || defined(__bsdi__)
-#define BROKEN_SETREUID 1
-#define BROKEN_SETREGID 1
-#endif
-
#ifdef BROKEN_SETREUID
#define setreuid ruby_setreuid
#endif
@@ -137,10 +127,10 @@ static VALUE S_Tms;
*/
static VALUE
-get_pid(void)
+get_pid()
{
rb_secure(2);
- return PIDT2NUM(getpid());
+ return INT2FIX(getpid());
}
@@ -161,13 +151,13 @@ get_pid(void)
*/
static VALUE
-get_ppid(void)
+get_ppid()
{
rb_secure(2);
#ifdef _WIN32
return INT2FIX(0);
#else
- return PIDT2NUM(getppid());
+ return INT2FIX(getppid());
#endif
}
@@ -203,29 +193,18 @@ get_ppid(void)
*/
static VALUE rb_cProcStatus;
-
-VALUE
-rb_last_status_get(void)
-{
- return GET_VM()->last_status;
-}
-
-void
-rb_last_status_set(int status, rb_pid_t pid)
-{
- rb_vm_t *vm = GET_VM();
- vm->last_status = rb_obj_alloc(rb_cProcStatus);
- rb_iv_set(vm->last_status, "status", INT2FIX(status));
- rb_iv_set(vm->last_status, "pid", PIDT2NUM(pid));
-}
+VALUE rb_last_status = Qnil;
static void
-rb_last_status_clear(void)
+last_status_set(status, pid)
+ int status, pid;
{
- rb_vm_t *vm = GET_VM();
- vm->last_status = Qnil;
+ rb_last_status = rb_obj_alloc(rb_cProcStatus);
+ rb_iv_set(rb_last_status, "status", INT2FIX(status));
+ rb_iv_set(rb_last_status, "pid", INT2FIX(pid));
}
+
/*
* call-seq:
* stat.to_i => fixnum
@@ -240,7 +219,8 @@ rb_last_status_clear(void)
*/
static VALUE
-pst_to_i(VALUE st)
+pst_to_i(st)
+ VALUE st;
{
return rb_iv_get(st, "status");
}
@@ -248,6 +228,21 @@ pst_to_i(VALUE st)
/*
* call-seq:
+ * stat.to_s => string
+ *
+ * Equivalent to _stat_<code>.to_i.to_s</code>.
+ */
+
+static VALUE
+pst_to_s(st)
+ VALUE st;
+{
+ return rb_fix2str(pst_to_i(st), 10);
+}
+
+
+/*
+ * call-seq:
* stat.pid => fixnum
*
* Returns the process ID that this status object represents.
@@ -258,25 +253,42 @@ pst_to_i(VALUE st)
*/
static VALUE
-pst_pid(VALUE st)
+pst_pid(st)
+ VALUE st;
{
return rb_iv_get(st, "pid");
}
-static void
-pst_message(VALUE str, rb_pid_t pid, int status)
+
+/*
+ * call-seq:
+ * stat.inspect => string
+ *
+ * Override the inspection method.
+ */
+
+static VALUE
+pst_inspect(st)
+ VALUE st;
{
+ VALUE pid;
+ int status;
+ VALUE str;
char buf[256];
- snprintf(buf, sizeof(buf), "pid %ld", (long)pid);
- rb_str_cat2(str, buf);
+
+ pid = pst_pid(st);
+ status = NUM2INT(st);
+
+ snprintf(buf, sizeof(buf), "#<%s: pid=%ld", rb_class2name(CLASS_OF(st)), NUM2LONG(pid));
+ str = rb_str_new2(buf);
if (WIFSTOPPED(status)) {
int stopsig = WSTOPSIG(status);
const char *signame = ruby_signal_name(stopsig);
if (signame) {
- snprintf(buf, sizeof(buf), " stopped SIG%s (signal %d)", signame, stopsig);
+ snprintf(buf, sizeof(buf), ",stopped(SIG%s=%d)", signame, stopsig);
}
else {
- snprintf(buf, sizeof(buf), " stopped signal %d", stopsig);
+ snprintf(buf, sizeof(buf), ",stopped(%d)", stopsig);
}
rb_str_cat2(str, buf);
}
@@ -284,67 +296,22 @@ pst_message(VALUE str, rb_pid_t pid, int status)
int termsig = WTERMSIG(status);
const char *signame = ruby_signal_name(termsig);
if (signame) {
- snprintf(buf, sizeof(buf), " SIG%s (signal %d)", signame, termsig);
+ snprintf(buf, sizeof(buf), ",signaled(SIG%s=%d)", signame, termsig);
}
else {
- snprintf(buf, sizeof(buf), " signal %d", termsig);
+ snprintf(buf, sizeof(buf), ",signaled(%d)", termsig);
}
rb_str_cat2(str, buf);
}
if (WIFEXITED(status)) {
- snprintf(buf, sizeof(buf), " exit %d", WEXITSTATUS(status));
+ snprintf(buf, sizeof(buf), ",exited(%d)", WEXITSTATUS(status));
rb_str_cat2(str, buf);
}
#ifdef WCOREDUMP
if (WCOREDUMP(status)) {
- rb_str_cat2(str, " (core dumped)");
+ rb_str_cat2(str, ",coredumped");
}
#endif
-}
-
-
-/*
- * call-seq:
- * stat.to_s => string
- *
- * Show pid and exit status as a string.
- */
-
-static VALUE
-pst_to_s(VALUE st)
-{
- rb_pid_t pid;
- int status;
- VALUE str;
-
- pid = NUM2LONG(pst_pid(st));
- status = NUM2INT(pst_to_i(st));
-
- str = rb_str_buf_new(0);
- pst_message(str, pid, status);
- return str;
-}
-
-
-/*
- * call-seq:
- * stat.inspect => string
- *
- * Override the inspection method.
- */
-
-static VALUE
-pst_inspect(VALUE st)
-{
- rb_pid_t pid;
- int status;
- VALUE str;
-
- pid = NUM2LONG(pst_pid(st));
- status = NUM2INT(pst_to_i(st));
-
- str = rb_sprintf("#<%s: ", rb_class2name(CLASS_OF(st)));
- pst_message(str, pid, status);
rb_str_cat2(str, ">");
return str;
}
@@ -359,7 +326,8 @@ pst_inspect(VALUE st)
*/
static VALUE
-pst_equal(VALUE st1, VALUE st2)
+pst_equal(st1, st2)
+ VALUE st1, st2;
{
if (st1 == st2) return Qtrue;
return rb_equal(pst_to_i(st1), st2);
@@ -379,7 +347,8 @@ pst_equal(VALUE st1, VALUE st2)
*/
static VALUE
-pst_bitand(VALUE st1, VALUE st2)
+pst_bitand(st1, st2)
+ VALUE st1, st2;
{
int status = NUM2INT(st1) & NUM2INT(st2);
@@ -400,7 +369,8 @@ pst_bitand(VALUE st1, VALUE st2)
*/
static VALUE
-pst_rshift(VALUE st1, VALUE st2)
+pst_rshift(st1, st2)
+ VALUE st1, st2;
{
int status = NUM2INT(st1) >> NUM2INT(st2);
@@ -418,7 +388,8 @@ pst_rshift(VALUE st1, VALUE st2)
*/
static VALUE
-pst_wifstopped(VALUE st)
+pst_wifstopped(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -438,7 +409,8 @@ pst_wifstopped(VALUE st)
*/
static VALUE
-pst_wstopsig(VALUE st)
+pst_wstopsig(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -457,7 +429,8 @@ pst_wstopsig(VALUE st)
*/
static VALUE
-pst_wifsignaled(VALUE st)
+pst_wifsignaled(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -478,7 +451,8 @@ pst_wifsignaled(VALUE st)
*/
static VALUE
-pst_wtermsig(VALUE st)
+pst_wtermsig(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -498,7 +472,8 @@ pst_wtermsig(VALUE st)
*/
static VALUE
-pst_wifexited(VALUE st)
+pst_wifexited(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -529,7 +504,8 @@ pst_wifexited(VALUE st)
*/
static VALUE
-pst_wexitstatus(VALUE st)
+pst_wexitstatus(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -548,7 +524,8 @@ pst_wexitstatus(VALUE st)
*/
static VALUE
-pst_success_p(VALUE st)
+pst_success_p(st)
+ VALUE st;
{
int status = NUM2INT(st);
@@ -567,7 +544,8 @@ pst_success_p(VALUE st)
*/
static VALUE
-pst_wcoredump(VALUE st)
+pst_wcoredump(st)
+ VALUE st;
{
#ifdef WCOREDUMP
int status = NUM2INT(st);
@@ -584,58 +562,45 @@ pst_wcoredump(VALUE st)
#if !defined(HAVE_WAITPID) && !defined(HAVE_WAIT4)
#define NO_WAITPID
static st_table *pid_tbl;
-#else
-struct waitpid_arg {
- rb_pid_t pid;
- int *st;
- int flags;
-};
#endif
-static VALUE
-rb_waitpid_blocking(void *data)
+int
+rb_waitpid(pid, st, flags)
+ int pid;
+ int *st;
+ int flags;
{
- rb_pid_t result;
+ int result;
#ifndef NO_WAITPID
- struct waitpid_arg *arg = data;
-#endif
+ int oflags = flags;
+ if (!rb_thread_alone()) { /* there're other threads to run */
+ flags |= WNOHANG;
+ }
+ retry:
TRAP_BEG;
-#if defined NO_WAITPID
- result = wait(data);
-#elif defined HAVE_WAITPID
- result = waitpid(arg->pid, arg->st, arg->flags);
+#ifdef HAVE_WAITPID
+ result = waitpid(pid, st, flags);
#else /* HAVE_WAIT4 */
- result = wait4(arg->pid, arg->st, arg->flags, NULL);
+ result = wait4(pid, st, flags, NULL);
#endif
TRAP_END;
- return (VALUE)result;
-}
-
-rb_pid_t
-rb_waitpid(rb_pid_t pid, int *st, int flags)
-{
- rb_pid_t result;
-#ifndef NO_WAITPID
- struct waitpid_arg arg;
-
- arg.pid = pid;
- arg.st = st;
- arg.flags = flags;
- result = (rb_pid_t)rb_thread_blocking_region(rb_waitpid_blocking, &arg,
- RB_UBF_DFL, 0);
if (result < 0) {
-#if 0
if (errno == EINTR) {
rb_thread_polling();
goto retry;
}
-#endif
return -1;
}
+ if (result == 0) {
+ if (oflags & WNOHANG) return 0;
+ rb_thread_polling();
+ if (rb_thread_alone()) flags = oflags;
+ goto retry;
+ }
#else /* NO_WAITPID */
- if (pid_tbl && st_lookup(pid_tbl, pid, (st_data_t *)st)) {
- rb_last_status_set(*st, pid);
+ if (pid_tbl && st_lookup(pid_tbl, pid, st)) {
+ last_status_set(*st, pid);
st_delete(pid_tbl, (st_data_t*)&pid, NULL);
return pid;
}
@@ -645,8 +610,9 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
}
for (;;) {
- result = (rb_pid_t)rb_thread_blocking_region(rb_waitpid_blocking,
- st, RB_UBF_DFL);
+ TRAP_BEG;
+ result = wait(st);
+ TRAP_END;
if (result < 0) {
if (errno == EINTR) {
rb_thread_schedule();
@@ -658,25 +624,27 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
break;
}
if (!pid_tbl)
- pid_tbl = st_init_numtable();
- st_insert(pid_tbl, pid, (st_data_t)st);
+ pid_tbl = st_init_numtable();
+ st_insert(pid_tbl, pid, st);
if (!rb_thread_alone()) rb_thread_schedule();
}
#endif
if (result > 0) {
- rb_last_status_set(*st, result);
+ last_status_set(*st, result);
}
return result;
}
#ifdef NO_WAITPID
struct wait_data {
- rb_pid_t pid;
+ int pid;
int status;
};
static int
-wait_each(rb_pid_t pid, int status, struct wait_data *data)
+wait_each(pid, status, data)
+ int pid, status;
+ struct wait_data *data;
{
if (data->status != -1) return ST_STOP;
@@ -686,10 +654,12 @@ wait_each(rb_pid_t pid, int status, struct wait_data *data)
}
static int
-waitall_each(rb_pid_t pid, int status, VALUE ary)
+waitall_each(pid, status, ary)
+ int pid, status;
+ VALUE ary;
{
- rb_last_status_set(status, pid);
- rb_ary_push(ary, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get());
+ last_status_set(status, pid);
+ rb_ary_push(ary, rb_assoc_new(INT2NUM(pid), rb_last_status));
return ST_DELETE;
}
#endif
@@ -754,11 +724,12 @@ waitall_each(rb_pid_t pid, int status, VALUE ary)
*/
static VALUE
-proc_wait(int argc, VALUE *argv)
+proc_wait(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE vpid, vflags;
- rb_pid_t pid;
- int flags, status;
+ int pid, flags, status;
rb_secure(2);
flags = 0;
@@ -767,7 +738,7 @@ proc_wait(int argc, VALUE *argv)
pid = -1;
}
else {
- pid = NUM2PIDT(vpid);
+ pid = NUM2INT(vpid);
if (argc == 2 && !NIL_P(vflags)) {
flags = NUM2UINT(vflags);
}
@@ -775,10 +746,9 @@ proc_wait(int argc, VALUE *argv)
if ((pid = rb_waitpid(pid, &status, flags)) < 0)
rb_sys_fail(0);
if (pid == 0) {
- rb_last_status_clear();
- return Qnil;
+ return rb_last_status = Qnil;
}
- return PIDT2NUM(pid);
+ return INT2FIX(pid);
}
@@ -800,11 +770,13 @@ proc_wait(int argc, VALUE *argv)
*/
static VALUE
-proc_wait2(int argc, VALUE *argv)
+proc_wait2(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE pid = proc_wait(argc, argv);
if (NIL_P(pid)) return Qnil;
- return rb_assoc_new(pid, rb_last_status_get());
+ return rb_assoc_new(pid, rb_last_status);
}
@@ -829,11 +801,10 @@ proc_wait2(int argc, VALUE *argv)
*/
static VALUE
-proc_waitall(void)
+proc_waitall()
{
VALUE result;
- rb_pid_t pid;
- int status;
+ int pid, status;
rb_secure(2);
result = rb_ary_new();
@@ -841,49 +812,51 @@ proc_waitall(void)
if (pid_tbl) {
st_foreach(pid_tbl, waitall_each, result);
}
-#else
- rb_last_status_clear();
-#endif
for (pid = -1;;) {
-#ifdef NO_WAITPID
pid = wait(&status);
-#else
- pid = rb_waitpid(-1, &status, 0);
-#endif
if (pid == -1) {
if (errno == ECHILD)
break;
-#ifdef NO_WAITPID
if (errno == EINTR) {
rb_thread_schedule();
continue;
}
-#endif
rb_sys_fail(0);
}
-#ifdef NO_WAITPID
- rb_last_status_set(status, pid);
-#endif
- rb_ary_push(result, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get()));
+ last_status_set(status, pid);
+ rb_ary_push(result, rb_assoc_new(INT2NUM(pid), rb_last_status));
+ }
+#else
+ rb_last_status = Qnil;
+ for (pid = -1;;) {
+ pid = rb_waitpid(-1, &status, 0);
+ if (pid == -1) {
+ if (errno == ECHILD)
+ break;
+ rb_sys_fail(0);
+ }
+ rb_ary_push(result, rb_assoc_new(INT2NUM(pid), rb_last_status));
}
+#endif
return result;
}
static VALUE
-detach_process_watcher(void *arg)
+detach_process_watcher(arg)
+ void *arg;
{
- rb_pid_t cpid, pid = (rb_pid_t)(VALUE)arg;
- int status;
+ int pid = (int)(VALUE)arg, status;
- while ((cpid = rb_waitpid(pid, &status, 0)) == 0) {
- /* wait while alive */
+ while (rb_waitpid(pid, &status, WNOHANG) == 0) {
+ rb_thread_sleep(1);
}
- return rb_last_status_get();
+ return rb_last_status;
}
VALUE
-rb_detach_process(rb_pid_t pid)
+rb_detach_process(pid)
+ int pid;
{
return rb_thread_create(detach_process_watcher, (void*)(VALUE)pid);
}
@@ -901,7 +874,8 @@ rb_detach_process(rb_pid_t pid)
* separate Ruby thread whose sole job is to reap the status of the
* process _pid_ when it terminates. Use <code>detach</code>
* only when you do not intent to explicitly wait for the child to
- * terminate.
+ * terminate. <code>detach</code> only checks the status
+ * periodically (currently once each second).
*
* The waiting thread returns the exit status of the detached process
* when it terminates, so you can use <code>Thread#join</code> to
@@ -938,26 +912,26 @@ static VALUE
proc_detach(VALUE obj, VALUE pid)
{
rb_secure(2);
- return rb_detach_process(NUM2PIDT(pid));
+ return rb_detach_process(NUM2INT(pid));
}
#ifndef HAVE_STRING_H
char *strtok();
#endif
-void rb_thread_stop_timer_thread(void);
-void rb_thread_start_timer_thread(void);
-void rb_thread_reset_timer_thread(void);
-
-#define before_exec() \
- (rb_enable_interrupt(), rb_thread_stop_timer_thread())
-#define after_exec() \
- (rb_thread_start_timer_thread(), rb_disable_interrupt())
+#ifdef HAVE_SETITIMER
+#define before_exec() rb_thread_stop_timer()
+#define after_exec() rb_thread_start_timer()
+#else
+#define before_exec()
+#define after_exec()
+#endif
-extern char *dln_find_exe(const char *fname, const char *path);
+extern char *dln_find_exe();
static void
-security(const char *str)
+security(str)
+ char *str;
{
if (rb_env_path_tainted()) {
if (rb_safe_level() > 0) {
@@ -967,15 +941,16 @@ security(const char *str)
}
static int
-proc_exec_v(char **argv, const char *prog)
+proc_exec_v(argv, prog)
+ char **argv;
+ char *prog;
{
if (!prog)
prog = argv[0];
+ security(prog);
prog = dln_find_exe(prog, 0);
- if (!prog) {
- errno = ENOENT;
+ if (!prog)
return -1;
- }
#if (defined(MSDOS) && !defined(DJGPP)) || defined(__human68k__) || defined(__EMX__) || defined(OS2)
{
@@ -1020,15 +995,23 @@ proc_exec_v(char **argv, const char *prog)
return -1;
}
-int
-rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
+static int
+proc_exec_n(argc, argv, progv)
+ int argc;
+ VALUE *argv;
+ VALUE progv;
{
+ char *prog = 0;
char **args;
int i;
+ if (progv) {
+ prog = RSTRING(progv)->ptr;
+ }
args = ALLOCA_N(char*, argc+1);
for (i=0; i<argc; i++) {
- args[i] = RSTRING_PTR(argv[i]);
+ SafeStringValue(argv[i]);
+ args[i] = RSTRING(argv[i])->ptr;
}
args[i] = 0;
if (args[0]) {
@@ -1038,29 +1021,24 @@ rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
}
int
-rb_proc_exec(const char *str)
+rb_proc_exec(str)
+ const char *str;
{
+#ifndef _WIN32
const char *s = str;
char *ss, *t;
char **argv, **a;
+#endif
while (*str && ISSPACE(*str))
str++;
#ifdef _WIN32
before_exec();
- rb_w32_spawn(P_OVERLAY, (char *)str, 0);
+ do_spawn(P_OVERLAY, (char *)str);
after_exec();
#else
for (s=str; *s; s++) {
- if (ISSPACE(*s)) {
- const char *p, *nl = NULL;
- for (p = s; ISSPACE(*p); p++) {
- if (*p == '\n') nl = p;
- }
- if (!*p) break;
- if (nl) s = nl;
- }
if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) {
#if defined(MSDOS)
int status;
@@ -1069,7 +1047,8 @@ rb_proc_exec(const char *str)
after_exec();
if (status != -1)
exit(status);
-#elif defined(__human68k__) || defined(__CYGWIN32__) || defined(__EMX__)
+#else
+#if defined(__human68k__) || defined(__CYGWIN32__) || defined(__EMX__)
char *shell = dln_find_exe("sh", 0);
int status = -1;
before_exec();
@@ -1085,13 +1064,13 @@ rb_proc_exec(const char *str)
execl("/bin/sh", "sh", "-c", str, (char *)NULL);
preserving_errno(after_exec());
#endif
+#endif
return -1;
}
}
a = argv = ALLOCA_N(char*, (s-str)/2+2);
ss = ALLOCA_N(char, s-str+1);
- memcpy(ss, str, s-str);
- ss[s-str] = '\0';
+ strcpy(ss, str);
if ((*a++ = strtok(ss, " \t")) != 0) {
while ((t = strtok(NULL, " \t")) != 0) {
*a++ = t;
@@ -1106,19 +1085,16 @@ rb_proc_exec(const char *str)
return -1;
}
-#if defined(_WIN32)
-#define HAVE_SPAWNV 1
-#endif
-
-#if !defined(HAVE_FORK) && defined(HAVE_SPAWNV)
-#if defined(_WIN32)
-#define proc_spawn_v(argv, prog) rb_w32_aspawn(P_NOWAIT, prog, argv)
-#else
-static rb_pid_t
-proc_spawn_v(char **argv, char *prog)
+#if defined(__human68k__) || defined(__DJGPP__) || defined(_WIN32)
+static int
+proc_spawn_v(argv, prog)
+ char **argv;
+ char *prog;
{
+#if defined(__human68k__)
char *extension;
- rb_pid_t status;
+#endif
+ int status;
if (!prog)
prog = argv[0];
@@ -1152,45 +1128,54 @@ proc_spawn_v(char **argv, char *prog)
}
#endif
before_exec();
+#if defined(_WIN32)
+ status = do_aspawn(P_WAIT, prog, argv);
+#else
status = spawnv(P_WAIT, prog, argv);
- rb_last_status_set(status == -1 ? 127 : status, 0);
+#endif
after_exec();
return status;
}
-#endif
-static rb_pid_t
-proc_spawn_n(int argc, VALUE *argv, VALUE prog)
+static int
+proc_spawn_n(argc, argv, prog)
+ int argc;
+ VALUE *argv;
+ VALUE prog;
{
char **args;
int i;
args = ALLOCA_N(char*, argc + 1);
for (i = 0; i < argc; i++) {
- args[i] = RSTRING_PTR(argv[i]);
+ SafeStringValue(argv[i]);
+ args[i] = StringValueCStr(argv[i]);
}
+ if (prog)
+ SafeStringValue(prog);
args[i] = (char*) 0;
if (args[0])
- return proc_spawn_v(args, prog ? RSTRING_PTR(prog) : 0);
+ return proc_spawn_v(args, prog ? StringValueCStr(prog) : 0);
return -1;
}
-#if defined(_WIN32)
-#define proc_spawn(str) rb_w32_spawn(P_NOWAIT, str, 0)
-#else
-static rb_pid_t
-proc_spawn(char *str)
+#if !defined(_WIN32)
+static int
+proc_spawn(sv)
+ VALUE sv;
{
+ char *str;
char *s, *t;
char **argv, **a;
- rb_pid_t status;
+ int status;
+ SafeStringValue(sv);
+ str = s = StringValueCStr(sv);
for (s = str; *s; s++) {
if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) {
char *shell = dln_find_exe("sh", 0);
before_exec();
status = shell?spawnl(P_WAIT,shell,"sh","-c",str,(char*)NULL):system(str);
- rb_last_status_set(status == -1 ? 127 : status, 0);
after_exec();
return status;
}
@@ -1208,37 +1193,51 @@ proc_spawn(char *str)
#endif
#endif
-VALUE
-rb_check_argv(int argc, VALUE *argv)
+struct rb_exec_arg {
+ int argc;
+ VALUE *argv;
+ VALUE prog;
+};
+
+static void
+proc_prepare_args(e, argc, argv, prog)
+ struct rb_exec_arg *e;
+ int argc;
+ VALUE *argv;
+ VALUE prog;
{
- VALUE tmp, prog;
int i;
- const char *name = 0;
- if (argc == 0) {
- rb_raise(rb_eArgError, "wrong number of arguments");
- }
-
- prog = 0;
- tmp = rb_check_array_type(argv[0]);
- if (!NIL_P(tmp)) {
- if (RARRAY_LEN(tmp) != 2) {
- rb_raise(rb_eArgError, "wrong first argument");
- }
- prog = RARRAY_PTR(tmp)[0];
- argv[0] = RARRAY_PTR(tmp)[1];
+ MEMZERO(e, struct rb_exec_arg, 1);
+ if (prog) {
SafeStringValue(prog);
StringValueCStr(prog);
- prog = rb_str_new4(prog);
- name = RSTRING_PTR(prog);
}
for (i = 0; i < argc; i++) {
SafeStringValue(argv[i]);
- argv[i] = rb_str_new4(argv[i]);
StringValueCStr(argv[i]);
}
- security(name ? name : RSTRING_PTR(argv[0]));
- return prog;
+ security(RSTRING(prog ? prog : argv[0])->ptr);
+ e->prog = prog;
+ e->argc = argc;
+ e->argv = argv;
+}
+
+static VALUE
+proc_exec_args(earg)
+ VALUE earg;
+{
+ struct rb_exec_arg *e = (struct rb_exec_arg *)earg;
+ int argc = e->argc;
+ VALUE *argv = e->argv;
+ VALUE prog = e->prog;
+
+ if (argc == 1 && prog == 0) {
+ return (VALUE)rb_proc_exec(RSTRING(argv[0])->ptr);
+ }
+ else {
+ return (VALUE)proc_exec_n(argc, argv, prog);
+ }
}
/*
@@ -1258,9 +1257,6 @@ rb_check_argv(int argc, VALUE *argv)
* used, so the running command may inherit some of the environment of
* the original program (including open file descriptors).
*
- * Raises SystemCallError if the _command_ couldn't execute (typically
- * <code>Errno::ENOENT</code> when it was not found).
- *
* exec "echo *" # echoes list of files in current directory
* # never get here
*
@@ -1270,185 +1266,34 @@ rb_check_argv(int argc, VALUE *argv)
*/
VALUE
-rb_f_exec(int argc, VALUE *argv)
+rb_f_exec(argc, argv)
+ int argc;
+ VALUE *argv;
{
- struct rb_exec_arg e;
- VALUE prog;
-
- prog = rb_check_argv(argc, argv);
- if (!prog && argc == 1) {
- e.argc = 0;
- e.argv = 0;
- e.prog = RSTRING_PTR(argv[0]);
- }
- else {
- e.argc = argc;
- e.argv = argv;
- e.prog = prog ? RSTRING_PTR(prog) : 0;
- }
- rb_exec(&e);
- rb_sys_fail(e.prog);
- return Qnil; /* dummy */
-}
-
-int
-rb_exec(const struct rb_exec_arg *e)
-{
- int argc = e->argc;
- VALUE *argv = e->argv;
- const char *prog = e->prog;
+ VALUE prog = 0;
+ VALUE tmp;
+ struct rb_exec_arg earg;
if (argc == 0) {
- rb_proc_exec(prog);
- }
- else {
- rb_proc_exec_n(argc, argv, prog);
+ rb_last_status = Qnil;
+ rb_raise(rb_eArgError, "wrong number of arguments");
}
-#ifndef FD_CLOEXEC
- preserving_errno({
- fprintf(stderr, "%s:%d: command not found: %s\n",
- rb_sourcefile(), rb_sourceline(), prog);
- });
-#endif
- return -1;
-}
-
-static int
-rb_exec_atfork(void* arg)
-{
- rb_thread_atfork();
- return rb_exec(arg);
-}
-#ifdef HAVE_FORK
-#ifdef FD_CLOEXEC
-#if SIZEOF_INT == SIZEOF_LONG
-#define proc_syswait (VALUE (*)(VALUE))rb_syswait
-#else
-static VALUE
-proc_syswait(VALUE pid)
-{
- rb_syswait((int)pid);
- return Qnil;
-}
-#endif
-#endif
-
-/*
- * Forks child process, and returns the process ID in the parent
- * process.
- *
- * If +status+ is given, protects from any exceptions and sets the
- * jump status to it.
- *
- * In the child process, just returns 0 if +chfunc+ is +NULL+.
- * Otherwise +chfunc+ will be called with +charg+, and then the child
- * process exits with +EXIT_SUCCESS+ when it returned zero.
- *
- * In the case of the function is called and returns non-zero value,
- * the child process exits with non-+EXIT_SUCCESS+ value (normaly
- * 127). And, on the platforms where +FD_CLOEXEC+ is available,
- * +errno+ is propagated to the parent process, and this function
- * returns -1 in the parent process. On the other platforms, just
- * returns pid.
- *
- * +chfunc+ must not raise any exceptions.
- */
-rb_pid_t
-rb_fork(int *status, int (*chfunc)(void*), void *charg)
-{
- rb_pid_t pid;
- int err, state = 0;
-#ifdef FD_CLOEXEC
- int ep[2];
-#endif
-
-#ifndef __VMS
-#define prefork() ( \
- rb_io_flush(rb_stdout), \
- rb_io_flush(rb_stderr) \
- )
-#else
-#define prefork() ((void)0)
-#endif
-
- prefork();
-
-#ifdef FD_CLOEXEC
- if (chfunc) {
- if (pipe(ep)) return -1;
- if (fcntl(ep[1], F_SETFD, FD_CLOEXEC)) {
- preserving_errno((close(ep[0]), close(ep[1])));
- return -1;
- }
- }
-#endif
- for (; (pid = fork()) < 0; prefork()) {
- switch (errno) {
- case EAGAIN:
-#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- if (!status && !chfunc) {
- rb_thread_sleep(1);
- continue;
- }
- else {
- rb_protect((VALUE (*)())rb_thread_sleep, 1, &state);
- if (status) *status = state;
- if (!state) continue;
- }
- default:
-#ifdef FD_CLOEXEC
- if (chfunc) {
- preserving_errno((close(ep[0]), close(ep[1])));
- }
-#endif
- if (state && !status) rb_jump_tag(state);
- return -1;
- }
- }
- if (!pid) {
- rb_thread_reset_timer_thread();
- if (chfunc) {
-#ifdef FD_CLOEXEC
- close(ep[0]);
-#endif
- if (!(*chfunc)(charg)) _exit(EXIT_SUCCESS);
-#ifdef FD_CLOEXEC
- err = errno;
- write(ep[1], &err, sizeof(err));
-#endif
-#if EXIT_SUCCESS == 127
- _exit(EXIT_FAILURE);
-#else
- _exit(127);
-#endif
- }
- rb_thread_start_timer_thread();
- }
-#ifdef FD_CLOEXEC
- else if (chfunc) {
- close(ep[1]);
- if ((state = read(ep[0], &err, sizeof(err))) < 0) {
- err = errno;
- }
- close(ep[0]);
- if (state) {
- if (status) {
- rb_protect(proc_syswait, (VALUE)pid, status);
- }
- else {
- rb_syswait(pid);
- }
- errno = err;
- return -1;
+ tmp = rb_check_array_type(argv[0]);
+ if (!NIL_P(tmp)) {
+ if (RARRAY(tmp)->len != 2) {
+ rb_raise(rb_eArgError, "wrong first argument");
}
+ prog = RARRAY(tmp)->ptr[0];
+ argv[0] = RARRAY(tmp)->ptr[1];
+ SafeStringValue(prog);
}
-#endif
- return pid;
+ proc_prepare_args(&earg, argc, argv, prog);
+ proc_exec_args((VALUE)&earg);
+ rb_sys_fail(RSTRING(argv[0])->ptr);
+ return Qnil; /* dummy */
}
-#endif
+
/*
* call-seq:
@@ -1472,14 +1317,20 @@ rb_fork(int *status, int (*chfunc)(void*), void *charg)
*/
static VALUE
-rb_f_fork(VALUE obj)
+rb_f_fork(obj)
+ VALUE obj;
{
-#if defined(HAVE_FORK) && !defined(__NetBSD__)
- rb_pid_t pid;
+#if !defined(__human68k__) && !defined(_WIN32) && !defined(__MACOS__) && !defined(__EMX__) && !defined(__VMS)
+ int pid;
rb_secure(2);
- switch (pid = rb_fork(0, 0, 0)) {
+#ifndef __VMS
+ fflush(stdout);
+ fflush(stderr);
+#endif
+
+ switch (pid = fork()) {
case 0:
#ifdef linux
after_exec();
@@ -1498,7 +1349,7 @@ rb_f_fork(VALUE obj)
return Qnil;
default:
- return PIDT2NUM(pid);
+ return INT2FIX(pid);
}
#else
rb_notimplement();
@@ -1518,7 +1369,10 @@ rb_f_fork(VALUE obj)
*/
static VALUE
-rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
+rb_f_exit_bang(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE status;
int istatus;
@@ -1545,146 +1399,22 @@ rb_f_exit_bang(int argc, VALUE *argv, VALUE obj)
return Qnil; /* not reached */
}
-void
-rb_exit(int status)
-{
- if (GET_THREAD()->tag) {
- VALUE args[2];
-
- args[0] = INT2NUM(status);
- args[1] = rb_str_new2("exit");
- rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
- }
- ruby_finalize();
- exit(status);
-}
-
-
-/*
- * call-seq:
- * exit(integer=0)
- * Kernel::exit(integer=0)
- * Process::exit(integer=0)
- *
- * Initiates the termination of the Ruby script by raising the
- * <code>SystemExit</code> exception. This exception may be caught. The
- * optional parameter is used to return a status code to the invoking
- * environment.
- *
- * begin
- * exit
- * puts "never get here"
- * rescue SystemExit
- * puts "rescued a SystemExit exception"
- * end
- * puts "after begin block"
- *
- * <em>produces:</em>
- *
- * rescued a SystemExit exception
- * after begin block
- *
- * Just prior to termination, Ruby executes any <code>at_exit</code> functions
- * (see Kernel::at_exit) and runs any object finalizers (see
- * ObjectSpace::define_finalizer).
- *
- * at_exit { puts "at_exit function" }
- * ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
- * exit
- *
- * <em>produces:</em>
- *
- * at_exit function
- * in finalizer
- */
-
-VALUE
-rb_f_exit(int argc, VALUE *argv)
-{
- VALUE status;
- int istatus;
-
- rb_secure(4);
- if (rb_scan_args(argc, argv, "01", &status) == 1) {
- switch (status) {
- case Qtrue:
- istatus = EXIT_SUCCESS;
- break;
- case Qfalse:
- istatus = EXIT_FAILURE;
- break;
- default:
- istatus = NUM2INT(status);
-#if EXIT_SUCCESS != 0
- if (istatus == 0)
- istatus = EXIT_SUCCESS;
-#endif
- break;
- }
- }
- else {
- istatus = EXIT_SUCCESS;
- }
- rb_exit(istatus);
- return Qnil; /* not reached */
-}
-
-
-/*
- * call-seq:
- * abort
- * Kernel::abort
- * Process::abort
- *
- * Terminate execution immediately, effectively by calling
- * <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
- * to STDERR prior to terminating.
- */
-
-VALUE
-rb_f_abort(int argc, VALUE *argv)
-{
- extern void ruby_error_print(void);
-
- rb_secure(4);
- if (argc == 0) {
- if (!NIL_P(GET_THREAD()->errinfo)) {
- ruby_error_print();
- }
- rb_exit(EXIT_FAILURE);
- }
- else {
- VALUE args[2];
-
- rb_scan_args(argc, argv, "1", &args[1]);
- StringValue(argv[0]);
- rb_io_puts(argc, argv, rb_stderr);
- args[0] = INT2NUM(EXIT_FAILURE);
- rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
- }
- return Qnil; /* not reached */
-}
-
-
#if defined(sun)
#define signal(a,b) sigset(a,b)
-#else
-# if defined(POSIX_SIGNAL)
-# define signal(a,b) posix_signal(a,b)
-# endif
#endif
void
-rb_syswait(rb_pid_t pid)
+rb_syswait(pid)
+ int pid;
{
static int overriding;
#ifdef SIGHUP
- RETSIGTYPE (*hfunc)(int);
+ RETSIGTYPE (*hfunc)_((int)) = 0;
#endif
#ifdef SIGQUIT
- RETSIGTYPE (*qfunc)(int);
+ RETSIGTYPE (*qfunc)_((int)) = 0;
#endif
- RETSIGTYPE (*ifunc)(int);
+ RETSIGTYPE (*ifunc)_((int)) = 0;
int status;
int i, hooked = Qfalse;
@@ -1716,57 +1446,15 @@ rb_syswait(rb_pid_t pid)
}
}
-rb_pid_t
-rb_spawn(int argc, VALUE *argv)
-{
- rb_pid_t status;
- VALUE prog;
-
- prog = rb_check_argv(argc, argv);
-
- if (!prog && argc == 1) {
- --argc;
- prog = *argv++;
- }
-#if defined HAVE_FORK
- {
- struct rb_exec_arg earg;
- earg.argc = argc;
- earg.argv = argv;
- earg.prog = prog ? RSTRING_PTR(prog) : 0;
- status = rb_fork(&status, rb_exec_atfork, &earg);
- if (prog && argc) argv[0] = prog;
- }
-#elif defined HAVE_SPAWNV
- if (!argc) {
- status = proc_spawn(RSTRING_PTR(prog));
- }
- else {
- status = proc_spawn_n(argc, argv, prog);
- }
- if (prog && argc) argv[0] = prog;
-#else
- if (prog && argc) argv[0] = prog;
- if (argc) prog = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
- status = system(StringValuePtr(prog));
-# if defined(__human68k__) || defined(__DJGPP__)
- rb_last_status_set(status == -1 ? 127 : status, 0);
-# else
- rb_last_status_set((status & 0xff) << 8, 0);
-# endif
-#endif
- return status;
-}
-
/*
* call-seq:
* system(cmd [, arg, ...]) => true or false
*
- * Executes _cmd_ in a subshell, returning +true+ if the command
- * gives zero exit status, +false+ for non zero exit status. Returns
- * +nil+ if command execution fails. An error status is available in
- * <code>$?</code>. The arguments are processed in the same way as
- * for <code>Kernel::exec</code>.
+ * Executes _cmd_ in a subshell, returning +true+ if
+ * the command was found and ran successfully, +false+
+ * otherwise. An error status is available in <code>$?</code>. The
+ * arguments are processed in the same way as for
+ * <code>Kernel::exec</code>.
*
* system("echo *")
* system("echo", "*")
@@ -1778,56 +1466,133 @@ rb_spawn(int argc, VALUE *argv)
*/
static VALUE
-rb_f_system(int argc, VALUE *argv)
+rb_f_system(argc, argv)
+ int argc;
+ VALUE *argv;
{
int status;
+#if defined(__EMX__)
+ VALUE cmd;
-#if defined(SIGCLD) && !defined(SIGCHLD)
-# define SIGCHLD SIGCLD
-#endif
+ fflush(stdout);
+ fflush(stderr);
+ if (argc == 0) {
+ rb_last_status = Qnil;
+ rb_raise(rb_eArgError, "wrong number of arguments");
+ }
-#ifdef SIGCHLD
- RETSIGTYPE (*chfunc)(int);
+ if (TYPE(argv[0]) == T_ARRAY) {
+ if (RARRAY(argv[0])->len != 2) {
+ rb_raise(rb_eArgError, "wrong first argument");
+ }
+ argv[0] = RARRAY(argv[0])->ptr[0];
+ }
+ cmd = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
- chfunc = signal(SIGCHLD, SIG_DFL);
-#endif
- status = rb_spawn(argc, argv);
-#if defined(HAVE_FORK) || defined(HAVE_SPAWNV)
- if (status > 0) {
- rb_syswait(status);
+ SafeStringValue(cmd);
+ status = do_spawn(RSTRING(cmd)->ptr);
+ last_status_set(status, 0);
+#elif defined(__human68k__) || defined(__DJGPP__) || defined(_WIN32)
+ volatile VALUE prog = 0;
+
+ fflush(stdout);
+ fflush(stderr);
+ if (argc == 0) {
+ rb_last_status = Qnil;
+ rb_raise(rb_eArgError, "wrong number of arguments");
}
+
+ if (TYPE(argv[0]) == T_ARRAY) {
+ if (RARRAY(argv[0])->len != 2) {
+ rb_raise(rb_eArgError, "wrong first argument");
+ }
+ prog = RARRAY(argv[0])->ptr[0];
+ argv[0] = RARRAY(argv[0])->ptr[1];
+ }
+
+ if (argc == 1 && prog == 0) {
+#if defined(_WIN32)
+ SafeStringValue(argv[0]);
+ status = do_spawn(P_WAIT, StringValueCStr(argv[0]));
+#else
+ status = proc_spawn(argv[0]);
#endif
-#ifdef SIGCHLD
- signal(SIGCHLD, chfunc);
-#endif
- if (status < 0) {
- return Qnil;
}
- status = NUM2INT(rb_last_status_get());
- if (status == EXIT_SUCCESS) return Qtrue;
- return Qfalse;
-}
+ else {
+ status = proc_spawn_n(argc, argv, prog);
+ }
+#if !defined(_WIN32)
+ last_status_set(status == -1 ? 127 : status, 0);
+#else
+ if (status == -1)
+ last_status_set(0x7f << 8, 0);
+#endif
+#elif defined(__VMS)
+ VALUE cmd;
-/*
- * call-seq:
- * spawn(cmd [, arg, ...]) => pid
- *
- * Similar to <code>Kernel::system</code> except for not waiting for
- * end of _cmd_, but returns its <i>pid</i>.
- */
+ if (argc == 0) {
+ rb_last_status = Qnil;
+ rb_raise(rb_eArgError, "wrong number of arguments");
+ }
-static VALUE
-rb_f_spawn(int argc, VALUE *argv)
-{
- rb_pid_t pid;
+ if (TYPE(argv[0]) == T_ARRAY) {
+ if (RARRAY(argv[0])->len != 2) {
+ rb_raise(rb_eArgError, "wrong first argument");
+ }
+ argv[0] = RARRAY(argv[0])->ptr[0];
+ }
+ cmd = rb_ary_join(rb_ary_new4(argc, argv), rb_str_new2(" "));
- pid = rb_spawn(argc, argv);
- if (pid == -1) rb_sys_fail(RSTRING_PTR(argv[0]));
-#if defined(HAVE_FORK) || defined(HAVE_SPAWNV)
- return PIDT2NUM(pid);
+ SafeStringValue(cmd);
+ status = system(StringValueCStr(cmd));
+ last_status_set((status & 0xff) << 8, 0);
#else
- return Qnil;
+ volatile VALUE prog = 0;
+ int pid;
+ struct rb_exec_arg earg;
+ RETSIGTYPE (*chfunc)(int);
+
+ fflush(stdout);
+ fflush(stderr);
+ if (argc == 0) {
+ rb_last_status = Qnil;
+ rb_raise(rb_eArgError, "wrong number of arguments");
+ }
+
+ if (TYPE(argv[0]) == T_ARRAY) {
+ if (RARRAY(argv[0])->len != 2) {
+ rb_raise(rb_eArgError, "wrong first argument");
+ }
+ prog = RARRAY(argv[0])->ptr[0];
+ argv[0] = RARRAY(argv[0])->ptr[1];
+ }
+ proc_prepare_args(&earg, argc, argv, prog);
+
+ chfunc = signal(SIGCHLD, SIG_DFL);
+ retry:
+ pid = fork();
+ if (pid == 0) {
+ /* child process */
+ rb_thread_atfork();
+ rb_protect(proc_exec_args, (VALUE)&earg, NULL);
+ _exit(127);
+ }
+ if (pid < 0) {
+ if (errno == EAGAIN) {
+ rb_thread_sleep(1);
+ goto retry;
+ }
+ }
+ else {
+ rb_syswait(pid);
+ }
+ signal(SIGCHLD, chfunc);
+ if (pid < 0) rb_sys_fail(0);
+ status = NUM2INT(rb_last_status);
#endif
+
+ if (status == EXIT_SUCCESS) return Qtrue;
+ return Qfalse;
}
/*
@@ -1848,7 +1613,9 @@ rb_f_spawn(int argc, VALUE *argv)
*/
static VALUE
-rb_f_sleep(int argc, VALUE *argv)
+rb_f_sleep(argc, argv)
+ int argc;
+ VALUE *argv;
{
int beg, end;
@@ -1869,6 +1636,10 @@ rb_f_sleep(int argc, VALUE *argv)
}
+#if defined(SIGCLD) && !defined(SIGCHLD)
+# define SIGCHLD SIGCLD
+#endif
+
/*
* call-seq:
* Process.getpgrp => integer
@@ -1881,20 +1652,22 @@ rb_f_sleep(int argc, VALUE *argv)
*/
static VALUE
-proc_getpgrp(void)
+proc_getpgrp()
{
- rb_pid_t pgrp;
+#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
+ int pgrp;
+#endif
rb_secure(2);
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
pgrp = getpgrp();
if (pgrp < 0) rb_sys_fail(0);
- return PIDT2NUM(pgrp);
+ return INT2FIX(pgrp);
#else
# ifdef HAVE_GETPGID
pgrp = getpgid(0);
if (pgrp < 0) rb_sys_fail(0);
- return PIDT2NUM(pgrp);
+ return INT2FIX(pgrp);
# else
rb_notimplement();
# endif
@@ -1911,7 +1684,7 @@ proc_getpgrp(void)
*/
static VALUE
-proc_setpgrp(void)
+proc_setpgrp()
{
rb_secure(2);
/* check for posix setpgid() first; this matches the posix */
@@ -1940,15 +1713,16 @@ proc_setpgrp(void)
*/
static VALUE
-proc_getpgid(VALUE obj, VALUE pid)
+proc_getpgid(obj, pid)
+ VALUE obj, pid;
{
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
- rb_pid_t i;
+ int i;
rb_secure(2);
- i = getpgid(NUM2PIDT(pid));
+ i = getpgid(NUM2INT(pid));
if (i < 0) rb_sys_fail(0);
- return PIDT2NUM(i);
+ return INT2NUM(i);
#else
rb_notimplement();
#endif
@@ -1964,14 +1738,15 @@ proc_getpgid(VALUE obj, VALUE pid)
*/
static VALUE
-proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
+proc_setpgid(obj, pid, pgrp)
+ VALUE obj, pid, pgrp;
{
#ifdef HAVE_SETPGID
- rb_pid_t ipid, ipgrp;
+ int ipid, ipgrp;
rb_secure(2);
- ipid = NUM2PIDT(pid);
- ipgrp = NUM2PIDT(pgrp);
+ ipid = NUM2INT(pid);
+ ipgrp = NUM2INT(pgrp);
if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0);
return INT2FIX(0);
@@ -1993,36 +1768,36 @@ proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
*/
static VALUE
-proc_setsid(void)
+proc_setsid()
{
#if defined(HAVE_SETSID)
- rb_pid_t pid;
+ int pid;
rb_secure(2);
pid = setsid();
if (pid < 0) rb_sys_fail(0);
- return PIDT2NUM(pid);
+ return INT2FIX(pid);
#elif defined(HAVE_SETPGRP) && defined(TIOCNOTTY)
- rb_pid_t pid;
- int ret;
+ rb_pid_t pid;
+ int ret;
- rb_secure(2);
- pid = getpid();
+ rb_secure(2);
+ pid = getpid();
#if defined(SETPGRP_VOID)
- ret = setpgrp();
- /* If `pid_t setpgrp(void)' is equivalent to setsid(),
- `ret' will be the same value as `pid', and following open() will fail.
- In Linux, `int setpgrp(void)' is equivalent to setpgid(0, 0). */
+ ret = setpgrp();
+ /* If `pid_t setpgrp(void)' is equivalent to setsid(),
+ `ret' will be the same value as `pid', and following open() will fail.
+ In Linux, `int setpgrp(void)' is equivalent to setpgid(0, 0). */
#else
- ret = setpgrp(0, pid);
+ ret = setpgrp(0, pid);
#endif
- if (ret == -1) rb_sys_fail(0);
+ if (ret == -1) rb_sys_fail(0);
- if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
- ioctl(fd, TIOCNOTTY, NULL);
- close(fd);
- }
- return PIDT2NUM(pid);
+ if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
+ ioctl(fd, TIOCNOTTY, NULL);
+ close(fd);
+ }
+ return INT2FIX(pid);
#else
rb_notimplement();
#endif
@@ -2047,7 +1822,8 @@ proc_setsid(void)
*/
static VALUE
-proc_getpriority(VALUE obj, VALUE which, VALUE who)
+proc_getpriority(obj, which, who)
+ VALUE obj, which, who;
{
#ifdef HAVE_GETPRIORITY
int prio, iwhich, iwho;
@@ -2079,7 +1855,8 @@ proc_getpriority(VALUE obj, VALUE which, VALUE who)
*/
static VALUE
-proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio)
+proc_setpriority(obj, which, who, prio)
+ VALUE obj, which, who, prio;
{
#ifdef HAVE_GETPRIORITY
int iwhich, iwho, iprio;
@@ -2136,7 +1913,7 @@ proc_getrlimit(VALUE obj, VALUE resource)
rb_secure(2);
if (getrlimit(NUM2INT(resource), &rlim) < 0) {
- rb_sys_fail("getrlimit");
+ rb_sys_fail("getrlimit");
}
return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max));
#else
@@ -2198,7 +1975,7 @@ proc_setrlimit(int argc, VALUE *argv, VALUE obj)
rlim.rlim_max = NUM2RLIM(rlim_max);
if (setrlimit(NUM2INT(resource), &rlim) < 0) {
- rb_sys_fail("setrlimit");
+ rb_sys_fail("setrlimit");
}
return Qnil;
#else
@@ -2208,7 +1985,7 @@ proc_setrlimit(int argc, VALUE *argv, VALUE obj)
static int under_uid_switch = 0;
static void
-check_uid_switch(void)
+check_uid_switch()
{
rb_secure(2);
if (under_uid_switch) {
@@ -2218,7 +1995,7 @@ check_uid_switch(void)
static int under_gid_switch = 0;
static void
-check_gid_switch(void)
+check_gid_switch()
{
rb_secure(2);
if (under_gid_switch) {
@@ -2248,11 +2025,12 @@ check_gid_switch(void)
*/
static VALUE
-p_sys_setuid(VALUE obj, VALUE id)
+p_sys_setuid(obj, id)
+ VALUE obj, id;
{
#if defined HAVE_SETUID
check_uid_switch();
- if (setuid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
+ if (setuid(NUM2INT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2271,11 +2049,12 @@ p_sys_setuid(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_setruid(VALUE obj, VALUE id)
+p_sys_setruid(obj, id)
+ VALUE obj, id;
{
#if defined HAVE_SETRUID
check_uid_switch();
- if (setruid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
+ if (setruid(NUM2INT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2293,11 +2072,12 @@ p_sys_setruid(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_seteuid(VALUE obj, VALUE id)
+p_sys_seteuid(obj, id)
+ VALUE obj, id;
{
#if defined HAVE_SETEUID
check_uid_switch();
- if (seteuid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
+ if (seteuid(NUM2INT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2317,11 +2097,12 @@ p_sys_seteuid(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
+p_sys_setreuid(obj, rid, eid)
+ VALUE obj, rid, eid;
{
#if defined HAVE_SETREUID
check_uid_switch();
- if (setreuid(NUM2UIDT(rid),NUM2UIDT(eid)) != 0) rb_sys_fail(0);
+ if (setreuid(NUM2INT(rid),NUM2INT(eid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2341,11 +2122,12 @@ p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
*/
static VALUE
-p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
+p_sys_setresuid(obj, rid, eid, sid)
+ VALUE obj, rid, eid, sid;
{
#if defined HAVE_SETRESUID
check_uid_switch();
- if (setresuid(NUM2UIDT(rid),NUM2UIDT(eid),NUM2UIDT(sid)) != 0) rb_sys_fail(0);
+ if (setresuid(NUM2INT(rid),NUM2INT(eid),NUM2INT(sid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2365,10 +2147,11 @@ p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
*/
static VALUE
-proc_getuid(VALUE obj)
+proc_getuid(obj)
+ VALUE obj;
{
- rb_uid_t uid = getuid();
- return UIDT2NUM(uid);
+ int uid = getuid();
+ return INT2FIX(uid);
}
@@ -2381,13 +2164,12 @@ proc_getuid(VALUE obj)
*/
static VALUE
-proc_setuid(VALUE obj, VALUE id)
+proc_setuid(obj, id)
+ VALUE obj, id;
{
- rb_uid_t uid;
+ int uid = NUM2INT(id);
check_uid_switch();
-
- uid = NUM2UIDT(id);
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
if (setresuid(uid, -1, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREUID
@@ -2406,7 +2188,7 @@ proc_setuid(VALUE obj, VALUE id)
#else
rb_notimplement();
#endif
- return id;
+ return INT2FIX(uid);
}
@@ -2420,11 +2202,12 @@ proc_setuid(VALUE obj, VALUE id)
*
*/
-static rb_uid_t SAVED_USER_ID = -1;
+static int SAVED_USER_ID = -1;
#ifdef BROKEN_SETREUID
int
-setreuid(rb_uid_t ruid, rb_uid_t euid)
+setreuid(ruid, euid)
+ rb_uid_t ruid, euid;
{
if (ruid != -1 && ruid != getuid()) {
if (euid == -1) euid = geteuid();
@@ -2451,13 +2234,14 @@ setreuid(rb_uid_t ruid, rb_uid_t euid)
*/
static VALUE
-p_uid_change_privilege(VALUE obj, VALUE id)
+p_uid_change_privilege(obj, id)
+ VALUE obj, id;
{
- rb_uid_t uid;
+ int uid;
check_uid_switch();
- uid = NUM2UIDT(id);
+ uid = NUM2INT(id);
if (geteuid() == 0) { /* root-user */
#if defined(HAVE_SETRESUID)
@@ -2585,7 +2369,7 @@ p_uid_change_privilege(VALUE obj, VALUE id)
rb_notimplement();
#endif
}
- return id;
+ return INT2FIX(uid);
}
@@ -2600,11 +2384,12 @@ p_uid_change_privilege(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_setgid(VALUE obj, VALUE id)
+p_sys_setgid(obj, id)
+ VALUE obj, id;
{
#if defined HAVE_SETGID
check_gid_switch();
- if (setgid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
+ if (setgid(NUM2INT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2622,11 +2407,12 @@ p_sys_setgid(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_setrgid(VALUE obj, VALUE id)
+p_sys_setrgid(obj, id)
+ VALUE obj, id;
{
#if defined HAVE_SETRGID
check_gid_switch();
- if (setrgid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
+ if (setrgid(NUM2INT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2645,11 +2431,12 @@ p_sys_setrgid(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_setegid(VALUE obj, VALUE id)
+p_sys_setegid(obj, id)
+ VALUE obj, id;
{
#if defined HAVE_SETEGID
check_gid_switch();
- if (setegid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
+ if (setegid(NUM2INT(id)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2669,11 +2456,12 @@ p_sys_setegid(VALUE obj, VALUE id)
*/
static VALUE
-p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
+p_sys_setregid(obj, rid, eid)
+ VALUE obj, rid, eid;
{
#if defined HAVE_SETREGID
check_gid_switch();
- if (setregid(NUM2GIDT(rid),NUM2GIDT(eid)) != 0) rb_sys_fail(0);
+ if (setregid(NUM2INT(rid),NUM2INT(eid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2692,11 +2480,12 @@ p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
*/
static VALUE
-p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
+p_sys_setresgid(obj, rid, eid, sid)
+ VALUE obj, rid, eid, sid;
{
#if defined HAVE_SETRESGID
check_gid_switch();
- if (setresgid(NUM2GIDT(rid),NUM2GIDT(eid),NUM2GIDT(sid)) != 0) rb_sys_fail(0);
+ if (setresgid(NUM2INT(rid),NUM2INT(eid),NUM2INT(sid)) != 0) rb_sys_fail(0);
#else
rb_notimplement();
#endif
@@ -2717,7 +2506,8 @@ p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
*/
static VALUE
-p_sys_issetugid(VALUE obj)
+p_sys_issetugid(obj)
+ VALUE obj;
{
#if defined HAVE_ISSETUGID
rb_secure(2);
@@ -2745,10 +2535,11 @@ p_sys_issetugid(VALUE obj)
*/
static VALUE
-proc_getgid(VALUE obj)
+proc_getgid(obj)
+ VALUE obj;
{
- rb_gid_t gid = getgid();
- return GIDT2NUM(gid);
+ int gid = getgid();
+ return INT2FIX(gid);
}
@@ -2760,13 +2551,12 @@ proc_getgid(VALUE obj)
*/
static VALUE
-proc_setgid(VALUE obj, VALUE id)
+proc_setgid(obj, id)
+ VALUE obj, id;
{
- rb_gid_t gid;
+ int gid = NUM2INT(id);
check_gid_switch();
-
- gid = NUM2GIDT(id);
#if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREGID
@@ -2785,7 +2575,7 @@ proc_setgid(VALUE obj, VALUE id)
#else
rb_notimplement();
#endif
- return GIDT2NUM(gid);
+ return INT2FIX(gid);
}
@@ -2820,7 +2610,7 @@ proc_getgroups(VALUE obj)
ary = rb_ary_new();
for (i = 0; i < ngroups; i++)
- rb_ary_push(ary, GIDT2NUM(groups[i]));
+ rb_ary_push(ary, INT2NUM(groups[i]));
return ary;
#else
@@ -2854,29 +2644,29 @@ proc_setgroups(VALUE obj, VALUE ary)
Check_Type(ary, T_ARRAY);
- ngroups = RARRAY_LEN(ary);
+ ngroups = RARRAY(ary)->len;
if (ngroups > maxgroups)
- rb_raise(rb_eArgError, "too many groups, %lu max", (unsigned long)maxgroups);
+ rb_raise(rb_eArgError, "too many groups, %d max", maxgroups);
groups = ALLOCA_N(rb_gid_t, ngroups);
- for (i = 0; i < ngroups && i < RARRAY_LEN(ary); i++) {
- VALUE g = RARRAY_PTR(ary)[i];
+ for (i = 0; i < ngroups && i < RARRAY(ary)->len; i++) {
+ VALUE g = RARRAY(ary)->ptr[i];
if (FIXNUM_P(g)) {
- groups[i] = NUM2GIDT(g);
+ groups[i] = FIX2INT(g);
}
else {
VALUE tmp = rb_check_string_type(g);
if (NIL_P(tmp)) {
- groups[i] = NUM2GIDT(g);
+ groups[i] = NUM2INT(g);
}
else {
- gr = getgrnam(RSTRING_PTR(tmp));
+ gr = getgrnam(RSTRING(tmp)->ptr);
if (gr == NULL)
rb_raise(rb_eArgError,
- "can't find group for %s", RSTRING_PTR(tmp));
+ "can't find group for %s", RSTRING(tmp)->ptr);
groups[i] = gr->gr_gid;
}
}
@@ -2912,10 +2702,11 @@ proc_setgroups(VALUE obj, VALUE ary)
*/
static VALUE
-proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp)
+proc_initgroups(obj, uname, base_grp)
+ VALUE obj, uname, base_grp;
{
#ifdef HAVE_INITGROUPS
- if (initgroups(StringValuePtr(uname), NUM2GIDT(base_grp)) != 0) {
+ if (initgroups(StringValuePtr(uname), (rb_gid_t)NUM2INT(base_grp)) != 0) {
rb_sys_fail(0);
}
return proc_getgroups(obj);
@@ -2937,7 +2728,8 @@ proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp)
*/
static VALUE
-proc_getmaxgroups(VALUE obj)
+proc_getmaxgroups(obj)
+ VALUE obj;
{
return INT2FIX(maxgroups);
}
@@ -2964,59 +2756,6 @@ proc_setmaxgroups(VALUE obj, VALUE val)
return INT2FIX(maxgroups);
}
-/*
- * call-seq:
- * Process.daemon() => fixnum
- * Process.daemon(nochdir=nil,noclose=nil) => fixnum
- *
- * Detach the process from controlling terminal and run in
- * the background as system daemon. Unless the argument
- * nochdir is true (i.e. non false), it changes the current
- * working directory to the root ("/"). Unless the argument
- * noclose is true, daemon() will redirect standard input,
- * standard output and standard error to /dev/null.
- */
-
-static VALUE
-proc_daemon(int argc, VALUE *argv)
-{
- VALUE nochdir, noclose;
- int n;
-
- rb_secure(2);
- rb_scan_args(argc, argv, "02", &nochdir, &noclose);
-
-#if defined(HAVE_DAEMON)
- n = daemon(RTEST(nochdir), RTEST(noclose));
- if (n < 0) rb_sys_fail("daemon");
- return INT2FIX(n);
-#elif defined(HAVE_FORK)
- switch (rb_fork(0, 0, 0)) {
- case -1:
- return (-1);
- case 0:
- break;
- default:
- _exit(0);
- }
-
- proc_setsid();
-
- if (!RTEST(nochdir))
- (void)chdir("/");
-
- if (!RTEST(noclose) && (n = open("/dev/null", O_RDWR, 0)) != -1) {
- (void)dup2(n, 0);
- (void)dup2(n, 1);
- (void)dup2(n, 2);
- if (n > 2)
- (void)close (n);
- }
- return INT2FIX(0);
-#else
- rb_notimplement();
-#endif
-}
/********************************************************************
*
@@ -3032,7 +2771,8 @@ static int SAVED_GROUP_ID = -1;
#ifdef BROKEN_SETREGID
int
-setregid(rb_gid_t rgid, rb_gid_t egid)
+setregid(rgid, egid)
+ rb_gid_t rgid, egid;
{
if (rgid != -1 && rgid != getgid()) {
if (egid == -1) egid = getegid();
@@ -3059,13 +2799,14 @@ setregid(rb_gid_t rgid, rb_gid_t egid)
*/
static VALUE
-p_gid_change_privilege(VALUE obj, VALUE id)
+p_gid_change_privilege(obj, id)
+ VALUE obj, id;
{
- rb_gid_t gid;
+ int gid;
check_gid_switch();
- gid = NUM2GIDT(id);
+ gid = NUM2INT(id);
if (geteuid() == 0) { /* root-user */
#if defined(HAVE_SETRESGID)
@@ -3157,7 +2898,7 @@ p_gid_change_privilege(VALUE obj, VALUE id)
if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0);
SAVED_GROUP_ID = gid;
if (setrgid(gid) < 0) rb_sys_fail(0);
- }
+ }
} else if (/* getegid() != gid && */ getgid() == gid) {
if (setegid(gid) < 0) rb_sys_fail(0);
if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0);
@@ -3194,7 +2935,7 @@ p_gid_change_privilege(VALUE obj, VALUE id)
rb_notimplement();
#endif
}
- return id;
+ return INT2FIX(gid);
}
@@ -3210,10 +2951,11 @@ p_gid_change_privilege(VALUE obj, VALUE id)
*/
static VALUE
-proc_geteuid(VALUE obj)
+proc_geteuid(obj)
+ VALUE obj;
{
- rb_uid_t euid = geteuid();
- return UIDT2NUM(euid);
+ int euid = geteuid();
+ return INT2FIX(euid);
}
@@ -3226,22 +2968,20 @@ proc_geteuid(VALUE obj)
*/
static VALUE
-proc_seteuid(VALUE obj, VALUE euid)
+proc_seteuid(obj, euid)
+ VALUE obj, euid;
{
- rb_uid_t uid;
-
check_uid_switch();
-
- uid = NUM2UIDT(euid);
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
- if (setresuid(-1, uid, -1) < 0) rb_sys_fail(0);
+ if (setresuid(-1, NUM2INT(euid), -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREUID
- if (setreuid(-1, uid) < 0) rb_sys_fail(0);
+ if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0);
#elif defined HAVE_SETEUID
- if (seteuid(uid) < 0) rb_sys_fail(0);
+ if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
#elif defined HAVE_SETUID
- if (uid == getuid()) {
- if (setuid(uid) < 0) rb_sys_fail(0);
+ euid = NUM2INT(euid);
+ if (euid == getuid()) {
+ if (setuid(euid) < 0) rb_sys_fail(0);
}
else {
rb_notimplement();
@@ -3252,10 +2992,11 @@ proc_seteuid(VALUE obj, VALUE euid)
return euid;
}
-static rb_uid_t
-rb_seteuid_core(rb_uid_t euid)
+static VALUE
+rb_seteuid_core(euid)
+ int euid;
{
- rb_uid_t uid;
+ int uid;
check_uid_switch();
@@ -3283,7 +3024,7 @@ rb_seteuid_core(rb_uid_t euid)
#else
rb_notimplement();
#endif
- return euid;
+ return INT2FIX(euid);
}
@@ -3302,10 +3043,10 @@ rb_seteuid_core(rb_uid_t euid)
*/
static VALUE
-p_uid_grant_privilege(VALUE obj, VALUE id)
+p_uid_grant_privilege(obj, id)
+ VALUE obj, id;
{
- rb_seteuid_core(NUM2UIDT(id));
- return id;
+ return rb_seteuid_core(NUM2INT(id));
}
@@ -3322,11 +3063,12 @@ p_uid_grant_privilege(VALUE obj, VALUE id)
*/
static VALUE
-proc_getegid(VALUE obj)
+proc_getegid(obj)
+ VALUE obj;
{
- rb_gid_t egid = getegid();
+ int egid = getegid();
- return GIDT2NUM(egid);
+ return INT2FIX(egid);
}
@@ -3339,22 +3081,21 @@ proc_getegid(VALUE obj)
*/
static VALUE
-proc_setegid(VALUE obj, VALUE egid)
+proc_setegid(obj, egid)
+ VALUE obj, egid;
{
- rb_gid_t gid;
-
check_gid_switch();
- gid = NUM2GIDT(egid);
#if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
- if (setresgid(-1, gid, -1) < 0) rb_sys_fail(0);
+ if (setresgid(-1, NUM2INT(egid), -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETREGID
- if (setregid(-1, gid) < 0) rb_sys_fail(0);
+ if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0);
#elif defined HAVE_SETEGID
- if (setegid(gid) < 0) rb_sys_fail(0);
+ if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
#elif defined HAVE_SETGID
- if (gid == getgid()) {
- if (setgid(gid) < 0) rb_sys_fail(0);
+ egid = NUM2INT(egid);
+ if (egid == getgid()) {
+ if (setgid(egid) < 0) rb_sys_fail(0);
}
else {
rb_notimplement();
@@ -3365,10 +3106,11 @@ proc_setegid(VALUE obj, VALUE egid)
return egid;
}
-static rb_gid_t
-rb_setegid_core(rb_gid_t egid)
+static VALUE
+rb_setegid_core(egid)
+ int egid;
{
- rb_gid_t gid;
+ int gid;
check_gid_switch();
@@ -3396,7 +3138,7 @@ rb_setegid_core(rb_gid_t egid)
#else
rb_notimplement();
#endif
- return egid;
+ return INT2FIX(egid);
}
@@ -3415,10 +3157,10 @@ rb_setegid_core(rb_gid_t egid)
*/
static VALUE
-p_gid_grant_privilege(VALUE obj, VALUE id)
+p_gid_grant_privilege(obj, id)
+ VALUE obj, id;
{
- rb_setegid_core(NUM2GIDT(id));
- return id;
+ return rb_setegid_core(NUM2INT(id));
}
@@ -3432,7 +3174,7 @@ p_gid_grant_privilege(VALUE obj, VALUE id)
*/
static VALUE
-p_uid_exchangeable(void)
+p_uid_exchangeable()
{
#if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
return Qtrue;
@@ -3457,9 +3199,10 @@ p_uid_exchangeable(void)
*/
static VALUE
-p_uid_exchange(VALUE obj)
+p_uid_exchange(obj)
+ VALUE obj;
{
- rb_uid_t uid, euid;
+ int uid, euid;
check_uid_switch();
@@ -3475,7 +3218,7 @@ p_uid_exchange(VALUE obj)
#else
rb_notimplement();
#endif
- return UIDT2NUM(uid);
+ return INT2FIX(uid);
}
@@ -3489,7 +3232,7 @@ p_uid_exchange(VALUE obj)
*/
static VALUE
-p_gid_exchangeable(void)
+p_gid_exchangeable()
{
#if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
return Qtrue;
@@ -3514,9 +3257,10 @@ p_gid_exchangeable(void)
*/
static VALUE
-p_gid_exchange(VALUE obj)
+p_gid_exchange(obj)
+ VALUE obj;
{
- rb_gid_t gid, egid;
+ int gid, egid;
check_gid_switch();
@@ -3532,7 +3276,7 @@ p_gid_exchange(VALUE obj)
#else
rb_notimplement();
#endif
- return GIDT2NUM(gid);
+ return INT2FIX(gid);
}
/* [MG] :FIXME: Is this correct? I'm not sure how to phrase this. */
@@ -3547,7 +3291,7 @@ p_gid_exchange(VALUE obj)
*/
static VALUE
-p_uid_have_saved_id(void)
+p_uid_have_saved_id()
{
#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS)
return Qtrue;
@@ -3559,11 +3303,11 @@ p_uid_have_saved_id(void)
#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS)
static VALUE
-p_uid_sw_ensure(rb_uid_t id)
+p_uid_sw_ensure(id)
+ int id;
{
under_uid_switch = 0;
- id = rb_seteuid_core(id);
- return UIDT2NUM(id);
+ return rb_seteuid_core(id);
}
@@ -3581,9 +3325,10 @@ p_uid_sw_ensure(rb_uid_t id)
*/
static VALUE
-p_uid_switch(VALUE obj)
+p_uid_switch(obj)
+ VALUE obj;
{
- rb_uid_t uid, euid;
+ int uid, euid;
check_uid_switch();
@@ -3591,38 +3336,40 @@ p_uid_switch(VALUE obj)
euid = geteuid();
if (uid != euid) {
- proc_seteuid(obj, UIDT2NUM(uid));
+ proc_seteuid(obj, INT2FIX(uid));
if (rb_block_given_p()) {
under_uid_switch = 1;
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, SAVED_USER_ID);
} else {
- return UIDT2NUM(euid);
+ return INT2FIX(euid);
}
} else if (euid != SAVED_USER_ID) {
- proc_seteuid(obj, UIDT2NUM(SAVED_USER_ID));
+ proc_seteuid(obj, INT2FIX(SAVED_USER_ID));
if (rb_block_given_p()) {
under_uid_switch = 1;
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, euid);
} else {
- return UIDT2NUM(uid);
+ return INT2FIX(uid);
}
} else {
errno = EPERM;
rb_sys_fail(0);
}
-}
+
#else
static VALUE
-p_uid_sw_ensure(VALUE obj)
+p_uid_sw_ensure(obj)
+ VALUE obj;
{
under_uid_switch = 0;
return p_uid_exchange(obj);
}
static VALUE
-p_uid_switch(VALUE obj)
+p_uid_switch(obj)
+ VALUE obj;
{
- rb_uid_t uid, euid;
+ int uid, euid;
check_uid_switch();
@@ -3638,10 +3385,10 @@ p_uid_switch(VALUE obj)
under_uid_switch = 1;
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, obj);
} else {
- return UIDT2NUM(euid);
+ return INT2FIX(euid);
}
-}
#endif
+}
/* [MG] :FIXME: Is this correct? I'm not sure how to phrase this. */
@@ -3656,7 +3403,7 @@ p_uid_switch(VALUE obj)
*/
static VALUE
-p_gid_have_saved_id(void)
+p_gid_have_saved_id()
{
#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS)
return Qtrue;
@@ -3667,11 +3414,11 @@ p_gid_have_saved_id(void)
#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || defined(_POSIX_SAVED_IDS)
static VALUE
-p_gid_sw_ensure(rb_gid_t id)
+p_gid_sw_ensure(id)
+ int id;
{
under_gid_switch = 0;
- id = rb_setegid_core(id);
- return GIDT2NUM(id);
+ return rb_setegid_core(id);
}
@@ -3689,7 +3436,8 @@ p_gid_sw_ensure(rb_gid_t id)
*/
static VALUE
-p_gid_switch(VALUE obj)
+p_gid_switch(obj)
+ VALUE obj;
{
int gid, egid;
@@ -3699,38 +3447,39 @@ p_gid_switch(VALUE obj)
egid = getegid();
if (gid != egid) {
- proc_setegid(obj, GIDT2NUM(gid));
+ proc_setegid(obj, INT2FIX(gid));
if (rb_block_given_p()) {
under_gid_switch = 1;
return rb_ensure(rb_yield, Qnil, p_gid_sw_ensure, SAVED_GROUP_ID);
} else {
- return GIDT2NUM(egid);
+ return INT2FIX(egid);
}
} else if (egid != SAVED_GROUP_ID) {
- proc_setegid(obj, GIDT2NUM(SAVED_GROUP_ID));
+ proc_setegid(obj, INT2FIX(SAVED_GROUP_ID));
if (rb_block_given_p()) {
under_gid_switch = 1;
return rb_ensure(rb_yield, Qnil, p_gid_sw_ensure, egid);
} else {
- return GIDT2NUM(gid);
+ return INT2FIX(gid);
}
} else {
errno = EPERM;
rb_sys_fail(0);
}
-}
#else
static VALUE
-p_gid_sw_ensure(VALUE obj)
+p_gid_sw_ensure(obj)
+ VALUE obj;
{
under_gid_switch = 0;
return p_gid_exchange(obj);
}
static VALUE
-p_gid_switch(VALUE obj)
+p_gid_switch(obj)
+ VALUE obj;
{
- rb_gid_t gid, egid;
+ int gid, egid;
check_gid_switch();
@@ -3746,10 +3495,10 @@ p_gid_switch(VALUE obj)
under_gid_switch = 1;
return rb_ensure(rb_yield, Qnil, p_gid_sw_ensure, obj);
} else {
- return GIDT2NUM(egid);
+ return INT2FIX(egid);
}
-}
#endif
+}
/*
@@ -3765,7 +3514,8 @@ p_gid_switch(VALUE obj)
*/
VALUE
-rb_proc_times(VALUE obj)
+rb_proc_times(obj)
+ VALUE obj;
{
#if defined(HAVE_TIMES) && !defined(__CHECKER__)
const double hertz =
@@ -3786,10 +3536,10 @@ rb_proc_times(VALUE obj)
times(&buf);
return rb_struct_new(S_Tms,
- utime = DOUBLE2NUM(buf.tms_utime / hertz),
- stime = DOUBLE2NUM(buf.tms_stime / hertz),
- cutime = DOUBLE2NUM(buf.tms_cutime / hertz),
- sctime = DOUBLE2NUM(buf.tms_cstime / hertz));
+ utime = rb_float_new(buf.tms_utime / hertz),
+ stime = rb_float_new(buf.tms_stime / hertz),
+ cutime = rb_float_new(buf.tms_cutime / hertz),
+ sctime = rb_float_new(buf.tms_cstime / hertz));
#else
rb_notimplement();
#endif
@@ -3807,21 +3557,19 @@ VALUE rb_mProcID_Syscall;
*/
void
-Init_process(void)
+Init_process()
{
- rb_define_virtual_variable("$?", rb_last_status_get, 0);
rb_define_virtual_variable("$$", get_pid, 0);
+ rb_define_readonly_variable("$?", &rb_last_status);
rb_define_global_function("exec", rb_f_exec, -1);
rb_define_global_function("fork", rb_f_fork, 0);
rb_define_global_function("exit!", rb_f_exit_bang, -1);
rb_define_global_function("system", rb_f_system, -1);
- rb_define_global_function("spawn", rb_f_spawn, -1);
rb_define_global_function("sleep", rb_f_sleep, -1);
- rb_define_global_function("exit", rb_f_exit, -1);
- rb_define_global_function("abort", rb_f_abort, -1);
rb_mProcess = rb_define_module("Process");
+#if !defined(_WIN32) && !defined(DJGPP)
#ifdef WNOHANG
rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(WNOHANG));
#else
@@ -3832,13 +3580,13 @@ Init_process(void)
#else
rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(0));
#endif
+#endif
rb_define_singleton_method(rb_mProcess, "exec", rb_f_exec, -1);
rb_define_singleton_method(rb_mProcess, "fork", rb_f_fork, 0);
- rb_define_singleton_method(rb_mProcess, "spawn", rb_f_spawn, -1);
rb_define_singleton_method(rb_mProcess, "exit!", rb_f_exit_bang, -1);
- rb_define_singleton_method(rb_mProcess, "exit", rb_f_exit, -1);
- rb_define_singleton_method(rb_mProcess, "abort", rb_f_abort, -1);
+ rb_define_singleton_method(rb_mProcess, "exit", rb_f_exit, -1); /* in eval.c */
+ rb_define_singleton_method(rb_mProcess, "abort", rb_f_abort, -1); /* in eval.c */
rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1); /* in signal.c */
rb_define_module_function(rb_mProcess, "wait", proc_wait, -1);
@@ -3892,15 +3640,18 @@ Init_process(void)
rb_define_module_function(rb_mProcess, "getrlimit", proc_getrlimit, 1);
rb_define_module_function(rb_mProcess, "setrlimit", proc_setrlimit, -1);
#ifdef RLIM2NUM
-#ifdef RLIM_INFINITY
- rb_define_const(rb_mProcess, "RLIM_INFINITY", RLIM2NUM(RLIM_INFINITY));
-#endif
+ {
+ VALUE inf = RLIM2NUM(RLIM_INFINITY), v;
+ rb_define_const(rb_mProcess, "RLIM_INFINITY", inf);
#ifdef RLIM_SAVED_MAX
- rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", RLIM2NUM(RLIM_SAVED_MAX));
+ v = RLIM_INFINITY == RLIM_SAVED_MAX ? inf : RLIM2NUM(RLIM_SAVED_MAX);
+ rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", v);
#endif
#ifdef RLIM_SAVED_CUR
- rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", RLIM2NUM(RLIM_SAVED_CUR));
+ v = RLIM_INFINITY == RLIM_SAVED_CUR ? inf : RLIM2NUM(RLIM_SAVED_CUR);
+ rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", v);
#endif
+ }
#ifdef RLIMIT_CORE
rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
#endif
@@ -3950,8 +3701,6 @@ Init_process(void)
rb_define_module_function(rb_mProcess, "maxgroups", proc_getmaxgroups, 0);
rb_define_module_function(rb_mProcess, "maxgroups=", proc_setmaxgroups, 1);
- rb_define_module_function(rb_mProcess, "daemon", proc_daemon, -1);
-
rb_define_module_function(rb_mProcess, "times", rb_proc_times, 0);
#if defined(HAVE_TIMES) || defined(_WIN32)
diff --git a/random.c b/random.c
index bb3a41e6b2..ad5558bca9 100644
--- a/random.c
+++ b/random.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri Dec 24 16:39:21 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -76,7 +76,8 @@ static unsigned long *next;
/* initializes state[N] with a seed */
static void
-init_genrand(unsigned long s)
+init_genrand(s)
+ unsigned long s;
{
int j;
state[0]= s & 0xffffffffUL;
@@ -123,7 +124,7 @@ init_by_array(unsigned long init_key[], int key_length)
}
static void
-next_state(void)
+next_state()
{
unsigned long *p=state;
int j;
@@ -145,8 +146,8 @@ next_state(void)
}
/* generates a random number on [0,0xffffffff]-interval */
-static unsigned long
-genrand_int32(void)
+unsigned long
+rb_genrand_int32(void)
{
unsigned long y;
@@ -163,10 +164,10 @@ genrand_int32(void)
}
/* generates a random number on [0,1) with 53-bit resolution*/
-static double
-genrand_real(void)
+double
+rb_genrand_real(void)
{
- unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
+ unsigned long a=rb_genrand_int32()>>5, b=rb_genrand_int32()>>6;
return(a*67108864.0+b)*(1.0/9007199254740992.0);
}
/* These real versions are due to Isaku Wada, 2002/01/09 added */
@@ -176,7 +177,7 @@ genrand_real(void)
/* These real versions are due to Isaku Wada, 2002/01/09 added */
-#include "ruby/ruby.h"
+#include "ruby.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -188,22 +189,12 @@ genrand_real(void)
#include <fcntl.h>
#endif
-unsigned long
-rb_genrand_int32(void)
-{
- return genrand_int32();
-}
-
-double
-rb_genrand_real(void)
-{
- return genrand_real();
-}
-
+static int first = 1;
static VALUE saved_seed = INT2FIX(0);
static VALUE
-rand_init(VALUE vseed)
+rand_init(vseed)
+ VALUE vseed;
{
volatile VALUE seed;
VALUE old;
@@ -216,7 +207,7 @@ rand_init(VALUE vseed)
len = sizeof(VALUE);
break;
case T_BIGNUM:
- len = RBIGNUM_LEN(seed) * SIZEOF_BDIGITS;
+ len = RBIGNUM(seed)->len * SIZEOF_BDIGITS;
if (len == 0)
len = 4;
break;
@@ -235,12 +226,12 @@ rand_init(VALUE vseed)
}
else {
int i, j;
- for (i = RBIGNUM_LEN(seed)-1; 0 <= i; i--) {
+ for (i = RBIGNUM(seed)->len-1; 0 <= i; i--) {
j = i * SIZEOF_BDIGITS / 4;
#if SIZEOF_BDIGITS < 4
buf[j] <<= SIZEOF_BDIGITS * 8;
#endif
- buf[j] |= RBIGNUM_DIGITS(seed)[i];
+ buf[j] |= ((BDIGIT *)RBIGNUM(seed)->digits)[i];
}
}
while (1 < len && buf[len-1] == 0) {
@@ -254,6 +245,7 @@ rand_init(VALUE vseed)
len--;
init_by_array(buf, len);
}
+ first = 0;
old = saved_seed;
saved_seed = seed;
free(buf);
@@ -261,7 +253,7 @@ rand_init(VALUE vseed)
}
static VALUE
-random_seed(void)
+random_seed()
{
static int n = 0;
struct timeval tv;
@@ -275,12 +267,12 @@ random_seed(void)
OBJSETUP(big, rb_cBignum, T_BIGNUM);
seed_len = 4 * sizeof(long);
- RBIGNUM_SET_SIGN(big, 1);
- rb_big_resize((VALUE)big, seed_len / SIZEOF_BDIGITS + 1);
- digits = RBIGNUM_DIGITS(big);
- seed = (unsigned long *)RBIGNUM_DIGITS(big);
+ big->sign = 1;
+ big->len = seed_len / SIZEOF_BDIGITS + 1;
+ digits = big->digits = ALLOC_N(BDIGIT, big->len);
+ seed = (unsigned long *)big->digits;
- memset(digits, 0, RBIGNUM_LEN(big) * SIZEOF_BDIGITS);
+ memset(digits, 0, big->len * SIZEOF_BDIGITS);
#ifdef S_ISCHR
if ((fd = open("/dev/urandom", O_RDONLY
@@ -308,7 +300,7 @@ random_seed(void)
seed[3] ^= (unsigned long)&seed;
/* set leading-zero-guard if need. */
- digits[RBIGNUM_LEN(big)-1] = digits[RBIGNUM_LEN(big)-2] <= 1 ? 1 : 0;
+ digits[big->len-1] = digits[big->len-2] <= 1 ? 1 : 0;
return rb_big_norm((VALUE)big);
}
@@ -318,8 +310,8 @@ random_seed(void)
* srand(number=0) => old_seed
*
* Seeds the pseudorandom number generator to the value of
- * <i>number</i>.<code>to_i.abs</code>. If <i>number</i> is omitted
- * or zero, seeds the generator using a combination of the time, the
+ * <i>number</i>.<code>to_i.abs</code>. If <i>number</i> is omitted,
+ * seeds the generator using a combination of the time, the
* process id, and a sequence number. (This is also the behavior if
* <code>Kernel::rand</code> is called without previously calling
* <code>srand</code>, but without the sequence.) By setting the seed
@@ -328,7 +320,10 @@ random_seed(void)
*/
static VALUE
-rb_f_srand(int argc, VALUE *argv, VALUE obj)
+rb_f_srand(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE seed, old;
@@ -366,7 +361,7 @@ limited_rand(unsigned long limit)
val = 0;
for (i = SIZEOF_LONG/4-1; 0 <= i; i--) {
if (mask >> (i * 32)) {
- val |= genrand_int32() << (i * 32);
+ val |= rb_genrand_int32() << (i * 32);
val &= mask;
if (limit < val)
goto retry;
@@ -382,20 +377,20 @@ limited_big_rand(struct RBignum *limit)
struct RBignum *val;
int i, len, boundary;
- len = (RBIGNUM_LEN(limit) * SIZEOF_BDIGITS + 3) / 4;
+ len = (limit->len * SIZEOF_BDIGITS + 3) / 4;
val = (struct RBignum *)rb_big_clone((VALUE)limit);
- RBIGNUM_SET_SIGN(val, 1);
+ val->sign = 1;
#if SIZEOF_BDIGITS == 2
-# define BIG_GET32(big,i) (RBIGNUM_DIGITS(big)[(i)*2] | \
- ((i)*2+1 < RBIGNUM_DIGITS(big) ? (RBIGNUM_DIGITS(big)[(i)*2+1] << 16) \
+# define BIG_GET32(big,i) (((BDIGIT *)(big)->digits)[(i)*2] | \
+ ((i)*2+1 < (big)->len ? (((BDIGIT *)(big)->digits)[(i)*2+1] << 16) \
: 0))
-# define BIG_SET32(big,i,d) ((RBIGNUM_DIGITS(big)[(i)*2] = (d) & 0xffff), \
- ((i)*2+1 < RBIGNUM_DIGITS(big) ? (RBIGNUM_DIGITS(big)[(i)*2+1] = (d) >> 16) \
+# define BIG_SET32(big,i,d) ((((BDIGIT *)(big)->digits)[(i)*2] = (d) & 0xffff), \
+ ((i)*2+1 < (big)->len ? (((BDIGIT *)(big)->digits)[(i)*2+1] = (d) >> 16) \
: 0))
#else
/* SIZEOF_BDIGITS == 4 */
-# define BIG_GET32(big,i) (RBIGNUM_DIGITS(big)[i])
-# define BIG_SET32(big,i,d) (RBIGNUM_DIGITS(big)[i] = (d))
+# define BIG_GET32(big,i) (((BDIGIT *)(big)->digits)[i])
+# define BIG_SET32(big,i,d) (((BDIGIT *)(big)->digits)[i] = (d))
#endif
retry:
mask = 0;
@@ -404,7 +399,7 @@ limited_big_rand(struct RBignum *limit)
lim = BIG_GET32(limit, i);
mask = mask ? 0xffffffff : make_mask(lim);
if (mask) {
- rnd = genrand_int32() & mask;
+ rnd = rb_genrand_int32() & mask;
if (boundary) {
if (lim < rnd)
goto retry;
@@ -441,35 +436,41 @@ limited_big_rand(struct RBignum *limit)
*/
static VALUE
-rb_f_rand(int argc, VALUE *argv, VALUE obj)
+rb_f_rand(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
VALUE vmax;
long val, max;
rb_scan_args(argc, argv, "01", &vmax);
+ if (first) {
+ rand_init(random_seed());
+ }
switch (TYPE(vmax)) {
case T_FLOAT:
- if (RFLOAT_VALUE(vmax) <= LONG_MAX && RFLOAT_VALUE(vmax) >= LONG_MIN) {
- max = (long)RFLOAT_VALUE(vmax);
+ if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN) {
+ max = (long)RFLOAT(vmax)->value;
break;
}
- if (RFLOAT_VALUE(vmax) < 0)
- vmax = rb_dbl2big(-RFLOAT_VALUE(vmax));
+ if (RFLOAT(vmax)->value < 0)
+ vmax = rb_dbl2big(-RFLOAT(vmax)->value);
else
- vmax = rb_dbl2big(RFLOAT_VALUE(vmax));
+ vmax = rb_dbl2big(RFLOAT(vmax)->value);
/* fall through */
case T_BIGNUM:
bignum:
{
struct RBignum *limit = (struct RBignum *)vmax;
- if (!RBIGNUM_SIGN(limit)) {
+ if (!limit->sign) {
limit = (struct RBignum *)rb_big_clone(vmax);
- RBIGNUM_SET_SIGN(limit, 1);
+ limit->sign = 1;
}
limit = (struct RBignum *)rb_big_minus((VALUE)limit, INT2FIX(1));
if (FIXNUM_P((VALUE)limit)) {
if (FIX2LONG((VALUE)limit) == -1)
- return DOUBLE2NUM(genrand_real());
+ return rb_float_new(rb_genrand_real());
return LONG2NUM(limited_rand(FIX2LONG((VALUE)limit)));
}
return limited_big_rand(limit);
@@ -480,13 +481,14 @@ rb_f_rand(int argc, VALUE *argv, VALUE obj)
default:
vmax = rb_Integer(vmax);
if (TYPE(vmax) == T_BIGNUM) goto bignum;
+ /* fall through */
case T_FIXNUM:
max = FIX2LONG(vmax);
break;
}
if (max == 0) {
- return DOUBLE2NUM(genrand_real());
+ return rb_float_new(rb_genrand_real());
}
if (max < 0) max = -max;
val = limited_rand(max-1);
@@ -494,9 +496,8 @@ rb_f_rand(int argc, VALUE *argv, VALUE obj)
}
void
-Init_Random(void)
+Init_Random()
{
- rand_init(random_seed());
rb_define_global_function("srand", rb_f_srand, -1);
rb_define_global_function("rand", rb_f_rand, -1);
rb_global_variable(&saved_seed);
diff --git a/range.c b/range.c
index 392bf97a89..7526324da7 100644
--- a/range.c
+++ b/range.c
@@ -6,37 +6,36 @@
$Date$
created at: Thu Aug 19 17:46:47 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
VALUE rb_cRange;
static ID id_cmp, id_succ, id_beg, id_end, id_excl;
-#define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0])
-#define RANGE_END(r) (RSTRUCT(r)->as.ary[1])
-#define RANGE_EXCL(r) (RSTRUCT(r)->as.ary[2])
-
-#define EXCL(r) RTEST(RANGE_EXCL(r))
-#define SET_EXCL(r,v) (RSTRUCT(r)->as.ary[2] = (v) ? Qtrue : Qfalse)
+#define EXCL(r) RTEST(rb_ivar_get((r), id_excl))
+#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse)
static VALUE
-range_failed(void)
+range_failed()
{
rb_raise(rb_eArgError, "bad value for range");
return Qnil; /* dummy */
}
static VALUE
-range_check(VALUE *args)
+range_check(args)
+ VALUE *args;
{
return rb_funcall(args[0], id_cmp, 1, args[1]);
}
static void
-range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
+range_init(range, beg, end, exclude_end)
+ VALUE range, beg, end;
+ int exclude_end;
{
VALUE args[2];
@@ -47,17 +46,18 @@ range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
VALUE v;
v = rb_rescue(range_check, (VALUE)args, range_failed, 0);
- if (NIL_P(v))
- range_failed();
+ if (NIL_P(v)) range_failed();
}
SET_EXCL(range, exclude_end);
- RSTRUCT(range)->as.ary[0] = beg;
- RSTRUCT(range)->as.ary[1] = end;
+ rb_ivar_set(range, id_beg, beg);
+ rb_ivar_set(range, id_end, end);
}
VALUE
-rb_range_new(VALUE beg, VALUE end, int exclude_end)
+rb_range_new(beg, end, exclude_end)
+ VALUE beg, end;
+ int exclude_end;
{
VALUE range = rb_obj_alloc(rb_cRange);
@@ -75,13 +75,16 @@ rb_range_new(VALUE beg, VALUE end, int exclude_end)
*/
static VALUE
-range_initialize(int argc, VALUE *argv, VALUE range)
+range_initialize(argc, argv, range)
+ int argc;
+ VALUE *argv;
+ VALUE range;
{
VALUE beg, end, flags;
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
/* Ranges are immutable, so that they should be initialized only once. */
- if (RANGE_EXCL(range) != Qnil) {
+ if (rb_ivar_defined(range, id_beg)) {
rb_name_error(rb_intern("initialize"), "`initialize' called twice");
}
range_init(range, beg, end, RTEST(flags));
@@ -97,7 +100,8 @@ range_initialize(int argc, VALUE *argv, VALUE range)
*/
static VALUE
-range_exclude_end_p(VALUE range)
+range_exclude_end_p(range)
+ VALUE range;
{
return EXCL(range) ? Qtrue : Qfalse;
}
@@ -118,49 +122,45 @@ range_exclude_end_p(VALUE range)
*/
static VALUE
-range_eq(VALUE range, VALUE obj)
+range_eq(range, obj)
+ VALUE range, obj;
{
- if (range == obj)
- return Qtrue;
+ if (range == obj) return Qtrue;
if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
return Qfalse;
- if (!rb_equal(RANGE_BEG(range), RANGE_BEG(obj)))
+ if (!rb_equal(rb_ivar_get(range, id_beg), rb_ivar_get(obj, id_beg)))
return Qfalse;
- if (!rb_equal(RANGE_END(range), RANGE_END(obj)))
+ if (!rb_equal(rb_ivar_get(range, id_end), rb_ivar_get(obj, id_end)))
return Qfalse;
- if (EXCL(range) != EXCL(obj))
- return Qfalse;
+ if (EXCL(range) != EXCL(obj)) return Qfalse;
return Qtrue;
}
static int
-r_lt(VALUE a, VALUE b)
+r_lt(a, b)
+ VALUE a, b;
{
VALUE r = rb_funcall(a, id_cmp, 1, b);
- if (NIL_P(r))
- return Qfalse;
- if (rb_cmpint(r, a, b) < 0)
- return Qtrue;
+ if (NIL_P(r)) return Qfalse;
+ if (rb_cmpint(r, a, b) < 0) return Qtrue;
return Qfalse;
}
static int
-r_le(VALUE a, VALUE b)
+r_le(a, b)
+ VALUE a, b;
{
int c;
VALUE r = rb_funcall(a, id_cmp, 1, b);
- if (NIL_P(r))
- return Qfalse;
+ if (NIL_P(r)) return Qfalse;
c = rb_cmpint(r, a, b);
- if (c == 0)
- return INT2FIX(0);
- if (c < 0)
- return Qtrue;
+ if (c == 0) return INT2FIX(0);
+ if (c < 0) return Qtrue;
return Qfalse;
}
@@ -180,20 +180,19 @@ r_le(VALUE a, VALUE b)
*/
static VALUE
-range_eql(VALUE range, VALUE obj)
+range_eql(range, obj)
+ VALUE range, obj;
{
- if (range == obj)
- return Qtrue;
+ if (range == obj) return Qtrue;
if (!rb_obj_is_instance_of(obj, rb_obj_class(range)))
return Qfalse;
- if (!rb_eql(RANGE_BEG(range), RANGE_BEG(obj)))
+ if (!rb_eql(rb_ivar_get(range, id_beg), rb_ivar_get(obj, id_beg)))
return Qfalse;
- if (!rb_eql(RANGE_END(range), RANGE_END(obj)))
+ if (!rb_eql(rb_ivar_get(range, id_end), rb_ivar_get(obj, id_end)))
return Qfalse;
- if (EXCL(range) != EXCL(obj))
- return Qfalse;
+ if (EXCL(range) != EXCL(obj)) return Qfalse;
return Qtrue;
}
@@ -208,53 +207,64 @@ range_eql(VALUE range, VALUE obj)
*/
static VALUE
-range_hash(VALUE range)
+range_hash(range)
+ VALUE range;
{
long hash = EXCL(range);
VALUE v;
- v = rb_hash(RANGE_BEG(range));
+ v = rb_hash(rb_ivar_get(range, id_beg));
hash ^= v << 1;
- v = rb_hash(RANGE_END(range));
+ v = rb_hash(rb_ivar_get(range, id_end));
hash ^= v << 9;
hash ^= EXCL(range) << 24;
return LONG2FIX(hash);
}
+static VALUE
+str_step(args)
+ VALUE *args;
+{
+ return rb_str_upto(args[0], args[1], EXCL(args[2]));
+}
+
static void
-range_each_func(VALUE range, VALUE (*func) (VALUE, void *), VALUE v, VALUE e,
- void *arg)
+range_each_func(range, func, v, e, arg)
+ VALUE range;
+ void (*func) _((VALUE, void*));
+ VALUE v, e;
+ void *arg;
{
int c;
if (EXCL(range)) {
while (r_lt(v, e)) {
- (*func) (v, arg);
+ (*func)(v, arg);
v = rb_funcall(v, id_succ, 0, 0);
}
}
else {
while (RTEST(c = r_le(v, e))) {
- (*func) (v, arg);
- if (c == INT2FIX(0))
- break;
+ (*func)(v, arg);
+ if (c == INT2FIX(0)) break;
v = rb_funcall(v, id_succ, 0, 0);
}
}
}
static VALUE
-step_i(VALUE i, void *arg)
+step_i(i, arg)
+ VALUE i;
+ VALUE arg;
{
- VALUE *iter = arg;
+ VALUE *iter = (VALUE *)arg;
if (FIXNUM_P(iter[0])) {
iter[0] -= INT2FIX(1) & ~FIXNUM_FLAG;
}
else {
- VALUE one = INT2FIX(1);
- iter[0] = rb_funcall(iter[0], '-', 1, &one);
+ iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1));
}
if (iter[0] == INT2FIX(0)) {
rb_yield(i);
@@ -268,7 +278,7 @@ step_i(VALUE i, void *arg)
* rng.step(n=1) {| obj | block } => rng
*
* Iterates over <i>rng</i>, passing each <i>n</i>th element to the block. If
- * the range contains numbers or strings, natural ordering is used. Otherwise
+ * the range contains numbers, <i>n</i> is added for each iteration. Otherwise
* <code>step</code> invokes <code>succ</code> to iterate through range
* elements. The following code uses class <code>Xs</code>, which is defined
* in the class-level documentation.
@@ -292,35 +302,36 @@ step_i(VALUE i, void *arg)
static VALUE
-range_step(int argc, VALUE *argv, VALUE range)
+range_step(argc, argv, range)
+ int argc;
+ VALUE *argv;
+ VALUE range;
{
- VALUE b, e, step;
- long unit;
+ VALUE b, e, step, tmp;
RETURN_ENUMERATOR(range, argc, argv);
- b = RANGE_BEG(range);
- e = RANGE_END(range);
- if (rb_scan_args(argc, argv, "01", &step) == 0) {
+ b = rb_ivar_get(range, id_beg);
+ e = rb_ivar_get(range, id_end);
+ if (argc == 0) {
step = INT2FIX(1);
- unit = 1;
- }
- else if (FIXNUM_P(step)) {
- unit = NUM2LONG(step);
}
else {
- VALUE tmp = rb_to_int(step);
- unit = rb_cmpint(tmp, step, INT2FIX(0));
- step = tmp;
- }
- if (unit < 0) {
- rb_raise(rb_eArgError, "step can't be negative");
+ rb_scan_args(argc, argv, "01", &step);
+ if (!rb_obj_is_kind_of(step, rb_cNumeric)) {
+ step = rb_to_int(step);
+ }
+ if (rb_funcall(step, '<', 1, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step can't be negative");
+ }
+ else if (!rb_funcall(step, '>', 1, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step can't be 0");
+ }
}
- if (unit == 0)
- rb_raise(rb_eArgError, "step can't be 0");
+
if (FIXNUM_P(b) && FIXNUM_P(e) && FIXNUM_P(step)) { /* fixnums are special */
long end = FIX2LONG(e);
- long i;
+ long i, unit = FIX2LONG(step);
if (!EXCL(range))
end += 1;
@@ -330,12 +341,23 @@ range_step(int argc, VALUE *argv, VALUE range)
if (i + unit < i) break;
i += unit;
}
+
+ }
+ else if (rb_obj_is_kind_of(b, rb_cNumeric) ||
+ !NIL_P(rb_check_to_integer(b, "to_int")) ||
+ !NIL_P(rb_check_to_integer(e, "to_int"))) {
+ ID op = EXCL(range) ? '<' : rb_intern("<=");
+
+ while (RTEST(rb_funcall(b, op, 1, e))) {
+ rb_yield(b);
+ b = rb_funcall(b, '+', 1, step);
+ }
}
else {
- VALUE tmp = rb_check_string_type(b);
+ tmp = rb_check_string_type(b);
if (!NIL_P(tmp)) {
- VALUE args[2], iter[2];
+ VALUE args[5], iter[2];
b = tmp;
args[0] = e;
@@ -344,11 +366,11 @@ range_step(int argc, VALUE *argv, VALUE range)
iter[1] = step;
rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter);
}
- else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
- ID c = rb_intern(EXCL(range) ? "<" : "<=");
+ else if (rb_obj_is_kind_of(b, rb_cNumeric) ||
+ !NIL_P(rb_check_to_integer(b, "to_int")) ||
+ !NIL_P(rb_check_to_integer(e, "to_int"))) {
+ ID c = EXCL(range) ? '<' : rb_intern("<=");
- if (rb_equal(step, INT2FIX(0)))
- rb_raise(rb_eArgError, "step can't be 0");
while (RTEST(rb_funcall(b, c, 1, e))) {
rb_yield(b);
b = rb_funcall(b, '+', 1, step);
@@ -369,11 +391,12 @@ range_step(int argc, VALUE *argv, VALUE range)
return range;
}
-static VALUE
-each_i(VALUE v, void *arg)
+static void
+each_i(v, arg)
+ VALUE v;
+ void *arg;
{
rb_yield(v);
- return Qnil;
}
/*
@@ -395,14 +418,15 @@ each_i(VALUE v, void *arg)
*/
static VALUE
-range_each(VALUE range)
+range_each(range)
+ VALUE range;
{
VALUE beg, end;
RETURN_ENUMERATOR(range, 0, 0);
- beg = RANGE_BEG(range);
- end = RANGE_END(range);
+ beg = rb_ivar_get(range, id_beg);
+ end = rb_ivar_get(range, id_end);
if (!rb_respond_to(beg, id_succ)) {
rb_raise(rb_eTypeError, "can't iterate from %s",
@@ -412,18 +436,18 @@ range_each(VALUE range)
long lim = FIX2LONG(end);
long i;
- if (!EXCL(range))
- lim += 1;
- for (i = FIX2LONG(beg); i < lim; i++) {
+ if (!EXCL(range)) lim += 1;
+ for (i=FIX2LONG(beg); i<lim; i++) {
rb_yield(LONG2NUM(i));
}
}
else if (TYPE(beg) == T_STRING) {
- VALUE args[2];
+ VALUE args[5], iter[2];
- args[0] = end;
- args[1] = EXCL(range) ? Qtrue : Qfalse;
- rb_block_call(beg, rb_intern("upto"), 2, args, rb_yield, 0);
+ args[0] = beg; args[1] = end; args[2] = range;
+ iter[0] = INT2FIX(1); iter[1] = INT2FIX(1);
+ rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i,
+ (VALUE)iter);
}
else {
range_each_func(range, each_i, beg, end, NULL);
@@ -433,21 +457,24 @@ range_each(VALUE range)
/*
* call-seq:
+ * rng.first => obj
* rng.begin => obj
*
* Returns the first object in <i>rng</i>.
*/
static VALUE
-range_begin(VALUE range)
+range_first(range)
+ VALUE range;
{
- return RANGE_BEG(range);
+ return rb_ivar_get(range, id_beg);
}
/*
* call-seq:
* rng.end => obj
+ * rng.last => obj
*
* Returns the object that defines the end of <i>rng</i>.
*
@@ -457,176 +484,38 @@ range_begin(VALUE range)
static VALUE
-range_end(VALUE range)
-{
- return RANGE_END(range);
-}
-
-
-static VALUE
-first_i(VALUE i, VALUE *ary)
-{
- 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:
- * rng.first => obj
- * rng.first(n) => an_array
- *
- * Returns the first object in <i>rng</i>, or the first +n+ elements.
- */
-
-static VALUE
-range_first(int argc, VALUE *argv, VALUE range)
-{
- VALUE n, ary[2];
-
- if (argc == 0) return RANGE_BEG(range);
-
- rb_scan_args(argc, argv, "1", &n);
- ary[0] = n;
- ary[1] = rb_ary_new2(NUM2LONG(n));
- rb_block_call(range, rb_intern("each"), 0, 0, first_i, (VALUE)ary);
-
- return ary[1];
-}
-
-
-/*
- * call-seq:
- * rng.last => obj
- * rng.last(n) => an_array
- *
- * Returns the last object in <i>rng</i>, or the last +n+ elements.
- */
-
-static VALUE
-range_last(int argc, VALUE *argv, VALUE range)
-{
- VALUE rb_ary_last(int, VALUE *, VALUE);
-
- if (argc == 0) return RANGE_END(range);
- return rb_ary_last(argc, argv, rb_Array(range));
-}
-
-
-/*
- * call-seq:
- * rng.min => obj
- * rng.min {| a,b | block } => obj
- *
- * Returns the minimum value in <i>rng</i>. The second uses
- * the block to compare values. Returns nil if the first
- * value in range is larger than the last value.
- *
- */
-
-
-static VALUE
-range_min(VALUE range)
+range_last(range)
+ VALUE range;
{
- if (rb_block_given_p()) {
- return rb_call_super(0, 0);
- }
- else {
- VALUE b = RANGE_BEG(range);
- VALUE e = RANGE_END(range);
- int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
-
- if (c > 0 || (c == 0 && EXCL(range)))
- return Qnil;
- return b;
- }
-}
-
-/*
- * call-seq:
- * rng.max => obj
- * rng.max {| a,b | block } => obj
- *
- * Returns the maximum value in <i>rng</i>. The second uses
- * the block to compare values. Returns nil if the first
- * value in range is larger than the last value.
- *
- */
-
-
-static VALUE
-range_max(VALUE range)
-{
- VALUE e = RANGE_END(range);
- int ip = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cInteger);
-
- if (rb_block_given_p() || (EXCL(range) && !ip)) {
- return rb_call_super(0, 0);
- }
- else {
- VALUE b = RANGE_BEG(range);
- int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
-
- if (c > 0)
- return Qnil;
- if (EXCL(range)) {
- if (c == 0) return Qnil;
- if (FIXNUM_P(e)) {
- return LONG2NUM(FIX2LONG(e) - 1);
- }
- return rb_funcall(e, '-', 1, INT2FIX(1));
- }
- return e;
- }
+ return rb_ivar_get(range, id_end);
}
VALUE
-rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
+rb_range_beg_len(range, begp, lenp, len, err)
+ VALUE range;
+ long *begp, *lenp;
+ long len;
+ int err;
{
- VALUE b, e;
- long beg, end, excl;
+ long beg, end, b, e;
- if (rb_obj_is_kind_of(range, rb_cRange)) {
- b = RANGE_BEG(range);
- e = RANGE_END(range);
- excl = EXCL(range);
- }
- else {
- b = rb_check_to_integer(range, "begin");
- if (NIL_P(b))
- return Qfalse;
- e = rb_check_to_integer(range, "end");
- if (NIL_P(e))
- return Qfalse;
- excl = RTEST(rb_funcall(range, rb_intern("exclude_end?"), 0));
- }
- beg = NUM2LONG(b);
- end = NUM2LONG(e);
+ if (!rb_obj_is_kind_of(range, rb_cRange)) return Qfalse;
+
+ beg = b = NUM2LONG(rb_ivar_get(range, id_beg));
+ end = e = NUM2LONG(rb_ivar_get(range, id_end));
if (beg < 0) {
beg += len;
- if (beg < 0)
- goto out_of_range;
+ if (beg < 0) goto out_of_range;
}
if (err == 0 || err == 2) {
- if (beg > len)
- goto out_of_range;
- if (end > len)
- end = len;
+ if (beg > len) goto out_of_range;
+ if (end > len) end = len;
}
- if (end < 0)
- end += len;
- if (!excl)
- end++; /* include end point */
+ if (end < 0) end += len;
+ if (!EXCL(range)) end++; /* include end point */
len = end - beg;
- if (len < 0)
- len = 0;
+ if (len < 0) len = 0;
*begp = beg;
*lenp = len;
@@ -635,7 +524,7 @@ rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
out_of_range:
if (err) {
rb_raise(rb_eRangeError, "%ld..%s%ld out of range",
- b, excl ? "." : "", e);
+ b, EXCL(range)? "." : "", e);
}
return Qnil;
}
@@ -648,14 +537,15 @@ rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
*/
static VALUE
-range_to_s(VALUE range)
+range_to_s(range)
+ VALUE range;
{
VALUE str, str2;
- str = rb_obj_as_string(RANGE_BEG(range));
- str2 = rb_obj_as_string(RANGE_END(range));
+ str = rb_obj_as_string(rb_ivar_get(range, id_beg));
+ str2 = rb_obj_as_string(rb_ivar_get(range, id_end));
str = rb_str_dup(str);
- rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
+ rb_str_cat(str, "...", EXCL(range)?3:2);
rb_str_append(str, str2);
OBJ_INFECT(str, str2);
@@ -673,14 +563,15 @@ range_to_s(VALUE range)
static VALUE
-range_inspect(VALUE range)
+range_inspect(range)
+ VALUE range;
{
VALUE str, str2;
- str = rb_inspect(RANGE_BEG(range));
- str2 = rb_inspect(RANGE_END(range));
+ str = rb_inspect(rb_ivar_get(range, id_beg));
+ str2 = rb_inspect(rb_ivar_get(range, id_end));
str = rb_str_dup(str);
- rb_str_cat(str, "...", EXCL(range) ? 3 : 2);
+ rb_str_cat(str, "...", EXCL(range)?3:2);
rb_str_append(str, str2);
OBJ_INFECT(str, str2);
@@ -690,6 +581,8 @@ range_inspect(VALUE range)
/*
* call-seq:
* rng === obj => true or false
+ * rng.member?(val) => true or false
+ * rng.include?(val) => true or false
*
* Returns <code>true</code> if <i>obj</i> is an element of
* <i>rng</i>, <code>false</code> otherwise. Conveniently,
@@ -708,120 +601,24 @@ range_inspect(VALUE range)
*/
static VALUE
-range_eqq(VALUE range, VALUE val)
-{
- return rb_funcall(range, rb_intern("include?"), 1, val);
-}
-
-
-/*
- * call-seq:
- * rng.member?(val) => true or false
- * rng.include?(val) => true or false
- *
- * Returns <code>true</code> if <i>obj</i> is an element of
- * <i>rng</i>, <code>false</code> otherwise.
- *
- * ("a".."z").include?("g") # => true
- * ("a".."z").include?("A") # => false
- */
-
-static VALUE
-range_include(VALUE range, VALUE val)
-{
- VALUE beg = RANGE_BEG(range);
- VALUE end = RANGE_END(range);
- int nv = FIXNUM_P(beg) || FIXNUM_P(end) ||
- rb_obj_is_kind_of(beg, rb_cNumeric) ||
- rb_obj_is_kind_of(end, rb_cNumeric);
-
- if (nv ||
- !NIL_P(rb_check_to_integer(beg, "to_int")) ||
- !NIL_P(rb_check_to_integer(end, "to_int"))) {
- if (r_le(beg, val)) {
- if (EXCL(range)) {
- if (r_lt(val, end))
- return Qtrue;
- }
- else {
- if (r_le(val, end))
- return Qtrue;
- }
- }
- return Qfalse;
- }
- /* TODO: ruby_frame->this_func = rb_intern("include?"); */
- return rb_call_super(1, &val);
-}
-
-
-/*
- * call-seq:
- * rng.cover?(val) => true or false
- *
- * Returns <code>true</code> if <i>obj</i> is between beg and end,
- * i.e <code>beg <= obj <= end</code> (or <i>end</i> exclusive when
- * <code>exclude_end?</code> is true).
- *
- * ("a".."z").cover?("c") #=> true
- * ("a".."z").cover?("5") #=> false
- */
-
-static VALUE
-range_cover(VALUE range, VALUE val)
+range_include(range, val)
+ VALUE range, val;
{
VALUE beg, end;
- beg = RANGE_BEG(range);
- end = RANGE_END(range);
+ beg = rb_ivar_get(range, id_beg);
+ end = rb_ivar_get(range, id_end);
if (r_le(beg, val)) {
if (EXCL(range)) {
- if (r_lt(val, end))
- return Qtrue;
+ if (r_lt(val, end)) return Qtrue;
}
else {
- if (r_le(val, end))
- return Qtrue;
+ if (r_le(val, end)) return Qtrue;
}
}
return Qfalse;
}
-static VALUE
-range_dumper(VALUE range)
-{
- VALUE v;
- NEWOBJ(m, struct RObject);
- OBJSETUP(m, rb_cObject, T_OBJECT);
-
- v = (VALUE)m;
-
- rb_ivar_set(v, id_excl, RANGE_EXCL(range));
- rb_ivar_set(v, id_beg, RANGE_BEG(range));
- rb_ivar_set(v, id_end, RANGE_END(range));
- return v;
-}
-
-static VALUE
-range_loader(VALUE range, VALUE obj)
-{
- if (TYPE(obj) != T_OBJECT || RBASIC(obj)->klass != rb_cObject) {
- rb_raise(rb_eTypeError, "not a dumped range object");
- }
-
- RSTRUCT(range)->as.ary[0] = rb_ivar_get(obj, id_beg);
- RSTRUCT(range)->as.ary[1] = rb_ivar_get(obj, id_end);
- RSTRUCT(range)->as.ary[2] = rb_ivar_get(obj, id_excl);
- return range;
-}
-
-static VALUE
-range_alloc(VALUE klass)
-{
- /* rb_struct_alloc_noinit itself should not be used because
- * rb_marshal_define_compat uses equality of allocaiton function */
- return rb_struct_alloc_noinit(klass);
-}
/* A <code>Range</code> represents an interval---a set of values with a
* start and an end. Ranges may be constructed using the
@@ -876,33 +673,21 @@ range_alloc(VALUE klass)
*/
void
-Init_Range(void)
+Init_Range()
{
- id_cmp = rb_intern("<=>");
- id_succ = rb_intern("succ");
- id_beg = rb_intern("begin");
- id_end = rb_intern("end");
- id_excl = rb_intern("excl");
-
- rb_cRange = rb_struct_define_without_accessor(
- "Range", rb_cObject, range_alloc,
- "begin", "end", "excl", NULL);
-
+ rb_cRange = rb_define_class("Range", rb_cObject);
rb_include_module(rb_cRange, rb_mEnumerable);
- rb_marshal_define_compat(rb_cRange, rb_cObject, range_dumper, range_loader);
rb_define_method(rb_cRange, "initialize", range_initialize, -1);
rb_define_method(rb_cRange, "==", range_eq, 1);
- rb_define_method(rb_cRange, "===", range_eqq, 1);
+ rb_define_method(rb_cRange, "===", range_include, 1);
rb_define_method(rb_cRange, "eql?", range_eql, 1);
rb_define_method(rb_cRange, "hash", range_hash, 0);
rb_define_method(rb_cRange, "each", range_each, 0);
rb_define_method(rb_cRange, "step", range_step, -1);
- rb_define_method(rb_cRange, "begin", range_begin, 0);
- rb_define_method(rb_cRange, "end", range_end, 0);
- rb_define_method(rb_cRange, "first", range_first, -1);
- rb_define_method(rb_cRange, "last", range_last, -1);
- rb_define_method(rb_cRange, "min", range_min, 0);
- rb_define_method(rb_cRange, "max", range_max, 0);
+ rb_define_method(rb_cRange, "first", range_first, 0);
+ rb_define_method(rb_cRange, "last", range_last, 0);
+ rb_define_method(rb_cRange, "begin", range_first, 0);
+ rb_define_method(rb_cRange, "end", range_last, 0);
rb_define_method(rb_cRange, "to_s", range_to_s, 0);
rb_define_method(rb_cRange, "inspect", range_inspect, 0);
@@ -910,5 +695,10 @@ Init_Range(void)
rb_define_method(rb_cRange, "member?", range_include, 1);
rb_define_method(rb_cRange, "include?", range_include, 1);
- rb_define_method(rb_cRange, "cover?", range_cover, 1);
+
+ id_cmp = rb_intern("<=>");
+ id_succ = rb_intern("succ");
+ id_beg = rb_intern("begin");
+ id_end = rb_intern("end");
+ id_excl = rb_intern("excl");
}
diff --git a/re.c b/re.c
index dcbc234602..a0ac6a84c8 100644
--- a/re.c
+++ b/re.c
@@ -5,21 +5,16 @@
$Author$
created at: Mon Aug 9 18:24:49 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/re.h"
-#include "ruby/encoding.h"
-#include "ruby/util.h"
-#include "regint.h"
+#include "ruby.h"
+#include "re.h"
#include <ctype.h>
VALUE rb_eRegexpError;
-typedef char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN];
-
#define BEG(no) regs->beg[no]
#define END(no) regs->end[no]
@@ -75,30 +70,37 @@ static const char casetable[] = {
#endif
int
-rb_memcicmp(const void *x, const void *y, long len)
+rb_memcicmp(x, y, len)
+ const void *x, *y;
+ long len;
{
const unsigned char *p1 = x, *p2 = y;
int tmp;
while (len--) {
- if ((tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++]))
+ if ((tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++]) != 0)
return tmp;
}
return 0;
}
-#undef rb_memcmp
-
int
-rb_memcmp(const void *p1, const void *p2, long len)
+rb_memcmp(p1, p2, len)
+ const void *p1, *p2;
+ long len;
{
- return memcmp(p1, p2, len);
+ if (!ruby_ignorecase) {
+ return memcmp(p1, p2, len);
+ }
+ return rb_memcicmp(p1, p2, len);
}
long
-rb_memsearch(const void *x0, long m, const void *y0, long n)
+rb_memsearch(x0, m, y0, n)
+ const void *x0, *y0;
+ long m, n;
{
- const unsigned char *x = x0, *y = y0;
+ const unsigned char *x = (unsigned char *)x0, *y = (unsigned char *)y0;
const unsigned char *s, *e;
long i;
int d;
@@ -115,182 +117,250 @@ rb_memsearch(const void *x0, long m, const void *y0, long n)
d = sizeof(hx) * CHAR_BIT - 1;
if (d > m) d = m;
- if (n == m) {
- return memcmp(x, s, m) == 0 ? 0 : -1;
- }
- /* Prepare hash value */
- for (hy = hx = i = 0; i < d; ++i) {
- hx = KR_REHASH(0, x[i], hx);
- hy = KR_REHASH(0, s[i], hy);
+ if (ruby_ignorecase) {
+ if (n == m) {
+ return rb_memcicmp(x, s, m) == 0 ? 0 : -1;
+ }
+ /* Prepare hash value */
+ for (hy = hx = i = 0; i < d; ++i) {
+ hx = KR_REHASH(0, casetable[x[i]], hx);
+ hy = KR_REHASH(0, casetable[s[i]], hy);
+ }
+ /* Searching */
+ while (hx != hy || rb_memcicmp(x, s, m)) {
+ if (s >= e) return -1;
+ hy = KR_REHASH(casetable[*s], casetable[*(s+d)], hy);
+ s++;
+ }
}
- /* Searching */
- while (hx != hy || memcmp(x, s, m)) {
- if (s >= e) return -1;
- hy = KR_REHASH(*s, *(s+d), hy);
- s++;
+ else {
+ if (n == m) {
+ return memcmp(x, s, m) == 0 ? 0 : -1;
+ }
+ /* Prepare hash value */
+ for (hy = hx = i = 0; i < d; ++i) {
+ hx = KR_REHASH(0, x[i], hx);
+ hy = KR_REHASH(0, s[i], hy);
+ }
+ /* Searching */
+ while (hx != hy || memcmp(x, s, m)) {
+ if (s >= e) return -1;
+ hy = KR_REHASH(*s, *(s+d), hy);
+ s++;
+ }
}
return s-y;
}
#define REG_LITERAL FL_USER5
-#define REG_ENCODING_NONE FL_USER6
-
+#define REG_CASESTATE FL_USER0
+#define KCODE_NONE 0
+#define KCODE_EUC FL_USER1
+#define KCODE_SJIS FL_USER2
+#define KCODE_UTF8 FL_USER3
#define KCODE_FIXED FL_USER4
+#define KCODE_MASK (KCODE_EUC|KCODE_SJIS|KCODE_UTF8)
-#define ARG_REG_OPTION_MASK \
- (ONIG_OPTION_IGNORECASE|ONIG_OPTION_MULTILINE|ONIG_OPTION_EXTEND)
-#define ARG_ENCODING_FIXED 16
-#define ARG_ENCODING_NONE 32
+static int reg_kcode = DEFAULT_KCODE;
-#define ARG_KCODE_NONE 0
-#define ARG_KCODE_EUC 1
-#define ARG_KCODE_SJIS 2
-#define ARG_KCODE_UTF8 3
-#define ARG_KCODE_MASK 3
+static void
+kcode_euc(re)
+ struct RRegexp *re;
+{
+ FL_UNSET(re, KCODE_MASK);
+ FL_SET(re, KCODE_EUC);
+ FL_SET(re, KCODE_FIXED);
+}
-static int
-char_to_option(int c)
+static void
+kcode_sjis(re)
+ struct RRegexp *re;
{
- int val;
+ FL_UNSET(re, KCODE_MASK);
+ FL_SET(re, KCODE_SJIS);
+ FL_SET(re, KCODE_FIXED);
+}
- switch (c) {
- case 'i':
- val = ONIG_OPTION_IGNORECASE;
- break;
- case 'x':
- val = ONIG_OPTION_EXTEND;
- break;
- case 'm':
- val = ONIG_OPTION_MULTILINE;
- break;
- default:
- val = 0;
- break;
- }
- return val;
+static void
+kcode_utf8(re)
+ struct RRegexp *re;
+{
+ FL_UNSET(re, KCODE_MASK);
+ FL_SET(re, KCODE_UTF8);
+ FL_SET(re, KCODE_FIXED);
}
-static char *
-option_to_str(char str[4], int options)
+static void
+kcode_none(re)
+ struct RRegexp *re;
{
- char *p = str;
- if (options & ONIG_OPTION_MULTILINE) *p++ = 'm';
- if (options & ONIG_OPTION_IGNORECASE) *p++ = 'i';
- if (options & ONIG_OPTION_EXTEND) *p++ = 'x';
- *p = 0;
- return str;
+ FL_UNSET(re, KCODE_MASK);
+ FL_SET(re, KCODE_FIXED);
}
-extern int
-rb_char_to_option_kcode(int c, int *option, int *kcode)
+static int curr_kcode;
+
+void
+rb_kcode_set_option(re)
+ VALUE re;
{
- *option = 0;
+ if (!FL_TEST(re, KCODE_FIXED)) return;
- switch (c) {
- case 'n':
- *kcode = -1;
- return (*option = ARG_ENCODING_NONE);
- case 'e':
- *kcode = ARG_KCODE_EUC;
+ curr_kcode = RBASIC(re)->flags & KCODE_MASK;
+ if (reg_kcode == curr_kcode) return;
+ switch (curr_kcode) {
+ case KCODE_NONE:
+ re_mbcinit(MBCTYPE_ASCII);
break;
- case 's':
- *kcode = ARG_KCODE_SJIS;
+ case KCODE_EUC:
+ re_mbcinit(MBCTYPE_EUC);
break;
- case 'u':
- *kcode = ARG_KCODE_UTF8;
+ case KCODE_SJIS:
+ re_mbcinit(MBCTYPE_SJIS);
+ break;
+ case KCODE_UTF8:
+ re_mbcinit(MBCTYPE_UTF8);
+ break;
+ }
+}
+
+void
+rb_kcode_reset_option()
+{
+ if (reg_kcode == curr_kcode) return;
+ switch (reg_kcode) {
+ case KCODE_NONE:
+ re_mbcinit(MBCTYPE_ASCII);
+ break;
+ case KCODE_EUC:
+ re_mbcinit(MBCTYPE_EUC);
+ break;
+ case KCODE_SJIS:
+ re_mbcinit(MBCTYPE_SJIS);
+ break;
+ case KCODE_UTF8:
+ re_mbcinit(MBCTYPE_UTF8);
break;
- default:
- *kcode = -1;
- return (*option = char_to_option(c));
}
- *option = ARG_ENCODING_FIXED;
- return 1;
+}
+
+int
+rb_reg_mbclen2(c, re)
+ unsigned int c;
+ VALUE re;
+{
+ int len;
+
+ if (!FL_TEST(re, KCODE_FIXED))
+ return mbclen(c);
+ rb_kcode_set_option(re);
+ len = mbclen(c);
+ rb_kcode_reset_option();
+ return len;
}
static void
-rb_reg_check(VALUE re)
+rb_reg_check(re)
+ VALUE re;
{
if (!RREGEXP(re)->ptr || !RREGEXP(re)->str) {
rb_raise(rb_eTypeError, "uninitialized Regexp");
}
}
+extern int ruby_in_compile;
+
static void
-rb_reg_expr_str(VALUE str, const char *s, long len)
+rb_reg_expr_str(str, s, len)
+ VALUE str;
+ const char *s;
+ long len;
{
- rb_encoding *enc = rb_enc_get(str);
const char *p, *pend;
int need_escape = 0;
- int c, clen;
p = s; pend = p + len;
while (p<pend) {
- c = rb_enc_ascget(p, pend, &clen, enc);
- if (c == -1) {
- p += mbclen(p, pend, enc);
- }
- else if (c != '/' && rb_enc_isprint(c, enc)) {
- p += clen;
- }
- else {
+ if (*p == '/' || (!ISPRINT(*p) && !ismbchar(*p))) {
need_escape = 1;
break;
- }
+ }
+ p += mbclen(*p);
}
if (!need_escape) {
rb_str_buf_cat(str, s, len);
}
else {
- p = s;
+ p = s;
while (p<pend) {
- c = rb_enc_ascget(p, pend, &clen, enc);
- if (c == '\\' && p+clen < pend) {
- int n = clen + mbclen(p+clen, pend, enc);
+ if (*p == '\\') {
+ int n = mbclen(p[1]) + 1;
rb_str_buf_cat(str, p, n);
p += n;
continue;
}
- else if (c == '/') {
+ else if (*p == '/') {
char c = '\\';
rb_str_buf_cat(str, &c, 1);
- rb_str_buf_cat(str, p, clen);
+ rb_str_buf_cat(str, p, 1);
}
- else if (c == -1) {
- int l = mbclen(p, pend, enc);
- rb_str_buf_cat(str, p, l);
- p += l;
+ else if (ismbchar(*p)) {
+ rb_str_buf_cat(str, p, mbclen(*p));
+ p += mbclen(*p);
continue;
}
- else if (rb_enc_isprint(c, enc)) {
- rb_str_buf_cat(str, p, clen);
+ else if (ISPRINT(*p)) {
+ rb_str_buf_cat(str, p, 1);
}
- else if (!rb_enc_isspace(c, enc)) {
+ else if (!ISSPACE(*p)) {
char b[8];
- sprintf(b, "\\x%02X", c);
+ sprintf(b, "\\%03o", *p & 0377);
rb_str_buf_cat(str, b, 4);
}
else {
- rb_str_buf_cat(str, p, clen);
+ rb_str_buf_cat(str, p, 1);
}
- p += clen;
+ p++;
}
}
}
static VALUE
-rb_reg_desc(const char *s, long len, VALUE re)
+rb_reg_desc(s, len, re)
+ const char *s;
+ long len;
+ VALUE re;
{
VALUE str = rb_str_buf_new2("/");
- rb_enc_copy(str, re);
rb_reg_expr_str(str, s, len);
rb_str_buf_cat2(str, "/");
if (re) {
- char opts[4];
rb_reg_check(re);
- if (*option_to_str(opts, RREGEXP(re)->ptr->options))
- rb_str_buf_cat2(str, opts);
+ if (RREGEXP(re)->ptr->options & RE_OPTION_MULTILINE)
+ rb_str_buf_cat2(str, "m");
+ if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE)
+ rb_str_buf_cat2(str, "i");
+ if (RREGEXP(re)->ptr->options & RE_OPTION_EXTENDED)
+ rb_str_buf_cat2(str, "x");
+
+ if (FL_TEST(re, KCODE_FIXED)) {
+ switch ((RBASIC(re)->flags & KCODE_MASK)) {
+ case KCODE_NONE:
+ rb_str_buf_cat2(str, "n");
+ break;
+ case KCODE_EUC:
+ rb_str_buf_cat2(str, "e");
+ break;
+ case KCODE_SJIS:
+ rb_str_buf_cat2(str, "s");
+ break;
+ case KCODE_UTF8:
+ rb_str_buf_cat2(str, "u");
+ break;
+ }
+ }
}
OBJ_INFECT(str, re);
return str;
@@ -299,20 +369,16 @@ rb_reg_desc(const char *s, long len, VALUE re)
/*
* call-seq:
- * rxp.source => str
- *
+ * rxp.source => str
+ *
* Returns the original string of the pattern.
- *
- * /ab+c/ix.source #=> "ab+c"
- *
- * Note that escape sequences are retained as is.
- *
- * /\x20\+/.source #=> "\\x20\\+"
- *
+ *
+ * /ab+c/ix.source #=> "ab+c"
*/
static VALUE
-rb_reg_source(VALUE re)
+rb_reg_source(re)
+ VALUE re;
{
VALUE str;
@@ -330,12 +396,12 @@ rb_reg_source(VALUE re)
* <code>#inspect</code> actually produces the more natural version of
* the string than <code>#to_s</code>.
*
- * /ab+c/ix.inspect #=> "/ab+c/ix"
- *
+ * /ab+c/ix.to_s #=> /ab+c/ix
*/
static VALUE
-rb_reg_inspect(VALUE re)
+rb_reg_inspect(re)
+ VALUE re;
{
rb_reg_check(re);
return rb_reg_desc(RREGEXP(re)->str, RREGEXP(re)->len, re);
@@ -345,38 +411,37 @@ rb_reg_inspect(VALUE re)
/*
* call-seq:
* rxp.to_s => str
- *
+ *
* Returns a string containing the regular expression and its options (using the
- * <code>(?opts:source)</code> notation. This string can be fed back in to
+ * <code>(?xxx:yyy)</code> notation. This string can be fed back in to
* <code>Regexp::new</code> to a regular expression with the same semantics as
* the original. (However, <code>Regexp#==</code> may not return true when
* comparing the two, as the source of the regular expression itself may
* differ, as the example shows). <code>Regexp#inspect</code> produces a
* generally more readable version of <i>rxp</i>.
- *
- * r1 = /ab+c/ix #=> /ab+c/ix
- * s1 = r1.to_s #=> "(?ix-m:ab+c)"
- * r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/
- * r1 == r2 #=> false
- * r1.source #=> "ab+c"
- * r2.source #=> "(?ix-m:ab+c)"
+ *
+ * r1 = /ab+c/ix #=> /ab+c/ix
+ * s1 = r1.to_s #=> "(?ix-m:ab+c)"
+ * r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/
+ * r1 == r2 #=> false
+ * r1.source #=> "ab+c"
+ * r2.source #=> "(?ix-m:ab+c)"
*/
static VALUE
-rb_reg_to_s(VALUE re)
+rb_reg_to_s(re)
+ VALUE re;
{
- int options, opt;
- const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
+ int options;
+ const int embeddable = RE_OPTION_MULTILINE|RE_OPTION_IGNORECASE|RE_OPTION_EXTENDED;
long len;
- const UChar* ptr;
+ const char* ptr;
VALUE str = rb_str_buf_new2("(?");
- char optbuf[5];
rb_reg_check(re);
- rb_enc_copy(str, re);
options = RREGEXP(re)->ptr->options;
- ptr = (UChar*)RREGEXP(re)->str;
+ ptr = RREGEXP(re)->str;
len = RREGEXP(re)->len;
again:
if (len >= 4 && ptr[0] == '(' && ptr[1] == '?') {
@@ -384,13 +449,16 @@ rb_reg_to_s(VALUE re)
ptr += 2;
if ((len -= 2) > 0) {
do {
- opt = char_to_option((int )*ptr);
- if (opt != 0) {
- options |= opt;
- }
- else {
- break;
- }
+ if (*ptr == 'm') {
+ options |= RE_OPTION_MULTILINE;
+ }
+ else if (*ptr == 'i') {
+ options |= RE_OPTION_IGNORECASE;
+ }
+ else if (*ptr == 'x') {
+ options |= RE_OPTION_EXTENDED;
+ }
+ else break;
++ptr;
} while (--len > 0);
}
@@ -398,13 +466,16 @@ rb_reg_to_s(VALUE re)
++ptr;
--len;
do {
- opt = char_to_option((int )*ptr);
- if (opt != 0) {
- options &= ~opt;
- }
- else {
- break;
- }
+ if (*ptr == 'm') {
+ options &= ~RE_OPTION_MULTILINE;
+ }
+ else if (*ptr == 'i') {
+ options &= ~RE_OPTION_IGNORECASE;
+ }
+ else if (*ptr == 'x') {
+ options &= ~RE_OPTION_EXTENDED;
+ }
+ else break;
++ptr;
} while (--len > 0);
}
@@ -414,89 +485,69 @@ rb_reg_to_s(VALUE re)
goto again;
}
if (*ptr == ':' && ptr[len-1] == ')') {
- int r;
Regexp *rp;
- r = onig_alloc_init(&rp, ONIG_OPTION_DEFAULT,
- ONIGENC_CASE_FOLD_DEFAULT,
- rb_enc_get(re),
- OnigDefaultSyntax);
- if (r == 0) {
- ++ptr;
- len -= 2;
- err = (onig_compile(rp, ptr, ptr + len, NULL) != 0);
- }
- onig_free(rp);
+ rb_kcode_set_option(re);
+ rp = ALLOC(Regexp);
+ MEMZERO((char *)rp, Regexp, 1);
+ err = re_compile_pattern(++ptr, len -= 2, rp) != 0;
+ rb_kcode_reset_option();
+ re_free_pattern(rp);
}
if (err) {
options = RREGEXP(re)->ptr->options;
- ptr = (UChar*)RREGEXP(re)->str;
+ ptr = RREGEXP(re)->str;
len = RREGEXP(re)->len;
}
}
- if (*option_to_str(optbuf, options)) rb_str_buf_cat2(str, optbuf);
+ if (options & RE_OPTION_MULTILINE) rb_str_buf_cat2(str, "m");
+ if (options & RE_OPTION_IGNORECASE) rb_str_buf_cat2(str, "i");
+ if (options & RE_OPTION_EXTENDED) rb_str_buf_cat2(str, "x");
if ((options & embeddable) != embeddable) {
- optbuf[0] = '-';
- option_to_str(optbuf + 1, ~options);
- rb_str_buf_cat2(str, optbuf);
+ rb_str_buf_cat2(str, "-");
+ if (!(options & RE_OPTION_MULTILINE)) rb_str_buf_cat2(str, "m");
+ if (!(options & RE_OPTION_IGNORECASE)) rb_str_buf_cat2(str, "i");
+ if (!(options & RE_OPTION_EXTENDED)) rb_str_buf_cat2(str, "x");
}
rb_str_buf_cat2(str, ":");
- rb_reg_expr_str(str, (char*)ptr, len);
+ rb_reg_expr_str(str, ptr, len);
rb_str_buf_cat2(str, ")");
- rb_enc_copy(str, re);
OBJ_INFECT(str, re);
return str;
}
static void
-rb_reg_raise(const char *s, long len, const char *err, VALUE re)
+rb_reg_raise(s, len, err, re)
+ const char *s;
+ long len;
+ const char *err;
+ VALUE re;
{
VALUE desc = rb_reg_desc(s, len, re);
- rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING_PTR(desc));
-}
-
-static VALUE
-rb_reg_error_desc(VALUE str, int options, const char *err)
-{
- char opts[6];
- VALUE desc = rb_str_buf_new2(err);
-
- rb_enc_copy(desc, str);
- rb_str_buf_cat2(desc, ": /");
- rb_reg_expr_str(desc, RSTRING_PTR(str), RSTRING_LEN(str));
- opts[0] = '/';
- option_to_str(opts + 1, options);
- rb_str_buf_cat2(desc, opts);
- return rb_exc_new3(rb_eRegexpError, desc);
-}
-
-static void
-rb_reg_raise_str(VALUE str, int options, const char *err)
-{
- rb_exc_raise(rb_reg_error_desc(str, options, err));
+ if (ruby_in_compile)
+ rb_compile_error("%s: %s", err, RSTRING(desc)->ptr);
+ else
+ rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING(desc)->ptr);
}
/*
* call-seq:
* rxp.casefold? => true or false
- *
+ *
* Returns the value of the case-insensitive flag.
- *
- * /a/.casefold? #=> false
- * /a/i.casefold? #=> true
- * /(?i:a)/.casefold? #=> false
*/
static VALUE
-rb_reg_casefold_p(VALUE re)
+rb_reg_casefold_p(re)
+ VALUE re;
{
rb_reg_check(re);
- if (RREGEXP(re)->ptr->options & ONIG_OPTION_IGNORECASE) return Qtrue;
+ if (RREGEXP(re)->ptr->options & RE_OPTION_IGNORECASE) return Qtrue;
return Qfalse;
}
@@ -504,118 +555,75 @@ rb_reg_casefold_p(VALUE re)
/*
* call-seq:
* rxp.options => fixnum
- *
+ *
* Returns the set of bits corresponding to the options used when creating this
* Regexp (see <code>Regexp::new</code> for details. Note that additional bits
* may be set in the returned options: these are used internally by the regular
* expression code. These extra bits are ignored if the options are passed to
* <code>Regexp::new</code>.
- *
+ *
* Regexp::IGNORECASE #=> 1
* Regexp::EXTENDED #=> 2
* Regexp::MULTILINE #=> 4
- *
- * /cat/.options #=> 0
- * /cat/ix.options #=> 3
- * Regexp.new('cat', true).options #=> 1
- * /\xa1\xa2/e.options #=> 16
- *
+ *
+ * /cat/.options #=> 128
+ * /cat/ix.options #=> 131
+ * Regexp.new('cat', true).options #=> 129
+ * Regexp.new('cat', 0, 's').options #=> 384
+ *
* r = /cat/ix
* Regexp.new(r.source, r.options) #=> /cat/ix
*/
static VALUE
-rb_reg_options_m(VALUE re)
+rb_reg_options_m(re)
+ VALUE re;
{
int options = rb_reg_options(re);
return INT2NUM(options);
}
-static int
-reg_names_iter(const OnigUChar *name, const OnigUChar *name_end,
- int back_num, int *back_refs, OnigRegex regex, void *arg)
-{
- VALUE ary = (VALUE)arg;
- rb_ary_push(ary, rb_str_new((const char *)name, name_end-name));
- return 0;
-}
/*
- * call-seq:
- * rxp.names => [name1, name2, ...]
- *
- * Returns a list of names of captures as an array of strings.
- *
- * /(?<foo>.)(?<bar>.)(?<baz>.)/.names
- * #=> ["foo", "bar", "baz"]
- *
- * /(?<foo>.)(?<foo>.)/.names
- * #=> ["foo"]
- *
- * /(.)(.)/.names'
- * #=> []
- */
-
-static VALUE
-rb_reg_names(VALUE re)
-{
- VALUE ary = rb_ary_new();
- onig_foreach_name(RREGEXP(re)->ptr, reg_names_iter, (void*)ary);
- return ary;
-}
-
-static int
-reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
- int back_num, int *back_refs, OnigRegex regex, void *arg)
-{
- VALUE hash = (VALUE)arg;
- VALUE ary = rb_ary_new2(back_num);
- int i;
-
- for(i = 0; i < back_num; i++)
- rb_ary_store(ary, i, INT2NUM(back_refs[i]));
-
- rb_hash_aset(hash, rb_str_new((const char*)name, name_end-name),ary);
-
- return 0;
-}
-
-/*
- * call-seq:
- * rxp.named_captures => hash
- *
- * Returns a hash representing information about named captures of <i>rxp</i>.
- *
- * A key of the hash is a name of the named captures.
- * A value of the hash is an array which is list of indexes of corresponding
- * named captures.
- *
- * /(?<foo>.)(?<bar>.)/.named_captures
- * #=> {"foo"=>[1], "bar"=>[2]}
- *
- * /(?<foo>.)(?<foo>.)/.named_captures'
- * #=> {"foo"=>[1, 2]}
- *
- * If there are no named captures, an empty hash is returned.
- *
- * /(.)(.)/.named_captures'
- * #=> {}
+ * call-seq:
+ * rxp.kcode => str
+ *
+ * Returns the character set code for the regexp.
*/
static VALUE
-rb_reg_named_captures(VALUE re)
-{
- VALUE hash = rb_hash_new();
- onig_foreach_name(RREGEXP(re)->ptr, reg_named_captures_iter, (void*)hash);
- return hash;
+rb_reg_kcode_m(re)
+ VALUE re;
+{
+ const char *kcode;
+
+ if (FL_TEST(re, KCODE_FIXED)) {
+ switch (RBASIC(re)->flags & KCODE_MASK) {
+ case KCODE_NONE:
+ kcode = "none"; break;
+ case KCODE_EUC:
+ kcode = "euc"; break;
+ case KCODE_SJIS:
+ kcode = "sjis"; break;
+ case KCODE_UTF8:
+ kcode = "utf8"; break;
+ default:
+ rb_bug("unknown kcode - should not happen");
+ break;
+ }
+ return rb_str_new2(kcode);
+ }
+ return Qnil;
}
static Regexp*
-make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_buffer err)
+make_regexp(s, len, flags)
+ const char *s;
+ long len;
+ int flags;
{
Regexp *rp;
- int r;
- OnigErrorInfo einfo;
+ const char *err;
/* Handle escaped characters first. */
@@ -624,18 +632,19 @@ make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_bu
from that.
*/
- r = onig_alloc_init(&rp, flags, ONIGENC_CASE_FOLD_DEFAULT,
- enc, OnigDefaultSyntax);
- if (r) {
- onig_error_code_to_str((UChar*)err, r);
- return 0;
+ rp = ALLOC(Regexp);
+ MEMZERO((char *)rp, Regexp, 1);
+ rp->buffer = ALLOC_N(char, 16);
+ rp->allocated = 16;
+ rp->fastmap = ALLOC_N(char, 256);
+ if (flags) {
+ rp->options = flags;
}
+ err = re_compile_pattern(s, len, rp);
- r = onig_compile(rp, (UChar*)s, (UChar*)(s + len), &einfo);
-
- if (r != 0) {
- onig_free(rp);
- (void )onig_error_code_to_str((UChar*)err, r, &einfo);
+ if (err != NULL) {
+ re_free_pattern(rp);
+ rb_reg_raise(s, len, err, 0);
return 0;
}
return rp;
@@ -647,24 +656,26 @@ make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_bu
*
* <code>MatchData</code> is the type of the special variable <code>$~</code>,
* and is the type of the object returned by <code>Regexp#match</code> and
- * <code>Regexp.last_match</code>. It encapsulates all the results of a pattern
+ * <code>Regexp#last_match</code>. It encapsulates all the results of a pattern
* match, results normally accessed through the special variables
* <code>$&</code>, <code>$'</code>, <code>$`</code>, <code>$1</code>,
- * <code>$2</code>, and so on.
+ * <code>$2</code>, and so on. <code>Matchdata</code> is also known as
+ * <code>MatchingData</code>.
*
*/
VALUE rb_cMatch;
+static VALUE match_alloc _((VALUE));
static VALUE
-match_alloc(VALUE klass)
+match_alloc(klass)
+ VALUE klass;
{
NEWOBJ(match, struct RMatch);
OBJSETUP(match, klass, T_MATCH);
match->str = 0;
match->regs = 0;
- match->regexp = 0;
match->regs = ALLOC(struct re_registers);
MEMZERO(match->regs, struct re_registers, 1);
@@ -673,7 +684,8 @@ match_alloc(VALUE klass)
/* :nodoc: */
static VALUE
-match_init_copy(VALUE obj, VALUE orig)
+match_init_copy(obj, orig)
+ VALUE obj, orig;
{
if (obj == orig) return obj;
@@ -681,134 +693,51 @@ match_init_copy(VALUE obj, VALUE orig)
rb_raise(rb_eTypeError, "wrong argument class");
}
RMATCH(obj)->str = RMATCH(orig)->str;
- onig_region_free(RMATCH(obj)->regs, 0);
+ re_free_registers(RMATCH(obj)->regs);
RMATCH(obj)->regs->allocated = 0;
- onig_region_copy(RMATCH(obj)->regs, RMATCH(orig)->regs);
+ re_copy_registers(RMATCH(obj)->regs, RMATCH(orig)->regs);
return obj;
}
/*
- * call-seq:
- * mtch.regexp => regexp
- *
- * Returns the regexp.
- *
- * m = /a.*b/.match("abc")
- * m.regexp #=> /a.*b/
- */
-
-static VALUE
-match_regexp(VALUE match)
-{
- return RMATCH(match)->regexp;
-}
-
-/*
- * call-seq:
- * mtch.names => [name1, name2, ...]
- *
- * Returns a list of names of captures as an array of strings.
- * It is same as mtch.regexp.names.
- *
- * /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").names
- * #=> ["foo", "bar", "baz"]
- *
- * m = /(?<x>.)(?<y>.)?/.match("a") #=> #<MatchData "a" x:"a" y:nil>
- * m.names #=> ["x", "y"]
- */
-
-static VALUE
-match_names(VALUE match)
-{
- return rb_reg_names(RMATCH(match)->regexp);
-}
-
-/*
* call-seq:
* mtch.length => integer
* mtch.size => integer
- *
+ *
* Returns the number of elements in the match array.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.length #=> 5
* m.size #=> 5
*/
static VALUE
-match_size(VALUE match)
+match_size(match)
+ VALUE match;
{
return INT2FIX(RMATCH(match)->regs->num_regs);
}
-static VALUE
-match_sublen(VALUE str, int offset)
-{
- int i;
-
- i = rb_str_sublen(str, offset);
- return INT2FIX(i);
-}
-
-static int
-match_backref_number(VALUE match, VALUE backref)
-{
- const char *name;
- int num;
-
- struct re_registers *regs = RMATCH(match)->regs;
- VALUE regexp = RMATCH(match)->regexp;
-
- switch(TYPE(backref)) {
- default:
- return NUM2INT(backref);
-
- case T_SYMBOL:
- name = rb_id2name(SYM2ID(backref));
- break;
-
- case T_STRING:
- name = StringValueCStr(backref);
- break;
- }
-
- num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
- (const unsigned char*)name,
- (const unsigned char*)name + strlen(name),
- regs);
-
- if (num < 1) {
- rb_raise(rb_eIndexError, "undefined group name reference: %s", name);
- }
-
- return num;
-}
-
/*
* call-seq:
* mtch.offset(n) => array
- *
+ *
* Returns a two-element array containing the beginning and ending offsets of
* the <em>n</em>th match.
- * <em>n</em> can be a string or symbol to reference a named capture.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
- * m.offset(0) #=> [1, 7]
- * m.offset(4) #=> [6, 7]
- *
- * m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
- * p m.offset(:foo) #=> [0, 1]
- * p m.offset(:bar) #=> [2, 3]
- *
+ * m.offset(0) #=> [1, 7]
+ * m.offset(4) #=> [6, 7]
*/
static VALUE
-match_offset(VALUE match, VALUE n)
+match_offset(match, n)
+ VALUE match, n;
{
- int i = match_backref_number(match, n);
+ int i = NUM2INT(n);
if (i < 0 || RMATCH(match)->regs->num_regs <= i)
rb_raise(rb_eIndexError, "index %d out of matches", i);
@@ -816,32 +745,28 @@ match_offset(VALUE match, VALUE n)
if (RMATCH(match)->regs->beg[i] < 0)
return rb_assoc_new(Qnil, Qnil);
- return rb_assoc_new(match_sublen(RMATCH(match)->str, RMATCH(match)->regs->beg[i]),
- match_sublen(RMATCH(match)->str, RMATCH(match)->regs->end[i]));
+ return rb_assoc_new(INT2FIX(RMATCH(match)->regs->beg[i]),
+ INT2FIX(RMATCH(match)->regs->end[i]));
}
/*
* call-seq:
* mtch.begin(n) => integer
- *
+ *
* Returns the offset of the start of the <em>n</em>th element of the match
* array in the string.
- * <em>n</em> can be a string or symbol to reference a named capture.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
- * m.begin(0) #=> 1
- * m.begin(2) #=> 2
- *
- * m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
- * p m.begin(:foo) #=> 0
- * p m.begin(:bar) #=> 2
+ * m.begin(0) #=> 1
+ * m.begin(2) #=> 2
*/
static VALUE
-match_begin(VALUE match, VALUE n)
+match_begin(match, n)
+ VALUE match, n;
{
- int i = match_backref_number(match, n);
+ int i = NUM2INT(n);
if (i < 0 || RMATCH(match)->regs->num_regs <= i)
rb_raise(rb_eIndexError, "index %d out of matches", i);
@@ -849,31 +774,27 @@ match_begin(VALUE match, VALUE n)
if (RMATCH(match)->regs->beg[i] < 0)
return Qnil;
- return match_sublen(RMATCH(match)->str, RMATCH(match)->regs->beg[i]);
+ return INT2FIX(RMATCH(match)->regs->beg[i]);
}
/*
* call-seq:
* mtch.end(n) => integer
- *
+ *
* Returns the offset of the character immediately following the end of the
* <em>n</em>th element of the match array in the string.
- * <em>n</em> can be a string or symbol to reference a named capture.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
- * m.end(0) #=> 7
- * m.end(2) #=> 3
- *
- * m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
- * p m.end(:foo) #=> 1
- * p m.end(:bar) #=> 3
+ * m.end(0) #=> 7
+ * m.end(2) #=> 3
*/
static VALUE
-match_end(VALUE match, VALUE n)
+match_end(match, n)
+ VALUE match, n;
{
- int i = match_backref_number(match, n);
+ int i = NUM2INT(n);
if (i < 0 || RMATCH(match)->regs->num_regs <= i)
rb_raise(rb_eIndexError, "index %d out of matches", i);
@@ -881,193 +802,134 @@ match_end(VALUE match, VALUE n)
if (RMATCH(match)->regs->beg[i] < 0)
return Qnil;
- return match_sublen(RMATCH(match)->str, RMATCH(match)->regs->end[i]);
+ return INT2FIX(RMATCH(match)->regs->end[i]);
}
#define MATCH_BUSY FL_USER2
void
-rb_match_busy(VALUE match)
+rb_match_busy(match)
+ VALUE match;
{
FL_SET(match, MATCH_BUSY);
}
-/*
- * call-seq:
- * rxp.fixed_encoding? => true or false
- *
- * Returns false if rxp is applicable to
- * a string with any ASCII compatible encoding.
- * Returns true otherwise.
- *
- * r = /a/
- * r.fixed_encoding? #=> false
- * r =~ "\u{6666} a" #=> 2
- * r =~ "\xa1\xa2 a".force_encoding("euc-jp") #=> 2
- * r =~ "abc".force_encoding("euc-jp") #=> 0
- *
- * r = /a/u
- * r.fixed_encoding? #=> true
- * r.encoding #=> <Encoding:UTF-8>
- * r =~ "\u{6666} a" #=> 2
- * r =~ "\xa1\xa2".force_encoding("euc-jp") # ArgumentError
- * r =~ "abc".force_encoding("euc-jp") #=> 0
- *
- * r = /\u{6666}/
- * r.fixed_encoding? #=> true
- * r.encoding #=> <Encoding:UTF-8>
- * r =~ "\u{6666} a" #=> 0
- * r =~ "\xa1\xa2".force_encoding("euc-jp") # ArgumentError
- * r =~ "abc".force_encoding("euc-jp") #=> nil
- */
-
-static VALUE
-rb_reg_fixed_encoding_p(VALUE re)
-{
- if (ENCODING_GET(re) != 0 || FL_TEST(re, KCODE_FIXED))
- return Qtrue;
- else
- return Qfalse;
-}
-
-static VALUE
-rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
- rb_encoding **fixed_enc, onig_errmsg_buffer err);
+int ruby_ignorecase;
+static int may_need_recompile;
static void
-rb_reg_prepare_re(VALUE re, VALUE str)
+rb_reg_prepare_re(re)
+ VALUE re;
{
int need_recompile = 0;
- rb_encoding *enc;
+ int state;
rb_reg_check(re);
+ state = FL_TEST(re, REG_CASESTATE);
/* ignorecase status */
- if (rb_reg_fixed_encoding_p(re)) {
- if (ENCODING_GET(re) != rb_enc_get_index(str) &&
- rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
- rb_raise(rb_eArgError,
- "incompatible encoding regexp match (%s regexp with %s string)",
- rb_enc_name(rb_enc_from_index(ENCODING_GET(re))),
- rb_enc_name(rb_enc_get(str)));
- }
+ if (ruby_ignorecase && !state) {
+ FL_SET(re, REG_CASESTATE);
+ RREGEXP(re)->ptr->options |= RE_OPTION_IGNORECASE;
+ need_recompile = 1;
}
- else {
- if ((enc = rb_enc_get(str)) != 0 &&
- RREGEXP(re)->ptr->enc != enc) {
- need_recompile = 1;
- }
- if ((RBASIC(re)->flags & REG_ENCODING_NONE) &&
- enc != rb_ascii8bit_encoding() &&
- rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
- rb_warn("regexp match /.../n against to %s string",
- rb_enc_name(enc));
- }
+ if (!ruby_ignorecase && state) {
+ FL_UNSET(re, REG_CASESTATE);
+ RREGEXP(re)->ptr->options &= ~RE_OPTION_IGNORECASE;
+ need_recompile = 1;
+ }
+
+ if (!FL_TEST(re, KCODE_FIXED) &&
+ (RBASIC(re)->flags & KCODE_MASK) != reg_kcode) {
+ need_recompile = 1;
+ RBASIC(re)->flags &= ~KCODE_MASK;
+ RBASIC(re)->flags |= reg_kcode;
}
if (need_recompile) {
- onig_errmsg_buffer err;
- int r;
- OnigErrorInfo einfo;
- regex_t *reg, *reg2;
- UChar *pattern;
- VALUE unescaped;
- rb_encoding *fixed_enc = 0;
+ const char *err;
+ if (FL_TEST(re, KCODE_FIXED))
+ rb_kcode_set_option(re);
rb_reg_check(re);
- reg = RREGEXP(re)->ptr;
- pattern = ((UChar*)RREGEXP(re)->str);
-
- unescaped = rb_reg_preprocess(
- RREGEXP(re)->str, RREGEXP(re)->str + RREGEXP(re)->len, enc,
- &fixed_enc, err);
-
- r = onig_new(&reg2, (UChar* )RSTRING_PTR(unescaped),
- (UChar* )(RSTRING_PTR(unescaped) + RSTRING_LEN(unescaped)),
- reg->options, enc,
- OnigDefaultSyntax, &einfo);
- if (r) {
- onig_error_code_to_str((UChar*)err, r, &einfo);
- rb_reg_raise((char* )pattern, RREGEXP(re)->len, err, re);
+ RREGEXP(re)->ptr->fastmap_accurate = 0;
+ err = re_compile_pattern(RREGEXP(re)->str, RREGEXP(re)->len, RREGEXP(re)->ptr);
+ if (err != NULL) {
+ rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len, err, re);
}
-
- RREGEXP(re)->ptr = reg2;
- onig_free(reg);
- RB_GC_GUARD(unescaped);
}
}
-int
-rb_reg_adjust_startpos(VALUE re, VALUE str, int pos, int reverse)
+long
+rb_reg_adjust_startpos(re, str, pos, reverse)
+ VALUE re, str;
+ long pos, reverse;
{
- int range;
- OnigEncoding enc;
- UChar *p, *string;
+ long range;
- rb_reg_prepare_re(re, str);
+ rb_reg_check(re);
+ if (may_need_recompile) rb_reg_prepare_re(re);
+
+ if (FL_TEST(re, KCODE_FIXED))
+ rb_kcode_set_option(re);
+ else if (reg_kcode != curr_kcode)
+ rb_kcode_reset_option();
if (reverse) {
range = -pos;
}
else {
- range = RSTRING_LEN(str) - pos;
+ range = RSTRING(str)->len - pos;
}
-
- enc = (RREGEXP(re)->ptr)->enc;
-
- if (pos > 0 && ONIGENC_MBC_MAXLEN(enc) != 1 && pos < RSTRING_LEN(str)) {
- string = (UChar*)RSTRING_PTR(str);
-
- if (range > 0) {
- p = onigenc_get_right_adjust_char_head(enc, string, string + pos);
- }
- else {
- p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, string, string + pos);
- }
- return p - string;
- }
-
- return pos;
+ return re_adjust_startpos(RREGEXP(re)->ptr,
+ RSTRING(str)->ptr, RSTRING(str)->len,
+ pos, range);
}
-int
-rb_reg_search(VALUE re, VALUE str, int pos, int reverse)
+long
+rb_reg_search(re, str, pos, reverse)
+ VALUE re, str;
+ long pos, reverse;
{
- int result;
+ long result;
VALUE match;
- static struct re_registers regs;
- int range;
+ struct re_registers regs;
+ long range;
- if (pos > RSTRING_LEN(str) || pos < 0) {
+ if (pos > RSTRING(str)->len || pos < 0) {
rb_backref_set(Qnil);
return -1;
}
- rb_reg_prepare_re(re, str);
+ rb_reg_check(re);
+ if (may_need_recompile) rb_reg_prepare_re(re);
+
+ if (FL_TEST(re, KCODE_FIXED))
+ rb_kcode_set_option(re);
+ else if (reg_kcode != curr_kcode)
+ rb_kcode_reset_option();
if (reverse) {
range = -pos;
}
else {
- range = RSTRING_LEN(str) - pos;
+ range = RSTRING(str)->len - pos;
}
+ MEMZERO(&regs, struct re_registers, 1);
+ result = re_search(RREGEXP(re)->ptr,RSTRING(str)->ptr,RSTRING(str)->len,
+ pos, range, &regs);
+
+ if (FL_TEST(re, KCODE_FIXED))
+ rb_kcode_reset_option();
- result = onig_search(RREGEXP(re)->ptr,
- (UChar*)(RSTRING_PTR(str)),
- ((UChar*)(RSTRING_PTR(str)) + RSTRING_LEN(str)),
- ((UChar*)(RSTRING_PTR(str)) + pos),
- ((UChar*)(RSTRING_PTR(str)) + pos + range),
- &regs, ONIG_OPTION_NONE);
+ if (result == -2) {
+ rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len,
+ "Stack overflow in regexp matcher", re);
+ }
if (result < 0) {
- if (result == ONIG_MISMATCH) {
- rb_backref_set(Qnil);
- return result;
- }
- else {
- onig_errmsg_buffer err;
- onig_error_code_to_str((UChar*)err, result);
- rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len, err, 0);
- }
+ re_free_registers(&regs);
+ rb_backref_set(Qnil);
+ return result;
}
match = rb_backref_get();
@@ -1075,25 +937,26 @@ rb_reg_search(VALUE re, VALUE str, int pos, int reverse)
match = match_alloc(rb_cMatch);
}
else {
- if (rb_safe_level() >= 3)
+ if (rb_safe_level() >= 3)
OBJ_TAINT(match);
else
FL_UNSET(match, FL_TAINT);
}
- onig_region_copy(RMATCH(match)->regs, &regs);
+ re_copy_registers(RMATCH(match)->regs, &regs);
+ re_free_registers(&regs);
RMATCH(match)->str = rb_str_new4(str);
- RMATCH(match)->regexp = re;
rb_backref_set(match);
OBJ_INFECT(match, re);
OBJ_INFECT(match, str);
-
return result;
}
VALUE
-rb_reg_nth_defined(int nth, VALUE match)
+rb_reg_nth_defined(nth, match)
+ int nth;
+ VALUE match;
{
if (NIL_P(match)) return Qnil;
if (nth >= RMATCH(match)->regs->num_regs) {
@@ -1108,7 +971,9 @@ rb_reg_nth_defined(int nth, VALUE match)
}
VALUE
-rb_reg_nth_match(int nth, VALUE match)
+rb_reg_nth_match(nth, match)
+ int nth;
+ VALUE match;
{
VALUE str;
long start, end, len;
@@ -1125,13 +990,14 @@ rb_reg_nth_match(int nth, VALUE match)
if (start == -1) return Qnil;
end = RMATCH(match)->END(nth);
len = end - start;
- str = rb_str_subseq(RMATCH(match)->str, start, len);
+ str = rb_str_substr(RMATCH(match)->str, start, len);
OBJ_INFECT(str, match);
return str;
}
VALUE
-rb_reg_last_match(VALUE match)
+rb_reg_last_match(match)
+ VALUE match;
{
return rb_reg_nth_match(0, match);
}
@@ -1140,22 +1006,23 @@ rb_reg_last_match(VALUE match)
/*
* call-seq:
* mtch.pre_match => str
- *
+ *
* Returns the portion of the original string before the current match.
* Equivalent to the special variable <code>$`</code>.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.pre_match #=> "T"
*/
VALUE
-rb_reg_match_pre(VALUE match)
+rb_reg_match_pre(match)
+ VALUE match;
{
VALUE str;
if (NIL_P(match)) return Qnil;
if (RMATCH(match)->BEG(0) == -1) return Qnil;
- str = rb_str_subseq(RMATCH(match)->str, 0, RMATCH(match)->BEG(0));
+ str = rb_str_substr(RMATCH(match)->str, 0, RMATCH(match)->BEG(0));
if (OBJ_TAINTED(match)) OBJ_TAINT(str);
return str;
}
@@ -1164,16 +1031,17 @@ rb_reg_match_pre(VALUE match)
/*
* call-seq:
* mtch.post_match => str
- *
+ *
* Returns the portion of the original string after the current match.
* Equivalent to the special variable <code>$'</code>.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
* m.post_match #=> ": The Movie"
*/
VALUE
-rb_reg_match_post(VALUE match)
+rb_reg_match_post(match)
+ VALUE match;
{
VALUE str;
long pos;
@@ -1182,13 +1050,14 @@ rb_reg_match_post(VALUE match)
if (RMATCH(match)->BEG(0) == -1) return Qnil;
str = RMATCH(match)->str;
pos = RMATCH(match)->END(0);
- str = rb_str_subseq(str, pos, RSTRING_LEN(str) - pos);
+ str = rb_str_substr(str, pos, RSTRING(str)->len - pos);
if (OBJ_TAINTED(match)) OBJ_TAINT(str);
return str;
}
VALUE
-rb_reg_match_last(VALUE match)
+rb_reg_match_last(match)
+ VALUE match;
{
int i;
@@ -1202,44 +1071,46 @@ rb_reg_match_last(VALUE match)
}
static VALUE
-last_match_getter(void)
+last_match_getter()
{
return rb_reg_last_match(rb_backref_get());
}
static VALUE
-prematch_getter(void)
+prematch_getter()
{
return rb_reg_match_pre(rb_backref_get());
}
static VALUE
-postmatch_getter(void)
+postmatch_getter()
{
return rb_reg_match_post(rb_backref_get());
}
static VALUE
-last_paren_match_getter(void)
+last_paren_match_getter()
{
return rb_reg_match_last(rb_backref_get());
}
static VALUE
-match_array(VALUE match, int start)
+match_array(match, start)
+ VALUE match;
+ int start;
{
struct re_registers *regs = RMATCH(match)->regs;
VALUE ary = rb_ary_new2(regs->num_regs);
VALUE target = RMATCH(match)->str;
int i;
int taint = OBJ_TAINTED(match);
-
+
for (i=start; i<regs->num_regs; i++) {
if (regs->beg[i] == -1) {
rb_ary_push(ary, Qnil);
}
else {
- VALUE str = rb_str_subseq(target, regs->beg[i], regs->end[i]-regs->beg[i]);
+ VALUE str = rb_str_substr(target, regs->beg[i], regs->end[i]-regs->beg[i]);
if (taint) OBJ_TAINT(str);
rb_ary_push(ary, str);
}
@@ -1255,18 +1126,18 @@ match_array(VALUE match, int start)
/*
* call-seq:
* mtch.to_a => anArray
- *
+ *
* Returns the array of matches.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
- *
+ *
* Because <code>to_a</code> is called when expanding
* <code>*</code><em>variable</em>, there's a useful assignment
* shortcut for extracting matched fields. This is slightly slower than
* accessing the fields directly (as an intermediate array is
* generated).
- *
+ *
* all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138."))
* all #=> "HX1138"
* f1 #=> "H"
@@ -1275,7 +1146,8 @@ match_array(VALUE match, int start)
*/
static VALUE
-match_to_a(VALUE match)
+match_to_a(match)
+ VALUE match;
{
return match_array(match, 0);
}
@@ -1294,96 +1166,53 @@ match_to_a(VALUE match)
* f4 #=> "8"
*/
static VALUE
-match_captures(VALUE match)
+match_captures(match)
+ VALUE match;
{
return match_array(match, 1);
}
-static int
-name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
-{
- int num;
-
- num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
- (const unsigned char* )name, (const unsigned char* )name_end, regs);
- if (num >= 1) {
- return num;
- }
- else {
- VALUE s = rb_str_new(name, (long )(name_end - name));
- rb_raise(rb_eIndexError, "undefined group name reference: %s",
- StringValuePtr(s));
- }
-}
/*
* call-seq:
- * mtch[i] => str or nil
+ * mtch[i] => obj
* mtch[start, length] => array
* mtch[range] => array
- * mtch[name] => str or nil
- *
+ *
* Match Reference---<code>MatchData</code> acts as an array, and may be
* accessed using the normal array indexing techniques. <i>mtch</i>[0] is
* equivalent to the special variable <code>$&</code>, and returns the entire
* matched string. <i>mtch</i>[1], <i>mtch</i>[2], and so on return the values
* of the matched backreferences (portions of the pattern between parentheses).
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
- * m #=> #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
* m[0] #=> "HX1138"
* m[1, 2] #=> ["H", "X"]
* m[1..3] #=> ["H", "X", "113"]
* m[-3, 2] #=> ["X", "113"]
- *
- * m = /(?<foo>a+)b/.match("ccaaab")
- * m #=> #<MatchData "aaab" foo:"aaa">
- * m["foo"] #=> "aaa"
- * m[:foo] #=> "aaa"
*/
static VALUE
-match_aref(int argc, VALUE *argv, VALUE match)
+match_aref(argc, argv, match)
+ int argc;
+ VALUE *argv;
+ VALUE match;
{
VALUE idx, rest;
rb_scan_args(argc, argv, "11", &idx, &rest);
- if (NIL_P(rest)) {
- if (FIXNUM_P(idx)) {
- if (FIX2INT(idx) >= 0) {
- return rb_reg_nth_match(FIX2INT(idx), match);
- }
- }
- else {
- const char *p;
- int num;
-
- switch (TYPE(idx)) {
- case T_SYMBOL:
- p = rb_id2name(SYM2ID(idx));
- goto name_to_backref;
- break;
- case T_STRING:
- p = StringValuePtr(idx);
-
- name_to_backref:
- num = name_to_backref_number(RMATCH(match)->regs,
- RMATCH(match)->regexp, p, p + strlen(p));
- return rb_reg_nth_match(num, match);
- break;
-
- default:
- break;
- }
- }
+ if (!NIL_P(rest) || !FIXNUM_P(idx) || FIX2INT(idx) < 0) {
+ return rb_ary_aref(argc, argv, match_to_a(match));
}
-
- return rb_ary_aref(argc, argv, match_to_a(match));
+ return rb_reg_nth_match(FIX2INT(idx), match);
}
+static VALUE match_entry _((VALUE, long));
static VALUE
-match_entry(VALUE match, long n)
+match_entry(match, n)
+ VALUE match;
+ long n;
{
return rb_reg_nth_match(n, match);
}
@@ -1391,37 +1220,79 @@ match_entry(VALUE match, long n)
/*
* call-seq:
- *
* mtch.values_at([index]*) => array
- * mtch.select([index]*) => array
- *
+ *
* Uses each <i>index</i> to access the matching values, returning an array of
* the corresponding matches.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
* m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"]
*/
static VALUE
-match_values_at(int argc, VALUE *argv, VALUE match)
+match_values_at(argc, argv, match)
+ int argc;
+ VALUE *argv;
+ VALUE match;
{
- return rb_get_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry);
+ return rb_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry);
}
/*
* call-seq:
+ * mtch.select{|obj| block} => array
+ *
+ * Returns an array containing match strings for which <em>block</em>
+ * gives <code>true</code>. MatchData#select will be removed from Ruby 1.9.
+ *
+ * m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
+ * p m.select{|x| /X/ =~ x} #=> ["HX1138", "X"]
+ */
+
+static VALUE
+match_select(argc, argv, match)
+ int argc;
+ VALUE *argv;
+ VALUE match;
+{
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ else {
+ struct re_registers *regs = RMATCH(match)->regs;
+ VALUE target = RMATCH(match)->str;
+ VALUE result = rb_ary_new();
+ int i;
+ int taint = OBJ_TAINTED(match);
+
+ for (i=0; i<regs->num_regs; i++) {
+ VALUE str = rb_str_substr(target, regs->beg[i], regs->end[i]-regs->beg[i]);
+ if (taint) OBJ_TAINT(str);
+ if (RTEST(rb_yield(str))) {
+ rb_ary_push(result, str);
+ }
+ }
+ return result;
+ }
+}
+
+
+
+/*
+ * call-seq:
* mtch.to_s => str
- *
+ *
* Returns the entire matched string.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.to_s #=> "HX1138"
*/
static VALUE
-match_to_s(VALUE match)
+match_to_s(match)
+ VALUE match;
{
VALUE str = rb_reg_last_match(match);
@@ -1435,38 +1306,20 @@ match_to_s(VALUE match)
/*
* call-seq:
* mtch.string => str
- *
+ *
* Returns a frozen copy of the string passed in to <code>match</code>.
- *
+ *
* m = /(.)(.)(\d+)(\d)/.match("THX1138.")
* m.string #=> "THX1138."
*/
static VALUE
-match_string(VALUE match)
+match_string(match)
+ VALUE match;
{
return RMATCH(match)->str; /* str is frozen */
}
-struct backref_name_tag {
- const UChar *name;
- long len;
-};
-
-static int
-match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
- int back_num, int *back_refs, OnigRegex regex, void *arg0)
-{
- struct backref_name_tag *arg = (struct backref_name_tag *)arg0;
- int i;
-
- for (i = 0; i < back_num; i++) {
- arg[back_refs[i]].name = name;
- arg[back_refs[i]].len = name_end - name;
- }
- return 0;
-}
-
/*
* call-seq:
* mtch.inspect => str
@@ -1482,26 +1335,16 @@ match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
* puts /(.)(.)?(.)/.match("fo").inspect
* #=> #<MatchData "fo" 1:"f" 2:nil 3:"o">
*
- * puts /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").inspect
- * #=> #<MatchData "hog" foo:"h" bar:"o" baz:"g">
- *
*/
static VALUE
match_inspect(VALUE match)
{
- char *cname = rb_obj_classname(match);
+ const char *cname = rb_obj_classname(match);
VALUE str;
int i;
- int num_regs = RMATCH(match)->regs->num_regs;
- struct backref_name_tag *names;
- VALUE regexp = RMATCH(match)->regexp;
-
- names = ALLOCA_N(struct backref_name_tag, num_regs);
- MEMZERO(names, struct backref_name_tag, num_regs);
-
- onig_foreach_name(RREGEXP(regexp)->ptr,
- match_inspect_name_iter, names);
+ struct re_registers *regs = RMATCH(match)->regs;
+ int num_regs = regs->num_regs;
str = rb_str_buf_new2("#<");
rb_str_buf_cat2(str, cname);
@@ -1510,13 +1353,9 @@ match_inspect(VALUE match)
VALUE v;
rb_str_buf_cat2(str, " ");
if (0 < i) {
- if (names[i].name)
- rb_str_buf_cat(str, (const char *)names[i].name, names[i].len);
- else {
- char buf[sizeof(i)*3+1];
- snprintf(buf, sizeof(buf), "%d", i);
- rb_str_buf_cat2(str, buf);
- }
+ char buf[sizeof(i)*3+1];
+ snprintf(buf, sizeof(buf), "%d", i);
+ rb_str_buf_cat2(str, buf);
rb_str_buf_cat2(str, ":");
}
v = rb_reg_nth_match(i, match);
@@ -1532,500 +1371,72 @@ match_inspect(VALUE match)
VALUE rb_cRegexp;
-static int
-read_escaped_byte(const char **pp, const char *end, onig_errmsg_buffer err)
-{
- const char *p = *pp;
- int code;
- int meta_prefix = 0, ctrl_prefix = 0;
- int len;
- int retbyte;
-
- retbyte = -1;
- if (p == end || *p++ != '\\') {
- strcpy(err, "too short escaped multibyte character");
- return -1;
- }
-
-again:
- if (p == end) {
- strcpy(err, "too short escape sequence");
- return -1;
- }
- switch (*p++) {
- case '\\': code = '\\'; break;
- case 'n': code = '\n'; break;
- case 't': code = '\t'; break;
- case 'r': code = '\r'; break;
- case 'f': code = '\f'; break;
- case 'v': code = '\013'; break;
- case 'a': code = '\007'; break;
- case 'e': code = '\033'; break;
-
- /* \OOO */
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- p--;
- code = ruby_scan_oct(p, end < p+3 ? end-p : 3, &len);
- p += len;
- break;
-
- case 'x': /* \xHH */
- code = ruby_scan_hex(p, end < p+2 ? end-p : 2, &len);
- if (len < 1) {
- strcpy(err, "invalid hex escape");
- return -1;
- }
- p += len;
- break;
-
- case 'M': /* \M-X, \M-\C-X, \M-\cX */
- if (meta_prefix) {
- strcpy(err, "duplicate meta escape");
- return -1;
- }
- meta_prefix = 1;
- if (p+1 < end && *p++ == '-' && (*p & 0x80) == 0) {
- if (*p == '\\') {
- p++;
- goto again;
- }
- else {
- code = *p++;
- break;
- }
- }
- strcpy(err, "too short meta escape");
- return -1;
-
- case 'C': /* \C-X, \C-\M-X */
- if (p == end || *p++ != '-') {
- strcpy(err, "too short control escape");
- return -1;
- }
- case 'c': /* \cX, \c\M-X */
- if (ctrl_prefix) {
- strcpy(err, "duplicate control escape");
- return -1;
- }
- ctrl_prefix = 1;
- if (p < end && (*p & 0x80) == 0) {
- if (*p == '\\') {
- p++;
- goto again;
- }
- else {
- code = *p++;
- break;
- }
- }
- strcpy(err, "too short control escape");
- return -1;
-
- default:
- strcpy(err, "unexpected escape sequence");
- return -1;
- }
- if (code < 0 || 0xff < code) {
- strcpy(err, "invalid escape code");
- return -1;
- }
-
- if (ctrl_prefix)
- code &= 0x1f;
- if (meta_prefix)
- code |= 0x80;
-
- *pp = p;
- return code;
-}
-
-static int
-unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc,
- VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
-{
- const char *p = *pp;
- int chmaxlen = rb_enc_mbmaxlen(enc);
- char *chbuf = ALLOCA_N(char, chmaxlen);
- int chlen = 0;
- int byte;
- int l;
-
- memset(chbuf, 0, chmaxlen);
-
- byte = read_escaped_byte(&p, end, err);
- if (byte == -1) {
- return -1;
- }
-
- chbuf[chlen++] = byte;
- while (chlen < chmaxlen &&
- MBCLEN_NEEDMORE(rb_enc_precise_mbclen(chbuf, chbuf+chlen, enc))) {
- byte = read_escaped_byte(&p, end, err);
- if (byte == -1) {
- return -1;
- }
- chbuf[chlen++] = byte;
- }
-
- l = rb_enc_precise_mbclen(chbuf, chbuf+chlen, enc);
- if (MBCLEN_INVALID(l)) {
- strcpy(err, "invalid multibyte escape");
- return -1;
- }
- if (1 < chlen || (chbuf[0] & 0x80)) {
- rb_str_buf_cat(buf, chbuf, chlen);
-
- if (*encp == 0)
- *encp = enc;
- else if (*encp != enc) {
- strcpy(err, "escaped non ASCII character in UTF-8 regexp");
- return -1;
- }
- }
- else {
- char escbuf[5];
- snprintf(escbuf, sizeof(escbuf), "\\x%02X", chbuf[0]&0xff);
- rb_str_buf_cat(buf, escbuf, 4);
- }
- *pp = p;
- return 0;
-}
-
-static int
-check_unicode_range(unsigned long code, onig_errmsg_buffer err)
-{
- if ((0xd800 <= code && code <= 0xdfff) || /* Surrogates */
- 0x10ffff < code) {
- strcpy(err, "invalid Unicode range");
- return -1;
- }
- return 0;
-}
-
-static int
-append_utf8(unsigned long uv,
- VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
-{
- if (check_unicode_range(uv, err) != 0)
- return -1;
- if (uv < 0x80) {
- char escbuf[5];
- snprintf(escbuf, sizeof(escbuf), "\\x%02X", (int)uv);
- rb_str_buf_cat(buf, escbuf, 4);
- }
- else {
- int len;
- char utf8buf[6];
- len = rb_uv_to_utf8(utf8buf, uv);
- rb_str_buf_cat(buf, utf8buf, len);
-
- if (*encp == 0)
- *encp = rb_utf8_encoding();
- else if (*encp != rb_utf8_encoding()) {
- strcpy(err, "UTF-8 character in non UTF-8 regexp");
- return -1;
- }
- }
- return 0;
-}
-
-static int
-unescape_unicode_list(const char **pp, const char *end,
- VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
-{
- const char *p = *pp;
- int has_unicode = 0;
- unsigned long code;
- int len;
-
- while (p < end && ISSPACE(*p)) p++;
-
- while (1) {
- code = ruby_scan_hex(p, end-p, &len);
- if (len == 0)
- break;
- if (6 < len) { /* max 10FFFF */
- strcpy(err, "invalid Unicode range");
- return -1;
- }
- p += len;
- if (append_utf8(code, buf, encp, err) != 0)
- return -1;
- has_unicode = 1;
-
- while (p < end && ISSPACE(*p)) p++;
- }
-
- if (has_unicode == 0) {
- strcpy(err, "invalid Unicode list");
- return -1;
- }
-
- *pp = p;
-
- return 0;
-}
-
-static int
-unescape_unicode_bmp(const char **pp, const char *end,
- VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
-{
- const char *p = *pp;
- int len;
- unsigned long code;
-
- if (end < p+4) {
- strcpy(err, "invalid Unicode escape");
- return -1;
- }
- code = ruby_scan_hex(p, 4, &len);
- if (len != 4) {
- strcpy(err, "invalid Unicode escape");
- return -1;
- }
- if (append_utf8(code, buf, encp, err) != 0)
- return -1;
- *pp = p + 4;
- return 0;
-}
-
-static int
-unescape_nonascii(const char *p, const char *end, rb_encoding *enc,
- VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
-{
- char c;
- char smallbuf[2];
-
- while (p < end) {
- int chlen = rb_enc_precise_mbclen(p, end, enc);
- if (!MBCLEN_CHARFOUND(chlen)) {
- strcpy(err, "invalid multibyte character");
- return -1;
- }
- if (1 < chlen || (*p & 0x80)) {
- rb_str_buf_cat(buf, p, chlen);
- p += chlen;
- if (*encp == 0)
- *encp = enc;
- else if (*encp != enc) {
- strcpy(err, "non ASCII character in UTF-8 regexp");
- return -1;
- }
- continue;
- }
-
- switch (c = *p++) {
- case '\\':
- if (p == end) {
- strcpy(err, "too short escape sequence");
- return -1;
- }
- switch (c = *p++) {
- case '1': case '2': case '3':
- case '4': case '5': case '6': case '7': /* \O, \OO, \OOO or backref */
- {
- int octlen;
- if (ruby_scan_oct(p-1, end-(p-1), &octlen) <= 0177) {
- /* backref or 7bit octal.
- no need to unescape anyway.
- re-escaping may break backref */
- goto escape_asis;
- }
- }
- /* xxx: How about more than 199 subexpressions? */
-
- case '0': /* \0, \0O, \0OO */
-
- case 'x': /* \xHH */
- case 'c': /* \cX, \c\M-X */
- case 'C': /* \C-X, \C-\M-X */
- case 'M': /* \M-X, \M-\C-X, \M-\cX */
- p = p-2;
- if (unescape_escaped_nonascii(&p, end, enc, buf, encp, err) != 0)
- return -1;
- break;
-
- case 'u':
- if (p == end) {
- strcpy(err, "too short escape sequence");
- return -1;
- }
- if (*p == '{') {
- /* \u{H HH HHH HHHH HHHHH HHHHHH ...} */
- p++;
- if (unescape_unicode_list(&p, end, buf, encp, err) != 0)
- return -1;
- if (p == end || *p++ != '}') {
- strcpy(err, "invalid Unicode list");
- return -1;
- }
- break;
- }
- else {
- /* \uHHHH */
- if (unescape_unicode_bmp(&p, end, buf, encp, err) != 0)
- return -1;
- break;
- }
-
- default: /* \n, \\, \d, \9, etc. */
-escape_asis:
- smallbuf[0] = '\\';
- smallbuf[1] = c;
- rb_str_buf_cat(buf, smallbuf, 2);
- break;
- }
- break;
-
- default:
- rb_str_buf_cat(buf, &c, 1);
- break;
- }
- }
-
- return 0;
-}
-
-static VALUE
-rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc,
- rb_encoding **fixed_enc, onig_errmsg_buffer err)
-{
- VALUE buf;
-
- buf = rb_str_buf_new(0);
-
- *fixed_enc = 0;
- if (unescape_nonascii(p, end, enc, buf, fixed_enc, err) != 0)
- return Qnil;
-
- if (fixed_enc) {
- rb_enc_associate(buf, *fixed_enc);
- }
-
- return buf;
-}
-
-VALUE
-rb_reg_check_preprocess(VALUE str)
-{
- rb_encoding *fixed_enc = 0;
- onig_errmsg_buffer err;
- VALUE buf;
- char *p, *end;
- rb_encoding *enc;
-
- StringValue(str);
- p = RSTRING_PTR(str);
- end = p + RSTRING_LEN(str);
- enc = rb_enc_get(str);
-
- buf = rb_reg_preprocess(p, end, enc, &fixed_enc, err);
- RB_GC_GUARD(str);
-
- if (buf == Qnil) {
- return rb_reg_error_desc(str, 0, err);
- }
- return Qnil;
-}
-
-#if 0
-static VALUE
-rb_reg_preprocess_obj(VALUE str,
- rb_encoding **fixed_enc, onig_errmsg_buffer err)
-{
- VALUE buf;
- char *p, *end;
- rb_encoding *enc;
-
- StringValue(str);
- p = RSTRING_PTR(str);
- end = p + RSTRING_LEN(str);
- enc = rb_enc_get(str);
-
- buf = rb_reg_preprocess(p, end, enc, fixed_enc, err);
- RB_GC_GUARD(str);
- return buf;
-}
-
-static VALUE
-rb_reg_preprocess_m(VALUE klass, VALUE obj)
-{
- rb_encoding *fixed_enc = 0;
- onig_errmsg_buffer err;
- VALUE str = rb_reg_preprocess_obj(obj, &fixed_enc, err);
- if (str == Qnil)
- rb_raise(rb_eArgError, "%s", err);
- return rb_assoc_new(str, fixed_enc ? Qtrue : Qfalse);
-}
-#endif
-
-static int
-rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
- int options, onig_errmsg_buffer err)
+static void
+rb_reg_initialize(obj, s, len, options)
+ VALUE obj;
+ const char *s;
+ long len;
+ int options; /* CASEFOLD = 1 */
+ /* EXTENDED = 2 */
+ /* MULTILINE = 4 */
+ /* CODE_NONE = 16 */
+ /* CODE_EUC = 32 */
+ /* CODE_SJIS = 48 */
+ /* CODE_UTF8 = 64 */
{
struct RRegexp *re = RREGEXP(obj);
- VALUE unescaped;
- rb_encoding *fixed_enc = 0;
- rb_encoding *a_enc = rb_ascii8bit_encoding();
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
rb_check_frozen(obj);
if (FL_TEST(obj, REG_LITERAL))
rb_raise(rb_eSecurityError, "can't modify literal regexp");
- if (re->ptr) onig_free(re->ptr);
+ if (re->ptr) re_free_pattern(re->ptr);
if (re->str) free(re->str);
re->ptr = 0;
re->str = 0;
- unescaped = rb_reg_preprocess(s, s+len, enc, &fixed_enc, err);
- if (unescaped == Qnil)
- return -1;
-
- if (fixed_enc) {
- if ((fixed_enc != enc && (options & ARG_ENCODING_FIXED)) ||
- (fixed_enc != a_enc && (options & ARG_ENCODING_NONE))) {
- strcpy(err, "incompatible character encoding");
- return -1;
- }
- if (fixed_enc != a_enc) {
- options |= ARG_ENCODING_FIXED;
- enc = fixed_enc;
- }
- }
- else if (!(options & ARG_ENCODING_FIXED)) {
- enc = a_enc;
+ switch (options & ~0xf) {
+ case 0:
+ default:
+ FL_SET(re, reg_kcode);
+ break;
+ case 16:
+ kcode_none(re);
+ break;
+ case 32:
+ kcode_euc(re);
+ break;
+ case 48:
+ kcode_sjis(re);
+ break;
+ case 64:
+ kcode_utf8(re);
+ break;
}
- rb_enc_associate((VALUE)re, enc);
- if ((options & ARG_ENCODING_FIXED) || fixed_enc) {
- re->basic.flags |= KCODE_FIXED;
+ if (options & ~0xf) {
+ rb_kcode_set_option((VALUE)re);
}
- if (options & ARG_ENCODING_NONE) {
- re->basic.flags |= REG_ENCODING_NONE;
+ if (ruby_ignorecase) {
+ options |= RE_OPTION_IGNORECASE;
+ FL_SET(re, REG_CASESTATE);
}
-
- re->ptr = make_regexp(RSTRING_PTR(unescaped), RSTRING_LEN(unescaped), enc,
- options & ARG_REG_OPTION_MASK, err);
- if (!re->ptr) return -1;
+ re->ptr = make_regexp(s, len, options & 0xf);
re->str = ALLOC_N(char, len+1);
memcpy(re->str, s, len);
re->str[len] = '\0';
re->len = len;
- RB_GC_GUARD(unescaped);
- return 0;
-}
-
-static int
-rb_reg_initialize_str(VALUE obj, VALUE str, int options, onig_errmsg_buffer err)
-{
- return rb_reg_initialize(obj, RSTRING_PTR(str), RSTRING_LEN(str), rb_enc_get(str),
- options, err);
+ if (options & ~0xf) {
+ rb_kcode_reset_option();
+ }
+ if (ruby_in_compile) FL_SET(obj, REG_LITERAL);
}
+static VALUE rb_reg_s_alloc _((VALUE));
static VALUE
-rb_reg_s_alloc(VALUE klass)
+rb_reg_s_alloc(klass)
+ VALUE klass;
{
NEWOBJ(re, struct RRegexp);
OBJSETUP(re, klass, T_REGEXP);
@@ -2038,45 +1449,47 @@ rb_reg_s_alloc(VALUE klass)
}
VALUE
-rb_reg_new(VALUE s, int options)
-{
- VALUE re = rb_reg_s_alloc(rb_cRegexp);
- onig_errmsg_buffer err;
-
- if (rb_reg_initialize_str(re, s, options, err) != 0) {
- rb_reg_raise_str(s, options, err);
- }
-
- return re;
-}
-
-VALUE
-rb_reg_compile(VALUE str, int options)
+rb_reg_new(s, len, options)
+ const char *s;
+ long len;
+ int options;
{
VALUE re = rb_reg_s_alloc(rb_cRegexp);
- onig_errmsg_buffer err;
- if (!str) str = rb_str_new(0,0);
- if (rb_reg_initialize_str(re, str, options, err) != 0) {
- rb_set_errinfo(rb_reg_error_desc(str, options, err));
- return Qnil;
- }
- FL_SET(re, REG_LITERAL);
- return re;
+ rb_reg_initialize(re, s, len, options);
+ return (VALUE)re;
}
+static int case_cache;
+static int kcode_cache;
static VALUE reg_cache;
VALUE
-rb_reg_regcomp(VALUE str)
+rb_reg_regcomp(str)
+ VALUE str;
{
volatile VALUE save_str = str;
- if (reg_cache && RREGEXP(reg_cache)->len == RSTRING_LEN(str)
- && ENCODING_GET(reg_cache) == ENCODING_GET(str)
- && memcmp(RREGEXP(reg_cache)->str, RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
+ if (reg_cache && RREGEXP(reg_cache)->len == RSTRING(str)->len
+ && case_cache == ruby_ignorecase
+ && kcode_cache == reg_kcode
+ && memcmp(RREGEXP(reg_cache)->str, RSTRING(str)->ptr, RSTRING(str)->len) == 0)
return reg_cache;
- return reg_cache = rb_reg_new(save_str, 0);
+ case_cache = ruby_ignorecase;
+ kcode_cache = reg_kcode;
+ reg_cache = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, ruby_ignorecase);
+ RB_GC_GUARD(save_str);
+ return reg_cache;
+}
+
+static int
+rb_reg_cur_kcode(re)
+ VALUE re;
+{
+ if (FL_TEST(re, KCODE_FIXED)) {
+ return RBASIC(re)->flags & KCODE_MASK;
+ }
+ return 0;
}
/*
@@ -2087,7 +1500,8 @@ rb_reg_regcomp(VALUE str)
*/
static VALUE
-rb_reg_hash(VALUE re)
+rb_reg_hash(re)
+ VALUE re;
{
int hashval, len;
char *p;
@@ -2100,7 +1514,7 @@ rb_reg_hash(VALUE re)
hashval = hashval * 33 + *p++;
}
hashval = hashval + (hashval>>5);
-
+
return INT2FIX(hashval);
}
@@ -2109,150 +1523,95 @@ rb_reg_hash(VALUE re)
* call-seq:
* rxp == other_rxp => true or false
* rxp.eql?(other_rxp) => true or false
- *
+ *
* Equality---Two regexps are equal if their patterns are identical, they have
* the same character set code, and their <code>casefold?</code> values are the
* same.
- *
+ *
* /abc/ == /abc/x #=> false
* /abc/ == /abc/i #=> false
- * /abc/ == /abc/n #=> false
* /abc/u == /abc/n #=> false
*/
static VALUE
-rb_reg_equal(VALUE re1, VALUE re2)
+rb_reg_equal(re1, re2)
+ VALUE re1, re2;
{
if (re1 == re2) return Qtrue;
if (TYPE(re2) != T_REGEXP) return Qfalse;
rb_reg_check(re1); rb_reg_check(re2);
- if (FL_TEST(re1, KCODE_FIXED) != FL_TEST(re2, KCODE_FIXED)) return Qfalse;
- if (RREGEXP(re1)->ptr->options != RREGEXP(re2)->ptr->options) return Qfalse;
if (RREGEXP(re1)->len != RREGEXP(re2)->len) return Qfalse;
- if (ENCODING_GET(re1) != ENCODING_GET(re2)) return Qfalse;
- if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, RREGEXP(re1)->len) == 0) {
+ if (memcmp(RREGEXP(re1)->str, RREGEXP(re2)->str, RREGEXP(re1)->len) == 0 &&
+ rb_reg_cur_kcode(re1) == rb_reg_cur_kcode(re2) &&
+ RREGEXP(re1)->ptr->options == RREGEXP(re2)->ptr->options) {
return Qtrue;
}
return Qfalse;
}
-static VALUE
-reg_operand(VALUE s, int check)
-{
- if (SYMBOL_P(s)) {
- return rb_sym_to_s(s);
- }
- else {
- VALUE tmp = rb_check_string_type(s);
- if (check && NIL_P(tmp)) {
- rb_raise(rb_eTypeError, "can't convert %s to String",
- rb_obj_classname(s));
- }
- return tmp;
- }
-}
-static long
-reg_match_pos(VALUE re, VALUE *strp, long pos)
+/*
+ * call-seq:
+ * rxp.match(str) => matchdata or nil
+ *
+ * Returns a <code>MatchData</code> object describing the match, or
+ * <code>nil</code> if there was no match. This is equivalent to retrieving the
+ * value of the special variable <code>$~</code> following a normal match.
+ *
+ * /(.)(.)(.)/.match("abc")[2] #=> "b"
+ */
+
+VALUE
+rb_reg_match(re, str)
+ VALUE re, str;
{
- VALUE str = *strp;
+ long start;
if (NIL_P(str)) {
rb_backref_set(Qnil);
- return -1;
+ return Qnil;
}
- *strp = str = reg_operand(str, Qtrue);
- if (pos != 0) {
- if (pos < 0) {
- VALUE l = rb_str_length(str);
- pos += NUM2INT(l);
- if (pos < 0) {
- return pos;
- }
- }
- pos = rb_reg_adjust_startpos(re, str, pos, 0);
+ StringValue(str);
+ start = rb_reg_search(re, str, 0, 0);
+ if (start < 0) {
+ return Qnil;
}
- return rb_reg_search(re, str, pos, 0);
+ return LONG2FIX(start);
}
-/*
- * call-seq:
- * rxp =~ str => integer or nil
- *
- * Match---Matches <i>rxp</i> against <i>str</i>.
- *
- * /at/ =~ "input data" #=> 7
- * /ax/ =~ "input data" #=> nil
- *
- * If <code>=~</code> is used with a regexp literal with named captures,
- * captured strings (or nil) is assigned to local variables named by
- * the capture names.
- *
- * /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = y "
- * p lhs #=> "x"
- * p rhs #=> "y"
- *
- * If it is not matched, nil is assigned for the variables.
- *
- * /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = "
- * p lhs #=> nil
- * p rhs #=> nil
- *
- * This assignment is implemented in the Ruby parser.
- * So a regexp literal is required for the assignment.
- * The assignment is not occur if the regexp is not a literal.
- *
- * re = /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/
- * re =~ " x = "
- * p lhs # undefined local variable
- * p rhs # undefined local variable
- *
- * A regexp interpolation, <code>#{}</code>, also disables
- * the assignment.
- *
- * rhs_pat = /(?<rhs>\w+)/
- * /(?<lhs>\w+)\s*=\s*#{rhs_pat}/ =~ "x = y"
- * p lhs # undefined local variable
- *
- */
-
-VALUE
-rb_reg_match(VALUE re, VALUE str)
-{
- long pos = reg_match_pos(re, &str, 0);
- if (pos < 0) return Qnil;
- pos = rb_str_sublen(str, pos);
- return LONG2FIX(pos);
-}
/*
* call-seq:
* rxp === str => true or false
- *
+ *
* Case Equality---Synonym for <code>Regexp#=~</code> used in case statements.
- *
+ *
* a = "HELLO"
* case a
* when /^[a-z]*$/; print "Lower case\n"
* when /^[A-Z]*$/; print "Upper case\n"
* else; print "Mixed case\n"
* end
- *
+ *
* <em>produces:</em>
- *
+ *
* Upper case
*/
VALUE
-rb_reg_eqq(VALUE re, VALUE str)
+rb_reg_eqq(re, str)
+ VALUE re, str;
{
long start;
- str = reg_operand(str, Qfalse);
- if (NIL_P(str)) {
- rb_backref_set(Qnil);
- return Qfalse;
+ if (TYPE(str) != T_STRING) {
+ str = rb_check_string_type(str);
+ if (NIL_P(str)) {
+ rb_backref_set(Qnil);
+ return Qfalse;
+ }
}
+ StringValue(str);
start = rb_reg_search(re, str, 0, 0);
if (start < 0) {
return Qfalse;
@@ -2264,16 +1623,17 @@ rb_reg_eqq(VALUE re, VALUE str)
/*
* call-seq:
* ~ rxp => integer or nil
- *
+ *
* Match---Matches <i>rxp</i> against the contents of <code>$_</code>.
* Equivalent to <code><i>rxp</i> =~ $_</code>.
- *
+ *
* $_ = "input data"
* ~ /at/ #=> 7
*/
VALUE
-rb_reg_match2(VALUE re)
+rb_reg_match2(re)
+ VALUE re;
{
long start;
VALUE line = rb_lastline_get();
@@ -2287,62 +1647,30 @@ rb_reg_match2(VALUE re)
if (start < 0) {
return Qnil;
}
- start = rb_str_sublen(line, start);
return LONG2FIX(start);
}
/*
* call-seq:
- * rxp.match(str) => matchdata or nil
- * rxp.match(str,pos) => matchdata or nil
- *
+ * rxp.match(str) => matchdata or nil
+ *
* Returns a <code>MatchData</code> object describing the match, or
* <code>nil</code> if there was no match. This is equivalent to retrieving the
* value of the special variable <code>$~</code> following a normal match.
- * If the second parameter is present, it specifies the position in the string
- * to begin the search.
- *
- * /(.)(.)(.)/.match("abc")[2] #=> "b"
- * /(.)(.)/.match("abc", 1)[2] #=> "c"
*
- * If a block is given, invoke the block with MatchData if match succeed, so
- * that you can write
- *
- * pat.match(str) {|m| ...}
- *
- * instead of
- *
- * if m = pat.match(str)
- * ...
- * end
- *
- * The retuen value is a value from block exection in this case.
+ * /(.)(.)(.)/.match("abc")[2] #=> "b"
*/
static VALUE
-rb_reg_match_m(int argc, VALUE *argv, VALUE re)
+rb_reg_match_m(re, str)
+ VALUE re, str;
{
- VALUE result, str, initpos;
- long pos;
-
- if (rb_scan_args(argc, argv, "11", &str, &initpos) == 2) {
- pos = NUM2LONG(initpos);
- }
- else {
- pos = 0;
- }
+ VALUE result = rb_reg_match(re, str);
- pos = reg_match_pos(re, &str, pos);
- if (pos < 0) {
- rb_backref_set(Qnil);
- return Qnil;
- }
+ if (NIL_P(result)) return Qnil;
result = rb_backref_get();
rb_match_busy(result);
- if (!NIL_P(result) && rb_block_given_p()) {
- return rb_yield(result);
- }
return result;
}
@@ -2352,14 +1680,13 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
* Synonym for <code>Regexp.new</code>
*/
-
/*
* call-seq:
- * Regexp.new(string [, options]) => regexp
+ * Regexp.new(string [, options [, lang]]) => regexp
* Regexp.new(regexp) => regexp
- * Regexp.compile(string [, options]) => regexp
+ * Regexp.compile(string [, options [, lang]]) => regexp
* Regexp.compile(regexp) => regexp
- *
+ *
* Constructs a new regular expression from <i>pattern</i>, which can be either
* a <code>String</code> or a <code>Regexp</code> (in which case that regexp's
* options are propagated, and new options may not be specified (a change as of
@@ -2367,8 +1694,10 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
* more of the constants <code>Regexp::EXTENDED</code>,
* <code>Regexp::IGNORECASE</code>, and <code>Regexp::MULTILINE</code>,
* <em>or</em>-ed together. Otherwise, if <i>options</i> is not
- * <code>nil</code>, the regexp will be case insensitive.
- *
+ * <code>nil</code>, the regexp will be case insensitive. The <i>lang</i>
+ * parameter enables multibyte support for the regexp: `n', `N' = none, `e',
+ * `E' = EUC, `s', `S' = SJIS, `u', `U' = UTF-8.
+ *
* r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/
* r2 = Regexp.new('cat', true) #=> /cat/i
* r3 = Regexp.new('dog', Regexp::EXTENDED) #=> /dog/x
@@ -2376,76 +1705,96 @@ rb_reg_match_m(int argc, VALUE *argv, VALUE re)
*/
static VALUE
-rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
+rb_reg_initialize_m(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- onig_errmsg_buffer err;
- int flags = 0;
- VALUE str;
- rb_encoding *enc;
- const char *ptr;
+ const char *s;
long len;
+ int flags = 0;
if (argc == 0 || argc > 3) {
rb_raise(rb_eArgError, "wrong number of arguments");
}
if (TYPE(argv[0]) == T_REGEXP) {
- VALUE re = argv[0];
-
if (argc > 1) {
- rb_warn("flags ignored");
+ rb_warn("flags%s ignored", (argc == 3) ? " and encoding": "");
}
- rb_reg_check(re);
- flags = rb_reg_options(re);
- ptr = RREGEXP(re)->str;
- len = RREGEXP(re)->len;
- enc = rb_enc_get(re);
- if (rb_reg_initialize(self, ptr, len, enc, flags, err)) {
- str = rb_enc_str_new(ptr, len, enc);
- rb_reg_raise_str(str, flags, err);
+ rb_reg_check(argv[0]);
+ flags = RREGEXP(argv[0])->ptr->options & 0xf;
+ if (FL_TEST(argv[0], KCODE_FIXED)) {
+ switch (RBASIC(argv[0])->flags & KCODE_MASK) {
+ case KCODE_NONE:
+ flags |= 16;
+ break;
+ case KCODE_EUC:
+ flags |= 32;
+ break;
+ case KCODE_SJIS:
+ flags |= 48;
+ break;
+ case KCODE_UTF8:
+ flags |= 64;
+ break;
+ default:
+ break;
+ }
}
+ s = RREGEXP(argv[0])->str;
+ len = RREGEXP(argv[0])->len;
}
else {
if (argc >= 2) {
if (FIXNUM_P(argv[1])) flags = FIX2INT(argv[1]);
- else if (RTEST(argv[1])) flags = ONIG_OPTION_IGNORECASE;
+ else if (RTEST(argv[1])) flags = RE_OPTION_IGNORECASE;
}
- enc = 0;
if (argc == 3 && !NIL_P(argv[2])) {
char *kcode = StringValuePtr(argv[2]);
- if (kcode[0] == 'n' || kcode[1] == 'N') {
- enc = rb_enc_from_index(0);
- flags |= ARG_ENCODING_FIXED;
- }
- else {
- rb_warning("encoding option is obsolete - %s", kcode);
+
+ flags &= ~0x70;
+ switch (kcode[0]) {
+ case 'n': case 'N':
+ flags |= 16;
+ break;
+ case 'e': case 'E':
+ flags |= 32;
+ break;
+ case 's': case 'S':
+ flags |= 48;
+ break;
+ case 'u': case 'U':
+ flags |= 64;
+ break;
+ default:
+ break;
}
}
- str = argv[0];
- ptr = StringValuePtr(str);
- if (enc
- ? rb_reg_initialize(self, ptr, RSTRING_LEN(str), enc, flags, err)
- : rb_reg_initialize_str(self, str, flags, err)) {
- rb_reg_raise_str(str, flags, err);
- }
+ s = StringValuePtr(argv[0]);
+ len = RSTRING(argv[0])->len;
}
+ rb_reg_initialize(self, s, len, flags);
return self;
}
VALUE
-rb_reg_quote(VALUE str)
+rb_reg_quote(str)
+ VALUE str;
{
- rb_encoding *enc = rb_enc_get(str);
char *s, *send, *t;
VALUE tmp;
- int c, clen;
- int ascii_only = rb_enc_str_asciionly_p(str);
-
- s = RSTRING_PTR(str);
- send = s + RSTRING_LEN(str);
- while (s < send) {
- c = rb_enc_ascget(s, send, &clen, enc);
- if (c == -1) {
- s += mbclen(s, send, enc);
+ int c;
+
+ s = RSTRING(str)->ptr;
+ send = s + RSTRING(str)->len;
+ for (; s < send; s++) {
+ c = *s;
+ if (ismbchar(c)) {
+ int n = mbclen(c);
+
+ while (n-- && s < send)
+ s++;
+ s--;
continue;
}
switch (c) {
@@ -2454,37 +1803,29 @@ rb_reg_quote(VALUE str)
case '*': case '.': case '\\':
case '?': case '+': case '^': case '$':
case ' ': case '#':
- case '\t': case '\f': case '\v': case '\n': case '\r':
+ case '\t': case '\f': case '\n': case '\r':
goto meta_found;
}
- s += clen;
}
- if (ascii_only && rb_enc_get_index(str) != 0) {
- str = rb_str_new3(str);
- rb_enc_associate(str, rb_enc_from_index(0));
- }
- return str;
+ return rb_str_new3(str);
meta_found:
- tmp = rb_str_new(0, RSTRING_LEN(str)*2);
- if (!ascii_only) {
- rb_enc_copy(tmp, str);
- }
- t = RSTRING_PTR(tmp);
+ tmp = rb_str_new(0, RSTRING(str)->len*2);
+ t = RSTRING(tmp)->ptr;
/* copy upto metacharacter */
- memcpy(t, RSTRING_PTR(str), s - RSTRING_PTR(str));
- t += s - RSTRING_PTR(str);
+ memcpy(t, RSTRING(str)->ptr, s - RSTRING(str)->ptr);
+ t += s - RSTRING(str)->ptr;
- while (s < send) {
- c = rb_enc_ascget(s, send, &clen, enc);
- if (c == -1) {
- int n = mbclen(s, send, enc);
+ for (; s < send; s++) {
+ c = *s;
+ if (ismbchar(c)) {
+ int n = mbclen(c);
- while (n--)
+ while (n-- && s < send)
*t++ = *s++;
+ s--;
continue;
}
- s += clen;
switch (c) {
case '[': case ']': case '{': case '}':
case '(': case ')': case '|': case '-':
@@ -2513,14 +1854,10 @@ rb_reg_quote(VALUE str)
*t++ = '\\';
*t++ = 'f';
continue;
- case '\v':
- *t++ = '\\';
- *t++ = 'v';
- continue;
}
*t++ = c;
}
- rb_str_resize(tmp, t - RSTRING_PTR(tmp));
+ rb_str_resize(tmp, t - RSTRING(tmp)->ptr);
OBJ_INFECT(tmp, str);
return tmp;
}
@@ -2528,162 +1865,160 @@ rb_reg_quote(VALUE str)
/*
* call-seq:
- * Regexp.escape(str) => string
- * Regexp.quote(str) => string
- *
+ * Regexp.escape(str) => a_str
+ * Regexp.quote(str) => a_str
+ *
* Escapes any characters that would have special meaning in a regular
* expression. Returns a new escaped string, or self if no characters are
* escaped. For any string,
- * <code>Regexp.new(Regexp.escape(<i>str</i>))=~<i>str</i></code> will be true.
- *
- * Regexp.escape('\*?{}.') #=> \\\*\?\{\}\.
- *
+ * <code>Regexp.escape(<i>str</i>)=~<i>str</i></code> will be true.
+ *
+ * Regexp.escape('\\*?{}.') #=> \\\\\*\?\{\}\.
*/
static VALUE
-rb_reg_s_quote(VALUE c, VALUE str)
+rb_reg_s_quote(argc, argv)
+ int argc;
+ VALUE *argv;
{
- return rb_reg_quote(reg_operand(str, Qtrue));
+ VALUE str, kcode;
+ int kcode_saved = reg_kcode;
+
+ rb_scan_args(argc, argv, "11", &str, &kcode);
+ if (!NIL_P(kcode)) {
+ rb_set_kcode(StringValuePtr(kcode));
+ curr_kcode = reg_kcode;
+ reg_kcode = kcode_saved;
+ }
+ StringValue(str);
+ str = rb_reg_quote(str);
+ rb_kcode_reset_option();
+ return str;
}
int
-rb_reg_options(VALUE re)
+rb_kcode()
{
- int options;
-
- rb_reg_check(re);
- options = RREGEXP(re)->ptr->options & ARG_REG_OPTION_MASK;
- if (RBASIC(re)->flags & KCODE_FIXED) options |= ARG_ENCODING_FIXED;
- if (RBASIC(re)->flags & REG_ENCODING_NONE) options |= ARG_ENCODING_NONE;
- return options;
+ switch (reg_kcode) {
+ case KCODE_EUC:
+ return MBCTYPE_EUC;
+ case KCODE_SJIS:
+ return MBCTYPE_SJIS;
+ case KCODE_UTF8:
+ return MBCTYPE_UTF8;
+ case KCODE_NONE:
+ return MBCTYPE_ASCII;
+ }
+ rb_bug("wrong reg_kcode value (0x%x)", reg_kcode);
}
-VALUE
-rb_check_regexp_type(VALUE re)
-{
- return rb_check_convert_type(re, T_REGEXP, "Regexp", "to_regexp");
+static int
+rb_reg_get_kcode(re)
+ VALUE re;
+{
+ switch (RBASIC(re)->flags & KCODE_MASK) {
+ case KCODE_NONE:
+ return 16;
+ case KCODE_EUC:
+ return 32;
+ case KCODE_SJIS:
+ return 48;
+ case KCODE_UTF8:
+ return 64;
+ default:
+ return 0;
+ }
}
-/*
- * call-seq:
- * Regexp.try_convert(obj) -> re or nil
- *
- * Try to convert <i>obj</i> into a Regexp, using to_regexp method.
- * Returns converted regexp or nil if <i>obj</i> cannot be converted
- * for any reason.
- *
- * Regexp.try_convert(/re/) #=> /re/
- * Regexp.try_convert("re") #=> nil
- *
- * o = Object.new
- * Regexp.try_convert(o) #=> nil
- * def o.to_regexp() /foo/ end
- * Regexp.try_convert(o) #=> /foo/
- *
- */
-static VALUE
-rb_reg_s_try_convert(VALUE dummy, VALUE re)
+int
+rb_reg_options(re)
+ VALUE re;
{
- return rb_check_regexp_type(re);
+ int options;
+
+ rb_reg_check(re);
+ options = RREGEXP(re)->ptr->options &
+ (RE_OPTION_IGNORECASE|RE_OPTION_MULTILINE|RE_OPTION_EXTENDED);
+ if (FL_TEST(re, KCODE_FIXED)) {
+ options |= rb_reg_get_kcode(re);
+ }
+ return options;
}
static VALUE
-rb_reg_s_union(VALUE self, VALUE args0)
+rb_reg_s_union(self, args0)
+ VALUE self;
+ VALUE args0;
{
long argc = RARRAY_LEN(args0);
-
if (argc == 0) {
VALUE args[1];
args[0] = rb_str_new2("(?!)");
return rb_class_new_instance(1, args, rb_cRegexp);
}
else if (argc == 1) {
- VALUE arg = rb_ary_entry(args0, 0);
- VALUE re = rb_check_regexp_type(arg);
- if (!NIL_P(re))
- return re;
+ VALUE v;
+ v = rb_check_convert_type(rb_ary_entry(args0, 0), T_REGEXP, "Regexp", "to_regexp");
+ if (!NIL_P(v))
+ return v;
else {
- VALUE quoted;
- quoted = rb_reg_s_quote(Qnil, arg);
- return rb_reg_new(quoted, 0);
+ VALUE args[1];
+ args[0] = rb_reg_s_quote(RARRAY_LEN(args0), RARRAY_PTR(args0));
+ return rb_class_new_instance(1, args, rb_cRegexp);
}
}
else {
- int i;
- VALUE source = rb_str_buf_new(0);
- rb_encoding *result_enc;
-
- int has_asciionly = 0;
- rb_encoding *has_ascii_compat_fixed = 0;
- rb_encoding *has_ascii_incompat = 0;
-
- for (i = 0; i < argc; i++) {
- volatile VALUE v;
- VALUE e = rb_ary_entry(args0, i);
-
- if (0 < i)
- rb_str_buf_cat2(source, "|"); /* xxx: UTF-16 */
-
- v = rb_check_regexp_type(e);
- if (!NIL_P(v)) {
- rb_encoding *enc = rb_enc_get(v);
- if (!rb_enc_asciicompat(enc)) {
- if (!has_ascii_incompat)
- has_ascii_incompat = enc;
- else if (has_ascii_incompat != enc)
- rb_raise(rb_eArgError, "regexp encodings differ");
- }
- else if (rb_reg_fixed_encoding_p(v)) {
- if (!has_ascii_compat_fixed)
- has_ascii_compat_fixed = enc;
- else if (has_ascii_compat_fixed != enc)
- rb_raise(rb_eArgError, "regexp encodings differ");
- }
- else {
- has_asciionly = 1;
- }
- v = rb_reg_to_s(v);
- }
- else {
- rb_encoding *enc = rb_enc_get(e);
- StringValue(e);
- enc = rb_enc_get(e);
- if (!rb_enc_str_asciicompat_p(e)) {
- if (!has_ascii_incompat)
- has_ascii_incompat = enc;
- else if (has_ascii_incompat != enc)
- rb_raise(rb_eArgError, "regexp encodings differ");
- }
- else if (rb_enc_str_asciionly_p(e)) {
- has_asciionly = 1;
- }
- else {
- if (!has_ascii_compat_fixed)
- has_ascii_compat_fixed = enc;
- else if (has_ascii_compat_fixed != enc)
- rb_raise(rb_eArgError, "regexp encodings differ");
+ int i, kcode = -1;
+ VALUE kcode_re = Qnil;
+ VALUE source = rb_str_buf_new(0);
+ VALUE args[3];
+ for (i = 0; i < argc; i++) {
+ volatile VALUE v;
+ if (0 < i)
+ rb_str_buf_cat2(source, "|");
+ v = rb_check_convert_type(rb_ary_entry(args0, i), T_REGEXP, "Regexp", "to_regexp");
+ if (!NIL_P(v)) {
+ if (FL_TEST(v, KCODE_FIXED)) {
+ if (kcode == -1) {
+ kcode_re = v;
+ kcode = RBASIC(v)->flags & KCODE_MASK;
+ }
+ else if ((RBASIC(v)->flags & KCODE_MASK) != kcode) {
+ volatile VALUE str1, str2;
+ str1 = rb_inspect(kcode_re);
+ str2 = rb_inspect(v);
+ rb_raise(rb_eArgError, "mixed kcode: %s and %s",
+ RSTRING(str1)->ptr, RSTRING(str2)->ptr);
+ }
}
- v = rb_reg_s_quote(Qnil, e);
- }
- if (has_ascii_incompat && (has_asciionly || has_ascii_compat_fixed)) {
- rb_raise(rb_eArgError, "regexp encodings differ");
+ v = rb_reg_to_s(v);
}
-
- rb_str_append(source, v);
- }
-
- if (has_ascii_incompat) {
- result_enc = has_ascii_incompat;
- }
- else if (has_ascii_compat_fixed) {
- result_enc = has_ascii_compat_fixed;
+ else {
+ args[0] = rb_ary_entry(args0, i);
+ v = rb_reg_s_quote(1, args);
+ }
+ rb_str_buf_append(source, v);
}
- else {
- result_enc = rb_enc_from_index(0);
+ args[0] = source;
+ args[1] = Qnil;
+ switch (kcode) {
+ case -1:
+ args[2] = Qnil;
+ break;
+ case KCODE_NONE:
+ args[2] = rb_str_new2("n");
+ break;
+ case KCODE_EUC:
+ args[2] = rb_str_new2("e");
+ break;
+ case KCODE_SJIS:
+ args[2] = rb_str_new2("s");
+ break;
+ case KCODE_UTF8:
+ args[2] = rb_str_new2("u");
+ break;
}
-
- rb_enc_associate(source, result_enc);
- return rb_class_new_instance(1, &source, rb_cRegexp);
+ return rb_class_new_instance(3, args, rb_cRegexp);
}
}
@@ -2691,12 +2026,12 @@ rb_reg_s_union(VALUE self, VALUE args0)
* call-seq:
* Regexp.union(pat1, pat2, ...) => new_regexp
* Regexp.union(pats_ary) => new_regexp
- *
+ *
* Return a <code>Regexp</code> object that is the union of the given
* <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
* can be Regexp objects, in which case their options will be preserved, or
* Strings. If no patterns are given, returns <code>/(?!)/</code>.
- *
+ *
* Regexp.union #=> /(?!)/
* Regexp.union("penzance") #=> /penzance/
* Regexp.union("a+b*c") #=> /a\+b\*c/
@@ -2717,12 +2052,9 @@ rb_reg_s_union_m(VALUE self, VALUE args)
/* :nodoc: */
static VALUE
-rb_reg_init_copy(VALUE copy, VALUE re)
+rb_reg_init_copy(copy, re)
+ VALUE copy, re;
{
- onig_errmsg_buffer err;
- const char *s;
- long len;
-
if (copy == re) return copy;
rb_check_frozen(copy);
/* need better argument type check */
@@ -2730,97 +2062,58 @@ rb_reg_init_copy(VALUE copy, VALUE re)
rb_raise(rb_eTypeError, "wrong argument type");
}
rb_reg_check(re);
- s = RREGEXP(re)->str;
- len = RREGEXP(re)->len;
- if (rb_reg_initialize(copy, s, len, rb_enc_get(re), rb_reg_options(re), err) != 0) {
- rb_reg_raise(s, len, err, re);
- }
+ rb_reg_initialize(copy, RREGEXP(re)->str, RREGEXP(re)->len,
+ rb_reg_options(re));
return copy;
}
VALUE
-rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
+rb_reg_regsub(str, src, regs)
+ VALUE str, src;
+ struct re_registers *regs;
{
VALUE val = 0;
- char *p, *s, *e;
- int no, clen;
- rb_encoding *enc = rb_enc_check(str, src);
+ char *p, *s, *e, c;
+ int no;
- p = s = RSTRING_PTR(str);
- e = s + RSTRING_LEN(str);
+ p = s = RSTRING(str)->ptr;
+ e = s + RSTRING(str)->len;
while (s < e) {
- int c = rb_enc_ascget(s, e, &clen, enc);
- char *ss;
+ char *ss = s;
- if (c == -1) {
- s += mbclen(s, e, enc);
+ c = *s++;
+ if (ismbchar(c)) {
+ s += mbclen(c) - 1;
continue;
}
- ss = s;
- s += clen;
-
if (c != '\\' || s == e) continue;
if (!val) {
val = rb_str_buf_new(ss-p);
+ rb_str_buf_cat(val, p, ss-p);
+ }
+ else {
+ rb_str_buf_cat(val, p, ss-p);
}
- rb_str_buf_cat(val, p, ss-p);
-
- c = rb_enc_ascget(s, e, &clen, enc);
- if (c == -1) {
- s += mbclen(s, e, enc);
- rb_str_buf_cat(val, ss, s-ss);
- continue;
- }
- s += clen;
+ c = *s++;
p = s;
switch (c) {
- case '1': case '2': case '3': case '4':
+ case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- if (onig_noname_group_capture_is_active(RREGEXP(regexp)->ptr)) {
- no = c - '0';
- }
- else {
- continue;
- }
+ no = c - '0';
break;
-
- case 'k':
- if (s < e && rb_enc_ascget(s, e, &clen, enc) == '<') {
- char *name, *name_end;
-
- name_end = name = s + clen;
- while (name_end < e) {
- c = rb_enc_ascget(name_end, e, &clen, enc);
- if (c == '>') break;
- name_end += c == -1 ? mbclen(name_end, e, enc) : clen;
- }
- if (name_end < e) {
- no = name_to_backref_number(regs, regexp, name, name_end);
- p = s = name_end + clen;
- break;
- }
- else {
- rb_raise(rb_eRuntimeError, "invalid group name reference format");
- }
- }
-
- rb_str_buf_cat(val, ss, s-ss);
- continue;
-
- case '0':
case '&':
no = 0;
break;
case '`':
- rb_str_buf_cat(val, RSTRING_PTR(src), BEG(0));
+ rb_str_buf_cat(val, RSTRING(src)->ptr, BEG(0));
continue;
case '\'':
- rb_str_buf_cat(val, RSTRING_PTR(src)+END(0), RSTRING_LEN(src)-END(0));
+ rb_str_buf_cat(val, RSTRING(src)->ptr+END(0), RSTRING(src)->len-END(0));
continue;
case '+':
@@ -2830,61 +2123,116 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
break;
case '\\':
- rb_str_buf_cat(val, s-clen, clen);
+ rb_str_buf_cat(val, s-1, 1);
continue;
default:
- rb_str_buf_cat(val, ss, s-ss);
+ rb_str_buf_cat(val, s-2, 2);
continue;
}
if (no >= 0) {
if (no >= regs->num_regs) continue;
if (BEG(no) == -1) continue;
- rb_str_buf_cat(val, RSTRING_PTR(src)+BEG(no), END(no)-BEG(no));
+ rb_str_buf_cat(val, RSTRING(src)->ptr+BEG(no), END(no)-BEG(no));
}
}
if (p < e) {
if (!val) {
val = rb_str_buf_new(e-p);
+ rb_str_buf_cat(val, p, e-p);
+ }
+ else {
+ rb_str_buf_cat(val, p, e-p);
}
- rb_str_buf_cat(val, p, e-p);
}
if (!val) return str;
- rb_enc_associate(val, enc);
return val;
}
+const char*
+rb_get_kcode()
+{
+ switch (reg_kcode) {
+ case KCODE_SJIS:
+ return "SJIS";
+ case KCODE_EUC:
+ return "EUC";
+ case KCODE_UTF8:
+ return "UTF8";
+ default:
+ return "NONE";
+ }
+}
+
static VALUE
-kcode_getter(void)
+kcode_getter()
{
- rb_warn("variable $KCODE is no longer effective");
- return Qnil;
+ return rb_str_new2(rb_get_kcode());
+}
+
+void
+rb_set_kcode(code)
+ const char *code;
+{
+ if (code == 0) goto set_no_conversion;
+
+ switch (code[0]) {
+ case 'E':
+ case 'e':
+ reg_kcode = KCODE_EUC;
+ re_mbcinit(MBCTYPE_EUC);
+ break;
+ case 'S':
+ case 's':
+ reg_kcode = KCODE_SJIS;
+ re_mbcinit(MBCTYPE_SJIS);
+ break;
+ case 'U':
+ case 'u':
+ reg_kcode = KCODE_UTF8;
+ re_mbcinit(MBCTYPE_UTF8);
+ break;
+ default:
+ case 'N':
+ case 'n':
+ case 'A':
+ case 'a':
+ set_no_conversion:
+ reg_kcode = KCODE_NONE;
+ re_mbcinit(MBCTYPE_ASCII);
+ break;
+ }
}
static void
-kcode_setter(VALUE val, ID id)
+kcode_setter(val)
+ VALUE val;
{
- rb_warn("variable $KCODE is no longer effective; ignored");
+ may_need_recompile = 1;
+ rb_set_kcode(StringValuePtr(val));
}
static VALUE
-ignorecase_getter(void)
+ignorecase_getter()
{
- rb_warn("variable $= is no longer effective");
- return Qfalse;
+ return ruby_ignorecase?Qtrue:Qfalse;
}
static void
-ignorecase_setter(VALUE val, ID id)
+ignorecase_setter(val, id)
+ VALUE val;
+ ID id;
{
- rb_warn("variable $= is no longer effective; ignored");
+ rb_warn("modifying %s is deprecated", rb_id2name(id));
+ may_need_recompile = 1;
+ ruby_ignorecase = RTEST(val);
}
static VALUE
-match_getter(void)
+match_getter()
{
VALUE match = rb_backref_get();
@@ -2894,7 +2242,8 @@ match_getter(void)
}
static void
-match_setter(VALUE val)
+match_setter(val)
+ VALUE val;
{
if (!NIL_P(val)) {
Check_Type(val, T_MATCH);
@@ -2905,37 +2254,29 @@ match_setter(VALUE val)
/*
* call-seq:
* Regexp.last_match => matchdata
- * Regexp.last_match(n) => str
- *
+ * Regexp.last_match(fixnum) => str
+ *
* The first form returns the <code>MatchData</code> object generated by the
* last successful pattern match. Equivalent to reading the global variable
- * <code>$~</code>. The second form returns the <i>n</i>th field in this
+ * <code>$~</code>. The second form returns the nth field in this
* <code>MatchData</code> object.
- * <em>n</em> can be a string or symbol to reference a named capture.
- *
- * /c(.)t/ =~ 'cat' #=> 0
- * Regexp.last_match #=> #<MatchData "cat" "a">
- * Regexp.last_match(0) #=> "cat"
- * Regexp.last_match(1) #=> "a"
- * Regexp.last_match(2) #=> nil
- *
- * /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ "var = val"
- * Regexp.last_match #=> #<MatchData "var = val" lhs:"var" rhs:"val">
- * Regexp.last_match(:lhs) #=> "var"
- * Regexp.last_match(:rhs) #=> "val"
+ *
+ * /c(.)t/ =~ 'cat' #=> 0
+ * Regexp.last_match #=> #<MatchData:0x401b3d30>
+ * Regexp.last_match(0) #=> "cat"
+ * Regexp.last_match(1) #=> "a"
+ * Regexp.last_match(2) #=> nil
*/
static VALUE
-rb_reg_s_last_match(int argc, VALUE *argv)
+rb_reg_s_last_match(argc, argv)
+ int argc;
+ VALUE *argv;
{
VALUE nth;
if (rb_scan_args(argc, argv, "01", &nth) == 1) {
- VALUE match = rb_backref_get();
- int n;
- if (NIL_P(match)) return Qnil;
- n = match_backref_number(match, nth);
- return rb_reg_nth_match(n, match);
+ return rb_reg_nth_match(NUM2INT(nth), rb_backref_get());
}
return match_getter();
}
@@ -2952,12 +2293,24 @@ rb_reg_s_last_match(int argc, VALUE *argv)
*/
void
-Init_Regexp(void)
+Init_Regexp()
{
rb_eRegexpError = rb_define_class("RegexpError", rb_eStandardError);
- onigenc_set_default_caseconv_table((UChar*)casetable);
- onigenc_set_default_encoding(ONIG_ENCODING_ASCII);
+ re_set_casetable(casetable);
+#if DEFAULT_KCODE == KCODE_EUC
+ re_mbcinit(MBCTYPE_EUC);
+#else
+#if DEFAULT_KCODE == KCODE_SJIS
+ re_mbcinit(MBCTYPE_SJIS);
+#else
+#if DEFAULT_KCODE == KCODE_UTF8
+ re_mbcinit(MBCTYPE_UTF8);
+#else
+ re_mbcinit(MBCTYPE_ASCII);
+#endif
+#endif
+#endif
rb_define_virtual_variable("$~", match_getter, match_setter);
rb_define_virtual_variable("$&", last_match_getter, 0);
@@ -2972,15 +2325,10 @@ Init_Regexp(void)
rb_cRegexp = rb_define_class("Regexp", rb_cObject);
rb_define_alloc_func(rb_cRegexp, rb_reg_s_alloc);
rb_define_singleton_method(rb_cRegexp, "compile", rb_class_new_instance, -1);
- rb_define_singleton_method(rb_cRegexp, "quote", rb_reg_s_quote, 1);
- rb_define_singleton_method(rb_cRegexp, "escape", rb_reg_s_quote, 1);
+ rb_define_singleton_method(rb_cRegexp, "quote", rb_reg_s_quote, -1);
+ rb_define_singleton_method(rb_cRegexp, "escape", rb_reg_s_quote, -1);
rb_define_singleton_method(rb_cRegexp, "union", rb_reg_s_union_m, -2);
rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, -1);
- rb_define_singleton_method(rb_cRegexp, "try_convert", rb_reg_s_try_convert, 1);
-
-#if 0
- rb_define_singleton_method(rb_cRegexp, "preprocess", rb_reg_preprocess_m, 1);
-#endif
rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1);
rb_define_method(rb_cRegexp, "initialize_copy", rb_reg_init_copy, 1);
@@ -2990,30 +2338,26 @@ Init_Regexp(void)
rb_define_method(rb_cRegexp, "=~", rb_reg_match, 1);
rb_define_method(rb_cRegexp, "===", rb_reg_eqq, 1);
rb_define_method(rb_cRegexp, "~", rb_reg_match2, 0);
- rb_define_method(rb_cRegexp, "match", rb_reg_match_m, -1);
+ rb_define_method(rb_cRegexp, "match", rb_reg_match_m, 1);
rb_define_method(rb_cRegexp, "to_s", rb_reg_to_s, 0);
rb_define_method(rb_cRegexp, "inspect", rb_reg_inspect, 0);
rb_define_method(rb_cRegexp, "source", rb_reg_source, 0);
rb_define_method(rb_cRegexp, "casefold?", rb_reg_casefold_p, 0);
rb_define_method(rb_cRegexp, "options", rb_reg_options_m, 0);
- rb_define_method(rb_cRegexp, "encoding", rb_obj_encoding, 0); /* in encoding.c */
- rb_define_method(rb_cRegexp, "fixed_encoding?", rb_reg_fixed_encoding_p, 0);
- rb_define_method(rb_cRegexp, "names", rb_reg_names, 0);
- rb_define_method(rb_cRegexp, "named_captures", rb_reg_named_captures, 0);
+ rb_define_method(rb_cRegexp, "kcode", rb_reg_kcode_m, 0);
- rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(ONIG_OPTION_IGNORECASE));
- rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(ONIG_OPTION_EXTEND));
- rb_define_const(rb_cRegexp, "MULTILINE", INT2FIX(ONIG_OPTION_MULTILINE));
+ rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(RE_OPTION_IGNORECASE));
+ rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(RE_OPTION_EXTENDED));
+ rb_define_const(rb_cRegexp, "MULTILINE", INT2FIX(RE_OPTION_MULTILINE));
rb_global_variable(&reg_cache);
rb_cMatch = rb_define_class("MatchData", rb_cObject);
+ rb_define_global_const("MatchingData", rb_cMatch);
rb_define_alloc_func(rb_cMatch, match_alloc);
rb_undef_method(CLASS_OF(rb_cMatch), "new");
rb_define_method(rb_cMatch, "initialize_copy", match_init_copy, 1);
- rb_define_method(rb_cMatch, "regexp", match_regexp, 0);
- rb_define_method(rb_cMatch, "names", match_names, 0);
rb_define_method(rb_cMatch, "size", match_size, 0);
rb_define_method(rb_cMatch, "length", match_size, 0);
rb_define_method(rb_cMatch, "offset", match_offset, 1);
@@ -3023,7 +2367,7 @@ Init_Regexp(void)
rb_define_method(rb_cMatch, "[]", match_aref, -1);
rb_define_method(rb_cMatch, "captures", match_captures, 0);
rb_define_method(rb_cMatch, "values_at", match_values_at, -1);
- rb_define_method(rb_cMatch, "select", match_values_at, -1);
+ rb_define_method(rb_cMatch, "select", match_select, -1);
rb_define_method(rb_cMatch, "pre_match", rb_reg_match_pre, 0);
rb_define_method(rb_cMatch, "post_match", rb_reg_match_post, 0);
rb_define_method(rb_cMatch, "to_s", match_to_s, 0);
diff --git a/re.h b/re.h
new file mode 100644
index 0000000000..45b2753dd5
--- /dev/null
+++ b/re.h
@@ -0,0 +1,42 @@
+/**********************************************************************
+
+ re.h -
+
+ $Author$
+ $Date$
+ created at: Thu Sep 30 14:18:32 JST 1993
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef RE_H
+#define RE_H
+
+#include <sys/types.h>
+#include <stdio.h>
+
+#include "regex.h"
+
+typedef struct re_pattern_buffer Regexp;
+
+struct RMatch {
+ struct RBasic basic;
+ VALUE str;
+ struct re_registers *regs;
+};
+
+#define RMATCH(obj) (R_CAST(RMatch)(obj))
+
+VALUE rb_reg_regcomp _((VALUE));
+long rb_reg_search _((VALUE, VALUE, long, long));
+VALUE rb_reg_regsub _((VALUE, VALUE, struct re_registers *));
+long rb_reg_adjust_startpos _((VALUE, VALUE, long, long));
+void rb_match_busy _((VALUE));
+VALUE rb_reg_quote _((VALUE));
+
+RUBY_EXTERN int ruby_ignorecase;
+
+int rb_reg_mbclen2 _((unsigned int, VALUE));
+#define mbclen2(c,re) rb_reg_mbclen2((c),(re))
+#endif
diff --git a/regcomp.c b/regcomp.c
deleted file mode 100644
index f3d604a21d..0000000000
--- a/regcomp.c
+++ /dev/null
@@ -1,6311 +0,0 @@
-/**********************************************************************
- regcomp.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regparse.h"
-
-OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN;
-
-extern OnigCaseFoldType
-onig_get_default_case_fold_flag(void)
-{
- return OnigDefaultCaseFoldFlag;
-}
-
-extern int
-onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag)
-{
- OnigDefaultCaseFoldFlag = case_fold_flag;
- return 0;
-}
-
-
-#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
-static unsigned char PadBuf[WORD_ALIGNMENT_SIZE];
-#endif
-
-static UChar*
-str_dup(UChar* s, UChar* end)
-{
- int len = end - s;
-
- if (len > 0) {
- UChar* r = (UChar* )xmalloc(len + 1);
- CHECK_NULL_RETURN(r);
- xmemcpy(r, s, len);
- r[len] = (UChar )0;
- return r;
- }
- else return NULL;
-}
-
-static void
-swap_node(Node* a, Node* b)
-{
- Node c;
- c = *a; *a = *b; *b = c;
-
- if (NTYPE(a) == NT_STR) {
- StrNode* sn = NSTR(a);
- if (sn->capa == 0) {
- int len = sn->end - sn->s;
- sn->s = sn->buf;
- sn->end = sn->s + len;
- }
- }
-
- if (NTYPE(b) == NT_STR) {
- StrNode* sn = NSTR(b);
- if (sn->capa == 0) {
- int len = sn->end - sn->s;
- sn->s = sn->buf;
- sn->end = sn->s + len;
- }
- }
-}
-
-static OnigDistance
-distance_add(OnigDistance d1, OnigDistance d2)
-{
- if (d1 == ONIG_INFINITE_DISTANCE || d2 == ONIG_INFINITE_DISTANCE)
- return ONIG_INFINITE_DISTANCE;
- else {
- if (d1 <= ONIG_INFINITE_DISTANCE - d2) return d1 + d2;
- else return ONIG_INFINITE_DISTANCE;
- }
-}
-
-static OnigDistance
-distance_multiply(OnigDistance d, int m)
-{
- if (m == 0) return 0;
-
- if (d < ONIG_INFINITE_DISTANCE / m)
- return d * m;
- else
- return ONIG_INFINITE_DISTANCE;
-}
-
-static int
-bitset_is_empty(BitSetRef bs)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) {
- if (bs[i] != 0) return 0;
- }
- return 1;
-}
-
-#ifdef ONIG_DEBUG
-static int
-bitset_on_num(BitSetRef bs)
-{
- int i, n;
-
- n = 0;
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- if (BITSET_AT(bs, i)) n++;
- }
- return n;
-}
-#endif
-
-extern int
-onig_bbuf_init(BBuf* buf, int size)
-{
- if (size <= 0) {
- size = 0;
- buf->p = NULL;
- }
- else {
- buf->p = (UChar* )xmalloc(size);
- if (IS_NULL(buf->p)) return(ONIGERR_MEMORY);
- }
-
- buf->alloc = size;
- buf->used = 0;
- return 0;
-}
-
-
-#ifdef USE_SUBEXP_CALL
-
-static int
-unset_addr_list_init(UnsetAddrList* uslist, int size)
-{
- UnsetAddr* p;
-
- p = (UnsetAddr* )xmalloc(sizeof(UnsetAddr)* size);
- CHECK_NULL_RETURN_MEMERR(p);
- uslist->num = 0;
- uslist->alloc = size;
- uslist->us = p;
- return 0;
-}
-
-static void
-unset_addr_list_end(UnsetAddrList* uslist)
-{
- if (IS_NOT_NULL(uslist->us))
- xfree(uslist->us);
-}
-
-static int
-unset_addr_list_add(UnsetAddrList* uslist, int offset, struct _Node* node)
-{
- UnsetAddr* p;
- int size;
-
- if (uslist->num >= uslist->alloc) {
- size = uslist->alloc * 2;
- p = (UnsetAddr* )xrealloc(uslist->us, sizeof(UnsetAddr) * size);
- CHECK_NULL_RETURN_MEMERR(p);
- uslist->alloc = size;
- uslist->us = p;
- }
-
- uslist->us[uslist->num].offset = offset;
- uslist->us[uslist->num].target = node;
- uslist->num++;
- return 0;
-}
-#endif /* USE_SUBEXP_CALL */
-
-
-static int
-add_opcode(regex_t* reg, int opcode)
-{
- BBUF_ADD1(reg, opcode);
- return 0;
-}
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
-static int
-add_state_check_num(regex_t* reg, int num)
-{
- StateCheckNumType n = (StateCheckNumType )num;
-
- BBUF_ADD(reg, &n, SIZE_STATE_CHECK_NUM);
- return 0;
-}
-#endif
-
-static int
-add_rel_addr(regex_t* reg, int addr)
-{
- RelAddrType ra = (RelAddrType )addr;
-
- BBUF_ADD(reg, &ra, SIZE_RELADDR);
- return 0;
-}
-
-static int
-add_abs_addr(regex_t* reg, int addr)
-{
- AbsAddrType ra = (AbsAddrType )addr;
-
- BBUF_ADD(reg, &ra, SIZE_ABSADDR);
- return 0;
-}
-
-static int
-add_length(regex_t* reg, int len)
-{
- LengthType l = (LengthType )len;
-
- BBUF_ADD(reg, &l, SIZE_LENGTH);
- return 0;
-}
-
-static int
-add_mem_num(regex_t* reg, int num)
-{
- MemNumType n = (MemNumType )num;
-
- BBUF_ADD(reg, &n, SIZE_MEMNUM);
- return 0;
-}
-
-static int
-add_pointer(regex_t* reg, void* addr)
-{
- PointerType ptr = (PointerType )addr;
-
- BBUF_ADD(reg, &ptr, SIZE_POINTER);
- return 0;
-}
-
-static int
-add_option(regex_t* reg, OnigOptionType option)
-{
- BBUF_ADD(reg, &option, SIZE_OPTION);
- return 0;
-}
-
-static int
-add_opcode_rel_addr(regex_t* reg, int opcode, int addr)
-{
- int r;
-
- r = add_opcode(reg, opcode);
- if (r) return r;
- r = add_rel_addr(reg, addr);
- return r;
-}
-
-static int
-add_bytes(regex_t* reg, UChar* bytes, int len)
-{
- BBUF_ADD(reg, bytes, len);
- return 0;
-}
-
-static int
-add_bitset(regex_t* reg, BitSetRef bs)
-{
- BBUF_ADD(reg, bs, SIZE_BITSET);
- return 0;
-}
-
-static int
-add_opcode_option(regex_t* reg, int opcode, OnigOptionType option)
-{
- int r;
-
- r = add_opcode(reg, opcode);
- if (r) return r;
- r = add_option(reg, option);
- return r;
-}
-
-static int compile_length_tree(Node* node, regex_t* reg);
-static int compile_tree(Node* node, regex_t* reg);
-
-
-#define IS_NEED_STR_LEN_OP_EXACT(op) \
- ((op) == OP_EXACTN || (op) == OP_EXACTMB2N ||\
- (op) == OP_EXACTMB3N || (op) == OP_EXACTMBN || (op) == OP_EXACTN_IC)
-
-static int
-select_str_opcode(int mb_len, int str_len, int ignore_case)
-{
- int op;
-
- if (ignore_case) {
- switch (str_len) {
- case 1: op = OP_EXACT1_IC; break;
- default: op = OP_EXACTN_IC; break;
- }
- }
- else {
- switch (mb_len) {
- case 1:
- switch (str_len) {
- case 1: op = OP_EXACT1; break;
- case 2: op = OP_EXACT2; break;
- case 3: op = OP_EXACT3; break;
- case 4: op = OP_EXACT4; break;
- case 5: op = OP_EXACT5; break;
- default: op = OP_EXACTN; break;
- }
- break;
-
- case 2:
- switch (str_len) {
- case 1: op = OP_EXACTMB2N1; break;
- case 2: op = OP_EXACTMB2N2; break;
- case 3: op = OP_EXACTMB2N3; break;
- default: op = OP_EXACTMB2N; break;
- }
- break;
-
- case 3:
- op = OP_EXACTMB3N;
- break;
-
- default:
- op = OP_EXACTMBN;
- break;
- }
- }
- return op;
-}
-
-static int
-compile_tree_empty_check(Node* node, regex_t* reg, int empty_info)
-{
- int r;
- int saved_num_null_check = reg->num_null_check;
-
- if (empty_info != 0) {
- r = add_opcode(reg, OP_NULL_CHECK_START);
- if (r) return r;
- r = add_mem_num(reg, reg->num_null_check); /* NULL CHECK ID */
- if (r) return r;
- reg->num_null_check++;
- }
-
- r = compile_tree(node, reg);
- if (r) return r;
-
- if (empty_info != 0) {
- if (empty_info == NQ_TARGET_IS_EMPTY)
- r = add_opcode(reg, OP_NULL_CHECK_END);
- else if (empty_info == NQ_TARGET_IS_EMPTY_MEM)
- r = add_opcode(reg, OP_NULL_CHECK_END_MEMST);
- else if (empty_info == NQ_TARGET_IS_EMPTY_REC)
- r = add_opcode(reg, OP_NULL_CHECK_END_MEMST_PUSH);
-
- if (r) return r;
- r = add_mem_num(reg, saved_num_null_check); /* NULL CHECK ID */
- }
- return r;
-}
-
-#ifdef USE_SUBEXP_CALL
-static int
-compile_call(CallNode* node, regex_t* reg)
-{
- int r;
-
- r = add_opcode(reg, OP_CALL);
- if (r) return r;
- r = unset_addr_list_add(node->unset_addr_list, BBUF_GET_OFFSET_POS(reg),
- node->target);
- if (r) return r;
- r = add_abs_addr(reg, 0 /*dummy addr.*/);
- return r;
-}
-#endif
-
-static int
-compile_tree_n_times(Node* node, int n, regex_t* reg)
-{
- int i, r;
-
- for (i = 0; i < n; i++) {
- r = compile_tree(node, reg);
- if (r) return r;
- }
- return 0;
-}
-
-static int
-add_compile_string_length(UChar* s, int mb_len, int str_len,
- regex_t* reg, int ignore_case)
-{
- int len;
- int op = select_str_opcode(mb_len, str_len, ignore_case);
-
- len = SIZE_OPCODE;
-
- if (op == OP_EXACTMBN) len += SIZE_LENGTH;
- if (IS_NEED_STR_LEN_OP_EXACT(op))
- len += SIZE_LENGTH;
-
- len += mb_len * str_len;
- return len;
-}
-
-static int
-add_compile_string(UChar* s, int mb_len, int str_len,
- regex_t* reg, int ignore_case)
-{
- int op = select_str_opcode(mb_len, str_len, ignore_case);
- add_opcode(reg, op);
-
- if (op == OP_EXACTMBN)
- add_length(reg, mb_len);
-
- if (IS_NEED_STR_LEN_OP_EXACT(op)) {
- if (op == OP_EXACTN_IC)
- add_length(reg, mb_len * str_len);
- else
- add_length(reg, str_len);
- }
-
- add_bytes(reg, s, mb_len * str_len);
- return 0;
-}
-
-
-static int
-compile_length_string_node(Node* node, regex_t* reg)
-{
- int rlen, r, len, prev_len, slen, ambig;
- OnigEncoding enc = reg->enc;
- UChar *p, *prev;
- StrNode* sn;
-
- sn = NSTR(node);
- if (sn->end <= sn->s)
- return 0;
-
- ambig = NSTRING_IS_AMBIG(node);
-
- p = prev = sn->s;
- prev_len = enc_len(enc, p, sn->end);
- p += prev_len;
- slen = 1;
- rlen = 0;
-
- for (; p < sn->end; ) {
- len = enc_len(enc, p, sn->end);
- if (len == prev_len) {
- slen++;
- }
- else {
- r = add_compile_string_length(prev, prev_len, slen, reg, ambig);
- rlen += r;
- prev = p;
- slen = 1;
- prev_len = len;
- }
- p += len;
- }
- r = add_compile_string_length(prev, prev_len, slen, reg, ambig);
- rlen += r;
- return rlen;
-}
-
-static int
-compile_length_string_raw_node(StrNode* sn, regex_t* reg)
-{
- if (sn->end <= sn->s)
- return 0;
-
- return add_compile_string_length(sn->s, 1 /* sb */, sn->end - sn->s, reg, 0);
-}
-
-static int
-compile_string_node(Node* node, regex_t* reg)
-{
- int r, len, prev_len, slen, ambig;
- OnigEncoding enc = reg->enc;
- UChar *p, *prev, *end;
- StrNode* sn;
-
- sn = NSTR(node);
- if (sn->end <= sn->s)
- return 0;
-
- end = sn->end;
- ambig = NSTRING_IS_AMBIG(node);
-
- p = prev = sn->s;
- prev_len = enc_len(enc, p, end);
- p += prev_len;
- slen = 1;
-
- for (; p < end; ) {
- len = enc_len(enc, p, end);
- if (len == prev_len) {
- slen++;
- }
- else {
- r = add_compile_string(prev, prev_len, slen, reg, ambig);
- if (r) return r;
-
- prev = p;
- slen = 1;
- prev_len = len;
- }
-
- p += len;
- }
- return add_compile_string(prev, prev_len, slen, reg, ambig);
-}
-
-static int
-compile_string_raw_node(StrNode* sn, regex_t* reg)
-{
- if (sn->end <= sn->s)
- return 0;
-
- return add_compile_string(sn->s, 1 /* sb */, sn->end - sn->s, reg, 0);
-}
-
-static int
-add_multi_byte_cclass(BBuf* mbuf, regex_t* reg)
-{
-#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
- add_length(reg, mbuf->used);
- return add_bytes(reg, mbuf->p, mbuf->used);
-#else
- int r, pad_size;
- UChar* p = BBUF_GET_ADD_ADDRESS(reg) + SIZE_LENGTH;
-
- GET_ALIGNMENT_PAD_SIZE(p, pad_size);
- add_length(reg, mbuf->used + (WORD_ALIGNMENT_SIZE - 1));
- if (pad_size != 0) add_bytes(reg, PadBuf, pad_size);
-
- r = add_bytes(reg, mbuf->p, mbuf->used);
-
- /* padding for return value from compile_length_cclass_node() to be fix. */
- pad_size = (WORD_ALIGNMENT_SIZE - 1) - pad_size;
- if (pad_size != 0) add_bytes(reg, PadBuf, pad_size);
- return r;
-#endif
-}
-
-static int
-compile_length_cclass_node(CClassNode* cc, regex_t* reg)
-{
- int len;
-
- if (IS_NCCLASS_SHARE(cc)) {
- len = SIZE_OPCODE + SIZE_POINTER;
- return len;
- }
-
- if (IS_NULL(cc->mbuf)) {
- len = SIZE_OPCODE + SIZE_BITSET;
- }
- else {
- if (ONIGENC_MBC_MINLEN(reg->enc) > 1 || bitset_is_empty(cc->bs)) {
- len = SIZE_OPCODE;
- }
- else {
- len = SIZE_OPCODE + SIZE_BITSET;
- }
-#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
- len += SIZE_LENGTH + cc->mbuf->used;
-#else
- len += SIZE_LENGTH + cc->mbuf->used + (WORD_ALIGNMENT_SIZE - 1);
-#endif
- }
-
- return len;
-}
-
-static int
-compile_cclass_node(CClassNode* cc, regex_t* reg)
-{
- int r;
-
- if (IS_NCCLASS_SHARE(cc)) {
- add_opcode(reg, OP_CCLASS_NODE);
- r = add_pointer(reg, cc);
- return r;
- }
-
- if (IS_NULL(cc->mbuf)) {
- if (IS_NCCLASS_NOT(cc))
- add_opcode(reg, OP_CCLASS_NOT);
- else
- add_opcode(reg, OP_CCLASS);
-
- r = add_bitset(reg, cc->bs);
- }
- else {
- if (ONIGENC_MBC_MINLEN(reg->enc) > 1 || bitset_is_empty(cc->bs)) {
- if (IS_NCCLASS_NOT(cc))
- add_opcode(reg, OP_CCLASS_MB_NOT);
- else
- add_opcode(reg, OP_CCLASS_MB);
-
- r = add_multi_byte_cclass(cc->mbuf, reg);
- }
- else {
- if (IS_NCCLASS_NOT(cc))
- add_opcode(reg, OP_CCLASS_MIX_NOT);
- else
- add_opcode(reg, OP_CCLASS_MIX);
-
- r = add_bitset(reg, cc->bs);
- if (r) return r;
- r = add_multi_byte_cclass(cc->mbuf, reg);
- }
- }
-
- return r;
-}
-
-static int
-entry_repeat_range(regex_t* reg, int id, int lower, int upper)
-{
-#define REPEAT_RANGE_ALLOC 4
-
- OnigRepeatRange* p;
-
- if (reg->repeat_range_alloc == 0) {
- p = (OnigRepeatRange* )xmalloc(sizeof(OnigRepeatRange) * REPEAT_RANGE_ALLOC);
- CHECK_NULL_RETURN_MEMERR(p);
- reg->repeat_range = p;
- reg->repeat_range_alloc = REPEAT_RANGE_ALLOC;
- }
- else if (reg->repeat_range_alloc <= id) {
- int n;
- n = reg->repeat_range_alloc + REPEAT_RANGE_ALLOC;
- p = (OnigRepeatRange* )xrealloc(reg->repeat_range,
- sizeof(OnigRepeatRange) * n);
- CHECK_NULL_RETURN_MEMERR(p);
- reg->repeat_range = p;
- reg->repeat_range_alloc = n;
- }
- else {
- p = reg->repeat_range;
- }
-
- p[id].lower = lower;
- p[id].upper = (IS_REPEAT_INFINITE(upper) ? 0x7fffffff : upper);
- return 0;
-}
-
-static int
-compile_range_repeat_node(QtfrNode* qn, int target_len, int empty_info,
- regex_t* reg)
-{
- int r;
- int num_repeat = reg->num_repeat;
-
- r = add_opcode(reg, qn->greedy ? OP_REPEAT : OP_REPEAT_NG);
- if (r) return r;
- r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */
- reg->num_repeat++;
- if (r) return r;
- r = add_rel_addr(reg, target_len + SIZE_OP_REPEAT_INC);
- if (r) return r;
-
- r = entry_repeat_range(reg, num_repeat, qn->lower, qn->upper);
- if (r) return r;
-
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
-
- if (
-#ifdef USE_SUBEXP_CALL
- reg->num_call > 0 ||
-#endif
- IS_QUANTIFIER_IN_REPEAT(qn)) {
- r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC_SG : OP_REPEAT_INC_NG_SG);
- }
- else {
- r = add_opcode(reg, qn->greedy ? OP_REPEAT_INC : OP_REPEAT_INC_NG);
- }
- if (r) return r;
- r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID */
- return r;
-}
-
-static int
-is_anychar_star_quantifier(QtfrNode* qn)
-{
- if (qn->greedy && IS_REPEAT_INFINITE(qn->upper) &&
- NTYPE(qn->target) == NT_CANY)
- return 1;
- else
- return 0;
-}
-
-#define QUANTIFIER_EXPAND_LIMIT_SIZE 50
-#define CKN_ON (ckn > 0)
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
-
-static int
-compile_length_quantifier_node(QtfrNode* qn, regex_t* reg)
-{
- int len, mod_tlen, cklen;
- int ckn;
- int infinite = IS_REPEAT_INFINITE(qn->upper);
- int empty_info = qn->target_empty_info;
- int tlen = compile_length_tree(qn->target, reg);
-
- if (tlen < 0) return tlen;
-
- ckn = ((reg->num_comb_exp_check > 0) ? qn->comb_exp_check_num : 0);
-
- cklen = (CKN_ON ? SIZE_STATE_CHECK_NUM: 0);
-
- /* anychar repeat */
- if (NTYPE(qn->target) == NT_CANY) {
- if (qn->greedy && infinite) {
- if (IS_NOT_NULL(qn->next_head_exact) && !CKN_ON)
- return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower + cklen;
- else
- return SIZE_OP_ANYCHAR_STAR + tlen * qn->lower + cklen;
- }
- }
-
- if (empty_info != 0)
- mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
- else
- mod_tlen = tlen;
-
- if (infinite && qn->lower <= 1) {
- if (qn->greedy) {
- if (qn->lower == 1)
- len = SIZE_OP_JUMP;
- else
- len = 0;
-
- len += SIZE_OP_PUSH + cklen + mod_tlen + SIZE_OP_JUMP;
- }
- else {
- if (qn->lower == 0)
- len = SIZE_OP_JUMP;
- else
- len = 0;
-
- len += mod_tlen + SIZE_OP_PUSH + cklen;
- }
- }
- else if (qn->upper == 0) {
- if (qn->is_refered != 0) /* /(?<n>..){0}/ */
- len = SIZE_OP_JUMP + tlen;
- else
- len = 0;
- }
- else if (qn->upper == 1 && qn->greedy) {
- if (qn->lower == 0) {
- if (CKN_ON) {
- len = SIZE_OP_STATE_CHECK_PUSH + tlen;
- }
- else {
- len = SIZE_OP_PUSH + tlen;
- }
- }
- else {
- len = tlen;
- }
- }
- else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
- len = SIZE_OP_PUSH + cklen + SIZE_OP_JUMP + tlen;
- }
- else {
- len = SIZE_OP_REPEAT_INC
- + mod_tlen + SIZE_OPCODE + SIZE_RELADDR + SIZE_MEMNUM;
- if (CKN_ON)
- len += SIZE_OP_STATE_CHECK;
- }
-
- return len;
-}
-
-static int
-compile_quantifier_node(QtfrNode* qn, regex_t* reg)
-{
- int r, mod_tlen;
- int ckn;
- int infinite = IS_REPEAT_INFINITE(qn->upper);
- int empty_info = qn->target_empty_info;
- int tlen = compile_length_tree(qn->target, reg);
-
- if (tlen < 0) return tlen;
-
- ckn = ((reg->num_comb_exp_check > 0) ? qn->comb_exp_check_num : 0);
-
- if (is_anychar_star_quantifier(qn)) {
- r = compile_tree_n_times(qn->target, qn->lower, reg);
- if (r) return r;
- if (IS_NOT_NULL(qn->next_head_exact) && !CKN_ON) {
- if (IS_MULTILINE(reg->options))
- r = add_opcode(reg, OP_ANYCHAR_ML_STAR_PEEK_NEXT);
- else
- r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT);
- if (r) return r;
- if (CKN_ON) {
- r = add_state_check_num(reg, ckn);
- if (r) return r;
- }
-
- return add_bytes(reg, NSTR(qn->next_head_exact)->s, 1);
- }
- else {
- if (IS_MULTILINE(reg->options)) {
- r = add_opcode(reg, (CKN_ON ?
- OP_STATE_CHECK_ANYCHAR_ML_STAR
- : OP_ANYCHAR_ML_STAR));
- }
- else {
- r = add_opcode(reg, (CKN_ON ?
- OP_STATE_CHECK_ANYCHAR_STAR
- : OP_ANYCHAR_STAR));
- }
- if (r) return r;
- if (CKN_ON)
- r = add_state_check_num(reg, ckn);
-
- return r;
- }
- }
-
- if (empty_info != 0)
- mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
- else
- mod_tlen = tlen;
-
- if (infinite && qn->lower <= 1) {
- if (qn->greedy) {
- if (qn->lower == 1) {
- r = add_opcode_rel_addr(reg, OP_JUMP,
- (CKN_ON ? SIZE_OP_STATE_CHECK_PUSH : SIZE_OP_PUSH));
- if (r) return r;
- }
-
- if (CKN_ON) {
- r = add_opcode(reg, OP_STATE_CHECK_PUSH);
- if (r) return r;
- r = add_state_check_num(reg, ckn);
- if (r) return r;
- r = add_rel_addr(reg, mod_tlen + SIZE_OP_JUMP);
- }
- else {
- r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP);
- }
- if (r) return r;
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + (int )SIZE_OP_JUMP
- + (int )(CKN_ON ? SIZE_OP_STATE_CHECK_PUSH : SIZE_OP_PUSH)));
- }
- else {
- if (qn->lower == 0) {
- r = add_opcode_rel_addr(reg, OP_JUMP, mod_tlen);
- if (r) return r;
- }
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
- if (CKN_ON) {
- r = add_opcode(reg, OP_STATE_CHECK_PUSH_OR_JUMP);
- if (r) return r;
- r = add_state_check_num(reg, ckn);
- if (r) return r;
- r = add_rel_addr(reg,
- -(mod_tlen + (int )SIZE_OP_STATE_CHECK_PUSH_OR_JUMP));
- }
- else
- r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH));
- }
- }
- else if (qn->upper == 0) {
- if (qn->is_refered != 0) { /* /(?<n>..){0}/ */
- r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
- if (r) return r;
- r = compile_tree(qn->target, reg);
- }
- else
- r = 0;
- }
- else if (qn->upper == 1 && qn->greedy) {
- if (qn->lower == 0) {
- if (CKN_ON) {
- r = add_opcode(reg, OP_STATE_CHECK_PUSH);
- if (r) return r;
- r = add_state_check_num(reg, ckn);
- if (r) return r;
- r = add_rel_addr(reg, tlen);
- }
- else {
- r = add_opcode_rel_addr(reg, OP_PUSH, tlen);
- }
- if (r) return r;
- }
-
- r = compile_tree(qn->target, reg);
- }
- else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
- if (CKN_ON) {
- r = add_opcode(reg, OP_STATE_CHECK_PUSH);
- if (r) return r;
- r = add_state_check_num(reg, ckn);
- if (r) return r;
- r = add_rel_addr(reg, SIZE_OP_JUMP);
- }
- else {
- r = add_opcode_rel_addr(reg, OP_PUSH, SIZE_OP_JUMP);
- }
-
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
- if (r) return r;
- r = compile_tree(qn->target, reg);
- }
- else {
- r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg);
- if (CKN_ON) {
- if (r) return r;
- r = add_opcode(reg, OP_STATE_CHECK);
- if (r) return r;
- r = add_state_check_num(reg, ckn);
- }
- }
- return r;
-}
-
-#else /* USE_COMBINATION_EXPLOSION_CHECK */
-
-static int
-compile_length_quantifier_node(QtfrNode* qn, regex_t* reg)
-{
- int len, mod_tlen;
- int infinite = IS_REPEAT_INFINITE(qn->upper);
- int empty_info = qn->target_empty_info;
- int tlen = compile_length_tree(qn->target, reg);
-
- if (tlen < 0) return tlen;
-
- /* anychar repeat */
- if (NTYPE(qn->target) == NT_CANY) {
- if (qn->greedy && infinite) {
- if (IS_NOT_NULL(qn->next_head_exact))
- return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower;
- else
- return SIZE_OP_ANYCHAR_STAR + tlen * qn->lower;
- }
- }
-
- if (empty_info != 0)
- mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
- else
- mod_tlen = tlen;
-
- if (infinite &&
- (qn->lower <= 1 || tlen * qn->lower <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
- if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {
- len = SIZE_OP_JUMP;
- }
- else {
- len = tlen * qn->lower;
- }
-
- if (qn->greedy) {
- if (IS_NOT_NULL(qn->head_exact))
- len += SIZE_OP_PUSH_OR_JUMP_EXACT1 + mod_tlen + SIZE_OP_JUMP;
- else if (IS_NOT_NULL(qn->next_head_exact))
- len += SIZE_OP_PUSH_IF_PEEK_NEXT + mod_tlen + SIZE_OP_JUMP;
- else
- len += SIZE_OP_PUSH + mod_tlen + SIZE_OP_JUMP;
- }
- else
- len += SIZE_OP_JUMP + mod_tlen + SIZE_OP_PUSH;
- }
- else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
- len = SIZE_OP_JUMP + tlen;
- }
- else if (!infinite && qn->greedy &&
- (qn->upper == 1 || (tlen + SIZE_OP_PUSH) * qn->upper
- <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
- len = tlen * qn->lower;
- len += (SIZE_OP_PUSH + tlen) * (qn->upper - qn->lower);
- }
- else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
- len = SIZE_OP_PUSH + SIZE_OP_JUMP + tlen;
- }
- else {
- len = SIZE_OP_REPEAT_INC
- + mod_tlen + SIZE_OPCODE + SIZE_RELADDR + SIZE_MEMNUM;
- }
-
- return len;
-}
-
-static int
-compile_quantifier_node(QtfrNode* qn, regex_t* reg)
-{
- int i, r, mod_tlen;
- int infinite = IS_REPEAT_INFINITE(qn->upper);
- int empty_info = qn->target_empty_info;
- int tlen = compile_length_tree(qn->target, reg);
-
- if (tlen < 0) return tlen;
-
- if (is_anychar_star_quantifier(qn)) {
- r = compile_tree_n_times(qn->target, qn->lower, reg);
- if (r) return r;
- if (IS_NOT_NULL(qn->next_head_exact)) {
- if (IS_MULTILINE(reg->options))
- r = add_opcode(reg, OP_ANYCHAR_ML_STAR_PEEK_NEXT);
- else
- r = add_opcode(reg, OP_ANYCHAR_STAR_PEEK_NEXT);
- if (r) return r;
- return add_bytes(reg, NSTR(qn->next_head_exact)->s, 1);
- }
- else {
- if (IS_MULTILINE(reg->options))
- return add_opcode(reg, OP_ANYCHAR_ML_STAR);
- else
- return add_opcode(reg, OP_ANYCHAR_STAR);
- }
- }
-
- if (empty_info != 0)
- mod_tlen = tlen + (SIZE_OP_NULL_CHECK_START + SIZE_OP_NULL_CHECK_END);
- else
- mod_tlen = tlen;
-
- if (infinite &&
- (qn->lower <= 1 || tlen * qn->lower <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
- if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) {
- if (qn->greedy) {
- if (IS_NOT_NULL(qn->head_exact))
- r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH_OR_JUMP_EXACT1);
- else if (IS_NOT_NULL(qn->next_head_exact))
- r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH_IF_PEEK_NEXT);
- else
- r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_PUSH);
- }
- else {
- r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_JUMP);
- }
- if (r) return r;
- }
- else {
- r = compile_tree_n_times(qn->target, qn->lower, reg);
- if (r) return r;
- }
-
- if (qn->greedy) {
- if (IS_NOT_NULL(qn->head_exact)) {
- r = add_opcode_rel_addr(reg, OP_PUSH_OR_JUMP_EXACT1,
- mod_tlen + SIZE_OP_JUMP);
- if (r) return r;
- add_bytes(reg, NSTR(qn->head_exact)->s, 1);
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH_OR_JUMP_EXACT1));
- }
- else if (IS_NOT_NULL(qn->next_head_exact)) {
- r = add_opcode_rel_addr(reg, OP_PUSH_IF_PEEK_NEXT,
- mod_tlen + SIZE_OP_JUMP);
- if (r) return r;
- add_bytes(reg, NSTR(qn->next_head_exact)->s, 1);
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH_IF_PEEK_NEXT));
- }
- else {
- r = add_opcode_rel_addr(reg, OP_PUSH, mod_tlen + SIZE_OP_JUMP);
- if (r) return r;
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP,
- -(mod_tlen + (int )SIZE_OP_JUMP + (int )SIZE_OP_PUSH));
- }
- }
- else {
- r = add_opcode_rel_addr(reg, OP_JUMP, mod_tlen);
- if (r) return r;
- r = compile_tree_empty_check(qn->target, reg, empty_info);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_PUSH, -(mod_tlen + (int )SIZE_OP_PUSH));
- }
- }
- else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */
- r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
- if (r) return r;
- r = compile_tree(qn->target, reg);
- }
- else if (!infinite && qn->greedy &&
- (qn->upper == 1 || (tlen + SIZE_OP_PUSH) * qn->upper
- <= QUANTIFIER_EXPAND_LIMIT_SIZE)) {
- int n = qn->upper - qn->lower;
-
- r = compile_tree_n_times(qn->target, qn->lower, reg);
- if (r) return r;
-
- for (i = 0; i < n; i++) {
- r = add_opcode_rel_addr(reg, OP_PUSH,
- (n - i) * tlen + (n - i - 1) * SIZE_OP_PUSH);
- if (r) return r;
- r = compile_tree(qn->target, reg);
- if (r) return r;
- }
- }
- else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */
- r = add_opcode_rel_addr(reg, OP_PUSH, SIZE_OP_JUMP);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP, tlen);
- if (r) return r;
- r = compile_tree(qn->target, reg);
- }
- else {
- r = compile_range_repeat_node(qn, mod_tlen, empty_info, reg);
- }
- return r;
-}
-#endif /* USE_COMBINATION_EXPLOSION_CHECK */
-
-static int
-compile_length_option_node(EncloseNode* node, regex_t* reg)
-{
- int tlen;
- OnigOptionType prev = reg->options;
-
- reg->options = node->option;
- tlen = compile_length_tree(node->target, reg);
- reg->options = prev;
-
- if (tlen < 0) return tlen;
-
- if (IS_DYNAMIC_OPTION(prev ^ node->option)) {
- return SIZE_OP_SET_OPTION_PUSH + SIZE_OP_SET_OPTION + SIZE_OP_FAIL
- + tlen + SIZE_OP_SET_OPTION;
- }
- else
- return tlen;
-}
-
-static int
-compile_option_node(EncloseNode* node, regex_t* reg)
-{
- int r;
- OnigOptionType prev = reg->options;
-
- if (IS_DYNAMIC_OPTION(prev ^ node->option)) {
- r = add_opcode_option(reg, OP_SET_OPTION_PUSH, node->option);
- if (r) return r;
- r = add_opcode_option(reg, OP_SET_OPTION, prev);
- if (r) return r;
- r = add_opcode(reg, OP_FAIL);
- if (r) return r;
- }
-
- reg->options = node->option;
- r = compile_tree(node->target, reg);
- reg->options = prev;
-
- if (IS_DYNAMIC_OPTION(prev ^ node->option)) {
- if (r) return r;
- r = add_opcode_option(reg, OP_SET_OPTION, prev);
- }
- return r;
-}
-
-static int
-compile_length_enclose_node(EncloseNode* node, regex_t* reg)
-{
- int len;
- int tlen;
-
- if (node->type == ENCLOSE_OPTION)
- return compile_length_option_node(node, reg);
-
- if (node->target) {
- tlen = compile_length_tree(node->target, reg);
- if (tlen < 0) return tlen;
- }
- else
- tlen = 0;
-
- switch (node->type) {
- case ENCLOSE_MEMORY:
-#ifdef USE_SUBEXP_CALL
- if (IS_ENCLOSE_CALLED(node)) {
- len = SIZE_OP_MEMORY_START_PUSH + tlen
- + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN;
- if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
- len += (IS_ENCLOSE_RECURSION(node)
- ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH);
- else
- len += (IS_ENCLOSE_RECURSION(node)
- ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END);
- }
- else
-#endif
- {
- if (BIT_STATUS_AT(reg->bt_mem_start, node->regnum))
- len = SIZE_OP_MEMORY_START_PUSH;
- else
- len = SIZE_OP_MEMORY_START;
-
- len += tlen + (BIT_STATUS_AT(reg->bt_mem_end, node->regnum)
- ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END);
- }
- break;
-
- case ENCLOSE_STOP_BACKTRACK:
- if (IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(node)) {
- QtfrNode* qn = NQTFR(node->target);
- tlen = compile_length_tree(qn->target, reg);
- if (tlen < 0) return tlen;
-
- len = tlen * qn->lower
- + SIZE_OP_PUSH + tlen + SIZE_OP_POP + SIZE_OP_JUMP;
- }
- else {
- len = SIZE_OP_PUSH_STOP_BT + tlen + SIZE_OP_POP_STOP_BT;
- }
- break;
-
- default:
- return ONIGERR_TYPE_BUG;
- break;
- }
-
- return len;
-}
-
-static int get_char_length_tree(Node* node, regex_t* reg, int* len);
-
-static int
-compile_enclose_node(EncloseNode* node, regex_t* reg)
-{
- int r, len;
-
- if (node->type == ENCLOSE_OPTION)
- return compile_option_node(node, reg);
-
- switch (node->type) {
- case ENCLOSE_MEMORY:
-#ifdef USE_SUBEXP_CALL
- if (IS_ENCLOSE_CALLED(node)) {
- r = add_opcode(reg, OP_CALL);
- if (r) return r;
- node->call_addr = BBUF_GET_OFFSET_POS(reg) + SIZE_ABSADDR + SIZE_OP_JUMP;
- node->state |= NST_ADDR_FIXED;
- r = add_abs_addr(reg, (int )node->call_addr);
- if (r) return r;
- len = compile_length_tree(node->target, reg);
- len += (SIZE_OP_MEMORY_START_PUSH + SIZE_OP_RETURN);
- if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
- len += (IS_ENCLOSE_RECURSION(node)
- ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH);
- else
- len += (IS_ENCLOSE_RECURSION(node)
- ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END);
-
- r = add_opcode_rel_addr(reg, OP_JUMP, len);
- if (r) return r;
- }
-#endif
- if (BIT_STATUS_AT(reg->bt_mem_start, node->regnum))
- r = add_opcode(reg, OP_MEMORY_START_PUSH);
- else
- r = add_opcode(reg, OP_MEMORY_START);
- if (r) return r;
- r = add_mem_num(reg, node->regnum);
- if (r) return r;
- r = compile_tree(node->target, reg);
- if (r) return r;
-#ifdef USE_SUBEXP_CALL
- if (IS_ENCLOSE_CALLED(node)) {
- if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
- r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node)
- ? OP_MEMORY_END_PUSH_REC : OP_MEMORY_END_PUSH));
- else
- r = add_opcode(reg, (IS_ENCLOSE_RECURSION(node)
- ? OP_MEMORY_END_REC : OP_MEMORY_END));
-
- if (r) return r;
- r = add_mem_num(reg, node->regnum);
- if (r) return r;
- r = add_opcode(reg, OP_RETURN);
- }
- else
-#endif
- {
- if (BIT_STATUS_AT(reg->bt_mem_end, node->regnum))
- r = add_opcode(reg, OP_MEMORY_END_PUSH);
- else
- r = add_opcode(reg, OP_MEMORY_END);
- if (r) return r;
- r = add_mem_num(reg, node->regnum);
- }
- break;
-
- case ENCLOSE_STOP_BACKTRACK:
- if (IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(node)) {
- QtfrNode* qn = NQTFR(node->target);
- r = compile_tree_n_times(qn->target, qn->lower, reg);
- if (r) return r;
-
- len = compile_length_tree(qn->target, reg);
- if (len < 0) return len;
-
- r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_POP + SIZE_OP_JUMP);
- if (r) return r;
- r = compile_tree(qn->target, reg);
- if (r) return r;
- r = add_opcode(reg, OP_POP);
- if (r) return r;
- r = add_opcode_rel_addr(reg, OP_JUMP,
- -((int )SIZE_OP_PUSH + len + (int )SIZE_OP_POP + (int )SIZE_OP_JUMP));
- }
- else {
- r = add_opcode(reg, OP_PUSH_STOP_BT);
- if (r) return r;
- r = compile_tree(node->target, reg);
- if (r) return r;
- r = add_opcode(reg, OP_POP_STOP_BT);
- }
- break;
-
- default:
- return ONIGERR_TYPE_BUG;
- break;
- }
-
- return r;
-}
-
-static int
-compile_length_anchor_node(AnchorNode* node, regex_t* reg)
-{
- int len;
- int tlen = 0;
-
- if (node->target) {
- tlen = compile_length_tree(node->target, reg);
- if (tlen < 0) return tlen;
- }
-
- switch (node->type) {
- case ANCHOR_PREC_READ:
- len = SIZE_OP_PUSH_POS + tlen + SIZE_OP_POP_POS;
- break;
- case ANCHOR_PREC_READ_NOT:
- len = SIZE_OP_PUSH_POS_NOT + tlen + SIZE_OP_FAIL_POS;
- break;
- case ANCHOR_LOOK_BEHIND:
- len = SIZE_OP_LOOK_BEHIND + tlen;
- break;
- case ANCHOR_LOOK_BEHIND_NOT:
- len = SIZE_OP_PUSH_LOOK_BEHIND_NOT + tlen + SIZE_OP_FAIL_LOOK_BEHIND_NOT;
- break;
-
- default:
- len = SIZE_OPCODE;
- break;
- }
-
- return len;
-}
-
-static int
-compile_anchor_node(AnchorNode* node, regex_t* reg)
-{
- int r, len;
-
- switch (node->type) {
- case ANCHOR_BEGIN_BUF: r = add_opcode(reg, OP_BEGIN_BUF); break;
- case ANCHOR_END_BUF: r = add_opcode(reg, OP_END_BUF); break;
- case ANCHOR_BEGIN_LINE: r = add_opcode(reg, OP_BEGIN_LINE); break;
- case ANCHOR_END_LINE: r = add_opcode(reg, OP_END_LINE); break;
- case ANCHOR_SEMI_END_BUF: r = add_opcode(reg, OP_SEMI_END_BUF); break;
- case ANCHOR_BEGIN_POSITION: r = add_opcode(reg, OP_BEGIN_POSITION); break;
-
- case ANCHOR_WORD_BOUND: r = add_opcode(reg, OP_WORD_BOUND); break;
- case ANCHOR_NOT_WORD_BOUND: r = add_opcode(reg, OP_NOT_WORD_BOUND); break;
-#ifdef USE_WORD_BEGIN_END
- case ANCHOR_WORD_BEGIN: r = add_opcode(reg, OP_WORD_BEGIN); break;
- case ANCHOR_WORD_END: r = add_opcode(reg, OP_WORD_END); break;
-#endif
-
- case ANCHOR_PREC_READ:
- r = add_opcode(reg, OP_PUSH_POS);
- if (r) return r;
- r = compile_tree(node->target, reg);
- if (r) return r;
- r = add_opcode(reg, OP_POP_POS);
- break;
-
- case ANCHOR_PREC_READ_NOT:
- len = compile_length_tree(node->target, reg);
- if (len < 0) return len;
- r = add_opcode_rel_addr(reg, OP_PUSH_POS_NOT, len + SIZE_OP_FAIL_POS);
- if (r) return r;
- r = compile_tree(node->target, reg);
- if (r) return r;
- r = add_opcode(reg, OP_FAIL_POS);
- break;
-
- case ANCHOR_LOOK_BEHIND:
- {
- int n;
- r = add_opcode(reg, OP_LOOK_BEHIND);
- if (r) return r;
- if (node->char_len < 0) {
- r = get_char_length_tree(node->target, reg, &n);
- if (r) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
- }
- else
- n = node->char_len;
- r = add_length(reg, n);
- if (r) return r;
- r = compile_tree(node->target, reg);
- }
- break;
-
- case ANCHOR_LOOK_BEHIND_NOT:
- {
- int n;
- len = compile_length_tree(node->target, reg);
- r = add_opcode_rel_addr(reg, OP_PUSH_LOOK_BEHIND_NOT,
- len + SIZE_OP_FAIL_LOOK_BEHIND_NOT);
- if (r) return r;
- if (node->char_len < 0) {
- r = get_char_length_tree(node->target, reg, &n);
- if (r) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
- }
- else
- n = node->char_len;
- r = add_length(reg, n);
- if (r) return r;
- r = compile_tree(node->target, reg);
- if (r) return r;
- r = add_opcode(reg, OP_FAIL_LOOK_BEHIND_NOT);
- }
- break;
-
- default:
- return ONIGERR_TYPE_BUG;
- break;
- }
-
- return r;
-}
-
-static int
-compile_length_tree(Node* node, regex_t* reg)
-{
- int len, type, r;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- len = 0;
- do {
- r = compile_length_tree(NCAR(node), reg);
- if (r < 0) return r;
- len += r;
- } while (IS_NOT_NULL(node = NCDR(node)));
- r = len;
- break;
-
- case NT_ALT:
- {
- int n;
-
- n = r = 0;
- do {
- r += compile_length_tree(NCAR(node), reg);
- n++;
- } while (IS_NOT_NULL(node = NCDR(node)));
- r += (SIZE_OP_PUSH + SIZE_OP_JUMP) * (n - 1);
- }
- break;
-
- case NT_STR:
- if (NSTRING_IS_RAW(node))
- r = compile_length_string_raw_node(NSTR(node), reg);
- else
- r = compile_length_string_node(node, reg);
- break;
-
- case NT_CCLASS:
- r = compile_length_cclass_node(NCCLASS(node), reg);
- break;
-
- case NT_CTYPE:
- case NT_CANY:
- r = SIZE_OPCODE;
- break;
-
- case NT_BREF:
- {
- BRefNode* br = NBREF(node);
-
-#ifdef USE_BACKREF_AT_LEVEL
- if (IS_BACKREF_NEST_LEVEL(br)) {
- r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH +
- SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
- }
- else
-#endif
- if (br->back_num == 1) {
- r = ((!IS_IGNORECASE(reg->options) && br->back_static[0] <= 2)
- ? SIZE_OPCODE : (SIZE_OPCODE + SIZE_MEMNUM));
- }
- else {
- r = SIZE_OPCODE + SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
- }
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- r = SIZE_OP_CALL;
- break;
-#endif
-
- case NT_QTFR:
- r = compile_length_quantifier_node(NQTFR(node), reg);
- break;
-
- case NT_ENCLOSE:
- r = compile_length_enclose_node(NENCLOSE(node), reg);
- break;
-
- case NT_ANCHOR:
- r = compile_length_anchor_node(NANCHOR(node), reg);
- break;
-
- default:
- return ONIGERR_TYPE_BUG;
- break;
- }
-
- return r;
-}
-
-static int
-compile_tree(Node* node, regex_t* reg)
-{
- int n, type, len, pos, r = 0;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- do {
- r = compile_tree(NCAR(node), reg);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_ALT:
- {
- Node* x = node;
- len = 0;
- do {
- len += compile_length_tree(NCAR(x), reg);
- if (NCDR(x) != NULL) {
- len += SIZE_OP_PUSH + SIZE_OP_JUMP;
- }
- } while (IS_NOT_NULL(x = NCDR(x)));
- pos = reg->used + len; /* goal position */
-
- do {
- len = compile_length_tree(NCAR(node), reg);
- if (IS_NOT_NULL(NCDR(node))) {
- r = add_opcode_rel_addr(reg, OP_PUSH, len + SIZE_OP_JUMP);
- if (r) break;
- }
- r = compile_tree(NCAR(node), reg);
- if (r) break;
- if (IS_NOT_NULL(NCDR(node))) {
- len = pos - (reg->used + SIZE_OP_JUMP);
- r = add_opcode_rel_addr(reg, OP_JUMP, len);
- if (r) break;
- }
- } while (IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
- case NT_STR:
- if (NSTRING_IS_RAW(node))
- r = compile_string_raw_node(NSTR(node), reg);
- else
- r = compile_string_node(node, reg);
- break;
-
- case NT_CCLASS:
- r = compile_cclass_node(NCCLASS(node), reg);
- break;
-
- case NT_CTYPE:
- {
- int op;
-
- switch (NCTYPE(node)->ctype) {
- case ONIGENC_CTYPE_WORD:
- if (NCTYPE(node)->not != 0) op = OP_NOT_WORD;
- else op = OP_WORD;
- break;
- default:
- return ONIGERR_TYPE_BUG;
- break;
- }
- r = add_opcode(reg, op);
- }
- break;
-
- case NT_CANY:
- if (IS_MULTILINE(reg->options))
- r = add_opcode(reg, OP_ANYCHAR_ML);
- else
- r = add_opcode(reg, OP_ANYCHAR);
- break;
-
- case NT_BREF:
- {
- BRefNode* br = NBREF(node);
-
-#ifdef USE_BACKREF_AT_LEVEL
- if (IS_BACKREF_NEST_LEVEL(br)) {
- r = add_opcode(reg, OP_BACKREF_AT_LEVEL);
- if (r) return r;
- r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE));
- if (r) return r;
- r = add_length(reg, br->nest_level);
- if (r) return r;
-
- goto add_bacref_mems;
- }
- else
-#endif
- if (br->back_num == 1) {
- n = br->back_static[0];
- if (IS_IGNORECASE(reg->options)) {
- r = add_opcode(reg, OP_BACKREFN_IC);
- if (r) return r;
- r = add_mem_num(reg, n);
- }
- else {
- switch (n) {
- case 1: r = add_opcode(reg, OP_BACKREF1); break;
- case 2: r = add_opcode(reg, OP_BACKREF2); break;
- default:
- r = add_opcode(reg, OP_BACKREFN);
- if (r) return r;
- r = add_mem_num(reg, n);
- break;
- }
- }
- }
- else {
- int i;
- int* p;
-
- if (IS_IGNORECASE(reg->options)) {
- r = add_opcode(reg, OP_BACKREF_MULTI_IC);
- }
- else {
- r = add_opcode(reg, OP_BACKREF_MULTI);
- }
- if (r) return r;
-
-#ifdef USE_BACKREF_AT_LEVEL
- add_bacref_mems:
-#endif
- r = add_length(reg, br->back_num);
- if (r) return r;
- p = BACKREFS_P(br);
- for (i = br->back_num - 1; i >= 0; i--) {
- r = add_mem_num(reg, p[i]);
- if (r) return r;
- }
- }
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- r = compile_call(NCALL(node), reg);
- break;
-#endif
-
- case NT_QTFR:
- r = compile_quantifier_node(NQTFR(node), reg);
- break;
-
- case NT_ENCLOSE:
- r = compile_enclose_node(NENCLOSE(node), reg);
- break;
-
- case NT_ANCHOR:
- r = compile_anchor_node(NANCHOR(node), reg);
- break;
-
- default:
-#ifdef ONIG_DEBUG
- fprintf(stderr, "compile_tree: undefined node type %d\n", NTYPE(node));
-#endif
- break;
- }
-
- return r;
-}
-
-#ifdef USE_NAMED_GROUP
-
-static int
-noname_disable_map(Node** plink, GroupNumRemap* map, int* counter)
-{
- int r = 0;
- Node* node = *plink;
-
- switch (NTYPE(node)) {
- case NT_LIST:
- case NT_ALT:
- do {
- r = noname_disable_map(&(NCAR(node)), map, counter);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_QTFR:
- {
- Node** ptarget = &(NQTFR(node)->target);
- Node* old = *ptarget;
- r = noname_disable_map(ptarget, map, counter);
- if (*ptarget != old && NTYPE(*ptarget) == NT_QTFR) {
- onig_reduce_nested_quantifier(node, *ptarget);
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- if (en->type == ENCLOSE_MEMORY) {
- if (IS_ENCLOSE_NAMED_GROUP(en)) {
- (*counter)++;
- map[en->regnum].new_val = *counter;
- en->regnum = *counter;
- r = noname_disable_map(&(en->target), map, counter);
- }
- else {
- *plink = en->target;
- en->target = NULL_NODE;
- onig_node_free(node);
- r = noname_disable_map(plink, map, counter);
- }
- }
- else
- r = noname_disable_map(&(en->target), map, counter);
- }
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-static int
-renumber_node_backref(Node* node, GroupNumRemap* map)
-{
- int i, pos, n, old_num;
- int *backs;
- BRefNode* bn = NBREF(node);
-
- if (! IS_BACKREF_NAME_REF(bn))
- return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
-
- old_num = bn->back_num;
- if (IS_NULL(bn->back_dynamic))
- backs = bn->back_static;
- else
- backs = bn->back_dynamic;
-
- for (i = 0, pos = 0; i < old_num; i++) {
- n = map[backs[i]].new_val;
- if (n > 0) {
- backs[pos] = n;
- pos++;
- }
- }
-
- bn->back_num = pos;
- return 0;
-}
-
-static int
-renumber_by_map(Node* node, GroupNumRemap* map)
-{
- int r = 0;
-
- switch (NTYPE(node)) {
- case NT_LIST:
- case NT_ALT:
- do {
- r = renumber_by_map(NCAR(node), map);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
- case NT_QTFR:
- r = renumber_by_map(NQTFR(node)->target, map);
- break;
- case NT_ENCLOSE:
- r = renumber_by_map(NENCLOSE(node)->target, map);
- break;
-
- case NT_BREF:
- r = renumber_node_backref(node, map);
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-static int
-numbered_ref_check(Node* node)
-{
- int r = 0;
-
- switch (NTYPE(node)) {
- case NT_LIST:
- case NT_ALT:
- do {
- r = numbered_ref_check(NCAR(node));
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
- case NT_QTFR:
- r = numbered_ref_check(NQTFR(node)->target);
- break;
- case NT_ENCLOSE:
- r = numbered_ref_check(NENCLOSE(node)->target);
- break;
-
- case NT_BREF:
- if (! IS_BACKREF_NAME_REF(NBREF(node)))
- return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-static int
-disable_noname_group_capture(Node** root, regex_t* reg, ScanEnv* env)
-{
- int r, i, pos, counter;
- BitStatusType loc;
- GroupNumRemap* map;
-
- map = (GroupNumRemap* )xalloca(sizeof(GroupNumRemap) * (env->num_mem + 1));
- CHECK_NULL_RETURN_MEMERR(map);
- for (i = 1; i <= env->num_mem; i++) {
- map[i].new_val = 0;
- }
- counter = 0;
- r = noname_disable_map(root, map, &counter);
- if (r != 0) return r;
-
- r = renumber_by_map(*root, map);
- if (r != 0) return r;
-
- for (i = 1, pos = 1; i <= env->num_mem; i++) {
- if (map[i].new_val > 0) {
- SCANENV_MEM_NODES(env)[pos] = SCANENV_MEM_NODES(env)[i];
- pos++;
- }
- }
-
- loc = env->capture_history;
- BIT_STATUS_CLEAR(env->capture_history);
- for (i = 1; i <= ONIG_MAX_CAPTURE_HISTORY_GROUP; i++) {
- if (BIT_STATUS_AT(loc, i)) {
- BIT_STATUS_ON_AT_SIMPLE(env->capture_history, map[i].new_val);
- }
- }
-
- env->num_mem = env->num_named;
- reg->num_mem = env->num_named;
-
- return onig_renumber_name_table(reg, map);
-}
-#endif /* USE_NAMED_GROUP */
-
-#ifdef USE_SUBEXP_CALL
-static int
-unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg)
-{
- int i, offset;
- EncloseNode* en;
- AbsAddrType addr;
-
- for (i = 0; i < uslist->num; i++) {
- en = NENCLOSE(uslist->us[i].target);
- if (! IS_ENCLOSE_ADDR_FIXED(en)) return ONIGERR_PARSER_BUG;
- addr = en->call_addr;
- offset = uslist->us[i].offset;
-
- BBUF_WRITE(reg, offset, &addr, SIZE_ABSADDR);
- }
- return 0;
-}
-#endif
-
-#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
-static int
-quantifiers_memory_node_info(Node* node)
-{
- int r = 0;
-
- switch (NTYPE(node)) {
- case NT_LIST:
- case NT_ALT:
- {
- int v;
- do {
- v = quantifiers_memory_node_info(NCAR(node));
- if (v > r) r = v;
- } while (v >= 0 && IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- if (IS_CALL_RECURSION(NCALL(node))) {
- return NQ_TARGET_IS_EMPTY_REC; /* tiny version */
- }
- else
- r = quantifiers_memory_node_info(NCALL(node)->target);
- break;
-#endif
-
- case NT_QTFR:
- {
- QtfrNode* qn = NQTFR(node);
- if (qn->upper != 0) {
- r = quantifiers_memory_node_info(qn->target);
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- switch (en->type) {
- case ENCLOSE_MEMORY:
- return NQ_TARGET_IS_EMPTY_MEM;
- break;
-
- case ENCLOSE_OPTION:
- case ENCLOSE_STOP_BACKTRACK:
- r = quantifiers_memory_node_info(en->target);
- break;
- default:
- break;
- }
- }
- break;
-
- case NT_BREF:
- case NT_STR:
- case NT_CTYPE:
- case NT_CCLASS:
- case NT_CANY:
- case NT_ANCHOR:
- default:
- break;
- }
-
- return r;
-}
-#endif /* USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK */
-
-static int
-get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env)
-{
- OnigDistance tmin;
- int r = 0;
-
- *min = 0;
- switch (NTYPE(node)) {
- case NT_BREF:
- {
- int i;
- int* backs;
- Node** nodes = SCANENV_MEM_NODES(env);
- BRefNode* br = NBREF(node);
- if (br->state & NST_RECURSION) break;
-
- backs = BACKREFS_P(br);
- if (backs[0] > env->num_mem) return ONIGERR_INVALID_BACKREF;
- r = get_min_match_length(nodes[backs[0]], min, env);
- if (r != 0) break;
- for (i = 1; i < br->back_num; i++) {
- if (backs[i] > env->num_mem) return ONIGERR_INVALID_BACKREF;
- r = get_min_match_length(nodes[backs[i]], &tmin, env);
- if (r != 0) break;
- if (*min > tmin) *min = tmin;
- }
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- if (IS_CALL_RECURSION(NCALL(node))) {
- EncloseNode* en = NENCLOSE(NCALL(node)->target);
- if (IS_ENCLOSE_MIN_FIXED(en))
- *min = en->min_len;
- }
- else
- r = get_min_match_length(NCALL(node)->target, min, env);
- break;
-#endif
-
- case NT_LIST:
- do {
- r = get_min_match_length(NCAR(node), &tmin, env);
- if (r == 0) *min += tmin;
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_ALT:
- {
- Node *x, *y;
- y = node;
- do {
- x = NCAR(y);
- r = get_min_match_length(x, &tmin, env);
- if (r != 0) break;
- if (y == node) *min = tmin;
- else if (*min > tmin) *min = tmin;
- } while (r == 0 && IS_NOT_NULL(y = NCDR(y)));
- }
- break;
-
- case NT_STR:
- {
- StrNode* sn = NSTR(node);
- *min = sn->end - sn->s;
- }
- break;
-
- case NT_CTYPE:
- *min = 1;
- break;
-
- case NT_CCLASS:
- case NT_CANY:
- *min = 1;
- break;
-
- case NT_QTFR:
- {
- QtfrNode* qn = NQTFR(node);
-
- if (qn->lower > 0) {
- r = get_min_match_length(qn->target, min, env);
- if (r == 0)
- *min = distance_multiply(*min, qn->lower);
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- switch (en->type) {
- case ENCLOSE_MEMORY:
-#ifdef USE_SUBEXP_CALL
- if (IS_ENCLOSE_MIN_FIXED(en))
- *min = en->min_len;
- else {
- r = get_min_match_length(en->target, min, env);
- if (r == 0) {
- en->min_len = *min;
- SET_ENCLOSE_STATUS(node, NST_MIN_FIXED);
- }
- }
- break;
-#endif
- case ENCLOSE_OPTION:
- case ENCLOSE_STOP_BACKTRACK:
- r = get_min_match_length(en->target, min, env);
- break;
- }
- }
- break;
-
- case NT_ANCHOR:
- default:
- break;
- }
-
- return r;
-}
-
-static int
-get_max_match_length(Node* node, OnigDistance *max, ScanEnv* env)
-{
- OnigDistance tmax;
- int r = 0;
-
- *max = 0;
- switch (NTYPE(node)) {
- case NT_LIST:
- do {
- r = get_max_match_length(NCAR(node), &tmax, env);
- if (r == 0)
- *max = distance_add(*max, tmax);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_ALT:
- do {
- r = get_max_match_length(NCAR(node), &tmax, env);
- if (r == 0 && *max < tmax) *max = tmax;
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_STR:
- {
- StrNode* sn = NSTR(node);
- *max = sn->end - sn->s;
- }
- break;
-
- case NT_CTYPE:
- *max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
- break;
-
- case NT_CCLASS:
- case NT_CANY:
- *max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
- break;
-
- case NT_BREF:
- {
- int i;
- int* backs;
- Node** nodes = SCANENV_MEM_NODES(env);
- BRefNode* br = NBREF(node);
- if (br->state & NST_RECURSION) {
- *max = ONIG_INFINITE_DISTANCE;
- break;
- }
- backs = BACKREFS_P(br);
- for (i = 0; i < br->back_num; i++) {
- if (backs[i] > env->num_mem) return ONIGERR_INVALID_BACKREF;
- r = get_max_match_length(nodes[backs[i]], &tmax, env);
- if (r != 0) break;
- if (*max < tmax) *max = tmax;
- }
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- if (! IS_CALL_RECURSION(NCALL(node)))
- r = get_max_match_length(NCALL(node)->target, max, env);
- else
- *max = ONIG_INFINITE_DISTANCE;
- break;
-#endif
-
- case NT_QTFR:
- {
- QtfrNode* qn = NQTFR(node);
-
- if (qn->upper != 0) {
- r = get_max_match_length(qn->target, max, env);
- if (r == 0 && *max != 0) {
- if (! IS_REPEAT_INFINITE(qn->upper))
- *max = distance_multiply(*max, qn->upper);
- else
- *max = ONIG_INFINITE_DISTANCE;
- }
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- switch (en->type) {
- case ENCLOSE_MEMORY:
-#ifdef USE_SUBEXP_CALL
- if (IS_ENCLOSE_MAX_FIXED(en))
- *max = en->max_len;
- else {
- r = get_max_match_length(en->target, max, env);
- if (r == 0) {
- en->max_len = *max;
- SET_ENCLOSE_STATUS(node, NST_MAX_FIXED);
- }
- }
- break;
-#endif
- case ENCLOSE_OPTION:
- case ENCLOSE_STOP_BACKTRACK:
- r = get_max_match_length(en->target, max, env);
- break;
- }
- }
- break;
-
- case NT_ANCHOR:
- default:
- break;
- }
-
- return r;
-}
-
-#define GET_CHAR_LEN_VARLEN -1
-#define GET_CHAR_LEN_TOP_ALT_VARLEN -2
-
-/* fixed size pattern node only */
-static int
-get_char_length_tree1(Node* node, regex_t* reg, int* len, int level)
-{
- int tlen;
- int r = 0;
-
- level++;
- *len = 0;
- switch (NTYPE(node)) {
- case NT_LIST:
- do {
- r = get_char_length_tree1(NCAR(node), reg, &tlen, level);
- if (r == 0)
- *len = distance_add(*len, tlen);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_ALT:
- {
- int tlen2;
- int varlen = 0;
-
- r = get_char_length_tree1(NCAR(node), reg, &tlen, level);
- while (r == 0 && IS_NOT_NULL(node = NCDR(node))) {
- r = get_char_length_tree1(NCAR(node), reg, &tlen2, level);
- if (r == 0) {
- if (tlen != tlen2)
- varlen = 1;
- }
- }
- if (r == 0) {
- if (varlen != 0) {
- if (level == 1)
- r = GET_CHAR_LEN_TOP_ALT_VARLEN;
- else
- r = GET_CHAR_LEN_VARLEN;
- }
- else
- *len = tlen;
- }
- }
- break;
-
- case NT_STR:
- {
- StrNode* sn = NSTR(node);
- UChar *s = sn->s;
- while (s < sn->end) {
- s += enc_len(reg->enc, s, sn->end);
- (*len)++;
- }
- }
- break;
-
- case NT_QTFR:
- {
- QtfrNode* qn = NQTFR(node);
- if (qn->lower == qn->upper) {
- r = get_char_length_tree1(qn->target, reg, &tlen, level);
- if (r == 0)
- *len = distance_multiply(tlen, qn->lower);
- }
- else
- r = GET_CHAR_LEN_VARLEN;
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- if (! IS_CALL_RECURSION(NCALL(node)))
- r = get_char_length_tree1(NCALL(node)->target, reg, len, level);
- else
- r = GET_CHAR_LEN_VARLEN;
- break;
-#endif
-
- case NT_CTYPE:
- *len = 1;
- break;
-
- case NT_CCLASS:
- case NT_CANY:
- *len = 1;
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- switch (en->type) {
- case ENCLOSE_MEMORY:
-#ifdef USE_SUBEXP_CALL
- if (IS_ENCLOSE_CLEN_FIXED(en))
- *len = en->char_len;
- else {
- r = get_char_length_tree1(en->target, reg, len, level);
- if (r == 0) {
- en->char_len = *len;
- SET_ENCLOSE_STATUS(node, NST_CLEN_FIXED);
- }
- }
- break;
-#endif
- case ENCLOSE_OPTION:
- case ENCLOSE_STOP_BACKTRACK:
- r = get_char_length_tree1(en->target, reg, len, level);
- break;
- default:
- break;
- }
- }
- break;
-
- case NT_ANCHOR:
- break;
-
- default:
- r = GET_CHAR_LEN_VARLEN;
- break;
- }
-
- return r;
-}
-
-static int
-get_char_length_tree(Node* node, regex_t* reg, int* len)
-{
- return get_char_length_tree1(node, reg, len, 0);
-}
-
-/* x is not included y ==> 1 : 0 */
-static int
-is_not_included(Node* x, Node* y, regex_t* reg)
-{
- int i, len;
- OnigCodePoint code;
- UChar *p, c;
- int ytype;
-
- retry:
- ytype = NTYPE(y);
- switch (NTYPE(x)) {
- case NT_CTYPE:
- {
- switch (ytype) {
- case NT_CTYPE:
- if (NCTYPE(y)->ctype == NCTYPE(x)->ctype &&
- NCTYPE(y)->not != NCTYPE(x)->not)
- return 1;
- else
- return 0;
- break;
-
- case NT_CCLASS:
- swap:
- {
- Node* tmp;
- tmp = x; x = y; y = tmp;
- goto retry;
- }
- break;
-
- case NT_STR:
- goto swap;
- break;
-
- default:
- break;
- }
- }
- break;
-
- case NT_CCLASS:
- {
- CClassNode* xc = NCCLASS(x);
- switch (ytype) {
- case NT_CTYPE:
- switch (NCTYPE(y)->ctype) {
- case ONIGENC_CTYPE_WORD:
- if (NCTYPE(y)->not == 0) {
- if (IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) {
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- if (BITSET_AT(xc->bs, i)) {
- if (IS_CODE_SB_WORD(reg->enc, i)) return 0;
- }
- }
- return 1;
- }
- return 0;
- }
- else {
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- if (! IS_CODE_SB_WORD(reg->enc, i)) {
- if (!IS_NCCLASS_NOT(xc)) {
- if (BITSET_AT(xc->bs, i))
- return 0;
- }
- else {
- if (! BITSET_AT(xc->bs, i))
- return 0;
- }
- }
- }
- return 1;
- }
- break;
-
- default:
- break;
- }
- break;
-
- case NT_CCLASS:
- {
- int v;
- CClassNode* yc = NCCLASS(y);
-
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- v = BITSET_AT(xc->bs, i);
- if ((v != 0 && !IS_NCCLASS_NOT(xc)) ||
- (v == 0 && IS_NCCLASS_NOT(xc))) {
- v = BITSET_AT(yc->bs, i);
- if ((v != 0 && !IS_NCCLASS_NOT(yc)) ||
- (v == 0 && IS_NCCLASS_NOT(yc)))
- return 0;
- }
- }
- if ((IS_NULL(xc->mbuf) && !IS_NCCLASS_NOT(xc)) ||
- (IS_NULL(yc->mbuf) && !IS_NCCLASS_NOT(yc)))
- return 1;
- return 0;
- }
- break;
-
- case NT_STR:
- goto swap;
- break;
-
- default:
- break;
- }
- }
- break;
-
- case NT_STR:
- {
- StrNode* xs = NSTR(x);
- if (NSTRING_LEN(x) == 0)
- break;
-
- c = *(xs->s);
- switch (ytype) {
- case NT_CTYPE:
- switch (NCTYPE(y)->ctype) {
- case ONIGENC_CTYPE_WORD:
- if (ONIGENC_IS_MBC_WORD(reg->enc, xs->s, xs->end))
- return NCTYPE(y)->not;
- else
- return !(NCTYPE(y)->not);
- break;
- default:
- break;
- }
- break;
-
- case NT_CCLASS:
- {
- CClassNode* cc = NCCLASS(y);
-
- code = ONIGENC_MBC_TO_CODE(reg->enc, xs->s,
- xs->s + ONIGENC_MBC_MAXLEN(reg->enc));
- return (onig_is_code_in_cc(reg->enc, code, cc) != 0 ? 0 : 1);
- }
- break;
-
- case NT_STR:
- {
- UChar *q;
- StrNode* ys = NSTR(y);
- len = NSTRING_LEN(x);
- if (len > NSTRING_LEN(y)) len = NSTRING_LEN(y);
- if (NSTRING_IS_AMBIG(x) || NSTRING_IS_AMBIG(y)) {
- /* tiny version */
- return 0;
- }
- else {
- for (i = 0, p = ys->s, q = xs->s; i < len; i++, p++, q++) {
- if (*p != *q) return 1;
- }
- }
- }
- break;
-
- default:
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
- return 0;
-}
-
-static Node*
-get_head_value_node(Node* node, int exact, regex_t* reg)
-{
- Node* n = NULL_NODE;
-
- switch (NTYPE(node)) {
- case NT_BREF:
- case NT_ALT:
- case NT_CANY:
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
-#endif
- break;
-
- case NT_CTYPE:
- case NT_CCLASS:
- if (exact == 0) {
- n = node;
- }
- break;
-
- case NT_LIST:
- n = get_head_value_node(NCAR(node), exact, reg);
- break;
-
- case NT_STR:
- {
- StrNode* sn = NSTR(node);
-
- if (sn->end <= sn->s)
- break;
-
- if (exact != 0 &&
- !NSTRING_IS_RAW(node) && IS_IGNORECASE(reg->options)) {
- }
- else {
- n = node;
- }
- }
- break;
-
- case NT_QTFR:
- {
- QtfrNode* qn = NQTFR(node);
- if (qn->lower > 0) {
- if (IS_NOT_NULL(qn->head_exact))
- n = qn->head_exact;
- else
- n = get_head_value_node(qn->target, exact, reg);
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- switch (en->type) {
- case ENCLOSE_OPTION:
- {
- OnigOptionType options = reg->options;
-
- reg->options = NENCLOSE(node)->option;
- n = get_head_value_node(NENCLOSE(node)->target, exact, reg);
- reg->options = options;
- }
- break;
-
- case ENCLOSE_MEMORY:
- case ENCLOSE_STOP_BACKTRACK:
- n = get_head_value_node(en->target, exact, reg);
- break;
- }
- }
- break;
-
- case NT_ANCHOR:
- if (NANCHOR(node)->type == ANCHOR_PREC_READ)
- n = get_head_value_node(NANCHOR(node)->target, exact, reg);
- break;
-
- default:
- break;
- }
-
- return n;
-}
-
-static int
-check_type_tree(Node* node, int type_mask, int enclose_mask, int anchor_mask)
-{
- int type, r = 0;
-
- type = NTYPE(node);
- if ((NTYPE2BIT(type) & type_mask) == 0)
- return 1;
-
- switch (type) {
- case NT_LIST:
- case NT_ALT:
- do {
- r = check_type_tree(NCAR(node), type_mask, enclose_mask,
- anchor_mask);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_QTFR:
- r = check_type_tree(NQTFR(node)->target, type_mask, enclose_mask,
- anchor_mask);
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
- if ((en->type & enclose_mask) == 0)
- return 1;
-
- r = check_type_tree(en->target, type_mask, enclose_mask, anchor_mask);
- }
- break;
-
- case NT_ANCHOR:
- type = NANCHOR(node)->type;
- if ((type & anchor_mask) == 0)
- return 1;
-
- if (NANCHOR(node)->target)
- r = check_type_tree(NANCHOR(node)->target,
- type_mask, enclose_mask, anchor_mask);
- break;
-
- default:
- break;
- }
- return r;
-}
-
-#ifdef USE_SUBEXP_CALL
-
-#define RECURSION_EXIST 1
-#define RECURSION_INFINITE 2
-
-static int
-subexp_inf_recursive_check(Node* node, ScanEnv* env, int head)
-{
- int type;
- int r = 0;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- {
- Node *x;
- OnigDistance min;
- int ret;
-
- x = node;
- do {
- ret = subexp_inf_recursive_check(NCAR(x), env, head);
- if (ret < 0 || ret == RECURSION_INFINITE) return ret;
- r |= ret;
- if (head) {
- ret = get_min_match_length(NCAR(x), &min, env);
- if (ret != 0) return ret;
- if (min != 0) head = 0;
- }
- } while (IS_NOT_NULL(x = NCDR(x)));
- }
- break;
-
- case NT_ALT:
- {
- int ret;
- r = RECURSION_EXIST;
- do {
- ret = subexp_inf_recursive_check(NCAR(node), env, head);
- if (ret < 0 || ret == RECURSION_INFINITE) return ret;
- r &= ret;
- } while (IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
- case NT_QTFR:
- r = subexp_inf_recursive_check(NQTFR(node)->target, env, head);
- if (r == RECURSION_EXIST) {
- if (NQTFR(node)->lower == 0) r = 0;
- }
- break;
-
- case NT_ANCHOR:
- {
- AnchorNode* an = NANCHOR(node);
- switch (an->type) {
- case ANCHOR_PREC_READ:
- case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND:
- case ANCHOR_LOOK_BEHIND_NOT:
- r = subexp_inf_recursive_check(an->target, env, head);
- break;
- }
- }
- break;
-
- case NT_CALL:
- r = subexp_inf_recursive_check(NCALL(node)->target, env, head);
- break;
-
- case NT_ENCLOSE:
- if (IS_ENCLOSE_MARK2(NENCLOSE(node)))
- return 0;
- else if (IS_ENCLOSE_MARK1(NENCLOSE(node)))
- return (head == 0 ? RECURSION_EXIST : RECURSION_INFINITE);
- else {
- SET_ENCLOSE_STATUS(node, NST_MARK2);
- r = subexp_inf_recursive_check(NENCLOSE(node)->target, env, head);
- CLEAR_ENCLOSE_STATUS(node, NST_MARK2);
- }
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-static int
-subexp_inf_recursive_check_trav(Node* node, ScanEnv* env)
-{
- int type;
- int r = 0;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- case NT_ALT:
- do {
- r = subexp_inf_recursive_check_trav(NCAR(node), env);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_QTFR:
- r = subexp_inf_recursive_check_trav(NQTFR(node)->target, env);
- break;
-
- case NT_ANCHOR:
- {
- AnchorNode* an = NANCHOR(node);
- switch (an->type) {
- case ANCHOR_PREC_READ:
- case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND:
- case ANCHOR_LOOK_BEHIND_NOT:
- r = subexp_inf_recursive_check_trav(an->target, env);
- break;
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
-
- if (IS_ENCLOSE_RECURSION(en)) {
- SET_ENCLOSE_STATUS(node, NST_MARK1);
- r = subexp_inf_recursive_check(en->target, env, 1);
- if (r > 0) return ONIGERR_NEVER_ENDING_RECURSION;
- CLEAR_ENCLOSE_STATUS(node, NST_MARK1);
- }
- r = subexp_inf_recursive_check_trav(en->target, env);
- }
-
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-static int
-subexp_recursive_check(Node* node)
-{
- int r = 0;
-
- switch (NTYPE(node)) {
- case NT_LIST:
- case NT_ALT:
- do {
- r |= subexp_recursive_check(NCAR(node));
- } while (IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_QTFR:
- r = subexp_recursive_check(NQTFR(node)->target);
- break;
-
- case NT_ANCHOR:
- {
- AnchorNode* an = NANCHOR(node);
- switch (an->type) {
- case ANCHOR_PREC_READ:
- case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND:
- case ANCHOR_LOOK_BEHIND_NOT:
- r = subexp_recursive_check(an->target);
- break;
- }
- }
- break;
-
- case NT_CALL:
- r = subexp_recursive_check(NCALL(node)->target);
- if (r != 0) SET_CALL_RECURSION(node);
- break;
-
- case NT_ENCLOSE:
- if (IS_ENCLOSE_MARK2(NENCLOSE(node)))
- return 0;
- else if (IS_ENCLOSE_MARK1(NENCLOSE(node)))
- return 1; /* recursion */
- else {
- SET_ENCLOSE_STATUS(node, NST_MARK2);
- r = subexp_recursive_check(NENCLOSE(node)->target);
- CLEAR_ENCLOSE_STATUS(node, NST_MARK2);
- }
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-
-static int
-subexp_recursive_check_trav(Node* node, ScanEnv* env)
-{
-#define FOUND_CALLED_NODE 1
-
- int type;
- int r = 0;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- case NT_ALT:
- {
- int ret;
- do {
- ret = subexp_recursive_check_trav(NCAR(node), env);
- if (ret == FOUND_CALLED_NODE) r = FOUND_CALLED_NODE;
- else if (ret < 0) return ret;
- } while (IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
- case NT_QTFR:
- r = subexp_recursive_check_trav(NQTFR(node)->target, env);
- if (NQTFR(node)->upper == 0) {
- if (r == FOUND_CALLED_NODE)
- NQTFR(node)->is_refered = 1;
- }
- break;
-
- case NT_ANCHOR:
- {
- AnchorNode* an = NANCHOR(node);
- switch (an->type) {
- case ANCHOR_PREC_READ:
- case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND:
- case ANCHOR_LOOK_BEHIND_NOT:
- r = subexp_recursive_check_trav(an->target, env);
- break;
- }
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
-
- if (! IS_ENCLOSE_RECURSION(en)) {
- if (IS_ENCLOSE_CALLED(en)) {
- SET_ENCLOSE_STATUS(node, NST_MARK1);
- r = subexp_recursive_check(en->target);
- if (r != 0) SET_ENCLOSE_STATUS(node, NST_RECURSION);
- CLEAR_ENCLOSE_STATUS(node, NST_MARK1);
- }
- }
- r = subexp_recursive_check_trav(en->target, env);
- if (IS_ENCLOSE_CALLED(en))
- r |= FOUND_CALLED_NODE;
- }
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-static int
-setup_subexp_call(Node* node, ScanEnv* env)
-{
- int type;
- int r = 0;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- do {
- r = setup_subexp_call(NCAR(node), env);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_ALT:
- do {
- r = setup_subexp_call(NCAR(node), env);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_QTFR:
- r = setup_subexp_call(NQTFR(node)->target, env);
- break;
- case NT_ENCLOSE:
- r = setup_subexp_call(NENCLOSE(node)->target, env);
- break;
-
- case NT_CALL:
- {
- int n, num, *refs;
- UChar *p;
- CallNode* cn = NCALL(node);
- Node** nodes = SCANENV_MEM_NODES(env);
-
-#ifdef USE_NAMED_GROUP
- n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, &refs);
-#else
- n = -1;
-#endif
- if (n <= 0) {
- /* name not found, check group number. (?*ddd) */
- p = cn->name;
- num = onig_scan_unsigned_number(&p, cn->name_end, env->enc);
- if (num <= 0 || p != cn->name_end) {
- onig_scan_env_set_error_string(env,
- ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
- return ONIGERR_UNDEFINED_NAME_REFERENCE;
- }
-#ifdef USE_NAMED_GROUP
- if (env->num_named > 0 &&
- IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
- !ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
- return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
- }
-#endif
- if (num > env->num_mem) {
- onig_scan_env_set_error_string(env,
- ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
- return ONIGERR_UNDEFINED_GROUP_REFERENCE;
- }
- cn->ref_num = num;
- goto set_call_attr;
- }
- else if (n > 1) {
- onig_scan_env_set_error_string(env,
- ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, cn->name, cn->name_end);
- return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
- }
- else {
- cn->ref_num = refs[0];
- set_call_attr:
- cn->target = nodes[cn->ref_num];
- if (IS_NULL(cn->target)) {
- onig_scan_env_set_error_string(env,
- ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
- return ONIGERR_UNDEFINED_NAME_REFERENCE;
- }
- SET_ENCLOSE_STATUS(cn->target, NST_CALLED);
- BIT_STATUS_ON_AT(env->bt_mem_start, cn->ref_num);
- cn->unset_addr_list = env->unset_addr_list;
- }
- }
- break;
-
- case NT_ANCHOR:
- {
- AnchorNode* an = NANCHOR(node);
-
- switch (an->type) {
- case ANCHOR_PREC_READ:
- case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND:
- case ANCHOR_LOOK_BEHIND_NOT:
- r = setup_subexp_call(an->target, env);
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
- return r;
-}
-#endif
-
-/* divide different length alternatives in look-behind.
- (?<=A|B) ==> (?<=A)|(?<=B)
- (?<!A|B) ==> (?<!A)(?<!B)
-*/
-static int
-divide_look_behind_alternatives(Node* node)
-{
- Node *head, *np, *insert_node;
- AnchorNode* an = NANCHOR(node);
- int anc_type = an->type;
-
- head = an->target;
- np = NCAR(head);
- swap_node(node, head);
- NCAR(node) = head;
- NANCHOR(head)->target = np;
-
- np = node;
- while ((np = NCDR(np)) != NULL_NODE) {
- insert_node = onig_node_new_anchor(anc_type);
- CHECK_NULL_RETURN_MEMERR(insert_node);
- NANCHOR(insert_node)->target = NCAR(np);
- NCAR(np) = insert_node;
- }
-
- if (anc_type == ANCHOR_LOOK_BEHIND_NOT) {
- np = node;
- do {
- SET_NTYPE(np, NT_LIST); /* alt -> list */
- } while ((np = NCDR(np)) != NULL_NODE);
- }
- return 0;
-}
-
-static int
-setup_look_behind(Node* node, regex_t* reg, ScanEnv* env)
-{
- int r, len;
- AnchorNode* an = NANCHOR(node);
-
- r = get_char_length_tree(an->target, reg, &len);
- if (r == 0)
- an->char_len = len;
- else if (r == GET_CHAR_LEN_VARLEN)
- r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
- else if (r == GET_CHAR_LEN_TOP_ALT_VARLEN) {
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND))
- r = divide_look_behind_alternatives(node);
- else
- r = ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
- }
-
- return r;
-}
-
-static int
-next_setup(Node* node, Node* next_node, regex_t* reg)
-{
- int type;
-
- retry:
- type = NTYPE(node);
- if (type == NT_QTFR) {
- QtfrNode* qn = NQTFR(node);
- if (qn->greedy && IS_REPEAT_INFINITE(qn->upper)) {
-#ifdef USE_QTFR_PEEK_NEXT
- Node* n = get_head_value_node(next_node, 1, reg);
- /* '\0': for UTF-16BE etc... */
- if (IS_NOT_NULL(n) && NSTR(n)->s[0] != '\0') {
- qn->next_head_exact = n;
- }
-#endif
- /* automatic posseivation a*b ==> (?>a*)b */
- if (qn->lower <= 1) {
- int ttype = NTYPE(qn->target);
- if (IS_NODE_TYPE_SIMPLE(ttype)) {
- Node *x, *y;
- x = get_head_value_node(qn->target, 0, reg);
- if (IS_NOT_NULL(x)) {
- y = get_head_value_node(next_node, 0, reg);
- if (IS_NOT_NULL(y) && is_not_included(x, y, reg)) {
- Node* en = onig_node_new_enclose(ENCLOSE_STOP_BACKTRACK);
- CHECK_NULL_RETURN_MEMERR(en);
- SET_ENCLOSE_STATUS(en, NST_STOP_BT_SIMPLE_REPEAT);
- swap_node(node, en);
- NENCLOSE(node)->target = en;
- }
- }
- }
- }
- }
- }
- else if (type == NT_ENCLOSE) {
- EncloseNode* en = NENCLOSE(node);
- if (en->type == ENCLOSE_MEMORY) {
- node = en->target;
- goto retry;
- }
- }
- return 0;
-}
-
-
-static int
-update_string_node_case_fold(regex_t* reg, Node *node)
-{
- UChar *p, *q, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
- UChar *sbuf, *ebuf, *sp;
- int r, i, len, sbuf_size;
- StrNode* sn = NSTR(node);
-
- end = sn->end;
- sbuf_size = (end - sn->s) * 2;
- sbuf = (UChar* )xmalloc(sbuf_size);
- CHECK_NULL_RETURN_MEMERR(sbuf);
- ebuf = sbuf + sbuf_size;
-
- sp = sbuf;
- p = sn->s;
- while (p < end) {
- len = ONIGENC_MBC_CASE_FOLD(reg->enc, reg->case_fold_flag, &p, end, buf);
- q = buf;
- for (i = 0; i < len; i++) {
- if (sp >= ebuf) {
- sbuf = (UChar* )xrealloc(sbuf, sbuf_size * 2);
- CHECK_NULL_RETURN_MEMERR(sbuf);
- sp = sbuf + sbuf_size;
- sbuf_size *= 2;
- ebuf = sbuf + sbuf_size;
- }
-
- *sp++ = buf[i];
- }
- }
-
- r = onig_node_str_set(node, sbuf, sp);
- if (r != 0) {
- xfree(sbuf);
- return r;
- }
-
- xfree(sbuf);
- return 0;
-}
-
-static int
-expand_case_fold_make_rem_string(Node** rnode, UChar *s, UChar *end,
- regex_t* reg)
-{
- int r;
- Node *node;
-
- node = onig_node_new_str(s, end);
- if (IS_NULL(node)) return ONIGERR_MEMORY;
-
- r = update_string_node_case_fold(reg, node);
- if (r != 0) {
- onig_node_free(node);
- return r;
- }
-
- NSTRING_SET_AMBIG(node);
- NSTRING_SET_DONT_GET_OPT_INFO(node);
- *rnode = node;
- return 0;
-}
-
-static int
-expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[],
- UChar *p, int slen, UChar *end,
- regex_t* reg, Node **rnode)
-{
- int r, i, j, len, varlen;
- Node *anode, *var_anode, *snode, *xnode, *an;
- UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
-
- *rnode = var_anode = NULL_NODE;
-
- varlen = 0;
- for (i = 0; i < item_num; i++) {
- if (items[i].byte_len != slen) {
- varlen = 1;
- break;
- }
- }
-
- if (varlen != 0) {
- *rnode = var_anode = onig_node_new_alt(NULL_NODE, NULL_NODE);
- if (IS_NULL(var_anode)) return ONIGERR_MEMORY;
-
- xnode = onig_node_new_list(NULL, NULL);
- if (IS_NULL(xnode)) goto mem_err;
- NCAR(var_anode) = xnode;
-
- anode = onig_node_new_alt(NULL_NODE, NULL_NODE);
- if (IS_NULL(anode)) goto mem_err;
- NCAR(xnode) = anode;
- }
- else {
- *rnode = anode = onig_node_new_alt(NULL_NODE, NULL_NODE);
- if (IS_NULL(anode)) return ONIGERR_MEMORY;
- }
-
- snode = onig_node_new_str(p, p + slen);
- if (IS_NULL(snode)) goto mem_err;
-
- NCAR(anode) = snode;
-
- for (i = 0; i < item_num; i++) {
- snode = onig_node_new_str(NULL, NULL);
- if (IS_NULL(snode)) goto mem_err;
-
- for (j = 0; j < items[i].code_len; j++) {
- len = ONIGENC_CODE_TO_MBC(reg->enc, items[i].code[j], buf);
- if (len < 0) {
- r = len;
- goto mem_err2;
- }
-
- r = onig_node_str_cat(snode, buf, buf + len);
- if (r != 0) goto mem_err2;
- }
-
- an = onig_node_new_alt(NULL_NODE, NULL_NODE);
- if (IS_NULL(an)) {
- goto mem_err2;
- }
-
- if (items[i].byte_len != slen) {
- Node *rem;
- UChar *q = p + items[i].byte_len;
-
- if (q < end) {
- r = expand_case_fold_make_rem_string(&rem, q, end, reg);
- if (r != 0) {
- onig_node_free(an);
- goto mem_err2;
- }
-
- xnode = onig_node_list_add(NULL_NODE, snode);
- if (IS_NULL(xnode)) {
- onig_node_free(an);
- onig_node_free(rem);
- goto mem_err2;
- }
- if (IS_NULL(onig_node_list_add(xnode, rem))) {
- onig_node_free(an);
- onig_node_free(xnode);
- onig_node_free(rem);
- goto mem_err;
- }
-
- NCAR(an) = xnode;
- }
- else {
- NCAR(an) = snode;
- }
-
- NCDR(var_anode) = an;
- var_anode = an;
- }
- else {
- NCAR(an) = snode;
- NCDR(anode) = an;
- anode = an;
- }
- }
-
- return varlen;
-
- mem_err2:
- onig_node_free(snode);
-
- mem_err:
- onig_node_free(*rnode);
-
- return ONIGERR_MEMORY;
-}
-
-static int
-expand_case_fold_string(Node* node, regex_t* reg)
-{
-#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION 8
-
- int r, n, len, alt_num;
- UChar *start, *end, *p;
- Node *top_root, *root, *snode, *prev_node;
- OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
- StrNode* sn = NSTR(node);
-
- if (NSTRING_IS_AMBIG(node)) return 0;
-
- start = sn->s;
- end = sn->end;
- if (start >= end) return 0;
-
- r = 0;
- top_root = root = prev_node = snode = NULL_NODE;
- alt_num = 1;
- p = start;
- while (p < end) {
- n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(reg->enc, reg->case_fold_flag,
- p, end, items);
- if (n < 0) {
- r = n;
- goto err;
- }
-
- len = enc_len(reg->enc, p, end);
-
- if (n == 0) {
- if (IS_NULL(snode)) {
- if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
- top_root = root = onig_node_list_add(NULL_NODE, prev_node);
- if (IS_NULL(root)) {
- onig_node_free(prev_node);
- goto mem_err;
- }
- }
-
- prev_node = snode = onig_node_new_str(NULL, NULL);
- if (IS_NULL(snode)) goto mem_err;
- if (IS_NOT_NULL(root)) {
- if (IS_NULL(onig_node_list_add(root, snode))) {
- onig_node_free(snode);
- goto mem_err;
- }
- }
- }
-
- r = onig_node_str_cat(snode, p, p + len);
- if (r != 0) goto err;
- }
- else {
- alt_num *= (n + 1);
- if (alt_num > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break;
-
- if (IS_NULL(root) && IS_NOT_NULL(prev_node)) {
- top_root = root = onig_node_list_add(NULL_NODE, prev_node);
- if (IS_NULL(root)) {
- onig_node_free(prev_node);
- goto mem_err;
- }
- }
-
- r = expand_case_fold_string_alt(n, items, p, len, end, reg, &prev_node);
- if (r < 0) goto mem_err;
- if (r == 1) {
- if (IS_NULL(root)) {
- top_root = prev_node;
- }
- else {
- if (IS_NULL(onig_node_list_add(root, prev_node))) {
- onig_node_free(prev_node);
- goto mem_err;
- }
- }
-
- root = NCAR(prev_node);
- }
- else { /* r == 0 */
- if (IS_NOT_NULL(root)) {
- if (IS_NULL(onig_node_list_add(root, prev_node))) {
- onig_node_free(prev_node);
- goto mem_err;
- }
- }
- }
-
- snode = NULL_NODE;
- }
-
- p += len;
- }
-
- if (p < end) {
- Node *srem;
-
- r = expand_case_fold_make_rem_string(&srem, p, end, reg);
- if (r != 0) goto mem_err;
-
- if (IS_NOT_NULL(prev_node) && IS_NULL(root)) {
- top_root = root = onig_node_list_add(NULL_NODE, prev_node);
- if (IS_NULL(root)) {
- onig_node_free(srem);
- onig_node_free(prev_node);
- goto mem_err;
- }
- }
-
- if (IS_NULL(root)) {
- prev_node = srem;
- }
- else {
- if (IS_NULL(onig_node_list_add(root, srem))) {
- onig_node_free(srem);
- goto mem_err;
- }
- }
- }
-
- /* ending */
- top_root = (IS_NOT_NULL(top_root) ? top_root : prev_node);
- swap_node(node, top_root);
- onig_node_free(top_root);
- return 0;
-
- mem_err:
- r = ONIGERR_MEMORY;
-
- err:
- onig_node_free(top_root);
- return r;
-}
-
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
-
-#define CEC_THRES_NUM_BIG_REPEAT 512
-#define CEC_INFINITE_NUM 0x7fffffff
-
-#define CEC_IN_INFINITE_REPEAT (1<<0)
-#define CEC_IN_FINITE_REPEAT (1<<1)
-#define CEC_CONT_BIG_REPEAT (1<<2)
-
-static int
-setup_comb_exp_check(Node* node, int state, ScanEnv* env)
-{
- int type;
- int r = state;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- {
- Node* prev = NULL_NODE;
- do {
- r = setup_comb_exp_check(NCAR(node), r, env);
- prev = NCAR(node);
- } while (r >= 0 && IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
- case NT_ALT:
- {
- int ret;
- do {
- ret = setup_comb_exp_check(NCAR(node), state, env);
- r |= ret;
- } while (ret >= 0 && IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
- case NT_QTFR:
- {
- int child_state = state;
- int add_state = 0;
- QtfrNode* qn = NQTFR(node);
- Node* target = qn->target;
- int var_num;
-
- if (! IS_REPEAT_INFINITE(qn->upper)) {
- if (qn->upper > 1) {
- /* {0,1}, {1,1} are allowed */
- child_state |= CEC_IN_FINITE_REPEAT;
-
- /* check (a*){n,m}, (a+){n,m} => (a*){n,n}, (a+){n,n} */
- if (env->backrefed_mem == 0) {
- if (NTYPE(qn->target) == NT_ENCLOSE) {
- EncloseNode* en = NENCLOSE(qn->target);
- if (en->type == ENCLOSE_MEMORY) {
- if (NTYPE(en->target) == NT_QTFR) {
- QtfrNode* q = NQTFR(en->target);
- if (IS_REPEAT_INFINITE(q->upper)
- && q->greedy == qn->greedy) {
- qn->upper = (qn->lower == 0 ? 1 : qn->lower);
- if (qn->upper == 1)
- child_state = state;
- }
- }
- }
- }
- }
- }
- }
-
- if (state & CEC_IN_FINITE_REPEAT) {
- qn->comb_exp_check_num = -1;
- }
- else {
- if (IS_REPEAT_INFINITE(qn->upper)) {
- var_num = CEC_INFINITE_NUM;
- child_state |= CEC_IN_INFINITE_REPEAT;
- }
- else {
- var_num = qn->upper - qn->lower;
- }
-
- if (var_num >= CEC_THRES_NUM_BIG_REPEAT)
- add_state |= CEC_CONT_BIG_REPEAT;
-
- if (((state & CEC_IN_INFINITE_REPEAT) != 0 && var_num != 0) ||
- ((state & CEC_CONT_BIG_REPEAT) != 0 &&
- var_num >= CEC_THRES_NUM_BIG_REPEAT)) {
- if (qn->comb_exp_check_num == 0) {
- env->num_comb_exp_check++;
- qn->comb_exp_check_num = env->num_comb_exp_check;
- if (env->curr_max_regnum > env->comb_exp_max_regnum)
- env->comb_exp_max_regnum = env->curr_max_regnum;
- }
- }
- }
-
- r = setup_comb_exp_check(target, child_state, env);
- r |= add_state;
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
-
- switch (en->type) {
- case ENCLOSE_MEMORY:
- {
- if (env->curr_max_regnum < en->regnum)
- env->curr_max_regnum = en->regnum;
-
- r = setup_comb_exp_check(en->target, state, env);
- }
- break;
-
- default:
- r = setup_comb_exp_check(en->target, state, env);
- break;
- }
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- if (IS_CALL_RECURSION(NCALL(node)))
- env->has_recursion = 1;
- else
- r = setup_comb_exp_check(NCALL(node)->target, state, env);
- break;
-#endif
-
- default:
- break;
- }
-
- return r;
-}
-#endif
-
-#define IN_ALT (1<<0)
-#define IN_NOT (1<<1)
-#define IN_REPEAT (1<<2)
-#define IN_VAR_REPEAT (1<<3)
-
-/* setup_tree does the following work.
- 1. check empty loop. (set qn->target_empty_info)
- 2. expand ignore-case in char class.
- 3. set memory status bit flags. (reg->mem_stats)
- 4. set qn->head_exact for [push, exact] -> [push_or_jump_exact1, exact].
- 5. find invalid patterns in look-behind.
- 6. expand repeated string.
- */
-static int
-setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
-{
- int type;
- int r = 0;
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- {
- Node* prev = NULL_NODE;
- do {
- r = setup_tree(NCAR(node), reg, state, env);
- if (IS_NOT_NULL(prev) && r == 0) {
- r = next_setup(prev, NCAR(node), reg);
- }
- prev = NCAR(node);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- }
- break;
-
- case NT_ALT:
- do {
- r = setup_tree(NCAR(node), reg, (state | IN_ALT), env);
- } while (r == 0 && IS_NOT_NULL(node = NCDR(node)));
- break;
-
- case NT_CCLASS:
- break;
-
- case NT_STR:
- if (IS_IGNORECASE(reg->options) && !NSTRING_IS_RAW(node)) {
- r = expand_case_fold_string(node, reg);
- }
- break;
-
- case NT_CTYPE:
- case NT_CANY:
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- break;
-#endif
-
- case NT_BREF:
- {
- int i;
- int* p;
- Node** nodes = SCANENV_MEM_NODES(env);
- BRefNode* br = NBREF(node);
- p = BACKREFS_P(br);
- for (i = 0; i < br->back_num; i++) {
- if (p[i] > env->num_mem) return ONIGERR_INVALID_BACKREF;
- BIT_STATUS_ON_AT(env->backrefed_mem, p[i]);
- BIT_STATUS_ON_AT(env->bt_mem_start, p[i]);
-#ifdef USE_BACKREF_AT_LEVEL
- if (IS_BACKREF_NEST_LEVEL(br)) {
- BIT_STATUS_ON_AT(env->bt_mem_end, p[i]);
- }
-#endif
- SET_ENCLOSE_STATUS(nodes[p[i]], NST_MEM_BACKREFED);
- }
- }
- break;
-
- case NT_QTFR:
- {
- OnigDistance d;
- QtfrNode* qn = NQTFR(node);
- Node* target = qn->target;
-
- if ((state & IN_REPEAT) != 0) {
- qn->state |= NST_IN_REPEAT;
- }
-
- if (IS_REPEAT_INFINITE(qn->upper) || qn->upper >= 1) {
- r = get_min_match_length(target, &d, env);
- if (r) break;
- if (d == 0) {
- qn->target_empty_info = NQ_TARGET_IS_EMPTY;
-#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
- r = quantifiers_memory_node_info(target);
- if (r < 0) break;
- if (r > 0) {
- qn->target_empty_info = r;
- }
-#endif
-#if 0
- r = get_max_match_length(target, &d, env);
- if (r == 0 && d == 0) {
- /* ()* ==> ()?, ()+ ==> () */
- qn->upper = 1;
- if (qn->lower > 1) qn->lower = 1;
- if (NTYPE(target) == NT_STR) {
- qn->upper = qn->lower = 0; /* /(?:)+/ ==> // */
- }
- }
-#endif
- }
- }
-
- state |= IN_REPEAT;
- if (qn->lower != qn->upper)
- state |= IN_VAR_REPEAT;
- r = setup_tree(target, reg, state, env);
- if (r) break;
-
- /* expand string */
-#define EXPAND_STRING_MAX_LENGTH 100
- if (NTYPE(target) == NT_STR) {
- if (!IS_REPEAT_INFINITE(qn->lower) && qn->lower == qn->upper &&
- qn->lower > 1 && qn->lower <= EXPAND_STRING_MAX_LENGTH) {
- int len = NSTRING_LEN(target);
- StrNode* sn = NSTR(target);
-
- if (len * qn->lower <= EXPAND_STRING_MAX_LENGTH) {
- int i, n = qn->lower;
- onig_node_conv_to_str_node(node, NSTR(target)->flag);
- for (i = 0; i < n; i++) {
- r = onig_node_str_cat(node, sn->s, sn->end);
- if (r) break;
- }
- onig_node_free(target);
- break; /* break case NT_QTFR: */
- }
- }
- }
-
-#ifdef USE_OP_PUSH_OR_JUMP_EXACT
- if (qn->greedy && (qn->target_empty_info != 0)) {
- if (NTYPE(target) == NT_QTFR) {
- QtfrNode* tqn = NQTFR(target);
- if (IS_NOT_NULL(tqn->head_exact)) {
- qn->head_exact = tqn->head_exact;
- tqn->head_exact = NULL;
- }
- }
- else {
- qn->head_exact = get_head_value_node(qn->target, 1, reg);
- }
- }
-#endif
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
-
- switch (en->type) {
- case ENCLOSE_OPTION:
- {
- OnigOptionType options = reg->options;
- reg->options = NENCLOSE(node)->option;
- r = setup_tree(NENCLOSE(node)->target, reg, state, env);
- reg->options = options;
- }
- break;
-
- case ENCLOSE_MEMORY:
- if ((state & (IN_ALT | IN_NOT | IN_VAR_REPEAT)) != 0) {
- BIT_STATUS_ON_AT(env->bt_mem_start, en->regnum);
- /* SET_ENCLOSE_STATUS(node, NST_MEM_IN_ALT_NOT); */
- }
- r = setup_tree(en->target, reg, state, env);
- break;
-
- case ENCLOSE_STOP_BACKTRACK:
- {
- Node* target = en->target;
- r = setup_tree(target, reg, state, env);
- if (NTYPE(target) == NT_QTFR) {
- QtfrNode* tqn = NQTFR(target);
- if (IS_REPEAT_INFINITE(tqn->upper) && tqn->lower <= 1 &&
- tqn->greedy != 0) { /* (?>a*), a*+ etc... */
- int qtype = NTYPE(tqn->target);
- if (IS_NODE_TYPE_SIMPLE(qtype))
- SET_ENCLOSE_STATUS(node, NST_STOP_BT_SIMPLE_REPEAT);
- }
- }
- }
- break;
- }
- }
- break;
-
- case NT_ANCHOR:
- {
- AnchorNode* an = NANCHOR(node);
-
- switch (an->type) {
- case ANCHOR_PREC_READ:
- r = setup_tree(an->target, reg, state, env);
- break;
- case ANCHOR_PREC_READ_NOT:
- r = setup_tree(an->target, reg, (state | IN_NOT), env);
- break;
-
-/* allowed node types in look-behind */
-#define ALLOWED_TYPE_IN_LB \
- ( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \
- BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL )
-
-#define ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY )
-#define ALLOWED_ENCLOSE_IN_LB_NOT 0
-
-#define ALLOWED_ANCHOR_IN_LB \
-( ANCHOR_LOOK_BEHIND | ANCHOR_BEGIN_LINE | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION )
-#define ALLOWED_ANCHOR_IN_LB_NOT \
-( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION )
-
- case ANCHOR_LOOK_BEHIND:
- {
- r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB,
- ALLOWED_ENCLOSE_IN_LB, ALLOWED_ANCHOR_IN_LB);
- if (r < 0) return r;
- if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
- r = setup_look_behind(node, reg, env);
- if (r != 0) return r;
- r = setup_tree(an->target, reg, state, env);
- }
- break;
-
- case ANCHOR_LOOK_BEHIND_NOT:
- {
- r = check_type_tree(an->target, ALLOWED_TYPE_IN_LB,
- ALLOWED_ENCLOSE_IN_LB_NOT, ALLOWED_ANCHOR_IN_LB_NOT);
- if (r < 0) return r;
- if (r > 0) return ONIGERR_INVALID_LOOK_BEHIND_PATTERN;
- r = setup_look_behind(node, reg, env);
- if (r != 0) return r;
- r = setup_tree(an->target, reg, (state | IN_NOT), env);
- }
- break;
- }
- }
- break;
-
- default:
- break;
- }
-
- return r;
-}
-
-/* set skip map for Boyer-Moor search */
-static int
-set_bm_skip(UChar* s, UChar* end, OnigEncoding enc,
- UChar skip[], int** int_skip)
-{
- int i, len;
-
- len = end - s;
- if (len < ONIG_CHAR_TABLE_SIZE) {
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = len;
-
- for (i = 0; i < len - 1; i++)
- skip[s[i]] = len - 1 - i;
- }
- else {
- if (IS_NULL(*int_skip)) {
- *int_skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE);
- if (IS_NULL(*int_skip)) return ONIGERR_MEMORY;
- }
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) (*int_skip)[i] = len;
-
- for (i = 0; i < len - 1; i++)
- (*int_skip)[s[i]] = len - 1 - i;
- }
- return 0;
-}
-
-#define OPT_EXACT_MAXLEN 24
-
-typedef struct {
- OnigDistance min; /* min byte length */
- OnigDistance max; /* max byte length */
-} MinMaxLen;
-
-typedef struct {
- MinMaxLen mmd;
- OnigEncoding enc;
- OnigOptionType options;
- OnigCaseFoldType case_fold_flag;
- ScanEnv* scan_env;
-} OptEnv;
-
-typedef struct {
- int left_anchor;
- int right_anchor;
-} OptAncInfo;
-
-typedef struct {
- MinMaxLen mmd; /* info position */
- OptAncInfo anc;
-
- int reach_end;
- int ignore_case;
- int len;
- UChar s[OPT_EXACT_MAXLEN];
-} OptExactInfo;
-
-typedef struct {
- MinMaxLen mmd; /* info position */
- OptAncInfo anc;
-
- int value; /* weighted value */
- UChar map[ONIG_CHAR_TABLE_SIZE];
-} OptMapInfo;
-
-typedef struct {
- MinMaxLen len;
-
- OptAncInfo anc;
- OptExactInfo exb; /* boundary */
- OptExactInfo exm; /* middle */
- OptExactInfo expr; /* prec read (?=...) */
-
- OptMapInfo map; /* boundary */
-} NodeOptInfo;
-
-
-static int
-map_position_value(OnigEncoding enc, int i)
-{
- static const short int ByteValTable[] = {
- 5, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 1, 1, 10, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 12, 4, 7, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5,
- 5, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 5, 5, 5,
- 5, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 1
- };
-
- if (i < sizeof(ByteValTable)/sizeof(ByteValTable[0])) {
- if (i == 0 && ONIGENC_MBC_MINLEN(enc) > 1)
- return 20;
- else
- return (int )ByteValTable[i];
- }
- else
- return 4; /* Take it easy. */
-}
-
-static int
-distance_value(MinMaxLen* mm)
-{
- /* 1000 / (min-max-dist + 1) */
- static const short int dist_vals[] = {
- 1000, 500, 333, 250, 200, 167, 143, 125, 111, 100,
- 91, 83, 77, 71, 67, 63, 59, 56, 53, 50,
- 48, 45, 43, 42, 40, 38, 37, 36, 34, 33,
- 32, 31, 30, 29, 29, 28, 27, 26, 26, 25,
- 24, 24, 23, 23, 22, 22, 21, 21, 20, 20,
- 20, 19, 19, 19, 18, 18, 18, 17, 17, 17,
- 16, 16, 16, 16, 15, 15, 15, 15, 14, 14,
- 14, 14, 14, 14, 13, 13, 13, 13, 13, 13,
- 12, 12, 12, 12, 12, 12, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 10, 10, 10, 10, 10
- };
-
- int d;
-
- if (mm->max == ONIG_INFINITE_DISTANCE) return 0;
-
- d = mm->max - mm->min;
- if (d < sizeof(dist_vals)/sizeof(dist_vals[0]))
- /* return dist_vals[d] * 16 / (mm->min + 12); */
- return (int )dist_vals[d];
- else
- return 1;
-}
-
-static int
-comp_distance_value(MinMaxLen* d1, MinMaxLen* d2, int v1, int v2)
-{
- if (v2 <= 0) return -1;
- if (v1 <= 0) return 1;
-
- v1 *= distance_value(d1);
- v2 *= distance_value(d2);
-
- if (v2 > v1) return 1;
- if (v2 < v1) return -1;
-
- if (d2->min < d1->min) return 1;
- if (d2->min > d1->min) return -1;
- return 0;
-}
-
-static int
-is_equal_mml(MinMaxLen* a, MinMaxLen* b)
-{
- return (a->min == b->min && a->max == b->max) ? 1 : 0;
-}
-
-
-static void
-set_mml(MinMaxLen* mml, OnigDistance min, OnigDistance max)
-{
- mml->min = min;
- mml->max = max;
-}
-
-static void
-clear_mml(MinMaxLen* mml)
-{
- mml->min = mml->max = 0;
-}
-
-static void
-copy_mml(MinMaxLen* to, MinMaxLen* from)
-{
- to->min = from->min;
- to->max = from->max;
-}
-
-static void
-add_mml(MinMaxLen* to, MinMaxLen* from)
-{
- to->min = distance_add(to->min, from->min);
- to->max = distance_add(to->max, from->max);
-}
-
-#if 0
-static void
-add_len_mml(MinMaxLen* to, OnigDistance len)
-{
- to->min = distance_add(to->min, len);
- to->max = distance_add(to->max, len);
-}
-#endif
-
-static void
-alt_merge_mml(MinMaxLen* to, MinMaxLen* from)
-{
- if (to->min > from->min) to->min = from->min;
- if (to->max < from->max) to->max = from->max;
-}
-
-static void
-copy_opt_env(OptEnv* to, OptEnv* from)
-{
- *to = *from;
-}
-
-static void
-clear_opt_anc_info(OptAncInfo* anc)
-{
- anc->left_anchor = 0;
- anc->right_anchor = 0;
-}
-
-static void
-copy_opt_anc_info(OptAncInfo* to, OptAncInfo* from)
-{
- *to = *from;
-}
-
-static void
-concat_opt_anc_info(OptAncInfo* to, OptAncInfo* left, OptAncInfo* right,
- OnigDistance left_len, OnigDistance right_len)
-{
- clear_opt_anc_info(to);
-
- to->left_anchor = left->left_anchor;
- if (left_len == 0) {
- to->left_anchor |= right->left_anchor;
- }
-
- to->right_anchor = right->right_anchor;
- if (right_len == 0) {
- to->right_anchor |= left->right_anchor;
- }
-}
-
-static int
-is_left_anchor(int anc)
-{
- if (anc == ANCHOR_END_BUF || anc == ANCHOR_SEMI_END_BUF ||
- anc == ANCHOR_END_LINE || anc == ANCHOR_PREC_READ ||
- anc == ANCHOR_PREC_READ_NOT)
- return 0;
-
- return 1;
-}
-
-static int
-is_set_opt_anc_info(OptAncInfo* to, int anc)
-{
- if ((to->left_anchor & anc) != 0) return 1;
-
- return ((to->right_anchor & anc) != 0 ? 1 : 0);
-}
-
-static void
-add_opt_anc_info(OptAncInfo* to, int anc)
-{
- if (is_left_anchor(anc))
- to->left_anchor |= anc;
- else
- to->right_anchor |= anc;
-}
-
-static void
-remove_opt_anc_info(OptAncInfo* to, int anc)
-{
- if (is_left_anchor(anc))
- to->left_anchor &= ~anc;
- else
- to->right_anchor &= ~anc;
-}
-
-static void
-alt_merge_opt_anc_info(OptAncInfo* to, OptAncInfo* add)
-{
- to->left_anchor &= add->left_anchor;
- to->right_anchor &= add->right_anchor;
-}
-
-static int
-is_full_opt_exact_info(OptExactInfo* ex)
-{
- return (ex->len >= OPT_EXACT_MAXLEN ? 1 : 0);
-}
-
-static void
-clear_opt_exact_info(OptExactInfo* ex)
-{
- clear_mml(&ex->mmd);
- clear_opt_anc_info(&ex->anc);
- ex->reach_end = 0;
- ex->ignore_case = 0;
- ex->len = 0;
- ex->s[0] = '\0';
-}
-
-static void
-copy_opt_exact_info(OptExactInfo* to, OptExactInfo* from)
-{
- *to = *from;
-}
-
-static void
-concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)
-{
- int i, j, len;
- UChar *p, *end;
- OptAncInfo tanc;
-
- if (! to->ignore_case && add->ignore_case) {
- if (to->len >= add->len) return ; /* avoid */
-
- to->ignore_case = 1;
- }
-
- p = add->s;
- end = p + add->len;
- for (i = to->len; p < end; ) {
- len = enc_len(enc, p, end);
- if (i + len > OPT_EXACT_MAXLEN) break;
- for (j = 0; j < len && p < end; j++)
- to->s[i++] = *p++;
- }
-
- to->len = i;
- to->reach_end = (p == end ? add->reach_end : 0);
-
- concat_opt_anc_info(&tanc, &to->anc, &add->anc, 1, 1);
- if (! to->reach_end) tanc.right_anchor = 0;
- copy_opt_anc_info(&to->anc, &tanc);
-}
-
-static void
-concat_opt_exact_info_str(OptExactInfo* to,
- UChar* s, UChar* end, int raw, OnigEncoding enc)
-{
- int i, j, len;
- UChar *p;
-
- for (i = to->len, p = s; p < end && i < OPT_EXACT_MAXLEN; ) {
- len = enc_len(enc, p, end);
- if (i + len > OPT_EXACT_MAXLEN) break;
- for (j = 0; j < len && p < end; j++)
- to->s[i++] = *p++;
- }
-
- to->len = i;
-}
-
-static void
-alt_merge_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OptEnv* env)
-{
- int i, j, len;
-
- if (add->len == 0 || to->len == 0) {
- clear_opt_exact_info(to);
- return ;
- }
-
- if (! is_equal_mml(&to->mmd, &add->mmd)) {
- clear_opt_exact_info(to);
- return ;
- }
-
- for (i = 0; i < to->len && i < add->len; ) {
- if (to->s[i] != add->s[i]) break;
- len = enc_len(env->enc, to->s + i, to->s + to->len);
-
- for (j = 1; j < len; j++) {
- if (to->s[i+j] != add->s[i+j]) break;
- }
- if (j < len) break;
- i += len;
- }
-
- if (! add->reach_end || i < add->len || i < to->len) {
- to->reach_end = 0;
- }
- to->len = i;
- to->ignore_case |= add->ignore_case;
-
- alt_merge_opt_anc_info(&to->anc, &add->anc);
- if (! to->reach_end) to->anc.right_anchor = 0;
-}
-
-static void
-select_opt_exact_info(OnigEncoding enc, OptExactInfo* now, OptExactInfo* alt)
-{
- int v1, v2;
-
- v1 = now->len;
- v2 = alt->len;
-
- if (v2 == 0) {
- return ;
- }
- else if (v1 == 0) {
- copy_opt_exact_info(now, alt);
- return ;
- }
- else if (v1 <= 2 && v2 <= 2) {
- /* ByteValTable[x] is big value --> low price */
- v2 = map_position_value(enc, now->s[0]);
- v1 = map_position_value(enc, alt->s[0]);
-
- if (now->len > 1) v1 += 5;
- if (alt->len > 1) v2 += 5;
- }
-
- if (now->ignore_case == 0) v1 *= 2;
- if (alt->ignore_case == 0) v2 *= 2;
-
- if (comp_distance_value(&now->mmd, &alt->mmd, v1, v2) > 0)
- copy_opt_exact_info(now, alt);
-}
-
-static void
-clear_opt_map_info(OptMapInfo* map)
-{
- static const OptMapInfo clean_info = {
- {0, 0}, {0, 0}, 0,
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- }
- };
-
- xmemcpy(map, &clean_info, sizeof(OptMapInfo));
-}
-
-static void
-copy_opt_map_info(OptMapInfo* to, OptMapInfo* from)
-{
- *to = *from;
-}
-
-static void
-add_char_opt_map_info(OptMapInfo* map, UChar c, OnigEncoding enc)
-{
- if (map->map[c] == 0) {
- map->map[c] = 1;
- map->value += map_position_value(enc, c);
- }
-}
-
-static int
-add_char_amb_opt_map_info(OptMapInfo* map, UChar* p, UChar* end,
- OnigEncoding enc, OnigCaseFoldType case_fold_flag)
-{
- OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
- UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
- int i, n;
-
- add_char_opt_map_info(map, p[0], enc);
-
- case_fold_flag = DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag);
- n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, case_fold_flag, p, end, items);
- if (n < 0) return n;
-
- for (i = 0; i < n; i++) {
- ONIGENC_CODE_TO_MBC(enc, items[i].code[0], buf);
- add_char_opt_map_info(map, buf[0], enc);
- }
-
- return 0;
-}
-
-static void
-select_opt_map_info(OptMapInfo* now, OptMapInfo* alt)
-{
- static int z = 1<<15; /* 32768: something big value */
-
- int v1, v2;
-
- if (alt->value == 0) return ;
- if (now->value == 0) {
- copy_opt_map_info(now, alt);
- return ;
- }
-
- v1 = z / now->value;
- v2 = z / alt->value;
- if (comp_distance_value(&now->mmd, &alt->mmd, v1, v2) > 0)
- copy_opt_map_info(now, alt);
-}
-
-static int
-comp_opt_exact_or_map_info(OptExactInfo* e, OptMapInfo* m)
-{
-#define COMP_EM_BASE 20
- int ve, vm;
-
- if (m->value <= 0) return -1;
-
- ve = COMP_EM_BASE * e->len * (e->ignore_case ? 1 : 2);
- vm = COMP_EM_BASE * 5 * 2 / m->value;
- return comp_distance_value(&e->mmd, &m->mmd, ve, vm);
-}
-
-static void
-alt_merge_opt_map_info(OnigEncoding enc, OptMapInfo* to, OptMapInfo* add)
-{
- int i, val;
-
- /* if (! is_equal_mml(&to->mmd, &add->mmd)) return ; */
- if (to->value == 0) return ;
- if (add->value == 0 || to->mmd.max < add->mmd.min) {
- clear_opt_map_info(to);
- return ;
- }
-
- alt_merge_mml(&to->mmd, &add->mmd);
-
- val = 0;
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {
- if (add->map[i])
- to->map[i] = 1;
-
- if (to->map[i])
- val += map_position_value(enc, i);
- }
- to->value = val;
-
- alt_merge_opt_anc_info(&to->anc, &add->anc);
-}
-
-static void
-set_bound_node_opt_info(NodeOptInfo* opt, MinMaxLen* mmd)
-{
- copy_mml(&(opt->exb.mmd), mmd);
- copy_mml(&(opt->expr.mmd), mmd);
- copy_mml(&(opt->map.mmd), mmd);
-}
-
-static void
-clear_node_opt_info(NodeOptInfo* opt)
-{
- clear_mml(&opt->len);
- clear_opt_anc_info(&opt->anc);
- clear_opt_exact_info(&opt->exb);
- clear_opt_exact_info(&opt->exm);
- clear_opt_exact_info(&opt->expr);
- clear_opt_map_info(&opt->map);
-}
-
-static void
-copy_node_opt_info(NodeOptInfo* to, NodeOptInfo* from)
-{
- *to = *from;
-}
-
-static void
-concat_left_node_opt_info(OnigEncoding enc, NodeOptInfo* to, NodeOptInfo* add)
-{
- int exb_reach, exm_reach;
- OptAncInfo tanc;
-
- concat_opt_anc_info(&tanc, &to->anc, &add->anc, to->len.max, add->len.max);
- copy_opt_anc_info(&to->anc, &tanc);
-
- if (add->exb.len > 0 && to->len.max == 0) {
- concat_opt_anc_info(&tanc, &to->anc, &add->exb.anc,
- to->len.max, add->len.max);
- copy_opt_anc_info(&add->exb.anc, &tanc);
- }
-
- if (add->map.value > 0 && to->len.max == 0) {
- if (add->map.mmd.max == 0)
- add->map.anc.left_anchor |= to->anc.left_anchor;
- }
-
- exb_reach = to->exb.reach_end;
- exm_reach = to->exm.reach_end;
-
- if (add->len.max != 0)
- to->exb.reach_end = to->exm.reach_end = 0;
-
- if (add->exb.len > 0) {
- if (exb_reach) {
- concat_opt_exact_info(&to->exb, &add->exb, enc);
- clear_opt_exact_info(&add->exb);
- }
- else if (exm_reach) {
- concat_opt_exact_info(&to->exm, &add->exb, enc);
- clear_opt_exact_info(&add->exb);
- }
- }
- select_opt_exact_info(enc, &to->exm, &add->exb);
- select_opt_exact_info(enc, &to->exm, &add->exm);
-
- if (to->expr.len > 0) {
- if (add->len.max > 0) {
- if (to->expr.len > (int )add->len.max)
- to->expr.len = add->len.max;
-
- if (to->expr.mmd.max == 0)
- select_opt_exact_info(enc, &to->exb, &to->expr);
- else
- select_opt_exact_info(enc, &to->exm, &to->expr);
- }
- }
- else if (add->expr.len > 0) {
- copy_opt_exact_info(&to->expr, &add->expr);
- }
-
- select_opt_map_info(&to->map, &add->map);
-
- add_mml(&to->len, &add->len);
-}
-
-static void
-alt_merge_node_opt_info(NodeOptInfo* to, NodeOptInfo* add, OptEnv* env)
-{
- alt_merge_opt_anc_info (&to->anc, &add->anc);
- alt_merge_opt_exact_info(&to->exb, &add->exb, env);
- alt_merge_opt_exact_info(&to->exm, &add->exm, env);
- alt_merge_opt_exact_info(&to->expr, &add->expr, env);
- alt_merge_opt_map_info(env->enc, &to->map, &add->map);
-
- alt_merge_mml(&to->len, &add->len);
-}
-
-
-#define MAX_NODE_OPT_INFO_REF_COUNT 5
-
-static int
-optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
-{
- int type;
- int r = 0;
-
- clear_node_opt_info(opt);
- set_bound_node_opt_info(opt, &env->mmd);
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- {
- OptEnv nenv;
- NodeOptInfo nopt;
- Node* nd = node;
-
- copy_opt_env(&nenv, env);
- do {
- r = optimize_node_left(NCAR(nd), &nopt, &nenv);
- if (r == 0) {
- add_mml(&nenv.mmd, &nopt.len);
- concat_left_node_opt_info(env->enc, opt, &nopt);
- }
- } while (r == 0 && IS_NOT_NULL(nd = NCDR(nd)));
- }
- break;
-
- case NT_ALT:
- {
- NodeOptInfo nopt;
- Node* nd = node;
-
- do {
- r = optimize_node_left(NCAR(nd), &nopt, env);
- if (r == 0) {
- if (nd == node) copy_node_opt_info(opt, &nopt);
- else alt_merge_node_opt_info(opt, &nopt, env);
- }
- } while ((r == 0) && IS_NOT_NULL(nd = NCDR(nd)));
- }
- break;
-
- case NT_STR:
- {
- StrNode* sn = NSTR(node);
- int slen = sn->end - sn->s;
- int is_raw = NSTRING_IS_RAW(node);
-
- if (! NSTRING_IS_AMBIG(node)) {
- concat_opt_exact_info_str(&opt->exb, sn->s, sn->end,
- NSTRING_IS_RAW(node), env->enc);
- if (slen > 0) {
- add_char_opt_map_info(&opt->map, *(sn->s), env->enc);
- }
- set_mml(&opt->len, slen, slen);
- }
- else {
- int max;
-
- if (NSTRING_IS_DONT_GET_OPT_INFO(node)) {
- int n = onigenc_strlen(env->enc, sn->s, sn->end);
- max = ONIGENC_MBC_MAXLEN_DIST(env->enc) * n;
- }
- else {
- concat_opt_exact_info_str(&opt->exb, sn->s, sn->end,
- is_raw, env->enc);
- opt->exb.ignore_case = 1;
-
- if (slen > 0) {
- r = add_char_amb_opt_map_info(&opt->map, sn->s, sn->end,
- env->enc, env->case_fold_flag);
- if (r != 0) break;
- }
-
- max = slen;
- }
-
- set_mml(&opt->len, slen, max);
- }
-
- if (opt->exb.len == slen)
- opt->exb.reach_end = 1;
- }
- break;
-
- case NT_CCLASS:
- {
- int i, z;
- CClassNode* cc = NCCLASS(node);
-
- /* no need to check ignore case. (setted in setup_tree()) */
-
- if (IS_NOT_NULL(cc->mbuf) || IS_NCCLASS_NOT(cc)) {
- OnigDistance min = ONIGENC_MBC_MINLEN(env->enc);
- OnigDistance max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
-
- set_mml(&opt->len, min, max);
- }
- else {
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- z = BITSET_AT(cc->bs, i);
- if ((z && !IS_NCCLASS_NOT(cc)) || (!z && IS_NCCLASS_NOT(cc))) {
- add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
- }
- }
- set_mml(&opt->len, 1, 1);
- }
- }
- break;
-
- case NT_CTYPE:
- {
- int i, min, max;
-
- max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
-
- if (max == 1) {
- min = 1;
-
- switch (NCTYPE(node)->ctype) {
- case ONIGENC_CTYPE_WORD:
- if (NCTYPE(node)->not != 0) {
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- if (! ONIGENC_IS_CODE_WORD(env->enc, i)) {
- add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
- }
- }
- }
- else {
- for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
- if (ONIGENC_IS_CODE_WORD(env->enc, i)) {
- add_char_opt_map_info(&opt->map, (UChar )i, env->enc);
- }
- }
- }
- break;
- }
- }
- else {
- min = ONIGENC_MBC_MINLEN(env->enc);
- }
- set_mml(&opt->len, min, max);
- }
- break;
-
- case NT_CANY:
- {
- OnigDistance min = ONIGENC_MBC_MINLEN(env->enc);
- OnigDistance max = ONIGENC_MBC_MAXLEN_DIST(env->enc);
- set_mml(&opt->len, min, max);
- }
- break;
-
- case NT_ANCHOR:
- switch (NANCHOR(node)->type) {
- case ANCHOR_BEGIN_BUF:
- case ANCHOR_BEGIN_POSITION:
- case ANCHOR_BEGIN_LINE:
- case ANCHOR_END_BUF:
- case ANCHOR_SEMI_END_BUF:
- case ANCHOR_END_LINE:
- add_opt_anc_info(&opt->anc, NANCHOR(node)->type);
- break;
-
- case ANCHOR_PREC_READ:
- {
- NodeOptInfo nopt;
-
- r = optimize_node_left(NANCHOR(node)->target, &nopt, env);
- if (r == 0) {
- if (nopt.exb.len > 0)
- copy_opt_exact_info(&opt->expr, &nopt.exb);
- else if (nopt.exm.len > 0)
- copy_opt_exact_info(&opt->expr, &nopt.exm);
-
- opt->expr.reach_end = 0;
-
- if (nopt.map.value > 0)
- copy_opt_map_info(&opt->map, &nopt.map);
- }
- }
- break;
-
- case ANCHOR_PREC_READ_NOT:
- case ANCHOR_LOOK_BEHIND: /* Sorry, I can't make use of it. */
- case ANCHOR_LOOK_BEHIND_NOT:
- break;
- }
- break;
-
- case NT_BREF:
- {
- int i;
- int* backs;
- OnigDistance min, max, tmin, tmax;
- Node** nodes = SCANENV_MEM_NODES(env->scan_env);
- BRefNode* br = NBREF(node);
-
- if (br->state & NST_RECURSION) {
- set_mml(&opt->len, 0, ONIG_INFINITE_DISTANCE);
- break;
- }
- backs = BACKREFS_P(br);
- r = get_min_match_length(nodes[backs[0]], &min, env->scan_env);
- if (r != 0) break;
- r = get_max_match_length(nodes[backs[0]], &max, env->scan_env);
- if (r != 0) break;
- for (i = 1; i < br->back_num; i++) {
- r = get_min_match_length(nodes[backs[i]], &tmin, env->scan_env);
- if (r != 0) break;
- r = get_max_match_length(nodes[backs[i]], &tmax, env->scan_env);
- if (r != 0) break;
- if (min > tmin) min = tmin;
- if (max < tmax) max = tmax;
- }
- if (r == 0) set_mml(&opt->len, min, max);
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- if (IS_CALL_RECURSION(NCALL(node)))
- set_mml(&opt->len, 0, ONIG_INFINITE_DISTANCE);
- else {
- OnigOptionType save = env->options;
- env->options = NENCLOSE(NCALL(node)->target)->option;
- r = optimize_node_left(NCALL(node)->target, opt, env);
- env->options = save;
- }
- break;
-#endif
-
- case NT_QTFR:
- {
- int i;
- OnigDistance min, max;
- NodeOptInfo nopt;
- QtfrNode* qn = NQTFR(node);
-
- r = optimize_node_left(qn->target, &nopt, env);
- if (r) break;
-
- if (qn->lower == 0 && IS_REPEAT_INFINITE(qn->upper)) {
- if (env->mmd.max == 0 &&
- NTYPE(qn->target) == NT_CANY && qn->greedy) {
- if (IS_MULTILINE(env->options))
- add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_ML);
- else
- add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR);
- }
- }
- else {
- if (qn->lower > 0) {
- copy_node_opt_info(opt, &nopt);
- if (nopt.exb.len > 0) {
- if (nopt.exb.reach_end) {
- for (i = 2; i < qn->lower &&
- ! is_full_opt_exact_info(&opt->exb); i++) {
- concat_opt_exact_info(&opt->exb, &nopt.exb, env->enc);
- }
- if (i < qn->lower) {
- opt->exb.reach_end = 0;
- }
- }
- }
-
- if (qn->lower != qn->upper) {
- opt->exb.reach_end = 0;
- opt->exm.reach_end = 0;
- }
- if (qn->lower > 1)
- opt->exm.reach_end = 0;
- }
- }
-
- min = distance_multiply(nopt.len.min, qn->lower);
- if (IS_REPEAT_INFINITE(qn->upper))
- max = (nopt.len.max > 0 ? ONIG_INFINITE_DISTANCE : 0);
- else
- max = distance_multiply(nopt.len.max, qn->upper);
-
- set_mml(&opt->len, min, max);
- }
- break;
-
- case NT_ENCLOSE:
- {
- EncloseNode* en = NENCLOSE(node);
-
- switch (en->type) {
- case ENCLOSE_OPTION:
- {
- OnigOptionType save = env->options;
-
- env->options = en->option;
- r = optimize_node_left(en->target, opt, env);
- env->options = save;
- }
- break;
-
- case ENCLOSE_MEMORY:
-#ifdef USE_SUBEXP_CALL
- en->opt_count++;
- if (en->opt_count > MAX_NODE_OPT_INFO_REF_COUNT) {
- OnigDistance min, max;
-
- min = 0;
- max = ONIG_INFINITE_DISTANCE;
- if (IS_ENCLOSE_MIN_FIXED(en)) min = en->min_len;
- if (IS_ENCLOSE_MAX_FIXED(en)) max = en->max_len;
- set_mml(&opt->len, min, max);
- }
- else
-#endif
- {
- r = optimize_node_left(en->target, opt, env);
-
- if (is_set_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_MASK)) {
- if (BIT_STATUS_AT(env->scan_env->backrefed_mem, en->regnum))
- remove_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_STAR_MASK);
- }
- }
- break;
-
- case ENCLOSE_STOP_BACKTRACK:
- r = optimize_node_left(en->target, opt, env);
- break;
- }
- }
- break;
-
- default:
-#ifdef ONIG_DEBUG
- fprintf(stderr, "optimize_node_left: undefined node type %d\n",
- NTYPE(node));
-#endif
- r = ONIGERR_TYPE_BUG;
- break;
- }
-
- return r;
-}
-
-static int
-set_optimize_exact_info(regex_t* reg, OptExactInfo* e)
-{
- int r;
-
- if (e->len == 0) return 0;
-
- if (e->ignore_case) {
- reg->exact = (UChar* )xmalloc(e->len);
- CHECK_NULL_RETURN_MEMERR(reg->exact);
- xmemcpy(reg->exact, e->s, e->len);
- reg->exact_end = reg->exact + e->len;
- reg->optimize = ONIG_OPTIMIZE_EXACT_IC;
- }
- else {
- int allow_reverse;
-
- reg->exact = str_dup(e->s, e->s + e->len);
- CHECK_NULL_RETURN_MEMERR(reg->exact);
- reg->exact_end = reg->exact + e->len;
-
- allow_reverse =
- ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);
-
- if (e->len >= 3 || (e->len >= 2 && allow_reverse)) {
- r = set_bm_skip(reg->exact, reg->exact_end, reg->enc,
- reg->map, &(reg->int_map));
- if (r) return r;
-
- reg->optimize = (allow_reverse != 0
- ? ONIG_OPTIMIZE_EXACT_BM : ONIG_OPTIMIZE_EXACT_BM_NOT_REV);
- }
- else {
- reg->optimize = ONIG_OPTIMIZE_EXACT;
- }
- }
-
- reg->dmin = e->mmd.min;
- reg->dmax = e->mmd.max;
-
- if (reg->dmin != ONIG_INFINITE_DISTANCE) {
- reg->threshold_len = reg->dmin + (reg->exact_end - reg->exact);
- }
-
- return 0;
-}
-
-static void
-set_optimize_map_info(regex_t* reg, OptMapInfo* m)
-{
- int i;
-
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
- reg->map[i] = m->map[i];
-
- reg->optimize = ONIG_OPTIMIZE_MAP;
- reg->dmin = m->mmd.min;
- reg->dmax = m->mmd.max;
-
- if (reg->dmin != ONIG_INFINITE_DISTANCE) {
- reg->threshold_len = reg->dmin + 1;
- }
-}
-
-static void
-set_sub_anchor(regex_t* reg, OptAncInfo* anc)
-{
- reg->sub_anchor |= anc->left_anchor & ANCHOR_BEGIN_LINE;
- reg->sub_anchor |= anc->right_anchor & ANCHOR_END_LINE;
-}
-
-#ifdef ONIG_DEBUG
-static void print_optimize_info(FILE* f, regex_t* reg);
-#endif
-
-static int
-set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)
-{
-
- int r;
- NodeOptInfo opt;
- OptEnv env;
-
- env.enc = reg->enc;
- env.options = reg->options;
- env.case_fold_flag = reg->case_fold_flag;
- env.scan_env = scan_env;
- clear_mml(&env.mmd);
-
- r = optimize_node_left(node, &opt, &env);
- if (r) return r;
-
- reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF |
- ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML);
-
- reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF);
-
- if (reg->anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)) {
- reg->anchor_dmin = opt.len.min;
- reg->anchor_dmax = opt.len.max;
- }
-
- if (opt.exb.len > 0 || opt.exm.len > 0) {
- select_opt_exact_info(reg->enc, &opt.exb, &opt.exm);
- if (opt.map.value > 0 &&
- comp_opt_exact_or_map_info(&opt.exb, &opt.map) > 0) {
- goto set_map;
- }
- else {
- r = set_optimize_exact_info(reg, &opt.exb);
- set_sub_anchor(reg, &opt.exb.anc);
- }
- }
- else if (opt.map.value > 0) {
- set_map:
- set_optimize_map_info(reg, &opt.map);
- set_sub_anchor(reg, &opt.map.anc);
- }
- else {
- reg->sub_anchor |= opt.anc.left_anchor & ANCHOR_BEGIN_LINE;
- if (opt.len.max == 0)
- reg->sub_anchor |= opt.anc.right_anchor & ANCHOR_END_LINE;
- }
-
-#if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH)
- print_optimize_info(stderr, reg);
-#endif
- return r;
-}
-
-static void
-clear_optimize_info(regex_t* reg)
-{
- reg->optimize = ONIG_OPTIMIZE_NONE;
- reg->anchor = 0;
- reg->anchor_dmin = 0;
- reg->anchor_dmax = 0;
- reg->sub_anchor = 0;
- reg->exact_end = (UChar* )NULL;
- reg->threshold_len = 0;
- if (IS_NOT_NULL(reg->exact)) {
- xfree(reg->exact);
- reg->exact = (UChar* )NULL;
- }
-}
-
-#ifdef ONIG_DEBUG
-
-static void print_enc_string(FILE* fp, OnigEncoding enc,
- const UChar *s, const UChar *end)
-{
- fprintf(fp, "\nPATTERN: /");
-
- if (ONIGENC_MBC_MINLEN(enc) > 1) {
- const UChar *p;
- OnigCodePoint code;
-
- p = s;
- while (p < end) {
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- if (code >= 0x80) {
- fprintf(fp, " 0x%04x ", (int )code);
- }
- else {
- fputc((int )code, fp);
- }
-
- p += enc_len(enc, p);
- }
- }
- else {
- while (s < end) {
- fputc((int )*s, fp);
- s++;
- }
- }
-
- fprintf(fp, "/\n");
-}
-
-static void
-print_distance_range(FILE* f, OnigDistance a, OnigDistance b)
-{
- if (a == ONIG_INFINITE_DISTANCE)
- fputs("inf", f);
- else
- fprintf(f, "(%u)", a);
-
- fputs("-", f);
-
- if (b == ONIG_INFINITE_DISTANCE)
- fputs("inf", f);
- else
- fprintf(f, "(%u)", b);
-}
-
-static void
-print_anchor(FILE* f, int anchor)
-{
- int q = 0;
-
- fprintf(f, "[");
-
- if (anchor & ANCHOR_BEGIN_BUF) {
- fprintf(f, "begin-buf");
- q = 1;
- }
- if (anchor & ANCHOR_BEGIN_LINE) {
- if (q) fprintf(f, ", ");
- q = 1;
- fprintf(f, "begin-line");
- }
- if (anchor & ANCHOR_BEGIN_POSITION) {
- if (q) fprintf(f, ", ");
- q = 1;
- fprintf(f, "begin-pos");
- }
- if (anchor & ANCHOR_END_BUF) {
- if (q) fprintf(f, ", ");
- q = 1;
- fprintf(f, "end-buf");
- }
- if (anchor & ANCHOR_SEMI_END_BUF) {
- if (q) fprintf(f, ", ");
- q = 1;
- fprintf(f, "semi-end-buf");
- }
- if (anchor & ANCHOR_END_LINE) {
- if (q) fprintf(f, ", ");
- q = 1;
- fprintf(f, "end-line");
- }
- if (anchor & ANCHOR_ANYCHAR_STAR) {
- if (q) fprintf(f, ", ");
- q = 1;
- fprintf(f, "anychar-star");
- }
- if (anchor & ANCHOR_ANYCHAR_STAR_ML) {
- if (q) fprintf(f, ", ");
- fprintf(f, "anychar-star-pl");
- }
-
- fprintf(f, "]");
-}
-
-static void
-print_optimize_info(FILE* f, regex_t* reg)
-{
- static const char* on[] = { "NONE", "EXACT", "EXACT_BM", "EXACT_BM_NOT_REV",
- "EXACT_IC", "MAP" };
-
- fprintf(f, "optimize: %s\n", on[reg->optimize]);
- fprintf(f, " anchor: "); print_anchor(f, reg->anchor);
- if ((reg->anchor & ANCHOR_END_BUF_MASK) != 0)
- print_distance_range(f, reg->anchor_dmin, reg->anchor_dmax);
- fprintf(f, "\n");
-
- if (reg->optimize) {
- fprintf(f, " sub anchor: "); print_anchor(f, reg->sub_anchor);
- fprintf(f, "\n");
- }
- fprintf(f, "\n");
-
- if (reg->exact) {
- UChar *p;
- fprintf(f, "exact: [");
- for (p = reg->exact; p < reg->exact_end; p++) {
- fputc(*p, f);
- }
- fprintf(f, "]: length: %d\n", (reg->exact_end - reg->exact));
- }
- else if (reg->optimize & ONIG_OPTIMIZE_MAP) {
- int c, i, n = 0;
-
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
- if (reg->map[i]) n++;
-
- fprintf(f, "map: n=%d\n", n);
- if (n > 0) {
- c = 0;
- fputc('[', f);
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {
- if (reg->map[i] != 0) {
- if (c > 0) fputs(", ", f);
- c++;
- if (ONIGENC_MBC_MAXLEN(reg->enc) == 1 &&
- ONIGENC_IS_CODE_PRINT(reg->enc, (OnigCodePoint )i))
- fputc(i, f);
- else
- fprintf(f, "%d", i);
- }
- }
- fprintf(f, "]\n");
- }
- }
-}
-#endif /* ONIG_DEBUG */
-
-
-static void
-onig_free_body(regex_t* reg)
-{
- if (IS_NOT_NULL(reg->p)) xfree(reg->p);
- if (IS_NOT_NULL(reg->exact)) xfree(reg->exact);
- if (IS_NOT_NULL(reg->int_map)) xfree(reg->int_map);
- if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward);
- if (IS_NOT_NULL(reg->repeat_range)) xfree(reg->repeat_range);
- if (IS_NOT_NULL(reg->chain)) onig_free(reg->chain);
-
-#ifdef USE_NAMED_GROUP
- onig_names_free(reg);
-#endif
-}
-
-extern void
-onig_free(regex_t* reg)
-{
- if (IS_NOT_NULL(reg)) {
- onig_free_body(reg);
- xfree(reg);
- }
-}
-
-#define REGEX_TRANSFER(to,from) do {\
- (to)->state = ONIG_STATE_MODIFY;\
- onig_free_body(to);\
- xmemcpy(to, from, sizeof(regex_t));\
- xfree(from);\
-} while (0)
-
-extern void
-onig_transfer(regex_t* to, regex_t* from)
-{
- THREAD_ATOMIC_START;
- REGEX_TRANSFER(to, from);
- THREAD_ATOMIC_END;
-}
-
-#define REGEX_CHAIN_HEAD(reg) do {\
- while (IS_NOT_NULL((reg)->chain)) {\
- (reg) = (reg)->chain;\
- }\
-} while (0)
-
-extern void
-onig_chain_link_add(regex_t* to, regex_t* add)
-{
- THREAD_ATOMIC_START;
- REGEX_CHAIN_HEAD(to);
- to->chain = add;
- THREAD_ATOMIC_END;
-}
-
-extern void
-onig_chain_reduce(regex_t* reg)
-{
- regex_t *head, *prev;
-
- prev = reg;
- head = prev->chain;
- if (IS_NOT_NULL(head)) {
- reg->state = ONIG_STATE_MODIFY;
- while (IS_NOT_NULL(head->chain)) {
- prev = head;
- head = head->chain;
- }
- prev->chain = (regex_t* )NULL;
- REGEX_TRANSFER(reg, head);
- }
-}
-
-#if 0
-extern int
-onig_clone(regex_t** to, regex_t* from)
-{
- int r, size;
- regex_t* reg;
-
-#ifdef USE_MULTI_THREAD_SYSTEM
- if (ONIG_STATE(from) >= ONIG_STATE_NORMAL) {
- ONIG_STATE_INC(from);
- if (IS_NOT_NULL(from->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
- onig_chain_reduce(from);
- ONIG_STATE_INC(from);
- }
- }
- else {
- int n = 0;
- while (ONIG_STATE(from) < ONIG_STATE_NORMAL) {
- if (++n > THREAD_PASS_LIMIT_COUNT)
- return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT;
- THREAD_PASS;
- }
- ONIG_STATE_INC(from);
- }
-#endif /* USE_MULTI_THREAD_SYSTEM */
-
- r = onig_alloc_init(&reg, ONIG_OPTION_NONE, ONIGENC_CASE_FOLD_DEFAULT,
- from->enc, ONIG_SYNTAX_DEFAULT);
- if (r != 0) {
- ONIG_STATE_DEC(from);
- return r;
- }
-
- xmemcpy(reg, from, sizeof(onig_t));
- reg->chain = (regex_t* )NULL;
- reg->state = ONIG_STATE_NORMAL;
-
- if (from->p) {
- reg->p = (UChar* )xmalloc(reg->alloc);
- if (IS_NULL(reg->p)) goto mem_error;
- xmemcpy(reg->p, from->p, reg->alloc);
- }
-
- if (from->exact) {
- reg->exact = (UChar* )xmalloc(from->exact_end - from->exact);
- if (IS_NULL(reg->exact)) goto mem_error;
- reg->exact_end = reg->exact + (from->exact_end - from->exact);
- xmemcpy(reg->exact, from->exact, reg->exact_end - reg->exact);
- }
-
- if (from->int_map) {
- size = sizeof(int) * ONIG_CHAR_TABLE_SIZE;
- reg->int_map = (int* )xmalloc(size);
- if (IS_NULL(reg->int_map)) goto mem_error;
- xmemcpy(reg->int_map, from->int_map, size);
- }
-
- if (from->int_map_backward) {
- size = sizeof(int) * ONIG_CHAR_TABLE_SIZE;
- reg->int_map_backward = (int* )xmalloc(size);
- if (IS_NULL(reg->int_map_backward)) goto mem_error;
- xmemcpy(reg->int_map_backward, from->int_map_backward, size);
- }
-
-#ifdef USE_NAMED_GROUP
- reg->name_table = names_clone(from); /* names_clone is not implemented */
-#endif
-
- ONIG_STATE_DEC(from);
- *to = reg;
- return 0;
-
- mem_error:
- ONIG_STATE_DEC(from);
- return ONIGERR_MEMORY;
-}
-#endif
-
-#ifdef ONIG_DEBUG
-static void print_compiled_byte_code_list P_((FILE* f, regex_t* reg));
-#endif
-#ifdef ONIG_DEBUG_PARSE_TREE
-static void print_tree P_((FILE* f, Node* node));
-#endif
-
-extern int
-onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
- OnigErrorInfo* einfo)
-{
-#define COMPILE_INIT_SIZE 20
-
- int r, init_size;
- Node* root;
- ScanEnv scan_env;
-#ifdef USE_SUBEXP_CALL
- UnsetAddrList uslist;
-#endif
-
- reg->state = ONIG_STATE_COMPILING;
-
-#ifdef ONIG_DEBUG
- print_enc_string(stderr, reg->enc, pattern, pattern_end);
-#endif
-
- if (reg->alloc == 0) {
- init_size = (pattern_end - pattern) * 2;
- if (init_size <= 0) init_size = COMPILE_INIT_SIZE;
- r = BBUF_INIT(reg, init_size);
- if (r != 0) goto end;
- }
- else
- reg->used = 0;
-
- reg->num_mem = 0;
- reg->num_repeat = 0;
- reg->num_null_check = 0;
- reg->repeat_range_alloc = 0;
- reg->repeat_range = (OnigRepeatRange* )NULL;
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- reg->num_comb_exp_check = 0;
-#endif
-
- r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env);
- if (r != 0) goto err;
-
-#ifdef USE_NAMED_GROUP
- /* mixed use named group and no-named group */
- if (scan_env.num_named > 0 &&
- IS_SYNTAX_BV(scan_env.syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
- !ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_CAPTURE_GROUP)) {
- if (scan_env.num_named != scan_env.num_mem)
- r = disable_noname_group_capture(&root, reg, &scan_env);
- else
- r = numbered_ref_check(root);
-
- if (r != 0) goto err;
- }
-#endif
-
-#ifdef USE_SUBEXP_CALL
- if (scan_env.num_call > 0) {
- r = unset_addr_list_init(&uslist, scan_env.num_call);
- if (r != 0) goto err;
- scan_env.unset_addr_list = &uslist;
- r = setup_subexp_call(root, &scan_env);
- if (r != 0) goto err_unset;
- r = subexp_recursive_check_trav(root, &scan_env);
- if (r < 0) goto err_unset;
- r = subexp_inf_recursive_check_trav(root, &scan_env);
- if (r != 0) goto err_unset;
-
- reg->num_call = scan_env.num_call;
- }
- else
- reg->num_call = 0;
-#endif
-
- r = setup_tree(root, reg, 0, &scan_env);
- if (r != 0) goto err_unset;
-
-#ifdef ONIG_DEBUG_PARSE_TREE
- print_tree(stderr, root);
-#endif
-
- reg->capture_history = scan_env.capture_history;
- reg->bt_mem_start = scan_env.bt_mem_start;
- reg->bt_mem_start |= reg->capture_history;
- if (IS_FIND_CONDITION(reg->options))
- BIT_STATUS_ON_ALL(reg->bt_mem_end);
- else {
- reg->bt_mem_end = scan_env.bt_mem_end;
- reg->bt_mem_end |= reg->capture_history;
- }
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- if (scan_env.backrefed_mem == 0
-#ifdef USE_SUBEXP_CALL
- || scan_env.num_call == 0
-#endif
- ) {
- setup_comb_exp_check(root, 0, &scan_env);
-#ifdef USE_SUBEXP_CALL
- if (scan_env.has_recursion != 0) {
- scan_env.num_comb_exp_check = 0;
- }
- else
-#endif
- if (scan_env.comb_exp_max_regnum > 0) {
- int i;
- for (i = 1; i <= scan_env.comb_exp_max_regnum; i++) {
- if (BIT_STATUS_AT(scan_env.backrefed_mem, i) != 0) {
- scan_env.num_comb_exp_check = 0;
- break;
- }
- }
- }
- }
-
- reg->num_comb_exp_check = scan_env.num_comb_exp_check;
-#endif
-
- clear_optimize_info(reg);
-#ifndef ONIG_DONT_OPTIMIZE
- r = set_optimize_info_from_tree(root, reg, &scan_env);
- if (r != 0) goto err_unset;
-#endif
-
- if (IS_NOT_NULL(scan_env.mem_nodes_dynamic)) {
- xfree(scan_env.mem_nodes_dynamic);
- scan_env.mem_nodes_dynamic = (Node** )NULL;
- }
-
- r = compile_tree(root, reg);
- if (r == 0) {
- r = add_opcode(reg, OP_END);
-#ifdef USE_SUBEXP_CALL
- if (scan_env.num_call > 0) {
- r = unset_addr_list_fix(&uslist, reg);
- unset_addr_list_end(&uslist);
- if (r) goto err;
- }
-#endif
-
- if ((reg->num_repeat != 0) || (reg->bt_mem_end != 0))
- reg->stack_pop_level = STACK_POP_LEVEL_ALL;
- else {
- if (reg->bt_mem_start != 0)
- reg->stack_pop_level = STACK_POP_LEVEL_MEM_START;
- else
- reg->stack_pop_level = STACK_POP_LEVEL_FREE;
- }
- }
-#ifdef USE_SUBEXP_CALL
- else if (scan_env.num_call > 0) {
- unset_addr_list_end(&uslist);
- }
-#endif
- onig_node_free(root);
-
-#ifdef ONIG_DEBUG_COMPILE
-#ifdef USE_NAMED_GROUP
- onig_print_names(stderr, reg);
-#endif
- print_compiled_byte_code_list(stderr, reg);
-#endif
-
- end:
- reg->state = ONIG_STATE_NORMAL;
- return r;
-
- err_unset:
-#ifdef USE_SUBEXP_CALL
- if (scan_env.num_call > 0) {
- unset_addr_list_end(&uslist);
- }
-#endif
- err:
- if (IS_NOT_NULL(scan_env.error)) {
- if (IS_NOT_NULL(einfo)) {
- einfo->enc = scan_env.enc;
- einfo->par = scan_env.error;
- einfo->par_end = scan_env.error_end;
- }
- }
-
- onig_node_free(root);
- if (IS_NOT_NULL(scan_env.mem_nodes_dynamic))
- xfree(scan_env.mem_nodes_dynamic);
- return r;
-}
-
-#ifdef USE_RECOMPILE_API
-extern int
-onig_recompile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
- OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
- OnigErrorInfo* einfo)
-{
- int r;
- regex_t *new_reg;
-
- r = onig_new(&new_reg, pattern, pattern_end, option, enc, syntax, einfo);
- if (r) return r;
- if (ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
- onig_transfer(reg, new_reg);
- }
- else {
- onig_chain_link_add(reg, new_reg);
- }
- return 0;
-}
-#endif
-
-static int onig_inited = 0;
-
-extern int
-onig_alloc_init(regex_t** reg, OnigOptionType option,
- OnigCaseFoldType case_fold_flag,
- OnigEncoding enc, OnigSyntaxType* syntax)
-{
- if (! onig_inited)
- onig_init();
-
- if (ONIGENC_IS_UNDEF(enc))
- return ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED;
-
- if ((option & (ONIG_OPTION_DONT_CAPTURE_GROUP|ONIG_OPTION_CAPTURE_GROUP))
- == (ONIG_OPTION_DONT_CAPTURE_GROUP|ONIG_OPTION_CAPTURE_GROUP)) {
- return ONIGERR_INVALID_COMBINATION_OF_OPTIONS;
- }
-
- *reg = (regex_t* )xmalloc(sizeof(regex_t));
- if (IS_NULL(*reg)) return ONIGERR_MEMORY;
- (*reg)->state = ONIG_STATE_MODIFY;
-
- if ((option & ONIG_OPTION_NEGATE_SINGLELINE) != 0) {
- option |= syntax->options;
- option &= ~ONIG_OPTION_SINGLELINE;
- }
- else
- option |= syntax->options;
-
- (*reg)->enc = enc;
- (*reg)->options = option;
- (*reg)->syntax = syntax;
- (*reg)->optimize = 0;
- (*reg)->exact = (UChar* )NULL;
- (*reg)->int_map = (int* )NULL;
- (*reg)->int_map_backward = (int* )NULL;
- (*reg)->chain = (regex_t* )NULL;
-
- (*reg)->p = (UChar* )NULL;
- (*reg)->alloc = 0;
- (*reg)->used = 0;
- (*reg)->name_table = (void* )NULL;
-
- (*reg)->case_fold_flag = case_fold_flag;
- return 0;
-}
-
-extern int
-onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
- OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
- OnigErrorInfo* einfo)
-{
- int r;
-
- if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
-
- r = onig_alloc_init(reg, option, ONIGENC_CASE_FOLD_DEFAULT,
- enc, syntax);
- if (r) return r;
-
- r = onig_compile(*reg, pattern, pattern_end, einfo);
- if (r) {
- onig_free(*reg);
- *reg = NULL;
- }
- return r;
-}
-
-extern int
-onig_init(void)
-{
- if (onig_inited != 0)
- return 0;
-
- THREAD_SYSTEM_INIT;
- THREAD_ATOMIC_START;
-
- onig_inited = 1;
-
- onigenc_init();
- /* onigenc_set_default_caseconv_table((UChar* )0); */
-
-#ifdef ONIG_DEBUG_STATISTICS
- onig_statistics_init();
-#endif
-
- THREAD_ATOMIC_END;
- return 0;
-}
-
-
-extern int
-onig_end(void)
-{
- extern int onig_free_shared_cclass_table(void);
-
- THREAD_ATOMIC_START;
-
-#ifdef ONIG_DEBUG_STATISTICS
- onig_print_statistics(stderr);
-#endif
-
-#ifdef USE_SHARED_CCLASS_TABLE
- onig_free_shared_cclass_table();
-#endif
-
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
- onig_free_node_list();
-#endif
-
- onig_inited = 0;
-
- THREAD_ATOMIC_END;
- THREAD_SYSTEM_END;
- return 0;
-}
-
-extern int
-onig_is_in_code_range(const UChar* p, OnigCodePoint code)
-{
- OnigCodePoint n, *data;
- OnigCodePoint low, high, x;
-
- GET_CODE_POINT(n, p);
- data = (OnigCodePoint* )p;
- data++;
-
- for (low = 0, high = n; low < high; ) {
- x = (low + high) >> 1;
- if (code > data[x * 2 + 1])
- low = x + 1;
- else
- high = x;
- }
-
- return ((low < n && code >= data[low * 2]) ? 1 : 0);
-}
-
-extern int
-onig_is_code_in_cc_len(int enclen, OnigCodePoint code, CClassNode* cc)
-{
- int found;
-
- if (enclen > 1 || (code >= SINGLE_BYTE_SIZE)) {
- if (IS_NULL(cc->mbuf)) {
- found = 0;
- }
- else {
- found = (onig_is_in_code_range(cc->mbuf->p, code) != 0 ? 1 : 0);
- }
- }
- else {
- found = (BITSET_AT(cc->bs, code) == 0 ? 0 : 1);
- }
-
- if (IS_NCCLASS_NOT(cc))
- return !found;
- else
- return found;
-}
-
-extern int
-onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc)
-{
- int len;
-
- if (ONIGENC_MBC_MINLEN(enc) > 1) {
- len = 2;
- }
- else {
- len = ONIGENC_CODE_TO_MBCLEN(enc, code);
- }
- return onig_is_code_in_cc_len(len, code, cc);
-}
-
-
-#ifdef ONIG_DEBUG
-
-/* arguments type */
-#define ARG_SPECIAL -1
-#define ARG_NON 0
-#define ARG_RELADDR 1
-#define ARG_ABSADDR 2
-#define ARG_LENGTH 3
-#define ARG_MEMNUM 4
-#define ARG_OPTION 5
-#define ARG_STATE_CHECK 6
-
-OnigOpInfoType OnigOpInfo[] = {
- { OP_FINISH, "finish", ARG_NON },
- { OP_END, "end", ARG_NON },
- { OP_EXACT1, "exact1", ARG_SPECIAL },
- { OP_EXACT2, "exact2", ARG_SPECIAL },
- { OP_EXACT3, "exact3", ARG_SPECIAL },
- { OP_EXACT4, "exact4", ARG_SPECIAL },
- { OP_EXACT5, "exact5", ARG_SPECIAL },
- { OP_EXACTN, "exactn", ARG_SPECIAL },
- { OP_EXACTMB2N1, "exactmb2-n1", ARG_SPECIAL },
- { OP_EXACTMB2N2, "exactmb2-n2", ARG_SPECIAL },
- { OP_EXACTMB2N3, "exactmb2-n3", ARG_SPECIAL },
- { OP_EXACTMB2N, "exactmb2-n", ARG_SPECIAL },
- { OP_EXACTMB3N, "exactmb3n" , ARG_SPECIAL },
- { OP_EXACTMBN, "exactmbn", ARG_SPECIAL },
- { OP_EXACT1_IC, "exact1-ic", ARG_SPECIAL },
- { OP_EXACTN_IC, "exactn-ic", ARG_SPECIAL },
- { OP_CCLASS, "cclass", ARG_SPECIAL },
- { OP_CCLASS_MB, "cclass-mb", ARG_SPECIAL },
- { OP_CCLASS_MIX, "cclass-mix", ARG_SPECIAL },
- { OP_CCLASS_NOT, "cclass-not", ARG_SPECIAL },
- { OP_CCLASS_MB_NOT, "cclass-mb-not", ARG_SPECIAL },
- { OP_CCLASS_MIX_NOT, "cclass-mix-not", ARG_SPECIAL },
- { OP_CCLASS_NODE, "cclass-node", ARG_SPECIAL },
- { OP_ANYCHAR, "anychar", ARG_NON },
- { OP_ANYCHAR_ML, "anychar-ml", ARG_NON },
- { OP_ANYCHAR_STAR, "anychar*", ARG_NON },
- { OP_ANYCHAR_ML_STAR, "anychar-ml*", ARG_NON },
- { OP_ANYCHAR_STAR_PEEK_NEXT, "anychar*-peek-next", ARG_SPECIAL },
- { OP_ANYCHAR_ML_STAR_PEEK_NEXT, "anychar-ml*-peek-next", ARG_SPECIAL },
- { OP_WORD, "word", ARG_NON },
- { OP_NOT_WORD, "not-word", ARG_NON },
- { OP_WORD_BOUND, "word-bound", ARG_NON },
- { OP_NOT_WORD_BOUND, "not-word-bound", ARG_NON },
- { OP_WORD_BEGIN, "word-begin", ARG_NON },
- { OP_WORD_END, "word-end", ARG_NON },
- { OP_BEGIN_BUF, "begin-buf", ARG_NON },
- { OP_END_BUF, "end-buf", ARG_NON },
- { OP_BEGIN_LINE, "begin-line", ARG_NON },
- { OP_END_LINE, "end-line", ARG_NON },
- { OP_SEMI_END_BUF, "semi-end-buf", ARG_NON },
- { OP_BEGIN_POSITION, "begin-position", ARG_NON },
- { OP_BACKREF1, "backref1", ARG_NON },
- { OP_BACKREF2, "backref2", ARG_NON },
- { OP_BACKREFN, "backrefn", ARG_MEMNUM },
- { OP_BACKREFN_IC, "backrefn-ic", ARG_SPECIAL },
- { OP_BACKREF_MULTI, "backref_multi", ARG_SPECIAL },
- { OP_BACKREF_MULTI_IC, "backref_multi-ic", ARG_SPECIAL },
- { OP_BACKREF_AT_LEVEL, "backref_at_level", ARG_SPECIAL },
- { OP_MEMORY_START_PUSH, "mem-start-push", ARG_MEMNUM },
- { OP_MEMORY_START, "mem-start", ARG_MEMNUM },
- { OP_MEMORY_END_PUSH, "mem-end-push", ARG_MEMNUM },
- { OP_MEMORY_END_PUSH_REC, "mem-end-push-rec", ARG_MEMNUM },
- { OP_MEMORY_END, "mem-end", ARG_MEMNUM },
- { OP_MEMORY_END_REC, "mem-end-rec", ARG_MEMNUM },
- { OP_SET_OPTION_PUSH, "set-option-push", ARG_OPTION },
- { OP_SET_OPTION, "set-option", ARG_OPTION },
- { OP_FAIL, "fail", ARG_NON },
- { OP_JUMP, "jump", ARG_RELADDR },
- { OP_PUSH, "push", ARG_RELADDR },
- { OP_POP, "pop", ARG_NON },
- { OP_PUSH_OR_JUMP_EXACT1, "push-or-jump-e1", ARG_SPECIAL },
- { OP_PUSH_IF_PEEK_NEXT, "push-if-peek-next", ARG_SPECIAL },
- { OP_REPEAT, "repeat", ARG_SPECIAL },
- { OP_REPEAT_NG, "repeat-ng", ARG_SPECIAL },
- { OP_REPEAT_INC, "repeat-inc", ARG_MEMNUM },
- { OP_REPEAT_INC_NG, "repeat-inc-ng", ARG_MEMNUM },
- { OP_REPEAT_INC_SG, "repeat-inc-sg", ARG_MEMNUM },
- { OP_REPEAT_INC_NG_SG, "repeat-inc-ng-sg", ARG_MEMNUM },
- { OP_NULL_CHECK_START, "null-check-start", ARG_MEMNUM },
- { OP_NULL_CHECK_END, "null-check-end", ARG_MEMNUM },
- { OP_NULL_CHECK_END_MEMST,"null-check-end-memst", ARG_MEMNUM },
- { OP_NULL_CHECK_END_MEMST_PUSH,"null-check-end-memst-push", ARG_MEMNUM },
- { OP_PUSH_POS, "push-pos", ARG_NON },
- { OP_POP_POS, "pop-pos", ARG_NON },
- { OP_PUSH_POS_NOT, "push-pos-not", ARG_RELADDR },
- { OP_FAIL_POS, "fail-pos", ARG_NON },
- { OP_PUSH_STOP_BT, "push-stop-bt", ARG_NON },
- { OP_POP_STOP_BT, "pop-stop-bt", ARG_NON },
- { OP_LOOK_BEHIND, "look-behind", ARG_SPECIAL },
- { OP_PUSH_LOOK_BEHIND_NOT, "push-look-behind-not", ARG_SPECIAL },
- { OP_FAIL_LOOK_BEHIND_NOT, "fail-look-behind-not", ARG_NON },
- { OP_CALL, "call", ARG_ABSADDR },
- { OP_RETURN, "return", ARG_NON },
- { OP_STATE_CHECK_PUSH, "state-check-push", ARG_SPECIAL },
- { OP_STATE_CHECK_PUSH_OR_JUMP, "state-check-push-or-jump", ARG_SPECIAL },
- { OP_STATE_CHECK, "state-check", ARG_STATE_CHECK },
- { OP_STATE_CHECK_ANYCHAR_STAR, "state-check-anychar*", ARG_STATE_CHECK },
- { OP_STATE_CHECK_ANYCHAR_ML_STAR,
- "state-check-anychar-ml*", ARG_STATE_CHECK },
- { -1, "", ARG_NON }
-};
-
-static char*
-op2name(int opcode)
-{
- int i;
-
- for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
- if (opcode == OnigOpInfo[i].opcode)
- return OnigOpInfo[i].name;
- }
- return "";
-}
-
-static int
-op2arg_type(int opcode)
-{
- int i;
-
- for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
- if (opcode == OnigOpInfo[i].opcode)
- return OnigOpInfo[i].arg_type;
- }
- return ARG_SPECIAL;
-}
-
-static void
-Indent(FILE* f, int indent)
-{
- int i;
- for (i = 0; i < indent; i++) putc(' ', f);
-}
-
-static void
-p_string(FILE* f, int len, UChar* s)
-{
- fputs(":", f);
- while (len-- > 0) { fputc(*s++, f); }
-}
-
-static void
-p_len_string(FILE* f, LengthType len, int mb_len, UChar* s)
-{
- int x = len * mb_len;
-
- fprintf(f, ":%d:", len);
- while (x-- > 0) { fputc(*s++, f); }
-}
-
-extern void
-onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
- OnigEncoding enc)
-{
- int i, n, arg_type;
- RelAddrType addr;
- LengthType len;
- MemNumType mem;
- StateCheckNumType scn;
- OnigCodePoint code;
- UChar *q;
-
- fprintf(f, "[%s", op2name(*bp));
- arg_type = op2arg_type(*bp);
- if (arg_type != ARG_SPECIAL) {
- bp++;
- switch (arg_type) {
- case ARG_NON:
- break;
- case ARG_RELADDR:
- GET_RELADDR_INC(addr, bp);
- fprintf(f, ":(%d)", addr);
- break;
- case ARG_ABSADDR:
- GET_ABSADDR_INC(addr, bp);
- fprintf(f, ":(%d)", addr);
- break;
- case ARG_LENGTH:
- GET_LENGTH_INC(len, bp);
- fprintf(f, ":%d", len);
- break;
- case ARG_MEMNUM:
- mem = *((MemNumType* )bp);
- bp += SIZE_MEMNUM;
- fprintf(f, ":%d", mem);
- break;
- case ARG_OPTION:
- {
- OnigOptionType option = *((OnigOptionType* )bp);
- bp += SIZE_OPTION;
- fprintf(f, ":%d", option);
- }
- break;
-
- case ARG_STATE_CHECK:
- scn = *((StateCheckNumType* )bp);
- bp += SIZE_STATE_CHECK_NUM;
- fprintf(f, ":%d", scn);
- break;
- }
- }
- else {
- switch (*bp++) {
- case OP_EXACT1:
- case OP_ANYCHAR_STAR_PEEK_NEXT:
- case OP_ANYCHAR_ML_STAR_PEEK_NEXT:
- p_string(f, 1, bp++); break;
- case OP_EXACT2:
- p_string(f, 2, bp); bp += 2; break;
- case OP_EXACT3:
- p_string(f, 3, bp); bp += 3; break;
- case OP_EXACT4:
- p_string(f, 4, bp); bp += 4; break;
- case OP_EXACT5:
- p_string(f, 5, bp); bp += 5; break;
- case OP_EXACTN:
- GET_LENGTH_INC(len, bp);
- p_len_string(f, len, 1, bp);
- bp += len;
- break;
-
- case OP_EXACTMB2N1:
- p_string(f, 2, bp); bp += 2; break;
- case OP_EXACTMB2N2:
- p_string(f, 4, bp); bp += 4; break;
- case OP_EXACTMB2N3:
- p_string(f, 6, bp); bp += 6; break;
- case OP_EXACTMB2N:
- GET_LENGTH_INC(len, bp);
- p_len_string(f, len, 2, bp);
- bp += len * 2;
- break;
- case OP_EXACTMB3N:
- GET_LENGTH_INC(len, bp);
- p_len_string(f, len, 3, bp);
- bp += len * 3;
- break;
- case OP_EXACTMBN:
- {
- int mb_len;
-
- GET_LENGTH_INC(mb_len, bp);
- GET_LENGTH_INC(len, bp);
- fprintf(f, ":%d:%d:", mb_len, len);
- n = len * mb_len;
- while (n-- > 0) { fputc(*bp++, f); }
- }
- break;
-
- case OP_EXACT1_IC:
- len = enc_len(enc, bp);
- p_string(f, len, bp);
- bp += len;
- break;
- case OP_EXACTN_IC:
- GET_LENGTH_INC(len, bp);
- p_len_string(f, len, 1, bp);
- bp += len;
- break;
-
- case OP_CCLASS:
- n = bitset_on_num((BitSetRef )bp);
- bp += SIZE_BITSET;
- fprintf(f, ":%d", n);
- break;
-
- case OP_CCLASS_NOT:
- n = bitset_on_num((BitSetRef )bp);
- bp += SIZE_BITSET;
- fprintf(f, ":%d", n);
- break;
-
- case OP_CCLASS_MB:
- case OP_CCLASS_MB_NOT:
- GET_LENGTH_INC(len, bp);
- q = bp;
-#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
- ALIGNMENT_RIGHT(q);
-#endif
- GET_CODE_POINT(code, q);
- bp += len;
- fprintf(f, ":%d:%d", (int )code, len);
- break;
-
- case OP_CCLASS_MIX:
- case OP_CCLASS_MIX_NOT:
- n = bitset_on_num((BitSetRef )bp);
- bp += SIZE_BITSET;
- GET_LENGTH_INC(len, bp);
- q = bp;
-#ifndef PLATFORM_UNALIGNED_WORD_ACCESS
- ALIGNMENT_RIGHT(q);
-#endif
- GET_CODE_POINT(code, q);
- bp += len;
- fprintf(f, ":%d:%d:%d", n, (int )code, len);
- break;
-
- case OP_CCLASS_NODE:
- {
- CClassNode *cc;
-
- GET_POINTER_INC(cc, bp);
- n = bitset_on_num(cc->bs);
- fprintf(f, ":%u:%d", (unsigned int )cc, n);
- }
- break;
-
- case OP_BACKREFN_IC:
- mem = *((MemNumType* )bp);
- bp += SIZE_MEMNUM;
- fprintf(f, ":%d", mem);
- break;
-
- case OP_BACKREF_MULTI_IC:
- case OP_BACKREF_MULTI:
- fputs(" ", f);
- GET_LENGTH_INC(len, bp);
- for (i = 0; i < len; i++) {
- GET_MEMNUM_INC(mem, bp);
- if (i > 0) fputs(", ", f);
- fprintf(f, "%d", mem);
- }
- break;
-
- case OP_BACKREF_AT_LEVEL:
- {
- OnigOptionType option;
- LengthType level;
-
- GET_OPTION_INC(option, bp);
- fprintf(f, ":%d", option);
- GET_LENGTH_INC(level, bp);
- fprintf(f, ":%d", level);
-
- fputs(" ", f);
- GET_LENGTH_INC(len, bp);
- for (i = 0; i < len; i++) {
- GET_MEMNUM_INC(mem, bp);
- if (i > 0) fputs(", ", f);
- fprintf(f, "%d", mem);
- }
- }
- break;
-
- case OP_REPEAT:
- case OP_REPEAT_NG:
- {
- mem = *((MemNumType* )bp);
- bp += SIZE_MEMNUM;
- addr = *((RelAddrType* )bp);
- bp += SIZE_RELADDR;
- fprintf(f, ":%d:%d", mem, addr);
- }
- break;
-
- case OP_PUSH_OR_JUMP_EXACT1:
- case OP_PUSH_IF_PEEK_NEXT:
- addr = *((RelAddrType* )bp);
- bp += SIZE_RELADDR;
- fprintf(f, ":(%d)", addr);
- p_string(f, 1, bp);
- bp += 1;
- break;
-
- case OP_LOOK_BEHIND:
- GET_LENGTH_INC(len, bp);
- fprintf(f, ":%d", len);
- break;
-
- case OP_PUSH_LOOK_BEHIND_NOT:
- GET_RELADDR_INC(addr, bp);
- GET_LENGTH_INC(len, bp);
- fprintf(f, ":%d:(%d)", len, addr);
- break;
-
- case OP_STATE_CHECK_PUSH:
- case OP_STATE_CHECK_PUSH_OR_JUMP:
- scn = *((StateCheckNumType* )bp);
- bp += SIZE_STATE_CHECK_NUM;
- addr = *((RelAddrType* )bp);
- bp += SIZE_RELADDR;
- fprintf(f, ":%d:(%d)", scn, addr);
- break;
-
- default:
- fprintf(stderr, "onig_print_compiled_byte_code: undefined code %d\n",
- *--bp);
- }
- }
- fputs("]", f);
- if (nextp) *nextp = bp;
-}
-
-static void
-print_compiled_byte_code_list(FILE* f, regex_t* reg)
-{
- int ncode;
- UChar* bp = reg->p;
- UChar* end = reg->p + reg->used;
-
- fprintf(f, "code length: %d\n", reg->used);
-
- ncode = 0;
- while (bp < end) {
- ncode++;
- if (bp > reg->p) {
- if (ncode % 5 == 0)
- fprintf(f, "\n");
- else
- fputs(" ", f);
- }
- onig_print_compiled_byte_code(f, bp, &bp, reg->enc);
- }
-
- fprintf(f, "\n");
-}
-
-static void
-print_indent_tree(FILE* f, Node* node, int indent)
-{
- int i, type;
- int add = 3;
- UChar* p;
-
- Indent(f, indent);
- if (IS_NULL(node)) {
- fprintf(f, "ERROR: null node!!!\n");
- exit (0);
- }
-
- type = NTYPE(node);
- switch (type) {
- case NT_LIST:
- case NT_ALT:
- if (NTYPE(node) == NT_LIST)
- fprintf(f, "<list:%x>\n", (int )node);
- else
- fprintf(f, "<alt:%x>\n", (int )node);
-
- print_indent_tree(f, NCAR(node), indent + add);
- while (IS_NOT_NULL(node = NCDR(node))) {
- if (NTYPE(node) != type) {
- fprintf(f, "ERROR: list/alt right is not a cons. %d\n", NTYPE(node));
- exit(0);
- }
- print_indent_tree(f, NCAR(node), indent + add);
- }
- break;
-
- case NT_STR:
- fprintf(f, "<string%s:%x>",
- (NSTRING_IS_RAW(node) ? "-raw" : ""), (int )node);
- for (p = NSTR(node)->s; p < NSTR(node)->end; p++) {
- if (*p >= 0x20 && *p < 0x7f)
- fputc(*p, f);
- else {
- fprintf(f, " 0x%02x", *p);
- }
- }
- break;
-
- case NT_CCLASS:
- fprintf(f, "<cclass:%x>", (int )node);
- if (IS_CCLASS_NOT(NCCLASS(node)) fputs(" not", f);
- if (NCCLASS(node)->mbuf) {
- BBuf* bbuf = NCCLASS(node)->mbuf;
- for (i = 0; i < bbuf->used; i++) {
- if (i > 0) fprintf(f, ",");
- fprintf(f, "%0x", bbuf->p[i]);
- }
- }
- break;
-
- case NT_CTYPE:
- fprintf(f, "<ctype:%x> ", (int )node);
- switch (NCTYPE(node)->ctype) {
- case ONIGENC_CTYPE_WORD:
- if (NCTYPE(node)->not != 0)
- fputs("not word", f);
- else
- fputs("word", f);
- break;
-
- default:
- fprintf(f, "ERROR: undefined ctype.\n");
- exit(0);
- }
- break;
-
- case NT_CANY:
- fprintf(f, "<anychar:%x>", (int )node);
- break;
-
- case NT_ANCHOR:
- fprintf(f, "<anchor:%x> ", (int )node);
- switch (NANCHOR(node)->type) {
- case ANCHOR_BEGIN_BUF: fputs("begin buf", f); break;
- case ANCHOR_END_BUF: fputs("end buf", f); break;
- case ANCHOR_BEGIN_LINE: fputs("begin line", f); break;
- case ANCHOR_END_LINE: fputs("end line", f); break;
- case ANCHOR_SEMI_END_BUF: fputs("semi end buf", f); break;
- case ANCHOR_BEGIN_POSITION: fputs("begin position", f); break;
-
- case ANCHOR_WORD_BOUND: fputs("word bound", f); break;
- case ANCHOR_NOT_WORD_BOUND: fputs("not word bound", f); break;
-#ifdef USE_WORD_BEGIN_END
- case ANCHOR_WORD_BEGIN: fputs("word begin", f); break;
- case ANCHOR_WORD_END: fputs("word end", f); break;
-#endif
- case ANCHOR_PREC_READ: fputs("prec read", f); break;
- case ANCHOR_PREC_READ_NOT: fputs("prec read not", f); break;
- case ANCHOR_LOOK_BEHIND: fputs("look_behind", f); break;
- case ANCHOR_LOOK_BEHIND_NOT: fputs("look_behind_not",f); break;
-
- default:
- fprintf(f, "ERROR: undefined anchor type.\n");
- break;
- }
- break;
-
- case NT_BREF:
- {
- int* p;
- BRefNode* br = NBREF(node);
- p = BACKREFS_P(br);
- fprintf(f, "<backref:%x>", (int )node);
- for (i = 0; i < br->back_num; i++) {
- if (i > 0) fputs(", ", f);
- fprintf(f, "%d", p[i]);
- }
- }
- break;
-
-#ifdef USE_SUBEXP_CALL
- case NT_CALL:
- {
- CallNode* cn = NCALL(node);
- fprintf(f, "<call:%x>", (int )node);
- p_string(f, cn->name_end - cn->name, cn->name);
- }
- break;
-#endif
-
- case NT_QTFR:
- fprintf(f, "<quantifier:%x>{%d,%d}%s\n", (int )node,
- NQTFR(node)->lower, NQTFR(node)->upper,
- (NQTFR(node)->greedy ? "" : "?"));
- print_indent_tree(f, NQTFR(node)->target, indent + add);
- break;
-
- case NT_ENCLOSE:
- fprintf(f, "<enclose:%x> ", (int )node);
- switch (NENCLOSE(node)->type) {
- case ENCLOSE_OPTION:
- fprintf(f, "option:%d\n", NENCLOSE(node)->option);
- print_indent_tree(f, NENCLOSE(node)->target, indent + add);
- break;
- case ENCLOSE_MEMORY:
- fprintf(f, "memory:%d", NENCLOSE(node)->regnum);
- break;
- case ENCLOSE_STOP_BACKTRACK:
- fprintf(f, "stop-bt");
- break;
-
- default:
- break;
- }
- fprintf(f, "\n");
- print_indent_tree(f, NENCLOSE(node)->target, indent + add);
- break;
-
- default:
- fprintf(f, "print_indent_tree: undefined node type %d\n", NTYPE(node));
- break;
- }
-
- if (type != NT_LIST && type != NT_ALT && type != NT_QTFR &&
- type != NT_ENCLOSE)
- fprintf(f, "\n");
- fflush(f);
-}
-#endif /* ONIG_DEBUG */
-
-#ifdef ONIG_DEBUG_PARSE_TREE
-static void
-print_tree(FILE* f, Node* node)
-{
- print_indent_tree(f, node, 0);
-}
-#endif
diff --git a/regenc.c b/regenc.c
deleted file mode 100644
index ebeb086810..0000000000
--- a/regenc.c
+++ /dev/null
@@ -1,913 +0,0 @@
-/**********************************************************************
- regenc.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT;
-
-extern int
-onigenc_init(void)
-{
- return 0;
-}
-
-extern OnigEncoding
-onigenc_get_default_encoding(void)
-{
- return OnigEncDefaultCharEncoding;
-}
-
-extern int
-onigenc_set_default_encoding(OnigEncoding enc)
-{
- OnigEncDefaultCharEncoding = enc;
- return 0;
-}
-
-extern UChar*
-onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
-{
- UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
- if (p < s) {
- p += enc_len(enc, p, s);
- }
- return p;
-}
-
-extern UChar*
-onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,
- const UChar* start, const UChar* s, const UChar** prev)
-{
- UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
-
- if (p < s) {
- if (prev) *prev = (const UChar* )p;
- p += enc_len(enc, p, s);
- }
- else {
- if (prev) *prev = (const UChar* )NULL; /* Sorry */
- }
- return p;
-}
-
-extern UChar*
-onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
-{
- if (s <= start)
- return (UChar* )NULL;
-
- return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
-}
-
-extern UChar*
-onigenc_step_back(OnigEncoding enc, const UChar* start, const UChar* s, int n)
-{
- while (ONIG_IS_NOT_NULL(s) && n-- > 0) {
- if (s <= start)
- return (UChar* )NULL;
-
- s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
- }
- return (UChar* )s;
-}
-
-extern UChar*
-onigenc_step(OnigEncoding enc, const UChar* p, const UChar* end, int n)
-{
- UChar* q = (UChar* )p;
- while (n-- > 0) {
- q += ONIGENC_MBC_ENC_LEN(enc, q, end);
- }
- return (q <= end ? q : NULL);
-}
-
-extern int
-onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
-{
- int n = 0;
- UChar* q = (UChar* )p;
-
- while (q < end) {
- q += ONIGENC_MBC_ENC_LEN(enc, q, end);
- n++;
- }
- return n;
-}
-
-extern int
-onigenc_strlen_null(OnigEncoding enc, const UChar* s)
-{
- int n = 0;
- UChar* p = (UChar* )s;
- UChar* e = p + strlen(s);
-
- while (1) {
- if (*p == '\0') {
- UChar* q;
- int len = ONIGENC_MBC_MINLEN(enc);
-
- if (len == 1) return n;
- q = p + 1;
- while (len > 1) {
- if (*q != '\0') break;
- q++;
- len--;
- }
- if (len == 1) return n;
- }
- p += ONIGENC_MBC_ENC_LEN(enc, p, e);
- n++;
- }
-}
-
-extern int
-onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
-{
- UChar* start = (UChar* )s;
- UChar* p = (UChar* )s;
- UChar* e = p + strlen(s);
-
- while (1) {
- if (*p == '\0') {
- UChar* q;
- int len = ONIGENC_MBC_MINLEN(enc);
-
- if (len == 1) return (int )(p - start);
- q = p + 1;
- while (len > 1) {
- if (*q != '\0') break;
- q++;
- len--;
- }
- if (len == 1) return (int )(p - start);
- }
- p += ONIGENC_MBC_ENC_LEN(enc, p, e);
- }
-}
-
-const UChar OnigEncAsciiToLowerCaseTable[] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
- '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
-};
-
-#ifdef USE_UPPER_CASE_TABLE
-const UChar OnigEncAsciiToUpperCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
- '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
- '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
- '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
- '\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
- '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
- '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
- '\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
- '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
-};
-#endif
-
-const unsigned short OnigEncAsciiCtypeTable[256] = {
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
- 0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
- 0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
- 0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
- 0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
- 0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
- 0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-const UChar OnigEncISO_8859_1_ToLowerCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-#ifdef USE_UPPER_CASE_TABLE
-const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
- '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
- '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
- '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
- '\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
- '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
- '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
- '\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
- '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
- '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
- '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\367',
- '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\377',
-};
-#endif
-
-extern void
-onigenc_set_default_caseconv_table(const UChar* table)
-{
- /* nothing */
- /* obsoleted. */
-}
-
-extern UChar*
-onigenc_get_left_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
-{
- return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
-}
-
-const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = {
- { 0x41, 0x61 },
- { 0x42, 0x62 },
- { 0x43, 0x63 },
- { 0x44, 0x64 },
- { 0x45, 0x65 },
- { 0x46, 0x66 },
- { 0x47, 0x67 },
- { 0x48, 0x68 },
- { 0x49, 0x69 },
- { 0x4a, 0x6a },
- { 0x4b, 0x6b },
- { 0x4c, 0x6c },
- { 0x4d, 0x6d },
- { 0x4e, 0x6e },
- { 0x4f, 0x6f },
- { 0x50, 0x70 },
- { 0x51, 0x71 },
- { 0x52, 0x72 },
- { 0x53, 0x73 },
- { 0x54, 0x74 },
- { 0x55, 0x75 },
- { 0x56, 0x76 },
- { 0x57, 0x77 },
- { 0x58, 0x78 },
- { 0x59, 0x79 },
- { 0x5a, 0x7a }
-};
-
-extern int
-onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg,
- OnigEncoding enc)
-{
- OnigCodePoint code;
- int i, r;
-
- for (i = 0; i < sizeof(OnigAsciiLowerMap)/sizeof(OnigPairCaseFoldCodes)
- ; i++) {
- code = OnigAsciiLowerMap[i].to;
- r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);
- if (r != 0) return r;
-
- code = OnigAsciiLowerMap[i].from;
- r = (*f)(OnigAsciiLowerMap[i].to, &code, 1, arg);
- if (r != 0) return r;
- }
-
- return 0;
-}
-
-extern int
-onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[],
- OnigEncoding enc)
-{
- if (0x41 <= *p && *p <= 0x5a) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p + 0x20);
- return 1;
- }
- else if (0x61 <= *p && *p <= 0x7a) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p - 0x20);
- return 1;
- }
- else
- return 0;
-}
-
-extern int
-ss_apply_all_case_fold(OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg)
-{
- static OnigCodePoint ss[] = { 0x73, 0x73 };
-
- return (*f)((OnigCodePoint )0xdf, ss, 2, arg);
-}
-
-extern int
-onigenc_apply_all_case_fold_with_map(int map_size,
- const OnigPairCaseFoldCodes map[],
- int ess_tsett_flag, OnigCaseFoldType flag,
- OnigApplyAllCaseFoldFunc f, void* arg)
-{
- OnigCodePoint code;
- int i, r;
-
- r = onigenc_ascii_apply_all_case_fold(flag, f, arg, 0);
- if (r != 0) return r;
-
- for (i = 0; i < map_size; i++) {
- code = map[i].to;
- r = (*f)(map[i].from, &code, 1, arg);
- if (r != 0) return r;
-
- code = map[i].from;
- r = (*f)(map[i].to, &code, 1, arg);
- if (r != 0) return r;
- }
-
- if (ess_tsett_flag != 0)
- return ss_apply_all_case_fold(flag, f, arg);
-
- return 0;
-}
-
-extern int
-onigenc_get_case_fold_codes_by_str_with_map(int map_size,
- const OnigPairCaseFoldCodes map[],
- int ess_tsett_flag, OnigCaseFoldType flag,
- const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
-{
- if (0x41 <= *p && *p <= 0x5a) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p + 0x20);
- if (*p == 0x53 && ess_tsett_flag != 0 && end > p + 1
- && (*(p+1) == 0x53 || *(p+1) == 0x73)) {
- /* SS */
- items[1].byte_len = 2;
- items[1].code_len = 1;
- items[1].code[0] = (OnigCodePoint )0xdf;
- return 2;
- }
- else
- return 1;
- }
- else if (0x61 <= *p && *p <= 0x7a) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = (OnigCodePoint )(*p - 0x20);
- if (*p == 0x73 && ess_tsett_flag != 0 && end > p + 1
- && (*(p+1) == 0x73 || *(p+1) == 0x53)) {
- /* ss */
- items[1].byte_len = 2;
- items[1].code_len = 1;
- items[1].code[0] = (OnigCodePoint )0xdf;
- return 2;
- }
- else
- return 1;
- }
- else if (*p == 0xdf && ess_tsett_flag != 0) {
- items[0].byte_len = 1;
- items[0].code_len = 2;
- items[0].code[0] = (OnigCodePoint )'s';
- items[0].code[1] = (OnigCodePoint )'s';
-
- items[1].byte_len = 1;
- items[1].code_len = 2;
- items[1].code[0] = (OnigCodePoint )'S';
- items[1].code[1] = (OnigCodePoint )'S';
-
- items[2].byte_len = 1;
- items[2].code_len = 2;
- items[2].code[0] = (OnigCodePoint )'s';
- items[2].code[1] = (OnigCodePoint )'S';
-
- items[3].byte_len = 1;
- items[3].code_len = 2;
- items[3].code[0] = (OnigCodePoint )'S';
- items[3].code[1] = (OnigCodePoint )'s';
-
- return 4;
- }
- else {
- int i;
-
- for (i = 0; i < map_size; i++) {
- if (*p == map[i].from) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = map[i].to;
- return 1;
- }
- else if (*p == map[i].to) {
- items[0].byte_len = 1;
- items[0].code_len = 1;
- items[0].code[0] = map[i].from;
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-
-extern int
-onigenc_not_support_get_ctype_code_range(int ctype,
- OnigCodePoint* sb_out, const OnigCodePoint* ranges[],
- OnigEncoding enc)
-{
- return ONIG_NO_SUPPORT_CONFIG;
-}
-
-extern int
-onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- if (p < end) {
- if (*p == 0x0a) return 1;
- }
- return 0;
-}
-
-/* for single byte encodings */
-extern int
-onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag, const UChar** p,
- const UChar*end, UChar* lower, OnigEncoding enc)
-{
- *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p);
-
- (*p)++;
- return 1; /* return byte length of converted char to lower */
-}
-
-#if 0
-extern int
-onigenc_ascii_is_mbc_ambiguous(OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- const UChar* p = *pp;
-
- (*pp)++;
- return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
-}
-#endif
-
-extern int
-onigenc_single_byte_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc)
-{
- return 1;
-}
-
-extern OnigCodePoint
-onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
-{
- return (OnigCodePoint )(*p);
-}
-
-extern int
-onigenc_single_byte_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
-{
- return 1;
-}
-
-extern int
-onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
-{
- *buf = (UChar )(code & 0xff);
- return 1;
-}
-
-extern UChar*
-onigenc_single_byte_left_adjust_char_head(const UChar* start, const UChar* s,
- OnigEncoding enc)
-{
- return (UChar* )s;
-}
-
-extern int
-onigenc_always_true_is_allowed_reverse_match(const UChar* s, const UChar* end,
- OnigEncoding enc)
-{
- return TRUE;
-}
-
-extern int
-onigenc_always_false_is_allowed_reverse_match(const UChar* s, const UChar* end,
- OnigEncoding enc)
-{
- return FALSE;
-}
-
-extern int
-onigenc_ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype,
- OnigEncoding enc)
-{
- if (code < 128)
- return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
- else
- return FALSE;
-}
-
-extern OnigCodePoint
-onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
-{
- int c, i, len;
- OnigCodePoint n;
-
- len = enc_len(enc, p, end);
- n = (OnigCodePoint )(*p++);
- if (len == 1) return n;
-
- for (i = 1; i < len; i++) {
- if (p >= end) break;
- c = *p++;
- n <<= 8; n += c;
- }
- return n;
-}
-
-extern int
-onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag,
- const UChar** pp, const UChar* end, UChar* lower)
-{
- int len;
- const UChar *p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
- *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
- (*pp)++;
- return 1;
- }
- else {
- int i;
-
- len = enc_len(enc, p, end);
- for (i = 0; i < len; i++) {
- *lower++ = *p++;
- }
- (*pp) += len;
- return len; /* return byte length of converted to lower char */
- }
-}
-
-#if 0
-extern int
-onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,
- const UChar** pp, const UChar* end)
-{
- const UChar* p = *pp;
-
- if (ONIGENC_IS_MBC_ASCII(p)) {
- (*pp)++;
- return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
- }
-
- (*pp) += enc_len(enc, p);
- return FALSE;
-}
-#endif
-
-extern int
-onigenc_mb2_code_to_mbclen(OnigCodePoint code)
-{
- if ((code & 0xff00) != 0) return 2;
- else return 1;
-}
-
-extern int
-onigenc_mb4_code_to_mbclen(OnigCodePoint code)
-{
- if ((code & 0xff000000) != 0) return 4;
- else if ((code & 0xff0000) != 0) return 3;
- else if ((code & 0xff00) != 0) return 2;
- else return 1;
-}
-
-extern int
-onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
-{
- UChar *p = buf;
-
- if ((code & 0xff00) != 0) {
- *p++ = (UChar )((code >> 8) & 0xff);
- }
- *p++ = (UChar )(code & 0xff);
-
-#if 1
- if (enc_len(enc, buf, p) != (p - buf))
- return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
-#endif
- return p - buf;
-}
-
-extern int
-onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
-{
- UChar *p = buf;
-
- if ((code & 0xff000000) != 0) {
- *p++ = (UChar )((code >> 24) & 0xff);
- }
- if ((code & 0xff0000) != 0 || p != buf) {
- *p++ = (UChar )((code >> 16) & 0xff);
- }
- if ((code & 0xff00) != 0 || p != buf) {
- *p++ = (UChar )((code >> 8) & 0xff);
- }
- *p++ = (UChar )(code & 0xff);
-
-#if 1
- if (enc_len(enc, buf, p) != (p - buf))
- return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
-#endif
- return p - buf;
-}
-
-extern int
-onigenc_minimum_property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
-{
- static PosixBracketEntryType PBS[] = {
- { (UChar* )"Alnum", ONIGENC_CTYPE_ALNUM, 5 },
- { (UChar* )"Alpha", ONIGENC_CTYPE_ALPHA, 5 },
- { (UChar* )"Blank", ONIGENC_CTYPE_BLANK, 5 },
- { (UChar* )"Cntrl", ONIGENC_CTYPE_CNTRL, 5 },
- { (UChar* )"Digit", ONIGENC_CTYPE_DIGIT, 5 },
- { (UChar* )"Graph", ONIGENC_CTYPE_GRAPH, 5 },
- { (UChar* )"Lower", ONIGENC_CTYPE_LOWER, 5 },
- { (UChar* )"Print", ONIGENC_CTYPE_PRINT, 5 },
- { (UChar* )"Punct", ONIGENC_CTYPE_PUNCT, 5 },
- { (UChar* )"Space", ONIGENC_CTYPE_SPACE, 5 },
- { (UChar* )"Upper", ONIGENC_CTYPE_UPPER, 5 },
- { (UChar* )"XDigit", ONIGENC_CTYPE_XDIGIT, 6 },
- { (UChar* )"ASCII", ONIGENC_CTYPE_ASCII, 5 },
- { (UChar* )"Word", ONIGENC_CTYPE_WORD, 4 },
- { (UChar* )NULL, -1, 0 }
- };
-
- PosixBracketEntryType *pb;
- int len;
-
- len = onigenc_strlen(enc, p, end);
- for (pb = PBS; IS_NOT_NULL(pb->name); pb++) {
- if (len == pb->len &&
- onigenc_with_ascii_strncmp(enc, p, end, pb->name, pb->len) == 0)
- return pb->ctype;
- }
-
- return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
-}
-
-extern int
-onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
- unsigned int ctype)
-{
- if (code < 128)
- return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
- else {
- if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
- return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
- }
- }
-
- return FALSE;
-}
-
-extern int
-onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
- unsigned int ctype)
-{
- if (code < 128)
- return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
- else {
- if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
- return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
- }
- }
-
- return FALSE;
-}
-
-extern int
-onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end,
- const UChar* sascii /* ascii */, int n)
-{
- int x, c;
-
- while (n-- > 0) {
- if (p >= end) return (int )(*sascii);
-
- c = (int )ONIGENC_MBC_TO_CODE(enc, p, end);
- x = *sascii - c;
- if (x) return x;
-
- sascii++;
- p += enc_len(enc, p, end);
- }
- return 0;
-}
-
-/* Property management */
-static int
-resize_property_list(int new_size, const OnigCodePoint*** plist, int* psize)
-{
- int size;
- const OnigCodePoint **list = *plist;
-
- size = sizeof(OnigCodePoint*) * new_size;
- if (IS_NULL(list)) {
- list = (const OnigCodePoint** )xmalloc(size);
- }
- else {
- list = (const OnigCodePoint** )xrealloc((void* )list, size);
- }
-
- if (IS_NULL(list)) return ONIGERR_MEMORY;
-
- *plist = list;
- *psize = new_size;
-
- return 0;
-}
-
-extern int
-onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
- hash_table_type **table, const OnigCodePoint*** plist, int *pnum,
- int *psize)
-{
-#define PROP_INIT_SIZE 16
-
- int r;
-
- if (*psize <= *pnum) {
- int new_size = (*psize == 0 ? PROP_INIT_SIZE : *psize * 2);
- r = resize_property_list(new_size, plist, psize);
- if (r != 0) return r;
- }
-
- (*plist)[*pnum] = prop;
-
- if (ONIG_IS_NULL(*table)) {
- *table = onig_st_init_strend_table_with_size(PROP_INIT_SIZE);
- if (ONIG_IS_NULL(*table)) return ONIGERR_MEMORY;
- }
-
- *pnum = *pnum + 1;
- onig_st_insert_strend(*table, name, name + strlen((char* )name),
- (hash_data_type )(*pnum + ONIGENC_MAX_STD_CTYPE));
- return 0;
-}
-
-extern int
-onigenc_property_list_init(int (*f)())
-{
- int r;
-
- THREAD_ATOMIC_START;
-
- r = f();
-
- THREAD_ATOMIC_END;
- return r;
-}
diff --git a/regenc.h b/regenc.h
deleted file mode 100644
index 0bd0abeeb2..0000000000
--- a/regenc.h
+++ /dev/null
@@ -1,198 +0,0 @@
-#ifndef REGENC_H
-#define REGENC_H
-/**********************************************************************
- regenc.h - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef REGINT_H
-#ifndef RUBY_EXTERN
-#include "ruby/config.h"
-#include "ruby/defines.h"
-#endif
-#ifdef ONIG_ESCAPE_UCHAR_COLLISION
-#undef ONIG_ESCAPE_UCHAR_COLLISION
-#endif
-#endif
-#include "ruby/oniguruma.h"
-
-typedef struct {
- OnigCodePoint from;
- OnigCodePoint to;
-} OnigPairCaseFoldCodes;
-
-
-#ifndef NULL
-#define NULL ((void* )0)
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-/* error codes */
-#define ONIGENC_ERR_MEMORY -5
-#define ONIGENC_ERR_TYPE_BUG -6
-#define ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE -400
-#define ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE -401
-
-#define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0)
-#define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
-#define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL
-#define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val)
-
-/* character types bit flag */
-#define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
-#define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA)
-#define BIT_CTYPE_BLANK (1<< ONIGENC_CTYPE_BLANK)
-#define BIT_CTYPE_CNTRL (1<< ONIGENC_CTYPE_CNTRL)
-#define BIT_CTYPE_DIGIT (1<< ONIGENC_CTYPE_DIGIT)
-#define BIT_CTYPE_GRAPH (1<< ONIGENC_CTYPE_GRAPH)
-#define BIT_CTYPE_LOWER (1<< ONIGENC_CTYPE_LOWER)
-#define BIT_CTYPE_PRINT (1<< ONIGENC_CTYPE_PRINT)
-#define BIT_CTYPE_PUNCT (1<< ONIGENC_CTYPE_PUNCT)
-#define BIT_CTYPE_SPACE (1<< ONIGENC_CTYPE_SPACE)
-#define BIT_CTYPE_UPPER (1<< ONIGENC_CTYPE_UPPER)
-#define BIT_CTYPE_XDIGIT (1<< ONIGENC_CTYPE_XDIGIT)
-#define BIT_CTYPE_WORD (1<< ONIGENC_CTYPE_WORD)
-#define BIT_CTYPE_ALNUM (1<< ONIGENC_CTYPE_ALNUM)
-#define BIT_CTYPE_ASCII (1<< ONIGENC_CTYPE_ASCII)
-
-#define CTYPE_TO_BIT(ctype) (1<<(ctype))
-#define CTYPE_IS_WORD_GRAPH_PRINT(ctype) \
- ((ctype) == ONIGENC_CTYPE_WORD || (ctype) == ONIGENC_CTYPE_GRAPH ||\
- (ctype) == ONIGENC_CTYPE_PRINT)
-
-
-typedef struct {
- UChar *name;
- int ctype;
- short int len;
-} PosixBracketEntryType;
-
-
-/* #define USE_CRNL_AS_LINE_TERMINATOR */
-#define USE_UNICODE_PROPERTIES
-/* #define USE_UNICODE_CASE_FOLD_TURKISH_AZERI */
-/* #define USE_UNICODE_ALL_LINE_TERMINATORS */ /* see Unicode.org UTF#18 */
-
-
-#define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ASCII
-
-/* for encoding system implementation (internal) */
-ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
-ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc));
-ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
-ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
-ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((int ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
-ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end, OnigEncoding enc));
-
-
-/* methods for single byte encoding */
-ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower, OnigEncoding enc));
-ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p, const UChar* e, OnigEncoding enc));
-ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end, OnigEncoding enc));
-ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
-ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf, OnigEncoding enc));
-ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s, OnigEncoding enc));
-ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc));
-ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc));
-ONIG_EXTERN int onigenc_ascii_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
-
-/* methods for multi byte encoding */
-ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));
-ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));
-ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code));
-ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
-ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
-ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
-ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
-ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code));
-ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
-ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
-
-
-/* in enc/unicode.c */
-ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
-ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((int ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));
-ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
-ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
-ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
-ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
-
-
-#define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
- OnigEncISO_8859_1_ToLowerCaseTable[c]
-#define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
- OnigEncISO_8859_1_ToUpperCaseTable[c]
-
-ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
-ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
-
-ONIG_EXTERN int
-onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
-ONIG_EXTERN UChar*
-onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
-
-/* defined in regexec.c, but used in enc/xxx.c */
-extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
-
-ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding;
-ONIG_EXTERN const UChar OnigEncAsciiToLowerCaseTable[];
-ONIG_EXTERN const UChar OnigEncAsciiToUpperCaseTable[];
-ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
-
-#define ONIGENC_IS_ASCII_CODE(code) ((code) < 0x80)
-#define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
-#define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
-#define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
- ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
-#define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
- (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
- ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
-
-#ifdef ONIG_ENC_REGISTER
-extern int ONIG_ENC_REGISTER(const char *, OnigEncodingType*);
-#define OnigEncodingName(n) encoding_##n
-#define OnigEncodingDeclare(n) static OnigEncodingType OnigEncodingName(n)
-#define OnigEncodingDefine(f,n) \
- OnigEncodingDeclare(n); \
- void Init_##f(void) { \
- ONIG_ENC_REGISTER(OnigEncodingName(n).name, \
- &OnigEncodingName(n)); \
- } \
- OnigEncodingDeclare(n)
-#else
-#define OnigEncodingName(n) OnigEncoding##n
-#define OnigEncodingDeclare(n) OnigEncodingType OnigEncodingName(n)
-#define OnigEncodingDefine(f,n) OnigEncodingDeclare(n)
-#endif
-
-#endif /* REGENC_H */
diff --git a/regerror.c b/regerror.c
deleted file mode 100644
index cf80bbfc99..0000000000
--- a/regerror.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/**********************************************************************
- regerror.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-#include <stdio.h> /* for vsnprintf() */
-
-#ifdef HAVE_STDARG_PROTOTYPES
-#include <stdarg.h>
-#define va_init_list(a,b) va_start(a,b)
-#else
-#include <varargs.h>
-#define va_init_list(a,b) va_start(a)
-#endif
-
-extern UChar*
-onig_error_code_to_format(int code)
-{
- char *p;
-
- if (code >= 0) return (UChar* )0;
-
- switch (code) {
- case ONIG_MISMATCH:
- p = "mismatch"; break;
- case ONIG_NO_SUPPORT_CONFIG:
- p = "no support in this configuration"; break;
- case ONIGERR_MEMORY:
- p = "fail to memory allocation"; break;
- case ONIGERR_MATCH_STACK_LIMIT_OVER:
- p = "match-stack limit over"; break;
- case ONIGERR_TYPE_BUG:
- p = "undefined type (bug)"; break;
- case ONIGERR_PARSER_BUG:
- p = "internal parser error (bug)"; break;
- case ONIGERR_STACK_BUG:
- p = "stack error (bug)"; break;
- case ONIGERR_UNDEFINED_BYTECODE:
- p = "undefined bytecode (bug)"; break;
- case ONIGERR_UNEXPECTED_BYTECODE:
- p = "unexpected bytecode (bug)"; break;
- case ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED:
- p = "default multibyte-encoding is not setted"; break;
- case ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR:
- p = "can't convert to wide-char on specified multibyte-encoding"; break;
- case ONIGERR_INVALID_ARGUMENT:
- p = "invalid argument"; break;
- case ONIGERR_END_PATTERN_AT_LEFT_BRACE:
- p = "end pattern at left brace"; break;
- case ONIGERR_END_PATTERN_AT_LEFT_BRACKET:
- p = "end pattern at left bracket"; break;
- case ONIGERR_EMPTY_CHAR_CLASS:
- p = "empty char-class"; break;
- case ONIGERR_PREMATURE_END_OF_CHAR_CLASS:
- p = "premature end of char-class"; break;
- case ONIGERR_END_PATTERN_AT_ESCAPE:
- p = "end pattern at escape"; break;
- case ONIGERR_END_PATTERN_AT_META:
- p = "end pattern at meta"; break;
- case ONIGERR_END_PATTERN_AT_CONTROL:
- p = "end pattern at control"; break;
- case ONIGERR_META_CODE_SYNTAX:
- p = "invalid meta-code syntax"; break;
- case ONIGERR_CONTROL_CODE_SYNTAX:
- p = "invalid control-code syntax"; break;
- case ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE:
- p = "char-class value at end of range"; break;
- case ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE:
- p = "char-class value at start of range"; break;
- case ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS:
- p = "unmatched range specifier in char-class"; break;
- case ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED:
- p = "target of repeat operator is not specified"; break;
- case ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID:
- p = "target of repeat operator is invalid"; break;
- case ONIGERR_NESTED_REPEAT_OPERATOR:
- p = "nested repeat operator"; break;
- case ONIGERR_UNMATCHED_CLOSE_PARENTHESIS:
- p = "unmatched close parenthesis"; break;
- case ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS:
- p = "end pattern with unmatched parenthesis"; break;
- case ONIGERR_END_PATTERN_IN_GROUP:
- p = "end pattern in group"; break;
- case ONIGERR_UNDEFINED_GROUP_OPTION:
- p = "undefined group option"; break;
- case ONIGERR_INVALID_POSIX_BRACKET_TYPE:
- p = "invalid POSIX bracket type"; break;
- case ONIGERR_INVALID_LOOK_BEHIND_PATTERN:
- p = "invalid pattern in look-behind"; break;
- case ONIGERR_INVALID_REPEAT_RANGE_PATTERN:
- p = "invalid repeat range {lower,upper}"; break;
- case ONIGERR_TOO_BIG_NUMBER:
- p = "too big number"; break;
- case ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE:
- p = "too big number for repeat range"; break;
- case ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE:
- p = "upper is smaller than lower in repeat range"; break;
- case ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS:
- p = "empty range in char class"; break;
- case ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE:
- p = "mismatch multibyte code length in char-class range"; break;
- case ONIGERR_TOO_MANY_MULTI_BYTE_RANGES:
- p = "too many multibyte code ranges are specified"; break;
- case ONIGERR_TOO_SHORT_MULTI_BYTE_STRING:
- p = "too short multibyte code string"; break;
- case ONIGERR_TOO_BIG_BACKREF_NUMBER:
- p = "too big backref number"; break;
- case ONIGERR_INVALID_BACKREF:
-#ifdef USE_NAMED_GROUP
- p = "invalid backref number/name"; break;
-#else
- p = "invalid backref number"; break;
-#endif
- case ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED:
- p = "numbered backref/call is not allowed. (use name)"; break;
- case ONIGERR_TOO_BIG_WIDE_CHAR_VALUE:
- p = "too big wide-char value"; break;
- case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:
- p = "too long wide-char value"; break;
- case ONIGERR_INVALID_WIDE_CHAR_VALUE:
- p = "invalid wide-char value"; break;
- case ONIGERR_EMPTY_GROUP_NAME:
- p = "group name is empty"; break;
- case ONIGERR_INVALID_GROUP_NAME:
- p = "invalid group name <%n>"; break;
- case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:
-#ifdef USE_NAMED_GROUP
- p = "invalid char in group name <%n>"; break;
-#else
- p = "invalid char in group number <%n>"; break;
-#endif
- case ONIGERR_UNDEFINED_NAME_REFERENCE:
- p = "undefined name <%n> reference"; break;
- case ONIGERR_UNDEFINED_GROUP_REFERENCE:
- p = "undefined group <%n> reference"; break;
- case ONIGERR_MULTIPLEX_DEFINED_NAME:
- p = "multiplex defined name <%n>"; break;
- case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:
- p = "multiplex definition name <%n> call"; break;
- case ONIGERR_NEVER_ENDING_RECURSION:
- p = "never ending recursion"; break;
- case ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY:
- p = "group number is too big for capture history"; break;
- case ONIGERR_INVALID_CHAR_PROPERTY_NAME:
- p = "invalid character property name {%n}"; break;
- case ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION:
- p = "not supported encoding combination"; break;
- case ONIGERR_INVALID_COMBINATION_OF_OPTIONS:
- p = "invalid combination of options"; break;
- case ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT:
- p = "over thread pass limit count"; break;
-
- default:
- p = "undefined error code"; break;
- }
-
- return (UChar* )p;
-}
-
-
-static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
- UChar buf[], int buf_size, int *is_over)
-{
- int len;
- UChar *p;
- OnigCodePoint code;
-
- if (ONIGENC_MBC_MINLEN(enc) > 1) {
- p = s;
- len = 0;
- while (p < end) {
- code = ONIGENC_MBC_TO_CODE(enc, p, end);
- if (code >= 0x80) {
- if (len + 5 <= buf_size) {
- sprintf((char* )(&(buf[len])), "\\x%02X",
- (unsigned int )(code & 0377));
- len += 5;
- }
- else {
- break;
- }
- }
- else {
- buf[len++] = (UChar )code;
- }
-
- p += enc_len(enc, p, end);
- if (len >= buf_size) break;
- }
-
- *is_over = ((p < end) ? 1 : 0);
- }
- else {
- len = MIN((end - s), buf_size);
- xmemcpy(buf, s, (size_t )len);
- *is_over = ((buf_size < (end - s)) ? 1 : 0);
- }
-
- return len;
-}
-
-
-/* for ONIG_MAX_ERROR_MESSAGE_LEN */
-#define MAX_ERROR_PAR_LEN 30
-
-extern int
-#ifdef HAVE_STDARG_PROTOTYPES
-onig_error_code_to_str(UChar* s, int code, ...)
-#else
-onig_error_code_to_str(s, code, va_alist)
- UChar* s;
- int code;
- va_dcl
-#endif
-{
- UChar *p, *q;
- OnigErrorInfo* einfo;
- int len, is_over;
- UChar parbuf[MAX_ERROR_PAR_LEN];
- va_list vargs;
-
- va_init_list(vargs, code);
-
- switch (code) {
- case ONIGERR_UNDEFINED_NAME_REFERENCE:
- case ONIGERR_UNDEFINED_GROUP_REFERENCE:
- case ONIGERR_MULTIPLEX_DEFINED_NAME:
- case ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL:
- case ONIGERR_INVALID_GROUP_NAME:
- case ONIGERR_INVALID_CHAR_IN_GROUP_NAME:
- case ONIGERR_INVALID_CHAR_PROPERTY_NAME:
- einfo = va_arg(vargs, OnigErrorInfo*);
- len = to_ascii(einfo->enc, einfo->par, einfo->par_end,
- parbuf, MAX_ERROR_PAR_LEN - 3, &is_over);
- q = onig_error_code_to_format(code);
- p = s;
- while (*q != '\0') {
- if (*q == '%') {
- q++;
- if (*q == 'n') { /* '%n': name */
- xmemcpy(p, parbuf, len);
- p += len;
- if (is_over != 0) {
- xmemcpy(p, "...", 3);
- p += 3;
- }
- q++;
- }
- else
- goto normal_char;
- }
- else {
- normal_char:
- *p++ = *q++;
- }
- }
- *p = '\0';
- len = p - s;
- break;
-
- default:
- q = onig_error_code_to_format(code);
- len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, q);
- xmemcpy(s, q, len);
- s[len] = '\0';
- break;
- }
-
- va_end(vargs);
- return len;
-}
-
-
-void
-#ifdef HAVE_STDARG_PROTOTYPES
-onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
- UChar* pat, UChar* pat_end, const UChar *fmt, ...)
-#else
-onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
- UChar buf[];
- int bufsize;
- OnigEncoding enc;
- UChar* pat;
- UChar* pat_end;
- const UChar *fmt;
- va_dcl
-#endif
-{
- int n, need, len;
- UChar *p, *s, *bp;
- UChar bs[6];
- va_list args;
-
- va_init_list(args, fmt);
- n = xvsnprintf((char* )buf, bufsize, (const char* )fmt, args);
- va_end(args);
-
- need = (pat_end - pat) * 4 + 4;
-
- if (n + need < bufsize) {
- strcat((char* )buf, ": /");
- s = buf + onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, buf);
-
- p = pat;
- while (p < pat_end) {
- if (*p == '\\') {
- *s++ = *p++;
- len = enc_len(enc, p, pat_end);
- while (len-- > 0) *s++ = *p++;
- }
- else if (*p == '/') {
- *s++ = (unsigned char )'\\';
- *s++ = *p++;
- }
- else if (ONIGENC_IS_MBC_HEAD(enc, p, pat_end)) {
- len = enc_len(enc, p, pat_end);
- if (ONIGENC_MBC_MINLEN(enc) == 1) {
- while (len-- > 0) *s++ = *p++;
- }
- else { /* for UTF16 */
- int blen;
-
- while (len-- > 0) {
- sprintf((char* )bs, "\\x%02X", *p++ & 0377);
- blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
- bp = bs;
- while (blen-- > 0) *s++ = *bp++;
- }
- }
- }
- else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
- !ONIGENC_IS_CODE_SPACE(enc, *p)) {
- sprintf((char* )bs, "\\x%02X", *p++ & 0377);
- len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
- bp = bs;
- while (len-- > 0) *s++ = *bp++;
- }
- else {
- *s++ = *p++;
- }
- }
-
- *s++ = '/';
- *s = '\0';
- }
-}
diff --git a/regex.c b/regex.c
new file mode 100644
index 0000000000..b92978fdbb
--- /dev/null
+++ b/regex.c
@@ -0,0 +1,4693 @@
+/* Extended regular expression matching and search library.
+ Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file LGPL. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto)
+ Last change: May 21, 1993 by t^2 */
+/* removed gapped buffer support, multiple syntax support by matz <matz@nts.co.jp> */
+/* Perl5 extension added by matz <matz@caelum.co.jp> */
+/* UTF-8 extension added Jan 16 1999 by Yoshida Masato <yoshidam@tau.bekkoame.ne.jp> */
+
+#include "config.h"
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+/* We write fatal error messages on standard error. */
+#include <stdio.h>
+
+/* isalpha(3) etc. are used for the character classes. */
+#include <ctype.h>
+#include <sys/types.h>
+
+#ifndef PARAMS
+# if defined __GNUC__ || (defined __STDC__ && __STDC__)
+# define PARAMS(args) args
+# else
+# define PARAMS(args) ()
+# endif /* GCC. */
+#endif /* Not PARAMS. */
+
+#if defined(STDC_HEADERS)
+# include <stddef.h>
+#else
+/* We need this for `regex.h', and perhaps for the Emacs include files. */
+# include <sys/types.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#if !defined(__STDC__) && !defined(_MSC_VER)
+# define volatile
+#endif
+
+#ifdef HAVE_PROTOTYPES
+# define _(args) args
+#else
+# define _(args) ()
+#endif
+
+#ifdef RUBY_PLATFORM
+#include "defines.h"
+#undef xmalloc
+#undef xrealloc
+#undef xcalloc
+#undef xfree
+
+# define RUBY
+extern int rb_prohibit_interrupt;
+extern int rb_trap_pending;
+void rb_trap_exec _((void));
+
+# define CHECK_INTS do {\
+ if (!rb_prohibit_interrupt) {\
+ if (rb_trap_pending) rb_trap_exec();\
+ }\
+} while (0)
+#endif
+
+/* Make alloca work the best possible way. */
+#ifdef __GNUC__
+# ifndef atarist
+# ifndef alloca
+# define alloca __builtin_alloca
+# endif
+# endif /* atarist */
+#else
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+void *alloca ();
+# endif
+# endif /* AIX */
+# endif /* HAVE_ALLOCA_H */
+
+#endif /* __GNUC__ */
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+#define xmalloc malloc
+#define xrealloc realloc
+#define xcalloc calloc
+#define xfree free
+
+#ifdef C_ALLOCA
+#define FREE_VARIABLES() alloca(0)
+#else
+#define FREE_VARIABLES()
+#endif
+
+#define FREE_AND_RETURN_VOID(stackb) do { \
+ FREE_VARIABLES(); \
+ if (stackb != stacka) xfree(stackb); \
+ return; \
+} while(0)
+
+#define FREE_AND_RETURN(stackb,val) do { \
+ FREE_VARIABLES(); \
+ if (stackb != stacka) xfree(stackb); \
+ return(val); \
+} while(0)
+
+#define DOUBLE_STACK(type) do { \
+ type *stackx; \
+ unsigned int xlen = stacke - stackb; \
+ if (stackb == stacka) { \
+ stackx = (type*)xmalloc(2 * xlen * sizeof(type)); \
+ if (!stackx) goto memory_exhausted; \
+ memcpy(stackx, stackb, xlen * sizeof (type)); \
+ } \
+ else { \
+ stackx = (type*)xrealloc(stackb, 2 * xlen * sizeof(type)); \
+ if (!stackx) goto memory_exhausted; \
+ } \
+ /* Rearrange the pointers. */ \
+ stackp = stackx + (stackp - stackb); \
+ stackb = stackx; \
+ stacke = stackb + 2 * xlen; \
+} while (0)
+
+#define RE_TALLOC(n,t) ((t*)alloca((n)*sizeof(t)))
+#define TMALLOC(n,t) ((t*)xmalloc((n)*sizeof(t)))
+#define TREALLOC(s,n,t) (s=((t*)xrealloc(s,(n)*sizeof(t))))
+
+#define EXPAND_FAIL_STACK() DOUBLE_STACK(unsigned char*)
+#define ENSURE_FAIL_STACK(n) \
+ do { \
+ if (stacke - stackp <= (n)) { \
+ /* if (len > re_max_failures * MAX_NUM_FAILURE_ITEMS) \
+ { \
+ FREE_AND_RETURN(stackb,(-2)); \
+ }*/ \
+ \
+ /* Roughly double the size of the stack. */ \
+ EXPAND_FAIL_STACK(); \
+ } \
+ } while (0)
+
+/* Get the interface, including the syntax bits. */
+#include "regex.h"
+
+/* Subroutines for re_compile_pattern. */
+static void store_jump _((char*, int, char*));
+static void insert_jump _((int, char*, char*, char*));
+static void store_jump_n _((char*, int, char*, unsigned));
+static void insert_jump_n _((int, char*, char*, char*, unsigned));
+/*static void insert_op _((int, char*, char*));*/
+static void insert_op_2 _((int, char*, char*, int, int));
+static int memcmp_translate _((unsigned char*, unsigned char*, int));
+
+/* Define the syntax stuff, so we can do the \<, \>, etc. */
+
+/* This must be nonzero for the wordchar and notwordchar pattern
+ commands in re_match. */
+#define Sword 1
+#define Sword2 2
+
+#define SYNTAX(c) re_syntax_table[c]
+
+static char re_syntax_table[256];
+static void init_syntax_once _((void));
+static const unsigned char *translate = 0;
+static void init_regs _((struct re_registers*, unsigned int));
+static void bm_init_skip _((int *, unsigned char*, int, const unsigned char*));
+static int current_mbctype = MBCTYPE_ASCII;
+
+#undef P
+
+#ifdef RUBY
+#include "util.h"
+void rb_warn _((const char*, ...));
+# define re_warning(x) rb_warn(x)
+#endif
+
+#ifndef re_warning
+# define re_warning(x)
+#endif
+
+static void
+init_syntax_once()
+{
+ register int c;
+ static int done = 0;
+
+ if (done)
+ return;
+
+ memset(re_syntax_table, 0, sizeof re_syntax_table);
+
+ for (c=0; c<=0x7f; c++)
+ if (isalnum(c))
+ re_syntax_table[c] = Sword;
+ re_syntax_table['_'] = Sword;
+
+ for (c=0x80; c<=0xff; c++)
+ if (isalnum(c))
+ re_syntax_table[c] = Sword2;
+ done = 1;
+}
+
+void
+re_set_casetable(table)
+ const char *table;
+{
+ translate = (const unsigned char*)table;
+}
+
+/* Jim Meyering writes:
+
+ "... Some ctype macros are valid only for character codes that
+ isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
+ using /bin/cc or gcc but without giving an ansi option). So, all
+ ctype uses should be through macros like ISPRINT... If
+ STDC_HEADERS is defined, then autoconf has verified that the ctype
+ macros don't need to be guarded with references to isascii. ...
+ Defining isascii to 1 should let any compiler worth its salt
+ eliminate the && through constant folding."
+ Solaris defines some of these symbols so we must undefine them first. */
+
+#undef ISASCII
+#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
+# define ISASCII(c) 1
+#else
+# define ISASCII(c) isascii(c)
+#endif
+
+#ifdef isblank
+# define ISBLANK(c) (ISASCII(c) && isblank(c))
+#else
+# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+#endif
+#ifdef isgraph
+# define ISGRAPH(c) (ISASCII(c) && isgraph(c))
+#else
+# define ISGRAPH(c) (ISASCII(c) && isprint(c) && !isspace(c))
+#endif
+
+#undef ISPRINT
+#define ISPRINT(c) (ISASCII(c) && isprint(c))
+#define ISDIGIT(c) (ISASCII(c) && isdigit(c))
+#define ISALNUM(c) (ISASCII(c) && isalnum(c))
+#define ISALPHA(c) (ISASCII(c) && isalpha(c))
+#define ISCNTRL(c) (ISASCII(c) && iscntrl(c))
+#define ISLOWER(c) (ISASCII(c) && islower(c))
+#define ISPUNCT(c) (ISASCII(c) && ispunct(c))
+#define ISSPACE(c) (ISASCII(c) && isspace(c))
+#define ISUPPER(c) (ISASCII(c) && isupper(c))
+#define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
+
+#ifndef NULL
+# define NULL (void *)0
+#endif
+
+/* We remove any previous definition of `SIGN_EXTEND_CHAR',
+ since ours (we hope) works properly with all combinations of
+ machines, compilers, `char' and `unsigned char' argument types.
+ (Per Bothner suggested the basic approach.) */
+#undef SIGN_EXTEND_CHAR
+#if __STDC__
+# define SIGN_EXTEND_CHAR(c) ((signed char)(c))
+#else /* not __STDC__ */
+/* As in Harbison and Steele. */
+# define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
+#endif
+
+/* These are the command codes that appear in compiled regular
+ expressions, one per byte. Some command codes are followed by
+ argument bytes. A command code can specify any interpretation
+ whatsoever for its arguments. Zero-bytes may appear in the compiled
+ regular expression.
+
+ The value of `exactn' is needed in search.c (search_buffer) in emacs.
+ So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of
+ `exactn' we use here must also be 1. */
+
+enum regexpcode
+ {
+ unused=0,
+ exactn=1, /* Followed by one byte giving n, then by n literal bytes. */
+ begline, /* Fail unless at beginning of line. */
+ endline, /* Fail unless at end of line. */
+ begbuf, /* Succeeds if at beginning of buffer (if emacs) or at beginning
+ of string to be matched (if not). */
+ endbuf, /* Analogously, for end of buffer/string. */
+ endbuf2, /* End of buffer/string, or newline just before it. */
+ begpos, /* Matches where last scan//gsub left off. */
+ jump, /* Followed by two bytes giving relative address to jump to. */
+ jump_past_alt,/* Same as jump, but marks the end of an alternative. */
+ on_failure_jump, /* Followed by two bytes giving relative address of
+ place to resume at in case of failure. */
+ finalize_jump, /* Throw away latest failure point and then jump to
+ address. */
+ maybe_finalize_jump, /* Like jump but finalize if safe to do so.
+ This is used to jump back to the beginning
+ of a repeat. If the command that follows
+ this jump is clearly incompatible with the
+ one at the beginning of the repeat, such that
+ we can be sure that there is no use backtracking
+ out of repetitions already completed,
+ then we finalize. */
+ dummy_failure_jump, /* Jump, and push a dummy failure point. This
+ failure point will be thrown away if an attempt
+ is made to use it for a failure. A + construct
+ makes this before the first repeat. Also
+ use it as an intermediary kind of jump when
+ compiling an or construct. */
+ push_dummy_failure, /* Push a dummy failure point and continue. Used at the end of
+ alternatives. */
+ succeed_n, /* Used like on_failure_jump except has to succeed n times;
+ then gets turned into an on_failure_jump. The relative
+ address following it is useless until then. The
+ address is followed by two bytes containing n. */
+ jump_n, /* Similar to jump, but jump n times only; also the relative
+ address following is in turn followed by yet two more bytes
+ containing n. */
+ try_next, /* Jump to next pattern for the first time,
+ leaving this pattern on the failure stack. */
+ finalize_push, /* Finalize stack and push the beginning of the pattern
+ on the stack to retry (used for non-greedy match) */
+ finalize_push_n, /* Similar to finalize_push, buf finalize n time only */
+ set_number_at, /* Set the following relative location to the
+ subsequent number. */
+ anychar, /* Matches any (more or less) one character excluding newlines. */
+ anychar_repeat, /* Matches sequence of characters excluding newlines. */
+ charset, /* Matches any one char belonging to specified set.
+ First following byte is number of bitmap bytes.
+ Then come bytes for a bitmap saying which chars are in.
+ Bits in each byte are ordered low-bit-first.
+ A character is in the set if its bit is 1.
+ A character too large to have a bit in the map
+ is automatically not in the set. */
+ charset_not, /* Same parameters as charset, but match any character
+ that is not one of those specified. */
+ start_memory, /* Start remembering the text that is matched, for
+ storing in a memory register. Followed by one
+ byte containing the register number. Register numbers
+ must be in the range 0 through RE_NREGS. */
+ stop_memory, /* Stop remembering the text that is matched
+ and store it in a memory register. Followed by
+ one byte containing the register number. Register
+ numbers must be in the range 0 through RE_NREGS. */
+ start_paren, /* Place holder at the start of (?:..). */
+ stop_paren, /* Place holder at the end of (?:..). */
+ casefold_on, /* Turn on casefold flag. */
+ casefold_off, /* Turn off casefold flag. */
+ option_set, /* Turn on multi line match (match with newlines). */
+ start_nowidth, /* Save string point to the stack. */
+ stop_nowidth, /* Restore string place at the point start_nowidth. */
+ pop_and_fail, /* Fail after popping nowidth entry from stack. */
+ stop_backtrack, /* Restore backtrack stack at the point start_nowidth. */
+ duplicate, /* Match a duplicate of something remembered.
+ Followed by one byte containing the index of the memory
+ register. */
+ wordchar, /* Matches any word-constituent character. */
+ notwordchar, /* Matches any char that is not a word-constituent. */
+ wordbeg, /* Succeeds if at word beginning. */
+ wordend, /* Succeeds if at word end. */
+ wordbound, /* Succeeds if at a word boundary. */
+ notwordbound /* Succeeds if not at a word boundary. */
+ };
+
+
+/* Number of failure points to allocate space for initially,
+ when matching. If this number is exceeded, more space is allocated,
+ so it is not a hard limit. */
+
+#ifndef NFAILURES
+#define NFAILURES 160
+#endif
+
+/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
+#define STORE_NUMBER(destination, number) \
+ do { (destination)[0] = (number) & 0377; \
+ (destination)[1] = (number) >> 8; } while (0)
+
+/* Same as STORE_NUMBER, except increment the destination pointer to
+ the byte after where the number is stored. Watch out that values for
+ DESTINATION such as p + 1 won't work, whereas p will. */
+#define STORE_NUMBER_AND_INCR(destination, number) \
+ do { STORE_NUMBER(destination, number); \
+ (destination) += 2; } while (0)
+
+
+/* Put into DESTINATION a number stored in two contingous bytes starting
+ at SOURCE. */
+#define EXTRACT_NUMBER(destination, source) \
+ do { (destination) = *(source) & 0377; \
+ (destination) += SIGN_EXTEND_CHAR(*(char*)((source) + 1)) << 8; } while (0)
+
+/* Same as EXTRACT_NUMBER, except increment the pointer for source to
+ point to second byte of SOURCE. Note that SOURCE has to be a value
+ such as p, not, e.g., p + 1. */
+#define EXTRACT_NUMBER_AND_INCR(destination, source) \
+ do { EXTRACT_NUMBER(destination, source); \
+ (source) += 2; } while (0)
+
+
+/* Specify the precise syntax of regexps for compilation. This provides
+ for compatibility for various utilities which historically have
+ different, incompatible syntaxes.
+
+ The argument SYNTAX is a bit-mask comprised of the various bits
+ defined in regex.h. */
+
+long
+re_set_syntax(syntax)
+ long syntax;
+{
+ /* obsolete */
+ return 0;
+}
+
+/* Macros for re_compile_pattern, which is found below these definitions. */
+
+#define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate)
+#define MAY_TRANSLATE() ((bufp->options&(RE_OPTION_IGNORECASE|RE_MAY_IGNORECASE)) && translate)
+/* Fetch the next character in the uncompiled pattern---translating it
+ if necessary. Also cast from a signed character in the constant
+ string passed to us by the user to an unsigned char that we can use
+ as an array index (in, e.g., `translate'). */
+#define PATFETCH(c) \
+ do {if (p == pend) goto end_of_pattern; \
+ c = (unsigned char) *p++; \
+ if (TRANSLATE_P()) c = (unsigned char)translate[c]; \
+ } while (0)
+
+/* Fetch the next character in the uncompiled pattern, with no
+ translation. */
+#define PATFETCH_RAW(c) \
+ do {if (p == pend) goto end_of_pattern; \
+ c = (unsigned char)*p++; \
+ } while (0)
+
+/* Go backwards one character in the pattern. */
+#define PATUNFETCH p--
+
+#define MBC2WC(c, p) \
+ do { \
+ if (current_mbctype == MBCTYPE_UTF8) { \
+ int n = mbclen(c) - 1; \
+ c &= (1<<(BYTEWIDTH-2-n)) - 1; \
+ while (n--) { \
+ c = c << 6 | (*p++ & ((1<<6)-1)); \
+ } \
+ } \
+ else { \
+ c <<= 8; \
+ c |= (unsigned char)*(p)++; \
+ } \
+ } while (0)
+
+#define PATFETCH_MBC(c) \
+ do { \
+ if (p + mbclen(c) - 1 >= pend) goto end_of_pattern; \
+ MBC2WC(c, p); \
+ } while(0)
+
+#define WC2MBC1ST(c) \
+ ((current_mbctype != MBCTYPE_UTF8) ? ((c<0x100) ? (c) : (((c)>>8)&0xff)) : utf8_firstbyte(c))
+
+typedef unsigned int (*mbc_startpos_func_t) _((const char *string, unsigned int pos));
+
+static unsigned int asc_startpos _((const char *string, unsigned int pos));
+static unsigned int euc_startpos _((const char *string, unsigned int pos));
+static unsigned int sjis_startpos _((const char *string, unsigned int pos));
+static unsigned int utf8_startpos _((const char *string, unsigned int pos));
+
+static const mbc_startpos_func_t mbc_startpos_func[4] = {
+ asc_startpos, euc_startpos, sjis_startpos, utf8_startpos
+};
+
+#define mbc_startpos(start, pos) (*mbc_startpos_func[current_mbctype])((start), (pos))
+
+static unsigned int
+utf8_firstbyte(c)
+ unsigned long c;
+{
+ if (c < 0x80) return c;
+ if (c <= 0x7ff) return ((c>>6)&0xff)|0xc0;
+ if (c <= 0xffff) return ((c>>12)&0xff)|0xe0;
+ if (c <= 0x1fffff) return ((c>>18)&0xff)|0xf0;
+ if (c <= 0x3ffffff) return ((c>>24)&0xff)|0xf8;
+ if (c <= 0x7fffffff) return ((c>>30)&0xff)|0xfc;
+#if SIZEOF_INT > 4
+ if (c <= 0xfffffffff) return 0xfe;
+#else
+ return 0xfe;
+#endif
+}
+
+#if 0
+static void
+print_mbc(c)
+ unsigned int c;
+{
+ if (current_mbctype == MBCTYPE_UTF8) {
+ if (c < 0x80)
+ printf("%c", (int)c);
+ else if (c <= 0x7ff)
+ printf("%c%c", (int)utf8_firstbyte(c), (int)(c & 0x3f));
+ else if (c <= 0xffff)
+ printf("%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 6) & 0x3f),
+ (int)(c & 0x3f));
+ else if (c <= 0x1fffff)
+ printf("%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 12) & 0x3f),
+ (int)((c >> 6) & 0x3f), (int)(c & 0x3f));
+ else if (c <= 0x3ffffff)
+ printf("%c%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 18) & 0x3f),
+ (int)((c >> 12) & 0x3f), (int)((c >> 6) & 0x3f), (int)(c & 0x3f));
+ else if (c <= 0x7fffffff)
+ printf("%c%c%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 24) & 0x3f),
+ (int)((c >> 18) & 0x3f), (int)((c >> 12) & 0x3f),
+ (int)((c >> 6) & 0x3f), (int)(c & 0x3f));
+ }
+ else if (c < 0xff) {
+ printf("\\%o", (int)c);
+ }
+ else {
+ printf("%c%c", (int)(c >> BYTEWIDTH), (int)(c &0xff));
+ }
+}
+#endif
+
+/* If the buffer isn't allocated when it comes in, use this. */
+#define INIT_BUF_SIZE 28
+
+/* Make sure we have at least N more bytes of space in buffer. */
+#define GET_BUFFER_SPACE(n) \
+ do { \
+ while (b - bufp->buffer + (n) >= bufp->allocated) \
+ EXTEND_BUFFER; \
+ } while (0)
+
+/* Make sure we have one more byte of buffer space and then add CH to it. */
+#define BUFPUSH(ch) \
+ do { \
+ GET_BUFFER_SPACE(1); \
+ *b++ = (char)(ch); \
+ } while (0)
+
+/* Extend the buffer by twice its current size via reallociation and
+ reset the pointers that pointed into the old allocation to point to
+ the correct places in the new allocation. If extending the buffer
+ results in it being larger than 1 << 16, then flag memory exhausted. */
+#define EXTEND_BUFFER \
+ do { char *old_buffer = bufp->buffer; \
+ if (bufp->allocated == (1L<<16)) goto too_big; \
+ bufp->allocated *= 2; \
+ if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \
+ bufp->buffer = (char*)xrealloc(bufp->buffer, bufp->allocated); \
+ if (bufp->buffer == 0) \
+ goto memory_exhausted; \
+ b = (b - old_buffer) + bufp->buffer; \
+ if (fixup_alt_jump) \
+ fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \
+ if (laststart) \
+ laststart = (laststart - old_buffer) + bufp->buffer; \
+ begalt = (begalt - old_buffer) + bufp->buffer; \
+ if (pending_exact) \
+ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
+ } while (0)
+
+
+/* Set the bit for character C in a character set list. */
+#define SET_LIST_BIT(c) \
+ (b[(unsigned char)(c) / BYTEWIDTH] \
+ |= 1 << ((unsigned char)(c) % BYTEWIDTH))
+
+/* Get the next unsigned number in the uncompiled pattern. */
+#define GET_UNSIGNED_NUMBER(num) \
+ do { if (p != pend) { \
+ PATFETCH(c); \
+ while (ISDIGIT(c)) { \
+ if (num < 0) \
+ num = 0; \
+ num = num * 10 + c - '0'; \
+ if (p == pend) \
+ break; \
+ PATFETCH(c); \
+ } \
+ } \
+ } while (0)
+
+#define STREQ(s1, s2) ((strcmp(s1, s2) == 0))
+
+#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
+
+#define IS_CHAR_CLASS(string) \
+ (STREQ(string, "alpha") || STREQ(string, "upper") \
+ || STREQ(string, "lower") || STREQ(string, "digit") \
+ || STREQ(string, "alnum") || STREQ(string, "xdigit") \
+ || STREQ(string, "space") || STREQ(string, "print") \
+ || STREQ(string, "punct") || STREQ(string, "graph") \
+ || STREQ(string, "cntrl") || STREQ(string, "blank"))
+
+#define STORE_MBC(p, c) \
+ do { \
+ (p)[0] = (unsigned char)(((c) >>24) & 0xff); \
+ (p)[1] = (unsigned char)(((c) >>16) & 0xff); \
+ (p)[2] = (unsigned char)(((c) >> 8) & 0xff); \
+ (p)[3] = (unsigned char)(((c) >> 0) & 0xff); \
+ } while (0)
+
+#define STORE_MBC_AND_INCR(p, c) \
+ do { \
+ *(p)++ = (unsigned char)(((c) >>24) & 0xff); \
+ *(p)++ = (unsigned char)(((c) >>16) & 0xff); \
+ *(p)++ = (unsigned char)(((c) >> 8) & 0xff); \
+ *(p)++ = (unsigned char)(((c) >> 0) & 0xff); \
+ } while (0)
+
+#define EXTRACT_MBC(p) \
+ ((unsigned int)((unsigned char)(p)[0] << 24 | \
+ (unsigned char)(p)[1] << 16 | \
+ (unsigned char)(p)[2] << 8 | \
+ (unsigned char)(p)[3]))
+
+#define EXTRACT_MBC_AND_INCR(p) \
+ ((unsigned int)((p) += 4, \
+ (unsigned char)(p)[-4] << 24 | \
+ (unsigned char)(p)[-3] << 16 | \
+ (unsigned char)(p)[-2] << 8 | \
+ (unsigned char)(p)[-1]))
+
+#define EXTRACT_UNSIGNED(p) \
+ ((unsigned char)(p)[0] | (unsigned char)(p)[1] << 8)
+#define EXTRACT_UNSIGNED_AND_INCR(p) \
+ ((p) += 2, (unsigned char)(p)[-2] | (unsigned char)(p)[-1] << 8)
+
+/* Handle (mb)?charset(_not)?.
+
+ Structure of mbcharset(_not)? in compiled pattern.
+
+ struct {
+ unsinged char id; mbcharset(_not)?
+ unsigned char sbc_size;
+ unsigned char sbc_map[sbc_size]; same as charset(_not)? up to here.
+ unsigned short mbc_size; number of intervals.
+ struct {
+ unsigned long beg; beginning of interval.
+ unsigned long end; end of interval.
+ } intervals[mbc_size];
+ }; */
+
+static void
+set_list_bits(c1, c2, b)
+ unsigned long c1, c2;
+ unsigned char *b;
+{
+ unsigned char sbc_size = b[-1];
+ unsigned short mbc_size = EXTRACT_UNSIGNED(&b[sbc_size]);
+ unsigned short beg, end, upb;
+
+ if (c1 > c2)
+ return;
+ b = &b[sbc_size + 2];
+
+ for (beg = 0, upb = mbc_size; beg < upb; ) {
+ unsigned short mid = (unsigned short)(beg + upb) >> 1;
+
+ if ((int)c1 - 1 > (int)EXTRACT_MBC(&b[mid*8+4]))
+ beg = mid + 1;
+ else
+ upb = mid;
+ }
+
+ for (end = beg, upb = mbc_size; end < upb; ) {
+ unsigned short mid = (unsigned short)(end + upb) >> 1;
+
+ if ((int)c2 >= (int)EXTRACT_MBC(&b[mid*8]) - 1)
+ end = mid + 1;
+ else
+ upb = mid;
+ }
+
+ if (beg != end) {
+ if (c1 > EXTRACT_MBC(&b[beg*8]))
+ c1 = EXTRACT_MBC(&b[beg*8]);
+ if (c2 < EXTRACT_MBC(&b[(end - 1)*8+4]))
+ c2 = EXTRACT_MBC(&b[(end - 1)*8+4]);
+ }
+ if (end < mbc_size && end != beg + 1)
+ /* NOTE: memcpy() would not work here. */
+ memmove(&b[(beg + 1)*8], &b[end*8], (mbc_size - end)*8);
+ STORE_MBC(&b[beg*8 + 0], c1);
+ STORE_MBC(&b[beg*8 + 4], c2);
+ mbc_size += beg - end + 1;
+ STORE_NUMBER(&b[-2], mbc_size);
+}
+
+static int
+is_in_list_sbc(c, b)
+ unsigned long c;
+ const unsigned char *b;
+{
+ unsigned short size;
+
+ size = *b++;
+ return ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH);
+}
+
+static int
+is_in_list_mbc(c, b)
+ unsigned long c;
+ const unsigned char *b;
+{
+ unsigned short size;
+ unsigned short i, j;
+
+ size = *b++;
+ b += size + 2;
+ size = EXTRACT_UNSIGNED(&b[-2]);
+ if (size == 0) return 0;
+
+ for (i = 0, j = size; i < j; ) {
+ unsigned short k = (unsigned short)(i + j) >> 1;
+
+ if (c > EXTRACT_MBC(&b[k*8+4]))
+ i = k + 1;
+ else
+ j = k;
+ }
+ if (i < size && EXTRACT_MBC(&b[i*8]) <= c)
+ return 1;
+
+ return 0;
+}
+
+static int
+is_in_list(c, b)
+ unsigned long c;
+ const unsigned char *b;
+{
+ return is_in_list_sbc(c, b) || (current_mbctype ? is_in_list_mbc(c, b) : 0);
+}
+
+#if 0
+static void
+print_partial_compiled_pattern(start, end)
+ unsigned char *start;
+ unsigned char *end;
+{
+ int mcnt, mcnt2;
+ unsigned char *p = start;
+ unsigned char *pend = end;
+
+ if (start == NULL) {
+ printf("(null)\n");
+ return;
+ }
+
+ /* Loop over pattern commands. */
+ while (p < pend) {
+ switch ((enum regexpcode)*p++) {
+ case unused:
+ printf("/unused");
+ break;
+
+ case exactn:
+ mcnt = *p++;
+ printf("/exactn/%d", mcnt);
+ do {
+ putchar('/');
+ printf("%c", *p++);
+ }
+ while (--mcnt);
+ break;
+
+ case start_memory:
+ mcnt = *p++;
+ printf("/start_memory/%d/%d", mcnt, *p++);
+ break;
+
+ case stop_memory:
+ mcnt = *p++;
+ printf("/stop_memory/%d/%d", mcnt, *p++);
+ break;
+
+ case start_paren:
+ printf("/start_paren");
+ break;
+
+ case stop_paren:
+ printf("/stop_paren");
+ break;
+
+ case casefold_on:
+ printf("/casefold_on");
+ break;
+
+ case casefold_off:
+ printf("/casefold_off");
+ break;
+
+ case option_set:
+ printf("/option_set/%d", *p++);
+ break;
+
+ case start_nowidth:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/start_nowidth//%d", mcnt);
+ break;
+
+ case stop_nowidth:
+ printf("/stop_nowidth//");
+ p += 2;
+ break;
+
+ case pop_and_fail:
+ printf("/pop_and_fail");
+ break;
+
+ case stop_backtrack:
+ printf("/stop_backtrack//");
+ p += 2;
+ break;
+
+ case duplicate:
+ printf("/duplicate/%d", *p++);
+ break;
+
+ case anychar:
+ printf("/anychar");
+ break;
+
+ case anychar_repeat:
+ printf("/anychar_repeat");
+ break;
+
+ case charset:
+ case charset_not:
+ {
+ register int c;
+
+ printf("/charset%s",
+ (enum regexpcode)*(p - 1) == charset_not ? "_not" : "");
+
+ mcnt = *p++;
+ printf("/%d", mcnt);
+ for (c = 0; c < mcnt; c++) {
+ unsigned bit;
+ unsigned char map_byte = p[c];
+
+ putchar('/');
+
+ for (bit = 0; bit < BYTEWIDTH; bit++)
+ if (map_byte & (1 << bit))
+ printf("%c", c * BYTEWIDTH + bit);
+ }
+ p += mcnt;
+ mcnt = EXTRACT_UNSIGNED_AND_INCR(p);
+ putchar('/');
+ while (mcnt--) {
+ print_mbc(EXTRACT_MBC_AND_INCR(p));
+ putchar('-');
+ print_mbc(EXTRACT_MBC_AND_INCR(p));
+ }
+ break;
+ }
+
+ case begline:
+ printf("/begline");
+ break;
+
+ case endline:
+ printf("/endline");
+ break;
+
+ case on_failure_jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/on_failure_jump//%d", mcnt);
+ break;
+
+ case dummy_failure_jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/dummy_failure_jump//%d", mcnt);
+ break;
+
+ case push_dummy_failure:
+ printf("/push_dummy_failure");
+ break;
+
+ case finalize_jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/finalize_jump//%d", mcnt);
+ break;
+
+ case maybe_finalize_jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/maybe_finalize_jump//%d", mcnt);
+ break;
+
+ case jump_past_alt:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/jump_past_alt//%d", mcnt);
+ break;
+
+ case jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/jump//%d", mcnt);
+ break;
+
+ case succeed_n:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ EXTRACT_NUMBER_AND_INCR(mcnt2, p);
+ printf("/succeed_n//%d//%d", mcnt, mcnt2);
+ break;
+
+ case jump_n:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ EXTRACT_NUMBER_AND_INCR(mcnt2, p);
+ printf("/jump_n//%d//%d", mcnt, mcnt2);
+ break;
+
+ case set_number_at:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ EXTRACT_NUMBER_AND_INCR(mcnt2, p);
+ printf("/set_number_at//%d//%d", mcnt, mcnt2);
+ break;
+
+ case try_next:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/try_next//%d", mcnt);
+ break;
+
+ case finalize_push:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ printf("/finalize_push//%d", mcnt);
+ break;
+
+ case finalize_push_n:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ EXTRACT_NUMBER_AND_INCR(mcnt2, p);
+ printf("/finalize_push_n//%d//%d", mcnt, mcnt2);
+ break;
+
+ case wordbound:
+ printf("/wordbound");
+ break;
+
+ case notwordbound:
+ printf("/notwordbound");
+ break;
+
+ case wordbeg:
+ printf("/wordbeg");
+ break;
+
+ case wordend:
+ printf("/wordend");
+
+ case wordchar:
+ printf("/wordchar");
+ break;
+
+ case notwordchar:
+ printf("/notwordchar");
+ break;
+
+ case begbuf:
+ printf("/begbuf");
+ break;
+
+ case endbuf:
+ printf("/endbuf");
+ break;
+
+ case endbuf2:
+ printf("/endbuf2");
+ break;
+
+ case begpos:
+ printf("/begpos");
+ break;
+
+ default:
+ printf("?%d", *(p-1));
+ }
+ }
+ printf("/\n");
+}
+
+
+static void
+print_compiled_pattern(bufp)
+ struct re_pattern_buffer *bufp;
+{
+ unsigned char *buffer = (unsigned char*)bufp->buffer;
+
+ print_partial_compiled_pattern(buffer, buffer + bufp->used);
+}
+#endif
+
+static char*
+calculate_must_string(start, end)
+ char *start;
+ char *end;
+{
+ int mcnt;
+ int max = 0;
+ unsigned char *p = (unsigned char *)start;
+ unsigned char *pend = (unsigned char *)end;
+ char *must = 0;
+
+ if (start == NULL) return 0;
+
+ /* Loop over pattern commands. */
+ while (p < pend) {
+ switch ((enum regexpcode)*p++) {
+ case unused:
+ break;
+
+ case exactn:
+ mcnt = *p;
+ if (mcnt > max) {
+ must = (char *)p;
+ max = mcnt;
+ }
+ p += mcnt+1;
+ break;
+
+ case start_memory:
+ case stop_memory:
+ p += 2;
+ break;
+
+ case duplicate:
+ case option_set:
+ p++;
+ break;
+
+ case casefold_on:
+ case casefold_off:
+ return 0; /* should not check must_string */
+
+ case pop_and_fail:
+ case anychar:
+ case anychar_repeat:
+ case begline:
+ case endline:
+ case wordbound:
+ case notwordbound:
+ case wordbeg:
+ case wordend:
+ case wordchar:
+ case notwordchar:
+ case begbuf:
+ case endbuf:
+ case endbuf2:
+ case begpos:
+ case push_dummy_failure:
+ case start_paren:
+ case stop_paren:
+ break;
+
+ case charset:
+ case charset_not:
+ mcnt = *p++;
+ p += mcnt;
+ mcnt = EXTRACT_UNSIGNED_AND_INCR(p);
+ while (mcnt--) {
+ p += 8;
+ }
+ break;
+
+ case on_failure_jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ if (mcnt > 0) p += mcnt;
+ if ((enum regexpcode)p[-3] == jump) {
+ p -= 2;
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ if (mcnt > 0) p += mcnt;
+ }
+ break;
+
+ case dummy_failure_jump:
+ case succeed_n:
+ case try_next:
+ case jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ if (mcnt > 0) p += mcnt;
+ break;
+
+ case start_nowidth:
+ case stop_nowidth:
+ case stop_backtrack:
+ case finalize_jump:
+ case maybe_finalize_jump:
+ case finalize_push:
+ p += 2;
+ break;
+
+ case jump_n:
+ case set_number_at:
+ case finalize_push_n:
+ p += 4;
+ break;
+
+ default:
+ break;
+ }
+ }
+ return must;
+}
+
+static unsigned int
+read_backslash(c)
+ int c;
+{
+ switch (c) {
+ case 'n':
+ return '\n';
+
+ case 't':
+ return '\t';
+
+ case 'r':
+ return '\r';
+
+ case 'f':
+ return '\f';
+
+ case 'v':
+ return '\v';
+
+ case 'a':
+ return '\007';
+
+ case 'b':
+ return '\010';
+
+ case 'e':
+ return '\033';
+ }
+ return c;
+}
+
+static unsigned int
+read_special(p, pend, pp)
+ const char *p, *pend, **pp;
+{
+ int c;
+
+ PATFETCH_RAW(c);
+ switch (c) {
+ case 'M':
+ PATFETCH_RAW(c);
+ if (c != '-') return -1;
+ PATFETCH_RAW(c);
+ *pp = p;
+ if (c == '\\') {
+ return read_special(--p, pend, pp) | 0x80;
+ }
+ else if (c == -1) return ~0;
+ else {
+ return ((c & 0xff) | 0x80);
+ }
+
+ case 'C':
+ PATFETCH_RAW(c);
+ if (c != '-') return ~0;
+ case 'c':
+ PATFETCH_RAW(c);
+ *pp = p;
+ if (c == '\\') {
+ c = read_special(--p, pend, pp);
+ }
+ else if (c == '?') return 0177;
+ else if (c == -1) return ~0;
+ return c & 0x9f;
+ default:
+ *pp = p + 1;
+ return read_backslash(c);
+ }
+
+ end_of_pattern:
+ return ~0;
+}
+
+/* re_compile_pattern takes a regular-expression string
+ and converts it into a buffer full of byte commands for matching.
+
+ PATTERN is the address of the pattern string
+ SIZE is the length of it.
+ BUFP is a struct re_pattern_buffer * which points to the info
+ on where to store the byte commands.
+ This structure contains a char * which points to the
+ actual space, which should have been obtained with malloc.
+ re_compile_pattern may use realloc to grow the buffer space.
+
+ The number of bytes of commands can be found out by looking in
+ the `struct re_pattern_buffer' that bufp pointed to, after
+ re_compile_pattern returns. */
+
+const char *
+re_compile_pattern(pattern, size, bufp)
+ const char *pattern;
+ int size;
+ struct re_pattern_buffer *bufp;
+{
+ register char *b = bufp->buffer;
+ register const char *p = pattern;
+ const char *nextp;
+ const char *pend = pattern + size;
+ register unsigned int c, c1 = 0;
+ const char *p0;
+ int numlen;
+#define ERROR_MSG_MAX_SIZE 200
+ static char error_msg[ERROR_MSG_MAX_SIZE+1];
+
+ /* Address of the count-byte of the most recently inserted `exactn'
+ command. This makes it possible to tell whether a new exact-match
+ character can be added to that command or requires a new `exactn'
+ command. */
+
+ char *pending_exact = 0;
+
+ /* Address of the place where a forward-jump should go to the end of
+ the containing expression. Each alternative of an `or', except the
+ last, ends with a forward-jump of this sort. */
+
+ char *fixup_alt_jump = 0;
+
+ /* Address of start of the most recently finished expression.
+ This tells postfix * where to find the start of its operand. */
+
+ char *laststart = 0;
+
+ /* In processing a repeat, 1 means zero matches is allowed. */
+
+ char zero_times_ok;
+
+ /* In processing a repeat, 1 means many matches is allowed. */
+
+ char many_times_ok;
+
+ /* In processing a repeat, 1 means non-greedy matches. */
+
+ char greedy;
+
+ /* Address of beginning of regexp, or inside of last (. */
+
+ char *begalt = b;
+
+ /* Place in the uncompiled pattern (i.e., the {) to
+ which to go back if the interval is invalid. */
+ const char *beg_interval;
+
+ /* In processing an interval, at least this many matches must be made. */
+ int lower_bound;
+
+ /* In processing an interval, at most this many matches can be made. */
+ int upper_bound;
+
+ /* Stack of information saved by ( and restored by ).
+ Five stack elements are pushed by each (:
+ First, the value of b.
+ Second, the value of fixup_alt_jump.
+ Third, the value of begalt.
+ Fourth, the value of regnum.
+ Fifth, the type of the paren. */
+
+ int stacka[40];
+ int *stackb = stacka;
+ int *stackp = stackb;
+ int *stacke = stackb + 40;
+
+ /* Counts ('s as they are encountered. Remembered for the matching ),
+ where it becomes the register number to put in the stop_memory
+ command. */
+
+ int regnum = 1;
+
+ int range = 0;
+ int had_mbchar = 0;
+ int had_num_literal = 0;
+ int had_char_class = 0;
+
+ int options = bufp->options;
+
+ bufp->fastmap_accurate = 0;
+ bufp->must = 0;
+ bufp->must_skip = 0;
+
+ /* Initialize the syntax table. */
+ init_syntax_once();
+
+ if (bufp->allocated == 0) {
+ bufp->allocated = INIT_BUF_SIZE;
+ /* EXTEND_BUFFER loses when bufp->allocated is 0. */
+ bufp->buffer = (char*)xrealloc(bufp->buffer, INIT_BUF_SIZE);
+ if (!bufp->buffer) goto memory_exhausted; /* this not happen */
+ begalt = b = bufp->buffer;
+ }
+
+ while (p != pend) {
+ PATFETCH(c);
+
+ switch (c) {
+ case '$':
+ if (bufp->options & RE_OPTION_SINGLELINE) {
+ BUFPUSH(endbuf);
+ }
+ else {
+ p0 = p;
+ /* When testing what follows the $,
+ look past the \-constructs that don't consume anything. */
+
+ while (p0 != pend) {
+ if (*p0 == '\\' && p0 + 1 != pend
+ && (p0[1] == 'b' || p0[1] == 'B'))
+ p0 += 2;
+ else
+ break;
+ }
+ BUFPUSH(endline);
+ }
+ break;
+
+ case '^':
+ if (bufp->options & RE_OPTION_SINGLELINE)
+ BUFPUSH(begbuf);
+ else
+ BUFPUSH(begline);
+ break;
+
+ case '+':
+ case '?':
+ case '*':
+ /* If there is no previous pattern, char not special. */
+ if (!laststart) {
+ snprintf(error_msg, ERROR_MSG_MAX_SIZE,
+ "invalid regular expression; there's no previous pattern, to which '%c' would define cardinality at %d",
+ c, p-pattern);
+ FREE_AND_RETURN(stackb, error_msg);
+ }
+ /* If there is a sequence of repetition chars,
+ collapse it down to just one. */
+ zero_times_ok = c != '+';
+ many_times_ok = c != '?';
+ greedy = 1;
+ if (p != pend) {
+ PATFETCH(c);
+ switch (c) {
+ case '?':
+ greedy = 0;
+ break;
+ case '*':
+ case '+':
+ goto nested_meta;
+ default:
+ PATUNFETCH;
+ break;
+ }
+ }
+
+ repeat:
+ /* Star, etc. applied to an empty pattern is equivalent
+ to an empty pattern. */
+ if (!laststart)
+ break;
+
+ if (greedy && many_times_ok && *laststart == anychar && b - laststart <= 2) {
+ if (b[-1] == stop_paren)
+ b--;
+ if (zero_times_ok)
+ *laststart = anychar_repeat;
+ else {
+ BUFPUSH(anychar_repeat);
+ }
+ break;
+ }
+ /* Now we know whether or not zero matches is allowed
+ and also whether or not two or more matches is allowed. */
+ if (many_times_ok) {
+ /* If more than one repetition is allowed, put in at the
+ end a backward relative jump from b to before the next
+ jump we're going to put in below (which jumps from
+ laststart to after this jump). */
+ GET_BUFFER_SPACE(3);
+ store_jump(b,greedy?maybe_finalize_jump:finalize_push,laststart-3);
+ b += 3; /* Because store_jump put stuff here. */
+ }
+
+ /* On failure, jump from laststart to next pattern, which will be the
+ end of the buffer after this jump is inserted. */
+ GET_BUFFER_SPACE(3);
+ insert_jump(on_failure_jump, laststart, b + 3, b);
+ b += 3;
+
+ if (zero_times_ok) {
+ if (greedy == 0) {
+ GET_BUFFER_SPACE(3);
+ insert_jump(try_next, laststart, b + 3, b);
+ b += 3;
+ }
+ }
+ else {
+ /* At least one repetition is required, so insert a
+ `dummy_failure_jump' before the initial
+ `on_failure_jump' instruction of the loop. This
+ effects a skip over that instruction the first time
+ we hit that loop. */
+ GET_BUFFER_SPACE(3);
+ insert_jump(dummy_failure_jump, laststart, laststart + 6, b);
+ b += 3;
+ }
+ break;
+
+ case '.':
+ laststart = b;
+ BUFPUSH(anychar);
+ break;
+
+ case '[':
+ if (p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; '[' can't be the last character ie. can't start range at the end of pattern");
+ while ((b - bufp->buffer + 9 + (1 << BYTEWIDTH) / BYTEWIDTH)
+ > bufp->allocated)
+ EXTEND_BUFFER;
+
+ laststart = b;
+ if (*p == '^') {
+ BUFPUSH(charset_not);
+ p++;
+ }
+ else
+ BUFPUSH(charset);
+ p0 = p;
+
+ BUFPUSH((1 << BYTEWIDTH) / BYTEWIDTH);
+ /* Clear the whole map */
+ memset(b, 0, (1 << BYTEWIDTH) / BYTEWIDTH + 2);
+
+ had_mbchar = 0;
+ had_num_literal = 0;
+ had_char_class = 0;
+
+ /* Read in characters and ranges, setting map bits. */
+ for (;;) {
+ int size;
+ unsigned last = (unsigned)-1;
+
+ if ((size = EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])) || current_mbctype) {
+ /* Ensure the space is enough to hold another interval
+ of multi-byte chars in charset(_not)?. */
+ size = (1 << BYTEWIDTH) / BYTEWIDTH + 2 + size*8 + 8;
+ while (b + size + 1 > bufp->buffer + bufp->allocated)
+ EXTEND_BUFFER;
+ }
+ range_retry:
+ if (range && had_char_class) {
+ FREE_AND_RETURN(stackb, "invalid regular expression; can't use character class as an end value of range");
+ }
+ PATFETCH_RAW(c);
+
+ if (c == ']') {
+ if (p == p0 + 1) {
+ if (p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; empty character class");
+ re_warning("character class has `]' without escape");
+ }
+ else
+ /* Stop if this isn't merely a ] inside a bracket
+ expression, but rather the end of a bracket
+ expression. */
+ break;
+ }
+ /* Look ahead to see if it's a range when the last thing
+ was a character class. */
+ if (had_char_class && c == '-' && *p != ']')
+ FREE_AND_RETURN(stackb, "invalid regular expression; can't use character class as a start value of range");
+ if (ismbchar(c)) {
+ PATFETCH_MBC(c);
+ had_mbchar++;
+ }
+ had_char_class = 0;
+
+ if (c == '-' && ((p != p0 + 1 && *p != ']') ||
+ (p[0] == '-' && p[1] != ']') ||
+ range))
+ re_warning("character class has `-' without escape");
+ if (c == '[' && *p != ':')
+ re_warning("character class has `[' without escape");
+
+ /* \ escapes characters when inside [...]. */
+ if (c == '\\') {
+ PATFETCH_RAW(c);
+ switch (c) {
+ case 'w':
+ for (c = 0; c < (1 << BYTEWIDTH); c++) {
+ if (SYNTAX(c) == Sword ||
+ (!current_mbctype && SYNTAX(c) == Sword2))
+ SET_LIST_BIT(c);
+ }
+ if (current_mbctype) {
+ set_list_bits(0x80, 0xffffffff, b);
+ }
+ had_char_class = 1;
+ last = -1;
+ continue;
+
+ case 'W':
+ for (c = 0; c < (1 << BYTEWIDTH); c++) {
+ if (SYNTAX(c) != Sword &&
+ ((current_mbctype && !re_mbctab[c]) ||
+ (!current_mbctype && SYNTAX(c) != Sword2)))
+ SET_LIST_BIT(c);
+ }
+ had_char_class = 1;
+ last = -1;
+ continue;
+
+ case 's':
+ for (c = 0; c < 256; c++)
+ if (ISSPACE(c))
+ SET_LIST_BIT(c);
+ had_char_class = 1;
+ last = -1;
+ continue;
+
+ case 'S':
+ for (c = 0; c < 256; c++)
+ if (!ISSPACE(c))
+ SET_LIST_BIT(c);
+ if (current_mbctype)
+ set_list_bits(0x80, 0xffffffff, b);
+ had_char_class = 1;
+ last = -1;
+ continue;
+
+ case 'd':
+ for (c = '0'; c <= '9'; c++)
+ SET_LIST_BIT(c);
+ had_char_class = 1;
+ last = -1;
+ continue;
+
+ case 'D':
+ for (c = 0; c < 256; c++)
+ if (!ISDIGIT(c))
+ SET_LIST_BIT(c);
+ if (current_mbctype)
+ set_list_bits(0x80, 0xffffffff, b);
+ had_char_class = 1;
+ last = -1;
+ continue;
+
+ case 'x':
+ c = scan_hex(p, 2, &numlen);
+ if (numlen == 0) goto invalid_escape;
+ p += numlen;
+ had_num_literal = 1;
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ PATUNFETCH;
+ c = scan_oct(p, 3, &numlen);
+ p += numlen;
+ had_num_literal = 1;
+ break;
+
+ case 'M':
+ case 'C':
+ case 'c':
+ {
+ const char *pp;
+
+ --p;
+ c = read_special(p, pend, &pp);
+ if (c > 255) goto invalid_escape;
+ p = pp;
+ had_num_literal = 1;
+ }
+ break;
+
+ default:
+ c = read_backslash(c);
+ if (ismbchar(c)) {
+ PATFETCH_MBC(c);
+ had_mbchar++;
+ }
+ break;
+ }
+ }
+ else if (c == '[' && *p == ':') { /* [:...:] */
+ /* Leave room for the null. */
+ char str[CHAR_CLASS_MAX_LENGTH + 1];
+
+ PATFETCH_RAW(c);
+ c1 = 0;
+
+ /* If pattern is `[[:'. */
+ if (p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; re can't end '[[:'");
+
+ for (;;) {
+ PATFETCH_RAW(c);
+ if (c == ':' || c == ']' || p == pend
+ || c1 == CHAR_CLASS_MAX_LENGTH)
+ break;
+ str[c1++] = c;
+ }
+ str[c1] = '\0';
+
+ /* If isn't a word bracketed by `[:' and `:]':
+ undo the ending character, the letters, and
+ the leading `:' and `['. */
+ if (c == ':' && *p == ']') {
+ int ch;
+ char is_alnum = STREQ(str, "alnum");
+ char is_alpha = STREQ(str, "alpha");
+ char is_blank = STREQ(str, "blank");
+ char is_cntrl = STREQ(str, "cntrl");
+ char is_digit = STREQ(str, "digit");
+ char is_graph = STREQ(str, "graph");
+ char is_lower = STREQ(str, "lower");
+ char is_print = STREQ(str, "print");
+ char is_punct = STREQ(str, "punct");
+ char is_space = STREQ(str, "space");
+ char is_upper = STREQ(str, "upper");
+ char is_xdigit = STREQ(str, "xdigit");
+
+ if (!IS_CHAR_CLASS(str)){
+ snprintf(error_msg, ERROR_MSG_MAX_SIZE,
+ "invalid regular expression; [:%s:] is not a character class", str);
+ FREE_AND_RETURN(stackb, error_msg);
+ }
+
+ /* Throw away the ] at the end of the character class. */
+ PATFETCH(c);
+
+ if (p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; range doesn't have ending ']' after a character class");
+
+ for (ch = 0; ch < 1 << BYTEWIDTH; ch++) {
+ if ( (is_alnum && ISALNUM(ch))
+ || (is_alpha && ISALPHA(ch))
+ || (is_blank && ISBLANK(ch))
+ || (is_cntrl && ISCNTRL(ch))
+ || (is_digit && ISDIGIT(ch))
+ || (is_graph && ISGRAPH(ch))
+ || (is_lower && ISLOWER(ch))
+ || (is_print && ISPRINT(ch))
+ || (is_punct && ISPUNCT(ch))
+ || (is_space && ISSPACE(ch))
+ || (is_upper && ISUPPER(ch))
+ || (is_xdigit && ISXDIGIT(ch)))
+ SET_LIST_BIT(ch);
+ }
+ had_char_class = 1;
+ continue;
+ }
+ else {
+ c1 += 2;
+ while (c1--)
+ PATUNFETCH;
+ re_warning("character class has `[' without escape");
+ c = '[';
+ }
+ }
+
+ /* Get a range. */
+ if (range) {
+ if (last > c)
+ goto invalid_pattern;
+
+ range = 0;
+ if (had_mbchar == 0) {
+ if (TRANSLATE_P()) {
+ for (;last<=c;last++)
+ SET_LIST_BIT(translate[last]);
+ }
+ else {
+ for (;last<=c;last++)
+ SET_LIST_BIT(last);
+ }
+ }
+ else if (had_mbchar == 2) {
+ set_list_bits(last, c, b);
+ }
+ else {
+ /* restriction: range between sbc and mbc */
+ goto invalid_pattern;
+ }
+ }
+ else if (p[0] == '-' && p[1] != ']') {
+ last = c;
+ PATFETCH_RAW(c1);
+ range = 1;
+ goto range_retry;
+ }
+ else {
+ if (TRANSLATE_P() && c < 0x100) c = (unsigned char)translate[c];
+ if (had_mbchar == 0 && (!current_mbctype || !had_num_literal)) {
+ SET_LIST_BIT(c);
+ had_num_literal = 0;
+ }
+ else {
+ set_list_bits(c, c, b);
+ }
+ }
+ had_mbchar = 0;
+ }
+
+ /* Discard any character set/class bitmap bytes that are all
+ 0 at the end of the map. Decrement the map-length byte too. */
+ while ((int)b[-1] > 0 && b[b[-1] - 1] == 0)
+ b[-1]--;
+ if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH)
+ memmove(&b[(unsigned char)b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH],
+ 2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8);
+ b += b[-1] + 2 + EXTRACT_UNSIGNED(&b[(unsigned char)b[-1]])*8;
+ had_num_literal = 0;
+ break;
+
+ case '(':
+ {
+ int old_options = options;
+ int push_option = 0;
+ int casefold = 0;
+
+ PATFETCH(c);
+ if (c == '?') {
+ int negative = 0;
+
+ PATFETCH_RAW(c);
+ switch (c) {
+ case 'x': case 'm': case 'i': case '-':
+ for (;;) {
+ switch (c) {
+ case '-':
+ negative = 1;
+ break;
+
+ case ':':
+ case ')':
+ break;
+
+ case 'x':
+ if (negative)
+ options &= ~RE_OPTION_EXTENDED;
+ else
+ options |= RE_OPTION_EXTENDED;
+ break;
+
+ case 'm':
+ if (negative) {
+ if (options&RE_OPTION_MULTILINE) {
+ options &= ~RE_OPTION_MULTILINE;
+ }
+ }
+ else if (!(options&RE_OPTION_MULTILINE)) {
+ options |= RE_OPTION_MULTILINE;
+ }
+ push_option = 1;
+ break;
+
+ case 'i':
+ if (negative) {
+ if (options&RE_OPTION_IGNORECASE) {
+ options &= ~RE_OPTION_IGNORECASE;
+ }
+ }
+ else if (!(options&RE_OPTION_IGNORECASE)) {
+ options |= RE_OPTION_IGNORECASE;
+ }
+ casefold = 1;
+ break;
+
+ default:
+ FREE_AND_RETURN(stackb, "undefined (?...) inline option");
+ }
+ if (c == ')') {
+ c = '#'; /* read whole in-line options */
+ break;
+ }
+ if (c == ':') break;
+ PATFETCH_RAW(c);
+ }
+ break;
+
+ case '#':
+ for (;;) {
+ PATFETCH(c);
+ if (c == ')') break;
+ }
+ c = '#';
+ break;
+
+ case ':':
+ case '=':
+ case '!':
+ case '>':
+ break;
+
+ default:
+ FREE_AND_RETURN(stackb, "undefined (?...) sequence");
+ }
+ }
+ else {
+ PATUNFETCH;
+ c = '(';
+ }
+ if (c == '#') {
+ if (push_option) {
+ BUFPUSH(option_set);
+ BUFPUSH(options);
+ }
+ if (casefold) {
+ if (options & RE_OPTION_IGNORECASE)
+ BUFPUSH(casefold_on);
+ else
+ BUFPUSH(casefold_off);
+ }
+ break;
+ }
+ if (stackp+8 >= stacke) {
+ DOUBLE_STACK(int);
+ }
+
+ /* Laststart should point to the start_memory that we are about
+ to push (unless the pattern has RE_NREGS or more ('s). */
+ /* obsolete: now RE_NREGS is just a default register size. */
+ *stackp++ = b - bufp->buffer;
+ *stackp++ = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
+ *stackp++ = begalt - bufp->buffer;
+ switch (c) {
+ case '(':
+ BUFPUSH(start_memory);
+ BUFPUSH(regnum);
+ *stackp++ = regnum++;
+ *stackp++ = b - bufp->buffer;
+ BUFPUSH(0);
+ /* too many ()'s to fit in a byte. (max 254) */
+ if (regnum >= RE_REG_MAX) goto too_big;
+ break;
+
+ case '=':
+ case '!':
+ case '>':
+ BUFPUSH(start_nowidth);
+ *stackp++ = b - bufp->buffer;
+ BUFPUSH(0); /* temporary value */
+ BUFPUSH(0);
+ if (c != '!') break;
+
+ BUFPUSH(on_failure_jump);
+ *stackp++ = b - bufp->buffer;
+ BUFPUSH(0); /* temporary value */
+ BUFPUSH(0);
+ break;
+
+ case ':':
+ BUFPUSH(start_paren);
+ pending_exact = 0;
+ default:
+ break;
+ }
+ if (push_option) {
+ BUFPUSH(option_set);
+ BUFPUSH(options);
+ }
+ if (casefold) {
+ if (options & RE_OPTION_IGNORECASE)
+ BUFPUSH(casefold_on);
+ else
+ BUFPUSH(casefold_off);
+ }
+ *stackp++ = c;
+ *stackp++ = old_options;
+ fixup_alt_jump = 0;
+ laststart = 0;
+ begalt = b;
+ }
+ break;
+
+ case ')':
+ if (stackp == stackb)
+ FREE_AND_RETURN(stackb, "unmatched )");
+
+ pending_exact = 0;
+ if (fixup_alt_jump) {
+ /* Push a dummy failure point at the end of the
+ alternative for a possible future
+ `finalize_jump' to pop. See comments at
+ `push_dummy_failure' in `re_match'. */
+ BUFPUSH(push_dummy_failure);
+
+ /* We allocated space for this jump when we assigned
+ to `fixup_alt_jump', in the `handle_alt' case below. */
+ store_jump(fixup_alt_jump, jump, b);
+ }
+ if (options != stackp[-1]) {
+ if ((options ^ stackp[-1]) & RE_OPTION_IGNORECASE) {
+ BUFPUSH((options&RE_OPTION_IGNORECASE)?casefold_off:casefold_on);
+ }
+ if ((options ^ stackp[-1]) != RE_OPTION_IGNORECASE) {
+ BUFPUSH(option_set);
+ BUFPUSH(stackp[-1]);
+ }
+ }
+ p0 = b;
+ options = *--stackp;
+ switch (c = *--stackp) {
+ case '(':
+ {
+ char *loc = bufp->buffer + *--stackp;
+ *loc = regnum - stackp[-1];
+ BUFPUSH(stop_memory);
+ BUFPUSH(stackp[-1]);
+ BUFPUSH(regnum - stackp[-1]);
+ stackp--;
+ }
+ break;
+
+ case '!':
+ BUFPUSH(pop_and_fail);
+ /* back patch */
+ STORE_NUMBER(bufp->buffer+stackp[-1], b - bufp->buffer - stackp[-1] - 2);
+ stackp--;
+ /* fall through */
+ case '=':
+ BUFPUSH(stop_nowidth);
+ /* tell stack-pos place to start_nowidth */
+ STORE_NUMBER(bufp->buffer+stackp[-1], b - bufp->buffer - stackp[-1] - 2);
+ BUFPUSH(0); /* space to hold stack pos */
+ BUFPUSH(0);
+ stackp--;
+ break;
+
+ case '>':
+ BUFPUSH(stop_backtrack);
+ /* tell stack-pos place to start_nowidth */
+ STORE_NUMBER(bufp->buffer+stackp[-1], b - bufp->buffer - stackp[-1] - 2);
+ BUFPUSH(0); /* space to hold stack pos */
+ BUFPUSH(0);
+ stackp--;
+ break;
+
+ case ':':
+ BUFPUSH(stop_paren);
+ break;
+
+ default:
+ break;
+ }
+ begalt = *--stackp + bufp->buffer;
+ stackp--;
+ fixup_alt_jump = *stackp ? *stackp + bufp->buffer - 1 : 0;
+ laststart = *--stackp + bufp->buffer;
+ if (c == '!' || c == '=') laststart = b;
+ break;
+
+ case '|':
+ /* Insert before the previous alternative a jump which
+ jumps to this alternative if the former fails. */
+ GET_BUFFER_SPACE(3);
+ insert_jump(on_failure_jump, begalt, b + 6, b);
+ pending_exact = 0;
+ b += 3;
+ /* The alternative before this one has a jump after it
+ which gets executed if it gets matched. Adjust that
+ jump so it will jump to this alternative's analogous
+ jump (put in below, which in turn will jump to the next
+ (if any) alternative's such jump, etc.). The last such
+ jump jumps to the correct final destination. A picture:
+ _____ _____
+ | | | |
+ | v | v
+ a | b | c
+
+ If we are at `b', then fixup_alt_jump right now points to a
+ three-byte space after `a'. We'll put in the jump, set
+ fixup_alt_jump to right after `b', and leave behind three
+ bytes which we'll fill in when we get to after `c'. */
+
+ if (fixup_alt_jump)
+ store_jump(fixup_alt_jump, jump_past_alt, b);
+
+ /* Mark and leave space for a jump after this alternative,
+ to be filled in later either by next alternative or
+ when know we're at the end of a series of alternatives. */
+ fixup_alt_jump = b;
+ GET_BUFFER_SPACE(3);
+ b += 3;
+
+ laststart = 0;
+ begalt = b;
+ break;
+
+ case '{':
+ /* If there is no previous pattern, this is an invalid pattern. */
+ if (!laststart) {
+ snprintf(error_msg, ERROR_MSG_MAX_SIZE,
+ "invalid regular expression; there's no previous pattern, to which '{' would define cardinality at %d",
+ p-pattern);
+ FREE_AND_RETURN(stackb, error_msg);
+ }
+ if( p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; '{' can't be last character" );
+
+ beg_interval = p - 1;
+
+ lower_bound = -1; /* So can see if are set. */
+ upper_bound = -1;
+ GET_UNSIGNED_NUMBER(lower_bound);
+ if (c == ',') {
+ GET_UNSIGNED_NUMBER(upper_bound);
+ }
+ else
+ /* Interval such as `{1}' => match exactly once. */
+ upper_bound = lower_bound;
+
+ if (lower_bound < 0 || c != '}')
+ goto unfetch_interval;
+
+ if (lower_bound >= RE_DUP_MAX || upper_bound >= RE_DUP_MAX)
+ FREE_AND_RETURN(stackb, "too big quantifier in {,}");
+ if (upper_bound < 0) upper_bound = RE_DUP_MAX;
+ if (lower_bound > upper_bound)
+ FREE_AND_RETURN(stackb, "can't do {n,m} with n > m");
+
+ beg_interval = 0;
+ pending_exact = 0;
+
+ greedy = 1;
+ if (p != pend) {
+ PATFETCH(c);
+ if (c == '?') greedy = 0;
+ else PATUNFETCH;
+ }
+
+ if (lower_bound == 0) {
+ zero_times_ok = 1;
+ if (upper_bound == RE_DUP_MAX) {
+ many_times_ok = 1;
+ goto repeat;
+ }
+ if (upper_bound == 1) {
+ many_times_ok = 0;
+ goto repeat;
+ }
+ }
+ if (lower_bound == 1) {
+ if (upper_bound == 1) {
+ /* No need to repeat */
+ break;
+ }
+ if (upper_bound == RE_DUP_MAX) {
+ many_times_ok = 1;
+ zero_times_ok = 0;
+ goto repeat;
+ }
+ }
+
+ /* If upper_bound is zero, don't want to succeed at all;
+ jump from laststart to b + 3, which will be the end of
+ the buffer after this jump is inserted. */
+
+ if (upper_bound == 0) {
+ GET_BUFFER_SPACE(3);
+ insert_jump(jump, laststart, b + 3, b);
+ b += 3;
+ break;
+ }
+
+ /* If lower_bound == upper_bound, repeat count can be removed */
+ if (lower_bound == upper_bound) {
+ int mcnt;
+ int skip_stop_paren = 0;
+
+ if (b[-1] == stop_paren) {
+ skip_stop_paren = 1;
+ b--;
+ }
+
+ if (*laststart == exactn && laststart[1]+2 == b - laststart
+ && laststart[1]*lower_bound < 256) {
+ mcnt = laststart[1];
+ GET_BUFFER_SPACE((lower_bound-1)*mcnt);
+ laststart[1] = lower_bound*mcnt;
+ while (--lower_bound) {
+ memcpy(b, laststart+2, mcnt);
+ b += mcnt;
+ }
+ if (skip_stop_paren) BUFPUSH(stop_paren);
+ break;
+ }
+
+ if (lower_bound < 5 && b - laststart < 10) {
+ /* 5 and 10 are the magic numbers */
+
+ mcnt = b - laststart;
+ GET_BUFFER_SPACE((lower_bound-1)*mcnt);
+ while (--lower_bound) {
+ memcpy(b, laststart, mcnt);
+ b += mcnt;
+ }
+ if (skip_stop_paren) BUFPUSH(stop_paren);
+ break;
+ }
+ if (skip_stop_paren) b++; /* push back stop_paren */
+ }
+
+ /* Otherwise, we have a nontrivial interval. When
+ we're all done, the pattern will look like:
+ set_number_at <jump count> <upper bound>
+ set_number_at <succeed_n count> <lower bound>
+ succeed_n <after jump addr> <succed_n count>
+ <body of loop>
+ jump_n <succeed_n addr> <jump count>
+ (The upper bound and `jump_n' are omitted if
+ `upper_bound' is 1, though.) */
+ { /* If the upper bound is > 1, we need to insert
+ more at the end of the loop. */
+ unsigned nbytes = upper_bound == 1 ? 10 : 20;
+
+ GET_BUFFER_SPACE(nbytes);
+ /* Initialize lower bound of the `succeed_n', even
+ though it will be set during matching by its
+ attendant `set_number_at' (inserted next),
+ because `re_compile_fastmap' needs to know.
+ Jump to the `jump_n' we might insert below. */
+ insert_jump_n(succeed_n, laststart, b + (nbytes/2),
+ b, lower_bound);
+ b += 5; /* Just increment for the succeed_n here. */
+
+ /* Code to initialize the lower bound. Insert
+ before the `succeed_n'. The `5' is the last two
+ bytes of this `set_number_at', plus 3 bytes of
+ the following `succeed_n'. */
+ insert_op_2(set_number_at, laststart, b, 5, lower_bound);
+ b += 5;
+
+ if (upper_bound > 1) {
+ /* More than one repetition is allowed, so
+ append a backward jump to the `succeed_n'
+ that starts this interval.
+
+ When we've reached this during matching,
+ we'll have matched the interval once, so
+ jump back only `upper_bound - 1' times. */
+ GET_BUFFER_SPACE(5);
+ store_jump_n(b, greedy?jump_n:finalize_push_n, laststart + 5,
+ upper_bound - 1);
+ b += 5;
+
+ /* The location we want to set is the second
+ parameter of the `jump_n'; that is `b-2' as
+ an absolute address. `laststart' will be
+ the `set_number_at' we're about to insert;
+ `laststart+3' the number to set, the source
+ for the relative address. But we are
+ inserting into the middle of the pattern --
+ so everything is getting moved up by 5.
+ Conclusion: (b - 2) - (laststart + 3) + 5,
+ i.e., b - laststart.
+
+ We insert this at the beginning of the loop
+ so that if we fail during matching, we'll
+ reinitialize the bounds. */
+ insert_op_2(set_number_at, laststart, b, b - laststart,
+ upper_bound - 1);
+ b += 5;
+ }
+ }
+ break;
+
+ unfetch_interval:
+ /* If an invalid interval, match the characters as literals. */
+ re_warning("regexp has invalid interval");
+ p = beg_interval;
+ beg_interval = 0;
+
+ /* normal_char and normal_backslash need `c'. */
+ PATFETCH(c);
+ goto normal_char;
+
+ case '\\':
+ if (p == pend)
+ FREE_AND_RETURN(stackb, "invalid regular expression; '\\' can't be last character");
+ /* Do not translate the character after the \, so that we can
+ distinguish, e.g., \B from \b, even if we normally would
+ translate, e.g., B to b. */
+ PATFETCH_RAW(c);
+ switch (c) {
+ case 's':
+ case 'S':
+ case 'd':
+ case 'D':
+ while (b - bufp->buffer + 9 + (1 << BYTEWIDTH) / BYTEWIDTH
+ > bufp->allocated)
+ EXTEND_BUFFER;
+
+ laststart = b;
+ if (c == 's' || c == 'd') {
+ BUFPUSH(charset);
+ }
+ else {
+ BUFPUSH(charset_not);
+ }
+
+ BUFPUSH((1 << BYTEWIDTH) / BYTEWIDTH);
+ memset(b, 0, (1 << BYTEWIDTH) / BYTEWIDTH + 2);
+ if (c == 's' || c == 'S') {
+ SET_LIST_BIT(' ');
+ SET_LIST_BIT('\t');
+ SET_LIST_BIT('\n');
+ SET_LIST_BIT('\r');
+ SET_LIST_BIT('\f');
+ }
+ else {
+ char cc;
+
+ for (cc = '0'; cc <= '9'; cc++) {
+ SET_LIST_BIT(cc);
+ }
+ }
+
+ while ((int)b[-1] > 0 && b[b[-1] - 1] == 0)
+ b[-1]--;
+ if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH)
+ memmove(&b[(unsigned char)b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH],
+ 2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8);
+ b += b[-1] + 2 + EXTRACT_UNSIGNED(&b[(unsigned char)b[-1]])*8;
+ break;
+
+ case 'w':
+ laststart = b;
+ BUFPUSH(wordchar);
+ break;
+
+ case 'W':
+ laststart = b;
+ BUFPUSH(notwordchar);
+ break;
+
+#ifndef RUBY
+ case '<':
+ BUFPUSH(wordbeg);
+ break;
+
+ case '>':
+ BUFPUSH(wordend);
+ break;
+#endif
+
+ case 'b':
+ BUFPUSH(wordbound);
+ break;
+
+ case 'B':
+ BUFPUSH(notwordbound);
+ break;
+
+ case 'A':
+ BUFPUSH(begbuf);
+ break;
+
+ case 'Z':
+ if ((bufp->options & RE_OPTION_SINGLELINE) == 0) {
+ BUFPUSH(endbuf2);
+ break;
+ }
+ /* fall through */
+ case 'z':
+ BUFPUSH(endbuf);
+ break;
+
+ case 'G':
+ BUFPUSH(begpos);
+ break;
+
+ /* hex */
+ case 'x':
+ had_mbchar = 0;
+ c = scan_hex(p, 2, &numlen);
+ if (numlen == 0) goto invalid_escape;
+ p += numlen;
+ had_num_literal = 1;
+ goto numeric_char;
+
+ /* octal */
+ case '0':
+ had_mbchar = 0;
+ c = scan_oct(p, 2, &numlen);
+ p += numlen;
+ had_num_literal = 1;
+ goto numeric_char;
+
+ /* back-ref or octal */
+ case '1': case '2': case '3':
+ case '4': case '5': case '6':
+ case '7': case '8': case '9':
+ PATUNFETCH;
+ p0 = p;
+
+ had_mbchar = 0;
+ c1 = 0;
+ GET_UNSIGNED_NUMBER(c1);
+ if (!ISDIGIT(c)) PATUNFETCH;
+
+ if (9 < c1 && c1 >= regnum) {
+ /* need to get octal */
+ c = scan_oct(p0, 3, &numlen) & 0xff;
+ p = p0 + numlen;
+ c1 = 0;
+ had_num_literal = 1;
+ goto numeric_char;
+ }
+
+ laststart = b;
+ BUFPUSH(duplicate);
+ BUFPUSH(c1);
+ break;
+
+ case 'M':
+ case 'C':
+ case 'c':
+ p0 = --p;
+ c = read_special(p, pend, &p0);
+ if (c > 255) goto invalid_escape;
+ p = p0;
+ had_num_literal = 1;
+ goto numeric_char;
+
+ default:
+ c = read_backslash(c);
+ goto normal_char;
+ }
+ break;
+
+ case '#':
+ if (options & RE_OPTION_EXTENDED) {
+ while (p != pend) {
+ PATFETCH(c);
+ if (c == '\n') break;
+ }
+ break;
+ }
+ goto normal_char;
+
+ case ' ':
+ case '\t':
+ case '\f':
+ case '\r':
+ case '\n':
+ if (options & RE_OPTION_EXTENDED)
+ break;
+
+ default:
+ if (c == ']')
+ re_warning("regexp has `]' without escape");
+ else if (c == '}')
+ re_warning("regexp has `}' without escape");
+ normal_char: /* Expects the character in `c'. */
+ had_mbchar = 0;
+ if (ismbchar(c)) {
+ had_mbchar = 1;
+ c1 = p - pattern;
+ }
+ numeric_char:
+ nextp = p + mbclen(c) - 1;
+ if (!pending_exact || pending_exact + *pending_exact + 1 != b
+ || *pending_exact >= (c1 ? 0176 : 0177)
+ || (nextp < pend &&
+ ( *nextp == '+' || *nextp == '?'
+ || *nextp == '*' || *nextp == '^'
+ || *nextp == '{'))) {
+ laststart = b;
+ BUFPUSH(exactn);
+ pending_exact = b;
+ BUFPUSH(0);
+ }
+ if (had_num_literal || c == 0xff) {
+ BUFPUSH(0xff);
+ (*pending_exact)++;
+ had_num_literal = 0;
+ }
+ BUFPUSH(c);
+ (*pending_exact)++;
+ if (had_mbchar) {
+ int len = mbclen(c) - 1;
+ while (len--) {
+ PATFETCH_RAW(c);
+ BUFPUSH(c);
+ (*pending_exact)++;
+ }
+ }
+ }
+ }
+
+ if (fixup_alt_jump)
+ store_jump(fixup_alt_jump, jump, b);
+
+ if (stackp != stackb)
+ FREE_AND_RETURN(stackb, "unmatched (");
+
+ /* set optimize flags */
+ laststart = bufp->buffer;
+ if (laststart != b) {
+ if (*laststart == dummy_failure_jump) laststart += 3;
+ else if (*laststart == try_next) laststart += 3;
+ if (*laststart == anychar_repeat) {
+ bufp->options |= RE_OPTIMIZE_ANCHOR;
+ }
+ }
+
+ bufp->used = b - bufp->buffer;
+ bufp->re_nsub = regnum;
+ laststart = bufp->buffer;
+ if (laststart != b) {
+ if (*laststart == start_memory) laststart += 3;
+ if (*laststart == exactn) {
+ bufp->options |= RE_OPTIMIZE_EXACTN;
+ bufp->must = laststart+1;
+ }
+ }
+ if (!bufp->must) {
+ bufp->must = calculate_must_string(bufp->buffer, b);
+ }
+ if (current_mbctype == MBCTYPE_SJIS) bufp->options |= RE_OPTIMIZE_NO_BM;
+ else if (bufp->must) {
+ int i;
+ int len = (unsigned char)bufp->must[0];
+
+ for (i=1; i<len; i++) {
+ if ((unsigned char)bufp->must[i] == 0xff ||
+ (current_mbctype && ismbchar(bufp->must[i]))) {
+ bufp->options |= RE_OPTIMIZE_NO_BM;
+ break;
+ }
+ }
+ if (!(bufp->options & RE_OPTIMIZE_NO_BM)) {
+ bufp->must_skip = (int *) xmalloc((1 << BYTEWIDTH)*sizeof(int));
+ bm_init_skip(bufp->must_skip, (unsigned char*)bufp->must+1,
+ (unsigned char)bufp->must[0],
+ (unsigned char*)(MAY_TRANSLATE()?translate:0));
+ }
+ }
+
+ bufp->regstart = TMALLOC(regnum, unsigned char*);
+ bufp->regend = TMALLOC(regnum, unsigned char*);
+ bufp->old_regstart = TMALLOC(regnum, unsigned char*);
+ bufp->old_regend = TMALLOC(regnum, unsigned char*);
+ bufp->reg_info = TMALLOC(regnum, register_info_type);
+ bufp->best_regstart = TMALLOC(regnum, unsigned char*);
+ bufp->best_regend = TMALLOC(regnum, unsigned char*);
+ FREE_AND_RETURN(stackb, 0);
+
+ invalid_pattern:
+ FREE_AND_RETURN(stackb, "invalid regular expression");
+
+ end_of_pattern:
+ FREE_AND_RETURN(stackb, "premature end of regular expression");
+
+ too_big:
+ FREE_AND_RETURN(stackb, "regular expression too big");
+
+ memory_exhausted:
+ FREE_AND_RETURN(stackb, "memory exhausted");
+
+ nested_meta:
+ FREE_AND_RETURN(stackb, "nested *?+ in regexp");
+
+ invalid_escape:
+ FREE_AND_RETURN(stackb, "Invalid escape character syntax");
+}
+
+void
+re_free_pattern(bufp)
+ struct re_pattern_buffer *bufp;
+{
+ xfree(bufp->buffer);
+ xfree(bufp->fastmap);
+ if (bufp->must_skip) xfree(bufp->must_skip);
+
+ xfree(bufp->regstart);
+ xfree(bufp->regend);
+ xfree(bufp->old_regstart);
+ xfree(bufp->old_regend);
+ xfree(bufp->best_regstart);
+ xfree(bufp->best_regend);
+ xfree(bufp->reg_info);
+ xfree(bufp);
+}
+
+/* Store a jump of the form <OPCODE> <relative address>.
+ Store in the location FROM a jump operation to jump to relative
+ address FROM - TO. OPCODE is the opcode to store. */
+
+static void
+store_jump(from, opcode, to)
+ char *from, *to;
+ int opcode;
+{
+ from[0] = (char)opcode;
+ STORE_NUMBER(from + 1, to - (from + 3));
+}
+
+
+/* Open up space before char FROM, and insert there a jump to TO.
+ CURRENT_END gives the end of the storage not in use, so we know
+ how much data to copy up. OP is the opcode of the jump to insert.
+
+ If you call this function, you must zero out pending_exact. */
+
+static void
+insert_jump(op, from, to, current_end)
+ int op;
+ char *from, *to, *current_end;
+{
+ register char *pfrom = current_end; /* Copy from here... */
+ register char *pto = current_end + 3; /* ...to here. */
+
+ while (pfrom != from)
+ *--pto = *--pfrom;
+ store_jump(from, op, to);
+}
+
+
+/* Store a jump of the form <opcode> <relative address> <n> .
+
+ Store in the location FROM a jump operation to jump to relative
+ address FROM - TO. OPCODE is the opcode to store, N is a number the
+ jump uses, say, to decide how many times to jump.
+
+ If you call this function, you must zero out pending_exact. */
+
+static void
+store_jump_n(from, opcode, to, n)
+ char *from, *to;
+ int opcode;
+ unsigned n;
+{
+ from[0] = (char)opcode;
+ STORE_NUMBER(from + 1, to - (from + 3));
+ STORE_NUMBER(from + 3, n);
+}
+
+
+/* Similar to insert_jump, but handles a jump which needs an extra
+ number to handle minimum and maximum cases. Open up space at
+ location FROM, and insert there a jump to TO. CURRENT_END gives the
+ end of the storage in use, so we know how much data to copy up. OP is
+ the opcode of the jump to insert.
+
+ If you call this function, you must zero out pending_exact. */
+
+static void
+insert_jump_n(op, from, to, current_end, n)
+ int op;
+ char *from, *to, *current_end;
+ unsigned n;
+{
+ register char *pfrom = current_end; /* Copy from here... */
+ register char *pto = current_end + 5; /* ...to here. */
+
+ while (pfrom != from)
+ *--pto = *--pfrom;
+ store_jump_n(from, op, to, n);
+}
+
+
+#if 0
+/* Open up space at location THERE, and insert operation OP.
+ CURRENT_END gives the end of the storage in use, so
+ we know how much data to copy up.
+
+ If you call this function, you must zero out pending_exact. */
+
+static void
+insert_op(op, there, current_end)
+ int op;
+ char *there, *current_end;
+{
+ register char *pfrom = current_end; /* Copy from here... */
+ register char *pto = current_end + 1; /* ...to here. */
+
+ while (pfrom != there)
+ *--pto = *--pfrom;
+
+ there[0] = (char)op;
+}
+#endif
+
+
+/* Open up space at location THERE, and insert operation OP followed by
+ NUM_1 and NUM_2. CURRENT_END gives the end of the storage in use, so
+ we know how much data to copy up.
+
+ If you call this function, you must zero out pending_exact. */
+
+static void
+insert_op_2(op, there, current_end, num_1, num_2)
+ int op;
+ char *there, *current_end;
+ int num_1, num_2;
+{
+ register char *pfrom = current_end; /* Copy from here... */
+ register char *pto = current_end + 5; /* ...to here. */
+
+ while (pfrom != there)
+ *--pto = *--pfrom;
+
+ there[0] = (char)op;
+ STORE_NUMBER(there + 1, num_1);
+ STORE_NUMBER(there + 3, num_2);
+}
+
+
+#define trans_eq(c1, c2, translate) (translate?(translate[c1]==translate[c2]):((c1)==(c2)))
+static int
+slow_match(little, lend, big, bend, translate)
+ const unsigned char *little, *lend;
+ const unsigned char *big, *bend;
+ const unsigned char *translate;
+{
+ int c;
+
+ while (little < lend && big < bend) {
+ c = *little++;
+ if (c == 0xff)
+ c = *little++;
+ if (!trans_eq(*big++, c, translate)) break;
+ }
+ if (little == lend) return 1;
+ return 0;
+}
+
+static int
+slow_search(little, llen, big, blen, translate)
+ const unsigned char *little;
+ int llen;
+ const unsigned char *big;
+ int blen;
+ const char *translate;
+{
+ const unsigned char *bsave = big;
+ const unsigned char *bend = big + blen;
+ register int c;
+ int fescape = 0;
+
+ c = *little;
+ if (c == 0xff) {
+ c = little[1];
+ fescape = 1;
+ }
+ else if (translate && !ismbchar(c)) {
+ c = translate[c];
+ }
+
+ while (big < bend) {
+ /* look for first character */
+ if (fescape) {
+ while (big < bend) {
+ if (*big == c) break;
+ big++;
+ }
+ }
+ else if (translate && !ismbchar(c)) {
+ while (big < bend) {
+ if (ismbchar(*big)) big+=mbclen(*big)-1;
+ else if (translate[*big] == c) break;
+ big++;
+ }
+ }
+ else {
+ while (big < bend) {
+ if (*big == c) break;
+ if (ismbchar(*big)) big+=mbclen(*big)-1;
+ big++;
+ }
+ }
+
+ if (slow_match(little, little+llen, big, bend, (unsigned char *)translate))
+ return big - bsave;
+
+ big+=mbclen(*big);
+ }
+ return -1;
+}
+
+static void
+bm_init_skip(skip, pat, m, translate)
+ int *skip;
+ unsigned char *pat;
+ int m;
+ const unsigned char *translate;
+{
+ int j, c;
+
+ for (c=0; c<256; c++) {
+ skip[c] = m;
+ }
+ if (translate) {
+ for (j=0; j<m-1; j++) {
+ skip[translate[pat[j]]] = m-1-j;
+ }
+ }
+ else {
+ for (j=0; j<m-1; j++) {
+ skip[pat[j]] = m-1-j;
+ }
+ }
+}
+
+static int
+bm_search(little, llen, big, blen, skip, translate)
+ const unsigned char *little;
+ int llen;
+ const unsigned char *big;
+ int blen;
+ int *skip;
+ const unsigned char *translate;
+{
+ int i, j, k;
+
+ i = llen-1;
+ if (translate) {
+ while (i < blen) {
+ k = i;
+ j = llen-1;
+ while (j >= 0 && translate[big[k]] == translate[little[j]]) {
+ k--;
+ j--;
+ }
+ if (j < 0) return k+1;
+
+ i += skip[translate[big[i]]];
+ }
+ return -1;
+ }
+ while (i < blen) {
+ k = i;
+ j = llen-1;
+ while (j >= 0 && big[k] == little[j]) {
+ k--;
+ j--;
+ }
+ if (j < 0) return k+1;
+
+ i += skip[big[i]];
+ }
+ return -1;
+}
+
+/* Given a pattern, compute a fastmap from it. The fastmap records
+ which of the (1 << BYTEWIDTH) possible characters can start a string
+ that matches the pattern. This fastmap is used by re_search to skip
+ quickly over totally implausible text.
+
+ The caller must supply the address of a (1 << BYTEWIDTH)-byte data
+ area as bufp->fastmap.
+ The other components of bufp describe the pattern to be used. */
+static int
+re_compile_fastmap0(bufp)
+ struct re_pattern_buffer *bufp;
+{
+ unsigned char *pattern = (unsigned char*)bufp->buffer;
+ int size = bufp->used;
+ register char *fastmap = bufp->fastmap;
+ register unsigned char *p = pattern;
+ register unsigned char *pend = pattern + size;
+ register int j, k;
+ unsigned is_a_succeed_n;
+
+
+ unsigned char *stacka[NFAILURES];
+ unsigned char **stackb = stacka;
+ unsigned char **stackp = stackb;
+ unsigned char **stacke = stackb + NFAILURES;
+ int options = bufp->options;
+
+ memset(fastmap, 0, (1 << BYTEWIDTH));
+ bufp->fastmap_accurate = 1;
+ bufp->can_be_null = 0;
+
+ while (p) {
+ is_a_succeed_n = 0;
+ if (p == pend) {
+ bufp->can_be_null = 1;
+ break;
+ }
+#ifdef SWITCH_ENUM_BUG
+ switch ((int)((enum regexpcode)*p++))
+#else
+ switch ((enum regexpcode)*p++)
+#endif
+ {
+ case exactn:
+ if (p[1] == 0xff) {
+ if (TRANSLATE_P())
+ fastmap[translate[p[2]]] = 2;
+ else
+ fastmap[p[2]] = 2;
+ bufp->options |= RE_OPTIMIZE_BMATCH;
+ }
+ else if (TRANSLATE_P())
+ fastmap[translate[p[1]]] = 1;
+ else
+ fastmap[p[1]] = 1;
+ break;
+
+ case begline:
+ case begbuf:
+ case begpos:
+ case endbuf:
+ case endbuf2:
+ case wordbound:
+ case notwordbound:
+ case wordbeg:
+ case wordend:
+ case pop_and_fail:
+ case push_dummy_failure:
+ case start_paren:
+ case stop_paren:
+ continue;
+
+ case casefold_on:
+ bufp->options |= RE_MAY_IGNORECASE;
+ options |= RE_OPTION_IGNORECASE;
+ continue;
+
+ case casefold_off:
+ options &= ~RE_OPTION_IGNORECASE;
+ continue;
+
+ case option_set:
+ options = *p++;
+ continue;
+
+ case endline:
+ if (TRANSLATE_P())
+ fastmap[translate['\n']] = 1;
+ else
+ fastmap['\n'] = 1;
+ if ((options & RE_OPTION_SINGLELINE) == 0 && bufp->can_be_null == 0)
+ bufp->can_be_null = 2;
+ break;
+
+ case jump_n:
+ case finalize_jump:
+ case maybe_finalize_jump:
+ case jump:
+ case jump_past_alt:
+ case dummy_failure_jump:
+ case finalize_push:
+ case finalize_push_n:
+ EXTRACT_NUMBER_AND_INCR(j, p);
+ p += j;
+ if (j > 0)
+ continue;
+ /* Jump backward reached implies we just went through
+ the body of a loop and matched nothing.
+ Opcode jumped to should be an on_failure_jump.
+ Just treat it like an ordinary jump.
+ For a * loop, it has pushed its failure point already;
+ If so, discard that as redundant. */
+
+ if ((enum regexpcode)*p != on_failure_jump
+ && (enum regexpcode)*p != try_next
+ && (enum regexpcode)*p != succeed_n)
+ continue;
+ p++;
+ EXTRACT_NUMBER_AND_INCR(j, p);
+ p += j;
+ if (stackp != stackb && *stackp == p)
+ stackp--; /* pop */
+ continue;
+
+ case try_next:
+ case start_nowidth:
+ case stop_nowidth:
+ case stop_backtrack:
+ p += 2;
+ continue;
+
+ case succeed_n:
+ is_a_succeed_n = 1;
+ /* Get to the number of times to succeed. */
+ EXTRACT_NUMBER(k, p + 2);
+ /* Increment p past the n for when k != 0. */
+ if (k != 0) {
+ p += 4;
+ continue;
+ }
+ /* fall through */
+
+ case on_failure_jump:
+ EXTRACT_NUMBER_AND_INCR(j, p);
+ if (p + j < pend) {
+ if (stackp == stacke) {
+ EXPAND_FAIL_STACK();
+ }
+ *++stackp = p + j; /* push */
+ }
+ else {
+ bufp->can_be_null = 1;
+ }
+ if (is_a_succeed_n)
+ EXTRACT_NUMBER_AND_INCR(k, p); /* Skip the n. */
+ continue;
+
+ case set_number_at:
+ p += 4;
+ continue;
+
+ case start_memory:
+ case stop_memory:
+ p += 2;
+ continue;
+
+ case duplicate:
+ bufp->can_be_null = 1;
+ if (*p >= bufp->re_nsub) break;
+ fastmap['\n'] = 1;
+ case anychar_repeat:
+ case anychar:
+ for (j = 0; j < (1 << BYTEWIDTH); j++) {
+ if (j != '\n' || (options & RE_OPTION_MULTILINE))
+ fastmap[j] = 1;
+ }
+ if (bufp->can_be_null) {
+ FREE_AND_RETURN(stackb, 0);
+ }
+ /* Don't return; check the alternative paths
+ so we can set can_be_null if appropriate. */
+ if ((enum regexpcode)p[-1] == anychar_repeat) {
+ continue;
+ }
+ break;
+
+ case wordchar:
+ for (j = 0; j < 0x80; j++) {
+ if (SYNTAX(j) == Sword)
+ fastmap[j] = 1;
+ }
+ switch (current_mbctype) {
+ case MBCTYPE_ASCII:
+ for (j = 0x80; j < (1 << BYTEWIDTH); j++) {
+ if (SYNTAX(j) == Sword2)
+ fastmap[j] = 1;
+ }
+ break;
+ case MBCTYPE_EUC:
+ case MBCTYPE_SJIS:
+ case MBCTYPE_UTF8:
+ for (j = 0x80; j < (1 << BYTEWIDTH); j++) {
+ if (re_mbctab[j])
+ fastmap[j] = 1;
+ }
+ break;
+ }
+ break;
+
+ case notwordchar:
+ for (j = 0; j < 0x80; j++)
+ if (SYNTAX(j) != Sword)
+ fastmap[j] = 1;
+ switch (current_mbctype) {
+ case MBCTYPE_ASCII:
+ for (j = 0x80; j < (1 << BYTEWIDTH); j++) {
+ if (SYNTAX(j) != Sword2)
+ fastmap[j] = 1;
+ }
+ break;
+ case MBCTYPE_EUC:
+ case MBCTYPE_SJIS:
+ case MBCTYPE_UTF8:
+ for (j = 0x80; j < (1 << BYTEWIDTH); j++) {
+ if (!re_mbctab[j])
+ fastmap[j] = 1;
+ }
+ break;
+ }
+ break;
+
+ case charset:
+ /* NOTE: Charset for single-byte chars never contain
+ multi-byte char. See set_list_bits(). */
+ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+ if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) {
+ int tmp = TRANSLATE_P()?translate[j]:j;
+ fastmap[tmp] = 1;
+ }
+ {
+ unsigned short size;
+ unsigned long c, beg, end;
+
+ p += p[-1] + 2;
+ size = EXTRACT_UNSIGNED(&p[-2]);
+ for (j = 0; j < (int)size; j++) {
+ c = EXTRACT_MBC(&p[j*8]);
+ beg = WC2MBC1ST(c);
+ c = EXTRACT_MBC(&p[j*8+4]);
+ end = WC2MBC1ST(c);
+ /* set bits for 1st bytes of multi-byte chars. */
+ while (beg <= end) {
+ /* NOTE: Charset for multi-byte chars might contain
+ single-byte chars. We must reject them. */
+ if (c < 0x100) {
+ fastmap[beg] = 2;
+ bufp->options |= RE_OPTIMIZE_BMATCH;
+ }
+ else if (ismbchar(beg))
+ fastmap[beg] = 1;
+ beg++;
+ }
+ }
+ }
+ break;
+
+ case charset_not:
+ /* S: set of all single-byte chars.
+ M: set of all first bytes that can start multi-byte chars.
+ s: any set of single-byte chars.
+ m: any set of first bytes that can start multi-byte chars.
+
+ We assume S+M = U.
+ ___ _ _
+ s+m = (S*s+M*m). */
+ /* Chars beyond end of map must be allowed */
+ /* NOTE: Charset_not for single-byte chars might contain
+ multi-byte chars. See set_list_bits(). */
+ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
+ if (!ismbchar(j))
+ fastmap[j] = 1;
+
+ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+ if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) {
+ if (!ismbchar(j))
+ fastmap[j] = 1;
+ }
+ {
+ unsigned short size;
+ unsigned long c, beg;
+ int num_literal = 0;
+
+ p += p[-1] + 2;
+ size = EXTRACT_UNSIGNED(&p[-2]);
+ if (size == 0) {
+ for (j = 0x80; j < (1 << BYTEWIDTH); j++)
+ if (ismbchar(j))
+ fastmap[j] = 1;
+ break;
+ }
+ for (j = 0,c = 0;j < (int)size; j++) {
+ unsigned int cc = EXTRACT_MBC(&p[j*8]);
+ beg = WC2MBC1ST(cc);
+ while (c <= beg) {
+ if (ismbchar(c))
+ fastmap[c] = 1;
+ c++;
+ }
+
+ cc = EXTRACT_MBC(&p[j*8+4]);
+ if (cc < 0xff) {
+ num_literal = 1;
+ while (c <= cc) {
+ if (ismbchar(c))
+ fastmap[c] = 1;
+ c++;
+ }
+ }
+ c = WC2MBC1ST(cc);
+ }
+
+ for (j = c; j < (1 << BYTEWIDTH); j++) {
+ if (num_literal)
+ fastmap[j] = 1;
+ if (ismbchar(j))
+ fastmap[j] = 1;
+ }
+ }
+ break;
+
+ case unused: /* pacify gcc -Wall */
+ break;
+ }
+
+ /* Get here means we have successfully found the possible starting
+ characters of one path of the pattern. We need not follow this
+ path any farther. Instead, look at the next alternative
+ remembered in the stack. */
+ if (stackp != stackb)
+ p = *stackp--; /* pop */
+ else
+ break;
+ }
+ FREE_AND_RETURN(stackb, 0);
+ memory_exhausted:
+ FREE_AND_RETURN(stackb, -2);
+}
+
+void
+re_compile_fastmap(bufp)
+ struct re_pattern_buffer *bufp;
+{
+ (void)re_compile_fastmap0(bufp);
+}
+
+/* adjust startpos value to the position between characters. */
+int
+re_mbc_startpos(string, size, startpos, range)
+ const char *string;
+ int size, startpos, range;
+{
+ int i = mbc_startpos(string, startpos);
+
+ if (i < startpos) {
+ if (range > 0) {
+ startpos = i + mbclen(string[i]);
+ }
+ else {
+ int len = mbclen(string[i]);
+ if (i + len <= startpos)
+ startpos = i + len;
+ else
+ startpos = i;
+ }
+ }
+ return startpos;
+}
+
+int
+re_adjust_startpos(bufp, string, size, startpos, range)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int size, startpos, range;
+{
+ /* Update the fastmap now if not correct already. */
+ if (!bufp->fastmap_accurate) {
+ int ret = re_compile_fastmap0(bufp);
+ if (ret) return ret;
+ }
+
+ /* Adjust startpos for mbc string */
+ if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) {
+ startpos = re_mbc_startpos(string, size, startpos, range);
+ }
+ return startpos;
+}
+
+
+static int re_match_exec _((struct re_pattern_buffer *, const char *, int, int, int,
+ struct re_registers *));
+
+/* Using the compiled pattern in BUFP->buffer, first tries to match
+ STRING, starting first at index STARTPOS, then at STARTPOS + 1, and
+ so on. RANGE is the number of places to try before giving up. If
+ RANGE is negative, it searches backwards, i.e., the starting
+ positions tried are STARTPOS, STARTPOS - 1, etc. STRING is of SIZE.
+ In REGS, return the indices of STRING that matched the entire
+ BUFP->buffer and its contained subexpressions.
+
+ The value returned is the position in the strings at which the match
+ was found, or -1 if no match was found, or -2 if error (such as
+ failure stack overflow). */
+
+int
+re_search(bufp, string, size, startpos, range, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int size, startpos, range;
+ struct re_registers *regs;
+{
+ register char *fastmap = bufp->fastmap;
+ int val, anchor = 0, initpos = startpos;
+
+ /* Check for out-of-range starting position. */
+ if (startpos < 0 || startpos > size)
+ return -1;
+ if (!string) {
+ if (size == 0) string = "";
+ else return -1;
+ }
+
+ /* Update the fastmap now if not correct already. */
+ if (fastmap && !bufp->fastmap_accurate) {
+ int ret = re_compile_fastmap0(bufp);
+ if (ret) return ret;
+ }
+
+
+ /* If the search isn't to be a backwards one, don't waste time in a
+ search for a pattern that must be anchored. */
+ if (bufp->used > 0) {
+ switch ((enum regexpcode)bufp->buffer[0]) {
+ case begbuf:
+ begbuf_match:
+ if (range > 0) {
+ if (startpos > 0) return -1;
+ else {
+ val = re_match(bufp, string, size, 0, regs);
+ if (val >= 0) return 0;
+ return val;
+ }
+ }
+ break;
+
+ case begline:
+ anchor = 1;
+ break;
+
+ case begpos:
+ val = re_match(bufp, string, size, startpos, regs);
+ if (val >= 0) return startpos;
+ return val;
+
+ default:
+ break;
+ }
+ }
+ if (bufp->options & RE_OPTIMIZE_ANCHOR) {
+ if (bufp->options&RE_OPTION_MULTILINE && range > 0) {
+ goto begbuf_match;
+ }
+ anchor = 1;
+ }
+
+ if (bufp->must) {
+ int len = ((unsigned char*)bufp->must)[0];
+ int pos, pbeg, pend;
+
+ pbeg = startpos;
+ pend = startpos + range;
+ if (pbeg > pend) { /* swap pbeg,pend */
+ pos = pend; pend = pbeg; pbeg = pos;
+ }
+ pend = size;
+ if (bufp->options & RE_OPTIMIZE_NO_BM) {
+ pos = slow_search((unsigned char *)(bufp->must+1), len,
+ (unsigned char*)(string+pbeg), pend-pbeg,
+ (char *)(MAY_TRANSLATE()?translate:0));
+ }
+ else {
+ pos = bm_search((unsigned char *)(bufp->must+1), len,
+ (unsigned char *)(string+pbeg), pend-pbeg,
+ bufp->must_skip,
+ MAY_TRANSLATE()?translate:0);
+ }
+ if (pos == -1) return -1;
+ if (range > 0 && (bufp->options & RE_OPTIMIZE_EXACTN)) {
+ startpos += pos;
+ range -= pos;
+ if (range < 0) return -1;
+ }
+ }
+
+ for (;;) {
+ /* If a fastmap is supplied, skip quickly over characters that
+ cannot possibly be the start of a match. Note, however, that
+ if the pattern can possibly match the null string, we must
+ test it at each starting point so that we take the first null
+ string we get. */
+
+ if (fastmap && startpos < size
+ && bufp->can_be_null != 1 && !(anchor && startpos == 0)) {
+ if (range > 0) { /* Searching forwards. */
+ register unsigned char *p, c;
+ int irange = range;
+
+ p = (unsigned char*)string+startpos;
+
+ while (range > 0) {
+ c = *p++;
+ if (ismbchar(c)) {
+ int len;
+
+ if (fastmap[c])
+ break;
+ len = mbclen(c) - 1;
+ while (len--) {
+ c = *p++;
+ range--;
+ if (fastmap[c] == 2)
+ goto startpos_adjust;
+ }
+ }
+ else {
+ if (fastmap[MAY_TRANSLATE() ? translate[c] : c])
+ break;
+ }
+ range--;
+ }
+ startpos_adjust:
+ startpos += irange - range;
+ }
+ else { /* Searching backwards. */
+ register unsigned char c;
+
+ c = string[startpos];
+ c &= 0xff;
+ if (MAY_TRANSLATE() ? !fastmap[translate[c]] : !fastmap[c])
+ goto advance;
+ }
+ }
+
+ if (startpos > size) return -1;
+ if ((anchor || !bufp->can_be_null) && range > 0 && size > 0 && startpos == size)
+ return -1;
+ val = re_match_exec(bufp, string, size, startpos, initpos, regs);
+ if (val >= 0) return startpos;
+ if (val == -2) return -2;
+
+#ifndef NO_ALLOCA
+#ifdef C_ALLOCA
+ alloca(0);
+#endif /* C_ALLOCA */
+#endif /* NO_ALLOCA */
+
+ if (range > 0) {
+ if (anchor && startpos < size &&
+ (startpos < 1 || string[startpos-1] != '\n')) {
+ while (range > 0 && string[startpos] != '\n') {
+ range--;
+ startpos++;
+ }
+ }
+ }
+
+ advance:
+ if (!range)
+ break;
+ else if (range > 0) {
+ const char *d = string + startpos;
+
+ if (ismbchar(*d)) {
+ int len = mbclen(*d) - 1;
+ range-=len, startpos+=len;
+ if (!range)
+ break;
+ }
+ range--, startpos++;
+ }
+ else {
+ range++, startpos--;
+ {
+ const char *s, *d, *p;
+
+ s = string; d = string + startpos;
+ for (p = d; p-- > s && ismbchar(*p); )
+ /* --p >= s would not work on 80[12]?86.
+ (when the offset of s equals 0 other than huge model.) */
+ ;
+ if (!((d - p) & 1)) {
+ if (!range)
+ break;
+ range++, startpos--;
+ }
+ }
+ }
+ }
+ return -1;
+}
+
+
+
+
+/* The following are used for re_match, defined below: */
+
+/* Accessing macros used in re_match: */
+
+#define IS_ACTIVE(R) ((R).bits.is_active)
+#define MATCHED_SOMETHING(R) ((R).bits.matched_something)
+
+
+/* Macros used by re_match: */
+
+/* I.e., regstart, regend, and reg_info. */
+#define NUM_REG_ITEMS 3
+
+/* I.e., ptr and count. */
+#define NUM_COUNT_ITEMS 2
+
+/* Individual items aside from the registers. */
+#define NUM_NONREG_ITEMS 4
+
+/* We push at most this many things on the stack whenever we
+ fail. The `+ 2' refers to PATTERN_PLACE and STRING_PLACE, which are
+ arguments to the PUSH_FAILURE_POINT macro. */
+#define MAX_NUM_FAILURE_ITEMS (num_regs * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
+
+/* We push this many things on the stack whenever we fail. */
+#define NUM_FAILURE_ITEMS (last_used_reg * NUM_REG_ITEMS + NUM_NONREG_ITEMS + 1)
+
+/* This pushes counter information for succeed_n and jump_n */
+#define PUSH_FAILURE_COUNT(ptr) \
+ do { \
+ int c; \
+ EXTRACT_NUMBER(c, ptr); \
+ ENSURE_FAIL_STACK(NUM_COUNT_ITEMS); \
+ *stackp++ = (unsigned char*)(long)c; \
+ *stackp++ = (ptr); \
+ num_failure_counts++; \
+ } while (0)
+
+/* This pushes most of the information about the current state we will want
+ if we ever fail back to it. */
+
+#define PUSH_FAILURE_POINT(pattern_place, string_place) \
+ do { \
+ long last_used_reg, this_reg; \
+ \
+ /* Find out how many registers are active or have been matched. \
+ (Aside from register zero, which is only set at the end.) */ \
+ for (last_used_reg = num_regs-1; last_used_reg > 0; last_used_reg--)\
+ if (!REG_UNSET(regstart[last_used_reg])) \
+ break; \
+ \
+ ENSURE_FAIL_STACK(NUM_FAILURE_ITEMS); \
+ *stackp++ = (unsigned char*)(long)num_failure_counts; \
+ num_failure_counts = 0; \
+ \
+ /* Now push the info for each of those registers. */ \
+ for (this_reg = 1; this_reg <= last_used_reg; this_reg++) { \
+ *stackp++ = regstart[this_reg]; \
+ *stackp++ = regend[this_reg]; \
+ *stackp++ = reg_info[this_reg].word; \
+ } \
+ \
+ /* Push how many registers we saved. */ \
+ *stackp++ = (unsigned char*)last_used_reg; \
+ \
+ *stackp++ = pattern_place; \
+ *stackp++ = string_place; \
+ *stackp++ = (unsigned char*)(long)options; /* current option status */ \
+ *stackp++ = (unsigned char*)0; /* non-greedy flag */ \
+ } while(0)
+
+#define NON_GREEDY ((unsigned char*)1)
+
+#define POP_FAILURE_COUNT() \
+ do { \
+ unsigned char *ptr = *--stackp; \
+ int count = (long)*--stackp; \
+ STORE_NUMBER(ptr, count); \
+ } while (0)
+
+/* This pops what PUSH_FAILURE_POINT pushes. */
+
+#define POP_FAILURE_POINT() \
+ do { \
+ long temp; \
+ stackp -= NUM_NONREG_ITEMS; /* Remove failure points (and flag). */ \
+ temp = (long)*--stackp; /* How many regs pushed. */ \
+ temp *= NUM_REG_ITEMS; /* How much to take off the stack. */ \
+ stackp -= temp; /* Remove the register info. */ \
+ temp = (long)*--stackp; /* How many counters pushed. */ \
+ while (temp--) { \
+ POP_FAILURE_COUNT(); /* Remove the counter info. */ \
+ } \
+ num_failure_counts = 0; /* Reset num_failure_counts. */ \
+ } while(0)
+
+ /* Registers are set to a sentinel when they haven't yet matched. */
+#define REG_UNSET_VALUE ((unsigned char*)-1)
+#define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
+
+#define PREFETCH if (d == dend) goto fail
+
+ /* Call this when have matched something; it sets `matched' flags for the
+ registers corresponding to the subexpressions of which we currently
+ are inside. */
+#define SET_REGS_MATCHED \
+ do { unsigned this_reg; \
+ for (this_reg = 0; this_reg < num_regs; this_reg++) { \
+ if (IS_ACTIVE(reg_info[this_reg])) \
+ MATCHED_SOMETHING(reg_info[this_reg]) = 1; \
+ else \
+ MATCHED_SOMETHING(reg_info[this_reg]) = 0; \
+ } \
+ } while(0)
+
+#define AT_STRINGS_BEG(d) ((d) == string)
+#define AT_STRINGS_END(d) ((d) == dend)
+
+#define IS_A_LETTER(d) (SYNTAX(*(d)) == Sword || \
+ (current_mbctype ? \
+ (re_mbctab[*(d)] && ((d)+mbclen(*(d)))<=dend): \
+ SYNTAX(*(d)) == Sword2))
+
+#define PREV_IS_A_LETTER(d) ((current_mbctype == MBCTYPE_SJIS)? \
+ IS_A_LETTER((d)-(!AT_STRINGS_BEG((d)-1)&& \
+ ismbchar((d)[-2])?2:1)): \
+ ((current_mbctype && ((d)[-1] >= 0x80)) || \
+ IS_A_LETTER((d)-1)))
+
+static void
+init_regs(regs, num_regs)
+ struct re_registers *regs;
+ unsigned int num_regs;
+{
+ int i;
+
+ regs->num_regs = num_regs;
+ if (num_regs < RE_NREGS)
+ num_regs = RE_NREGS;
+
+ if (regs->allocated == 0) {
+ regs->beg = TMALLOC(num_regs, int);
+ regs->end = TMALLOC(num_regs, int);
+ regs->allocated = num_regs;
+ }
+ else if (regs->allocated < num_regs) {
+ TREALLOC(regs->beg, num_regs, int);
+ TREALLOC(regs->end, num_regs, int);
+ regs->allocated = num_regs;
+ }
+ for (i=0; i<num_regs; i++) {
+ regs->beg[i] = regs->end[i] = -1;
+ }
+}
+
+/* Match the pattern described by BUFP against STRING, which is of
+ SIZE. Start the match at index POS in STRING. In REGS, return the
+ indices of STRING that matched the entire BUFP->buffer and its
+ contained subexpressions.
+
+ If bufp->fastmap is nonzero, then it had better be up to date.
+
+ The reason that the data to match are specified as two components
+ which are to be regarded as concatenated is so this function can be
+ used directly on the contents of an Emacs buffer.
+
+ -1 is returned if there is no match. -2 is returned if there is an
+ error (such as match stack overflow). Otherwise the value is the
+ length of the substring which was matched. */
+
+int
+re_match(bufp, string_arg, size, pos, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string_arg;
+ int size, pos;
+ struct re_registers *regs;
+{
+ return re_match_exec(bufp, string_arg, size, pos, pos, regs);
+}
+
+static int
+re_match_exec(bufp, string_arg, size, pos, beg, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string_arg;
+ int size, pos, beg;
+ struct re_registers *regs;
+{
+ register unsigned char *p = (unsigned char*)bufp->buffer;
+ unsigned char *p1;
+
+ /* Pointer to beyond end of buffer. */
+ register unsigned char *pend = p + bufp->used;
+
+ unsigned num_regs = bufp->re_nsub;
+
+ unsigned char *string = (unsigned char*)string_arg;
+
+ register unsigned char *d, *dend;
+ register int mcnt; /* Multipurpose. */
+ int options = bufp->options;
+
+ /* Failure point stack. Each place that can handle a failure further
+ down the line pushes a failure point on this stack. It consists of
+ restart, regend, and reg_info for all registers corresponding to the
+ subexpressions we're currently inside, plus the number of such
+ registers, and, finally, two char *'s. The first char * is where to
+ resume scanning the pattern; the second one is where to resume
+ scanning the strings. If the latter is zero, the failure point is a
+ ``dummy''; if a failure happens and the failure point is a dummy, it
+ gets discarded and the next next one is tried. */
+
+ unsigned char **const stacka = 0;
+ unsigned char **stackb;
+ unsigned char **stackp;
+ unsigned char **stacke;
+
+ /* Information on the contents of registers. These are pointers into
+ the input strings; they record just what was matched (on this
+ attempt) by a subexpression part of the pattern, that is, the
+ regnum-th regstart pointer points to where in the pattern we began
+ matching and the regnum-th regend points to right after where we
+ stopped matching the regnum-th subexpression. (The zeroth register
+ keeps track of what the whole pattern matches.) */
+
+ unsigned char **regstart = bufp->regstart;
+ unsigned char **regend = bufp->regend;
+
+ /* If a group that's operated upon by a repetition operator fails to
+ match anything, then the register for its start will need to be
+ restored because it will have been set to wherever in the string we
+ are when we last see its open-group operator. Similarly for a
+ register's end. */
+ unsigned char **old_regstart = bufp->old_regstart;
+ unsigned char **old_regend = bufp->old_regend;
+
+ /* The is_active field of reg_info helps us keep track of which (possibly
+ nested) subexpressions we are currently in. The matched_something
+ field of reg_info[reg_num] helps us tell whether or not we have
+ matched any of the pattern so far this time through the reg_num-th
+ subexpression. These two fields get reset each time through any
+ loop their register is in. */
+
+ register_info_type *reg_info = bufp->reg_info;
+
+ /* The following record the register info as found in the above
+ variables when we find a match better than any we've seen before.
+ This happens as we backtrack through the failure points, which in
+ turn happens only if we have not yet matched the entire string. */
+
+ unsigned best_regs_set = 0;
+ unsigned char **best_regstart = bufp->best_regstart;
+ unsigned char **best_regend = bufp->best_regend;
+
+ int num_failure_counts = 0;
+
+ if (regs) {
+ init_regs(regs, num_regs);
+ }
+
+ /* Initialize the stack. */
+ stackb = TMALLOC(MAX_NUM_FAILURE_ITEMS * NFAILURES, unsigned char*);
+ stackp = stackb;
+ stacke = &stackb[MAX_NUM_FAILURE_ITEMS * NFAILURES];
+
+#ifdef DEBUG_REGEX
+ fprintf(stderr, "Entering re_match(%s)\n", string_arg);
+#endif
+
+ /* Initialize subexpression text positions to -1 to mark ones that no
+ ( or ( and ) or ) has been seen for. Also set all registers to
+ inactive and mark them as not having matched anything or ever
+ failed. */
+ for (mcnt = 0; mcnt < num_regs; mcnt++) {
+ regstart[mcnt] = regend[mcnt]
+ = old_regstart[mcnt] = old_regend[mcnt]
+ = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE;
+#ifdef __CHECKER__
+ reg_info[mcnt].word = 0;
+#endif
+ IS_ACTIVE (reg_info[mcnt]) = 0;
+ MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+ }
+
+ /* Set up pointers to ends of strings.
+ Don't allow the second string to be empty unless both are empty. */
+
+
+ /* `p' scans through the pattern as `d' scans through the data. `dend'
+ is the end of the input string that `d' points within. `d' is
+ advanced into the following input string whenever necessary, but
+ this happens before fetching; therefore, at the beginning of the
+ loop, `d' can be pointing at the end of a string, but it cannot
+ equal string2. */
+
+ d = string + pos, dend = string + size;
+
+ /* This loops over pattern commands. It exits by returning from the
+ function if match is complete, or it drops through if match fails
+ at this starting point in the input data. */
+
+ for (;;) {
+#ifdef DEBUG_REGEX
+ fprintf(stderr,
+ "regex loop(%d): matching 0x%02d\n",
+ p - (unsigned char*)bufp->buffer,
+ *p);
+#endif
+ /* End of pattern means we might have succeeded. */
+ if (p == pend) {
+ /* If not end of string, try backtracking. Otherwise done. */
+ if ((bufp->options & RE_OPTION_LONGEST) && d != dend) {
+ if (best_regs_set) /* non-greedy, no need to backtrack */
+ goto restore_best_regs;
+ while (stackp != stackb && stackp[-1] == NON_GREEDY) {
+ if (best_regs_set) /* non-greedy, no need to backtrack */
+ goto restore_best_regs;
+ POP_FAILURE_POINT();
+ }
+ if (stackp != stackb) {
+ /* More failure points to try. */
+
+ /* If exceeds best match so far, save it. */
+ if (! best_regs_set || (d > best_regend[0])) {
+ best_regs_set = 1;
+ best_regend[0] = d; /* Never use regstart[0]. */
+
+ for (mcnt = 1; mcnt < num_regs; mcnt++) {
+ best_regstart[mcnt] = regstart[mcnt];
+ best_regend[mcnt] = regend[mcnt];
+ }
+ }
+ goto fail;
+ }
+ /* If no failure points, don't restore garbage. */
+ else if (best_regs_set) {
+ restore_best_regs:
+ /* Restore best match. */
+ d = best_regend[0];
+
+ for (mcnt = 0; mcnt < num_regs; mcnt++) {
+ regstart[mcnt] = best_regstart[mcnt];
+ regend[mcnt] = best_regend[mcnt];
+ }
+ }
+ }
+
+ /* If caller wants register contents data back, convert it
+ to indices. */
+ if (regs) {
+ regs->beg[0] = pos;
+ regs->end[0] = d - string;
+ for (mcnt = 1; mcnt < num_regs; mcnt++) {
+ if (REG_UNSET(regend[mcnt])) {
+ regs->beg[mcnt] = -1;
+ regs->end[mcnt] = -1;
+ continue;
+ }
+ regs->beg[mcnt] = regstart[mcnt] - string;
+ regs->end[mcnt] = regend[mcnt] - string;
+ }
+ }
+ FREE_AND_RETURN(stackb, (d - pos - string));
+ }
+
+ /* Otherwise match next pattern command. */
+#ifdef SWITCH_ENUM_BUG
+ switch ((int)((enum regexpcode)*p++))
+#else
+ switch ((enum regexpcode)*p++)
+#endif
+ {
+ /* ( [or `(', as appropriate] is represented by start_memory,
+ ) by stop_memory. Both of those commands are followed by
+ a register number in the next byte. The text matched
+ within the ( and ) is recorded under that number. */
+ case start_memory:
+ old_regstart[*p] = regstart[*p];
+ regstart[*p] = d;
+ IS_ACTIVE(reg_info[*p]) = 1;
+ MATCHED_SOMETHING(reg_info[*p]) = 0;
+ p += 2;
+ continue;
+
+ case stop_memory:
+ old_regend[*p] = regend[*p];
+ regend[*p] = d;
+ IS_ACTIVE(reg_info[*p]) = 0;
+ p += 2;
+ continue;
+
+ case start_paren:
+ case stop_paren:
+ break;
+
+ /* \<digit> has been turned into a `duplicate' command which is
+ followed by the numeric value of <digit> as the register number. */
+ case duplicate:
+ {
+ int regno = *p++; /* Get which register to match against */
+ register unsigned char *d2, *dend2;
+
+ /* Check if there's corresponding group */
+ if (regno >= num_regs) goto fail;
+ /* Check if corresponding group is still open */
+ if (IS_ACTIVE(reg_info[regno])) goto fail;
+
+ /* Where in input to try to start matching. */
+ d2 = regstart[regno];
+ if (REG_UNSET(d2)) goto fail;
+
+ /* Where to stop matching; if both the place to start and
+ the place to stop matching are in the same string, then
+ set to the place to stop, otherwise, for now have to use
+ the end of the first string. */
+
+ dend2 = regend[regno];
+ if (REG_UNSET(dend2)) goto fail;
+ for (;;) {
+ /* At end of register contents => success */
+ if (d2 == dend2) break;
+
+ /* If necessary, advance to next segment in data. */
+ PREFETCH;
+
+ /* How many characters left in this segment to match. */
+ mcnt = dend - d;
+
+ /* Want how many consecutive characters we can match in
+ one shot, so, if necessary, adjust the count. */
+ if (mcnt > dend2 - d2)
+ mcnt = dend2 - d2;
+
+ /* Compare that many; failure if mismatch, else move
+ past them. */
+ if ((options & RE_OPTION_IGNORECASE)
+ ? memcmp_translate(d, d2, mcnt)
+ : memcmp((char*)d, (char*)d2, mcnt))
+ goto fail;
+ d += mcnt, d2 += mcnt;
+ }
+ }
+ break;
+
+ case start_nowidth:
+ PUSH_FAILURE_POINT(0, d);
+ if (stackp - stackb > RE_DUP_MAX) {
+ FREE_AND_RETURN(stackb,(-2));
+ }
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ STORE_NUMBER(p+mcnt, stackp - stackb);
+ continue;
+
+ case stop_nowidth:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ stackp = stackb + mcnt;
+ d = stackp[-3];
+ POP_FAILURE_POINT();
+ continue;
+
+ case stop_backtrack:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ stackp = stackb + mcnt;
+ POP_FAILURE_POINT();
+ continue;
+
+ case pop_and_fail:
+ EXTRACT_NUMBER(mcnt, p+1);
+ stackp = stackb + mcnt;
+ POP_FAILURE_POINT();
+ goto fail;
+
+ case anychar:
+ PREFETCH;
+ if (ismbchar(*d)) {
+ if (d + mbclen(*d) > dend)
+ goto fail;
+ SET_REGS_MATCHED;
+ d += mbclen(*d);
+ break;
+ }
+ if (!(options&RE_OPTION_MULTILINE)
+ && (TRANSLATE_P() ? translate[*d] : *d) == '\n')
+ goto fail;
+ SET_REGS_MATCHED;
+ d++;
+ break;
+
+ case anychar_repeat:
+ for (;;) {
+ PUSH_FAILURE_POINT(p, d);
+ PREFETCH;
+ if (ismbchar(*d)) {
+ if (d + mbclen(*d) > dend)
+ goto fail;
+ SET_REGS_MATCHED;
+ d += mbclen(*d);
+ continue;
+ }
+ if (!(options&RE_OPTION_MULTILINE) &&
+ (TRANSLATE_P() ? translate[*d] : *d) == '\n')
+ goto fail;
+ SET_REGS_MATCHED;
+ d++;
+ }
+ break;
+
+ case charset:
+ case charset_not:
+ {
+ int not; /* Nonzero for charset_not. */
+ int part = 0; /* true if matched part of mbc */
+ unsigned char *dsave = d + 1;
+ int cc, c;
+
+ PREFETCH;
+ c = (unsigned char)*d++;
+ if (ismbchar(c)) {
+ if (d + mbclen(c) - 1 <= dend) {
+ cc = c;
+ MBC2WC(c, d);
+ not = is_in_list_mbc(c, p);
+ if (!not) {
+ part = not = is_in_list_sbc(cc, p);
+ }
+ } else {
+ not = is_in_list(c, p);
+ }
+ }
+ else {
+ if (TRANSLATE_P())
+ c = (unsigned char)translate[c];
+ not = is_in_list(c, p);
+ }
+
+ if (*(p - 1) == (unsigned char)charset_not) {
+ not = !not;
+ }
+ if (!not) goto fail;
+
+ p += 1 + *p + 2 + EXTRACT_UNSIGNED(&p[1 + *p])*8;
+ SET_REGS_MATCHED;
+
+ if (part) d = dsave;
+ break;
+ }
+
+ case begline:
+ if (size == 0 || AT_STRINGS_BEG(d))
+ break;
+ if (d[-1] == '\n' && !AT_STRINGS_END(d))
+ break;
+ goto fail;
+
+ case endline:
+ if (AT_STRINGS_END(d)) {
+ break;
+ }
+ else if (*d == '\n')
+ break;
+ goto fail;
+
+ /* Match at the very beginning of the string. */
+ case begbuf:
+ if (AT_STRINGS_BEG(d))
+ break;
+ goto fail;
+
+ /* Match at the very end of the data. */
+ case endbuf:
+ if (AT_STRINGS_END(d))
+ break;
+ goto fail;
+
+ /* Match at the very end of the data. */
+ case endbuf2:
+ if (AT_STRINGS_END(d)) {
+ break;
+ }
+ /* .. or newline just before the end of the data. */
+ if (*d == '\n' && AT_STRINGS_END(d+1))
+ break;
+ goto fail;
+
+ /* `or' constructs are handled by starting each alternative with
+ an on_failure_jump that points to the start of the next
+ alternative. Each alternative except the last ends with a
+ jump to the joining point. (Actually, each jump except for
+ the last one really jumps to the following jump, because
+ tensioning the jumps is a hassle.) */
+
+ /* The start of a stupid repeat has an on_failure_jump that points
+ past the end of the repeat text. This makes a failure point so
+ that on failure to match a repetition, matching restarts past
+ as many repetitions have been found with no way to fail and
+ look for another one. */
+
+ /* A smart repeat is similar but loops back to the on_failure_jump
+ so that each repetition makes another failure point. */
+
+ /* Match at the starting position. */
+ case begpos:
+ if (d - string == beg)
+ break;
+ goto fail;
+
+ case on_failure_jump:
+ on_failure:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ PUSH_FAILURE_POINT(p + mcnt, d);
+ continue;
+
+ /* The end of a smart repeat has a maybe_finalize_jump back.
+ Change it either to a finalize_jump or an ordinary jump. */
+ case maybe_finalize_jump:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ p1 = p;
+
+ /* Compare the beginning of the repeat with what in the
+ pattern follows its end. If we can establish that there
+ is nothing that they would both match, i.e., that we
+ would have to backtrack because of (as in, e.g., `a*a')
+ then we can change to finalize_jump, because we'll
+ never have to backtrack.
+
+ This is not true in the case of alternatives: in
+ `(a|ab)*' we do need to backtrack to the `ab' alternative
+ (e.g., if the string was `ab'). But instead of trying to
+ detect that here, the alternative has put on a dummy
+ failure point which is what we will end up popping. */
+
+ /* Skip over open/close-group commands. */
+ while (p1 + 2 < pend) {
+ if ((enum regexpcode)*p1 == stop_memory ||
+ (enum regexpcode)*p1 == start_memory)
+ p1 += 3; /* Skip over args, too. */
+ else if (/*(enum regexpcode)*p1 == start_paren ||*/
+ (enum regexpcode)*p1 == stop_paren)
+ p1 += 1;
+ else
+ break;
+ }
+
+ if (p1 == pend)
+ p[-3] = (unsigned char)finalize_jump;
+ else if (*p1 == (unsigned char)exactn ||
+ *p1 == (unsigned char)endline) {
+ register int c = *p1 == (unsigned char)endline ? '\n' : p1[2];
+ register unsigned char *p2 = p + mcnt;
+ /* p2[0] ... p2[2] are an on_failure_jump.
+ Examine what follows that. */
+ if (p2[3] == (unsigned char)exactn && p2[5] != c)
+ p[-3] = (unsigned char)finalize_jump;
+ else if (p2[3] == (unsigned char)charset ||
+ p2[3] == (unsigned char)charset_not) {
+ int not;
+ if (ismbchar(c)) {
+ unsigned char *pp = p1+3;
+ MBC2WC(c, pp);
+ }
+ /* `is_in_list()' is TRUE if c would match */
+ /* That means it is not safe to finalize. */
+ not = is_in_list(c, p2 + 4);
+ if (p2[3] == (unsigned char)charset_not)
+ not = !not;
+ if (!not)
+ p[-3] = (unsigned char)finalize_jump;
+ }
+ }
+ p -= 2; /* Point at relative address again. */
+ if (p[-1] != (unsigned char)finalize_jump) {
+ p[-1] = (unsigned char)jump;
+ goto nofinalize;
+ }
+ /* Note fall through. */
+
+ /* The end of a stupid repeat has a finalize_jump back to the
+ start, where another failure point will be made which will
+ point to after all the repetitions found so far. */
+
+ /* Take off failure points put on by matching on_failure_jump
+ because didn't fail. Also remove the register information
+ put on by the on_failure_jump. */
+ case finalize_jump:
+ if (stackp > stackb && stackp[-3] == d) {
+ p = stackp[-4];
+ POP_FAILURE_POINT();
+ continue;
+ }
+ POP_FAILURE_POINT();
+ /* Note fall through. */
+
+ /* We need this opcode so we can detect where alternatives end
+ in `group_match_null_string_p' et al. */
+ case jump_past_alt:
+ /* fall through */
+
+ /* Jump without taking off any failure points. */
+ case jump:
+ nofinalize:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ if (mcnt < 0 && stackp > stackb && stackp[-3] == d) /* avoid infinite loop */
+ goto fail;
+ p += mcnt;
+ continue;
+
+ case dummy_failure_jump:
+ /* Normally, the on_failure_jump pushes a failure point, which
+ then gets popped at finalize_jump. We will end up at
+ finalize_jump, also, and with a pattern of, say, `a+', we
+ are skipping over the on_failure_jump, so we have to push
+ something meaningless for finalize_jump to pop. */
+ PUSH_FAILURE_POINT(0, 0);
+ goto nofinalize;
+
+ /* At the end of an alternative, we need to push a dummy failure
+ point in case we are followed by a `finalize_jump', because
+ we don't want the failure point for the alternative to be
+ popped. For example, matching `(a|ab)*' against `aab'
+ requires that we match the `ab' alternative. */
+ case push_dummy_failure:
+ /* See comments just above at `dummy_failure_jump' about the
+ two zeroes. */
+ p1 = p;
+ /* Skip over open/close-group commands. */
+ while (p1 + 2 < pend) {
+ if ((enum regexpcode)*p1 == stop_memory ||
+ (enum regexpcode)*p1 == start_memory)
+ p1 += 3; /* Skip over args, too. */
+ else if (/*(enum regexpcode)*p1 == start_paren ||*/
+ (enum regexpcode)*p1 == stop_paren)
+ p1 += 1;
+ else
+ break;
+ }
+ if (p1 < pend && (enum regexpcode)*p1 == jump)
+ p[-1] = unused;
+ else
+ PUSH_FAILURE_POINT(0, 0);
+ break;
+
+ /* Have to succeed matching what follows at least n times. Then
+ just handle like an on_failure_jump. */
+ case succeed_n:
+ EXTRACT_NUMBER(mcnt, p + 2);
+ /* Originally, this is how many times we HAVE to succeed. */
+ if (mcnt != 0) {
+ mcnt--;
+ p += 2;
+ PUSH_FAILURE_COUNT(p);
+ STORE_NUMBER_AND_INCR(p, mcnt);
+ PUSH_FAILURE_POINT(0, 0);
+ }
+ else {
+ goto on_failure;
+ }
+ continue;
+
+ case jump_n:
+ EXTRACT_NUMBER(mcnt, p + 2);
+ /* Originally, this is how many times we CAN jump. */
+ if (mcnt) {
+ mcnt--;
+ PUSH_FAILURE_COUNT(p + 2);
+ STORE_NUMBER(p + 2, mcnt);
+ goto nofinalize; /* Do the jump without taking off
+ any failure points. */
+ }
+ /* If don't have to jump any more, skip over the rest of command. */
+ else
+ p += 4;
+ continue;
+
+ case set_number_at:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ p1 = p + mcnt;
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ STORE_NUMBER(p1, mcnt);
+ continue;
+
+ case try_next:
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ if (p + mcnt < pend) {
+ PUSH_FAILURE_POINT(p, d);
+ stackp[-1] = NON_GREEDY;
+ }
+ p += mcnt;
+ continue;
+
+ case finalize_push:
+ POP_FAILURE_POINT();
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ if (mcnt < 0 && stackp > stackb && stackp[-3] == d) /* avoid infinite loop */
+ goto fail;
+ PUSH_FAILURE_POINT(p + mcnt, d);
+ stackp[-1] = NON_GREEDY;
+ continue;
+
+ case finalize_push_n:
+ EXTRACT_NUMBER(mcnt, p + 2);
+ /* Originally, this is how many times we CAN jump. */
+ if (mcnt) {
+ int pos, i;
+
+ mcnt--;
+ STORE_NUMBER(p + 2, mcnt);
+ EXTRACT_NUMBER(pos, p);
+ EXTRACT_NUMBER(i, p+pos+5);
+ if (i > 0) goto nofinalize;
+ POP_FAILURE_POINT();
+ EXTRACT_NUMBER_AND_INCR(mcnt, p);
+ PUSH_FAILURE_POINT(p + mcnt, d);
+ stackp[-1] = NON_GREEDY;
+ p += 2; /* skip n */
+ }
+ /* If don't have to push any more, skip over the rest of command. */
+ else
+ p += 4;
+ continue;
+
+ /* Ignore these. Used to ignore the n of succeed_n's which
+ currently have n == 0. */
+ case unused:
+ continue;
+
+ case casefold_on:
+ options |= RE_OPTION_IGNORECASE;
+ continue;
+
+ case casefold_off:
+ options &= ~RE_OPTION_IGNORECASE;
+ continue;
+
+ case option_set:
+ options = *p++;
+ continue;
+
+ case wordbound:
+ if (AT_STRINGS_BEG(d)) {
+ if (AT_STRINGS_END(d)) goto fail;
+ if (IS_A_LETTER(d)) break;
+ else goto fail;
+ }
+ if (AT_STRINGS_END(d)) {
+ if (PREV_IS_A_LETTER(d)) break;
+ else goto fail;
+ }
+ if (PREV_IS_A_LETTER(d) != IS_A_LETTER(d))
+ break;
+ goto fail;
+
+ case notwordbound:
+ if (AT_STRINGS_BEG(d)) {
+ if (IS_A_LETTER(d)) goto fail;
+ else break;
+ }
+ if (AT_STRINGS_END(d)) {
+ if (PREV_IS_A_LETTER(d)) goto fail;
+ else break;
+ }
+ if (PREV_IS_A_LETTER(d) != IS_A_LETTER(d))
+ goto fail;
+ break;
+
+ case wordbeg:
+ if (IS_A_LETTER(d) && (AT_STRINGS_BEG(d) || !PREV_IS_A_LETTER(d)))
+ break;
+ goto fail;
+
+ case wordend:
+ if (!AT_STRINGS_BEG(d) && PREV_IS_A_LETTER(d)
+ && (!IS_A_LETTER(d) || AT_STRINGS_END(d)))
+ break;
+ goto fail;
+
+ case wordchar:
+ PREFETCH;
+ if (!IS_A_LETTER(d))
+ goto fail;
+ if (ismbchar(*d) && d + mbclen(*d) - 1 < dend)
+ d += mbclen(*d) - 1;
+ d++;
+ SET_REGS_MATCHED;
+ break;
+
+ case notwordchar:
+ PREFETCH;
+ if (IS_A_LETTER(d))
+ goto fail;
+ if (ismbchar(*d) && d + mbclen(*d) - 1 < dend)
+ d += mbclen(*d) - 1;
+ d++;
+ SET_REGS_MATCHED;
+ break;
+
+ case exactn:
+ /* Match the next few pattern characters exactly.
+ mcnt is how many characters to match. */
+ mcnt = *p++;
+ /* This is written out as an if-else so we don't waste time
+ testing `translate' inside the loop. */
+ if (TRANSLATE_P()) {
+ do {
+ unsigned char c;
+
+ PREFETCH;
+ if (*p == 0xff) {
+ p++;
+ if (!--mcnt
+ || AT_STRINGS_END(d)
+ || (unsigned char)*d++ != (unsigned char)*p++)
+ goto fail;
+ continue;
+ }
+ c = *d++;
+ if (ismbchar(c)) {
+ int n;
+
+ if (c != (unsigned char)*p++)
+ goto fail;
+ for (n = mbclen(c) - 1; n > 0; n--)
+ if (!--mcnt /* redundant check if pattern was
+ compiled properly. */
+ || AT_STRINGS_END(d)
+ || (unsigned char)*d++ != (unsigned char)*p++)
+ goto fail;
+ continue;
+ }
+ /* compiled code translation needed for ruby */
+ if ((unsigned char)translate[c] != (unsigned char)translate[*p++])
+ goto fail;
+ }
+ while (--mcnt);
+ }
+ else {
+ do {
+ PREFETCH;
+ if (*p == 0xff) {p++; mcnt--;}
+ if (*d++ != *p++) goto fail;
+ }
+ while (--mcnt);
+ }
+ SET_REGS_MATCHED;
+ break;
+ }
+#ifdef RUBY
+ CHECK_INTS;
+#endif
+ continue; /* Successfully executed one pattern command; keep going. */
+
+ /* Jump here if any matching operation fails. */
+ fail:
+ if (stackp != stackb) {
+ /* A restart point is known. Restart there and pop it. */
+ short last_used_reg, this_reg;
+
+ /* If this failure point is from a dummy_failure_point, just
+ skip it. */
+ if (stackp[-4] == 0 || (best_regs_set && stackp[-1] == NON_GREEDY)) {
+ POP_FAILURE_POINT();
+ goto fail;
+ }
+ stackp--; /* discard greedy flag */
+ options = (long)*--stackp;
+ d = *--stackp;
+ p = *--stackp;
+ /* Restore register info. */
+ last_used_reg = (long)*--stackp;
+
+ /* Make the ones that weren't saved -1 or 0 again. */
+ for (this_reg = num_regs - 1; this_reg > last_used_reg; this_reg--) {
+ regend[this_reg] = REG_UNSET_VALUE;
+ regstart[this_reg] = REG_UNSET_VALUE;
+ IS_ACTIVE(reg_info[this_reg]) = 0;
+ MATCHED_SOMETHING(reg_info[this_reg]) = 0;
+ }
+
+ /* And restore the rest from the stack. */
+ for ( ; this_reg > 0; this_reg--) {
+ reg_info[this_reg].word = *--stackp;
+ regend[this_reg] = *--stackp;
+ regstart[this_reg] = *--stackp;
+ }
+ mcnt = (long)*--stackp;
+ while (mcnt--) {
+ POP_FAILURE_COUNT();
+ }
+ if (p < pend) {
+ int is_a_jump_n = 0;
+ int failed_paren = 0;
+
+ p1 = p;
+ /* If failed to a backwards jump that's part of a repetition
+ loop, need to pop this failure point and use the next one. */
+ switch ((enum regexpcode)*p1) {
+ case jump_n:
+ case finalize_push_n:
+ is_a_jump_n = 1;
+ case maybe_finalize_jump:
+ case finalize_jump:
+ case finalize_push:
+ case jump:
+ p1++;
+ EXTRACT_NUMBER_AND_INCR(mcnt, p1);
+
+ if (mcnt >= 0) break; /* should be backward jump */
+ p1 += mcnt;
+
+ if (( is_a_jump_n && (enum regexpcode)*p1 == succeed_n) ||
+ (!is_a_jump_n && (enum regexpcode)*p1 == on_failure_jump)) {
+ if (failed_paren) {
+ p1++;
+ EXTRACT_NUMBER_AND_INCR(mcnt, p1);
+ PUSH_FAILURE_POINT(p1 + mcnt, d);
+ }
+ goto fail;
+ }
+ break;
+ default:
+ /* do nothing */;
+ }
+ }
+ }
+ else
+ break; /* Matching at this starting point really fails. */
+ }
+
+ if (best_regs_set)
+ goto restore_best_regs;
+
+ FREE_AND_RETURN(stackb,(-1)); /* Failure to match. */
+ memory_exhausted:
+ FREE_AND_RETURN(stackb,(-2));
+}
+
+
+static int
+memcmp_translate(s1, s2, len)
+ unsigned char *s1, *s2;
+ register int len;
+{
+ register unsigned char *p1 = s1, *p2 = s2, c;
+ while (len) {
+ c = *p1++;
+ if (ismbchar(c)) {
+ int n;
+
+ if (c != *p2++) return 1;
+ for (n = mbclen(c) - 1; n > 0; n--)
+ if (!--len || *p1++ != *p2++)
+ return 1;
+ }
+ else
+ if (translate[c] != translate[*p2++])
+ return 1;
+ len--;
+ }
+ return 0;
+}
+
+void
+re_copy_registers(regs1, regs2)
+ struct re_registers *regs1, *regs2;
+{
+ int i;
+
+ if (regs1 == regs2) return;
+ if (regs1->allocated == 0) {
+ regs1->beg = TMALLOC(regs2->num_regs, int);
+ regs1->end = TMALLOC(regs2->num_regs, int);
+ regs1->allocated = regs2->num_regs;
+ }
+ else if (regs1->allocated < regs2->num_regs) {
+ TREALLOC(regs1->beg, regs2->num_regs, int);
+ TREALLOC(regs1->end, regs2->num_regs, int);
+ regs1->allocated = regs2->num_regs;
+ }
+ for (i=0; i<regs2->num_regs; i++) {
+ regs1->beg[i] = regs2->beg[i];
+ regs1->end[i] = regs2->end[i];
+ }
+ regs1->num_regs = regs2->num_regs;
+}
+
+void
+re_free_registers(regs)
+ struct re_registers *regs;
+{
+ if (regs->allocated == 0) return;
+ if (regs->beg) xfree(regs->beg);
+ if (regs->end) xfree(regs->end);
+}
+
+/* Functions for multi-byte support.
+ Created for grep multi-byte extension Jul., 1993 by t^2 (Takahiro Tanimoto)
+ Last change: Jul. 9, 1993 by t^2 */
+static const unsigned char mbctab_ascii[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+static const unsigned char mbctab_euc[] = { /* 0xA1-0xFE */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
+};
+
+static const unsigned char mbctab_sjis[] = { /* 0x81-0x9F,0xE0-0xFC */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0
+};
+
+static const unsigned char mbctab_sjis_trail[] = { /* 0x40-0x7E,0x80-0xFC */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0
+};
+
+static const unsigned char mbctab_utf8[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 0, 0,
+};
+
+const unsigned char *re_mbctab = mbctab_ascii;
+
+void
+re_mbcinit(mbctype)
+ int mbctype;
+{
+ switch (mbctype) {
+ case MBCTYPE_ASCII:
+ re_mbctab = mbctab_ascii;
+ current_mbctype = MBCTYPE_ASCII;
+ break;
+ case MBCTYPE_EUC:
+ re_mbctab = mbctab_euc;
+ current_mbctype = MBCTYPE_EUC;
+ break;
+ case MBCTYPE_SJIS:
+ re_mbctab = mbctab_sjis;
+ current_mbctype = MBCTYPE_SJIS;
+ break;
+ case MBCTYPE_UTF8:
+ re_mbctab = mbctab_utf8;
+ current_mbctype = MBCTYPE_UTF8;
+ break;
+ }
+}
+
+#define mbc_isfirst(t, c) (t)[(unsigned char)(c)]
+#define mbc_len(t, c) ((t)[(unsigned char)(c)]+1)
+
+static unsigned int
+asc_startpos(string, pos)
+ const char *string;
+ unsigned int pos;
+{
+ return pos;
+}
+
+#define euc_islead(c) ((unsigned char)((c) - 0xa1) > 0xfe - 0xa1)
+#define euc_mbclen(c) mbc_len(mbctab_euc, (c))
+static unsigned int
+euc_startpos(string, pos)
+ const char *string;
+ unsigned int pos;
+{
+ unsigned int i = pos, w;
+
+ while (i > 0 && !euc_islead(string[i])) {
+ --i;
+ }
+ if (i == pos || i + (w = euc_mbclen(string[i])) > pos) {
+ return i;
+ }
+ i += w;
+ return i + ((pos - i) & ~1);
+}
+
+#define sjis_isfirst(c) mbc_isfirst(mbctab_sjis, (c))
+#define sjis_istrail(c) mbctab_sjis_trail[(unsigned char)(c)]
+#define sjis_mbclen(c) mbc_len(mbctab_sjis, (c))
+static unsigned int
+sjis_startpos(string, pos)
+ const char *string;
+ unsigned int pos;
+{
+ unsigned int i = pos, w;
+
+ if (i > 0 && sjis_istrail(string[i])) {
+ do {
+ if (!sjis_isfirst(string[--i])) {
+ ++i;
+ break;
+ }
+ } while (i > 0);
+ }
+ if (i == pos || i + (w = sjis_mbclen(string[i])) > pos) {
+ return i;
+ }
+ i += w;
+ return i + ((pos - i) & ~1);
+}
+
+#define utf8_islead(c) ((unsigned char)((c) & 0xc0) != 0x80)
+#define utf8_mbclen(c) mbc_len(mbctab_utf8, (c))
+static unsigned int
+utf8_startpos(string, pos)
+ const char *string;
+ unsigned int pos;
+{
+ unsigned int i = pos, w;
+
+ while (i > 0 && !utf8_islead(string[i])) {
+ --i;
+ }
+ if (i == pos || i + (w = utf8_mbclen(string[i])) > pos) {
+ return i;
+ }
+ return i + w;
+}
+
+/*
+ vi: sw=2 ts=8
+ Local variables:
+ mode : C
+ c-file-style : "gnu"
+ tab-width : 8
+ End
+*/
diff --git a/regex.h b/regex.h
new file mode 100644
index 0000000000..fe4dbbb9ab
--- /dev/null
+++ b/regex.h
@@ -0,0 +1,221 @@
+/* Definitions for data structures and routines for the regular
+ expression library, version 0.12.
+ Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in /gd/gnu/lib.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file LGPL. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto)
+ Last change: May 21, 1993 by t^2 */
+/* modified for Ruby by matz@netlab.co.jp */
+
+#ifndef REGEX_H
+#define REGEX_H
+
+/* symbol mangling for ruby */
+#ifdef RUBY
+# define re_adjust_startpos ruby_re_adjust_startpos
+# define re_compile_fastmap ruby_re_compile_fastmap
+# define re_compile_pattern ruby_re_compile_pattern
+# define re_copy_registers ruby_re_copy_registers
+# define re_free_pattern ruby_re_free_pattern
+# define re_free_registers ruby_re_free_registers
+# define re_match ruby_re_match
+# define re_mbcinit ruby_re_mbcinit
+# define re_search ruby_re_search
+# define re_set_casetable ruby_re_set_casetable
+# define register_info_type ruby_register_info_type
+#endif
+
+#include <stddef.h>
+
+/* Define number of parens for which we record the beginnings and ends.
+ This affects how much space the `struct re_registers' type takes up. */
+#ifndef RE_NREGS
+#define RE_NREGS 10
+#endif
+
+#define BYTEWIDTH 8
+
+#define RE_REG_MAX ((1<<BYTEWIDTH)-1)
+
+/* Maximum number of duplicates an interval can allow. */
+#ifndef RE_DUP_MAX
+#define RE_DUP_MAX ((1 << 15) - 1)
+#endif
+
+
+/* If this bit is set, then character classes are supported; they are:
+ [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
+ [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+ If not set, then character classes are not supported. */
+#define RE_CHAR_CLASSES (1L << 9)
+
+/* match will be done case insensetively */
+#define RE_OPTION_IGNORECASE (1L)
+/* perl-style extended pattern available */
+#define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1)
+/* newline will be included for . */
+#define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1)
+/* ^ and $ ignore newline */
+#define RE_OPTION_SINGLELINE (RE_OPTION_MULTILINE<<1)
+/* search for longest match, in accord with POSIX regexp */
+#define RE_OPTION_LONGEST (RE_OPTION_SINGLELINE<<1)
+
+#define RE_MAY_IGNORECASE (RE_OPTION_LONGEST<<1)
+#define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
+#define RE_OPTIMIZE_EXACTN (RE_OPTIMIZE_ANCHOR<<1)
+#define RE_OPTIMIZE_NO_BM (RE_OPTIMIZE_EXACTN<<1)
+#define RE_OPTIMIZE_BMATCH (RE_OPTIMIZE_NO_BM<<1)
+
+/* For multi-byte char support */
+#define MBCTYPE_ASCII 0
+#define MBCTYPE_EUC 1
+#define MBCTYPE_SJIS 2
+#define MBCTYPE_UTF8 3
+
+extern
+#if defined _WIN32 && !defined __GNUC__ && !defined RUBY_EXPORT
+__declspec(dllimport)
+# endif
+const unsigned char *re_mbctab;
+#if defined(__STDC__)
+void re_mbcinit (int);
+#else
+void re_mbcinit ();
+#endif
+
+#undef ismbchar
+#define ismbchar(c) re_mbctab[(unsigned char)(c)]
+#define mbclen(c) (re_mbctab[(unsigned char)(c)]+1)
+
+/* Structure used in re_match() */
+
+typedef union
+{
+ unsigned char *word;
+ struct {
+ unsigned is_active : 1;
+ unsigned matched_something : 1;
+ } bits;
+} register_info_type;
+
+/* This data structure is used to represent a compiled pattern. */
+
+struct re_pattern_buffer
+ {
+ char *buffer; /* Space holding the compiled pattern commands. */
+ int allocated; /* Size of space that `buffer' points to. */
+ int used; /* Length of portion of buffer actually occupied */
+ char *fastmap; /* Pointer to fastmap, if any, or zero if none. */
+ /* re_search uses the fastmap, if there is one,
+ to skip over totally implausible characters. */
+ char *must; /* Pointer to exact pattern which strings should have
+ to be matched. */
+ int *must_skip; /* Pointer to exact pattern skip table for bm_search */
+ long options; /* Flags for options such as extended_pattern. */
+ long re_nsub; /* Number of subexpressions found by the compiler. */
+ char fastmap_accurate;
+ /* Set to zero when a new pattern is stored,
+ set to one when the fastmap is updated from it. */
+ char can_be_null; /* Set to one by compiling fastmap
+ if this pattern might match the null string.
+ It does not necessarily match the null string
+ in that case, but if this is zero, it cannot.
+ 2 as value means can match null string
+ but at end of range or before a character
+ listed in the fastmap. */
+
+ /* stack & working area for re_match() */
+ unsigned char **regstart;
+ unsigned char **regend;
+ unsigned char **old_regstart;
+ unsigned char **old_regend;
+ register_info_type *reg_info;
+ unsigned char **best_regstart;
+ unsigned char **best_regend;
+ };
+
+typedef struct re_pattern_buffer regex_t;
+
+/* Structure to store register contents data in.
+
+ Pass the address of such a structure as an argument to re_match, etc.,
+ if you want this information back.
+
+ For i from 1 to RE_NREGS - 1, start[i] records the starting index in
+ the string of where the ith subexpression matched, and end[i] records
+ one after the ending index. start[0] and end[0] are analogous, for
+ the entire pattern. */
+
+struct re_registers
+ {
+ int allocated;
+ int num_regs;
+ int *beg;
+ int *end;
+ };
+
+/* Type for byte offsets within the string. POSIX mandates this. */
+typedef size_t regoff_t;
+
+/* POSIX specification for registers. Aside from the different names than
+ `re_registers', POSIX uses an array of structures, instead of a
+ structure of arrays. */
+typedef struct
+{
+ regoff_t rm_so; /* Byte offset from string's start to substring's start. */
+ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
+} regmatch_t;
+
+#ifdef __STDC__
+
+extern const char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
+void re_free_pattern (struct re_pattern_buffer *);
+/* Is this really advertised? */
+extern int re_adjust_startpos (struct re_pattern_buffer *, const char*, int, int, int);
+extern void re_compile_fastmap (struct re_pattern_buffer *);
+extern int re_search (struct re_pattern_buffer *, const char*, int, int, int,
+ struct re_registers *);
+extern int re_match (struct re_pattern_buffer *, const char *, int, int,
+ struct re_registers *);
+extern void re_set_casetable (const char *table);
+extern void re_copy_registers (struct re_registers*, struct re_registers*);
+extern void re_free_registers (struct re_registers*);
+
+#ifndef RUBY
+/* 4.2 bsd compatibility. */
+extern char *re_comp (const char *);
+extern int re_exec (const char *);
+#endif
+
+#else /* !__STDC__ */
+
+extern const char *re_compile_pattern ();
+void re_free_regexp ();
+/* Is this really advertised? */
+extern int re_adjust_startpos ();
+extern void re_compile_fastmap ();
+extern int re_search ();
+extern int re_match ();
+extern void re_set_casetable ();
+extern void re_copy_registers ();
+extern void re_free_registers ();
+
+#endif /* __STDC__ */
+
+#endif /* !REGEX_H */
diff --git a/regexec.c b/regexec.c
deleted file mode 100644
index 84d69659c2..0000000000
--- a/regexec.c
+++ /dev/null
@@ -1,3802 +0,0 @@
-/**********************************************************************
- regexec.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-#ifdef USE_CRNL_AS_LINE_TERMINATOR
-#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
- (ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \
- ONIGENC_IS_MBC_NEWLINE(enc,(p+enc_len(enc,p)),end))
-#endif
-
-#ifdef USE_CAPTURE_HISTORY
-static void history_tree_free(OnigCaptureTreeNode* node);
-
-static void
-history_tree_clear(OnigCaptureTreeNode* node)
-{
- int i;
-
- if (IS_NOT_NULL(node)) {
- for (i = 0; i < node->num_childs; i++) {
- if (IS_NOT_NULL(node->childs[i])) {
- history_tree_free(node->childs[i]);
- }
- }
- for (i = 0; i < node->allocated; i++) {
- node->childs[i] = (OnigCaptureTreeNode* )0;
- }
- node->num_childs = 0;
- node->beg = ONIG_REGION_NOTPOS;
- node->end = ONIG_REGION_NOTPOS;
- node->group = -1;
- }
-}
-
-static void
-history_tree_free(OnigCaptureTreeNode* node)
-{
- history_tree_clear(node);
- xfree(node);
-}
-
-static void
-history_root_free(OnigRegion* r)
-{
- if (IS_NOT_NULL(r->history_root)) {
- history_tree_free(r->history_root);
- r->history_root = (OnigCaptureTreeNode* )0;
- }
-}
-
-static OnigCaptureTreeNode*
-history_node_new(void)
-{
- OnigCaptureTreeNode* node;
-
- node = (OnigCaptureTreeNode* )xmalloc(sizeof(OnigCaptureTreeNode));
- CHECK_NULL_RETURN(node);
- node->childs = (OnigCaptureTreeNode** )0;
- node->allocated = 0;
- node->num_childs = 0;
- node->group = -1;
- node->beg = ONIG_REGION_NOTPOS;
- node->end = ONIG_REGION_NOTPOS;
-
- return node;
-}
-
-static int
-history_tree_add_child(OnigCaptureTreeNode* parent, OnigCaptureTreeNode* child)
-{
-#define HISTORY_TREE_INIT_ALLOC_SIZE 8
-
- if (parent->num_childs >= parent->allocated) {
- int n, i;
-
- if (IS_NULL(parent->childs)) {
- n = HISTORY_TREE_INIT_ALLOC_SIZE;
- parent->childs =
- (OnigCaptureTreeNode** )xmalloc(sizeof(OnigCaptureTreeNode*) * n);
- }
- else {
- n = parent->allocated * 2;
- parent->childs =
- (OnigCaptureTreeNode** )xrealloc(parent->childs,
- sizeof(OnigCaptureTreeNode*) * n);
- }
- CHECK_NULL_RETURN_MEMERR(parent->childs);
- for (i = parent->allocated; i < n; i++) {
- parent->childs[i] = (OnigCaptureTreeNode* )0;
- }
- parent->allocated = n;
- }
-
- parent->childs[parent->num_childs] = child;
- parent->num_childs++;
- return 0;
-}
-
-static OnigCaptureTreeNode*
-history_tree_clone(OnigCaptureTreeNode* node)
-{
- int i;
- OnigCaptureTreeNode *clone, *child;
-
- clone = history_node_new();
- CHECK_NULL_RETURN(clone);
-
- clone->beg = node->beg;
- clone->end = node->end;
- for (i = 0; i < node->num_childs; i++) {
- child = history_tree_clone(node->childs[i]);
- if (IS_NULL(child)) {
- history_tree_free(clone);
- return (OnigCaptureTreeNode* )0;
- }
- history_tree_add_child(clone, child);
- }
-
- return clone;
-}
-
-extern OnigCaptureTreeNode*
-onig_get_capture_tree(OnigRegion* region)
-{
- return region->history_root;
-}
-#endif /* USE_CAPTURE_HISTORY */
-
-extern void
-onig_region_clear(OnigRegion* region)
-{
- int i;
-
- for (i = 0; i < region->num_regs; i++) {
- region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS;
- }
-#ifdef USE_CAPTURE_HISTORY
- history_root_free(region);
-#endif
-}
-
-extern int
-onig_region_resize(OnigRegion* region, int n)
-{
- region->num_regs = n;
-
- if (n < ONIG_NREGION)
- n = ONIG_NREGION;
-
- if (region->allocated == 0) {
- region->beg = (int* )xmalloc(n * sizeof(int));
- region->end = (int* )xmalloc(n * sizeof(int));
-
- if (region->beg == 0 || region->end == 0)
- return ONIGERR_MEMORY;
-
- region->allocated = n;
- }
- else if (region->allocated < n) {
- region->beg = (int* )xrealloc(region->beg, n * sizeof(int));
- region->end = (int* )xrealloc(region->end, n * sizeof(int));
-
- if (region->beg == 0 || region->end == 0)
- return ONIGERR_MEMORY;
-
- region->allocated = n;
- }
-
- return 0;
-}
-
-extern int
-onig_region_resize_clear(OnigRegion* region, int n)
-{
- int r;
-
- r = onig_region_resize(region, n);
- if (r != 0) return r;
- onig_region_clear(region);
- return 0;
-}
-
-extern int
-onig_region_set(OnigRegion* region, int at, int beg, int end)
-{
- if (at < 0) return ONIGERR_INVALID_ARGUMENT;
-
- if (at >= region->allocated) {
- int r = onig_region_resize(region, at + 1);
- if (r < 0) return r;
- }
-
- region->beg[at] = beg;
- region->end[at] = end;
- return 0;
-}
-
-extern void
-onig_region_init(OnigRegion* region)
-{
- region->num_regs = 0;
- region->allocated = 0;
- region->beg = (int* )0;
- region->end = (int* )0;
- region->history_root = (OnigCaptureTreeNode* )0;
-}
-
-extern OnigRegion*
-onig_region_new(void)
-{
- OnigRegion* r;
-
- r = (OnigRegion* )xmalloc(sizeof(OnigRegion));
- onig_region_init(r);
- return r;
-}
-
-extern void
-onig_region_free(OnigRegion* r, int free_self)
-{
- if (r) {
- if (r->allocated > 0) {
- if (r->beg) xfree(r->beg);
- if (r->end) xfree(r->end);
- r->allocated = 0;
- }
-#ifdef USE_CAPTURE_HISTORY
- history_root_free(r);
-#endif
- if (free_self) xfree(r);
- }
-}
-
-extern void
-onig_region_copy(OnigRegion* to, OnigRegion* from)
-{
-#define RREGC_SIZE (sizeof(int) * from->num_regs)
- int i;
-
- if (to == from) return;
-
- if (to->allocated == 0) {
- if (from->num_regs > 0) {
- to->beg = (int* )xmalloc(RREGC_SIZE);
- to->end = (int* )xmalloc(RREGC_SIZE);
- to->allocated = from->num_regs;
- }
- }
- else if (to->allocated < from->num_regs) {
- to->beg = (int* )xrealloc(to->beg, RREGC_SIZE);
- to->end = (int* )xrealloc(to->end, RREGC_SIZE);
- to->allocated = from->num_regs;
- }
-
- for (i = 0; i < from->num_regs; i++) {
- to->beg[i] = from->beg[i];
- to->end[i] = from->end[i];
- }
- to->num_regs = from->num_regs;
-
-#ifdef USE_CAPTURE_HISTORY
- history_root_free(to);
-
- if (IS_NOT_NULL(from->history_root)) {
- to->history_root = history_tree_clone(from->history_root);
- }
-#endif
-}
-
-
-/** stack **/
-#define INVALID_STACK_INDEX -1
-
-/* stack type */
-/* used by normal-POP */
-#define STK_ALT 0x0001
-#define STK_LOOK_BEHIND_NOT 0x0002
-#define STK_POS_NOT 0x0003
-/* handled by normal-POP */
-#define STK_MEM_START 0x0100
-#define STK_MEM_END 0x8200
-#define STK_REPEAT_INC 0x0300
-#define STK_STATE_CHECK_MARK 0x1000
-/* avoided by normal-POP */
-#define STK_NULL_CHECK_START 0x3000
-#define STK_NULL_CHECK_END 0x5000 /* for recursive call */
-#define STK_MEM_END_MARK 0x8400
-#define STK_POS 0x0500 /* used when POP-POS */
-#define STK_STOP_BT 0x0600 /* mark for "(?>...)" */
-#define STK_REPEAT 0x0700
-#define STK_CALL_FRAME 0x0800
-#define STK_RETURN 0x0900
-#define STK_VOID 0x0a00 /* for fill a blank */
-
-/* stack type check mask */
-#define STK_MASK_POP_USED 0x00ff
-#define STK_MASK_TO_VOID_TARGET 0x10ff
-#define STK_MASK_MEM_END_OR_MARK 0x8000 /* MEM_END or MEM_END_MARK */
-
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
-#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start) do {\
- (msa).stack_p = (void* )0;\
- (msa).options = (arg_option);\
- (msa).region = (arg_region);\
- (msa).start = (arg_start);\
- (msa).best_len = ONIG_MISMATCH;\
-} while(0)
-#else
-#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start) do {\
- (msa).stack_p = (void* )0;\
- (msa).options = (arg_option);\
- (msa).region = (arg_region);\
- (msa).start = (arg_start);\
-} while(0)
-#endif
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
-
-#define STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE 16
-
-#define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num) do { \
- if ((state_num) > 0 && str_len >= STATE_CHECK_STRING_THRESHOLD_LEN) {\
- unsigned int size = (unsigned int )(((str_len) + 1) * (state_num) + 7) >> 3;\
- offset = ((offset) * (state_num)) >> 3;\
- if (size > 0 && offset < size && size < STATE_CHECK_BUFF_MAX_SIZE) {\
- if (size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) \
- (msa).state_check_buff = (void* )xmalloc(size);\
- else \
- (msa).state_check_buff = (void* )xalloca(size);\
- xmemset(((char* )((msa).state_check_buff)+(offset)), 0, \
- (size_t )(size - (offset))); \
- (msa).state_check_buff_size = size;\
- }\
- else {\
- (msa).state_check_buff = (void* )0;\
- (msa).state_check_buff_size = 0;\
- }\
- }\
- else {\
- (msa).state_check_buff = (void* )0;\
- (msa).state_check_buff_size = 0;\
- }\
- } while(0)
-
-#define MATCH_ARG_FREE(msa) do {\
- if ((msa).stack_p) xfree((msa).stack_p);\
- if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \
- if ((msa).state_check_buff) xfree((msa).state_check_buff);\
- }\
-} while(0)
-#else
-#define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num)
-#define MATCH_ARG_FREE(msa) if ((msa).stack_p) xfree((msa).stack_p)
-#endif
-
-
-
-#define STACK_INIT(alloc_addr, ptr_num, stack_num) do {\
- if (msa->stack_p) {\
- alloc_addr = (char* )xalloca(sizeof(char*) * (ptr_num));\
- stk_alloc = (OnigStackType* )(msa->stack_p);\
- stk_base = stk_alloc;\
- stk = stk_base;\
- stk_end = stk_base + msa->stack_n;\
- }\
- else {\
- alloc_addr = (char* )xalloca(sizeof(char*) * (ptr_num)\
- + sizeof(OnigStackType) * (stack_num));\
- stk_alloc = (OnigStackType* )(alloc_addr + sizeof(char*) * (ptr_num));\
- stk_base = stk_alloc;\
- stk = stk_base;\
- stk_end = stk_base + (stack_num);\
- }\
-} while(0)
-
-#define STACK_SAVE do{\
- if (stk_base != stk_alloc) {\
- msa->stack_p = stk_base;\
- msa->stack_n = stk_end - stk_base;\
- };\
-} while(0)
-
-static unsigned int MatchStackLimitSize = DEFAULT_MATCH_STACK_LIMIT_SIZE;
-
-extern unsigned int
-onig_get_match_stack_limit_size(void)
-{
- return MatchStackLimitSize;
-}
-
-extern int
-onig_set_match_stack_limit_size(unsigned int size)
-{
- MatchStackLimitSize = size;
- return 0;
-}
-
-static int
-stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end,
- OnigStackType** arg_stk, OnigStackType* stk_alloc, OnigMatchArg* msa)
-{
- unsigned int n;
- OnigStackType *x, *stk_base, *stk_end, *stk;
-
- stk_base = *arg_stk_base;
- stk_end = *arg_stk_end;
- stk = *arg_stk;
-
- n = stk_end - stk_base;
- if (stk_base == stk_alloc && IS_NULL(msa->stack_p)) {
- x = (OnigStackType* )xmalloc(sizeof(OnigStackType) * n * 2);
- if (IS_NULL(x)) {
- STACK_SAVE;
- return ONIGERR_MEMORY;
- }
- xmemcpy(x, stk_base, n * sizeof(OnigStackType));
- n *= 2;
- }
- else {
- n *= 2;
- if (MatchStackLimitSize != 0 && n > MatchStackLimitSize) {
- if ((unsigned int )(stk_end - stk_base) == MatchStackLimitSize)
- return ONIGERR_MATCH_STACK_LIMIT_OVER;
- else
- n = MatchStackLimitSize;
- }
- x = (OnigStackType* )xrealloc(stk_base, sizeof(OnigStackType) * n);
- if (IS_NULL(x)) {
- STACK_SAVE;
- return ONIGERR_MEMORY;
- }
- }
- *arg_stk = x + (stk - stk_base);
- *arg_stk_base = x;
- *arg_stk_end = x + n;
- return 0;
-}
-
-#define STACK_ENSURE(n) do {\
- if (stk_end - stk < (n)) {\
- int r = stack_double(&stk_base, &stk_end, &stk, stk_alloc, msa);\
- if (r != 0) { STACK_SAVE; return r; } \
- }\
-} while(0)
-
-#define STACK_AT(index) (stk_base + (index))
-#define GET_STACK_INDEX(stk) ((stk) - stk_base)
-
-#define STACK_PUSH_TYPE(stack_type) do {\
- STACK_ENSURE(1);\
- stk->type = (stack_type);\
- STACK_INC;\
-} while(0)
-
-#define IS_TO_VOID_TARGET(stk) (((stk)->type & STK_MASK_TO_VOID_TARGET) != 0)
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
-#define STATE_CHECK_POS(s,snum) \
- (((s) - str) * num_comb_exp_check + ((snum) - 1))
-#define STATE_CHECK_VAL(v,snum) do {\
- if (state_check_buff != NULL) {\
- int x = STATE_CHECK_POS(s,snum);\
- (v) = state_check_buff[x/8] & (1<<(x%8));\
- }\
- else (v) = 0;\
-} while(0)
-
-
-#define ELSE_IF_STATE_CHECK_MARK(stk) \
- else if ((stk)->type == STK_STATE_CHECK_MARK) { \
- int x = STATE_CHECK_POS(stk->u.state.pstr, stk->u.state.state_check);\
- state_check_buff[x/8] |= (1<<(x%8)); \
- }
-
-#define STACK_PUSH(stack_type,pat,s,sprev) do {\
- STACK_ENSURE(1);\
- stk->type = (stack_type);\
- stk->u.state.pcode = (pat);\
- stk->u.state.pstr = (s);\
- stk->u.state.pstr_prev = (sprev);\
- stk->u.state.state_check = 0;\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_ENSURED(stack_type,pat) do {\
- stk->type = (stack_type);\
- stk->u.state.pcode = (pat);\
- stk->u.state.state_check = 0;\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_ALT_WITH_STATE_CHECK(pat,s,sprev,snum) do {\
- STACK_ENSURE(1);\
- stk->type = STK_ALT;\
- stk->u.state.pcode = (pat);\
- stk->u.state.pstr = (s);\
- stk->u.state.pstr_prev = (sprev);\
- stk->u.state.state_check = ((state_check_buff != NULL) ? (snum) : 0);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_STATE_CHECK(s,snum) do {\
- if (state_check_buff != NULL) {\
- STACK_ENSURE(1);\
- stk->type = STK_STATE_CHECK_MARK;\
- stk->u.state.pstr = (s);\
- stk->u.state.state_check = (snum);\
- STACK_INC;\
- }\
-} while(0)
-
-#else /* USE_COMBINATION_EXPLOSION_CHECK */
-
-#define ELSE_IF_STATE_CHECK_MARK(stk)
-
-#define STACK_PUSH(stack_type,pat,s,sprev) do {\
- STACK_ENSURE(1);\
- stk->type = (stack_type);\
- stk->u.state.pcode = (pat);\
- stk->u.state.pstr = (s);\
- stk->u.state.pstr_prev = (sprev);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_ENSURED(stack_type,pat) do {\
- stk->type = (stack_type);\
- stk->u.state.pcode = (pat);\
- STACK_INC;\
-} while(0)
-#endif /* USE_COMBINATION_EXPLOSION_CHECK */
-
-#define STACK_PUSH_ALT(pat,s,sprev) STACK_PUSH(STK_ALT,pat,s,sprev)
-#define STACK_PUSH_POS(s,sprev) STACK_PUSH(STK_POS,NULL_UCHARP,s,sprev)
-#define STACK_PUSH_POS_NOT(pat,s,sprev) STACK_PUSH(STK_POS_NOT,pat,s,sprev)
-#define STACK_PUSH_STOP_BT STACK_PUSH_TYPE(STK_STOP_BT)
-#define STACK_PUSH_LOOK_BEHIND_NOT(pat,s,sprev) \
- STACK_PUSH(STK_LOOK_BEHIND_NOT,pat,s,sprev)
-
-#define STACK_PUSH_REPEAT(id, pat) do {\
- STACK_ENSURE(1);\
- stk->type = STK_REPEAT;\
- stk->u.repeat.num = (id);\
- stk->u.repeat.pcode = (pat);\
- stk->u.repeat.count = 0;\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_REPEAT_INC(sindex) do {\
- STACK_ENSURE(1);\
- stk->type = STK_REPEAT_INC;\
- stk->u.repeat_inc.si = (sindex);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_MEM_START(mnum, s) do {\
- STACK_ENSURE(1);\
- stk->type = STK_MEM_START;\
- stk->u.mem.num = (mnum);\
- stk->u.mem.pstr = (s);\
- stk->u.mem.start = mem_start_stk[mnum];\
- stk->u.mem.end = mem_end_stk[mnum];\
- mem_start_stk[mnum] = GET_STACK_INDEX(stk);\
- mem_end_stk[mnum] = INVALID_STACK_INDEX;\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_MEM_END(mnum, s) do {\
- STACK_ENSURE(1);\
- stk->type = STK_MEM_END;\
- stk->u.mem.num = (mnum);\
- stk->u.mem.pstr = (s);\
- stk->u.mem.start = mem_start_stk[mnum];\
- stk->u.mem.end = mem_end_stk[mnum];\
- mem_end_stk[mnum] = GET_STACK_INDEX(stk);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_MEM_END_MARK(mnum) do {\
- STACK_ENSURE(1);\
- stk->type = STK_MEM_END_MARK;\
- stk->u.mem.num = (mnum);\
- STACK_INC;\
-} while(0)
-
-#define STACK_GET_MEM_START(mnum, k) do {\
- int level = 0;\
- k = stk;\
- while (k > stk_base) {\
- k--;\
- if ((k->type & STK_MASK_MEM_END_OR_MARK) != 0 \
- && k->u.mem.num == (mnum)) {\
- level++;\
- }\
- else if (k->type == STK_MEM_START && k->u.mem.num == (mnum)) {\
- if (level == 0) break;\
- level--;\
- }\
- }\
-} while(0)
-
-#define STACK_GET_MEM_RANGE(k, mnum, start, end) do {\
- int level = 0;\
- while (k < stk) {\
- if (k->type == STK_MEM_START && k->u.mem.num == (mnum)) {\
- if (level == 0) (start) = k->u.mem.pstr;\
- level++;\
- }\
- else if (k->type == STK_MEM_END && k->u.mem.num == (mnum)) {\
- level--;\
- if (level == 0) {\
- (end) = k->u.mem.pstr;\
- break;\
- }\
- }\
- k++;\
- }\
-} while(0)
-
-#define STACK_PUSH_NULL_CHECK_START(cnum, s) do {\
- STACK_ENSURE(1);\
- stk->type = STK_NULL_CHECK_START;\
- stk->u.null_check.num = (cnum);\
- stk->u.null_check.pstr = (s);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_NULL_CHECK_END(cnum) do {\
- STACK_ENSURE(1);\
- stk->type = STK_NULL_CHECK_END;\
- stk->u.null_check.num = (cnum);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_CALL_FRAME(pat) do {\
- STACK_ENSURE(1);\
- stk->type = STK_CALL_FRAME;\
- stk->u.call_frame.ret_addr = (pat);\
- STACK_INC;\
-} while(0)
-
-#define STACK_PUSH_RETURN do {\
- STACK_ENSURE(1);\
- stk->type = STK_RETURN;\
- STACK_INC;\
-} while(0)
-
-
-#ifdef ONIG_DEBUG
-#define STACK_BASE_CHECK(p, at) \
- if ((p) < stk_base) {\
- fprintf(stderr, "at %s\n", at);\
- goto stack_error;\
- }
-#else
-#define STACK_BASE_CHECK(p, at)
-#endif
-
-#define STACK_POP_ONE do {\
- stk--;\
- STACK_BASE_CHECK(stk, "STACK_POP_ONE"); \
-} while(0)
-
-#define STACK_POP do {\
- switch (pop_level) {\
- case STACK_POP_LEVEL_FREE:\
- while (1) {\
- stk--;\
- STACK_BASE_CHECK(stk, "STACK_POP"); \
- if ((stk->type & STK_MASK_POP_USED) != 0) break;\
- ELSE_IF_STATE_CHECK_MARK(stk);\
- }\
- break;\
- case STACK_POP_LEVEL_MEM_START:\
- while (1) {\
- stk--;\
- STACK_BASE_CHECK(stk, "STACK_POP 2"); \
- if ((stk->type & STK_MASK_POP_USED) != 0) break;\
- else if (stk->type == STK_MEM_START) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- ELSE_IF_STATE_CHECK_MARK(stk);\
- }\
- break;\
- default:\
- while (1) {\
- stk--;\
- STACK_BASE_CHECK(stk, "STACK_POP 3"); \
- if ((stk->type & STK_MASK_POP_USED) != 0) break;\
- else if (stk->type == STK_MEM_START) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- else if (stk->type == STK_REPEAT_INC) {\
- STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\
- }\
- else if (stk->type == STK_MEM_END) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- ELSE_IF_STATE_CHECK_MARK(stk);\
- }\
- break;\
- }\
-} while(0)
-
-#define STACK_POP_TIL_POS_NOT do {\
- while (1) {\
- stk--;\
- STACK_BASE_CHECK(stk, "STACK_POP_TIL_POS_NOT"); \
- if (stk->type == STK_POS_NOT) break;\
- else if (stk->type == STK_MEM_START) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- else if (stk->type == STK_REPEAT_INC) {\
- STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\
- }\
- else if (stk->type == STK_MEM_END) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- ELSE_IF_STATE_CHECK_MARK(stk);\
- }\
-} while(0)
-
-#define STACK_POP_TIL_LOOK_BEHIND_NOT do {\
- while (1) {\
- stk--;\
- STACK_BASE_CHECK(stk, "STACK_POP_TIL_LOOK_BEHIND_NOT"); \
- if (stk->type == STK_LOOK_BEHIND_NOT) break;\
- else if (stk->type == STK_MEM_START) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- else if (stk->type == STK_REPEAT_INC) {\
- STACK_AT(stk->u.repeat_inc.si)->u.repeat.count--;\
- }\
- else if (stk->type == STK_MEM_END) {\
- mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\
- mem_end_stk[stk->u.mem.num] = stk->u.mem.end;\
- }\
- ELSE_IF_STATE_CHECK_MARK(stk);\
- }\
-} while(0)
-
-#define STACK_POS_END(k) do {\
- k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_POS_END"); \
- if (IS_TO_VOID_TARGET(k)) {\
- k->type = STK_VOID;\
- }\
- else if (k->type == STK_POS) {\
- k->type = STK_VOID;\
- break;\
- }\
- }\
-} while(0)
-
-#define STACK_STOP_BT_END do {\
- OnigStackType *k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_STOP_BT_END"); \
- if (IS_TO_VOID_TARGET(k)) {\
- k->type = STK_VOID;\
- }\
- else if (k->type == STK_STOP_BT) {\
- k->type = STK_VOID;\
- break;\
- }\
- }\
-} while(0)
-
-#define STACK_NULL_CHECK(isnull,id,s) do {\
- OnigStackType* k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_NULL_CHECK"); \
- if (k->type == STK_NULL_CHECK_START) {\
- if (k->u.null_check.num == (id)) {\
- (isnull) = (k->u.null_check.pstr == (s));\
- break;\
- }\
- }\
- }\
-} while(0)
-
-#define STACK_NULL_CHECK_REC(isnull,id,s) do {\
- int level = 0;\
- OnigStackType* k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_NULL_CHECK_REC"); \
- if (k->type == STK_NULL_CHECK_START) {\
- if (k->u.null_check.num == (id)) {\
- if (level == 0) {\
- (isnull) = (k->u.null_check.pstr == (s));\
- break;\
- }\
- else level--;\
- }\
- }\
- else if (k->type == STK_NULL_CHECK_END) {\
- level++;\
- }\
- }\
-} while(0)
-
-#define STACK_NULL_CHECK_MEMST(isnull,id,s,reg) do {\
- OnigStackType* k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST"); \
- if (k->type == STK_NULL_CHECK_START) {\
- if (k->u.null_check.num == (id)) {\
- if (k->u.null_check.pstr != (s)) {\
- (isnull) = 0;\
- break;\
- }\
- else {\
- UChar* endp;\
- (isnull) = 1;\
- while (k < stk) {\
- if (k->type == STK_MEM_START) {\
- if (k->u.mem.end == INVALID_STACK_INDEX) {\
- (isnull) = 0; break;\
- }\
- if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\
- endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\
- else\
- endp = (UChar* )k->u.mem.end;\
- if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\
- (isnull) = 0; break;\
- }\
- else if (endp != s) {\
- (isnull) = -1; /* empty, but position changed */ \
- }\
- }\
- k++;\
- }\
- break;\
- }\
- }\
- }\
- }\
-} while(0)
-
-#define STACK_NULL_CHECK_MEMST_REC(isnull,id,s,reg) do {\
- int level = 0;\
- OnigStackType* k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_NULL_CHECK_MEMST_REC"); \
- if (k->type == STK_NULL_CHECK_START) {\
- if (k->u.null_check.num == (id)) {\
- if (level == 0) {\
- if (k->u.null_check.pstr != (s)) {\
- (isnull) = 0;\
- break;\
- }\
- else {\
- UChar* endp;\
- (isnull) = 1;\
- while (k < stk) {\
- if (k->type == STK_MEM_START) {\
- if (k->u.mem.end == INVALID_STACK_INDEX) {\
- (isnull) = 0; break;\
- }\
- if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\
- endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\
- else\
- endp = (UChar* )k->u.mem.end;\
- if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\
- (isnull) = 0; break;\
- }\
- else if (endp != s) {\
- (isnull) = -1; /* empty, but position changed */ \
- }\
- }\
- k++;\
- }\
- break;\
- }\
- }\
- else {\
- level--;\
- }\
- }\
- }\
- else if (k->type == STK_NULL_CHECK_END) {\
- if (k->u.null_check.num == (id)) level++;\
- }\
- }\
-} while(0)
-
-#define STACK_GET_REPEAT(id, k) do {\
- int level = 0;\
- k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_GET_REPEAT"); \
- if (k->type == STK_REPEAT) {\
- if (level == 0) {\
- if (k->u.repeat.num == (id)) {\
- break;\
- }\
- }\
- }\
- else if (k->type == STK_CALL_FRAME) level--;\
- else if (k->type == STK_RETURN) level++;\
- }\
-} while(0)
-
-#define STACK_RETURN(addr) do {\
- int level = 0;\
- OnigStackType* k = stk;\
- while (1) {\
- k--;\
- STACK_BASE_CHECK(k, "STACK_RETURN"); \
- if (k->type == STK_CALL_FRAME) {\
- if (level == 0) {\
- (addr) = k->u.call_frame.ret_addr;\
- break;\
- }\
- else level--;\
- }\
- else if (k->type == STK_RETURN)\
- level++;\
- }\
-} while(0)
-
-
-#define STRING_CMP(s1,s2,len) do {\
- while (len-- > 0) {\
- if (*s1++ != *s2++) goto fail;\
- }\
-} while(0)
-
-#define STRING_CMP_IC(case_fold_flag,s1,ps2,len) do {\
- if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len) == 0) \
- goto fail; \
-} while(0)
-
-static int string_cmp_ic(OnigEncoding enc, int case_fold_flag,
- UChar* s1, UChar** ps2, int mblen)
-{
- UChar buf1[ONIGENC_MBC_CASE_FOLD_MAXLEN];
- UChar buf2[ONIGENC_MBC_CASE_FOLD_MAXLEN];
- UChar *p1, *p2, *end1, *s2, *end2;
- int len1, len2;
-
- s2 = *ps2;
- end1 = s1 + mblen;
- end2 = s2 + mblen;
- while (s1 < end1) {
- len1 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s1, end1, buf1);
- len2 = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &s2, end2, buf2);
- if (len1 != len2) return 0;
- p1 = buf1;
- p2 = buf2;
- while (len1-- > 0) {
- if (*p1 != *p2) return 0;
- p1++;
- p2++;
- }
- }
-
- *ps2 = s2;
- return 1;
-}
-
-#define STRING_CMP_VALUE(s1,s2,len,is_fail) do {\
- is_fail = 0;\
- while (len-- > 0) {\
- if (*s1++ != *s2++) {\
- is_fail = 1; break;\
- }\
- }\
-} while(0)
-
-#define STRING_CMP_VALUE_IC(case_fold_flag,s1,ps2,len,is_fail) do {\
- if (string_cmp_ic(encode, case_fold_flag, s1, ps2, len) == 0) \
- is_fail = 1; \
- else \
- is_fail = 0; \
-} while(0)
-
-
-#define IS_EMPTY_STR (str == end)
-#define ON_STR_BEGIN(s) ((s) == str)
-#define ON_STR_END(s) ((s) == end)
-#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
-#define DATA_ENSURE_CHECK1 (s < right_range)
-#define DATA_ENSURE_CHECK(n) (s + (n) <= right_range)
-#define DATA_ENSURE(n) if (s + (n) > right_range) goto fail
-#else
-#define DATA_ENSURE_CHECK1 (s < end)
-#define DATA_ENSURE_CHECK(n) (s + (n) <= end)
-#define DATA_ENSURE(n) if (s + (n) > end) goto fail
-#endif /* USE_MATCH_RANGE_IS_COMPLETE_RANGE */
-
-
-#ifdef USE_CAPTURE_HISTORY
-static int
-make_capture_history_tree(OnigCaptureTreeNode* node, OnigStackType** kp,
- OnigStackType* stk_top, UChar* str, regex_t* reg)
-{
- int n, r;
- OnigCaptureTreeNode* child;
- OnigStackType* k = *kp;
-
- while (k < stk_top) {
- if (k->type == STK_MEM_START) {
- n = k->u.mem.num;
- if (n <= ONIG_MAX_CAPTURE_HISTORY_GROUP &&
- BIT_STATUS_AT(reg->capture_history, n) != 0) {
- child = history_node_new();
- CHECK_NULL_RETURN_MEMERR(child);
- child->group = n;
- child->beg = (int )(k->u.mem.pstr - str);
- r = history_tree_add_child(node, child);
- if (r != 0) return r;
- *kp = (k + 1);
- r = make_capture_history_tree(child, kp, stk_top, str, reg);
- if (r != 0) return r;
-
- k = *kp;
- child->end = (int )(k->u.mem.pstr - str);
- }
- }
- else if (k->type == STK_MEM_END) {
- if (k->u.mem.num == node->group) {
- node->end = (int )(k->u.mem.pstr - str);
- *kp = k;
- return 0;
- }
- }
- k++;
- }
-
- return 1; /* 1: root node ending. */
-}
-#endif
-
-#ifdef USE_BACKREF_AT_LEVEL
-static int mem_is_in_memp(int mem, int num, UChar* memp)
-{
- int i;
- MemNumType m;
-
- for (i = 0; i < num; i++) {
- GET_MEMNUM_INC(m, memp);
- if (mem == (int )m) return 1;
- }
- return 0;
-}
-
-static int backref_match_at_nested_level(regex_t* reg
- , OnigStackType* top, OnigStackType* stk_base
- , int ignore_case, int case_fold_flag
- , int nest, int mem_num, UChar* memp, UChar** s, const UChar* send)
-{
- UChar *ss, *p, *pstart, *pend = NULL_UCHARP;
- int level;
- OnigStackType* k;
-
- level = 0;
- k = top;
- k--;
- while (k >= stk_base) {
- if (k->type == STK_CALL_FRAME) {
- level--;
- }
- else if (k->type == STK_RETURN) {
- level++;
- }
- else if (level == nest) {
- if (k->type == STK_MEM_START) {
- if (mem_is_in_memp(k->u.mem.num, mem_num, memp)) {
- pstart = k->u.mem.pstr;
- if (pend != NULL_UCHARP) {
- if (pend - pstart > send - *s) return 0; /* or goto next_mem; */
- p = pstart;
- ss = *s;
-
- if (ignore_case != 0) {
- if (string_cmp_ic(reg->enc, case_fold_flag,
- pstart, &ss, (int )(pend - pstart)) == 0)
- return 0; /* or goto next_mem; */
- }
- else {
- while (p < pend) {
- if (*p++ != *ss++) return 0; /* or goto next_mem; */
- }
- }
-
- *s = ss;
- return 1;
- }
- }
- }
- else if (k->type == STK_MEM_END) {
- if (mem_is_in_memp(k->u.mem.num, mem_num, memp)) {
- pend = k->u.mem.pstr;
- }
- }
- }
- k--;
- }
-
- return 0;
-}
-#endif /* USE_BACKREF_AT_LEVEL */
-
-
-#ifdef ONIG_DEBUG_STATISTICS
-
-#define USE_TIMEOFDAY
-
-#ifdef USE_TIMEOFDAY
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-static struct timeval ts, te;
-#define GETTIME(t) gettimeofday(&(t), (struct timezone* )0)
-#define TIMEDIFF(te,ts) (((te).tv_usec - (ts).tv_usec) + \
- (((te).tv_sec - (ts).tv_sec)*1000000))
-#else
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
-static struct tms ts, te;
-#define GETTIME(t) times(&(t))
-#define TIMEDIFF(te,ts) ((te).tms_utime - (ts).tms_utime)
-#endif
-
-static int OpCounter[256];
-static int OpPrevCounter[256];
-static unsigned long OpTime[256];
-static int OpCurr = OP_FINISH;
-static int OpPrevTarget = OP_FAIL;
-static int MaxStackDepth = 0;
-
-#define MOP_IN(opcode) do {\
- if (opcode == OpPrevTarget) OpPrevCounter[OpCurr]++;\
- OpCurr = opcode;\
- OpCounter[opcode]++;\
- GETTIME(ts);\
-} while(0)
-
-#define MOP_OUT do {\
- GETTIME(te);\
- OpTime[OpCurr] += TIMEDIFF(te, ts);\
-} while(0)
-
-extern void
-onig_statistics_init(void)
-{
- int i;
- for (i = 0; i < 256; i++) {
- OpCounter[i] = OpPrevCounter[i] = 0; OpTime[i] = 0;
- }
- MaxStackDepth = 0;
-}
-
-extern void
-onig_print_statistics(FILE* f)
-{
- int i;
- fprintf(f, " count prev time\n");
- for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
- fprintf(f, "%8d: %8d: %10ld: %s\n",
- OpCounter[i], OpPrevCounter[i], OpTime[i], OnigOpInfo[i].name);
- }
- fprintf(f, "\nmax stack depth: %d\n", MaxStackDepth);
-}
-
-#define STACK_INC do {\
- stk++;\
- if (stk - stk_base > MaxStackDepth) \
- MaxStackDepth = stk - stk_base;\
-} while(0)
-
-#else
-#define STACK_INC stk++
-
-#define MOP_IN(opcode)
-#define MOP_OUT
-#endif
-
-
-/* matching region of POSIX API */
-typedef int regoff_t;
-
-typedef struct {
- regoff_t rm_so;
- regoff_t rm_eo;
-} posix_regmatch_t;
-
-/* match data(str - end) from position (sstart). */
-/* if sstart == str then set sprev to NULL. */
-static int
-match_at(regex_t* reg, const UChar* str, const UChar* end,
-#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
- const UChar* right_range,
-#endif
- const UChar* sstart, UChar* sprev, OnigMatchArg* msa)
-{
- static UChar FinishCode[] = { OP_FINISH };
-
- int i, n, num_mem, best_len, pop_level;
- LengthType tlen, tlen2;
- MemNumType mem;
- RelAddrType addr;
- OnigOptionType option = reg->options;
- OnigEncoding encode = reg->enc;
- OnigCaseFoldType case_fold_flag = reg->case_fold_flag;
- UChar *s, *q, *sbegin;
- UChar *p = reg->p;
- char *alloca_base;
- OnigStackType *stk_alloc, *stk_base, *stk, *stk_end;
- OnigStackType *stkp; /* used as any purpose. */
- OnigStackIndex si;
- OnigStackIndex *repeat_stk;
- OnigStackIndex *mem_start_stk, *mem_end_stk;
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- int scv;
- unsigned char* state_check_buff = msa->state_check_buff;
- int num_comb_exp_check = reg->num_comb_exp_check;
-#endif
- n = reg->num_repeat + reg->num_mem * 2;
-
- STACK_INIT(alloca_base, n, INIT_MATCH_STACK_SIZE);
- pop_level = reg->stack_pop_level;
- num_mem = reg->num_mem;
- repeat_stk = (OnigStackIndex* )alloca_base;
-
- mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
- mem_end_stk = mem_start_stk + num_mem;
- mem_start_stk--; /* for index start from 1,
- mem_start_stk[1]..mem_start_stk[num_mem] */
- mem_end_stk--; /* for index start from 1,
- mem_end_stk[1]..mem_end_stk[num_mem] */
- for (i = 1; i <= num_mem; i++) {
- mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
- }
-
-#ifdef ONIG_DEBUG_MATCH
- fprintf(stderr, "match_at: str: %d, end: %d, start: %d, sprev: %d\n",
- (int )str, (int )end, (int )sstart, (int )sprev);
- fprintf(stderr, "size: %d, start offset: %d\n",
- (int )(end - str), (int )(sstart - str));
-#endif
-
- STACK_PUSH_ENSURED(STK_ALT, FinishCode); /* bottom stack */
- best_len = ONIG_MISMATCH;
- s = (UChar* )sstart;
- while (1) {
-#ifdef ONIG_DEBUG_MATCH
- {
- UChar *q, *bp, buf[50];
- int len;
- fprintf(stderr, "%4d> \"", (int )(s - str));
- bp = buf;
- for (i = 0, q = s; i < 7 && q < end; i++) {
- len = enc_len(encode, q);
- while (len-- > 0) *bp++ = *q++;
- }
- if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; }
- else { xmemcpy(bp, "\"", 1); bp += 1; }
- *bp = 0;
- fputs((char* )buf, stderr);
- for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr);
- onig_print_compiled_byte_code(stderr, p, NULL, encode);
- fprintf(stderr, "\n");
- }
-#endif
-
- sbegin = s;
- switch (*p++) {
- case OP_END: MOP_IN(OP_END);
- n = s - sstart;
- if (n > best_len) {
- OnigRegion* region;
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
- if (IS_FIND_LONGEST(option)) {
- if (n > msa->best_len) {
- msa->best_len = n;
- msa->best_s = (UChar* )sstart;
- }
- else
- goto end_best_len;
- }
-#endif
- best_len = n;
- region = msa->region;
- if (region) {
-#ifdef USE_POSIX_REGION_OPTION
- if (IS_POSIX_REGION(msa->options)) {
- posix_regmatch_t* rmt = (posix_regmatch_t* )region;
-
- rmt[0].rm_so = sstart - str;
- rmt[0].rm_eo = s - str;
- for (i = 1; i <= num_mem; i++) {
- if (mem_end_stk[i] != INVALID_STACK_INDEX) {
- if (BIT_STATUS_AT(reg->bt_mem_start, i))
- rmt[i].rm_so = STACK_AT(mem_start_stk[i])->u.mem.pstr - str;
- else
- rmt[i].rm_so = (UChar* )((void* )(mem_start_stk[i])) - str;
-
- rmt[i].rm_eo = (BIT_STATUS_AT(reg->bt_mem_end, i)
- ? STACK_AT(mem_end_stk[i])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[i])) - str;
- }
- else {
- rmt[i].rm_so = rmt[i].rm_eo = ONIG_REGION_NOTPOS;
- }
- }
- }
- else {
-#endif /* USE_POSIX_REGION_OPTION */
- region->beg[0] = sstart - str;
- region->end[0] = s - str;
- for (i = 1; i <= num_mem; i++) {
- if (mem_end_stk[i] != INVALID_STACK_INDEX) {
- if (BIT_STATUS_AT(reg->bt_mem_start, i))
- region->beg[i] = STACK_AT(mem_start_stk[i])->u.mem.pstr - str;
- else
- region->beg[i] = (UChar* )((void* )mem_start_stk[i]) - str;
-
- region->end[i] = (BIT_STATUS_AT(reg->bt_mem_end, i)
- ? STACK_AT(mem_end_stk[i])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[i])) - str;
- }
- else {
- region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS;
- }
- }
-
-#ifdef USE_CAPTURE_HISTORY
- if (reg->capture_history != 0) {
- int r;
- OnigCaptureTreeNode* node;
-
- if (IS_NULL(region->history_root)) {
- region->history_root = node = history_node_new();
- CHECK_NULL_RETURN_MEMERR(node);
- }
- else {
- node = region->history_root;
- history_tree_clear(node);
- }
-
- node->group = 0;
- node->beg = sstart - str;
- node->end = s - str;
-
- stkp = stk_base;
- r = make_capture_history_tree(region->history_root, &stkp,
- stk, (UChar* )str, reg);
- if (r < 0) {
- best_len = r; /* error code */
- goto finish;
- }
- }
-#endif /* USE_CAPTURE_HISTORY */
-#ifdef USE_POSIX_REGION_OPTION
- } /* else IS_POSIX_REGION() */
-#endif
- } /* if (region) */
- } /* n > best_len */
-
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
- end_best_len:
-#endif
- MOP_OUT;
-
- if (IS_FIND_CONDITION(option)) {
- if (IS_FIND_NOT_EMPTY(option) && s == sstart) {
- best_len = ONIG_MISMATCH;
- goto fail; /* for retry */
- }
- if (IS_FIND_LONGEST(option) && DATA_ENSURE_CHECK1) {
- goto fail; /* for retry */
- }
- }
-
- /* default behavior: return first-matching result. */
- goto finish;
- break;
-
- case OP_EXACT1: MOP_IN(OP_EXACT1);
-#if 0
- DATA_ENSURE(1);
- if (*p != *s) goto fail;
- p++; s++;
-#endif
- if (*p != *s++) goto fail;
- DATA_ENSURE(0);
- p++;
- MOP_OUT;
- break;
-
- case OP_EXACT1_IC: MOP_IN(OP_EXACT1_IC);
- {
- int len;
- UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
-
- DATA_ENSURE(1);
- len = ONIGENC_MBC_CASE_FOLD(encode,
- /* DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag), */
- case_fold_flag,
- &s, end, lowbuf);
- DATA_ENSURE(0);
- q = lowbuf;
- while (len-- > 0) {
- if (*p != *q) {
- goto fail;
- }
- p++; q++;
- }
- }
- MOP_OUT;
- break;
-
- case OP_EXACT2: MOP_IN(OP_EXACT2);
- DATA_ENSURE(2);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- sprev = s;
- p++; s++;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACT3: MOP_IN(OP_EXACT3);
- DATA_ENSURE(3);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- sprev = s;
- p++; s++;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACT4: MOP_IN(OP_EXACT4);
- DATA_ENSURE(4);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- sprev = s;
- p++; s++;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACT5: MOP_IN(OP_EXACT5);
- DATA_ENSURE(5);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- sprev = s;
- p++; s++;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTN: MOP_IN(OP_EXACTN);
- GET_LENGTH_INC(tlen, p);
- DATA_ENSURE(tlen);
- while (tlen-- > 0) {
- if (*p++ != *s++) goto fail;
- }
- sprev = s - 1;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTN_IC: MOP_IN(OP_EXACTN_IC);
- {
- int len;
- UChar *q, *endp, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
-
- GET_LENGTH_INC(tlen, p);
- endp = p + tlen;
-
- while (p < endp) {
- sprev = s;
- DATA_ENSURE(1);
- len = ONIGENC_MBC_CASE_FOLD(encode,
- /* DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag), */
- case_fold_flag,
- &s, end, lowbuf);
- DATA_ENSURE(0);
- q = lowbuf;
- while (len-- > 0) {
- if (*p != *q) goto fail;
- p++; q++;
- }
- }
- }
-
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTMB2N1: MOP_IN(OP_EXACTMB2N1);
- DATA_ENSURE(2);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- MOP_OUT;
- break;
-
- case OP_EXACTMB2N2: MOP_IN(OP_EXACTMB2N2);
- DATA_ENSURE(4);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- sprev = s;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTMB2N3: MOP_IN(OP_EXACTMB2N3);
- DATA_ENSURE(6);
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- sprev = s;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTMB2N: MOP_IN(OP_EXACTMB2N);
- GET_LENGTH_INC(tlen, p);
- DATA_ENSURE(tlen * 2);
- while (tlen-- > 0) {
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- }
- sprev = s - 2;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTMB3N: MOP_IN(OP_EXACTMB3N);
- GET_LENGTH_INC(tlen, p);
- DATA_ENSURE(tlen * 3);
- while (tlen-- > 0) {
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- if (*p != *s) goto fail;
- p++; s++;
- }
- sprev = s - 3;
- MOP_OUT;
- continue;
- break;
-
- case OP_EXACTMBN: MOP_IN(OP_EXACTMBN);
- GET_LENGTH_INC(tlen, p); /* mb-len */
- GET_LENGTH_INC(tlen2, p); /* string len */
- tlen2 *= tlen;
- DATA_ENSURE(tlen2);
- while (tlen2-- > 0) {
- if (*p != *s) goto fail;
- p++; s++;
- }
- sprev = s - tlen;
- MOP_OUT;
- continue;
- break;
-
- case OP_CCLASS: MOP_IN(OP_CCLASS);
- DATA_ENSURE(1);
- if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail;
- p += SIZE_BITSET;
- s += enc_len(encode, s, end); /* OP_CCLASS can match mb-code. \D, \S */
- MOP_OUT;
- break;
-
- case OP_CCLASS_MB: MOP_IN(OP_CCLASS_MB);
- if (! ONIGENC_IS_MBC_HEAD(encode, s, end)) goto fail;
-
- cclass_mb:
- GET_LENGTH_INC(tlen, p);
- {
- OnigCodePoint code;
- UChar *ss;
- int mb_len;
-
- DATA_ENSURE(1);
- mb_len = enc_len(encode, s, end);
- DATA_ENSURE(mb_len);
- ss = s;
- s += mb_len;
- code = ONIGENC_MBC_TO_CODE(encode, ss, s);
-
-#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
- if (! onig_is_in_code_range(p, code)) goto fail;
-#else
- q = p;
- ALIGNMENT_RIGHT(q);
- if (! onig_is_in_code_range(q, code)) goto fail;
-#endif
- }
- p += tlen;
- MOP_OUT;
- break;
-
- case OP_CCLASS_MIX: MOP_IN(OP_CCLASS_MIX);
- DATA_ENSURE(1);
- if (ONIGENC_IS_MBC_HEAD(encode, s, end)) {
- p += SIZE_BITSET;
- goto cclass_mb;
- }
- else {
- if (BITSET_AT(((BitSetRef )p), *s) == 0)
- goto fail;
-
- p += SIZE_BITSET;
- GET_LENGTH_INC(tlen, p);
- p += tlen;
- s++;
- }
- MOP_OUT;
- break;
-
- case OP_CCLASS_NOT: MOP_IN(OP_CCLASS_NOT);
- DATA_ENSURE(1);
- if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail;
- p += SIZE_BITSET;
- s += enc_len(encode, s, end);
- MOP_OUT;
- break;
-
- case OP_CCLASS_MB_NOT: MOP_IN(OP_CCLASS_MB_NOT);
- DATA_ENSURE(1);
- if (! ONIGENC_IS_MBC_HEAD(encode, s, end)) {
- s++;
- GET_LENGTH_INC(tlen, p);
- p += tlen;
- goto cc_mb_not_success;
- }
-
- cclass_mb_not:
- GET_LENGTH_INC(tlen, p);
- {
- OnigCodePoint code;
- UChar *ss;
- int mb_len = enc_len(encode, s, end);
-
- if (! DATA_ENSURE_CHECK(mb_len)) {
- DATA_ENSURE(1);
- s = (UChar* )end;
- p += tlen;
- goto cc_mb_not_success;
- }
-
- ss = s;
- s += mb_len;
- code = ONIGENC_MBC_TO_CODE(encode, ss, s);
-
-#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
- if (onig_is_in_code_range(p, code)) goto fail;
-#else
- q = p;
- ALIGNMENT_RIGHT(q);
- if (onig_is_in_code_range(q, code)) goto fail;
-#endif
- }
- p += tlen;
-
- cc_mb_not_success:
- MOP_OUT;
- break;
-
- case OP_CCLASS_MIX_NOT: MOP_IN(OP_CCLASS_MIX_NOT);
- DATA_ENSURE(1);
- if (ONIGENC_IS_MBC_HEAD(encode, s, end)) {
- p += SIZE_BITSET;
- goto cclass_mb_not;
- }
- else {
- if (BITSET_AT(((BitSetRef )p), *s) != 0)
- goto fail;
-
- p += SIZE_BITSET;
- GET_LENGTH_INC(tlen, p);
- p += tlen;
- s++;
- }
- MOP_OUT;
- break;
-
- case OP_CCLASS_NODE: MOP_IN(OP_CCLASS_NODE);
- {
- OnigCodePoint code;
- void *node;
- int mb_len;
- UChar *ss;
-
- DATA_ENSURE(1);
- GET_POINTER_INC(node, p);
- mb_len = enc_len(encode, s, end);
- ss = s;
- s += mb_len;
- DATA_ENSURE(0);
- code = ONIGENC_MBC_TO_CODE(encode, ss, s);
- if (onig_is_code_in_cc_len(mb_len, code, node) == 0) goto fail;
- }
- MOP_OUT;
- break;
-
- case OP_ANYCHAR: MOP_IN(OP_ANYCHAR);
- DATA_ENSURE(1);
- n = enc_len(encode, s, end);
- DATA_ENSURE(n);
- if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
- s += n;
- MOP_OUT;
- break;
-
- case OP_ANYCHAR_ML: MOP_IN(OP_ANYCHAR_ML);
- DATA_ENSURE(1);
- n = enc_len(encode, s, end);
- DATA_ENSURE(n);
- s += n;
- MOP_OUT;
- break;
-
- case OP_ANYCHAR_STAR: MOP_IN(OP_ANYCHAR_STAR);
- while (DATA_ENSURE_CHECK1) {
- STACK_PUSH_ALT(p, s, sprev);
- n = enc_len(encode, s, end);
- DATA_ENSURE(n);
- if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
- sprev = s;
- s += n;
- }
- MOP_OUT;
- break;
-
- case OP_ANYCHAR_ML_STAR: MOP_IN(OP_ANYCHAR_ML_STAR);
- while (DATA_ENSURE_CHECK1) {
- STACK_PUSH_ALT(p, s, sprev);
- n = enc_len(encode, s, end);
- if (n > 1) {
- DATA_ENSURE(n);
- sprev = s;
- s += n;
- }
- else {
- sprev = s;
- s++;
- }
- }
- MOP_OUT;
- break;
-
- case OP_ANYCHAR_STAR_PEEK_NEXT: MOP_IN(OP_ANYCHAR_STAR_PEEK_NEXT);
- while (DATA_ENSURE_CHECK1) {
- if (*p == *s) {
- STACK_PUSH_ALT(p + 1, s, sprev);
- }
- n = enc_len(encode, s, end);
- DATA_ENSURE(n);
- if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
- sprev = s;
- s += n;
- }
- p++;
- MOP_OUT;
- break;
-
- case OP_ANYCHAR_ML_STAR_PEEK_NEXT:MOP_IN(OP_ANYCHAR_ML_STAR_PEEK_NEXT);
- while (DATA_ENSURE_CHECK1) {
- if (*p == *s) {
- STACK_PUSH_ALT(p + 1, s, sprev);
- }
- n = enc_len(encode, s, end);
- if (n > 1) {
- DATA_ENSURE(n);
- sprev = s;
- s += n;
- }
- else {
- sprev = s;
- s++;
- }
- }
- p++;
- MOP_OUT;
- break;
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- case OP_STATE_CHECK_ANYCHAR_STAR: MOP_IN(OP_STATE_CHECK_ANYCHAR_STAR);
- GET_STATE_CHECK_NUM_INC(mem, p);
- while (DATA_ENSURE_CHECK1) {
- STATE_CHECK_VAL(scv, mem);
- if (scv) goto fail;
-
- STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
- n = enc_len(encode, s);
- DATA_ENSURE(n);
- if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
- sprev = s;
- s += n;
- }
- MOP_OUT;
- break;
-
- case OP_STATE_CHECK_ANYCHAR_ML_STAR:
- MOP_IN(OP_STATE_CHECK_ANYCHAR_ML_STAR);
-
- GET_STATE_CHECK_NUM_INC(mem, p);
- while (DATA_ENSURE_CHECK1) {
- STATE_CHECK_VAL(scv, mem);
- if (scv) goto fail;
-
- STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
- n = enc_len(encode, s);
- if (n > 1) {
- DATA_ENSURE(n);
- sprev = s;
- s += n;
- }
- else {
- sprev = s;
- s++;
- }
- }
- MOP_OUT;
- break;
-#endif /* USE_COMBINATION_EXPLOSION_CHECK */
-
- case OP_WORD: MOP_IN(OP_WORD);
- DATA_ENSURE(1);
- if (! ONIGENC_IS_MBC_WORD(encode, s, end))
- goto fail;
-
- s += enc_len(encode, s, end);
- MOP_OUT;
- break;
-
- case OP_NOT_WORD: MOP_IN(OP_NOT_WORD);
- DATA_ENSURE(1);
- if (ONIGENC_IS_MBC_WORD(encode, s, end))
- goto fail;
-
- s += enc_len(encode, s, end);
- MOP_OUT;
- break;
-
- case OP_WORD_BOUND: MOP_IN(OP_WORD_BOUND);
- if (ON_STR_BEGIN(s)) {
- DATA_ENSURE(1);
- if (! ONIGENC_IS_MBC_WORD(encode, s, end))
- goto fail;
- }
- else if (ON_STR_END(s)) {
- if (! ONIGENC_IS_MBC_WORD(encode, sprev, end))
- goto fail;
- }
- else {
- if (ONIGENC_IS_MBC_WORD(encode, s, end)
- == ONIGENC_IS_MBC_WORD(encode, sprev, end))
- goto fail;
- }
- MOP_OUT;
- continue;
- break;
-
- case OP_NOT_WORD_BOUND: MOP_IN(OP_NOT_WORD_BOUND);
- if (ON_STR_BEGIN(s)) {
- if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end))
- goto fail;
- }
- else if (ON_STR_END(s)) {
- if (ONIGENC_IS_MBC_WORD(encode, sprev, end))
- goto fail;
- }
- else {
- if (ONIGENC_IS_MBC_WORD(encode, s, end)
- != ONIGENC_IS_MBC_WORD(encode, sprev, end))
- goto fail;
- }
- MOP_OUT;
- continue;
- break;
-
-#ifdef USE_WORD_BEGIN_END
- case OP_WORD_BEGIN: MOP_IN(OP_WORD_BEGIN);
- if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end)) {
- if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
- MOP_OUT;
- continue;
- }
- }
- goto fail;
- break;
-
- case OP_WORD_END: MOP_IN(OP_WORD_END);
- if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
- if (ON_STR_END(s) || !ONIGENC_IS_MBC_WORD(encode, s, end)) {
- MOP_OUT;
- continue;
- }
- }
- goto fail;
- break;
-#endif
-
- case OP_BEGIN_BUF: MOP_IN(OP_BEGIN_BUF);
- if (! ON_STR_BEGIN(s)) goto fail;
-
- MOP_OUT;
- continue;
- break;
-
- case OP_END_BUF: MOP_IN(OP_END_BUF);
- if (! ON_STR_END(s)) goto fail;
-
- MOP_OUT;
- continue;
- break;
-
- case OP_BEGIN_LINE: MOP_IN(OP_BEGIN_LINE);
- if (ON_STR_BEGIN(s)) {
- if (IS_NOTBOL(msa->options)) goto fail;
- MOP_OUT;
- continue;
- }
- else if (ONIGENC_IS_MBC_NEWLINE(encode, sprev, end) && !ON_STR_END(s)) {
- MOP_OUT;
- continue;
- }
- goto fail;
- break;
-
- case OP_END_LINE: MOP_IN(OP_END_LINE);
- if (ON_STR_END(s)) {
-#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
- if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE(encode, sprev, end)) {
-#endif
- if (IS_NOTEOL(msa->options)) goto fail;
- MOP_OUT;
- continue;
-#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
- }
-#endif
- }
- else if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) {
- MOP_OUT;
- continue;
- }
-#ifdef USE_CRNL_AS_LINE_TERMINATOR
- else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) {
- MOP_OUT;
- continue;
- }
-#endif
- goto fail;
- break;
-
- case OP_SEMI_END_BUF: MOP_IN(OP_SEMI_END_BUF);
- if (ON_STR_END(s)) {
-#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
- if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE(encode, sprev, end)) {
-#endif
- if (IS_NOTEOL(msa->options)) goto fail;
- MOP_OUT;
- continue;
-#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
- }
-#endif
- }
- else if (ONIGENC_IS_MBC_NEWLINE(encode, s, end) &&
- ON_STR_END(s + enc_len(encode, s, end))) {
- MOP_OUT;
- continue;
- }
-#ifdef USE_CRNL_AS_LINE_TERMINATOR
- else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) {
- UChar* ss = s + enc_len(encode, s);
- ss += enc_len(encode, ss);
- if (ON_STR_END(ss)) {
- MOP_OUT;
- continue;
- }
- }
-#endif
- goto fail;
- break;
-
- case OP_BEGIN_POSITION: MOP_IN(OP_BEGIN_POSITION);
- if (s != msa->start)
- goto fail;
-
- MOP_OUT;
- continue;
- break;
-
- case OP_MEMORY_START_PUSH: MOP_IN(OP_MEMORY_START_PUSH);
- GET_MEMNUM_INC(mem, p);
- STACK_PUSH_MEM_START(mem, s);
- MOP_OUT;
- continue;
- break;
-
- case OP_MEMORY_START: MOP_IN(OP_MEMORY_START);
- GET_MEMNUM_INC(mem, p);
- mem_start_stk[mem] = (OnigStackIndex )((void* )s);
- MOP_OUT;
- continue;
- break;
-
- case OP_MEMORY_END_PUSH: MOP_IN(OP_MEMORY_END_PUSH);
- GET_MEMNUM_INC(mem, p);
- STACK_PUSH_MEM_END(mem, s);
- MOP_OUT;
- continue;
- break;
-
- case OP_MEMORY_END: MOP_IN(OP_MEMORY_END);
- GET_MEMNUM_INC(mem, p);
- mem_end_stk[mem] = (OnigStackIndex )((void* )s);
- MOP_OUT;
- continue;
- break;
-
-#ifdef USE_SUBEXP_CALL
- case OP_MEMORY_END_PUSH_REC: MOP_IN(OP_MEMORY_END_PUSH_REC);
- GET_MEMNUM_INC(mem, p);
- STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
- STACK_PUSH_MEM_END(mem, s);
- mem_start_stk[mem] = GET_STACK_INDEX(stkp);
- MOP_OUT;
- continue;
- break;
-
- case OP_MEMORY_END_REC: MOP_IN(OP_MEMORY_END_REC);
- GET_MEMNUM_INC(mem, p);
- mem_end_stk[mem] = (OnigStackIndex )((void* )s);
- STACK_GET_MEM_START(mem, stkp);
-
- if (BIT_STATUS_AT(reg->bt_mem_start, mem))
- mem_start_stk[mem] = GET_STACK_INDEX(stkp);
- else
- mem_start_stk[mem] = (OnigStackIndex )((void* )stkp->u.mem.pstr);
-
- STACK_PUSH_MEM_END_MARK(mem);
- MOP_OUT;
- continue;
- break;
-#endif
-
- case OP_BACKREF1: MOP_IN(OP_BACKREF1);
- mem = 1;
- goto backref;
- break;
-
- case OP_BACKREF2: MOP_IN(OP_BACKREF2);
- mem = 2;
- goto backref;
- break;
-
- case OP_BACKREFN: MOP_IN(OP_BACKREFN);
- GET_MEMNUM_INC(mem, p);
- backref:
- {
- int len;
- UChar *pstart, *pend;
-
- /* if you want to remove following line,
- you should check in parse and compile time. */
- if (mem > num_mem) goto fail;
- if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
- if (mem_start_stk[mem] == INVALID_STACK_INDEX) goto fail;
-
- if (BIT_STATUS_AT(reg->bt_mem_start, mem))
- pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
- else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
-
- pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
- ? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
- DATA_ENSURE(n);
- sprev = s;
- STRING_CMP(pstart, s, n);
- while (sprev + (len = enc_len(encode, sprev, end)) < s)
- sprev += len;
-
- MOP_OUT;
- continue;
- }
- break;
-
- case OP_BACKREFN_IC: MOP_IN(OP_BACKREFN_IC);
- GET_MEMNUM_INC(mem, p);
- {
- int len;
- UChar *pstart, *pend;
-
- /* if you want to remove following line,
- you should check in parse and compile time. */
- if (mem > num_mem) goto fail;
- if (mem_end_stk[mem] == INVALID_STACK_INDEX) goto fail;
- if (mem_start_stk[mem] == INVALID_STACK_INDEX) goto fail;
-
- if (BIT_STATUS_AT(reg->bt_mem_start, mem))
- pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
- else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
-
- pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
- ? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
- DATA_ENSURE(n);
- sprev = s;
- STRING_CMP_IC(case_fold_flag, pstart, &s, n);
- while (sprev + (len = enc_len(encode, sprev, end)) < s)
- sprev += len;
-
- MOP_OUT;
- continue;
- }
- break;
-
- case OP_BACKREF_MULTI: MOP_IN(OP_BACKREF_MULTI);
- {
- int len, is_fail;
- UChar *pstart, *pend, *swork;
-
- GET_LENGTH_INC(tlen, p);
- for (i = 0; i < tlen; i++) {
- GET_MEMNUM_INC(mem, p);
-
- if (mem_end_stk[mem] == INVALID_STACK_INDEX) continue;
- if (mem_start_stk[mem] == INVALID_STACK_INDEX) continue;
-
- if (BIT_STATUS_AT(reg->bt_mem_start, mem))
- pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
- else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
-
- pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
- ? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
- DATA_ENSURE(n);
- sprev = s;
- swork = s;
- STRING_CMP_VALUE(pstart, swork, n, is_fail);
- if (is_fail) continue;
- s = swork;
- while (sprev + (len = enc_len(encode, sprev, end)) < s)
- sprev += len;
-
- p += (SIZE_MEMNUM * (tlen - i - 1));
- break; /* success */
- }
- if (i == tlen) goto fail;
- MOP_OUT;
- continue;
- }
- break;
-
- case OP_BACKREF_MULTI_IC: MOP_IN(OP_BACKREF_MULTI_IC);
- {
- int len, is_fail;
- UChar *pstart, *pend, *swork;
-
- GET_LENGTH_INC(tlen, p);
- for (i = 0; i < tlen; i++) {
- GET_MEMNUM_INC(mem, p);
-
- if (mem_end_stk[mem] == INVALID_STACK_INDEX) continue;
- if (mem_start_stk[mem] == INVALID_STACK_INDEX) continue;
-
- if (BIT_STATUS_AT(reg->bt_mem_start, mem))
- pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
- else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
-
- pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
- ? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
- n = pend - pstart;
- DATA_ENSURE(n);
- sprev = s;
- swork = s;
- STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, is_fail);
- if (is_fail) continue;
- s = swork;
- while (sprev + (len = enc_len(encode, sprev, end)) < s)
- sprev += len;
-
- p += (SIZE_MEMNUM * (tlen - i - 1));
- break; /* success */
- }
- if (i == tlen) goto fail;
- MOP_OUT;
- continue;
- }
- break;
-
-#ifdef USE_BACKREF_AT_LEVEL
- case OP_BACKREF_AT_LEVEL:
- {
- int len;
- OnigOptionType ic;
- LengthType level;
-
- GET_OPTION_INC(ic, p);
- GET_LENGTH_INC(level, p);
- GET_LENGTH_INC(tlen, p);
-
- sprev = s;
- if (backref_match_at_nested_level(reg, stk, stk_base, ic
- , case_fold_flag, (int )level, (int )tlen, p, &s, end)) {
- while (sprev + (len = enc_len(encode, sprev, end)) < s)
- sprev += len;
-
- p += (SIZE_MEMNUM * tlen);
- }
- else
- goto fail;
-
- MOP_OUT;
- continue;
- }
-
- break;
-#endif
-
-#if 0 /* no need: IS_DYNAMIC_OPTION() == 0 */
- case OP_SET_OPTION_PUSH: MOP_IN(OP_SET_OPTION_PUSH);
- GET_OPTION_INC(option, p);
- STACK_PUSH_ALT(p, s, sprev);
- p += SIZE_OP_SET_OPTION + SIZE_OP_FAIL;
- MOP_OUT;
- continue;
- break;
-
- case OP_SET_OPTION: MOP_IN(OP_SET_OPTION);
- GET_OPTION_INC(option, p);
- MOP_OUT;
- continue;
- break;
-#endif
-
- case OP_NULL_CHECK_START: MOP_IN(OP_NULL_CHECK_START);
- GET_MEMNUM_INC(mem, p); /* mem: null check id */
- STACK_PUSH_NULL_CHECK_START(mem, s);
- MOP_OUT;
- continue;
- break;
-
- case OP_NULL_CHECK_END: MOP_IN(OP_NULL_CHECK_END);
- {
- int isnull;
-
- GET_MEMNUM_INC(mem, p); /* mem: null check id */
- STACK_NULL_CHECK(isnull, mem, s);
- if (isnull) {
-#ifdef ONIG_DEBUG_MATCH
- fprintf(stderr, "NULL_CHECK_END: skip id:%d, s:%d\n",
- (int )mem, (int )s);
-#endif
- null_check_found:
- /* empty loop founded, skip next instruction */
- switch (*p++) {
- case OP_JUMP:
- case OP_PUSH:
- p += SIZE_RELADDR;
- break;
- case OP_REPEAT_INC:
- case OP_REPEAT_INC_NG:
- case OP_REPEAT_INC_SG:
- case OP_REPEAT_INC_NG_SG:
- p += SIZE_MEMNUM;
- break;
- default:
- goto unexpected_bytecode_error;
- break;
- }
- }
- }
- MOP_OUT;
- continue;
- break;
-
-#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
- case OP_NULL_CHECK_END_MEMST: MOP_IN(OP_NULL_CHECK_END_MEMST);
- {
- int isnull;
-
- GET_MEMNUM_INC(mem, p); /* mem: null check id */
- STACK_NULL_CHECK_MEMST(isnull, mem, s, reg);
- if (isnull) {
-#ifdef ONIG_DEBUG_MATCH
- fprintf(stderr, "NULL_CHECK_END_MEMST: skip id:%d, s:%d\n",
- (int )mem, (int )s);
-#endif
- if (isnull == -1) goto fail;
- goto null_check_found;
- }
- }
- MOP_OUT;
- continue;
- break;
-#endif
-
-#ifdef USE_SUBEXP_CALL
- case OP_NULL_CHECK_END_MEMST_PUSH:
- MOP_IN(OP_NULL_CHECK_END_MEMST_PUSH);
- {
- int isnull;
-
- GET_MEMNUM_INC(mem, p); /* mem: null check id */
-#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
- STACK_NULL_CHECK_MEMST_REC(isnull, mem, s, reg);
-#else
- STACK_NULL_CHECK_REC(isnull, mem, s);
-#endif
- if (isnull) {
-#ifdef ONIG_DEBUG_MATCH
- fprintf(stderr, "NULL_CHECK_END_MEMST_PUSH: skip id:%d, s:%d\n",
- (int )mem, (int )s);
-#endif
- if (isnull == -1) goto fail;
- goto null_check_found;
- }
- else {
- STACK_PUSH_NULL_CHECK_END(mem);
- }
- }
- MOP_OUT;
- continue;
- break;
-#endif
-
- case OP_JUMP: MOP_IN(OP_JUMP);
- GET_RELADDR_INC(addr, p);
- p += addr;
- MOP_OUT;
- CHECK_INTERRUPT_IN_MATCH_AT;
- continue;
- break;
-
- case OP_PUSH: MOP_IN(OP_PUSH);
- GET_RELADDR_INC(addr, p);
- STACK_PUSH_ALT(p + addr, s, sprev);
- MOP_OUT;
- continue;
- break;
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- case OP_STATE_CHECK_PUSH: MOP_IN(OP_STATE_CHECK_PUSH);
- GET_STATE_CHECK_NUM_INC(mem, p);
- STATE_CHECK_VAL(scv, mem);
- if (scv) goto fail;
-
- GET_RELADDR_INC(addr, p);
- STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem);
- MOP_OUT;
- continue;
- break;
-
- case OP_STATE_CHECK_PUSH_OR_JUMP: MOP_IN(OP_STATE_CHECK_PUSH_OR_JUMP);
- GET_STATE_CHECK_NUM_INC(mem, p);
- GET_RELADDR_INC(addr, p);
- STATE_CHECK_VAL(scv, mem);
- if (scv) {
- p += addr;
- }
- else {
- STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem);
- }
- MOP_OUT;
- continue;
- break;
-
- case OP_STATE_CHECK: MOP_IN(OP_STATE_CHECK);
- GET_STATE_CHECK_NUM_INC(mem, p);
- STATE_CHECK_VAL(scv, mem);
- if (scv) goto fail;
-
- STACK_PUSH_STATE_CHECK(s, mem);
- MOP_OUT;
- continue;
- break;
-#endif /* USE_COMBINATION_EXPLOSION_CHECK */
-
- case OP_POP: MOP_IN(OP_POP);
- STACK_POP_ONE;
- MOP_OUT;
- continue;
- break;
-
- case OP_PUSH_OR_JUMP_EXACT1: MOP_IN(OP_PUSH_OR_JUMP_EXACT1);
- GET_RELADDR_INC(addr, p);
- if (*p == *s && DATA_ENSURE_CHECK1) {
- p++;
- STACK_PUSH_ALT(p + addr, s, sprev);
- MOP_OUT;
- continue;
- }
- p += (addr + 1);
- MOP_OUT;
- continue;
- break;
-
- case OP_PUSH_IF_PEEK_NEXT: MOP_IN(OP_PUSH_IF_PEEK_NEXT);
- GET_RELADDR_INC(addr, p);
- if (*p == *s) {
- p++;
- STACK_PUSH_ALT(p + addr, s, sprev);
- MOP_OUT;
- continue;
- }
- p++;
- MOP_OUT;
- continue;
- break;
-
- case OP_REPEAT: MOP_IN(OP_REPEAT);
- {
- GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
- GET_RELADDR_INC(addr, p);
-
- STACK_ENSURE(1);
- repeat_stk[mem] = GET_STACK_INDEX(stk);
- STACK_PUSH_REPEAT(mem, p);
-
- if (reg->repeat_range[mem].lower == 0) {
- STACK_PUSH_ALT(p + addr, s, sprev);
- }
- }
- MOP_OUT;
- continue;
- break;
-
- case OP_REPEAT_NG: MOP_IN(OP_REPEAT_NG);
- {
- GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
- GET_RELADDR_INC(addr, p);
-
- STACK_ENSURE(1);
- repeat_stk[mem] = GET_STACK_INDEX(stk);
- STACK_PUSH_REPEAT(mem, p);
-
- if (reg->repeat_range[mem].lower == 0) {
- STACK_PUSH_ALT(p, s, sprev);
- p += addr;
- }
- }
- MOP_OUT;
- continue;
- break;
-
- case OP_REPEAT_INC: MOP_IN(OP_REPEAT_INC);
- GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
- si = repeat_stk[mem];
- stkp = STACK_AT(si);
-
- repeat_inc:
- stkp->u.repeat.count++;
- if (stkp->u.repeat.count >= reg->repeat_range[mem].upper) {
- /* end of repeat. Nothing to do. */
- }
- else if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) {
- STACK_PUSH_ALT(p, s, sprev);
- p = STACK_AT(si)->u.repeat.pcode; /* Don't use stkp after PUSH. */
- }
- else {
- p = stkp->u.repeat.pcode;
- }
- STACK_PUSH_REPEAT_INC(si);
- MOP_OUT;
- CHECK_INTERRUPT_IN_MATCH_AT;
- continue;
- break;
-
- case OP_REPEAT_INC_SG: MOP_IN(OP_REPEAT_INC_SG);
- GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
- STACK_GET_REPEAT(mem, stkp);
- si = GET_STACK_INDEX(stkp);
- goto repeat_inc;
- break;
-
- case OP_REPEAT_INC_NG: MOP_IN(OP_REPEAT_INC_NG);
- GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
- si = repeat_stk[mem];
- stkp = STACK_AT(si);
-
- repeat_inc_ng:
- stkp->u.repeat.count++;
- if (stkp->u.repeat.count < reg->repeat_range[mem].upper) {
- if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) {
- UChar* pcode = stkp->u.repeat.pcode;
-
- STACK_PUSH_REPEAT_INC(si);
- STACK_PUSH_ALT(pcode, s, sprev);
- }
- else {
- p = stkp->u.repeat.pcode;
- STACK_PUSH_REPEAT_INC(si);
- }
- }
- else if (stkp->u.repeat.count == reg->repeat_range[mem].upper) {
- STACK_PUSH_REPEAT_INC(si);
- }
- MOP_OUT;
- CHECK_INTERRUPT_IN_MATCH_AT;
- continue;
- break;
-
- case OP_REPEAT_INC_NG_SG: MOP_IN(OP_REPEAT_INC_NG_SG);
- GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
- STACK_GET_REPEAT(mem, stkp);
- si = GET_STACK_INDEX(stkp);
- goto repeat_inc_ng;
- break;
-
- case OP_PUSH_POS: MOP_IN(OP_PUSH_POS);
- STACK_PUSH_POS(s, sprev);
- MOP_OUT;
- continue;
- break;
-
- case OP_POP_POS: MOP_IN(OP_POP_POS);
- {
- STACK_POS_END(stkp);
- s = stkp->u.state.pstr;
- sprev = stkp->u.state.pstr_prev;
- }
- MOP_OUT;
- continue;
- break;
-
- case OP_PUSH_POS_NOT: MOP_IN(OP_PUSH_POS_NOT);
- GET_RELADDR_INC(addr, p);
- STACK_PUSH_POS_NOT(p + addr, s, sprev);
- MOP_OUT;
- continue;
- break;
-
- case OP_FAIL_POS: MOP_IN(OP_FAIL_POS);
- STACK_POP_TIL_POS_NOT;
- goto fail;
- break;
-
- case OP_PUSH_STOP_BT: MOP_IN(OP_PUSH_STOP_BT);
- STACK_PUSH_STOP_BT;
- MOP_OUT;
- continue;
- break;
-
- case OP_POP_STOP_BT: MOP_IN(OP_POP_STOP_BT);
- STACK_STOP_BT_END;
- MOP_OUT;
- continue;
- break;
-
- case OP_LOOK_BEHIND: MOP_IN(OP_LOOK_BEHIND);
- GET_LENGTH_INC(tlen, p);
- s = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen);
- if (IS_NULL(s)) goto fail;
- sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s);
- MOP_OUT;
- continue;
- break;
-
- case OP_PUSH_LOOK_BEHIND_NOT: MOP_IN(OP_PUSH_LOOK_BEHIND_NOT);
- GET_RELADDR_INC(addr, p);
- GET_LENGTH_INC(tlen, p);
- q = (UChar* )ONIGENC_STEP_BACK(encode, str, s, (int )tlen);
- if (IS_NULL(q)) {
- /* too short case -> success. ex. /(?<!XXX)a/.match("a")
- If you want to change to fail, replace following line. */
- p += addr;
- /* goto fail; */
- }
- else {
- STACK_PUSH_LOOK_BEHIND_NOT(p + addr, s, sprev);
- s = q;
- sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s);
- }
- MOP_OUT;
- continue;
- break;
-
- case OP_FAIL_LOOK_BEHIND_NOT: MOP_IN(OP_FAIL_LOOK_BEHIND_NOT);
- STACK_POP_TIL_LOOK_BEHIND_NOT;
- goto fail;
- break;
-
-#ifdef USE_SUBEXP_CALL
- case OP_CALL: MOP_IN(OP_CALL);
- GET_ABSADDR_INC(addr, p);
- STACK_PUSH_CALL_FRAME(p);
- p = reg->p + addr;
- MOP_OUT;
- continue;
- break;
-
- case OP_RETURN: MOP_IN(OP_RETURN);
- STACK_RETURN(p);
- STACK_PUSH_RETURN;
- MOP_OUT;
- continue;
- break;
-#endif
-
- case OP_FINISH:
- goto finish;
- break;
-
- fail:
- MOP_OUT;
- /* fall */
- case OP_FAIL: MOP_IN(OP_FAIL);
- STACK_POP;
- p = stk->u.state.pcode;
- s = stk->u.state.pstr;
- sprev = stk->u.state.pstr_prev;
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- if (stk->u.state.state_check != 0) {
- stk->type = STK_STATE_CHECK_MARK;
- stk++;
- }
-#endif
-
- MOP_OUT;
- continue;
- break;
-
- default:
- goto bytecode_error;
-
- } /* end of switch */
- sprev = sbegin;
- } /* end of while(1) */
-
- finish:
- STACK_SAVE;
- return best_len;
-
-#ifdef ONIG_DEBUG
- stack_error:
- STACK_SAVE;
- return ONIGERR_STACK_BUG;
-#endif
-
- bytecode_error:
- STACK_SAVE;
- return ONIGERR_UNDEFINED_BYTECODE;
-
- unexpected_bytecode_error:
- STACK_SAVE;
- return ONIGERR_UNEXPECTED_BYTECODE;
-}
-
-
-static UChar*
-slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
- const UChar* text, const UChar* text_end, UChar* text_range)
-{
- UChar *t, *p, *s, *end;
-
- end = (UChar* )text_end;
- end -= target_end - target - 1;
- if (end > text_range)
- end = text_range;
-
- s = (UChar* )text;
-
- while (s < end) {
- if (*s == *target) {
- p = s + 1;
- t = target + 1;
- while (t < target_end) {
- if (*t != *p++)
- break;
- t++;
- }
- if (t == target_end)
- return s;
- }
- s += enc_len(enc, s, end);
- }
-
- return (UChar* )NULL;
-}
-
-static int
-str_lower_case_match(OnigEncoding enc, int case_fold_flag,
- const UChar* t, const UChar* tend,
- const UChar* p, const UChar* end)
-{
- int lowlen;
- UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
-
- while (t < tend) {
- lowlen = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &p, end, lowbuf);
- q = lowbuf;
- while (lowlen > 0) {
- if (*t++ != *q++) return 0;
- lowlen--;
- }
- }
-
- return 1;
-}
-
-static UChar*
-slow_search_ic(OnigEncoding enc, int case_fold_flag,
- UChar* target, UChar* target_end,
- const UChar* text, const UChar* text_end, UChar* text_range)
-{
- UChar *s, *end;
-
- end = (UChar* )text_end;
- end -= target_end - target - 1;
- if (end > text_range)
- end = text_range;
-
- s = (UChar* )text;
-
- while (s < end) {
- if (str_lower_case_match(enc, case_fold_flag, target, target_end,
- s, text_end))
- return s;
-
- s += enc_len(enc, s, text_end);
- }
-
- return (UChar* )NULL;
-}
-
-static UChar*
-slow_search_backward(OnigEncoding enc, UChar* target, UChar* target_end,
- const UChar* text, const UChar* adjust_text,
- const UChar* text_end, const UChar* text_start)
-{
- UChar *t, *p, *s;
-
- s = (UChar* )text_end;
- s -= (target_end - target);
- if (s > text_start)
- s = (UChar* )text_start;
- else
- s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, adjust_text, s);
-
- while (s >= text) {
- if (*s == *target) {
- p = s + 1;
- t = target + 1;
- while (t < target_end) {
- if (*t != *p++)
- break;
- t++;
- }
- if (t == target_end)
- return s;
- }
- s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s);
- }
-
- return (UChar* )NULL;
-}
-
-static UChar*
-slow_search_backward_ic(OnigEncoding enc, int case_fold_flag,
- UChar* target, UChar* target_end,
- const UChar* text, const UChar* adjust_text,
- const UChar* text_end, const UChar* text_start)
-{
- UChar *s;
-
- s = (UChar* )text_end;
- s -= (target_end - target);
- if (s > text_start)
- s = (UChar* )text_start;
- else
- s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, adjust_text, s);
-
- while (s >= text) {
- if (str_lower_case_match(enc, case_fold_flag,
- target, target_end, s, text_end))
- return s;
-
- s = (UChar* )onigenc_get_prev_char_head(enc, adjust_text, s);
- }
-
- return (UChar* )NULL;
-}
-
-static UChar*
-bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
- const UChar* text, const UChar* text_end,
- const UChar* text_range)
-{
- const UChar *s, *se, *t, *p, *end;
- const UChar *tail;
- int skip, tlen1;
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr, "bm_search_notrev: text: %d, text_end: %d, text_range: %d\n",
- (int )text, (int )text_end, (int )text_range);
-#endif
-
- tail = target_end - 1;
- tlen1 = tail - target;
- end = text_range;
- if (end + tlen1 > text_end)
- end = text_end - tlen1;
-
- s = text;
-
- if (IS_NULL(reg->int_map)) {
- while (s < end) {
- p = se = s + tlen1;
- t = tail;
- while (t >= target && *p == *t) {
- p--; t--;
- }
- if (t < target) return (UChar* )s;
-
- skip = reg->map[*se];
- t = s;
- do {
- s += enc_len(reg->enc, s, end);
- } while ((s - t) < skip && s < end);
- }
- }
- else {
- while (s < end) {
- p = se = s + tlen1;
- t = tail;
- while (t >= target && *p == *t) {
- p--; t--;
- }
- if (t < target) return (UChar* )s;
-
- skip = reg->int_map[*se];
- t = s;
- do {
- s += enc_len(reg->enc, s, end);
- } while ((s - t) < skip && s < end);
- }
- }
-
- return (UChar* )NULL;
-}
-
-static UChar*
-bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
- const UChar* text, const UChar* text_end, const UChar* text_range)
-{
- const UChar *s, *t, *p, *end;
- const UChar *tail;
-
- end = text_range + (target_end - target) - 1;
- if (end > text_end)
- end = text_end;
-
- tail = target_end - 1;
- s = text + (target_end - target) - 1;
- if (IS_NULL(reg->int_map)) {
- while (s < end) {
- p = s;
- t = tail;
- while (t >= target && *p == *t) {
- p--; t--;
- }
- if (t < target) return (UChar* )(p + 1);
- s += reg->map[*s];
- }
- }
- else { /* see int_map[] */
- while (s < end) {
- p = s;
- t = tail;
- while (t >= target && *p == *t) {
- p--; t--;
- }
- if (t < target) return (UChar* )(p + 1);
- s += reg->int_map[*s];
- }
- }
- return (UChar* )NULL;
-}
-
-static int
-set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc, int** skip)
-
-{
- int i, len;
-
- if (IS_NULL(*skip)) {
- *skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE);
- if (IS_NULL(*skip)) return ONIGERR_MEMORY;
- }
-
- len = end - s;
- for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
- (*skip)[i] = len;
-
- for (i = len - 1; i > 0; i--)
- (*skip)[s[i]] = i;
-
- return 0;
-}
-
-static UChar*
-bm_search_backward(regex_t* reg, const UChar* target, const UChar* target_end,
- const UChar* text, const UChar* adjust_text,
- const UChar* text_end, const UChar* text_start)
-{
- const UChar *s, *t, *p;
-
- s = text_end - (target_end - target);
- if (text_start < s)
- s = text_start;
- else
- s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s);
-
- while (s >= text) {
- p = s;
- t = target;
- while (t < target_end && *p == *t) {
- p++; t++;
- }
- if (t == target_end)
- return (UChar* )s;
-
- s -= reg->int_map_backward[*s];
- s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s);
- }
-
- return (UChar* )NULL;
-}
-
-static UChar*
-map_search(OnigEncoding enc, UChar map[],
- const UChar* text, const UChar* text_range)
-{
- const UChar *s = text;
-
- while (s < text_range) {
- if (map[*s]) return (UChar* )s;
-
- s += enc_len(enc, s, text_range);
- }
- return (UChar* )NULL;
-}
-
-static UChar*
-map_search_backward(OnigEncoding enc, UChar map[],
- const UChar* text, const UChar* adjust_text,
- const UChar* text_start)
-{
- const UChar *s = text_start;
-
- while (s >= text) {
- if (map[*s]) return (UChar* )s;
-
- s = onigenc_get_prev_char_head(enc, adjust_text, s);
- }
- return (UChar* )NULL;
-}
-
-extern int
-onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region,
- OnigOptionType option)
-{
- int r;
- UChar *prev;
- OnigMatchArg msa;
-
-#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
- start:
- THREAD_ATOMIC_START;
- if (ONIG_STATE(reg) >= ONIG_STATE_NORMAL) {
- ONIG_STATE_INC(reg);
- if (IS_NOT_NULL(reg->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
- onig_chain_reduce(reg);
- ONIG_STATE_INC(reg);
- }
- }
- else {
- int n;
-
- THREAD_ATOMIC_END;
- n = 0;
- while (ONIG_STATE(reg) < ONIG_STATE_NORMAL) {
- if (++n > THREAD_PASS_LIMIT_COUNT)
- return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT;
- THREAD_PASS;
- }
- goto start;
- }
- THREAD_ATOMIC_END;
-#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
-
- MATCH_ARG_INIT(msa, option, region, at);
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- {
- int offset = at - str;
- STATE_CHECK_BUFF_INIT(msa, end - str, offset, reg->num_comb_exp_check);
- }
-#endif
-
- if (region
-#ifdef USE_POSIX_REGION_OPTION
- && !IS_POSIX_REGION(option)
-#endif
- ) {
- r = onig_region_resize_clear(region, reg->num_mem + 1);
- }
- else
- r = 0;
-
- if (r == 0) {
- prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
- r = match_at(reg, str, end,
-#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
- end,
-#endif
- at, prev, &msa);
- }
-
- MATCH_ARG_FREE(msa);
- ONIG_STATE_DEC_THREAD(reg);
- return r;
-}
-
-static int
-forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
- UChar* range, UChar** low, UChar** high, UChar** low_prev)
-{
- UChar *p, *pprev = (UChar* )NULL;
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr, "forward_search_range: str: %d, end: %d, s: %d, range: %d\n",
- (int )str, (int )end, (int )s, (int )range);
-#endif
-
- p = s;
- if (reg->dmin > 0) {
- if (ONIGENC_IS_SINGLEBYTE(reg->enc)) {
- p += reg->dmin;
- }
- else {
- UChar *q = p + reg->dmin;
- while (p < q) p += enc_len(reg->enc, p, end);
- }
- }
-
- retry:
- switch (reg->optimize) {
- case ONIG_OPTIMIZE_EXACT:
- p = slow_search(reg->enc, reg->exact, reg->exact_end, p, end, range);
- break;
- case ONIG_OPTIMIZE_EXACT_IC:
- p = slow_search_ic(reg->enc, reg->case_fold_flag,
- reg->exact, reg->exact_end, p, end, range);
- break;
-
- case ONIG_OPTIMIZE_EXACT_BM:
- p = bm_search(reg, reg->exact, reg->exact_end, p, end, range);
- break;
-
- case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:
- p = bm_search_notrev(reg, reg->exact, reg->exact_end, p, end, range);
- break;
-
- case ONIG_OPTIMIZE_MAP:
- p = map_search(reg->enc, reg->map, p, range);
- break;
- }
-
- if (p && p < range) {
- if (p - reg->dmin < s) {
- retry_gate:
- pprev = p;
- p += enc_len(reg->enc, p, end);
- goto retry;
- }
-
- if (reg->sub_anchor) {
- UChar* prev;
-
- switch (reg->sub_anchor) {
- case ANCHOR_BEGIN_LINE:
- if (!ON_STR_BEGIN(p)) {
- prev = onigenc_get_prev_char_head(reg->enc,
- (pprev ? pprev : str), p);
- if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))
- goto retry_gate;
- }
- break;
-
- case ANCHOR_END_LINE:
- if (ON_STR_END(p)) {
-#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
- prev = (UChar* )onigenc_get_prev_char_head(reg->enc,
- (pprev ? pprev : str), p);
- if (prev && ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end))
- goto retry_gate;
-#endif
- }
- else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end)
-#ifdef USE_CRNL_AS_LINE_TERMINATOR
- && ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)
-#endif
- )
- goto retry_gate;
- break;
- }
- }
-
- if (reg->dmax == 0) {
- *low = p;
- if (low_prev) {
- if (*low > s)
- *low_prev = onigenc_get_prev_char_head(reg->enc, s, p);
- else
- *low_prev = onigenc_get_prev_char_head(reg->enc,
- (pprev ? pprev : str), p);
- }
- }
- else {
- if (reg->dmax != ONIG_INFINITE_DISTANCE) {
- *low = p - reg->dmax;
- if (*low > s) {
- *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s,
- *low, (const UChar** )low_prev);
- if (low_prev && IS_NULL(*low_prev))
- *low_prev = onigenc_get_prev_char_head(reg->enc,
- (pprev ? pprev : s), *low);
- }
- else {
- if (low_prev)
- *low_prev = onigenc_get_prev_char_head(reg->enc,
- (pprev ? pprev : str), *low);
- }
- }
- }
- /* no needs to adjust *high, *high is used as range check only */
- *high = p - reg->dmin;
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr,
- "forward_search_range success: low: %d, high: %d, dmin: %d, dmax: %d\n",
- (int )(*low - str), (int )(*high - str), reg->dmin, reg->dmax);
-#endif
- return 1; /* success */
- }
-
- return 0; /* fail */
-}
-
-static int set_bm_backward_skip P_((UChar* s, UChar* end, OnigEncoding enc,
- int** skip));
-
-#define BM_BACKWARD_SEARCH_LENGTH_THRESHOLD 100
-
-static int
-backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
- UChar* s, const UChar* range, UChar* adjrange,
- UChar** low, UChar** high)
-{
- int r;
- UChar *p;
-
- range += reg->dmin;
- p = s;
-
- retry:
- switch (reg->optimize) {
- case ONIG_OPTIMIZE_EXACT:
- exact_method:
- p = slow_search_backward(reg->enc, reg->exact, reg->exact_end,
- range, adjrange, end, p);
- break;
-
- case ONIG_OPTIMIZE_EXACT_IC:
- p = slow_search_backward_ic(reg->enc, reg->case_fold_flag,
- reg->exact, reg->exact_end,
- range, adjrange, end, p);
- break;
-
- case ONIG_OPTIMIZE_EXACT_BM:
- case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:
- if (IS_NULL(reg->int_map_backward)) {
- if (s - range < BM_BACKWARD_SEARCH_LENGTH_THRESHOLD)
- goto exact_method;
-
- r = set_bm_backward_skip(reg->exact, reg->exact_end, reg->enc,
- &(reg->int_map_backward));
- if (r) return r;
- }
- p = bm_search_backward(reg, reg->exact, reg->exact_end, range, adjrange,
- end, p);
- break;
-
- case ONIG_OPTIMIZE_MAP:
- p = map_search_backward(reg->enc, reg->map, range, adjrange, p);
- break;
- }
-
- if (p) {
- if (reg->sub_anchor) {
- UChar* prev;
-
- switch (reg->sub_anchor) {
- case ANCHOR_BEGIN_LINE:
- if (!ON_STR_BEGIN(p)) {
- prev = onigenc_get_prev_char_head(reg->enc, str, p);
- if (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {
- p = prev;
- goto retry;
- }
- }
- break;
-
- case ANCHOR_END_LINE:
- if (ON_STR_END(p)) {
-#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
- prev = onigenc_get_prev_char_head(reg->enc, adjrange, p);
- if (IS_NULL(prev)) goto fail;
- if (ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end)) {
- p = prev;
- goto retry;
- }
-#endif
- }
- else if (! ONIGENC_IS_MBC_NEWLINE(reg->enc, p, end)
-#ifdef USE_CRNL_AS_LINE_TERMINATOR
- && ! ONIGENC_IS_MBC_CRNL(reg->enc, p, end)
-#endif
- ) {
- p = onigenc_get_prev_char_head(reg->enc, adjrange, p);
- if (IS_NULL(p)) goto fail;
- goto retry;
- }
- break;
- }
- }
-
- /* no needs to adjust *high, *high is used as range check only */
- if (reg->dmax != ONIG_INFINITE_DISTANCE) {
- *low = p - reg->dmax;
- *high = p - reg->dmin;
- *high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high);
- }
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr, "backward_search_range: low: %d, high: %d\n",
- (int )(*low - str), (int )(*high - str));
-#endif
- return 1; /* success */
- }
-
- fail:
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr, "backward_search_range: fail.\n");
-#endif
- return 0; /* fail */
-}
-
-
-extern int
-onig_search(regex_t* reg, const UChar* str, const UChar* end,
- const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option)
-{
- int r;
- UChar *s, *prev;
- OnigMatchArg msa;
- const UChar *orig_start = start;
-#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
- const UChar *orig_range = range;
-#endif
-
-#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
- start:
- THREAD_ATOMIC_START;
- if (ONIG_STATE(reg) >= ONIG_STATE_NORMAL) {
- ONIG_STATE_INC(reg);
- if (IS_NOT_NULL(reg->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
- onig_chain_reduce(reg);
- ONIG_STATE_INC(reg);
- }
- }
- else {
- int n;
-
- THREAD_ATOMIC_END;
- n = 0;
- while (ONIG_STATE(reg) < ONIG_STATE_NORMAL) {
- if (++n > THREAD_PASS_LIMIT_COUNT)
- return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT;
- THREAD_PASS;
- }
- goto start;
- }
- THREAD_ATOMIC_END;
-#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr,
- "onig_search (entry point): str: %d, end: %d, start: %d, range: %d\n",
- (int )str, (int )(end - str), (int )(start - str), (int )(range - str));
-#endif
-
- if (region
-#ifdef USE_POSIX_REGION_OPTION
- && !IS_POSIX_REGION(option)
-#endif
- ) {
- r = onig_region_resize_clear(region, reg->num_mem + 1);
- if (r) goto finish_no_msa;
- }
-
- if (start > end || start < str) goto mismatch_no_msa;
-
-
-#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
-#define MATCH_AND_RETURN_CHECK(upper_range) \
- r = match_at(reg, str, end, (upper_range), s, prev, &msa); \
- if (r != ONIG_MISMATCH) {\
- if (r >= 0) {\
- if (! IS_FIND_LONGEST(reg->options)) {\
- goto match;\
- }\
- }\
- else goto finish; /* error */ \
- }
-#else
-#define MATCH_AND_RETURN_CHECK(upper_range) \
- r = match_at(reg, str, end, (upper_range), s, prev, &msa); \
- if (r != ONIG_MISMATCH) {\
- if (r >= 0) {\
- goto match;\
- }\
- else goto finish; /* error */ \
- }
-#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */
-#else
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
-#define MATCH_AND_RETURN_CHECK(none) \
- r = match_at(reg, str, end, s, prev, &msa);\
- if (r != ONIG_MISMATCH) {\
- if (r >= 0) {\
- if (! IS_FIND_LONGEST(reg->options)) {\
- goto match;\
- }\
- }\
- else goto finish; /* error */ \
- }
-#else
-#define MATCH_AND_RETURN_CHECK(none) \
- r = match_at(reg, str, end, s, prev, &msa);\
- if (r != ONIG_MISMATCH) {\
- if (r >= 0) {\
- goto match;\
- }\
- else goto finish; /* error */ \
- }
-#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */
-#endif /* USE_MATCH_RANGE_IS_COMPLETE_RANGE */
-
-
- /* anchor optimize: resume search range */
- if (reg->anchor != 0 && str < end) {
- UChar *min_semi_end, *max_semi_end;
-
- if (reg->anchor & ANCHOR_BEGIN_POSITION) {
- /* search start-position only */
- begin_position:
- if (range > start)
- range = start + 1;
- else
- range = start;
- }
- else if (reg->anchor & ANCHOR_BEGIN_BUF) {
- /* search str-position only */
- if (range > start) {
- if (start != str) goto mismatch_no_msa;
- range = str + 1;
- }
- else {
- if (range <= str) {
- start = str;
- range = str;
- }
- else
- goto mismatch_no_msa;
- }
- }
- else if (reg->anchor & ANCHOR_END_BUF) {
- min_semi_end = max_semi_end = (UChar* )end;
-
- end_buf:
- if ((OnigDistance )(max_semi_end - str) < reg->anchor_dmin)
- goto mismatch_no_msa;
-
- if (range > start) {
- if ((OnigDistance )(min_semi_end - start) > reg->anchor_dmax) {
- start = min_semi_end - reg->anchor_dmax;
- if (start < end)
- start = onigenc_get_right_adjust_char_head(reg->enc, str, start);
- else { /* match with empty at end */
- start = onigenc_get_prev_char_head(reg->enc, str, end);
- }
- }
- if ((OnigDistance )(max_semi_end - (range - 1)) < reg->anchor_dmin) {
- range = max_semi_end - reg->anchor_dmin + 1;
- }
-
- if (start >= range) goto mismatch_no_msa;
- }
- else {
- if ((OnigDistance )(min_semi_end - range) > reg->anchor_dmax) {
- range = min_semi_end - reg->anchor_dmax;
- }
- if ((OnigDistance )(max_semi_end - start) < reg->anchor_dmin) {
- start = max_semi_end - reg->anchor_dmin;
- start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, start);
- }
- if (range > start) goto mismatch_no_msa;
- }
- }
- else if (reg->anchor & ANCHOR_SEMI_END_BUF) {
- UChar* pre_end = ONIGENC_STEP_BACK(reg->enc, str, end, 1);
-
- max_semi_end = (UChar* )end;
- if (ONIGENC_IS_MBC_NEWLINE(reg->enc, pre_end, end)) {
- min_semi_end = pre_end;
-
-#ifdef USE_CRNL_AS_LINE_TERMINATOR
- pre_end = ONIGENC_STEP_BACK(reg->enc, str, pre_end, 1);
- if (IS_NOT_NULL(pre_end) &&
- ONIGENC_IS_MBC_CRNL(reg->enc, pre_end, end)) {
- min_semi_end = pre_end;
- }
-#endif
- if (min_semi_end > str && start <= min_semi_end) {
- goto end_buf;
- }
- }
- else {
- min_semi_end = (UChar* )end;
- goto end_buf;
- }
- }
- else if ((reg->anchor & ANCHOR_ANYCHAR_STAR_ML)) {
- goto begin_position;
- }
- }
- else if (str == end) { /* empty string */
- static const UChar* address_for_empty_string = (UChar* )"";
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr, "onig_search: empty string.\n");
-#endif
-
- if (reg->threshold_len == 0) {
- start = end = str = address_for_empty_string;
- s = (UChar* )start;
- prev = (UChar* )NULL;
-
- MATCH_ARG_INIT(msa, option, region, start);
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- msa.state_check_buff = (void* )0;
- msa.state_check_buff_size = 0; /* NO NEED, for valgrind */
-#endif
- MATCH_AND_RETURN_CHECK(end);
- goto mismatch;
- }
- goto mismatch_no_msa;
- }
-
-#ifdef ONIG_DEBUG_SEARCH
- fprintf(stderr, "onig_search(apply anchor): end: %d, start: %d, range: %d\n",
- (int )(end - str), (int )(start - str), (int )(range - str));
-#endif
-
- MATCH_ARG_INIT(msa, option, region, orig_start);
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- {
- int offset = (MIN(start, range) - str);
- STATE_CHECK_BUFF_INIT(msa, end - str, offset, reg->num_comb_exp_check);
- }
-#endif
-
- s = (UChar* )start;
- if (range > start) { /* forward search */
- if (s > str)
- prev = onigenc_get_prev_char_head(reg->enc, str, s);
- else
- prev = (UChar* )NULL;
-
- if (reg->optimize != ONIG_OPTIMIZE_NONE) {
- UChar *sch_range, *low, *high, *low_prev;
-
- sch_range = (UChar* )range;
- if (reg->dmax != 0) {
- if (reg->dmax == ONIG_INFINITE_DISTANCE)
- sch_range = (UChar* )end;
- else {
- sch_range += reg->dmax;
- if (sch_range > end) sch_range = (UChar* )end;
- }
- }
-
- if ((end - start) < reg->threshold_len)
- goto mismatch;
-
- if (reg->dmax != ONIG_INFINITE_DISTANCE) {
- do {
- if (! forward_search_range(reg, str, end, s, sch_range,
- &low, &high, &low_prev)) goto mismatch;
- if (s < low) {
- s = low;
- prev = low_prev;
- }
- while (s <= high) {
- MATCH_AND_RETURN_CHECK(orig_range);
- prev = s;
- s += enc_len(reg->enc, s, end);
- }
- } while (s < range);
- goto mismatch;
- }
- else { /* check only. */
- if (! forward_search_range(reg, str, end, s, sch_range,
- &low, &high, (UChar** )NULL)) goto mismatch;
-
- if ((reg->anchor & ANCHOR_ANYCHAR_STAR) != 0) {
- do {
- MATCH_AND_RETURN_CHECK(orig_range);
- prev = s;
- s += enc_len(reg->enc, s, end);
-
- while (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end) && s < range) {
- prev = s;
- s += enc_len(reg->enc, s, end);
- }
- } while (s < range);
- goto mismatch;
- }
- }
- }
-
- do {
- MATCH_AND_RETURN_CHECK(orig_range);
- prev = s;
- s += enc_len(reg->enc, s, end);
- } while (s < range);
-
- if (s == range) { /* because empty match with /$/. */
- MATCH_AND_RETURN_CHECK(orig_range);
- }
- }
- else { /* backward search */
-#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
- if (orig_start < end)
- orig_start += enc_len(reg->enc, orig_start); /* is upper range */
-#endif
-
- if (reg->optimize != ONIG_OPTIMIZE_NONE) {
- UChar *low, *high, *adjrange, *sch_start;
-
- if (range < end)
- adjrange = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, str, range);
- else
- adjrange = (UChar* )end;
-
- if (reg->dmax != ONIG_INFINITE_DISTANCE &&
- (end - range) >= reg->threshold_len) {
- do {
- sch_start = s + reg->dmax;
- if (sch_start > end) sch_start = (UChar* )end;
- if (backward_search_range(reg, str, end, sch_start, range, adjrange,
- &low, &high) <= 0)
- goto mismatch;
-
- if (s > high)
- s = high;
-
- while (s >= low) {
- prev = onigenc_get_prev_char_head(reg->enc, str, s);
- MATCH_AND_RETURN_CHECK(orig_start);
- s = prev;
- }
- } while (s >= range);
- goto mismatch;
- }
- else { /* check only. */
- if ((end - range) < reg->threshold_len) goto mismatch;
-
- sch_start = s;
- if (reg->dmax != 0) {
- if (reg->dmax == ONIG_INFINITE_DISTANCE)
- sch_start = (UChar* )end;
- else {
- sch_start += reg->dmax;
- if (sch_start > end) sch_start = (UChar* )end;
- else
- sch_start = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc,
- start, sch_start);
- }
- }
- if (backward_search_range(reg, str, end, sch_start, range, adjrange,
- &low, &high) <= 0) goto mismatch;
- }
- }
-
- do {
- prev = onigenc_get_prev_char_head(reg->enc, str, s);
- MATCH_AND_RETURN_CHECK(orig_start);
- s = prev;
- } while (s >= range);
- }
-
- mismatch:
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
- if (IS_FIND_LONGEST(reg->options)) {
- if (msa.best_len >= 0) {
- s = msa.best_s;
- goto match;
- }
- }
-#endif
- r = ONIG_MISMATCH;
-
- finish:
- MATCH_ARG_FREE(msa);
- ONIG_STATE_DEC_THREAD(reg);
-
- /* If result is mismatch and no FIND_NOT_EMPTY option,
- then the region is not setted in match_at(). */
- if (IS_FIND_NOT_EMPTY(reg->options) && region
-#ifdef USE_POSIX_REGION_OPTION
- && !IS_POSIX_REGION(option)
-#endif
- ) {
- onig_region_clear(region);
- }
-
-#ifdef ONIG_DEBUG
- if (r != ONIG_MISMATCH)
- fprintf(stderr, "onig_search: error %d\n", r);
-#endif
- return r;
-
- mismatch_no_msa:
- r = ONIG_MISMATCH;
- finish_no_msa:
- ONIG_STATE_DEC_THREAD(reg);
-#ifdef ONIG_DEBUG
- if (r != ONIG_MISMATCH)
- fprintf(stderr, "onig_search: error %d\n", r);
-#endif
- return r;
-
- match:
- ONIG_STATE_DEC_THREAD(reg);
- MATCH_ARG_FREE(msa);
- return s - str;
-}
-
-extern OnigEncoding
-onig_get_encoding(regex_t* reg)
-{
- return reg->enc;
-}
-
-extern OnigOptionType
-onig_get_options(regex_t* reg)
-{
- return reg->options;
-}
-
-extern OnigCaseFoldType
-onig_get_case_fold_flag(regex_t* reg)
-{
- return reg->case_fold_flag;
-}
-
-extern OnigSyntaxType*
-onig_get_syntax(regex_t* reg)
-{
- return reg->syntax;
-}
-
-extern int
-onig_number_of_captures(regex_t* reg)
-{
- return reg->num_mem;
-}
-
-extern int
-onig_number_of_capture_histories(regex_t* reg)
-{
-#ifdef USE_CAPTURE_HISTORY
- int i, n;
-
- n = 0;
- for (i = 0; i <= ONIG_MAX_CAPTURE_HISTORY_GROUP; i++) {
- if (BIT_STATUS_AT(reg->capture_history, i) != 0)
- n++;
- }
- return n;
-#else
- return 0;
-#endif
-}
-
-extern void
-onig_copy_encoding(OnigEncoding to, OnigEncoding from)
-{
- *to = *from;
-}
-
diff --git a/regint.h b/regint.h
deleted file mode 100644
index 182eed2670..0000000000
--- a/regint.h
+++ /dev/null
@@ -1,836 +0,0 @@
-#ifndef REGINT_H
-#define REGINT_H
-/**********************************************************************
- regint.h - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* for debug */
-/* #define ONIG_DEBUG_PARSE_TREE */
-/* #define ONIG_DEBUG_COMPILE */
-/* #define ONIG_DEBUG_SEARCH */
-/* #define ONIG_DEBUG_MATCH */
-/* #define ONIG_DONT_OPTIMIZE */
-
-/* for byte-code statistical data. */
-/* #define ONIG_DEBUG_STATISTICS */
-
-#if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
- defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
- defined(ONIG_DEBUG_STATISTICS)
-#ifndef ONIG_DEBUG
-#define ONIG_DEBUG
-#endif
-#endif
-
-#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
- (defined(__ppc__) && defined(__APPLE__)) || \
- defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \
- defined(__mc68020__)
-/* #define PLATFORM_UNALIGNED_WORD_ACCESS */
-#endif
-
-/* config */
-/* spec. config */
-#define USE_NAMED_GROUP
-#define USE_SUBEXP_CALL
-#define USE_BACKREF_AT_LEVEL /* \k<name+n>, \k<name-n> */
-#define USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK /* /(?:()|())*\2/ */
-#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
-#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
-/* #define USE_RECOMPILE_API */
-/* #define USE_CRNL_AS_LINE_TERMINATOR */ /* moved to regenc.h. */
-
-/* internal config */
-#define USE_PARSE_TREE_NODE_RECYCLE
-#define USE_OP_PUSH_OR_JUMP_EXACT
-#define USE_QTFR_PEEK_NEXT
-#define USE_ST_LIBRARY
-#define USE_SHARED_CCLASS_TABLE
-
-#define INIT_MATCH_STACK_SIZE 160
-#define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
-
-/* */
-/* escape other system UChar definition */
-#ifndef RUBY_DEFINES_H
-#include "ruby/config.h"
-#include "ruby/defines.h"
-#endif
-#ifdef ONIG_ESCAPE_UCHAR_COLLISION
-#undef ONIG_ESCAPE_UCHAR_COLLISION
-#endif
-#undef USE_MATCH_RANGE_IS_COMPLETE_RANGE
-#define USE_CAPTURE_HISTORY
-#define USE_VARIABLE_META_CHARS
-#define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */
-#define USE_POSIX_REGION_OPTION /* needed for POSIX API support */
-#define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
-/* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
-/* #define USE_MULTI_THREAD_SYSTEM */
-#define THREAD_SYSTEM_INIT /* depend on thread system */
-#define THREAD_SYSTEM_END /* depend on thread system */
-#define THREAD_ATOMIC_START /* depend on thread system */
-#define THREAD_ATOMIC_END /* depend on thread system */
-#define THREAD_PASS /* depend on thread system */
-#ifndef xmalloc
-#define xmalloc malloc
-#define xrealloc realloc
-#define xcalloc calloc
-#define xfree free
-#endif
-
-#define CHECK_INTERRUPT_IN_MATCH_AT
-
-#ifdef RUBY
-
-#define onig_st_init_table st_init_table
-#define onig_st_init_table_with_size st_init_table_with_size
-#define onig_st_init_numtable st_init_numtable
-#define onig_st_init_numtable_with_size st_init_numtable_with_size
-#define onig_st_init_strtable st_init_strtable
-#define onig_st_init_strtable_with_size st_init_strtable_with_size
-#define onig_st_delete st_delete
-#define onig_st_delete_safe st_delete_safe
-#define onig_st_insert st_insert
-#define onig_st_lookup st_lookup
-#define onig_st_foreach st_foreach
-#define onig_st_add_direct st_add_direct
-#define onig_st_free_table st_free_table
-#define onig_st_cleanup_safe st_cleanup_safe
-#define onig_st_copy st_copy
-#define onig_st_nothing_key_clone st_nothing_key_clone
-#define onig_st_nothing_key_free st_nothing_key_free
-#define onig_st_is_member st_is_member
-
-#define USE_UPPER_CASE_TABLE
-#else
-
-#define st_init_table onig_st_init_table
-#define st_init_table_with_size onig_st_init_table_with_size
-#define st_init_numtable onig_st_init_numtable
-#define st_init_numtable_with_size onig_st_init_numtable_with_size
-#define st_init_strtable onig_st_init_strtable
-#define st_init_strtable_with_size onig_st_init_strtable_with_size
-#define st_delete onig_st_delete
-#define st_delete_safe onig_st_delete_safe
-#define st_insert onig_st_insert
-#define st_lookup onig_st_lookup
-#define st_foreach onig_st_foreach
-#define st_add_direct onig_st_add_direct
-#define st_free_table onig_st_free_table
-#define st_cleanup_safe onig_st_cleanup_safe
-#define st_copy onig_st_copy
-#define st_nothing_key_clone onig_st_nothing_key_clone
-#define st_nothing_key_free onig_st_nothing_key_free
-/* */
-#define onig_st_is_member st_is_member
-
-#endif
-
-#define STATE_CHECK_STRING_THRESHOLD_LEN 7
-#define STATE_CHECK_BUFF_MAX_SIZE 0x4000
-
-#define THREAD_PASS_LIMIT_COUNT 8
-#define xmemset memset
-#define xmemcpy memcpy
-#define xmemmove memmove
-
-#if defined(_WIN32) && !defined(__GNUC__)
-#define xalloca _alloca
-#define xvsnprintf _vsnprintf
-#else
-#define xalloca alloca
-#define xvsnprintf vsnprintf
-#endif
-
-
-#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
-#define ONIG_STATE_INC(reg) (reg)->state++
-#define ONIG_STATE_DEC(reg) (reg)->state--
-
-#define ONIG_STATE_INC_THREAD(reg) do {\
- THREAD_ATOMIC_START;\
- (reg)->state++;\
- THREAD_ATOMIC_END;\
-} while(0)
-#define ONIG_STATE_DEC_THREAD(reg) do {\
- THREAD_ATOMIC_START;\
- (reg)->state--;\
- THREAD_ATOMIC_END;\
-} while(0)
-#else
-#define ONIG_STATE_INC(reg) /* Nothing */
-#define ONIG_STATE_DEC(reg) /* Nothing */
-#define ONIG_STATE_INC_THREAD(reg) /* Nothing */
-#define ONIG_STATE_DEC_THREAD(reg) /* Nothing */
-#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
-#include <alloca.h>
-#endif
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-
-#include <ctype.h>
-#ifdef HAVE_SYS_TYPES_H
-#ifndef __BORLANDC__
-#include <sys/types.h>
-#endif
-#endif
-
-#ifdef __BORLANDC__
-#include <malloc.h>
-#endif
-
-#ifdef ONIG_DEBUG
-# include <stdio.h>
-#endif
-
-#include "regenc.h"
-
-#ifdef MIN
-#undef MIN
-#endif
-#ifdef MAX
-#undef MAX
-#endif
-#define MIN(a,b) (((a)>(b))?(b):(a))
-#define MAX(a,b) (((a)<(b))?(b):(a))
-
-#define IS_NULL(p) (((void*)(p)) == (void*)0)
-#define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
-#define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
-#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
-#define NULL_UCHARP ((UChar* )0)
-
-
-#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
-
-#define PLATFORM_GET_INC(val,p,type) do{\
- val = *(type* )p;\
- (p) += sizeof(type);\
-} while(0)
-
-#else
-
-#define PLATFORM_GET_INC(val,p,type) do{\
- xmemcpy(&val, (p), sizeof(type));\
- (p) += sizeof(type);\
-} while(0)
-
-/* sizeof(OnigCodePoint) */
-#define WORD_ALIGNMENT_SIZE SIZEOF_LONG
-
-#define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
- (pad_size) = WORD_ALIGNMENT_SIZE \
- - ((unsigned int )(addr) % WORD_ALIGNMENT_SIZE);\
- if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
-} while (0)
-
-#define ALIGNMENT_RIGHT(addr) do {\
- (addr) += (WORD_ALIGNMENT_SIZE - 1);\
- (addr) -= ((unsigned int )(addr) % WORD_ALIGNMENT_SIZE);\
-} while (0)
-
-#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
-
-/* stack pop level */
-#define STACK_POP_LEVEL_FREE 0
-#define STACK_POP_LEVEL_MEM_START 1
-#define STACK_POP_LEVEL_ALL 2
-
-/* optimize flags */
-#define ONIG_OPTIMIZE_NONE 0
-#define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
-#define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
-#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (but not simple match) */
-#define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
-#define ONIG_OPTIMIZE_MAP 5 /* char map */
-
-/* bit status */
-typedef unsigned int BitStatusType;
-
-#define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
-#define BIT_STATUS_CLEAR(stats) (stats) = 0
-#define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
-#define BIT_STATUS_AT(stats,n) \
- ((n) < BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1))
-
-#define BIT_STATUS_ON_AT(stats,n) do {\
- if ((n) < BIT_STATUS_BITS_NUM)\
- (stats) |= (1 << (n));\
- else\
- (stats) |= 1;\
-} while (0)
-
-#define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
- if ((n) < BIT_STATUS_BITS_NUM)\
- (stats) |= (1 << (n));\
-} while (0)
-
-
-#define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
-
-#define DIGITVAL(code) ((code) - '0')
-#define ODIGITVAL(code) DIGITVAL(code)
-#define XDIGITVAL(enc,code) \
- (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
- : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
-
-#define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
-#define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
-#define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
-#define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
-#define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
-#define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
-#define IS_FIND_CONDITION(option) ((option) & \
- (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
-#define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
-#define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
-#define IS_POSIX_REGION(option) ((option) & ONIG_OPTION_POSIX_REGION)
-
-/* OP_SET_OPTION is required for these options.
-#define IS_DYNAMIC_OPTION(option) \
- (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
-*/
-/* ignore-case and multibyte status are included in compiled code. */
-#define IS_DYNAMIC_OPTION(option) 0
-
-#define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
- ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
-
-#define REPEAT_INFINITE -1
-#define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
-
-/* bitset */
-#define BITS_PER_BYTE 8
-#define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
-#define BITS_IN_ROOM (sizeof(Bits) * BITS_PER_BYTE)
-#define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
-
-#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
-typedef unsigned int Bits;
-#else
-typedef unsigned char Bits;
-#endif
-typedef Bits BitSet[BITSET_SIZE];
-typedef Bits* BitSetRef;
-
-#define SIZE_BITSET sizeof(BitSet)
-
-#define BITSET_CLEAR(bs) do {\
- int i;\
- for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; }\
-} while (0)
-
-#define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM]
-#define BS_BIT(pos) (1 << (pos % BITS_IN_ROOM))
-
-#define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
-#define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
-#define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
-#define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
-
-/* bytes buffer */
-typedef struct _BBuf {
- UChar* p;
- unsigned int used;
- unsigned int alloc;
-} BBuf;
-
-#define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
-
-#define BBUF_SIZE_INC(buf,inc) do{\
- (buf)->alloc += (inc);\
- (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
- if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
-} while (0)
-
-#define BBUF_EXPAND(buf,low) do{\
- do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
- (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
- if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
-} while (0)
-
-#define BBUF_ENSURE_SIZE(buf,size) do{\
- unsigned int new_alloc = (buf)->alloc;\
- while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
- if ((buf)->alloc != new_alloc) {\
- (buf)->p = (UChar* )xrealloc((buf)->p, new_alloc);\
- if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
- (buf)->alloc = new_alloc;\
- }\
-} while (0)
-
-#define BBUF_WRITE(buf,pos,bytes,n) do{\
- int used = (pos) + (n);\
- if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
- xmemcpy((buf)->p + (pos), (bytes), (n));\
- if ((buf)->used < (unsigned int )used) (buf)->used = used;\
-} while (0)
-
-#define BBUF_WRITE1(buf,pos,byte) do{\
- int used = (pos) + 1;\
- if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
- (buf)->p[(pos)] = (byte);\
- if ((buf)->used < (unsigned int )used) (buf)->used = used;\
-} while (0)
-
-#define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
-#define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
-#define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
-#define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
-
-/* from < to */
-#define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
- if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
- xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
- if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
-} while (0)
-
-/* from > to */
-#define BBUF_MOVE_LEFT(buf,from,to,n) do {\
- xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
-} while (0)
-
-/* from > to */
-#define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
- xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
- (buf)->used -= (from - to);\
-} while (0)
-
-#define BBUF_INSERT(buf,pos,bytes,n) do {\
- if (pos >= (buf)->used) {\
- BBUF_WRITE(buf,pos,bytes,n);\
- }\
- else {\
- BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
- xmemcpy((buf)->p + (pos), (bytes), (n));\
- }\
-} while (0)
-
-#define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
-
-
-#define ANCHOR_BEGIN_BUF (1<<0)
-#define ANCHOR_BEGIN_LINE (1<<1)
-#define ANCHOR_BEGIN_POSITION (1<<2)
-#define ANCHOR_END_BUF (1<<3)
-#define ANCHOR_SEMI_END_BUF (1<<4)
-#define ANCHOR_END_LINE (1<<5)
-
-#define ANCHOR_WORD_BOUND (1<<6)
-#define ANCHOR_NOT_WORD_BOUND (1<<7)
-#define ANCHOR_WORD_BEGIN (1<<8)
-#define ANCHOR_WORD_END (1<<9)
-#define ANCHOR_PREC_READ (1<<10)
-#define ANCHOR_PREC_READ_NOT (1<<11)
-#define ANCHOR_LOOK_BEHIND (1<<12)
-#define ANCHOR_LOOK_BEHIND_NOT (1<<13)
-
-#define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
-#define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
-
-/* operation code */
-enum OpCode {
- OP_FINISH = 0, /* matching process terminator (no more alternative) */
- OP_END = 1, /* pattern code terminator (success end) */
-
- OP_EXACT1 = 2, /* single byte, N = 1 */
- OP_EXACT2, /* single byte, N = 2 */
- OP_EXACT3, /* single byte, N = 3 */
- OP_EXACT4, /* single byte, N = 4 */
- OP_EXACT5, /* single byte, N = 5 */
- OP_EXACTN, /* single byte */
- OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
- OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
- OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
- OP_EXACTMB2N, /* mb-length = 2 */
- OP_EXACTMB3N, /* mb-length = 3 */
- OP_EXACTMBN, /* other length */
-
- OP_EXACT1_IC, /* single byte, N = 1, ignore case */
- OP_EXACTN_IC, /* single byte, ignore case */
-
- OP_CCLASS,
- OP_CCLASS_MB,
- OP_CCLASS_MIX,
- OP_CCLASS_NOT,
- OP_CCLASS_MB_NOT,
- OP_CCLASS_MIX_NOT,
- OP_CCLASS_NODE, /* pointer to CClassNode node */
-
- OP_ANYCHAR, /* "." */
- OP_ANYCHAR_ML, /* "." multi-line */
- OP_ANYCHAR_STAR, /* ".*" */
- OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
- OP_ANYCHAR_STAR_PEEK_NEXT,
- OP_ANYCHAR_ML_STAR_PEEK_NEXT,
-
- OP_WORD,
- OP_NOT_WORD,
- OP_WORD_BOUND,
- OP_NOT_WORD_BOUND,
- OP_WORD_BEGIN,
- OP_WORD_END,
-
- OP_BEGIN_BUF,
- OP_END_BUF,
- OP_BEGIN_LINE,
- OP_END_LINE,
- OP_SEMI_END_BUF,
- OP_BEGIN_POSITION,
-
- OP_BACKREF1,
- OP_BACKREF2,
- OP_BACKREFN,
- OP_BACKREFN_IC,
- OP_BACKREF_MULTI,
- OP_BACKREF_MULTI_IC,
- OP_BACKREF_AT_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
-
- OP_MEMORY_START,
- OP_MEMORY_START_PUSH, /* push back-tracker to stack */
- OP_MEMORY_END_PUSH, /* push back-tracker to stack */
- OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
- OP_MEMORY_END,
- OP_MEMORY_END_REC, /* push marker to stack */
-
- OP_FAIL, /* pop stack and move */
- OP_JUMP,
- OP_PUSH,
- OP_POP,
- OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
- OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
- OP_REPEAT, /* {n,m} */
- OP_REPEAT_NG, /* {n,m}? (non greedy) */
- OP_REPEAT_INC,
- OP_REPEAT_INC_NG, /* non greedy */
- OP_REPEAT_INC_SG, /* search and get in stack */
- OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
- OP_NULL_CHECK_START, /* null loop checker start */
- OP_NULL_CHECK_END, /* null loop checker end */
- OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
- OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
-
- OP_PUSH_POS, /* (?=...) start */
- OP_POP_POS, /* (?=...) end */
- OP_PUSH_POS_NOT, /* (?!...) start */
- OP_FAIL_POS, /* (?!...) end */
- OP_PUSH_STOP_BT, /* (?>...) start */
- OP_POP_STOP_BT, /* (?>...) end */
- OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
- OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
- OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
-
- OP_CALL, /* \g<name> */
- OP_RETURN,
-
- OP_STATE_CHECK_PUSH, /* combination explosion check and push */
- OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
- OP_STATE_CHECK, /* check only */
- OP_STATE_CHECK_ANYCHAR_STAR,
- OP_STATE_CHECK_ANYCHAR_ML_STAR,
-
- /* no need: IS_DYNAMIC_OPTION() == 0 */
- OP_SET_OPTION_PUSH, /* set option and push recover option */
- OP_SET_OPTION /* set option */
-};
-
-typedef int RelAddrType;
-typedef int AbsAddrType;
-typedef int LengthType;
-typedef int RepeatNumType;
-typedef short int MemNumType;
-typedef short int StateCheckNumType;
-typedef void* PointerType;
-
-#define SIZE_OPCODE 1
-#define SIZE_RELADDR sizeof(RelAddrType)
-#define SIZE_ABSADDR sizeof(AbsAddrType)
-#define SIZE_LENGTH sizeof(LengthType)
-#define SIZE_MEMNUM sizeof(MemNumType)
-#define SIZE_STATE_CHECK_NUM sizeof(StateCheckNumType)
-#define SIZE_REPEATNUM sizeof(RepeatNumType)
-#define SIZE_OPTION sizeof(OnigOptionType)
-#define SIZE_CODE_POINT sizeof(OnigCodePoint)
-#define SIZE_POINTER sizeof(PointerType)
-
-
-#define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
-#define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
-#define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
-#define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
-#define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
-#define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
-#define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
-#define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
-
-/* code point's address must be aligned address. */
-#define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
-#define GET_BYTE_INC(byte,p) do{\
- byte = *(p);\
- (p)++;\
-} while(0)
-
-
-/* op-code + arg size */
-#define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
-#define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
-#define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
-#define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
-#define SIZE_OP_POP SIZE_OPCODE
-#define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
-#define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
-#define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_PUSH_POS SIZE_OPCODE
-#define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
-#define SIZE_OP_POP_POS SIZE_OPCODE
-#define SIZE_OP_FAIL_POS SIZE_OPCODE
-#define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
-#define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
-#define SIZE_OP_FAIL SIZE_OPCODE
-#define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
-#define SIZE_OP_POP_STOP_BT SIZE_OPCODE
-#define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
-#define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
-#define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
-#define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
-#define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
-#define SIZE_OP_RETURN SIZE_OPCODE
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
-#define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
-#define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
-#define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
-#define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
-#endif
-
-#define MC_ESC(syn) (syn)->meta_char_table.esc
-#define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
-#define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
-#define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
-#define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
-#define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
-
-#define IS_MC_ESC_CODE(code, syn) \
- ((code) == MC_ESC(syn) && \
- !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
-
-
-#define SYN_POSIX_COMMON_OP \
- ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
- ONIG_SYN_OP_DECIMAL_BACKREF | \
- ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
- ONIG_SYN_OP_LINE_ANCHOR | \
- ONIG_SYN_OP_ESC_CONTROL_CHARS )
-
-#define SYN_GNU_REGEX_OP \
- ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
- ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
- ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
- ONIG_SYN_OP_VBAR_ALT | \
- ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
- ONIG_SYN_OP_QMARK_ZERO_ONE | \
- ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
- ONIG_SYN_OP_ESC_W_WORD | \
- ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
- ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
- ONIG_SYN_OP_LINE_ANCHOR )
-
-#define SYN_GNU_REGEX_BV \
- ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
- ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
- ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
-
-
-#define NCCLASS_FLAGS(cc) ((cc)->flags)
-#define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
-#define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
-#define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
-
-/* cclass node */
-#define FLAG_NCCLASS_NOT (1<<0)
-#define FLAG_NCCLASS_SHARE (1<<1)
-
-#define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
-#define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
-#define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
-#define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
-#define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
-
-typedef struct {
- int type;
- /* struct _Node* next; */
- /* unsigned int flags; */
-} NodeBase;
-
-typedef struct {
- NodeBase base;
- unsigned int flags;
- BitSet bs;
- BBuf* mbuf; /* multi-byte info or NULL */
-} CClassNode;
-
-typedef long OnigStackIndex;
-
-typedef struct _OnigStackType {
- unsigned int type;
- union {
- struct {
- UChar *pcode; /* byte code position */
- UChar *pstr; /* string position */
- UChar *pstr_prev; /* previous char position of pstr */
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- unsigned int state_check;
-#endif
- } state;
- struct {
- int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
- UChar *pcode; /* byte code position (head of repeated target) */
- int num; /* repeat id */
- } repeat;
- struct {
- OnigStackIndex si; /* index of stack */
- } repeat_inc;
- struct {
- int num; /* memory num */
- UChar *pstr; /* start/end position */
- /* Following information is setted, if this stack type is MEM-START */
- OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
- OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
- } mem;
- struct {
- int num; /* null check id */
- UChar *pstr; /* start position */
- } null_check;
-#ifdef USE_SUBEXP_CALL
- struct {
- UChar *ret_addr; /* byte code position */
- int num; /* null check id */
- UChar *pstr; /* string position */
- } call_frame;
-#endif
- } u;
-} OnigStackType;
-
-typedef struct {
- void* stack_p;
- int stack_n;
- OnigOptionType options;
- OnigRegion* region;
- const UChar* start; /* search start position (for \G: BEGIN_POSITION) */
-#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
- int best_len; /* for ONIG_OPTION_FIND_LONGEST */
- UChar* best_s;
-#endif
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- void* state_check_buff;
- int state_check_buff_size;
-#endif
-} OnigMatchArg;
-
-
-#define IS_CODE_SB_WORD(enc,code) \
- (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
-
-#ifdef ONIG_DEBUG
-
-typedef struct {
- short int opcode;
- char* name;
- short int arg_type;
-} OnigOpInfoType;
-
-extern OnigOpInfoType OnigOpInfo[];
-
-extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar** nextp, OnigEncoding enc));
-
-#ifdef ONIG_DEBUG_STATISTICS
-extern void onig_statistics_init P_((void));
-extern void onig_print_statistics P_((FILE* f));
-#endif
-#endif
-
-extern UChar* onig_error_code_to_format P_((int code));
-extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
-extern int onig_bbuf_init P_((BBuf* buf, int size));
-extern int onig_alloc_init P_((regex_t** reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, OnigSyntaxType* syntax));
-extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo));
-extern void onig_chain_reduce P_((regex_t* reg));
-extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
-extern void onig_transfer P_((regex_t* to, regex_t* from));
-extern int onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
-extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
-
-/* strend hash */
-typedef void hash_table_type;
-#ifdef RUBY
-#include <ruby/st.h>
-typedef st_data_t hash_data_type;
-#else
-typedef unsigned long hash_data_type;
-#endif
-
-extern hash_table_type* onig_st_init_strend_table_with_size P_((int size));
-extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
-extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
-
-/* encoding property management */
-#define PROPERTY_LIST_ADD_PROP(Name, CR) \
- r = onigenc_property_list_add_property((UChar* )Name, CR,\
- &PropertyNameTable, &PropertyList, &PropertyListNum,\
- &PropertyListSize);\
- if (r != 0) goto end
-
-#define PROPERTY_LIST_INIT_CHECK \
- if (PropertyInited == 0) {\
- int r = onigenc_property_list_init(init_property_list);\
- if (r != 0) return r;\
- }
-
-extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
-extern int onigenc_property_list_init P_((int (*f)()));
-
-#endif /* REGINT_H */
diff --git a/regparse.c b/regparse.c
deleted file mode 100644
index f86abc80ab..0000000000
--- a/regparse.c
+++ /dev/null
@@ -1,5345 +0,0 @@
-/**********************************************************************
- regparse.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regparse.h"
-
-#define WARN_BUFSIZE 256
-
-OnigSyntaxType OnigSyntaxRuby = {
- (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
- ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
- ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
- ONIG_SYN_OP_ESC_C_CONTROL )
- & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
- , ( ONIG_SYN_OP2_QMARK_GROUP_EFFECT |
- ONIG_SYN_OP2_OPTION_RUBY |
- ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP | ONIG_SYN_OP2_ESC_K_NAMED_BACKREF |
- ONIG_SYN_OP2_ESC_G_SUBEXP_CALL |
- ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
- ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
- ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
- ONIG_SYN_OP2_CCLASS_SET_OP | ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL |
- ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META | ONIG_SYN_OP2_ESC_V_VTAB |
- ONIG_SYN_OP2_ESC_H_XDIGIT )
- , ( SYN_GNU_REGEX_BV |
- ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV |
- ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND |
- ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
- ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME |
- ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY |
- ONIG_SYN_WARN_CC_OP_NOT_ESCAPED |
- ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT )
- , ONIG_OPTION_NONE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType* OnigDefaultSyntax = ONIG_SYNTAX_RUBY;
-
-extern void onig_null_warn(const char* s) { }
-
-#ifdef DEFAULT_WARN_FUNCTION
-static OnigWarnFunc onig_warn = (OnigWarnFunc )DEFAULT_WARN_FUNCTION;
-#else
-static OnigWarnFunc onig_warn = onig_null_warn;
-#endif
-
-#ifdef DEFAULT_VERB_WARN_FUNCTION
-static OnigWarnFunc onig_verb_warn = (OnigWarnFunc )DEFAULT_VERB_WARN_FUNCTION;
-#else
-static OnigWarnFunc onig_verb_warn = onig_null_warn;
-#endif
-
-extern void onig_set_warn_func(OnigWarnFunc f)
-{
- onig_warn = f;
-}
-
-extern void onig_set_verb_warn_func(OnigWarnFunc f)
-{
- onig_verb_warn = f;
-}
-
-static void
-bbuf_free(BBuf* bbuf)
-{
- if (IS_NOT_NULL(bbuf)) {
- if (IS_NOT_NULL(bbuf->p)) xfree(bbuf->p);
- xfree(bbuf);
- }
-}
-
-static int
-bbuf_clone(BBuf** rto, BBuf* from)
-{
- int r;
- BBuf *to;
-
- *rto = to = (BBuf* )xmalloc(sizeof(BBuf));
- CHECK_NULL_RETURN_MEMERR(to);
- r = BBUF_INIT(to, from->alloc);
- if (r != 0) return r;
- to->used = from->used;
- xmemcpy(to->p, from->p, from->used);
- return 0;
-}
-
-#define ONOFF(v,f,negative) (negative) ? ((v) &= ~(f)) : ((v) |= (f))
-
-#define MBCODE_START_POS(enc) \
- (OnigCodePoint )(ONIGENC_MBC_MINLEN(enc) > 1 ? 0 : 0x80)
-
-#define SET_ALL_MULTI_BYTE_RANGE(enc, pbuf) \
- add_code_range_to_buf(pbuf, MBCODE_START_POS(enc), ~((OnigCodePoint )0))
-
-#define ADD_ALL_MULTI_BYTE_RANGE(enc, mbuf) do {\
- if (! ONIGENC_IS_SINGLEBYTE(enc)) {\
- r = SET_ALL_MULTI_BYTE_RANGE(enc, &(mbuf));\
- if (r) return r;\
- }\
-} while (0)
-
-
-#define BITSET_IS_EMPTY(bs,empty) do {\
- int i;\
- empty = 1;\
- for (i = 0; i < BITSET_SIZE; i++) {\
- if ((bs)[i] != 0) {\
- empty = 0; break;\
- }\
- }\
-} while (0)
-
-static void
-bitset_set_range(BitSetRef bs, int from, int to)
-{
- int i;
- for (i = from; i <= to && i < SINGLE_BYTE_SIZE; i++) {
- BITSET_SET_BIT(bs, i);
- }
-}
-
-#if 0
-static void
-bitset_set_all(BitSetRef bs)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) { bs[i] = ~((Bits )0); }
-}
-#endif
-
-static void
-bitset_invert(BitSetRef bs)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) { bs[i] = ~(bs[i]); }
-}
-
-static void
-bitset_invert_to(BitSetRef from, BitSetRef to)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) { to[i] = ~(from[i]); }
-}
-
-static void
-bitset_and(BitSetRef dest, BitSetRef bs)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) { dest[i] &= bs[i]; }
-}
-
-static void
-bitset_or(BitSetRef dest, BitSetRef bs)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) { dest[i] |= bs[i]; }
-}
-
-static void
-bitset_copy(BitSetRef dest, BitSetRef bs)
-{
- int i;
- for (i = 0; i < BITSET_SIZE; i++) { dest[i] = bs[i]; }
-}
-
-extern int
-onig_strncmp(const UChar* s1, const UChar* s2, int n)
-{
- int x;
-
- while (n-- > 0) {
- x = *s2++ - *s1++;
- if (x) return x;
- }
- return 0;
-}
-
-extern void
-onig_strcpy(UChar* dest, const UChar* src, const UChar* end)
-{
- int len = end - src;
- if (len > 0) {
- xmemcpy(dest, src, len);
- dest[len] = (UChar )0;
- }
-}
-
-static UChar*
-strdup_with_null(OnigEncoding enc, UChar* s, UChar* end)
-{
- int slen, term_len, i;
- UChar *r;
-
- slen = end - s;
- term_len = ONIGENC_MBC_MINLEN(enc);
-
- r = (UChar* )xmalloc(slen + term_len);
- CHECK_NULL_RETURN(r);
- xmemcpy(r, s, slen);
-
- for (i = 0; i < term_len; i++)
- r[slen + i] = (UChar )0;
-
- return r;
-}
-
-
-/* scan pattern methods */
-#define PEND_VALUE 0
-
-#define PFETCH_READY UChar* pfetch_prev
-#define PEND (p < end ? 0 : 1)
-#define PUNFETCH p = pfetch_prev
-#define PINC do { \
- pfetch_prev = p; \
- p += ONIGENC_MBC_ENC_LEN(enc, p, end); \
-} while (0)
-#define PFETCH(c) do { \
- c = ONIGENC_MBC_TO_CODE(enc, p, end); \
- pfetch_prev = p; \
- p += ONIGENC_MBC_ENC_LEN(enc, p, end); \
-} while (0)
-
-#define PPEEK (p < end ? ONIGENC_MBC_TO_CODE(enc, p, end) : PEND_VALUE)
-#define PPEEK_IS(c) (PPEEK == (OnigCodePoint )c)
-
-static UChar*
-strcat_capa(UChar* dest, UChar* dest_end, const UChar* src, const UChar* src_end,
- int capa)
-{
- UChar* r;
-
- if (dest)
- r = (UChar* )xrealloc(dest, capa + 1);
- else
- r = (UChar* )xmalloc(capa + 1);
-
- CHECK_NULL_RETURN(r);
- onig_strcpy(r + (dest_end - dest), src, src_end);
- return r;
-}
-
-/* dest on static area */
-static UChar*
-strcat_capa_from_static(UChar* dest, UChar* dest_end,
- const UChar* src, const UChar* src_end, int capa)
-{
- UChar* r;
-
- r = (UChar* )xmalloc(capa + 1);
- CHECK_NULL_RETURN(r);
- onig_strcpy(r, dest, dest_end);
- onig_strcpy(r + (dest_end - dest), src, src_end);
- return r;
-}
-
-#ifdef USE_NAMED_GROUP
-
-#define INIT_NAME_BACKREFS_ALLOC_NUM 8
-
-typedef struct {
- UChar* name;
- int name_len; /* byte length */
- int back_num; /* number of backrefs */
- int back_alloc;
- int back_ref1;
- int* back_refs;
-} NameEntry;
-
-#ifdef USE_ST_LIBRARY
-
-#include "ruby/st.h"
-
-typedef struct {
- unsigned char* s;
- unsigned char* end;
-} st_strend_key;
-
-static int
-str_end_cmp(st_strend_key* x, st_strend_key* y)
-{
- unsigned char *p, *q;
- int c;
-
- if ((x->end - x->s) != (y->end - y->s))
- return 1;
-
- p = x->s;
- q = y->s;
- while (p < x->end) {
- c = (int )*p - (int )*q;
- if (c != 0) return c;
-
- p++; q++;
- }
-
- return 0;
-}
-
-static int
-str_end_hash(st_strend_key* x)
-{
- UChar *p;
- int val = 0;
-
- p = x->s;
- while (p < x->end) {
- val = val * 997 + (int )*p++;
- }
-
- return val + (val >> 5);
-}
-
-extern hash_table_type*
-onig_st_init_strend_table_with_size(int size)
-{
- static const struct st_hash_type hashType = {
- str_end_cmp,
- str_end_hash,
- };
-
- return (hash_table_type* )
- onig_st_init_table_with_size(&hashType, size);
-}
-
-extern int
-onig_st_lookup_strend(hash_table_type* table, const UChar* str_key,
- const UChar* end_key, hash_data_type *value)
-{
- st_strend_key key;
-
- key.s = (UChar* )str_key;
- key.end = (UChar* )end_key;
-
- return onig_st_lookup(table, (st_data_t )(&key), value);
-}
-
-extern int
-onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
- const UChar* end_key, hash_data_type value)
-{
- st_strend_key* key;
- int result;
-
- key = (st_strend_key* )xmalloc(sizeof(st_strend_key));
- key->s = (UChar* )str_key;
- key->end = (UChar* )end_key;
- result = onig_st_insert(table, (st_data_t )key, value);
- if (result) {
- xfree(key);
- }
- return result;
-}
-
-
-typedef st_table NameTable;
-typedef st_data_t HashDataType; /* 1.6 st.h doesn't define st_data_t type */
-
-#define NAMEBUF_SIZE 24
-#define NAMEBUF_SIZE_1 25
-
-#ifdef ONIG_DEBUG
-static int
-i_print_name_entry(UChar* key, NameEntry* e, void* arg)
-{
- int i;
- FILE* fp = (FILE* )arg;
-
- fprintf(fp, "%s: ", e->name);
- if (e->back_num == 0)
- fputs("-", fp);
- else if (e->back_num == 1)
- fprintf(fp, "%d", e->back_ref1);
- else {
- for (i = 0; i < e->back_num; i++) {
- if (i > 0) fprintf(fp, ", ");
- fprintf(fp, "%d", e->back_refs[i]);
- }
- }
- fputs("\n", fp);
- return ST_CONTINUE;
-}
-
-extern int
-onig_print_names(FILE* fp, regex_t* reg)
-{
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t)) {
- fprintf(fp, "name table\n");
- onig_st_foreach(t, i_print_name_entry, (HashDataType )fp);
- fputs("\n", fp);
- }
- return 0;
-}
-#endif
-
-static int
-i_free_name_entry(UChar* key, NameEntry* e, void* arg)
-{
- xfree(e->name);
- if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
- xfree(key);
- xfree(e);
- return ST_DELETE;
-}
-
-static int
-names_clear(regex_t* reg)
-{
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, i_free_name_entry, 0);
- }
- return 0;
-}
-
-extern int
-onig_names_free(regex_t* reg)
-{
- int r;
- NameTable* t;
-
- r = names_clear(reg);
- if (r) return r;
-
- t = (NameTable* )reg->name_table;
- if (IS_NOT_NULL(t)) onig_st_free_table(t);
- reg->name_table = (void* )NULL;
- return 0;
-}
-
-static NameEntry*
-name_find(regex_t* reg, const UChar* name, const UChar* name_end)
-{
- NameEntry* e;
- NameTable* t = (NameTable* )reg->name_table;
-
- e = (NameEntry* )NULL;
- if (IS_NOT_NULL(t)) {
- onig_st_lookup_strend(t, name, name_end, (HashDataType* )((void* )(&e)));
- }
- return e;
-}
-
-typedef struct {
- int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*);
- regex_t* reg;
- void* arg;
- int ret;
- OnigEncoding enc;
-} INamesArg;
-
-static int
-i_names(UChar* key, NameEntry* e, INamesArg* arg)
-{
- int r = (*(arg->func))(e->name,
- e->name + e->name_len,
- e->back_num,
- (e->back_num > 1 ? e->back_refs : &(e->back_ref1)),
- arg->reg, arg->arg);
- if (r != 0) {
- arg->ret = r;
- return ST_STOP;
- }
- return ST_CONTINUE;
-}
-
-extern int
-onig_foreach_name(regex_t* reg,
- int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg)
-{
- INamesArg narg;
- NameTable* t = (NameTable* )reg->name_table;
-
- narg.ret = 0;
- if (IS_NOT_NULL(t)) {
- narg.func = func;
- narg.reg = reg;
- narg.arg = arg;
- narg.enc = reg->enc; /* should be pattern encoding. */
- onig_st_foreach(t, i_names, (HashDataType )&narg);
- }
- return narg.ret;
-}
-
-static int
-i_renumber_name(UChar* key, NameEntry* e, GroupNumRemap* map)
-{
- int i;
-
- if (e->back_num > 1) {
- for (i = 0; i < e->back_num; i++) {
- e->back_refs[i] = map[e->back_refs[i]].new_val;
- }
- }
- else if (e->back_num == 1) {
- e->back_ref1 = map[e->back_ref1].new_val;
- }
-
- return ST_CONTINUE;
-}
-
-extern int
-onig_renumber_name_table(regex_t* reg, GroupNumRemap* map)
-{
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, i_renumber_name, (HashDataType )map);
- }
- return 0;
-}
-
-
-extern int
-onig_number_of_names(regex_t* reg)
-{
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t))
- return t->num_entries;
- else
- return 0;
-}
-
-#else /* USE_ST_LIBRARY */
-
-#define INIT_NAMES_ALLOC_NUM 8
-
-typedef struct {
- NameEntry* e;
- int num;
- int alloc;
-} NameTable;
-
-#ifdef ONIG_DEBUG
-extern int
-onig_print_names(FILE* fp, regex_t* reg)
-{
- int i, j;
- NameEntry* e;
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t) && t->num > 0) {
- fprintf(fp, "name table\n");
- for (i = 0; i < t->num; i++) {
- e = &(t->e[i]);
- fprintf(fp, "%s: ", e->name);
- if (e->back_num == 0) {
- fputs("-", fp);
- }
- else if (e->back_num == 1) {
- fprintf(fp, "%d", e->back_ref1);
- }
- else {
- for (j = 0; j < e->back_num; j++) {
- if (j > 0) fprintf(fp, ", ");
- fprintf(fp, "%d", e->back_refs[j]);
- }
- }
- fputs("\n", fp);
- }
- fputs("\n", fp);
- }
- return 0;
-}
-#endif
-
-static int
-names_clear(regex_t* reg)
-{
- int i;
- NameEntry* e;
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t)) {
- for (i = 0; i < t->num; i++) {
- e = &(t->e[i]);
- if (IS_NOT_NULL(e->name)) {
- xfree(e->name);
- e->name = NULL;
- e->name_len = 0;
- e->back_num = 0;
- e->back_alloc = 0;
- if (IS_NOT_NULL(e->back_refs)) xfree(e->back_refs);
- e->back_refs = (int* )NULL;
- }
- }
- if (IS_NOT_NULL(t->e)) {
- xfree(t->e);
- t->e = NULL;
- }
- t->num = 0;
- }
- return 0;
-}
-
-extern int
-onig_names_free(regex_t* reg)
-{
- int r;
- NameTable* t;
-
- r = names_clear(reg);
- if (r) return r;
-
- t = (NameTable* )reg->name_table;
- if (IS_NOT_NULL(t)) xfree(t);
- reg->name_table = NULL;
- return 0;
-}
-
-static NameEntry*
-name_find(regex_t* reg, UChar* name, UChar* name_end)
-{
- int i, len;
- NameEntry* e;
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t)) {
- len = name_end - name;
- for (i = 0; i < t->num; i++) {
- e = &(t->e[i]);
- if (len == e->name_len && onig_strncmp(name, e->name, len) == 0)
- return e;
- }
- }
- return (NameEntry* )NULL;
-}
-
-extern int
-onig_foreach_name(regex_t* reg,
- int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg)
-{
- int i, r;
- NameEntry* e;
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t)) {
- for (i = 0; i < t->num; i++) {
- e = &(t->e[i]);
- r = (*func)(e->name, e->name + e->name_len, e->back_num,
- (e->back_num > 1 ? e->back_refs : &(e->back_ref1)),
- reg, arg);
- if (r != 0) return r;
- }
- }
- return 0;
-}
-
-extern int
-onig_number_of_names(regex_t* reg)
-{
- NameTable* t = (NameTable* )reg->name_table;
-
- if (IS_NOT_NULL(t))
- return t->num;
- else
- return 0;
-}
-
-#endif /* else USE_ST_LIBRARY */
-
-static int
-name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env)
-{
- int alloc;
- NameEntry* e;
- NameTable* t = (NameTable* )reg->name_table;
-
- if (name_end - name <= 0)
- return ONIGERR_EMPTY_GROUP_NAME;
-
- e = name_find(reg, name, name_end);
- if (IS_NULL(e)) {
-#ifdef USE_ST_LIBRARY
- if (IS_NULL(t)) {
- t = onig_st_init_strend_table_with_size(5);
- reg->name_table = (void* )t;
- }
- e = (NameEntry* )xmalloc(sizeof(NameEntry));
- CHECK_NULL_RETURN_MEMERR(e);
-
- e->name = strdup_with_null(reg->enc, name, name_end);
- if (IS_NULL(e->name)) return ONIGERR_MEMORY;
- onig_st_insert_strend(t, e->name, (e->name + (name_end - name)),
- (HashDataType )e);
-
- e->name_len = name_end - name;
- e->back_num = 0;
- e->back_alloc = 0;
- e->back_refs = (int* )NULL;
-
-#else
-
- if (IS_NULL(t)) {
- alloc = INIT_NAMES_ALLOC_NUM;
- t = (NameTable* )xmalloc(sizeof(NameTable));
- CHECK_NULL_RETURN_MEMERR(t);
- t->e = NULL;
- t->alloc = 0;
- t->num = 0;
-
- t->e = (NameEntry* )xmalloc(sizeof(NameEntry) * alloc);
- if (IS_NULL(t->e)) {
- xfree(t);
- return ONIGERR_MEMORY;
- }
- t->alloc = alloc;
- reg->name_table = t;
- goto clear;
- }
- else if (t->num == t->alloc) {
- int i;
-
- alloc = t->alloc * 2;
- t->e = (NameEntry* )xrealloc(t->e, sizeof(NameEntry) * alloc);
- CHECK_NULL_RETURN_MEMERR(t->e);
- t->alloc = alloc;
-
- clear:
- for (i = t->num; i < t->alloc; i++) {
- t->e[i].name = NULL;
- t->e[i].name_len = 0;
- t->e[i].back_num = 0;
- t->e[i].back_alloc = 0;
- t->e[i].back_refs = (int* )NULL;
- }
- }
- e = &(t->e[t->num]);
- t->num++;
- e->name = strdup_with_null(reg->enc, name, name_end);
- e->name_len = name_end - name;
-#endif
- }
-
- if (e->back_num >= 1 &&
- ! IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME)) {
- onig_scan_env_set_error_string(env, ONIGERR_MULTIPLEX_DEFINED_NAME,
- name, name_end);
- return ONIGERR_MULTIPLEX_DEFINED_NAME;
- }
-
- e->back_num++;
- if (e->back_num == 1) {
- e->back_ref1 = backref;
- }
- else {
- if (e->back_num == 2) {
- alloc = INIT_NAME_BACKREFS_ALLOC_NUM;
- e->back_refs = (int* )xmalloc(sizeof(int) * alloc);
- CHECK_NULL_RETURN_MEMERR(e->back_refs);
- e->back_alloc = alloc;
- e->back_refs[0] = e->back_ref1;
- e->back_refs[1] = backref;
- }
- else {
- if (e->back_num > e->back_alloc) {
- alloc = e->back_alloc * 2;
- e->back_refs = (int* )xrealloc(e->back_refs, sizeof(int) * alloc);
- CHECK_NULL_RETURN_MEMERR(e->back_refs);
- e->back_alloc = alloc;
- }
- e->back_refs[e->back_num - 1] = backref;
- }
- }
-
- return 0;
-}
-
-extern int
-onig_name_to_group_numbers(regex_t* reg, const UChar* name,
- const UChar* name_end, int** nums)
-{
- NameEntry* e = name_find(reg, name, name_end);
-
- if (IS_NULL(e)) return ONIGERR_UNDEFINED_NAME_REFERENCE;
-
- switch (e->back_num) {
- case 0:
- break;
- case 1:
- *nums = &(e->back_ref1);
- break;
- default:
- *nums = e->back_refs;
- break;
- }
- return e->back_num;
-}
-
-extern int
-onig_name_to_backref_number(regex_t* reg, const UChar* name,
- const UChar* name_end, OnigRegion *region)
-{
- int i, n, *nums;
-
- n = onig_name_to_group_numbers(reg, name, name_end, &nums);
- if (n < 0)
- return n;
- else if (n == 0)
- return ONIGERR_PARSER_BUG;
- else if (n == 1)
- return nums[0];
- else {
- if (IS_NOT_NULL(region)) {
- for (i = n - 1; i >= 0; i--) {
- if (region->beg[nums[i]] != ONIG_REGION_NOTPOS)
- return nums[i];
- }
- }
- return nums[n - 1];
- }
-}
-
-#else /* USE_NAMED_GROUP */
-
-extern int
-onig_name_to_group_numbers(regex_t* reg, const UChar* name,
- const UChar* name_end, int** nums)
-{
- return ONIG_NO_SUPPORT_CONFIG;
-}
-
-extern int
-onig_name_to_backref_number(regex_t* reg, const UChar* name,
- const UChar* name_end, OnigRegion* region)
-{
- return ONIG_NO_SUPPORT_CONFIG;
-}
-
-extern int
-onig_foreach_name(regex_t* reg,
- int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg)
-{
- return ONIG_NO_SUPPORT_CONFIG;
-}
-
-extern int
-onig_number_of_names(regex_t* reg)
-{
- return 0;
-}
-#endif /* else USE_NAMED_GROUP */
-
-extern int
-onig_noname_group_capture_is_active(regex_t* reg)
-{
- if (ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_DONT_CAPTURE_GROUP))
- return 0;
-
-#ifdef USE_NAMED_GROUP
- if (onig_number_of_names(reg) > 0 &&
- IS_SYNTAX_BV(reg->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
- !ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_CAPTURE_GROUP)) {
- return 0;
- }
-#endif
-
- return 1;
-}
-
-
-#define INIT_SCANENV_MEMNODES_ALLOC_SIZE 16
-
-static void
-scan_env_clear(ScanEnv* env)
-{
- int i;
-
- BIT_STATUS_CLEAR(env->capture_history);
- BIT_STATUS_CLEAR(env->bt_mem_start);
- BIT_STATUS_CLEAR(env->bt_mem_end);
- BIT_STATUS_CLEAR(env->backrefed_mem);
- env->error = (UChar* )NULL;
- env->error_end = (UChar* )NULL;
- env->num_call = 0;
- env->num_mem = 0;
-#ifdef USE_NAMED_GROUP
- env->num_named = 0;
-#endif
- env->mem_alloc = 0;
- env->mem_nodes_dynamic = (Node** )NULL;
-
- for (i = 0; i < SCANENV_MEMNODES_SIZE; i++)
- env->mem_nodes_static[i] = NULL_NODE;
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- env->num_comb_exp_check = 0;
- env->comb_exp_max_regnum = 0;
- env->curr_max_regnum = 0;
- env->has_recursion = 0;
-#endif
-}
-
-static int
-scan_env_add_mem_entry(ScanEnv* env)
-{
- int i, need, alloc;
- Node** p;
-
- need = env->num_mem + 1;
- if (need >= SCANENV_MEMNODES_SIZE) {
- if (env->mem_alloc <= need) {
- if (IS_NULL(env->mem_nodes_dynamic)) {
- alloc = INIT_SCANENV_MEMNODES_ALLOC_SIZE;
- p = (Node** )xmalloc(sizeof(Node*) * alloc);
- xmemcpy(p, env->mem_nodes_static,
- sizeof(Node*) * SCANENV_MEMNODES_SIZE);
- }
- else {
- alloc = env->mem_alloc * 2;
- p = (Node** )xrealloc(env->mem_nodes_dynamic, sizeof(Node*) * alloc);
- }
- CHECK_NULL_RETURN_MEMERR(p);
-
- for (i = env->num_mem + 1; i < alloc; i++)
- p[i] = NULL_NODE;
-
- env->mem_nodes_dynamic = p;
- env->mem_alloc = alloc;
- }
- }
-
- env->num_mem++;
- return env->num_mem;
-}
-
-static int
-scan_env_set_mem_node(ScanEnv* env, int num, Node* node)
-{
- if (env->num_mem >= num)
- SCANENV_MEM_NODES(env)[num] = node;
- else
- return ONIGERR_PARSER_BUG;
- return 0;
-}
-
-
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
-typedef struct _FreeNode {
- struct _FreeNode* next;
-} FreeNode;
-
-static FreeNode* FreeNodeList = (FreeNode* )NULL;
-#endif
-
-extern void
-onig_node_free(Node* node)
-{
- start:
- if (IS_NULL(node)) return ;
-
- switch (NTYPE(node)) {
- case NT_STR:
- if (NSTR(node)->capa != 0 &&
- IS_NOT_NULL(NSTR(node)->s) && NSTR(node)->s != NSTR(node)->buf) {
- xfree(NSTR(node)->s);
- }
- break;
-
- case NT_LIST:
- case NT_ALT:
- onig_node_free(NCAR(node));
- {
- Node* next_node = NCDR(node);
-
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
- {
- FreeNode* n = (FreeNode* )node;
-
- THREAD_ATOMIC_START;
- n->next = FreeNodeList;
- FreeNodeList = n;
- THREAD_ATOMIC_END;
- }
-#else
- xfree(node);
-#endif
- node = next_node;
- goto start;
- }
- break;
-
- case NT_CCLASS:
- {
- CClassNode* cc = NCCLASS(node);
-
- if (IS_NCCLASS_SHARE(cc)) return ;
- if (cc->mbuf)
- bbuf_free(cc->mbuf);
- }
- break;
-
- case NT_QTFR:
- if (NQTFR(node)->target)
- onig_node_free(NQTFR(node)->target);
- break;
-
- case NT_ENCLOSE:
- if (NENCLOSE(node)->target)
- onig_node_free(NENCLOSE(node)->target);
- break;
-
- case NT_BREF:
- if (IS_NOT_NULL(NBREF(node)->back_dynamic))
- xfree(NBREF(node)->back_dynamic);
- break;
-
- case NT_ANCHOR:
- if (NANCHOR(node)->target)
- onig_node_free(NANCHOR(node)->target);
- break;
- }
-
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
- {
- FreeNode* n = (FreeNode* )node;
-
- THREAD_ATOMIC_START;
- n->next = FreeNodeList;
- FreeNodeList = n;
- THREAD_ATOMIC_END;
- }
-#else
- xfree(node);
-#endif
-}
-
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
-extern int
-onig_free_node_list(void)
-{
- FreeNode* n;
-
- /* THREAD_ATOMIC_START; */
- while (IS_NOT_NULL(FreeNodeList)) {
- n = FreeNodeList;
- FreeNodeList = FreeNodeList->next;
- xfree(n);
- }
- /* THREAD_ATOMIC_END; */
- return 0;
-}
-#endif
-
-static Node*
-node_new(void)
-{
- Node* node;
-
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
- THREAD_ATOMIC_START;
- if (IS_NOT_NULL(FreeNodeList)) {
- node = (Node* )FreeNodeList;
- FreeNodeList = FreeNodeList->next;
- THREAD_ATOMIC_END;
- return node;
- }
- THREAD_ATOMIC_END;
-#endif
-
- node = (Node* )xmalloc(sizeof(Node));
- /* xmemset(node, 0, sizeof(Node)); */
- return node;
-}
-
-
-static void
-initialize_cclass(CClassNode* cc)
-{
- BITSET_CLEAR(cc->bs);
- /* cc->base.flags = 0; */
- cc->flags = 0;
- cc->mbuf = NULL;
-}
-
-static Node*
-node_new_cclass(void)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_CCLASS);
- initialize_cclass(NCCLASS(node));
- return node;
-}
-
-static Node*
-node_new_cclass_by_codepoint_range(int not, OnigCodePoint sb_out,
- const OnigCodePoint ranges[])
-{
- int n, i;
- CClassNode* cc;
- OnigCodePoint j;
-
- Node* node = node_new_cclass();
- CHECK_NULL_RETURN(node);
-
- cc = NCCLASS(node);
- if (not != 0) NCCLASS_SET_NOT(cc);
-
- BITSET_CLEAR(cc->bs);
- if (sb_out > 0 && IS_NOT_NULL(ranges)) {
- n = ONIGENC_CODE_RANGE_NUM(ranges);
- for (i = 0; i < n; i++) {
- for (j = ONIGENC_CODE_RANGE_FROM(ranges, i);
- j <= (int )ONIGENC_CODE_RANGE_TO(ranges, i); j++) {
- if (j >= sb_out) goto sb_end;
-
- BITSET_SET_BIT(cc->bs, j);
- }
- }
- }
-
- sb_end:
- if (IS_NULL(ranges)) {
- is_null:
- cc->mbuf = NULL;
- }
- else {
- BBuf* bbuf;
-
- n = ONIGENC_CODE_RANGE_NUM(ranges);
- if (n == 0) goto is_null;
-
- bbuf = (BBuf* )xmalloc(sizeof(BBuf));
- CHECK_NULL_RETURN(bbuf);
- bbuf->alloc = n + 1;
- bbuf->used = n + 1;
- bbuf->p = (UChar* )((void* )ranges);
-
- cc->mbuf = bbuf;
- }
-
- return node;
-}
-
-static Node*
-node_new_ctype(int type, int not)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_CTYPE);
- NCTYPE(node)->ctype = type;
- NCTYPE(node)->not = not;
- return node;
-}
-
-static Node*
-node_new_anychar(void)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_CANY);
- return node;
-}
-
-static Node*
-node_new_list(Node* left, Node* right)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_LIST);
- NCAR(node) = left;
- NCDR(node) = right;
- return node;
-}
-
-extern Node*
-onig_node_new_list(Node* left, Node* right)
-{
- return node_new_list(left, right);
-}
-
-extern Node*
-onig_node_list_add(Node* list, Node* x)
-{
- Node *n;
-
- n = onig_node_new_list(x, NULL);
- if (IS_NULL(n)) return NULL_NODE;
-
- if (IS_NOT_NULL(list)) {
- while (IS_NOT_NULL(NCDR(list)))
- list = NCDR(list);
-
- NCDR(list) = n;
- }
-
- return n;
-}
-
-extern Node*
-onig_node_new_alt(Node* left, Node* right)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_ALT);
- NCAR(node) = left;
- NCDR(node) = right;
- return node;
-}
-
-extern Node*
-onig_node_new_anchor(int type)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_ANCHOR);
- NANCHOR(node)->type = type;
- NANCHOR(node)->target = NULL;
- NANCHOR(node)->char_len = -1;
- return node;
-}
-
-static Node*
-node_new_backref(int back_num, int* backrefs, int by_name,
-#ifdef USE_BACKREF_AT_LEVEL
- int exist_level, int nest_level,
-#endif
- ScanEnv* env)
-{
- int i;
- Node* node = node_new();
-
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_BREF);
- NBREF(node)->state = 0;
- NBREF(node)->back_num = back_num;
- NBREF(node)->back_dynamic = (int* )NULL;
- if (by_name != 0)
- NBREF(node)->state |= NST_NAME_REF;
-
-#ifdef USE_BACKREF_AT_LEVEL
- if (exist_level != 0) {
- NBREF(node)->state |= NST_NEST_LEVEL;
- NBREF(node)->nest_level = nest_level;
- }
-#endif
-
- for (i = 0; i < back_num; i++) {
- if (backrefs[i] <= env->num_mem &&
- IS_NULL(SCANENV_MEM_NODES(env)[backrefs[i]])) {
- NBREF(node)->state |= NST_RECURSION; /* /...(\1).../ */
- break;
- }
- }
-
- if (back_num <= NODE_BACKREFS_SIZE) {
- for (i = 0; i < back_num; i++)
- NBREF(node)->back_static[i] = backrefs[i];
- }
- else {
- int* p = (int* )xmalloc(sizeof(int) * back_num);
- if (IS_NULL(p)) {
- onig_node_free(node);
- return NULL;
- }
- NBREF(node)->back_dynamic = p;
- for (i = 0; i < back_num; i++)
- p[i] = backrefs[i];
- }
- return node;
-}
-
-#ifdef USE_SUBEXP_CALL
-static Node*
-node_new_call(UChar* name, UChar* name_end)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_CALL);
- NCALL(node)->state = 0;
- NCALL(node)->ref_num = CALLNODE_REFNUM_UNDEF;
- NCALL(node)->target = NULL_NODE;
- NCALL(node)->name = name;
- NCALL(node)->name_end = name_end;
- return node;
-}
-#endif
-
-static Node*
-node_new_quantifier(int lower, int upper, int by_number)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_QTFR);
- NQTFR(node)->state = 0;
- NQTFR(node)->target = NULL;
- NQTFR(node)->lower = lower;
- NQTFR(node)->upper = upper;
- NQTFR(node)->greedy = 1;
- NQTFR(node)->target_empty_info = NQ_TARGET_ISNOT_EMPTY;
- NQTFR(node)->head_exact = NULL_NODE;
- NQTFR(node)->next_head_exact = NULL_NODE;
- NQTFR(node)->is_refered = 0;
- if (by_number != 0)
- NQTFR(node)->state |= NST_BY_NUMBER;
-
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- NQTFR(node)->comb_exp_check_num = 0;
-#endif
-
- return node;
-}
-
-static Node*
-node_new_enclose(int type)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_ENCLOSE);
- NENCLOSE(node)->type = type;
- NENCLOSE(node)->state = 0;
- NENCLOSE(node)->regnum = 0;
- NENCLOSE(node)->option = 0;
- NENCLOSE(node)->target = NULL;
- NENCLOSE(node)->call_addr = -1;
- NENCLOSE(node)->opt_count = 0;
- return node;
-}
-
-extern Node*
-onig_node_new_enclose(int type)
-{
- return node_new_enclose(type);
-}
-
-static Node*
-node_new_enclose_memory(OnigOptionType option, int is_named)
-{
- Node* node = node_new_enclose(ENCLOSE_MEMORY);
- CHECK_NULL_RETURN(node);
- if (is_named != 0)
- SET_ENCLOSE_STATUS(node, NST_NAMED_GROUP);
-
-#ifdef USE_SUBEXP_CALL
- NENCLOSE(node)->option = option;
-#endif
- return node;
-}
-
-static Node*
-node_new_option(OnigOptionType option)
-{
- Node* node = node_new_enclose(ENCLOSE_OPTION);
- CHECK_NULL_RETURN(node);
- NENCLOSE(node)->option = option;
- return node;
-}
-
-extern int
-onig_node_str_cat(Node* node, const UChar* s, const UChar* end)
-{
- int addlen = end - s;
-
- if (addlen > 0) {
- int len = NSTR(node)->end - NSTR(node)->s;
-
- if (NSTR(node)->capa > 0 || (len + addlen > NODE_STR_BUF_SIZE - 1)) {
- UChar* p;
- int capa = len + addlen + NODE_STR_MARGIN;
-
- if (capa <= NSTR(node)->capa) {
- onig_strcpy(NSTR(node)->s + len, s, end);
- }
- else {
- if (NSTR(node)->s == NSTR(node)->buf)
- p = strcat_capa_from_static(NSTR(node)->s, NSTR(node)->end,
- s, end, capa);
- else
- p = strcat_capa(NSTR(node)->s, NSTR(node)->end, s, end, capa);
-
- CHECK_NULL_RETURN_MEMERR(p);
- NSTR(node)->s = p;
- NSTR(node)->capa = capa;
- }
- }
- else {
- onig_strcpy(NSTR(node)->s + len, s, end);
- }
- NSTR(node)->end = NSTR(node)->s + len + addlen;
- }
-
- return 0;
-}
-
-extern int
-onig_node_str_set(Node* node, const UChar* s, const UChar* end)
-{
- onig_node_str_clear(node);
- return onig_node_str_cat(node, s, end);
-}
-
-static int
-node_str_cat_char(Node* node, UChar c)
-{
- UChar s[1];
-
- s[0] = c;
- return onig_node_str_cat(node, s, s + 1);
-}
-
-extern void
-onig_node_conv_to_str_node(Node* node, int flag)
-{
- SET_NTYPE(node, NT_STR);
- NSTR(node)->flag = flag;
- NSTR(node)->capa = 0;
- NSTR(node)->s = NSTR(node)->buf;
- NSTR(node)->end = NSTR(node)->buf;
-}
-
-extern void
-onig_node_str_clear(Node* node)
-{
- if (NSTR(node)->capa != 0 &&
- IS_NOT_NULL(NSTR(node)->s) && NSTR(node)->s != NSTR(node)->buf) {
- xfree(NSTR(node)->s);
- }
-
- NSTR(node)->capa = 0;
- NSTR(node)->flag = 0;
- NSTR(node)->s = NSTR(node)->buf;
- NSTR(node)->end = NSTR(node)->buf;
-}
-
-static Node*
-node_new_str(const UChar* s, const UChar* end)
-{
- Node* node = node_new();
- CHECK_NULL_RETURN(node);
-
- SET_NTYPE(node, NT_STR);
- NSTR(node)->capa = 0;
- NSTR(node)->flag = 0;
- NSTR(node)->s = NSTR(node)->buf;
- NSTR(node)->end = NSTR(node)->buf;
- if (onig_node_str_cat(node, s, end)) {
- onig_node_free(node);
- return NULL;
- }
- return node;
-}
-
-extern Node*
-onig_node_new_str(const UChar* s, const UChar* end)
-{
- return node_new_str(s, end);
-}
-
-static Node*
-node_new_str_raw(UChar* s, UChar* end)
-{
- Node* node = node_new_str(s, end);
- NSTRING_SET_RAW(node);
- return node;
-}
-
-static Node*
-node_new_empty(void)
-{
- return node_new_str(NULL, NULL);
-}
-
-static Node*
-node_new_str_raw_char(UChar c)
-{
- UChar p[1];
-
- p[0] = c;
- return node_new_str_raw(p, p + 1);
-}
-
-static Node*
-str_node_split_last_char(StrNode* sn, OnigEncoding enc)
-{
- const UChar *p;
- Node* n = NULL_NODE;
-
- if (sn->end > sn->s) {
- p = onigenc_get_prev_char_head(enc, sn->s, sn->end);
- if (p && p > sn->s) { /* can be splitted. */
- n = node_new_str(p, sn->end);
- if ((sn->flag & NSTR_RAW) != 0)
- NSTRING_SET_RAW(n);
- sn->end = (UChar* )p;
- }
- }
- return n;
-}
-
-static int
-str_node_can_be_split(StrNode* sn, OnigEncoding enc)
-{
- if (sn->end > sn->s) {
- return ((enc_len(enc, sn->s, sn->end) < sn->end - sn->s) ? 1 : 0);
- }
- return 0;
-}
-
-#ifdef USE_PAD_TO_SHORT_BYTE_CHAR
-static int
-node_str_head_pad(StrNode* sn, int num, UChar val)
-{
- UChar buf[NODE_STR_BUF_SIZE];
- int i, len;
-
- len = sn->end - sn->s;
- onig_strcpy(buf, sn->s, sn->end);
- onig_strcpy(&(sn->s[num]), buf, buf + len);
- sn->end += num;
-
- for (i = 0; i < num; i++) {
- sn->s[i] = val;
- }
-}
-#endif
-
-extern int
-onig_scan_unsigned_number(UChar** src, const UChar* end, OnigEncoding enc)
-{
- unsigned int num, val;
- OnigCodePoint c;
- UChar* p = *src;
- PFETCH_READY;
-
- num = 0;
- while (!PEND) {
- PFETCH(c);
- if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
- val = (unsigned int )DIGITVAL(c);
- if ((INT_MAX_LIMIT - val) / 10UL < num)
- return -1; /* overflow */
-
- num = num * 10 + val;
- }
- else {
- PUNFETCH;
- break;
- }
- }
- *src = p;
- return num;
-}
-
-static int
-scan_unsigned_hexadecimal_number(UChar** src, UChar* end, int maxlen,
- OnigEncoding enc)
-{
- OnigCodePoint c;
- unsigned int num, val;
- UChar* p = *src;
- PFETCH_READY;
-
- num = 0;
- while (!PEND && maxlen-- != 0) {
- PFETCH(c);
- if (ONIGENC_IS_CODE_XDIGIT(enc, c)) {
- val = (unsigned int )XDIGITVAL(enc,c);
- if ((INT_MAX_LIMIT - val) / 16UL < num)
- return -1; /* overflow */
-
- num = (num << 4) + XDIGITVAL(enc,c);
- }
- else {
- PUNFETCH;
- break;
- }
- }
- *src = p;
- return num;
-}
-
-static int
-scan_unsigned_octal_number(UChar** src, UChar* end, int maxlen,
- OnigEncoding enc)
-{
- OnigCodePoint c;
- unsigned int num, val;
- UChar* p = *src;
- PFETCH_READY;
-
- num = 0;
- while (!PEND && maxlen-- != 0) {
- PFETCH(c);
- if (ONIGENC_IS_CODE_DIGIT(enc, c) && c < '8') {
- val = ODIGITVAL(c);
- if ((INT_MAX_LIMIT - val) / 8UL < num)
- return -1; /* overflow */
-
- num = (num << 3) + val;
- }
- else {
- PUNFETCH;
- break;
- }
- }
- *src = p;
- return num;
-}
-
-
-#define BBUF_WRITE_CODE_POINT(bbuf,pos,code) \
- BBUF_WRITE(bbuf, pos, &(code), SIZE_CODE_POINT)
-
-/* data format:
- [n][from-1][to-1][from-2][to-2] ... [from-n][to-n]
- (all data size is OnigCodePoint)
- */
-static int
-new_code_range(BBuf** pbuf)
-{
-#define INIT_MULTI_BYTE_RANGE_SIZE (SIZE_CODE_POINT * 5)
- int r;
- OnigCodePoint n;
- BBuf* bbuf;
-
- bbuf = *pbuf = (BBuf* )xmalloc(sizeof(BBuf));
- CHECK_NULL_RETURN_MEMERR(*pbuf);
- r = BBUF_INIT(*pbuf, INIT_MULTI_BYTE_RANGE_SIZE);
- if (r) return r;
-
- n = 0;
- BBUF_WRITE_CODE_POINT(bbuf, 0, n);
- return 0;
-}
-
-static int
-add_code_range_to_buf(BBuf** pbuf, OnigCodePoint from, OnigCodePoint to)
-{
- int r, inc_n, pos;
- int low, high, bound, x;
- OnigCodePoint n, *data;
- BBuf* bbuf;
-
- if (from > to) {
- n = from; from = to; to = n;
- }
-
- if (IS_NULL(*pbuf)) {
- r = new_code_range(pbuf);
- if (r) return r;
- bbuf = *pbuf;
- n = 0;
- }
- else {
- bbuf = *pbuf;
- GET_CODE_POINT(n, bbuf->p);
- }
- data = (OnigCodePoint* )(bbuf->p);
- data++;
-
- for (low = 0, bound = n; low < bound; ) {
- x = (low + bound) >> 1;
- if (from > data[x*2 + 1])
- low = x + 1;
- else
- bound = x;
- }
-
- for (high = low, bound = n; high < bound; ) {
- x = (high + bound) >> 1;
- if (to >= data[x*2] - 1)
- high = x + 1;
- else
- bound = x;
- }
-
- inc_n = low + 1 - high;
- if (n + inc_n > ONIG_MAX_MULTI_BYTE_RANGES_NUM)
- return ONIGERR_TOO_MANY_MULTI_BYTE_RANGES;
-
- if (inc_n != 1) {
- if (from > data[low*2])
- from = data[low*2];
- if (to < data[(high - 1)*2 + 1])
- to = data[(high - 1)*2 + 1];
- }
-
- if (inc_n != 0 && (OnigCodePoint )high < n) {
- int from_pos = SIZE_CODE_POINT * (1 + high * 2);
- int to_pos = SIZE_CODE_POINT * (1 + (low + 1) * 2);
- int size = (n - high) * 2 * SIZE_CODE_POINT;
-
- if (inc_n > 0) {
- BBUF_MOVE_RIGHT(bbuf, from_pos, to_pos, size);
- }
- else {
- BBUF_MOVE_LEFT_REDUCE(bbuf, from_pos, to_pos);
- }
- }
-
- pos = SIZE_CODE_POINT * (1 + low * 2);
- BBUF_ENSURE_SIZE(bbuf, pos + SIZE_CODE_POINT * 2);
- BBUF_WRITE_CODE_POINT(bbuf, pos, from);
- BBUF_WRITE_CODE_POINT(bbuf, pos + SIZE_CODE_POINT, to);
- n += inc_n;
- BBUF_WRITE_CODE_POINT(bbuf, 0, n);
-
- return 0;
-}
-
-static int
-add_code_range(BBuf** pbuf, ScanEnv* env, OnigCodePoint from, OnigCodePoint to)
-{
- if (from > to) {
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC))
- return 0;
- else
- return ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS;
- }
-
- return add_code_range_to_buf(pbuf, from, to);
-}
-
-static int
-not_code_range_buf(OnigEncoding enc, BBuf* bbuf, BBuf** pbuf)
-{
- int r, i, n;
- OnigCodePoint pre, from, *data, to = 0;
-
- *pbuf = (BBuf* )NULL;
- if (IS_NULL(bbuf)) {
- set_all:
- return SET_ALL_MULTI_BYTE_RANGE(enc, pbuf);
- }
-
- data = (OnigCodePoint* )(bbuf->p);
- GET_CODE_POINT(n, data);
- data++;
- if (n <= 0) goto set_all;
-
- r = 0;
- pre = MBCODE_START_POS(enc);
- for (i = 0; i < n; i++) {
- from = data[i*2];
- to = data[i*2+1];
- if (pre <= from - 1) {
- r = add_code_range_to_buf(pbuf, pre, from - 1);
- if (r != 0) return r;
- }
- if (to == ~((OnigCodePoint )0)) break;
- pre = to + 1;
- }
- if (to < ~((OnigCodePoint )0)) {
- r = add_code_range_to_buf(pbuf, to + 1, ~((OnigCodePoint )0));
- }
- return r;
-}
-
-#define SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2) do {\
- BBuf *tbuf; \
- int tnot; \
- tnot = not1; not1 = not2; not2 = tnot; \
- tbuf = bbuf1; bbuf1 = bbuf2; bbuf2 = tbuf; \
-} while (0)
-
-static int
-or_code_range_buf(OnigEncoding enc, BBuf* bbuf1, int not1,
- BBuf* bbuf2, int not2, BBuf** pbuf)
-{
- int r;
- OnigCodePoint i, n1, *data1;
- OnigCodePoint from, to;
-
- *pbuf = (BBuf* )NULL;
- if (IS_NULL(bbuf1) && IS_NULL(bbuf2)) {
- if (not1 != 0 || not2 != 0)
- return SET_ALL_MULTI_BYTE_RANGE(enc, pbuf);
- return 0;
- }
-
- r = 0;
- if (IS_NULL(bbuf2))
- SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2);
-
- if (IS_NULL(bbuf1)) {
- if (not1 != 0) {
- return SET_ALL_MULTI_BYTE_RANGE(enc, pbuf);
- }
- else {
- if (not2 == 0) {
- return bbuf_clone(pbuf, bbuf2);
- }
- else {
- return not_code_range_buf(enc, bbuf2, pbuf);
- }
- }
- }
-
- if (not1 != 0)
- SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2);
-
- data1 = (OnigCodePoint* )(bbuf1->p);
- GET_CODE_POINT(n1, data1);
- data1++;
-
- if (not2 == 0 && not1 == 0) { /* 1 OR 2 */
- r = bbuf_clone(pbuf, bbuf2);
- }
- else if (not1 == 0) { /* 1 OR (not 2) */
- r = not_code_range_buf(enc, bbuf2, pbuf);
- }
- if (r != 0) return r;
-
- for (i = 0; i < n1; i++) {
- from = data1[i*2];
- to = data1[i*2+1];
- r = add_code_range_to_buf(pbuf, from, to);
- if (r != 0) return r;
- }
- return 0;
-}
-
-static int
-and_code_range1(BBuf** pbuf, OnigCodePoint from1, OnigCodePoint to1,
- OnigCodePoint* data, int n)
-{
- int i, r;
- OnigCodePoint from2, to2;
-
- for (i = 0; i < n; i++) {
- from2 = data[i*2];
- to2 = data[i*2+1];
- if (from2 < from1) {
- if (to2 < from1) continue;
- else {
- from1 = to2 + 1;
- }
- }
- else if (from2 <= to1) {
- if (to2 < to1) {
- if (from1 <= from2 - 1) {
- r = add_code_range_to_buf(pbuf, from1, from2-1);
- if (r != 0) return r;
- }
- from1 = to2 + 1;
- }
- else {
- to1 = from2 - 1;
- }
- }
- else {
- from1 = from2;
- }
- if (from1 > to1) break;
- }
- if (from1 <= to1) {
- r = add_code_range_to_buf(pbuf, from1, to1);
- if (r != 0) return r;
- }
- return 0;
-}
-
-static int
-and_code_range_buf(BBuf* bbuf1, int not1, BBuf* bbuf2, int not2, BBuf** pbuf)
-{
- int r;
- OnigCodePoint i, j, n1, n2, *data1, *data2;
- OnigCodePoint from, to, from1, to1, from2, to2;
-
- *pbuf = (BBuf* )NULL;
- if (IS_NULL(bbuf1)) {
- if (not1 != 0 && IS_NOT_NULL(bbuf2)) /* not1 != 0 -> not2 == 0 */
- return bbuf_clone(pbuf, bbuf2);
- return 0;
- }
- else if (IS_NULL(bbuf2)) {
- if (not2 != 0)
- return bbuf_clone(pbuf, bbuf1);
- return 0;
- }
-
- if (not1 != 0)
- SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2);
-
- data1 = (OnigCodePoint* )(bbuf1->p);
- data2 = (OnigCodePoint* )(bbuf2->p);
- GET_CODE_POINT(n1, data1);
- GET_CODE_POINT(n2, data2);
- data1++;
- data2++;
-
- if (not2 == 0 && not1 == 0) { /* 1 AND 2 */
- for (i = 0; i < n1; i++) {
- from1 = data1[i*2];
- to1 = data1[i*2+1];
- for (j = 0; j < n2; j++) {
- from2 = data2[j*2];
- to2 = data2[j*2+1];
- if (from2 > to1) break;
- if (to2 < from1) continue;
- from = MAX(from1, from2);
- to = MIN(to1, to2);
- r = add_code_range_to_buf(pbuf, from, to);
- if (r != 0) return r;
- }
- }
- }
- else if (not1 == 0) { /* 1 AND (not 2) */
- for (i = 0; i < n1; i++) {
- from1 = data1[i*2];
- to1 = data1[i*2+1];
- r = and_code_range1(pbuf, from1, to1, data2, n2);
- if (r != 0) return r;
- }
- }
-
- return 0;
-}
-
-static int
-clear_not_flag_cclass(CClassNode* cc, OnigEncoding enc)
-{
- BBuf *tbuf;
- int r;
-
- if (IS_NCCLASS_NOT(cc)) {
- bitset_invert(cc->bs);
-
- if (! ONIGENC_IS_SINGLEBYTE(enc)) {
- r = not_code_range_buf(enc, cc->mbuf, &tbuf);
- if (r != 0) return r;
-
- bbuf_free(cc->mbuf);
- cc->mbuf = tbuf;
- }
-
- NCCLASS_CLEAR_NOT(cc);
- }
-
- return 0;
-}
-
-static int
-and_cclass(CClassNode* dest, CClassNode* cc, OnigEncoding enc)
-{
- int r, not1, not2;
- BBuf *buf1, *buf2, *pbuf;
- BitSetRef bsr1, bsr2;
- BitSet bs1, bs2;
-
- not1 = IS_NCCLASS_NOT(dest);
- bsr1 = dest->bs;
- buf1 = dest->mbuf;
- not2 = IS_NCCLASS_NOT(cc);
- bsr2 = cc->bs;
- buf2 = cc->mbuf;
-
- if (not1 != 0) {
- bitset_invert_to(bsr1, bs1);
- bsr1 = bs1;
- }
- if (not2 != 0) {
- bitset_invert_to(bsr2, bs2);
- bsr2 = bs2;
- }
- bitset_and(bsr1, bsr2);
- if (bsr1 != dest->bs) {
- bitset_copy(dest->bs, bsr1);
- bsr1 = dest->bs;
- }
- if (not1 != 0) {
- bitset_invert(dest->bs);
- }
-
- if (! ONIGENC_IS_SINGLEBYTE(enc)) {
- if (not1 != 0 && not2 != 0) {
- r = or_code_range_buf(enc, buf1, 0, buf2, 0, &pbuf);
- }
- else {
- r = and_code_range_buf(buf1, not1, buf2, not2, &pbuf);
- if (r == 0 && not1 != 0) {
- BBuf *tbuf;
- r = not_code_range_buf(enc, pbuf, &tbuf);
- if (r != 0) {
- bbuf_free(pbuf);
- return r;
- }
- bbuf_free(pbuf);
- pbuf = tbuf;
- }
- }
- if (r != 0) return r;
-
- dest->mbuf = pbuf;
- bbuf_free(buf1);
- return r;
- }
- return 0;
-}
-
-static int
-or_cclass(CClassNode* dest, CClassNode* cc, OnigEncoding enc)
-{
- int r, not1, not2;
- BBuf *buf1, *buf2, *pbuf;
- BitSetRef bsr1, bsr2;
- BitSet bs1, bs2;
-
- not1 = IS_NCCLASS_NOT(dest);
- bsr1 = dest->bs;
- buf1 = dest->mbuf;
- not2 = IS_NCCLASS_NOT(cc);
- bsr2 = cc->bs;
- buf2 = cc->mbuf;
-
- if (not1 != 0) {
- bitset_invert_to(bsr1, bs1);
- bsr1 = bs1;
- }
- if (not2 != 0) {
- bitset_invert_to(bsr2, bs2);
- bsr2 = bs2;
- }
- bitset_or(bsr1, bsr2);
- if (bsr1 != dest->bs) {
- bitset_copy(dest->bs, bsr1);
- bsr1 = dest->bs;
- }
- if (not1 != 0) {
- bitset_invert(dest->bs);
- }
-
- if (! ONIGENC_IS_SINGLEBYTE(enc)) {
- if (not1 != 0 && not2 != 0) {
- r = and_code_range_buf(buf1, 0, buf2, 0, &pbuf);
- }
- else {
- r = or_code_range_buf(enc, buf1, not1, buf2, not2, &pbuf);
- if (r == 0 && not1 != 0) {
- BBuf *tbuf;
- r = not_code_range_buf(enc, pbuf, &tbuf);
- if (r != 0) {
- bbuf_free(pbuf);
- return r;
- }
- bbuf_free(pbuf);
- pbuf = tbuf;
- }
- }
- if (r != 0) return r;
-
- dest->mbuf = pbuf;
- bbuf_free(buf1);
- return r;
- }
- else
- return 0;
-}
-
-static int
-conv_backslash_value(int c, ScanEnv* env)
-{
- if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_CONTROL_CHARS)) {
- switch (c) {
- case 'n': return '\n';
- case 't': return '\t';
- case 'r': return '\r';
- case 'f': return '\f';
- case 'a': return '\007';
- case 'b': return '\010';
- case 'e': return '\033';
- case 'v':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_V_VTAB))
- return '\v';
- break;
-
- default:
- break;
- }
- }
- return c;
-}
-
-static int
-is_invalid_quantifier_target(Node* node)
-{
- switch (NTYPE(node)) {
- case NT_ANCHOR:
- return 1;
- break;
-
- case NT_ENCLOSE:
- /* allow enclosed elements */
- /* return is_invalid_quantifier_target(NENCLOSE(node)->target); */
- break;
-
- case NT_LIST:
- do {
- if (! is_invalid_quantifier_target(NCAR(node))) return 0;
- } while (IS_NOT_NULL(node = NCDR(node)));
- return 0;
- break;
-
- case NT_ALT:
- do {
- if (is_invalid_quantifier_target(NCAR(node))) return 1;
- } while (IS_NOT_NULL(node = NCDR(node)));
- break;
-
- default:
- break;
- }
- return 0;
-}
-
-/* ?:0, *:1, +:2, ??:3, *?:4, +?:5 */
-static int
-popular_quantifier_num(QtfrNode* q)
-{
- if (q->greedy) {
- if (q->lower == 0) {
- if (q->upper == 1) return 0;
- else if (IS_REPEAT_INFINITE(q->upper)) return 1;
- }
- else if (q->lower == 1) {
- if (IS_REPEAT_INFINITE(q->upper)) return 2;
- }
- }
- else {
- if (q->lower == 0) {
- if (q->upper == 1) return 3;
- else if (IS_REPEAT_INFINITE(q->upper)) return 4;
- }
- else if (q->lower == 1) {
- if (IS_REPEAT_INFINITE(q->upper)) return 5;
- }
- }
- return -1;
-}
-
-
-enum ReduceType {
- RQ_ASIS = 0, /* as is */
- RQ_DEL = 1, /* delete parent */
- RQ_A, /* to '*' */
- RQ_AQ, /* to '*?' */
- RQ_QQ, /* to '??' */
- RQ_P_QQ, /* to '+)??' */
- RQ_PQ_Q /* to '+?)?' */
-};
-
-static enum ReduceType ReduceTypeTable[6][6] = {
- {RQ_DEL, RQ_A, RQ_A, RQ_QQ, RQ_AQ, RQ_ASIS}, /* '?' */
- {RQ_DEL, RQ_DEL, RQ_DEL, RQ_P_QQ, RQ_P_QQ, RQ_DEL}, /* '*' */
- {RQ_A, RQ_A, RQ_DEL, RQ_ASIS, RQ_P_QQ, RQ_DEL}, /* '+' */
- {RQ_DEL, RQ_AQ, RQ_AQ, RQ_DEL, RQ_AQ, RQ_AQ}, /* '??' */
- {RQ_DEL, RQ_DEL, RQ_DEL, RQ_DEL, RQ_DEL, RQ_DEL}, /* '*?' */
- {RQ_ASIS, RQ_PQ_Q, RQ_DEL, RQ_AQ, RQ_AQ, RQ_DEL} /* '+?' */
-};
-
-extern void
-onig_reduce_nested_quantifier(Node* pnode, Node* cnode)
-{
- int pnum, cnum;
- QtfrNode *p, *c;
-
- p = NQTFR(pnode);
- c = NQTFR(cnode);
- pnum = popular_quantifier_num(p);
- cnum = popular_quantifier_num(c);
- if (pnum < 0 || cnum < 0) return ;
-
- switch(ReduceTypeTable[cnum][pnum]) {
- case RQ_DEL:
- *pnode = *cnode;
- break;
- case RQ_A:
- p->target = c->target;
- p->lower = 0; p->upper = REPEAT_INFINITE; p->greedy = 1;
- break;
- case RQ_AQ:
- p->target = c->target;
- p->lower = 0; p->upper = REPEAT_INFINITE; p->greedy = 0;
- break;
- case RQ_QQ:
- p->target = c->target;
- p->lower = 0; p->upper = 1; p->greedy = 0;
- break;
- case RQ_P_QQ:
- p->target = cnode;
- p->lower = 0; p->upper = 1; p->greedy = 0;
- c->lower = 1; c->upper = REPEAT_INFINITE; c->greedy = 1;
- return ;
- break;
- case RQ_PQ_Q:
- p->target = cnode;
- p->lower = 0; p->upper = 1; p->greedy = 1;
- c->lower = 1; c->upper = REPEAT_INFINITE; c->greedy = 0;
- return ;
- break;
- case RQ_ASIS:
- p->target = cnode;
- return ;
- break;
- }
-
- c->target = NULL_NODE;
- onig_node_free(cnode);
-}
-
-
-enum TokenSyms {
- TK_EOT = 0, /* end of token */
- TK_RAW_BYTE = 1,
- TK_CHAR,
- TK_STRING,
- TK_CODE_POINT,
- TK_ANYCHAR,
- TK_CHAR_TYPE,
- TK_BACKREF,
- TK_CALL,
- TK_ANCHOR,
- TK_OP_REPEAT,
- TK_INTERVAL,
- TK_ANYCHAR_ANYTIME, /* SQL '%' == .* */
- TK_ALT,
- TK_SUBEXP_OPEN,
- TK_SUBEXP_CLOSE,
- TK_CC_OPEN,
- TK_QUOTE_OPEN,
- TK_CHAR_PROPERTY, /* \p{...}, \P{...} */
- /* in cc */
- TK_CC_CLOSE,
- TK_CC_RANGE,
- TK_POSIX_BRACKET_OPEN,
- TK_CC_AND, /* && */
- TK_CC_CC_OPEN /* [ */
-};
-
-typedef struct {
- enum TokenSyms type;
- int escaped;
- int base; /* is number: 8, 16 (used in [....]) */
- UChar* backp;
- union {
- UChar* s;
- int c;
- OnigCodePoint code;
- int anchor;
- int subtype;
- struct {
- int lower;
- int upper;
- int greedy;
- int possessive;
- } repeat;
- struct {
- int num;
- int ref1;
- int* refs;
- int by_name;
-#ifdef USE_BACKREF_AT_LEVEL
- int exist_level;
- int level; /* \k<name+n> */
-#endif
- } backref;
- struct {
- UChar* name;
- UChar* name_end;
- } call;
- struct {
- int ctype;
- int not;
- } prop;
- } u;
-} OnigToken;
-
-
-static int
-fetch_range_quantifier(UChar** src, UChar* end, OnigToken* tok, ScanEnv* env)
-{
- int low, up, syn_allow, non_low = 0;
- int r = 0;
- OnigCodePoint c;
- OnigEncoding enc = env->enc;
- UChar* p = *src;
- PFETCH_READY;
-
- syn_allow = IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_INVALID_INTERVAL);
-
- if (PEND) {
- if (syn_allow)
- return 1; /* "....{" : OK! */
- else
- return ONIGERR_END_PATTERN_AT_LEFT_BRACE; /* "....{" syntax error */
- }
-
- if (! syn_allow) {
- c = PPEEK;
- if (c == ')' || c == '(' || c == '|') {
- return ONIGERR_END_PATTERN_AT_LEFT_BRACE;
- }
- }
-
- low = onig_scan_unsigned_number(&p, end, env->enc);
- if (low < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
- if (low > ONIG_MAX_REPEAT_NUM)
- return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
-
- if (p == *src) { /* can't read low */
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV)) {
- /* allow {,n} as {0,n} */
- low = 0;
- non_low = 1;
- }
- else
- goto invalid;
- }
-
- if (PEND) goto invalid;
- PFETCH(c);
- if (c == ',') {
- UChar* prev = p;
- up = onig_scan_unsigned_number(&p, end, env->enc);
- if (up < 0) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
- if (up > ONIG_MAX_REPEAT_NUM)
- return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE;
-
- if (p == prev) {
- if (non_low != 0)
- goto invalid;
- up = REPEAT_INFINITE; /* {n,} : {n,infinite} */
- }
- }
- else {
- if (non_low != 0)
- goto invalid;
-
- PUNFETCH;
- up = low; /* {n} : exact n times */
- r = 2; /* fixed */
- }
-
- if (PEND) goto invalid;
- PFETCH(c);
- if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_BRACE_INTERVAL)) {
- if (c != MC_ESC(env->syntax)) goto invalid;
- PFETCH(c);
- }
- if (c != '}') goto invalid;
-
- if (!IS_REPEAT_INFINITE(up) && low > up) {
- return ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE;
- }
-
- tok->type = TK_INTERVAL;
- tok->u.repeat.lower = low;
- tok->u.repeat.upper = up;
- *src = p;
- return r; /* 0: normal {n,m}, 2: fixed {n} */
-
- invalid:
- if (syn_allow)
- return 1; /* OK */
- else
- return ONIGERR_INVALID_REPEAT_RANGE_PATTERN;
-}
-
-/* \M-, \C-, \c, or \... */
-static int
-fetch_escaped_value(UChar** src, UChar* end, ScanEnv* env)
-{
- int v;
- OnigCodePoint c;
- OnigEncoding enc = env->enc;
- UChar* p = *src;
- PFETCH_READY;
-
- if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
-
- PFETCH(c);
- switch (c) {
- case 'M':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META)) {
- if (PEND) return ONIGERR_END_PATTERN_AT_META;
- PFETCH(c);
- if (c != '-') return ONIGERR_META_CODE_SYNTAX;
- if (PEND) return ONIGERR_END_PATTERN_AT_META;
- PFETCH(c);
- if (c == MC_ESC(env->syntax)) {
- v = fetch_escaped_value(&p, end, env);
- if (v < 0) return v;
- c = (OnigCodePoint )v;
- }
- c = ((c & 0xff) | 0x80);
- }
- else
- goto backslash;
- break;
-
- case 'C':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL)) {
- if (PEND) return ONIGERR_END_PATTERN_AT_CONTROL;
- PFETCH(c);
- if (c != '-') return ONIGERR_CONTROL_CODE_SYNTAX;
- goto control;
- }
- else
- goto backslash;
-
- case 'c':
- if (IS_SYNTAX_OP(env->syntax, ONIG_SYN_OP_ESC_C_CONTROL)) {
- control:
- if (PEND) return ONIGERR_END_PATTERN_AT_CONTROL;
- PFETCH(c);
- if (c == '?') {
- c = 0177;
- }
- else {
- if (c == MC_ESC(env->syntax)) {
- v = fetch_escaped_value(&p, end, env);
- if (v < 0) return v;
- c = (OnigCodePoint )v;
- }
- c &= 0x9f;
- }
- break;
- }
- /* fall through */
-
- default:
- {
- backslash:
- c = conv_backslash_value(c, env);
- }
- break;
- }
-
- *src = p;
- return c;
-}
-
-static int fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env);
-
-static OnigCodePoint
-get_name_end_code_point(OnigCodePoint start)
-{
- switch (start) {
- case '<': return (OnigCodePoint )'>'; break;
- case '\'': return (OnigCodePoint )'\''; break;
- default:
- break;
- }
-
- return (OnigCodePoint )0;
-}
-
-#ifdef USE_NAMED_GROUP
-#ifdef USE_BACKREF_AT_LEVEL
-/*
- \k<name+n>, \k<name-n>
-*/
-static int
-fetch_name_with_level(OnigCodePoint start_code, UChar** src, UChar* end,
- UChar** rname_end, ScanEnv* env, int* level)
-{
- int r, exist_level = 0;
- OnigCodePoint end_code;
- OnigCodePoint c = 0;
- OnigEncoding enc = env->enc;
- UChar *name_end;
- UChar *p = *src;
- PFETCH_READY;
-
- end_code = get_name_end_code_point(start_code);
-
- name_end = end;
- r = 0;
- if (PEND) {
- return ONIGERR_EMPTY_GROUP_NAME;
- }
- else {
- PFETCH(c);
- if (c == end_code)
- return ONIGERR_EMPTY_GROUP_NAME;
-
- if (!ONIGENC_IS_CODE_WORD(enc, c)) {
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
- }
- }
-
- while (!PEND) {
- name_end = p;
- PFETCH(c);
- if (c == end_code || c == ')' || c == '+' || c == '-') break;
-
- if (!ONIGENC_IS_CODE_WORD(enc, c)) {
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
- }
- }
-
- if (c != end_code) {
- if (c == '+' || c == '-') {
- int num;
- int flag = (c == '-' ? -1 : 1);
-
- PFETCH(c);
- if (! ONIGENC_IS_CODE_DIGIT(enc, c)) goto err;
- PUNFETCH;
- num = onig_scan_unsigned_number(&p, end, enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- *level = (num * flag);
- exist_level = 1;
-
- PFETCH(c);
- if (c == end_code)
- goto end;
- }
-
- err:
- r = ONIGERR_INVALID_GROUP_NAME;
- name_end = end;
- }
-
- end:
- if (r == 0) {
- *rname_end = name_end;
- *src = p;
- return (exist_level ? 1 : 0);
- }
- else {
- onig_scan_env_set_error_string(env, r, *src, name_end);
- return r;
- }
-}
-#endif /* USE_BACKREF_AT_LEVEL */
-
-/*
- def: 0 -> define name (don't allow number name)
- 1 -> reference name (allow number name)
-*/
-static int
-fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
- UChar** rname_end, ScanEnv* env, int ref)
-{
- int r, is_num;
- OnigCodePoint end_code;
- OnigCodePoint c = 0;
- OnigEncoding enc = env->enc;
- UChar *name_end;
- UChar *p = *src;
- PFETCH_READY;
-
- end_code = get_name_end_code_point(start_code);
-
- name_end = end;
- r = 0;
- is_num = 0;
- if (PEND) {
- return ONIGERR_EMPTY_GROUP_NAME;
- }
- else {
- PFETCH(c);
- if (c == end_code)
- return ONIGERR_EMPTY_GROUP_NAME;
-
- if (ONIGENC_IS_CODE_DIGIT(enc, c)) {
- if (ref == 1)
- is_num = 1;
- else {
- r = ONIGERR_INVALID_GROUP_NAME;
- }
- }
- else if (!ONIGENC_IS_CODE_WORD(enc, c)) {
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
- }
- }
-
- while (!PEND) {
- name_end = p;
- PFETCH(c);
- if (c == end_code || c == ')') break;
-
- if (is_num == 1) {
- if (! ONIGENC_IS_CODE_DIGIT(enc, c)) {
- if (!ONIGENC_IS_CODE_WORD(enc, c))
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
- else
- r = ONIGERR_INVALID_GROUP_NAME;
- }
- }
- else {
- if (!ONIGENC_IS_CODE_WORD(enc, c)) {
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
- }
- }
- }
-
- if (c != end_code) {
- r = ONIGERR_INVALID_GROUP_NAME;
- name_end = end;
- }
-
- if (r == 0) {
- *rname_end = name_end;
- *src = p;
- return 0;
- }
- else {
- onig_scan_env_set_error_string(env, r, *src, name_end);
- return r;
- }
-}
-#else
-static int
-fetch_name(OnigCodePoint start_code, UChar** src, UChar* end,
- UChar** rname_end, ScanEnv* env, int ref)
-{
- int r, len;
- OnigCodePoint end_code;
- OnigCodePoint c = 0;
- UChar *name_end;
- OnigEncoding enc = env->enc;
- UChar *p = *src;
- PFETCH_READY;
-
- end_code = get_name_end_code_point(start_code);
-
- r = 0;
- while (!PEND) {
- name_end = p;
- if (enc_len(enc, p) > 1)
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
-
- PFETCH(c);
- if (c == end_code || c == ')') break;
- if (! ONIGENC_IS_CODE_DIGIT(enc, c))
- r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME;
- }
- if (c != end_code) {
- r = ONIGERR_INVALID_GROUP_NAME;
- name_end = end;
- }
-
- if (r == 0) {
- *rname_end = name_end;
- *src = p;
- return 0;
- }
- else {
- err:
- onig_scan_env_set_error_string(env, r, *src, name_end);
- return r;
- }
-}
-#endif
-
-static void
-CC_ESC_WARN(ScanEnv* env, UChar *c)
-{
- if (onig_warn == onig_null_warn) return ;
-
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_CC_OP_NOT_ESCAPED) &&
- IS_SYNTAX_BV(env->syntax, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC)) {
- UChar buf[WARN_BUFSIZE];
- onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
- env->pattern, env->pattern_end,
- (UChar* )"character class has '%s' without escape", c);
- (*onig_warn)((char* )buf);
- }
-}
-
-static void
-CLOSE_BRACKET_WITHOUT_ESC_WARN(ScanEnv* env, UChar* c)
-{
- if (onig_warn == onig_null_warn) return ;
-
- if (IS_SYNTAX_BV((env)->syntax, ONIG_SYN_WARN_CC_OP_NOT_ESCAPED)) {
- UChar buf[WARN_BUFSIZE];
- onig_snprintf_with_pattern(buf, WARN_BUFSIZE, (env)->enc,
- (env)->pattern, (env)->pattern_end,
- (UChar* )"regular expression has '%s' without escape", c);
- (*onig_warn)((char* )buf);
- }
-}
-
-static UChar*
-find_str_position(OnigCodePoint s[], int n, UChar* from, UChar* to,
- UChar **next, OnigEncoding enc)
-{
- int i;
- OnigCodePoint x;
- UChar *q;
- UChar *p = from;
-
- while (p < to) {
- x = ONIGENC_MBC_TO_CODE(enc, p, to);
- q = p + enc_len(enc, p, to);
- if (x == s[0]) {
- for (i = 1; i < n && q < to; i++) {
- x = ONIGENC_MBC_TO_CODE(enc, q, to);
- if (x != s[i]) break;
- q += enc_len(enc, q, to);
- }
- if (i >= n) {
- if (IS_NOT_NULL(next))
- *next = q;
- return p;
- }
- }
- p = q;
- }
- return NULL_UCHARP;
-}
-
-static int
-str_exist_check_with_esc(OnigCodePoint s[], int n, UChar* from, UChar* to,
- OnigCodePoint bad, OnigEncoding enc, OnigSyntaxType* syn)
-{
- int i, in_esc;
- OnigCodePoint x;
- UChar *q;
- UChar *p = from;
-
- in_esc = 0;
- while (p < to) {
- if (in_esc) {
- in_esc = 0;
- p += enc_len(enc, p, to);
- }
- else {
- x = ONIGENC_MBC_TO_CODE(enc, p, to);
- q = p + enc_len(enc, p, to);
- if (x == s[0]) {
- for (i = 1; i < n && q < to; i++) {
- x = ONIGENC_MBC_TO_CODE(enc, q, to);
- if (x != s[i]) break;
- q += enc_len(enc, q, to);
- }
- if (i >= n) return 1;
- p += enc_len(enc, p, to);
- }
- else {
- x = ONIGENC_MBC_TO_CODE(enc, p, to);
- if (x == bad) return 0;
- else if (x == MC_ESC(syn)) in_esc = 1;
- p = q;
- }
- }
- }
- return 0;
-}
-
-static int
-fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
-{
- int num;
- OnigCodePoint c, c2;
- OnigSyntaxType* syn = env->syntax;
- OnigEncoding enc = env->enc;
- UChar* prev;
- UChar* p = *src;
- PFETCH_READY;
-
- if (PEND) {
- tok->type = TK_EOT;
- return tok->type;
- }
-
- PFETCH(c);
- tok->type = TK_CHAR;
- tok->base = 0;
- tok->u.c = c;
- tok->escaped = 0;
-
- if (c == ']') {
- tok->type = TK_CC_CLOSE;
- }
- else if (c == '-') {
- tok->type = TK_CC_RANGE;
- }
- else if (c == MC_ESC(syn)) {
- if (! IS_SYNTAX_BV(syn, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC))
- goto end;
-
- if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
-
- PFETCH(c);
- tok->escaped = 1;
- tok->u.c = c;
- switch (c) {
- case 'w':
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
- tok->u.prop.not = 0;
- break;
- case 'W':
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
- tok->u.prop.not = 1;
- break;
- case 'd':
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
- tok->u.prop.not = 0;
- break;
- case 'D':
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
- tok->u.prop.not = 1;
- break;
- case 's':
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
- tok->u.prop.not = 0;
- break;
- case 'S':
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
- tok->u.prop.not = 1;
- break;
- case 'h':
- if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 0;
- break;
- case 'H':
- if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 1;
- break;
-
- case 'p':
- case 'P':
- c2 = PPEEK;
- if (c2 == '{' &&
- IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {
- PINC;
- tok->type = TK_CHAR_PROPERTY;
- tok->u.prop.not = (c == 'P' ? 1 : 0);
-
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {
- PFETCH(c2);
- if (c2 == '^') {
- tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);
- }
- else
- PUNFETCH;
- }
- }
- break;
-
- case 'x':
- if (PEND) break;
-
- prev = p;
- if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) {
- PINC;
- num = scan_unsigned_hexadecimal_number(&p, end, 8, enc);
- if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
- if (!PEND) {
- c2 = PPEEK;
- if (ONIGENC_IS_CODE_XDIGIT(enc, c2))
- return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;
- }
-
- if (p > prev + enc_len(enc, prev, end) && !PEND && (PPEEK_IS('}'))) {
- PINC;
- tok->type = TK_CODE_POINT;
- tok->base = 16;
- tok->u.code = (OnigCodePoint )num;
- }
- else {
- /* can't read nothing or invalid format */
- p = prev;
- }
- }
- else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) {
- num = scan_unsigned_hexadecimal_number(&p, end, 2, enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- if (p == prev) { /* can't read nothing. */
- num = 0; /* but, it's not error */
- }
- tok->type = TK_RAW_BYTE;
- tok->base = 16;
- tok->u.c = num;
- }
- break;
-
- case 'u':
- if (PEND) break;
-
- prev = p;
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) {
- num = scan_unsigned_hexadecimal_number(&p, end, 4, enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- if (p == prev) { /* can't read nothing. */
- num = 0; /* but, it's not error */
- }
- tok->type = TK_CODE_POINT;
- tok->base = 16;
- tok->u.code = (OnigCodePoint )num;
- }
- break;
-
- case '0':
- case '1': case '2': case '3': case '4': case '5': case '6': case '7':
- if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {
- PUNFETCH;
- prev = p;
- num = scan_unsigned_octal_number(&p, end, 3, enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- if (p == prev) { /* can't read nothing. */
- num = 0; /* but, it's not error */
- }
- tok->type = TK_RAW_BYTE;
- tok->base = 8;
- tok->u.c = num;
- }
- break;
-
- default:
- PUNFETCH;
- num = fetch_escaped_value(&p, end, env);
- if (num < 0) return num;
- if (tok->u.c != num) {
- tok->u.code = (OnigCodePoint )num;
- tok->type = TK_CODE_POINT;
- }
- break;
- }
- }
- else if (c == '[') {
- if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_POSIX_BRACKET) && (PPEEK_IS(':'))) {
- OnigCodePoint send[] = { (OnigCodePoint )':', (OnigCodePoint )']' };
- tok->backp = p; /* point at '[' is readed */
- PINC;
- if (str_exist_check_with_esc(send, 2, p, end,
- (OnigCodePoint )']', enc, syn)) {
- tok->type = TK_POSIX_BRACKET_OPEN;
- }
- else {
- PUNFETCH;
- goto cc_in_cc;
- }
- }
- else {
- cc_in_cc:
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP)) {
- tok->type = TK_CC_CC_OPEN;
- }
- else {
- CC_ESC_WARN(env, (UChar* )"[");
- }
- }
- }
- else if (c == '&') {
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP) &&
- !PEND && (PPEEK_IS('&'))) {
- PINC;
- tok->type = TK_CC_AND;
- }
- }
-
- end:
- *src = p;
- return tok->type;
-}
-
-static int
-fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
-{
- int r, num;
- OnigCodePoint c;
- OnigEncoding enc = env->enc;
- OnigSyntaxType* syn = env->syntax;
- UChar* prev;
- UChar* p = *src;
- PFETCH_READY;
-
- start:
- if (PEND) {
- tok->type = TK_EOT;
- return tok->type;
- }
-
- tok->type = TK_STRING;
- tok->base = 0;
- tok->backp = p;
-
- PFETCH(c);
- if (IS_MC_ESC_CODE(c, syn)) {
- if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE;
-
- tok->backp = p;
- PFETCH(c);
-
- tok->u.c = c;
- tok->escaped = 1;
- switch (c) {
- case '*':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF)) break;
- tok->type = TK_OP_REPEAT;
- tok->u.repeat.lower = 0;
- tok->u.repeat.upper = REPEAT_INFINITE;
- goto greedy_check;
- break;
-
- case '+':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_PLUS_ONE_INF)) break;
- tok->type = TK_OP_REPEAT;
- tok->u.repeat.lower = 1;
- tok->u.repeat.upper = REPEAT_INFINITE;
- goto greedy_check;
- break;
-
- case '?':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_QMARK_ZERO_ONE)) break;
- tok->type = TK_OP_REPEAT;
- tok->u.repeat.lower = 0;
- tok->u.repeat.upper = 1;
- greedy_check:
- if (!PEND && PPEEK_IS('?') &&
- IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_NON_GREEDY)) {
- PFETCH(c);
- tok->u.repeat.greedy = 0;
- tok->u.repeat.possessive = 0;
- }
- else {
- possessive_check:
- if (!PEND && PPEEK_IS('+') &&
- ((IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT) &&
- tok->type != TK_INTERVAL) ||
- (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL) &&
- tok->type == TK_INTERVAL))) {
- PFETCH(c);
- tok->u.repeat.greedy = 1;
- tok->u.repeat.possessive = 1;
- }
- else {
- tok->u.repeat.greedy = 1;
- tok->u.repeat.possessive = 0;
- }
- }
- break;
-
- case '{':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_BRACE_INTERVAL)) break;
- r = fetch_range_quantifier(&p, end, tok, env);
- if (r < 0) return r; /* error */
- if (r == 0) goto greedy_check;
- else if (r == 2) { /* {n} */
- if (IS_SYNTAX_BV(syn, ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY))
- goto possessive_check;
-
- goto greedy_check;
- }
- /* r == 1 : normal char */
- break;
-
- case '|':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_VBAR_ALT)) break;
- tok->type = TK_ALT;
- break;
-
- case '(':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LPAREN_SUBEXP)) break;
- tok->type = TK_SUBEXP_OPEN;
- break;
-
- case ')':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LPAREN_SUBEXP)) break;
- tok->type = TK_SUBEXP_CLOSE;
- break;
-
- case 'w':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
- tok->u.prop.not = 0;
- break;
-
- case 'W':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_W_WORD)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_WORD;
- tok->u.prop.not = 1;
- break;
-
- case 'b':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;
- tok->type = TK_ANCHOR;
- tok->u.anchor = ANCHOR_WORD_BOUND;
- break;
-
- case 'B':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;
- tok->type = TK_ANCHOR;
- tok->u.anchor = ANCHOR_NOT_WORD_BOUND;
- break;
-
-#ifdef USE_WORD_BEGIN_END
- case '<':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END)) break;
- tok->type = TK_ANCHOR;
- tok->u.anchor = ANCHOR_WORD_BEGIN;
- break;
-
- case '>':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END)) break;
- tok->type = TK_ANCHOR;
- tok->u.anchor = ANCHOR_WORD_END;
- break;
-#endif
-
- case 's':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
- tok->u.prop.not = 0;
- break;
-
- case 'S':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_S_WHITE_SPACE)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_SPACE;
- tok->u.prop.not = 1;
- break;
-
- case 'd':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
- tok->u.prop.not = 0;
- break;
-
- case 'D':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_D_DIGIT)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_DIGIT;
- tok->u.prop.not = 1;
- break;
-
- case 'h':
- if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 0;
- break;
-
- case 'H':
- if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break;
- tok->type = TK_CHAR_TYPE;
- tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT;
- tok->u.prop.not = 1;
- break;
-
- case 'A':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
- begin_buf:
- tok->type = TK_ANCHOR;
- tok->u.subtype = ANCHOR_BEGIN_BUF;
- break;
-
- case 'Z':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
- tok->type = TK_ANCHOR;
- tok->u.subtype = ANCHOR_SEMI_END_BUF;
- break;
-
- case 'z':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
- end_buf:
- tok->type = TK_ANCHOR;
- tok->u.subtype = ANCHOR_END_BUF;
- break;
-
- case 'G':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR)) break;
- tok->type = TK_ANCHOR;
- tok->u.subtype = ANCHOR_BEGIN_POSITION;
- break;
-
- case '`':
- if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR)) break;
- goto begin_buf;
- break;
-
- case '\'':
- if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR)) break;
- goto end_buf;
- break;
-
- case 'x':
- if (PEND) break;
-
- prev = p;
- if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) {
- PINC;
- num = scan_unsigned_hexadecimal_number(&p, end, 8, enc);
- if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
- if (!PEND) {
- if (ONIGENC_IS_CODE_XDIGIT(enc, PPEEK))
- return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE;
- }
-
- if ((p > prev + enc_len(enc, prev, end)) && !PEND && PPEEK_IS('}')) {
- PINC;
- tok->type = TK_CODE_POINT;
- tok->u.code = (OnigCodePoint )num;
- }
- else {
- /* can't read nothing or invalid format */
- p = prev;
- }
- }
- else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) {
- num = scan_unsigned_hexadecimal_number(&p, end, 2, enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- if (p == prev) { /* can't read nothing. */
- num = 0; /* but, it's not error */
- }
- tok->type = TK_RAW_BYTE;
- tok->base = 16;
- tok->u.c = num;
- }
- break;
-
- case 'u':
- if (PEND) break;
-
- prev = p;
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) {
- num = scan_unsigned_hexadecimal_number(&p, end, 4, enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- if (p == prev) { /* can't read nothing. */
- num = 0; /* but, it's not error */
- }
- tok->type = TK_CODE_POINT;
- tok->base = 16;
- tok->u.code = (OnigCodePoint )num;
- }
- break;
-
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- PUNFETCH;
- prev = p;
- num = onig_scan_unsigned_number(&p, end, enc);
- if (num < 0 || num > ONIG_MAX_BACKREF_NUM) {
- goto skip_backref;
- }
-
- if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_DECIMAL_BACKREF) &&
- (num <= env->num_mem || num <= 9)) { /* This spec. from GNU regex */
- if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
- if (num > env->num_mem || IS_NULL(SCANENV_MEM_NODES(env)[num]))
- return ONIGERR_INVALID_BACKREF;
- }
-
- tok->type = TK_BACKREF;
- tok->u.backref.num = 1;
- tok->u.backref.ref1 = num;
- tok->u.backref.by_name = 0;
-#ifdef USE_BACKREF_AT_LEVEL
- tok->u.backref.exist_level = 0;
-#endif
- break;
- }
-
- skip_backref:
- if (c == '8' || c == '9') {
- /* normal char */
- p = prev; PINC;
- break;
- }
-
- p = prev;
- /* fall through */
- case '0':
- if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {
- prev = p;
- num = scan_unsigned_octal_number(&p, end, (c == '0' ? 2:3), enc);
- if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
- if (p == prev) { /* can't read nothing. */
- num = 0; /* but, it's not error */
- }
- tok->type = TK_RAW_BYTE;
- tok->base = 8;
- tok->u.c = num;
- }
- else if (c != '0') {
- PINC;
- }
- break;
-
-#ifdef USE_NAMED_GROUP
- case 'k':
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_K_NAMED_BACKREF)) {
- PFETCH(c);
- if (c == '<' || c == '\'') {
- UChar* name_end;
- int* backs;
-
- prev = p;
-
-#ifdef USE_BACKREF_AT_LEVEL
- name_end = NULL_UCHARP; /* no need. escape gcc warning. */
- r = fetch_name_with_level((OnigCodePoint )c, &p, end, &name_end,
- env, &tok->u.backref.level);
- if (r == 1) tok->u.backref.exist_level = 1;
- else tok->u.backref.exist_level = 0;
-#else
- r = fetch_name(&p, end, &name_end, env, 1);
-#endif
- if (r < 0) return r;
-
- num = onig_name_to_group_numbers(env->reg, prev, name_end, &backs);
- if (num <= 0) {
- onig_scan_env_set_error_string(env,
- ONIGERR_UNDEFINED_NAME_REFERENCE, prev, name_end);
- return ONIGERR_UNDEFINED_NAME_REFERENCE;
- }
- if (IS_SYNTAX_BV(syn, ONIG_SYN_STRICT_CHECK_BACKREF)) {
- int i;
- for (i = 0; i < num; i++) {
- if (backs[i] > env->num_mem ||
- IS_NULL(SCANENV_MEM_NODES(env)[backs[i]]))
- return ONIGERR_INVALID_BACKREF;
- }
- }
-
- tok->type = TK_BACKREF;
- tok->u.backref.by_name = 1;
- if (num == 1) {
- tok->u.backref.num = 1;
- tok->u.backref.ref1 = backs[0];
- }
- else {
- tok->u.backref.num = num;
- tok->u.backref.refs = backs;
- }
- }
- else
- PUNFETCH;
- }
- break;
-#endif
-
-#ifdef USE_SUBEXP_CALL
- case 'g':
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_G_SUBEXP_CALL)) {
- PFETCH(c);
- if (c == '<' || c == '\'') {
- UChar* name_end;
-
- prev = p;
- r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, 1);
- if (r < 0) return r;
-
- tok->type = TK_CALL;
- tok->u.call.name = prev;
- tok->u.call.name_end = name_end;
- }
- else
- PUNFETCH;
- }
- break;
-#endif
-
- case 'Q':
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE)) {
- tok->type = TK_QUOTE_OPEN;
- }
- break;
-
- case 'p':
- case 'P':
- if (PPEEK_IS('{') &&
- IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) {
- PINC;
- tok->type = TK_CHAR_PROPERTY;
- tok->u.prop.not = (c == 'P' ? 1 : 0);
-
- if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) {
- PFETCH(c);
- if (c == '^') {
- tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0);
- }
- else
- PUNFETCH;
- }
- }
- break;
-
- default:
- PUNFETCH;
- num = fetch_escaped_value(&p, end, env);
- if (num < 0) return num;
- /* set_raw: */
- if (tok->u.c != num) {
- tok->type = TK_CODE_POINT;
- tok->u.code = (OnigCodePoint )num;
- }
- else { /* string */
- p = tok->backp + enc_len(enc, tok->backp, end);
- }
- break;
- }
- }
- else {
- tok->u.c = c;
- tok->escaped = 0;
-
-#ifdef USE_VARIABLE_META_CHARS
- if ((c != ONIG_INEFFECTIVE_META_CHAR) &&
- IS_SYNTAX_OP(syn, ONIG_SYN_OP_VARIABLE_META_CHARACTERS)) {
- if (c == MC_ANYCHAR(syn))
- goto any_char;
- else if (c == MC_ANYTIME(syn))
- goto anytime;
- else if (c == MC_ZERO_OR_ONE_TIME(syn))
- goto zero_or_one_time;
- else if (c == MC_ONE_OR_MORE_TIME(syn))
- goto one_or_more_time;
- else if (c == MC_ANYCHAR_ANYTIME(syn)) {
- tok->type = TK_ANYCHAR_ANYTIME;
- goto out;
- }
- }
-#endif
-
- switch (c) {
- case '.':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_DOT_ANYCHAR)) break;
-#ifdef USE_VARIABLE_META_CHARS
- any_char:
-#endif
- tok->type = TK_ANYCHAR;
- break;
-
- case '*':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ASTERISK_ZERO_INF)) break;
-#ifdef USE_VARIABLE_META_CHARS
- anytime:
-#endif
- tok->type = TK_OP_REPEAT;
- tok->u.repeat.lower = 0;
- tok->u.repeat.upper = REPEAT_INFINITE;
- goto greedy_check;
- break;
-
- case '+':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_PLUS_ONE_INF)) break;
-#ifdef USE_VARIABLE_META_CHARS
- one_or_more_time:
-#endif
- tok->type = TK_OP_REPEAT;
- tok->u.repeat.lower = 1;
- tok->u.repeat.upper = REPEAT_INFINITE;
- goto greedy_check;
- break;
-
- case '?':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_QMARK_ZERO_ONE)) break;
-#ifdef USE_VARIABLE_META_CHARS
- zero_or_one_time:
-#endif
- tok->type = TK_OP_REPEAT;
- tok->u.repeat.lower = 0;
- tok->u.repeat.upper = 1;
- goto greedy_check;
- break;
-
- case '{':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_BRACE_INTERVAL)) break;
- r = fetch_range_quantifier(&p, end, tok, env);
- if (r < 0) return r; /* error */
- if (r == 0) goto greedy_check;
- else if (r == 2) { /* {n} */
- if (IS_SYNTAX_BV(syn, ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY))
- goto possessive_check;
-
- goto greedy_check;
- }
- /* r == 1 : normal char */
- break;
-
- case '|':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_VBAR_ALT)) break;
- tok->type = TK_ALT;
- break;
-
- case '(':
- if (PPEEK_IS('?') &&
- IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {
- PINC;
- if (PPEEK_IS('#')) {
- PFETCH(c);
- while (1) {
- if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
- PFETCH(c);
- if (c == MC_ESC(syn)) {
- if (!PEND) PFETCH(c);
- }
- else {
- if (c == ')') break;
- }
- }
- goto start;
- }
- PUNFETCH;
- }
-
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LPAREN_SUBEXP)) break;
- tok->type = TK_SUBEXP_OPEN;
- break;
-
- case ')':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LPAREN_SUBEXP)) break;
- tok->type = TK_SUBEXP_CLOSE;
- break;
-
- case '^':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LINE_ANCHOR)) break;
- tok->type = TK_ANCHOR;
- tok->u.subtype = (IS_SINGLELINE(env->option)
- ? ANCHOR_BEGIN_BUF : ANCHOR_BEGIN_LINE);
- break;
-
- case '$':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_LINE_ANCHOR)) break;
- tok->type = TK_ANCHOR;
- tok->u.subtype = (IS_SINGLELINE(env->option)
- ? ANCHOR_SEMI_END_BUF : ANCHOR_END_LINE);
- break;
-
- case '[':
- if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_BRACKET_CC)) break;
- tok->type = TK_CC_OPEN;
- break;
-
- case ']':
- if (*src > env->pattern) /* /].../ is allowed. */
- CLOSE_BRACKET_WITHOUT_ESC_WARN(env, (UChar* )"]");
- break;
-
- case '#':
- if (IS_EXTEND(env->option)) {
- while (!PEND) {
- PFETCH(c);
- if (ONIGENC_IS_CODE_NEWLINE(enc, c))
- break;
- }
- goto start;
- break;
- }
- break;
-
- case ' ': case '\t': case '\n': case '\r': case '\f':
- if (IS_EXTEND(env->option))
- goto start;
- break;
-
- default:
- /* string */
- break;
- }
- }
-
-#ifdef USE_VARIABLE_META_CHARS
- out:
-#endif
- *src = p;
- return tok->type;
-}
-
-static int
-add_ctype_to_cc_by_range(CClassNode* cc, int ctype, int not, OnigEncoding enc,
- OnigCodePoint sb_out, const OnigCodePoint mbr[])
-{
- int i, r;
- OnigCodePoint j;
-
- int n = ONIGENC_CODE_RANGE_NUM(mbr);
-
- if (not == 0) {
- for (i = 0; i < n; i++) {
- for (j = ONIGENC_CODE_RANGE_FROM(mbr, i);
- j <= ONIGENC_CODE_RANGE_TO(mbr, i); j++) {
- if (j >= sb_out) {
- if (j == ONIGENC_CODE_RANGE_TO(mbr, i)) i++;
- else if (j > ONIGENC_CODE_RANGE_FROM(mbr, i)) {
- r = add_code_range_to_buf(&(cc->mbuf), j,
- ONIGENC_CODE_RANGE_TO(mbr, i));
- if (r != 0) return r;
- i++;
- }
-
- goto sb_end;
- }
- BITSET_SET_BIT(cc->bs, j);
- }
- }
-
- sb_end:
- for ( ; i < n; i++) {
- r = add_code_range_to_buf(&(cc->mbuf),
- ONIGENC_CODE_RANGE_FROM(mbr, i),
- ONIGENC_CODE_RANGE_TO(mbr, i));
- if (r != 0) return r;
- }
- }
- else {
- OnigCodePoint prev = 0;
-
- for (i = 0; i < n; i++) {
- for (j = prev;
- j < ONIGENC_CODE_RANGE_FROM(mbr, i); j++) {
- if (j >= sb_out) {
- goto sb_end2;
- }
- BITSET_SET_BIT(cc->bs, j);
- }
- prev = ONIGENC_CODE_RANGE_TO(mbr, i) + 1;
- }
- for (j = prev; j < sb_out; j++) {
- BITSET_SET_BIT(cc->bs, j);
- }
-
- sb_end2:
- prev = sb_out;
-
- for (i = 0; i < n; i++) {
- if (prev < ONIGENC_CODE_RANGE_FROM(mbr, i)) {
- r = add_code_range_to_buf(&(cc->mbuf), prev,
- ONIGENC_CODE_RANGE_FROM(mbr, i) - 1);
- if (r != 0) return r;
- }
- prev = ONIGENC_CODE_RANGE_TO(mbr, i) + 1;
- }
- if (prev < 0x7fffffff) {
- r = add_code_range_to_buf(&(cc->mbuf), prev, 0x7fffffff);
- if (r != 0) return r;
- }
- }
-
- return 0;
-}
-
-static int
-add_ctype_to_cc(CClassNode* cc, int ctype, int not, ScanEnv* env)
-{
- int c, r;
- const OnigCodePoint *ranges;
- OnigCodePoint sb_out;
- OnigEncoding enc = env->enc;
-
- r = ONIGENC_GET_CTYPE_CODE_RANGE(enc, ctype, &sb_out, &ranges);
- if (r == 0) {
- return add_ctype_to_cc_by_range(cc, ctype, not, env->enc, sb_out, ranges);
- }
- else if (r != ONIG_NO_SUPPORT_CONFIG) {
- return r;
- }
-
- r = 0;
- switch (ctype) {
- case ONIGENC_CTYPE_ALPHA:
- case ONIGENC_CTYPE_BLANK:
- case ONIGENC_CTYPE_CNTRL:
- case ONIGENC_CTYPE_DIGIT:
- case ONIGENC_CTYPE_LOWER:
- case ONIGENC_CTYPE_PUNCT:
- case ONIGENC_CTYPE_SPACE:
- case ONIGENC_CTYPE_UPPER:
- case ONIGENC_CTYPE_XDIGIT:
- case ONIGENC_CTYPE_ASCII:
- case ONIGENC_CTYPE_ALNUM:
- if (not != 0) {
- for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
- if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
- BITSET_SET_BIT(cc->bs, c);
- }
- ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
- }
- else {
- for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
- if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
- BITSET_SET_BIT(cc->bs, c);
- }
- }
- break;
-
- case ONIGENC_CTYPE_GRAPH:
- case ONIGENC_CTYPE_PRINT:
- if (not != 0) {
- for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
- if (! ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
- BITSET_SET_BIT(cc->bs, c);
- }
- }
- else {
- for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
- if (ONIGENC_IS_CODE_CTYPE(enc, (OnigCodePoint )c, ctype))
- BITSET_SET_BIT(cc->bs, c);
- }
- ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
- }
- break;
-
- case ONIGENC_CTYPE_WORD:
- if (not == 0) {
- for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
- if (IS_CODE_SB_WORD(enc, c)) BITSET_SET_BIT(cc->bs, c);
- }
- ADD_ALL_MULTI_BYTE_RANGE(enc, cc->mbuf);
- }
- else {
- for (c = 0; c < SINGLE_BYTE_SIZE; c++) {
- if ((ONIGENC_CODE_TO_MBCLEN(enc, c) > 0) /* 0: invalid code point */
- && ! ONIGENC_IS_CODE_WORD(enc, c))
- BITSET_SET_BIT(cc->bs, c);
- }
- }
- break;
-
- default:
- return ONIGERR_PARSER_BUG;
- break;
- }
-
- return r;
-}
-
-static int
-parse_posix_bracket(CClassNode* cc, UChar** src, UChar* end, ScanEnv* env)
-{
-#define POSIX_BRACKET_CHECK_LIMIT_LENGTH 20
-#define POSIX_BRACKET_NAME_MIN_LEN 4
-
- static PosixBracketEntryType PBS[] = {
- { (UChar* )"alnum", ONIGENC_CTYPE_ALNUM, 5 },
- { (UChar* )"alpha", ONIGENC_CTYPE_ALPHA, 5 },
- { (UChar* )"blank", ONIGENC_CTYPE_BLANK, 5 },
- { (UChar* )"cntrl", ONIGENC_CTYPE_CNTRL, 5 },
- { (UChar* )"digit", ONIGENC_CTYPE_DIGIT, 5 },
- { (UChar* )"graph", ONIGENC_CTYPE_GRAPH, 5 },
- { (UChar* )"lower", ONIGENC_CTYPE_LOWER, 5 },
- { (UChar* )"print", ONIGENC_CTYPE_PRINT, 5 },
- { (UChar* )"punct", ONIGENC_CTYPE_PUNCT, 5 },
- { (UChar* )"space", ONIGENC_CTYPE_SPACE, 5 },
- { (UChar* )"upper", ONIGENC_CTYPE_UPPER, 5 },
- { (UChar* )"xdigit", ONIGENC_CTYPE_XDIGIT, 6 },
- { (UChar* )"ascii", ONIGENC_CTYPE_ASCII, 5 },
- { (UChar* )"word", ONIGENC_CTYPE_WORD, 4 },
- { (UChar* )NULL, -1, 0 }
- };
-
- PosixBracketEntryType *pb;
- int not, i, r;
- OnigCodePoint c;
- OnigEncoding enc = env->enc;
- UChar *p = *src;
- PFETCH_READY;
-
- if (PPEEK_IS('^')) {
- PINC;
- not = 1;
- }
- else
- not = 0;
-
- if (onigenc_strlen(enc, p, end) < POSIX_BRACKET_NAME_MIN_LEN + 3)
- goto not_posix_bracket;
-
- for (pb = PBS; IS_NOT_NULL(pb->name); pb++) {
- if (onigenc_with_ascii_strncmp(enc, p, end, pb->name, pb->len) == 0) {
- p = (UChar* )onigenc_step(enc, p, end, pb->len);
- if (onigenc_with_ascii_strncmp(enc, p, end, (UChar* )":]", 2) != 0)
- return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
-
- r = add_ctype_to_cc(cc, pb->ctype, not, env);
- if (r != 0) return r;
-
- PINC; PINC;
- *src = p;
- return 0;
- }
- }
-
- not_posix_bracket:
- c = 0;
- i = 0;
- while (!PEND && ((c = PPEEK) != ':') && c != ']') {
- PINC;
- if (++i > POSIX_BRACKET_CHECK_LIMIT_LENGTH) break;
- }
- if (c == ':' && ! PEND) {
- PINC;
- if (! PEND) {
- PFETCH(c);
- if (c == ']')
- return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
- }
- }
-
- return 1; /* 1: is not POSIX bracket, but no error. */
-}
-
-static int
-fetch_char_property_to_ctype(UChar** src, UChar* end, ScanEnv* env)
-{
- int r;
- OnigCodePoint c;
- OnigEncoding enc = env->enc;
- UChar *prev, *start, *p = *src;
- PFETCH_READY;
-
- r = 0;
- start = prev = p;
-
- while (!PEND) {
- prev = p;
- PFETCH(c);
- if (c == '}') {
- r = ONIGENC_PROPERTY_NAME_TO_CTYPE(enc, start, prev);
- if (r < 0) break;
-
- *src = p;
- return r;
- }
- else if (c == '(' || c == ')' || c == '{' || c == '|') {
- r = ONIGERR_INVALID_CHAR_PROPERTY_NAME;
- break;
- }
- }
-
- onig_scan_env_set_error_string(env, r, *src, prev);
- return r;
-}
-
-static int
-parse_char_property(Node** np, OnigToken* tok, UChar** src, UChar* end,
- ScanEnv* env)
-{
- int r, ctype;
- CClassNode* cc;
-
- ctype = fetch_char_property_to_ctype(src, end, env);
- if (ctype < 0) return ctype;
-
- *np = node_new_cclass();
- CHECK_NULL_RETURN_MEMERR(*np);
- cc = NCCLASS(*np);
- r = add_ctype_to_cc(cc, ctype, 0, env);
- if (r != 0) return r;
- if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
-
- return 0;
-}
-
-
-enum CCSTATE {
- CCS_VALUE,
- CCS_RANGE,
- CCS_COMPLETE,
- CCS_START
-};
-
-enum CCVALTYPE {
- CCV_SB,
- CCV_CODE_POINT,
- CCV_CLASS
-};
-
-static int
-next_state_class(CClassNode* cc, OnigCodePoint* vs, enum CCVALTYPE* type,
- enum CCSTATE* state, ScanEnv* env)
-{
- int r;
-
- if (*state == CCS_RANGE)
- return ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE;
-
- if (*state == CCS_VALUE && *type != CCV_CLASS) {
- if (*type == CCV_SB)
- BITSET_SET_BIT(cc->bs, (int )(*vs));
- else if (*type == CCV_CODE_POINT) {
- r = add_code_range(&(cc->mbuf), env, *vs, *vs);
- if (r < 0) return r;
- }
- }
-
- *state = CCS_VALUE;
- *type = CCV_CLASS;
- return 0;
-}
-
-static int
-next_state_val(CClassNode* cc, OnigCodePoint *vs, OnigCodePoint v,
- int* vs_israw, int v_israw,
- enum CCVALTYPE intype, enum CCVALTYPE* type,
- enum CCSTATE* state, ScanEnv* env)
-{
- int r;
-
- switch (*state) {
- case CCS_VALUE:
- if (*type == CCV_SB)
- BITSET_SET_BIT(cc->bs, (int )(*vs));
- else if (*type == CCV_CODE_POINT) {
- r = add_code_range(&(cc->mbuf), env, *vs, *vs);
- if (r < 0) return r;
- }
- break;
-
- case CCS_RANGE:
- if (intype == *type) {
- if (intype == CCV_SB) {
- if (*vs > 0xff || v > 0xff)
- return ONIGERR_INVALID_WIDE_CHAR_VALUE;
-
- if (*vs > v) {
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC))
- goto ccs_range_end;
- else
- return ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS;
- }
- bitset_set_range(cc->bs, (int )*vs, (int )v);
- }
- else {
- r = add_code_range(&(cc->mbuf), env, *vs, v);
- if (r < 0) return r;
- }
- }
- else {
-#if 0
- if (intype == CCV_CODE_POINT && *type == CCV_SB) {
-#endif
- if (*vs > v) {
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC))
- goto ccs_range_end;
- else
- return ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS;
- }
- bitset_set_range(cc->bs, (int )*vs, (int )(v < 0xff ? v : 0xff));
- r = add_code_range(&(cc->mbuf), env, (OnigCodePoint )*vs, v);
- if (r < 0) return r;
-#if 0
- }
- else
- return ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE;
-#endif
- }
- ccs_range_end:
- *state = CCS_COMPLETE;
- break;
-
- case CCS_COMPLETE:
- case CCS_START:
- *state = CCS_VALUE;
- break;
-
- default:
- break;
- }
-
- *vs_israw = v_israw;
- *vs = v;
- *type = intype;
- return 0;
-}
-
-static int
-code_exist_check(OnigCodePoint c, UChar* from, UChar* end, int ignore_escaped,
- ScanEnv* env)
-{
- int in_esc;
- OnigCodePoint code;
- OnigEncoding enc = env->enc;
- UChar* p = from;
- PFETCH_READY;
-
- in_esc = 0;
- while (! PEND) {
- if (ignore_escaped && in_esc) {
- in_esc = 0;
- }
- else {
- PFETCH(code);
- if (code == c) return 1;
- if (code == MC_ESC(env->syntax)) in_esc = 1;
- }
- }
- return 0;
-}
-
-static int
-parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end,
- ScanEnv* env)
-{
- int r, neg, len, fetched, and_start;
- OnigCodePoint v, vs;
- UChar *p;
- Node* node;
- CClassNode *cc, *prev_cc;
- CClassNode work_cc;
-
- enum CCSTATE state;
- enum CCVALTYPE val_type, in_type;
- int val_israw, in_israw;
-
- prev_cc = (CClassNode* )NULL;
- *np = NULL_NODE;
- r = fetch_token_in_cc(tok, src, end, env);
- if (r == TK_CHAR && tok->u.c == '^' && tok->escaped == 0) {
- neg = 1;
- r = fetch_token_in_cc(tok, src, end, env);
- }
- else {
- neg = 0;
- }
-
- if (r < 0) return r;
- if (r == TK_CC_CLOSE) {
- if (! code_exist_check((OnigCodePoint )']',
- *src, env->pattern_end, 1, env))
- return ONIGERR_EMPTY_CHAR_CLASS;
-
- CC_ESC_WARN(env, (UChar* )"]");
- r = tok->type = TK_CHAR; /* allow []...] */
- }
-
- *np = node = node_new_cclass();
- CHECK_NULL_RETURN_MEMERR(node);
- cc = NCCLASS(node);
-
- and_start = 0;
- state = CCS_START;
- p = *src;
- while (r != TK_CC_CLOSE) {
- fetched = 0;
- switch (r) {
- case TK_CHAR:
- len = ONIGENC_CODE_TO_MBCLEN(env->enc, tok->u.c);
- if (len > 1) {
- in_type = CCV_CODE_POINT;
- }
- else {
- sb_char:
- in_type = CCV_SB;
- }
- v = (OnigCodePoint )tok->u.c;
- in_israw = 0;
- goto val_entry2;
- break;
-
- case TK_RAW_BYTE:
- /* tok->base != 0 : octal or hexadec. */
- if (! ONIGENC_IS_SINGLEBYTE(env->enc) && tok->base != 0) {
- UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
- UChar* bufe = buf + ONIGENC_CODE_TO_MBC_MAXLEN;
- UChar* psave = p;
- int i, base = tok->base;
-
- buf[0] = tok->u.c;
- for (i = 1; i < ONIGENC_MBC_MAXLEN(env->enc); i++) {
- r = fetch_token_in_cc(tok, &p, end, env);
- if (r < 0) goto err;
- if (r != TK_RAW_BYTE || tok->base != base) {
- fetched = 1;
- break;
- }
- buf[i] = tok->u.c;
- }
-
- if (i < ONIGENC_MBC_MINLEN(env->enc)) {
- r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
- goto err;
- }
-
- len = enc_len(env->enc, buf, buf+i);
- if (i < len) {
- r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
- goto err;
- }
- else if (i > len) { /* fetch back */
- p = psave;
- for (i = 1; i < len; i++) {
- r = fetch_token_in_cc(tok, &p, end, env);
- }
- fetched = 0;
- }
-
- if (i == 1) {
- v = (OnigCodePoint )buf[0];
- goto raw_single;
- }
- else {
- v = ONIGENC_MBC_TO_CODE(env->enc, buf, bufe);
- in_type = CCV_CODE_POINT;
- }
- }
- else {
- v = (OnigCodePoint )tok->u.c;
- raw_single:
- in_type = CCV_SB;
- }
- in_israw = 1;
- goto val_entry2;
- break;
-
- case TK_CODE_POINT:
- v = tok->u.code;
- in_israw = 1;
- val_entry:
- len = ONIGENC_CODE_TO_MBCLEN(env->enc, v);
- if (len < 0) {
- r = len;
- goto err;
- }
- in_type = (len == 1 ? CCV_SB : CCV_CODE_POINT);
- val_entry2:
- r = next_state_val(cc, &vs, v, &val_israw, in_israw, in_type, &val_type,
- &state, env);
- if (r != 0) goto err;
- break;
-
- case TK_POSIX_BRACKET_OPEN:
- r = parse_posix_bracket(cc, &p, end, env);
- if (r < 0) goto err;
- if (r == 1) { /* is not POSIX bracket */
- CC_ESC_WARN(env, (UChar* )"[");
- p = tok->backp;
- v = (OnigCodePoint )tok->u.c;
- in_israw = 0;
- goto val_entry;
- }
- goto next_class;
- break;
-
- case TK_CHAR_TYPE:
- r = add_ctype_to_cc(cc, tok->u.prop.ctype, tok->u.prop.not, env);
- if (r != 0) return r;
-
- next_class:
- r = next_state_class(cc, &vs, &val_type, &state, env);
- if (r != 0) goto err;
- break;
-
- case TK_CHAR_PROPERTY:
- {
- int ctype;
-
- ctype = fetch_char_property_to_ctype(&p, end, env);
- if (ctype < 0) return ctype;
- r = add_ctype_to_cc(cc, ctype, tok->u.prop.not, env);
- if (r != 0) return r;
- goto next_class;
- }
- break;
-
- case TK_CC_RANGE:
- if (state == CCS_VALUE) {
- r = fetch_token_in_cc(tok, &p, end, env);
- if (r < 0) goto err;
- fetched = 1;
- if (r == TK_CC_CLOSE) { /* allow [x-] */
- range_end_val:
- v = (OnigCodePoint )'-';
- in_israw = 0;
- goto val_entry;
- }
- else if (r == TK_CC_AND) {
- CC_ESC_WARN(env, (UChar* )"-");
- goto range_end_val;
- }
- state = CCS_RANGE;
- }
- else if (state == CCS_START) {
- /* [-xa] is allowed */
- v = (OnigCodePoint )tok->u.c;
- in_israw = 0;
-
- r = fetch_token_in_cc(tok, &p, end, env);
- if (r < 0) goto err;
- fetched = 1;
- /* [--x] or [a&&-x] is warned. */
- if (r == TK_CC_RANGE || and_start != 0)
- CC_ESC_WARN(env, (UChar* )"-");
-
- goto val_entry;
- }
- else if (state == CCS_RANGE) {
- CC_ESC_WARN(env, (UChar* )"-");
- goto sb_char; /* [!--x] is allowed */
- }
- else { /* CCS_COMPLETE */
- r = fetch_token_in_cc(tok, &p, end, env);
- if (r < 0) goto err;
- fetched = 1;
- if (r == TK_CC_CLOSE) goto range_end_val; /* allow [a-b-] */
- else if (r == TK_CC_AND) {
- CC_ESC_WARN(env, (UChar* )"-");
- goto range_end_val;
- }
-
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) {
- CC_ESC_WARN(env, (UChar* )"-");
- goto sb_char; /* [0-9-a] is allowed as [0-9\-a] */
- }
- r = ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS;
- goto err;
- }
- break;
-
- case TK_CC_CC_OPEN: /* [ */
- {
- Node *anode;
- CClassNode* acc;
-
- r = parse_char_class(&anode, tok, &p, end, env);
- if (r != 0) goto cc_open_err;
- acc = NCCLASS(anode);
- r = or_cclass(cc, acc, env->enc);
-
- onig_node_free(anode);
- cc_open_err:
- if (r != 0) goto err;
- }
- break;
-
- case TK_CC_AND: /* && */
- {
- if (state == CCS_VALUE) {
- r = next_state_val(cc, &vs, 0, &val_israw, 0, val_type,
- &val_type, &state, env);
- if (r != 0) goto err;
- }
- /* initialize local variables */
- and_start = 1;
- state = CCS_START;
-
- if (IS_NOT_NULL(prev_cc)) {
- r = and_cclass(prev_cc, cc, env->enc);
- if (r != 0) goto err;
- bbuf_free(cc->mbuf);
- }
- else {
- prev_cc = cc;
- cc = &work_cc;
- }
- initialize_cclass(cc);
- }
- break;
-
- case TK_EOT:
- r = ONIGERR_PREMATURE_END_OF_CHAR_CLASS;
- goto err;
- break;
- default:
- r = ONIGERR_PARSER_BUG;
- goto err;
- break;
- }
-
- if (fetched)
- r = tok->type;
- else {
- r = fetch_token_in_cc(tok, &p, end, env);
- if (r < 0) goto err;
- }
- }
-
- if (state == CCS_VALUE) {
- r = next_state_val(cc, &vs, 0, &val_israw, 0, val_type,
- &val_type, &state, env);
- if (r != 0) goto err;
- }
-
- if (IS_NOT_NULL(prev_cc)) {
- r = and_cclass(prev_cc, cc, env->enc);
- if (r != 0) goto err;
- bbuf_free(cc->mbuf);
- cc = prev_cc;
- }
-
- if (neg != 0)
- NCCLASS_SET_NOT(cc);
- else
- NCCLASS_CLEAR_NOT(cc);
- if (IS_NCCLASS_NOT(cc) &&
- IS_SYNTAX_BV(env->syntax, ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC)) {
- int is_empty;
-
- is_empty = (IS_NULL(cc->mbuf) ? 1 : 0);
- if (is_empty != 0)
- BITSET_IS_EMPTY(cc->bs, is_empty);
-
- if (is_empty == 0) {
-#define NEWLINE_CODE 0x0a
-
- if (ONIGENC_IS_CODE_NEWLINE(env->enc, NEWLINE_CODE)) {
- if (ONIGENC_CODE_TO_MBCLEN(env->enc, NEWLINE_CODE) == 1)
- BITSET_SET_BIT(cc->bs, NEWLINE_CODE);
- else
- add_code_range(&(cc->mbuf), env, NEWLINE_CODE, NEWLINE_CODE);
- }
- }
- }
- *src = p;
- return 0;
-
- err:
- if (cc != NCCLASS(*np))
- bbuf_free(cc->mbuf);
- onig_node_free(*np);
- return r;
-}
-
-static int parse_subexp(Node** top, OnigToken* tok, int term,
- UChar** src, UChar* end, ScanEnv* env);
-
-static int
-parse_enclose(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
- ScanEnv* env)
-{
- int r, num;
- int list_capture;
- Node *target;
- OnigOptionType option;
- OnigEncoding enc = env->enc;
- OnigCodePoint c;
- UChar* p = *src;
- PFETCH_READY;
-
- *np = NULL;
- if (PEND) return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS;
-
- option = env->option;
- if (PPEEK_IS('?') &&
- IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {
- PINC;
- if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
-
- PFETCH(c);
- switch (c) {
- case ':': /* (?:...) grouping only */
- group:
- r = fetch_token(tok, &p, end, env);
- if (r < 0) return r;
- r = parse_subexp(np, tok, term, &p, end, env);
- if (r < 0) return r;
- *src = p;
- return 1; /* group */
- break;
-
- case '=':
- *np = onig_node_new_anchor(ANCHOR_PREC_READ);
- break;
- case '!': /* preceding read */
- *np = onig_node_new_anchor(ANCHOR_PREC_READ_NOT);
- break;
- case '>': /* (?>...) stop backtrack */
- *np = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
- break;
-
- case '\'':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
- goto named_group1;
- }
- else
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- break;
-
- case '<': /* look behind (?<=...), (?<!...) */
- PFETCH(c);
- if (c == '=')
- *np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND);
- else if (c == '!')
- *np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND_NOT);
-#ifdef USE_NAMED_GROUP
- else {
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
- UChar *name;
- UChar *name_end;
-
- PUNFETCH;
- c = '<';
-
- named_group1:
- list_capture = 0;
-
- named_group2:
- name = p;
- r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, 0);
- if (r < 0) return r;
-
- num = scan_env_add_mem_entry(env);
- if (num < 0) return num;
- if (list_capture != 0 && num >= BIT_STATUS_BITS_NUM)
- return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
-
- r = name_add(env->reg, name, name_end, num, env);
- if (r != 0) return r;
- *np = node_new_enclose_memory(env->option, 1);
- CHECK_NULL_RETURN_MEMERR(*np);
- NENCLOSE(*np)->regnum = num;
- if (list_capture != 0)
- BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
- env->num_named++;
- }
- else {
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- }
- }
-#else
- else {
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- }
-#endif
- break;
-
- case '@':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY)) {
-#ifdef USE_NAMED_GROUP
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
- PFETCH(c);
- if (c == '<' || c == '\'') {
- list_capture = 1;
- goto named_group2; /* (?@<name>...) */
- }
- PUNFETCH;
- }
-#endif
- *np = node_new_enclose_memory(env->option, 0);
- CHECK_NULL_RETURN_MEMERR(*np);
- num = scan_env_add_mem_entry(env);
- if (num < 0) {
- onig_node_free(*np);
- return num;
- }
- else if (num >= BIT_STATUS_BITS_NUM) {
- onig_node_free(*np);
- return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
- }
- NENCLOSE(*np)->regnum = num;
- BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
- }
- else {
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- }
- break;
-
-#ifdef USE_POSIXLINE_OPTION
- case 'p':
-#endif
- case '-': case 'i': case 'm': case 's': case 'x':
- {
- int neg = 0;
-
- while (1) {
- switch (c) {
- case ':':
- case ')':
- break;
-
- case '-': neg = 1; break;
- case 'x': ONOFF(option, ONIG_OPTION_EXTEND, neg); break;
- case 'i': ONOFF(option, ONIG_OPTION_IGNORECASE, neg); break;
- case 's':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
- ONOFF(option, ONIG_OPTION_MULTILINE, neg);
- }
- else
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- break;
-
- case 'm':
- if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
- ONOFF(option, ONIG_OPTION_SINGLELINE, (neg == 0 ? 1 : 0));
- }
- else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) {
- ONOFF(option, ONIG_OPTION_MULTILINE, neg);
- }
- else
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- break;
-#ifdef USE_POSIXLINE_OPTION
- case 'p':
- ONOFF(option, ONIG_OPTION_MULTILINE|ONIG_OPTION_SINGLELINE, neg);
- break;
-#endif
- default:
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- }
-
- if (c == ')') {
- *np = node_new_option(option);
- CHECK_NULL_RETURN_MEMERR(*np);
- *src = p;
- return 2; /* option only */
- }
- else if (c == ':') {
- OnigOptionType prev = env->option;
-
- env->option = option;
- r = fetch_token(tok, &p, end, env);
- if (r < 0) return r;
- r = parse_subexp(&target, tok, term, &p, end, env);
- env->option = prev;
- if (r < 0) return r;
- *np = node_new_option(option);
- CHECK_NULL_RETURN_MEMERR(*np);
- NENCLOSE(*np)->target = target;
- *src = p;
- return 0;
- }
-
- if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
- PFETCH(c);
- }
- }
- break;
-
- default:
- return ONIGERR_UNDEFINED_GROUP_OPTION;
- }
- }
- else {
- if (ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_DONT_CAPTURE_GROUP))
- goto group;
-
- *np = node_new_enclose_memory(env->option, 0);
- CHECK_NULL_RETURN_MEMERR(*np);
- num = scan_env_add_mem_entry(env);
- if (num < 0) return num;
- NENCLOSE(*np)->regnum = num;
- }
-
- CHECK_NULL_RETURN_MEMERR(*np);
- r = fetch_token(tok, &p, end, env);
- if (r < 0) return r;
- r = parse_subexp(&target, tok, term, &p, end, env);
- if (r < 0) return r;
-
- if (NTYPE(*np) == NT_ANCHOR)
- NANCHOR(*np)->target = target;
- else {
- NENCLOSE(*np)->target = target;
- if (NENCLOSE(*np)->type == ENCLOSE_MEMORY) {
- /* Don't move this to previous of parse_subexp() */
- r = scan_env_set_mem_node(env, NENCLOSE(*np)->regnum, *np);
- if (r != 0) return r;
- }
- }
-
- *src = p;
- return 0;
-}
-
-static const char* PopularQStr[] = {
- "?", "*", "+", "??", "*?", "+?"
-};
-
-static const char* ReduceQStr[] = {
- "", "", "*", "*?", "??", "+ and ??", "+? and ?"
-};
-
-static int
-set_quantifier(Node* qnode, Node* target, int group, ScanEnv* env)
-{
- QtfrNode* qn;
-
- qn = NQTFR(qnode);
- if (qn->lower == 1 && qn->upper == 1) {
- return 1;
- }
-
- switch (NTYPE(target)) {
- case NT_STR:
- if (! group) {
- StrNode* sn = NSTR(target);
- if (str_node_can_be_split(sn, env->enc)) {
- Node* n = str_node_split_last_char(sn, env->enc);
- if (IS_NOT_NULL(n)) {
- qn->target = n;
- return 2;
- }
- }
- }
- break;
-
- case NT_QTFR:
- { /* check redundant double repeat. */
- /* verbose warn (?:.?)? etc... but not warn (.?)? etc... */
- QtfrNode* qnt = NQTFR(target);
- int nestq_num = popular_quantifier_num(qn);
- int targetq_num = popular_quantifier_num(qnt);
-
-#ifdef USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
- if (!IS_QUANTIFIER_BY_NUMBER(qn) && !IS_QUANTIFIER_BY_NUMBER(qnt) &&
- IS_SYNTAX_BV(env->syntax, ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT)) {
- UChar buf[WARN_BUFSIZE];
-
- switch(ReduceTypeTable[targetq_num][nestq_num]) {
- case RQ_ASIS:
- break;
-
- case RQ_DEL:
- if (onig_verb_warn != onig_null_warn) {
- onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
- env->pattern, env->pattern_end,
- (UChar* )"redundant nested repeat operator");
- (*onig_verb_warn)((char* )buf);
- }
- goto warn_exit;
- break;
-
- default:
- if (onig_verb_warn != onig_null_warn) {
- onig_snprintf_with_pattern(buf, WARN_BUFSIZE, env->enc,
- env->pattern, env->pattern_end,
- (UChar* )"nested repeat operator %s and %s was replaced with '%s'",
- PopularQStr[targetq_num], PopularQStr[nestq_num],
- ReduceQStr[ReduceTypeTable[targetq_num][nestq_num]]);
- (*onig_verb_warn)((char* )buf);
- }
- goto warn_exit;
- break;
- }
- }
-
- warn_exit:
-#endif
- if (targetq_num >= 0) {
- if (nestq_num >= 0) {
- onig_reduce_nested_quantifier(qnode, target);
- goto q_exit;
- }
- else if (targetq_num == 1 || targetq_num == 2) { /* * or + */
- /* (?:a*){n,m}, (?:a+){n,m} => (?:a*){n,n}, (?:a+){n,n} */
- if (! IS_REPEAT_INFINITE(qn->upper) && qn->upper > 1 && qn->greedy) {
- qn->upper = (qn->lower == 0 ? 1 : qn->lower);
- }
- }
- }
- }
- break;
-
- default:
- break;
- }
-
- qn->target = target;
- q_exit:
- return 0;
-}
-
-
-#ifdef USE_SHARED_CCLASS_TABLE
-
-#define THRESHOLD_RANGE_NUM_FOR_SHARE_CCLASS 8
-
-/* for ctype node hash table */
-
-typedef struct {
- OnigEncoding enc;
- int not;
- int type;
-} type_cclass_key;
-
-static int type_cclass_cmp(type_cclass_key* x, type_cclass_key* y)
-{
- if (x->type != y->type) return 1;
- if (x->enc != y->enc) return 1;
- if (x->not != y->not) return 1;
- return 0;
-}
-
-static int type_cclass_hash(type_cclass_key* key)
-{
- int i, val;
- UChar *p;
-
- val = 0;
-
- p = (UChar* )&(key->enc);
- for (i = 0; i < sizeof(key->enc); i++) {
- val = val * 997 + (int )*p++;
- }
-
- p = (UChar* )(&key->type);
- for (i = 0; i < sizeof(key->type); i++) {
- val = val * 997 + (int )*p++;
- }
-
- val += key->not;
- return val + (val >> 5);
-}
-
-static const struct st_hash_type type_type_cclass_hash = {
- type_cclass_cmp,
- type_cclass_hash,
-};
-
-static st_table* OnigTypeCClassTable;
-
-
-static int
-i_free_shared_class(type_cclass_key* key, Node* node, void* arg)
-{
- if (IS_NOT_NULL(node)) {
- CClassNode* cc = NCCLASS(node);
- if (IS_NOT_NULL(cc->mbuf)) xfree(cc->mbuf);
- xfree(node);
- }
-
- if (IS_NOT_NULL(key)) xfree(key);
- return ST_DELETE;
-}
-
-extern int
-onig_free_shared_cclass_table(void)
-{
- if (IS_NOT_NULL(OnigTypeCClassTable)) {
- onig_st_foreach(OnigTypeCClassTable, i_free_shared_class, 0);
- onig_st_free_table(OnigTypeCClassTable);
- OnigTypeCClassTable = NULL;
- }
-
- return 0;
-}
-
-#endif /* USE_SHARED_CCLASS_TABLE */
-
-
-typedef struct {
- ScanEnv* env;
- CClassNode* cc;
- Node* alt_root;
- Node** ptail;
-} IApplyCaseFoldArg;
-
-static int
-i_apply_case_fold(OnigCodePoint from, OnigCodePoint to[],
- int to_len, void* arg)
-{
- IApplyCaseFoldArg* iarg;
- ScanEnv* env;
- CClassNode* cc;
- BitSetRef bs;
-
- iarg = (IApplyCaseFoldArg* )arg;
- env = iarg->env;
- cc = iarg->cc;
- bs = cc->bs;
-
- if (to_len == 1) {
- int in_cc;
- in_cc = onig_is_code_in_cc(env->enc, from, cc);
- if ((in_cc != 0 && !IS_NCCLASS_NOT(cc)) ||
- (in_cc == 0 && IS_NCCLASS_NOT(cc))) {
- if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) {
- if (IS_NCCLASS_NOT(cc)) clear_not_flag_cclass(cc, env->enc);
- add_code_range(&(cc->mbuf), env, *to, *to);
- }
- else {
- /* /(?i:[^A-C])/.match("a") ==> fail. */
- BITSET_SET_BIT(bs, *to);
- }
- }
- }
- else {
- int r, i, len;
- UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
- Node *snode = NULL_NODE;
-
- if (onig_is_code_in_cc(env->enc, from, cc)) {
- if (IS_NCCLASS_NOT(cc)) clear_not_flag_cclass(cc, env->enc);
-
- for (i = 0; i < to_len; i++) {
- len = ONIGENC_CODE_TO_MBC(env->enc, to[i], buf);
- if (i == 0) {
- snode = onig_node_new_str(buf, buf + len);
- CHECK_NULL_RETURN_MEMERR(snode);
-
- /* char-class expanded multi-char only
- compare with string folded at match time. */
- NSTRING_SET_AMBIG(snode);
- }
- else {
- r = onig_node_str_cat(snode, buf, buf + len);
- if (r < 0) {
- onig_node_free(snode);
- return r;
- }
- }
- }
-
- *(iarg->ptail) = onig_node_new_alt(snode, NULL_NODE);
- CHECK_NULL_RETURN_MEMERR(*(iarg->ptail));
- iarg->ptail = &(NCDR((*(iarg->ptail))));
- }
- }
-
- return 0;
-}
-
-static int
-parse_exp(Node** np, OnigToken* tok, int term,
- UChar** src, UChar* end, ScanEnv* env)
-{
- int r, len, group = 0;
- Node* qn;
- Node** targetp;
-
- *np = NULL;
- if (tok->type == term)
- goto end_of_token;
-
- switch (tok->type) {
- case TK_ALT:
- case TK_EOT:
- end_of_token:
- *np = node_new_empty();
- return tok->type;
- break;
-
- case TK_SUBEXP_OPEN:
- r = parse_enclose(np, tok, TK_SUBEXP_CLOSE, src, end, env);
- if (r < 0) return r;
- if (r == 1) group = 1;
- else if (r == 2) { /* option only */
- Node* target;
- OnigOptionType prev = env->option;
-
- env->option = NENCLOSE(*np)->option;
- r = fetch_token(tok, src, end, env);
- if (r < 0) return r;
- r = parse_subexp(&target, tok, term, src, end, env);
- env->option = prev;
- if (r < 0) return r;
- NENCLOSE(*np)->target = target;
- return tok->type;
- }
- break;
-
- case TK_SUBEXP_CLOSE:
- if (! IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP))
- return ONIGERR_UNMATCHED_CLOSE_PARENTHESIS;
-
- if (tok->escaped) goto tk_raw_byte;
- else goto tk_byte;
- break;
-
- case TK_STRING:
- tk_byte:
- {
- *np = node_new_str(tok->backp, *src);
- CHECK_NULL_RETURN_MEMERR(*np);
-
- while (1) {
- r = fetch_token(tok, src, end, env);
- if (r < 0) return r;
- if (r != TK_STRING) break;
-
- r = onig_node_str_cat(*np, tok->backp, *src);
- if (r < 0) return r;
- }
-
- string_end:
- targetp = np;
- goto repeat;
- }
- break;
-
- case TK_RAW_BYTE:
- tk_raw_byte:
- {
- *np = node_new_str_raw_char((UChar )tok->u.c);
- CHECK_NULL_RETURN_MEMERR(*np);
- len = 1;
- while (1) {
- if (len >= ONIGENC_MBC_MINLEN(env->enc)) {
- if (len == enc_len(env->enc, NSTR(*np)->s, NSTR(*np)->end)) {
- r = fetch_token(tok, src, end, env);
- NSTRING_CLEAR_RAW(*np);
- goto string_end;
- }
- }
-
- r = fetch_token(tok, src, end, env);
- if (r < 0) return r;
- if (r != TK_RAW_BYTE) {
- /* Don't use this, it is wrong for little endian encodings. */
-#ifdef USE_PAD_TO_SHORT_BYTE_CHAR
- int rem;
- if (len < ONIGENC_MBC_MINLEN(env->enc)) {
- rem = ONIGENC_MBC_MINLEN(env->enc) - len;
- (void )node_str_head_pad(NSTR(*np), rem, (UChar )0);
- if (len + rem == enc_len(env->enc, NSTR(*np)->s)) {
- NSTRING_CLEAR_RAW(*np);
- goto string_end;
- }
- }
-#endif
- return ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
- }
-
- r = node_str_cat_char(*np, (UChar )tok->u.c);
- if (r < 0) return r;
-
- len++;
- }
- }
- break;
-
- case TK_CODE_POINT:
- {
- UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN];
- int num = ONIGENC_CODE_TO_MBC(env->enc, tok->u.code, buf);
- if (num < 0) return num;
-#ifdef NUMBERED_CHAR_IS_NOT_CASE_AMBIG
- *np = node_new_str_raw(buf, buf + num);
-#else
- *np = node_new_str(buf, buf + num);
-#endif
- CHECK_NULL_RETURN_MEMERR(*np);
- }
- break;
-
- case TK_QUOTE_OPEN:
- {
- OnigCodePoint end_op[2];
- UChar *qstart, *qend, *nextp;
-
- end_op[0] = (OnigCodePoint )MC_ESC(env->syntax);
- end_op[1] = (OnigCodePoint )'E';
- qstart = *src;
- qend = find_str_position(end_op, 2, qstart, end, &nextp, env->enc);
- if (IS_NULL(qend)) {
- nextp = qend = end;
- }
- *np = node_new_str(qstart, qend);
- CHECK_NULL_RETURN_MEMERR(*np);
- *src = nextp;
- }
- break;
-
- case TK_CHAR_TYPE:
- {
- switch (tok->u.prop.ctype) {
- case ONIGENC_CTYPE_WORD:
- *np = node_new_ctype(tok->u.prop.ctype, tok->u.prop.not);
- CHECK_NULL_RETURN_MEMERR(*np);
- break;
-
- case ONIGENC_CTYPE_SPACE:
- case ONIGENC_CTYPE_DIGIT:
- case ONIGENC_CTYPE_XDIGIT:
- {
- CClassNode* cc;
-
-#ifdef USE_SHARED_CCLASS_TABLE
- const OnigCodePoint *mbr;
- OnigCodePoint sb_out;
-
- r = ONIGENC_GET_CTYPE_CODE_RANGE(env->enc, tok->u.prop.ctype,
- &sb_out, &mbr);
- if (r == 0 &&
- ONIGENC_CODE_RANGE_NUM(mbr)
- >= THRESHOLD_RANGE_NUM_FOR_SHARE_CCLASS) {
- type_cclass_key key;
- type_cclass_key* new_key;
-
- key.enc = env->enc;
- key.not = tok->u.prop.not;
- key.type = tok->u.prop.ctype;
-
- THREAD_ATOMIC_START;
-
- if (IS_NULL(OnigTypeCClassTable)) {
- OnigTypeCClassTable
- = onig_st_init_table_with_size(&type_type_cclass_hash, 10);
- if (IS_NULL(OnigTypeCClassTable)) {
- THREAD_ATOMIC_END;
- return ONIGERR_MEMORY;
- }
- }
- else {
- if (onig_st_lookup(OnigTypeCClassTable, (st_data_t )&key,
- (st_data_t* )np)) {
- THREAD_ATOMIC_END;
- break;
- }
- }
-
- *np = node_new_cclass_by_codepoint_range(tok->u.prop.not,
- sb_out, mbr);
- if (IS_NULL(*np)) {
- THREAD_ATOMIC_END;
- return ONIGERR_MEMORY;
- }
-
- cc = NCCLASS(*np);
- NCCLASS_SET_SHARE(cc);
- new_key = (type_cclass_key* )xmalloc(sizeof(type_cclass_key));
- xmemcpy(new_key, &key, sizeof(type_cclass_key));
- onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
- (st_data_t )*np);
-
- THREAD_ATOMIC_END;
- }
- else {
-#endif
- *np = node_new_cclass();
- CHECK_NULL_RETURN_MEMERR(*np);
- cc = NCCLASS(*np);
- add_ctype_to_cc(cc, tok->u.prop.ctype, 0, env);
- if (tok->u.prop.not != 0) NCCLASS_SET_NOT(cc);
-#ifdef USE_SHARED_CCLASS_TABLE
- }
-#endif
- }
- break;
-
- default:
- return ONIGERR_PARSER_BUG;
- break;
- }
- }
- break;
-
- case TK_CHAR_PROPERTY:
- r = parse_char_property(np, tok, src, end, env);
- if (r != 0) return r;
- break;
-
- case TK_CC_OPEN:
- {
- CClassNode* cc;
-
- r = parse_char_class(np, tok, src, end, env);
- if (r != 0) return r;
-
- cc = NCCLASS(*np);
- if (IS_IGNORECASE(env->option)) {
- IApplyCaseFoldArg iarg;
-
- iarg.env = env;
- iarg.cc = cc;
- iarg.alt_root = NULL_NODE;
- iarg.ptail = &(iarg.alt_root);
-
- r = ONIGENC_APPLY_ALL_CASE_FOLD(env->enc, env->case_fold_flag,
- i_apply_case_fold, &iarg);
- if (r != 0) {
- onig_node_free(iarg.alt_root);
- return r;
- }
- if (IS_NOT_NULL(iarg.alt_root)) {
- Node* work = onig_node_new_alt(*np, iarg.alt_root);
- if (IS_NULL(work)) {
- onig_node_free(iarg.alt_root);
- return ONIGERR_MEMORY;
- }
- *np = work;
- }
- }
- }
- break;
-
- case TK_ANYCHAR:
- *np = node_new_anychar();
- CHECK_NULL_RETURN_MEMERR(*np);
- break;
-
- case TK_ANYCHAR_ANYTIME:
- *np = node_new_anychar();
- CHECK_NULL_RETURN_MEMERR(*np);
- qn = node_new_quantifier(0, REPEAT_INFINITE, 0);
- CHECK_NULL_RETURN_MEMERR(qn);
- NQTFR(qn)->target = *np;
- *np = qn;
- break;
-
- case TK_BACKREF:
- len = tok->u.backref.num;
- *np = node_new_backref(len,
- (len > 1 ? tok->u.backref.refs : &(tok->u.backref.ref1)),
- tok->u.backref.by_name,
-#ifdef USE_BACKREF_AT_LEVEL
- tok->u.backref.exist_level,
- tok->u.backref.level,
-#endif
- env);
- CHECK_NULL_RETURN_MEMERR(*np);
- break;
-
-#ifdef USE_SUBEXP_CALL
- case TK_CALL:
- *np = node_new_call(tok->u.call.name, tok->u.call.name_end);
- CHECK_NULL_RETURN_MEMERR(*np);
- env->num_call++;
- break;
-#endif
-
- case TK_ANCHOR:
- *np = onig_node_new_anchor(tok->u.anchor);
- break;
-
- case TK_OP_REPEAT:
- case TK_INTERVAL:
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS)) {
- if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS))
- return ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED;
- else
- *np = node_new_empty();
- }
- else {
- goto tk_byte;
- }
- break;
-
- default:
- return ONIGERR_PARSER_BUG;
- break;
- }
-
- {
- targetp = np;
-
- re_entry:
- r = fetch_token(tok, src, end, env);
- if (r < 0) return r;
-
- repeat:
- if (r == TK_OP_REPEAT || r == TK_INTERVAL) {
- if (is_invalid_quantifier_target(*targetp))
- return ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID;
-
- qn = node_new_quantifier(tok->u.repeat.lower, tok->u.repeat.upper,
- (r == TK_INTERVAL ? 1 : 0));
- CHECK_NULL_RETURN_MEMERR(qn);
- NQTFR(qn)->greedy = tok->u.repeat.greedy;
- r = set_quantifier(qn, *targetp, group, env);
- if (r < 0) return r;
-
- if (tok->u.repeat.possessive != 0) {
- Node* en;
- en = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
- CHECK_NULL_RETURN_MEMERR(en);
- NENCLOSE(en)->target = qn;
- qn = en;
- }
-
- if (r == 0) {
- *targetp = qn;
- }
- else if (r == 2) { /* split case: /abc+/ */
- Node *tmp;
-
- *targetp = node_new_list(*targetp, NULL);
- CHECK_NULL_RETURN_MEMERR(*targetp);
- tmp = NCDR(*targetp) = node_new_list(qn, NULL);
- CHECK_NULL_RETURN_MEMERR(tmp);
- targetp = &(NCAR(tmp));
- }
- goto re_entry;
- }
- }
-
- return r;
-}
-
-static int
-parse_branch(Node** top, OnigToken* tok, int term,
- UChar** src, UChar* end, ScanEnv* env)
-{
- int r;
- Node *node, **headp;
-
- *top = NULL;
- r = parse_exp(&node, tok, term, src, end, env);
- if (r < 0) return r;
-
- if (r == TK_EOT || r == term || r == TK_ALT) {
- *top = node;
- }
- else {
- *top = node_new_list(node, NULL);
- headp = &(NCDR(*top));
- while (r != TK_EOT && r != term && r != TK_ALT) {
- r = parse_exp(&node, tok, term, src, end, env);
- if (r < 0) return r;
-
- if (NTYPE(node) == NT_LIST) {
- *headp = node;
- while (IS_NOT_NULL(NCDR(node))) node = NCDR(node);
- headp = &(NCDR(node));
- }
- else {
- *headp = node_new_list(node, NULL);
- headp = &(NCDR(*headp));
- }
- }
- }
-
- return r;
-}
-
-/* term_tok: TK_EOT or TK_SUBEXP_CLOSE */
-static int
-parse_subexp(Node** top, OnigToken* tok, int term,
- UChar** src, UChar* end, ScanEnv* env)
-{
- int r;
- Node *node, **headp;
-
- *top = NULL;
- r = parse_branch(&node, tok, term, src, end, env);
- if (r < 0) {
- onig_node_free(node);
- return r;
- }
-
- if (r == term) {
- *top = node;
- }
- else if (r == TK_ALT) {
- *top = onig_node_new_alt(node, NULL);
- headp = &(NCDR(*top));
- while (r == TK_ALT) {
- r = fetch_token(tok, src, end, env);
- if (r < 0) return r;
- r = parse_branch(&node, tok, term, src, end, env);
- if (r < 0) return r;
-
- *headp = onig_node_new_alt(node, NULL);
- headp = &(NCDR(*headp));
- }
-
- if (tok->type != term)
- goto err;
- }
- else {
- err:
- if (term == TK_SUBEXP_CLOSE)
- return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS;
- else
- return ONIGERR_PARSER_BUG;
- }
-
- return r;
-}
-
-static int
-parse_regexp(Node** top, UChar** src, UChar* end, ScanEnv* env)
-{
- int r;
- OnigToken tok;
-
- r = fetch_token(&tok, src, end, env);
- if (r < 0) return r;
- r = parse_subexp(top, &tok, TK_EOT, src, end, env);
- if (r < 0) return r;
- return 0;
-}
-
-extern int
-onig_parse_make_tree(Node** root, const UChar* pattern, const UChar* end,
- regex_t* reg, ScanEnv* env)
-{
- int r;
- UChar* p;
-
-#ifdef USE_NAMED_GROUP
- names_clear(reg);
-#endif
-
- scan_env_clear(env);
- env->option = reg->options;
- env->case_fold_flag = reg->case_fold_flag;
- env->enc = reg->enc;
- env->syntax = reg->syntax;
- env->pattern = (UChar* )pattern;
- env->pattern_end = (UChar* )end;
- env->reg = reg;
-
- *root = NULL;
- p = (UChar* )pattern;
- r = parse_regexp(root, &p, (UChar* )end, env);
- reg->num_mem = env->num_mem;
- return r;
-}
-
-extern void
-onig_scan_env_set_error_string(ScanEnv* env, int ecode,
- UChar* arg, UChar* arg_end)
-{
- env->error = arg;
- env->error_end = arg_end;
-}
diff --git a/regparse.h b/regparse.h
deleted file mode 100644
index 7a6314098a..0000000000
--- a/regparse.h
+++ /dev/null
@@ -1,350 +0,0 @@
-#ifndef REGPARSE_H
-#define REGPARSE_H
-/**********************************************************************
- regparse.h - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-/* node type */
-#define NT_STR 0
-#define NT_CCLASS 1
-#define NT_CTYPE 2
-#define NT_CANY 3
-#define NT_BREF 4
-#define NT_QTFR 5
-#define NT_ENCLOSE 6
-#define NT_ANCHOR 7
-#define NT_LIST 8
-#define NT_ALT 9
-#define NT_CALL 10
-
-/* node type bit */
-#define NTYPE2BIT(type) (1<<(type))
-
-#define BIT_NT_STR NTYPE2BIT(NT_STR)
-#define BIT_NT_CCLASS NTYPE2BIT(NT_CCLASS)
-#define BIT_NT_CTYPE NTYPE2BIT(NT_CTYPE)
-#define BIT_NT_CANY NTYPE2BIT(NT_CANY)
-#define BIT_NT_BREF NTYPE2BIT(NT_BREF)
-#define BIT_NT_QTFR NTYPE2BIT(NT_QTFR)
-#define BIT_NT_ENCLOSE NTYPE2BIT(NT_ENCLOSE)
-#define BIT_NT_ANCHOR NTYPE2BIT(NT_ANCHOR)
-#define BIT_NT_LIST NTYPE2BIT(NT_LIST)
-#define BIT_NT_ALT NTYPE2BIT(NT_ALT)
-#define BIT_NT_CALL NTYPE2BIT(NT_CALL)
-
-#define IS_NODE_TYPE_SIMPLE(type) \
- ((NTYPE2BIT(type) & (BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE |\
- BIT_NT_CANY | BIT_NT_BREF)) != 0)
-
-#define NTYPE(node) ((node)->u.base.type)
-#define SET_NTYPE(node, ntype) (node)->u.base.type = (ntype)
-
-#define NSTR(node) (&((node)->u.str))
-#define NCCLASS(node) (&((node)->u.cclass))
-#define NCTYPE(node) (&((node)->u.ctype))
-#define NBREF(node) (&((node)->u.bref))
-#define NQTFR(node) (&((node)->u.qtfr))
-#define NENCLOSE(node) (&((node)->u.enclose))
-#define NANCHOR(node) (&((node)->u.anchor))
-#define NCONS(node) (&((node)->u.cons))
-#define NCALL(node) (&((node)->u.call))
-
-#define NCAR(node) (NCONS(node)->car)
-#define NCDR(node) (NCONS(node)->cdr)
-
-
-
-#define ANCHOR_ANYCHAR_STAR_MASK (ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML)
-#define ANCHOR_END_BUF_MASK (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)
-
-#define ENCLOSE_MEMORY (1<<0)
-#define ENCLOSE_OPTION (1<<1)
-#define ENCLOSE_STOP_BACKTRACK (1<<2)
-
-#define NODE_STR_MARGIN 16
-#define NODE_STR_BUF_SIZE 24 /* sizeof(CClassNode) - sizeof(int)*4 */
-#define NODE_BACKREFS_SIZE 6
-
-#define NSTR_RAW (1<<0) /* by backslashed number */
-#define NSTR_AMBIG (1<<1)
-#define NSTR_DONT_GET_OPT_INFO (1<<2)
-
-#define NSTRING_LEN(node) ((node)->u.str.end - (node)->u.str.s)
-#define NSTRING_SET_RAW(node) (node)->u.str.flag |= NSTR_RAW
-#define NSTRING_CLEAR_RAW(node) (node)->u.str.flag &= ~NSTR_RAW
-#define NSTRING_SET_AMBIG(node) (node)->u.str.flag |= NSTR_AMBIG
-#define NSTRING_SET_DONT_GET_OPT_INFO(node) \
- (node)->u.str.flag |= NSTR_DONT_GET_OPT_INFO
-#define NSTRING_IS_RAW(node) (((node)->u.str.flag & NSTR_RAW) != 0)
-#define NSTRING_IS_AMBIG(node) (((node)->u.str.flag & NSTR_AMBIG) != 0)
-#define NSTRING_IS_DONT_GET_OPT_INFO(node) \
- (((node)->u.str.flag & NSTR_DONT_GET_OPT_INFO) != 0)
-
-#define BACKREFS_P(br) \
- (IS_NOT_NULL((br)->back_dynamic) ? (br)->back_dynamic : (br)->back_static);
-
-#define NQ_TARGET_ISNOT_EMPTY 0
-#define NQ_TARGET_IS_EMPTY 1
-#define NQ_TARGET_IS_EMPTY_MEM 2
-#define NQ_TARGET_IS_EMPTY_REC 3
-
-/* status bits */
-#define NST_MIN_FIXED (1<<0)
-#define NST_MAX_FIXED (1<<1)
-#define NST_CLEN_FIXED (1<<2)
-#define NST_MARK1 (1<<3)
-#define NST_MARK2 (1<<4)
-#define NST_MEM_BACKREFED (1<<5)
-#define NST_STOP_BT_SIMPLE_REPEAT (1<<6)
-#define NST_RECURSION (1<<7)
-#define NST_CALLED (1<<8)
-#define NST_ADDR_FIXED (1<<9)
-#define NST_NAMED_GROUP (1<<10)
-#define NST_NAME_REF (1<<11)
-#define NST_IN_REPEAT (1<<12) /* STK_REPEAT is nested in stack. */
-#define NST_NEST_LEVEL (1<<13)
-#define NST_BY_NUMBER (1<<14) /* {n,m} */
-
-#define SET_ENCLOSE_STATUS(node,f) (node)->u.enclose.state |= (f)
-#define CLEAR_ENCLOSE_STATUS(node,f) (node)->u.enclose.state &= ~(f)
-
-#define IS_ENCLOSE_CALLED(en) (((en)->state & NST_CALLED) != 0)
-#define IS_ENCLOSE_ADDR_FIXED(en) (((en)->state & NST_ADDR_FIXED) != 0)
-#define IS_ENCLOSE_RECURSION(en) (((en)->state & NST_RECURSION) != 0)
-#define IS_ENCLOSE_MARK1(en) (((en)->state & NST_MARK1) != 0)
-#define IS_ENCLOSE_MARK2(en) (((en)->state & NST_MARK2) != 0)
-#define IS_ENCLOSE_MIN_FIXED(en) (((en)->state & NST_MIN_FIXED) != 0)
-#define IS_ENCLOSE_MAX_FIXED(en) (((en)->state & NST_MAX_FIXED) != 0)
-#define IS_ENCLOSE_CLEN_FIXED(en) (((en)->state & NST_CLEN_FIXED) != 0)
-#define IS_ENCLOSE_STOP_BT_SIMPLE_REPEAT(en) \
- (((en)->state & NST_STOP_BT_SIMPLE_REPEAT) != 0)
-#define IS_ENCLOSE_NAMED_GROUP(en) (((en)->state & NST_NAMED_GROUP) != 0)
-
-#define SET_CALL_RECURSION(node) (node)->u.call.state |= NST_RECURSION
-#define IS_CALL_RECURSION(cn) (((cn)->state & NST_RECURSION) != 0)
-#define IS_CALL_NAME_REF(cn) (((cn)->state & NST_NAME_REF) != 0)
-#define IS_BACKREF_NAME_REF(bn) (((bn)->state & NST_NAME_REF) != 0)
-#define IS_BACKREF_NEST_LEVEL(bn) (((bn)->state & NST_NEST_LEVEL) != 0)
-#define IS_QUANTIFIER_IN_REPEAT(qn) (((qn)->state & NST_IN_REPEAT) != 0)
-#define IS_QUANTIFIER_BY_NUMBER(qn) (((qn)->state & NST_BY_NUMBER) != 0)
-
-#define CALLNODE_REFNUM_UNDEF -1
-
-typedef struct {
- NodeBase base;
- UChar* s;
- UChar* end;
- unsigned int flag;
- int capa; /* (allocated size - 1) or 0: use buf[] */
- UChar buf[NODE_STR_BUF_SIZE];
-} StrNode;
-
-typedef struct {
- NodeBase base;
- int state;
- struct _Node* target;
- int lower;
- int upper;
- int greedy;
- int target_empty_info;
- struct _Node* head_exact;
- struct _Node* next_head_exact;
- int is_refered; /* include called node. don't eliminate even if {0} */
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- int comb_exp_check_num; /* 1,2,3...: check, 0: no check */
-#endif
-} QtfrNode;
-
-typedef struct {
- NodeBase base;
- int state;
- int type;
- int regnum;
- OnigOptionType option;
- struct _Node* target;
- AbsAddrType call_addr;
- /* for multiple call reference */
- OnigDistance min_len; /* min length (byte) */
- OnigDistance max_len; /* max length (byte) */
- int char_len; /* character length */
- int opt_count; /* referenced count in optimize_node_left() */
-} EncloseNode;
-
-#ifdef USE_SUBEXP_CALL
-
-typedef struct {
- int offset;
- struct _Node* target;
-} UnsetAddr;
-
-typedef struct {
- int num;
- int alloc;
- UnsetAddr* us;
-} UnsetAddrList;
-
-typedef struct {
- NodeBase base;
- int state;
- int ref_num;
- UChar* name;
- UChar* name_end;
- struct _Node* target; /* EncloseNode : ENCLOSE_MEMORY */
- UnsetAddrList* unset_addr_list;
-} CallNode;
-
-#endif
-
-typedef struct {
- NodeBase base;
- int state;
- int back_num;
- int back_static[NODE_BACKREFS_SIZE];
- int* back_dynamic;
- int nest_level;
-} BRefNode;
-
-typedef struct {
- NodeBase base;
- int type;
- struct _Node* target;
- int char_len;
-} AnchorNode;
-
-typedef struct {
- NodeBase base;
- struct _Node* car;
- struct _Node* cdr;
-} ConsAltNode;
-
-typedef struct {
- NodeBase base;
- int ctype;
- int not;
-} CtypeNode;
-
-typedef struct _Node {
- union {
- NodeBase base;
- StrNode str;
- CClassNode cclass;
- QtfrNode qtfr;
- EncloseNode enclose;
- BRefNode bref;
- AnchorNode anchor;
- ConsAltNode cons;
- CtypeNode ctype;
-#ifdef USE_SUBEXP_CALL
- CallNode call;
-#endif
- } u;
-} Node;
-
-
-#define NULL_NODE ((Node* )0)
-
-#define SCANENV_MEMNODES_SIZE 8
-#define SCANENV_MEM_NODES(senv) \
- (IS_NOT_NULL((senv)->mem_nodes_dynamic) ? \
- (senv)->mem_nodes_dynamic : (senv)->mem_nodes_static)
-
-typedef struct {
- OnigOptionType option;
- OnigCaseFoldType case_fold_flag;
- OnigEncoding enc;
- OnigSyntaxType* syntax;
- BitStatusType capture_history;
- BitStatusType bt_mem_start;
- BitStatusType bt_mem_end;
- BitStatusType backrefed_mem;
- UChar* pattern;
- UChar* pattern_end;
- UChar* error;
- UChar* error_end;
- regex_t* reg; /* for reg->names only */
- int num_call;
-#ifdef USE_SUBEXP_CALL
- UnsetAddrList* unset_addr_list;
-#endif
- int num_mem;
-#ifdef USE_NAMED_GROUP
- int num_named;
-#endif
- int mem_alloc;
- Node* mem_nodes_static[SCANENV_MEMNODES_SIZE];
- Node** mem_nodes_dynamic;
-#ifdef USE_COMBINATION_EXPLOSION_CHECK
- int num_comb_exp_check;
- int comb_exp_max_regnum;
- int curr_max_regnum;
- int has_recursion;
-#endif
-} ScanEnv;
-
-
-#define IS_SYNTAX_OP(syn, opm) (((syn)->op & (opm)) != 0)
-#define IS_SYNTAX_OP2(syn, opm) (((syn)->op2 & (opm)) != 0)
-#define IS_SYNTAX_BV(syn, bvm) (((syn)->behavior & (bvm)) != 0)
-
-#ifdef USE_NAMED_GROUP
-typedef struct {
- int new_val;
-} GroupNumRemap;
-
-extern int onig_renumber_name_table P_((regex_t* reg, GroupNumRemap* map));
-#endif
-
-extern int onig_strncmp P_((const UChar* s1, const UChar* s2, int n));
-extern void onig_strcpy P_((UChar* dest, const UChar* src, const UChar* end));
-extern void onig_scan_env_set_error_string P_((ScanEnv* env, int ecode, UChar* arg, UChar* arg_end));
-extern int onig_scan_unsigned_number P_((UChar** src, const UChar* end, OnigEncoding enc));
-extern void onig_reduce_nested_quantifier P_((Node* pnode, Node* cnode));
-extern void onig_node_conv_to_str_node P_((Node* node, int raw));
-extern int onig_node_str_cat P_((Node* node, const UChar* s, const UChar* end));
-extern int onig_node_str_set P_((Node* node, const UChar* s, const UChar* end));
-extern void onig_node_free P_((Node* node));
-extern Node* onig_node_new_enclose P_((int type));
-extern Node* onig_node_new_anchor P_((int type));
-extern Node* onig_node_new_str P_((const UChar* s, const UChar* end));
-extern Node* onig_node_new_list P_((Node* left, Node* right));
-extern Node* onig_node_list_add P_((Node* list, Node* x));
-extern Node* onig_node_new_alt P_((Node* left, Node* right));
-extern void onig_node_str_clear P_((Node* node));
-extern int onig_free_node_list P_((void));
-extern int onig_names_free P_((regex_t* reg));
-extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env));
-
-#ifdef ONIG_DEBUG
-#ifdef USE_NAMED_GROUP
-extern int onig_print_names(FILE*, regex_t*);
-#endif
-#endif
-
-#endif /* REGPARSE_H */
diff --git a/regsyntax.c b/regsyntax.c
deleted file mode 100644
index ade5b55f77..0000000000
--- a/regsyntax.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/**********************************************************************
- regsyntax.c - Oniguruma (regular expression library)
-**********************************************************************/
-/*-
- * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "regint.h"
-
-OnigSyntaxType OnigSyntaxASIS = {
- 0
- , ONIG_SYN_OP2_INEFFECTIVE_ESCAPE
- , 0
- , ONIG_OPTION_NONE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxPosixBasic = {
- ( SYN_POSIX_COMMON_OP | ONIG_SYN_OP_ESC_LPAREN_SUBEXP |
- ONIG_SYN_OP_ESC_BRACE_INTERVAL )
- , 0
- , 0
- , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxPosixExtended = {
- ( SYN_POSIX_COMMON_OP | ONIG_SYN_OP_LPAREN_SUBEXP |
- ONIG_SYN_OP_BRACE_INTERVAL |
- ONIG_SYN_OP_PLUS_ONE_INF | ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_VBAR_ALT )
- , 0
- , ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
- ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
- ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP |
- ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
- , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxEmacs = {
- ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC |
- ONIG_SYN_OP_ESC_BRACE_INTERVAL |
- ONIG_SYN_OP_ESC_LPAREN_SUBEXP | ONIG_SYN_OP_ESC_VBAR_ALT |
- ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF |
- ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_DECIMAL_BACKREF |
- ONIG_SYN_OP_LINE_ANCHOR | ONIG_SYN_OP_ESC_CONTROL_CHARS )
- , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR
- , ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC
- , ONIG_OPTION_NONE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxGrep = {
- ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_POSIX_BRACKET |
- ONIG_SYN_OP_ESC_BRACE_INTERVAL | ONIG_SYN_OP_ESC_LPAREN_SUBEXP |
- ONIG_SYN_OP_ESC_VBAR_ALT |
- ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_ESC_PLUS_ONE_INF |
- ONIG_SYN_OP_ESC_QMARK_ZERO_ONE | ONIG_SYN_OP_LINE_ANCHOR |
- ONIG_SYN_OP_ESC_W_WORD | ONIG_SYN_OP_ESC_B_WORD_BOUND |
- ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | ONIG_SYN_OP_DECIMAL_BACKREF )
- , 0
- , ( ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC | ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC )
- , ONIG_OPTION_NONE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxGnuRegex = {
- SYN_GNU_REGEX_OP
- , 0
- , SYN_GNU_REGEX_BV
- , ONIG_OPTION_NONE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxJava = {
- (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
- ONIG_SYN_OP_ESC_CONTROL_CHARS | ONIG_SYN_OP_ESC_C_CONTROL |
- ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 )
- & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
- , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE | ONIG_SYN_OP2_QMARK_GROUP_EFFECT |
- ONIG_SYN_OP2_OPTION_PERL | ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
- ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL | ONIG_SYN_OP2_CCLASS_SET_OP |
- ONIG_SYN_OP2_ESC_V_VTAB | ONIG_SYN_OP2_ESC_U_HEX4 |
- ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY )
- , ( SYN_GNU_REGEX_BV | ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND )
- , ONIG_OPTION_SINGLELINE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-OnigSyntaxType OnigSyntaxPerl = {
- (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
- ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
- ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
- ONIG_SYN_OP_ESC_C_CONTROL )
- & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
- , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
- ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
- ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
- ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT )
- , SYN_GNU_REGEX_BV
- , ONIG_OPTION_SINGLELINE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-/* Perl + named group */
-OnigSyntaxType OnigSyntaxPerl_NG = {
- (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
- ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
- ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
- ONIG_SYN_OP_ESC_C_CONTROL )
- & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
- , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
- ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
- ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
- ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
- ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP |
- ONIG_SYN_OP2_ESC_K_NAMED_BACKREF |
- ONIG_SYN_OP2_ESC_G_SUBEXP_CALL )
- , ( SYN_GNU_REGEX_BV |
- ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
- ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME )
- , ONIG_OPTION_SINGLELINE
- ,
- {
- (OnigCodePoint )'\\' /* esc */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
- , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
- }
-};
-
-
-
-extern int
-onig_set_default_syntax(OnigSyntaxType* syntax)
-{
- if (IS_NULL(syntax))
- syntax = ONIG_SYNTAX_RUBY;
-
- OnigDefaultSyntax = syntax;
- return 0;
-}
-
-extern void
-onig_copy_syntax(OnigSyntaxType* to, OnigSyntaxType* from)
-{
- *to = *from;
-}
-
-extern void
-onig_set_syntax_op(OnigSyntaxType* syntax, unsigned int op)
-{
- syntax->op = op;
-}
-
-extern void
-onig_set_syntax_op2(OnigSyntaxType* syntax, unsigned int op2)
-{
- syntax->op2 = op2;
-}
-
-extern void
-onig_set_syntax_behavior(OnigSyntaxType* syntax, unsigned int behavior)
-{
- syntax->behavior = behavior;
-}
-
-extern void
-onig_set_syntax_options(OnigSyntaxType* syntax, OnigOptionType options)
-{
- syntax->options = options;
-}
-
-extern unsigned int
-onig_get_syntax_op(OnigSyntaxType* syntax)
-{
- return syntax->op;
-}
-
-extern unsigned int
-onig_get_syntax_op2(OnigSyntaxType* syntax)
-{
- return syntax->op2;
-}
-
-extern unsigned int
-onig_get_syntax_behavior(OnigSyntaxType* syntax)
-{
- return syntax->behavior;
-}
-
-extern OnigOptionType
-onig_get_syntax_options(OnigSyntaxType* syntax)
-{
- return syntax->options;
-}
-
-#ifdef USE_VARIABLE_META_CHARS
-extern int onig_set_meta_char(OnigSyntaxType* enc,
- unsigned int what, OnigCodePoint code)
-{
- switch (what) {
- case ONIG_META_CHAR_ESCAPE:
- enc->meta_char_table.esc = code;
- break;
- case ONIG_META_CHAR_ANYCHAR:
- enc->meta_char_table.anychar = code;
- break;
- case ONIG_META_CHAR_ANYTIME:
- enc->meta_char_table.anytime = code;
- break;
- case ONIG_META_CHAR_ZERO_OR_ONE_TIME:
- enc->meta_char_table.zero_or_one_time = code;
- break;
- case ONIG_META_CHAR_ONE_OR_MORE_TIME:
- enc->meta_char_table.one_or_more_time = code;
- break;
- case ONIG_META_CHAR_ANYCHAR_ANYTIME:
- enc->meta_char_table.anychar_anytime = code;
- break;
- default:
- return ONIGERR_INVALID_ARGUMENT;
- break;
- }
- return 0;
-}
-#endif /* USE_VARIABLE_META_CHARS */
diff --git a/ruby.c b/ruby.c
index 94aba59008..fab9cc47d7 100644
--- a/ruby.c
+++ b/ruby.c
@@ -6,25 +6,25 @@
$Date$
created at: Tue Aug 10 12:47:31 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#ifdef __CYGWIN__
+#if defined _WIN32 || defined __CYGWIN__
#include <windows.h>
+#endif
+#if defined __CYGWIN__
#include <sys/cygwin.h>
#endif
#ifdef _WIN32_WCE
#include <winsock.h>
-#include "ruby/wince.h"
+#include "wince.h"
#endif
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "ruby/encoding.h"
-#include "eval_intern.h"
+#include "ruby.h"
#include "dln.h"
+#include "node.h"
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
@@ -36,98 +36,73 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if defined(HAVE_FCNTL_H)
-#include <fcntl.h>
-#elif defined(HAVE_SYS_FCNTL_H)
-#include <sys/fcntl.h>
-#endif
-#ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-#ifndef MAXPATHLEN
-# define MAXPATHLEN 1024
-#endif
-#if defined(__MACOS__) && defined(__MWERKS__)
-#include <console.h>
+#ifndef HAVE_STRING_H
+char *strchr _((const char*,const char));
+char *strrchr _((const char*,const char));
+char *strstr _((const char*,const char*));
#endif
-#include "ruby/util.h"
+#include "util.h"
#ifndef HAVE_STDLIB_H
char *getenv();
#endif
-/* TODO: move to VM */
VALUE ruby_debug = Qfalse;
VALUE ruby_verbose = Qfalse;
-VALUE rb_parser_get_yydebug(VALUE);
-VALUE rb_parser_set_yydebug(VALUE, VALUE);
+static int sflag = 0;
+static int xflag = 0;
+extern int ruby_yydebug;
-char *ruby_inplace_mode = 0;
+char *ruby_inplace_mode = Qfalse;
-struct cmdline_options {
- int argc;
- char **argv;
- int sflag, xflag;
- int do_loop, do_print;
- int do_check, do_line;
- int do_split, do_search;
- int usage;
- int version;
- int copyright;
- int disable_gems;
- int verbose;
- int yydebug;
- char *script;
- VALUE e_script;
- int enc_index;
-};
+static void load_stdin _((void));
+static void load_file _((const char *, int));
+static void forbid_setid _((const char *));
-static NODE *load_file(VALUE, const char *, int, struct cmdline_options *);
-static void forbid_setid(const char *);
+static VALUE do_loop = Qfalse, do_print = Qfalse;
+static VALUE do_check = Qfalse, do_line = Qfalse;
+static VALUE do_split = Qfalse;
-static struct {
- int argc;
- char **argv;
-#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE)
- int len;
-#endif
-} origarg;
+static const char *script;
+
+static int origargc;
+static char **origargv;
static void
-usage(const char *name)
+usage(name)
+ const char *name;
{
/* This message really ought to be max 23 lines.
* Removed -h because the user already knows that option. Others? */
static const char *const usage_msg[] = {
- "-0[octal] specify record separator (\\0, if no argument)",
- "-a autosplit mode with -n or -p (splits $_ into $F)",
- "-c check syntax only",
- "-Cdirectory cd to directory, before executing your script",
- "-d set debugging flags (set $DEBUG to true)",
- "-e 'command' one line of script. Several -e's allowed. Omit [programfile]",
- "-Fpattern split() pattern for autosplit (-a)",
- "-i[extension] edit ARGV files in place (make backup if extension supplied)",
- "-Idirectory specify $LOAD_PATH directory (may be used more than once)",
- "-Kkcode specifies KANJI (Japanese) code-set",
- "-l enable line ending processing",
- "-n assume 'while gets(); ... end' loop around your script",
- "-p assume loop like -n but print line also like sed",
- "-rlibrary require the library, before executing your script",
- "-s enable some switch parsing for switches after script name",
- "-S look for the script using PATH environment variable",
- "-T[level] turn on tainting checks",
- "-v print version number, then turn on verbose mode",
- "-w turn warnings on for your script",
- "-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)",
- "-x[directory] strip off text before #!ruby line and perhaps cd to directory",
- "--disable-gems disable gem libraries",
- "--copyright print the copyright",
- "--version print the version",
- NULL
- };
+"-0[octal] specify record separator (\\0, if no argument)",
+"-a autosplit mode with -n or -p (splits $_ into $F)",
+"-c check syntax only",
+"-Cdirectory cd to directory, before executing your script",
+"-d set debugging flags (set $DEBUG to true)",
+"-e 'command' one line of script. Several -e's allowed. Omit [programfile]",
+"-Fpattern split() pattern for autosplit (-a)",
+"-i[extension] edit ARGV files in place (make backup if extension supplied)",
+"-Idirectory specify $LOAD_PATH directory (may be used more than once)",
+"-Kkcode specifies KANJI (Japanese) code-set",
+"-l enable line ending processing",
+"-n assume 'while gets(); ... end' loop around your script",
+"-p assume loop like -n but print line also like sed",
+"-rlibrary require the library, before executing your script",
+"-s enable some switch parsing for switches after script name",
+"-S look for the script using PATH environment variable",
+"-T[level] turn on tainting checks",
+"-v print version number, then turn on verbose mode",
+"-w turn warnings on for your script",
+"-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)",
+"-x[directory] strip off text before #!ruby line and perhaps cd to directory",
+"--copyright print the copyright",
+"--version print the version",
+NULL
+};
const char *const *p = usage_msg;
printf("Usage: %s [switches] [--] [programfile] [arguments]\n", name);
@@ -135,23 +110,6 @@ usage(const char *name)
printf(" %s\n", *p++);
}
-static rb_encoding *
-locale_encoding(void)
-{
- VALUE codeset = rb_locale_charmap(Qnil);
- char *name;
- int idx;
-
- if (codeset == Qnil)
- return rb_ascii8bit_encoding();
-
- name = StringValueCStr(codeset);
- idx = rb_enc_find_index(name);
- if (idx < 0)
- return rb_ascii8bit_encoding();
- return rb_enc_from_index(idx);
-}
-
extern VALUE rb_load_path;
#ifndef CharNext /* defined as CharNext[AW] on Windows. */
@@ -221,8 +179,11 @@ rubylib_mangled_path2(const char *s)
#define rubylib_mangled_path2 rb_str_new2
#endif
+static void push_include _((const char *path));
+
static void
-push_include(const char *path, VALUE (*filter)(VALUE))
+push_include(path)
+ const char *path;
{
const char sep = PATH_SEP_CHAR;
const char *p, *s;
@@ -233,14 +194,14 @@ push_include(const char *path, VALUE (*filter)(VALUE))
p++;
if (!*p) break;
for (s = p; *s && *s != sep; s = CharNext(s));
- rb_ary_push(rb_load_path, (*filter)(rubylib_mangled_path(p, s - p)));
+ rb_ary_push(rb_load_path, rubylib_mangled_path(p, s - p));
p = s;
}
}
#ifdef __CYGWIN__
static void
-push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
+push_include_cygwin(const char *path)
{
const char *p, *s;
char rubylib[FILENAME_MAX];
@@ -266,7 +227,7 @@ push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
}
if (cygwin_conv_to_posix_path(p, rubylib) == 0)
p = rubylib;
- push_include(p, filter);
+ push_include(p);
if (!*s) break;
p = s + 1;
}
@@ -276,79 +237,46 @@ push_include_cygwin(const char *path, VALUE (*filter)(VALUE))
#endif
void
-ruby_push_include(const char *path, VALUE (*filter)(VALUE))
+ruby_incpush(path)
+ const char *path;
{
if (path == 0)
return;
- push_include(path, filter);
-}
-
-static VALUE
-identical_path(VALUE path)
-{
- return path;
-}
-
-void
-ruby_incpush(const char *path)
-{
- ruby_push_include(path, identical_path);
-}
-
-static VALUE
-expand_include_path(VALUE path)
-{
- char *p = RSTRING_PTR(path);
- if (!p)
- return path;
- if (*p == '.' && p[1] == '/')
- return path;
- return rb_file_expand_path(path, Qnil);
-}
-
-void
-ruby_incpush_expand(const char *path)
-{
- ruby_push_include(path, expand_include_path);
+ push_include(path);
}
#if defined DOSISH || defined __CYGWIN__
#define LOAD_RELATIVE 1
#endif
-#if defined _WIN32 || defined __CYGWIN__
-static HMODULE libruby;
-
-BOOL WINAPI
-DllMain(HINSTANCE dll, DWORD reason, LPVOID reserved)
-{
- if (reason == DLL_PROCESS_ATTACH)
- libruby = dll;
- return TRUE;
-}
-#endif
-
void
-ruby_init_loadpath(void)
+ruby_init_loadpath()
{
#if defined LOAD_RELATIVE
- char libpath[MAXPATHLEN + 1];
+ char libpath[FILENAME_MAX+1];
char *p;
int rest;
-
#if defined _WIN32 || defined __CYGWIN__
+ HMODULE libruby = NULL;
+ MEMORY_BASIC_INFORMATION m;
+
+#ifndef _WIN32_WCE
+ memset(&m, 0, sizeof(m));
+ if (VirtualQuery(ruby_init_loadpath, &m, sizeof(m)) && m.State == MEM_COMMIT)
+ libruby = (HMODULE)m.AllocationBase;
+#endif
GetModuleFileName(libruby, libpath, sizeof libpath);
#elif defined(DJGPP)
extern char *__dos_argv0;
- strncpy(libpath, __dos_argv0, sizeof(libpath) - 1);
+ strncpy(libpath, __dos_argv0, FILENAME_MAX);
#elif defined(__human68k__)
extern char **_argv;
- strncpy(libpath, _argv[0], sizeof(libpath) - 1);
+ strncpy(libpath, _argv[0], FILENAME_MAX);
#elif defined(__EMX__)
- _execname(libpath, sizeof(libpath) - 1);
+ _execname(libpath, FILENAME_MAX);
#endif
- libpath[sizeof(libpath) - 1] = '\0';
+ libpath[FILENAME_MAX] = '\0';
#if defined DOSISH
translate_char(libpath, '\\', '/');
#elif defined __CYGWIN__
@@ -371,7 +299,7 @@ ruby_init_loadpath(void)
p = libpath + 1;
}
- rest = sizeof(libpath) - 1 - (p - libpath);
+ rest = FILENAME_MAX - (p - libpath);
#define RUBY_RELATIVE(path) (strncpy(p, (path), rest), libpath)
#else
@@ -416,66 +344,80 @@ struct req_list {
char *name;
struct req_list *next;
};
-static struct {
- struct req_list *last, head;
-} req_list = {&req_list.head,};
+static struct req_list req_list_head, *req_list_last = &req_list_head;
static void
-add_modules(const char *mod)
+add_modules(mod)
+ const char *mod;
{
struct req_list *list;
list = ALLOC(struct req_list);
- list->name = ALLOC_N(char, strlen(mod) + 1);
+ list->name = ALLOC_N(char, strlen(mod)+1);
strcpy(list->name, mod);
list->next = 0;
- req_list.last->next = list;
- req_list.last = list;
+ req_list_last->next = list;
+ req_list_last = list;
}
-extern void Init_ext(void);
-extern VALUE rb_vm_top_self(void);
+extern void Init_ext _((void));
static void
-require_libraries(void)
+require_libraries()
{
- struct req_list *list = req_list.head.next;
+ extern NODE *ruby_eval_tree;
+ extern NODE *ruby_eval_tree_begin;
+ NODE *save[3];
+ struct req_list *list = req_list_head.next;
struct req_list *tmp;
- ID require = rb_intern("require");
+ save[0] = ruby_eval_tree;
+ save[1] = ruby_eval_tree_begin;
+ save[2] = NEW_NEWLINE(0);
+ ruby_eval_tree = ruby_eval_tree_begin = 0;
+ ruby_current_node = 0;
Init_ext(); /* should be called here for some reason :-( */
- req_list.last = 0;
+ ruby_current_node = save[2];
+ ruby_set_current_source();
+ req_list_last = 0;
while (list) {
- VALUE feature = rb_str_new2(list->name);
+ int state;
+
+ ruby_current_node = 0;
+ rb_protect((VALUE (*)(VALUE))rb_require, (VALUE)list->name, &state);
+ if (state) rb_jump_tag(state);
tmp = list->next;
free(list->name);
free(list);
list = tmp;
- rb_funcall2(rb_vm_top_self(), require, 1, &feature);
+ ruby_current_node = save[2];
+ ruby_set_current_source();
}
- req_list.head.next = 0;
+ req_list_head.next = 0;
+ ruby_eval_tree = save[0];
+ ruby_eval_tree_begin = save[1];
+ rb_gc_force_recycle((VALUE)save[2]);
+ ruby_current_node = 0;
}
static void
-process_sflag(struct cmdline_options *opt)
+process_sflag()
{
- if (opt->sflag) {
+ if (sflag) {
long n;
VALUE *args;
- n = RARRAY_LEN(rb_argv);
- args = RARRAY_PTR(rb_argv);
+ n = RARRAY(rb_argv)->len;
+ args = RARRAY(rb_argv)->ptr;
while (n > 0) {
VALUE v = *args++;
char *s = StringValuePtr(v);
char *p;
int hyphen = Qfalse;
- if (s[0] != '-')
- break;
+ if (s[0] != '-') break;
n--;
- if (s[1] == '-' && s[2] == '\0')
- break;
+ if (s[1] == '-' && s[2] == '\0') break;
v = Qtrue;
/* check if valid name before replacing - with _ */
@@ -490,8 +432,7 @@ process_sflag(struct cmdline_options *opt)
}
else if (*p != '_' && !ISALNUM(*p)) {
VALUE name_error[2];
- name_error[0] =
- rb_str_new2("invalid name for global variable - ");
+ name_error[0] = rb_str_new2("invalid name for global variable - ");
if (!(p = strchr(p, '='))) {
rb_str_cat2(name_error[0], s);
}
@@ -505,72 +446,76 @@ process_sflag(struct cmdline_options *opt)
s[0] = '$';
if (hyphen) {
for (p = s + 1; *p; ++p) {
- if (*p == '-')
- *p = '_';
+ if (*p == '-') *p = '_';
}
}
rb_gv_set(s, v);
}
- n = RARRAY_LEN(rb_argv) - n;
+ n = RARRAY(rb_argv)->len - n;
while (n--) {
rb_ary_shift(rb_argv);
}
}
- opt->sflag = 0;
+ sflag = 0;
}
-NODE *rb_parser_append_print(VALUE, NODE *);
-NODE *rb_parser_while_loop(VALUE, NODE *, int, int);
-static int proc_options(int argc, char **argv, struct cmdline_options *opt);
+static void proc_options _((int argc, char **argv));
-static char *
-moreswitches(const char *s, struct cmdline_options *opt)
+static char*
+moreswitches(s)
+ char *s;
{
- int argc;
- char *argv[3];
- const char *p = s;
+ int argc; char *argv[3];
+ char *p = s;
- argc = 2;
- argv[0] = argv[2] = 0;
+ argc = 2; argv[0] = argv[2] = 0;
while (*s && !ISSPACE(*s))
s++;
- argv[1] = ALLOCA_N(char, s - p + 2);
+ argv[1] = ALLOCA_N(char, s-p+2);
argv[1][0] = '-';
- strncpy(argv[1] + 1, p, s - p);
- argv[1][s - p + 1] = '\0';
- proc_options(argc, argv, opt);
+ strncpy(argv[1]+1, p, s-p);
+ argv[1][s-p+1] = '\0';
+ proc_options(argc, argv);
while (*s && ISSPACE(*s))
s++;
- return (char *)s;
+ return s;
}
-static int
-proc_options(int argc, char **argv, struct cmdline_options *opt)
+static void
+proc_options(argc, argv)
+ int argc;
+ char **argv;
{
- int argc0 = argc;
- const char *s;
- const char *enc_name = 0;
+ char *argv0 = argv[0];
+ int do_search;
+ char *s;
+ NODE *volatile script_node = 0;
- if (argc == 0)
- return 0;
+ int version = 0;
+ int copyright = 0;
+ int verbose = 0;
+ VALUE e_script = Qfalse;
- for (argc--, argv++; argc > 0; argc--, argv++) {
- if (argv[0][0] != '-' || !argv[0][1])
- break;
+ if (argc == 0) return;
+
+ do_search = Qfalse;
+
+ for (argc--,argv++; argc > 0; argc--,argv++) {
+ if (argv[0][0] != '-' || !argv[0][1]) break;
- s = argv[0] + 1;
+ s = argv[0]+1;
reswitch:
switch (*s) {
case 'a':
- opt->do_split = Qtrue;
+ do_split = Qtrue;
s++;
goto reswitch;
case 'p':
- opt->do_print = Qtrue;
+ do_print = Qtrue;
/* through */
case 'n':
- opt->do_loop = Qtrue;
+ do_loop = Qtrue;
s++;
goto reswitch;
@@ -581,17 +526,17 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
goto reswitch;
case 'y':
- opt->yydebug = 1;
+ ruby_yydebug = 1;
s++;
goto reswitch;
case 'v':
- if (opt->verbose) {
+ if (argv0 == 0 || verbose) {
s++;
goto reswitch;
}
ruby_show_version();
- opt->verbose = 1;
+ verbose = 1;
case 'w':
ruby_verbose = Qtrue;
s++;
@@ -604,49 +549,44 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
if (*++s) {
v = scan_oct(s, 1, &numlen);
- if (numlen == 0)
- v = 1;
+ if (numlen == 0) v = 1;
s += numlen;
}
switch (v) {
case 0:
- ruby_verbose = Qnil;
- break;
+ ruby_verbose = Qnil; break;
case 1:
- ruby_verbose = Qfalse;
- break;
+ ruby_verbose = Qfalse; break;
default:
- ruby_verbose = Qtrue;
- break;
+ ruby_verbose = Qtrue; break;
}
}
goto reswitch;
case 'c':
- opt->do_check = Qtrue;
+ do_check = Qtrue;
s++;
goto reswitch;
case 's':
forbid_setid("-s");
- opt->sflag = 1;
+ sflag = 1;
s++;
goto reswitch;
case 'h':
- usage(origarg.argv[0]);
- rb_exit(EXIT_SUCCESS);
- break;
+ usage(origargv[0]);
+ exit(0);
case 'l':
- opt->do_line = Qtrue;
+ do_line = Qtrue;
rb_output_rs = rb_rs;
s++;
goto reswitch;
case 'S':
forbid_setid("-S");
- opt->do_search = Qtrue;
+ do_search = Qtrue;
s++;
goto reswitch;
@@ -654,18 +594,18 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
forbid_setid("-e");
if (!*++s) {
s = argv[1];
- argc--, argv++;
+ argc--,argv++;
}
if (!s) {
- rb_raise(rb_eRuntimeError, "no code specified for -e");
+ fprintf(stderr, "%s: no code specified for -e\n", origargv[0]);
+ exit(2);
}
- if (!opt->e_script) {
- opt->e_script = rb_str_new(0, 0);
- if (opt->script == 0)
- opt->script = "-e";
+ if (!e_script) {
+ e_script = rb_str_new(0,0);
+ if (script == 0) script = "-e";
}
- rb_str_cat2(opt->e_script, s);
- rb_str_cat2(opt->e_script, "\n");
+ rb_str_cat2(e_script, s);
+ rb_str_cat2(e_script, "\n");
break;
case 'r':
@@ -675,19 +615,18 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
}
else if (argv[1]) {
add_modules(argv[1]);
- argc--, argv++;
+ argc--,argv++;
}
break;
case 'i':
forbid_setid("-i");
- if (ruby_inplace_mode)
- free(ruby_inplace_mode);
- ruby_inplace_mode = strdup(s + 1);
+ if (ruby_inplace_mode) free(ruby_inplace_mode);
+ ruby_inplace_mode = strdup(s+1);
break;
case 'x':
- opt->xflag = Qtrue;
+ xflag = Qtrue;
s++;
if (*s && chdir(s) < 0) {
rb_fatal("Can't chdir to %s", s);
@@ -699,7 +638,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
s++;
if (!*s) {
s = argv[1];
- argc--, argv++;
+ argc--,argv++;
}
if (!s || !*s) {
rb_fatal("Can't chdir");
@@ -711,37 +650,13 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
case 'F':
if (*++s) {
- rb_fs = rb_reg_new(rb_str_new2(s), 0);
+ rb_fs = rb_reg_new(s, strlen(s), 0);
}
break;
- case 'E':
- if (!*++s) {
- s = argv[1];
- argc--, argv++;
- }
- goto encoding;
-
case 'K':
if (*++s) {
- rb_encoding *enc = 0;
- switch (*s) {
- case 'E': case 'e':
- enc = ONIG_ENCODING_EUC_JP;
- break;
- case 'S': case 's':
- enc = ONIG_ENCODING_SJIS;
- break;
- case 'U': case 'u':
- enc = ONIG_ENCODING_UTF8;
- break;
- case 'N': case 'n': case 'A': case 'a':
- enc = ONIG_ENCODING_ASCII;
- break;
- }
- if (enc) {
- opt->enc_index = rb_enc_find_index(rb_enc_name(enc));
- }
+ rb_set_kcode(s);
s++;
}
goto reswitch;
@@ -753,8 +668,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
if (*++s) {
v = scan_oct(s, 2, &numlen);
- if (numlen == 0)
- v = 1;
+ if (numlen == 0) v = 1;
s += numlen;
}
rb_set_safe_level(v);
@@ -764,10 +678,10 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
case 'I':
forbid_setid("-I");
if (*++s)
- ruby_incpush_expand(s);
+ ruby_incpush(s);
else if (argv[1]) {
- ruby_incpush_expand(argv[1]);
- argc--, argv++;
+ ruby_incpush(argv[1]);
+ argc--,argv++;
}
break;
@@ -779,8 +693,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
v = scan_oct(s, 4, &numlen);
s += numlen;
- if (v > 0377)
- rb_rs = Qnil;
+ if (v > 0377) rb_rs = Qnil;
else if (v == 0 && numlen >= 2) {
rb_rs = rb_str_new2("\n\n");
}
@@ -793,70 +706,50 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
case '-':
if (!s[1] || (s[1] == '\r' && !s[2])) {
- argc--, argv++;
+ argc--,argv++;
goto switch_end;
}
s++;
if (strcmp("copyright", s) == 0)
- opt->copyright = 1;
+ copyright = 1;
else if (strcmp("debug", s) == 0) {
ruby_debug = Qtrue;
ruby_verbose = Qtrue;
}
- else if (strcmp("disable-gems", s) == 0)
- opt->disable_gems = 1;
- else if (strcmp("encoding", s) == 0) {
- int idx;
- if (!--argc || !(s = *++argv)) {
- noencoding:
- rb_raise(rb_eRuntimeError, "missing argument for --encoding");
- }
- encoding:
- if ((idx = rb_enc_find_index(s)) < 0) {
- rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s);
- }
- opt->enc_index = idx;
- }
- else if (strncmp("encoding=", s, 9) == 0) {
- if (!*(s += 9)) goto noencoding;
- goto encoding;
- }
else if (strcmp("version", s) == 0)
- opt->version = 1;
+ version = 1;
else if (strcmp("verbose", s) == 0) {
- opt->verbose = 1;
+ verbose = 1;
ruby_verbose = Qtrue;
}
else if (strcmp("yydebug", s) == 0)
- opt->yydebug = 1;
+ ruby_yydebug = 1;
else if (strcmp("help", s) == 0) {
- usage(origarg.argv[0]);
- rb_exit(EXIT_SUCCESS);
+ usage(origargv[0]);
+ exit(0);
}
else {
- rb_raise(rb_eRuntimeError,
- "invalid option --%s (-h will show valid options)", s);
+ fprintf(stderr, "%s: invalid option --%s (-h will show valid options)\n",
+ origargv[0], s);
+ exit(2);
}
break;
case '\r':
- if (!s[1])
- break;
+ if (!s[1]) break;
default:
{
+ const char *format;
if (ISPRINT(*s)) {
- rb_raise(rb_eRuntimeError,
- "invalid option -%c (-h will show valid options)",
- (int)(unsigned char)*s);
+ format = "%s: invalid option -%c (-h will show valid options)\n";
}
else {
- rb_raise(rb_eRuntimeError,
- "invalid option -\\x%02X (-h will show valid options)",
- (int)(unsigned char)*s);
+ format = "%s: invalid option -\\%03o (-h will show valid options)\n";
}
+ fprintf(stderr, format, origargv[0], (int)(unsigned char)*s);
}
- goto switch_end;
+ exit(2);
case 0:
break;
@@ -864,48 +757,18 @@ proc_options(int argc, char **argv, struct cmdline_options *opt)
}
switch_end:
- return argc0 - argc;
-}
-
-void Init_prelude(void);
-
-static void
-ruby_init_gems(struct cmdline_options *opt)
-{
- VALUE gem;
- gem = rb_define_module("Gem");
- rb_const_set(gem, rb_intern("Enable"), opt->disable_gems ? Qfalse : Qtrue);
- Init_prelude();
-}
-
-static VALUE
-process_options(VALUE arg)
-{
- struct cmdline_options *opt = (struct cmdline_options *)arg;
- int argc = opt->argc;
- char **argv = opt->argv;
- NODE *tree = 0;
- VALUE parser;
- rb_encoding *enc;
- const char *s;
- int i = proc_options(argc, argv, opt);
-
- argc -= i;
- argv += i;
+ if (argv0 == 0) return;
if (rb_safe_level() == 0 && (s = getenv("RUBYOPT"))) {
- while (ISSPACE(*s))
- s++;
- if (*s == 'T' || (*s == '-' && *(s + 1) == 'T')) {
+ while (ISSPACE(*s)) s++;
+ if (*s == 'T' || (*s == '-' && *(s+1) == 'T')) {
int numlen;
int v = 1;
- if (*s != 'T')
- ++s;
+ if (*s != 'T') ++s;
if (*++s) {
v = scan_oct(s, 2, &numlen);
- if (numlen == 0)
- v = 1;
+ if (numlen == 0) v = 1;
}
rb_set_safe_level(v);
}
@@ -914,27 +777,23 @@ process_options(VALUE arg)
if (*s == '-') {
s++;
if (ISSPACE(*s)) {
- do {
- s++;
- } while (ISSPACE(*s));
+ do {s++;} while (ISSPACE(*s));
continue;
}
}
- if (!*s)
- break;
+ if (!*s) break;
if (!strchr("IdvwWrK", *s))
- rb_raise(rb_eRuntimeError,
- "invalid switch in RUBYOPT: -%c", *s);
- s = moreswitches(s, opt);
+ rb_raise(rb_eRuntimeError, "illegal switch in RUBYOPT: -%c", *s);
+ s = moreswitches(s);
}
}
}
- if (opt->version) {
+ if (version) {
ruby_show_version();
- return Qtrue;
+ exit(0);
}
- if (opt->copyright) {
+ if (copyright) {
ruby_show_copyright();
}
@@ -943,122 +802,97 @@ process_options(VALUE arg)
OBJ_TAINT(rb_load_path);
}
- if (!opt->e_script) {
+ if (!e_script) {
if (argc == 0) { /* no more args */
- if (opt->verbose)
- return Qtrue;
- opt->script = "-";
+ if (verbose) exit(0);
+ script = "-";
}
else {
- opt->script = argv[0];
- if (opt->script[0] == '\0') {
- opt->script = "-";
+ script = argv[0];
+#if defined DOSISH || defined __CYGWIN__
+ translate_char(argv[0], '\\', '/');
+#endif
+ if (script[0] == '\0') {
+ script = "-";
}
- else if (opt->do_search) {
+ else if (do_search) {
char *path = getenv("RUBYPATH");
- opt->script = 0;
+ script = 0;
if (path) {
- opt->script = dln_find_file(argv[0], path);
+ script = dln_find_file(argv[0], path);
}
- if (!opt->script) {
- opt->script = dln_find_file(argv[0], getenv(PATH_ENV));
+ if (!script) {
+ script = dln_find_file(argv[0], getenv(PATH_ENV));
}
- if (!opt->script)
- opt->script = argv[0];
- }
+ if (!script) script = argv[0];
+ script = ruby_sourcefile = rb_source_filename(script);
+ script_node = NEW_NEWLINE(0);
#if defined DOSISH || defined __CYGWIN__
- /* assume that we can change argv[n] if never change its length. */
- translate_char(opt->script, '\\', '/');
+ translate_char(ruby_sourcefile, '\\', '/');
#endif
- argc--;
- argv++;
+ }
+ argc--; argv++;
}
}
- ruby_script(opt->script);
+ ruby_script(script);
ruby_set_argv(argc, argv);
- process_sflag(opt);
+ process_sflag();
ruby_init_loadpath();
- ruby_init_gems(opt);
- parser = rb_parser_new();
- if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue);
- if (opt->e_script) {
- if (opt->enc_index >= 0)
- rb_enc_associate_index(opt->e_script, opt->enc_index);
+ ruby_sourcefile = rb_source_filename(argv0);
+ if (e_script) {
require_libraries();
- tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
+ rb_compile_string(script, e_script, 1);
+ }
+ else if (strlen(script) == 1 && script[0] == '-') {
+ load_stdin();
}
else {
- if (opt->script[0] == '-' && !opt->script[1]) {
- forbid_setid("program input from stdin");
- }
- tree = load_file(parser, opt->script, 1, opt);
+ load_file(script, 1);
}
- if (!tree) return Qfalse;
-
- process_sflag(opt);
- opt->xflag = 0;
+ process_sflag();
+ xflag = 0;
if (rb_safe_level() >= 4) {
FL_UNSET(rb_argv, FL_TAINT);
FL_UNSET(rb_load_path, FL_TAINT);
}
-
- if (opt->do_check) {
- printf("Syntax OK\n");
- return Qtrue;
- }
-
- if (tree) {
- if (opt->do_print) {
- tree = rb_parser_append_print(parser, tree);
- }
- if (opt->do_loop) {
- tree = rb_parser_while_loop(parser, tree, opt->do_line, opt->do_split);
- }
- }
-
- if (opt->enc_index >= 0) {
- enc = rb_enc_from_index(opt->enc_index);
- }
- else {
- enc = locale_encoding();
- }
- rb_enc_set_default_external(rb_enc_from_encoding(enc));
-
- return (VALUE)tree;
}
-static NODE *
-load_file(VALUE parser, const char *fname, int script, struct cmdline_options *opt)
+extern int ruby__end__seen;
+
+static void
+load_file(fname, script)
+ const char *fname;
+ int script;
{
extern VALUE rb_stdin;
VALUE f;
int line_start = 1;
- NODE *tree = 0;
- if (!fname)
- rb_load_fail(fname);
+ if (!fname) rb_load_fail(fname);
if (strcmp(fname, "-") == 0) {
f = rb_stdin;
}
else {
- int fd, mode = O_RDONLY;
+ FILE *fp = fopen(fname, "r");
+
+ if (fp == NULL) {
+ rb_load_fail(fname);
+ }
+ fclose(fp);
+
+ f = rb_file_open(fname, "r");
#if defined DOSISH || defined __CYGWIN__
{
- const char *ext = strrchr(fname, '.');
+ char *ext = strrchr(fname, '.');
if (ext && strcasecmp(ext, ".exe") == 0)
- mode |= O_BINARY;
+ rb_io_binmode(f);
}
#endif
- if ((fd = open(fname, mode)) < 0) {
- rb_load_fail(fname);
- }
-
- f = rb_io_fdopen(fd, mode, fname);
}
if (script) {
@@ -1066,15 +900,15 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o
VALUE line;
char *p;
- if (opt->xflag) {
+ if (xflag) {
forbid_setid("-x");
- opt->xflag = Qfalse;
+ xflag = Qfalse;
while (!NIL_P(line = rb_io_gets(f))) {
line_start++;
- if (RSTRING_LEN(line) > 2
- && RSTRING_PTR(line)[0] == '#'
- && RSTRING_PTR(line)[1] == '!') {
- if ((p = strstr(RSTRING_PTR(line), "ruby")) != 0) {
+ if (RSTRING(line)->len > 2
+ && RSTRING(line)->ptr[0] == '#'
+ && RSTRING(line)->ptr[1] == '!') {
+ if ((p = strstr(RSTRING(line)->ptr, "ruby")) != 0) {
goto start_read;
}
}
@@ -1082,25 +916,22 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o
rb_raise(rb_eLoadError, "no Ruby script found in input");
}
- c = rb_io_getbyte(f);
+ c = rb_io_getc(f);
if (c == INT2FIX('#')) {
- c = rb_io_getbyte(f);
- if (c == INT2FIX('!')) {
- line = rb_io_gets(f);
- if (NIL_P(line))
- return 0;
+ line = rb_io_gets(f);
+ if (NIL_P(line)) return;
+ line_start++;
- if ((p = strstr(RSTRING_PTR(line), "ruby")) == 0) {
+ if (RSTRING(line)->len > 2 && RSTRING(line)->ptr[0] == '!') {
+ if ((p = strstr(RSTRING(line)->ptr, "ruby")) == 0) {
/* not ruby script, kick the program */
char **argv;
char *path;
- char *pend = RSTRING_PTR(line) + RSTRING_LEN(line);
+ char *pend = RSTRING(line)->ptr + RSTRING(line)->len;
- p = RSTRING_PTR(line); /* skip `#!' */
- if (pend[-1] == '\n')
- pend--; /* chomp line */
- if (pend[-1] == '\r')
- pend--;
+ p = RSTRING(line)->ptr + 1; /* skip `#!' */
+ if (pend[-1] == '\n') pend--; /* chomp line */
+ if (pend[-1] == '\r') pend--;
*pend = '\0';
while (p < pend && ISSPACE(*p))
p++;
@@ -1109,75 +940,103 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o
p++;
*p++ = '\0';
if (p < pend) {
- argv = ALLOCA_N(char *, origarg.argc + 3);
+ argv = ALLOCA_N(char*, origargc+3);
argv[1] = p;
- MEMCPY(argv + 2, origarg.argv + 1, char *, origarg.argc);
+ MEMCPY(argv+2, origargv+1, char*, origargc);
}
else {
- argv = origarg.argv;
+ argv = origargv;
}
argv[0] = path;
execv(path, argv);
+ ruby_sourcefile = rb_source_filename(fname);
+ ruby_sourceline = 1;
rb_fatal("Can't exec %s", path);
}
start_read:
p += 4;
- RSTRING_PTR(line)[RSTRING_LEN(line) - 1] = '\0';
- if (RSTRING_PTR(line)[RSTRING_LEN(line) - 2] == '\r')
- RSTRING_PTR(line)[RSTRING_LEN(line) - 2] = '\0';
+ RSTRING(line)->ptr[RSTRING(line)->len-1] = '\0';
+ if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
+ RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
if ((p = strstr(p, " -")) != 0) {
p++; /* skip space before `-' */
while (*p == '-') {
- p = moreswitches(p + 1, opt);
+ p = moreswitches(p+1);
}
}
-
- /* push back shebang for pragma may exist in next line */
- rb_io_ungetc(f, rb_str_new2("!\n"));
}
- else if (!NIL_P(c)) {
- rb_io_ungetc(f, c);
- }
- rb_io_ungetc(f, INT2FIX('#'));
}
else if (!NIL_P(c)) {
rb_io_ungetc(f, c);
}
require_libraries(); /* Why here? unnatural */
+ if (NIL_P(c)) return;
}
- if (opt->enc_index >= 0) rb_enc_associate_index(f, opt->enc_index);
- tree = (NODE *)rb_parser_compile_file(parser, fname, f, line_start);
- if (script && rb_parser_end_seen_p(parser)) {
+ rb_compile_file(fname, f, line_start);
+ if (script && ruby__end__seen) {
rb_define_global_const("DATA", f);
}
else if (f != rb_stdin) {
rb_io_close(f);
}
- return tree;
+
+ if (ruby_parser_stack_on_heap()) {
+ rb_gc();
+ }
}
-void *
-rb_load_file(const char *fname)
+void
+rb_load_file(fname)
+ const char *fname;
{
- struct cmdline_options opt;
+ load_file(fname, 0);
+}
- MEMZERO(&opt, opt, 1);
- return load_file(rb_parser_new(), fname, 0, &opt);
+static void
+load_stdin()
+{
+ forbid_setid("program input from stdin");
+ load_file("-", 1);
}
VALUE rb_progname;
VALUE rb_argv;
VALUE rb_argv0;
-#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE)
-#if !defined(_WIN32) && !(defined(HAVE_SETENV) && defined(HAVE_UNSETENV))
+#if defined(PSTAT_SETCMD) || defined(HAVE_SETPROCTITLE)
+#elif defined(_WIN32)
+#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
+#else
#define USE_ENVSPACE_FOR_ARG0
#endif
#ifdef USE_ENVSPACE_FOR_ARG0
+static struct {
+ char *begin, *end;
+} envspace;
extern char **environ;
+
+static void
+set_arg0space()
+{
+ char *s;
+ int i;
+
+ if (!environ || (s = environ[0]) == NULL) return;
+ envspace.begin = s;
+ s += strlen(s);
+ for (i = 1; environ[i]; i++) {
+ if (environ[i] == s + 1) {
+ s++;
+ s += strlen(s); /* this one is ok too */
+ }
+ }
+ envspace.end = s;
+}
+#else
+#define set_arg0space() ((void)0)
#endif
static int
@@ -1186,6 +1045,7 @@ get_arglen(int argc, char **argv)
char *s = argv[0];
int i;
+ if (!argc) return 0;
s += strlen(s);
/* See if all the arguments are contiguous in memory */
for (i = 1; i < argc; i++) {
@@ -1211,69 +1071,77 @@ get_arglen(int argc, char **argv)
#endif
return s - argv[0];
}
-#endif
static void
-set_arg0(VALUE val, ID id)
+set_arg0(val, id)
+ VALUE val;
+ ID id;
{
- char *s, *t;
+ VALUE progname;
+ char *s;
long i;
+ int j;
+#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE)
+ static int len = 0;
+#endif
- if (origarg.argv == 0)
- rb_raise(rb_eRuntimeError, "$0 not initialized");
+ if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized");
StringValue(val);
- s = RSTRING_PTR(val);
- i = RSTRING_LEN(val);
+ s = RSTRING(val)->ptr;
+ i = RSTRING(val)->len;
#if defined(PSTAT_SETCMD)
- if (i > PST_CLEN) {
- union pstun un;
- char buf[PST_CLEN + 1]; /* PST_CLEN is 64 (HP-UX 11.23) */
- strncpy(buf, s, PST_CLEN);
- buf[PST_CLEN] = '\0';
- un.pst_command = buf;
- pstat(PSTAT_SETCMD, un, PST_CLEN, 0, 0);
+ if (i >= PST_CLEN) {
+ union pstun j;
+ j.pst_command = s;
+ i = PST_CLEN;
+ RSTRING(val)->len = i;
+ *(s + i) = '\0';
+ pstat(PSTAT_SETCMD, j, PST_CLEN, 0, 0);
}
else {
- union pstun un;
- un.pst_command = s;
- pstat(PSTAT_SETCMD, un, i, 0, 0);
+ union pstun j;
+ j.pst_command = s;
+ pstat(PSTAT_SETCMD, j, i, 0, 0);
}
+ progname = rb_tainted_str_new(s, i);
#elif defined(HAVE_SETPROCTITLE)
setproctitle("%.*s", (int)i, s);
+ progname = rb_tainted_str_new(s, i);
#else
-
- if (i >= origarg.len) {
- i = origarg.len;
+ if (len == 0) {
+ len = get_arglen(origargc, origargv);
}
- memcpy(origarg.argv[0], s, i);
- t = origarg.argv[0] + i;
- *t = '\0';
-
- if (i + 1 < origarg.len) memset(t + 1, ' ', origarg.len - i - 1);
-
- {
- int j;
- for (j = 1; j < origarg.argc; j++) {
- origarg.argv[j] = t;
- }
+ if (i >= len) {
+ i = len;
+ }
+ memcpy(origargv[0], s, i);
+ s = origargv[0] + i;
+ *s = '\0';
+ if (++i < len) memset(s + 1, ' ', len - i);
+ for (i = len-1, j = origargc-1; j > 0 && i >= 0; --i, --j) {
+ origargv[j] = origargv[0] + i;
+ *origargv[j] = '\0';
}
+ progname = rb_tainted_str_new2(origargv[0]);
#endif
- rb_progname = rb_tainted_str_new(s, i);
+ rb_progname = rb_obj_freeze(progname);
}
void
-ruby_script(const char *name)
+ruby_script(name)
+ const char *name;
{
if (name) {
- rb_progname = rb_tainted_str_new2(name);
+ rb_progname = rb_obj_freeze(rb_tainted_str_new2(name));
+ ruby_sourcefile = rb_source_filename(name);
}
}
static int uid, euid, gid, egid;
static void
-init_ids(void)
+init_ids()
{
uid = (int)getuid();
euid = (int)geteuid();
@@ -1289,7 +1157,8 @@ init_ids(void)
}
static void
-forbid_setid(const char *s)
+forbid_setid(s)
+ const char *s;
{
if (euid != uid)
rb_raise(rb_eSecurityError, "no %s allowed while running setuid", s);
@@ -1300,34 +1169,27 @@ forbid_setid(const char *s)
}
static void
-verbose_setter(VALUE val, ID id, VALUE *variable)
+verbose_setter(val, id, variable)
+ VALUE val;
+ ID id;
+ VALUE *variable;
{
ruby_verbose = RTEST(val) ? Qtrue : val;
}
-static VALUE
-opt_W_getter(VALUE val, ID id)
-{
- if (ruby_verbose == Qnil)
- return INT2FIX(0);
- if (ruby_verbose == Qfalse)
- return INT2FIX(1);
- if (ruby_verbose == Qtrue)
- return INT2FIX(2);
- return Qnil; /* not reached */
-}
-
void
-ruby_prog_init(void)
+ruby_prog_init()
{
init_ids();
+ ruby_sourcefile = rb_source_filename("ruby");
rb_define_hooked_variable("$VERBOSE", &ruby_verbose, 0, verbose_setter);
rb_define_hooked_variable("$-v", &ruby_verbose, 0, verbose_setter);
rb_define_hooked_variable("$-w", &ruby_verbose, 0, verbose_setter);
- rb_define_virtual_variable("$-W", opt_W_getter, 0);
rb_define_variable("$DEBUG", &ruby_debug);
rb_define_variable("$-d", &ruby_debug);
+ rb_define_readonly_variable("$-p", &do_print);
+ rb_define_readonly_variable("$-l", &do_line);
rb_define_hooked_variable("$0", &rb_progname, 0, set_arg0);
rb_define_hooked_variable("$PROGRAM_NAME", &rb_progname, 0, set_arg0);
@@ -1335,6 +1197,7 @@ ruby_prog_init(void)
rb_define_readonly_variable("$*", &rb_argv);
rb_argv = rb_ary_new();
rb_define_global_const("ARGV", rb_argv);
+ rb_define_readonly_variable("$-a", &do_split);
rb_global_variable(&rb_argv0);
#ifdef MSDOS
@@ -1348,18 +1211,18 @@ ruby_prog_init(void)
}
void
-ruby_set_argv(int argc, char **argv)
+ruby_set_argv(argc, argv)
+ int argc;
+ char **argv;
{
int i;
#if defined(USE_DLN_A_OUT)
- if (origarg.argv)
- dln_argv0 = origarg.argv[0];
- else
- dln_argv0 = argv[0];
+ if (origargv) dln_argv0 = origargv[0];
+ else dln_argv0 = argv[0];
#endif
rb_ary_clear(rb_argv);
- for (i = 0; i < argc; i++) {
+ for (i=0; i < argc; i++) {
VALUE arg = rb_tainted_str_new2(argv[i]);
OBJ_FREEZE(arg);
@@ -1367,76 +1230,29 @@ ruby_set_argv(int argc, char **argv)
}
}
-static VALUE
-false_value(void)
-{
- return Qfalse;
-}
-
-static VALUE
-true_value(void)
-{
- return Qtrue;
-}
-
-#define rb_define_readonly_boolean(name, val) \
- rb_define_virtual_variable((name), (val) ? true_value : false_value, 0)
-
-void *
-ruby_process_options(int argc, char **argv)
+void
+ruby_process_options(argc, argv)
+ int argc;
+ char **argv;
{
- struct cmdline_options opt;
- NODE *tree;
+ origargc = argc; origargv = argv;
- MEMZERO(&opt, opt, 1);
ruby_script(argv[0]); /* for the time being */
rb_argv0 = rb_progname;
- opt.argc = argc;
- opt.argv = argv;
- opt.enc_index = -1;
- tree = (NODE *)rb_vm_call_cfunc(rb_vm_top_self(),
- process_options, (VALUE)&opt,
- 0, rb_progname);
-
- rb_define_readonly_boolean("$-p", opt.do_print);
- rb_define_readonly_boolean("$-l", opt.do_line);
- rb_define_readonly_boolean("$-a", opt.do_split);
-
- return tree;
-}
-
-void
-ruby_sysinit(int *argc, char ***argv)
-{
-#if defined(__APPLE__) && (defined(__MACH__) || defined(__DARWIN__))
- int i, n = *argc, len = 0;
- char **v1 = *argv, **v2, *p;
+#if defined(USE_DLN_A_OUT)
+ dln_argv0 = argv[0];
+#endif
+ set_arg0space();
+ proc_options(argc, argv);
- for (i = 0; i < n; ++i) {
- len += strlen(v1[i]) + 1;
+ if (do_check && ruby_nerrs == 0) {
+ printf("Syntax OK\n");
+ exit(0);
}
- v2 = malloc((n + 1)* sizeof(char*) + len);
- p = (char *)&v2[n + 1];
- for (i = 0; i < n; ++i) {
- int l = strlen(v1[i]);
- memcpy(p, v1[i], l + 1);
- v2[i] = p;
- p += l + 1;
+ if (do_print) {
+ rb_parser_append_print();
+ }
+ if (do_loop) {
+ rb_parser_while_loop(do_line, do_split);
}
- v2[n] = 0;
- *argv = v2;
-#elif defined(__MACOS__) && defined(__MWERKS__)
- *argc = ccommand(argv);
-#elif defined(_WIN32)
- void rb_w32_sysinit(int *argc, char ***argv);
- rb_w32_sysinit(argc, argv);
-#endif
- origarg.argc = *argc;
- origarg.argv = *argv;
-#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE)
- origarg.len = get_arglen(origarg.argc, origarg.argv);
-#endif
-#if defined(USE_DLN_A_OUT)
- dln_argv0 = origarg.argv[0];
-#endif
}
diff --git a/ruby.h b/ruby.h
new file mode 100644
index 0000000000..4281ad4a0e
--- /dev/null
+++ b/ruby.h
@@ -0,0 +1,776 @@
+/**********************************************************************
+
+ ruby.h -
+
+ $Author$
+ created at: Thu Jun 10 14:26:32 JST 1993
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+ Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+ Copyright (C) 2000 Information-technology Promotion Agency, Japan
+
+**********************************************************************/
+
+#ifndef RUBY_H
+#define RUBY_H
+
+#if defined(__cplusplus)
+extern "C" {
+#if 0
+} /* satisfy cc-mode */
+#endif
+#endif
+
+#include "config.h"
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+
+#define NORETURN_STYLE_NEW 1
+#ifndef NORETURN
+# define NORETURN(x) x
+#endif
+#ifndef NOINLINE
+# define NOINLINE(x) x
+#endif
+
+#include "defines.h"
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+#ifdef HAVE_INTRINSICS_H
+# include <intrinsics.h>
+#endif
+
+#include <stddef.h>
+#include <stdio.h>
+
+/* need to include <ctype.h> to use these macros */
+#ifndef ISPRINT
+#define ISASCII(c) isascii((int)(unsigned char)(c))
+#undef ISPRINT
+#define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
+#define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
+#define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c)))
+#define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c)))
+#define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c)))
+#define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c)))
+#define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c)))
+#define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
+#endif
+
+#if defined(HAVE_ALLOCA_H)
+#include <alloca.h>
+#else
+# ifdef _AIX
+#pragma alloca
+# endif
+#endif
+
+#if defined(__VMS)
+# pragma builtins
+# define alloca __alloca
+#endif
+
+#if SIZEOF_LONG != SIZEOF_VOIDP
+# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
+#else
+typedef unsigned long VALUE;
+typedef unsigned long ID;
+#endif
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# ifndef LONG_MAX
+# ifdef HAVE_LIMITS_H
+# include <limits.h>
+# else
+ /* assuming 32bit(2's compliment) long */
+# define LONG_MAX 2147483647
+# endif
+# endif
+# ifndef LONG_MIN
+# define LONG_MIN (-LONG_MAX-1)
+# endif
+# ifndef CHAR_BIT
+# define CHAR_BIT 8
+# endif
+#endif
+
+#ifdef HAVE_LONG_LONG
+# ifndef LLONG_MAX
+# ifdef LONG_LONG_MAX
+# define LLONG_MAX LONG_LONG_MAX
+# else
+# ifdef _I64_MAX
+# define LLONG_MAX _I64_MAX
+# else
+ /* assuming 64bit(2's complement) long long */
+# define LLONG_MAX 9223372036854775807LL
+# endif
+# endif
+# endif
+# ifndef LLONG_MIN
+# ifdef LONG_LONG_MIN
+# define LLONG_MIN LONG_LONG_MIN
+# else
+# ifdef _I64_MIN
+# define LLONG_MIN _I64_MIN
+# else
+# define LLONG_MIN (-LLONG_MAX-1)
+# endif
+# endif
+# endif
+#endif
+
+#define FIXNUM_MAX (LONG_MAX>>1)
+#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
+
+#define FIXNUM_FLAG 0x01
+#define INT2FIX(i) ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG))
+#define LONG2FIX(i) INT2FIX(i)
+#define rb_fix_new(v) INT2FIX(v)
+VALUE rb_int2inum _((long));
+#define INT2NUM(v) rb_int2inum(v)
+#define LONG2NUM(v) INT2NUM(v)
+#define rb_int_new(v) rb_int2inum(v)
+VALUE rb_uint2inum _((unsigned long));
+#define UINT2NUM(v) rb_uint2inum(v)
+#define ULONG2NUM(v) UINT2NUM(v)
+#define rb_uint_new(v) rb_uint2inum(v)
+
+#ifdef HAVE_LONG_LONG
+VALUE rb_ll2inum _((LONG_LONG));
+#define LL2NUM(v) rb_ll2inum(v)
+VALUE rb_ull2inum _((unsigned LONG_LONG));
+#define ULL2NUM(v) rb_ull2inum(v)
+#endif
+
+#if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
+# define OFFT2NUM(v) LL2NUM(v)
+#elif SIZEOF_OFF_T == SIZEOF_LONG
+# define OFFT2NUM(v) LONG2NUM(v)
+#else
+# define OFFT2NUM(v) INT2NUM(v)
+#endif
+
+#define FIX2LONG(x) RSHIFT((long)x,1)
+#define FIX2ULONG(x) (((unsigned long)(x))>>1)
+#define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
+#define POSFIXABLE(f) ((f) < FIXNUM_MAX+1)
+#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
+#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
+
+#define IMMEDIATE_MASK 0x03
+#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
+
+#define SYMBOL_FLAG 0x0e
+#define SYMBOL_P(x) (((VALUE)(x)&0xff)==SYMBOL_FLAG)
+#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
+#define SYM2ID(x) RSHIFT((unsigned long)x,8)
+
+/* special contants - i.e. non-zero and non-fixnum constants */
+#define Qfalse ((VALUE)0)
+#define Qtrue ((VALUE)2)
+#define Qnil ((VALUE)4)
+#define Qundef ((VALUE)6) /* undefined value for placeholder */
+
+#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
+#define NIL_P(v) ((VALUE)(v) == Qnil)
+
+#define CLASS_OF(v) rb_class_of((VALUE)(v))
+
+#define T_NONE 0x00
+
+#define T_NIL 0x01
+#define T_OBJECT 0x02
+#define T_CLASS 0x03
+#define T_ICLASS 0x04
+#define T_MODULE 0x05
+#define T_FLOAT 0x06
+#define T_STRING 0x07
+#define T_REGEXP 0x08
+#define T_ARRAY 0x09
+#define T_FIXNUM 0x0a
+#define T_HASH 0x0b
+#define T_STRUCT 0x0c
+#define T_BIGNUM 0x0d
+#define T_FILE 0x0e
+
+#define T_TRUE 0x20
+#define T_FALSE 0x21
+#define T_DATA 0x22
+#define T_MATCH 0x23
+#define T_SYMBOL 0x24
+
+#define T_BLKTAG 0x3b
+#define T_UNDEF 0x3c
+#define T_VARMAP 0x3d
+#define T_SCOPE 0x3e
+#define T_NODE 0x3f
+
+#define T_MASK 0x3f
+
+#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
+
+#define TYPE(x) rb_type((VALUE)(x))
+
+#define RB_GC_GUARD(v) (*(volatile VALUE *)&(v))
+
+void rb_check_type _((VALUE,int));
+#define Check_Type(v,t) rb_check_type((VALUE)(v),t)
+
+VALUE rb_str_to_str _((VALUE));
+VALUE rb_string_value _((volatile VALUE*));
+char *rb_string_value_ptr _((volatile VALUE*));
+char *rb_string_value_cstr _((volatile VALUE*));
+
+#define StringValue(v) rb_string_value(&(v))
+#define StringValuePtr(v) rb_string_value_ptr(&(v))
+#define StringValueCStr(v) rb_string_value_cstr(&(v))
+
+void rb_check_safe_obj _((VALUE));
+void rb_check_safe_str _((VALUE));
+#define SafeStringValue(v) do {\
+ StringValue(v);\
+ rb_check_safe_obj(v);\
+} while (0)
+/* obsolete macro - use SafeStringValue(v) */
+#define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
+
+void rb_secure _((int));
+RUBY_EXTERN int ruby_safe_level;
+#define rb_safe_level() (ruby_safe_level)
+void rb_set_safe_level _((int));
+void rb_secure_update _((VALUE));
+
+long rb_num2long _((VALUE));
+unsigned long rb_num2ulong _((VALUE));
+#define NUM2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
+#define NUM2ULONG(x) rb_num2ulong((VALUE)x)
+#if SIZEOF_INT < SIZEOF_LONG
+long rb_num2int _((VALUE));
+#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):rb_num2int((VALUE)x))
+long rb_fix2int _((VALUE));
+#define FIX2INT(x) rb_fix2int((VALUE)x)
+unsigned long rb_num2uint _((VALUE));
+#define NUM2UINT(x) rb_num2uint(x)
+unsigned long rb_fix2uint _((VALUE));
+#define FIX2UINT(x) rb_fix2uint(x)
+#else
+#define NUM2INT(x) ((int)NUM2LONG(x))
+#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
+#define FIX2INT(x) ((int)FIX2LONG(x))
+#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
+#endif
+
+#ifdef HAVE_LONG_LONG
+LONG_LONG rb_num2ll _((VALUE));
+unsigned LONG_LONG rb_num2ull _((VALUE));
+# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
+# define NUM2ULL(x) rb_num2ull((VALUE)x)
+#endif
+
+#if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T > SIZEOF_LONG
+# define NUM2OFFT(x) ((off_t)NUM2LL(x))
+#else
+# define NUM2OFFT(x) NUM2LONG(x)
+#endif
+
+double rb_num2dbl _((VALUE));
+#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
+
+/* obsolete API - use StringValue() */
+char *rb_str2cstr _((VALUE,long*));
+/* obsolete API - use StringValuePtr() */
+#define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
+
+#define NUM2CHR(x) (((TYPE(x) == T_STRING)&&(RSTRING(x)->len>=1))?\
+ RSTRING(x)->ptr[0]:(char)(NUM2INT(x)&0xff))
+#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
+
+VALUE rb_newobj _((void));
+#define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
+#define OBJSETUP(obj,c,t) do {\
+ RBASIC(obj)->flags = (t);\
+ RBASIC(obj)->klass = (c);\
+ if (rb_safe_level() >= 3) FL_SET(obj, FL_TAINT);\
+} while (0)
+#define CLONESETUP(clone,obj) do {\
+ OBJSETUP(clone,rb_singleton_class_clone((VALUE)obj),RBASIC(obj)->flags);\
+ rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\
+ if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)clone,(VALUE)obj);\
+} while (0)
+#define DUPSETUP(dup,obj) do {\
+ OBJSETUP(dup,rb_obj_class(obj),(RBASIC(obj)->flags)&(T_MASK|FL_EXIVAR|FL_TAINT));\
+ if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)dup,(VALUE)obj);\
+} while (0)
+
+struct RBasic {
+ unsigned long flags;
+ VALUE klass;
+};
+
+struct RObject {
+ struct RBasic basic;
+ struct st_table *iv_tbl;
+};
+
+struct RClass {
+ struct RBasic basic;
+ struct st_table *iv_tbl;
+ struct st_table *m_tbl;
+ VALUE super;
+};
+#define RCLASS_IV_TBL(c) (RCLASS(c)->iv_tbl)
+#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
+#define RCLASS_SUPER(c) (RCLASS(c)->super)
+#define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m)
+#define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
+#define RMODULE_SUPER(m) RCLASS_SUPER(m)
+
+struct RFloat {
+ struct RBasic basic;
+ double value;
+};
+
+#define ELTS_SHARED FL_USER2
+
+struct RString {
+ struct RBasic basic;
+ long len;
+ char *ptr;
+ union {
+ long capa;
+ VALUE shared;
+ } aux;
+};
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+
+struct RArray {
+ struct RBasic basic;
+ long len;
+ union {
+ long capa;
+ VALUE shared;
+ } aux;
+ VALUE *ptr;
+};
+#define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#define RARRAY_LEN(s) (RARRAY(s)->len)
+
+struct RRegexp {
+ struct RBasic basic;
+ struct re_pattern_buffer *ptr;
+ long len;
+ char *str;
+};
+
+struct RHash {
+ struct RBasic basic;
+ struct st_table *tbl;
+ int iter_lev;
+ VALUE ifnone;
+};
+#define RHASH_TBL(h) (RHASH(h)->tbl)
+#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
+#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
+#define RHASH_SIZE(h) (RHASH(h)->tbl->num_entries)
+#define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
+
+struct RFile {
+ struct RBasic basic;
+ struct rb_io_t *fptr;
+};
+
+struct RData {
+ struct RBasic basic;
+ void (*dmark) _((void*));
+ void (*dfree) _((void*));
+ void *data;
+};
+
+#define DATA_PTR(dta) (RDATA(dta)->data)
+
+/*
+#define RUBY_DATA_FUNC(func) ((void (*)_((void*)))func)
+*/
+typedef void (*RUBY_DATA_FUNC) _((void*));
+
+VALUE rb_data_object_alloc _((VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
+
+#define Data_Wrap_Struct(klass,mark,free,sval)\
+ rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)
+
+#define Data_Make_Struct(klass,type,mark,free,sval) (\
+ sval = ALLOC(type),\
+ memset(sval, 0, sizeof(type)),\
+ Data_Wrap_Struct(klass,mark,free,sval)\
+)
+
+#define Data_Get_Struct(obj,type,sval) do {\
+ Check_Type(obj, T_DATA); \
+ sval = (type*)DATA_PTR(obj);\
+} while (0)
+
+struct RStruct {
+ struct RBasic basic;
+ long len;
+ VALUE *ptr;
+};
+#define RSTRUCT_LEN(st) (RSTRUCT(st)->len)
+#define RSTRUCT_PTR(st) (RSTRUCT(st)->ptr)
+
+struct RBignum {
+ struct RBasic basic;
+ char sign;
+ long len;
+ void *digits;
+};
+
+#define R_CAST(st) (struct st*)
+#define RBASIC(obj) (R_CAST(RBasic)(obj))
+#define ROBJECT(obj) (R_CAST(RObject)(obj))
+#define RCLASS(obj) (R_CAST(RClass)(obj))
+#define RMODULE(obj) RCLASS(obj)
+#define RFLOAT(obj) (R_CAST(RFloat)(obj))
+#define RSTRING(obj) (R_CAST(RString)(obj))
+#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
+#define RARRAY(obj) (R_CAST(RArray)(obj))
+#define RHASH(obj) (R_CAST(RHash)(obj))
+#define RDATA(obj) (R_CAST(RData)(obj))
+#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
+#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
+#define RFILE(obj) (R_CAST(RFile)(obj))
+
+#define FL_SINGLETON FL_USER0
+#define FL_MARK (1<<6)
+#define FL_FINALIZE (1<<7)
+#define FL_TAINT (1<<8)
+#define FL_EXIVAR (1<<9)
+#define FL_FREEZE (1<<10)
+
+#define FL_USHIFT 11
+
+#define FL_USER0 (1<<(FL_USHIFT+0))
+#define FL_USER1 (1<<(FL_USHIFT+1))
+#define FL_USER2 (1<<(FL_USHIFT+2))
+#define FL_USER3 (1<<(FL_USHIFT+3))
+#define FL_USER4 (1<<(FL_USHIFT+4))
+#define FL_USER5 (1<<(FL_USHIFT+5))
+#define FL_USER6 (1<<(FL_USHIFT+6))
+#define FL_USER7 (1<<(FL_USHIFT+7))
+
+#define FL_UMASK (0xff<<FL_USHIFT)
+
+#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
+
+#define FL_ABLE(x) (!SPECIAL_CONST_P(x))
+#define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
+#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
+#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
+#define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
+
+#define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
+#define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
+#define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
+
+#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
+#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
+
+#define ALLOC_N(type,n) (type*)xmalloc(sizeof(type)*(n))
+#define ALLOC(type) (type*)xmalloc(sizeof(type))
+#define REALLOC_N(var,type,n) (var)=(type*)xrealloc((char*)(var),sizeof(type)*(n))
+
+#define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
+
+#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
+#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
+#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
+#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
+
+void rb_obj_infect _((VALUE,VALUE));
+
+typedef int ruby_glob_func(const char*,VALUE);
+void rb_glob _((const char*,void(*)(const char*,VALUE),VALUE));
+void rb_globi _((const char*,void(*)(const char*,VALUE),VALUE));
+int ruby_brace_expand _((const char*,int,ruby_glob_func*,VALUE));
+int ruby_brace_glob _((const char*,int,ruby_glob_func*,VALUE));
+
+VALUE rb_define_class _((const char*,VALUE));
+VALUE rb_define_module _((const char*));
+VALUE rb_define_class_under _((VALUE, const char*, VALUE));
+VALUE rb_define_module_under _((VALUE, const char*));
+
+void rb_include_module _((VALUE,VALUE));
+void rb_extend_object _((VALUE,VALUE));
+
+void rb_define_variable _((const char*,VALUE*));
+void rb_define_virtual_variable _((const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
+void rb_define_hooked_variable _((const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
+int ruby_glob _((const char*,int,int(*)(const char*,VALUE),VALUE));
+int ruby_globi _((const char*,int,int(*)(const char*,VALUE),VALUE));
+void rb_define_readonly_variable _((const char*,VALUE*));
+void rb_define_const _((VALUE,const char*,VALUE));
+void rb_define_global_const _((const char*,VALUE));
+
+#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
+void rb_define_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
+void rb_define_module_function _((VALUE,const char*,VALUE(*)(ANYARGS),int));
+void rb_define_global_function _((const char*,VALUE(*)(ANYARGS),int));
+
+void rb_undef_method _((VALUE,const char*));
+void rb_define_alias _((VALUE,const char*,const char*));
+void rb_define_attr _((VALUE,const char*,int,int));
+
+void rb_global_variable _((VALUE*));
+void rb_gc_register_address _((VALUE*));
+void rb_gc_unregister_address _((VALUE*));
+
+ID rb_intern _((const char*));
+const char *rb_id2name _((ID));
+ID rb_to_id _((VALUE));
+
+const char *rb_class2name _((VALUE));
+const char *rb_obj_classname _((VALUE));
+
+void rb_p _((VALUE));
+
+VALUE rb_eval_string _((const char*));
+VALUE rb_eval_string_protect _((const char*, int*));
+VALUE rb_eval_string_wrap _((const char*, int*));
+VALUE rb_funcall __((VALUE, ID, int, ...));
+VALUE rb_funcall2 _((VALUE, ID, int, const VALUE*));
+VALUE rb_funcall3 _((VALUE, ID, int, const VALUE*));
+int rb_scan_args __((int, const VALUE*, const char*, ...));
+VALUE rb_call_super _((int, const VALUE*));
+
+VALUE rb_gv_set _((const char*, VALUE));
+VALUE rb_gv_get _((const char*));
+VALUE rb_iv_get _((VALUE, const char*));
+VALUE rb_iv_set _((VALUE, const char*, VALUE));
+
+VALUE rb_equal _((VALUE,VALUE));
+
+RUBY_EXTERN VALUE ruby_verbose, ruby_debug;
+
+NORETURN(void rb_raise __((VALUE, const char*, ...)));
+NORETURN(void rb_fatal __((const char*, ...)));
+NORETURN(void rb_bug __((const char*, ...)));
+NORETURN(void rb_sys_fail _((const char*)));
+NORETURN(void rb_iter_break _((void)));
+NORETURN(void rb_exit _((int)));
+NORETURN(void rb_notimplement _((void)));
+
+void rb_warning __((const char*, ...)); /* reports if `-w' specified */
+void rb_sys_warning __((const char*, ...)); /* reports if `-w' specified */
+void rb_warn __((const char*, ...)); /* reports always */
+
+typedef VALUE rb_block_call_func _((VALUE, VALUE));
+
+VALUE rb_each _((VALUE));
+VALUE rb_yield _((VALUE));
+VALUE rb_yield_values __((int n, ...));
+VALUE rb_yield_splat _((VALUE));
+int rb_block_given_p _((void));
+void rb_need_block _((void));
+VALUE rb_iterate _((VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE));
+VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
+VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...));
+VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
+VALUE rb_catch _((const char*,VALUE(*)(ANYARGS),VALUE));
+NORETURN(void rb_throw _((const char*,VALUE)));
+
+VALUE rb_require _((const char*));
+
+#ifdef __ia64
+void ruby_init_stack(VALUE*, void*);
+#define RUBY_INIT_STACK \
+ VALUE variable_in_this_stack_frame; \
+ ruby_init_stack(&variable_in_this_stack_frame, rb_ia64_bsp());
+#else
+void ruby_init_stack(VALUE*);
+#define RUBY_INIT_STACK \
+ VALUE variable_in_this_stack_frame; \
+ ruby_init_stack(&variable_in_this_stack_frame);
+#endif
+void ruby_init _((void));
+void ruby_options _((int, char**));
+NORETURN(void ruby_run _((void)));
+
+RUBY_EXTERN VALUE rb_mKernel;
+RUBY_EXTERN VALUE rb_mComparable;
+RUBY_EXTERN VALUE rb_mEnumerable;
+RUBY_EXTERN VALUE rb_mPrecision;
+RUBY_EXTERN VALUE rb_mErrno;
+RUBY_EXTERN VALUE rb_mFileTest;
+RUBY_EXTERN VALUE rb_mGC;
+RUBY_EXTERN VALUE rb_mMath;
+RUBY_EXTERN VALUE rb_mProcess;
+
+RUBY_EXTERN VALUE rb_cObject;
+RUBY_EXTERN VALUE rb_cArray;
+RUBY_EXTERN VALUE rb_cBignum;
+RUBY_EXTERN VALUE rb_cBinding;
+RUBY_EXTERN VALUE rb_cClass;
+RUBY_EXTERN VALUE rb_cCont;
+RUBY_EXTERN VALUE rb_cDir;
+RUBY_EXTERN VALUE rb_cData;
+RUBY_EXTERN VALUE rb_cEnumerator;
+RUBY_EXTERN VALUE rb_cFalseClass;
+RUBY_EXTERN VALUE rb_cFile;
+RUBY_EXTERN VALUE rb_cFixnum;
+RUBY_EXTERN VALUE rb_cFloat;
+RUBY_EXTERN VALUE rb_cHash;
+RUBY_EXTERN VALUE rb_cInteger;
+RUBY_EXTERN VALUE rb_cIO;
+RUBY_EXTERN VALUE rb_cMatch;
+RUBY_EXTERN VALUE rb_cMethod;
+RUBY_EXTERN VALUE rb_cModule;
+RUBY_EXTERN VALUE rb_cNameErrorMesg;
+RUBY_EXTERN VALUE rb_cNilClass;
+RUBY_EXTERN VALUE rb_cNumeric;
+RUBY_EXTERN VALUE rb_cProc;
+RUBY_EXTERN VALUE rb_cRange;
+RUBY_EXTERN VALUE rb_cRegexp;
+RUBY_EXTERN VALUE rb_cStat;
+RUBY_EXTERN VALUE rb_cString;
+RUBY_EXTERN VALUE rb_cStruct;
+RUBY_EXTERN VALUE rb_cSymbol;
+RUBY_EXTERN VALUE rb_cThread;
+RUBY_EXTERN VALUE rb_cTime;
+RUBY_EXTERN VALUE rb_cTrueClass;
+RUBY_EXTERN VALUE rb_cUnboundMethod;
+
+RUBY_EXTERN VALUE rb_eException;
+RUBY_EXTERN VALUE rb_eStandardError;
+RUBY_EXTERN VALUE rb_eSystemExit;
+RUBY_EXTERN VALUE rb_eInterrupt;
+RUBY_EXTERN VALUE rb_eSignal;
+RUBY_EXTERN VALUE rb_eFatal;
+RUBY_EXTERN VALUE rb_eArgError;
+RUBY_EXTERN VALUE rb_eEOFError;
+RUBY_EXTERN VALUE rb_eIndexError;
+RUBY_EXTERN VALUE rb_eStopIteration;
+RUBY_EXTERN VALUE rb_eRangeError;
+RUBY_EXTERN VALUE rb_eIOError;
+RUBY_EXTERN VALUE rb_eRuntimeError;
+RUBY_EXTERN VALUE rb_eSecurityError;
+RUBY_EXTERN VALUE rb_eSystemCallError;
+RUBY_EXTERN VALUE rb_eThreadError;
+RUBY_EXTERN VALUE rb_eTypeError;
+RUBY_EXTERN VALUE rb_eZeroDivError;
+RUBY_EXTERN VALUE rb_eNotImpError;
+RUBY_EXTERN VALUE rb_eNoMemError;
+RUBY_EXTERN VALUE rb_eNoMethodError;
+RUBY_EXTERN VALUE rb_eFloatDomainError;
+RUBY_EXTERN VALUE rb_eLocalJumpError;
+RUBY_EXTERN VALUE rb_eSysStackError;
+RUBY_EXTERN VALUE rb_eRegexpError;
+
+RUBY_EXTERN VALUE rb_eScriptError;
+RUBY_EXTERN VALUE rb_eNameError;
+RUBY_EXTERN VALUE rb_eSyntaxError;
+RUBY_EXTERN VALUE rb_eLoadError;
+
+RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
+RUBY_EXTERN VALUE ruby_errinfo;
+
+static inline VALUE
+#if defined(HAVE_PROTOTYPES)
+rb_class_of(VALUE obj)
+#else
+rb_class_of(obj)
+ VALUE obj;
+#endif
+{
+ if (FIXNUM_P(obj)) return rb_cFixnum;
+ if (obj == Qnil) return rb_cNilClass;
+ if (obj == Qfalse) return rb_cFalseClass;
+ if (obj == Qtrue) return rb_cTrueClass;
+ if (SYMBOL_P(obj)) return rb_cSymbol;
+
+ return RBASIC(obj)->klass;
+}
+
+static inline int
+#if defined(HAVE_PROTOTYPES)
+rb_type(VALUE obj)
+#else
+rb_type(obj)
+ VALUE obj;
+#endif
+{
+ if (FIXNUM_P(obj)) return T_FIXNUM;
+ if (obj == Qnil) return T_NIL;
+ if (obj == Qfalse) return T_FALSE;
+ if (obj == Qtrue) return T_TRUE;
+ if (obj == Qundef) return T_UNDEF;
+ if (SYMBOL_P(obj)) return T_SYMBOL;
+ return BUILTIN_TYPE(obj);
+}
+
+static inline int
+#if defined(HAVE_PROTOTYPES)
+rb_special_const_p(VALUE obj)
+#else
+rb_special_const_p(obj)
+ VALUE obj;
+#endif
+{
+ if (SPECIAL_CONST_P(obj)) return Qtrue;
+ return Qfalse;
+}
+
+#include "missing.h"
+#include "intern.h"
+
+#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
+/* hook for external modules */
+static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
+#endif
+
+#if defined(HAVE_LIBPTHREAD)
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+typedef pthread_t rb_nativethread_t;
+# define NATIVETHREAD_CURRENT() pthread_self()
+# define NATIVETHREAD_EQUAL(t1,t2) pthread_equal((t1),(t2))
+# define HAVE_NATIVETHREAD
+
+# define NATIVETHREAD_KILL(th,sig) pthread_kill((th),(sig))
+# define HAVE_NATIVETHREAD_KILL
+#elif defined(_WIN32) || defined(_WIN32_WCE)
+typedef DWORD rb_nativethread_t;
+# define NATIVETHREAD_CURRENT() GetCurrentThreadId()
+# define NATIVETHREAD_EQUAL(t1,t2) ((t1) == (t2))
+# define HAVE_NATIVETHREAD
+#endif
+#ifdef HAVE_NATIVETHREAD
+int is_ruby_native_thread _((void));
+#else
+#define is_ruby_native_thread() (1)
+#endif
+#ifdef HAVE_NATIVETHREAD_KILL
+void ruby_native_thread_kill _((int));
+#endif
+
+#if defined(__cplusplus)
+#if 0
+{ /* satisfy cc-mode */
+#endif
+} /* extern "C" { */
+#endif
+
+#endif /* ifndef RUBY_H */
diff --git a/rubyio.h b/rubyio.h
new file mode 100644
index 0000000000..a1ac885500
--- /dev/null
+++ b/rubyio.h
@@ -0,0 +1,91 @@
+/**********************************************************************
+
+ rubyio.h -
+
+ $Author$
+ $Date$
+ created at: Fri Nov 12 16:47:09 JST 1993
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef RUBYIO_H
+#define RUBYIO_H
+
+#include <stdio.h>
+#include <errno.h>
+
+#if defined(HAVE_STDIO_EXT_H)
+#include <stdio_ext.h>
+#endif
+
+typedef struct rb_io_t {
+ FILE *f; /* stdio ptr for read/write */
+ FILE *f2; /* additional ptr for rw pipes */
+ int mode; /* mode flags */
+ int pid; /* child's pid (for pipes) */
+ int lineno; /* number of lines read */
+ char *path; /* pathname for file */
+ void (*finalize) _((struct rb_io_t*,int)); /* finalize proc */
+} rb_io_t;
+
+#define HAVE_RB_IO_T 1
+#define OpenFile rb_io_t /* for backward compatibility */
+
+#define FMODE_READABLE 1
+#define FMODE_WRITABLE 2
+#define FMODE_READWRITE 3
+#define FMODE_APPEND 64
+#define FMODE_CREATE 128
+#define FMODE_BINMODE 4
+#define FMODE_SYNC 8
+#define FMODE_WBUF 16
+#define FMODE_RBUF 32
+#define FMODE_WSPLIT 0x200
+#define FMODE_WSPLIT_INITIALIZED 0x400
+
+#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
+
+#define MakeOpenFile(obj, fp) do {\
+ if (RFILE(obj)->fptr) {\
+ rb_io_close(obj);\
+ free(RFILE(obj)->fptr);\
+ RFILE(obj)->fptr = 0;\
+ }\
+ fp = 0;\
+ fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
+ fp->f = fp->f2 = NULL;\
+ fp->mode = 0;\
+ fp->pid = 0;\
+ fp->lineno = 0;\
+ fp->path = NULL;\
+ fp->finalize = 0;\
+} while (0)
+
+#define GetReadFile(fptr) ((fptr)->f)
+#define GetWriteFile(fptr) (((fptr)->f2) ? (fptr)->f2 : (fptr)->f)
+
+FILE *rb_fopen _((const char*, const char*));
+FILE *rb_fdopen _((int, const char*));
+int rb_getc _((FILE*));
+long rb_io_fread _((char *, long, FILE *));
+long rb_io_fwrite _((const char *, long, FILE *));
+int rb_io_mode_flags _((const char*));
+int rb_io_modenum_flags _((int));
+void rb_io_check_writable _((rb_io_t*));
+void rb_io_check_readable _((rb_io_t*));
+void rb_io_fptr_finalize _((rb_io_t*));
+void rb_io_synchronized _((rb_io_t*));
+void rb_io_check_initialized _((rb_io_t*));
+void rb_io_check_closed _((rb_io_t*));
+int rb_io_wait_readable _((int));
+int rb_io_wait_writable _((int));
+void rb_io_set_nonblock(rb_io_t *fptr);
+
+VALUE rb_io_taint_check _((VALUE));
+NORETURN(void rb_eof_error _((void)));
+
+void rb_read_check _((FILE*));
+int rb_read_pending _((FILE*));
+#endif
diff --git a/rubysig.h b/rubysig.h
new file mode 100644
index 0000000000..3eb877855e
--- /dev/null
+++ b/rubysig.h
@@ -0,0 +1,105 @@
+/**********************************************************************
+
+ rubysig.h -
+
+ $Author$
+ $Date$
+ created at: Wed Aug 16 01:15:38 JST 1995
+
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef SIG_H
+#define SIG_H
+#include <errno.h>
+
+#ifdef _WIN32
+typedef LONG rb_atomic_t;
+
+# define ATOMIC_TEST(var) InterlockedExchange(&(var), 0)
+# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
+# define ATOMIC_INC(var) InterlockedIncrement(&(var))
+# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
+
+/* Windows doesn't allow interrupt while system calls */
+# define TRAP_BEG do {\
+ int saved_errno = 0;\
+ rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1)
+# define TRAP_END\
+ ATOMIC_SET(rb_trap_immediate, trap_immediate);\
+ saved_errno = errno;\
+ CHECK_INTS;\
+ errno = saved_errno;\
+} while (0)
+# define RUBY_CRITICAL(statements) do {\
+ rb_w32_enter_critical();\
+ statements;\
+ rb_w32_leave_critical();\
+} while (0)
+#else
+typedef int rb_atomic_t;
+
+# define ATOMIC_TEST(var) ((var) ? ((var) = 0, 1) : 0)
+# define ATOMIC_SET(var, val) ((var) = (val))
+# define ATOMIC_INC(var) (++(var))
+# define ATOMIC_DEC(var) (--(var))
+
+# define TRAP_BEG do {\
+ int saved_errno = 0;\
+ int trap_immediate = rb_trap_immediate;\
+ rb_trap_immediate = 1
+# define TRAP_END rb_trap_immediate = trap_immediate;\
+ saved_errno = errno;\
+ CHECK_INTS;\
+ errno = saved_errno;\
+} while (0)
+
+# define RUBY_CRITICAL(statements) do {\
+ int trap_immediate = rb_trap_immediate;\
+ rb_trap_immediate = 0;\
+ statements;\
+ rb_trap_immediate = trap_immediate;\
+} while (0)
+#endif
+RUBY_EXTERN rb_atomic_t rb_trap_immediate;
+
+RUBY_EXTERN int rb_prohibit_interrupt;
+#define DEFER_INTS (rb_prohibit_interrupt++)
+#define ALLOW_INTS do {\
+ rb_prohibit_interrupt--;\
+ CHECK_INTS;\
+} while (0)
+#define ENABLE_INTS (rb_prohibit_interrupt--)
+
+VALUE rb_with_disable_interrupt _((VALUE(*)(ANYARGS),VALUE));
+
+RUBY_EXTERN rb_atomic_t rb_trap_pending;
+void rb_trap_restore_mask _((void));
+
+RUBY_EXTERN int rb_thread_critical;
+RUBY_EXTERN int rb_thread_pending;
+void rb_thread_schedule _((void));
+#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
+# define CHECK_INTS do {\
+ if (!(rb_prohibit_interrupt || rb_thread_critical)) {\
+ if (rb_thread_pending) rb_thread_schedule();\
+ if (rb_trap_pending) rb_trap_exec();\
+ }\
+} while (0)
+#else
+/* pseudo preemptive thread switching */
+RUBY_EXTERN int rb_thread_tick;
+#define THREAD_TICK 500
+#define CHECK_INTS do {\
+ if (!(rb_prohibit_interrupt || rb_thread_critical)) {\
+ if (rb_thread_pending || rb_thread_tick-- <= 0) {\
+ rb_thread_tick = THREAD_TICK;\
+ rb_thread_schedule();\
+ }\
+ }\
+ if (rb_trap_pending) rb_trap_exec();\
+} while (0)
+#endif
+
+#endif
diff --git a/rubytest.rb b/rubytest.rb
index fb836735f5..8ae637c00e 100755
--- a/rubytest.rb
+++ b/rubytest.rb
@@ -2,7 +2,7 @@
exit if defined?(CROSS_COMPILING)
load './rbconfig.rb'
-include RbConfig
+include Config
ruby = "./#{CONFIG['ruby_install_name']}#{CONFIG['EXEEXT']}"
unless File.exist? ruby
@@ -37,13 +37,13 @@ $stderr.reopen($stdout)
error = ''
srcdir = File.dirname(__FILE__)
-`#{ruby} -I#{srcdir}/lib #{srcdir}/sample/test.rb`.each_line do |line|
+`#{ruby} -I#{srcdir}/lib #{srcdir}/sample/test.rb`.each do |line|
if line =~ /^end of test/
- print "\ntest succeeded\n"
- exit true
+ print "test succeeded\n"
+ exit 0
end
- error << line if %r:^(sample/test.rb|not): =~ line
+ error << line if line =~ %r:^(sample/test.rb|not):
end
print error
print "test failed\n"
-exit false
+exit 1
diff --git a/sample/README b/sample/README
index e3340ba311..bc38a8b2d0 100644
--- a/sample/README
+++ b/sample/README
@@ -3,6 +3,7 @@ biorhythm.rb biorhythm calculator
cal.rb cal(1) clone
cbreak.rb no echo done by ioctl
clnt.rb socket client
+dbmtest.rb test for dbm
dir.rb directory access
dualstack-fetch.rb IPv6 demo
dualstack-httpd.rb IPv6 demo
@@ -19,7 +20,7 @@ fib.scm Fibonacci number (Scheme)
freq.rb count word occurrence
from.rb scan mail spool
fullpath.rb convert ls -lR to fullpath format
-goodfriday.rb print various christian calendar event.
+getopts.test test fot getopt.rb
io.rb io test
irb.rb interactive ruby
less.rb front end for less
@@ -27,8 +28,9 @@ list.rb stupid object sample
list2.rb stupid object sample
list3.rb stupid object sample
mine.rb simple mine sweeper
-mkproto.rb extract prototype from C
+mkproto.rb extract prototype from C
mpart.rb split file int multi part
+mrshtest.rb test marshal
observ.rb observer design pattern sample
occur.pl count word occurrence (Perl)
occur.rb count word occurrence (Ruby)
@@ -39,6 +41,7 @@ rcs.awk random character stereogram (AWK)
rcs.rb random character stereogram (Ruby)
rcs.dat data for random character stereogram
rd2html.rb rd (Ruby Document) to HTML translator
+regx.rb regular expression tester
sieve.rb sieve of Eratosthenes
svr.rb socket server
test.rb test suite used by `make test'
diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb
index f2dff503ee..c7e26c4fff 100644
--- a/sample/biorhythm.rb
+++ b/sample/biorhythm.rb
@@ -27,8 +27,21 @@
include Math
require "date.rb"
-require "optparse"
-require "optparse/date"
+require "parsearg.rb"
+require "parsedate.rb"
+
+def usage()
+ print "Usage:\n"
+ print "biorhythm.rb [options]\n"
+ print " options...\n"
+ print " -D YYYYMMDD(birthday) : use default values.\n"
+ print " --sdate | --date YYYYMMDD : use system date; use specified date.\n"
+ print " --birthday YYYYMMDD : specifies your birthday.\n"
+ print " -v | -g : show values or graph.\n"
+ print " --days DAYS : graph range (only in effect for graphs).\n"
+ print " --help : help\n"
+end
+$USAGE = 'usage'
def printHeader(y, m, d, p, w)
print "\n>>> Biorhythm <<<\n"
@@ -45,52 +58,60 @@ def getPosition(z)
return phys, emot, geist
end
-def prompt(msg)
- $stderr.print msg
- return gets.chomp
+def parsedate(s)
+ ParseDate::parsedate(s).values_at(0, 1, 2)
+end
+
+def name_of_week(date)
+ Date::DAYNAMES[date.wday]
end
#
# main program
#
-options = {
- :graph => true,
- :date => Date.today,
- :days => 9,
-}
-ARGV.options do |opts|
- opts.on("-b", "--birthday=DATE", Date, "specify your birthday"){|v|
- options[:birthday] = v
- }
- opts.on("--date=DATE", Date, "specify date to show"){|v|
- options[:date] = v
- }
- opts.on("-g", "--show-graph", TrueClass, "show graph (default)"){|v|
- options[:graph] = v
- }
- opts.on("-v", "--show-values", TrueClass, "show values"){|v|
- options[:graph] = !v
- }
- opts.on("--days=DAYS", Integer, "graph range (only in effect for graph)"){|v|
- options[:days] = v - 1
- }
- opts.on_tail("-h", "--help", "show this message"){puts opts; exit}
- begin
- opts.parse!
- rescue => ex
- puts "Error: #{ex.message}"
- puts opts
- exit
+parseArgs(0, nil, "vg", "D:", "sdate", "date:", "birthday:", "days:")
+
+if $OPT_D
+ dd = Date.today
+ bd = Date.new(*parsedate($OPT_D))
+ ausgabeart = "g"
+else
+ if $OPT_birthday
+ bd = Date.new(*parsedate($OPT_birthday))
+ else
+ STDERR.print("Birthday (YYYYMMDD) : ")
+ unless (si = STDIN.gets.chop).empty?
+ bd = Date.new(*parsedate(si))
+ end
+ end
+ if !bd
+ STDERR.print "BAD Input Birthday!!\n"
+ exit()
end
-end
-bd = options[:birthday] || Date.parse(prompt("Your birthday (YYYYMMDD): "))
-dd = options[:date] || Date.today
-ausgabeart = options[:graph] ? "g" : "v"
-display_period = options[:days]
+ if $OPT_sdate
+ dd = Date.today
+ elsif $OPT_date
+ dd = Date.new(*parsedate($OPT_date))
+ else
+ STDERR.print("Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
+ unless (si = STDIN.gets.chop).empty?
+ dd = Date.new(*parsedate(si))
+ end
+ end
+ dd ||= Date.today
+ if $OPT_v
+ ausgabeart = "v"
+ elsif $OPT_g
+ ausgabeart = "g"
+ else
+ STDERR.print("Values for today or Graph (v/g) [default g] : ")
+ ausgabeart = STDIN.gets.chop
+ end
+end
if ausgabeart == "v"
- printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
+ printHeader(bd.year, bd.month, bd.day, dd - bd, name_of_week(bd))
print "\n"
phys, emot, geist = getPosition(dd - bd)
@@ -100,7 +121,21 @@ if ausgabeart == "v"
printf "Mental: %d%%\n", geist
print "\n"
else
- printHeader(bd.year, bd.month, bd.day, dd - bd, bd.strftime("%a"))
+ if $OPT_days
+ display_period = $OPT_days.to_i
+ elsif $OPT_D
+ display_period = 9
+ else
+ STDERR.printf("Graph for how many days [default 10] : ")
+ display_period = STDIN.gets.chop
+ if display_period.empty?
+ display_period = 9
+ else
+ display_period = display_period.to_i - 1
+ end
+ end
+
+ printHeader(bd.year, bd.month, bd.day, dd - bd, name_of_week(bd))
print " P=physical, E=emotional, M=mental\n"
print " -------------------------+-------------------------\n"
print " Bad Condition | Good Condition\n"
diff --git a/sample/cal.rb b/sample/cal.rb
index 197cdfe3a6..387657490f 100644
--- a/sample/cal.rb
+++ b/sample/cal.rb
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby
-# cal.rb: Written by Tadayoshi Funaba 1998-2004
-# $Id: cal.rb,v 2.8 2004-09-25 12:50:10+09 tadf Exp $
+# cal.rb: Written by Tadayoshi Funaba 1998-2004,2006,2008
+# $Id: cal.rb,v 2.11 2008-01-06 08:42:17+09 tadf Exp $
require 'date'
@@ -9,25 +9,25 @@ class Cal
START =
{
- 'cn' => true, # China
- 'de' => 2342032, # Germany (protestant states)
- 'dk' => 2342032, # Denmark
- 'es' => 2299161, # Spain
- 'fi' => 2361390, # Finland
- 'fr' => 2299227, # France
- 'gb' => 2361222, # United Kingdom
- 'gr' => 2423868, # Greece
- 'hu' => 2301004, # Hungary
- 'it' => 2299161, # Italy
- 'jp' => true, # Japan
- 'no' => 2342032, # Norway
- 'pl' => 2299161, # Poland
- 'pt' => 2299161, # Portugal
- 'ru' => 2421639, # Russia
- 'se' => 2361390, # Sweden
- 'us' => 2361222, # United States
- 'os' => false, # (old style)
- 'ns' => true # (new style)
+ 'cn' => Date::GREGORIAN, # China
+ 'de' => 2342032, # Germany (protestant states)
+ 'dk' => 2342032, # Denmark
+ 'es' => 2299161, # Spain
+ 'fi' => 2361390, # Finland
+ 'fr' => 2299227, # France
+ 'gb' => 2361222, # United Kingdom
+ 'gr' => 2423868, # Greece
+ 'hu' => 2301004, # Hungary
+ 'it' => 2299161, # Italy
+ 'jp' => Date::GREGORIAN, # Japan
+ 'no' => 2342032, # Norway
+ 'pl' => 2299161, # Poland
+ 'pt' => 2299161, # Portugal
+ 'ru' => 2421639, # Russia
+ 'se' => 2361390, # Sweden
+ 'us' => 2361222, # United States
+ 'os' => Date::JULIAN, # (old style)
+ 'ns' => Date::GREGORIAN # (new style)
}
DEFAULT_START = 'gb'
@@ -53,7 +53,7 @@ class Cal
end
def pict(y, m)
- d = (1..31).detect{|d| Date.valid_date?(y, m, d, @start)}
+ d = (1..31).detect{|x| Date.valid_date?(y, m, x, @start)}
fi = Date.new(y, m, d, @start)
fi -= (fi.jd - @k + 1) % 7
@@ -72,7 +72,7 @@ class Cal
ca = %w(January February March April May June July
August September October November December)[m - 1]
- ca = ca + ' ' + y.to_s if not @opt_y
+ ca = ca + ' ' + y.to_s if !@opt_y
ca = ca.center(@mw)
ta.unshift(ca)
@@ -150,15 +150,17 @@ if __FILE__ == $0
end
y, m = ARGV.values_at(1, 0).compact.collect{|x| x.to_i}
- cal.opt_y(true) if y and not m
+ cal.opt_y(true) if y && !m
to = Date.today
y ||= to.year
m ||= to.mon
- usage unless m >= 1 and m <= 12
+ usage unless m >= 1 && m <= 12
usage unless y >= -4712
print cal.print(y, m)
end
+
+# See Bird & Wadler's Introduction to functional programming 4.5.
diff --git a/sample/dbmtest.rb b/sample/dbmtest.rb
new file mode 100644
index 0000000000..c77cc2065b
--- /dev/null
+++ b/sample/dbmtest.rb
@@ -0,0 +1,14 @@
+# ruby dbm acess
+require "dbm"
+
+d = DBM.open("test")
+keys = d.keys
+if keys.length > 0 then
+ for k in keys; print k, "\n"; end
+ for v in d.values; print v, "\n"; end
+else
+ d['foobar'] = 'FB'
+ d['baz'] = 'BZ'
+ d['quux'] = 'QX'
+end
+
diff --git a/sample/drb/darrayc.rb b/sample/drb/darrayc.rb
index b181d22699..6f5ff6bb5d 100644
--- a/sample/drb/darrayc.rb
+++ b/sample/drb/darrayc.rb
@@ -45,3 +45,15 @@ ro.each do |x|
puts count
redo if count == 3
end
+
+puts "# each, retry"
+retried = false
+ro.each do |x|
+ puts x
+ if x == 4 && !retried
+ puts 'retry'
+ retried = true
+ retry
+ end
+end
+
diff --git a/sample/erb/erb4html.rb b/sample/erb/erb4html.rb
new file mode 100644
index 0000000000..df0ffae44f
--- /dev/null
+++ b/sample/erb/erb4html.rb
@@ -0,0 +1,60 @@
+require 'erb'
+
+class ERB
+ class ERBString < String
+ def to_s; self; end
+
+ def erb_concat(s)
+ if self.class === s
+ concat(s)
+ else
+ concat(erb_quote(s))
+ end
+ end
+
+ def erb_quote(s); s; end
+ end
+end
+
+class ERB4Html < ERB
+ def self.quoted(s)
+ HtmlString.new(s)
+ end
+
+ class HtmlString < ERB::ERBString
+ def erb_quote(s)
+ ERB::Util::html_escape(s)
+ end
+ end
+
+ def set_eoutvar(compiler, eoutvar = '_erbout')
+ compiler.put_cmd = "#{eoutvar}.concat"
+ compiler.insert_cmd = "#{eoutvar}.erb_concat"
+
+ cmd = []
+ cmd.push "#{eoutvar} = ERB4Html.quoted('')"
+
+ compiler.pre_cmd = cmd
+
+ cmd = []
+ cmd.push(eoutvar)
+
+ compiler.post_cmd = cmd
+ end
+end
+
+if __FILE__ == $0
+ page = <<EOP
+<title><%=title%></title>
+<p><%=para%></p>
+EOP
+ erb = ERB4Html.new(page)
+
+ title = "<auto-quote>"
+ para = "&lt;quoted&gt;"
+ puts erb.result
+
+ title = "<auto-quote>"
+ para = ERB4Html.quoted("&lt;quoted&gt;")
+ puts erb.result
+end
diff --git a/sample/from.rb b/sample/from.rb
index aa93e6726a..6b0c702bb7 100644
--- a/sample/from.rb
+++ b/sample/from.rb
@@ -1,113 +1,98 @@
#! /usr/local/bin/ruby
-require "time"
+require "parsedate"
require "kconv"
+require "mailread"
+
+include ParseDate
+include Kconv
class String
+
+ def kconv(code = Kconv::EUC)
+ Kconv.kconv(self, code, Kconv::AUTO)
+ end
+
def kjust(len)
- res = ''
- rlen = 0
- self.each_char do |char|
- delta = char.bytesize > 1 ? 2 : 1
- break if rlen + delta > len
- rlen += delta
- res += char
+ len += 1
+ me = self[0, len].ljust(len)
+ if me =~ /.$/ and $&.size == 2
+ me[-2..-1] = ' '
+ me[-2, 2] = ' '
end
- res += ' ' * (len - rlen) if rlen < len
- res
+ me.chop!
end
+
end
-def fromout(date, from, subj)
- return 0 if !date
- y, m, d = Time.parse(date).to_a.reverse[4, 3] if date
- y ||= 0; m ||= 0; d ||= 0
- from ||= "sombody@somewhere"
- from.delete!("\r\n")
- from = from.kconv(Encoding.default_external).kjust(28)
- subj ||= "(nil)"
- subj.delete!("\r\n")
- subj = subj.kconv(Encoding.default_external).kjust(40)
- printf "%02d/%02d/%02d [%s] %s\n", y%100, m, d, from, subj
- return 1
+if ARGV[0] == '-w'
+ wait = true
+ ARGV.shift
end
-def get_mailfile(user)
- file = user
- unless user
- file = ENV['MAIL']
- user = ENV['USER'] || ENV['USERNAME'] || ENV['LOGNAME']
- end
+if ARGV.length == 0
+ file = ENV['MAIL']
+ user = ENV['USER'] || ENV['USERNAME'] || ENV['LOGNAME']
+else
+ file = user = ARGV[0]
+ ARGV.clear
+end
- if file == nil or !File.exist?(file)
- [ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m|
- path = "#{m}/mail/#{user}"
- if File.exist?(path)
- file = path
- break
- end
+if file == nil or !File.exist? file
+ [ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m|
+ if File.exist? f = "#{m}/mail/#{user}"
+ file = f
+ break
end
end
- file
end
-def from_main
- if ARGV[0] == '-w'
- wait = true
- ARGV.shift
+$outcount = 0;
+def fromout(date, from, subj)
+ return if !date
+ y, m, d = parsedate(date) if date
+ y ||= 0; m ||= 0; d ||= 0
+ if from
+ from.gsub! /\n/, ""
+ else
+ from = "sombody@somewhere"
end
- file = get_mailfile(ARGV[0])
-
- outcount = 0
- if File.exist?(file)
- atime = File.atime(file)
- mtime = File.mtime(file)
- open(file, "r") do |f|
- until f.eof?
- header = {}
- f.each_line do |line|
- next if /^From / =~ line # skip From-line
- break if /^$/ =~ line # end of header
-
- if /^(?<attr>\S+?):\s*(?<value>.*)/ =~ line
- attr.capitalize!
- header[attr] = value
- elsif attr
- header[attr] += "\n" + line.lstrip
- end
- end
+ if subj
+ subj.gsub! /\n/, ""
+ else
+ subj = "(nil)"
+ end
+ if ENV['LANG'] =~ /sjis/i
+ lang = Kconv::SJIS
+ else
+ lang = Kconv::EUC
+ end
+ from = from.kconv(lang).kjust(28)
+ subj = subj.kconv(lang).kjust(40)
+ printf "%02d/%02d/%02d [%s] %s\n",y%100,m,d,from,subj
+ $outcount += 1
+end
- f.each_line do |line|
- break if /^From / =~ line
- end
- outcount += fromout(header['Date'], header['From'], header['Subject'])
- end
+if File.exist?(file)
+ atime = File.atime(file)
+ mtime = File.mtime(file)
+ f = open(file, "r")
+ begin
+ until f.eof?
+ mail = Mail.new(f)
+ fromout mail.header['Date'],mail.header['From'],mail.header['Subject']
end
+ ensure
+ f.close
File.utime(atime, mtime, file)
end
-
- if outcount == 0
- print "You have no mail.\n"
- sleep 2 if wait
- elsif wait
- system "stty cbreak -echo"
- $stdin.getc
- system "stty cooked echo"
- end
end
-if __FILE__ == $0
- from_main
+if $outcount == 0
+ print "You have no mail.\n"
+ sleep 2 if wait
+elsif wait
+ system "stty cbreak -echo"
+ getc()
+ system "stty cooked echo"
end
-
-__END__
-
-=begin
-
-= from.rb
-
-== USAGE
-
-ruby from.rb [-w] [username_or_filename]
-
-=end
diff --git a/sample/getopts.test b/sample/getopts.test
new file mode 100644
index 0000000000..2866bccea8
--- /dev/null
+++ b/sample/getopts.test
@@ -0,0 +1,36 @@
+#! /usr/local/bin/ruby
+
+load("parsearg.rb")
+
+def usage()
+ printf "Usage:\n"
+ printf "%s -d [-x x] [-y y] [--geometry geom] [--version] [string ...]\n", $0
+end
+
+$USAGE = 'usage'
+parseArgs(0, "d&(x|y)", "dfg", "x:", "y:", "geometry:800x600", "version")
+if ($OPT_d)
+ if $OPT_version
+ printf "version 1.0\n"
+ end
+ if ($OPT_x)
+ printf("x = %d\n", $OPT_x.to_i)
+ end
+ if ($OPT_y)
+ printf("y = %d\n", $OPT_y.to_i)
+ end
+ if ($OPT_geometry)
+ printf("geometry = %s\n", $OPT_geometry)
+ end
+ if $OPT_f
+ printf "f = TRUE\n"
+ end
+ if $OPT_g
+ printf "g = TRUE\n"
+ end
+end
+
+while (ARGV.length != 0)
+ print "other = ", ARGV[0], "\n"
+ ARGV.shift
+end
diff --git a/sample/goodfriday.rb b/sample/goodfriday.rb
deleted file mode 100644
index a95cfe819f..0000000000
--- a/sample/goodfriday.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-#! /usr/bin/env ruby
-
-# goodfriday.rb: Written by Tadayoshi Funaba 1998, 2000, 2002
-# $Id: goodfriday.rb,v 1.1 1998-03-08 18:44:44+09 tadf Exp $
-
-require 'date'
-
-def easter(y)
- g = (y % 19) + 1
- c = (y / 100) + 1
- x = (3 * c / 4) - 12
- z = ((8 * c + 5) / 25) - 5
- d = (5 * y / 4) - x - 10
- e = (11 * g + 20 + z - x) % 30
- e += 1 if e == 25 and g > 11 or e == 24
- n = 44 - e
- n += 30 if n < 21
- n = n + 7 - ((d + n) % 7)
- if n <= 31 then [y, 3, n] else [y, 4, n - 31] end
-end
-
-es = Date.new(*easter(Time.now.year))
-[[-9*7, 'Septuagesima Sunday'],
- [-8*7, 'Sexagesima Sunday'],
- [-7*7, 'Quinquagesima Sunday (Shrove Sunday)'],
- [-48, 'Shrove Monday'],
- [-47, 'Shrove Tuesday'],
- [-46, 'Ash Wednesday'],
- [-6*7, 'Quadragesima Sunday'],
- [-3*7, 'Mothering Sunday'],
- [-2*7, 'Passion Sunday'],
- [-7, 'Palm Sunday'],
- [-3, 'Maunday Thursday'],
- [-2, 'Good Friday'],
- [-1, 'Easter Eve'],
- [0, 'Easter Day'],
- [1, 'Easter Monday'],
- [7, 'Low Sunday'],
- [5*7, 'Rogation Sunday'],
- [39, 'Ascension Day (Holy Thursday)'],
- [42, 'Sunday after Ascension Day'],
- [7*7, 'Pentecost (Whitsunday)'],
- [50, 'Whitmonday'],
- [8*7, 'Trinity Sunday'],
- [60, 'Corpus Christi (Thursday after Trinity)']].
-each do |xs|
- puts((es + xs.shift).to_s + ' ' + xs.shift)
-end
diff --git a/sample/mrshtest.rb b/sample/mrshtest.rb
new file mode 100644
index 0000000000..8d2dc9936b
--- /dev/null
+++ b/sample/mrshtest.rb
@@ -0,0 +1,13 @@
+include Marshal
+a = 25.6;
+pt = Struct.new('Point', :x,:y);
+x = pt.new(10, 10)
+y = pt.new(20, 20)
+rt = Struct.new('Rectangle', :origin,:corner);
+z = rt.new(x, y)
+c = Object.new
+s = [a, x, z, c, c, "fff"];
+p s
+d = dump(s);
+p d
+p load(d)
diff --git a/sample/occur.rb b/sample/occur.rb
index 4ec6ae479b..8bb09e15ad 100644
--- a/sample/occur.rb
+++ b/sample/occur.rb
@@ -1,8 +1,8 @@
# word occurrence listing
# usege: ruby occur.rb file..
freq = Hash.new(0)
-while line = gets()
- for word in line.split(/\W+/)
+while gets()
+ for word in split(/\W+/)
freq[word] += 1
end
end
diff --git a/sample/openssl/cert_store_view.rb b/sample/openssl/cert_store_view.rb
new file mode 100644
index 0000000000..26c4d527f7
--- /dev/null
+++ b/sample/openssl/cert_store_view.rb
@@ -0,0 +1,911 @@
+#!/usr/bin/env ruby
+
+require 'fox'
+require 'openssl'
+require 'time'
+require 'certstore'
+require 'getopts'
+
+include Fox
+
+module CertDumpSupport
+ def cert_label(cert)
+ subject_alt_name =
+ cert.extensions.find { |ext| ext.oid == 'subjectAltName' }
+ if subject_alt_name
+ subject_alt_name.value.split(/\s*,\s/).each do |alt_name_pair|
+ alt_tag, alt_name = alt_name_pair.split(/:/)
+ return alt_name
+ end
+ end
+ name_label(cert.subject)
+ end
+
+ def name_label(name)
+ ary = name.to_a
+ if (cn = ary.find { |rdn| rdn[0] == 'CN' })
+ return cn[1]
+ end
+ if ary.last[0] == 'OU'
+ return ary.last[1]
+ end
+ name.to_s
+ end
+
+ def name_text(name)
+ name.to_a.collect { |tag, value|
+ "#{tag} = #{value}"
+ }.reverse.join("\n")
+ end
+
+ def bn_label(bn)
+ ("0" << sprintf("%X", bn)).scan(/../).join(" ")
+ end
+end
+
+class CertDump
+ include CertDumpSupport
+
+ def initialize(cert)
+ @cert = cert
+ end
+
+ def get_dump(tag)
+ case tag
+ when 'Version'
+ version
+ when 'Serial'
+ serial
+ when 'Signature Algorithm'
+ signature_algorithm
+ when 'Issuer'
+ issuer
+ when 'Validity'
+ validity
+ when 'Not before'
+ not_before
+ when 'Not after'
+ not_after
+ when 'Subject'
+ subject
+ when 'Public key'
+ public_key
+ else
+ ext(tag)
+ end
+ end
+
+ def get_dump_line(tag)
+ case tag
+ when 'Version'
+ version_line
+ when 'Serial'
+ serial_line
+ when 'Signature Algorithm'
+ signature_algorithm_line
+ when 'Subject'
+ subject_line
+ when 'Issuer'
+ issuer_line
+ when 'Validity'
+ validity_line
+ when 'Not before'
+ not_before_line
+ when 'Not after'
+ not_after_line
+ when 'Public key'
+ public_key_line
+ else
+ ext_line(tag)
+ end
+ end
+
+private
+
+ def version
+ "Version: #{@cert.version + 1}"
+ end
+
+ def version_line
+ version
+ end
+
+ def serial
+ bn_label(@cert.serial)
+ end
+
+ def serial_line
+ serial
+ end
+
+ def signature_algorithm
+ @cert.signature_algorithm
+ end
+
+ def signature_algorithm_line
+ signature_algorithm
+ end
+
+ def subject
+ name_text(@cert.subject)
+ end
+
+ def subject_line
+ @cert.subject.to_s
+ end
+
+ def issuer
+ name_text(@cert.issuer)
+ end
+
+ def issuer_line
+ @cert.issuer.to_s
+ end
+
+ def validity
+ <<EOS
+Not before: #{not_before}
+Not after: #{not_after}
+EOS
+ end
+
+ def validity_line
+ "from #{@cert.not_before.iso8601} to #{@cert.not_after.iso8601}"
+ end
+
+ def not_before
+ @cert.not_before.to_s
+ end
+
+ def not_before_line
+ not_before
+ end
+
+ def not_after
+ @cert.not_after.to_s
+ end
+
+ def not_after_line
+ not_after
+ end
+
+ def public_key
+ @cert.public_key.to_text
+ end
+
+ def public_key_line
+ "#{@cert.public_key.class} -- " << public_key.scan(/\A[^\n]*/)[0] << '...'
+ end
+
+ def ext(tag)
+ @cert.extensions.each do |ext|
+ if ext.oid == tag
+ return ext_detail(tag, ext.value)
+ end
+ end
+ "(unknown)"
+ end
+
+ def ext_line(tag)
+ ext(tag).tr("\r\n", '')
+ end
+
+ def ext_detail(tag, value)
+ value
+ end
+end
+
+class CrlDump
+ include CertDumpSupport
+
+ def initialize(crl)
+ @crl = crl
+ end
+
+ def get_dump(tag)
+ case tag
+ when 'Version'
+ version
+ when 'Signature Algorithm'
+ signature_algorithm
+ when 'Issuer'
+ issuer
+ when 'Last update'
+ last_update
+ when 'Next update'
+ next_update
+ else
+ ext(tag)
+ end
+ end
+
+ def get_dump_line(tag)
+ case tag
+ when 'Version'
+ version_line
+ when 'Signature Algorithm'
+ signature_algorithm_line
+ when 'Issuer'
+ issuer_line
+ when 'Last update'
+ last_update_line
+ when 'Next update'
+ next_update_line
+ else
+ ext_line(tag)
+ end
+ end
+
+private
+
+ def version
+ "Version: #{@crl.version + 1}"
+ end
+
+ def version_line
+ version
+ end
+
+ def signature_algorithm
+ @crl.signature_algorithm
+ end
+
+ def signature_algorithm_line
+ signature_algorithm
+ end
+
+ def issuer
+ name_text(@crl.issuer)
+ end
+
+ def issuer_line
+ @crl.issuer.to_s
+ end
+
+ def last_update
+ @crl.last_update.to_s
+ end
+
+ def last_update_line
+ last_update
+ end
+
+ def next_update
+ @crl.next_update.to_s
+ end
+
+ def next_update_line
+ next_update
+ end
+
+ def ext(tag)
+ @crl.extensions.each do |ext|
+ if ext.oid == tag
+ return ext_detail(tag, ext.value)
+ end
+ end
+ "(unknown)"
+ end
+
+ def ext_line(tag)
+ ext(tag).tr("\r\n", '')
+ end
+
+ def ext_detail(tag, value)
+ value
+ end
+end
+
+class RevokedDump
+ include CertDumpSupport
+
+ def initialize(revoked)
+ @revoked = revoked
+ end
+
+ def get_dump(tag)
+ case tag
+ when 'Serial'
+ serial
+ when 'Time'
+ time
+ else
+ ext(tag)
+ end
+ end
+
+ def get_dump_line(tag)
+ case tag
+ when 'Serial'
+ serial_line
+ when 'Time'
+ time_line
+ else
+ ext_line(tag)
+ end
+ end
+
+private
+
+ def serial
+ bn_label(@revoked.serial)
+ end
+
+ def serial_line
+ serial
+ end
+
+ def time
+ @revoked.time.to_s
+ end
+
+ def time_line
+ time
+ end
+
+ def ext(tag)
+ @revoked.extensions.each do |ext|
+ if ext.oid == tag
+ return ext_detail(tag, ext.value)
+ end
+ end
+ "(unknown)"
+ end
+
+ def ext_line(tag)
+ ext(tag).tr("\r\n", '')
+ end
+
+ def ext_detail(tag, value)
+ value
+ end
+end
+
+class RequestDump
+ include CertDumpSupport
+
+ def initialize(req)
+ @req = req
+ end
+
+ def get_dump(tag)
+ case tag
+ when 'Version'
+ version
+ when 'Signature Algorithm'
+ signature_algorithm
+ when 'Subject'
+ subject
+ when 'Public key'
+ public_key
+ else
+ attributes(tag)
+ end
+ end
+
+ def get_dump_line(tag)
+ case tag
+ when 'Version'
+ version_line
+ when 'Signature Algorithm'
+ signature_algorithm_line
+ when 'Subject'
+ subject_line
+ when 'Public key'
+ public_key_line
+ else
+ attributes_line(tag)
+ end
+ end
+
+private
+
+ def version
+ "Version: #{@req.version + 1}"
+ end
+
+ def version_line
+ version
+ end
+
+ def signature_algorithm
+ @req.signature_algorithm
+ end
+
+ def signature_algorithm_line
+ signature_algorithm
+ end
+
+ def subject
+ name_text(@req.subject)
+ end
+
+ def subject_line
+ @req.subject.to_s
+ end
+
+ def public_key
+ @req.public_key.to_text
+ end
+
+ def public_key_line
+ "#{@req.public_key.class} -- " << public_key.scan(/\A[^\n]*/)[0] << '...'
+ end
+
+ def attributes(tag)
+ "(unknown)"
+ end
+
+ def attributes_line(tag)
+ attributes(tag).tr("\r\n", '')
+ end
+end
+
+class CertStoreView < FXMainWindow
+ class CertTree
+ include CertDumpSupport
+
+ def initialize(observer, tree)
+ @observer = observer
+ @tree = tree
+ @tree.connect(SEL_COMMAND) do |sender, sel, item|
+ if item.data
+ @observer.getApp().beginWaitCursor do
+ @observer.show_item(item.data)
+ end
+ else
+ @observer.show_item(nil)
+ end
+ end
+ end
+
+ def show(cert_store)
+ @tree.clearItems
+ @self_signed_ca_node = add_item_last(nil, "Trusted root CA")
+ @other_ca_node = add_item_last(nil, "Intermediate CA")
+ @ee_node = add_item_last(nil, "Personal")
+ @crl_node = add_item_last(nil, "CRL")
+ @request_node = add_item_last(nil, "Request")
+ @verify_path_node = add_item_last(nil, "Certification path")
+ show_certs(cert_store)
+ end
+
+ def show_certs(cert_store)
+ remove_items(@self_signed_ca_node)
+ remove_items(@other_ca_node)
+ remove_items(@ee_node)
+ remove_items(@crl_node)
+ remove_items(@request_node)
+ import_certs(cert_store)
+ end
+
+ def show_request(req)
+ node = add_item_last(@request_node, name_label(req.subject), req)
+ @tree.selectItem(node)
+ @observer.show_item(req)
+ end
+
+ def show_verify_path(verify_path)
+ add_verify_path(verify_path)
+ end
+
+ private
+
+ def open_node(node)
+ node.expanded = node.opened = true
+ end
+
+ def close_node(node)
+ node.expanded = node.opened = false
+ end
+
+ def import_certs(cert_store)
+ cert_store.self_signed_ca.each do |cert|
+ add_item_last(@self_signed_ca_node, cert_label(cert), cert)
+ end
+ cert_store.other_ca.each do |cert|
+ add_item_last(@other_ca_node, cert_label(cert), cert)
+ end
+ cert_store.ee.each do |cert|
+ add_item_last(@ee_node, cert_label(cert), cert)
+ end
+ cert_store.crl.each do |crl|
+ node = add_item_last(@crl_node, name_label(crl.issuer), crl)
+ close_node(node)
+ crl.revoked.each do |revoked|
+ add_item_last(node, bn_label(revoked.serial), revoked)
+ end
+ end
+ cert_store.request.each do |req|
+ add_item_last(@requestnode, name_label(req.subject), req)
+ end
+ end
+
+ def add_verify_path(verify_path)
+ node = @verify_path_node
+ last_cert = nil
+ verify_path.reverse_each do |ok, cert, crl_check, error_string|
+ warn = []
+ if @observer.cert_store.is_ca?(cert)
+ warn << 'NO ARL' unless crl_check
+ else
+ warn << 'NO CRL' unless crl_check
+ end
+ warn_str = '(' << warn.join(", ") << ')'
+ warn_mark = warn.empty? ? '' : '!'
+ label = if ok
+ "OK#{warn_mark}..." + cert_label(cert)
+ else
+ "NG(#{error_string})..." + cert_label(cert)
+ end
+ label << warn_str unless warn.empty?
+ node = add_item_last(node, label, cert)
+ node.expanded = true
+ last_cert = cert
+ end
+ if last_cert
+ @tree.selectItem(node)
+ @observer.show_item(last_cert)
+ end
+ end
+
+ def add_item_last(parent, label, obj = nil)
+ node = @tree.addItemLast(parent, FXTreeItem.new(label))
+ node.data = obj if obj
+ open_node(node)
+ node
+ end
+
+ def remove_items(node)
+ while node.getNumChildren > 0
+ @tree.removeItem(node.getFirst)
+ end
+ end
+ end
+
+ class CertInfo
+ def initialize(observer, table)
+ @observer = observer
+ @table = table
+ @table.leadingRows = 0
+ @table.leadingCols = 0
+ @table.trailingRows = 0
+ @table.trailingCols = 0
+ @table.showVertGrid(false)
+ @table.showHorzGrid(false)
+ @table.setTableSize(1, 2)
+ @table.setColumnWidth(0, 125)
+ @table.setColumnWidth(1, 350)
+ end
+
+ def show(item)
+ @observer.show_detail(nil, nil)
+ if item.nil?
+ set_column_size(1)
+ return
+ end
+ case item
+ when OpenSSL::X509::Certificate
+ show_cert(item)
+ when OpenSSL::X509::CRL
+ show_crl(item)
+ when OpenSSL::X509::Revoked
+ show_revoked(item)
+ when OpenSSL::X509::Request
+ show_request(item)
+ else
+ raise NotImplementedError.new("Unknown item type #{item.class}.")
+ end
+ end
+
+ private
+
+ def show_cert(cert)
+ wrap = CertDump.new(cert)
+ items = []
+ items << ['Version', wrap.get_dump_line('Version')]
+ items << ['Signature Algorithm', wrap.get_dump_line('Signature Algorithm')]
+ items << ['Issuer', wrap.get_dump_line('Issuer')]
+ items << ['Serial', wrap.get_dump_line('Serial')]
+ #items << ['Not before', wrap.get_dump_line('Not before')]
+ #items << ['Not after', wrap.get_dump_line('Not after')]
+ items << ['Subject', wrap.get_dump_line('Subject')]
+ items << ['Public key', wrap.get_dump_line('Public key')]
+ items << ['Validity', wrap.get_dump_line('Validity')]
+ (cert.extensions.sort { |a, b| a.oid <=> b.oid }).each do |ext|
+ items << [ext.oid, wrap.get_dump_line(ext.oid)]
+ end
+ show_items(cert, items)
+ end
+
+ def show_crl(crl)
+ wrap = CrlDump.new(crl)
+ items = []
+ items << ['Version', wrap.get_dump_line('Version')]
+ items << ['Signature Algorithm', wrap.get_dump_line('Signature Algorithm')]
+ items << ['Issuer', wrap.get_dump_line('Issuer')]
+ items << ['Last update', wrap.get_dump_line('Last update')]
+ items << ['Next update', wrap.get_dump_line('Next update')]
+ crl.extensions.each do |ext|
+ items << [ext.oid, wrap.get_dump_line(ext.oid)]
+ end
+ show_items(crl, items)
+ end
+
+ def show_revoked(revoked)
+ wrap = RevokedDump.new(revoked)
+ items = []
+ items << ['Serial', wrap.get_dump_line('Serial')]
+ items << ['Time', wrap.get_dump_line('Time')]
+ revoked.extensions.each do |ext|
+ items << [ext.oid, wrap.get_dump_line(ext.oid)]
+ end
+ show_items(revoked, items)
+ end
+
+ def show_request(req)
+ wrap = RequestDump.new(req)
+ items = []
+ items << ['Version', wrap.get_dump_line('Version')]
+ items << ['Signature Algorithm', wrap.get_dump_line('Signature Algorithm')]
+ items << ['Subject', wrap.get_dump_line('Subject')]
+ items << ['Public key', wrap.get_dump_line('Public key')]
+ req.attributes.each do |attr|
+ items << [attr.attr, wrap.get_dump_line(attr.oid)]
+ end
+ show_items(req, items)
+ end
+
+ def show_items(obj, items)
+ set_column_size(items.size)
+ items.each_with_index do |ele, idx|
+ tag, value = ele
+ @table.setItemText(idx, 0, tag)
+ @table.getItem(idx, 0).data = tag
+ @table.setItemText(idx, 1, value.to_s)
+ @table.getItem(idx, 1).data = tag
+ end
+ @table.connect(SEL_COMMAND) do |sender, sel, loc|
+ item = @table.getItem(loc.row, loc.col)
+ @observer.show_detail(obj, item.data)
+ end
+ justify_table
+ end
+
+ def set_column_size(size)
+ col0_width = @table.getColumnWidth(0)
+ col1_width = @table.getColumnWidth(1)
+ @table.setTableSize(size, 2)
+ @table.setColumnWidth(0, col0_width)
+ @table.setColumnWidth(1, col1_width)
+ end
+
+ def justify_table
+ for col in 0..@table.numCols-1
+ for row in 0..@table.numRows-1
+ @table.getItem(row, col).justify = FXTableItem::LEFT
+ end
+ end
+ end
+ end
+
+ class CertDetail
+ def initialize(observer, detail)
+ @observer = observer
+ @detail = detail
+ end
+
+ def show(item, tag)
+ if item.nil?
+ @detail.text = ''
+ return
+ end
+ case item
+ when OpenSSL::X509::Certificate
+ show_cert(item, tag)
+ when OpenSSL::X509::CRL
+ show_crl(item, tag)
+ when OpenSSL::X509::Revoked
+ show_revoked(item, tag)
+ when OpenSSL::X509::Request
+ show_request(item, tag)
+ else
+ raise NotImplementedError.new("Unknown item type #{item.class}.")
+ end
+ end
+
+ private
+
+ def show_cert(cert, tag)
+ wrap = CertDump.new(cert)
+ @detail.text = wrap.get_dump(tag)
+ end
+
+ def show_crl(crl, tag)
+ wrap = CrlDump.new(crl)
+ @detail.text = wrap.get_dump(tag)
+ end
+
+ def show_revoked(revoked, tag)
+ wrap = RevokedDump.new(revoked)
+ @detail.text = wrap.get_dump(tag)
+ end
+
+ def show_request(request, tag)
+ wrap = RequestDump.new(request)
+ @detail.text = wrap.get_dump(tag)
+ end
+ end
+
+ attr_reader :cert_store
+
+ def initialize(app, cert_store)
+ @cert_store = cert_store
+ @verify_filter = 0
+ @verify_filename = nil
+ full_width = 800
+ full_height = 500
+ horz_pos = 300
+
+ super(app, "Certificate store", nil, nil, DECOR_ALL, 0, 0, full_width,
+ full_height)
+
+ FXTooltip.new(self.getApp())
+
+ menubar = FXMenubar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
+ file_menu = FXMenuPane.new(self)
+ FXMenuTitle.new(menubar, "&File", nil, file_menu)
+ file_open_menu = FXMenuPane.new(self)
+ FXMenuCommand.new(file_open_menu, "&Directory\tCtl-O").connect(SEL_COMMAND,
+ method(:on_cmd_file_open_dir))
+ FXMenuCascade.new(file_menu, "&Open\tCtl-O", nil, file_open_menu)
+ FXMenuCommand.new(file_menu, "&Quit\tCtl-Q", nil, getApp(), FXApp::ID_QUIT)
+
+ tool_menu = FXMenuPane.new(self)
+ FXMenuTitle.new(menubar, "&Tool", nil, tool_menu)
+ FXMenuCommand.new(tool_menu, "&Verify\tCtl-N").connect(SEL_COMMAND,
+ method(:on_cmd_tool_verify))
+ FXMenuCommand.new(tool_menu, "&Show Request\tCtl-R").connect(SEL_COMMAND,
+ method(:on_cmd_tool_request))
+
+ base_frame = FXHorizontalFrame.new(self, LAYOUT_FILL_X | LAYOUT_FILL_Y)
+ splitter_horz = FXSplitter.new(base_frame, LAYOUT_SIDE_TOP | LAYOUT_FILL_X |
+ LAYOUT_FILL_Y | SPLITTER_TRACKING | SPLITTER_HORIZONTAL)
+
+ # Cert tree
+ cert_tree_frame = FXHorizontalFrame.new(splitter_horz, LAYOUT_FILL_X |
+ LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK)
+ cert_tree_frame.setWidth(horz_pos)
+ cert_tree = FXTreeList.new(cert_tree_frame, 0, nil, 0,
+ TREELIST_BROWSESELECT | TREELIST_SHOWS_LINES | TREELIST_SHOWS_BOXES |
+ TREELIST_ROOT_BOXES | LAYOUT_FILL_X | LAYOUT_FILL_Y)
+ @cert_tree = CertTree.new(self, cert_tree)
+
+ # Cert info
+ splitter_vert = FXSplitter.new(splitter_horz, LAYOUT_SIDE_TOP |
+ LAYOUT_FILL_X | LAYOUT_FILL_Y | SPLITTER_TRACKING | SPLITTER_VERTICAL |
+ SPLITTER_REVERSED)
+ cert_list_base = FXVerticalFrame.new(splitter_vert, LAYOUT_FILL_X |
+ LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0)
+ cert_list_frame = FXHorizontalFrame.new(cert_list_base, FRAME_SUNKEN |
+ FRAME_THICK | LAYOUT_FILL_X | LAYOUT_FILL_Y)
+ cert_info = FXTable.new(cert_list_frame, 2, 10, nil, 0, FRAME_SUNKEN |
+ TABLE_COL_SIZABLE | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 2, 2, 2, 2)
+ @cert_info = CertInfo.new(self, cert_info)
+
+ cert_detail_base = FXVerticalFrame.new(splitter_vert, LAYOUT_FILL_X |
+ LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0)
+ cert_detail_frame = FXHorizontalFrame.new(cert_detail_base, FRAME_SUNKEN |
+ FRAME_THICK | LAYOUT_FILL_X | LAYOUT_FILL_Y)
+ cert_detail = FXText.new(cert_detail_frame, nil, 0, TEXT_READONLY |
+ LAYOUT_FILL_X | LAYOUT_FILL_Y)
+ @cert_detail = CertDetail.new(self, cert_detail)
+
+ show_init
+ end
+
+ def create
+ super
+ show(PLACEMENT_SCREEN)
+ end
+
+ def show_init
+ @cert_tree.show(@cert_store)
+ show_item(nil)
+ end
+
+ def show_certs
+ @cert_tree.show_certs(@cert_store)
+ end
+
+ def show_request(req)
+ @cert_tree.show_request(req)
+ end
+
+ def show_verify_path(verify_path)
+ @cert_tree.show_verify_path(verify_path)
+ end
+
+ def show_item(item)
+ @cert_info.show(item) if @cert_info
+ end
+
+ def show_detail(item, tag)
+ @cert_detail.show(item, tag) if @cert_detail
+ end
+
+ def verify(certfile)
+ path = verify_certfile(certfile)
+ show_certs # CRL could be change.
+ show_verify_path(path)
+ end
+
+private
+
+ def on_cmd_file_open_dir(sender, sel, ptr)
+ dir = FXFileDialog.getOpenDirectory(self, "Open certificate directory", ".")
+ unless dir.empty?
+ begin
+ @cert_store = CertStore.new(dir)
+ rescue
+ show_error($!)
+ end
+ show_init
+ end
+ 1
+ end
+
+ def on_cmd_tool_verify(sender, sel, ptr)
+ dialog = FXFileDialog.new(self, "Verify certificate")
+ dialog.filename = ''
+ dialog.patternList = ["All Files (*)", "PEM formatted certificate (*.pem)"]
+ dialog.currentPattern = @verify_filter
+ if dialog.execute != 0
+ @verify_filename = dialog.filename
+ verify(@verify_filename)
+ end
+ @verify_filter = dialog.currentPattern
+ 1
+ end
+
+ def on_cmd_tool_request(sender, sel, ptr)
+ dialog = FXFileDialog.new(self, "Show request")
+ dialog.filename = ''
+ dialog.patternList = ["All Files (*)", "PEM formatted certificate (*.pem)"]
+ if dialog.execute != 0
+ req = @cert_store.generate_cert(dialog.filename)
+ show_request(req)
+ end
+ 1
+ end
+
+ def verify_certfile(filename)
+ begin
+ cert = @cert_store.generate_cert(filename)
+ result = @cert_store.verify(cert)
+ @cert_store.scan_certs
+ result
+ rescue
+ show_error($!)
+ []
+ end
+ end
+
+ def show_error(e)
+ msg = e.inspect + "\n" + e.backtrace.join("\n")
+ FXMessageBox.error(self, MBOX_OK, "Error", msg)
+ end
+end
+
+getopts nil, "cert:"
+
+certs_dir = ARGV.shift or raise "#{$0} cert_dir"
+certfile = $OPT_cert
+app = FXApp.new("CertStore", "FoxTest")
+cert_store = CertStore.new(certs_dir)
+w = CertStoreView.new(app, cert_store)
+app.create
+if certfile
+ w.verify(certfile)
+end
+app.run
diff --git a/sample/openssl/cipher.rb b/sample/openssl/cipher.rb
index 58b10d6046..6e8cdb9427 100644
--- a/sample/openssl/cipher.rb
+++ b/sample/openssl/cipher.rb
@@ -1,54 +1,33 @@
#!/usr/bin/env ruby
require 'openssl'
-def crypt_by_password(alg, pass, salt, text)
- puts "--Setup--"
- puts %(cipher alg: "#{alg}")
- puts %(plain text: "#{text}")
- puts %(password: "#{pass}")
- puts %(salt: "#{salt}")
- puts
-
- puts "--Encrypting--"
- enc = OpenSSL::Cipher::Cipher.new(alg)
- enc.encrypt
- enc.pkcs5_keyivgen(pass, salt)
- cipher = enc.update(text)
- cipher << enc.final
- puts %(encrypted text: #{cipher.inspect})
- puts
-
- puts "--Decrypting--"
- dec = OpenSSL::Cipher::Cipher.new(alg)
- dec.decrypt
- dec.pkcs5_keyivgen(pass, salt)
- plain = dec.update(cipher)
- plain << dec.final
- puts %(decrypted text: "#{plain}")
- puts
-end
-
-def ciphers
- ciphers = OpenSSL::Cipher.ciphers.sort
- ciphers.each{|i|
- if i.upcase != i && ciphers.include?(i.upcase)
- ciphers.delete(i)
- end
- }
- return ciphers
-end
+text = "abcdefghijklmnopqrstuvwxyz"
+pass = "secret password"
+salt = "8 octets" # or nil
+alg = "DES-EDE3-CBC"
+#alg = "AES-128-CBC"
-puts "Supported ciphers in #{OpenSSL::OPENSSL_VERSION}:"
-ciphers.each_with_index{|name, i|
- printf("%-15s", name)
- puts if (i + 1) % 5 == 0
-}
-puts
+puts "--Setup--"
+puts %(clear text: "#{text}")
+puts %(password: "#{pass}")
+puts %(salt: "#{salt}")
+puts %(cipher alg: "#{alg}")
puts
-alg = ARGV.shift || ciphers.first
-pass = "secret password"
-salt = "8 octets" # or nil
-text = "abcdefghijklmnopqrstuvwxyz"
+puts "--Encrypting--"
+des = OpenSSL::Cipher::Cipher.new(alg)
+des.pkcs5_keyivgen(pass, salt)
+des.encrypt
+cipher = des.update(text)
+cipher << des.final
+puts %(encrypted text: #{cipher.inspect})
+puts
-crypt_by_password(alg, pass, salt, text)
+puts "--Decrypting--"
+des = OpenSSL::Cipher::Cipher.new(alg)
+des.pkcs5_keyivgen(pass, salt)
+des.decrypt
+out = des.update(cipher)
+out << des.final
+puts %(decrypted text: "#{out}")
+puts
diff --git a/sample/openssl/echo_cli.rb b/sample/openssl/echo_cli.rb
index 069a21ec94..29b356a7ad 100644
--- a/sample/openssl/echo_cli.rb
+++ b/sample/openssl/echo_cli.rb
@@ -2,15 +2,15 @@
require 'socket'
require 'openssl'
-require 'optparse'
+require 'getopts'
-options = ARGV.getopts("p:c:k:C:")
+getopts nil, "p:2000", "c:", "k:", "C:"
host = ARGV[0] || "localhost"
-port = options["p"] || "2000"
-cert_file = options["c"]
-key_file = options["k"]
-ca_path = options["C"]
+port = $OPT_p
+cert_file = $OPT_c
+key_file = $OPT_k
+ca_path = $OPT_C
ctx = OpenSSL::SSL::SSLContext.new()
if cert_file && key_file
@@ -27,18 +27,11 @@ end
s = TCPSocket.new(host, port)
ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
ssl.connect # start SSL session
-p ssl.peer_cert
-errors = Hash.new
-OpenSSL::X509.constants.grep(/^V_(ERR_|OK)/).each do |name|
- errors[OpenSSL::X509.const_get(name)] = name
-end
-p errors[ssl.verify_result]
-
ssl.sync_close = true # if true the underlying socket will be
# closed in SSLSocket#close. (default: false)
while line = $stdin.gets
ssl.write line
- puts ssl.gets.inspect
+ print ssl.gets
end
ssl.close
diff --git a/sample/openssl/echo_svr.rb b/sample/openssl/echo_svr.rb
index 719de6be84..be8e10fa26 100644
--- a/sample/openssl/echo_svr.rb
+++ b/sample/openssl/echo_svr.rb
@@ -2,14 +2,14 @@
require 'socket'
require 'openssl'
-require 'optparse'
+require 'getopts'
-options = ARGV.getopts("p:c:k:C:")
+getopts nil, "p:2000", "c:", "k:", "C:"
-port = options["p"] || "2000"
-cert_file = options["c"]
-key_file = options["k"]
-ca_path = options["C"]
+port = $OPT_p
+cert_file = $OPT_c
+key_file = $OPT_k
+ca_path = $OPT_C
if cert_file && key_file
cert = OpenSSL::X509::Certificate.new(File::read(cert_file))
@@ -55,11 +55,8 @@ tcps = TCPServer.new(port)
ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
loop do
ns = ssls.accept
- puts "connected from #{ns.peeraddr}"
while line = ns.gets
- puts line.inspect
ns.write line
end
- puts "connection closed"
ns.close
end
diff --git a/sample/openssl/gen_csr.rb b/sample/openssl/gen_csr.rb
index 4228707fdb..5858acd9f2 100644
--- a/sample/openssl/gen_csr.rb
+++ b/sample/openssl/gen_csr.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require 'optparse'
+require 'getopts'
require 'openssl'
include OpenSSL
@@ -14,13 +14,14 @@ EOS
exit
end
-options = ARGV.getopts(nil, "key:", "csrout:", "keyout:")
-keypair_file = options["key"]
-csrout = options["csrout"] || "csr.pem"
-keyout = options["keyout"] || "keypair.pem"
+getopts nil, "key:", "csrout:", "keyout:"
+keypair_file = $OPT_key
+csrout = $OPT_csrout || "csr.pem"
+keyout = $OPT_keyout || "keypair.pem"
$stdout.sync = true
name_str = ARGV.shift or usage()
+p name_str
name = X509::Name.parse(name_str)
keypair = nil
@@ -47,5 +48,3 @@ puts "Writing #{csrout}..."
File.open(csrout, "w") do |f|
f << req.to_pem
end
-puts req.to_text
-puts req.to_pem
diff --git a/sample/openssl/smime_read.rb b/sample/openssl/smime_read.rb
index 17394f9b8d..0f08f54f7e 100644
--- a/sample/openssl/smime_read.rb
+++ b/sample/openssl/smime_read.rb
@@ -1,12 +1,12 @@
-require 'optparse'
+require 'getopts'
require 'openssl'
include OpenSSL
-options = ARGV.getopts("c:k:C:")
+getopts nil, "c:", "k:", "C:"
-cert_file = options["c"]
-key_file = options["k"]
-ca_path = options["C"]
+cert_file = $OPT_c
+key_file = $OPT_k
+ca_path = $OPT_C
data = $stdin.read
diff --git a/sample/openssl/smime_write.rb b/sample/openssl/smime_write.rb
index 535b3d6685..ce32cd8146 100644
--- a/sample/openssl/smime_write.rb
+++ b/sample/openssl/smime_write.rb
@@ -1,12 +1,12 @@
require 'openssl'
-require 'optparse'
+require 'getopts'
include OpenSSL
-options = ARGV.getopts("c:k:r:")
+getopts nil, "c:", "k:", "r:"
-cert_file = options["c"]
-key_file = options["k"]
-rcpt_file = options["r"]
+cert_file = $OPT_c
+key_file = $OPT_k
+rcpt_file = $OPT_r
cert = X509::Certificate.new(File::read(cert_file))
key = PKey::RSA.new(File::read(key_file))
diff --git a/sample/openssl/wget.rb b/sample/openssl/wget.rb
index ee637204db..0362ab980d 100644
--- a/sample/openssl/wget.rb
+++ b/sample/openssl/wget.rb
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
require 'net/https'
-require 'optparse'
+require 'getopts'
-options = ARGV.getopts('C:')
+getopts nil, 'C:'
-cert_store = options["C"]
+ca_path = $OPT_C
uri = URI.parse(ARGV[0])
if proxy = ENV['HTTP_PROXY']
@@ -18,12 +18,11 @@ h = Net::HTTP.new(uri.host, uri.port, prx_host, prx_port)
h.set_debug_output($stderr) if $DEBUG
if uri.scheme == "https"
h.use_ssl = true
- if cert_store
- if File.directory?(cert_store)
- h.ca_path = cert_store
- else
- h.ca_file = cert_store
- end
+ if ca_path
+ h.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ h.ca_path = ca_path
+ else
+ $stderr.puts "!!! WARNING: PEER CERTIFICATE WON'T BE VERIFIED !!!"
end
end
diff --git a/sample/optparse/opttest.rb b/sample/optparse/opttest.rb
index e2c6d1e048..61b157bce5 100644
--- a/sample/optparse/opttest.rb
+++ b/sample/optparse/opttest.rb
@@ -23,49 +23,49 @@ ARGV.options do
# mandatory argument
opts.on("-r", "--require=LIBRARY", String,
"require the LIBRARY, before",
- "executing your script") {|lib|@library=lib}
+ "executing your script") {|@library|}
# optional argument
opts.on("-i", "--inplace=[EXTENSION]",
"edit ARGV files in place", # multiline description
- "(make backup if EXTENSION supplied)") {|inplace| @inplace = inplace || ''}
+ "(make backup if EXTENSION supplied)") {|@inplace| @inplace ||= ''}
- opts.on("-N=[NUM]", Integer) {|num|@number=num}
+ opts.on("-N=[NUM]", Integer) {|@number|}
# additional class
- opts.on("-t", "--[no-]time[=TIME]", Time, "it's the time") {|time|@time=time}
+ opts.on("-t", "--[no-]time[=TIME]", Time, "it's the time") {|@time|}
# limit argument syntax
opts.on("-[0-7]", "-F", "--irs=[OCTAL]", OptionParser::OctalInteger,
- "specify record separator", "(\\0, if no argument)") {|irs|@irs=irs}
+ "specify record separator", "(\\0, if no argument)") {|@irs|}
# boolean switch(default true)
@exec = true
- opts.on("-n", "--no-exec[=FLAG]", TrueClass, "not really execute") {|exec|@exec=exec}
+ opts.on("-n", "--no-exec[=FLAG]", TrueClass, "not really execute") {|@exec|}
# array
- opts.on("-a", "--list[=LIST,LIST]", Array, "list") {|list|@list=list}
+ opts.on("-a", "--list[=LIST,LIST]", Array, "list") {|@list|}
# fixed size array
- opts.on("--pair[=car,cdr]", Array, "pair") {|x,y|@x=x; @y=y}
+ opts.on("--pair[=car,cdr]", Array, "pair") {|@x, @y|}
# keyword completion
opts.on("--code=CODE", CODES, CODE_ALIASES, "select coding system",
- "("+CODES.join(",")+",", " "+CODE_ALIASES.keys.join(",")+")") {|c|@code=c}
+ "("+CODES.join(",")+",", " "+CODE_ALIASES.keys.join(",")+")") {|@code|}
# optional argument with keyword completion
- opts.on("--type[=TYPE]", [:text, :binary], "select type(text, binary)") {|t|@type=t}
+ opts.on("--type[=TYPE]", [:text, :binary], "select type(text, binary)") {|@type|}
# boolean switch with optional argument(default false)
- opts.on("-v", "--[no-]verbose=[FLAG]", "run verbosely") {|v|@verbose=v}
+ opts.on("-v", "--[no-]verbose=[FLAG]", "run verbosely") {|@verbose|}
# easy way, set local variable
- opts.on("-q", "--quit", "quit when ARGV is empty") {|q|@quit=q}
+ opts.on("-q", "--quit", "quit when ARGV is empty") {|@quit|}
# adding on the fly
opts.on("--add=SWITCH=[ARG]", "add option on the fly", /\A(\w+)(?:=.+)?\Z/) do
|opt, var|
- opts.on("--#{opt}", "added in runtime", &eval("proc {|x|@#{var}=x}"))
+ opts.on("--#{opt}", "added in runtime", &eval("proc {|@#{var}|}"))
end
opts.on_head("specific options:")
@@ -79,7 +79,7 @@ ARGV.options do
end
pp self
-begin print ARGV.options; exit end if @quit
+(print ARGV.options; exit) if @quit
ARGV.options = nil # no more parse
puts "ARGV = #{ARGV.join(' ')}" if !ARGV.empty?
#opts.variable.each {|sym| puts "#{sym} = #{opts.send(sym).inspect}"}
diff --git a/sample/regx.rb b/sample/regx.rb
new file mode 100644
index 0000000000..6d90b7f293
--- /dev/null
+++ b/sample/regx.rb
@@ -0,0 +1,23 @@
+st = "\033[7m"
+en = "\033[m"
+#st = "<<"
+#en = ">>"
+
+while true
+ print "str> "
+ STDOUT.flush
+ input = gets
+ break if not input
+ if input != ""
+ str = input
+ str.chop!
+ end
+ print "pat> "
+ STDOUT.flush
+ re = gets
+ break if not re
+ re.chop!
+ str.gsub! re, "#{st}\\&#{en}"
+ print str, "\n"
+end
+print "\n"
diff --git a/sample/ripper/ruby2html.rb b/sample/ripper/ruby2html.rb
deleted file mode 100644
index 8f64f5a713..0000000000
--- a/sample/ripper/ruby2html.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env ruby
-# $originalId: ruby2html.rb,v 1.2 2005/09/23 22:53:47 aamine Exp $
-
-TEMPLATE_LINE = __LINE__ + 2
-TEMPLATE = <<-EndTemplate
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
-<% if css %>
- <link rel="stylesheet" type="text/css" href="<%= css %>">
-<% end %>
- <title><%= File.basename(f.path) %></title>
-</head>
-<body>
-<pre>
-<%
- if print_line_number
- Ruby2HTML.compile(f).each_with_index do |line, idx|
-%><%= sprintf('%4d %s', idx+1, line) %><%
- end
- else
-%><%= Ruby2HTML.compile(f) %><%
- end
-%>
-</pre>
-</body>
-</html>
-EndTemplate
-
-require 'ripper'
-require 'stringio'
-require 'cgi'
-require 'erb'
-require 'optparse'
-
-def main
- encoding = 'us-ascii'
- css = nil
- print_line_number = false
- parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [-l] [<file>...]"
- parser.on('--encoding=NAME', 'Character encoding [us-ascii].') {|name|
- encoding = name
- }
- parser.on('--css=URL', 'Set a link to CSS.') {|url|
- css = url
- }
- parser.on('-l', '--line-number', 'Show line number.') {
- print_line_number = true
- }
- parser.on('--help', 'Prints this message and quit.') {
- puts parser.help
- exit 0
- }
- begin
- parser.parse!
- rescue OptionParser::ParseError => err
- $stderr.puts err
- $stderr.puts parser.help
- exit 1
- end
- puts ruby2html(ARGF, encoding, css, print_line_number)
-end
-
-class ERB
- attr_accessor :lineno
-
- remove_method :result
- def result(b)
- eval(@src, b, (@filename || '(erb)'), (@lineno || 1))
- end
-end
-
-def ruby2html(f, encoding, css, print_line_number)
- erb = ERB.new(TEMPLATE, nil, '>')
- erb.filename = __FILE__
- erb.lineno = TEMPLATE_LINE
- erb.result(binding())
-end
-
-class Ruby2HTML < Ripper::Filter
- def Ruby2HTML.compile(f)
- buf = StringIO.new
- Ruby2HTML.new(f).parse(buf)
- buf.string
- end
-
- def on_default(event, tok, f)
- f << CGI.escapeHTML(tok)
- end
-
- def on_kw(tok, f)
- f << %Q[<span class="resword">#{CGI.escapeHTML(tok)}</span>]
- end
-
- def on_comment(tok, f)
- f << %Q[<span class="comment">#{CGI.escapeHTML(tok.rstrip)}</span>\n]
- end
-
- def on_tstring_beg(tok, f)
- f << %Q[<span class="string">#{CGI.escapeHTML(tok)}]
- end
-
- def on_tstring_end(tok, f)
- f << %Q[#{CGI.escapeHTML(tok)}</span>]
- end
-end
-
-if $0 == __FILE__
- main
-end
diff --git a/sample/ripper/strip-comment.rb b/sample/ripper/strip-comment.rb
deleted file mode 100644
index bd26b6a377..0000000000
--- a/sample/ripper/strip-comment.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# $Id$
-
-require 'ripper/filter'
-
-class CommentStripper < Ripper::Filter
- def CommentStripper.strip(src)
- new(src).parse(nil)
- end
-
- def on_default(event, token, data)
- print token
- end
-
- def on_comment(token, data)
- puts
- end
-end
-
-CommentStripper.strip(ARGF)
diff --git a/sample/test.rb b/sample/test.rb
index 52898d582c..eb0791b3de 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -1,11 +1,12 @@
#! /usr/bin/env ruby
+$KCODE = "none"
$testnum=0
$ntest=0
$failed = 0
def test_check(what)
- STDERR.print "\nsample/test.rb:#{what} "
+ printf "%s\n", what
$what = what
$testnum = 0
end
@@ -13,17 +14,13 @@ end
def test_ok(cond,n=1)
$testnum+=1
$ntest+=1
- where = (st = caller(n)) ? st[0] : "caller error! (n=#{n}, trace=#{caller(0).join(', ')}"
if cond
- STDERR.print "."
- printf "ok %d (%s)\n", $testnum, where
+ printf "ok %d\n", $testnum
else
- STDERR.print "F"
+ where = caller(n)[0]
printf "not ok %s %d -- %s\n", $what, $testnum, where
$failed+=1
end
- STDOUT.flush
- STDERR.flush
end
# make sure conditional operators work
@@ -57,13 +54,15 @@ a = [*[]]; test_ok(a == [])
a = [*[1]]; test_ok(a == [1])
a = [*[1,2]]; test_ok(a == [1,2])
-a = *[]; test_ok(a == [])
-a = *[1]; test_ok(a == [1])
-a = *[nil]; test_ok(a == [nil])
-a = *[[]]; test_ok(a == [[]])
+a = *nil; test_ok(a == nil)
+a = *1; test_ok(a == 1)
+a = *[]; test_ok(a == nil)
+a = *[1]; test_ok(a == 1)
+a = *[nil]; test_ok(a == nil)
+a = *[[]]; test_ok(a == [])
a = *[1,2]; test_ok(a == [1,2])
-a = *[*[]]; test_ok(a == [])
-a = *[*[1]]; test_ok(a == [1])
+a = *[*[]]; test_ok(a == nil)
+a = *[*[1]]; test_ok(a == 1)
a = *[*[1,2]]; test_ok(a == [1,2])
a, = nil; test_ok(a == nil)
@@ -79,6 +78,8 @@ a, = [*[1]]; test_ok(a == 1)
a, = *[1,2]; test_ok(a == 1)
a, = [*[1,2]]; test_ok(a == 1)
+a, = *nil; test_ok(a == nil)
+a, = *1; test_ok(a == 1)
a, = *[]; test_ok(a == nil)
a, = *[1]; test_ok(a == 1)
a, = *[nil]; test_ok(a == nil)
@@ -90,15 +91,17 @@ a, = *[*[1,2]]; test_ok(a == 1)
*a = nil; test_ok(a == [nil])
*a = 1; test_ok(a == [1])
-*a = []; test_ok(a == [])
-*a = [1]; test_ok(a == [1])
-*a = [nil]; test_ok(a == [nil])
-*a = [[]]; test_ok(a == [[]])
-*a = [1,2]; test_ok(a == [1,2])
-*a = [*[]]; test_ok(a == [])
-*a = [*[1]]; test_ok(a == [1])
-*a = [*[1,2]]; test_ok(a == [1,2])
-
+*a = []; test_ok(a == [[]])
+*a = [1]; test_ok(a == [[1]])
+*a = [nil]; test_ok(a == [[nil]])
+*a = [[]]; test_ok(a == [[[]]])
+*a = [1,2]; test_ok(a == [[1,2]])
+*a = [*[]]; test_ok(a == [[]])
+*a = [*[1]]; test_ok(a == [[1]])
+*a = [*[1,2]]; test_ok(a == [[1,2]])
+
+*a = *nil; test_ok(a == [nil])
+*a = *1; test_ok(a == [1])
*a = *[]; test_ok(a == [])
*a = *[1]; test_ok(a == [1])
*a = *[nil]; test_ok(a == [nil])
@@ -119,6 +122,8 @@ a,b,*c = [*[]]; test_ok([a,b,c] == [nil,nil,[]])
a,b,*c = [*[1]]; test_ok([a,b,c] == [1,nil,[]])
a,b,*c = [*[1,2]]; test_ok([a,b,c] == [1,2,[]])
+a,b,*c = *nil; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = *1; test_ok([a,b,c] == [1,nil,[]])
a,b,*c = *[]; test_ok([a,b,c] == [nil,nil,[]])
a,b,*c = *[1]; test_ok([a,b,c] == [1,nil,[]])
a,b,*c = *[nil]; test_ok([a,b,c] == [nil,nil,[]])
@@ -137,13 +142,13 @@ def f; yield [[]]; end; f {|a| test_ok(a == [[]])}
def f; yield [*[]]; end; f {|a| test_ok(a == [])}
def f; yield [*[1]]; end; f {|a| test_ok(a == [1])}
def f; yield [*[1,2]]; end; f {|a| test_ok(a == [1,2])}
-def f; yield *[]; end; f {|a| test_ok(a == nil)}
+
+def f; yield *nil; end; f {|a| test_ok(a == nil)}
+def f; yield *1; end; f {|a| test_ok(a == 1)}
def f; yield *[1]; end; f {|a| test_ok(a == 1)}
def f; yield *[nil]; end; f {|a| test_ok(a == nil)}
def f; yield *[[]]; end; f {|a| test_ok(a == [])}
-def f; yield *[*[]]; end; f {|a| test_ok(a == nil)}
def f; yield *[*[1]]; end; f {|a| test_ok(a == 1)}
-def f; yield *[*[1,2]]; end; f {|a| test_ok(a == 1)}
def f; yield; end; f {|a,| test_ok(a == nil)}
def f; yield nil; end; f {|a,| test_ok(a == nil)}
@@ -156,10 +161,12 @@ def f; yield [*[]]; end; f {|a,| test_ok(a == nil)}
def f; yield [*[1]]; end; f {|a,| test_ok(a == 1)}
def f; yield [*[1,2]]; end; f {|a,| test_ok(a == 1)}
+def f; yield *nil; end; f {|a,| test_ok(a == nil)}
+def f; yield *1; end; f {|a,| test_ok(a == 1)}
def f; yield *[]; end; f {|a,| test_ok(a == nil)}
def f; yield *[1]; end; f {|a,| test_ok(a == 1)}
def f; yield *[nil]; end; f {|a,| test_ok(a == nil)}
-def f; yield *[[]]; end; f {|a,| test_ok(a == nil)}
+def f; yield *[[]]; end; f {|a,| test_ok(a == [])}
def f; yield *[*[]]; end; f {|a,| test_ok(a == nil)}
def f; yield *[*[1]]; end; f {|a,| test_ok(a == 1)}
def f; yield *[*[1,2]]; end; f {|a,| test_ok(a == 1)}
@@ -176,6 +183,8 @@ def f; yield [*[]]; end; f {|*a| test_ok(a == [[]])}
def f; yield [*[1]]; end; f {|*a| test_ok(a == [[1]])}
def f; yield [*[1,2]]; end; f {|*a| test_ok(a == [[1,2]])}
+def f; yield *nil; end; f {|*a| test_ok(a == [nil])}
+def f; yield *1; end; f {|*a| test_ok(a == [1])}
def f; yield *[]; end; f {|*a| test_ok(a == [])}
def f; yield *[1]; end; f {|*a| test_ok(a == [1])}
def f; yield *[nil]; end; f {|*a| test_ok(a == [nil])}
@@ -195,10 +204,12 @@ def f; yield [*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
def f; yield [*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
def f; yield [*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,2,[]])}
+def f; yield *nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *1; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
def f; yield *[]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
def f; yield *[1]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
def f; yield *[nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
-def f; yield *[[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *[[]]; end; f {|a,b,*c| test_ok([a,b,c] == [[],nil,[]])}
def f; yield *[*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
def f; yield *[*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
def f; yield *[*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,2,[]])}
@@ -214,40 +225,58 @@ def r; return [*[]]; end; a = r(); test_ok(a == [])
def r; return [*[1]]; end; a = r(); test_ok(a == [1])
def r; return [*[1,2]]; end; a = r(); test_ok(a == [1,2])
-def r; return *[]; end; a = r(); test_ok(a == [])
-def r; return *[1]; end; a = r(); test_ok(a == [1])
-def r; return *[nil]; end; a = r(); test_ok(a == [nil])
-def r; return *[[]]; end; a = r(); test_ok(a == [[]])
-def r; return *[*[]]; end; a = r(); test_ok(a == [])
-def r; return *[*[1]]; end; a = r(); test_ok(a == [1])
+def r; return *nil; end; a = r(); test_ok(a == nil)
+def r; return *1; end; a = r(); test_ok(a == 1)
+def r; return *[]; end; a = r(); test_ok(a == nil)
+def r; return *[1]; end; a = r(); test_ok(a == 1)
+def r; return *[nil]; end; a = r(); test_ok(a == nil)
+def r; return *[[]]; end; a = r(); test_ok(a == [])
+def r; return *[*[]]; end; a = r(); test_ok(a == nil)
+def r; return *[*[1]]; end; a = r(); test_ok(a == 1)
def r; return *[*[1,2]]; end; a = r(); test_ok(a == [1,2])
-def r; return *[[]]; end; a = *r(); test_ok(a == [[]])
+def r; return *nil; end; a = *r(); test_ok(a == nil)
+def r; return *1; end; a = *r(); test_ok(a == 1)
+def r; return *[]; end; a = *r(); test_ok(a == nil)
+def r; return *[1]; end; a = *r(); test_ok(a == 1)
+def r; return *[nil]; end; a = *r(); test_ok(a == nil)
+def r; return *[[]]; end; a = *r(); test_ok(a == nil)
+def r; return *[*[]]; end; a = *r(); test_ok(a == nil)
+def r; return *[*[1]]; end; a = *r(); test_ok(a == 1)
def r; return *[*[1,2]]; end; a = *r(); test_ok(a == [1,2])
def r; return; end; *a = r(); test_ok(a == [nil])
def r; return nil; end; *a = r(); test_ok(a == [nil])
def r; return 1; end; *a = r(); test_ok(a == [1])
-def r; return []; end; *a = r(); test_ok(a == [])
-def r; return [1]; end; *a = r(); test_ok(a == [1])
-def r; return [nil]; end; *a = r(); test_ok(a == [nil])
-def r; return [[]]; end; *a = r(); test_ok(a == [[]])
-def r; return [1,2]; end; *a = r(); test_ok(a == [1,2])
-def r; return [*[]]; end; *a = r(); test_ok(a == [])
-def r; return [*[1]]; end; *a = r(); test_ok(a == [1])
-def r; return [*[1,2]]; end; *a = r(); test_ok(a == [1,2])
-
-def r; return *[]; end; *a = r(); test_ok(a == [])
+def r; return []; end; *a = r(); test_ok(a == [[]])
+def r; return [1]; end; *a = r(); test_ok(a == [[1]])
+def r; return [nil]; end; *a = r(); test_ok(a == [[nil]])
+def r; return [[]]; end; *a = r(); test_ok(a == [[[]]])
+def r; return [1,2]; end; *a = r(); test_ok(a == [[1,2]])
+def r; return [*[]]; end; *a = r(); test_ok(a == [[]])
+def r; return [*[1]]; end; *a = r(); test_ok(a == [[1]])
+def r; return [*[1,2]]; end; *a = r(); test_ok(a == [[1,2]])
+
+def r; return *nil; end; *a = r(); test_ok(a == [nil])
+def r; return *1; end; *a = r(); test_ok(a == [1])
+def r; return *[]; end; *a = r(); test_ok(a == [nil])
def r; return *[1]; end; *a = r(); test_ok(a == [1])
def r; return *[nil]; end; *a = r(); test_ok(a == [nil])
def r; return *[[]]; end; *a = r(); test_ok(a == [[]])
-def r; return *[1,2]; end; *a = r(); test_ok(a == [1,2])
-def r; return *[*[]]; end; *a = r(); test_ok(a == [])
+def r; return *[1,2]; end; *a = r(); test_ok(a == [[1,2]])
+def r; return *[*[]]; end; *a = r(); test_ok(a == [nil])
def r; return *[*[1]]; end; *a = r(); test_ok(a == [1])
-def r; return *[*[1,2]]; end; *a = r(); test_ok(a == [1,2])
-
-def r; return *[[]]; end; *a = *r(); test_ok(a == [[]])
+def r; return *[*[1,2]]; end; *a = r(); test_ok(a == [[1,2]])
+
+def r; return *nil; end; *a = *r(); test_ok(a == [nil])
+def r; return *1; end; *a = *r(); test_ok(a == [1])
+def r; return *[]; end; *a = *r(); test_ok(a == [nil])
+def r; return *[1]; end; *a = *r(); test_ok(a == [1])
+def r; return *[nil]; end; *a = *r(); test_ok(a == [nil])
+def r; return *[[]]; end; *a = *r(); test_ok(a == [])
def r; return *[1,2]; end; *a = *r(); test_ok(a == [1,2])
+def r; return *[*[]]; end; *a = *r(); test_ok(a == [nil])
+def r; return *[*[1]]; end; *a = *r(); test_ok(a == [1])
def r; return *[*[1,2]]; end; *a = *r(); test_ok(a == [1,2])
def r; return; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
@@ -262,10 +291,12 @@ def r; return [*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
def r; return [*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
def r; return [*[1,2]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
+def r; return *nil; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
+def r; return *1; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
def r; return *[]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
def r; return *[1]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
def r; return *[nil]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
-def r; return *[[]]; end; a,b,*c = r(); test_ok([a,b,c] == [[],nil,[]])
+def r; return *[[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
def r; return *[1,2]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]])
def r; return *[*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]])
def r; return *[*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]])
@@ -321,37 +352,48 @@ a = loop do break [*[]]; end; test_ok(a == [])
a = loop do break [*[1]]; end; test_ok(a == [1])
a = loop do break [*[1,2]]; end; test_ok(a == [1,2])
-a = loop do break *[]; end; test_ok(a == [])
-a = loop do break *[1]; end; test_ok(a == [1])
-a = loop do break *[nil]; end; test_ok(a == [nil])
-a = loop do break *[[]]; end; test_ok(a == [[]])
-a = loop do break *[*[]]; end; test_ok(a == [])
-a = loop do break *[*[1]]; end; test_ok(a == [1])
+a = loop do break *nil; end; test_ok(a == nil)
+a = loop do break *1; end; test_ok(a == 1)
+a = loop do break *[]; end; test_ok(a == nil)
+a = loop do break *[1]; end; test_ok(a == 1)
+a = loop do break *[nil]; end; test_ok(a == nil)
+a = loop do break *[[]]; end; test_ok(a == [])
+a = loop do break *[*[]]; end; test_ok(a == nil)
+a = loop do break *[*[1]]; end; test_ok(a == 1)
a = loop do break *[*[1,2]]; end; test_ok(a == [1,2])
*a = loop do break; end; test_ok(a == [nil])
*a = loop do break nil; end; test_ok(a == [nil])
*a = loop do break 1; end; test_ok(a == [1])
-*a = loop do break []; end; test_ok(a == [])
-*a = loop do break [1]; end; test_ok(a == [1])
-*a = loop do break [nil]; end; test_ok(a == [nil])
-*a = loop do break [[]]; end; test_ok(a == [[]])
-*a = loop do break [1,2]; end; test_ok(a == [1,2])
-*a = loop do break [*[]]; end; test_ok(a == [])
-*a = loop do break [*[1]]; end; test_ok(a == [1])
-*a = loop do break [*[1,2]]; end; test_ok(a == [1,2])
-
-*a = loop do break *[]; end; test_ok(a == [])
+*a = loop do break []; end; test_ok(a == [[]])
+*a = loop do break [1]; end; test_ok(a == [[1]])
+*a = loop do break [nil]; end; test_ok(a == [[nil]])
+*a = loop do break [[]]; end; test_ok(a == [[[]]])
+*a = loop do break [1,2]; end; test_ok(a == [[1,2]])
+*a = loop do break [*[]]; end; test_ok(a == [[]])
+*a = loop do break [*[1]]; end; test_ok(a == [[1]])
+*a = loop do break [*[1,2]]; end; test_ok(a == [[1,2]])
+
+*a = loop do break *nil; end; test_ok(a == [nil])
+*a = loop do break *1; end; test_ok(a == [1])
+*a = loop do break *[]; end; test_ok(a == [nil])
*a = loop do break *[1]; end; test_ok(a == [1])
*a = loop do break *[nil]; end; test_ok(a == [nil])
*a = loop do break *[[]]; end; test_ok(a == [[]])
-*a = loop do break *[1,2]; end; test_ok(a == [1,2])
-*a = loop do break *[*[]]; end; test_ok(a == [])
+*a = loop do break *[1,2]; end; test_ok(a == [[1,2]])
+*a = loop do break *[*[]]; end; test_ok(a == [nil])
*a = loop do break *[*[1]]; end; test_ok(a == [1])
-*a = loop do break *[*[1,2]]; end; test_ok(a == [1,2])
-
-*a = *loop do break *[[]]; end; test_ok(a == [[]])
+*a = loop do break *[*[1,2]]; end; test_ok(a == [[1,2]])
+
+*a = *loop do break *nil; end; test_ok(a == [nil])
+*a = *loop do break *1; end; test_ok(a == [1])
+*a = *loop do break *[]; end; test_ok(a == [nil])
+*a = *loop do break *[1]; end; test_ok(a == [1])
+*a = *loop do break *[nil]; end; test_ok(a == [nil])
+*a = *loop do break *[[]]; end; test_ok(a == [])
*a = *loop do break *[1,2]; end; test_ok(a == [1,2])
+*a = *loop do break *[*[]]; end; test_ok(a == [nil])
+*a = *loop do break *[*[1]]; end; test_ok(a == [1])
*a = *loop do break *[*[1,2]]; end; test_ok(a == [1,2])
a,b,*c = loop do break; end; test_ok([a,b,c] == [nil,nil,[]])
@@ -366,10 +408,12 @@ a,b,*c = loop do break [*[]]; end; test_ok([a,b,c] == [nil,nil,[]])
a,b,*c = loop do break [*[1]]; end; test_ok([a,b,c] == [1,nil,[]])
a,b,*c = loop do break [*[1,2]]; end; test_ok([a,b,c] == [1,2,[]])
+a,b,*c = loop do break *nil; end; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = loop do break *1; end; test_ok([a,b,c] == [1,nil,[]])
a,b,*c = loop do break *[]; end; test_ok([a,b,c] == [nil,nil,[]])
a,b,*c = loop do break *[1]; end; test_ok([a,b,c] == [1,nil,[]])
a,b,*c = loop do break *[nil]; end; test_ok([a,b,c] == [nil,nil,[]])
-a,b,*c = loop do break *[[]]; end; test_ok([a,b,c] == [[],nil,[]])
+a,b,*c = loop do break *[[]]; end; test_ok([a,b,c] == [nil,nil,[]])
a,b,*c = loop do break *[1,2]; end; test_ok([a,b,c] == [1,2,[]])
a,b,*c = loop do break *[*[]]; end; test_ok([a,b,c] == [nil,nil,[]])
a,b,*c = loop do break *[*[1]]; end; test_ok([a,b,c] == [1,nil,[]])
@@ -387,30 +431,39 @@ r([]){next [*[]]}
r([1]){next [*[1]]}
r([1,2]){next [*[1,2]]}
-r([]){next *[]}
-r([1]){next *[1]}
-r([nil]){next *[nil]}
-r([[]]){next *[[]]}
-r([]){next *[*[]]}
-r([1]){next *[*[1]]}
+r(nil){next *nil}
+r(1){next *1}
+r(nil){next *[]}
+r(1){next *[1]}
+r(nil){next *[nil]}
+r([]){next *[[]]}
+r(nil){next *[*[]]}
+r(1){next *[*[1]]}
r([1,2]){next *[*[1,2]]}
def r(val); *a = yield(); test_ok(a == val, 2); end
r([nil]){next}
r([nil]){next nil}
r([1]){next 1}
-r([]){next []}
-r([1]){next [1]}
-r([nil]){next [nil]}
-r([[]]){next [[]]}
-r([1,2]){next [1,2]}
-r([]){next [*[]]}
-r([1]){next [*[1]]}
-r([1,2]){next [*[1,2]]}
+r([[]]){next []}
+r([[1]]){next [1]}
+r([[nil]]){next [nil]}
+r([[[]]]){next [[]]}
+r([[1,2]]){next [1,2]}
+r([[]]){next [*[]]}
+r([[1]]){next [*[1]]}
+r([[1,2]]){next [*[1,2]]}
def r(val); *a = *yield(); test_ok(a == val, 2); end
-r([[]]){next *[[]]}
+r([nil]){next *nil}
+r([1]){next *1}
+r([nil]){next *[]}
+r([1]){next *[1]}
+r([nil]){next *[nil]}
+r([]){next *[[]]}
r([1,2]){next *[1,2]}
+r([nil]){next *[*[]]}
+r([1]){next *[*[1]]}
r([1,2]){next *[*[1,2]]}
def r(val); a,b,*c = yield(); test_ok([a,b,c] == val, 2); end
@@ -427,8 +480,15 @@ r([1,nil,[]]){next [*[1]]}
r([1,2,[]]){next [*[1,2]]}
def r(val); a,b,*c = *yield(); test_ok([a,b,c] == val, 2); end
-r([[],nil,[]]){next *[[]]}
+r([nil,nil,[]]){next *nil}
+r([1,nil,[]]){next *1}
+r([nil,nil,[]]){next *[]}
+r([1,nil,[]]){next *[1]}
+r([nil,nil,[]]){next *[nil]}
+r([nil,nil,[]]){next *[[]]}
r([1,2,[]]){next *[1,2]}
+r([nil,nil,[]]){next *[*[]]}
+r([1,nil,[]]){next *[*[1]]}
r([1,2,[]]){next *[*[1,2]]}
test_check "condition"
@@ -525,15 +585,15 @@ tmp.close
# test redo
$bad = false
tmp = open("while_tmp", "r")
-while line = tmp.gets()
- lastline = line
- line = line.gsub(/vt100/, 'VT100')
- if lastline != line
- line.gsub!('VT100', 'Vt100')
+while tmp.gets()
+ line = $_
+ gsub(/vt100/, 'VT100')
+ if $_ != line
+ $_.gsub!('VT100', 'Vt100')
redo
end
- $bad = 1 if /vt100/ =~ line
- $bad = 1 if /VT100/ =~ line
+ $bad = 1 if /vt100/ =~ $_
+ $bad = 1 if /VT100/ =~ $_
end
test_ok(tmp.eof? && !$bad)
tmp.close
@@ -753,11 +813,12 @@ test_ok($x == [1,2,3,1,2,3])
test_check "hash"
$x = {1=>2, 2=>4, 3=>6}
+$y = {1, 2, 2, 4, 3, 6}
test_ok($x[1] == 2)
test_ok(begin
- for k,v in $x
+ for k,v in $y
raise if k*2 != v
end
true
@@ -771,19 +832,19 @@ test_ok($x.has_value?(4))
test_ok($x.values_at(2,3) == [4,6])
test_ok($x == {1=>2, 2=>4, 3=>6})
-$z = $x.keys.sort.join(":")
+$z = $y.keys.sort.join(":")
test_ok($z == "1:2:3")
-$z = $x.values.sort.join(":")
+$z = $y.values.sort.join(":")
test_ok($z == "2:4:6")
-test_ok($x == $x)
+test_ok($x == $y)
-$x.shift
-test_ok($x.length == 2)
+$y.shift
+test_ok($y.length == 2)
$z = [1,2]
-$x[$z] = 256
-test_ok($x[$z] == 256)
+$y[$z] = 256
+test_ok($y[$z] == 256)
$x = Hash.new(0)
$x[1] = 1
@@ -848,9 +909,8 @@ def tt
}
end
-i=0
tt{|i| break if i == 5}
-test_ok(i == 0)
+test_ok(i == 5)
def tt2(dummy)
yield 1
@@ -916,6 +976,18 @@ end
test_ok($x.size == 7)
test_ok($x == [1, 2, 3, 4, 5, 6, 7])
+$done = false
+$x = []
+for i in 1 .. 7 # see how retry works in iterator loop
+ if i == 4 and not $done
+ $done = true
+ retry
+ end
+ $x.push(i)
+end
+test_ok($x.size == 10)
+test_ok($x == [1, 2, 3, 1, 2, 3, 4, 5, 6, 7])
+
# append method to built-in class
class Array
def iter_test1
@@ -953,11 +1025,11 @@ test_ok(IterTest.new(nil).method(:f).to_proc.call([m]) == [m])
IterTest.new([0]).each0 {|x| test_ok(x == 0)}
IterTest.new([1]).each1 {|x| test_ok(x == 1)}
IterTest.new([2]).each2 {|x| test_ok(x == [2])}
-#IterTest.new([3]).each3 {|x| test_ok(x == 3)}
+IterTest.new([3]).each3 {|x| test_ok(x == 3)}
IterTest.new([4]).each4 {|x| test_ok(x == 4)}
IterTest.new([5]).each5 {|x| test_ok(x == 5)}
IterTest.new([6]).each6 {|x| test_ok(x == [6])}
-#IterTest.new([7]).each7 {|x| test_ok(x == 7)}
+IterTest.new([7]).each7 {|x| test_ok(x == 7)}
IterTest.new([8]).each8 {|x| test_ok(x == 8)}
IterTest.new([[0]]).each0 {|x| test_ok(x == [0])}
@@ -970,8 +1042,8 @@ IterTest.new([[6]]).each6 {|x| test_ok(x == [[6]])}
IterTest.new([[7]]).each7 {|x| test_ok(x == 7)}
IterTest.new([[8]]).each8 {|x| test_ok(x == [8])}
-IterTest.new([[0,0]]).each0 {|*x| test_ok(x == [[0,0]])}
-IterTest.new([[8,8]]).each8 {|*x| test_ok(x == [[8,8]])}
+IterTest.new([[0,0]]).each0 {|x| test_ok(x == [0,0])}
+IterTest.new([[8,8]]).each8 {|x| test_ok(x == [8,8])}
def m0(v)
v
@@ -984,7 +1056,7 @@ test_ok(m1{p 'test'})
test_ok(!m1)
def m
- m0(block_given?,&Proc.new{})
+ m0(block_given?,&proc{})
end
test_ok(m1{p 'test'})
test_ok(!m1)
@@ -1011,7 +1083,7 @@ end
block_test(NilClass)
block_test(Proc){}
-def call_argument_test(state, proc, *args)
+def argument_test(state, proc, *args)
x = state
begin
proc.call(*args)
@@ -1021,48 +1093,42 @@ def call_argument_test(state, proc, *args)
test_ok(x,2)
end
-call_argument_test(true, lambda{||})
-call_argument_test(false, lambda{||}, 1)
-call_argument_test(true, lambda{|a,|}, 1)
-call_argument_test(false, lambda{|a,|})
-call_argument_test(false, lambda{|a,|}, 1,2)
-
-call_argument_test(true, Proc.new{||})
-call_argument_test(true, Proc.new{||}, 1)
-call_argument_test(true, Proc.new{|a,|}, 1)
-call_argument_test(true, Proc.new{|a,|})
-call_argument_test(true, Proc.new{|a,|}, 1,2)
+argument_test(true, lambda{||})
+argument_test(false, lambda{||}, 1)
+argument_test(true, lambda{|a,|}, 1)
+argument_test(false, lambda{|a,|})
+argument_test(false, lambda{|a,|}, 1,2)
-def block_get(&block)
+def get_block(&block)
block
end
-test_ok(Proc == block_get{}.class)
-call_argument_test(true, block_get{||})
-call_argument_test(true, block_get{||}, 1)
-call_argument_test(true, block_get{|a,|}, 1)
-call_argument_test(true, block_get{|a,|})
-call_argument_test(true, block_get{|a,|}, 1,2)
+test_ok(Proc == get_block{}.class)
+argument_test(true, get_block{||})
+argument_test(true, get_block{||}, 1)
+argument_test(true, get_block{|a,|}, 1)
+argument_test(true, get_block{|a,|})
+argument_test(true, get_block{|a,|}, 1,2)
-call_argument_test(true, block_get(&lambda{||}))
-call_argument_test(false, block_get(&lambda{||}),1)
-call_argument_test(true, block_get(&lambda{|a,|}),1)
-call_argument_test(false, block_get(&lambda{|a,|}),1,2)
+argument_test(true, get_block(&lambda{||}))
+argument_test(false, get_block(&lambda{||}),1)
+argument_test(true, get_block(&lambda{|a,|}),1)
+argument_test(false, get_block(&lambda{|a,|}),1,2)
-blk = block_get{11}
-test_ok(blk.class == Proc)
-test_ok(blk.to_proc.class == Proc)
-test_ok(blk.clone.call == 11)
-test_ok(block_get(&blk).class == Proc)
+block = get_block{11}
+test_ok(block.class == Proc)
+test_ok(block.to_proc.class == Proc)
+test_ok(block.clone.call == 11)
+test_ok(get_block(&block).class == Proc)
-lmd = lambda{44}
-test_ok(lmd.class == Proc)
-test_ok(lmd.to_proc.class == Proc)
-test_ok(lmd.clone.call == 44)
-test_ok(block_get(&lmd).class == Proc)
+lambda = lambda{44}
+test_ok(lambda.class == Proc)
+test_ok(lambda.to_proc.class == Proc)
+test_ok(lambda.clone.call == 44)
+test_ok(get_block(&lambda).class == Proc)
-test_ok(Proc.new{|a,| a}.yield(1,2,3) == 1)
-call_argument_test(true, Proc.new{|a,|}, 1,2)
+test_ok(Proc.new{|a,| a}.call(1,2,3) == 1)
+argument_test(true, Proc.new{|a,|}, 1,2)
test_ok(Proc.new{|&b| b.call(10)}.call {|x| x} == 10)
test_ok(Proc.new{|a,&b| b.call(a)}.call(12) {|x| x} == 12)
@@ -1070,7 +1136,7 @@ test_ok(Proc.new{|a,&b| b.call(a)}.call(12) {|x| x} == 12)
def test_return1
Proc.new {
return 55
- }.yield + 5
+ }.call + 5
end
test_ok(test_return1() == 55)
def test_return2
@@ -1087,23 +1153,15 @@ def proc_yield()
yield
end
def proc_return1
- lambda{return 42}.call+1
-end
-test_ok(proc_return1() == 43)
-def proc_return2
- ->{return 42}.call+1
-end
-test_ok(proc_return2() == 43)
-def proc_return3
proc_call{return 42}+1
end
-test_ok(proc_return3() == 42)
-def proc_return4
+test_ok(proc_return1() == 42)
+def proc_return2
proc_yield{return 42}+1
end
-test_ok(proc_return4() == 42)
+test_ok(proc_return2() == 42)
-def ljump_test(state, proc, *args)
+def ljump_test(state, proc, *args)
x = state
begin
proc.call(*args)
@@ -1113,165 +1171,26 @@ def ljump_test(state, proc, *args)
test_ok(x,2)
end
-ljump_test(false, block_get{break})
+ljump_test(false, get_block{break})
ljump_test(true, lambda{break})
-def exit_value_test(&block)
- block.call
-rescue LocalJumpError
- $!.exit_value
-end
-
-test_ok(45 == exit_value_test{break 45})
-
-test_ok(55 == begin
- block_get{break 55}.call
- rescue LocalJumpError
- $!.exit_value
- end)
-
-def block_call(&block)
- block.call
-end
-
-def test_b1
- block_call{break 11}
-end
-test_ok(test_b1() == 11)
-
-def ljump_rescue(r)
- begin
- yield
- rescue LocalJumpError => e
- r if /from proc-closure/ =~ e.message
- end
-end
-
-def test_b2
- ljump_rescue(22) do
- block_get{break 21}.call
- end
-end
-test_ok(test_b2() == 22)
-
-def test_b3
- ljump_rescue(33) do
- Proc.new{break 31}.yield
- end
-end
-test_ok(test_b3() == 33)
-
-def test_b4
- lambda{break 44}.call
-end
-test_ok(test_b4() == 44)
-
-def test_b5
- ljump_rescue(55) do
- b = block_get{break 54}
- block_call(&b)
- end
-end
-test_ok(test_b5() == 55)
-
-def test_b6
- b = lambda{break 67}
- block_call(&b)
- 66
-end
-test_ok(test_b6() == 66)
-
-def util_r7
- block_get{break 78}
-end
-
-def test_b7
- b = util_r7()
- ljump_rescue(77) do
- block_call(&b)
- end
-end
-test_ok(test_b7() == 77)
-
-def util_b8(&block)
- block_call(&block)
-end
-
-def test_b8
- util_b8{break 88}
-end
-test_ok(test_b8() == 88)
-
-def util_b9(&block)
- lambda{block.call; 98}.call
-end
-
-def test_b9
- util_b9{break 99}
-end
-test_ok(test_b9() == 99)
-
-def util_b10
- util_b9{break 100}
-end
-
-def test_b10
- util_b10()
-end
-test_ok(test_b10() == 100)
-
-def test_b11
- ljump_rescue(111) do
- loop do
- Proc.new{break 110}.yield
- break 112
- end
- end
-end
-test_ok(test_b11() == 111)
-
-def test_b12
- loop do
- break lambda{break 122}.call
- break 121
- end
-end
-test_ok(test_b12() == 122)
-
-def test_b13
- ljump_rescue(133) do
- while true
- Proc.new{break 130}.yield
- break 131
- end
- end
-end
-test_ok(test_b13() == 133)
-
-def test_b14
- while true
- break lambda{break 144}.call
- break 143
- end
-end
-test_ok(test_b14() == 144)
-
-def test_b15
- [0].each {|c| yield 1 }
- 156
-end
-test_ok(test_b15{|e| break 155 } == 155)
+test_ok(block.arity == -1)
+test_ok(lambda.arity == -1)
+test_ok(lambda{||}.arity == 0)
+test_ok(lambda{|a|}.arity == 1)
+test_ok(lambda{|a,|}.arity == 1)
+test_ok(lambda{|a,b|}.arity == 2)
def marity_test(m)
method = method(m)
- test_ok(method.arity == method.to_proc.arity, 2)
+ test_ok(method.arity == method.to_proc.arity)
end
marity_test(:test_ok)
marity_test(:marity_test)
marity_test(:p)
lambda(&method(:test_ok)).call(true)
-lambda(&block_get{|a,n| test_ok(a,n)}).call(true, 2)
+lambda(&get_block{|a,n| test_ok(a,n)}).call(true, 2)
class ITER_TEST1
def a
@@ -1303,37 +1222,6 @@ end
ITER_TEST4.new.foo(44){55}
-class ITER_TEST5
- def tt(aa)
- aa
- end
-
- def uu(a)
- class << self
- define_method(:tt) do |sym|
- super(sym)
- end
- end
- end
-
- def xx(*x)
- x.size
- end
-end
-
-a = ITER_TEST5.new
-a.uu(12)
-test_ok(a.tt(1) == 1)
-
-class ITER_TEST6 < ITER_TEST5
- def xx(*a)
- a << 12
- super
- end
-end
-
-test_ok(ITER_TEST6.new.xx([24]) == 2)
-
test_check "float"
test_ok(2.6.floor == 2)
test_ok((-2.6).floor == -3)
@@ -1424,6 +1312,7 @@ $good = true;
for i in 4000..4096
n1 = 1 << i;
if (n1**2-1) / (n1+1) != (n1-1)
+ p i
$good = false
end
end
@@ -1527,9 +1416,9 @@ test_ok($x.sub(/.*\.([^\.]+)$/, '<\&>') == "<a.gif>")
# character constants(assumes ASCII)
test_ok("a"[0] == ?a)
test_ok(?a == ?a)
-test_ok(?\C-a == "\1")
-test_ok(?\M-a == "\341")
-test_ok(?\M-\C-a == "\201")
+test_ok(?\C-a == 1)
+test_ok(?\M-a == 225)
+test_ok(?\M-\C-a == 129)
test_ok("a".upcase![0] == ?A)
test_ok("A".downcase![0] == ?a)
test_ok("abc".tr!("a-z", "A-Z") == "ABC")
@@ -1541,7 +1430,7 @@ $x = "abcdef"
$y = [ ?a, ?b, ?c, ?d, ?e, ?f ]
$bad = false
$x.each_byte {|i|
- if i.chr != $y.shift
+ if i != $y.shift
$bad = true
break
end
@@ -1630,20 +1519,20 @@ test_ok(aaa(1, 2, 3, 4) == [1, 2, 3, 4])
test_ok(aaa(1, *[2, 3, 4]) == [1, 2, 3, 4])
test_check "proc"
-$proc = Proc.new{|i| i}
+$proc = proc{|i| i}
test_ok($proc.call(2) == 2)
test_ok($proc.call(3) == 3)
-$proc = Proc.new{|i| i*2}
+$proc = proc{|i| i*2}
test_ok($proc.call(2) == 4)
test_ok($proc.call(3) == 6)
-Proc.new{
+proc{
iii=5 # nested local variable
- $proc = Proc.new{|i|
+ $proc = proc{|i|
iii = i
}
- $proc2 = Proc.new {
+ $proc2 = proc {
$x = iii # nested variables shared by procs
}
# scope of nested variables
@@ -1672,12 +1561,12 @@ if defined? Process.kill
test_check "signal"
$x = 0
- trap "SIGINT", Proc.new{|sig| $x = 2}
+ trap "SIGINT", proc{|sig| $x = 2}
Process.kill "SIGINT", $$
sleep 0.1
test_ok($x == 2)
- trap "SIGINT", Proc.new{raise "Interrupt"}
+ trap "SIGINT", proc{raise "Interrupt"}
x = false
begin
@@ -1751,53 +1640,51 @@ rescue NameError # must raise error
end
test_ok(!$bad)
-x = binding #! YARV Limitation: Proc.new{}
+x = proc{}
eval "i4 = 1", x
test_ok(eval("i4", x) == 1)
-x = Proc.new{binding}.call #! YARV Limitation: Proc.new{Proc.new{}}.call
+x = proc{proc{}}.call
eval "i4 = 22", x
test_ok(eval("i4", x) == 22)
$x = []
-x = Proc.new{binding}.call #! YARV Limitation: Proc.new{Proc.new{}}.call
-eval "(0..9).each{|i5| $x[i5] = Proc.new{i5*2}}", x
+x = proc{proc{}}.call
+eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
test_ok($x[4].call == 8)
x = binding
eval "i = 1", x
test_ok(eval("i", x) == 1)
-x = Proc.new{binding}.call
+x = proc{binding}.call
eval "i = 22", x
test_ok(eval("i", x) == 22)
$x = []
-x = Proc.new{binding}.call
-eval "(0..9).each{|i5| $x[i5] = Proc.new{i5*2}}", x
+x = proc{binding}.call
+eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
test_ok($x[4].call == 8)
-x = Proc.new{binding}.call
+x = proc{binding}.call
eval "for i6 in 1..1; j6=i6; end", x
test_ok(eval("defined? i6", x))
test_ok(eval("defined? j6", x))
-Proc.new {
+proc {
p = binding
eval "foo11 = 1", p
foo22 = 5
- Proc.new{foo11=22}.call
- Proc.new{foo22=55}.call
+ proc{foo11=22}.call
+ proc{foo22=55}.call
test_ok(eval("foo11", p) == eval("foo11"))
test_ok(eval("foo11") == 1)
test_ok(eval("foo22", p) == eval("foo22"))
test_ok(eval("foo22") == 55)
-}.call if false #! YARV Limitation
+}.call
-#! YARV Limitation: p1 = Proc.new{i7 = 0; Proc.new{i7}}.call
-p1 = Proc.new{i7 = 0; binding}.call
-#! YARV Limitation: test_ok(p1.call == 0)
+p1 = proc{i7 = 0; proc{i7}}.call
+test_ok(p1.call == 0)
eval "i7=5", p1
-#! YARV Limitation: test_ok(p1.call == 5)
+test_ok(p1.call == 5)
test_ok(!defined?(i7))
-if false #! YARV Limitation
-p1 = Proc.new{i7 = 0; Proc.new{i7}}.call
+p1 = proc{i7 = 0; proc{i7}}.call
i7 = nil
test_ok(p1.call == 0)
eval "i7=1", p1
@@ -1805,7 +1692,6 @@ test_ok(p1.call == 1)
eval "i7=5", p1
test_ok(p1.call == 5)
test_ok(i7 == nil)
-end
test_check "system"
test_ok(`echo foobar` == "foobar\n")
@@ -1833,7 +1719,7 @@ tmp.print "__END__\n";
tmp.print "this is a trailing junk\n";
tmp.close
-test_ok(`./miniruby -x script_tmp` == '')
+test_ok(`./miniruby -x script_tmp` == 'nil')
test_ok(`./miniruby -x script_tmp -zzz=555` == '555')
tmp = open("script_tmp", "w")
@@ -1842,7 +1728,7 @@ for i in 1..5
end
tmp.close
-`./miniruby -i.bak -pe '$_.sub!(/^[0-9]+$/){$&.to_i * 5}' script_tmp`
+`./miniruby -i.bak -pe 'sub(/^[0-9]+$/){$&.to_i * 5}' script_tmp`
done = true
tmp = open("script_tmp", "r")
while tmp.gets
@@ -1853,32 +1739,29 @@ while tmp.gets
end
tmp.close
test_ok(done)
-
+
File.unlink "script_tmp" or `/bin/rm -f "script_tmp"`
File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
$bad = false
-if (dir = File.dirname(File.dirname(__FILE__))) == '.'
+if (dir = File.dirname(File.dirname($0))) == '.'
dir = ""
else
dir << "/"
end
def valid_syntax?(code, fname)
- p fname
- code.force_encoding("ascii-8bit")
code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) {
"#$&#{"\n" if $1 && !$2}BEGIN{return true}\n"
}
eval(code, nil, fname, 0)
rescue Exception
- STDERR.puts $!.message
+ puts $!.message
false
end
-for script in Dir["#{dir}{lib,sample,ext,test}/**/*.rb"]
+for script in Dir["#{dir}{lib,sample,ext}/**/*.rb"]
unless valid_syntax? IO::read(script), script
- STDERR.puts script
$bad = true
end
end
@@ -2010,7 +1893,7 @@ $_ = foobar
test_ok($_ == foobar)
class Gods
- @@rule = "Uranus" # private to Gods
+ @@rule = "Uranus"
def ruler0
@@rule
end
@@ -2026,18 +1909,15 @@ class Gods
end
module Olympians
- @@rule ="Zeus"
- def ruler3
+ @@rule ="Zeus"
+ def ruler3
@@rule
end
end
class Titans < Gods
- @@rule = "Cronus" # do not affect @@rule in Gods
- include Olympians
- def ruler4
- @@rule
- end
+ @@rule = "Cronus"
+ include Olympians # OK to cause warning (intentional)
end
test_ok(Gods.new.ruler0 == "Cronus")
@@ -2048,12 +1928,11 @@ test_ok(Titans.ruler2 == "Cronus")
atlas = Titans.new
test_ok(atlas.ruler0 == "Cronus")
test_ok(atlas.ruler3 == "Zeus")
-test_ok(atlas.ruler4 == "Cronus")
test_check "trace"
$x = 1234
$y = 0
-trace_var :$x, Proc.new{$y = $x}
+trace_var :$x, proc{$y = $x}
$x = 40414
test_ok($y == $x)
@@ -2061,7 +1940,7 @@ untrace_var :$x
$x = 19660208
test_ok($y != $x)
-trace_var :$x, Proc.new{$x *= 2}
+trace_var :$x, proc{$x *= 2}
$x = 5
test_ok($x == 10)
@@ -2179,15 +2058,6 @@ end
test_ok(File.expand_path(".", "//") == "//")
test_ok(File.expand_path("sub", "//") == "//sub")
-# test_check "Proc#binding"
-ObjectSpace.each_object(Proc){|o|
- begin
- b = o.binding
- eval 'self', b
- rescue ArgumentError
- end
-}
-
test_check "gc"
begin
1.upto(10000) {
@@ -2216,14 +2086,8 @@ l = []
GC.start
test_ok true # reach here or dumps core
-ObjectSpace.each_object{|o|
- o.class.name
-}
-
-test_ok true # reach here or dumps core
-
if $failed > 0
- printf "not ok/test: %d failed %d\n", $ntest, $failed
+ printf "test: %d failed %d\n", $ntest, $failed
else
printf "end of test(test: %d)\n", $ntest
end
diff --git a/sample/time.rb b/sample/time.rb
index 84fa9e1a8d..e16912052e 100644
--- a/sample/time.rb
+++ b/sample/time.rb
@@ -1,8 +1,12 @@
-#! /usr/local/bin/ruby
-cmd = ARGV.join(" ")
+#! /usr/bin/env ruby
+
b = Time.now
-system(cmd)
+system(*ARGV)
e = Time.now
-ut, st, cut, cst = Time.times.to_a
-total = (e - b).to_f
-STDERR.printf "%11.1f real %11.1f user %11.1f sys\n", total, cut, cst
+
+tms = Process.times
+real = e - b
+user = tms.cutime
+sys = tms.cstime
+
+STDERR.printf("%11.1f real %11.1f user %11.1f sys\n", real, user, sys)
diff --git a/signal.c b/signal.c
index 9e0316d2d6..fb21fd34fe 100644
--- a/signal.c
+++ b/signal.c
@@ -6,16 +6,14 @@
$Date$
created at: Tue Dec 20 10:13:44 JST 1994
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/signal.h"
-#include "ruby/node.h"
-#include "vm_core.h"
+#include "ruby.h"
+#include "rubysig.h"
#include <signal.h>
#include <stdio.h>
@@ -23,6 +21,12 @@
#undef SIGBUS
#endif
+#if defined HAVE_SIGPROCMASK || defined HAVE_SIGSETMASK
+#define USE_TRAP_MASK 1
+#else
+#define USE_TRAP_MASK 0
+#endif
+
#ifndef NSIG
# ifdef DJGPP
# define NSIG SIGMAX
@@ -171,7 +175,8 @@ static struct signals {
};
static int
-signm2signo(const char *nm)
+signm2signo(nm)
+ const char *nm;
{
struct signals *sigs;
@@ -182,7 +187,8 @@ signm2signo(const char *nm)
}
static const char*
-signo2signm(int no)
+signo2signm(no)
+ int no;
{
struct signals *sigs;
@@ -193,7 +199,8 @@ signo2signm(int no)
}
const char *
-ruby_signal_name(int no)
+ruby_signal_name(no)
+ int no;
{
return signo2signm(no);
}
@@ -207,23 +214,27 @@ ruby_signal_name(int no)
*/
static VALUE
-esignal_init(int argc, VALUE *argv, VALUE self)
+esignal_init(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
int argnum = 1;
VALUE sig = Qnil;
int signo;
const char *signm;
+ char tmpnm[(sizeof(int)*CHAR_BIT)/3+4];
if (argc > 0) {
- sig = rb_check_to_integer(argv[0], "to_int");
- if (!NIL_P(sig)) argnum = 2;
+ sig = argv[0];
+ if (FIXNUM_P(sig)) argnum = 2;
}
if (argc < 1 || argnum < argc) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, argnum);
}
if (argnum == 2) {
- signo = NUM2INT(sig);
+ signo = FIX2INT(sig);
if (signo < 0 || signo > NSIG) {
rb_raise(rb_eArgError, "invalid signal number (%d)", signo);
}
@@ -233,11 +244,12 @@ esignal_init(int argc, VALUE *argv, VALUE self)
else {
signm = signo2signm(signo);
if (signm) {
- sig = rb_sprintf("SIG%s", signm);
+ snprintf(tmpnm, sizeof(tmpnm), "SIG%s", signm);
}
else {
- sig = rb_sprintf("SIG%u", signo);
+ snprintf(tmpnm, sizeof(tmpnm), "SIG%u", signo);
}
+ sig = rb_str_new2(signm = tmpnm);
}
}
else {
@@ -258,21 +270,28 @@ esignal_init(int argc, VALUE *argv, VALUE self)
}
static VALUE
-interrupt_init(int argc, VALUE *argv, VALUE self)
+interrupt_init(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE args[2];
args[0] = INT2FIX(SIGINT);
rb_scan_args(argc, argv, "01", &args[1]);
+
return rb_call_super(2, args);
}
void
-ruby_default_signal(int sig)
+ruby_default_signal(sig)
+ int sig;
{
#ifndef MACOS_UNUSE_SIGNAL
+ extern rb_pid_t getpid _((void));
+
signal(sig, SIG_DFL);
- raise(sig);
+ kill(getpid(), sig);
#endif
}
@@ -301,11 +320,10 @@ ruby_default_signal(int sig)
*/
VALUE
-rb_f_kill(int argc, VALUE *argv)
+rb_f_kill(argc, argv)
+ int argc;
+ VALUE *argv;
{
-#ifndef HAS_KILLPG
-#define killpg(pg, sig) kill(-(pg), sig)
-#endif
int negative = 0;
int sig;
int i;
@@ -325,7 +343,7 @@ rb_f_kill(int argc, VALUE *argv)
goto str_signal;
case T_STRING:
- s = RSTRING_PTR(argv[0]);
+ s = RSTRING(argv[0])->ptr;
if (s[0] == '-') {
negative++;
s++;
@@ -346,7 +364,7 @@ rb_f_kill(int argc, VALUE *argv)
str = rb_check_string_type(argv[0]);
if (!NIL_P(str)) {
- s = RSTRING_PTR(str);
+ s = RSTRING(str)->ptr;
goto str_signal;
}
rb_raise(rb_eArgError, "bad signal type %s",
@@ -358,22 +376,28 @@ rb_f_kill(int argc, VALUE *argv)
if (sig < 0) {
sig = -sig;
for (i=1; i<argc; i++) {
- if (killpg(NUM2PIDT(argv[i]), sig) < 0)
+ int pid = NUM2INT(argv[i]);
+#ifdef HAS_KILLPG
+ if (killpg(pid, sig) < 0)
+#else
+ if (kill(-pid, sig) < 0)
+#endif
rb_sys_fail(0);
}
}
else {
for (i=1; i<argc; i++) {
- if (kill(NUM2PIDT(argv[i]), sig) < 0)
+ Check_Type(argv[i], T_FIXNUM);
+ if (kill(FIX2INT(argv[i]), sig) < 0)
rb_sys_fail(0);
}
}
- rb_thread_polling();
return INT2FIX(i-1);
}
static struct {
VALUE cmd;
+ int safe;
} trap_list[NSIG];
static rb_atomic_t trap_pending_list[NSIG];
static char rb_trap_accept_nativethreads[NSIG];
@@ -381,14 +405,8 @@ rb_atomic_t rb_trap_pending;
rb_atomic_t rb_trap_immediate;
int rb_prohibit_interrupt = 1;
-VALUE
-rb_get_trap_cmd(int sig)
-{
- return trap_list[sig].cmd;
-}
-
void
-rb_gc_mark_trap_list(void)
+rb_gc_mark_trap_list()
{
#ifndef MACOS_UNUSE_SIGNAL
int i;
@@ -404,44 +422,67 @@ rb_gc_mark_trap_list(void)
#define sighandler_t sh_t
#endif
-typedef RETSIGTYPE (*sighandler_t)(int);
+typedef RETSIGTYPE (*sighandler_t)_((int));
#ifdef POSIX_SIGNAL
static sighandler_t
-ruby_signal(int signum, sighandler_t handler)
+ruby_signal(signum, handler)
+ int signum;
+ sighandler_t handler;
{
struct sigaction sigact, old;
rb_trap_accept_nativethreads[signum] = 0;
- sigemptyset(&sigact.sa_mask);
-#ifdef SA_SIGINFO
- sigact.sa_sigaction = (void (*)(int, siginfo_t*, void*))handler;
- sigact.sa_flags = SA_SIGINFO;
-#else
sigact.sa_handler = handler;
+ sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
-#endif
-
-#ifdef SA_NOCLDWAIT
+# ifdef SA_NOCLDWAIT
if (signum == SIGCHLD && handler == SIG_IGN)
sigact.sa_flags |= SA_NOCLDWAIT;
-#endif
+# endif
sigaction(signum, &sigact, &old);
return old.sa_handler;
}
-sighandler_t
-posix_signal(int signum, sighandler_t handler)
+void
+posix_signal(signum, handler)
+ int signum;
+ sighandler_t handler;
{
- return ruby_signal(signum, handler);
+ ruby_signal(signum, handler);
}
+# ifdef HAVE_NATIVETHREAD
+static sighandler_t
+ruby_nativethread_signal(signum, handler)
+ int signum;
+ sighandler_t handler;
+{
+ sighandler_t old;
+
+ old = ruby_signal(signum, handler);
+ rb_trap_accept_nativethreads[signum] = 1;
+ return old;
+}
+
+void
+posix_nativethread_signal(signum, handler)
+ int signum;
+ sighandler_t handler;
+{
+ ruby_nativethread_signal(signum, handler);
+}
+# endif
+
#else /* !POSIX_SIGNAL */
#define ruby_signal(sig,handler) (rb_trap_accept_nativethreads[sig] = 0, signal((sig),(handler)))
-#ifdef HAVE_NATIVETHREAD
+
+# ifdef HAVE_NATIVETHREAD
static sighandler_t
-ruby_nativethread_signal(int signum, sighandler_t handler)
+ruby_nativethread_signal(signum, handler)
+ int signum;
+ sighandler_t handler;
{
sighandler_t old;
@@ -449,172 +490,176 @@ ruby_nativethread_signal(int signum, sighandler_t handler)
rb_trap_accept_nativethreads[signum] = 1;
return old;
}
-#endif
-#endif
+# endif
+#endif /* POSIX_SIGNAL */
-static RETSIGTYPE
-sighandler(int sig)
+static void signal_exec _((int sig));
+static void
+signal_exec(sig)
+ int sig;
{
- rb_vm_t *vm = GET_VM(); /* fix me for Multi-VM */
- ATOMIC_INC(vm->signal_buff[sig]);
- ATOMIC_INC(vm->buffered_signal_size);
-
-#if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL)
- ruby_signal(sig, sighandler);
+ if (trap_list[sig].cmd == 0) {
+ switch (sig) {
+ case SIGINT:
+ rb_thread_interrupt();
+ break;
+#ifdef SIGHUP
+ case SIGHUP:
+#endif
+#ifdef SIGQUIT
+ case SIGQUIT:
#endif
+#ifdef SIGTERM
+ case SIGTERM:
+#endif
+#ifdef SIGALRM
+ case SIGALRM:
+#endif
+#ifdef SIGUSR1
+ case SIGUSR1:
+#endif
+#ifdef SIGUSR2
+ case SIGUSR2:
+#endif
+ rb_thread_signal_raise(sig);
+ break;
+ }
+ }
+ else if (trap_list[sig].cmd == Qundef) {
+ rb_thread_signal_exit();
+ }
+ else {
+ rb_thread_trap_eval(trap_list[sig].cmd, sig, trap_list[sig].safe);
+ }
}
+#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
+static void
+sigsend_to_ruby_thread(int sig)
+{
# ifdef HAVE_SIGPROCMASK
-static sigset_t trap_last_mask;
+ sigset_t mask, old_mask;
# else
-static int trap_last_mask;
+ int mask, old_mask;
# endif
+# ifdef HAVE_SIGPROCMASK
+ sigfillset(&mask);
+ sigprocmask(SIG_BLOCK, &mask, &old_mask);
+# else
+ mask = sigblock(~0);
+ sigsetmask(mask);
+# endif
-#if HAVE_PTHREAD_H
-#include <pthread.h>
+ ruby_native_thread_kill(sig);
+}
#endif
-void
-rb_disable_interrupt(void)
+static RETSIGTYPE sighandler _((int));
+static RETSIGTYPE
+sighandler(sig)
+ int sig;
{
-#ifndef _WIN32
- sigset_t mask;
- sigfillset(&mask);
- sigdelset(&mask, SIGVTALRM);
- sigdelset(&mask, SIGSEGV);
- pthread_sigmask(SIG_SETMASK, &mask, NULL);
+#ifdef _WIN32
+#define IN_MAIN_CONTEXT(f, a) (rb_w32_main_context(a, f) ? (void)0 : f(a))
+#else
+#define IN_MAIN_CONTEXT(f, a) f(a)
#endif
-}
-void
-rb_enable_interrupt(void)
-{
-#ifndef _WIN32
- sigset_t mask;
- sigemptyset(&mask);
- pthread_sigmask(SIG_SETMASK, &mask, NULL);
+ if (sig >= NSIG) {
+ rb_bug("trap_handler: Bad signal %d", sig);
+ }
+
+#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
+ if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
+ sigsend_to_ruby_thread(sig);
+ return;
+ }
#endif
-}
-int
-rb_get_next_signal(rb_vm_t *vm)
-{
- int i, sig = 0;
-
- for (i=1; i<RUBY_NSIG; i++) {
- if (vm->signal_buff[i] > 0) {
- rb_disable_interrupt();
- {
- ATOMIC_DEC(vm->signal_buff[i]);
- ATOMIC_DEC(vm->buffered_signal_size);
- }
- rb_enable_interrupt();
- sig = i;
- break;
- }
+#if !defined(BSD_SIGNAL) && !defined(POSIX_SIGNAL)
+ if (rb_trap_accept_nativethreads[sig]) {
+ ruby_nativethread_signal(sig, sighandler);
+ }
+ else {
+ ruby_signal(sig, sighandler);
+ }
+#endif
+
+ if (trap_list[sig].cmd == 0 && ATOMIC_TEST(rb_trap_immediate)) {
+ IN_MAIN_CONTEXT(signal_exec, sig);
+ ATOMIC_SET(rb_trap_immediate, 1);
+ }
+ else {
+ ATOMIC_INC(rb_trap_pending);
+ ATOMIC_INC(trap_pending_list[sig]);
+#ifdef _WIN32
+ rb_w32_interrupted();
+#endif
}
- return sig;
}
#ifdef SIGBUS
+static RETSIGTYPE sigbus _((int));
static RETSIGTYPE
-sigbus(int sig)
+sigbus(sig)
+ int sig;
{
+#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
+ if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
+ sigsend_to_ruby_thread(sig);
+ return;
+ }
+#endif
+
rb_bug("Bus Error");
}
#endif
#ifdef SIGSEGV
-static int segv_received = 0;
+static RETSIGTYPE sigsegv _((int));
static RETSIGTYPE
-sigsegv(int sig)
+sigsegv(sig)
+ int sig;
{
- if (segv_received) {
- fprintf(stderr, "SEGV recieved in SEGV handler\n");
- exit(1);
- }
- else {
- extern int ruby_gc_stress;
- segv_received = 1;
- ruby_gc_stress = 0;
- rb_bug("Segmentation fault");
+#if defined(HAVE_NATIVETHREAD) && defined(HAVE_NATIVETHREAD_KILL)
+ if (!is_ruby_native_thread() && !rb_trap_accept_nativethreads[sig]) {
+ sigsend_to_ruby_thread(sig);
+ return;
}
+#endif
+
+ extern int ruby_gc_stress;
+ ruby_gc_stress = 0;
+ rb_bug("Segmentation fault");
}
#endif
#ifdef SIGPIPE
+static RETSIGTYPE sigpipe _((int));
static RETSIGTYPE
-sigpipe(int sig)
+sigpipe(sig)
+ int sig;
{
/* do nothing */
}
#endif
-static void
-signal_exec(VALUE cmd, int sig)
-{
- rb_proc_t *proc;
- VALUE signum = INT2FIX(sig);
- GetProcPtr(cmd, proc);
- vm_invoke_proc(GET_THREAD(), proc, proc->block.self, 1, &signum, 0);
-}
-
void
-rb_trap_exit(void)
+rb_trap_exit()
{
#ifndef MACOS_UNUSE_SIGNAL
if (trap_list[0].cmd) {
VALUE trap_exit = trap_list[0].cmd;
trap_list[0].cmd = 0;
- signal_exec(trap_exit, 0);
+ rb_eval_cmd(trap_exit, rb_ary_new3(1, INT2FIX(0)), trap_list[0].safe);
}
#endif
}
void
-rb_signal_exec(rb_thread_t *th, int sig)
-{
- VALUE cmd = rb_get_trap_cmd(sig);
-
- if (cmd == 0) {
- switch (sig) {
- case SIGINT:
- rb_interrupt();
- break;
-#ifdef SIGHUP
- case SIGHUP:
-#endif
-#ifdef SIGQUIT
- case SIGQUIT:
-#endif
-#ifdef SIGTERM
- case SIGTERM:
-#endif
-#ifdef SIGALRM
- case SIGALRM:
-#endif
-#ifdef SIGUSR1
- case SIGUSR1:
-#endif
-#ifdef SIGUSR2
- case SIGUSR2:
-#endif
- rb_thread_signal_raise(th, sig);
- break;
- }
- }
- else if (cmd == Qundef) {
- rb_thread_signal_exit(th);
- }
- else {
- signal_exec(cmd, sig);
- }
-}
-
-void
-rb_trap_exec(void)
+rb_trap_exec()
{
#ifndef MACOS_UNUSE_SIGNAL
int i;
@@ -622,7 +667,7 @@ rb_trap_exec(void)
for (i=0; i<NSIG; i++) {
if (trap_pending_list[i]) {
trap_pending_list[i] = 0;
- rb_signal_exec(GET_THREAD(), i);
+ signal_exec(i);
}
}
#endif /* MACOS_UNUSE_SIGNAL */
@@ -630,157 +675,89 @@ rb_trap_exec(void)
}
struct trap_arg {
-#ifndef _WIN32
+#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK
sigset_t mask;
# else
int mask;
# endif
#endif
- int sig;
- sighandler_t func;
- VALUE cmd;
+ VALUE sig, cmd;
};
-static sighandler_t
-default_handler(int sig)
-{
- sighandler_t func;
- switch (sig) {
- case SIGINT:
-#ifdef SIGHUP
- case SIGHUP:
-#endif
-#ifdef SIGQUIT
- case SIGQUIT:
-#endif
-#ifdef SIGTERM
- case SIGTERM:
-#endif
-#ifdef SIGALRM
- case SIGALRM:
-#endif
-#ifdef SIGUSR1
- case SIGUSR1:
-#endif
-#ifdef SIGUSR2
- case SIGUSR2:
-#endif
- func = sighandler;
- break;
-#ifdef SIGBUS
- case SIGBUS:
- func = sigbus;
- break;
-#endif
-#ifdef SIGSEGV
- case SIGSEGV:
- func = sigsegv;
- break;
-#endif
-#ifdef SIGPIPE
- case SIGPIPE:
- func = sigpipe;
- break;
+#if USE_TRAP_MASK
+# ifdef HAVE_SIGPROCMASK
+static sigset_t trap_last_mask;
+# else
+static int trap_last_mask;
+# endif
#endif
- default:
- func = SIG_DFL;
- break;
- }
-
- return func;
-}
+static RETSIGTYPE sigexit _((int));
static RETSIGTYPE
-wrong_trap(int sig)
+sigexit(sig)
+ int sig;
{
+ rb_thread_signal_exit();
}
-static sighandler_t
-trap_handler(VALUE *cmd, int sig)
+static VALUE
+trap(arg)
+ struct trap_arg *arg;
{
- sighandler_t func = wrong_trap;
- VALUE command;
+ sighandler_t func, oldfunc;
+ VALUE command, oldcmd;
+ int sig = -1;
+ const char *s;
- if (NIL_P(*cmd)) {
+ func = sighandler;
+ command = arg->cmd;
+ if (NIL_P(command)) {
func = SIG_IGN;
}
- else {
- command = rb_check_string_type(*cmd);
- if (!NIL_P(command)) {
- SafeStringValue(command); /* taint check */
- switch (RSTRING_LEN(command)) {
- case 0:
- goto sig_ign;
- break;
- case 14:
- if (strncmp(RSTRING_PTR(command), "SYSTEM_DEFAULT", 14) == 0) {
- func = SIG_DFL;
- *cmd = 0;
- }
- break;
- case 7:
- if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) {
-sig_ign:
- func = SIG_IGN;
- *cmd = 0;
- }
- else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) {
-sig_dfl:
- func = default_handler(sig);
- *cmd = 0;
- }
- else if (strncmp(RSTRING_PTR(command), "DEFAULT", 7) == 0) {
- goto sig_dfl;
- }
- break;
- case 6:
- if (strncmp(RSTRING_PTR(command), "IGNORE", 6) == 0) {
- goto sig_ign;
- }
- break;
- case 4:
- if (strncmp(RSTRING_PTR(command), "EXIT", 4) == 0) {
- func = sighandler;
- *cmd = Qundef;
- }
- break;
+ else if (TYPE(command) == T_STRING) {
+ SafeStringValue(command); /* taint check */
+ if (RSTRING(command)->len == 0) {
+ func = SIG_IGN;
+ }
+ else if (RSTRING(command)->len == 7) {
+ if (strncmp(RSTRING(command)->ptr, "SIG_IGN", 7) == 0) {
+ func = SIG_IGN;
+ }
+ else if (strncmp(RSTRING(command)->ptr, "SIG_DFL", 7) == 0) {
+ func = SIG_DFL;
}
- if (func == wrong_trap) {
- rb_raise(rb_eArgError, "wrong trap - %s", RSTRING_PTR(command));
+ else if (strncmp(RSTRING(command)->ptr, "DEFAULT", 7) == 0) {
+ func = SIG_DFL;
}
}
- else {
- rb_proc_t *proc;
- GetProcPtr(*cmd, proc);
- func = sighandler;
+ else if (RSTRING(command)->len == 6) {
+ if (strncmp(RSTRING(command)->ptr, "IGNORE", 6) == 0) {
+ func = SIG_IGN;
+ }
+ }
+ else if (RSTRING(command)->len == 4) {
+ if (strncmp(RSTRING(command)->ptr, "EXIT", 4) == 0) {
+ func = sigexit;
+ }
}
}
+ if (func == SIG_IGN || func == SIG_DFL) {
+ command = 0;
+ }
- return func;
-}
-
-static int
-trap_signm(VALUE vsig)
-{
- int sig = -1;
- const char *s;
-
- switch (TYPE(vsig)) {
+ switch (TYPE(arg->sig)) {
case T_FIXNUM:
- sig = FIX2INT(vsig);
- if (sig < 0 || sig >= NSIG) {
- rb_raise(rb_eArgError, "invalid signal number (%d)", sig);
- }
+ sig = FIX2INT(arg->sig);
break;
case T_SYMBOL:
- s = rb_id2name(SYM2ID(vsig));
+ s = rb_id2name(SYM2ID(arg->sig));
if (!s) rb_raise(rb_eArgError, "bad signal");
goto str_signal;
- default:
- s = StringValuePtr(vsig);
+ case T_STRING:
+ s = RSTRING(arg->sig)->ptr;
str_signal:
if (strncmp("SIG", s, 3) == 0)
@@ -789,32 +766,67 @@ trap_signm(VALUE vsig)
if (sig == 0 && strcmp(s, "EXIT") != 0)
rb_raise(rb_eArgError, "unsupported signal SIG%s", s);
}
- return sig;
-}
-
-static VALUE
-trap(struct trap_arg *arg)
-{
- sighandler_t oldfunc, func = arg->func;
- VALUE oldcmd, command = arg->cmd;
- int sig = arg->sig;
+ if (sig < 0 || sig >= NSIG) {
+ rb_raise(rb_eArgError, "invalid signal number (%d)", sig);
+ }
+#if defined(HAVE_SETITIMER)
+ if (sig == SIGVTALRM) {
+ rb_raise(rb_eArgError, "SIGVTALRM reserved for Thread; can't set handler");
+ }
+#endif
+ if (func == SIG_DFL) {
+ switch (sig) {
+ case SIGINT:
+#ifdef SIGHUP
+ case SIGHUP:
+#endif
+#ifdef SIGQUIT
+ case SIGQUIT:
+#endif
+#ifdef SIGTERM
+ case SIGTERM:
+#endif
+#ifdef SIGALRM
+ case SIGALRM:
+#endif
+#ifdef SIGUSR1
+ case SIGUSR1:
+#endif
+#ifdef SIGUSR2
+ case SIGUSR2:
+#endif
+ func = sighandler;
+ break;
+#ifdef SIGBUS
+ case SIGBUS:
+ func = sigbus;
+ break;
+#endif
+#ifdef SIGSEGV
+ case SIGSEGV:
+ func = sigsegv;
+ break;
+#endif
+#ifdef SIGPIPE
+ case SIGPIPE:
+ func = sigpipe;
+ break;
+#endif
+ }
+ }
oldfunc = ruby_signal(sig, func);
oldcmd = trap_list[sig].cmd;
- switch (oldcmd) {
- case 0:
+ if (!oldcmd) {
if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE");
else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT");
else oldcmd = Qnil;
- break;
- case Qundef:
- oldcmd = rb_str_new2("EXIT");
- break;
}
trap_list[sig].cmd = command;
+ trap_list[sig].safe = ruby_safe_level;
/* enable at least specified signal. */
-#ifndef _WIN32
+#if USE_TRAP_MASK
#ifdef HAVE_SIGPROCMASK
sigdelset(&arg->mask, sig);
#else
@@ -824,9 +836,10 @@ trap(struct trap_arg *arg)
return oldcmd;
}
-#ifndef _WIN32
+#if USE_TRAP_MASK
static VALUE
-trap_ensure(struct trap_arg *arg)
+trap_ensure(arg)
+ struct trap_arg *arg;
{
/* enable interrupt */
#ifdef HAVE_SIGPROCMASK
@@ -840,9 +853,9 @@ trap_ensure(struct trap_arg *arg)
#endif
void
-rb_trap_restore_mask(void)
+rb_trap_restore_mask()
{
-#ifndef _WIN32
+#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK
sigprocmask(SIG_SETMASK, &trap_last_mask, NULL);
# else
@@ -853,22 +866,19 @@ rb_trap_restore_mask(void)
/*
* call-seq:
- * Signal.trap( signal, command ) => obj
+ * Signal.trap( signal, proc ) => obj
* Signal.trap( signal ) {| | block } => obj
*
* Specifies the handling of signals. The first parameter is a signal
* name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
* signal number. The characters ``SIG'' may be omitted from the
* signal name. The command or block specifies code to be run when the
- * signal is raised.
- * If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal
- * will be ignored.
- * If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
- * will be invoked.
- * If the command is ``EXIT'', the script will be terminated by the signal.
- * If the command is ``SYSTEM_DEFAULT'', the operating system's default
- * handler will be invoked.
- * Otherwise, the given command or block will be run.
+ * signal is raised. If the command is the string ``IGNORE'' or
+ * ``SIG_IGN'', the signal will be ignored. If the command is
+ * ``DEFAULT'' or ``SIG_DFL'', the operating system's default handler
+ * will be invoked. If the command is ``EXIT'', the script will be
+ * terminated by the signal. Otherwise, the given command or block
+ * will be run.
* The special signal name ``EXIT'' or signal number zero will be
* invoked just prior to program termination.
* trap returns the previous handler for the given signal.
@@ -883,7 +893,9 @@ rb_trap_restore_mask(void)
* Terminating: 27460
*/
static VALUE
-sig_trap(int argc, VALUE *argv)
+sig_trap(argc, argv)
+ int argc;
+ VALUE *argv;
{
struct trap_arg arg;
@@ -892,20 +904,18 @@ sig_trap(int argc, VALUE *argv)
rb_raise(rb_eArgError, "wrong number of arguments -- trap(sig, cmd)/trap(sig){...}");
}
- arg.sig = trap_signm(argv[0]);
+ arg.sig = argv[0];
if (argc == 1) {
arg.cmd = rb_block_proc();
- arg.func = sighandler;
}
else if (argc == 2) {
arg.cmd = argv[1];
- arg.func = trap_handler(&arg.cmd, arg.sig);
}
if (OBJ_TAINTED(arg.cmd)) {
rb_raise(rb_eSecurityError, "Insecure: tainted signal trap");
}
-#ifndef _WIN32
+#if USE_TRAP_MASK
/* disable interrupt */
# ifdef HAVE_SIGPROCMASK
sigfillset(&arg.mask);
@@ -930,7 +940,7 @@ sig_trap(int argc, VALUE *argv)
* Signal.list #=> {"ABRT"=>6, "ALRM"=>14, "BUS"=>7, "CHLD"=>17, "CLD"=>17, "CONT"=>18, "FPE"=>8, "HUP"=>1, "ILL"=>4, "INT"=>2, "IO"=>29, "IOT"=>6, "KILL"=>9, "PIPE"=>13, "POLL"=>29, "PROF"=>27, "PWR"=>30, "QUIT"=>3, "SEGV"=>11, "STOP"=>19, "SYS"=>31, "TERM"=>15, "TRAP"=>5, "TSTP"=>20, "TTIN"=>21, "TTOU"=>22, "URG"=>23, "USR1"=>10, "USR2"=>12, "VTALRM"=>26, "WINCH"=>28, "XCPU"=>24, "XFSZ"=>25}
*/
static VALUE
-sig_list(void)
+sig_list()
{
VALUE h = rb_hash_new();
struct signals *sigs;
@@ -942,7 +952,9 @@ sig_list(void)
}
static void
-install_sighandler(int signum, sighandler_t handler)
+install_sighandler(signum, handler)
+ int signum;
+ sighandler_t handler;
{
sighandler_t old;
@@ -952,11 +964,42 @@ install_sighandler(int signum, sighandler_t handler)
}
}
+#if 0
+/*
+ * If you write a handler which works on any native thread
+ * (even if the thread is NOT a ruby's one), please enable
+ * this function and use it to install the handler, instead
+ * of `install_sighandler()'.
+ */
+#ifdef HAVE_NATIVETHREAD
+static void
+install_nativethread_sighandler(signum, handler)
+ int signum;
+ sighandler_t handler;
+{
+ sighandler_t old;
+ int old_st;
+
+ old_st = rb_trap_accept_nativethreads[signum];
+ old = ruby_nativethread_signal(signum, handler);
+ if (old != SIG_DFL) {
+ if (old_st) {
+ ruby_nativethread_signal(signum, old);
+ } else {
+ ruby_signal(signum, old);
+ }
+ }
+}
+#endif
+#endif
+
+#if defined(SIGCLD) || defined(SIGCHLD)
static void
-init_sigchld(int sig)
+init_sigchld(sig)
+ int sig;
{
sighandler_t oldfunc;
-#ifndef _WIN32
+#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK
sigset_t mask;
# else
@@ -964,7 +1007,7 @@ init_sigchld(int sig)
# endif
#endif
-#ifndef _WIN32
+#if USE_TRAP_MASK
/* disable interrupt */
# ifdef HAVE_SIGPROCMASK
sigfillset(&mask);
@@ -981,7 +1024,7 @@ init_sigchld(int sig)
trap_list[sig].cmd = 0;
}
-#ifndef _WIN32
+#if USE_TRAP_MASK
#ifdef HAVE_SIGPROCMASK
sigdelset(&mask, sig);
sigprocmask(SIG_SETMASK, &mask, NULL);
@@ -992,21 +1035,6 @@ init_sigchld(int sig)
trap_last_mask = mask;
#endif
}
-
-void
-ruby_sig_finalize()
-{
- sighandler_t oldfunc;
-
- oldfunc = ruby_signal(SIGINT, SIG_IGN);
- if (oldfunc == sighandler) {
- ruby_signal(SIGINT, SIG_DFL);
- }
-}
-
-
-#ifdef RUBY_DEBUG_ENV
-int ruby_enable_coredump = 0;
#endif
/*
@@ -1047,7 +1075,7 @@ int ruby_enable_coredump = 0;
* systems; in particular signal delivery may not always be reliable.
*/
void
-Init_signal(void)
+Init_signal()
{
#ifndef MACOS_UNUSE_SIGNAL
VALUE mSignal = rb_define_module("Signal");
@@ -1081,17 +1109,12 @@ Init_signal(void)
install_sighandler(SIGUSR2, sighandler);
#endif
-#ifdef RUBY_DEBUG_ENV
- if (!ruby_enable_coredump)
-#endif
- {
#ifdef SIGBUS
install_sighandler(SIGBUS, sigbus);
#endif
#ifdef SIGSEGV
install_sighandler(SIGSEGV, sigsegv);
#endif
- }
#ifdef SIGPIPE
install_sighandler(SIGPIPE, sigpipe);
#endif
diff --git a/sprintf.c b/sprintf.c
index 48aae1de34..d39352b922 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -6,26 +6,27 @@
$Date$
created at: Fri Oct 15 10:39:26 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/re.h"
-#include "ruby/encoding.h"
+#include "ruby.h"
+#include "re.h"
+#include <ctype.h>
#include <math.h>
-#include <stdarg.h>
#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
#define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT)
#define EXTENDSIGN(n, l) (((~0 << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0 << (n)))
-static void fmt_setup(char*,int,int,int,int);
+static void fmt_setup _((char*,int,int,int,int));
static char*
-remove_sign_bits(char *str, int base)
+remove_sign_bits(str, base)
+ char *str;
+ int base;
{
char *s, *t;
@@ -56,7 +57,9 @@ remove_sign_bits(char *str, int base)
}
static char
-sign_bits(int base, const char *p)
+sign_bits(base, p)
+ int base;
+ const char *p;
{
char c = '.';
@@ -88,7 +91,7 @@ sign_bits(int base, const char *p)
bsiz*=2;\
}\
rb_str_resize(result, bsiz);\
- buf = RSTRING_PTR(result);\
+ buf = RSTRING(result)->ptr;\
} while (0)
#define PUSH(s, l) do { \
@@ -97,12 +100,6 @@ sign_bits(int base, const char *p)
blen += (l);\
} while (0)
-#define FILL(c, l) do { \
- CHECK(l);\
- memset(&buf[blen], c, l);\
- blen += (l);\
-} while (0)
-
#define GETARG() (nextvalue != Qundef ? nextvalue : \
posarg < 0 ? \
(rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
@@ -117,7 +114,7 @@ sign_bits(int base, const char *p)
((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[nth])
#define GETNUM(n, val) \
- for (; p < end && rb_enc_isdigit(*p, enc); p++) { \
+ for (; p < end && ISDIGIT(*p); p++) { \
int next_n = 10 * n + (*p - '0'); \
if (next_n / 10 != n) {\
rb_raise(rb_eArgError, #val " too big"); \
@@ -248,15 +245,19 @@ sign_bits(int base, const char *p)
*/
VALUE
-rb_f_sprintf(int argc, const VALUE *argv)
+rb_f_sprintf(argc, argv)
+ int argc;
+ VALUE *argv;
{
return rb_str_format(argc - 1, argv + 1, GETNTHARG(0));
}
VALUE
-rb_str_format(int argc, const VALUE *argv, VALUE fmt)
+rb_str_format(argc, argv, fmt)
+ int argc;
+ VALUE *argv;
+ VALUE fmt;
{
- rb_encoding *enc;
const char *p, *end;
char *buf;
int blen, bsiz;
@@ -289,16 +290,13 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
--argv;
if (OBJ_TAINTED(fmt)) tainted = 1;
StringValue(fmt);
- enc = rb_enc_get(fmt);
fmt = rb_str_new4(fmt);
- p = RSTRING_PTR(fmt);
- end = p + RSTRING_LEN(fmt);
+ p = RSTRING(fmt)->ptr;
+ end = p + RSTRING(fmt)->len;
blen = 0;
bsiz = 120;
result = rb_str_buf_new(bsiz);
- rb_enc_copy(result, fmt);
- buf = RSTRING_PTR(result);
- memset(buf, 0, bsiz);
+ buf = RSTRING(result)->ptr;
for (; p < end; p++) {
const char *t;
@@ -317,7 +315,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
retry:
switch (*p) {
default:
- if (rb_enc_isprint(*p, enc))
+ if (ISPRINT(*p))
rb_raise(rb_eArgError, "malformed format string - %%%c", *p);
else
rb_raise(rb_eArgError, "malformed format string");
@@ -406,7 +404,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
p--;
case '%':
if (flags != FNONE) {
- rb_raise(rb_eArgError, "invalid format character - %%");
+ rb_raise(rb_eArgError, "illegal format character - %%");
}
PUSH("%", 1);
break;
@@ -414,40 +412,15 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
case 'c':
{
VALUE val = GETARG();
- VALUE tmp;
- int c, n;
-
- tmp = rb_check_string_type(val);
- if (!NIL_P(tmp)) {
- if (rb_enc_strlen(RSTRING_PTR(tmp),RSTRING_END(tmp),enc) != 1) {
- rb_raise(rb_eArgError, "%%c requires a character");
- }
- c = rb_enc_codepoint(RSTRING_PTR(tmp), RSTRING_END(tmp), enc);
- }
- else {
- c = NUM2INT(val);
- }
- n = rb_enc_codelen(c, enc);
- if (n == 0) {
- rb_raise(rb_eArgError, "invalid character");
- }
- if (!(flags & FWIDTH)) {
- CHECK(n);
- rb_enc_mbcput(c, &buf[blen], enc);
- blen += n;
- }
- else if ((flags & FMINUS)) {
- CHECK(n);
- rb_enc_mbcput(c, &buf[blen], enc);
- blen += n;
- FILL(' ', width-1);
- }
- else {
- FILL(' ', width-1);
- CHECK(n);
- rb_enc_mbcput(c, &buf[blen], enc);
- blen += n;
- }
+ char c;
+
+ if (!(flags & FMINUS))
+ while (--width > 0)
+ PUSH(" ", 1);
+ c = NUM2INT(val) & 0xff;
+ PUSH(&c, 1);
+ while (--width > 0)
+ PUSH(" ", 1);
}
break;
@@ -455,42 +428,30 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
case 'p':
{
VALUE arg = GETARG();
- long len, slen;
+ long len;
if (*p == 'p') arg = rb_inspect(arg);
str = rb_obj_as_string(arg);
if (OBJ_TAINTED(str)) tainted = 1;
- len = RSTRING_LEN(str);
- enc = rb_enc_check(result, str);
- if (flags&(FPREC|FWIDTH)) {
- slen = rb_enc_strlen(RSTRING_PTR(str),RSTRING_END(str),enc);
- if (slen < 0) {
- rb_raise(rb_eArgError, "invalid mbstring sequence");
- }
- }
+ len = RSTRING(str)->len;
if (flags&FPREC) {
- if (prec < slen) {
- char *p = rb_enc_nth(RSTRING_PTR(str), RSTRING_END(str),
- prec, enc);
- slen = prec;
- len = p - RSTRING_PTR(str);
+ if (prec < len) {
+ len = prec;
}
}
/* need to adjust multi-byte string pos */
if (flags&FWIDTH) {
- if (width > slen) {
- width -= slen;
+ if (width > len) {
+ CHECK(width);
+ width -= len;
if (!(flags&FMINUS)) {
- CHECK(width);
while (width--) {
buf[blen++] = ' ';
}
}
- CHECK(len);
memcpy(&buf[blen], RSTRING_PTR(str), len);
blen += len;
if (flags&FMINUS) {
- CHECK(width);
while (width--) {
buf[blen++] = ' ';
}
@@ -498,8 +459,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
break;
}
}
- PUSH(RSTRING_PTR(str), len);
- rb_enc_associate(result, enc);
+ PUSH(RSTRING(str)->ptr, len);
}
break;
@@ -520,17 +480,20 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
long v = 0;
int base, bignum = 0;
int len, pos;
+ volatile VALUE tmp;
+ volatile VALUE tmp1;
switch (*p) {
case 'd':
case 'i':
- case 'u':
sign = 1; break;
case 'o':
case 'x':
case 'X':
case 'b':
case 'B':
+ case 'u':
+ default:
if (flags&(FPLUS|FSPACE)) sign = 1;
break;
}
@@ -555,11 +518,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
bin_retry:
switch (TYPE(val)) {
case T_FLOAT:
- if (FIXABLE((long)RFLOAT_VALUE(val))) {
- val = LONG2FIX((long)RFLOAT_VALUE(val));
- goto bin_retry;
- }
- val = rb_dbl2big(RFLOAT_VALUE(val));
+ val = rb_dbl2big(RFLOAT(val)->value);
if (FIXNUM_P(val)) goto bin_retry;
bignum = 1;
break;
@@ -616,92 +575,96 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
}
sprintf(fbuf, "%%l%c", c);
sprintf(nbuf, fbuf, v);
- }
- else {
s = nbuf;
- if (v < 0) {
+ goto format_integer;
+ }
+ s = nbuf;
+ if (v < 0) {
+ if (base == 10) {
+ rb_warning("negative number for %%u specifier");
+ }
+ if (!(flags&(FPREC|FZERO))) {
strcpy(s, "..");
s += 2;
}
- sprintf(fbuf, "%%l%c", *p == 'X' ? 'x' : *p);
- sprintf(s, fbuf, v);
- if (v < 0) {
- char d = 0;
-
- remove_sign_bits(s, base);
- switch (base) {
- case 16:
- d = 'f'; break;
- case 8:
- d = '7'; break;
- }
- if (d && *s != d) {
- memmove(s+1, s, strlen(s)+1);
- *s = d;
- }
+ }
+ sprintf(fbuf, "%%l%c", *p == 'X' ? 'x' : *p);
+ sprintf(s, fbuf, v);
+ if (v < 0) {
+ char d = 0;
+
+ remove_sign_bits(s, base);
+ switch (base) {
+ case 16:
+ d = 'f'; break;
+ case 8:
+ d = '7'; break;
+ }
+ if (d && *s != d) {
+ memmove(s+1, s, strlen(s)+1);
+ *s = d;
}
}
s = nbuf;
+ goto format_integer;
}
- else {
- if (sign) {
- tmp = rb_big2str(val, base);
- s = RSTRING_PTR(tmp);
- if (s[0] == '-') {
- s++;
- sc = '-';
- width--;
- }
- else if (flags & FPLUS) {
- sc = '+';
- width--;
- }
- else if (flags & FSPACE) {
- sc = ' ';
- width--;
- }
+
+ if (sign) {
+ tmp = rb_big2str(val, base);
+ s = RSTRING(tmp)->ptr;
+ if (s[0] == '-') {
+ s++;
+ sc = '-';
+ width--;
}
- else {
- volatile VALUE tmp1;
- if (!RBIGNUM_SIGN(val)) {
- val = rb_big_clone(val);
- rb_big_2comp(val);
- }
- tmp1 = tmp = rb_big2str0(val, base, RBIGNUM_SIGN(val));
- s = RSTRING_PTR(tmp);
- if (*s == '-') {
- if (base == 10) {
- rb_warning("negative number for %%u specifier");
- }
- remove_sign_bits(++s, base);
- tmp = rb_str_new(0, 3+strlen(s));
- t = RSTRING_PTR(tmp);
- if (!(flags&(FPREC|FZERO))) {
- strcpy(t, "..");
- t += 2;
- }
- switch (base) {
- case 16:
- if (s[0] != 'f') strcpy(t++, "f"); break;
- case 8:
- if (s[0] != '7') strcpy(t++, "7"); break;
- case 2:
- if (s[0] != '1') strcpy(t++, "1"); break;
- }
- strcpy(t, s);
- s = RSTRING_PTR(tmp);
- }
+ else if (flags & FPLUS) {
+ sc = '+';
+ width--;
}
+ else if (flags & FSPACE) {
+ sc = ' ';
+ width--;
+ }
+ goto format_integer;
+ }
+ if (!RBIGNUM(val)->sign) {
+ val = rb_big_clone(val);
+ rb_big_2comp(val);
+ }
+ tmp1 = tmp = rb_big2str0(val, base, RBIGNUM(val)->sign);
+ s = RSTRING(tmp)->ptr;
+ if (*s == '-') {
+ if (base == 10) {
+ rb_warning("negative number for %%u specifier");
+ }
+ remove_sign_bits(++s, base);
+ tmp = rb_str_new(0, 3+strlen(s));
+ t = RSTRING(tmp)->ptr;
+ if (!(flags&(FPREC|FZERO))) {
+ strcpy(t, "..");
+ t += 2;
+ }
+ switch (base) {
+ case 16:
+ if (s[0] != 'f') strcpy(t++, "f"); break;
+ case 8:
+ if (s[0] != '7') strcpy(t++, "7"); break;
+ case 2:
+ if (s[0] != '1') strcpy(t++, "1"); break;
+ }
+ strcpy(t, s);
+ bignum = 2;
}
+ s = RSTRING(tmp)->ptr;
+ format_integer:
pos = -1;
len = strlen(s);
if (*p == 'X') {
char *pp = s;
- int c;
- while ((c = (int)(unsigned char)*pp) != 0) {
- *pp = rb_enc_toupper(c, enc);
+ while (*pp) {
+ *pp = toupper(*pp);
pp++;
}
}
@@ -734,7 +697,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
else {
char c;
- if (!sign && bignum && !RBIGNUM_SIGN(val))
+ if (!sign && bignum && !RBIGNUM(val)->sign)
c = sign_bits(base, p);
else
c = '0';
@@ -761,7 +724,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
int i, need = 6;
char fbuf[32];
- fval = RFLOAT_VALUE(rb_Float(val));
+ fval = RFLOAT(rb_Float(val))->value;
+#if defined(_WIN32) && !defined(__BORLANDC__)
if (isnan(fval) || isinf(fval)) {
const char *expr;
@@ -774,6 +738,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
need = strlen(expr);
if ((!isnan(fval) && fval < 0.0) || (flags & FPLUS))
need++;
+ else if (flags & FSPACE)
+ need++;
if ((flags & FWIDTH) && need < width)
need = width;
@@ -817,7 +783,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
blen += strlen(&buf[blen]);
break;
}
-
+#endif /* defined(_WIN32) && !defined(__BORLANDC__) */
fmt_setup(fbuf, *p, flags, width, prec);
need = 0;
if (*p != 'e' && *p != 'E') {
@@ -855,7 +821,10 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
}
static void
-fmt_setup(char *buf, int c, int flags, int width, int prec)
+fmt_setup(buf, c, flags, width, prec)
+ char *buf;
+ int c;
+ int flags, width, prec;
{
*buf++ = '%';
if (flags & FSHARP) *buf++ = '#';
@@ -877,83 +846,3 @@ fmt_setup(char *buf, int c, int flags, int width, int prec)
*buf++ = c;
*buf = '\0';
}
-
-#undef FILE
-#define FILE rb_printf_buffer
-#define __sbuf rb_printf_sbuf
-#define __sFILE rb_printf_sfile
-#undef feof
-#undef ferror
-#undef clearerr
-#undef fileno
-#if SIZEOF_LONG < SIZEOF_VOIDP
-# if SIZEOF_LONG_LONG == SIZEOF_VOIDP
-# define _HAVE_SANE_QUAD_
-# define _HAVE_LLP64_
-# define quad_t LONG_LONG
-# define u_quad_t unsigned LONG_LONG
-# endif
-#endif
-#undef vsnprintf
-#undef snprintf
-#include "missing/vsnprintf.c"
-
-static int
-ruby__sfvwrite(register rb_printf_buffer *fp, register struct __suio *uio)
-{
- struct __siov *iov;
- VALUE result = (VALUE)fp->_bf._base;
- char *buf = (char*)fp->_p;
- size_t len, n;
- int blen = buf - RSTRING_PTR(result), bsiz = fp->_w;
-
- if (RBASIC(result)->klass) {
- rb_raise(rb_eRuntimeError, "rb_vsprintf reentered");
- }
- if ((len = uio->uio_resid) == 0)
- return 0;
- CHECK(len);
- buf += blen;
- fp->_w = bsiz;
- for (iov = uio->uio_iov; len > 0; ++iov) {
- MEMCPY(buf, iov->iov_base, char, n = iov->iov_len);
- buf += n;
- len -= n;
- }
- fp->_p = (unsigned char *)buf;
- return 0;
-}
-
-VALUE
-rb_vsprintf(const char *fmt, va_list ap)
-{
- rb_printf_buffer f;
- VALUE result;
-
- f._flags = __SWR | __SSTR;
- f._bf._size = 0;
- f._w = 120;
- result = rb_str_buf_new(f._w);
- f._bf._base = (unsigned char *)result;
- f._p = (unsigned char *)RSTRING_PTR(result);
- RBASIC(result)->klass = 0;
- f.vwrite = ruby__sfvwrite;
- BSD_vfprintf(&f, fmt, ap);
- RBASIC(result)->klass = rb_cString;
- rb_str_resize(result, (char *)f._p - RSTRING_PTR(result));
-
- return result;
-}
-
-VALUE
-rb_sprintf(const char *format, ...)
-{
- VALUE result;
- va_list ap;
-
- va_start(ap, format);
- result = rb_vsprintf(format, ap);
- va_end(ap);
-
- return result;
-}
diff --git a/st.c b/st.c
index a0e669294b..c16c3109a8 100644
--- a/st.c
+++ b/st.c
@@ -2,20 +2,14 @@
/* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */
-#ifdef NOT_RUBY
-#include "regint.h"
-#include "st.h"
-#else
-#include "ruby/config.h"
-#include "ruby/defines.h"
-#include "ruby/st.h"
-#endif
-
+#include "config.h"
+#include "defines.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <string.h>
+#include "st.h"
typedef struct st_table_entry st_table_entry;
@@ -24,7 +18,6 @@ struct st_table_entry {
st_data_t key;
st_data_t record;
st_table_entry *next;
- st_table_entry *fore, *back;
};
#define ST_DEFAULT_MAX_DENSITY 5
@@ -39,25 +32,20 @@ struct st_table_entry {
* allocated initially
*
*/
-
-static const struct st_hash_type type_numhash = {
- st_numcmp,
- st_numhash,
+static int numcmp(long, long);
+static int numhash(long);
+static struct st_hash_type type_numhash = {
+ numcmp,
+ numhash,
};
/* extern int strcmp(const char *, const char *); */
static int strhash(const char *);
-static const struct st_hash_type type_strhash = {
+static struct st_hash_type type_strhash = {
strcmp,
strhash,
};
-static int strcasehash(const char *);
-static const struct st_hash_type type_strcasehash = {
- strcasecmp,
- strcasehash,
-};
-
static void rehash(st_table *);
#ifdef RUBY
@@ -65,7 +53,7 @@ static void rehash(st_table *);
#define calloc xcalloc
#endif
-#define alloc(type) (type*)malloc((size_t)sizeof(type))
+#define alloc(type) (type*)malloc((unsigned)sizeof(type))
#define Calloc(n,s) (char*)calloc((n),(s))
#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
@@ -115,7 +103,8 @@ static long primes[] = {
};
static int
-new_size(int size)
+new_size(size)
+ int size;
{
int i;
@@ -128,7 +117,7 @@ new_size(int size)
int newsize;
for (i = 0, newsize = MINSIZE;
- i < (int )(sizeof(primes)/sizeof(primes[0]));
+ i < sizeof(primes)/sizeof(primes[0]);
i++, newsize <<= 1)
{
if (newsize > size) return primes[i];
@@ -151,10 +140,10 @@ stat_col()
}
#endif
-#define MAX_PACKED_NUMHASH 5
-
st_table*
-st_init_table_with_size(const struct st_hash_type *type, int size)
+st_init_table_with_size(type, size)
+ struct st_hash_type *type;
+ int size;
{
st_table *tbl;
@@ -170,16 +159,15 @@ st_init_table_with_size(const struct st_hash_type *type, int size)
tbl = alloc(st_table);
tbl->type = type;
tbl->num_entries = 0;
- tbl->entries_packed = type == &type_numhash && size/2 <= MAX_PACKED_NUMHASH;
tbl->num_bins = size;
tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*));
- tbl->head = 0;
return tbl;
}
st_table*
-st_init_table(const struct st_hash_type *type)
+st_init_table(type)
+ struct st_hash_type *type;
{
return st_init_table_with_size(type, 0);
}
@@ -191,7 +179,8 @@ st_init_numtable(void)
}
st_table*
-st_init_numtable_with_size(int size)
+st_init_numtable_with_size(size)
+ int size;
{
return st_init_table_with_size(&type_numhash, size);
}
@@ -203,51 +192,27 @@ st_init_strtable(void)
}
st_table*
-st_init_strtable_with_size(int size)
+st_init_strtable_with_size(size)
+ int size;
{
return st_init_table_with_size(&type_strhash, size);
}
-st_table*
-st_init_strcasetable(void)
-{
- return st_init_table(&type_strcasehash);
-}
-
-st_table*
-st_init_strcasetable_with_size(int size)
-{
- return st_init_table_with_size(&type_strcasehash, size);
-}
-
void
-st_clear(st_table *table)
+st_free_table(table)
+ st_table *table;
{
register st_table_entry *ptr, *next;
int i;
- if (table->entries_packed) {
- table->num_entries = 0;
- return;
- }
-
for(i = 0; i < table->num_bins; i++) {
ptr = table->bins[i];
- table->bins[i] = 0;
while (ptr != 0) {
next = ptr->next;
free(ptr);
ptr = next;
}
}
- table->num_entries = 0;
- table->head = 0;
-}
-
-void
-st_free_table(st_table *table)
-{
- st_clear(table);
free(table->bins);
free(table);
}
@@ -274,22 +239,14 @@ st_free_table(st_table *table)
} while (0)
int
-st_lookup(st_table *table, register st_data_t key, st_data_t *value)
+st_lookup(table, key, value)
+ st_table *table;
+ register st_data_t key;
+ st_data_t *value;
{
unsigned int hash_val, bin_pos;
register st_table_entry *ptr;
- if (table->entries_packed) {
- int i;
- for (i = 0; i < table->num_entries; i++) {
- if ((st_data_t)table->bins[i*2] == key) {
- if (value !=0) *value = (st_data_t)table->bins[i*2+1];
- return 1;
- }
- }
- return 0;
- }
-
hash_val = do_hash(key, table);
FIND_ENTRY(table, ptr, hash_val, bin_pos);
@@ -302,38 +259,9 @@ st_lookup(st_table *table, register st_data_t key, st_data_t *value)
}
}
-int
-st_get_key(st_table *table, register st_data_t key, st_data_t *result)
-{
- unsigned int hash_val, bin_pos;
- register st_table_entry *ptr;
-
- if (table->entries_packed) {
- int i;
- for (i = 0; i < table->num_entries; i++) {
- if ((st_data_t)table->bins[i*2] == key) {
- if (result !=0) *result = (st_data_t)table->bins[i*2];
- return 1;
- }
- }
- return 0;
- }
-
- hash_val = do_hash(key, table);
- FIND_ENTRY(table, ptr, hash_val, bin_pos);
-
- if (ptr == 0) {
- return 0;
- }
- else {
- if (result != 0) *result = ptr->key;
- return 1;
- }
-}
-
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
do {\
- st_table_entry *entry, *head;\
+ st_table_entry *entry;\
if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) {\
rehash(table);\
bin_pos = hash_val % table->num_bins;\
@@ -345,59 +273,19 @@ do {\
entry->key = key;\
entry->record = value;\
entry->next = table->bins[bin_pos];\
- if ((head = table->head) != 0) {\
- entry->fore = head;\
- (entry->back = head->back)->fore = entry;\
- head->back = entry;\
- }\
- else {\
- table->head = entry->fore = entry->back = entry;\
- }\
table->bins[bin_pos] = entry;\
table->num_entries++;\
} while (0)
-static void
-unpack_entries(register st_table *table)
-{
- int i;
- struct st_table_entry *packed_bins[MAX_PACKED_NUMHASH*2];
- int num_entries = table->num_entries;
-
- memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * num_entries*2);
- table->entries_packed = 0;
- table->num_entries = 0;
- memset(table->bins, 0, sizeof(struct st_table_entry *) * table->num_bins);
- for (i = 0; i < num_entries; i++) {
- st_insert(table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]);
- }
-}
-
int
-st_insert(register st_table *table, register st_data_t key, st_data_t value)
+st_insert(table, key, value)
+ register st_table *table;
+ register st_data_t key;
+ st_data_t value;
{
unsigned int hash_val, bin_pos;
register st_table_entry *ptr;
- if (table->entries_packed) {
- int i;
- for (i = 0; i < table->num_entries; i++) {
- if ((st_data_t)table->bins[i*2] == key) {
- table->bins[i*2+1] = (struct st_table_entry*)value;
- return 1;
- }
- }
- if ((table->num_entries+1) * 2 <= table->num_bins && table->num_entries+1 <= MAX_PACKED_NUMHASH) {
- i = table->num_entries++;
- table->bins[i*2] = (struct st_table_entry*)key;
- table->bins[i*2+1] = (struct st_table_entry*)value;
- return 0;
- }
- else {
- unpack_entries(table);
- }
- }
-
hash_val = do_hash(key, table);
FIND_ENTRY(table, ptr, hash_val, bin_pos);
@@ -412,58 +300,51 @@ st_insert(register st_table *table, register st_data_t key, st_data_t value)
}
void
-st_add_direct(st_table *table, st_data_t key, st_data_t value)
+st_add_direct(table, key, value)
+ st_table *table;
+ st_data_t key;
+ st_data_t value;
{
unsigned int hash_val, bin_pos;
- if (table->entries_packed) {
- int i;
- if ((table->num_entries+1) * 2 <= table->num_bins && table->num_entries+1 <= MAX_PACKED_NUMHASH) {
- i = table->num_entries++;
- table->bins[i*2] = (struct st_table_entry*)key;
- table->bins[i*2+1] = (struct st_table_entry*)value;
- return;
- }
- else {
- unpack_entries(table);
- }
- }
-
hash_val = do_hash(key, table);
bin_pos = hash_val % table->num_bins;
ADD_DIRECT(table, key, value, hash_val, bin_pos);
}
static void
-rehash(register st_table *table)
+rehash(table)
+ register st_table *table;
{
- register st_table_entry *ptr, **new_bins;
- int i, new_num_bins;
+ register st_table_entry *ptr, *next, **new_bins;
+ int i, old_num_bins = table->num_bins, new_num_bins;
unsigned int hash_val;
- new_num_bins = new_size(table->num_bins+1);
- new_bins = (st_table_entry**)
- xrealloc(table->bins, new_num_bins * sizeof(st_table_entry*));
- for (i = 0; i < new_num_bins; ++i) new_bins[i] = 0;
- table->num_bins = new_num_bins;
- table->bins = new_bins;
+ new_num_bins = new_size(old_num_bins+1);
+ new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*));
- if ((ptr = table->head) != 0) {
- do {
+ for(i = 0; i < old_num_bins; i++) {
+ ptr = table->bins[i];
+ while (ptr != 0) {
+ next = ptr->next;
hash_val = ptr->hash % new_num_bins;
ptr->next = new_bins[hash_val];
new_bins[hash_val] = ptr;
- } while ((ptr = ptr->fore) != table->head);
+ ptr = next;
+ }
}
+ free(table->bins);
+ table->num_bins = new_num_bins;
+ table->bins = new_bins;
}
st_table*
-st_copy(st_table *old_table)
+st_copy(old_table)
+ st_table *old_table;
{
st_table *new_table;
- st_table_entry *ptr, *entry, *prev, **tail;
- int num_bins = old_table->num_bins;
- unsigned int hash_val;
+ st_table_entry *ptr, *entry;
+ int i, num_bins = old_table->num_bins;
new_table = alloc(st_table);
if (new_table == 0) {
@@ -479,91 +360,73 @@ st_copy(st_table *old_table)
return 0;
}
- if (old_table->entries_packed) {
- memcpy(new_table->bins, old_table->bins, sizeof(struct st_table_entry *) * old_table->num_bins);
- return new_table;
- }
-
- if ((ptr = old_table->head) != 0) {
- prev = 0;
- tail = &new_table->head;
- do {
+ for(i = 0; i < num_bins; i++) {
+ new_table->bins[i] = 0;
+ ptr = old_table->bins[i];
+ while (ptr != 0) {
entry = alloc(st_table_entry);
if (entry == 0) {
- st_free_table(new_table);
+ free(new_table->bins);
+ free(new_table);
return 0;
}
*entry = *ptr;
- hash_val = entry->hash % num_bins;
- entry->next = new_table->bins[hash_val];
- new_table->bins[hash_val] = entry;
- entry->back = prev;
- *tail = prev = entry;
- tail = &entry->fore;
- } while ((ptr = ptr->fore) != old_table->head);
- entry = new_table->head;
- entry->back = prev;
- *tail = entry;
+ entry->next = new_table->bins[i];
+ new_table->bins[i] = entry;
+ ptr = ptr->next;
+ }
}
-
return new_table;
}
-#define REMOVE_ENTRY(table, ptr) do \
- { \
- if (ptr == ptr->fore) { \
- table->head = 0; \
- } \
- else { \
- st_table_entry *fore = ptr->fore, *back = ptr->back; \
- fore->back = back; \
- back->fore = fore; \
- if (ptr == table->head) table->head = fore; \
- } \
- table->num_entries--; \
- } while (0)
-
int
-st_delete(register st_table *table, register st_data_t *key, st_data_t *value)
+st_delete(table, key, value)
+ register st_table *table;
+ register st_data_t *key;
+ st_data_t *value;
{
unsigned int hash_val;
- st_table_entry **prev;
+ st_table_entry *tmp;
register st_table_entry *ptr;
- if (table->entries_packed) {
- int i;
- for (i = 0; i < table->num_entries; i++) {
- if ((st_data_t)table->bins[i*2] == *key) {
- if (value != 0) *value = (st_data_t)table->bins[i*2+1];
- table->num_entries--;
- memmove(&table->bins[i*2], &table->bins[(i+1)*2],
- sizeof(struct st_table_entry*) * 2*(table->num_entries-i));
- return 1;
- }
- }
- if (value != 0) *value = 0;
- return 0;
+ hash_val = do_hash_bin(*key, table);
+ ptr = table->bins[hash_val];
+
+ if (ptr == 0) {
+ if (value != 0) *value = 0;
+ return 0;
}
- hash_val = do_hash_bin(*key, table);
+ if (EQUAL(table, *key, ptr->key)) {
+ table->bins[hash_val] = ptr->next;
+ table->num_entries--;
+ if (value != 0) *value = ptr->record;
+ *key = ptr->key;
+ free(ptr);
+ return 1;
+ }
- for (prev = &table->bins[hash_val]; (ptr = *prev) != 0; prev = &ptr->next) {
- if (EQUAL(table, *key, ptr->key)) {
- *prev = ptr->next;
- REMOVE_ENTRY(table, ptr);
- if (value != 0) *value = ptr->record;
- *key = ptr->key;
- free(ptr);
+ for(; ptr->next != 0; ptr = ptr->next) {
+ if (EQUAL(table, ptr->next->key, *key)) {
+ tmp = ptr->next;
+ ptr->next = ptr->next->next;
+ table->num_entries--;
+ if (value != 0) *value = tmp->record;
+ *key = tmp->key;
+ free(tmp);
return 1;
}
}
- if (value != 0) *value = 0;
return 0;
}
int
-st_delete_safe(register st_table *table, register st_data_t *key, st_data_t *value, st_data_t never)
+st_delete_safe(table, key, value, never)
+ register st_table *table;
+ register st_data_t *key;
+ st_data_t *value;
+ st_data_t never;
{
unsigned int hash_val;
register st_table_entry *ptr;
@@ -571,9 +434,14 @@ st_delete_safe(register st_table *table, register st_data_t *key, st_data_t *val
hash_val = do_hash_bin(*key, table);
ptr = table->bins[hash_val];
- for (; ptr != 0; ptr = ptr->next) {
+ if (ptr == 0) {
+ if (value != 0) *value = 0;
+ return 0;
+ }
+
+ for(; ptr != 0; ptr = ptr->next) {
if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) {
- REMOVE_ENTRY(table, ptr);
+ table->num_entries--;
*key = ptr->key;
if (value != 0) *value = ptr->record;
ptr->key = ptr->record = never;
@@ -581,313 +449,127 @@ st_delete_safe(register st_table *table, register st_data_t *key, st_data_t *val
}
}
- if (value != 0) *value = 0;
return 0;
}
+static int
+delete_never(key, value, never)
+ st_data_t key, value, never;
+{
+ if (value == never) return ST_DELETE;
+ return ST_CONTINUE;
+}
+
void
-st_cleanup_safe(st_table *table, st_data_t never)
+st_cleanup_safe(table, never)
+ st_table *table;
+ st_data_t never;
{
- st_table_entry *ptr, **last, *tmp;
- int i;
+ int num_entries = table->num_entries;
- for (i = 0; i < table->num_bins; i++) {
- ptr = *(last = &table->bins[i]);
- while (ptr != 0) {
- if (ptr->key == never) {
- tmp = ptr;
- *last = ptr = ptr->next;
- free(tmp);
- }
- else {
- ptr = *(last = &ptr->next);
- }
- }
- }
+ st_foreach(table, delete_never, never);
+ table->num_entries = num_entries;
}
int
-st_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)
+st_foreach(table, func, arg)
+ st_table *table;
+ int (*func)();
+ st_data_t arg;
{
- st_table_entry *ptr, **last, *tmp;
+ st_table_entry *ptr, *last, *tmp;
enum st_retval retval;
- int i, end;
-
- if (table->entries_packed) {
- for (i = 0; i < table->num_entries; i++) {
- int j;
- st_data_t key, val;
- key = (st_data_t)table->bins[i*2];
- val = (st_data_t)table->bins[i*2+1];
- retval = (*func)(key, val, arg);
- switch (retval) {
- case ST_CHECK: /* check if hash is modified during iteration */
- for (j = 0; j < table->num_entries; j++) {
- if ((st_data_t)table->bins[j*2] == key)
- break;
- }
- if (j == table->num_entries) {
- /* call func with error notice */
- retval = (*func)(0, 0, arg, 1);
- return 1;
- }
- /* fall through */
- case ST_CONTINUE:
- break;
- case ST_STOP:
- return 0;
- case ST_DELETE:
- table->num_entries--;
- memmove(&table->bins[i*2], &table->bins[(i+1)*2],
- sizeof(struct st_table_entry*) * 2*(table->num_entries-i));
- i--;
- break;
- }
- }
- return 0;
- }
+ int i;
- if ((ptr = table->head) != 0) {
- do {
- end = ptr->fore == table->head;
+ for(i = 0; i < table->num_bins; i++) {
+ last = 0;
+ for(ptr = table->bins[i]; ptr != 0;) {
retval = (*func)(ptr->key, ptr->record, arg);
switch (retval) {
- case ST_CHECK: /* check if hash is modified during iteration */
- i = ptr->hash % table->num_bins;
- for (tmp = table->bins[i]; tmp != ptr; tmp = tmp->next) {
- if (!tmp) {
- /* call func with error notice */
- retval = (*func)(0, 0, arg, 1);
- return 1;
+ case ST_CHECK: /* check if hash is modified during iteration */
+ tmp = 0;
+ if (i < table->num_bins) {
+ for (tmp = table->bins[i]; tmp; tmp=tmp->next) {
+ if (tmp == ptr) break;
}
}
- /* fall through */
- case ST_CONTINUE:
- ptr = ptr->fore;
- break;
- case ST_STOP:
- return 0;
- case ST_DELETE:
- last = &table->bins[ptr->hash % table->num_bins];
- for (; (tmp = *last) != 0; last = &tmp->next) {
- if (ptr == tmp) {
- tmp = ptr->fore;
- *last = ptr->next;
- REMOVE_ENTRY(table, ptr);
- free(ptr);
- if (ptr == tmp) return 0;
- ptr = tmp;
- break;
- }
+ if (!tmp) {
+ /* call func with error notice */
+ return 1;
}
- }
- } while (!end && table->head);
- }
- return 0;
-}
-
-int
-st_reverse_foreach(st_table *table, int (*func)(ANYARGS), st_data_t arg)
-{
- st_table_entry *ptr, **last, *tmp;
- enum st_retval retval;
- int i, end;
-
- if (table->entries_packed) {
- for (i = table->num_entries-1; 0 <= i; i--) {
- int j;
- st_data_t key, val;
- key = (st_data_t)table->bins[i*2];
- val = (st_data_t)table->bins[i*2+1];
- retval = (*func)(key, val, arg);
- switch (retval) {
- case ST_CHECK: /* check if hash is modified during iteration */
- for (j = 0; j < table->num_entries; j++) {
- if ((st_data_t)table->bins[j*2] == key)
- break;
- }
- if (j == table->num_entries) {
- /* call func with error notice */
- retval = (*func)(0, 0, arg, 1);
- return 1;
- }
/* fall through */
- case ST_CONTINUE:
+ case ST_CONTINUE:
+ last = ptr;
+ ptr = ptr->next;
break;
- case ST_STOP:
- return 0;
- case ST_DELETE:
- table->num_entries--;
- memmove(&table->bins[i*2], &table->bins[(i+1)*2],
- sizeof(struct st_table_entry*) * 2*(table->num_entries-i));
- break;
- }
- }
- return 0;
- }
-
- if ((ptr = table->head) != 0) {
- ptr = ptr->back;
- do {
- end = ptr == table->head;
- retval = (*func)(ptr->key, ptr->record, arg, 0);
- switch (retval) {
- case ST_CHECK: /* check if hash is modified during iteration */
- i = ptr->hash % table->num_bins;
- for (tmp = table->bins[i]; tmp != ptr; tmp = tmp->next) {
- if (!tmp) {
- /* call func with error notice */
- retval = (*func)(0, 0, arg, 1);
- return 1;
- }
+ case ST_STOP:
+ return 0;
+ case ST_DELETE:
+ tmp = ptr;
+ if (last == 0) {
+ table->bins[i] = ptr->next;
}
- /* fall through */
- case ST_CONTINUE:
- ptr = ptr->back;
- break;
- case ST_STOP:
- return 0;
- case ST_DELETE:
- last = &table->bins[ptr->hash % table->num_bins];
- for (; (tmp = *last) != 0; last = &tmp->next) {
- if (ptr == tmp) {
- tmp = ptr->back;
- *last = ptr->next;
- REMOVE_ENTRY(table, ptr);
- free(ptr);
- ptr = tmp;
- break;
- }
+ else {
+ last->next = ptr->next;
}
ptr = ptr->next;
free(tmp);
table->num_entries--;
}
- } while (!end && table->head);
+ }
}
return 0;
}
-/*
- * hash_32 - 32 bit Fowler/Noll/Vo FNV-1a hash code
- *
- * @(#) $Hash32: Revision: 1.1 $
- * @(#) $Hash32: Id: hash_32a.c,v 1.1 2003/10/03 20:38:53 chongo Exp $
- * @(#) $Hash32: Source: /usr/local/src/cmd/fnv/RCS/hash_32a.c,v $
- *
- ***
- *
- * Fowler/Noll/Vo hash
- *
- * The basis of this hash algorithm was taken from an idea sent
- * as reviewer comments to the IEEE POSIX P1003.2 committee by:
- *
- * Phong Vo (http://www.research.att.com/info/kpv/)
- * Glenn Fowler (http://www.research.att.com/~gsf/)
- *
- * In a subsequent ballot round:
- *
- * Landon Curt Noll (http://www.isthe.com/chongo/)
- *
- * improved on their algorithm. Some people tried this hash
- * and found that it worked rather well. In an EMail message
- * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
- *
- * FNV hashes are designed to be fast while maintaining a low
- * collision rate. The FNV speed allows one to quickly hash lots
- * of data while maintaining a reasonable collision rate. See:
- *
- * http://www.isthe.com/chongo/tech/comp/fnv/index.html
- *
- * for more details as well as other forms of the FNV hash.
- ***
- *
- * To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
- * Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
- *
- ***
- *
- * Please do not copyright this code. This code is in the public domain.
- *
- * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
- * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * By:
- * chongo <Landon Curt Noll> /\oo/\
- * http://www.isthe.com/chongo/
- *
- * Share and Enjoy! :-)
- */
-
-/*
- * 32 bit FNV-1 and FNV-1a non-zero initial basis
- *
- * The FNV-1 initial basis is the FNV-0 hash of the following 32 octets:
- *
- * chongo <Landon Curt Noll> /\../\
- *
- * NOTE: The \'s above are not back-slashing escape characters.
- * They are literal ASCII backslash 0x5c characters.
- *
- * NOTE: The FNV-1a initial basis is the same value as FNV-1 by definition.
- */
-#define FNV1_32A_INIT 0x811c9dc5
-
-/*
- * 32 bit magic FNV-1a prime
- */
-#define FNV_32_PRIME 0x01000193
-
static int
-strhash(register const char *string)
+strhash(string)
+ register const char *string;
{
- register unsigned int hval = FNV1_32A_INIT;
+ register int c;
- /*
- * FNV-1a hash each octet in the buffer
- */
- while (*string) {
- /* xor the bottom with the current octet */
- hval ^= (unsigned int)*string++;
+#ifdef HASH_ELFHASH
+ register unsigned int h = 0, g;
- /* multiply by the 32 bit FNV magic prime mod 2^32 */
- hval *= FNV_32_PRIME;
+ while ((c = *string++) != '\0') {
+ h = ( h << 4 ) + c;
+ if ( g = h & 0xF0000000 )
+ h ^= g >> 24;
+ h &= ~g;
}
- return hval;
-}
-
-static int
-strcasehash(register const char *string)
-{
- register unsigned int hval = FNV1_32A_INIT;
+ return h;
+#elif defined(HASH_PERL)
+ register int val = 0;
+
+ while ((c = *string++) != '\0') {
+ val += c;
+ val += (val << 10);
+ val ^= (val >> 6);
+ }
+ val += (val << 3);
+ val ^= (val >> 11);
- /*
- * FNV-1a hash each octet in the buffer
- */
- while (*string) {
- unsigned int c = (unsigned char)*string++;
- if ((unsigned int)(c - 'A') <= ('Z' - 'A')) c += 'a' - 'A';
- hval ^= c;
+ return val + (val << 15);
+#else
+ register int val = 0;
- /* multiply by the 32 bit FNV magic prime mod 2^32 */
- hval *= FNV_32_PRIME;
+ while ((c = *string++) != '\0') {
+ val = val*997 + c;
}
- return hval;
+
+ return val + (val>>5);
+#endif
}
-int
-st_numcmp(st_data_t x, st_data_t y)
+static int
+numcmp(x, y)
+ long x, y;
{
return x != y;
}
-int
-st_numhash(st_data_t n)
+static int
+numhash(n)
+ long n;
{
- return (int)n;
+ return n;
}
diff --git a/st.h b/st.h
new file mode 100644
index 0000000000..fb56f5ffad
--- /dev/null
+++ b/st.h
@@ -0,0 +1,72 @@
+/* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
+
+/* @(#) st.h 5.1 89/12/14 */
+
+#ifndef ST_INCLUDED
+
+#define ST_INCLUDED
+
+#if SIZEOF_LONG == SIZEOF_VOIDP
+typedef unsigned long st_data_t;
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+typedef unsigned LONG_LONG st_data_t;
+#else
+# error ---->> st.c requires sizeof(void*) == sizeof(long) to be compiled. <<---
+-
+#endif
+#define ST_DATA_T_DEFINED
+
+typedef struct st_table st_table;
+
+struct st_hash_type {
+ int (*compare)();
+ int (*hash)();
+};
+
+struct st_table {
+ struct st_hash_type *type;
+ int num_bins;
+ int num_entries;
+ struct st_table_entry **bins;
+};
+
+#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
+
+enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
+
+#ifndef _
+# define _(args) args
+#endif
+#ifndef ANYARGS
+# ifdef __cplusplus
+# define ANYARGS ...
+# else
+# define ANYARGS
+# endif
+#endif
+
+st_table *st_init_table _((struct st_hash_type *));
+st_table *st_init_table_with_size _((struct st_hash_type *, int));
+st_table *st_init_numtable _((void));
+st_table *st_init_numtable_with_size _((int));
+st_table *st_init_strtable _((void));
+st_table *st_init_strtable_with_size _((int));
+int st_delete _((st_table *, st_data_t *, st_data_t *));
+int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t));
+int st_insert _((st_table *, st_data_t, st_data_t));
+int st_lookup _((st_table *, st_data_t, st_data_t *));
+int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
+void st_add_direct _((st_table *, st_data_t, st_data_t));
+void st_free_table _((st_table *));
+void st_cleanup_safe _((st_table *, st_data_t));
+st_table *st_copy _((st_table *));
+
+#define ST_NUMCMP ((int (*)()) 0)
+#define ST_NUMHASH ((int (*)()) -2)
+
+#define st_numcmp ST_NUMCMP
+#define st_numhash ST_NUMHASH
+
+int st_strhash();
+
+#endif /* ST_INCLUDED */
diff --git a/string.c b/string.c
index 9dc6a13109..e0cd9c58e3 100644
--- a/string.c
+++ b/string.c
@@ -6,15 +6,14 @@
$Date$
created at: Mon Aug 9 17:12:58 JST 1993
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#include "ruby/ruby.h"
-#include "ruby/re.h"
-#include "ruby/encoding.h"
+#include "ruby.h"
+#include "re.h"
#define BEG(no) regs->beg[no]
#define END(no) regs->end[no]
@@ -27,155 +26,59 @@
#endif
VALUE rb_cString;
-VALUE rb_cSymbol;
-#define STR_TMPLOCK FL_USER7
-#define STR_NOEMBED FL_USER1
-#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
+#define STR_TMPLOCK FL_USER1
#define STR_ASSOC FL_USER3
-#define STR_SHARED_P(s) FL_ALL(s, STR_NOEMBED|ELTS_SHARED)
-#define STR_ASSOC_P(s) FL_ALL(s, STR_NOEMBED|STR_ASSOC)
-#define STR_NOCAPA (STR_NOEMBED|ELTS_SHARED|STR_ASSOC)
-#define STR_NOCAPA_P(s) (FL_TEST(s,STR_NOEMBED) && FL_ANY(s,ELTS_SHARED|STR_ASSOC))
-#define STR_UNSET_NOCAPA(s) do {\
- if (FL_TEST(s,STR_NOEMBED)) FL_UNSET(s,(ELTS_SHARED|STR_ASSOC));\
-} while (0)
-
-
-#define STR_SET_NOEMBED(str) do {\
- FL_SET(str, STR_NOEMBED);\
- STR_SET_EMBED_LEN(str, 0);\
-} while (0)
-#define STR_SET_EMBED(str) FL_UNSET(str, STR_NOEMBED)
-#define STR_EMBED_P(str) (!FL_TEST(str, STR_NOEMBED))
-#define STR_SET_EMBED_LEN(str, n) do { \
- long tmp_n = (n);\
- RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\
- RBASIC(str)->flags |= (tmp_n) << RSTRING_EMBED_LEN_SHIFT;\
-} while (0)
-
-#define STR_SET_LEN(str, n) do { \
- if (STR_EMBED_P(str)) {\
- STR_SET_EMBED_LEN(str, n);\
- }\
- else {\
- RSTRING(str)->as.heap.len = (n);\
- }\
-} while (0)
-
-#define STR_DEC_LEN(str) do {\
- if (STR_EMBED_P(str)) {\
- long n = RSTRING_LEN(str);\
- n--;\
- STR_SET_EMBED_LEN(str, n);\
- }\
- else {\
- RSTRING(str)->as.heap.len--;\
- }\
-} while (0)
+#define STR_NOCAPA (ELTS_SHARED|STR_ASSOC)
#define RESIZE_CAPA(str,capacity) do {\
- if (STR_EMBED_P(str)) {\
- if ((capacity) > RSTRING_EMBED_LEN_MAX) {\
- char *tmp = ALLOC_N(char, capacity+1);\
- memcpy(tmp, RSTRING_PTR(str), RSTRING_LEN(str));\
- RSTRING(str)->as.heap.ptr = tmp;\
- RSTRING(str)->as.heap.len = RSTRING_LEN(str);\
- STR_SET_NOEMBED(str);\
- RSTRING(str)->as.heap.aux.capa = (capacity);\
- }\
- }\
- else {\
- REALLOC_N(RSTRING(str)->as.heap.ptr, char, (capacity)+1);\
- if (!STR_NOCAPA_P(str))\
- RSTRING(str)->as.heap.aux.capa = (capacity);\
- }\
+ REALLOC_N(RSTRING(str)->ptr, char, (capacity)+1);\
+ if (!FL_TEST(str, STR_NOCAPA))\
+ RSTRING(str)->aux.capa = (capacity);\
} while (0)
-#define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
-#define IS_7BIT(str) (ENC_CODERANGE(str) == ENC_CODERANGE_7BIT)
-#define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
-
VALUE rb_fs;
-int
-rb_enc_str_coderange(VALUE str)
-{
- int cr = ENC_CODERANGE(str);
-
- if (cr == ENC_CODERANGE_UNKNOWN) {
- rb_encoding *enc = rb_enc_get(str);
-
- const char *p = RSTRING_PTR(str);
- const char *e = p + RSTRING_LEN(str);
-
- cr = rb_enc_asciicompat(enc) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
- while (p < e) {
- int ret = rb_enc_precise_mbclen(p, e, enc);
- int len = MBCLEN_CHARFOUND(ret);
-
- if (len) {
- if (len != 1 || !rb_enc_isascii((unsigned char)*p, enc)) {
- cr = ENC_CODERANGE_VALID;
- }
- p += len;
- }
- else {
- cr = ENC_CODERANGE_BROKEN;
- break;
- }
- }
- ENC_CODERANGE_SET(str, cr);
- }
- return cr;
-}
-
-int rb_enc_str_asciionly_p(VALUE str)
-{
- rb_encoding *enc = rb_enc_get(str);
-
- if (!rb_enc_asciicompat(enc))
- return Qfalse;
- else if (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
- return Qtrue;
- return Qfalse;
-}
-
static inline void
-str_mod_check(VALUE s, char *p, long len)
+str_mod_check(s, p, len)
+ VALUE s;
+ char *p;
+ long len;
{
- if (RSTRING_PTR(s) != p || RSTRING_LEN(s) != len){
+ if (RSTRING(s)->ptr != p || RSTRING(s)->len != len) {
rb_raise(rb_eRuntimeError, "string modified");
}
}
static inline void
-str_frozen_check(VALUE s)
+str_frozen_check(s)
+ VALUE s;
{
if (OBJ_FROZEN(s)) {
rb_raise(rb_eRuntimeError, "string frozen");
}
}
+static VALUE str_alloc _((VALUE));
static VALUE
-str_alloc(VALUE klass)
+str_alloc(klass)
+ VALUE klass;
{
NEWOBJ(str, struct RString);
OBJSETUP(str, klass, T_STRING);
- if (klass == rb_cSymbol) {
- /* need to be registered in table */
- RBASIC(str)->klass = rb_cString;
- }
- str->as.heap.ptr = 0;
- str->as.heap.len = 0;
- str->as.heap.aux.capa = 0;
+ str->ptr = 0;
+ str->len = 0;
+ str->aux.capa = 0;
return (VALUE)str;
}
static VALUE
-str_new(VALUE klass, const char *ptr, long len)
+str_new(klass, ptr, len)
+ VALUE klass;
+ const char *ptr;
+ long len;
{
VALUE str;
@@ -184,36 +87,27 @@ str_new(VALUE klass, const char *ptr, long len)
}
str = str_alloc(klass);
- if (len > RSTRING_EMBED_LEN_MAX) {
- RSTRING(str)->as.heap.aux.capa = len;
- RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1);
- STR_SET_NOEMBED(str);
- }
+ RSTRING(str)->len = len;
+ RSTRING(str)->aux.capa = len;
+ RSTRING(str)->ptr = ALLOC_N(char,len+1);
if (ptr) {
- memcpy(RSTRING_PTR(str), ptr, len);
+ memcpy(RSTRING(str)->ptr, ptr, len);
}
- STR_SET_LEN(str, len);
- RSTRING_PTR(str)[len] = '\0';
+ RSTRING(str)->ptr[len] = '\0';
return str;
}
VALUE
-rb_str_new(const char *ptr, long len)
+rb_str_new(ptr, len)
+ const char *ptr;
+ long len;
{
return str_new(rb_cString, ptr, len);
}
VALUE
-rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)
-{
- VALUE str = str_new(rb_cString, ptr, len);
-
- rb_enc_associate(str, enc);
- return str;
-}
-
-VALUE
-rb_str_new2(const char *ptr)
+rb_str_new2(ptr)
+ const char *ptr;
{
if (!ptr) {
rb_raise(rb_eArgError, "NULL pointer given");
@@ -222,7 +116,9 @@ rb_str_new2(const char *ptr)
}
VALUE
-rb_tainted_str_new(const char *ptr, long len)
+rb_tainted_str_new(ptr, len)
+ const char *ptr;
+ long len;
{
VALUE str = rb_str_new(ptr, len);
@@ -231,7 +127,8 @@ rb_tainted_str_new(const char *ptr, long len)
}
VALUE
-rb_tainted_str_new2(const char *ptr)
+rb_tainted_str_new2(ptr)
+ const char *ptr;
{
VALUE str = rb_str_new2(ptr);
@@ -240,37 +137,22 @@ rb_tainted_str_new2(const char *ptr)
}
static VALUE
-str_new_shared(VALUE klass, VALUE str)
+str_new3(klass, str)
+ VALUE klass, str;
{
VALUE str2 = str_alloc(klass);
- if (RSTRING_LEN(str) <= RSTRING_EMBED_LEN_MAX) {
- STR_SET_EMBED(str2);
- memcpy(RSTRING_PTR(str2), RSTRING_PTR(str), RSTRING_LEN(str)+1);
- STR_SET_EMBED_LEN(str2, RSTRING_LEN(str));
- }
- else {
- FL_SET(str2, STR_NOEMBED);
- RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
- RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
- RSTRING(str2)->as.heap.aux.shared = str;
- FL_SET(str2, ELTS_SHARED);
- }
+ RSTRING(str2)->len = RSTRING(str)->len;
+ RSTRING(str2)->ptr = RSTRING(str)->ptr;
+ RSTRING(str2)->aux.shared = str;
+ FL_SET(str2, ELTS_SHARED);
return str2;
}
-static VALUE
-str_new3(VALUE klass, VALUE str)
-{
- VALUE str2 = str_new_shared(klass, str);
-
- rb_enc_copy(str2, str);
- return str2;
-}
-
VALUE
-rb_str_new3(VALUE str)
+rb_str_new3(str)
+ VALUE str;
{
VALUE str2 = str_new3(rb_obj_class(str), str);
@@ -279,47 +161,44 @@ rb_str_new3(VALUE str)
}
static VALUE
-str_new4(VALUE klass, VALUE str)
+str_new4(klass, str)
+ VALUE klass, str;
{
- VALUE str2;
+ VALUE str2 = str_alloc(klass);
- str2 = str_alloc(klass);
- STR_SET_NOEMBED(str2);
- RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
- RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
- if (STR_SHARED_P(str)) {
+ RSTRING(str2)->len = RSTRING(str)->len;
+ RSTRING(str2)->ptr = RSTRING(str)->ptr;
+ if (FL_TEST(str, ELTS_SHARED)) {
FL_SET(str2, ELTS_SHARED);
- RSTRING(str2)->as.heap.aux.shared = RSTRING(str)->as.heap.aux.shared;
+ RSTRING(str2)->aux.shared = RSTRING(str)->aux.shared;
}
else {
FL_SET(str, ELTS_SHARED);
- RSTRING(str)->as.heap.aux.shared = str2;
+ RSTRING(str)->aux.shared = str2;
}
- rb_enc_copy(str2, str);
- OBJ_INFECT(str2, str);
+
return str2;
}
VALUE
-rb_str_new4(VALUE orig)
+rb_str_new4(orig)
+ VALUE orig;
{
VALUE klass, str;
if (OBJ_FROZEN(orig)) return orig;
klass = rb_obj_class(orig);
- if (STR_SHARED_P(orig) && (str = RSTRING(orig)->as.heap.aux.shared)
- && klass == RBASIC(str)->klass) {
+ if (FL_TEST(orig, ELTS_SHARED) && (str = RSTRING(orig)->aux.shared) && klass == RBASIC(str)->klass) {
long ofs;
- ofs = RSTRING_LEN(str) - RSTRING_LEN(orig);
+ ofs = RSTRING(str)->len - RSTRING(orig)->len;
if ((ofs > 0) || (!OBJ_TAINTED(str) && OBJ_TAINTED(orig))) {
str = str_new3(klass, str);
- RSTRING(str)->as.heap.ptr += ofs;
- RSTRING(str)->as.heap.len -= ofs;
+ RSTRING(str)->ptr += ofs;
+ RSTRING(str)->len -= ofs;
}
}
- else if (STR_ASSOC_P(orig) || STR_EMBED_P(orig)) {
- str = str_new(klass, RSTRING_PTR(orig), RSTRING_LEN(orig));
- rb_enc_copy(str, orig);
+ else if (FL_TEST(orig, STR_ASSOC)) {
+ str = str_new(klass, RSTRING(orig)->ptr, RSTRING(orig)->len);
}
else {
str = str_new4(klass, orig);
@@ -330,7 +209,10 @@ rb_str_new4(VALUE orig)
}
VALUE
-rb_str_new5(VALUE obj, const char *ptr, long len)
+rb_str_new5(obj, ptr, len)
+ VALUE obj;
+ const char *ptr;
+ long len;
{
return str_new(rb_obj_class(obj), ptr, len);
}
@@ -338,23 +220,26 @@ rb_str_new5(VALUE obj, const char *ptr, long len)
#define STR_BUF_MIN_SIZE 128
VALUE
-rb_str_buf_new(long capa)
+rb_str_buf_new(capa)
+ long capa;
{
VALUE str = str_alloc(rb_cString);
if (capa < STR_BUF_MIN_SIZE) {
capa = STR_BUF_MIN_SIZE;
}
- FL_SET(str, STR_NOEMBED);
- RSTRING(str)->as.heap.aux.capa = capa;
- RSTRING(str)->as.heap.ptr = ALLOC_N(char, capa+1);
- RSTRING(str)->as.heap.ptr[0] = '\0';
+ RSTRING(str)->ptr = 0;
+ RSTRING(str)->len = 0;
+ RSTRING(str)->aux.capa = capa;
+ RSTRING(str)->ptr = ALLOC_N(char, capa+1);
+ RSTRING(str)->ptr[0] = '\0';
return str;
}
VALUE
-rb_str_buf_new2(const char *ptr)
+rb_str_buf_new2(ptr)
+ const char *ptr;
{
VALUE str;
long len = strlen(ptr);
@@ -366,61 +251,55 @@ rb_str_buf_new2(const char *ptr)
}
VALUE
-rb_str_tmp_new(long len)
+rb_str_tmp_new(len)
+ long len;
{
return str_new(0, 0, len);
}
-void
-rb_str_free(VALUE str)
-{
- if (!STR_EMBED_P(str) && !STR_SHARED_P(str)) {
- xfree(RSTRING(str)->as.heap.ptr);
- }
-}
-
VALUE
-rb_str_to_str(VALUE str)
+rb_str_to_str(str)
+ VALUE str;
{
return rb_convert_type(str, T_STRING, "String", "to_str");
}
-void
-rb_str_shared_replace(VALUE str, VALUE str2)
+static void
+rb_str_shared_replace(str, str2)
+ VALUE str, str2;
{
if (str == str2) return;
rb_str_modify(str);
- if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
- if (RSTRING_LEN(str2) <= RSTRING_EMBED_LEN_MAX) {
- STR_SET_EMBED(str);
- memcpy(RSTRING_PTR(str), RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
- STR_SET_EMBED_LEN(str, RSTRING_LEN(str2));
+ if (!FL_TEST(str, ELTS_SHARED)) free(RSTRING(str)->ptr);
+ if (NIL_P(str2)) {
+ RSTRING(str)->ptr = 0;
+ RSTRING(str)->len = 0;
+ RSTRING(str)->aux.capa = 0;
+ FL_UNSET(str, STR_NOCAPA);
return;
}
- if (!STR_SHARED_P(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
- }
- STR_SET_NOEMBED(str);
- STR_UNSET_NOCAPA(str);
- RSTRING(str)->as.heap.ptr = RSTRING_PTR(str2);
- RSTRING(str)->as.heap.len = RSTRING_LEN(str2);
- if (STR_NOCAPA_P(str2)) {
+ RSTRING(str)->ptr = RSTRING(str2)->ptr;
+ RSTRING(str)->len = RSTRING(str2)->len;
+ FL_UNSET(str, STR_NOCAPA);
+ if (FL_TEST(str2, STR_NOCAPA)) {
FL_SET(str, RBASIC(str2)->flags & STR_NOCAPA);
- RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
+ RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
else {
- RSTRING(str)->as.heap.aux.capa = RSTRING(str2)->as.heap.aux.capa;
+ RSTRING(str)->aux.capa = RSTRING(str2)->aux.capa;
}
- RSTRING(str2)->as.heap.ptr = 0; /* abandon str2 */
- RSTRING(str2)->as.heap.len = 0;
- RSTRING(str2)->as.heap.aux.capa = 0;
- STR_UNSET_NOCAPA(str2);
+ RSTRING(str2)->ptr = 0; /* abandon str2 */
+ RSTRING(str2)->len = 0;
+ RSTRING(str2)->aux.capa = 0;
+ FL_UNSET(str2, STR_NOCAPA);
+ if (OBJ_TAINTED(str2)) OBJ_TAINT(str);
}
static ID id_to_s;
VALUE
-rb_obj_as_string(VALUE obj)
+rb_obj_as_string(obj)
+ VALUE obj;
{
VALUE str;
@@ -434,10 +313,11 @@ rb_obj_as_string(VALUE obj)
return str;
}
-static VALUE rb_str_replace(VALUE, VALUE);
+static VALUE rb_str_replace _((VALUE, VALUE));
VALUE
-rb_str_dup(VALUE str)
+rb_str_dup(str)
+ VALUE str;
{
VALUE dup = str_alloc(rb_obj_class(str));
rb_str_replace(dup, str);
@@ -453,7 +333,10 @@ rb_str_dup(VALUE str)
*/
static VALUE
-rb_str_init(int argc, VALUE *argv, VALUE str)
+rb_str_init(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE orig;
@@ -462,48 +345,18 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
return str;
}
-static long
-str_strlen(VALUE str, rb_encoding *enc)
-{
- long len;
-
- if (is_ascii_string(str)) return RSTRING_LEN(str);
- if (!enc) enc = rb_enc_get(str);
- len = rb_enc_strlen(RSTRING_PTR(str), RSTRING_END(str), enc);
- if (len < 0) {
- rb_raise(rb_eArgError, "invalid mbstring sequence");
- }
- return len;
-}
-
/*
* call-seq:
* str.length => integer
- * str.size => integer
*
- * Returns the character length of <i>str</i>.
- */
-
-VALUE
-rb_str_length(VALUE str)
-{
- int len;
-
- len = str_strlen(str, rb_enc_get(str));
- return INT2NUM(len);
-}
-
-/*
- * call-seq:
- * str.bytesize => integer
- *
- * Returns the length of <i>str</i> in bytes.
+ * Returns the length of <i>str</i>.
*/
static VALUE
-rb_str_bytesize(VALUE str)
+rb_str_length(str)
+ VALUE str;
{
- return INT2NUM(RSTRING_LEN(str));
+ return LONG2NUM(RSTRING(str)->len);
}
/*
@@ -517,9 +370,10 @@ rb_str_bytesize(VALUE str)
*/
static VALUE
-rb_str_empty(VALUE str)
+rb_str_empty(str)
+ VALUE str;
{
- if (RSTRING_LEN(str) == 0)
+ if (RSTRING(str)->len == 0)
return Qtrue;
return Qfalse;
}
@@ -535,22 +389,20 @@ rb_str_empty(VALUE str)
*/
VALUE
-rb_str_plus(VALUE str1, VALUE str2)
+rb_str_plus(str1, str2)
+ VALUE str1, str2;
{
VALUE str3;
- rb_encoding *enc;
StringValue(str2);
- enc = rb_enc_check(str1, str2);
- str3 = rb_str_new(0, RSTRING_LEN(str1)+RSTRING_LEN(str2));
- memcpy(RSTRING_PTR(str3), RSTRING_PTR(str1), RSTRING_LEN(str1));
- memcpy(RSTRING_PTR(str3) + RSTRING_LEN(str1),
- RSTRING_PTR(str2), RSTRING_LEN(str2));
- RSTRING_PTR(str3)[RSTRING_LEN(str3)] = '\0';
+ str3 = rb_str_new(0, RSTRING(str1)->len+RSTRING(str2)->len);
+ memcpy(RSTRING(str3)->ptr, RSTRING(str1)->ptr, RSTRING(str1)->len);
+ memcpy(RSTRING(str3)->ptr + RSTRING(str1)->len,
+ RSTRING(str2)->ptr, RSTRING(str2)->len);
+ RSTRING(str3)->ptr[RSTRING(str3)->len] = '\0';
if (OBJ_TAINTED(str1) || OBJ_TAINTED(str2))
OBJ_TAINT(str3);
- rb_enc_associate(str3, enc);
return str3;
}
@@ -565,7 +417,9 @@ rb_str_plus(VALUE str1, VALUE str2)
*/
VALUE
-rb_str_times(VALUE str, VALUE times)
+rb_str_times(str, times)
+ VALUE str;
+ VALUE times;
{
VALUE str2;
long i, len;
@@ -574,18 +428,18 @@ rb_str_times(VALUE str, VALUE times)
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
- if (len && LONG_MAX/len < RSTRING_LEN(str)) {
+ if (len && LONG_MAX/len < RSTRING(str)->len) {
rb_raise(rb_eArgError, "argument too big");
}
- str2 = rb_str_new5(str, 0, len *= RSTRING_LEN(str));
- for (i = 0; i < len; i += RSTRING_LEN(str)) {
- memcpy(RSTRING_PTR(str2) + i,
- RSTRING_PTR(str), RSTRING_LEN(str));
+ str2 = rb_str_new5(str,0, len *= RSTRING(str)->len);
+ for (i = 0; i < len; i += RSTRING(str)->len) {
+ memcpy(RSTRING(str2)->ptr + i,
+ RSTRING(str)->ptr, RSTRING(str)->len);
}
- RSTRING_PTR(str2)[RSTRING_LEN(str2)] = '\0';
+ RSTRING(str2)->ptr[RSTRING(str2)->len] = '\0';
+
OBJ_INFECT(str2, str);
- rb_enc_copy(str2, str);
return str2;
}
@@ -605,9 +459,10 @@ rb_str_times(VALUE str, VALUE times)
*/
static VALUE
-rb_str_format_m(VALUE str, VALUE arg)
+rb_str_format_m(str, arg)
+ VALUE str, arg;
{
- VALUE tmp = rb_check_array_type(arg);
+ volatile VALUE tmp = rb_check_array_type(arg);
if (!NIL_P(tmp)) {
return rb_str_format(RARRAY_LEN(tmp), RARRAY_PTR(tmp), str);
@@ -615,8 +470,9 @@ rb_str_format_m(VALUE str, VALUE arg)
return rb_str_format(1, &arg, str);
}
-static void
-str_modifiable(VALUE str)
+static int
+str_independent(str)
+ VALUE str;
{
if (FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "can't modify string; temporarily locked");
@@ -624,250 +480,166 @@ str_modifiable(VALUE str)
if (OBJ_FROZEN(str)) rb_error_frozen("string");
if (!OBJ_TAINTED(str) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify string");
-}
-
-static int
-str_independent(VALUE str)
-{
- str_modifiable(str);
- if (!STR_SHARED_P(str)) return 1;
- if (STR_EMBED_P(str)) return 1;
+ if (!FL_TEST(str, ELTS_SHARED)) return 1;
return 0;
}
static void
-str_make_independent(VALUE str)
+str_make_independent(str)
+ VALUE str;
{
char *ptr;
- long len = RSTRING_LEN(str);
- ptr = ALLOC_N(char, len+1);
- if (RSTRING_PTR(str)) {
- memcpy(ptr, RSTRING_PTR(str), len);
+ ptr = ALLOC_N(char, RSTRING(str)->len+1);
+ if (RSTRING(str)->ptr) {
+ memcpy(ptr, RSTRING(str)->ptr, RSTRING(str)->len);
}
- STR_SET_NOEMBED(str);
- ptr[len] = 0;
- RSTRING(str)->as.heap.ptr = ptr;
- RSTRING(str)->as.heap.aux.capa = len;
- STR_UNSET_NOCAPA(str);
+ ptr[RSTRING(str)->len] = 0;
+ RSTRING(str)->ptr = ptr;
+ RSTRING(str)->aux.capa = RSTRING(str)->len;
+ FL_UNSET(str, STR_NOCAPA);
}
void
-rb_str_modify(VALUE str)
+rb_str_modify(str)
+ VALUE str;
{
if (!str_independent(str))
str_make_independent(str);
- ENC_CODERANGE_CLEAR(str);
}
void
-rb_str_associate(VALUE str, VALUE add)
+rb_str_associate(str, add)
+ VALUE str, add;
{
- if (STR_ASSOC_P(str)) {
- /* sanity check */
- if (OBJ_FROZEN(str)) rb_error_frozen("string");
+ if (FL_TEST(str, STR_ASSOC)) {
/* already associated */
- rb_ary_concat(RSTRING(str)->as.heap.aux.shared, add);
+ rb_ary_concat(RSTRING(str)->aux.shared, add);
}
else {
- if (STR_SHARED_P(str) || STR_EMBED_P(str)) {
+ if (FL_TEST(str, ELTS_SHARED)) {
str_make_independent(str);
}
- else if (RSTRING(str)->as.heap.aux.capa != RSTRING_LEN(str)) {
- RESIZE_CAPA(str, RSTRING_LEN(str));
+ else if (RSTRING(str)->aux.capa != RSTRING(str)->len) {
+ RESIZE_CAPA(str, RSTRING(str)->len);
}
+ RSTRING(str)->aux.shared = add;
FL_SET(str, STR_ASSOC);
- RSTRING(str)->as.heap.aux.shared = add;
}
}
VALUE
-rb_str_associated(VALUE str)
+rb_str_associated(str)
+ VALUE str;
{
- if (STR_ASSOC_P(str)) {
- if (OBJ_FROZEN(str)) return Qfalse;
- return RSTRING(str)->as.heap.aux.shared;
+ if (FL_TEST(str, STR_ASSOC)) {
+ return RSTRING(str)->aux.shared;
}
return Qfalse;
}
+static const char null_str[] = "";
+#define null_str ((char *)null_str)
+
VALUE
-rb_string_value(volatile VALUE *ptr)
+rb_string_value(ptr)
+ volatile VALUE *ptr;
{
VALUE s = *ptr;
if (TYPE(s) != T_STRING) {
s = rb_str_to_str(s);
*ptr = s;
}
+ if (!RSTRING(s)->ptr) {
+ FL_SET(s, ELTS_SHARED);
+ RSTRING(s)->ptr = null_str;
+ }
return s;
}
char *
-rb_string_value_ptr(volatile VALUE *ptr)
+rb_string_value_ptr(ptr)
+ volatile VALUE *ptr;
{
- return RSTRING_PTR(rb_string_value(ptr));
+ return RSTRING(rb_string_value(ptr))->ptr;
}
char *
-rb_string_value_cstr(volatile VALUE *ptr)
+rb_string_value_cstr(ptr)
+ volatile VALUE *ptr;
{
VALUE str = rb_string_value(ptr);
- char *s = RSTRING_PTR(str);
+ char *s = RSTRING(str)->ptr;
- if (!s || RSTRING_LEN(str) != strlen(s)) {
+ if (!s || RSTRING(str)->len != strlen(s)) {
rb_raise(rb_eArgError, "string contains null byte");
}
return s;
}
VALUE
-rb_check_string_type(VALUE str)
+rb_check_string_type(str)
+ VALUE str;
{
str = rb_check_convert_type(str, T_STRING, "String", "to_str");
- return str;
-}
-
-/*
- * call-seq:
- * String.try_convert(obj) -> string or nil
- *
- * Try to convert <i>obj</i> into a String, using to_str method.
- * Returns converted regexp or nil if <i>obj</i> cannot be converted
- * for any reason.
- *
- * String.try_convert("str") # => str
- * String.try_convert(/re/) # => nil
- */
-static VALUE
-rb_str_s_try_convert(VALUE dummy, VALUE str)
-{
- return rb_check_string_type(str);
-}
-
-static char*
-str_nth(char *p, char *e, int nth, rb_encoding *enc, int asc)
-{
- if (asc)
- p += nth;
- else
- p = rb_enc_nth(p, e, nth, enc);
- if (!p) return 0;
- if (p > e) return e;
- return p;
-}
-
-static int
-str_offset(char *p, char *e, int nth, rb_encoding *enc, int asc)
-{
- const char *pp = str_nth(p, e, nth, enc, asc);
- if (!pp) return e - p;
- return pp - p;
-}
-
-static long
-str_sublen(VALUE str, long pos, rb_encoding *enc)
-{
- if (rb_enc_mbmaxlen(enc) == 1 || pos < 0) return pos;
- else {
- char *p = RSTRING_PTR(str);
- char *e = p + pos;
- long i;
-
- i = 0;
- while (p < e) {
- p += rb_enc_mbclen(p, RSTRING_END(str), enc);
- i++;
- }
- if (p == e) return i;
- return i - 1;
+ if (!NIL_P(str) && !RSTRING(str)->ptr) {
+ FL_SET(str, ELTS_SHARED);
+ RSTRING(str)->ptr = null_str;
}
-}
-
-int
-rb_str_sublen(VALUE str, int len)
-{
- return str_sublen(str, len, rb_enc_get(str));
-}
-
-VALUE
-rb_str_subseq(VALUE str, long beg, long len)
-{
- VALUE str2 = rb_str_new5(str, RSTRING_PTR(str)+beg, len);
-
- rb_enc_copy(str2, str);
- OBJ_INFECT(str2, str);
-
- return str2;
+ return str;
}
VALUE
-rb_str_substr(VALUE str, long beg, long len)
+rb_str_substr(str, beg, len)
+ VALUE str;
+ long beg, len;
{
- rb_encoding *enc = rb_enc_get(str);
VALUE str2;
- char *p, *s = RSTRING_PTR(str), *e = s + RSTRING_LEN(str);
- int asc = IS_7BIT(str);
if (len < 0) return Qnil;
- if (!RSTRING_LEN(str)) {
- len = 0;
- }
+ if (beg > RSTRING(str)->len) return Qnil;
if (beg < 0) {
- if (len > -beg) len = -beg;
- if (-beg * rb_enc_mbmaxlen(enc) < RSTRING_LEN(str) / 8) {
- beg = -beg;
- while (len++ < beg && (e = rb_enc_prev_char(s, e, enc)) != 0);
- p = e;
- if (!p) return Qnil;
- while (beg-- > 0 && (p = rb_enc_prev_char(s, p, enc)) != 0);
- if (!p) return Qnil;
- len = e - p;
- goto sub;
- }
- else {
- beg += str_strlen(str, enc);
- if (beg < 0) return Qnil;
- }
+ beg += RSTRING(str)->len;
+ if (beg < 0) return Qnil;
}
- else if (beg > 0 && beg > str_strlen(str, enc)) {
- return Qnil;
+ if (beg + len > RSTRING(str)->len) {
+ len = RSTRING(str)->len - beg;
}
- if (len == 0) {
- p = 0;
- }
- else if ((p = str_nth(s, e, beg, enc, asc)) == e) {
+ if (len < 0) {
len = 0;
}
- else if (rb_enc_mbmaxlen(enc) == rb_enc_mbminlen(enc)) {
- long rest = (e - p) / rb_enc_mbmaxlen(enc);
- if (len > rest)
- len = rest;
- else
- len *= rb_enc_mbmaxlen(enc);
+ if (len == 0) {
+ str2 = rb_str_new5(str,0,0);
+ }
+ else if (len > sizeof(struct RString)/2 &&
+ beg + len == RSTRING(str)->len && !FL_TEST(str, STR_ASSOC)) {
+ str2 = rb_str_new4(str);
+ str2 = str_new3(rb_obj_class(str2), str2);
+ RSTRING(str2)->ptr += RSTRING(str2)->len - len;
+ RSTRING(str2)->len = len;
}
else {
- len = str_offset(p, e, len, enc, asc);
+ str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len);
}
- sub:
- str2 = rb_str_new5(str, p, len);
- rb_enc_copy(str2, str);
OBJ_INFECT(str2, str);
return str2;
}
VALUE
-rb_str_freeze(VALUE str)
+rb_str_freeze(str)
+ VALUE str;
{
return rb_obj_freeze(str);
}
VALUE
-rb_str_dup_frozen(VALUE str)
+rb_str_dup_frozen(str)
+ VALUE str;
{
- if (STR_SHARED_P(str) && RSTRING(str)->as.heap.aux.shared) {
- VALUE shared = RSTRING(str)->as.heap.aux.shared;
- if (RSTRING_LEN(shared) == RSTRING_LEN(str)) {
+ if (FL_TEST(str, ELTS_SHARED) && RSTRING(str)->aux.shared) {
+ VALUE shared = RSTRING(str)->aux.shared;
+ if (RSTRING(shared)->len == RSTRING(str)->len) {
OBJ_FREEZE(shared);
return shared;
}
@@ -879,7 +651,8 @@ rb_str_dup_frozen(VALUE str)
}
VALUE
-rb_str_locktmp(VALUE str)
+rb_str_locktmp(str)
+ VALUE str;
{
if (FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "temporal locking already locked string");
@@ -889,7 +662,8 @@ rb_str_locktmp(VALUE str)
}
VALUE
-rb_str_unlocktmp(VALUE str)
+rb_str_unlocktmp(str)
+ VALUE str;
{
if (!FL_TEST(str, STR_TMPLOCK)) {
rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
@@ -901,96 +675,113 @@ rb_str_unlocktmp(VALUE str)
void
rb_str_set_len(VALUE str, long len)
{
- STR_SET_LEN(str, len);
- RSTRING_PTR(str)[len] = '\0';
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = '\0';
}
VALUE
-rb_str_resize(VALUE str, long len)
+rb_str_resize(str, len)
+ VALUE str;
+ long len;
{
if (len < 0) {
rb_raise(rb_eArgError, "negative string size (or size too big)");
}
rb_str_modify(str);
- if (len != RSTRING_LEN(str)) {
- if (STR_EMBED_P(str)) {
- char *ptr;
- if (len <= RSTRING_EMBED_LEN_MAX) {
- STR_SET_EMBED_LEN(str, len);
- RSTRING_PTR(str)[len] = '\0';
- return str;
+ if (len != RSTRING(str)->len) {
+ if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
+ REALLOC_N(RSTRING(str)->ptr, char, len+1);
+ if (!FL_TEST(str, STR_NOCAPA)) {
+ RSTRING(str)->aux.capa = len;
}
- ptr = ALLOC_N(char,len+1);
- MEMCPY(ptr, RSTRING_PTR(str), char, RSTRING_LEN(str));
- RSTRING(str)->as.heap.ptr = ptr;
- STR_SET_NOEMBED(str);
}
- else if (RSTRING_LEN(str) < len || RSTRING_LEN(str) - len > 1024) {
- REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1);
- }
- if (!STR_NOCAPA_P(str)) {
- RSTRING(str)->as.heap.aux.capa = len;
- }
- RSTRING(str)->as.heap.len = len;
- RSTRING(str)->as.heap.ptr[len] = '\0'; /* sentinel */
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = '\0'; /* sentinel */
}
return str;
}
-VALUE
-rb_str_buf_cat(VALUE str, const char *ptr, long len)
+static VALUE
+str_buf_cat(str, ptr, len)
+ VALUE str;
+ const char *ptr;
+ long len;
{
- long capa, total;
+ long capa, total, off = -1;;
- if (len == 0) return str;
- if (len < 0) {
- rb_raise(rb_eArgError, "negative string size (or size too big)");
- }
rb_str_modify(str);
- if (STR_ASSOC_P(str)) {
- FL_UNSET(str, STR_ASSOC);
- capa = RSTRING(str)->as.heap.aux.capa = RSTRING_LEN(str);
+ if (ptr >= RSTRING(str)->ptr && ptr <= RSTRING(str)->ptr + RSTRING(str)->len) {
+ off = ptr - RSTRING(str)->ptr;
}
- else if (STR_EMBED_P(str)) {
- capa = RSTRING_EMBED_LEN_MAX;
+ if (len == 0) return 0;
+ if (FL_TEST(str, STR_ASSOC)) {
+ FL_UNSET(str, STR_ASSOC);
+ capa = RSTRING(str)->aux.capa = RSTRING(str)->len;
}
else {
- capa = RSTRING(str)->as.heap.aux.capa;
+ capa = RSTRING(str)->aux.capa;
+ }
+ if (RSTRING(str)->len >= LONG_MAX - len) {
+ rb_raise(rb_eArgError, "string sizes too big");
}
- total = RSTRING_LEN(str)+len;
+ total = RSTRING(str)->len+len;
if (capa <= total) {
while (total > capa) {
+ if (capa + 1 >= LONG_MAX / 2) {
+ capa = total;
+ break;
+ }
capa = (capa + 1) * 2;
}
RESIZE_CAPA(str, capa);
}
- memcpy(RSTRING_PTR(str) + RSTRING_LEN(str), ptr, len);
- STR_SET_LEN(str, total);
- RSTRING_PTR(str)[total] = '\0'; /* sentinel */
+ if (off != -1) {
+ ptr = RSTRING(str)->ptr + off;
+ }
+ memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len);
+ RSTRING(str)->len = total;
+ RSTRING(str)->ptr[total] = '\0'; /* sentinel */
return str;
}
VALUE
-rb_str_buf_cat2(VALUE str, const char *ptr)
+rb_str_buf_cat(str, ptr, len)
+ VALUE str;
+ const char *ptr;
+ long len;
+{
+ if (len == 0) return str;
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative string size (or size too big)");
+ }
+ return str_buf_cat(str, ptr, len);
+}
+
+VALUE
+rb_str_buf_cat2(str, ptr)
+ VALUE str;
+ const char *ptr;
{
return rb_str_buf_cat(str, ptr, strlen(ptr));
}
VALUE
-rb_str_cat(VALUE str, const char *ptr, long len)
+rb_str_cat(str, ptr, len)
+ VALUE str;
+ const char *ptr;
+ long len;
{
if (len < 0) {
rb_raise(rb_eArgError, "negative string size (or size too big)");
}
- if (STR_ASSOC_P(str)) {
+ if (FL_TEST(str, STR_ASSOC)) {
rb_str_modify(str);
- if (STR_EMBED_P(str)) str_make_independent(str);
- REALLOC_N(RSTRING(str)->as.heap.ptr, char, RSTRING(str)->as.heap.len+len);
- memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len, ptr, len);
- RSTRING(str)->as.heap.len += len;
- RSTRING(str)->as.heap.ptr[RSTRING(str)->as.heap.len] = '\0'; /* sentinel */
+ REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+len+1);
+ memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len);
+ RSTRING(str)->len += len;
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; /* sentinel */
return str;
}
@@ -998,83 +789,42 @@ rb_str_cat(VALUE str, const char *ptr, long len)
}
VALUE
-rb_str_cat2(VALUE str, const char *ptr)
+rb_str_cat2(str, ptr)
+ VALUE str;
+ const char *ptr;
{
return rb_str_cat(str, ptr, strlen(ptr));
}
VALUE
-rb_str_buf_append(VALUE str, VALUE str2)
+rb_str_buf_append(str, str2)
+ VALUE str, str2;
{
- rb_encoding *enc;
- long capa, len;
- int cr1, cr2;
-
- enc = rb_enc_check(str, str2);
- cr1 = ENC_CODERANGE(str);
- cr2 = ENC_CODERANGE(str2);
- if (cr1 == ENC_CODERANGE_BROKEN || cr2 == ENC_CODERANGE_BROKEN) {
- cr1 = ENC_CODERANGE_UNKNOWN;
- }
- else if (cr2 > cr1) {
- cr1 = cr2;
- }
- rb_str_modify(str);
- if (STR_ASSOC_P(str)) {
- FL_UNSET(str, STR_ASSOC);
- capa = RSTRING(str)->as.heap.aux.capa = RSTRING_LEN(str);
- }
- else if (STR_EMBED_P(str)) {
- capa = RSTRING_EMBED_LEN_MAX;
- }
- else {
- capa = RSTRING(str)->as.heap.aux.capa;
- }
- len = RSTRING_LEN(str)+RSTRING_LEN(str2);
- if (capa <= len) {
- while (len > capa) {
- capa = (capa + 1) * 2;
- }
- RESIZE_CAPA(str, capa);
- }
- memcpy(RSTRING_PTR(str) + RSTRING_LEN(str),
- RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
- STR_SET_LEN(str, len);
+ str_buf_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
- rb_enc_associate(str, enc);
- if (cr1 != ENC_CODERANGE_UNKNOWN) {
- ENC_CODERANGE_SET(str, cr1);
- }
-
return str;
}
VALUE
-rb_str_append(VALUE str, VALUE str2)
+rb_str_append(str, str2)
+ VALUE str, str2;
{
- rb_encoding *enc;
- int cr, cr2;
-
StringValue(str2);
- enc = rb_enc_check(str, str2);
- cr = ENC_CODERANGE(str);
- if ((cr2 = ENC_CODERANGE(str2)) > cr) cr = cr2;
rb_str_modify(str);
- if (RSTRING_LEN(str2) > 0) {
- if (STR_ASSOC_P(str)) {
- long len = RSTRING_LEN(str)+RSTRING_LEN(str2);
- REALLOC_N(RSTRING(str)->as.heap.ptr, char, len+1);
- memcpy(RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len,
- RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
- RSTRING(str)->as.heap.len = len;
+ if (RSTRING(str2)->len > 0) {
+ if (FL_TEST(str, STR_ASSOC)) {
+ long len = RSTRING(str)->len+RSTRING(str2)->len;
+ REALLOC_N(RSTRING(str)->ptr, char, len+1);
+ memcpy(RSTRING(str)->ptr + RSTRING(str)->len,
+ RSTRING(str2)->ptr, RSTRING(str2)->len);
+ RSTRING(str)->ptr[len] = '\0'; /* sentinel */
+ RSTRING(str)->len = len;
}
else {
- rb_str_buf_append(str, str2);
+ return rb_str_buf_append(str, str2);
}
}
OBJ_INFECT(str, str2);
- rb_enc_associate(str, enc);
- ENC_CODERANGE_SET(str, cr);
return str;
}
@@ -1087,8 +837,8 @@ rb_str_append(VALUE str, VALUE str2)
* str.concat(obj) => str
*
* Append---Concatenates the given object to <i>str</i>. If the object is a
- * <code>Fixnum</code>, it is considered as a codepoint, and is converted
- * to a character before concatenation.
+ * <code>Fixnum</code> between 0 and 255, it is converted to a character before
+ * concatenation.
*
* a = "hello "
* a << "world" #=> "hello world"
@@ -1096,156 +846,55 @@ rb_str_append(VALUE str, VALUE str2)
*/
VALUE
-rb_str_concat(VALUE str1, VALUE str2)
+rb_str_concat(str1, str2)
+ VALUE str1, str2;
{
if (FIXNUM_P(str2)) {
- rb_encoding *enc = rb_enc_get(str1);
- int c = FIX2INT(str2);
- int pos = RSTRING_LEN(str1);
- int len = rb_enc_codelen(c, enc);
-
- if (len == 0) {
- rb_raise(rb_eArgError, "invalid codepoint 0x%x", c);
+ int i = FIX2INT(str2);
+ if (0 <= i && i <= 0xff) { /* byte */
+ char c = i;
+ return rb_str_cat(str1, &c, 1);
}
- rb_str_resize(str1, pos+len);
- rb_enc_mbcput(c, RSTRING_PTR(str1)+pos, enc);
- return str1;
}
- return rb_str_append(str1, str2);
-}
-
-typedef unsigned int ub4; /* unsigned 4-byte quantities */
-typedef unsigned char ub1; /* unsigned 1-byte quantities */
-
-#define hashsize(n) ((ub4)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
+ str1 = rb_str_append(str1, str2);
-/*
---------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-For every delta with one or two bits set, and the deltas of all three
- high bits or all three low bits, whether the original value of a,b,c
- is almost all zero or is uniformly distributed,
-* If mix() is run forward or backward, at least 32 bits in a,b,c
- have at least 1/4 probability of changing.
-* If mix() is run forward, every bit of c will change between 1/3 and
- 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
-mix() was built out of 36 single-cycle latency instructions in a
- structure that could supported 2x parallelism, like so:
- a -= b;
- a -= c; x = (c>>13);
- b -= c; a ^= x;
- b -= a; x = (a<<8);
- c -= a; b ^= x;
- c -= b; x = (b>>13);
- ...
- Unfortunately, superscalar Pentiums and Sparcs can't take advantage
- of that parallelism. They've also turned some of those single-cycle
- latency instructions into multi-cycle latency instructions. Still,
- this is the fastest good hash I could find. There were about 2^^68
- to choose from. I only looked at a billion or so.
---------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
- a -= b; a -= c; a ^= (c>>13); \
- b -= c; b -= a; b ^= (a<<8); \
- c -= a; c -= b; c ^= (b>>13); \
- a -= b; a -= c; a ^= (c>>12); \
- b -= c; b -= a; b ^= (a<<16); \
- c -= a; c -= b; c ^= (b>>5); \
- a -= b; a -= c; a ^= (c>>3); \
- b -= c; b -= a; b ^= (a<<10); \
- c -= a; c -= b; c ^= (b>>15); \
-}
-
-/*
---------------------------------------------------------------------
-hash() -- hash a variable-length key into a 32-bit value
- k : the key (the unaligned variable-length array of bytes)
- len : the length of the key, counting by bytes
- initval : can be any 4-byte value
-Returns a 32-bit value. Every bit of the key affects every bit of
-the return value. Every 1-bit and 2-bit delta achieves avalanche.
-About 6*len+35 instructions.
-
-The best hash table sizes are powers of 2. There is no need to do
-mod a prime (mod is sooo slow!). If you need less than 32 bits,
-use a bitmask. For example, if you need only 10 bits, do
- h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (ub1 **)k, do it like this:
- for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
-
-By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
-code any way you wish, private, educational, or commercial. It's free.
-
-See http://burtleburtle.net/bob/hash/evahash.html
-Use for hash table lookup, or anything where one collision in 2^^32 is
-acceptable. Do NOT use for cryptographic purposes.
---------------------------------------------------------------------
-*/
-
-static ub4
-hash(const ub1 *k, ub4 length, ub4 initval)
- /* k: the key */
- /* length: the length of the key */
- /* initval: the previous hash, or an arbitrary value */
-{
- register ub4 a,b,c,len;
-
- /* Set up the internal state */
- len = length;
- a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
- c = initval; /* the previous hash value */
-
- /*---------------------------------------- handle most of the key */
- while (len >= 12) {
- a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
- b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
- c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
- mix(a,b,c);
- k += 12; len -= 12;
- }
-
- /*------------------------------------- handle the last 11 bytes */
- c += length;
- switch(len) /* all the case statements fall through */
- {
- case 11: c+=((ub4)k[10]<<24);
- case 10: c+=((ub4)k[9]<<16);
- case 9 : c+=((ub4)k[8]<<8);
- /* the first byte of c is reserved for the length */
- case 8 : b+=((ub4)k[7]<<24);
- case 7 : b+=((ub4)k[6]<<16);
- case 6 : b+=((ub4)k[5]<<8);
- case 5 : b+=k[4];
- case 4 : a+=((ub4)k[3]<<24);
- case 3 : a+=((ub4)k[2]<<16);
- case 2 : a+=((ub4)k[1]<<8);
- case 1 : a+=k[0];
- /* case 0: nothing left to add */
- }
- mix(a,b,c);
- /*-------------------------------------------- report the result */
- return c;
-}
-
-int
-rb_memhash(const void *ptr, long len)
-{
- return hash(ptr, len, 0);
+ return str1;
}
int
-rb_str_hash(VALUE str)
+rb_str_hash(str)
+ VALUE str;
{
- int e = rb_enc_get_index(str);
- if (e && is_ascii_string(str)) {
- e = 0;
- }
- return hash((const void *)RSTRING_PTR(str), RSTRING_LEN(str), e);
+ register long len = RSTRING(str)->len;
+ register char *p = RSTRING(str)->ptr;
+ register int key = 0;
+
+#if defined(HASH_ELFHASH)
+ register unsigned int g;
+
+ while (len--) {
+ key = (key << 4) + *p++;
+ if (g = key & 0xF0000000)
+ key ^= g >> 24;
+ key &= ~g;
+ }
+#elif defined(HASH_PERL)
+ while (len--) {
+ key += *p++;
+ key += (key << 10);
+ key ^= (key >> 6);
+ }
+ key += (key << 3);
+ key ^= (key >> 11);
+ key += (key << 15);
+#else
+ while (len--) {
+ key = key*65599 + *p;
+ p++;
+ }
+ key = key + (key>>5);
+#endif
+ return key;
}
/*
@@ -1256,56 +905,27 @@ rb_str_hash(VALUE str)
*/
static VALUE
-rb_str_hash_m(VALUE str)
+rb_str_hash_m(str)
+ VALUE str;
{
- int hval = rb_str_hash(str);
- return INT2FIX(hval);
+ int key = rb_str_hash(str);
+ return INT2FIX(key);
}
#define lesser(a,b) (((a)>(b))?(b):(a))
int
-rb_str_comparable(VALUE str1, VALUE str2)
-{
- int idx1 = rb_enc_get_index(str1);
- int idx2 = rb_enc_get_index(str2);
- int rc1, rc2;
-
- if (idx1 == idx2) return Qtrue;
- rc1 = rb_enc_str_coderange(str1);
- rc2 = rb_enc_str_coderange(str2);
- if (rc1 == ENC_CODERANGE_7BIT) {
- if (rc2 == ENC_CODERANGE_7BIT) return Qtrue;
- if (rb_enc_asciicompat(rb_enc_from_index(idx1)))
- return Qtrue;
- }
- if (rc2 == ENC_CODERANGE_7BIT) {
- if (rb_enc_asciicompat(rb_enc_from_index(idx2)))
- return Qtrue;
- }
- return Qfalse;
-}
-
-int
-rb_str_cmp(VALUE str1, VALUE str2)
+rb_str_cmp(str1, str2)
+ VALUE str1, str2;
{
long len;
int retval;
- rb_encoding *enc;
- enc = rb_enc_compatible(str1, str2);
- len = lesser(RSTRING_LEN(str1), RSTRING_LEN(str2));
- retval = memcmp(RSTRING_PTR(str1), RSTRING_PTR(str2), len);
+ len = lesser(RSTRING(str1)->len, RSTRING(str2)->len);
+ retval = rb_memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len);
if (retval == 0) {
- if (RSTRING_LEN(str1) == RSTRING_LEN(str2)) {
- if (!enc) {
- if (rb_enc_get(str1) - rb_enc_get(str2) > 0)
- return 1;
- return -1;
- }
- return 0;
- }
- if (RSTRING_LEN(str1) > RSTRING_LEN(str2)) return 1;
+ if (RSTRING(str1)->len == RSTRING(str2)->len) return 0;
+ if (RSTRING(str1)->len > RSTRING(str2)->len) return 1;
return -1;
}
if (retval > 0) return 1;
@@ -1322,8 +942,9 @@ rb_str_cmp(VALUE str1, VALUE str2)
* <code><=></code> <i>obj</i> returns zero.
*/
-VALUE
-rb_str_equal(VALUE str1, VALUE str2)
+static VALUE
+rb_str_equal(str1, str2)
+ VALUE str1, str2;
{
if (str1 == str2) return Qtrue;
if (TYPE(str2) != T_STRING) {
@@ -1332,14 +953,15 @@ rb_str_equal(VALUE str1, VALUE str2)
}
return rb_equal(str2, str1);
}
- if (!rb_str_comparable(str1, str2)) return Qfalse;
- if (RSTRING_LEN(str1) == RSTRING_LEN(str2) &&
+ if (RSTRING(str1)->len == RSTRING(str2)->len &&
rb_str_cmp(str1, str2) == 0) {
return Qtrue;
}
return Qfalse;
}
+#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
+
/*
* call-seq:
* str.eql?(other) => true or false
@@ -1348,14 +970,14 @@ rb_str_equal(VALUE str1, VALUE str2)
*/
static VALUE
-rb_str_eql(VALUE str1, VALUE str2)
+rb_str_eql(str1, str2)
+ VALUE str1, str2;
{
- if (TYPE(str2) != T_STRING || RSTRING_LEN(str1) != RSTRING_LEN(str2))
+ if (TYPE(str2) != T_STRING || RSTRING(str1)->len != RSTRING(str2)->len)
return Qfalse;
- if (!rb_str_comparable(str1, str2)) return Qfalse;
- if (memcmp(RSTRING_PTR(str1), RSTRING_PTR(str2),
- lesser(RSTRING_LEN(str1), RSTRING_LEN(str2))) == 0)
+ if (memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr,
+ lesser(RSTRING(str1)->len, RSTRING(str2)->len)) == 0)
return Qtrue;
return Qfalse;
@@ -1369,7 +991,9 @@ rb_str_eql(VALUE str1, VALUE str2)
* <i>other_str</i> is equal to, and +1 if <i>other_str</i> is greater than
* <i>str</i>. If the strings are of different lengths, and the strings are
* equal when compared up to the shortest length, then the longer string is
- * considered greater than the shorter one. In older versions of Ruby, setting
+ * considered greater than the shorter one. If the variable <code>$=</code> is
+ * <code>false</code>, the comparison is based on comparing the binary values
+ * of each character in the string. In older versions of Ruby, setting
* <code>$=</code> allowed case-insensitive comparisons; this is now deprecated
* in favor of using <code>String#casecmp</code>.
*
@@ -1385,7 +1009,8 @@ rb_str_eql(VALUE str1, VALUE str2)
*/
static VALUE
-rb_str_cmp_m(VALUE str1, VALUE str2)
+rb_str_cmp_m(str1, str2)
+ VALUE str1, str2;
{
long result;
@@ -1425,78 +1050,41 @@ rb_str_cmp_m(VALUE str1, VALUE str2)
*/
static VALUE
-rb_str_casecmp(VALUE str1, VALUE str2)
+rb_str_casecmp(str1, str2)
+ VALUE str1, str2;
{
long len;
- rb_encoding *enc;
- char *p1, *p1end, *p2, *p2end;
+ int retval;
StringValue(str2);
- enc = rb_enc_compatible(str1, str2);
- if (!enc) {
- return rb_str_cmp(str1, str2);
- }
-
- p1 = RSTRING_PTR(str1); p1end = RSTRING_END(p1);
- p2 = RSTRING_PTR(str2); p2end = RSTRING_END(str2);
- while (p1 < p1end && p2 < p2end) {
- int c1 = rb_enc_codepoint(p1, p1end, enc);
- int c2 = rb_enc_codepoint(p2, p2end, enc);
-
- if (c1 != c2) {
- c1 = rb_enc_toupper(c1, enc);
- c2 = rb_enc_toupper(c2, enc);
- if (c1 > c2) return INT2FIX(1);
- if (c1 < c2) return INT2FIX(-1);
- }
- len = rb_enc_codelen(c1, enc);
- p1 += len;
- p2 += len;
+ len = lesser(RSTRING(str1)->len, RSTRING(str2)->len);
+ retval = rb_memcicmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len);
+ if (retval == 0) {
+ if (RSTRING(str1)->len == RSTRING(str2)->len) return INT2FIX(0);
+ if (RSTRING(str1)->len > RSTRING(str2)->len) return INT2FIX(1);
+ return INT2FIX(-1);
}
- if (RSTRING_LEN(str1) == RSTRING_LEN(str2)) return INT2FIX(0);
- if (RSTRING_LEN(str1) > RSTRING_LEN(str2)) return INT2FIX(1);
+ if (retval == 0) return INT2FIX(0);
+ if (retval > 0) return INT2FIX(1);
return INT2FIX(-1);
}
static long
-rb_str_index(VALUE str, VALUE sub, long offset)
+rb_str_index(str, sub, offset)
+ VALUE str, sub;
+ long offset;
{
long pos;
- char *s, *sptr;
- long len, slen;
- rb_encoding *enc;
- enc = rb_enc_check(str, sub);
- if (is_broken_string(sub)) {
- return -1;
- }
- len = str_strlen(str, enc);
- slen = str_strlen(sub, enc);
if (offset < 0) {
- offset += len;
+ offset += RSTRING(str)->len;
if (offset < 0) return -1;
}
- if (len - offset < slen) return -1;
- s = RSTRING_PTR(str);
- if (offset) {
- offset = str_offset(s, RSTRING_END(str), offset, enc, IS_7BIT(str));
- s += offset;
- }
- if (slen == 0) return offset;
- /* need proceed one character at a time */
- sptr = RSTRING_PTR(sub);
- slen = RSTRING_LEN(sub);
- len = RSTRING_LEN(str) - offset;
- for (;;) {
- char *t;
- pos = rb_memsearch(sptr, slen, s, len);
- if (pos < 0) return pos;
- t = rb_enc_right_char_head(s, s+pos, enc);
- if (t == s) break;
- if ((len -= t - s) <= 0) return -1;
- offset += t - s;
- s = t;
- }
+ if (RSTRING(str)->len - offset < RSTRING(sub)->len) return -1;
+ if (RSTRING(sub)->len == 0) return offset;
+ pos = rb_memsearch(RSTRING(sub)->ptr, RSTRING(sub)->len,
+ RSTRING(str)->ptr+offset, RSTRING(str)->len-offset);
+ if (pos < 0) return pos;
return pos + offset;
}
@@ -1520,7 +1108,10 @@ rb_str_index(VALUE str, VALUE sub, long offset)
*/
static VALUE
-rb_str_index_m(int argc, VALUE *argv, VALUE str)
+rb_str_index_m(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE sub;
VALUE initpos;
@@ -1533,7 +1124,7 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
pos = 0;
}
if (pos < 0) {
- pos += str_strlen(str, rb_enc_get(str));
+ pos += RSTRING(str)->len;
if (pos < 0) {
if (TYPE(sub) == T_REGEXP) {
rb_backref_set(Qnil);
@@ -1546,9 +1137,19 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
case T_REGEXP:
pos = rb_reg_adjust_startpos(sub, str, pos, 0);
pos = rb_reg_search(sub, str, pos, 0);
- pos = rb_str_sublen(str, pos);
break;
+ case T_FIXNUM: {
+ int c = FIX2INT(sub);
+ long len = RSTRING(str)->len;
+ unsigned char *p = (unsigned char*)RSTRING(str)->ptr;
+
+ for (;pos<len;pos++) {
+ if (p[pos] == c) return LONG2NUM(pos);
+ }
+ return Qnil;
+ }
+
default: {
VALUE tmp;
@@ -1562,7 +1163,6 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
/* fall through */
case T_STRING:
pos = rb_str_index(str, sub, pos);
- pos = rb_str_sublen(str, pos);
break;
}
@@ -1571,41 +1171,33 @@ rb_str_index_m(int argc, VALUE *argv, VALUE str)
}
static long
-rb_str_rindex(VALUE str, VALUE sub, long pos)
+rb_str_rindex(str, sub, pos)
+ VALUE str, sub;
+ long pos;
{
- long len, slen;
- char *s, *sbeg, *e, *t;
- rb_encoding *enc;
- int asc = IS_7BIT(str);
+ long len = RSTRING(sub)->len;
+ char *s, *sbeg, *t;
- enc = rb_enc_check(str, sub);
- if (is_broken_string(sub)) {
- return -1;
- }
- len = str_strlen(str, enc);
- slen = str_strlen(sub, enc);
/* substring longer than string */
- if (len < slen) return -1;
- if (len - pos < slen) {
- pos = len - slen;
+ if (RSTRING(str)->len < len) return -1;
+ if (RSTRING(str)->len - pos < len) {
+ pos = RSTRING(str)->len - len;
+ }
+ sbeg = RSTRING(str)->ptr;
+ s = RSTRING(str)->ptr + pos;
+ t = RSTRING(sub)->ptr;
+ if (len) {
+ while (sbeg <= s) {
+ if (rb_memcmp(s, t, len) == 0) {
+ return s - RSTRING(str)->ptr;
+ }
+ s--;
+ }
+ return -1;
}
- if (len == 0) {
+ else {
return pos;
}
- sbeg = RSTRING_PTR(str);
- e = RSTRING_END(str);
- t = RSTRING_PTR(sub);
- slen = RSTRING_LEN(sub);
- for (;;) {
- s = str_nth(sbeg, e, pos, enc, asc);
- if (!s) return -1;
- if (memcmp(s, t, slen) == 0) {
- return pos;
- }
- if (pos == 0) break;
- pos--;
- }
- return -1;
}
@@ -1629,17 +1221,19 @@ rb_str_rindex(VALUE str, VALUE sub, long pos)
*/
static VALUE
-rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
+rb_str_rindex_m(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE sub;
- VALUE vpos;
- rb_encoding *enc = rb_enc_get(str);
- long pos, len = str_strlen(str, enc);
+ VALUE position;
+ long pos;
- if (rb_scan_args(argc, argv, "11", &sub, &vpos) == 2) {
- pos = NUM2LONG(vpos);
+ if (rb_scan_args(argc, argv, "11", &sub, &position) == 2) {
+ pos = NUM2LONG(position);
if (pos < 0) {
- pos += len;
+ pos += RSTRING(str)->len;
if (pos < 0) {
if (TYPE(sub) == T_REGEXP) {
rb_backref_set(Qnil);
@@ -1647,19 +1241,17 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
return Qnil;
}
}
- if (pos > len) pos = len;
+ if (pos > RSTRING(str)->len) pos = RSTRING(str)->len;
}
else {
- pos = len;
+ pos = RSTRING(str)->len;
}
switch (TYPE(sub)) {
case T_REGEXP:
- /* enc = rb_get_check(str, sub); */
if (RREGEXP(sub)->len) {
pos = rb_reg_adjust_startpos(sub, str, pos, 1);
pos = rb_reg_search(sub, str, pos, 1);
- pos = rb_str_sublen(str, pos);
}
if (pos >= 0) return LONG2NUM(pos);
break;
@@ -1679,6 +1271,22 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
pos = rb_str_rindex(str, sub, pos);
if (pos >= 0) return LONG2NUM(pos);
break;
+
+ case T_FIXNUM: {
+ int c = FIX2INT(sub);
+ unsigned char *p = (unsigned char*)RSTRING(str)->ptr + pos;
+ unsigned char *pbeg = (unsigned char*)RSTRING(str)->ptr;
+
+ if (pos == RSTRING(str)->len) {
+ if (pos == 0) return Qnil;
+ --p;
+ }
+ while (pbeg <= p) {
+ if (*p == c) return LONG2NUM((char*)p - RSTRING(str)->ptr);
+ p--;
+ }
+ return Qnil;
+ }
}
return Qnil;
}
@@ -1698,7 +1306,8 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_match(VALUE x, VALUE y)
+rb_str_match(x, y)
+ VALUE x, y;
{
switch (TYPE(y)) {
case T_STRING:
@@ -1713,7 +1322,7 @@ rb_str_match(VALUE x, VALUE y)
}
-static VALUE get_pat(VALUE, int);
+static VALUE get_pat _((VALUE, int));
/*
@@ -1721,46 +1330,24 @@ static VALUE get_pat(VALUE, int);
* str.match(pattern) => matchdata or nil
*
* Converts <i>pattern</i> to a <code>Regexp</code> (if it isn't already one),
- * then invokes its <code>match</code> method on <i>str</i>. If the second
- * parameter is present, it specifies the position in the string to begin the
- * search.
+ * then invokes its <code>match</code> method on <i>str</i>.
*
- * 'hello'.match('(.)\1') #=> #<MatchData "ll" "l">
+ * 'hello'.match('(.)\1') #=> #<MatchData:0x401b3d30>
* 'hello'.match('(.)\1')[0] #=> "ll"
* 'hello'.match(/(.)\1/)[0] #=> "ll"
* 'hello'.match('xx') #=> nil
- *
- * If a block is given, invoke the block with MatchData if match succeed, so
- * that you can write
- *
- * str.match(pat) {|m| ...}
- *
- * instead of
- *
- * if m = str.match(pat)
- * ...
- * end
- *
- * The retuen value is a value from block exection in this case.
*/
static VALUE
-rb_str_match_m(int argc, VALUE *argv, VALUE str)
+rb_str_match_m(str, re)
+ VALUE str, re;
{
- VALUE re, result;
- if (argc < 1)
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
- re = argv[0];
- argv[0] = str;
- result = rb_funcall2(get_pat(re, 0), rb_intern("match"), argc, argv);
- if (!NIL_P(result) && rb_block_given_p()) {
- return rb_yield(result);
- }
- return result;
+ return rb_funcall(get_pat(re, 0), rb_intern("match"), 1, str);
}
-static int
-succ_char(char *s)
+static char
+succ_char(s)
+ char *s;
{
char c = *s;
@@ -1783,52 +1370,6 @@ succ_char(char *s)
return 0;
}
-/*
- overwrite +s+ by succeeding letter of +c+ in +enc+ and returns
- carried-out letter. assuming each ranges are successive, and mbclen
- never change in each ranges.
- */
-static int
-enc_succ_char(unsigned int c, char *s, rb_encoding *enc)
-{
- unsigned int cs;
-
- /* numerics */
- if (rb_enc_isdigit(c, enc)) {
- cs = c++;
- if (rb_enc_isdigit(c, enc)) {
- rb_enc_mbcput(c, s, enc);
- return 0;
- }
- do c = cs--; while (rb_enc_isdigit(cs, enc));
- rb_enc_mbcput(c, s, enc);
- return ++c;
- }
- /* small alphabets */
- if (rb_enc_islower(c, enc)) {
- cs = c++;
- if (rb_enc_islower(c, enc)) {
- rb_enc_mbcput(c, s, enc);
- return 0;
- }
- do c = cs--; while (rb_enc_islower(cs, enc));
- rb_enc_mbcput(c, s, enc);
- return c;
- }
- /* capital alphabets */
- if (rb_enc_isupper(c, enc)) {
- cs = c++;
- if (rb_enc_isupper(c, enc)) {
- rb_enc_mbcput(c, s, enc);
- return 0;
- }
- do c = cs--; while (rb_enc_isupper(cs, enc));
- rb_enc_mbcput(c, s, enc);
- return c;
- }
- return -1;
-}
-
/*
* call-seq:
@@ -1855,63 +1396,43 @@ enc_succ_char(unsigned int c, char *s, rb_encoding *enc)
* "***".succ #=> "**+"
*/
-VALUE
-rb_str_succ(VALUE orig)
+static VALUE
+rb_str_succ(orig)
+ VALUE orig;
{
- rb_encoding *enc;
VALUE str;
- char *sbeg, *s, *e;
+ char *sbeg, *s;
int c = -1;
- unsigned int cc = 0;
- long n = 0, o = 0, l;
- char carry[ONIGENC_CODE_TO_MBC_MAXLEN];
+ long n = 0;
- str = rb_str_new5(orig, RSTRING_PTR(orig), RSTRING_LEN(orig));
- rb_enc_copy(str, orig);
+ str = rb_str_new5(orig, RSTRING(orig)->ptr, RSTRING(orig)->len);
OBJ_INFECT(str, orig);
- if (RSTRING_LEN(str) == 0) return str;
-
- enc = rb_enc_get(orig);
- sbeg = RSTRING_PTR(str);
- s = e = sbeg + RSTRING_LEN(str);
-
- while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) {
- if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
- cc = rb_enc_mbc_to_codepoint(s, e, enc);
- if (rb_enc_isalnum(cc, enc)) {
- if (rb_enc_isascii(cc, enc)) {
- if ((c = succ_char(s)) == 0) break;
- }
- else {
- if ((c = enc_succ_char(cc, s, enc)) == 0) break;
- }
+ if (RSTRING(str)->len == 0) return str;
+
+ sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1;
+
+ while (sbeg <= s) {
+ if (ISALNUM(*s)) {
+ if ((c = succ_char(s)) == 0) break;
n = s - sbeg;
}
+ s--;
}
if (c == -1) { /* str contains no alnum */
+ sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1;
c = '\001';
- s = e;
- while ((s = rb_enc_prev_char(sbeg, s, enc)) != 0) {
- int limit = 256;
- if ((l = rb_enc_precise_mbclen(s, e, enc)) <= 0) continue;
- cc = rb_enc_mbc_to_codepoint(s, e, enc);
- while ((l = rb_enc_mbcput(++cc, carry, enc)) < 0 && --limit);
- if (l > 0) {
- if (l == (o = e - s)) goto overlay;
- n = s - sbeg;
- goto insert;
- }
+ while (sbeg <= s) {
+ if ((*s += 1) != 0) break;
+ s--;
}
}
- if (!s && (l = rb_enc_mbcput(c, carry, enc)) > 0) {
- insert:
- RESIZE_CAPA(str, RSTRING_LEN(str) + l - o);
- s = RSTRING_PTR(str) + n;
- memmove(s + l, s + o, RSTRING_LEN(str) - n - o);
- overlay:
- memmove(s, carry, l);
- STR_SET_LEN(str, RSTRING_LEN(str) + l - o);
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
+ if (s < sbeg) {
+ RESIZE_CAPA(str, RSTRING(str)->len + 1);
+ s = RSTRING(str)->ptr + n;
+ memmove(s+1, s, RSTRING(str)->len - n);
+ *s = c;
+ RSTRING(str)->len += 1;
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
}
return str;
@@ -1928,13 +1449,42 @@ rb_str_succ(VALUE orig)
*/
static VALUE
-rb_str_succ_bang(VALUE str)
+rb_str_succ_bang(str)
+ VALUE str;
{
rb_str_shared_replace(str, rb_str_succ(str));
return str;
}
+VALUE
+rb_str_upto(beg, end, excl)
+ VALUE beg, end;
+ int excl;
+{
+ VALUE current, after_end;
+ ID succ = rb_intern("succ");
+ int n;
+
+ StringValue(end);
+ n = rb_str_cmp(beg, end);
+ if (n > 0 || (excl && n == 0)) return beg;
+ after_end = rb_funcall(end, succ, 0, 0);
+ current = beg;
+ while (!rb_str_equal(current, after_end)) {
+ rb_yield(current);
+ if (!excl && rb_str_equal(current, end)) break;
+ current = rb_funcall(current, succ, 0, 0);
+ StringValue(current);
+ if (excl && rb_str_equal(current, end)) break;
+ StringValue(current);
+ if (RSTRING(current)->len > RSTRING(end)->len || RSTRING(current)->len == 0)
+ break;
+ }
+
+ return beg;
+}
+
/*
* call-seq:
@@ -1943,7 +1493,7 @@ rb_str_succ_bang(VALUE str)
* Iterates through successive values, starting at <i>str</i> and
* ending at <i>other_str</i> inclusive, passing each value in turn to
* the block. The <code>String#succ</code> method is used to generate
- * each value. If optional second arguent excle is omitted or is <code>false</code>,
+ * each value. If optional second argument exclusive is omitted or is <code>false</code>,
* the last value will be included; otherwise it will be excluded.
*
* "a8".upto("b6") {|s| print s, ' ' }
@@ -1958,38 +1508,22 @@ rb_str_succ_bang(VALUE str)
*/
static VALUE
-rb_str_upto(int argc, VALUE *argv, VALUE beg)
+rb_str_upto_m(argc, argv, beg)
+ int argc;
+ VALUE *argv;
+ VALUE beg;
{
VALUE end, exclusive;
- VALUE current, after_end;
- ID succ;
- int n, excl;
rb_scan_args(argc, argv, "11", &end, &exclusive);
- rb_enc_check(beg, end);
- excl = RTEST(exclusive);
- succ = rb_intern("succ");
- StringValue(end);
- n = rb_str_cmp(beg, end);
- if (n > 0 || (excl && n == 0)) return beg;
- after_end = rb_funcall(end, succ, 0, 0);
- current = beg;
- while (!rb_str_equal(current, after_end)) {
- rb_yield(current);
- if (!excl && rb_str_equal(current, end)) break;
- current = rb_funcall(current, succ, 0, 0);
- StringValue(current);
- if (excl && rb_str_equal(current, end)) break;
- StringValue(current);
- if (RSTRING_LEN(current) > RSTRING_LEN(end) || RSTRING_LEN(current) == 0)
- break;
- }
- return beg;
+ return rb_str_upto(beg, end, RTEST(exclusive));
}
static VALUE
-rb_str_subpat(VALUE str, VALUE re, int nth)
+rb_str_subpat(str, re, nth)
+ VALUE str, re;
+ int nth;
{
if (rb_reg_search(re, str, 0, 0) >= 0) {
return rb_reg_nth_match(nth, rb_backref_get());
@@ -1998,7 +1532,9 @@ rb_str_subpat(VALUE str, VALUE re, int nth)
}
static VALUE
-rb_str_aref(VALUE str, VALUE indx)
+rb_str_aref(str, indx)
+ VALUE str;
+ VALUE indx;
{
long idx;
@@ -2007,9 +1543,13 @@ rb_str_aref(VALUE str, VALUE indx)
idx = FIX2LONG(indx);
num_index:
- str = rb_str_substr(str, idx, 1);
- if (!NIL_P(str) && RSTRING_LEN(str) == 0) return Qnil;
- return str;
+ if (idx < 0) {
+ idx = RSTRING(str)->len + idx;
+ }
+ if (idx < 0 || RSTRING(str)->len <= idx) {
+ return Qnil;
+ }
+ return INT2FIX(RSTRING(str)->ptr[idx] & 0xff);
case T_REGEXP:
return rb_str_subpat(str, indx, 0);
@@ -2025,14 +1565,14 @@ rb_str_aref(VALUE str, VALUE indx)
long beg, len;
VALUE tmp;
- len = str_strlen(str, rb_enc_get(str));
- switch (rb_range_beg_len(indx, &beg, &len, len, 0)) {
+ switch (rb_range_beg_len(indx, &beg, &len, RSTRING(str)->len, 0)) {
case Qfalse:
break;
case Qnil:
return Qnil;
default:
tmp = rb_str_substr(str, beg, len);
+ OBJ_INFECT(tmp, indx);
return tmp;
}
}
@@ -2045,21 +1585,21 @@ rb_str_aref(VALUE str, VALUE indx)
/*
* call-seq:
- * str[fixnum] => new_str or nil
+ * str[fixnum] => fixnum or nil
* str[fixnum, fixnum] => new_str or nil
* str[range] => new_str or nil
* str[regexp] => new_str or nil
* str[regexp, fixnum] => new_str or nil
* str[other_str] => new_str or nil
- * str.slice(fixnum) => new_str or nil
+ * str.slice(fixnum) => fixnum or nil
* str.slice(fixnum, fixnum) => new_str or nil
* str.slice(range) => new_str or nil
* str.slice(regexp) => new_str or nil
* str.slice(regexp, fixnum) => new_str or nil
* str.slice(other_str) => new_str or nil
*
- * Element Reference---If passed a single <code>Fixnum</code>, returns a
- * substring of one character at that position. If passed two <code>Fixnum</code>
+ * Element Reference---If passed a single <code>Fixnum</code>, returns the code
+ * of the character at that position. If passed two <code>Fixnum</code>
* objects, returns a substring starting at the offset given by the first, and
* a length given by the second. If given a range, a substring containing
* characters at offsets given by the range is returned. In all three cases, if
@@ -2075,7 +1615,7 @@ rb_str_aref(VALUE str, VALUE indx)
* match.
*
* a = "hello there"
- * a[1] #=> "e"
+ * a[1] #=> 101
* a[1,3] #=> "ell"
* a[1..3] #=> "ell"
* a[-3,2] #=> "er"
@@ -2091,7 +1631,10 @@ rb_str_aref(VALUE str, VALUE indx)
*/
static VALUE
-rb_str_aref_m(int argc, VALUE *argv, VALUE str)
+rb_str_aref_m(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
if (argc == 2) {
if (TYPE(argv[0]) == T_REGEXP) {
@@ -2106,83 +1649,70 @@ rb_str_aref_m(int argc, VALUE *argv, VALUE str)
}
static void
-rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
-{
- rb_str_modify(str);
- if (len < RSTRING_LEN(val)) {
- /* expand string */
- RESIZE_CAPA(str, RSTRING_LEN(str) + RSTRING_LEN(val) - len + 1);
- }
-
- if (RSTRING_LEN(val) != len) {
- memmove(RSTRING_PTR(str) + beg + RSTRING_LEN(val),
- RSTRING_PTR(str) + beg + len,
- RSTRING_LEN(str) - (beg + len));
- }
- if (RSTRING_LEN(val) < beg && len < 0) {
- MEMZERO(RSTRING_PTR(str) + RSTRING_LEN(str), char, -len);
- }
- if (RSTRING_LEN(val) > 0) {
- memmove(RSTRING_PTR(str)+beg, RSTRING_PTR(val), RSTRING_LEN(val));
- }
- STR_SET_LEN(str, RSTRING_LEN(str) + RSTRING_LEN(val) - len);
- if (RSTRING_PTR(str)) {
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
- }
- OBJ_INFECT(str, val);
-}
-
-static void
-rb_str_splice(VALUE str, long beg, long len, VALUE val)
+rb_str_splice(str, beg, len, val)
+ VALUE str;
+ long beg, len;
+ VALUE val;
{
- long slen;
- char *p, *e;
- rb_encoding *enc;
- int asc = IS_7BIT(str);
-
if (len < 0) rb_raise(rb_eIndexError, "negative length %ld", len);
StringValue(val);
rb_str_modify(str);
- enc = rb_enc_check(str, val);
- slen = str_strlen(str, enc);
- if (slen < beg) {
+ if (RSTRING(str)->len < beg) {
out_of_range:
rb_raise(rb_eIndexError, "index %ld out of string", beg);
}
if (beg < 0) {
- if (-beg > slen) {
+ if (-beg > RSTRING(str)->len) {
goto out_of_range;
}
- beg += slen;
+ beg += RSTRING(str)->len;
+ }
+ if (RSTRING(str)->len < len || RSTRING(str)->len < beg + len) {
+ len = RSTRING(str)->len - beg;
+ }
+
+ if (len < RSTRING(val)->len) {
+ /* expand string */
+ RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1);
+ }
+
+ if (RSTRING(val)->len != len) {
+ memmove(RSTRING(str)->ptr + beg + RSTRING(val)->len,
+ RSTRING(str)->ptr + beg + len,
+ RSTRING(str)->len - (beg + len));
}
- if (slen < len || slen < beg + len) {
- len = slen - beg;
+ if (RSTRING(str)->len < beg && len < 0) {
+ MEMZERO(RSTRING(str)->ptr + RSTRING(str)->len, char, -len);
}
- p = str_nth(RSTRING_PTR(str), RSTRING_END(str), beg, enc, asc);
- if (!p) p = RSTRING_END(str);
- e = str_nth(p, RSTRING_END(str), len, enc, asc);
- if (!e) e = RSTRING_END(str);
- /* error check */
- beg = p - RSTRING_PTR(str); /* physical position */
- len = e - p; /* physical length */
- rb_str_splice_0(str, beg, len, val);
- rb_enc_associate(str, enc);
+ if (RSTRING(val)->len > 0) {
+ memmove(RSTRING(str)->ptr+beg, RSTRING(val)->ptr, RSTRING(val)->len);
+ }
+ RSTRING(str)->len += RSTRING(val)->len - len;
+ if (RSTRING(str)->ptr) {
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
+ }
+ OBJ_INFECT(str, val);
}
void
-rb_str_update(VALUE str, long beg, long len, VALUE val)
+rb_str_update(str, beg, len, val)
+ VALUE str;
+ long beg, len;
+ VALUE val;
{
rb_str_splice(str, beg, len, val);
}
static void
-rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
+rb_str_subpat_set(str, re, nth, val)
+ VALUE str, re;
+ int nth;
+ VALUE val;
{
VALUE match;
long start, end, len;
- rb_encoding *enc;
if (rb_reg_search(re, str, 0, 0) < 0) {
rb_raise(rb_eIndexError, "regexp not matched");
@@ -2205,14 +1735,13 @@ rb_str_subpat_set(VALUE str, VALUE re, int nth, VALUE val)
}
end = RMATCH(match)->END(nth);
len = end - start;
- StringValue(val);
- enc = rb_enc_check(str, val);
- rb_str_splice_0(str, start, len, val);
- rb_enc_associate(str, enc);
+ rb_str_splice(str, start, len, val);
}
static VALUE
-rb_str_aset(VALUE str, VALUE indx, VALUE val)
+rb_str_aset(str, indx, val)
+ VALUE str;
+ VALUE indx, val;
{
long idx, beg;
@@ -2220,7 +1749,26 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
case T_FIXNUM:
idx = FIX2LONG(indx);
num_index:
- rb_str_splice(str, idx, 1, val);
+ if (RSTRING(str)->len <= idx) {
+ out_of_range:
+ rb_raise(rb_eIndexError, "index %ld out of string", idx);
+ }
+ if (idx < 0) {
+ if (-idx > RSTRING(str)->len)
+ goto out_of_range;
+ idx += RSTRING(str)->len;
+ }
+ if (FIXNUM_P(val)) {
+ rb_str_modify(str);
+ if (RSTRING(str)->len == idx) {
+ RSTRING(str)->len += 1;
+ RESIZE_CAPA(str, RSTRING(str)->len);
+ }
+ RSTRING(str)->ptr[idx] = FIX2INT(val) & 0xff;
+ }
+ else {
+ rb_str_splice(str, idx, 1, val);
+ }
return val;
case T_REGEXP:
@@ -2232,15 +1780,14 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
if (beg < 0) {
rb_raise(rb_eIndexError, "string not matched");
}
- beg = rb_str_sublen(str, beg);
- rb_str_splice(str, beg, str_strlen(indx, 0), val);
+ rb_str_splice(str, beg, RSTRING(indx)->len, val);
return val;
default:
/* check if indx is Range */
{
long beg, len;
- if (rb_range_beg_len(indx, &beg, &len, str_strlen(str, 0), 2)) {
+ if (rb_range_beg_len(indx, &beg, &len, RSTRING(str)->len, 2)) {
rb_str_splice(str, beg, len, val);
return val;
}
@@ -2252,6 +1799,7 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
/*
* call-seq:
+ * str[fixnum] = fixnum
* str[fixnum] = new_str
* str[fixnum, fixnum] = new_str
* str[range] = aString
@@ -2275,7 +1823,10 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
*/
static VALUE
-rb_str_aset_m(int argc, VALUE *argv, VALUE str)
+rb_str_aset_m(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
if (argc == 3) {
if (TYPE(argv[0]) == T_REGEXP) {
@@ -2310,12 +1861,13 @@ rb_str_aset_m(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_insert(VALUE str, VALUE idx, VALUE str2)
+rb_str_insert(str, idx, str2)
+ VALUE str, idx, str2;
{
long pos = NUM2LONG(idx);
if (pos == -1) {
- return rb_str_append(str, str2);
+ pos = RSTRING(str)->len;
}
else if (pos < 0) {
pos++;
@@ -2324,7 +1876,6 @@ rb_str_insert(VALUE str, VALUE idx, VALUE str2)
return str;
}
-
/*
* call-seq:
* str.slice!(fixnum) => fixnum or nil
@@ -2334,7 +1885,10 @@ rb_str_insert(VALUE str, VALUE idx, VALUE str2)
* str.slice!(other_str) => new_str or nil
*
* Deletes the specified portion from <i>str</i>, and returns the portion
- * deleted.
+ * deleted. The forms that take a <code>Fixnum</code> will raise an
+ * <code>IndexError</code> if the value is out of range; the <code>Range</code>
+ * form will raise a <code>RangeError</code>, and the <code>Regexp</code> and
+ * <code>String</code> forms will silently ignore the assignment.
*
* string = "this is a string"
* string.slice!(2) #=> 105
@@ -2345,7 +1899,10 @@ rb_str_insert(VALUE str, VALUE idx, VALUE str2)
*/
static VALUE
-rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
+rb_str_slice_bang(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE result;
VALUE buf[3];
@@ -2357,7 +1914,6 @@ rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
for (i=0; i<argc; i++) {
buf[i] = argv[i];
}
- rb_str_modify(str);
buf[i] = rb_str_new(0,0);
result = rb_str_aref_m(argc, buf, str);
if (!NIL_P(result)) {
@@ -2367,7 +1923,9 @@ rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
}
static VALUE
-get_pat(VALUE pat, int quote)
+get_pat(pat, quote)
+ VALUE pat;
+ int quote;
{
VALUE val;
@@ -2393,6 +1951,30 @@ get_pat(VALUE pat, int quote)
return rb_reg_regcomp(pat);
}
+static VALUE
+get_pat_quoted(pat)
+ VALUE pat;
+{
+ return get_pat(pat, 1);
+}
+
+static VALUE
+regcomp_failed(str)
+ VALUE str;
+{
+ rb_raise(rb_eArgError, "invalid byte sequence");
+ /*NOTREACHED*/
+ return Qundef;
+}
+
+static VALUE
+get_arg_pat(pat, quote)
+ VALUE pat;
+{
+ return rb_rescue2(get_pat_quoted, pat,
+ regcomp_failed, pat,
+ rb_eRegexpError, (VALUE)0);
+}
/*
* call-seq:
@@ -2405,7 +1987,10 @@ get_pat(VALUE pat, int quote)
*/
static VALUE
-rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
+rb_str_sub_bang(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE pat, repl, match;
struct re_registers *regs;
@@ -2427,41 +2012,36 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
pat = get_pat(argv[0], 1);
if (rb_reg_search(pat, str, 0, 0) >= 0) {
- rb_encoding *enc;
-
match = rb_backref_get();
regs = RMATCH(match)->regs;
if (iter) {
- char *p = RSTRING_PTR(str); long len = RSTRING_LEN(str);
+ char *p = RSTRING(str)->ptr; long len = RSTRING(str)->len;
rb_match_busy(match);
repl = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
- enc = rb_enc_check(str, repl);
str_mod_check(str, p, len);
str_frozen_check(str);
rb_backref_set(match);
}
else {
- repl = rb_reg_regsub(repl, str, regs, pat);
- enc = rb_enc_check(str, repl);
+ repl = rb_reg_regsub(repl, str, regs);
}
rb_str_modify(str);
- rb_enc_associate(str, enc);
if (OBJ_TAINTED(repl)) tainted = 1;
plen = END(0) - BEG(0);
- if (RSTRING_LEN(repl) > plen) {
- RESIZE_CAPA(str, RSTRING_LEN(str) + RSTRING_LEN(repl) - plen);
- }
- if (RSTRING_LEN(repl) != plen) {
- memmove(RSTRING_PTR(str) + BEG(0) + RSTRING_LEN(repl),
- RSTRING_PTR(str) + BEG(0) + plen,
- RSTRING_LEN(str) - BEG(0) - plen);
- }
- memcpy(RSTRING_PTR(str) + BEG(0),
- RSTRING_PTR(repl), RSTRING_LEN(repl));
- STR_SET_LEN(str, RSTRING_LEN(str) + RSTRING_LEN(repl) - plen);
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
+ if (RSTRING(repl)->len > plen) {
+ RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(repl)->len - plen);
+ }
+ if (RSTRING(repl)->len != plen) {
+ memmove(RSTRING(str)->ptr + BEG(0) + RSTRING(repl)->len,
+ RSTRING(str)->ptr + BEG(0) + plen,
+ RSTRING(str)->len - BEG(0) - plen);
+ }
+ memcpy(RSTRING(str)->ptr + BEG(0),
+ RSTRING(repl)->ptr, RSTRING(repl)->len);
+ RSTRING(str)->len += RSTRING(repl)->len - plen;
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
if (tainted) OBJ_TAINT(str);
return str;
@@ -2485,7 +2065,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
* If the method call specifies <i>replacement</i>, special variables such as
* <code>$&</code> will not be useful, as substitution into the string occurs
* before the pattern match starts. However, the sequences <code>\1</code>,
- * <code>\2</code>, <code>\k<group_name></code>, etc., may be used.
+ * <code>\2</code>, etc., may be used.
*
* In the block form, the current match string is passed in as a parameter, and
* variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
@@ -2495,14 +2075,16 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
* The result inherits any tainting in the original string or any supplied
* replacement string.
*
- * "hello".sub(/[aeiou]/, '*') #=> "h*llo"
- * "hello".sub(/([aeiou])/, '<\1>') #=> "h<e>llo"
- * "hello".sub(/./) {|s| s[0].to_s + ' ' } #=> "104 ello"
- * "hello".sub(/(?<foo>[aeiou])/, '*\k<foo>*') #=> "h*e*llo"
+ * "hello".sub(/[aeiou]/, '*') #=> "h*llo"
+ * "hello".sub(/([aeiou])/, '<\1>') #=> "h<e>llo"
+ * "hello".sub(/./) {|s| s[0].to_s + ' ' } #=> "104 ello"
*/
static VALUE
-rb_str_sub(int argc, VALUE *argv, VALUE str)
+rb_str_sub(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_sub_bang(argc, argv, str);
@@ -2510,7 +2092,11 @@ rb_str_sub(int argc, VALUE *argv, VALUE str)
}
static VALUE
-str_gsub(int argc, VALUE *argv, VALUE str, int bang)
+str_gsub(argc, argv, str, bang)
+ int argc;
+ VALUE *argv;
+ VALUE str;
+ int bang;
{
VALUE pat, val, repl, match, dest;
struct re_registers *regs;
@@ -2519,24 +2105,21 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
int iter = 0;
char *buf, *bp, *sp, *cp;
int tainted = 0;
- rb_encoding *enc;
-
- switch (argc) {
- case 1:
- RETURN_ENUMERATOR(str, argc, argv);
+
+ if (argc == 1) {
+ RETURN_ENUMERATOR(str, argc, argv);
iter = 1;
- break;
- case 2:
+ }
+ else if (argc == 2) {
repl = argv[1];
StringValue(repl);
if (OBJ_TAINTED(repl)) tainted = 1;
- break;
- default:
+ }
+ else {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
}
pat = get_pat(argv[0], 1);
- enc = rb_enc_get(pat);
offset=0; n=0;
beg = rb_reg_search(pat, str, 0, 0);
if (beg < 0) {
@@ -2544,100 +2127,92 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
return rb_str_dup(str);
}
- blen = RSTRING_LEN(str) + 30; /* len + margin */
+ blen = RSTRING(str)->len + 30; /* len + margin */
dest = str_new(0, 0, blen);
- buf = RSTRING_PTR(dest);
+ buf = RSTRING(dest)->ptr;
bp = buf;
- sp = cp = RSTRING_PTR(str);
- slen = RSTRING_LEN(str);
+ sp = cp = RSTRING(str)->ptr;
+ slen = RSTRING(str)->len;
rb_str_locktmp(dest);
- do {
- rb_encoding *enc;
-
+ while (beg >= 0) {
n++;
match = rb_backref_get();
regs = RMATCH(match)->regs;
if (iter) {
-
rb_match_busy(match);
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
- enc = rb_enc_check(str, val);
str_mod_check(str, sp, slen);
if (bang) str_frozen_check(str);
- if (val == dest) { /* paranoid chack [ruby-dev:24827] */
+ if (val == dest) { /* paranoid chack [ruby-dev:24827] */
rb_raise(rb_eRuntimeError, "block should not cheat");
}
rb_backref_set(match);
}
else {
- val = rb_reg_regsub(repl, str, regs, pat);
- enc = rb_enc_check(str, val);
+ val = rb_reg_regsub(repl, str, regs);
}
- rb_enc_associate(str, enc);
if (OBJ_TAINTED(val)) tainted = 1;
- len = (bp - buf) + (beg - offset) + RSTRING_LEN(val) + 3;
+ len = (bp - buf) + (beg - offset) + RSTRING(val)->len + 3;
if (blen < len) {
while (blen < len) blen *= 2;
len = bp - buf;
RESIZE_CAPA(dest, blen);
- STR_SET_LEN(dest, blen);
- buf = RSTRING_PTR(dest);
+ RSTRING(dest)->len = blen;
+ buf = RSTRING(dest)->ptr;
bp = buf + len;
}
len = beg - offset; /* copy pre-match substr */
memcpy(bp, cp, len);
bp += len;
- memcpy(bp, RSTRING_PTR(val), RSTRING_LEN(val));
- bp += RSTRING_LEN(val);
+ memcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);
+ bp += RSTRING(val)->len;
offset = END(0);
if (BEG(0) == END(0)) {
/*
* Always consume at least one character of the input string
* in order to prevent infinite loops.
*/
- if (RSTRING_LEN(str) <= END(0)) break;
- len = rb_enc_mbclen(RSTRING_PTR(str)+END(0), RSTRING_END(str), enc);
- memcpy(bp, RSTRING_PTR(str)+END(0), len);
+ if (RSTRING(str)->len <= END(0)) break;
+ len = mbclen2(RSTRING(str)->ptr[END(0)], pat);
+ memcpy(bp, RSTRING(str)->ptr+END(0), len);
bp += len;
offset = END(0) + len;
}
- cp = RSTRING_PTR(str) + offset;
- if (offset > RSTRING_LEN(str)) break;
+ cp = RSTRING(str)->ptr + offset;
+ if (offset > RSTRING(str)->len) break;
beg = rb_reg_search(pat, str, offset, 0);
- } while (beg >= 0);
- if (RSTRING_LEN(str) > offset) {
+ }
+ if (RSTRING(str)->len > offset) {
len = bp - buf;
- if (blen - len < RSTRING_LEN(str) - offset) {
- blen = len + RSTRING_LEN(str) - offset;
+ if (blen - len < RSTRING(str)->len - offset) {
+ blen = len + RSTRING(str)->len - offset;
RESIZE_CAPA(dest, blen);
- buf = RSTRING_PTR(dest);
+ buf = RSTRING(dest)->ptr;
bp = buf + len;
}
- memcpy(bp, cp, RSTRING_LEN(str) - offset);
- bp += RSTRING_LEN(str) - offset;
+ memcpy(bp, cp, RSTRING(str)->len - offset);
+ bp += RSTRING(str)->len - offset;
}
rb_backref_set(match);
*bp = '\0';
rb_str_unlocktmp(dest);
if (bang) {
- if (str_independent(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
+ if (str_independent(str)) {
+ free(RSTRING(str)->ptr);
}
- STR_SET_NOEMBED(str);
- STR_UNSET_NOCAPA(str);
- RSTRING(str)->as.heap.ptr = buf;
- RSTRING(str)->as.heap.aux.capa = blen;
- RSTRING(dest)->as.heap.ptr = 0;
- RSTRING(dest)->as.heap.len = 0;
+ FL_UNSET(str, STR_NOCAPA);
+ RSTRING(str)->ptr = buf;
+ RSTRING(str)->aux.capa = blen;
+ RSTRING(dest)->ptr = 0;
+ RSTRING(dest)->len = 0;
}
else {
RBASIC(dest)->klass = rb_obj_class(str);
OBJ_INFECT(dest, str);
- rb_enc_copy(dest, str);
str = dest;
}
- STR_SET_LEN(str, bp - buf);
+ RSTRING(str)->len = bp - buf;
if (tainted) OBJ_TAINT(str);
return str;
@@ -2654,7 +2229,10 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
*/
static VALUE
-rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
+rb_str_gsub_bang(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
return str_gsub(argc, argv, str, 1);
}
@@ -2675,9 +2253,8 @@ rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
* If a string is used as the replacement, special variables from the match
* (such as <code>$&</code> and <code>$1</code>) cannot be substituted into it,
* as substitution into the string occurs before the pattern match
- * starts. However, the sequences <code>\1</code>, <code>\2</code>,
- * <code>\k<group_name></code>, and so on may be used to interpolate
- * successive groups in the match.
+ * starts. However, the sequences <code>\1</code>, <code>\2</code>, and so on
+ * may be used to interpolate successive groups in the match.
*
* In the block form, the current match string is passed in as a parameter, and
* variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
@@ -2687,14 +2264,16 @@ rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
* The result inherits any tainting in the original string or any supplied
* replacement string.
*
- * "hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
- * "hello".gsub(/([aeiou])/, '<\1>') #=> "h<e>ll<o>"
- * "hello".gsub(/./) {|s| s[0].to_s + ' '} #=> "104 101 108 108 111 "
- * "hello".gsub(/(?<foo>[aeiou])/, '{\k<foo>}') #=> "h{e}ll{o}"
+ * "hello".gsub(/[aeiou]/, '*') #=> "h*ll*"
+ * "hello".gsub(/([aeiou])/, '<\1>') #=> "h<e>ll<o>"
+ * "hello".gsub(/./) {|s| s[0].to_s + ' '} #=> "104 101 108 108 111 "
*/
static VALUE
-rb_str_gsub(int argc, VALUE *argv, VALUE str)
+rb_str_gsub(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
return str_gsub(argc, argv, str, 0);
}
@@ -2712,125 +2291,132 @@ rb_str_gsub(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_replace(VALUE str, VALUE str2)
+rb_str_replace(str, str2)
+ VALUE str, str2;
{
- long len;
if (str == str2) return str;
StringValue(str2);
- len = RSTRING_LEN(str2);
- if (STR_SHARED_P(str2)) {
- if (str_independent(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
- }
- STR_SET_NOEMBED(str);
- RSTRING(str)->as.heap.len = len;
- RSTRING(str)->as.heap.ptr = RSTRING_PTR(str2);
+ if (FL_TEST(str2, ELTS_SHARED)) {
+ if (str_independent(str)) {
+ free(RSTRING(str)->ptr);
+ }
+ RSTRING(str)->len = RSTRING(str2)->len;
+ RSTRING(str)->ptr = RSTRING(str2)->ptr;
FL_SET(str, ELTS_SHARED);
FL_UNSET(str, STR_ASSOC);
- RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
- }
- else if (STR_ASSOC_P(str2)) {
- rb_str_modify(str);
- STR_SET_NOEMBED(str);
- RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1);
- memcpy(RSTRING_PTR(str), RSTRING_PTR(str2), len+1);
- FL_SET(str, STR_ASSOC);
- RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
+ RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
else {
rb_str_modify(str);
- rb_str_resize(str, len);
- memcpy(RSTRING_PTR(str), RSTRING_PTR(str2), len+1);
+ rb_str_resize(str, RSTRING(str2)->len);
+ memcpy(RSTRING(str)->ptr, RSTRING(str2)->ptr, RSTRING(str2)->len);
+ if (FL_TEST(str2, STR_ASSOC)) {
+ FL_SET(str, STR_ASSOC);
+ RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
+ }
}
OBJ_INFECT(str, str2);
- rb_enc_copy(str, str2);
return str;
}
+static VALUE
+uscore_get()
+{
+ VALUE line;
+
+ line = rb_lastline_get();
+ if (TYPE(line) != T_STRING) {
+ rb_raise(rb_eTypeError, "$_ value need to be String (%s given)",
+ NIL_P(line) ? "nil" : rb_obj_classname(line));
+ }
+ return line;
+}
+
/*
* call-seq:
- * string.clear -> string
- *
- * Makes string empty.
- *
- * a = "abcde"
- * a.clear #=> ""
+ * sub!(pattern, replacement) => $_ or nil
+ * sub!(pattern) {|...| block } => $_ or nil
+ *
+ * Equivalent to <code>$_.sub!(<i>args</i>)</code>.
*/
static VALUE
-rb_str_clear(VALUE str)
+rb_f_sub_bang(argc, argv)
+ int argc;
+ VALUE *argv;
{
- /* rb_str_modify() */ /* no need for str_make_independent */
- if (str_independent(str) && !STR_EMBED_P(str)) {
- free(RSTRING_PTR(str));
- }
- STR_SET_EMBED(str);
- STR_SET_EMBED_LEN(str, 0);
- RSTRING_PTR(str)[0] = 0;
- return str;
+ return rb_str_sub_bang(argc, argv, uscore_get());
}
/*
* call-seq:
- * string.chr -> string
- *
- * Returns a one-character string at the beginning of the string.
- *
- * a = "abcde"
- * a.chr #=> "a"
+ * sub(pattern, replacement) => $_
+ * sub(pattern) { block } => $_
+ *
+ * Equivalent to <code>$_.sub(<i>args</i>)</code>, except that
+ * <code>$_</code> will be updated if substitution occurs.
*/
static VALUE
-rb_str_chr(VALUE str)
+rb_f_sub(argc, argv)
+ int argc;
+ VALUE *argv;
{
- return rb_str_substr(str, 0, 1);
+ VALUE str = rb_str_dup(uscore_get());
+
+ if (NIL_P(rb_str_sub_bang(argc, argv, str)))
+ return str;
+ rb_lastline_set(str);
+ return str;
}
/*
* call-seq:
- * str.reverse => new_str
+ * gsub!(pattern, replacement) => string or nil
+ * gsub!(pattern) {|...| block } => string or nil
*
- * Returns a new string with the characters from <i>str</i> in reverse order.
+ * Equivalent to <code>Kernel::gsub</code>, except <code>nil</code> is
+ * returned if <code>$_</code> is not modified.
*
- * "stressed".reverse #=> "desserts"
+ * $_ = "quick brown fox"
+ * gsub! /cat/, '*' #=> nil
+ * $_ #=> "quick brown fox"
*/
static VALUE
-rb_str_reverse(VALUE str)
+rb_f_gsub_bang(argc, argv)
+ int argc;
+ VALUE *argv;
{
- rb_encoding *enc;
- VALUE obj;
- char *s, *e, *p;
-
- if (RSTRING_LEN(str) <= 1) return rb_str_dup(str);
- enc = rb_enc_get(str);
- obj = rb_str_new5(str, 0, RSTRING_LEN(str));
- s = RSTRING_PTR(str); e = RSTRING_END(str);
- p = RSTRING_END(obj);
+ return rb_str_gsub_bang(argc, argv, uscore_get());
+}
- if (RSTRING_LEN(str) > 1) {
- if (rb_enc_mbmaxlen(enc) == 1) {
- while (s < e) {
- *--p = *s++;
- }
- }
- else {
- while (s < e) {
- int clen = rb_enc_mbclen(s, e, enc);
+/*
+ * call-seq:
+ * gsub(pattern, replacement) => string
+ * gsub(pattern) {|...| block } => string
+ *
+ * Equivalent to <code>$_.gsub...</code>, except that <code>$_</code>
+ * receives the modified result.
+ *
+ * $_ = "quick brown fox"
+ * gsub /[aeiou]/, '*' #=> "q**ck br*wn f*x"
+ * $_ #=> "q**ck br*wn f*x"
+ */
- p -= clen;
- memcpy(p, s, clen);
- s += clen;
- }
- }
- }
- STR_SET_LEN(obj, RSTRING_LEN(str));
- OBJ_INFECT(obj, str);
- rb_enc_associate(obj, enc);
+static VALUE
+rb_f_gsub(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE str = rb_str_dup(uscore_get());
- return obj;
+ if (NIL_P(rb_str_gsub_bang(argc, argv, str)))
+ return str;
+ rb_lastline_set(str);
+ return str;
}
@@ -2842,25 +2428,20 @@ rb_str_reverse(VALUE str)
*/
static VALUE
-rb_str_reverse_bang(VALUE str)
+rb_str_reverse_bang(str)
+ VALUE str;
{
- rb_encoding *enc = rb_enc_get(str);
- char *s, *e, c;
+ char *s, *e;
+ char c;
- if (RSTRING_LEN(str) > 1) {
+ if (RSTRING(str)->len > 1) {
rb_str_modify(str);
- s = RSTRING_PTR(str);
- e = RSTRING_END(str) - 1;
-
- if (rb_enc_mbmaxlen(enc) == 1) {
- while (s < e) {
- c = *s;
- *s++ = *e;
- *e-- = c;
- }
- }
- else {
- rb_str_shared_replace(str, rb_str_reverse(str));
+ s = RSTRING(str)->ptr;
+ e = s + RSTRING(str)->len - 1;
+ while (s < e) {
+ c = *s;
+ *s++ = *e;
+ *e-- = c;
}
}
return str;
@@ -2869,6 +2450,37 @@ rb_str_reverse_bang(VALUE str)
/*
* call-seq:
+ * str.reverse => new_str
+ *
+ * Returns a new string with the characters from <i>str</i> in reverse order.
+ *
+ * "stressed".reverse #=> "desserts"
+ */
+
+static VALUE
+rb_str_reverse(str)
+ VALUE str;
+{
+ VALUE obj;
+ char *s, *e, *p;
+
+ if (RSTRING(str)->len <= 1) return rb_str_dup(str);
+
+ obj = rb_str_new5(str, 0, RSTRING(str)->len);
+ s = RSTRING(str)->ptr; e = s + RSTRING(str)->len - 1;
+ p = RSTRING(obj)->ptr;
+
+ while (e >= s) {
+ *p++ = *e--;
+ }
+ OBJ_INFECT(obj, str);
+
+ return obj;
+}
+
+
+/*
+ * call-seq:
* str.include? other_str => true or false
* str.include? fixnum => true or false
*
@@ -2881,10 +2493,17 @@ rb_str_reverse_bang(VALUE str)
*/
static VALUE
-rb_str_include(VALUE str, VALUE arg)
+rb_str_include(str, arg)
+ VALUE str, arg;
{
long i;
+ if (FIXNUM_P(arg)) {
+ if (memchr(RSTRING(str)->ptr, FIX2INT(arg), RSTRING(str)->len))
+ return Qtrue;
+ return Qfalse;
+ }
+
StringValue(arg);
i = rb_str_index(str, arg, 0);
@@ -2915,7 +2534,10 @@ rb_str_include(VALUE str, VALUE arg)
*/
static VALUE
-rb_str_to_i(int argc, VALUE *argv, VALUE str)
+rb_str_to_i(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE b;
int base;
@@ -2925,7 +2547,7 @@ rb_str_to_i(int argc, VALUE *argv, VALUE str)
else base = NUM2INT(b);
if (base < 0) {
- rb_raise(rb_eArgError, "invalid radix %d", base);
+ rb_raise(rb_eArgError, "illegal radix %d", base);
}
return rb_str_to_inum(str, base, Qfalse);
}
@@ -2946,9 +2568,10 @@ rb_str_to_i(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_to_f(VALUE str)
+rb_str_to_f(str)
+ VALUE str;
{
- return DOUBLE2NUM(rb_str_to_dbl(str, Qfalse));
+ return rb_float_new(rb_str_to_dbl(str, Qfalse));
}
@@ -2961,7 +2584,8 @@ rb_str_to_f(VALUE str)
*/
static VALUE
-rb_str_to_s(VALUE str)
+rb_str_to_s(str)
+ VALUE str;
{
if (rb_obj_class(str) != rb_cString) {
VALUE dup = str_alloc(rb_cString);
@@ -2971,116 +2595,85 @@ rb_str_to_s(VALUE str)
return str;
}
-static void
-str_cat_char(VALUE str, int c, rb_encoding *enc)
-{
- char s[16];
- int n = rb_enc_codelen(c, enc);
-
- rb_enc_mbcput(c, s, enc);
- rb_str_buf_cat(str, s, n);
-}
-
-static void
-prefix_escape(VALUE str, int c, rb_encoding *enc)
-{
- str_cat_char(str, '\\', enc);
- str_cat_char(str, c, enc);
-}
-
/*
* call-seq:
* str.inspect => string
*
- * Returns a printable version of _str_, srrounded by quote marks,
- * with special characters escaped.
+ * Returns a printable version of _str_, with special characters
+ * escaped.
*
* str = "hello"
- * str[3] = "\b"
- * str.inspect #=> "\"hel\bo\""
+ * str[3] = 8
+ * str.inspect #=> "hel\010o"
*/
VALUE
-rb_str_inspect(VALUE str)
+rb_str_inspect(str)
+ VALUE str;
{
- rb_encoding *enc = rb_enc_get(str);
char *p, *pend;
- VALUE result = rb_str_buf_new2("");
+ VALUE result = rb_str_buf_new2("\"");
+ char s[5];
- rb_enc_associate(result, enc);
- str_cat_char(result, '"', enc);
- p = RSTRING_PTR(str); pend = RSTRING_END(str);
+ p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
while (p < pend) {
- int c;
- int n;
- int cc;
-
- n = rb_enc_precise_mbclen(p, pend, enc);
- if (!MBCLEN_CHARFOUND(n)) {
- p++;
- n = 1;
- goto escape_codepoint;
- }
-
- c = rb_enc_codepoint(p, pend, enc);
- n = rb_enc_codelen(c, enc);
-
- p += n;
- if (c == '"'|| c == '\\' ||
- (c == '#' && p < pend &&
- (cc = rb_enc_codepoint(p,pend,enc),
- (cc == '$' || cc == '@' || cc == '{')))) {
- prefix_escape(result, c, enc);
+ char c = *p++;
+ if (ismbchar(c) && p < pend) {
+ int len = mbclen(c);
+ rb_str_buf_cat(result, p - 1, len);
+ p += len - 1;
+ }
+ else if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) {
+ s[0] = '\\'; s[1] = c;
+ rb_str_buf_cat(result, s, 2);
+ }
+ else if (ISPRINT(c)) {
+ s[0] = c;
+ rb_str_buf_cat(result, s, 1);
}
else if (c == '\n') {
- prefix_escape(result, 'n', enc);
+ s[0] = '\\'; s[1] = 'n';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == '\r') {
- prefix_escape(result, 'r', enc);
+ s[0] = '\\'; s[1] = 'r';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == '\t') {
- prefix_escape(result, 't', enc);
+ s[0] = '\\'; s[1] = 't';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == '\f') {
- prefix_escape(result, 'f', enc);
+ s[0] = '\\'; s[1] = 'f';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == '\013') {
- prefix_escape(result, 'v', enc);
+ s[0] = '\\'; s[1] = 'v';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == '\010') {
- prefix_escape(result, 'b', enc);
+ s[0] = '\\'; s[1] = 'b';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == '\007') {
- prefix_escape(result, 'a', enc);
+ s[0] = '\\'; s[1] = 'a';
+ rb_str_buf_cat(result, s, 2);
}
else if (c == 033) {
- prefix_escape(result, 'e', enc);
- }
- else if (rb_enc_isprint(c, enc)) {
- rb_str_buf_cat(result, p-n, n);
+ s[0] = '\\'; s[1] = 'e';
+ rb_str_buf_cat(result, s, 2);
}
else {
- char buf[5];
- char *s;
- char *q;
-
-escape_codepoint:
- for (q = p-n; q < p; q++) {
- s = buf;
- sprintf(buf, "\\x%02X", *q & 0377);
- while (*s) {
- str_cat_char(result, *s++, enc);
- }
- }
+ sprintf(s, "\\%03o", c & 0377);
+ rb_str_buf_cat2(result, s);
}
}
- str_cat_char(result, '"', enc);
+ rb_str_buf_cat2(result, "\"");
OBJ_INFECT(result, str);
return result;
}
-#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
/*
* call-seq:
@@ -3091,16 +2684,16 @@ escape_codepoint:
*/
VALUE
-rb_str_dump(VALUE str)
+rb_str_dump(str)
+ VALUE str;
{
- rb_encoding *enc = rb_enc_from_index(0);
long len;
char *p, *pend;
char *q, *qend;
VALUE result;
len = 2; /* "" */
- p = RSTRING_PTR(str); pend = p + RSTRING_LEN(str);
+ p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
while (p < pend) {
char c = *p++;
switch (c) {
@@ -3116,7 +2709,7 @@ rb_str_dump(VALUE str)
break;
default:
- if (rb_enc_isprint(c, enc)) {
+ if (ISPRINT(c)) {
len++;
}
else {
@@ -3127,8 +2720,8 @@ rb_str_dump(VALUE str)
}
result = rb_str_new5(str, 0, len);
- p = RSTRING_PTR(str); pend = p + RSTRING_LEN(str);
- q = RSTRING_PTR(result); qend = q + len;
+ p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
+ q = RSTRING(result)->ptr; qend = q + len;
*q++ = '"';
while (p < pend) {
@@ -3142,6 +2735,9 @@ rb_str_dump(VALUE str)
if (IS_EVSTR(p, pend)) *q++ = '\\';
*q++ = '#';
}
+ else if (ISPRINT(c)) {
+ *q++ = c;
+ }
else if (c == '\n') {
*q++ = '\\';
*q++ = 'n';
@@ -3174,20 +2770,15 @@ rb_str_dump(VALUE str)
*q++ = '\\';
*q++ = 'e';
}
- else if (rb_enc_isprint(c, enc)) {
- *q++ = c;
- }
else {
*q++ = '\\';
- sprintf(q, "x%02X", c&0xff);
+ sprintf(q, "%03o", c&0xff);
q += 3;
}
}
*q++ = '"';
OBJ_INFECT(result, str);
- /* result from dump is ASCII */
- rb_enc_associate(result, enc);
return result;
}
@@ -3198,28 +2789,26 @@ rb_str_dump(VALUE str)
*
* Upcases the contents of <i>str</i>, returning <code>nil</code> if no changes
* were made.
- * Note: case replacement is effective only in ASCII region.
*/
static VALUE
-rb_str_upcase_bang(VALUE str)
+rb_str_upcase_bang(str)
+ VALUE str;
{
- rb_encoding *enc;
char *s, *send;
int modify = 0;
rb_str_modify(str);
- enc = rb_enc_get(str);
- s = RSTRING_PTR(str); send = RSTRING_END(str);
+ s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
while (s < send) {
- int c = rb_enc_codepoint(s, send, enc);
-
- if (rb_enc_islower(c, enc)) {
- /* assuming toupper returns codepoint with same size */
- rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
+ if (ismbchar(*s)) {
+ s+=mbclen(*s) - 1;
+ }
+ else if (ISLOWER(*s)) {
+ *s = toupper(*s);
modify = 1;
}
- s += rb_enc_codelen(c, enc);
+ s++;
}
if (modify) return str;
@@ -3234,13 +2823,13 @@ rb_str_upcase_bang(VALUE str)
* Returns a copy of <i>str</i> with all lowercase letters replaced with their
* uppercase counterparts. The operation is locale insensitive---only
* characters ``a'' to ``z'' are affected.
- * Note: case replacement is effective only in ASCII region.
*
* "hEllO".upcase #=> "HELLO"
*/
static VALUE
-rb_str_upcase(VALUE str)
+rb_str_upcase(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_upcase_bang(str);
@@ -3254,28 +2843,26 @@ rb_str_upcase(VALUE str)
*
* Downcases the contents of <i>str</i>, returning <code>nil</code> if no
* changes were made.
- * Note: case replacement is effective only in ASCII region.
*/
static VALUE
-rb_str_downcase_bang(VALUE str)
+rb_str_downcase_bang(str)
+ VALUE str;
{
- rb_encoding *enc;
char *s, *send;
int modify = 0;
rb_str_modify(str);
- enc = rb_enc_get(str);
- s = RSTRING_PTR(str); send = RSTRING_END(str);
+ s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
while (s < send) {
- int c = rb_enc_codepoint(s, send, enc);
-
- if (rb_enc_isupper(c, enc)) {
- /* assuming toupper returns codepoint with same size */
- rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
+ if (ismbchar(*s)) {
+ s+=mbclen(*s) - 1;
+ }
+ else if (ISUPPER(*s)) {
+ *s = tolower(*s);
modify = 1;
}
- s += rb_enc_codelen(c, enc);
+ s++;
}
if (modify) return str;
@@ -3290,13 +2877,13 @@ rb_str_downcase_bang(VALUE str)
* Returns a copy of <i>str</i> with all uppercase letters replaced with their
* lowercase counterparts. The operation is locale insensitive---only
* characters ``A'' to ``Z'' are affected.
- * Note: case replacement is effective only in ASCII region.
*
* "hEllO".downcase #=> "hello"
*/
static VALUE
-rb_str_downcase(VALUE str)
+rb_str_downcase(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_downcase_bang(str);
@@ -3310,7 +2897,6 @@ rb_str_downcase(VALUE str)
*
* Modifies <i>str</i> by converting the first character to uppercase and the
* remainder to lowercase. Returns <code>nil</code> if no changes are made.
- * Note: case conversion is effective only in ASCII region.
*
* a = "hello"
* a.capitalize! #=> "Hello"
@@ -3319,31 +2905,27 @@ rb_str_downcase(VALUE str)
*/
static VALUE
-rb_str_capitalize_bang(VALUE str)
+rb_str_capitalize_bang(str)
+ VALUE str;
{
- rb_encoding *enc;
char *s, *send;
int modify = 0;
- int c;
rb_str_modify(str);
- enc = rb_enc_get(str);
- if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil;
- s = RSTRING_PTR(str); send = RSTRING_END(str);
-
- c = rb_enc_codepoint(s, send, enc);
- if (rb_enc_islower(c, enc)) {
- rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
+ if (RSTRING(str)->len == 0 || !RSTRING(str)->ptr) return Qnil;
+ s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
+ if (ISLOWER(*s)) {
+ *s = toupper(*s);
modify = 1;
}
- s += rb_enc_codelen(c, enc);
- while (s < send) {
- c = rb_enc_codepoint(s, send, enc);
- if (rb_enc_isupper(c, enc)) {
- rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
+ while (++s < send) {
+ if (ismbchar(*s)) {
+ s+=mbclen(*s) - 1;
+ }
+ else if (ISUPPER(*s)) {
+ *s = tolower(*s);
modify = 1;
}
- s += rb_enc_codelen(c, enc);
}
if (modify) return str;
return Qnil;
@@ -3356,7 +2938,6 @@ rb_str_capitalize_bang(VALUE str)
*
* Returns a copy of <i>str</i> with the first character converted to uppercase
* and the remainder to lowercase.
- * Note: case conversion is effective only in ASCII region.
*
* "hello".capitalize #=> "Hello"
* "HELLO".capitalize #=> "Hello"
@@ -3364,7 +2945,8 @@ rb_str_capitalize_bang(VALUE str)
*/
static VALUE
-rb_str_capitalize(VALUE str)
+rb_str_capitalize(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_capitalize_bang(str);
@@ -3373,38 +2955,35 @@ rb_str_capitalize(VALUE str)
/*
- * call-seq:
-* str.swapcase! => str or nil
+ * call-seq:
+ * str.swapcase! => str or nil
*
* Equivalent to <code>String#swapcase</code>, but modifies the receiver in
* place, returning <i>str</i>, or <code>nil</code> if no changes were made.
- * Note: case conversion is effective only in ASCII region.
*/
static VALUE
-rb_str_swapcase_bang(VALUE str)
+rb_str_swapcase_bang(str)
+ VALUE str;
{
- rb_encoding *enc;
char *s, *send;
int modify = 0;
rb_str_modify(str);
- enc = rb_enc_get(str);
- s = RSTRING_PTR(str); send = RSTRING_END(str);
+ s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
while (s < send) {
- int c = rb_enc_codepoint(s, send, enc);
-
- if (rb_enc_isupper(c, enc)) {
- /* assuming toupper returns codepoint with same size */
- rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
+ if (ismbchar(*s)) {
+ s+=mbclen(*s) - 1;
+ }
+ else if (ISUPPER(*s)) {
+ *s = tolower(*s);
modify = 1;
}
- else if (rb_enc_islower(c, enc)) {
- /* assuming toupper returns codepoint with same size */
- rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
+ else if (ISLOWER(*s)) {
+ *s = toupper(*s);
modify = 1;
}
- s += rb_enc_codelen(c, enc);
+ s++;
}
if (modify) return str;
@@ -3418,14 +2997,14 @@ rb_str_swapcase_bang(VALUE str)
*
* Returns a copy of <i>str</i> with uppercase alphabetic characters converted
* to lowercase and lowercase characters converted to uppercase.
- * Note: case conversion is effective only in ASCII region.
*
* "Hello".swapcase #=> "hELLO"
* "cYbEr_PuNk11".swapcase #=> "CyBeR_pUnK11"
*/
static VALUE
-rb_str_swapcase(VALUE str)
+rb_str_swapcase(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_swapcase_bang(str);
@@ -3440,21 +3019,25 @@ struct tr {
};
static int
-trnext(struct tr *t, rb_encoding *enc)
+trnext(t)
+ struct tr *t;
{
for (;;) {
if (!t->gen) {
if (t->p == t->pend) return -1;
- t->now = rb_enc_codepoint(t->p, t->pend, enc);
- t->p += rb_enc_codelen(t->now, enc);
+ if (t->p < t->pend - 1 && *t->p == '\\') {
+ t->p++;
+ }
+ t->now = *(USTR)t->p++;
if (t->p < t->pend - 1 && *t->p == '-') {
t->p++;
if (t->p < t->pend) {
- int c = rb_enc_codepoint(t->p, t->pend, enc);
- t->p += rb_enc_codelen(c, enc);
- if (t->now > c) continue;
+ if (t->now > *(USTR)t->p) {
+ t->p++;
+ continue;
+ }
t->gen = 1;
- t->max = c;
+ t->max = *(USTR)t->p++;
}
}
return t->now;
@@ -3469,40 +3052,32 @@ trnext(struct tr *t, rb_encoding *enc)
}
}
-static VALUE rb_str_delete_bang(int,VALUE*,VALUE);
+static VALUE rb_str_delete_bang _((int,VALUE*,VALUE));
static VALUE
-tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
+tr_trans(str, src, repl, sflag)
+ VALUE str, src, repl;
+ int sflag;
{
- SIGNED_VALUE trans[256];
- rb_encoding *enc, *e1, *e2;
struct tr trsrc, trrepl;
int cflag = 0;
- int c, last = 0, modify = 0, i;
+ int trans[256];
+ int i, c, modify = 0;
char *s, *send;
- VALUE hash = 0;
StringValue(src);
StringValue(repl);
- if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil;
- trsrc.p = RSTRING_PTR(src); trsrc.pend = trsrc.p + RSTRING_LEN(src);
- if (RSTRING_LEN(src) >= 2 && RSTRING_PTR(src)[0] == '^') {
+ if (RSTRING(str)->len == 0 || !RSTRING(str)->ptr) return Qnil;
+ trsrc.p = RSTRING(src)->ptr; trsrc.pend = trsrc.p + RSTRING(src)->len;
+ if (RSTRING(src)->len >= 2 && RSTRING(src)->ptr[0] == '^') {
cflag++;
trsrc.p++;
}
- if (RSTRING_LEN(repl) == 0) {
+ if (RSTRING(repl)->len == 0) {
return rb_str_delete_bang(1, &src, str);
}
- e1 = rb_enc_check(str, src);
- e2 = rb_enc_check(str, repl);
- if (e1 == e2) {
- enc = e1;
- }
- else {
- enc = rb_enc_check(src, repl);
- }
- trrepl.p = RSTRING_PTR(repl);
- trrepl.pend = trrepl.p + RSTRING_LEN(repl);
+ trrepl.p = RSTRING(repl)->ptr;
+ trrepl.pend = trrepl.p + RSTRING(repl)->len;
trsrc.gen = trrepl.gen = 0;
trsrc.now = trrepl.now = 0;
trsrc.max = trrepl.max = 0;
@@ -3511,21 +3086,14 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
for (i=0; i<256; i++) {
trans[i] = 1;
}
- while ((c = trnext(&trsrc, enc)) >= 0) {
- if (c < 256) {
- trans[c] = -1;
- }
- else {
- if (!hash) hash = rb_hash_new();
- rb_hash_aset(hash, INT2NUM(c), Qtrue);
- }
+ while ((c = trnext(&trsrc)) >= 0) {
+ trans[c & 0xff] = -1;
}
- while ((c = trnext(&trrepl, enc)) >= 0)
+ while ((c = trnext(&trrepl)) >= 0)
/* retrieve last replacer */;
- last = trrepl.now;
for (i=0; i<256; i++) {
if (trans[i] >= 0) {
- trans[i] = last;
+ trans[i] = trrepl.now;
}
}
}
@@ -3535,139 +3103,49 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
for (i=0; i<256; i++) {
trans[i] = -1;
}
- while ((c = trnext(&trsrc, enc)) >= 0) {
- r = trnext(&trrepl, enc);
+ while ((c = trnext(&trsrc)) >= 0) {
+ r = trnext(&trrepl);
if (r == -1) r = trrepl.now;
- if (c < 256) {
- trans[c] = INT2NUM(r);
- }
- else {
- if (!hash) hash = rb_hash_new();
- rb_hash_aset(hash, INT2NUM(c), INT2NUM(r));
- }
+ trans[c & 0xff] = r;
}
}
rb_str_modify(str);
- s = RSTRING_PTR(str); send = RSTRING_END(str);
+ s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
if (sflag) {
- int clen, tlen, max = RSTRING_LEN(str);
- int offset, save = -1;
- char *buf = ALLOC_N(char, max), *t = buf;
- VALUE v;
+ char *t = s;
+ int c0, last = -1;
- if (cflag) tlen = rb_enc_codelen(last, enc);
while (s < send) {
- c = rb_enc_codepoint(s, send, enc);
- tlen = clen = rb_enc_codelen(c, enc);
-
- s += clen;
- if (c < 256) {
- v = trans[c] >= 0 ? trans[c] : Qnil;
- }
- else {
- v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
- }
- if (!NIL_P(v)) {
- if (!cflag) {
- c = NUM2INT(v);
- if (save == c) continue;
- save = c;
- tlen = rb_enc_codelen(c, enc);
- modify = 1;
- }
- else {
- save = c = last;
- modify = 1;
- }
+ c0 = *s++;
+ if ((c = trans[c0 & 0xff]) >= 0) {
+ if (last == c) continue;
+ last = c;
+ *t++ = c & 0xff;
+ modify = 1;
}
else {
- save = -1;
- }
- while (t - buf + tlen >= max) {
- offset = t - buf;
- max *= 2;
- REALLOC_N(buf, char, max);
- t = buf + offset;
+ last = -1;
+ *t++ = c0;
}
- rb_enc_mbcput(c, t, enc);
- t += tlen;
}
- *t = '\0';
- RSTRING(str)->as.heap.ptr = buf;
- RSTRING(str)->as.heap.len = t - buf;
- STR_SET_NOEMBED(str);
- RSTRING(str)->as.heap.aux.capa = max;
+ if (RSTRING(str)->len > (t - RSTRING(str)->ptr)) {
+ RSTRING(str)->len = (t - RSTRING(str)->ptr);
+ modify = 1;
+ *t = '\0';
+ }
}
- else if (rb_enc_mbmaxlen(enc) == 1) {
+ else {
while (s < send) {
- c = (unsigned char)*s;
- if (trans[c] >= 0) {
- if (!cflag) {
- c = FIX2INT(trans[c]);
- *s = c;
- modify = 1;
- }
- else {
- *s = last;
- modify = 1;
- }
+ if ((c = trans[*s & 0xff]) >= 0) {
+ *s = c & 0xff;
+ modify = 1;
}
s++;
}
}
- else {
- int clen, tlen, max = RSTRING_LEN(str) * 1.2;
- int offset;
- char *buf = ALLOC_N(char, max), *t = buf;
- VALUE v;
-
- if (cflag) tlen = rb_enc_codelen(last, enc);
- while (s < send) {
- c = rb_enc_codepoint(s, send, enc);
- tlen = clen = rb_enc_codelen(c, enc);
- if (c < 256) {
- v = trans[c] >= 0 ? trans[c] : Qnil;
- }
- else {
- v = hash ? rb_hash_aref(hash, INT2NUM(c)) : Qnil;
- }
- if (!NIL_P(v)) {
- if (!cflag) {
- c = NUM2INT(v);
- tlen = rb_enc_codelen(c, enc);
- modify = 1;
- }
- else {
- c = last;
- modify = 1;
- }
- }
- while (t - buf + tlen >= max) {
- offset = t - buf;
- max *= 2;
- REALLOC_N(buf, char, max);
- t = buf + offset;
- }
- if (s != t) rb_enc_mbcput(c, t, enc);
- s += clen;
- t += tlen;
- }
- if (!STR_EMBED_P(str)) {
- free(RSTRING(str)->as.heap.ptr);
- }
- *t = '\0';
- RSTRING(str)->as.heap.ptr = buf;
- RSTRING(str)->as.heap.len = t - buf;
- STR_SET_NOEMBED(str);
- RSTRING(str)->as.heap.aux.capa = max;
- }
-
- if (modify) {
- rb_enc_associate(str, enc);
- return str;
- }
+ if (modify) return str;
return Qnil;
}
@@ -3682,7 +3160,8 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
*/
static VALUE
-rb_str_tr_bang(VALUE str, VALUE src, VALUE repl)
+rb_str_tr_bang(str, src, repl)
+ VALUE str, src, repl;
{
return tr_trans(str, src, repl, 0);
}
@@ -3706,7 +3185,8 @@ rb_str_tr_bang(VALUE str, VALUE src, VALUE repl)
*/
static VALUE
-rb_str_tr(VALUE str, VALUE src, VALUE repl)
+rb_str_tr(str, src, repl)
+ VALUE str, src, repl;
{
str = rb_str_dup(str);
tr_trans(str, src, repl, 0);
@@ -3714,94 +3194,58 @@ rb_str_tr(VALUE str, VALUE src, VALUE repl)
}
static void
-tr_setup_table(VALUE str, char stable[256], int first,
- VALUE *tablep, VALUE *ctablep, rb_encoding *enc)
+tr_setup_table(str, table, init)
+ VALUE str;
+ char table[256];
+ int init;
{
char buf[256];
struct tr tr;
- int c;
- VALUE table = 0, ptable = 0;
- int i, cflag = 0;
+ int i, c;
+ int cflag = 0;
- tr.p = RSTRING_PTR(str); tr.pend = tr.p + RSTRING_LEN(str);
+ tr.p = RSTRING(str)->ptr; tr.pend = tr.p + RSTRING(str)->len;
tr.gen = tr.now = tr.max = 0;
-
- if (RSTRING_LEN(str) > 1 && RSTRING_PTR(str)[0] == '^') {
+ if (RSTRING(str)->len > 1 && RSTRING(str)->ptr[0] == '^') {
cflag = 1;
tr.p++;
}
- if (first) {
+
+ if (init) {
for (i=0; i<256; i++) {
- stable[i] = 1;
+ table[i] = 1;
}
}
for (i=0; i<256; i++) {
buf[i] = cflag;
}
-
- while ((c = trnext(&tr, enc)) >= 0) {
- if (c < 256) {
- buf[c & 0xff] = !cflag;
- }
- else {
- VALUE key = INT2NUM(c);
-
- if (!table) {
- table = rb_hash_new();
- if (cflag) {
- ptable = *ctablep;
- *ctablep = table;
- }
- else {
- ptable = *tablep;
- *tablep = table;
- }
- }
- if (!ptable || !NIL_P(rb_hash_aref(ptable, key))) {
- rb_hash_aset(table, key, Qtrue);
- }
- }
+ while ((c = trnext(&tr)) >= 0) {
+ buf[c & 0xff] = !cflag;
}
for (i=0; i<256; i++) {
- stable[i] = stable[i] && buf[i];
+ table[i] = table[i] && buf[i];
}
}
-static int
-tr_find(int c, char table[256], VALUE del, VALUE nodel)
-{
- if (c < 256) {
- return table[c] ? Qtrue : Qfalse;
- }
- else {
- VALUE v = INT2NUM(c);
-
- if (!del || NIL_P(rb_hash_lookup(del, v))) {
- return Qfalse;
- }
- if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
- return Qfalse;
- return Qtrue;
- }
-}
-
/*
* call-seq:
- * str.delete!([other_str]+) => str or nil
+ * str.delete!([other_str]+>) => str or nil
*
* Performs a <code>delete</code> operation in place, returning <i>str</i>, or
* <code>nil</code> if <i>str</i> was not modified.
*/
static VALUE
-rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
+rb_str_delete_bang(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
- char squeez[256];
- rb_encoding *enc = 0;
char *s, *send, *t;
- VALUE del = 0, nodel = 0;
+ char squeez[256];
int modify = 0;
+ int init = 1;
int i;
if (argc < 1) {
@@ -3811,29 +3255,23 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
VALUE s = argv[i];
StringValue(s);
- enc = rb_enc_check(str, s);
- tr_setup_table(s, squeez, i==0, &del, &nodel, enc);
+ tr_setup_table(s, squeez, init);
+ init = 0;
}
rb_str_modify(str);
- s = t = RSTRING_PTR(str);
- if (!s || RSTRING_LEN(str) == 0) return Qnil;
- send = RSTRING_END(str);
+ s = t = RSTRING(str)->ptr;
+ if (!s || RSTRING(str)->len == 0) return Qnil;
+ send = s + RSTRING(str)->len;
while (s < send) {
- int c = rb_enc_codepoint(s, send, enc);
- int clen = rb_enc_codelen(c, enc);
-
- if (tr_find(c, squeez, del, nodel)) {
+ if (squeez[*s & 0xff])
modify = 1;
- }
- else {
- if (t != s) rb_enc_mbcput(c, t, enc);
- t += clen;
- }
- s += clen;
+ else
+ *t++ = *s;
+ s++;
}
*t = '\0';
- STR_SET_LEN(str, t - RSTRING_PTR(str));
+ RSTRING(str)->len = t - RSTRING(str)->ptr;
if (modify) return str;
return Qnil;
@@ -3855,7 +3293,10 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_delete(int argc, VALUE *argv, VALUE str)
+rb_str_delete(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_delete_bang(argc, argv, str);
@@ -3872,47 +3313,46 @@ rb_str_delete(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
+rb_str_squeeze_bang(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
char squeez[256];
- rb_encoding *enc = 0;
- VALUE del = 0, nodel = 0;
char *s, *send, *t;
- int save, modify = 0;
+ int c, save, modify = 0;
+ int init = 1;
int i;
if (argc == 0) {
- enc = rb_enc_get(str);
+ for (i=0; i<256; i++) {
+ squeez[i] = 1;
+ }
}
else {
for (i=0; i<argc; i++) {
VALUE s = argv[i];
StringValue(s);
- enc = rb_enc_check(str, s);
- tr_setup_table(s, squeez, i==0, &del, &nodel, enc);
+ tr_setup_table(s, squeez, init);
+ init = 0;
}
}
rb_str_modify(str);
- s = t = RSTRING_PTR(str);
- if (!s || RSTRING_LEN(str) == 0) return Qnil;
- send = RSTRING_END(str);
+ s = t = RSTRING(str)->ptr;
+ if (!s || RSTRING(str)->len == 0) return Qnil;
+ send = s + RSTRING(str)->len;
save = -1;
while (s < send) {
- int c = rb_enc_codepoint(s, send, enc);
- int clen = rb_enc_codelen(c, enc);
-
- if (c != save || (argc > 0 && !tr_find(c, squeez, del, nodel))) {
- if (t != s) rb_enc_mbcput(c, t, enc);
- save = c;
- t += clen;
+ c = *s++ & 0xff;
+ if (c != save || !squeez[c]) {
+ *t++ = save = c;
}
- s += clen;
}
*t = '\0';
- if (t - RSTRING_PTR(str) != RSTRING_LEN(str)) {
- STR_SET_LEN(str, t - RSTRING_PTR(str));
+ if (t - RSTRING(str)->ptr != RSTRING(str)->len) {
+ RSTRING(str)->len = t - RSTRING(str)->ptr;
modify = 1;
}
@@ -3937,7 +3377,10 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_squeeze(int argc, VALUE *argv, VALUE str)
+rb_str_squeeze(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_squeeze_bang(argc, argv, str);
@@ -3954,7 +3397,8 @@ rb_str_squeeze(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl)
+rb_str_tr_s_bang(str, src, repl)
+ VALUE str, src, repl;
{
return tr_trans(str, src, repl, 1);
}
@@ -3974,7 +3418,8 @@ rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl)
*/
static VALUE
-rb_str_tr_s(VALUE str, VALUE src, VALUE repl)
+rb_str_tr_s(str, src, repl)
+ VALUE str, src, repl;
{
str = rb_str_dup(str);
tr_trans(str, src, repl, 1);
@@ -3999,12 +3444,14 @@ rb_str_tr_s(VALUE str, VALUE src, VALUE repl)
*/
static VALUE
-rb_str_count(int argc, VALUE *argv, VALUE str)
+rb_str_count(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
char table[256];
- rb_encoding *enc = 0;
- VALUE del = 0, nodel = 0;
char *s, *send;
+ int init = 1;
int i;
if (argc < 1) {
@@ -4014,22 +3461,18 @@ rb_str_count(int argc, VALUE *argv, VALUE str)
VALUE s = argv[i];
StringValue(s);
- enc = rb_enc_check(str, s);
- tr_setup_table(s, table,i==0, &del, &nodel, enc);
+ tr_setup_table(s, table, init);
+ init = 0;
}
- s = RSTRING_PTR(str);
- if (!s || RSTRING_LEN(str) == 0) return INT2FIX(0);
- send = RSTRING_END(str);
+ s = RSTRING(str)->ptr;
+ if (!s || RSTRING(str)->len == 0) return INT2FIX(0);
+ send = s + RSTRING(str)->len;
i = 0;
while (s < send) {
- int c = rb_enc_codepoint(s, send, enc);
- int clen = rb_enc_codelen(c, enc);
-
- if (tr_find(c, table, del, nodel)) {
+ if (table[*s++ & 0xff]) {
i++;
}
- s += clen;
}
return INT2NUM(i);
}
@@ -4049,8 +3492,7 @@ rb_str_count(int argc, VALUE *argv, VALUE str)
*
* If <i>pattern</i> is a <code>Regexp</code>, <i>str</i> is divided where the
* pattern matches. Whenever the pattern matches a zero-length string,
- * <i>str</i> is split into individual characters. If <i>pattern</i> contains
- * groups, the respective matches will be returned in the array as well.
+ * <i>str</i> is split into individual characters.
*
* If <i>pattern</i> is omitted, the value of <code>$;</code> is used. If
* <code>$;</code> is <code>nil</code> (which is the default), <i>str</i> is
@@ -4078,9 +3520,11 @@ rb_str_count(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_split_m(int argc, VALUE *argv, VALUE str)
+rb_str_split_m(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
- rb_encoding *enc;
VALUE spat;
VALUE limit;
int awk_split = Qfalse;
@@ -4092,14 +3536,13 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
lim = NUM2INT(limit);
if (lim <= 0) limit = Qnil;
else if (lim == 1) {
- if (RSTRING_LEN(str) == 0)
+ if (RSTRING(str)->len == 0)
return rb_ary_new2(0);
return rb_ary_new3(1, str);
}
i = 1;
}
- enc = rb_enc_get(str);
if (NIL_P(spat)) {
if (!NIL_P(rb_fs)) {
spat = rb_fs;
@@ -4109,8 +3552,8 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
else {
fs_set:
- if (TYPE(spat) == T_STRING && RSTRING_LEN(spat) == 1) {
- if (RSTRING_PTR(spat)[0] == ' ') {
+ if (TYPE(spat) == T_STRING && RSTRING(spat)->len == 1) {
+ if (RSTRING(spat)->ptr[0] == ' ') {
awk_split = Qtrue;
}
else {
@@ -4125,35 +3568,31 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
result = rb_ary_new();
beg = 0;
if (awk_split) {
- char *ptr = RSTRING_PTR(str);
- char *eptr = RSTRING_END(str);
- char *bptr = ptr;
+ char *ptr = RSTRING(str)->ptr;
+ long len = RSTRING(str)->len;
+ char *eptr = ptr + len;
int skip = 1;
- int c;
- end = beg;
- while (ptr < eptr) {
- c = rb_enc_codepoint(ptr, eptr, enc);
- ptr += rb_enc_mbclen(ptr, eptr, enc);
+ for (end = beg = 0; ptr<eptr; ptr++) {
if (skip) {
- if (rb_enc_isspace(c, enc)) {
- beg = ptr - bptr;
+ if (ISSPACE(*ptr)) {
+ beg++;
}
else {
- end = ptr - bptr;
+ end = beg+1;
skip = 0;
if (!NIL_P(limit) && lim <= i) break;
}
}
else {
- if (rb_enc_isspace(c, enc)) {
- rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
+ if (ISSPACE(*ptr)) {
+ rb_ary_push(result, rb_str_substr(str, beg, end-beg));
skip = 1;
- beg = ptr - bptr;
+ beg = end + 1;
if (!NIL_P(limit)) ++i;
}
else {
- end = ptr - bptr;
+ end++;
}
}
}
@@ -4167,28 +3606,22 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
regs = RMATCH(rb_backref_get())->regs;
if (start == end && BEG(0) == END(0)) {
- if (!RSTRING_PTR(str)) {
+ if (!RSTRING(str)->ptr) {
rb_ary_push(result, rb_str_new("", 0));
break;
}
else if (last_null == 1) {
- rb_ary_push(result, rb_str_subseq(str, beg,
- rb_enc_mbclen(RSTRING_PTR(str)+beg,
- RSTRING_END(str),
- enc)));
+ rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat)));
beg = start;
}
else {
- if (RSTRING_PTR(str)+start == RSTRING_END(str))
- start++;
- else
- start += rb_enc_mbclen(RSTRING_PTR(str)+start,RSTRING_END(str),enc);
+ start += mbclen2(RSTRING(str)->ptr[start],spat);
last_null = 1;
continue;
}
}
else {
- rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
+ rb_ary_push(result, rb_str_substr(str, beg, end-beg));
beg = start = END(0);
}
last_null = 0;
@@ -4198,22 +3631,22 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
if (BEG(idx) == END(idx))
tmp = rb_str_new5(str, 0, 0);
else
- tmp = rb_str_subseq(str, BEG(idx), END(idx)-BEG(idx));
+ tmp = rb_str_substr(str, BEG(idx), END(idx)-BEG(idx));
rb_ary_push(result, tmp);
}
if (!NIL_P(limit) && lim <= ++i) break;
}
}
- if (RSTRING_LEN(str) > 0 && (!NIL_P(limit) || RSTRING_LEN(str) > beg || lim < 0)) {
- if (RSTRING_LEN(str) == beg)
+ if (RSTRING(str)->len > 0 && (!NIL_P(limit) || RSTRING(str)->len > beg || lim < 0)) {
+ if (RSTRING(str)->len == beg)
tmp = rb_str_new5(str, 0, 0);
else
- tmp = rb_str_subseq(str, beg, RSTRING_LEN(str)-beg);
+ tmp = rb_str_substr(str, beg, RSTRING(str)->len-beg);
rb_ary_push(result, tmp);
}
if (NIL_P(limit) && lim == 0) {
- while (RARRAY_LEN(result) > 0 &&
- RSTRING_LEN(RARRAY_PTR(result)[RARRAY_LEN(result)-1]) == 0)
+ while (RARRAY(result)->len > 0 &&
+ RSTRING(RARRAY(result)->ptr[RARRAY(result)->len-1])->len == 0)
rb_ary_pop(result);
}
@@ -4221,7 +3654,9 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
}
VALUE
-rb_str_split(VALUE str, const char *sep0)
+rb_str_split(str, sep0)
+ VALUE str;
+ const char *sep0;
{
VALUE sep;
@@ -4230,6 +3665,21 @@ rb_str_split(VALUE str, const char *sep0)
return rb_str_split_m(1, &sep, str);
}
+/*
+ * call-seq:
+ * split([pattern [, limit]]) => array
+ *
+ * Equivalent to <code>$_.split(<i>pattern</i>, <i>limit</i>)</code>.
+ * See <code>String#split</code>.
+ */
+
+static VALUE
+rb_f_split(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ return rb_str_split_m(argc, argv, uscore_get());
+}
/*
* Document-method: lines
@@ -4245,15 +3695,14 @@ rb_str_split(VALUE str, const char *sep0)
*/
/*
- * Document-method: each_line
* call-seq:
+ * str.each(separator=$/) {|substr| block } => str
* str.each_line(separator=$/) {|substr| block } => str
*
* Splits <i>str</i> using the supplied parameter as the record separator
* (<code>$/</code> by default), passing each substring in turn to the supplied
- * block. If a zero-length record separator is supplied, the string is split on
- * <code>\n</code> characters, except that multiple successive newlines are
- * appended together.
+ * block. If a zero-length record separator is supplied, the string is split
+ * into paragraphs delimited by multiple successive newlines.
*
* print "Example one\n"
* "hello\nworld".each {|s| p s}
@@ -4278,62 +3727,55 @@ rb_str_split(VALUE str, const char *sep0)
*/
static VALUE
-rb_str_each_line(int argc, VALUE *argv, VALUE str)
+rb_str_each_line(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
- rb_encoding *enc;
VALUE rs;
int newline;
- char *p = RSTRING_PTR(str), *pend = p + RSTRING_LEN(str), *s = p;
+ char *p = RSTRING(str)->ptr, *pend = p + RSTRING(str)->len, *s;
char *ptr = p;
- long len = RSTRING_LEN(str), rslen;
+ long len = RSTRING(str)->len, rslen;
VALUE line;
if (rb_scan_args(argc, argv, "01", &rs) == 0) {
rs = rb_rs;
}
RETURN_ENUMERATOR(str, argc, argv);
-
if (NIL_P(rs)) {
rb_yield(str);
return str;
}
StringValue(rs);
- enc = rb_enc_check(str, rs);
- rslen = RSTRING_LEN(rs);
+ rslen = RSTRING(rs)->len;
if (rslen == 0) {
newline = '\n';
}
else {
- newline = rb_enc_codepoint(RSTRING_PTR(rs), RSTRING_END(rs), enc);
+ newline = RSTRING(rs)->ptr[rslen-1];
}
- while (p < pend) {
- int c = rb_enc_codepoint(p, pend, enc);
- int n = rb_enc_codelen(c, enc);
-
- if (rslen == 0 && c == newline) {
- while (p < pend && rb_enc_codepoint(p, pend, enc) == newline) {
- p += n;
- }
- p -= n;
+ for (s = p, p += rslen; p < pend; p++) {
+ if (rslen == 0 && *p == '\n') {
+ if (*++p != '\n') continue;
+ while (*p == '\n') p++;
}
- if (c == newline &&
- (rslen <= 1 || memcmp(RSTRING_PTR(rs), p, rslen) == 0)) {
- line = rb_str_new5(str, s, p - s + (rslen ? rslen : n));
+ if (RSTRING(str)->ptr < p && p[-1] == newline &&
+ (rslen <= 1 ||
+ rb_memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) {
+ line = rb_str_new5(str, s, p - s);
OBJ_INFECT(line, str);
- rb_enc_copy(line, str);
rb_yield(line);
str_mod_check(str, ptr, len);
- s = p + (rslen ? rslen : n);
+ s = p;
}
- p += n;
}
if (s != pend) {
if (p > pend) p = pend;
line = rb_str_new5(str, s, p - s);
OBJ_INFECT(line, str);
- rb_enc_copy(line, str);
rb_yield(line);
}
@@ -4354,7 +3796,6 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
*/
/*
- * Document-method: each_byte
* call-seq:
* str.each_byte {|fixnum| block } => str
*
@@ -4368,13 +3809,14 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_each_byte(VALUE str)
+rb_str_each_byte(str)
+ VALUE str;
{
long i;
RETURN_ENUMERATOR(str, 0, 0);
- for (i=0; i<RSTRING_LEN(str); i++) {
- rb_yield(INT2FIX(RSTRING_PTR(str)[i] & 0xff));
+ for (i=0; i<RSTRING(str)->len; i++) {
+ rb_yield(INT2FIX(RSTRING(str)->ptr[i] & 0xff));
}
return str;
}
@@ -4409,32 +3851,20 @@ rb_str_each_byte(VALUE str)
static VALUE
rb_str_each_char(VALUE str)
{
- int i, len = str_strlen(str, 0);
+ int i, len, n;
+ const char *ptr;
RETURN_ENUMERATOR(str, 0, 0);
- for (i=0; i<len; i++) {
- rb_yield(rb_str_substr(str, i, 1));
+ str = rb_str_new4(str);
+ ptr = RSTRING(str)->ptr;
+ len = RSTRING(str)->len;
+ for (i = 0; i < len; i += n) {
+ n = mbclen(ptr[i]);
+ rb_yield(rb_str_substr(str, i, n));
}
return str;
}
-static long
-chopped_length(VALUE str)
-{
- rb_encoding *enc = rb_enc_get(str);
- const char *p, *p2, *beg, *end;
-
- beg = RSTRING_PTR(str);
- end = beg + RSTRING_LEN(str);
- if (beg > end) return 0;
- p = rb_enc_prev_char(beg, end, enc);
- if (!p) return 0;
- if (p > beg && rb_enc_codepoint(p, end, enc) == '\n') {
- p2 = rb_enc_prev_char(beg, p, enc);
- if (p2 && rb_enc_codepoint(p2, end, enc) == '\r') p = p2;
- }
- return p - beg;
-}
/*
* call-seq:
@@ -4446,14 +3876,19 @@ chopped_length(VALUE str)
*/
static VALUE
-rb_str_chop_bang(VALUE str)
+rb_str_chop_bang(str)
+ VALUE str;
{
- if (RSTRING_LEN(str) > 0) {
- long len;
+ if (RSTRING(str)->len > 0) {
rb_str_modify(str);
- len = chopped_length(str);
- STR_SET_LEN(str, len);
- RSTRING_PTR(str)[len] = '\0';
+ RSTRING(str)->len--;
+ if (RSTRING(str)->ptr[RSTRING(str)->len] == '\n') {
+ if (RSTRING(str)->len > 0 &&
+ RSTRING(str)->ptr[RSTRING(str)->len-1] == '\r') {
+ RSTRING(str)->len--;
+ }
+ }
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
return str;
}
return Qnil;
@@ -4478,12 +3913,68 @@ rb_str_chop_bang(VALUE str)
*/
static VALUE
-rb_str_chop(VALUE str)
+rb_str_chop(str)
+ VALUE str;
{
- VALUE str2 = rb_str_new5(str, RSTRING_PTR(str), chopped_length(str));
- rb_enc_copy(str2, str);
- OBJ_INFECT(str2, str);
- return str2;
+ str = rb_str_dup(str);
+ rb_str_chop_bang(str);
+ return str;
+}
+
+
+/*
+ * call-seq:
+ * chop! => $_ or nil
+ *
+ * Equivalent to <code>$_.chop!</code>.
+ *
+ * a = "now\r\n"
+ * $_ = a
+ * chop! #=> "now"
+ * chop! #=> "no"
+ * chop! #=> "n"
+ * chop! #=> ""
+ * chop! #=> nil
+ * $_ #=> ""
+ * a #=> ""
+ */
+
+static VALUE
+rb_f_chop_bang(str)
+ VALUE str;
+{
+ return rb_str_chop_bang(uscore_get());
+}
+
+/*
+ * call-seq:
+ * chop => string
+ *
+ * Equivalent to <code>($_.dup).chop!</code>, except <code>nil</code>
+ * is never returned. See <code>String#chop!</code>.
+ *
+ * a = "now\r\n"
+ * $_ = a
+ * chop #=> "now"
+ * $_ #=> "now"
+ * chop #=> "no"
+ * chop #=> "n"
+ * chop #=> ""
+ * chop #=> ""
+ * a #=> "now\r\n"
+ */
+
+static VALUE
+rb_f_chop()
+{
+ VALUE str = uscore_get();
+
+ if (RSTRING(str)->len > 0) {
+ str = rb_str_dup(str);
+ rb_str_chop_bang(str);
+ rb_lastline_set(str);
+ }
+ return str;
}
@@ -4496,78 +3987,72 @@ rb_str_chop(VALUE str)
*/
static VALUE
-rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
+rb_str_chomp_bang(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
- rb_encoding *enc;
VALUE rs;
int newline;
- char *p, *pp, *e;
+ char *p;
long len, rslen;
if (rb_scan_args(argc, argv, "01", &rs) == 0) {
- len = RSTRING_LEN(str);
+ len = RSTRING(str)->len;
if (len == 0) return Qnil;
- p = RSTRING_PTR(str);
+ p = RSTRING(str)->ptr;
rs = rb_rs;
if (rs == rb_default_rs) {
smart_chomp:
rb_str_modify(str);
- if (RSTRING_PTR(str)[len-1] == '\n') {
- STR_DEC_LEN(str);
- if (RSTRING_LEN(str) > 0 &&
- RSTRING_PTR(str)[RSTRING_LEN(str)-1] == '\r') {
- STR_DEC_LEN(str);
+ if (RSTRING(str)->ptr[len-1] == '\n') {
+ RSTRING(str)->len--;
+ if (RSTRING(str)->len > 0 &&
+ RSTRING(str)->ptr[RSTRING(str)->len-1] == '\r') {
+ RSTRING(str)->len--;
}
}
- else if (RSTRING_PTR(str)[len-1] == '\r') {
- STR_DEC_LEN(str);
+ else if (RSTRING(str)->ptr[len-1] == '\r') {
+ RSTRING(str)->len--;
}
else {
return Qnil;
}
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
return str;
}
}
if (NIL_P(rs)) return Qnil;
StringValue(rs);
- enc = rb_enc_check(str, rs);
- len = RSTRING_LEN(str);
+ len = RSTRING(str)->len;
if (len == 0) return Qnil;
- p = RSTRING_PTR(str);
- rslen = RSTRING_LEN(rs);
+ p = RSTRING(str)->ptr;
+ rslen = RSTRING(rs)->len;
if (rslen == 0) {
while (len>0 && p[len-1] == '\n') {
len--;
if (len>0 && p[len-1] == '\r')
len--;
}
- if (len < RSTRING_LEN(str)) {
+ if (len < RSTRING(str)->len) {
rb_str_modify(str);
- STR_SET_LEN(str, len);
- RSTRING_PTR(str)[len] = '\0';
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = '\0';
return str;
}
return Qnil;
}
if (rslen > len) return Qnil;
- newline = RSTRING_PTR(rs)[rslen-1];
+ newline = RSTRING(rs)->ptr[rslen-1];
if (rslen == 1 && newline == '\n')
goto smart_chomp;
- if (is_broken_string(rs)) {
- return Qnil;
- }
- e = p + len;
- pp = e - rslen;
if (p[len-1] == newline &&
(rslen <= 1 ||
- memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
- if (rb_enc_left_char_head(p, pp, enc) != pp)
- return Qnil;
+ rb_memcmp(RSTRING(rs)->ptr, p+len-rslen, rslen) == 0)) {
rb_str_modify(str);
- STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->len -= rslen;
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
return str;
}
return Qnil;
@@ -4594,7 +4079,10 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_chomp(int argc, VALUE *argv, VALUE str)
+rb_str_chomp(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_chomp_bang(argc, argv, str);
@@ -4603,6 +4091,61 @@ rb_str_chomp(int argc, VALUE *argv, VALUE str)
/*
* call-seq:
+ * chomp! => $_ or nil
+ * chomp!(string) => $_ or nil
+ *
+ * Equivalent to <code>$_.chomp!(<em>string</em>)</code>. See
+ * <code>String#chomp!</code>
+ *
+ * $_ = "now\n"
+ * chomp! #=> "now"
+ * $_ #=> "now"
+ * chomp! "x" #=> nil
+ * $_ #=> "now"
+ */
+
+static VALUE
+rb_f_chomp_bang(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ return rb_str_chomp_bang(argc, argv, uscore_get());
+}
+
+/*
+ * call-seq:
+ * chomp => $_
+ * chomp(string) => $_
+ *
+ * Equivalent to <code>$_ = $_.chomp(<em>string</em>)</code>. See
+ * <code>String#chomp</code>.
+ *
+ * $_ = "now\n"
+ * chomp #=> "now"
+ * $_ #=> "now"
+ * chomp "ow" #=> "n"
+ * $_ #=> "n"
+ * chomp "xxx" #=> "n"
+ * $_ #=> "n"
+ */
+
+static VALUE
+rb_f_chomp(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE str = uscore_get();
+ VALUE dup = rb_str_dup(str);
+
+ if (NIL_P(rb_str_chomp_bang(argc, argv, dup)))
+ return str;
+ rb_lastline_set(dup);
+ return dup;
+}
+
+
+/*
+ * call-seq:
* str.lstrip! => self or nil
*
* Removes leading whitespace from <i>str</i>, returning <code>nil</code> if no
@@ -4614,29 +4157,22 @@ rb_str_chomp(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_lstrip_bang(VALUE str)
+rb_str_lstrip_bang(str)
+ VALUE str;
{
- rb_encoding *enc;
char *s, *t, *e;
- rb_str_modify(str);
- enc = rb_enc_get(str);
- s = RSTRING_PTR(str);
- if (!s || RSTRING_LEN(str) == 0) return Qnil;
- e = t = RSTRING_END(str);
+ s = RSTRING(str)->ptr;
+ if (!s || RSTRING(str)->len == 0) return Qnil;
+ e = t = s + RSTRING(str)->len;
/* remove spaces at head */
- while (s < e) {
- int cc = rb_enc_codepoint(s, e, enc);
-
- if (!rb_enc_isspace(cc, enc)) break;
- s += rb_enc_codelen(cc, enc);
- }
+ while (s < t && ISSPACE(*s)) s++;
- if (s > RSTRING_PTR(str)) {
+ if (s > RSTRING(str)->ptr) {
rb_str_modify(str);
- STR_SET_LEN(str, t-s);
- memmove(RSTRING_PTR(str), s, RSTRING_LEN(str));
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->len = t-s;
+ memmove(RSTRING(str)->ptr, s, RSTRING(str)->len);
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
return str;
}
return Qnil;
@@ -4655,7 +4191,8 @@ rb_str_lstrip_bang(VALUE str)
*/
static VALUE
-rb_str_lstrip(VALUE str)
+rb_str_lstrip(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_lstrip_bang(str);
@@ -4676,34 +4213,25 @@ rb_str_lstrip(VALUE str)
*/
static VALUE
-rb_str_rstrip_bang(VALUE str)
+rb_str_rstrip_bang(str)
+ VALUE str;
{
- rb_encoding *enc;
char *s, *t, *e;
- int space_seen = Qfalse;
- rb_str_modify(str);
- enc = rb_enc_get(str);
- s = RSTRING_PTR(str);
- if (!s || RSTRING_LEN(str) == 0) return Qnil;
- t = e = RSTRING_END(str);
- while (s < e) {
- int cc = rb_enc_codepoint(s, e, enc);
+ s = RSTRING(str)->ptr;
+ if (!s || RSTRING(str)->len == 0) return Qnil;
+ e = t = s + RSTRING(str)->len;
+
+ /* remove trailing '\0's */
+ while (s < t && t[-1] == '\0') t--;
+
+ /* remove trailing spaces */
+ while (s < t && ISSPACE(*(t-1))) t--;
- if (!cc || rb_enc_isspace(cc, enc)) {
- if (!space_seen) t = s;
- space_seen = Qtrue;
- }
- else {
- space_seen = Qfalse;
- }
- s += rb_enc_codelen(cc, enc);
- }
- if (!space_seen) t = s;
if (t < e) {
rb_str_modify(str);
- STR_SET_LEN(str, t-RSTRING_PTR(str));
- RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
+ RSTRING(str)->len = t-s;
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
return str;
}
return Qnil;
@@ -4722,7 +4250,8 @@ rb_str_rstrip_bang(VALUE str)
*/
static VALUE
-rb_str_rstrip(VALUE str)
+rb_str_rstrip(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_rstrip_bang(str);
@@ -4739,7 +4268,8 @@ rb_str_rstrip(VALUE str)
*/
static VALUE
-rb_str_strip_bang(VALUE str)
+rb_str_strip_bang(str)
+ VALUE str;
{
VALUE l = rb_str_lstrip_bang(str);
VALUE r = rb_str_rstrip_bang(str);
@@ -4760,7 +4290,8 @@ rb_str_strip_bang(VALUE str)
*/
static VALUE
-rb_str_strip(VALUE str)
+rb_str_strip(str)
+ VALUE str;
{
str = rb_str_dup(str);
rb_str_strip_bang(str);
@@ -4768,14 +4299,14 @@ rb_str_strip(VALUE str)
}
static VALUE
-scan_once(VALUE str, VALUE pat, long *start)
+scan_once(str, pat, start)
+ VALUE str, pat;
+ long *start;
{
- rb_encoding *enc;
VALUE result, match;
struct re_registers *regs;
long i;
- enc = rb_enc_get(str);
if (rb_reg_search(pat, str, *start, 0) >= 0) {
match = rb_backref_get();
regs = RMATCH(match)->regs;
@@ -4783,9 +4314,8 @@ scan_once(VALUE str, VALUE pat, long *start)
/*
* Always consume at least one character of the input string
*/
- if (RSTRING_LEN(str) > END(0))
- *start = END(0)+rb_enc_mbclen(RSTRING_PTR(str)+END(0),
- RSTRING_END(str), enc);
+ if (RSTRING(str)->len > END(0))
+ *start = END(0)+mbclen2(RSTRING(str)->ptr[END(0)],pat);
else
*start = END(0)+1;
}
@@ -4838,12 +4368,13 @@ scan_once(VALUE str, VALUE pat, long *start)
*/
static VALUE
-rb_str_scan(VALUE str, VALUE pat)
+rb_str_scan(str, pat)
+ VALUE str, pat;
{
VALUE result;
long start = 0;
VALUE match = Qnil;
- char *p = RSTRING_PTR(str); long len = RSTRING_LEN(str);
+ char *p = RSTRING(str)->ptr; long len = RSTRING(str)->len;
pat = get_pat(pat, 1);
if (!rb_block_given_p()) {
@@ -4868,6 +4399,22 @@ rb_str_scan(VALUE str, VALUE pat)
return str;
}
+/*
+ * call-seq:
+ * scan(pattern) => array
+ * scan(pattern) {|///| block } => $_
+ *
+ * Equivalent to calling <code>$_.scan</code>. See
+ * <code>String#scan</code>.
+ */
+
+static VALUE
+rb_f_scan(self, pat)
+ VALUE self, pat;
+{
+ return rb_str_scan(uscore_get(), pat);
+}
+
/*
* call-seq:
@@ -4884,7 +4431,8 @@ rb_str_scan(VALUE str, VALUE pat)
*/
static VALUE
-rb_str_hex(VALUE str)
+rb_str_hex(str)
+ VALUE str;
{
return rb_str_to_inum(str, 16, Qfalse);
}
@@ -4905,7 +4453,8 @@ rb_str_hex(VALUE str)
*/
static VALUE
-rb_str_oct(VALUE str)
+rb_str_oct(str)
+ VALUE str;
{
return rb_str_to_inum(str, -8, Qfalse);
}
@@ -4922,19 +4471,20 @@ rb_str_oct(VALUE str)
*/
static VALUE
-rb_str_crypt(VALUE str, VALUE salt)
+rb_str_crypt(str, salt)
+ VALUE str, salt;
{
- extern char *crypt(const char *, const char *);
+ extern char *crypt _((const char *, const char*));
VALUE result;
const char *s;
StringValue(salt);
- if (RSTRING_LEN(salt) < 2)
- rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
+ if (RSTRING(salt)->len < 2)
+ rb_raise(rb_eArgError, "salt too short(need >=2 bytes)");
- if (RSTRING_PTR(str)) s = RSTRING_PTR(str);
+ if (RSTRING(str)->ptr) s = RSTRING(str)->ptr;
else s = "";
- result = rb_str_new2(crypt(s, RSTRING_PTR(salt)));
+ result = rb_str_new2(crypt(s, RSTRING(salt)->ptr));
OBJ_INFECT(result, str);
OBJ_INFECT(result, salt);
return result;
@@ -4962,38 +4512,27 @@ rb_str_crypt(VALUE str, VALUE salt)
*/
VALUE
-rb_str_intern(VALUE s)
+rb_str_intern(s)
+ VALUE s;
{
- VALUE str = RB_GC_GUARD(s);
+ volatile VALUE str = s;
ID id;
- if (OBJ_TAINTED(str) && rb_safe_level() >= 1) {
+ if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) {
+ rb_raise(rb_eArgError, "interning empty string");
+ }
+ if (strlen(RSTRING(str)->ptr) != RSTRING(str)->len)
+ rb_raise(rb_eArgError, "symbol string may not contain `\\0'");
+ if (OBJ_TAINTED(str) && rb_safe_level() >= 1 && !rb_sym_interned_p(str)) {
rb_raise(rb_eSecurityError, "Insecure: can't intern tainted string");
}
- id = rb_intern_str(str);
+ id = rb_intern(RSTRING(str)->ptr);
return ID2SYM(id);
}
/*
* call-seq:
- * str.ord => integer
- *
- * Return the <code>Integer</code> ordinal of a one-character string.
- *
- * "a".ord #=> 97
- */
-
-VALUE
-rb_str_ord(VALUE s)
-{
- int c;
-
- c = rb_enc_codepoint(RSTRING_PTR(s), RSTRING_END(s), rb_enc_get(s));
- return INT2NUM(c);
-}
-/*
- * call-seq:
* str.sum(n=16) => integer
*
* Returns a basic <em>n</em>-bit checksum of the characters in <i>str</i>,
@@ -5004,7 +4543,10 @@ rb_str_ord(VALUE s)
*/
static VALUE
-rb_str_sum(int argc, VALUE *argv, VALUE str)
+rb_str_sum(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
VALUE vbits;
int bits;
@@ -5016,8 +4558,8 @@ rb_str_sum(int argc, VALUE *argv, VALUE str)
}
else bits = NUM2INT(vbits);
- ptr = p = RSTRING_PTR(str);
- len = RSTRING_LEN(str);
+ ptr = p = RSTRING(str)->ptr;
+ len = RSTRING(str)->len;
pend = p + len;
if (bits >= sizeof(long)*CHAR_BIT) {
VALUE sum = INT2FIX(0);
@@ -5052,81 +4594,72 @@ rb_str_sum(int argc, VALUE *argv, VALUE str)
}
static VALUE
-rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
+rb_str_justify(argc, argv, str, jflag)
+ int argc;
+ VALUE *argv;
+ VALUE str;
+ char jflag;
{
- rb_encoding *enc;
VALUE w;
- long width, len, flen = 1, fclen = 1;
+ long width, flen = 0;
VALUE res;
- char *p, *f = " ";
- long n, llen, rlen;
- volatile VALUE pad;
- int asc = 1;
+ char *p, *pend;
+ const char *f = " ";
+ long n;
+ VALUE pad;
rb_scan_args(argc, argv, "11", &w, &pad);
- enc = rb_enc_get(str);
width = NUM2LONG(w);
if (argc == 2) {
StringValue(pad);
- enc = rb_enc_check(str, pad);
- f = RSTRING_PTR(pad);
- flen = RSTRING_LEN(pad);
- fclen = str_strlen(pad, enc);
- asc = is_ascii_string(pad);
+ f = RSTRING(pad)->ptr;
+ flen = RSTRING(pad)->len;
if (flen == 0) {
rb_raise(rb_eArgError, "zero width padding");
}
}
- len = str_strlen(str, enc);
- if (width < 0 || len >= width) return rb_str_dup(str);
- n = width - len;
- llen = (jflag == 'l') ? 0 : ((jflag == 'r') ? n : n/2);
- rlen = n - llen;
- res = rb_str_new5(str, 0, RSTRING_LEN(str)+n*flen/fclen+2);
- p = RSTRING_PTR(res);
- while (llen) {
+ if (width < 0 || RSTRING(str)->len >= width) return rb_str_dup(str);
+ res = rb_str_new5(str, 0, width);
+ p = RSTRING(res)->ptr;
+ if (jflag != 'l') {
+ n = width - RSTRING(str)->len;
+ pend = p + ((jflag == 'r') ? n : n/2);
if (flen <= 1) {
- *p++ = *f;
- llen--;
- }
- else if (llen > fclen) {
- memcpy(p,f,flen);
- p += flen;
- llen -= fclen;
+ while (p < pend) {
+ *p++ = *f;
+ }
}
else {
- char *fp = str_nth(f, f+flen, llen, enc, asc);
- n = fp - f;
- memcpy(p,f,n);
- p+=n;
- break;
+ const char *q = f;
+ while (p + flen <= pend) {
+ memcpy(p,f,flen);
+ p += flen;
+ }
+ while (p < pend) {
+ *p++ = *q++;
+ }
}
}
- memcpy(p, RSTRING_PTR(str), RSTRING_LEN(str));
- p+=RSTRING_LEN(str);
- while (rlen) {
+ memcpy(p, RSTRING(str)->ptr, RSTRING(str)->len);
+ if (jflag != 'r') {
+ p += RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
if (flen <= 1) {
- *p++ = *f;
- rlen--;
- }
- else if (rlen > fclen) {
- memcpy(p,f,flen);
- p += flen;
- rlen -= fclen;
+ while (p < pend) {
+ *p++ = *f;
+ }
}
else {
- char *fp = str_nth(f, f+flen, rlen, enc, asc);
- n = fp - f;
- memcpy(p,f,n);
- p+=n;
- break;
+ while (p + flen <= pend) {
+ memcpy(p,f,flen);
+ p += flen;
+ }
+ while (p < pend) {
+ *p++ = *f++;
+ }
}
}
- *p = '\0';
- STR_SET_LEN(res, p-RSTRING_PTR(res));
OBJ_INFECT(res, str);
- if (!NIL_P(pad)) OBJ_INFECT(res, pad);
- rb_enc_associate(res, enc);
+ if (flen > 0) OBJ_INFECT(res, pad);
return res;
}
@@ -5145,7 +4678,10 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
*/
static VALUE
-rb_str_ljust(int argc, VALUE *argv, VALUE str)
+rb_str_ljust(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
return rb_str_justify(argc, argv, str, 'l');
}
@@ -5165,7 +4701,10 @@ rb_str_ljust(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_rjust(int argc, VALUE *argv, VALUE str)
+rb_str_rjust(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
return rb_str_justify(argc, argv, str, 'r');
}
@@ -5185,7 +4724,10 @@ rb_str_rjust(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_center(int argc, VALUE *argv, VALUE str)
+rb_str_center(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
return rb_str_justify(argc, argv, str, 'c');
}
@@ -5194,25 +4736,27 @@ rb_str_center(int argc, VALUE *argv, VALUE str)
* call-seq:
* str.partition(sep) => [head, sep, tail]
*
- * Searches the string for <i>sep</i> and returns the part before
- * it, the <i>sep</i>, and the part after it. If <i>sep</i> is not found,
- * returns <i>str</i> and two empty strings.
+ * Searches the string for <i>sep</i> and returns the part before it,
+ * the <i>sep</i>, and the part after it. If <i>sep</i> is not
+ * found, returns <i>str</i> and two empty strings. If no argument
+ * is given, Enumerable#partition is called.
*
* "hello".partition("l") #=> ["he", "l", "lo"]
* "hello".partition("x") #=> ["hello", "", ""]
*/
static VALUE
-rb_str_partition(VALUE str, VALUE sep)
+rb_str_partition(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
+ VALUE sep;
long pos;
- int regex = Qfalse;
- if (TYPE(sep) == T_REGEXP) {
- pos = rb_reg_search(sep, str, 0, 0);
- regex = Qtrue;
- }
- else {
+ if (argc == 0) return rb_call_super(argc, argv);
+ rb_scan_args(argc, argv, "1", &sep);
+ if (TYPE(sep) != T_REGEXP) {
VALUE tmp;
tmp = rb_check_string_type(sep);
@@ -5220,20 +4764,19 @@ rb_str_partition(VALUE str, VALUE sep)
rb_raise(rb_eTypeError, "type mismatch: %s given",
rb_obj_classname(sep));
}
- pos = rb_str_index(str, sep, 0);
+ sep = get_arg_pat(tmp);
}
+ pos = rb_reg_search(sep, str, 0, 0);
if (pos < 0) {
failed:
return rb_ary_new3(3, str, rb_str_new(0,0),rb_str_new(0,0));
}
- if (regex) {
- sep = rb_str_subpat(str, sep, 0);
- if (pos == 0 && RSTRING_LEN(sep) == 0) goto failed;
- }
- return rb_ary_new3(3, rb_str_subseq(str, 0, pos),
+ sep = rb_str_subpat(str, sep, 0);
+ if (pos == 0 && RSTRING(sep)->len == 0) goto failed;
+ return rb_ary_new3(3, rb_str_substr(str, 0, pos),
sep,
- rb_str_subseq(str, pos+RSTRING_LEN(sep),
- RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
+ rb_str_substr(str, pos+RSTRING(sep)->len,
+ RSTRING(str)->len-pos-RSTRING(sep)->len));
}
/*
@@ -5250,16 +4793,13 @@ rb_str_partition(VALUE str, VALUE sep)
*/
static VALUE
-rb_str_rpartition(VALUE str, VALUE sep)
+rb_str_rpartition(str, sep)
+ VALUE str;
+ VALUE sep;
{
- long pos = RSTRING_LEN(str);
- int regex = Qfalse;
+ long pos = RSTRING(str)->len;
- if (TYPE(sep) == T_REGEXP) {
- pos = rb_reg_search(sep, str, pos, 1);
- regex = Qtrue;
- }
- else {
+ if (TYPE(sep) != T_REGEXP) {
VALUE tmp;
tmp = rb_check_string_type(sep);
@@ -5267,19 +4807,17 @@ rb_str_rpartition(VALUE str, VALUE sep)
rb_raise(rb_eTypeError, "type mismatch: %s given",
rb_obj_classname(sep));
}
- pos = rb_str_sublen(str, pos);
- pos = rb_str_rindex(str, sep, pos);
+ sep = get_arg_pat(tmp);
}
+ pos = rb_reg_search(sep, str, pos, 1);
if (pos < 0) {
return rb_ary_new3(3, rb_str_new(0,0),rb_str_new(0,0), str);
}
- if (regex) {
- sep = rb_reg_nth_match(0, rb_backref_get());
- }
- return rb_ary_new3(3, rb_str_subseq(str, 0, pos),
+ sep = rb_reg_nth_match(0, rb_backref_get());
+ return rb_ary_new3(3, rb_str_substr(str, 0, pos),
sep,
- rb_str_subseq(str, pos+RSTRING_LEN(sep),
- RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
+ rb_str_substr(str, pos+RSTRING(sep)->len,
+ RSTRING(str)->len-pos-RSTRING(sep)->len));
}
/*
@@ -5290,16 +4828,20 @@ rb_str_rpartition(VALUE str, VALUE sep)
*/
static VALUE
-rb_str_start_with(int argc, VALUE *argv, VALUE str)
+rb_str_start_with(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
int i;
+ VALUE pat;
for (i=0; i<argc; i++) {
- VALUE tmp = rb_check_string_type(argv[i]);
- if (NIL_P(tmp)) continue;
- rb_enc_check(str, tmp);
- if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
- if (memcmp(RSTRING_PTR(str), RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
+ VALUE prefix = rb_check_string_type(argv[i]);
+ if (NIL_P(prefix)) continue;
+ if (RSTRING(str)->len < RSTRING(prefix)->len) continue;
+ pat = get_arg_pat(prefix);
+ if (rb_reg_search(pat, str, 0, 1) >= 0)
return Qtrue;
}
return Qfalse;
@@ -5313,24 +4855,32 @@ rb_str_start_with(int argc, VALUE *argv, VALUE str)
*/
static VALUE
-rb_str_end_with(int argc, VALUE *argv, VALUE str)
+rb_str_end_with(argc, argv, str)
+ int argc;
+ VALUE *argv;
+ VALUE str;
{
int i;
+ long pos;
+ VALUE pat;
for (i=0; i<argc; i++) {
- VALUE tmp = rb_check_string_type(argv[i]);
- if (NIL_P(tmp)) continue;
- rb_enc_check(str, tmp);
- if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
- if (memcmp(RSTRING_PTR(str) + RSTRING_LEN(str) - RSTRING_LEN(tmp),
- RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
- return Qtrue;
+ VALUE suffix = rb_check_string_type(argv[i]);
+ if (NIL_P(suffix)) continue;
+ if (RSTRING(str)->len < RSTRING(suffix)->len) continue;
+ pat = get_arg_pat(suffix);
+ pos = rb_reg_adjust_startpos(pat, str, RSTRING(str)->len - RSTRING(suffix)->len, 0);
+ if (rb_reg_search(pat, str, pos, 0) >= 0)
+ return Qtrue;
}
return Qfalse;
}
void
-rb_str_setter(VALUE val, ID id, VALUE *var)
+rb_str_setter(val, id, var)
+ VALUE val;
+ ID id;
+ VALUE *var;
{
if (!NIL_P(val) && TYPE(val) != T_STRING) {
rb_raise(rb_eTypeError, "value of %s must be String", rb_id2name(id));
@@ -5340,336 +4890,6 @@ rb_str_setter(VALUE val, ID id, VALUE *var)
/*
- * call-seq:
- * str.force_encoding(encoding) => str
- *
- * Changes the encoding to +encoding+ and returns self.
- */
-
-static VALUE
-rb_str_force_encoding(VALUE str, VALUE enc)
-{
- str_modifiable(str);
- rb_enc_associate(str, rb_to_encoding(enc));
- return str;
-}
-
-/*
- * call-seq:
- * str.valid_encoding? => true or false
- *
- * Returns true for a string which encoded correctly.
- *
- * "\xc2\xa1".force_encoding("UTF-8").valid_encoding? => true
- * "\xc2".force_encoding("UTF-8").valid_encoding? => false
- * "\x80".force_encoding("UTF-8").valid_encoding? => false
- */
-
-static VALUE
-rb_str_valid_encoding_p(VALUE str)
-{
- int cr = rb_enc_str_coderange(str);
-
- return cr == ENC_CODERANGE_BROKEN ? Qfalse : Qtrue;
-}
-
-/*
- * call-seq:
- * str.ascii_only? => true or false
- *
- * Returns true for a string which has only ASCII characters.
- *
- * "abc".force_encoding("UTF-8").ascii_only? => true
- * "abc\u{6666}".force_encoding("UTF-8").ascii_only? => false
- */
-
-static VALUE
-rb_str_is_ascii_only_p(VALUE str)
-{
- int cr = rb_enc_str_coderange(str);
-
- return cr == ENC_CODERANGE_7BIT ? Qtrue : Qfalse;
-}
-
-/**********************************************************************
- * Document-class: Symbol
- *
- * <code>Symbol</code> objects represent names and some strings
- * inside the Ruby
- * interpreter. They are generated using the <code>:name</code> and
- * <code>:"string"</code> literals
- * syntax, and by the various <code>to_sym</code> methods. The same
- * <code>Symbol</code> object will be created for a given name or string
- * for the duration of a program's execution, regardless of the context
- * or meaning of that name. Thus if <code>Fred</code> is a constant in
- * one context, a method in another, and a class in a third, the
- * <code>Symbol</code> <code>:Fred</code> will be the same object in
- * all three contexts.
- *
- * module One
- * class Fred
- * end
- * $f1 = :Fred
- * end
- * module Two
- * Fred = 1
- * $f2 = :Fred
- * end
- * def Fred()
- * end
- * $f3 = :Fred
- * $f1.id #=> 2514190
- * $f2.id #=> 2514190
- * $f3.id #=> 2514190
- *
- */
-
-
-/*
- * call-seq:
- * sym == obj => true or false
- *
- * Equality---If <i>sym</i> and <i>obj</i> are exactly the same
- * symbol, returns <code>true</code>. Otherwise, compares them
- * as strings.
- */
-
-static VALUE
-sym_equal(VALUE sym1, VALUE sym2)
-{
- if (sym1 == sym2) return Qtrue;
- return Qfalse;
-}
-
-
-/*
- * call-seq:
- * sym.to_i => fixnum
- *
- * Returns an integer that is unique for each symbol within a
- * particular execution of a program.
- *
- * :fred.to_i #=> 9809
- * "fred".to_sym.to_i #=> 9809
- */
-
-static VALUE
-sym_to_i(VALUE sym)
-{
- ID id = SYM2ID(sym);
-
- return LONG2FIX(id);
-}
-
-
-/*
- * call-seq:
- * sym.inspect => string
- *
- * Returns the representation of <i>sym</i> as a symbol literal.
- *
- * :fred.inspect #=> ":fred"
- */
-
-static VALUE
-sym_inspect(VALUE sym)
-{
- VALUE str, klass = Qundef;
- ID id = SYM2ID(sym);
- rb_encoding *enc;
-
- sym = rb_id2str(id);
- enc = rb_enc_get(sym);
- str = rb_enc_str_new(0, RSTRING_LEN(sym)+1, enc);
- RSTRING_PTR(str)[0] = ':';
- memcpy(RSTRING_PTR(str)+1, RSTRING_PTR(sym), RSTRING_LEN(sym));
- if (RSTRING_LEN(sym) != strlen(RSTRING_PTR(sym)) ||
- !rb_enc_symname_p(RSTRING_PTR(sym), enc)) {
- str = rb_str_dump(str);
- strncpy(RSTRING_PTR(str), ":\"", 2);
- }
- if (klass != Qundef) {
- rb_str_cat2(str, "/");
- rb_str_append(str, rb_inspect(klass));
- }
- return str;
-}
-
-
-/*
- * call-seq:
- * sym.id2name => string
- * sym.to_s => string
- *
- * Returns the name or string corresponding to <i>sym</i>.
- *
- * :fred.id2name #=> "fred"
- */
-
-
-VALUE
-rb_sym_to_s(VALUE sym)
-{
- ID id = SYM2ID(sym);
-
- return str_new3(rb_cString, rb_id2str(id));
-}
-
-
-/*
- * call-seq:
- * sym.to_sym => sym
- * sym.intern => sym
- *
- * In general, <code>to_sym</code> returns the <code>Symbol</code> corresponding
- * to an object. As <i>sym</i> is already a symbol, <code>self</code> is returned
- * in this case.
- */
-
-static VALUE
-sym_to_sym(VALUE sym)
-{
- return sym;
-}
-
-static VALUE
-sym_call(VALUE args, VALUE sym, int argc, VALUE *argv)
-{
- VALUE obj;
-
- if (argc < 1) {
- rb_raise(rb_eArgError, "no receiver given");
- }
- obj = argv[0];
- return rb_funcall3(obj, (ID)sym, argc - 1, argv + 1);
-}
-
-/*
- * call-seq:
- * sym.to_proc
- *
- * Returns a _Proc_ object which respond to the given method by _sym_.
- *
- * (1..3).collect(&:to_s) #=> ["1", "2", "3"]
- */
-
-static VALUE
-sym_to_proc(VALUE sym)
-{
- return rb_proc_new(sym_call, (VALUE)SYM2ID(sym));
-}
-
-
-static VALUE
-sym_succ(VALUE sym)
-{
- return rb_str_intern(rb_str_succ(rb_sym_to_s(sym)));
-}
-
-static VALUE
-sym_cmp(VALUE sym, VALUE other)
-{
- if (!SYMBOL_P(other)) {
- return Qnil;
- }
- return rb_str_cmp_m(rb_sym_to_s(sym), rb_sym_to_s(other));
-}
-
-static VALUE
-sym_casecmp(VALUE sym, VALUE other)
-{
- if (!SYMBOL_P(other)) {
- return Qnil;
- }
- return rb_str_casecmp(rb_sym_to_s(sym), rb_sym_to_s(other));
-}
-
-static VALUE
-sym_match(VALUE sym, VALUE other)
-{
- return rb_str_match(rb_sym_to_s(sym), other);
-}
-
-static VALUE
-sym_eqq(VALUE sym, VALUE other)
-{
- if (sym == other) return Qtrue;
- return rb_str_equal(rb_sym_to_s(sym), other);
-}
-
-static VALUE
-sym_aref(int argc, VALUE *argv, VALUE sym)
-{
- return rb_str_aref_m(argc, argv, rb_sym_to_s(sym));
-}
-
-static VALUE
-sym_length(VALUE sym)
-{
- return rb_str_length(rb_id2str(SYM2ID(sym)));
-}
-
-static VALUE
-sym_empty(VALUE sym)
-{
- return rb_str_empty(rb_id2str(SYM2ID(sym)));
-}
-
-static VALUE
-sym_upcase(VALUE sym)
-{
- return rb_str_intern(rb_str_upcase(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_downcase(VALUE sym)
-{
- return rb_str_intern(rb_str_downcase(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_capitalize(VALUE sym)
-{
- return rb_str_intern(rb_str_capitalize(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_swapcase(VALUE sym)
-{
- return rb_str_intern(rb_str_swapcase(rb_id2str(SYM2ID(sym))));
-}
-
-static VALUE
-sym_encoding(VALUE sym)
-{
- return rb_obj_encoding(rb_id2str(SYM2ID(sym)));
-}
-
-ID
-rb_to_id(VALUE name)
-{
- VALUE tmp;
- ID id;
-
- switch (TYPE(name)) {
- default:
- tmp = rb_check_string_type(name);
- if (NIL_P(tmp)) {
- rb_raise(rb_eTypeError, "%s is not a symbol",
- RSTRING_PTR(rb_inspect(name)));
- }
- name = tmp;
- /* fall through */
- case T_STRING:
- name = rb_str_intern(name);
- /* fall through */
- case T_SYMBOL:
- return SYM2ID(name);
- }
- return id;
-}
-
-/*
* A <code>String</code> object holds and manipulates an arbitrary sequence of
* bytes, typically representing characters. String objects may be created
* using <code>String::new</code> or as literals.
@@ -5683,12 +4903,12 @@ rb_to_id(VALUE name)
*/
void
-Init_String(void)
+Init_String()
{
rb_cString = rb_define_class("String", rb_cObject);
rb_include_module(rb_cString, rb_mComparable);
+ rb_include_module(rb_cString, rb_mEnumerable);
rb_define_alloc_func(rb_cString, str_alloc);
- rb_define_singleton_method(rb_cString, "try_convert", rb_str_s_try_convert, 1);
rb_define_method(rb_cString, "initialize", rb_str_init, -1);
rb_define_method(rb_cString, "initialize_copy", rb_str_replace, 1);
rb_define_method(rb_cString, "<=>", rb_str_cmp_m, 1);
@@ -5704,20 +4924,18 @@ Init_String(void)
rb_define_method(rb_cString, "insert", rb_str_insert, 2);
rb_define_method(rb_cString, "length", rb_str_length, 0);
rb_define_method(rb_cString, "size", rb_str_length, 0);
- rb_define_method(rb_cString, "bytesize", rb_str_bytesize, 0);
+ rb_define_method(rb_cString, "bytesize", rb_str_length, 0);
rb_define_method(rb_cString, "empty?", rb_str_empty, 0);
rb_define_method(rb_cString, "=~", rb_str_match, 1);
- rb_define_method(rb_cString, "match", rb_str_match_m, -1);
+ rb_define_method(rb_cString, "match", rb_str_match_m, 1);
rb_define_method(rb_cString, "succ", rb_str_succ, 0);
rb_define_method(rb_cString, "succ!", rb_str_succ_bang, 0);
rb_define_method(rb_cString, "next", rb_str_succ, 0);
rb_define_method(rb_cString, "next!", rb_str_succ_bang, 0);
- rb_define_method(rb_cString, "upto", rb_str_upto, -1);
+ rb_define_method(rb_cString, "upto", rb_str_upto_m, -1);
rb_define_method(rb_cString, "index", rb_str_index_m, -1);
rb_define_method(rb_cString, "rindex", rb_str_rindex_m, -1);
rb_define_method(rb_cString, "replace", rb_str_replace, 1);
- rb_define_method(rb_cString, "clear", rb_str_clear, 0);
- rb_define_method(rb_cString, "chr", rb_str_chr, 0);
rb_define_method(rb_cString, "to_i", rb_str_to_i, -1);
rb_define_method(rb_cString, "to_f", rb_str_to_f, 0);
@@ -5739,8 +4957,6 @@ Init_String(void)
rb_define_method(rb_cString, "hex", rb_str_hex, 0);
rb_define_method(rb_cString, "oct", rb_str_oct, 0);
rb_define_method(rb_cString, "split", rb_str_split_m, -1);
- rb_define_method(rb_cString, "lines", rb_str_each_line, -1);
- rb_define_method(rb_cString, "bytes", rb_str_each_byte, 0);
rb_define_method(rb_cString, "reverse", rb_str_reverse, 0);
rb_define_method(rb_cString, "reverse!", rb_str_reverse_bang, 0);
rb_define_method(rb_cString, "concat", rb_str_concat, 1);
@@ -5748,7 +4964,6 @@ Init_String(void)
rb_define_method(rb_cString, "crypt", rb_str_crypt, 1);
rb_define_method(rb_cString, "intern", rb_str_intern, 0);
rb_define_method(rb_cString, "to_sym", rb_str_intern, 0);
- rb_define_method(rb_cString, "ord", rb_str_ord, 0);
rb_define_method(rb_cString, "include?", rb_str_include, 1);
rb_define_method(rb_cString, "start_with?", rb_str_start_with, -1);
@@ -5788,61 +5003,40 @@ Init_String(void)
rb_define_method(rb_cString, "squeeze!", rb_str_squeeze_bang, -1);
rb_define_method(rb_cString, "each_line", rb_str_each_line, -1);
+ rb_define_method(rb_cString, "each", rb_str_each_line, -1);
rb_define_method(rb_cString, "each_byte", rb_str_each_byte, 0);
rb_define_method(rb_cString, "each_char", rb_str_each_char, 0);
+ rb_define_method(rb_cString, "lines", rb_str_each_line, -1);
+ rb_define_method(rb_cString, "bytes", rb_str_each_byte, 0);
+ rb_define_method(rb_cString, "chars", rb_str_each_char, 0);
+
rb_define_method(rb_cString, "sum", rb_str_sum, -1);
+ rb_define_global_function("sub", rb_f_sub, -1);
+ rb_define_global_function("gsub", rb_f_gsub, -1);
+
+ rb_define_global_function("sub!", rb_f_sub_bang, -1);
+ rb_define_global_function("gsub!", rb_f_gsub_bang, -1);
+
+ rb_define_global_function("chop", rb_f_chop, 0);
+ rb_define_global_function("chop!", rb_f_chop_bang, 0);
+
+ rb_define_global_function("chomp", rb_f_chomp, -1);
+ rb_define_global_function("chomp!", rb_f_chomp_bang, -1);
+
+ rb_define_global_function("split", rb_f_split, -1);
+ rb_define_global_function("scan", rb_f_scan, 1);
+
rb_define_method(rb_cString, "slice", rb_str_aref_m, -1);
rb_define_method(rb_cString, "slice!", rb_str_slice_bang, -1);
- rb_define_method(rb_cString, "partition", rb_str_partition, 1);
+ rb_define_method(rb_cString, "partition", rb_str_partition, -1);
rb_define_method(rb_cString, "rpartition", rb_str_rpartition, 1);
- rb_define_method(rb_cString, "encoding", rb_obj_encoding, 0); /* in encoding.c */
- rb_define_method(rb_cString, "force_encoding", rb_str_force_encoding, 1);
- rb_define_method(rb_cString, "valid_encoding?", rb_str_valid_encoding_p, 0);
- rb_define_method(rb_cString, "ascii_only?", rb_str_is_ascii_only_p, 0);
-
id_to_s = rb_intern("to_s");
rb_fs = Qnil;
rb_define_variable("$;", &rb_fs);
rb_define_variable("$-F", &rb_fs);
-
- rb_cSymbol = rb_define_class("Symbol", rb_cObject);
- rb_include_module(rb_cSymbol, rb_mComparable);
- rb_undef_alloc_func(rb_cSymbol);
- rb_undef_method(CLASS_OF(rb_cSymbol), "new");
- rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in parse.y */
-
- rb_define_method(rb_cSymbol, "==", sym_equal, 1);
- rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0);
- rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
- rb_define_method(rb_cSymbol, "to_s", rb_sym_to_s, 0);
- rb_define_method(rb_cSymbol, "id2name", rb_sym_to_s, 0);
- rb_define_method(rb_cSymbol, "intern", sym_to_sym, 0);
- rb_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
- rb_define_method(rb_cSymbol, "to_proc", sym_to_proc, 0);
- rb_define_method(rb_cSymbol, "succ", sym_succ, 0);
- rb_define_method(rb_cSymbol, "next", sym_succ, 0);
-
- rb_define_method(rb_cSymbol, "<=>", sym_cmp, 1);
- rb_define_method(rb_cSymbol, "casecmp", sym_casecmp, 1);
- rb_define_method(rb_cSymbol, "=~", sym_match, 1);
- rb_define_method(rb_cSymbol, "===", sym_eqq, 1);
-
- rb_define_method(rb_cSymbol, "[]", sym_aref, -1);
- rb_define_method(rb_cSymbol, "slice", sym_aref, -1);
- rb_define_method(rb_cSymbol, "length", sym_length, 0);
- rb_define_method(rb_cSymbol, "size", sym_length, 0);
- rb_define_method(rb_cSymbol, "empty?", sym_empty, 0);
- rb_define_method(rb_cSymbol, "match", sym_match, -1);
-
- rb_define_method(rb_cSymbol, "upcase", sym_upcase, 0);
- rb_define_method(rb_cSymbol, "downcase", sym_downcase, 0);
- rb_define_method(rb_cSymbol, "capitalize", sym_capitalize, 0);
- rb_define_method(rb_cSymbol, "swapcase", sym_swapcase, 0);
-
- rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
}
diff --git a/struct.c b/struct.c
index 2fadd47dfc..9417c1c347 100644
--- a/struct.c
+++ b/struct.c
@@ -6,18 +6,21 @@
$Date$
created at: Tue Mar 22 18:44:30 JST 1995
- Copyright (C) 1993-2007 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "ruby/ruby.h"
+#include "ruby.h"
+#include "env.h"
VALUE rb_cStruct;
-static VALUE struct_alloc(VALUE);
+static VALUE struct_alloc _((VALUE));
VALUE
-rb_struct_iv_get(VALUE c, const char *name)
+rb_struct_iv_get(c, name)
+ VALUE c;
+ const char *name;
{
ID id;
@@ -25,14 +28,15 @@ rb_struct_iv_get(VALUE c, const char *name)
for (;;) {
if (rb_ivar_defined(c, id))
return rb_ivar_get(c, id);
- c = RCLASS_SUPER(c);
+ c = RCLASS(c)->super;
if (c == 0 || c == rb_cStruct)
return Qnil;
}
}
VALUE
-rb_struct_s_members(VALUE klass)
+rb_struct_s_members(klass)
+ VALUE klass;
{
VALUE members = rb_struct_iv_get(klass, "__members__");
@@ -46,28 +50,30 @@ rb_struct_s_members(VALUE klass)
}
VALUE
-rb_struct_members(VALUE s)
+rb_struct_members(s)
+ VALUE s;
{
VALUE members = rb_struct_s_members(rb_obj_class(s));
- if (RSTRUCT_LEN(s) != RARRAY_LEN(members)) {
- rb_raise(rb_eTypeError, "struct size differs (%ld required %ld given)",
- RARRAY_LEN(members), RSTRUCT_LEN(s));
+ if (RSTRUCT(s)->len != RARRAY(members)->len) {
+ rb_raise(rb_eTypeError, "struct size differs (%d required %d given)",
+ RARRAY(members)->len, RSTRUCT(s)->len);
}
return members;
}
static VALUE
-rb_struct_s_members_m(VALUE klass)
+rb_struct_s_members_m(klass)
+ VALUE klass;
{
VALUE members, ary;
VALUE *p, *pend;
members = rb_struct_s_members(klass);
- ary = rb_ary_new2(RARRAY_LEN(members));
- p = RARRAY_PTR(members); pend = p + RARRAY_LEN(members);
+ ary = rb_ary_new2(RARRAY(members)->len);
+ p = RARRAY(members)->ptr; pend = p + RARRAY(members)->len;
while (p < pend) {
- rb_ary_push(ary, *p);
+ rb_ary_push(ary, rb_str_new2(rb_id2name(SYM2ID(*p))));
p++;
}
@@ -87,22 +93,25 @@ rb_struct_s_members_m(VALUE klass)
*/
static VALUE
-rb_struct_members_m(VALUE obj)
+rb_struct_members_m(obj)
+ VALUE obj;
{
return rb_struct_s_members_m(rb_obj_class(obj));
}
VALUE
-rb_struct_getmember(VALUE obj, ID id)
+rb_struct_getmember(obj, id)
+ VALUE obj;
+ ID id;
{
VALUE members, slot;
long i;
members = rb_struct_members(obj);
slot = ID2SYM(id);
- for (i=0; i<RARRAY_LEN(members); i++) {
- if (RARRAY_PTR(members)[i] == slot) {
- return RSTRUCT_PTR(obj)[i];
+ for (i=0; i<RARRAY(members)->len; i++) {
+ if (RARRAY(members)->ptr[i] == slot) {
+ return RSTRUCT(obj)->ptr[i];
}
}
rb_name_error(id, "%s is not struct member", rb_id2name(id));
@@ -110,25 +119,24 @@ rb_struct_getmember(VALUE obj, ID id)
}
static VALUE
-rb_struct_ref(VALUE obj)
+rb_struct_ref(obj)
+ VALUE obj;
{
- return rb_struct_getmember(obj, rb_frame_this_func());
+ return rb_struct_getmember(obj, ruby_frame->orig_func);
}
-static VALUE rb_struct_ref0(VALUE obj) {return RSTRUCT_PTR(obj)[0];}
-static VALUE rb_struct_ref1(VALUE obj) {return RSTRUCT_PTR(obj)[1];}
-static VALUE rb_struct_ref2(VALUE obj) {return RSTRUCT_PTR(obj)[2];}
-static VALUE rb_struct_ref3(VALUE obj) {return RSTRUCT_PTR(obj)[3];}
-static VALUE rb_struct_ref4(VALUE obj) {return RSTRUCT_PTR(obj)[4];}
-static VALUE rb_struct_ref5(VALUE obj) {return RSTRUCT_PTR(obj)[5];}
-static VALUE rb_struct_ref6(VALUE obj) {return RSTRUCT_PTR(obj)[6];}
-static VALUE rb_struct_ref7(VALUE obj) {return RSTRUCT_PTR(obj)[7];}
-static VALUE rb_struct_ref8(VALUE obj) {return RSTRUCT_PTR(obj)[8];}
-static VALUE rb_struct_ref9(VALUE obj) {return RSTRUCT_PTR(obj)[9];}
+static VALUE rb_struct_ref0(obj) VALUE obj; {return RSTRUCT(obj)->ptr[0];}
+static VALUE rb_struct_ref1(obj) VALUE obj; {return RSTRUCT(obj)->ptr[1];}
+static VALUE rb_struct_ref2(obj) VALUE obj; {return RSTRUCT(obj)->ptr[2];}
+static VALUE rb_struct_ref3(obj) VALUE obj; {return RSTRUCT(obj)->ptr[3];}
+static VALUE rb_struct_ref4(obj) VALUE obj; {return RSTRUCT(obj)->ptr[4];}
+static VALUE rb_struct_ref5(obj) VALUE obj; {return RSTRUCT(obj)->ptr[5];}
+static VALUE rb_struct_ref6(obj) VALUE obj; {return RSTRUCT(obj)->ptr[6];}
+static VALUE rb_struct_ref7(obj) VALUE obj; {return RSTRUCT(obj)->ptr[7];}
+static VALUE rb_struct_ref8(obj) VALUE obj; {return RSTRUCT(obj)->ptr[8];}
+static VALUE rb_struct_ref9(obj) VALUE obj; {return RSTRUCT(obj)->ptr[9];}
-#define N_REF_FUNC (sizeof(ref_func) / sizeof(ref_func[0]))
-
-static VALUE (*ref_func[])(VALUE) = {
+static VALUE (*ref_func[10])() = {
rb_struct_ref0,
rb_struct_ref1,
rb_struct_ref2,
@@ -142,7 +150,8 @@ static VALUE (*ref_func[])(VALUE) = {
};
static void
-rb_struct_modify(VALUE s)
+rb_struct_modify(s)
+ VALUE s;
{
if (OBJ_FROZEN(s)) rb_error_frozen("Struct");
if (!OBJ_TAINTED(s) && rb_safe_level() >= 4)
@@ -150,26 +159,30 @@ rb_struct_modify(VALUE s)
}
static VALUE
-rb_struct_set(VALUE obj, VALUE val)
+rb_struct_set(obj, val)
+ VALUE obj, val;
{
VALUE members, slot;
+ ID id;
long i;
members = rb_struct_members(obj);
rb_struct_modify(obj);
- for (i=0; i<RARRAY_LEN(members); i++) {
- slot = RARRAY_PTR(members)[i];
- if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
- return RSTRUCT_PTR(obj)[i] = val;
+ id = ruby_frame->orig_func;
+ for (i=0; i<RARRAY(members)->len; i++) {
+ slot = RARRAY(members)->ptr[i];
+ if (rb_id_attrset(SYM2ID(slot)) == id) {
+ return RSTRUCT(obj)->ptr[i] = val;
}
}
- rb_name_error(rb_frame_this_func(), "`%s' is not a struct member",
- rb_id2name(rb_frame_this_func()));
+ rb_name_error(ruby_frame->last_func, "`%s' is not a struct member",
+ rb_id2name(id));
return Qnil; /* not reached */
}
static VALUE
-make_struct(VALUE name, VALUE members, VALUE klass)
+make_struct(name, members, klass)
+ VALUE name, members, klass;
{
VALUE nstr;
ID id;
@@ -183,7 +196,6 @@ make_struct(VALUE name, VALUE members, VALUE klass)
}
else {
char *cname = StringValuePtr(name);
-
id = rb_intern(cname);
if (!rb_is_const_id(id)) {
rb_name_error(id, "identifier %s needs to be constant", cname);
@@ -194,17 +206,17 @@ make_struct(VALUE name, VALUE members, VALUE klass)
}
nstr = rb_define_class_under(klass, rb_id2name(id), klass);
}
- rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY_LEN(members)));
+ rb_iv_set(nstr, "__size__", LONG2NUM(RARRAY(members)->len));
rb_iv_set(nstr, "__members__", members);
rb_define_alloc_func(nstr, struct_alloc);
rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1);
rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1);
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
- for (i=0; i< RARRAY_LEN(members); i++) {
- ID id = SYM2ID(RARRAY_PTR(members)[i]);
+ for (i=0; i< RARRAY(members)->len; i++) {
+ ID id = SYM2ID(RARRAY(members)->ptr[i]);
if (rb_is_local_id(id) || rb_is_const_id(id)) {
- if (i < N_REF_FUNC) {
+ if (i<10) {
rb_define_method_id(nstr, id, ref_func[i], 0);
}
else {
@@ -217,52 +229,22 @@ make_struct(VALUE name, VALUE members, VALUE klass)
return nstr;
}
-VALUE
-rb_struct_alloc_noinit(VALUE klass)
-{
- return struct_alloc(klass);
-}
-
-VALUE
-rb_struct_define_without_accessor(char *class_name, VALUE super, rb_alloc_func_t alloc, ...)
-{
- VALUE klass;
- va_list ar;
- VALUE members;
- long i;
- char *name;
-
- members = rb_ary_new2(0);
- va_start(ar, alloc);
- i = 0;
- while ((name = va_arg(ar, char*)) != NULL) {
- rb_ary_push(members, ID2SYM(rb_intern(name)));
- }
- va_end(ar);
- OBJ_FREEZE(members);
-
- if (class_name) {
- klass = rb_define_class(class_name, super);
- }
- else {
- klass = rb_class_new(super);
- rb_make_metaclass(klass, RBASIC(super)->klass);
- rb_class_inherited(super, klass);
- }
-
- rb_iv_set(klass, "__size__", LONG2NUM(RARRAY_LEN(members)));
- rb_iv_set(klass, "__members__", members);
-
- if (alloc)
- rb_define_alloc_func(klass, alloc);
- else
- rb_define_alloc_func(klass, struct_alloc);
-
- return klass;
-}
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
rb_struct_define(const char *name, ...)
+#else
+rb_struct_define(name, va_alist)
+ const char *name;
+ va_dcl
+#endif
{
va_list ar;
VALUE nm, ary;
@@ -272,7 +254,7 @@ rb_struct_define(const char *name, ...)
else nm = rb_str_new2(name);
ary = rb_ary_new();
- va_start(ar, name);
+ va_init_list(ar, name);
while ((mem = va_arg(ar, char*)) != 0) {
ID slot = rb_intern(mem);
rb_ary_push(ary, ID2SYM(slot));
@@ -317,7 +299,10 @@ rb_struct_define(const char *name, ...)
*/
static VALUE
-rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
+rb_struct_s_def(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
VALUE name, rest;
long i;
@@ -325,14 +310,14 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
ID id;
rb_scan_args(argc, argv, "1*", &name, &rest);
- for (i=0; i<RARRAY_LEN(rest); i++) {
- id = rb_to_id(RARRAY_PTR(rest)[i]);
- RARRAY_PTR(rest)[i] = ID2SYM(id);
- }
if (!NIL_P(name) && SYMBOL_P(name)) {
rb_ary_unshift(rest, name);
name = Qnil;
}
+ for (i=0; i<RARRAY(rest)->len; i++) {
+ id = rb_to_id(RARRAY(rest)->ptr[i]);
+ RARRAY(rest)->ptr[i] = ID2SYM(id);
+ }
st = make_struct(name, rest, klass);
if (rb_block_given_p()) {
rb_mod_module_eval(0, 0, st);
@@ -344,8 +329,9 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
/*
*/
-VALUE
-rb_struct_initialize(VALUE self, VALUE values)
+static VALUE
+rb_struct_initialize(self, values)
+ VALUE self, values;
{
VALUE klass = rb_obj_class(self);
VALUE size;
@@ -354,19 +340,20 @@ rb_struct_initialize(VALUE self, VALUE values)
rb_struct_modify(self);
size = rb_struct_iv_get(klass, "__size__");
n = FIX2LONG(size);
- if (n < RARRAY_LEN(values)) {
+ if (n < RARRAY(values)->len) {
rb_raise(rb_eArgError, "struct size differs");
}
- MEMCPY(RSTRUCT_PTR(self), RARRAY_PTR(values), VALUE, RARRAY_LEN(values));
- if (n > RARRAY_LEN(values)) {
- rb_mem_clear(RSTRUCT_PTR(self)+RARRAY_LEN(values),
- n-RARRAY_LEN(values));
+ MEMCPY(RSTRUCT(self)->ptr, RARRAY(values)->ptr, VALUE, RARRAY(values)->len);
+ if (n > RARRAY(values)->len) {
+ rb_mem_clear(RSTRUCT(self)->ptr+RARRAY(values)->len,
+ n-RARRAY(values)->len);
}
return Qnil;
}
static VALUE
-struct_alloc(VALUE klass)
+struct_alloc(klass)
+ VALUE klass;
{
VALUE size;
long n;
@@ -376,28 +363,28 @@ struct_alloc(VALUE klass)
size = rb_struct_iv_get(klass, "__size__");
n = FIX2LONG(size);
- if (0 < n && n <= RSTRUCT_EMBED_LEN_MAX) {
- RBASIC(st)->flags &= ~RSTRUCT_EMBED_LEN_MASK;
- RBASIC(st)->flags |= n << RSTRUCT_EMBED_LEN_SHIFT;
- rb_mem_clear(st->as.ary, n);
- }
- else {
- st->as.heap.ptr = ALLOC_N(VALUE, n);
- rb_mem_clear(st->as.heap.ptr, n);
- st->as.heap.len = n;
- }
+ st->ptr = ALLOC_N(VALUE, n);
+ rb_mem_clear(st->ptr, n);
+ st->len = n;
return (VALUE)st;
}
VALUE
-rb_struct_alloc(VALUE klass, VALUE values)
+rb_struct_alloc(klass, values)
+ VALUE klass, values;
{
- return rb_class_new_instance(RARRAY_LEN(values), RARRAY_PTR(values), klass);
+ return rb_class_new_instance(RARRAY(values)->len, RARRAY(values)->ptr, klass);
}
VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
rb_struct_new(VALUE klass, ...)
+#else
+rb_struct_new(klass, va_alist)
+ VALUE klass;
+ va_dcl
+#endif
{
VALUE sz, *mem;
long size, i;
@@ -406,7 +393,7 @@ rb_struct_new(VALUE klass, ...)
sz = rb_struct_iv_get(klass, "__size__");
size = FIX2LONG(sz);
mem = ALLOCA_N(VALUE, size);
- va_start(args, klass);
+ va_init_list(args, klass);
for (i=0; i<size; i++) {
mem[i] = va_arg(args, VALUE);
}
@@ -434,13 +421,14 @@ rb_struct_new(VALUE klass, ...)
*/
static VALUE
-rb_struct_each(VALUE s)
+rb_struct_each(s)
+ VALUE s;
{
long i;
RETURN_ENUMERATOR(s, 0, 0);
- for (i=0; i<RSTRUCT_LEN(s); i++) {
- rb_yield(RSTRUCT_PTR(s)[i]);
+ for (i=0; i<RSTRUCT(s)->len; i++) {
+ rb_yield(RSTRUCT(s)->ptr[i]);
}
return s;
}
@@ -464,54 +452,51 @@ rb_struct_each(VALUE s)
*/
static VALUE
-rb_struct_each_pair(VALUE s)
+rb_struct_each_pair(s)
+ VALUE s;
{
VALUE members;
long i;
RETURN_ENUMERATOR(s, 0, 0);
members = rb_struct_members(s);
- for (i=0; i<RSTRUCT_LEN(s); i++) {
- rb_yield_values(2, rb_ary_entry(members, i), RSTRUCT_PTR(s)[i]);
+ for (i=0; i<RSTRUCT(s)->len; i++) {
+ rb_yield_values(2, rb_ary_entry(members, i), RSTRUCT(s)->ptr[i]);
}
return s;
}
static VALUE
-inspect_struct(VALUE s, VALUE dummy, int recur)
+inspect_struct(s)
+ VALUE s;
{
- char *cname = rb_class2name(rb_obj_class(s));
+ const char *cname = rb_class2name(rb_obj_class(s));
VALUE str, members;
long i;
- if (recur) {
- return rb_sprintf("#<struct %s:...>", cname);
- }
-
members = rb_struct_members(s);
- if (cname[0] == '#') {
- str = rb_str_new2("#<struct ");
- }
- else {
- str = rb_sprintf("#<struct %s ", cname);
- }
- for (i=0; i<RSTRUCT_LEN(s); i++) {
+ str = rb_str_buf_new2("#<struct ");
+ rb_str_cat2(str, cname);
+ rb_str_cat2(str, " ");
+ for (i=0; i<RSTRUCT(s)->len; i++) {
VALUE slot;
ID id;
+ const char *p;
if (i > 0) {
rb_str_cat2(str, ", ");
}
- slot = RARRAY_PTR(members)[i];
+ slot = RARRAY(members)->ptr[i];
id = SYM2ID(slot);
if (rb_is_local_id(id) || rb_is_const_id(id)) {
- rb_str_append(str, rb_id2str(id));
+ p = rb_id2name(id);
+ rb_str_cat2(str, p);
}
else {
rb_str_append(str, rb_inspect(slot));
}
rb_str_cat2(str, "=");
- rb_str_append(str, rb_inspect(RSTRUCT_PTR(s)[i]));
+ rb_str_append(str, rb_inspect(RSTRUCT(s)->ptr[i]));
}
rb_str_cat2(str, ">");
OBJ_INFECT(str, s);
@@ -528,9 +513,19 @@ inspect_struct(VALUE s, VALUE dummy, int recur)
*/
static VALUE
-rb_struct_inspect(VALUE s)
+rb_struct_inspect(s)
+ VALUE s;
{
- return rb_exec_recursive(inspect_struct, s, 0);
+ if (rb_inspecting_p(s)) {
+ const char *cname = rb_class2name(rb_obj_class(s));
+ size_t len = strlen(cname) + 14;
+ VALUE str = rb_str_new(0, len);
+
+ snprintf(RSTRING(str)->ptr, len+1, "#<struct %s:...>", cname);
+ RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ return str;
+ }
+ return rb_protect_inspect(inspect_struct, s, 0);
}
/*
@@ -546,39 +541,43 @@ rb_struct_inspect(VALUE s)
*/
static VALUE
-rb_struct_to_a(VALUE s)
+rb_struct_to_a(s)
+ VALUE s;
{
- return rb_ary_new4(RSTRUCT_LEN(s), RSTRUCT_PTR(s));
+ return rb_ary_new4(RSTRUCT(s)->len, RSTRUCT(s)->ptr);
}
/* :nodoc: */
static VALUE
-rb_struct_init_copy(VALUE copy, VALUE s)
+rb_struct_init_copy(copy, s)
+ VALUE copy, s;
{
if (copy == s) return copy;
rb_check_frozen(copy);
if (!rb_obj_is_instance_of(s, rb_obj_class(copy))) {
rb_raise(rb_eTypeError, "wrong argument class");
}
- if (RSTRUCT_LEN(copy) != RSTRUCT_LEN(s)) {
+ if (RSTRUCT(copy)->len != RSTRUCT(s)->len) {
rb_raise(rb_eTypeError, "struct size mismatch");
}
- MEMCPY(RSTRUCT_PTR(copy), RSTRUCT_PTR(s), VALUE, RSTRUCT_LEN(copy));
+ MEMCPY(RSTRUCT(copy)->ptr, RSTRUCT(s)->ptr, VALUE, RSTRUCT(copy)->len);
return copy;
}
static VALUE
-rb_struct_aref_id(VALUE s, ID id)
+rb_struct_aref_id(s, id)
+ VALUE s;
+ ID id;
{
VALUE members;
long i, len;
members = rb_struct_members(s);
- len = RARRAY_LEN(members);
+ len = RARRAY(members)->len;
for (i=0; i<len; i++) {
- if (SYM2ID(RARRAY_PTR(members)[i]) == id) {
- return RSTRUCT_PTR(s)[i];
+ if (SYM2ID(RARRAY(members)->ptr[i]) == id) {
+ return RSTRUCT(s)->ptr[i];
}
}
rb_name_error(id, "no member '%s' in struct", rb_id2name(id));
@@ -605,7 +604,8 @@ rb_struct_aref_id(VALUE s, ID id)
*/
VALUE
-rb_struct_aref(VALUE s, VALUE idx)
+rb_struct_aref(s, idx)
+ VALUE s, idx;
{
long i;
@@ -614,32 +614,34 @@ rb_struct_aref(VALUE s, VALUE idx)
}
i = NUM2LONG(idx);
- if (i < 0) i = RSTRUCT_LEN(s) + i;
+ if (i < 0) i = RSTRUCT(s)->len + i;
if (i < 0)
rb_raise(rb_eIndexError, "offset %ld too small for struct(size:%ld)",
- i, RSTRUCT_LEN(s));
- if (RSTRUCT_LEN(s) <= i)
+ i, RSTRUCT(s)->len);
+ if (RSTRUCT(s)->len <= i)
rb_raise(rb_eIndexError, "offset %ld too large for struct(size:%ld)",
- i, RSTRUCT_LEN(s));
- return RSTRUCT_PTR(s)[i];
+ i, RSTRUCT(s)->len);
+ return RSTRUCT(s)->ptr[i];
}
static VALUE
-rb_struct_aset_id(VALUE s, ID id, VALUE val)
+rb_struct_aset_id(s, id, val)
+ VALUE s, val;
+ ID id;
{
VALUE members;
long i, len;
members = rb_struct_members(s);
rb_struct_modify(s);
- len = RARRAY_LEN(members);
- if (RSTRUCT_LEN(s) != RARRAY_LEN(members)) {
- rb_raise(rb_eTypeError, "struct size differs (%ld required %ld given)",
- RARRAY_LEN(members), RSTRUCT_LEN(s));
+ len = RARRAY(members)->len;
+ if (RSTRUCT(s)->len != RARRAY(members)->len) {
+ rb_raise(rb_eTypeError, "struct size differs (%d required %d given)",
+ RARRAY(members)->len, RSTRUCT(s)->len);
}
for (i=0; i<len; i++) {
- if (SYM2ID(RARRAY_PTR(members)[i]) == id) {
- RSTRUCT_PTR(s)[i] = val;
+ if (SYM2ID(RARRAY(members)->ptr[i]) == id) {
+ RSTRUCT(s)->ptr[i] = val;
return val;
}
}
@@ -668,7 +670,8 @@ rb_struct_aset_id(VALUE s, ID id, VALUE val)
*/
VALUE
-rb_struct_aset(VALUE s, VALUE idx, VALUE val)
+rb_struct_aset(s, idx, val)
+ VALUE s, idx, val;
{
long i;
@@ -677,21 +680,24 @@ rb_struct_aset(VALUE s, VALUE idx, VALUE val)
}
i = NUM2LONG(idx);
- if (i < 0) i = RSTRUCT_LEN(s) + i;
+ if (i < 0) i = RSTRUCT(s)->len + i;
if (i < 0) {
rb_raise(rb_eIndexError, "offset %ld too small for struct(size:%ld)",
- i, RSTRUCT_LEN(s));
+ i, RSTRUCT(s)->len);
}
- if (RSTRUCT_LEN(s) <= i) {
+ if (RSTRUCT(s)->len <= i) {
rb_raise(rb_eIndexError, "offset %ld too large for struct(size:%ld)",
- i, RSTRUCT_LEN(s));
+ i, RSTRUCT(s)->len);
}
rb_struct_modify(s);
- return RSTRUCT_PTR(s)[i] = val;
+ return RSTRUCT(s)->ptr[i] = val;
}
+static VALUE struct_entry _((VALUE, long));
static VALUE
-struct_entry(VALUE s, long n)
+struct_entry(s, n)
+ VALUE s;
+ long n;
{
return rb_struct_aref(s, LONG2NUM(n));
}
@@ -713,9 +719,12 @@ struct_entry(VALUE s, long n)
*/
static VALUE
-rb_struct_values_at(int argc, VALUE *argv, VALUE s)
+rb_struct_values_at(argc, argv, s)
+ int argc;
+ VALUE *argv;
+ VALUE s;
{
- return rb_get_values_at(s, RSTRUCT_LEN(s), argc, argv, struct_entry);
+ return rb_values_at(s, RSTRUCT(s)->len, argc, argv, struct_entry);
}
/*
@@ -733,7 +742,10 @@ rb_struct_values_at(int argc, VALUE *argv, VALUE s)
*/
static VALUE
-rb_struct_select(int argc, VALUE *argv, VALUE s)
+rb_struct_select(argc, argv, s)
+ int argc;
+ VALUE *argv;
+ VALUE s;
{
VALUE result;
long i;
@@ -742,9 +754,9 @@ rb_struct_select(int argc, VALUE *argv, VALUE s)
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
result = rb_ary_new();
- for (i = 0; i < RSTRUCT_LEN(s); i++) {
- if (RTEST(rb_yield(RSTRUCT_PTR(s)[i]))) {
- rb_ary_push(result, RSTRUCT_PTR(s)[i]);
+ for (i = 0; i < RSTRUCT(s)->len; i++) {
+ if (RTEST(rb_yield(RSTRUCT(s)->ptr[i]))) {
+ rb_ary_push(result, RSTRUCT(s)->ptr[i]);
}
}
@@ -769,19 +781,20 @@ rb_struct_select(int argc, VALUE *argv, VALUE s)
*/
static VALUE
-rb_struct_equal(VALUE s, VALUE s2)
+rb_struct_equal(s, s2)
+ VALUE s, s2;
{
long i;
if (s == s2) return Qtrue;
if (TYPE(s2) != T_STRUCT) return Qfalse;
if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
- if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
+ if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {
rb_bug("inconsistent struct"); /* should never happen */
}
- for (i=0; i<RSTRUCT_LEN(s); i++) {
- if (!rb_equal(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
+ for (i=0; i<RSTRUCT(s)->len; i++) {
+ if (!rb_equal(RSTRUCT(s)->ptr[i], RSTRUCT(s2)->ptr[i])) return Qfalse;
}
return Qtrue;
}
@@ -794,15 +807,16 @@ rb_struct_equal(VALUE s, VALUE s2)
*/
static VALUE
-rb_struct_hash(VALUE s)
+rb_struct_hash(s)
+ VALUE s;
{
long i, h;
VALUE n;
h = rb_hash(rb_obj_class(s));
- for (i = 0; i < RSTRUCT_LEN(s); i++) {
+ for (i = 0; i < RSTRUCT(s)->len; i++) {
h = (h << 1) | (h<0 ? 1 : 0);
- n = rb_hash(RSTRUCT_PTR(s)[i]);
+ n = rb_hash(RSTRUCT(s)->ptr[i]);
h ^= NUM2LONG(n);
}
return LONG2FIX(h);
@@ -817,19 +831,20 @@ rb_struct_hash(VALUE s)
*/
static VALUE
-rb_struct_eql(VALUE s, VALUE s2)
+rb_struct_eql(s, s2)
+ VALUE s, s2;
{
long i;
if (s == s2) return Qtrue;
if (TYPE(s2) != T_STRUCT) return Qfalse;
if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
- if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
+ if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {
rb_bug("inconsistent struct"); /* should never happen */
}
- for (i=0; i<RSTRUCT_LEN(s); i++) {
- if (!rb_eql(RSTRUCT_PTR(s)[i], RSTRUCT_PTR(s2)[i])) return Qfalse;
+ for (i=0; i<RSTRUCT(s)->len; i++) {
+ if (!rb_eql(RSTRUCT(s)->ptr[i], RSTRUCT(s2)->ptr[i])) return Qfalse;
}
return Qtrue;
}
@@ -847,9 +862,10 @@ rb_struct_eql(VALUE s, VALUE s2)
*/
static VALUE
-rb_struct_size(VALUE s)
+rb_struct_size(s)
+ VALUE s;
{
- return LONG2FIX(RSTRUCT_LEN(s));
+ return LONG2FIX(RSTRUCT(s)->len);
}
/*
@@ -868,7 +884,7 @@ rb_struct_size(VALUE s)
* <code>Symbol</code> (such as <code>:name</code>).
*/
void
-Init_Struct(void)
+Init_Struct()
{
rb_cStruct = rb_define_class("Struct", rb_cObject);
rb_include_module(rb_cStruct, rb_mEnumerable);
diff --git a/template/insns.inc.tmpl b/template/insns.inc.tmpl
deleted file mode 100644
index 770210e752..0000000000
--- a/template/insns.inc.tmpl
+++ /dev/null
@@ -1,21 +0,0 @@
-/** -*-c-*-
- This file contains YARV instructions list.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/insns.inc.tmpl'
- or insns2vm.rb
- */
-
-
-/* BIN : Basic Instruction Name */
-#define BIN(n) YARVINSN_##n
-
-enum{
-<%= insns %>
-};
-
-#define VM_INSTRUCTION_SIZE <%= @insns.size %>
-
diff --git a/template/insns_info.inc.tmpl b/template/insns_info.inc.tmpl
deleted file mode 100644
index d7e745bca7..0000000000
--- a/template/insns_info.inc.tmpl
+++ /dev/null
@@ -1,83 +0,0 @@
-/** -*-c-*-
- This file contains instruction information for yarv instruction sequence.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/insns_info.inc.tmpl'
- or insns2vm.rb
- */
-
-<%= insn_type_chars %>
-
-static char *insn_name_info[] = {
-<%= insn_names %>
-};
-
-static char *insn_operand_info[] = {
-<%= operands_info %>
-};
-
-static int insn_len_info[] = {
-<%= operands_num_info %>
-};
-
-#ifdef USE_INSN_RET_NUM
-static int insn_stack_push_num_info[] = {
-<%= stack_num_info %>
-};
-#endif
-
-#ifdef USE_INSN_STACK_INCREASE
-static int
-insn_stack_increase(int depth, int insn, VALUE *opes)
-{
- switch(insn){
-<%= stack_increase %>
- default:
- rb_bug("insn_sp_increase: unreachable");
- }
- return 0;
-}
-#endif
-
-/* some utilities */
-
-static int
-insn_len(int insn)
-{
- return insn_len_info[insn];
-}
-
-static char *
-insn_name(int insn)
-{
- return insn_name_info[insn];
-}
-
-static char *
-insn_op_types(int insn)
-{
- return insn_operand_info[insn];
-}
-
-static int
-insn_op_type(int insn, int pos)
-{
- int len = insn_len(insn) - 1;
- if(pos < len){
- return insn_operand_info[insn][pos];
- }
- else{
- return 0;
- }
-}
-
-#ifdef USE_INSN_RET_NUM
-static int
-insn_ret_num(int insn)
-{
- return insn_stack_push_num_info[insn];
-}
-#endif
diff --git a/template/minsns.inc.tmpl b/template/minsns.inc.tmpl
deleted file mode 100644
index f994c9b53b..0000000000
--- a/template/minsns.inc.tmpl
+++ /dev/null
@@ -1,14 +0,0 @@
-/** -*-c-*-
- This file contains YARV instructions list, to define YARVCore::Instructions.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/minsns.inc.tmpl'
- or insns2vm.rb
- */
-
-<%= defs %>
-
-
diff --git a/template/opt_sc.inc.tmpl b/template/opt_sc.inc.tmpl
deleted file mode 100644
index fc1c2f7184..0000000000
--- a/template/opt_sc.inc.tmpl
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*-c-*- *********************************************************/
-/*******************************************************************/
-/*******************************************************************/
-/**
- This file is for threaded code.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/opt_sc.inc.tmpl'
- or rb/insns2vm.rb
- */
-
-#define SC_STATE_SIZE 6
-
-#define SCS_XX 1
-#define SCS_AX 2
-#define SCS_BX 3
-#define SCS_AB 4
-#define SCS_BA 5
-
-#define SC_ERROR 0xffffffff
-
-static VALUE sc_insn_info[][SC_STATE_SIZE] = {
-<%= sc_insn_info %>
-};
-
-static VALUE sc_insn_next[] = {
-<%= sc_insn_next %>
-};
-
diff --git a/template/optinsn.inc.tmpl b/template/optinsn.inc.tmpl
deleted file mode 100644
index c7828fe960..0000000000
--- a/template/optinsn.inc.tmpl
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*-c-*- *********************************************************/
-/*******************************************************************/
-/*******************************************************************/
-/**
- This file is for threaded code.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/optinsn.inc.tmpl'
- or rb/insns2vm.rb
- */
-
-static INSN *
-insn_operands_unification(INSN *insnobj){
-#ifdef OPT_OPERANDS_UNIFICATION
- /* optimize rule */
- switch(insnobj->insn_id){
-
-<%= rule %>
-
- default:
- /* do nothing */;
- break;
- }
-#endif
- return insnobj;
-}
-
diff --git a/template/optunifs.inc.tmpl b/template/optunifs.inc.tmpl
deleted file mode 100644
index 8a3ae3e897..0000000000
--- a/template/optunifs.inc.tmpl
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*-c-*- *********************************************************/
-/*******************************************************************/
-/*******************************************************************/
-/**
- This file is for threaded code.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/optunifs.inc.tmpl'
- or rb/insns2vm.rb
- */
-
-/*
- static int UNIFIED_insn_name_1[] = {id, size, ...};
- static int UNIFIED_insn_name_2[] = {id, size, ...};
- ...
-
- static *int UNIFIED_insn_name[] = {size,
- UNIFIED_insn_name_1,
- UNIFIED_insn_name_2, ...};
- ...
-
- static **int unified_insns_data[] = {
- UNIFIED_insn_nameA,
- UNIFIED_insn_nameB, ...};
- */
-
-<%= unif_insns_each %>
-<%= unif_insns %>
-<%= unif_insns_data %>
-
-#undef GET_INSN_NAME
-
diff --git a/template/vm.inc.tmpl b/template/vm.inc.tmpl
deleted file mode 100644
index f79de9785a..0000000000
--- a/template/vm.inc.tmpl
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*-c-*- *********************************************************/
-/*******************************************************************/
-/*******************************************************************/
-/**
- This file is VM main loop.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'insns.c'
- */
-
-<%=
-line = 15
-vm_body.gsub(/\n|__CURRENT_LINE__|__CURRENT_FILE__/){|e|
- case e
- when '__CURRENT_LINE__'
- line.to_s
- when '__CURRENT_FILE__'
- "vm.inc"
- else
- line += 1
- e
- end
-}
-%>
-
diff --git a/template/vmtc.inc.tmpl b/template/vmtc.inc.tmpl
deleted file mode 100644
index f73bbc6323..0000000000
--- a/template/vmtc.inc.tmpl
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*-c-*- *********************************************************/
-/*******************************************************************/
-/*******************************************************************/
-/**
- This file is for threaded code.
-
- ----
- This file is auto generated by insns2vm.rb
- DO NOT TOUCH!
-
- If you want to fix something, you must edit 'template/vmtc.inc.tmpl'
- or insns2vm.rb
- */
-
-static const void *const insns_address_table[] = {
-<%= insns_table %>
-};
-
diff --git a/template/yarvarch.en b/template/yarvarch.en
deleted file mode 100644
index 7a76e25b7e..0000000000
--- a/template/yarvarch.en
+++ /dev/null
@@ -1,7 +0,0 @@
-#title YARV: Yet another RubyVM - Software Architecture
-
-maybe writing.
-
-* YARV instruction set
-
-<%= d %>
diff --git a/template/yarvarch.ja b/template/yarvarch.ja
deleted file mode 100644
index c332c20811..0000000000
--- a/template/yarvarch.ja
+++ /dev/null
@@ -1,454 +0,0 @@
-#title YARVƒA[ƒLƒeƒNƒ`ƒƒ
-#set author “ú–{ Ruby ‚Ì‰ï ‚³‚³‚¾‚±‚¤‚¢‚¿
-
-
-- 2005-03-03(Thu) 00:31:12 +0900 ‚¢‚ë‚¢‚ë‚Æ‘‚«’¼‚µ
-
-----
-
-* ‚±‚ê‚ÍH
-
-[[YARV: Yet Another RubyVM|http://www.atdot.net/yarv]] ‚Ì ÝŒvƒƒ‚‚Å‚·B
-
-
-YARV ‚ÍARuby ƒvƒƒOƒ‰ƒ€‚Ì‚½‚߂̎Ÿ‚Ì‹@”\‚ð’ñ‹Ÿ‚µ‚Ü‚·B
-
-- Compiler
-- VM Generator
-- VM (Virtual Machine)
-- Assembler
-- Dis-Assembler
-- (experimental) JIT Compiler
-- (experimental) AOT Compiler
-
-
-Œ»Ý‚Ì YARV ‚Í Ruby ƒCƒ“ƒ^ƒvƒŠƒ^‚ÌŠg’£ƒ‰ƒCƒuƒ‰ƒŠ‚Æ‚µ‚ÄŽÀ‘•‚µ‚Ä‚¢‚Ü‚·B‚±
-‚ê‚É‚æ‚èARuby ƒCƒ“ƒ^ƒvƒŠƒ^‚Ì•K—v‚È‹@”\iƒp[ƒTAƒIƒuƒWƒFƒNƒgŠÇ—AŠù‘¶
-‚ÌŠg’£ƒ‰ƒCƒuƒ‰ƒŠj‚Ȃǂª‚Ù‚Ú‚»‚̂܂ܗ˜—p‚Å‚«‚Ü‚·B
-
-‚½‚¾‚µA‚¢‚­‚‚©‚̃pƒbƒ`‚ð Ruby ƒCƒ“ƒ^ƒvƒŠƒ^‚É“–‚ĂȂ¯‚ê‚΂Ȃè‚Ü‚¹‚ñB
-
-¡Œã‚ÍARuby –{‘̂̃Cƒ“ƒ^ƒvƒŠƒ^•”•ªieval.cj‚ð’u‚«Š·‚¦‚邱‚Æ‚ð–ÚŽw‚µ‚Ä
-ŠJ”­‚ðŒp‘±‚·‚é—\’è‚Å‚·B
-
-
-* Compiler (compile.h, compile.c)
-
-ƒRƒ“ƒpƒCƒ‰‚ÍARuby ƒCƒ“ƒ^ƒvƒŠƒ^‚̃p[ƒT‚É‚æ‚Á‚ͬ‚³‚ꂽ\•¶–ØiRNode
-ƒf[ƒ^‚É‚æ‚é–Øj‚ð YARV –½—ß—ñ‚ɕϊ·‚µ‚Ü‚·BYARV –½—߂ɂ‚¢‚Ă͌ãq‚µ‚Ü
-‚·B
-
-‚Æ‚­‚ɓ‚¢‚±‚Ƃ͂µ‚Ä‚¢‚Ü‚¹‚ñ‚ªAƒXƒR[ƒv‚Ȃǂ̊JŽnŽž‚Ƀ[ƒJƒ‹•Ï”‚̉
-Šú‰»‚Ȃǂðs‚¢A‚ ‚Æ‚Í\•¶–Ø‚ð’H‚è•ÏŠ·‚µ‚Ä‚¢‚«‚Ü‚·B
-
-•ÏŠ·’†‚Í Ruby ‚Ì Array ƒIƒuƒWƒFƒNƒg‚É YARV –½—߃IƒuƒWƒFƒNƒgA‚¨‚æ‚уIƒy
-ƒ‰ƒ“ƒh‚ðŠi”[‚µ‚Ä‚¢‚«AÅŒã‚ÉŽÀs‚Å‚«‚éŒ`‚ɕϊ·‚µ‚Ü‚·BƒRƒ“ƒpƒCƒ‰‚Å‚ÍAƒR
-ƒ“ƒpƒCƒ‹’†‚ɶ¬‚·‚郃‚ƒŠ—̈æ‚ÌŠÇ—‚ª–â‘è‚ɂȂ邱‚Æ‚ª‚ ‚è‚Ü‚·‚ªAYARV
-‚Ìê‡ARuby ƒCƒ“ƒ^ƒvƒŠƒ^‚ª‚·‚ׂĖʓ|‚ð‚݂Ă­‚ê‚é‚̂ł±‚Ì•”•ª‚Í”ñí‚ÉŠy
-‚Éì‚邱‚Æ‚ª‚Å‚«‚Ü‚µ‚½iƒK[ƒx[ƒWƒRƒŒƒNƒ^‚É‚æ‚Á‚ÄŽ©“®“I‚Ƀƒ‚ƒŠŠÇ—‚ð‚µ
-‚Ä‚­‚ê‚邽‚ßjB
-
-YARV –½—ß‚ÍA–½—ß‚ðŽ¦‚·Ž¯•ÊŽqAƒIƒyƒ‰ƒ“ƒh‚È‚ÇA‚·‚×‚Ä 1 word iƒ}ƒVƒ“‚Å
-•\Œ»‚Å‚«‚鎩‘R‚È’lBC Œ¾Œê‚ł̓|ƒCƒ“ƒ^‚̃TƒCƒYBRuby ƒCƒ“ƒ^ƒvƒŠƒ^—pŒê‚Å
-‚Í VALUE ‚̃TƒCƒYj‚Å•\Œ»‚³‚ê‚Ü‚·B‚»‚Ì‚½‚ßAYARV –½—߂͂¢‚í‚ä‚éuƒoƒCƒg
-ƒR[ƒhv‚ł͂ ‚è‚Ü‚¹‚ñB‚»‚Ì‚½‚ßAYARV ‚Ìà–¾‚ȂǂłÍu–½—ß—ñv‚Æ‚¢‚¤—p
-Œê‚ðŽg‚Á‚Ä‚¢‚Ü‚·B
-
-1 word ‚Å‚ ‚邽‚ßAƒƒ‚ƒŠ‚Ì—˜—pŒø—¦‚Í‘½­ˆ«‚­‚È‚è‚Ü‚·‚ªAƒAƒNƒZƒX‘¬“x‚È
-‚Ç‚ðl—¶‚·‚邯A–{•ûŽ®‚ªˆê”Ô‚¢‚¢‚Æl‚¦‚Ä‚¨‚è‚Ü‚·B‚½‚Æ‚¦‚΃Iƒyƒ‰ƒ“ƒh‚ðƒR
-ƒ“ƒXƒ^ƒ“ƒgƒv[ƒ‹‚ÉŠi”[‚µAƒCƒ“ƒfƒbƒNƒX‚݂̂ðƒIƒyƒ‰ƒ“ƒh‚ÅŽ¦‚·‚±‚Æ‚à‰Â”\‚Å
-‚·‚ªAŠÔÚƒAƒNƒZƒX‚ɂȂÁ‚Ä‚µ‚Ü‚¤‚̂ū”\‚ɉe‹¿‚ªo‚邽‚ßA‹p‰º‚µ‚Ü‚µ‚½B
-
-
-* VM Generator (rb/insns2vm.rb, insns.def)
-
-rb/insns2vm.rb ‚Æ‚¢‚¤ƒXƒNƒŠƒvƒg‚ÍAinsns.def ‚Æ‚¢‚¤ƒtƒ@ƒCƒ‹‚ð“ǂݞ‚ÝA
-VM ‚Ì‚½‚߂ɕK—v‚ȃtƒ@ƒCƒ‹‚𶬂µ‚Ü‚·B‹ï‘Ì“I‚É‚ÍA–½—ß‚ðŽÀs‚·‚é•”•ª‚ð
-¶¬‚µ‚Ü‚·‚ªA‚Ù‚©‚É‚àƒRƒ“ƒpƒCƒ‹‚É•K—v‚Èî•ñAÅ“K‰»‚É•K—v‚Èî•ñA‚âƒAƒZ
-ƒ“ƒuƒ‰A‹tƒAƒZƒ“ƒuƒ‰‚É•K—v‚Èî•ñ‚ðŽ¦‚·ƒtƒ@ƒCƒ‹‚ඬ‚µ‚Ü‚·B
-
-
-** –½—ß‹Lq
-
-insns.def ‚É‚ÍAŠe–½—ß‚ª‚ǂ̂悤‚È–½—߂ł ‚é‚©‚ð‹Lq‚µ‚Ü‚·B‹ï‘Ì“I‚ɂ͎Ÿ
-‚Ìî•ñ‚ð‹Lq‚µ‚Ü‚·B
-
-- –½—߂̖¼‘O
-- ‚»‚Ì–½—߂̃JƒeƒSƒŠAƒRƒƒ“ƒgi‰pŒêA“ú–{Œêj
-- ƒIƒyƒ‰ƒ“ƒh‚Ì–¼‘O
-- ‚»‚Ì–½—ߎÀs‘O‚ɃXƒ^ƒbƒN‚©‚çƒ|ƒbƒv‚·‚é’l
-- ‚»‚Ì–½—ߎÀsŒã‚ɃXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚é’l
-- ‚»‚Ì–½—߂̃ƒWƒbƒNiC Œ¾Œê‚Å‹Lqj
-
-‚½‚Æ‚¦‚ÎAƒXƒ^ƒbƒN‚É self ‚ð‚¨‚­ putself ‚Æ‚¢‚¤–½—߂͎Ÿ‚̂悤‚É‹Lq‚µ‚Ü
-‚·B
-
-#code
-/**
- @c put
- @e put self.
- @j self ‚ð’u‚­B
- */
-DEFINE_INSN
-putself
-()
-()
-(VALUE val)
-{
- val = GET_SELF();
-}
-#end
-
-‚±‚Ìê‡AƒIƒyƒ‰ƒ“ƒh‚ÆAƒXƒ^ƒbƒN‚©‚çƒ|ƒbƒv‚·‚é’l‚Í–³‚¢‚±‚ƂɂȂè‚Ü‚·B–½
-—ßI—¹ŒãAself ‚ðƒXƒ^ƒbƒNƒgƒbƒv‚É’u‚«‚½‚¢‚킯‚Å‚·‚ªA‚»‚ê‚Í val ‚Æ‚¢‚¤A
-ƒXƒ^ƒbƒN‚ɃvƒbƒVƒ…‚·‚é’l‚Æ‚µ‚Ä錾‚µ‚Ä‚¨‚¢‚½•Ï”‚É‘ã“ü‚µ‚Ä‚¨‚­‚±‚Æ‚ÅA‚±
-‚ê‚ð•ÏŠ·‚·‚邯ƒXƒ^ƒbƒNƒgƒbƒv‚É’u‚­ C ƒvƒƒOƒ‰ƒ€‚ª¶¬‚³‚ê‚Ü‚·B
-
-ׂ©‚¢ƒtƒH[ƒ}ƒbƒg‚Í insns.def ‚Ì–`“ª‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B‚»‚ñ‚Ȃɓ‚­
-‚È‚¢‚ÆŽv‚¢‚Ü‚·B
-
-insnhelper.h ‚Æ‚¢‚¤ƒtƒ@ƒCƒ‹‚ÉA–½—߃ƒWƒbƒN‚ð‹Lq‚·‚邽‚߂ɕK—v‚ȃ}ƒNƒ
-‚ª’è‹`‚³‚ê‚Ä‚¢‚Ü‚·B‚Ü‚½AVM ‚Ì“à•”\‘¢‚ÉŠÖ‚·‚é’è‹`‚Í vm.h ‚Æ‚¢‚¤ƒtƒ@ƒC
-ƒ‹‚É‚ ‚è‚Ü‚·B
-
-
-* VM (Virtual Machine, vm.h, vm.c)
-
-VM ‚ÍAŽÀۂɃRƒ“ƒpƒCƒ‹‚µ‚½Œ‹‰Ê¶¬‚³‚ê‚é YARV –½—ß—ñ‚ðŽÀs‚µ‚Ü‚·B‚Ü‚³
-‚ÉA‚±‚Ì•”•ª‚ª YARV ‚̃Lƒ‚‚ɂȂèA«—ˆ“I‚É‚Í eval.c ‚ð‚±‚Ì VM ‚Å’u‚«Š·‚¦
-‚½‚¢‚Æl‚¦‚Ä‚¢‚Ü‚·B
-
-Œ»Ý‚Ì Ruby ƒCƒ“ƒ^ƒvƒŠƒ^‚ÅŽÀs‚Å‚«‚é‚·‚ׂĂ̂±‚Æ‚ªA‚±‚Ì VM ‚ÅŽÀŒ»‚Å‚«‚é
-‚悤‚Éì‚Á‚Ä‚¢‚Ü‚·iŒ»’iŠK‚ł͂܂¾Š®‘S‚ł͂ ‚è‚Ü‚¹‚ñ‚ªA‚»‚¤‚È‚é‚ׂ«‚Å‚·jB
-
-VM ‚ÍA’Pƒ‚ȃXƒ^ƒbƒNƒ}ƒVƒ“‚Æ‚µ‚ÄŽÀ‘•‚µ‚Ä‚¢‚Ü‚·BƒXƒŒƒbƒh‚ЂƂ‚ɃXƒ^ƒb
-ƒN‚ЂƂ‚ð•ÛŽ‚µ‚Ü‚·BƒXƒ^ƒbƒN‚̗̈æ‚̓q[ƒv‚©‚çŽæ“¾‚·‚é‚Ì‚ÅA_“î‚ȗ̈æ
-ݒ肪‰Â”\‚Å‚·B
-
-
-** ƒŒƒWƒXƒ^
-
-VM ‚Í 5 ‚‚̉¼‘z“I‚ȃŒƒWƒXƒ^‚É‚æ‚Á‚ħŒä‚³‚ê‚Ü‚·B
-
-- PC (Program Counter)
-- SP (Stack Pointer)
-- CFP (Control Frame Pointer)
-- LFP (Local Frame Pointer)
-- DFP (Dynamic Frame Pointer)
-
-PC ‚ÍŒ»ÝŽÀs’†‚Ì–½—ß—ñ‚̈ʒu‚ðŽ¦‚µ‚Ü‚·BSP ‚̓Xƒ^ƒbƒNƒgƒbƒv‚̈ʒu‚ðŽ¦‚µ
-‚Ü‚·BCFPALFPADFP ‚Í‚»‚ꂼ‚êƒtƒŒ[ƒ€‚Ìî•ñ‚ðŽ¦‚µ‚Ü‚·BÚׂ͌ãq‚µ‚Ü‚·B
-
-
-** ƒXƒ^ƒbƒNƒtƒŒ[ƒ€
-
-obsolete (update soon)
-
-
-** ƒtƒŒ[ƒ€ƒfƒUƒCƒ“‚ɂ‚¢‚Ă̕⑫
-
-Lisp ‚̈—Œn‚È‚Ç‚ð‚©‚ñ‚ª‚¦‚邯A‚í‚´‚í‚´ƒuƒƒbƒNƒ[ƒJƒ‹ƒtƒŒ[ƒ€‚ƃƒ\
-ƒbƒhƒ[ƒJƒ‹ƒtƒŒ[ƒ€‚̂悤‚È‚à‚Ì‚ð—pˆÓ‚·‚é‚̂͊ïˆÙ‚ÉŒ©‚¦‚é‚©‚à‚µ‚ê‚Ü‚¹‚ñB
-‚ ‚éƒtƒŒ[ƒ€‚ðA“ü‚êŽq\‘¢‚É‚µ‚ÄAƒ[ƒJƒ‹•Ï”‚̃AƒNƒZƒX‚Í‚»‚Ì“ü‚êŽq‚ðŠO
-‘¤‚É’H‚ê‚ΕK‚¸‚½‚ǂ蒅‚­‚±‚Æ‚ª‚Å‚«‚é‚©‚ç‚Å‚·i‚‚܂èAlfp ‚Í•K—v‚È‚¢jB
-
-‚µ‚©‚µARuby ‚ł͂¢‚­‚‚©ó‹µ‚ªˆá‚¢‚Ü‚·B‚Ü‚¸Aƒƒ\ƒbƒhƒ[ƒJƒ‹‚Èî•ñ‚ª
-‚ ‚邱‚ÆA‹ï‘Ì“I‚ɂ̓uƒƒbƒN‚Æselficallee ‚©‚ç‚Ý‚é‚Æ recieverj‚Å‚·B‚±
-‚Ìî•ñ‚ð‚»‚ê‚¼‚ê‚̃tƒŒ[ƒ€‚É‚à‚½‚¹‚é‚͖̂³‘ʂł·B
-
-‚Ü‚½ARuby2.0 ‚©‚ç‚̓uƒƒbƒNƒ[ƒJƒ‹•Ï”‚͂Ȃ­‚È‚è‚Ü‚·iƒuƒƒbƒNƒ[ƒJƒ‹
-ˆø”‚ÍŽc‚é‚Ì‚ÅA\‘¢Ž©‘̂͂ ‚Ü‚è•Ï‚í‚è‚Ü‚¹‚ñjB‚»‚Ì‚½‚ßAƒƒ\ƒbƒhƒ[ƒJ
-ƒ‹•Ï”‚ւ̃AƒNƒZƒX‚ª•p”­‚·‚邱‚Æ‚ª—\‘z‚³‚ê‚Ü‚·B
-
-‚±‚̂Ƃ«Aƒƒ\ƒbƒhƒ[ƒJƒ‹•Ï”‚ւ̃AƒNƒZƒX‚Ì‚½‚тɃtƒŒ[ƒ€iƒXƒR[ƒvj‚Ì
-ƒŠƒXƒg‚ð‚½‚Ç‚é‚͖̂³‘ʂł ‚邯”»’f‚µA–¾Ž¦“I‚Ƀƒ\ƒbƒhƒ[ƒJƒ‹ƒXƒR[ƒv‚Æ
-ƒuƒƒbƒNƒtƒŒ[ƒ€‚𕪗£‚µAƒuƒƒbƒNƒtƒŒ[ƒ€‚©‚ç‚̓ƒ\ƒbƒhƒ[ƒJƒ‹ƒtƒŒ[ƒ€
-‚ª lfpƒŒƒWƒXƒ^‚É‚æ‚Á‚Ä—eˆÕ‚ɃAƒNƒZƒX‚Å‚«‚邿‚¤‚É‚µ‚Ü‚µ‚½B
-
-
-** ƒƒ\ƒbƒhŒÄ‚Ño‚µ‚ɂ‚¢‚Ä
-
-ƒƒ\ƒbƒhŒÄ‚Ño‚µ‚ÍAYARV –½—ß—ñ‚Å‹Lq‚³‚ꂽƒƒ\ƒbƒh‚©AC ‚Å‹Lq‚³‚ꂽƒ
-ƒ\ƒbƒh‚©‚É‚æ‚Á‚ăfƒBƒXƒpƒbƒ`Žè–@‚ª•Ï‚í‚è‚Ü‚·B
-
-YARV –½—ß—ñ‚Å‚ ‚Á‚½ê‡Aãq‚µ‚½ƒXƒ^ƒbƒNƒtƒŒ[ƒ€‚ð쬂µ‚Ä–½—ß‚ðŒp‘±‚µ
-‚Ü‚·B‚Æ‚­‚É VM ‚ÌŠÖ”‚ðÄ‹AŒÄ‚Ño‚·‚·‚邱‚Æ‚Ís‚È‚¢‚Ü‚¹‚ñB
-
-C ‚Å‹Lq‚³‚ꂽƒƒ\ƒbƒh‚¾‚Á‚½ê‡A’Pƒ‚É‚»‚ÌŠÖ”‚ðŒÄ‚Ño‚µ‚Ü‚·i‚½‚¾‚µA
-ƒoƒbƒNƒgƒŒ[ƒX‚𳂵‚­¶¬‚·‚邽‚߂Ƀƒ\ƒbƒhŒÄ‚Ño‚µ‚Ìî•ñ‚ð•t‰Á‚µ‚Ä‚©‚ç
-s‚È‚¢‚Ü‚·jB
-
-‚±‚Ì‚½‚ßAVM —pƒXƒ^ƒbƒN‚ð•Ê“r—pˆÓ‚µ‚½‚à‚Ì‚ÌAƒvƒƒOƒ‰ƒ€‚É‚æ‚Á‚Ă̓}ƒVƒ“
-ƒXƒ^ƒbƒN‚ðŽg‚¢Ø‚Á‚Ä‚µ‚Ü‚¤‰Â”\«‚ª‚ ‚è‚Ü‚·iC -> Ruby -> C -> ... ‚Æ‚¢‚¤
-ŒÄ‚Ño‚µ‚ª‘±‚¢‚½ê‡jB‚±‚ê‚ÍAŒ»Ý‚Å‚Í”ð‚¯‚ç‚ê‚È‚¢Žd—l‚ƂȂÁ‚Ä‚¢‚Ü‚·B
-
-
-** —áŠO
-
-—áŠO‚ÍAJava ‚Ì JVM ‚Æ“¯—l‚É—áŠOƒe[ƒuƒ‹‚ð—pˆÓ‚·‚邱‚ƂŎÀŒ»‚µ‚Ü‚·B—áŠO
-‚ª”­¶‚µ‚½‚çA“–ŠYƒtƒŒ[ƒ€‚ðA—áŠOƒe[ƒuƒ‹‚ðŒŸ¸‚µ‚Ü‚·B‚»‚±‚ÅA—áŠO‚ª”­
-¶‚µ‚½‚Æ‚«‚Ì PC ‚Ì’l‚ɇ’v‚·‚éƒGƒ“ƒgƒŠ‚ª‚ ‚Á‚½ê‡A‚»‚̃Gƒ“ƒgƒŠ‚É]‚Á‚Ä
-“®ì‚µ‚Ü‚·B‚à‚µƒGƒ“ƒgƒŠ‚ªŒ©‚‚©‚ç‚È‚©‚Á‚½ê‡AƒXƒ^ƒbƒN‚ðŽT‚«–ß‚µ‚Ă܂½
-“¯—l‚É‚»‚̃XƒR[ƒv‚Ì—áŠOƒe[ƒuƒ‹‚ðŒŸ¸‚µ‚Ü‚·B
-
-‚Ü‚½AbreakAreturniƒuƒƒbƒN’†jAretry ‚È‚Ç‚à“¯—l‚ÌŽd‘g‚݂ŎÀŒ»‚µ‚Ü‚·B
-
-*** —áŠOƒe[ƒuƒ‹
-
-—áŠOƒe[ƒuƒ‹ƒGƒ“ƒgƒŠ‚Í‹ï‘Ì“I‚ɂ͎Ÿ‚Ìî•ñ‚ªŠi”[‚³‚ê‚Ä‚¢‚Ü‚·B
-
-- ‘ÎÛ‚Æ‚·‚é PC ‚͈̔Í
-- ‘ÎÛ‚Æ‚·‚é—áŠO‚ÌŽí—Þ
-- ‚à‚µ‘ÎۂƂȂÁ‚½‚Æ‚«‚ɃWƒƒƒ“ƒv‚·‚éæiŽí—Þ‚É‚æ‚éj
-- ‚à‚µ‘ÎۂƂȂÁ‚½‚Æ‚«‚É‹N“®‚·‚éƒuƒƒbƒN‚Ì iseq
-
-
-*** rescue
-
-rescue ߂̓uƒƒbƒN‚Æ‚µ‚ÄŽÀŒ»‚µ‚Ä‚¢‚Ü‚·B$! ‚Ì’l‚ð—Bˆê‚̈ø”‚Æ‚µ‚ÄŽ‚¿‚Ü
-‚·B
-
-#code
-begin
-rescue A
-rescue B
-rescue C
-end
-#end
-
-‚ÍAŽŸ‚̂悤‚È Ruby ƒXƒNƒŠƒvƒg‚ɕϊ·‚³‚ê‚Ü‚·B
-
-#code
-{|err|
- case err
- when A === err
- when B === err
- when C === err
- else
- raise # yarv ‚Ì–½—ß‚Å‚Í throw
- end
-}
-#end
-
-
-*** ensure
-
-³íŒni—áŠO‚ª”­¶‚µ‚È‚©‚Á‚½ê‡j‚ƈÙíŒni—áŠO‚ª”­¶‚µ‚½‚Æ‚«‚È‚Çj‚Ì2
-Ží—Þ‚Ì–½—ß—ñ‚ª¶¬‚³‚ê‚Ü‚·B³íŒn‚Å‚ÍA‚½‚¾‚̘A‘±‚µ‚½ƒR[ƒh—Ìˆæ‚Æ‚µ‚ăR
-ƒ“ƒpƒCƒ‹‚³‚ê‚Ü‚·B‚Ü‚½AˆÙíŒn‚ł̓uƒƒbƒN‚Æ‚µ‚ÄŽÀ‘•‚µ‚Ü‚·BÅŒã‚Í•K‚¸
-throw –½—߂Œ÷‚߂邱‚ƂɂȂè‚Ü‚·B
-
-
-*** break, returniƒuƒƒbƒN’†jAretry
-
-break •¶AƒuƒƒbƒN’†‚Ì return •¶Aretry •¶‚Í throw –½—߂Ƃµ‚ăRƒ“ƒpƒCƒ‹
-‚³‚ê‚Ü‚·B‚Ç‚±‚܂Ŗ߂邩‚ÍAbreak ‚ðƒtƒbƒN‚·‚é—áŠOƒe[ƒuƒ‹‚̃Gƒ“ƒgƒŠ‚ª”»
-’f‚µ‚Ü‚·B
-
-
-** ’蔂̌Ÿõ
-
-’蔂Ƃ¢‚¤–¼‘O‚Ȃ̂ÉARuby ‚ł̓Rƒ“ƒpƒCƒ‹Žž‚ÉŒˆ’肵‚Ü‚¹‚ñB‚Æ‚¢‚¤‚©A‚¢
-‚‚܂łàÄ’è‹`‰Â”\‚ɂȂÁ‚Ä‚¢‚Ü‚·B
-
-’蔃AƒNƒZƒX‚Ì‚½‚ß‚ÌRuby‹Lq‚ÍŽŸ‚̂悤‚ɂȂè‚Ü‚·B
-
-#code
-Ruby•\Œ»:
-expr::ID::...::ID
-#end
-
-‚±‚ê‚ÍAyarv–½—߃Zƒbƒg‚ł͎Ÿ‚̂悤‚ɂȂè‚Ü‚·B
-
-#code
-(expr)
-getconstant ID
-...
-getconstant ID
-#end
-
-
-*** ’蔌ŸõƒpƒX
-
-‚à‚µ expr ‚ª nil ‚¾‚Á‚½ê‡A’蔌ŸõƒpƒX‚É]‚Á‚Ē蔂ðŒŸõ‚µ‚Ü‚·B‚±‚Ì
-‹““®‚Í¡Œã Ruby 2.0 ‚ÉŒü‚¯‚Ä•ÏX‚³‚ê‚éꇂª‚ ‚è‚Ü‚·B
-
-+ ƒNƒ‰ƒXAƒ‚ƒWƒ…[ƒ‹‚Ì“®“IƒlƒXƒgŠÖŒWiƒvƒƒOƒ‰ƒ€‚ÌŽš–Êãj‚ðƒ‹[ƒg‚܂ŒH‚é
-+ Œp³ŠÖŒW‚ðƒ‹[ƒgiObjectj‚܂ŒH‚é
-
-‚±‚Ì‚½‚ßAƒNƒ‰ƒXAƒ‚ƒWƒ…[ƒ‹‚Ì“®“IƒlƒXƒgŠÖŒW‚ð•Û‘¶‚µ‚È‚¯‚ê‚΂Ȃè‚Ü‚¹‚ñB
-‚±‚Ì‚½‚ß‚ÉAthread_object ‚É‚Í klass_nest_stack ‚Æ‚¢‚¤‚à‚Ì‚ð—pˆÓ‚µ‚Ü‚µ‚½B
-‚±‚ê‚ÍAŒ»Ý‚̃lƒXƒg‚Ìî•ñ‚ð•Û‘¶‚µ‚Ü‚·B
-
-ƒƒ\ƒbƒh’è‹`ŽžA‚»‚ÌŒ»Ý‚̃lƒXƒgî•ñ‚ðƒƒ\ƒbƒh’è‹`Žž‚Éidup‚µ‚Äj‰Á‚¦‚é
-‚±‚Æ‚ÅA‚»‚̃ƒ\ƒbƒh‚ÌŽÀsŽžA‚»‚̃lƒXƒgî•ñ‚ðŽQÆ‚·‚邱‚Æ‚ª‰Â”\‚ɂȂè‚Ü
-‚·B
-
-ƒgƒbƒvƒŒƒxƒ‹‚Å‚ÍA‚»‚Ìî•ñ‚͂Ȃ¢‚±‚ƂɂȂè‚Ü‚·B
-
-ƒNƒ‰ƒX/ƒ‚ƒWƒ…[ƒ‹’è‹`•¶ŽÀsŽž‚ÍAŒ»Ý‚Ìî•ñ‚»‚Ì‚à‚Ì‚ðŽQÆ‚·‚邱‚ƂɂȂè
-‚Ü‚·B‚±‚ê‚ÍAƒNƒ‰ƒXƒXƒR[ƒv“Ë“üŽžA‚»‚Ìî•ñ‚ðƒNƒ‰ƒX’è‹`•¶‚ɃRƒs[‚µ‚Ü‚·
-i‚·‚łɃRƒs[‚³‚ê‚Ä‚¢‚ê‚ÎA‚±‚ê‚ðs‚¢‚Ü‚¹‚ñjB
-
-‚±‚ê‚É‚æ‚èA“®“I‚ȃlƒXƒgî•ñ‚ð“ˆê“I‚Ɉµ‚¤‚±‚Æ‚ª‚Å‚«‚Ü‚·B
-
-
-** Å“K‰»Žè–@
-
-YARV ‚ł͂‘¬‰»‚ð–Ú“I‚Æ‚µ‚Ä‚¢‚é‚Ì‚ÅA‚³‚Ü‚´‚Ü‚ÈÅ“K‰»Žè–@‚ð—˜—p‚µ‚Ä‚¢‚Ü
-‚·BÚׂ͊„ˆ¤‚µ‚Ü‚·‚ªAˆÈ‰º‚Éq‚ׂéÅ“K‰»‚Ȃǂðs‚È‚Á‚Ä‚¨‚è‚Ü‚·B
-
-
-*** threaded code
-
-GCC ‚Ì C Œ¾ŒêŠg’£‚Å‚ ‚é’l‚Æ‚µ‚Ẵ‰ƒxƒ‹‚ð—˜—p‚µ‚Ä direct threaded code
-‚ðŽÀŒ»‚µ‚Ä‚¢‚Ü‚·B
-
-
-*** Peephole optimization
-
-‚¢‚­‚‚©‚ÌŠÈ’P‚ÈÅ“K‰»‚ð‚µ‚Ä‚¢‚Ü‚·B
-
-
-*** inline method cache
-
-–½—ß—ñ‚Ì’†‚Ƀƒ\ƒbƒhŒŸõŒ‹‰Ê‚ð–„‚ßž‚݂܂·B
-
-
-*** inline constant cache
-
-–½—ß—ñ‚Ì’†‚ɒ蔌ŸõŒ‹‰Ê‚ð–„‚ßž‚݂܂·B
-
-
-*** ƒuƒƒbƒN‚Æ Proc ƒIƒuƒWƒFƒNƒg‚Ì•ª—£
-
-ƒuƒƒbƒN•t‚«ƒƒ\ƒbƒhŒÄ‚Ño‚µ‚ªs‚È‚í‚ꂽ‚Æ‚«‚ɂ͂·‚®‚ɂ̓uƒƒbƒN‚ð Proc
-ƒIƒuƒWƒFƒNƒg‚Æ‚µ‚ͬ‚µ‚Ü‚¹‚ñB‚±‚ê‚É‚æ‚èA•K—v‚È‚¢ Proc ƒIƒuƒWƒFƒNƒg‚Ì
-¶¬‚ð—}‚¦‚Ä‚¢‚Ü‚·B
-
-Proc ƒƒ\ƒbƒh‚ÍAŽÀÛ‚É•K—v‚ɂȂÁ‚½Žž“_‚Åì‚ç‚êA‚»‚̂Ƃ«‚Ɋ‹«iƒXƒR[
-ƒvã‚ÉŠm•Û‚³‚ꂽ•Ï”‚È‚Çj‚ðƒq[ƒv‚ɕۑ¶‚µ‚Ü‚·B
-
-
-*** “Á‰»–½—ß
-
-Fixnum “¯Žm‚̉ÁŽZ‚Ȃǂ𳒼‚ÉŠÖ”ŒÄ‚Ño‚µ‚É‚æ‚Á‚Äs‚È‚¤‚ÆAƒRƒXƒg‚ª‚©‚©
-‚é‚Ì‚ÅA‚±‚ê‚ç‚̃vƒŠƒ~ƒeƒBƒu‚È‘€ì‚ðs‚È‚¤‚½‚߂̃ƒ\ƒbƒhŒÄ‚Ño‚µ‚Íê—p–½
-—ß‚ð—pˆÓ‚µ‚Ü‚µ‚½B
-
-
-*** –½—ß—Z‡
-
-•¡”‚Ì–½—ß‚ð 1 –½—߂ɕϊ·‚µ‚Ü‚·B—Z‡–½—ß‚Í opt_insn_unif.def ‚Ì‹Lq‚É‚æ
-‚莩“®“I‚ɶ¬‚³‚ê‚Ü‚·B
-
-
-*** ƒIƒyƒ‰ƒ“ƒh—Z‡
-
-•¡”‚̃Iƒyƒ‰ƒ“ƒh‚ðŠÜ‚ß‚½–½—߂𶬂µ‚Ü‚·B—Z‡–½—ß‚Í opt_operand.def ‚Ì
-‹Lq‚É‚æ‚Á‚ÄŽ©“®“I‚ɶ¬‚³‚ê‚Ü‚·B
-
-
-*** stack caching
-
-ƒXƒ^ƒbƒNƒgƒbƒv‚ð‰¼‘zƒŒƒWƒXƒ^‚ɕێ‚·‚邿‚¤‚É‚µ‚Ü‚·BŒ»Ý‚Í 2 ŒÂ‚̉¼‘zƒŒ
-ƒWƒXƒ^‚ð‘z’肵A5ó‘Ԃ̃Xƒ^ƒbƒNƒLƒƒƒbƒVƒ“ƒO‚ðs‚È‚¢‚Ü‚·BƒXƒ^ƒbƒNƒLƒƒƒb
-ƒVƒ“ƒO‚·‚é–½—߂͎©“®“I‚ɶ¬‚³‚ê‚Ü‚·B
-
-
-*** JIT Compile
-
-‹@ŠBŒê‚ðØ‚è“\‚肵‚Ü‚·B”ñí‚ÉŽÀŒ±“I‚ȃR[ƒh‚à‚Ì‚µ‚©ì‚Á‚Ä‚¨‚è‚Ü‚¹‚ñB‚Ù
-‚Æ‚ñ‚ǂ̃vƒƒOƒ‰ƒ€‚Í“®‚«‚Ü‚¹‚ñB
-
-
-*** AOT Compile
-
-YARV –½—ß—ñ‚ð C Œ¾Œê‚ɕϊ·‚µ‚Ü‚·B‚Ü‚¾\•ª‚ÈÅ“K‰»‚ðs‚È‚¦‚Ä‚¨‚è‚Ü‚¹‚ñ‚ªA
-‚»‚ê‚È‚è‚É“®‚«‚Ü‚·Brb/aotc.rb ‚ªƒRƒ“ƒpƒCƒ‰‚Å‚·B
-
-
-* Assembler (rb/yasm.rb)
-
-YARV –½—ß—ñ‚̃AƒZƒ“ƒuƒ‰‚ð—pˆÓ‚µ‚Ü‚µ‚½BŽg‚¢•û‚Í rb/yasm.rb ‚ðŽQÆ‚µ‚Ä‚­
-‚¾‚³‚¢i‚Ü‚¾A—Ꭶ‚µ‚Ä‚ ‚鶬Žè–@‚Ì‚·‚ׂĂðƒTƒ|[ƒg‚µ‚Ä‚¢‚é‚킯‚ł͂ ‚è
-‚Ü‚¹‚ñjB
-
-
-* Dis-Assembler (disasm.c)
-
-YARV –½—ß—ñ‚ðŽ¦‚·ƒIƒuƒWƒFƒNƒg YARVCore::InstructionSequence ‚É‚Í disasm
-ƒƒ\ƒbƒh‚ª‚ ‚è‚Ü‚·B‚±‚ê‚ÍA–½—ß—ñ‚ð‹tƒAƒZƒ“ƒuƒ‹‚µ‚½•¶Žš—ñ‚ð•Ô‚µ‚Ü‚·B
-
-
-* YARV –½—߃Zƒbƒg
-
-<%= d %>
-
-* ‚»‚Ì‘¼
-
-** ƒeƒXƒg
-
-test/test_* ‚ªƒeƒXƒgƒP[ƒX‚Å‚·Bˆê‰žAƒ~ƒX‚È‚­“®‚­‚Í‚¸‚Å‚·B‹t‚É‚¢‚¤‚ÆA
-‚±‚̃eƒXƒg‚É‹Lq‚³‚ê‚Ä‚¢‚é—Ⴓ͂«‚¿‚ñ‚Æ“®ì‚·‚邯‚¢‚¤‚±‚Ƃł·B
-
-
-** ƒxƒ“ƒ`ƒ}[ƒN
-
-benchmark/bm_* ‚Ƀxƒ“ƒ`ƒ}[ƒNƒvƒƒOƒ‰ƒ€‚ª‚¨‚¢‚Ä‚ ‚è‚Ü‚·B
-
-
-** ¡Œã‚Ì—\’è
-
-‚Ü‚¾‚Ü‚¾‚â‚ç‚È‚¯‚ê‚΂¢‚¯‚È‚¢‚±‚ÆA–¢ŽÀ‘••”•ª‚ª‚½‚­‚³‚ñ‚ ‚è‚Ü‚·‚ñ‚Å‚â‚Á‚Ä
-‚¢‚©‚È‚¯‚ê‚΂Ȃè‚Ü‚¹‚ñBˆê”Ô‘å‚«‚È–Ú•W‚Í eval.c ‚ð’u‚«Š·‚¦‚邱‚Ƃłµ‚傤
-‚©B
-
-
-*** Verifier
-
-YARV –½—ß—ñ‚ÍAƒ~ƒX‚ª‚ ‚Á‚Ä‚à“®‚©‚µ‚Ä‚µ‚Ü‚¤‚½‚ߊ댯‚Å‚ ‚é‰Â”\«‚ª‚ ‚è‚Ü
-‚·B‚»‚Ì‚½‚ßAƒXƒ^ƒbƒN‚Ì—˜—pó‘Ô‚ð‚«‚¿‚ñ‚ÆŽ–‘O‚ÉŒŸØ‚·‚邿‚¤‚ȃxƒŠƒtƒ@ƒC
-ƒA‚ð—pˆÓ‚µ‚È‚¯‚ê‚΂Ȃç‚È‚¢‚Æl‚¦‚Ä‚¢‚Ü‚·B
-
-
-*** Compiled File ‚Ì\‘z
-
-Ruby ƒvƒƒOƒ‰ƒ€‚ð‚±‚Ì–½—߃Zƒbƒg‚ɃVƒŠƒAƒ‰ƒCƒY‚µ‚½ƒf[ƒ^\‘¢‚ðƒtƒ@ƒCƒ‹‚É
-o—͂ł«‚邿‚¤‚É‚µ‚½‚¢‚Æl‚¦‚Ä‚¢‚Ü‚·B‚±‚ê‚ð—˜—p‚µ‚Ĉê“xƒRƒ“ƒpƒCƒ‹‚µ‚½–½
-—ß—ñ‚ðƒtƒ@ƒCƒ‹‚ɕۑ¶‚µ‚Ä‚¨‚¯‚ÎAŽŸ‰ñƒ[ƒhŽž‚ɂ̓Rƒ“ƒpƒCƒ‹‚ÌŽèŠÔAƒRƒXƒg
-‚ðÈ‚­‚±‚Æ‚ª‚Å‚«‚Ü‚·B
-
-
-**** ‘S‘Ì\¬
-
-ŽŸ‚̂悤‚ȃtƒ@ƒCƒ‹\¬‚ðl‚¦‚Ä‚¢‚Ü‚·‚ªA‚Ü‚¾–¢’è‚Å‚·B
-
-#code
-u4 : 4 byte unsigned storage
-u2 : 2 byte unsigned storage
-u1 : 1 byte unsigned storage
-
-every storages are little endian :-)
-
-CompiledFile{
- u4 magic;
-
- u2 major;
- u2 minor;
-
- u4 character_code;
-
- u4 constants_pool_count;
- ConstantEntry constants_pool[constants_pool_count];
-
- u4 block_count;
- blockEntry blocks[block_count];
-
- u4 method_count;
- MethodEntry methods[method_count];
-}
-#end
-
-Java classfile ‚̃pƒNƒŠB
-
diff --git a/template/yasmdata.rb.tmpl b/template/yasmdata.rb.tmpl
deleted file mode 100644
index 95ad092e4f..0000000000
--- a/template/yasmdata.rb.tmpl
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*-ruby-*-
-#
-
-class VM
- class InstructionSequence
- class Instruction
- InsnID2NO = {
-<%= insn_id2no %>
- }
-
- def self.id2insn_no id
- if InsnID2NO.has_key? id
- InsnID2NO[id]
- end
- end
- end
- end
-end
-
-
diff --git a/test/csv/line_endings.gz b/test/csv/line_endings.gz
deleted file mode 100644
index 39e1729ee4..0000000000
--- a/test/csv/line_endings.gz
+++ /dev/null
Binary files differ
diff --git a/test/csv/tc_csv_parsing.rb b/test/csv/tc_csv_parsing.rb
deleted file mode 100644
index 965af929f3..0000000000
--- a/test/csv/tc_csv_parsing.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_csv_parsing.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-#
-# Following tests are my interpretation of the
-# {CSV RCF}[http://www.ietf.org/rfc/rfc4180.txt]. I only deviate from that
-# document in one place (intentionally) and that is to make the default row
-# separator <tt>$/</tt>.
-#
-class TestCSVParsing < Test::Unit::TestCase
- def test_mastering_regex_example
- ex = %Q{Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K}
- assert_equal( [ "Ten Thousand", "10000", " 2710 ", nil, "10,000",
- "It's \"10 Grand\", baby", "10K" ],
- CSV.parse_line(ex) )
- end
-
- # Old Ruby 1.8 CSV library tests.
- def test_std_lib_csv
- [ ["\t", ["\t"]],
- ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
- ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
- ["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
- ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
- ["\"\"", [""]],
- ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
- ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
- ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
- ["foo,\"\",baz", ["foo", "", "baz"]],
- ["\",\"", [","]],
- ["foo", ["foo"]],
- [",,", [nil, nil, nil]],
- [",", [nil, nil]],
- ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
- ["foo,,baz", ["foo", nil, "baz"]],
- ["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
- ["\",\",\",\"", [",", ","]],
- ["foo,bar,", ["foo", "bar", nil]],
- [",foo,bar", [nil, "foo", "bar"]],
- ["foo,bar", ["foo", "bar"]],
- [";", [";"]],
- ["\t,\t", ["\t", "\t"]],
- ["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
- ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
- ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
- [";,;", [";", ";"]] ].each do |csv_test|
- assert_equal(csv_test.last, CSV.parse_line(csv_test.first))
- end
-
- [ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
- ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
- ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
- ["\"\"", [""]],
- ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
- ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
- ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
- ["foo,\"\",baz", ["foo", "", "baz"]],
- ["foo", ["foo"]],
- [",,", [nil, nil, nil]],
- [",", [nil, nil]],
- ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
- ["foo,,baz", ["foo", nil, "baz"]],
- ["foo,bar", ["foo", "bar"]],
- ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
- ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]] ].each do |csv_test|
- assert_equal(csv_test.last, CSV.parse_line(csv_test.first))
- end
- end
-
- # From: http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/6496
- def test_aras_edge_cases
- [ [%Q{a,b}, ["a", "b"]],
- [%Q{a,"""b"""}, ["a", "\"b\""]],
- [%Q{a,"""b"}, ["a", "\"b"]],
- [%Q{a,"b"""}, ["a", "b\""]],
- [%Q{a,"\nb"""}, ["a", "\nb\""]],
- [%Q{a,"""\nb"}, ["a", "\"\nb"]],
- [%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
- [%Q{a,"""\nb\n""",\nc}, ["a", "\"\nb\n\"", nil]],
- [%Q{a,,,}, ["a", nil, nil, nil]],
- [%Q{,}, [nil, nil]],
- [%Q{"",""}, ["", ""]],
- [%Q{""""}, ["\""]],
- [%Q{"""",""}, ["\"",""]],
- [%Q{,""}, [nil,""]],
- [%Q{,"\r"}, [nil,"\r"]],
- [%Q{"\r\n,"}, ["\r\n,"]],
- [%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |edge_case|
- assert_equal(edge_case.last, CSV.parse_line(edge_case.first))
- end
- end
-
- def test_james_edge_cases
- # A read at eof? should return nil.
- assert_equal(nil, CSV.parse_line(""))
- #
- # With Ruby 1.8 CSV it's impossible to tell an empty line from a line
- # containing a single +nil+ field. The old CSV library returns
- # <tt>[nil]</tt> in these cases, but <tt>Array.new</tt> makes more sense to
- # me.
- #
- assert_equal(Array.new, CSV.parse_line("\n1,2,3\n"))
- end
-
- def test_malformed_csv
- assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line("1,2\r,3", :row_sep => "\n")
- end
-
- bad_data = <<-END_DATA.gsub(/^ +/, "")
- line,1,abc
- line,2,"def\nghi"
-
- line,4,some\rjunk
- line,5,jkl
- END_DATA
- lines = bad_data.lines.to_a
- assert_equal(6, lines.size)
- assert_match(/\Aline,4/, lines.find { |l| l =~ /some\rjunk/ })
-
- csv = CSV.new(bad_data)
- begin
- loop do
- assert_not_nil(csv.shift)
- assert_send([csv.lineno, :<, 4])
- end
- rescue CSV::MalformedCSVError
- assert_equal( "Unquoted fields do not allow \\r or \\n (line 4).",
- $!.message )
- end
-
- assert_raise(CSV::MalformedCSVError) { CSV.parse_line('1,2,"3...') }
-
- bad_data = <<-END_DATA.gsub(/^ +/, "")
- line,1,abc
- line,2,"def\nghi"
-
- line,4,8'10"
- line,5,jkl
- END_DATA
- lines = bad_data.lines.to_a
- assert_equal(6, lines.size)
- assert_match(/\Aline,4/, lines.find { |l| l =~ /8'10"/ })
-
- csv = CSV.new(bad_data)
- begin
- loop do
- assert_not_nil(csv.shift)
- assert_send([csv.lineno, :<, 4])
- end
- rescue CSV::MalformedCSVError
- assert_equal("Unclosed quoted field on line 4.", $!.message)
- end
- end
-end
diff --git a/test/csv/tc_csv_writing.rb b/test/csv/tc_csv_writing.rb
deleted file mode 100644
index 4677284306..0000000000
--- a/test/csv/tc_csv_writing.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_csv_writing.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-class TestCSVWriting < Test::Unit::TestCase
- def test_writing
- [ ["\t", ["\t"]],
- ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
- ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
- ["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
- ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
- ["\"\"", [""]],
- ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
- ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
- ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
- ["foo,\"\",baz", ["foo", "", "baz"]],
- ["\",\"", [","]],
- ["foo", ["foo"]],
- [",,", [nil, nil, nil]],
- [",", [nil, nil]],
- ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
- ["foo,,baz", ["foo", nil, "baz"]],
- ["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
- ["\",\",\",\"", [",", ","]],
- ["foo,bar,", ["foo", "bar", nil]],
- [",foo,bar", [nil, "foo", "bar"]],
- ["foo,bar", ["foo", "bar"]],
- [";", [";"]],
- ["\t,\t", ["\t", "\t"]],
- ["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
- ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
- ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
- [";,;", [";", ";"]],
- ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
- ["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
- ["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
- ["\"\"", [""]],
- ["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
- ["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
- ["foo,\"\r\",baz", ["foo", "\r", "baz"]],
- ["foo,\"\",baz", ["foo", "", "baz"]],
- ["foo", ["foo"]],
- [",,", [nil, nil, nil]],
- [",", [nil, nil]],
- ["foo,\"\n\",baz", ["foo", "\n", "baz"]],
- ["foo,,baz", ["foo", nil, "baz"]],
- ["foo,bar", ["foo", "bar"]],
- ["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
- ["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
- [%Q{a,b}, ["a", "b"]],
- [%Q{a,"""b"""}, ["a", "\"b\""]],
- [%Q{a,"""b"}, ["a", "\"b"]],
- [%Q{a,"b"""}, ["a", "b\""]],
- [%Q{a,"\nb"""}, ["a", "\nb\""]],
- [%Q{a,"""\nb"}, ["a", "\"\nb"]],
- [%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
- [%Q{a,"""\nb\n""",}, ["a", "\"\nb\n\"", nil]],
- [%Q{a,,,}, ["a", nil, nil, nil]],
- [%Q{,}, [nil, nil]],
- [%Q{"",""}, ["", ""]],
- [%Q{""""}, ["\""]],
- [%Q{"""",""}, ["\"",""]],
- [%Q{,""}, [nil,""]],
- [%Q{,"\r"}, [nil,"\r"]],
- [%Q{"\r\n,"}, ["\r\n,"]],
- [%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |test_case|
- assert_equal(test_case.first + $/, CSV.generate_line(test_case.last))
- end
- end
-
- def test_col_sep
- assert_equal( "a;b;;c\n", CSV.generate_line( ["a", "b", nil, "c"],
- :col_sep => ";" ) )
- assert_equal( "a\tb\t\tc\n", CSV.generate_line( ["a", "b", nil, "c"],
- :col_sep => "\t" ) )
- end
-
- def test_row_sep
- assert_equal( "a,b,,c\r\n", CSV.generate_line( ["a", "b", nil, "c"],
- :row_sep => "\r\n" ) )
- end
-
- def test_force_quotes
- assert_equal( %Q{"1","b","","already ""quoted"""\n},
- CSV.generate_line( [1, "b", nil, %Q{already "quoted"}],
- :force_quotes => true ) )
- end
-end
diff --git a/test/csv/tc_data_converters.rb b/test/csv/tc_data_converters.rb
deleted file mode 100644
index 24c6b6b76f..0000000000
--- a/test/csv/tc_data_converters.rb
+++ /dev/null
@@ -1,260 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_data_converters.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-class TestDataConverters < Test::Unit::TestCase
- def setup
- @data = "Numbers,:integer,1,:float,3.015"
- @parser = CSV.new(@data)
-
- @custom = lambda { |field| field =~ /\A:(\S.*?)\s*\Z/ ? $1.to_sym : field }
-
- @win_safe_time_str = Time.now.strftime("%a %b %d %H:%M:%S %Y")
- end
-
- def test_builtin_integer_converter
- # does convert
- [-5, 1, 10000000000].each do |n|
- assert_equal(n, CSV::Converters[:integer][n.to_s])
- end
-
- # does not convert
- (%w{junk 1.0} + [""]).each do |str|
- assert_equal(str, CSV::Converters[:integer][str])
- end
- end
-
- def test_builtin_float_converter
- # does convert
- [-5.1234, 0, 2.3e-11].each do |n|
- assert_equal(n, CSV::Converters[:float][n.to_s])
- end
-
- # does not convert
- (%w{junk 1..0 .015F} + [""]).each do |str|
- assert_equal(str, CSV::Converters[:float][str])
- end
- end
-
- def test_builtin_date_converter
- # does convert
- assert_instance_of(
- Date,
- CSV::Converters[:date][@win_safe_time_str.sub(/\d+:\d+:\d+ /, "")]
- )
-
- # does not convert
- assert_instance_of(String, CSV::Converters[:date]["junk"])
- end
-
- def test_builtin_date_time_converter
- # does convert
- assert_instance_of( DateTime,
- CSV::Converters[:date_time][@win_safe_time_str] )
-
- # does not convert
- assert_instance_of(String, CSV::Converters[:date_time]["junk"])
- end
-
- def test_convert_with_builtin
- # setup parser...
- assert(@parser.respond_to?(:convert))
- assert_nothing_raised(Exception) { @parser.convert(:integer) }
-
- # and use
- assert_equal(["Numbers", ":integer", 1, ":float", "3.015"], @parser.shift)
-
- setup # reset
-
- # setup parser...
- assert_nothing_raised(Exception) { @parser.convert(:float) }
-
- # and use
- assert_equal(["Numbers", ":integer", 1.0, ":float", 3.015], @parser.shift)
- end
-
- def test_convert_order
- # floats first, then integers...
- assert_nothing_raised(Exception) do
- @parser.convert(:float)
- @parser.convert(:integer)
- end
-
- # gets us nothing but floats
- assert_equal( [String, String, Float, String, Float],
- @parser.shift.map { |field| field.class } )
-
- setup # reset
-
- # integers have precendance...
- assert_nothing_raised(Exception) do
- @parser.convert(:integer)
- @parser.convert(:float)
- end
-
- # gives us proper number conversion
- assert_equal( [String, String, Fixnum, String, Float],
- @parser.shift.map { |field| field.class } )
- end
-
- def test_builtin_numeric_combo_converter
- # setup parser...
- assert_nothing_raised(Exception) { @parser.convert(:numeric) }
-
- # and use
- assert_equal( [String, String, Fixnum, String, Float],
- @parser.shift.map { |field| field.class } )
- end
-
- def test_builtin_all_nested_combo_converter
- # setup parser...
- @data << ",#{@win_safe_time_str}" # add a DateTime field
- @parser = CSV.new(@data) # reset parser
- assert_nothing_raised(Exception) { @parser.convert(:all) }
-
- # and use
- assert_equal( [String, String, Fixnum, String, Float, DateTime],
- @parser.shift.map { |field| field.class } )
- end
-
- def test_convert_with_custom_code
- # define custom converter...
- assert_nothing_raised(Exception) do
- @parser.convert { |field| field =~ /\A:(\S.*?)\s*\Z/ ? $1.to_sym : field }
- end
-
- # and use
- assert_equal(["Numbers", :integer, "1", :float, "3.015"], @parser.shift)
-
- setup # reset
-
- # mix built-in and custom...
- assert_nothing_raised(Exception) { @parser.convert(:numeric) }
- assert_nothing_raised(Exception) { @parser.convert(&@custom) }
-
- # and use
- assert_equal(["Numbers", :integer, 1, :float, 3.015], @parser.shift)
- end
-
- def test_convert_with_custom_code_using_field_info
- # define custom converter that uses field information...
- assert_nothing_raised(Exception) do
- @parser.convert do |field, info|
- assert_equal(1, info.line)
- info.index == 4 ? Float(field).floor : field
- end
- end
-
- # and use
- assert_equal(["Numbers", ":integer", "1", ":float", 3], @parser.shift)
- end
-
- def test_convert_with_custom_code_using_field_info_header
- @parser = CSV.new(@data, :headers => %w{one two three four five})
-
- # define custom converter that uses field header information...
- assert_nothing_raised(Exception) do
- @parser.convert do |field, info|
- info.header == "three" ? Integer(field) * 100 : field
- end
- end
-
- # and use
- assert_equal( ["Numbers", ":integer", 100, ":float", "3.015"],
- @parser.shift.fields )
- end
-
- def test_shortcut_interface
- assert_equal( ["Numbers", ":integer", 1, ":float", 3.015],
- CSV.parse_line(@data, :converters => :numeric) )
-
- assert_equal( ["Numbers", ":integer", 1, ":float", 3.015],
- CSV.parse_line(@data, :converters => [:integer, :float]) )
-
- assert_equal( ["Numbers", :integer, 1, :float, 3.015],
- CSV.parse_line(@data, :converters => [:numeric, @custom]) )
- end
-
- def test_unconverted_fields
- [ [ @data,
- ["Numbers", :integer, 1, :float, 3.015],
- %w{Numbers :integer 1 :float 3.015} ],
- ["\n", Array.new, Array.new] ].each do |test, fields, unconverted|
- row = nil
- assert_nothing_raised(Exception) do
- row = CSV.parse_line( test,
- :converters => [:numeric, @custom],
- :unconverted_fields => true )
- end
- assert_not_nil(row)
- assert_equal(fields, row)
- assert_respond_to(row, :unconverted_fields)
- assert_equal(unconverted, row.unconverted_fields)
- end
-
- data = <<-END_CSV.gsub(/^\s+/, "")
- first,second,third
- 1,2,3
- END_CSV
- row = nil
- assert_nothing_raised(Exception) do
- row = CSV.parse_line( data,
- :converters => :numeric,
- :unconverted_fields => true,
- :headers => :first_row )
- end
- assert_not_nil(row)
- assert_equal([["first", 1], ["second", 2], ["third", 3]], row.to_a)
- assert_respond_to(row, :unconverted_fields)
- assert_equal(%w{1 2 3}, row.unconverted_fields)
-
- assert_nothing_raised(Exception) do
- row = CSV.parse_line( data,
- :converters => :numeric,
- :unconverted_fields => true,
- :headers => :first_row,
- :return_headers => true )
- end
- assert_not_nil(row)
- assert_equal( [%w{first first}, %w{second second}, %w{third third}],
- row.to_a )
- assert_respond_to(row, :unconverted_fields)
- assert_equal(%w{first second third}, row.unconverted_fields)
-
- assert_nothing_raised(Exception) do
- row = CSV.parse_line( data,
- :converters => :numeric,
- :unconverted_fields => true,
- :headers => :first_row,
- :return_headers => true,
- :header_converters => :symbol )
- end
- assert_not_nil(row)
- assert_equal( [[:first, "first"], [:second, "second"], [:third, "third"]],
- row.to_a )
- assert_respond_to(row, :unconverted_fields)
- assert_equal(%w{first second third}, row.unconverted_fields)
-
- assert_nothing_raised(Exception) do
- row = CSV.parse_line( data,
- :converters => :numeric,
- :unconverted_fields => true,
- :headers => %w{my new headers},
- :return_headers => true,
- :header_converters => :symbol )
- end
- assert_not_nil(row)
- assert_equal( [[:my, "my"], [:new, "new"], [:headers, "headers"]],
- row.to_a )
- assert_respond_to(row, :unconverted_fields)
- assert_equal(Array.new, row.unconverted_fields)
- end
-end
diff --git a/test/csv/tc_features.rb b/test/csv/tc_features.rb
deleted file mode 100644
index ae5a8a451b..0000000000
--- a/test/csv/tc_features.rb
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_features.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-require "zlib"
-
-require "csv"
-
-class TestCSVFeatures < Test::Unit::TestCase
- TEST_CASES = [ [%Q{a,b}, ["a", "b"]],
- [%Q{a,"""b"""}, ["a", "\"b\""]],
- [%Q{a,"""b"}, ["a", "\"b"]],
- [%Q{a,"b"""}, ["a", "b\""]],
- [%Q{a,"\nb"""}, ["a", "\nb\""]],
- [%Q{a,"""\nb"}, ["a", "\"\nb"]],
- [%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
- [%Q{a,"""\nb\n""",\nc}, ["a", "\"\nb\n\"", nil]],
- [%Q{a,,,}, ["a", nil, nil, nil]],
- [%Q{,}, [nil, nil]],
- [%Q{"",""}, ["", ""]],
- [%Q{""""}, ["\""]],
- [%Q{"""",""}, ["\"",""]],
- [%Q{,""}, [nil,""]],
- [%Q{,"\r"}, [nil,"\r"]],
- [%Q{"\r\n,"}, ["\r\n,"]],
- [%Q{"\r\n,",}, ["\r\n,", nil]] ]
-
- def setup
- @sample_data = <<-END_DATA.gsub(/^ +/, "")
- line,1,abc
- line,2,"def\nghi"
-
- line,4,jkl
- END_DATA
- @csv = CSV.new(@sample_data)
- end
-
- def test_col_sep
- [";", "\t"].each do |sep|
- TEST_CASES.each do |test_case|
- assert_equal( test_case.last.map { |t| t.tr(",", sep) unless t.nil? },
- CSV.parse_line( test_case.first.tr(",", sep),
- :col_sep => sep ) )
- end
- end
- assert_equal([",,,", nil], CSV.parse_line(",,,;", :col_sep => ";"))
- end
-
- def test_row_sep
- assert_raise(CSV::MalformedCSVError) do
- CSV.parse_line("1,2,3\n,4,5\r\n", :row_sep => "\r\n")
- end
- assert_equal( ["1", "2", "3\n", "4", "5"],
- CSV.parse_line(%Q{1,2,"3\n",4,5\r\n}, :row_sep => "\r\n"))
- end
-
- def test_quote_char
- TEST_CASES.each do |test_case|
- assert_equal( test_case.last.map { |t| t.tr('"', "'") unless t.nil? },
- CSV.parse_line( test_case.first.tr('"', "'"),
- :quote_char => "'" ) )
- end
- end
-
- def test_row_sep_auto_discovery
- ["\r\n", "\n", "\r"].each do |line_end|
- data = "1,2,3#{line_end}4,5#{line_end}"
- discovered = CSV.new(data).instance_eval { @row_sep }
- assert_equal(line_end, discovered)
- end
-
- assert_equal("\n", CSV.new("\n\r\n\r").instance_eval { @row_sep })
-
- assert_equal($/, CSV.new("").instance_eval { @row_sep })
-
- assert_equal($/, CSV.new(STDERR).instance_eval { @row_sep })
- end
-
- def test_lineno
- assert_equal(5, @sample_data.lines.to_a.size)
-
- 4.times do |line_count|
- assert_equal(line_count, @csv.lineno)
- assert_not_nil(@csv.shift)
- assert_equal(line_count + 1, @csv.lineno)
- end
- assert_nil(@csv.shift)
- end
-
- def test_readline
- test_lineno
-
- @csv.rewind
-
- test_lineno
- end
-
- def test_unknown_options
- assert_raise(ArgumentError) { CSV.new(String.new, :unknown => :error) }
- end
-
- def test_skip_blanks
- assert_equal(4, @csv.to_a.size)
-
- @csv = CSV.new(@sample_data, :skip_blanks => true)
-
- count = 0
- @csv.each do |row|
- count += 1
- assert_equal("line", row.first)
- end
- assert_equal(3, count)
- end
-
- # reported by Kev Jackson
- def test_failing_to_escape_col_sep_bug_fix
- assert_nothing_raised(Exception) { CSV.new(String.new, :col_sep => "|") }
- end
-
- # reported by Chris Roos
- def test_failing_to_reset_headers_in_rewind_bug_fix
- csv = CSV.new("forename,surname", :headers => true, :return_headers => true)
- csv.each { |row| assert row.header_row? }
- csv.rewind
- csv.each { |row| assert row.header_row? }
- end
-
- # reported by Dave Burt
- def test_leading_empty_fields_with_multibyte_col_sep_bug_fix
- data = <<-END_DATA.gsub(/^\s+/, "")
- <=><=>A<=>B<=>C
- 1<=>2<=>3
- END_DATA
- parsed = CSV.parse(data, :col_sep => "<=>")
- assert_equal([[nil, nil, "A", "B", "C"], ["1", "2", "3"]], parsed)
- end
-
- def test_gzip_reader_bug_fix
- zipped = nil
- assert_nothing_raised(NoMethodError) do
- zipped = CSV.new(
- Zlib::GzipReader.open(
- File.join(File.dirname(__FILE__), "line_endings.gz")
- )
- )
- end
- assert_equal("\r\n", zipped.instance_eval { @row_sep })
- end
-
- def test_gzip_writer_bug_fix
- file = File.join(File.dirname(__FILE__), "temp.gz")
- zipped = nil
- assert_nothing_raised(NoMethodError) do
- zipped = CSV.new(Zlib::GzipWriter.open(file))
- end
- zipped << %w[one two three]
- zipped << [1, 2, 3]
- zipped.close
-
- assert( Zlib::GzipReader.open(file) { |f| f.read }.
- include?($INPUT_RECORD_SEPARATOR),
- "@row_sep did not default" )
- File.unlink(file)
- end
-
- def test_version
- assert_not_nil(CSV::VERSION)
- assert_instance_of(String, CSV::VERSION)
- assert(CSV::VERSION.frozen?)
- assert_match(/\A\d\.\d\.\d\Z/, CSV::VERSION)
- end
-end
diff --git a/test/csv/tc_headers.rb b/test/csv/tc_headers.rb
deleted file mode 100644
index 74e2f54ad4..0000000000
--- a/test/csv/tc_headers.rb
+++ /dev/null
@@ -1,261 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_headers.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-class TestCSVHeaders < Test::Unit::TestCase
- def setup
- @data = <<-END_CSV.gsub(/^\s+/, "")
- first,second,third
- A,B,C
- 1,2,3
- END_CSV
- end
-
- def test_first_row
- [:first_row, true].each do |setting| # two names for the same setting
- # activate headers
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => setting)
- end
-
- # first data row - skipping headers
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first A}, %w{second B}, %w{third C}], row.to_a)
-
- # second data row
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first 1}, %w{second 2}, %w{third 3}], row.to_a)
-
- # empty
- assert_nil(csv[2])
- end
- end
-
- def test_array_of_headers
- # activate headers
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => [:my, :new, :headers])
- end
-
- # first data row - skipping headers
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal( [[:my, "first"], [:new, "second"], [:headers, "third"]],
- row.to_a )
-
- # second data row
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([[:my, "A"], [:new, "B"], [:headers, "C"]], row.to_a)
-
- # third data row
- row = csv[2]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([[:my, "1"], [:new, "2"], [:headers, "3"]], row.to_a)
-
- # empty
- assert_nil(csv[3])
-
- # with return and convert
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => [:my, :new, :headers],
- :return_headers => true,
- :header_converters => lambda { |h| h.to_s } )
- end
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([["my", :my], ["new", :new], ["headers", :headers]], row.to_a)
- assert(row.header_row?)
- assert(!row.field_row?)
- end
-
- def test_csv_header_string
- # activate headers
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => "my,new,headers")
- end
-
- # first data row - skipping headers
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my first}, %w{new second}, %w{headers third}], row.to_a)
-
- # second data row
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my A}, %w{new B}, %w{headers C}], row.to_a)
-
- # third data row
- row = csv[2]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{my 1}, %w{new 2}, %w{headers 3}], row.to_a)
-
- # empty
- assert_nil(csv[3])
-
- # with return and convert
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => "my,new,headers",
- :return_headers => true,
- :header_converters => :symbol )
- end
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([[:my, "my"], [:new, "new"], [:headers, "headers"]], row.to_a)
- assert(row.header_row?)
- assert(!row.field_row?)
- end
-
- def test_return_headers
- # activate headers and request they are returned
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => true, :return_headers => true)
- end
-
- # header row
- row = csv[0]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal( [%w{first first}, %w{second second}, %w{third third}],
- row.to_a )
- assert(row.header_row?)
- assert(!row.field_row?)
-
- # first data row - skipping headers
- row = csv[1]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first A}, %w{second B}, %w{third C}], row.to_a)
- assert(!row.header_row?)
- assert(row.field_row?)
-
- # second data row
- row = csv[2]
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([%w{first 1}, %w{second 2}, %w{third 3}], row.to_a)
- assert(!row.header_row?)
- assert(row.field_row?)
-
- # empty
- assert_nil(csv[3])
- end
-
- def test_converters
- # create test data where headers and fields look alike
- data = <<-END_MATCHING_CSV.gsub(/^\s+/, "")
- 1,2,3
- 1,2,3
- END_MATCHING_CSV
-
- # normal converters do not affect headers
- csv = CSV.parse( data, :headers => true,
- :return_headers => true,
- :converters => :numeric )
- assert_equal([%w{1 1}, %w{2 2}, %w{3 3}], csv[0].to_a)
- assert_equal([["1", 1], ["2", 2], ["3", 3]], csv[1].to_a)
- assert_nil(csv[2])
-
- # header converters do affect headers (only)
- assert_nothing_raised(Exception) do
- csv = CSV.parse( data, :headers => true,
- :return_headers => true,
- :converters => :numeric,
- :header_converters => :symbol )
- end
- assert_equal([[:"1", "1"], [:"2", "2"], [:"3", "3"]], csv[0].to_a)
- assert_equal([[:"1", 1], [:"2", 2], [:"3", 3]], csv[1].to_a)
- assert_nil(csv[2])
- end
-
- def test_builtin_downcase_converter
- csv = CSV.parse( "One,TWO Three", :headers => true,
- :return_headers => true,
- :header_converters => :downcase )
- assert_equal(%w{one two\ three}, csv.headers)
- end
-
- def test_builtin_symbol_converter
- csv = CSV.parse( "One,TWO Three", :headers => true,
- :return_headers => true,
- :header_converters => :symbol )
- assert_equal([:one, :two_three], csv.headers)
- end
-
- def test_custom_converter
- converter = lambda { |header| header.tr(" ", "_") }
- csv = CSV.parse( "One,TWO Three",
- :headers => true,
- :return_headers => true,
- :header_converters => converter )
- assert_equal(%w{One TWO_Three}, csv.headers)
- end
-
- def test_table_support
- csv = nil
- assert_nothing_raised(Exception) do
- csv = CSV.parse(@data, :headers => true)
- end
-
- assert_instance_of(CSV::Table, csv)
- end
-
- def test_skip_blanks
- @data = <<-END_CSV.gsub(/^ +/, "")
-
-
- A,B,C
-
- 1,2,3
-
-
-
- END_CSV
-
- expected = [%w[1 2 3]]
- CSV.parse(@data, :headers => true, :skip_blanks => true) do |row|
- assert_equal(expected.shift, row.fields)
- end
-
- expected = [%w[A B C], %w[1 2 3]]
- CSV.parse( @data,
- :headers => true,
- :return_headers => true,
- :skip_blanks => true ) do |row|
- assert_equal(expected.shift, row.fields)
- end
- end
-
- def test_blank_row_bug_fix
- @data += "\n#{@data}" # add a blank row
-
- # ensure that everything returned is a Row object
- CSV.parse(@data, :headers => true) do |row|
- assert_instance_of(CSV::Row, row)
- end
- end
-end
diff --git a/test/csv/tc_interface.rb b/test/csv/tc_interface.rb
deleted file mode 100644
index e8cc920f9d..0000000000
--- a/test/csv/tc_interface.rb
+++ /dev/null
@@ -1,235 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_interface.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-class TestCSVInterface < Test::Unit::TestCase
- def setup
- @path = File.join(File.dirname(__FILE__), "temp_test_data.csv")
-
- File.open(@path, "w") do |file|
- file << "1\t2\t3\r\n"
- file << "4\t5\r\n"
- end
-
- @expected = [%w{1 2 3}, %w{4 5}]
- end
-
- def teardown
- File.unlink(@path)
- end
-
- ### Test Read Interface ###
-
- def test_foreach
- CSV.foreach(@path, :col_sep => "\t", :row_sep => "\r\n") do |row|
- assert_equal(@expected.shift, row)
- end
- end
-
- def test_open_and_close
- csv = CSV.open(@path, "r+", :col_sep => "\t", :row_sep => "\r\n")
- assert_not_nil(csv)
- assert_instance_of(CSV, csv)
- assert_equal(false, csv.closed?)
- csv.close
- assert(csv.closed?)
-
- ret = CSV.open(@path) do |csv|
- assert_instance_of(CSV, csv)
- "Return value."
- end
- assert(csv.closed?)
- assert_equal("Return value.", ret)
- end
-
- def test_parse
- data = File.read(@path)
- assert_equal( @expected,
- CSV.parse(data, :col_sep => "\t", :row_sep => "\r\n") )
-
- CSV.parse(data, :col_sep => "\t", :row_sep => "\r\n") do |row|
- assert_equal(@expected.shift, row)
- end
- end
-
- def test_parse_line
- row = CSV.parse_line("1;2;3", :col_sep => ";")
- assert_not_nil(row)
- assert_instance_of(Array, row)
- assert_equal(%w{1 2 3}, row)
-
- # shortcut interface
- row = "1;2;3".parse_csv(:col_sep => ";")
- assert_not_nil(row)
- assert_instance_of(Array, row)
- assert_equal(%w{1 2 3}, row)
- end
-
- def test_read_and_readlines
- assert_equal( @expected,
- CSV.read(@path, :col_sep => "\t", :row_sep => "\r\n") )
- assert_equal( @expected,
- CSV.readlines(@path, :col_sep => "\t", :row_sep => "\r\n") )
-
-
- data = CSV.open(@path, :col_sep => "\t", :row_sep => "\r\n") do |csv|
- csv.read
- end
- assert_equal(@expected, data)
- data = CSV.open(@path, :col_sep => "\t", :row_sep => "\r\n") do |csv|
- csv.readlines
- end
- assert_equal(@expected, data)
- end
-
- def test_table
- table = CSV.table(@path, :col_sep => "\t", :row_sep => "\r\n")
- assert_instance_of(CSV::Table, table)
- assert_equal([[:"1", :"2", :"3"], [4, 5, nil]], table.to_a)
- end
-
- def test_shift # aliased as gets() and readline()
- CSV.open(@path, "r+", :col_sep => "\t", :row_sep => "\r\n") do |csv|
- assert_equal(@expected.shift, csv.shift)
- assert_equal(@expected.shift, csv.shift)
- assert_equal(nil, csv.shift)
- end
- end
-
- ### Test Write Interface ###
-
- def test_generate
- str = CSV.generate do |csv| # default empty String
- assert_instance_of(CSV, csv)
- assert_equal(csv, csv << [1, 2, 3])
- assert_equal(csv, csv << [4, nil, 5])
- end
- assert_not_nil(str)
- assert_instance_of(String, str)
- assert_equal("1,2,3\n4,,5\n", str)
-
- CSV.generate(str) do |csv| # appending to a String
- assert_equal(csv, csv << ["last", %Q{"row"}])
- end
- assert_equal(%Q{1,2,3\n4,,5\nlast,"""row"""\n}, str)
- end
-
- def test_generate_line
- line = CSV.generate_line(%w{1 2 3}, :col_sep => ";")
- assert_not_nil(line)
- assert_instance_of(String, line)
- assert_equal("1;2;3\n", line)
-
- # shortcut interface
- line = %w{1 2 3}.to_csv(:col_sep => ";")
- assert_not_nil(line)
- assert_instance_of(String, line)
- assert_equal("1;2;3\n", line)
- end
-
- def test_write_header_detection
- File.unlink(@path)
-
- headers = %w{a b c}
- CSV.open(@path, "w", :headers => true) do |csv|
- csv << headers
- csv << %w{1 2 3}
- assert_equal(headers, csv.instance_variable_get(:@headers))
- end
- end
-
- def test_write_lineno
- File.unlink(@path)
-
- CSV.open(@path, "w") do |csv|
- lines = 20
- lines.times { csv << %w{a b c} }
- assert_equal(lines, csv.lineno)
- end
- end
-
- def test_write_hash
- File.unlink(@path)
-
- lines = [{:a => 1, :b => 2, :c => 3}, {:a => 4, :b => 5, :c => 6}]
- CSV.open( @path, "w", :headers => true,
- :converters => :all,
- :header_converters => :symbol ) do |csv|
- csv << lines.first.keys
- lines.each { |line| csv << line }
- end
- CSV.open( @path, "w", :headers => true,
- :converters => :all,
- :header_converters => :symbol ) do |csv|
- csv.each { |line| assert_equal(lines.shift, line.to_hash) }
- end
- end
-
- def test_append # aliased add_row() and puts()
- File.unlink(@path)
-
- CSV.open(@path, "w", :col_sep => "\t", :row_sep => "\r\n") do |csv|
- @expected.each { |row| csv << row }
- end
-
- test_shift
-
- # same thing using CSV::Row objects
- File.unlink(@path)
-
- CSV.open(@path, "w", :col_sep => "\t", :row_sep => "\r\n") do |csv|
- @expected.each { |row| csv << CSV::Row.new(Array.new, row) }
- end
-
- test_shift
- end
-
- ### Test Read and Write Interface ###
-
- def test_filter
- assert_respond_to(CSV, :filter)
-
- expected = [[1, 2, 3], [4, 5]]
- CSV.filter( "1;2;3\n4;5\n", (result = String.new),
- :in_col_sep => ";", :out_col_sep => ",",
- :converters => :all ) do |row|
- assert_equal(row, expected.shift)
- row.map! { |n| n * 2 }
- row << "Added\r"
- end
- assert_equal("2,4,6,\"Added\r\"\n8,10,\"Added\r\"\n", result)
- end
-
- def test_instance
- csv = String.new
-
- first = nil
- assert_nothing_raised(Exception) do
- first = CSV.instance(csv, :col_sep => ";")
- first << %w{a b c}
- end
-
- assert_equal("a;b;c\n", csv)
-
- second = nil
- assert_nothing_raised(Exception) do
- second = CSV.instance(csv, :col_sep => ";")
- second << [1, 2, 3]
- end
-
- assert_equal(first.object_id, second.object_id)
- assert_equal("a;b;c\n1;2;3\n", csv)
-
- # shortcuts
- assert_equal(STDOUT, CSV.instance.instance_eval { @io })
- assert_equal(STDOUT, CSV { |csv| csv.instance_eval { @io } })
- end
-end
diff --git a/test/csv/tc_row.rb b/test/csv/tc_row.rb
deleted file mode 100644
index a9b7f042b2..0000000000
--- a/test/csv/tc_row.rb
+++ /dev/null
@@ -1,289 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_row.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-class TestCSVRow < Test::Unit::TestCase
- def setup
- @row = CSV::Row.new(%w{A B C A A}, [1, 2, 3, 4])
- end
-
- def test_initialize
- # basic
- row = CSV::Row.new(%w{A B C}, [1, 2, 3])
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([["A", 1], ["B", 2], ["C", 3]], row.to_a)
-
- # missing headers
- row = CSV::Row.new(%w{A}, [1, 2, 3])
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([["A", 1], [nil, 2], [nil, 3]], row.to_a)
-
- # missing fields
- row = CSV::Row.new(%w{A B C}, [1, 2])
- assert_not_nil(row)
- assert_instance_of(CSV::Row, row)
- assert_equal([["A", 1], ["B", 2], ["C", nil]], row.to_a)
- end
-
- def test_row_type
- # field rows
- row = CSV::Row.new(%w{A B C}, [1, 2, 3]) # implicit
- assert(!row.header_row?)
- assert(row.field_row?)
- row = CSV::Row.new(%w{A B C}, [1, 2, 3], false) # explicit
- assert(!row.header_row?)
- assert(row.field_row?)
-
- # header row
- row = CSV::Row.new(%w{A B C}, [1, 2, 3], true)
- assert(row.header_row?)
- assert(!row.field_row?)
- end
-
- def test_headers
- assert_equal(%w{A B C A A}, @row.headers)
- end
-
- def test_field
- # by name
- assert_equal(2, @row.field("B"))
- assert_equal(2, @row["B"]) # alias
-
- # by index
- assert_equal(3, @row.field(2))
-
- # missing
- assert_nil(@row.field("Missing"))
- assert_nil(@row.field(10))
-
- # minimum index
- assert_equal(1, @row.field("A"))
- assert_equal(1, @row.field("A", 0))
- assert_equal(4, @row.field("A", 1))
- assert_equal(4, @row.field("A", 2))
- assert_equal(4, @row.field("A", 3))
- assert_equal(nil, @row.field("A", 4))
- assert_equal(nil, @row.field("A", 5))
- end
-
- def test_set_field
- # set field by name
- assert_equal(100, @row["A"] = 100)
-
- # set field by index
- assert_equal(300, @row[3] = 300)
-
- # set field by name and minimum index
- assert_equal([:a, :b, :c], @row["A", 4] = [:a, :b, :c])
-
- # verify the changes
- assert_equal( [ ["A", 100],
- ["B", 2],
- ["C", 3],
- ["A", 300],
- ["A", [:a, :b, :c]] ], @row.to_a )
-
- # assigning an index past the end
- assert_equal("End", @row[10] = "End")
- assert_equal( [ ["A", 100],
- ["B", 2],
- ["C", 3],
- ["A", 300],
- ["A", [:a, :b, :c]],
- [nil, nil],
- [nil, nil],
- [nil, nil],
- [nil, nil],
- [nil, nil],
- [nil, "End"] ], @row.to_a )
-
- # assigning a new field by header
- assert_equal("New", @row[:new] = "New")
- assert_equal( [ ["A", 100],
- ["B", 2],
- ["C", 3],
- ["A", 300],
- ["A", [:a, :b, :c]],
- [nil, nil],
- [nil, nil],
- [nil, nil],
- [nil, nil],
- [nil, nil],
- [nil, "End"],
- [:new, "New"] ], @row.to_a )
- end
-
- def test_append
- # add a value
- assert_equal(@row, @row << "Value")
- assert_equal( [ ["A", 1],
- ["B", 2],
- ["C", 3],
- ["A", 4],
- ["A", nil],
- [nil, "Value"] ], @row.to_a )
-
- # add a pair
- assert_equal(@row, @row << %w{Header Field})
- assert_equal( [ ["A", 1],
- ["B", 2],
- ["C", 3],
- ["A", 4],
- ["A", nil],
- [nil, "Value"],
- %w{Header Field} ], @row.to_a )
-
- # a pair with Hash syntax
- assert_equal(@row, @row << {:key => :value})
- assert_equal( [ ["A", 1],
- ["B", 2],
- ["C", 3],
- ["A", 4],
- ["A", nil],
- [nil, "Value"],
- %w{Header Field},
- [:key, :value] ], @row.to_a )
-
- # multiple fields at once
- assert_equal(@row, @row.push(100, 200, [:last, 300]))
- assert_equal( [ ["A", 1],
- ["B", 2],
- ["C", 3],
- ["A", 4],
- ["A", nil],
- [nil, "Value"],
- %w{Header Field},
- [:key, :value],
- [nil, 100],
- [nil, 200],
- [:last, 300] ], @row.to_a )
- end
-
- def test_delete
- # by index
- assert_equal(["B", 2], @row.delete(1))
-
- # by header
- assert_equal(["C", 3], @row.delete("C"))
-
- # using a block
- assert_equal(@row, @row.delete_if { |h, f| h == "A" and not f.nil? })
- assert_equal([["A", nil]], @row.to_a)
- end
-
- def test_fields
- # all fields
- assert_equal([1, 2, 3, 4, nil], @row.fields)
-
- # by header
- assert_equal([1, 3], @row.fields("A", "C"))
-
- # by index
- assert_equal([2, 3, nil], @row.fields(1, 2, 10))
-
- # by both
- assert_equal([2, 3, 4], @row.fields("B", "C", 3))
-
- # with minimum indices
- assert_equal([2, 3, 4], @row.fields("B", "C", ["A", 3]))
-
- # by header range
- assert_equal([2, 3], @row.values_at("B".."C"))
- end
-
- def test_index
- # basic usage
- assert_equal(0, @row.index("A"))
- assert_equal(1, @row.index("B"))
- assert_equal(2, @row.index("C"))
- assert_equal(nil, @row.index("Z"))
-
- # with minimum index
- assert_equal(0, @row.index("A"))
- assert_equal(0, @row.index("A", 0))
- assert_equal(3, @row.index("A", 1))
- assert_equal(3, @row.index("A", 2))
- assert_equal(3, @row.index("A", 3))
- assert_equal(4, @row.index("A", 4))
- assert_equal(nil, @row.index("A", 5))
- end
-
- def test_queries
- # headers
- assert(@row.header?("A"))
- assert(@row.header?("C"))
- assert(!@row.header?("Z"))
- assert(@row.include?("A")) # alias
-
- # fields
- assert(@row.field?(4))
- assert(@row.field?(nil))
- assert(!@row.field?(10))
- end
-
- def test_each
- # array style
- ary = @row.to_a
- @row.each do |pair|
- assert_equal(ary.first.first, pair.first)
- assert_equal(ary.shift.last, pair.last)
- end
-
- # hash style
- ary = @row.to_a
- @row.each do |header, field|
- assert_equal(ary.first.first, header)
- assert_equal(ary.shift.last, field)
- end
-
- # verify that we can chain the call
- assert_equal(@row, @row.each { })
- end
-
- def test_enumerable
- assert_equal( [["A", 1], ["A", 4], ["A", nil]],
- @row.select { |pair| pair.first == "A" } )
-
- assert_equal(10, @row.inject(0) { |sum, (header, n)| sum + (n || 0) })
- end
-
- def test_to_a
- row = CSV::Row.new(%w{A B C}, [1, 2, 3]).to_a
- assert_instance_of(Array, row)
- row.each do |pair|
- assert_instance_of(Array, pair)
- assert_equal(2, pair.size)
- end
- assert_equal([["A", 1], ["B", 2], ["C", 3]], row)
- end
-
- def test_to_hash
- assert_equal({"A" => nil, "B" => 2, "C" => 3}, @row.to_hash)
- end
-
- def test_to_csv
- # normal conversion
- assert_equal("1,2,3,4,\n", @row.to_csv)
- assert_equal("1,2,3,4,\n", @row.to_s) # alias
-
- # with options
- assert_equal( "1|2|3|4|\r\n",
- @row.to_csv(:col_sep => "|", :row_sep => "\r\n") )
- end
-
- def test_array_delegation
- assert(!@row.empty?, "Row was empty.")
-
- assert_equal([@row.headers.size, @row.fields.size].max, @row.size)
- end
-end
diff --git a/test/csv/tc_serialization.rb b/test/csv/tc_serialization.rb
deleted file mode 100644
index d9c37fde21..0000000000
--- a/test/csv/tc_serialization.rb
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_serialization.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-# An example of how to provide custom CSV serialization.
-class Hash
- def self.csv_load( meta, headers, fields )
- self[*headers.zip(fields).to_a.flatten.map { |e| eval(e) }]
- end
-
- def csv_headers
- keys.map { |key| key.inspect }
- end
-
- def csv_dump( headers )
- headers.map { |header| fetch(eval(header)).inspect }
- end
-end
-
-class TestSerialization < Test::Unit::TestCase
-
- ### Classes Used to Test Serialization ###
-
- class ReadOnlyName
- def initialize( first, last )
- @first, @last = first, last
- end
-
- attr_reader :first, :last
-
- def ==( other )
- %w{first last}.all? { |att| send(att) == other.send(att) }
- end
- end
-
- Name = Struct.new(:first, :last)
-
- class FullName < Name
- def initialize( first, last, suffix = nil )
- super(first, last)
-
- @suffix = suffix
- end
-
- attr_accessor :suffix
-
- def ==( other )
- %w{first last suffix}.all? { |att| send(att) == other.send(att) }
- end
- end
-
- ### Tests ###
-
- def test_class_dump
- @names = [ %w{James Gray},
- %w{Dana Gray},
- %w{Greg Brown} ].map do |first, last|
- ReadOnlyName.new(first, last)
- end
-
- assert_nothing_raised(Exception) do
- @data = CSV.dump(@names)
- end
- assert_equal(<<-END_CLASS_DUMP.gsub(/^\s*/, ""), @data)
- class,TestSerialization::ReadOnlyName
- @first,@last
- James,Gray
- Dana,Gray
- Greg,Brown
- END_CLASS_DUMP
- end
-
- def test_struct_dump
- @names = [ %w{James Gray},
- %w{Dana Gray},
- %w{Greg Brown} ].map do |first, last|
- Name.new(first, last)
- end
-
- assert_nothing_raised(Exception) do
- @data = CSV.dump(@names)
- end
- assert_equal(<<-END_STRUCT_DUMP.gsub(/^\s*/, ""), @data)
- class,TestSerialization::Name
- first=,last=
- James,Gray
- Dana,Gray
- Greg,Brown
- END_STRUCT_DUMP
- end
-
- def test_inherited_struct_dump
- @names = [ %w{James Gray II},
- %w{Dana Gray},
- %w{Greg Brown} ].map do |first, last, suffix|
- FullName.new(first, last, suffix)
- end
-
- assert_nothing_raised(Exception) do
- @data = CSV.dump(@names)
- end
- assert_equal(<<-END_STRUCT_DUMP.gsub(/^\s*/, ""), @data)
- class,TestSerialization::FullName
- @suffix,first=,last=
- II,James,Gray
- ,Dana,Gray
- ,Greg,Brown
- END_STRUCT_DUMP
- end
-
- def test_load
- %w{ test_class_dump
- test_struct_dump
- test_inherited_struct_dump }.each do |test|
- send(test)
- CSV.load(@data).each do |loaded|
- assert_instance_of(@names.first.class, loaded)
- assert_equal(@names.shift, loaded)
- end
- end
- end
-
- def test_io
- test_class_dump
-
- data_file = File.join(File.dirname(__FILE__), "temp_test_data.csv")
- CSV.dump(@names, File.open(data_file, "w"))
-
- assert(File.exist?(data_file))
- assert_equal(<<-END_IO_DUMP.gsub(/^\s*/, ""), File.read(data_file))
- class,TestSerialization::ReadOnlyName
- @first,@last
- James,Gray
- Dana,Gray
- Greg,Brown
- END_IO_DUMP
-
- assert_equal(@names, CSV.load(File.open(data_file)))
-
- File.unlink(data_file)
- end
-
- def test_custom_dump_and_load
- obj = {1 => "simple", :test => Hash}
- assert_equal(obj, CSV.load(CSV.dump([obj])).first)
- end
-end
diff --git a/test/csv/tc_table.rb b/test/csv/tc_table.rb
deleted file mode 100644
index 028274d97f..0000000000
--- a/test/csv/tc_table.rb
+++ /dev/null
@@ -1,392 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# tc_table.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "csv"
-
-class TestCSVTable < Test::Unit::TestCase
- def setup
- @rows = [ CSV::Row.new(%w{A B C}, [1, 2, 3]),
- CSV::Row.new(%w{A B C}, [4, 5, 6]),
- CSV::Row.new(%w{A B C}, [7, 8, 9]) ]
- @table = CSV::Table.new(@rows)
-
- @header_table = CSV::Table.new(
- [CSV::Row.new(%w{A B C}, %w{A B C}, true)] + @rows
- )
- end
-
- def test_initialze
- assert_not_nil(@table)
- assert_instance_of(CSV::Table, @table)
- end
-
- def test_modes
- assert_equal(:col_or_row, @table.mode)
-
- # non-destructive changes, intended for one shot calls
- cols = @table.by_col
- assert_equal(:col_or_row, @table.mode)
- assert_equal(:col, cols.mode)
- assert_equal(@table, cols)
-
- rows = @table.by_row
- assert_equal(:col_or_row, @table.mode)
- assert_equal(:row, rows.mode)
- assert_equal(@table, rows)
-
- # destructive mode changing calls
- assert_equal(@table, @table.by_row!)
- assert_equal(:row, @table.mode)
- assert_equal(@table, @table.by_col_or_row!)
- assert_equal(:col_or_row, @table.mode)
- end
-
- def test_headers
- assert_equal(@rows.first.headers, @table.headers)
- end
-
- def test_index
- ##################
- ### Mixed Mode ###
- ##################
- # by row
- @rows.each_index { |i| assert_equal(@rows[i], @table[i]) }
- assert_equal(nil, @table[100]) # empty row
-
- # by col
- @rows.first.headers.each do |header|
- assert_equal(@rows.map { |row| row[header] }, @table[header])
- end
- assert_equal([nil] * @rows.size, @table["Z"]) # empty col
-
- # by cell, row then col
- assert_equal(2, @table[0][1])
- assert_equal(6, @table[1]["C"])
-
- # by cell, col then row
- assert_equal(5, @table["B"][1])
- assert_equal(9, @table["C"][2])
-
- # with headers (by col)
- assert_equal(["B", 2, 5, 8], @header_table["B"])
-
- ###################
- ### Column Mode ###
- ###################
- @table.by_col!
-
- assert_equal([2, 5, 8], @table[1])
- assert_equal([2, 5, 8], @table["B"])
-
- ################
- ### Row Mode ###
- ################
- @table.by_row!
-
- assert_equal(@rows[1], @table[1])
- assert_raise(TypeError) { @table["B"] }
-
- ############################
- ### One Shot Mode Change ###
- ############################
- assert_equal(@rows[1], @table[1])
- assert_equal([2, 5, 8], @table.by_col[1])
- assert_equal(@rows[1], @table[1])
- end
-
- def test_set_row_or_column
- ##################
- ### Mixed Mode ###
- ##################
- # set row
- @table[2] = [10, 11, 12]
- assert_equal([%w[A B C], [1, 2, 3], [4, 5, 6], [10, 11, 12]], @table.to_a)
-
- @table[3] = CSV::Row.new(%w[A B C], [13, 14, 15])
- assert_equal( [%w[A B C], [1, 2, 3], [4, 5, 6], [10, 11, 12], [13, 14, 15]],
- @table.to_a )
-
- # set col
- @table["Type"] = "data"
- assert_equal( [ %w[A B C Type],
- [1, 2, 3, "data"],
- [4, 5, 6, "data"],
- [10, 11, 12, "data"],
- [13, 14, 15, "data"] ],
- @table.to_a )
-
- @table["Index"] = [1, 2, 3]
- assert_equal( [ %w[A B C Type Index],
- [1, 2, 3, "data", 1],
- [4, 5, 6, "data", 2],
- [10, 11, 12, "data", 3],
- [13, 14, 15, "data", nil] ],
- @table.to_a )
-
- @table["B"] = [100, 200]
- assert_equal( [ %w[A B C Type Index],
- [1, 100, 3, "data", 1],
- [4, 200, 6, "data", 2],
- [10, nil, 12, "data", 3],
- [13, nil, 15, "data", nil] ],
- @table.to_a )
-
- # verify resulting table
- assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
- A,B,C,Type,Index
- 1,100,3,data,1
- 4,200,6,data,2
- 10,,12,data,3
- 13,,15,data,
- END_RESULT
-
- # with headers
- @header_table["Type"] = "data"
- assert_equal(%w[Type data data data], @header_table["Type"])
-
- ###################
- ### Column Mode ###
- ###################
- @table.by_col!
-
- @table[1] = [2, 5, 11, 14]
- assert_equal( [ %w[A B C Type Index],
- [1, 2, 3, "data", 1],
- [4, 5, 6, "data", 2],
- [10, 11, 12, "data", 3],
- [13, 14, 15, "data", nil] ],
- @table.to_a )
-
- @table["Extra"] = "new stuff"
- assert_equal( [ %w[A B C Type Index Extra],
- [1, 2, 3, "data", 1, "new stuff"],
- [4, 5, 6, "data", 2, "new stuff"],
- [10, 11, 12, "data", 3, "new stuff"],
- [13, 14, 15, "data", nil, "new stuff"] ],
- @table.to_a )
-
- ################
- ### Row Mode ###
- ################
- @table.by_row!
-
- @table[1] = (1..6).to_a
- assert_equal( [ %w[A B C Type Index Extra],
- [1, 2, 3, "data", 1, "new stuff"],
- [1, 2, 3, 4, 5, 6],
- [10, 11, 12, "data", 3, "new stuff"],
- [13, 14, 15, "data", nil, "new stuff"] ],
- @table.to_a )
-
- assert_raise(TypeError) { @table["Extra"] = nil }
- end
-
- def test_each
- ######################
- ### Mixed/Row Mode ###
- ######################
- i = 0
- @table.each do |row|
- assert_equal(@rows[i], row)
- i += 1
- end
-
- # verify that we can chain the call
- assert_equal(@table, @table.each { })
-
- ###################
- ### Column Mode ###
- ###################
- @table.by_col!
-
- headers = @table.headers
- @table.each do |header, column|
- assert_equal(headers.shift, header)
- assert_equal(@table[header], column)
- end
-
- ############################
- ### One Shot Mode Change ###
- ############################
- @table.by_col_or_row!
-
- @table.each { |row| assert_instance_of(CSV::Row, row) }
- @table.by_col.each { |tuple| assert_instance_of(Array, tuple) }
- @table.each { |row| assert_instance_of(CSV::Row, row) }
- end
-
- def test_enumerable
- assert_equal( @rows.values_at(0, 2),
- @table.select { |row| (row["B"] % 2).zero? } )
-
- assert_equal(@rows[1], @table.find { |row| row["C"] > 5 })
- end
-
- def test_to_a
- assert_equal([%w[A B C], [1, 2, 3], [4, 5, 6], [7, 8, 9]], @table.to_a)
-
- # with headers
- assert_equal( [%w[A B C], [1, 2, 3], [4, 5, 6], [7, 8, 9]],
- @header_table.to_a )
- end
-
- def test_to_csv
- csv = <<-END_CSV.gsub(/^\s+/, "")
- A,B,C
- 1,2,3
- 4,5,6
- 7,8,9
- END_CSV
-
- # normal conversion
- assert_equal(csv, @table.to_csv)
- assert_equal(csv, @table.to_s) # alias
-
- # with options
- assert_equal( csv.gsub(",", "|").gsub("\n", "\r\n"),
- @table.to_csv(:col_sep => "|", :row_sep => "\r\n") )
-
- # with headers
- assert_equal(csv, @header_table.to_csv)
- end
-
- def test_append
- # verify that we can chain the call
- assert_equal(@table, @table << [10, 11, 12])
-
- # Array append
- assert_equal(CSV::Row.new(%w[A B C], [10, 11, 12]), @table[-1])
-
- # Row append
- assert_equal(@table, @table << CSV::Row.new(%w[A B C], [13, 14, 15]))
- assert_equal(CSV::Row.new(%w[A B C], [13, 14, 15]), @table[-1])
- end
-
- def test_delete
- ##################
- ### Mixed Mode ###
- ##################
- # delete a row
- assert_equal(@rows[1], @table.delete(1))
-
- # delete a col
- assert_equal(@rows.map { |row| row["A"] }, @table.delete("A"))
-
- # verify resulting table
- assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
- B,C
- 2,3
- 8,9
- END_RESULT
-
- ###################
- ### Column Mode ###
- ###################
- setup
- @table.by_col!
-
- assert_equal(@rows.map { |row| row[0] }, @table.delete(0))
- assert_equal(@rows.map { |row| row["C"] }, @table.delete("C"))
-
- # verify resulting table
- assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
- B
- 2
- 5
- 8
- END_RESULT
-
- ################
- ### Row Mode ###
- ################
- setup
- @table.by_row!
-
- assert_equal(@rows[1], @table.delete(1))
- assert_raise(TypeError) { @table.delete("C") }
-
- # verify resulting table
- assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
- A,B,C
- 1,2,3
- 7,8,9
- END_RESULT
- end
-
- def test_delete_if
- ######################
- ### Mixed/Row Mode ###
- ######################
- # verify that we can chain the call
- assert_equal(@table, @table.delete_if { |row| (row["B"] % 2).zero? })
-
- # verify resulting table
- assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
- A,B,C
- 4,5,6
- END_RESULT
-
- ###################
- ### Column Mode ###
- ###################
- setup
- @table.by_col!
-
- assert_equal(@table, @table.delete_if { |h, v| h > "A" })
- assert_equal(<<-END_RESULT.gsub(/^\s+/, ""), @table.to_csv)
- A
- 1
- 4
- 7
- END_RESULT
- end
-
- def test_values_at
- ##################
- ### Mixed Mode ###
- ##################
- # rows
- assert_equal(@rows.values_at(0, 2), @table.values_at(0, 2))
- assert_equal(@rows.values_at(1..2), @table.values_at(1..2))
-
- # cols
- assert_equal([[1, 3], [4, 6], [7, 9]], @table.values_at("A", "C"))
- assert_equal([[2, 3], [5, 6], [8, 9]], @table.values_at("B".."C"))
-
- ###################
- ### Column Mode ###
- ###################
- @table.by_col!
-
- assert_equal([[1, 3], [4, 6], [7, 9]], @table.values_at(0, 2))
- assert_equal([[1, 3], [4, 6], [7, 9]], @table.values_at("A", "C"))
-
- ################
- ### Row Mode ###
- ################
- @table.by_row!
-
- assert_equal(@rows.values_at(0, 2), @table.values_at(0, 2))
- assert_raise(TypeError) { @table.values_at("A", "C") }
-
- ############################
- ### One Shot Mode Change ###
- ############################
- assert_equal(@rows.values_at(0, 2), @table.values_at(0, 2))
- assert_equal([[1, 3], [4, 6], [7, 9]], @table.by_col.values_at(0, 2))
- assert_equal(@rows.values_at(0, 2), @table.values_at(0, 2))
- end
-
- def test_array_delegation
- assert(!@table.empty?, "Table was empty.")
-
- assert_equal(@rows.size, @table.size)
- end
-end
diff --git a/test/csv/test_csv.rb b/test/csv/test_csv.rb
new file mode 100644
index 0000000000..1db540921b
--- /dev/null
+++ b/test/csv/test_csv.rb
@@ -0,0 +1,1753 @@
+require 'test/unit'
+require 'tempfile'
+require 'fileutils'
+
+require 'csv'
+
+class CSV
+ class StreamBuf
+ # Let buffer work hard.
+ remove_const("BufSize")
+ BufSize = 2
+ end
+end
+
+
+module CSVTestSupport
+ def d(data)
+ data
+ end
+end
+
+
+class TestCSV < Test::Unit::TestCase
+ file = Tempfile.new("crlf")
+ file << "\n"
+ file.open
+ file.binmode
+ RSEP = file.read
+ file.close
+
+ include CSVTestSupport
+
+ class << self
+ include CSVTestSupport
+ end
+
+ @@simpleCSVData = {
+ [nil] => '',
+ [''] => '""',
+ [nil, nil] => ',',
+ [nil, nil, nil] => ',,',
+ ['foo'] => 'foo',
+ [','] => '","',
+ [',', ','] => '",",","',
+ [';'] => ';',
+ [';', ';'] => ';,;',
+ ["\"\r", "\"\r"] => "\"\"\"\r\",\"\"\"\r\"",
+ ["\"\n", "\"\n"] => "\"\"\"\n\",\"\"\"\n\"",
+ ["\t"] => "\t",
+ ["\t", "\t"] => "\t,\t",
+ ['foo', 'bar'] => 'foo,bar',
+ ['foo', '"bar"', 'baz'] => 'foo,"""bar""",baz',
+ ['foo', 'foo,bar', 'baz'] => 'foo,"foo,bar",baz',
+ ['foo', '""', 'baz'] => 'foo,"""""",baz',
+ ['foo', '', 'baz'] => 'foo,"",baz',
+ ['foo', nil, 'baz'] => 'foo,,baz',
+ [nil, 'foo', 'bar'] => ',foo,bar',
+ ['foo', 'bar', nil] => 'foo,bar,',
+ ['foo', "\r", 'baz'] => "foo,\"\r\",baz",
+ ['foo', "\n", 'baz'] => "foo,\"\n\",baz",
+ ['foo', "\r\n\r", 'baz'] => "foo,\"\r\n\r\",baz",
+ ['foo', "\r\n", 'baz'] => "foo,\"\r\n\",baz",
+ ['foo', "\r.\n", 'baz'] => "foo,\"\r.\n\",baz",
+ ['foo', "\r\n\n", 'baz'] => "foo,\"\r\n\n\",baz",
+ ['foo', '"', 'baz'] => 'foo,"""",baz',
+ }
+
+ @@fullCSVData = {
+ [d(nil)] => '',
+ [d('')] => '""',
+ [d(nil), d(nil)] => ',',
+ [d(nil), d(nil), d(nil)] => ',,',
+ [d('foo')] => 'foo',
+ [d('foo'), d('bar')] => 'foo,bar',
+ [d('foo'), d('"bar"'), d('baz')] => 'foo,"""bar""",baz',
+ [d('foo'), d('foo,bar'), d('baz')] => 'foo,"foo,bar",baz',
+ [d('foo'), d('""'), d('baz')] => 'foo,"""""",baz',
+ [d('foo'), d(''), d('baz')] => 'foo,"",baz',
+ [d('foo'), d(nil), d('baz')] => 'foo,,baz',
+ [d('foo'), d("\r"), d('baz')] => "foo,\"\r\",baz",
+ [d('foo'), d("\n"), d('baz')] => "foo,\"\n\",baz",
+ [d('foo'), d("\r\n"), d('baz')] => "foo,\"\r\n\",baz",
+ [d('foo'), d("\r.\n"), d('baz')] => "foo,\"\r.\n\",baz",
+ [d('foo'), d("\r\n\n"), d('baz')] => "foo,\"\r\n\n\",baz",
+ [d('foo'), d('"'), d('baz')] => 'foo,"""",baz',
+ }
+
+ @@fullCSVDataArray = @@fullCSVData.collect { |key, value| key }
+
+ def ssv2csv(ssvStr, row_sep = nil)
+ sepConv(ssvStr, ?;, ?,, row_sep)
+ end
+
+ def csv2ssv(csvStr, row_sep = nil)
+ sepConv(csvStr, ?,, ?;, row_sep)
+ end
+
+ def tsv2csv(tsvStr, row_sep = nil)
+ sepConv(tsvStr, ?\t, ?,, row_sep)
+ end
+
+ def csv2tsv(csvStr, row_sep = nil)
+ sepConv(csvStr, ?,, ?\t, row_sep)
+ end
+
+ def sepConv(srcStr, srcSep, destSep, row_sep = nil)
+ rows = []
+ cols, idx = CSV.parse_row(srcStr, 0, rows, srcSep, row_sep)
+ destStr = ''
+ cols = CSV.generate_row(rows, rows.size, destStr, destSep, row_sep)
+ destStr
+ end
+
+public
+
+ def setup
+ @tmpdir = File.join(Dir.tmpdir, "ruby_test_csv_tmp_#{$$}")
+ Dir.mkdir(@tmpdir)
+ @infile = File.join(@tmpdir, 'in.csv')
+ @infiletsv = File.join(@tmpdir, 'in.tsv')
+ @emptyfile = File.join(@tmpdir, 'empty.csv')
+ @outfile = File.join(@tmpdir, 'out.csv')
+ @bomfile = File.join(@tmpdir, "bom.csv")
+ @macfile = File.join(@tmpdir, "mac.csv")
+
+ CSV.open(@infile, "wb") do |writer|
+ @@fullCSVDataArray.each do |row|
+ writer.add_row(row)
+ end
+ end
+
+ CSV.open(@infiletsv, "wb", ?\t) do |writer|
+ @@fullCSVDataArray.each do |row|
+ writer.add_row(row)
+ end
+ end
+
+ CSV.generate(@emptyfile) do |writer|
+ # Create empty file.
+ end
+
+ File.open(@bomfile, "wb") do |f|
+ f.write("\357\273\277\"foo\"\r\n\"bar\"\r\n")
+ end
+
+ File.open(@macfile, "wb") do |f|
+ f.write("\"Avenches\",\"aus Umgebung\"\r\"Bad Hersfeld\",\"Ausgrabung\"")
+ end
+ end
+
+ def teardown
+ FileUtils.rm_rf(@tmpdir)
+ end
+
+ #### CSV::Reader unit test
+
+ def test_Reader_each
+ file = File.open(@infile, "rb")
+ begin
+ reader = CSV::Reader.create(file)
+ expectedArray = @@fullCSVDataArray.dup
+ first = true
+ ret = reader.each { |row|
+ if first
+ assert_instance_of(Array, row)
+ first = false
+ end
+ expected = expectedArray.shift
+ assert_equal(expected, row)
+ }
+ assert_nil(ret, "Return is nil")
+ assert(expectedArray.empty?)
+ ensure
+ file.close
+ end
+
+ # Illegal format.
+ reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
+ assert_raises(CSV::IllegalFormatError) do
+ reader.each do |row|
+ end
+ end
+
+ reader = CSV::Reader.create("a,b\r\n\"")
+ assert_raises(CSV::IllegalFormatError) do
+ reader.each do |row|
+ end
+ end
+ end
+
+ def test_Reader_shift
+ file = File.open(@infile, "rb")
+ begin
+ reader = CSV::Reader.create(file)
+ first = true
+ checked = 0
+ @@fullCSVDataArray.each do |expected|
+ actual = reader.shift
+ if first
+ assert_instance_of(Array, actual)
+ first = false
+ end
+ assert_equal(expected, actual)
+ checked += 1
+ end
+ assert(checked == @@fullCSVDataArray.size)
+ ensure
+ file.close
+ end
+
+ # Illegal format.
+ reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
+ assert_raises(CSV::IllegalFormatError) do
+ reader.shift
+ reader.shift
+ end
+
+ reader = CSV::Reader.create("a,b\r\na,b,\"c\"\ra")
+ assert_raises(CSV::IllegalFormatError) do
+ reader.shift
+ reader.shift
+ end
+ end
+
+ def test_Reader_getRow
+ if CSV::Reader.respond_to?(:allocate)
+ obj = CSV::Reader.allocate
+ assert_raises(NotImplementedError) do
+ row = []
+ obj.shift
+ end
+ end
+ end
+
+ def test_IOReader_close_on_terminate
+ f = File.open(@infile, "r")
+ reader = CSV::IOReader.create(f)
+ reader.close
+ assert(!f.closed?)
+ f.close
+
+ f = File.open(@infile, "r")
+ writer = CSV::IOReader.create(f)
+ writer.close_on_terminate
+ writer.close
+ assert(f.closed?)
+ end
+
+ def test_Reader_close
+ f = File.open(@infile, "r")
+ reader = CSV::IOReader.create(f)
+ reader.close_on_terminate
+ reader.close
+ assert(f.closed?)
+ end
+
+ def test_Reader_s_new
+ assert_raises(RuntimeError) do
+ CSV::Reader.new(nil)
+ end
+ end
+
+ def test_Reader_s_create
+ reader = CSV::Reader.create("abc")
+ assert_instance_of(CSV::StringReader, reader, "With a String")
+
+ file = File.open(@infile, "rb")
+ reader = CSV::Reader.create(file)
+ assert_instance_of(CSV::IOReader, reader, 'With an IO')
+
+ obj = Object.new
+ def obj.sysread(size)
+ "abc"
+ end
+ def obj.read(size)
+ "abc"
+ end
+ reader = CSV::Reader.create(obj)
+ assert_instance_of(CSV::IOReader, reader, "With not an IO or String")
+
+ # No need to test Tempfile because it's a pseudo IO. I test this here
+ # fors other tests.
+ reader = CSV::Reader.create(Tempfile.new("in.csv"))
+ assert_instance_of(CSV::IOReader, reader, "With an pseudo IO.")
+ file.close
+ end
+
+ def test_IOReader_s_create_binmode
+ file = File.open(@outfile, "wb")
+ file << "\"\r\n\",\"\r\",\"\n\"\r1,2,3"
+ file.close
+
+ file = File.open(@outfile, "rb")
+ begin
+ reader = CSV::IOReader.new(file, ?,, ?\r)
+ assert_equal(["\r\n", "\r", "\n"], reader.shift.to_a)
+ assert_equal(["1", "2", "3"], reader.shift.to_a)
+ reader.close
+ ensure
+ file.close
+ end
+
+ file = File.open(@outfile, "r") # not "rb"
+ begin
+ lfincell = (RSEP == "\n" ? "\r\n" : "\n")
+ reader = CSV::IOReader.new(file, ?,, ?\r)
+ assert_equal([lfincell, "\r", "\n"], reader.shift.to_a)
+ assert_equal(["1", "2", "3"], reader.shift.to_a)
+ reader.close
+ ensure
+ file.close
+ end
+ end
+
+ def test_Reader_s_parse
+ ret = CSV::Reader.parse("a,b,c") { |row|
+ assert_instance_of(Array, row, "Block parameter")
+ }
+ assert_nil(ret, "Return is nil")
+
+ ret = CSV::Reader.parse("a;b;c", ?;) { |row|
+ assert_instance_of(Array, row, "Block parameter")
+ }
+
+ file = Tempfile.new("in.csv")
+ file << "a,b,c"
+ file.open
+ ret = CSV::Reader.parse(file) { |row|
+ assert_instance_of(Array, row, "Block parameter")
+ }
+ assert_nil(ret, "Return is nil")
+
+ file = Tempfile.new("in.csv")
+ file << "a,b,c"
+ file.open
+ ret = CSV::Reader.parse(file, ?,) { |row|
+ assert_instance_of(Array, row, "Block parameter")
+ }
+
+ # Illegal format.
+ assert_raises(CSV::IllegalFormatError) do
+ CSV::Reader.parse("a,b\r\na,b,\"c\"\ra") do |row|
+ end
+ end
+
+ assert_raises(CSV::IllegalFormatError) do
+ CSV::Reader.parse("a,b\r\na,b\"") do |row|
+ end
+ end
+ end
+
+
+ #### CSV::Writer unit test
+
+ def test_Writer_s_new
+ assert_raises(RuntimeError) do
+ CSV::Writer.new(nil)
+ end
+ end
+
+ def test_Writer_s_generate
+ ret = CSV::Writer.generate(STDOUT) { |writer|
+ assert_instance_of(CSV::BasicWriter, writer, "Block parameter")
+ }
+
+ ret = CSV::Writer.generate(STDOUT, ?;) { |writer|
+ assert_instance_of(CSV::BasicWriter, writer, "Block parameter")
+ }
+
+ assert_nil(ret, "Return is nil")
+ end
+
+ def test_Writer_s_create
+ writer = CSV::Writer.create(STDERR)
+ assert_instance_of(CSV::BasicWriter, writer, "String")
+
+ writer = CSV::Writer.create(STDERR, ?;)
+ assert_instance_of(CSV::BasicWriter, writer, "String")
+
+ writer = CSV::Writer.create(Tempfile.new("out.csv"))
+ assert_instance_of(CSV::BasicWriter, writer, "IO")
+ end
+
+ def test_Writer_LSHIFT # '<<'
+ file = Tempfile.new("out.csv")
+ CSV::Writer.generate(file) do |writer|
+ ret = writer << ['a', 'b', 'c']
+ assert_instance_of(CSV::BasicWriter, ret, 'Return is self')
+
+ writer << [nil, 'e', 'f'] << [nil, nil, '']
+ end
+ file.open
+ file.binmode
+ str = file.read
+ assert_equal("a,b,c#{RSEP},e,f#{RSEP},,\"\"#{RSEP}", str, 'Normal')
+
+ file = Tempfile.new("out2.csv")
+ CSV::Writer.generate(file) do |writer|
+ ret = writer << [d('a'), d('b'), d('c')]
+ assert_instance_of(CSV::BasicWriter, ret, 'Return is self')
+
+ writer << [d(nil), d('e'), d('f')] << [d(nil), d(nil), d('')]
+ end
+ file.open
+ file.binmode
+ str = file.read
+ assert_equal("a,b,c#{RSEP},e,f#{RSEP},,\"\"#{RSEP}", str, 'Normal')
+ end
+
+ def test_Writer_add_row
+ file = Tempfile.new("out.csv")
+ CSV::Writer.generate(file) do |writer|
+ ret = writer.add_row(
+ [d('a'), d('b'), d('c')])
+ assert_instance_of(CSV::BasicWriter, ret, 'Return is self')
+
+ writer.add_row(
+ [d(nil), d('e'), d('f')]
+ ).add_row(
+ [d(nil), d(nil), d('')]
+ )
+ end
+ file.open
+ file.binmode
+ str = file.read
+ assert_equal("a,b,c#{RSEP},e,f#{RSEP},,\"\"#{RSEP}", str, 'Normal')
+ end
+
+ def test_Writer_close
+ f = File.open(@outfile, "w")
+ writer = CSV::BasicWriter.create(f)
+ writer.close_on_terminate
+ writer.close
+ assert(f.closed?)
+ end
+
+ def test_BasicWriter_close_on_terminate
+ f = File.open(@outfile, "w")
+ writer = CSV::BasicWriter.create(f)
+ writer.close
+ assert(!f.closed?)
+ f.close
+
+ f = File.open(@outfile, "w")
+ writer = CSV::BasicWriter.new(f)
+ writer.close_on_terminate
+ writer.close
+ assert(f.closed?)
+ end
+
+ def test_BasicWriter_s_create_binmode
+ file = File.open(@outfile, "w") # not "wb"
+ begin
+ writer = CSV::BasicWriter.new(file, ?,, ?\r)
+ writer << ["\r\n", "\r", "\n"]
+ writer << ["1", "2", "3"]
+ writer.close
+ ensure
+ file.close
+ end
+
+ file = File.open(@outfile, "rb")
+ str = file.read
+ file.close
+ assert_equal("\"\r#{RSEP}\",\"\r\",\"#{RSEP}\"\r1,2,3\r", str)
+ end
+
+ #### CSV unit test
+
+ def test_s_open_reader
+ assert_raises(ArgumentError, 'Illegal mode') do
+ CSV.open("temp", "a")
+ end
+
+ assert_raises(ArgumentError, 'Illegal mode') do
+ CSV.open("temp", "a", ?;)
+ end
+
+ reader = CSV.open(@infile, "r")
+ assert_instance_of(CSV::IOReader, reader)
+ reader.close
+
+ reader = CSV.open(@infile, "rb")
+ assert_instance_of(CSV::IOReader, reader)
+ reader.close
+
+ reader = CSV.open(@infile, "r", ?;)
+ assert_instance_of(CSV::IOReader, reader)
+ reader.close
+
+ CSV.open(@infile, "r") do |row|
+ assert_instance_of(Array, row)
+ break
+ end
+
+ CSV.open(@infiletsv, "r", ?\t) do |row|
+ assert_instance_of(Array, row)
+ break
+ end
+
+ assert_raises(Errno::ENOENT) do
+ CSV.open("NoSuchFileOrDirectory", "r")
+ end
+
+ assert_raises(Errno::ENOENT) do
+ CSV.open("NoSuchFileOrDirectory", "r", ?;)
+ end
+
+ # Illegal format.
+ File.open(@outfile, "wb") do |f|
+ f << "a,b\r\na,b,\"c\"\ra"
+ end
+ assert_raises(CSV::IllegalFormatError) do
+ CSV.open(@outfile, "r") do |row|
+ end
+ end
+
+ File.open(@outfile, "wb") do |f|
+ f << "a,b\r\na,b\""
+ end
+ assert_raises(CSV::IllegalFormatError) do
+ CSV.open(@outfile, "r") do |row|
+ end
+ end
+
+ CSV.open(@emptyfile, "r") do |row|
+ assert_fail("Must not reach here")
+ end
+ end
+
+ def test_s_parse
+ result = CSV.parse(File.read(@infile))
+ assert_instance_of(Array, result)
+ assert_instance_of(Array, result[0])
+
+ result = CSV.parse(File.read(@infile))
+ assert_instance_of(Array, result)
+ assert_instance_of(Array, result[0])
+
+ assert_equal([], CSV.parse(""))
+ assert_equal([[nil]], CSV.parse("\n"))
+
+ CSV.parse(File.read(@infile)) do |row|
+ assert_instance_of(Array, row)
+ break
+ end
+
+ CSV.parse(File.read(@infiletsv), ?\t) do |row|
+ assert_instance_of(Array, row)
+ break
+ end
+
+ CSV.parse("") do |row|
+ assert(false)
+ end
+
+ count = 0
+ CSV.parse("\n") do |row|
+ assert_equal([nil], row)
+ count += 1
+ end
+ assert_equal(1, count)
+
+ assert_equal([["a|b-c|d"]], CSV.parse("a|b-c|d"))
+ assert_equal([["a", "b"], ["c", "d"]], CSV.parse("a|b-c|d", "|", "-"))
+ end
+
+ def test_s_open_writer
+ writer = CSV.open(@outfile, "w")
+ assert_instance_of(CSV::BasicWriter, writer)
+ writer.close
+
+ writer = CSV.open(@outfile, "wb")
+ assert_instance_of(CSV::BasicWriter, writer)
+ writer.close
+
+ writer = CSV.open(@outfile, "wb", ?;)
+ assert_instance_of(CSV::BasicWriter, writer)
+ writer.close
+
+ CSV.open(@outfile, "w") do |writer|
+ assert_instance_of(CSV::BasicWriter, writer)
+ end
+
+ CSV.open(@outfile, "w", ?;) do |writer|
+ assert_instance_of(CSV::BasicWriter, writer)
+ end
+
+ begin
+ CSV.open(@tmpdir, "w")
+ assert(false)
+ rescue Exception => ex
+ assert(ex.is_a?(Errno::EEXIST) || ex.is_a?(Errno::EISDIR) || ex.is_a?(Errno::EACCES))
+ end
+ end
+
+ def test_s_generate
+ writer = CSV.generate(@outfile)
+ assert_instance_of(CSV::BasicWriter, writer)
+ writer.close
+
+ writer = CSV.generate(@outfile, ?;)
+ assert_instance_of(CSV::BasicWriter, writer)
+ writer.close
+
+ CSV.generate(@outfile) do |writer|
+ assert_instance_of(CSV::BasicWriter, writer)
+ end
+
+ CSV.generate(@outfile, ?;) do |writer|
+ assert_instance_of(CSV::BasicWriter, writer)
+ end
+
+ begin
+ CSV.generate(@tmpdir)
+ assert(false)
+ rescue Exception => ex
+ assert(ex.is_a?(Errno::EEXIST) || ex.is_a?(Errno::EISDIR) || ex.is_a?(Errno::EACCES))
+ end
+ end
+
+ def test_s_generate_line
+ str = CSV.generate_line([])
+ assert_equal('', str, "Extra boundary check.")
+
+ str = CSV.generate_line([], ?;)
+ assert_equal('', str, "Extra boundary check.")
+
+ @@simpleCSVData.each do |col, str|
+ buf = CSV.generate_line(col)
+ assert_equal(str, buf)
+ end
+
+ @@simpleCSVData.each do |col, str|
+ buf = CSV.generate_line(col, ?;)
+ assert_equal(str + "\n", ssv2csv(buf))
+ end
+
+ @@simpleCSVData.each do |col, str|
+ buf = CSV.generate_line(col, ?\t)
+ assert_equal(str + "\n", tsv2csv(buf))
+ end
+
+ str = CSV.generate_line(['a', 'b'], nil, ?|)
+ assert_equal('a,b', str)
+
+ str = CSV.generate_line(['a', 'b'], nil, "a")
+ assert_equal('"a",b', str)
+ end
+
+ def test_s_generate_row
+ buf = ''
+ cols = CSV.generate_row([], 0, buf)
+ assert_equal(0, cols)
+ assert_equal("\n", buf, "Extra boundary check.")
+
+ buf = ''
+ cols = CSV.generate_row([], 0, buf, ?;)
+ assert_equal(0, cols)
+ assert_equal("\n", buf, "Extra boundary check.")
+
+ buf = ''
+ cols = CSV.generate_row([], 0, buf, ?\t)
+ assert_equal(0, cols)
+ assert_equal("\n", buf, "Extra boundary check.")
+
+ buf = ''
+ cols = CSV.generate_row([], 0, buf, ?\t, ?|)
+ assert_equal(0, cols)
+ assert_equal("|", buf, "Extra boundary check.")
+
+ buf = ''
+ cols = CSV.generate_row([d('1')], 2, buf)
+ assert_equal('1,', buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1')], 2, buf, ?;)
+ assert_equal('1;', buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1')], 2, buf, ?\t)
+ assert_equal("1\t", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1')], 2, buf, ?\t, ?|)
+ assert_equal("1\t", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1'), d('2')], 1, buf)
+ assert_equal("1\n", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1'), d('2')], 1, buf, ?;)
+ assert_equal("1\n", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1'), d('2')], 1, buf, ?\t)
+ assert_equal("1\n", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1'), d('2')], 1, buf, ?\t, ?\n)
+ assert_equal("1\n", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1'), d('2')], 1, buf, ?\t, ?\r)
+ assert_equal("1\r", buf)
+
+ buf = ''
+ cols = CSV.generate_row([d('1'), d('2')], 1, buf, ?\t, ?|)
+ assert_equal("1|", buf)
+
+ @@fullCSVData.each do |col, str|
+ buf = ''
+ cols = CSV.generate_row(col, col.size, buf)
+ assert_equal(col.size, cols)
+ assert_equal(str + "\n", buf)
+ end
+
+ @@fullCSVData.each do |col, str|
+ buf = ''
+ cols = CSV.generate_row(col, col.size, buf, ?;)
+ assert_equal(col.size, cols)
+ assert_equal(str + "\n", ssv2csv(buf))
+ end
+
+ @@fullCSVData.each do |col, str|
+ buf = ''
+ cols = CSV.generate_row(col, col.size, buf, ?\t)
+ assert_equal(col.size, cols)
+ assert_equal(str + "\n", tsv2csv(buf))
+ end
+
+ # row separator
+ @@fullCSVData.each do |col, str|
+ buf = ''
+ cols = CSV.generate_row(col, col.size, buf, ?,, ?|)
+ assert_equal(col.size, cols)
+ assert_equal(str + "|", buf)
+ end
+
+ # col and row separator
+ @@fullCSVData.each do |col, str|
+ buf = ''
+ cols = CSV.generate_row(col, col.size, buf, ?\t, ?|)
+ assert_equal(col.size, cols)
+ assert_equal(str + "|", tsv2csv(buf, ?|))
+ end
+
+ buf = ''
+ toBe = ''
+ cols = 0
+ colsToBe = 0
+ @@fullCSVData.each do |col, str|
+ cols += CSV.generate_row(col, col.size, buf)
+ toBe << str << "\n"
+ colsToBe += col.size
+ end
+ assert_equal(colsToBe, cols)
+ assert_equal(toBe, buf)
+
+ buf = ''
+ toBe = ''
+ cols = 0
+ colsToBe = 0
+ @@fullCSVData.each do |col, str|
+ lineBuf = ''
+ cols += CSV.generate_row(col, col.size, lineBuf, ?;)
+ buf << ssv2csv(lineBuf) << "\n"
+ toBe << ssv2csv(lineBuf) << "\n"
+ colsToBe += col.size
+ end
+ assert_equal(colsToBe, cols)
+ assert_equal(toBe, buf)
+
+ buf = ''
+ toBe = ''
+ cols = 0
+ colsToBe = 0
+ @@fullCSVData.each do |col, str|
+ lineBuf = ''
+ cols += CSV.generate_row(col, col.size, lineBuf, ?\t)
+ buf << tsv2csv(lineBuf) << "\n"
+ toBe << tsv2csv(lineBuf) << "\n"
+ colsToBe += col.size
+ end
+ assert_equal(colsToBe, cols)
+ assert_equal(toBe, buf)
+
+ buf = ''
+ toBe = ''
+ cols = 0
+ colsToBe = 0
+ @@fullCSVData.each do |col, str|
+ lineBuf = ''
+ cols += CSV.generate_row(col, col.size, lineBuf, ?|)
+ buf << tsv2csv(lineBuf, ?|)
+ toBe << tsv2csv(lineBuf, ?|)
+ colsToBe += col.size
+ end
+ assert_equal(colsToBe, cols)
+ assert_equal(toBe, buf)
+ end
+
+ def test_s_parse_line
+ @@simpleCSVData.each do |col, str|
+ row = CSV.parse_line(str)
+ assert_instance_of(Array, row)
+ assert_equal(col.size, row.size)
+ assert_equal(col, row)
+ end
+
+ @@simpleCSVData.each do |col, str|
+ str = csv2ssv(str)
+ row = CSV.parse_line(str, ?;)
+ assert_instance_of(Array, row)
+ assert_equal(col.size, row.size, str.inspect)
+ assert_equal(col, row, str.inspect)
+ end
+
+ @@simpleCSVData.each do |col, str|
+ str = csv2tsv(str)
+ row = CSV.parse_line(str, ?\t)
+ assert_instance_of(Array, row)
+ assert_equal(col.size, row.size)
+ assert_equal(col, row)
+ end
+
+ assert_equal(['a', 'b', 'c'], CSV.parse_line("a,b,c", nil, nil))
+ assert_equal(['a', nil], CSV.parse_line("a,b,c", nil, ?b))
+ assert_equal(['a', 'b', nil], CSV.parse_line("a,b,c", nil, "c"))
+ assert_equal([nil], CSV.parse_line(""))
+ assert_equal([nil], CSV.parse_line("\n"))
+ assert_equal([""], CSV.parse_line("\"\"\n"))
+
+ # Illegal format.
+ buf = []
+ row = CSV.parse_line("a,b,\"c\"\ra")
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ buf = Array.new
+ row = CSV.parse_line("a;b;\"c\"\ra", ?;)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ buf = Array.new
+ row = CSV.parse_line("a\tb\t\"c\"\ra", ?\t)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("a,b\"")
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("a;b\"", ?;)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("a\tb\"", ?\t)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("\"a,b\"\r,")
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("\"a;b\"\r;", ?;)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("\"a\tb\"\r\t", ?\t)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("\"a,b\"\r\"")
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("\"a;b\"\r\"", ?;)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+
+ row = CSV.parse_line("\"a\tb\"\r\"", ?\t)
+ assert_instance_of(Array, row)
+ assert_equal(0, row.size)
+ end
+
+ def test_s_parse_row
+ @@fullCSVData.each do |col, str|
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "\r\n", 0, buf)
+ assert_equal(cols, buf.size, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf, str.inspect)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "\n", 0, buf, ?,, ?\n)
+ assert_equal(cols, buf.size, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf, str.inspect)
+
+ # separator: |
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "|", 0, buf, ?,)
+ assert_not_equal(col, buf)
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "|", 0, buf, ?,, ?|)
+ assert_equal(cols, buf.size, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf, str.inspect)
+ end
+
+ @@fullCSVData.each do |col, str|
+ str = csv2ssv(str)
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "\r\n", 0, buf, ?;)
+ assert_equal(cols, buf.size, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf, str)
+ end
+
+ @@fullCSVData.each do |col, str|
+ str = csv2tsv(str)
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "\r\n", 0, buf, ?\t)
+ assert_equal(cols, buf.size, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf, str)
+ end
+
+ @@fullCSVData.each do |col, str|
+ str = csv2tsv(str, ?|)
+ buf = Array.new
+ cols, idx = CSV.parse_row(str + "|", 0, buf, ?\t, ?|)
+ assert_equal(cols, buf.size, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf, str)
+ end
+
+ buf = []
+ CSV.parse_row("a,b,c", 0, buf, nil, nil)
+ assert_equal(['a', 'b', 'c'], buf)
+
+ buf = []
+ CSV.parse_row("a,b,c", 0, buf, nil, ?b)
+ assert_equal(['a', nil], buf)
+
+ buf = []
+ CSV.parse_row("a,b,c", 0, buf, nil, "c")
+ assert_equal(['a', 'b', nil], buf)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a,b,\"c\r\"", 0, buf)
+ assert_equal(["a", "b", "c\r"], buf.to_a)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a;b;\"c\r\"", 0, buf, ?;)
+ assert_equal(["a", "b", "c\r"], buf.to_a)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\tb\t\"c\r\"", 0, buf, ?\t)
+ assert_equal(["a", "b", "c\r"], buf.to_a)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a,b,c\n", 0, buf, ?,, ?\n)
+ assert_equal(["a", "b", "c"], buf.to_a)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\tb\tc\n", 0, buf, ?\t, ?\n)
+ assert_equal(["a", "b", "c"], buf.to_a)
+
+ # Illegal format.
+ buf = Array.new
+ cols, idx = CSV.parse_row("a,b,c\"", 0, buf)
+ assert_equal(0, cols, "Illegal format; unbalanced double-quote.")
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a;b;c\"", 0, buf, ?;)
+ assert_equal(0, cols, "Illegal format; unbalanced double-quote.")
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a,b,\"c\"\ra", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a,b,\"c\"\ra", 0, buf, ?;)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a,b\"", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a;b\"", 0, buf, ?;)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("\"a,b\"\r,", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\r,", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\r", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\rbc", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\r\"\"", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("a\r\rabc,", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("\"a;b\"\r;", 0, buf, ?;)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("\"a,b\"\r\"", 0, buf)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+
+ buf = Array.new
+ cols, idx = CSV.parse_row("\"a;b\"\r\"", 0, buf, ?;)
+ assert_equal(0, cols)
+ assert_equal(0, idx)
+ end
+
+ def test_s_parse_rowEOF
+ @@fullCSVData.each do |col, str|
+ if str == ''
+ # String "" is not allowed.
+ next
+ end
+ buf = Array.new
+ cols, idx = CSV.parse_row(str, 0, buf)
+ assert_equal(col.size, cols, "Reported size.")
+ assert_equal(col.size, buf.size, "Size.")
+ assert_equal(col, buf)
+ end
+ end
+
+ def test_s_parse_rowConcat
+ buf = ''
+ toBe = []
+ @@fullCSVData.each do |col, str|
+ buf << str << "\r\n"
+ toBe.concat(col)
+ end
+ idx = 0
+ cols = 0
+ parsed = Array.new
+ parsedCols = 0
+ begin
+ cols, idx = CSV.parse_row(buf, idx, parsed)
+ parsedCols += cols
+ end while cols > 0
+ assert_equal(toBe.size, parsedCols)
+ assert_equal(toBe.size, parsed.size)
+ assert_equal(toBe, parsed)
+
+ buf = ''
+ toBe = []
+ @@fullCSVData.each do |col, str|
+ buf << str << "\n"
+ toBe.concat(col)
+ end
+ idx = 0
+ cols = 0
+ parsed = Array.new
+ parsedCols = 0
+ begin
+ cols, idx = CSV.parse_row(buf, idx, parsed, ?,, ?\n)
+ parsedCols += cols
+ end while cols > 0
+ assert_equal(toBe.size, parsedCols)
+ assert_equal(toBe.size, parsed.size)
+ assert_equal(toBe, parsed)
+
+ buf = ''
+ toBe = []
+ @@fullCSVData.sort { |a, b|
+ a[0].length <=> b[0].length
+ }.each do |col, str|
+ buf << str << "\n"
+ toBe.concat(col)
+ end
+ idx = 0
+ cols = 0
+ parsed = Array.new
+ parsedCols = 0
+ begin
+ cols, idx = CSV.parse_row(buf, idx, parsed, ?,, ?\n)
+ parsedCols += cols
+ end while cols > 0
+ assert_equal(toBe.size, parsedCols)
+ assert_equal(toBe.size, parsed.size)
+ assert_equal(toBe, parsed)
+
+ buf = ''
+ toBe = []
+ @@fullCSVData.each do |col, str|
+ buf << str << "|"
+ toBe.concat(col)
+ end
+ idx = 0
+ cols = 0
+ parsed = []
+ parsedCols = 0
+ begin
+ cols, idx = CSV.parse_row(buf, idx, parsed, ?,, ?|)
+ parsedCols += cols
+ end while cols > 0
+ assert_equal(toBe.size, parsedCols)
+ assert_equal(toBe.size, parsed.size)
+ assert_equal(toBe, parsed)
+ end
+
+ def test_utf8
+ rows = []
+ CSV.open(@bomfile, "r") do |row|
+ rows << row.to_a
+ end
+ assert_equal([["foo"], ["bar"]], rows)
+
+ rows = []
+ file = File.open(@bomfile)
+ CSV::Reader.parse(file) do |row|
+ rows << row.to_a
+ end
+ assert_equal([["foo"], ["bar"]], rows)
+ file.close
+ end
+
+ def test_macCR
+ rows = []
+ CSV.open(@macfile, "r", ?,, ?\r) do |row|
+ rows << row.to_a
+ end
+ assert_equal([["Avenches", "aus Umgebung"], ["Bad Hersfeld", "Ausgrabung"]], rows)
+
+ rows = []
+ assert_raises(CSV::IllegalFormatError) do
+ CSV.open(@macfile, "r") do |row|
+ rows << row.to_a
+ end
+ assert_equal([["Avenches", "aus Umgebung\r\"Bad Hersfeld", "Ausgrabung"]], rows)
+ end
+
+ rows = []
+ file = File.open(@macfile)
+ begin
+ CSV::Reader.parse(file, ?,, ?\r) do |row|
+ rows << row.to_a
+ end
+ assert_equal([["Avenches", "aus Umgebung"], ["Bad Hersfeld", "Ausgrabung"]], rows)
+ ensure
+ file.close
+ end
+
+ rows = []
+ file = File.open(@macfile)
+ begin
+ assert_raises(CSV::IllegalFormatError) do
+ CSV::Reader.parse(file, ?,) do |row|
+ rows << row.to_a
+ end
+ assert_equal([["Avenches", "aus Umgebung\r\"Bad Hersfeld", "Ausgrabung"]], rows)
+ end
+ ensure
+ file.close
+ end
+ end
+
+
+ #### CSV unit test
+
+ InputStreamPattern = '0123456789'
+ InputStreamPatternSize = InputStreamPattern.size
+ def expChar(idx)
+ InputStreamPattern[idx % InputStreamPatternSize]
+ end
+
+ def expStr(idx, n)
+ if n > InputStreamPatternSize
+ InputStreamPattern + expStr(0, n - InputStreamPatternSize)
+ else
+ InputStreamPattern[idx % InputStreamPatternSize, n]
+ end
+ end
+
+ def setupInputStream(size, bufSize = nil)
+ setBufSize(bufSize) if bufSize
+ m = ((size / InputStreamPatternSize) + 1).to_i
+ File.open(@outfile, "wb") do |f|
+ f << (InputStreamPattern * m)[0, size]
+ end
+ file = File.open(@outfile, "rb")
+ buf = CSV::IOBuf.new(file)
+ if block_given?
+ yield(buf)
+ file.close
+ nil
+ else
+ buf
+ end
+ end
+
+ def setBufSize(size)
+ CSV::StreamBuf.module_eval('remove_const("BufSize")')
+ CSV::StreamBuf.module_eval("BufSize = #{ size }")
+ end
+
+ class StrBuf < CSV::StreamBuf
+ private
+ def initialize(string)
+ @str = string
+ @idx = 0
+ super()
+ end
+
+ def read(size)
+ str = @str[@idx, size]
+ if str.empty?
+ nil
+ else
+ @idx += str.size
+ str
+ end
+ end
+ end
+
+ class ErrBuf < CSV::StreamBuf
+ class Error < RuntimeError; end
+ private
+ def initialize
+ @first = true
+ super()
+ end
+
+ def read(size)
+ if @first
+ @first = false
+ "a" * size
+ else
+ raise ErrBuf::Error.new
+ end
+ end
+ end
+
+ def test_StreamBuf_MyBuf
+ # At first, check ruby's behaviour.
+ s = "abc"
+ assert_equal(?a, s[0])
+ assert_equal(?b, s[1])
+ assert_equal(?c, s[2])
+ assert_equal(nil, s[3])
+ assert_equal("a", s[0, 1])
+ assert_equal("b", s[1, 1])
+ assert_equal("c", s[2, 1])
+ assert_equal("", s[3, 1])
+ assert_equal(nil, s[4, 1])
+
+ s = StrBuf.new("abc")
+ assert_equal(?a, s[0])
+ assert_equal(?b, s.get(1))
+ assert_equal(?c, s[2])
+ assert_equal(nil, s.get(3))
+ assert_equal("a", s[0, 1])
+ assert_equal("b", s.get(1, 1))
+ assert_equal("c", s[2, 1])
+ assert_equal("", s.get(3, 1))
+ assert_equal(nil, s[4, 1])
+
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(?b, s[0])
+ assert(!s.is_eos?)
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(?c, s[0])
+ assert(!s.is_eos?)
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(nil, s[0])
+ assert(s.is_eos?)
+ dropped = s.drop(1)
+ assert_equal(0, dropped)
+ assert_equal(nil, s[0])
+ assert(s.is_eos?)
+
+ s = StrBuf.new("")
+ assert_equal(nil, s[0])
+
+ s = StrBuf.new("")
+ dropped = s.drop(1)
+ assert_equal(0, dropped)
+
+ assert_raises(TestCSV::ErrBuf::Error) do
+ s = ErrBuf.new
+ s[1024]
+ end
+
+ assert_raises(TestCSV::ErrBuf::Error) do
+ s = ErrBuf.new
+ s.drop(1024)
+ end
+ end
+
+ def test_StreamBuf_AREF # '[idx]'
+ setupInputStream(22, 1024) do |s|
+ [0, 1, 9, 10, 19, 20, 21].each do |idx|
+ assert_equal(expChar(idx), s[idx], idx.to_s)
+ end
+ [22, 23].each do |idx|
+ assert_equal(nil, s[idx], idx.to_s)
+ end
+ assert_equal(nil, s[-1])
+ end
+
+ setupInputStream(22, 1) do |s|
+ [0, 1, 9, 10, 19, 20, 21].each do |idx|
+ assert_equal(expChar(idx), s[idx], idx.to_s)
+ end
+ [22, 23].each do |idx|
+ assert_equal(nil, s[idx], idx.to_s)
+ end
+ end
+
+ setupInputStream(1024, 1) do |s|
+ [1023, 0].each do |idx|
+ assert_equal(expChar(idx), s[idx], idx.to_s)
+ end
+ [1024, 1025].each do |idx|
+ assert_equal(nil, s[idx], idx.to_s)
+ end
+ end
+
+ setupInputStream(1, 1) do |s|
+ [0].each do |idx|
+ assert_equal(expChar(idx), s[idx], idx.to_s)
+ end
+ [1, 2].each do |idx|
+ assert_equal(nil, s[idx], idx.to_s)
+ end
+ end
+ end
+
+ def test_StreamBuf_AREF_n # '[idx, n]'
+ # At first, check ruby's behaviour.
+ assert_equal("", "abc"[3, 1])
+ assert_equal(nil, "abc"[4, 1])
+
+ setupInputStream(22, 1024) do |s|
+ [0, 1, 9, 10, 19, 20, 21].each do |idx|
+ assert_equal(expStr(idx, 1), s[idx, 1], idx.to_s)
+ end
+ assert_equal("", s[22, 1])
+ assert_equal(nil, s[23, 1])
+ end
+
+ setupInputStream(22, 1) do |s|
+ [0, 1, 9, 10, 19, 20, 21].each do |idx|
+ assert_equal(expStr(idx, 1), s[idx, 1], idx.to_s)
+ end
+ assert_equal("", s[22, 1])
+ assert_equal(nil, s[23, 1])
+ end
+
+ setupInputStream(1024, 1) do |s|
+ [1023, 0].each do |idx|
+ assert_equal(expStr(idx, 1), s[idx, 1], idx.to_s)
+ end
+ assert_equal("", s[1024, 1])
+ assert_equal(nil, s[1025, 1])
+ end
+
+ setupInputStream(1, 1) do |s|
+ [0].each do |idx|
+ assert_equal(expStr(idx, 1), s[idx, 1], idx.to_s)
+ end
+ assert_equal("", s[1, 1])
+ assert_equal(nil, s[2, 1])
+ end
+
+ setupInputStream(22, 11) do |s|
+ [0, 1, 10, 11, 20].each do |idx|
+ assert_equal(expStr(idx, 2), s[idx, 2], idx.to_s)
+ end
+ assert_equal(expStr(21, 1), s[21, 2])
+
+ assert_equal(expStr(0, 12), s[0, 12])
+ assert_equal(expStr(10, 12), s[10, 12])
+ assert_equal(expStr(10, 12), s[10, 13])
+ assert_equal(expStr(10, 12), s[10, 14])
+ assert_equal(expStr(10, 12), s[10, 1024])
+
+ assert_equal(nil, s[0, -1])
+ assert_equal(nil, s[21, -1])
+
+ assert_equal(nil, s[-1, 10])
+ assert_equal(nil, s[-1, -1])
+ end
+ end
+
+ def test_StreamBuf_get
+ setupInputStream(22, 1024) do |s|
+ [0, 1, 9, 10, 19, 20, 21].each do |idx|
+ assert_equal(expChar(idx), s.get(idx), idx.to_s)
+ end
+ [22, 23].each do |idx|
+ assert_equal(nil, s.get(idx), idx.to_s)
+ end
+ assert_equal(nil, s.get(-1))
+ end
+ end
+
+ def test_StreamBuf_get_n
+ setupInputStream(22, 1024) do |s|
+ [0, 1, 9, 10, 19, 20, 21].each do |idx|
+ assert_equal(expStr(idx, 1), s.get(idx, 1), idx.to_s)
+ end
+ assert_equal("", s.get(22, 1))
+ assert_equal(nil, s.get(23, 1))
+
+ assert_equal(nil, s.get(-1, 1))
+ assert_equal(nil, s.get(-1, -1))
+ end
+ end
+
+ def test_StreamBuf_drop
+ setupInputStream(22, 1024) do |s|
+ assert_equal(expChar(0), s[0])
+ assert_equal(expChar(21), s[21])
+ assert_equal(nil, s[22])
+
+ dropped = s.drop(-1)
+ assert_equal(0, dropped)
+ assert_equal(expChar(0), s[0])
+
+ dropped = s.drop(0)
+ assert_equal(0, dropped)
+ assert_equal(expChar(0), s[0])
+
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(expChar(1), s[0])
+ assert_equal(expChar(2), s[1])
+
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(expChar(2), s[0])
+ assert_equal(expChar(3), s[1])
+ end
+
+ setupInputStream(4, 2) do |s|
+ dropped = s.drop(2)
+ assert_equal(2, dropped)
+ assert_equal(expChar(2), s[0])
+ assert_equal(expChar(3), s[1])
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(expChar(3), s[0])
+ assert_equal(nil, s[1])
+ dropped = s.drop(1)
+ assert_equal(1, dropped)
+ assert_equal(nil, s[0])
+ assert_equal(nil, s[1])
+ dropped = s.drop(0)
+ assert_equal(0, dropped)
+ assert_equal(nil, s[0])
+ assert_equal(nil, s[1])
+ end
+
+ setupInputStream(6, 3) do |s|
+ dropped = s.drop(2)
+ assert_equal(2, dropped)
+ dropped = s.drop(2)
+ assert_equal(2, dropped)
+ assert_equal(expChar(4), s[0])
+ assert_equal(expChar(5), s[1])
+ dropped = s.drop(3)
+ assert_equal(2, dropped)
+ assert_equal(nil, s[0])
+ assert_equal(nil, s[1])
+ end
+ end
+
+ def test_StreamBuf_is_eos?
+ setupInputStream(3, 1024) do |s|
+ assert(!s.is_eos?)
+ s.drop(1)
+ assert(!s.is_eos?)
+ s.drop(1)
+ assert(!s.is_eos?)
+ s.drop(1)
+ assert(s.is_eos?)
+ s.drop(1)
+ assert(s.is_eos?)
+ end
+
+ setupInputStream(3, 2) do |s|
+ assert(!s.is_eos?)
+ s.drop(1)
+ assert(!s.is_eos?)
+ s.drop(1)
+ assert(!s.is_eos?)
+ s.drop(1)
+ assert(s.is_eos?)
+ s.drop(1)
+ assert(s.is_eos?)
+ end
+ end
+
+ def test_StreamBuf_s_new
+ # NotImplementedError should be raised from StreamBuf#read.
+ assert_raises(NotImplementedError) do
+ CSV::StreamBuf.new
+ end
+ end
+
+ def test_IOBuf_close
+ f = File.open(@outfile, "wb")
+ f << "tst"
+ f.close
+
+ f = File.open(@outfile, "rb")
+ iobuf = CSV::IOBuf.new(f)
+ iobuf.close
+ assert(true) # iobuf.close does not raise any exception.
+ f.close
+ end
+
+ def test_IOBuf_s_new
+ iobuf = CSV::IOBuf.new(Tempfile.new("in.csv"))
+ assert_instance_of(CSV::IOBuf, iobuf)
+ end
+
+
+ #### CSV functional test
+
+ # sample data
+ #
+ # 1 2 3 4 5 6 7 8
+ # +------+-------+---------+-------+--------+------+----+------+
+ # | foo | "foo" | foo,bar | "" |(empty) |(null)| \r | \r\n |
+ # +------+-------+---------+-------+--------+------+----+------+
+ # | NaHi | "Na" | Na,Hi | \r.\n | \r\n\n | " | \n | \r\n |
+ # +------+-------+---------+-------+--------+------+----+------+
+ #
+ def test_s_parseAndCreate
+ colSize = 8
+ csvStr = "foo,!!!foo!!!,!foo,bar!,!!!!!!,!!,,!\r!,!\r\n!\nNaHi,!!!Na!!!,!Na,Hi!,!\r.\n!,!\r\n\n!,!!!!,!\n!,!\r\n!".gsub!('!', '"')
+ csvStrTerminated = csvStr + "\n"
+
+ myStr = csvStr.dup
+ res1 = []; res2 = []
+ idx = 0
+ col, idx = CSV::parse_row(myStr, 0, res1)
+ col, idx = CSV::parse_row(myStr, idx, res2)
+
+ buf = ''
+ col = CSV::generate_row(res1, colSize, buf)
+ col = CSV::generate_row(res2, colSize, buf)
+ assert_equal(csvStrTerminated, buf)
+
+ parsed = []
+ CSV::Reader.parse(csvStrTerminated) do |row|
+ parsed << row
+ end
+
+ buf = ''
+ CSV::Writer.generate(buf) do |writer|
+ parsed.each do |row|
+ writer.add_row(row)
+ end
+ end
+ assert_equal(csvStrTerminated, buf)
+
+ buf = ''
+ CSV::Writer.generate(buf) do |writer|
+ parsed.each do |row|
+ writer << row
+ end
+ end
+ assert_equal(csvStrTerminated, buf)
+ end
+
+ def test_writer_fs_rs_generate
+ buf = ''
+ CSV::Writer.generate(buf, ",,") do |writer|
+ writer << []
+ end
+ assert_equal("\n", buf)
+
+ buf = ''
+ CSV::Writer.generate(buf, ",,") do |writer|
+ writer << [] << []
+ end
+ assert_equal("\n\n", buf)
+
+ buf = ''
+ CSV::Writer.generate(buf, ",,") do |writer|
+ writer << [1]
+ end
+ assert_equal("1\n", buf)
+
+ buf = ''
+ CSV::Writer.generate(buf, ",,") do |writer|
+ writer << [1, 2, 3]
+ writer << [4, ",,", 5]
+ end
+ assert_equal("1,,2,,3\n4,,\",,\",,5\n", buf)
+
+ buf = ''
+ CSV::Writer.generate(buf, ",,:", ",,;") do |writer|
+ writer << [nil, nil, nil]
+ writer << [nil, ",,", nil]
+ end
+ assert_equal(",,:,,:,,;,,:,,,,:,,;", buf)
+
+ buf = ''
+ CSV::Writer.generate(buf, "---") do |writer|
+ writer << [1, 2, 3]
+ writer << [4, "---\"---", 5]
+ end
+ assert_equal("1---2---3\n4---\"---\"\"---\"---5\n", buf)
+
+ buf = ''
+ CSV::Writer.generate(buf, nil) do |writer|
+ writer << [1, 2, 3]
+ writer << [4, ",\",", 5]
+ end
+ assert_equal("1,2,3\n4,\",\"\",\",5\n", buf)
+ end
+
+ def test_writer_fs_rs_parse
+ reader = CSV::Reader.create('a||b--c||d', '||', '--')
+ assert_equal(['a', 'b'], reader.shift)
+ assert_equal(['c', 'd'], reader.shift)
+
+ reader = CSV::Reader.create("a@|b@-c@|d", "@|", "@-")
+ assert_equal(['a', 'b'], reader.shift)
+ assert_equal(['c', 'd'], reader.shift)
+
+ reader = CSV::Reader.create("ababfsababrs", "abfs", "abrs")
+ assert_equal(['ab', 'ab'], reader.shift)
+
+ reader = CSV::Reader.create('"ab"abfsababrs', "abfs", "abrs")
+ assert_equal(['ab', 'ab'], reader.shift)
+
+ reader = CSV::Reader.create('"ab"aabfsababrs', "abfs", "abrs")
+ assert_raises(CSV::IllegalFormatError) do
+ reader.shift
+ end
+
+ # fs match while matching rs progress
+ reader = CSV::Reader.create("ab,ababrs", nil, "abrs")
+ assert_equal(['ab', 'ab'], reader.shift)
+
+ reader = CSV::Reader.create(',ababrs', nil, "abrs")
+ assert_equal([nil, 'ab'], reader.shift)
+
+ reader = CSV::Reader.create('"",ababrs', nil, "abrs")
+ assert_equal(['', 'ab'], reader.shift)
+
+ reader = CSV::Reader.create('ab,"ab"abrs', nil, "abrs")
+ assert_equal(['ab', 'ab'], reader.shift)
+
+ reader = CSV::Reader.create('ab,"ab"aabrs', nil, "abrs")
+ assert_raises(CSV::IllegalFormatError) do
+ reader.shift
+ end
+
+ # rs match while matching fs progress
+ reader = CSV::Reader.create("ab|abc", 'ab-', "ab|")
+ assert_equal([nil], reader.shift)
+ assert_equal(['abc'], reader.shift)
+
+ reader = CSV::Reader.create("ab\ncdabcef", "abc", "\n")
+ assert_equal(['ab'], reader.shift)
+ assert_equal(['cd', "ef"], reader.shift)
+
+ # EOF while fs/rs matching
+ reader = CSV::Reader.create("ab", 'ab-', "xyz")
+ assert_equal(['ab'], reader.shift)
+
+ reader = CSV::Reader.create("ab", 'xyz', "ab|")
+ assert_equal(['ab'], reader.shift)
+
+ reader = CSV::Reader.create("ab", 'ab-', "ab|")
+ assert_equal(['ab'], reader.shift)
+
+ reader = CSV::Reader.create(",,:,,:,,;,,:,,,,:,,;", ",,:", ",,;")
+ assert_equal([nil, nil, nil], reader.shift)
+ assert_equal([nil, ",,", nil], reader.shift)
+ end
+
+ def test_s_foreach
+ File.open(@outfile, "w") do |f|
+ f << "1,2,3\n4,5,6"
+ end
+ row = []
+ CSV.foreach(@outfile) { |line|
+ row << line
+ }
+ assert_equal([['1', '2', '3'], ['4', '5', '6']], row)
+
+ File.open(@outfile, "w") do |f|
+ f << "1,2,3\r4,5,6"
+ end
+ row = []
+ CSV.foreach(@outfile, "\r") { |line|
+ row << line
+ }
+ assert_equal([['1', '2', '3'], ['4', '5', '6']], row)
+ end
+
+ def test_s_readlines
+ File.open(@outfile, "w") do |f|
+ f << "1,2,3\n4,5,6"
+ end
+ assert_equal([["1", "2", "3"], ["4", "5", "6"]], CSV.readlines(@outfile))
+ assert_equal([["1", "2", nil], [nil, "5", "6"]], CSV.readlines(@outfile, "3\n4"))
+ end
+
+ def test_s_read
+ File.open(@outfile, "w") do |f|
+ f << "1,2,3\n4,5,6"
+ end
+ assert_equal([["1", "2", "3"], ["4", "5", "6"]], CSV.read(@outfile))
+ assert_equal([["1", "2"]], CSV.read(@outfile, 3))
+ assert_equal([[nil], ["4", nil]], CSV.read(@outfile, 3, 5))
+ end
+end
diff --git a/test/csv/ts_all.rb b/test/csv/ts_all.rb
deleted file mode 100644
index c930523757..0000000000
--- a/test/csv/ts_all.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/local/bin/ruby -w
-
-# ts_all.rb
-#
-# Created by James Edward Gray II on 2005-10-31.
-# Copyright 2005 James Edward Gray II. You can redistribute or modify this code
-# under the terms of Ruby's license.
-
-require "test/unit"
-
-require "tc_csv_parsing"
-require "tc_features"
-require "tc_interface"
-require "tc_csv_writing"
-require "tc_data_converters"
-require "tc_row"
-require "tc_table"
-require "tc_headers"
-require "tc_serialization"
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb
index 159ab43f35..941e139946 100644
--- a/test/dbm/test_dbm.rb
+++ b/test/dbm/test_dbm.rb
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'tmpdir'
begin
require 'dbm'
@@ -13,7 +12,7 @@ if defined? DBM
class TestDBM < Test::Unit::TestCase
def TestDBM.uname_s
require 'rbconfig'
- case RbConfig::CONFIG['target_os']
+ case Config::CONFIG['target_os']
when 'cygwin'
require 'Win32API'
uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
@@ -22,25 +21,23 @@ if defined? DBM
utsname.unpack('A20' * 5)[0]
else
- RbConfig::CONFIG['target_os']
+ Config::CONFIG['target_os']
end
end
SYSTEM = uname_s
def setup
- @tmpdir = Dir.mktmpdir("tmptest_dbm")
- @prefix = "tmptest_dbm_#{$$}"
- @path = "#{@tmpdir}/#{@prefix}_"
+ @path = "tmptest_dbm_"
assert_instance_of(DBM, @dbm = DBM.new(@path))
# prepare to make readonly DBM file
- DBM.open("#{@tmpdir}/#{@prefix}_rdonly") {|dbm|
+ DBM.open("tmptest_dbm_rdonly") {|dbm|
dbm['foo'] = 'FOO'
}
- File.chmod(0400, *Dir.glob("#{@tmpdir}/#{@prefix}_rdonly.*"))
+ File.chmod(0400, *Dir.glob("tmptest_dbm_rdonly.*"))
- assert_instance_of(DBM, @dbm_rdonly = DBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
+ assert_instance_of(DBM, @dbm_rdonly = DBM.new("tmptest_dbm_rdonly", nil))
end
def teardown
assert_nil(@dbm.close)
@@ -48,7 +45,8 @@ if defined? DBM
ObjectSpace.each_object(DBM) do |obj|
obj.close unless obj.closed?
end
- FileUtils.remove_entry_secure @tmpdir
+ File.delete *Dir.glob("tmptest_dbm*").to_a
+ p Dir.glob("tmptest_dbm*") if $DEBUG
end
def check_size(expect, dbm=@dbm)
@@ -75,21 +73,21 @@ if defined? DBM
def test_s_new_has_no_block
# DBM.new ignore the block
foo = true
- assert_instance_of(DBM, dbm = DBM.new("#{@tmpdir}/#{@prefix}") { foo = false })
+ assert_instance_of(DBM, dbm = DBM.new("tmptest_dbm") { foo = false })
assert_equal(foo, true)
assert_nil(dbm.close)
end
def test_s_open_no_create
- assert_nil(dbm = DBM.open("#{@tmpdir}/#{@prefix}", nil))
+ assert_nil(dbm = DBM.open("tmptest_dbm", nil))
ensure
dbm.close if dbm
end
def test_s_open_with_block
- assert_equal(DBM.open("#{@tmpdir}/#{@prefix}") { :foo }, :foo)
+ assert_equal(DBM.open("tmptest_dbm") { :foo }, :foo)
end
def test_close
- assert_instance_of(DBM, dbm = DBM.open("#{@tmpdir}/#{@prefix}"))
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm"))
assert_nil(dbm.close)
# closed DBM file
@@ -166,6 +164,13 @@ if defined? DBM
assert_nil(@dbm['bar'])
end
+ def test_indexes
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+ assert_equal(values.reverse, @dbm.indexes(*keys.reverse))
+ end
+
def test_values_at
keys = %w(foo bar baz)
values = %w(FOO BAR BAZ)
@@ -497,41 +502,19 @@ if defined? DBM
end
class TestDBM2 < Test::Unit::TestCase
+ TMPROOT = "#{Dir.tmpdir}/ruby-dbm.#{$$}"
+
def setup
- @tmproot = Dir.mktmpdir('ruby-dbm')
+ Dir.mkdir TMPROOT
end
def teardown
- FileUtils.remove_entry_secure @tmproot if File.directory?(@tmproot)
- end
-
- def test_reader_open_notexist
- assert_raise(Errno::ENOENT) {
- DBM.open("#{@tmproot}/a", 0666, DBM::READER)
- }
- end
-
- def test_writer_open_notexist
- assert_raise(Errno::ENOENT) {
- DBM.open("#{@tmproot}/a", 0666, DBM::WRITER)
- }
- end
-
- def test_wrcreat_open_notexist
- v = DBM.open("#{@tmproot}/a", 0666, DBM::WRCREAT)
- assert_instance_of(DBM, v)
- v.close
- end
-
- def test_newdb_open_notexist
- v = DBM.open("#{@tmproot}/a", 0666, DBM::NEWDB)
- assert_instance_of(DBM, v)
- v.close
+ FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
end
def test_reader_open
- DBM.open("#{@tmproot}/a") {} # create a db.
- v = DBM.open("#{@tmproot}/a", nil, DBM::READER) {|d|
+ DBM.open("#{TMPROOT}/a") {}
+ v = DBM.open("#{TMPROOT}/a", nil, DBM::READER) {|d|
# Errno::EPERM is raised on Solaris which use ndbm.
# DBMError is raised on Debian which use gdbm.
assert_raises(Errno::EPERM, DBMError) { d["k"] = "v" }
@@ -541,10 +524,10 @@ if defined? DBM
end
def test_newdb_open
- DBM.open("#{@tmproot}/a") {|dbm|
+ DBM.open("#{TMPROOT}/a") {|dbm|
dbm["k"] = "v"
}
- v = DBM.open("#{@tmproot}/a", nil, DBM::NEWDB) {|d|
+ v = DBM.open("#{TMPROOT}/a", nil, DBM::NEWDB) {|d|
assert_equal(0, d.length)
assert_nil(d["k"])
true
@@ -553,9 +536,9 @@ if defined? DBM
end
def test_freeze
- DBM.open("#{@tmproot}/a") {|d|
+ DBM.open("#{TMPROOT}/a") {|d|
d.freeze
- assert_raises(RuntimeError) { d["k"] = "v" }
+ assert_raises(TypeError) { d["k"] = "v" }
}
end
end
diff --git a/test/digest/test_digest_hmac.rb b/test/digest/test_digest_hmac.rb
deleted file mode 100644
index a0d5d2f244..0000000000
--- a/test/digest/test_digest_hmac.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('../inlinetest.rb')
-InlineTest.loadtest__END__part('digest/hmac.rb')
diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb
index 143d856a1e..bc16ab1ca2 100644
--- a/test/drb/drbtest.rb
+++ b/test/drb/drbtest.rb
@@ -179,7 +179,7 @@ module DRbCore
def test_07_public_private_protected_missing
assert_nothing_raised() {
begin
- @there.method_missing(:eval, 'nil')
+ @there.method_missing(:eval)
rescue NoMethodError
assert_match(/^private method \`eval\'/, $!.message)
end
@@ -208,7 +208,7 @@ module DRbCore
assert_match(/^undefined method \`undefined_method_test\'/, $!.message)
end
}
- assert_raises(DRb::DRbConnError) do
+ assert_raises(SecurityError) do
@there.method_missing(:__send__, :to_s)
end
assert_equal(true, @there.missing)
@@ -305,19 +305,18 @@ module DRbAry
assert_equal([1, 2, 'III', 'III', 4, 'five', 6], ary)
end
- # retry in block is not supported on ruby 1.9
- #def test_04_retry
- # retried = false
- # ary = []
- # @there.each do |x|
- # ary.push x
- # if x == 4 && !retried
- # retried = true
- # retry
- # end
- # end
- # assert_equal([1, 2, 'III', 4, 1, 2, 'III', 4, 'five', 6], ary)
- #end
+ def test_04_retry
+ retried = false
+ ary = []
+ @there.each do |x|
+ ary.push x
+ if x == 4 && !retried
+ retried = true
+ retry
+ end
+ end
+ assert_equal([1, 2, 'III', 4, 1, 2, 'III', 4, 'five', 6], ary)
+ end
def test_05_break
ary = []
diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb
index 106e958d9a..5719f60b80 100644
--- a/test/drb/test_drb.rb
+++ b/test/drb/test_drb.rb
@@ -113,7 +113,7 @@ class TestDRbYield < Test::Unit::TestCase
end
end
-class TestDRbRubyYield < TestDRbYield
+class TestRubyYield < TestDRbYield
def echo_yield(*arg)
yield(*arg)
end
@@ -145,7 +145,7 @@ class TestDRbRubyYield < TestDRbYield
end
end
-class TestDRbRuby18Yield < TestDRbRubyYield
+class TestRuby18Yield < TestRubyYield
class YieldTest18
def echo_yield(*arg, &proc)
proc.call(*arg)
@@ -207,7 +207,7 @@ class TestDRbSafe1 < TestDRbAry
end
end
-class TestDRbEval # < Test::Unit::TestCase
+class TestDRbEval < Test::Unit::TestCase
def setup
super
@ext = DRbService.ext_service('ut_eval.rb')
diff --git a/test/erb/hello.erb b/test/erb/hello.erb
new file mode 100644
index 0000000000..d5ebcb73b9
--- /dev/null
+++ b/test/erb/hello.erb
@@ -0,0 +1,4 @@
+= hello
+<% 3.times do |n| %>
+* <%= n %>
+<% end %>
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb
index 0572720635..935998493f 100644
--- a/test/erb/test_erb.rb
+++ b/test/erb/test_erb.rb
@@ -9,7 +9,7 @@ class TestERB < Test::Unit::TestCase
e = assert_raise(MyError) {
erb.result
}
- assert_equal("(erb):1:in `raise'", e.backtrace[0])
+ assert_equal("(erb):1", e.backtrace[0])
end
def test_with_filename
@@ -18,7 +18,7 @@ class TestERB < Test::Unit::TestCase
e = assert_raise(MyError) {
erb.result
}
- assert_equal("test filename:1:in `raise'", e.backtrace[0])
+ assert_equal("test filename:1", e.backtrace[0])
end
def test_without_filename_with_safe_level
@@ -26,7 +26,7 @@ class TestERB < Test::Unit::TestCase
e = assert_raise(MyError) {
erb.result
}
- assert_equal("(erb):1:in `raise'", e.backtrace[0])
+ assert_equal("(erb):1", e.backtrace[0])
end
def test_with_filename_and_safe_level
@@ -35,6 +35,392 @@ class TestERB < Test::Unit::TestCase
e = assert_raise(MyError) {
erb.result
}
- assert_equal("test filename:1:in `raise'", e.backtrace[0])
+ assert_equal("test filename:1", e.backtrace[0])
+ end
+end
+
+class TestERBCore < Test::Unit::TestCase
+ def setup
+ @erb = ERB
+ end
+
+ def test_core
+ _test_core(nil)
+ _test_core(0)
+ _test_core(1)
+ _test_core(2)
+ _test_core(3)
+ end
+
+ def _test_core(safe)
+ erb = @erb.new("hello")
+ assert_equal("hello", erb.result)
+
+ erb = @erb.new("hello", safe, 0)
+ assert_equal("hello", erb.result)
+
+ erb = @erb.new("hello", safe, 1)
+ assert_equal("hello", erb.result)
+
+ erb = @erb.new("hello", safe, 2)
+ assert_equal("hello", erb.result)
+
+ src = <<EOS
+%% hi
+= hello
+<% 3.times do |n| %>
+% n=0
+* <%= n %>
+<% end %>
+EOS
+
+ ans = <<EOS
+%% hi
+= hello
+
+% n=0
+* 0
+
+% n=0
+* 1
+
+% n=0
+* 2
+
+EOS
+ erb = @erb.new(src)
+ assert_equal(ans, erb.result)
+ erb = @erb.new(src, safe, 0)
+ assert_equal(ans, erb.result)
+ erb = @erb.new(src, safe, '')
+ assert_equal(ans, erb.result)
+
+ ans = <<EOS
+%% hi
+= hello
+% n=0
+* 0% n=0
+* 1% n=0
+* 2
+EOS
+ erb = @erb.new(src, safe, 1)
+ assert_equal(ans.chomp, erb.result)
+ erb = @erb.new(src, safe, '>')
+ assert_equal(ans.chomp, erb.result)
+
+ ans = <<EOS
+%% hi
+= hello
+% n=0
+* 0
+% n=0
+* 1
+% n=0
+* 2
+EOS
+
+ erb = @erb.new(src, safe, 2)
+ assert_equal(ans, erb.result)
+ erb = @erb.new(src, safe, '<>')
+ assert_equal(ans, erb.result)
+
+ ans = <<EOS
+% hi
+= hello
+
+* 0
+
+* 0
+
+* 0
+
+EOS
+ erb = @erb.new(src, safe, '%')
+ assert_equal(ans, erb.result)
+
+ ans = <<EOS
+% hi
+= hello
+* 0* 0* 0
+EOS
+ erb = @erb.new(src, safe, '%>')
+ assert_equal(ans.chomp, erb.result)
+
+ ans = <<EOS
+% hi
+= hello
+* 0
+* 0
+* 0
+EOS
+ erb = @erb.new(src, safe, '%<>')
+ assert_equal(ans, erb.result)
+ end
+
+ def test_safe_04
+ erb = @erb.new('<%=$SAFE%>', 4)
+ assert_equal('4', erb.result(TOPLEVEL_BINDING.taint))
+ end
+
+ class Foo; end
+
+ def test_def_class
+ erb = @erb.new('hello')
+ cls = erb.def_class
+ assert_equal(Object, cls.superclass)
+ assert(cls.new.respond_to?('result'))
+ cls = erb.def_class(Foo)
+ assert_equal(Foo, cls.superclass)
+ assert(cls.new.respond_to?('result'))
+ cls = erb.def_class(Object, 'erb')
+ assert_equal(Object, cls.superclass)
+ assert(cls.new.respond_to?('erb'))
+ end
+
+ def test_percent
+ src = <<EOS
+%n = 1
+<%= n%>
+EOS
+ assert_equal("1\n", ERB.new(src, nil, '%').result)
+
+ src = <<EOS
+<%
+%>
+EOS
+ ans = "\n"
+ assert_equal(ans, ERB.new(src, nil, '%').result)
+
+ src = "<%\n%>"
+ # ans = "\n"
+ ans = ""
+ assert_equal(ans, ERB.new(src, nil, '%').result)
+
+ src = <<EOS
+<%
+n = 1
+%><%= n%>
+EOS
+ assert_equal("1\n", ERB.new(src, nil, '%').result)
+
+ src = <<EOS
+%n = 1
+%% <% n = 2
+n.times do |i|%>
+%% %%><%%<%= i%><%
+end%>
+%%%
+EOS
+ ans = <<EOS
+%
+% %%><%0
+% %%><%1
+%%
+EOS
+ assert_equal(ans, ERB.new(src, nil, '%').result)
+ end
+
+ def test_def_method
+ klass = Class.new
+ klass.module_eval do
+ extend ERB::DefMethod
+ fname = File.join(File.dirname(File.expand_path(__FILE__)), 'hello.erb')
+ def_erb_method('hello', fname)
+ end
+ assert(klass.new.respond_to?('hello'))
+
+ assert(! klass.new.respond_to?('hello_world'))
+ erb = @erb.new('hello, world')
+ klass.module_eval do
+ def_erb_method('hello_world', erb)
+ end
+ assert(klass.new.respond_to?('hello_world'))
+ end
+
+ def test_escape
+ src = <<EOS
+1.<%% : <%="<%%"%>
+2.%%> : <%="%%>"%>
+3.
+% x = "foo"
+<%=x%>
+4.
+%% print "foo"
+5.
+%% <%="foo"%>
+6.<%="
+% print 'foo'
+"%>
+7.<%="
+%% print 'foo'
+"%>
+EOS
+ ans = <<EOS
+1.<% : <%%
+2.%%> : %>
+3.
+foo
+4.
+% print "foo"
+5.
+% foo
+6.
+% print 'foo'
+
+7.
+%% print 'foo'
+
+EOS
+ assert_equal(ans, ERB.new(src, nil, '%').result)
+ end
+
+ def test_keep_lineno
+ src = <<EOS
+Hello,
+% x = "World"
+<%= x%>
+% raise("lineno")
+EOS
+
+ erb = ERB.new(src, nil, '%')
+ begin
+ erb.result
+ assert(false)
+ rescue
+ assert_equal("(erb):4", $@[0].to_s)
+ end
+
+ src = <<EOS
+%>
+Hello,
+<% x = "World%%>
+"%>
+<%= x%>
+EOS
+
+ ans = <<EOS
+%>Hello,
+World%>
+EOS
+ assert_equal(ans, ERB.new(src, nil, '>').result)
+
+ ans = <<EOS
+%>
+Hello,
+
+World%>
+EOS
+ assert_equal(ans, ERB.new(src, nil, '<>').result)
+
+ ans = <<EOS
+%>
+Hello,
+
+World%>
+
+EOS
+ assert_equal(ans, ERB.new(src).result)
+
+ src = <<EOS
+Hello,
+<% x = "World%%>
+"%>
+<%= x%>
+<% raise("lineno") %>
+EOS
+
+ erb = ERB.new(src)
+ begin
+ erb.result
+ assert(false)
+ rescue
+ assert_equal("(erb):5", $@[0].to_s)
+ end
+
+ erb = ERB.new(src, nil, '>')
+ begin
+ erb.result
+ assert(false)
+ rescue
+ assert_equal("(erb):5", $@[0].to_s)
+ end
+
+ erb = ERB.new(src, nil, '<>')
+ begin
+ erb.result
+ assert(false)
+ rescue
+ assert_equal("(erb):5", $@[0].to_s)
+ end
+
+ src = <<EOS
+% y = 'Hello'
+<%- x = "World%%>
+"-%>
+<%= x %><%- x = nil -%>
+<% raise("lineno") %>
+EOS
+
+ erb = ERB.new(src, nil, '-')
+ begin
+ erb.result
+ assert(false)
+ rescue
+ assert_equal("(erb):5", $@[0].to_s)
+ end
+
+ erb = ERB.new(src, nil, '%-')
+ begin
+ erb.result
+ assert(false)
+ rescue
+ assert_equal("(erb):5", $@[0].to_s)
+ end
+ end
+
+ def test_explicit
+ src = <<EOS
+<% x = %w(hello world) -%>
+NotSkip <%- y = x -%> NotSkip
+<% x.each do |w| -%>
+ <%- up = w.upcase -%>
+ * <%= up %>
+<% end -%>
+ <%- z = nil -%> NotSkip <%- z = x %>
+ <%- z.each do |w| -%>
+ <%- down = w.downcase -%>
+ * <%= down %>
+ <%- up = w.upcase -%>
+ * <%= up %>
+ <%- end -%>
+KeepNewLine <%- z = nil -%>
+EOS
+
+ ans = <<EOS
+NotSkip NotSkip
+ * HELLO
+ * WORLD
+ NotSkip
+ * hello
+ * HELLO
+ * world
+ * WORLD
+KeepNewLine
+EOS
+ assert_equal(ans, ERB.new(src, nil, '-').result)
+ assert_equal(ans, ERB.new(src, nil, '-%').result)
+ end
+end
+
+class TestERBCoreWOStrScan < TestERBCore
+ def setup
+ @save_map = ERB::Compiler::Scanner.instance_variable_get('@scanner_map')
+ map = {[nil, false]=>ERB::Compiler::SimpleScanner}
+ ERB::Compiler::Scanner.instance_variable_set('@scanner_map', map)
+ super
+ end
+
+ def teardown
+ ERB::Compiler::Scanner.instance_variable_set('@scanner_map', @save_map)
end
end
diff --git a/test/fileutils/fileasserts.rb b/test/fileutils/fileasserts.rb
index 41469a6ac6..c2e9244a96 100644
--- a/test/fileutils/fileasserts.rb
+++ b/test/fileutils/fileasserts.rb
@@ -17,7 +17,7 @@ module Test
b = File.stat(to)
assert_equal a.mode, b.mode, "mode #{a.mode} != #{b.mode}"
#assert_equal a.atime, b.atime
- assert_equal_timestamp a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}"
+ assert_equal a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}"
assert_equal a.uid, b.uid, "uid #{a.uid} != #{b.uid}"
assert_equal a.gid, b.gid, "gid #{a.gid} != #{b.gid}"
end
@@ -62,39 +62,6 @@ module Test
}
end
- def assert_equal_time(expected, actual, message=nil)
- _wrap_assertion {
- expected_str = expected.to_s
- actual_str = actual.to_s
- if expected_str == actual_str
- expected_str << " (nsec=#{expected.nsec})"
- actual_str << " (nsec=#{actual.nsec})"
- end
- full_message = build_message(message, <<EOT)
-<#{expected_str}> expected but was
-<#{actual_str}>.
-EOT
- assert_block(full_message) { expected == actual }
- }
- end
-
- def assert_equal_timestamp(expected, actual, message=nil)
- _wrap_assertion {
- expected_str = expected.to_s
- actual_str = actual.to_s
- if expected_str == actual_str
- expected_str << " (nsec=#{expected.nsec})"
- actual_str << " (nsec=#{actual.nsec})"
- end
- full_message = build_message(message, <<EOT)
-<#{expected_str}> expected but was
-<#{actual_str}>.
-EOT
- # subsecond timestamp is not portable.
- assert_block(full_message) { expected.tv_sec == actual.tv_sec }
- }
- end
-
end
end
end
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index a52eb50071..cab51c9e8c 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -77,7 +77,7 @@ class TestFileUtils
include FileUtils
def check_singleton(name)
- assert_equal true, ::FileUtils.public_methods.include?(name.to_sym)
+ assert_equal true, ::FileUtils.public_methods.include?(name.to_s)
end
def my_rm_rf(path)
@@ -296,7 +296,10 @@ if have_symlink?
cp_r 'tmp/cpr_src2', 'tmp/cpr_dest2'
assert_directory 'tmp/cpr_dest2'
#assert_not_symlink 'tmp/cpr_dest2'
- assert_symlink 'tmp/cpr_dest2' # 2005-05-26: feature change
+ # * 2005-05-26: feature change on trunk
+ #assert_symlink 'tmp/cpr_dest2'
+ # * 2005-09-19: revert for 1.8 (:dereference_root => true by default)
+ assert_not_symlink 'tmp/cpr_dest2'
assert_symlink 'tmp/cpr_dest2/symlink'
assert_equal 'SLdest', File.readlink('tmp/cpr_dest2/symlink')
end
@@ -326,13 +329,14 @@ end
assert_same_file fname, 'tmp/mvdest'
end
+ # [ruby-talk:124368]
mkdir 'tmp/tmpdir'
mkdir_p 'tmp/dest2/tmpdir'
assert_raises(Errno::EEXIST) {
mv 'tmp/tmpdir', 'tmp/dest2'
}
mkdir 'tmp/dest2/tmpdir/junk'
- assert_raises(Errno::EEXIST, "[ruby-talk:124368]") {
+ assert_raises(Errno::EEXIST) {
mv 'tmp/tmpdir', 'tmp/dest2'
}
@@ -789,7 +793,7 @@ end
install 'tmp/aaa', 'tmp/bbb'
assert_equal "aaa\n", File.read('tmp/bbb')
assert_equal 0600, (File.stat('tmp/bbb').mode & 0777) if have_file_perm?
- assert_equal_time t, File.mtime('tmp/bbb')
+ assert_equal t, File.mtime('tmp/bbb')
File.unlink 'tmp/aaa'
File.unlink 'tmp/bbb'
diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb
index 96bb732e4e..5b25497211 100644
--- a/test/gdbm/test_gdbm.rb
+++ b/test/gdbm/test_gdbm.rb
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'tmpdir'
begin
require 'gdbm'
@@ -13,7 +12,7 @@ if defined? GDBM
class TestGDBM < Test::Unit::TestCase
def TestGDBM.uname_s
require 'rbconfig'
- case RbConfig::CONFIG['target_os']
+ case Config::CONFIG['target_os']
when 'cygwin'
require 'Win32API'
uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
@@ -22,22 +21,20 @@ if defined? GDBM
utsname.unpack('A20' * 5)[0]
else
- RbConfig::CONFIG['target_os']
+ Config::CONFIG['target_os']
end
end
SYSTEM = uname_s
def setup
- @tmpdir = Dir.mktmpdir("tmptest_gdbm")
- @prefix = "tmptest_gdbm_#{$$}"
- @path = "#{@tmpdir}/#{@prefix}_"
+ @path = "tmptest_gdbm_"
assert_instance_of(GDBM, @gdbm = GDBM.new(@path))
# prepare to make readonly GDBM file
- GDBM.open("#{@tmpdir}/#{@prefix}_rdonly", 0400) {|gdbm|
+ GDBM.open("tmptest_gdbm_rdonly", 0400) {|gdbm|
gdbm['foo'] = 'FOO'
}
- assert_instance_of(GDBM, @gdbm_rdonly = GDBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
+ assert_instance_of(GDBM, @gdbm_rdonly = GDBM.new("tmptest_gdbm_rdonly", nil))
end
def teardown
assert_nil(@gdbm.close)
@@ -45,7 +42,8 @@ if defined? GDBM
ObjectSpace.each_object(GDBM) do |obj|
obj.close unless obj.closed?
end
- FileUtils.remove_entry_secure @tmpdir
+ File.delete *Dir.glob("*tmptest_gdbm*").to_a
+ p Dir.glob("*tmptest_gdbm*") if $DEBUG
end
def check_size(expect, gdbm=@gdbm)
@@ -72,7 +70,7 @@ if defined? GDBM
def test_s_new_has_no_block
# GDBM.new ignore the block
foo = true
- assert_instance_of(GDBM, gdbm = GDBM.new("#{@tmpdir}/#{@prefix}") { foo = false })
+ assert_instance_of(GDBM, gdbm = GDBM.new("tmptest_gdbm") { foo = false })
assert_equal(foo, true)
assert_nil(gdbm.close)
end
@@ -81,54 +79,54 @@ if defined? GDBM
save_mask = File.umask(0)
begin
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}"))
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm"))
gdbm.close
- assert_equal(File.stat("#{@tmpdir}/#{@prefix}").mode & 0777, 0666)
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}2", 0644))
+ assert_equal(File.stat("tmptest_gdbm").mode & 0777, 0666)
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm2", 0644))
gdbm.close
- assert_equal(File.stat("#{@tmpdir}/#{@prefix}2").mode & 0777, 0644)
+ assert_equal(File.stat("tmptest_gdbm2").mode & 0777, 0644)
ensure
File.umask save_mask
end
end
def test_s_open_no_create
- # this test is failed on libgdbm 1.8.0
- assert_nil(gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", nil))
+ assert_nil(gdbm = GDBM.open("tmptest_gdbm", nil),
+ "this test is failed on libgdbm 1.8.0")
ensure
gdbm.close if gdbm
end
def test_s_open_3rd_arg
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
GDBM::FAST))
gdbm.close
# gdbm 1.8.0 specific
if defined? GDBM::SYNC
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
GDBM::SYNC))
gdbm.close
end
# gdbm 1.8.0 specific
if defined? GDBM::NOLOCK
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
GDBM::NOLOCK))
gdbm.close
end
end
def test_s_open_with_block
- assert_equal(GDBM.open("#{@tmpdir}/#{@prefix}") { :foo }, :foo)
+ assert_equal(GDBM.open("tmptest_gdbm") { :foo }, :foo)
end
def test_s_open_lock
return unless have_fork? # snip this test
pid = fork() {
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
sleep 2
}
begin
sleep 1
assert_raise(Errno::EWOULDBLOCK) {
begin
- assert_instance_of(GDBM, gdbm2 = GDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644))
rescue Errno::EAGAIN, Errno::EACCES
raise Errno::EWOULDBLOCK
end
@@ -142,10 +140,10 @@ if defined? GDBM
# Is it guaranteed on many OS?
def test_s_open_lock_one_process
# locking on one process
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
assert_raise(Errno::EWOULDBLOCK) {
begin
- GDBM.open("#{@tmpdir}/#{@prefix}", 0644)
+ GDBM.open("tmptest_gdbm", 0644)
rescue Errno::EAGAIN
raise Errno::EWOULDBLOCK
end
@@ -161,7 +159,7 @@ if defined? GDBM
return unless have_fork? # snip this test
pid = fork() {
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
GDBM::NOLOCK))
sleep 2
}
@@ -169,17 +167,17 @@ if defined? GDBM
begin
gdbm2 = nil
assert_nothing_raised(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
- assert_instance_of(GDBM, gdbm2 = GDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644))
}
ensure
Process.wait pid
gdbm2.close if gdbm2
end
- p Dir.glob("#{@tmpdir}/#{@prefix}*") if $DEBUG
+ p Dir.glob("tmptest_gdbm*") if $DEBUG
- pid = fork() {
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ pid = Process.fork() {
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
sleep 2
}
begin
@@ -187,7 +185,7 @@ if defined? GDBM
gdbm2 = nil
assert_nothing_raised(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
# this test is failed on Cygwin98 (???)
- assert_instance_of(GDBM, gdbm2 = GDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644,
GDBM::NOLOCK))
}
ensure
@@ -197,15 +195,16 @@ if defined? GDBM
end
def test_s_open_error
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0))
+ return if /(ms|bcc)win|mingw|djgpp/ =~ RUBY_PLATFORM
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0))
assert_raise(Errno::EACCES) {
- GDBM.open("#{@tmpdir}/#{@prefix}", 0)
+ GDBM.open("tmptest_gdbm", 0)
}
gdbm.close
end
def test_close
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}"))
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm"))
assert_nil(gdbm.close)
# closed GDBM file
@@ -594,10 +593,10 @@ if defined? GDBM
end
def test_sync
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0666, GDBM::FAST))
+ assert_instance_of(GDBM, gdbm = GDBM.open('tmptest_gdbm', 0666, GDBM::FAST))
assert_equal(gdbm.sync, gdbm)
gdbm.close
- assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0666))
+ assert_instance_of(GDBM, gdbm = GDBM.open('tmptest_gdbm', 0666))
assert_equal(gdbm.sync, gdbm)
gdbm.close
end
@@ -652,41 +651,19 @@ if defined? GDBM
end
class TestGDBM2 < Test::Unit::TestCase
+ TMPROOT = "#{Dir.tmpdir}/ruby-gdbm.#{$$}"
+
def setup
- @tmproot = Dir.mktmpdir('ruby-gdbm')
+ Dir.mkdir TMPROOT
end
def teardown
- FileUtils.remove_entry_secure @tmproot if File.directory?(@tmproot)
- end
-
- def test_reader_open_notexist
- assert_raise(Errno::ENOENT) {
- GDBM.open("#{@tmproot}/a", 0666, GDBM::READER)
- }
- end
-
- def test_writer_open_notexist
- assert_raise(Errno::ENOENT) {
- GDBM.open("#{@tmproot}/a", 0666, GDBM::WRITER)
- }
- end
-
- def test_wrcreat_open_notexist
- v = GDBM.open("#{@tmproot}/a", 0666, GDBM::WRCREAT)
- assert_instance_of(GDBM, v)
- v.close
- end
-
- def test_newdb_open_notexist
- v = GDBM.open("#{@tmproot}/a", 0666, GDBM::NEWDB)
- assert_instance_of(GDBM, v)
- v.close
+ FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
end
def test_reader_open
- GDBM.open("#{@tmproot}/a.dbm") {} # create a db.
- v = GDBM.open("#{@tmproot}/a.dbm", nil, GDBM::READER) {|d|
+ GDBM.open("#{TMPROOT}/a.dbm") {}
+ v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::READER) {|d|
assert_raises(GDBMError) { d["k"] = "v" }
true
}
@@ -694,10 +671,10 @@ if defined? GDBM
end
def test_newdb_open
- GDBM.open("#{@tmproot}/a.dbm") {|dbm|
+ GDBM.open("#{TMPROOT}/a.dbm") {|dbm|
dbm["k"] = "v"
}
- v = GDBM.open("#{@tmproot}/a.dbm", nil, GDBM::NEWDB) {|d|
+ v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::NEWDB) {|d|
assert_equal(0, d.length)
assert_nil(d["k"])
true
@@ -706,9 +683,9 @@ if defined? GDBM
end
def test_freeze
- GDBM.open("#{@tmproot}/a.dbm") {|d|
+ GDBM.open("#{TMPROOT}/a.dbm") {|d|
d.freeze
- assert_raises(RuntimeError) { d["k"] = "v" }
+ assert_raises(TypeError) { d["k"] = "v" }
}
end
end
diff --git a/test/iconv/test_basic.rb b/test/iconv/test_basic.rb
new file mode 100644
index 0000000000..ea564e91f1
--- /dev/null
+++ b/test/iconv/test_basic.rb
@@ -0,0 +1,49 @@
+require File.join(File.dirname(__FILE__), "utils.rb")
+
+class TestIconv::Basic < TestIconv
+ def test_euc2sjis
+ iconv = Iconv.open('SHIFT_JIS', 'EUC-JP')
+ str = iconv.iconv(EUCJ_STR)
+ str << iconv.iconv(nil)
+ assert_equal(SJIS_STR, str)
+ iconv.close
+ end
+
+ def test_close
+ iconv = Iconv.new('Shift_JIS', 'EUC-JP')
+ output = ""
+ begin
+ output += iconv.iconv(EUCJ_STR)
+ output += iconv.iconv(nil)
+ ensure
+ assert_respond_to(iconv, :close)
+ assert_equal("", iconv.close)
+ assert_equal(SJIS_STR, output)
+ end
+ end
+
+ def test_open_without_block
+ assert_respond_to(Iconv, :open)
+ iconv = Iconv.open('SHIFT_JIS', 'EUC-JP')
+ str = iconv.iconv(EUCJ_STR)
+ str << iconv.iconv(nil)
+ assert_equal(SJIS_STR, str )
+ iconv.close
+ end
+
+ def test_open_with_block
+ input = "#{EUCJ_STR}\n"*2
+ output = ""
+ Iconv.open("Shift_JIS", "EUC-JP") do |cd|
+ input.each_line do |s|
+ output << cd.iconv(s)
+ end
+ output << cd.iconv(nil)
+ end
+ assert_equal("#{SJIS_STR}\n"*2, output)
+ end
+
+ def test_unknown_encoding
+ assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") }
+ end
+end if defined?(TestIconv)
diff --git a/test/iconv/test_option.rb b/test/iconv/test_option.rb
new file mode 100644
index 0000000000..a1f3457c31
--- /dev/null
+++ b/test/iconv/test_option.rb
@@ -0,0 +1,31 @@
+require File.join(File.dirname(__FILE__), "utils.rb")
+
+class TestIconv::Option < TestIconv
+ def test_ignore_option
+ iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore')
+ str = iconv.iconv(EUCJ_STR)
+ str << iconv.iconv(nil)
+ assert_equal(SJIS_STR, str)
+ iconv.close
+
+ iconv = Iconv.new('SHIFT_JIS//IGNORE', 'EUC-JP//ignore')
+ str = iconv.iconv(EUCJ_STR)
+ str << iconv.iconv(nil)
+ assert_equal(SJIS_STR, str)
+ iconv.close
+ end
+
+ def test_translit_option
+ iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore')
+ str = iconv.iconv(EUCJ_STR)
+ str << iconv.iconv(nil)
+ assert_equal(SJIS_STR, str)
+ iconv.close
+
+ iconv = Iconv.new('SHIFT_JIS//TRANSLIT', 'EUC-JP//translit//ignore')
+ str = iconv.iconv(EUCJ_STR)
+ str << iconv.iconv(nil)
+ assert_equal(SJIS_STR, str)
+ iconv.close
+ end
+end if defined?(TestIconv)
diff --git a/test/iconv/test_partial.rb b/test/iconv/test_partial.rb
new file mode 100644
index 0000000000..aa4d0ba250
--- /dev/null
+++ b/test/iconv/test_partial.rb
@@ -0,0 +1,41 @@
+require File.join(File.dirname(__FILE__), "utils.rb")
+
+class TestIconv::Partial < TestIconv
+ def test_partial_ascii
+ c = Iconv.open(ASCII, ASCII)
+ ref = '[ruby-core:17092]'
+ rescue
+ return
+ else
+ assert_equal("abc", c.iconv("abc"))
+ assert_equal("c", c.iconv("abc", 2), "#{ref}: with start")
+ assert_equal("c", c.iconv("abc", 2, 1), "#{ref}: with start, length")
+ assert_equal("c", c.iconv("abc", 2, 5), "#{ref}: with start, longer length")
+ assert_equal("bc", c.iconv("abc", -2), "#{ref}: with nagative start")
+ assert_equal("b", c.iconv("abc", -2, 1), "#{ref}: with nagative start, length")
+ assert_equal("bc", c.iconv("abc", -2, 5), "#{ref}: with nagative start, longer length")
+ assert_equal("", c.iconv("abc", 5), "#{ref}: with OOB")
+ assert_equal("", c.iconv("abc", 5, 2), "#{ref}: with OOB, length")
+ ensure
+ c.close if c
+ end
+
+ def test_partial_euc2sjis
+ c = Iconv.open('SHIFT_JIS', 'EUC-JP')
+ rescue
+ return
+ else
+ assert_equal(SJIS_STR[0, 2], c.iconv(EUCJ_STR, 0, 2))
+ assert_equal(SJIS_STR, c.iconv(EUCJ_STR, 0, 20))
+ assert_equal(SJIS_STR[2..-1], c.iconv(EUCJ_STR, 2))
+ assert_equal(SJIS_STR[2, 2], c.iconv(EUCJ_STR, 2, 2))
+ assert_equal(SJIS_STR[2..-1], c.iconv(EUCJ_STR, 2, 20))
+ assert_equal(SJIS_STR[-4..-1], c.iconv(EUCJ_STR, -4))
+ assert_equal(SJIS_STR[-4, 2], c.iconv(EUCJ_STR, -4, 2))
+ assert_equal(SJIS_STR[-4..-1], c.iconv(EUCJ_STR, -4, 20))
+ assert_equal("", c.iconv(EUCJ_STR, 20))
+ assert_equal("", c.iconv(EUCJ_STR, 20, 2))
+ ensure
+ c.close
+ end
+end if defined?(TestIconv)
diff --git a/test/iconv/utils.rb b/test/iconv/utils.rb
new file mode 100644
index 0000000000..bc75deb173
--- /dev/null
+++ b/test/iconv/utils.rb
@@ -0,0 +1,26 @@
+begin
+ require 'iconv'
+rescue LoadError
+else
+ require 'test/unit'
+end
+
+class TestIconv < ::Test::Unit::TestCase
+ if defined?(::Encoding) and String.method_defined?(:force_encoding)
+ def self.encode(str, enc)
+ str.force_encoding(enc)
+ end
+ else
+ def self.encode(str, enc)
+ str
+ end
+ end
+
+ def default_test
+ self.class == TestIconv or super
+ end
+
+ ASCII = "ascii"
+ EUCJ_STR = encode("\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa", "EUC-JP").freeze
+ SJIS_STR = encode("\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8", "Shift_JIS").freeze
+end if defined?(::Iconv)
diff --git a/test/inlinetest.rb b/test/inlinetest.rb
deleted file mode 100644
index 6dbd793f10..0000000000
--- a/test/inlinetest.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-module InlineTest
- def eval_part(libname, sep, part)
- path = libpath(libname)
- program = File.open(path) { |f| f.read }
- mainpart, endpart = program.split(sep)
- if endpart.nil?
- raise RuntimeError.new("No #{part} part in the library '#{path}'")
- end
- eval(endpart, TOPLEVEL_BINDING, path, mainpart.count("\n")+1)
- end
- module_function :eval_part
-
- def loadtest(libname)
- require(libname)
- in_critical do
- in_progname(libpath(libname)) do
- eval_part(libname, /^(?=if\s+(?:\$0\s*==\s*__FILE__|__FILE__\s*==\s*\$0)(?:[\#\s]|$))/, '$0 == __FILE__')
- end
- end
- end
- module_function :loadtest
-
- def loadtest__END__part(libname)
- require(libname)
- eval_part(libname, /^__END__\r?$/, '__END__')
- end
- module_function :loadtest__END__part
-
- @mutex = Mutex.new
-
- def self.in_critical(&block)
- @mutex.synchronize(&block)
- end
-
- def self.in_progname(progname)
- progname_backup = $0.dup
- $0.replace(progname)
- begin
- yield
- ensure
- $0.replace(progname_backup)
- end
- end
-
- def self.libpath(libname)
- libpath = nil
- $:.find do |path|
- File.file?(testname = File.join(path, libname)) && libpath = testname
- end
- if libpath.nil?
- raise RuntimeError.new("'#{libname}' not found")
- end
- libpath
- end
-end
diff --git a/test/io/nonblock/test_flush.rb b/test/io/nonblock/test_flush.rb
index 34450f6fb9..2afbba300e 100644
--- a/test/io/nonblock/test_flush.rb
+++ b/test/io/nonblock/test_flush.rb
@@ -4,9 +4,8 @@ begin
rescue LoadError
end
-Thread.abort_on_exception = true
class TestIONonblock < Test::Unit::TestCase
- def test_flush
+ def test_flush # [ruby-dev:24985]
r,w = IO.pipe
w.nonblock = true
w.sync = false
@@ -23,8 +22,7 @@ class TestIONonblock < Test::Unit::TestCase
result << s
end
}
- w.flush # assert_raise(IOError, "[ruby-dev:24985]") {w.flush}
+ assert_raise(IOError) {w.flush}
assert_nothing_raised {t.join}
- assert_equal(4097, result.size)
end
end if IO.method_defined?(:nonblock)
diff --git a/test/json/fixtures/fail1.json b/test/json/fixtures/fail1.json
deleted file mode 100644
index 6216b865f1..0000000000
--- a/test/json/fixtures/fail1.json
+++ /dev/null
@@ -1 +0,0 @@
-"A JSON payload should be an object or array, not a string." \ No newline at end of file
diff --git a/test/json/fixtures/fail10.json b/test/json/fixtures/fail10.json
deleted file mode 100644
index 5d8c0047bd..0000000000
--- a/test/json/fixtures/fail10.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Extra value after close": true} "misplaced quoted value" \ No newline at end of file
diff --git a/test/json/fixtures/fail11.json b/test/json/fixtures/fail11.json
deleted file mode 100644
index 76eb95b458..0000000000
--- a/test/json/fixtures/fail11.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Illegal expression": 1 + 2} \ No newline at end of file
diff --git a/test/json/fixtures/fail12.json b/test/json/fixtures/fail12.json
deleted file mode 100644
index 77580a4522..0000000000
--- a/test/json/fixtures/fail12.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Illegal invocation": alert()} \ No newline at end of file
diff --git a/test/json/fixtures/fail13.json b/test/json/fixtures/fail13.json
deleted file mode 100644
index 379406b59b..0000000000
--- a/test/json/fixtures/fail13.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Numbers cannot have leading zeroes": 013} \ No newline at end of file
diff --git a/test/json/fixtures/fail14.json b/test/json/fixtures/fail14.json
deleted file mode 100644
index 0ed366b38a..0000000000
--- a/test/json/fixtures/fail14.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Numbers cannot be hex": 0x14} \ No newline at end of file
diff --git a/test/json/fixtures/fail18.json b/test/json/fixtures/fail18.json
deleted file mode 100644
index d61a345465..0000000000
--- a/test/json/fixtures/fail18.json
+++ /dev/null
@@ -1 +0,0 @@
-[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] // No, we don't limit our depth: Moved to pass...
diff --git a/test/json/fixtures/fail19.json b/test/json/fixtures/fail19.json
deleted file mode 100644
index 3b9c46fa9a..0000000000
--- a/test/json/fixtures/fail19.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Missing colon" null} \ No newline at end of file
diff --git a/test/json/fixtures/fail2.json b/test/json/fixtures/fail2.json
deleted file mode 100644
index 6b7c11e5a5..0000000000
--- a/test/json/fixtures/fail2.json
+++ /dev/null
@@ -1 +0,0 @@
-["Unclosed array" \ No newline at end of file
diff --git a/test/json/fixtures/fail20.json b/test/json/fixtures/fail20.json
deleted file mode 100644
index 27c1af3e72..0000000000
--- a/test/json/fixtures/fail20.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Double colon":: null} \ No newline at end of file
diff --git a/test/json/fixtures/fail21.json b/test/json/fixtures/fail21.json
deleted file mode 100644
index 62474573b2..0000000000
--- a/test/json/fixtures/fail21.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Comma instead of colon", null} \ No newline at end of file
diff --git a/test/json/fixtures/fail22.json b/test/json/fixtures/fail22.json
deleted file mode 100644
index a7752581bc..0000000000
--- a/test/json/fixtures/fail22.json
+++ /dev/null
@@ -1 +0,0 @@
-["Colon instead of comma": false] \ No newline at end of file
diff --git a/test/json/fixtures/fail23.json b/test/json/fixtures/fail23.json
deleted file mode 100644
index 494add1ca1..0000000000
--- a/test/json/fixtures/fail23.json
+++ /dev/null
@@ -1 +0,0 @@
-["Bad value", truth] \ No newline at end of file
diff --git a/test/json/fixtures/fail24.json b/test/json/fixtures/fail24.json
deleted file mode 100644
index caff239bfc..0000000000
--- a/test/json/fixtures/fail24.json
+++ /dev/null
@@ -1 +0,0 @@
-['single quote'] \ No newline at end of file
diff --git a/test/json/fixtures/fail25.json b/test/json/fixtures/fail25.json
deleted file mode 100644
index 2dfbd259ee..0000000000
--- a/test/json/fixtures/fail25.json
+++ /dev/null
@@ -1 +0,0 @@
-["tab character in string "]
diff --git a/test/json/fixtures/fail27.json b/test/json/fixtures/fail27.json
deleted file mode 100644
index 6b01a2ca4a..0000000000
--- a/test/json/fixtures/fail27.json
+++ /dev/null
@@ -1,2 +0,0 @@
-["line
-break"] \ No newline at end of file
diff --git a/test/json/fixtures/fail28.json b/test/json/fixtures/fail28.json
deleted file mode 100644
index 621a0101c6..0000000000
--- a/test/json/fixtures/fail28.json
+++ /dev/null
@@ -1,2 +0,0 @@
-["line\
-break"] \ No newline at end of file
diff --git a/test/json/fixtures/fail3.json b/test/json/fixtures/fail3.json
deleted file mode 100644
index 168c81eb78..0000000000
--- a/test/json/fixtures/fail3.json
+++ /dev/null
@@ -1 +0,0 @@
-{unquoted_key: "keys must be quoted"} \ No newline at end of file
diff --git a/test/json/fixtures/fail4.json b/test/json/fixtures/fail4.json
deleted file mode 100644
index 9de168bf34..0000000000
--- a/test/json/fixtures/fail4.json
+++ /dev/null
@@ -1 +0,0 @@
-["extra comma",] \ No newline at end of file
diff --git a/test/json/fixtures/fail5.json b/test/json/fixtures/fail5.json
deleted file mode 100644
index ddf3ce3d24..0000000000
--- a/test/json/fixtures/fail5.json
+++ /dev/null
@@ -1 +0,0 @@
-["double extra comma",,] \ No newline at end of file
diff --git a/test/json/fixtures/fail6.json b/test/json/fixtures/fail6.json
deleted file mode 100644
index ed91580e1b..0000000000
--- a/test/json/fixtures/fail6.json
+++ /dev/null
@@ -1 +0,0 @@
-[ , "<-- missing value"] \ No newline at end of file
diff --git a/test/json/fixtures/fail7.json b/test/json/fixtures/fail7.json
deleted file mode 100644
index 8a96af3e4e..0000000000
--- a/test/json/fixtures/fail7.json
+++ /dev/null
@@ -1 +0,0 @@
-["Comma after the close"], \ No newline at end of file
diff --git a/test/json/fixtures/fail8.json b/test/json/fixtures/fail8.json
deleted file mode 100644
index b28479c6ec..0000000000
--- a/test/json/fixtures/fail8.json
+++ /dev/null
@@ -1 +0,0 @@
-["Extra close"]] \ No newline at end of file
diff --git a/test/json/fixtures/fail9.json b/test/json/fixtures/fail9.json
deleted file mode 100644
index 5815574f36..0000000000
--- a/test/json/fixtures/fail9.json
+++ /dev/null
@@ -1 +0,0 @@
-{"Extra comma": true,} \ No newline at end of file
diff --git a/test/json/fixtures/pass1.json b/test/json/fixtures/pass1.json
deleted file mode 100644
index 7828fcc137..0000000000
--- a/test/json/fixtures/pass1.json
+++ /dev/null
@@ -1,56 +0,0 @@
-[
- "JSON Test Pattern pass1",
- {"object with 1 member":["array with 1 element"]},
- {},
- [],
- -42,
- true,
- false,
- null,
- {
- "integer": 1234567890,
- "real": -9876.543210,
- "e": 0.123456789e-12,
- "E": 1.234567890E+34,
- "": 23456789012E666,
- "zero": 0,
- "one": 1,
- "space": " ",
- "quote": "\"",
- "backslash": "\\",
- "controls": "\b\f\n\r\t",
- "slash": "/ & \/",
- "alpha": "abcdefghijklmnopqrstuvwyz",
- "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
- "digit": "0123456789",
- "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
- "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
- "true": true,
- "false": false,
- "null": null,
- "array":[ ],
- "object":{ },
- "address": "50 St. James Street",
- "url": "http://www.JSON.org/",
- "comment": "// /* <!-- --",
- "# -- --> */": " ",
- " s p a c e d " :[1,2 , 3
-
-,
-
-4 , 5 , 6 ,7 ],
- "compact": [1,2,3,4,5,6,7],
- "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
- "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
- "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
-: "A key can be any string"
- },
- 0.5 ,98.6
-,
-99.44
-,
-
-1066
-
-
-,"rosebud"] \ No newline at end of file
diff --git a/test/json/fixtures/pass15.json b/test/json/fixtures/pass15.json
deleted file mode 100644
index fc8376b605..0000000000
--- a/test/json/fixtures/pass15.json
+++ /dev/null
@@ -1 +0,0 @@
-["Illegal backslash escape: \x15"] \ No newline at end of file
diff --git a/test/json/fixtures/pass16.json b/test/json/fixtures/pass16.json
deleted file mode 100644
index c43ae3c286..0000000000
--- a/test/json/fixtures/pass16.json
+++ /dev/null
@@ -1 +0,0 @@
-["Illegal backslash escape: \'"] \ No newline at end of file
diff --git a/test/json/fixtures/pass17.json b/test/json/fixtures/pass17.json
deleted file mode 100644
index 62b9214aed..0000000000
--- a/test/json/fixtures/pass17.json
+++ /dev/null
@@ -1 +0,0 @@
-["Illegal backslash escape: \017"] \ No newline at end of file
diff --git a/test/json/fixtures/pass2.json b/test/json/fixtures/pass2.json
deleted file mode 100644
index d3c63c7ad8..0000000000
--- a/test/json/fixtures/pass2.json
+++ /dev/null
@@ -1 +0,0 @@
-[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] \ No newline at end of file
diff --git a/test/json/fixtures/pass26.json b/test/json/fixtures/pass26.json
deleted file mode 100644
index 845d26a6a5..0000000000
--- a/test/json/fixtures/pass26.json
+++ /dev/null
@@ -1 +0,0 @@
-["tab\ character\ in\ string\ "] \ No newline at end of file
diff --git a/test/json/fixtures/pass3.json b/test/json/fixtures/pass3.json
deleted file mode 100644
index 4528d51f1a..0000000000
--- a/test/json/fixtures/pass3.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "JSON Test Pattern pass3": {
- "The outermost value": "must be an object or array.",
- "In this test": "It is an object."
- }
-}
diff --git a/test/json/runner.rb b/test/json/runner.rb
deleted file mode 100755
index 91bc12a594..0000000000
--- a/test/json/runner.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit/ui/console/testrunner'
-require 'test/unit/testsuite'
-$:.unshift File.expand_path(File.dirname($0))
-$:.unshift 'tests'
-require 'test_json'
-require 'test_json_generate'
-require 'test_json_unicode'
-require 'test_json_addition'
-require 'test_json_rails'
-require 'test_json_fixtures'
-
-class TS_AllTests
- def self.suite
- suite = Test::Unit::TestSuite.new name
- suite << TC_JSONGenerate.suite
- suite << TC_JSON.suite
- suite << TC_JSONUnicode.suite
- suite << TC_JSONAddition.suite
- suite << TC_JSONRails.suite
- suite << TC_JSONFixtures.suite
- end
-end
-Test::Unit::UI::Console::TestRunner.run(TS_AllTests)
- # vim: set et sw=2 ts=2:
diff --git a/test/json/test_json.rb b/test/json/test_json.rb
deleted file mode 100755
index 2325c10063..0000000000
--- a/test/json/test_json.rb
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'json'
-
-class TC_JSON < Test::Unit::TestCase
- include JSON
-
- def setup
- @ary = [1, "foo", 3.14, 4711.0, 2.718, nil, [1,-2,3], false, true].map do
- |x| [x]
- end
- @ary_to_parse = ["1", '"foo"', "3.14", "4711.0", "2.718", "null",
- "[1,-2,3]", "false", "true"].map do
- |x| "[#{x}]"
- end
- @hash = {
- 'a' => 2,
- 'b' => 3.141,
- 'c' => 'c',
- 'd' => [ 1, "b", 3.14 ],
- 'e' => { 'foo' => 'bar' },
- 'g' => "\"\0\037",
- 'h' => 1000.0,
- 'i' => 0.001
- }
- @json = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},' +
- '"g":"\\"\\u0000\\u001f","h":1.0E3,"i":1.0E-3}'
- end
- suite << TC_JSON.suite
-
- def test_construction
- parser = JSON::Parser.new('test')
- assert_equal 'test', parser.source
- end
-
- def assert_equal_float(expected, is)
- assert_in_delta(expected.first, is.first, 1e-2)
- end
-
- def test_parse_simple_arrays
- assert_equal([], parse('[]'))
- assert_equal([], parse(' [ ] '))
- assert_equal([nil], parse('[null]'))
- assert_equal([false], parse('[false]'))
- assert_equal([true], parse('[true]'))
- assert_equal([-23], parse('[-23]'))
- assert_equal([23], parse('[23]'))
- assert_equal([0.23], parse('[0.23]'))
- assert_equal([0.0], parse('[0e0]'))
- assert_raises(JSON::ParserError) { parse('[+23.2]') }
- assert_raises(JSON::ParserError) { parse('[+23]') }
- assert_raises(JSON::ParserError) { parse('[.23]') }
- assert_raises(JSON::ParserError) { parse('[023]') }
- assert_equal_float [3.141], parse('[3.141]')
- assert_equal_float [-3.141], parse('[-3.141]')
- assert_equal_float [3.141], parse('[3141e-3]')
- assert_equal_float [3.141], parse('[3141.1e-3]')
- assert_equal_float [3.141], parse('[3141E-3]')
- assert_equal_float [3.141], parse('[3141.0E-3]')
- assert_equal_float [-3.141], parse('[-3141.0e-3]')
- assert_equal_float [-3.141], parse('[-3141e-3]')
- assert_equal([""], parse('[""]'))
- assert_equal(["foobar"], parse('["foobar"]'))
- assert_equal([{}], parse('[{}]'))
- end
-
- def test_parse_simple_objects
- assert_equal({}, parse('{}'))
- assert_equal({}, parse(' { } '))
- assert_equal({ "a" => nil }, parse('{ "a" : null}'))
- assert_equal({ "a" => nil }, parse('{"a":null}'))
- assert_equal({ "a" => false }, parse('{ "a" : false } '))
- assert_equal({ "a" => false }, parse('{"a":false}'))
- assert_raises(JSON::ParserError) { parse('{false}') }
- assert_equal({ "a" => true }, parse('{"a":true}'))
- assert_equal({ "a" => true }, parse(' { "a" : true } '))
- assert_equal({ "a" => -23 }, parse(' { "a" : -23 } '))
- assert_equal({ "a" => -23 }, parse(' { "a" : -23 } '))
- assert_equal({ "a" => 23 }, parse('{"a":23 } '))
- assert_equal({ "a" => 23 }, parse(' { "a" : 23 } '))
- assert_equal({ "a" => 0.23 }, parse(' { "a" : 0.23 } '))
- assert_equal({ "a" => 0.23 }, parse(' { "a" : 0.23 } '))
- end
-
- begin
- require 'permutation'
- def test_parse_more_complex_arrays
- a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
- perms = Permutation.for a
- perms.each do |perm|
- orig_ary = perm.project
- json = pretty_generate(orig_ary)
- assert_equal orig_ary, parse(json)
- end
- end
-
- def test_parse_complex_objects
- a = [ nil, false, true, "foßbar", [ "n€st€d", true ], { "nested" => true, "n€ßt€ð2" => {} }]
- perms = Permutation.for a
- perms.each do |perm|
- s = "a"
- orig_obj = perm.project.inject({}) { |h, x| h[s.dup] = x; s = s.succ; h }
- json = pretty_generate(orig_obj)
- assert_equal orig_obj, parse(json)
- end
- end
- rescue LoadError
- warn "Skipping permutation tests."
- end
-
- def test_parse_arrays
- assert_equal([1,2,3], parse('[1,2,3]'))
- assert_equal([1.2,2,3], parse('[1.2,2,3]'))
- assert_equal([[],[[],[]]], parse('[[],[[],[]]]'))
- end
-
- def test_parse_values
- assert_equal([""], parse('[""]'))
- assert_equal(["\\"], parse('["\\\\"]'))
- assert_equal(['"'], parse('["\""]'))
- assert_equal(['\\"\\'], parse('["\\\\\\"\\\\"]'))
- assert_equal(["\"\b\n\r\t\0\037"],
- parse('["\"\b\n\r\t\u0000\u001f"]'))
- for i in 0 ... @ary.size
- assert_equal(@ary[i], parse(@ary_to_parse[i]))
- end
- end
-
- def test_parse_array
- assert_equal([], parse('[]'))
- assert_equal([], parse(' [ ] '))
- assert_equal([1], parse('[1]'))
- assert_equal([1], parse(' [ 1 ] '))
- assert_equal(@ary,
- parse('[[1],["foo"],[3.14],[47.11e+2],[2718.0E-3],[null],[[1,-2,3]]'\
- ',[false],[true]]'))
- assert_equal(@ary, parse(%Q{ [ [1] , ["foo"] , [3.14] \t , [47.11e+2]
- , [2718.0E-3 ],\r[ null] , [[1, -2, 3 ]], [false ],[ true]\n ] }))
- end
-
- def test_parse_object
- assert_equal({}, parse('{}'))
- assert_equal({}, parse(' { } '))
- assert_equal({'foo'=>'bar'}, parse('{"foo":"bar"}'))
- assert_equal({'foo'=>'bar'}, parse(' { "foo" : "bar" } '))
- end
-
- def test_parser_reset
- parser = Parser.new(@json)
- assert_equal(@hash, parser.parse)
- assert_equal(@hash, parser.parse)
- end
-
- def test_comments
- json = <<EOT
-{
- "key1":"value1", // eol comment
- "key2":"value2" /* multi line
- * comment */,
- "key3":"value3" /* multi line
- // nested eol comment
- * comment */
-}
-EOT
- assert_equal(
- { "key1" => "value1", "key2" => "value2", "key3" => "value3" },
- parse(json))
- json = <<EOT
-{
- "key1":"value1" /* multi line
- // nested eol comment
- /* illegal nested multi line comment */
- * comment */
-}
-EOT
- assert_raises(ParserError) { parse(json) }
- json = <<EOT
-{
- "key1":"value1" /* multi line
- // nested eol comment
- closed multi comment */
- and again, throw an Error */
-}
-EOT
- assert_raises(ParserError) { parse(json) }
- json = <<EOT
-{
- "key1":"value1" /*/*/
-}
-EOT
- assert_equal({ "key1" => "value1" }, parse(json))
- end
-
- def test_backslash
- data = [ '\\.(?i:gif|jpe?g|png)$' ]
- json = '["\\\\.(?i:gif|jpe?g|png)$"]'
- assert_equal json, JSON.unparse(data)
- assert_equal data, JSON.parse(json)
- #
- data = [ '\\"' ]
- json = '["\\\\\""]'
- assert_equal json, JSON.unparse(data)
- assert_equal data, JSON.parse(json)
- #
- json = '["\/"]'
- data = JSON.parse(json)
- assert_equal ['/'], data
- assert_equal json, JSON.unparse(data)
- #
- json = '["\""]'
- data = JSON.parse(json)
- assert_equal ['"'], data
- assert_equal json, JSON.unparse(data)
- json = '["\\\'"]'
- data = JSON.parse(json)
- assert_equal ["'"], data
- assert_equal '["\'"]', JSON.unparse(data)
- end
-
- def test_wrong_inputs
- assert_raises(ParserError) { JSON.parse('"foo"') }
- assert_raises(ParserError) { JSON.parse('123') }
- assert_raises(ParserError) { JSON.parse('[] bla') }
- assert_raises(ParserError) { JSON.parse('[] 1') }
- assert_raises(ParserError) { JSON.parse('[] []') }
- assert_raises(ParserError) { JSON.parse('[] {}') }
- assert_raises(ParserError) { JSON.parse('{} []') }
- assert_raises(ParserError) { JSON.parse('{} {}') }
- assert_raises(ParserError) { JSON.parse('[NULL]') }
- assert_raises(ParserError) { JSON.parse('[FALSE]') }
- assert_raises(ParserError) { JSON.parse('[TRUE]') }
- assert_raises(ParserError) { JSON.parse('[07] ') }
- assert_raises(ParserError) { JSON.parse('[0a]') }
- assert_raises(ParserError) { JSON.parse('[1.]') }
- assert_raises(ParserError) { JSON.parse(' ') }
- end
-
- def test_nesting
- to_deep = '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]'
- assert_raises(JSON::NestingError) { JSON.parse to_deep }
- assert_raises(JSON::NestingError) { JSON.parser.new(to_deep).parse }
- assert_raises(JSON::NestingError) { JSON.parse to_deep, :max_nesting => 19 }
- ok = JSON.parse to_deep, :max_nesting => 20
- assert_kind_of Array, ok
- ok = JSON.parse to_deep, :max_nesting => nil
- assert_kind_of Array, ok
- ok = JSON.parse to_deep, :max_nesting => false
- assert_kind_of Array, ok
- ok = JSON.parse to_deep, :max_nesting => 0
- assert_kind_of Array, ok
- end
-end
- # vim: set et sw=2 ts=2:
diff --git a/test/json/test_json_addition.rb b/test/json/test_json_addition.rb
deleted file mode 100755
index 04c690ce31..0000000000
--- a/test/json/test_json_addition.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'json/add/core'
-require 'date'
-
-class TC_JSONAddition < Test::Unit::TestCase
- include JSON
-
- class A
- def initialize(a)
- @a = a
- end
-
- attr_reader :a
-
- def ==(other)
- a == other.a
- end
-
- def self.json_create(object)
- new(*object['args'])
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name,
- 'args' => [ @a ],
- }.to_json(*args)
- end
- end
-
- class B
- def to_json(*args)
- {
- 'json_class' => self.class.name,
- }.to_json(*args)
- end
- end
-
- class C
- def self.json_creatable?
- false
- end
-
- def to_json(*args)
- {
- 'json_class' => 'TC_JSONAddition::Nix',
- }.to_json(*args)
- end
- end
-
- def setup
- end
-
- def test_extended_json
- a = A.new(666)
- assert A.json_creatable?
- json = generate(a)
- a_again = JSON.parse(json)
- assert_kind_of a.class, a_again
- assert_equal a, a_again
- end
-
- def test_extended_json_disabled
- a = A.new(666)
- assert A.json_creatable?
- json = generate(a)
- a_again = JSON.parse(json, :create_additions => true)
- assert_kind_of a.class, a_again
- assert_equal a, a_again
- a_hash = JSON.parse(json, :create_additions => false)
- assert_kind_of Hash, a_hash
- assert_equal(
- {"args"=>[666], "json_class"=>"TC_JSONAddition::A"}.sort_by { |k,| k },
- a_hash.sort_by { |k,| k }
- )
- end
-
- def test_extended_json_fail
- b = B.new
- assert !B.json_creatable?
- json = generate(b)
- assert_equal({ 'json_class' => B.name }, JSON.parse(json))
- end
-
- def test_extended_json_fail
- c = C.new
- assert !C.json_creatable?
- json = generate(c)
- assert_raises(ArgumentError) { JSON.parse(json) }
- end
-
- def test_raw_strings
- raw = ''
- raw_array = []
- for i in 0..255
- raw << i
- raw_array << i
- end
- json = raw.to_json_raw
- json_raw_object = raw.to_json_raw_object
- hash = { 'json_class' => 'String', 'raw'=> raw_array }
- assert_equal hash, json_raw_object
- json_raw = <<EOT.chomp
-{\"json_class\":\"String\",\"raw\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]}
-EOT
-# "
- assert_equal json_raw, json
- raw_again = JSON.parse(json)
- assert_equal raw, raw_again
- end
-
- def test_core
- t = Time.at(1198254128, 895990)
- assert_equal t, JSON(JSON(t))
- d = Date.today
- assert_equal d, JSON(JSON(d))
- d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161)
- assert_equal d, JSON(JSON(d))
- assert_equal 1..10, JSON(JSON(1..10))
- assert_equal 1...10, JSON(JSON(1...10))
- assert_equal "a".."c", JSON(JSON("a".."c"))
- assert_equal "a"..."c", JSON(JSON("a"..."c"))
- struct = Struct.new 'MyJsonStruct', :foo, :bar
- s = struct.new 4711, 'foot'
- assert_equal s, JSON(JSON(s))
- struct = Struct.new :foo, :bar
- s = struct.new 4711, 'foot'
- assert_raises(JSONError) { JSON(s) }
- begin
- raise TypeError, "test me"
- rescue TypeError => e
- e_json = JSON.generate e
- e_again = JSON e_json
- assert_kind_of TypeError, e_again
- assert_equal e.message, e_again.message
- assert_equal e.backtrace, e_again.backtrace
- end
- assert_equal /foo/, JSON(JSON(/foo/))
- assert_equal /foo/i, JSON(JSON(/foo/i))
- end
-end
diff --git a/test/json/test_json_fixtures.rb b/test/json/test_json_fixtures.rb
deleted file mode 100755
index 33573cd300..0000000000
--- a/test/json/test_json_fixtures.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'json'
-
-class TC_JSONFixtures < Test::Unit::TestCase
- def setup
- fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json')
- passed, failed = Dir[fixtures].partition { |f| f['pass'] }
- @passed = passed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
- @failed = failed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
- end
-
- def test_passing
- for name, source in @passed
- assert JSON.parse(source),
- "Did not pass for fixture '#{name}'"
- end
- end
-
- def test_failing
- for name, source in @failed
- assert_raises(JSON::ParserError, JSON::NestingError,
- "Did not fail for fixture '#{name}'") do
- JSON.parse(source)
- end
- end
- end
-end
diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb
deleted file mode 100644
index e720b2d862..0000000000
--- a/test/json/test_json_generate.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'test/unit'
-require 'json'
-
-class TC_JSONGenerate < Test::Unit::TestCase
- include JSON
-
- def setup
- @hash = {
- 'a' => 2,
- 'b' => 3.141,
- 'c' => 'c',
- 'd' => [ 1, "b", 3.14 ],
- 'e' => { 'foo' => 'bar' },
- 'g' => "\"\0\037",
- 'h' => 1000.0,
- 'i' => 0.001
- }
- @json2 = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},' +
- '"g":"\\"\\u0000\\u001f","h":1000.0,"i":0.001}'
- @json3 = <<'EOT'.chomp
-{
- "a": 2,
- "b": 3.141,
- "c": "c",
- "d": [
- 1,
- "b",
- 3.14
- ],
- "e": {
- "foo": "bar"
- },
- "g": "\"\u0000\u001f",
- "h": 1000.0,
- "i": 0.001
-}
-EOT
- end
-
- def test_unparse
- json = unparse(@hash)
- assert_equal(JSON.parse(@json2), JSON.parse(json))
- parsed_json = parse(json)
- assert_equal(@hash, parsed_json)
- json = generate({1=>2})
- assert_equal('{"1":2}', json)
- parsed_json = parse(json)
- assert_equal({"1"=>2}, parsed_json)
- end
-
- def test_unparse_pretty
- json = pretty_unparse(@hash)
- assert_equal(JSON.parse(@json3), JSON.parse(json))
- parsed_json = parse(json)
- assert_equal(@hash, parsed_json)
- json = pretty_generate({1=>2})
- assert_equal(<<'EOT'.chomp, json)
-{
- "1": 2
-}
-EOT
- parsed_json = parse(json)
- assert_equal({"1"=>2}, parsed_json)
- end
-
- def test_states
- json = generate({1=>2}, nil)
- assert_equal('{"1":2}', json)
- s = JSON.state.new(:check_circular => true)
- #assert s.check_circular
- h = { 1=>2 }
- h[3] = h
- assert_raises(JSON::CircularDatastructure) { generate(h, s) }
- s = JSON.state.new(:check_circular => true)
- #assert s.check_circular
- a = [ 1, 2 ]
- a << a
- assert_raises(JSON::CircularDatastructure) { generate(a, s) }
- end
-end
diff --git a/test/json/test_json_rails.rb b/test/json/test_json_rails.rb
deleted file mode 100644
index e44ea606e3..0000000000
--- a/test/json/test_json_rails.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'json/add/rails'
-require 'date'
-
-class TC_JSONRails < Test::Unit::TestCase
- include JSON
-
- class A
- def initialize(a)
- @a = a
- end
-
- attr_reader :a
-
- def ==(other)
- a == other.a
- end
-
- def self.json_create(object)
- new(*object['args'])
- end
-
- def to_json(*args)
- {
- 'json_class' => self.class.name,
- 'args' => [ @a ],
- }.to_json(*args)
- end
- end
-
- class B
- def to_json(*args)
- {
- 'json_class' => self.class.name,
- }.to_json(*args)
- end
- end
-
- class C
- def to_json(*args)
- {
- 'json_class' => 'TC_JSONRails::Nix',
- }.to_json(*args)
- end
- end
-
- def setup
- end
-
- def test_extended_json
- a = A.new(666)
- assert A.json_creatable?
- json = generate(a)
- a_again = JSON.parse(json)
- assert_kind_of a.class, a_again
- assert_equal a, a_again
- end
-
- def test_extended_json_disabled
- a = A.new(666)
- assert A.json_creatable?
- json = generate(a)
- a_again = JSON.parse(json, :create_additions => true)
- assert_kind_of a.class, a_again
- assert_equal a, a_again
- a_hash = JSON.parse(json, :create_additions => false)
- assert_kind_of Hash, a_hash
- assert_equal(
- {"args"=>[666], "json_class"=>"TC_JSONRails::A"}.sort_by { |k,| k },
- a_hash.sort_by { |k,| k }
- )
- end
-
- def test_extended_json_fail
- b = B.new
- assert !B.json_creatable?
- json = generate(b)
- assert_equal({ 'json_class' => B.name }, JSON.parse(json))
- end
-
- def test_extended_json_fail
- c = C.new # with rails addition all objects are theoretically creatable
- assert C.json_creatable?
- json = generate(c)
- assert_raises(ArgumentError) { JSON.parse(json) }
- end
-
- def test_raw_strings
- raw = ''
- raw_array = []
- for i in 0..255
- raw << i
- raw_array << i
- end
- json = raw.to_json_raw
- json_raw_object = raw.to_json_raw_object
- hash = { 'json_class' => 'String', 'raw'=> raw_array }
- assert_equal hash, json_raw_object
- json_raw = <<EOT.chomp
-{\"json_class\":\"String\",\"raw\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255]}
-EOT
-# "
- assert_equal json_raw, json
- raw_again = JSON.parse(json)
- assert_equal raw, raw_again
- end
-
- def test_symbol
- assert_equal '"foo"', JSON(:foo) # we don't want an object here
- end
-end
diff --git a/test/json/test_json_unicode.rb b/test/json/test_json_unicode.rb
deleted file mode 100755
index 9e0d762f6d..0000000000
--- a/test/json/test_json_unicode.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'test/unit'
-require 'json'
-
-class TC_JSONUnicode < Test::Unit::TestCase
- include JSON
-
- def setup
- end
-
- def test_unicode
- assert_equal '""', ''.to_json
- assert_equal '"\\b"', "\b".to_json
- assert_equal '"\u0001"', 0x1.chr.to_json
- assert_equal '"\u001f"', 0x1f.chr.to_json
- assert_equal '" "', ' '.to_json
- assert_equal "\"#{0x7f.chr}\"", 0x7f.chr.to_json
- utf8 = [ "© ≠ €! \01" ]
- json = '["\u00a9 \u2260 \u20ac! \u0001"]'
- assert_equal json, utf8.to_json
- assert_equal utf8, parse(json)
- utf8 = ["\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212"]
- json = "[\"\\u3042\\u3044\\u3046\\u3048\\u304a\"]"
- assert_equal json, utf8.to_json
- assert_equal utf8, parse(json)
- utf8 = ['სáƒáƒ¥áƒáƒ áƒ—ველáƒ']
- json = "[\"\\u10e1\\u10d0\\u10e5\\u10d0\\u10e0\\u10d7\\u10d5\\u10d4\\u10da\\u10dd\"]"
- assert_equal json, utf8.to_json
- assert_equal utf8, parse(json)
- assert_equal '["\\u00c3"]', JSON.generate(["Ã"])
- assert_equal ["€"], JSON.parse('["\u20ac"]')
- utf8 = ["\xf0\xa0\x80\x81"]
- json = '["\ud840\udc01"]'
- assert_equal json, JSON.generate(utf8)
- assert_equal utf8, JSON.parse(json)
- end
-
- def test_chars
- (0..0x7f).each do |i|
- json = '["\u%04x"]' % i
- if RUBY_VERSION >= "1.9."
- i = i.chr
- end
- assert_equal i, JSON.parse(json).first[0]
- if i == ?\b
- generated = JSON.generate(["" << i])
- assert '["\b"]' == generated || '["\10"]' == generated
- elsif [?\n, ?\r, ?\t, ?\f].include?(i)
- assert_equal '[' << ('' << i).dump << ']', JSON.generate(["" << i])
- elsif i.chr < 0x20.chr
- assert_equal json, JSON.generate(["" << i])
- end
- end
- assert_raises(JSON::GeneratorError) do
- JSON.generate(["" << 0x80])
- end
- assert_equal "\302\200", JSON.parse('["\u0080"]').first
- end
-end
diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb
index e69638b5ee..ab578a1b81 100644
--- a/test/logger/test_logger.rb
+++ b/test/logger/test_logger.rb
@@ -6,7 +6,7 @@ require 'tempfile'
class TestLoggerSeverity < Test::Unit::TestCase
def test_enum
logger_levels = Logger.constants
- levels = [:WARN, :UNKNOWN, :INFO, :FATAL, :DEBUG, :ERROR]
+ levels = ["WARN", "UNKNOWN", "INFO", "FATAL", "DEBUG", "ERROR"]
Logger::Severity.constants.each do |level|
assert(levels.include?(level))
assert(logger_levels.include?(level))
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb
index 064471eecb..b539cb3cca 100644
--- a/test/monitor/test_monitor.rb
+++ b/test/monitor/test_monitor.rb
@@ -94,9 +94,7 @@ class TestMonitor < Test::Unit::TestCase
assert_equal(true, result1)
assert_equal("bar", a)
end
- end
- def _test_timedwait
b = "foo"
queue2 = Queue.new
Thread.start do
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
deleted file mode 100644
index 97eed02b07..0000000000
--- a/test/net/http/test_http.rb
+++ /dev/null
@@ -1,319 +0,0 @@
-# $Id$
-
-require 'test/unit'
-require 'net/http'
-require 'stringio'
-require File.expand_path("utils", File.dirname(__FILE__))
-
-module TestNetHTTP_version_1_1_methods
-
- def test_s_get
- assert_equal $test_net_http_data,
- Net::HTTP.get(config('host'), '/', config('port'))
- end
-
- def test_head
- start {|http|
- res = http.head('/')
- assert_kind_of Net::HTTPResponse, res
- assert_equal $test_net_http_data_type, res['Content-Type']
- assert_equal $test_net_http_data.size, res['Content-Length'].to_i
- }
- end
-
- def test_get
- start {|http|
- _test_get__get http
- _test_get__iter http
- _test_get__chunked http
- }
- end
-
- def _test_get__get(http)
- res, body = http.get('/')
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, res.body
- assert_kind_of String, body
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- assert_equal $test_net_http_data_type, res['Content-Type']
- assert_equal $test_net_http_data.size, body.size
- assert_equal $test_net_http_data, body
- assert_equal $test_net_http_data.size, res.body.size
- assert_equal $test_net_http_data, res.body
- end
-
- def _test_get__iter(http)
- buf = ''
- res, body = http.get('/') {|s| buf << s }
- assert_kind_of Net::HTTPResponse, res
- # assert_kind_of String, res.body
- # assert_kind_of String, body
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- assert_equal $test_net_http_data_type, res['Content-Type']
- assert_equal $test_net_http_data.size, buf.size
- assert_equal $test_net_http_data, buf
- # assert_equal $test_net_http_data.size, res.body.size
- # assert_equal $test_net_http_data, res.body
- end
-
- def _test_get__chunked(http)
- buf = ''
- res, body = http.get('/') {|s| buf << s }
- assert_kind_of Net::HTTPResponse, res
- # assert_kind_of String, res.body
- # assert_kind_of String, body
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- assert_equal $test_net_http_data_type, res['Content-Type']
- assert_equal $test_net_http_data.size, buf.size
- assert_equal $test_net_http_data, buf
- # assert_equal $test_net_http_data.size, res.body.size
- # assert_equal $test_net_http_data, res.body
- end
-
- def test_get__break
- i = 0
- start {|http|
- http.get('/') do |str|
- i += 1
- break
- end
- }
- assert_equal 1, i
- end
-
- def test_get__implicit_start
- res, body = new().get('/')
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, body
- assert_kind_of String, res.body
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data_type, res['Content-Type']
- assert_equal $test_net_http_data.size, res.body.size
- assert_equal $test_net_http_data, res.body
- end
-
- def test_get2
- start {|http|
- http.get2('/') {|res|
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of Net::HTTPResponse, res.header
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data_type, res['Content-Type']
- assert_kind_of String, res.body
- assert_kind_of String, res.entity
- assert_equal $test_net_http_data.size, res.body.size
- assert_equal $test_net_http_data, res.body
- assert_equal $test_net_http_data, res.entity
- }
- }
- end
-
- def test_post
- start {|http|
- _test_post__base http
- _test_post__file http
- }
- end
-
- def _test_post__base(http)
- uheader = {}
- uheader['Accept'] = 'application/octet-stream'
- data = 'post data'
- res, body = http.post('/', data)
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, body
- assert_kind_of String, res.body
- assert_equal data, body
- assert_equal data, res.body
- assert_equal data, res.entity
- end
-
- def _test_post__file(http)
- data = 'post data'
- f = StringIO.new
- http.post('/', data, nil, f)
- assert_equal data, f.string
- end
-
- def test_s_post_form
- res = Net::HTTP.post_form(
- URI.parse("http://#{config('host')}:#{config('port')}/"),
- "a" => "x")
- assert_equal ["a=x"], res.body.split(/[;&]/).sort
-
- res = Net::HTTP.post_form(
- URI.parse("http://#{config('host')}:#{config('port')}/"),
- "a" => "x",
- "b" => "y")
- assert_equal ["a=x", "b=y"], res.body.split(/[;&]/).sort
-
- res = Net::HTTP.post_form(
- URI.parse("http://#{config('host')}:#{config('port')}/"),
- "a" => ["x1", "x2"],
- "b" => "y")
- assert_equal ["a=x1", "a=x2", "b=y"], res.body.split(/[;&]/).sort
- end
-
-end
-
-
-module TestNetHTTP_version_1_2_methods
-
- def test_request
- start {|http|
- _test_request__GET http
- _test_request__file http
- # _test_request__range http # WEBrick does not support Range: header.
- _test_request__HEAD http
- _test_request__POST http
- _test_request__stream_body http
- }
- end
-
- def _test_request__GET(http)
- req = Net::HTTP::Get.new('/')
- http.request(req) {|res|
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, res.body
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- assert_equal $test_net_http_data.size, res.body.size
- assert_equal $test_net_http_data, res.body
- }
- end
-
- def _test_request__file(http)
- req = Net::HTTP::Get.new('/')
- http.request(req) {|res|
- assert_kind_of Net::HTTPResponse, res
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- f = StringIO.new
- res.read_body f
- assert_equal $test_net_http_data.size, f.string.size
- assert_equal $test_net_http_data, f.string
- }
- end
-
- def _test_request__range(http)
- req = Net::HTTP::Get.new('/')
- req['range'] = 'bytes=0-5'
- assert_equal $test_net_http_data[0,6], http.request(req).body
- end
-
- def _test_request__HEAD(http)
- req = Net::HTTP::Head.new('/')
- http.request(req) {|res|
- assert_kind_of Net::HTTPResponse, res
- assert_not_nil res['content-length']
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- assert_nil res.body
- }
- end
-
- def _test_request__POST(http)
- data = 'post data'
- req = Net::HTTP::Post.new('/')
- req['Accept'] = $test_net_http_data_type
- http.request(req, data) {|res|
- assert_kind_of Net::HTTPResponse, res
- assert_equal data.size, res['content-length'].to_i
- assert_kind_of String, res.body
- assert_equal data, res.body
- }
- end
-
- def _test_request__stream_body(http)
- req = Net::HTTP::Post.new('/')
- data = $test_net_http_data
- req.content_length = data.size
- req.body_stream = StringIO.new(data)
- res = http.request(req)
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, res.body
- assert_equal data.size, res.body.size
- assert_equal data, res.body
- end
-
- def test_send_request
- start {|http|
- _test_send_request__GET http
- _test_send_request__POST http
- }
- end
-
- def _test_send_request__GET(http)
- res = http.send_request('GET', '/')
- assert_kind_of Net::HTTPResponse, res
- assert_equal $test_net_http_data.size, res['content-length'].to_i
- assert_kind_of String, res.body
- assert_equal $test_net_http_data, res.body
- end
-
- def _test_send_request__POST(http)
- data = 'aaabbb cc ddddddddddd lkjoiu4j3qlkuoa'
- res = http.send_request('POST', '/', data)
- assert_kind_of Net::HTTPResponse, res
- assert_kind_of String, res.body
- assert_equal data.size, res.body.size
- assert_equal data, res.body
- end
-end
-
-class TestNetHTTP_version_1_1 < Test::Unit::TestCase
- CONFIG = {
- 'host' => '127.0.0.1',
- 'port' => 10081,
- 'proxy_host' => nil,
- 'proxy_port' => nil,
- }
-
- include TestNetHTTPUtils
- include TestNetHTTP_version_1_1_methods
-
- def new
- Net::HTTP.version_1_1
- super
- end
-end
-
-class TestNetHTTP_v1_2 < Test::Unit::TestCase
- CONFIG = {
- 'host' => '127.0.0.1',
- 'port' => 10081,
- 'proxy_host' => nil,
- 'proxy_port' => nil,
- }
-
- include TestNetHTTPUtils
- include TestNetHTTP_version_1_1_methods
- include TestNetHTTP_version_1_2_methods
-
- def new
- Net::HTTP.version_1_2
- super
- end
-end
-
-=begin
-class TestNetHTTP_proxy < Test::Unit::TestCase
- CONFIG = {
- 'host' => '127.0.0.1',
- 'port' => 10081,
- 'proxy_host' => '127.0.0.1',
- 'proxy_port' => 10082,
- }
-
- include TestNetHTTPUtils
- include TestNetHTTP_version_1_1_methods
- include TestNetHTTP_version_1_2_methods
-
- def new
- Net::HTTP.version_1_2
- super
- end
-end
-=end
diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb
deleted file mode 100644
index adb50c58fb..0000000000
--- a/test/net/http/test_https.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require "test/unit"
-begin
- require 'net/https'
- require 'stringio'
- require File.expand_path("../../openssl/utils", File.dirname(__FILE__))
- require File.expand_path("utils", File.dirname(__FILE__))
-rescue LoadError
- # should skip this test
-end
-
-class TestNetHTTPS < Test::Unit::TestCase
- include TestNetHTTPUtils
-
- subject = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=localhost")
- exts = [
- ["keyUsage", "keyEncipherment,digitalSignature", true],
- ]
- key = OpenSSL::TestUtils::TEST_KEY_RSA1024
- cert = OpenSSL::TestUtils.issue_cert(
- subject, key, 1, Time.now, Time.now + 3600, exts,
- nil, nil, OpenSSL::Digest::SHA1.new
- )
-
- CONFIG = {
- 'host' => '127.0.0.1',
- 'port' => 10081,
- 'proxy_host' => nil,
- 'proxy_port' => nil,
- 'ssl_enable' => true,
- 'ssl_certificate' => cert,
- 'ssl_private_key' => key,
- }
-
- def test_get
- http = Net::HTTP.new("localhost", config("port"))
- http.use_ssl = true
- http.verify_callback = Proc.new do |preverify_ok, store_ctx|
- store_ctx.current_cert.to_der == config('ssl_certificate').to_der
- end
- http.request_get("/") {|res|
- assert_equal($test_net_http_data, res.body)
- }
- end
-
- def test_post
- http = Net::HTTP.new("localhost", config("port"))
- http.use_ssl = true
- http.verify_callback = Proc.new do |preverify_ok, store_ctx|
- store_ctx.current_cert.to_der == config('ssl_certificate').to_der
- end
- data = config('ssl_private_key').to_der
- http.request_post("/", data) {|res|
- assert_equal(data, res.body)
- }
- end
-
- if ENV["RUBY_OPENSSL_TEST_ALL"]
- def test_verify
- http = Net::HTTP.new("ssl.netlab.jp", 443)
- http.use_ssl = true
- assert(
- (http.request_head("/"){|res| } rescue false),
- "The system may not have default CA certificate store."
- )
- end
- end
-
- def test_verify_none
- http = Net::HTTP.new("localhost", config("port"))
- http.use_ssl = true
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
- http.request_get("/") {|res|
- assert_equal($test_net_http_data, res.body)
- }
- end
-
- def test_certificate_verify_failure
- http = Net::HTTP.new("localhost", config("port"))
- http.use_ssl = true
- ex = assert_raise(OpenSSL::SSL::SSLError){
- http.request_get("/") {|res| }
- }
- assert_match(/certificate verify failed/, ex.message)
- end
-
- def test_identity_verify_failure
- http = Net::HTTP.new("127.0.0.1", config("port"))
- http.use_ssl = true
- http.verify_callback = Proc.new do |preverify_ok, store_ctx|
- store_ctx.current_cert.to_der == config('ssl_certificate').to_der
- end
- ex = assert_raise(OpenSSL::SSL::SSLError){
- http.request_get("/") {|res| }
- }
- assert_match(/hostname was not match/, ex.message)
- end
-end if defined?(OpenSSL)
diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb
deleted file mode 100644
index 766bf71c46..0000000000
--- a/test/net/http/utils.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require 'webrick'
-begin
- require "webrick/https"
-rescue LoadError
- # SSL features cannot be tested
-end
-require 'webrick/httpservlet/abstract'
-
-module TestNetHTTPUtils
- def start(&block)
- new().start(&block)
- end
-
- def new
- klass = Net::HTTP::Proxy(config('proxy_host'), config('proxy_port'))
- http = klass.new(config('host'), config('port'))
- http.set_debug_output logfile()
- http
- end
-
- def config(key)
- self.class::CONFIG[key]
- end
-
- def logfile
- $DEBUG ? $stderr : NullWriter.new
- end
-
- def setup
- spawn_server
- end
-
- def teardown
- @server.shutdown
- until @server.status == :Stop
- sleep 0.1
- end
- # resume global state
- Net::HTTP.version_1_2
- end
-
- def spawn_server
- server_config = {
- :BindAddress => config('host'),
- :Port => config('port'),
- :Logger => WEBrick::Log.new(NullWriter.new),
- :AccessLog => [],
- :ShutdownSocketWithoutClose => true,
- :ServerType => Thread,
- }
- if defined?(OpenSSL) and config('ssl_enable')
- server_config.update({
- :SSLEnable => true,
- :SSLCertificate => config('ssl_certificate'),
- :SSLPrivateKey => config('ssl_private_key'),
- })
- end
- @server = WEBrick::HTTPServer.new(server_config)
- @server.mount('/', Servlet)
- @server.start
- n_try_max = 5
- begin
- TCPSocket.open(config('host'), config('port')).close
- rescue Errno::ECONNREFUSED
- sleep 0.2
- n_try_max -= 1
- raise 'cannot spawn server; give up' if n_try_max < 0
- retry
- end
- end
-
- $test_net_http = nil
- $test_net_http_data = (0...256).to_a.map {|i| i.chr }.join('') * 64
- $test_net_http_data_type = 'application/octet-stream'
-
- class Servlet < WEBrick::HTTPServlet::AbstractServlet
- def do_GET(req, res)
- res['Content-Type'] = $test_net_http_data_type
- res.body = $test_net_http_data
- end
-
- # echo server
- def do_POST(req, res)
- res['Content-Type'] = req['Content-Type']
- res.body = req.body
- end
- end
-
- class NullWriter
- def <<(s) end
- def puts(*args) end
- def print(*args) end
- def printf(*args) end
- end
-end
diff --git a/test/net/imap/cacert.pem b/test/net/imap/cacert.pem
deleted file mode 100644
index 8a48e07a90..0000000000
--- a/test/net/imap/cacert.pem
+++ /dev/null
@@ -1,62 +0,0 @@
-Certificate:
- Data:
- Version: 3 (0x2)
- Serial Number:
- d2:9c:5c:81:a3:b0:3b:ec
- Signature Algorithm: sha1WithRSAEncryption
- Issuer: C=JP, ST=Shimane, O=Ruby Core Team, CN=Ruby Test CA
- Validity
- Not Before: Dec 22 08:35:19 2007 GMT
- Not After : Dec 21 08:35:19 2010 GMT
- Subject: C=JP, ST=Shimane, O=Ruby Core Team, CN=Ruby Test CA
- Subject Public Key Info:
- Public Key Algorithm: rsaEncryption
- RSA Public Key: (1024 bit)
- Modulus (1024 bit):
- 00:ee:b1:1a:06:25:1f:29:80:a1:59:ef:0f:0d:8b:
- 5a:88:40:73:56:95:d9:db:b4:71:3c:36:7f:b4:fc:
- 68:51:54:8b:8d:9e:41:27:fb:31:d1:7a:6c:5c:21:
- 30:3d:22:f6:7a:92:c3:fa:b3:85:36:44:76:22:6c:
- 08:82:78:89:7d:c3:19:d4:ec:7d:05:5b:75:cd:38:
- 1c:89:03:ef:02:aa:7e:6d:5b:36:ea:ad:e2:0b:ec:
- 4b:e2:36:bf:c0:49:44:93:a6:cc:da:40:be:5f:c0:
- 75:3b:be:c0:28:db:42:57:90:3b:83:af:2d:60:9a:
- c6:b1:bc:5c:68:12:2d:70:25
- Exponent: 65537 (0x10001)
- X509v3 extensions:
- X509v3 Subject Key Identifier:
- AE:F5:39:FE:D2:35:A2:2C:1E:CB:0E:08:4C:0E:5A:DC:44:99:E2:9C
- X509v3 Authority Key Identifier:
- keyid:AE:F5:39:FE:D2:35:A2:2C:1E:CB:0E:08:4C:0E:5A:DC:44:99:E2:9C
- DirName:/C=JP/ST=Shimane/O=Ruby Core Team/CN=Ruby Test CA
- serial:D2:9C:5C:81:A3:B0:3B:EC
-
- X509v3 Basic Constraints:
- CA:TRUE
- Signature Algorithm: sha1WithRSAEncryption
- 9e:28:89:81:83:55:1b:38:cb:85:86:ec:ee:cc:f4:cf:f0:47:
- 61:72:07:f2:2e:ca:67:f7:c8:29:b5:3c:34:d2:cf:c2:f7:9c:
- 4d:ce:8d:37:24:57:85:c1:0e:27:86:81:15:99:ec:af:05:ae:
- 09:96:f6:f7:5a:c0:d2:a4:82:ed:d6:d3:26:e9:3d:50:50:0c:
- 71:c2:6e:9a:50:30:73:8a:94:0d:c1:9c:1a:da:76:80:b8:8b:
- 46:ec:10:93:6c:8d:cb:ab:eb:12:5d:e0:6f:1a:5a:ac:5c:34:
- 12:df:7b:a7:dc:b6:0f:d6:3e:ac:2f:69:db:11:aa:1d:c4:90:
- f6:fa
------BEGIN CERTIFICATE-----
-MIICzjCCAjegAwIBAgIJANKcXIGjsDvsMA0GCSqGSIb3DQEBBQUAME8xCzAJBgNV
-BAYTAkpQMRAwDgYDVQQIEwdTaGltYW5lMRcwFQYDVQQKEw5SdWJ5IENvcmUgVGVh
-bTEVMBMGA1UEAxMMUnVieSBUZXN0IENBMB4XDTA3MTIyMjA4MzUxOVoXDTEwMTIy
-MTA4MzUxOVowTzELMAkGA1UEBhMCSlAxEDAOBgNVBAgTB1NoaW1hbmUxFzAVBgNV
-BAoTDlJ1YnkgQ29yZSBUZWFtMRUwEwYDVQQDEwxSdWJ5IFRlc3QgQ0EwgZ8wDQYJ
-KoZIhvcNAQEBBQADgY0AMIGJAoGBAO6xGgYlHymAoVnvDw2LWohAc1aV2du0cTw2
-f7T8aFFUi42eQSf7MdF6bFwhMD0i9nqSw/qzhTZEdiJsCIJ4iX3DGdTsfQVbdc04
-HIkD7wKqfm1bNuqt4gvsS+I2v8BJRJOmzNpAvl/AdTu+wCjbQleQO4OvLWCaxrG8
-XGgSLXAlAgMBAAGjgbEwga4wHQYDVR0OBBYEFK71Of7SNaIsHssOCEwOWtxEmeKc
-MH8GA1UdIwR4MHaAFK71Of7SNaIsHssOCEwOWtxEmeKcoVOkUTBPMQswCQYDVQQG
-EwJKUDEQMA4GA1UECBMHU2hpbWFuZTEXMBUGA1UEChMOUnVieSBDb3JlIFRlYW0x
-FTATBgNVBAMTDFJ1YnkgVGVzdCBDQYIJANKcXIGjsDvsMAwGA1UdEwQFMAMBAf8w
-DQYJKoZIhvcNAQEFBQADgYEAniiJgYNVGzjLhYbs7sz0z/BHYXIH8i7KZ/fIKbU8
-NNLPwvecTc6NNyRXhcEOJ4aBFZnsrwWuCZb291rA0qSC7dbTJuk9UFAMccJumlAw
-c4qUDcGcGtp2gLiLRuwQk2yNy6vrEl3gbxparFw0Et97p9y2D9Y+rC9p2xGqHcSQ
-9vo=
------END CERTIFICATE-----
diff --git a/test/net/imap/server.crt b/test/net/imap/server.crt
deleted file mode 100644
index 77803ee385..0000000000
--- a/test/net/imap/server.crt
+++ /dev/null
@@ -1,12 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIB0jCCATsCAQIwDQYJKoZIhvcNAQEFBQAwTzELMAkGA1UEBhMCSlAxEDAOBgNV
-BAgTB1NoaW1hbmUxFzAVBgNVBAoTDlJ1YnkgQ29yZSBUZWFtMRUwEwYDVQQDEwxS
-dWJ5IFRlc3QgQ0EwHhcNMDcxMjIyMDg0MDA1WhcNMTcxMjE5MDg0MDA1WjAUMRIw
-EAYDVQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANt1
-0EXesd+/caAOsKXmvPQcneUlZ2TFe8vxr8a+mqrqfg/MBa/vQGkGsskTnX7rogbi
-6n0Hx8eZx/vVuOtjd2IrGBLDU1jQ9cdADAHRJoI0Fgnj3GX03LtdpUFg56l0utdM
-tqOcxYyJr8vonwX+6v5kJL/n7eP20PzW6/wGghD7AgMBAAEwDQYJKoZIhvcNAQEF
-BQADgYEA2zl2U40/ogkC3k1ccoO4n/szaGW/wfxFREjn9BCvSB8iGRYNCGO/MdZ6
-maaSuAPdIw6RdFncL6dC3xf5IrriCyOmdZM/O8hgC/sNOnWtRAA/+XJqs0UnZ/A2
-f06bSqE1BTSiUU5wY4UraN2aDgnbFonCrY5RipZgLYaWyEbRtF8=
------END CERTIFICATE-----
diff --git a/test/net/imap/server.key b/test/net/imap/server.key
deleted file mode 100644
index 7c57546ece..0000000000
--- a/test/net/imap/server.key
+++ /dev/null
@@ -1,15 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXQIBAAKBgQDbddBF3rHfv3GgDrCl5rz0HJ3lJWdkxXvL8a/Gvpqq6n4PzAWv
-70BpBrLJE51+66IG4up9B8fHmcf71bjrY3diKxgSw1NY0PXHQAwB0SaCNBYJ49xl
-9Ny7XaVBYOepdLrXTLajnMWMia/L6J8F/ur+ZCS/5+3j9tD81uv8BoIQ+wIDAQAB
-AoGAGtYHR+P5gFDaxiXFuCPFC1zMeg7e29XCU6gURIteQnQ2QhxCvcbV64HkLu51
-HeYWhB0Pa4aeCWxmpgb2e+JH4MEoIjeJSGyZQeqwkQLgWJDdvkgWx5am58QzA60I
-ipkZ9QHcPffSs5RiGx4yfr58KqAmwFphGCY8W7v4LqaENdECQQD9H5VTW9g4gj1c
-j3uNYvSI/D7a9P7gfI+ziczuwMm5xsBx3D/t5TAr3SJKNne3sl1E6ZERCUbzxf+C
-k58EiHx1AkEA3fRLGqDOq7EcQhbjTcA/v/t5MwlGEUsS9+XrqOWn50YuoIwRZJ3v
-qHRQzfQfFNklGtfBvwQ4md3irXjMeGVprwJBAMEAuwiDiHuV+xm/ofKtmE13IKot
-ksYy1BOOp/8IawhHXueyi+BmF/PqOkIiA+jCjNGF0oIN89beizPSQbbgJx0CQG/K
-qL1bu1ys0y/SeWBi8XkP/0aeaCUzq/UiYCTsrzoEll2UzvnftqMhGsXxLGqCyHaR
-r2s3hA6zvIVlL4+AfM8CQQClq+WDrC5VKciLYakZNWJjV1m+H2Ut/0fXdUjKHajE
-FWLcsrOhADf6bkTb71GwPxnKRkkRmud5upP0ZYYTqM4X
------END RSA PRIVATE KEY-----
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index eba9bb242a..0ee217965c 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -2,142 +2,10 @@ require "net/imap"
require "test/unit"
class IMAPTest < Test::Unit::TestCase
- CA_FILE = File.expand_path("cacert.pem", File.dirname(__FILE__))
- SERVER_KEY = File.expand_path("server.key", File.dirname(__FILE__))
- SERVER_CERT = File.expand_path("server.crt", File.dirname(__FILE__))
-
- def test_encode_utf7
- utf8 = "\357\274\241\357\274\242\357\274\243".force_encoding("UTF-8")
- s = Net::IMAP.encode_utf7(utf8)
- assert_equal("&,yH,Iv8j-".force_encoding("UTF-8"), s)
- end
-
- def test_decode_utf7
- s = Net::IMAP.decode_utf7("&,yH,Iv8j-")
- utf8 = "\357\274\241\357\274\242\357\274\243".force_encoding("UTF-8")
- assert_equal(utf8, s)
- end
-
- def test_imaps_unknown_ca
- assert_raise(OpenSSL::SSL::SSLError) do
- imaps_test do |port|
- Net::IMAP.new("localhost",
- :port => port,
- :ssl => true)
- end
- end
- end
-
- def test_imaps_with_ca_file
- assert_nothing_raised do
- imaps_test do |port|
- Net::IMAP.new("localhost",
- :port => port,
- :ssl => { :ca_file => CA_FILE })
- end
- end
- end
-
- def test_imaps_verify_none
- assert_nothing_raised do
- imaps_test do |port|
- Net::IMAP.new("localhost",
- :port => port,
- :ssl => { :verify_mode => OpenSSL::SSL::VERIFY_NONE })
- end
- end
- end
-
- def test_imaps_post_connection_check
- assert_raise(OpenSSL::SSL::SSLError) do
- imaps_test do |port|
- Net::IMAP.new("127.0.0.1",
- :port => port,
- :ssl => { :ca_file => CA_FILE })
- end
- end
- end
-
- def test_starttls
- starttls_test do |port|
- imap = Net::IMAP.new("localhost", :port => port)
- imap.starttls(:ca_file => CA_FILE)
- imap
- end
- end
-
- private
-
- def imaps_test
- server = TCPServer.new(0)
- port = server.addr[1]
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.ca_file = CA_FILE
- ctx.key = File.open(SERVER_KEY) { |f|
- OpenSSL::PKey::RSA.new(f)
- }
- ctx.cert = File.open(SERVER_CERT) { |f|
- OpenSSL::X509::Certificate.new(f)
- }
- ssl_server = OpenSSL::SSL::SSLServer.new(server, ctx)
- Thread.start do
- begin
- sock = ssl_server.accept
- begin
- sock.print("* OK test server\r\n")
- sock.gets
- sock.print("* BYE terminating connection\r\n")
- sock.print("RUBY0001 OK LOGOUT completed\r\n")
- ensure
- sock.close
- end
- rescue
- end
- end
- begin
- imap = yield(port)
- imap.logout
- imap.disconnect
- ensure
- ssl_server.close
- end
- end
-
- def starttls_test
- server = TCPServer.new(0)
- port = server.addr[1]
- Thread.start do
- begin
- sock = server.accept
- sock.print("* OK test server\r\n")
- sock.gets
- sock.print("RUBY0001 OK completed\r\n")
- ctx = OpenSSL::SSL::SSLContext.new
- ctx.ca_file = CA_FILE
- ctx.key = File.open(SERVER_KEY) { |f|
- OpenSSL::PKey::RSA.new(f)
- }
- ctx.cert = File.open(SERVER_CERT) { |f|
- OpenSSL::X509::Certificate.new(f)
- }
- sock = OpenSSL::SSL::SSLSocket.new(sock, ctx)
- begin
- sock.accept
- sock.gets
- sock.print("* BYE terminating connection\r\n")
- sock.print("RUBY0002 OK LOGOUT completed\r\n")
- ensure
- sock.close
- end
- rescue
- end
- end
- begin
- imap = yield(port)
- imap.logout
- imap.disconnect
- ensure
- server.close
- end
+ def test_parse_nomodesq
+ parser = Net::IMAP::ResponseParser.new
+ r = parser.parse(%Q'* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox\r\n')
+ assert_equal("OK", r.name)
+ assert_equal("NOMODSEQ", r.data.code.name)
end
end
diff --git a/test/nkf/test_kconv.rb b/test/nkf/test_kconv.rb
index df357e211d..2533424705 100644
--- a/test/nkf/test_kconv.rb
+++ b/test/nkf/test_kconv.rb
@@ -2,73 +2,70 @@ require 'test/unit'
require 'kconv'
class TestKconv < Test::Unit::TestCase
- def setup
- @euc_str = "\
+ EUC_STR = "\
\xa5\xaa\xa5\xd6\xa5\xb8\xa5\xa7\xa5\xaf\xa5\xc8\xbb\xd8\xb8\xfe\
\xa5\xd7\xa5\xed\xa5\xb0\xa5\xe9\xa5\xdf\xa5\xf3\xa5\xb0\xb8\xc0\xb8\xec
-\x52\x75\x62\x79".force_encoding('EUC-JP')
- @utf8_str = "\
+\x52\x75\x62\x79"
+ UTF8_STR = "\
\xe3\x82\xaa\xe3\x83\x96\xe3\x82\xb8\xe3\x82\xa7\
\xe3\x82\xaf\xe3\x83\x88\xe6\x8c\x87\xe5\x90\x91\
\xe3\x83\x97\xe3\x83\xad\xe3\x82\xb0\xe3\x83\xa9\xe3\x83\x9f\
\xe3\x83\xb3\xe3\x82\xb0\xe8\xa8\x80\xe8\xaa\x9e
-\x52\x75\x62\x79".force_encoding('UTF-8')
- @sjis_str = "\
+\x52\x75\x62\x79"
+ SJIS_STR = "\
\x83\x49\x83\x75\x83\x57\x83\x46\x83\x4e\x83\x67\x8e\x77\x8c\xfc\
\x83\x76\x83\x8d\x83\x4f\x83\x89\x83\x7e\x83\x93\x83\x4f\x8c\xbe\x8c\xea
-\x52\x75\x62\x79".force_encoding('Shift_JIS')
- @jis_str = "\
+\x52\x75\x62\x79"
+ JIS_STR = "\
\x1b\x24\x42\x25\x2a\x25\x56\x25\x38\x25\x27\x25\x2f\x25\x48\x3b\x58\x38\x7e\
\x25\x57\x25\x6d\x25\x30\x25\x69\x25\x5f\x25\x73\x25\x30\x38\x40\x38\x6c\x1b\x28\x42
-\x52\x75\x62\x79".force_encoding('ISO-2022-JP')
- end
-
+\x52\x75\x62\x79"
def test_eucjp
- assert(@euc_str.dup.force_encoding(nil).iseuc)
- assert_equal(::Kconv::EUC, Kconv.guess(@euc_str))
- assert_equal(@euc_str, @euc_str.toeuc)
- assert_equal(@euc_str, @sjis_str.toeuc)
- assert_equal(@euc_str, @utf8_str.toeuc)
- assert_equal(@euc_str, @jis_str.toeuc)
- assert_equal(@euc_str, @euc_str.kconv(::NKF::EUC))
- assert_equal(@euc_str, @sjis_str.kconv(::NKF::EUC))
- assert_equal(@euc_str, @utf8_str.kconv(::NKF::EUC))
- assert_equal(@euc_str, @jis_str.kconv(::NKF::EUC))
+ assert(EUC_STR.iseuc)
+ assert_equal(::Kconv::EUC, Kconv.guess(EUC_STR))
+ assert_equal(EUC_STR, EUC_STR.toeuc)
+ assert_equal(EUC_STR, SJIS_STR.toeuc)
+ assert_equal(EUC_STR, UTF8_STR.toeuc)
+ assert_equal(EUC_STR, JIS_STR.toeuc)
+ assert_equal(EUC_STR, EUC_STR.kconv(::NKF::EUC))
+ assert_equal(EUC_STR, SJIS_STR.kconv(::NKF::EUC))
+ assert_equal(EUC_STR, UTF8_STR.kconv(::NKF::EUC))
+ assert_equal(EUC_STR, JIS_STR.kconv(::NKF::EUC))
end
def test_shiftjis
- assert(@sjis_str.dup.force_encoding(nil).issjis)
- assert_equal(::Kconv::SJIS, Kconv.guess(@sjis_str))
- assert_equal(@sjis_str, @euc_str.tosjis)
- assert_equal(@sjis_str, @sjis_str.tosjis)
- assert_equal(@sjis_str, @utf8_str.tosjis)
- assert_equal(@sjis_str, @jis_str.tosjis)
- assert_equal(@sjis_str, @euc_str.kconv(::NKF::SJIS))
- assert_equal(@sjis_str, @sjis_str.kconv(::NKF::SJIS))
- assert_equal(@sjis_str, @utf8_str.kconv(::NKF::SJIS))
- assert_equal(@sjis_str, @jis_str.kconv(::NKF::SJIS))
+ assert(SJIS_STR.issjis)
+ assert_equal(::Kconv::SJIS, Kconv.guess(SJIS_STR))
+ assert_equal(SJIS_STR, EUC_STR.tosjis)
+ assert_equal(SJIS_STR, SJIS_STR.tosjis)
+ assert_equal(SJIS_STR, UTF8_STR.tosjis)
+ assert_equal(SJIS_STR, JIS_STR.tosjis)
+ assert_equal(SJIS_STR, EUC_STR.kconv(::NKF::SJIS))
+ assert_equal(SJIS_STR, SJIS_STR.kconv(::NKF::SJIS))
+ assert_equal(SJIS_STR, UTF8_STR.kconv(::NKF::SJIS))
+ assert_equal(SJIS_STR, JIS_STR.kconv(::NKF::SJIS))
end
def test_utf8
- assert(@utf8_str.dup.force_encoding(nil).isutf8)
- assert_equal(::Kconv::UTF8, Kconv.guess(@utf8_str))
- assert_equal(@utf8_str, @euc_str.toutf8)
- assert_equal(@utf8_str, @sjis_str.toutf8)
- assert_equal(@utf8_str, @utf8_str.toutf8)
- assert_equal(@utf8_str, @jis_str.toutf8)
- assert_equal(@utf8_str, @euc_str.kconv(::NKF::UTF8))
- assert_equal(@utf8_str, @sjis_str.kconv(::NKF::UTF8))
- assert_equal(@utf8_str, @utf8_str.kconv(::NKF::UTF8))
- assert_equal(@utf8_str, @jis_str.kconv(::NKF::UTF8))
+ assert(UTF8_STR.isutf8)
+ assert_equal(::Kconv::UTF8, Kconv.guess(UTF8_STR))
+ assert_equal(UTF8_STR, EUC_STR.toutf8)
+ assert_equal(UTF8_STR, SJIS_STR.toutf8)
+ assert_equal(UTF8_STR, UTF8_STR.toutf8)
+ assert_equal(UTF8_STR, JIS_STR.toutf8)
+ assert_equal(UTF8_STR, EUC_STR.kconv(::NKF::UTF8))
+ assert_equal(UTF8_STR, SJIS_STR.kconv(::NKF::UTF8))
+ assert_equal(UTF8_STR, UTF8_STR.kconv(::NKF::UTF8))
+ assert_equal(UTF8_STR, JIS_STR.kconv(::NKF::UTF8))
end
def test_jis
- assert_equal(::Kconv::JIS, Kconv.guess(@jis_str))
- assert_equal(@jis_str, @euc_str.tojis)
- assert_equal(@jis_str, @sjis_str.tojis)
- assert_equal(@jis_str, @utf8_str.tojis)
- assert_equal(@jis_str, @jis_str.tojis)
- assert_equal(@jis_str, @euc_str.kconv(::NKF::JIS))
- assert_equal(@jis_str, @sjis_str.kconv(::NKF::JIS))
- assert_equal(@jis_str, @utf8_str.kconv(::NKF::JIS))
- assert_equal(@jis_str, @jis_str.kconv(::NKF::JIS))
+ assert_equal(::Kconv::JIS, Kconv.guess(JIS_STR))
+ assert_equal(JIS_STR, EUC_STR.tojis)
+ assert_equal(JIS_STR, SJIS_STR.tojis)
+ assert_equal(JIS_STR, UTF8_STR.tojis)
+ assert_equal(JIS_STR, JIS_STR.tojis)
+ assert_equal(JIS_STR, EUC_STR.kconv(::NKF::JIS))
+ assert_equal(JIS_STR, SJIS_STR.kconv(::NKF::JIS))
+ assert_equal(JIS_STR, UTF8_STR.kconv(::NKF::JIS))
+ assert_equal(JIS_STR, JIS_STR.kconv(::NKF::JIS))
end
end
diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb
index 86811a464c..f196bc48fb 100644
--- a/test/openssl/test_asn1.rb
+++ b/test/openssl/test_asn1.rb
@@ -169,7 +169,7 @@ class OpenSSL::TestASN1 < Test::Unit::TestCase
assert_equal(OpenSSL::ASN1::OctetString, ext.value[2].class)
extv = OpenSSL::ASN1.decode(ext.value[2].value)
assert_equal(OpenSSL::ASN1::BitString, extv.class)
- str = "\000"; str[0] = 0b00000110.chr
+ str = "\000"; str[0] = 0b00000110
assert_equal(str, extv.value)
ext = extensions.value[0].value[2] # subjetKeyIdentifier
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
index 17713c9988..7273554362 100644
--- a/test/openssl/test_pair.rb
+++ b/test/openssl/test_pair.rb
@@ -54,11 +54,6 @@ module SSLPair
else
return c, s
end
- ensure
- if th && th.alive?
- th.kill
- th.join
- end
end
end
diff --git a/test/openssl/test_pkcs7.rb b/test/openssl/test_pkcs7.rb
index 2cdd9343ff..9b472c1795 100644
--- a/test/openssl/test_pkcs7.rb
+++ b/test/openssl/test_pkcs7.rb
@@ -46,7 +46,7 @@ class OpenSSL::TestPKCS7 < Test::Unit::TestCase
data = "aaaaa\r\nbbbbb\r\nccccc\r\n"
tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs)
- p7 = OpenSSL::PKCS7.new(tmp.to_der)
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
certs = p7.certificates
signers = p7.signers
assert(p7.verify([], store))
@@ -65,7 +65,7 @@ class OpenSSL::TestPKCS7 < Test::Unit::TestCase
data = "aaaaa\nbbbbb\nccccc\n"
flag = OpenSSL::PKCS7::BINARY
tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs, flag)
- p7 = OpenSSL::PKCS7.new(tmp.to_der)
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
certs = p7.certificates
signers = p7.signers
assert(p7.verify([], store))
@@ -87,7 +87,7 @@ class OpenSSL::TestPKCS7 < Test::Unit::TestCase
tmp1.add_signer(tmp2.signers[0])
tmp1.add_certificate(@ee2_cert)
- p7 = OpenSSL::PKCS7.new(tmp1.to_der)
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp1.to_der)
certs = p7.certificates
signers = p7.signers
assert(p7.verify([], store))
@@ -108,7 +108,7 @@ class OpenSSL::TestPKCS7 < Test::Unit::TestCase
data = "aaaaa\nbbbbb\nccccc\n"
flag = OpenSSL::PKCS7::BINARY|OpenSSL::PKCS7::DETACHED
tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs, flag)
- p7 = OpenSSL::PKCS7.new(tmp.to_der)
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
a1 = OpenSSL::ASN1.decode(p7)
certs = p7.certificates
@@ -136,7 +136,7 @@ class OpenSSL::TestPKCS7 < Test::Unit::TestCase
data = "aaaaa\nbbbbb\nccccc\n"
tmp = OpenSSL::PKCS7.encrypt(certs, data, cipher, OpenSSL::PKCS7::BINARY)
- p7 = OpenSSL::PKCS7.new(tmp.to_der)
+ p7 = OpenSSL::PKCS7::PKCS7.new(tmp.to_der)
recip = p7.recipients
assert_equal(:enveloped, p7.type)
assert_equal(2, recip.size)
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index 2bd6689a62..29d3d19edc 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -58,28 +58,84 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
OpenSSL::TestUtils.issue_crl(*arg)
end
- def start_server(port0, verify_mode, start_immediately, &block)
- server = nil
+ def readwrite_loop(ctx, ssl)
+ while line = ssl.gets
+ if line =~ /^STARTTLS$/
+ ssl.accept
+ next
+ end
+ ssl.write(line)
+ end
+ rescue OpenSSL::SSL::SSLError
+ rescue IOError
+ ensure
+ ssl.close rescue nil
+ end
+
+ def server_loop(ctx, ssls, server_proc)
+ loop do
+ ssl = nil
+ begin
+ ssl = ssls.accept
+ rescue OpenSSL::SSL::SSLError
+ retry
+ end
+
+ Thread.start do
+ Thread.current.abort_on_exception = true
+ server_proc.call(ctx, ssl)
+ end
+ end
+ rescue Errno::EBADF, IOError
+ end
+
+ def start_server(port0, verify_mode, start_immediately, args = {}, &block)
+ ctx_proc = args[:ctx_proc]
+ server_proc = args[:server_proc]
+ server_proc ||= method(:readwrite_loop)
+
+ store = OpenSSL::X509::Store.new
+ store.add_cert(@ca_cert)
+ store.purpose = OpenSSL::X509::PURPOSE_SSL_CLIENT
+ ctx = OpenSSL::SSL::SSLContext.new
+ ctx.cert_store = store
+ #ctx.extra_chain_cert = [ ca_cert ]
+ ctx.cert = @svr_cert
+ ctx.key = @svr_key
+ ctx.verify_mode = verify_mode
+ ctx_proc.call(ctx) if ctx_proc
+
+ Socket.do_not_reverse_lookup = true
+ tcps = nil
+ port = port0
begin
- cmd = [RUBY]
- cmd << "-d" if $DEBUG
- cmd << SSL_SERVER << port0.to_s << verify_mode.to_s
- cmd << (start_immediately ? "yes" : "no")
- server = IO.popen(cmd, "w+")
- server.write(@ca_cert.to_pem)
- server.write(@svr_cert.to_pem)
- server.write(@svr_key.to_pem)
- pid = Integer(server.gets)
- if port = server.gets
- if $DEBUG
- $stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, pid, port)
- end
- block.call(server, port.to_i)
+ tcps = TCPServer.new("127.0.0.1", port)
+ rescue Errno::EADDRINUSE
+ port += 1
+ retry
+ end
+
+ ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
+ ssls.start_immediately = start_immediately
+
+ begin
+ server = Thread.new do
+ Thread.current.abort_on_exception = true
+ server_loop(ctx, ssls, server_proc)
end
+
+ $stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, pid, port) if $DEBUG
+
+ block.call(server, port.to_i)
ensure
- if server
- Process.kill(:KILL, pid)
- server.close
+ tcps.close if (tcps)
+ if (server)
+ server.join(5)
+ if server.alive?
+ server.kill
+ server.join
+ flunk("TCPServer was closed and SSLServer is still alive") unless $!
+ end
end
end
end
@@ -93,6 +149,12 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
ssl.connect
end
+ def test_ctx_setup
+ ctx = OpenSSL::SSL::SSLContext.new
+ assert_equal(ctx.setup, true)
+ assert_equal(ctx.setup, nil)
+ end
+
def test_connect_and_close
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port|
sock = TCPSocket.new("127.0.0.1", port)
@@ -131,18 +193,6 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
assert_equal(str, buf)
}
- # puts and gets
- ITERATIONS.times{
- str = "x" * 100 + "\n"
- ssl.puts(str)
- assert_equal(str, ssl.gets)
-
- str = "x" * 100
- ssl.puts(str)
- assert_equal(str, ssl.gets("\n", 100))
- assert_equal("\n", ssl.gets)
- }
-
# read and write
ITERATIONS.times{|i|
str = "x" * 100 + "\n"
@@ -182,7 +232,7 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
called = nil
ctx = OpenSSL::SSL::SSLContext.new
- ctx.client_cert_cb = Proc.new{|ssl|
+ ctx.client_cert_cb = Proc.new{ |sslconn|
called = true
[@cli_cert, @cli_key]
}
@@ -360,6 +410,125 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
assert(!OpenSSL::SSL.verify_certificate_identity(cert, "foo.example.com"))
}
end
+
+ def test_client_session
+ last_session = nil
+ start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) do |server, port|
+ 2.times do
+ sock = TCPSocket.new("127.0.0.1", port)
+ ssl = OpenSSL::SSL::SSLSocket.new(sock)
+ ssl.sync_close = true
+ ssl.session = last_session if last_session
+ ssl.connect
+
+ session = ssl.session
+ if last_session
+ assert(ssl.session_reused?)
+
+ if session.respond_to?(:id)
+ assert_equal(session.id, last_session.id)
+ end
+ assert_equal(session.to_pem, last_session.to_pem)
+ assert_equal(session.to_der, last_session.to_der)
+ # Older version of OpenSSL may not be consistent. Look up which versions later.
+ assert_equal(session.to_text, last_session.to_text)
+ else
+ assert(!ssl.session_reused?)
+ end
+ last_session = session
+
+ str = "x" * 100 + "\n"
+ ssl.puts(str)
+ assert_equal(str, ssl.gets)
+
+ ssl.close
+ end
+ end
+ end
+
+ def test_server_session
+ connections = 0
+ saved_session = nil
+
+ ctx_proc = Proc.new do |ctx, ssl|
+# add test for session callbacks here
+ end
+
+ server_proc = Proc.new do |ctx, ssl|
+ session = ssl.session
+ stats = ctx.session_cache_stats
+
+ case connections
+ when 0
+ assert_equal(stats[:cache_num], 1)
+ assert_equal(stats[:cache_hits], 0)
+ assert_equal(stats[:cache_misses], 0)
+ assert(!ssl.session_reused?)
+ when 1
+ assert_equal(stats[:cache_num], 1)
+ assert_equal(stats[:cache_hits], 1)
+ assert_equal(stats[:cache_misses], 0)
+ assert(ssl.session_reused?)
+ ctx.session_remove(session)
+ saved_session = session
+ when 2
+ assert_equal(stats[:cache_num], 1)
+ assert_equal(stats[:cache_hits], 1)
+ assert_equal(stats[:cache_misses], 1)
+ assert(!ssl.session_reused?)
+ ctx.session_add(saved_session)
+ when 3
+ assert_equal(stats[:cache_num], 2)
+ assert_equal(stats[:cache_hits], 2)
+ assert_equal(stats[:cache_misses], 1)
+ assert(ssl.session_reused?)
+ ctx.flush_sessions(Time.now + 5000)
+ when 4
+ assert_equal(stats[:cache_num], 1)
+ assert_equal(stats[:cache_hits], 2)
+ assert_equal(stats[:cache_misses], 2)
+ assert(!ssl.session_reused?)
+ ctx.session_add(saved_session)
+ end
+ connections += 1
+
+ readwrite_loop(ctx, ssl)
+ end
+
+ first_session = nil
+ start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc, :server_proc => server_proc) do |server, port|
+ 10.times do |i|
+ sock = TCPSocket.new("127.0.0.1", port)
+ ctx = OpenSSL::SSL::SSLContext.new
+ if defined?(OpenSSL::SSL::OP_NO_TICKET)
+ # disable RFC4507 support
+ ctx.options = OpenSSL::SSL::OP_NO_TICKET
+ end
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx)
+ ssl.sync_close = true
+ ssl.session = first_session if first_session
+ ssl.connect
+
+ session = ssl.session
+ if first_session
+ case i
+ when 1; assert(ssl.session_reused?)
+ when 2; assert(!ssl.session_reused?)
+ when 3; assert(ssl.session_reused?)
+ when 4; assert(!ssl.session_reused?)
+ when 5..10; assert(ssl.session_reused?)
+ end
+ end
+ first_session ||= session
+
+ str = "x" * 100 + "\n"
+ ssl.puts(str)
+ assert_equal(str, ssl.gets)
+
+ ssl.close
+ end
+ end
+ end
end
end
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 246b69f0e3..9b0b9c01e8 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -475,32 +475,4 @@ class TestPathname < Test::Unit::TestCase
def test_kernel_pathname
assert_equal(Pathname.new("a"), Pathname("a"))
end
-
- def test_file_basename
- assert_equal("bar", File.basename(Pathname.new("foo/bar")))
- end
-
- def test_file_dirname
- assert_equal("foo", File.dirname(Pathname.new("foo/bar")))
- end
-
- def test_file_split
- assert_equal(["foo", "bar"], File.split(Pathname.new("foo/bar")))
- end
-
- def test_file_extname
- assert_equal(".baz", File.extname(Pathname.new("bar.baz")))
- end
-
- def test_file_fnmatch
- assert(File.fnmatch("*.*", Pathname.new("bar.baz")))
- end
-
- def test_file_join
- assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar")))
- lambda {
- $SAFE = 1
- assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar").taint))
- }.call
- end
end
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index 73a496a4f9..edc3aa09b9 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -69,8 +69,6 @@ class TestReadline < Test::Unit::TestCase
STDIN.reopen(stdin)
STDOUT.reopen(stdout)
begin
- Readline.input = STDIN
- Readline.output = STDOUT
yield
ensure
STDIN.reopen(orig_stdin)
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index d796546a3d..c0f93733c0 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -12,14 +12,14 @@ class MockClock
include Singleton
class MyTS < Rinda::TupleSpace
- def keeper
+ def keeper_thread
nil
end
end
def initialize
@now = 2
- @reso = 0.1
+ @reso = 1
@ts = MyTS.new
@ts.write([2, :now])
@inf = 2**31 - 1
@@ -33,17 +33,18 @@ class MockClock
n
end
- def _forward(n=@reso)
+ def _forward(n=nil)
now ,= @ts.take([nil, :now])
@now = now + n
n = @reso if n.nil?
@ts.write([@now, :now])
end
- def forward(n=@reso)
+ def forward(n)
while n > 0
_forward(@reso)
n -= @reso
+ Thread.pass
end
end
@@ -55,21 +56,11 @@ class MockClock
@ts.write([2, :now])
end
- def sleep(n=@reso)
- while will_deadlock?
- n -= @reso
- forward
- return 0 if n <= 0
- end
+ def sleep(n=nil)
now ,= @ts.read([nil, :now])
@ts.read([(now + n)..@inf, :now])
0
end
-
- def will_deadlock?
- sz = Thread.current.group.list.find_all {|x| x.status != 'sleep'}.size
- sz <= 1
- end
end
module Time
@@ -115,6 +106,14 @@ module TupleSpaceTestModule
Time.sleep(n)
end
end
+
+ def thread_join(th)
+ while th.alive?
+ Kernel.sleep(0.1)
+ sleep(1)
+ end
+ th.value
+ end
def test_00_tuple
tuple = Rinda::TupleEntry.new([1,2,3])
@@ -240,6 +239,28 @@ module TupleSpaceTestModule
end
end
+ def test_ruby_talk_264062
+ th = Thread.new { @ts.take([:empty], 1) }
+ sleep(10)
+ assert_raises(Rinda::RequestExpiredError) do
+ thread_join(th)
+ end
+
+ th = Thread.new { @ts.read([:empty], 1) }
+ sleep(10)
+ assert_raises(Rinda::RequestExpiredError) do
+ thread_join(th)
+ end
+ end
+
+ def test_symbol_tuple
+ @ts.write([:symbol, :symbol])
+ @ts.write(['string', :string])
+ assert_equal([[:symbol, :symbol]], @ts.read_all([:symbol, nil]))
+ assert_equal([[:symbol, :symbol]], @ts.read_all([Symbol, nil]))
+ assert_equal([], @ts.read_all([:nil, nil]))
+ end
+
def test_core_01
5.times do |n|
@ts.write([:req, 2])
@@ -252,7 +273,7 @@ module TupleSpaceTestModule
s = 0
while true
begin
- tuple = @ts.take([:req, Integer], 0.5)
+ tuple = @ts.take([:req, Integer], 1)
assert_equal(2, tuple[1])
s += tuple[1]
rescue Rinda::RequestExpiredError
@@ -263,10 +284,9 @@ module TupleSpaceTestModule
s
end
- sleep(20)
+ assert_equal(10, thread_join(taker))
tuple = @ts.take([:ans, nil])
assert_equal(10, tuple[1])
- assert_equal(10, taker.value)
end
def test_core_02
@@ -274,7 +294,7 @@ module TupleSpaceTestModule
s = 0
while true
begin
- tuple = @ts.take([:req, Integer], 1.0)
+ tuple = @ts.take([:req, Integer], 1)
assert_equal(2, tuple[1])
s += tuple[1]
rescue Rinda::RequestExpiredError
@@ -289,10 +309,9 @@ module TupleSpaceTestModule
@ts.write([:req, 2])
end
- sleep(20)
+ assert_equal(10, thread_join(taker))
tuple = @ts.take([:ans, nil])
assert_equal(10, tuple[1])
- assert_equal(10, taker.value)
assert_equal([], @ts.read_all([nil, nil]))
end
@@ -349,7 +368,7 @@ module TupleSpaceTestModule
s = 0
while true
begin
- tuple = @ts.take([:req, Integer], 1.0)
+ tuple = @ts.take([:req, Integer], 1)
s += tuple[1]
rescue Rinda::RequestExpiredError
break
@@ -359,26 +378,23 @@ module TupleSpaceTestModule
s
end
- writer = Thread.new do
- 5.times do |n|
- @ts.write([:req, 2])
- sleep 0.1
- end
+ 5.times do |n|
+ @ts.write([:req, 2])
end
@ts.take({"message"=>"first", "name"=>"3"})
sleep(4)
+ assert_equal(10, thread_join(taker))
tuple = @ts.take([:ans, nil])
assert_equal(10, tuple[1])
- assert_equal(10, taker.value)
assert_equal([], @ts.read_all([nil, nil]))
notify1.cancel
sleep(3) # notify2 expired
- assert_equal([0, 11], listener1.value)
- assert_equal([0, 3], listener2.value)
+ assert_equal([0, 11], thread_join(listener1))
+ assert_equal([0, 3], thread_join(listener2))
ary = []
ary.push(["write", {"message"=>"first", "name"=>"3"}])
@@ -405,21 +421,21 @@ module TupleSpaceTestModule
taker = Thread.new do
@ts.take([:take, nil], 10) do |template|
Thread.new do
- sleep 0.2
template.cancel
end
end
end
- sleep(1)
- assert(template.canceled?)
-
- @ts.write([:take, 1])
+ sleep(2)
assert_raises(Rinda::RequestCanceledError) do
- assert_nil(taker.value)
+ assert_nil(thread_join(taker))
end
+ assert(template.canceled?)
+
+ @ts.write([:take, 1])
+
assert_equal([[:take, 1]], @ts.read_all([nil, nil]))
end
@@ -433,21 +449,21 @@ module TupleSpaceTestModule
reader = Thread.new do
@ts.read([:take, nil], 10) do |template|
Thread.new do
- sleep 0.2
template.cancel
end
end
end
- sleep(1)
- assert(template.canceled?)
-
- @ts.write([:take, 1])
+ sleep(2)
assert_raises(Rinda::RequestCanceledError) do
- assert_nil(reader.value)
+ assert_nil(thread_join(reader))
end
+ assert(template.canceled?)
+
+ @ts.write([:take, 1])
+
assert_equal([[:take, 1]], @ts.read_all([nil, nil]))
end
@@ -478,30 +494,22 @@ module TupleSpaceTestModule
assert(tuple.expired?)
assert(!tuple.alive?)
- tuple = Rinda::TupleEntry.new([1,2,3], SimpleRenewer.new(1,2))
+ @renewer = SimpleRenewer.new(1,2)
+ tuple = Rinda::TupleEntry.new([1,2,3], @renewer)
assert(!tuple.canceled?)
assert(!tuple.expired?)
assert(tuple.alive?)
- sleep(1.5)
+ sleep(1)
assert(!tuple.canceled?)
assert(!tuple.expired?)
assert(tuple.alive?)
- sleep(1.5)
+ sleep(2)
assert(tuple.expired?)
assert(!tuple.alive?)
end
end
class TupleSpaceTest < Test::Unit::TestCase
- def test_message
- flunk("YARV doesn't support Rinda")
- end
-end
-
-end
-__END__
-
-class TupleSpaceTest < Test::Unit::TestCase
include TupleSpaceTestModule
def setup
@@ -520,13 +528,9 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
end
def test_remote_array_and_hash
- ary = [1, 2, 3]
- @ts.write(DRbObject.new(ary))
- GC.start
+ @ts.write(DRbObject.new([1, 2, 3]))
assert_equal([1, 2, 3], @ts.take([1, 2, 3], 0))
- hash = {'head' => 1, 'tail' => 2}
- @ts.write(DRbObject.new(hash))
- GC.start
+ @ts.write(DRbObject.new({'head' => 1, 'tail' => 2}))
assert_equal({'head' => 1, 'tail' => 2},
@ts.take({'head' => 1, 'tail' => 2}, 0))
end
diff --git a/test/rinda/test_tuplebag.rb b/test/rinda/test_tuplebag.rb
deleted file mode 100644
index eccf372125..0000000000
--- a/test/rinda/test_tuplebag.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-require 'test/unit'
-require 'rinda/tuplespace'
-
-class TestTupleBag < Test::Unit::TestCase
-
- def setup
- @tb = Rinda::TupleBag.new
- end
-
- def test_delete
- assert_nothing_raised do
- val = @tb.delete tup(:val, 1)
- assert_equal nil, val
- end
-
- t = tup(:val, 1)
- @tb.push t
-
- val = @tb.delete t
-
- assert_equal t, val
-
- assert_equal [], @tb.find_all(tem(:val, 1))
-
- t1 = tup(:val, 1)
- t2 = tup(:val, 1)
- @tb.push t1
- @tb.push t2
-
- val = @tb.delete t1
-
- assert_equal t1, val
-
- assert_equal [t2], @tb.find_all(tem(:val, 1))
- end
-
- def test_delete_unless_alive
- assert_equal [], @tb.delete_unless_alive
-
- t1 = tup(:val, nil)
- t2 = tup(:val, nil)
-
- @tb.push t1
- @tb.push t2
-
- assert_equal [], @tb.delete_unless_alive
-
- t1.cancel
-
- assert_equal [t1], @tb.delete_unless_alive, 'canceled'
-
- t2.renew Object.new
-
- assert_equal [t2], @tb.delete_unless_alive, 'expired'
- end
-
- def test_find
- template = tem(:val, nil)
-
- assert_equal nil, @tb.find(template)
-
- t1 = tup(:other, 1)
- @tb.push t1
-
- assert_equal nil, @tb.find(template)
-
- t2 = tup(:val, 1)
- @tb.push t2
-
- assert_equal t2, @tb.find(template)
-
- t2.cancel
-
- assert_equal nil, @tb.find(template), 'canceled'
-
- t3 = tup(:val, 3)
- @tb.push t3
-
- assert_equal t3, @tb.find(template)
-
- t3.renew Object.new
-
- assert_equal nil, @tb.find(template), 'expired'
- end
-
- def test_find_all
- template = tem(:val, nil)
-
- t1 = tup(:other, 1)
- @tb.push t1
-
- assert_equal [], @tb.find_all(template)
-
- t2 = tup(:val, 2)
- t3 = tup(:val, 3)
-
- @tb.push t2
- @tb.push t3
-
- assert_equal [t2, t3], @tb.find_all(template)
-
- t2.cancel
-
- assert_equal [t3], @tb.find_all(template), 'canceled'
-
- t3.renew Object.new
-
- assert_equal [], @tb.find_all(template), 'expired'
- end
-
- def test_find_all_template
- tuple = tup(:val, 1)
-
- t1 = tem(:other, nil)
- @tb.push t1
-
- assert_equal [], @tb.find_all_template(tuple)
-
- t2 = tem(:val, nil)
- t3 = tem(:val, nil)
-
- @tb.push t2
- @tb.push t3
-
- assert_equal [t2, t3], @tb.find_all_template(tuple)
-
- t2.cancel
-
- assert_equal [t3], @tb.find_all_template(tuple), 'canceled'
-
- t3.renew Object.new
-
- assert_equal [], @tb.find_all_template(tuple), 'expired'
- end
-
- def test_has_expires_eh
- assert_equal false, @tb.has_expires?
-
- t = tup(:val, 1)
- @tb.push t
-
- assert_equal true, @tb.has_expires?
-
- t.renew Object.new
-
- assert_equal false, @tb.has_expires?
- end
-
- def test_push
- t = tup(:val, 1)
-
- @tb.push t
-
- assert_equal t, @tb.find(tem(:val, 1))
- end
-
- ##
- # Create a tuple with +ary+ for its contents
-
- def tup(*ary)
- Rinda::TupleEntry.new ary
- end
-
- ##
- # Create a template with +ary+ for its contents
-
- def tem(*ary)
- Rinda::TemplateEntry.new ary
- end
-
-end
-
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb
deleted file mode 100644
index 483ac0d013..0000000000
--- a/test/ripper/dummyparser.rb
+++ /dev/null
@@ -1,571 +0,0 @@
-#
-# dummyparser.rb
-#
-
-require 'ripper'
-
-class Node
- def initialize(name, *nodes)
- @name = name
- @children = nodes
- end
-
- attr_reader :children
-
- def to_s
- "#{@name}(#{@children.map {|n| n.to_s }.join(',')})"
- end
-end
-
-class NodeList
- def initialize
- @list = []
- end
-
- attr_reader :list
-
- def push(item)
- @list.push item
- self
- end
-
- def prepend(items)
- @list.unshift items
- end
-
- def to_s
- '[' + @list.join(',') + ']'
- end
-end
-
-class DummyParser < Ripper
-
- def on_program(stmts)
- $thru_program = true
- stmts
- end
-
- def on_stmts_new
- NodeList.new
- end
-
- def on_stmts_add(stmts, st)
- stmts.push st
- stmts
- end
-
- def on_void_stmt
- Node.new('void')
- end
-
- def on_BEGIN(stmts)
- Node.new('BEGIN', stmts)
- end
-
- def on_END(stmts)
- Node.new('END', stmts)
- end
-
- def on_var_ref(name)
- Node.new('ref', name)
- end
-
- def on_alias(a, b)
- Node.new('alias', a, b)
- end
-
- def on_var_alias(a, b)
- Node.new('valias', a, b)
- end
-
- def on_alias_error(a)
- Node.new('aliaserr', a)
- end
-
- def on_aref(a, b)
- Node.new('aref', a, b)
- end
-
- def on_aref_field(a, b)
- Node.new('aref_field', a, b)
- end
-
- def on_arg_ambiguous
- Node.new('arg_ambiguous')
- end
-
- def on_arg_paren(args)
- args
- end
-
- def on_args_new
- NodeList.new
- end
-
- def on_args_add(list, arg)
- list.push(arg)
- end
-
- def on_args_add_block(list, blk)
- if blk
- list.push('&' + blk.to_s)
- else
- list
- end
- end
-
- def on_args_add_star(list, arg)
- list.push('*' + arg.to_s)
- end
-
- def on_args_prepend(list, args)
- list.prepend args
- list
- end
-
- def on_method_add_arg(m, arg)
- if arg == nil
- arg = on_args_new
- end
- m.children.push arg
- m
- end
-
- def on_method_add_block(m, b)
- on_args_add_block(m.children, b)
- m
- end
-
- def on_assoc_new(a, b)
- Node.new('assoc', a, b)
- end
-
- def on_bare_assoc_hash(assoc_list)
- Node.new('assocs', *assoc_list)
- end
-
- def on_assoclist_from_args(a)
- Node.new('assocs', *a.list)
- end
-
- ######## untested
-
- def on_array(a)
- Node.new('array', a)
- end
-
- def on_assign(a, b)
- Node.new('assign', a, b)
- end
-
- def on_assign_error(a)
- Node.new('assign_error', a)
- end
-
- def on_begin(a)
- Node.new('begin', a)
- end
-
- def on_binary(a, b, c)
- Node.new('binary', a, b, c)
- end
-
- def on_block_var(a)
- Node.new('block_var', a)
- end
-
- def on_bodystmt(a, b, c, d)
- Node.new('bodystmt', a, b, c, d)
- end
-
- def on_brace_block(a, b)
- Node.new('brace_block', a, b)
- end
-
- def on_break(a)
- Node.new('break', a)
- end
-
- def on_call(a, b, c)
- Node.new('call', a, b, c)
- end
-
- def on_case(a, b)
- Node.new('case', a, b)
- end
-
- def on_class(a, b, c)
- Node.new('class', a, b, c)
- end
-
- def on_class_name_error(a)
- Node.new('class_name_error', a)
- end
-
- def on_command(a, b)
- Node.new('command', a, b)
- end
-
- def on_command_call(a, b, c, d)
- Node.new('command_call', a, b, c, d)
- end
-
- def on_const_ref(a)
- Node.new('const_ref', a)
- end
-
- def on_constpath_field(a, b)
- Node.new('constpath_field', a, b)
- end
-
- def on_constpath_ref(a, b)
- Node.new('constpath_ref', a, b)
- end
-
- def on_def(a, b, c)
- Node.new('def', a, b, c)
- end
-
- def on_defined(a)
- Node.new('defined', a)
- end
-
- def on_defs(a, b, c, d, e)
- Node.new('defs', a, b, c, d, e)
- end
-
- def on_do_block(a, b)
- Node.new('do_block', a, b)
- end
-
- def on_dot2(a, b)
- Node.new('dot2', a, b)
- end
-
- def on_dot3(a, b)
- Node.new('dot3', a, b)
- end
-
- def on_dyna_symbol(a)
- Node.new('dyna_symbol', a)
- end
-
- def on_else(a)
- Node.new('else', a)
- end
-
- def on_elsif(a, b, c)
- Node.new('elsif', a, b, c)
- end
-
- def on_ensure(a)
- Node.new('ensure', a)
- end
-
- def on_fcall(a)
- Node.new('fcall', a)
- end
-
- def on_field(a, b, c)
- Node.new('field', a, b, c)
- end
-
- def on_for(a, b, c)
- Node.new('for', a, b, c)
- end
-
- def on_hash(a)
- Node.new('hash', a)
- end
-
- def on_if(a, b, c)
- Node.new('if', a, b, c)
- end
-
- def on_if_mod(a, b)
- Node.new('if_mod', a, b)
- end
-
- def on_ifop(a, b, c)
- Node.new('ifop', a, b, c)
- end
-
- def on_iter_block(a, b)
- Node.new('iter_block', a, b)
- end
-
- def on_massign(a, b)
- Node.new('massign', a, b)
- end
-
- def on_mlhs_add(a, b)
- Node.new('mlhs_add', a, b)
- end
-
- def on_mlhs_add_star(a, b)
- Node.new('mlhs_add_star', a, b)
- end
-
- def on_mlhs_new
- Node.new('mlhs_new')
- end
-
- def on_mlhs_paren(a)
- Node.new('mlhs_paren', a)
- end
-
- def on_module(a, b)
- Node.new('module', a, b)
- end
-
- def on_mrhs_add(a, b)
- Node.new('mrhs_add', a, b)
- end
-
- def on_mrhs_add_star(a, b)
- Node.new('mrhs_add_star', a, b)
- end
-
- def on_mrhs_new
- Node.new('mrhs_new')
- end
-
- def on_mrhs_new_from_arglist(a)
- Node.new('mrhs_new_from_arglist', a)
- end
-
- def on_next(a)
- Node.new('next', a)
- end
-
- def on_opassign(a, b, c)
- Node.new('opassign', a, b, c)
- end
-
- def on_param_error(a)
- Node.new('param_error', a)
- end
-
- def on_params(a, b, c, d)
- Node.new('params', a, b, c, d)
- end
-
- def on_paren(a)
- Node.new('paren', a)
- end
-
- def on_parse_error(a)
- Node.new('parse_error', a)
- end
-
- def on_qwords_add(a, b)
- Node.new('qwords_add', a, b)
- end
-
- def on_qwords_new
- Node.new('qwords_new')
- end
-
- def on_redo
- Node.new('redo')
- end
-
- def on_regexp_literal(a)
- Node.new('regexp_literal', a)
- end
-
- def on_rescue(a, b, c, d)
- Node.new('rescue', a, b, c, d)
- end
-
- def on_rescue_mod(a, b)
- Node.new('rescue_mod', a, b)
- end
-
- def on_restparam(a)
- Node.new('restparam', a)
- end
-
- def on_retry
- Node.new('retry')
- end
-
- def on_return(a)
- Node.new('return', a)
- end
-
- def on_return0
- Node.new('return0')
- end
-
- def on_sclass(a, b)
- Node.new('sclass', a, b)
- end
-
- def on_sp(a)
- Node.new('space', a)
- end
-
- def on_string_add(a, b)
- Node.new('string_add', a, b)
- end
-
- def on_string_concat(a, b)
- Node.new('string_concat', a, b)
- end
-
- def on_string_content
- Node.new('string_content')
- end
-
- def on_string_dvar(a)
- Node.new('string_dvar', a)
- end
-
- def on_string_embexpr(a)
- Node.new('string_embexpr', a)
- end
-
- def on_string_literal(a)
- Node.new('string_literal', a)
- end
-
- def on_super(a)
- Node.new('super', a)
- end
-
- def on_symbol(a)
- Node.new('symbol', a)
- end
-
- def on_symbol_literal(a)
- Node.new('symbol_literal', a)
- end
-
- def on_topconst_field(a)
- Node.new('topconst_field', a)
- end
-
- def on_topconst_ref(a)
- Node.new('topconst_ref', a)
- end
-
- def on_unary(a, b)
- Node.new('unary', a, b)
- end
-
- def on_undef(a)
- Node.new('undef', a)
- end
-
- def on_unless(a, b, c)
- Node.new('unless', a, b, c)
- end
-
- def on_unless_mod(a, b)
- Node.new('unless_mod', a, b)
- end
-
- def on_until_mod(a, b)
- Node.new('until_mod', a, b)
- end
-
- def on_var_field(a)
- Node.new('var_field', a)
- end
-
- def on_when(a, b, c)
- Node.new('when', a, b, c)
- end
-
- def on_while(a, b)
- Node.new('while', a, b)
- end
-
- def on_while_mod(a, b)
- Node.new('while_mod', a, b)
- end
-
- def on_word_add(a, b)
- Node.new('word_add', a, b)
- end
-
- def on_word_new
- Node.new('word_new')
- end
-
- def on_words_add(a, b)
- Node.new('words_add', a, b)
- end
-
- def on_words_new
- Node.new('words_new')
- end
-
- def on_xstring_add(a, b)
- Node.new('xstring_add', a, b)
- end
-
- def on_xstring_literal(a)
- Node.new('xstring_literal', a)
- end
-
- def on_xstring_new
- Node.new('xstring_new')
- end
-
- def on_yield(a)
- Node.new('yield', a)
- end
-
- def on_yield0
- Node.new('yield0')
- end
-
- def on_zsuper
- Node.new('zsuper')
- end
-
- def on_backref(a)
- a
- end
- def on_comma(a)
- a
- end
- def on_gvar(a)
- a
- end
- def on_ident(a)
- a
- end
- def on_int(a)
- a
- end
- def on_kw(a)
- a
- end
- def on_lbrace(a)
- a
- end
- def on_rbrace(a)
- a
- end
- def on_lbracket(a)
- a
- end
- def on_rbracket(a)
- a
- end
- def on_lparen(a)
- a
- end
- def on_rparen(a)
- a
- end
- def on_op(a)
- a
- end
- def on_semicolon(a)
- a
- end
-end
diff --git a/test/ripper/test_files.rb b/test/ripper/test_files.rb
deleted file mode 100644
index c2d7a50a3f..0000000000
--- a/test/ripper/test_files.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-begin
-
-require 'ripper'
-require 'find'
-require 'test/unit'
-
-class TestRipper_Generic < Test::Unit::TestCase
- SRCDIR = File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))
-
- class Parser < Ripper
- PARSER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; r.inspect; Object.new end" }
- SCANNER_EVENTS.each {|n| eval "def on_#{n}(*args) r = [:#{n}, *args]; r.inspect; Object.new end" }
- end
-
- def test_parse_files
- Find.find("#{SRCDIR}/lib", "#{SRCDIR}/ext", "#{SRCDIR}/sample", "#{SRCDIR}/test") {|n|
- next if /\.rb\z/ !~ n || !File.file?(n)
- assert_nothing_raised("ripper failed to parse: #{n.inspect}") { Parser.new(File.read(n)).parse }
- }
- end
-end
-
-rescue LoadError
-end
-
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
deleted file mode 100644
index fa640a37ec..0000000000
--- a/test/ripper/test_parser_events.rb
+++ /dev/null
@@ -1,498 +0,0 @@
-begin
-
-require 'dummyparser'
-require 'test/unit'
-
-class TestRipper_ParserEvents < Test::Unit::TestCase
-
- # should be enabled
-=begin
- def test_event_coverage
- dispatched = Ripper::PARSER_EVENTS.map {|event,*| event }
- dispatched.each do |e|
- assert_equal true, respond_to?("test_#{e}", true),
- "event not tested: #{e.inspect}"
- end
- end
-=end
-
- def parse(str)
- DummyParser.new(str).parse.to_s
- end
-
- $thru_program = false
-
- def test_program
- assert_equal '[void()]', parse('')
- assert_equal true, $thru_program
- end
-
- def test_stmts_new
- assert_equal '[void()]', parse('')
- end
-
- def test_stmts_add
- assert_equal '[ref(nil)]', parse('nil')
- assert_equal '[ref(nil),ref(nil)]', parse('nil;nil')
- assert_equal '[ref(nil),ref(nil),ref(nil)]', parse('nil;nil;nil')
- end
-
- def test_void_stmt
- assert_equal '[void()]', parse('')
- assert_equal '[void()]', parse('; ;')
- end
-
- def test_var_ref
- assert_equal '[ref(a)]', parse('a')
- assert_equal '[ref(nil)]', parse('nil')
- assert_equal '[ref(true)]', parse('true')
- end
-
- def test_BEGIN
- assert_equal '[BEGIN([void()])]', parse('BEGIN{}')
- assert_equal '[BEGIN([ref(nil)])]', parse('BEGIN{nil}')
- end
-
- def test_END
- assert_equal '[END([void()])]', parse('END{}')
- assert_equal '[END([ref(nil)])]', parse('END{nil}')
- end
-
- def test_alias
- assert_equal '[alias(symbol_literal(a),symbol_literal(b))]', parse('alias a b')
- end
-
- def test_var_alias
- assert_equal '[valias($a,$g)]', parse('alias $a $g')
- end
-
- def test_alias_error
- assert_equal '[aliaserr(valias($a,$1))]', parse('alias $a $1')
- end
-
- def test_arglist
- assert_equal '[fcall(m,[])]', parse('m()')
- assert_equal '[fcall(m,[1])]', parse('m(1)')
- assert_equal '[fcall(m,[1,2])]', parse('m(1,2)')
- assert_equal '[fcall(m,[*ref(r)])]', parse('m(*r)')
- assert_equal '[fcall(m,[1,*ref(r)])]', parse('m(1,*r)')
- assert_equal '[fcall(m,[1,2,*ref(r)])]', parse('m(1,2,*r)')
- assert_equal '[fcall(m,[&ref(r)])]', parse('m(&r)')
- assert_equal '[fcall(m,[1,&ref(r)])]', parse('m(1,&r)')
- assert_equal '[fcall(m,[1,2,&ref(r)])]', parse('m(1,2,&r)')
- assert_equal '[fcall(m,[*ref(a),&ref(b)])]', parse('m(*a,&b)')
- assert_equal '[fcall(m,[1,*ref(a),&ref(b)])]', parse('m(1,*a,&b)')
- assert_equal '[fcall(m,[1,2,*ref(a),&ref(b)])]', parse('m(1,2,*a,&b)')
- end
-
- def test_arg_paren
- # FIXME
- end
-
- def test_aref
- assert_equal '[aref(ref(v),[1])]', parse('v[1]')
- assert_equal '[aref(ref(v),[1,2])]', parse('v[1,2]')
- end
-
- def test_assocs
- assert_equal '[fcall(m,[assocs(assoc(1,2))])]', parse('m(1=>2)')
- assert_equal '[fcall(m,[assocs(assoc(1,2),assoc(3,4))])]', parse('m(1=>2,3=>4)')
- assert_equal '[fcall(m,[3,assocs(assoc(1,2))])]', parse('m(3,1=>2)')
- end
-
- def test_aref_field
- assert_equal '[assign(aref_field(ref(a),[1]),2)]', parse('a[1]=2')
- end
-
-=begin
- def test_arg_ambiguous
- assert_equal true, $thru__arg_ambiguous
- end
-=end
-
- def test_array # array literal
- assert_equal '[array([1,2,3])]', parse('[1,2,3]')
- end
-
- def test_assign # generic assignment
- assert_equal '[assign(var_field(v),1)]', parse('v=1')
- end
-
-=begin
- def test_assign_error
- assert_equal true, $thru__assign_error
- end
-
- def test_begin
- assert_equal true, $thru__begin
- end
-
- def test_binary
- assert_equal true, $thru__binary
- end
-
- def test_block_var
- assert_equal true, $thru__block_var
- end
-
- def test_bodystmt
- assert_equal true, $thru__bodystmt
- end
-
- def test_brace_block
- assert_equal true, $thru__brace_block
- end
-
- def test_break
- assert_equal true, $thru__break
- end
-
- def test_call
- assert_equal true, $thru__call
- end
-
- def test_case
- assert_equal true, $thru__case
- end
-
- def test_class
- assert_equal true, $thru__class
- end
-
- def test_class_name_error
- assert_equal true, $thru__class_name_error
- end
-
- def test_command
- assert_equal true, $thru__command
- end
-
- def test_command_call
- assert_equal true, $thru__command_call
- end
-
- def test_const_ref
- assert_equal true, $thru__const_ref
- end
-
- def test_constpath_field
- assert_equal true, $thru__constpath_field
- end
-
- def test_constpath_ref
- assert_equal true, $thru__constpath_ref
- end
-
- def test_def
- assert_equal true, $thru__def
- end
-
- def test_defined
- assert_equal true, $thru__defined
- end
-
- def test_defs
- assert_equal true, $thru__defs
- end
-
- def test_do_block
- assert_equal true, $thru__do_block
- end
-
- def test_dot2
- assert_equal true, $thru__dot2
- end
-
- def test_dot3
- assert_equal true, $thru__dot3
- end
-
- def test_dyna_symbol
- assert_equal true, $thru__dyna_symbol
- end
-
- def test_else
- assert_equal true, $thru__else
- end
-
- def test_elsif
- assert_equal true, $thru__elsif
- end
-
- def test_ensure
- assert_equal true, $thru__ensure
- end
-
- def test_fcall
- assert_equal true, $thru__fcall
- end
-
- def test_field
- assert_equal true, $thru__field
- end
-
- def test_for
- assert_equal true, $thru__for
- end
-
- def test_hash
- assert_equal true, $thru__hash
- end
-
- def test_if
- assert_equal true, $thru__if
- end
-
- def test_if_mod
- assert_equal true, $thru__if_mod
- end
-
- def test_ifop
- assert_equal true, $thru__ifop
- end
-
- def test_iter_block
- assert_equal true, $thru__iter_block
- end
-
- def test_massign
- assert_equal true, $thru__massign
- end
-
- def test_method_add_arg
- assert_equal true, $thru__method_add_arg
- end
-
- def test_mlhs_add
- assert_equal true, $thru__mlhs_add
- end
-
- def test_mlhs_add_star
- assert_equal true, $thru__mlhs_add_star
- end
-
- def test_mlhs_new
- assert_equal true, $thru__mlhs_new
- end
-
- def test_mlhs_paren
- assert_equal true, $thru__mlhs_paren
- end
-
- def test_module
- assert_equal true, $thru__module
- end
-
- def test_mrhs_add
- assert_equal true, $thru__mrhs_add
- end
-
- def test_mrhs_add_star
- assert_equal true, $thru__mrhs_add_star
- end
-
- def test_mrhs_new
- assert_equal true, $thru__mrhs_new
- end
-
- def test_mrhs_new_from_arglist
- assert_equal true, $thru__mrhs_new_from_arglist
- end
-
- def test_next
- assert_equal true, $thru__next
- end
-
- def test_opassign
- assert_equal true, $thru__opassign
- end
-
- def test_param_error
- assert_equal true, $thru__param_error
- end
-
- def test_params
- assert_equal true, $thru__params
- end
-
- def test_paren
- assert_equal true, $thru__paren
- end
-
- def test_parse_error
- assert_equal true, $thru__parse_error
- end
-
- def test_qwords_add
- assert_equal true, $thru__qwords_add
- end
-
- def test_qwords_new
- assert_equal true, $thru__qwords_new
- end
-
- def test_redo
- assert_equal true, $thru__redo
- end
-
- def test_regexp_literal
- assert_equal true, $thru__regexp_literal
- end
-
- def test_rescue
- assert_equal true, $thru__rescue
- end
-
- def test_rescue_mod
- assert_equal true, $thru__rescue_mod
- end
-
- def test_restparam
- assert_equal true, $thru__restparam
- end
-
- def test_retry
- assert_equal true, $thru__retry
- end
-
- def test_return
- assert_equal true, $thru__return
- end
-
- def test_return0
- assert_equal true, $thru__return0
- end
-
- def test_sclass
- assert_equal true, $thru__sclass
- end
-
- def test_space
- assert_equal true, $thru__space
- end
-
- def test_string_add
- assert_equal true, $thru__string_add
- end
-
- def test_string_concat
- assert_equal true, $thru__string_concat
- end
-
- def test_string_content
- assert_equal true, $thru__string_content
- end
-
- def test_string_dvar
- assert_equal true, $thru__string_dvar
- end
-
- def test_string_embexpr
- assert_equal true, $thru__string_embexpr
- end
-
- def test_string_literal
- assert_equal true, $thru__string_literal
- end
-
- def test_super
- assert_equal true, $thru__super
- end
-
- def test_symbol
- assert_equal true, $thru__symbol
- end
-
- def test_symbol_literal
- assert_equal true, $thru__symbol_literal
- end
-
- def test_topconst_field
- assert_equal true, $thru__topconst_field
- end
-
- def test_topconst_ref
- assert_equal true, $thru__topconst_ref
- end
-
- def test_unary
- assert_equal true, $thru__unary
- end
-
- def test_undef
- assert_equal true, $thru__undef
- end
-
- def test_unless
- assert_equal true, $thru__unless
- end
-
- def test_unless_mod
- assert_equal true, $thru__unless_mod
- end
-
- def test_until_mod
- assert_equal true, $thru__until_mod
- end
-
- def test_var_field
- assert_equal true, $thru__var_field
- end
-
- def test_when
- assert_equal true, $thru__when
- end
-
- def test_while
- assert_equal true, $thru__while
- end
-
- def test_while_mod
- assert_equal true, $thru__while_mod
- end
-
- def test_word_add
- assert_equal true, $thru__word_add
- end
-
- def test_word_new
- assert_equal true, $thru__word_new
- end
-
- def test_words_add
- assert_equal true, $thru__words_add
- end
-
- def test_words_new
- assert_equal true, $thru__words_new
- end
-
- def test_xstring_add
- assert_equal true, $thru__xstring_add
- end
-
- def test_xstring_literal
- assert_equal true, $thru__xstring_literal
- end
-
- def test_xstring_new
- assert_equal true, $thru__xstring_new
- end
-
- def test_yield
- assert_equal true, $thru__yield
- end
-
- def test_yield0
- assert_equal true, $thru__yield0
- end
-
- def test_zsuper
- assert_equal true, $thru__zsuper
- end
-=end
-
-end
-
-rescue LoadError
-end
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
deleted file mode 100644
index 4389946104..0000000000
--- a/test/ripper/test_scanner_events.rb
+++ /dev/null
@@ -1,807 +0,0 @@
-#
-# test_scanner_events.rb
-#
-begin
-
-require 'ripper'
-require 'test/unit'
-
-class TestRipper_ScannerEvents < Test::Unit::TestCase
-
- def test_event_coverage
- dispatched = Ripper::SCANNER_EVENTS.map {|event,_| event }
- dispatched.each do |e|
- assert_equal true, respond_to?("test_#{e}", true), "event not tested: #{e}"
- end
- end
-
- def scan(target, str)
- sym = "on_#{target}".intern
- Ripper.lex(str).select {|_1,type,_2| type == sym }.map {|_1,_2,tok| tok }
- end
-
- def test_tokenize
- assert_equal [],
- Ripper.tokenize('')
- assert_equal ['a'],
- Ripper.tokenize('a')
- assert_equal ['1'],
- Ripper.tokenize('1')
- assert_equal ['1', ';', 'def', ' ', 'm', '(', 'arg', ')', 'end'],
- Ripper.tokenize("1;def m(arg)end")
- assert_equal ['print', '(', '<<EOS', ')', "\n", "heredoc\n", "EOS\n"],
- Ripper.tokenize("print(<<EOS)\nheredoc\nEOS\n")
- assert_equal ['print', '(', ' ', '<<EOS', ')', "\n", "heredoc\n", "EOS\n"],
- Ripper.tokenize("print( <<EOS)\nheredoc\nEOS\n")
- assert_equal ["\#\n", "\n", "\#\n", "\n", "nil", "\n"],
- Ripper.tokenize("\#\n\n\#\n\nnil\n")
- end
-
- def test_lex
- assert_equal [],
- Ripper.lex('')
- assert_equal [[[1,0], :on_ident, "a"]],
- Ripper.lex('a')
- assert_equal [[[1, 0], :on_kw, "nil"]],
- Ripper.lex("nil")
- assert_equal [[[1, 0], :on_kw, "def"],
- [[1, 3], :on_sp, " "],
- [[1, 4], :on_ident, "m"],
- [[1, 5], :on_lparen, "("],
- [[1, 6], :on_ident, "a"],
- [[1, 7], :on_rparen, ")"],
- [[1, 8], :on_kw, "end"]],
- Ripper.lex("def m(a)end")
- assert_equal [[[1, 0], :on_int, "1"],
- [[1, 1], :on_nl, "\n"],
- [[2, 0], :on_int, "2"],
- [[2, 1], :on_nl, "\n"],
- [[3, 0], :on_int, "3"]],
- Ripper.lex("1\n2\n3")
- assert_equal [[[1, 0], :on_heredoc_beg, "<<EOS"],
- [[1, 5], :on_nl, "\n"],
- [[2, 0], :on_tstring_content, "heredoc\n"],
- [[3, 0], :on_heredoc_end, "EOS"]],
- Ripper.lex("<<EOS\nheredoc\nEOS")
- end
-
- def test_location
- validate_location ""
- validate_location " "
- validate_location "@"
- validate_location "\n"
- validate_location "\r\n"
- validate_location "\n\n\n\n\n\r\n\n\n"
- validate_location "\n;\n;\n;\n;\n"
- validate_location "nil"
- validate_location "@ivar"
- validate_location "1;2;3"
- validate_location "1\n2\n3"
- validate_location "1\n2\n3\n"
- validate_location "def m(a) nil end"
- validate_location "if true then false else nil end"
- validate_location "BEGIN{print nil}"
- validate_location "%w(a b\nc\r\nd \ne )"
- validate_location %Q["a\nb\r\nc"]
- validate_location "print(<<EOS)\nheredoc\nEOS\n"
- validate_location %Q[print(<<-"EOS")\nheredoc\n EOS\n]
- end
-
- def validate_location(src)
- buf = ''
- Ripper.lex(src).each do |pos, type, tok|
- line, col = *pos
- assert_equal buf.count("\n") + 1, line,
- "wrong lineno: #{tok.inspect} (#{type}) [#{line}:#{col}]"
- assert_equal buf.sub(/\A.*\n/m, '').size, col,
- "wrong column: #{tok.inspect} (#{type}) [#{line}:#{col}]"
- buf << tok
- end
- assert_equal src, buf
- end
-
- def test_backref
- assert_equal ["$`", "$&", "$'", '$1', '$2', '$3'],
- scan('backref', %q[m($~, $`, $&, $', $1, $2, $3)])
- end
-
- def test_backtick
- assert_equal ["`"],
- scan('backtick', %q[p `make all`])
- end
-
- def test_comma
- assert_equal [','] * 6,
- scan('comma', %q[ m(0,1,2,3,4,5,6) ])
- assert_equal [],
- scan('comma', %q[".,.,.,.,.,.,.."])
- assert_equal [],
- scan('comma', %Q[<<EOS\n,,,,,,,,,,\nEOS])
- end
-
- def test_period
- assert_equal [],
- scan('period', '')
- assert_equal ['.'],
- scan('period', 'a.b')
- assert_equal ['.'],
- scan('period', 'Object.new')
- assert_equal [],
- scan('period', '"."')
- assert_equal [],
- scan('period', '1..2')
- assert_equal [],
- scan('period', '1...3')
- end
-
- def test_const
- assert_equal ['CONST'],
- scan('const', 'CONST')
- assert_equal ['C'],
- scan('const', 'C')
- assert_equal ['CONST_A'],
- scan('const', 'CONST_A')
- assert_equal ['Const', 'Const2', 'Const3'],
- scan('const', 'Const; Const2; Const3')
- assert_equal ['Const'],
- scan('const', 'Const(a)')
- assert_equal ['M', 'A', 'A2'],
- scan('const', 'M(A,A2)')
- assert_equal [],
- scan('const', '')
- assert_equal [],
- scan('const', 'm(lvar, @ivar, @@cvar, $gvar)')
- end
-
- def test_cvar
- assert_equal [],
- scan('cvar', '')
- assert_equal ['@@cvar'],
- scan('cvar', '@@cvar')
- assert_equal ['@@__cvar__'],
- scan('cvar', '@@__cvar__')
- assert_equal ['@@CVAR'],
- scan('cvar', '@@CVAR')
- assert_equal ['@@cvar'],
- scan('cvar', ' @@cvar#comment')
- assert_equal ['@@cvar'],
- scan('cvar', ':@@cvar')
- assert_equal ['@@cvar'],
- scan('cvar', 'm(lvar, @ivar, @@cvar, $gvar)')
- assert_equal [],
- scan('cvar', '"@@cvar"')
- end
-
- def test_embexpr_beg
- assert_equal [],
- scan('embexpr_beg', '')
- assert_equal ['#{'],
- scan('embexpr_beg', '"#{expr}"')
- assert_equal [],
- scan('embexpr_beg', '%q[#{expr}]')
- assert_equal ['#{'],
- scan('embexpr_beg', '%Q[#{expr}]')
- assert_equal ['#{'],
- scan('embexpr_beg', "m(<<EOS)\n\#{expr}\nEOS")
- end
-
- def test_embexpr_end
-=begin
- # currently detected as "rbrace"
- assert_equal [],
- scan('embexpr_end', '')
- assert_equal ['}'],
- scan('embexpr_end', '"#{expr}"')
- assert_equal [],
- scan('embexpr_end', '%q[#{expr}]')
- assert_equal ['}'],
- scan('embexpr_end', '%Q[#{expr}]')
- assert_equal ['}'],
- scan('embexpr_end', "m(<<EOS)\n\#{expr}\nEOS")
-=end
- end
-
- def test_embvar
- assert_equal [],
- scan('embvar', '')
- assert_equal ['#'],
- scan('embvar', '"#$gvar"')
- assert_equal ['#'],
- scan('embvar', '"#@ivar"')
- assert_equal ['#'],
- scan('embvar', '"#@@cvar"')
- assert_equal [],
- scan('embvar', '"#lvar"')
- assert_equal [],
- scan('embvar', '"#"')
- assert_equal [],
- scan('embvar', '"\#$gvar"')
- assert_equal [],
- scan('embvar', '"\#@ivar"')
- assert_equal [],
- scan('embvar', '%q[#@ivar]')
- assert_equal ['#'],
- scan('embvar', '%Q[#@ivar]')
- end
-
- def test_float
- assert_equal [],
- scan('float', '')
- assert_equal ['1.000'],
- scan('float', '1.000')
- assert_equal ['123.456'],
- scan('float', '123.456')
- assert_equal ['1.2345678901234567890123456789'],
- scan('float', '1.2345678901234567890123456789')
- assert_equal ['1.000'],
- scan('float', ' 1.000# comment')
- assert_equal ['1.234e5'],
- scan('float', '1.234e5')
- assert_equal ['1.234e1234567890'],
- scan('float', '1.234e1234567890')
- assert_equal ['1.0'],
- scan('float', 'm(a,b,1.0,c,d)')
- end
-
- def test_gvar
- assert_equal [],
- scan('gvar', '')
- assert_equal ['$a'],
- scan('gvar', '$a')
- assert_equal ['$A'],
- scan('gvar', '$A')
- assert_equal ['$gvar'],
- scan('gvar', 'm(lvar, @ivar, @@cvar, $gvar)')
- assert_equal %w($_ $~ $* $$ $? $! $@ $/ $\\ $; $, $. $= $: $< $> $"),
- scan('gvar', 'm($_, $~, $*, $$, $?, $!, $@, $/, $\\, $;, $,, $., $=, $:, $<, $>, $")')
- end
-
- def test_ident
- assert_equal [],
- scan('ident', '')
- assert_equal ['lvar'],
- scan('ident', 'lvar')
- assert_equal ['m', 'lvar'],
- scan('ident', 'm(lvar, @ivar, @@cvar, $gvar)')
- end
-
- def test_int
- assert_equal [],
- scan('int', '')
- assert_equal ['1', '10', '100000000000000'],
- scan('int', 'm(1,10,100000000000000)')
- end
-
- def test_ivar
- assert_equal [],
- scan('ivar', '')
- assert_equal ['@ivar'],
- scan('ivar', '@ivar')
- assert_equal ['@__ivar__'],
- scan('ivar', '@__ivar__')
- assert_equal ['@IVAR'],
- scan('ivar', '@IVAR')
- assert_equal ['@ivar'],
- scan('ivar', 'm(lvar, @ivar, @@cvar, $gvar)')
- end
-
- def test_kw
- assert_equal [],
- scan('kw', '')
- assert_equal %w(not),
- scan('kw', 'not 1')
- assert_equal %w(and),
- scan('kw', '1 and 2')
- assert_equal %w(or),
- scan('kw', '1 or 2')
- assert_equal %w(if then else end),
- scan('kw', 'if 1 then 2 else 3 end')
- assert_equal %w(if then elsif else end),
- scan('kw', 'if 1 then 2 elsif 3 else 4 end')
- assert_equal %w(unless then end),
- scan('kw', 'unless 1 then end')
- assert_equal %w(if true),
- scan('kw', '1 if true')
- assert_equal %w(unless false),
- scan('kw', '2 unless false')
- assert_equal %w(case when when else end),
- scan('kw', 'case n; when 1; when 2; else 3 end')
- assert_equal %w(while do nil end),
- scan('kw', 'while 1 do nil end')
- assert_equal %w(until do nil end),
- scan('kw', 'until 1 do nil end')
- assert_equal %w(while),
- scan('kw', '1 while 2')
- assert_equal %w(until),
- scan('kw', '1 until 2')
- assert_equal %w(while break next retry end),
- scan('kw', 'while 1; break; next; retry end')
- assert_equal %w(for in next break end),
- scan('kw', 'for x in obj; next 1; break 2 end')
- assert_equal %w(begin rescue retry end),
- scan('kw', 'begin 1; rescue; retry; end')
- assert_equal %w(rescue),
- scan('kw', '1 rescue 2')
- assert_equal %w(def redo return end),
- scan('kw', 'def m() redo; return end')
- assert_equal %w(def yield yield end),
- scan('kw', 'def m() yield; yield 1 end')
- assert_equal %w(def super super super end),
- scan('kw', 'def m() super; super(); super(1) end')
- assert_equal %w(alias),
- scan('kw', 'alias a b')
- assert_equal %w(undef),
- scan('kw', 'undef public')
- assert_equal %w(class end),
- scan('kw', 'class A < Object; end')
- assert_equal %w(module end),
- scan('kw', 'module M; end')
- assert_equal %w(class end),
- scan('kw', 'class << obj; end')
- assert_equal %w(BEGIN),
- scan('kw', 'BEGIN { }')
- assert_equal %w(END),
- scan('kw', 'END { }')
- assert_equal %w(self),
- scan('kw', 'self.class')
- assert_equal %w(nil true false),
- scan('kw', 'p(nil, true, false)')
- assert_equal %w(__FILE__ __LINE__),
- scan('kw', 'p __FILE__, __LINE__')
- assert_equal %w(defined?),
- scan('kw', 'defined?(Object)')
- end
-
- def test_lbrace
- assert_equal [],
- scan('lbrace', '')
- assert_equal ['{'],
- scan('lbrace', '3.times{ }')
- assert_equal ['{'],
- scan('lbrace', '3.times { }')
- assert_equal ['{'],
- scan('lbrace', '3.times{}')
- assert_equal [],
- scan('lbrace', '"{}"')
- assert_equal ['{'],
- scan('lbrace', '{1=>2}')
- end
-
- def test_rbrace
- assert_equal [],
- scan('rbrace', '')
- assert_equal ['}'],
- scan('rbrace', '3.times{ }')
- assert_equal ['}'],
- scan('rbrace', '3.times { }')
- assert_equal ['}'],
- scan('rbrace', '3.times{}')
- assert_equal [],
- scan('rbrace', '"{}"')
- assert_equal ['}'],
- scan('rbrace', '{1=>2}')
- end
-
- def test_lbracket
- assert_equal [],
- scan('lbracket', '')
- assert_equal ['['],
- scan('lbracket', '[]')
- assert_equal ['['],
- scan('lbracket', 'a[1]')
- assert_equal [],
- scan('lbracket', 'm(%q[])')
- end
-
- def test_rbracket
- assert_equal [],
- scan('rbracket', '')
- assert_equal [']'],
- scan('rbracket', '[]')
- assert_equal [']'],
- scan('rbracket', 'a[1]')
- assert_equal [],
- scan('rbracket', 'm(%q[])')
- end
-
- def test_lparen
- assert_equal [],
- scan('lparen', '')
- assert_equal ['('],
- scan('lparen', '()')
- assert_equal ['('],
- scan('lparen', 'm()')
- assert_equal ['('],
- scan('lparen', 'm (a)')
- assert_equal [],
- scan('lparen', '"()"')
- assert_equal [],
- scan('lparen', '"%w()"')
- end
-
- def test_rparen
- assert_equal [],
- scan('rparen', '')
- assert_equal [')'],
- scan('rparen', '()')
- assert_equal [')'],
- scan('rparen', 'm()')
- assert_equal [')'],
- scan('rparen', 'm (a)')
- assert_equal [],
- scan('rparen', '"()"')
- assert_equal [],
- scan('rparen', '"%w()"')
- end
-
- def test_op
- assert_equal [],
- scan('op', '')
- assert_equal ['|'],
- scan('op', '1 | 1')
- assert_equal ['^'],
- scan('op', '1 ^ 1')
- assert_equal ['&'],
- scan('op', '1 & 1')
- assert_equal ['<=>'],
- scan('op', '1 <=> 1')
- assert_equal ['=='],
- scan('op', '1 == 1')
- assert_equal ['==='],
- scan('op', '1 === 1')
- assert_equal ['=~'],
- scan('op', '1 =~ 1')
- assert_equal ['>'],
- scan('op', '1 > 1')
- assert_equal ['>='],
- scan('op', '1 >= 1')
- assert_equal ['<'],
- scan('op', '1 < 1')
- assert_equal ['<='],
- scan('op', '1 <= 1')
- assert_equal ['<<'],
- scan('op', '1 << 1')
- assert_equal ['>>'],
- scan('op', '1 >> 1')
- assert_equal ['+'],
- scan('op', '1 + 1')
- assert_equal ['-'],
- scan('op', '1 - 1')
- assert_equal ['*'],
- scan('op', '1 * 1')
- assert_equal ['/'],
- scan('op', '1 / 1')
- assert_equal ['%'],
- scan('op', '1 % 1')
- assert_equal ['**'],
- scan('op', '1 ** 1')
- assert_equal ['~'],
- scan('op', '~1')
- assert_equal ['-'],
- scan('op', '-a')
- assert_equal ['+'],
- scan('op', '+a')
- assert_equal ['[]'],
- scan('op', ':[]')
- assert_equal ['[]='],
- scan('op', ':[]=')
- assert_equal [],
- scan('op', %q[`make all`])
- end
-
- def test_symbeg
- assert_equal [],
- scan('symbeg', '')
- assert_equal [':'],
- scan('symbeg', ':sym')
- assert_equal [':'],
- scan('symbeg', '[1,2,3,:sym]')
- assert_equal [],
- scan('symbeg', '":sym"')
- assert_equal [],
- scan('symbeg', 'a ? b : c')
- end
-
- def test_tstring_beg
- assert_equal [],
- scan('tstring_beg', '')
- assert_equal ['"'],
- scan('tstring_beg', '"abcdef"')
- assert_equal ['%q['],
- scan('tstring_beg', '%q[abcdef]')
- assert_equal ['%Q['],
- scan('tstring_beg', '%Q[abcdef]')
- end
-
- def test_tstring_content
- assert_equal [],
- scan('tstring_content', '')
- assert_equal ['abcdef'],
- scan('tstring_content', '"abcdef"')
- assert_equal ['abcdef'],
- scan('tstring_content', '%q[abcdef]')
- assert_equal ['abcdef'],
- scan('tstring_content', '%Q[abcdef]')
- assert_equal ['abc', 'def'],
- scan('tstring_content', '"abc#{1}def"')
- assert_equal ['sym'],
- scan('tstring_content', ':"sym"')
- end
-
- def test_tstring_end
- assert_equal [],
- scan('tstring_end', '')
- assert_equal ['"'],
- scan('tstring_end', '"abcdef"')
- assert_equal [']'],
- scan('tstring_end', '%q[abcdef]')
- assert_equal [']'],
- scan('tstring_end', '%Q[abcdef]')
- end
-
- def test_regexp_beg
- assert_equal [],
- scan('regexp_beg', '')
- assert_equal ['/'],
- scan('regexp_beg', '/re/')
- assert_equal ['%r<'],
- scan('regexp_beg', '%r<re>')
- assert_equal [],
- scan('regexp_beg', '5 / 5')
- end
-
- def test_regexp_end
- assert_equal [],
- scan('regexp_end', '')
- assert_equal ['/'],
- scan('regexp_end', '/re/')
- assert_equal ['>'],
- scan('regexp_end', '%r<re>')
- end
-
- def test_words_beg
- assert_equal [],
- scan('words_beg', '')
- assert_equal ['%W('],
- scan('words_beg', '%W()')
- assert_equal ['%W('],
- scan('words_beg', '%W(w w w)')
- assert_equal ['%W( '],
- scan('words_beg', '%W( w w w )')
- end
-
- def test_qwords_beg
- assert_equal [],
- scan('qwords_beg', '')
- assert_equal ['%w('],
- scan('qwords_beg', '%w()')
- assert_equal ['%w('],
- scan('qwords_beg', '%w(w w w)')
- assert_equal ['%w( '],
- scan('qwords_beg', '%w( w w w )')
- end
-
- # FIXME: Close paren must not present (`words_end' scanner event?).
- def test_words_sep
- assert_equal [],
- scan('words_sep', '')
- assert_equal [')'],
- scan('words_sep', '%w()')
- assert_equal [' ', ' ', ')'],
- scan('words_sep', '%w(w w w)')
- assert_equal [' ', ' ', ' )'],
- scan('words_sep', '%w( w w w )')
- assert_equal ["\n", ' ', ' )'],
- scan('words_sep', "%w( w\nw w )")
- end
-
- def test_heredoc_beg
- assert_equal [],
- scan('heredoc_beg', '')
- assert_equal ['<<EOS'],
- scan('heredoc_beg', "<<EOS\nheredoc\nEOS")
- assert_equal ['<<EOS'],
- scan('heredoc_beg', "<<EOS\nheredoc\nEOS\n")
- assert_equal ['<<EOS'],
- scan('heredoc_beg', "<<EOS\nheredoc\nEOS \n")
- assert_equal ['<<-EOS'],
- scan('heredoc_beg', "<<-EOS\nheredoc\n\tEOS \n")
- assert_equal ['<<"EOS"'],
- scan('heredoc_beg', %Q[<<"EOS"\nheredoc\nEOS])
- assert_equal [%q(<<'EOS')],
- scan('heredoc_beg', "<<'EOS'\nheredoc\nEOS")
- assert_equal [%q(<<`EOS`)],
- scan('heredoc_beg', "<<`EOS`\nheredoc\nEOS")
- assert_equal [%q(<<" ")],
- scan('heredoc_beg', %Q[<<" "\nheredoc\nEOS])
- end
-
- def test_tstring_content_HEREDOC
- assert_equal [],
- scan('tstring_content', '')
- assert_equal ["heredoc\n"],
- scan('tstring_content', "<<EOS\nheredoc\nEOS")
- assert_equal ["heredoc\n"],
- scan('tstring_content', "<<EOS\nheredoc\nEOS\n")
- assert_equal ["heredoc \n"],
- scan('tstring_content', "<<EOS\nheredoc \nEOS \n")
- assert_equal ["heredoc\n"],
- scan('tstring_content', "<<-EOS\nheredoc\n\tEOS \n")
- end
-
- def test_heredoc_end
- assert_equal [],
- scan('heredoc_end', '')
- assert_equal ["EOS"],
- scan('heredoc_end', "<<EOS\nheredoc\nEOS")
- assert_equal ["EOS\n"],
- scan('heredoc_end', "<<EOS\nheredoc\nEOS\n")
- assert_equal ["EOS \n"],
- scan('heredoc_end', "<<EOS\nheredoc\nEOS \n")
- assert_equal ["\tEOS \n"],
- scan('heredoc_end', "<<-EOS\nheredoc\n\tEOS \n")
- end
-
- def test_semicolon
- assert_equal [],
- scan('semicolon', '')
- assert_equal %w(;),
- scan('semicolon', ';')
- assert_equal %w(; ;),
- scan('semicolon', '; ;')
- assert_equal %w(; ; ;),
- scan('semicolon', 'nil;nil;nil;')
- assert_equal %w(; ; ;),
- scan('semicolon', 'nil;nil;nil;nil')
- assert_equal [],
- scan('semicolon', '";"')
- assert_equal [],
- scan('semicolon', '%w(;)')
- assert_equal [],
- scan('semicolon', '/;/')
- end
-
- def test_comment
- assert_equal [],
- scan('comment', '')
- assert_equal ['# comment'],
- scan('comment', '# comment')
- assert_equal ["# comment\n"],
- scan('comment', "# comment\n")
- assert_equal ["# comment\n"],
- scan('comment', "# comment\n1 + 1")
- assert_equal ["# comment\n"],
- scan('comment', "1 + 1 + 1# comment\n1 + 1")
- end
-
- def test_embdoc_beg
- assert_equal [],
- scan('embdoc_beg', '')
- assert_equal ["=begin\n"],
- scan('embdoc_beg', "=begin\ndoc\n=end")
- assert_equal ["=begin \n"],
- scan('embdoc_beg', "=begin \ndoc\n=end\n")
- assert_equal ["=begin comment\n"],
- scan('embdoc_beg', "=begin comment\ndoc\n=end\n")
- end
-
- def test_embdoc
- assert_equal [],
- scan('embdoc', '')
- assert_equal ["doc\n"],
- scan('embdoc', "=begin\ndoc\n=end")
- assert_equal ["doc\n"],
- scan('embdoc', "=begin\ndoc\n=end\n")
- end
-
- def test_embdoc_end
- assert_equal [],
- scan('embdoc_end', '')
- assert_equal ["=end"],
- scan('embdoc_end', "=begin\ndoc\n=end")
- assert_equal ["=end\n"],
- scan('embdoc_end', "=begin\ndoc\n=end\n")
- end
-
- def test_sp
- assert_equal [],
- scan('sp', '')
- assert_equal [' '],
- scan('sp', ' ')
- assert_equal [' '],
- scan('sp', ' 1')
- assert_equal [],
- scan('sp', "\n")
- assert_equal [' '],
- scan('sp', " \n")
- assert_equal [' ', ' '],
- scan('sp', "1 + 1")
- assert_equal [],
- scan('sp', "' '")
- assert_equal [],
- scan('sp', "%w( )")
- assert_equal [],
- scan('sp', "%w( w )")
- assert_equal [],
- scan('sp', "p(/ /)")
- end
-
- # `nl' event always means End-Of-Statement.
- def test_nl
- assert_equal [],
- scan('nl', '')
- assert_equal [],
- scan('nl', "\n")
- assert_equal ["\n"],
- scan('nl', "1 + 1\n")
- assert_equal ["\n", "\n"],
- scan('nl', "1 + 1\n2 + 2\n")
- assert_equal [],
- scan('nl', "1 +\n1")
- assert_equal [],
- scan('nl', "1;\n")
- assert_equal ["\r\n"],
- scan('nl', "1 + 1\r\n")
- assert_equal [],
- scan('nl', "1;\r\n")
- end
-
- def test_ignored_nl
- assert_equal [],
- scan('ignored_nl', '')
- assert_equal ["\n"],
- scan('ignored_nl', "\n")
- assert_equal [],
- scan('ignored_nl', "1 + 1\n")
- assert_equal [],
- scan('ignored_nl', "1 + 1\n2 + 2\n")
- assert_equal ["\n"],
- scan('ignored_nl', "1 +\n1")
- assert_equal ["\n"],
- scan('ignored_nl', "1;\n")
- assert_equal [],
- scan('ignored_nl', "1 + 1\r\n")
- assert_equal ["\r\n"],
- scan('ignored_nl', "1;\r\n")
- end
-
- def test___end__
- assert_equal [],
- scan('__end__', "")
- assert_equal ["__END__"],
- scan('__end__', "__END__")
- assert_equal ["__END__\n"],
- scan('__end__', "__END__\n")
- assert_equal ["__END__\n"],
- Ripper.tokenize("__END__\njunk junk junk")
- assert_equal ["__END__"],
- scan('__end__', "1\n__END__")
- assert_equal [],
- scan('__end__', "print('__END__')")
- end
-
- def test_CHAR
- assert_equal [],
- scan('CHAR', "")
- assert_equal ["@"],
- scan('CHAR', "@")
- assert_equal [],
- scan('CHAR', "@ivar")
- end
-
- def test_label
- end
-
- def test_tlambda
- end
-
- def test_tlambeg
- end
-
- def test_tlambda_arg
- end
-
-end
-
-rescue LoadError
-end
diff --git a/test/rss/dot.png b/test/rss/dot.png
new file mode 100644
index 0000000000..9c6960fa2f
--- /dev/null
+++ b/test/rss/dot.png
Binary files differ
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index dd06fb2572..0d0d2cbe4f 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -557,20 +557,14 @@ EOA
def assert_atom_content_inline_other_text(generator)
_wrap_assertion do
- require "zlib"
-
- type = "application/zip"
+ type = "image/png"
assert_parse(generator.call(<<-EOA), :nothing_raised)
<content type="#{type}"/>
EOA
- text = ""
- char = "a"
- 100.times do |i|
- text << char
- char.succ!
- end
- base64_content = [Zlib::Deflate.deflate(text)].pack("m").delete("\n")
+ png_file = File.join(File.dirname(__FILE__), "dot.png")
+ png = File.open(png_file, "rb") {|file| file.read}
+ base64_content = [png].pack("m").delete("\n")
[false, true].each do |with_space|
xml_content = base64_content
@@ -591,7 +585,7 @@ EOA
assert(content.inline_other_base64?)
assert(!content.out_of_line?)
assert(!content.have_xml_content?)
- assert_equal(text, Zlib::Inflate.inflate(content.content))
+ assert_equal(png, content.content)
xml = REXML::Document.new(content.to_s).root
assert_rexml_element([], {"type" => type}, base64_content, xml)
diff --git a/test/rss/test_atom.rb b/test/rss/test_atom.rb
index 1f65008fa0..d573b923cc 100644
--- a/test/rss/test_atom.rb
+++ b/test/rss/test_atom.rb
@@ -641,24 +641,17 @@ module RSS
def assert_atom_content_inline_other_base64_to_s(target_class)
_wrap_assertion do
- require "zlib"
-
- text = ""
- char = "a"
- 100.times do |i|
- text << char
- char.succ!
- end
-
- type = "application/zip"
- original_content = Zlib::Deflate.deflate(text)
+ type = "image/png"
+ png_file = File.join(File.dirname(__FILE__), "dot.png")
+ original_content = File.open(png_file, "rb") {|file| file.read}
content = target_class.new
content.type = type
content.content = original_content
xml = REXML::Document.new(content.to_s).root
assert_rexml_element([], {"type" => type},
- [original_content].pack("m").delete("\n"), xml)
+ [original_content].pack("m").delete("\n"),
+ xml)
end
end
diff --git a/test/rss/test_maker_0.9.rb b/test/rss/test_maker_0.9.rb
index df92945a86..c211bf605b 100644
--- a/test/rss/test_maker_0.9.rb
+++ b/test/rss/test_maker_0.9.rb
@@ -13,7 +13,7 @@ module RSS
setup_dummy_channel(maker)
setup_dummy_image(maker)
end
- assert_equal("0.91", rss.rss_version)
+ assert_equal("0.92", rss.rss_version)
rss = RSS::Maker.make("0.91") do |maker|
setup_dummy_channel(maker)
diff --git a/test/rss/test_maker_2.0.rb b/test/rss/test_maker_2.0.rb
index 8fd9134f70..c338e343a3 100644
--- a/test/rss/test_maker_2.0.rb
+++ b/test/rss/test_maker_2.0.rb
@@ -430,6 +430,35 @@ module RSS
test_items(false)
end
+ def test_pubDate_without_description
+ title = "TITLE"
+ link = "http://hoge.com/"
+ description = "text hoge fuga"
+ author = "oprah@oxygen.net"
+ pubDate = Time.now
+
+ rss = RSS::Maker.make("2.0") do |maker|
+ setup_dummy_channel(maker)
+
+ maker.items.new_item do |item|
+ item.title = title
+ item.link = link
+ # item.description = description
+ item.author = author
+ item.pubDate = pubDate
+ end
+ end
+ assert_equal(1, rss.items.size)
+ rss.channel.items.each_with_index do |item, i|
+ assert_equal(title, item.title)
+ assert_equal(link, item.link)
+ # assert_equal(description, item.description)
+ assert_equal(author, item.author)
+ assert_equal(pubDate, item.pubDate)
+ assert_equal(pubDate, item.date)
+ end
+ end
+
def test_guid
isPermaLink = "true"
content = "http://inessential.com/2002/09/01.php#a2"
diff --git a/test/rss/test_maker_dc.rb b/test/rss/test_maker_dc.rb
index 72a967231a..c9df36a1ce 100644
--- a/test/rss/test_maker_dc.rb
+++ b/test/rss/test_maker_dc.rb
@@ -86,8 +86,9 @@ module RSS
elems.each do |name, values, plural|
dc_elems = item.__send__("dc_#{plural}")
values.each do |value|
- elem = dc_elems.__send__("new_#{name}")
- elem.value = value
+ dc_elems.__send__("new_#{name}") do |elem|
+ elem.value = value
+ end
end
end
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 59458ef51b..2e8c9be4d3 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -46,5 +46,17 @@ EOR
assert_nil(RSS::Parser.parse(garbage_rss_file))
end
end
+
+ def test_parse_tag_includes_hyphen
+ assert_nothing_raised do
+ RSS::Parser.parse(make_RDF(<<-EOR))
+<xCal:x-calconnect-venue xmlns:xCal="urn:ietf:params:xml:ns:xcal" />
+#{make_channel}
+#{make_item}
+#{make_textinput}
+#{make_image}
+EOR
+ end
+ end
end
end
diff --git a/test/rss/test_parser_1.0.rb b/test/rss/test_parser_1.0.rb
index 216881b767..819ce286a5 100644
--- a/test/rss/test_parser_1.0.rb
+++ b/test/rss/test_parser_1.0.rb
@@ -509,4 +509,3 @@ EOR
end
end
end
-
diff --git a/test/rss/test_version.rb b/test/rss/test_version.rb
index a602caf103..64f6f0482e 100644
--- a/test/rss/test_version.rb
+++ b/test/rss/test_version.rb
@@ -3,7 +3,7 @@ require "rss-testcase"
module RSS
class TestVersion < TestCase
def test_version
- assert_equal("0.2.2", ::RSS::VERSION)
+ assert_equal("0.2.4", ::RSS::VERSION)
end
end
end
diff --git a/test/ruby/beginmainend.rb b/test/ruby/beginmainend.rb
index 6cdfb15ea6..646140dd22 100644
--- a/test/ruby/beginmainend.rb
+++ b/test/ruby/beginmainend.rb
@@ -16,7 +16,7 @@ BEGIN {
}
# for scope check
-#raise if defined?(local_begin1)
+raise if defined?(local_begin1)
raise unless defined?($global_begin1)
raise unless defined?(::ConstBegin1)
local_for_end2 = "e2"
diff --git a/test/ruby/endblockwarn_rb b/test/ruby/endblockwarn.rb
index 7b7f97f597..7b7f97f597 100644
--- a/test/ruby/endblockwarn_rb
+++ b/test/ruby/endblockwarn.rb
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index bbcab83d06..c481326288 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -1,8 +1,5 @@
module EnvUtil
def rubybin
- unless ENV["RUBYOPT"]
-
- end
if ruby = ENV["RUBY"]
return ruby
end
@@ -20,8 +17,8 @@ module EnvUtil
begin
require "rbconfig"
File.join(
- RbConfig::CONFIG["bindir"],
- RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
)
rescue LoadError
"ruby"
diff --git a/test/ruby/marshaltestlib.rb b/test/ruby/marshaltestlib.rb
index 211bbd8796..891f43b1f7 100644
--- a/test/ruby/marshaltestlib.rb
+++ b/test/ruby/marshaltestlib.rb
@@ -17,7 +17,7 @@ module MarshalTestLib
def marshaltest(o1)
str = encode(o1)
- print str.dump, "\n" if $DEBUG
+ print str, "\n" if $DEBUG
o2 = decode(str)
o2
end
@@ -29,8 +29,8 @@ module MarshalTestLib
iv1 = o1.instance_variables.sort
iv2 = o2.instance_variables.sort
assert_equal(iv1, iv2)
- val1 = iv1.map {|var| o1.instance_eval {eval var.to_s}}
- val2 = iv1.map {|var| o2.instance_eval {eval var.to_s}}
+ val1 = iv1.map {|var| o1.instance_eval {eval var}}
+ val2 = iv1.map {|var| o2.instance_eval {eval var}}
assert_equal(val1, val2, msg)
if block_given?
assert_equal(yield(o1), yield(o2), msg)
diff --git a/test/ruby/sentence.rb b/test/ruby/sentence.rb
deleted file mode 100644
index 50f42d6885..0000000000
--- a/test/ruby/sentence.rb
+++ /dev/null
@@ -1,668 +0,0 @@
-# == sentence library
-#
-# = Features
-#
-# * syntax based sentences generation
-# * sentence operations such as substitution.
-#
-# = Example
-#
-# Some arithmetic expressions using "+", "-", "*" and "/" are generated as follows.
-#
-# require 'sentence'
-# Sentence.each({
-# :exp => [["num"],
-# [:exp, "+", :exp],
-# [:exp, "-", :exp],
-# [:exp, "*", :exp],
-# [:exp, "/", :exp]]
-# }, :exp, 2) {|sent| p sent }
-# #=>
-# #<Sentence: "num">
-# #<Sentence: ("num") "+" ("num")>
-# #<Sentence: ("num") "+" (("num") "+" ("num"))>
-# #<Sentence: ("num") "+" (("num") "-" ("num"))>
-# #<Sentence: ("num") "+" (("num") "*" ("num"))>
-# #<Sentence: ("num") "+" (("num") "/" ("num"))>
-# #<Sentence: (("num") "+" ("num")) "+" ("num")>
-# ...
-#
-# Sentence.each takes 3 arguments.
-# The first argument is the syntax for the expressions.
-# The second argument, :exp, is a generating nonterminal.
-# The third argument, 2, limits derivation to restrict results finitely.
-#
-# Some arithmetic expressions including parenthesis can be generated as follows.
-#
-# syntax = {
-# :factor => [["n"],
-# ["(", :exp, ")"]],
-# :term => [[:factor],
-# [:term, "*", :factor],
-# [:term, "/", :factor]],
-# :exp => [[:term],
-# [:exp, "+", :term],
-# [:exp, "-", :term]]
-# }
-# Sentence.each(syntax, :exp, 2) {|sent| p sent }
-# #=>
-# #<Sentence: (("n"))>
-# #<Sentence: (("(" ((("n"))) ")"))>
-# #<Sentence: (("(" ((("(" ((("n"))) ")"))) ")"))>
-# #<Sentence: (("(" (((("n")) "*" ("n"))) ")"))>
-# #<Sentence: (("(" (((("n")) "/" ("n"))) ")"))>
-# #<Sentence: (("(" (((("n"))) "+" (("n"))) ")"))>
-# #<Sentence: (("(" (((("n"))) "-" (("n"))) ")"))>
-# #<Sentence: ((("n")) "*" ("n"))>
-# #<Sentence: ((("n")) "*" ("(" ((("n"))) ")"))>
-# ...
-#
-# Sentence#to_s can be used to concatenate strings
-# in a sentence:
-#
-# Sentence.each(syntax, :exp, 2) {|sent| p sent.to_s }
-# #=>
-# "n"
-# "(n)"
-# "((n))"
-# "(n*n)"
-# "(n/n)"
-# "(n+n)"
-# "(n-n)"
-# "n*n"
-# "n*(n)"
-# ...
-#
-
-# Sentence() instantiates a sentence object.
-#
-# Sentence("foo", "bar")
-# #=> #<Sentence: "foo" "bar">
-#
-# Sentence("foo", ["bar", "baz"])
-# #=> #<Sentence: "foo" ("bar" "baz")>
-#
-def Sentence(*ary)
- Sentence.new(ary)
-end
-
-# Sentence class represents a tree with string leaves.
-#
-class Sentence
- # _ary_ represents a tree.
- # It should be a possibly nested array which contains strings.
- #
- # Note that _ary_ is not copied.
- # Don't modify _ary_ after the sentence object is instantiated.
- #
- # Sentence.new(["a", "pen"])
- # #<Sentence: "a" "pen">
- #
- # Sentence.new(["I", "have", ["a", "pen"]])
- # #<Sentence: "I" "have" ("a" "pen")>
- #
- def initialize(ary)
- @sent = ary
- end
-
- # returns a string which is concatenation of all strings.
- # No separator is used.
- #
- # Sentence("2", "+", "3").to_s
- # "2+3"
- #
- # Sentence("2", "+", ["3", "*", "5"]).to_s
- # "2+3*5"
- #
- def to_s
- @sent.join('')
- end
-
- # returns a string which is concatenation of all strings separated by _sep_.
- # If _sep_ is not given, single space is used.
- #
- # Sentence("I", "have", ["a", "pen"]).join
- # "I have a pen"
- #
- # Sentence("I", "have", ["a", "pen"]).join("/")
- # "I/have/a/pen"
- #
- # Sentence("a", [], "b").join("/")
- # "a/b"
- #
- def join(sep=' ')
- @sent.flatten.join(sep)
- end
-
- # returns a tree as a nested array.
- #
- # Note that the result is not copied.
- # Don't modify the result.
- #
- # Sentence(["foo", "bar"], "baz").to_a
- # #=> [["foo", "bar"], "baz"]
- #
- def to_a
- @sent
- end
-
- # returns <i>i</i>th element as a sentence or string.
- #
- # s = Sentence(["foo", "bar"], "baz")
- # s #=> #<Sentence: ("foo" "bar") "baz">
- # s[0] #=> #<Sentence: "foo" "bar">
- # s[1] #=> "baz"
- #
- def [](i)
- e = @sent[i]
- e.respond_to?(:to_ary) ? Sentence.new(e) : e
- end
-
- # returns the number of top level elements.
- #
- # Sentence.new(%w[foo bar]).length
- # #=> 2
- #
- # Sentence(%w[2 * 7], "+", %w[3 * 5]).length
- # #=> 3
- #
- def length
- @sent.length
- end
-
- # iterates over children.
- #
- # Sentence(%w[2 * 7], "+", %w[3 * 5]).each {|v| p v }
- # #=>
- # #<Sentence: "2" "*" "7">
- # "+"
- # #<Sentence: "3" "*" "5">
- #
- def each # :yield: element
- @sent.each_index {|i|
- yield self[i]
- }
- end
- include Enumerable
-
- def inspect
- "#<#{self.class}: #{inner_inspect(@sent, '')}>"
- end
-
- # :stopdoc:
- def inner_inspect(ary, r)
- first = true
- ary.each {|obj|
- r << ' ' if !first
- first = false
- if obj.respond_to? :to_ary
- r << '('
- inner_inspect(obj, r)
- r << ')'
- else
- r << obj.inspect
- end
- }
- r
- end
- # :startdoc:
-
- # returns new sentence object which
- # _target_ is substituted by the block.
- #
- # Sentence#subst invokes <tt>_target_ === _string_</tt> for each
- # string in the sentence.
- # The strings which === returns true are substituted by the block.
- # The block is invoked with the substituting string.
- #
- # Sentence.new(%w[2 + 3]).subst("+") { "*" }
- # #<Sentence: "2" "*" "3">
- #
- # Sentence.new(%w[2 + 3]).subst(/\A\d+\z/) {|s| ((s.to_i)*2).to_s }
- # #=> #<Sentence: "4" "+" "6">
- #
- def subst(target, &b) # :yield: string
- Sentence.new(subst_rec(@sent, target, &b))
- end
-
- # :stopdoc:
- def subst_rec(obj, target, &b)
- if obj.respond_to? :to_ary
- a = []
- obj.each {|e| a << subst_rec(e, target, &b) }
- a
- elsif target === obj
- yield obj
- else
- obj
- end
- end
- # :startdoc:
-
- # find a subsentence and return it.
- # The block is invoked for each subsentence in preorder manner.
- # The first subsentence which the block returns true is returned.
- #
- # Sentence(%w[2 * 7], "+", %w[3 * 5]).find_subtree {|s| s[1] == "*" }
- # #=> #<Sentence: "2" "*" "7">
- #
- def find_subtree(&b) # :yield: sentence
- find_subtree_rec(@sent, &b)
- end
-
- # :stopdoc:
- def find_subtree_rec(obj, &b)
- if obj.respond_to? :to_ary
- s = Sentence.new(obj)
- if b.call s
- return s
- else
- obj.each {|e|
- r = find_subtree_rec(e, &b)
- return r if r
- }
- end
- end
- nil
- end
- # :startdoc:
-
- # returns a new sentence object which expands according to the condition
- # given by the block.
- #
- # The block is invoked for each subsentence.
- # The subsentences which the block returns true are
- # expanded into parent.
- #
- # s = Sentence(%w[2 * 7], "+", %w[3 * 5])
- # #=> #<Sentence: ("2" "*" "7") "+" ("3" "*" "5")>
- #
- # s.expand { true }
- # #=> #<Sentence: "2" "*" "7" "+" "3" "*" "5">
- #
- # s.expand {|s| s[0] == "3" }
- # #=> #<Sentence: (("2" "*" "7") "+" "3" "*" "5")>
- #
- def expand(&b) # :yield: sentence
- Sentence.new(expand_rec(@sent, &b))
- end
-
- # :stopdoc:
- def expand_rec(obj, r=[], &b)
- if obj.respond_to? :to_ary
- obj.each {|o|
- s = Sentence.new(o)
- if b.call s
- expand_rec(o, r, &b)
- else
- a = []
- expand_rec(o, a, &b)
- r << a
- end
- }
- else
- r << obj
- end
- r
- end
- # :startdoc:
-
- # Sentence.each generates sentences
- # by deriving the start symbol _sym_ using _syntax_.
- # The derivation is restricted by an positive integer _limit_ to
- # avoid infinite generation.
- #
- # Sentence.each yields the block with a generated sentence.
- #
- # Sentence.each({
- # :exp => [["n"],
- # [:exp, "+", :exp],
- # [:exp, "*", :exp]]
- # }, :exp, 1) {|sent| p sent }
- # #=>
- # #<Sentence: "n">
- # #<Sentence: ("n") "+" ("n")>
- # #<Sentence: ("n") "*" ("n")>
- #
- # Sentence.each({
- # :exp => [["n"],
- # [:exp, "+", :exp],
- # [:exp, "*", :exp]]
- # }, :exp, 2) {|sent| p sent }
- # #=>
- # #<Sentence: "n">
- # #<Sentence: ("n") "+" ("n")>
- # #<Sentence: ("n") "+" (("n") "+" ("n"))>
- # #<Sentence: ("n") "+" (("n") "*" ("n"))>
- # #<Sentence: (("n") "+" ("n")) "+" ("n")>
- # #<Sentence: (("n") "*" ("n")) "+" ("n")>
- # #<Sentence: ("n") "*" ("n")>
- # #<Sentence: ("n") "*" (("n") "+" ("n"))>
- # #<Sentence: ("n") "*" (("n") "*" ("n"))>
- # #<Sentence: (("n") "+" ("n")) "*" ("n")>
- # #<Sentence: (("n") "*" ("n")) "*" ("n")>
- #
- def Sentence.each(syntax, sym, limit)
- Gen.new(syntax).each_tree(sym, limit) {|tree|
- yield Sentence.new(tree)
- }
- end
-
- # Sentence.expand_syntax returns an expanded syntax:
- # * No rule derives to empty sequence
- # * Underivable rule simplified
- # * No channel rule
- # * Symbols which has zero or one choices are not appered in rhs.
- #
- # Note that the rules which can derive empty and non-empty
- # sequences are modified to derive only non-empty sequences.
- #
- # Sentence.expand_syntax({
- # :underivable1 => [],
- # :underivable2 => [[:underivable1]],
- # :underivable3 => [[:underivable3]],
- # :empty_only1 => [[]],
- # :empty_only2 => [[:just_empty1, :just_empty1]],
- # :empty_or_not => [[], ["foo"]],
- # :empty_or_not_2 => [[:empty_or_not, :empty_or_not]],
- # :empty_or_not_3 => [[:empty_or_not, :empty_or_not, :empty_or_not]],
- # :empty_or_not_4 => [[:empty_or_not_2, :empty_or_not_2]],
- # :channel1 => [[:channeled_data]],
- # :channeled_data => [["a", "b"], ["c", "d"]],
- # :single_choice => [["single", "choice"]],
- # :single_choice_2 => [[:single_choice, :single_choice]],
- # })
- # #=>
- # {
- # :underivable1=>[], # underivable rules are simplified to [].
- # :underivable2=>[],
- # :underivable3=>[],
- # :empty_only1=>[], # derivation to empty sequence are removed.
- # :empty_only2=>[],
- # :empty_or_not=>[["foo"]], # empty sequences are removed too.
- # :empty_or_not_2=>[["foo"], ["foo", "foo"]],
- # :empty_or_not_3=>[["foo"], ["foo", "foo"], ["foo", "foo", "foo"]],
- # :empty_or_not_4=> [["foo"], ["foo", "foo"], [:empty_or_not_2, :empty_or_not_2]],
- # :channel1=>[["a", "b"], ["c", "d"]], # channel rules are removed.
- # :channeled_data=>[["a", "b"], ["c", "d"]],
- # :single_choice=>[["single", "choice"]], # single choice rules are expanded.
- # :single_choice_2=>[["single", "choice", "single", "choice"]],
- # }
- #
- # Sentence.expand_syntax({
- # :factor => [["n"],
- # ["(", :exp, ")"]],
- # :term => [[:factor],
- # [:term, "*", :factor],
- # [:term, "/", :factor]],
- # :exp => [[:term],
- # [:exp, "+", :term],
- # [:exp, "-", :term]]
- # })
- # #=>
- # {:exp=> [["n"],
- # ["(", :exp, ")"],
- # [:exp, "+", :term],
- # [:exp, "-", :term],
- # [:term, "*", :factor],
- # [:term, "/", :factor]],
- # :factor=> [["n"],
- # ["(", :exp, ")"]],
- # :term=> [["n"],
- # ["(", :exp, ")"],
- # [:term, "*", :factor],
- # [:term, "/", :factor]]
- # }
- #
- def Sentence.expand_syntax(syntax)
- Sentence::Gen.expand_syntax(syntax)
- end
-
- # :stopdoc:
- class Gen
- def Gen.each_tree(syntax, sym, limit, &b)
- Gen.new(syntax).each_tree(sym, limit, &b)
- end
-
- def Gen.each_string(syntax, sym, limit, &b)
- Gen.new(syntax).each_string(sym, limit, &b)
- end
-
- def initialize(syntax)
- @syntax = syntax
- end
-
- def self.expand_syntax(syntax)
- syntax = simplify_underivable_rules(syntax)
- syntax = simplify_emptyonly_rules(syntax)
- syntax = make_rules_no_empseq(syntax)
- syntax = expand_channel_rules(syntax)
-
- syntax = expand_noalt_rules(syntax)
- syntax = reorder_rules(syntax)
- end
-
- def self.simplify_underivable_rules(syntax)
- deribable_syms = {}
- changed = true
- while changed
- changed = false
- syntax.each {|sym, rules|
- next if deribable_syms[sym]
- rules.each {|rhs|
- if rhs.all? {|e| String === e || deribable_syms[e] }
- deribable_syms[sym] = true
- changed = true
- break
- end
- }
- }
- end
- result = {}
- syntax.each {|sym, rules|
- if deribable_syms[sym]
- rules2 = []
- rules.each {|rhs|
- rules2 << rhs if rhs.all? {|e| String === e || deribable_syms[e] }
- }
- result[sym] = rules2.uniq
- else
- result[sym] = []
- end
- }
- result
- end
-
- def self.simplify_emptyonly_rules(syntax)
- justempty_syms = {}
- changed = true
- while changed
- changed = false
- syntax.each {|sym, rules|
- next if justempty_syms[sym]
- if !rules.empty? && rules.all? {|rhs| rhs.all? {|e| justempty_syms[e] } }
- justempty_syms[sym] = true
- changed = true
- end
- }
- end
- result = {}
- syntax.each {|sym, rules|
- result[sym] = rules.map {|rhs| rhs.reject {|e| justempty_syms[e] } }.uniq
- }
- result
- end
-
- def self.expand_emptyable_syms(rhs, emptyable_syms)
- if rhs.empty?
- yield []
- else
- first = rhs[0]
- rest = rhs[1..-1]
- if emptyable_syms[first]
- expand_emptyable_syms(rest, emptyable_syms) {|rhs2|
- yield [first] + rhs2
- yield rhs2
- }
- else
- expand_emptyable_syms(rest, emptyable_syms) {|rhs2|
- yield [first] + rhs2
- }
- end
- end
- end
-
- def self.make_rules_no_empseq(syntax)
- emptyable_syms = {}
- changed = true
- while changed
- changed = false
- syntax.each {|sym, rules|
- next if emptyable_syms[sym]
- rules.each {|rhs|
- if rhs.all? {|e| emptyable_syms[e] }
- emptyable_syms[sym] = true
- changed = true
- break
- end
- }
- }
- end
- result = {}
- syntax.each {|sym, rules|
- rules2 = []
- rules.each {|rhs|
- expand_emptyable_syms(rhs, emptyable_syms) {|rhs2|
- next if rhs2.empty?
- rules2 << rhs2
- }
- }
- result[sym] = rules2.uniq
- }
- result
- end
-
- def self.expand_channel_rules(syntax)
- channel_rules = {}
- syntax.each {|sym, rules|
- channel_rules[sym] = {sym=>true}
- rules.each {|rhs|
- if rhs.length == 1 && Symbol === rhs[0]
- channel_rules[sym][rhs[0]] = true
- end
- }
- }
- changed = true
- while changed
- changed = false
- channel_rules.each {|sym, set|
- n1 = set.size
- set.keys.each {|s|
- set.update(channel_rules[s])
- }
- n2 = set.size
- changed = true if n1 < n2
- }
- end
- result = {}
- syntax.each {|sym, rules|
- rules2 = []
- channel_rules[sym].each_key {|s|
- syntax[s].each {|rhs|
- unless rhs.length == 1 && Symbol === rhs[0]
- rules2 << rhs
- end
- }
- }
- result[sym] = rules2.uniq
- }
- result
- end
-
- def self.expand_noalt_rules(syntax)
- noalt_syms = {}
- syntax.each {|sym, rules|
- if rules.length == 1
- noalt_syms[sym] = true
- end
- }
- result = {}
- syntax.each {|sym, rules|
- rules2 = []
- rules.each {|rhs|
- rhs2 = []
- rhs.each {|e|
- if noalt_syms[e]
- rhs2.concat syntax[e][0]
- else
- rhs2 << e
- end
- }
- rules2 << rhs2
- }
- result[sym] = rules2.uniq
- }
- result
- end
-
- def self.reorder_rules(syntax)
- result = {}
- syntax.each {|sym, rules|
- result[sym] = rules.sort_by {|rhs|
- [rhs.find_all {|e| Symbol === e }.length, rhs.length]
- }
- }
- result
- end
-
- def each_tree(sym, limit)
- generate_from_sym(sym, limit) {|_, tree|
- yield tree
- }
- nil
- end
-
- def each_string(sym, limit)
- generate_from_sym(sym, limit) {|_, tree|
- yield [tree].join('')
- }
- nil
- end
-
- def generate_from_sym(sym, limit, &b)
- return if limit < 0
- if String === sym
- yield limit, sym
- else
- rules = @syntax[sym]
- raise "undefined rule: #{sym}" if !rules
- rules.each {|rhs|
- if rhs.length == 1 || rules.length == 1
- limit1 = limit
- else
- limit1 = limit-1
- end
- generate_from_rhs(rhs, limit1, &b)
- }
- end
- nil
- end
-
- def generate_from_rhs(rhs, limit)
- return if limit < 0
- if rhs.empty?
- yield limit, []
- else
- generate_from_sym(rhs[0], limit) {|limit1, child|
- generate_from_rhs(rhs[1..-1], limit1) {|limit2, arr|
- yield limit2, [child, *arr]
- }
- }
- end
- nil
- end
- end
- # :startdoc:
-
-end
-
diff --git a/test/ruby/suicide.rb b/test/ruby/suicide.rb
new file mode 100644
index 0000000000..2687ed04cd
--- /dev/null
+++ b/test/ruby/suicide.rb
@@ -0,0 +1,2 @@
+STDERR.reopen(STDOUT)
+at_exit{Process.kill(:INT, $$)}
diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb
index d72fe702af..83f897fb00 100644
--- a/test/ruby/test_alias.rb
+++ b/test/ruby/test_alias.rb
@@ -2,63 +2,39 @@ require 'test/unit'
class TestAlias < Test::Unit::TestCase
class Alias0
- def foo
- "foo"
- end
+ def foo; "foo" end
end
-
- class Alias1 < Alias0
+ class Alias1<Alias0
alias bar foo
-
- def foo
- "foo+#{super}"
- end
+ def foo; "foo+" + super end
end
-
- class Alias2 < Alias1
+ class Alias2<Alias1
alias baz foo
undef foo
end
-
- class Alias3 < Alias2
+ class Alias3<Alias2
def foo
- super
+ defined? super
end
-
def bar
- super
+ defined? super
end
-
def quux
- super
+ defined? super
end
end
def test_alias
x = Alias2.new
- assert_equal "foo", x.bar
- assert_equal "foo+foo", x.baz
- assert_equal "foo+foo", x.baz # test_check for cache
+ assert_equal("foo", x.bar)
+ assert_equal("foo+foo", x.baz)
- x = Alias3.new
- assert_raise(NoMethodError) { x.foo }
- assert_equal "foo", x.bar
- assert_raise(NoMethodError) { x.quux }
- end
-
- class C
- def m
- $SAFE
- end
- end
+ # test_check for cache
+ assert_equal("foo+foo", x.baz)
- def test_JVN_83768862
- d = lambda {
- $SAFE = 4
- dclass = Class.new(C)
- dclass.send(:alias_method, :mm, :m)
- dclass.new
- }.call
- assert_raise(SecurityError) { d.mm }
+ x = Alias3.new
+ assert(!x.foo)
+ assert(x.bar)
+ assert(!x.quux)
end
end
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index c0206baed5..4c7c3dfb6d 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -466,10 +466,7 @@ class TestArray < Test::Unit::TestCase
assert_equal([], @cls[].collect { 99 })
- # Ruby 1.9 feature change:
- # Enumerable#collect without block returns an Enumerator.
- #assert_equal([1, 2, 3], @cls[1, 2, 3].collect)
- assert_kind_of Enumerable::Enumerator, @cls[1, 2, 3].collect
+ assert_equal([1, 2, 3], @cls[1, 2, 3].collect)
end
# also update map!
@@ -531,6 +528,15 @@ class TestArray < Test::Unit::TestCase
assert_equal([1, 2, 3, 1, 2, 3], a)
end
+ def test_count
+ a = @cls[1, 2, 3, 1, 2]
+ assert_equal(5, a.count)
+ assert_equal(2, a.count(1))
+ assert_equal(3, a.count {|x| x % 2 == 1 })
+ assert_equal(2, a.count(1) {|x| x % 2 == 1 })
+ assert_raise(ArgumentError) { a.count(0, 1) }
+ end
+
def test_delete
a = @cls[*('cab'..'cat').to_a]
assert_equal('cap', a.delete('cap'))
@@ -712,6 +718,20 @@ class TestArray < Test::Unit::TestCase
@cls[@cls[@cls[@cls[],@cls[]],@cls[@cls[]],@cls[]],@cls[@cls[@cls[]]]].flatten)
end
+ def test_flatten_with_callcc
+ respond_to?(:callcc, true) or require 'continuation'
+ o = Object.new
+ def o.to_ary() callcc {|k| @cont = k; [1,2,3]} end
+ begin
+ assert_equal([10, 20, 1, 2, 3, 30, 1, 2, 3, 40], [10, 20, o, 30, o, 40].flatten)
+ rescue => e
+ else
+ o.instance_eval {@cont}.call
+ end
+ assert_instance_of(RuntimeError, e, '[ruby-dev:34798]')
+ assert_match(/reentered/, e.message, '[ruby-dev:34798]')
+ end
+
def test_hash
a1 = @cls[ 'cat', 'dog' ]
a2 = @cls[ 'cat', 'dog' ]
@@ -1140,19 +1160,19 @@ class TestArray < Test::Unit::TestCase
def test_to_s
$, = ""
a = @cls[]
- assert_equal("[]", a.to_s)
+ assert_equal("", a.to_s)
$, = ""
a = @cls[1, 2]
- assert_equal("[1, 2]", a.to_s)
+ assert_equal("12", a.to_s)
$, = ""
a = @cls[1, 2, 3]
- assert_equal("[1, 2, 3]", a.to_s)
+ assert_equal("123", a.to_s)
$, = ":"
a = @cls[1, 2, 3]
- assert_equal("[1, 2, 3]", a.to_s)
+ assert_equal("1:2:3", a.to_s)
$, = ""
end
@@ -1229,4 +1249,24 @@ class TestArray < Test::Unit::TestCase
assert_equal(@cls[].permutation(0).to_a, @cls[[]])
end
+
+ def test_take
+ assert_equal([1,2,3], [1,2,3,4,5,0].take(3))
+ assert_raise(ArgumentError, '[ruby-dev:34123]') { [1,2].take(-1) }
+ assert_equal([1,2], [1,2].take(1000000000), '[ruby-dev:34123]')
+ end
+
+ def test_take_while
+ assert_equal([1,2], [1,2,3,4,5,0].take_while {|i| i < 3 })
+ end
+
+ def test_drop
+ assert_equal([4,5,0], [1,2,3,4,5,0].drop(3))
+ assert_raise(ArgumentError, '[ruby-dev:34123]') { [1,2].drop(-1) }
+ assert_equal([], [1,2].drop(1000000000), '[ruby-dev:34123]')
+ end
+
+ def test_drop_while
+ assert_equal([3,4,5,0], [1,2,3,4,5,0].drop_while {|i| i < 3 })
+ end
end
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb
index df0ae0713c..63f37a9d73 100644
--- a/test/ruby/test_assignment.rb
+++ b/test/ruby/test_assignment.rb
@@ -29,26 +29,30 @@ class TestAssignment < Test::Unit::TestCase
a = [*[1]]; assert_equal([1], a)
a = [*[1,2]]; assert_equal([1,2], a)
- a = *[]; assert_equal([], a)
- a = *[1]; assert_equal([1], a)
- a = *[nil]; assert_equal([nil], a)
- a = *[[]]; assert_equal([[]], a)
+ a = *nil; assert_nil(a)
+ a = *1; assert_equal(1, a)
+ a = *[]; assert_nil(a)
+ a = *[1]; assert_equal(1, a)
+ a = *[nil]; assert_nil(a)
+ a = *[[]]; assert_equal([], a)
a = *[1,2]; assert_equal([1,2], a)
- a = *[*[]]; assert_equal([], a)
- a = *[*[1]]; assert_equal([1], a)
+ a = *[*[]]; assert_nil(a)
+ a = *[*[1]]; assert_equal(1, a)
a = *[*[1,2]]; assert_equal([1,2], a)
*a = nil; assert_equal([nil], a)
*a = 1; assert_equal([1], a)
- *a = []; assert_equal([], a)
- *a = [1]; assert_equal([1], a)
- *a = [nil]; assert_equal([nil], a)
- *a = [[]]; assert_equal([[]], a)
- *a = [1,2]; assert_equal([1,2], a)
- *a = [*[]]; assert_equal([], a)
- *a = [*[1]]; assert_equal([1], a)
- *a = [*[1,2]]; assert_equal([1,2], a)
-
+ *a = []; assert_equal([[]], a)
+ *a = [1]; assert_equal([[1]], a)
+ *a = [nil]; assert_equal([[nil]], a)
+ *a = [[]]; assert_equal([[[]]], a)
+ *a = [1,2]; assert_equal([[1,2]], a)
+ *a = [*[]]; assert_equal([[]], a)
+ *a = [*[1]]; assert_equal([[1]], a)
+ *a = [*[1,2]]; assert_equal([[1,2]], a)
+
+ *a = *nil; assert_equal([nil], a)
+ *a = *1; assert_equal([1], a)
*a = *[]; assert_equal([], a)
*a = *[1]; assert_equal([1], a)
*a = *[nil]; assert_equal([nil], a)
@@ -69,6 +73,8 @@ class TestAssignment < Test::Unit::TestCase
a,b,*c = [*[1]]; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = [*[1,2]]; assert_equal([1,2,[]], [a,b,c])
+ a,b,*c = *nil; assert_equal([nil,nil,[]], [a,b,c])
+ a,b,*c = *1; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = *[]; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = *[1]; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = *[nil]; assert_equal([nil,nil,[]], [a,b,c])
@@ -80,133 +86,155 @@ class TestAssignment < Test::Unit::TestCase
end
def test_yield
- def f; yield(nil); end; f {|a| assert_nil(a)}; undef f
- def f; yield(1); end; f {|a| assert_equal(1, a)}; undef f
- def f; yield([]); end; f {|a| assert_equal([], a)}; undef f
- def f; yield([1]); end; f {|a| assert_equal([1], a)}; undef f
- def f; yield([nil]); end; f {|a| assert_equal([nil], a)}; undef f
- def f; yield([[]]); end; f {|a| assert_equal([[]], a)}; undef f
- def f; yield([*[]]); end; f {|a| assert_equal([], a)}; undef f
- def f; yield([*[1]]); end; f {|a| assert_equal([1], a)}; undef f
- def f; yield([*[1,2]]); end; f {|a| assert_equal([1,2], a)}; undef f
-
- def f; yield(*[1]); end; f {|a| assert_equal(1, a)}; undef f
- def f; yield(*[nil]); end; f {|a| assert_equal(nil, a)}; undef f
- def f; yield(*[[]]); end; f {|a| assert_equal([], a)}; undef f
- def f; yield(*[*[1]]); end; f {|a| assert_equal(1, a)}; undef f
-
- def f; yield; end; f {|*a| assert_equal([], a)}; undef f
- def f; yield(nil); end; f {|*a| assert_equal([nil], a)}; undef f
- def f; yield(1); end; f {|*a| assert_equal([1], a)}; undef f
- def f; yield([]); end; f {|*a| assert_equal([[]], a)}; undef f
- def f; yield([1]); end; f {|*a| assert_equal([[1]], a)}; undef f
- def f; yield([nil]); end; f {|*a| assert_equal([[nil]], a)}; undef f
- def f; yield([[]]); end; f {|*a| assert_equal([[[]]], a)}; undef f
- def f; yield([1,2]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
- def f; yield([*[]]); end; f {|*a| assert_equal([[]], a)}; undef f
- def f; yield([*[1]]); end; f {|*a| assert_equal([[1]], a)}; undef f
- def f; yield([*[1,2]]); end; f {|*a| assert_equal([[1,2]], a)}; undef f
-
- def f; yield(*[]); end; f {|*a| assert_equal([], a)}; undef f
- def f; yield(*[1]); end; f {|*a| assert_equal([1], a)}; undef f
- def f; yield(*[nil]); end; f {|*a| assert_equal([nil], a)}; undef f
- def f; yield(*[[]]); end; f {|*a| assert_equal([[]], a)}; undef f
- def f; yield(*[*[]]); end; f {|*a| assert_equal([], a)}; undef f
- def f; yield(*[*[1]]); end; f {|*a| assert_equal([1], a)}; undef f
- def f; yield(*[*[1,2]]); end; f {|*a| assert_equal([1,2], a)}; undef f
-
- def f; yield; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield(nil); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield(1); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
- def f; yield([]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield([1]); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
- def f; yield([nil]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield([[]]); end; f {|a,b,*c| assert_equal([[],nil,[]], [a,b,c])}; undef f
- def f; yield([*[]]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield([*[1]]); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
- def f; yield([*[1,2]]); end; f {|a,b,*c| assert_equal([1,2,[]], [a,b,c])}; undef f
-
- def f; yield(*[]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield(*[1]); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
- def f; yield(*[nil]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield(*[[]]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield(*[*[]]); end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}; undef f
- def f; yield(*[*[1]]); end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}; undef f
- def f; yield(*[*[1,2]]); end; f {|a,b,*c| assert_equal([1,2,[]], [a,b,c])}; undef f
+ def f; yield nil; end; f {|a| assert_nil(a)}
+ def f; yield 1; end; f {|a| assert_equal(1, a)}
+ def f; yield []; end; f {|a| assert_equal([], a)}
+ def f; yield [1]; end; f {|a| assert_equal([1], a)}
+ def f; yield [nil]; end; f {|a| assert_equal([nil], a)}
+ def f; yield [[]]; end; f {|a| assert_equal([[]], a)}
+ def f; yield [*[]]; end; f {|a| assert_equal([], a)}
+ def f; yield [*[1]]; end; f {|a| assert_equal([1], a)}
+ def f; yield [*[1,2]]; end; f {|a| assert_equal([1,2], a)}
+
+ def f; yield *nil; end; f {|a| assert_nil(a)}
+ def f; yield *1; end; f {|a| assert_equal(1, a)}
+ def f; yield *[1]; end; f {|a| assert_equal(1, a)}
+ def f; yield *[nil]; end; f {|a| assert_nil(a)}
+ def f; yield *[[]]; end; f {|a| assert_equal([], a)}
+ def f; yield *[*[1]]; end; f {|a| assert_equal(1, a)}
+
+ def f; yield; end; f {|*a| assert_equal([], a)}
+ def f; yield nil; end; f {|*a| assert_equal([nil], a)}
+ def f; yield 1; end; f {|*a| assert_equal([1], a)}
+ def f; yield []; end; f {|*a| assert_equal([[]], a)}
+ def f; yield [1]; end; f {|*a| assert_equal([[1]], a)}
+ def f; yield [nil]; end; f {|*a| assert_equal([[nil]], a)}
+ def f; yield [[]]; end; f {|*a| assert_equal([[[]]], a)}
+ def f; yield [1,2]; end; f {|*a| assert_equal([[1,2]], a)}
+ def f; yield [*[]]; end; f {|*a| assert_equal([[]], a)}
+ def f; yield [*[1]]; end; f {|*a| assert_equal([[1]], a)}
+ def f; yield [*[1,2]]; end; f {|*a| assert_equal([[1,2]], a)}
+
+ def f; yield *nil; end; f {|*a| assert_equal([nil], a)}
+ def f; yield *1; end; f {|*a| assert_equal([1], a)}
+ def f; yield *[]; end; f {|*a| assert_equal([], a)}
+ def f; yield *[1]; end; f {|*a| assert_equal([1], a)}
+ def f; yield *[nil]; end; f {|*a| assert_equal([nil], a)}
+ def f; yield *[[]]; end; f {|*a| assert_equal([[]], a)}
+ def f; yield *[*[]]; end; f {|*a| assert_equal([], a)}
+ def f; yield *[*[1]]; end; f {|*a| assert_equal([1], a)}
+ def f; yield *[*[1,2]]; end; f {|*a| assert_equal([1,2], a)}
+
+ def f; yield; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield nil; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield 1; end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}
+ def f; yield []; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield [1]; end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}
+ def f; yield [nil]; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield [[]]; end; f {|a,b,*c| assert_equal([[],nil,[]], [a,b,c])}
+ def f; yield [*[]]; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield [*[1]]; end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}
+ def f; yield [*[1,2]]; end; f {|a,b,*c| assert_equal([1,2,[]], [a,b,c])}
+
+ def f; yield *nil; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield *1; end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}
+ def f; yield *[]; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield *[1]; end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}
+ def f; yield *[nil]; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield *[[]]; end; f {|a,b,*c| assert_equal([[],nil,[]], [a,b,c])}
+ def f; yield *[*[]]; end; f {|a,b,*c| assert_equal([nil,nil,[]], [a,b,c])}
+ def f; yield *[*[1]]; end; f {|a,b,*c| assert_equal([1,nil,[]], [a,b,c])}
+ def f; yield *[*[1,2]]; end; f {|a,b,*c| assert_equal([1,2,[]], [a,b,c])}
end
def test_return
- def r; return; end; a = r(); assert_nil(a); undef r
- def r; return nil; end; a = r(); assert_nil(a); undef r
- def r; return 1; end; a = r(); assert_equal(1, a); undef r
- def r; return []; end; a = r(); assert_equal([], a); undef r
- def r; return [1]; end; a = r(); assert_equal([1], a); undef r
- def r; return [nil]; end; a = r(); assert_equal([nil], a); undef r
- def r; return [[]]; end; a = r(); assert_equal([[]], a); undef r
- def r; return [*[]]; end; a = r(); assert_equal([], a); undef r
- def r; return [*[1]]; end; a = r(); assert_equal([1], a); undef r
- def r; return [*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
-
- def r; return *[]; end; a = r(); assert_equal([], a); undef r
- def r; return *[1]; end; a = r(); assert_equal([1], a); undef r
- def r; return *[nil]; end; a = r(); assert_equal([nil], a); undef r
- def r; return *[[]]; end; a = r(); assert_equal([[]], a); undef r
- def r; return *[*[]]; end; a = r(); assert_equal([], a); undef r
- def r; return *[*[1]]; end; a = r(); assert_equal([1], a); undef r
- def r; return *[*[1,2]]; end; a = r(); assert_equal([1,2], a); undef r
-
- def r; return *[[]]; end; a = *r(); assert_equal([[]], a); undef r
- def r; return *[*[1,2]]; end; a = *r(); assert_equal([1,2], a); undef r
-
- def r; return; end; *a = r(); assert_equal([nil], a); undef r
- def r; return nil; end; *a = r(); assert_equal([nil], a); undef r
- def r; return 1; end; *a = r(); assert_equal([1], a); undef r
- def r; return []; end; *a = r(); assert_equal([], a); undef r
- def r; return [1]; end; *a = r(); assert_equal([1], a); undef r
- def r; return [nil]; end; *a = r(); assert_equal([nil], a); undef r
- def r; return [[]]; end; *a = r(); assert_equal([[]], a); undef r
- def r; return [1,2]; end; *a = r(); assert_equal([1,2], a); undef r
- def r; return [*[]]; end; *a = r(); assert_equal([], a); undef r
- def r; return [*[1]]; end; *a = r(); assert_equal([1], a); undef r
- def r; return [*[1,2]]; end; *a = r(); assert_equal([1,2], a); undef r
-
- def r; return *[]; end; *a = r(); assert_equal([], a); undef r
- def r; return *[1]; end; *a = r(); assert_equal([1], a); undef r
- def r; return *[nil]; end; *a = r(); assert_equal([nil], a); undef r
- def r; return *[[]]; end; *a = r(); assert_equal([[]], a); undef r
- def r; return *[1,2]; end; *a = r(); assert_equal([1,2], a); undef r
- def r; return *[*[]]; end; *a = r(); assert_equal([], a); undef r
- def r; return *[*[1]]; end; *a = r(); assert_equal([1], a); undef r
- def r; return *[*[1,2]]; end; *a = r(); assert_equal([1,2], a); undef r
-
- def r; return *[[]]; end; *a = *r(); assert_equal([[]], a); undef r
- def r; return *[1,2]; end; *a = *r(); assert_equal([1,2], a); undef r
- def r; return *[*[1,2]]; end; *a = *r(); assert_equal([1,2], a); undef r
-
- def r; return; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return nil; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return 1; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
- def r; return []; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return [1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
- def r; return [nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return [[]]; end; a,b,*c = r(); assert_equal([[],nil,[]], [a,b,c]); undef r
- def r; return [1,2]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
- def r; return [*[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return [*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
- def r; return [*[1,2]]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
-
- def r; return *[]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return *[1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
- def r; return *[nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return *[[]]; end; a,b,*c = r(); assert_equal([[],nil,[]], [a,b,c]); undef r
- def r; return *[1,2]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
- def r; return *[*[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c]); undef r
- def r; return *[*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c]); undef r
- def r; return *[*[1,2]]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c]); undef r
-
- def r; return 1, *[]; end; a,b = r(); assert_equal([1,nil], [a,b]); undef r
- def r; return 1,2,*[1]; end; a,b = r(); assert_equal([1,2], [a,b]); undef r
- def r; return 1,2,3,*[1,2]; end; a,b = r(); assert_equal([1,2], [a,b]); undef r
+ def r; return; end; a = r(); assert_nil(a)
+ def r; return nil; end; a = r(); assert_nil(a)
+ def r; return 1; end; a = r(); assert_equal(1, a)
+ def r; return []; end; a = r(); assert_equal([], a)
+ def r; return [1]; end; a = r(); assert_equal([1], a)
+ def r; return [nil]; end; a = r(); assert_equal([nil], a)
+ def r; return [[]]; end; a = r(); assert_equal([[]], a)
+ def r; return [*[]]; end; a = r(); assert_equal([], a)
+ def r; return [*[1]]; end; a = r(); assert_equal([1], a)
+ def r; return [*[1,2]]; end; a = r(); assert_equal([1,2], a)
+
+ def r; return *nil; end; a = r(); assert_nil(a)
+ def r; return *1; end; a = r(); assert_equal(1, a)
+ def r; return *[]; end; a = r(); assert_nil(a)
+ def r; return *[1]; end; a = r(); assert_equal(1, a)
+ def r; return *[nil]; end; a = r(); assert_nil(a)
+ def r; return *[[]]; end; a = r(); assert_equal([], a)
+ def r; return *[*[]]; end; a = r(); assert_nil(a)
+ def r; return *[*[1]]; end; a = r(); assert_equal(1, a)
+ def r; return *[*[1,2]]; end; a = r(); assert_equal([1,2], a)
+
+ def r; return *nil; end; a = *r(); assert_nil(a)
+ def r; return *1; end; a = *r(); assert_equal(1, a)
+ def r; return *[]; end; a = *r(); assert_nil(a)
+ def r; return *[1]; end; a = *r(); assert_equal(1, a)
+ def r; return *[nil]; end; a = *r(); assert_nil(a)
+ def r; return *[[]]; end; a = *r(); assert_nil(a)
+ def r; return *[*[]]; end; a = *r(); assert_nil(a)
+ def r; return *[*[1]]; end; a = *r(); assert_equal(1, a)
+ def r; return *[*[1,2]]; end; a = *r(); assert_equal([1,2], a)
+
+ def r; return; end; *a = r(); assert_equal([nil], a)
+ def r; return nil; end; *a = r(); assert_equal([nil], a)
+ def r; return 1; end; *a = r(); assert_equal([1], a)
+ def r; return []; end; *a = r(); assert_equal([[]], a)
+ def r; return [1]; end; *a = r(); assert_equal([[1]], a)
+ def r; return [nil]; end; *a = r(); assert_equal([[nil]], a)
+ def r; return [[]]; end; *a = r(); assert_equal([[[]]], a)
+ def r; return [1,2]; end; *a = r(); assert_equal([[1,2]], a)
+ def r; return [*[]]; end; *a = r(); assert_equal([[]], a)
+ def r; return [*[1]]; end; *a = r(); assert_equal([[1]], a)
+ def r; return [*[1,2]]; end; *a = r(); assert_equal([[1,2]], a)
+
+ def r; return *nil; end; *a = r(); assert_equal([nil], a)
+ def r; return *1; end; *a = r(); assert_equal([1], a)
+ def r; return *[]; end; *a = r(); assert_equal([nil], a)
+ def r; return *[1]; end; *a = r(); assert_equal([1], a)
+ def r; return *[nil]; end; *a = r(); assert_equal([nil], a)
+ def r; return *[[]]; end; *a = r(); assert_equal([[]], a)
+ def r; return *[1,2]; end; *a = r(); assert_equal([[1,2]], a)
+ def r; return *[*[]]; end; *a = r(); assert_equal([nil], a)
+ def r; return *[*[1]]; end; *a = r(); assert_equal([1], a)
+ def r; return *[*[1,2]]; end; *a = r(); assert_equal([[1,2]], a)
+
+ def r; return *nil; end; *a = *r(); assert_equal([nil], a)
+ def r; return *1; end; *a = *r(); assert_equal([1], a)
+ def r; return *[]; end; *a = *r(); assert_equal([nil], a)
+ def r; return *[1]; end; *a = *r(); assert_equal([1], a)
+ def r; return *[nil]; end; *a = *r(); assert_equal([nil], a)
+ def r; return *[[]]; end; *a = *r(); assert_equal([], a)
+ def r; return *[1,2]; end; *a = *r(); assert_equal([1,2], a)
+ def r; return *[*[]]; end; *a = *r(); assert_equal([nil], a)
+ def r; return *[*[1]]; end; *a = *r(); assert_equal([1], a)
+ def r; return *[*[1,2]]; end; *a = *r(); assert_equal([1,2], a)
+
+ def r; return; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return nil; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return 1; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c])
+ def r; return []; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return [1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c])
+ def r; return [nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return [[]]; end; a,b,*c = r(); assert_equal([[],nil,[]], [a,b,c])
+ def r; return [1,2]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c])
+ def r; return [*[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return [*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c])
+ def r; return [*[1,2]]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c])
+
+ def r; return *nil; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return *1; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c])
+ def r; return *[]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return *[1]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c])
+ def r; return *[nil]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return *[[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return *[1,2]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c])
+ def r; return *[*[]]; end; a,b,*c = r(); assert_equal([nil,nil,[]], [a,b,c])
+ def r; return *[*[1]]; end; a,b,*c = r(); assert_equal([1,nil,[]], [a,b,c])
+ def r; return *[*[1,2]]; end; a,b,*c = r(); assert_equal([1,2,[]], [a,b,c])
end
def test_lambda
@@ -264,37 +292,48 @@ class TestAssignment < Test::Unit::TestCase
a = loop do break [*[1]]; end; assert_equal([1], a)
a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
- a = loop do break *[]; end; assert_equal([], a)
- a = loop do break *[1]; end; assert_equal([1], a)
- a = loop do break *[nil]; end; assert_equal([nil], a)
- a = loop do break *[[]]; end; assert_equal([[]], a)
- a = loop do break *[*[]]; end; assert_equal([], a)
- a = loop do break *[*[1]]; end; assert_equal([1], a)
+ a = loop do break *nil; end; assert_nil(a)
+ a = loop do break *1; end; assert_equal(1, a)
+ a = loop do break *[]; end; assert_nil(a)
+ a = loop do break *[1]; end; assert_equal(1, a)
+ a = loop do break *[nil]; end; assert_nil(a)
+ a = loop do break *[[]]; end; assert_equal([], a)
+ a = loop do break *[*[]]; end; assert_nil(a)
+ a = loop do break *[*[1]]; end; assert_equal(1, a)
a = loop do break *[*[1,2]]; end; assert_equal([1,2], a)
*a = loop do break; end; assert_equal([nil], a)
*a = loop do break nil; end; assert_equal([nil], a)
*a = loop do break 1; end; assert_equal([1], a)
- *a = loop do break []; end; assert_equal([], a)
- *a = loop do break [1]; end; assert_equal([1], a)
- *a = loop do break [nil]; end; assert_equal([nil], a)
- *a = loop do break [[]]; end; assert_equal([[]], a)
- *a = loop do break [1,2]; end; assert_equal([1,2], a)
- *a = loop do break [*[]]; end; assert_equal([], a)
- *a = loop do break [*[1]]; end; assert_equal([1], a)
- *a = loop do break [*[1,2]]; end; assert_equal([1,2], a)
-
- *a = loop do break *[]; end; assert_equal([], a)
+ *a = loop do break []; end; assert_equal([[]], a)
+ *a = loop do break [1]; end; assert_equal([[1]], a)
+ *a = loop do break [nil]; end; assert_equal([[nil]], a)
+ *a = loop do break [[]]; end; assert_equal([[[]]], a)
+ *a = loop do break [1,2]; end; assert_equal([[1,2]], a)
+ *a = loop do break [*[]]; end; assert_equal([[]], a)
+ *a = loop do break [*[1]]; end; assert_equal([[1]], a)
+ *a = loop do break [*[1,2]]; end; assert_equal([[1,2]], a)
+
+ *a = loop do break *nil; end; assert_equal([nil], a)
+ *a = loop do break *1; end; assert_equal([1], a)
+ *a = loop do break *[]; end; assert_equal([nil], a)
*a = loop do break *[1]; end; assert_equal([1], a)
*a = loop do break *[nil]; end; assert_equal([nil], a)
*a = loop do break *[[]]; end; assert_equal([[]], a)
- *a = loop do break *[1,2]; end; assert_equal([1,2], a)
- *a = loop do break *[*[]]; end; assert_equal([], a)
+ *a = loop do break *[1,2]; end; assert_equal([[1,2]], a)
+ *a = loop do break *[*[]]; end; assert_equal([nil], a)
*a = loop do break *[*[1]]; end; assert_equal([1], a)
- *a = loop do break *[*[1,2]]; end; assert_equal([1,2], a)
-
- *a = *loop do break *[[]]; end; assert_equal([[]], a)
+ *a = loop do break *[*[1,2]]; end; assert_equal([[1,2]], a)
+
+ *a = *loop do break *nil; end; assert_equal([nil], a)
+ *a = *loop do break *1; end; assert_equal([1], a)
+ *a = *loop do break *[]; end; assert_equal([nil], a)
+ *a = *loop do break *[1]; end; assert_equal([1], a)
+ *a = *loop do break *[nil]; end; assert_equal([nil], a)
+ *a = *loop do break *[[]]; end; assert_equal([], a)
*a = *loop do break *[1,2]; end; assert_equal([1,2], a)
+ *a = *loop do break *[*[]]; end; assert_equal([nil], a)
+ *a = *loop do break *[*[1]]; end; assert_equal([1], a)
*a = *loop do break *[*[1,2]]; end; assert_equal([1,2], a)
a,b,*c = loop do break; end; assert_equal([nil,nil,[]], [a,b,c])
@@ -309,10 +348,12 @@ class TestAssignment < Test::Unit::TestCase
a,b,*c = loop do break [*[1]]; end; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = loop do break [*[1,2]]; end; assert_equal([1,2,[]], [a,b,c])
+ a,b,*c = loop do break *nil; end; assert_equal([nil,nil,[]], [a,b,c])
+ a,b,*c = loop do break *1; end; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = loop do break *[]; end; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = loop do break *[1]; end; assert_equal([1,nil,[]], [a,b,c])
a,b,*c = loop do break *[nil]; end; assert_equal([nil,nil,[]], [a,b,c])
- a,b,*c = loop do break *[[]]; end; assert_equal([[],nil,[]], [a,b,c])
+ a,b,*c = loop do break *[[]]; end; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = loop do break *[1,2]; end; assert_equal([1,2,[]], [a,b,c])
a,b,*c = loop do break *[*[]]; end; assert_equal([nil,nil,[]], [a,b,c])
a,b,*c = loop do break *[*[1]]; end; assert_equal([1,nil,[]], [a,b,c])
@@ -332,34 +373,40 @@ class TestAssignment < Test::Unit::TestCase
r([1]){next [*[1]]}
r([1,2]){next [*[1,2]]}
- r([]){next *[]}
- r([1]){next *[1]}
- r([nil]){next *[nil]}
- r([[]]){next *[[]]}
- r([]){next *[*[]]}
- r([1]){next *[*[1]]}
+ r(nil){next *nil}
+ r(1){next *1}
+ r(nil){next *[]}
+ r(1){next *[1]}
+ r(nil){next *[nil]}
+ r([]){next *[[]]}
+ r(nil){next *[*[]]}
+ r(1){next *[*[1]]}
r([1,2]){next *[*[1,2]]}
- undef r
def r(val); *a = yield(); assert_equal(val, a); end
r([nil]){next}
r([nil]){next nil}
r([1]){next 1}
- r([]){next []}
- r([1]){next [1]}
- r([nil]){next [nil]}
- r([[]]){next [[]]}
- r([1,2]){next [1,2]}
- r([]){next [*[]]}
- r([1]){next [*[1]]}
- r([1,2]){next [*[1,2]]}
- undef r
+ r([[]]){next []}
+ r([[1]]){next [1]}
+ r([[nil]]){next [nil]}
+ r([[[]]]){next [[]]}
+ r([[1,2]]){next [1,2]}
+ r([[]]){next [*[]]}
+ r([[1]]){next [*[1]]}
+ r([[1,2]]){next [*[1,2]]}
def r(val); *a = *yield(); assert_equal(val, a); end
- r([[]]){next *[[]]}
+ r([nil]){next *nil}
+ r([1]){next *1}
+ r([nil]){next *[]}
+ r([1]){next *[1]}
+ r([nil]){next *[nil]}
+ r([]){next *[[]]}
r([1,2]){next *[1,2]}
+ r([nil]){next *[*[]]}
+ r([1]){next *[*[1]]}
r([1,2]){next *[*[1,2]]}
- undef r
def r(val); a,b,*c = yield(); assert_equal(val, [a,b,c]); end
r([nil,nil,[]]){next}
@@ -373,66 +420,40 @@ class TestAssignment < Test::Unit::TestCase
r([nil,nil,[]]){next [*[]]}
r([1,nil,[]]){next [*[1]]}
r([1,2,[]]){next [*[1,2]]}
- undef r
def r(val); a,b,*c = *yield(); assert_equal(val, [a,b,c]); end
- r([[],nil,[]]){next *[[]]}
+ r([nil,nil,[]]){next *nil}
+ r([1,nil,[]]){next *1}
+ r([nil,nil,[]]){next *[]}
+ r([1,nil,[]]){next *[1]}
+ r([nil,nil,[]]){next *[nil]}
+ r([nil,nil,[]]){next *[[]]}
r([1,2,[]]){next *[1,2]}
+ r([nil,nil,[]]){next *[*[]]}
+ r([1,nil,[]]){next *[*[1]]}
r([1,2,[]]){next *[*[1,2]]}
- undef r
end
- def test_massign
+ def test_assign2
a = nil
assert(defined?(a))
assert_nil(a)
# multiple asignment
a, b = 1, 2
- assert_equal 1, a
- assert_equal 2, b
-
- a, b, c = 1, 2, 3
- assert_equal 1, a
- assert_equal 2, b
- assert_equal 3, c
+ assert(a == 1 && b == 2)
- a = 1
- b = 2
a, b = b, a
- assert_equal 2, a
- assert_equal 1, b
-
- a, = 1, 2
- assert_equal 1, a
-
- a, = 1, 2, 3
- assert_equal 1, a
+ assert(a == 2 && b == 1)
- a, * = 1, 2, 3
- assert_equal 1, a
+ a, = 1,2
+ assert_equal(1, a)
a, *b = 1, 2, 3
- assert_equal 1, a
- assert_equal [2, 3], b
-
- # not supported yet
- #a, *b, c = 1, 2, 3, 4
- #assert_equal 1, a
- #assert_equal [2,3], b
- #assert_equal 4, c
-
- a = 1, 2
- assert_equal [1, 2], a
-
- a = [1, 2], [3, 4]
- assert_equal [[1,2], [3,4]], a
+ assert(a == 1 && b == [2, 3])
a, (b, c), d = 1, [2, 3], 4
- assert_equal 1, a
- assert_equal 2, b
- assert_equal 3, c
- assert_equal 4, d
+ assert(a == 1 && b == 2 && c == 3 && d == 4)
*a = 1, 2, 3
assert_equal([1, 2, 3], a)
@@ -442,246 +463,5 @@ class TestAssignment < Test::Unit::TestCase
*a = nil
assert_equal([nil], a)
-
- a, b = 1
- assert_equal 1, a
- assert_nil b
-
- a, b = [1, 2]
- assert_equal 1, a
- assert_equal 2, b
- end
-
- def test_nested_massign
- (a, b), c = [[1, 2], 3]; assert_equal [1,2,3], [a,b,c]
- a, (b, c) = [[1, 2], 3]; assert_equal [[1,2], 3, nil], [a,b,c]
- a, (b, c) = [1, [2, 3]]; assert_equal [1,2,3], [a,b,c]
- (a, b), *c = [[1, 2], 3]; assert_equal [1,2,[3]], [a,b,c]
- (a,b),c,(d,e) = [[1,2],3,[4,5]]; assert_equal [1,2,3,4,5],[a,b,c,d,e]
- (a,*b),c,(d,e,*) = [[1,2],3,[4,5]]; assert_equal [1,[2],3,4,5],[a,b,c,d,e]
- (a,b),c,(d,*e) = [[1,2,3],4,[5,6,7,8]]; assert_equal [1,2,4,5,[6,7,8]],[a,b,c,d,e]
- (a,(b1,b2)),c,(d,e) = [[1,2],3,[4,5]]; assert_equal [1,2,nil,3,4,5],[a,b1,b2,c,d,e]
- (a,(b1,b2)),c,(d,e) = [[1,[21,22]],3,[4,5]]; assert_equal [1,21,22,3,4,5],[a,b1,b2,c,d,e]
- end
-
- class MyObj
- def to_ary
- [[1,2],[3,4]]
- end
- end
-
- def test_to_ary_splat
- a, b = MyObj.new
- assert_equal [[1,2],[3,4]], [a,b]
- end
-
- A = 1
- B = 2
- X, Y = A, B
- class Base
- A = 3
- B = 4
- end
-
- def test_const_massign
- assert_equal [1,2], [X,Y]
- a, b = Base::A, Base::B
- assert_equal [3,4], [a,b]
- end
-end
-
-require 'sentence'
-class TestAssignmentGen < Test::Unit::TestCase
- Syntax = {
- :exp => [["0"],
- ["nil"],
- ["false"],
- ["[]"],
- ["[",:exps,"]"]],
- :exps => [[:exp],
- [:exp,",",:exps]],
- :arg => [[:exp]],
- :mrhs => [[:args,",",:arg],
- [:args,",","*",:arg],
- ["*",:arg]],
- :args => [[:arg],
- ["*",:arg],
- [:args,",",:arg],
- [:args,",","*",:arg]],
- :mlhs => [[:mlhs_basic],
- ["(",:mlhs_inner,")"]],
- :mlhs_inner => [[:mlhs_basic],
- ["(",:mlhs_inner,")"]],
- :mlhs_basic => [[:mlhs_head],
- [:mlhs_head,:mlhs_item],
- [:mlhs_head,"*",:mlhs_node],
- [:mlhs_head,"*",:mlhs_node,",",:mlhs_post],
- [:mlhs_head,"*"],
- [:mlhs_head,"*",",", :mlhs_post],
- [ "*",:mlhs_node],
- [ "*",:mlhs_node,",",:mlhs_post],
- [ "*"],
- [ "*",",", :mlhs_post]],
- :mlhs_head => [[:mlhs_item,","],
- [:mlhs_head,:mlhs_item,","]],
- :mlhs_post => [[:mlhs_item],
- [:mlhs_post,",",:mlhs_item]],
- :mlhs_item => [[:mlhs_node],
- ["(",:mlhs_inner,")"]],
- :mlhs_node => [["var"]],
- :xassign => [["var"," = ",:exp],
- ["var"," = ",:mrhs],
- [:mlhs," = ",:exp],
- [:mlhs," = ",:mrhs]],
- }
-
- def rename_var(obj)
- vars = []
- r = obj.subst('var') {
- var = "v#{vars.length}"
- vars << var
- var
- }
- return r, vars
- end
-
- def expand_except_paren(obj)
- return obj if obj.respond_to? :to_str
- obj.expand {|s|
- !(s[0] == '(' && s[-1] == ')') &&
- !(s[0] == '[' && s[-1] == ']')
- }
- end
-
- def extract_single_element(ary)
- raise "not a single element array: #{ary.inspect}" if ary.length != 1
- ary[0]
- end
-
- def emu_assign_ary(lhs, rv, h)
- rv = rv.respond_to?(:to_ary) ? rv : [rv]
- rv = rv.dup
- a = [[]]
- lhs.each {|e|
- if e == ','
- a << []
- else
- a.last << e
- end
- }
- a.pop if a.last == []
- pre = []
- star = post = nil
- a.each {|e|
- if post
- post << e
- elsif e[0] == '*'
- star = e
- post = []
- else
- pre << e
- end
- }
- pre.map! {|e| extract_single_element(e) }
- if star
- if star == ['*']
- star = nil
- else
- star = extract_single_element(star[1..-1])
- end
- end
- post.map! {|e| extract_single_element(e) } if post
-
- until pre.empty?
- emu_assign_single(pre.shift, rv.shift, h)
- end
-
- if post
- if rv.length < post.length
- until post.empty?
- emu_assign_single(post.shift, rv.shift, h)
- end
- else
- until post.empty?
- emu_assign_single(post.pop, rv.pop, h)
- end
- end
- end
-
- if star
- emu_assign_single(star, rv, h)
- end
- end
-
- def emu_assign_single(lhs, rv, h={})
- if lhs.respond_to? :to_str
- if /\A[a-z0-9]+\z/ =~ lhs
- h[lhs] = rv
- else
- raise "unexpected lhs string: #{lhs.inspect}"
- end
- elsif Sentence === lhs
- if lhs[0] == '(' && lhs[-1] == ')'
- emu_assign_ary(lhs[1...-1], rv, h)
- elsif lhs.length == 1 && String === lhs[0] && /\A[a-z0-9]+\z/ =~ lhs[0]
- h[lhs[0]] = rv
- else
- raise "unexpected lhs sentence: #{lhs.inspect}"
- end
- else
- raise "unexpected lhs: #{lhs.inspect}"
- end
- h
- end
-
- def emu_assign(assign)
- lhs = expand_except_paren(assign[0])
- rhs = expand_except_paren(assign[2])
- lopen = Sentence === lhs && lhs[-1] != ')' && lhs.any? {|e| e == '*' || e == ',' }
- ropen = Sentence === rhs && rhs[-1] != ']' && rhs.any? {|e| e == '*' || e == ',' }
- lhs = Sentence.new(['(']+lhs.to_a+[')']) if lopen
- begin
- rv = eval((ropen ? ["[",assign[2],"]"] : assign[2]).join(''))
- rescue Exception
- rv = $!.message
- end
- emu_assign_single(lhs, rv)
- end
-
- def do_assign(assign, vars)
- assign = assign.to_s
- code1 = "#{assign}; [#{vars.join(",")}]"
- assign.gsub!(/\bv\d+\b/, "o.a")
- code2 = "o=[];class << o; self end.send(:define_method,:a=){|v|self << v};#{assign};o"
- begin
- vals1 = eval(code1)
- rescue Exception
- return {:ex=>$!.message}
- end
- begin
- vals2 = eval(code2)
- rescue Exception
- return {:ex=>$!.message}
- end
- assert_equal(vals1, vals2, code1)
- vals = vals1
- h = {}
- [vars, vals].transpose.each {|k,v| h[k] = v }
- h
- end
-
- def check(assign)
- assign, vars = rename_var(assign)
- sent = assign.to_s
- bruby = do_assign(assign, vars).to_a.sort
- bemu = emu_assign(assign).to_a.sort
- assert_equal(bemu, bruby, sent)
- end
-
- def test_assignment
- syntax = Sentence.expand_syntax(Syntax)
- Sentence.each(syntax, :xassign, 4) {|assign|
- check(assign)
- }
end
end
diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb
deleted file mode 100644
index 6ac93e037a..0000000000
--- a/test/ruby/test_basicinstructions.rb
+++ /dev/null
@@ -1,628 +0,0 @@
-require 'test/unit'
-
-ConstTest = 3
-class Class
- alias _remove_const remove_const
- public :_remove_const
-end
-
-class TestBasicInstructions < Test::Unit::TestCase
-
- def test_immediates
- assert_equal((1==1), true)
- assert_equal((1==2), false)
- assert_equal [][0], nil
- assert_equal "sym".intern, :sym
- assert_equal "sym".intern, :"sym"
- assert_equal 1234 + 0, 1234
- assert_equal 1234, 1_2_3_4
- assert_equal 41, 0b0101001
- assert_equal 420, 0644
- assert_equal 18, 0x12
- assert_equal 123456789012345678901234567890 + 0,
- 123456789012345678901234567890
- assert_equal 1.234 + 0.0, 1.234
- end
-
- def test_self
- assert_equal self, self
- assert_equal false, (self == false) # Qfalse==0 in C
- assert_equal false, (self == nil)
- assert_equal false, (self == 0)
- end
-
- def test_string
- expected = "str" + "ing"
- assert_equal expected, 'string'
- assert_equal expected, "string"
- assert_equal expected, %q(string)
- assert_equal expected, %Q(string)
- assert_equal expected, %(string)
- end
-
- def test_dstring
- assert_equal "2", "#{1+1}"
- s = "OK"
- assert_equal "OK", "#{s}"
- assert_equal "OKx", "#{s}x"
- assert_equal "xOK", "x#{s}"
- assert_equal "xOKx", "x#{s}x"
- end
-
- def test_dsym
- assert_equal :a3c, :"a#{1+2}c"
- s = "sym"
- assert_equal :sym, :"#{s}"
- assert_equal :sym, :"#{"#{"#{s}"}"}"
- end
-
- def test_xstr
- assert_equal 'hoge', `echo hoge`.chomp
- assert_equal '3', `echo #{1 + 2}`.chomp
- hoge = 'huga'
- assert_equal 'huga', `echo #{hoge}`.chomp
- end
-
- def test_regexp
- assert_equal /test/, /test/
- assert_equal 'test', /test/.source
- assert_equal 'TEST', /TEST/.source
- assert_equal true, !!(/test/ =~ 'test')
- assert_equal false, !!(/test/ =~ 'does not match')
-
- re = /test/
- assert_equal re, re
- assert_equal 'test', re.source
- assert_equal true, !!(re =~ 'test')
- assert_equal false, !!(re =~ 'does not match')
-
- assert_equal /x#{1+1}x/, /x#{1+1}x/
- s = "OK"
- assert_equal /x#{s}x/, /x#{s}x/
- assert_equal true, !!(/x#{s}x/ =~ "xOKx")
- assert_equal false, !!(/x#{s}x/ =~ "does not match")
-
- s = "OK"
- prev = nil
- 3.times do
- assert_equal prev.object_id, (prev ||= /#{s}/o).object_id if prev
- end
- end
-
- def test_array
- assert_equal [], []
- assert_equal 0, [].size
- assert_equal [1, 2, 3], [1, 2, 3]
- assert_equal [3, 7, 11], [1+2, 3+4, 5+6]
- assert_equal [[1], [2], [3]], [[1], [2], [3]]
-
- a = [1, 2, 3]
- assert_equal 1, a[0]
- assert_equal 2, a[1]
- assert_equal 3, a[2]
- assert_nil a[3]
-
- a = %w( a b c )
- assert_equal 'a', a[0]
- assert_equal 'b', a[1]
- assert_equal 'c', a[2]
- assert_nil a[3]
- end
-
- def test_hash
- assert_equal({}, {})
- assert_equal({1=>2}, {1=>2})
- assert_equal({1=>2, 3=>4}, {1=>2, 3=>4})
- assert_equal({1=>2, 3=>4}, {3=>4, 1=>2})
- # assert_equal({1=>2, 3=>4}, {1,2, 3,4}) # 1.9 doesn't support
- assert_equal({"key"=>"val"}, {"key"=>"val"})
- end
-
- def test_range
- assert_equal((1..3), (1..3))
- assert_equal((1...3), (1...3))
- assert_not_equal((1...3), (1..3))
- assert_not_equal((1..3), (1...3))
- assert_equal((1..3), (1..2+1))
- assert_equal((1...3), (1...2+1))
- assert_equal(('a'..'z'), ('a'..'z'))
- end
-
- def test_not
- assert_equal true, !nil
- assert_equal true, !false
- assert_equal false, !true
- assert_equal false, !3
- assert_equal false, !(1+1)
-
- assert_equal false, !!nil
- assert_equal false, !!false
- assert_equal true, !!true
- assert_equal true, !!3
- assert_equal true, !!(1+1)
-
- assert_equal true, (not nil)
- assert_equal true, (not false)
- assert_equal false, (not true)
- assert_equal false, (not 3)
- assert_equal false, (not (1 + 1))
-
- assert_equal false, (not not nil)
- assert_equal false, (not not false)
- assert_equal true, (not not true)
- assert_equal true, (not not 3)
- assert_equal true, (not not (1+1))
- end
-
- def test_local_variable
- a = 7
- assert_equal 7, a
- assert_equal a, a
- b = 17
- assert_equal 7, a
- assert_equal 17, b
- assert_equal a, a
- assert_equal b, b
- assert_not_equal a, b
- assert_not_equal b, a
- a = b
- assert_equal 17, a
- assert_equal 17, b
- assert_equal a, a
- assert_equal b, b
- assert_equal a, b
- assert_equal b, a
- c = 28
- assert_equal 17, a
- assert_equal 17, b
- assert_equal 28, c
- assert_equal a, a
- assert_equal b, b
- assert_equal a, b
- assert_equal c, c
- assert_not_equal a, c
- assert_not_equal b, c
- a = b = c
- assert_equal 28, a
- assert_equal 28, b
- assert_equal 28, c
- assert_equal a, a
- assert_equal b, b
- assert_equal a, b
- assert_equal b, a
- assert_equal a, c
- assert_equal c, a
- assert_equal b, c
- assert_equal c, b
-
- a = 1
- b = 2
- c = 3
- set_lvar_in_another_method
- assert_equal 1, a
- assert_equal 2, b
- assert_equal 3, c
- end
-
- def set_lvar_in_another_method
- assert_raise(NameError) { a }
- assert_raise(NameError) { b }
- assert_raise(NameError) { c }
- a = "NOT OK"
- b = "NOT OK"
- c = "NOT OK"
- end
-
- class Const
- $Const = self
- C = 'Const::C'
- def self.c() C end
- def c() C end
-
- class A
- C = 'Const::A::C'
- def self.c() C end
- def c() C end
- CC = 'Const::A::CC'
- def self.cc() CC end
- def cc() CC end
-
- class B
- C = 'Const::A::B::C'
- def self.c() C end
- def c() C end
- def self.cc() CC end
- def cc() CC end
- end
- end
-
- class AA < A
- def self.cc() CC end
- def cc() CC end
- end
-
- class AAA < AA
- def self.cc() CC end
- def cc() CC end
- end
- end
- C = 0
-
- def test_const_path
- do_test_const_path
- do_test_const_path
- do_test_const_path
- end
-
- def do_test_const_path
- assert_equal 0, C
- assert_equal 0, C
- assert_equal 3, ::ConstTest
- assert_equal 3, ::ConstTest
- assert_equal $Const, Const
-
- assert_equal 'Const::C', Const::C
- assert_equal 'Const::C', Const::C
- assert_equal 'Const::A::C', Const::A::C
- assert_equal 'Const::A::C', Const::A::C
- assert_equal 'Const::A::B::C', Const::A::B::C
- assert_equal 'Const::A::B::C', Const::A::B::C
-
- Const::A::B._remove_const :C
- assert_equal 'Const::C', Const::C
- assert_equal 'Const::A::C', Const::A::C
- assert_raise(NameError) { Const::A::B::C }
-
- Const::A._remove_const :C
- assert_equal 'Const::C', Const::C
- assert_raise(NameError) { Const::A::C }
- assert_raise(NameError) { Const::A::B::C }
-
- Const._remove_const :C
- assert_raise(NameError) { Const::C }
- assert_raise(NameError) { Const::A::C }
- assert_raise(NameError) { Const::A::B::C }
-
- Const::A.const_set :C, 'Const::A::C'
- assert_raise(NameError) { Const::C }
- assert_equal 'Const::A::C', Const::A::C
- assert_raise(NameError) { Const::A::B::C }
-
- Const::A::B.const_set :C, 'Const::A::B::C'
- assert_raise(NameError) { Const::C }
- assert_equal 'Const::A::C', Const::A::C
- assert_equal 'Const::A::B::C', Const::A::B::C
-
- Const.const_set :C, 'Const::C'
- assert_equal 'Const::C', Const::C
- assert_equal 'Const::A::C', Const::A::C
- assert_equal 'Const::A::B::C', Const::A::B::C
- end
-
- def test_const_cref
- do_test_const_cref
- do_test_const_cref
- do_test_const_cref
- end
-
- def do_test_const_cref
- assert_equal 'Const::C', Const.new.c
- assert_equal 'Const::A::C', Const::A.new.c
- assert_equal 'Const::A::B::C', Const::A::B.new.c
-
- assert_equal 'Const::C', Const.c
- assert_equal 'Const::A::C', Const::A.c
- assert_equal 'Const::A::B::C', Const::A::B.c
-
- Const::A::B._remove_const :C
- assert_equal 'Const::C', Const.c
- assert_equal 'Const::A::C', Const::A.c
- assert_equal 'Const::A::C', Const::A::B.c
- assert_equal 'Const::C', Const.new.c
- assert_equal 'Const::A::C', Const::A.new.c
- assert_equal 'Const::A::C', Const::A::B.new.c
-
- Const::A._remove_const :C
- assert_equal 'Const::C', Const.c
- assert_equal 'Const::C', Const::A.c
- assert_equal 'Const::C', Const::A::B.c
- assert_equal 'Const::C', Const.new.c
- assert_equal 'Const::C', Const::A.new.c
- assert_equal 'Const::C', Const::A::B.new.c
-
- Const::A::B.const_set :C, 'Const::A::B::C'
- assert_equal 'Const::C', Const.c
- assert_equal 'Const::C', Const::A.c
- assert_equal 'Const::A::B::C', Const::A::B.c
- assert_equal 'Const::C', Const.new.c
- assert_equal 'Const::C', Const::A.new.c
- assert_equal 'Const::A::B::C', Const::A::B.new.c
-
- Const::A.const_set :C, 'Const::A::C'
- assert_equal 'Const::C', Const.c
- assert_equal 'Const::A::C', Const::A.c
- assert_equal 'Const::A::B::C', Const::A::B.c
- assert_equal 'Const::C', Const.new.c
- assert_equal 'Const::A::C', Const::A.new.c
- assert_equal 'Const::A::B::C', Const::A::B.new.c
- ensure
- # reset
- Const.const_set :C, 'Const::C' unless Const.const_defined?(:C)
- Const::A.const_set :C, 'Const::A::C' unless Const::A.const_defined?(:C)
- Const::A::B.const_set :C, 'Const::A::B::C' unless Const::A::B.const_defined?(:C)
- end
-
- def test_const_inherit
- do_test_const_inherit
- do_test_const_inherit
- do_test_const_inherit
- end
-
- def do_test_const_inherit
- assert_equal 'Const::A::CC', Const::A.cc
- assert_equal 'Const::A::CC', Const::AA.cc
- assert_equal 'Const::A::CC', Const::AAA.cc
- assert_equal 'Const::A::CC', Const::A.new.cc
- assert_equal 'Const::A::CC', Const::AA.new.cc
- assert_equal 'Const::A::CC', Const::AAA.new.cc
-
- Const::AA.const_set :CC, 'Const::AA::CC'
- assert_equal 'Const::A::CC', Const::A.cc
- assert_equal 'Const::AA::CC', Const::AA.cc
- assert_equal 'Const::AA::CC', Const::AAA.cc
- assert_equal 'Const::A::CC', Const::A.new.cc
- assert_equal 'Const::AA::CC', Const::AA.new.cc
- assert_equal 'Const::AA::CC', Const::AAA.new.cc
-
- Const::AAA.const_set :CC, 'Const::AAA::CC'
- assert_equal 'Const::A::CC', Const::A.cc
- assert_equal 'Const::AA::CC', Const::AA.cc
- assert_equal 'Const::AAA::CC', Const::AAA.cc
- assert_equal 'Const::A::CC', Const::A.new.cc
- assert_equal 'Const::AA::CC', Const::AA.new.cc
- assert_equal 'Const::AAA::CC', Const::AAA.new.cc
-
- Const::AA._remove_const :CC
- assert_equal 'Const::A::CC', Const::A.cc
- assert_equal 'Const::A::CC', Const::AA.cc
- assert_equal 'Const::AAA::CC', Const::AAA.cc
- assert_equal 'Const::A::CC', Const::A.new.cc
- assert_equal 'Const::A::CC', Const::AA.new.cc
- assert_equal 'Const::AAA::CC', Const::AAA.new.cc
-
- Const::AAA._remove_const :CC
- assert_equal 'Const::A::CC', Const::A.cc
- assert_equal 'Const::A::CC', Const::AA.cc
- assert_equal 'Const::A::CC', Const::AAA.cc
- assert_equal 'Const::A::CC', Const::A.new.cc
- assert_equal 'Const::A::CC', Const::AA.new.cc
- assert_equal 'Const::A::CC', Const::AAA.new.cc
- end
-
- def test_global_variable
- $gvar1 = 1
- assert_equal 1, $gvar1
- $gvar1 = 2
- assert_equal 2, $gvar1
- $gvar2 = 77
- assert_equal 2, $gvar1
- assert_equal 77, $gvar2
- $gvar2 = $gvar1
- assert_equal 2, $gvar1
- assert_equal 2, $gvar2
- $gvar1 = 1
- assert_equal 1, $gvar1
- assert_equal 2, $gvar2
- set_gvar_in_another_method
- assert_equal "OK1", $gvar1
- assert_equal "OK2", $gvar2
- end
-
- def set_gvar_in_another_method
- assert_equal 1, $gvar1
- assert_equal 2, $gvar2
- $gvar1 = "OK1"
- $gvar2 = "OK2"
- end
-
- class CVarA
- @@cv = 'CVarA@@cv'
- def self.cv() @@cv end
- def self.cv=(v) @@cv = v end
- class << self
- def cv2() @@cv end
- end
- def cv() @@cv end
- def cv=(v) @@cv = v end
- end
-
- class CVarB < CVarA
- def self.cvB() @@cv end
- def self.cvB=(v) @@cv = v end
- class << self
- def cvB2() @@cv end
- end
- def cvB() @@cv end
- def cvB=(v) @@cv = v end
- end
-
- def test_class_variable
- assert_equal 'CVarA@@cv', CVarA.cv
- assert_equal 'CVarA@@cv', CVarA.cv2
- assert_equal 'CVarA@@cv', CVarA.new.cv
- CVarA.cv = 'singleton'
- assert_equal 'singleton', CVarA.cv
- assert_equal 'singleton', CVarA.cv2
- assert_equal 'singleton', CVarA.new.cv
- CVarA.new.cv = 'instance'
- assert_equal 'instance', CVarA.cv
- assert_equal 'instance', CVarA.cv2
- assert_equal 'instance', CVarA.new.cv
-
- CVarA.cv = 'CVarA@@cv'
- CVarB.cv = 'B/singleton'
- assert_equal 'B/singleton', CVarB.cv
- assert_equal 'B/singleton', CVarB.cv2
- assert_equal 'B/singleton', CVarB.new.cv
- assert_equal 'B/singleton', CVarA.cv
- assert_equal 'B/singleton', CVarA.cv2
- assert_equal 'B/singleton', CVarA.new.cv
- CVarB.new.cv = 'B/instance'
- assert_equal 'B/instance', CVarB.cv
- assert_equal 'B/instance', CVarB.cv2
- assert_equal 'B/instance', CVarB.new.cv
- assert_equal 'B/instance', CVarA.cv
- assert_equal 'B/instance', CVarA.cv2
- assert_equal 'B/instance', CVarA.new.cv
-
- CVarA.cv = 'CVarA@@cv'
- assert_equal('CVarA@@cv', CVarB.cvB)
- assert_equal('CVarA@@cv', CVarB.cvB2)
- assert_equal('CVarA@@cv', CVarB.new.cvB)
- CVarB.cvB = 'B/singleton'
- assert_equal 'B/singleton', CVarB.cvB
- assert_equal 'B/singleton', CVarB.cvB2
- assert_equal 'B/singleton', CVarB.new.cvB
- assert_equal 'B/singleton', CVarA.cv
- assert_equal 'B/singleton', CVarA.cv2
- assert_equal 'B/singleton', CVarA.new.cv
- CVarB.new.cvB = 'B/instance'
- assert_equal 'B/instance', CVarB.cvB
- assert_equal 'B/instance', CVarB.cvB2
- assert_equal 'B/instance', CVarB.new.cvB
- assert_equal 'B/instance', CVarA.cv
- assert_equal 'B/instance', CVarA.cv2
- assert_equal 'B/instance', CVarA.new.cv
-
- CVarA.cv = 'CVarA@@cv'
- CVarB.cvB = 'CVarB@@cv'
- end
-
- class OP
- attr_accessor :x
- end
-
- def test_opassign
- x = nil
- x ||= 1
- assert_equal 1, x
- x &&= 2
- assert_equal 2, x
- x ||= 3
- assert_equal 2, x
- x &&= 4
- assert_equal 4, x
-
- y = OP.new
- y.x = nil
- y.x ||= 1
- assert_equal 1, y.x
- y.x &&= 2
- assert_equal 2, y.x
- y.x ||= 3
- assert_equal 2, y.x
- y.x &&= 4
- assert_equal 4, y.x
-
- z = OP.new
- z.x = y
- z.x.x = nil
- z.x.x ||= 1
- assert_equal 1, z.x.x
- z.x.x &&= 2
- assert_equal 2, z.x.x
- z.x.x ||= 3
- assert_equal 2, z.x.x
- z.x.x &&= 4
- assert_equal 4, z.x.x
-
- a = []
- a[0] = nil
- a[0] ||= 1
- assert_equal 1, a[0]
- a[0] &&= 2
- assert_equal 2, a[0]
- a[0] ||= 3
- assert_equal 2, a[0]
- a[0] &&= 4
- assert_equal 4, a[0]
- end
-
- def test_backref
- /re/ =~ 'not match'
- assert_nil $~
- assert_nil $`
- assert_nil $&
- assert_nil $'
- assert_nil $+
- assert_nil $1
- assert_nil $2
- assert_nil $3
- assert_nil $4
- assert_nil $5
- assert_nil $6
- assert_nil $7
- assert_nil $8
- assert_nil $9
-
- /(a)(b)(c)(d)(e)(f)(g)(h)(i)/ =~ 'xabcdefghiy'
- assert_not_nil $~
- assert_instance_of MatchData, $~
- assert_equal 'abcdefghi', $~[0]
- assert_equal 'a', $~[1]
- assert_equal 'b', $~[2]
- assert_equal 'c', $~[3]
- assert_equal 'd', $~[4]
- assert_equal 'e', $~[5]
- assert_equal 'f', $~[6]
- assert_equal 'g', $~[7]
- assert_equal 'h', $~[8]
- assert_equal 'i', $~[9]
- assert_equal 'x', $`
- assert_equal 'abcdefghi', $&
- assert_equal 'y', $'
- assert_equal 'i', $+
- assert_equal 'a', $1
- assert_equal 'b', $2
- assert_equal 'c', $3
- assert_equal 'd', $4
- assert_equal 'e', $5
- assert_equal 'f', $6
- assert_equal 'g', $7
- assert_equal 'h', $8
- assert_equal 'i', $9
-
- /re/ =~ 'not match'
- assert_nil $~
- assert_nil $`
- assert_nil $&
- assert_nil $'
- assert_nil $+
- assert_nil $1
- assert_nil $2
- assert_nil $3
- assert_nil $4
- assert_nil $5
- assert_nil $6
- assert_nil $7
- assert_nil $8
- assert_nil $9
- end
-
- def test_array_splat
- a = []
- assert_equal [], [*a]
- assert_equal [1], [1, *a]
- a = [2]
- assert_equal [2], [*a]
- assert_equal [1, 2], [1, *a]
- a = [2, 3]
- assert_equal [2, 3], [*a]
- assert_equal [1, 2, 3], [1, *a]
-
- a = nil
- assert_equal [], [*a]
- assert_equal [1], [1, *a]
- end
-
-end
diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb
index 21b9b4c33f..b5d898d3b6 100644
--- a/test/ruby/test_beginendblock.rb
+++ b/test/ruby/test_beginendblock.rb
@@ -13,7 +13,7 @@ class TestBeginEndBlock < Test::Unit::TestCase
def test_beginendblock
ruby = EnvUtil.rubybin
target = File.join(DIR, 'beginmainend.rb')
- result = IO.popen([ruby, target]){|io|io.read}
+ result = IO.popen("#{q(ruby)} #{q(target)}"){|io|io.read}
assert_equal(%w(b1 b2-1 b2 main b3-1 b3 b4 e1 e4 e3 e2 e4-2 e4-1 e1-1 e4-1-1), result.split)
end
@@ -38,15 +38,16 @@ errout = ARGV.shift
STDERR.reopen(File.open(errout, "w"))
STDERR.sync = true
Dir.chdir(#{q(DIR)})
-system("#{ruby}", "endblockwarn_rb")
+cmd = "\\"#{ruby}\\" \\"endblockwarn.rb\\""
+system(cmd)
EOF
launcher.close
launcherpath = launcher.path
errout.close
erroutpath = errout.path
- system(ruby, launcherpath, erroutpath)
+ system("#{q(ruby)} #{q(launcherpath)} #{q(erroutpath)}")
expected = <<EOW
-endblockwarn_rb:2: warning: END in method; use at_exit
+endblockwarn.rb:2: warning: END in method; use at_exit
(eval):2: warning: END in method; use at_exit
EOW
assert_equal(expected, File.read(erroutpath))
@@ -54,14 +55,15 @@ EOW
end
def test_raise_in_at_exit
+ # [ruby-core:09675]
ruby = EnvUtil.rubybin
- out = IO.popen([ruby, '-e', 'STDERR.reopen(STDOUT)',
- '-e', 'at_exit{raise %[SomethingBad]}',
- '-e', 'raise %[SomethingElse]']) {|f|
+ out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \
+ "at_exit{raise %[SomethingBad]};" \
+ "raise %[SomethingElse]'") {|f|
f.read
}
- assert_match /SomethingBad/, out, "[ruby-core:9675]"
- assert_match /SomethingElse/, out, "[ruby-core:9675]"
+ assert_match /SomethingBad/, out
+ assert_match /SomethingElse/, out
end
def test_should_propagate_exit_code
@@ -73,10 +75,7 @@ EOW
def test_should_propagate_signaled
ruby = EnvUtil.rubybin
- out = IO.popen(
- [ruby,
- '-e', 'STDERR.reopen(STDOUT)',
- '-e', 'at_exit{Process.kill(:INT, $$); loop{}}']) {|f|
+ out = IO.popen("#{ruby} #{File.dirname(__FILE__)}/suicide.rb"){|f|
f.read
}
assert_match /Interrupt$/, out
@@ -84,4 +83,16 @@ EOW
assert_nil $?.exitstatus
assert_equal Signal.list["INT"], $?.termsig
end
+
+ def test_begin_and_eval
+ $test_begin_and_eval = :ok
+ begin
+ eval("BEGIN{$test_begin_and_eval = :ng}\n_/a:a")
+ rescue SyntaxError
+ x1 = x2 = $test_begin_and_eval
+ eval("x2 = $test_begin_and_eval")
+ end
+ assert_equal(:ok, x1)
+ assert_equal(:ok, x2)
+ end
end
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index a264d1cf63..99c5952173 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -85,14 +85,22 @@ class TestBignum < Test::Unit::TestCase
shift_test(-0xfffffffffffffffff)
end
- def test_to_s
- assert_equal("fvvvvvvvvvvvv" ,18446744073709551615.to_s(32), "[ruby-core:10686]")
- assert_equal("g000000000000" ,18446744073709551616.to_s(32), "[ruby-core:10686]")
- assert_equal("3w5e11264sgsf" ,18446744073709551615.to_s(36), "[ruby-core:10686]")
- assert_equal("3w5e11264sgsg" ,18446744073709551616.to_s(36), "[ruby-core:10686]")
- assert_equal("nd075ib45k86f" ,18446744073709551615.to_s(31), "[ruby-core:10686]")
- assert_equal("nd075ib45k86g" ,18446744073709551616.to_s(31), "[ruby-core:10686]")
+ def test_to_s # [ruby-core:10686]
+ assert_equal("fvvvvvvvvvvvv" ,18446744073709551615.to_s(32))
+ assert_equal("g000000000000" ,18446744073709551616.to_s(32))
+ assert_equal("3w5e11264sgsf" ,18446744073709551615.to_s(36))
+ assert_equal("3w5e11264sgsg" ,18446744073709551616.to_s(36))
+ assert_equal("nd075ib45k86f" ,18446744073709551615.to_s(31))
+ assert_equal("nd075ib45k86g" ,18446744073709551616.to_s(31))
assert_equal("1777777777777777777777" ,18446744073709551615.to_s(8))
assert_equal("-1777777777777777777777" ,-18446744073709551615.to_s(8))
end
+
+ def test_too_big_to_s
+ if (big = 2**31-1).is_a?(Fixnum)
+ return
+ end
+ e = assert_raise(RangeError) {(1 << big).to_s}
+ assert_match(/too big to convert/, e.message)
+ end
end
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
deleted file mode 100644
index fa8a40f39b..0000000000
--- a/test/ruby/test_class.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require 'test/unit'
-
-class TestClass < Test::Unit::TestCase
-
- # ------------------
- # Various test classes
- # ------------------
-
- class ClassOne
- attr :num_args
- @@subs = []
- def initialize(*args)
- @num_args = args.size
- @args = args
- end
- def [](n)
- @args[n]
- end
- def ClassOne.inherited(klass)
- @@subs.push klass
- end
- def subs
- @@subs
- end
- end
-
- class ClassTwo < ClassOne
- end
-
- class ClassThree < ClassOne
- end
-
- class ClassFour < ClassThree
- end
-
- # ------------------
- # Start of tests
- # ------------------
-
- def test_s_inherited
- assert_equal([ClassTwo, ClassThree, ClassFour], ClassOne.new.subs)
- end
-
- def test_s_new
- c = Class.new
- assert_same(Class, c.class)
- assert_same(Object, c.superclass)
-
- c = Class.new(Fixnum)
- assert_same(Class, c.class)
- assert_same(Fixnum, c.superclass)
- end
-
- def test_00_new_basic
- a = ClassOne.new
- assert_equal(ClassOne, a.class)
- assert_equal(0, a.num_args)
-
- a = ClassOne.new(1, 2, 3)
- assert_equal(3, a.num_args)
- assert_equal(1, a[0])
- end
-
- def test_01_new_inherited
- a = ClassTwo.new
- assert_equal(ClassTwo, a.class)
- assert_equal(0, a.num_args)
-
- a = ClassTwo.new(1, 2, 3)
- assert_equal(3, a.num_args)
- assert_equal(1, a[0])
- end
-
- def test_superclass
- assert_equal(ClassOne, ClassTwo.superclass)
- assert_equal(Object, ClassTwo.superclass.superclass)
- assert_equal(BasicObject, ClassTwo.superclass.superclass.superclass)
- end
-
-end
diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb
index 3708a5a0ca..8d01379dbd 100644
--- a/test/ruby/test_const.rb
+++ b/test/ruby/test_const.rb
@@ -15,34 +15,19 @@ class TestConst < Test::Unit::TestCase
end
def test_const
- assert defined?(TEST1)
- assert_equal 1, TEST1
- assert defined?(TEST2)
- assert_equal 2, TEST2
-
self.class.class_eval {
include Const
}
- assert defined?(TEST1)
- assert_equal 1, TEST1
- assert defined?(TEST2)
- assert_equal 2, TEST2
- assert defined?(TEST3)
- assert_equal 3, TEST3
- assert defined?(TEST4)
- assert_equal 4, TEST4
+ assert_equal([1,2,3,4], [TEST1,TEST2,TEST3,TEST4])
self.class.class_eval {
include Const2
}
STDERR.print "intentionally redefines TEST3, TEST4\n" if $VERBOSE
- assert defined?(TEST1)
- assert_equal 1, TEST1
- assert defined?(TEST2)
- assert_equal 2, TEST2
- assert defined?(TEST3)
- assert_equal 6, TEST3
- assert defined?(TEST4)
- assert_equal 8, TEST4
+ assert_equal([1,2,6,8], [TEST1,TEST2,TEST3,TEST4])
+
+ assert_equal(-1, (String <=> Object))
+ assert_equal(1, (Object <=> String))
+ assert_equal(nil, (Array <=> String))
end
end
diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb
deleted file mode 100644
index 0313d71249..0000000000
--- a/test/ruby/test_continuation.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require 'test/unit'
-require 'continuation'
-require 'fiber'
-
-class TestContinuation < Test::Unit::TestCase
- def test_create
- assert_equal(:ok, callcc{:ok})
- assert_equal(:ok, callcc{|c| c.call :ok})
- end
-
- def test_call
- assert_equal(:ok, callcc{|c| c.call :ok})
-
- ary = []
- ary << callcc{|c|
- @cont = c
- :a
- }
- @cont.call :b if ary.length < 3
- assert_equal([:a, :b, :b], ary)
- end
-
- def test_check_localvars
- vv = 0
- @v = 0
- @ary = []
- [1, 2, 3].each{|i|
- callcc {|k| @k = k}
- @v += 1
- vv += 1
- }
- @ary << [vv, @v]
- @k.call if @v < 10
- assert_equal((3..10).map{|e| [e, e]}, @ary)
- end
-
- def test_error
- cont = callcc{|c| c}
- assert_raise(RuntimeError){
- Thread.new{cont.call}.join
- }
- assert_raise(LocalJumpError){
- callcc
- }
- assert_raise(RuntimeError){
- c = nil
- Fiber.new do
- callcc {|c2| c = c2 }
- end.resume
- c.call
- }
- end
-end
-
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb
index bfcd7fb667..8a7fcf45a9 100644
--- a/test/ruby/test_defined.rb
+++ b/test/ruby/test_defined.rb
@@ -10,8 +10,6 @@ class TestDefined < Test::Unit::TestCase
yield(defined?(self.foo))
yield(defined?(f.foo))
end
- def baz(f)
- end
end
def defined_test
@@ -36,46 +34,10 @@ class TestDefined < Test::Unit::TestCase
assert(defined?(1 == 2)) # operator expression
f = Foo.new
- assert_nil(defined?(f.foo)) # protected method
+ assert_nil(defined?(f.foo))
f.bar(f) { |v| assert(v) }
- assert_nil(defined?(f.quux)) # undefined method
- assert_nil(defined?(f.baz(x))) # undefined argument
- x = 0
- assert(defined?(f.baz(x)))
- assert_nil(defined?(f.quux(x)))
- assert(defined?(print(x)))
- assert_nil(defined?(quux(x)))
assert(defined_test) # not iterator
- assert(!defined_test{}) # called as iterator
-
- /a/ =~ ''
- assert_equal nil, defined?($&)
- assert_equal nil, defined?($`)
- assert_equal nil, defined?($')
- assert_equal nil, defined?($+)
- assert_equal nil, defined?($1)
- assert_equal nil, defined?($2)
- /a/ =~ 'a'
- assert_equal 'global-variable', defined?($&)
- assert_equal 'global-variable', defined?($`)
- assert_equal 'global-variable', defined?($')
- assert_equal nil, defined?($+)
- assert_equal nil, defined?($1)
- assert_equal nil, defined?($2)
- /(a)/ =~ 'a'
- assert_equal 'global-variable', defined?($&)
- assert_equal 'global-variable', defined?($`)
- assert_equal 'global-variable', defined?($')
- assert_equal 'global-variable', defined?($+)
- assert_equal 'global-variable', defined?($1)
- assert_equal nil, defined?($2)
- /(a)b/ =~ 'ab'
- assert_equal 'global-variable', defined?($&)
- assert_equal 'global-variable', defined?($`)
- assert_equal 'global-variable', defined?($')
- assert_equal 'global-variable', defined?($+)
- assert_equal 'global-variable', defined?($1)
- assert_equal nil, defined?($2)
+ assert(!defined_test{}) # called as iterator
end
end
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index 10c4a04fed..09685bee8f 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -5,23 +5,25 @@ require 'fileutils'
class TestDir < Test::Unit::TestCase
+ ROOT = File.join(Dir.tmpdir, "__test_dir__#{$$}")
+
def setup
- @root = Dir.mktmpdir('__test_dir__')
+ Dir.mkdir(ROOT)
for i in ?a..?z
- if i.ord % 2 == 0
- FileUtils.touch(File.join(@root, i))
+ if i % 2 == 0
+ FileUtils.touch(File.join(ROOT, i.chr))
else
- FileUtils.mkdir(File.join(@root, i))
+ FileUtils.mkdir(File.join(ROOT, i.chr))
end
end
end
def teardown
- FileUtils.remove_entry_secure @root if File.directory?(@root)
+ FileUtils.rm_rf ROOT if File.directory?(ROOT)
end
def test_seek
- dir = Dir.open(@root)
+ dir = Dir.open(ROOT)
begin
cache = []
loop do
@@ -29,22 +31,12 @@ class TestDir < Test::Unit::TestCase
break unless name = dir.read
cache << [pos, name]
end
- for x,y in cache.sort_by {|z| z[0] % 3 } # shuffle
- dir.seek(x)
- assert_equal(y, dir.read)
+ for x in cache.sort_by {|x| x[0] % 3 } # shuffle
+ dir.seek(x[0])
+ assert_equal(x[1], dir.read)
end
ensure
dir.close
end
end
-
- def test_JVN_13947696
- b = lambda {
- d = Dir.open('.')
- $SAFE = 4
- d.close
- }
- assert_raise(SecurityError) { b.call }
- end
-
end
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb
deleted file mode 100644
index a9bcd8eb97..0000000000
--- a/test/ruby/test_encoding.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'test/unit'
-
-class TestEncoding < Test::Unit::TestCase
-
- # Test basic encoding methods: list, find, name
- def test_encoding
- encodings = Encoding.list
- assert_equal(encodings.empty?, false)
-
- encodings.each do |e|
- assert_equal(e, Encoding.find(e.name))
- assert_equal(e, Encoding.find(e.name.upcase))
- assert_equal(e, Encoding.find(e.name.capitalize))
- assert_equal(e, Encoding.find(e.name.downcase))
- end
- end
-
- # Test that Encoding objects can't be copied
- # And that they can be compared by object_id
- def test_singleton
- encodings = Encoding.list
- encodings.each do |e|
- assert_raise(TypeError) { e.dup }
- assert_raise(TypeError) { e.clone }
- assert_equal(e.object_id, Marshal.load(Marshal.dump(e)).object_id)
- end
- end
-end
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
new file mode 100644
index 0000000000..e541d566c0
--- /dev/null
+++ b/test/ruby/test_enum.rb
@@ -0,0 +1,258 @@
+require 'test/unit'
+
+class TestEnumerable < Test::Unit::TestCase
+ def setup
+ @obj = Object.new
+ class << @obj
+ include Enumerable
+ def each
+ yield 1
+ yield 2
+ yield 3
+ yield 1
+ yield 2
+ end
+ end
+ @verbose = $VERBOSE
+ $VERBOSE = nil
+ end
+
+ def teardown
+ $VERBOSE = @verbose
+ end
+
+ def test_grep
+ assert_equal([1, 2, 1, 2], @obj.grep(1..2))
+ a = []
+ @obj.grep(2) {|x| a << x }
+ assert_equal([2, 2], a)
+ end
+
+ def test_count
+ assert_equal(5, @obj.count)
+ assert_equal(2, @obj.count(1))
+ assert_equal(3, @obj.count {|x| x % 2 == 1 })
+ assert_equal(2, @obj.count(1) {|x| x % 2 == 1 })
+ assert_raise(ArgumentError) { @obj.count(0, 1) }
+ end
+
+ def test_find
+ assert_equal(2, @obj.find {|x| x % 2 == 0 })
+ assert_equal(nil, @obj.find {|x| false })
+ assert_equal(:foo, @obj.find(proc { :foo }) {|x| false })
+ end
+
+ def test_find_index
+ assert_equal(1, @obj.find_index(2))
+ assert_equal(1, @obj.find_index {|x| x % 2 == 0 })
+ assert_equal(nil, @obj.find_index {|x| false })
+ assert_raise(ArgumentError) { @obj.find_index(0, 1) }
+ end
+
+ def test_find_all
+ assert_equal([1, 3, 1], @obj.find_all {|x| x % 2 == 1 })
+ end
+
+ def test_reject
+ assert_equal([2, 3, 2], @obj.reject {|x| x < 2 })
+ end
+
+ def test_to_a
+ assert_equal([1, 2, 3, 1, 2], @obj.to_a)
+ end
+
+ def test_inject
+ assert_equal(12, @obj.inject {|z, x| z * x })
+ assert_equal(48, @obj.inject {|z, x| z * 2 + x })
+ assert_equal(12, @obj.inject(:*))
+ assert_equal(24, @obj.inject(2) {|z, x| z * x })
+ assert_equal(24, @obj.inject(2, :*) {|z, x| z * x })
+ end
+
+ def test_partition
+ assert_equal([[1, 3, 1], [2, 2]], @obj.partition {|x| x % 2 == 1 })
+ end
+
+ def test_group_by
+ h = { 1 => [1, 1], 2 => [2, 2], 3 => [3] }
+ assert_equal(h, @obj.group_by {|x| x })
+ end
+
+ def test_first
+ assert_equal(1, @obj.first)
+ assert_equal([1, 2, 3], @obj.first(3))
+ end
+
+ def test_sort
+ assert_equal([1, 1, 2, 2, 3], @obj.sort)
+ end
+
+ def test_sort_by
+ assert_equal([3, 2, 2, 1, 1], @obj.sort_by {|x| -x })
+ end
+
+ def test_all
+ assert_equal(true, @obj.all? {|x| x <= 3 })
+ assert_equal(false, @obj.all? {|x| x < 3 })
+ assert_equal(true, @obj.all?)
+ assert_equal(false, [true, true, false].all?)
+ end
+
+ def test_any
+ assert_equal(true, @obj.any? {|x| x >= 3 })
+ assert_equal(false, @obj.any? {|x| x > 3 })
+ assert_equal(true, @obj.any?)
+ assert_equal(false, [false, false, false].any?)
+ end
+
+ def test_one
+ assert(@obj.one? {|x| x == 3 })
+ assert(!(@obj.one? {|x| x == 1 }))
+ assert(!(@obj.one? {|x| x == 4 }))
+ assert(%w{ant bear cat}.one? {|word| word.length == 4})
+ assert(!(%w{ant bear cat}.one? {|word| word.length > 4}))
+ assert(!(%w{ant bear cat}.one? {|word| word.length < 4}))
+ assert(!([ nil, true, 99 ].one?))
+ assert([ nil, true, false ].one?)
+ end
+
+ def test_none
+ assert(@obj.none? {|x| x == 4 })
+ assert(!(@obj.none? {|x| x == 1 }))
+ assert(!(@obj.none? {|x| x == 3 }))
+ assert(%w{ant bear cat}.none? {|word| word.length == 5})
+ assert(!(%w{ant bear cat}.none? {|word| word.length >= 4}))
+ assert([].none?)
+ assert([nil].none?)
+ assert([nil,false].none?)
+ end
+
+ def test_min
+ assert_equal(1, @obj.min)
+ assert_equal(3, @obj.min {|a,b| b <=> a })
+ a = %w(albatross dog horse)
+ assert_equal("albatross", a.min)
+ assert_equal("dog", a.min {|a,b| a.length <=> b.length })
+ assert_equal(1, [3,2,1].min)
+ end
+
+ def test_max
+ assert_equal(3, @obj.max)
+ assert_equal(1, @obj.max {|a,b| b <=> a })
+ a = %w(albatross dog horse)
+ assert_equal("horse", a.max)
+ assert_equal("albatross", a.max {|a,b| a.length <=> b.length })
+ assert_equal(1, [3,2,1].max{|a,b| b <=> a })
+ end
+
+ def test_minmax
+ assert_equal([1, 3], @obj.minmax)
+ assert_equal([3, 1], @obj.minmax {|a,b| b <=> a })
+ a = %w(albatross dog horse)
+ assert_equal(["albatross", "horse"], a.minmax)
+ assert_equal(["dog", "albatross"], a.minmax {|a,b| a.length <=> b.length })
+ assert_equal([1, 3], [2,3,1].minmax)
+ assert_equal([3, 1], [2,3,1].minmax {|a,b| b <=> a })
+ end
+
+ def test_min_by
+ assert_equal(3, @obj.min_by {|x| -x })
+ a = %w(albatross dog horse)
+ assert_equal("dog", a.min_by {|x| x.length })
+ assert_equal(3, [2,3,1].min_by {|x| -x })
+ end
+
+ def test_max_by
+ assert_equal(1, @obj.max_by {|x| -x })
+ a = %w(albatross dog horse)
+ assert_equal("albatross", a.max_by {|x| x.length })
+ assert_equal(1, [2,3,1].max_by {|x| -x })
+ end
+
+ def test_minmax_by
+ assert_equal([3, 1], @obj.minmax_by {|x| -x })
+ a = %w(albatross dog horse)
+ assert_equal(["dog", "albatross"], a.minmax_by {|x| x.length })
+ assert_equal([3, 1], [2,3,1].minmax_by {|x| -x })
+ end
+
+ def test_member
+ assert(@obj.member?(1))
+ assert(!(@obj.member?(4)))
+ assert([1,2,3].member?(1))
+ assert(!([1,2,3].member?(4)))
+ end
+
+ def test_each_with_index
+ a = []
+ @obj.each_with_index {|x, i| a << [x, i] }
+ assert_equal([[1,0],[2,1],[3,2],[1,3],[2,4]], a)
+
+ hash = Hash.new
+ %w(cat dog wombat).each_with_index do |item, index|
+ hash[item] = index
+ end
+ assert_equal({"cat"=>0, "wombat"=>2, "dog"=>1}, hash)
+ end
+
+ def test_zip
+ assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj))
+ a = []
+ @obj.zip([:a, :b, :c]) {|x,y| a << [x, y] }
+ assert_equal([[1,:a],[2,:b],[3,:c],[1,nil],[2,nil]], a)
+ end
+
+ def test_take
+ assert_equal([1,2,3], @obj.take(3))
+ end
+
+ def test_take_while
+ assert_equal([1,2], @obj.take_while {|x| x <= 2})
+ end
+
+ def test_drop
+ assert_equal([3,1,2], @obj.drop(2))
+ end
+
+ def test_drop_while
+ assert_equal([3,1,2], @obj.drop_while {|x| x <= 2})
+ end
+
+ def test_cycle
+ assert_equal([1,2,3,1,2,1,2,3,1,2], @obj.cycle.take(10))
+ end
+
+ def test_callcc
+ assert_raise(RuntimeError) do
+ c = nil
+ @obj.sort_by {|x| callcc {|c2| c ||= c2 }; x }
+ c.call
+ end
+
+ assert_raise(RuntimeError) do
+ c = nil
+ o = Object.new
+ class << o; self; end.class_eval do
+ define_method(:<=>) do |x|
+ callcc {|c2| c ||= c2 }
+ 0
+ end
+ end
+ [o, o].sort_by {|x| x }
+ c.call
+ end
+
+ assert_raise(RuntimeError) do
+ c = nil
+ o = Object.new
+ class << o; self; end.class_eval do
+ define_method(:<=>) do |x|
+ callcc {|c2| c ||= c2 }
+ 0
+ end
+ end
+ [o, o, o].sort_by {|x| x }
+ c.call
+ end
+ end
+end
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index cb0c393236..2625791129 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -1,6 +1,16 @@
require 'test/unit'
class TestEnumerator < Test::Unit::TestCase
+ def setup
+ @obj = Object.new
+ class << @obj
+ include Enumerable
+ def foo(*a)
+ a.each {|x| yield x }
+ end
+ end
+ end
+
def enum_test obj
i = 0
obj.map{|e|
@@ -10,8 +20,8 @@ class TestEnumerator < Test::Unit::TestCase
def test_iterators
assert_equal [0, 1, 2], enum_test(3.times)
- assert_equal [:x, :y, :z], enum_test([:x, :y, :z].each)
- assert_equal [[:x, 1], [:y, 2]], enum_test({:x=>1, :y=>2})
+ assert_equal ["x", "y", "z"], enum_test(["z", "y", "x"].each)
+ assert_equal [["x", 1], ["y", 2]], enum_test({"y"=>2, "x"=>1})
end
## Enumerator as Iterator
@@ -43,5 +53,53 @@ class TestEnumerator < Test::Unit::TestCase
assert_equal :ok2, e.next
assert_raise(StopIteration){e.next}
end
+
+
+ def test_initialize
+ assert_equal([1, 2, 3], @obj.to_enum(:foo, 1, 2, 3).to_a)
+ assert_equal([1, 2, 3], Enumerable::Enumerator.new(@obj, :foo, 1, 2, 3).to_a)
+ assert_raise(ArgumentError) { Enumerable::Enumerator.new }
+ end
+
+ def test_initialize_copy
+ assert_equal([1, 2, 3], @obj.to_enum(:foo, 1, 2, 3).dup.to_a)
+ e = @obj.to_enum(:foo, 1, 2, 3)
+ assert_nothing_raised { assert_equal(1, e.next) }
+ #assert_raise(TypeError) { e.dup }
+ end
+
+ def test_gc
+ assert_nothing_raised do
+ 1.times do
+ foo = [1,2,3].to_enum
+ GC.start
+ end
+ GC.start
+ end
+ end
+
+ def test_slice
+ assert_equal([[1,2,3],[4,5,6],[7,8,9],[10]], (1..10).each_slice(3).to_a)
+ end
+
+ def test_cons
+ a = [[1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9,10]]
+ assert_equal(a, (1..10).each_cons(3).to_a)
+ end
+
+ def test_with_index
+ assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
+ end
+
+ def test_next_rewind
+ e = @obj.to_enum(:foo, 1, 2, 3)
+ assert_equal(1, e.next)
+ assert_equal(2, e.next)
+ e.rewind
+ assert_equal(1, e.next)
+ assert_equal(2, e.next)
+ assert_equal(3, e.next)
+ assert_raise(StopIteration) { e.next }
+ end
end
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index c3af6f1bde..3a65f91fa4 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -4,10 +4,8 @@ class TestEnv < Test::Unit::TestCase
IGNORE_CASE = /djgpp|bccwin|mswin|mingw/ =~ RUBY_PLATFORM
def setup
- @backup = ENV['test']
- @BACKUP = ENV['TEST']
- ENV.delete('test')
- ENV.delete('TEST')
+ @backup = ENV.delete('test')
+ @BACKUP = ENV.delete('TEST')
end
def teardown
@@ -59,26 +57,26 @@ class TestEnv < Test::Unit::TestCase
assert_equal(true, ENV.has_value?(val.upcase))
end
- def test_key
+ def test_index
val = 'a'
val.succ! while ENV.has_value?(val) && ENV.has_value?(val.upcase)
ENV['test'] = val[0...-1]
- assert_nil(ENV.key(val))
- assert_nil(ENV.key(val.upcase))
+ assert_nil(ENV.index(val))
+ assert_nil(ENV.index(val.upcase))
ENV['test'] = val
if IGNORE_CASE
- assert_equal('TEST', ENV.key(val).upcase)
+ assert_equal('TEST', ENV.index(val).upcase)
else
- assert_equal('test', ENV.key(val))
+ assert_equal('test', ENV.index(val))
end
- assert_nil(ENV.key(val.upcase))
+ assert_nil(ENV.index(val.upcase))
ENV['test'] = val.upcase
- assert_nil(ENV.key(val))
+ assert_nil(ENV.index(val))
if IGNORE_CASE
- assert_equal('TEST', ENV.key(val.upcase).upcase)
+ assert_equal('TEST', ENV.index(val.upcase).upcase)
else
- assert_equal('test', ENV.key(val.upcase))
+ assert_equal('test', ENV.index(val.upcase))
end
end
end
diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb
index 6e39374a9c..6b3fea7bb4 100644
--- a/test/ruby/test_eval.rb
+++ b/test/ruby/test_eval.rb
@@ -1,201 +1,7 @@
require 'test/unit'
class TestEval < Test::Unit::TestCase
-
- @ivar = 12
- @@cvar = 13
- $gvar__eval = 14
- Const = 15
-
- def test_eval_basic
- assert_equal nil, eval("nil")
- assert_equal true, eval("true")
- assert_equal false, eval("false")
- assert_equal self, eval("self")
- assert_equal 1, eval("1")
- assert_equal :sym, eval(":sym")
-
- assert_equal 11, eval("11")
- @ivar = 12
- assert_equal 12, eval("@ivar")
- assert_equal 13, eval("@@cvar")
- assert_equal 14, eval("$gvar__eval")
- assert_equal 15, eval("Const")
-
- assert_equal 16, eval("7 + 9")
- assert_equal 17, eval("17.to_i")
- assert_equal "18", eval(%q("18"))
- assert_equal "19", eval(%q("1#{9}"))
-
- 1.times {
- assert_equal 12, eval("@ivar")
- assert_equal 13, eval("@@cvar")
- assert_equal 14, eval("$gvar__eval")
- assert_equal 15, eval("Const")
- }
- end
-
- def test_eval_binding_basic
- assert_equal nil, eval("nil", binding())
- assert_equal true, eval("true", binding())
- assert_equal false, eval("false", binding())
- assert_equal self, eval("self", binding())
- assert_equal 1, eval("1", binding())
- assert_equal :sym, eval(":sym", binding())
-
- assert_equal 11, eval("11", binding())
- @ivar = 12
- assert_equal 12, eval("@ivar", binding())
- assert_equal 13, eval("@@cvar", binding())
- assert_equal 14, eval("$gvar__eval", binding())
- assert_equal 15, eval("Const", binding())
-
- assert_equal 16, eval("7 + 9", binding())
- assert_equal 17, eval("17.to_i", binding())
- assert_equal "18", eval(%q("18"), binding())
- assert_equal "19", eval(%q("1#{9}"), binding())
-
- 1.times {
- assert_equal 12, eval("@ivar")
- assert_equal 13, eval("@@cvar")
- assert_equal 14, eval("$gvar__eval")
- assert_equal 15, eval("Const")
- }
- end
-
- def test_module_eval_string_basic
- c = self.class
- assert_equal nil, c.module_eval("nil")
- assert_equal true, c.module_eval("true")
- assert_equal false, c.module_eval("false")
- assert_equal c, c.module_eval("self")
- assert_equal :sym, c.module_eval(":sym")
- assert_equal 11, c.module_eval("11")
- @ivar = 12
- assert_equal 12, c.module_eval("@ivar")
- assert_equal 13, c.module_eval("@@cvar")
- assert_equal 14, c.module_eval("$gvar__eval")
- assert_equal 15, c.module_eval("Const")
- assert_equal 16, c.module_eval("7 + 9")
- assert_equal 17, c.module_eval("17.to_i")
- assert_equal "18", c.module_eval(%q("18"))
- assert_equal "19", c.module_eval(%q("1#{9}"))
-
- @ivar = 12
- 1.times {
- assert_equal 12, c.module_eval("@ivar")
- assert_equal 13, c.module_eval("@@cvar")
- assert_equal 14, c.module_eval("$gvar__eval")
- assert_equal 15, c.module_eval("Const")
- }
- end
-
- def test_module_eval_block_basic
- c = self.class
- assert_equal nil, c.module_eval { nil }
- assert_equal true, c.module_eval { true }
- assert_equal false, c.module_eval { false }
- assert_equal c, c.module_eval { self }
- assert_equal :sym, c.module_eval { :sym }
- assert_equal 11, c.module_eval { 11 }
- @ivar = 12
- assert_equal 12, c.module_eval { @ivar }
- assert_equal 13, c.module_eval { @@cvar }
- assert_equal 14, c.module_eval { $gvar__eval }
- assert_equal 15, c.module_eval { Const }
- assert_equal 16, c.module_eval { 7 + 9 }
- assert_equal 17, c.module_eval { "17".to_i }
- assert_equal "18", c.module_eval { "18" }
- assert_equal "19", c.module_eval { "1#{9}" }
-
- @ivar = 12
- 1.times {
- assert_equal 12, c.module_eval { @ivar }
- assert_equal 13, c.module_eval { @@cvar }
- assert_equal 14, c.module_eval { $gvar__eval }
- assert_equal 15, c.module_eval { Const }
- }
- end
-
- def forall_TYPE(mid)
- objects = [Object.new, [], nil, true, false, 77, :sym] # TODO: check
- objects.each do |obj|
- obj.instance_variable_set :@ivar, 12
- send mid, obj
- end
- end
-
- def test_instance_eval_string_basic
- forall_TYPE :instance_eval_string_basic_i
- end
-
- def instance_eval_string_basic_i(o)
- assert_equal nil, o.instance_eval("nil")
- assert_equal true, o.instance_eval("true")
- assert_equal false, o.instance_eval("false")
- assert_equal o, o.instance_eval("self")
- assert_equal 1, o.instance_eval("1")
- assert_equal :sym, o.instance_eval(":sym")
-
- assert_equal 11, o.instance_eval("11")
- assert_equal 12, o.instance_eval("@ivar")
- assert_raise(NameError) {o.instance_eval("@@cvar")}
- assert_equal 14, o.instance_eval("$gvar__eval")
- assert_equal 15, o.instance_eval("Const")
- assert_equal 16, o.instance_eval("7 + 9")
- assert_equal 17, o.instance_eval("17.to_i")
- assert_equal "18", o.instance_eval(%q("18"))
- assert_equal "19", o.instance_eval(%q("1#{9}"))
-
- 1.times {
- assert_equal 12, o.instance_eval("@ivar")
- assert_raise(NameError) {o.instance_eval("@@cvar")}
- assert_equal 14, o.instance_eval("$gvar__eval")
- assert_equal 15, o.instance_eval("Const")
- }
- end
-
- def test_instance_eval_block_basic
- forall_TYPE :instance_eval_block_basic_i
- end
-
- def instance_eval_block_basic_i(o)
- assert_equal nil, o.instance_eval { nil }
- assert_equal true, o.instance_eval { true }
- assert_equal false, o.instance_eval { false }
- assert_equal o, o.instance_eval { self }
- assert_equal 1, o.instance_eval { 1 }
- assert_equal :sym, o.instance_eval { :sym }
-
- assert_equal 11, o.instance_eval { 11 }
- assert_equal 12, o.instance_eval { @ivar }
- assert_raise(NameError) {o.instance_eval{ @@cvar }}
- assert_equal 14, o.instance_eval { $gvar__eval }
- assert_equal 15, o.instance_eval { Const }
- assert_equal 16, o.instance_eval { 7 + 9 }
- assert_equal 17, o.instance_eval { 17.to_i }
- assert_equal "18", o.instance_eval { "18" }
- assert_equal "19", o.instance_eval { "1#{9}" }
-
- 1.times {
- assert_equal 12, o.instance_eval { @ivar }
- assert_raise(NameError) {o.instance_eval{ @@cvar }}
- assert_equal 14, o.instance_eval { $gvar__eval }
- assert_equal 15, o.instance_eval { Const }
- }
- end
-
- def test_instance_eval_cvar
- [Object.new, [], 7, :sym, true, false, nil].each do |obj|
- assert_raise(NameError){obj.instance_eval("@@cvar")}
- assert_raise(NameError){obj.instance_eval{@@cvar}}
- end
- end
-
- #
- # From ruby/test/ruby/test_eval.rb
- #
-
+ # eval with binding
def test_ev
local1 = "local1"
lambda {
@@ -204,7 +10,7 @@ class TestEval < Test::Unit::TestCase
}.call
end
- def test_eval_orig
+ def test_eval
assert_nil(eval(""))
$bad=false
eval 'while false; $bad = true; print "foo\n" end'
@@ -260,19 +66,16 @@ class TestEval < Test::Unit::TestCase
end
assert(!$bad)
- if false
- # Ruby 2.0 doesn't see Proc as Binding
- x = proc{}
- eval "i4 = 1", x
- assert_equal(1, eval("i4", x))
- x = proc{proc{}}.call
- eval "i4 = 22", x
- assert_equal(22, eval("i4", x))
- $x = []
- x = proc{proc{}}.call
- eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
- assert_equal(8, $x[4].call)
- end
+ x = proc{}
+ eval "i4 = 1", x
+ assert_equal(1, eval("i4", x))
+ x = proc{proc{}}.call
+ eval "i4 = 22", x
+ assert_equal(22, eval("i4", x))
+ $x = []
+ x = proc{proc{}}.call
+ eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
+ assert_equal(8, $x[4].call)
x = binding
eval "i = 1", x
@@ -295,61 +98,55 @@ class TestEval < Test::Unit::TestCase
foo22 = 5
proc{foo11=22}.call
proc{foo22=55}.call
- # assert_equal(eval("foo11"), eval("foo11", p))
- # assert_equal(1, eval("foo11"))
+ assert_equal(eval("foo11"), eval("foo11", p))
+ assert_equal(1, eval("foo11"))
assert_equal(eval("foo22"), eval("foo22", p))
assert_equal(55, eval("foo22"))
}.call
- if false
- # Ruby 2.0 doesn't see Proc as Binding
- p1 = proc{i7 = 0; proc{i7}}.call
- assert_equal(0, p1.call)
- eval "i7=5", p1
- assert_equal(5, p1.call)
- assert(!defined?(i7))
- end
+ p1 = proc{i7 = 0; proc{i7}}.call
+ assert_equal(0, p1.call)
+ eval "i7=5", p1
+ assert_equal(5, p1.call)
+ assert(!defined?(i7))
- if false
- # Ruby 2.0 doesn't see Proc as Binding
- p1 = proc{i7 = 0; proc{i7}}.call
- i7 = nil
- assert_equal(0, p1.call)
- eval "i7=1", p1
- assert_equal(1, p1.call)
- eval "i7=5", p1
- assert_equal(5, p1.call)
- assert_nil(i7)
- end
+ p1 = proc{i7 = 0; proc{i7}}.call
+ i7 = nil
+ assert_equal(0, p1.call)
+ eval "i7=1", p1
+ assert_equal(1, p1.call)
+ eval "i7=5", p1
+ assert_equal(5, p1.call)
+ assert_nil(i7)
end
- def test_nil_instance_eval_cvar
+ def test_nil_instance_eval_cvar # [ruby-dev:24103]
def nil.test_binding
binding
end
bb = eval("nil.instance_eval \"binding\"", nil.test_binding)
- assert_raise(NameError, "[ruby-dev:24103]") { eval("@@a", bb) }
+ assert_raise(NameError) { eval("@@a", bb) }
class << nil
remove_method :test_binding
end
end
- def test_fixnum_instance_eval_cvar
- assert_raise(NameError, "[ruby-dev:24213]") { 1.instance_eval "@@a" }
+ def test_fixnum_instance_eval_cvar # [ruby-dev:24213]
+ assert_raise(NameError) { 1.instance_eval "@@a" }
end
- def test_cvar_scope_with_instance_eval
+ def test_cvar_scope_with_instance_eval # [ruby-dev:24223]
Fixnum.class_eval "@@test_cvar_scope_with_instance_eval = 1" # depends on [ruby-dev:24229]
@@test_cvar_scope_with_instance_eval = 4
- assert_equal(1, 1.instance_eval("@@test_cvar_scope_with_instance_eval"), "[ruby-dev:24223]")
+ assert_equal(4, 1.instance_eval("@@test_cvar_scope_with_instance_eval"))
Fixnum.__send__(:remove_class_variable, :@@test_cvar_scope_with_instance_eval)
end
- def test_eval_and_define_method
- assert_nothing_raised("[ruby-dev:24228]") {
+ def test_eval_and_define_method # [ruby-dev:24228]
+ assert_nothing_raised {
def temporally_method_for_test_eval_and_define_method(&block)
lambda {
- class << Object.new; self end.send(:define_method, :zzz, &block)
+ class << Object.new; self end.__send__(:define_method, :zzz, &block)
}
end
v = eval("temporally_method_for_test_eval_and_define_method {}")
@@ -357,5 +154,4 @@ class TestEval < Test::Unit::TestCase
v.call
}
end
-
end
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
deleted file mode 100644
index fc9a49919a..0000000000
--- a/test/ruby/test_fiber.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-require 'test/unit'
-require 'fiber'
-require 'continuation'
-
-class TestFiber < Test::Unit::TestCase
- def test_normal
- f = Fiber.current
- assert_equal(:ok2,
- Fiber.new{|e|
- assert_equal(:ok1, e)
- Fiber.yield :ok2
- }.resume(:ok1)
- )
- assert_equal([:a, :b], Fiber.new{|a, b| [a, b]}.resume(:a, :b))
- end
-
- def test_term
- assert_equal(:ok, Fiber.new{:ok}.resume)
- assert_equal([:a, :b, :c, :d, :e],
- Fiber.new{
- Fiber.new{
- Fiber.new{
- Fiber.new{
- [:a]
- }.resume + [:b]
- }.resume + [:c]
- }.resume + [:d]
- }.resume + [:e])
- end
-
- def test_many_fibers
- max = 10000
- assert_equal(max, max.times{
- Fiber.new{}
- })
- assert_equal(max,
- max.times{|i|
- Fiber.new{
- }.resume
- }
- )
- end
-
- def test_many_fibers_with_threads
- max = 1000
- @cnt = 0
- (1..100).map{|ti|
- Thread.new{
- max.times{|i|
- Fiber.new{
- @cnt += 1
- }.resume
- }
- }
- }.each{|t|
- t.join
- }
- assert_equal(:ok, :ok)
- end
-
- def test_error
- assert_raise(ArgumentError){
- Fiber.new # Fiber without block
- }
- assert_raise(FiberError){
- f = Fiber.new{}
- Thread.new{f.resume}.join # Fiber yielding across thread
- }
- assert_raise(FiberError){
- f = Fiber.new{}
- f.resume
- f.resume
- }
- assert_raise(RuntimeError){
- f = Fiber.new{
- @c = callcc{|c| @c = c}
- }.resume
- @c.call # cross fiber callcc
- }
- assert_raise(RuntimeError){
- Fiber.new{
- raise
- }.resume
- }
- assert_raise(FiberError){
- Fiber.yield
- }
- assert_raise(FiberError){
- fib = Fiber.new{
- fib.resume
- }
- fib.resume
- }
- assert_raise(FiberError){
- fib = Fiber.new{
- Fiber.new{
- fib.resume
- }.resume
- }
- fib.resume
- }
- end
-
- def test_return
- assert_raise(LocalJumpError){
- Fiber.new do
- return
- end.resume
- }
- end
-
- def test_throw
- assert_raise(ArgumentError){
- Fiber.new do
- throw :a
- end.resume
- }
- end
-
- def test_transfer
- ary = []
- f2 = nil
- f1 = Fiber.new{
- ary << f2.transfer(:foo)
- :ok
- }
- f2 = Fiber.new{
- ary << f1.transfer(:baz)
- :ng
- }
- assert_equal(:ok, f1.transfer)
- assert_equal([:baz], ary)
- end
-
- def test_tls
- #
- def tvar(var, val)
- old = Thread.current[var]
- begin
- Thread.current[var] = val
- yield
- ensure
- Thread.current[var] = old
- end
- end
-
- fb = Fiber.new {
- assert_equal(nil, Thread.current[:v]); tvar(:v, :x) {
- assert_equal(:x, Thread.current[:v]); Fiber.yield
- assert_equal(:x, Thread.current[:v]); }
- assert_equal(nil, Thread.current[:v]); Fiber.yield
- raise # unreachable
- }
-
- assert_equal(nil, Thread.current[:v]); tvar(:v,1) {
- assert_equal(1, Thread.current[:v]); tvar(:v,3) {
- assert_equal(3, Thread.current[:v]); fb.resume
- assert_equal(3, Thread.current[:v]); }
- assert_equal(1, Thread.current[:v]); }
- assert_equal(nil, Thread.current[:v]); fb.resume
- assert_equal(nil, Thread.current[:v]);
- end
-end
-
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 9119575797..2458dde347 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -1,5 +1,6 @@
require 'test/unit'
require 'tempfile'
+$:.replace([File.dirname(File.expand_path(__FILE__))] | $:)
require 'ut_eof'
class TestFile < Test::Unit::TestCase
@@ -7,23 +8,27 @@ class TestFile < Test::Unit::TestCase
# I don't know Ruby's spec about "unlink-before-close" exactly.
# This test asserts current behaviour.
def test_unlink_before_close
- Dir.mktmpdir('rubytest-file') {|tmpdir|
- filename = tmpdir + '/' + File.basename(__FILE__) + ".#{$$}"
- w = File.open(filename, "w")
- w << "foo"
- w.close
- r = File.open(filename, "r")
- begin
- if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
- assert_raise(Errno::EACCES) {File.unlink(filename)}
- else
- assert_nothing_raised {File.unlink(filename)}
- end
- ensure
- r.close
- File.unlink(filename) if File.exist?(filename)
+ filename = File.basename(__FILE__) + ".#{$$}"
+ w = File.open(filename, "w")
+ w << "foo"
+ w.close
+ r = File.open(filename, "r")
+ begin
+ if /(mswin|bccwin|mingw|emx)/ =~ RUBY_PLATFORM
+ begin
+ File.unlink(filename)
+ assert(false)
+ rescue Errno::EACCES
+ assert(true)
+ end
+ else
+ File.unlink(filename)
+ assert(true)
end
- }
+ ensure
+ r.close
+ File.unlink(filename) if File.exist?(filename)
+ end
end
include TestEOF
@@ -37,16 +42,22 @@ class TestFile < Test::Unit::TestCase
include TestEOF::Seek
- def test_truncate_wbuf
+ def test_fnmatch
+ # from [ruby-dev:22815] and [ruby-dev:22819]
+ assert(true, File.fnmatch('\[1\]' , '[1]'))
+ assert(true, File.fnmatch('*?', 'a'))
+ end
+
+ def test_truncate_wbuf # [ruby-dev:24191]
f = Tempfile.new("test-truncate")
f.print "abc"
f.truncate(0)
f.print "def"
f.close
- assert_equal("\0\0\0def", File.read(f.path), "[ruby-dev:24191]")
+ assert_equal("\0\0\0def", File.read(f.path))
end
- def test_truncate_rbuf
+ def test_truncate_rbuf # [ruby-dev:24197]
f = Tempfile.new("test-truncate")
f.puts "abc"
f.puts "def"
@@ -54,14 +65,7 @@ class TestFile < Test::Unit::TestCase
f.open
assert_equal("abc\n", f.gets)
f.truncate(3)
- assert_equal(nil, f.gets, "[ruby-dev:24197]")
- end
-
- def test_truncate_beyond_eof
- f = Tempfile.new("test-truncate")
- f.print "abc"
- f.truncate 10
- assert_equal("\0" * 7, f.read(100), "[ruby-dev:24532]")
+ assert_equal(nil, f.gets)
end
def test_read_all_extended_file
@@ -90,7 +94,7 @@ class TestFile < Test::Unit::TestCase
assert_nil(f.getc)
open(f.path, "w") {|g| g.print "a" }
result = []
- f.each_byte {|b| result << b.chr }
+ f.each_byte {|b| result << b }
assert_equal([?a], result)
end
@@ -101,18 +105,4 @@ class TestFile < Test::Unit::TestCase
assert_equal(?a, f.getc)
end
- def test_s_chown
- assert_nothing_raised { File.chown -1, -1 }
- assert_nothing_raised { File.chown nil, nil }
- end
-
- def test_chown
- assert_nothing_raised {
- File.open(__FILE__) {|f| f.chown -1, -1 }
- }
- assert_nothing_raised("[ruby-dev:27140]") {
- File.open(__FILE__) {|f| f.chown nil, nil }
- }
- end
-
end
diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb
index 81a091eb40..d17b1f8d49 100644
--- a/test/ruby/test_fixnum.rb
+++ b/test/ruby/test_fixnum.rb
@@ -23,99 +23,4 @@ class TestFixnum < Test::Unit::TestCase
end
end
end
-
- def test_succ
- assert_equal(0x40000000, 0x3fffffff.succ, "[ruby-dev:31189]")
- assert_equal(0x4000000000000000, 0x3fffffffffffffff.succ, "[ruby-dev:31190]")
- end
-
- def test_pred
- assert_equal(-0x40000001, (-0x40000000).pred)
- assert_equal(-0x4000000000000001, (-0x4000000000000000).pred)
- end
-
- def test_plus
- assert_equal(0x40000000, 0x3fffffff+1)
- assert_equal(0x4000000000000000, 0x3fffffffffffffff+1)
- assert_equal(-0x40000001, (-0x40000000)+(-1))
- assert_equal(-0x4000000000000001, (-0x4000000000000000)+(-1))
- assert_equal(-0x80000000, (-0x40000000)+(-0x40000000))
- end
-
- def test_sub
- assert_equal(0x40000000, 0x3fffffff-(-1))
- assert_equal(0x4000000000000000, 0x3fffffffffffffff-(-1))
- assert_equal(-0x40000001, (-0x40000000)-1)
- assert_equal(-0x4000000000000001, (-0x4000000000000000)-1)
- assert_equal(-0x80000000, (-0x40000000)-0x40000000)
- end
-
- def test_mult
- assert_equal(0x40000000, 0x20000000*2)
- assert_equal(0x4000000000000000, 0x2000000000000000*2)
- assert_equal(-0x40000001, 33025*(-32513))
- assert_equal(-0x4000000000000001, 1380655685*(-3340214413))
- assert_equal(0x40000000, (-0x40000000)*(-1))
- end
-
- def test_div
- assert_equal(2, 5/2)
- assert_equal(0, 1/2)
- assert_equal(-1, -1/2)
- assert_equal(0, -(1/2))
- assert_equal(-1, (-1)/2)
- assert_equal(0, (-1)/(-2))
- assert_equal(-1, 1/(-2))
- assert_equal(1, -(1/(-2)))
- assert_equal(0x3fffffff, 0xbffffffd/3)
- assert_equal(0x40000000, 0xc0000000/3)
- assert_equal(0x4000000000000000, 0xc000000000000000/3)
- assert_equal(-0x40000001, 0xc0000003/(-3))
- assert_equal(-0x4000000000000001, 0xc000000000000003/(-3))
- assert_equal(0x40000000, (-0x40000000)/(-1), "[ruby-dev:31210]")
- assert_equal(0x4000000000000000, (-0x4000000000000000)/(-1))
- end
-
- def test_mod
- assert_equal(2, (-0x40000000) % 3)
- assert_equal(0, (-0x40000000) % (-1))
- end
-
- def test_divmod
- (-5).upto(5) {|a|
- (-5).upto(5) {|b|
- next if b == 0
- q, r = a.divmod(b)
- assert_equal(a, b*q+r)
- assert(r.abs < b.abs)
- assert(0 < b ? (0 <= r && r < b) : (b < r && r <= 0))
- assert_equal(q, a/b)
- assert_equal(q, a.div(b))
- assert_equal(r, a%b)
- assert_equal(r, a.modulo(b))
- }
- }
- end
-
- def test_not
- assert_equal(-0x40000000, ~0x3fffffff)
- assert_equal(0x3fffffff, ~-0x40000000)
- end
-
- def test_lshift
- assert_equal(0x40000000, 0x20000000<<1)
- assert_equal(-0x40000000, (-0x20000000)<<1)
- assert_equal(-0x80000000, (-0x40000000)<<1)
- end
-
- def test_rshift
- assert_equal(0x20000000, 0x40000000>>1)
- assert_equal(-0x20000000, (-0x40000000)>>1)
- assert_equal(-0x40000000, (-0x80000000)>>1)
- end
-
- def test_abs
- assert_equal(0x40000000, (-0x40000000).abs)
- assert_equal(0x4000000000000000, (-0x4000000000000000).abs)
- end
end
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index 0b06bd9d4d..cbc6a7886b 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -11,8 +11,6 @@ class TestFloat < Test::Unit::TestCase
assert_equal(3, 2.6.round)
assert_equal(-2, (-2.4).truncate)
assert((13.4 % 1 - 0.4).abs < 0.0001)
- assert_equal(36893488147419111424,
- 36893488147419107329.0.to_i)
end
def nan_test(x,y)
@@ -75,6 +73,7 @@ class TestFloat < Test::Unit::TestCase
assert(a.abs < Float::EPSILON)
a = Float("-.0")
assert(a.abs < Float::EPSILON)
+ assert(a.abs < Float::EPSILON)
assert_raise(ArgumentError){Float(".")}
assert_raise(ArgumentError){Float("+")}
assert_raise(ArgumentError){Float("+.")}
@@ -111,4 +110,38 @@ class TestFloat < Test::Unit::TestCase
assert_equal(-3.5, (-11.5).remainder(4))
assert_equal(-3.5, (-11.5).remainder(-4))
end
+
+ def test_to_i
+ assert_operator(4611686018427387905.0.to_i, :>, 0)
+ assert_operator(4611686018427387904.0.to_i, :>, 0)
+ assert_operator(4611686018427387903.8.to_i, :>, 0)
+ assert_operator(4611686018427387903.5.to_i, :>, 0)
+ assert_operator(4611686018427387903.2.to_i, :>, 0)
+ assert_operator(4611686018427387903.0.to_i, :>, 0)
+ assert_operator(4611686018427387902.0.to_i, :>, 0)
+
+ assert_operator(1073741825.0.to_i, :>, 0)
+ assert_operator(1073741824.0.to_i, :>, 0)
+ assert_operator(1073741823.8.to_i, :>, 0)
+ assert_operator(1073741823.5.to_i, :>, 0)
+ assert_operator(1073741823.2.to_i, :>, 0)
+ assert_operator(1073741823.0.to_i, :>, 0)
+ assert_operator(1073741822.0.to_i, :>, 0)
+
+ assert_operator((-1073741823.0).to_i, :<, 0)
+ assert_operator((-1073741824.0).to_i, :<, 0)
+ assert_operator((-1073741824.2).to_i, :<, 0)
+ assert_operator((-1073741824.5).to_i, :<, 0)
+ assert_operator((-1073741824.8).to_i, :<, 0)
+ assert_operator((-1073741825.0).to_i, :<, 0)
+ assert_operator((-1073741826.0).to_i, :<, 0)
+
+ assert_operator((-4611686018427387903.0).to_i, :<, 0)
+ assert_operator((-4611686018427387904.0).to_i, :<, 0)
+ assert_operator((-4611686018427387904.2).to_i, :<, 0)
+ assert_operator((-4611686018427387904.5).to_i, :<, 0)
+ assert_operator((-4611686018427387904.8).to_i, :<, 0)
+ assert_operator((-4611686018427387905.0).to_i, :<, 0)
+ assert_operator((-4611686018427387906.0).to_i, :<, 0)
+ end
end
diff --git a/test/ruby/test_fnmatch.rb b/test/ruby/test_fnmatch.rb
deleted file mode 100644
index 1c1a158477..0000000000
--- a/test/ruby/test_fnmatch.rb
+++ /dev/null
@@ -1,104 +0,0 @@
-require 'test/unit'
-
-class TestFnmatch < Test::Unit::TestCase
-
- def bracket_test(s, t) # `s' should start with neither '!' nor '^'
- 0x21.upto(0x7E) do |i|
- assert_equal(t.include?(i.chr), File.fnmatch("[#{s}]", i.chr, File::FNM_DOTMATCH))
- assert_equal(t.include?(i.chr), !File.fnmatch("[^#{s}]", i.chr, File::FNM_DOTMATCH))
- assert_equal(t.include?(i.chr), !File.fnmatch("[!#{s}]", i.chr, File::FNM_DOTMATCH))
- end
- end
- def test_fnmatch
- assert(File.fnmatch('\[1\]' , '[1]'), "[ruby-dev:22819]")
- assert(File.fnmatch('*?', 'a'), "[ruby-dev:22815]")
- assert(File.fnmatch('*/', 'a/'))
- assert(File.fnmatch('\[1\]' , '[1]', File::FNM_PATHNAME))
- assert(File.fnmatch('*?', 'a', File::FNM_PATHNAME))
- assert(File.fnmatch('*/', 'a/', File::FNM_PATHNAME))
- # text
- assert(File.fnmatch('cat', 'cat'))
- assert(!File.fnmatch('cat', 'category'))
- assert(!File.fnmatch('cat', 'wildcat'))
- # '?' matches any one character
- assert(File.fnmatch('?at', 'cat'))
- assert(File.fnmatch('c?t', 'cat'))
- assert(File.fnmatch('ca?', 'cat'))
- assert(File.fnmatch('?a?', 'cat'))
- assert(!File.fnmatch('c??t', 'cat'))
- assert(!File.fnmatch('??at', 'cat'))
- assert(!File.fnmatch('ca??', 'cat'))
- # '*' matches any number (including 0) of any characters
- assert(File.fnmatch('c*', 'cats'))
- assert(File.fnmatch('c*ts', 'cats'))
- assert(File.fnmatch('*ts', 'cats'))
- assert(File.fnmatch('*c*a*t*s*', 'cats'))
- assert(!File.fnmatch('c*t', 'cats'))
- assert(!File.fnmatch('*abc', 'abcabz'))
- assert(File.fnmatch('*abz', 'abcabz'))
- assert(!File.fnmatch('a*abc', 'abc'))
- assert(File.fnmatch('a*bc', 'abc'))
- assert(!File.fnmatch('a*bc', 'abcd'))
- # [seq] : matches any character listed between bracket
- # [!seq] or [^seq] : matches any character except those listed between bracket
- bracket_test("bd-gikl-mosv-x", "bdefgiklmosvwx")
- # escaping character
- assert(File.fnmatch('\?', '?'))
- assert(!File.fnmatch('\?', '\?'))
- assert(!File.fnmatch('\?', 'a'))
- assert(!File.fnmatch('\?', '\a'))
- assert(File.fnmatch('\*', '*'))
- assert(!File.fnmatch('\*', '\*'))
- assert(!File.fnmatch('\*', 'cats'))
- assert(!File.fnmatch('\*', '\cats'))
- assert(File.fnmatch('\a', 'a'))
- assert(!File.fnmatch('\a', '\a'))
- assert(File.fnmatch('[a\-c]', 'a'))
- assert(File.fnmatch('[a\-c]', '-'))
- assert(File.fnmatch('[a\-c]', 'c'))
- assert(!File.fnmatch('[a\-c]', 'b'))
- assert(!File.fnmatch('[a\-c]', '\\'))
- # escaping character loses its meaning if FNM_NOESCAPE is set
- assert(!File.fnmatch('\?', '?', File::FNM_NOESCAPE))
- assert(File.fnmatch('\?', '\?', File::FNM_NOESCAPE))
- assert(!File.fnmatch('\?', 'a', File::FNM_NOESCAPE))
- assert(File.fnmatch('\?', '\a', File::FNM_NOESCAPE))
- assert(!File.fnmatch('\*', '*', File::FNM_NOESCAPE))
- assert(File.fnmatch('\*', '\*', File::FNM_NOESCAPE))
- assert(!File.fnmatch('\*', 'cats', File::FNM_NOESCAPE))
- assert(File.fnmatch('\*', '\cats', File::FNM_NOESCAPE))
- assert(!File.fnmatch('\a', 'a', File::FNM_NOESCAPE))
- assert(File.fnmatch('\a', '\a', File::FNM_NOESCAPE))
- assert(File.fnmatch('[a\-c]', 'a', File::FNM_NOESCAPE))
- assert(!File.fnmatch('[a\-c]', '-', File::FNM_NOESCAPE))
- assert(File.fnmatch('[a\-c]', 'c', File::FNM_NOESCAPE))
- assert(File.fnmatch('[a\-c]', 'b', File::FNM_NOESCAPE)) # '\\' < 'b' < 'c'
- assert(File.fnmatch('[a\-c]', '\\', File::FNM_NOESCAPE))
- # case is ignored if FNM_CASEFOLD is set
- assert(!File.fnmatch('cat', 'CAT'))
- assert(File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD))
- assert(!File.fnmatch('[a-z]', 'D'))
- assert(File.fnmatch('[a-z]', 'D', File::FNM_CASEFOLD))
- # wildcard doesn't match '/' if FNM_PATHNAME is set
- assert(File.fnmatch('foo?boo', 'foo/boo'))
- assert(File.fnmatch('foo*', 'foo/boo'))
- assert(!File.fnmatch('foo?boo', 'foo/boo', File::FNM_PATHNAME))
- assert(!File.fnmatch('foo*', 'foo/boo', File::FNM_PATHNAME))
- # wildcard matches leading period if FNM_DOTMATCH is set
- assert(!File.fnmatch('*', '.profile'))
- assert(File.fnmatch('*', '.profile', File::FNM_DOTMATCH))
- assert(File.fnmatch('.*', '.profile'))
- assert(File.fnmatch('*', 'dave/.profile'))
- assert(File.fnmatch('*/*', 'dave/.profile'))
- assert(!File.fnmatch('*/*', 'dave/.profile', File::FNM_PATHNAME))
- assert(File.fnmatch('*/*', 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH))
- # recursive matching
- assert(File.fnmatch('**/foo', 'a/b/c/foo', File::FNM_PATHNAME))
- assert(File.fnmatch('**/foo', '/foo', File::FNM_PATHNAME))
- assert(!File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME))
- assert(File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH))
- assert(File.fnmatch('**/foo', '/root/foo', File::FNM_PATHNAME))
- assert(File.fnmatch('**/foo', 'c:/root/foo', File::FNM_PATHNAME))
- end
-
-end
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index 72c38e4b27..d0b4e3df77 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -8,9 +8,6 @@ class TestGc < Test::Unit::TestCase
end
def test_gc
- prev_stress = GC.stress
- GC.stress = false
-
assert_nothing_raised do
1.upto(10000) {
tmp = [0,1,2,3,4,5,6,7,8,9]
@@ -29,7 +26,5 @@ class TestGc < Test::Unit::TestCase
}
GC.start
assert true # reach here or dumps core
-
- GC.stress = prev_stress
end
end
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 440736765c..4131a6bdd3 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -4,7 +4,7 @@ class TestHash < Test::Unit::TestCase
def test_hash
x = {1=>2, 2=>4, 3=>6}
- y = {1=>2, 2=>4, 3=>6} # y = {1, 2, 2, 4, 3, 6} # 1.9 doesn't support
+ y = {1, 2, 2, 4, 3, 6}
assert_equal(2, x[1])
@@ -352,8 +352,8 @@ class TestHash < Test::Unit::TestCase
end
def test_fetch
- assert_raise(KeyError) { @cls[].fetch(1) }
- assert_raise(KeyError) { @h.fetch('gumby') }
+ assert_raise(IndexError) { @cls[].fetch(1) }
+ assert_raise(IndexError) { @h.fetch('gumby') }
assert_equal('gumbygumby', @h.fetch('gumby') {|k| k * 2 })
assert_equal('pokey', @h.fetch('gumby', 'pokey'))
@@ -386,15 +386,6 @@ class TestHash < Test::Unit::TestCase
assert(!@h.include?('gumby'))
end
- def test_key
- assert_equal(1, @h.key('one'))
- assert_equal(nil, @h.key('nil'))
- assert_equal('nil', @h.key(nil))
-
- assert_equal(nil, @h.key('gumby'))
- assert_equal(nil, @cls[].key('gumby'))
- end
-
def test_values_at
res = @h.values_at('dog', 'cat', 'horse')
assert(res.length == 3)
@@ -601,11 +592,11 @@ class TestHash < Test::Unit::TestCase
def test_to_s
h = @cls[ 1 => 2, "cat" => "dog", 1.5 => :fred ]
- assert_equal(h.inspect, h.to_s)
+ assert_equal(h.to_a.join, h.to_s)
$, = ":"
- assert_equal(h.inspect, h.to_s)
+ assert_equal(h.to_a.join, h.to_s)
h = @cls[]
- assert_equal(h.inspect, h.to_s)
+ assert_equal(h.to_a.join, h.to_s)
$, = nil
end
@@ -644,4 +635,7 @@ class TestHash < Test::Unit::TestCase
assert_equal([], expected - vals)
end
+ def test_hash_hash
+ assert_equal({0=>2,11=>1}.hash, {11=>1,0=>2}.hash)
+ end
end
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 81501a61c3..cfda9e5985 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -575,7 +575,7 @@ class TestInteger < Test::Unit::TestCase
}
end
- def test_printf_diu
+ def test_printf_di
VS.reverse_each {|a|
s = sprintf("%d", a)
b = s.to_i
@@ -583,9 +583,6 @@ class TestInteger < Test::Unit::TestCase
s = sprintf("%i", a)
b = s.to_i
assert_equal(a, b, "sprintf('%i', #{a}) = #{s.inspect}")
- s = sprintf("%u", a)
- b = s.to_i
- assert_equal(a, b, "sprintf('%u', #{a}) = #{s.inspect}")
}
end
@@ -597,28 +594,6 @@ class TestInteger < Test::Unit::TestCase
}
end
- def test_pack
- %w[c C s S s! S! i I i! I! l L l! L! q Q n N v V].each {|template|
- size = [0].pack(template).size
- mask = (1 << (size * 8)) - 1
- if /[A-Znv]/ =~ template
- min = 0
- max = (1 << (size * 8))-1
- else
- min = -(1 << (size * 8 - 1))
- max = (1 << (size * 8 - 1)) - 1
- end
- VS.reverse_each {|a|
- s = [a].pack(template)
- b = s.unpack(template)[0]
- assert_equal(a & mask, b & mask, "[#{a}].pack(#{template.dump}).unpack(#{template.dump}) & #{mask}")
- if min <= a && a <= max
- assert_equal(a, b, "[#{a}].pack(#{template.dump}).unpack(#{template.dump})")
- end
- }
- }
- end
-
def test_pack_ber
template = "w"
VS.reverse_each {|a|
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index de75bfd55c..642c8f4430 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2,57 +2,10 @@ require 'test/unit'
class TestIO < Test::Unit::TestCase
def test_gets_rs
- # default_rs
- r, w = IO.pipe
- w.print "aaa\nbbb\n"
- w.close
- assert_equal "aaa\n", r.gets
- assert_equal "bbb\n", r.gets
- assert_nil r.gets
- r.close
-
- # nil
- r, w = IO.pipe
- w.print "a\n\nb\n\n"
- w.close
- assert_equal "a\n\nb\n\n", r.gets(nil)
- assert_nil r.gets("")
- r.close
-
- # "\377"
r, w = IO.pipe
w.print "\377xyz"
w.close
- r.binmode
assert_equal("\377", r.gets("\377"), "[ruby-dev:24460]")
r.close
-
- # ""
- r, w = IO.pipe
- w.print "a\n\nb\n\n"
- w.close
- assert_equal "a\n\n", r.gets(""), "[ruby-core:03771]"
- assert_equal "b\n\n", r.gets("")
- assert_nil r.gets("")
- r.close
- end
-
- # This test cause SEGV.
- def test_ungetc
- r, w = IO.pipe
- w.close
- assert_raise(IOError, "[ruby-dev:31650]") { 20000.times { r.ungetc "a" } }
- ensure
- r.close
- end
-
- def test_each_byte
- r, w = IO.pipe
- w << "abc def"
- w.close
- r.each_byte {|byte| break if byte == 32 }
- assert_equal("def", r.read, "[ruby-dev:31659]")
- ensure
- r.close
end
end
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
deleted file mode 100644
index ccb74103fc..0000000000
--- a/test/ruby/test_io_m17n.rb
+++ /dev/null
@@ -1,388 +0,0 @@
-require 'test/unit'
-require 'tmpdir'
-require 'timeout'
-
-class TestIO_M17N < Test::Unit::TestCase
- ENCS = [
- Encoding::ASCII_8BIT,
- Encoding::EUC_JP,
- Encoding::Shift_JIS,
- Encoding::UTF_8
- ]
-
- def with_tmpdir
- Dir.mktmpdir {|dir|
- Dir.chdir(dir) {
- yield dir
- }
- }
- end
-
- def with_pipe(enc=nil)
- r, w = IO.pipe(enc)
- begin
- yield r, w
- ensure
- r.close if !r.closed?
- w.close if !w.closed?
- end
- end
-
- def generate_file(path, content)
- open(path, "wb") {|f| f.write content }
- end
-
- def encdump(str)
- "#{str.dump}.force_encoding(#{str.encoding.name.dump})"
- end
-
- def assert_str_equal(expected, actual, message=nil)
- full_message = build_message(message, <<EOT)
-#{encdump expected} expected but not equal to
-#{encdump actual}.
-EOT
- assert_block(full_message) { expected == actual }
- end
-
- def test_open_r
- with_tmpdir {
- generate_file('tmp', "")
- open("tmp", "r") {|f|
- assert_equal(Encoding.default_external, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_open_rb
- with_tmpdir {
- generate_file('tmp', "")
- open("tmp", "rb") {|f|
- assert_equal(Encoding::ASCII_8BIT, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_open_r_enc
- with_tmpdir {
- generate_file('tmp', "")
- open("tmp", "r:euc-jp") {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_open_r_enc_enc
- with_tmpdir {
- generate_file('tmp', "")
- open("tmp", "r:euc-jp:utf-8") {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(Encoding::UTF_8, f.internal_encoding)
- }
- }
- end
-
- def test_open_w
- with_tmpdir {
- open("tmp", "w") {|f|
- assert_equal(nil, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_open_wb
- with_tmpdir {
- open("tmp", "wb") {|f|
- assert_equal(nil, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_open_w_enc
- with_tmpdir {
- open("tmp", "w:euc-jp") {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_open_w_enc_enc
- with_tmpdir {
- open("tmp", "w:euc-jp:utf-8") {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(Encoding::UTF_8, f.internal_encoding)
- }
- }
- end
-
- def test_open_w_enc
- with_tmpdir {
- open("tmp", "w:euc-jp") {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- }
- }
- end
-
- def test_stdin
- assert_equal(Encoding.default_external, STDIN.external_encoding)
- assert_equal(nil, STDIN.internal_encoding)
- end
-
- def test_stdout
- assert_equal(nil, STDOUT.external_encoding)
- assert_equal(nil, STDOUT.internal_encoding)
- end
-
- def test_stderr
- assert_equal(nil, STDERR.external_encoding)
- assert_equal(nil, STDERR.internal_encoding)
- end
-
- def test_terminator_conversion
- with_tmpdir {
- generate_file('tmp', "before \u00FF after")
- s = open("tmp", "r:utf-8:iso-8859-1") {|f|
- f.gets("\xFF".force_encoding("iso-8859-1"))
- }
- assert_equal(Encoding.find("iso-8859-1"), s.encoding)
- assert_str_equal("before \xFF".force_encoding("iso-8859-1"), s, '[ruby-core:14288]')
- }
- end
-
- def test_terminator_conversion2
- with_tmpdir {
- generate_file('tmp', "before \xA1\xA2\xA2\xA3 after")
- s = open("tmp", "r:euc-jp:utf-8") {|f|
- f.gets("\xA2\xA2".force_encoding("euc-jp").encode("utf-8"))
- }
- assert_equal(Encoding.find("utf-8"), s.encoding)
- assert_str_equal("before \xA1\xA2\xA2\xA3 after".force_encoding("euc-jp").encode("utf-8"), s, '[ruby-core:14319]')
- }
- end
-
- def test_nonascii_terminator
- with_tmpdir {
- generate_file('tmp', "before \xA2\xA2 after")
- open("tmp", "r:euc-jp") {|f|
- assert_raise(ArgumentError) {
- f.gets("\xA2\xA2".force_encoding("utf-8"))
- }
- }
- }
- end
-
- def test_pipe_terminator_conversion
- with_pipe("euc-jp:utf-8") {|r, w|
- w.write "before \xa2\xa2 after"
- rs = "\xA2\xA2".encode("utf-8", "euc-jp")
- w.close
- timeout(1) {
- assert_equal("before \xa2\xa2".encode("utf-8", "euc-jp"),
- r.gets(rs))
- }
- }
- end
-
- def test_pipe_conversion
- with_pipe("euc-jp:utf-8") {|r, w|
- w.write "\xa1\xa1"
- assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc)
- }
- end
-
- def test_pipe_convert_partial_read
- with_pipe("euc-jp:utf-8") {|r, w|
- begin
- t = Thread.new {
- w.write "\xa1"
- sleep 0.1
- w.write "\xa1"
- }
- assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc)
- ensure
- t.join if t
- end
- }
- end
-
- def test_open_ascii
- with_tmpdir {
- src = "abc\n"
- generate_file('tmp', "abc\n")
- ENCS.each {|enc|
- s = open('tmp', "r:#{enc}") {|f| f.gets }
- assert_equal(enc, s.encoding)
- assert_str_equal(src, s)
- }
- }
- end
-
- def test_open_nonascii
- with_tmpdir {
- src = "\xc2\xa1\n"
- generate_file('tmp', src)
- ENCS.each {|enc|
- content = src.dup.force_encoding(enc)
- s = open('tmp', "r:#{enc}") {|f| f.gets }
- assert_equal(enc, s.encoding)
- assert_str_equal(content, s)
- }
- }
- end
-
- def test_read_encoding
- with_tmpdir {
- src = "\xc2\xa1\n".force_encoding("ASCII-8BIT")
- generate_file('tmp', "\xc2\xa1\n")
- ENCS.each {|enc|
- content = src.dup.force_encoding(enc)
- open('tmp', "r:#{enc}") {|f|
- s = f.getc
- assert_equal(enc, s.encoding)
- assert_str_equal(content[0], s)
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.readchar
- assert_equal(enc, s.encoding)
- assert_str_equal(content[0], s)
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.gets
- assert_equal(enc, s.encoding)
- assert_str_equal(content, s)
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.readline
- assert_equal(enc, s.encoding)
- assert_str_equal(content, s)
- }
- open('tmp', "r:#{enc}") {|f|
- lines = f.readlines
- assert_equal(1, lines.length)
- s = lines[0]
- assert_equal(enc, s.encoding)
- assert_str_equal(content, s)
- }
- open('tmp', "r:#{enc}") {|f|
- f.each_line {|s|
- assert_equal(enc, s.encoding)
- assert_str_equal(content, s)
- }
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.read
- assert_equal(enc, s.encoding)
- assert_str_equal(content, s)
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.read(1)
- assert_equal(Encoding::ASCII_8BIT, s.encoding)
- assert_str_equal(src[0], s)
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.readpartial(1)
- assert_equal(Encoding::ASCII_8BIT, s.encoding)
- assert_str_equal(src[0], s)
- }
- open('tmp', "r:#{enc}") {|f|
- s = f.sysread(1)
- assert_equal(Encoding::ASCII_8BIT, s.encoding)
- assert_str_equal(src[0], s)
- }
- }
- }
- end
-
- def test_write_noenc
- src = "\xc2\xa1\n".force_encoding("ascii-8bit")
- with_tmpdir {
- open('tmp', "w") {|f|
- ENCS.each {|enc|
- f.write src.dup.force_encoding(enc)
- }
- }
- open('tmp', 'r:ascii-8bit') {|f|
- assert_equal(src*ENCS.length, f.read)
- }
- }
- end
-
- def test_write_conversion
- utf8 = "\u6666"
- eucjp = "\xb3\xa2".force_encoding("EUC-JP")
- with_tmpdir {
- open('tmp', "w:EUC-JP") {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(nil, f.internal_encoding)
- f.print utf8
- }
- assert_equal(eucjp, File.read('tmp').force_encoding("EUC-JP"))
- open('tmp', 'r:EUC-JP:UTF-8') {|f|
- assert_equal(Encoding::EUC_JP, f.external_encoding)
- assert_equal(Encoding::UTF_8, f.internal_encoding)
- assert_equal(utf8, f.read)
- }
- }
- end
-
- def test_pipe
- utf8 = "\u6666"
- eucjp = "\xb3\xa2".force_encoding("EUC-JP")
-
- with_pipe {|r,w|
- assert_equal(Encoding.default_external, r.external_encoding)
- assert_equal(nil, r.internal_encoding)
- w << utf8
- w.close
- s = r.read
- assert_equal(Encoding.default_external, s.encoding)
- assert_str_equal(utf8.dup.force_encoding(Encoding.default_external), s)
- }
-
- with_pipe("EUC-JP") {|r,w|
- assert_equal(Encoding::EUC_JP, r.external_encoding)
- assert_equal(nil, r.internal_encoding)
- w << eucjp
- w.close
- assert_equal(eucjp, r.read)
- }
-
- with_pipe("UTF-8:EUC-JP") {|r,w|
- assert_equal(Encoding::UTF_8, r.external_encoding)
- assert_equal(Encoding::EUC_JP, r.internal_encoding)
- w << utf8
- w.close
- assert_equal(eucjp, r.read)
- }
-
- ENCS.each {|enc|
- with_pipe(enc) {|r, w|
- w << "\xc2\xa1"
- w.close
- s = r.getc
- assert_equal(enc, s.encoding)
- }
- }
-
- ENCS.each {|enc|
- next if enc == Encoding::ASCII_8BIT
- next if enc == Encoding::UTF_8
- with_pipe("#{enc}:UTF-8") {|r, w|
- w << "\xc2\xa1"
- w.close
- s = r.read
- assert_equal(Encoding::UTF_8, s.encoding)
- assert_equal(s.encode("UTF-8"), s)
- }
- }
-
- end
-
-end
-
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index 4b38ac806a..2cd48b29a4 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -52,7 +52,7 @@ class TestIterator < Test::Unit::TestCase
def test_nested_iterator
i = 0
tt{|i| break if i == 5}
- assert_equal(0, i)
+ assert_equal(5, i)
assert_raises(ArgumentError) do
tt3{}
@@ -69,7 +69,7 @@ class TestIterator < Test::Unit::TestCase
end
end
- # iterator break/redo/next
+ # iterator break/redo/next/retry
def test_break
done = true
loop{
@@ -104,6 +104,18 @@ class TestIterator < Test::Unit::TestCase
end
assert_equal(7, $x.size)
assert_equal([1, 2, 3, 4, 5, 6, 7], $x)
+
+ $done = false
+ $x = []
+ for i in 1 .. 7 # see how retry works in iterator loop
+ if i == 4 and not $done
+ $done = true
+ retry
+ end
+ $x.push(i)
+ end
+ assert_equal(10, $x.size)
+ assert_equal([1, 2, 3, 1, 2, 3, 4, 5, 6, 7], $x)
end
def test_append_method_to_built_in_class
@@ -137,9 +149,11 @@ class TestIterator < Test::Unit::TestCase
IterTest.new([0]).each0 {|x| assert_equal(0, x)}
IterTest.new([1]).each1 {|x| assert_equal(1, x)}
IterTest.new([2]).each2 {|x| assert_equal([2], x)}
+ IterTest.new([3]).each3 {|x| assert_equal(3, x)}
IterTest.new([4]).each4 {|x| assert_equal(4, x)}
IterTest.new([5]).each5 {|x| assert_equal(5, x)}
IterTest.new([6]).each6 {|x| assert_equal([6], x)}
+ IterTest.new([7]).each7 {|x| assert_equal(7, x)}
IterTest.new([8]).each8 {|x| assert_equal(8, x)}
IterTest.new([[0]]).each0 {|x| assert_equal([0], x)}
@@ -152,8 +166,8 @@ class TestIterator < Test::Unit::TestCase
IterTest.new([[7]]).each7 {|x| assert_equal(7, x)}
IterTest.new([[8]]).each8 {|x| assert_equal([8], x)}
- IterTest.new([[0,0]]).each0 {|*x| assert_equal([[0,0]], x)}
- IterTest.new([[8,8]]).each8 {|*x| assert_equal([[8,8]], x)}
+ IterTest.new([[0,0]]).each0 {|x| assert_equal([0,0], x)}
+ IterTest.new([[8,8]]).each8 {|x| assert_equal([8,8], x)}
end
def m(var)
@@ -245,11 +259,11 @@ class TestIterator < Test::Unit::TestCase
assert_equal(block.clone.call, 11)
assert_instance_of(Proc, get_block(&block))
- lmd = lambda{44}
- assert_instance_of(Proc, lmd)
- assert_instance_of(Proc, lmd.to_proc)
- assert_equal(lmd.clone.call, 44)
- assert_instance_of(Proc, get_block(&lmd))
+ lambda = lambda{44}
+ assert_instance_of(Proc, lambda)
+ assert_instance_of(Proc, lambda.to_proc)
+ assert_equal(lambda.clone.call, 44)
+ assert_instance_of(Proc, get_block(&lambda))
assert_equal(1, Proc.new{|a,| a}.call(1,2,3))
assert_nothing_raised {Proc.new{|a,|}.call(1,2)}
@@ -298,21 +312,14 @@ class TestIterator < Test::Unit::TestCase
end
def test_ljump
+ block = get_block{11}
+ lambda = lambda{44}
assert_raises(LocalJumpError) {get_block{break}.call}
+ assert_nothing_raised {lambda{break}.call}
+ assert_instance_of(LocalJumpError, (get_block{break}.call rescue $!))
- # cannot use assert_nothing_raised due to passing block.
- begin
- val = lambda{break 11}.call
- rescue LocalJumpError
- assert(false, "LocalJumpError occurred from break in lambda")
- else
- assert(11, val)
- end
-
- block = get_block{11}
- lmd = lambda{44}
- assert_equal(0, block.arity)
- assert_equal(0, lmd.arity)
+ assert_equal(-1, block.arity)
+ assert_equal(-1, lambda.arity)
assert_equal(0, lambda{||}.arity)
assert_equal(1, lambda{|a|}.arity)
assert_equal(1, lambda{|a,|}.arity)
@@ -320,8 +327,8 @@ class TestIterator < Test::Unit::TestCase
end
def marity_test(m)
- mobj = method(m)
- assert_equal(mobj.arity, mobj.to_proc.arity)
+ method = method(m)
+ assert_equal(method.arity, method.to_proc.arity)
end
def test_marity
@@ -334,10 +341,10 @@ class TestIterator < Test::Unit::TestCase
end
def foo
- yield(:key, :value)
+ yield([:key, :value])
end
def bar(&blk)
- blk.call(:key, :value)
+ blk.call([:key, :value])
end
def test_yield_vs_call
@@ -349,19 +356,13 @@ class TestIterator < Test::Unit::TestCase
def each
yield [:key, :value]
end
- alias each_pair each
end
def test_assoc_yield
- [{:key=>:value}, H.new].each {|h|
- h.each{|a| assert_equal([:key, :value], a)}
- h.each{|a,| assert_equal(:key, a)}
- h.each{|*a| assert_equal([[:key, :value]], a)}
- h.each{|k,v| assert_equal([:key, :value], [k,v])}
- h.each_pair{|a| assert_equal([:key, :value], a)}
- h.each_pair{|a,| assert_equal(:key, a)}
- h.each_pair{|*a| assert_equal([[:key, :value]], a)}
- h.each_pair{|k,v| assert_equal([:key, :value], [k,v])}
+ [{:key=>:value}, H.new].each {|h|
+ h.each{|a| assert_equal([:key, :value], a)}
+ h.each{|*a| assert_equal([[:key, :value]], a)}
+ h.each{|k,v| assert_equal([:key, :value], [k,v])}
}
end
@@ -473,25 +474,4 @@ class TestIterator < Test::Unit::TestCase
def test_block_given_within_iterator
assert_equal(["b"], ["a", "b", "c"].grep(IterString.new("b")) {|s| s})
end
-
- def test_enumerator
- [1,2,3].each.with_index {|x,i|
- assert_equal(x, i+1)
- }
-
- e = [1,2,3].each
- assert_equal(1, e.next)
- assert_equal(2, e.next)
- assert_equal(3, e.next)
- assert_raises(StopIteration){e.next}
- e.rewind
- assert_equal(1, e.next)
- e.rewind
- a = []
- loop{a.push e.next}
- assert_equal([1,2,3], a)
-
- assert_equal([[1, 8, 10], [2, 6, 11], [3, 4, 12]],
- (1..10).zip([8,6,4],(10..100)).to_a)
- end
end
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
deleted file mode 100644
index bb0861ab53..0000000000
--- a/test/ruby/test_lambda.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-require 'test/unit'
-
-class TestLambdaParameters < Test::Unit::TestCase
-
- def test_exact_parameter
- assert_raise(ArgumentError){(1..3).each(&lambda{})}
- end
-
- def test_call_simple
- assert_equal(1, lambda{|a| a}.call(1))
- assert_equal([1,2], lambda{|a, b| [a,b]}.call(1,2))
- assert_raises(ArgumentError) { lambda{|a|}.call(1,2) }
- assert_raises(ArgumentError) { lambda{|a|}.call() }
- assert_raises(ArgumentError) { lambda{}.call(1) }
- assert_raises(ArgumentError) { lambda{|a, b|}.call(1,2,3) }
-
- assert_equal(1, ->(a){ a }.call(1))
- assert_equal([1,2], ->(a,b){ [a,b] }.call(1,2))
- assert_raises(ArgumentError) { ->(a){ }.call(1,2) }
- assert_raises(ArgumentError) { ->(a){ }.call() }
- assert_raises(ArgumentError) { ->(){ }.call(1) }
- assert_raises(ArgumentError) { ->(a,b){ }.call(1,2,3) }
- end
-
-end
-
-__END__
- def test_lambda_as_iterator
- a = 0
- 2.times(&->(_){ a += 1 })
- assert_equal(a, 2)
- end
-
- def test_call_rest_args
- assert_equal([1,2], ->(*a){ a }.call(1,2))
- assert_equal([1,2,[]], ->(a,b,*c){ [a,b,c] }.call(1,2))
- assert_raises(ArgumentError){ ->(a,*b){ }.call() }
- end
-
- def test_call_opt_args
- assert_equal([1,2,3,4], ->(a,b,c=3,d=4){ [a,b,c,d] }.call(1,2))
- assert_equal([1,2,3,4], ->(a,b,c=0,d=4){ [a,b,c,d] }.call(1,2,3))
- assert_raises(ArgumentError){ ->(a,b=1){ }.call() }
- assert_raises(ArgumentError){ ->(a,b=1){ }.call(1,2,3) }
- end
-
- def test_call_rest_and_opt
- assert_equal([1,2,3,[]], ->(a,b=2,c=3,*d){ [a,b,c,d] }.call(1))
- assert_equal([1,2,3,[]], ->(a,b=0,c=3,*d){ [a,b,c,d] }.call(1,2))
- assert_equal([1,2,3,[4,5,6]], ->(a,b=0,c=0,*d){ [a,b,c,d] }.call(1,2,3,4,5,6))
- assert_raises(ArgumentError){ ->(a,b=1,*c){ }.call() }
- end
-
- def test_call_with_block
- f = ->(a,b,c=3,*d,&e){ [a,b,c,d,e.call(d + [a,b,c])] }
- assert_equal([1,2,3,[],6], f.call(1,2){|z| z.inject{|s,x| s+x} } )
- assert_equal(nil, ->(&b){ b }.call)
- foo { puts "bogus block " }
- assert_equal(1, ->(&b){ b.call }.call { 1 })
- b = nil
- assert_equal(1, ->(&b){ b.call }.call { 1 })
- assert_nil(b)
- end
-
- def foo
- assert_equal(nil, ->(&b){ b }.call)
- end
-end
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
deleted file mode 100644
index 70aad3604f..0000000000
--- a/test/ruby/test_literal.rb
+++ /dev/null
@@ -1,184 +0,0 @@
-require 'test/unit'
-
-class TestRubyLiteral < Test::Unit::TestCase
-
- def test_special_const
- assert_equal 'true', true.inspect
- assert_instance_of TrueClass, true
- assert_equal 'false', false.inspect
- assert_instance_of FalseClass, false
- assert_equal 'nil', nil.inspect
- assert_instance_of NilClass, nil
- assert_equal ':sym', :sym.inspect
- assert_instance_of Symbol, :sym
- assert_equal '1234', 1234.inspect
- assert_instance_of Fixnum, 1234
- assert_equal '1234', 1_2_3_4.inspect
- assert_instance_of Fixnum, 1_2_3_4
- assert_equal '18', 0x12.inspect
- assert_instance_of Fixnum, 0x12
- assert_equal '15', 0o17.inspect
- assert_instance_of Fixnum, 0o17
- assert_equal '5', 0b101.inspect
- assert_instance_of Fixnum, 0b101
- assert_equal '123456789012345678901234567890', 123456789012345678901234567890.inspect
- assert_instance_of Bignum, 123456789012345678901234567890
- assert_instance_of Float, 1.3
- end
-
- def test_self
- assert_equal self, self
- assert_instance_of TestRubyLiteral, self
- assert_respond_to self, :test_self
- end
-
- def test_string
- assert_instance_of String, ?a
- assert_equal "a", ?a
- assert_instance_of String, ?A
- assert_equal "A", ?A
- assert_instance_of String, ?\n
- assert_equal "\n", ?\n
- assert_equal " ", ?\ # space
- assert_equal '', ''
- assert_equal 'string', 'string'
- assert_equal 'string string', 'string string'
- assert_equal ' ', ' '
- assert_equal ' ', " "
- assert_equal "\0", "\0"
- assert_equal "\1", "\1"
- assert_equal "3", "\x33"
- assert_equal "\n", "\n"
- end
-
- def test_dstring
- assert_equal '2', "#{1+1}"
- assert_equal '16', "#{2 ** 4}"
- s = "string"
- assert_equal s, "#{s}"
- end
-
- def test_dsymbol
- assert_equal :a3c, :"a#{1+2}c"
- end
-
- def test_xstring
- assert_equal "foo\n", `echo foo`
- s = 'foo'
- assert_equal "foo\n", `echo #{s}`
- end
-
- def test_regexp
- assert_instance_of Regexp, //
- assert_match //, 'a'
- assert_match //, ''
- assert_instance_of Regexp, /a/
- assert_match /a/, 'a'
- assert_no_match /test/, 'tes'
- re = /test/
- assert_match re, 'test'
- str = 'test'
- assert_match re, str
- assert_match /test/, str
- assert_equal 0, (/test/ =~ 'test')
- assert_equal 0, (re =~ 'test')
- assert_equal 0, (/test/ =~ str)
- assert_equal 0, (re =~ str)
- assert_equal 0, ('test' =~ /test/)
- assert_equal 0, ('test' =~ re)
- assert_equal 0, (str =~ /test/)
- assert_equal 0, (str =~ re)
- end
-
- def test_dregexp
- assert_instance_of Regexp, /re#{'ge'}xp/
- assert_equal(/regexp/, /re#{'ge'}xp/)
- end
-
- def test_array
- assert_instance_of Array, []
- assert_equal [], []
- assert_equal 0, [].size
- assert_instance_of Array, [0]
- assert_equal [3], [3]
- assert_equal 1, [3].size
- a = [3]
- assert_equal 3, a[0]
- assert_instance_of Array, [1,2]
- assert_equal [1,2], [1,2]
- assert_instance_of Array, [1,2,3,4,5]
- assert_equal [1,2,3,4,5], [1,2,3,4,5]
- assert_equal 5, [1,2,3,4,5].size
- a = [1,2]
- assert_equal 1, a[0]
- assert_equal 2, a[1]
- a = [1 + 2, 3 + 4, 5 + 6]
- assert_instance_of Array, a
- assert_equal [3, 7, 11], a
- assert_equal 7, a[1]
- assert_equal 1, ([0][0] += 1)
- assert_equal 1, ([2][0] -= 1)
- a = [obj = Object.new]
- assert_instance_of Array, a
- assert_equal 1, a.size
- assert_equal obj, a[0]
- a = [1,2,3]
- a[1] = 5
- assert_equal 5, a[1]
- end
-
- def test_hash
- assert_instance_of Hash, {}
- assert_equal({}, {})
- assert_instance_of Hash, {1 => 2}
- assert_equal({1 => 2}, {1 => 2})
- h = {1 => 2}
- assert_equal 2, h[1]
- h = {"string" => "literal", "goto" => "hell"}
- assert_equal h, h
- assert_equal 2, h.size
- assert_equal h, h
- assert_equal "literal", h["string"]
- end
-
- def test_range
- assert_instance_of Range, (1..2)
- assert_equal(1..2, 1..2)
- r = 1..2
- assert_equal 1, r.begin
- assert_equal 2, r.end
- assert_equal false, r.exclude_end?
- assert_instance_of Range, (1...3)
- assert_equal(1...3, 1...3)
- r = 1...3
- assert_equal 1, r.begin
- assert_equal 3, r.end
- assert_equal true, r.exclude_end?
- r = 1+2 .. 3+4
- assert_instance_of Range, r
- assert_equal 3, r.begin
- assert_equal 7, r.end
- assert_equal false, r.exclude_end?
- r = 1+2 ... 3+4
- assert_instance_of Range, r
- assert_equal 3, r.begin
- assert_equal 7, r.end
- assert_equal true, r.exclude_end?
- assert_instance_of Range, 'a'..'c'
- r = 'a'..'c'
- assert_equal 'a', r.begin
- assert_equal 'c', r.end
- end
-
- def test__FILE__
- assert_instance_of String, __FILE__
- assert_equal __FILE__, __FILE__
- assert_equal 'test_literal.rb', File.basename(__FILE__)
- end
-
- def test__LINE__
- assert_instance_of Fixnum, __LINE__
- assert_equal __LINE__, __LINE__
- end
-
-end
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
deleted file mode 100644
index da765312cb..0000000000
--- a/test/ruby/test_m17n.rb
+++ /dev/null
@@ -1,1913 +0,0 @@
-require 'test/unit'
-require 'stringio'
-
-class TestM17N < Test::Unit::TestCase
- def assert_encoding(encname, actual, message=nil)
- assert_equal(Encoding.find(encname), actual, message)
- end
-
- module AESU
- def a(str) str.dup.force_encoding("ASCII-8BIT") end
- def e(str) str.dup.force_encoding("EUC-JP") end
- def s(str) str.dup.force_encoding("Shift_JIS") end
- def u(str) str.dup.force_encoding("UTF-8") end
- end
- include AESU
- extend AESU
-
- def assert_strenc(bytes, enc, actual, message=nil)
- assert_instance_of(String, actual, message)
- enc = Encoding.find(enc) if String === enc
- assert_equal(enc, actual.encoding, message)
- assert_equal(a(bytes), a(actual), message)
- end
-
- def assert_warning(pat, mesg=nil)
- begin
- org_stderr = $stderr
- $stderr = StringIO.new(warn = '')
- yield
- ensure
- $stderr = org_stderr
- end
- assert_match(pat, warn, mesg)
- end
-
- def assert_regexp_generic_encoding(r)
- assert(!r.fixed_encoding?)
- %w[ASCII-8BIT EUC-JP Shift_JIS UTF-8].each {|ename|
- # "\xc2\xa1" is a valid sequence for ASCII-8BIT, EUC-JP, Shift_JIS and UTF-8.
- assert_nothing_raised { r =~ "\xc2\xa1".force_encoding(ename) }
- }
- end
-
- def assert_regexp_fixed_encoding(r)
- assert(r.fixed_encoding?)
- %w[ASCII-8BIT EUC-JP Shift_JIS UTF-8].each {|ename|
- enc = Encoding.find(ename)
- if enc == r.encoding
- assert_nothing_raised { r =~ "\xc2\xa1".force_encoding(enc) }
- else
- assert_raise(ArgumentError) { r =~ "\xc2\xa1".force_encoding(enc) }
- end
- }
- end
-
- def assert_regexp_generic_ascii(r)
- assert_encoding("ASCII-8BIT", r.encoding)
- assert_regexp_generic_encoding(r)
- end
-
- def assert_regexp_fixed_ascii8bit(r)
- assert_encoding("ASCII-8BIT", r.encoding)
- assert_regexp_fixed_encoding(r)
- end
-
- def assert_regexp_fixed_eucjp(r)
- assert_encoding("EUC-JP", r.encoding)
- assert_regexp_fixed_encoding(r)
- end
-
- def assert_regexp_fixed_sjis(r)
- assert_encoding("Shift_JIS", r.encoding)
- assert_regexp_fixed_encoding(r)
- end
-
- def assert_regexp_fixed_utf8(r)
- assert_encoding("UTF-8", r.encoding)
- assert_regexp_fixed_encoding(r)
- end
-
- STRINGS = [
- a(""), e(""), s(""), u(""),
- a("a"), e("a"), s("a"), u("a"),
- a("."), e("."), s("."), u("."),
-
- # single character
- a("\x80"), a("\xff"),
- e("\xa1\xa1"), e("\xfe\xfe"),
- e("\x8e\xa1"), e("\x8e\xfe"),
- e("\x8f\xa1\xa1"), e("\x8f\xfe\xfe"),
- s("\x81\x40"), s("\xfc\xfc"),
- s("\xa1"), s("\xdf"),
- u("\xc2\x80"), u("\xf4\x8f\xbf\xbf"),
-
- # same byte sequence
- a("\xc2\xa1"), e("\xc2\xa1"), s("\xc2\xa1"), u("\xc2\xa1"),
-
- s("\x81A"), # mutibyte character which contains "A"
- s("\x81a"), # mutibyte character which contains "a"
-
- # invalid
- e("\xa1"), e("\x80"),
- s("\x81"), s("\x80"),
- u("\xc2"), u("\x80"),
-
- # for transitivity test
- u("\xe0\xa0\xa1"),
- e("\xe0\xa0\xa1"),
- s("\xe0\xa0\xa1"),
- ]
-
- def combination(*args)
- if args.empty?
- yield []
- else
- arg = args.shift
- arg.each {|v|
- combination(*args) {|vs|
- yield [v, *vs]
- }
- }
- end
- end
-
- def encdump(str)
- "#{str.dump}.force_encoding(#{str.encoding.name.dump})"
- end
-
- def encdumpargs(args)
- r = '('
- args.each_with_index {|a, i|
- r << ',' if 0 < i
- if String === a
- r << encdump(a)
- else
- r << a.inspect
- end
- }
- r << ')'
- r
- end
-
- def assert_str_enc_propagation(t, s1, s2)
- if !s1.ascii_only?
- assert_equal(s1.encoding, t.encoding)
- elsif !s2.ascii_only?
- assert_equal(s2.encoding, t.encoding)
- else
- assert([s1.encoding, s2.encoding].include?(t.encoding))
- end
- end
-
- def assert_same_result(expected_proc, actual_proc)
- e = nil
- begin
- t = expected_proc.call
- rescue
- e = $!
- end
- if e
- assert_raise(e.class) { actual_proc.call }
- else
- assert_equal(t, actual_proc.call)
- end
- end
-
- def each_slice_call
- combination(STRINGS, -2..2) {|s, nth|
- yield s, nth
- }
- combination(STRINGS, -2..2, 0..2) {|s, nth, len|
- yield s, nth, len
- }
- combination(STRINGS, STRINGS) {|s, substr|
- yield s, substr
- }
- combination(STRINGS, -2..2, 0..2) {|s, first, last|
- yield s, first..last
- yield s, first...last
- }
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s2.valid_encoding?
- next
- end
- yield s1, Regexp.new(Regexp.escape(s2))
- }
- combination(STRINGS, STRINGS, 0..2) {|s1, s2, nth|
- if !s2.valid_encoding?
- next
- end
- yield s1, Regexp.new(Regexp.escape(s2)), nth
- }
- end
-
- def str_enc_compatible?(*strs)
- encs = []
- strs.each {|s|
- encs << s.encoding if !s.ascii_only?
- }
- encs.uniq!
- encs.length <= 1
- end
-
- # tests start
-
- def test_string_ascii_literal
- assert_encoding("ASCII-8BIT", eval(a(%{""})).encoding)
- assert_encoding("ASCII-8BIT", eval(a(%{"a"})).encoding)
- end
-
- def test_string_eucjp_literal
- assert_encoding("ASCII-8BIT", eval(e(%{""})).encoding)
- assert_encoding("ASCII-8BIT", eval(e(%{"a"})).encoding)
- assert_encoding("EUC-JP", eval(e(%{"\xa1\xa1"})).encoding)
- assert_encoding("EUC-JP", eval(e(%{"\\xa1\\xa1"})).encoding)
- assert_encoding("ASCII-8BIT", eval(e(%{"\\x20"})).encoding)
- assert_encoding("ASCII-8BIT", eval(e(%{"\\n"})).encoding)
- assert_encoding("EUC-JP", eval(e(%{"\\x80"})).encoding)
- end
-
- def test_string_mixed_unicode
- assert_raise(SyntaxError) { eval(a(%{"\xc2\xa0\\u{6666}"})) }
- assert_raise(SyntaxError) { eval(e(%{"\xc2\xa0\\u{6666}"})) }
- assert_raise(SyntaxError) { eval(s(%{"\xc2\xa0\\u{6666}"})) }
- assert_nothing_raised { eval(u(%{"\xc2\xa0\\u{6666}"})) }
- assert_raise(SyntaxError) { eval(a(%{"\\u{6666}\xc2\xa0"})) }
- assert_raise(SyntaxError) { eval(e(%{"\\u{6666}\xc2\xa0"})) }
- assert_raise(SyntaxError) { eval(s(%{"\\u{6666}\xc2\xa0"})) }
- assert_nothing_raised { eval(u(%{"\\u{6666}\xc2\xa0"})) }
- end
-
- def test_string_inspect
- assert_equal('"\xFE"', e("\xfe").inspect)
- assert_equal('"\x8E"', e("\x8e").inspect)
- assert_equal('"\x8F"', e("\x8f").inspect)
- assert_equal('"\x8F\xA1"', e("\x8f\xa1").inspect)
- assert_equal('"\xEF"', s("\xef").inspect)
- assert_equal('"\xC2"', u("\xc2").inspect)
- assert_equal('"\xE0\x80"', u("\xe0\x80").inspect)
- assert_equal('"\xF0\x80\x80"', u("\xf0\x80\x80").inspect)
- assert_equal('"\xF8\x80\x80\x80"', u("\xf8\x80\x80\x80").inspect)
- assert_equal('"\xFC\x80\x80\x80\x80"', u("\xfc\x80\x80\x80\x80").inspect)
-
- assert_equal('"\xFE "', e("\xfe ").inspect)
- assert_equal('"\x8E "', e("\x8e ").inspect)
- assert_equal('"\x8F "', e("\x8f ").inspect)
- assert_equal('"\x8F\xA1 "', e("\x8f\xa1 ").inspect)
- assert_equal('"\xEF "', s("\xef ").inspect)
- assert_equal('"\xC2 "', u("\xc2 ").inspect)
- assert_equal('"\xE0\x80 "', u("\xe0\x80 ").inspect)
- assert_equal('"\xF0\x80\x80 "', u("\xf0\x80\x80 ").inspect)
- assert_equal('"\xF8\x80\x80\x80 "', u("\xf8\x80\x80\x80 ").inspect)
- assert_equal('"\xFC\x80\x80\x80\x80 "', u("\xfc\x80\x80\x80\x80 ").inspect)
-
-
- assert_equal(e("\"\\xA1\x8f\xA1\xA1\""), e("\xa1\x8f\xa1\xa1").inspect)
-
- assert_equal('"\x81."', s("\x81.").inspect)
- assert_equal(s("\"\x81@\""), s("\x81@").inspect)
-
- assert_equal('"\xFC"', u("\xfc").inspect)
- end
-
- def test_validate_redundant_utf8
- bits_0x10ffff = "11110100 10001111 10111111 10111111"
- [
- "0xxxxxxx",
- "110XXXXx 10xxxxxx",
- "1110XXXX 10Xxxxxx 10xxxxxx",
- "11110XXX 10XXxxxx 10xxxxxx 10xxxxxx",
- "111110XX 10XXXxxx 10xxxxxx 10xxxxxx 10xxxxxx",
- "1111110X 10XXXXxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx",
- "11111110 10XXXXXx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx",
- "11111111 10XXXXXX 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx",
- ].each {|pat0|
- [
- pat0.gsub(/x/, '1'),
- pat0.gsub(/x/, '0')
- ].each {|pat1|
- [
- pat1.sub(/X([^X]*)\z/, '1\1').gsub(/X/, "0"),
- pat1.gsub(/X/, "1"),
- ].each {|pat2|
- s = [pat2.gsub(/ /, "")].pack("B*").force_encoding("utf-8")
- if pat2 <= bits_0x10ffff
- assert(s.valid_encoding?, "#{pat2}")
- else
- assert(!s.valid_encoding?, "#{pat2}")
- end
- }
- if / / =~ pat0
- pat3 = pat1.gsub(/X/, "0")
- s = [pat3.gsub(/ /, "")].pack("B*").force_encoding("utf-8")
- assert(!s.valid_encoding?, "#{pat3}")
- end
- }
- }
- end
-
- def test_validate_surrogate
- # 1110XXXX 10Xxxxxx 10xxxxxx : 3 bytes UTF-8
- pats = [
- "11101101 10011111 10111111", # just before surrogate high
- "11101101 1010xxxx 10xxxxxx", # surrogate high
- "11101101 1011xxxx 10xxxxxx", # surrogate low
- "11101110 10000000 10000000", # just after surrogate low
- ]
- pats.values_at(1,2).each {|pat0|
- [
- pat0.gsub(/x/, '0'),
- pat0.gsub(/x/, '1'),
- ].each {|pat1|
- s = [pat1.gsub(/ /, "")].pack("B*").force_encoding("utf-8")
- assert(!s.valid_encoding?, "#{pat1}")
- }
- }
- pats.values_at(0,3).each {|pat|
- s = [pat.gsub(/ /, "")].pack("B*").force_encoding("utf-8")
- assert(s.valid_encoding?, "#{pat}")
- }
- end
-
- def test_regexp_too_short_multibyte_character
- assert_raise(SyntaxError) { eval('/\xfe/e') }
- assert_raise(SyntaxError) { eval('/\x8e/e') }
- assert_raise(SyntaxError) { eval('/\x8f/e') }
- assert_raise(SyntaxError) { eval('/\x8f\xa1/e') }
- assert_raise(SyntaxError) { eval('/\xef/s') }
- assert_raise(SyntaxError) { eval('/\xc2/u') }
- assert_raise(SyntaxError) { eval('/\xe0\x80/u') }
- assert_raise(SyntaxError) { eval('/\xf0\x80\x80/u') }
- assert_raise(SyntaxError) { eval('/\xf8\x80\x80\x80/u') }
- assert_raise(SyntaxError) { eval('/\xfc\x80\x80\x80\x80/u') }
-
- # raw 8bit
- assert_raise(SyntaxError) { eval("/\xfe/e") }
- assert_raise(SyntaxError) { eval("/\xc2/u") }
-
- # invalid suffix
- assert_raise(SyntaxError) { eval('/\xc2\xff/u') }
- assert_raise(SyntaxError) { eval('/\xc2 /u') }
- assert_raise(SyntaxError) { eval('/\xc2\x20/u') }
- end
-
- def test_regexp_generic
- assert_regexp_generic_ascii(/a/)
- assert_regexp_generic_ascii(Regexp.new(a("a")))
- assert_regexp_generic_ascii(Regexp.new(e("a")))
- assert_regexp_generic_ascii(Regexp.new(s("a")))
- assert_regexp_generic_ascii(Regexp.new(u("a")))
-
- [/a/, Regexp.new(a("a"))].each {|r|
- assert_equal(0, r =~ a("a"))
- assert_equal(0, r =~ e("a"))
- assert_equal(0, r =~ s("a"))
- assert_equal(0, r =~ u("a"))
- assert_equal(nil, r =~ a("\xc2\xa1"))
- assert_equal(nil, r =~ e("\xc2\xa1"))
- assert_equal(nil, r =~ s("\xc2\xa1"))
- assert_equal(nil, r =~ u("\xc2\xa1"))
- }
- end
-
- def test_regexp_ascii_none
- r = /a/n
-
- assert_warning(%r{regexp match /.../n against to}) {
- assert_regexp_generic_ascii(r)
- }
-
- assert_equal(0, r =~ a("a"))
- assert_equal(0, r =~ e("a"))
- assert_equal(0, r =~ s("a"))
- assert_equal(0, r =~ u("a"))
- assert_equal(nil, r =~ a("\xc2\xa1"))
- assert_warning(%r{regexp match /.../n against to EUC-JP string}) {
- assert_equal(nil, r =~ e("\xc2\xa1"))
- }
- assert_warning(%r{regexp match /.../n against to Shift_JIS string}) {
- assert_equal(nil, r =~ s("\xc2\xa1"))
- }
- assert_warning(%r{regexp match /.../n against to UTF-8 string}) {
- assert_equal(nil, r =~ u("\xc2\xa1"))
- }
- end
-
- def test_regexp_ascii
- assert_regexp_fixed_ascii8bit(/\xc2\xa1/n)
- assert_regexp_fixed_ascii8bit(eval(a(%{/\xc2\xa1/})))
- assert_regexp_fixed_ascii8bit(eval(a(%{/\xc2\xa1/n})))
- assert_regexp_fixed_ascii8bit(eval(a(%q{/\xc2\xa1/})))
-
- [/\xc2\xa1/n, eval(a(%{/\xc2\xa1/})), eval(a(%{/\xc2\xa1/n}))].each {|r|
- assert_equal(nil, r =~ a("a"))
- assert_equal(nil, r =~ e("a"))
- assert_equal(nil, r =~ s("a"))
- assert_equal(nil, r =~ u("a"))
- assert_equal(0, r =~ a("\xc2\xa1"))
- assert_raise(ArgumentError) { r =~ e("\xc2\xa1") }
- assert_raise(ArgumentError) { r =~ s("\xc2\xa1") }
- assert_raise(ArgumentError) { r =~ u("\xc2\xa1") }
- }
- end
-
- def test_regexp_euc
- assert_regexp_fixed_eucjp(/a/e)
- assert_regexp_fixed_eucjp(/\xc2\xa1/e)
- assert_regexp_fixed_eucjp(eval(e(%{/\xc2\xa1/})))
- assert_regexp_fixed_eucjp(eval(e(%q{/\xc2\xa1/})))
-
- [/a/e].each {|r|
- assert_equal(0, r =~ a("a"))
- assert_equal(0, r =~ e("a"))
- assert_equal(0, r =~ s("a"))
- assert_equal(0, r =~ u("a"))
- assert_raise(ArgumentError) { r =~ a("\xc2\xa1") }
- assert_equal(nil, r =~ e("\xc2\xa1"))
- assert_raise(ArgumentError) { r =~ s("\xc2\xa1") }
- assert_raise(ArgumentError) { r =~ u("\xc2\xa1") }
- }
-
- [/\xc2\xa1/e, eval(e(%{/\xc2\xa1/})), eval(e(%q{/\xc2\xa1/}))].each {|r|
- assert_equal(nil, r =~ a("a"))
- assert_equal(nil, r =~ e("a"))
- assert_equal(nil, r =~ s("a"))
- assert_equal(nil, r =~ u("a"))
- assert_raise(ArgumentError) { r =~ a("\xc2\xa1") }
- assert_equal(0, r =~ e("\xc2\xa1"))
- assert_raise(ArgumentError) { r =~ s("\xc2\xa1") }
- assert_raise(ArgumentError) { r =~ u("\xc2\xa1") }
- }
- end
-
- def test_regexp_sjis
- assert_regexp_fixed_sjis(/a/s)
- assert_regexp_fixed_sjis(/\xc2\xa1/s)
- assert_regexp_fixed_sjis(eval(s(%{/\xc2\xa1/})))
- assert_regexp_fixed_sjis(eval(s(%q{/\xc2\xa1/})))
- end
-
- def test_regexp_embed
- r = eval(e("/\xc2\xa1/"))
- assert_raise(ArgumentError) { eval(s("/\xc2\xa1\#{r}/s")) }
- assert_raise(ArgumentError) { eval(s("/\#{r}\xc2\xa1/s")) }
-
- r = /\xc2\xa1/e
- #assert_raise(ArgumentError) { eval(s("/\xc2\xa1\#{r}/s")) }
- #assert_raise(ArgumentError) { eval(s("/\#{r}\xc2\xa1/s")) }
-
- r = eval(e("/\xc2\xa1/"))
- #assert_raise(ArgumentError) { /\xc2\xa1#{r}/s }
-
- r = /\xc2\xa1/e
- #assert_raise(ArgumentError) { /\xc2\xa1#{r}/s }
- end
-
- def test_begin_end_offset
- str = e("\244\242\244\244\244\246\244\250\244\252a")
- assert(/(a)/ =~ str)
- assert_equal("a", $&)
- assert_equal(5, $~.begin(0))
- assert_equal(6, $~.end(0))
- assert_equal([5,6], $~.offset(0))
- assert_equal(5, $~.begin(1))
- assert_equal(6, $~.end(1))
- assert_equal([5,6], $~.offset(1))
- end
-
- def test_begin_end_offset_sjis
- str = s("\x81@@")
- assert(/@/ =~ str)
- assert_equal(s("\x81@"), $`)
- assert_equal("@", $&)
- assert_equal("", $')
- assert_equal([1,2], $~.offset(0))
- end
-
- def test_quote
- assert_regexp_generic_ascii(/#{Regexp.quote(a("a"))}#{Regexp.quote(e("e"))}/)
-
- # Regexp.quote returns ASCII-8BIT string for ASCII only string
- # to make generic regexp if possible.
- assert_encoding("ASCII-8BIT", Regexp.quote(a("")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(e("")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(s("")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(u("")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(a("a")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(e("a")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(s("a")).encoding)
- assert_encoding("ASCII-8BIT", Regexp.quote(u("a")).encoding)
-
- assert_encoding("ASCII-8BIT", Regexp.quote(a("\xc2\xa1")).encoding)
- assert_encoding("EUC-JP", Regexp.quote(e("\xc2\xa1")).encoding)
- assert_encoding("Shift_JIS", Regexp.quote(s("\xc2\xa1")).encoding)
- assert_encoding("UTF-8", Regexp.quote(u("\xc2\xa1")).encoding)
- end
-
- def test_union_0
- r = Regexp.union
- assert_regexp_generic_ascii(r)
- assert(r !~ a(""))
- assert(r !~ e(""))
- assert(r !~ s(""))
- assert(r !~ u(""))
- end
-
- def test_union_1_asciionly_string
- assert_regexp_generic_ascii(Regexp.union(a("")))
- assert_regexp_generic_ascii(Regexp.union(e("")))
- assert_regexp_generic_ascii(Regexp.union(s("")))
- assert_regexp_generic_ascii(Regexp.union(u("")))
- assert_regexp_generic_ascii(Regexp.union(a("a")))
- assert_regexp_generic_ascii(Regexp.union(e("a")))
- assert_regexp_generic_ascii(Regexp.union(s("a")))
- assert_regexp_generic_ascii(Regexp.union(u("a")))
- assert_regexp_generic_ascii(Regexp.union(a("\t")))
- assert_regexp_generic_ascii(Regexp.union(e("\t")))
- assert_regexp_generic_ascii(Regexp.union(s("\t")))
- assert_regexp_generic_ascii(Regexp.union(u("\t")))
- end
-
- def test_union_1_nonascii_string
- assert_regexp_fixed_ascii8bit(Regexp.union(a("\xc2\xa1")))
- assert_regexp_fixed_eucjp(Regexp.union(e("\xc2\xa1")))
- assert_regexp_fixed_sjis(Regexp.union(s("\xc2\xa1")))
- assert_regexp_fixed_utf8(Regexp.union(u("\xc2\xa1")))
- end
-
- def test_union_1_regexp
- assert_regexp_generic_ascii(Regexp.union(//))
- assert_warning(%r{regexp match /.../n against to}) {
- assert_regexp_generic_ascii(Regexp.union(//n))
- }
- assert_regexp_fixed_eucjp(Regexp.union(//e))
- assert_regexp_fixed_sjis(Regexp.union(//s))
- assert_regexp_fixed_utf8(Regexp.union(//u))
- end
-
- def test_union_2
- ary = [
- a(""), e(""), s(""), u(""),
- a("\xc2\xa1"), e("\xc2\xa1"), s("\xc2\xa1"), u("\xc2\xa1")
- ]
- ary.each {|s1|
- ary.each {|s2|
- if s1.empty?
- if s2.empty?
- assert_regexp_generic_ascii(Regexp.union(s1, s2))
- else
- r = Regexp.union(s1, s2)
- assert_regexp_fixed_encoding(r)
- assert_equal(s2.encoding, r.encoding)
- end
- else
- if s2.empty?
- r = Regexp.union(s1, s2)
- assert_regexp_fixed_encoding(r)
- assert_equal(s1.encoding, r.encoding)
- else
- if s1.encoding == s2.encoding
- r = Regexp.union(s1, s2)
- assert_regexp_fixed_encoding(r)
- assert_equal(s1.encoding, r.encoding)
- else
- assert_raise(ArgumentError) { Regexp.union(s1, s2) }
- end
- end
- end
- }
- }
- end
-
- def test_dynamic_ascii_regexp
- assert_warning(%r{regexp match /.../n against to}) {
- assert_regexp_generic_ascii(/#{}/n)
- }
- assert_regexp_fixed_ascii8bit(/#{}\xc2\xa1/n)
- assert_regexp_fixed_ascii8bit(/\xc2\xa1#{}/n)
- #assert_raise(SyntaxError) { s1, s2 = s('\xc2'), s('\xa1'); /#{s1}#{s2}/ }
- end
-
- def test_dynamic_eucjp_regexp
- assert_regexp_fixed_eucjp(/#{}/e)
- assert_regexp_fixed_eucjp(/#{}\xc2\xa1/e)
- assert_regexp_fixed_eucjp(/\xc2\xa1#{}/e)
- assert_raise(SyntaxError) { eval('/\xc2#{}/e') }
- assert_raise(SyntaxError) { eval('/#{}\xc2/e') }
- assert_raise(SyntaxError) { eval('/\xc2#{}\xa1/e') }
- #assert_raise(SyntaxError) { s1, s2 = e('\xc2'), e('\xa1'); /#{s1}#{s2}/ }
- end
-
- def test_dynamic_sjis_regexp
- assert_regexp_fixed_sjis(/#{}/s)
- assert_regexp_fixed_sjis(/#{}\xc2\xa1/s)
- assert_regexp_fixed_sjis(/\xc2\xa1#{}/s)
- assert_raise(SyntaxError) { eval('/\x81#{}/s') }
- assert_raise(SyntaxError) { eval('/#{}\x81/s') }
- assert_raise(SyntaxError) { eval('/\x81#{}\xa1/s') }
- #assert_raise(SyntaxError) { s1, s2 = s('\x81'), s('\xa1'); /#{s1}#{s2}/ }
- end
-
- def test_dynamic_utf8_regexp
- assert_regexp_fixed_utf8(/#{}/u)
- assert_regexp_fixed_utf8(/#{}\xc2\xa1/u)
- assert_regexp_fixed_utf8(/\xc2\xa1#{}/u)
- assert_raise(SyntaxError) { eval('/\xc2#{}/u') }
- assert_raise(SyntaxError) { eval('/#{}\xc2/u') }
- assert_raise(SyntaxError) { eval('/\xc2#{}\xa1/u') }
- #assert_raise(SyntaxError) { s1, s2 = u('\xc2'), u('\xa1'); /#{s1}#{s2}/ }
- end
-
- def test_regexp_unicode
- assert_nothing_raised { eval '/\u{0}/u' }
- assert_nothing_raised { eval '/\u{D7FF}/u' }
- assert_raise(SyntaxError) { eval '/\u{D800}/u' }
- assert_raise(SyntaxError) { eval '/\u{DFFF}/u' }
- assert_nothing_raised { eval '/\u{E000}/u' }
- assert_nothing_raised { eval '/\u{10FFFF}/u' }
- assert_raise(SyntaxError) { eval '/\u{110000}/u' }
- end
-
- def test_regexp_mixed_unicode
- assert_raise(SyntaxError) { eval(a(%{/\xc2\xa0\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(e(%{/\xc2\xa0\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(s(%{/\xc2\xa0\\u{6666}/})) }
- assert_nothing_raised { eval(u(%{/\xc2\xa0\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(a(%{/\\u{6666}\xc2\xa0/})) }
- assert_raise(SyntaxError) { eval(e(%{/\\u{6666}\xc2\xa0/})) }
- assert_raise(SyntaxError) { eval(s(%{/\\u{6666}\xc2\xa0/})) }
- assert_nothing_raised { eval(u(%{/\\u{6666}\xc2\xa0/})) }
-
- assert_raise(SyntaxError) { eval(a(%{/\\xc2\\xa0\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(e(%{/\\xc2\\xa0\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(s(%{/\\xc2\\xa0\\u{6666}/})) }
- assert_nothing_raised { eval(u(%{/\\xc2\\xa0\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(a(%{/\\u{6666}\\xc2\\xa0/})) }
- assert_raise(SyntaxError) { eval(e(%{/\\u{6666}\\xc2\\xa0/})) }
- assert_raise(SyntaxError) { eval(s(%{/\\u{6666}\\xc2\\xa0/})) }
- assert_nothing_raised { eval(u(%{/\\u{6666}\\xc2\\xa0/})) }
-
- assert_raise(SyntaxError) { eval(a(%{/\xc2\xa0#{}\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(e(%{/\xc2\xa0#{}\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(s(%{/\xc2\xa0#{}\\u{6666}/})) }
- assert_nothing_raised { eval(u(%{/\xc2\xa0#{}\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(a(%{/\\u{6666}#{}\xc2\xa0/})) }
- assert_raise(SyntaxError) { eval(e(%{/\\u{6666}#{}\xc2\xa0/})) }
- assert_raise(SyntaxError) { eval(s(%{/\\u{6666}#{}\xc2\xa0/})) }
- assert_nothing_raised { eval(u(%{/\\u{6666}#{}\xc2\xa0/})) }
-
- assert_raise(SyntaxError) { eval(a(%{/\\xc2\\xa0#{}\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(e(%{/\\xc2\\xa0#{}\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(s(%{/\\xc2\\xa0#{}\\u{6666}/})) }
- assert_nothing_raised { eval(u(%{/\\xc2\\xa0#{}\\u{6666}/})) }
- assert_raise(SyntaxError) { eval(a(%{/\\u{6666}#{}\\xc2\\xa0/})) }
- assert_raise(SyntaxError) { eval(e(%{/\\u{6666}#{}\\xc2\\xa0/})) }
- assert_raise(SyntaxError) { eval(s(%{/\\u{6666}#{}\\xc2\\xa0/})) }
- assert_nothing_raised { eval(u(%{/\\u{6666}#{}\\xc2\\xa0/})) }
- end
-
- def test_str_allocate
- s = String.allocate
- assert_equal(Encoding::ASCII_8BIT, s.encoding)
- end
-
- def test_str_String
- s = String(10)
- assert_equal(Encoding::ASCII_8BIT, s.encoding)
- end
-
- def test_str_new
- STRINGS.each {|s|
- t = String.new(s)
- assert_strenc(a(s), s.encoding, t)
- }
- end
-
- def test_str_plus
- combination(STRINGS, STRINGS) {|s1, s2|
- if s1.encoding != s2.encoding && !s1.ascii_only? && !s2.ascii_only?
- assert_raise(ArgumentError) { s1 + s2 }
- else
- t = s1 + s2
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert_equal(a(s1) + a(s2), a(t))
- assert_str_enc_propagation(t, s1, s2)
- end
- }
- end
-
- def test_str_times
- STRINGS.each {|s|
- [0,1,2].each {|n|
- t = s * n
- assert(t.valid_encoding?) if s.valid_encoding?
- assert_strenc(a(s) * n, s.encoding, t)
- }
- }
- end
-
- def test_sprintf_c
- assert_strenc("\x80", 'ASCII-8BIT', a("%c") % 128)
- #assert_raise(ArgumentError) { a("%c") % 0xc2a1 }
- assert_strenc("\xc2\xa1", 'EUC-JP', e("%c") % 0xc2a1)
- assert_raise(ArgumentError) { e("%c") % 0xc2 }
- assert_strenc("\xc2", 'Shift_JIS', s("%c") % 0xc2)
- #assert_raise(ArgumentError) { s("%c") % 0xc2a1 }
- assert_strenc("\u{c2a1}", 'UTF-8', u("%c") % 0xc2a1)
- assert_strenc("\u{c2}", 'UTF-8', u("%c") % 0xc2)
- end
-
- def test_sprintf_s
- STRINGS.each {|s|
- assert_strenc(a(s), s.encoding, "%s".force_encoding(s.encoding) % s)
- if !s.empty? # xxx
- assert_strenc(a(s), s.encoding, a("%s") % s)
- end
- }
- end
-
- def test_sprintf_p
- assert_strenc('""', 'ASCII-8BIT', a("%p") % a(""))
- assert_strenc('""', 'EUC-JP', e("%p") % e(""))
- assert_strenc('""', 'Shift_JIS', s("%p") % s(""))
- assert_strenc('""', 'UTF-8', u("%p") % u(""))
-
- assert_strenc('"a"', 'ASCII-8BIT', a("%p") % a("a"))
- assert_strenc('"a"', 'EUC-JP', e("%p") % e("a"))
- assert_strenc('"a"', 'Shift_JIS', s("%p") % s("a"))
- assert_strenc('"a"', 'UTF-8', u("%p") % u("a"))
-
- assert_strenc('"\xC2\xA1"', 'ASCII-8BIT', a("%p") % a("\xc2\xa1"))
- assert_strenc("\"\xC2\xA1\"", 'EUC-JP', e("%p") % e("\xc2\xa1"))
- #assert_strenc("\"\xC2\xA1\"", 'Shift_JIS', s("%p") % s("\xc2\xa1"))
- assert_strenc("\"\xC2\xA1\"", 'UTF-8', u("%p") % u("\xc2\xa1"))
-
- assert_strenc('"\x00"', 'ASCII-8BIT', a("%p") % a("\x00"))
- assert_strenc('"\x00"', 'EUC-JP', e("%p") % e("\x00"))
- assert_strenc('"\x00"', 'Shift_JIS', s("%p") % s("\x00"))
- assert_strenc('"\x00"', 'UTF-8', u("%p") % u("\x00"))
- end
-
- def test_str_eq_reflexive
- STRINGS.each {|s|
- assert(s == s, "#{encdump s} == #{encdump s}")
- }
- end
-
- def test_str_eq_symmetric
- combination(STRINGS, STRINGS) {|s1, s2|
- if s1 == s2
- assert(s2 == s1, "#{encdump s2} == #{encdump s1}")
- else
- assert(!(s2 == s1), "!(#{encdump s2} == #{encdump s1})")
- end
- }
- end
-
- def test_str_eq_transitive
- combination(STRINGS, STRINGS, STRINGS) {|s1, s2, s3|
- if s1 == s2 && s2 == s3
- assert(s1 == s3, "transitive: #{encdump s1} == #{encdump s2} == #{encdump s3}")
- end
- }
- end
-
- def test_str_eq
- combination(STRINGS, STRINGS) {|s1, s2|
- desc_eq = "#{encdump s1} == #{encdump s2}"
- if s1.ascii_only? && s2.ascii_only? && a(s1) == a(s2)
- assert(s1 == s2, desc_eq)
- elsif s1.encoding == s2.encoding && a(s1) == a(s2)
- assert(s1 == s2, desc_eq)
- assert(!(s1 != s2))
- assert_equal(0, s1 <=> s2)
- else
- assert(!(s1 == s2), "!(#{desc_eq})")
- assert(s1 != s2)
- assert_not_equal(0, s1 <=> s2)
- end
- }
- end
-
- def test_str_lt
- assert(a("a") < a("\xa1"))
- assert(a("a") < s("\xa1"))
- assert(s("a") < a("\xa1"))
- end
-
- def test_str_concat
- combination(STRINGS, STRINGS) {|s1, s2|
- s = s1.dup
- if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
- s << s2
- assert(s.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert_equal(a(s), a(s1) + a(s2))
- assert_str_enc_propagation(s, s1, s2)
- else
- assert_raise(ArgumentError) { s << s2 }
- end
- }
- end
-
- def test_str_aref
- assert_equal(a("\xc2"), a("\xc2\xa1")[0])
- assert_equal(a("\xa1"), a("\xc2\xa1")[1])
- assert_equal(nil, a("\xc2\xa1")[2])
- assert_equal(e("\xc2\xa1"), e("\xc2\xa1")[0])
- assert_equal(nil, e("\xc2\xa1")[1])
- assert_equal(s("\xc2"), s("\xc2\xa1")[0])
- assert_equal(s("\xa1"), s("\xc2\xa1")[1])
- assert_equal(nil, s("\xc2\xa1")[2])
- assert_equal(u("\xc2\xa1"), u("\xc2\xa1")[0])
- assert_equal(nil, u("\xc2\xa1")[1])
-
- STRINGS.each {|s|
- t = ''
- 0.upto(s.length-1) {|i|
- u = s[i]
- assert(u.valid_encoding?) if s.valid_encoding?
- t << u
- }
- assert_equal(t, s)
- }
-
- end
-
- def test_str_aref_len
- assert_equal(a("\xa1"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 1])
- assert_equal(a("\xa1\xc2"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 2])
-
- assert_equal(e("\xc2\xa2"), e("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 1])
- assert_equal(e("\xc2\xa2\xc2\xa3"), e("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 2])
-
- assert_equal(s("\xa1"), s("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 1])
- assert_equal(s("\xa1\xc2"), s("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 2])
-
- assert_equal(u("\xc2\xa2"), u("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 1])
- assert_equal(u("\xc2\xa2\xc2\xa3"), u("\xc2\xa1\xc2\xa2\xc2\xa3")[1, 2])
-
- STRINGS.each {|s|
- t = ''
- 0.upto(s.length-1) {|i|
- u = s[i,1]
- assert(u.valid_encoding?) if s.valid_encoding?
- t << u
- }
- assert_equal(t, s)
- }
-
- STRINGS.each {|s|
- t = ''
- 0.step(s.length-1, 2) {|i|
- u = s[i,2]
- assert(u.valid_encoding?) if s.valid_encoding?
- t << u
- }
- assert_equal(t, s)
- }
- end
-
- def test_str_aref_substr
- assert_equal(a("\xa1\xc2"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[a("\xa1\xc2")])
- assert_raise(ArgumentError) { a("\xc2\xa1\xc2\xa2\xc2\xa3")[e("\xa1\xc2")] }
-
- assert_equal(nil, e("\xc2\xa1\xc2\xa2\xc2\xa3")[e("\xa1\xc2")])
- assert_raise(ArgumentError) { e("\xc2\xa1\xc2\xa2\xc2\xa3")[s("\xa1\xc2")] }
-
- assert_equal(s("\xa1\xc2"), s("\xc2\xa1\xc2\xa2\xc2\xa3")[s("\xa1\xc2")])
- assert_raise(ArgumentError) { s("\xc2\xa1\xc2\xa2\xc2\xa3")[u("\xa1\xc2")] }
-
- assert_equal(nil, u("\xc2\xa1\xc2\xa2\xc2\xa3")[u("\xa1\xc2")])
- assert_raise(ArgumentError) { u("\xc2\xa1\xc2\xa2\xc2\xa3")[a("\xa1\xc2")] }
-
- combination(STRINGS, STRINGS) {|s1, s2|
- if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
- t = s1[s2]
- if t != nil
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert_equal(s2, t)
- assert_match(/#{Regexp.escape(s2)}/, s1)
- end
- else
- assert_raise(ArgumentError) { s1[s2] }
- end
- }
- end
-
- def test_str_aref_range2
- combination(STRINGS, -2..2, -2..2) {|s, first, last|
- t = s[first..last]
- if first < 0
- first += s.length
- if first < 0
- assert_nil(t, "#{s.inspect}[#{first}..#{last}]")
- next
- end
- end
- if s.length < first
- assert_nil(t, "#{s.inspect}[#{first}..#{last}]")
- next
- end
- assert(t.valid_encoding?) if s.valid_encoding?
- if last < 0
- last += s.length
- end
- t2 = ''
- first.upto(last) {|i|
- c = s[i]
- t2 << c if c
- }
- assert_equal(t2, t, "#{s.inspect}[#{first}..#{last}]")
- }
- end
-
- def test_str_aref_range3
- combination(STRINGS, -2..2, -2..2) {|s, first, last|
- t = s[first...last]
- if first < 0
- first += s.length
- if first < 0
- assert_nil(t, "#{s.inspect}[#{first}..#{last}]")
- next
- end
- end
- if s.length < first
- assert_nil(t, "#{s.inspect}[#{first}..#{last}]")
- next
- end
- if last < 0
- last += s.length
- end
- assert(t.valid_encoding?) if s.valid_encoding?
- t2 = ''
- first.upto(last-1) {|i|
- c = s[i]
- t2 << c if c
- }
- assert_equal(t2, t, "#{s.inspect}[#{first}..#{last}]")
- }
- end
-
- def test_str_assign
- combination(STRINGS, STRINGS) {|s1, s2|
- (-2).upto(2) {|i|
- t = s1.dup
- if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
- if i < -s1.length || s1.length < i
- assert_raise(IndexError) { t[i] = s2 }
- else
- t[i] = s2
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert(a(t).index(a(s2)))
- if s1.valid_encoding? && s2.valid_encoding?
- if i == s1.length && s2.empty?
- assert_nil(t[i])
- elsif i < 0
- assert_equal(s2, t[i-s2.length+1,s2.length],
- "t = #{encdump(s1)}; t[#{i}] = #{encdump(s2)}; t[#{i-s2.length+1},#{s2.length}]")
- else
- assert_equal(s2, t[i,s2.length],
- "t = #{encdump(s1)}; t[#{i}] = #{encdump(s2)}; t[#{i},#{s2.length}]")
- end
- end
- end
- else
- assert_raise(ArgumentError) { t[i] = s2 }
- end
- }
- }
- end
-
- def test_str_assign_len
- combination(STRINGS, -2..2, 0..2, STRINGS) {|s1, i, len, s2|
- t = s1.dup
- if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
- if i < -s1.length || s1.length < i
- assert_raise(IndexError) { t[i,len] = s2 }
- else
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- t[i,len] = s2
- assert(a(t).index(a(s2)))
- if s1.valid_encoding? && s2.valid_encoding?
- if i == s1.length && s2.empty?
- assert_nil(t[i])
- elsif i < 0
- if -i < len
- len = -i
- end
- assert_equal(s2, t[i-s2.length+len,s2.length],
- "t = #{encdump(s1)}; t[#{i},#{len}] = #{encdump(s2)}; t[#{i-s2.length+len},#{s2.length}]")
- else
- assert_equal(s2, t[i,s2.length],
- "t = #{encdump(s1)}; t[#{i},#{len}] = #{encdump(s2)}; t[#{i},#{s2.length}]")
- end
- end
- end
- else
- assert_raise(ArgumentError) { t[i,len] = s2 }
- end
- }
- end
-
- def test_str_assign_substr
- combination(STRINGS, STRINGS, STRINGS) {|s1, s2, s3|
- t = s1.dup
- encs = [
- !s1.ascii_only? ? s1.encoding : nil,
- !s2.ascii_only? ? s2.encoding : nil,
- !s3.ascii_only? ? s3.encoding : nil].uniq.compact
- if 1 < encs.length
- assert_raise(ArgumentError, IndexError) { t[s2] = s3 }
- else
- if encs.empty?
- encs = [
- s1.encoding,
- s2.encoding,
- s3.encoding].uniq.reject {|e| e == Encoding.find("ASCII-8BIT") }
- if encs.empty?
- encs = [Encoding.find("ASCII-8BIT")]
- end
- end
- if !t[s2]
- else
- t[s2] = s3
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding? && s3.valid_encoding?
- end
- end
- }
- end
-
- def test_str_assign_range2
- combination(STRINGS, -2..2, -2..2, STRINGS) {|s1, first, last, s2|
- t = s1.dup
- if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
- if first < -s1.length || s1.length < first
- assert_raise(RangeError) { t[first..last] = s2 }
- else
- t[first..last] = s2
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert(a(t).index(a(s2)))
- if s1.valid_encoding? && s2.valid_encoding?
- if first < 0
- assert_equal(s2, t[s1.length+first, s2.length])
- else
- assert_equal(s2, t[first, s2.length])
- end
- end
- end
- else
- assert_raise(ArgumentError, RangeError,
- "t=#{encdump(s1)};t[#{first}..#{last}]=#{encdump(s2)}") {
- t[first..last] = s2
- }
- end
- }
- end
-
- def test_str_assign_range3
- combination(STRINGS, -2..2, -2..2, STRINGS) {|s1, first, last, s2|
- t = s1.dup
- if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
- if first < -s1.length || s1.length < first
- assert_raise(RangeError) { t[first...last] = s2 }
- else
- t[first...last] = s2
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert(a(t).index(a(s2)))
- if s1.valid_encoding? && s2.valid_encoding?
- if first < 0
- assert_equal(s2, t[s1.length+first, s2.length])
- else
- assert_equal(s2, t[first, s2.length])
- end
- end
- end
- else
- assert_raise(ArgumentError, RangeError,
- "t=#{encdump(s1)};t[#{first}...#{last}]=#{encdump(s2)}") {
- t[first...last] = s2
- }
- end
- }
- end
-
- def test_str_cmp
- combination(STRINGS, STRINGS) {|s1, s2|
- desc = "#{encdump s1} <=> #{encdump s2}"
- r = s1 <=> s2
- if s1 == s2
- assert_equal(0, r, desc)
- else
- assert_not_equal(0, r, desc)
- end
- }
- end
-
- def test_str_capitalize
- STRINGS.each {|s|
- begin
- t1 = s.capitalize
- rescue ArgumentError
- assert(!s.valid_encoding?)
- next
- end
- assert(t1.valid_encoding?) if s.valid_encoding?
- assert(t1.casecmp(s))
- t2 = s.dup
- t2.capitalize!
- assert_equal(t1, t2)
- assert_equal(s.downcase.sub(/\A[a-z]/) {|ch| a(ch).upcase }, t1)
- }
- end
-
- def test_str_casecmp
- combination(STRINGS, STRINGS) {|s1, s2|
- #puts "#{encdump(s1)}.casecmp(#{encdump(s2)})"
- begin
- r = s1.casecmp(s2)
- rescue ArgumentError
- assert(!s1.valid_encoding? || !s2.valid_encoding?)
- next
- end
- #assert_equal(s1.upcase <=> s2.upcase, r)
- }
- end
-
- def test_str_center
- assert_encoding("EUC-JP", "a".center(5, "\xa1\xa2".force_encoding("euc-jp")).encoding)
-
- combination(STRINGS, [0,1,2,3,10]) {|s1, width|
- t = s1.center(width)
- assert(a(t).index(a(s1)))
- }
- combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
- if s2.empty?
- assert_raise(ArgumentError) { s1.center(width, s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.center(width, s2) }
- next
- end
- t = s1.center(width, s2)
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert(a(t).index(a(s1)))
- assert_str_enc_propagation(t, s1, s2) if (t != s1)
- }
- end
-
- def test_str_ljust
- combination(STRINGS, [0,1,2,3,10]) {|s1, width|
- t = s1.ljust(width)
- assert(a(t).index(a(s1)))
- }
- combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
- if s2.empty?
- assert_raise(ArgumentError) { s1.ljust(width, s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.ljust(width, s2) }
- next
- end
- t = s1.ljust(width, s2)
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert(a(t).index(a(s1)))
- assert_str_enc_propagation(t, s1, s2) if (t != s1)
- }
- end
-
- def test_str_rjust
- combination(STRINGS, [0,1,2,3,10]) {|s1, width|
- t = s1.rjust(width)
- assert(a(t).index(a(s1)))
- }
- combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
- if s2.empty?
- assert_raise(ArgumentError) { s1.rjust(width, s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.rjust(width, s2) }
- next
- end
- t = s1.rjust(width, s2)
- assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
- assert(a(t).index(a(s1)))
- assert_str_enc_propagation(t, s1, s2) if (t != s1)
- }
- end
-
- def test_str_chomp
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.chomp(s2) }
- next
- end
- t = s1.chomp(s2)
- assert(t.valid_encoding?, "#{encdump(s1)}.chomp(#{encdump(s2)})") if s1.valid_encoding? && s2.valid_encoding?
- assert_equal(s1.encoding, t.encoding)
- t2 = s1.dup
- t2.chomp!(s2)
- assert_equal(t, t2)
- }
- end
-
- def test_str_chop
- STRINGS.each {|s|
- s = s.dup
- desc = "#{encdump s}.chop"
- if !s.valid_encoding?
- #assert_raise(ArgumentError, desc) { s.chop }
- begin
- s.chop
- rescue ArgumentError
- e = $!
- end
- next if e
- end
- t = nil
- assert_nothing_raised(desc) { t = s.chop }
- assert(t.valid_encoding?) if s.valid_encoding?
- assert(a(s).index(a(t)))
- t2 = s.dup
- t2.chop!
- assert_equal(t, t2)
- }
- end
-
- def test_str_clear
- STRINGS.each {|s|
- t = s.dup
- t.clear
- assert(t.valid_encoding?)
- assert(t.empty?)
- }
- end
-
- def test_str_clone
- STRINGS.each {|s|
- t = s.clone
- assert_equal(s, t)
- assert_equal(s.encoding, t.encoding)
- assert_equal(a(s), a(t))
- }
- end
-
- def test_str_dup
- STRINGS.each {|s|
- t = s.dup
- assert_equal(s, t)
- assert_equal(s.encoding, t.encoding)
- assert_equal(a(s), a(t))
- }
- end
-
- def test_str_count
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_raise(ArgumentError) { s1.count(s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.count(s2) }
- next
- end
- n = s1.count(s2)
- n0 = a(s1).count(a(s2))
- assert_operator(n, :<=, n0)
- }
- end
-
- def test_str_crypt
- combination(STRINGS, STRINGS) {|str, salt|
- if a(salt).length < 2
- assert_raise(ArgumentError) { str.crypt(salt) }
- next
- end
- t = str.crypt(salt)
- assert_equal(a(str).crypt(a(salt)), t)
- assert_encoding('ASCII-8BIT', t.encoding)
- }
- end
-
- def test_str_delete
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_raise(ArgumentError) { s1.delete(s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.delete(s2) }
- next
- end
- t = s1.delete(s2)
- assert(t.valid_encoding?)
- assert_equal(t.encoding, s1.encoding)
- assert_operator(t.length, :<=, s1.length)
- t2 = s1.dup
- t2.delete!(s2)
- assert_equal(t, t2)
- }
- end
-
- def test_str_downcase
- STRINGS.each {|s|
- if !s.valid_encoding?
- assert_raise(ArgumentError) { s.downcase }
- next
- end
- t = s.downcase
- assert(t.valid_encoding?)
- assert_equal(t.encoding, s.encoding)
- assert(t.casecmp(s))
- t2 = s.dup
- t2.downcase!
- assert_equal(t, t2)
- }
- end
-
- def test_str_dump
- STRINGS.each {|s|
- t = s.dump
- assert(t.valid_encoding?)
- assert(t.ascii_only?)
- u = eval(t)
- assert_equal(a(s), a(u))
- }
- end
-
- def test_str_each_line
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_raise(ArgumentError) { s1.each_line(s2) {} }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.each_line(s2) {} }
- next
- end
- lines = []
- s1.each_line(s2) {|line|
- assert(line.valid_encoding?)
- assert_equal(s1.encoding, line.encoding)
- lines << line
- }
- next if lines.size == 0
- s2 = lines.join('')
- assert_equal(s1.encoding, s2.encoding)
- assert_equal(s1, s2)
- }
- end
-
- def test_str_each_byte
- STRINGS.each {|s|
- bytes = []
- s.each_byte {|b|
- bytes << b
- }
- a(s).split(//).each_with_index {|ch, i|
- assert_equal(ch.ord, bytes[i])
- }
- }
- end
-
- def test_str_empty?
- STRINGS.each {|s|
- if s.length == 0
- assert(s.empty?)
- else
- assert(!s.empty?)
- end
- }
- end
-
- def test_str_hex
- STRINGS.each {|s|
- t = s.hex
- t2 = a(s)[/\A[0-9a-fA-Fx]*/].hex
- assert_equal(t2, t)
- }
- end
-
- def test_str_include?
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.include?(s2) }
- assert_raise(ArgumentError) { s1.index(s2) }
- assert_raise(ArgumentError) { s1.rindex(s2) }
- next
- end
- t = s1.include?(s2)
- if t
- assert(a(s1).include?(a(s2)))
- assert(s1.index(s2))
- assert(s1.rindex(s2))
- else
- assert(!s1.index(s2))
- assert(!s1.rindex(s2), "!#{encdump(s1)}.rindex(#{encdump(s2)})")
- end
- if s2.empty?
- assert_equal(true, t)
- next
- end
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_equal(false, t, "#{encdump s1}.include?(#{encdump s2})")
- next
- end
- if t && s1.valid_encoding? && s2.valid_encoding?
- assert_match(/#{Regexp.escape(s2)}/, s1)
- else
- assert_no_match(/#{Regexp.escape(s2)}/, s1)
- end
- }
- end
-
- def test_str_index
- combination(STRINGS, STRINGS, -2..2) {|s1, s2, pos|
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.index(s2) }
- next
- end
- t = s1.index(s2, pos)
- if s2.empty?
- if pos < 0 && pos+s1.length < 0
- assert_equal(nil, t, "#{encdump s1}.index(#{encdump s2}, #{pos})");
- elsif pos < 0
- assert_equal(s1.length+pos, t, "#{encdump s1}.index(#{encdump s2}, #{pos})");
- elsif s1.length < pos
- assert_equal(nil, t, "#{encdump s1}.index(#{encdump s2}, #{pos})");
- else
- assert_equal(pos, t, "#{encdump s1}.index(#{encdump s2}, #{pos})");
- end
- next
- end
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_equal(nil, t, "#{encdump s1}.index(#{encdump s2}, #{pos})");
- next
- end
- if t
- re = /#{Regexp.escape(s2)}/
- assert(re.match(s1, pos))
- assert_equal($`.length, t, "#{encdump s1}.index(#{encdump s2}, #{pos})")
- else
- assert_no_match(/#{Regexp.escape(s2)}/, s1[pos..-1])
- end
- }
- end
-
- def test_str_rindex
- combination(STRINGS, STRINGS, -2..2) {|s1, s2, pos|
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.rindex(s2) }
- next
- end
- t = s1.rindex(s2, pos)
- if s2.empty?
- if pos < 0 && pos+s1.length < 0
- assert_equal(nil, t, "#{encdump s1}.rindex(#{encdump s2}, #{pos})")
- elsif pos < 0
- assert_equal(s1.length+pos, t, "#{encdump s1}.rindex(#{encdump s2}, #{pos})")
- elsif s1.length < pos
- assert_equal(s1.length, t, "#{encdump s1}.rindex(#{encdump s2}, #{pos})")
- else
- assert_equal(pos, t, "#{encdump s1}.rindex(#{encdump s2}, #{pos})")
- end
- next
- end
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_equal(nil, t, "#{encdump s1}.rindex(#{encdump s2}, #{pos})")
- next
- end
- if t
- #puts "#{encdump s1}.rindex(#{encdump s2}, #{pos}) => #{t}"
- assert(a(s1).index(a(s2)))
- pos2 = pos
- pos2 += s1.length if pos < 0
- re = /\A(.{0,#{pos2}})#{Regexp.escape(s2)}/m
- assert(re.match(s1), "#{re.inspect}.match(#{encdump(s1)})")
- assert_equal($1.length, t, "#{encdump s1}.rindex(#{encdump s2}, #{pos})")
- else
- re = /#{Regexp.escape(s2)}/
- n = re =~ s1
- if n
- if pos < 0
- assert_operator(n, :>, s1.length+pos)
- else
- assert_operator(n, :>, pos)
- end
- end
- end
- }
- end
-
- def test_str_insert
- combination(STRINGS, 0..2, STRINGS) {|s1, nth, s2|
- t1 = s1.dup
- t2 = s1.dup
- begin
- t1[nth, 0] = s2
- rescue ArgumentError, IndexError => e1
- end
- begin
- t2.insert(nth, s2)
- rescue ArgumentError, IndexError => e2
- end
- assert_equal(t1, t2, "t=#{encdump s1}; t.insert(#{nth},#{encdump s2}); t")
- assert_equal(e1.class, e2.class, "begin #{encdump s1}.insert(#{nth},#{encdump s2}); rescue ArgumentError, IndexError => e; e end")
- }
- combination(STRINGS, -2..-1, STRINGS) {|s1, nth, s2|
- next if s1.length + nth < 0
- next unless s1.valid_encoding?
- next unless s2.valid_encoding?
- t1 = s1.dup
- begin
- t1.insert(nth, s2)
- slen = s2.length
- assert_equal(t1[nth-slen+1,slen], s2, "t=#{encdump s1}; t.insert(#{nth},#{encdump s2}); t")
- rescue ArgumentError, IndexError => e
- end
- }
- end
-
- def test_str_intern
- STRINGS.each {|s|
- if /\0/ =~ a(s)
- assert_raise(ArgumentError) { s.intern }
- else
- sym = s.intern
- assert_equal(s, sym.to_s)
- end
- }
- end
-
- def test_str_length
- STRINGS.each {|s|
- assert_operator(s.length, :<=, s.bytesize)
- }
- end
-
- def test_str_oct
- STRINGS.each {|s|
- t = s.oct
- t2 = a(s)[/\A[0-9a-fA-FxXbB]*/].oct
- assert_equal(t2, t)
- }
- end
-
- def test_str_replace
- combination(STRINGS, STRINGS) {|s1, s2|
- t = s1.dup
- t.replace s2
- assert_equal(s2, t)
- assert_equal(s2.encoding, t.encoding)
- }
- end
-
- def test_str_reverse
- STRINGS.each {|s|
- t = s.reverse
- assert_equal(s.bytesize, t.bytesize)
- if !s.valid_encoding?
- assert_operator(t.length, :<=, s.length)
- next
- end
- assert_equal(s, t.reverse)
- }
- end
-
- def test_str_scan
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s2.valid_encoding?
- assert_raise(RegexpError) { s1.scan(s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.scan(s2) }
- next
- end
- r = s1.scan(s2)
- r.each {|t|
- assert_equal(s2, t)
- }
- }
- end
-
- def test_str_slice
- each_slice_call {|obj, *args|
- assert_same_result(lambda { obj[*args] }, lambda { obj.slice(*args) })
- }
- end
-
- def test_str_slice!
- each_slice_call {|s, *args|
- t = s.dup
- begin
- r = t.slice!(*args)
- rescue
- e = $!
- end
- if e
- assert_raise(e.class) { s.slice(*args) }
- next
- end
- if !r
- assert_nil(s.slice(*args))
- next
- end
- assert_equal(s.slice(*args), r)
- assert_equal(s.bytesize, r.bytesize + t.bytesize)
- if args.length == 1 && String === args[0]
- assert_equal(args[0].encoding, r.encoding,
- "#{encdump s}.slice!#{encdumpargs args}.encoding")
- else
- assert_equal(s.encoding, r.encoding,
- "#{encdump s}.slice!#{encdumpargs args}.encoding")
- end
- if [s, *args].all? {|o| !(String === o) || o.valid_encoding? }
- assert(r.valid_encoding?)
- assert(t.valid_encoding?)
- assert_equal(s.length, r.length + t.length)
- end
- }
- end
-
- def test_str_split
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s2.valid_encoding?
- assert_raise(RegexpError) { s1.split(s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.split(s2) }
- next
- end
- t = s1.split(s2)
- t.each {|r|
- assert(a(s1).include?(a(r)))
- assert_equal(s1.encoding, r.encoding)
- }
- assert(a(s1).include?(t.map {|u| a(u) }.join(a(s2))))
- if s1.valid_encoding? && s2.valid_encoding?
- t.each {|r|
- assert(r.valid_encoding?)
- }
- end
- }
- end
-
- def test_str_squeeze
- combination(STRINGS, STRINGS) {|s1, s2|
- if !s1.valid_encoding? || !s2.valid_encoding?
- assert_raise(ArgumentError, "#{encdump s1}.squeeze(#{encdump s2})") { s1.squeeze(s2) }
- next
- end
- if !s1.ascii_only? && !s2.ascii_only? && s1.encoding != s2.encoding
- assert_raise(ArgumentError) { s1.squeeze(s2) }
- next
- end
- t = s1.squeeze(s2)
- assert_operator(t.length, :<=, s1.length)
- t2 = s1.dup
- t2.squeeze!(s2)
- assert_equal(t, t2)
- }
- end
-
- def test_squeeze
- s = "\xa3\xb0\xa3\xb1\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
- assert_equal("\xa3\xb0\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp"), s.squeeze)
- end
-
- def test_str_strip
- STRINGS.each {|s|
- if !s.valid_encoding?
- assert_raise(ArgumentError, "#{encdump s}.strip") { s.strip }
- next
- end
- t = s.strip
- l = s.lstrip
- r = s.rstrip
- assert_operator(l.length, :<=, s.length)
- assert_operator(r.length, :<=, s.length)
- assert_operator(t.length, :<=, l.length)
- assert_operator(t.length, :<=, r.length)
- t2 = s.dup
- t2.strip!
- assert_equal(t, t2)
- l2 = s.dup
- l2.lstrip!
- assert_equal(l, l2)
- r2 = s.dup
- r2.rstrip!
- assert_equal(r, r2)
- }
- end
-
- def test_str_sum
- STRINGS.each {|s|
- assert_equal(a(s).sum, s.sum)
- }
- end
-
- def test_str_swapcase
- STRINGS.each {|s|
- if !s.valid_encoding?
- assert_raise(ArgumentError, "#{encdump s}.swapcase") { s.swapcase }
- next
- end
- t1 = s.swapcase
- assert(t1.valid_encoding?) if s.valid_encoding?
- assert(t1.casecmp(s))
- t2 = s.dup
- t2.swapcase!
- assert_equal(t1, t2)
- t3 = t1.swapcase
- assert_equal(s, t3);
- }
- end
-
-
- def test_str_to_f
- STRINGS.each {|s|
- assert_nothing_raised { s.to_f }
- }
- end
-
- def test_str_to_i
- STRINGS.each {|s|
- assert_nothing_raised { s.to_i }
- 2.upto(36) {|radix|
- assert_nothing_raised { s.to_i(radix) }
- }
- }
- end
-
- def test_str_to_s
- STRINGS.each {|s|
- assert_same(s, s.to_s)
- assert_same(s, s.to_str)
- }
- end
-
- def test_tr
- s = "\x81\x41".force_encoding("shift_jis")
- assert_equal(s.tr("A", "B"), s)
- assert_equal(s.tr_s("A", "B"), s)
-
- assert_nothing_raised {
- "a".force_encoding("ASCII-8BIT").tr("a".force_encoding("ASCII-8BIT"), "a".force_encoding("EUC-JP"))
- }
-
- assert_equal("\xA1\xA1".force_encoding("EUC-JP"),
- "a".force_encoding("ASCII-8BIT").tr("a".force_encoding("ASCII-8BIT"), "\xA1\xA1".force_encoding("EUC-JP")))
-
- combination(STRINGS, STRINGS, STRINGS) {|s1, s2, s3|
- desc = "#{encdump s1}.tr(#{encdump s2}, #{encdump s3})"
- if s1.empty?
- assert_equal(s1, s1.tr(s2, s3), desc)
- next
- end
- if !str_enc_compatible?(s1, s2, s3)
- assert_raise(ArgumentError, desc) { s1.tr(s2, s3) }
- next
- end
- if !s1.valid_encoding?
- assert_raise(ArgumentError, desc) { s1.tr(s2, s3) }
- next
- end
- if s2.empty?
- assert_equal(s1, s1.tr(s2, s3), desc)
- next
- end
- if !s2.valid_encoding? || !s3.valid_encoding?
- assert_raise(ArgumentError, desc) { s1.tr(s2, s3) }
- next
- end
- t = s1.tr(s2, s3)
- assert_operator(s1.length, :>=, t.length, desc)
- }
- end
-
- def test_tr_s
- assert_equal("\xA1\xA1".force_encoding("EUC-JP"),
- "a".force_encoding("ASCII-8BIT").tr("a".force_encoding("ASCII-8BIT"), "\xA1\xA1".force_encoding("EUC-JP")))
-
- combination(STRINGS, STRINGS, STRINGS) {|s1, s2, s3|
- desc = "#{encdump s1}.tr_s(#{encdump s2}, #{encdump s3})"
- if s1.empty?
- assert_equal(s1, s1.tr_s(s2, s3), desc)
- next
- end
- if !s1.valid_encoding?
- assert_raise(ArgumentError, desc) { s1.tr_s(s2, s3) }
- next
- end
- if !str_enc_compatible?(s1, s2, s3)
- assert_raise(ArgumentError, desc) { s1.tr(s2, s3) }
- next
- end
- if s2.empty?
- assert_equal(s1, s1.tr_s(s2, s3), desc)
- next
- end
- if !s2.valid_encoding? || !s3.valid_encoding?
- assert_raise(ArgumentError, desc) { s1.tr_s(s2, s3) }
- next
- end
-
- t = nil
- assert_nothing_raised(desc) { t = s1.tr_s(s1, s3) }
- assert_operator(s1.length, :>=, t.length, desc)
- }
- end
-
- def test_str_upcase
- STRINGS.each {|s|
- desc = "#{encdump s}.upcase"
- if !s.valid_encoding?
- assert_raise(ArgumentError, desc) { s.upcase }
- next
- end
- t1 = s.upcase
- assert(t1.valid_encoding?)
- assert(t1.casecmp(s))
- t2 = s.dup
- t2.upcase!
- assert_equal(t1, t2)
- }
- end
-
- def test_str_succ
- starts = [
- e("\xA1\xA1"),
- e("\xFE\xFE")
- ]
- STRINGS.each {|s0|
- next if s0.empty?
- s = s0.dup
- n = 1000
- h = {}
- n.times {|i|
- if h[s]
- assert(false, "#{encdump s} cycle with succ! #{i-h[s]} times")
- end
- h[s] = i
- assert_operator(s.length, :<=, s0.length + Math.log2(i+1) + 1, "#{encdump s0} succ! #{i} times => #{encdump s}")
- s.succ!
- }
- }
- end
-
- def test_str_hash
- combination(STRINGS, STRINGS) {|s1, s2|
- if s1.eql?(s2)
- assert_equal(s1.hash, s2.hash, "#{encdump s1}.hash == #{encdump s2}.dump")
- end
- }
- end
-
- def test_sub
- s = "abc".sub(/b/, "\xa1\xa1".force_encoding("euc-jp"))
- assert_encoding("EUC-JP", s.encoding)
- assert_equal(Encoding::EUC_JP, "\xa4\xa2".force_encoding("euc-jp").sub(/./, '\&').encoding)
- assert_equal(Encoding::EUC_JP, "\xa4\xa2".force_encoding("euc-jp").gsub(/./, '\&').encoding)
- end
-
- def test_regexp_match
- assert_equal([0,0], //.match("\xa1\xa1".force_encoding("euc-jp"),-1).offset(0))
- end
-
- def test_nonascii_method_name
- eval(e("def \xc2\xa1() @nonascii_method_name = :e end"))
- eval(u("def \xc2\xa1() @nonascii_method_name = :u end"))
- eval(e("\xc2\xa1()"))
- assert_equal(:e, @nonascii_method_name)
- eval(u("\xc2\xa1()"))
- assert_equal(:u, @nonascii_method_name)
- me = method(e("\xc2\xa1"))
- mu = method(u("\xc2\xa1"))
- assert_not_equal(me.name, mu.name)
- assert_not_equal(me.inspect, mu.inspect)
- assert_equal(e("\xc2\xa1"), me.name)
- assert_equal(u("\xc2\xa1"), mu.name)
- end
-
- def test_symbol
- s1 = "\xc2\xa1".force_encoding("euc-jp").intern
- s2 = "\xc2\xa1".force_encoding("utf-8").intern
- assert_not_equal(s1, s2)
- end
-
- def test_chr
- 0.upto(255) {|b|
- assert_equal([b].pack("C"), b.chr)
- }
- end
-
- def test_marshal
- STRINGS.each {|s|
- m = Marshal.dump(s)
- t = Marshal.load(m)
- assert_equal(s, t)
- }
- end
-
- def test_env
- ENV.each {|k, v|
- assert_equal(Encoding::ASCII_8BIT, k.encoding)
- assert_equal(Encoding::ASCII_8BIT, v.encoding)
- }
- end
-end
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 049db1221e..11f3583076 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -1,5 +1,12 @@
require 'test/unit'
-require 'marshaltestlib'
+dir = File.dirname(File.expand_path(__FILE__))
+orgpath = $:.dup
+begin
+ $:.push(dir)
+ require 'marshaltestlib'
+ensure
+ $:.replace(orgpath)
+end
class TestMarshal < Test::Unit::TestCase
include MarshalTestLib
@@ -22,34 +29,20 @@ class TestMarshal < Test::Unit::TestCase
return f
end
- def test_marshal
- x = [1, 2, 3, [4,5,"foo"], {1=>"bar"}, 2.5, fact(30)]
- assert_equal x, Marshal.load(Marshal.dump(x))
+ StrClone=String.clone;
- [[1,2,3,4], [81, 2, 118, 3146]].each { |w,x,y,z|
- obj = (x.to_f + y.to_f / z.to_f) * Math.exp(w.to_f / (x.to_f + y.to_f / z.to_f))
- assert_equal obj, Marshal.load(Marshal.dump(obj))
- }
- end
+ def test_marshal
+ $x = [1,2,3,[4,5,"foo"],{1=>"bar"},2.5,fact(30)]
+ $y = Marshal.dump($x)
+ assert_equal($x, Marshal.load($y))
- StrClone = String.clone
- def test_marshal_cloned_class
assert_instance_of(StrClone, Marshal.load(Marshal.dump(StrClone.new("abc"))))
- end
- def test_inconsistent_struct
- TestMarshal.const_set :StructOrNot, Struct.new(:a)
- s = Marshal.dump(StructOrNot.new(1))
- TestMarshal.instance_eval { remove_const :StructOrNot }
- TestMarshal.const_set :StructOrNot, Class.new
- assert_raise(TypeError, "[ruby-dev:31709]") { Marshal.load(s) }
- end
-
- def test_struct_invalid_members
- TestMarshal.const_set :StructInvalidMembers, Struct.new(:a)
- Marshal.load("\004\bIc&TestMarshal::StructInvalidMembers\006:\020__members__\"\bfoo")
- assert_raise(TypeError, "[ruby-dev:31759]") {
- TestMarshal::StructInvalidMembers.members
+ [[1,2,3,4], [81, 2, 118, 3146]].each { |w,x,y,z|
+ a = (x.to_f + y.to_f / z.to_f) * Math.exp(w.to_f / (x.to_f + y.to_f / z.to_f))
+ ma = Marshal.dump(a)
+ b = Marshal.load(ma)
+ assert_equal(a, b)
}
end
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index c7bd443785..d721176aa0 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -8,8 +8,6 @@ class TestMethod < Test::Unit::TestCase
def mo2(a, b = nil) end
def mo3(*a) end
def mo4(a, *b, &c) end
- def mo5(a, *b, c) end
- def mo6(a, *b, c, &d) end
class Base
def foo() :base end
@@ -26,8 +24,6 @@ class TestMethod < Test::Unit::TestCase
assert_equal(-2, method(:mo2).arity)
assert_equal(-1, method(:mo3).arity)
assert_equal(-2, method(:mo4).arity)
- assert_equal(-3, method(:mo5).arity)
- assert_equal(-3, method(:mo6).arity)
end
def test_unbind
@@ -44,12 +40,14 @@ class TestMethod < Test::Unit::TestCase
end
end
- def test_callee
- assert_equal(:test_callee, __method__)
- assert_equal(:m, Class.new {def m; __method__; end}.new.m)
- assert_equal(:m, Class.new {def m; tap{return __method__}; end}.new.m)
- assert_equal(:m, Class.new {define_method(:m) {__method__}}.new.m)
- assert_equal(:m, Class.new {define_method(:m) {tap{return __method__}}}.new.m)
- assert_nil(eval("class TestCallee; __method__; end"))
+ def test_receiver_name_owner
+ o = Object.new
+ def o.foo; end
+ m = o.method(:foo)
+ assert_equal(o, m.receiver)
+ assert_equal("foo", m.name)
+ assert_equal(class << o; self; end, m.owner)
+ assert_equal("foo", m.unbind.name)
+ assert_equal(class << o; self; end, m.unbind.owner)
end
end
diff --git a/test/ruby/test_mixed_unicode_escapes.rb b/test/ruby/test_mixed_unicode_escapes.rb
deleted file mode 100644
index e80e6fb14e..0000000000
--- a/test/ruby/test_mixed_unicode_escapes.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: sjis -*-
-# This test is in a differnt file than TestUnicodeEscapes
-# So that we can have a different coding comment above
-
-require 'test/unit'
-
-class TestMixedUnicodeEscape < Test::Unit::TestCase
- def test_basic
- # Unicode escapes do work in an sjis encoded file, but only
- # if they don't contain other multi-byte chars
- assert_equal("A", "\u0041")
- # 8-bit character escapes are okay.
- assert_equal("B\xFF", "\u0042\xFF")
-
- # sjis mb chars mixed with Unicode shound not work
- assert_raise(SyntaxError) { eval %q("é\u1234")}
- assert_raise(SyntaxError) { eval %q("\u{1234}é")}
-
- # String interpolation turns into an expression and we get
- # a different kind of error, but we still can't mix these
- assert_raise(ArgumentError) { eval %q("\u{1234}#{nil}é")}
- assert_raise(ArgumentError) { eval %q("é#{nil}\u1234")}
-
- end
-end
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
deleted file mode 100644
index 81ba08cf32..0000000000
--- a/test/ruby/test_module.rb
+++ /dev/null
@@ -1,316 +0,0 @@
-require 'test/unit'
-require 'pp'
-
-$m0 = Module.nesting
-
-class TestModule < Test::Unit::TestCase
-
- def test_LT_0
- assert_equal true, String < Object
- assert_equal false, Object < String
- assert_nil String < Array
- assert_equal true, Array < Enumerable
- assert_equal false, Enumerable < Array
- assert_nil Proc < Comparable
- assert_nil Comparable < Proc
- end
-
- def test_GT_0
- assert_equal false, String > Object
- assert_equal true, Object > String
- assert_nil String > Array
- assert_equal false, Array > Enumerable
- assert_equal true, Enumerable > Array
- assert_nil Comparable > Proc
- assert_nil Proc > Comparable
- end
-
- def test_CMP_0
- assert_equal -1, (String <=> Object)
- assert_equal 1, (Object <=> String)
- assert_nil(Array <=> String)
- end
-
- ExpectedException = NoMethodError
-
- # Support stuff
-
- def remove_pp_mixins(list)
- list.reject {|c| c == PP::ObjectMixin }
- end
-
- module Mixin
- MIXIN = 1
- def mixin
- end
- end
-
- module User
- USER = 2
- include Mixin
- def user
- end
- end
-
- module Other
- def other
- end
- end
-
- class AClass
- def AClass.cm1
- "cm1"
- end
- def AClass.cm2
- cm1 + "cm2" + cm3
- end
- def AClass.cm3
- "cm3"
- end
-
- private_class_method :cm1, "cm3"
-
- def aClass
- end
-
- def aClass1
- end
-
- def aClass2
- end
-
- private :aClass1
- protected :aClass2
- end
-
- class BClass < AClass
- def bClass1
- end
-
- private
-
- def bClass2
- end
-
- protected
- def bClass3
- end
- end
-
- MyClass = AClass.clone
- class MyClass
- public_class_method :cm1
- end
-
- # -----------------------------------------------------------
-
- def test_CMP # '<=>'
- assert_equal( 0, Mixin <=> Mixin)
- assert_equal(-1, User <=> Mixin)
- assert_equal( 1, Mixin <=> User)
-
- assert_equal( 0, Object <=> Object)
- assert_equal(-1, String <=> Object)
- assert_equal( 1, Object <=> String)
- end
-
- def test_GE # '>='
- assert(Mixin >= User)
- assert(Mixin >= Mixin)
- assert(!(User >= Mixin))
-
- assert(Object >= String)
- assert(String >= String)
- assert(!(String >= Object))
- end
-
- def test_GT # '>'
- assert(Mixin > User)
- assert(!(Mixin > Mixin))
- assert(!(User > Mixin))
-
- assert(Object > String)
- assert(!(String > String))
- assert(!(String > Object))
- end
-
- def test_LE # '<='
- assert(User <= Mixin)
- assert(Mixin <= Mixin)
- assert(!(Mixin <= User))
-
- assert(String <= Object)
- assert(String <= String)
- assert(!(Object <= String))
- end
-
- def test_LT # '<'
- assert(User < Mixin)
- assert(!(Mixin < Mixin))
- assert(!(Mixin < User))
-
- assert(String < Object)
- assert(!(String < String))
- assert(!(Object < String))
- end
-
- def test_VERY_EQUAL # '==='
- assert(Object === self)
- assert(Test::Unit::TestCase === self)
- assert(TestModule === self)
- assert(!(String === self))
- end
-
- def test_ancestors
- assert_equal([User, Mixin], User.ancestors)
- assert_equal([Mixin], Mixin.ancestors)
-
- assert_equal([Object, Kernel, BasicObject], remove_pp_mixins(Object.ancestors))
- assert_equal([String, Comparable, Object, Kernel, BasicObject],
- remove_pp_mixins(String.ancestors))
- end
-
- def test_class_eval
- Other.class_eval("CLASS_EVAL = 1")
- assert_equal(1, Other::CLASS_EVAL)
- assert(Other.constants.include?(:CLASS_EVAL))
- end
-
- def test_class_variable_set
- # TODO
- end
-
- def test_class_variable_get
- # TODO
- end
-
- def test_const_defined?
- assert(Math.const_defined?(:PI))
- assert(Math.const_defined?("PI"))
- assert(!Math.const_defined?(:IP))
- assert(!Math.const_defined?("IP"))
- end
-
- def test_const_get
- assert_equal(Math::PI, Math.const_get("PI"))
- assert_equal(Math::PI, Math.const_get(:PI))
- end
-
- def test_const_set
- assert(!Other.const_defined?(:KOALA))
- Other.const_set(:KOALA, 99)
- assert(Other.const_defined?(:KOALA))
- assert_equal(99, Other::KOALA)
- Other.const_set("WOMBAT", "Hi")
- assert_equal("Hi", Other::WOMBAT)
- end
-
- def test_constants
- assert_equal([:MIXIN], Mixin.constants)
- assert_equal([:MIXIN, :USER], User.constants.sort)
- end
-
- def test_included_modules
- assert_equal([], Mixin.included_modules)
- assert_equal([Mixin], User.included_modules)
- assert_equal([Kernel], remove_pp_mixins(Object.included_modules))
- assert_equal([Comparable, Kernel],
- remove_pp_mixins(String.included_modules))
- end
-
- def test_instance_methods
- assert_equal([:user], User.instance_methods(false))
- assert_equal([:user, :mixin].sort, User.instance_methods(true).sort)
- assert_equal([:mixin], Mixin.instance_methods)
- assert_equal([:mixin], Mixin.instance_methods(true))
- # Ruby 1.8 feature change:
- # #instance_methods includes protected methods.
- #assert_equal([:aClass], AClass.instance_methods(false))
- assert_equal([:aClass, :aClass2], AClass.instance_methods(false).sort)
- assert_equal([:aClass, :aClass2],
- (AClass.instance_methods(true) - Object.instance_methods(true)).sort)
- end
-
- def test_method_defined?
- assert(!User.method_defined?(:wombat))
- assert(User.method_defined?(:user))
- assert(User.method_defined?(:mixin))
- assert(!User.method_defined?(:wombat))
- assert(User.method_defined?(:user))
- assert(User.method_defined?(:mixin))
- end
-
- def test_module_eval
- User.module_eval("MODULE_EVAL = 1")
- assert_equal(1, User::MODULE_EVAL)
- assert(User.constants.include?(:MODULE_EVAL))
- User.instance_eval("remove_const(:MODULE_EVAL)")
- assert(!User.constants.include?(:MODULE_EVAL))
- end
-
- def test_name
- assert_equal("Fixnum", Fixnum.name)
- assert_equal("TestModule::Mixin", Mixin.name)
- assert_equal("TestModule::User", User.name)
- end
-
- def test_private_class_method
- assert_raise(ExpectedException) { AClass.cm1 }
- assert_raise(ExpectedException) { AClass.cm3 }
- assert_equal("cm1cm2cm3", AClass.cm2)
- end
-
- def test_private_instance_methods
- assert_equal([:aClass1], AClass.private_instance_methods(false))
- assert_equal([:bClass2], BClass.private_instance_methods(false))
- assert_equal([:aClass1, :bClass2],
- (BClass.private_instance_methods(true) -
- Object.private_instance_methods(true)).sort)
- end
-
- def test_protected_instance_methods
- assert_equal([:aClass2], AClass.protected_instance_methods)
- assert_equal([:bClass3], BClass.protected_instance_methods(false))
- assert_equal([:bClass3, :aClass2].sort,
- (BClass.protected_instance_methods(true) -
- Object.protected_instance_methods(true)).sort)
- end
-
- def test_public_class_method
- assert_equal("cm1", MyClass.cm1)
- assert_equal("cm1cm2cm3", MyClass.cm2)
- assert_raise(ExpectedException) { eval "MyClass.cm3" }
- end
-
- def test_public_instance_methods
- assert_equal([:aClass], AClass.public_instance_methods(false))
- assert_equal([:bClass1], BClass.public_instance_methods(false))
- end
-
- def test_s_constants
- c1 = Module.constants
- Object.module_eval "WALTER = 99"
- c2 = Module.constants
- assert_equal([:WALTER], c2 - c1)
- end
-
- module M1
- $m1 = Module.nesting
- module M2
- $m2 = Module.nesting
- end
- end
-
- def test_s_nesting
- assert_equal([], $m0)
- assert_equal([TestModule::M1, TestModule], $m1)
- assert_equal([TestModule::M1::M2,
- TestModule::M1, TestModule], $m2)
- end
-
- def test_s_new
- m = Module.new
- assert_instance_of(Module, m)
- end
-
-end
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
deleted file mode 100644
index 8e8311e6ef..0000000000
--- a/test/ruby/test_optimization.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-require 'test/unit'
-
-class TestRubyOptimization < Test::Unit::TestCase
-
- BIGNUM_POS_MIN_32 = 1073741824 # 2 ** 30
- if BIGNUM_POS_MIN_32.kind_of?(Fixnum)
- FIXNUM_MAX = 4611686018427387903 # 2 ** 62 - 1
- else
- FIXNUM_MAX = 1073741823 # 2 ** 30 - 1
- end
-
- BIGNUM_NEG_MAX_32 = -1073741825 # -2 ** 30 - 1
- if BIGNUM_NEG_MAX_32.kind_of?(Fixnum)
- FIXNUM_MIN = -4611686018427387904 # -2 ** 62
- else
- FIXNUM_MIN = -1073741824 # -2 ** 30
- end
-
- def redefine_method(klass, method)
- (@redefine_method_seq ||= 0)
- seq = (@redefine_method_seq += 1)
- eval(<<-End, ::TOPLEVEL_BINDING)
- class #{klass}
- alias redefine_method_orig_#{seq} #{method}
- undef #{method}
- def #{method}(*args)
- args[0]
- end
- end
- End
- begin
- return yield
- ensure
- eval(<<-End, ::TOPLEVEL_BINDING)
- class #{klass}
- undef #{method}
- alias #{method} redefine_method_orig_#{seq}
- end
- End
- end
- end
-
- def test_fixnum_plus
- a, b = 1, 2
- assert_equal 3, a + b
- assert_instance_of Fixnum, FIXNUM_MAX
- assert_instance_of Bignum, FIXNUM_MAX + 1
-
- assert_equal 21, 10 + 11
- assert_equal 11, redefine_method('Fixnum', '+') { 10 + 11 }
- assert_equal 21, 10 + 11
- end
-
- def test_fixnum_minus
- assert_equal 5, 8 - 3
- assert_instance_of Fixnum, FIXNUM_MIN
- assert_instance_of Bignum, FIXNUM_MIN - 1
-
- assert_equal 5, 8 - 3
- assert_equal 3, redefine_method('Fixnum', '-') { 8 - 3 }
- assert_equal 5, 8 - 3
- end
-
- def test_fixnum_mul
- assert_equal 15, 3 * 5
- end
-
- def test_fixnum_div
- assert_equal 3, 15 / 5
- end
-
- def test_fixnum_mod
- assert_equal 1, 8 % 7
- end
-
- def test_float_plus
- assert_equal 4.0, 2.0 + 2.0
- assert_equal 2.0, redefine_method('Float', '+') { 2.0 + 2.0 }
- assert_equal 4.0, 2.0 + 2.0
- end
-
- def test_string_length
- assert_equal 6, "string".length
- assert_nil redefine_method('String', 'length') { "string".length }
- assert_equal 6, "string".length
- end
-
- def test_string_plus
- assert_equal "", "" + ""
- assert_equal "x", "x" + ""
- assert_equal "x", "" + "x"
- assert_equal "ab", "a" + "b"
- assert_equal 'b', redefine_method('String', '+') { "a" + "b" }
- assert_equal "ab", "a" + "b"
- end
-
- def test_string_succ
- assert_equal 'b', 'a'.succ
- assert_equal 'B', 'A'.succ
- end
-
- def test_string_format
- assert_equal '2', '%d' % 2
- end
-
- def test_array_plus
- assert_equal [1,2], [1]+[2]
- end
-
- def test_array_minus
- assert_equal [2], [1,2] - [1]
- end
-
- def test_array_length
- assert_equal 0, [].length
- assert_equal 3, [1,2,3].length
- end
-
- def test_hash_length
- assert_equal 0, {}.length
- assert_equal 1, {1=>1}.length
- end
-
- class MyObj
- def ==(other)
- true
- end
- end
-
- def test_eq
- assert_equal true, nil == nil
- assert_equal true, 1 == 1
- assert_equal true, 'string' == 'string'
- assert_equal true, 1 == MyObj.new
- assert_equal false, nil == MyObj.new
- assert_equal true, MyObj.new == 1
- assert_equal true, MyObj.new == nil
- end
-
-end
diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb
index 18c701f033..63dbd07346 100644
--- a/test/ruby/test_path.rb
+++ b/test/ruby/test_path.rb
@@ -44,13 +44,13 @@ class TestPath < Test::Unit::TestCase
assert_equal("//sub", File.expand_path("sub", "//"))
end
- def test_dirname
+ def test_dirname # [ruby-dev:27738]
if /(bcc|ms)win\d|mingw|cygwin|djgpp|human|emx/ =~ RUBY_PLATFORM
# DOSISH_DRIVE_LETTER
assert_equal('C:.', File.dirname('C:'))
assert_equal('C:.', File.dirname('C:a'))
assert_equal('C:.', File.dirname('C:a/'))
- assert_equal('C:a', File.dirname('C:a/b'), "[ruby-dev:27738]")
+ assert_equal('C:a', File.dirname('C:a/b'))
assert_equal('C:/', File.dirname('C:/'))
assert_equal('C:/', File.dirname('C:/a'))
@@ -62,7 +62,7 @@ class TestPath < Test::Unit::TestCase
assert_equal('C:/', File.dirname('C://a/'))
assert_equal('C:/a', File.dirname('C://a/b'))
- assert_equal('C:/', File.dirname('C:///'), "[ruby-dev:27738]")
+ assert_equal('C:/', File.dirname('C:///'))
assert_equal('C:/', File.dirname('C:///a'))
assert_equal('C:/', File.dirname('C:///a/'))
assert_equal('C:/a', File.dirname('C:///a/b'))
@@ -134,7 +134,7 @@ class TestPath < Test::Unit::TestCase
end
end
- def test_basename
+ def test_basename # [ruby-dev:27766]
if /(bcc|ms)win\d|mingw|cygwin|djgpp|human|emx/ =~ RUBY_PLATFORM
# DOSISH_DRIVE_LETTER
assert_equal('', File.basename('C:'))
@@ -194,7 +194,7 @@ class TestPath < Test::Unit::TestCase
assert_equal('/', File.basename('//'))
assert_equal('/', File.basename('//a'))
assert_equal('/', File.basename('//a/'))
- assert_equal('/', File.basename('//a/b'), "[ruby-dev:27776]")
+ assert_equal('/', File.basename('//a/b'))
assert_equal('/', File.basename('//a/b/'))
assert_equal('c', File.basename('//a/b/c'))
diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb
index 73c7965e8c..c3b4d29c0a 100644
--- a/test/ruby/test_pipe.rb
+++ b/test/ruby/test_pipe.rb
@@ -1,5 +1,7 @@
require 'test/unit'
+$:.replace([File.dirname(File.expand_path(__FILE__))] | $:)
require 'ut_eof'
+require 'envutil'
class TestPipe < Test::Unit::TestCase
include TestEOF
diff --git a/test/ruby/test_primitive.rb b/test/ruby/test_primitive.rb
deleted file mode 100644
index 8ffbe549d6..0000000000
--- a/test/ruby/test_primitive.rb
+++ /dev/null
@@ -1,397 +0,0 @@
-require 'test/unit'
-
-class TestRubyPrimitive < Test::Unit::TestCase
-
- def test_not
- assert_equal false, !true
- assert_equal true, !false
- assert_equal true, !nil
- assert_equal false, !(1+1)
- assert_equal false, !!nil
- assert_equal true, !!1
- end
-
- def test_lvar
- a = 1
- assert_equal 1, a
- b = 2
- assert_equal 1, a
- a = b = 3
- assert_equal 3, a
- assert_equal 3, b
- a = b = c = 4
- assert_equal 4, a
- assert_equal 4, b
- assert_equal 4, c
- end
-
- C = 1
- class A
- Const = 1
- class B
- Const = 2
- class C
- Const = 3
- def const
- Const
- end
- end
- end
- end
- (1..2).map {
- A::B::C::Const
- }
-
- def test_constant
- assert_equal 1, C
- assert_equal 1, C
- assert_equal 1, A::Const
- assert_equal 2, A::B::Const
- assert_equal 3, A::B::C::Const
- assert_equal 3, A::B::C.new.const
- assert_equal 1, ::TestRubyPrimitive::A::Const
- A::B::C.send(:remove_const, :Const)
- assert_equal 2, A::B::C.new.const
- assert_raise(TypeError) {
- C::CONST
- }
- end
-
- class A2
- class B2
- class C2
- C = 7
- end
- end
- end
-
- def test_constant_cache
- i = 0
- while i < 3
- r = A2::B2::C2::C
- i += 1
- end
- assert_equal 7, r
- end
-
- class A3
- class B3
- C = 99
- end
- end
- i = 0
- while i < 3
- r = A3::B3::C # cache
- class A3::B3
- remove_const :C
- end
- A3::B3::C = i ** i
- i += 1
- end
-
- def test_constant_cache2
- assert_equal 4, A3::B3::C
- end
-
- class A4
- Const = 7
- (1..3).map {
- $test_ruby_primitive_constant_cache3 = self::Const
- }
- end
-
- def test_constant_cache3
- assert_equal 7, $test_ruby_primitive_constant_cache3
- end
-
- class A5
- Const = 8
- (1..3).map {
- $test_ruby_primitive_constant_cache4 = eval('self')::Const
- }
- end
-
- def test_constatant_cache4
- assert_equal 8, $test_ruby_primitive_constant_cache4
- end
-
- class A6
- Const = 0
- def self.foo
- self::Const
- end
- end
- class B6 < A6
- Const = 1
- end
- class C6 < B6
- Const = 2
- end
- $test_ruby_primitive_constant_cache5 = [A6.foo, B6.foo, C6.foo]
-
- def test_constant_cache5
- assert_equal [0, 1, 2], $test_ruby_primitive_constant_cache5
- end
-
- def test_gvar
- $test_ruby_primitive_gvar = 7
- assert_equal 7, $test_ruby_primitive_gvar
- assert_equal 7, $test_ruby_primitive_gvar
- $test_ruby_primitive_gvar = 88
- assert_equal 88, $test_ruby_primitive_gvar
- assert_equal 88, $test_ruby_primitive_gvar
- assert_equal 7, ($test_ruby_primitive_gvar = 7)
- assert_equal 7, ($test_ruby_primitive_gvar = 7)
- end
-
- class A7
- @@c = 1
- def m
- @@c += 1
- end
- end
-
- def test_cvar_from_instance_method
- assert_equal 2, A7.new.m
- assert_equal 3, A7.new.m
- assert_equal 4, A7.new.m
- end
-
- class A8
- @@c = 1
- class << self
- def m
- @@c += 1
- end
- end
- end
-
- def test_cvar_from_singleton_method
- assert_equal 2, A8.m
- assert_equal 3, A8.m
- assert_equal 4, A8.m
- end
-
- class A9
- @@c = 1
- def self.m
- @@c += 1
- end
- end
-
- def test_cvar_from_singleton_method2
- assert_equal 2, A9.m
- assert_equal 3, A9.m
- assert_equal 4, A9.m
- end
-
- class A10
- attr_accessor :a
- end
-
- def test_opassign
- i = 0
- i += 1
- assert_equal 1, i
-
- @iv = 2
- @iv += 2
- assert_equal 4, @iv
-
- @@cv ||= 1
- assert_equal 1, @@cv
- @@cv &&= 2
- assert_equal 2, @@cv
- @@cv ||= 99
- assert_equal 2, @@cv
-
- $gv = 3
- $gv += 4
- assert_equal 7, $gv
-
- obj = A10.new
- obj.a = 9
- obj.a &&= 7
- assert_equal 7, obj.a
-
- obj.a = nil
- obj.a ||= 2
- assert_equal 2, obj.a
-
- obj.a &&= 3
- assert_equal 3, obj.a
-
- a = []
- a[0] ||= 3
- assert_equal 3, a[0]
- a[0] &&= 7
- assert_equal 7, a[0]
- a[0] ||= 3
- assert_equal 7, a[0]
- end
-
- def test_opassign_and_or
- a = 1
- a ||= 2
- assert_equal 1, a
- a = nil
- a ||= 2
- assert_equal 2, a
- a = 1
- a &&= 3
- assert_equal 3, a
- a = nil
- a &&= 4
- assert_nil a
-
- h = {}
- h[0] ||= 1
- assert_equal 1, h[0]
- h = {}
- h[0] &&= 1
- assert_nil h[0]
- h = {0 => 7}
- h[0] ||= 1
- assert_equal 7, h[0]
- h = {0 => 7}
- h[0] &&= 1
- assert_equal 1, h[0]
- end
-
- def test_backref
- /a(b)(c)d/ =~ 'xyzabcdefgabcdefg'
- assert_equal 'b', $1
- assert_equal 'c', $2
- assert_nil $3
- assert_instance_of MatchData, $~
- assert_equal 'abcd', $&
- assert_equal 'xyz', $`
- assert_equal 'efgabcdefg', $'
- assert_equal 'c', $+
-
- /(?!)/ =~ 'xyzabcdefgabcdefg'
- assert_nil $1
- assert_nil $2
- assert_nil $3
- assert_nil $~
- assert_nil $&
- assert_nil $`
- assert_nil $'
- assert_nil $+
- end
-
- def test_fact
- assert_equal 306057512216440636035370461297268629388588804173576999416776741259476533176716867465515291422477573349939147888701726368864263907759003154226842927906974559841225476930271954604008012215776252176854255965356903506788725264321896264299365204576448830388909753943489625436053225980776521270822437639449120128678675368305712293681943649956460498166450227716500185176546469340112226034729724066333258583506870150169794168850353752137554910289126407157154830282284937952636580145235233156936482233436799254594095276820608062232812387383880817049600000000000000000000000000000000000000000000000000000000000000000000000000, fact(300)
- end
-
- def fact(n)
- if n > 1
- n * fact(n - 1)
- else
- 1
- end
- end
-
- def test_mul
- assert_equal 0, 2 * 0
- assert_equal 0, 0 * 2
- assert_equal 4, 2 * 2
- end
-
- class MyNum
- def /(a)
- a * 100
- end
- end
-
- def test_div
- assert_equal 1, 3 / 2
- assert_equal 1.5, 3.0 / 2.0
- assert_equal 300, MyNum.new / 3
- end
-
- class MyArr
- def length
- 'string'
- end
- end
-
- def test_length
- assert_equal 0, [].length
- assert_equal 1, [1].length
- assert_equal 2, [1,2].length
- assert_equal 0, {}.length
- assert_equal 1, {1=>1}.length
- assert_equal 2, {1=>1, 2=>2}.length
- assert_equal 'string', MyArr.new.length
- end
-
- class MyNum2
- def %(a)
- a * 100
- end
- end
-
- def test_mod
- assert_equal 2, 5 % 3
- assert_equal 1.0, 3.0 % 2.0
- assert_equal 300, MyNum2.new % 3
- end
-
- class MyObj
- def [](*args)
- args
- end
-
- def []=(*args)
- args
- end
- end
-
- def test_aref
- a = [0,1]
- assert_equal 0, a[0]
- assert_equal 1, a[1]
- assert_nil a[2]
- h = {0=>0, 1=>1}
- obj = MyObj.new
- assert_equal 0, h[0]
- assert_equal 1, h[1]
- assert_nil h[2]
- assert_equal [0], obj[0]
- assert_equal [0,1], obj[0,1]
- assert_equal [0,1,2], obj[0,1,2]
- end
-
- def test_aset
- obj = MyObj.new
- assert_equal 7, (obj[0] = 7)
- assert_equal 7, (obj[0,1] = 7)
- assert_equal 7, (obj[0,1,2] = 7)
- end
-
- class MyObj2
- def attr=(*args)
- args
- end
- end
-
- def test_attr_setter
- obj = MyObj2.new
- assert_equal 1, (obj.attr = 1)
- end
-
- def test_list_expand
- a = []
- assert_equal [0], [0, *a]
- a = [1]
- assert_equal [0,1], [0, *a]
- a = [1,2]
- assert_equal [0,1,2], [0, *a]
- a = [1,2,3]
- assert_equal [0,1,2,3], [0, *a]
- #a = [1,2,3]
- #assert_equal [0,1,2,3,4], [0, *a, 4]
- end
-
-end
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index b5dbdc936c..0ddc76a804 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -50,91 +50,45 @@ class TestProc < Test::Unit::TestCase
end
def test_arity
- assert_equal(0, proc{}.arity)
+ assert_equal(-1, proc{}.arity)
assert_equal(0, proc{||}.arity)
assert_equal(1, proc{|x|}.arity)
assert_equal(2, proc{|x, y|}.arity)
assert_equal(-2, proc{|x, *y|}.arity)
assert_equal(-1, proc{|*x|}.arity)
assert_equal(-1, proc{|*|}.arity)
- assert_equal(-3, proc{|x, *y, z|}.arity)
- assert_equal(-4, proc{|x, *y, z, a|}.arity)
- assert_arity(0) {}
+ assert_arity(-1) {}
assert_arity(0) {||}
assert_arity(1) {|x|}
assert_arity(2) {|x, y|}
assert_arity(-2) {|x, *y|}
- assert_arity(-3) {|x, *y, z|}
assert_arity(-1) {|*x|}
assert_arity(-1) {|*|}
end
+ # [ruby-dev:22592]
def m(x)
lambda { x }
end
-
def test_eq
+ # [ruby-dev:22592]
a = m(1)
b = m(2)
- assert_not_equal(a, b, "[ruby-dev:22592]")
- assert_not_equal(a.call, b.call, "[ruby-dev:22592]")
+ assert_not_equal(a, b)
+ assert_not_equal(a.call, b.call)
- assert_not_equal(proc {||}, proc {|x,y|}, "[ruby-dev:22599]")
+ # [ruby-dev:22599]
+ assert_not_equal(proc {||}, proc {|x,y|})
+ # [ruby-dev:22601]
a = lambda {|x| lambda {} }.call(1)
b = lambda {}
- assert_not_equal(a, b, "[ruby-dev:22601]")
+ assert_not_equal(a, b)
end
def test_block_par
assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
end
-
- def test_safe
- safe = $SAFE
- c = Class.new
- x = c.new
-
- p = proc {
- $SAFE += 1
- proc {$SAFE}
- }.call
- assert_equal(safe, $SAFE)
- assert_equal(safe + 1, p.call)
- assert_equal(safe, $SAFE)
-
- c.class_eval {define_method(:safe, p)}
- assert_equal(safe, x.safe)
- assert_equal(safe, x.method(:safe).call)
- assert_equal(safe, x.method(:safe).to_proc.call)
-
- p = proc {$SAFE += 1}
- assert_equal(safe + 1, p.call)
- assert_equal(safe, $SAFE)
-
- c.class_eval {define_method(:inc, p)}
- assert_equal(safe + 1, proc {x.inc; $SAFE}.call)
- assert_equal(safe, $SAFE)
- assert_equal(safe + 1, proc {x.method(:inc).call; $SAFE}.call)
- assert_equal(safe, $SAFE)
- assert_equal(safe + 1, proc {x.method(:inc).to_proc.call; $SAFE}.call)
- assert_equal(safe, $SAFE)
- end
-
- def m2
- "OK"
- end
-
- def block
- method(:m2).to_proc
- end
-
- # [yarv-dev:777] block made by Method#to_proc
- def test_method_to_proc
- b = block()
- assert_equal "OK", b.call
- end
-
end
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 1e9ad4d457..93eb871edc 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -36,6 +36,6 @@ class TestProcess < Test::Unit::TestCase
exit 1
}
Process.wait pid
- assert_equal(0, $?.to_i, "#{$?}")
+ assert_equal(0, $?.to_i)
end
end
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index 34179af74d..455175087d 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -14,61 +14,4 @@ class TestRange < Test::Unit::TestCase
r = (arr.shift)..(arr.shift)
assert_equal(1..2, r, "[ruby-dev:26383]")
end
-
- class DuckRange
- def initialize(b,e,excl=false)
- @begin = b
- @end = e
- @excl = excl
- end
- attr_reader :begin, :end
-
- def exclude_end?
- @excl
- end
- end
-
- def test_duckrange
- assert_equal("bc", "abcd"[DuckRange.new(1,2)])
- end
-
- def test_min
- assert_equal(1, (1..2).min)
- assert_equal(nil, (2..1).min)
- assert_equal(1, (1...2).min)
-
- assert_equal(1.0, (1.0..2.0).min)
- assert_equal(nil, (2.0..1.0).min)
- assert_equal(1, (1.0...2.0).min)
-
- assert_equal(0, (0..0).min)
- assert_equal(nil, (0...0).min)
- end
-
- def test_max
- assert_equal(2, (1..2).max)
- assert_equal(nil, (2..1).max)
- assert_equal(1, (1...2).max)
-
- assert_equal(2.0, (1.0..2.0).max)
- assert_equal(nil, (2.0..1.0).max)
- assert_raise(TypeError) { (1.0...2.0).max }
-
- assert_equal(-0x80000002, ((-0x80000002)...(-0x80000001)).max)
-
- assert_equal(0, (0..0).max)
- assert_equal(nil, (0...0).max)
- end
-
- def test_initialize_twice
- r = eval("1..2")
- assert_raise(NameError) { r.instance_eval { initialize 3, 4 } }
- end
-
- def test_uninitialized_range
- r = Range.allocate
- s = Marshal.dump(r)
- r = Marshal.load(s)
- assert_nothing_raised { r.instance_eval { initialize 5, 6} }
- end
end
diff --git a/test/ruby/test_readpartial.rb b/test/ruby/test_readpartial.rb
index c4f9d193f2..3877e21f85 100644
--- a/test/ruby/test_readpartial.rb
+++ b/test/ruby/test_readpartial.rb
@@ -43,6 +43,7 @@ class TestReadPartial < Test::Unit::TestCase
}
end
+ if !File::ALT_SEPARATOR # read on pipe cannot timeout on Windows.
def test_open_pipe
pipe {|r, w|
w << 'abc'
@@ -67,4 +68,7 @@ class TestReadPartial < Test::Unit::TestCase
}
}
end
+ end
+
end
+
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
deleted file mode 100644
index 520af49640..0000000000
--- a/test/ruby/test_regexp.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-require 'test/unit'
-
-class TestRegexp < Test::Unit::TestCase
- def test_ruby_dev_24643
- assert_nothing_raised("[ruby-dev:24643]") {
- /(?:(?:[a]*[a])?b)*a*$/ =~ "aabaaca"
- }
- end
-
- def test_ruby_talk_116455
- assert_match(/^(\w{2,}).* ([A-Za-z\xa2\xc0-\xff]{2,}?)$/, "Hallo Welt")
- end
-
- def test_ruby_dev_24887
- assert_equal("a".gsub(/a\Z/, ""), "")
- end
-
- def test_yoshidam_net_20041111_1
- s = "[\xC2\xA0-\xC3\xBE]"
- assert_match(Regexp.new(s, nil, "u"), "\xC3\xBE")
- end
-
- def test_yoshidam_net_20041111_2
- assert_raise(RegexpError) do
- s = "[\xFF-\xFF]".force_encoding("utf-8")
- Regexp.new(s, nil, "u")
- end
- end
-
- def test_ruby_dev_31309
- assert_equal('Ruby', 'Ruby'.sub(/[^a-z]/i, '-'))
- end
-
- def test_assert_normal_exit
- # moved from knownbug. It caused core.
- Regexp.union("a", "a")
- end
-
- def test_to_s
- assert_equal '(?-mix:\x00)', Regexp.new("\0").to_s
- end
-
- def test_union
- assert_equal :ok, begin
- Regexp.union(
- "a",
- Regexp.new("\xc2\xa1".force_encoding("euc-jp")),
- Regexp.new("\xc2\xa1".force_encoding("utf-8")))
- :ng
- rescue ArgumentError
- :ok
- end
- end
-
- def test_named_capture
- m = /&(?<foo>.*?);/.match("aaa &amp; yyy")
- assert_equal("amp", m["foo"])
- assert_equal("amp", m[:foo])
- assert_equal(5, m.begin(:foo))
- assert_equal(8, m.end(:foo))
- assert_equal([5,8], m.offset(:foo))
-
- assert_equal("aaa [amp] yyy",
- "aaa &amp; yyy".sub(/&(?<foo>.*?);/, '[\k<foo>]'))
-
- assert_equal('#<MatchData "&amp; y" foo:"amp">',
- /&(?<foo>.*?); (y)/.match("aaa &amp; yyy").inspect)
- assert_equal('#<MatchData "&amp; y" 1:"amp" 2:"y">',
- /&(.*?); (y)/.match("aaa &amp; yyy").inspect)
- assert_equal('#<MatchData "&amp; y" foo:"amp" bar:"y">',
- /&(?<foo>.*?); (?<bar>y)/.match("aaa &amp; yyy").inspect)
- assert_equal('#<MatchData "&amp; y" foo:"amp" foo:"y">',
- /&(?<foo>.*?); (?<foo>y)/.match("aaa &amp; yyy").inspect)
-
- /(?<id>[A-Za-z_]+)/ =~ "!abc"
- assert_equal("abc", Regexp.last_match(:id))
-
- /a/ =~ "b" # doesn't match.
- assert_equal(nil, Regexp.last_match)
- assert_equal(nil, Regexp.last_match(1))
- assert_equal(nil, Regexp.last_match(:foo))
-
- assert_equal(["foo", "bar"], /(?<foo>.)(?<bar>.)/.names)
- assert_equal(["foo"], /(?<foo>.)(?<foo>.)/.names)
- assert_equal([], /(.)(.)/.names)
-
- assert_equal(["foo", "bar"], /(?<foo>.)(?<bar>.)/.match("ab").names)
- assert_equal(["foo"], /(?<foo>.)(?<foo>.)/.match("ab").names)
- assert_equal([], /(.)(.)/.match("ab").names)
-
- assert_equal({"foo"=>[1], "bar"=>[2]},
- /(?<foo>.)(?<bar>.)/.named_captures)
- assert_equal({"foo"=>[1, 2]},
- /(?<foo>.)(?<foo>.)/.named_captures)
- assert_equal({}, /(.)(.)/.named_captures)
-
- assert_equal("a[b]c", "abc".sub(/(?<x>[bc])/, "[\\k<x>]"))
- end
-
- def test_assign_named_capture
- assert_equal("a", eval('/(?<foo>.)/ =~ "a"; foo'))
- assert_equal("a", eval('foo = 1; /(?<foo>.)/ =~ "a"; foo'))
- assert_equal("a", eval('1.times {|foo| /(?<foo>.)/ =~ "a"; break foo }'))
- assert_nothing_raised { eval('/(?<Foo>.)/ =~ "a"') }
- assert_nil(eval('/(?<Foo>.)/ =~ "a"; defined? Foo'))
- end
-
- def test_assign_named_capture_to_reserved_word
- /(?<nil>.)/ =~ "a"
- assert(!local_variables.include?(:nil), "[ruby-dev:32675]")
- end
-
- def test_match_regexp
- r = /./
- m = r.match("a")
- assert_equal(r, m.regexp)
- end
-end
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 2de6a04843..14d6679407 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -1,174 +1,138 @@
require 'test/unit'
class TestSetTraceFunc < Test::Unit::TestCase
- def setup
- @original_compile_option = VM::InstructionSequence.compile_option
- VM::InstructionSequence.compile_option = {
- :trace_instruction => true,
- :specialized_instruction => false
- }
- end
-
- def teardown
- VM::InstructionSequence.compile_option = @original_compile_option
- end
+ def foo; end;
- def test_c_call
+ def bar
events = []
- eval <<-EOF.gsub(/^.*?: /, "")
- 1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
- 2: events << [event, lineno, mid, klass]
- 3: })
- 4: x = 1 + 1
- 5: set_trace_func(nil)
- EOF
- assert_equal(["c-return", 3, :set_trace_func, Kernel],
- events.shift)
- assert_equal(["line", 4, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 4, :+, Fixnum],
- events.shift)
- assert_equal(["c-return", 4, :+, Fixnum],
- events.shift)
- assert_equal(["line", 5, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 5, :set_trace_func, Kernel],
- events.shift)
- assert_equal([], events)
+ set_trace_func(Proc.new { |event, file, lineno, mid, bidning, klass|
+ events << [event, lineno, mid, klass]
+ })
+ return events
end
- def test_call
+ def test_event
events = []
- eval <<-EOF.gsub(/^.*?: /, "")
- 1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
- 2: events << [event, lineno, mid, klass]
- 3: })
- 4: def add(x, y)
- 5: x + y
- 6: end
- 7: x = add(1, 1)
- 8: set_trace_func(nil)
- EOF
- assert_equal(["c-return", 3, :set_trace_func, Kernel],
- events.shift)
- assert_equal(["line", 4, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 4, :method_added, Module],
- events.shift)
- assert_equal(["c-return", 4, :method_added, Module],
- events.shift)
- assert_equal(["line", 7, __method__, self.class],
- events.shift)
- assert_equal(["call", 6, :add, self.class],
- events.shift)
- assert_equal(["line", 5, :add, self.class],
- events.shift)
- assert_equal(["c-call", 5, :+, Fixnum],
- events.shift)
- assert_equal(["c-return", 5, :+, Fixnum],
- events.shift)
- assert_equal(["return", 6, :add, self.class],
- events.shift)
- assert_equal(["line", 8, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 8, :set_trace_func, Kernel],
- events.shift)
- assert_equal([], events)
- end
+ set_trace_func(Proc.new { |event, file, lineno, mid, bidning, klass|
+ events << [event, lineno, mid, klass]
+ })
+ a = 1
+ foo
+ a
+ b = 1 + 2
+ if b == 3
+ case b
+ when 2
+ c = "b == 2"
+ when 3
+ c = "b == 3"
+ end
+ end
+ begin
+ raise "error"
+ rescue
+ end
+ eval("class Foo; end")
+ set_trace_func nil
- def test_class
- events = []
- eval <<-EOF.gsub(/^.*?: /, "")
- 1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
- 2: events << [event, lineno, mid, klass]
- 3: })
- 4: class Foo
- 5: def bar
- 6: end
- 7: end
- 8: x = Foo.new.bar
- 9: set_trace_func(nil)
- EOF
- assert_equal(["c-return", 3, :set_trace_func, Kernel],
- events.shift)
- assert_equal(["line", 4, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 4, :inherited, Class],
- events.shift)
- assert_equal(["c-return", 4, :inherited, Class],
- events.shift)
- assert_equal(["class", 7, nil, nil],
- events.shift)
- assert_equal(["line", 5, nil, nil],
- events.shift)
- assert_equal(["c-call", 5, :method_added, Module],
- events.shift)
- assert_equal(["c-return", 5, :method_added, Module],
- events.shift)
- assert_equal(["end", 7, nil, nil],
- events.shift)
- assert_equal(["line", 8, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 8, :new, Class],
- events.shift)
- assert_equal(["c-call", 8, :initialize, BasicObject],
- events.shift)
- assert_equal(["c-return", 8, :initialize, BasicObject],
- events.shift)
- assert_equal(["c-return", 8, :new, Class],
- events.shift)
- assert_equal(["call", 6, :bar, Foo],
- events.shift)
- assert_equal(["return", 6, :bar, Foo],
- events.shift)
- assert_equal(["line", 9, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 9, :set_trace_func, Kernel],
- events.shift)
+ assert_equal(["line", 19, :test_event, TestSetTraceFunc],
+ events.shift) # a = 1
+ assert_equal(["line", 20, :test_event, TestSetTraceFunc],
+ events.shift) # foo
+ assert_equal(["call", 4, :foo, TestSetTraceFunc],
+ events.shift) # foo
+ assert_equal(["return", 4, :foo, TestSetTraceFunc],
+ events.shift) # foo
+ assert_equal(["line", 21, :test_event, TestSetTraceFunc],
+ events.shift) # a
+ assert_equal(["line", 22, :test_event, TestSetTraceFunc],
+ events.shift) # b = 1 + 2
+ assert_equal(["c-call", 22, :+, Fixnum],
+ events.shift) # 1 + 2
+ assert_equal(["c-return", 22, :+, Fixnum],
+ events.shift) # 1 + 2
+ assert_equal(["line", 23, :test_event, TestSetTraceFunc],
+ events.shift) # if b == 3
+ assert_equal(["c-call", 23, :==, Fixnum],
+ events.shift) # b == 3
+ assert_equal(["c-return", 23, :==, Fixnum],
+ events.shift) # b == 3
+ assert_equal(["line", 23, :test_event, TestSetTraceFunc],
+ events.shift) # if b == 3
+ assert_equal(["line", 24, :test_event, TestSetTraceFunc],
+ events.shift) # case b
+ assert_equal(["line", 25, :test_event, TestSetTraceFunc],
+ events.shift) # when 2
+ assert_equal(["c-call", 25, :===, Kernel],
+ events.shift) # when 2
+ assert_equal(["c-call", 25, :==, Fixnum],
+ events.shift) # when 2
+ assert_equal(["c-return", 25, :==, Fixnum],
+ events.shift) # when 2
+ assert_equal(["c-return", 25, :===, Kernel],
+ events.shift) # when 2
+ assert_equal(["line", 27, :test_event, TestSetTraceFunc],
+ events.shift) # when 3
+ assert_equal(["c-call", 27, :===, Kernel],
+ events.shift) # when 3
+ assert_equal(["c-return", 27, :===, Kernel],
+ events.shift) # when 3
+ assert_equal(["line", 28, :test_event, TestSetTraceFunc],
+ events.shift) # c = "b == 3"
+ assert_equal(["line", 31, :test_event, TestSetTraceFunc],
+ events.shift) # begin
+ assert_equal(["line", 32, :test_event, TestSetTraceFunc],
+ events.shift) # raise "error"
+ assert_equal(["c-call", 32, :raise, Kernel],
+ events.shift) # raise "error"
+ assert_equal(["c-call", 32, :new, Class],
+ events.shift) # raise "error"
+ assert_equal(["c-call", 32, :initialize, Exception],
+ events.shift) # raise "error"
+ assert_equal(["c-return", 32, :initialize, Exception],
+ events.shift) # raise "error"
+ assert_equal(["c-return", 32, :new, Class],
+ events.shift) # raise "error"
+ assert_equal(["c-call", 32, :backtrace, Exception],
+ events.shift) # raise "error"
+ assert_equal(["c-return", 32, :backtrace, Exception],
+ events.shift) # raise "error"
+ assert_equal(["c-call", 32, :set_backtrace, Exception],
+ events.shift) # raise "error"
+ assert_equal(["c-return", 32, :set_backtrace, Exception],
+ events.shift) # raise "error"
+ assert_equal(["raise", 32, :test_event, TestSetTraceFunc],
+ events.shift) # raise "error"
+ assert_equal(["c-return", 32, :raise, Kernel],
+ events.shift) # raise "error"
+ assert_equal(["line", 35, :test_event, TestSetTraceFunc],
+ events.shift) # eval(<<EOF)
+ assert_equal(["c-call", 35, :eval, Kernel],
+ events.shift) # eval(<<EOF)
+ assert_equal(["line", 1, :test_event, TestSetTraceFunc],
+ events.shift) # class Foo
+ assert_equal(["c-call", 1, :inherited, Class],
+ events.shift) # class Foo
+ assert_equal(["c-return", 1, :inherited, Class],
+ events.shift) # class Foo
+ assert_equal(["class", 1, :test_event, TestSetTraceFunc],
+ events.shift) # class Foo
+ assert_equal(["end", 1, :test_event, TestSetTraceFunc],
+ events.shift) # class Foo
+ assert_equal(["c-return", 35, :eval, Kernel],
+ events.shift) # eval(<<EOF)
+ assert_equal(["line", 36, :test_event, TestSetTraceFunc],
+ events.shift) # set_trace_func nil
+ assert_equal(["c-call", 36, :set_trace_func, Kernel],
+ events.shift) # set_trace_func nil
assert_equal([], events)
- end
- def test_raise
- events = []
- eval <<-EOF.gsub(/^.*?: /, "")
- 1: set_trace_func(Proc.new { |event, file, lineno, mid, binding, klass|
- 2: events << [event, lineno, mid, klass]
- 3: })
- 4: raise "error" rescue nil
- 5: set_trace_func(nil)
- EOF
- assert_equal(["c-return", 3, :set_trace_func, Kernel],
- events.shift)
- assert_equal(["line", 4, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 4, :raise, Kernel],
- events.shift)
- assert_equal(["c-call", 4, :new, Class],
- events.shift)
- assert_equal(["c-call", 4, :initialize, Exception],
- events.shift)
- assert_equal(["c-return", 4, :initialize, Exception],
- events.shift)
- assert_equal(["c-return", 4, :new, Class],
- events.shift)
- assert_equal(["c-call", 4, :backtrace, Exception],
- events.shift)
- assert_equal(["c-return", 4, :backtrace, Exception],
- events.shift)
- assert_equal(["c-call", 4, :set_backtrace, Exception],
- events.shift)
- assert_equal(["c-return", 4, :set_backtrace, Exception],
- events.shift)
- assert_equal(["raise", 4, :raise, Kernel],
- events.shift)
- assert_equal(["c-call", 4, :===, Module],
- events.shift)
- assert_equal(["c-return", 4, :===, Module],
- events.shift)
- assert_equal(["line", 5, __method__, self.class],
- events.shift)
- assert_equal(["c-call", 5, :set_trace_func, Kernel],
- events.shift)
+ events = bar
+ set_trace_func(nil)
+ assert_equal(["line", 11, :bar, TestSetTraceFunc], events.shift)
+ assert_equal(["return", 11, :bar, TestSetTraceFunc], events.shift)
+ assert_equal(["line", 131, :test_event, TestSetTraceFunc], events.shift)
+ assert_equal(["c-call", 131, :set_trace_func, Kernel], events.shift)
assert_equal([], events)
end
end
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index 1ca9bf0b55..43e16b8c79 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -4,31 +4,32 @@ require 'timeout'
class TestSignal < Test::Unit::TestCase
def have_fork?
begin
- Process.fork {}
- return true
+ fork{}
+ true
rescue NotImplementedError
- return false
+ false
end
end
def test_signal
- return unless Process.respond_to?(:kill)
+ defined?(Process.kill) or return
begin
- x = 0
- oldtrap = Signal.trap(:INT) {|sig| x = 2 }
- Process.kill :INT, Process.pid
+ $x = 0
+ oldtrap = trap "SIGINT", proc{|sig| $x = 2}
+ Process.kill "SIGINT", $$
sleep 0.1
- assert_equal 2, x
+ assert_equal(2, $x)
- Signal.trap(:INT) { raise "Interrupt" }
- ex = assert_raises(RuntimeError) {
- Process.kill :INT, Process.pid
+ trap "SIGINT", proc{raise "Interrupt"}
+
+ x = assert_raises(RuntimeError) do
+ Process.kill "SIGINT", $$
sleep 0.1
- }
- assert_kind_of Exception, ex
- assert_match(/Interrupt/, ex.message)
+ end
+ assert(x)
+ assert_match(/Interrupt/, x.message)
ensure
- Signal.trap :INT, oldtrap if oldtrap
+ trap "SIGINT", oldtrap
end
end
@@ -37,8 +38,8 @@ class TestSignal < Test::Unit::TestCase
begin
r, w = IO.pipe
r0, w0 = IO.pipe
- pid = Process.fork {
- Signal.trap(:USR1, "EXIT")
+ pid = fork {
+ trap(:USR1, "EXIT")
w0.close
w.syswrite("a")
Thread.start { Thread.pass }
@@ -49,7 +50,7 @@ class TestSignal < Test::Unit::TestCase
assert_nothing_raised("[ruby-dev:26128]") {
Process.kill(:USR1, pid)
begin
- Timeout.timeout(3) {
+ Timeout.timeout(10) {
Process.waitpid pid
}
rescue Timeout::Error
diff --git a/test/ruby/test_sleep.rb b/test/ruby/test_sleep.rb
new file mode 100644
index 0000000000..675fdc9747
--- /dev/null
+++ b/test/ruby/test_sleep.rb
@@ -0,0 +1,10 @@
+require 'test/unit'
+
+class TestSleep < Test::Unit::TestCase
+ def test_sleep_5sec
+ start = Time.now
+ sleep 5
+ slept = Time.now-start
+ assert_in_delta(5.0, slept, 0.1, "[ruby-core:18015]: longer than expected")
+ end
+end
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
deleted file mode 100644
index 20c3581e2a..0000000000
--- a/test/ruby/test_sprintf.rb
+++ /dev/null
@@ -1,182 +0,0 @@
-require 'test/unit'
-
-class TestSprintf < Test::Unit::TestCase
- def test_positional
- assert_equal(" 00001", sprintf("%*1$.*2$3$d", 10, 5, 1))
- end
-
- def test_binary
- assert_equal("0", sprintf("%b", 0))
- assert_equal("1", sprintf("%b", 1))
- assert_equal("10", sprintf("%b", 2))
- assert_equal("..1", sprintf("%b", -1))
-
- assert_equal(" 0", sprintf("%4b", 0))
- assert_equal(" 1", sprintf("%4b", 1))
- assert_equal(" 10", sprintf("%4b", 2))
- assert_equal(" ..1", sprintf("%4b", -1))
-
- assert_equal("0000", sprintf("%04b", 0))
- assert_equal("0001", sprintf("%04b", 1))
- assert_equal("0010", sprintf("%04b", 2))
- assert_equal("1111", sprintf("%04b", -1))
-
- assert_equal("0000", sprintf("%.4b", 0))
- assert_equal("0001", sprintf("%.4b", 1))
- assert_equal("0010", sprintf("%.4b", 2))
- assert_equal("1111", sprintf("%.4b", -1))
-
- assert_equal(" 0000", sprintf("%6.4b", 0))
- assert_equal(" 0001", sprintf("%6.4b", 1))
- assert_equal(" 0010", sprintf("%6.4b", 2))
- assert_equal(" 1111", sprintf("%6.4b", -1))
-
- assert_equal(" 0b0", sprintf("%#4b", 0))
- assert_equal(" 0b1", sprintf("%#4b", 1))
- assert_equal("0b10", sprintf("%#4b", 2))
- assert_equal("0b..1", sprintf("%#4b", -1))
-
- assert_equal("0b00", sprintf("%#04b", 0))
- assert_equal("0b01", sprintf("%#04b", 1))
- assert_equal("0b10", sprintf("%#04b", 2))
- assert_equal("0b11", sprintf("%#04b", -1))
-
- assert_equal("0b0000", sprintf("%#.4b", 0))
- assert_equal("0b0001", sprintf("%#.4b", 1))
- assert_equal("0b0010", sprintf("%#.4b", 2))
- assert_equal("0b1111", sprintf("%#.4b", -1))
-
- assert_equal("0b0000", sprintf("%#6.4b", 0))
- assert_equal("0b0001", sprintf("%#6.4b", 1))
- assert_equal("0b0010", sprintf("%#6.4b", 2))
- assert_equal("0b1111", sprintf("%#6.4b", -1))
-
- assert_equal("+0", sprintf("%+b", 0))
- assert_equal("+1", sprintf("%+b", 1))
- assert_equal("+10", sprintf("%+b", 2))
- assert_equal("-1", sprintf("%+b", -1))
-
- assert_equal(" +0", sprintf("%+4b", 0))
- assert_equal(" +1", sprintf("%+4b", 1))
- assert_equal(" +10", sprintf("%+4b", 2))
- assert_equal(" -1", sprintf("%+4b", -1))
-
- assert_equal("+000", sprintf("%+04b", 0))
- assert_equal("+001", sprintf("%+04b", 1))
- assert_equal("+010", sprintf("%+04b", 2))
- assert_equal("-001", sprintf("%+04b", -1))
-
- assert_equal("+0000", sprintf("%+.4b", 0))
- assert_equal("+0001", sprintf("%+.4b", 1))
- assert_equal("+0010", sprintf("%+.4b", 2))
- assert_equal("-0001", sprintf("%+.4b", -1))
-
- assert_equal(" +0000", sprintf("%+6.4b", 0))
- assert_equal(" +0001", sprintf("%+6.4b", 1))
- assert_equal(" +0010", sprintf("%+6.4b", 2))
- assert_equal(" -0001", sprintf("%+6.4b", -1))
- end
-
- def test_nan
- nan = 0.0 / 0.0
- assert_equal("NaN", sprintf("%f", nan))
- assert_equal("NaN", sprintf("%-f", nan))
- assert_equal("+NaN", sprintf("%+f", nan))
-
- assert_equal(" NaN", sprintf("%8f", nan))
- assert_equal("NaN ", sprintf("%-8f", nan))
- assert_equal(" +NaN", sprintf("%+8f", nan))
-
- assert_equal("00000NaN", sprintf("%08f", nan))
- assert_equal("NaN ", sprintf("%-08f", nan))
- assert_equal("+0000NaN", sprintf("%+08f", nan))
-
- assert_equal(" NaN", sprintf("% 8f", nan))
- assert_equal(" NaN ", sprintf("%- 8f", nan))
- assert_equal(" +NaN", sprintf("%+ 8f", nan))
-
- assert_equal(" 0000NaN", sprintf("% 08f", nan))
- assert_equal(" NaN ", sprintf("%- 08f", nan))
- assert_equal("+0000NaN", sprintf("%+ 08f", nan))
- end
-
- def test_inf
- inf = 1.0 / 0.0
- assert_equal("Inf", sprintf("%f", inf))
- assert_equal("Inf", sprintf("%-f", inf))
- assert_equal("+Inf", sprintf("%+f", inf))
-
- assert_equal(" Inf", sprintf("%8f", inf))
- assert_equal("Inf ", sprintf("%-8f", inf))
- assert_equal(" +Inf", sprintf("%+8f", inf))
-
- assert_equal("00000Inf", sprintf("%08f", inf))
- assert_equal("Inf ", sprintf("%-08f", inf))
- assert_equal("+0000Inf", sprintf("%+08f", inf))
-
- assert_equal(" Inf", sprintf("% 8f", inf))
- assert_equal(" Inf ", sprintf("%- 8f", inf))
- assert_equal(" +Inf", sprintf("%+ 8f", inf))
-
- assert_equal(" 0000Inf", sprintf("% 08f", inf))
- assert_equal(" Inf ", sprintf("%- 08f", inf))
- assert_equal("+0000Inf", sprintf("%+ 08f", inf))
-
- assert_equal("-Inf", sprintf("%f", -inf))
- assert_equal("-Inf", sprintf("%-f", -inf))
- assert_equal("-Inf", sprintf("%+f", -inf))
-
- assert_equal(" -Inf", sprintf("%8f", -inf))
- assert_equal("-Inf ", sprintf("%-8f", -inf))
- assert_equal(" -Inf", sprintf("%+8f", -inf))
-
- assert_equal("-0000Inf", sprintf("%08f", -inf))
- assert_equal("-Inf ", sprintf("%-08f", -inf))
- assert_equal("-0000Inf", sprintf("%+08f", -inf))
-
- assert_equal(" -Inf", sprintf("% 8f", -inf))
- assert_equal("-Inf ", sprintf("%- 8f", -inf))
- assert_equal(" -Inf", sprintf("%+ 8f", -inf))
-
- assert_equal("-0000Inf", sprintf("% 08f", -inf))
- assert_equal("-Inf ", sprintf("%- 08f", -inf))
- assert_equal("-0000Inf", sprintf("%+ 08f", -inf))
- assert_equal('..f00000000',
- sprintf("%x", -2**32), '[ruby-dev:32351]')
- assert_equal("..101111111111111111111111111111111",
- sprintf("%b", -2147483649), '[ruby-dev:32365]')
- end
-
- def test_invalid
- # Star precision before star width:
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%.**d", 5, 10, 1)}
-
- # Precision before flags and width:
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%.5+05d", 5)}
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%.5 5d", 5)}
-
- # Overriding a star width with a numeric one:
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%*1s", 5, 1)}
-
- # Width before flags:
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%5+0d", 1)}
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%5 0d", 1)}
-
- # Specifying width multiple times:
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%50+30+20+10+5d", 5)}
- assert_raise(ArgumentError, "[ruby-core:11569]") {sprintf("%50 30 20 10 5d", 5)}
-
- # Specifying the precision multiple times with negative star arguments:
- assert_raise(ArgumentError, "[ruby-core:11570]") {sprintf("%.*.*.*.*f", -1, -1, -1, 5, 1)}
-
- # Null bytes after percent signs are removed:
- assert_equal("%\0x hello", sprintf("%\0x hello"), "[ruby-core:11571]")
-
- assert_raise(ArgumentError, "[ruby-core:11573]") {sprintf("%.25555555555555555555555555555555555555s", "hello")}
- end
-
- def test_float
- assert_equal("36893488147419111424",
- sprintf("%20.0f", 36893488147419107329.0))
- end
-end
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 7af6dcd11c..f8938cad84 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1,1125 +1,13 @@
require 'test/unit'
-# use of $= is deprecated after 1.7.1
-def pre_1_7_1
-end
-
class TestString < Test::Unit::TestCase
-
- def initialize(*args)
- @cls = String
- @aref_re_nth = true
- @aref_re_silent = false
- @aref_slicebang_silent = true
- super
- end
-
- def S(str)
- @cls.new(str)
- end
-
- def test_s_new
- assert_equal("RUBY", S("RUBY"))
- end
-
- def test_AREF # '[]'
- assert_equal("A", S("AooBar")[0])
- assert_equal("B", S("FooBaB")[-1])
- assert_equal(nil, S("FooBar")[6])
- assert_equal(nil, S("FooBar")[-7])
-
- assert_equal(S("Foo"), S("FooBar")[0,3])
- assert_equal(S("Bar"), S("FooBar")[-3,3])
- assert_equal(S(""), S("FooBar")[6,2])
- assert_equal(nil, S("FooBar")[-7,10])
-
- assert_equal(S("Foo"), S("FooBar")[0..2])
- assert_equal(S("Foo"), S("FooBar")[0...3])
- assert_equal(S("Bar"), S("FooBar")[-3..-1])
- assert_equal(S(""), S("FooBar")[6..2])
- assert_equal(nil, S("FooBar")[-10..-7])
-
- assert_equal(S("Foo"), S("FooBar")[/^F../])
- assert_equal(S("Bar"), S("FooBar")[/..r$/])
- assert_equal(nil, S("FooBar")[/xyzzy/])
- assert_equal(nil, S("FooBar")[/plugh/])
-
- assert_equal(S("Foo"), S("FooBar")[S("Foo")])
- assert_equal(S("Bar"), S("FooBar")[S("Bar")])
- assert_equal(nil, S("FooBar")[S("xyzzy")])
- assert_equal(nil, S("FooBar")[S("plugh")])
-
- if @aref_re_nth
- assert_equal(S("Foo"), S("FooBar")[/([A-Z]..)([A-Z]..)/, 1])
- assert_equal(S("Bar"), S("FooBar")[/([A-Z]..)([A-Z]..)/, 2])
- assert_equal(nil, S("FooBar")[/([A-Z]..)([A-Z]..)/, 3])
- assert_equal(S("Bar"), S("FooBar")[/([A-Z]..)([A-Z]..)/, -1])
- assert_equal(S("Foo"), S("FooBar")[/([A-Z]..)([A-Z]..)/, -2])
- assert_equal(nil, S("FooBar")[/([A-Z]..)([A-Z]..)/, -3])
- end
- end
-
- def test_ASET # '[]='
- s = S("FooBar")
- s[0] = S('A')
- assert_equal(S("AooBar"), s)
-
- s[-1]= S('B')
- assert_equal(S("AooBaB"), s)
- assert_raise(IndexError) { s[-7] = S("xyz") }
- assert_equal(S("AooBaB"), s)
- s[0] = S("ABC")
- assert_equal(S("ABCooBaB"), s)
-
- s = S("FooBar")
- s[0,3] = S("A")
- assert_equal(S("ABar"),s)
- s[0] = S("Foo")
- assert_equal(S("FooBar"), s)
- s[-3,3] = S("Foo")
- assert_equal(S("FooFoo"), s)
- assert_raise(IndexError) { s[7,3] = S("Bar") }
- assert_raise(IndexError) { s[-7,3] = S("Bar") }
-
- s = S("FooBar")
- s[0..2] = S("A")
- assert_equal(S("ABar"), s)
- s[1..3] = S("Foo")
- assert_equal(S("AFoo"), s)
- s[-4..-4] = S("Foo")
- assert_equal(S("FooFoo"), s)
- assert_raise(RangeError) { s[7..10] = S("Bar") }
- assert_raise(RangeError) { s[-7..-10] = S("Bar") }
-
- s = S("FooBar")
- s[/^F../]= S("Bar")
- assert_equal(S("BarBar"), s)
- s[/..r$/] = S("Foo")
- assert_equal(S("BarFoo"), s)
- if @aref_re_silent
- s[/xyzzy/] = S("None")
- assert_equal(S("BarFoo"), s)
- else
- assert_raise(IndexError) { s[/xyzzy/] = S("None") }
- end
- if @aref_re_nth
- s[/([A-Z]..)([A-Z]..)/, 1] = S("Foo")
- assert_equal(S("FooFoo"), s)
- s[/([A-Z]..)([A-Z]..)/, 2] = S("Bar")
- assert_equal(S("FooBar"), s)
- assert_raise(IndexError) { s[/([A-Z]..)([A-Z]..)/, 3] = "None" }
- s[/([A-Z]..)([A-Z]..)/, -1] = S("Foo")
- assert_equal(S("FooFoo"), s)
- s[/([A-Z]..)([A-Z]..)/, -2] = S("Bar")
- assert_equal(S("BarFoo"), s)
- assert_raise(IndexError) { s[/([A-Z]..)([A-Z]..)/, -3] = "None" }
- end
-
- s = S("FooBar")
- s[S("Foo")] = S("Bar")
- assert_equal(S("BarBar"), s)
-
- pre_1_7_1 do
- s = S("FooBar")
- s[S("Foo")] = S("xyz")
- assert_equal(S("xyzBar"), s)
-
- $= = true
- s = S("FooBar")
- s[S("FOO")] = S("Bar")
- assert_equal(S("BarBar"), s)
- s[S("FOO")] = S("xyz")
- assert_equal(S("BarBar"), s)
- $= = false
- end
-
- s = S("a string")
- s[0..s.size] = S("another string")
- assert_equal(S("another string"), s)
- end
-
- def test_CMP # '<=>'
- assert_equal(1, S("abcdef") <=> S("abcde"))
- assert_equal(0, S("abcdef") <=> S("abcdef"))
- assert_equal(-1, S("abcde") <=> S("abcdef"))
-
- assert_equal(-1, S("ABCDEF") <=> S("abcdef"))
-
- pre_1_7_1 do
- $= = true
- assert_equal(0, S("ABCDEF") <=> S("abcdef"))
- $= = false
- end
- end
-
- def test_EQUAL # '=='
- assert_equal(false, S("foo") == :foo)
- assert(S("abcdef") == S("abcdef"))
-
- pre_1_7_1 do
- $= = true
- assert(S("CAT") == S('cat'))
- assert(S("CaT") == S('cAt'))
- $= = false
- end
-
- assert(S("CAT") != S('cat'))
- assert(S("CaT") != S('cAt'))
- end
-
- def test_LSHIFT # '<<'
- assert_equal(S("world!"), S("world") << 33)
- assert_equal(S("world!"), S("world") << S('!'))
- end
-
- def test_MATCH # '=~'
- assert_equal(10, S("FeeFieFoo-Fum") =~ /Fum$/)
- assert_equal(nil, S("FeeFieFoo-Fum") =~ /FUM$/)
-
- pre_1_7_1 do
- $= = true
- assert_equal(10, S("FeeFieFoo-Fum") =~ /FUM$/)
- $= = false
- end
- end
-
- def test_MOD # '%'
- assert_equal(S("00123"), S("%05d") % 123)
- assert_equal(S("123 |00000001"), S("%-5s|%08x") % [123, 1])
- x = S("%3s %-4s%%foo %.0s%5d %#x%c%3.1f %b %x %X %#b %#x %#X") %
- [S("hi"),
- 123,
- S("never seen"),
- 456,
- 0,
- ?A,
- 3.0999,
- 11,
- 171,
- 171,
- 11,
- 171,
- 171]
-
- assert_equal(S(' hi 123 %foo 456 0x0A3.1 1011 ab AB 0b1011 0xab 0XAB'), x)
- end
-
- def test_MUL # '*'
- assert_equal(S("XXX"), S("X") * 3)
- assert_equal(S("HOHO"), S("HO") * 2)
- end
-
- def test_PLUS # '+'
- assert_equal(S("Yodel"), S("Yo") + S("del"))
- end
-
- def casetest(a, b, rev=false)
- case a
- when b
- assert(!rev)
- else
- assert(rev)
- end
- end
-
- def test_VERY_EQUAL # '==='
- # assert_equal(true, S("foo") === :foo)
- casetest(S("abcdef"), S("abcdef"))
-
- pre_1_7_1 do
- $= = true
- casetest(S("CAT"), S('cat'))
- casetest(S("CaT"), S('cAt'))
- $= = false
- end
-
- casetest(S("CAT"), S('cat'), true) # Reverse the test - we don't want to
- casetest(S("CaT"), S('cAt'), true) # find these in the case.
- end
-
- def test_capitalize
- assert_equal(S("Hello"), S("hello").capitalize)
- assert_equal(S("Hello"), S("hELLO").capitalize)
- assert_equal(S("123abc"), S("123ABC").capitalize)
- end
-
- def test_capitalize!
- a = S("hello"); a.capitalize!
- assert_equal(S("Hello"), a)
-
- a = S("hELLO"); a.capitalize!
- assert_equal(S("Hello"), a)
-
- a = S("123ABC"); a.capitalize!
- assert_equal(S("123abc"), a)
-
- assert_equal(nil, S("123abc").capitalize!)
- assert_equal(S("123abc"), S("123ABC").capitalize!)
- assert_equal(S("Abc"), S("ABC").capitalize!)
- assert_equal(S("Abc"), S("abc").capitalize!)
- assert_equal(nil, S("Abc").capitalize!)
-
- a = S("hello")
- b = a.dup
- assert_equal(S("Hello"), a.capitalize!)
- assert_equal(S("hello"), b)
-
- end
-
- def test_center
- assert_equal(S("hello"), S("hello").center(4))
- assert_equal(S(" hello "), S("hello").center(11))
- end
-
- def test_chomp
- assert_equal(S("hello"), S("hello").chomp("\n"))
- assert_equal(S("hello"), S("hello\n").chomp("\n"))
-
- $/ = "\n"
-
- assert_equal(S("hello"), S("hello").chomp)
- assert_equal(S("hello"), S("hello\n").chomp)
-
- $/ = "!"
- assert_equal(S("hello"), S("hello").chomp)
- assert_equal(S("hello"), S("hello!").chomp)
- $/ = "\n"
- end
-
- def test_chomp!
- a = S("hello")
- a.chomp!(S("\n"))
-
- assert_equal(S("hello"), a)
- assert_equal(nil, a.chomp!(S("\n")))
-
- a = S("hello\n")
- a.chomp!(S("\n"))
- assert_equal(S("hello"), a)
-
- $/ = "\n"
- a = S("hello")
- a.chomp!
- assert_equal(S("hello"), a)
-
- a = S("hello\n")
- a.chomp!
- assert_equal(S("hello"), a)
-
- $/ = "!"
- a = S("hello")
- a.chomp!
- assert_equal(S("hello"), a)
-
- a="hello!"
- a.chomp!
- assert_equal(S("hello"), a)
-
- $/ = "\n"
-
- a = S("hello\n")
- b = a.dup
- assert_equal(S("hello"), a.chomp!)
- assert_equal(S("hello\n"), b)
-
- end
-
- def test_chop
- assert_equal(S("hell"), S("hello").chop)
- assert_equal(S("hello"), S("hello\r\n").chop)
- assert_equal(S("hello\n"), S("hello\n\r").chop)
- assert_equal(S(""), S("\r\n").chop)
- assert_equal(S(""), S("").chop)
- end
-
- def test_chop!
- a = S("hello").chop!
- assert_equal(S("hell"), a)
-
- a = S("hello\r\n").chop!
- assert_equal(S("hello"), a)
-
- a = S("hello\n\r").chop!
- assert_equal(S("hello\n"), a)
-
- a = S("\r\n").chop!
- assert_equal(S(""), a)
-
- a = S("").chop!
- assert_nil(a)
-
- a = S("hello\n")
- b = a.dup
- assert_equal(S("hello"), a.chop!)
- assert_equal(S("hello\n"), b)
- end
-
- def test_clone
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = S("Cool")
- a.taint if taint
- a.freeze if frozen
- b = a.clone
-
- assert_equal(a, b)
- assert(a.__id__ != b.__id__)
- assert_equal(a.frozen?, b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
- end
- end
-
- def test_concat
- assert_equal(S("world!"), S("world").concat(33))
- assert_equal(S("world!"), S("world").concat(S('!')))
- end
-
- def test_count
- a = S("hello world")
- assert_equal(5, a.count(S("lo")))
- assert_equal(2, a.count(S("lo"), S("o")))
- assert_equal(4, a.count(S("hello"), S("^l")))
- assert_equal(4, a.count(S("ej-m")))
- end
-
- def test_crypt
- assert_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("aa")))
- assert(S('aaGUC/JkO9/Sc') != S("mypassword").crypt(S("ab")))
- end
-
- def test_delete
- assert_equal(S("heo"), S("hello").delete(S("l"), S("lo")))
- assert_equal(S("he"), S("hello").delete(S("lo")))
- assert_equal(S("hell"), S("hello").delete(S("aeiou"), S("^e")))
- assert_equal(S("ho"), S("hello").delete(S("ej-m")))
- end
-
- def test_delete!
- a = S("hello")
- a.delete!(S("l"), S("lo"))
- assert_equal(S("heo"), a)
-
- a = S("hello")
- a.delete!(S("lo"))
- assert_equal(S("he"), a)
-
- a = S("hello")
- a.delete!(S("aeiou"), S("^e"))
- assert_equal(S("hell"), a)
-
- a = S("hello")
- a.delete!(S("ej-m"))
- assert_equal(S("ho"), a)
-
- a = S("hello")
- assert_nil(a.delete!(S("z")))
-
- a = S("hello")
- b = a.dup
- a.delete!(S("lo"))
- assert_equal(S("he"), a)
- assert_equal(S("hello"), b)
- end
-
-
- def test_downcase
- assert_equal(S("hello"), S("helLO").downcase)
- assert_equal(S("hello"), S("hello").downcase)
- assert_equal(S("hello"), S("HELLO").downcase)
- assert_equal(S("abc hello 123"), S("abc HELLO 123").downcase)
- end
-
- def test_downcase!
- a = S("helLO")
- b = a.dup
- assert_equal(S("hello"), a.downcase!)
- assert_equal(S("hello"), a)
- assert_equal(S("helLO"), b)
-
- a=S("hello")
- assert_nil(a.downcase!)
- assert_equal(S("hello"), a)
- end
-
- def test_dump
- a= S("Test") << 1 << 2 << 3 << 9 << 13 << 10
- assert_equal(S('"Test\\x01\\x02\\x03\\t\\r\\n"'), a.dump)
- end
-
- def test_dup
- for taint in [ false, true ]
- for frozen in [ false, true ]
- a = S("hello")
- a.taint if taint
- a.freeze if frozen
- b = a.dup
-
- assert_equal(a, b)
- assert(a.__id__ != b.__id__)
- assert(!b.frozen?)
- assert_equal(a.tainted?, b.tainted?)
- end
- end
- end
-
- def test_each
- $/ = "\n"
- res=[]
- S("hello\nworld").lines.each {|x| res << x}
- assert_equal(S("hello\n"), res[0])
- assert_equal(S("world"), res[1])
-
- res=[]
- S("hello\n\n\nworld").lines(S('')).each {|x| res << x}
- assert_equal(S("hello\n\n\n"), res[0])
- assert_equal(S("world"), res[1])
-
- $/ = "!"
- res=[]
- S("hello!world").lines.each {|x| res << x}
- assert_equal(S("hello!"), res[0])
- assert_equal(S("world"), res[1])
- $/ = "\n"
- end
-
- def test_each_byte
- res = []
- S("ABC").each_byte {|x| res << x }
- assert_equal(65, res[0])
- assert_equal(66, res[1])
- assert_equal(67, res[2])
- end
-
- def test_each_line
- $/ = "\n"
- res=[]
- S("hello\nworld").lines.each {|x| res << x}
- assert_equal(S("hello\n"), res[0])
- assert_equal(S("world"), res[1])
-
- res=[]
- S("hello\n\n\nworld").lines(S('')).each {|x| res << x}
- assert_equal(S("hello\n\n\n"), res[0])
- assert_equal(S("world"), res[1])
-
- $/ = "!"
-
- res=[]
- S("hello!world").lines.each {|x| res << x}
- assert_equal(S("hello!"), res[0])
- assert_equal(S("world"), res[1])
-
- $/ = "\n"
- end
-
- def test_empty?
- assert(S("").empty?)
- assert(!S("not").empty?)
- end
-
- def test_eql?
- a = S("hello")
- assert(a.eql?(S("hello")))
- assert(a.eql?(a))
- end
-
- def test_gsub
- assert_equal(S("h*ll*"), S("hello").gsub(/[aeiou]/, S('*')))
- assert_equal(S("h<e>ll<o>"), S("hello").gsub(/([aeiou])/, S('<\1>')))
- assert_equal(S("h e l l o "),
- S("hello").gsub(/./) { |s| s[0].to_s + S(' ')})
- assert_equal(S("HELL-o"),
- S("hello").gsub(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 })
-
- a = S("hello")
- a.taint
- assert(a.gsub(/./, S('X')).tainted?)
- end
-
- def test_gsub!
- a = S("hello")
- b = a.dup
- a.gsub!(/[aeiou]/, S('*'))
- assert_equal(S("h*ll*"), a)
- assert_equal(S("hello"), b)
-
- a = S("hello")
- a.gsub!(/([aeiou])/, S('<\1>'))
- assert_equal(S("h<e>ll<o>"), a)
-
- a = S("hello")
- a.gsub!(/./) { |s| s[0].to_s + S(' ')}
- assert_equal(S("h e l l o "), a)
-
- a = S("hello")
- a.gsub!(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 }
- assert_equal(S("HELL-o"), a)
-
- r = S('X')
- r.taint
- a.gsub!(/./, r)
- assert(a.tainted?)
-
- a = S("hello")
- assert_nil(a.sub!(S('X'), S('Y')))
- end
-
- def test_hash
- assert_equal(S("hello").hash, S("hello").hash)
- assert(S("hello").hash != S("helLO").hash)
- end
-
- def test_hex
- assert_equal(255, S("0xff").hex)
- assert_equal(-255, S("-0xff").hex)
- assert_equal(255, S("ff").hex)
- assert_equal(-255, S("-ff").hex)
- assert_equal(0, S("-ralph").hex)
- assert_equal(-15, S("-fred").hex)
- assert_equal(15, S("fred").hex)
- end
-
- def test_include?
- assert( S("foobar").include?(?f))
- assert( S("foobar").include?(S("foo")))
- assert(!S("foobar").include?(S("baz")))
- assert(!S("foobar").include?(?z))
- end
-
- def test_index
- assert_equal(0, S("hello").index(?h))
- assert_equal(1, S("hello").index(S("ell")))
- assert_equal(2, S("hello").index(/ll./))
-
- assert_equal(3, S("hello").index(?l, 3))
- assert_equal(3, S("hello").index(S("l"), 3))
- assert_equal(3, S("hello").index(/l./, 3))
-
- assert_nil(S("hello").index(?z, 3))
- assert_nil(S("hello").index(S("z"), 3))
- assert_nil(S("hello").index(/z./, 3))
-
- assert_nil(S("hello").index(?z))
- assert_nil(S("hello").index(S("z")))
- assert_nil(S("hello").index(/z./))
- end
-
- def test_intern
- assert_equal(:koala, S("koala").intern)
- assert(:koala != S("Koala").intern)
- end
-
- def test_length
- assert_equal(0, S("").length)
- assert_equal(4, S("1234").length)
- assert_equal(6, S("1234\r\n").length)
- assert_equal(7, S("\0011234\r\n").length)
- end
-
- def test_ljust
- assert_equal(S("hello"), S("hello").ljust(4))
- assert_equal(S("hello "), S("hello").ljust(11))
- end
-
- def test_next
- assert_equal(S("abd"), S("abc").next)
- assert_equal(S("z"), S("y").next)
- assert_equal(S("aaa"), S("zz").next)
-
- assert_equal(S("124"), S("123").next)
- assert_equal(S("1000"), S("999").next)
-
- assert_equal(S("2000aaa"), S("1999zzz").next)
- assert_equal(S("AAAAA000"), S("ZZZZ999").next)
-
- assert_equal(S("*+"), S("**").next)
- end
-
- def test_next!
- a = S("abc")
- b = a.dup
- assert_equal(S("abd"), a.next!)
- assert_equal(S("abd"), a)
- assert_equal(S("abc"), b)
-
- a = S("y")
- assert_equal(S("z"), a.next!)
- assert_equal(S("z"), a)
-
- a = S("zz")
- assert_equal(S("aaa"), a.next!)
- assert_equal(S("aaa"), a)
-
- a = S("123")
- assert_equal(S("124"), a.next!)
- assert_equal(S("124"), a)
-
- a = S("999")
- assert_equal(S("1000"), a.next!)
- assert_equal(S("1000"), a)
-
- a = S("1999zzz")
- assert_equal(S("2000aaa"), a.next!)
- assert_equal(S("2000aaa"), a)
-
- a = S("ZZZZ999")
- assert_equal(S("AAAAA000"), a.next!)
- assert_equal(S("AAAAA000"), a)
-
- a = S("**")
- assert_equal(S("*+"), a.next!)
- assert_equal(S("*+"), a)
- end
-
- def test_oct
- assert_equal(255, S("0377").oct)
- assert_equal(255, S("377").oct)
- assert_equal(-255, S("-0377").oct)
- assert_equal(-255, S("-377").oct)
- assert_equal(0, S("OO").oct)
- assert_equal(24, S("030OO").oct)
- end
-
- def test_replace
- a = S("foo")
- assert_equal(S("f"), a.replace(S("f")))
-
- a = S("foo")
- assert_equal(S("foobar"), a.replace(S("foobar")))
-
- a = S("foo")
- a.taint
- b = a.replace(S("xyz"))
- assert_equal(S("xyz"), b)
- assert(b.tainted?)
- end
-
- def test_reverse
- assert_equal(S("beta"), S("ateb").reverse)
- assert_equal(S("madamImadam"), S("madamImadam").reverse)
-
- a=S("beta")
- assert_equal(S("ateb"), a.reverse)
- assert_equal(S("beta"), a)
- end
-
- def test_reverse!
- a = S("beta")
- b = a.dup
- assert_equal(S("ateb"), a.reverse!)
- assert_equal(S("ateb"), a)
- assert_equal(S("beta"), b)
-
- assert_equal(S("madamImadam"), S("madamImadam").reverse!)
-
- a = S("madamImadam")
- assert_equal(S("madamImadam"), a.reverse!) # ??
- assert_equal(S("madamImadam"), a)
- end
-
- def test_rindex
- assert_equal(3, S("hello").rindex(?l))
- assert_equal(6, S("ell, hello").rindex(S("ell")))
- assert_equal(7, S("ell, hello").rindex(/ll./))
-
- assert_equal(3, S("hello,lo").rindex(?l, 3))
- assert_equal(3, S("hello,lo").rindex(S("l"), 3))
- assert_equal(3, S("hello,lo").rindex(/l./, 3))
-
- assert_nil(S("hello").rindex(?z, 3))
- assert_nil(S("hello").rindex(S("z"), 3))
- assert_nil(S("hello").rindex(/z./, 3))
-
- assert_nil(S("hello").rindex(?z))
- assert_nil(S("hello").rindex(S("z")))
- assert_nil(S("hello").rindex(/z./))
- end
-
- def test_rjust
- assert_equal(S("hello"), S("hello").rjust(4))
- assert_equal(S(" hello"), S("hello").rjust(11))
- end
-
- def test_scan
- a = S("cruel world")
- assert_equal([S("cruel"), S("world")],a.scan(/\w+/))
- assert_equal([S("cru"), S("el "), S("wor")],a.scan(/.../))
- assert_equal([[S("cru")], [S("el ")], [S("wor")]],a.scan(/(...)/))
-
- res = []
- a.scan(/\w+/) { |w| res << w }
- assert_equal([S("cruel"), S("world") ],res)
-
- res = []
- a.scan(/.../) { |w| res << w }
- assert_equal([S("cru"), S("el "), S("wor")],res)
-
- res = []
- a.scan(/(...)/) { |w| res << w }
- assert_equal([[S("cru")], [S("el ")], [S("wor")]],res)
- end
-
- def test_size
- assert_equal(0, S("").size)
- assert_equal(4, S("1234").size)
- assert_equal(6, S("1234\r\n").size)
- assert_equal(7, S("\0011234\r\n").size)
- end
-
- def test_slice
- assert_equal(?A, S("AooBar").slice(0))
- assert_equal(?B, S("FooBaB").slice(-1))
- assert_nil(S("FooBar").slice(6))
- assert_nil(S("FooBar").slice(-7))
-
- assert_equal(S("Foo"), S("FooBar").slice(0,3))
- assert_equal(S(S("Bar")), S("FooBar").slice(-3,3))
- assert_nil(S("FooBar").slice(7,2)) # Maybe should be six?
- assert_nil(S("FooBar").slice(-7,10))
-
- assert_equal(S("Foo"), S("FooBar").slice(0..2))
- assert_equal(S("Bar"), S("FooBar").slice(-3..-1))
- assert_equal(S(""), S("FooBar").slice(6..2))
- assert_nil(S("FooBar").slice(-10..-7))
-
- assert_equal(S("Foo"), S("FooBar").slice(/^F../))
- assert_equal(S("Bar"), S("FooBar").slice(/..r$/))
- assert_nil(S("FooBar").slice(/xyzzy/))
- assert_nil(S("FooBar").slice(/plugh/))
-
- assert_equal(S("Foo"), S("FooBar").slice(S("Foo")))
- assert_equal(S("Bar"), S("FooBar").slice(S("Bar")))
- assert_nil(S("FooBar").slice(S("xyzzy")))
- assert_nil(S("FooBar").slice(S("plugh")))
- end
-
- def test_slice!
- a = S("AooBar")
- b = a.dup
- assert_equal(?A, a.slice!(0))
- assert_equal(S("ooBar"), a)
- assert_equal(S("AooBar"), b)
-
- a = S("FooBar")
- assert_equal(?r,a.slice!(-1))
- assert_equal(S("FooBa"), a)
-
- a = S("FooBar")
- if @aref_slicebang_silent
- assert_nil( a.slice!(6) )
- else
- assert_raise(IndexError) { a.slice!(6) }
- end
- assert_equal(S("FooBar"), a)
-
- if @aref_slicebang_silent
- assert_nil( a.slice!(-7) )
- else
- assert_raise(IndexError) { a.slice!(-7) }
- end
- assert_equal(S("FooBar"), a)
-
- a = S("FooBar")
- assert_equal(S("Foo"), a.slice!(0,3))
- assert_equal(S("Bar"), a)
-
- a = S("FooBar")
- assert_equal(S("Bar"), a.slice!(-3,3))
- assert_equal(S("Foo"), a)
-
- a=S("FooBar")
- if @aref_slicebang_silent
- assert_nil(a.slice!(7,2)) # Maybe should be six?
- else
- assert_raise(IndexError) {a.slice!(7,2)} # Maybe should be six?
- end
- assert_equal(S("FooBar"), a)
- if @aref_slicebang_silent
- assert_nil(a.slice!(-7,10))
- else
- assert_raise(IndexError) {a.slice!(-7,10)}
- end
- assert_equal(S("FooBar"), a)
-
- a=S("FooBar")
- assert_equal(S("Foo"), a.slice!(0..2))
- assert_equal(S("Bar"), a)
-
- a=S("FooBar")
- assert_equal(S("Bar"), a.slice!(-3..-1))
- assert_equal(S("Foo"), a)
-
- a=S("FooBar")
- if @aref_slicebang_silent
- assert_equal(S(""), a.slice!(6..2))
- else
- assert_raise(RangeError) {a.slice!(6..2)}
- end
- assert_equal(S("FooBar"), a)
- if @aref_slicebang_silent
- assert_nil(a.slice!(-10..-7))
- else
- assert_raise(RangeError) {a.slice!(-10..-7)}
- end
- assert_equal(S("FooBar"), a)
-
- a=S("FooBar")
- assert_equal(S("Foo"), a.slice!(/^F../))
- assert_equal(S("Bar"), a)
-
- a=S("FooBar")
- assert_equal(S("Bar"), a.slice!(/..r$/))
- assert_equal(S("Foo"), a)
-
- a=S("FooBar")
- if @aref_slicebang_silent
- assert_nil(a.slice!(/xyzzy/))
- else
- assert_raise(IndexError) {a.slice!(/xyzzy/)}
- end
- assert_equal(S("FooBar"), a)
- if @aref_slicebang_silent
- assert_nil(a.slice!(/plugh/))
- else
- assert_raise(IndexError) {a.slice!(/plugh/)}
- end
- assert_equal(S("FooBar"), a)
-
- a=S("FooBar")
- assert_equal(S("Foo"), a.slice!(S("Foo")))
- assert_equal(S("Bar"), a)
-
- a=S("FooBar")
- assert_equal(S("Bar"), a.slice!(S("Bar")))
- assert_equal(S("Foo"), a)
-
- pre_1_7_1 do
- a=S("FooBar")
- assert_nil(a.slice!(S("xyzzy")))
- assert_equal(S("FooBar"), a)
- assert_nil(a.slice!(S("plugh")))
- assert_equal(S("FooBar"), a)
- end
- end
-
- def test_split
- assert_nil($;)
- assert_equal([S("a"), S("b"), S("c")], S(" a b\t c ").split)
- assert_equal([S("a"), S("b"), S("c")], S(" a b\t c ").split(S(" ")))
-
- assert_equal([S(" a "), S(" b "), S(" c ")], S(" a | b | c ").split(S("|")))
-
- assert_equal([S("a"), S("b"), S("c")], S("aXXbXXcXX").split(/X./))
-
- assert_equal([S("a"), S("b"), S("c")], S("abc").split(//))
-
- assert_equal([S("a|b|c")], S("a|b|c").split(S('|'), 1))
-
- assert_equal([S("a"), S("b|c")], S("a|b|c").split(S('|'), 2))
- assert_equal([S("a"), S("b"), S("c")], S("a|b|c").split(S('|'), 3))
-
- assert_equal([S("a"), S("b"), S("c"), S("")], S("a|b|c|").split(S('|'), -1))
- assert_equal([S("a"), S("b"), S("c"), S(""), S("")], S("a|b|c||").split(S('|'), -1))
-
- assert_equal([S("a"), S(""), S("b"), S("c")], S("a||b|c|").split(S('|')))
- assert_equal([S("a"), S(""), S("b"), S("c"), S("")], S("a||b|c|").split(S('|'), -1))
- end
-
- def test_squeeze
- assert_equal(S("abc"), S("aaabbbbccc").squeeze)
- assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" ")))
- assert_equal(S("BxTyWz"), S("BxxxTyyyWzzzzz").squeeze(S("a-z")))
- end
-
- def test_squeeze!
- a = S("aaabbbbccc")
- b = a.dup
- assert_equal(S("abc"), a.squeeze!)
- assert_equal(S("abc"), a)
- assert_equal(S("aaabbbbccc"), b)
-
- a = S("aa bb cc")
- assert_equal(S("aa bb cc"), a.squeeze!(S(" ")))
- assert_equal(S("aa bb cc"), a)
-
- a = S("BxxxTyyyWzzzzz")
- assert_equal(S("BxTyWz"), a.squeeze!(S("a-z")))
- assert_equal(S("BxTyWz"), a)
-
- a=S("The quick brown fox")
- assert_nil(a.squeeze!)
- end
-
- def test_strip
- assert_equal(S("x"), S(" x ").strip)
- assert_equal(S("x"), S(" \n\r\t x \t\r\n\n ").strip)
- end
-
- def test_strip!
- a = S(" x ")
- b = a.dup
- assert_equal(S("x") ,a.strip!)
- assert_equal(S("x") ,a)
- assert_equal(S(" x "), b)
-
- a = S(" \n\r\t x \t\r\n\n ")
- assert_equal(S("x"), a.strip!)
- assert_equal(S("x"), a)
-
- a = S("x")
- assert_nil(a.strip!)
- assert_equal(S("x") ,a)
- end
-
- def test_sub
- assert_equal(S("h*llo"), S("hello").sub(/[aeiou]/, S('*')))
- assert_equal(S("h<e>llo"), S("hello").sub(/([aeiou])/, S('<\1>')))
- assert_equal(S("h ello"), S("hello").sub(/./) {
- |s| s[0].to_s + S(' ')})
- assert_equal(S("HELL-o"), S("hello").sub(/(hell)(.)/) {
- |s| $1.upcase + S('-') + $2
- })
-
- assert_equal(S("a\\aba"), S("ababa").sub(/b/, '\\'))
- assert_equal(S("ab\\aba"), S("ababa").sub(/(b)/, '\1\\'))
- assert_equal(S("ababa"), S("ababa").sub(/(b)/, '\1'))
- assert_equal(S("ababa"), S("ababa").sub(/(b)/, '\\1'))
- assert_equal(S("a\\1aba"), S("ababa").sub(/(b)/, '\\\1'))
- assert_equal(S("a\\1aba"), S("ababa").sub(/(b)/, '\\\\1'))
- assert_equal(S("a\\baba"), S("ababa").sub(/(b)/, '\\\\\1'))
-
- assert_equal(S("a--ababababababababab"),
- S("abababababababababab").sub(/(b)/, '-\9-'))
- assert_equal(S("1-b-0"),
- S("1b2b3b4b5b6b7b8b9b0").
- sub(/(b).(b).(b).(b).(b).(b).(b).(b).(b)/, '-\9-'))
- assert_equal(S("1-b-0"),
- S("1b2b3b4b5b6b7b8b9b0").
- sub(/(b).(b).(b).(b).(b).(b).(b).(b).(b)/, '-\\9-'))
- assert_equal(S("1-\\9-0"),
- S("1b2b3b4b5b6b7b8b9b0").
- sub(/(b).(b).(b).(b).(b).(b).(b).(b).(b)/, '-\\\9-'))
- assert_equal(S("k"),
- S("1a2b3c4d5e6f7g8h9iAjBk").
- sub(/.(.).(.).(.).(.).(.).(.).(.).(.).(.).(.).(.)/, '\+'))
-
- assert_equal(S("ab\\aba"), S("ababa").sub(/b/, '\&\\'))
- assert_equal(S("ababa"), S("ababa").sub(/b/, '\&'))
- assert_equal(S("ababa"), S("ababa").sub(/b/, '\\&'))
- assert_equal(S("a\\&aba"), S("ababa").sub(/b/, '\\\&'))
- assert_equal(S("a\\&aba"), S("ababa").sub(/b/, '\\\\&'))
- assert_equal(S("a\\baba"), S("ababa").sub(/b/, '\\\\\&'))
-
- a = S("hello")
- a.taint
- assert(a.sub(/./, S('X')).tainted?)
- end
-
- def test_sub!
- a = S("hello")
- b = a.dup
- a.sub!(/[aeiou]/, S('*'))
- assert_equal(S("h*llo"), a)
- assert_equal(S("hello"), b)
-
- a = S("hello")
- a.sub!(/([aeiou])/, S('<\1>'))
- assert_equal(S("h<e>llo"), a)
-
- a = S("hello")
- a.sub!(/./) { |s| s[0].to_s + S(' ')}
- assert_equal(S("h ello"), a)
-
- a = S("hello")
- a.sub!(/(hell)(.)/) { |s| $1.upcase + S('-') + $2 }
- assert_equal(S("HELL-o"), a)
-
- a=S("hello")
- assert_nil(a.sub!(/X/, S('Y')))
-
- r = S('X')
- r.taint
- a.sub!(/./, r)
- assert(a.tainted?)
- end
-
- def test_succ
- assert_equal(S("abd"), S("abc").succ)
- assert_equal(S("z"), S("y").succ)
- assert_equal(S("aaa"), S("zz").succ)
-
- assert_equal(S("124"), S("123").succ)
- assert_equal(S("1000"), S("999").succ)
-
- assert_equal(S("2000aaa"), S("1999zzz").succ)
- assert_equal(S("AAAAA000"), S("ZZZZ999").succ)
- assert_equal(S("*+"), S("**").succ)
-
- assert_equal("abce", "abcd".succ)
- assert_equal("THX1139", "THX1138".succ)
- assert_equal("<<koalb>>", "<<koala>>".succ)
- assert_equal("2000aaa", "1999zzz".succ)
- assert_equal("AAAA0000", "ZZZ9999".succ)
- assert_equal("**+", "***".succ)
- end
-
- def test_succ!
- a = S("abc")
- b = a.dup
- assert_equal(S("abd"), a.succ!)
- assert_equal(S("abd"), a)
- assert_equal(S("abc"), b)
-
- a = S("y")
- assert_equal(S("z"), a.succ!)
- assert_equal(S("z"), a)
-
- a = S("zz")
- assert_equal(S("aaa"), a.succ!)
- assert_equal(S("aaa"), a)
-
- a = S("123")
- assert_equal(S("124"), a.succ!)
- assert_equal(S("124"), a)
-
- a = S("999")
- assert_equal(S("1000"), a.succ!)
- assert_equal(S("1000"), a)
-
- a = S("1999zzz")
- assert_equal(S("2000aaa"), a.succ!)
- assert_equal(S("2000aaa"), a)
-
- a = S("ZZZZ999")
- assert_equal(S("AAAAA000"), a.succ!)
- assert_equal(S("AAAAA000"), a)
-
- a = S("**")
- assert_equal(S("*+"), a.succ!)
- assert_equal(S("*+"), a)
-
- assert_equal("aaaaaaaaaaaa", "zzzzzzzzzzz".succ!)
- assert_equal("aaaaaaaaaaaaaaaaaaaaaaaa", "zzzzzzzzzzzzzzzzzzzzzzz".succ!)
- end
-
- def test_sum
- n = S("\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001")
- assert_equal(15, n.sum)
- n += S("\001")
- assert_equal(16, n.sum(17))
- n[0] = 2.chr
- assert(15 != n.sum)
- end
-
def check_sum(str, bits=16)
sum = 0
str.each_byte {|c| sum += c}
sum = sum & ((1 << bits) - 1) if bits != 0
assert_equal(sum, str.sum(bits))
end
-
- def test_sum_2
+ def test_sum
assert_equal(0, "".sum)
assert_equal(294, "abc".sum)
check_sum("abc")
@@ -1128,232 +16,4 @@ class TestString < Test::Unit::TestCase
check_sum("xyz", bits)
}
end
-
- def test_swapcase
- assert_equal(S("hi&LOW"), S("HI&low").swapcase)
- end
-
- def test_swapcase!
- a = S("hi&LOW")
- b = a.dup
- assert_equal(S("HI&low"), a.swapcase!)
- assert_equal(S("HI&low"), a)
- assert_equal(S("hi&LOW"), b)
-
- a = S("$^#^%$#!!")
- assert_nil(a.swapcase!)
- assert_equal(S("$^#^%$#!!"), a)
- end
-
- def test_to_f
- assert_equal(344.3, S("344.3").to_f)
- assert_equal(5.9742e24, S("5.9742e24").to_f)
- assert_equal(98.6, S("98.6 degrees").to_f)
- assert_equal(0.0, S("degrees 100.0").to_f)
- end
-
- def test_to_i
- assert_equal(1480, S("1480ft/sec").to_i)
- assert_equal(0, S("speed of sound in water @20C = 1480ft/sec)").to_i)
- assert_equal(0, " 0".to_i)
- assert_equal(0, "+0".to_i)
- assert_equal(0, "-0".to_i)
- assert_equal(0, "--0".to_i)
- assert_equal(16, "0x10".to_i(0))
- assert_equal(16, "0X10".to_i(0))
- assert_equal(2, "0b10".to_i(0))
- assert_equal(2, "0B10".to_i(0))
- assert_equal(8, "0o10".to_i(0))
- assert_equal(8, "0O10".to_i(0))
- assert_equal(10, "0d10".to_i(0))
- assert_equal(10, "0D10".to_i(0))
- assert_equal(8, "010".to_i(0))
- assert_raise(ArgumentError) { "010".to_i(-10) }
- 2.upto(36) {|radix|
- assert_equal(radix, "10".to_i(radix))
- assert_equal(radix**2, "100".to_i(radix))
- }
- assert_raise(ArgumentError) { "0".to_i(1) }
- assert_raise(ArgumentError) { "0".to_i(37) }
- assert_equal(0, "z".to_i(10))
- assert_equal(12, "1_2".to_i(10))
- assert_equal(0x40000000, "1073741824".to_i(10))
- assert_equal(0x4000000000000000, "4611686018427387904".to_i(10))
- assert_equal(12, "1__2".to_i(10))
- assert_equal(1, "1_z".to_i(10))
- end
-
- def test_to_s
- a = S("me")
- assert_equal("me", a.to_s)
- assert_equal(a.__id__, a.to_s.__id__) if @cls == String
- end
-
- def test_to_str
- a = S("me")
- assert_equal("me", a.to_s)
- assert_equal(a.__id__, a.to_s.__id__) if @cls == String
- end
-
- def test_tr
- assert_equal(S("hippo"), S("hello").tr(S("el"), S("ip")))
- assert_equal(S("*e**o"), S("hello").tr(S("^aeiou"), S("*")))
- assert_equal(S("hal"), S("ibm").tr(S("b-z"), S("a-z")))
- end
-
- def test_tr!
- a = S("hello")
- b = a.dup
- assert_equal(S("hippo"), a.tr!(S("el"), S("ip")))
- assert_equal(S("hippo"), a)
- assert_equal(S("hello"),b)
-
- a = S("hello")
- assert_equal(S("*e**o"), a.tr!(S("^aeiou"), S("*")))
- assert_equal(S("*e**o"), a)
-
- a = S("IBM")
- assert_equal(S("HAL"), a.tr!(S("B-Z"), S("A-Z")))
- assert_equal(S("HAL"), a)
-
- a = S("ibm")
- assert_nil(a.tr!(S("B-Z"), S("A-Z")))
- assert_equal(S("ibm"), a)
- end
-
- def test_tr_s
- assert_equal(S("hypo"), S("hello").tr_s(S("el"), S("yp")))
- assert_equal(S("h*o"), S("hello").tr_s(S("el"), S("*")))
- end
-
- def test_tr_s!
- a = S("hello")
- b = a.dup
- assert_equal(S("hypo"), a.tr_s!(S("el"), S("yp")))
- assert_equal(S("hypo"), a)
- assert_equal(S("hello"), b)
-
- a = S("hello")
- assert_equal(S("h*o"), a.tr_s!(S("el"), S("*")))
- assert_equal(S("h*o"), a)
- end
-
- def test_unpack
- a = [S("cat"), S("wom"), S("x"), S("yy")]
- assert_equal(a, S("catwomx yy ").unpack(S("A3A3A3A3")))
-
- assert_equal([S("cat")], S("cat \000\000").unpack(S("A*")))
- assert_equal([S("cwx"), S("wx"), S("x"), S("yy")],
- S("cwx yy ").unpack(S("A3@1A3@2A3A3")))
- assert_equal([S("cat"), S("wom"), S("x\000\000"), S("yy\000")],
- S("catwomx\000\000yy\000").unpack(S("a3a3a3a3")))
- assert_equal([S("cat \000\000")], S("cat \000\000").unpack(S("a*")))
- assert_equal([S("ca")], S("catdog").unpack(S("a2")))
-
- assert_equal([S("cat\000\000")],
- S("cat\000\000\000\000\000dog").unpack(S("a5")))
-
- assert_equal([S("01100001")], S("\x61").unpack(S("B8")))
- assert_equal([S("01100001")], S("\x61").unpack(S("B*")))
- assert_equal([S("0110000100110111")], S("\x61\x37").unpack(S("B16")))
- assert_equal([S("01100001"), S("00110111")], S("\x61\x37").unpack(S("B8B8")))
- assert_equal([S("0110")], S("\x60").unpack(S("B4")))
-
- assert_equal([S("01")], S("\x40").unpack(S("B2")))
-
- assert_equal([S("01100001")], S("\x86").unpack(S("b8")))
- assert_equal([S("01100001")], S("\x86").unpack(S("b*")))
-
- assert_equal([S("0110000100110111")], S("\x86\xec").unpack(S("b16")))
- assert_equal([S("01100001"), S("00110111")], S("\x86\xec").unpack(S("b8b8")))
-
- assert_equal([S("0110")], S("\x06").unpack(S("b4")))
- assert_equal([S("01")], S("\x02").unpack(S("b2")))
-
- assert_equal([ 65, 66, 67 ], S("ABC").unpack(S("C3")))
- assert_equal([ 255, 66, 67 ], S("\377BC").unpack("C*"))
- assert_equal([ 65, 66, 67 ], S("ABC").unpack("c3"))
- assert_equal([ -1, 66, 67 ], S("\377BC").unpack("c*"))
-
-
- assert_equal([S("4142"), S("0a"), S("1")], S("AB\n\x10").unpack(S("H4H2H1")))
- assert_equal([S("1424"), S("a0"), S("2")], S("AB\n\x02").unpack(S("h4h2h1")))
-
- assert_equal([S("abc\002defcat\001"), S(""), S("")],
- S("abc=02def=\ncat=\n=01=\n").unpack(S("M9M3M4")))
-
- assert_equal([S("hello\n")], S("aGVsbG8K\n").unpack(S("m")))
-
- assert_equal([S("hello\nhello\n")], S(",:&5L;&\\*:&5L;&\\*\n").unpack(S("u")))
-
- assert_equal([0xa9, 0x42, 0x2260], S("\xc2\xa9B\xe2\x89\xa0").unpack(S("U*")))
-
-=begin
- skipping "Not tested:
- D,d & double-precision float, native format\\
- E & double-precision float, little-endian byte order\\
- e & single-precision float, little-endian byte order\\
- F,f & single-precision float, native format\\
- G & double-precision float, network (big-endian) byte order\\
- g & single-precision float, network (big-endian) byte order\\
- I & unsigned integer\\
- i & integer\\
- L & unsigned long\\
- l & long\\
-
- m & string encoded in base64 (uuencoded)\\
- N & long, network (big-endian) byte order\\
- n & short, network (big-endian) byte-order\\
- P & pointer to a structure (fixed-length string)\\
- p & pointer to a null-terminated string\\
- S & unsigned short\\
- s & short\\
- V & long, little-endian byte order\\
- v & short, little-endian byte order\\
- X & back up a byte\\
- x & null byte\\
- Z & ASCII string (null padded, count is width)\\
-"
-=end
- end
-
- def test_upcase
- assert_equal(S("HELLO"), S("hello").upcase)
- assert_equal(S("HELLO"), S("hello").upcase)
- assert_equal(S("HELLO"), S("HELLO").upcase)
- assert_equal(S("ABC HELLO 123"), S("abc HELLO 123").upcase)
- end
-
- def test_upcase!
- a = S("hello")
- b = a.dup
- assert_equal(S("HELLO"), a.upcase!)
- assert_equal(S("HELLO"), a)
- assert_equal(S("hello"), b)
-
- a = S("HELLO")
- assert_nil(a.upcase!)
- assert_equal(S("HELLO"), a)
- end
-
- def test_upto
- a = S("aa")
- start = S("aa")
- count = 0
- assert_equal(S("aa"), a.upto(S("zz")) {|s|
- assert_equal(start, s)
- start.succ!
- count += 1
- })
- assert_equal(676, count)
- end
-
- def test_splice!
- l = S("1234\n234\n34\n4\n")
- assert_equal(S("1234\n"), l.slice!(/\A.*\n/), "[ruby-dev:31665]")
- assert_equal(S("234\n"), l.slice!(/\A.*\n/), "[ruby-dev:31665]")
- assert_equal(S("34\n"), l.slice!(/\A.*\n/), "[ruby-dev:31665]")
- assert_equal(S("4\n"), l.slice!(/\A.*\n/), "[ruby-dev:31665]")
- assert_nil(l.slice!(/\A.*\n/), "[ruby-dev:31665]")
- end
end
diff --git a/test/ruby/test_stringchar.rb b/test/ruby/test_stringchar.rb
index c128181b2f..34934e87bd 100644
--- a/test/ruby/test_stringchar.rb
+++ b/test/ruby/test_stringchar.rb
@@ -68,9 +68,9 @@ END
# character constants(assumes ASCII)
assert_equal(?a, "a"[0])
assert_equal(?a, ?a)
- assert_equal("\1", ?\C-a)
- assert_equal("\341", ?\M-a)
- assert_equal("\201", ?\M-\C-a)
+ assert_equal(1, ?\C-a)
+ assert_equal(225, ?\M-a)
+ assert_equal(129, ?\M-\C-a)
assert_equal(?A, "a".upcase![0])
assert_equal(?a, "A".downcase![0])
assert_equal("ABC", "abc".tr!("a-z", "A-Z"))
@@ -82,7 +82,7 @@ END
$y = [ ?a, ?b, ?c, ?d, ?e, ?f ]
$bad = false
$x.each_byte {|i|
- if i.chr != $y.shift
+ if i != $y.shift
$bad = true
break
end
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index e66dd8f05b..fa1bb1549a 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -21,32 +21,4 @@ class TestStruct < Test::Unit::TestCase
test.bar = 47
assert_equal(47, test.bar)
end
-
- # [ruby-dev:26247] more than 10 struct members causes segmentation fault
- def test_morethan10members
- list = %w( a b c d e f g h i j k l m n o p )
- until list.empty?
- c = Struct.new(* list.map {|ch| ch.intern }).new
- list.each do |ch|
- c.__send__(ch)
- end
- list.pop
- end
- end
-
- def test_small_structs
- names = [:a, :b, :c, :d]
- 1.upto(4) {|n|
- fields = names[0, n]
- klass = Struct.new(*fields)
- o = klass.new(*(0...n).to_a)
- fields.each_with_index {|name, i|
- assert_equal(i, o[name])
- }
- o = klass.new(*(0...n).to_a.reverse)
- fields.each_with_index {|name, i|
- assert_equal(n-i-1, o[name])
- }
- }
- end
end
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 5e93074e2d..900fe997e6 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -120,15 +120,15 @@ class TestSuper < Test::Unit::TestCase
def uu(a)
class << self
define_method(:tt) do |sym|
- super(sym)
+ super
end
end
end
end
- def test_define_method
+ def test_define_method # [ruby-core:03856]
a = A.new
a.uu(12)
- assert_equal("A#tt", a.tt(12), "[ruby-core:3856]")
+ assert_equal("A#tt", a.tt(12))
end
end
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index f53e615766..42350ba6e7 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -77,5 +77,16 @@ class TestSymbol < Test::Unit::TestCase
def test_to_proc
assert_equal %w(1 2 3), (1..3).map(&:to_s)
+ [
+ [],
+ [1],
+ [1, 2],
+ [1, [2, 3]],
+ ].each do |ary|
+ ary_id = ary.object_id
+ assert_equal ary_id, :object_id.to_proc.call(ary)
+ ary_ids = ary.collect{|x| x.object_id }
+ assert_equal ary_ids, ary.collect(&:object_id)
+ end
end
end
diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb
index 403bacab2d..3513577ec5 100644
--- a/test/ruby/test_system.rb
+++ b/test/ruby/test_system.rb
@@ -1,10 +1,9 @@
require 'test/unit'
+$:.replace([File.dirname(File.expand_path(__FILE__))] | $:)
require 'envutil'
-require 'tmpdir'
class TestSystem < Test::Unit::TestCase
def valid_syntax?(code, fname)
- code.force_encoding("ascii-8bit")
code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) {
"#$&#{"\n" if $1 && !$2}BEGIN{return true}\n"
}
@@ -16,50 +15,46 @@ class TestSystem < Test::Unit::TestCase
assert_equal("foobar\n", `echo foobar`)
assert_equal('foobar', `#{ruby} -e 'print "foobar"'`)
- Dir.mktmpdir("ruby_script_tmp") {|tmpdir|
- tmpfilename = "#{tmpdir}/ruby_script_tmp.#{$$}"
+ tmp = open("script_tmp", "w")
+ tmp.print "print $zzz\n";
+ tmp.close
- tmp = open(tmpfilename, "w")
- tmp.print "print $zzz\n";
- tmp.close
+ assert_equal('true', `#{ruby} -s script_tmp -zzz`)
+ assert_equal('555', `#{ruby} -s script_tmp -zzz=555`)
- assert_equal('true', `#{ruby} -s #{tmpfilename} -zzz`)
- assert_equal('555', `#{ruby} -s #{tmpfilename} -zzz=555`)
+ tmp = open("script_tmp", "w")
+ tmp.print "#! /usr/local/bin/ruby -s\n";
+ tmp.print "print $zzz\n";
+ tmp.close
- tmp = open(tmpfilename, "w")
- tmp.print "#! /usr/local/bin/ruby -s\n";
- tmp.print "print $zzz\n";
- tmp.close
+ assert_equal('678', `#{ruby} script_tmp -zzz=678`)
- assert_equal('678', `#{ruby} #{tmpfilename} -zzz=678`)
+ tmp = open("script_tmp", "w")
+ tmp.print "this is a leading junk\n";
+ tmp.print "#! /usr/local/bin/ruby -s\n";
+ tmp.print "print $zzz\n";
+ tmp.print "__END__\n";
+ tmp.print "this is a trailing junk\n";
+ tmp.close
- tmp = open(tmpfilename, "w")
- tmp.print "this is a leading junk\n";
- tmp.print "#! /usr/local/bin/ruby -s\n";
- tmp.print "print $zzz\n";
- tmp.print "__END__\n";
- tmp.print "this is a trailing junk\n";
- tmp.close
+ assert_equal('nil', `#{ruby} -x script_tmp`)
+ assert_equal('555', `#{ruby} -x script_tmp -zzz=555`)
- assert_equal('', `#{ruby} -x #{tmpfilename}`)
- assert_equal('555', `#{ruby} -x #{tmpfilename} -zzz=555`)
-
- tmp = open(tmpfilename, "w")
- for i in 1..5
- tmp.print i, "\n"
- end
- tmp.close
+ tmp = open("script_tmp", "w")
+ for i in 1..5
+ tmp.print i, "\n"
+ end
+ tmp.close
- `#{ruby} -i.bak -pe '$_.sub!(/^[0-9]+$/){$&.to_i * 5}' #{tmpfilename}`
- tmp = open(tmpfilename, "r")
- while tmp.gets
- assert_equal(0, $_.to_i % 5)
- end
- tmp.close
+ `#{ruby} -i.bak -pe 'sub(/^[0-9]+$/){$&.to_i * 5}' script_tmp`
+ tmp = open("script_tmp", "r")
+ while tmp.gets
+ assert_equal(0, $_.to_i % 5)
+ end
+ tmp.close
- File.unlink tmpfilename or `/bin/rm -f "#{tmpfilename}"`
- File.unlink "#{tmpfilename}.bak" or `/bin/rm -f "#{tmpfilename}.bak"`
- }
+ File.unlink "script_tmp" or `/bin/rm -f "script_tmp"`
+ File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
end
def test_syntax
@@ -69,8 +64,4 @@ class TestSystem < Test::Unit::TestCase
end
end
end
-
- def test_empty_evstr
- assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
- end
end
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
deleted file mode 100644
index 0d924eea57..0000000000
--- a/test/ruby/test_thread.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'test/unit'
-
-class TestThread < Test::Unit::TestCase
- def test_mutex_synchronize
- m = Mutex.new
- r = 0
- max = 100
- (1..max).map{
- Thread.new{
- i=0
- while i<max*max
- i+=1
- m.synchronize{
- r += 1
- }
- end
- }
- }.each{|e|
- e.join
- }
- assert_equal(max * max * max, r)
- end
-end
-
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 92c62ef5e9..ae1a35ffad 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'rational'
class TestTime < Test::Unit::TestCase
def test_time_add()
@@ -64,25 +63,15 @@ class TestTime < Test::Unit::TestCase
end
end
- def test_huge_difference
+ def test_huge_difference # [ruby-dev:22619]
if negative_time_t?
- assert_equal(Time.at(-0x80000000), Time.at(0x7fffffff) - 0xffffffff, "[ruby-dev:22619]")
+ assert_equal(Time.at(-0x80000000), Time.at(0x7fffffff) - 0xffffffff)
assert_equal(Time.at(-0x80000000), Time.at(0x7fffffff) + (-0xffffffff))
- assert_equal(Time.at(0x7fffffff), Time.at(-0x80000000) + 0xffffffff, "[ruby-dev:22619]")
+ assert_equal(Time.at(0x7fffffff), Time.at(-0x80000000) + 0xffffffff)
assert_equal(Time.at(0x7fffffff), Time.at(-0x80000000) - (-0xffffffff))
end
end
- def test_big_minus
- begin
- bigtime0 = Time.at(2**60)
- bigtime1 = Time.at(2**60+1)
- rescue RangeError
- return
- end
- assert_equal(1.0, bigtime1 - bigtime0)
- end
-
def test_at
assert_equal(100000, Time.at(0.1).usec)
assert_equal(10000, Time.at(0.01).usec)
@@ -90,59 +79,17 @@ class TestTime < Test::Unit::TestCase
assert_equal(100, Time.at(0.0001).usec)
assert_equal(10, Time.at(0.00001).usec)
assert_equal(1, Time.at(0.000001).usec)
- assert_equal(100000000, Time.at(0.1).nsec)
- assert_equal(10000000, Time.at(0.01).nsec)
- assert_equal(1000000, Time.at(0.001).nsec)
- assert_equal(100000, Time.at(0.0001).nsec)
- assert_equal(10000, Time.at(0.00001).nsec)
- assert_equal(1000, Time.at(0.000001).nsec)
- assert_equal(100, Time.at(0.0000001).nsec)
- assert_equal(10, Time.at(0.00000001).nsec)
- assert_equal(1, Time.at(0.000000001).nsec)
- end
-
- def test_at2
- assert_equal(100, Time.at(0, 0.1).nsec)
- assert_equal(10, Time.at(0, 0.01).nsec)
- assert_equal(1, Time.at(0, 0.001).nsec)
- end
-
- def test_at_rational
- assert_equal(1, Time.at(Rational(1,1) / 1000000000).nsec)
- assert_equal(1, Time.at(1167609600 + Rational(1,1) / 1000000000).nsec)
- end
-
- def test_utc_subsecond
- assert_equal(100000, Time.utc(2007,1,1,0,0,1.1).usec)
- assert_equal(100000, Time.utc(2007,1,1,0,0,Rational(11,10)).usec)
- end
-
- def test_eq_nsec
- assert_equal(Time.at(0, 0.123), Time.at(0, 0.123))
- assert_not_equal(Time.at(0, 0.123), Time.at(0, 0.124))
- end
-
- def assert_marshal_roundtrip(t)
- iv_names = t.instance_variables
- iv_vals1 = iv_names.map {|n| t.instance_variable_get n }
- m = Marshal.dump(t)
- t2 = Marshal.load(m)
- iv_vals2 = iv_names.map {|n| t2.instance_variable_get n }
- assert_equal(t, t2)
- assert_equal(iv_vals1, iv_vals2)
- t2
- end
-
- def test_marshal_nsec
- assert_marshal_roundtrip(Time.at(0, 0.123))
- assert_marshal_roundtrip(Time.at(0, 0.120))
- end
-
- def test_marshal_ivar
- t = Time.at(123456789, 987654.321)
- t.instance_eval { @var = 135 }
- assert_marshal_roundtrip(t)
- assert_marshal_roundtrip(Marshal.load(Marshal.dump(t)))
+ assert_equal(0, Time.at(1e-7).usec)
+ assert_equal(0, Time.at(4e-7).usec)
+ assert_equal(1, Time.at(6e-7).usec)
+ assert_equal(1, Time.at(14e-7).usec)
+ assert_equal(2, Time.at(16e-7).usec)
+ if negative_time_t?
+ assert_equal(0, Time.at(-1e-7).usec)
+ assert_equal(0, Time.at(-4e-7).usec)
+ assert_equal(999999, Time.at(-6e-7).usec)
+ assert_equal(999999, Time.at(-14e-7).usec)
+ assert_equal(999998, Time.at(-16e-7).usec)
+ end
end
-
end
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb
deleted file mode 100644
index 73177a136b..0000000000
--- a/test/ruby/test_transcode.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-# -*- encoding: ASCII-8BIT -*- # make sure this runs in binary mode
-# some of the comments are in UTF-8
-
-require 'test/unit'
-class TestTranscode < Test::Unit::TestCase
- def setup # trick to create all the necessary encodings
- all_encodings = [ 'ISO-8859-1', 'ISO-8859-2',
- 'ISO-8859-3', 'ISO-8859-4',
- 'ISO-8859-5', 'ISO-8859-6',
- 'ISO-8859-7', 'ISO-8859-8',
- 'ISO-8859-9', 'ISO-8859-10',
- 'ISO-8859-11', 'ISO-8859-13',
- 'ISO-8859-14', 'ISO-8859-15'
- ]
- all_encodings.each do |enc|
- 'abc'.encode(enc, 'UTF-8')
- end
- end
-
- def test_errors
- # we don't have semantics for conversion without attribute yet
- # maybe 'convert to UTF-8' would be nice :-)
- assert_raise(ArgumentError) { 'abc'.encode }
- assert_raise(ArgumentError) { 'abc'.encode! }
- assert_raise(ArgumentError) { 'abc'.encode('foo', 'bar') }
- assert_raise(ArgumentError) { 'abc'.encode!('foo', 'bar') }
- assert_raise(ArgumentError) { 'abc'.force_encoding('utf-8').encode('foo') }
- assert_raise(ArgumentError) { 'abc'.force_encoding('utf-8').encode!('foo') }
- assert_raise(RuntimeError) { "\xA5".encode('utf-8','iso-8859-3') }
- end
-
- def test_arguments
- assert_equal('abc', 'abc'.force_encoding('utf-8').encode('iso-8859-1'))
- # check that encoding is kept when no conversion is done
- assert_equal('abc'.force_encoding('Shift_JIS'), 'abc'.force_encoding('Shift_JIS').encode('Shift_JIS'))
- assert_equal('abc'.force_encoding('Shift_JIS'), 'abc'.force_encoding('Shift_JIS').encode!('Shift_JIS'))
- # assert that encoding is correctly set
- assert_equal("D\u00FCrst".encoding, "D\xFCrst".force_encoding('iso-8859-1').encode('utf-8').encoding)
- # check that Encoding can be used as parameter
- assert_equal("D\u00FCrst", "D\xFCrst".encode('utf-8', Encoding.find('ISO-8859-1')))
- assert_equal("D\u00FCrst", "D\xFCrst".encode(Encoding.find('utf-8'), 'ISO-8859-1'))
- assert_equal("D\u00FCrst", "D\xFCrst".encode(Encoding.find('utf-8'), Encoding.find('ISO-8859-1')))
- end
-
- def test_length
- assert_equal("\u20AC"*20, ("\xA4"*20).encode('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*20, ("\xA4"*20).encode!('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*2000, ("\xA4"*2000).encode('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*2000, ("\xA4"*2000).encode!('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*200000, ("\xA4"*200000).encode('utf-8', 'iso-8859-15'))
- assert_equal("\u20AC"*200000, ("\xA4"*200000).encode!('utf-8', 'iso-8859-15'))
- end
-
- def check_both_ways(utf8, raw, encoding)
- assert_equal(utf8, raw.encode('utf-8', encoding))
- assert_equal(raw, utf8.encode(encoding).force_encoding('ASCII-8BIT'))
- end
-
- def test_encodings
- check_both_ways("\u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D",
- "\x82\xdc\x82\xc2\x82\xe0\x82\xc6 \x82\xe4\x82\xab\x82\xd0\x82\xeb", 'shift_jis') # ã¾ã¤ã‚‚㨠ゆãã²ã‚
- check_both_ways("\u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D",
- "\xa4\xde\xa4\xc4\xa4\xe2\xa4\xc8 \xa4\xe6\xa4\xad\xa4\xd2\xa4\xed", 'euc-jp')
- check_both_ways("\u677E\u672C\u884C\u5F18", "\x8f\xbc\x96\x7b\x8d\x73\x8d\x4f", 'shift_jis') # æ¾æœ¬è¡Œå¼˜
- check_both_ways("\u677E\u672C\u884C\u5F18", "\xbe\xbe\xcb\xdc\xb9\xd4\xb9\xb0", 'euc-jp')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-1') # Dürst
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-2')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-3')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-4')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-9')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-10')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-13')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-14')
- check_both_ways("D\u00FCrst", "D\xFCrst", 'iso-8859-15')
- check_both_ways("r\u00E9sum\u00E9", "r\xE9sum\xE9", 'iso-8859-1') # résumé
- check_both_ways("\u0065\u006C\u0151\u00ED\u0072\u00E1\u0073", "el\xF5\xEDr\xE1s", 'iso-8859-2') # előírás
- check_both_ways("\u043F\u0435\u0440\u0435\u0432\u043E\u0434",
- "\xDF\xD5\xE0\xD5\xD2\xDE\xD4", 'iso-8859-5') # перевод
- check_both_ways("\u0643\u062A\u0628", "\xE3\xCA\xC8", 'iso-8859-6') # كتب
- check_both_ways("\u65E5\u8A18", "\x93\xFA\x8BL", 'shift_jis') # 日記
- check_both_ways("\u65E5\u8A18", "\xC6\xFC\xB5\xAD", 'euc-jp')
- end
-
- def test_twostep
- assert_equal("D\xFCrst".force_encoding('iso-8859-2'), "D\xFCrst".encode('iso-8859-2', 'iso-8859-1'))
- end
-
- def test_ascii_range
- encodings = [
- 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',
- 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6',
- 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
- 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-13',
- 'ISO-8859-14', 'ISO-8859-15',
- 'EUC-JP', 'SHIFT_JIS'
- ]
- all_ascii = (0..127).to_a.pack 'C*'
- encodings.each do |enc|
- test_start = all_ascii
- assert_equal(test_start, test_start.encode('UTF-8',enc).encode(enc).force_encoding('ASCII-8BIT'))
- end
- end
-
- def test_all_bytes
- encodings_8859 = [
- 'ISO-8859-1', 'ISO-8859-2',
- #'ISO-8859-3', # not all bytes used
- 'ISO-8859-4', 'ISO-8859-5',
- #'ISO-8859-6', # not all bytes used
- #'ISO-8859-7', # not all bytes used
- #'ISO-8859-8', # not all bytes used
- 'ISO-8859-9', 'ISO-8859-10',
- #'ISO-8859-11', # not all bytes used
- #'ISO-8859-12', # not available
- 'ISO-8859-13','ISO-8859-14','ISO-8859-15',
- #'ISO-8859-16', # not available
- ]
- all_bytes = (0..255).to_a.pack 'C*'
- encodings_8859.each do |enc|
- test_start = all_bytes
- assert_equal(test_start, test_start.encode('UTF-8',enc).encode(enc).force_encoding('ASCII-8BIT'))
- end
- end
-end
diff --git a/test/ruby/test_unicode_escape.rb b/test/ruby/test_unicode_escape.rb
deleted file mode 100644
index a1800c66e6..0000000000
--- a/test/ruby/test_unicode_escape.rb
+++ /dev/null
@@ -1,267 +0,0 @@
-# -*- coding: utf-8 -*-
-
-require 'test/unit'
-
-class TestUnicodeEscape < Test::Unit::TestCase
- def test_basic
- assert_equal('Matz - æ¾æœ¬è¡Œå¼˜',
- "Matz - \u677E\u672C\u884C\u5F18")
- assert_equal('Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚',
- "Matz - \u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D")
- assert_equal('Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚',
- "Matz - \u{307E}\u{3064}\u{3082}\u{3068} \u{3086}\u{304D}\u{3072}\u{308D}")
- assert_equal('Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚',
- "Matz - \u{307E 3064 3082 3068 20 3086 304D 3072 308D}")
- assert_equal("Aoyama Gakuin University - \xE9\x9D\x92\xE5\xB1\xB1\xE5\xAD\xA6\xE9\x99\xA2\xE5\xA4\xA7\xE5\xAD\xA6",
- "Aoyama Gakuin University - \u9752\u5C71\u5B66\u9662\u5927\u5B66")
- assert_equal('Aoyama Gakuin University - é’山学院大学',
- "Aoyama Gakuin University - \u9752\u5C71\u5B66\u9662\u5927\u5B66")
- assert_equal('é’山学院大学', "\u9752\u5C71\u5B66\u9662\u5927\u5B66")
- assert_equal("Martin D\xC3\xBCrst", "Martin D\u00FCrst")
- assert_equal('Martin Dürst', "Martin D\u00FCrst")
- assert_equal('ü', "\u00FC")
- assert_equal("Martin D\xC3\xBCrst", "Martin D\u{FC}rst")
- assert_equal('Martin Dürst', "Martin D\u{FC}rst")
- assert_equal('ü', "\u{FC}")
- assert_equal('ü', %Q|\u{FC}|)
- assert_equal('ü', %W{\u{FC}}[0])
-
- # \u escapes in here documents
- assert_equal('Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚', <<EOS.chop)
-Matz - \u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D
-EOS
-
- assert_equal('Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚', <<"EOS".chop)
-Matz - \u{307E 3064 3082 3068} \u{3086 304D 3072 308D}
-EOS
- assert_not_equal('Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚', <<'EOS'.chop)
-Matz - \u{307E 3064 3082 3068} \u{3086 304D 3072 308D}
-EOS
-
- # single-quoted things don't expand \u
- assert_not_equal('ü', '\u{FC}')
- assert_not_equal('ü', %q|\u{FC}|)
- assert_not_equal('ü', %w{\u{FC}}[0])
- assert_equal('\u00fc', "\\" + "u00fc")
-
- # \u in %x strings
- assert_equal(`echo "\u0041"`.chop, "A")
- assert_equal(%x{echo "\u0041"}.chop, "A")
- assert_equal(`echo "\u{FC}"`.force_encoding("utf-8"), "ü\n")
-
- # \u in quoted symbols
- assert_equal(:A, :"\u0041")
- assert_equal(:a, :"\u0061")
- assert_equal(:ã¾, :ã¾)
- assert_equal(:ü, :ü)
- assert_equal(:"\u{41}", :"\u0041")
- assert_equal(:ü, :"\u{fc}")
-
- # the NUL character is not allowed in symbols
- assert_raise(SyntaxError) { eval %q(:"\u{0}")}
- assert_raise(SyntaxError) { eval %q(:"\u0000")}
- assert_raise(SyntaxError) { eval %q(:"\u{fc 0 0041}")}
- assert_raise(SyntaxError) { eval %q(:"\x00")}
- assert_raise(SyntaxError) { eval %q(:"\0")}
- end
-
- def test_regexp
-
- # Compare regexps to regexps
- assert_not_equal(/Yukihiro Matsumoto - æ¾æœ¬è¡Œå¼˜/,
- /Yukihiro Matsumoto - \u677E\u672C\u884C\u5F18/)
- assert_not_equal(/Yukihiro Matsumoto - æ¾æœ¬è¡Œå¼˜/,
- /Yukihiro Matsumoto - \u{677E 672C 884C 5F18}/)
- assert_not_equal(/Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚/,
- /Matz - \u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D/)
- assert_not_equal(/Aoyama Gakuin University - é’山学院大学/,
- /Aoyama Gakuin University - \u9752\u5C71\u5B66\u9662\u5927\u5B66/)
- assert_not_equal(/é’山学院大学/, /\u9752\u5C71\u5B66\u9662\u5927\u5B66/)
- assert_not_equal(/Martin Dürst/, /Martin D\u00FCrst/)
- assert_not_equal(/ü/, /\u00FC/)
- assert_not_equal(/Martin Dürst/, /Martin D\u{FC}rst/)
- assert_not_equal(/ü/, /\u{FC}/)
- assert_not_equal(/ü/, %r{\u{FC}})
- assert_not_equal(/ü/i, %r{\u00FC}i)
-
- assert_equal('Yukihiro Matsumoto - \u677E\u672C\u884C\u5F18',
- /Yukihiro Matsumoto - \u677E\u672C\u884C\u5F18/.source)
- assert_equal('Yukihiro Matsumoto - \u{677E 672C 884C 5F18}',
- /Yukihiro Matsumoto - \u{677E 672C 884C 5F18}/.source)
- assert_equal('Matz - \u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D',
- /Matz - \u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D/.source)
- assert_equal('Aoyama Gakuin University - \u9752\u5C71\u5B66\u9662\u5927\u5B66',
- /Aoyama Gakuin University - \u9752\u5C71\u5B66\u9662\u5927\u5B66/.source)
- assert_equal('\u9752\u5C71\u5B66\u9662\u5927\u5B66',
- /\u9752\u5C71\u5B66\u9662\u5927\u5B66/.source)
- assert_equal('Martin D\u00FCrst', /Martin D\u00FCrst/.source)
- assert_equal('\u00FC', /\u00FC/.source)
- assert_equal('Martin D\u{FC}rst', /Martin D\u{FC}rst/.source)
- assert_equal('\u{FC}', /\u{FC}/.source)
- assert_equal('\u{FC}', %r{\u{FC}}.source)
- assert_equal('\u00FC', %r{\u00FC}i.source)
-
- # match strings to regexps
- assert_equal(0, "Yukihiro Matsumoto - æ¾æœ¬è¡Œå¼˜" =~ /Yukihiro Matsumoto - \u677E\u672C\u884C\u5F18/)
- assert_equal(0, "Yukihiro Matsumoto - \u677E\u672C\u884C\u5F18" =~ /Yukihiro Matsumoto - \u677E\u672C\u884C/)
- assert_equal(0, "Yukihiro Matsumoto - æ¾æœ¬è¡Œå¼˜" =~ /Yukihiro Matsumoto - \u{677E 672C 884C 5F18}/)
- assert_equal(0, %Q{Yukihiro Matsumoto - \u{677E 672C 884C 5F18}} =~ /Yukihiro Matsumoto - \u{677E 672C 884C 5F18}/)
- assert_equal(0, "Matz - ã¾ã¤ã‚‚㨠ゆãã²ã‚" =~ /Matz - \u307E\u3064\u3082\u3068 \u3086\u304D\u3072\u308D/)
- assert_equal(0, "Aoyama Gakuin University - é’山学院大学" =~ /Aoyama Gakuin University - \u9752\u5C71\u5B66\u9662\u5927\u5B66/)
- assert_equal(0, "é’山学院大学" =~ /\u9752\u5C71\u5B66\u9662\u5927\u5B66/)
- assert_equal(0, "Martin Dürst" =~ /Martin D\u00FCrst/)
- assert_equal(0, "ü" =~ /\u00FC/)
- assert_equal(0, "Martin Dürst" =~ /Martin D\u{FC}rst/)
- assert_equal(0, "ü" =~ %r{\u{FC}})
- assert_equal(0, "ü" =~ %r{\u00FC}i)
-
- # Flip order of the two operands
- assert_equal(0, /Martin D\u00FCrst/ =~ "Martin Dürst")
- assert_equal(4, /\u00FC/ =~ "testü")
- assert_equal(3, /Martin D\u{FC}rst/ =~ "fooMartin Dürstbar")
- assert_equal(3, %r{\u{FC}} =~ "fooübar")
-
- # Put \u in strings, literal character in regexp
- assert_equal(0, "Martin D\u00FCrst" =~ /Martin Dürst/)
- assert_equal(4, "test\u00FC" =~ /ü/)
- assert_equal(3, "fooMartin D\u{FC}rstbar" =~ /Martin Dürst/)
- assert_equal(3, %Q{foo\u{FC}bar} =~ %r<ü>)
-
- assert_match(eval('/\u{2a}/'), "*")
- assert_raise(SyntaxError) { eval('/\u{6666}/n') }
- assert_raise(SyntaxError) { eval('/\u{6666}/e') }
- assert_raise(SyntaxError) { eval('/\u{6666}/s') }
- assert_nothing_raised { eval('/\u{6666}/u') }
- end
-
- def test_dynamic_regexp
- assert_match(Regexp.new("Martin D\\u{FC}rst"), "Martin Dürst")
- end
-
- def test_syntax_variants
- # all hex digits
- assert_equal("\xC4\xA3\xE4\x95\xA7\xE8\xA6\xAB\xEC\xB7\xAF", "\u0123\u4567\u89AB\uCDEF")
- assert_equal("\xC4\xA3\xE4\x95\xA7\xE8\xA6\xAB\xEC\xB7\xAF", "\u0123\u4567\u89AB\uCDEF")
- assert_equal("\xC4\xA3\xE4\x95\xA7\xE8\xA6\xAB\xEC\xB7\xAF", "\u0123\u4567\u89ab\ucdef")
- assert_equal("\xC4\xA3\xE4\x95\xA7\xE8\xA6\xAB\xEC\xB7\xAF", "\u0123\u4567\u89ab\ucdef")
- assert_equal("\xC4\xA3\xE4\x95\xA7\xE8\xA6\xAB\xEC\xB7\xAF", "\u0123\u4567\u89aB\uCdEf")
- assert_equal("\xC4\xA3\xE4\x95\xA7\xE8\xA6\xAB\xEC\xB7\xAF", "\u0123\u4567\u89aB\ucDEF")
- end
-
- def test_fulton
- # examples from Hal Fulton's book (second edition), chapter 4
- # precomposed e'pe'e
- assert_equal('épée', "\u00E9\u0070\u00E9\u0065")
- assert_equal('épée', "\u00E9p\u00E9e")
- assert_equal("\xC3\xA9\x70\xC3\xA9\x65", "\u00E9\u0070\u00E9\u0065")
- assert_equal("\xC3\xA9\x70\xC3\xA9\x65", "\u00E9p\u00E9e")
- # decomposed e'pe'e
- assert_equal('eÌpeÌe', "\u0065\u0301\u0070\u0065\u0301\u0065")
- assert_equal('eÌpeÌe', "e\u0301pe\u0301e")
- assert_equal("\x65\xCC\x81\x70\x65\xCC\x81\x65", "\u0065\u0301\u0070\u0065\u0301\u0065")
- assert_equal("\x65\xCC\x81\x70\x65\xCC\x81\x65", "e\u0301pe\u0301e")
- # combinations of NFC/D, NFKC/D
- assert_equal('öffnen', "\u00F6\u0066\u0066\u006E\u0065\u006E")
- assert_equal("\xC3\xB6ffnen", "\u00F6\u0066\u0066\u006E\u0065\u006E")
- assert_equal('öffnen', "\u00F6ffnen")
- assert_equal("\xC3\xB6ffnen", "\u00F6ffnen")
- assert_equal('öffnen', "\u006F\u0308\u0066\u0066\u006E\u0065\u006E")
- assert_equal("\x6F\xCC\x88ffnen", "\u006F\u0308\u0066\u0066\u006E\u0065\u006E")
- assert_equal('öffnen', "o\u0308ffnen")
- assert_equal("\x6F\xCC\x88ffnen", "o\u0308ffnen")
- assert_equal('öffnen', "\u00F6\uFB00\u006E\u0065\u006E")
- assert_equal("\xC3\xB6\xEF\xAC\x80nen", "\u00F6\uFB00\u006E\u0065\u006E")
- assert_equal('öffnen', "\u00F6\uFB00nen")
- assert_equal("\xC3\xB6\xEF\xAC\x80nen", "\u00F6\uFB00nen")
- assert_equal('öffnen', "\u006F\u0308\uFB00\u006E\u0065\u006E")
- assert_equal("\x6F\xCC\x88\xEF\xAC\x80nen", "\u006F\u0308\uFB00\u006E\u0065\u006E")
- assert_equal('öffnen', "o\u0308\uFB00nen")
- assert_equal("\x6F\xCC\x88\xEF\xAC\x80nen", "o\u0308\uFB00nen")
- # German sharp s (sz)
- assert_equal('Straße', "\u0053\u0074\u0072\u0061\u00DF\u0065")
- assert_equal("\x53\x74\x72\x61\xC3\x9F\x65", "\u0053\u0074\u0072\u0061\u00DF\u0065")
- assert_equal('Straße', "Stra\u00DFe")
- assert_equal("\x53\x74\x72\x61\xC3\x9F\x65", "Stra\u00DFe")
- assert_equal('Straße', "\u{53}\u{74}\u{72}\u{61}\u{DF}\u{65}")
- assert_equal("\x53\x74\x72\x61\xC3\x9F\x65", "\u{53}\u{74}\u{72}\u{61}\u{DF}\u{65}")
- assert_equal("\x53\x74\x72\x61\xC3\x9F\x65", "\u{53 74 72 61 DF 65}")
- assert_equal('Straße', "Stra\u{DF}e")
- assert_equal("\x53\x74\x72\x61\xC3\x9F\x65", "Stra\u{DF}e")
- end
-
- def test_edge_cases
- # start and end of each outer plane
- assert_equal("\xF4\x8F\xBF\xBF", "\u{10FFFF}")
- assert_equal("\xF4\x80\x80\x80", "\u{100000}")
- assert_equal("\xF3\xBF\xBF\xBF", "\u{FFFFF}")
- assert_equal("\xF3\xB0\x80\x80", "\u{F0000}")
- assert_equal("\xF3\xAF\xBF\xBF", "\u{EFFFF}")
- assert_equal("\xF3\xA0\x80\x80", "\u{E0000}")
- assert_equal("\xF3\x9F\xBF\xBF", "\u{DFFFF}")
- assert_equal("\xF3\x90\x80\x80", "\u{D0000}")
- assert_equal("\xF3\x8F\xBF\xBF", "\u{CFFFF}")
- assert_equal("\xF3\x80\x80\x80", "\u{C0000}")
- assert_equal("\xF2\xBF\xBF\xBF", "\u{BFFFF}")
- assert_equal("\xF2\xB0\x80\x80", "\u{B0000}")
- assert_equal("\xF2\xAF\xBF\xBF", "\u{AFFFF}")
- assert_equal("\xF2\xA0\x80\x80", "\u{A0000}")
- assert_equal("\xF2\x9F\xBF\xBF", "\u{9FFFF}")
- assert_equal("\xF2\x90\x80\x80", "\u{90000}")
- assert_equal("\xF2\x8F\xBF\xBF", "\u{8FFFF}")
- assert_equal("\xF2\x80\x80\x80", "\u{80000}")
- assert_equal("\xF1\xBF\xBF\xBF", "\u{7FFFF}")
- assert_equal("\xF1\xB0\x80\x80", "\u{70000}")
- assert_equal("\xF1\xAF\xBF\xBF", "\u{6FFFF}")
- assert_equal("\xF1\xA0\x80\x80", "\u{60000}")
- assert_equal("\xF1\x9F\xBF\xBF", "\u{5FFFF}")
- assert_equal("\xF1\x90\x80\x80", "\u{50000}")
- assert_equal("\xF1\x8F\xBF\xBF", "\u{4FFFF}")
- assert_equal("\xF1\x80\x80\x80", "\u{40000}")
- assert_equal("\xF0\xBF\xBF\xBF", "\u{3FFFF}")
- assert_equal("\xF0\xB0\x80\x80", "\u{30000}")
- assert_equal("\xF0\xAF\xBF\xBF", "\u{2FFFF}")
- assert_equal("\xF0\xA0\x80\x80", "\u{20000}")
- assert_equal("\xF0\x9F\xBF\xBF", "\u{1FFFF}")
- assert_equal("\xF0\x90\x80\x80", "\u{10000}")
- # BMP
- assert_equal("\xEF\xBF\xBF", "\uFFFF")
- assert_equal("\xEE\x80\x80", "\uE000")
- assert_equal("\xED\x9F\xBF", "\uD7FF")
- assert_equal("\xE0\xA0\x80", "\u0800")
- assert_equal("\xDF\xBF", "\u07FF")
- assert_equal("\xC2\x80", "\u0080")
- assert_equal("\x7F", "\u007F")
- assert_equal("\x00", "\u0000")
- end
-
- def test_chars
- assert_equal(?\u0041, ?A)
- assert_equal(?\u{79}, ?\x79)
- assert_equal(?\u{0}, ?\000)
- assert_equal(?\u0000, ?\000)
- end
-
- # Tests to make sure that disallowed cases fail
- def test_fail
- assert_raise(SyntaxError) { eval %q("\uabc") } # too short
- assert_raise(SyntaxError) { eval %q("\uab") } # too short
- assert_raise(SyntaxError) { eval %q("\ua") } # too short
- assert_raise(SyntaxError) { eval %q("\u") } # too short
- assert_raise(SyntaxError) { eval %q("\u{110000}") } # too high
- assert_raise(SyntaxError) { eval %q("\u{abcdeff}") } # too long
- assert_raise(SyntaxError) { eval %q("\ughij") } # bad hex digits
- assert_raise(SyntaxError) { eval %q("\u{ghij}") } # bad hex digits
-
- assert_raise(SyntaxError) { eval %q("\u{123 456 }")} # extra space
- assert_raise(SyntaxError) { eval %q("\u{ 123 456}")} # extra space
- assert_raise(SyntaxError) { eval %q("\u{123 456}")} # extra space
-
-# The utf-8 encoding object currently does not object to codepoints
-# in the surrogate blocks, so these do not raise an error.
-# assert_raise(SyntaxError) { "\uD800" } # surrogate block
-# assert_raise(SyntaxError) { "\uDCBA" } # surrogate block
-# assert_raise(SyntaxError) { "\uDFFF" } # surrogate block
-# assert_raise(SyntaxError) { "\uD847\uDD9A" } # surrogate pair
-
- end
-end
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index cd04de5c3a..8726160826 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -25,11 +25,8 @@ class TestVariable < Test::Unit::TestCase
end
class Titans < Gods
- @@rule = "Cronus" # modifies @@rule in Gods
- include Olympians
- def ruler4
- @@rule
- end
+ @@rule = "Cronus"
+ include Olympians # OK to cause warning (intentional)
end
def test_variable
@@ -52,6 +49,5 @@ class TestVariable < Test::Unit::TestCase
atlas = Titans.new
assert_equal("Cronus", atlas.ruler0)
assert_equal("Zeus", atlas.ruler3)
- assert_equal("Cronus", atlas.ruler4)
end
end
diff --git a/test/ruby/test_whileuntil.rb b/test/ruby/test_whileuntil.rb
index df5bda450d..6faed31160 100644
--- a/test/ruby/test_whileuntil.rb
+++ b/test/ruby/test_whileuntil.rb
@@ -1,75 +1,70 @@
require 'test/unit'
-require 'tmpdir'
class TestWhileuntil < Test::Unit::TestCase
def test_while
- Dir.mktmpdir("ruby_while_tmp") {|tmpdir|
- tmpfilename = "#{tmpdir}/ruby_while_tmp.#{$$}"
+ tmp = open("while_tmp", "w")
+ tmp.print "tvi925\n";
+ tmp.print "tvi920\n";
+ tmp.print "vt100\n";
+ tmp.print "Amiga\n";
+ tmp.print "paper\n";
+ tmp.close
- tmp = open(tmpfilename, "w")
- tmp.print "tvi925\n";
- tmp.print "tvi920\n";
- tmp.print "vt100\n";
- tmp.print "Amiga\n";
- tmp.print "paper\n";
- tmp.close
-
- tmp = open(tmpfilename, "r")
- assert_instance_of(File, tmp)
-
- while line = tmp.gets()
- break if /vt100/ =~ line
- end
+ tmp = open("while_tmp", "r")
+ assert_instance_of(File, tmp)
+
+ while line = tmp.gets()
+ break if /vt100/ =~ line
+ end
- assert(!tmp.eof?)
- assert_match(/vt100/, line)
- tmp.close
+ assert(!tmp.eof?)
+ assert_match(/vt100/, line)
+ tmp.close
- tmp = open(tmpfilename, "r")
- while line = tmp.gets()
- next if /vt100/ =~ line
- assert_no_match(/vt100/, line)
- end
- assert(tmp.eof?)
+ tmp = open("while_tmp", "r")
+ while line = tmp.gets()
+ next if /vt100/ =~ line
assert_no_match(/vt100/, line)
- tmp.close
+ end
+ assert(tmp.eof?)
+ assert_no_match(/vt100/, line)
+ tmp.close
- tmp = open(tmpfilename, "r")
- while line = tmp.gets()
- lastline = line
- line = line.gsub(/vt100/, 'VT100')
- if lastline != line
- line.gsub!('VT100', 'Vt100')
- redo
- end
- assert_no_match(/vt100/, line)
- assert_no_match(/VT100/, line)
+ tmp = open("while_tmp", "r")
+ while tmp.gets()
+ line = $_
+ gsub(/vt100/, 'VT100')
+ if $_ != line
+ $_.gsub!('VT100', 'Vt100')
+ redo
end
- assert(tmp.eof?)
- tmp.close
+ assert_no_match(/vt100/, $_)
+ assert_no_match(/VT100/, $_)
+ end
+ assert(tmp.eof?)
+ tmp.close
- sum=0
- for i in 1..10
- sum += i
- i -= 1
- if i > 0
- redo
- end
+ sum=0
+ for i in 1..10
+ sum += i
+ i -= 1
+ if i > 0
+ redo
end
- assert_equal(220, sum)
+ end
+ assert_equal(220, sum)
- tmp = open(tmpfilename, "r")
- while line = tmp.gets()
- break if 3
- assert_no_match(/vt100/, line)
- assert_no_match(/Amiga/, line)
- assert_no_match(/paper/, line)
- end
- tmp.close
+ tmp = open("while_tmp", "r")
+ while line = tmp.gets()
+ break if 3
+ assert_no_match(/vt100/, line)
+ assert_no_match(/Amiga/, line)
+ assert_no_match(/paper/, line)
+ end
+ tmp.close
- File.unlink tmpfilename or `/bin/rm -f "#{tmpfilename}"`
- assert(!File.exist?(tmpfilename))
- }
+ File.unlink "while_tmp" or `/bin/rm -f "while_tmp"`
+ assert(!File.exist?("while_tmp"))
end
def test_until
diff --git a/test/ruby/test_yield.rb b/test/ruby/test_yield.rb
deleted file mode 100644
index ead0715d4e..0000000000
--- a/test/ruby/test_yield.rb
+++ /dev/null
@@ -1,355 +0,0 @@
-require 'test/unit'
-
-class TestRubyYield < Test::Unit::TestCase
-
- def test_ary_each
- ary = [1]
- ary.each {|a, b, c, d| assert_equal [1,nil,nil,nil], [a,b,c,d] }
- ary.each {|a, b, c| assert_equal [1,nil,nil], [a,b,c] }
- ary.each {|a, b| assert_equal [1,nil], [a,b] }
- ary.each {|a| assert_equal 1, a }
- end
-
- def test_hash_each
- h = {:a => 1}
- h.each do |k, v|
- assert_equal :a, k
- assert_equal 1, v
- end
- h.each do |kv|
- assert_equal [:a, 1], kv
- end
- end
-
- def test_yield_0
- assert_equal 1, iter0 { 1 }
- assert_equal 2, iter0 { 2 }
- end
-
- def iter0
- yield
- end
-
- def test_yield_1
- iter1([]) {|a, b| assert_equal [nil,nil], [a, b] }
- iter1([1]) {|a, b| assert_equal [1,nil], [a, b] }
- iter1([1, 2]) {|a, b| assert_equal [1,2], [a,b] }
- iter1([1, 2, 3]) {|a, b| assert_equal [1,2], [a,b] }
-
- iter1([]) {|a| assert_equal [], a }
- iter1([1]) {|a| assert_equal [1], a }
- iter1([1, 2]) {|a| assert_equal [1,2], a }
- iter1([1, 2, 3]) {|a| assert_equal [1,2,3], a }
- end
-
- def iter1(args)
- yield args
- end
-
- def test_yield2
- def iter2_1() yield 1, *[2, 3] end
- iter2_1 {|a, b, c| assert_equal [1,2,3], [a,b,c] }
- def iter2_2() yield 1, *[] end
- iter2_2 {|a, b, c| assert_equal [1,nil,nil], [a,b,c] }
- def iter2_3() yield 1, *[2] end
- iter2_3 {|a, b, c| assert_equal [1,2,nil], [a,b,c] }
- end
-
- def test_yield_nested
- [[1, [2, 3]]].each {|a, (b, c)|
- assert_equal [1,2,3], [a,b,c]
- }
- [[1, [2, 3]]].map {|a, (b, c)|
- assert_equal [1,2,3], [a,b,c]
- }
- end
-
- def test_with_enum
- obj = Object
- def obj.each
- yield(*[])
- end
- obj.each{|*v| assert_equal([], [], '[ruby-dev:32392]')}
- obj.to_enum.each{|*v| assert_equal([], [], '[ruby-dev:32392]')}
- end
-end
-
-require 'sentence'
-class TestRubyYieldGen < Test::Unit::TestCase
- Syntax = {
- :exp => [["0"],
- ["nil"],
- ["false"],
- ["[]"],
- ["[",:exps,"]"]],
- :exps => [[:exp],
- [:exp,",",:exps]],
- :opt_block_param => [[],
- [:block_param_def]],
- :block_param_def => [['|', '|'],
- ['|', :block_param, '|']],
- :block_param => [[:f_arg, ",", :f_rest_arg, :opt_f_block_arg],
- [:f_arg, ","],
- [:f_arg, ',', :f_rest_arg, ",", :f_arg, :opt_f_block_arg],
- [:f_arg, :opt_f_block_arg],
- [:f_rest_arg, :opt_f_block_arg],
- [:f_rest_arg, ',', :f_arg, :opt_f_block_arg],
- [:f_block_arg]],
- :f_arg => [[:f_arg_item],
- [:f_arg, ',', :f_arg_item]],
- :f_rest_arg => [['*', "var"],
- ['*']],
- :opt_f_block_arg => [[',', :f_block_arg],
- []],
- :f_block_arg => [['&', 'var']],
- :f_arg_item => [[:f_norm_arg],
- ['(', :f_margs, ')']],
- :f_margs => [[:f_marg_list],
- [:f_marg_list, ',', '*', :f_norm_arg],
- [:f_marg_list, ',', '*', :f_norm_arg, ',', :f_marg_list],
- [:f_marg_list, ',', '*'],
- [:f_marg_list, ',', '*', ',', :f_marg_list],
- [ '*', :f_norm_arg],
- [ '*', :f_norm_arg, ',', :f_marg_list],
- [ '*'],
- [ '*', ',', :f_marg_list]],
- :f_marg_list => [[:f_marg],
- [:f_marg_list, ',', :f_marg]],
- :f_marg => [[:f_norm_arg],
- ['(', :f_margs, ')']],
- :f_norm_arg => [['var']],
-
- :command_args => [[:open_args]],
- :open_args => [[' ',:call_args],
- ['(', ')'],
- ['(', :call_args2, ')']],
- :call_args => [[:command],
- [ :args, :opt_block_arg],
- [ :assocs, :opt_block_arg],
- [ :args, ',', :assocs, :opt_block_arg],
- [ :block_arg]],
- :call_args2 => [[:arg, ',', :args, :opt_block_arg],
- [:arg, ',', :block_arg],
- [ :assocs, :opt_block_arg],
- [:arg, ',', :assocs, :opt_block_arg],
- [:arg, ',', :args, ',', :assocs, :opt_block_arg],
- [ :block_arg]],
-
- :command_args_noblock => [[:open_args_noblock]],
- :open_args_noblock => [[' ',:call_args_noblock],
- ['(', ')'],
- ['(', :call_args2_noblock, ')']],
- :call_args_noblock => [[:command],
- [ :args],
- [ :assocs],
- [ :args, ',', :assocs]],
- :call_args2_noblock => [[:arg, ',', :args],
- [ :assocs],
- [:arg, ',', :assocs],
- [:arg, ',', :args, ',', :assocs]],
-
- :command => [],
- :args => [[:arg],
- ["*",:arg],
- [:args,",",:arg],
- [:args,",","*",:arg]],
- :arg => [[:exp]],
- :assocs => [[:assoc],
- [:assocs, ',', :assoc]],
- :assoc => [[:arg, '=>', :arg],
- ['label', ':', :arg]],
- :opt_block_arg => [[',', :block_arg],
- []],
- :block_arg => [['&', :arg]],
- #:test => [['def m() yield', :command_args_noblock, ' end; r = m {', :block_param_def, 'vars', '}; undef m; r']]
- :test_proc => [['def m() yield', :command_args_noblock, ' end; r = m {', :block_param_def, 'vars', '}; undef m; r']],
- :test_lambda => [['def m() yield', :command_args_noblock, ' end; r = m(&lambda {', :block_param_def, 'vars', '}); undef m; r']],
- :test_enum => [['o = Object.new; def o.each() yield', :command_args_noblock, ' end; r1 = r2 = nil; o.each {|*x| r1 = x }; o.to_enum.each {|*x| r2 = x }; [r1, r2]']]
- }
-
- def rename_var(obj)
- vars = []
- r = obj.subst('var') {
- var = "v#{vars.length}"
- vars << var
- var
- }
- return r, vars
- end
-
- def split_by_comma(ary)
- return [] if ary.empty?
- result = [[]]
- ary.each {|e|
- if e == ','
- result << []
- else
- result.last << e
- end
- }
- result
- end
-
- def emu_return_args(*vs)
- vs
- end
-
- def emu_eval_args(args)
- if args.last == []
- args = args[0...-1]
- end
- code = "emu_return_args #{args.map {|a| a.join('') }.join(",")}"
- eval code
- end
-
- def emu_bind_single(arg, param, result_binding)
- #p [:emu_bind_single, arg, param]
- if param.length == 1 && String === param[0] && /\A[a-z0-9]+\z/ =~ param[0]
- result_binding[param[0]] = arg
- elsif param.length == 1 && Array === param[0] && param[0][0] == '(' && param[0][-1] == ')'
- arg = [arg] unless Array === arg
- emu_bind_params(arg, split_by_comma(param[0][1...-1]), false, result_binding)
- else
- raise "unexpected param: #{param.inspect}"
- end
- result_binding
- end
-
- def emu_bind_params(args, params, islambda, result_binding={})
- #p [:emu_bind_params, args, params]
- if params.last == [] # extra comma
- params.pop
- end
-
- star_index = nil
- params.each_with_index {|par, i|
- star_index = i if par[0] == '*'
- }
-
- if islambda
- if star_index
- if args.length < params.length - 1
- throw :emuerror, ArgumentError
- end
- else
- if args.length != params.length
- throw :emuerror, ArgumentError
- end
- end
- end
-
- # TRICK #2 : adjust mismatch on number of arguments
- if star_index
- pre_params = params[0...star_index]
- rest_param = params[star_index]
- post_params = params[(star_index+1)..-1]
- pre_params.each {|par| emu_bind_single(args.shift, par, result_binding) }
- if post_params.length <= args.length
- post_params.reverse_each {|par| emu_bind_single(args.pop, par, result_binding) }
- else
- post_params.each {|par| emu_bind_single(args.shift, par, result_binding) }
- end
- if rest_param != ['*']
- emu_bind_single(args, rest_param[1..-1], result_binding)
- end
- else
- params.each_with_index {|par, i|
- emu_bind_single(args[i], par, result_binding)
- }
- end
-
- #p [args, params, result_binding]
-
- result_binding
- end
-
- def emu_bind(t, islambda)
- #puts
- #p t
- command_args_noblock = t[1]
- block_param_def = t[3]
- command_args_noblock = command_args_noblock.expand {|a| !(a[0] == '[' && a[-1] == ']') }
- block_param_def = block_param_def.expand {|a| !(a[0] == '(' && a[-1] == ')') }
-
- if command_args_noblock.to_a[0] == ' '
- args = command_args_noblock.to_a[1..-1]
- elsif command_args_noblock.to_a[0] == '(' && command_args_noblock.to_a[-1] == ')'
- args = command_args_noblock.to_a[1...-1]
- else
- raise "unexpected command_args_noblock: #{command_args_noblock.inspect}"
- end
- args = emu_eval_args(split_by_comma(args))
-
- params = block_param_def.to_a[1...-1]
- params = split_by_comma(params)
-
- #p [:emu0, args, params]
-
- result_binding = {}
-
- if params.last && params.last[0] == '&'
- result_binding[params.last[1]] = nil
- params.pop
- end
-
- if !islambda
- # TRICK #1 : single array argument is expanded if there are two or more params.
- # * block parameter is not counted.
- # * extra comma after single param forces the expansion.
- if args.length == 1 && Array === args[0] && 1 < params.length
- args = args[0]
- end
- end
-
- emu_bind_params(args, params, islambda, result_binding)
- #p result_binding
- result_binding
- end
-
- def emu(t, vars, islambda)
- catch(:emuerror) {
- emu_binding = emu_bind(t, islambda)
- vars.map {|var| emu_binding.fetch(var, "NOVAL") }
- }
- end
-
- def check_nofork(t, islambda=false)
- t, vars = rename_var(t)
- t = t.subst('vars') { " [#{vars.join(",")}]" }
- emu_values = emu(t, vars, islambda)
- s = t.to_s
- #print "#{s}\t\t"
- #STDOUT.flush
- begin
- eval_values = eval(s)
- rescue ArgumentError
- eval_values = ArgumentError
- end
- #success = emu_values == eval_values ? 'succ' : 'fail'
- #puts "eval:#{vs_ev.inspect[1...-1].delete(' ')}\temu:#{vs_emu.inspect[1...-1].delete(' ')}\t#{success}"
- assert_equal(emu_values, eval_values, s)
- end
-
- def test_yield
- syntax = Sentence.expand_syntax(Syntax)
- Sentence.each(syntax, :test_proc, 4) {|t|
- check_nofork(t)
- }
- end
-
- def test_yield_lambda
- syntax = Sentence.expand_syntax(Syntax)
- Sentence.each(syntax, :test_lambda, 4) {|t|
- check_nofork(t, true)
- }
- end
-
- def test_yield_enum
- syntax = Sentence.expand_syntax(Syntax)
- Sentence.each(syntax, :test_enum, 4) {|t|
- r1, r2 = eval(t.to_s)
- assert_equal(r1, r2, "#{t}")
- }
- end
-
-end
diff --git a/test/ruby/ut_eof.rb b/test/ruby/ut_eof.rb
index b7219ddb51..e6f6eddd6f 100644
--- a/test/ruby/ut_eof.rb
+++ b/test/ruby/ut_eof.rb
@@ -6,8 +6,8 @@ module TestEOF
assert_equal("", f.read(0))
assert_equal("", f.read(0))
assert_equal("", f.read)
- assert_equal("", f.read(0))
- assert_equal("", f.read(0))
+ assert_nil(f.read(0))
+ assert_nil(f.read(0))
}
open_file("") {|f|
assert_nil(f.read(1))
@@ -43,8 +43,8 @@ module TestEOF
assert_equal("" , f.read(0))
assert_equal("" , f.read(0))
assert_equal("", f.read)
- assert_equal("", f.read(0))
- assert_equal("", f.read(0))
+ assert_nil(f.read(0))
+ assert_nil(f.read(0))
}
open_file("a") {|f|
assert_equal("a", f.read(1))
@@ -69,7 +69,7 @@ module TestEOF
}
open_file("a") {|f|
assert_equal("a", f.read)
- assert_equal("", f.read(0))
+ assert_nil(f.read(0))
}
open_file("a") {|f|
s = "x"
@@ -109,7 +109,7 @@ module TestEOF
assert_equal(10, f.pos)
assert_equal("", f.read(0))
assert_equal("", f.read)
- assert_equal("", f.read(0))
+ assert_nil(f.read(0))
assert_equal("", f.read)
}
end
diff --git a/test/rubygems/bogussources.rb b/test/rubygems/bogussources.rb
deleted file mode 100644
index 008e3a1de5..0000000000
--- a/test/rubygems/bogussources.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'rubygems'
-Gem.use_paths("test/mock/gems")
diff --git a/test/rubygems/data/gem-private_key.pem b/test/rubygems/data/gem-private_key.pem
deleted file mode 100644
index 3e4be4cd9a..0000000000
--- a/test/rubygems/data/gem-private_key.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpQIBAAKCAQEAz0tTOtsJuHDKAEXrQx0f6DUEzBEUTSLR1fk0iEHsY9rDCQxm
-sw5Bf2UnVhdD03B4/XzIK+pat2CMQc37/vLIBuVgS7g/fzatGiM0m5rAHtycr0XU
-8Ek6zjx4iSv70OLjybY+/utHCEc838awGDMCFR21jYxgATPVwqAIyasvwbKh/Vhw
-uErFPqT9G8BKTHsaX+H+ADIRH001OmWkjB6EyjF05114kNMa0+2C7daV9hoBL3md
-hCt6zOGcapl/9LkGxhcNEUB/So16V1ZQldg9macGyWktyNTSfctlF+f8okAmicG3
-XIwaW8UTmjFCmvDs/h1R/uKpe2IOHz87n29d2QIDAQABAoIBAQCR6n/nyg+JmTtX
-/d+hGns/RTLfQpZ7xarXZ9gmoeD4WSE42VXhbIOGXXnXDAFecKl6Jb/xycGZm4if
-OZPM3rEWyZeDNWrc7WvkHiwF7GSYVMqmRg2iJqoSSla+mAtl+pBFiNfHMW6K0Tp0
-erOyFRW+L2+A9/MMZaRun6AP9URkn0jz2kwmMFf+6szmzVn6fPFzZDRI+hEeaDmi
-LBzSrfrddrIBX+xGEoBj6RmfnKBCSUVSSxOauYjd4mVjVYxvMH4SV1hXDUS5GPl5
-MbCiBb7bpNIg/8ljMoRrQiqk0XwwS7MaCqPtMhUtpSmC/zSjAfmoN7AOc/Xh69cQ
-OCMNZH9BAoGBAPBlsuuU6fg0gVTKDdR12jHx03uRRt8/nPxHnpJkZCIh9XKh1LtY
-bkumi9HZpp3mzDiaGg/rwfCwNckKx8NLhICLgkric6ClrKftxTu6C8tBAb5YDi6u
-74KYnV8lMY/unzBtIloPgM3uluS292POmrWZpKwhvHLD71MewzMor5HFAoGBANy/
-mwsBs8i3Gzk8Twjq8effhPpE7kpxhC7bhwmjX3q41EjQWDT8M6xb1P9dRSsCIebi
-kqP1yhl27dJpA8r5WqE/z89xhBvObAGRv41eXxOI0LaH2k5lJQrUeSC+51dy+BEB
-T3GXD4C5ezZHQ8Wz/oL73uikrfhD+AqOZT2YbMEFAoGBAJvWEWpOGm3f+4bvhI+Z
-5lxCG4oa3wqRvj58XvsfQRovUWGCLtlTtgwsZq8enLf3iaOXohV4Czzvva4Z4u1i
-4v5BcbEBo1scixRBOn5BWKvl9C9j/a2dkX3jWQD4p2xaj69gz8f6DNFyPTb+tNhq
-cjgO5YUASZ1MDrSfWIKteULRAoGAZkZv8x2KyofrmQ0UITGZerDYz4t4TA1kDMGx
-QwnqhtVzpXjCJWpkFotFmDsCfPaz9mErR8PtKvcrIL1/AF+fWe5Sve3+I1P0PpXk
-hf8fVdGhwbAXuRKrouTmagGI9b9Sp65PvHUcvasyJufFwqeuV8mScX87CzeSiHGI
-/ozMdnECgYEAq4+losrhe0DEmiC9zVPvwRXjbSixDsSJxHfOcqIsZqhUgBiZ4TJD
-SrkuukrMZib6BAD+PtCJS1TBbJyyvL3QecizhHSIh3ZnT0HnaRPatLEYmU65+3kE
-kTqL4ik92bJnnWowy677sydl1lzBJDVa9ZlTs7BFSd8y/0DZaUxGg2I=
------END RSA PRIVATE KEY-----
diff --git a/test/rubygems/data/gem-public_cert.pem b/test/rubygems/data/gem-public_cert.pem
deleted file mode 100644
index 885bf7f369..0000000000
--- a/test/rubygems/data/gem-public_cert.pem
+++ /dev/null
@@ -1,20 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMREwDwYDVQQDDAhydWJ5
-Z2VtczEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUxEzARBgoJkiaJk/IsZAEZFgNj
-b20wHhcNMDcwODAyMDMyNTQyWhcNMDgwODAxMDMyNTQyWjBBMREwDwYDVQQDDAhy
-dWJ5Z2VtczEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUxEzARBgoJkiaJk/IsZAEZ
-FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPS1M62wm4cMoA
-RetDHR/oNQTMERRNItHV+TSIQexj2sMJDGazDkF/ZSdWF0PTcHj9fMgr6lq3YIxB
-zfv+8sgG5WBLuD9/Nq0aIzSbmsAe3JyvRdTwSTrOPHiJK/vQ4uPJtj7+60cIRzzf
-xrAYMwIVHbWNjGABM9XCoAjJqy/BsqH9WHC4SsU+pP0bwEpMexpf4f4AMhEfTTU6
-ZaSMHoTKMXTnXXiQ0xrT7YLt1pX2GgEveZ2EK3rM4ZxqmX/0uQbGFw0RQH9KjXpX
-VlCV2D2ZpwbJaS3I1NJ9y2UX5/yiQCaJwbdcjBpbxROaMUKa8Oz+HVH+4ql7Yg4f
-Pzufb13ZAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
-BBRYTAoj4cn8CWZMHFnHGQgoO5jyFTANBgkqhkiG9w0BAQUFAAOCAQEATRrJC05l
-dOmx67Sy3bU+AVXkOr7B9nn2Myqo9uSIAncPoElN6aHr/Q8wOOjtok4r0JcHPe1e
-eotDCZUE1Jkl13Tpv26rOfOOUHtGlyAIAtpsUGOraaJkSut4WKLr1/KckyAAEtgP
-c13A0s0mEiWFRuYxIdEi54561pTT2qQBE/DUPGoYD5rUg9XYAlSovMMwG99Oca7L
-cI6vCymr1bzzddExoywBNOy0fbBT62I3ICBGbH5yOVVKVmlxeo2Zp10FCj0kDrnq
-OuMJSDr5I2XPYqoC+W4YSbwn55o2jGIUX1lOq2Hvj4tFgSxlnJZn0tUhBfR3gSOn
-IFnrqu8PlZsLFw==
------END CERTIFICATE-----
diff --git a/test/rubygems/fake_certlib/openssl.rb b/test/rubygems/fake_certlib/openssl.rb
deleted file mode 100644
index 948110f078..0000000000
--- a/test/rubygems/fake_certlib/openssl.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-fail LoadError, "no such file to load -- openssl"
diff --git a/test/rubygems/functional.rb b/test/rubygems/functional.rb
deleted file mode 100644
index 4838167324..0000000000
--- a/test/rubygems/functional.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require 'rubygems'
-require 'test/insure_session'
-require 'rubygems/format'
-require 'rubygems/command_manager'
-
-class FunctionalTest < Test::Unit::TestCase
- def setup
- @gem_path = File.expand_path("bin/gem")
- lib_path = File.expand_path("lib")
- @ruby_options = "-I#{lib_path} -I."
- @verbose = false
- end
-
- def test_gem_help_options
- gem_nossl 'help options'
- assert_match(/Usage:/, @out, @err)
- assert_status
- end
-
- def test_gem_help_commands
- gem_nossl 'help commands'
- assert_match(/gem install/, @out)
- assert_status
- end
-
- def test_gem_no_args_shows_help
- gem_nossl
- assert_match(/Usage:/, @out)
- assert_status 1
- end
-
- # This test is disabled because of the insanely long time it takes
- # to time out.
- def xtest_bogus_source_hoses_up_remote_install_but_gem_command_gives_decent_error_message
- @ruby_options << " -rtest/bogussources"
- gem_nossl "install asdf --remote"
- assert_match(/error/im, @err)
- assert_status 1
- end
-
- def test_all_command_helps
- mgr = Gem::CommandManager.new
- mgr.command_names.each do |cmdname|
- gem_nossl "help #{cmdname}"
- assert_match(/Usage: gem #{cmdname}/, @out,
- "should see help for #{cmdname}")
- end
- end
-
- # :section: Help Methods
-
- # Run a gem command without the SSL library.
- def gem_nossl(options="")
- old_options = @ruby_options.dup
- @ruby_options << " -Itest/fake_certlib"
- gem(options)
- ensure
- @ruby_options = old_options
- end
-
- # Run a gem command with the SSL library.
- def gem_withssl(options="")
- gem(options)
- end
-
- # Run a gem command for the functional test.
- def gem(options="")
- shell = Session::Shell.new
- options = options + " --config-file missing_file" if options !~ /--config-file/
- command = "#{Gem.ruby} #{@ruby_options} #{@gem_path} #{options}"
- puts "\n\nCOMMAND: [#{command}]" if @verbose
- @out, @err = shell.execute command
- @status = shell.exit_status
- puts "STATUS: [#{@status}]" if @verbose
- puts "OUTPUT: [#{@out}]" if @verbose
- puts "ERROR: [#{@err}]" if @verbose
- puts "PWD: [#{Dir.pwd}]" if @verbose
- shell.close
- end
-
- private
-
- def assert_status(expected_status=0)
- assert_equal expected_status, @status
- end
-
-end
diff --git a/test/rubygems/gemutilities.rb b/test/rubygems/gemutilities.rb
deleted file mode 100644
index fb41210ac8..0000000000
--- a/test/rubygems/gemutilities.rb
+++ /dev/null
@@ -1,315 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-at_exit { $SAFE = 1 }
-
-require 'fileutils'
-require 'test/unit'
-require 'tmpdir'
-require 'uri'
-require 'rubygems/gem_open_uri'
-require 'rubygems/source_info_cache'
-
-require File.join(File.expand_path(File.dirname(__FILE__)), 'mockgemui')
-
-module Gem
- def self.source_index=(si)
- @@source_index = si
- end
-
- def self.win_platform=(val)
- @@win_platform = val
- end
-end
-
-class FakeFetcher
-
- attr_reader :data
- attr_accessor :uri
- attr_accessor :paths
-
- def initialize
- @data = {}
- @paths = []
- @uri = nil
- end
-
- def fetch_path(path)
- path = path.to_s
- @paths << path
- raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
- data = @data[path]
- raise Gem::RemoteFetcher::FetchError, "no data for #{path}" if data.nil?
- data.respond_to?(:call) ? data.call : data
- end
-
- def fetch_size(path)
- path = path.to_s
- @paths << path
- raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
- data = @data[path]
- raise Gem::RemoteFetcher::FetchError, "no data for #{path}" if data.nil?
- data.respond_to?(:call) ? data.call : data.length
- end
-
-end
-
-class RubyGemTestCase < Test::Unit::TestCase
-
- include Gem::DefaultUserInteraction
-
- undef_method :default_test if instance_methods.include? 'default_test' or
- instance_methods.include? :default_test
-
- def setup
- super
-
- @ui = MockGemUi.new
- tmpdir = nil
- Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
- @tempdir = File.join tmpdir, "test_rubygems_#{$$}"
- @tempdir.untaint
- @gemhome = File.join @tempdir, "gemhome"
- @gemcache = File.join(@gemhome, "source_cache")
- @usrcache = File.join(@gemhome, ".gem", "user_cache")
-
- FileUtils.mkdir_p @gemhome
-
- ENV['GEMCACHE'] = @usrcache
- Gem.use_paths(@gemhome)
- Gem.loaded_specs.clear
-
- Gem.configuration.verbose = true
- Gem.configuration.update_sources = true
-
- @gem_repo = "http://gems.example.com"
- Gem.sources.replace [@gem_repo]
-
- @orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
- Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:RUBY_INSTALL_NAME]
-
- @orig_arch = Gem::ConfigMap[:arch]
-
- if win_platform?
- util_set_arch 'i386-mswin32'
- else
- util_set_arch 'i686-darwin8.10.1'
- end
-
- @marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
- end
-
- def teardown
- Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY
- Gem::ConfigMap[:arch] = @orig_arch
-
- if defined? Gem::RemoteFetcher then
- Gem::RemoteFetcher.instance_variable_set :@fetcher, nil
- end
-
- FileUtils.rm_rf @tempdir
-
- ENV.delete 'GEMCACHE'
- ENV.delete 'GEM_HOME'
- ENV.delete 'GEM_PATH'
-
- Gem.clear_paths
- Gem::SourceInfoCache.instance_variable_set :@cache, nil
- end
-
- def install_gem gem
- require 'rubygems/installer'
-
- use_ui MockGemUi.new do
- Dir.chdir @tempdir do
- Gem::Builder.new(gem).build
- end
- end
-
- gem = File.join(@tempdir, "#{gem.full_name}.gem").untaint
- Gem::Installer.new(gem).install
- end
-
- def prep_cache_files(lc)
- [ [lc.system_cache_file, 'sys'],
- [lc.user_cache_file, 'usr'],
- ].each do |fn, data|
- FileUtils.mkdir_p File.dirname(fn).untaint
- open(fn.dup.untaint, "wb") { |f| f.write(Marshal.dump({'key' => data})) }
- end
- end
-
- def read_cache(fn)
- open(fn.dup.untaint) { |f| Marshal.load f.read }
- end
-
- def write_file(path)
- path = File.join(@gemhome, path)
- dir = File.dirname path
- FileUtils.mkdir_p dir
- File.open(path, "w") { |io|
- yield(io)
- }
- path
- end
-
- def quick_gem(gemname, version='2')
- require 'rubygems/specification'
-
- spec = Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = gemname
- s.version = version
- s.author = 'A User'
- s.email = 'example@example.com'
- s.homepage = 'http://example.com'
- s.has_rdoc = true
- s.summary = "this is a summary"
- s.description = "This is a test description"
-
- yield(s) if block_given?
- end
-
- path = File.join "specifications", "#{spec.full_name}.gemspec"
- written_path = write_file path do |io|
- io.write(spec.to_ruby)
- end
-
- spec.loaded_from = written_path
-
- return spec
- end
-
- def util_build_gem(spec)
- dir = File.join(@gemhome, 'gems', spec.full_name)
- FileUtils.mkdir_p dir
-
- Dir.chdir dir do
- spec.files.each do |file|
- next if File.exist? file
- FileUtils.mkdir_p File.dirname(file)
- File.open file, 'w' do |fp| fp.puts "# #{file}" end
- end
-
- use_ui MockGemUi.new do
- Gem::Builder.new(spec).build
- end
-
- FileUtils.mv "#{spec.full_name}.gem",
- File.join(@gemhome, 'cache', "#{spec.original_name}.gem")
- end
- end
-
- def util_make_gems
- init = proc do |s|
- s.files = %w[lib/code.rb]
- s.require_paths = %w[lib]
- end
-
- @a1 = quick_gem('a', '1', &init)
- @a2 = quick_gem('a', '2', &init)
- @b2 = quick_gem('b', '2', &init)
- @c1_2 = quick_gem('c', '1.2', &init)
- @pl1 = quick_gem 'pl', '1' do |s| # l for legacy
- s.files = %w[lib/code.rb]
- s.require_paths = %w[lib]
- s.platform = Gem::Platform.new 'i386-linux'
- s.instance_variable_set :@original_platform, 'i386-linux'
- end
-
- write_file File.join(*%W[gems #{@a1.original_name} lib code.rb]) do end
- write_file File.join(*%W[gems #{@a2.original_name} lib code.rb]) do end
- write_file File.join(*%W[gems #{@b2.original_name} lib code.rb]) do end
- write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb]) do end
- write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb]) do end
-
- [@a1, @a2, @b2, @c1_2, @pl1].each { |spec| util_build_gem spec }
-
- FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
-
- Gem.source_index = nil
- end
-
- ##
- # Set the platform to +cpu+ and +os+
-
- def util_set_arch(arch)
- Gem::ConfigMap[:arch] = arch
- platform = Gem::Platform.new arch
-
- Gem.instance_variable_set :@platforms, nil
- Gem::Platform.instance_variable_set :@local, nil
-
- platform
- end
-
- def util_setup_fake_fetcher
- require 'zlib'
- require 'socket'
- require 'rubygems/remote_fetcher'
-
- @uri = URI.parse @gem_repo
- @fetcher = FakeFetcher.new
- @fetcher.uri = @uri
-
- @gem1 = quick_gem 'gem_one' do |gem|
- gem.files = %w[Rakefile lib/gem_one.rb]
- end
-
- @gem2 = quick_gem 'gem_two' do |gem|
- gem.files = %w[Rakefile lib/gem_two.rb]
- end
-
- @gem3 = quick_gem 'gem_three' do |gem| # missing gem
- gem.files = %w[Rakefile lib/gem_three.rb]
- end
-
- # this gem has a higher version and longer name than the gem we want
- @gem4 = quick_gem 'gem_one_evil', '666' do |gem|
- gem.files = %w[Rakefile lib/gem_one.rb]
- end
-
- @all_gems = [@gem1, @gem2, @gem3, @gem4].sort
- @all_gem_names = @all_gems.map { |gem| gem.full_name }
-
- gem_names = [@gem1.full_name, @gem2.full_name, @gem4.full_name]
- @gem_names = gem_names.sort.join("\n")
-
- @source_index = Gem::SourceIndex.new @gem1.full_name => @gem1,
- @gem2.full_name => @gem2,
- @gem4.full_name => @gem4
-
- Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
- end
-
- def util_setup_source_info_cache(*specs)
- require 'rubygems/source_info_cache_entry'
-
- specs = Hash[*specs.map { |spec| [spec.full_name, spec] }.flatten]
- si = Gem::SourceIndex.new specs
-
- sice = Gem::SourceInfoCacheEntry.new si, 0
- sic = Gem::SourceInfoCache.new
- sic.set_cache_data( { @gem_repo => sice } )
- Gem::SourceInfoCache.instance_variable_set :@cache, sic
- si
- end
-
- def util_zip(data)
- Zlib::Deflate.deflate data
- end
-
- def self.win_platform?
- Gem.win_platform?
- end
-
- def win_platform?
- Gem.win_platform?
- end
-
-end
-
diff --git a/test/rubygems/insure_session.rb b/test/rubygems/insure_session.rb
deleted file mode 100644
index e56f9abcb8..0000000000
--- a/test/rubygems/insure_session.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-
-require 'rubygems'
-
-def install_session
- path_to_gem = File.join("redist", "session.gem")
- begin
- Gem::Installer.new(path_to_gem).install
- rescue Errno::EACCES => ex
- puts
- puts "*****************************************************************"
- puts "Unable to install Gem 'Session'."
- puts "Reason: #{ex.message}"
- puts "Try running:"
- puts
- puts " gem -Li #{path_to_gem}"
- puts
- puts "with the appropriate admin privileges."
- puts "*****************************************************************"
- puts
- exit
- end
- gem 'session'
-end
-
-begin
- require 'session'
-rescue LoadError => e
- puts
- puts "Required Gem 'Session' missing."
- puts "We can attempt to install from the RubyGems Distribution,"
- puts "but installation may require admin privileges on your system."
- puts
- print "Install now from RubyGems distribution? [Yn]"
- answer = gets
- if(answer =~ /^y/i || answer =~ /^[^a-zA-Z0-9]$/) then
- install_session
- puts
- puts "Retry running the functional tests."
- exit(0)
- else
- puts "Test cancelled...quitting"
- exit(1)
- end
-end
diff --git a/test/rubygems/mockgemui.rb b/test/rubygems/mockgemui.rb
deleted file mode 100644
index d9bc2a8134..0000000000
--- a/test/rubygems/mockgemui.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-
-require 'stringio'
-require 'rubygems/user_interaction'
-
-class MockGemUi < Gem::StreamUI
- class TermError < RuntimeError; end
-
- def initialize(input="")
- super(StringIO.new(input), StringIO.new, StringIO.new)
- @terminated = false
- @banged = false
- end
-
- def input
- @ins.string
- end
-
- def output
- @outs.string
- end
-
- def error
- @errs.string
- end
-
- def banged?
- @banged
- end
-
- def terminated?
- @terminated
- end
-
- def terminate_interaction!(status=1)
- @terminated = true
- @banged = true
- fail TermError
- end
-
- def terminate_interaction(status=0)
- @terminated = true
- fail TermError
- end
-end
diff --git a/test/rubygems/simple_gem.rb b/test/rubygems/simple_gem.rb
deleted file mode 100644
index a6f14bc3c7..0000000000
--- a/test/rubygems/simple_gem.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
- SIMPLE_GEM = <<-GEMDATA
- MD5SUM = "e3701f9db765a2358aef94c40ded71c8"
- if $0 == __FILE__
- require 'optparse'
-
- options = {}
- ARGV.options do |opts|
- opts.on_tail("--help", "show this message") {puts opts; exit}
- opts.on('--dir=DIRNAME', "Installation directory for the Gem") {|options[:directory]|}
- opts.on('--force', "Force Gem to intall, bypassing dependency checks") {|options[:force]|}
- opts.on('--gen-rdoc', "Generate RDoc documentation for the Gem") {|options[:gen_rdoc]|}
- opts.parse!
- end
-
- require 'rubygems'
- @directory = options[:directory] || Gem.dir
- @force = options[:force]
-
- gem = Gem::Installer.new(__FILE__).install(@force, @directory)
- if options[:gen_rdoc]
- Gem::DocManager.new(gem).generate_rdoc
- end
-end
-
-__END__
---- !ruby/object:Gem::Specification
-rubygems_version: "1.0"
-name: testing
-version: !ruby/object:Gem::Version
- version: 1.2.3
-date: 2004-03-18 22:01:52.859121 -05:00
-platform:
-summary: This exercise the gem testing stuff.
-require_paths:
- - lib
-files:
- - lib/foo.rb
- - lib/test
- - lib/test.rb
- - lib/test/wow.rb
-autorequire: test
-test_suite_file: foo
-requirements:
- - a computer processor
----
--
- size: 109
- mode: 420
- path: lib/foo.rb
--
- size: 0
- mode: 420
- path: lib/test.rb
--
- size: 15
- mode: 420
- path: lib/test/wow.rb
----
-eJwVjDEKgDAUQ/eeIpsKguhY3ARPoHMp9quF0mL7e39/h5DwQpLpqz4TOqbC
-U42eO6WuYEvBntIhECuaaX1KqXXLmy2kAEc32szExK+PjyBAlpTZyK0N/Twu
-g1CKTjX9BGAj1w==
----
-eJwDAAAAAAE=
----
-eJwrKC0pVlAvzy9XyE3MU+cCACwiBP4=
- GEMDATA
diff --git a/test/rubygems/test_config.rb b/test/rubygems/test_config.rb
deleted file mode 100644
index 89ac0e4462..0000000000
--- a/test/rubygems/test_config.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rbconfig'
-require 'rubygems'
-
-class TestConfig < RubyGemTestCase
-
- def test_gem_original_datadir
- datadir = Config::CONFIG['datadir']
- assert_equal "#{datadir}/xyz", Config.gem_original_datadir('xyz')
- end
-
- def test_datadir
- datadir = Config::CONFIG['datadir']
- assert_equal "#{datadir}/xyz", Config.datadir('xyz')
- end
-
-end
-
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
deleted file mode 100644
index 41b127ce39..0000000000
--- a/test/rubygems/test_gem.rb
+++ /dev/null
@@ -1,348 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems'
-require 'rubygems/gem_openssl'
-require 'rubygems/installer'
-require 'pathname'
-
-class TestGem < RubyGemTestCase
-
- def setup
- super
-
- @additional = %w[a b].map { |d| File.join @tempdir, d }
- @default_dir_re = %r|/[Rr]uby/[Gg]ems/[0-9.]+|
- end
-
- def test_self_all_load_paths
- util_make_gems
-
- expected = [
- File.join(@gemhome, *%W[gems #{@a1.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@a2.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@b2.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
- ]
-
- assert_equal expected, Gem.all_load_paths.sort
- end
-
- def test_self_bindir
- assert_equal File.join(@gemhome, 'bin'), Gem.bindir
- assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Gem.dir)
- assert_equal File.join(@gemhome, 'bin'), Gem.bindir(Pathname.new(Gem.dir))
- end
-
- def test_self_bindir_default_dir
- default = Gem.default_dir
- bindir = (defined? RUBY_FRAMEWORK_VERSION) ? '/usr/bin' : Config::CONFIG['bindir']
- assert_equal bindir, Gem.bindir(default)
- assert_equal bindir, Gem.bindir(Pathname.new(default))
- end
-
- def test_self_clear_paths
- Gem.dir
- Gem.path
- searcher = Gem.searcher
- source_index = Gem.source_index
-
- Gem.clear_paths
-
- assert_equal nil, Gem.instance_variable_get(:@gem_home)
- assert_equal nil, Gem.instance_variable_get(:@gem_path)
- assert_not_equal searcher, Gem.searcher
- assert_not_equal source_index.object_id, Gem.source_index.object_id
- end
-
- def test_self_configuration
- expected = Gem::ConfigFile.new []
- Gem.configuration = nil
-
- assert_equal expected, Gem.configuration
- end
-
- def test_self_datadir
- foo = nil
-
- Dir.chdir @tempdir do
- FileUtils.mkdir_p 'data'
- File.open File.join('data', 'foo.txt'), 'w' do |fp|
- fp.puts 'blah'
- end
-
- foo = quick_gem 'foo' do |s| s.files = %w[data/foo.txt] end
- install_gem foo
- end
-
- gem 'foo'
-
- expected = File.join @gemhome, 'gems', foo.full_name, 'data', 'foo'
-
- assert_equal expected, Gem.datadir('foo')
- end
-
- def test_self_datadir_nonexistent_package
- assert_nil Gem.datadir('xyzzy')
- end
-
- def test_self_default_dir
- assert_match @default_dir_re, Gem.default_dir
- end
-
- def test_self_default_exec_format
- orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
- orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:RUBY_INSTALL_NAME]
- Gem::ConfigMap[:BASERUBY] = 'ruby'
- Gem::ConfigMap[:RUBY_INSTALL_NAME] = 'ruby'
-
- assert_equal '%s', Gem.default_exec_format
- ensure
- Gem::ConfigMap[:BASERUBY] = orig_BASERUBY
- Gem::ConfigMap[:RUBY_INSTALL_NAME] = orig_RUBY_INSTALL_NAME
- end
-
- def test_self_default_exec_format_18
- orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
- orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:RUBY_INSTALL_NAME]
- Gem::ConfigMap[:BASERUBY] = 'ruby'
- Gem::ConfigMap[:RUBY_INSTALL_NAME] = 'ruby18'
-
- assert_equal '%s18', Gem.default_exec_format
- ensure
- Gem::ConfigMap[:BASERUBY] = orig_BASERUBY
- Gem::ConfigMap[:RUBY_INSTALL_NAME] = orig_RUBY_INSTALL_NAME
- end
-
- def test_self_default_exec_format_jruby
- orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
- orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:RUBY_INSTALL_NAME]
- Gem::ConfigMap[:BASERUBY] = 'ruby'
- Gem::ConfigMap[:RUBY_INSTALL_NAME] = 'jruby'
-
- assert_equal 'j%s', Gem.default_exec_format
- ensure
- Gem::ConfigMap[:BASERUBY] = orig_BASERUBY
- Gem::ConfigMap[:RUBY_INSTALL_NAME] = orig_RUBY_INSTALL_NAME
- end
-
- def test_self_default_sources
- assert_equal %w[http://gems.rubyforge.org], Gem.default_sources
- end
-
- def test_self_dir
- assert_equal @gemhome, Gem.dir
-
- Gem::DIRECTORIES.each do |filename|
- assert File.directory?(File.join(Gem.dir, filename)),
- "expected #{filename} to exist"
- end
- end
-
- def test_self_ensure_gem_directories
- FileUtils.rm_r @gemhome
- Gem.use_paths @gemhome
-
- Gem.ensure_gem_subdirectories @gemhome
-
- assert File.directory?(File.join(@gemhome, "cache"))
- end
-
- def test_self_ensure_gem_directories_missing_parents
- gemdir = File.join @tempdir, 'a/b/c/gemdir'
- FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil
- assert !File.exist?(File.join(@tempdir, 'a')),
- "manually remove #{File.join @tempdir, 'a'}, tests are broken"
- Gem.use_paths gemdir
-
- Gem.ensure_gem_subdirectories gemdir
-
- assert File.directory?("#{gemdir}/cache")
- end
-
- unless win_platform? then # only for FS that support write protection
- def test_self_ensure_gem_directories_write_protected
- gemdir = File.join @tempdir, "egd"
- FileUtils.rm_r gemdir rescue nil
- assert !File.exist?(gemdir), "manually remove #{gemdir}, tests are broken"
- FileUtils.mkdir_p gemdir
- FileUtils.chmod 0400, gemdir
- Gem.use_paths gemdir
-
- Gem.ensure_gem_subdirectories gemdir
-
- assert !File.exist?("#{gemdir}/cache")
- ensure
- FileUtils.chmod 0600, gemdir
- end
-
- def test_self_ensure_gem_directories_write_protected_parents
- parent = File.join(@tempdir, "egd")
- gemdir = "#{parent}/a/b/c"
-
- FileUtils.rm_r parent rescue nil
- assert !File.exist?(parent), "manually remove #{parent}, tests are broken"
- FileUtils.mkdir_p parent
- FileUtils.chmod 0400, parent
- Gem.use_paths(gemdir)
-
- Gem.ensure_gem_subdirectories gemdir
-
- assert !File.exist?("#{gemdir}/cache")
- ensure
- FileUtils.chmod 0600, parent
- end
- end
-
- def test_ensure_ssl_available
- orig_Gem_ssl_available = Gem.ssl_available?
-
- Gem.ssl_available = true
- assert_nothing_raised do Gem.ensure_ssl_available end
-
- Gem.ssl_available = false
- e = assert_raise Gem::Exception do Gem.ensure_ssl_available end
- assert_equal 'SSL is not installed on this system', e.message
- ensure
- Gem.ssl_available = orig_Gem_ssl_available
- end
-
- def test_self_latest_load_paths
- util_make_gems
-
- expected = [
- File.join(@gemhome, *%W[gems #{@a2.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@b2.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
- File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
- ]
-
- assert_equal expected, Gem.latest_load_paths.sort
- end
-
- def test_self_loaded_specs
- foo = quick_gem 'foo'
- install_gem foo
- Gem.source_index = nil
-
- Gem.activate 'foo', false
-
- assert_equal true, Gem.loaded_specs.keys.include?('foo')
- end
-
- def test_self_path
- assert_equal [Gem.dir], Gem.path
- end
-
- def test_self_path_ENV_PATH
- Gem.clear_paths
- path_count = Gem.path.size
- Gem.clear_paths
- util_ensure_gem_dirs
-
- ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
-
- assert_equal @additional, Gem.path[0,2]
- assert_equal path_count + @additional.size, Gem.path.size
- assert_match Gem.dir, Gem.path.last
- end
-
- def test_self_path_duplicate
- Gem.clear_paths
- util_ensure_gem_dirs
- dirs = @additional + [@gemhome] + [File.join(@tempdir, 'a')]
-
- ENV['GEM_HOME'] = @gemhome
- ENV['GEM_PATH'] = dirs.join File::PATH_SEPARATOR
-
- assert_equal @gemhome, Gem.dir
- paths = [Gem.dir]
- paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
- assert_equal @additional + paths, Gem.path
- end
-
- def test_self_path_overlap
- Gem.clear_paths
-
- util_ensure_gem_dirs
- ENV['GEM_HOME'] = @gemhome
- ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
-
- assert_equal @gemhome, Gem.dir
- paths = [Gem.dir]
- paths.insert(0, APPLE_GEM_HOME) if defined? APPLE_GEM_HOME
- assert_equal @additional + paths, Gem.path
- end
-
- def test_self_platforms
- assert_equal [Gem::Platform::RUBY, Gem::Platform.local], Gem.platforms
- end
-
- def test_self_prefix
- file_name = File.expand_path __FILE__
- expected = File.dirname File.dirname(file_name)
- expected = File.dirname expected if expected =~ %r|/test| # for Ruby trunk
- assert_equal expected, Gem.prefix
- end
-
- def test_self_required_location
- util_make_gems
-
- assert_equal File.join(@tempdir, *%w[gemhome gems c-1.2 lib code.rb]),
- Gem.required_location("c", "code.rb")
- assert_equal File.join(@tempdir, *%w[gemhome gems a-1 lib code.rb]),
- Gem.required_location("a", "code.rb", "< 2")
- assert_equal File.join(@tempdir, *%w[gemhome gems a-2 lib code.rb]),
- Gem.required_location("a", "code.rb", "= 2")
- end
-
- def test_self_searcher
- assert_kind_of Gem::GemPathSearcher, Gem.searcher
- end
-
- def test_self_source_index
- assert_kind_of Gem::SourceIndex, Gem.source_index
- end
-
- def test_self_sources
- assert_equal %w[http://gems.example.com], Gem.sources
- end
-
- def test_ssl_available_eh
- orig_Gem_ssl_available = Gem.ssl_available?
-
- Gem.ssl_available = true
- assert_equal true, Gem.ssl_available?
-
- Gem.ssl_available = false
- assert_equal false, Gem.ssl_available?
- ensure
- Gem.ssl_available = orig_Gem_ssl_available
- end
-
- def test_self_use_paths
- util_ensure_gem_dirs
-
- Gem.use_paths @gemhome, @additional
-
- assert_equal @gemhome, Gem.dir
- assert_equal @additional + [Gem.dir], Gem.path
- end
-
- def test_self_user_home
- if ENV['HOME'] then
- assert_equal ENV['HOME'], Gem.user_home
- else
- assert true, 'count this test'
- end
- end
-
- def util_ensure_gem_dirs
- Gem.ensure_gem_subdirectories @gemhome
- @additional.each do |dir|
- Gem.ensure_gem_subdirectories @gemhome
- end
- end
-
-end
-
diff --git a/test/rubygems/test_gem_builder.rb b/test/rubygems/test_gem_builder.rb
deleted file mode 100644
index 31a0d71880..0000000000
--- a/test/rubygems/test_gem_builder.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/builder'
-
-class TestGemBuilder < RubyGemTestCase
-
- def test_build
- builder = Gem::Builder.new quick_gem('a')
-
- use_ui @ui do
- Dir.chdir @tempdir do
- builder.build
- end
- end
-
- assert_match %r|Successfully built RubyGem\n Name: a|, @ui.output
- end
-
- def test_build_validates
- builder = Gem::Builder.new Gem::Specification.new
-
- assert_raises Gem::InvalidSpecificationException do
- builder.build
- end
- end
-
-end
-
diff --git a/test/rubygems/test_gem_command.rb b/test/rubygems/test_gem_command.rb
deleted file mode 100644
index 9ed57b3692..0000000000
--- a/test/rubygems/test_gem_command.rb
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/command'
-
-class Gem::Command
- public :parser
-end
-
-class TestGemCommand < RubyGemTestCase
-
- def setup
- super
-
- @xopt = nil
-
- Gem::Command.common_options.clear
- Gem::Command.common_options << [
- ['-x', '--exe', 'Execute'], lambda do |*a|
- @xopt = true
- end
- ]
-
- @cmd_name = 'doit'
- @cmd = Gem::Command.new @cmd_name, 'summary'
- end
-
- def test_self_add_specific_extra_args
- added_args = %w[--all]
- @cmd.add_option '--all' do |v,o| end
-
- Gem::Command.add_specific_extra_args @cmd_name, added_args
-
- assert_equal added_args, Gem::Command.specific_extra_args(@cmd_name)
-
- h = @cmd.add_extra_args []
-
- assert_equal added_args, h
- end
-
- def test_self_add_specific_extra_args_unknown
- added_args = %w[--definitely_not_there]
-
- Gem::Command.add_specific_extra_args @cmd_name, added_args
-
- assert_equal added_args, Gem::Command.specific_extra_args(@cmd_name)
-
- h = @cmd.add_extra_args []
-
- assert_equal [], h
- end
-
- def test_add_option_overlapping_common_and_local_options
- @cmd.add_option('-x', '--zip', 'BAD!') do end
- @cmd.add_option('-z', '--exe', 'BAD!') do end
- @cmd.add_option('-x', '--exe', 'BAD!') do end
-
- assert_match %r|-x, --zip|, @cmd.parser.to_s
- assert_match %r|-z, --exe|, @cmd.parser.to_s
- assert_no_match %r|-x, --exe|, @cmd.parser.to_s
- end
-
- def test_basic_accessors
- assert_equal "doit", @cmd.command
- assert_equal "gem doit", @cmd.program_name
- assert_equal "summary", @cmd.summary
- end
-
- def test_common_option_in_class
- assert Array === Gem::Command.common_options
- end
-
- def test_defaults
- @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
- options[:help] = value
- end
-
- @cmd.defaults = { :help => true }
-
- @cmd.when_invoked do |options|
- assert options[:help], "Help options should default true"
- end
-
- use_ui @ui do
- @cmd.invoke
- end
-
- assert_match %r|Usage: gem doit|, @ui.output
- end
-
- def test_invoke
- done = false
- @cmd.when_invoked { done = true }
-
- use_ui @ui do
- @cmd.invoke
- end
-
- assert done
- end
-
- def test_invode_with_bad_options
- use_ui @ui do
- @cmd.when_invoked do true end
-
- ex = assert_raise(OptionParser::InvalidOption) do
- @cmd.invoke('-zzz')
- end
-
- assert_match(/invalid option:/, ex.message)
- end
- end
-
- def test_invoke_with_common_options
- @cmd.when_invoked do true end
-
- use_ui @ui do
- @cmd.invoke "-x"
- end
-
- assert @xopt, "Should have done xopt"
- end
-
- # Returning false from the command handler invokes the usage output.
- def test_invoke_with_help
- done = false
-
- use_ui @ui do
- @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
- options[:help] = true
- done = true
- end
-
- @cmd.invoke('--help')
-
- assert done
- end
-
- assert_match(/Usage/, @ui.output)
- assert_match(/gem doit/, @ui.output)
- assert_match(/\[options\]/, @ui.output)
- assert_match(/-h/, @ui.output)
- assert_match(/--help \[COMMAND\]/, @ui.output)
- assert_match(/Get help on COMMAND/, @ui.output)
- assert_match(/-x/, @ui.output)
- assert_match(/--exe/, @ui.output)
- assert_match(/Execute/, @ui.output)
- assert_match(/Common Options:/, @ui.output)
- end
-
- def test_invoke_with_options
- @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
- options[:help] = true
- end
-
- @cmd.when_invoked do |opts|
- assert opts[:help]
- end
-
- use_ui @ui do
- @cmd.invoke '-h'
- end
-
- assert_match %r|Usage: gem doit|, @ui.output
- end
-
- def test_option_recognition
- @cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
- options[:help] = true
- end
- @cmd.add_option('-f', '--file FILE', 'File option') do |value, options|
- options[:help] = true
- end
- assert @cmd.handles?(['-x'])
- assert @cmd.handles?(['-h'])
- assert @cmd.handles?(['-h', 'command'])
- assert @cmd.handles?(['--help', 'command'])
- assert @cmd.handles?(['-f', 'filename'])
- assert @cmd.handles?(['--file=filename'])
- assert ! @cmd.handles?(['-z'])
- assert ! @cmd.handles?(['-f'])
- assert ! @cmd.handles?(['--toothpaste'])
-
- args = ['-h', 'command']
- @cmd.handles?(args)
- assert_equal ['-h', 'command'], args
- end
-
-end
-
diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb
deleted file mode 100644
index 4198bb9a2a..0000000000
--- a/test/rubygems/test_gem_command_manager.rb
+++ /dev/null
@@ -1,211 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/command_manager'
-
-class InterruptCommand < Gem::Command
-
- def initialize
- super('interrupt', 'Raises an Interrupt Exception', {})
- end
-
- def execute
- raise Interrupt, "Interrupt exception"
- end
-
-end
-
-class TestGemCommandManager < RubyGemTestCase
-
- def setup
- super
-
- @command_manager = Gem::CommandManager.new
- end
-
- def test_run_interrupt
- use_ui @ui do
- @command_manager.register_command :interrupt
- assert_raises MockGemUi::TermError do
- @command_manager.run 'interrupt'
- end
- assert_equal '', ui.output
- assert_equal "ERROR: Interrupted\n", ui.error
- end
- end
-
- def test_process_args_bad_arg
- use_ui @ui do
- assert_raises(MockGemUi::TermError) {
- @command_manager.process_args("--bad-arg")
- }
- end
-
- assert_match(/invalid option: --bad-arg/i, @ui.error)
- end
-
- def test_process_args_install
- #capture all install options
- use_ui @ui do
- check_options = nil
- @command_manager['install'].when_invoked do |options|
- check_options = options
- true
- end
-
- #check defaults
- @command_manager.process_args("install")
- assert_equal false, check_options[:test]
- assert_equal true, check_options[:generate_rdoc]
- assert_equal false, check_options[:force]
- assert_equal :both, check_options[:domain]
- assert_equal true, check_options[:wrappers]
- assert_equal Gem::Requirement.default, check_options[:version]
- assert_equal Gem.dir, check_options[:install_dir]
-
- #check settings
- check_options = nil
- @command_manager.process_args(
- "install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper")
- assert_equal true, check_options[:test]
- assert_equal true, check_options[:generate_rdoc]
- assert_equal true, check_options[:force]
- assert_equal :local, check_options[:domain]
- assert_equal false, check_options[:wrappers]
- assert_equal Gem::Requirement.new('3.0'), check_options[:version]
- assert_equal Dir.pwd, check_options[:install_dir]
-
- #check remote domain
- check_options = nil
- @command_manager.process_args("install --remote")
- assert_equal :remote, check_options[:domain]
-
- #check both domain
- check_options = nil
- @command_manager.process_args("install --both")
- assert_equal :both, check_options[:domain]
-
- #check both domain
- check_options = nil
- @command_manager.process_args("install --both")
- assert_equal :both, check_options[:domain]
- end
- end
-
- def test_process_args_uninstall
- #capture all uninstall options
- check_options = nil
- @command_manager['uninstall'].when_invoked do |options|
- check_options = options
- true
- end
-
- #check defaults
- @command_manager.process_args("uninstall")
- assert_equal Gem::Requirement.default, check_options[:version]
-
- #check settings
- check_options = nil
- @command_manager.process_args("uninstall foobar --version 3.0")
- assert_equal "foobar", check_options[:args].first
- assert_equal Gem::Requirement.new('3.0'), check_options[:version]
- end
-
- def test_process_args_check
- #capture all check options
- check_options = nil
- @command_manager['check'].when_invoked do |options|
- check_options = options
- true
- end
-
- #check defaults
- @command_manager.process_args("check")
- assert_equal false, check_options[:verify]
- assert_equal false, check_options[:alien]
-
- #check settings
- check_options = nil
- @command_manager.process_args("check --verify foobar --alien")
- assert_equal "foobar", check_options[:verify]
- assert_equal true, check_options[:alien]
- end
-
- def test_process_args_build
- #capture all build options
- check_options = nil
- @command_manager['build'].when_invoked do |options|
- check_options = options
- true
- end
-
- #check defaults
- @command_manager.process_args("build")
- #NOTE: Currently no defaults
-
- #check settings
- check_options = nil
- @command_manager.process_args("build foobar.rb")
- assert_equal 'foobar.rb', check_options[:args].first
- end
-
- def test_process_args_query
- #capture all query options
- check_options = nil
- @command_manager['query'].when_invoked do |options|
- check_options = options
- true
- end
-
- #check defaults
- @command_manager.process_args("query")
- assert_equal(/.*/, check_options[:name])
- assert_equal :local, check_options[:domain]
- assert_equal false, check_options[:details]
-
- #check settings
- check_options = nil
- @command_manager.process_args("query --name foobar --local --details")
- assert_equal(/foobar/i, check_options[:name])
- assert_equal :local, check_options[:domain]
- assert_equal true, check_options[:details]
-
- #remote domain
- check_options = nil
- @command_manager.process_args("query --remote")
- assert_equal :remote, check_options[:domain]
-
- #both (local/remote) domains
- check_options = nil
- @command_manager.process_args("query --both")
- assert_equal :both, check_options[:domain]
- end
-
- def test_process_args_update
- #capture all update options
- check_options = nil
- @command_manager['update'].when_invoked do |options|
- check_options = options
- true
- end
-
- #check defaults
- @command_manager.process_args("update")
- assert_equal true, check_options[:generate_rdoc]
-
- #check settings
- check_options = nil
- @command_manager.process_args("update --force --test --rdoc --install-dir .")
- assert_equal true, check_options[:test]
- assert_equal true, check_options[:generate_rdoc]
- assert_equal true, check_options[:force]
- assert_equal Dir.pwd, check_options[:install_dir]
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
deleted file mode 100644
index a49b6777bd..0000000000
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/build_command'
-require 'rubygems/format'
-
-class TestGemCommandsBuildCommand < RubyGemTestCase
-
- def setup
- super
-
- @gem = quick_gem 'some_gem' do |s|
- s.rubyforge_project = 'example'
- end
-
- @cmd = Gem::Commands::BuildCommand.new
- end
-
- def test_execute
- gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
-
- File.open gemspec_file, 'w' do |gs|
- gs.write @gem.to_ruby
- end
-
- util_test_build_gem @gem, gemspec_file
- end
-
- def test_execute_yaml
- gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
-
- File.open gemspec_file, 'w' do |gs|
- gs.write @gem.to_yaml
- end
-
- util_test_build_gem @gem, gemspec_file
- end
-
- def test_execute_bad_gem
- @cmd.options[:args] = %w[some_gem]
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal '', @ui.output
- assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
- end
-
- def util_test_build_gem(gem, gemspec_file)
- @cmd.options[:args] = [gemspec_file]
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- output = @ui.output.split "\n"
- assert_equal " Successfully built RubyGem", output.shift
- assert_equal " Name: some_gem", output.shift
- assert_equal " Version: 2", output.shift
- assert_equal " File: some_gem-2.gem", output.shift
- assert_equal [], output
- assert_equal '', @ui.error
-
- gem_file = File.join @tempdir, "#{gem.full_name}.gem"
- assert File.exist?(gem_file)
-
- spec = Gem::Format.from_file_by_path(gem_file).spec
-
- assert_equal "some_gem", spec.name
- assert_equal "this is a summary", spec.summary
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb
deleted file mode 100644
index 09a401e4f7..0000000000
--- a/test/rubygems/test_gem_commands_cert_command.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-
-require 'rubygems/commands/cert_command'
-
-class TestGemCommandsCertCommand < RubyGemTestCase
-
- def setup
- super
-
- @orig_security_trust_dir = Gem::Security::OPT[:trust_dir]
- Gem::Security::OPT[:trust_dir] = @tempdir
-
- @cmd = Gem::Commands::CertCommand.new
-
- root = File.expand_path(File.dirname(__FILE__))
-
- FileUtils.cp File.join(root, 'data', 'gem-private_key.pem'), @tempdir
- FileUtils.cp File.join(root, 'data', 'gem-public_cert.pem'), @tempdir
-
- @cert_file_name = File.join @tempdir, 'gem-public_cert.pem'
- @pkey_file_name = File.join @tempdir, 'gem-private_key.pem'
- end
-
- def teardown
- Gem::Security::OPT[:trust_dir] = @orig_security_trust_dir
-
- super
- end
-
- def test_execute_add
- use_ui @ui do
- @cmd.send :handle_options, %W[--add #{@cert_file_name}]
- end
-
- assert_equal "Added '/CN=rubygems/DC=example/DC=com'\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_build
- FileUtils.rm @cert_file_name
- FileUtils.rm @pkey_file_name
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.send :handle_options, %W[--build nobody@example.com]
- end
- end
-
- output = @ui.output.split "\n"
-
- assert_equal 'Public Cert: gem-public_cert.pem', output.shift
- assert_equal 'Private Key: gem-private_key.pem', output.shift
- assert_equal 'Don\'t forget to move the key file to somewhere private...',
- output.shift
- assert_equal [], output
-
- assert_equal '', @ui.error
-
- assert File.exist?(File.join(@tempdir, 'gem-private_key.pem'))
- assert File.exist?(File.join(@tempdir, 'gem-public_cert.pem'))
- end
-
- def test_execute_certificate
- use_ui @ui do
- @cmd.send :handle_options, %W[--certificate #{@cert_file_name}]
- end
-
- assert_equal '', @ui.output
- assert_equal '', @ui.error
-
- assert_equal File.read(@cert_file_name),
- Gem::Security::OPT[:issuer_cert].to_s
- end
-
- def test_execute_list
- use_ui @ui do
- @cmd.send :handle_options, %W[--list]
- end
-
- assert_equal "/CN=rubygems/DC=example/DC=com\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_private_key
- use_ui @ui do
- @cmd.send :handle_options, %W[--private-key #{@pkey_file_name}]
- end
-
- assert_equal '', @ui.output
- assert_equal '', @ui.error
-
- assert_equal File.read(@pkey_file_name),
- Gem::Security::OPT[:issuer_key].to_s
- end
-
- def test_execute_remove
- use_ui @ui do
- @cmd.send :handle_options, %W[--remove rubygems]
- end
-
- assert_equal "Removed '/CN=rubygems/DC=example/DC=com'\n", @ui.output
- assert_equal '', @ui.error
-
- assert !File.exist?(@cert_file_name)
- end
-
- def test_execute_sign
- use_ui @ui do
- @cmd.send :handle_options, %W[
- -K #{@pkey_file_name} -C #{@cert_file_name} --sign #{@cert_file_name}
- ]
- end
-
- assert_equal '', @ui.output
- assert_equal '', @ui.error
-
- # HACK this test sucks
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_check_command.rb b/test/rubygems/test_gem_commands_check_command.rb
deleted file mode 100644
index eea7cc5cfa..0000000000
--- a/test/rubygems/test_gem_commands_check_command.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/check_command'
-
-class TestGemCommandsCheckCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::CheckCommand.new
- end
-
- def test_initialize
- assert_equal "check", @cmd.command
- assert_equal "gem check", @cmd.program_name
- assert_match(/Check/, @cmd.summary)
- end
-
-end
diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb
deleted file mode 100644
index cdb89673da..0000000000
--- a/test/rubygems/test_gem_commands_contents_command.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/contents_command'
-
-class TestGemCommandsContentsCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::ContentsCommand.new
- end
-
- def test_execute
- @cmd.options[:args] = %w[foo]
- quick_gem 'foo' do |gem|
- gem.files = %w[lib/foo.rb Rakefile]
- end
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|lib/foo\.rb|, @ui.output
- assert_match %r|Rakefile|, @ui.output
- assert_equal "", @ui.error
- end
-
- def test_execute_bad_gem
- @cmd.options[:args] = %w[foo]
-
- assert_raise MockGemUi::TermError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- assert_match %r|Unable to find gem 'foo' in default gem paths|, @ui.output
- assert_match %r|Directories searched:|, @ui.output
- assert_equal "", @ui.error
- end
-
- def test_execute_exact_match
- @cmd.options[:args] = %w[foo]
- quick_gem 'foo' do |gem|
- gem.files = %w[lib/foo.rb Rakefile]
- end
-
- quick_gem 'foo_bar' do |gem|
- gem.files = %w[lib/foo_bar.rb Rakefile]
- end
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|lib/foo\.rb|, @ui.output
- assert_match %r|Rakefile|, @ui.output
- assert_equal "", @ui.error
- end
-
- def test_execute_lib_only
- @cmd.options[:args] = %w[foo]
- @cmd.options[:lib_only] = true
-
- quick_gem 'foo' do |gem|
- gem.files = %w[lib/foo.rb Rakefile]
- end
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|lib/foo\.rb|, @ui.output
- assert_no_match %r|Rakefile|, @ui.output
-
- assert_equal "", @ui.error
- end
-
- def test_handle_options
- assert_equal false, @cmd.options[:lib_only]
- assert_equal [], @cmd.options[:specdirs]
- assert_equal nil, @cmd.options[:version]
-
- @cmd.send :handle_options, %w[-l -s foo --version 0.0.2]
-
- assert_equal true, @cmd.options[:lib_only]
- assert_equal %w[foo], @cmd.options[:specdirs]
- assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version]
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_dependency_command.rb b/test/rubygems/test_gem_commands_dependency_command.rb
deleted file mode 100644
index 0f0d95695d..0000000000
--- a/test/rubygems/test_gem_commands_dependency_command.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/dependency_command'
-
-class TestGemCommandsDependencyCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::DependencyCommand.new
- @cmd.options[:domain] = :local
- end
-
- def test_execute
- quick_gem 'foo' do |gem|
- gem.add_dependency 'bar', '> 1'
- end
-
- @cmd.options[:args] = %w[foo]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_no_match
- @cmd.options[:args] = %w[foo]
-
- assert_raise MockGemUi::TermError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- assert_equal "No match found for foo (>= 0)\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_pipe_format
- quick_gem 'foo' do |gem|
- gem.add_dependency 'bar', '> 1'
- end
-
- @cmd.options[:args] = %w[foo]
- @cmd.options[:pipe_format] = true
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "bar --version '> 1'\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_reverse
- quick_gem 'foo' do |gem|
- gem.add_dependency 'bar', '> 1'
- end
-
- quick_gem 'baz' do |gem|
- gem.add_dependency 'foo'
- end
-
- @cmd.options[:args] = %w[foo]
- @cmd.options[:reverse_dependencies] = true
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-Gem foo-2
- bar (> 1)
- Used by
- baz-2 (foo (>= 0))
-
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_remote
- foo = quick_gem 'foo' do |gem|
- gem.add_dependency 'bar', '> 1'
- end
-
- util_setup_source_info_cache foo
-
- FileUtils.rm File.join(@gemhome, 'specifications',
- "#{foo.full_name}.gemspec")
-
- @cmd.options[:args] = %w[foo]
- @cmd.options[:domain] = :remote
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
- assert_equal '', @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb
deleted file mode 100644
index 65c8cf3133..0000000000
--- a/test/rubygems/test_gem_commands_environment_command.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/environment_command'
-
-class TestGemCommandsEnvironmentCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::EnvironmentCommand.new
- end
-
- def test_execute
- orig_sources = Gem.sources.dup
- Gem.sources.replace %w[http://gems.example.com]
-
- @cmd.send :handle_options, %w[]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|RUBYGEMS VERSION: (\d\.)+\d \((\d\.)+\d\)|, @ui.output
- assert_match %r|RUBY VERSION: \d\.\d\.\d \(.*\) \[.*\]|, @ui.output
- assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
- @ui.output
- assert_match %r|RUBYGEMS PREFIX: |, @ui.output
- assert_match %r|RUBY EXECUTABLE:.*ruby|, @ui.output
- assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
- assert_match %r|- #{Gem::Platform.local}|, @ui.output
- assert_match %r|GEM PATHS:|, @ui.output
- assert_match %r|- #{Regexp.escape @gemhome}|, @ui.output
- assert_match %r|GEM CONFIGURATION:|, @ui.output
- assert_match %r|:verbose => |, @ui.output
- assert_match %r|REMOTE SOURCES:|, @ui.output
- assert_equal '', @ui.error
-
- ensure
- Gem.sources.replace orig_sources
- end
-
- def test_execute_gemdir
- @cmd.send :handle_options, %w[gemdir]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "#{@gemhome}\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_gempath
- @cmd.send :handle_options, %w[gempath]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "#{@gemhome}\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_packageversion
- @cmd.send :handle_options, %w[packageversion]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "#{Gem::RubyGemsPackageVersion}\n", @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_remotesources
- orig_sources = Gem.sources.dup
- Gem.sources.replace %w[http://gems.example.com]
-
- @cmd.send :handle_options, %w[remotesources]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "http://gems.example.com\n", @ui.output
- assert_equal '', @ui.error
-
- ensure
- Gem.sources.replace orig_sources
- end
-
- def test_execute_unknown
- @cmd.send :handle_options, %w[unknown]
-
- assert_raise Gem::CommandLineError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- assert_equal '', @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_version
- @cmd.send :handle_options, %w[version]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "#{Gem::RubyGemsVersion}\n", @ui.output
- assert_equal '', @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_fetch_command.rb b/test/rubygems/test_gem_commands_fetch_command.rb
deleted file mode 100644
index 3aa9119378..0000000000
--- a/test/rubygems/test_gem_commands_fetch_command.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/fetch_command'
-
-class TestGemCommandsFetchCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::FetchCommand.new
- end
-
- def test_execute
- util_setup_fake_fetcher
-
- util_build_gem @gem1
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
- @source_index.dump
- @fetcher.data["#{@gem_repo}/gems/#{@gem1.full_name}.gem"] =
- File.read(File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"))
-
- @cmd.options[:args] = [@gem1.name]
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- assert File.exist?(File.join(@tempdir, "#{@gem1.full_name}.gem"))
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_generate_index_command.rb b/test/rubygems/test_gem_commands_generate_index_command.rb
deleted file mode 100644
index 548197841b..0000000000
--- a/test/rubygems/test_gem_commands_generate_index_command.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/indexer'
-require 'rubygems/commands/generate_index_command'
-
-class TestGemCommandsGenerateIndexCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::GenerateIndexCommand.new
- @cmd.options[:directory] = @gemhome
- end
-
- def test_execute
- use_ui @ui do
- @cmd.execute
- end
-
- yaml = File.join @gemhome, 'yaml'
- yaml_z = File.join @gemhome, 'yaml.Z'
- quick_index = File.join @gemhome, 'quick', 'index'
- quick_index_rz = File.join @gemhome, 'quick', 'index.rz'
-
- assert File.exist?(yaml), yaml
- assert File.exist?(yaml_z), yaml_z
- assert File.exist?(quick_index), quick_index
- assert File.exist?(quick_index_rz), quick_index_rz
- end
-
-end if ''.respond_to? :to_xs
-
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
deleted file mode 100644
index 78840be8c6..0000000000
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ /dev/null
@@ -1,160 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/install_command'
-
-class TestGemCommandsInstallCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::InstallCommand.new
- @cmd.options[:generate_rdoc] = false
- @cmd.options[:generate_ri] = false
- end
-
- def test_execute_include_dependencies
- @cmd.options[:include_dependencies] = true
- @cmd.options[:args] = []
-
- assert_raise Gem::CommandLineError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- output = @ui.output.split "\n"
- assert_equal "INFO: `gem install -y` is now default and will be removed",
- output.shift
- assert_equal "INFO: use --ignore-dependencies to install only the gems you list",
- output.shift
- assert output.empty?, output.inspect
- end
-
- def test_execute_local
- util_setup_fake_fetcher
- @cmd.options[:domain] = :local
-
- gem1 = quick_gem 'gem_one'
- util_build_gem gem1
- FileUtils.mv File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"),
- File.join(@tempdir)
-
- @cmd.options[:args] = [gem1.name]
-
- use_ui @ui do
- orig_dir = Dir.pwd
- begin
- Dir.chdir @tempdir
- @cmd.execute
- ensure
- Dir.chdir orig_dir
- end
- end
-
- out = @ui.output.split "\n"
- assert_equal "Successfully installed #{@gem1.full_name}", out.shift
- assert_equal "1 gem installed", out.shift
- assert out.empty?, out.inspect
- end
-
- def test_execute_local_missing
- util_setup_fake_fetcher
- @cmd.options[:domain] = :local
-
- @cmd.options[:args] = %w[gem_one]
-
- use_ui @ui do
- @cmd.execute
- end
-
- # HACK no repository was checked
- assert_equal "ERROR: could not find gem_one locally or in a repository\n",
- @ui.error
- end
-
- def test_execute_no_gem
- @cmd.options[:args] = %w[]
-
- assert_raise Gem::CommandLineError do
- @cmd.execute
- end
- end
-
- def test_execute_nonexistent
- util_setup_fake_fetcher
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
- @source_index.dump
-
- @cmd.options[:args] = %w[nonexistent]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "ERROR: could not find nonexistent locally or in a repository\n",
- @ui.error
- end
-
- def test_execute_remote
- @cmd.options[:generate_rdoc] = true
- @cmd.options[:generate_ri] = true
- util_setup_fake_fetcher
-
- util_build_gem @gem1
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
- @source_index.dump
- @fetcher.data["#{@gem_repo}/gems/gem_one-0.0.2.gem"] =
- File.read(File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"))
-
- @cmd.options[:args] = [@gem1.name]
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
- assert_match %r|Bulk updating|, out.shift
- assert_equal "Successfully installed #{@gem1.full_name}", out.shift
- assert_equal "1 gem installed", out.shift
- assert_equal "Installing ri documentation for #{@gem1.full_name}...",
- out.shift
- assert_equal "Installing RDoc documentation for #{@gem1.full_name}...",
- out.shift
- assert out.empty?, out.inspect
- end
-
- def test_execute_two
- util_setup_fake_fetcher
- @cmd.options[:domain] = :local
-
- gem1 = quick_gem 'gem_one'
- util_build_gem gem1
- FileUtils.mv File.join(@gemhome, 'cache', "#{@gem1.full_name}.gem"),
- File.join(@tempdir)
-
- gem2 = quick_gem 'gem_two'
- util_build_gem gem2
- FileUtils.mv File.join(@gemhome, 'cache', "#{@gem2.full_name}.gem"),
- File.join(@tempdir)
-
- @cmd.options[:args] = [gem1.name, gem2.name]
-
- use_ui @ui do
- orig_dir = Dir.pwd
- begin
- Dir.chdir @tempdir
- @cmd.execute
- ensure
- Dir.chdir orig_dir
- end
- end
-
- out = @ui.output.split "\n"
- assert_equal "Successfully installed #{@gem1.full_name}", out.shift
- assert_equal "Successfully installed #{@gem2.full_name}", out.shift
- assert_equal "2 gems installed", out.shift
- assert out.empty?, out.inspect
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_mirror_command.rb b/test/rubygems/test_gem_commands_mirror_command.rb
deleted file mode 100644
index 359ba5481e..0000000000
--- a/test/rubygems/test_gem_commands_mirror_command.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/indexer'
-require 'rubygems/commands/mirror_command'
-
-class TestGemCommandsMirrorCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::MirrorCommand.new
- end
-
- def test_execute
- util_make_gems
-
- gems_dir = File.join @tempdir, 'gems'
- mirror = File.join @tempdir, 'mirror'
-
- FileUtils.mkdir_p gems_dir
- FileUtils.mkdir_p mirror
-
- Dir[File.join(@gemhome, 'cache', '*.gem')].each do |gem|
- FileUtils.mv gem, gems_dir
- end
-
- use_ui @ui do
- Gem::Indexer.new(@tempdir).generate_index
- end
-
- orig_HOME = ENV['HOME']
- ENV['HOME'] = @tempdir
- Gem.instance_variable_set :@user_home, nil
-
- File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
- fp.puts "---"
- # tempdir could be a drive+path (under windows)
- if @tempdir.match(/[a-z]:/i)
- fp.puts "- from: file:///#{@tempdir}"
- else
- fp.puts "- from: file://#{@tempdir}"
- end
- fp.puts " to: #{mirror}"
- end
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert File.exist?(File.join(mirror, 'gems', "#{@a1.full_name}.gem"))
- assert File.exist?(File.join(mirror, 'gems', "#{@a2.full_name}.gem"))
- assert File.exist?(File.join(mirror, 'gems', "#{@b2.full_name}.gem"))
- assert File.exist?(File.join(mirror, 'gems', "#{@c1_2.full_name}.gem"))
- assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
- ensure
- orig_HOME.nil? ? ENV.delete('HOME') : ENV['HOME'] = orig_HOME
- Gem.instance_variable_set :@user_home, nil
- end
-
-end if ''.respond_to? :to_xs
-
diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb
deleted file mode 100644
index cd1d3500ae..0000000000
--- a/test/rubygems/test_gem_commands_pristine_command.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/pristine_command'
-
-class TestGemCommandsPristineCommand < RubyGemTestCase
-
- def setup
- super
- @cmd = Gem::Commands::PristineCommand.new
- end
-
- def test_execute
- a = quick_gem 'a' do |s| s.executables = %w[foo] end
- FileUtils.mkdir_p File.join(@tempdir, 'bin')
- File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
-
- install_gem a
-
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Restoring gem(s) to pristine condition...", out.shift
- assert_equal "#{a.full_name} is in pristine condition", out.shift
- assert out.empty?, out.inspect
- end
-
- def test_execute_all
- a = quick_gem 'a' do |s| s.executables = %w[foo] end
- FileUtils.mkdir_p File.join(@tempdir, 'bin')
- File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
-
- install_gem a
-
- gem_bin = File.join @gemhome, 'gems', "#{a.full_name}", 'bin', 'foo'
-
- FileUtils.rm gem_bin
-
- @cmd.handle_options %w[--all]
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Restoring gem(s) to pristine condition...", out.shift
- assert_equal "Restoring 1 file to #{a.full_name}...", out.shift
- assert_equal " #{gem_bin}", out.shift
- assert out.empty?, out.inspect
- end
-
- def test_execute_missing_cache_gem
- a = quick_gem 'a' do |s| s.executables = %w[foo] end
- FileUtils.mkdir_p File.join(@tempdir, 'bin')
- File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
-
- install_gem a
-
- FileUtils.rm File.join(@gemhome, 'cache', "#{a.full_name}.gem")
-
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- @cmd.execute
- end
-
- out = @ui.output.split "\n"
-
- assert_equal "Restoring gem\(s\) to pristine condition...", out.shift
- assert out.empty?, out.inspect
-
- assert_equal "ERROR: Cached gem for #{a.full_name} not found, use `gem install` to restore\n",
- @ui.error
- end
-
- def test_execute_no_gem
- @cmd.options[:args] = %w[]
-
- e = assert_raise Gem::CommandLineError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- assert_match %r|specify a gem name|, e.message
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
deleted file mode 100644
index 4430ccfd33..0000000000
--- a/test/rubygems/test_gem_commands_query_command.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/query_command'
-
-class TestGemCommandsQueryCommand < RubyGemTestCase
-
- def setup
- super
-
- @foo_gem = quick_gem 'foo' do |spec|
- spec.summary = 'This is a lot of text. ' * 5
- end
- @foo_gem_p = quick_gem 'foo' do |spec|
- spec.summary = 'This is a lot of text. ' * 5
- spec.platform = Gem::Platform::CURRENT
- end
- @bar_gem = quick_gem 'bar'
-
- @cmd = Gem::Commands::QueryCommand.new
- end
-
- def test_execute
- util_setup_source_info_cache @foo_gem, @foo_gem_p
-
- @cmd.handle_options %w[-r]
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-foo (2)
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_details
- util_setup_source_info_cache @foo_gem
-
- @cmd.handle_options %w[-r -d]
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-foo (2)
- This is a lot of text. This is a lot of text. This is a lot of
- text. This is a lot of text. This is a lot of text.
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_no_versions
- util_setup_source_info_cache @foo_gem, @bar_gem
-
- @cmd.handle_options %w[-r --no-versions]
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-
-*** REMOTE GEMS ***
-
-bar
-foo
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_server_command.rb b/test/rubygems/test_gem_commands_server_command.rb
deleted file mode 100644
index 3e6af2e11c..0000000000
--- a/test/rubygems/test_gem_commands_server_command.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/server_command'
-
-class TestGemCommandsServerCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::ServerCommand.new
- end
-
- def test_handle_options
- @cmd.send :handle_options, %w[-p 8808 --no-daemon]
-
- assert_equal false, @cmd.options[:daemon]
- assert_equal @gemhome, @cmd.options[:gemdir]
- assert_equal 8808, @cmd.options[:port]
-
- @cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
-
- assert_equal true, @cmd.options[:daemon]
- assert_equal '/nonexistent', @cmd.options[:gemdir]
- assert_equal 9999, @cmd.options[:port]
- end
-end
-
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
deleted file mode 100644
index 3d1ab801b1..0000000000
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/sources_command'
-
-class TestGemCommandsSourcesCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::SourcesCommand.new
- end
-
- def test_execute
- util_setup_source_info_cache
- @cmd.handle_options []
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-*** CURRENT SOURCES ***
-
-#{@gem_repo}
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_add
- util_setup_fake_fetcher
-
- @si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
-
- @fetcher.data["http://beta-gems.example.com/Marshal.#{@marshal_version}"] =
- @si.dump
-
- @cmd.handle_options %w[--add http://beta-gems.example.com]
-
- util_setup_source_info_cache
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-Bulk updating Gem source index for: http://beta-gems.example.com
-http://beta-gems.example.com added to sources
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
-
- Gem::SourceInfoCache.cache.flush
- assert_equal %W[http://beta-gems.example.com #{@gem_repo}],
- Gem::SourceInfoCache.cache_data.keys.sort
- end
-
- def test_execute_add_nonexistent_source
- util_setup_fake_fetcher
-
- @si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
-
- @fetcher.data["http://beta-gems.example.com/Marshal.#{@marshal_version}"] =
- proc do
- raise Gem::RemoteFetcher::FetchError, 'it died'
- end
-
-
- Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
-
- @cmd.handle_options %w[--add http://beta-gems.example.com]
-
- util_setup_source_info_cache
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-Error fetching http://beta-gems.example.com:
-\tit died
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_add_bad_uri
- @cmd.handle_options %w[--add beta-gems.example.com]
-
- util_setup_source_info_cache
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-beta-gems.example.com is not a URI
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_remove
- @cmd.handle_options %W[--remove #{@gem_repo}]
-
- util_setup_source_info_cache
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = "#{@gem_repo} removed from sources\n"
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
-
- Gem::SourceInfoCache.cache.flush
- assert_equal [], Gem::SourceInfoCache.cache_data.keys
- end
-
- def test_execute_update
- @cmd.handle_options %w[--update]
-
- util_setup_source_info_cache
- util_setup_fake_fetcher
- @si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = @si.dump
-
- use_ui @ui do
- @cmd.execute
- end
-
- expected = <<-EOF
-Bulk updating Gem source index for: #{@gem_repo}
-source cache successfully updated
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb
deleted file mode 100644
index 3741446536..0000000000
--- a/test/rubygems/test_gem_commands_specification_command.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/specification_command'
-
-class TestGemCommandsSpecificationCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::SpecificationCommand.new
- end
-
- def test_execute
- foo = quick_gem 'foo'
-
- @cmd.options[:args] = %w[foo]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|Gem::Specification|, @ui.output
- assert_match %r|name: foo|, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_all
- foo1 = quick_gem 'foo', '0.0.1'
- foo2 = quick_gem 'foo', '0.0.2'
-
- @cmd.options[:args] = %w[foo]
- @cmd.options[:all] = true
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|Gem::Specification|, @ui.output
- assert_match %r|name: foo|, @ui.output
- assert_match %r|version: 0.0.1|, @ui.output
- assert_match %r|version: 0.0.2|, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_bad_name
- @cmd.options[:args] = %w[foo]
-
- assert_raise MockGemUi::TermError do
- use_ui @ui do
- @cmd.execute
- end
- end
-
- assert_equal '', @ui.output
- assert_equal "ERROR: Unknown gem 'foo'\n", @ui.error
- end
-
- def test_execute_exact_match
- foo = quick_gem 'foo'
- foo_bar = quick_gem 'foo_bar'
-
- @cmd.options[:args] = %w[foo]
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_match %r|Gem::Specification|, @ui.output
- assert_match %r|name: foo|, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_execute_remote
- foo = quick_gem 'foo'
-
- util_setup_source_info_cache foo
-
- FileUtils.rm File.join(@gemhome, 'specifications',
- "#{foo.full_name}.gemspec")
-
- @cmd.options[:args] = %w[foo]
- @cmd.options[:domain] = :remote
-
- use_ui @ui do
- @cmd.execute
- end
-
- assert_equal "#{foo.to_yaml}\n", @ui.output
- assert_equal "WARNING: Remote information is not complete\n\n", @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb
deleted file mode 100644
index 427f9403c3..0000000000
--- a/test/rubygems/test_gem_commands_unpack_command.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/unpack_command'
-
-class TestGemCommandsUnpackCommand < RubyGemTestCase
-
- def setup
- super
-
- Dir.chdir @tempdir do
- @cmd = Gem::Commands::UnpackCommand.new
- end
- end
-
- def test_execute
- util_make_gems
-
- @cmd.options[:args] = %w[a]
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- assert File.exist?(File.join(@tempdir, 'a-2'))
- end
-
- def test_execute_with_target_option
- util_make_gems
-
- target = 'with_target'
- @cmd.options[:args] = %w[a]
- @cmd.options[:target] = target
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- assert File.exist?(File.join(@tempdir, target, 'a-2'))
- end
-
- def test_execute_exact_match
- foo_spec = quick_gem 'foo'
- foo_bar_spec = quick_gem 'foo_bar'
-
- use_ui @ui do
- Dir.chdir @tempdir do
- Gem::Builder.new(foo_spec).build
- Gem::Builder.new(foo_bar_spec).build
- end
- end
-
- foo_path = File.join(@tempdir, "#{foo_spec.full_name}.gem")
- foo_bar_path = File.join(@tempdir, "#{foo_bar_spec.full_name}.gem")
- Gem::Installer.new(foo_path).install
- Gem::Installer.new(foo_bar_path).install
-
- @cmd.options[:args] = %w[foo]
-
- use_ui @ui do
- Dir.chdir @tempdir do
- @cmd.execute
- end
- end
-
- assert File.exist?(File.join(@tempdir, foo_spec.full_name))
- end
-
-end
-
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
deleted file mode 100644
index e0360b0d6b..0000000000
--- a/test/rubygems/test_gem_config_file.rb
+++ /dev/null
@@ -1,210 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/config_file'
-
-class TestGemConfigFile < RubyGemTestCase
-
- def setup
- super
-
- @temp_conf = File.join @tempdir, '.gemrc'
-
- @cfg_args = %W[--config-file #{@temp_conf}]
- util_config_file
- end
-
- def test_initialize
- assert_equal @temp_conf, @cfg.config_file_name
-
- assert_equal false, @cfg.backtrace
- assert_equal true, @cfg.update_sources
- assert_equal false, @cfg.benchmark
- assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
- assert_equal true, @cfg.verbose
- assert_equal %w[http://gems.example.com], Gem.sources
-
- File.open @temp_conf, 'w' do |fp|
- fp.puts ":backtrace: true"
- fp.puts ":update_sources: false"
- fp.puts ":benchmark: true"
- fp.puts ":bulk_threshold: 10"
- fp.puts ":verbose: false"
- fp.puts ":sources:"
- fp.puts " - http://more-gems.example.com"
- fp.puts "install: --wrappers"
- end
-
- util_config_file
-
- assert_equal true, @cfg.backtrace
- assert_equal true, @cfg.benchmark
- assert_equal 10, @cfg.bulk_threshold
- assert_equal false, @cfg.verbose
- assert_equal false, @cfg.update_sources
- assert_equal %w[http://more-gems.example.com], Gem.sources
- assert_equal '--wrappers', @cfg[:install]
- end
-
- def test_initialize_handle_arguments_config_file
- util_config_file %W[--config-file #{@temp_conf}]
-
- assert_equal @temp_conf, @cfg.config_file_name
- end
-
- def test_initialize_handle_arguments_config_file_equals
- util_config_file %W[--config-file=#{@temp_conf}]
-
- assert_equal @temp_conf, @cfg.config_file_name
- end
-
- def test_handle_arguments
- args = %w[--backtrace --bunch --of --args here]
-
- @cfg.handle_arguments args
-
- assert_equal %w[--bunch --of --args here], @cfg.args
- end
-
- def test_handle_arguments_backtrace
- assert_equal false, @cfg.backtrace
-
- args = %w[--backtrace]
-
- @cfg.handle_arguments args
-
- assert_equal true, @cfg.backtrace
- end
-
- def test_handle_arguments_benchmark
- assert_equal false, @cfg.benchmark
-
- args = %w[--benchmark]
-
- @cfg.handle_arguments args
-
- assert_equal true, @cfg.benchmark
- end
-
- def test_handle_arguments_debug
- old_dollar_DEBUG = $DEBUG
- assert_equal false, $DEBUG
-
- args = %w[--debug]
-
- @cfg.handle_arguments args
-
- assert_equal true, $DEBUG
- ensure
- $DEBUG = old_dollar_DEBUG
- end
-
- def test_handle_arguments_override
- File.open @temp_conf, 'w' do |fp|
- fp.puts ":benchmark: false"
- end
-
- util_config_file %W[--benchmark --config-file=#{@temp_conf}]
-
- assert_equal true, @cfg.benchmark
- end
-
- def test_handle_arguments_traceback
- assert_equal false, @cfg.backtrace
-
- args = %w[--traceback]
-
- @cfg.handle_arguments args
-
- assert_equal true, @cfg.backtrace
- end
-
- def test_really_verbose
- assert_equal false, @cfg.really_verbose
-
- @cfg.verbose = true
-
- assert_equal false, @cfg.really_verbose
-
- @cfg.verbose = 1
-
- assert_equal true, @cfg.really_verbose
- end
-
- def test_write
- @cfg.backtrace = true
- @cfg.benchmark = true
- @cfg.update_sources = false
- @cfg.bulk_threshold = 10
- @cfg.verbose = false
- Gem.sources.replace %w[http://more-gems.example.com]
- @cfg[:install] = '--wrappers'
-
- @cfg.write
-
- util_config_file
-
- # These should not be written out to the config file.
- assert_equal false, @cfg.backtrace, 'backtrace'
- assert_equal false, @cfg.benchmark, 'benchmark'
- assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold,
- 'bulk_threshold'
- assert_equal true, @cfg.update_sources, 'update_sources'
- assert_equal true, @cfg.verbose, 'verbose'
-
- assert_equal '--wrappers', @cfg[:install], 'install'
-
- # this should be written out to the config file.
- assert_equal %w[http://more-gems.example.com], Gem.sources
- end
-
- def test_write_from_hash
- File.open @temp_conf, 'w' do |fp|
- fp.puts ":backtrace: true"
- fp.puts ":benchmark: true"
- fp.puts ":bulk_threshold: 10"
- fp.puts ":update_sources: false"
- fp.puts ":verbose: false"
- fp.puts ":sources:"
- fp.puts " - http://more-gems.example.com"
- fp.puts "install: --wrappers"
- end
-
- util_config_file
-
- @cfg.backtrace = :junk
- @cfg.benchmark = :junk
- @cfg.update_sources = :junk
- @cfg.bulk_threshold = 20
- @cfg.verbose = :junk
- Gem.sources.replace %w[http://even-more-gems.example.com]
- @cfg[:install] = '--wrappers --no-rdoc'
-
- @cfg.write
-
- util_config_file
-
- # These should not be written out to the config file
- assert_equal true, @cfg.backtrace, 'backtrace'
- assert_equal true, @cfg.benchmark, 'benchmark'
- assert_equal 10, @cfg.bulk_threshold, 'bulk_threshold'
- assert_equal false, @cfg.update_sources, 'update_sources'
- assert_equal false, @cfg.verbose, 'verbose'
-
- assert_equal '--wrappers --no-rdoc', @cfg[:install], 'install'
-
- assert_equal %w[http://even-more-gems.example.com], Gem.sources
- end
-
- def util_config_file(args = @cfg_args)
- @cfg = Gem::ConfigFile.new args
- end
-
-end
-
diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb
deleted file mode 100644
index f280221a00..0000000000
--- a/test/rubygems/test_gem_dependency.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/version'
-
-class TestGemDependency < RubyGemTestCase
-
- def setup
- super
-
- @pkg1_0 = Gem::Dependency.new 'pkg', ['> 1.0']
- @pkg1_1 = Gem::Dependency.new 'pkg', ['> 1.1']
-
- @oth1_0 = Gem::Dependency.new 'other', ['> 1.0']
-
- @r1_0 = Gem::Requirement.new ['> 1.0']
- end
-
- def test_initialize
- assert_equal "pkg", @pkg1_0.name
- assert_equal @r1_0, @pkg1_0.version_requirements
- end
-
- def test_initialize_double
- dep = Gem::Dependency.new("pkg", ["> 1.0", "< 2.0"])
-
- assert_equal Gem::Requirement.new(["> 1.0", "< 2.0"]),
- dep.version_requirements
- end
-
- def test_initialize_empty
- dep = Gem::Dependency.new("pkg", [])
- req = @r1_0
-
- req.instance_eval do
- @version = ">= 1.0"
- @op = ">="
- @nums = [1,0]
- @requirements = nil
- end
-
- dep.instance_eval do
- @version_requirement = req
- @version_requirements = nil
- end
-
- assert_equal Gem::Requirement.new([">= 1.0"]), dep.version_requirements
- end
-
- def test_initialize_version
- dep = Gem::Dependency.new 'pkg', Gem::Version.new('2')
-
- assert_equal 'pkg', dep.name
-
- assert_equal Gem::Requirement.new('= 2'), dep.version_requirements
- end
-
- def test_equals2
- assert_equal @pkg1_0, @pkg1_0.dup
- assert_equal @pkg1_0.dup, @pkg1_0
-
- assert_not_equal @pkg1_0, @pkg1_1, "requirements different"
- assert_not_equal @pkg1_1, @pkg1_0, "requirements different"
-
- assert_not_equal @pkg1_0, @oth1_0, "names different"
- assert_not_equal @oth1_0, @pkg1_0, "names different"
-
- assert_not_equal @pkg1_0, Object.new
- assert_not_equal Object.new, @pkg1_0
- end
-
- def test_hash
- assert_equal @pkg1_0.hash, @pkg1_0.dup.hash
- assert_equal @pkg1_0.dup.hash, @pkg1_0.hash
-
- assert_not_equal @pkg1_0.hash, @pkg1_1.hash, "requirements different"
- assert_not_equal @pkg1_1.hash, @pkg1_0.hash, "requirements different"
-
- assert_not_equal @pkg1_0.hash, @oth1_0.hash, "names different"
- assert_not_equal @oth1_0.hash, @pkg1_0.hash, "names different"
- end
-
-end
-
diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb
deleted file mode 100644
index c299476eeb..0000000000
--- a/test/rubygems/test_gem_dependency_installer.rb
+++ /dev/null
@@ -1,542 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/dependency_installer'
-
-class TestGemDependencyInstaller < RubyGemTestCase
-
- def setup
- super
-
- @gems_dir = File.join @tempdir, 'gems'
- @cache_dir = File.join @gemhome, 'cache'
- FileUtils.mkdir @gems_dir
-
- write_file File.join('gems', 'a-1', 'bin', 'a_bin') do |fp|
- fp.puts "#!/usr/bin/ruby"
- end
- @a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
-
- @b1, @b1_gem = util_gem 'b', '1' do |s| s.add_dependency 'a' end
-
- @d1, @d1_gem = util_gem 'd', '1'
- @d2, @d2_gem = util_gem 'd', '2'
-
- @x1_m, @x1_m_gem = util_gem 'x', '1' do |s|
- s.platform = Gem::Platform.new %w[cpu my_platform 1]
- end
-
- @x1_o, @x1_o_gem = util_gem 'x', '1' do |s|
- s.platform = Gem::Platform.new %w[cpu other_platform 1]
- end
-
- @w1, @w1_gem = util_gem 'w', '1' do |s| s.add_dependency 'x' end
-
- @y1, @y1_gem = util_gem 'y', '1'
- @y1_1_p, @y1_1_p_gem = util_gem 'y', '1.1' do |s|
- s.platform = Gem::Platform.new %w[cpu my_platform 1]
- end
-
- @z1, @z1_gem = util_gem 'z', '1' do |s| s.add_dependency 'y' end
-
- si = util_setup_source_info_cache @a1, @b1, @d1, @d2, @x1_m, @x1_o, @w1,
- @y1, @y1_1_p, @z1
-
- @fetcher = FakeFetcher.new
- Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
- @fetcher.uri = URI.parse 'http://gems.example.com'
- @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
-
- FileUtils.rm_rf File.join(@gemhome, 'gems')
- end
-
- def test_install
- FileUtils.mv @a1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a'
- inst.install
- end
-
- assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
- Gem::SourceIndex.from_installed_gems
-
- assert_equal [@a1], inst.installed_gems
- end
-
- def test_install_dependency
- FileUtils.mv @a1_gem, @tempdir
- FileUtils.mv @b1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'b'
- inst.install
- end
-
- assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_dependency_existing
- Gem::Installer.new(@a1_gem).install
- FileUtils.mv @a1_gem, @tempdir
- FileUtils.mv @b1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'b'
- inst.install
- end
-
- assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_dependency_old
- e1, e1_gem = util_gem 'e', '1'
- f1, f1_gem = util_gem 'f', '1' do |s| s.add_dependency 'e' end
- f2, f2_gem = util_gem 'f', '2'
-
- FileUtils.mv e1_gem, @tempdir
- FileUtils.mv f1_gem, @tempdir
- FileUtils.mv f2_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'f'
- inst.install
- end
-
- assert_equal %w[f-2], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_local
- FileUtils.mv @a1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a-1.gem'
- inst.install
- end
-
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_local_subdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'gems/a-1.gem'
- inst.install
- end
-
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_env_shebang
- FileUtils.mv @a1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a', nil, :env_shebang => true,
- :wrappers => true
- inst.install
- end
-
- assert_match %r|\A#!/usr/bin/env ruby\n|,
- File.read(File.join(@gemhome, 'bin', 'a_bin'))
- end
-
- def test_install_force
- FileUtils.mv @b1_gem, @tempdir
- si = util_setup_source_info_cache @b1
- @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'b', nil, :force => true
- inst.install
- end
-
- assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_ignore_dependencies
- FileUtils.mv @b1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'b', nil, :ignore_dependencies => true
- inst.install
- end
-
- assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_install_dir
- FileUtils.mv @a1_gem, @tempdir
- gemhome2 = File.join @tempdir, 'gemhome2'
- Dir.mkdir gemhome2
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a', nil, :install_dir => gemhome2
- inst.install
- end
-
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
-
- assert File.exist?(File.join(gemhome2, 'specifications',
- "#{@a1.full_name}.gemspec"))
- end
-
- def test_install_domain_both
- a1_data = nil
- File.open @a1_gem, 'rb' do |fp|
- a1_data = fp.read
- end
-
- @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
-
- FileUtils.mv @b1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'b', nil, :domain => :both
- inst.install
- end
-
- assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
- a1, b1 = inst.installed_gems
-
- a1_expected = File.join(@gemhome, 'specifications',
- "#{a1.full_name}.gemspec")
- b1_expected = File.join(@gemhome, 'specifications',
- "#{b1.full_name}.gemspec")
-
- assert_equal a1_expected, a1.loaded_from
- assert_equal b1_expected, b1.loaded_from
- end
-
- def test_install_domain_local
- FileUtils.mv @b1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- e = assert_raise Gem::InstallError do
- inst = Gem::DependencyInstaller.new 'b', nil, :domain => :local
- inst.install
- end
- assert_equal 'b requires a (>= 0)', e.message
- end
-
- assert_equal [], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_domain_remote
- a1_data = nil
- File.open @a1_gem, 'rb' do |fp|
- a1_data = fp.read
- end
-
- @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
-
- inst = Gem::DependencyInstaller.new 'a', nil, :domain => :remote
- inst.install
-
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_domain_remote_platform_newer
- a2_o, a2_o_gem = util_gem 'a', '2' do |s|
- s.platform = Gem::Platform.new %w[cpu other_platform 1]
- end
-
- si = util_setup_source_info_cache @a1, a2_o
-
- @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
-
- a1_data = nil
- a2_o_data = nil
-
- File.open @a1_gem, 'rb' do |fp| a1_data = fp.read end
- File.open a2_o_gem, 'rb' do |fp| a2_o_data = fp.read end
-
- @fetcher.data["http://gems.example.com/gems/#{@a1.full_name}.gem"] =
- a1_data
- @fetcher.data["http://gems.example.com/gems/#{a2_o.full_name}.gem"] =
- a2_o_data
-
- inst = Gem::DependencyInstaller.new 'a', nil, :domain => :remote
- inst.install
-
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_reinstall
- Gem::Installer.new(@a1_gem).install
- FileUtils.mv @a1_gem, @tempdir
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a'
- inst.install
- end
-
- assert_equal Gem::SourceIndex.new(@a1.full_name => @a1),
- Gem::SourceIndex.from_installed_gems
-
- assert_equal %w[a-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_security_policy
- FileUtils.mv @a1_gem, @cache_dir
- FileUtils.mv @b1_gem, @cache_dir
- policy = Gem::Security::HighSecurity
- inst = Gem::DependencyInstaller.new 'b', nil, :security_policy => policy
-
- e = assert_raise Gem::Exception do
- inst.install
- end
-
- assert_equal 'Unsigned gem', e.message
-
- assert_equal %w[], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_wrappers
- FileUtils.mv @a1_gem, @cache_dir
- inst = Gem::DependencyInstaller.new 'a', :wrappers => true
-
- inst.install
-
- assert_match %r|This file was generated by RubyGems.|,
- File.read(File.join(@gemhome, 'bin', 'a_bin'))
- end
-
- def test_install_version
- FileUtils.mv @d1_gem, @cache_dir
- FileUtils.mv @d2_gem, @cache_dir
- inst = Gem::DependencyInstaller.new 'd', '= 1'
-
- inst.install
-
- assert_equal %w[d-1], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_install_version_default
- FileUtils.mv @d1_gem, @cache_dir
- FileUtils.mv @d2_gem, @cache_dir
- inst = Gem::DependencyInstaller.new 'd'
-
- inst.install
-
- assert_equal %w[d-2], inst.installed_gems.map { |s| s.full_name }
- end
-
- def test_download
- a1_data = nil
- File.open @a1_gem, 'rb' do |fp|
- a1_data = fp.read
- end
-
- @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
-
- inst = Gem::DependencyInstaller.new 'a'
-
- a1_cache_gem = File.join(@gemhome, 'cache', "#{@a1.full_name}.gem")
- assert_equal a1_cache_gem, inst.download(@a1, 'http://gems.example.com')
-
- assert File.exist?(a1_cache_gem)
- end
-
- def test_download_cached
- FileUtils.mv @a1_gem, @cache_dir
-
- inst = Gem::DependencyInstaller.new 'a'
-
- assert_equal File.join(@gemhome, 'cache', "#{@a1.full_name}.gem"),
- inst.download(@a1, 'http://gems.example.com')
- end
-
- def test_download_local
- FileUtils.mv @a1_gem, @tempdir
- local_path = File.join @tempdir, "#{@a1.full_name}.gem"
- inst = nil
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a'
- end
-
- assert_equal File.join(@gemhome, 'cache', "#{@a1.full_name}.gem"),
- inst.download(@a1, local_path)
- end
-
- def test_download_install_dir
- a1_data = nil
- File.open @a1_gem, 'rb' do |fp|
- a1_data = fp.read
- end
-
- @fetcher.data['http://gems.example.com/gems/a-1.gem'] = a1_data
-
- install_dir = File.join @tempdir, 'more_gems'
-
- inst = Gem::DependencyInstaller.new 'a', nil, :install_dir => install_dir
-
- a1_cache_gem = File.join install_dir, 'cache', "#{@a1.full_name}.gem"
- assert_equal a1_cache_gem, inst.download(@a1, 'http://gems.example.com')
-
- assert File.exist?(a1_cache_gem)
- end
-
- unless win_platform? then # File.chmod doesn't work
- def test_download_local_read_only
- FileUtils.mv @a1_gem, @tempdir
- local_path = File.join @tempdir, "#{@a1.full_name}.gem"
- inst = nil
- File.chmod 0555, File.join(@gemhome, 'cache')
-
- Dir.chdir @tempdir do
- inst = Gem::DependencyInstaller.new 'a'
- end
-
- assert_equal File.join(@tempdir, "#{@a1.full_name}.gem"),
- inst.download(@a1, local_path)
- ensure
- File.chmod 0755, File.join(@gemhome, 'cache')
- end
- end
-
- def test_download_platform_legacy
- original_platform = 'old-platform'
-
- e1, e1_gem = util_gem 'e', '1' do |s|
- s.platform = Gem::Platform::CURRENT
- s.instance_variable_set :@original_platform, original_platform
- end
-
- e1_data = nil
- File.open e1_gem, 'rb' do |fp|
- e1_data = fp.read
- end
-
- @fetcher.data["http://gems.example.com/gems/e-1-#{original_platform}.gem"] = e1_data
-
- inst = Gem::DependencyInstaller.new 'a'
-
- e1_cache_gem = File.join(@gemhome, 'cache', "#{e1.full_name}.gem")
- assert_equal e1_cache_gem, inst.download(e1, 'http://gems.example.com')
-
- assert File.exist?(e1_cache_gem)
- end
-
- def test_download_unsupported
- inst = Gem::DependencyInstaller.new 'a'
-
- e = assert_raise Gem::InstallError do
- inst.download @a1, 'ftp://gems.rubyforge.org'
- end
-
- assert_equal 'unsupported URI scheme ftp', e.message
- end
-
- def test_find_gems_gems_with_sources
- inst = Gem::DependencyInstaller.new 'a'
- dep = Gem::Dependency.new 'b', '>= 0'
-
- assert_equal [[@b1, 'http://gems.example.com']],
- inst.find_gems_with_sources(dep)
- end
-
- def test_find_gems_with_sources_local
- FileUtils.mv @a1_gem, @tempdir
- inst = Gem::DependencyInstaller.new 'b'
- dep = Gem::Dependency.new 'a', '>= 0'
- gems = nil
-
- Dir.chdir @tempdir do
- gems = inst.find_gems_with_sources dep
- end
-
- assert_equal 2, gems.length
- remote = gems.first
- assert_equal @a1, remote.first, 'remote spec'
- assert_equal 'http://gems.example.com', remote.last, 'remote path'
-
- local = gems.last
- assert_equal 'a-1', local.first.full_name, 'local spec'
- assert_equal File.join(@tempdir, "#{@a1.full_name}.gem"),
- local.last, 'local path'
- end
-
- def test_gather_dependencies
- inst = Gem::DependencyInstaller.new 'b'
-
- assert_equal %w[a-1 b-1], inst.gems_to_install.map { |s| s.full_name }
- end
-
- def test_gather_dependencies_dropped
- b2, = util_gem 'b', '2'
- c1, = util_gem 'c', '1' do |s| s.add_dependency 'b' end
-
- si = util_setup_source_info_cache @a1, @b1, b2, c1
-
- @fetcher = FakeFetcher.new
- Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
- @fetcher.uri = URI.parse 'http://gems.example.com'
- @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
-
- inst = Gem::DependencyInstaller.new 'c'
-
- assert_equal %w[b-2 c-1], inst.gems_to_install.map { |s| s.full_name }
- end
-
- def test_gather_dependencies_platform_alternate
- util_set_arch 'cpu-my_platform1'
-
- inst = Gem::DependencyInstaller.new 'w'
-
- assert_equal %w[x-1-cpu-my_platform-1 w-1],
- inst.gems_to_install.map { |s| s.full_name }
- end
-
- def test_gather_dependencies_platform_bump
- inst = Gem::DependencyInstaller.new 'z'
-
- assert_equal %w[y-1 z-1], inst.gems_to_install.map { |s| s.full_name }
- end
-
- def test_gather_dependencies_old_required
- e1, = util_gem 'e', '1' do |s| s.add_dependency 'd', '= 1' end
-
- si = util_setup_source_info_cache @d1, @d2, e1
-
- @fetcher = FakeFetcher.new
- Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
- @fetcher.uri = URI.parse 'http://gems.example.com'
- @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
-
- inst = Gem::DependencyInstaller.new 'e'
-
- assert_equal %w[d-1 e-1], inst.gems_to_install.map { |s| s.full_name }
- end
-
- def util_gem(name, version, &block)
- spec = quick_gem(name, version, &block)
-
- util_build_gem spec
-
- cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
- FileUtils.mv File.join(@gemhome, 'cache', "#{spec.original_name}.gem"),
- cache_file
- FileUtils.rm File.join(@gemhome, 'specifications',
- "#{spec.full_name}.gemspec")
-
- spec.loaded_from = nil
- spec.loaded = false
-
- [spec, cache_file]
- end
-
-end
-
diff --git a/test/rubygems/test_gem_dependency_list.rb b/test/rubygems/test_gem_dependency_list.rb
deleted file mode 100644
index 5fdc227f05..0000000000
--- a/test/rubygems/test_gem_dependency_list.rb
+++ /dev/null
@@ -1,212 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/dependency_list'
-
-class TestGemDependencyList < RubyGemTestCase
-
- def setup
- super
-
- @deplist = Gem::DependencyList.new
-
- @a1 = quick_gem 'a', '1'
- @a2 = quick_gem 'a', '2'
- @a3 = quick_gem 'a', '3'
-
- @b1 = quick_gem 'b', '1' do |s| s.add_dependency 'a', '>= 1' end
- @b2 = quick_gem 'b', '2' do |s| s.add_dependency 'a', '>= 1' end
-
- @c1 = quick_gem 'c', '1' do |s| s.add_dependency 'b', '>= 1' end
- @c2 = quick_gem 'c', '2'
-
- @d1 = quick_gem 'd', '1' do |s| s.add_dependency 'c', '>= 1' end
- end
-
- def test_self_from_source_index
- hash = {
- 'a-1' => @a1,
- 'b-2' => @b2,
- }
-
- si = Gem::SourceIndex.new hash
- deps = Gem::DependencyList.from_source_index si
-
- assert_equal %w[b-2 a-1], deps.dependency_order.map { |s| s.full_name }
- end
-
- def test_active_count
- assert_equal 0, @deplist.send(:active_count, [], {})
- assert_equal 1, @deplist.send(:active_count, [@a1], {})
- assert_equal 0, @deplist.send(:active_count, [@a1],
- { @a1.full_name => true })
- end
-
- def test_add
- assert_equal [], @deplist.dependency_order
-
- @deplist.add @a1, @b2
-
- assert_equal [@b2, @a1], @deplist.dependency_order
- end
-
- def test_dependency_order
- @deplist.add @a1, @b1, @c1, @d1
-
- order = @deplist.dependency_order
-
- assert_equal %w[d-1 c-1 b-1 a-1], order.map { |s| s.full_name }
- end
-
- def test_dependency_order_circle
- @a1.add_dependency 'c', '>= 1'
- @deplist.add @a1, @b1, @c1
-
- order = @deplist.dependency_order
-
- assert_equal %w[b-1 c-1 a-1], order.map { |s| s.full_name }
- end
-
- def test_dependency_order_diamond
- util_diamond
- e1 = quick_gem 'e', '1'
- @deplist.add e1
- @a1.add_dependency 'e', '>= 1'
-
- order = @deplist.dependency_order
-
- assert_equal %w[d-1 c-2 b-1 a-2 e-1], order.map { |s| s.full_name },
- 'deps of trimmed specs not included'
- end
-
- def test_dependency_order_no_dependendencies
- @deplist.add @a1, @c2
-
- order = @deplist.dependency_order
-
- assert_equal %w[c-2 a-1], order.map { |s| s.full_name }
- end
-
- def test_find_name
- @deplist.add @a1, @b2
-
- assert_equal "a-1", @deplist.find_name("a-1").full_name
- assert_equal "b-2", @deplist.find_name("b-2").full_name
-
- assert_nil @deplist.find_name("c-2")
- end
-
- def test_ok_eh
- assert @deplist.ok?, 'no dependencies'
-
- @deplist.add @b2
-
- assert ! @deplist.ok?, 'unsatisfied dependency'
-
- @deplist.add @a1
-
- assert @deplist.ok?, 'satisfied dependency'
- end
-
- def test_ok_eh_mismatch
- a1 = quick_gem 'a', '1'
- a2 = quick_gem 'a', '2'
-
- b = quick_gem 'b', '1' do |s| s.add_dependency 'a', '= 1' end
- c = quick_gem 'c', '1' do |s| s.add_dependency 'a', '= 2' end
-
- d = quick_gem 'd', '1' do |s|
- s.add_dependency 'b'
- s.add_dependency 'c'
- end
-
- @deplist.add a1, a2, b, c, d
-
- assert @deplist.ok?, 'this will break on require'
- end
-
- def test_ok_eh_redundant
- @deplist.add @a1, @a3, @b2
-
- @deplist.remove_by_name("a-1")
-
- assert @deplist.ok?
- end
-
- def test_ok_to_remove_eh
- @deplist.add @a1
-
- assert @deplist.ok_to_remove?("a-1")
-
- @deplist.add @b2
-
- assert ! @deplist.ok_to_remove?("a-1")
-
- @deplist.add @a2
-
- assert @deplist.ok_to_remove?("a-1")
- assert @deplist.ok_to_remove?("a-2")
- assert @deplist.ok_to_remove?("b-2")
- end
-
- def test_ok_to_remove_eh_after_sibling_removed
- @deplist.add @a1, @a2, @b2
-
- assert @deplist.ok_to_remove?("a-1")
- assert @deplist.ok_to_remove?("a-2")
-
- @deplist.remove_by_name("a-1")
-
- assert ! @deplist.ok_to_remove?("a-2")
- end
-
- def test_remove_by_name
- @deplist.add @a1, @b2
-
- @deplist.remove_by_name "a-1"
-
- assert ! @deplist.ok?
- end
-
- def test_tsort_each_node
- util_diamond
-
- order = %w[a-1 a-2 b-1 c-2 d-1]
-
- @deplist.tsort_each_node do |node|
- assert_equal order.shift, node.full_name
- end
-
- assert order.empty?
- end
-
- def test_tsort_each_child
- util_diamond
-
- order = %w[a-2]
-
- @deplist.tsort_each_child(@b1) do |node|
- assert_equal order.shift, node.full_name
- end
-
- assert order.empty?
- end
-
- # d1 -> b1 -> a1
- # d1 -> c2 -> a2
- def util_diamond
- @c2.add_dependency 'a', '>= 2'
- @d1.add_dependency 'b'
-
- @deplist.add @a1, @a2, @b1, @c2, @d1
- end
-
-end
-
diff --git a/test/rubygems/test_gem_digest.rb b/test/rubygems/test_gem_digest.rb
deleted file mode 100755
index 9d825b2796..0000000000
--- a/test/rubygems/test_gem_digest.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require "test/unit"
-require "rubygems/digest/md5"
-require "rubygems/digest/sha1"
-require "rubygems/digest/sha2"
-
-class TestRubygemsGemDigest < Test::Unit::TestCase
- def test_sha256_hex_digest_works
- digester = Gem::SHA256.new
- assert_equal "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78", digester.hexdigest("ABC")
- end
-
- def test_sha256_digest_works
- digester = Gem::SHA256.new
- assert_equal "\265\324\004\\?Fo\251\037\342\314j\276y#*\032W\315\361\004\367\242nqn\n\036'\211\337x",
- digester.digest("ABC")
- end
-
- def test_sha1_hex_digest_works
- digester = Gem::SHA1.new
- assert_equal "3c01bdbb26f358bab27f267924aa2c9a03fcfdb8", digester.hexdigest("ABC")
- end
-
- def test_sha1_digest_works
- digester = Gem::SHA1.new
- assert_equal "<\001\275\273&\363X\272\262\177&y$\252,\232\003\374\375\270", digester.digest("ABC")
- end
-
- def test_md5_hex_digest_works
- digester = Gem::MD5.new
- assert_equal "902fbdd2b1df0c4f70b4a5d23525e932", digester.hexdigest("ABC")
- end
-
- def test_md5_digest_works
- digester = Gem::MD5.new
- assert_equal "\220/\275\322\261\337\fOp\264\245\3225%\3512", digester.digest("ABC")
- end
-end \ No newline at end of file
diff --git a/test/rubygems/test_gem_doc_manager.rb b/test/rubygems/test_gem_doc_manager.rb
deleted file mode 100644
index e52fb9f0cd..0000000000
--- a/test/rubygems/test_gem_doc_manager.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/doc_manager'
-
-class TestGemDocManager < RubyGemTestCase
-
- def setup
- super
-
- @spec = quick_gem 'a'
- @manager = Gem::DocManager.new(@spec)
- end
-
- def test_uninstall_doc_unwritable
- orig_mode = File.stat(@spec.installation_path).mode
- File.chmod 0, @spec.installation_path
-
- assert_raise Gem::FilePermissionError do
- @manager.uninstall_doc
- end
- ensure
- File.chmod orig_mode, @spec.installation_path
- end
-
-end
-
diff --git a/test/rubygems/test_gem_ext_configure_builder.rb b/test/rubygems/test_gem_ext_configure_builder.rb
deleted file mode 100644
index 25aa7412aa..0000000000
--- a/test/rubygems/test_gem_ext_configure_builder.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/ext'
-
-class TestGemExtConfigureBuilder < RubyGemTestCase
-
- def setup
- super
-
- @makefile_body = "all:\n\t@echo ok\ninstall:\n\t@echo ok"
-
- @ext = File.join @tempdir, 'ext'
- @dest_path = File.join @tempdir, 'prefix'
-
- FileUtils.mkdir_p @ext
- FileUtils.mkdir_p @dest_path
- end
-
- def test_self_build
- return if RUBY_PLATFORM =~ /mswin/ # HACK
-
- File.open File.join(@ext, './configure'), 'w' do |configure|
- configure.puts "#!/bin/sh\necho \"#{@makefile_body}\" > Makefile"
- end
-
- output = []
-
- Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
- end
-
- expected = [
- "sh ./configure --prefix=#{@dest_path}",
- "", "make", "ok\n", "make install", "ok\n"
- ]
-
- assert_equal expected, output
- end
-
- def test_self_build_fail
- return if RUBY_PLATFORM =~ /mswin/ # HACK
- output = []
-
- error = assert_raise Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
- end
- end
-
- expected = %r|configure failed:
-
-sh \./configure --prefix=#{Regexp.escape @dest_path}
-.*?: \./configure: No such file or directory
-|
-
- assert_match expected, error.message
-
- assert_equal "sh ./configure --prefix=#{@dest_path}", output.shift
- assert_match %r|\./configure: No such file or directory\n|, output.shift
- assert_equal true, output.empty?
- end
-
- def test_self_build_has_makefile
- File.open File.join(@ext, 'Makefile'), 'w' do |makefile|
- makefile.puts @makefile_body
- end
-
- output = []
- Dir.chdir @ext do
- Gem::Ext::ConfigureBuilder.build nil, nil, @dest_path, output
- end
-
- case RUBY_PLATFORM
- when /mswin/ then
- assert_equal 'nmake', output[0]
- assert_equal 'nmake install', output[2]
- else
- assert_equal 'make', output[0]
- assert_equal 'make install', output[2]
- end
- end
-
-end
-
diff --git a/test/rubygems/test_gem_ext_ext_conf_builder.rb b/test/rubygems/test_gem_ext_ext_conf_builder.rb
deleted file mode 100644
index fb21fa0755..0000000000
--- a/test/rubygems/test_gem_ext_ext_conf_builder.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/ext'
-
-class TestGemExtExtConfBuilder < RubyGemTestCase
-
- def setup
- super
-
- @ext = File.join @tempdir, 'ext'
- @dest_path = File.join @tempdir, 'prefix'
-
- FileUtils.mkdir_p @ext
- FileUtils.mkdir_p @dest_path
- end
-
- def test_class_build
- File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
- extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
- end
-
- output = []
-
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
- end
-
- expected = [
- "ruby extconf.rb",
- "creating Makefile\n",
- "make",
- "make: Nothing to be done for `all'.\n",
- "make install",
- "make: Nothing to be done for `install'.\n"
- ]
-
- assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
- assert_equal "creating Makefile\n", output[1]
- case RUBY_PLATFORM
- when /mswin/ then
- assert_equal "nmake", output[2]
- assert_equal "nmake install", output[4]
- else
- assert_equal "make", output[2]
- assert_equal "make install", output[4]
- end
- end
-
- def test_class_build_extconf_fail
- File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
- extconf.puts "require 'mkmf'"
- extconf.puts "have_library 'nonexistent' or abort 'need libnonexistent'"
- extconf.puts "create_makefile 'foo'"
- end
-
- output = []
-
- error = assert_raise Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
- end
- end
-
- assert_match(/\Aextconf failed:
-
-#{Gem.ruby} extconf.rb.*
-checking for main\(\) in .*?nonexistent/m, error.message)
-
- assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
- end
-
- def test_class_make
- output = []
- makefile_path = File.join(@ext, 'Makefile')
- File.open makefile_path, 'w' do |makefile|
- makefile.puts "RUBYARCHDIR = $(foo)$(target_prefix)"
- makefile.puts "RUBYLIBDIR = $(bar)$(target_prefix)"
- makefile.puts "all:"
- makefile.puts "install:"
- end
-
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.make @ext, output
- end
-
- case RUBY_PLATFORM
- when /mswin/ then
- assert_equal 'nmake', output[0]
- assert_equal 'nmake install', output[2]
- else
- assert_equal 'make', output[0]
- assert_equal 'make install', output[2]
- end
-
- edited_makefile = <<-EOF
-RUBYARCHDIR = #{@ext}$(target_prefix)
-RUBYLIBDIR = #{@ext}$(target_prefix)
-all:
-install:
- EOF
-
- assert_equal edited_makefile, File.read(makefile_path)
- end
-
- def test_class_make_no_Makefile
- error = assert_raise Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::ExtConfBuilder.make @ext, ['output']
- end
- end
-
- expected = <<-EOF.strip
-Makefile not found:
-
-output
- EOF
-
- assert_equal expected, error.message
- end
-
-end
-
diff --git a/test/rubygems/test_gem_ext_rake_builder.rb b/test/rubygems/test_gem_ext_rake_builder.rb
deleted file mode 100644
index cd63106077..0000000000
--- a/test/rubygems/test_gem_ext_rake_builder.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/ext'
-
-class TestGemExtRakeBuilder < RubyGemTestCase
-
- def setup
- super
-
- @ext = File.join @tempdir, 'ext'
- @dest_path = File.join @tempdir, 'prefix'
-
- FileUtils.mkdir_p @ext
- FileUtils.mkdir_p @dest_path
- end
-
- def test_class_build
- File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
- mkrf_conf.puts <<-EO_MKRF
- File.open("Rakefile","w") do |f|
- f.puts "task :default"
- end
- EO_MKRF
- end
-
- output = []
- realdir = nil # HACK /tmp vs. /private/tmp
-
- Dir.chdir @ext do
- realdir = Dir.pwd
- Gem::Ext::RakeBuilder.build 'mkrf_conf.rb', nil, @dest_path, output
- end
-
- expected = [
- "#{Gem.ruby} mkrf_conf.rb",
- "",
- "rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
- "(in #{realdir})\n"
- ]
-
- assert_equal expected, output
- end
-
- def test_class_build_fail
- File.open File.join(@ext, 'mkrf_conf.rb'), 'w' do |mkrf_conf|
- mkrf_conf.puts <<-EO_MKRF
- File.open("Rakefile","w") do |f|
- f.puts "task :default do abort 'fail' end"
- end
- EO_MKRF
- end
-
- output = []
-
- error = assert_raise Gem::InstallError do
- Dir.chdir @ext do
- Gem::Ext::RakeBuilder.build "mkrf_conf.rb", nil, @dest_path, output
- end
- end
-
- expected = <<-EOF.strip
-rake failed:
-
-#{Gem.ruby} mkrf_conf.rb
-
-rake RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
- EOF
-
- assert_equal expected, error.message.split("\n")[0..4].join("\n")
- end
-
-end
-
diff --git a/test/rubygems/test_gem_format.rb b/test/rubygems/test_gem_format.rb
deleted file mode 100644
index 35eee6bae2..0000000000
--- a/test/rubygems/test_gem_format.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
-require 'rubygems/format'
-
-class TestGemFormat < RubyGemTestCase
-
- def setup
- super
-
- @simple_gem = SIMPLE_GEM
- end
-
- def test_from_file_by_path
- util_make_gems
-
- gems = Dir[File.join(@gemhome, 'cache', '*.gem')]
-
- names = [@a1, @a2, @b2, @c1_2, @pl1].map do |spec|
- spec.original_name
- end
-
- gems_n_names = gems.sort.zip names
-
- gems_n_names.each do |gemfile, name|
- spec = Gem::Format.from_file_by_path(gemfile).spec
-
- assert_equal name, spec.original_name
- end
- end
-
- def test_from_file_by_path_nonexistent
- assert_raise Gem::Exception do
- Gem::Format.from_file_by_path '/nonexistent'
- end
- end
-
- def test_from_io_garbled
- e = assert_raise Gem::Package::FormatError do
- # subtly bogus input
- Gem::Format.from_io(StringIO.new(@simple_gem.upcase))
- end
-
- assert_equal 'No metadata found!', e.message
-
- e = assert_raise Gem::Package::FormatError do
- # Totally bogus input
- Gem::Format.from_io(StringIO.new(@simple_gem.reverse))
- end
-
- assert_equal 'No metadata found!', e.message
-
- e = assert_raise Gem::Package::FormatError do
- # This was intentionally screws up YAML parsing.
- Gem::Format.from_io(StringIO.new(@simple_gem.gsub(/:/, "boom")))
- end
-
- assert_equal 'No metadata found!', e.message
- end
-
-end
-
-
diff --git a/test/rubygems/test_gem_gem_path_searcher.rb b/test/rubygems/test_gem_gem_path_searcher.rb
deleted file mode 100644
index d35416e867..0000000000
--- a/test/rubygems/test_gem_gem_path_searcher.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/gem_path_searcher'
-
-class Gem::GemPathSearcher
- attr_accessor :gemspecs
- attr_accessor :lib_dirs
-
- public :init_gemspecs
- public :matching_file
- public :lib_dirs_for
-end
-
-class TestGemGemPathSearcher < RubyGemTestCase
-
- def setup
- super
-
- @foo1 = quick_gem 'foo', '0.1' do |s|
- s.require_paths << 'lib2'
- s.files << 'lib/foo.rb'
- end
-
- path = File.join 'gems', @foo1.full_name, 'lib', 'foo.rb'
- write_file(path) { |fp| fp.puts "# #{path}" }
-
- @foo2 = quick_gem 'foo', '0.2'
- @bar1 = quick_gem 'bar', '0.1'
- @bar2 = quick_gem 'bar', '0.2'
-
- Gem.source_index = util_setup_source_info_cache @foo1, @foo2, @bar1, @bar2
-
- @gps = Gem::GemPathSearcher.new
- end
-
- def test_find
- assert_equal @foo1, @gps.find('foo')
- end
-
- def test_init_gemspecs
- assert_equal [@bar2, @bar1, @foo2, @foo1], @gps.init_gemspecs
- end
-
- def test_lib_dirs_for
- lib_dirs = @gps.lib_dirs_for(@foo1)
- expected = File.join @gemhome, 'gems', @foo1.full_name, '{lib,lib2}'
-
- assert_equal expected, lib_dirs
- end
-
- def test_matching_file
- assert !@gps.matching_file(@foo1, 'bar')
- assert @gps.matching_file(@foo1, 'foo')
- end
-
-end
-
diff --git a/test/rubygems/test_gem_gem_runner.rb b/test/rubygems/test_gem_gem_runner.rb
deleted file mode 100644
index 4e3239f015..0000000000
--- a/test/rubygems/test_gem_gem_runner.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/gem_runner'
-
-class TestGemGemRunner < RubyGemTestCase
-
- def test_do_configuration
- Gem.clear_paths
-
- temp_conf = File.join @tempdir, '.gemrc'
-
- other_gem_path = File.join @tempdir, 'other_gem_path'
- other_gem_home = File.join @tempdir, 'other_gem_home'
-
- Gem.ensure_gem_subdirectories other_gem_path
- Gem.ensure_gem_subdirectories other_gem_home
-
- File.open temp_conf, 'w' do |fp|
- fp.puts "gem: --commands"
- fp.puts "gemhome: #{other_gem_home}"
- fp.puts "gempath:"
- fp.puts " - #{other_gem_path}"
- fp.puts "rdoc: --all"
- end
-
- gr = Gem::GemRunner.new
- gr.send :do_configuration, %W[--config-file #{temp_conf}]
-
- assert_equal [other_gem_path, other_gem_home], Gem.path
- assert_equal %w[--commands], Gem::Command.extra_args
- assert_equal %w[--all], Gem::DocManager.configured_args
- end
-
-end
-
diff --git a/test/rubygems/test_gem_indexer.rb b/test/rubygems/test_gem_indexer.rb
deleted file mode 100644
index 9eb78500c9..0000000000
--- a/test/rubygems/test_gem_indexer.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-
-require 'rubygems/indexer'
-
-unless ''.respond_to? :to_xs then
- warn "Gem::Indexer tests are being skipped. Install builder gem."
-end
-
-class TestGemIndexer < RubyGemTestCase
-
- def setup
- super
-
- util_make_gems
-
- gems = File.join(@tempdir, 'gems')
- FileUtils.mkdir_p gems
- cache_gems = File.join @gemhome, 'cache', '*.gem'
- FileUtils.mv Dir[cache_gems], gems
-
- @indexer = Gem::Indexer.new @tempdir
- end
-
- def test_initialize
- assert_equal @tempdir, @indexer.dest_directory
- assert_equal File.join(Dir.tmpdir, "gem_generate_index_#{$$}"),
- @indexer.directory
- end
-
- def test_generate_index
- use_ui @ui do
- @indexer.generate_index
- end
-
- assert File.exist?(File.join(@tempdir, 'yaml'))
- assert File.exist?(File.join(@tempdir, 'yaml.Z'))
- assert File.exist?(File.join(@tempdir, "Marshal.#{@marshal_version}"))
- assert File.exist?(File.join(@tempdir, "Marshal.#{@marshal_version}.Z"))
-
- quickdir = File.join @tempdir, 'quick'
- marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
-
- assert File.directory?(quickdir)
- assert File.directory?(marshal_quickdir)
-
- assert_indexed quickdir, "index"
- assert_indexed quickdir, "index.rz"
-
- assert_indexed quickdir, "#{@a1.full_name}.gemspec.rz"
- assert_indexed quickdir, "#{@a2.full_name}.gemspec.rz"
- assert_indexed quickdir, "#{@b2.full_name}.gemspec.rz"
- assert_indexed quickdir, "#{@c1_2.full_name}.gemspec.rz"
-
- assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
- deny_indexed quickdir, "#{@pl1.full_name}.gemspec.rz"
-
- assert_indexed marshal_quickdir, "#{@a1.full_name}.gemspec.rz"
- assert_indexed marshal_quickdir, "#{@a2.full_name}.gemspec.rz"
-
- deny_indexed quickdir, "#{@c1_2.full_name}.gemspec"
- deny_indexed marshal_quickdir, "#{@c1_2.full_name}.gemspec"
- end
-
- def test_generate_index_ui
- use_ui @ui do
- @indexer.generate_index
- end
-
- expected = <<-EOF
-Generating index for 5 gems in #{@tempdir}
-.....
-Loaded all gems
-Generating master indexes (this may take a while)
- EOF
-
- assert_equal expected, @ui.output
- assert_equal '', @ui.error
- end
-
- def test_generate_index_contents
- use_ui @ui do
- @indexer.generate_index
- end
-
- yaml_path = File.join(@tempdir, 'yaml')
- dump_path = File.join(@tempdir, "Marshal.#{@marshal_version}")
-
- yaml_index = YAML.load_file(yaml_path)
- dump_str = nil
- File.open dump_path, 'rb' do |fp| dump_str = fp.read end
- dump_index = Marshal.load dump_str
-
- dump_index.each do |_,gem|
- gem.send :remove_instance_variable, :@loaded
- end
-
- assert_equal yaml_index, dump_index,
- "expected YAML and Marshal to produce identical results"
- end
-
- def assert_indexed(dir, name)
- file = File.join dir, name
- assert File.exist?(file), "#{file} does not exist"
- end
-
- def deny_indexed(dir, name)
- file = File.join dir, name
- assert !File.exist?(file), "#{file} exists"
- end
-
-end if ''.respond_to? :to_xs
-
diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb
deleted file mode 100644
index 8c7a5ce3f7..0000000000
--- a/test/rubygems/test_gem_install_update_options.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/install_update_options'
-require 'rubygems/command'
-
-class TestGemInstallUpdateOptions < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Command.new 'dummy', 'dummy'
- @cmd.extend Gem::InstallUpdateOptions
- end
-
- def test_add_install_update_options
- @cmd.add_install_update_options
-
- args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
- --ignore-dependencies --format-exec --include-dependencies]
-
- assert @cmd.handles?(args)
- end
-
- def test_security_policy
- @cmd.add_install_update_options
-
- @cmd.handle_options %w[-P HighSecurity]
-
- assert_equal Gem::Security::HighSecurity, @cmd.options[:security_policy]
- end
-
- def test_security_policy_unknown
- @cmd.add_install_update_options
-
- assert_raise OptionParser::InvalidArgument do
- @cmd.handle_options %w[-P UnknownSecurity]
- end
- end
-
-end
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
deleted file mode 100644
index 442ed6cfc3..0000000000
--- a/test/rubygems/test_gem_installer.rb
+++ /dev/null
@@ -1,885 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/installer'
-
-class Gem::Installer
- attr_accessor :gem_dir
-
- attr_writer :format
- attr_writer :gem_home
- attr_writer :env_shebang
- attr_writer :ignore_dependencies
- attr_writer :format_executable
- attr_writer :security_policy
- attr_writer :spec
- attr_writer :wrappers
-end
-
-class TestGemInstaller < RubyGemTestCase
-
- def setup
- super
-
- @spec = quick_gem "a"
- @gem = File.join @tempdir, "#{@spec.full_name}.gem"
-
- util_build_gem @spec
- FileUtils.mv File.join(@gemhome, 'cache', "#{@spec.full_name}.gem"),
- @tempdir
-
- @installer = Gem::Installer.new @gem
- @installer.gem_dir = util_gem_dir
- @installer.gem_home = @gemhome
- @installer.spec = @spec
- end
-
- def util_gem_dir(version = '2')
- File.join @gemhome, "gems", "a-#{version}" # HACK
- end
-
- def util_gem_bindir(version = '2')
- File.join util_gem_dir(version), "bin"
- end
-
- def util_inst_bindir
- File.join @gemhome, "bin"
- end
-
- def util_make_exec(version = '2', shebang = "#!/usr/bin/ruby")
- @spec.executables = ["my_exec"]
-
- FileUtils.mkdir_p util_gem_bindir(version)
- exec_file = @installer.formatted_program_filename "my_exec"
- exec_path = File.join util_gem_bindir(version), exec_file
- File.open exec_path, 'w' do |f|
- f.puts shebang
- end
- end
-
- def test_app_script_text
- util_make_exec '2', ''
-
- expected = <<-EOF
-#!#{Gem.ruby}
-#
-# This file was generated by RubyGems.
-#
-# The application 'a' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = \">= 0\"
-
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
- version = $1
- ARGV.shift
-end
-
-gem 'a', version
-load 'my_exec'
- EOF
-
- wrapper = @installer.app_script_text 'my_exec'
- assert_equal expected, wrapper
- end
-
- def test_build_extensions_none
- use_ui @ui do
- @installer.build_extensions
- end
-
- assert_equal '', @ui.output
- assert_equal '', @ui.error
-
- assert !File.exist?('gem_make.out')
- end
-
- def test_build_extensions_extconf_bad
- @spec.extensions << 'extconf.rb'
-
- e = assert_raise Gem::Installer::ExtensionBuildError do
- use_ui @ui do
- @installer.build_extensions
- end
- end
-
- assert_match(/\AERROR: Failed to build gem native extension.$/, e.message)
-
- assert_equal "Building native extensions. This could take a while...\n",
- @ui.output
- assert_equal '', @ui.error
-
- gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
- expected = <<-EOF
-#{Gem.ruby} extconf.rb
-#{Gem.ruby}: No such file or directory -- extconf.rb (LoadError)
- EOF
-
- assert_equal expected, File.read(gem_make_out)
- end
-
- def test_build_extensions_unsupported
- @spec.extensions << nil
-
- e = assert_raise Gem::Installer::ExtensionBuildError do
- use_ui @ui do
- @installer.build_extensions
- end
- end
-
- assert_match(/^No builder for extension ''$/, e.message)
-
- assert_equal "Building native extensions. This could take a while...\n",
- @ui.output
- assert_equal '', @ui.error
-
- assert_equal "No builder for extension ''\n", File.read('gem_make.out')
- ensure
- FileUtils.rm_f 'gem_make.out'
- end
-
- def test_ensure_dependency
- dep = Gem::Dependency.new 'a', '>= 2'
- assert @installer.ensure_dependency(@spec, dep)
-
- dep = Gem::Dependency.new 'b', '> 2'
- e = assert_raise Gem::InstallError do
- @installer.ensure_dependency @spec, dep
- end
-
- assert_equal 'a requires b (> 2)', e.message
- end
-
- def test_expand_and_validate_gem_dir
- @installer.gem_dir = '/nonexistent'
- expanded_gem_dir = @installer.send(:expand_and_validate_gem_dir)
- if win_platform?
- expected = File.join(Config::CONFIG['bindir'][0..2], 'nonexistent').downcase
- expanded_gem_dir = expanded_gem_dir.downcase
- else
- expected = '/nonexistent'
- end
-
- assert_equal expected, expanded_gem_dir
- end
-
- def test_extract_files
- format = Object.new
- def format.file_entries
- [[{'size' => 7, 'mode' => 0400, 'path' => 'thefile'}, 'thefile']]
- end
-
- @installer.format = format
-
- @installer.extract_files
-
- assert_equal 'thefile', File.read(File.join(util_gem_dir, 'thefile'))
- end
-
- def test_extract_files_bad_dest
- @installer.gem_dir = 'somedir'
- @installer.format = nil
- e = assert_raise ArgumentError do
- @installer.extract_files
- end
-
- assert_equal 'format required to extract from', e.message
- end
-
- def test_extract_files_relative
- format = Object.new
- def format.file_entries
- [[{'size' => 10, 'mode' => 0644, 'path' => '../thefile'}, '../thefile']]
- end
-
- @installer.format = format
-
- e = assert_raise Gem::InstallError do
- @installer.extract_files
- end
-
- assert_equal "attempt to install file into \"../thefile\" under #{util_gem_dir.inspect}",
- e.message
- assert_equal false, File.file?(File.join(@tempdir, '../thefile')),
- "You may need to remove this file if you broke the test once"
- end
-
- def test_extract_files_absolute
- format = Object.new
- def format.file_entries
- [[{'size' => 8, 'mode' => 0644, 'path' => '/thefile'}, '/thefile']]
- end
-
- @installer.format = format
-
- e = assert_raise Gem::InstallError do
- @installer.extract_files
- end
-
- assert_equal 'attempt to install file into "/thefile"', e.message
- assert_equal false, File.file?(File.join('/thefile')),
- "You may need to remove this file if you broke the test once"
- end
-
- def test_generate_bin_bindir
- @installer.wrappers = true
-
- @spec.executables = ["my_exec"]
- @spec.bindir = '.'
-
- exec_file = @installer.formatted_program_filename "my_exec"
- exec_path = File.join util_gem_dir(@spec.version), exec_file
- File.open exec_path, 'w' do |f|
- f.puts '#!/usr/bin/ruby'
- end
-
- @installer.gem_dir = util_gem_dir
-
- @installer.generate_bin
-
- assert_equal true, File.directory?(util_inst_bindir)
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal true, File.exist?(installed_exec)
- assert_equal(0100755, File.stat(installed_exec).mode) unless win_platform?
-
- wrapper = File.read installed_exec
- assert_match %r|generated by RubyGems|, wrapper
- end
-
- def test_generate_bin_script
- @installer.wrappers = true
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- @installer.generate_bin
- assert_equal true, File.directory?(util_inst_bindir)
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal true, File.exist?(installed_exec)
- assert_equal(0100755, File.stat(installed_exec).mode) unless win_platform?
-
- wrapper = File.read installed_exec
- assert_match %r|generated by RubyGems|, wrapper
- end
-
- def test_generate_bin_script_format
- @installer.format_executable = true
- @installer.wrappers = true
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- Gem::Installer.exec_format = 'foo-%s-bar'
- @installer.generate_bin
- assert_equal true, File.directory?(util_inst_bindir)
- installed_exec = File.join util_inst_bindir, 'foo-my_exec-bar'
- assert_equal true, File.exist?(installed_exec)
- ensure
- Gem::Installer.exec_format = nil
- end
-
- def test_generate_bin_script_format_disabled
- @installer.wrappers = true
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- Gem::Installer.exec_format = 'foo-%s-bar'
- @installer.generate_bin
- assert_equal true, File.directory?(util_inst_bindir)
- installed_exec = File.join util_inst_bindir, 'my_exec'
- assert_equal true, File.exist?(installed_exec)
- ensure
- Gem::Installer.exec_format = nil
- end
-
- def test_generate_bin_script_install_dir
- @installer.wrappers = true
- @spec.executables = ["my_exec"]
-
- gem_dir = File.join "#{@gemhome}2", 'gems', @spec.full_name
- gem_bindir = File.join gem_dir, 'bin'
- FileUtils.mkdir_p gem_bindir
- File.open File.join(gem_bindir, "my_exec"), 'w' do |f|
- f.puts "#!/bin/ruby"
- end
-
- @installer.gem_home = "#{@gemhome}2"
- @installer.gem_dir = gem_dir
-
- @installer.generate_bin
-
- installed_exec = File.join("#{@gemhome}2", 'bin', 'my_exec')
- assert_equal true, File.exist?(installed_exec)
- assert_equal(0100755, File.stat(installed_exec).mode) unless win_platform?
-
- wrapper = File.read installed_exec
- assert_match %r|generated by RubyGems|, wrapper
- end
-
- def test_generate_bin_script_no_execs
- @installer.wrappers = true
- @installer.generate_bin
- assert_equal false, File.exist?(util_inst_bindir)
- end
-
- def test_generate_bin_script_no_perms
- @installer.wrappers = true
- util_make_exec
-
- Dir.mkdir util_inst_bindir
- File.chmod 0000, util_inst_bindir
-
- assert_raises Gem::FilePermissionError do
- @installer.generate_bin
- end
-
- ensure
- File.chmod 0700, util_inst_bindir unless $DEBUG
- end
-
- def test_generate_bin_script_no_shebang
- @installer.wrappers = true
- @spec.executables = ["my_exec"]
-
- gem_dir = File.join @gemhome, 'gems', @spec.full_name
- gem_bindir = File.join gem_dir, 'bin'
- FileUtils.mkdir_p gem_bindir
- File.open File.join(gem_bindir, "my_exec"), 'w' do |f|
- f.puts "blah blah blah"
- end
-
- @installer.generate_bin
-
- installed_exec = File.join @gemhome, 'bin', 'my_exec'
- assert_equal true, File.exist?(installed_exec)
- assert_equal 0100755, File.stat(installed_exec).mode unless win_platform?
-
- wrapper = File.read installed_exec
- assert_match %r|generated by RubyGems|, wrapper
- # HACK some gems don't have #! in their executables, restore 2008/06
- #assert_no_match %r|generated by RubyGems|, wrapper
- end
-
- def test_generate_bin_symlink
- return if win_platform? #Windows FS do not support symlinks
-
- @installer.wrappers = false
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- @installer.generate_bin
- assert_equal true, File.directory?(util_inst_bindir)
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal true, File.symlink?(installed_exec)
- assert_equal(File.join(util_gem_dir, "bin", "my_exec"),
- File.readlink(installed_exec))
- end
-
- def test_generate_bin_symlink_no_execs
- @installer.wrappers = false
- @installer.generate_bin
- assert_equal false, File.exist?(util_inst_bindir)
- end
-
- def test_generate_bin_symlink_no_perms
- @installer.wrappers = false
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- Dir.mkdir util_inst_bindir
- File.chmod 0000, util_inst_bindir
-
- assert_raises Gem::FilePermissionError do
- @installer.generate_bin
- end
-
- ensure
- File.chmod 0700, util_inst_bindir unless $DEBUG
- end
-
- def test_generate_bin_symlink_update_newer
- return if win_platform? #Windows FS do not support symlinks
-
- @installer.wrappers = false
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- @installer.generate_bin
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal(File.join(util_gem_dir, "bin", "my_exec"),
- File.readlink(installed_exec))
-
- @spec = Gem::Specification.new do |s|
- s.files = ['lib/code.rb']
- s.name = "a"
- s.version = "3"
- s.summary = "summary"
- s.description = "desc"
- s.require_path = 'lib'
- end
-
- util_make_exec '3'
- @installer.gem_dir = File.join util_gem_dir('3')
- @installer.generate_bin
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal(File.join(util_gem_bindir('3'), "my_exec"),
- File.readlink(installed_exec),
- "Ensure symlink moved to latest version")
- end
-
- def test_generate_bin_symlink_update_older
- return if win_platform? #Windows FS do not support symlinks
-
- @installer.wrappers = false
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- @installer.generate_bin
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal(File.join(util_gem_dir, "bin", "my_exec"),
- File.readlink(installed_exec))
-
- spec = Gem::Specification.new do |s|
- s.files = ['lib/code.rb']
- s.name = "a"
- s.version = "1"
- s.summary = "summary"
- s.description = "desc"
- s.require_path = 'lib'
- end
-
- util_make_exec '1'
- @installer.gem_dir = util_gem_dir('1')
- @installer.spec = spec
-
- @installer.generate_bin
-
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal(File.join(util_gem_dir('2'), "bin", "my_exec"),
- File.readlink(installed_exec),
- "Ensure symlink not moved")
- end
-
- def test_generate_bin_symlink_update_remove_wrapper
- return if win_platform? #Windows FS do not support symlinks
-
- @installer.wrappers = true
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- @installer.generate_bin
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal true, File.exist?(installed_exec)
-
- @spec = Gem::Specification.new do |s|
- s.files = ['lib/code.rb']
- s.name = "a"
- s.version = "3"
- s.summary = "summary"
- s.description = "desc"
- s.require_path = 'lib'
- end
-
- @installer.wrappers = false
- util_make_exec '3'
- @installer.gem_dir = util_gem_dir '3'
- @installer.generate_bin
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal(File.join(util_gem_dir('3'), "bin", "my_exec"),
- File.readlink(installed_exec),
- "Ensure symlink moved to latest version")
- end
-
- def test_generate_bin_symlink_win32
- old_win_platform = Gem.win_platform?
- Gem.win_platform = true
- @installer.wrappers = false
- util_make_exec
- @installer.gem_dir = util_gem_dir
-
- use_ui @ui do
- @installer.generate_bin
- end
-
- assert_equal true, File.directory?(util_inst_bindir)
- installed_exec = File.join(util_inst_bindir, "my_exec")
- assert_equal true, File.exist?(installed_exec)
-
- assert_match(/Unable to use symlinks on Windows, installing wrapper/i,
- @ui.error)
-
- wrapper = File.read installed_exec
- assert_match(/generated by RubyGems/, wrapper)
- ensure
- Gem.win_platform = old_win_platform
- end
-
- def test_generate_bin_uses_default_shebang
- return if win_platform? #Windows FS do not support symlinks
-
- @installer.wrappers = true
- util_make_exec
-
- @installer.generate_bin
-
- default_shebang = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- shebang_line = open("#{@gemhome}/bin/my_exec") { |f| f.readlines.first }
- assert_match(/\A#!/, shebang_line)
- assert_match(/#{default_shebang}/, shebang_line)
- end
-
- def test_initialize
- spec = quick_gem 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
- gem = File.join @tempdir, "#{spec.full_name}.gem"
-
- util_build_gem spec
- FileUtils.mv File.join(@gemhome, 'cache', "#{spec.full_name}.gem"),
- @tempdir
-
- installer = Gem::Installer.new gem
-
- assert_equal File.join(@gemhome, 'gems', spec.full_name), installer.gem_dir
- end
-
- def test_install
- util_setup_gem
-
- use_ui @ui do
- assert_equal @spec, @installer.install
- end
-
- gemdir = File.join @gemhome, 'gems', @spec.full_name
- assert File.exist?(gemdir)
-
- exe = File.join(gemdir, 'bin', 'executable')
- assert File.exist?(exe)
- exe_mode = File.stat(exe).mode & 0111
- assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform?
-
- assert File.exist?(File.join(gemdir, 'lib', 'code.rb'))
-
- assert File.exist?(File.join(gemdir, 'ext', 'a', 'Rakefile'))
-
- spec_file = File.join(@gemhome, 'specifications',
- "#{@spec.full_name}.gemspec")
-
- assert_equal spec_file, @spec.loaded_from
- assert File.exist?(spec_file)
- end
-
- def test_install_bad_gem
- gem = nil
-
- use_ui @ui do
- Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
- gem = File.join @tempdir, "#{@spec.full_name}.gem"
- end
-
- gem_data = File.open gem, 'rb' do |fp| fp.read 1024 end
- File.open gem, 'wb' do |fp| fp.write gem_data end
-
- e = assert_raise Gem::InstallError do
- use_ui @ui do
- @installer = Gem::Installer.new gem
- @installer.install
- end
- end
-
- assert_equal "invalid gem format for #{gem}", e.message
- end
-
- def test_install_check_dependencies
- @spec.add_dependency 'b', '> 5'
- util_setup_gem
-
- use_ui @ui do
- assert_raise Gem::InstallError do
- @installer.install
- end
- end
- end
-
- def test_install_force
- use_ui @ui do
- installer = Gem::Installer.new old_ruby_required, :force => true
- installer.install
- end
-
- gem_dir = File.join(@gemhome, 'gems', 'old_ruby_required-1')
- assert File.exist?(gem_dir)
- end
-
- def test_install_ignore_dependencies
- @spec.add_dependency 'b', '> 5'
- util_setup_gem
- @installer.ignore_dependencies = true
-
- use_ui @ui do
- assert_equal @spec, @installer.install
- end
-
- gemdir = File.join @gemhome, 'gems', @spec.full_name
- assert File.exist?(gemdir)
-
- exe = File.join(gemdir, 'bin', 'executable')
- assert File.exist?(exe)
- exe_mode = File.stat(exe).mode & 0111
- assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform?
- assert File.exist?(File.join(gemdir, 'lib', 'code.rb'))
-
- assert File.exist?(File.join(@gemhome, 'specifications',
- "#{@spec.full_name}.gemspec"))
- end
-
- def test_install_missing_dirs
- FileUtils.rm_f File.join(Gem.dir, 'cache')
- FileUtils.rm_f File.join(Gem.dir, 'docs')
- FileUtils.rm_f File.join(Gem.dir, 'specifications')
-
- use_ui @ui do
- Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
- gem = File.join @tempdir, "#{@spec.full_name}.gem"
-
- @installer.install
- end
-
- File.directory? File.join(Gem.dir, 'cache')
- File.directory? File.join(Gem.dir, 'docs')
- File.directory? File.join(Gem.dir, 'specifications')
-
- assert File.exist?(File.join(@gemhome, 'cache', "#{@spec.full_name}.gem"))
- assert File.exist?(File.join(@gemhome, 'specifications',
- "#{@spec.full_name}.gemspec"))
- end
-
- def test_install_with_message
- @spec.post_install_message = 'I am a shiny gem!'
-
- use_ui @ui do
- Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
-
- @installer.install
- end
-
- assert_match %r|I am a shiny gem!|, @ui.output
- end
-
- def test_install_writable
- util_setup_gem
-
- orig_mode = File.stat(Gem.dir).mode
- File.chmod 0000, Gem.dir
-
- e = assert_raise Gem::FilePermissionError do
- @installer.install
- end
-
- assert_equal "You don't have write permissions into the #{@gemhome} directory.",
- e.message
- ensure
- File.chmod orig_mode, Gem.dir
- end
-
- def test_install_wrong_ruby_version
- use_ui @ui do
- installer = Gem::Installer.new old_ruby_required
- e = assert_raise Gem::InstallError do
- installer.install
- end
- assert_equal 'old_ruby_required requires Ruby version = 1.4.6',
- e.message
- end
- end
-
- def test_install_wrong_rubygems_version
- spec = quick_gem 'old_rubygems_required', '1' do |s|
- s.required_rubygems_version = '< 0'
- end
-
- util_build_gem spec
-
- gem = File.join @gemhome, 'cache', "#{spec.full_name}.gem"
-
- use_ui @ui do
- @installer = Gem::Installer.new gem
- e = assert_raise Gem::InstallError do
- @installer.install
- end
- assert_equal 'old_rubygems_required requires RubyGems version < 0',
- e.message
- end
- end
-
- def test_installation_satisfies_dependency_eh
- dep = Gem::Dependency.new 'a', '>= 2'
- assert @installer.installation_satisfies_dependency?(dep)
-
- dep = Gem::Dependency.new 'a', '> 2'
- assert ! @installer.installation_satisfies_dependency?(dep)
- end
-
- def test_shebang
- util_make_exec '2', "#!/usr/bin/ruby"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby}", shebang
- end
-
- def test_shebang_arguments
- util_make_exec '2', "#!/usr/bin/ruby -ws"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby} -ws", shebang
- end
-
- def test_shebang_empty
- util_make_exec '2', ''
-
- shebang = @installer.shebang 'my_exec'
- assert_equal "#!#{Gem.ruby}", shebang
- end
-
- def test_shebang_env
- util_make_exec '2', "#!/usr/bin/env ruby"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby}", shebang
- end
-
- def test_shebang_env_arguments
- util_make_exec '2', "#!/usr/bin/env ruby -ws"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby} -ws", shebang
- end
-
- def test_shebang_env_shebang
- util_make_exec '2', ''
- @installer.env_shebang = true
-
- shebang = @installer.shebang 'my_exec'
- assert_equal "#!/usr/bin/env ruby", shebang
- end
-
- def test_shebang_nested
- util_make_exec '2', "#!/opt/local/ruby/bin/ruby"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby}", shebang
- end
-
- def test_shebang_nested_arguments
- util_make_exec '2', "#!/opt/local/ruby/bin/ruby -ws"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby} -ws", shebang
- end
-
- def test_shebang_version
- util_make_exec '2', "#!/usr/bin/ruby18"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby}", shebang
- end
-
- def test_shebang_version_arguments
- util_make_exec '2', "#!/usr/bin/ruby18 -ws"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby} -ws", shebang
- end
-
- def test_shebang_version_env
- util_make_exec '2', "#!/usr/bin/env ruby18"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby}", shebang
- end
-
- def test_shebang_version_env_arguments
- util_make_exec '2', "#!/usr/bin/env ruby18 -ws"
-
- shebang = @installer.shebang 'my_exec'
-
- assert_equal "#!#{Gem.ruby} -ws", shebang
- end
-
- def test_unpack
- util_setup_gem
-
- dest = File.join @gemhome, 'gems', @spec.full_name
-
- @installer.unpack dest
-
- assert File.exist?(File.join(dest, 'lib', 'code.rb'))
- assert File.exist?(File.join(dest, 'bin', 'executable'))
- end
-
- def test_write_spec
- spec_dir = File.join @gemhome, 'specifications'
- spec_file = File.join spec_dir, "#{@spec.full_name}.gemspec"
- FileUtils.rm spec_file
- assert !File.exist?(spec_file)
-
- @installer.spec = @spec
- @installer.gem_home = @gemhome
-
- @installer.write_spec
-
- assert File.exist?(spec_file)
- assert_equal @spec, eval(File.read(spec_file))
- end
-
- def old_ruby_required
- spec = quick_gem 'old_ruby_required', '1' do |s|
- s.required_ruby_version = '= 1.4.6'
- end
-
- util_build_gem spec
-
- File.join @gemhome, 'cache', "#{spec.full_name}.gem"
- end
-
- def util_setup_gem
- @spec.files = File.join('lib', 'code.rb')
- @spec.executables << 'executable'
- @spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb')
-
- Dir.chdir @tempdir do
- FileUtils.mkdir_p 'bin'
- FileUtils.mkdir_p 'lib'
- FileUtils.mkdir_p File.join('ext', 'a')
- File.open File.join('bin', 'executable'), 'w' do |f| f.puts '1' end
- File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
- File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
- f << <<-EOF
- File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
- EOF
- end
-
- use_ui @ui do
- FileUtils.rm @gem
- Gem::Builder.new(@spec).build
- end
- end
-
- @installer = Gem::Installer.new @gem
- end
-
-end
-
diff --git a/test/rubygems/test_gem_local_remote_options.rb b/test/rubygems/test_gem_local_remote_options.rb
deleted file mode 100644
index d5a6651ade..0000000000
--- a/test/rubygems/test_gem_local_remote_options.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/local_remote_options'
-require 'rubygems/command'
-
-class TestGemLocalRemoteOptions < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Command.new 'dummy', 'dummy'
- @cmd.extend Gem::LocalRemoteOptions
- end
-
- def test_add_local_remote_options
- @cmd.add_local_remote_options
-
- args = %w[-l -r -b -B 10 --source http://gems.example.com -p --update-sources]
- assert @cmd.handles?(args)
- end
-
- def test_local_eh
- assert_equal false, @cmd.local?
-
- @cmd.options[:domain] = :local
-
- assert_equal true, @cmd.local?
-
- @cmd.options[:domain] = :both
-
- assert_equal true, @cmd.local?
- end
-
- def test_remote_eh
- assert_equal false, @cmd.remote?
-
- @cmd.options[:domain] = :remote
-
- assert_equal true, @cmd.remote?
-
- @cmd.options[:domain] = :both
-
- assert_equal true, @cmd.remote?
- end
-
- def test_source_option
- @cmd.add_source_option
-
- s1 = URI.parse 'http://more-gems.example.com'
- s2 = URI.parse 'http://even-more-gems.example.com'
-
- @cmd.handle_options %W[--source #{s1} --source #{s2}]
-
- assert_equal [s1, s2], Gem.sources
- end
-
- def test_update_sources_option
- @cmd.add_update_sources_option
-
- Gem.configuration.update_sources = false
-
- @cmd.handle_options %W[--update-sources]
-
- assert_equal true, Gem.configuration.update_sources
-
- @cmd.handle_options %W[--no-update-sources]
-
- assert_equal false, Gem.configuration.update_sources
- end
-
- def test_source_option_bad
- @cmd.add_source_option
-
- s1 = 'htp://more-gems.example.com'
-
- assert_raise OptionParser::InvalidArgument do
- @cmd.handle_options %W[--source #{s1}]
- end
-
- assert_equal %w[http://gems.example.com], Gem.sources
- end
-
-end
-
diff --git a/test/rubygems/test_gem_outdated_command.rb b/test/rubygems/test_gem_outdated_command.rb
deleted file mode 100644
index adcc4d1980..0000000000
--- a/test/rubygems/test_gem_outdated_command.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/commands/outdated_command'
-
-class TestGemOutdatedCommand < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Commands::OutdatedCommand.new
- end
-
- def test_initialize
- assert @cmd.handles?(%W[--platform #{Gem::Platform.local}])
- end
-
- def test_execute
- local_01 = quick_gem 'foo', '0.1'
- local_02 = quick_gem 'foo', '0.2'
- remote_10 = quick_gem 'foo', '1.0'
- remote_20 = quick_gem 'foo', '2.0'
-
- remote_spec_file = File.join @gemhome, 'specifications',
- remote_10.full_name + ".gemspec"
- FileUtils.rm remote_spec_file
-
- remote_spec_file = File.join @gemhome, 'specifications',
- remote_20.full_name + ".gemspec"
- FileUtils.rm remote_spec_file
-
- util_setup_source_info_cache remote_10, remote_20
-
- use_ui @ui do @cmd.execute end
-
- assert_equal "foo (0.2 < 2.0)\n", @ui.output
- assert_equal "", @ui.error
- end
-
-end
-
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
deleted file mode 100644
index 648c2a9f36..0000000000
--- a/test/rubygems/test_gem_platform.rb
+++ /dev/null
@@ -1,259 +0,0 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'test/unit'
-require 'rubygems/platform'
-require 'rbconfig'
-
-class TestGemPlatform < RubyGemTestCase
-
- def test_self_const_missing
- consts = [:DARWIN, :LINUX_586, :MSWIN32, :PPC_DARWIN, :WIN32, :X86_LINUX]
-
- consts.each do |const|
- e = assert_raise NameError do
- Gem::Platform.const_missing const
- end
-
- assert_equal "#{const} has been removed, use CURRENT instead",
- e.message
- end
- end
-
- def test_self_local
- util_set_arch 'i686-darwin8.10.1'
-
- assert_equal Gem::Platform.new(%w[x86 darwin 8]), Gem::Platform.local
- end
-
- def test_self_match
- assert Gem::Platform.match(nil), 'nil == ruby'
- assert Gem::Platform.match(Gem::Platform.local), 'exact match'
- assert Gem::Platform.match(Gem::Platform.local.to_s), '=~ match'
- assert Gem::Platform.match(Gem::Platform::RUBY), 'ruby'
- end
-
- def test_self_new
- assert_equal Gem::Platform.local, Gem::Platform.new(Gem::Platform::CURRENT)
- assert_equal Gem::Platform::RUBY, Gem::Platform.new(Gem::Platform::RUBY)
- assert_equal Gem::Platform::RUBY, Gem::Platform.new(nil)
- assert_equal Gem::Platform::RUBY, Gem::Platform.new('')
- end
-
- def test_initialize
- test_cases = {
- 'amd64-freebsd6' => ['amd64', 'freebsd', '6'],
- 'hppa2.0w-hpux11.31' => ['hppa2.0w', 'hpux', '11'],
- 'java' => [nil, 'java', nil],
- 'jruby' => [nil, 'java', nil],
- 'powerpc-aix5.3.0.0' => ['powerpc', 'aix', '5'],
- 'powerpc-darwin7' => ['powerpc', 'darwin', '7'],
- 'powerpc-darwin8' => ['powerpc', 'darwin', '8'],
- 'powerpc-linux' => ['powerpc', 'linux', nil],
- 'powerpc64-linux' => ['powerpc64', 'linux', nil],
- 'sparc-solaris2.10' => ['sparc', 'solaris', '2.10'],
- 'sparc-solaris2.8' => ['sparc', 'solaris', '2.8'],
- 'sparc-solaris2.9' => ['sparc', 'solaris', '2.9'],
- 'universal-darwin8' => ['universal', 'darwin', '8'],
- 'universal-darwin9' => ['universal', 'darwin', '9'],
- 'i386-cygwin' => ['x86', 'cygwin', nil],
- 'i686-darwin' => ['x86', 'darwin', nil],
- 'i686-darwin8.4.1' => ['x86', 'darwin', '8'],
- 'i386-freebsd4.11' => ['x86', 'freebsd', '4'],
- 'i386-freebsd5' => ['x86', 'freebsd', '5'],
- 'i386-freebsd6' => ['x86', 'freebsd', '6'],
- 'i386-freebsd7' => ['x86', 'freebsd', '7'],
- 'i386-java1.5' => ['x86', 'java', '1.5'],
- 'x86-java1.6' => ['x86', 'java', '1.6'],
- 'i386-java1.6' => ['x86', 'java', '1.6'],
- 'i686-linux' => ['x86', 'linux', nil],
- 'i586-linux' => ['x86', 'linux', nil],
- 'i486-linux' => ['x86', 'linux', nil],
- 'i386-linux' => ['x86', 'linux', nil],
- 'i586-linux-gnu' => ['x86', 'linux', nil],
- 'i386-linux-gnu' => ['x86', 'linux', nil],
- 'i386-mingw32' => ['x86', 'mingw32', nil],
- 'i386-mswin32' => ['x86', 'mswin32', nil],
- 'i386-mswin32_80' => ['x86', 'mswin32', '80'],
- 'i386-mswin32-80' => ['x86', 'mswin32', '80'],
- 'x86-mswin32' => ['x86', 'mswin32', nil],
- 'x86-mswin32_60' => ['x86', 'mswin32', '60'],
- 'x86-mswin32-60' => ['x86', 'mswin32', '60'],
- 'i386-netbsdelf' => ['x86', 'netbsdelf', nil],
- 'i386-openbsd4.0' => ['x86', 'openbsd', '4.0'],
- 'i386-solaris2.10' => ['x86', 'solaris', '2.10'],
- 'i386-solaris2.8' => ['x86', 'solaris', '2.8'],
- 'mswin32' => ['x86', 'mswin32', nil],
- 'x86_64-linux' => ['x86_64', 'linux', nil],
- 'x86_64-openbsd3.9' => ['x86_64', 'openbsd', '3.9'],
- 'x86_64-openbsd4.0' => ['x86_64', 'openbsd', '4.0'],
- }
-
- test_cases.each do |arch, expected|
- platform = Gem::Platform.new arch
- assert_equal expected, platform.to_a, arch.inspect
- end
- end
-
- def test_initialize_command_line
- expected = ['x86', 'mswin32', nil]
-
- platform = Gem::Platform.new 'i386-mswin32'
-
- assert_equal expected, platform.to_a, 'i386-mswin32'
-
- expected = ['x86', 'mswin32', '80']
-
- platform = Gem::Platform.new 'i386-mswin32-80'
-
- assert_equal expected, platform.to_a, 'i386-mswin32-80'
- end
-
- def test_initialize_mswin32_vc6
- orig_RUBY_SO_NAME = Config::CONFIG['RUBY_SO_NAME']
- Config::CONFIG['RUBY_SO_NAME'] = 'msvcrt-ruby18'
-
- expected = ['x86', 'mswin32', nil]
-
- platform = Gem::Platform.new 'i386-mswin32'
-
- assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
- ensure
- Config::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
- end
-
- def test_initialize_platform
- platform = Gem::Platform.new 'cpu-my_platform1'
- expected = Gem::Platform.new platform
-
- assert_equal 'cpu', platform.cpu
- assert_equal 'my_platform', platform.os
- assert_equal '1', platform.version
- end
-
- def test_initialize_test
- platform = Gem::Platform.new 'cpu-my_platform1'
- assert_equal 'cpu', platform.cpu
- assert_equal 'my_platform', platform.os
- assert_equal '1', platform.version
-
- platform = Gem::Platform.new 'cpu-other_platform1'
- assert_equal 'cpu', platform.cpu
- assert_equal 'other_platform', platform.os
- assert_equal '1', platform.version
- end
-
- def test_to_s
- if win_platform? then
- assert_equal 'x86-mswin32-60', Gem::Platform.local.to_s
- else
- assert_equal 'x86-darwin-8', Gem::Platform.local.to_s
- end
- end
-
- def test_equals2
- my = Gem::Platform.new %w[cpu my_platform 1]
- other = Gem::Platform.new %w[cpu other_platform 1]
-
- assert_equal my, my
- assert_not_equal my, other
- assert_not_equal other, my
- end
-
- def test_equals3
- my = Gem::Platform.new %w[cpu my_platform 1]
- other = Gem::Platform.new %w[cpu other_platform 1]
-
- assert(my === my)
- assert !(other === my)
- assert !(my === other)
- end
-
- def test_equals3_cpu
- ppc_darwin8 = Gem::Platform.new 'powerpc-darwin8.0'
- uni_darwin8 = Gem::Platform.new 'universal-darwin8.0'
- x86_darwin8 = Gem::Platform.new 'i686-darwin8.0'
-
- util_set_arch 'powerpc-darwin8'
- assert((ppc_darwin8 === Gem::Platform.local), 'powerpc =~ universal')
- assert((uni_darwin8 === Gem::Platform.local), 'powerpc =~ universal')
- assert !(x86_darwin8 === Gem::Platform.local), 'powerpc =~ universal'
-
- util_set_arch 'i686-darwin8'
- assert !(ppc_darwin8 === Gem::Platform.local), 'powerpc =~ universal'
- assert((uni_darwin8 === Gem::Platform.local), 'x86 =~ universal')
- assert((x86_darwin8 === Gem::Platform.local), 'powerpc =~ universal')
-
- util_set_arch 'universal-darwin8'
- assert((ppc_darwin8 === Gem::Platform.local), 'universal =~ ppc')
- assert((uni_darwin8 === Gem::Platform.local), 'universal =~ universal')
- assert((x86_darwin8 === Gem::Platform.local), 'universal =~ x86')
- end
-
- def test_equals3_version
- util_set_arch 'i686-darwin8'
-
- x86_darwin = Gem::Platform.new ['x86', 'darwin', nil]
- x86_darwin7 = Gem::Platform.new ['x86', 'darwin', '7']
- x86_darwin8 = Gem::Platform.new ['x86', 'darwin', '8']
- x86_darwin9 = Gem::Platform.new ['x86', 'darwin', '9']
-
- assert((x86_darwin === Gem::Platform.local), 'x86_darwin === x86_darwin8')
- assert((x86_darwin8 === Gem::Platform.local), 'x86_darwin8 === x86_darwin8')
-
- assert !(x86_darwin7 === Gem::Platform.local), 'x86_darwin7 === x86_darwin8'
- assert !(x86_darwin9 === Gem::Platform.local), 'x86_darwin9 === x86_darwin8'
- end
-
- def test_equals_tilde
- util_set_arch 'i386-mswin32'
-
- assert_match 'mswin32', Gem::Platform.local
- assert_match 'i386-mswin32', Gem::Platform.local
-
- # oddballs
- assert_match 'i386-mswin32-mq5.3', Gem::Platform.local
- assert_match 'i386-mswin32-mq6', Gem::Platform.local
- deny_match 'win32-1.8.2-VC7', Gem::Platform.local
- deny_match 'win32-1.8.4-VC6', Gem::Platform.local
- deny_match 'win32-source', Gem::Platform.local
- deny_match 'windows', Gem::Platform.local
-
- util_set_arch 'i686-linux'
- assert_match 'i486-linux', Gem::Platform.local
- assert_match 'i586-linux', Gem::Platform.local
- assert_match 'i686-linux', Gem::Platform.local
-
- util_set_arch 'i686-darwin8'
- assert_match 'i686-darwin8.4.1', Gem::Platform.local
- assert_match 'i686-darwin8.8.2', Gem::Platform.local
-
- util_set_arch 'java'
- assert_match 'java', Gem::Platform.local
- assert_match 'jruby', Gem::Platform.local
-
- util_set_arch 'powerpc-darwin'
- assert_match 'powerpc-darwin', Gem::Platform.local
-
- util_set_arch 'powerpc-darwin7'
- assert_match 'powerpc-darwin7.9.0', Gem::Platform.local
-
- util_set_arch 'powerpc-darwin8'
- assert_match 'powerpc-darwin8.10.0', Gem::Platform.local
-
- util_set_arch 'sparc-solaris2.8'
- assert_match 'sparc-solaris2.8-mq5.3', Gem::Platform.local
- end
-
- def assert_match(pattern, platform, message = '')
- full_message = build_message message, "<?> expected to be =~\n<?>.",
- platform, pattern
- assert_block(full_message) { platform =~ pattern }
- end
-
- def deny_match(pattern, platform, message = '')
- full_message = build_message message, "<?> expected to be !~\n<?>.",
- platform, pattern
- assert_block(full_message) { platform !~ pattern }
- end
-
-end
-
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
deleted file mode 100644
index fd3843851a..0000000000
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ /dev/null
@@ -1,434 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'webrick'
-require 'zlib'
-require 'rubygems/remote_fetcher'
-
-# = Testing Proxy Settings
-#
-# These tests check the proper proxy server settings by running two
-# web servers. The web server at http://localhost:#{SERVER_PORT}
-# represents the normal gem server and returns a gemspec with a rake
-# version of 0.4.11. The web server at http://localhost:#{PROXY_PORT}
-# represents the proxy server and returns a different dataset where
-# rake has version 0.4.2. This allows us to detect which server is
-# returning the data.
-#
-# Note that the proxy server is not a *real* proxy server. But our
-# software doesn't really care, as long as we hit the proxy URL when a
-# proxy is configured.
-#
-class TestGemRemoteFetcher < RubyGemTestCase
-
- include Gem::DefaultUserInteraction
-
- SERVER_DATA = <<-EOY
---- !ruby/object:Gem::Cache
-gems:
- rake-0.4.11: !ruby/object:Gem::Specification
- rubygems_version: "0.7"
- specification_version: 1
- name: rake
- version: !ruby/object:Gem::Version
- version: 0.4.11
- date: 2004-11-12
- summary: Ruby based make-like utility.
- require_paths:
- - lib
- author: Jim Weirich
- email: jim@weirichhouse.org
- homepage: http://rake.rubyforge.org
- rubyforge_project: rake
- description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
- autorequire:
- default_executable: rake
- bindir: bin
- has_rdoc: true
- required_ruby_version: !ruby/object:Gem::Version::Requirement
- requirements:
- -
- - ">"
- - !ruby/object:Gem::Version
- version: 0.0.0
- version:
- platform: ruby
- files:
- - README
- test_files: []
- library_stubs:
- rdoc_options:
- extra_rdoc_files:
- executables:
- - rake
- extensions: []
- requirements: []
- dependencies: []
- EOY
-
- PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, '0.4.2')
-
- # don't let 1.8 and 1.9 autotest collide
- RUBY_VERSION =~ /(\d+)\.(\d+)\.(\d+)/
- PROXY_PORT = 12345 + $1.to_i * 100 + $2.to_i * 10 + $3.to_i
- SERVER_PORT = 23456 + $1.to_i * 100 + $2.to_i * 10 + $3.to_i
-
- def setup
- super
- self.class.start_servers
- self.class.enable_yaml = true
- self.class.enable_zip = false
- ENV.delete 'http_proxy'
- ENV.delete 'HTTP_PROXY'
- ENV.delete 'http_proxy_user'
- ENV.delete 'HTTP_PROXY_USER'
- ENV.delete 'http_proxy_pass'
- ENV.delete 'HTTP_PROXY_PASS'
-
- base_server_uri = "http://localhost:#{SERVER_PORT}"
- @proxy_uri = "http://localhost:#{PROXY_PORT}"
-
- @server_uri = base_server_uri + "/yaml"
- @server_z_uri = base_server_uri + "/yaml.Z"
-
- Gem::RemoteFetcher.instance_variable_set :@fetcher, nil
- end
-
- def test_self_fetcher
- fetcher = Gem::RemoteFetcher.fetcher
- assert_not_nil fetcher
- assert_kind_of Gem::RemoteFetcher, fetcher
- end
-
- def test_self_fetcher_with_proxy
- proxy_uri = 'http://proxy.example.com'
- Gem.configuration[:http_proxy] = proxy_uri
- fetcher = Gem::RemoteFetcher.fetcher
- assert_not_nil fetcher
- assert_kind_of Gem::RemoteFetcher, fetcher
- assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri).to_s
- end
-
- def test_self_fetcher_with_proxy_URI
- proxy_uri = URI.parse 'http://proxy.example.com'
- Gem.configuration[:http_proxy] = proxy_uri
- fetcher = Gem::RemoteFetcher.fetcher
- assert_not_nil fetcher
- assert_kind_of Gem::RemoteFetcher, fetcher
- assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri)
- end
-
- def test_fetch_size_bad_uri
- fetcher = Gem::RemoteFetcher.new nil
-
- e = assert_raise ArgumentError do
- fetcher.fetch_size 'gems.example.com/yaml'
- end
-
- assert_equal 'uri is not an HTTP URI', e.message
- end
-
- def test_fetch_size_socket_error
- fetcher = Gem::RemoteFetcher.new nil
- def fetcher.connect_to(host, port)
- raise SocketError
- end
-
- uri = 'http://gems.example.com/yaml'
- e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_size uri
- end
-
- assert_equal "SocketError (SocketError)\n\tgetting size of #{uri}", e.message
- end
-
- def test_no_proxy
- use_ui @ui do
- fetcher = Gem::RemoteFetcher.new nil
- assert_data_from_server fetcher.fetch_path(@server_uri)
- assert_equal SERVER_DATA.size, fetcher.fetch_size(@server_uri)
- end
- end
-
- def test_explicit_proxy
- use_ui @ui do
- fetcher = Gem::RemoteFetcher.new @proxy_uri
- assert_equal PROXY_DATA.size, fetcher.fetch_size(@server_uri)
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_explicit_proxy_with_user_auth
- use_ui @ui do
- uri = URI.parse @proxy_uri
- uri.user, uri.password = 'foo', 'bar'
- fetcher = Gem::RemoteFetcher.new uri.to_s
- proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'foo', proxy.user
- assert_equal 'bar', proxy.password
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
-
- use_ui @ui do
- uri = URI.parse @proxy_uri
- uri.user, uri.password = 'domain%5Cuser', 'bar'
- fetcher = Gem::RemoteFetcher.new uri.to_s
- proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'domain\user', URI.unescape(proxy.user)
- assert_equal 'bar', proxy.password
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
-
- use_ui @ui do
- uri = URI.parse @proxy_uri
- uri.user, uri.password = 'user', 'my%20pass'
- fetcher = Gem::RemoteFetcher.new uri.to_s
- proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'user', proxy.user
- assert_equal 'my pass', URI.unescape(proxy.password)
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_explicit_proxy_with_user_auth_in_env
- use_ui @ui do
- ENV['http_proxy'] = @proxy_uri
- ENV['http_proxy_user'] = 'foo'
- ENV['http_proxy_pass'] = 'bar'
- fetcher = Gem::RemoteFetcher.new nil
- proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'foo', proxy.user
- assert_equal 'bar', proxy.password
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
-
- use_ui @ui do
- ENV['http_proxy'] = @proxy_uri
- ENV['http_proxy_user'] = 'foo\user'
- ENV['http_proxy_pass'] = 'my bar'
- fetcher = Gem::RemoteFetcher.new nil
- proxy = fetcher.instance_variable_get("@proxy_uri")
- assert_equal 'foo\user', URI.unescape(proxy.user)
- assert_equal 'my bar', URI.unescape(proxy.password)
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_fetch_path_io_error
- fetcher = Gem::RemoteFetcher.new nil
-
- def fetcher.open_uri_or_path(uri) raise EOFError; end
-
- e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path 'uri'
- end
-
- assert_equal 'EOFError: EOFError reading uri', e.message
- end
-
- def test_fetch_path_open_uri_http_error
- fetcher = Gem::RemoteFetcher.new nil
-
- def fetcher.open_uri_or_path(uri)
- io = StringIO.new 'went boom'
- err = OpenURI::HTTPError.new 'error', io
- raise err
- end
-
- e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path 'uri'
- end
-
- assert_equal "OpenURI::HTTPError: error reading uri\n\twent boom", e.message
- end
-
- def test_fetch_path_socket_error
- fetcher = Gem::RemoteFetcher.new nil
-
- def fetcher.open_uri_or_path(uri) raise SocketError; end
-
- e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path 'uri'
- end
-
- assert_equal 'SocketError: SocketError reading uri', e.message
- end
-
- def test_fetch_path_system_call_error
- fetcher = Gem::RemoteFetcher.new nil
-
- def fetcher.open_uri_or_path(uri);
- raise Errno::ECONNREFUSED, 'connect(2)'
- end
-
- e = assert_raise Gem::RemoteFetcher::FetchError do
- fetcher.fetch_path 'uri'
- end
-
- assert_match %r|\AErrno::ECONNREFUSED: .* - connect\(2\) reading uri\z|,
- e.message
- end
-
- def test_get_proxy_from_env_empty
- orig_env_HTTP_PROXY = ENV['HTTP_PROXY']
- orig_env_http_proxy = ENV['http_proxy']
-
- ENV['HTTP_PROXY'] = ''
- ENV.delete 'http_proxy'
-
- fetcher = Gem::RemoteFetcher.new nil
-
- assert_equal nil, fetcher.send(:get_proxy_from_env)
-
- ensure
- orig_env_HTTP_PROXY.nil? ? ENV.delete('HTTP_PROXY') :
- ENV['HTTP_PROXY'] = orig_env_HTTP_PROXY
- orig_env_http_proxy.nil? ? ENV.delete('http_proxy') :
- ENV['http_proxy'] = orig_env_http_proxy
- end
-
- def test_implicit_no_proxy
- use_ui @ui do
- ENV['http_proxy'] = 'http://fakeurl:12345'
- fetcher = Gem::RemoteFetcher.new :no_proxy
- assert_data_from_server fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_implicit_proxy
- use_ui @ui do
- ENV['http_proxy'] = @proxy_uri
- fetcher = Gem::RemoteFetcher.new nil
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_implicit_upper_case_proxy
- use_ui @ui do
- ENV['HTTP_PROXY'] = @proxy_uri
- fetcher = Gem::RemoteFetcher.new nil
- assert_data_from_proxy fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_implicit_proxy_no_env
- use_ui @ui do
- fetcher = Gem::RemoteFetcher.new nil
- assert_data_from_server fetcher.fetch_path(@server_uri)
- end
- end
-
- def test_zip
- use_ui @ui do
- self.class.enable_zip = true
- fetcher = Gem::RemoteFetcher.new nil
- assert_equal SERVER_DATA.size, fetcher.fetch_size(@server_uri), "probably not from proxy"
- zip_data = fetcher.fetch_path(@server_z_uri)
- assert zip_data.size < SERVER_DATA.size, "Zipped data should be smaller"
- end
- end
-
- def test_no_zip
- use_ui @ui do
- self.class.enable_zip = false
- fetcher = Gem::RemoteFetcher.new nil
- assert_error { fetcher.fetch_path(@server_z_uri) }
- end
- end
-
- def test_yaml_error_on_size
- use_ui @ui do
- self.class.enable_yaml = false
- fetcher = Gem::RemoteFetcher.new nil
- assert_error { fetcher.size }
- end
- end
-
- private
-
- def assert_error(exception_class=Exception)
- got_exception = false
- begin
- yield
- rescue exception_class => ex
- got_exception = true
- end
- assert got_exception, "Expected exception conforming to #{exception_class}"
- end
-
- def assert_data_from_server(data)
- assert_block("Data is not from server") { data =~ /0\.4\.11/ }
- end
-
- def assert_data_from_proxy(data)
- assert_block("Data is not from proxy") { data =~ /0\.4\.2/ }
- end
-
- class NilLog < WEBrick::Log
- def log(level, data) #Do nothing
- end
- end
-
- class << self
- attr_reader :normal_server, :proxy_server
- attr_accessor :enable_zip, :enable_yaml
-
- def start_servers
- @normal_server ||= start_server(SERVER_PORT, SERVER_DATA)
- @proxy_server ||= start_server(PROXY_PORT, PROXY_DATA)
- @enable_yaml = true
- @enable_zip = false
- end
-
- private
-
- def start_server(port, data)
- Thread.new do
- begin
- null_logger = NilLog.new
- s = WEBrick::HTTPServer.new(
- :Port => port,
- :DocumentRoot => nil,
- :Logger => null_logger,
- :AccessLog => null_logger
- )
- s.mount_proc("/kill") { |req, res| s.shutdown }
- s.mount_proc("/yaml") { |req, res|
- if @enable_yaml
- res.body = data
- res['Content-Type'] = 'text/plain'
- res['content-length'] = data.size
- else
- res.status = "404"
- res.body = "<h1>NOT FOUND</h1>"
- res['Content-Type'] = 'text/html'
- end
- }
- s.mount_proc("/yaml.Z") { |req, res|
- if @enable_zip
- res.body = Zlib::Deflate.deflate(data)
- res['Content-Type'] = 'text/plain'
- else
- res.status = "404"
- res.body = "<h1>NOT FOUND</h1>"
- res['Content-Type'] = 'text/html'
- end
- }
- s.start
- rescue Exception => ex
- abort ex.message
- puts "ERROR during server thread: #{ex.message}"
- end
- end
- sleep 0.2 # Give the servers time to startup
- end
- end
-
-end
-
diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb
deleted file mode 100644
index c441bd16df..0000000000
--- a/test/rubygems/test_gem_requirement.rb
+++ /dev/null
@@ -1,223 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/version'
-
-class TestGemRequirement < RubyGemTestCase
-
- def setup
- super
-
- @r1_2 = Gem::Requirement.new '= 1.2'
- @r1_3 = Gem::Requirement.new '= 1.3'
- end
-
- def test_initialize
- r = Gem::Requirement.new '2'
- assert_equal '= 2', r.to_s, 'String'
-
- r = Gem::Requirement.new %w[2]
- assert_equal '= 2', r.to_s, 'Array of Strings'
-
- r = Gem::Requirement.new Gem::Version.new('2')
- assert_equal '= 2', r.to_s, 'Gem::Version'
- end
-
- def test_equals2
- assert_equal @r1_2, @r1_2.dup
- assert_equal @r1_2.dup, @r1_2
-
- assert_not_equal @r1_3, @r1_2
- assert_not_equal @r1_2, @r1_3
-
- assert_not_equal Object.new, @r1_2
- assert_not_equal @r1_2, Object.new
- end
-
- def test_hash
- assert_equal @r1_2.hash, @r1_2.dup.hash
- assert_equal @r1_2.dup.hash, @r1_2.hash
-
- assert_not_equal @r1_2.hash, @r1_3.hash
- assert_not_equal @r1_3.hash, @r1_2.hash
- end
-
- # We may get some old gems that have requirements in old formats.
- # We need to be able to handle those old requirements by normalizing
- # them to the latest format.
- def test_normalization
- require 'yaml'
- yamldep = %{--- !ruby/object:Gem::Requirement
- nums:
- - 1
- - 0
- - 4
- op: ">="
- version: ">= 1.0.4"}
- dep = YAML.load(yamldep)
- dep.normalize
- assert_equal ">= 1.0.4", dep.to_s
- end
-
- def test_parse
- assert_equal ['=', Gem::Version.new(1)], @r1_2.parse(' 1')
-
- assert_equal ['=', Gem::Version.new(1)], @r1_2.parse('= 1')
- assert_equal ['>', Gem::Version.new(1)], @r1_2.parse('> 1')
-
- assert_equal ['=', Gem::Version.new(0)], @r1_2.parse('=')
- assert_equal ['>', Gem::Version.new(0)], @r1_2.parse('>')
-
- assert_equal ['=', Gem::Version.new(1)], @r1_2.parse("=\n1")
- assert_equal ['=', Gem::Version.new(0)], @r1_2.parse("=\njunk")
-
- assert_equal ['=', Gem::Version.new(2)], @r1_2.parse(Gem::Version.new('2'))
- end
-
- def test_parse_illformed
- e = assert_raise ArgumentError do
- @r1_2.parse(nil)
- end
-
- assert_equal 'Illformed requirement [nil]', e.message
-
- e = assert_raise ArgumentError do
- @r1_2.parse('')
- end
-
- assert_equal 'Illformed requirement [""]', e.message
- end
-
- def test_satisfied_by_eh_bang_equal
- r1_2 = Gem::Requirement.new '!= 1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal true, r1_2.satisfied_by?(nil)
- assert_equal true, r1_2.satisfied_by?(v1_1)
- assert_equal false, r1_2.satisfied_by?(v1_2)
- assert_equal true, r1_2.satisfied_by?(v1_3)
- end
-
- def test_satisfied_by_eh_blank
- r1_2 = Gem::Requirement.new '1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal false, r1_2.satisfied_by?(nil)
- assert_equal false, r1_2.satisfied_by?(v1_1)
- assert_equal true, r1_2.satisfied_by?(v1_2)
- assert_equal false, r1_2.satisfied_by?(v1_3)
- end
-
- def test_satisfied_by_eh_equal
- r1_2 = @r1_2
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal false, r1_2.satisfied_by?(nil)
- assert_equal false, r1_2.satisfied_by?(v1_1)
- assert_equal true, r1_2.satisfied_by?(v1_2)
- assert_equal false, r1_2.satisfied_by?(v1_3)
- end
-
- def test_satisfied_by_eh_gt
- r1_2 = Gem::Requirement.new '> 1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal false, r1_2.satisfied_by?(v1_1)
- assert_equal false, r1_2.satisfied_by?(v1_2)
- assert_equal true, r1_2.satisfied_by?(v1_3)
-
- assert_raise NoMethodError do
- assert_equal true, r1_2.satisfied_by?(nil)
- end
- end
-
- def test_satisfied_by_eh_gte
- r1_2 = Gem::Requirement.new '>= 1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal false, r1_2.satisfied_by?(v1_1)
- assert_equal true, r1_2.satisfied_by?(v1_2)
- assert_equal true, r1_2.satisfied_by?(v1_3)
-
- assert_raise NoMethodError do
- assert_equal true, r1_2.satisfied_by?(nil)
- end
- end
-
- def test_satisfied_by_eh_list
- r = Gem::Requirement.create(['> 1.1', '< 1.3'])
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal false, r.satisfied_by?(v1_1)
- assert_equal true, r.satisfied_by?(v1_2)
- assert_equal false, r.satisfied_by?(v1_3)
-
- assert_raise NoMethodError do
- assert_equal true, r.satisfied_by?(nil)
- end
- end
-
- def test_satisfied_by_eh_lt
- r1_2 = Gem::Requirement.new '< 1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal true, r1_2.satisfied_by?(v1_1)
- assert_equal false, r1_2.satisfied_by?(v1_2)
- assert_equal false, r1_2.satisfied_by?(v1_3)
-
- assert_raise NoMethodError do
- assert_equal true, r1_2.satisfied_by?(nil)
- end
- end
-
- def test_satisfied_by_eh_lte
- r1_2 = Gem::Requirement.new '<= 1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal true, r1_2.satisfied_by?(v1_1)
- assert_equal true, r1_2.satisfied_by?(v1_2)
- assert_equal false, r1_2.satisfied_by?(v1_3)
-
- assert_raise NoMethodError do
- assert_equal true, r1_2.satisfied_by?(nil)
- end
- end
-
- def test_satisfied_by_eh_tilde_gt
- r1_2 = Gem::Requirement.new '~> 1.2'
- v1_1 = Gem::Version.new '1.1'
- v1_2 = Gem::Version.new '1.2'
- v1_3 = Gem::Version.new '1.3'
-
- assert_equal false, r1_2.satisfied_by?(v1_1)
- assert_equal true, r1_2.satisfied_by?(v1_2)
- assert_equal true, r1_2.satisfied_by?(v1_3)
-
- assert_raise NoMethodError do
- assert_equal true, r1_2.satisfied_by?(nil)
- end
- end
-
-end
-
diff --git a/test/rubygems/test_gem_server.rb b/test/rubygems/test_gem_server.rb
deleted file mode 100644
index c283e661dc..0000000000
--- a/test/rubygems/test_gem_server.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/server'
-require 'stringio'
-
-class Gem::Server
- attr_accessor :source_index
- attr_reader :server
-end
-
-class TestGemServer < RubyGemTestCase
-
- def setup
- super
-
- @a1 = quick_gem 'a', '1'
-
- @server = Gem::Server.new Gem.dir, 8809, false
- @req = WEBrick::HTTPRequest.new :Logger => nil
- @res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
- end
-
- def test_quick_index
- data = StringIO.new "GET /quick/index HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'text/plain', @res['content-type']
- assert_equal "a-1", @res.body
- end
-
- def test_quick_index_rz
- data = StringIO.new "GET /quick/index.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'text/plain', @res['content-type']
- assert_equal "a-1", Zlib::Inflate.inflate(@res.body)
- end
-
- def test_quick_a_1_gemspec_rz
- data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert @res['date']
- assert_equal 'text/plain', @res['content-type']
- yaml = Zlib::Inflate.inflate(@res.body)
- assert_match %r|Gem::Specification|, yaml
- assert_match %r|name: a|, yaml
- assert_match %r|version: "1"|, yaml
- end
-
- def test_quick_a_1_mswin32_gemspec_rz
- a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
- si = Gem::SourceIndex.new @a1.full_name => @a1, a1_p.full_name => a1_p
- @server.source_index = si
-
- data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert @res['date']
- assert_equal 'text/plain', @res['content-type']
- yaml = Zlib::Inflate.inflate(@res.body)
- assert_match %r|Gem::Specification|, yaml
- assert_match %r|name: a|, yaml
- assert_match %r|version: "1"|, yaml
- end
-
- def test_quick_common_substrings
- ab1 = quick_gem 'ab', '1'
- si = Gem::SourceIndex.new @a1.full_name => @a1, ab1.full_name => ab1
- @server.source_index = si
-
- data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 200, @res.status, @res.body
- assert @res['date']
- assert_equal 'text/plain', @res['content-type']
- yaml = Zlib::Inflate.inflate @res.body
- assert_match %r|Gem::Specification|, yaml
- assert_match %r|name: a$|, yaml
- assert_match %r|version: "1"|, yaml
- end
-
- def test_quick_z_9_gemspec_rz
- data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
- @req.parse data
-
- @server.quick @req, @res
-
- assert_equal 404, @res.status, @res.body
- assert_match %r| \d\d:\d\d:\d\d |, @res['date']
- assert_equal 'text/plain', @res['content-type']
- assert_equal 'No gems found matching "z" "9" nil', @res.body
- assert_equal 404, @res.status
- end
-
-end
-
diff --git a/test/rubygems/test_gem_source_index.rb b/test/rubygems/test_gem_source_index.rb
deleted file mode 100644
index 45f59f2430..0000000000
--- a/test/rubygems/test_gem_source_index.rb
+++ /dev/null
@@ -1,429 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/source_index'
-require 'rubygems/config_file'
-
-class Gem::SourceIndex
- public :fetcher, :fetch_bulk_index, :fetch_quick_index,
- :find_missing, :gems, :remove_extra,
- :update_with_missing, :unzip
-end
-
-class TestGemSourceIndex < RubyGemTestCase
-
- def setup
- super
-
- util_setup_fake_fetcher
- end
-
- def test_create_from_directory
- # TODO
- end
-
- def test_fetcher
- assert_equal @fetcher, @source_index.fetcher
- end
-
- def test_fetch_bulk_index_compressed
- util_setup_bulk_fetch true
-
- use_ui @ui do
- fetched_index = @source_index.fetch_bulk_index @uri
- assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
- fetched_index.gems.map { |n,s| n }.sort
- end
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_fetch_bulk_index_error
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] = proc { raise SocketError }
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = proc { raise SocketError }
- @fetcher.data["#{@gem_repo}/yaml.Z"] = proc { raise SocketError }
- @fetcher.data["#{@gem_repo}/yaml"] = proc { raise SocketError }
-
- e = assert_raise Gem::RemoteSourceException do
- use_ui @ui do
- @source_index.fetch_bulk_index @uri
- end
- end
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift
- assert_equal "#{@gem_repo}/yaml.Z", paths.shift
- assert_equal "#{@gem_repo}/yaml", paths.shift
-
- assert paths.empty?, paths.join(', ')
-
- assert_equal 'Error fetching remote gem cache: SocketError',
- e.message
- end
-
- def test_fetch_bulk_index_fallback
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] =
- proc { raise SocketError }
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] =
- proc { raise SocketError }
- @fetcher.data["#{@gem_repo}/yaml.Z"] = proc { raise SocketError }
- @fetcher.data["#{@gem_repo}/yaml"] = @source_index.to_yaml
-
- use_ui @ui do
- fetched_index = @source_index.fetch_bulk_index @uri
- assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
- fetched_index.gems.map { |n,s| n }.sort
- end
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift
- assert_equal "#{@gem_repo}/yaml.Z", paths.shift
- assert_equal "#{@gem_repo}/yaml", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_fetch_bulk_index_marshal_mismatch
- marshal = @source_index.dump
- marshal[0] = (Marshal::MAJOR_VERSION - 1).chr
-
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = marshal
- @fetcher.data["#{@gem_repo}/yaml"] = @source_index.to_yaml
-
- use_ui @ui do
- fetched_index = @source_index.fetch_bulk_index @uri
- assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
- fetched_index.gems.map { |n,s| n }.sort
- end
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift
- assert_equal "#{@gem_repo}/yaml.Z", paths.shift
- assert_equal "#{@gem_repo}/yaml", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_fetch_bulk_index_uncompressed
- util_setup_bulk_fetch false
- use_ui @ui do
- fetched_index = @source_index.fetch_bulk_index @uri
- assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
- fetched_index.gems.map { |n,s| n }.sort
- end
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_fetch_quick_index
- quick_index = util_zip @gem_names
- @fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
-
- quick_index = @source_index.fetch_quick_index @uri
- assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
- quick_index.sort
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_fetch_quick_index_error
- @fetcher.data["#{@gem_repo}/quick/index.rz"] =
- proc { raise Exception }
-
- e = assert_raise Gem::OperationNotSupportedError do
- @source_index.fetch_quick_index @uri
- end
-
- assert_equal 'No quick index found: Exception', e.message
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_find_missing
- missing = @source_index.find_missing [@gem3.full_name]
- assert_equal [@gem3.full_name], missing
- end
-
- def test_find_missing_none_missing
- missing = @source_index.find_missing @gem_names.split
- assert_equal [], missing
- end
-
- def test_latest_specs
- spec = quick_gem @gem1.name, '1'
- @source_index.add_spec spec
-
- expected = [
- @gem1.full_name,
- @gem2.full_name,
- @gem4.full_name,
- ].sort
-
- assert_equal expected, @source_index.latest_specs.map { |s| s.full_name }.sort
- end
-
- def test_outdated
- sic = Gem::SourceInfoCache.new
- Gem::SourceInfoCache.instance_variable_set :@cache, sic
-
- assert_equal [], @source_index.outdated
-
- updated = quick_gem @gem1.name, (@gem1.version.bump)
- util_setup_source_info_cache updated
-
- assert_equal [updated.name], @source_index.outdated
-
- updated_platform = quick_gem @gem1.name, (updated.version.bump) do |s|
- s.platform = Gem::Platform.new 'x86-other_platform1'
- end
-
- util_setup_source_info_cache updated, updated_platform
-
- assert_equal [updated_platform.name], @source_index.outdated
- end
-
- def test_remove_extra
- @source_index.remove_extra [@gem1.full_name]
- assert_equal [@gem1.full_name], @source_index.gems.map { |n,s| n }
- end
-
- def test_remove_extra_no_changes
- gems = @gem_names.split.sort
- @source_index.remove_extra gems
- assert_equal gems, @source_index.gems.map { |n,s| n }.sort
- end
-
- def test_search
- assert_equal [@gem1, @gem4], @source_index.search("gem_one")
- assert_equal [@gem1], @source_index.search("gem_one", "= 2")
-
- assert_equal [], @source_index.search("bogusstring")
- assert_equal [], @source_index.search("gem_one", "= 3.2.1")
-
- @a1 = quick_gem 'a', '1'
- @a2 = quick_gem 'a', '2'
-
- source_index = Gem::SourceIndex.new @a1.full_name => @a1,
- @a2.full_name => @a2
-
- assert_equal [@a1], source_index.search(@a1.name, '= 1')
-
- r1 = Gem::Requirement.create '= 1'
- assert_equal [@a1], source_index.search(@a1.name, r1)
-
- dep = Gem::Dependency.new @a1.name, r1
- assert_equal [@a1], source_index.search(dep)
- end
-
- def test_search_empty_cache
- empty_source_index = Gem::SourceIndex.new({})
- assert_equal [], empty_source_index.search("foo")
- end
-
- def test_search_platform
- util_set_arch 'x86-my_platform1'
-
- a1 = quick_gem 'a', '1'
- a1_mine = quick_gem 'a', '1' do |s|
- s.platform = Gem::Platform.new 'x86-my_platform1'
- end
- a1_other = quick_gem 'a', '1' do |s|
- s.platform = Gem::Platform.new 'x86-other_platform1'
- end
-
- si = Gem::SourceIndex.new(a1.full_name => a1, a1_mine.full_name => a1_mine,
- a1_other.full_name => a1_other)
-
- dep = Gem::Dependency.new 'a', Gem::Requirement.new('1')
-
- gems = si.search dep, true
-
- assert_equal [a1, a1_mine], gems.sort
- end
-
- def test_signature
- sig = @source_index.gem_signature('foo-1.2.3')
- assert_equal 64, sig.length
- assert_match(/^[a-f0-9]{64}$/, sig)
- end
-
- def test_specification
- assert_equal @gem1, @source_index.specification(@gem1.full_name)
-
- assert_nil @source_index.specification("foo-1.2.4")
- end
-
- def test_index_signature
- sig = @source_index.index_signature
- assert_match(/^[a-f0-9]{64}$/, sig)
- end
-
- def test_unzip
- input = "x\234+\316\317MU(I\255(\001\000\021\350\003\232"
- assert_equal 'some text', @source_index.unzip(input)
- end
-
- def test_update_bulk
- util_setup_bulk_fetch true
-
- @source_index.gems.replace({})
- assert_equal [], @source_index.gems.keys.sort
-
- use_ui @ui do
- @source_index.update @uri
-
- assert_equal @gem_names.split, @source_index.gems.keys.sort
- end
-
- paths = @fetcher.paths
-
- assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
- assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
-
- assert paths.empty?, paths.join(', ')
- end
-
- def test_update_incremental
- old_gem_conf = Gem.configuration
- Gem.configuration = Gem::ConfigFile.new([])
-
- quick_index = util_zip @all_gem_names.join("\n")
- @fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
-
- marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
- "#{@gem3.full_name}.gemspec.rz"
- @fetcher.data[marshal_uri] = util_zip Marshal.dump(@gem3)
-
- use_ui @ui do
- @source_index.update @uri
-
- assert_equal @all_gem_names, @source_index.gems.keys.sort
- end
-
- paths = @fetcher.paths
- assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
- assert_equal marshal_uri, paths.shift
-
- assert paths.empty?, paths.join(', ')
- ensure
- Gem.configuration = old_gem_conf
- end
-
- def test_update_incremental_fallback
- old_gem_conf = Gem.configuration
- Gem.configuration = Gem::ConfigFile.new([])
-
- quick_index = util_zip @all_gem_names.join("\n")
- @fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
-
- marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
- "#{@gem3.full_name}.gemspec.rz"
-
- yaml_uri = "#{@gem_repo}/quick/#{@gem3.full_name}.gemspec.rz"
- @fetcher.data[yaml_uri] = util_zip @gem3.to_yaml
-
- use_ui @ui do
- @source_index.update @uri
-
- assert_equal @all_gem_names, @source_index.gems.keys.sort
- end
-
- paths = @fetcher.paths
- assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
- assert_equal marshal_uri, paths.shift
- assert_equal yaml_uri, paths.shift
-
- assert paths.empty?, paths.join(', ')
- ensure
- Gem.configuration = old_gem_conf
- end
-
- def test_update_incremental_marshal_mismatch
- old_gem_conf = Gem.configuration
- Gem.configuration = Gem::ConfigFile.new([])
-
- quick_index = util_zip @all_gem_names.join("\n")
- @fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
-
- marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
- "#{@gem3.full_name}.gemspec.rz"
- marshal_data = Marshal.dump(@gem3)
- marshal_data[0] = (Marshal::MAJOR_VERSION - 1).chr
- @fetcher.data[marshal_uri] = util_zip marshal_data
-
- yaml_uri = "#{@gem_repo}/quick/#{@gem3.full_name}.gemspec.rz"
- @fetcher.data[yaml_uri] = util_zip @gem3.to_yaml
-
- use_ui @ui do
- @source_index.update @uri
-
- assert_equal @all_gem_names, @source_index.gems.keys.sort
- end
-
- paths = @fetcher.paths
- assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
- assert_equal marshal_uri, paths.shift
- assert_equal yaml_uri, paths.shift
-
- assert paths.empty?, paths.join(', ')
- ensure
- Gem.configuration = old_gem_conf
- end
-
- def test_update_with_missing
- marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
- "#{@gem3.full_name}.gemspec.rz"
- dumped = Marshal.dump(@gem3)
- @fetcher.data[marshal_uri] = util_zip(dumped)
-
- use_ui @ui do
- @source_index.update_with_missing @uri, [@gem3.full_name]
- end
-
- spec = @source_index.specification(@gem3.full_name)
- # We don't care about the equality of undumped attributes
- @gem3.files = spec.files
- @gem3.loaded_from = spec.loaded_from
-
- assert_equal @gem3, spec
- end
-
- def util_setup_bulk_fetch(compressed)
- source_index = @source_index.dump
-
- if compressed then
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] = util_zip source_index
- else
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index
- end
- end
-
-end
diff --git a/test/rubygems/test_gem_source_info_cache.rb b/test/rubygems/test_gem_source_info_cache.rb
deleted file mode 100644
index 570b643bc5..0000000000
--- a/test/rubygems/test_gem_source_info_cache.rb
+++ /dev/null
@@ -1,299 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/source_info_cache'
-
-class Gem::SourceIndex
- public :gems
-end
-
-class TestGemSourceInfoCache < RubyGemTestCase
-
- def setup
- @original_sources = Gem.sources
-
- super
-
- util_setup_fake_fetcher
-
- @sic = Gem::SourceInfoCache.new
- @sic.instance_variable_set :@fetcher, @fetcher
-
- prep_cache_files @sic
- end
-
- def teardown
- super
- Gem.sources.replace @original_sources
- end
-
- def test_self_cache_refreshes
- Gem.configuration.update_sources = true #true by default
- source_index = Gem::SourceIndex.new 'key' => 'sys'
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index.dump
-
- Gem.sources.replace %W[#{@gem_repo}]
-
- use_ui @ui do
- assert_not_nil Gem::SourceInfoCache.cache
- assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
- assert_equal Gem::SourceInfoCache.cache.object_id,
- Gem::SourceInfoCache.cache.object_id
- assert_match %r|Bulk updating|, @ui.output
- end
- end
-
- def test_self_cache_skips_refresh_based_on_configuration
- Gem.configuration.update_sources = false
- source_index = Gem::SourceIndex.new 'key' => 'sys'
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index.dump
-
- Gem.sources.replace %w[#{@gem_repo}]
-
- use_ui @ui do
- assert_not_nil Gem::SourceInfoCache.cache
- assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
- assert_equal Gem::SourceInfoCache.cache.object_id,
- Gem::SourceInfoCache.cache.object_id
- assert_no_match %r|Bulk updating|, @ui.output
- end
- end
-
- def test_self_cache_data
- source_index = Gem::SourceIndex.new 'key' => 'sys'
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index.dump
-
- Gem::SourceInfoCache.instance_variable_set :@cache, nil
- sice = Gem::SourceInfoCacheEntry.new source_index, 0
-
- use_ui @ui do
- assert_equal source_index.gems,
- Gem::SourceInfoCache.cache_data[@gem_repo].source_index.gems
- end
- end
-
- def test_cache_data
- assert_equal [['key','sys']], @sic.cache_data.to_a.sort
- end
-
- def test_cache_data_dirty
- def @sic.dirty() @dirty; end
- assert_equal false, @sic.dirty, 'clean on init'
- @sic.cache_data
- assert_equal false, @sic.dirty, 'clean on fetch'
- @sic.update
- @sic.cache_data
- assert_equal true, @sic.dirty, 'still dirty'
- end
-
- def test_cache_data_irreparable
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = @source_index.dump
-
- data = { @gem_repo => { 'totally' => 'borked' } }
-
- [@sic.system_cache_file, @sic.user_cache_file].each do |fn|
- FileUtils.mkdir_p File.dirname(fn)
- open(fn, "wb") { |f| f.write Marshal.dump(data) }
- end
-
- @sic.instance_eval { @cache_data = nil }
-
- fetched = use_ui @ui do @sic.cache_data end
-
- fetched_si = fetched["#{@gem_repo}"].source_index
-
- assert_equal @source_index.index_signature, fetched_si.index_signature
- end
-
- def test_cache_data_none_readable
- FileUtils.chmod 0222, @sic.system_cache_file
- FileUtils.chmod 0222, @sic.user_cache_file
- return if (File.stat(@sic.system_cache_file).mode & 0222) != 0222
- return if (File.stat(@sic.user_cache_file).mode & 0222) != 0222
- # HACK for systems that don't support chmod
- assert_equal({}, @sic.cache_data)
- end
-
- def test_cache_data_none_writable
- FileUtils.chmod 0444, @sic.system_cache_file
- FileUtils.chmod 0444, @sic.user_cache_file
- e = assert_raise RuntimeError do
- @sic.cache_data
- end
- assert_equal 'unable to locate a writable cache file', e.message
- end
-
- def test_cache_data_repair
- data = {
- @gem_repo => {
- 'cache' => Gem::SourceIndex.new,
- 'size' => 0,
- }
- }
- [@sic.system_cache_file, @sic.user_cache_file].each do |fn|
- FileUtils.mkdir_p File.dirname(fn)
- open(fn, "wb") { |f| f.write Marshal.dump(data) }
- end
-
- @sic.instance_eval { @cache_data = nil }
-
- expected = {
- @gem_repo =>
- Gem::SourceInfoCacheEntry.new(Gem::SourceIndex.new, 0)
- }
- assert_equal expected, @sic.cache_data
- end
-
- def test_cache_data_user_fallback
- FileUtils.chmod 0444, @sic.system_cache_file
- assert_equal [['key','usr']], @sic.cache_data.to_a.sort
- end
-
- def test_cache_file
- assert_equal @gemcache, @sic.cache_file
- end
-
- def test_cache_file_user_fallback
- FileUtils.chmod 0444, @sic.system_cache_file
- assert_equal @usrcache, @sic.cache_file
- end
-
- def test_cache_file_none_writable
- FileUtils.chmod 0444, @sic.system_cache_file
- FileUtils.chmod 0444, @sic.user_cache_file
- e = assert_raise RuntimeError do
- @sic.cache_file
- end
- assert_equal 'unable to locate a writable cache file', e.message
- end
-
- def test_flush
- @sic.cache_data['key'] = 'new'
- @sic.update
- @sic.flush
-
- assert_equal [['key','new']], read_cache(@sic.system_cache_file).to_a.sort
- end
-
- def test_read_system_cache
- assert_equal [['key','sys']], @sic.cache_data.to_a.sort
- end
-
- def test_read_user_cache
- FileUtils.chmod 0444, @sic.system_cache_file
-
- assert_equal [['key','usr']], @sic.cache_data.to_a.sort
- end
-
- def test_search
- si = Gem::SourceIndex.new @gem1.full_name => @gem1
- cache_data = {
- @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
- }
- @sic.instance_variable_set :@cache_data, cache_data
-
- assert_equal [@gem1], @sic.search(//)
- end
-
- def test_search_dependency
- si = Gem::SourceIndex.new @gem1.full_name => @gem1
- cache_data = {
- @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
- }
- @sic.instance_variable_set :@cache_data, cache_data
-
- dep = Gem::Dependency.new @gem1.name, @gem1.version
-
- assert_equal [@gem1], @sic.search(dep)
- end
-
- def test_search_no_matches
- si = Gem::SourceIndex.new @gem1.full_name => @gem1
- cache_data = {
- @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
- }
- @sic.instance_variable_set :@cache_data, cache_data
-
- assert_equal [], @sic.search(/nonexistent/)
- end
-
- def test_search_no_matches_in_source
- si = Gem::SourceIndex.new @gem1.full_name => @gem1
- cache_data = {
- @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
- }
- @sic.instance_variable_set :@cache_data, cache_data
- Gem.sources.replace %w[more-gems.example.com]
-
- assert_equal [], @sic.search(/nonexistent/)
- end
-
- def test_search_with_source
- si = Gem::SourceIndex.new @gem1.full_name => @gem1
- cache_data = {
- @gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
- }
- @sic.instance_variable_set :@cache_data, cache_data
-
- assert_equal [[@gem1, @gem_repo]],
- @sic.search_with_source(//)
- end
-
- def test_system_cache_file
- assert_equal File.join(Gem.dir, "source_cache"), @sic.system_cache_file
- end
-
- def test_user_cache_file
- assert_equal @usrcache, @sic.user_cache_file
- end
-
- def test_write_cache
- @sic.cache_data['key'] = 'new'
- @sic.write_cache
-
- assert_equal [['key', 'new']],
- read_cache(@sic.system_cache_file).to_a.sort
- assert_equal [['key', 'usr']],
- read_cache(@sic.user_cache_file).to_a.sort
- end
-
- def test_write_cache_user
- FileUtils.chmod 0444, @sic.system_cache_file
- @sic.set_cache_data({'key' => 'new'})
- @sic.update
- @sic.write_cache
-
- assert_equal [['key', 'sys']], read_cache(@sic.system_cache_file).to_a.sort
- assert_equal [['key', 'new']], read_cache(@sic.user_cache_file).to_a.sort
- end
-
- def test_write_cache_user_from_scratch
- FileUtils.rm_rf @sic.user_cache_file
- FileUtils.chmod 0444, @sic.system_cache_file
- @sic.set_cache_data({'key' => 'new'})
- @sic.update
- @sic.write_cache
-
- assert_equal [['key', 'sys']], read_cache(@sic.system_cache_file).to_a.sort
- assert_equal [['key', 'new']], read_cache(@sic.user_cache_file).to_a.sort
- end
-
- def test_write_cache_user_no_directory
- FileUtils.rm_rf File.dirname(@sic.user_cache_file)
- FileUtils.chmod 0444, @sic.system_cache_file
- @sic.set_cache_data({'key' => 'new'})
- @sic.update
- @sic.write_cache
-
- assert_equal [['key','sys']], read_cache(@sic.system_cache_file).to_a.sort
- assert_equal [['key','new']], read_cache(@sic.user_cache_file).to_a.sort
- end
-
-end
-
diff --git a/test/rubygems/test_gem_source_info_cache_entry.rb b/test/rubygems/test_gem_source_info_cache_entry.rb
deleted file mode 100644
index 023baf948b..0000000000
--- a/test/rubygems/test_gem_source_info_cache_entry.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/source_info_cache_entry'
-
-class TestGemSourceInfoCacheEntry < RubyGemTestCase
-
- def setup
- super
-
- util_setup_fake_fetcher
-
- @si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
- @sic_e = Gem::SourceInfoCacheEntry.new @si, @si.dump.size
- end
-
- def test_refresh
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] =
- proc { raise Exception }
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = @si.dump
-
- assert_nothing_raised do
- @sic_e.refresh @gem_repo
- end
- end
-
- def test_refresh_bad_uri
- assert_raise URI::BadURIError do
- @sic_e.refresh 'gems.example.com'
- end
- end
-
- def test_refresh_update
- si = Gem::SourceIndex.new @gem1.full_name => @gem1,
- @gem2.full_name => @gem2
- @fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = si.dump
-
- use_ui @ui do
- @sic_e.refresh @gem_repo
- end
-
- new_gem = @sic_e.source_index.specification(@gem2.full_name)
- assert_equal @gem2.full_name, new_gem.full_name
- end
-
-end
-
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
deleted file mode 100644
index 20eb12479f..0000000000
--- a/test/rubygems/test_gem_specification.rb
+++ /dev/null
@@ -1,870 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'stringio'
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/specification'
-
-class TestGemSpecification < RubyGemTestCase
-
- LEGACY_YAML_SPEC = <<-EOF
---- !ruby/object:Gem::Specification
-rubygems_version: "1.0"
-name: keyedlist
-version: !ruby/object:Gem::Version
- version: 0.4.0
-date: 2004-03-28 15:37:49.828000 +02:00
-platform:
-summary: A Hash which automatically computes keys.
-require_paths:
- - lib
-files:
- - lib/keyedlist.rb
-autorequire: keyedlist
-author: Florian Gross
-email: flgr@ccan.de
-has_rdoc: true
- EOF
-
- LEGACY_RUBY_SPEC = <<-EOF
-Gem::Specification.new do |s|
- s.name = %q{keyedlist}
- s.version = %q{0.4.0}
- s.has_rdoc = true
- s.summary = %q{A Hash which automatically computes keys.}
- s.files = ["lib/keyedlist.rb"]
- s.require_paths = ["lib"]
- s.autorequire = %q{keyedlist}
- s.author = %q{Florian Gross}
- s.email = %q{flgr@ccan.de}
-end
- EOF
-
- def setup
- super
-
- @a1 = quick_gem 'a', '1' do |s|
- s.executable = 'exec'
- s.extensions << 'ext/a/extconf.rb'
- s.has_rdoc = 'true'
- s.test_file = 'test/suite.rb'
- s.requirements << 'A working computer'
- s.rubyforge_project = 'example'
-
- s.add_dependency 'rake', '> 0.4'
- s.add_dependency 'jabber4r', '> 0.0.0'
- s.add_dependency 'pqa', ['> 0.4', '<= 0.6']
-
- s.mark_version
- s.files = %w[lib/code.rb]
- end
-
- @a2 = quick_gem 'a', '2' do |s|
- s.files = %w[lib/code.rb]
- end
-
- FileUtils.mkdir_p File.join(@tempdir, 'bin')
- File.open File.join(@tempdir, 'bin', 'exec'), 'w' do |fp|
- fp.puts "#!#{Gem.ruby}"
- end
- end
-
- def test_self_attribute_names
- expected_value = %w[
- authors
- autorequire
- bindir
- cert_chain
- date
- default_executable
- dependencies
- description
- email
- executables
- extensions
- extra_rdoc_files
- files
- has_rdoc
- homepage
- name
- platform
- post_install_message
- rdoc_options
- require_paths
- required_ruby_version
- required_rubygems_version
- requirements
- rubyforge_project
- rubygems_version
- signing_key
- specification_version
- summary
- test_files
- version
- ]
-
- actual_value = Gem::Specification.attribute_names.map { |a| a.to_s }.sort
-
- assert_equal expected_value, actual_value
- end
-
- def test_self_load
- spec = File.join @gemhome, 'specifications', "#{@a2.full_name}.gemspec"
- gs = Gem::Specification.load spec
-
- assert_equal @a2, gs
- end
-
- def test_self_load_legacy_ruby
- spec = eval LEGACY_RUBY_SPEC
- assert_equal 'keyedlist', spec.name
- assert_equal '0.4.0', spec.version.to_s
- assert_equal true, spec.has_rdoc?
- assert_equal Gem::Specification::TODAY, spec.date
- assert spec.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
- assert_equal false, spec.has_unit_tests?
- end
-
- def test_self_load_legacy_yaml
- s = YAML.load StringIO.new(LEGACY_YAML_SPEC)
- assert_equal 'keyedlist', s.name
- assert_equal '0.4.0', s.version.to_s
- assert_equal true, s.has_rdoc?
- #assert_equal Date.today, s.date
- #assert s.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
- assert_equal false, s.has_unit_tests?
- end
-
- def test_self_normalize_yaml_input_with_183_yaml
- input = "!ruby/object:Gem::Specification "
- assert_equal "--- #{input}", Gem::Specification.normalize_yaml_input(input)
- end
-
- def test_self_normalize_yaml_input_with_non_183_yaml
- input = "--- !ruby/object:Gem::Specification "
- assert_equal input, Gem::Specification.normalize_yaml_input(input)
- end
-
- def test_self_normalize_yaml_input_with_183_io
- input = "!ruby/object:Gem::Specification "
- assert_equal "--- #{input}",
- Gem::Specification.normalize_yaml_input(StringIO.new(input))
- end
-
- def test_self_normalize_yaml_input_with_non_183_io
- input = "--- !ruby/object:Gem::Specification "
- assert_equal input,
- Gem::Specification.normalize_yaml_input(StringIO.new(input))
- end
-
- def test_initialize
- spec = Gem::Specification.new do |s|
- s.name = "blah"
- s.version = "1.3.5"
- end
-
- assert_equal "blah", spec.name
- assert_equal "1.3.5", spec.version.to_s
- assert_equal Gem::Platform::RUBY, spec.platform
- assert_equal nil, spec.summary
- assert_equal [], spec.files
-
- assert_equal [], spec.test_files
- assert_equal [], spec.rdoc_options
- assert_equal [], spec.extra_rdoc_files
- assert_equal [], spec.executables
- assert_equal [], spec.extensions
- assert_equal [], spec.requirements
- assert_equal [], spec.dependencies
- assert_equal 'bin', spec.bindir
- assert_equal false, spec.has_rdoc
- assert_equal false, spec.has_rdoc?
- assert_equal '>= 0', spec.required_ruby_version.to_s
- assert_equal '>= 0', spec.required_rubygems_version.to_s
- end
-
- def test_initialize_future
- version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + 1
- spec = Gem::Specification.new do |s|
- s.name = "blah"
- s.version = "1.3.5"
-
- s.specification_version = version
-
- s.new_unknown_attribute = "a value"
- end
-
- assert_equal "blah", spec.name
- assert_equal "1.3.5", spec.version.to_s
- end
-
- def test__dump
- @a2.platform = Gem::Platform.local
- @a2.instance_variable_set :@original_platform, 'old_platform'
-
- data = Marshal.dump @a2
-
- same_spec = Marshal.load data
-
- assert_equal 'old_platform', same_spec.original_platform
- end
-
- def test_author
- assert_equal 'A User', @a1.author
- end
-
- def test_authors
- assert_equal ['A User'], @a1.authors
- end
-
- def test_bindir_equals
- @a1.bindir = 'apps'
-
- assert_equal 'apps', @a1.bindir
- end
-
- def test_bindir_equals_nil
- @a2.bindir = nil
- @a2.executable = 'app'
-
- assert_equal nil, @a2.bindir
- assert_equal %w[lib/code.rb app], @a2.files
- end
-
- def test_date
- assert_equal Gem::Specification::TODAY, @a1.date
- end
-
- def test_date_equals_date
- @a1.date = Date.new(2003, 9, 17)
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
- end
-
- def test_date_equals_string
- @a1.date = '2003-09-17'
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
- end
-
- def test_date_equals_time
- @a1.date = Time.local(2003, 9, 17, 0,0,0)
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
- end
-
- def test_date_equals_time_local
- # HACK PDT
- @a1.date = Time.local(2003, 9, 17, 19,50,0)
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
- end
-
- def test_date_equals_time_utc
- # HACK PDT
- @a1.date = Time.local(2003, 9, 17, 19,50,0)
- assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
- end
-
- def test_default_executable
- assert_equal 'exec', @a1.default_executable
-
- @a1.default_executable = nil
- @a1.instance_variable_set :@executables, nil
- assert_equal nil, @a1.default_executable
- end
-
- def test_dependencies
- rake = Gem::Dependency.new 'rake', '> 0.4'
- jabber = Gem::Dependency.new 'jabber4r', '> 0.0.0'
- pqa = Gem::Dependency.new 'pqa', ['> 0.4', '<= 0.6']
-
- assert_equal [rake, jabber, pqa], @a1.dependencies
- end
-
- def test_description
- assert_equal 'This is a test description', @a1.description
- end
-
- def test_eql_eh
- g1 = quick_gem 'gem'
- g2 = quick_gem 'gem'
-
- assert_equal g1, g2
- assert_equal g1.hash, g2.hash
- assert_equal true, g1.eql?(g2)
- end
-
- def test_equals2
- assert_equal @a1, @a1
- assert_equal @a1, @a1.dup
- assert_not_equal @a1, @a2
- assert_not_equal @a1, Object.new
- end
-
- # The cgikit specification was reported to be causing trouble in at least
- # one version of RubyGems, so we test explicitly for it.
- def test_equals2_cgikit
- cgikit = Gem::Specification.new do |s|
- s.name = %q{cgikit}
- s.version = "1.1.0"
- s.date = %q{2004-03-13}
- s.summary = %q{CGIKit is a componented-oriented web application } +
- %q{framework like Apple Computers WebObjects. } +
- %{This framework services Model-View-Controller architecture } +
- %q{programming by components based on a HTML file, a definition } +
- %q{file and a Ruby source. }
- s.email = %q{info@spice-of-life.net}
- s.homepage = %q{http://www.spice-of-life.net/download/cgikit/}
- s.autorequire = %q{cgikit}
- s.bindir = nil
- s.has_rdoc = nil
- s.required_ruby_version = nil
- s.platform = nil
- s.files = ["lib/cgikit", "lib/cgikit.rb", "lib/cgikit/components", "..."]
- end
-
- assert_equal cgikit, cgikit
- end
-
- def test_equals2_default_executable
- spec = @a1.dup
- spec.default_executable = 'xx'
-
- assert_not_equal @a1, spec
- assert_not_equal spec, @a1
- end
-
- def test_equals2_extensions
- spec = @a1.dup
- spec.extensions = 'xx'
-
- assert_not_equal @a1, spec
- assert_not_equal spec, @a1
- end
-
- def test_executables
- @a1.executable = 'app'
- assert_equal %w[app], @a1.executables
- end
-
- def test_executable_equals
- @a2.executable = 'app'
- assert_equal 'app', @a2.executable
- assert_equal %w[lib/code.rb bin/app], @a2.files
- end
-
- def test_extensions
- assert_equal ['ext/a/extconf.rb'], @a1.extensions
- end
-
- def test_files
- @a1.files = %w(files bin/common)
- @a1.test_files = %w(test_files bin/common)
- @a1.executables = %w(executables common)
- @a1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
- @a1.extensions = %w(extensions bin/common)
-
- expected = %w[
- bin/common
- bin/executables
- extensions
- extra_rdoc_files
- files
- test_files
- ]
- assert_equal expected, @a1.files.sort
- end
-
- def test_files_duplicate
- @a2.files = %w[a b c d b]
- @a2.extra_rdoc_files = %w[x y z x]
- @a2.normalize
-
- assert_equal %w[a b c d x y z], @a2.files
- assert_equal %w[x y z], @a2.extra_rdoc_files
- end
-
- def test_files_extra_rdoc_files
- @a2.files = %w[a b c d]
- @a2.extra_rdoc_files = %w[x y z]
- @a2.normalize
- assert_equal %w[a b c d x y z], @a2.files
- end
-
- def test_files_non_array
- @a1.files = "F"
- @a1.test_files = "TF"
- @a1.executables = "X"
- @a1.extra_rdoc_files = "ERF"
- @a1.extensions = "E"
-
- assert_equal %w[E ERF F TF bin/X], @a1.files.sort
- end
-
- def test_files_non_array_pathological
- @a1.instance_variable_set :@files, "F"
- @a1.instance_variable_set :@test_files, "TF"
- @a1.instance_variable_set :@extra_rdoc_files, "ERF"
- @a1.instance_variable_set :@extensions, "E"
- @a1.instance_variable_set :@executables, "X"
-
- assert_equal %w[E ERF F TF bin/X], @a1.files.sort
- assert_kind_of Integer, @a1.hash
- end
-
- def test_full_gem_path
- assert_equal File.join(@gemhome, 'gems', @a1.full_name),
- @a1.full_gem_path
-
- @a1.original_platform = 'mswin32'
-
- assert_equal File.join(@gemhome, 'gems', @a1.original_name),
- @a1.full_gem_path
- end
-
- def test_full_name
- assert_equal 'a-1', @a1.full_name
-
- @a1.platform = Gem::Platform.new ['universal', 'darwin', nil]
- assert_equal 'a-1-universal-darwin', @a1.full_name
-
- @a1.instance_variable_set :@new_platform, 'mswin32'
- assert_equal 'a-1-mswin32', @a1.full_name, 'legacy'
-
- return if win_platform?
-
- @a1.platform = 'current'
- assert_equal 'a-1-x86-darwin-8', @a1.full_name
- end
-
- def test_full_name_windows
- test_cases = {
- 'i386-mswin32' => 'a-1-x86-mswin32-60',
- 'i386-mswin32_80' => 'a-1-x86-mswin32-80',
- 'i386-mingw32' => 'a-1-x86-mingw32'
- }
-
- test_cases.each do |arch, expected|
- util_set_arch arch
- @a1.platform = 'current'
- assert_equal expected, @a1.full_name
- end
- end
-
- def test_has_rdoc_eh
- assert_equal true, @a1.has_rdoc?
- end
-
- def test_hash
- assert_equal @a1.hash, @a1.hash
- assert_equal @a1.hash, @a1.dup.hash
- assert_not_equal @a1.hash, @a2.hash
- end
-
- def test_lib_files
- @a1.files = %w[lib/foo.rb Rakefile]
-
- assert_equal %w[lib/foo.rb], @a1.lib_files
- end
-
- def test_name
- assert_equal 'a', @a1.name
- end
-
- def test_original_name
- assert_equal 'a-1', @a1.full_name
-
- @a1.platform = 'i386-linux'
- @a1.instance_variable_set :@original_platform, 'i386-linux'
- assert_equal 'a-1-i386-linux', @a1.original_name
- end
-
- def test_platform
- assert_equal Gem::Platform::RUBY, @a1.platform
- end
-
- def test_platform_equals
- @a1.platform = nil
- assert_equal Gem::Platform::RUBY, @a1.platform
-
- @a1.platform = Gem::Platform::RUBY
- assert_equal Gem::Platform::RUBY, @a1.platform
-
- test_cases = {
- 'i386-mswin32' => ['x86', 'mswin32', '60'],
- 'i386-mswin32_80' => ['x86', 'mswin32', '80'],
- 'i386-mingw32' => ['x86', 'mingw32', nil ],
- 'x86-darwin8' => ['x86', 'darwin', '8' ],
- }
-
- test_cases.each do |arch, expected|
- util_set_arch arch
- @a1.platform = Gem::Platform::CURRENT
- assert_equal Gem::Platform.new(expected), @a1.platform
- end
- end
-
- def test_platform_equals_current
- @a1.platform = Gem::Platform::CURRENT
- assert_equal Gem::Platform.local, @a1.platform
- assert_equal Gem::Platform.local.to_s, @a1.original_platform
- end
-
- def test_platform_equals_legacy
- @a1.platform = 'mswin32'
- assert_equal Gem::Platform.new('x86-mswin32'), @a1.platform
-
- @a1.platform = 'i586-linux'
- assert_equal Gem::Platform.new('x86-linux'), @a1.platform
-
- @a1.platform = 'powerpc-darwin'
- assert_equal Gem::Platform.new('ppc-darwin'), @a1.platform
- end
-
- def test_require_paths
- @a1.require_path = 'lib'
- assert_equal %w[lib], @a1.require_paths
- end
-
- def test_requirements
- assert_equal ['A working computer'], @a1.requirements
- end
-
- def test_spaceship_name
- s1 = quick_gem 'a', '1'
- s2 = quick_gem 'b', '1'
-
- assert_equal(-1, (s1 <=> s2))
- assert_equal( 0, (s1 <=> s1))
- assert_equal( 1, (s2 <=> s1))
- end
-
- def test_spaceship_platform
- s1 = quick_gem 'a', '1'
- s2 = quick_gem 'a', '1' do |s|
- s.platform = Gem::Platform.new 'x86-my_platform1'
- end
-
- assert_equal( -1, (s1 <=> s2))
- assert_equal( 0, (s1 <=> s1))
- assert_equal( 1, (s2 <=> s1))
- end
-
- def test_spaceship_version
- s1 = quick_gem 'a', '1'
- s2 = quick_gem 'a', '2'
-
- assert_equal( -1, (s1 <=> s2))
- assert_equal( 0, (s1 <=> s1))
- assert_equal( 1, (s2 <=> s1))
- end
-
- def test_summary
- assert_equal 'this is a summary', @a1.summary
- end
-
- def test_test_files
- @a1.test_file = 'test/suite.rb'
- assert_equal ['test/suite.rb'], @a1.test_files
- end
-
- def test_to_ruby
- @a2.required_rubygems_version = Gem::Requirement.new '> 0'
-
- ruby_code = @a2.to_ruby
-
- expected = "Gem::Specification.new do |s|
- s.name = %q{a}
- s.version = \"2\"
-
- s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} if s.respond_to? :specification_version=
-
- s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version=
- s.authors = [\"A User\"]
- s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
- s.description = %q{This is a test description}
- s.email = %q{example@example.com}
- s.files = [\"lib/code.rb\"]
- s.has_rdoc = true
- s.homepage = %q{http://example.com}
- s.require_paths = [\"lib\"]
- s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
- s.summary = %q{this is a summary}
-end
-"
-
- assert_equal expected, ruby_code
-
- same_spec = eval ruby_code
-
- assert_equal @a2, same_spec
- end
-
- def test_to_ruby_fancy
- @a1.platform = Gem::Platform.local
- ruby_code = @a1.to_ruby
-
- local = Gem::Platform.local
- expected_platform = "[#{local.cpu.inspect}, #{local.os.inspect}, #{local.version.inspect}]"
-
- expected = "Gem::Specification.new do |s|
- s.name = %q{a}
- s.version = \"1\"
- s.platform = Gem::Platform.new(#{expected_platform})
-
- s.specification_version = 2 if s.respond_to? :specification_version=
-
- s.required_rubygems_version = Gem::Requirement.new(\">= 0\") if s.respond_to? :required_rubygems_version=
- s.authors = [\"A User\"]
- s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
- s.default_executable = %q{exec}
- s.description = %q{This is a test description}
- s.email = %q{example@example.com}
- s.executables = [\"exec\"]
- s.extensions = [\"ext/a/extconf.rb\"]
- s.files = [\"lib/code.rb\", \"test/suite.rb\", \"bin/exec\", \"ext/a/extconf.rb\"]
- s.has_rdoc = %q{true}
- s.homepage = %q{http://example.com}
- s.require_paths = [\"lib\"]
- s.requirements = [\"A working computer\"]
- s.rubyforge_project = %q{example}
- s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
- s.summary = %q{this is a summary}
- s.test_files = [\"test/suite.rb\"]
-
- s.add_dependency(%q<rake>, [\"> 0.4\"])
- s.add_dependency(%q<jabber4r>, [\"> 0.0.0\"])
- s.add_dependency(%q<pqa>, [\"> 0.4\", \"<= 0.6\"])
-end
-"
-
- assert_equal expected, ruby_code
-
- same_spec = eval ruby_code
-
- assert_equal @a1, same_spec
- end
-
- def test_to_ruby_legacy
- gemspec1 = eval LEGACY_RUBY_SPEC
- ruby_code = gemspec1.to_ruby
- gemspec2 = eval ruby_code
-
- assert_equal gemspec1, gemspec2
- end
-
- def test_to_ruby_platform
- @a2.platform = Gem::Platform.local
- @a2.instance_variable_set :@original_platform, 'old_platform'
-
- ruby_code = @a2.to_ruby
-
- same_spec = eval ruby_code
-
- assert_equal 'old_platform', same_spec.original_platform
- end
-
- def test_to_yaml
- yaml_str = @a1.to_yaml
- same_spec = YAML.load(yaml_str)
-
- assert_equal @a1, same_spec
- end
-
- def test_to_yaml_fancy
- @a1.platform = Gem::Platform.local
- yaml_str = @a1.to_yaml
-
- same_spec = YAML.load(yaml_str)
-
- assert_equal Gem::Platform.local, same_spec.platform
-
- assert_equal @a1, same_spec
- end
-
- def test_to_yaml_platform_empty_string
- @a1.instance_variable_set :@original_platform, ''
-
- assert_match %r|^platform: ruby$|, @a1.to_yaml
- end
-
- def test_to_yaml_platform_legacy
- @a1.platform = 'powerpc-darwin7.9.0'
- @a1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
-
- yaml_str = @a1.to_yaml
-
- same_spec = YAML.load(yaml_str)
-
- assert_equal Gem::Platform.new('powerpc-darwin7'), same_spec.platform
- assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
- end
-
- def test_to_yaml_platform_nil
- @a1.instance_variable_set :@original_platform, nil
-
- assert_match %r|^platform: ruby$|, @a1.to_yaml
- end
-
- def test_validate
- Dir.chdir @tempdir do
- assert @a1.validate
- end
- end
-
- def test_validate_authors
- Dir.chdir @tempdir do
- @a1.authors = []
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: no author specified\n", @ui.error, 'error'
-
- @a1.authors = [Object.new]
-
- e = assert_raise Gem::InvalidSpecificationException do
- @a1.validate
- end
-
- assert_equal 'authors must be Array of Strings', e.message
- end
- end
-
- def test_validate_autorequire
- Dir.chdir @tempdir do
- @a1.autorequire = 'code'
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: deprecated autorequire specified\n",
- @ui.error, 'error'
- end
- end
-
- def test_validate_email
- Dir.chdir @tempdir do
- @a1.email = ''
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: no email specified\n", @ui.error, 'error'
- end
- end
-
- def test_validate_empty
- e = assert_raise Gem::InvalidSpecificationException do
- Gem::Specification.new.validate
- end
-
- assert_equal 'missing value for attribute name', e.message
- end
-
- def test_validate_executables
- FileUtils.mkdir_p File.join(@tempdir, 'bin')
- File.open File.join(@tempdir, 'bin', 'exec'), 'w' do end
-
- use_ui @ui do
- Dir.chdir @tempdir do
- assert @a1.validate
- end
- end
-
- assert_equal '', @ui.output, 'output'
- assert_equal "WARNING: bin/exec is missing #! line\n", @ui.error, 'error'
- end
-
- def test_validate_empty_require_paths
- @a1.require_paths = []
- e = assert_raise Gem::InvalidSpecificationException do
- @a1.validate
- end
-
- assert_equal 'specification must have at least one require_path', e.message
- end
-
- def test_validate_homepage
- Dir.chdir @tempdir do
- @a1.homepage = ''
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
- end
- end
-
- def test_validate_has_rdoc
- Dir.chdir @tempdir do
- @a1.has_rdoc = false
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: RDoc will not be generated (has_rdoc == false)\n",
- @ui.error, 'error'
- end
- end
-
- def test_validate_platform_legacy
- Dir.chdir @tempdir do
- @a1.platform = 'mswin32'
- assert @a1.validate
-
- @a1.platform = 'i586-linux'
- assert @a1.validate
-
- @a1.platform = 'powerpc-darwin'
- assert @a1.validate
- end
- end
-
- def test_validate_rubyforge_project
- Dir.chdir @tempdir do
- @a1.rubyforge_project = ''
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: no rubyforge_project specified\n",
- @ui.error, 'error'
- end
- end
-
- def test_validate_rubygems_version
- @a1.rubygems_version = "3"
- e = assert_raise Gem::InvalidSpecificationException do
- @a1.validate
- end
-
- assert_equal "expected RubyGems version #{Gem::RubyGemsVersion}, was 3",
- e.message
- end
-
- def test_validate_summary
- Dir.chdir @tempdir do
- @a1.summary = ''
-
- use_ui @ui do
- @a1.validate
- end
-
- assert_equal "WARNING: no summary specified\n", @ui.error, 'error'
- end
- end
-
- def test_version
- assert_equal Gem::Version.new('1'), @a1.version
- end
-
-end
-
diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb
deleted file mode 100644
index a8564ba94f..0000000000
--- a/test/rubygems/test_gem_stream_ui.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/user_interaction'
-
-class TestGemStreamUI < RubyGemTestCase
-
- module IsTty
- attr_accessor :tty
-
- def tty?
- @tty = true unless defined? @tty
- return @tty
- end
-
- alias_method :isatty, :tty?
- end
-
- def setup
- super
-
- @cfg = Gem.configuration
-
- @in = StringIO.new
- @out = StringIO.new
- @err = StringIO.new
-
- @in.extend IsTty
-
- @sui = Gem::StreamUI.new @in, @out, @err
- end
-
- def test_ask
- timeout(1) do
- expected_answer = "Arthur, King of the Britons"
- @in.string = "#{expected_answer}\n"
- actual_answer = @sui.ask("What is your name?")
- assert_equal expected_answer, actual_answer
- end
- end
-
- def test_ask_no_tty
- @in.tty = false
-
- timeout(0.1) do
- answer = @sui.ask("what is your favorite color?")
- assert_equal nil, answer
- end
- end
-
- def test_ask_yes_no_no_tty_with_default
- @in.tty = false
-
- timeout(0.1) do
- answer = @sui.ask_yes_no("do coconuts migrate?", false)
- assert_equal false, answer
-
- answer = @sui.ask_yes_no("do coconuts migrate?", true)
- assert_equal true, answer
- end
- end
-
- def test_ask_yes_no_no_tty_without_default
- @in.tty = false
-
- timeout(0.1) do
- assert_raises(Gem::OperationNotSupportedError) do
- @sui.ask_yes_no("do coconuts migrate?")
- end
- end
- end
-
- def test_choose_from_list
- @in.puts "1"
- @in.rewind
-
- result = @sui.choose_from_list 'which one?', %w[foo bar]
-
- assert_equal ['foo', 0], result
- assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
- end
-
- def test_choose_from_list_EOF
- result = @sui.choose_from_list 'which one?', %w[foo bar]
-
- assert_equal [nil, nil], result
- assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
- end
-
- def test_proress_reporter_silent_nil
- @cfg.verbose = nil
- reporter = @sui.progress_reporter 10, 'hi'
- assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
- end
-
- def test_proress_reporter_silent_false
- @cfg.verbose = false
- reporter = @sui.progress_reporter 10, 'hi'
- assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
- assert_equal "", @out.string
- end
-
- def test_proress_reporter_simple
- @cfg.verbose = true
- reporter = @sui.progress_reporter 10, 'hi'
- assert_kind_of Gem::StreamUI::SimpleProgressReporter, reporter
- assert_equal "hi\n", @out.string
- end
-
- def test_proress_reporter_verbose
- @cfg.verbose = 0
- reporter = @sui.progress_reporter 10, 'hi'
- assert_kind_of Gem::StreamUI::VerboseProgressReporter, reporter
- assert_equal "hi\n", @out.string
- end
-
-end
-
diff --git a/test/rubygems/test_gem_validator.rb b/test/rubygems/test_gem_validator.rb
deleted file mode 100644
index c910cfdf11..0000000000
--- a/test/rubygems/test_gem_validator.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
-require 'rubygems/validator'
-
-class TestGemValidator < RubyGemTestCase
-
- def setup
- super
-
- @simple_gem = SIMPLE_GEM
- @validator = Gem::Validator.new
- end
-
- def test_verify_gem_file
- gem_file = File.join @tempdir, 'simple_gem.gem'
- File.open gem_file, 'wb' do |fp| fp.write @simple_gem end
-
- assert_equal nil, @validator.verify_gem_file(gem_file)
- end
-
- def test_verify_gem_file_empty
- e = assert_raise Gem::VerificationError do
- @validator.verify_gem_file ''
- end
-
- assert_equal 'missing gem file ', e.message
- end
-
- def test_verify_gem_file_nonexistent
- file = '/nonexistent/nonexistent.gem'
- e = assert_raise Gem::VerificationError do
- @validator.verify_gem_file file
- end
-
- assert_equal "missing gem file #{file}", e.message
- end
-
- def test_verify_gem
- assert_equal nil, @validator.verify_gem(@simple_gem)
- end
-
- def test_verify_gem_empty
- e = assert_raise Gem::VerificationError do
- @validator.verify_gem ''
- end
-
- assert_equal 'empty gem file', e.message
- end
-
- def test_verify_gem_invalid_checksum
- e = assert_raise Gem::VerificationError do
- @validator.verify_gem @simple_gem.upcase
- end
-
- assert_equal 'invalid checksum for gem file', e.message
- end
-
- def test_verify_gem_no_sum
- assert_equal nil, @validator.verify_gem('words')
- end
-
-end
-
diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb
deleted file mode 100644
index 99dd49933d..0000000000
--- a/test/rubygems/test_gem_version.rb
+++ /dev/null
@@ -1,206 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/version'
-
-class TestGemVersion < RubyGemTestCase
-
- def setup
- super
-
- @v1_0 = Gem::Version.new '1.0'
- @v1_2 = Gem::Version.new '1.2'
- @v1_3 = Gem::Version.new '1.3'
- end
-
- def test_class_create
- assert_version Gem::Version.create('1.0')
- assert_version Gem::Version.create("1.0 ")
- assert_version Gem::Version.create(" 1.0 ")
- assert_version Gem::Version.create("1.0\n")
- assert_version Gem::Version.create("\n1.0\n")
-
- assert_equal Gem::Version.create('1'), Gem::Version.create(1)
- end
-
- def test_class_create_malformed
- e = assert_raise ArgumentError do Gem::Version.create("junk") end
- assert_equal "Malformed version number string junk", e.message
-
- e = assert_raise ArgumentError do Gem::Version.create("1.0\n2.0") end
- assert_equal "Malformed version number string 1.0\n2.0", e.message
- end
-
- def test_bad
- assert_inadequate( "", "> 0.1")
- assert_inadequate( "1.2.3", "!= 1.2.3")
- assert_inadequate( "1.2.003.0.0", "!= 1.02.3")
- assert_inadequate( "4.5.6", "< 1.2.3")
- assert_inadequate( "1.0", "> 1.1")
- assert_inadequate( "0", ">")
- assert_inadequate( "0", "<")
- assert_inadequate( "", "= 0.1")
- assert_inadequate( "1.1.1", "> 1.1.1")
- assert_inadequate( "1.2", "= 1.1")
- assert_inadequate( "1.40", "= 1.1")
- assert_inadequate( "1.3", "= 1.40")
- assert_inadequate( "9.3.3", "<= 9.3.2")
- assert_inadequate( "9.3.1", ">= 9.3.2")
- assert_inadequate( "9.3.03", "<= 9.3.2")
- assert_inadequate( "1.0.0.1", "= 1.0")
- end
-
- def test_bump_trailing_zeros
- v = Gem::Version.new("5.0.0")
- assert_equal "5.1", v.bump.to_s
- end
-
- def test_bump
- v = Gem::Version.new("5.2.4")
- assert_equal "5.3", v.bump.to_s
- end
-
- def test_bump_one_level
- v = Gem::Version.new("5")
- assert_equal "6", v.bump.to_s
- end
-
- def test_eql_eh
- v = Gem::Version.new("1.2")
-
- assert_equal true, v.eql?(@v1_2)
- assert_equal true, @v1_2.eql?(v)
-
- assert_equal false, @v1_2.eql?(@v1_3)
- assert_equal false, @v1_3.eql?(@v1_2)
- end
-
- def test_equals2
- v = Gem::Version.new("1.2")
-
- assert_equal v, @v1_2
- assert_equal @v1_2, v
-
- assert_not_equal @v1_2, @v1_3
- assert_not_equal @v1_3, @v1_2
- end
-
- def test_hash
- v = Gem::Version.new("1.2")
- assert_equal v.hash, @v1_2.hash
- assert_not_equal @v1_2.hash, @v1_3.hash
- end
-
- def test_illformed_requirements
- [ ">>> 1.3.5", "> blah" ].each do |rq|
- assert_raises(ArgumentError, "req [#{rq}] should fail") {
- Gem::Version::Requirement.new(rq)
- }
- end
- end
-
- def test_normalize
- assert_equal [1], Gem::Version.new("1").to_ints
- assert_equal [1], Gem::Version.new("1.0").to_ints
- assert_equal [1, 1], Gem::Version.new("1.1").to_ints
- end
-
- def test_ok
- assert_adequate( "0.2.33", "= 0.2.33")
- assert_adequate( "0.2.34", "> 0.2.33")
- assert_adequate( "1.0", "= 1.0")
- assert_adequate( "1.0", "1.0")
- assert_adequate( "1.8.2", "> 1.8.0")
- assert_adequate( "1.112", "> 1.111")
- assert_adequate( "0.2", "> 0.0.0")
- assert_adequate( "0.0.0.0.0.2", "> 0.0.0")
- assert_adequate( "0.0.1.0", "> 0.0.0.1")
- assert_adequate( "10.3.2", "> 9.3.2")
- assert_adequate( "1.0.0.0", "= 1.0")
- assert_adequate( "10.3.2", "!= 9.3.4")
- assert_adequate( "10.3.2", "> 9.3.2")
- assert_adequate( "10.3.2", "> 9.3.2")
- assert_adequate( " 9.3.2", ">= 9.3.2")
- assert_adequate( "9.3.2 ", ">= 9.3.2")
- assert_adequate( "", "= 0")
- assert_adequate( "", "< 0.1")
- assert_adequate( " ", "< 0.1 ")
- assert_adequate( "", " < 0.1")
- assert_adequate( "0", "=")
- assert_adequate( "0", ">=")
- assert_adequate( "0", "<=")
- end
-
- def test_satisfied_by_eh_boxed
- assert_inadequate("1.3", "~> 1.4")
- assert_adequate( "1.4", "~> 1.4")
- assert_adequate( "1.5", "~> 1.4")
- assert_inadequate("2.0", "~> 1.4")
-
- assert_inadequate("1.3", "~> 1.4.4")
- assert_inadequate("1.4", "~> 1.4.4")
- assert_adequate( "1.4.4", "~> 1.4.4")
- assert_adequate( "1.4.5", "~> 1.4.4")
- assert_inadequate("1.5", "~> 1.4.4")
- assert_inadequate("2.0", "~> 1.4.4")
- end
-
- def test_satisfied_by_eh_multiple
- req = [">= 1.4", "<= 1.6", "!= 1.5"]
- assert_inadequate("1.3", req)
- assert_adequate( "1.4", req)
- assert_inadequate("1.5", req)
- assert_adequate( "1.6", req)
- assert_inadequate("1.7", req)
- assert_inadequate("2.0", req)
- end
-
- def test_spaceship
- assert_equal 1, Gem::Version.new('1.8.2') <=> Gem::Version.new('0.0.0')
- end
-
- def test_boxed
- assert_inadequate("1.3", "~> 1.4")
- assert_adequate( "1.4", "~> 1.4")
- assert_adequate( "1.5", "~> 1.4")
- assert_inadequate("2.0", "~> 1.4")
-
- assert_inadequate("1.3", "~> 1.4.4")
- assert_inadequate("1.4", "~> 1.4.4")
- assert_adequate( "1.4.4", "~> 1.4.4")
- assert_adequate( "1.4.5", "~> 1.4.4")
- assert_inadequate("1.5", "~> 1.4.4")
- assert_inadequate("2.0", "~> 1.4.4")
- end
-
- def test_to_s
- v = Gem::Version.new("5.2.4")
- assert_equal "5.2.4", v.to_s
- end
-
- def assert_adequate(version, requirement)
- ver = Gem::Version.new(version)
- req = Gem::Version::Requirement.new(requirement)
- assert req.satisfied_by?(ver),
- "Version #{version} should be adequate for Requirement #{requirement}"
- end
-
- def assert_inadequate(version, requirement)
- ver = Gem::Version.new(version)
- req = Gem::Version::Requirement.new(requirement)
- assert ! req.satisfied_by?(ver),
- "Version #{version} should not be adequate for Requirement #{requirement}"
- end
-
- def assert_version(actual)
- assert_equal @v1_0, actual
- assert_equal @v1_0.version, actual.version
- end
-
-end
-
diff --git a/test/rubygems/test_gem_version_option.rb b/test/rubygems/test_gem_version_option.rb
deleted file mode 100644
index 30c73390fe..0000000000
--- a/test/rubygems/test_gem_version_option.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-require 'rubygems/command'
-require 'rubygems/version_option'
-
-class TestGemVersionOption < RubyGemTestCase
-
- def setup
- super
-
- @cmd = Gem::Command.new 'dummy', 'dummy'
- @cmd.extend Gem::VersionOption
- end
-
- def test_add_platform_option
- @cmd.add_platform_option
-
- assert @cmd.handles?(%w[--platform x86-darwin])
- end
-
- def test_add_version_option
- @cmd.add_version_option
-
- assert @cmd.handles?(%w[--version >1])
- end
-
- def test_platform_option
- @cmd.add_platform_option
-
- @cmd.handle_options %w[--platform x86-freebsd6 --platform x86-freebsd7]
-
- expected = [
- Gem::Platform::RUBY,
- Gem::Platform.new('x86-freebsd6'),
- Gem::Platform.new('x86-freebsd7'),
- ]
-
- assert_equal expected, Gem.platforms
- end
-
- def test_platform_option_ruby
- @cmd.add_platform_option
-
- @cmd.handle_options %w[--platform ruby]
-
- expected = [
- Gem::Platform::RUBY
- ]
-
- assert_equal expected, Gem.platforms
- end
-
- def test_platform_option_twice
- @cmd.add_platform_option
-
- @cmd.handle_options %w[--platform x86-freebsd6 --platform x86-freebsd-6]
-
- expected = [
- Gem::Platform::RUBY,
- Gem::Platform.new('x86-freebsd6'),
- ]
-
- assert_equal expected, Gem.platforms
- end
-
- def test_version_option
- @cmd.add_version_option
-
- @cmd.handle_options %w[--version >1]
-
- expected = { :version => Gem::Requirement.new('> 1'), :args => [] }
-
- assert_equal expected, @cmd.options
- end
-
-end
-
diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb
deleted file mode 100644
index e06a78e32a..0000000000
--- a/test/rubygems/test_kernel.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
-
-class TestKernel < RubyGemTestCase
-
- def setup
- super
-
- @old_path = $:.dup
-
- util_make_gems
- end
-
- def teardown
- super
-
- $:.replace @old_path
- end
-
- def test_gem
- assert gem('a', '= 1'), "Should load"
- assert $:.any? { |p| %r{a-1/lib} =~ p }
- assert $:.any? { |p| %r{a-1/bin} =~ p }
- end
-
- def test_gem_redundent
- assert gem('a', '= 1'), "Should load"
- assert ! gem('a', '= 1'), "Should not load"
- assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
- assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
- end
-
- def test_gem_overlapping
- assert gem('a', '= 1'), "Should load"
- assert ! gem('a', '>= 1'), "Should not load"
- assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
- assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
- end
-
- def test_gem_conflicting
- assert gem('a', '= 1'), "Should load"
-
- ex = assert_raise Gem::Exception do
- gem 'a', '= 2'
- end
-
- assert_match(/activate a \(= 2\)/, ex.message)
- assert_match(/activated a-1/, ex.message)
-
- assert $:.any? { |p| %r{a-1/lib} =~ p }
- assert $:.any? { |p| %r{a-1/bin} =~ p }
- assert ! $:.any? { |p| %r{a-2/lib} =~ p }
- assert ! $:.any? { |p| %r{a-2/bin} =~ p }
- end
-
-end
-
diff --git a/test/rubygems/test_open_uri.rb b/test/rubygems/test_open_uri.rb
deleted file mode 100644
index 6f18b7bb6b..0000000000
--- a/test/rubygems/test_open_uri.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'test/unit'
-require 'rubygems/gem_open_uri'
-
-class TestOpenURI < Test::Unit::TestCase
-
- def test_open_uri_not_broken
- assert_nothing_raised do
- open __FILE__ do end
- end
- end
-
-end
-
diff --git a/test/rubygems/test_package.rb b/test/rubygems/test_package.rb
deleted file mode 100644
index 60ab76aa3b..0000000000
--- a/test/rubygems/test_package.rb
+++ /dev/null
@@ -1,610 +0,0 @@
-#--
-# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
-# All rights reserved.
-# See LICENSE.txt for permissions.
-#++
-
-require 'test/unit'
-require 'stringio'
-require 'fileutils'
-
-require 'rubygems'
-require 'rubygems/package'
-
-class File
-
- # straight from setup.rb
- def self.dir?(path)
- # for corrupted windows stat()
- File.directory?((path[-1,1] == '/') ? path : path + '/')
- end
-
- def self.read_b(name)
- File.open(name, "rb"){|f| f.read}
- end
-
-end
-
-class TarTestCase < Test::Unit::TestCase
-
- undef_method :default_test if instance_methods.include? 'default_test' or
- instance_methods.include? :default_test
-
- def assert_headers_equal(h1, h2)
- fields = %w[name 100 mode 8 uid 8 gid 8 size 12 mtime 12 checksum 8
- typeflag 1 linkname 100 magic 6 version 2 uname 32
- gname 32 devmajor 8 devminor 8 prefix 155]
- offset = 0
- until fields.empty?
- name = fields.shift
- length = fields.shift.to_i
- if name == "checksum"
- chksum_off = offset
- offset += length
- next
- end
- assert_equal(h1[offset, length], h2[offset, length],
- "Field #{name} of the tar header differs.")
- offset += length
- end
- assert_equal(h1[chksum_off, 8], h2[chksum_off, 8])
- end
-
- def tar_file_header(fname, dname, mode, length)
- h = header("0", fname, dname, length, mode)
- checksum = calc_checksum(h)
- header("0", fname, dname, length, mode, checksum)
- end
-
- def tar_dir_header(name, prefix, mode)
- h = header("5", name, prefix, 0, mode)
- checksum = calc_checksum(h)
- header("5", name, prefix, 0, mode, checksum)
- end
-
- def header(type, fname, dname, length, mode, checksum = nil)
- checksum ||= " " * 8
-
- arr = [ # struct tarfile_entry_posix
- ASCIIZ(fname, 100), # char name[100]; ASCII + (Z unless filled)
- Z(to_oct(mode, 7)), # char mode[8]; 0 padded, octal null
- Z(to_oct(0, 7)), # char uid[8]; ditto
- Z(to_oct(0, 7)), # char gid[8]; ditto
- Z(to_oct(length, 11)), # char size[12]; 0 padded, octal, null
- Z(to_oct(0, 11)), # char mtime[12]; 0 padded, octal, null
- checksum, # char checksum[8]; 0 padded, octal, null, space
- type, # char typeflag[1]; file: "0" dir: "5"
- "\0" * 100, # char linkname[100]; ASCII + (Z unless filled)
- "ustar\0", # char magic[6]; "ustar\0"
- "00", # char version[2]; "00"
- ASCIIZ("wheel", 32), # char uname[32]; ASCIIZ
- ASCIIZ("wheel", 32), # char gname[32]; ASCIIZ
- Z(to_oct(0, 7)), # char devmajor[8]; 0 padded, octal, null
- Z(to_oct(0, 7)), # char devminor[8]; 0 padded, octal, null
- ASCIIZ(dname, 155) # char prefix[155]; ASCII + (Z unless filled)
- ]
-
- format = "C100C8C8C8C12C12C8CC100C6C2C32C32C8C8C155"
- h = if RUBY_VERSION >= "1.9" then
- arr.join
- else
- arr = arr.join("").split(//).map{|x| x[0]}
- arr.pack format
- end
- ret = h + "\0" * (512 - h.size)
- assert_equal(512, ret.size)
- ret
- end
-
- def calc_checksum(header)
- sum = header.unpack("C*").inject{|s,a| s + a}
- SP(Z(to_oct(sum, 6)))
- end
-
- def to_oct(n, pad_size)
- "%0#{pad_size}o" % n
- end
-
- def ASCIIZ(str, length)
- str + "\0" * (length - str.length)
- end
-
- def SP(s)
- s + " "
- end
-
- def Z(s)
- s + "\0"
- end
-
- def SP_Z(s)
- s + " \0"
- end
-
-end
-
-class TestTarHeader < TarTestCase
-
- def test_arguments_are_checked
- e = ArgumentError
- gpth = Gem::Package::TarHeader
- assert_raises(e) { gpth.new :name=>"", :size=>"", :mode=>"" }
- assert_raises(e) { gpth.new :name=>"", :size=>"", :prefix=>"" }
- assert_raises(e) { gpth.new :name=>"", :prefix=>"", :mode=>"" }
- assert_raises(e) { gpth.new :prefix=>"", :size=>"", :mode=>"" }
- end
-
- def test_basic_headers
- header = Gem::Package::TarHeader.new(:name => "bla", :mode => 012345,
- :size => 10, :prefix => "").to_s
- assert_headers_equal(tar_file_header("bla", "", 012345, 10), header.to_s)
- header = Gem::Package::TarHeader.new(:name => "bla", :mode => 012345,
- :size => 0, :prefix => "",
- :typeflag => "5" ).to_s
- assert_headers_equal(tar_dir_header("bla", "", 012345), header)
- end
-
- def test_long_name_works
- header = Gem::Package::TarHeader.new(:name => "a" * 100, :mode => 012345,
- :size => 10, :prefix => "").to_s
- assert_headers_equal(tar_file_header("a" * 100, "", 012345, 10), header)
-
- header = Gem::Package::TarHeader.new(:name => "a" * 100, :mode => 012345,
- :size => 10, :prefix => "bb" * 60).to_s
- assert_headers_equal(tar_file_header("a" * 100, "bb" * 60, 012345, 10),
- header)
- end
-
- def test_new_from_stream
- header = tar_file_header("a" * 100, "", 012345, 10)
- h = nil
- header = StringIO.new header
- assert_nothing_raised{ h = Gem::Package::TarHeader.new_from_stream header }
- assert_equal("a" * 100, h.name)
- assert_equal(012345, h.mode)
- assert_equal(10, h.size)
- assert_equal("", h.prefix)
- assert_equal("ustar", h.magic)
- end
-
-end
-
-class TestTarInput < TarTestCase
-
- # Sometimes the setgid bit doesn't take. Don't know if this
- # is a problem on all systems, or just some. But for now, we
- # will ignore it in the tests.
- SETGID_BIT = 02000
-
- def setup
- FileUtils.mkdir_p "data__"
- inner_tar = tar_file_header("bla", "", 0612, 10)
- inner_tar += "0123456789" + "\0" * 502
- inner_tar += tar_file_header("foo", "", 0636, 5)
- inner_tar += "01234" + "\0" * 507
- inner_tar += tar_dir_header("__dir__", "", 0600)
- inner_tar += "\0" * 1024
- str = StringIO.new ""
- begin
- os = Zlib::GzipWriter.new str
- os.write inner_tar
- ensure
- os.finish
- end
- str.rewind
- File.open("data__/bla.tar", "wb") do |f|
- f.write tar_file_header("data.tar.gz", "", 0644, str.string.size)
- f.write str.string
- f.write "\0" * ((512 - (str.string.size % 512)) % 512 )
- @spec = Gem::Specification.new do |spec|
- spec.author = "Mauricio :)"
- end
- meta = @spec.to_yaml
- f.write tar_file_header("metadata", "", 0644, meta.size)
- f.write meta + "\0" * (1024 - meta.size)
- f.write "\0" * 1024
- end
- @file = "data__/bla.tar"
- @entry_names = %w{bla foo __dir__}
- @entry_sizes = [10, 5, 0]
- #FIXME: are these modes system dependent?
- @entry_modes = [0100612, 0100636, 040600]
- @entry_files = %w{data__/bla data__/foo}
- @entry_contents = %w[0123456789 01234]
- end
-
- def teardown
- # FileUtils.rm_rf "data__"
- end
-
- def test_each_works
- Gem::Package::TarInput.open(@file) do |is|
- count = 0
-
- is.each_with_index do |entry, i|
- count = i
-
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- assert_equal(@entry_names[i], entry.name)
- assert_equal(@entry_sizes[i], entry.size)
- end
-
- assert_equal 2, count
-
- assert_equal @spec, is.metadata
- end
- end
-
- def test_extract_entry_works
- Gem::Package::TarInput.open(@file) do |is|
- assert_equal @spec, is.metadata
- count = 0
-
- is.each_with_index do |entry, i|
- count = i
- is.extract_entry "data__", entry
- name = File.join("data__", entry.name)
-
- if entry.is_directory?
- assert File.dir?(name)
- else
- assert File.file?(name)
- assert_equal(@entry_sizes[i], File.stat(name).size)
- #FIXME: win32? !!
- end
-
- unless ::Config::CONFIG["arch"] =~ /msdos|win32/i
- assert_equal(@entry_modes[i],
- File.stat(name).mode & (~SETGID_BIT))
- end
- end
-
- assert_equal 2, count
- end
-
- @entry_files.each_with_index do |x, i|
- assert(File.file?(x))
- assert_equal(@entry_contents[i], File.read_b(x))
- end
- end
-
-end
-
-class TestTarOutput < TarTestCase
-
- def setup
- FileUtils.mkdir_p "data__", :verbose=>false
- @file = "data__/bla2.tar"
- end
-
- def teardown
- FileUtils.rm_rf "data__"
- end
-
- def test_file_looks_good
- Gem::Package::TarOutput.open(@file) do |os|
- os.metadata = "bla".to_yaml
- end
- f = File.open(@file, "rb")
- Gem::Package::TarReader.new(f) do |is|
- i = 0
- is.each do |entry|
- case i
- when 0
- assert_equal("data.tar.gz", entry.name)
- when 1
- assert_equal("metadata.gz", entry.name)
- gzis = Zlib::GzipReader.new entry
- assert_equal("bla".to_yaml, gzis.read)
- gzis.close
- end
- i += 1
- end
- assert_equal(2, i)
- end
- ensure
- f.close
- end
-
-end
-
-class TestTarReader < TarTestCase
-
- def test_eof_works
- str = tar_file_header("bar", "baz", 0644, 0)
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- data = entry.read
- assert_equal(nil, data)
- assert_equal(nil, entry.read(10))
- assert_equal(nil, entry.read)
- assert_equal(nil, entry.getc)
- assert_equal(true, entry.eof?)
- end
- end
- str = tar_dir_header("foo", "bar", 012345)
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- data = entry.read
- assert_equal(nil, data)
- assert_equal(nil, entry.read(10))
- assert_equal(nil, entry.read)
- assert_equal(nil, entry.getc)
- assert_equal(true, entry.eof?)
- end
- end
- str = tar_dir_header("foo", "bar", 012345)
- str += tar_file_header("bar", "baz", 0644, 0)
- str += tar_file_header("bar", "baz", 0644, 0)
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- data = entry.read
- assert_equal(nil, data)
- assert_equal(nil, entry.read(10))
- assert_equal(nil, entry.read)
- assert_equal(nil, entry.getc)
- assert_equal(true, entry.eof?)
- end
- end
- end
-
- def test_multiple_entries
- str = tar_file_header("lib/foo", "", 010644, 10) + "\0" * 512
- str += tar_file_header("bar", "baz", 0644, 0)
- str += tar_dir_header("foo", "bar", 012345)
- str += "\0" * 1024
- names = %w[lib/foo bar foo]
- prefixes = ["", "baz", "bar"]
- modes = [010644, 0644, 012345]
- sizes = [10, 0, 0]
- isdir = [false, false, true]
- isfile = [true, true, false]
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- i = 0
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- assert_equal(names[i], entry.name)
- assert_equal(prefixes[i], entry.prefix)
- assert_equal(sizes[i], entry.size)
- assert_equal(modes[i], entry.mode)
- assert_equal(isdir[i], entry.is_directory?)
- assert_equal(isfile[i], entry.is_file?)
- if prefixes[i] != ""
- assert_equal(File.join(prefixes[i], names[i]),
- entry.full_name)
- else
- assert_equal(names[i], entry.name)
- end
- i += 1
- end
- assert_equal(names.size, i)
- end
- end
-
- def test_read_works
- contents = ('a'..'z').inject(""){|s,x| s << x * 100}
- str = tar_file_header("lib/foo", "", 010644, contents.size) + contents
- str += "\0" * (512 - (str.size % 512))
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- data = entry.read(3000) # bigger than contents.size
- assert_equal(contents, data)
- assert_equal(true, entry.eof?)
- end
- end
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- data = entry.read(100)
- (entry.size - data.size).times {|i| data << entry.getc.chr }
- assert_equal(contents, data)
- assert_equal(nil, entry.read(10))
- assert_equal(true, entry.eof?)
- end
- end
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- assert_kind_of(Gem::Package::TarReader::Entry, entry)
- data = entry.read
- assert_equal(contents, data)
- assert_equal(nil, entry.read(10))
- assert_equal(nil, entry.read)
- assert_equal(nil, entry.getc)
- assert_equal(true, entry.eof?)
- end
- end
- end
-
- def test_rewind_entry_works
- content = ('a'..'z').to_a.join(" ")
- str = tar_file_header("lib/foo", "", 010644, content.size) + content +
- "\0" * (512 - content.size)
- str << "\0" * 1024
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- is.each_entry do |entry|
- 3.times do
- entry.rewind
- assert_equal(content, entry.read)
- assert_equal(content.size, entry.pos)
- end
- end
- end
- end
-
- def test_rewind_works
- content = ('a'..'z').to_a.join(" ")
- str = tar_file_header("lib/foo", "", 010644, content.size) + content +
- "\0" * (512 - content.size)
- str << "\0" * 1024
- Gem::Package::TarReader.new(StringIO.new(str)) do |is|
- 3.times do
- is.rewind
- i = 0
- is.each_entry do |entry|
- assert_equal(content, entry.read)
- i += 1
- end
- assert_equal(1, i)
- end
- end
- end
-
-end
-
-class TestTarWriter < TarTestCase
-
- class DummyIO
- attr_reader :data
- def initialize
- @data = ""
- end
- def write(dat)
- data << dat
- dat.size
- end
- def reset
- @data = ""
- end
- end
-
- def setup
- @data = "a" * 10
- @dummyos = DummyIO.new
- @os = Gem::Package::TarWriter.new(@dummyos)
- end
-
- def teardown
- @os.close
- end
-
- def test_add_file
- dummyos = StringIO.new
- class << dummyos
- def method_missing(meth, *a)
- self.string.send(meth, *a)
- end
- end
-
- content1 = ('a'..'z').to_a.join("") # 26
- content2 = ('aa'..'zz').to_a.join("") # 1352
-
- Gem::Package::TarWriter.new(dummyos) do |os|
- os.add_file("lib/foo/bar", 0644) {|f| f.write "a" * 10 }
- os.add_file("lib/bar/baz", 0644) {|f| f.write content1 }
- os.add_file("lib/bar/baz", 0644) {|f| f.write content2 }
- os.add_file("lib/bar/baz", 0644) {|f| }
- end
-
- assert_headers_equal(tar_file_header("lib/foo/bar", "", 0644, 10),
- dummyos[0,512])
- assert_equal("a" * 10 + "\0" * 502, dummyos[512,512])
- offset = 512 * 2
- [content1, content2, ""].each do |data|
- assert_headers_equal(tar_file_header("lib/bar/baz", "", 0644,
- data.size),
- dummyos[offset,512])
- offset += 512
- until !data || data == ""
- chunk = data[0,512]
- data[0,512] = ""
- assert_equal(chunk + "\0" * (512-chunk.size),
- dummyos[offset,512])
- offset += 512
- end
- end
- assert_equal("\0" * 1024, dummyos[offset,1024])
- end
-
- def test_add_file_simple
- @dummyos.reset
- Gem::Package::TarWriter.new(@dummyos) do |os|
- os.add_file_simple("lib/foo/bar", 0644, 10) {|f| f.write "a" * 10 }
- os.add_file_simple("lib/bar/baz", 0644, 100) {|f| f.write "fillme"}
- end
- assert_headers_equal(tar_file_header("lib/foo/bar", "", 0644, 10),
- @dummyos.data[0,512])
- assert_equal("a" * 10 + "\0" * 502, @dummyos.data[512,512])
- assert_headers_equal(tar_file_header("lib/bar/baz", "", 0644, 100),
- @dummyos.data[512*2,512])
- assert_equal("fillme" + "\0" * 506, @dummyos.data[512*3,512])
- assert_equal("\0" * 512, @dummyos.data[512*4, 512])
- assert_equal("\0" * 512, @dummyos.data[512*5, 512])
- end
-
- def test_add_file_tests_seekability
- assert_raises(Gem::Package::NonSeekableIO) do
- @os.add_file("libdfdsfd", 0644) {|f| }
- end
- end
-
- def test_file_name_is_split_correctly
- # test insane file lengths, and
- # a{100}/b{155}, etc
- @dummyos.reset
- names = ["a" * 155 + '/' + "b" * 100, "a" * 151 + "/" + ("qwer/" * 19) + "bla" ]
- o_names = ["b" * 100, "qwer/" * 19 + "bla"]
- o_prefixes = ["a" * 155, "a" * 151]
- names.each {|name| @os.add_file_simple(name, 0644, 10) { } }
- o_names.each_with_index do |nam, i|
- assert_headers_equal(tar_file_header(nam, o_prefixes[i], 0644, 10),
- @dummyos.data[2*i*512,512])
- end
- assert_raises(Gem::Package::TooLongFileName) do
- @os.add_file_simple(File.join("a" * 152, "b" * 10, "a" * 92), 0644,10) {}
- end
- assert_raises(Gem::Package::TooLongFileName) do
- @os.add_file_simple(File.join("a" * 162, "b" * 10), 0644,10) {}
- end
- assert_raises(Gem::Package::TooLongFileName) do
- @os.add_file_simple(File.join("a" * 10, "b" * 110), 0644,10) {}
- end
- end
-
- def test_file_size_is_checked
- @dummyos.reset
- assert_raises(Gem::Package::TarWriter::FileOverflow) do
- @os.add_file_simple("lib/foo/bar", 0644, 10) {|f| f.write "1" * 100}
- end
- assert_nothing_raised do
- @os.add_file_simple("lib/foo/bar", 0644, 10) {|f| }
- end
- end
-
- def test_write_data
- @dummyos.reset
- @os.add_file_simple("lib/foo/bar", 0644, 10) { |f| f.write @data }
- @os.flush
- assert_equal(@data + ("\0" * (512-@data.size)),
- @dummyos.data[512,512])
- end
-
- def test_write_header
- @dummyos.reset
- @os.add_file_simple("lib/foo/bar", 0644, 0) { |f| }
- @os.flush
- assert_headers_equal(tar_file_header("lib/foo/bar", "", 0644, 0),
- @dummyos.data[0,512])
- @dummyos.reset
- @os.mkdir("lib/foo", 0644)
- assert_headers_equal(tar_dir_header("lib/foo", "", 0644),
- @dummyos.data[0,512])
- @os.mkdir("lib/bar", 0644)
- assert_headers_equal(tar_dir_header("lib/bar", "", 0644),
- @dummyos.data[512*1,512])
- end
-
- def test_write_operations_fail_after_closed
- @dummyos.reset
- @os.add_file_simple("sadd", 0644, 20) { |f| }
- @os.close
- assert_raises(Gem::Package::ClosedIO) { @os.flush }
- assert_raises(Gem::Package::ClosedIO) { @os.add_file("dfdsf", 0644){} }
- assert_raises(Gem::Package::ClosedIO) { @os.mkdir "sdfdsf", 0644 }
- end
-
-end
-
diff --git a/test/runner.rb b/test/runner.rb
index f9ed25a931..d274bc8929 100644
--- a/test/runner.rb
+++ b/test/runner.rb
@@ -1,5 +1,3 @@
-require 'rbconfig'
-exit if CROSS_COMPILING
require 'test/unit'
rcsid = %w$Id$
diff --git a/test/scanf/data.txt b/test/scanf/data.txt
deleted file mode 100644
index 302cfd0089..0000000000
--- a/test/scanf/data.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-this is 33 a fun
-little input file
-
-with
-
-characters
diff --git a/test/scanf/test_scanf.rb b/test/scanf/test_scanf.rb
deleted file mode 100644
index d2e7aa988f..0000000000
--- a/test/scanf/test_scanf.rb
+++ /dev/null
@@ -1,313 +0,0 @@
-# $Id$
-#
-# scanf for Ruby
-#
-# Unit tests
-#
-
-require 'scanf.rb'
-require 'test/unit'
-require 'tmpdir'
-
-# Comment out either of these lines to skip those tests.
-
-class TestStringScanf < Test::Unit::TestCase;end
-class TestIOScanf < Test::Unit::TestCase;end
-
-module ScanfTests
-
-def tests
- [
-
-# Scratchpad
- [ "%2[a]", "nbc", []],
- [ "%*d %*3d %*s", "123 +456 abc", [] ],
- [ "%d%c", "123 x", [ 123, " " ] ],
- [ "%d%c", "123x", [ 123, "x" ] ],
- [ "%d %c", "123x", [ 123, "x" ] ],
- [ "%d %c", "123 x", [ 123, "x" ] ],
-
-# Testing failures
- [ "%x", "x", [] ],
- [ "%2x", "x", [] ],
- [ "%i", "x", [] ],
-# ]; end; def nothing; [
- [ "%2i", "x", [] ],
- [ "%2o", "x", [] ],
- [ "%d", "x", [] ],
- [ "%2d", "x", [] ],
- [ "%3d", "+x3", [] ],
- [ "%d%[abc]", "eabc", [] ],
- [ "%d\n%[abc]", "\neabc", [] ],
- [ "%d%[^abc]", "ghiabc", [ ] ],
- [ "%d%[abc]", "abc", [] ],
- [ "%*d %*3d %*s", "123 +456 abc", [] ],
- [ "%d%s", "", [] ],
- [ "%d%s", "blah 123 string", [] ],
- [ "%[\n]", "abc\n", [] ],
- [ "%[\n]", "abc\n", [] ],
- [ "%[\n]", "abc\n", [] ],
- [ "%f", "x", [] ],
- [ "%f", "z", [] ],
- [ "%f", "z3.2534", [] ],
- [ "", "", [] ],
- [ "", "abc 123", [] ],
- [ '%[^\\w]%c', "a...1", [] ],
-
-# Testing 'x'
- [ "%3x", "0xz", [0] ],
-
-# Testing 'i'
- [ "%3i", "097", [0] ],
- [ "%3i", "0xz", [0] ],
- [ "%1i", "3", [ 3 ] ],
- [ "%2i", "07", [ 7 ] ],
- [ "%2i", "0a", [ 0 ] ],
-
-# Testing 'c'
- [ "%3c", "abc", [ "abc" ] ],
- [ "%3c", "a\nb", [ "a\nb" ] ],
- [ "%3c", "a\nbcd", [ "a\nb" ] ],
- [ "%c\n\n", "x\n\n", [ "x" ] ],
- [ "%c\n\n", "x\n\n", [ "x" ] ],
- [ "%c", "\n", [ "\n" ] ],
- [ "%c", "x\n", [ "x" ] ],
- [ "%2c", " 123", [" 1"] ],
- [ " %c", " x", ["x"] ],
- [ "%c", " x", [" "] ],
- [ "%c", "123", ["1"] ],
- [ "%2c", "123", ["12"] ],
- [ "%5c", "a\nb\n\n", [ "a\nb\n\n" ] ],
- [ "%6c", "a\nb\n\nx", [ "a\nb\n\nx" ] ],
- [ "%5c", "ab\ncd", [ "ab\ncd" ] ],
- [ "%5c", "a\nb\n\n", [ "a\nb\n\n" ] ],
-
-# Testing 'o'
- [ "%3o", "0xz", [0] ],
-
-# Testing 'd'
- [ "%d", "\n123", [ 123 ] ],
- [ "%d", "\n\n123", [ 123 ] ],
- [ "%d", "\n123", [ 123 ] ],
- [ "%1d", "2", [2] ],
-
-# Mixed tests
-# Includes:
-# whitespace/newline
-# mixed integer bases
-# various mixed specifiers
-
- [ "%[^\\w]%c", "...1", [ "...", "1"] ],
- [ '%[^\\w]%c', "...1", [ "...", "1"] ],
- [ "%[abc\n]%d", "a\n\nb\n\nc 123", [ "a\n\nb\n\nc", 123 ] ],
- [ "%[abc\n]%d", "a\n\nb\n\nc \t 123", [ "a\n\nb\n\nc", 123 ] ],
- [ "%[abc\t]%d", "a\t\tb\t\tc 123", [ "a\t\tb\t\tc", 123 ] ],
- [ "%d%3[abc\n]", "123a\nbeaab", [ 123, "a\nb" ] ],
- [ "%d%20c", "42 is the key", [ 42, " is the key" ] ],
- [ "%d %20c", "42 is the key", [ 42, "is the key" ] ],
- [ "%d%3[^abc\n]%d", "123de\nf123", [ 123, "de" ] ],
- [ "%d %4c", "3abc", [ 3, "abc" ] ],
- [ "%f%d\n%[abc]", "1\neabc", [1.0] ],
- [ "%d%3[abc]", "123aaab", [ 123, "aaa" ] ],
- [ "%d%3[abc]", "123 aaab", [ 123 ] ],
- [ "%d%3[abc]", "123aeaab", [ 123, "a" ] ],
- [ "%d%[^abc]", "123defabc", [123, "def" ] ],
- [ "%d%3[^abc]", "123defdef", [ 123, "def" ] ],
- [ "%d%3[^abc] ", "123defdef ", [ 123, "def" ] ],
- [ "%d%3[^abc]ghi", "123defghi", [ 123, "def" ] ],
- [ "%d%3[^abc]", "123defdef", [ 123, "def" ] ],
- [ "%d%3[^abc]", "123adefdef", [ 123 ] ],
- [ "%d%3[^abc]", "123deafdef", [ 123, "de" ] ],
- [ "%d%3[^abc\n]", "123de\nf", [ 123, "de" ] ],
- [ "%s%c%c%s", "abc\n\ndef", ["abc", "\n","\n", "def" ] ],
- [ "%c%d", "\n\n123", [ "\n",123 ] ],
- [ "%s%c%d", "abc\n123", [ "abc", "\n", 123 ] ],
- [ "%s%c%d", "abc\n\n123", [ "abc", "\n", 123 ] ],
- [ "%c%d", "\t\n123", [ "\t",123 ] ],
- [ "%s%c%d", "abc\t\n123", [ "abc", "\t", 123 ] ],
- [ "%3c%d", "abc123", [ "abc", 123 ] ],
- [ "%3c\n%d", "abc123", [ "abc", 123 ] ],
- [ "%3c\n%d", "abc 123", [ "abc", 123 ] ],
- [ "%3c %d", "abc123", [ "abc", 123 ] ],
- [ "%3c\t%d", "abc \n 123", [ "abc", 123 ] ],
- [ "%3c\t%d", "abc \n 123 ", [ "abc", 123 ] ],
- [ "%3c%d", "a\nb123", [ "a\nb", 123 ] ],
- [ "%f%3c", "1.2x\ny", [ 1.2, "x\ny"] ],
- [ "%d\n%d\n%d", "123 456 789", [ 123,456,789 ] ],
- [ "%d\n%i%2d%x\n%d", "123 0718932", [ 123, 071, 89, 0x32] ],
- [ "%c\n%c", "x y", [ "x", "y" ] ],
- [ "%c\t%c", "x y", [ "x", "y" ] ],
- [ "%s\n%s", "x y", [ "x", "y" ] ],
- [ "%s%s\n", "x y", [ "x", "y" ] ],
- [ "%c\n\n%c", "x\n\ny", [ "x", "y" ] ],
- [ "%s%d%d", "abc\n123\n456", [ "abc", 123, 456 ] ],
- [ "%3s%c%3c%d", "1.2x\n\ny123", [ "1.2", "x", "\n\ny", 123 ] ],
- [ "%f%3c", "1.2x\ny", [ 1.2, "x\ny"] ],
- [ "%c\n%c", "x\n\ny", [ "x", "y" ] ],
- [ "%c\n\n%c", "x\n\ny", [ "x", "y" ] ],
- [ "%c %c", "x\n\ny", [ "x", "y" ] ],
- [ "%s\n\n%c", "x\n\ny", [ "x", "y" ] ],
- [ "%s\n\n%s", "x\n\ny", [ "x", "y" ] ],
- [ "%d\n\n%d", "23\n\n45", [ 23, 45 ] ],
- [ "%d\n%d", "23\n\n45", [ 23, 45 ] ],
- [ "%c\n\n%c", "x y", [ "x", "y" ] ],
- [ "%c%c", "x\n\ny", [ "x", "\n" ] ],
- [ "%c\n%c", "x y", [ "x", "y" ] ],
- [ "%c\t%c", "x y", [ "x", "y" ] ],
- [ "%s\n%s", "x y", [ "x", "y" ] ],
- [ "%s%s\n", "x y", [ "x", "y" ] ],
- [ "%c%c", "x\n", [ "x", "\n" ] ],
- [ "%d%c%c%d", "345 678", [ 345, " ", " ", 678] ],
- [ "%d %c%s", "123 x hello", [123, "x", "hello"] ],
- [ "%d%2c", "654 123", [654," 1"] ],
- [ "%5c%s", "a\nb\n\nxyz", [ "a\nb\n\n","xyz" ] ],
- [ "%s%[ xyz]%d", "hello x 32", ["hello", " x ", 32] ],
- [ "%5s%8[a-z]%d", "helloblahblah 32", ["hello", "blahblah", 32] ],
- [ '%s%[abcde\\s]%d', "hello badea 32", ["hello", " badea ", 32] ],
- [ '%d%[\\s]%c', "123 \n\t X", [ 123," \n\t ", "X"] ],
- [ "%4s%2c%c", "1.2x\n\ny", [ "1.2x", "\n\n","y"] ],
- [ "%f%c %3c%d", "1.2x\n\ny123", [ 1.2, "x", "y12", 3 ] ],
- [ "%s%5c", "abc ab\ncd", [ "abc", " ab\nc" ] ],
- [ "%5c%f", "ab\ncd1.2", [ "ab\ncd",1.2 ] ],
- [ "%5c%c", "ab\ncd1", [ "ab\ncd","1" ] ],
- [ "%f%c%2c%d", "1.2x\ny123", [ 1.2, "x", "\ny", 123 ] ],
- [ "%f%c%3c", "1.2x\ny123", [ 1.2, "x", "\ny1"] ],
- [ "%s\n%s", "blah\n\nand\nmore stuff", [ "blah", "and" ] ],
- [ "%o%d%x", "21912a3", [ "21".oct, 912, "a3".hex ] ],
- [ "%3o%4d%3x", "21912a3", [ "21".oct, 912, "a3".hex ] ],
- [ "%3o%4d%5x", "2191240xa3", [ "21".oct, 9124, "a3".hex ] ],
- [ "%3d%3x", "12abc", [12, "abc".hex] ],
- [ "%s%i%d", "hello +0xdef 123", [ "hello", "def".hex, 123] ],
- [ "%s%i%d", "hello -0xdef 123", [ "hello", -"def".hex, 123] ],
- [ "%s%i%i%i", "hello 012 -012 100", [ "hello", 10, -10, 100 ] ],
- [ "%s%i%i%i", "hello 012 0x12 100", [ "hello", 10, 18, 100 ] ],
- [ "%s%5i%3i%4i", "hello 0x123 123 0123", [ "hello", "0x123".hex, 123,"0123".oct] ],
- [ "%s%3i%4i", "hello 1230123", [ "hello", 123,"0123".oct] ],
- [ "%s%3i", "hello 1230", [ "hello", 123] ],
- [ "%s%5x%d", "hello 0xdef 123", [ "hello", "def".hex, 123] ],
- [ "%s%6x%d", "hello +0xdef 123", [ "hello", "def".hex, 123] ],
- [ "%s%6x%d", "hello -0xdef 123", [ "hello", -"def".hex, 123] ],
- [ "%s%6x%d", "hello -0xdef 123", [ "hello", -"def".hex, 123] ],
- [ "%s%4x%d", "hello -def 123", [ "hello", -"def".hex, 123] ],
- [ "%s%3x%d", "hello def 123", [ "hello", "def".hex, 123] ],
- [ "%s%x%d", "hello -def 123", [ "hello", -"def".hex, 123] ],
- [ "%s%x%d", "hello -0xdef 123", [ "hello", -"def".hex, 123] ],
- [ "%s%x%d", "hello 0xdef 123", [ "hello", "def".hex, 123] ],
- [ "%s%d%x%s", "hello 123 abc def", [ "hello", 123, "abc".hex, "def"] ],
- [ "%s%d%o%d", "hello 012 012 100", [ "hello", 12, 10, 100 ] ],
- [ "%s%d%o%d", "hello 012 -012 100", [ "hello", 12, -10, 100 ] ],
- [ "%s%o%x%d", "hello 012 0x12 100", [ "hello", 10, 18, 100 ] ],
- [ "%s%d%o%d", "hello 012 +01288", [ "hello", 12, 10, 88 ] ],
- [ "%f %d %s", "12.3e23 45 string", ["12.3e23".to_f, 45, "string"] ],
- [ "%f %d %s", "12.3e+23 45 string", ["12.3e23".to_f, 45, "string"] ],
- [ "%f %d %s", "12.3e-23 45 string", ["12.3e-23".to_f, 45, "string"] ],
- [ "%f %d %s", "12.3e23 45 string", ["12.3e23".to_f, 45, "string"] ],
- [ "%f %d %s", "-12.3e-23 45 string", ["-12.3e-23".to_f, 45, "string"] ],
- [ "%f %d %s", "12.e23 45 string", ["12.e23".to_f, 45, "string"] ],
- [ "%5f %d %s", "1.2e23 string", ["1.2e2".to_f, 3, "string"] ],
- [ "%5f%d %s", "1.2e23 string", ["1.2e2".to_f, 3, "string"] ],
- [ "%5f%d %d %s", "1.2e23 45 string", ["1.2e2".to_f, 3, 45, "string"] ],
- [ "%6f %d %d %s", "+1.2e23 45 string", ["1.2e2".to_f, 3, 45, "string"] ],
- [ "%d %d", "123 \n 345", [123, 345] ],
- [ "%d %*d", "123 \n 345", [123] ],
- [ "%d %3d789", "123 +45789", [123, 45] ],
- [ "%d %3d%d", "123 +456789", [123, 45, 6789] ],
- [ "%d %3dabc", "123 456abc", [123, 456] ],
- [ "%d %s", "123abc", [123, "abc"] ],
- [ "%d%s %s", "123 abc def", [123, "abc", "def"] ],
- [ "%s%s", "abc123 def", ["abc123", "def"] ],
- [ "%s%s %s", "123 abc def", ["123", "abc", "def"] ],
- [ "%s%%%s", "abc % def", ["abc", "def"] ],
- [ "%d %3d %s", "+123 456abc", [123, 456, "abc"] ],
- [ "%d %3d %s", "123 456abc", [123, 456, "abc"] ],
- [ "%d %3d %s", "123 +456 abc", [123, 45, "6"] ],
- [ "%d %3d %s", "-123-456abc", [-123, -45, "6abc"] ],
- [ "%dabc%d", "123abc345", [123, 345] ],
- [ "%d%5s%d", "123 abcde12", [123, "abcde", 12] ],
- [ "%5d%5s%5d", "12345abcde67890", [12345, "abcde", 67890] ],
- [ "%5d%*5s%5d", "12345abcde67890", [12345, 67890] ],
- [ " 12345%5s%5d", "12345abcde67890", [ "abcde", 67890] ],
- [ "%5dabcde%5d", "12345abcde67890", [ 12345, 67890] ],
- [ "%s%%%*s", "abc % def", ["abc"] ],
- [ "%*6s %d", "string 123", [123] ],
- [ "%d %*3d %s", "-123-456abc", [-123, "6abc"] ],
- [ "%d%s", "123", [123] ],
- [ "%s%d", "abc", ["abc"] ],
- [ "%f%x", "3.2e45x", ["3.2e45x".to_f] ],
- [ "%s%d", "abc", ["abc"] ],
- [ "%*5f%d %d %s", "1.2e23 45 string", [3, 45, "string"] ],
- [ "%5f%*d %d %s", "1.2e23 45 string", ["1.2e2".to_f, 45, "string"] ],
- [ "%*5f%*d %*d %s", "1.2e23 45 string", ["string"] ],
- [ "%f %*d %s", "12.e23 45 string", ["12.e23".to_f, "string"] ],
- [ "%5f %d %s", "1.2e23 string", ["1.2e2".to_f, 3, "string"] ],
- [ "%s %f %s %d %x%c%c%c%c",
- "float: 1.2e23 dec/hex: 135a23 abc",
- ["float:", "1.2e23".to_f, "dec/hex:", 135, "a23".hex, " ", "a", "b", "c" ] ],
-
-# Testing 's'
- [ "%s\n", "blah\n\n\n", [ "blah" ] ],
-
-# Testing '['
- [ "%[a\nb]", "a\nb", [ "a\nb" ] ],
- [ "%[abc]", "acb", [ "acb" ] ],
- [ "%[abc\n]", "a\nb", [ "a\nb" ] ],
- [ "%[^abc]", "defabc", [ "def" ] ],
- [ "%[-abc]", "abc-cba", [ "abc-cba" ] ],
- [ "%[\n]", "\n", [ "\n" ] ],
- [ "%[\n]", "\nabc", [ "\n" ] ],
- [ "%[\n\t]", "\t\n", [ "\t\n" ] ],
- [ "%[a-f]", "abczef", [ "abc" ] ],
- [ "%d%3[abc]", "123 aaab", [ 123 ] ],
- [ "%d%3[^abc]", "123adefdef", [ 123 ] ],
- [ "%d%3[[:lower:]] %f", "123ade1.2", [ 123,"ade",1.2 ] ],
- [ "%d%3[[:lower:]] %f", "123ad1.2", [ 123,"ad",1.2 ] ],
- [ "%d%3[[:lower:]] %f", "123 ad1.2", [ 123 ] ],
- [ "%d%[[:lower:]]", "123abcdef1.2", [ 123, "abcdef" ] ],
- [ "%[[:lower:]]%d", "abcdef123", [ "abcdef", 123 ] ],
- [ "%[[:digit:]]%[[:alpha:]]", "123abcdef", [ "123", "abcdef" ] ],
- [ "%[[:digit:]]%d", "123 123", [ "123", 123 ] ],
- [ "%[[:upper:]]", "ABCdefGHI", [ "ABC" ] ],
-
-# Testing 'f'
- [ "%2f", "x", [0.0] ], # width-floats match anything (by design)
- [ "%f", "1.23e45", [1.23e+45] ],
- [ "%f", "3.25ee", [3.25] ],
- [ "%f", "3..25", [3.0] ],
- [ "%f", "+3.25", [3.25] ],
- [ "%f", "+3.25e2", [325.0] ],
- [ "%f", "3.z", [3.0] ],
- ]
- end
- end
-
-class TestStringScanf
- include Scanf
- extend ScanfTests
-
- i = 1
- self.tests.each do |test|
- define_method("test_#{i}") do ||
- assert_equal(test[2], test[1].scanf(test[0]))
- end
- i += 1
- end
-end
-
-class TestIOScanf
- include Scanf
- extend ScanfTests
-
- tmpfilename = "#{Dir.tmpdir}/iotest.dat.#{$$}"
-
- i = 1
- self.tests.each do |test|
- define_method("test_#{i}") do ||
- File.open(tmpfilename, "w") {|fh| fh.print test[1]}
- File.open(tmpfilename, "r") { |fh|
- assert_equal(test[2], fh.scanf(test[0]))
- }
- File.delete(tmpfilename)
- end
- i += 1
- end
-end
diff --git a/test/scanf/test_scanfblocks.rb b/test/scanf/test_scanfblocks.rb
deleted file mode 100644
index 907a3c2838..0000000000
--- a/test/scanf/test_scanfblocks.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# $Id$
-#
-# scanf for Ruby
-#
-# Some not very comprehensive tests of block behavior.
-
-
-require 'test/unit'
-require 'scanf'
-require 'tmpdir'
-
-class TestScanfBlock < Test::Unit::TestCase
-
- def setup
- @str = <<-EOS
- Beethoven 1770
- Bach 1685
- Handel 1685
- Scarlatti 1685
- Brahms 1833
- EOS
- end
-
-alias set_up setup
- def test_str1
- res = @str.scanf("%s%d") { |name, year| "#{name} was born in #{year}." }
- assert_equal(res,
- [ "Beethoven was born in 1770.",
- "Bach was born in 1685.",
- "Handel was born in 1685.",
- "Scarlatti was born in 1685.",
- "Brahms was born in 1833." ])
- end
-
- def test_str2
- names = @str.scanf("%s%d") { |name, year| name.upcase }
- assert_equal(names, ["BEETHOVEN", "BACH", "HANDEL", "SCARLATTI", "BRAHMS"])
- end
-
- def test_str3
- assert_equal("".scanf("%d%f%s") {}, [])
- end
-
- def test_str4
- assert_equal("abc".scanf("%d%f%s") {}, [])
- end
-
- def test_str5
- assert_equal("abc".scanf("") {}, [])
- end
-
- def test_io1
- fn = "#{Dir.tmpdir}/iotest.dat.#{$$}"
- File.open(fn, "w") { |fh| fh.puts(@str) }
- fh = File.open(fn, "rb")
- res = fh.scanf("%s%d") { |name, year| "#{name} was born in #{year}." }
-
- assert_equal(
- [ "Beethoven was born in 1770.",
- "Bach was born in 1685.",
- "Handel was born in 1685.",
- "Scarlatti was born in 1685.",
- "Brahms was born in 1833." ],res)
- fh.close
- ensure
- File.delete(fn)
- end
-
- def test_io2
- fn = "#{Dir.tmpdir}/iotest.dat.#{$$}"
- File.open(fn, "w").close
- fh = File.open(fn,"rb")
- assert_equal(fh.scanf("") {}, [])
- fh.seek(0)
- assert_equal(fh.scanf("%d%f%s") {}, [])
- fh.close
- ensure
- File.delete(fn)
- end
-
-end
diff --git a/test/scanf/test_scanfio.rb b/test/scanf/test_scanfio.rb
deleted file mode 100644
index c8740aed43..0000000000
--- a/test/scanf/test_scanfio.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# $Id$
-#
-# scanf for Ruby
-#
-# Ad hoc tests of IO#scanf (needs to be expanded)
-
-
-require "scanf"
-
-class TestScanfIO
- def test_io
- fh = File.new(File.join(File.dirname(__FILE__), "data.txt"), "r")
- assert_equal(0, fh.pos)
- assert_equal(["this", "is"], fh.scanf("%s%s"))
- assert_equal([33, "littel"], fh.scanf("%da fun%s"))
- #p fh.pos
- end
-end
-
diff --git a/test/sdbm/test_sdbm.rb b/test/sdbm/test_sdbm.rb
index 0badf7c4b7..8789d719dd 100644
--- a/test/sdbm/test_sdbm.rb
+++ b/test/sdbm/test_sdbm.rb
@@ -1,5 +1,4 @@
require 'test/unit'
-require 'tmpdir'
begin
require 'sdbm'
@@ -8,9 +7,7 @@ end
class TestSDBM < Test::Unit::TestCase
def setup
- @tmpdir = Dir.mktmpdir("tmptest_sdbm")
- @prefix = "tmptest_sdbm_#{$$}"
- @path = "#{@tmpdir}/#{@prefix}_"
+ @path = "tmptest_sdbm_"
assert_instance_of(SDBM, @sdbm = SDBM.new(@path))
end
def teardown
@@ -18,7 +15,8 @@ class TestSDBM < Test::Unit::TestCase
ObjectSpace.each_object(SDBM) do |obj|
obj.close unless obj.closed?
end
- FileUtils.remove_entry_secure @tmpdir
+ File.delete *Dir.glob("tmptest_sdbm*").to_a
+ p Dir.glob("tmptest_sdbm*") if $DEBUG
end
def check_size(expect, sdbm=@sdbm)
@@ -49,26 +47,26 @@ class TestSDBM < Test::Unit::TestCase
def test_s_new_has_no_block
# SDBM.new ignore the block
foo = true
- assert_instance_of(SDBM, sdbm = SDBM.new("#{@tmpdir}/#{@prefix}") { foo = false })
+ assert_instance_of(SDBM, sdbm = SDBM.new("tmptest_sdbm") { foo = false })
assert_equal(foo, true)
assert_nil(sdbm.close)
end
def test_s_open_no_create
- assert_nil(sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", nil))
+ assert_nil(sdbm = SDBM.open("tmptest_sdbm", nil))
ensure
sdbm.close if sdbm
end
def test_s_open_with_block
- assert_equal(SDBM.open("#{@tmpdir}/#{@prefix}") { :foo }, :foo)
+ assert_equal(SDBM.open("tmptest_sdbm") { :foo }, :foo)
end
=begin
# Is it guaranteed on many OS?
def test_s_open_lock_one_process
# locking on one process
- assert_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644))
assert_raise(Errno::EWOULDBLOCK) {
begin
- SDBM.open("#{@tmpdir}/#{@prefix}", 0644)
+ SDBM.open("tmptest_sdbm", 0644)
rescue Errno::EAGAIN
raise Errno::EWOULDBLOCK
end
@@ -83,8 +81,8 @@ class TestSDBM < Test::Unit::TestCase
end
return unless have_fork? # snip this test
- pid = fork() {
- assert_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ fork() {
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644,
SDBM::NOLOCK))
sleep 2
}
@@ -92,17 +90,17 @@ class TestSDBM < Test::Unit::TestCase
begin
sdbm2 = nil
assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
- assert_instance_of(SDBM, sdbm2 = SDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ assert_instance_of(SDBM, sdbm2 = SDBM.open("tmptest_sdbm", 0644))
}
ensure
- Process.wait pid
+ Process.wait
sdbm2.close if sdbm2
end
- p Dir.glob("#{@tmpdir}/#{@prefix}*") if $DEBUG
+ p Dir.glob("tmptest_sdbm*") if $DEBUG
- pid = fork() {
- assert_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", 0644))
+ fork() {
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644))
sleep 2
}
begin
@@ -110,25 +108,26 @@ class TestSDBM < Test::Unit::TestCase
sdbm2 = nil
assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
# this test is failed on Cygwin98 (???)
- assert_instance_of(SDBM, sdbm2 = SDBM.open("#{@tmpdir}/#{@prefix}", 0644,
+ assert_instance_of(SDBM, sdbm2 = SDBM.open("tmptest_sdbm", 0644,
SDBM::NOLOCK))
}
ensure
- Process.wait pid
+ Process.wait
sdbm2.close if sdbm2
end
end
def test_s_open_error
- assert_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", 0))
+ return if /(ms|bcc)win|mingw|djgpp/ =~ RUBY_PLATFORM
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0))
assert_raise(Errno::EACCES) {
- SDBM.open("#{@tmpdir}/#{@prefix}", 0)
+ SDBM.open("tmptest_sdbm", 0)
}
sdbm.close
end
def test_close
- assert_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}"))
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm"))
assert_nil(sdbm.close)
# closed SDBM file
@@ -205,6 +204,13 @@ class TestSDBM < Test::Unit::TestCase
assert_nil(@sdbm['bar'])
end
+ def test_indexes
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+ assert_equal(values.reverse, @sdbm.indexes(*keys.reverse))
+ end
+
def test_values_at
keys = %w(foo bar baz)
values = %w(FOO BAR BAZ)
@@ -526,4 +532,3 @@ class TestSDBM < Test::Unit::TestCase
}
end
end
-
diff --git a/test/soap/asp.net/hello.wsdl b/test/soap/asp.net/hello.wsdl
new file mode 100644
index 0000000000..b94129c152
--- /dev/null
+++ b/test/soap/asp.net/hello.wsdl
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+xmlns:s="http://www.w3.org/2001/XMLSchema"
+xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+xmlns:tns="http://localhost/WebService/"
+xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
+xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+targetNamespace="http://localhost/WebService/"
+xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <s:schema elementFormDefault="qualified"
+targetNamespace="http://localhost/WebService/">
+ <s:element name="HelloWorld">
+ <s:complexType />
+ </s:element>
+ <s:element name="HelloWorldResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1"
+name="HelloWorldResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="SayHello">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="name"
+type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="SayHelloResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1"
+name="SayHelloResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ </s:schema>
+ </wsdl:types>
+ <wsdl:message name="HelloWorldSoapIn">
+ <wsdl:part name="parameters" element="tns:HelloWorld" />
+ </wsdl:message>
+ <wsdl:message name="HelloWorldSoapOut">
+ <wsdl:part name="parameters" element="tns:HelloWorldResponse" />
+ </wsdl:message>
+ <wsdl:message name="SayHelloSoapIn">
+ <wsdl:part name="parameters" element="tns:SayHello" />
+ </wsdl:message>
+ <wsdl:message name="SayHelloSoapOut">
+ <wsdl:part name="parameters" element="tns:SayHelloResponse" />
+ </wsdl:message>
+ <wsdl:portType name="Service1Soap">
+ <wsdl:operation name="HelloWorld">
+ <wsdl:input message="tns:HelloWorldSoapIn" />
+ <wsdl:output message="tns:HelloWorldSoapOut" />
+ </wsdl:operation>
+ <wsdl:operation name="SayHello">
+ <wsdl:input message="tns:SayHelloSoapIn" />
+ <wsdl:output message="tns:SayHelloSoapOut" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+style="document" />
+ <wsdl:operation name="HelloWorld">
+ <soap:operation
+soapAction="http://localhost/WebService/HelloWorld" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="SayHello">
+ <soap:operation soapAction="http://localhost/WebService/SayHello"
+style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Service1">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
+ <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
+ <soap:address
+location="http://localhost/WebService/Service1.asmx" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/test/soap/asp.net/test_aspdotnet.rb b/test/soap/asp.net/test_aspdotnet.rb
new file mode 100644
index 0000000000..7d5f3fd288
--- /dev/null
+++ b/test/soap/asp.net/test_aspdotnet.rb
@@ -0,0 +1,111 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/rpc/driver'
+
+
+module SOAP; module ASPDotNet
+
+
+class TestASPDotNet < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = "http://localhost/WebService/"
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + 'SayHello',
+ 'sayHello',
+ XSD::QName.new(Namespace, 'SayHello'),
+ XSD::QName.new(Namespace, 'SayHelloResponse')
+ )
+ end
+
+ def sayHello(arg)
+ name = arg['name']
+ "Hello #{name}"
+ end
+ end
+
+ Port = 17171
+ Endpoint = "http://localhost:#{Port}/"
+
+ def setup
+ setup_server
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_document_method
+ @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace)
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.add_document_method('sayHello', Server::Namespace + 'SayHello',
+ XSD::QName.new(Server::Namespace, 'SayHello'),
+ XSD::QName.new(Server::Namespace, 'SayHelloResponse'))
+ assert_equal("Hello Mike", @client.sayHello(:name => "Mike"))
+ end
+
+ def test_aspdotnethandler
+ @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace)
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.add_method_with_soapaction('sayHello', Server::Namespace + 'SayHello', 'name')
+ @client.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
+ assert_equal("Hello Mike", @client.sayHello("Mike"))
+ end
+
+ if defined?(HTTPAccess2)
+
+ # qualified!
+ REQUEST_ASPDOTNETHANDLER =
+%q[<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <n1:sayHello xmlns:n1="http://localhost/WebService/">
+ <n1:name>Mike</n1:name>
+ </n1:sayHello>
+ </env:Body>
+</env:Envelope>]
+
+ def test_aspdotnethandler_envelope
+ @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace)
+ @client.wiredump_dev = str = ''
+ @client.add_method_with_soapaction('sayHello', Server::Namespace + 'SayHello', 'name')
+ @client.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
+ assert_equal("Hello Mike", @client.sayHello("Mike"))
+ assert_equal(REQUEST_ASPDOTNETHANDLER, parse_requestxml(str))
+ end
+
+ def parse_requestxml(str)
+ str.split(/\r?\n\r?\n/)[3]
+ end
+
+ end
+end
+
+
+end; end
diff --git a/test/soap/calc/calc.rb b/test/soap/calc/calc.rb
new file mode 100644
index 0000000000..6bc78803b3
--- /dev/null
+++ b/test/soap/calc/calc.rb
@@ -0,0 +1,17 @@
+module CalcService
+ def self.add(lhs, rhs)
+ lhs + rhs
+ end
+
+ def self.sub(lhs, rhs)
+ lhs - rhs
+ end
+
+ def self.multi(lhs, rhs)
+ lhs * rhs
+ end
+
+ def self.div(lhs, rhs)
+ lhs / rhs
+ end
+end
diff --git a/test/soap/calc/calc2.rb b/test/soap/calc/calc2.rb
new file mode 100644
index 0000000000..69495730e7
--- /dev/null
+++ b/test/soap/calc/calc2.rb
@@ -0,0 +1,29 @@
+class CalcService2
+ def initialize(value = 0)
+ @value = value
+ end
+
+ def set_value(value)
+ @value = value
+ end
+
+ def get_value
+ @value
+ end
+
+ def +(rhs)
+ @value + rhs
+ end
+
+ def -(rhs)
+ @value - rhs
+ end
+
+ def *(rhs)
+ @value * rhs
+ end
+
+ def /(rhs)
+ @value / rhs
+ end
+end
diff --git a/test/soap/calc/server.cgi b/test/soap/calc/server.cgi
new file mode 100644
index 0000000000..1eb0d1d864
--- /dev/null
+++ b/test/soap/calc/server.cgi
@@ -0,0 +1,13 @@
+require 'soap/rpc/cgistub'
+
+class CalcServer < SOAP::RPC::CGIStub
+ def initialize(*arg)
+ super
+
+ require 'calc'
+ servant = CalcService
+ add_servant(servant, 'http://tempuri.org/calcService')
+ end
+end
+
+status = CalcServer.new('CalcServer', nil).start
diff --git a/test/soap/calc/server.rb b/test/soap/calc/server.rb
new file mode 100644
index 0000000000..a93774d909
--- /dev/null
+++ b/test/soap/calc/server.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'calc'
+
+class CalcServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+
+ servant = CalcService
+ add_servant(servant, 'http://tempuri.org/calcService')
+ end
+end
+
+if $0 == __FILE__
+ status = CalcServer.new('CalcServer', nil, '0.0.0.0', 17171).start
+end
diff --git a/test/soap/calc/server2.rb b/test/soap/calc/server2.rb
new file mode 100644
index 0000000000..01c6d75289
--- /dev/null
+++ b/test/soap/calc/server2.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'calc2'
+
+class CalcServer2 < SOAP::RPC::StandaloneServer
+ def on_init
+ servant = CalcService2.new
+ add_method(servant, 'set_value', 'newValue')
+ add_method(servant, 'get_value')
+ add_method_as(servant, '+', 'add', 'lhs')
+ add_method_as(servant, '-', 'sub', 'lhs')
+ add_method_as(servant, '*', 'multi', 'lhs')
+ add_method_as(servant, '/', 'div', 'lhs')
+ end
+end
+
+if $0 == __FILE__
+ status = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', 17171).start
+end
diff --git a/test/soap/calc/test_calc.rb b/test/soap/calc/test_calc.rb
new file mode 100644
index 0000000000..88738716a6
--- /dev/null
+++ b/test/soap/calc/test_calc.rb
@@ -0,0 +1,49 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'server.rb'
+
+
+module SOAP
+module Calc
+
+
+class TestCalc < Test::Unit::TestCase
+ Port = 17171
+
+ def setup
+ @server = CalcServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @calc = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @calc.add_method('add', 'lhs', 'rhs')
+ @calc.add_method('sub', 'lhs', 'rhs')
+ @calc.add_method('multi', 'lhs', 'rhs')
+ @calc.add_method('div', 'lhs', 'rhs')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @calc.reset_stream
+ end
+
+ def test_calc
+ assert_equal(3, @calc.add(1, 2))
+ assert_equal(-1.1, @calc.sub(1.1, 2.2))
+ assert_equal(2.42, @calc.multi(1.1, 2.2))
+ assert_equal(2, @calc.div(5, 2))
+ assert_equal(2.5, @calc.div(5.0, 2))
+ assert_equal(1.0/0.0, @calc.div(1.1, 0))
+ assert_raises(ZeroDivisionError) do
+ @calc.div(1, 0)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/calc/test_calc2.rb b/test/soap/calc/test_calc2.rb
new file mode 100644
index 0000000000..f334b29bdb
--- /dev/null
+++ b/test/soap/calc/test_calc2.rb
@@ -0,0 +1,53 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'server2.rb'
+
+
+module SOAP
+module Calc
+
+
+class TestCalc2 < Test::Unit::TestCase
+ Port = 17171
+
+ def setup
+ @server = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @var = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @var.wiredump_dev = STDERR if $DEBUG
+ @var.add_method('set_value', 'newValue')
+ @var.add_method('get_value')
+ @var.add_method_as('+', 'add', 'rhs')
+ @var.add_method_as('-', 'sub', 'rhs')
+ @var.add_method_as('*', 'multi', 'rhs')
+ @var.add_method_as('/', 'div', 'rhs')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @var.reset_stream
+ end
+
+ def test_calc2
+ assert_equal(1, @var.set_value(1))
+ assert_equal(3, @var + 2)
+ assert_equal(-1.2, @var - 2.2)
+ assert_equal(2.2, @var * 2.2)
+ assert_equal(0, @var / 2)
+ assert_equal(0.5, @var / 2.0)
+ assert_raises(ZeroDivisionError) do
+ @var / 0
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/calc/test_calc_cgi.rb b/test/soap/calc/test_calc_cgi.rb
new file mode 100644
index 0000000000..d28830629f
--- /dev/null
+++ b/test/soap/calc/test_calc_cgi.rb
@@ -0,0 +1,69 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'logger'
+require 'webrick'
+require 'rbconfig'
+
+
+module SOAP
+module Calc
+
+
+class TestCalcCGI < Test::Unit::TestCase
+ # This test shuld be run after installing ruby.
+ RUBYBIN = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+ RUBYBIN << " -d" if $DEBUG
+
+ Port = 17171
+
+ def setup
+ logger = Logger.new(STDERR)
+ logger.level = Logger::Severity::ERROR
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__)),
+ :CGIPathEnv => ENV['PATH'],
+ :CGIInterpreter => RUBYBIN
+ )
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/server.cgi"
+ @calc = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @calc.wiredump_dev = STDERR if $DEBUG
+ @calc.add_method('add', 'lhs', 'rhs')
+ @calc.add_method('sub', 'lhs', 'rhs')
+ @calc.add_method('multi', 'lhs', 'rhs')
+ @calc.add_method('div', 'lhs', 'rhs')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @calc.reset_stream
+ end
+
+ def test_calc_cgi
+ assert_equal(3, @calc.add(1, 2))
+ assert_equal(-1.1, @calc.sub(1.1, 2.2))
+ assert_equal(2.42, @calc.multi(1.1, 2.2))
+ assert_equal(2, @calc.div(5, 2))
+ assert_equal(2.5, @calc.div(5.0, 2))
+ assert_equal(1.0/0.0, @calc.div(1.1, 0))
+ assert_raises(ZeroDivisionError) do
+ @calc.div(1, 0)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/fault/test_customfault.rb b/test/soap/fault/test_customfault.rb
new file mode 100644
index 0000000000..2f7bc2be6e
--- /dev/null
+++ b/test/soap/fault/test_customfault.rb
@@ -0,0 +1,58 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+
+
+module SOAP
+module Fault
+
+
+class TestCustomFault < Test::Unit::TestCase
+ Port = 17171
+
+ class CustomFaultServer < SOAP::RPC::StandaloneServer
+ def on_init
+ add_method(self, 'fault', 'msg')
+ end
+
+ def fault(msg)
+ SOAPFault.new(SOAPString.new("mycustom"),
+ SOAPString.new("error: #{msg}"),
+ SOAPString.new(self.class.name))
+ end
+ end
+
+ def setup
+ @server = CustomFaultServer.new('customfault', 'urn:customfault', '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'urn:customfault')
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method("fault", "msg")
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_custom_fault
+ begin
+ @client.fault("message")
+ assert(false, 'exception not raised')
+ rescue SOAP::FaultError => e
+ assert(true, 'exception raised')
+ assert_equal('error: message', e.message)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/header/server.cgi b/test/soap/header/server.cgi
new file mode 100644
index 0000000000..2a188538d9
--- /dev/null
+++ b/test/soap/header/server.cgi
@@ -0,0 +1,119 @@
+require 'pstore'
+require 'soap/rpc/cgistub'
+require 'soap/header/simplehandler'
+
+
+class AuthHeaderPortServer < SOAP::RPC::CGIStub
+ PortName = 'http://tempuri.org/authHeaderPort'
+ SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+ SessionDB = File.join(File.expand_path(File.dirname(__FILE__)), 'session.pstoredb')
+
+ class AuthHeaderService
+ def self.create
+ new
+ end
+
+ def deposit(amt)
+ "deposit #{amt} OK"
+ end
+
+ def withdrawal(amt)
+ "withdrawal #{amt} OK"
+ end
+ end
+
+ class AuthHeaderSupportService
+ def delete_sessiondb
+ File.unlink(SessionDB) if File.file?(SessionDB)
+ backup = SessionDB + "~"
+ File.unlink(backup) if File.file?(backup)
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(AuthHeaderService.new, PortName)
+ add_rpc_servant(AuthHeaderSupportService.new, SupportPortName)
+ add_rpc_headerhandler(ServerAuthHeaderHandler.new)
+ end
+
+ class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
+ Users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+
+ def initialize
+ super(MyHeaderName)
+ @db = PStore.new(SessionDB)
+ @db.transaction do
+ @db["root"] = {} unless @db.root?("root")
+ end
+ @userid = @sessionid = nil
+ end
+
+ def login(userid, passwd)
+ userid and passwd and Users[userid] == passwd
+ end
+
+ def auth(sessionid)
+ in_sessiondb do |root|
+ root[sessionid][0]
+ end
+ end
+
+ def create_session(userid)
+ in_sessiondb do |root|
+ while true
+ key = create_sessionkey
+ break unless root[key]
+ end
+ root[key] = [userid]
+ key
+ end
+ end
+
+ def destroy_session(sessionkey)
+ in_sessiondb do |root|
+ root.delete(sessionkey)
+ end
+ end
+
+ def on_simple_outbound
+ { "sessionid" => @sessionid }
+ end
+
+ def on_simple_inbound(my_header, mu)
+ succeeded = false
+ userid = my_header["userid"]
+ passwd = my_header["passwd"]
+ if login(userid, passwd)
+ succeeded = true
+ elsif sessionid = my_header["sessionid"]
+ if userid = auth(sessionid)
+ destroy_session(sessionid)
+ succeeded = true
+ end
+ end
+ raise RuntimeError.new("authentication failed") unless succeeded
+ @userid = userid
+ @sessionid = create_session(userid)
+ end
+
+ private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+
+ def in_sessiondb
+ @db.transaction do
+ yield(@db["root"])
+ end
+ end
+ end
+end
+
+
+status = AuthHeaderPortServer.new('AuthHeaderPortServer', nil).start
diff --git a/test/soap/header/test_authheader.rb b/test/soap/header/test_authheader.rb
new file mode 100644
index 0000000000..47e1e76b82
--- /dev/null
+++ b/test/soap/header/test_authheader.rb
@@ -0,0 +1,240 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+
+
+module SOAP
+module Header
+
+
+class TestAuthHeader < Test::Unit::TestCase
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+ DummyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "dummy")
+
+ class AuthHeaderPortServer < SOAP::RPC::StandaloneServer
+ class AuthHeaderService
+ def self.create
+ new
+ end
+
+ def deposit(amt)
+ "deposit #{amt} OK"
+ end
+
+ def withdrawal(amt)
+ "withdrawal #{amt} OK"
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(AuthHeaderService.new, PortName)
+ ServerAuthHeaderHandler.init
+ add_request_headerhandler(ServerAuthHeaderHandler)
+ end
+
+ class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
+ class << self
+ def create
+ new
+ end
+
+ def init
+ @users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+ @sessions = {}
+ end
+
+ def login(userid, passwd)
+ userid and passwd and @users[userid] == passwd
+ end
+
+ def auth(sessionid)
+ @sessions[sessionid][0]
+ end
+
+ def create_session(userid)
+ while true
+ key = create_sessionkey
+ break unless @sessions[key]
+ end
+ @sessions[key] = [userid]
+ key
+ end
+
+ def destroy_session(sessionkey)
+ @sessions.delete(sessionkey)
+ end
+
+ def sessions
+ @sessions
+ end
+
+ private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+ end
+
+ def initialize
+ super(MyHeaderName)
+ @userid = @sessionid = nil
+ end
+
+ def on_simple_outbound
+ { "sessionid" => @sessionid }
+ end
+
+ def on_simple_inbound(my_header, mu)
+ auth = false
+ userid = my_header["userid"]
+ passwd = my_header["passwd"]
+ if self.class.login(userid, passwd)
+ auth = true
+ elsif sessionid = my_header["sessionid"]
+ if userid = self.class.auth(sessionid)
+ self.class.destroy_session(sessionid)
+ auth = true
+ end
+ end
+ raise RuntimeError.new("authentication failed") unless auth
+ @userid = userid
+ @sessionid = self.class.create_session(userid)
+ end
+ end
+ end
+
+ class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(userid, passwd, mustunderstand)
+ super(MyHeaderName)
+ @sessionid = nil
+ @userid = userid
+ @passwd = passwd
+ @mustunderstand = mustunderstand
+ end
+
+ def on_simple_outbound
+ if @sessionid
+ { "sessionid" => @sessionid }
+ else
+ { "userid" => @userid, "passwd" => @passwd }
+ end
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ @sessionid = my_header["sessionid"]
+ end
+
+ def sessionid
+ @sessionid
+ end
+ end
+
+ class DummyHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(mustunderstand)
+ super(DummyHeaderName)
+ @mustunderstand = mustunderstand
+ end
+
+ def on_simple_outbound
+ { XSD::QName.new("foo", "bar") => nil }
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = AuthHeaderPortServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('deposit', 'amt')
+ @client.add_method('withdrawal', 'amt')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_success_no_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', false)
+ @client.headerhandler << h
+ do_transaction_check(h)
+ end
+
+ def test_success_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ do_transaction_check(h)
+ end
+
+ def test_no_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ @client.headerhandler << DummyHeaderHandler.new(false)
+ do_transaction_check(h)
+ end
+
+ def test_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ @client.headerhandler << (h2 = DummyHeaderHandler.new(true))
+ assert_raise(SOAP::UnhandledMustUnderstandHeaderError) do
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ end
+ @client.headerhandler.delete(h2)
+ @client.headerhandler << (h2 = DummyHeaderHandler.new(false))
+ do_transaction_check(h)
+ end
+
+ def do_transaction_check(h)
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
+ assert_equal("NaHi", serversess[0])
+ assert_equal("withdrawal 120 OK", @client.withdrawal(120))
+ serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
+ assert_equal("NaHi", serversess[0])
+ end
+
+ def test_authfailure
+ h = ClientAuthHeaderHandler.new('NaHi', 'pa', false)
+ @client.headerhandler << h
+ assert_raises(RuntimeError) do
+ @client.deposit(150)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/header/test_authheader_cgi.rb b/test/soap/header/test_authheader_cgi.rb
new file mode 100644
index 0000000000..d70b022ad8
--- /dev/null
+++ b/test/soap/header/test_authheader_cgi.rb
@@ -0,0 +1,121 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+require 'logger'
+require 'webrick'
+require 'rbconfig'
+
+
+module SOAP
+module Header
+
+
+class TestAuthHeaderCGI < Test::Unit::TestCase
+ # This test shuld be run after installing ruby.
+ RUBYBIN = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+ RUBYBIN << " -d" if $DEBUG
+
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+ SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+
+ class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(userid, passwd)
+ super(MyHeaderName)
+ @sessionid = nil
+ @userid = userid
+ @passwd = passwd
+ end
+
+ def on_simple_outbound
+ if @sessionid
+ { "sessionid" => @sessionid }
+ else
+ { "userid" => @userid, "passwd" => @passwd }
+ end
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ @sessionid = my_header["sessionid"]
+ end
+
+ def sessionid
+ @sessionid
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @endpoint = "http://localhost:#{Port}/server.cgi"
+ logger = Logger.new(STDERR)
+ logger.level = Logger::Severity::ERROR
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__)),
+ :CGIPathEnv => ENV['PATH'],
+ :CGIInterpreter => RUBYBIN
+ )
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('deposit', 'amt')
+ @client.add_method('withdrawal', 'amt')
+ @supportclient = SOAP::RPC::Driver.new(@endpoint, SupportPortName)
+ @supportclient.add_method('delete_sessiondb')
+ end
+
+ def teardown
+ @supportclient.delete_sessiondb
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ @supportclient.reset_stream
+ end
+
+ def test_success
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd')
+ @client.headerhandler << h
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ assert_equal("withdrawal 120 OK", @client.withdrawal(120))
+ end
+
+ def test_authfailure
+ h = ClientAuthHeaderHandler.new('NaHi', 'pa')
+ @client.headerhandler << h
+ assert_raises(RuntimeError) do
+ @client.deposit(150)
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/header/test_simplehandler.rb b/test/soap/header/test_simplehandler.rb
new file mode 100644
index 0000000000..75dbd4a550
--- /dev/null
+++ b/test/soap/header/test_simplehandler.rb
@@ -0,0 +1,116 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+
+
+module SOAP
+module Header
+
+
+class TestSimpleHandler < Test::Unit::TestCase
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+
+ class PingPortServer < SOAP::RPC::StandaloneServer
+ class PingService
+ def self.create
+ new
+ end
+
+ def ping
+ Thread.current[:pingheader]
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(PingService.new, PortName)
+ add_request_headerhandler(PingServerHeaderHandler)
+ end
+
+ class PingServerHeaderHandler < SOAP::Header::SimpleHandler
+ MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader")
+
+ def self.create
+ new
+ end
+
+ def initialize()
+ super(MyHeaderName)
+ end
+
+ def on_simple_outbound
+ "dummy"
+ end
+
+ def on_simple_inbound(my_header, mu)
+ Thread.current[:pingheader] = my_header
+ end
+ end
+ end
+
+ class PingClientHeaderHandler < SOAP::Header::SimpleHandler
+ MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader")
+
+ def initialize(pingHeader)
+ super(MyHeaderName)
+ @pingHeader = pingHeader
+ @mustunderstand = false
+ end
+
+ def on_simple_outbound
+ @pingHeader # --- note, not a Hash
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ Thread.current[:pingheader] = my_header
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = PingPortServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('ping')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_string
+ h = PingClientHeaderHandler.new('pingheader')
+ @client.headerhandler << h
+ assert_equal("pingheader", @client.ping)
+ assert_equal("dummy", Thread.current[:pingheader])
+ end
+end
+
+
+end
+end
diff --git a/test/soap/helloworld/hw_s.rb b/test/soap/helloworld/hw_s.rb
new file mode 100644
index 0000000000..1a54adb924
--- /dev/null
+++ b/test/soap/helloworld/hw_s.rb
@@ -0,0 +1,16 @@
+require 'soap/rpc/standaloneServer'
+
+class HelloWorldServer < SOAP::RPC::StandaloneServer
+ def on_init
+ add_method(self, 'hello_world', 'from')
+ end
+
+ def hello_world(from)
+ "Hello World, from #{ from }"
+ end
+end
+
+if $0 == __FILE__
+ server = HelloWorldServer.new('hws', 'urn:hws', '0.0.0.0', 17171)
+ server.start
+end
diff --git a/test/soap/helloworld/test_helloworld.rb b/test/soap/helloworld/test_helloworld.rb
new file mode 100644
index 0000000000..40c35b57fb
--- /dev/null
+++ b/test/soap/helloworld/test_helloworld.rb
@@ -0,0 +1,40 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'hw_s.rb'
+
+
+module SOAP
+module HelloWorld
+
+
+class TestHelloWorld < Test::Unit::TestCase
+ Port = 17171
+
+ def setup
+ @server = HelloWorldServer.new('hws', 'urn:hws', '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'urn:hws')
+ @client.add_method("hello_world", "from")
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_hello_world
+ assert_equal("Hello World, from NaHi", @client.hello_world("NaHi"))
+ assert_equal("Hello World, from <&>", @client.hello_world("<&>"))
+ end
+end
+
+
+end
+end
diff --git a/test/soap/marshal/test_digraph.rb b/test/soap/marshal/test_digraph.rb
new file mode 100644
index 0000000000..d7f30654f8
--- /dev/null
+++ b/test/soap/marshal/test_digraph.rb
@@ -0,0 +1,56 @@
+require 'test/unit'
+require 'soap/marshal'
+
+
+module SOAP
+module Marshal
+
+
+class Node; include SOAP::Marshallable
+ attr_reader :first, :second, :str
+
+ def initialize(*init_next)
+ @first = init_next[0]
+ @second = init_next[1]
+ end
+end
+
+class TestDigraph < Test::Unit::TestCase
+ def setup
+ @n9 = Node.new
+ @n81 = Node.new(@n9)
+ @n82 = Node.new(@n9)
+ @n7 = Node.new(@n81, @n82)
+ @n61 = Node.new(@n7)
+ @n62 = Node.new(@n7)
+ @n5 = Node.new(@n61, @n62)
+ @n41 = Node.new(@n5)
+ @n42 = Node.new(@n5)
+ @n3 = Node.new(@n41, @n42)
+ @n21 = Node.new(@n3)
+ @n22 = Node.new(@n3)
+ @n1 = Node.new(@n21, @n22)
+ end
+
+ def test_marshal
+ f = File.open("digraph_marshalled_string.soap", "wb")
+ SOAP::Marshal.dump(@n1, f)
+ f.close
+ f = File.open("digraph_marshalled_string.soap")
+ str = f.read
+ f.close
+ newnode = SOAP::Marshal.unmarshal(str)
+ assert_equal(newnode.first.first.__id__, newnode.second.first.__id__)
+ assert_equal(newnode.first.first.first.first.__id__, newnode.second.first.second.first.__id__)
+ end
+
+ def teardown
+ if File.exist?("digraph_marshalled_string.soap")
+ File.unlink("digraph_marshalled_string.soap")
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/soap/marshal/test_marshal.rb b/test/soap/marshal/test_marshal.rb
new file mode 100644
index 0000000000..5cc30a2b5d
--- /dev/null
+++ b/test/soap/marshal/test_marshal.rb
@@ -0,0 +1,26 @@
+require 'test/unit'
+require 'soap/marshal'
+dir = File.join(File.dirname(File.expand_path(__FILE__)), '../../ruby')
+orgpath = $:.dup
+begin
+ $:.push(dir)
+ require 'marshaltestlib'
+ensure
+ $:.replace(orgpath)
+end
+
+module SOAP
+module Marshal
+class TestMarshal < Test::Unit::TestCase
+ include MarshalTestLib
+
+ def encode(o)
+ SOAPMarshal.dump(o)
+ end
+
+ def decode(s)
+ SOAPMarshal.load(s)
+ end
+end
+end
+end
diff --git a/test/soap/marshal/test_struct.rb b/test/soap/marshal/test_struct.rb
new file mode 100644
index 0000000000..33975c31b0
--- /dev/null
+++ b/test/soap/marshal/test_struct.rb
@@ -0,0 +1,47 @@
+require 'test/unit'
+require 'soap/marshal'
+
+
+module SOAP
+module Marshal
+
+
+Foo1 = ::Struct.new("Foo1", :m)
+Foo2 = ::Struct.new(:m)
+class Foo3
+ attr_accessor :m
+end
+
+class TestStruct < Test::Unit::TestCase
+ def test_foo1
+ org = Foo1.new
+ org.m = org
+ obj = convert(org)
+ assert_equal(Foo1, obj.class)
+ assert_equal(obj.m, obj)
+ end
+
+ def test_foo2
+ org = Foo2.new
+ org.m = org
+ obj = convert(org)
+ assert_equal(Foo2, obj.class)
+ assert_equal(obj.m, obj)
+ end
+
+ def test_foo3
+ org = Foo3.new
+ org.m = org
+ obj = convert(org)
+ assert_equal(Foo3, obj.class)
+ assert_equal(obj.m, obj)
+ end
+
+ def convert(obj)
+ SOAP::Marshal.unmarshal(SOAP::Marshal.marshal(obj))
+ end
+end
+
+
+end
+end
diff --git a/test/soap/ssl/README b/test/soap/ssl/README
new file mode 100644
index 0000000000..98ebcf7c23
--- /dev/null
+++ b/test/soap/ssl/README
@@ -0,0 +1 @@
+* certificates and keys in this directory is copied from http-access2 test.
diff --git a/test/soap/ssl/ca.cert b/test/soap/ssl/ca.cert
new file mode 100644
index 0000000000..bcabbee4ad
--- /dev/null
+++ b/test/soap/ssl/ca.cert
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIID0DCCArigAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMDAwNDIzMloXDTM2MDEyMjAwNDIzMlowPDELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQswCQYDVQQDDAJDQTCCASIw
+DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANbv0x42BTKFEQOE+KJ2XmiSdZpR
+wjzQLAkPLRnLB98tlzs4xo+y4RyY/rd5TT9UzBJTIhP8CJi5GbS1oXEerQXB3P0d
+L5oSSMwGGyuIzgZe5+vZ1kgzQxMEKMMKlzA73rbMd4Jx3u5+jdbP0EDrPYfXSvLY
+bS04n2aX7zrN3x5KdDrNBfwBio2/qeaaj4+9OxnwRvYP3WOvqdW0h329eMfHw0pi
+JI0drIVdsEqClUV4pebT/F+CPUPkEh/weySgo9wANockkYu5ujw2GbLFcO5LXxxm
+dEfcVr3r6t6zOA4bJwL0W/e6LBcrwiG/qPDFErhwtgTLYf6Er67SzLyA66UCAwEA
+AaOB3DCB2TAPBgNVHRMBAf8EBTADAQH/MDEGCWCGSAGG+EIBDQQkFiJSdWJ5L09w
+ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRJ7Xd380KzBV7f
+USKIQ+O/vKbhDzAOBgNVHQ8BAf8EBAMCAQYwZAYDVR0jBF0wW4AUSe13d/NCswVe
+31EiiEPjv7ym4Q+hQKQ+MDwxCzAJBgNVBAYMAkpQMRIwEAYDVQQKDAlKSU4uR1Iu
+SlAxDDAKBgNVBAsMA1JSUjELMAkGA1UEAwwCQ0GCAQAwDQYJKoZIhvcNAQEFBQAD
+ggEBAIu/mfiez5XN5tn2jScgShPgHEFJBR0BTJBZF6xCk0jyqNx/g9HMj2ELCuK+
+r/Y7KFW5c5M3AQ+xWW0ZSc4kvzyTcV7yTVIwj2jZ9ddYMN3nupZFgBK1GB4Y05GY
+MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
+PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
+PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
+d/xgcK06UVQRL/HbEYGiQL056mc=
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/client.cert b/test/soap/ssl/client.cert
new file mode 100644
index 0000000000..ad13c4b735
--- /dev/null
+++ b/test/soap/ssl/client.cert
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKDCCAhCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMTAzMTQ1OFoXDTM1MDEyMzAzMTQ1OFowZTELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRAwDgYDVQQDDAdleGFtcGxl
+MSIwIAYJKoZIhvcNAQkBDBNleGFtcGxlQGV4YW1wbGUub3JnMIGfMA0GCSqGSIb3
+DQEBAQUAA4GNADCBiQKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLW
+jTkvsgOwbYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQ
+gNS6ew7/Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2Xf
+ewIDAQABo4GPMIGMMAwGA1UdEwEB/wQCMAAwMQYJYIZIAYb4QgENBCQWIlJ1Ynkv
+T3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOFvay0H7lr2
+xUx6waYEV2bVDYQhMAsGA1UdDwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYI
+KwYBBQUHAwQwDQYJKoZIhvcNAQEFBQADggEBABd2dYWqbDIWf5sWFvslezxJv8gI
+w64KCJBuyJAiDuf+oazr3016kMzAlt97KecLZDusGNagPrq02UX7YMoQFsWJBans
+cDtHrkM0al5r6/WGexNMgtYbNTYzt/IwodISGBgZ6dsOuhznwms+IBsTNDAvWeLP
+lt2tOqD8kEmjwMgn0GDRuKjs4EoboA3kMULb1p9akDV9ZESU3eOtpS5/G5J5msLI
+9WXbYBjcjvkLuJH9VsJhb+R58Vl0ViemvAHhPilSl1SPWVunGhv6FcIkdBEi1k9F
+e8BNMmsEjFiANiIRvpdLRbiGBt0KrKTndVfsmoKCvY48oCOvnzxtahFxfs8=
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/client.key b/test/soap/ssl/client.key
new file mode 100644
index 0000000000..37bc62f259
--- /dev/null
+++ b/test/soap/ssl/client.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLWjTkvsgOw
+bYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQgNS6ew7/
+Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2XfewIDAQAB
+AoGAZcz8llWErtsV3QB9gNb3S/PNADGjqBFjReva8n3jG2k4sZSibpwWTwUaTNtT
+ZQgjSRKRvH1hk9XwffNAvXAQZNNkuj/16gO2oO45nyLj4dO365ujLptWnVIWDHOE
+uN0GeiZO+VzcCisT0WCq4tvtLeH8svrxzA8cbXIEyOK7NiECQQDwo2zPFyKAZ/Cu
+lDJ6zKT+RjfWwW7DgWzirAlTrt4ViMaW+IaDH29TmQpb4V4NuR3Xi+2Xl4oicu6S
+36TW9+/FAkEA3rgfOQJuLlWSnw1RTGwvnC816a/W7iYYY7B+0U4cDbfWl7IoXT4y
+M8nV/HESooviZLqBwzAYSoj3fFKYBKpGPwJAUO8GN5iWWA2dW3ooiDiv/X1sZmRk
+dojfMFWgRW747tEzya8Ivq0h6kH8w+5GjeMG8Gn1nRiwsulo6Ckj7dEx6QJACyui
+7UIQ8qP6GZ4aYMHgVW4Mvy7Bkeo5OO7GPYs0Xv/EdJFL8vlGnVBXOjUVoS9w6Gpu
+TbLg1QQvnX2rADjmEwJANxZO2GUkaWGsEif8aGW0x5g/IdaMGG27pTWk5zqix7P3
+1UDrdo/JOXhptovhRi06EppIxAxYmbh9vd9VN8Itlw==
+-----END RSA PRIVATE KEY-----
diff --git a/test/soap/ssl/server.cert b/test/soap/ssl/server.cert
new file mode 100644
index 0000000000..998ccc5892
--- /dev/null
+++ b/test/soap/ssl/server.cert
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxDjAMBgNVBAMMBVN1YkNB
+MB4XDTA0MDEzMTAzMTMxNloXDTMzMDEyMzAzMTMxNlowQzELMAkGA1UEBgwCSlAx
+EjAQBgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRIwEAYDVQQDDAlsb2Nh
+bGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANFJTxWqup3nV9dsJAku
+p+WaXnPNIzcpAA3qMGZDJTJsfa8Du7ZxTP0XJK5mETttBrn711cJxAuP3KjqnW9S
+vtZ9lY2sXJ6Zj62sN5LwG3VVe25dI28yR1EsbHjJ5Zjf9tmggMC6am52dxuHbt5/
+vHo4ngJuKE/U+eeGRivMn6gFAgMBAAGjgYUwgYIwDAYDVR0TAQH/BAIwADAxBglg
+hkgBhvhCAQ0EJBYiUnVieS9PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
+BgNVHQ4EFgQUpZIyygD9JxFYHHOTEuWOLbCKfckwCwYDVR0PBAQDAgWgMBMGA1Ud
+JQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4IBAQBwAIj5SaBHaA5X31IP
+CFCJiep96awfp7RANO0cuUj+ZpGoFn9d6FXY0g+Eg5wAkCNIzZU5NHN9xsdOpnUo
+zIBbyTfQEPrge1CMWMvL6uGaoEXytq84VTitF/xBTky4KtTn6+es4/e7jrrzeUXQ
+RC46gkHObmDT91RkOEGjHLyld2328jo3DIN/VTHIryDeVHDWjY5dENwpwdkhhm60
+DR9IrNBbXWEe9emtguNXeN0iu1ux0lG1Hc6pWGQxMlRKNvGh0yZB9u5EVe38tOV0
+jQaoNyL7qzcQoXD3Dmbi1p0iRmg/+HngISsz8K7k7MBNVsSclztwgCzTZOBiVtkM
+rRlQ
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/server.key b/test/soap/ssl/server.key
new file mode 100644
index 0000000000..9ba2218a03
--- /dev/null
+++ b/test/soap/ssl/server.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDRSU8Vqrqd51fXbCQJLqflml5zzSM3KQAN6jBmQyUybH2vA7u2
+cUz9FySuZhE7bQa5+9dXCcQLj9yo6p1vUr7WfZWNrFyemY+trDeS8Bt1VXtuXSNv
+MkdRLGx4yeWY3/bZoIDAumpudncbh27ef7x6OJ4CbihP1PnnhkYrzJ+oBQIDAQAB
+AoGBAIf4CstW2ltQO7+XYGoex7Hh8s9lTSW/G2vu5Hbr1LTHy3fzAvdq8MvVR12O
+rk9fa+lU9vhzPc0NMB0GIDZ9GcHuhW5hD1Wg9OSCbTOkZDoH3CAFqonjh4Qfwv5W
+IPAFn9KHukdqGXkwEMdErsUaPTy9A1V/aROVEaAY+HJgq/eZAkEA/BP1QMV04WEZ
+Oynzz7/lLizJGGxp2AOvEVtqMoycA/Qk+zdKP8ufE0wbmCE3Qd6GoynavsHb6aGK
+gQobb8zDZwJBANSK6MrXlrZTtEaeZuyOB4mAmRzGzOUVkUyULUjEx2GDT93ujAma
+qm/2d3E+wXAkNSeRpjUmlQXy/2oSqnGvYbMCQQDRM+cYyEcGPUVpWpnj0shrF/QU
+9vSot/X1G775EMTyaw6+BtbyNxVgOIu2J+rqGbn3c+b85XqTXOPL0A2RLYkFAkAm
+syhSDtE9X55aoWsCNZY/vi+i4rvaFoQ/WleogVQAeGVpdo7/DK9t9YWoFBIqth0L
+mGSYFu9ZhvZkvQNV8eYrAkBJ+rOIaLDsmbrgkeDruH+B/9yrm4McDtQ/rgnOGYnH
+LjLpLLOrgUxqpzLWe++EwSLwK2//dHO+SPsQJ4xsyQJy
+-----END RSA PRIVATE KEY-----
diff --git a/test/soap/ssl/sslsvr.rb b/test/soap/ssl/sslsvr.rb
new file mode 100644
index 0000000000..4f67eb9485
--- /dev/null
+++ b/test/soap/ssl/sslsvr.rb
@@ -0,0 +1,57 @@
+require 'webrick/https'
+require 'logger'
+require 'rbconfig'
+
+require 'soap/rpc/httpserver'
+
+class HelloWorldServer < SOAP::RPC::HTTPServer
+private
+
+ def on_init
+ self.level = Logger::Severity::FATAL
+ @default_namespace = 'urn:ssltst'
+ add_method(self, 'hello_world', 'from')
+ end
+
+ def hello_world(from)
+ "Hello World, from #{ from }"
+ end
+end
+
+
+if $0 == __FILE__
+ PORT = 17171
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ def cert(filename)
+ OpenSSL::X509::Certificate.new(File.open(File.join(DIR, filename)) { |f|
+ f.read
+ })
+ end
+
+ def key(filename)
+ OpenSSL::PKey::RSA.new(File.open(File.join(DIR, filename)) { |f|
+ f.read
+ })
+ end
+
+ $server = HelloWorldServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => PORT,
+ :AccessLog => [],
+ :SSLEnable => true,
+ :SSLCACertificateFile => File.join(DIR, 'ca.cert'),
+ :SSLCertificate => cert('server.cert'),
+ :SSLPrivateKey => key('server.key'),
+ :SSLVerifyClient => nil, #OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT|OpenSSL::SSL::VERIFY_PEER,
+ :SSLClientCA => cert('ca.cert'),
+ :SSLCertName => nil
+ )
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ $server.start
+ }
+ STDOUT.sync = true
+ puts $$
+ t.join
+end
diff --git a/test/soap/ssl/subca.cert b/test/soap/ssl/subca.cert
new file mode 100644
index 0000000000..1e471851b8
--- /dev/null
+++ b/test/soap/ssl/subca.cert
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMDAwNDMyN1oXDTM1MDEyMjAwNDMyN1owPzELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQ4wDAYDVQQDDAVTdWJDQTCC
+ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ0Ou7AyRcRXnB/kVHv/6kwe
+ANzgg/DyJfsAUqW90m7Lu1nqyug8gK0RBd77yU0w5HOAMHTVSdpjZK0g2sgx4Mb1
+d/213eL9TTl5MRVEChTvQr8q5DVG/8fxPPE7fMI8eOAzd98/NOAChk+80r4Sx7fC
+kGVEE1bKwY1MrUsUNjOY2d6t3M4HHV3HX1V8ShuKfsHxgCmLzdI8U+5CnQedFgkm
+3e+8tr8IX5RR1wA1Ifw9VadF7OdI/bGMzog/Q8XCLf+WPFjnK7Gcx6JFtzF6Gi4x
+4dp1Xl45JYiVvi9zQ132wu8A1pDHhiNgQviyzbP+UjcB/tsOpzBQF8abYzgEkWEC
+AwEAAaNyMHAwDwYDVR0TAQH/BAUwAwEB/zAxBglghkgBhvhCAQ0EJBYiUnVieS9P
+cGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUlCjXWLsReYzH
+LzsxwVnCXmKoB/owCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQCJ/OyN
+rT8Cq2Y+G2yA/L1EMRvvxwFBqxavqaqHl/6rwsIBFlB3zbqGA/0oec6MAVnYynq4
+c4AcHTjx3bQ/S4r2sNTZq0DH4SYbQzIobx/YW8PjQUJt8KQdKMcwwi7arHP7A/Ha
+LKu8eIC2nsUBnP4NhkYSGhbmpJK+PFD0FVtD0ZIRlY/wsnaZNjWWcnWF1/FNuQ4H
+ySjIblqVQkPuzebv3Ror6ZnVDukn96Mg7kP4u6zgxOeqlJGRe1M949SS9Vudjl8X
+SF4aZUUB9pQGhsqQJVqaz2OlhGOp9D0q54xko/rekjAIcuDjl1mdX4F2WRrzpUmZ
+uY/bPeOBYiVsOYVe
+-----END CERTIFICATE-----
diff --git a/test/soap/ssl/test_ssl.rb b/test/soap/ssl/test_ssl.rb
new file mode 100644
index 0000000000..f0a1e18971
--- /dev/null
+++ b/test/soap/ssl/test_ssl.rb
@@ -0,0 +1,204 @@
+require 'test/unit'
+begin
+ require 'http-access2'
+rescue LoadError
+end
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2) and defined?(OpenSSL)
+
+module SOAP; module SSL
+
+
+class TestSSL < Test::Unit::TestCase
+ PORT = 17171
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ require 'rbconfig'
+ RUBY = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+
+ def setup
+ @url = "https://localhost:#{PORT}/hello"
+ @serverpid = @client = nil
+ @verify_callback_called = false
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_server
+ end
+
+ def test_options
+ cfg = @client.streamhandler.client.ssl_config
+ assert_nil(cfg.client_cert)
+ assert_nil(cfg.client_key)
+ assert_nil(cfg.client_ca)
+ assert_equal(OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, cfg.verify_mode)
+ assert_nil(cfg.verify_callback)
+ assert_nil(cfg.timeout)
+ assert_equal(OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv2, cfg.options)
+ assert_equal("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH", cfg.ciphers)
+ assert_instance_of(OpenSSL::X509::Store, cfg.cert_store)
+ # dummy call to ensure sslsvr initialization finished.
+ assert_raise(OpenSSL::SSL::SSLError) do
+ @client.hello_world("ssl client")
+ end
+ end
+
+ def test_verification
+ cfg = @client.options
+ cfg["protocol.http.ssl_config.verify_callback"] = method(:verify_callback).to_proc
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.client_cert"] = File.join(DIR, "client.cert")
+ cfg["protocol.http.ssl_config.client_key"] = File.join(DIR, "client.key")
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert")
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert")
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.verify_depth"] = "1"
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.verify_depth"] = ""
+ cfg["protocol.http.ssl_config.cert_store"] = OpenSSL::X509::Store.new
+ cfg["protocol.http.ssl_config.verify_mode"] = OpenSSL::SSL::VERIFY_PEER.to_s
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ #
+ cfg["protocol.http.ssl_config.verify_mode"] = ""
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ end
+
+ def test_property
+ testpropertyname = File.join(DIR, 'soapclient.properties')
+ File.open(testpropertyname, "w") do |f|
+ f <<<<__EOP__
+protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
+# depth: 1 causes an error (intentional)
+protocol.http.ssl_config.verify_depth = 1
+protocol.http.ssl_config.client_cert = #{File.join(DIR, 'client.cert')}
+protocol.http.ssl_config.client_key = #{File.join(DIR, 'client.key')}
+protocol.http.ssl_config.ca_file = #{File.join(DIR, 'ca.cert')}
+protocol.http.ssl_config.ca_file = #{File.join(DIR, 'subca.cert')}
+protocol.http.ssl_config.ciphers = ALL
+__EOP__
+ end
+ begin
+ @client.loadproperty(testpropertyname)
+ @client.options["protocol.http.ssl_config.verify_callback"] = method(:verify_callback).to_proc
+ @verify_callback_called = false
+ # NG with String
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ # NG with Integer
+ @client.options["protocol.http.ssl_config.verify_depth"] = 0
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ # OK with empty
+ @client.options["protocol.http.ssl_config.verify_depth"] = ""
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ # OK with nil
+ @client.options["protocol.http.ssl_config.verify_depth"] = nil
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ # OK with String
+ @client.options["protocol.http.ssl_config.verify_depth"] = "3"
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ # OK with Integer
+ @client.options["protocol.http.ssl_config.verify_depth"] = 3
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ ensure
+ File.unlink(testpropertyname)
+ end
+ end
+
+ def test_ciphers
+ cfg = @client.options
+ cfg["protocol.http.ssl_config.client_cert"] = File.join(DIR, 'client.cert')
+ cfg["protocol.http.ssl_config.client_key"] = File.join(DIR, 'client.key')
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert")
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert")
+ #cfg.timeout = 123
+ cfg["protocol.http.ssl_config.ciphers"] = "!ALL"
+ #
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ # depends on OpenSSL version. (?:0.9.8|0.9.7)
+ assert_match(/\A(?:SSL_CTX_set_cipher_list:: no cipher match|no ciphers available)\z/, ssle.message)
+ #
+ cfg["protocol.http.ssl_config.ciphers"] = "ALL"
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ end
+
+private
+
+ def q(str)
+ %Q["#{str}"]
+ end
+
+ def setup_server
+ svrcmd = "#{q(RUBY)} "
+ #svrcmd << "-d " if $DEBUG
+ svrcmd << File.join(DIR, "sslsvr.rb")
+ svrout = IO.popen(svrcmd)
+ @serverpid = Integer(svrout.gets.chomp)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, 'urn:ssltst')
+ @client.add_method("hello_world", "from")
+ end
+
+ def teardown_server
+ if @serverpid
+ Process.kill('KILL', @serverpid)
+ Process.waitpid(@serverpid)
+ end
+ end
+
+ def teardown_client
+ @client.reset_stream if @client
+ end
+
+ def verify_callback(ok, cert)
+ @verify_callback_called = true
+ p ["client", ok, cert] if $DEBUG
+ ok
+ end
+end
+
+
+end; end
+
+end
diff --git a/test/soap/struct/test_struct.rb b/test/soap/struct/test_struct.rb
new file mode 100644
index 0000000000..d92f4bc18a
--- /dev/null
+++ b/test/soap/struct/test_struct.rb
@@ -0,0 +1,77 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/rpc/driver'
+
+
+module SOAP; module Struct
+
+
+class TestStruct < Test::Unit::TestCase
+ Namespace = "urn:example.com:simpletype-rpc"
+ class Server < ::SOAP::RPC::HTTPServer
+ @@test_struct = ::Struct.new(:one, :two)
+
+ def on_init
+ add_method(self, 'a_method')
+ end
+
+ def a_method
+ @@test_struct.new("string", 1)
+ end
+ end
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :Port => Port,
+ :BindAddress => "0.0.0.0",
+ :AccessLog => [],
+ :SOAPDefaultNamespace => Namespace
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/", Namespace)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('a_method')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_struct
+ assert_equal("string", @client.a_method.one)
+ assert_equal(1, @client.a_method.two)
+ end
+end
+
+
+end; end
diff --git a/test/soap/swa/test_file.rb b/test/soap/swa/test_file.rb
new file mode 100644
index 0000000000..1ec7aa92a7
--- /dev/null
+++ b/test/soap/swa/test_file.rb
@@ -0,0 +1,73 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/attachment'
+
+
+module SOAP
+module SWA
+
+
+class TestFile < Test::Unit::TestCase
+ Port = 17171
+ THIS_FILE = File.expand_path(__FILE__)
+
+ class SwAService
+ def get_file
+ return {
+ 'name' => $0,
+ 'file' => SOAP::Attachment.new(File.open(THIS_FILE)) # closed when GCed.
+ }
+ end
+
+ def put_file(name, file)
+ "File '#{name}' was received ok."
+ end
+ end
+
+ def setup
+ @server = SOAP::RPC::StandaloneServer.new('SwAServer',
+ 'http://www.acmetron.com/soap', '0.0.0.0', Port)
+ @server.add_servant(SwAService.new)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'http://www.acmetron.com/soap')
+ @client.add_method('get_file')
+ @client.add_method('put_file', 'name', 'file')
+ @client.wiredump_dev = STDERR if $DEBUG
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_get_file
+ assert_equal(
+ File.open(THIS_FILE) { |f| f.read },
+ @client.get_file['file'].content
+ )
+ end
+
+ def test_put_file
+ assert_equal(
+ "File 'foo' was received ok.",
+ @client.put_file('foo',
+ SOAP::Attachment.new(File.open(THIS_FILE)))
+ )
+ assert_equal(
+ "File 'bar' was received ok.",
+ @client.put_file('bar',
+ SOAP::Attachment.new(File.open(THIS_FILE) { |f| f.read }))
+ )
+ end
+end
+
+
+end
+end
diff --git a/test/soap/test_basetype.rb b/test/soap/test_basetype.rb
new file mode 100644
index 0000000000..3785873560
--- /dev/null
+++ b/test/soap/test_basetype.rb
@@ -0,0 +1,970 @@
+require 'test/unit'
+require 'soap/baseData'
+
+
+module SOAP
+
+
+class TestSOAP < Test::Unit::TestCase
+ NegativeZero = (-1.0 / (1.0 / 0.0))
+
+ def setup
+ # Nothing to do.
+ end
+
+ def teardown
+ # Nothing to do.
+ end
+
+ def assert_parsed_result(klass, str)
+ o = klass.new(str)
+ assert_equal(str, o.to_s)
+ end
+
+ def test_SOAPNil
+ o = SOAP::SOAPNil.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::NilLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ o = SOAP::SOAPNil.new(nil)
+ assert_equal(true, o.is_nil)
+ assert_equal(nil, o.data)
+ assert_equal("", o.to_s)
+ o = SOAP::SOAPNil.new('var')
+ assert_equal(false, o.is_nil)
+ assert_equal('var', o.data)
+ assert_equal('var', o.to_s)
+ end
+
+ def test_SOAPString
+ o = SOAP::SOAPString.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::StringLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ str = "abc"
+ assert_equal(str, SOAP::SOAPString.new(str).data)
+ assert_equal(str, SOAP::SOAPString.new(str).to_s)
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPString.new("\0")
+ end
+ assert_raises(XSD::ValueSpaceError) do
+ p SOAP::SOAPString.new("\xC0\xC0").to_s
+ end
+ end
+
+ def test_SOAPBoolean
+ o = SOAP::SOAPBoolean.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::BooleanLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ ["true", true],
+ ["1", true],
+ ["false", false],
+ ["0", false],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPBoolean.new(data).data)
+ assert_equal(expected.to_s, SOAP::SOAPBoolean.new(data).to_s)
+ end
+
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPBoolean.new("nil").to_s
+ end
+ end
+
+ def test_SOAPDecimal
+ o = SOAP::SOAPDecimal.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DecimalLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 1000000000,
+ -9999999999,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ -1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789,
+ ]
+ targets.each do |dec|
+ assert_equal(dec.to_s, SOAP::SOAPDecimal.new(dec).data)
+ end
+
+ targets = [
+ "0",
+ "0.00000001",
+ "1000000000",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123.45678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPDecimal.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["0.0", "0"],
+ ["-0.0", "0"],
+ ["+0.0", "0"],
+ ["0.", "0"],
+ [".0", "0"],
+ [
+ "+0.12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "0.1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ ],
+ [
+ ".0000012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "0.000001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ ],
+ [
+ "-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.",
+ "-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ ],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDecimal.new(data).to_s)
+ end
+
+ targets = [
+ "0.000000000000a",
+ "00a.0000000000001",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPDecimal.new(d)
+ end
+ end
+ end
+
+ def test_SOAPFloat
+ o = SOAP::SOAPFloat.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::FloatLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 3.14159265358979,
+ 12.34e36,
+ 1.402e-45,
+ -1.402e-45,
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPFloat.new(f).data)
+ end
+
+ targets = [
+ "+3.141592654",
+ "+1.234e+37",
+ "+1.402e-45",
+ "-1.402e-45",
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPFloat.new(f).to_s)
+ end
+
+ targets = [
+ [3, "+3"], # should be 3.0?
+ [-2, "-2"], # ditto
+ [3.14159265358979, "+3.141592654"],
+ [12.34e36, "+1.234e+37"],
+ [1.402e-45, "+1.402e-45"],
+ [-1.402e-45, "-1.402e-45"],
+ ["1.402e", "+1.402"],
+ ["12.34E36", "+1.234e+37"],
+ ["1.402E-45", "+1.402e-45"],
+ ["-1.402E-45", "-1.402e-45"],
+ ["1.402E", "+1.402"],
+ ]
+ targets.each do |f, str|
+ assert_equal(str, SOAP::SOAPFloat.new(f).to_s)
+ end
+
+ assert_equal("+0", SOAP::SOAPFloat.new(+0.0).to_s)
+ assert_equal("-0", SOAP::SOAPFloat.new(NegativeZero).to_s)
+ assert(SOAP::SOAPFloat.new(0.0/0.0).data.nan?)
+ assert_equal("INF", SOAP::SOAPFloat.new(1.0/0.0).to_s)
+ assert_equal(1, SOAP::SOAPFloat.new(1.0/0.0).data.infinite?)
+ assert_equal("-INF", SOAP::SOAPFloat.new(-1.0/0.0).to_s)
+ assert_equal(-1, SOAP::SOAPFloat.new(-1.0/0.0).data.infinite?)
+
+ targets = [
+ "0.000000000000a",
+ "00a.0000000000001",
+ "+-5",
+ "5_0",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPFloat.new(d)
+ end
+ end
+ end
+
+ def test_SOAPDouble
+ o = SOAP::SOAPDouble.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DoubleLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 3.14159265358979,
+ 12.34e36,
+ 1.402e-45,
+ -1.402e-45,
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPDouble.new(f).data)
+ end
+
+ targets = [
+ "+3.14159265358979",
+ "+1.234e+37",
+ "+1.402e-45",
+ "-1.402e-45",
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPDouble.new(f).to_s)
+ end
+
+ targets = [
+ [3, "+3"], # should be 3.0?
+ [-2, "-2"], # ditto.
+ [3.14159265358979, "+3.14159265358979"],
+ [12.34e36, "+1.234e+37"],
+ [1.402e-45, "+1.402e-45"],
+ [-1.402e-45, "-1.402e-45"],
+ ["1.402e", "+1.402"],
+ ["12.34E36", "+1.234e+37"],
+ ["1.402E-45", "+1.402e-45"],
+ ["-1.402E-45", "-1.402e-45"],
+ ["1.402E", "+1.402"],
+ ]
+ targets.each do |f, str|
+ assert_equal(str, SOAP::SOAPDouble.new(f).to_s)
+ end
+
+ assert_equal("+0", SOAP::SOAPFloat.new(+0.0).to_s)
+ assert_equal("-0", SOAP::SOAPFloat.new(NegativeZero).to_s)
+ assert_equal("NaN", SOAP::SOAPDouble.new(0.0/0.0).to_s)
+ assert(SOAP::SOAPDouble.new(0.0/0.0).data.nan?)
+ assert_equal("INF", SOAP::SOAPDouble.new(1.0/0.0).to_s)
+ assert_equal(1, SOAP::SOAPDouble.new(1.0/0.0).data.infinite?)
+ assert_equal("-INF", SOAP::SOAPDouble.new(-1.0/0.0).to_s)
+ assert_equal(-1, SOAP::SOAPDouble.new(-1.0/0.0).data.infinite?)
+
+ targets = [
+ "0.000000000000a",
+ "00a.0000000000001",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPDouble.new(d)
+ end
+ end
+ end
+
+ def test_SOAPDuration
+ o = SOAP::SOAPDuration.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DurationLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "P1Y2M3DT4H5M6S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S",
+ "P0DT3456H7890M1234.5678S",
+ "P1234Y5678M9012D",
+ "-P1234Y5678M9012DT3456H7890M1234.5678S",
+ "P5678M9012DT3456H7890M1234.5678S",
+ "-P1234Y9012DT3456H7890M1234.5678S",
+ "+P1234Y5678MT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT7890M1234.5678S",
+ "-P1234Y5678M9012DT3456H1234.5678S",
+ "+P1234Y5678M9012DT3456H7890M",
+ "P123400000000000Y",
+ "-P567800000000000M",
+ "+P901200000000000D",
+ "P0DT345600000000000H",
+ "-P0DT789000000000000M",
+ "+P0DT123400000000000.000000000005678S",
+ "P1234YT1234.5678S",
+ "-P5678MT7890M",
+ "+P9012DT3456H",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPDuration, str)
+ end
+
+ targets = [
+ ["P0Y0M0DT0H0M0S",
+ "P0D"],
+ ["-P0DT0S",
+ "-P0D"],
+ ["P01234Y5678M9012DT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y005678M9012DT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M0009012DT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M9012DT00003456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M9012DT3456H000007890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M9012DT3456H7890M0000001234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDuration.new(data).to_s)
+ end
+ end
+
+ def test_SOAPDateTime
+ o = SOAP::SOAPDateTime.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DateTimeLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002-05-18T16:52:20Z",
+ "0001-01-01T00:00:00Z",
+ "9999-12-31T23:59:59Z",
+ "19999-12-31T23:59:59Z",
+ "2002-12-31T23:59:59.999Z",
+ "2002-12-31T23:59:59.001Z",
+ "2002-12-31T23:59:59.99999999999999999999Z",
+ "2002-12-31T23:59:59.00000000000000000001Z",
+ "2002-12-31T23:59:59+09:00",
+ "2002-12-31T23:59:59+00:01",
+ "2002-12-31T23:59:59-00:01",
+ "2002-12-31T23:59:59-23:59",
+ "2002-12-31T23:59:59.00000000000000000001+13:30",
+ "2002-12-31T23:59:59.51375Z",
+ "2002-12-31T23:59:59.51345+12:34",
+ "-2002-05-18T16:52:20Z",
+ "-4711-12-31T23:59:59Z",
+ "-4713-01-01T12:00:00Z",
+ "-19999-12-31T23:59:59Z",
+ "-2002-12-31T23:59:59+00:01",
+ "-0001-12-31T23:59:59.00000000000000000001+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPDateTime, str)
+ end
+
+ targets = [
+ ["2002-12-31T23:59:59.00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59+00:00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59-00:00",
+ "2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59.00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59+00:00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59-00:00",
+ "-2002-12-31T23:59:59Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDateTime.new(data).to_s)
+ d = DateTime.parse(data)
+ d >>= 12 if d.year < 0 # XSDDateTime.year(-1) == DateTime.year(0)
+ assert_equal(expected, SOAP::SOAPDateTime.new(d).to_s)
+ end
+
+ targets = [
+ "1-05-18T16:52:20Z",
+ "05-18T16:52:20Z",
+ "2002-05T16:52:20Z",
+ "2002-05-18T16:52Z",
+ "",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError, d.to_s) do
+ SOAP::SOAPDateTime.new(d)
+ end
+ end
+ end
+
+ def test_SOAPTime
+ o = SOAP::SOAPTime.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::TimeLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "16:52:20Z",
+ "00:00:00Z",
+ "23:59:59Z",
+ "23:59:59.999Z",
+ "23:59:59.001Z",
+ "23:59:59.99999999999999999999Z",
+ "23:59:59.00000000000000000001Z",
+ "23:59:59+09:00",
+ "23:59:59+00:01",
+ "23:59:59-00:01",
+ "23:59:59-23:59",
+ "23:59:59.00000000000000000001+13:30",
+ "23:59:59.51375Z",
+ "23:59:59.51375+12:34",
+ "23:59:59+00:01",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPTime, str)
+ end
+
+ targets = [
+ ["23:59:59.00",
+ "23:59:59Z"],
+ ["23:59:59+00:00",
+ "23:59:59Z"],
+ ["23:59:59-00:00",
+ "23:59:59Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPTime.new(data).to_s)
+ end
+ end
+
+ def test_SOAPDate
+ o = SOAP::SOAPDate.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DateLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002-05-18Z",
+ "0001-01-01Z",
+ "9999-12-31Z",
+ "19999-12-31Z",
+ "2002-12-31+09:00",
+ "2002-12-31+00:01",
+ "2002-12-31-00:01",
+ "2002-12-31-23:59",
+ "2002-12-31+13:30",
+ "-2002-05-18Z",
+ "-19999-12-31Z",
+ "-2002-12-31+00:01",
+ "-0001-12-31+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPDate, str)
+ end
+
+ targets = [
+ ["2002-12-31",
+ "2002-12-31Z"],
+ ["2002-12-31+00:00",
+ "2002-12-31Z"],
+ ["2002-12-31-00:00",
+ "2002-12-31Z"],
+ ["-2002-12-31",
+ "-2002-12-31Z"],
+ ["-2002-12-31+00:00",
+ "-2002-12-31Z"],
+ ["-2002-12-31-00:00",
+ "-2002-12-31Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDate.new(data).to_s)
+ d = Date.parse(data)
+ d >>= 12 if d.year < 0 # XSDDate.year(-1) == Date.year(0)
+ assert_equal(expected, SOAP::SOAPDate.new(d).to_s)
+ end
+ end
+
+ def test_SOAPGYearMonth
+ o = SOAP::SOAPGYearMonth.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GYearMonthLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002-05Z",
+ "0001-01Z",
+ "9999-12Z",
+ "19999-12Z",
+ "2002-12+09:00",
+ "2002-12+00:01",
+ "2002-12-00:01",
+ "2002-12-23:59",
+ "2002-12+13:30",
+ "-2002-05Z",
+ "-19999-12Z",
+ "-2002-12+00:01",
+ "-0001-12+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGYearMonth, str)
+ end
+
+ targets = [
+ ["2002-12",
+ "2002-12Z"],
+ ["2002-12+00:00",
+ "2002-12Z"],
+ ["2002-12-00:00",
+ "2002-12Z"],
+ ["-2002-12",
+ "-2002-12Z"],
+ ["-2002-12+00:00",
+ "-2002-12Z"],
+ ["-2002-12-00:00",
+ "-2002-12Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGYearMonth.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGYear
+ o = SOAP::SOAPGYear.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GYearLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002Z",
+ "0001Z",
+ "9999Z",
+ "19999Z",
+ "2002+09:00",
+ "2002+00:01",
+ "2002-00:01",
+ "2002-23:59",
+ "2002+13:30",
+ "-2002Z",
+ "-19999Z",
+ "-2002+00:01",
+ "-0001+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGYear, str)
+ end
+
+ targets = [
+ ["2002",
+ "2002Z"],
+ ["2002+00:00",
+ "2002Z"],
+ ["2002-00:00",
+ "2002Z"],
+ ["-2002",
+ "-2002Z"],
+ ["-2002+00:00",
+ "-2002Z"],
+ ["-2002-00:00",
+ "-2002Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGYear.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGMonthDay
+ o = SOAP::SOAPGMonthDay.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GMonthDayLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "05-18Z",
+ "01-01Z",
+ "12-31Z",
+ "12-31+09:00",
+ "12-31+00:01",
+ "12-31-00:01",
+ "12-31-23:59",
+ "12-31+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGMonthDay, str)
+ end
+
+ targets = [
+ ["12-31",
+ "12-31Z"],
+ ["12-31+00:00",
+ "12-31Z"],
+ ["12-31-00:00",
+ "12-31Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGMonthDay.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGDay
+ o = SOAP::SOAPGDay.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GDayLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "18Z",
+ "01Z",
+ "31Z",
+ "31+09:00",
+ "31+00:01",
+ "31-00:01",
+ "31-23:59",
+ "31+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGDay, str)
+ end
+
+ targets = [
+ ["31",
+ "31Z"],
+ ["31+00:00",
+ "31Z"],
+ ["31-00:00",
+ "31Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGDay.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGMonth
+ o = SOAP::SOAPGMonth.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GMonthLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "05Z",
+ "01Z",
+ "12Z",
+ "12+09:00",
+ "12+00:01",
+ "12-00:01",
+ "12-23:59",
+ "12+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGMonth, str)
+ end
+
+ targets = [
+ ["12",
+ "12Z"],
+ ["12+00:00",
+ "12Z"],
+ ["12-00:00",
+ "12Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGMonth.new(data).to_s)
+ end
+ end
+
+ def test_SOAPHexBinary
+ o = SOAP::SOAPHexBinary.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::HexBinaryLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "abcdef",
+ "\xe3\x81\xaa\xe3\x81\xb2",
+ "\0",
+ "",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPHexBinary.new(str).string)
+ assert_equal(str.unpack("H*")[0].tr('a-f', 'A-F'),
+ SOAP::SOAPHexBinary.new(str).data)
+ o = SOAP::SOAPHexBinary.new
+ o.set_encoded(str.unpack("H*")[0].tr('a-f', 'A-F'))
+ assert_equal(str, o.string)
+ o.set_encoded(str.unpack("H*")[0].tr('A-F', 'a-f'))
+ assert_equal(str, o.string)
+ end
+
+ targets = [
+ "0FG7",
+ "0fg7",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError, d.to_s) do
+ o = SOAP::SOAPHexBinary.new
+ o.set_encoded(d)
+ p o.string
+ end
+ end
+ end
+
+ def test_SOAPBase64Binary
+ o = SOAP::SOAPBase64.new
+ assert_equal(SOAP::EncodingNamespace, o.type.namespace)
+ assert_equal(SOAP::Base64Literal, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "abcdef",
+ "\xe3\x81\xaa\xe3\x81\xb2",
+ "\0",
+ "",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPBase64.new(str).string)
+ assert_equal([str].pack("m").chomp, SOAP::SOAPBase64.new(str).data)
+ o = SOAP::SOAPBase64.new
+ o.set_encoded([str].pack("m").chomp)
+ assert_equal(str, o.string)
+ end
+
+ targets = [
+ "-",
+ "*",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError, d.to_s) do
+ o = SOAP::SOAPBase64.new
+ o.set_encoded(d)
+ p o.string
+ end
+ end
+ end
+
+ def test_SOAPAnyURI
+ o = SOAP::SOAPAnyURI.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::AnyURILiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ # Too few tests here I know. Believe uri module. :)
+ targets = [
+ "foo",
+ "http://foo",
+ "http://foo/bar/baz",
+ "http://foo/bar#baz",
+ "http://foo/bar%20%20?a+b",
+ "HTTP://FOO/BAR%20%20?A+B",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPAnyURI, str)
+ end
+ end
+
+ def test_SOAPQName
+ o = SOAP::SOAPQName.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::QNameLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ # More strict test is needed but current implementation allows all non-':'
+ # chars like ' ', C0 or C1...
+ targets = [
+ "foo",
+ "foo:bar",
+ "a:b",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPQName, str)
+ end
+ end
+
+
+ ###
+ ## Derived types
+ #
+
+ def test_SOAPInteger
+ o = SOAP::SOAPInteger.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::IntegerLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 1000000000,
+ -9999999999,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ -1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789,
+ ]
+ targets.each do |int|
+ assert_equal(int, SOAP::SOAPInteger.new(int).data)
+ end
+
+ targets = [
+ "0",
+ "1000000000",
+ "-9999999999",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPInteger.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["000123", "123"],
+ ["-000123", "-123"],
+ [
+ "+12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ ],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPInteger.new(data).to_s)
+ end
+
+ targets = [
+ "0.0",
+ "-5.2",
+ "0.000000000000a",
+ "+-5",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890."
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPInteger.new(d)
+ end
+ end
+ end
+
+ def test_SOAPLong
+ o = SOAP::SOAPLong.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::LongLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 123,
+ -123,
+ 9223372036854775807,
+ -9223372036854775808,
+ ]
+ targets.each do |lng|
+ assert_equal(lng, SOAP::SOAPLong.new(lng).data)
+ end
+
+ targets = [
+ "0",
+ "123",
+ "-123",
+ "9223372036854775807",
+ "-9223372036854775808",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPLong.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["000123", "123"],
+ ["-000123", "-123"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPLong.new(data).to_s)
+ end
+
+ targets = [
+ 9223372036854775808,
+ -9223372036854775809,
+ "0.0",
+ "-5.2",
+ "0.000000000000a",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPLong.new(d)
+ end
+ end
+ end
+
+ def test_SOAPInt
+ o = SOAP::SOAPInt.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::IntLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 123,
+ -123,
+ 2147483647,
+ -2147483648,
+ ]
+ targets.each do |lng|
+ assert_equal(lng, SOAP::SOAPInt.new(lng).data)
+ end
+
+ targets = [
+ "0",
+ "123",
+ "-123",
+ "2147483647",
+ "-2147483648",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPInt.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["000123", "123"],
+ ["-000123", "-123"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPInt.new(data).to_s)
+ end
+
+ targets = [
+ 2147483648,
+ -2147483649,
+ "0.0",
+ "-5.2",
+ "0.000000000000a",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPInt.new(d)
+ end
+ end
+ end
+end
+
+
+end
diff --git a/test/soap/test_envelopenamespace.rb b/test/soap/test_envelopenamespace.rb
new file mode 100644
index 0000000000..5b7d281341
--- /dev/null
+++ b/test/soap/test_envelopenamespace.rb
@@ -0,0 +1,92 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'webrick'
+require 'logger'
+
+
+module SOAP
+
+
+class TestEnvelopeNamespace < Test::Unit::TestCase
+ Port = 17171
+ TemporaryNamespace = 'urn:foo'
+
+ def setup
+ @logger = Logger.new(STDERR)
+ @logger.level = Logger::Severity::ERROR
+ @url = "http://localhost:#{Port}/"
+ @server = @client = nil
+ @server_thread = nil
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_server
+ end
+
+ def setup_server
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => @logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__))
+ )
+ @server.mount(
+ '/',
+ WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc).to_proc)
+ )
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, '')
+ @client.add_method("do_server_proc")
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def do_server_proc(req, res)
+ res['content-type'] = 'text/xml'
+ res.body = <<__EOX__
+<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:env="#{TemporaryNamespace}">
+ <env:Body>
+ <n1:do_server_proc xmlns:n1="urn:foo" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <return>hello world</return>
+ </n1:do_server_proc>
+ </env:Body>
+</env:Envelope>
+__EOX__
+ end
+
+ def test_normal
+ assert_raise(SOAP::ResponseFormatError) do
+ @client.do_server_proc
+ end
+ @client.options["soap.envelope.requestnamespace"] = TemporaryNamespace
+ @client.options["soap.envelope.responsenamespace"] = TemporaryNamespace
+ assert_equal('hello world', @client.do_server_proc)
+ end
+end
+
+
+end
diff --git a/test/soap/test_httpconfigloader.rb b/test/soap/test_httpconfigloader.rb
new file mode 100644
index 0000000000..b06243f661
--- /dev/null
+++ b/test/soap/test_httpconfigloader.rb
@@ -0,0 +1,39 @@
+require 'test/unit'
+require 'soap/httpconfigloader'
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2)
+
+module SOAP
+
+
+class TestHTTPConfigLoader < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ def setup
+ @client = SOAP::RPC::Driver.new(nil, nil)
+ end
+
+ def test_property
+ testpropertyname = File.join(DIR, 'soapclient.properties')
+ File.open(testpropertyname, "w") do |f|
+ f <<<<__EOP__
+protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
+# depth: 1 causes an error (intentional)
+protocol.http.ssl_config.verify_depth = 1
+protocol.http.ssl_config.ciphers = ALL
+__EOP__
+ end
+ begin
+ @client.loadproperty(testpropertyname)
+ assert_equal('ALL', @client.options['protocol.http.ssl_config.ciphers'])
+ ensure
+ File.unlink(testpropertyname)
+ end
+ end
+end
+
+
+end
+
+end
diff --git a/test/soap/test_mapping.rb b/test/soap/test_mapping.rb
new file mode 100644
index 0000000000..26222e6719
--- /dev/null
+++ b/test/soap/test_mapping.rb
@@ -0,0 +1,59 @@
+require 'test/unit'
+require 'soap/mapping'
+
+
+module SOAP
+
+
+class TestMapping < Test::Unit::TestCase
+ def test_date
+ targets = [
+ ["2002-12-31",
+ "2002-12-31Z"],
+ ["2002-12-31+00:00",
+ "2002-12-31Z"],
+ ["2002-12-31-00:00",
+ "2002-12-31Z"],
+ ["-2002-12-31",
+ "-2002-12-31Z"],
+ ["-2002-12-31+00:00",
+ "-2002-12-31Z"],
+ ["-2002-12-31-00:00",
+ "-2002-12-31Z"],
+ ]
+ targets.each do |str, expectec|
+ d = Date.parse(str)
+ assert_equal(d.class, convert(d).class)
+ assert_equal(d, convert(d))
+ end
+ end
+
+ def test_datetime
+ targets = [
+ ["2002-12-31T23:59:59.00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59+00:00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59-00:00",
+ "2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59.00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59+00:00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59-00:00",
+ "-2002-12-31T23:59:59Z"],
+ ]
+ targets.each do |str, expectec|
+ d = DateTime.parse(str)
+ assert_equal(d.class, convert(d).class)
+ assert_equal(d, convert(d))
+ end
+ end
+
+ def convert(obj)
+ SOAP::Mapping.soap2obj(SOAP::Mapping.obj2soap(obj))
+ end
+end
+
+
+end
diff --git a/test/soap/test_no_indent.rb b/test/soap/test_no_indent.rb
new file mode 100644
index 0000000000..f49fb7389f
--- /dev/null
+++ b/test/soap/test_no_indent.rb
@@ -0,0 +1,86 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2)
+
+module SOAP
+
+
+class TestNoIndent < Test::Unit::TestCase
+ Port = 17171
+
+ class NopServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+ add_rpc_method(self, 'nop')
+ end
+
+ def nop
+ SOAP::RPC::SOAPVoid.new
+ end
+ end
+
+ def setup
+ @server = NopServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint)
+ @client.add_rpc_method('nop')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ INDENT_XML =
+%q[<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ </nop>
+ </env:Body>
+</env:Envelope>]
+
+ NO_INDENT_XML =
+%q[<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<env:Body>
+<nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+</nop>
+</env:Body>
+</env:Envelope>]
+
+ def test_indent
+ @client.wiredump_dev = str = ''
+ @client.options["soap.envelope.no_indent"] = false
+ @client.nop
+ assert_equal(INDENT_XML, parse_requestxml(str))
+ end
+
+ def test_no_indent
+ @client.wiredump_dev = str = ''
+ @client.options["soap.envelope.no_indent"] = true
+ @client.nop
+ assert_equal(NO_INDENT_XML, parse_requestxml(str))
+ end
+
+ def parse_requestxml(str)
+ str.split(/\r?\n\r?\n/)[3]
+ end
+end
+
+
+end
+
+end
diff --git a/test/soap/test_property.rb b/test/soap/test_property.rb
new file mode 100644
index 0000000000..7acd2c8437
--- /dev/null
+++ b/test/soap/test_property.rb
@@ -0,0 +1,424 @@
+require 'test/unit'
+require 'soap/property'
+
+
+module SOAP
+
+
+class TestProperty < Test::Unit::TestCase
+ FrozenError = (RUBY_VERSION >= "1.9.0") ? RuntimeError : TypeError
+
+ def setup
+ @prop = ::SOAP::Property.new
+ end
+
+ def teardown
+ # Nothing to do.
+ end
+
+ def test_s_load
+ propstr = <<__EOP__
+
+# comment1
+
+# comment2\r
+# comment2
+
+\r
+a.b.0 = 1
+a.b.1 = 2
+a.b.2 = 3
+client.protocol.http.proxy=http://myproxy:8080 \r
+client.protocol.http.no_proxy: intranet.example.com,local.example.com\r
+client.protocol.http.protocol_version = 1.0
+foo\\:bar\\=baz = qux
+foo\\\\.bar.baz=\tq\\\\ux\ttab
+ a\\ b = 1
+[ppp.qqq.rrr]
+sss = 3
+ttt.uuu = 4
+
+[ sss.ttt.uuu ]
+vvv.www = 5
+[ ]
+xxx.yyy.zzz = 6
+__EOP__
+ prop = Property.load(propstr)
+ assert_equal(["1", "2", "3"], prop["a.b"].values.sort)
+ assert_equal("intranet.example.com,local.example.com",
+ prop["client.protocol.http.no_proxy"])
+ assert_equal("http://myproxy:8080", prop["client.protocol.http.proxy"])
+ assert_equal("1.0", prop["client.protocol.http.protocol_version"])
+ assert_equal("q\\ux\ttab", prop['foo\.bar.baz'])
+ assert_equal("1", prop['a b'])
+ assert_equal("3", prop['ppp.qqq.rrr.sss'])
+ assert_equal("4", prop['ppp.qqq.rrr.ttt.uuu'])
+ assert_equal("5", prop['sss.ttt.uuu.vvv.www'])
+ assert_equal("6", prop['xxx.yyy.zzz'])
+ end
+
+ def test_load
+ prop = Property.new
+ hooked = false
+ prop.add_hook("foo.bar.baz") do |name, value|
+ assert_equal(["foo", "bar", "baz"], name)
+ assert_equal("123", value)
+ hooked = true
+ end
+ prop.lock
+ prop["foo.bar"].lock
+ prop.load("foo.bar.baz = 123")
+ assert(hooked)
+ assert_raises(FrozenError) do
+ prop.load("foo.bar.qux = 123")
+ end
+ prop.load("foo.baz = 456")
+ assert_equal("456", prop["foo.baz"])
+ end
+
+ def test_initialize
+ prop = ::SOAP::Property.new
+ # store is empty
+ assert_nil(prop["a"])
+ # does hook work?
+ assert_equal(1, prop["a"] = 1)
+ end
+
+ def test_aref
+ # name_to_a
+ assert_nil(@prop[:foo])
+ assert_nil(@prop["foo"])
+ assert_nil(@prop[[:foo]])
+ assert_nil(@prop[["foo"]])
+ assert_raises(ArgumentError) do
+ @prop[1]
+ end
+ @prop[:foo] = :foo
+ assert_equal(:foo, @prop[:foo])
+ assert_equal(:foo, @prop["foo"])
+ assert_equal(:foo, @prop[[:foo]])
+ assert_equal(:foo, @prop[["foo"]])
+ end
+
+ def test_referent
+ # referent(1)
+ assert_nil(@prop["foo.foo"])
+ assert_nil(@prop[["foo", "foo"]])
+ assert_nil(@prop[["foo", :foo]])
+ @prop["foo.foo"] = :foo
+ assert_equal(:foo, @prop["foo.foo"])
+ assert_equal(:foo, @prop[["foo", "foo"]])
+ assert_equal(:foo, @prop[[:foo, "foo"]])
+ # referent(2)
+ @prop["bar.bar.bar"] = :bar
+ assert_equal(:bar, @prop["bar.bar.bar"])
+ assert_equal(:bar, @prop[["bar", "bar", "bar"]])
+ assert_equal(:bar, @prop[[:bar, "bar", :bar]])
+ end
+
+ def test_to_key_and_deref
+ @prop["foo.foo"] = :foo
+ assert_equal(:foo, @prop["fOo.FoO"])
+ assert_equal(:foo, @prop[[:fOO, :FOO]])
+ assert_equal(:foo, @prop[["FoO", :Foo]])
+ # deref_key negative test
+ assert_raises(ArgumentError) do
+ @prop["baz"] = 1
+ @prop["baz.qux"] = 2
+ end
+ end
+
+ def test_hook_name
+ tag = Object.new
+ tested = false
+ @prop.add_hook("foo.bar") do |key, value|
+ assert_raise(FrozenError) do
+ key << "baz"
+ end
+ tested = true
+ end
+ @prop["foo.bar"] = tag
+ assert(tested)
+ end
+
+ def test_value_hook
+ tag = Object.new
+ tested = false
+ @prop.add_hook("FOO.BAR.BAZ") do |key, value|
+ assert_equal(["Foo", "baR", "baZ"], key)
+ assert_equal(tag, value)
+ tested = true
+ end
+ @prop["Foo.baR.baZ"] = tag
+ assert_equal(tag, @prop["foo.bar.baz"])
+ assert(tested)
+ @prop["foo.bar"] = 1 # unhook the above block
+ assert_equal(1, @prop["foo.bar"])
+ end
+
+ def test_key_hook_no_cascade
+ tag = Object.new
+ tested = 0
+ @prop.add_hook do |key, value|
+ assert(false)
+ end
+ @prop.add_hook(false) do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo") do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar", false) do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar.baz") do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar.baz.qux", false) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop["foo.bar.baz.qux"] = tag
+ assert_equal(tag, @prop["foo.bar.baz.qux"])
+ assert_equal(1, tested)
+ end
+
+ def test_key_hook_cascade
+ tag = Object.new
+ tested = 0
+ @prop.add_hook(true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar.baz", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar.baz.qux", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop["foo.bar.baz.qux"] = tag
+ assert_equal(tag, @prop["foo.bar.baz.qux"])
+ assert_equal(5, tested)
+ end
+
+ def test_keys
+ assert(@prop.keys.empty?)
+ @prop["foo"] = 1
+ @prop["bar"]
+ @prop["BAz"] = 2
+ assert_equal(2, @prop.keys.size)
+ assert(@prop.keys.member?("foo"))
+ assert(@prop.keys.member?("baz"))
+ #
+ assert_nil(@prop["a"])
+ @prop["a.a"] = 1
+ assert_instance_of(::SOAP::Property, @prop["a"])
+ @prop["a.b"] = 1
+ @prop["a.c"] = 1
+ assert_equal(3, @prop["a"].keys.size)
+ assert(@prop["a"].keys.member?("a"))
+ assert(@prop["a"].keys.member?("b"))
+ assert(@prop["a"].keys.member?("c"))
+ end
+
+ def test_lshift
+ assert(@prop.empty?)
+ @prop << 1
+ assert_equal([1], @prop.values)
+ assert_equal(1, @prop["0"])
+ @prop << 1
+ assert_equal([1, 1], @prop.values)
+ assert_equal(1, @prop["1"])
+ @prop << 1
+ assert_equal([1, 1, 1], @prop.values)
+ assert_equal(1, @prop["2"])
+ #
+ @prop["abc.def"] = o = SOAP::Property.new
+ tested = 0
+ o.add_hook do |k, v|
+ tested += 1
+ end
+ @prop["abc.def"] << 1
+ @prop["abc.def"] << 2
+ @prop["abc.def"] << 3
+ @prop["abc.def"] << 4
+ assert_equal(4, tested)
+ end
+
+ def test_lock_each
+ @prop["a.b.c.d.e"] = 1
+ @prop["a.b.d"] = branch = ::SOAP::Property.new
+ @prop["a.b.d.e.f"] = 2
+ @prop.lock
+ assert(@prop.locked?)
+ assert_instance_of(::SOAP::Property, @prop["a"])
+ assert_raises(FrozenError) do
+ @prop["b"]
+ end
+ #
+ @prop["a"].lock
+ assert_raises(FrozenError) do
+ @prop["a"]
+ end
+ assert_instance_of(::SOAP::Property, @prop["a.b"])
+ #
+ @prop["a.b"].lock
+ assert_raises(FrozenError) do
+ @prop["a.b"]
+ end
+ assert_raises(FrozenError) do
+ @prop["a"]
+ end
+ #
+ @prop["a.b.c.d"].lock
+ assert_instance_of(::SOAP::Property, @prop["a.b.c"])
+ assert_raises(FrozenError) do
+ @prop["a.b.c.d"]
+ end
+ assert_instance_of(::SOAP::Property, @prop["a.b.d"])
+ #
+ branch["e"].lock
+ assert_instance_of(::SOAP::Property, @prop["a.b.d"])
+ assert_raises(FrozenError) do
+ @prop["a.b.d.e"]
+ end
+ assert_raises(FrozenError) do
+ branch["e"]
+ end
+ end
+
+ def test_lock_cascade
+ @prop["a.a"] = nil
+ @prop["a.b.c"] = 1
+ @prop["b"] = false
+ @prop.lock(true)
+ assert(@prop.locked?)
+ assert_equal(nil, @prop["a.a"])
+ assert_equal(1, @prop["a.b.c"])
+ assert_equal(false, @prop["b"])
+ assert_raises(FrozenError) do
+ @prop["c"]
+ end
+ assert_raises(FrozenError) do
+ @prop["c"] = 2
+ end
+ assert_raises(FrozenError) do
+ @prop["a.b.R"]
+ end
+ assert_raises(FrozenError) do
+ @prop.add_hook do
+ assert(false)
+ end
+ end
+ assert_raises(FrozenError) do
+ @prop.add_hook("c") do
+ assert(false)
+ end
+ end
+ assert_raises(FrozenError) do
+ @prop.add_hook("a.c") do
+ assert(false)
+ end
+ end
+ assert_nil(@prop["a.a"])
+ @prop["a.a"] = 2
+ assert_equal(2, @prop["a.a"])
+ #
+ @prop.unlock(true)
+ assert_nil(@prop["c"])
+ @prop["c"] = 2
+ assert_equal(2, @prop["c"])
+ @prop["a.d.a.a"] = :foo
+ assert_equal(:foo, @prop["a.d.a.a"])
+ tested = false
+ @prop.add_hook("a.c") do |name, value|
+ assert(true)
+ tested = true
+ end
+ @prop["a.c"] = 3
+ assert(tested)
+ end
+
+ def test_hook_then_lock
+ tested = false
+ @prop.add_hook("a.b.c") do |name, value|
+ assert_equal(["a", "b", "c"], name)
+ tested = true
+ end
+ @prop["a.b"].lock
+ assert(!tested)
+ @prop["a.b.c"] = 5
+ assert(tested)
+ assert_equal(5, @prop["a.b.c"])
+ assert_raises(FrozenError) do
+ @prop["a.b.d"] = 5
+ end
+ end
+
+ def test_lock_unlock_return
+ assert_equal(@prop, @prop.lock)
+ assert_equal(@prop, @prop.unlock)
+ end
+
+ def test_lock_split
+ @prop["a.b.c"] = 1
+ assert_instance_of(::SOAP::Property, @prop["a.b"])
+ @prop["a.b.d"] = branch = ::SOAP::Property.new
+ @prop["a.b.d.e"] = 2
+ assert_equal(branch, @prop["a.b.d"])
+ assert_equal(branch, @prop[:a][:b][:d])
+ @prop.lock(true)
+ # split error 1
+ assert_raises(FrozenError) do
+ @prop["a.b"]
+ end
+ # split error 2
+ assert_raises(FrozenError) do
+ @prop["a"]
+ end
+ @prop["a.b.c"] = 2
+ assert_equal(2, @prop["a.b.c"])
+ # replace error
+ assert_raises(FrozenError) do
+ @prop["a.b.c"] = ::SOAP::Property.new
+ end
+ # override error
+ assert_raises(FrozenError) do
+ @prop["a.b"] = 1
+ end
+ #
+ assert_raises(FrozenError) do
+ @prop["a.b.d"] << 1
+ end
+ assert_raises(FrozenError) do
+ branch << 1
+ end
+ branch.unlock(true)
+ branch << 1
+ branch << 2
+ branch << 3
+ assert_equal(2, @prop["a.b.d.e"])
+ assert_equal(1, @prop["a.b.d.1"])
+ assert_equal(2, @prop["a.b.d.2"])
+ assert_equal(3, @prop["a.b.d.3"])
+ end
+end
+
+
+end
diff --git a/test/soap/test_soapelement.rb b/test/soap/test_soapelement.rb
new file mode 100644
index 0000000000..66e2a836a4
--- /dev/null
+++ b/test/soap/test_soapelement.rb
@@ -0,0 +1,122 @@
+require 'test/unit'
+require 'soap/baseData'
+require 'soap/mapping'
+
+
+module SOAP
+
+
+class TestSOAPElement < Test::Unit::TestCase
+ include SOAP
+
+ def setup
+ # Nothing to do.
+ end
+
+ def teardown
+ # Nothing to do.
+ end
+
+ def d(elename = nil, text = nil)
+ elename ||= n(nil, nil)
+ if text
+ SOAPElement.new(elename, text)
+ else
+ SOAPElement.new(elename) # do not merge.
+ end
+ end
+
+ def n(namespace, name)
+ XSD::QName.new(namespace, name)
+ end
+
+ def test_initialize
+ elename = n(nil, nil)
+ obj = d(elename)
+ assert_equal(elename, obj.elename)
+ assert_equal(LiteralNamespace, obj.encodingstyle)
+ assert_equal({}, obj.extraattr)
+ assert_equal([], obj.precedents)
+ assert_equal(nil, obj.qualified)
+ assert_equal(nil, obj.text)
+ assert(obj.members.empty?)
+
+ obj = d("foo", "text")
+ assert_equal(n(nil, "foo"), obj.elename)
+ assert_equal("text", obj.text)
+ end
+
+ def test_add
+ obj = d()
+ child = d("abc")
+ obj.add(child)
+ assert(obj.key?("abc"))
+ assert_same(child, obj["abc"])
+ assert_same(child, obj.abc)
+ def obj.foo; 1; end
+ child = d("foo")
+ obj.add(child)
+ assert_equal(1, obj.foo)
+ assert_equal(child, obj.var_foo)
+ child = d("_?a?b_")
+ obj.add(child)
+ assert_equal(child, obj.__send__('_?a?b_'))
+ end
+
+ def test_member
+ obj = d()
+ c1 = d("c1")
+ obj.add(c1)
+ c2 = d("c2")
+ obj.add(c2)
+ assert(obj.key?("c1"))
+ assert(obj.key?("c2"))
+ assert_equal(c1, obj["c1"])
+ assert_equal(c2, obj["c2"])
+ c22 = d("c22")
+ obj["c2"] = c22
+ assert(obj.key?("c2"))
+ assert_equal(c22, obj["c2"])
+ assert_equal(["c1", "c2"], obj.members.sort)
+ #
+ k_expect = ["c1", "c2"]
+ v_expect = [c1, c22]
+ obj.each do |k, v|
+ assert(k_expect.include?(k))
+ assert(v_expect.include?(v))
+ k_expect.delete(k)
+ v_expect.delete(v)
+ end
+ assert(k_expect.empty?)
+ assert(v_expect.empty?)
+ end
+
+ def test_to_obj
+ obj = d("root")
+ ct1 = d("ct1", "t1")
+ obj.add(ct1)
+ c2 = d("c2")
+ ct2 = d("ct2", "t2")
+ c2.add(ct2)
+ obj.add(c2)
+ assert_equal({ "ct1" => "t1", "c2" => { "ct2" => "t2" }}, obj.to_obj)
+ #
+ assert_equal(nil, d().to_obj)
+ assert_equal("abc", d(nil, "abc").to_obj)
+ assert_equal(nil, d("abc", nil).to_obj)
+ end
+
+ def test_from_obj
+ source = { "ct1" => "t1", "c2" => { "ct2" => "t2" }}
+ assert_equal(source, SOAPElement.from_obj(source).to_obj)
+ source = { "1" => nil }
+ assert_equal(source, SOAPElement.from_obj(source).to_obj)
+ source = {}
+ assert_equal(nil, SOAPElement.from_obj(source).to_obj) # not {}
+ source = nil
+ assert_equal(nil, SOAPElement.from_obj(source).to_obj)
+ end
+end
+
+
+end
diff --git a/test/soap/test_streamhandler.rb b/test/soap/test_streamhandler.rb
new file mode 100644
index 0000000000..c31254513f
--- /dev/null
+++ b/test/soap/test_streamhandler.rb
@@ -0,0 +1,209 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'webrick'
+require 'webrick/httpproxy'
+require 'logger'
+
+
+module SOAP
+
+
+class TestStreamHandler < Test::Unit::TestCase
+ Port = 17171
+ ProxyPort = 17172
+
+ def setup
+ @logger = Logger.new(STDERR)
+ @logger.level = Logger::Severity::ERROR
+ @url = "http://localhost:#{Port}/"
+ @proxyurl = "http://localhost:#{ProxyPort}/"
+ @server = @proxyserver = @client = nil
+ @server_thread = @proxyserver_thread = nil
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_proxyserver if @proxyserver
+ teardown_server
+ end
+
+ def setup_server
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => @logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__))
+ )
+ @server.mount(
+ '/',
+ WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc).to_proc)
+ )
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_proxyserver
+ @proxyserver = WEBrick::HTTPProxyServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => @logger,
+ :Port => ProxyPort,
+ :AccessLog => []
+ )
+ @proxyserver_thread = start_server_thread(@proxyserver)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, '')
+ @client.add_method("do_server_proc")
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_proxyserver
+ @proxyserver.shutdown
+ @proxyserver_thread.kill
+ @proxyserver_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def do_server_proc(req, res)
+ res['content-type'] = 'text/xml'
+ res.body = <<__EOX__
+<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <n1:do_server_proc xmlns:n1="urn:foo" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <return xsi:nil="true"/>
+ </n1:do_server_proc>
+ </env:Body>
+</env:Envelope>
+__EOX__
+ end
+
+ def parse_req_header(str)
+ if ::SOAP::HTTPStreamHandler::Client.to_s == 'SOAP::NetHttpClient'
+ str = eval(str.split(/\r?\n/)[4][3..-1])
+ end
+ parse_req_header_http_access2(str)
+ end
+
+ def parse_req_header_http_access2(str)
+ headerp = false
+ headers = {}
+ req = nil
+ str.split(/(?:\r?\n)/).each do |line|
+ if headerp and /^$/ =~line
+ headerp = false
+ break
+ end
+ if headerp
+ k, v = line.scan(/^([^:]+):\s*(.*)$/)[0]
+ headers[k.downcase] = v
+ end
+ if /^POST/ =~ line
+ req = line
+ headerp = true
+ end
+ end
+ return req, headers
+ end
+
+ def test_normal
+ str = ""
+ @client.wiredump_dev = str
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_match(%r"POST / HTTP/1.", r)
+ assert(/^text\/xml;/ =~ h["content-type"])
+ end
+
+ def test_uri
+ # initialize client with URI object
+ @client = SOAP::RPC::Driver.new(URI.parse(@url), '')
+ @client.add_method("do_server_proc")
+ # same as test_normal
+ str = ""
+ @client.wiredump_dev = str
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_match(%r"POST / HTTP/1.", r)
+ assert(/^text\/xml;/ =~ h["content-type"])
+ end
+
+ def test_basic_auth
+ unless Object.const_defined?('HTTPAccess2')
+ # soap4r + net/http + basic_auth is not supported.
+ # use http-access2 instead.
+ assert(true)
+ return
+ end
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.basic_auth"] << [@url, "foo", "bar"]
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("Basic Zm9vOmJhcg==", h["authorization"])
+ end
+
+ def test_proxy
+ if Object.const_defined?('HTTPAccess2')
+ backup = HTTPAccess2::Client::NO_PROXY_HOSTS.dup
+ HTTPAccess2::Client::NO_PROXY_HOSTS.clear
+ else
+ backup = SOAP::NetHttpClient::NO_PROXY_HOSTS.dup
+ SOAP::NetHttpClient::NO_PROXY_HOSTS.clear
+ end
+ setup_proxyserver
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.proxy"] = @proxyurl
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_match(%r"POST http://localhost:17171/ HTTP/1.", r)
+ # illegal proxy uri
+ assert_raise(ArgumentError) do
+ @client.options["protocol.http.proxy"] = 'ftp://foo:8080'
+ end
+ ensure
+ if Object.const_defined?('HTTPAccess2')
+ HTTPAccess2::Client::NO_PROXY_HOSTS.replace(backup)
+ else
+ SOAP::NetHttpClient::NO_PROXY_HOSTS.replace(backup)
+ end
+ end
+
+ def test_charset
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.charset"] = "iso-8859-8"
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("text/xml; charset=iso-8859-8", h["content-type"])
+ #
+ str.replace("")
+ @client.options["protocol.http.charset"] = "iso-8859-3"
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("text/xml; charset=iso-8859-3", h["content-type"])
+ end
+end
+
+
+end
diff --git a/test/soap/test_styleuse.rb b/test/soap/test_styleuse.rb
new file mode 100644
index 0000000000..4ea321848d
--- /dev/null
+++ b/test/soap/test_styleuse.rb
@@ -0,0 +1,333 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/rpc/driver'
+
+
+module SOAP
+
+
+class TestStyleUse < Test::Unit::TestCase
+ # rpc driver: obj in(Hash allowed for literal), obj out
+ #
+ # style: not visible from user
+ # rpc: wrapped element
+ # document: unwrappted element
+ #
+ # use:
+ # encoding: a graph (SOAP Data Model)
+ # literal: not a graph (SOAPElement)
+ #
+ # rpc stub: obj in, obj out(Hash is allowed for literal)
+ #
+ # style: not visible from user
+ # rpc: wrapped element
+ # document: unwrappted element
+ #
+ # use:
+ # encoding: a graph (SOAP Data Model)
+ # literal: not a graph (SOAPElement)
+ #
+ # document driver: SOAPElement in, SOAPElement out? [not implemented]
+ #
+ # style: ditto
+ # use: ditto
+ #
+ #
+ # document stub: SOAPElement in, SOAPElement out? [not implemented]
+ #
+ # style: ditto
+ # use: ditto
+ #
+ class GenericServant
+ # method name style: requeststyle_requestuse_responsestyle_responseuse
+
+ # 2 params -> array
+ def rpc_enc_rpc_enc(obj1, obj2)
+ [obj1, [obj1, obj2]]
+ end
+
+ # 2 objs -> array
+ def rpc_lit_rpc_enc(obj1, obj2)
+ [obj2, obj1]
+ end
+
+ # 2 params -> 2 params
+ def rpc_enc_rpc_lit(obj1, obj2)
+ klass = [obj1.class.name, obj2.class.name]
+ [obj2, obj1]
+ end
+
+ # 2 objs -> 2 objs
+ def rpc_lit_rpc_lit(obj1, obj2)
+ [obj1, obj2]
+ end
+
+ # 2 params -> array
+ def doc_enc_doc_enc(obj1, obj2)
+ [obj1, [obj1, obj2]]
+ end
+
+ # 2 objs -> array
+ def doc_lit_doc_enc(obj1, obj2)
+ [obj2, obj1]
+ end
+
+ # 2 params -> 2 hashes
+ def doc_enc_doc_lit(obj1, obj2)
+ klass = [obj1.class.name, obj2.class.name]
+ return {'obj1' => {'klass' => klass}, 'misc' => 'hash does not have an order'},
+ {'obj2' => {'klass' => klass}}
+ end
+
+ # 2 objs -> 2 objs
+ def doc_lit_doc_lit(obj1, obj2)
+ return obj1, obj2
+ end
+ end
+
+ Namespace = "urn:styleuse"
+
+ module Op
+ def self.opt(request_style, request_use, response_style, response_use)
+ {
+ :request_style => request_style,
+ :request_use => request_use,
+ :response_style => response_style,
+ :response_use => response_use
+ }
+ end
+
+ Op_rpc_enc_rpc_enc = [
+ XSD::QName.new(Namespace, 'rpc_enc_rpc_enc'),
+ nil,
+ 'rpc_enc_rpc_enc', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'return', nil]],
+ opt(:rpc, :encoded, :rpc, :encoded)
+ ]
+
+ Op_rpc_lit_rpc_enc = [
+ XSD::QName.new(Namespace, 'rpc_lit_rpc_enc'),
+ nil,
+ 'rpc_lit_rpc_enc', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'return', nil]],
+ opt(:rpc, :literal, :rpc, :encoded)
+ ]
+
+ Op_rpc_enc_rpc_lit = [
+ XSD::QName.new(Namespace, 'rpc_enc_rpc_lit'),
+ nil,
+ 'rpc_enc_rpc_lit', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'ret1', nil],
+ ['out', 'ret2', nil]],
+ opt(:rpc, :encoded, :rpc, :literal)
+ ]
+
+ Op_rpc_lit_rpc_lit = [
+ XSD::QName.new(Namespace, 'rpc_lit_rpc_lit'),
+ nil,
+ 'rpc_lit_rpc_lit', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'ret1', nil],
+ ['out', 'ret2', nil]],
+ opt(:rpc, :literal, :rpc, :literal)
+ ]
+
+ Op_doc_enc_doc_enc = [
+ Namespace + 'doc_enc_doc_enc',
+ 'doc_enc_doc_enc', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :encoded, :document, :encoded)
+ ]
+
+ Op_doc_lit_doc_enc = [
+ Namespace + 'doc_lit_doc_enc',
+ 'doc_lit_doc_enc', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :literal, :document, :encoded)
+ ]
+
+ Op_doc_enc_doc_lit = [
+ Namespace + 'doc_enc_doc_lit',
+ 'doc_enc_doc_lit', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :encoded, :document, :literal)
+ ]
+
+ Op_doc_lit_doc_lit = [
+ Namespace + 'doc_lit_doc_lit',
+ 'doc_lit_doc_lit', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :literal, :document, :literal)
+ ]
+ end
+
+ include Op
+
+ class Server < ::SOAP::RPC::HTTPServer
+ include Op
+
+ def on_init
+ @servant = GenericServant.new
+ add_rpc_operation(@servant, *Op_rpc_enc_rpc_enc)
+ add_rpc_operation(@servant, *Op_rpc_lit_rpc_enc)
+ add_rpc_operation(@servant, *Op_rpc_enc_rpc_lit)
+ add_rpc_operation(@servant, *Op_rpc_lit_rpc_lit)
+ add_document_operation(@servant, *Op_doc_enc_doc_enc)
+ add_document_operation(@servant, *Op_doc_lit_doc_enc)
+ add_document_operation(@servant, *Op_doc_enc_doc_lit)
+ add_document_operation(@servant, *Op_doc_lit_doc_lit)
+ end
+ end
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => Namespace
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/", Namespace)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_rpc_operation(*Op_rpc_enc_rpc_enc)
+ @client.add_rpc_operation(*Op_rpc_lit_rpc_enc)
+ @client.add_rpc_operation(*Op_rpc_enc_rpc_lit)
+ @client.add_rpc_operation(*Op_rpc_lit_rpc_lit)
+ @client.add_document_operation(*Op_doc_enc_doc_enc)
+ @client.add_document_operation(*Op_doc_lit_doc_enc)
+ @client.add_document_operation(*Op_doc_enc_doc_lit)
+ @client.add_document_operation(*Op_doc_lit_doc_lit)
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_rpc_enc_rpc_enc
+ o = "hello"
+ obj1 = o
+ obj2 = [1]
+ ret = @client.rpc_enc_rpc_enc(obj1, obj2)
+ # server returns [obj1, [obj1, obj2]]
+ assert_equal([obj1, [obj1, obj2]], ret)
+ assert_same(ret[0], ret[1][0])
+ end
+
+ S1 = ::Struct.new(:a)
+ S2 = ::Struct.new(:c)
+ def test_rpc_lit_rpc_enc
+ ret1, ret2 = @client.rpc_lit_rpc_enc(S1.new('b'), S2.new('d'))
+ assert_equal('d', ret1.c)
+ assert_equal('b', ret2.a)
+ # Hash is allowed for literal
+ ret1, ret2 = @client.rpc_lit_rpc_enc({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('d', ret1.c)
+ assert_equal('b', ret2.a)
+ # simple value
+ assert_equal(
+ ['1', 'a'],
+ @client.rpc_lit_rpc_enc('a', 1)
+ )
+ end
+
+ def test_rpc_enc_rpc_lit
+ assert_equal(
+ ['1', 'a'],
+ @client.rpc_enc_rpc_lit('a', '1')
+ )
+ end
+
+ def test_rpc_lit_rpc_lit
+ ret1, ret2 = @client.rpc_lit_rpc_lit({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('b', ret1["a"])
+ assert_equal('d', ret2["c"])
+ end
+
+ def test_doc_enc_doc_enc
+ o = "hello"
+ obj1 = o
+ obj2 = [1]
+ ret = @client.rpc_enc_rpc_enc(obj1, obj2)
+ # server returns [obj1, [obj1, obj2]]
+ assert_equal([obj1, [obj1, obj2]], ret)
+ assert_same(ret[0], ret[1][0])
+ end
+
+ def test_doc_lit_doc_enc
+ ret1, ret2 = @client.doc_lit_doc_enc({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('d', ret1.c)
+ assert_equal('b', ret2.a)
+ assert_equal(
+ ['a', '1'],
+ @client.doc_lit_doc_enc(1, 'a')
+ )
+ end
+
+ def test_doc_enc_doc_lit
+ ret1, ret2 = @client.doc_enc_doc_lit('a', 1)
+ # literal Array
+ assert_equal(['String', 'Fixnum'], ret1['obj1']['klass'])
+ # same value
+ assert_equal(ret1['obj1']['klass'], ret2['obj2']['klass'])
+ # not the same object (not encoded)
+ assert_not_same(ret1['obj1']['klass'], ret2['obj2']['klass'])
+ end
+
+ def test_doc_lit_doc_lit
+ ret1, ret2 = @client.doc_lit_doc_lit({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('b', ret1["a"])
+ assert_equal('d', ret2["c"])
+ end
+end
+
+
+end
diff --git a/test/soap/wsdlDriver/README.txt b/test/soap/wsdlDriver/README.txt
new file mode 100644
index 0000000000..b4d45a0486
--- /dev/null
+++ b/test/soap/wsdlDriver/README.txt
@@ -0,0 +1,2 @@
+echo_version.rb is generated by wsdl2ruby.rb;
+% wsdl2ruby.rb --wsdl simpletype.wsdl --classdef --force
diff --git a/test/soap/wsdlDriver/calc.wsdl b/test/soap/wsdlDriver/calc.wsdl
new file mode 100644
index 0000000000..694a01e87e
--- /dev/null
+++ b/test/soap/wsdlDriver/calc.wsdl
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--generated by GLUE Standard 4.0.1 on Wed Mar 09 10:20:07 GMT-08:00
+2005-->
+<wsdl:definitions name='Calculator'
+targetNamespace='http://www.themindelectric.com/wsdl/Calculator/'
+ xmlns:tns='http://www.themindelectric.com/wsdl/Calculator/'
+ xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
+ xmlns:http='http://schemas.xmlsoap.org/wsdl/http/'
+ xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/'
+ xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+ xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
+ xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
+ xmlns:tme='http://www.themindelectric.com/'>
+ <wsdl:message name='add0In'>
+ <wsdl:part name='x' type='xsd:float'/>
+ <wsdl:part name='y' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='add0Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='divide1In'>
+ <wsdl:part name='numerator' type='xsd:float'/>
+ <wsdl:part name='denominator' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='divide1Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='multiply2In'>
+ <wsdl:part name='x' type='xsd:float'/>
+ <wsdl:part name='y' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='multiply2Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='subtract3In'>
+ <wsdl:part name='x' type='xsd:float'/>
+ <wsdl:part name='y' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='subtract3Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:portType name='ICalculator'>
+ <wsdl:operation name='add' parameterOrder='x y'>
+ <wsdl:input name='add0In' message='tns:add0In'/>
+ <wsdl:output name='add0Out' message='tns:add0Out'/>
+ </wsdl:operation>
+ <wsdl:operation name='divide' parameterOrder='numerator
+denominator'>
+ <wsdl:input name='divide1In' message='tns:divide1In'/>
+ <wsdl:output name='divide1Out' message='tns:divide1Out'/>
+ </wsdl:operation>
+ <wsdl:operation name='multiply' parameterOrder='x y'>
+ <wsdl:input name='multiply2In' message='tns:multiply2In'/>
+ <wsdl:output name='multiply2Out'
+message='tns:multiply2Out'/>
+ </wsdl:operation>
+ <wsdl:operation name='subtract' parameterOrder='x y'>
+ <wsdl:input name='subtract3In' message='tns:subtract3In'/>
+ <wsdl:output name='subtract3Out'
+message='tns:subtract3Out'/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name='ICalculator' type='tns:ICalculator'>
+ <soap:binding style='rpc'
+transport='http://schemas.xmlsoap.org/soap/http'/>
+ <wsdl:operation name='add'>
+ <soap:operation soapAction='add' style='rpc'/>
+ <wsdl:input name='add0In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='add0Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name='divide'>
+ <soap:operation soapAction='divide' style='rpc'/>
+ <wsdl:input name='divide1In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='divide1Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name='multiply'>
+ <soap:operation soapAction='multiply' style='rpc'/>
+ <wsdl:input name='multiply2In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='multiply2Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name='subtract'>
+ <soap:operation soapAction='subtract' style='rpc'/>
+ <wsdl:input name='subtract3In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='subtract3Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name='Calculator'>
+ <wsdl:documentation>calculator service</wsdl:documentation>
+ <wsdl:port name='ICalculator' binding='tns:ICalculator'>
+ <soap:address
+location='http://ukulele:8080/calcapp/services/calculator'/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/test/soap/wsdlDriver/document.wsdl b/test/soap/wsdlDriver/document.wsdl
new file mode 100644
index 0000000000..5e9e74b9df
--- /dev/null
+++ b/test/soap/wsdlDriver/document.wsdl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="submit_service"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="urn:example.com:document"
+ targetNamespace="urn:example.com:document"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema targetNamespace="urn:example.com:document">
+ <xsd:element name="ruby">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="1" name="myversion" type="tns:myversion"/>
+ <xsd:element minOccurs="0" maxOccurs="1" name="date" type="xsd:dateTime"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="myversion">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="1.6"/>
+ <xsd:enumeration value="1.8"/>
+ <xsd:enumeration value="1.9"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:schema>
+ </types>
+
+ <message name="submit_msg">
+ <part name="parameters" element="tns:ruby"/>
+ </message>
+
+ <portType name="submit_port_type">
+ <operation name="submit">
+ <input message="tns:submit_msg"/>
+ <output message="tns:submit_msg"/>
+ </operation>
+ </portType>
+
+ <binding name="submit_binding" type="tns:submit_port_type">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="submit">
+ <soap:operation soapAction="urn:example.com:document#submit" style="document"/>
+ <input><soap:body use="literal"/></input>
+ <output><soap:body use="literal"/></output>
+ </operation>
+ </binding>
+
+ <service name="submit_service">
+ <port name="submit_port" binding="tns:submit_binding">
+ <soap:address location="http://localhost:10080"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/soap/wsdlDriver/echo_version.rb b/test/soap/wsdlDriver/echo_version.rb
new file mode 100644
index 0000000000..7d76fb7587
--- /dev/null
+++ b/test/soap/wsdlDriver/echo_version.rb
@@ -0,0 +1,20 @@
+# urn:example.com:simpletype-rpc-type
+class Version_struct
+ @@schema_type = "version_struct"
+ @@schema_ns = "urn:example.com:simpletype-rpc-type"
+
+ attr_accessor :version
+ attr_accessor :msg
+
+ def initialize(version = nil, msg = nil)
+ @version = version
+ @msg = msg
+ end
+end
+
+# urn:example.com:simpletype-rpc-type
+module Versions
+ C_16 = "1.6"
+ C_18 = "1.8"
+ C_19 = "1.9"
+end
diff --git a/test/soap/wsdlDriver/simpletype.wsdl b/test/soap/wsdlDriver/simpletype.wsdl
new file mode 100644
index 0000000000..6781dda552
--- /dev/null
+++ b/test/soap/wsdlDriver/simpletype.wsdl
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="echo_version"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="urn:example.com:simpletype-rpc"
+ xmlns:txd="urn:example.com:simpletype-rpc-type"
+ targetNamespace="urn:example.com:simpletype-rpc"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema targetNamespace="urn:example.com:simpletype-rpc-type">
+ <xsd:complexType name="version_struct">
+ <xsd:all>
+ <xsd:element name="myversion" type="txd:myversions" />
+ <xsd:element name="msg" type="xsd:string" />
+ </xsd:all>
+ </xsd:complexType>
+
+ <xsd:simpleType name="myversions">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="1.6"/>
+ <xsd:enumeration value="1.8"/>
+ <xsd:enumeration value="1.9"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:schema>
+ </types>
+
+ <message name="msg_version">
+ <part name="myversion" type="txd:myversions"/>
+ </message>
+
+ <message name="msg_version_struct">
+ <part name="return" type="txd:version_struct"/>
+ </message>
+
+ <portType name="echo_version_port_type">
+ <operation name="echo_version">
+ <input message="tns:msg_version"/>
+ <output message="tns:msg_version_struct"/>
+ </operation>
+ </portType>
+
+ <binding name="echo_version_binding" type="tns:echo_version_port_type">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="echo_version">
+ <soap:operation soapAction="urn:example.com:simpletype-rpc"/>
+ <input>
+ <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="echo_version_service">
+ <port name="echo_version_port" binding="tns:echo_version_binding">
+ <soap:address location="http://localhost:10080"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/soap/wsdlDriver/test_calc.rb b/test/soap/wsdlDriver/test_calc.rb
new file mode 100644
index 0000000000..d031f663a3
--- /dev/null
+++ b/test/soap/wsdlDriver/test_calc.rb
@@ -0,0 +1,100 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestCalc < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::HTTPServer
+ def on_init
+ add_method(self, 'add', 'x', 'y')
+ end
+
+ def add(x, y)
+ x.to_f + y.to_f
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => 'http://www.fred.com'
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @wsdl = File.join(DIR, 'calc.wsdl')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream if @client
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_rpc_driver
+ @client = ::SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = true
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ @client.generate_explicit_type = false
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ end
+
+ def test_old_driver
+ silent do
+ @client = ::SOAP::WSDLDriverFactory.new(@wsdl).create_driver
+ end
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = true
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ @client.generate_explicit_type = false
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ end
+
+ def silent
+ back = $VERBOSE
+ $VERBOSE = nil
+ begin
+ yield
+ ensure
+ $VERBOSE = back
+ end
+ end
+end
+
+
+end
diff --git a/test/soap/wsdlDriver/test_document.rb b/test/soap/wsdlDriver/test_document.rb
new file mode 100644
index 0000000000..634b827aae
--- /dev/null
+++ b/test/soap/wsdlDriver/test_document.rb
@@ -0,0 +1,78 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestDocument < Test::Unit::TestCase
+ Namespace = 'urn:example.com:document'
+
+ class Server < ::SOAP::RPC::StandaloneServer
+ def on_init
+ add_document_method(self, 'urn:example.com:document#submit', 'submit', XSD::QName.new(Namespace, 'ruby'), XSD::QName.new(Namespace, 'ruby'))
+ end
+
+ def submit(ruby)
+ ruby
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new('Test', Namespace, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'document.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.wiredump_dev = STDOUT if $DEBUG
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_document
+ msg = {'myversion' => "1.9", 'date' => "2004-01-01T00:00:00Z"}
+ reply_msg = @client.submit(msg)
+ assert_equal('1.9', reply_msg.myversion)
+ assert_equal('1.9', reply_msg['myversion'])
+ assert_equal('2004-01-01T00:00:00Z', reply_msg.date)
+ assert_equal('2004-01-01T00:00:00Z', reply_msg['date'])
+ end
+end
+
+
+end
diff --git a/test/soap/wsdlDriver/test_simpletype.rb b/test/soap/wsdlDriver/test_simpletype.rb
new file mode 100644
index 0000000000..76b3a32df7
--- /dev/null
+++ b/test/soap/wsdlDriver/test_simpletype.rb
@@ -0,0 +1,87 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestSimpleType < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::HTTPServer
+ def on_init
+ add_method(self, 'echo_version', 'version')
+ end
+
+ def echo_version(version)
+ # "2.0" is out of range.
+ Version_struct.new(version || "2.0", 'checked')
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ require File.join(DIR, 'echo_version')
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => "urn:example.com:simpletype-rpc"
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'simpletype.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = false
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_ping
+ result = @client.echo_version("1.9")
+ assert_equal("1.9", result.version)
+ assert_equal("checked", result.msg)
+ assert_raise(XSD::ValueSpaceError) do
+ @client.echo_version("2.0")
+ end
+ assert_raise(XSD::ValueSpaceError) do
+ @client.echo_version(nil) # nil => "2.0" => out of range
+ end
+ end
+end
+
+
+end
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index 90f1037db8..fc01467f16 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -19,7 +19,7 @@ class TestBasicSocket < Test::Unit::TestCase
n = s.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
assert_equal([0].pack("i"), n)
val = Object.new
- class << val; self end.send(:define_method, :to_int) {
+ class << val; self end.__send__(:define_method, :to_int) {
s.close
Socket::SO_TYPE
}
@@ -29,31 +29,29 @@ class TestBasicSocket < Test::Unit::TestCase
end
end
- def test_setsockopt
+ def test_setsockopt # [ruby-dev:25039]
s = nil
linger = [0, 0].pack("ii")
val = Object.new
- class << val; self end.send(:define_method, :to_str) {
+ class << val; self end.__send__(:define_method, :to_str) {
s.close
linger
}
- inet_stream do |sock|
- s = sock
+ inet_stream do |s|
assert_equal(0, s.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, linger))
- assert_raise(IOError, "[ruby-dev:25039]") {
+ assert_raise(IOError) {
s.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, val)
}
end
val = Object.new
- class << val; self end.send(:define_method, :to_int) {
+ class << val; self end.__send__(:define_method, :to_int) {
s.close
Socket::SO_LINGER
}
- inet_stream do |sock|
- s = sock
+ inet_stream do |s|
assert_raise(IOError) {
s.setsockopt(Socket::SOL_SOCKET, val, linger)
}
@@ -63,12 +61,11 @@ class TestBasicSocket < Test::Unit::TestCase
def test_listen
s = nil
log = Object.new
- class << log; self end.send(:define_method, :to_int) {
+ class << log; self end.__send__(:define_method, :to_int) {
s.close
2
}
- inet_stream do |sock|
- s = sock
+ inet_stream do |s|
assert_raise(IOError) {
s.listen(log)
}
@@ -82,19 +79,5 @@ class TestSocket < Test::Unit::TestCase
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(sockaddr_in) }
sockaddr_un = Socket.sockaddr_un("/tmp/s")
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) }
- end if Socket.respond_to?(:sockaddr_un)
-
- def test_sysaccept
- serv = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
- serv.bind(Socket.sockaddr_in(0, "127.0.0.1"))
- serv.listen 5
- c = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
- c.connect(serv.getsockname)
- fd, peeraddr = serv.sysaccept
- assert_equal(c.getsockname, peeraddr)
- ensure
- serv.close if serv
- c.close if c
- IO.for_fd(fd).close if fd
end
-end if defined?(Socket)
+end if defined?(Socket) && Socket.respond_to?(:sockaddr_un)
diff --git a/test/socket/test_tcp.rb b/test/socket/test_tcp.rb
deleted file mode 100644
index aa07d96cf0..0000000000
--- a/test/socket/test_tcp.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require "socket"
- require "test/unit"
-rescue LoadError
-end
-
-
-class TestTCPSocket < Test::Unit::TestCase
- def test_recvfrom
-assert false, "TODO: doesn't work on mswin32/64" if /mswin/ =~ RUBY_PLATFORM
- c = s = nil
- svr = TCPServer.new("localhost", 0)
- th = Thread.new {
- c = svr.accept
- Thread.pass
- ObjectSpace.each_object(String) {|s|
- s.replace "a" if s.length == 0x10000 and !s.frozen?
- }
- c.print("x"*0x1000)
- }
- addr = svr.addr
- sock = TCPSocket.open(addr[2], addr[1])
- assert_raise(RuntimeError, SocketError, "[ruby-dev:24705]") {
- sock.recvfrom(0x10000)
- }
- ensure
- th.join
- end
-end if defined?(TCPSocket)
diff --git a/test/socket/test_udp.rb b/test/socket/test_udp.rb
deleted file mode 100644
index d515ad4dbb..0000000000
--- a/test/socket/test_udp.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-begin
- require "socket"
- require "test/unit"
-rescue LoadError
-end
-
-
-class TestUDPSocket < Test::Unit::TestCase
- def test_connect
- s = UDPSocket.new
- host = Object.new
- class << host; self end.send(:define_method, :to_str) {
- s.close
- "127.0.0.1"
- }
- assert_raise(IOError, "[ruby-dev:25045]") {
- s.connect(host, 1)
- }
- end
-
- def test_bind
- s = UDPSocket.new
- host = Object.new
- class << host; self end.send(:define_method, :to_str) {
- s.close
- "127.0.0.1"
- }
- assert_raise(IOError, "[ruby-dev:25057]") {
- s.bind(host, 2000)
- }
- end
-end if defined?(UDPSocket)
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 3bd3d94c9d..14ddd6a4b6 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -118,6 +118,7 @@ class TestUNIXSocket < Test::Unit::TestCase
def test_nul
assert_raise(ArgumentError) { Socket.sockaddr_un("a\0b") }
+ assert_raise(ArgumentError) { UNIXServer.new("a\0b") }
end
def test_dgram_pair
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index f0031a5d07..de15ab5508 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -15,29 +15,29 @@ class TestStringIO < Test::Unit::TestCase
include TestEOF::Seek
- def test_truncate
+ def test_truncate # [ruby-dev:24190]
io = StringIO.new("")
io.puts "abc"
io.truncate(0)
io.puts "def"
- assert_equal("\0\0\0\0def\n", io.string, "[ruby-dev:24190]")
+ assert_equal("\0\0\0\0def\n", io.string)
end
- def test_seek_beyond_eof
+ def test_seek_beyond_eof # [ruby-dev:24194]
io = StringIO.new
n = 100
io.seek(n)
io.print "last"
- assert_equal("\0" * n + "last", io.string, "[ruby-dev:24194]")
+ assert_equal("\0" * n + "last", io.string)
end
- def test_overwrite
+ def test_overwrite # [ruby-core:03836]
stringio = StringIO.new
responses = ['', 'just another ruby', 'hacker']
responses.each do |resp|
stringio.puts(resp)
stringio.rewind
end
- assert_equal("hacker\nother ruby\n", stringio.string, "[ruby-core:3836]")
+ assert_equal("hacker\nother ruby\n", stringio.string)
end
end
diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb
index c918368435..75e96c0293 100644
--- a/test/strscan/test_stringscanner.rb
+++ b/test/strscan/test_stringscanner.rb
@@ -247,6 +247,19 @@ class TestStringScanner < Test::Unit::TestCase
s = StringScanner.new("")
assert_equal "", s.scan(//)
assert_equal "", s.scan(//)
+
+ # [ruby-dev:29914]
+ %w( NONE EUC SJIS UTF8 ).each do |kcode|
+ begin
+ $KCODE = kcode
+ assert_equal "a", StringScanner.new("a:b").scan(/[^\x01\:]+/n)
+ assert_equal "a", StringScanner.new("a:b").scan(/[^\x01\:]+/e)
+ assert_equal "a", StringScanner.new("a:b").scan(/[^\x01\:]+/s)
+ assert_equal "a", StringScanner.new("a:b").scan(/[^\x01\:]+/u)
+ ensure
+ $KCODE = 'NONE'
+ end
+ end
end
def test_skip
@@ -288,9 +301,15 @@ class TestStringScanner < Test::Unit::TestCase
assert_equal true, s.getch.tainted?
assert_nil s.getch
- s = StringScanner.new("\244\242".force_encoding("euc-jp"))
- assert_equal "\244\242", s.getch
- assert_nil s.getch
+ kc_backup = $KCODE
+ begin
+ $KCODE = 'EUC'
+ s = StringScanner.new("\244\242")
+ assert_equal "\244\242", s.getch
+ assert_nil s.getch
+ ensure
+ $KCODE = kc_backup
+ end
s = StringScanner.new('test')
s.scan(/te/)
@@ -316,10 +335,16 @@ class TestStringScanner < Test::Unit::TestCase
assert_equal true, s.get_byte.tainted?
assert_nil s.get_byte
- s = StringScanner.new("\244\242".force_encoding("euc-jp"))
- assert_equal "\244", s.get_byte
- assert_equal "\242", s.get_byte
- assert_nil s.get_byte
+ kc_backup = $KCODE
+ begin
+ $KCODE = 'EUC'
+ s = StringScanner.new("\244\242")
+ assert_equal "\244", s.get_byte
+ assert_equal "\242", s.get_byte
+ assert_nil s.get_byte
+ ensure
+ $KCODE = kc_backup
+ end
s = StringScanner.new('test')
s.scan(/te/)
@@ -412,9 +437,16 @@ class TestStringScanner < Test::Unit::TestCase
assert_nil s[0]
- s = StringScanner.new("\244\242".force_encoding("euc-jp"))
- s.getch
- assert_equal "\244\242", s[0]
+ kc_backup = $KCODE
+ begin
+ $KCODE = 'EUC'
+ s = StringScanner.new("\244\242")
+ s.getch
+ assert_equal "\244\242", s[0]
+ ensure
+ $KCODE = kc_backup
+ end
+
str = 'test'
str.taint
diff --git a/test/test_generator.rb b/test/test_generator.rb
deleted file mode 100644
index 604ce93caa..0000000000
--- a/test/test_generator.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest__END__part(target)
diff --git a/test/test_ipaddr.rb b/test/test_ipaddr.rb
deleted file mode 100644
index 604ce93caa..0000000000
--- a/test/test_ipaddr.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest__END__part(target)
diff --git a/test/test_pp.rb b/test/test_pp.rb
deleted file mode 100644
index 981fedd98f..0000000000
--- a/test/test_pp.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest(target)
diff --git a/test/test_prettyprint.rb b/test/test_prettyprint.rb
deleted file mode 100644
index 981fedd98f..0000000000
--- a/test/test_prettyprint.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest(target)
diff --git a/test/test_set.rb b/test/test_set.rb
deleted file mode 100644
index 604ce93caa..0000000000
--- a/test/test_set.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest__END__part(target)
diff --git a/test/test_shellwords.rb b/test/test_shellwords.rb
deleted file mode 100644
index ddb2d870b0..0000000000
--- a/test/test_shellwords.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'test/unit'
-require 'shellwords'
-
-class TestShellwords < Test::Unit::TestCase
-
- include Shellwords
-
- def setup
- @not_string = Class.new
- @cmd = "ruby my_prog.rb | less"
- end
-
-
- def test_string
- assert_instance_of(Array, shellwords(@cmd))
- assert_equal(4, shellwords(@cmd).length)
- end
-
- def test_unmatched_double_quote
- bad_cmd = 'one two "three'
- assert_raises ArgumentError do
- shellwords(bad_cmd)
- end
- end
-
- def test_unmatched_single_quote
- bad_cmd = "one two 'three"
- assert_raises ArgumentError do
- shellwords(bad_cmd)
- end
- end
-
- def test_unmatched_quotes
- bad_cmd = "one '"'"''""'""
- assert_raises ArgumentError do
- shellwords(bad_cmd)
- end
- end
-end
diff --git a/test/test_time.rb b/test/test_time.rb
deleted file mode 100644
index 981fedd98f..0000000000
--- a/test/test_time.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest(target)
diff --git a/test/test_tsort.rb b/test/test_tsort.rb
deleted file mode 100644
index 981fedd98f..0000000000
--- a/test/test_tsort.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'pathname'
-require Pathname.new(__FILE__).dirname.join('inlinetest.rb')
-target = __FILE__[/test_(.*\.rb)$/, 1]
-InlineTest.loadtest(target)
diff --git a/test/testunit/collector/test_dir.rb b/test/testunit/collector/test_dir.rb
index 3e5546943c..2de802c5e3 100644
--- a/test/testunit/collector/test_dir.rb
+++ b/test/testunit/collector/test_dir.rb
@@ -165,7 +165,7 @@ module Test
return false if(@required.include?(file))
begin
e = find(file)
- rescue Errno::ENOENT => ex
+ rescue Errno::ENOENT => e
if(/\.rb\Z/ =~ file)
raise LoadError, file
end
@@ -230,10 +230,10 @@ module Test
end
end
assert_equal('/', fs.pwd)
- assert_raise(Errno::ENOENT) do
+ assert_raises(Errno::ENOENT) do
fs.chdir('bogus')
end
- assert_raise(Errno::ENOTDIR) do
+ assert_raises(Errno::ENOTDIR) do
fs.chdir('a')
end
fs.chdir('b')
@@ -265,10 +265,10 @@ module Test
assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('.').sort)
assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('b/..').sort)
assert_equal(['.', '..', 'c', 'd'], fs.entries('b').sort)
- assert_raise(Errno::ENOENT) do
+ assert_raises(Errno::ENOENT) do
fs.entries('z')
end
- assert_raise(Errno::ENOTDIR) do
+ assert_raises(Errno::ENOTDIR) do
fs.entries('a')
end
fs.chdir('f')
@@ -292,7 +292,7 @@ module Test
end
assert_equal([], c)
- assert_raise(LoadError) do
+ assert_raises(LoadError) do
fs.require('bogus')
end
@@ -370,18 +370,13 @@ module Test
end
def test_collect_file
- expected = [@t1.suite]
- subsuites = []
- @c.collect_file('test_1.rb', subsuites, @c.find_test_cases)
- assert_equal(expected, subsuites)
+ expected = TestSuite.new('test_1.rb')
+ expected << @t1.suite
+ assert_equal(expected, @c.collect('test_1.rb'))
- expected = [@t4.suite]
- subsuites = []
- @c.collect_file('t4.rb', subsuites, @c.find_test_cases)
- assert_equal(expected, subsuites)
- assert_raise(LoadError) do
- @c.collect_file('tloaderr.rb', [], [])
- end
+ expected = TestSuite.new('t4.rb')
+ expected << @t4.suite
+ assert_equal(expected, @c.collect('t4.rb'))
end
def test_nil_pattern
@@ -394,7 +389,7 @@ module Test
def test_filtering
expected = TestSuite.new('.')
expected << @t1.suite
- @c.filter = proc{|t| t.method_name == :test_1a || t.method_name == :test_1b}
+ @c.filter = proc{|t| t.method_name == 'test_1a' || t.method_name == 'test_1b'}
assert_equal(expected, @c.collect)
end
diff --git a/test/testunit/collector/test_objectspace.rb b/test/testunit/collector/test_objectspace.rb
index 841d35452e..a1532ff3e6 100644
--- a/test/testunit/collector/test_objectspace.rb
+++ b/test/testunit/collector/test_objectspace.rb
@@ -43,8 +43,8 @@ module Test
def full_suite(name=ObjectSpace::NAME)
expected = TestSuite.new(name)
- expected << (TestSuite.new(@tc1.name) << @tc1.new(:test_1) << @tc1.new(:test_2))
- expected << (TestSuite.new(@tc2.name) << @tc2.new(:test_0))
+ expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1') << @tc1.new('test_2'))
+ expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
end
def empty_suite
@@ -81,15 +81,15 @@ module Test
assert_equal(full_suite, @c.collect)
expected = TestSuite.new(ObjectSpace::NAME)
- expected << (TestSuite.new(@tc1.name) << @tc1.new(:test_1))
- expected << (TestSuite.new(@tc2.name) << @tc2.new(:test_0))
- @c.filter = proc{|test| [:test_1, :test_0].include?(test.method_name)}
+ expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1'))
+ expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
+ @c.filter = proc{|test| ['test_1', 'test_0'].include?(test.method_name)}
assert_equal(expected, @c.collect)
expected = TestSuite.new(ObjectSpace::NAME)
- expected << (TestSuite.new(@tc1.name) << @tc1.new(:test_1))
- expected << (TestSuite.new(@tc2.name) << @tc2.new(:test_0))
- @c.filter = [proc{|t| t.method_name == :test_1 ? true : nil}, proc{|t| t.method_name == :test_0 ? true : nil}, proc{false}]
+ expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1'))
+ expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
+ @c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil}, proc{|t| t.method_name == 'test_0' ? true : nil}, proc{false}]
assert_equal(expected, @c.collect)
end
end
diff --git a/test/testunit/runit/test_assert.rb b/test/testunit/runit/test_assert.rb
new file mode 100644
index 0000000000..a3e62b2b2d
--- /dev/null
+++ b/test/testunit/runit/test_assert.rb
@@ -0,0 +1,402 @@
+# Author:: Masaki Suketa.
+# Adapted by:: Nathaniel Talbott.
+# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
+# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'rubyunit'
+
+module RUNIT
+ class TargetAssert
+ include RUNIT::Assert
+ end
+
+ class TestAssert < RUNIT::TestCase
+ def setup
+ @assert = TargetAssert.new
+ @e = nil
+ end
+
+ def test_assert
+ sub_test_assert_pass(true)
+ sub_test_assert_pass(TRUE)
+ sub_test_assert_failure(false)
+ sub_test_assert_failure(FALSE)
+ sub_test_assert_failure(nil)
+ sub_test_assert_pass("")
+ sub_test_assert_pass("ok")
+ sub_test_assert_pass(0)
+ sub_test_assert_pass(1)
+ end
+
+ def test_assert_with_2_argument
+ assert_no_exception {
+ assert(true, "3")
+ }
+ assert_no_exception {
+ assert(true)
+ }
+ end
+
+ def test_assert_equal_float_0_1
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(1.4, 1.35, 0.1)
+ }
+ sub_assert_pass(assert_proc)
+ end
+
+ def test_assert_equal_float_0_5
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(1.4, 1.34, 0.5)
+ }
+ sub_assert_pass(assert_proc)
+ end
+
+ def test_assert_equal_float_0
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(1.4, 1.4, 0)
+ }
+ sub_assert_pass(assert_proc)
+ end
+
+ def test_assert_equal_float_0_raise
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(1.4, 1.34, 0)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_equal_float_0_01
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(1.4, 1.35, 0.01)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_equal_float_0_001
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(Math.sqrt(2), 1.414, 0.001)
+ }
+ sub_assert_pass(assert_proc)
+ end
+
+ def test_assert_equal_float_minus_1_0
+ assert_proc = Proc.new {
+ @assert.assert_equal_float(1.4, 1.35, -1.0)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_fail
+ except = nil
+ begin
+ @assert.assert_fail("failure")
+ rescue Exception
+ except = $!
+ end
+ assert_not_nil(except)
+ end
+
+ def sub_test_assert_pass(obj)
+ assert_proc = Proc.new {
+ @assert.assert(obj)
+ }
+ sub_assert_pass(assert_proc)
+ end
+
+ def sub_test_assert_failure(obj)
+ assert_proc = Proc.new {
+ @assert.assert(obj)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_equal
+ assert_proc = Proc.new {
+ @assert.assert_equal(2, 2)
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_equal(2, 3)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_nil
+ obj = nil
+ assert_proc = Proc.new {
+ @assert.assert_nil(obj)
+ }
+ sub_assert_pass(assert_proc)
+ obj = 'string'
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_not_nil
+ obj = 'string'
+ assert_proc = Proc.new {
+ @assert.assert_not_nil(obj)
+ }
+ sub_assert_pass(assert_proc)
+
+ obj = nil
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_operator
+ assert_proc = Proc.new {
+ @assert.assert_operator(2, :<, 3)
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_operator(2, :>, 3)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_respond_to
+ sub_test_assert_respond_to('string', 'sub', 'foo')
+ sub_test_assert_respond_to('string', :sub, :foo)
+ end
+
+ def sub_test_assert_respond_to(obj, msg, dummy_msg)
+ assert_proc = Proc.new {
+ @assert.assert_respond_to(msg, obj)
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_respond_to(dummy_msg, obj)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_send
+ assert_proc = Proc.new {
+ ary = []
+ @assert.assert_send ary, :empty?
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ ary = [2,3]
+ @assert.assert_send ary, :empty?
+ }
+ sub_assert_raise_fail(assert_proc)
+ assert_proc = Proc.new {
+ str = "abc"
+ @assert.assert_send str, :sub!, "z", "y"
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_kind_of
+ assert_proc = Proc.new {
+ @assert.assert_kind_of(String, "string")
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_kind_of(Regexp, "string")
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_instance_of
+ assert_proc = Proc.new {
+ @assert.assert_instance_of(String, "string")
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_instance_of(Object, "string")
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_match
+ assert_proc = Proc.new{
+ @assert.assert_match('foostring', /foo/)
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_match('barstring', /foo/)
+ }
+ sub_assert_raise_fail(assert_proc)
+ match = @assert.assert_match('foostring', /foo/)
+ assert_instance_of(MatchData, match)
+ assert_equal('foo', match[0])
+ end
+
+ def test_assert_matches
+ assert_proc = Proc.new{
+ @assert.assert_matches('foostring', /foo/)
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_matches('barstring', /foo/)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_not_match
+ assert_proc = Proc.new{
+ @assert.assert_not_match('barstring', /foo/)
+ }
+ sub_assert_pass(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_not_match('foostring', /foo/)
+ }
+ sub_assert_raise_fail(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_not_match('foobarbaz', /ba.+/)
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_same
+ flag = false
+ e = "foo"
+ a = e
+ assert_proc = Proc.new {@assert.assert_same(e, a)}
+ sub_assert_pass(assert_proc)
+
+ a = "foo"
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def test_assert_exception
+ assert_proc = Proc.new{
+ @assert.assert_exception(IOError) {
+ raise IOError
+ }
+ }
+ sub_assert_pass(assert_proc)
+
+ assert_proc = Proc.new{
+ @assert.assert_exception(StandardError) {
+ raise IOError
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+
+ assert_proc = Proc.new{
+ @assert.assert_exception(IOError, "Exception") {
+ raise StandardError
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+
+ assert_proc = Proc.new {
+ @assert.assert_exception(StandardError) {
+ "No Exception raised in this block"
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+
+ assert_proc = Proc.new {
+ @assert.assert_exception(StandardError) {
+ exit(33)
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+
+ t = @assert.assert_exception(IOError) {
+ raise IOError
+ }
+ assert_instance_of(IOError, t)
+ t = @assert.assert_exception(NameError) {
+ non_existent_method
+ }
+ assert_instance_of(NameError, t)
+ t = @assert.assert_exception(SystemExit) {
+ exit(33)
+ }
+ assert_instance_of(SystemExit, t)
+ end
+
+ def test_assert_no_exception
+ assert_proc = Proc.new{
+ @assert.assert_no_exception(IOError, ArgumentError) {
+ "No Exception raised in this block"
+ }
+ }
+ sub_assert_pass(assert_proc)
+
+ assert_proc = Proc.new{
+ @assert.assert_no_exception(IOError, ArgumentError) {
+ raise StandardError, "Standard Error raised"
+ }
+ }
+ sub_assert_raise_error(assert_proc)
+
+ assert_proc = Proc.new{
+ @assert.assert_no_exception(IOError, ArgumentError) {
+ raise ArgumentError, "Bad Argument"
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+
+ assert_proc = Proc.new{
+ @assert.assert_no_exception {
+ raise ArgumentError, "Bad Argument"
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+
+ assert_proc = Proc.new{
+ @assert.assert_no_exception {
+ raise NameError, "Bad Name"
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+ assert_proc = Proc.new {
+ @assert.assert_no_exception {
+ raise NoMemoryError
+ }
+ }
+ sub_assert_raise_fail(assert_proc)
+ end
+
+ def sub_assert_pass(p)
+ flag = false
+ err = nil
+ begin
+ p.call
+ flag = true
+ rescue
+ err = $!
+ flag = false
+ end
+ assert(flag, err.to_s)
+ end
+
+ def sub_assert_raise_fail(p)
+ flag = false
+ err = nil
+ begin
+ p.call
+ flag = false
+ rescue RUNIT::AssertionFailedError
+ flag = true
+ err = $!
+ rescue Exception
+ flag = false
+ err = $!
+ end
+ assert(flag, err.to_s)
+ end
+
+ def sub_assert_raise_error(p)
+ flag = false
+ err = nil
+ begin
+ p.call
+ flag = false
+ rescue RUNIT::AssertionFailedError
+ flag = false
+ err = $!
+ rescue Exception
+ flag = true
+ err = $!
+ end
+ assert(flag, err.to_s)
+ end
+ end
+end
diff --git a/test/testunit/runit/test_testcase.rb b/test/testunit/runit/test_testcase.rb
new file mode 100644
index 0000000000..f57e0386e3
--- /dev/null
+++ b/test/testunit/runit/test_testcase.rb
@@ -0,0 +1,91 @@
+# Author:: Masaki Suketa.
+# Adapted by:: Nathaniel Talbott.
+# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
+# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'rubyunit'
+
+module RUNIT
+ class DummyError < StandardError
+ end
+
+ class TestTestCase < RUNIT::TestCase
+ def setup
+ @dummy_testcase = Class.new(RUNIT::TestCase) do
+ def self.name
+ "DummyTestCase"
+ end
+
+ attr_reader :status, :dummy_called, :dummy2_called
+
+ def initialize(*arg)
+ super(*arg)
+ @status = 0
+ @dummy_called = false
+ @dummy2_called = false
+ end
+
+ def setup
+ @status = 1 if @status == 0
+ end
+
+ def test_dummy
+ @status = 2 if @status == 1
+ @dummy_called = true
+ end
+
+ def test_dummy2
+ @status = 2 if @status == 1
+ @dummy2_called = true
+ raise DummyError
+ end
+
+ def teardown
+ @status = 3 if @status == 2
+ end
+ end
+
+ @test1 = @dummy_testcase.new('test_dummy')
+ @test2 = @dummy_testcase.new('test_dummy2', 'TestCase')
+ end
+
+ def test_name
+ assert_equal('DummyTestCase#test_dummy', @test1.name) # The second parameter to #initialize is ignored in emulation
+ assert_equal('DummyTestCase#test_dummy2', @test2.name)
+ end
+
+ def test_run
+ result = RUNIT::TestResult.new
+ @test1.run(result)
+ assert_equal(1, result.run_count)
+ end
+
+ def test_s_suite
+ suite = @dummy_testcase.suite
+ assert_instance_of(RUNIT::TestSuite, suite)
+ assert_equal(2, suite.count_test_cases)
+ end
+
+ def test_teardown_err
+ suite = Class.new(RUNIT::TestCase) do
+ def test_foo
+ assert(false)
+ end
+
+ def test_bar
+ assert(true)
+ end
+
+ def teardown
+ raise StandardError
+ end
+ end.suite
+
+ result = RUNIT::TestResult.new
+ suite.run(result)
+ assert_equal(2, result.error_size)
+ assert_equal(1, result.failure_size)
+ end
+ end
+end
diff --git a/test/testunit/runit/test_testresult.rb b/test/testunit/runit/test_testresult.rb
new file mode 100644
index 0000000000..702b88d0c0
--- /dev/null
+++ b/test/testunit/runit/test_testresult.rb
@@ -0,0 +1,144 @@
+# Author:: Masaki Suketa.
+# Adapted by:: Nathaniel Talbott.
+# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
+# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'rubyunit'
+
+module RUNIT
+ class TestTestResult < RUNIT::TestCase
+ def setup
+ @result = RUNIT::TestResult.new
+
+ @normal_suite = Class::new(RUNIT::TestCase) do
+ def test_1
+ assert(true)
+ assert(true)
+ end
+ end.suite
+
+ @failure_suite = Class::new(RUNIT::TestCase) do
+ def test_1
+ assert(true)
+ assert(false)
+ end
+ end.suite
+
+ @error_suite = Class::new(RUNIT::TestCase) do
+ def setup
+ raise ScriptError
+ end
+ def test_1
+ assert(true)
+ end
+ end.suite
+
+ @multi_failure_suite = Class::new(RUNIT::TestCase) do
+ def test1
+ assert(false)
+ end
+ def test2
+ assert(false)
+ end
+ def test3
+ assert(false)
+ end
+ end.suite
+
+ @with_error_suite = Class::new(RUNIT::TestCase) do
+ def test1
+ raise StandardError
+ end
+ end.suite
+
+ @multi_error_suite = Class::new(RUNIT::TestCase) do
+ def test1
+ raise StandardError
+ end
+ def test2
+ raise StandardError
+ end
+ def test3
+ raise StandardError
+ end
+ end.suite
+
+ @multi_suite = Class::new(RUNIT::TestCase) do
+ def test_1
+ assert(true)
+ assert(true)
+ end
+ def test_2
+ assert(true)
+ end
+ def test_3
+ assert(true)
+ assert(false)
+ assert(true)
+ end
+ end.suite
+ end
+
+ def test_error_size
+ @normal_suite.run(@result)
+ assert_equal(0, @result.error_size)
+ @with_error_suite.run(@result)
+ assert_equal(1, @result.error_size)
+ @multi_error_suite.run(@result)
+ assert_equal(4, @result.error_size)
+ end
+
+ def test_errors
+ @normal_suite.run(@result)
+ assert_equal(0, @result.errors.size)
+ end
+
+ def test_failure_size
+ @normal_suite.run(@result)
+ assert_equal(0, @result.failure_size)
+ @failure_suite.run(@result)
+ assert_equal(1, @result.failure_size)
+ @multi_failure_suite.run(@result)
+ assert_equal(4, @result.failure_size)
+ end
+
+ def test_failures
+ @normal_suite.run(@result)
+ assert_equal(0, @result.failures.size)
+ @failure_suite.run(@result)
+ assert_equal(1, @result.failures.size)
+ @multi_failure_suite.run(@result)
+ assert_equal(4, @result.failures.size)
+ end
+
+ def test_run_no_exception
+ assert_no_exception {
+ @error_suite.run(@result)
+ }
+ end
+
+ def test_run_asserts
+ @normal_suite.run(@result)
+ assert_equal(2, @result.run_asserts)
+ end
+
+ def test_run_asserts2
+ @failure_suite.run(@result)
+ assert_equal(2, @result.run_asserts)
+ end
+
+ def test_run_tests
+ assert_equal(0, @result.run_tests)
+ @normal_suite.run(@result)
+ assert_equal(1, @result.run_tests)
+ @multi_suite.run(@result)
+ assert_equal(4, @result.run_tests)
+ end
+
+ def test_succeed?
+ @normal_suite.run(@result)
+ assert(@result.succeed?)
+ end
+ end
+end
diff --git a/test/testunit/runit/test_testsuite.rb b/test/testunit/runit/test_testsuite.rb
new file mode 100644
index 0000000000..58702d3efe
--- /dev/null
+++ b/test/testunit/runit/test_testsuite.rb
@@ -0,0 +1,49 @@
+# Author:: Masaki Suketa.
+# Adapted by:: Nathaniel Talbott.
+# Copyright:: Copyright (c) Masaki Suketa. All rights reserved.
+# Copyright:: Copyright (c) 2002 Nathaniel Talbott. All rights reserved.
+# License:: Ruby license.
+
+require 'rubyunit'
+
+module RUNIT
+ class TestTestSuite < RUNIT::TestCase
+ def setup
+ @testsuite = RUNIT::TestSuite.new
+ @dummy_test = Class.new(RUNIT::TestCase) do
+ def test_foo
+ end
+ def test_bar
+ end
+ end
+ @dummy_empty_test = Class.new(RUNIT::TestCase){}
+ end
+
+ def test_count_test_cases
+ assert_equal(0, @testsuite.count_test_cases)
+
+ @testsuite.add(@dummy_empty_test.suite)
+ assert_equal(0, @testsuite.count_test_cases)
+
+ @testsuite.add(@dummy_test.suite)
+ assert_equal(2, @testsuite.count_test_cases)
+
+ @testsuite.add(@dummy_test.suite)
+ assert_equal(4, @testsuite.count_test_cases)
+
+ dummytest_foo = @dummy_test.new('test_foo')
+ @testsuite.add(dummytest_foo)
+ assert_equal(5, @testsuite.count_test_cases)
+ end
+
+ def test_add
+ @testsuite.add(@dummy_empty_test.suite)
+ assert_equal(0, @testsuite.size)
+ assert_equal(0, @testsuite.count_test_cases)
+
+ @testsuite.add(@dummy_test.suite)
+ assert_equal(2, @testsuite.size)
+ assert_equal(2, @testsuite.count_test_cases)
+ end
+ end
+end
diff --git a/test/testunit/test_assertions.rb b/test/testunit/test_assertions.rb
index 19b4963946..8ccd2a81bd 100644
--- a/test/testunit/test_assertions.rb
+++ b/test/testunit/test_assertions.rb
@@ -483,6 +483,7 @@ Message: <"Error">
def test_assert_send
object = Object.new
class << object
+ private
def return_argument(argument, bogus)
return argument
end
diff --git a/test/thread/lbtest.rb b/test/thread/lbtest.rb
new file mode 100755
index 0000000000..10bb90185f
--- /dev/null
+++ b/test/thread/lbtest.rb
@@ -0,0 +1,51 @@
+#! /usr/bin/ruby
+require 'thread'
+
+class LocalBarrier
+ def initialize(n)
+ @wait = Queue.new
+ @done = Queue.new
+ @keeper = begin_keeper(n)
+ end
+
+ def sync
+ @done.push(true)
+ @wait.pop
+ end
+
+ def join
+ @keeper.join
+ end
+
+ private
+ def begin_keeper(n)
+ Thread.start do
+ n.times do
+ @done.pop
+ end
+ n.times do
+ @wait.push(true)
+ end
+ end
+ end
+end
+
+n = 10
+
+lb = LocalBarrier.new(n)
+
+(n - 1).times do |i|
+ Thread.start do
+ sleep((rand(n) + 1) / 10.0)
+ puts "#{i}: done"
+ lb.sync
+ puts "#{i}: cont"
+ end
+end
+
+lb.sync
+puts "#{n-1}: done"
+
+# lb.join # leaving waiting threads.
+
+puts "exit."
diff --git a/test/thread/test_thread.rb b/test/thread/test_thread.rb
new file mode 100644
index 0000000000..44ae3b338d
--- /dev/null
+++ b/test/thread/test_thread.rb
@@ -0,0 +1,81 @@
+# -*- ruby-indent-level: 4 -*-
+require 'thread'
+require 'test/unit'
+
+class TC_Thread < Test::Unit::TestCase
+ def setup
+ Thread.abort_on_exception = true
+ end
+ def teardown
+ Thread.abort_on_exception = false
+ end
+ def test_condvar
+ mutex = Mutex.new
+ condvar = ConditionVariable.new
+ result = []
+ mutex.synchronize do
+ t = Thread.new do
+ mutex.synchronize do
+ result << 1
+ condvar.signal
+ end
+ end
+
+ result << 0
+ condvar.wait(mutex)
+ result << 2
+ t.join
+ end
+ assert_equal([0, 1, 2], result)
+ end
+
+ def test_condvar_wait_not_owner
+ mutex = Mutex.new
+ condvar = ConditionVariable.new
+
+ assert_raises(ThreadError) { condvar.wait(mutex) }
+ end
+
+ def test_condvar_wait_exception_handling
+ # Calling wait in the only thread running should raise a ThreadError of
+ # 'stopping only thread'
+ mutex = Mutex.new
+ condvar = ConditionVariable.new
+
+ Thread.abort_on_exception = false
+
+ locked = false
+ thread = Thread.new do
+ mutex.synchronize do
+ begin
+ condvar.wait(mutex)
+ rescue Exception
+ locked = mutex.locked?
+ raise
+ end
+ end
+ end
+
+ while !thread.stop?
+ sleep(0.1)
+ end
+
+ thread.raise Interrupt, "interrupt a dead condition variable"
+ assert_raises(Interrupt) { thread.value }
+ assert(locked)
+ end
+
+ def test_local_barrier
+ dir = File.dirname(__FILE__)
+ lbtest = File.join(dir, "lbtest.rb")
+ $:.unshift File.join(File.dirname(dir), 'ruby')
+ require 'envutil'
+ $:.shift
+ 10.times {
+ result = `#{EnvUtil.rubybin} #{lbtest}`
+ assert(!$?.coredump?, '[ruby-dev:30653]')
+ assert_equal("exit.", result[/.*\Z/], '[ruby-dev:30653]')
+ }
+ end
+end
+
diff --git a/test/uri/test_ftp.rb b/test/uri/test_ftp.rb
index c27cf6165b..10abd29502 100644
--- a/test/uri/test_ftp.rb
+++ b/test/uri/test_ftp.rb
@@ -31,11 +31,11 @@ class TestFTP < Test::Unit::TestCase
# If you think what's below is wrong, please read RubyForge bug 2055,
# RFC 1738 section 3.2.2, and RFC 2396.
u = URI.parse('ftp://ftp.example.com/foo/bar/file.ext')
- assert(u.path == 'foo/bar/file.ext')
+ assert_equal(u.path, 'foo/bar/file.ext')
u = URI.parse('ftp://ftp.example.com//foo/bar/file.ext')
- assert(u.path == '/foo/bar/file.ext')
+ assert_equal(u.path, '/foo/bar/file.ext')
u = URI.parse('ftp://ftp.example.com/%2Ffoo/bar/file.ext')
- assert(u.path == '/foo/bar/file.ext')
+ assert_equal(u.path, '/foo/bar/file.ext')
end
def test_assemble
@@ -43,7 +43,7 @@ class TestFTP < Test::Unit::TestCase
# assuming everyone else has implemented RFC 2396.
uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
'/path/file.zip', 'i'])
- assert(uri.to_s ==
+ assert_equal(uri.to_s,
'ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i')
end
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb
index 6661b4a5d2..5cd4c7f7ae 100644
--- a/test/uri/test_generic.rb
+++ b/test/uri/test_generic.rb
@@ -1,7 +1,10 @@
require 'test/unit'
require 'uri'
-class URI::TestGeneric < Test::Unit::TestCase
+module URI
+
+
+class TestGeneric < Test::Unit::TestCase
def setup
@url = 'http://a/b/c/d;p?q'
@base_url = URI.parse(@url)
@@ -39,6 +42,17 @@ class URI::TestGeneric < Test::Unit::TestCase
]
ary = uri_to_ary(url)
assert_equal(exp, ary)
+ # 1'
+ url = URI.parse('ftp://ftp.is.co.za/%2Frfc/rfc1808.txt')
+ assert_kind_of(URI::FTP, url)
+
+ exp = [
+ 'ftp',
+ nil, 'ftp.is.co.za', URI::FTP.default_port,
+ '/rfc/rfc1808.txt', nil,
+ ]
+ ary = uri_to_ary(url)
+ assert_equal(exp, ary)
# 2
url = URI.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles')
@@ -230,7 +244,7 @@ class URI::TestGeneric < Test::Unit::TestCase
assert_equal('', url.to_s)
end
- def test_rfc2396_examples
+ def test_rfc3986_examples
# http://a/b/c/d;p?q
# g:h = g:h
url = @base_url.merge('g:h')
@@ -306,11 +320,11 @@ class URI::TestGeneric < Test::Unit::TestCase
assert_equal('g?y', url.to_s)
# http://a/b/c/d;p?q
-# #s = (current document)#s
+# #s = http://a/b/c/d;p?q#s
url = @base_url.merge('#s')
assert_kind_of(URI::HTTP, url)
- assert_equal(@base_url.to_s + '#s', url.to_s)
- url = @base_url.route_to(@base_url.to_s + '#s')
+ assert_equal('http://a/b/c/d;p?q#s', url.to_s)
+ url = @base_url.route_to('http://a/b/c/d;p?q#s')
assert_kind_of(URI::Generic, url)
assert_equal('#s', url.to_s)
@@ -448,18 +462,18 @@ class URI::TestGeneric < Test::Unit::TestCase
url = @base_url.merge('/./g')
assert_kind_of(URI::HTTP, url)
assert_equal('http://a/g', url.to_s)
- url = @base_url.route_to('http://a/./g')
- assert_kind_of(URI::Generic, url)
- assert_equal('/./g', url.to_s)
+# url = @base_url.route_to('http://a/./g')
+# assert_kind_of(URI::Generic, url)
+# assert_equal('/./g', url.to_s)
# http://a/b/c/d;p?q
-# /../g = http://a/../g
+# /../g = http://a/g
url = @base_url.merge('/../g')
assert_kind_of(URI::HTTP, url)
assert_equal('http://a/g', url.to_s)
- url = @base_url.route_to('http://a/../g')
- assert_kind_of(URI::Generic, url)
- assert_equal('/../g', url.to_s)
+# url = @base_url.route_to('http://a/../g')
+# assert_kind_of(URI::Generic, url)
+# assert_equal('/../g', url.to_s)
# http://a/b/c/d;p?q
# g. = http://a/b/c/g.
@@ -502,20 +516,20 @@ class URI::TestGeneric < Test::Unit::TestCase
url = @base_url.merge('../../../g')
assert_kind_of(URI::HTTP, url)
assert_equal('http://a/g', url.to_s)
- url = @base_url.route_to('http://a/../g')
+ url = @base_url.route_to('http://a/g')
assert_kind_of(URI::Generic, url)
- assert('../../../g' != url.to_s) # ok? yes, it confuses you
- assert_equal('/../g', url.to_s) # and it is clearly
+ assert('../../../g' != url.to_s) # ok? yes, it confuses you
+ assert_equal('../../g', url.to_s) # and it is clearly
# http://a/b/c/d;p?q
-# ../../../../g = http://a/../../g
+# ../../../../g = http://a/g
url = @base_url.merge('../../../../g')
assert_kind_of(URI::HTTP, url)
assert_equal('http://a/g', url.to_s)
- url = @base_url.route_to('http://a/../../g')
+ url = @base_url.route_to('http://a/g')
assert_kind_of(URI::Generic, url)
assert('../../../../g' != url.to_s) # ok? yes, it confuses you
- assert_equal('/../../g', url.to_s) # and it is clearly
+ assert_equal('../../g', url.to_s) # and it is clearly
# http://a/b/c/d;p?q
# ./../g = http://a/b/g
@@ -644,9 +658,10 @@ class URI::TestGeneric < Test::Unit::TestCase
assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge'))
end
+ # ruby-dev:16728
def test_set_component
uri = URI.parse('http://foo:bar@baz')
- assert_equal('oof', uri.user = 'oof', "[ruby-dev:16728]")
+ assert_equal('oof', uri.user = 'oof')
assert_equal('http://oof:bar@baz', uri.to_s)
assert_equal('rab', uri.password = 'rab')
assert_equal('http://oof:rab@baz', uri.to_s)
@@ -683,57 +698,7 @@ class URI::TestGeneric < Test::Unit::TestCase
assert_raises(URI::InvalidURIError) { uri.path = 'bar' }
assert_raises(URI::InvalidURIError) { uri.query = 'bar' }
end
-
- def m(s)
- @base_url.merge(s).to_s
end
- def test_rfc3986_examples
- assert_equal("g:h", m("g:h"))
- assert_equal("http://a/b/c/g", m("g"))
- assert_equal("http://a/b/c/g", m("./g"))
- assert_equal("http://a/b/c/g/", m("g/"))
- assert_equal("http://a/g", m("/g"))
- assert_equal("http://g", m("//g"))
- assert_equal("http://a/b/c/d;p?y", m("?y"))
- assert_equal("http://a/b/c/g?y", m("g?y"))
- assert_equal("http://a/b/c/d;p?q#s", m("#s"))
- assert_equal("http://a/b/c/g#s", m("g#s"))
- assert_equal("http://a/b/c/g?y#s", m("g?y#s"))
- assert_equal("http://a/b/c/;x", m(";x"))
- assert_equal("http://a/b/c/g;x", m("g;x"))
- assert_equal("http://a/b/c/g;x?y#s", m("g;x?y#s"))
- assert_equal("http://a/b/c/d;p?q", m(""))
- assert_equal("http://a/b/c/", m("."))
- assert_equal("http://a/b/c/", m("./"))
- assert_equal("http://a/b/", m(".."))
- assert_equal("http://a/b/", m("../"))
- assert_equal("http://a/b/g", m("../g"))
- assert_equal("http://a/", m("../.."))
- assert_equal("http://a/", m("../../"))
- assert_equal("http://a/g", m("../../g"))
- assert_equal("http://a/g", m("../../../g"))
- assert_equal("http://a/g", m("../../../../g"))
-
- assert_equal("http://a/g", m("/./g"))
- assert_equal("http://a/g", m("/../g"))
- assert_equal("http://a/b/c/g.", m("g."))
- assert_equal("http://a/b/c/.g", m(".g"))
- assert_equal("http://a/b/c/g..", m("g.."))
- assert_equal("http://a/b/c/..g", m("..g"))
-
- assert_equal("http://a/b/g", m("./../g"))
- assert_equal("http://a/b/c/g/", m("./g/."))
- assert_equal("http://a/b/c/g/h", m("g/./h"))
- assert_equal("http://a/b/c/h", m("g/../h"))
- assert_equal("http://a/b/c/g;x=1/y", m("g;x=1/./y"))
- assert_equal("http://a/b/c/y", m("g;x=1/../y"))
-
- assert_equal("http://a/b/c/g?y/./x", m("g?y/./x"))
- assert_equal("http://a/b/c/g?y/../x", m("g?y/../x"))
- assert_equal("http://a/b/c/g#s/./x", m("g#s/./x"))
- assert_equal("http://a/b/c/g#s/../x", m("g#s/../x"))
-
- assert_equal("http:g", m("http:g"))
- end
+
end
diff --git a/test/webrick/.htaccess b/test/webrick/.htaccess
new file mode 100644
index 0000000000..69d4659b9f
--- /dev/null
+++ b/test/webrick/.htaccess
@@ -0,0 +1 @@
+this file should not be published.
diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb
index 7d883af3b5..b39fe2661c 100644
--- a/test/webrick/test_cgi.rb
+++ b/test/webrick/test_cgi.rb
@@ -1,29 +1,15 @@
require "webrick"
require File.join(File.dirname(__FILE__), "utils.rb")
require "test/unit"
-begin
- loadpath = $:.dup
- $:.replace($: | [File.expand_path("../ruby", File.dirname(__FILE__))])
- require 'envutil'
-ensure
- $:.replace(loadpath)
-end
class TestWEBrickCGI < Test::Unit::TestCase
def test_cgi
accepted = started = stopped = 0
requested0 = requested1 = 0
config = {
- :CGIInterpreter => EnvUtil.rubybin,
+ :CGIInterpreter => TestWEBrick::RubyBin,
:DocumentRoot => File.dirname(__FILE__),
:DirectoryIndex => ["webrick.cgi"],
- :RequestHandler => Proc.new{|req, res|
- def req.meta_vars
- meta = super
- meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR)
- return meta
- end
- },
}
if RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/
config[:CGIPathEnv] = ENV['PATH'] # runtime dll may not be in system dir.
@@ -54,7 +40,7 @@ class TestWEBrickCGI < Test::Unit::TestCase
assert_equal("a=1, a=2, b=x", res.body)}
req = Net::HTTP::Get.new("/")
http.request(req){|res|
- ary = res.body.lines.to_a
+ ary = res.body.to_a
assert_match(%r{/$}, ary[0])
assert_match(%r{/webrick.cgi$}, ary[1])
}
diff --git a/test/webrick/test_cookie.rb b/test/webrick/test_cookie.rb
index c8ded4c2dd..14771fd01c 100644
--- a/test/webrick/test_cookie.rb
+++ b/test/webrick/test_cookie.rb
@@ -61,7 +61,7 @@ class TestWEBrickCookie < Test::Unit::TestCase
assert_equal("WILE_E_COYOTE", cookie.value)
assert_equal(1, cookie.version)
assert_equal("/acme", cookie.path)
-
+
data = %(Shipping="FedEx"; Version="1"; Path="/acme"; Secure)
cookie = WEBrick::Cookie.parse_set_cookie(data)
assert_equal("Shipping", cookie.name)
diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb
index 64b2fcf231..2c7d97fa70 100644
--- a/test/webrick/test_filehandler.rb
+++ b/test/webrick/test_filehandler.rb
@@ -1,6 +1,7 @@
require "test/unit"
require "webrick"
require "stringio"
+require File.join(File.dirname(__FILE__), "utils.rb")
class WEBrick::TestFileHandler < Test::Unit::TestCase
def default_file_handler(filename)
@@ -8,12 +9,12 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
klass.new(WEBrick::Config::HTTP, filename)
end
+ def windows?
+ File.directory?("\\")
+ end
+
def get_res_body(res)
- if defined? res.body.read
- res.body.read
- else
- res.body
- end
+ return res.body.read rescue res.body
end
def make_range_request(range_spec)
@@ -66,4 +67,134 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase
res = make_range_response(filename, "bytes=0-0, -2")
assert_match(%r{^multipart/byteranges}, res["content-type"])
end
+
+ def test_filehandler
+ config = { :DocumentRoot => File.dirname(__FILE__), }
+ this_file = File.basename(__FILE__)
+ TestWEBrick.start_httpserver(config) do |server, addr, port|
+ http = Net::HTTP.new(addr, port)
+ req = Net::HTTP::Get.new("/")
+ http.request(req){|res|
+ assert_equal("200", res.code)
+ assert_equal("text/html", res.content_type)
+ assert_match(/HREF="#{this_file}"/, res.body)
+ }
+ req = Net::HTTP::Get.new("/#{this_file}")
+ http.request(req){|res|
+ assert_equal("200", res.code)
+ assert_equal("text/plain", res.content_type)
+ assert_equal(File.read(__FILE__), res.body)
+ }
+ end
+ end
+
+ def test_non_disclosure_name
+ config = { :DocumentRoot => File.dirname(__FILE__), }
+ this_file = File.basename(__FILE__)
+ TestWEBrick.start_httpserver(config) do |server, addr, port|
+ http = Net::HTTP.new(addr, port)
+ doc_root_opts = server[:DocumentRootOptions]
+ doc_root_opts[:NondisclosureName] = %w(.ht* *~ test_*)
+ req = Net::HTTP::Get.new("/")
+ http.request(req){|res|
+ assert_equal("200", res.code)
+ assert_equal("text/html", res.content_type)
+ assert_no_match(/HREF="#{File.basename(__FILE__)}"/, res.body)
+ }
+ req = Net::HTTP::Get.new("/#{this_file}")
+ http.request(req){|res|
+ assert_equal("404", res.code)
+ }
+ doc_root_opts[:NondisclosureName] = %w(.ht* *~ TEST_*)
+ http.request(req){|res|
+ assert_equal("404", res.code)
+ }
+ end
+ end
+
+ def test_directory_traversal
+ config = { :DocumentRoot => File.dirname(__FILE__), }
+ this_file = File.basename(__FILE__)
+ TestWEBrick.start_httpserver(config) do |server, addr, port|
+ http = Net::HTTP.new(addr, port)
+ req = Net::HTTP::Get.new("/../../")
+ http.request(req){|res| assert_equal("400", res.code) }
+ req = Net::HTTP::Get.new("/..%5c../#{File.basename(__FILE__)}")
+ http.request(req){|res| assert_equal(windows? ? "200" : "404", res.code) }
+ req = Net::HTTP::Get.new("/..%5c..%5cruby.c")
+ http.request(req){|res| assert_equal("404", res.code) }
+ end
+ end
+
+ def test_unwise_in_path
+ if windows?
+ config = { :DocumentRoot => File.dirname(__FILE__), }
+ this_file = File.basename(__FILE__)
+ TestWEBrick.start_httpserver(config) do |server, addr, port|
+ http = Net::HTTP.new(addr, port)
+ req = Net::HTTP::Get.new("/..%5c..")
+ http.request(req){|res| assert_equal("301", res.code) }
+ end
+ end
+ end
+
+ def test_short_filename
+ config = {
+ :CGIInterpreter => TestWEBrick::RubyBin,
+ :DocumentRoot => File.dirname(__FILE__),
+ :CGIPathEnv => ENV['PATH'],
+ }
+ TestWEBrick.start_httpserver(config) do |server, addr, port|
+ http = Net::HTTP.new(addr, port)
+
+ req = Net::HTTP::Get.new("/webric~1.cgi/test")
+ http.request(req) do |res|
+ if windows?
+ assert_equal("200", res.code)
+ assert_equal("/test", res.body)
+ else
+ assert_equal("404", res.code)
+ end
+ end
+
+ req = Net::HTTP::Get.new("/.htaccess")
+ http.request(req) {|res| assert_equal("404", res.code) }
+ req = Net::HTTP::Get.new("/htacce~1")
+ http.request(req) {|res| assert_equal("404", res.code) }
+ req = Net::HTTP::Get.new("/HTACCE~1")
+ http.request(req) {|res| assert_equal("404", res.code) }
+ end
+ end
+
+ def test_script_disclosure
+ config = {
+ :CGIInterpreter => TestWEBrick::RubyBin,
+ :DocumentRoot => File.dirname(__FILE__),
+ :CGIPathEnv => ENV['PATH'],
+ }
+ TestWEBrick.start_httpserver(config) do |server, addr, port|
+ http = Net::HTTP.new(addr, port)
+
+ req = Net::HTTP::Get.new("/webrick.cgi/test")
+ http.request(req) do |res|
+ assert_equal("200", res.code)
+ assert_equal("/test", res.body)
+ end
+
+ response_assertion = Proc.new do |res|
+ if windows?
+ assert_equal("200", res.code)
+ assert_equal("/test", res.body)
+ else
+ assert_equal("404", res.code)
+ end
+ end
+ req = Net::HTTP::Get.new("/webrick.cgi%20/test")
+ http.request(req, &response_assertion)
+ req = Net::HTTP::Get.new("/webrick.cgi./test")
+ http.request(req, &response_assertion)
+ req = Net::HTTP::Get.new("/webrick.cgi::$DATA/test")
+ http.request(req, &response_assertion)
+ end
+ end
end
diff --git a/test/webrick/test_httprequest.rb b/test/webrick/test_httprequest.rb
index f2fd887873..f0cd1a092a 100644
--- a/test/webrick/test_httprequest.rb
+++ b/test/webrick/test_httprequest.rb
@@ -56,16 +56,6 @@ class TestWEBrickHTTPRequest < Test::Unit::TestCase
assert(req.query.empty?)
end
- def test_request_uri_too_large
- msg = <<-_end_of_message_
- GET /#{"a"*1024} HTTP/1.1
- _end_of_message_
- req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
- assert_raises(WEBrick::HTTPStatus::RequestURITooLarge){
- req.parse(StringIO.new(msg.gsub(/^ {6}/, "")))
- }
- end
-
def test_parse_headers
msg = <<-_end_of_message_
GET /path HTTP/1.1
diff --git a/test/webrick/test_utils.rb b/test/webrick/test_utils.rb
deleted file mode 100644
index ace4632547..0000000000
--- a/test/webrick/test_utils.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require "test/unit"
-require "webrick/utils"
-
-class TestWEBrickUtils < Test::Unit::TestCase
- def assert_expired(flag, m)
- if m == WEBrick::Utils
- handler = WEBrick::Utils::TimeoutHandler.instance
- assert_equal(flag, handler.instance_eval{ @timeout_info.empty? })
- end
- end
-
- def do_test_timeout(m)
- ex = Class.new(StandardError)
-
- assert_equal(:foo, m.timeout(10){ :foo })
- assert_expired(true, m)
-
- i = 0
- assert_raises(Timeout::Error){
- m.timeout(2){
- assert_raises(Timeout::Error){ m.timeout(1){ i += 1; sleep } }
- assert_expired(false, m)
- i += 1
- sleep
- }
- }
- assert_equal(2, i)
- assert_expired(true, m)
-
- assert_raises(Timeout::Error){ m.timeout(0.1){ sleep } }
- assert_expired(true, m)
-
- assert_raises(ex){ m.timeout(0.1, ex){ sleep } }
- assert_expired(true, m)
-
- i = 0
- assert_raises(ex){
- m.timeout(10){
- m.timeout(1, ex){ i += 1; sleep }
- }
- sleep
- }
- assert_equal(1, i)
- assert_expired(true, m)
-
- i = 0
- assert_raises(Timeout::Error){
- m.timeout(1){
- m.timeout(10, ex){ i += 1; sleep }
- }
- sleep
- }
- assert_equal(1, i)
- assert_expired(true, m)
- end
-
- def test_webrick_timeout
- do_test_timeout(WEBrick::Utils)
- end
-
- #def test_timeout
- # do_test_timeout(Timeout)
- #end
-end
diff --git a/test/webrick/utils.rb b/test/webrick/utils.rb
index ba03156145..5db94e6cd5 100644
--- a/test/webrick/utils.rb
+++ b/test/webrick/utils.rb
@@ -1,3 +1,10 @@
+begin
+ loadpath = $:.dup
+ $:.replace($: | [File.expand_path("../ruby", File.dirname(__FILE__))])
+ require 'envutil'
+ensure
+ $:.replace(loadpath)
+end
require "webrick"
begin
require "webrick/https"
@@ -12,6 +19,11 @@ module TestWEBrick
return self
end
+ RubyBin = "\"#{EnvUtil.rubybin}\""
+ RubyBin << " \"-I#{File.expand_path("../..", File.dirname(__FILE__))}/lib\""
+ RubyBin << " \"-I#{File.dirname(EnvUtil.rubybin)}/.ext/common\""
+ RubyBin << " \"-I#{File.dirname(EnvUtil.rubybin)}/.ext/#{RUBY_PLATFORM}\""
+
module_function
def start_server(klass, config={}, &block)
@@ -23,7 +35,7 @@ module TestWEBrick
begin
thread = Thread.start{ server.start }
addr = server.listeners[0].addr
- block.yield([server, addr[3], addr[1]])
+ block.call([server, addr[3], addr[1]])
ensure
server.stop
thread.join
diff --git a/test/webrick/webrick_long_filename.cgi b/test/webrick/webrick_long_filename.cgi
new file mode 100644
index 0000000000..73ba729407
--- /dev/null
+++ b/test/webrick/webrick_long_filename.cgi
@@ -0,0 +1,36 @@
+#!ruby -d
+require "webrick/cgi"
+
+class TestApp < WEBrick::CGI
+ def do_GET(req, res)
+ res["content-type"] = "text/plain"
+ if (p = req.path_info) && p.length > 0
+ res.body = p
+ elsif (q = req.query).size > 0
+ res.body = q.keys.sort.collect{|key|
+ q[key].list.sort.collect{|v|
+ "#{key}=#{v}"
+ }.join(", ")
+ }.join(", ")
+ elsif %r{/$} =~ req.request_uri.to_s
+ res.body = ""
+ res.body << req.request_uri.to_s << "\n"
+ res.body << req.script_name
+ elsif !req.cookies.empty?
+ res.body = req.cookies.inject(""){|result, cookie|
+ result << "%s=%s\n" % [cookie.name, cookie.value]
+ }
+ res.cookies << WEBrick::Cookie.new("Customer", "WILE_E_COYOTE")
+ res.cookies << WEBrick::Cookie.new("Shipping", "FedEx")
+ else
+ res.body = req.script_name
+ end
+ end
+
+ def do_POST(req, res)
+ do_GET(req, res)
+ end
+end
+
+cgi = TestApp.new
+cgi.start
diff --git a/test/win32ole/test_folderitem2_invokeverb.rb b/test/win32ole/test_folderitem2_invokeverb.rb
deleted file mode 100644
index 853b05bed2..0000000000
--- a/test/win32ole/test_folderitem2_invokeverb.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# This script check that Win32OLE can execute InvokeVerb method of FolderItem2.
-#
-
-begin
- require 'win32ole'
-rescue LoadError
-end
-require 'test/unit'
-
-if defined?(WIN32OLE)
- class TestInvokeVerb < Test::Unit::TestCase
- def setup
- #
- # make dummy.txt file for InvokeVerb test.
- #
-
- @fso = WIN32OLE.new('Scripting.FileSystemObject')
- @dummy_file = @fso.GetTempName
- @cfolder = @fso.getFolder(".")
- f = @cfolder.CreateTextFile(@dummy_file)
- f.close
- @dummy_path = @cfolder.path + "\\" + @dummy_file
-
- @shell=WIN32OLE.new('Shell.Application')
- @nsp = @shell.NameSpace(@cfolder.path)
- @fi2 = @nsp.parseName(@dummy_file)
-
- @shortcut = nil
-
- #
- # Search the 'Create Shortcut (&S)' string in Japanese.
- # Yes, I know the string in the Windows 2000 Japanese Edition.
- # But I do not know about the string in any other Windows.
- #
- verbs = @fi2.verbs
- verbs.extend(Enumerable)
- @shortcut = verbs.collect{|verb|
- verb.name
- }.find {|name|
- name.unpack("C*") == [131, 86, 131, 135, 129, 91, 131, 103, 131, 74, 131, 98, 131, 103, 130, 204, 141, 236, 144, 172, 40, 38, 83, 41]
- # /.*\(\&S\)$/ =~ name
- }
- end
-
- def find_link(path)
- arlink = []
- @cfolder.files.each do |f|
- if /\.lnk$/ =~ f.path
- linkinfo = @nsp.parseName(f.name).getLink
- arlink.push f if linkinfo.path == path
- end
- end
- arlink
- end
-
- def test_invokeverb
- links = find_link(@dummy_path)
- assert(0, links.size)
-
- assert(@shortcut)
-
- # Now create shortcut to @dummy_path
- arg = WIN32OLE_VARIANT.new(@shortcut)
- @fi2.InvokeVerb(arg)
-
- # Now search shortcut to @dummy_path
- links = find_link(@dummy_path)
- assert(1, links.size)
- @lpath = links[0].path
- end
-
- def teardown
- if @lpath
- @fso.deleteFile(@lpath)
- end
- if @dummy_path
- @fso.deleteFile(@dummy_path)
- end
- end
-
- end
-end
diff --git a/test/win32ole/test_nil2vtempty.rb b/test/win32ole/test_nil2vtempty.rb
deleted file mode 100644
index 4be3902b6d..0000000000
--- a/test/win32ole/test_nil2vtempty.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# This is test script to check that WIN32OLE should convert nil to VT_EMPTY in second try.
-# [ruby-talk:137054]
-begin
- require 'win32ole'
-rescue LoadError
-end
-require 'test/unit'
-
-if defined?(WIN32OLE)
- class TestNIL2VT_EMPTY < Test::Unit::TestCase
- def setup
- fs = WIN32OLE.new('Scripting.FileSystemObject')
- @path = fs.GetFolder(".").path
- end
- def test_openSchema
- con = nil
- begin
- con = WIN32OLE.new('ADODB.Connection')
- con.connectionString = "Provider=MSDASQL;Extended Properties="
- con.connectionString +="\"DRIVER={Microsoft Text Driver (*.txt; *.csv)};DBQ=#{@path}\""
- con.open
- rescue
- con = nil
- end
- if con
- rs = con.openSchema(4, [nil,nil,"DUMMY", "TABLE"])
- assert(rs)
- assert_equal("_Recordset", rs.ole_type.name)
-
- rs = con.openSchema(4, [WIN32OLE_VARIANT::Empty, WIN32OLE_VARIANT::Empty, "DUMMY", "TABLE"])
- assert(rs)
- assert_equal("_Recordset", rs.ole_type.name)
- end
- end
- end
-end
diff --git a/test/win32ole/test_propertyputref.rb b/test/win32ole/test_propertyputref.rb
deleted file mode 100644
index 24459afe9b..0000000000
--- a/test/win32ole/test_propertyputref.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require 'test/unit'
-begin
- require 'win32ole'
-rescue LoadError
-end
-
-if defined?(WIN32OLE)
- class TestWIN32OLE_PROPERTYPUTREF < Test::Unit::TestCase
- def setup
- begin
- @sapi = WIN32OLE.new('SAPI.SpVoice')
- @sv = @sapi.voice
- rescue WIN32OLERuntimeError
- @sapi = nil
- end
- end
- def test_sapi
- if @sapi
- new_id = @sapi.getvoices.item(0).Id
- @sapi.voice = @sapi.getvoices.item(0)
- assert_equal(new_id, @sapi.voice.Id)
- end
- end
- def teardown
- if @sapi
- @sapi.voice = @sv
- end
- end
- end
-end
diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb
deleted file mode 100644
index 06d4713375..0000000000
--- a/test/win32ole/test_win32ole.rb
+++ /dev/null
@@ -1,408 +0,0 @@
-#
-
-begin
- require 'win32ole'
-rescue LoadError
-end
-require 'test/unit'
-
-if defined?(WIN32OLE)
- module CONST1
- end
- module CONST2
- end
-
- module TestCaseForDict
- def test_convert_bignum
- @dict1.add("a", 9999999999)
- @dict1.add("b", 999999999)
- @dict1.add("c", @dict1.item("b") * 10 + 9)
- assert_equal(9999999999, @dict1.item("a"))
- assert_equal(9999999999, @dict1.item("c"))
- end
- def test_add
- @dict1.add("a", 1000)
- assert_equal(1000, @dict1.item("a"))
- end
- def test_setproperty_equal_ended
- @dict1.compareMode = 1
- @dict1.add("one", 1)
- assert_equal(1, @dict1.item("ONE"))
- @dict2.add("one", 1)
- assert_nil(@dict2.item("ONE"))
- assert_equal(1, @dict2.item("one"))
- end
- def test_non_exist_property
- assert_raise(WIN32OLERuntimeError) {
- @dict1.unknown_property = 1
- }
- end
-
- def test_raise_message
- exc = assert_raise(WIN32OLERuntimeError) {
- @dict1.add
- }
- assert_match(/^\(in OLE method `add': \)/, exc.message)
-
- exc = assert_raise(WIN32OLERuntimeError) {
- @dict1._invoke(1, [], [])
- }
- assert_match(/^\(in OLE method `<dispatch id:1>': \)/, exc.message)
-
- exc = assert_raise(WIN32OLERuntimeError) {
- @dict1.compareMode = -1
- }
- assert_match(/^\(in setting property `compareMode': \)/, exc.message)
- end
-
- def test_ole_methods
- methods = @dict1.ole_methods
- mnames = methods.collect {|m|
- m.name
- }
- assert(mnames.include?("Add"))
- end
-
- def test_ole_func_methods
- methods = @dict1.ole_func_methods
- mnames = methods.collect {|m|
- m.name
- }
- assert(mnames.include?("Add"))
- end
-
- def test_ole_put_methods
- methods = @dict1.ole_put_methods
- mnames = methods.collect {|m|
- m.name
- }
- assert(mnames.include?("CompareMode"))
- end
-
- def test_ole_get_methods
- methods = @dict1.ole_get_methods
- mnames = methods.collect {|m|
- m.name
- }
- assert(mnames.include?("Count"))
- end
-
- def test_ole_mehtod_help
- minfo = @dict1.ole_method_help("Add")
- assert_equal(2, minfo.size_params)
- end
-
- def test_ole_typelib
- tlib = @dict1.ole_typelib
- assert_equal("Microsoft Scripting Runtime", tlib.name);
- end
-
- def test_each
- @dict1.add("one", 1)
- @dict1.add("two", 2)
- i = 0
- @dict1.keys.each do |item|
- i += 1
- end
- assert_equal(2, i)
- end
-
- def test_bracket
- @dict1.add("foo", "FOO")
- assert_equal("FOO", @dict1.item("foo"))
- assert_equal("FOO", @dict1["foo"])
- end
-
- def test_bracket_equal
- @dict1.add("foo", "FOO")
- @dict1["foo"] = "BAR"
- assert_equal("BAR", @dict1["foo"])
- end
-
- def test_invoke_with_array
- @dict1.add("ary1", [1,2,3])
- assert_equal([1,2,3], @dict1["ary1"])
-
- @dict1.add("ary2", [[1,2,"a"], [3,4,"b"]])
- assert_equal([[1,2,"a"], [3,4,"b"]], @dict1["ary2"])
-
- @dict1.add("ary3", [[[1]]])
- assert_equal([[[1]]], @dict1["ary3"])
-
- @dict1.add("ary4", [[[1], [2], [3]], [[4], [5], [6]]])
- assert_equal([[[1],[2], [3]], [[4], [5], [6]]], @dict1["ary4"])
- end
- end
-
- class TestWin32OLE < Test::Unit::TestCase
- include TestCaseForDict
- def setup
- @dict1 = WIN32OLE.new('Scripting.Dictionary')
- @dict2 = WIN32OLE.new('Scripting.Dictionary')
- end
- def test_s_new
- assert_instance_of(WIN32OLE, @dict1)
- assert_instance_of(WIN32OLE, @dict2)
- end
-
- def test_s_new_DCOM
- rshell = WIN32OLE.new("Shell.Application")
- assert_instance_of(WIN32OLE, rshell)
- end
-
- def test_s_new_from_clsid
- shell = WIN32OLE.new("{13709620-C279-11CE-A49E-444553540000}")
- assert_instance_of(WIN32OLE, shell)
- exc = assert_raise(WIN32OLERuntimeError) {
- WIN32OLE.new("{000}")
- }
- assert_match(/unknown OLE server: `\{000\}'/, exc.message)
- end
-
- def test_s_connect
- obj = WIN32OLE.connect("winmgmts:")
- assert_instance_of(WIN32OLE, obj)
- end
-
- def test_invoke_accept_symbol_hash_key
- fso = WIN32OLE.new('Scripting.FileSystemObject')
- afolder = fso.getFolder(".")
- bfolder = fso.getFolder({"FolderPath" => "."})
- cfolder = fso.getFolder({:FolderPath => "."})
- assert_equal(afolder.path, bfolder.path)
- assert_equal(afolder.path, cfolder.path)
- fso = nil
- end
-
- def test_setproperty
- installer = WIN32OLE.new("WindowsInstaller.Installer")
- record = installer.CreateRecord(2)
- # this is the way to set property with argument in Win32OLE.
- record.setproperty( "StringData", 1, 'dddd')
- assert_equal('dddd', record.StringData(1))
- end
-
- def test_ole_type
- fso = WIN32OLE.new('Scripting.FileSystemObject')
- tobj = fso.ole_type
- assert_match(/^IFileSystem/, tobj.name)
- end
-
- def test_ole_obj_help
- fso = WIN32OLE.new('Scripting.FileSystemObject')
- tobj = fso.ole_obj_help
- assert_match(/^IFileSystem/, tobj.name)
- end
-
-
- def test_invoke_hash_key_non_str_sym
- fso = WIN32OLE.new('Scripting.FileSystemObject')
- begin
- bfolder = fso.getFolder({1 => "."})
- assert(false)
- rescue TypeError
- assert(true)
- end
- fso = nil
- end
-
- def test_get_win32ole_object
- shell = WIN32OLE.new('Shell.Application')
- folder = shell.nameSpace(0)
- assert_instance_of(WIN32OLE, folder)
- end
-
- def test_invoke_accept_multi_hash_key
- shell = WIN32OLE.new('Shell.Application')
- folder = shell.nameSpace(0)
- item = folder.items.item(0)
- name = folder.getDetailsOf(item, 0)
- assert_equal(item.name, name)
- name = folder.getDetailsOf({:vItem => item, :iColumn => 0})
- assert_equal(item.name, name)
- name = folder.getDetailsOf({"vItem" => item, :iColumn => 0})
- assert_equal(item.name, name)
- end
-
- def test_ole_invoke_with_named_arg_last
- shell = WIN32OLE.new('Shell.Application')
- folder = shell.nameSpace(0)
- item = folder.items.item(0)
- name = folder.getDetailsOf(item, {:iColumn => 0})
- assert_equal(item.name, name)
- end
-
- def test__invoke
- shell=WIN32OLE.new('Shell.Application')
- assert_equal(shell.NameSpace(0).title, shell._invoke(0x60020002, [0], [WIN32OLE::VARIANT::VT_VARIANT]).title)
- end
-
- def test_ole_query_interface
- shell=WIN32OLE.new('Shell.Application')
- assert_raise(ArgumentError) {
- shell2 = shell.ole_query_interface
- }
- shell2 = shell.ole_query_interface('{A4C6892C-3BA9-11D2-9DEA-00C04FB16162}')
- assert_instance_of(WIN32OLE, shell2)
- end
-
- def test_s_const_load
- assert(!defined?(CONST1::SsfWINDOWS))
- shell=WIN32OLE.new('Shell.Application')
- WIN32OLE.const_load(shell, CONST1)
- assert_equal(36, CONST1::SsfWINDOWS)
-
- assert(!defined?(CONST2::SsfWINDOWS))
- WIN32OLE.const_load("Microsoft Shell Controls And Automation", CONST2)
- assert_equal(36, CONST2::SsfWINDOWS)
- end
-
- def test_s_create_guid
- guid = WIN32OLE.create_guid
- assert_match(/^\{[A-Z0-9]{8}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{12}/,
- guid)
- end
-
- def test_s_codepage
- assert_equal(WIN32OLE::CP_ACP, WIN32OLE.codepage)
- end
-
- def test_s_codepage_set
- WIN32OLE.codepage = WIN32OLE::CP_UTF8
- assert_equal(WIN32OLE::CP_UTF8, WIN32OLE.codepage)
- WIN32OLE.codepage = WIN32OLE::CP_ACP
- end
-
- def test_s_codepage_changed
- fso = WIN32OLE.new("Scripting.FileSystemObject")
- fname = fso.getTempName
- begin
- WIN32OLE.codepage = WIN32OLE::CP_UTF8
- file = fso.opentextfile(fname, 2, true)
- file.write [0x3042].pack("U*")
- file.close
- str = ""
- open(fname) {|ifs|
- str = ifs.read
- }
- assert_equal("\202\240", str)
-
- WIN32OLE.codepage = WIN32OLE::CP_ACP
- file = fso.opentextfile(fname, 2, true)
- file.write [0x3042].pack("U*")
- file.close
- open(fname) {|ifs|
- str = ifs.read
- }
- assert_equal("\343\201", str)
-
- # This test fail if codepage 20932 (euc) is not installed.
- begin
- WIN32OLE.codepage = 20932
- rescue WIN32OLERuntimeError
- end
- if (WIN32OLE.codepage == 20932)
- file = fso.opentextfile(fname, 2, true)
- file.write [164, 162].pack("c*")
- file.close
- open(fname) {|ifs|
- str = ifs.read
- }
- assert_equal("\202\240", str)
- end
-
- ensure
- WIN32OLE.codepage = WIN32OLE::CP_ACP
- if (File.exist?(fname))
- File.unlink(fname)
- end
- end
- end
-
- def test_s_locale
- assert_equal(WIN32OLE::LOCALE_SYSTEM_DEFAULT, WIN32OLE.locale)
- end
-
- def test_s_locale_set
- begin
- WIN32OLE.locale = 1041
- assert_equal(1041, WIN32OLE.locale)
- WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE.locale = 111
- }
- assert_equal(WIN32OLE::LOCALE_SYSTEM_DEFAULT, WIN32OLE.locale)
- ensure
- WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
- end
- end
-
- def test_s_locale_change
- begin
- WIN32OLE.locale = 0x0411
- obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY)
- assert_equal("100000", obj.value)
-
- WIN32OLE.locale = 1033
- obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
- assert_equal("100000", obj.value)
- ensure
- WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
- end
- end
-
- def test_const_CP_ACP
- assert_equal(0, WIN32OLE::CP_ACP)
- end
-
- def test_const_CP_OEMCP
- assert_equal(1, WIN32OLE::CP_OEMCP)
- end
-
- def test_const_CP_MACCP
- assert_equal(2, WIN32OLE::CP_MACCP)
- end
-
- def test_const_CP_THREAD_ACP
- assert_equal(3, WIN32OLE::CP_THREAD_ACP)
- end
-
- def test_const_CP_SYMBOL
- assert_equal(42, WIN32OLE::CP_SYMBOL)
- end
-
- def test_const_CP_UTF7
- assert_equal(65000, WIN32OLE::CP_UTF7)
- end
-
- def test_const_CP_UTF8
- assert_equal(65001, WIN32OLE::CP_UTF8)
- end
-
- def test_const_LOCALE_SYSTEM_DEFAULT
- assert_equal(0x0800, WIN32OLE::LOCALE_SYSTEM_DEFAULT);
- end
-
- def test_const_LOCALE_USER_DEFAULT
- assert_equal(0x0400, WIN32OLE::LOCALE_USER_DEFAULT);
- end
- end
-
- # test of subclass of WIN32OLE
- class MyDict < WIN32OLE
- def MyDict.new
- super('Scripting.Dictionary')
- end
- end
- class TestMyDict < Test::Unit::TestCase
- include TestCaseForDict
- def setup
- @dict1 = MyDict.new
- @dict2 = MyDict.new
- end
- def test_s_new
- assert_instance_of(MyDict, @dict1)
- assert_instance_of(MyDict, @dict2)
- end
- end
-end
diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb
deleted file mode 100644
index 522e7a61f0..0000000000
--- a/test/win32ole/test_win32ole_event.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require 'test/unit'
-
-if defined?(WIN32OLE_EVENT)
- class TestWIN32OLE_EVENT < Test::Unit::TestCase
- def create_temp_html
- fso = WIN32OLE.new('Scripting.FileSystemObject')
- dummy_file = fso.GetTempName + ".html"
- cfolder = fso.getFolder(".")
- f = cfolder.CreateTextFile(dummy_file)
- f.writeLine("<html><body>This is test HTML file for Win32OLE.</body></html>")
- f.close
- dummy_path = cfolder.path + "\\" + dummy_file
- dummy_path
- end
-
- def setup
- @ie = WIN32OLE.new("InternetExplorer.Application")
- @ie.visible = true
- @event = ""
- @event2 = ""
- @event3 = ""
- @f = create_temp_html
- end
-
- def default_handler(event, *args)
- @event += event
- end
-
- def test_on_event
- ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
- ev.on_event {|*args| default_handler(*args)}
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert_match(/BeforeNavigate/, @event)
- assert_match(/NavigateComplete/, @event)
- end
-
- def test_on_event2
- ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
- ev.on_event('BeforeNavigate') {|*args| handler1}
- ev.on_event('BeforeNavigate') {|*args| handler2}
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert_equal("handler2", @event2)
- end
-
- def test_on_event3
- ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
- ev.on_event {|*args| handler1}
- ev.on_event {|*args| handler2}
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert_equal("handler2", @event2)
- end
-
- def test_on_event4
- ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
- ev.on_event{|*args| handler1}
- ev.on_event{|*args| handler2}
- ev.on_event('NavigateComplete'){|*args| handler3(*args)}
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert(@event3!="")
- assert("handler2", @event2)
- end
-
- def test_on_event5
- ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
- ev.on_event {|*args| default_handler(*args)}
- ev.on_event('NavigateComplete'){|*args| handler3(*args)}
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert_match(/BeforeNavigate/, @event)
- assert(/NavigateComplete/ !~ @event)
- assert(@event!="")
- end
-
- def test_unadvise
- ev = WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
- ev.on_event {|*args| default_handler(*args)}
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert_match(/BeforeNavigate/, @event)
- ev.unadvise
- @event = ""
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.1
- end
- assert_equal("", @event);
- assert_raise(WIN32OLERuntimeError) {
- ev.on_event {|*args| default_handler(*args)}
- }
- end
-
- def handler1
- @event2 = "handler1"
- end
-
- def handler2
- @event2 = "handler2"
- end
-
- def handler3(url)
- @event3 += url
- end
-
- def teardown
- @ie.quit
- @ie = nil
- File.unlink(@f)
- GC.start
- end
- end
-end
diff --git a/test/win32ole/test_win32ole_method.rb b/test/win32ole/test_win32ole_method.rb
deleted file mode 100644
index 31eff87937..0000000000
--- a/test/win32ole/test_win32ole_method.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE_METHOD)
- class TestWIN32OLE_METHOD < Test::Unit::TestCase
-
- def setup
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- @m_open = WIN32OLE_METHOD.new(ole_type, "open")
- @m_namespace = WIN32OLE_METHOD.new(ole_type, "namespace")
- @m_parent = WIN32OLE_METHOD.new(ole_type, "parent")
- @m_invoke = WIN32OLE_METHOD.new(ole_type, "invoke")
- @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder")
-
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File")
- @m_file_name = WIN32OLE_METHOD.new(ole_type, "name")
-
- ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser")
- @m_navigate_complete = WIN32OLE_METHOD.new(ole_type, "NavigateComplete")
- end
-
- def test_initialize
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- assert_raise(ArgumentError) {
- method = WIN32OLE_METHOD.new("foo")
- }
- assert_raise(ArgumentError) {
- method = WIN32OLE_METHOD.new(ole_type)
- }
- assert_raise(WIN32OLERuntimeError) {
- method = WIN32OLE_METHOD.new(ole_type, "NonExistMethod")
- }
- method = WIN32OLE_METHOD.new(ole_type, "Open")
- assert_instance_of(WIN32OLE_METHOD, method)
- method = WIN32OLE_METHOD.new(ole_type, "open")
- assert_instance_of(WIN32OLE_METHOD, method)
- end
-
- def test_name
- assert_equal("Open", @m_open.name)
- end
-
- def test_return_type
- assert_equal("VOID", @m_open.return_type)
- assert_equal("Folder", @m_namespace.return_type)
- end
-
- def test_return_vtype
- assert_equal(24, @m_open.return_vtype)
- assert_equal(26, @m_namespace.return_vtype)
- end
-
- def test_return_type_detail
- assert_equal(['VOID'], @m_open.return_type_detail)
- assert_equal(['PTR', 'USERDEFINED', 'Folder'], @m_namespace.return_type_detail)
- end
-
- def test_invoke_kind
- assert_equal('FUNC', @m_open.invoke_kind)
- assert_equal('FUNC', @m_namespace.invoke_kind)
- assert_equal('PROPERTYGET', @m_parent.invoke_kind)
- end
-
- def test_invkind
- assert_equal(1, @m_namespace.invkind)
- assert_equal(2, @m_parent.invkind)
- end
-
- def test_visible?
- assert(@m_namespace.visible?)
- assert(!@m_invoke.visible?)
- end
-
- def test_event?
- assert(@m_navigate_complete.event?)
- assert(!@m_namespace.event?)
- end
-
- def test_event_interface
- assert_equal("DWebBrowserEvents", @m_navigate_complete.event_interface)
- assert_equal(nil, @m_namespace.event_interface)
- end
-
- def test_helpstring
- assert_equal("Get special folder from ShellSpecialFolderConstants", @m_namespace.helpstring)
- end
-
- def test_helpfile
- assert_equal("", @m_namespace.helpfile)
- assert_match(/VBENLR.*\.CHM$/i, @m_file_name.helpfile)
- end
-
- def test_helpcontext
- assert_equal(0, @m_namespace.helpcontext)
- assert_equal(2181996, @m_file_name.helpcontext)
- end
-
- def test_dispid
- assert_equal(1610743810, @m_namespace.dispid)
- end
-
- def test_offset_vtbl
- assert_equal(24, @m_invoke.offset_vtbl)
- end
-
- def test_size_params
- assert_equal(1, @m_open.size_params)
- assert_equal(4, @m_browse_for_folder.size_params)
- end
-
- def test_size_opt_params
- assert_equal(0, @m_open.size_opt_params)
- assert_equal(1, @m_browse_for_folder.size_opt_params)
- end
-
- def test_params
- params = @m_browse_for_folder.params
- assert_instance_of(Array, params)
- assert_equal(4, params.size)
- assert_instance_of(WIN32OLE_PARAM, params[0])
- end
-
- def test_to_s
- assert_equal(@m_namespace.name, @m_namespace.to_s)
- end
-
- def test_inspect
- assert_equal("#<WIN32OLE_METHOD:NameSpace>", @m_namespace.inspect)
- end
-
- end
-end
diff --git a/test/win32ole/test_win32ole_param.rb b/test/win32ole/test_win32ole_param.rb
deleted file mode 100644
index 4374f9a426..0000000000
--- a/test/win32ole/test_win32ole_param.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE_PARAM)
- class TestWIN32OLE_PARAM < Test::Unit::TestCase
-
- def setup
- ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser")
- m_navigate = WIN32OLE_METHOD.new(ole_type, "Navigate")
- m_before_navigate = WIN32OLE_METHOD.new(ole_type, "BeforeNavigate")
- params = m_navigate.params
- @param_url = params[0]
- @param_flags = params[1]
- @param_cancel = m_before_navigate.params[5]
-
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellLinkObject")
- m_geticonlocation = WIN32OLE_METHOD.new(ole_type, "GetIconLocation")
- @param_pbs = m_geticonlocation.params[0]
-
- ole_type = WIN32OLE_TYPE.new("Microsoft HTML Object Library", "FontNames")
- m_count = WIN32OLE_METHOD.new(ole_type, "Count")
- @param_p = m_count.params[0]
-
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject")
- m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile")
- @param_overwritefiles = m_copyfile.params[2]
- end
-
- def test_name
- assert_equal('URL', @param_url.name)
- assert_equal('Flags', @param_flags.name)
- assert_equal('Cancel', @param_cancel.name)
- end
-
- def test_ole_type
- assert_equal('BSTR', @param_url.ole_type)
- assert_equal('VARIANT', @param_flags.ole_type)
- end
-
- def test_ole_type_detail
- assert_equal(['BSTR'], @param_url.ole_type_detail)
- assert_equal(['PTR', 'VARIANT'], @param_flags.ole_type_detail)
- end
-
- def test_input?
- assert(@param_url.input?)
- assert(@param_cancel.input?)
- assert(!@param_pbs.input?)
- end
-
- def test_output?
- assert(!@param_url.output?)
- assert(@param_cancel.output?)
- assert(@param_pbs.output?)
- end
-
- def test_optional?
- assert(!@param_url.optional?)
- assert(@param_flags.optional?)
- end
-
- def test_retval?
- assert(!@param_url.retval?)
- assert(@param_p.retval?)
- end
-
- def test_default
- assert_equal(nil, @param_url.default)
- assert_equal(true, @param_overwritefiles.default)
- end
-
- def test_to_s
- assert_equal(@param_url.name, @param_url.to_s)
- end
-
- def test_inspect
- assert_equal("#<WIN32OLE_PARAM:URL>", @param_url.inspect)
- assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", @param_overwritefiles.inspect)
- end
- end
-end
diff --git a/test/win32ole/test_win32ole_type.rb b/test/win32ole/test_win32ole_type.rb
deleted file mode 100644
index a5b59ca477..0000000000
--- a/test/win32ole/test_win32ole_type.rb
+++ /dev/null
@@ -1,177 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE_TYPE)
- class TestWIN32OLE_TYPE < Test::Unit::TestCase
-
- def test_s_progids
- progids = WIN32OLE_TYPE.progids
- assert_instance_of(Array, progids)
- assert(progids.size > 0)
- assert_instance_of(String, progids[0])
- assert(progids.include?("Shell.Application.1"))
- end
-
- def test_initialize
- assert_raise(ArgumentError) {
- WIN32OLE_TYPE.new
- }
- assert_raise(ArgumentError) {
- WIN32OLE_TYPE.new("foo")
- }
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "foo")
- }
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Application")
- }
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- assert_instance_of(WIN32OLE_TYPE, ole_type)
-
- ole_type2 = WIN32OLE_TYPE.new("{13709620-C279-11CE-A49E-444553540000}", "Shell")
- assert_instance_of(WIN32OLE_TYPE, ole_type)
- assert_equal(ole_type.name, ole_type2.name)
- assert_equal(ole_type.ole_type, ole_type2.ole_type)
- assert_equal(ole_type.guid, ole_type2.guid)
- assert_equal(ole_type.progid, ole_type2.progid)
- assert_equal(ole_type.visible?, ole_type2.visible?)
- assert_equal(ole_type.to_s, ole_type2.to_s)
- assert_equal(ole_type.major_version, ole_type2.major_version)
- assert_equal(ole_type.minor_version, ole_type2.minor_version)
- assert_equal(ole_type.typekind, ole_type2.typekind)
- assert_equal(ole_type.helpstring, ole_type2.helpstring)
- assert_equal(ole_type.src_type, ole_type2.src_type)
- assert_equal(ole_type.helpfile, ole_type2.helpfile)
- assert_equal(ole_type.helpcontext, ole_type2.helpcontext)
- assert_equal(ole_type.variables.size, ole_type2.variables.size)
- assert_equal(ole_type.ole_methods[0].name, ole_type2.ole_methods[0].name)
- assert_equal(ole_type.ole_typelib.name, ole_type2.ole_typelib.name)
- assert_equal(ole_type.implemented_ole_types.size, ole_type2.implemented_ole_types.size)
- assert_equal(ole_type.inspect, ole_type2.inspect)
- end
-
- def setup
- @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- end
-
- def test_name
- assert_equal("Shell", @ole_type.name)
- end
-
- def test_ole_type
- assert_equal("Class", @ole_type.ole_type)
- end
-
- def test_guid
- assert_equal("{13709620-C279-11CE-A49E-444553540000}", @ole_type.guid)
- end
-
- def test_progid
- assert_equal("Shell.Application.1", @ole_type.progid)
- end
-
- def test_visible?
- assert(@ole_type.visible?)
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "IShellDispatch")
- assert(!ole_type.visible?)
- end
-
- def test_to_s
- assert_equal(@ole_type.to_s, @ole_type.name)
- end
-
- def test_major_version
- assert_equal(0, @ole_type.major_version)
- # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
- # assert_equal(8, ole_type.major_version)
- end
-
- def test_minor_version
- assert_equal(0, @ole_type.minor_version)
- # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
- # assert_equal(3, ole_type.minor_version)
- end
-
- def test_typekind
- assert_equal(5, @ole_type.typekind)
- end
-
- def test_helpstring
- assert_equal("Shell Object Type Information", @ole_type.helpstring)
- end
-
- def test_src_type
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "DriveTypeConst")
- assert_match(/__MIDL___MIDL_itf_scrrun_/, ole_type.src_type)
- assert_equal(nil, @ole_type.src_type)
- end
-
- def test_helpfile
- assert_equal("", @ole_type.helpfile)
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
- assert_match(/VBENLR98\.CHM$/i, ole_type.helpfile)
- end
-
- def test_helpcontext
- assert_equal(0, @ole_type.helpcontext)
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
- assert_equal(2181929, ole_type.helpcontext)
- end
-
- def test_variables
- variables = @ole_type.variables
- assert_instance_of(Array, variables)
- assert(variables.size == 0)
-
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
- variables = ole_type.variables
- assert_instance_of(Array, variables)
- assert(variables.size > 0)
-
- assert_instance_of(WIN32OLE_VARIABLE, variables[0])
- end
-
- def test_ole_methods
- methods = @ole_type.ole_methods
- assert_instance_of(Array, methods)
- assert(methods.size > 0)
- assert_instance_of(WIN32OLE_METHOD, methods[0]);
- assert(methods.collect{|m| m.name}.include?("Application"))
- end
-
- def test_ole_typelib
- tlib = @ole_type.ole_typelib
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
- assert_equal("Microsoft Shell Controls And Automation", tlib.name)
- end
-
- def test_implemented_ole_types
- ole_types = @ole_type.implemented_ole_types
- assert_instance_of(Array, ole_types)
- assert(ole_types.size > 0)
- assert_match(/^IShellDispatch5{0,1}$/, ole_types[0].name)
- end
-
- def test_inspect
- assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect)
- end
- # WIN32OLE_TYPE.typelibs will be obsoleted.
- def test_s_typelibs
- tlibs = WIN32OLE_TYPE.typelibs.sort
- tlibs2 = WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}.sort
- assert_equal(tlibs2, tlibs)
- end
-
- # WIN32OLE_TYPE.ole_classes will be obsoleted.
- def test_s_ole_classes
- ots1 = WIN32OLE_TYPE.ole_classes("Microsoft Shell Controls And Automation")
- ots2 = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation").ole_types
- otns1 = ots1.collect{|t| t.name}.sort
- otns2 = ots2.collect{|t| t.name}.sort
- assert_equal(otns2, otns1)
- end
- end
-end
diff --git a/test/win32ole/test_win32ole_typelib.rb b/test/win32ole/test_win32ole_typelib.rb
deleted file mode 100644
index 16e6c1a663..0000000000
--- a/test/win32ole/test_win32ole_typelib.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE_TYPELIB)
- class TestWIN32OLE_TYPELIB < Test::Unit::TestCase
- def test_s_typelibs
- tlibs = WIN32OLE_TYPELIB.typelibs
- assert_instance_of(Array, tlibs)
- assert(tlibs.size > 0)
- tlib = tlibs.find {|tlib| tlib.name == "Microsoft Shell Controls And Automation"}
- assert(tlib)
- end
-
- def test_initialize
- assert_raise(ArgumentError) {
- WIN32OLE_TYPELIB.new(1,2,3,4)
- }
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
-
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1.0)
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
-
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1, 0)
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
- guid = tlib.guid
-
- tlib_by_guid = WIN32OLE_TYPELIB.new(guid, 1, 0)
- assert_instance_of(WIN32OLE_TYPELIB, tlib_by_guid)
- assert_equal("Microsoft Shell Controls And Automation" , tlib_by_guid.name)
-
- path = tlib.path
- tlib_by_path = WIN32OLE_TYPELIB.new(path)
- assert_equal("Microsoft Shell Controls And Automation" , tlib_by_path.name)
-
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_TYPELIB.new("Non Exist Type Library")
- }
- end
-
- def test_guid
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid)
- end
-
- def test_name
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal("Microsoft Shell Controls And Automation", tlib.name)
- tlib = WIN32OLE_TYPELIB.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}")
- assert_equal("Microsoft Shell Controls And Automation", tlib.name)
- end
-
- def test_version
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal(1.0, tlib.version)
- end
-
- def test_major_version
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal(1, tlib.major_version)
- end
-
- def test_minor_version
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal(0, tlib.minor_version)
- end
-
- def test_path
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_match(/shell32\.dll$/i, tlib.path)
- end
-
- def test_visible?
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert(tlib.visible?)
- end
-
- def test_library_name
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal("Shell32", tlib.library_name)
- end
-
- def test_to_s
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal("Microsoft Shell Controls And Automation", tlib.to_s)
- end
-
- def test_ole_types
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- ole_types = tlib.ole_types
- assert_instance_of(Array, ole_types)
- assert(ole_types.size > 0)
- assert_instance_of(WIN32OLE_TYPE, ole_types[0])
- end
-
- def test_inspect
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect)
- end
-
- end
-end
diff --git a/test/win32ole/test_win32ole_variable.rb b/test/win32ole/test_win32ole_variable.rb
deleted file mode 100644
index 43529d3bad..0000000000
--- a/test/win32ole/test_win32ole_variable.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE_VARIABLE)
- class TestWIN32OLE_VARIABLE < Test::Unit::TestCase
-
- def setup
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
- @var1 = ole_type.variables.find {|v| v.name == 'ssfDESKTOP'}
-
- variables = WIN32OLE_TYPE.new("Microsoft Windows Installer Object Library", "Installer").variables
- @var2 = variables.find {|v| v.name == 'UILevel'}
- end
-
- def test_name
- assert_equal('ssfDESKTOP', @var1.name)
- end
-
- def test_ole_type
- assert_equal('INT', @var1.ole_type)
- assert_equal('MsiUILevel', @var2.ole_type)
- end
-
- def test_ole_type_detail
- assert_equal(['INT'], @var1.ole_type_detail)
- assert_equal(['USERDEFINED', 'MsiUILevel'], @var2.ole_type_detail)
- end
-
- def test_ole_type_value
- assert_equal(0, @var1.value)
- assert_equal(nil, @var2.value)
- end
-
- def test_ole_type_visible?
- assert(@var1.visible?)
- end
-
- def test_ole_type_variable_kind
- assert_equal("CONSTANT", @var1.variable_kind)
- assert_equal("DISPATCH", @var2.variable_kind)
- end
-
- def test_ole_type_varkind
- assert_equal(2, @var1.varkind)
- assert_equal(3, @var2.varkind)
- end
-
- def test_to_s
- assert_equal(@var1.name, @var1.to_s)
- end
-
- def test_inspect
- assert_equal("#<WIN32OLE_VARIABLE:ssfDESKTOP=0>", @var1.inspect)
- assert_equal("#<WIN32OLE_VARIABLE:UILevel=nil>", @var2.inspect)
- end
-
- end
-end
diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb
deleted file mode 100644
index 67ed783b4f..0000000000
--- a/test/win32ole/test_win32ole_variant.rb
+++ /dev/null
@@ -1,592 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-$MSGS = []
-def add_skip_message(msg)
- $MSGS.push msg
-end
-
-if defined?(WIN32OLE_VARIANT)
-
- class TestWIN32OLE_VARIANT < Test::Unit::TestCase
-
- def test_s_new
- obj = WIN32OLE_VARIANT.new('foo')
- assert_instance_of(WIN32OLE_VARIANT, obj)
- end
-
- def test_s_new_no_argument
- ex = nil
- begin
- obj = WIN32OLE_VARIANT.new
- rescue ArgumentError
- ex = $!
- end
- assert_instance_of(ArgumentError, ex)
- assert_equal("wrong number of arguments (0 for 1..3)", ex.message);
- end
-
- def test_s_new_one_argument
- ex = nil
- begin
- obj = WIN32OLE_VARIANT.new('foo')
- rescue
- ex = $!
- end
- assert_equal(nil, ex);
- end
-
- def test_s_new_with_nil
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I2)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I2, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I4)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_R4)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_R4, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_R8)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_R8, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_CY)
- assert_equal("0", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_CY, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DATE)
- assert_equal("1899/12/30 00:00:00", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_DATE, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_BSTR)
- assert_equal("", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
- assert_nil(obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_DISPATCH, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_BOOL)
- assert_equal(false, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_BOOL, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT)
- assert_nil(obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_VARIANT, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I1)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I1, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI1)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI1, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI2)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI2, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI4)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI4, obj.vartype)
-
-
- if defined?(WIN32OLE::VARIANT::VT_I8)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I8)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I8, obj.vartype)
- end
-
- if defined?(WIN32OLE::VARIANT::VT_UI8)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI8)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI8, obj.vartype)
- end
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_INT)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_INT, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UINT)
- assert_equal(0, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UINT, obj.vartype)
- end
-
- def test_s_new_with_non_nil
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I2)
- assert_equal(2, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I2, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_I4)
- assert_equal(3, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(4.5, WIN32OLE::VARIANT::VT_R4)
- assert_equal(4.5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_R4, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(5.5, WIN32OLE::VARIANT::VT_R8)
- assert_equal(5.5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_R8, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(600, WIN32OLE::VARIANT::VT_CY)
- assert_equal("600", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_CY, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2001/06/15 12:17:34", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_DATE, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new("foo", WIN32OLE::VARIANT::VT_BSTR)
- assert_equal("foo", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(true, WIN32OLE::VARIANT::VT_BOOL)
- assert_equal(true, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_BOOL, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I1)
- assert_equal(2, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I1, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_UI1)
- assert_equal(3, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI1, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_UI2)
- assert_equal(4, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI2, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UI4)
- assert_equal(5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI4, obj.vartype)
-
- if defined?(WIN32OLE::VARIANT::VT_I8)
- obj = WIN32OLE_VARIANT.new(-123456789012345, WIN32OLE::VARIANT::VT_I8)
- assert_equal(-123456789012345, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I8, obj.vartype)
- end
-
- if defined?(WIN32OLE::VARIANT::VT_UI8)
- obj = WIN32OLE_VARIANT.new(123456789012345, WIN32OLE::VARIANT::VT_UI8)
- assert_equal(123456789012345, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI8, obj.vartype)
- end
-
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_INT)
- assert_equal(4, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_INT, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UINT)
- assert_equal(5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UINT, obj.vartype)
- end
-
- def test_s_new_with_non_nil_byref
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(2, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(3, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(4.5, WIN32OLE::VARIANT::VT_R4|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(4.5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_R4|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(5.5, WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(5.5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(600, WIN32OLE::VARIANT::VT_CY|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal("600", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_CY|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal("2001/06/15 12:17:34", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new("foo", WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal("foo", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(true, WIN32OLE::VARIANT::VT_BOOL|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(true, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_BOOL|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I1|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(2, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I1|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(3, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_UI2|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(4, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI2|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UI4|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI4|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_INT|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(4, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_INT|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UINT|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(5, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UINT|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- end
-
- # This test is failed in cygwin.
- # The tagVARIANT definition has no union member pllVal in cygwin.
- def test_s_new_with_i8_byref
- if defined?(WIN32OLE::VARIANT::VT_I8) && /mswin/ =~ RUBY_PLATFORM
- obj = WIN32OLE_VARIANT.new(-123456789012345, WIN32OLE::VARIANT::VT_I8|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(-123456789012345, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- else
- STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_new_with_i8_byref is skipped")
- end
- end
-
- # This test is failed in cygwin.
- # The tagVARIANT definition has no union member pullVal in cygwin.
- def test_s_new_with_ui8_byref
- if defined?(WIN32OLE::VARIANT::VT_UI8) && /mswin/ =~ RUBY_PLATFORM
- obj = WIN32OLE_VARIANT.new(123456789012345, WIN32OLE::VARIANT::VT_UI8|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(123456789012345, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_UI8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- else
- STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_new_with_ui8_byref is skipped.")
- end
- end
-
- def test_value
- obj = WIN32OLE_VARIANT.new('foo')
- assert_equal('foo', obj.value)
- end
-
- def test_s_new_2_argument
- obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal('foo', obj.value);
- end
-
- def test_s_new_2_argument2
- obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR)
- assert_equal('foo', obj.value);
- end
-
- def test_s_new_dispatch_array
- vt = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH
- obj = WIN32OLE_VARIANT.new(nil, vt)
- assert_equal(vt, obj.vartype)
- assert_nil(obj.value)
-
- vt = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH|WIN32OLE::VARIANT::VT_BYREF
- obj = WIN32OLE_VARIANT.new(nil, vt)
- assert_equal(vt, obj.vartype)
- assert_nil(obj.value)
- end
-
- def test_s_array
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4)
- assert_instance_of(WIN32OLE_VARIANT, obj)
- assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY, obj.vartype)
- assert_equal([[0, 0, 0],[0, 0, 0]], obj.value)
-
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_ARRAY, obj.vartype)
- assert_equal([[0, 0, 0],[0, 0, 0]], obj.value)
-
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY)
- assert_instance_of(WIN32OLE_VARIANT, obj)
- assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY, obj.vartype)
- assert_equal([[0, 0, 0],[0, 0, 0]], obj.value)
-
- assert_equal(0, obj[0,0])
- obj[0,0] = 10
- assert_equal([[10, 0, 0],[0, 0, 0]], obj.value)
- obj[0,1] = "13.2"
- assert_equal([[10, 13, 0],[0, 0, 0]], obj.value)
-
- obj = WIN32OLE_VARIANT.array([3, 2], WIN32OLE::VARIANT::VT_VARIANT)
- obj[0,0] = 10
- obj[0,1] = "string"
- obj[1,0] = 12.735
- assert_equal([[10, "string"],[12.735, nil],[nil,nil]], obj.value)
-
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_DISPATCH)
- assert_equal([[nil, nil, nil],[nil,nil,nil]], obj.value)
- end
-
- def test_s_array_exc
- assert_raise(TypeError) {
- obj = WIN32OLE_VARIANT.array(2, WIN32OLE::VARIANT::VT_I4)
- }
- end
-
- def test_conversion_num2str
- obj = WIN32OLE_VARIANT.new(124, WIN32OLE::VARIANT::VT_BSTR)
- assert_equal("124", obj.value);
- end
-
- def test_conversion_float2int
- obj = WIN32OLE_VARIANT.new(12.345, WIN32OLE::VARIANT::VT_I4)
- assert_equal(12, obj.value)
- obj = WIN32OLE_VARIANT.new(12.345, WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal(12, obj.value)
- end
-
- def test_conversion_str2num
- obj = WIN32OLE_VARIANT.new("12.345", WIN32OLE::VARIANT::VT_R8)
- assert_equal(12.345, obj.value)
- end
-
- def test_conversion_ole_variant2ole_variant
- obj = WIN32OLE_VARIANT.new("12.345", WIN32OLE::VARIANT::VT_R4)
- obj = WIN32OLE_VARIANT.new(obj, WIN32OLE::VARIANT::VT_I4)
- assert_equal(12, obj.value)
- end
-
- def test_conversion_str2date
- obj = WIN32OLE_VARIANT.new("2004-12-24 12:24:45", WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2004/12/24 12:24:45", obj.value)
- end
-
- def test_conversion_time2date
- dt = Time.mktime(2004, 12, 24, 12, 24, 45)
- obj = WIN32OLE_VARIANT.new(dt, WIN32OLE::VARIANT::VT_DATE)
- assert_equal("2004/12/24 12:24:45", obj.value)
- end
-
- def test_conversion_str2cy
- begin
- WIN32OLE.locale = 0x0411 # set locale Japanese
- obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
- assert_equal("10000", obj.value)
- ensure
- WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT
- end
- end
-
- def test_create_vt_array
- obj = WIN32OLE_VARIANT.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8)
- assert_equal([1.2, 2.3], obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal([1.2, 2.3], obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- end
-
- def test_create_vt_array2
- obj = WIN32OLE_VARIANT.new([1.2, "a"], WIN32OLE::VARIANT::VT_ARRAY)
- assert_equal([1.2, "a"], obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_VARIANT, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new([1.2, "a"])
- assert_equal([1.2, "a"], obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_VARIANT, obj.vartype)
- end
-
-
- def test_create_vt_nested_array
- obj = WIN32OLE_VARIANT.new([[1.2, "a", "b"], [3.4, "C", "D"]], WIN32OLE::VARIANT::VT_ARRAY)
- assert_equal([[1.2, "a", "b"], [3.4, "C", "D"]], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[1.2, "a", "b"], [3.4, "C", "D"]])
- assert_equal([[1.2, "a", "b"], [3.4, "C", "D"]], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[1.2, "a", "b"], [3.4, "C", "D"], [5.6, "E", "F"]])
- assert_equal([[1.2, "a", "b"], [3.4, "C", "D"], [5.6, "E", "F"]], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[[1.2], [3.4]], [[5.6], [7.8]], [[9.1],[9.2]]])
- assert_equal([[[1.2], [3.4]], [[5.6], [7.8]], [[9.1],[9.2]]], obj.value)
- end
-
- def test_create_vt_array3
- obj = WIN32OLE_VARIANT.new([])
- assert_equal([], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[]])
- assert_equal([[]], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[],[]])
- assert_equal([[],[]], obj.value)
-
- obj = WIN32OLE_VARIANT.new([], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal([], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[]], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal([[]], obj.value)
-
- obj = WIN32OLE_VARIANT.new([[],[]], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal([[],[]], obj.value)
- end
-
- def test_create_vt_array_nil
- vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH|WIN32OLE::VARIANT::VT_BYREF
- obj = WIN32OLE_VARIANT.new(nil, vartype)
- assert_nil(obj.value)
- assert_equal(vartype, obj.vartype)
-
- vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH
- obj = WIN32OLE_VARIANT.new(nil, vartype)
- assert_nil(obj.value)
- assert_equal(vartype, obj.vartype)
- end
-
- def test_create_vt_array_str
- vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BSTR
- obj = WIN32OLE_VARIANT.new(["abc", "123"], vartype)
- assert_equal(vartype, obj.vartype)
- assert_equal(["abc", "123"], obj.value)
-
- vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_BSTR
- obj = WIN32OLE_VARIANT.new(["abc", "123"], vartype)
- assert_equal(vartype, obj.vartype)
- assert_equal(["abc", "123"], obj.value)
- end
-
- def test_create_vt_array_exc
- exc = assert_raise(TypeError) {
- obj = WIN32OLE_VARIANT.new(1, WIN32OLE::VARIANT::VT_ARRAY);
- }
- assert_match(/wrong argument type Fixnum \(expected Array\)/, exc.message)
- end
-
- def test_create_vt_array_str2ui1array
- obj = WIN32OLE_VARIANT.new("ABC", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
- assert_equal("ABC", obj.value)
-
- obj.value = "DEF"
- assert_equal("DEF", obj.value)
- obj[0] = 71
- assert_equal("GEF", obj.value)
-
- obj = WIN32OLE_VARIANT.new([65, 0].pack("C*"), WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
- assert_equal([65, 0].pack("C*"), obj.value)
-
- obj = WIN32OLE_VARIANT.new("abc", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF)
- assert_equal("abc", obj.value)
- obj.value = "DEF"
- assert_equal("DEF", obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj[1] = 71
- assert_equal("DGF", obj.value)
-
- end
-
- def test_create_vt_array_int
- obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
- assert_equal([65, 0].pack("C*"), obj.value)
-
- obj = WIN32OLE_VARIANT.new([65, 0])
- assert_equal([65, 0], obj.value)
-
- obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_ARRAY)
- assert_equal([65, 0], obj.value)
-
- end
-
- def test_vt_array_bracket
- obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]])
- assert_equal(1, obj[0,0])
- assert_equal(2, obj[0,1])
- assert_equal(3, obj[0,2])
- assert_equal(4, obj[1,0])
- assert_equal(5, obj[1,1])
- assert_equal(6, obj[1,2])
-
- assert_raise(WIN32OLERuntimeError) {
- obj[0,4]
- }
- assert_raise(WIN32OLERuntimeError) {
- obj[0,-1]
- }
- assert_raise(ArgumentError) {
- obj[0]
- }
-
- obj[0,0] = 7
- obj[1,2] = 8
- assert_equal([[7,2,3], [4,5,8]], obj.value)
-
- assert_raise(WIN32OLERuntimeError) {
- obj[0,4] = 9
- }
- assert_raise(WIN32OLERuntimeError) {
- obj[0,-1] = 10
- }
- assert_raise(ArgumentError) {
- obj[0] = 11
- }
- end
-
- def test_create_nil_dispatch
- var = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
- assert_nil(var.value)
- end
-
- def test_create_variant_byref
- obj = WIN32OLE_VARIANT.new("Str", WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF);
- assert_equal("Str", obj.value);
- end
-
- def test_vartype
- obj = WIN32OLE_VARIANT.new("Str")
- assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
- end
-
- def test_set_value
- obj = WIN32OLE_VARIANT.new(10)
- obj.value = 12
- assert_equal(12, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
- obj.value = "14"
- assert_equal(14, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
- obj.value = 11.2
- assert_equal(11, obj.value)
- assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
-
- obj = WIN32OLE_VARIANT.new([1,2])
- assert_raise(WIN32OLERuntimeError) {
- obj.value = [3,4]
- }
-
- obj = WIN32OLE_VARIANT.new("2007/01/01", WIN32OLE::VARIANT::VT_DATE)
- assert_raise(WIN32OLERuntimeError) {
- obj.value = "hogehoge"
- }
- assert_equal("2007/01/01 00:00:00", obj.value)
-
- obj2 = WIN32OLE_VARIANT.new("2006/01/01", WIN32OLE::VARIANT::VT_DATE)
- obj.value = obj2
- assert_equal("2006/01/01 00:00:00", obj.value)
- end
-
- def test_c_nothing
- assert_nil(WIN32OLE_VARIANT::Nothing.value)
- end
-
- def test_c_empty
- assert_nil(WIN32OLE_VARIANT::Empty.value)
- end
-
- def test_c_null
- assert_nil(WIN32OLE_VARIANT::Null.value)
- end
-
- end
-end
-
diff --git a/test/win32ole/test_win32ole_variant_m.rb b/test/win32ole/test_win32ole_variant_m.rb
deleted file mode 100644
index b3e48c20f0..0000000000
--- a/test/win32ole/test_win32ole_variant_m.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE::VARIANT)
- class TestWin32OLE_VARIANT_MODULE < Test::Unit::TestCase
- include WIN32OLE::VARIANT
- def test_variant
- assert_equal(0, VT_EMPTY)
- assert_equal(1, VT_NULL)
- assert_equal(2, VT_I2)
- assert_equal(3, VT_I4)
- assert_equal(4, VT_R4)
- assert_equal(5, VT_R8)
- assert_equal(6, VT_CY)
- assert_equal(7, VT_DATE)
- assert_equal(8, VT_BSTR)
- assert_equal(9, VT_DISPATCH)
- assert_equal(10, VT_ERROR)
- assert_equal(11, VT_BOOL)
- assert_equal(12, VT_VARIANT)
- assert_equal(13, VT_UNKNOWN)
- assert_equal(16, VT_I1)
- assert_equal(17, VT_UI1)
- assert_equal(18, VT_UI2)
- assert_equal(19, VT_UI4)
- assert_equal(22, VT_INT)
- assert_equal(23, VT_UINT)
- assert_equal(0x2000, VT_ARRAY)
- assert_equal(0x4000, VT_BYREF)
- end
- end
-end
diff --git a/test/win32ole/test_win32ole_variant_with_ie.rb b/test/win32ole/test_win32ole_variant_with_ie.rb
deleted file mode 100644
index 680f17ff54..0000000000
--- a/test/win32ole/test_win32ole_variant_with_ie.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# This is test script to check WIN32OLE_VARIANT using Internet Explorer
-begin
- require 'win32ole'
-rescue LoadError
-end
-require 'test/unit'
-
-if defined?(WIN32OLE)
- class TestWIN32OLE_VARIANT_WITH_IE < Test::Unit::TestCase
- def create_temp_html
- fso = WIN32OLE.new('Scripting.FileSystemObject')
- dummy_file = fso.GetTempName + ".html"
- cfolder = fso.getFolder(".")
- f = cfolder.CreateTextFile(dummy_file)
- f.writeLine("<html><body>This is test HTML file for Win32OLE.</body></html>")
- f.close
- dummy_path = cfolder.path + "\\" + dummy_file
- dummy_path
- end
- def setup
- @f = create_temp_html
- @ie = WIN32OLE.new('InternetExplorer.Application')
- @ie.visible = true
- @ie.navigate("file:///#{@f}")
- while @ie.busy
- sleep 0.5
- end
- end
- def test_variant_ref_and_argv
- @ie.execWB(19, 0, nil, -1)
- size = WIN32OLE::ARGV[3]
- assert(size >= 0)
-
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
- @ie.execWb(19, 0, nil, obj)
- assert_equal(size, obj.value)
- assert_equal(size, WIN32OLE::ARGV[3])
-
- obj = WIN32OLE_VARIANT.new(-1, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
- @ie.execWb(19, 0, nil, obj)
- assert_equal(size, obj.value)
- assert_equal(size, WIN32OLE::ARGV[3])
- end
-
- def teardown
- File.unlink(@f)
- if @ie
- @ie.quit
- @ie = nil
- end
- end
- end
-end
diff --git a/test/win32ole/test_word.rb b/test/win32ole/test_word.rb
deleted file mode 100644
index 2b455c6167..0000000000
--- a/test/win32ole/test_word.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# This is test for [ruby-Bugs#3237]
-#
-begin
- require 'win32ole'
-rescue LoadError
-end
-require "test/unit"
-
-if defined?(WIN32OLE)
- class TestWIN32OLE_WITH_WORD < Test::Unit::TestCase
-
- def setup
- begin
- @obj = WIN32OLE.new('Word.Application')
- rescue WIN32OLERuntimeError
- @obj = nil
- end
- end
-
- def test_ole_methods
- if @obj
- @obj.visible = true
- @obj.wordbasic.disableAutoMacros(true)
- assert(true)
- end
- end
-
- def test_s_connect
- if @obj
- obj2 = WIN32OLE.connect("Word.Application")
- assert_instance_of(WIN32OLE, obj2)
- obj2.visible = true
- end
- end
-
- def teardown
- if @obj
- @obj.quit
- @obj = nil
- end
- end
-
- end
-end
diff --git a/test/wsdl/any/any.wsdl b/test/wsdl/any/any.wsdl
new file mode 100644
index 0000000000..4d1f73a8cd
--- /dev/null
+++ b/test/wsdl/any/any.wsdl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="echo"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="urn:example.com:echo"
+ xmlns:txd="urn:example.com:echo-type"
+ targetNamespace="urn:example.com:echo"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema targetNamespace="urn:example.com:echo-type">
+ <xsd:complexType name="foo.bar">
+ <xsd:sequence>
+ <xsd:any />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </types>
+
+ <message name="msg_echoitem">
+ <part name="echoitem" type="txd:foo.bar"/>
+ </message>
+
+ <portType name="echo_port_type">
+ <operation name="echo">
+ <input message="tns:msg_echoitem"/>
+ <output message="tns:msg_echoitem"/>
+ </operation>
+ </portType>
+
+ <binding name="echo_binding" type="tns:echo_port_type">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
+ <operation name="echo">
+ <soap:operation soapAction="urn:example.com:echo"/>
+ <input>
+ <soap:body use="encoded" namespace="urn:example.com:echo"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body use="encoded" namespace="urn:example.com:echo"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="echo_service">
+ <port name="echo_port" binding="tns:echo_binding">
+ <soap:address location="http://localhost:10080"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/any/expectedDriver.rb b/test/wsdl/any/expectedDriver.rb
new file mode 100644
index 0000000000..6d1827fb94
--- /dev/null
+++ b/test/wsdl/any/expectedDriver.rb
@@ -0,0 +1,54 @@
+require 'echo.rb'
+
+require 'soap/rpc/driver'
+
+class Echo_port_type < ::SOAP::RPC::Driver
+ DefaultEndpointUrl = "http://localhost:10080"
+ MappingRegistry = ::SOAP::Mapping::Registry.new
+
+ MappingRegistry.set(
+ FooBar,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("urn:example.com:echo-type", "foo.bar") }
+ )
+
+ Methods = [
+ [ XSD::QName.new("urn:example.com:echo", "echo"),
+ "urn:example.com:echo",
+ "echo",
+ [ ["in", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]],
+ ["retval", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]] ],
+ { :request_style => :rpc, :request_use => :encoded,
+ :response_style => :rpc, :response_use => :encoded }
+ ]
+ ]
+
+ def initialize(endpoint_url = nil)
+ endpoint_url ||= DefaultEndpointUrl
+ super(endpoint_url, nil)
+ self.mapping_registry = MappingRegistry
+ init_methods
+ end
+
+private
+
+ def init_methods
+ Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ add_document_operation(*definitions)
+ else
+ add_rpc_operation(*definitions)
+ qname = definitions[0]
+ name = definitions[2]
+ if qname.name != name and qname.name.capitalize == name.capitalize
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
+ __send__(name, *arg)
+ end
+ end
+ end
+ end
+ end
+end
+
diff --git a/test/wsdl/any/expectedEcho.rb b/test/wsdl/any/expectedEcho.rb
new file mode 100644
index 0000000000..456950dfef
--- /dev/null
+++ b/test/wsdl/any/expectedEcho.rb
@@ -0,0 +1,14 @@
+require 'xsd/qname'
+
+# {urn:example.com:echo-type}foo.bar
+class FooBar
+ @@schema_type = "foo.bar"
+ @@schema_ns = "urn:example.com:echo-type"
+ @@schema_element = [["any", [nil, XSD::QName.new(nil, "any")]]]
+
+ attr_accessor :any
+
+ def initialize(any = nil)
+ @any = any
+ end
+end
diff --git a/test/wsdl/any/expectedService.rb b/test/wsdl/any/expectedService.rb
new file mode 100644
index 0000000000..e3885e7c6c
--- /dev/null
+++ b/test/wsdl/any/expectedService.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+require 'echoServant.rb'
+
+require 'soap/rpc/standaloneServer'
+require 'soap/mapping/registry'
+
+class Echo_port_type
+ MappingRegistry = ::SOAP::Mapping::Registry.new
+
+ MappingRegistry.set(
+ FooBar,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("urn:example.com:echo-type", "foo.bar") }
+ )
+
+ Methods = [
+ [ XSD::QName.new("urn:example.com:echo", "echo"),
+ "urn:example.com:echo",
+ "echo",
+ [ ["in", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]],
+ ["retval", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]] ],
+ { :request_style => :rpc, :request_use => :encoded,
+ :response_style => :rpc, :response_use => :encoded }
+ ]
+ ]
+end
+
+class Echo_port_typeApp < ::SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super(*arg)
+ servant = Echo_port_type.new
+ Echo_port_type::Methods.each do |definitions|
+ opt = definitions.last
+ if opt[:request_style] == :document
+ @router.add_document_operation(servant, *definitions)
+ else
+ @router.add_rpc_operation(servant, *definitions)
+ end
+ end
+ self.mapping_registry = Echo_port_type::MappingRegistry
+ end
+end
+
+if $0 == __FILE__
+ # Change listen port.
+ server = Echo_port_typeApp.new('app', nil, '0.0.0.0', 10080)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
+end
diff --git a/test/wsdl/any/test_any.rb b/test/wsdl/any/test_any.rb
new file mode 100644
index 0000000000..aab5eb631f
--- /dev/null
+++ b/test/wsdl/any/test_any.rb
@@ -0,0 +1,58 @@
+require 'test/unit'
+require 'wsdl/parser'
+require 'wsdl/soap/wsdl2ruby'
+module WSDL; module Any
+
+
+class TestAny < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+
+ def test_any
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("any.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['driver'] = nil
+ gen.opt['client_skelton'] = nil
+ gen.opt['servant_skelton'] = nil
+ gen.opt['standalone_server_stub'] = nil
+ gen.opt['force'] = true
+ suppress_warning do
+ gen.run
+ end
+ compare("expectedDriver.rb", "echoDriver.rb")
+ compare("expectedEcho.rb", "echo.rb")
+ compare("expectedService.rb", "echo_service.rb")
+
+ File.unlink(pathname("echo_service.rb"))
+ File.unlink(pathname("echo.rb"))
+ File.unlink(pathname("echo_serviceClient.rb"))
+ File.unlink(pathname("echoDriver.rb"))
+ File.unlink(pathname("echoServant.rb"))
+ end
+
+ def compare(expected, actual)
+ assert_equal(loadfile(expected), loadfile(actual), actual)
+ end
+
+ def loadfile(file)
+ File.open(pathname(file)) { |f| f.read }
+ end
+
+ def suppress_warning
+ back = $VERBOSE
+ $VERBOSE = nil
+ begin
+ yield
+ ensure
+ $VERBOSE = back
+ end
+ end
+end
+
+
+end; end
diff --git a/test/wsdl/axisArray/axisArray.wsdl b/test/wsdl/axisArray/axisArray.wsdl
new file mode 100644
index 0000000000..3602edb748
--- /dev/null
+++ b/test/wsdl/axisArray/axisArray.wsdl
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name = "itemList"
+ targetNamespace="urn:jp.gr.jin.rrr.example.itemList"
+ xmlns:tns="urn:jp.gr.jin.rrr.example.itemList"
+ xmlns:typens="urn:jp.gr.jin.rrr.example.itemListType"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="urn:jp.gr.jin.rrr.example.itemListType"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
+ <complexType name="Item">
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="ItemList">
+ <sequence>
+ <element maxOccurs="unbounded" minOccurs="0" name="Item" type="typens:Item"/>
+ </sequence>
+ </complexType>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="listItemRequest"/>
+
+ <wsdl:message name="listItemResponse">
+ <wsdl:part name="list" type="typens:ItemList"/>
+ </wsdl:message>
+
+ <wsdl:portType name="ItemListPortType">
+ <wsdl:operation name="listItem">
+ <wsdl:input message="tns:listItemRequest" name="listItemRequest"/>
+ <wsdl:output message="tns:listItemResponse" name="listItemResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="ItemListBinding" type="tns:ItemListPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="listItem">
+ <soap:operation soapAction=""/>
+ <wsdl:input name="listItemRequest">
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:jp.gr.jin.rrr.example.itemList" use="encoded"/>
+ </wsdl:input>
+ <wsdl:output name="listItemResponse">
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:jp.gr.jin.rrr.example.itemList" use="encoded"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="ItemListService">
+ <wsdl:port binding="tns:ItemListBinding" name="ItemListPort">
+ <soap:address location="http://localhost:10080/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/test/wsdl/axisArray/itemList.rb b/test/wsdl/axisArray/itemList.rb
new file mode 100644
index 0000000000..b81297ed37
--- /dev/null
+++ b/test/wsdl/axisArray/itemList.rb
@@ -0,0 +1,27 @@
+# Generated by wsdl2ruby.rb with axisArray.wsdl.
+
+# urn:jp.gr.jin.rrr.example.itemListType
+class Item
+ @@schema_type = "Item"
+ @@schema_ns = "urn:jp.gr.jin.rrr.example.itemListType"
+
+ def name
+ @name
+ end
+
+ def name=(value)
+ @name = value
+ end
+
+ def initialize(name = nil)
+ @name = name
+ end
+end
+
+# urn:jp.gr.jin.rrr.example.itemListType
+class ItemList < Array
+ # Contents type should be dumped here...
+ @@schema_type = "ItemList"
+ @@schema_ns = "urn:jp.gr.jin.rrr.example.itemListType"
+end
+
diff --git a/test/wsdl/axisArray/test_axisarray.rb b/test/wsdl/axisArray/test_axisarray.rb
new file mode 100644
index 0000000000..9f220bb48a
--- /dev/null
+++ b/test/wsdl/axisArray/test_axisarray.rb
@@ -0,0 +1,69 @@
+require 'test/unit'
+require 'soap/processor'
+require 'soap/mapping'
+require 'soap/rpc/element'
+require 'wsdl/importer'
+require 'itemList.rb'
+
+
+module WSDL
+
+
+class TestAxisArray < Test::Unit::TestCase
+ def setup
+ @xml =<<__EOX__
+<?xml version="1.0" encoding="UTF-8"?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <soapenv:Body>
+ <ns1:listItemResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:jp.gr.jin.rrr.example.itemList">
+ <list href="#id0"/>
+ </ns1:listItemResponse>
+ <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:ItemList" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:jp.gr.jin.rrr.example.itemListType">
+ <Item href="#id1"/>
+ <Item href="#id2"/>
+ <Item href="#id3"/>
+ </multiRef>
+ <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Item" xmlns:ns3="urn:jp.gr.jin.rrr.example.itemListType" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
+ <name xsi:type="xsd:string">name3</name>
+ </multiRef>
+ <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:Item" xmlns:ns4="urn:jp.gr.jin.rrr.example.itemListType" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
+ <name xsi:type="xsd:string">name1</name>
+ </multiRef>
+ <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:Item" xmlns:ns5="urn:jp.gr.jin.rrr.example.itemListType" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
+ <name xsi:type="xsd:string">name2</name>
+ </multiRef>
+ </soapenv:Body>
+</soapenv:Envelope>
+__EOX__
+ end
+
+ def test_by_stub
+ header, body = ::SOAP::Processor.unmarshal(@xml)
+ ary = ::SOAP::Mapping.soap2obj(body.response)
+ assert_equal(3, ary.size)
+ assert_equal("name1", ary[0].name)
+ assert_equal("name2", ary[1].name)
+ assert_equal("name3", ary[2].name)
+ end
+
+ def test_by_wsdl
+ wsdlfile = File.join(File.dirname(File.expand_path(__FILE__)), 'axisArray.wsdl')
+ wsdl = WSDL::Importer.import(wsdlfile)
+ service = wsdl.services[0]
+ port = service.ports[0]
+ wsdl_types = wsdl.collect_complextypes
+ rpc_decode_typemap = wsdl_types + wsdl.soap_rpc_complextypes(port.find_binding)
+ opt = {}
+ opt[:default_encodingstyle] = ::SOAP::EncodingNamespace
+ opt[:decode_typemap] = rpc_decode_typemap
+ header, body = ::SOAP::Processor.unmarshal(@xml, opt)
+ ary = ::SOAP::Mapping.soap2obj(body.response)
+ assert_equal(3, ary.size)
+ assert_equal("name1", ary[0].name)
+ assert_equal("name2", ary[1].name)
+ assert_equal("name3", ary[2].name)
+ end
+end
+
+
+end
diff --git a/test/wsdl/datetime/DatetimeService.rb b/test/wsdl/datetime/DatetimeService.rb
new file mode 100644
index 0000000000..800e06d66f
--- /dev/null
+++ b/test/wsdl/datetime/DatetimeService.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+require 'datetimeServant.rb'
+
+require 'soap/rpc/standaloneServer'
+require 'soap/mapping/registry'
+
+class DatetimePortType
+ MappingRegistry = ::SOAP::Mapping::Registry.new
+
+ Methods = [
+ ["now", "now",
+ [
+ ["in", "now", [::SOAP::SOAPDateTime]],
+ ["retval", "now", [::SOAP::SOAPDateTime]]
+ ],
+ "", "urn:jp.gr.jin.rrr.example.datetime", :rpc
+ ]
+ ]
+end
+
+class DatetimePortTypeApp < ::SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super(*arg)
+ servant = DatetimePortType.new
+ DatetimePortType::Methods.each do |name_as, name, param_def, soapaction, namespace, style|
+ if style == :document
+ @router.add_document_operation(servant, soapaction, name, param_def)
+ else
+ qname = XSD::QName.new(namespace, name_as)
+ @router.add_rpc_operation(servant, qname, soapaction, name, param_def)
+ end
+ end
+ self.mapping_registry = DatetimePortType::MappingRegistry
+ end
+end
+
+if $0 == __FILE__
+ # Change listen port.
+ server = DatetimePortTypeApp.new('app', nil, '0.0.0.0', 10080)
+ trap(:INT) do
+ server.shutdown
+ end
+ server.start
+end
diff --git a/benchmark/bmx_temp.rb b/test/wsdl/datetime/datetime.rb
index e69de29bb2..e69de29bb2 100644
--- a/benchmark/bmx_temp.rb
+++ b/test/wsdl/datetime/datetime.rb
diff --git a/test/wsdl/datetime/datetime.wsdl b/test/wsdl/datetime/datetime.wsdl
new file mode 100644
index 0000000000..4998dc48d6
--- /dev/null
+++ b/test/wsdl/datetime/datetime.wsdl
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name = "datetime"
+ targetNamespace="urn:jp.gr.jin.rrr.example.datetime"
+ xmlns:tns="urn:jp.gr.jin.rrr.example.datetime"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <wsdl:message name="nowRequest">
+ <wsdl:part name="now" type="xsd:dateTime"/>
+ </wsdl:message>
+
+ <wsdl:message name="nowResponse">
+ <wsdl:part name="now" type="xsd:dateTime"/>
+ </wsdl:message>
+
+ <wsdl:portType name="DatetimePortType">
+ <wsdl:operation name="now">
+ <wsdl:input message="tns:nowRequest" name="nowRequest"/>
+ <wsdl:output message="tns:nowResponse" name="nowResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="DatetimeBinding" type="tns:DatetimePortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="now">
+ <soap:operation soapAction=""/>
+ <wsdl:input name="nowRequest">
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:jp.gr.jin.rrr.example.datetime" use="encoded"/>
+ </wsdl:input>
+ <wsdl:output name="nowResponse">
+ <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:jp.gr.jin.rrr.example.datetime" use="encoded"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="DatetimeService">
+ <wsdl:port binding="tns:DatetimeBinding" name="DatetimePort">
+ <soap:address location="http://localhost:10080/"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/test/wsdl/datetime/datetimeServant.rb b/test/wsdl/datetime/datetimeServant.rb
new file mode 100644
index 0000000000..14145c42e5
--- /dev/null
+++ b/test/wsdl/datetime/datetimeServant.rb
@@ -0,0 +1,21 @@
+require 'datetime.rb'
+
+class DatetimePortType
+ # SYNOPSIS
+ # now(now)
+ #
+ # ARGS
+ # now - {http://www.w3.org/2001/XMLSchema}dateTime
+ #
+ # RETURNS
+ # now - {http://www.w3.org/2001/XMLSchema}dateTime
+ #
+ # RAISES
+ # (undefined)
+ #
+ def now(now)
+ #raise NotImplementedError.new
+ now + 1
+ end
+end
+
diff --git a/test/wsdl/datetime/test_datetime.rb b/test/wsdl/datetime/test_datetime.rb
new file mode 100644
index 0000000000..7652318205
--- /dev/null
+++ b/test/wsdl/datetime/test_datetime.rb
@@ -0,0 +1,82 @@
+require 'test/unit'
+require 'soap/wsdlDriver'
+require 'DatetimeService.rb'
+
+
+module WSDL
+module Datetime
+
+
+class TestDatetime < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = DatetimePortTypeApp.new('Datetime server', nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'datetime.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = true
+ @client.wiredump_dev = STDOUT if $DEBUG
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_datetime
+ d = DateTime.now
+ d1 = d + 1
+ d2 = @client.now(d)
+ assert_equal(d1.year, d2.year)
+ assert_equal(d1.month, d2.month)
+ assert_equal(d1.day, d2.day)
+ assert_equal(d1.hour, d2.hour)
+ assert_equal(d1.min, d2.min)
+ assert_equal(d1.sec, d2.sec)
+ assert_equal(d1.sec, d2.sec)
+ end
+
+ def test_time
+ d = DateTime.now
+ t = Time.gm(d.year, d.month, d.day, d.hour, d.min, d.sec)
+ d1 = d + 1
+ d2 = @client.now(t)
+ assert_equal(d1.year, d2.year)
+ assert_equal(d1.month, d2.month)
+ assert_equal(d1.day, d2.day)
+ assert_equal(d1.hour, d2.hour)
+ assert_equal(d1.min, d2.min)
+ assert_equal(d1.sec, d2.sec)
+ assert_equal(d1.sec, d2.sec)
+ end
+end
+
+
+end
+end
diff --git a/test/wsdl/document/document.wsdl b/test/wsdl/document/document.wsdl
new file mode 100644
index 0000000000..fbf03fae8b
--- /dev/null
+++ b/test/wsdl/document/document.wsdl
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions
+ name="echo"
+ targetNamespace="urn:docrpc"
+ xmlns:tns="urn:docrpc"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema elementFormDefault="unqualified" targetNamespace="urn:docrpc">
+ <xsd:complexType name="echo_struct">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="m_string" type="xsd:string" />
+ <xsd:element minOccurs="0" maxOccurs="1" name="m_datetime" type="xsd:dateTime" />
+ </xsd:sequence>
+ <xsd:attribute name="m_attr" type="xsd:string" />
+ </xsd:complexType>
+
+ <xsd:element name="echoele">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="struct1" type="tns:echo_struct" />
+ <xsd:element minOccurs="0" maxOccurs="1" name="struct-2" type="tns:echo_struct" />
+ </xsd:sequence>
+ <xsd:attribute name="attr_string" type="xsd:string" />
+ <xsd:attribute name="attr-int" type="xsd:int" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="echo_response">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="struct1" type="tns:echo_struct" />
+ <xsd:element minOccurs="0" maxOccurs="1" name="struct-2" type="tns:echo_struct" />
+ </xsd:sequence>
+ <xsd:attribute name="attr_string" type="xsd:string" />
+ <xsd:attribute name="attr-int" type="xsd:int" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </types>
+
+ <message name="echo_in">
+ <part name="parameters" element="tns:echoele" />
+ </message>
+ <message name="echo_out">
+ <part name="parameters" element="tns:echo_response" />
+ </message>
+
+ <portType name="docrpc_porttype">
+ <operation name="echo">
+ <input message="tns:echo_in" />
+ <output message="tns:echo_out" />
+ </operation>
+ </portType>
+
+ <binding name="docrpc_binding" type="tns:docrpc_porttype">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <operation name="echo">
+ <soap:operation soapAction="urn:docrpc:echo" style="document" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ </operation>
+ </binding>
+
+ <service name="docrpc_service">
+ <port name="docprc_service_port" binding="tns:docrpc_binding">
+ <soap:address location="http://localhost:17171/" />
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/document/echo.rb b/test/wsdl/document/echo.rb
new file mode 100644
index 0000000000..c6df75aca0
--- /dev/null
+++ b/test/wsdl/document/echo.rb
@@ -0,0 +1,92 @@
+require 'xsd/qname'
+
+# {urn:docrpc}echoele
+class Echoele
+ @@schema_type = "echoele"
+ @@schema_ns = "urn:docrpc"
+ @@schema_attribute = {XSD::QName.new(nil, "attr_string") => "SOAP::SOAPString", XSD::QName.new(nil, "attr-int") => "SOAP::SOAPInt"}
+ @@schema_element = [["struct1", ["Echo_struct", XSD::QName.new(nil, "struct1")]], ["struct_2", ["Echo_struct", XSD::QName.new(nil, "struct-2")]]]
+
+ attr_accessor :struct1
+ attr_accessor :struct_2
+
+ def xmlattr_attr_string
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr_string")]
+ end
+
+ def xmlattr_attr_string=(value)
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr_string")] = value
+ end
+
+ def xmlattr_attr_int
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr-int")]
+ end
+
+ def xmlattr_attr_int=(value)
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr-int")] = value
+ end
+
+ def initialize(struct1 = nil, struct_2 = nil)
+ @struct1 = struct1
+ @struct_2 = struct_2
+ @__xmlattr = {}
+ end
+end
+
+# {urn:docrpc}echo_response
+class Echo_response
+ @@schema_type = "echo_response"
+ @@schema_ns = "urn:docrpc"
+ @@schema_attribute = {XSD::QName.new(nil, "attr_string") => "SOAP::SOAPString", XSD::QName.new(nil, "attr-int") => "SOAP::SOAPInt"}
+ @@schema_element = [["struct1", ["Echo_struct", XSD::QName.new(nil, "struct1")]], ["struct_2", ["Echo_struct", XSD::QName.new(nil, "struct-2")]]]
+
+ attr_accessor :struct1
+ attr_accessor :struct_2
+
+ def xmlattr_attr_string
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr_string")]
+ end
+
+ def xmlattr_attr_string=(value)
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr_string")] = value
+ end
+
+ def xmlattr_attr_int
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr-int")]
+ end
+
+ def xmlattr_attr_int=(value)
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "attr-int")] = value
+ end
+
+ def initialize(struct1 = nil, struct_2 = nil)
+ @struct1 = struct1
+ @struct_2 = struct_2
+ @__xmlattr = {}
+ end
+end
+
+# {urn:docrpc}echo_struct
+class Echo_struct
+ @@schema_type = "echo_struct"
+ @@schema_ns = "urn:docrpc"
+ @@schema_attribute = {XSD::QName.new(nil, "m_attr") => "SOAP::SOAPString"}
+ @@schema_element = [["m_string", ["SOAP::SOAPString", XSD::QName.new(nil, "m_string")]], ["m_datetime", ["SOAP::SOAPDateTime", XSD::QName.new(nil, "m_datetime")]]]
+
+ attr_accessor :m_string
+ attr_accessor :m_datetime
+
+ def xmlattr_m_attr
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "m_attr")]
+ end
+
+ def xmlattr_m_attr=(value)
+ (@__xmlattr ||= {})[XSD::QName.new(nil, "m_attr")] = value
+ end
+
+ def initialize(m_string = nil, m_datetime = nil)
+ @m_string = m_string
+ @m_datetime = m_datetime
+ @__xmlattr = {}
+ end
+end
diff --git a/test/wsdl/document/number.wsdl b/test/wsdl/document/number.wsdl
new file mode 100644
index 0000000000..cc3dd8e9f0
--- /dev/null
+++ b/test/wsdl/document/number.wsdl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions
+ name="foo"
+ targetNamespace="urn:foo"
+ xmlns:tns="urn:foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema elementFormDefault="unqualified" targetNamespace="urn:foo">
+ <xsd:element name="get_foo">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="number" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </types>
+
+ <message name="get_foo_in">
+ <part name="parameters" element="tns:get_foo" />
+ </message>
+ <message name="get_foo_out">
+ <part name="parameters" type="xsd:string" />
+ </message>
+
+ <portType name="foo_porttype">
+ <operation name="get_foo">
+ <input message="tns:get_foo_in" />
+ <output message="tns:get_foo_out" />
+ </operation>
+ </portType>
+
+ <binding name="foo_binding" type="tns:foo_porttype">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+ style="document" />
+ <operation name="get_foo">
+ <soap:operation soapAction="urn:foo:get_foo" style="document" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ </operation>
+ </binding>
+
+ <service name="foo_service">
+ <port name="foo_service_port" binding="tns:foo_binding">
+ <soap:address location="http://localhost:17171/" />
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/document/ping_nosoapaction.wsdl b/test/wsdl/document/ping_nosoapaction.wsdl
new file mode 100644
index 0000000000..ab9529e456
--- /dev/null
+++ b/test/wsdl/document/ping_nosoapaction.wsdl
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions xmlns:tns="http://xmlsoap.org/Ping"
+xmlns="http://schemas.xmlsoap.org/wsdl/"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+targetNamespace="http://xmlsoap.org/Ping" name="Ping">
+ <types>
+ <schema targetNamespace="http://xmlsoap.org/Ping"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified">
+ <complexType name="ping">
+ <sequence>
+ <element name="scenario" type="xsd:string"
+ nillable="true"/>
+ <element name="origin" type="xsd:string"
+ nillable="true"/>
+ <element name="text" type="xsd:string"
+ nillable="true"/>
+ </sequence>
+ </complexType>
+ <complexType name="pingResponse">
+ <sequence>
+ <element name="scenario" type="xsd:string"
+ nillable="true"/>
+ <element name="origin" type="xsd:string"
+ nillable="true"/>
+ <element name="text" type="xsd:string"
+ nillable="true"/>
+ </sequence>
+ </complexType>
+ <element name="Ping" type="tns:ping"/>
+ <element name="PingResponse" type="tns:pingResponse"/>
+ </schema>
+ </types>
+ <message name="PingRequest">
+ <part name="ping" element="tns:Ping"/>
+ </message>
+ <message name="PingResponse">
+ <part name="pingResponse" element="tns:PingResponse"/>
+ </message>
+ <portType name="PingPort">
+ <operation name="Ping">
+ <input message="tns:PingRequest"/>
+ <output message="tns:PingResponse"/>
+ </operation>
+ </portType>
+ <binding name="PingBinding" type="tns:PingPort">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="Ping">
+ <soap:operation/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="PingService">
+ <port name="PingPort" binding="tns:PingBinding">
+ <soap:address
+ location="http://127.0.0.1:8080/axis/services/PingPort"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/document/test_nosoapaction.rb b/test/wsdl/document/test_nosoapaction.rb
new file mode 100644
index 0000000000..77f642fe1b
--- /dev/null
+++ b/test/wsdl/document/test_nosoapaction.rb
@@ -0,0 +1,109 @@
+require 'test/unit'
+require 'wsdl/parser'
+require 'wsdl/soap/wsdl2ruby'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+require 'soap/rpc/driver'
+
+
+module WSDL; module Document
+
+
+class TestNoSOAPAction < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = 'http://xmlsoap.org/Ping'
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + '/ping',
+ 'ping_with_soapaction',
+ XSD::QName.new(Namespace, 'Ping'),
+ XSD::QName.new(Namespace, 'PingResponse')
+ )
+
+ add_document_method(
+ self,
+ nil,
+ 'ping',
+ XSD::QName.new(Namespace, 'Ping'),
+ XSD::QName.new(Namespace, 'PingResponse')
+ )
+
+ # When no SOAPAction given, latter method(ping) is called.
+ end
+
+ def ping(arg)
+ arg.text = 'ping'
+ arg
+ end
+
+ def ping_with_soapaction(arg)
+ arg.text = 'ping_with_soapaction'
+ arg
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ Port = 17171
+
+ def setup
+ setup_server
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_with_soapaction
+ wsdl = File.join(DIR, 'ping_nosoapaction.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.wiredump_dev = STDOUT if $DEBUG
+ rv = @client.ping(:scenario => 'scenario', :origin => 'origin',
+ :text => 'text')
+ assert_equal('scenario', rv.scenario)
+ assert_equal('origin', rv.origin)
+ assert_equal('ping', rv.text)
+ end
+
+ def test_without_soapaction
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/",
+ Server::Namespace)
+ @client.add_document_method('ping', Server::Namespace + '/ping',
+ XSD::QName.new(Server::Namespace, 'Ping'),
+ XSD::QName.new(Server::Namespace, 'PingResponse'))
+ @client.wiredump_dev = STDOUT if $DEBUG
+ rv = @client.ping(:scenario => 'scenario', :origin => 'origin',
+ :text => 'text')
+ assert_equal('scenario', rv.scenario)
+ assert_equal('origin', rv.origin)
+ assert_equal('ping_with_soapaction', rv.text)
+ end
+end
+
+
+end; end
diff --git a/test/wsdl/document/test_number.rb b/test/wsdl/document/test_number.rb
new file mode 100644
index 0000000000..a640ef2a25
--- /dev/null
+++ b/test/wsdl/document/test_number.rb
@@ -0,0 +1,99 @@
+require 'test/unit'
+require 'wsdl/parser'
+require 'wsdl/soap/wsdl2ruby'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+
+module WSDL; module Document
+
+
+class TestNumber < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = 'urn:foo'
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + ':get_foo',
+ 'get_foo',
+ XSD::QName.new(Namespace, 'get_foo'),
+ XSD::QName.new(Namespace, 'get_foo_response')
+ )
+ end
+
+ def get_foo(arg)
+ arg.number
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_classdef
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ File.unlink(pathname('foo.rb'))
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', "urn:rpc", '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_classdef
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("number.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['force'] = true
+ gen.run
+ require pathname('foo')
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+
+ def test_wsdl
+ wsdl = File.join(DIR, 'number.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.wiredump_dev = STDOUT if $DEBUG
+
+ # with the Struct defined in foo.rb, which is generated from WSDL
+ assert_equal("12345", @client.get_foo(Get_foo.new("12345")))
+
+ # with Hash
+ assert_equal("12345", @client.get_foo({:number => "12345"}))
+
+ # with Original struct
+ get_foo_struct = Struct.new(:number)
+ assert_equal("12345", @client.get_foo(get_foo_struct.new("12345")))
+ end
+end
+
+
+end; end
diff --git a/test/wsdl/document/test_rpc.rb b/test/wsdl/document/test_rpc.rb
new file mode 100644
index 0000000000..56cd0677ad
--- /dev/null
+++ b/test/wsdl/document/test_rpc.rb
@@ -0,0 +1,177 @@
+require 'test/unit'
+require 'wsdl/parser'
+require 'wsdl/soap/wsdl2ruby'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+
+module WSDL; module Document
+
+
+class TestRPC < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = 'urn:docrpc'
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + ':echo',
+ 'echo',
+ XSD::QName.new(Namespace, 'echo'),
+ XSD::QName.new(Namespace, 'echo_response')
+ )
+ end
+
+ def echo(arg)
+ if arg.is_a?(Echoele)
+ # swap args
+ tmp = arg.struct1
+ arg.struct1 = arg.struct_2
+ arg.struct_2 = tmp
+ arg
+ else
+ # swap args
+ tmp = arg["struct1"]
+ arg["struct1"] = arg["struct-2"]
+ arg["struct-2"] = tmp
+ arg
+ end
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_classdef
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ #File.unlink(pathname('echo.rb'))
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', "urn:rpc", '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_classdef
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("document.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['force'] = true
+ gen.run
+ require pathname('echo')
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+
+ def test_wsdl
+ wsdl = File.join(DIR, 'document.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.wiredump_dev = STDOUT if $DEBUG
+
+ struct1 = Echo_struct.new("mystring1", now1 = Time.now)
+ struct1.xmlattr_m_attr = 'myattr1'
+ struct2 = Echo_struct.new("mystring2", now2 = Time.now)
+ struct2.xmlattr_m_attr = 'myattr2'
+ echo = Echoele.new(struct1, struct2)
+ echo.xmlattr_attr_string = 'attr_string'
+ echo.xmlattr_attr_int = 5
+ ret = @client.echo(echo)
+
+ # struct#m_datetime in a response is a DateTime even though
+ # struct#m_datetime in a request is a Time.
+ timeformat = "%Y-%m-%dT%H:%M:%S"
+ assert_equal("mystring2", ret.struct1.m_string)
+ assert_equal(now2.strftime(timeformat),
+ date2time(ret.struct1.m_datetime).strftime(timeformat))
+ assert_equal("mystring1", ret.struct_2.m_string)
+ assert_equal(now1.strftime(timeformat),
+ date2time(ret.struct_2.m_datetime).strftime(timeformat))
+ assert_equal("attr_string", ret.xmlattr_attr_string)
+ assert_equal(5, ret.xmlattr_attr_int)
+ end
+
+ def date2time(date)
+ if date.respond_to?(:to_time)
+ date.to_time
+ else
+ d = date.new_offset(0)
+ d.instance_eval {
+ Time.utc(year, mon, mday, hour, min, sec,
+ (sec_fraction * 86400000000).to_i)
+ }.getlocal
+ end
+ end
+
+ include ::SOAP
+ def test_naive
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/")
+ @client.add_document_method('echo', 'urn:docrpc:echo',
+ XSD::QName.new('urn:docrpc', 'echoele'),
+ XSD::QName.new('urn:docrpc', 'echo_response'))
+ @client.wiredump_dev = STDOUT if $DEBUG
+
+ echo = SOAPElement.new('foo')
+ echo.extraattr['attr_string'] = 'attr_string'
+ echo.extraattr['attr-int'] = 5
+ echo.add(struct1 = SOAPElement.new('struct1'))
+ struct1.add(SOAPElement.new('m_string', 'mystring1'))
+ struct1.add(SOAPElement.new('m_datetime', '2005-03-17T19:47:31+01:00'))
+ struct1.extraattr['m_attr'] = 'myattr1'
+ echo.add(struct2 = SOAPElement.new('struct-2'))
+ struct2.add(SOAPElement.new('m_string', 'mystring2'))
+ struct2.add(SOAPElement.new('m_datetime', '2005-03-17T19:47:32+02:00'))
+ struct2.extraattr['m_attr'] = 'myattr2'
+ ret = @client.echo(echo)
+ timeformat = "%Y-%m-%dT%H:%M:%S"
+ assert_equal('mystring2', ret.struct1.m_string)
+ assert_equal('2005-03-17T19:47:32',
+ ret.struct1.m_datetime.strftime(timeformat))
+ assert_equal("mystring1", ret.struct_2.m_string)
+ assert_equal('2005-03-17T19:47:31',
+ ret.struct_2.m_datetime.strftime(timeformat))
+ assert_equal('attr_string', ret.xmlattr_attr_string)
+ assert_equal(5, ret.xmlattr_attr_int)
+
+ echo = {'struct1' => {'m_string' => 'mystring1', 'm_datetime' => '2005-03-17T19:47:31+01:00'},
+ 'struct-2' => {'m_string' => 'mystring2', 'm_datetime' => '2005-03-17T19:47:32+02:00'}}
+ ret = @client.echo(echo)
+ timeformat = "%Y-%m-%dT%H:%M:%S"
+ assert_equal('mystring2', ret.struct1.m_string)
+ assert_equal('2005-03-17T19:47:32',
+ ret.struct1.m_datetime.strftime(timeformat))
+ assert_equal("mystring1", ret.struct_2.m_string)
+ assert_equal('2005-03-17T19:47:31',
+ ret.struct_2.m_datetime.strftime(timeformat))
+ end
+end
+
+
+end; end
diff --git a/test/wsdl/emptycomplextype.wsdl b/test/wsdl/emptycomplextype.wsdl
new file mode 100644
index 0000000000..4f8dc4849c
--- /dev/null
+++ b/test/wsdl/emptycomplextype.wsdl
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name = "emptycomplextype"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jp.gr.jin.rrr.example.emptycomplextype"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <xsd:schema elementFormDefault="qualified"
+ targetNamespace="urn:jp.gr.jin.rrr.example.emptycomplextype">
+ <xsd:element name="typeIn">
+ <xsd:complexType />
+ </xsd:element>
+
+ <xsd:element name="typeOut">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element minOccurs="0" maxOccurs="1" name="str1" type="xsd:string" />
+ <xsd:element minOccurs="0" maxOccurs="1" name="str2" type="xsd:string" />
+ <xsd:element minOccurs="0" maxOccurs="1" name="seq">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:any />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </types>
+</definitions>
diff --git a/test/wsdl/map/map.wsdl b/test/wsdl/map/map.wsdl
new file mode 100644
index 0000000000..e418a4cbbd
--- /dev/null
+++ b/test/wsdl/map/map.wsdl
@@ -0,0 +1,92 @@
+<?xml version="1.0"?>
+<definitions
+ name="map"
+ targetNamespace="urn:map"
+ xmlns:tns="urn:map"
+ xmlns:txd="urn:map"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:apachesoap="http://xml.apache.org/xml-soap">
+
+ <types>
+ <schema
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://xml.apache.org/xml-soap">
+ <complexType name="Map">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="key" type="xsd:anyType" />
+ <element name="value" type="xsd:anyType" />
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </schema>
+ </types>
+
+ <message name="mapRequest"/>
+ <message name="mapResponse">
+ <part name="return" type="apachesoap:Map"/>
+ </message>
+
+ <message name="map2Request">
+ <part name="arg" type="apachesoap:Map"/>
+ </message>
+ <message name="map2Response">
+ <part name="return" type="apachesoap:Map"/>
+ </message>
+
+ <portType name="MapServicePortType">
+ <operation name="map" parameterOrder="">
+ <input message="tns:mapRequest"/>
+ <output message="tns:mapResponse"/>
+ </operation>
+
+ <operation name="map2" parameterOrder="">
+ <input message="tns:map2Request"/>
+ <output message="tns:map2Response"/>
+ </operation>
+ </portType>
+
+ <binding name="MapServicePortBinding" type="tns:MapServicePortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="map">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:map"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:map"/>
+ </output>
+ </operation>
+
+ <operation name="map2">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:map"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="urn:map"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="MapService">
+ <port name="MapServicePort" binding="tns:MapServicePortBinding">
+ <soap:address location="http://raa.ruby-lang.org/soap/1.0.2/"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/map/map.xml b/test/wsdl/map/map.xml
new file mode 100644
index 0000000000..7106735ffc
--- /dev/null
+++ b/test/wsdl/map/map.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <n2:mapResponse xmlns:n1="http://schemas.xmlsoap.org/soap/encoding/" xmlns:n2="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <return xmlns:n3="http://xml.apache.org/xml-soap" xsi:type="n3:Map">
+ <item>
+ <key xsi:type="xsd:string">a</key>
+ <value xsi:type="n3:Map">
+ <item>
+ <key xsi:type="xsd:string">a1</key>
+ <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]">
+ <item xsi:type="xsd:string">a1</item>
+ </value>
+ </item>
+ <item>
+ <key xsi:type="xsd:string">a2</key>
+ <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]">
+ <item xsi:type="xsd:string">a2</item>
+ </value>
+ </item>
+ </value>
+ </item>
+ <item>
+ <key xsi:type="xsd:string">b</key>
+ <value xsi:type="n3:Map">
+ <item>
+ <key xsi:type="xsd:string">b1</key>
+ <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]">
+ <item xsi:type="xsd:string">b1</item>
+ </value>
+ </item>
+ <item>
+ <key xsi:type="xsd:string">b2</key>
+ <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]">
+ <item xsi:type="xsd:string">b2</item>
+ </value>
+ </item>
+ </value>
+ </item>
+ </return>
+ </n2:mapResponse>
+ </env:Body>
+</env:Envelope>
diff --git a/test/wsdl/map/test_map.rb b/test/wsdl/map/test_map.rb
new file mode 100644
index 0000000000..68f7d76e05
--- /dev/null
+++ b/test/wsdl/map/test_map.rb
@@ -0,0 +1,99 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/wsdlDriver'
+
+
+module WSDL
+
+
+class TestMap < Test::Unit::TestCase
+ Port = 17171
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ class Server < ::SOAP::RPC::HTTPServer
+ def on_init
+ add_method(self, 'map')
+ add_method(self, 'map2', 'arg')
+ end
+
+ def map
+ {1 => "a", 2 => "b"}
+ end
+
+ def map2(arg)
+ arg
+ end
+ end
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => "urn:map"
+ )
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'map.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = true
+ @client.wiredump_dev = STDOUT if $DEBUG
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_by_wsdl
+ dir = File.dirname(File.expand_path(__FILE__))
+ wsdlfile = File.join(dir, 'map.wsdl')
+ xml = File.open(File.join(dir, 'map.xml')) { |f| f.read }
+ wsdl = WSDL::Importer.import(wsdlfile)
+ service = wsdl.services[0]
+ port = service.ports[0]
+ wsdl_types = wsdl.collect_complextypes
+ rpc_decode_typemap = wsdl_types + wsdl.soap_rpc_complextypes(port.find_binding)
+ opt = {}
+ opt[:default_encodingstyle] = ::SOAP::EncodingNamespace
+ opt[:decode_typemap] = rpc_decode_typemap
+ header, body = ::SOAP::Processor.unmarshal(xml, opt)
+ map = ::SOAP::Mapping.soap2obj(body.response)
+ assert_equal(["a1"], map["a"]["a1"])
+ assert_equal(["a2"], map["a"]["a2"])
+ assert_equal(["b1"], map["b"]["b1"])
+ assert_equal(["b2"], map["b"]["b2"])
+ end
+
+ def test_wsdldriver
+ assert_equal({1 => "a", 2 => "b"}, @client.map)
+ assert_equal({1 => 2}, @client.map2({1 => 2}))
+ assert_equal({1 => {2 => 3}}, @client.map2({1 => {2 => 3}}))
+ assert_equal({["a", 2] => {2 => 3}}, @client.map2({["a", 2] => {2 => 3}}))
+ end
+end
+
+
+end
diff --git a/test/wsdl/marshal/person.wsdl b/test/wsdl/marshal/person.wsdl
new file mode 100644
index 0000000000..6ea8a04825
--- /dev/null
+++ b/test/wsdl/marshal/person.wsdl
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<definitions name="Person"
+ targetNamespace="http://www.jin.gr.jp/~nahi/xmlns/sample/Person"
+ xmlns:tns="http://www.jin.gr.jp/~nahi/xmlns/sample/Person"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jin.gr.jp/~nahi/xmlns/sample/Person">
+ <complexType name="Person">
+ <all>
+ <element name="familyname" type="xsd:string"/>
+ <element name="givenname" type="xsd:string"/>
+ <element name="var1" type="xsd:int"/>
+ <element name="var2" type="xsd:double"/>
+ <element name="var3" type="xsd:string"/>
+ </all>
+ </complexType>
+ </xsd:schema>
+ </types>
+</definitions>
diff --git a/test/wsdl/marshal/person_org.rb b/test/wsdl/marshal/person_org.rb
new file mode 100644
index 0000000000..f8c0e0db76
--- /dev/null
+++ b/test/wsdl/marshal/person_org.rb
@@ -0,0 +1,22 @@
+require 'xsd/qname'
+
+# {http://www.jin.gr.jp/~nahi/xmlns/sample/Person}Person
+class Person
+ @@schema_type = "Person"
+ @@schema_ns = "http://www.jin.gr.jp/~nahi/xmlns/sample/Person"
+ @@schema_element = [["familyname", ["SOAP::SOAPString", XSD::QName.new(nil, "familyname")]], ["givenname", ["SOAP::SOAPString", XSD::QName.new(nil, "givenname")]], ["var1", ["SOAP::SOAPInt", XSD::QName.new(nil, "var1")]], ["var2", ["SOAP::SOAPDouble", XSD::QName.new(nil, "var2")]], ["var3", ["SOAP::SOAPString", XSD::QName.new(nil, "var3")]]]
+
+ attr_accessor :familyname
+ attr_accessor :givenname
+ attr_accessor :var1
+ attr_accessor :var2
+ attr_accessor :var3
+
+ def initialize(familyname = nil, givenname = nil, var1 = nil, var2 = nil, var3 = nil)
+ @familyname = familyname
+ @givenname = givenname
+ @var1 = var1
+ @var2 = var2
+ @var3 = var3
+ end
+end
diff --git a/test/wsdl/marshal/test_wsdlmarshal.rb b/test/wsdl/marshal/test_wsdlmarshal.rb
new file mode 100644
index 0000000000..cd2bdb198a
--- /dev/null
+++ b/test/wsdl/marshal/test_wsdlmarshal.rb
@@ -0,0 +1,80 @@
+require 'test/unit'
+require 'wsdl/parser'
+require 'soap/mapping/wsdlencodedregistry'
+require 'soap/marshal'
+require 'wsdl/soap/wsdl2ruby'
+
+class WSDLMarshaller
+ include SOAP
+
+ def initialize(wsdlfile)
+ wsdl = WSDL::Parser.new.parse(File.open(wsdlfile) { |f| f.read })
+ types = wsdl.collect_complextypes
+ @opt = {
+ :decode_typemap => types,
+ :generate_explicit_type => false,
+ :pretty => true
+ }
+ @mapping_registry = Mapping::WSDLEncodedRegistry.new(types)
+ end
+
+ def dump(obj, io = nil)
+ type = Mapping.class2element(obj.class)
+ ele = Mapping.obj2soap(obj, @mapping_registry, type)
+ ele.elename = ele.type
+ Processor.marshal(SOAPEnvelope.new(nil, SOAPBody.new(ele)), @opt, io)
+ end
+
+ def load(io)
+ header, body = Processor.unmarshal(io, @opt)
+ Mapping.soap2obj(body.root_node)
+ end
+end
+
+
+require File.join(File.dirname(__FILE__), 'person_org')
+
+class Person
+ def ==(rhs)
+ @familyname == rhs.familyname and @givenname == rhs.givenname and
+ @var1 == rhs.var1 and @var2 == rhs.var2 and @var3 == rhs.var3
+ end
+end
+
+
+class TestWSDLMarshal < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ def test_marshal
+ marshaller = WSDLMarshaller.new(pathname('person.wsdl'))
+ obj = Person.new("NAKAMURA", "Hiroshi", 1, 1.0, "1")
+ str = marshaller.dump(obj)
+ obj2 = marshaller.load(str)
+ assert_equal(obj, obj2)
+ assert_equal(str, marshaller.dump(obj2))
+ end
+
+ def test_classdef
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("person.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['force'] = true
+ gen.run
+ compare("person_org.rb", "Person.rb")
+ File.unlink(pathname('Person.rb'))
+ end
+
+ def compare(expected, actual)
+ assert_equal(loadfile(expected), loadfile(actual), actual)
+ end
+
+ def loadfile(file)
+ File.open(pathname(file)) { |f| f.read }
+ end
+
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+end
diff --git a/test/wsdl/multiplefault.wsdl b/test/wsdl/multiplefault.wsdl
new file mode 100644
index 0000000000..2d928b60b0
--- /dev/null
+++ b/test/wsdl/multiplefault.wsdl
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<definitions name="MultipleFaultTest"
+ targetNamespace="urn:jp.gr.jin.rrr.example.ele"
+ xmlns:tns="urn:jp.gr.jin.rrr.example.ele"
+ xmlns:typens="urn:jp.gr.jin.rrr.example.datatypes"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jp.gr.jin.rrr.example.datatypes">
+ <xsd:complexType name="AuthenticationError">
+ <all>
+ <element name="message" type="xsd:string" />
+ <element name="backtrace" type="xoapenc:Array" />
+ </all>
+ </xsd:complexType>
+ <xsd:complexType name="AuthorizationError">
+ <all>
+ <element name="message" type="xsd:string" />
+ <element name="backtrace" type="xoapenc:Array" />
+ </all>
+ </xsd:complexType>
+ </xsd:schema>
+ </types>
+
+ <message name="inputmsg"/>
+ <message name="outputmsg"/>
+ <message name="faultmsg1" >
+ <part name="exception" type="typens:AuthenticationError" />
+ </message>
+ <message name="faultmsg2" >
+ <part name="exception" type="typens:AuthorizationError" />
+ </message>
+
+ <portType name="MultipleFaultPortType">
+ <operation name="myoperation">
+ <input message="tns:inputmsg"/>
+ <output message="tns:outputmsg"/>
+ <fault message="tns:faultmsg1"/>
+ <fault message="tns:faultmsg2"/>
+ </operation>
+ </portType>
+
+ <binding name="MultipleFaultBinding" type="tns:MultipleFaultPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="myoperation">
+ <soap:operation soapAction="urn:jp.gr.jin.rrr.example.ele"/>
+ <input>
+ <soap:body use="encoded" namespace="urn:jp.gr.jin.rrr.example.ele"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body use="encoded" namespace="urn:jp.gr.jin.rrr.example.ele"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="MultipleFaultService">
+ <port name="MultipleFaultPortType" binding="tns:MultipleFaultBinding">
+ <soap:address location="http://localhost:17171/"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/qualified/lp.rb b/test/wsdl/qualified/lp.rb
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/wsdl/qualified/lp.rb
diff --git a/test/wsdl/qualified/lp.wsdl b/test/wsdl/qualified/lp.wsdl
new file mode 100644
index 0000000000..b107b7b392
--- /dev/null
+++ b/test/wsdl/qualified/lp.wsdl
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions
+ name="lp"
+ targetNamespace="urn:lp"
+ xmlns:tns="urn:lp"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <schema xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="urn:lp" schemaLocation="lp.xsd"/>
+ </schema>
+ </types>
+
+ <message name="login_in">
+ <part name="parameters" element="tns:login" />
+ </message>
+ <message name="login_out">
+ <part name="parameters" element="tns:loginResponse" />
+ </message>
+
+ <portType name="lp_porttype">
+ <operation name="login">
+ <input message="tns:login_in" />
+ <output message="tns:login_out" />
+ </operation>
+ </portType>
+
+ <binding name="lp_binding" type="tns:lp_porttype">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <operation name="login">
+ <soap:operation soapAction="urn:lp:login" style="document" />
+ <input>
+ <soap:body use="literal" />
+ </input>
+ <output>
+ <soap:body use="literal" />
+ </output>
+ </operation>
+ </binding>
+
+ <service name="lp_service">
+ <port name="lp_service_port" binding="tns:lp_binding">
+ <soap:address location="http://localhost:17171/" />
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/qualified/lp.xsd b/test/wsdl/qualified/lp.xsd
new file mode 100644
index 0000000000..12bcbd8cef
--- /dev/null
+++ b/test/wsdl/qualified/lp.xsd
@@ -0,0 +1,26 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:lp="urn:lp" targetNamespace="urn:lp" elementFormDefault="unqualified">
+
+ <xs:complexType name="login">
+ <xs:sequence>
+ <xs:element name="username" type="xs:string"/>
+ <xs:element name="password" type="xs:string"/>
+ <xs:element name="timezone" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="login" type="lp:login"/>
+
+ <xs:complexType name="loginResponse">
+ <xs:sequence>
+ <xs:element name="loginResult">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="sessionID" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="loginResponse" type="lp:loginResponse"/>
+</xs:schema>
diff --git a/test/wsdl/qualified/np.wsdl b/test/wsdl/qualified/np.wsdl
new file mode 100644
index 0000000000..e2b7253d0e
--- /dev/null
+++ b/test/wsdl/qualified/np.wsdl
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www50.brinkster.com/vbfacileinpt/np" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www50.brinkster.com/vbfacileinpt/np" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <s:schema elementFormDefault="qualified" targetNamespace="http://www50.brinkster.com/vbfacileinpt/np">
+ <s:element name="GetPrimeNumbers">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="Max" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="GetPrimeNumbersResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="GetPrimeNumbersResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ </s:schema>
+ </wsdl:types>
+ <wsdl:message name="GetPrimeNumbersSoapIn">
+ <wsdl:part name="parameters" element="tns:GetPrimeNumbers" />
+ </wsdl:message>
+ <wsdl:message name="GetPrimeNumbersSoapOut">
+ <wsdl:part name="parameters" element="tns:GetPrimeNumbersResponse" />
+ </wsdl:message>
+ <wsdl:portType name="pnumSoap">
+ <wsdl:operation name="GetPrimeNumbers">
+ <wsdl:input message="tns:GetPrimeNumbersSoapIn" />
+ <wsdl:output message="tns:GetPrimeNumbersSoapOut" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="pnumSoap" type="tns:pnumSoap">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <wsdl:operation name="GetPrimeNumbers">
+ <soap:operation soapAction="http://www50.brinkster.com/vbfacileinpt/np/GetPrimeNumbers" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="pnum">
+ <wsdl:port name="pnumSoap" binding="tns:pnumSoap">
+ <soap:address location="http://www50.brinkster.com/vbfacileinpt/np.asmx" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions> \ No newline at end of file
diff --git a/test/wsdl/qualified/test_qualified.rb b/test/wsdl/qualified/test_qualified.rb
new file mode 100644
index 0000000000..d6c1159a87
--- /dev/null
+++ b/test/wsdl/qualified/test_qualified.rb
@@ -0,0 +1,154 @@
+require 'test/unit'
+require 'wsdl/soap/wsdl2ruby'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+if defined?(HTTPAccess2)
+
+module WSDL
+
+
+class TestQualified < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = 'http://www50.brinkster.com/vbfacileinpt/np'
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + '/GetPrimeNumbers',
+ 'GetPrimeNumbers',
+ XSD::QName.new(Namespace, 'GetPrimeNumbers'),
+ XSD::QName.new(Namespace, 'GetPrimeNumbersResponse')
+ )
+ end
+
+ def GetPrimeNumbers(arg)
+ nil
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_clientdef
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ unless $DEBUG
+ File.unlink(pathname('default.rb'))
+ File.unlink(pathname('defaultDriver.rb'))
+ end
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', "urn:lp", '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_clientdef
+ backupdir = Dir.pwd
+ begin
+ Dir.chdir(DIR)
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("np.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['driver'] = nil
+ gen.opt['force'] = true
+ gen.run
+ require pathname('default.rb')
+ ensure
+ Dir.chdir(backupdir)
+ end
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+
+ LOGIN_REQUEST_QUALIFIED_NS =
+%q[<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <n1:GetPrimeNumbers xmlns:n1="http://www50.brinkster.com/vbfacileinpt/np">
+ <n1:Max>10</n1:Max>
+ </n1:GetPrimeNumbers>
+ </env:Body>
+</env:Envelope>]
+
+ LOGIN_REQUEST_QUALIFIED =
+%q[<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <GetPrimeNumbers xmlns="http://www50.brinkster.com/vbfacileinpt/np">
+ <Max>10</Max>
+ </GetPrimeNumbers>
+ </env:Body>
+</env:Envelope>]
+
+ def test_wsdl
+ wsdl = File.join(DIR, 'np.wsdl')
+ @client = nil
+ backupdir = Dir.pwd
+ begin
+ Dir.chdir(DIR)
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ ensure
+ Dir.chdir(backupdir)
+ end
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.wiredump_dev = str = ''
+ @client.GetPrimeNumbers(:Max => 10)
+ assert_equal(LOGIN_REQUEST_QUALIFIED_NS, parse_requestxml(str))
+ end
+
+ include ::SOAP
+ def test_naive
+ backupdir = Dir.pwd
+ begin
+ Dir.chdir(DIR)
+ require pathname('defaultDriver')
+ ensure
+ Dir.chdir(backupdir)
+ end
+ @client = PnumSoap.new("http://localhost:#{Port}/")
+
+ @client.wiredump_dev = str = ''
+ @client.getPrimeNumbers(GetPrimeNumbers.new(10))
+ assert_equal(LOGIN_REQUEST_QUALIFIED, parse_requestxml(str))
+ end
+
+ def parse_requestxml(str)
+ str.split(/\r?\n\r?\n/)[3]
+ end
+end
+
+
+end
+
+end
diff --git a/test/wsdl/qualified/test_unqualified.rb b/test/wsdl/qualified/test_unqualified.rb
new file mode 100644
index 0000000000..bcfed73e58
--- /dev/null
+++ b/test/wsdl/qualified/test_unqualified.rb
@@ -0,0 +1,143 @@
+require 'test/unit'
+require 'wsdl/soap/wsdl2ruby'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+if defined?(HTTPAccess2)
+
+module WSDL
+
+
+class TestUnqualified < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = 'urn:lp'
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + ':login',
+ 'login',
+ XSD::QName.new(Namespace, 'login'),
+ XSD::QName.new(Namespace, 'loginResponse')
+ )
+ end
+
+ def login(arg)
+ nil
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_clientdef
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ File.unlink(pathname('lp.rb'))
+ File.unlink(pathname('lpDriver.rb'))
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', "urn:lp", '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_clientdef
+ backupdir = Dir.pwd
+ begin
+ Dir.chdir(DIR)
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("lp.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['driver'] = nil
+ gen.opt['force'] = true
+ gen.run
+ require pathname('lp')
+ ensure
+ Dir.chdir(backupdir)
+ end
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+
+ LOGIN_REQUEST_QUALIFIED =
+%q[<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <n1:login xmlns:n1="urn:lp">
+ <username>NaHi</username>
+ <password>passwd</password>
+ <timezone>JST</timezone>
+ </n1:login>
+ </env:Body>
+</env:Envelope>]
+
+ def test_wsdl
+ wsdl = File.join(DIR, 'lp.wsdl')
+ @client = nil
+ backupdir = Dir.pwd
+ begin
+ Dir.chdir(DIR)
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ ensure
+ Dir.chdir(backupdir)
+ end
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.wiredump_dev = str = ''
+ @client.login(:timezone => 'JST', :password => 'passwd',
+ :username => 'NaHi')
+ assert_equal(LOGIN_REQUEST_QUALIFIED, parse_requestxml(str))
+ end
+
+ include ::SOAP
+ def test_naive
+ backupdir = Dir.pwd
+ begin
+ Dir.chdir(DIR)
+ require pathname('lpDriver')
+ ensure
+ Dir.chdir(backupdir)
+ end
+ @client = Lp_porttype.new("http://localhost:#{Port}/")
+
+ @client.wiredump_dev = str = ''
+ @client.login(Login.new('NaHi', 'passwd', 'JST'))
+ assert_equal(LOGIN_REQUEST_QUALIFIED, parse_requestxml(str))
+ end
+
+ def parse_requestxml(str)
+ str.split(/\r?\n\r?\n/)[3]
+ end
+end
+
+
+end
+
+end
diff --git a/test/wsdl/raa/RAA.rb b/test/wsdl/raa/RAA.rb
new file mode 100644
index 0000000000..aff0525480
--- /dev/null
+++ b/test/wsdl/raa/RAA.rb
@@ -0,0 +1,243 @@
+# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
+class Category
+ @@schema_type = "Category"
+ @@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+
+ def major
+ @major
+ end
+
+ def major=(value)
+ @major = value
+ end
+
+ def minor
+ @minor
+ end
+
+ def minor=(value)
+ @minor = value
+ end
+
+ def initialize(major = nil,
+ minor = nil)
+ @major = major
+ @minor = minor
+ end
+end
+
+# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
+class Product
+ @@schema_type = "Product"
+ @@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+
+ def id
+ @id
+ end
+
+ def id=(value)
+ @id = value
+ end
+
+ def name
+ @name
+ end
+
+ def name=(value)
+ @name = value
+ end
+
+ def short_description
+ @short_description
+ end
+
+ def short_description=(value)
+ @short_description = value
+ end
+
+ def version
+ @version
+ end
+
+ def version=(value)
+ @version = value
+ end
+
+ def status
+ @status
+ end
+
+ def status=(value)
+ @status = value
+ end
+
+ def homepage
+ @homepage
+ end
+
+ def homepage=(value)
+ @homepage = value
+ end
+
+ def download
+ @download
+ end
+
+ def download=(value)
+ @download = value
+ end
+
+ def license
+ @license
+ end
+
+ def license=(value)
+ @license = value
+ end
+
+ def description
+ @description
+ end
+
+ def description=(value)
+ @description = value
+ end
+
+ def initialize(id = nil,
+ name = nil,
+ short_description = nil,
+ version = nil,
+ status = nil,
+ homepage = nil,
+ download = nil,
+ license = nil,
+ description = nil)
+ @id = id
+ @name = name
+ @short_description = short_description
+ @version = version
+ @status = status
+ @homepage = homepage
+ @download = download
+ @license = license
+ @description = description
+ end
+end
+
+# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
+class Owner
+ @@schema_type = "Owner"
+ @@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+
+ def id
+ @id
+ end
+
+ def id=(value)
+ @id = value
+ end
+
+ def email
+ @email
+ end
+
+ def email=(value)
+ @email = value
+ end
+
+ def name
+ @name
+ end
+
+ def name=(value)
+ @name = value
+ end
+
+ def initialize(id = nil,
+ email = nil,
+ name = nil)
+ @id = id
+ @email = email
+ @name = name
+ end
+end
+
+# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
+class Info
+ @@schema_type = "Info"
+ @@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+
+ def category
+ @category
+ end
+
+ def category=(value)
+ @category = value
+ end
+
+ def product
+ @product
+ end
+
+ def product=(value)
+ @product = value
+ end
+
+ def owner
+ @owner
+ end
+
+ def owner=(value)
+ @owner = value
+ end
+
+ def created
+ @created
+ end
+
+ def created=(value)
+ @created = value
+ end
+
+ def updated
+ @updated
+ end
+
+ def updated=(value)
+ @updated = value
+ end
+
+ def initialize(category = nil,
+ product = nil,
+ owner = nil,
+ created = nil,
+ updated = nil)
+ @category = category
+ @product = product
+ @owner = owner
+ @created = created
+ @updated = updated
+ end
+end
+
+# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
+class InfoArray < Array
+ # Contents type should be dumped here...
+ @@schema_type = "InfoArray"
+ @@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+end
+
+# http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/
+class StringArray < Array
+ # Contents type should be dumped here...
+ @@schema_type = "StringArray"
+ @@schema_ns = "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+end
+
+# http://xml.apache.org/xml-soap
+class Map < Array
+ # Contents type should be dumped here...
+ @@schema_type = "Map"
+ @@schema_ns = "http://xml.apache.org/xml-soap"
+end
+
diff --git a/test/wsdl/raa/RAAServant.rb b/test/wsdl/raa/RAAServant.rb
new file mode 100644
index 0000000000..68380f8e48
--- /dev/null
+++ b/test/wsdl/raa/RAAServant.rb
@@ -0,0 +1,99 @@
+class RAABaseServicePortType
+ # SYNOPSIS
+ # getAllListings
+ #
+ # ARGS
+ # N/A
+ #
+ # RETURNS
+ # return StringArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}StringArray
+ #
+ # RAISES
+ # (undefined)
+ #
+ def getAllListings
+ #raise NotImplementedError.new
+ ["ruby", "soap4r"]
+ end
+
+ # SYNOPSIS
+ # getProductTree
+ #
+ # ARGS
+ # N/A
+ #
+ # RETURNS
+ # return Map - {http://xml.apache.org/xml-soap}Map
+ #
+ # RAISES
+ # (undefined)
+ #
+ def getProductTree
+ raise NotImplementedError.new
+ end
+
+ # SYNOPSIS
+ # getInfoFromCategory(category)
+ #
+ # ARGS
+ # category Category - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Category
+ #
+ # RETURNS
+ # return InfoArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}InfoArray
+ #
+ # RAISES
+ # (undefined)
+ #
+ def getInfoFromCategory(category)
+ raise NotImplementedError.new
+ end
+
+ # SYNOPSIS
+ # getModifiedInfoSince(timeInstant)
+ #
+ # ARGS
+ # timeInstant - {http://www.w3.org/2001/XMLSchema}dateTime
+ #
+ # RETURNS
+ # return InfoArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}InfoArray
+ #
+ # RAISES
+ # (undefined)
+ #
+ def getModifiedInfoSince(timeInstant)
+ raise NotImplementedError.new
+ end
+
+ # SYNOPSIS
+ # getInfoFromName(productName)
+ #
+ # ARGS
+ # productName - {http://www.w3.org/2001/XMLSchema}string
+ #
+ # RETURNS
+ # return Info - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}Info
+ #
+ # RAISES
+ # (undefined)
+ #
+ def getInfoFromName(productName)
+ raise NotImplementedError.new
+ end
+
+ # SYNOPSIS
+ # getInfoFromOwnerId(ownerId)
+ #
+ # ARGS
+ # ownerId - {http://www.w3.org/2001/XMLSchema}int
+ #
+ # RETURNS
+ # return InfoArray - {http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/}InfoArray
+ #
+ # RAISES
+ # (undefined)
+ #
+ def getInfoFromOwnerId(ownerId)
+ raise NotImplementedError.new
+ end
+end
+
diff --git a/test/wsdl/raa/RAAService.rb b/test/wsdl/raa/RAAService.rb
new file mode 100644
index 0000000000..9d0813304c
--- /dev/null
+++ b/test/wsdl/raa/RAAService.rb
@@ -0,0 +1,100 @@
+#!/usr/bin/env ruby
+require 'RAAServant.rb'
+
+require 'soap/rpc/standaloneServer'
+
+class RAABaseServicePortType
+ MappingRegistry = SOAP::Mapping::Registry.new
+
+ MappingRegistry.set(
+ StringArray,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") }
+ )
+ MappingRegistry.set(
+ Map,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "anyType") }
+ )
+ MappingRegistry.set(
+ Category,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category") }
+ )
+ MappingRegistry.set(
+ InfoArray,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }
+ )
+ MappingRegistry.set(
+ Info,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }
+ )
+ MappingRegistry.set(
+ Product,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Product") }
+ )
+ MappingRegistry.set(
+ Owner,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Owner") }
+ )
+
+
+ Methods = [
+ ["getAllListings", "getAllListings", [
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getProductTree", "getProductTree", [
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "anyType"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getInfoFromCategory", "getInfoFromCategory", [
+ ["in", "category",
+ [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]],
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getModifiedInfoSince", "getModifiedInfoSince", [
+ ["in", "timeInstant",
+ [SOAP::SOAPDateTime]],
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getInfoFromName", "getInfoFromName", [
+ ["in", "productName",
+ [SOAP::SOAPString]],
+ ["retval", "return",
+ [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getInfoFromOwnerId", "getInfoFromOwnerId", [
+ ["in", "ownerId",
+ [SOAP::SOAPInt]],
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]], "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"]
+ ]
+end
+
+class App < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+
+ servant = RAABaseServicePortType.new
+ RAABaseServicePortType::Methods.each do |name_as, name, params, soapaction, namespace|
+ qname = XSD::QName.new(namespace, name_as)
+ @router.add_method(servant, qname, soapaction, name, params)
+ end
+
+ self.mapping_registry = RAABaseServicePortType::MappingRegistry
+ end
+end
+
+# Change listen port.
+if $0 == __FILE__
+ App.new('app', nil, '0.0.0.0', 10080).start
+end
diff --git a/test/wsdl/raa/README.txt b/test/wsdl/raa/README.txt
new file mode 100644
index 0000000000..efbaf9d87c
--- /dev/null
+++ b/test/wsdl/raa/README.txt
@@ -0,0 +1,8 @@
+RAAServant.rb: based on the file which is generated with the following command;
+ bin/wsdl2ruby.rb --wsdl raa.wsdl --servant_skelton --force
+
+RAAService.rb: generated with the following command;
+ bin/wsdl2ruby.rb --wsdl raa.wsdl --standalone_server_stub --force
+
+RAA.rb: generated with the following command;
+ bin/wsdl2ruby.rb --wsdl raa.wsdl --classdef --force
diff --git a/test/wsdl/raa/raa.wsdl b/test/wsdl/raa/raa.wsdl
new file mode 100644
index 0000000000..78376893dd
--- /dev/null
+++ b/test/wsdl/raa/raa.wsdl
@@ -0,0 +1,264 @@
+<?xml version="1.0"?>
+<definitions
+ name="RAA"
+ targetNamespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+ xmlns:tns="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+ xmlns:txd="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:apachesoap="http://xml.apache.org/xml-soap">
+
+ <types>
+ <schema
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/">
+
+ <complexType name="Category">
+ <all>
+ <element name="major" type="string"/>
+ <element name="minor" type="string"/>
+ </all>
+ </complexType>
+
+ <complexType name="Product">
+ <all>
+ <element name="id" type="int"/>
+ <element name="name" type="string"/>
+ <element name="short_description" type="string"/>
+ <element name="version" type="string"/>
+ <element name="status" type="string"/>
+ <element name="homepage" type="anyURI"/>
+ <element name="download" type="anyURI"/>
+ <element name="license" type="string"/>
+ <element name="description" type="string"/>
+ </all>
+ </complexType>
+
+ <complexType name="Owner">
+ <all>
+ <element name="id" type="int"/>
+ <element name="email" type="anyURI"/>
+ <element name="name" type="string"/>
+ </all>
+ </complexType>
+
+ <complexType name="Info">
+ <all>
+ <element name="category" type="txd:Category"/>
+ <element name="product" type="txd:Product"/>
+ <element name="owner" type="txd:Owner"/>
+ <element name="created" type="xsd:dateTime"/>
+ <element name="updated" type="xsd:dateTime"/>
+ </all>
+ </complexType>
+
+ <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
+ <complexType name="InfoArray">
+ <complexContent>
+ <restriction base="soapenc:Array">
+ <attribute ref="soapenc:arrayType" wsdl:arrayType="txd:Info[]"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <complexType name="StringArray">
+ <complexContent>
+ <restriction base="soapenc:Array">
+ <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+ </schema>
+
+ <!-- type definition for ApacheSOAP's Map -->
+ <schema
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://xml.apache.org/xml-soap">
+ <complexType name="Map">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="key" type="anyType" />
+ <element name="value" type="anyType" />
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </schema>
+ </types>
+
+ <message name="getAllListingsRequest"/>
+ <message name="getAllListingsResponse">
+ <part name="return" type="txd:StringArray"/>
+ </message>
+
+ <message name="getProductTreeRequest"/>
+ <message name="getProductTreeResponse">
+ <part name="return" type="apachesoap:Map"/>
+ </message>
+
+ <message name="getInfoFromCategoryRequest">
+ <part name="category" type="txd:Category"/>
+ </message>
+ <message name="getInfoFromCategoryResponse">
+ <part name="return" type="txd:InfoArray"/>
+ </message>
+
+ <message name="getModifiedInfoSinceRequest">
+ <part name="timeInstant" type="xsd:dateTime"/>
+ </message>
+ <message name="getModifiedInfoSinceResponse">
+ <part name="return" type="txd:InfoArray"/>
+ </message>
+
+ <message name="getInfoFromNameRequest">
+ <part name="productName" type="xsd:string"/>
+ </message>
+ <message name="getInfoFromNameResponse">
+ <part name="return" type="txd:Info"/>
+ </message>
+
+ <message name="getInfoFromOwnerIdRequest">
+ <part name="ownerId" type="xsd:int"/>
+ </message>
+ <message name="getInfoFromOwnerIdResponse">
+ <part name="return" type="txd:InfoArray"/>
+ </message>
+
+ <portType name="RAABaseServicePortType">
+ <operation name="getAllListings"
+ parameterOrder="">
+ <input message="tns:getAllListingsRequest"/>
+ <output message="tns:getAllListingsResponse"/>
+ </operation>
+
+ <operation name="getProductTree"
+ parameterOrder="">
+ <input message="tns:getProductTreeRequest"/>
+ <output message="tns:getProductTreeResponse"/>
+ </operation>
+
+ <operation name="getInfoFromCategory"
+ parameterOrder="category">
+ <input message="tns:getInfoFromCategoryRequest"/>
+ <output message="tns:getInfoFromCategoryResponse"/>
+ </operation>
+
+ <operation name="getModifiedInfoSince"
+ parameterOrder="timeInstant">
+ <input message="tns:getModifiedInfoSinceRequest"/>
+ <output message="tns:getModifiedInfoSinceResponse"/>
+ </operation>
+
+ <operation name="getInfoFromName"
+ parameterOrder="productName">
+ <input message="tns:getInfoFromNameRequest"/>
+ <output message="tns:getInfoFromNameResponse"/>
+ </operation>
+
+ <operation name="getInfoFromOwnerId"
+ parameterOrder="ownerId">
+ <input message="tns:getInfoFromOwnerIdRequest"/>
+ <output message="tns:getInfoFromOwnerIdResponse"/>
+ </operation>
+ </portType>
+
+ <binding name="RAABaseServicePortBinding" type="tns:RAABaseServicePortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <operation name="getAllListings">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </output>
+ </operation>
+
+ <operation name="getProductTree">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </output>
+ </operation>
+
+ <operation name="getInfoFromCategory">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </output>
+ </operation>
+
+ <operation name="getModifiedInfoSince">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </output>
+ </operation>
+
+ <operation name="getInfoFromName">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </output>
+ </operation>
+
+ <operation name="getInfoFromOwnerId">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="RAAService">
+ <port name="RAABaseServicePort" binding="tns:RAABaseServicePortBinding">
+ <soap:address location="http://raa.ruby-lang.org/soap/1.0.2/"/>
+ </port>
+ </service>
+</definitions>
diff --git a/test/wsdl/raa/server.rb b/test/wsdl/raa/server.rb
new file mode 100644
index 0000000000..87bbc6f569
--- /dev/null
+++ b/test/wsdl/raa/server.rb
@@ -0,0 +1,103 @@
+#!/usr/bin/env ruby
+require 'soap/rpc/standaloneServer'
+require 'RAA.rb'
+
+class RAABaseServicePortType
+ MappingRegistry = SOAP::Mapping::Registry.new
+
+ MappingRegistry.set(
+ StringArray,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") }
+ )
+ MappingRegistry.set(
+ Map,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://xml.apache.org/xml-soap", "Map") }
+ )
+ MappingRegistry.set(
+ Category,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category") }
+ )
+ MappingRegistry.set(
+ InfoArray,
+ ::SOAP::SOAPArray,
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }
+ )
+ MappingRegistry.set(
+ Info,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") }
+ )
+ MappingRegistry.set(
+ Product,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Product") }
+ )
+ MappingRegistry.set(
+ Owner,
+ ::SOAP::SOAPStruct,
+ ::SOAP::Mapping::Registry::TypedStructFactory,
+ { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Owner") }
+ )
+
+ Methods = [
+ ["getAllListings", "getAllListings", [
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.w3.org/2001/XMLSchema", "string"]]],
+ "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getProductTree", "getProductTree", [
+ ["retval", "return",
+ [::SOAP::SOAPStruct, "http://xml.apache.org/xml-soap", "Map"]]],
+ "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getInfoFromCategory", "getInfoFromCategory", [
+ ["in", "category",
+ [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]],
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
+ "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getModifiedInfoSince", "getModifiedInfoSince", [
+ ["in", "timeInstant",
+ [SOAP::SOAPDateTime]],
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
+ "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getInfoFromName", "getInfoFromName", [
+ ["in", "productName",
+ [SOAP::SOAPString]],
+ ["retval", "return",
+ [::SOAP::SOAPStruct, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
+ "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"],
+ ["getInfoFromOwnerId", "getInfoFromOwnerId", [
+ ["in", "ownerId",
+ [SOAP::SOAPInt]],
+ ["retval", "return",
+ [::SOAP::SOAPArray, "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]]],
+ "", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"]
+ ]
+
+ def getAllListings
+ ["ruby", "soap4r"]
+ end
+end
+
+class RAABaseServiceServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+
+ servant = RAABaseServicePortType.new
+ RAABaseServicePortType::Methods.each do |name_as, name, params, soapaction, namespace|
+ qname = XSD::QName.new(namespace, name_as)
+ @router.add_method(servant, qname, soapaction, name, params)
+ end
+
+ self.mapping_registry = RAABaseServicePortType::MappingRegistry
+ end
+end
diff --git a/test/wsdl/raa/test_raa.rb b/test/wsdl/raa/test_raa.rb
new file mode 100644
index 0000000000..0b00042ffb
--- /dev/null
+++ b/test/wsdl/raa/test_raa.rb
@@ -0,0 +1,71 @@
+require 'test/unit'
+require 'soap/wsdlDriver'
+require 'RAA.rb'
+require 'RAAServant.rb'
+require 'RAAService.rb'
+
+
+module WSDL
+module RAA
+
+
+class TestRAA < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = App.new('RAA server', nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'raa.wsdl')
+ @raa = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @raa.endpoint_url = "http://localhost:#{Port}/"
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @raa.reset_stream
+ end
+
+ def test_raa
+ assert_equal(["ruby", "soap4r"], @raa.getAllListings)
+ end
+
+ def foo
+ p @raa.getProductTree()
+ p @raa.getInfoFromCategory(Category.new("Library", "XML"))
+ t = Time.at(Time.now.to_i - 24 * 3600)
+ p @raa.getModifiedInfoSince(t)
+ p @raa.getModifiedInfoSince(DateTime.new(t.year, t.mon, t.mday, t.hour, t.min, t.sec))
+ o = @raa.getInfoFromName("SOAP4R")
+ p o.type
+ p o.owner.name
+ p o
+ end
+end
+
+
+end
+end
diff --git a/test/wsdl/ref/expectedProduct.rb b/test/wsdl/ref/expectedProduct.rb
new file mode 100644
index 0000000000..91c6e4c566
--- /dev/null
+++ b/test/wsdl/ref/expectedProduct.rb
@@ -0,0 +1,90 @@
+require 'xsd/qname'
+
+# {urn:product}Rating
+module Rating
+ C_0 = "0"
+ C_1 = "+1"
+ C_1_2 = "-1"
+end
+
+# {urn:product}Product-Bag
+class ProductBag
+ @@schema_type = "Product-Bag"
+ @@schema_ns = "urn:product"
+ @@schema_attribute = {XSD::QName.new("urn:product", "version") => "SOAP::SOAPString", XSD::QName.new("urn:product", "yesno") => "SOAP::SOAPString"}
+ @@schema_element = [["bag", ["Product[]", XSD::QName.new(nil, "bag")]], ["rating", ["SOAP::SOAPString[]", XSD::QName.new("urn:product", "Rating")]], ["product_Bag", [nil, XSD::QName.new("urn:product", "Product-Bag")]], ["comment_1", [nil, XSD::QName.new(nil, "comment_1")]], ["comment_2", ["Comment[]", XSD::QName.new(nil, "comment-2")]]]
+
+ attr_accessor :bag
+ attr_accessor :product_Bag
+ attr_accessor :comment_1
+ attr_accessor :comment_2
+
+ def Rating
+ @rating
+ end
+
+ def Rating=(value)
+ @rating = value
+ end
+
+ def xmlattr_version
+ (@__xmlattr ||= {})[XSD::QName.new("urn:product", "version")]
+ end
+
+ def xmlattr_version=(value)
+ (@__xmlattr ||= {})[XSD::QName.new("urn:product", "version")] = value
+ end
+
+ def xmlattr_yesno
+ (@__xmlattr ||= {})[XSD::QName.new("urn:product", "yesno")]
+ end
+
+ def xmlattr_yesno=(value)
+ (@__xmlattr ||= {})[XSD::QName.new("urn:product", "yesno")] = value
+ end
+
+ def initialize(bag = [], rating = [], product_Bag = nil, comment_1 = [], comment_2 = [])
+ @bag = bag
+ @rating = rating
+ @product_Bag = product_Bag
+ @comment_1 = comment_1
+ @comment_2 = comment_2
+ @__xmlattr = {}
+ end
+end
+
+# {urn:product}Creator
+class Creator
+ @@schema_type = "Creator"
+ @@schema_ns = "urn:product"
+ @@schema_element = []
+
+ def initialize
+ end
+end
+
+# {urn:product}Product
+class Product
+ @@schema_type = "Product"
+ @@schema_ns = "urn:product"
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], ["rating", ["SOAP::SOAPString", XSD::QName.new("urn:product", "Rating")]]]
+
+ attr_accessor :name
+
+ def Rating
+ @rating
+ end
+
+ def Rating=(value)
+ @rating = value
+ end
+
+ def initialize(name = nil, rating = nil)
+ @name = name
+ @rating = rating
+ end
+end
+
+# {urn:product}Comment
+class Comment < String
+end
diff --git a/test/wsdl/ref/product.wsdl b/test/wsdl/ref/product.wsdl
new file mode 100644
index 0000000000..993fe217aa
--- /dev/null
+++ b/test/wsdl/ref/product.wsdl
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<definitions name="product"
+ targetNamespace="urn:product"
+ xmlns:tns="urn:product"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:product">
+ <simpleType name="non-empty-string">
+ <restriction base="xsd:string">
+ <minLength value="1"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="Product">
+ <all>
+ <element name="name" type="xsd:string"/>
+ <element ref="tns:Rating"/>
+ </all>
+ </complexType>
+
+ <complexType name="Comment">
+ <simpleContent>
+ <extension base="xsd:string">
+ <attribute name="msgid" type="xsd:string" use="required"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <attribute name="version" type="tns:non-empty-string"/>
+
+ <attribute default="Y" name="yesno">
+ <simpleType>
+ <restriction base="xsd:string">
+ <enumeration value="Y"/>
+ <enumeration value="N"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+
+ <element name="Rating">
+ <simpleType>
+ <restriction base="xsd:string">
+ <enumeration value="+1"/>
+ <enumeration value="0"/>
+ <enumeration value="-1"/>
+ </restriction>
+ </simpleType>
+ </element>
+
+ <element name="Product-Bag">
+ <complexType>
+ <sequence>
+ <element name="bag" type="tns:Product" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="tns:Rating" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="tns:Product-Bag"/>
+ <element name="comment_1" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="xsd:string">
+ <attribute name="msgid" type="xsd:string" use="required"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+ <element name="comment-2" type="tns:Comment" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute ref="tns:version"/>
+ <attribute ref="tns:yesno"/>
+ </complexType>
+ </element>
+
+ <element name="Creator" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="xsd:string">
+ <attribute name="Role" type="xs:string" use="required"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+ </xsd:schema>
+ </types>
+</definitions>
diff --git a/test/wsdl/ref/test_ref.rb b/test/wsdl/ref/test_ref.rb
new file mode 100644
index 0000000000..9e29fa31e0
--- /dev/null
+++ b/test/wsdl/ref/test_ref.rb
@@ -0,0 +1,54 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+require 'wsdl/soap/wsdl2ruby'
+
+
+module WSDL
+module Ref
+
+
+class TestRef < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+ Port = 17171
+
+ def test_classdef
+ gen = WSDL::SOAP::WSDL2Ruby.new
+ gen.location = pathname("product.wsdl")
+ gen.basedir = DIR
+ gen.logger.level = Logger::FATAL
+ gen.opt['classdef'] = nil
+ gen.opt['force'] = true
+ suppress_warning do
+ gen.run
+ end
+ compare("expectedProduct.rb", "product.rb")
+ File.unlink(pathname('product.rb'))
+ end
+
+ def compare(expected, actual)
+ assert_equal(loadfile(expected), loadfile(actual), actual)
+ end
+
+ def loadfile(file)
+ File.open(pathname(file)) { |f| f.read }
+ end
+
+ def pathname(filename)
+ File.join(DIR, filename)
+ end
+
+ def suppress_warning
+ back = $VERBOSE
+ $VERBOSE = nil
+ begin
+ yield
+ ensure
+ $VERBOSE = back
+ end
+ end
+end
+
+
+end
+end
diff --git a/test/wsdl/rpc/echoDriver.rb b/test/wsdl/rpc/echoDriver.rb
new file mode 100644
index 0000000000..51e82076e7
--- /dev/null
+++ b/